You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

528 lines
18 KiB

Use legacy schematic plugin for loading schematics in all code paths. Use the legacy plugin schematic loader in the sheet edit and append schematic code paths. Check for fully qualified LIB_ID objects (must have library nickname) when loading existing schematics when edit sheets. Rewrite append schematic feature to handle import issues rather than change the name and file name of all of the sheets in the imported schematic. This includes the following: - Load the schematic into a temporary SCH_SHEET object. - Make sure the imported schematic does not cause any hierarchy recursion issues. - Verify the imported schematic uses fully qualified #LIB_ID objects (symbol library table). - Check to see if any symbol libraries need to be added to the current project's symbol library table. This includes: - Check if the symbol library already exists in the project or global symbol library table. - Convert symbol library URLS that use the ${KIPRJMOD} environment variable to absolute paths. ${KIPRJMOD} will not be the same for this project. - Check for duplicate symbol library nicknames and change the new symbol library nickname to prevent library name clashes. - Update all schematic symbol LIB_ID object library nicknames when the library nickname was changed to prevent clashes. - Check for duplicate sheet names which is illegal and automatically rename any duplicate sheets in the imported schematic. - Clear all of the annotation in the imported schematic to prevent clashes. - Append the objects from the temporary sheet to the current page. - Replace any duplicate time stamps. - Refresh the symbol library links. Add support code to SCH_SCREEN object to assist with schematic import. Doxygen comment cleaning. Fixes lp:1731760 https://bugs.launchpad.net/kicad/+bug/1731760
8 years ago
Use legacy schematic plugin for loading schematics in all code paths. Use the legacy plugin schematic loader in the sheet edit and append schematic code paths. Check for fully qualified LIB_ID objects (must have library nickname) when loading existing schematics when edit sheets. Rewrite append schematic feature to handle import issues rather than change the name and file name of all of the sheets in the imported schematic. This includes the following: - Load the schematic into a temporary SCH_SHEET object. - Make sure the imported schematic does not cause any hierarchy recursion issues. - Verify the imported schematic uses fully qualified #LIB_ID objects (symbol library table). - Check to see if any symbol libraries need to be added to the current project's symbol library table. This includes: - Check if the symbol library already exists in the project or global symbol library table. - Convert symbol library URLS that use the ${KIPRJMOD} environment variable to absolute paths. ${KIPRJMOD} will not be the same for this project. - Check for duplicate symbol library nicknames and change the new symbol library nickname to prevent library name clashes. - Update all schematic symbol LIB_ID object library nicknames when the library nickname was changed to prevent clashes. - Check for duplicate sheet names which is illegal and automatically rename any duplicate sheets in the imported schematic. - Clear all of the annotation in the imported schematic to prevent clashes. - Append the objects from the temporary sheet to the current page. - Replace any duplicate time stamps. - Refresh the symbol library links. Add support code to SCH_SCREEN object to assist with schematic import. Doxygen comment cleaning. Fixes lp:1731760 https://bugs.launchpad.net/kicad/+bug/1731760
8 years ago
* KIWAY Milestone A): Make major modules into DLL/DSOs. ! The initial testing of this commit should be done using a Debug build so that all the wxASSERT()s are enabled. Also, be sure and keep enabled the USE_KIWAY_DLLs option. The tree won't likely build without it. Turning it off is senseless anyways. If you want stable code, go back to a prior version, the one tagged with "stable". * Relocate all functionality out of the wxApp derivative into more finely targeted purposes: a) DLL/DSO specific b) PROJECT specific c) EXE or process specific d) configuration file specific data e) configuration file manipulations functions. All of this functionality was blended into an extremely large wxApp derivative and that was incompatible with the desire to support multiple concurrently loaded DLL/DSO's ("KIFACE")s and multiple concurrently open projects. An amazing amount of organization come from simply sorting each bit of functionality into the proper box. * Switch to wxConfigBase from wxConfig everywhere except instantiation. * Add classes KIWAY, KIFACE, KIFACE_I, SEARCH_STACK, PGM_BASE, PGM_KICAD, PGM_SINGLE_TOP, * Remove "Return" prefix on many function names. * Remove obvious comments from CMakeLists.txt files, and from else() and endif()s. * Fix building boost for use in a DSO on linux. * Remove some of the assumptions in the CMakeLists.txt files that windows had to be the host platform when building windows binaries. * Reduce the number of wxStrings being constructed at program load time via static construction. * Pass wxConfigBase* to all SaveSettings() and LoadSettings() functions so that these functions are useful even when the wxConfigBase comes from another source, as is the case in the KICAD_MANAGER_FRAME. * Move the setting of the KIPRJMOD environment variable into class PROJECT, so that it can be moved into a project variable soon, and out of FP_LIB_TABLE. * Add the KIWAY_PLAYER which is associated with a particular PROJECT, and all its child wxFrames and wxDialogs now have a Kiway() member function which returns a KIWAY& that that window tree branch is in support of. This is like wxWindows DNA in that child windows get this member with proper value at time of construction. * Anticipate some of the needs for milestones B) and C) and make code adjustments now in an effort to reduce work in those milestones. * No testing has been done for python scripting, since milestone C) has that being largely reworked and re-thought-out.
12 years ago
* KIWAY Milestone A): Make major modules into DLL/DSOs. ! The initial testing of this commit should be done using a Debug build so that all the wxASSERT()s are enabled. Also, be sure and keep enabled the USE_KIWAY_DLLs option. The tree won't likely build without it. Turning it off is senseless anyways. If you want stable code, go back to a prior version, the one tagged with "stable". * Relocate all functionality out of the wxApp derivative into more finely targeted purposes: a) DLL/DSO specific b) PROJECT specific c) EXE or process specific d) configuration file specific data e) configuration file manipulations functions. All of this functionality was blended into an extremely large wxApp derivative and that was incompatible with the desire to support multiple concurrently loaded DLL/DSO's ("KIFACE")s and multiple concurrently open projects. An amazing amount of organization come from simply sorting each bit of functionality into the proper box. * Switch to wxConfigBase from wxConfig everywhere except instantiation. * Add classes KIWAY, KIFACE, KIFACE_I, SEARCH_STACK, PGM_BASE, PGM_KICAD, PGM_SINGLE_TOP, * Remove "Return" prefix on many function names. * Remove obvious comments from CMakeLists.txt files, and from else() and endif()s. * Fix building boost for use in a DSO on linux. * Remove some of the assumptions in the CMakeLists.txt files that windows had to be the host platform when building windows binaries. * Reduce the number of wxStrings being constructed at program load time via static construction. * Pass wxConfigBase* to all SaveSettings() and LoadSettings() functions so that these functions are useful even when the wxConfigBase comes from another source, as is the case in the KICAD_MANAGER_FRAME. * Move the setting of the KIPRJMOD environment variable into class PROJECT, so that it can be moved into a project variable soon, and out of FP_LIB_TABLE. * Add the KIWAY_PLAYER which is associated with a particular PROJECT, and all its child wxFrames and wxDialogs now have a Kiway() member function which returns a KIWAY& that that window tree branch is in support of. This is like wxWindows DNA in that child windows get this member with proper value at time of construction. * Anticipate some of the needs for milestones B) and C) and make code adjustments now in an effort to reduce work in those milestones. * No testing has been done for python scripting, since milestone C) has that being largely reworked and re-thought-out.
12 years ago
Use legacy schematic plugin for loading schematics in all code paths. Use the legacy plugin schematic loader in the sheet edit and append schematic code paths. Check for fully qualified LIB_ID objects (must have library nickname) when loading existing schematics when edit sheets. Rewrite append schematic feature to handle import issues rather than change the name and file name of all of the sheets in the imported schematic. This includes the following: - Load the schematic into a temporary SCH_SHEET object. - Make sure the imported schematic does not cause any hierarchy recursion issues. - Verify the imported schematic uses fully qualified #LIB_ID objects (symbol library table). - Check to see if any symbol libraries need to be added to the current project's symbol library table. This includes: - Check if the symbol library already exists in the project or global symbol library table. - Convert symbol library URLS that use the ${KIPRJMOD} environment variable to absolute paths. ${KIPRJMOD} will not be the same for this project. - Check for duplicate symbol library nicknames and change the new symbol library nickname to prevent library name clashes. - Update all schematic symbol LIB_ID object library nicknames when the library nickname was changed to prevent clashes. - Check for duplicate sheet names which is illegal and automatically rename any duplicate sheets in the imported schematic. - Clear all of the annotation in the imported schematic to prevent clashes. - Append the objects from the temporary sheet to the current page. - Replace any duplicate time stamps. - Refresh the symbol library links. Add support code to SCH_SCREEN object to assist with schematic import. Doxygen comment cleaning. Fixes lp:1731760 https://bugs.launchpad.net/kicad/+bug/1731760
8 years ago
Use legacy schematic plugin for loading schematics in all code paths. Use the legacy plugin schematic loader in the sheet edit and append schematic code paths. Check for fully qualified LIB_ID objects (must have library nickname) when loading existing schematics when edit sheets. Rewrite append schematic feature to handle import issues rather than change the name and file name of all of the sheets in the imported schematic. This includes the following: - Load the schematic into a temporary SCH_SHEET object. - Make sure the imported schematic does not cause any hierarchy recursion issues. - Verify the imported schematic uses fully qualified #LIB_ID objects (symbol library table). - Check to see if any symbol libraries need to be added to the current project's symbol library table. This includes: - Check if the symbol library already exists in the project or global symbol library table. - Convert symbol library URLS that use the ${KIPRJMOD} environment variable to absolute paths. ${KIPRJMOD} will not be the same for this project. - Check for duplicate symbol library nicknames and change the new symbol library nickname to prevent library name clashes. - Update all schematic symbol LIB_ID object library nicknames when the library nickname was changed to prevent clashes. - Check for duplicate sheet names which is illegal and automatically rename any duplicate sheets in the imported schematic. - Clear all of the annotation in the imported schematic to prevent clashes. - Append the objects from the temporary sheet to the current page. - Replace any duplicate time stamps. - Refresh the symbol library links. Add support code to SCH_SCREEN object to assist with schematic import. Doxygen comment cleaning. Fixes lp:1731760 https://bugs.launchpad.net/kicad/+bug/1731760
8 years ago
Use legacy schematic plugin for loading schematics in all code paths. Use the legacy plugin schematic loader in the sheet edit and append schematic code paths. Check for fully qualified LIB_ID objects (must have library nickname) when loading existing schematics when edit sheets. Rewrite append schematic feature to handle import issues rather than change the name and file name of all of the sheets in the imported schematic. This includes the following: - Load the schematic into a temporary SCH_SHEET object. - Make sure the imported schematic does not cause any hierarchy recursion issues. - Verify the imported schematic uses fully qualified #LIB_ID objects (symbol library table). - Check to see if any symbol libraries need to be added to the current project's symbol library table. This includes: - Check if the symbol library already exists in the project or global symbol library table. - Convert symbol library URLS that use the ${KIPRJMOD} environment variable to absolute paths. ${KIPRJMOD} will not be the same for this project. - Check for duplicate symbol library nicknames and change the new symbol library nickname to prevent library name clashes. - Update all schematic symbol LIB_ID object library nicknames when the library nickname was changed to prevent clashes. - Check for duplicate sheet names which is illegal and automatically rename any duplicate sheets in the imported schematic. - Clear all of the annotation in the imported schematic to prevent clashes. - Append the objects from the temporary sheet to the current page. - Replace any duplicate time stamps. - Refresh the symbol library links. Add support code to SCH_SCREEN object to assist with schematic import. Doxygen comment cleaning. Fixes lp:1731760 https://bugs.launchpad.net/kicad/+bug/1731760
8 years ago
Use legacy schematic plugin for loading schematics in all code paths. Use the legacy plugin schematic loader in the sheet edit and append schematic code paths. Check for fully qualified LIB_ID objects (must have library nickname) when loading existing schematics when edit sheets. Rewrite append schematic feature to handle import issues rather than change the name and file name of all of the sheets in the imported schematic. This includes the following: - Load the schematic into a temporary SCH_SHEET object. - Make sure the imported schematic does not cause any hierarchy recursion issues. - Verify the imported schematic uses fully qualified #LIB_ID objects (symbol library table). - Check to see if any symbol libraries need to be added to the current project's symbol library table. This includes: - Check if the symbol library already exists in the project or global symbol library table. - Convert symbol library URLS that use the ${KIPRJMOD} environment variable to absolute paths. ${KIPRJMOD} will not be the same for this project. - Check for duplicate symbol library nicknames and change the new symbol library nickname to prevent library name clashes. - Update all schematic symbol LIB_ID object library nicknames when the library nickname was changed to prevent clashes. - Check for duplicate sheet names which is illegal and automatically rename any duplicate sheets in the imported schematic. - Clear all of the annotation in the imported schematic to prevent clashes. - Append the objects from the temporary sheet to the current page. - Replace any duplicate time stamps. - Refresh the symbol library links. Add support code to SCH_SCREEN object to assist with schematic import. Doxygen comment cleaning. Fixes lp:1731760 https://bugs.launchpad.net/kicad/+bug/1731760
8 years ago
Use legacy schematic plugin for loading schematics in all code paths. Use the legacy plugin schematic loader in the sheet edit and append schematic code paths. Check for fully qualified LIB_ID objects (must have library nickname) when loading existing schematics when edit sheets. Rewrite append schematic feature to handle import issues rather than change the name and file name of all of the sheets in the imported schematic. This includes the following: - Load the schematic into a temporary SCH_SHEET object. - Make sure the imported schematic does not cause any hierarchy recursion issues. - Verify the imported schematic uses fully qualified #LIB_ID objects (symbol library table). - Check to see if any symbol libraries need to be added to the current project's symbol library table. This includes: - Check if the symbol library already exists in the project or global symbol library table. - Convert symbol library URLS that use the ${KIPRJMOD} environment variable to absolute paths. ${KIPRJMOD} will not be the same for this project. - Check for duplicate symbol library nicknames and change the new symbol library nickname to prevent library name clashes. - Update all schematic symbol LIB_ID object library nicknames when the library nickname was changed to prevent clashes. - Check for duplicate sheet names which is illegal and automatically rename any duplicate sheets in the imported schematic. - Clear all of the annotation in the imported schematic to prevent clashes. - Append the objects from the temporary sheet to the current page. - Replace any duplicate time stamps. - Refresh the symbol library links. Add support code to SCH_SCREEN object to assist with schematic import. Doxygen comment cleaning. Fixes lp:1731760 https://bugs.launchpad.net/kicad/+bug/1731760
8 years ago
Use legacy schematic plugin for loading schematics in all code paths. Use the legacy plugin schematic loader in the sheet edit and append schematic code paths. Check for fully qualified LIB_ID objects (must have library nickname) when loading existing schematics when edit sheets. Rewrite append schematic feature to handle import issues rather than change the name and file name of all of the sheets in the imported schematic. This includes the following: - Load the schematic into a temporary SCH_SHEET object. - Make sure the imported schematic does not cause any hierarchy recursion issues. - Verify the imported schematic uses fully qualified #LIB_ID objects (symbol library table). - Check to see if any symbol libraries need to be added to the current project's symbol library table. This includes: - Check if the symbol library already exists in the project or global symbol library table. - Convert symbol library URLS that use the ${KIPRJMOD} environment variable to absolute paths. ${KIPRJMOD} will not be the same for this project. - Check for duplicate symbol library nicknames and change the new symbol library nickname to prevent library name clashes. - Update all schematic symbol LIB_ID object library nicknames when the library nickname was changed to prevent clashes. - Check for duplicate sheet names which is illegal and automatically rename any duplicate sheets in the imported schematic. - Clear all of the annotation in the imported schematic to prevent clashes. - Append the objects from the temporary sheet to the current page. - Replace any duplicate time stamps. - Refresh the symbol library links. Add support code to SCH_SCREEN object to assist with schematic import. Doxygen comment cleaning. Fixes lp:1731760 https://bugs.launchpad.net/kicad/+bug/1731760
8 years ago
Use legacy schematic plugin for loading schematics in all code paths. Use the legacy plugin schematic loader in the sheet edit and append schematic code paths. Check for fully qualified LIB_ID objects (must have library nickname) when loading existing schematics when edit sheets. Rewrite append schematic feature to handle import issues rather than change the name and file name of all of the sheets in the imported schematic. This includes the following: - Load the schematic into a temporary SCH_SHEET object. - Make sure the imported schematic does not cause any hierarchy recursion issues. - Verify the imported schematic uses fully qualified #LIB_ID objects (symbol library table). - Check to see if any symbol libraries need to be added to the current project's symbol library table. This includes: - Check if the symbol library already exists in the project or global symbol library table. - Convert symbol library URLS that use the ${KIPRJMOD} environment variable to absolute paths. ${KIPRJMOD} will not be the same for this project. - Check for duplicate symbol library nicknames and change the new symbol library nickname to prevent library name clashes. - Update all schematic symbol LIB_ID object library nicknames when the library nickname was changed to prevent clashes. - Check for duplicate sheet names which is illegal and automatically rename any duplicate sheets in the imported schematic. - Clear all of the annotation in the imported schematic to prevent clashes. - Append the objects from the temporary sheet to the current page. - Replace any duplicate time stamps. - Refresh the symbol library links. Add support code to SCH_SCREEN object to assist with schematic import. Doxygen comment cleaning. Fixes lp:1731760 https://bugs.launchpad.net/kicad/+bug/1731760
8 years ago
Use legacy schematic plugin for loading schematics in all code paths. Use the legacy plugin schematic loader in the sheet edit and append schematic code paths. Check for fully qualified LIB_ID objects (must have library nickname) when loading existing schematics when edit sheets. Rewrite append schematic feature to handle import issues rather than change the name and file name of all of the sheets in the imported schematic. This includes the following: - Load the schematic into a temporary SCH_SHEET object. - Make sure the imported schematic does not cause any hierarchy recursion issues. - Verify the imported schematic uses fully qualified #LIB_ID objects (symbol library table). - Check to see if any symbol libraries need to be added to the current project's symbol library table. This includes: - Check if the symbol library already exists in the project or global symbol library table. - Convert symbol library URLS that use the ${KIPRJMOD} environment variable to absolute paths. ${KIPRJMOD} will not be the same for this project. - Check for duplicate symbol library nicknames and change the new symbol library nickname to prevent library name clashes. - Update all schematic symbol LIB_ID object library nicknames when the library nickname was changed to prevent clashes. - Check for duplicate sheet names which is illegal and automatically rename any duplicate sheets in the imported schematic. - Clear all of the annotation in the imported schematic to prevent clashes. - Append the objects from the temporary sheet to the current page. - Replace any duplicate time stamps. - Refresh the symbol library links. Add support code to SCH_SCREEN object to assist with schematic import. Doxygen comment cleaning. Fixes lp:1731760 https://bugs.launchpad.net/kicad/+bug/1731760
8 years ago
Use legacy schematic plugin for loading schematics in all code paths. Use the legacy plugin schematic loader in the sheet edit and append schematic code paths. Check for fully qualified LIB_ID objects (must have library nickname) when loading existing schematics when edit sheets. Rewrite append schematic feature to handle import issues rather than change the name and file name of all of the sheets in the imported schematic. This includes the following: - Load the schematic into a temporary SCH_SHEET object. - Make sure the imported schematic does not cause any hierarchy recursion issues. - Verify the imported schematic uses fully qualified #LIB_ID objects (symbol library table). - Check to see if any symbol libraries need to be added to the current project's symbol library table. This includes: - Check if the symbol library already exists in the project or global symbol library table. - Convert symbol library URLS that use the ${KIPRJMOD} environment variable to absolute paths. ${KIPRJMOD} will not be the same for this project. - Check for duplicate symbol library nicknames and change the new symbol library nickname to prevent library name clashes. - Update all schematic symbol LIB_ID object library nicknames when the library nickname was changed to prevent clashes. - Check for duplicate sheet names which is illegal and automatically rename any duplicate sheets in the imported schematic. - Clear all of the annotation in the imported schematic to prevent clashes. - Append the objects from the temporary sheet to the current page. - Replace any duplicate time stamps. - Refresh the symbol library links. Add support code to SCH_SCREEN object to assist with schematic import. Doxygen comment cleaning. Fixes lp:1731760 https://bugs.launchpad.net/kicad/+bug/1731760
8 years ago
Use legacy schematic plugin for loading schematics in all code paths. Use the legacy plugin schematic loader in the sheet edit and append schematic code paths. Check for fully qualified LIB_ID objects (must have library nickname) when loading existing schematics when edit sheets. Rewrite append schematic feature to handle import issues rather than change the name and file name of all of the sheets in the imported schematic. This includes the following: - Load the schematic into a temporary SCH_SHEET object. - Make sure the imported schematic does not cause any hierarchy recursion issues. - Verify the imported schematic uses fully qualified #LIB_ID objects (symbol library table). - Check to see if any symbol libraries need to be added to the current project's symbol library table. This includes: - Check if the symbol library already exists in the project or global symbol library table. - Convert symbol library URLS that use the ${KIPRJMOD} environment variable to absolute paths. ${KIPRJMOD} will not be the same for this project. - Check for duplicate symbol library nicknames and change the new symbol library nickname to prevent library name clashes. - Update all schematic symbol LIB_ID object library nicknames when the library nickname was changed to prevent clashes. - Check for duplicate sheet names which is illegal and automatically rename any duplicate sheets in the imported schematic. - Clear all of the annotation in the imported schematic to prevent clashes. - Append the objects from the temporary sheet to the current page. - Replace any duplicate time stamps. - Refresh the symbol library links. Add support code to SCH_SCREEN object to assist with schematic import. Doxygen comment cleaning. Fixes lp:1731760 https://bugs.launchpad.net/kicad/+bug/1731760
8 years ago
Use legacy schematic plugin for loading schematics in all code paths. Use the legacy plugin schematic loader in the sheet edit and append schematic code paths. Check for fully qualified LIB_ID objects (must have library nickname) when loading existing schematics when edit sheets. Rewrite append schematic feature to handle import issues rather than change the name and file name of all of the sheets in the imported schematic. This includes the following: - Load the schematic into a temporary SCH_SHEET object. - Make sure the imported schematic does not cause any hierarchy recursion issues. - Verify the imported schematic uses fully qualified #LIB_ID objects (symbol library table). - Check to see if any symbol libraries need to be added to the current project's symbol library table. This includes: - Check if the symbol library already exists in the project or global symbol library table. - Convert symbol library URLS that use the ${KIPRJMOD} environment variable to absolute paths. ${KIPRJMOD} will not be the same for this project. - Check for duplicate symbol library nicknames and change the new symbol library nickname to prevent library name clashes. - Update all schematic symbol LIB_ID object library nicknames when the library nickname was changed to prevent clashes. - Check for duplicate sheet names which is illegal and automatically rename any duplicate sheets in the imported schematic. - Clear all of the annotation in the imported schematic to prevent clashes. - Append the objects from the temporary sheet to the current page. - Replace any duplicate time stamps. - Refresh the symbol library links. Add support code to SCH_SCREEN object to assist with schematic import. Doxygen comment cleaning. Fixes lp:1731760 https://bugs.launchpad.net/kicad/+bug/1731760
8 years ago
Use legacy schematic plugin for loading schematics in all code paths. Use the legacy plugin schematic loader in the sheet edit and append schematic code paths. Check for fully qualified LIB_ID objects (must have library nickname) when loading existing schematics when edit sheets. Rewrite append schematic feature to handle import issues rather than change the name and file name of all of the sheets in the imported schematic. This includes the following: - Load the schematic into a temporary SCH_SHEET object. - Make sure the imported schematic does not cause any hierarchy recursion issues. - Verify the imported schematic uses fully qualified #LIB_ID objects (symbol library table). - Check to see if any symbol libraries need to be added to the current project's symbol library table. This includes: - Check if the symbol library already exists in the project or global symbol library table. - Convert symbol library URLS that use the ${KIPRJMOD} environment variable to absolute paths. ${KIPRJMOD} will not be the same for this project. - Check for duplicate symbol library nicknames and change the new symbol library nickname to prevent library name clashes. - Update all schematic symbol LIB_ID object library nicknames when the library nickname was changed to prevent clashes. - Check for duplicate sheet names which is illegal and automatically rename any duplicate sheets in the imported schematic. - Clear all of the annotation in the imported schematic to prevent clashes. - Append the objects from the temporary sheet to the current page. - Replace any duplicate time stamps. - Refresh the symbol library links. Add support code to SCH_SCREEN object to assist with schematic import. Doxygen comment cleaning. Fixes lp:1731760 https://bugs.launchpad.net/kicad/+bug/1731760
8 years ago
Use legacy schematic plugin for loading schematics in all code paths. Use the legacy plugin schematic loader in the sheet edit and append schematic code paths. Check for fully qualified LIB_ID objects (must have library nickname) when loading existing schematics when edit sheets. Rewrite append schematic feature to handle import issues rather than change the name and file name of all of the sheets in the imported schematic. This includes the following: - Load the schematic into a temporary SCH_SHEET object. - Make sure the imported schematic does not cause any hierarchy recursion issues. - Verify the imported schematic uses fully qualified #LIB_ID objects (symbol library table). - Check to see if any symbol libraries need to be added to the current project's symbol library table. This includes: - Check if the symbol library already exists in the project or global symbol library table. - Convert symbol library URLS that use the ${KIPRJMOD} environment variable to absolute paths. ${KIPRJMOD} will not be the same for this project. - Check for duplicate symbol library nicknames and change the new symbol library nickname to prevent library name clashes. - Update all schematic symbol LIB_ID object library nicknames when the library nickname was changed to prevent clashes. - Check for duplicate sheet names which is illegal and automatically rename any duplicate sheets in the imported schematic. - Clear all of the annotation in the imported schematic to prevent clashes. - Append the objects from the temporary sheet to the current page. - Replace any duplicate time stamps. - Refresh the symbol library links. Add support code to SCH_SCREEN object to assist with schematic import. Doxygen comment cleaning. Fixes lp:1731760 https://bugs.launchpad.net/kicad/+bug/1731760
8 years ago
Use legacy schematic plugin for loading schematics in all code paths. Use the legacy plugin schematic loader in the sheet edit and append schematic code paths. Check for fully qualified LIB_ID objects (must have library nickname) when loading existing schematics when edit sheets. Rewrite append schematic feature to handle import issues rather than change the name and file name of all of the sheets in the imported schematic. This includes the following: - Load the schematic into a temporary SCH_SHEET object. - Make sure the imported schematic does not cause any hierarchy recursion issues. - Verify the imported schematic uses fully qualified #LIB_ID objects (symbol library table). - Check to see if any symbol libraries need to be added to the current project's symbol library table. This includes: - Check if the symbol library already exists in the project or global symbol library table. - Convert symbol library URLS that use the ${KIPRJMOD} environment variable to absolute paths. ${KIPRJMOD} will not be the same for this project. - Check for duplicate symbol library nicknames and change the new symbol library nickname to prevent library name clashes. - Update all schematic symbol LIB_ID object library nicknames when the library nickname was changed to prevent clashes. - Check for duplicate sheet names which is illegal and automatically rename any duplicate sheets in the imported schematic. - Clear all of the annotation in the imported schematic to prevent clashes. - Append the objects from the temporary sheet to the current page. - Replace any duplicate time stamps. - Refresh the symbol library links. Add support code to SCH_SCREEN object to assist with schematic import. Doxygen comment cleaning. Fixes lp:1731760 https://bugs.launchpad.net/kicad/+bug/1731760
8 years ago
* KIWAY Milestone A): Make major modules into DLL/DSOs. ! The initial testing of this commit should be done using a Debug build so that all the wxASSERT()s are enabled. Also, be sure and keep enabled the USE_KIWAY_DLLs option. The tree won't likely build without it. Turning it off is senseless anyways. If you want stable code, go back to a prior version, the one tagged with "stable". * Relocate all functionality out of the wxApp derivative into more finely targeted purposes: a) DLL/DSO specific b) PROJECT specific c) EXE or process specific d) configuration file specific data e) configuration file manipulations functions. All of this functionality was blended into an extremely large wxApp derivative and that was incompatible with the desire to support multiple concurrently loaded DLL/DSO's ("KIFACE")s and multiple concurrently open projects. An amazing amount of organization come from simply sorting each bit of functionality into the proper box. * Switch to wxConfigBase from wxConfig everywhere except instantiation. * Add classes KIWAY, KIFACE, KIFACE_I, SEARCH_STACK, PGM_BASE, PGM_KICAD, PGM_SINGLE_TOP, * Remove "Return" prefix on many function names. * Remove obvious comments from CMakeLists.txt files, and from else() and endif()s. * Fix building boost for use in a DSO on linux. * Remove some of the assumptions in the CMakeLists.txt files that windows had to be the host platform when building windows binaries. * Reduce the number of wxStrings being constructed at program load time via static construction. * Pass wxConfigBase* to all SaveSettings() and LoadSettings() functions so that these functions are useful even when the wxConfigBase comes from another source, as is the case in the KICAD_MANAGER_FRAME. * Move the setting of the KIPRJMOD environment variable into class PROJECT, so that it can be moved into a project variable soon, and out of FP_LIB_TABLE. * Add the KIWAY_PLAYER which is associated with a particular PROJECT, and all its child wxFrames and wxDialogs now have a Kiway() member function which returns a KIWAY& that that window tree branch is in support of. This is like wxWindows DNA in that child windows get this member with proper value at time of construction. * Anticipate some of the needs for milestones B) and C) and make code adjustments now in an effort to reduce work in those milestones. * No testing has been done for python scripting, since milestone C) has that being largely reworked and re-thought-out.
12 years ago
* KIWAY Milestone A): Make major modules into DLL/DSOs. ! The initial testing of this commit should be done using a Debug build so that all the wxASSERT()s are enabled. Also, be sure and keep enabled the USE_KIWAY_DLLs option. The tree won't likely build without it. Turning it off is senseless anyways. If you want stable code, go back to a prior version, the one tagged with "stable". * Relocate all functionality out of the wxApp derivative into more finely targeted purposes: a) DLL/DSO specific b) PROJECT specific c) EXE or process specific d) configuration file specific data e) configuration file manipulations functions. All of this functionality was blended into an extremely large wxApp derivative and that was incompatible with the desire to support multiple concurrently loaded DLL/DSO's ("KIFACE")s and multiple concurrently open projects. An amazing amount of organization come from simply sorting each bit of functionality into the proper box. * Switch to wxConfigBase from wxConfig everywhere except instantiation. * Add classes KIWAY, KIFACE, KIFACE_I, SEARCH_STACK, PGM_BASE, PGM_KICAD, PGM_SINGLE_TOP, * Remove "Return" prefix on many function names. * Remove obvious comments from CMakeLists.txt files, and from else() and endif()s. * Fix building boost for use in a DSO on linux. * Remove some of the assumptions in the CMakeLists.txt files that windows had to be the host platform when building windows binaries. * Reduce the number of wxStrings being constructed at program load time via static construction. * Pass wxConfigBase* to all SaveSettings() and LoadSettings() functions so that these functions are useful even when the wxConfigBase comes from another source, as is the case in the KICAD_MANAGER_FRAME. * Move the setting of the KIPRJMOD environment variable into class PROJECT, so that it can be moved into a project variable soon, and out of FP_LIB_TABLE. * Add the KIWAY_PLAYER which is associated with a particular PROJECT, and all its child wxFrames and wxDialogs now have a Kiway() member function which returns a KIWAY& that that window tree branch is in support of. This is like wxWindows DNA in that child windows get this member with proper value at time of construction. * Anticipate some of the needs for milestones B) and C) and make code adjustments now in an effort to reduce work in those milestones. * No testing has been done for python scripting, since milestone C) has that being largely reworked and re-thought-out.
12 years ago
Use legacy schematic plugin for loading schematics in all code paths. Use the legacy plugin schematic loader in the sheet edit and append schematic code paths. Check for fully qualified LIB_ID objects (must have library nickname) when loading existing schematics when edit sheets. Rewrite append schematic feature to handle import issues rather than change the name and file name of all of the sheets in the imported schematic. This includes the following: - Load the schematic into a temporary SCH_SHEET object. - Make sure the imported schematic does not cause any hierarchy recursion issues. - Verify the imported schematic uses fully qualified #LIB_ID objects (symbol library table). - Check to see if any symbol libraries need to be added to the current project's symbol library table. This includes: - Check if the symbol library already exists in the project or global symbol library table. - Convert symbol library URLS that use the ${KIPRJMOD} environment variable to absolute paths. ${KIPRJMOD} will not be the same for this project. - Check for duplicate symbol library nicknames and change the new symbol library nickname to prevent library name clashes. - Update all schematic symbol LIB_ID object library nicknames when the library nickname was changed to prevent clashes. - Check for duplicate sheet names which is illegal and automatically rename any duplicate sheets in the imported schematic. - Clear all of the annotation in the imported schematic to prevent clashes. - Append the objects from the temporary sheet to the current page. - Replace any duplicate time stamps. - Refresh the symbol library links. Add support code to SCH_SCREEN object to assist with schematic import. Doxygen comment cleaning. Fixes lp:1731760 https://bugs.launchpad.net/kicad/+bug/1731760
8 years ago
Use legacy schematic plugin for loading schematics in all code paths. Use the legacy plugin schematic loader in the sheet edit and append schematic code paths. Check for fully qualified LIB_ID objects (must have library nickname) when loading existing schematics when edit sheets. Rewrite append schematic feature to handle import issues rather than change the name and file name of all of the sheets in the imported schematic. This includes the following: - Load the schematic into a temporary SCH_SHEET object. - Make sure the imported schematic does not cause any hierarchy recursion issues. - Verify the imported schematic uses fully qualified #LIB_ID objects (symbol library table). - Check to see if any symbol libraries need to be added to the current project's symbol library table. This includes: - Check if the symbol library already exists in the project or global symbol library table. - Convert symbol library URLS that use the ${KIPRJMOD} environment variable to absolute paths. ${KIPRJMOD} will not be the same for this project. - Check for duplicate symbol library nicknames and change the new symbol library nickname to prevent library name clashes. - Update all schematic symbol LIB_ID object library nicknames when the library nickname was changed to prevent clashes. - Check for duplicate sheet names which is illegal and automatically rename any duplicate sheets in the imported schematic. - Clear all of the annotation in the imported schematic to prevent clashes. - Append the objects from the temporary sheet to the current page. - Replace any duplicate time stamps. - Refresh the symbol library links. Add support code to SCH_SCREEN object to assist with schematic import. Doxygen comment cleaning. Fixes lp:1731760 https://bugs.launchpad.net/kicad/+bug/1731760
8 years ago
Use legacy schematic plugin for loading schematics in all code paths. Use the legacy plugin schematic loader in the sheet edit and append schematic code paths. Check for fully qualified LIB_ID objects (must have library nickname) when loading existing schematics when edit sheets. Rewrite append schematic feature to handle import issues rather than change the name and file name of all of the sheets in the imported schematic. This includes the following: - Load the schematic into a temporary SCH_SHEET object. - Make sure the imported schematic does not cause any hierarchy recursion issues. - Verify the imported schematic uses fully qualified #LIB_ID objects (symbol library table). - Check to see if any symbol libraries need to be added to the current project's symbol library table. This includes: - Check if the symbol library already exists in the project or global symbol library table. - Convert symbol library URLS that use the ${KIPRJMOD} environment variable to absolute paths. ${KIPRJMOD} will not be the same for this project. - Check for duplicate symbol library nicknames and change the new symbol library nickname to prevent library name clashes. - Update all schematic symbol LIB_ID object library nicknames when the library nickname was changed to prevent clashes. - Check for duplicate sheet names which is illegal and automatically rename any duplicate sheets in the imported schematic. - Clear all of the annotation in the imported schematic to prevent clashes. - Append the objects from the temporary sheet to the current page. - Replace any duplicate time stamps. - Refresh the symbol library links. Add support code to SCH_SCREEN object to assist with schematic import. Doxygen comment cleaning. Fixes lp:1731760 https://bugs.launchpad.net/kicad/+bug/1731760
8 years ago
Modular-Kicad milestone B), major portions: *) Rework the set language support, simplify it by using KIWAY. Now any major frame with a "change language" menu can change the language for all KIWAY_PLAYERs in the whole KIWAY. Multiple KIWAYs are not supported yet. *) Simplify "modal wxFrame" support, and add that support exclusively to KIWAY_PLAYER where it is inherited by all derivatives. The function KIWAY_PLAYER::ShowModal() is in the vtable and so is cross module capable. *) Remove the requirements and assumptions that the wxFrame hierarchy always had PCB_EDIT_FRAME and SCH_EDIT_FRAME as immediate parents of their viewers and editors. This is no longer the case, nor required. *) Use KIWAY::Player() everywhere to make KIWAY_PLAYERs, this registers the KIWAY_PLAYER within the KIWAY and makes it very easy to find an open frame quickly. It also gives control to the KIWAY as to frame hierarchical relationships. *) Change single_top to use the KIWAY for loading a KIFACE and instantiating the single KIWAY_PLAYER, see bullet immediately above. *) Add KIWAY::OnKiwayEnd() and call it from PGM_BASE at program termination, this gives the KIFACEs a chance to save their final configuration dope to disk. *) Add dedicated FRAME_T's for the modal frames, so m_Ident can be tested and these modal frames are distinctly different than their non-modal equivalents. KIWAY_PLAYER::IsModal() is !not! a valid test during the wxFrame's constructor, so this is another important reason for having a dedicated FRAME_T for each modal wxFrame. On balance, more lines were deleted than were added to achieve all this.
12 years ago
18 years ago
  1. /*
  2. * This program source code file is part of KiCad, a free EDA CAD application.
  3. *
  4. * Copyright (C) 2015 Jean-Pierre Charras, jp.charras at wanadoo.fr
  5. * Copyright (C) 2004-2018 KiCad Developers, see change_log.txt for contributors.
  6. *
  7. * This program is free software; you can redistribute it and/or
  8. * modify it under the terms of the GNU General Public License
  9. * as published by the Free Software Foundation; either version 2
  10. * of the License, or (at your option) any later version.
  11. *
  12. * This program is distributed in the hope that it will be useful,
  13. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  15. * GNU General Public License for more details.
  16. *
  17. * You should have received a copy of the GNU General Public License
  18. * along with this program; if not, you may find one here:
  19. * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
  20. * or you may search the http://www.gnu.org website for the version 2 license,
  21. * or you may write to the Free Software Foundation, Inc.,
  22. * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
  23. */
  24. /**
  25. * @file sheet.cpp
  26. */
  27. #include <fctsys.h>
  28. #include <class_drawpanel.h>
  29. #include <confirm.h>
  30. #include <base_units.h>
  31. #include <kiface_i.h>
  32. #include <project.h>
  33. #include <wildcards_and_files_ext.h>
  34. #include <sch_edit_frame.h>
  35. #include <sch_legacy_plugin.h>
  36. #include <sch_sheet.h>
  37. #include <sch_sheet_path.h>
  38. #include <dialogs/dialog_sch_sheet_props.h>
  39. bool SCH_EDIT_FRAME::EditSheet( SCH_SHEET* aSheet, SCH_SHEET_PATH* aHierarchy )
  40. {
  41. if( aSheet == NULL || aHierarchy == NULL )
  42. return false;
  43. SCH_SHEET_LIST hierarchy( g_RootSheet ); // This is the schematic sheet hierarchy.
  44. // Get the new texts
  45. DIALOG_SCH_SHEET_PROPS dlg( this );
  46. wxString units = GetUnitsLabel( g_UserUnit );
  47. dlg.SetFileName( aSheet->GetFileName() );
  48. dlg.SetFileNameTextSize( StringFromValue( g_UserUnit, aSheet->GetFileNameSize() ) );
  49. dlg.SetFileNameTextSizeUnits( units );
  50. dlg.SetSheetName( aSheet->GetName() );
  51. dlg.SetSheetNameTextSize( StringFromValue( g_UserUnit, aSheet->GetSheetNameSize() ) );
  52. dlg.SetSheetNameTextSizeUnits( units );
  53. dlg.SetSheetTimeStamp( wxString::Format( wxT( "%8.8lX" ),
  54. (unsigned long) aSheet->GetTimeStamp() ) );
  55. /* This ugly hack fixes a bug in wxWidgets 2.8.7 and likely earlier
  56. * versions for the flex grid sizer in wxGTK that prevents the last
  57. * column from being sized correctly. It doesn't cause any problems
  58. * on win32 so it doesn't need to wrapped in ugly #ifdef __WXGTK__
  59. * #endif.
  60. * Still present in wxWidgets 3.0.2
  61. */
  62. dlg.Layout();
  63. dlg.Fit();
  64. dlg.SetMinSize( dlg.GetSize() );
  65. dlg.GetSizer()->Fit( &dlg );
  66. if( dlg.ShowModal() == wxID_CANCEL )
  67. return false;
  68. wxFileName fileName = dlg.GetFileName();
  69. fileName.SetExt( SchematicFileExtension );
  70. if( !fileName.IsOk() )
  71. {
  72. DisplayError( this, _( "File name is not valid!" ) );
  73. return false;
  74. }
  75. // Duplicate sheet names are not valid.
  76. const SCH_SHEET* sheet = hierarchy.FindSheetByName( dlg.GetSheetName() );
  77. if( sheet && (sheet != aSheet) )
  78. {
  79. DisplayError( this, wxString::Format( _( "A sheet named \"%s\" already exists." ),
  80. dlg.GetSheetName() ) );
  81. return false;
  82. }
  83. wxString msg;
  84. bool loadFromFile = false;
  85. bool clearAnnotation = false;
  86. SCH_SCREEN* useScreen = NULL;
  87. // Relative file names are relative to the path of the current sheet. This allows for
  88. // nesting of schematic files in subfolders.
  89. if( !fileName.IsAbsolute() )
  90. {
  91. const SCH_SCREEN* currentScreen = aHierarchy->LastScreen();
  92. wxCHECK_MSG( currentScreen, false, "Invalid sheet path object." );
  93. wxFileName currentSheetFileName = currentScreen->GetFileName();
  94. wxCHECK_MSG( fileName.Normalize( wxPATH_NORM_ALL, currentSheetFileName.GetPath() ), false,
  95. "Cannot normalize new sheet schematic file path." );
  96. }
  97. wxString newFilename = fileName.GetFullPath();
  98. // Search for a schematic file having the same filename
  99. // already in use in the hierarchy or on disk, in order to reuse it.
  100. if( !g_RootSheet->SearchHierarchy( newFilename, &useScreen ) )
  101. {
  102. loadFromFile = wxFileExists( newFilename );
  103. wxLogDebug( "Sheet requested file \"%s\", %s", newFilename,
  104. ( loadFromFile ) ? "found" : "not found" );
  105. }
  106. // Inside Eeschema, filenames are stored using unix notation
  107. newFilename.Replace( wxT( "\\" ), wxT( "/" ) );
  108. SCH_PLUGIN::SCH_PLUGIN_RELEASER pi( SCH_IO_MGR::FindPlugin( SCH_IO_MGR::SCH_LEGACY ) );
  109. if( aSheet->GetScreen() == NULL ) // New sheet.
  110. {
  111. if( useScreen || loadFromFile ) // Load from existing file.
  112. {
  113. clearAnnotation = true;
  114. wxString existsMsg;
  115. wxString linkMsg;
  116. existsMsg.Printf( _( "\"%s\" already exists." ), fileName.GetFullName() );
  117. linkMsg.Printf( _( "Link \"%s\" to this file?" ), dlg.GetSheetName() );
  118. msg.Printf( wxT( "%s\n\n%s" ), existsMsg, linkMsg );
  119. if( !IsOK( this, msg ) )
  120. return false;
  121. }
  122. else // New file.
  123. {
  124. aSheet->SetScreen( new SCH_SCREEN( &Kiway() ) );
  125. aSheet->GetScreen()->SetModify();
  126. aSheet->GetScreen()->SetMaxUndoItems( m_UndoRedoCountMax );
  127. aSheet->GetScreen()->SetFileName( newFilename );
  128. }
  129. }
  130. else // Existing sheet.
  131. {
  132. bool isUndoable = true;
  133. bool renameFile = false;
  134. wxString replaceMsg;
  135. wxString newMsg;
  136. wxString noUndoMsg;
  137. replaceMsg.Printf( _( "Change \"%s\" link from \"%s\" to \"%s\"?" ),
  138. dlg.GetSheetName(), aSheet->GetFileName(), fileName.GetFullName() );
  139. newMsg.Printf( _( "Create new file \"%s\" with contents of \"%s\"?" ),
  140. fileName.GetFullName(), aSheet->GetFileName() );
  141. noUndoMsg = _( "This action cannot be undone." );
  142. // We are always using here a case insensitive comparison
  143. // to avoid issues under Windows, although under Unix
  144. // filenames are case sensitive.
  145. // But many users create schematic under both Unix and Windows
  146. // **
  147. // N.B. aSheet->GetFileName() will return a relative path
  148. // aSheet->GetScreen()->GetFileName() returns a full path
  149. if( newFilename.CmpNoCase( aSheet->GetScreen()->GetFileName() ) != 0 )
  150. {
  151. // Sheet file name changes cannot be undone.
  152. isUndoable = false;
  153. if( useScreen || loadFromFile ) // Load from existing file.
  154. {
  155. clearAnnotation = true;
  156. msg.Printf( wxT( "%s\n\n%s" ), replaceMsg, noUndoMsg );
  157. if( !IsOK( this, msg ) )
  158. return false;
  159. if( loadFromFile )
  160. aSheet->SetScreen( NULL );
  161. }
  162. else // Save to new file name.
  163. {
  164. if( aSheet->GetScreenCount() > 1 )
  165. {
  166. msg.Printf( wxT( "%s\n\n%s" ), newMsg, noUndoMsg );
  167. if( !IsOK( this, msg ) )
  168. return false;
  169. }
  170. renameFile = true;
  171. }
  172. }
  173. m_canvas->SetIgnoreMouseEvents( true );
  174. if( isUndoable )
  175. SaveCopyInUndoList( aSheet, UR_CHANGED );
  176. if( renameFile )
  177. {
  178. aSheet->GetScreen()->SetFileName( newFilename );
  179. try
  180. {
  181. pi->Save( newFilename, aSheet->GetScreen(), &Kiway() );
  182. }
  183. catch( const IO_ERROR& ioe )
  184. {
  185. msg.Printf( _( "Error occurred saving schematic file \"%s\"." ), newFilename );
  186. DisplayErrorMessage( this, msg, ioe.What() );
  187. msg.Printf( _( "Failed to save schematic \"%s\"" ), newFilename );
  188. AppendMsgPanel( wxEmptyString, msg, CYAN );
  189. return false;
  190. }
  191. // If the the associated screen is shared by more than one sheet, remove the
  192. // screen and reload the file to a new screen. Failure to do this will trash
  193. // the screen reference counting in complex hierarchies.
  194. if( aSheet->GetScreenCount() > 1 )
  195. {
  196. aSheet->SetScreen( NULL );
  197. loadFromFile = true;
  198. }
  199. }
  200. }
  201. wxFileName userFileName = dlg.GetFileName();
  202. userFileName.SetExt( SchematicFileExtension );
  203. aSheet->SetFileName( userFileName.GetFullPath( wxPATH_UNIX ) );
  204. if( useScreen )
  205. {
  206. aSheet->SetScreen( useScreen );
  207. }
  208. else if( loadFromFile )
  209. {
  210. try
  211. {
  212. aSheet = pi->Load( newFilename, &Kiway(), aSheet );
  213. if( !pi->GetError().IsEmpty() )
  214. {
  215. DisplayErrorMessage( this,
  216. _( "The entire schematic could not be load. Errors "
  217. "occurred attempting to load hierarchical sheet "
  218. "schematics." ),
  219. pi->GetError() );
  220. }
  221. }
  222. catch( const IO_ERROR& ioe )
  223. {
  224. msg.Printf( _( "Error occurred loading schematic file \"%s\"." ), newFilename );
  225. DisplayErrorMessage( this, msg, ioe.What() );
  226. msg.Printf( _( "Failed to load schematic \"%s\"" ), newFilename );
  227. AppendMsgPanel( wxEmptyString, msg, CYAN );
  228. return false;
  229. }
  230. }
  231. aSheet->SetFileNameSize( ValueFromString( g_UserUnit, dlg.GetFileNameTextSize() ) );
  232. aSheet->SetName( dlg.GetSheetName() );
  233. aSheet->SetSheetNameSize( ValueFromString( g_UserUnit, dlg.GetSheetNameTextSize() ) );
  234. if( aSheet->GetName().IsEmpty() )
  235. aSheet->SetName( wxString::Format( wxT( "Sheet%8.8lX" ),
  236. (long unsigned) aSheet->GetTimeStamp() ) );
  237. // Make sure the sheet changes do not cause any recursion.
  238. SCH_SHEET_LIST sheetHierarchy( aSheet );
  239. // Make sure files have fully qualified path and file name.
  240. wxFileName destFn = aHierarchy->Last()->GetFileName();
  241. if( destFn.IsRelative() )
  242. destFn.MakeAbsolute( Prj().GetProjectPath() );
  243. if( hierarchy.TestForRecursion( sheetHierarchy, destFn.GetFullPath( wxPATH_UNIX ) ) )
  244. {
  245. msg.Printf( _( "The sheet changes cannot be made because the destination sheet already "
  246. "has the sheet \"%s\" or one of it's subsheets as a parent somewhere in "
  247. "the schematic hierarchy." ),
  248. newFilename );
  249. DisplayError( this, msg );
  250. return false;
  251. }
  252. // Check to make sure the symbols have been remapped to the symbol library table.
  253. SCH_SCREENS newScreens( aSheet );
  254. if( newScreens.HasNoFullyDefinedLibIds() )
  255. {
  256. msg.Printf(_( "The schematic \"%s\" has not been remapped to the symbol library table. "
  257. "Most if not all of the symbol library links will be broken. Do you "
  258. "want to continue?" ), fileName.GetFullName() );
  259. if( !IsOK( this, msg ) )
  260. return false;
  261. }
  262. if( clearAnnotation )
  263. {
  264. newScreens.ClearAnnotation();
  265. }
  266. m_canvas->MoveCursorToCrossHair();
  267. m_canvas->SetIgnoreMouseEvents( false );
  268. OnModify();
  269. return true;
  270. }
  271. /* Move selected sheet with the cursor.
  272. * Callback function used by m_mouseCaptureCallback.
  273. * Note also now this function is called only when resizing the sheet
  274. * But the (very small code) relative to sheet move is still present here
  275. */
  276. static void resizeSheetWithMouseCursor( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint& aPosition,
  277. bool aErase )
  278. {
  279. BASE_SCREEN* screen = aPanel->GetScreen();
  280. SCH_SHEET* sheet = dynamic_cast<SCH_SHEET*>( screen->GetCurItem() );
  281. if( sheet == nullptr ) // Be sure we are using the right object
  282. return;
  283. if( aErase )
  284. sheet->Draw( aPanel, aDC, wxPoint( 0, 0 ), g_XorMode );
  285. wxPoint pos = sheet->GetPosition();
  286. int width = aPanel->GetParent()->GetCrossHairPosition().x - pos.x;
  287. int height = aPanel->GetParent()->GetCrossHairPosition().y - pos.y;
  288. // If the sheet doesn't have any pins, clamp the minimum size to the default values.
  289. width = ( width < MIN_SHEET_WIDTH ) ? MIN_SHEET_WIDTH : width;
  290. height = ( height < MIN_SHEET_HEIGHT ) ? MIN_SHEET_HEIGHT : height;
  291. if( sheet->HasPins() )
  292. {
  293. int gridSizeX = KiROUND( screen->GetGridSize().x );
  294. int gridSizeY = KiROUND( screen->GetGridSize().y );
  295. // If the sheet has pins, use the pin positions to clamp the minimum width and height.
  296. height = ( height < sheet->GetMinHeight() + gridSizeY ) ?
  297. sheet->GetMinHeight() + gridSizeY : height;
  298. width = ( width < sheet->GetMinWidth() + gridSizeX ) ?
  299. sheet->GetMinWidth() + gridSizeX : width;
  300. }
  301. wxPoint grid = aPanel->GetParent()->GetNearestGridPosition(
  302. wxPoint( pos.x + width, pos.y + height ) );
  303. sheet->Resize( wxSize( grid.x - pos.x, grid.y - pos.y ) );
  304. sheet->Draw( aPanel, aDC, wxPoint( 0, 0 ), g_XorMode );
  305. }
  306. // Complete sheet move.
  307. static void ExitSheet( EDA_DRAW_PANEL* aPanel, wxDC* aDC )
  308. {
  309. SCH_SCREEN* screen = (SCH_SCREEN*) aPanel->GetScreen();
  310. SCH_ITEM* item = screen->GetCurItem();
  311. SCH_EDIT_FRAME* parent = (SCH_EDIT_FRAME*) aPanel->GetParent();
  312. if( (item == NULL) || (item->Type() != SCH_SHEET_T) || (parent == NULL) )
  313. return;
  314. parent->SetRepeatItem( NULL );
  315. item->Draw( aPanel, aDC, wxPoint( 0, 0 ), g_XorMode );
  316. if( item->IsNew() )
  317. {
  318. delete item;
  319. }
  320. else if( item->IsMoving() || item->IsResized() )
  321. {
  322. screen->Remove( item );
  323. delete item;
  324. item = parent->GetUndoItem();
  325. wxCHECK_RET( item != NULL, wxT( "Cannot restore undefined last sheet item." ) );
  326. screen->Append( item );
  327. // the owner of item is no more parent, this is the draw list of screen:
  328. parent->SetUndoItem( NULL );
  329. item->Draw( aPanel, aDC, wxPoint( 0, 0 ), GR_DEFAULT_DRAWMODE );
  330. item->ClearFlags();
  331. }
  332. else
  333. {
  334. item->ClearFlags();
  335. }
  336. screen->SetCurItem( NULL );
  337. }
  338. // Create hierarchy sheet.
  339. SCH_SHEET* SCH_EDIT_FRAME::CreateSheet( wxDC* aDC )
  340. {
  341. SetRepeatItem( NULL );
  342. SCH_SHEET* sheet = new SCH_SHEET( GetCrossHairPosition() );
  343. sheet->SetFlags( IS_NEW | IS_RESIZED );
  344. sheet->SetTimeStamp( GetNewTimeStamp() );
  345. sheet->SetParent( GetScreen() );
  346. sheet->SetScreen( NULL );
  347. // need to check if this is being added to the GetDrawItems().
  348. // also need to update the hierarchy, if we are adding
  349. // a sheet to a screen that already has multiple instances (!)
  350. GetScreen()->SetCurItem( sheet );
  351. m_canvas->SetMouseCapture( resizeSheetWithMouseCursor, ExitSheet );
  352. m_canvas->CallMouseCapture( aDC, wxDefaultPosition, false );
  353. m_canvas->CrossHairOff( aDC );
  354. SetCrossHairPosition( sheet->GetResizePosition() );
  355. m_canvas->MoveCursorToCrossHair();
  356. m_canvas->CrossHairOn( aDC );
  357. return sheet;
  358. }
  359. void SCH_EDIT_FRAME::ReSizeSheet( SCH_SHEET* aSheet, wxDC* aDC )
  360. {
  361. if( aSheet == NULL || aSheet->IsNew() )
  362. return;
  363. wxCHECK_RET( aSheet->Type() == SCH_SHEET_T,
  364. wxString::Format( wxT( "Cannot perform sheet resize on %s object." ),
  365. GetChars( aSheet->GetClass() ) ) );
  366. m_canvas->CrossHairOff( aDC );
  367. SetCrossHairPosition( aSheet->GetResizePosition() );
  368. m_canvas->MoveCursorToCrossHair();
  369. m_canvas->CrossHairOn( aDC );
  370. SetUndoItem( aSheet );
  371. aSheet->SetFlags( IS_RESIZED );
  372. m_canvas->SetMouseCapture( resizeSheetWithMouseCursor, ExitSheet );
  373. m_canvas->CallMouseCapture( aDC, wxDefaultPosition, true );
  374. if( aSheet->IsNew() ) // not already in edit, save a copy for undo/redo
  375. SetUndoItem( aSheet );
  376. }
  377. void SCH_EDIT_FRAME::RotateHierarchicalSheet( SCH_SHEET* aSheet, bool aRotCCW )
  378. {
  379. if( aSheet == NULL )
  380. return;
  381. // Save old sheet in undo list if not already in edit, or moving.
  382. if( aSheet->GetFlags() == 0 )
  383. SaveCopyInUndoList( aSheet, UR_CHANGED );
  384. // Rotate the sheet on itself. Sheets do not have a anchor point.
  385. // Rotation is made around it center
  386. wxPoint rotPoint = aSheet->GetBoundingBox().Centre();
  387. // Keep this rotation point on the grid, otherwise all items of this sheet
  388. // will be moved off grid
  389. rotPoint = GetNearestGridPosition( rotPoint );
  390. // rotate CCW, or CW. to rotate CW, rotate 3 times
  391. aSheet->Rotate( rotPoint );
  392. if( !aRotCCW )
  393. {
  394. aSheet->Rotate( rotPoint );
  395. aSheet->Rotate( rotPoint );
  396. }
  397. GetCanvas()->Refresh();
  398. OnModify();
  399. }
  400. void SCH_EDIT_FRAME::MirrorSheet( SCH_SHEET* aSheet, bool aFromXaxis )
  401. {
  402. if( aSheet == NULL )
  403. return;
  404. // Save old sheet in undo list if not already in edit, or moving.
  405. if( aSheet->GetFlags() == 0 )
  406. SaveCopyInUndoList( aSheet, UR_CHANGED );
  407. // Mirror the sheet on itself. Sheets do not have a anchor point.
  408. // Mirroring is made around it center
  409. wxPoint mirrorPoint = aSheet->GetBoundingBox().Centre();
  410. if( aFromXaxis ) // mirror relative to Horizontal axis
  411. aSheet->MirrorX( mirrorPoint.y );
  412. else // Mirror relative to vertical axis
  413. aSheet->MirrorY( mirrorPoint.x );
  414. GetCanvas()->Refresh();
  415. OnModify();
  416. }