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.

1040 lines
37 KiB

* 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
6 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
6 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
6 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
4 months ago
4 months ago
4 months ago
4 months ago
4 months ago
4 months ago
4 months ago
4 months ago
4 months 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 wanadoo.fr
  5. * Copyright (C) 2008 Wayne Stambaugh <stambaughw@gmail.com>
  6. * Copyright (C) 2023 CERN (www.cern.ch)
  7. * Copyright The KiCad Developers, see AUTHORS.txt for contributors.
  8. *
  9. * This program is free software; you can redistribute it and/or
  10. * modify it under the terms of the GNU General Public License
  11. * as published by the Free Software Foundation; either version 2
  12. * of the License, or (at your option) any later version.
  13. *
  14. * This program is distributed in the hope that it will be useful,
  15. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  16. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  17. * GNU General Public License for more details.
  18. *
  19. * You should have received a copy of the GNU General Public License
  20. * along with this program; if not, you may find one here:
  21. * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
  22. * or you may search the http://www.gnu.org website for the version 2 license,
  23. * or you may write to the Free Software Foundation, Inc.,
  24. * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
  25. */
  26. #ifndef SCH_EDIT_FRAME_H
  27. #define SCH_EDIT_FRAME_H
  28. #include <stddef.h>
  29. #include <vector>
  30. #include <wx/cmndata.h>
  31. #include <wx/event.h>
  32. #include <wx/gdicmn.h>
  33. #include <wx/string.h>
  34. #include <wx/treectrl.h>
  35. #include <wx/utils.h>
  36. #include <core/typeinfo.h>
  37. #include <eda_base_frame.h>
  38. #include <eeschema_settings.h>
  39. #include <math/box2.h>
  40. #include <sch_base_frame.h>
  41. #include <template_fieldnames.h>
  42. class SCH_ITEM;
  43. class EDA_ITEM;
  44. class SCH_LINE;
  45. class SCH_TEXT;
  46. class SCH_BITMAP;
  47. class SCH_SHEET;
  48. class SCH_SHEET_PATH;
  49. class SCH_SHEET_PIN;
  50. class SCH_SYMBOL;
  51. class SCH_FIELD;
  52. class SCH_JUNCTION;
  53. class SCHEMATIC;
  54. class SCH_COMMIT;
  55. class SCH_DESIGN_BLOCK_PANE;
  56. class DIALOG_BOOK_REPORTER;
  57. class DIALOG_ERC;
  58. class DIALOG_SYMBOL_FIELDS_TABLE;
  59. class RESCUER;
  60. class HIERARCHY_PANE;
  61. class API_HANDLER_SCH;
  62. class DIALOG_SCHEMATIC_SETUP;
  63. class PROGRESS_REPORTER;
  64. /// Schematic search type used by the socket link with Pcbnew
  65. enum SCH_SEARCH_T
  66. {
  67. HIGHLIGHT_PIN,
  68. HIGHLIGHT_SYMBOL
  69. };
  70. wxDECLARE_EVENT( EDA_EVT_SCHEMATIC_CHANGING, wxCommandEvent );
  71. wxDECLARE_EVENT( EDA_EVT_SCHEMATIC_CHANGED, wxCommandEvent );
  72. /**
  73. * Tree view item data for the net navigator.
  74. */
  75. class NET_NAVIGATOR_ITEM_DATA : public wxTreeItemData
  76. {
  77. public:
  78. NET_NAVIGATOR_ITEM_DATA( const SCH_SHEET_PATH& aSheetPath, const SCH_ITEM* aItem ) :
  79. m_sheetPath( aSheetPath ),
  80. m_item( aItem )
  81. {
  82. }
  83. NET_NAVIGATOR_ITEM_DATA() :
  84. m_item( nullptr )
  85. {
  86. }
  87. SCH_SHEET_PATH& GetSheetPath() { return m_sheetPath; }
  88. const SCH_ITEM* GetItem() const { return m_item; }
  89. bool operator==( const NET_NAVIGATOR_ITEM_DATA& aRhs ) const
  90. {
  91. return ( m_sheetPath == aRhs.m_sheetPath ) && ( m_item == aRhs.m_item );
  92. }
  93. NET_NAVIGATOR_ITEM_DATA& operator=( const NET_NAVIGATOR_ITEM_DATA& aItemData )
  94. {
  95. if( this == &aItemData )
  96. return *this;
  97. m_sheetPath = aItemData.m_sheetPath;
  98. m_item = aItemData.m_item;
  99. return *this;
  100. }
  101. private:
  102. SCH_SHEET_PATH m_sheetPath;
  103. const SCH_ITEM* m_item;
  104. };
  105. /**
  106. * Schematic editor (Eeschema) main window.
  107. */
  108. class SCH_EDIT_FRAME : public SCH_BASE_FRAME
  109. {
  110. public:
  111. SCH_EDIT_FRAME( KIWAY* aKiway, wxWindow* aParent );
  112. ~SCH_EDIT_FRAME() override;
  113. SCH_SCREEN* GetScreen() const override;
  114. SELECTION& GetCurrentSelection() override;
  115. SCHEMATIC& Schematic() const;
  116. std::unique_ptr<GRID_HELPER> MakeGridHelper() override;
  117. /**
  118. * Allow edit frame to show/hide hidden pins.
  119. */
  120. bool GetShowAllPins() const override;
  121. /**
  122. * Save changes to the project settings to the project (.pro) file.
  123. */
  124. void SaveProjectLocalSettings() override;
  125. /**
  126. * Load the KiCad project file (*.pro) settings specific to Eeschema.
  127. *
  128. * @return True if the project file was loaded correctly.
  129. */
  130. bool LoadProjectSettings();
  131. /**
  132. * Load the drawing sheet file.
  133. */
  134. void LoadDrawingSheet();
  135. void ShowSchematicSetupDialog( const wxString& aInitialPage = wxEmptyString );
  136. void LoadSettings( APP_SETTINGS_BASE* aCfg ) override;
  137. void SaveSettings( APP_SETTINGS_BASE* aCfg ) override;
  138. void CreateDefaultScreens();
  139. void setupUIConditions() override;
  140. /**
  141. * Get if the current schematic has been modified but not saved.
  142. *
  143. * @return true if the any changes have not been saved
  144. */
  145. bool IsContentModified() const override;
  146. /**
  147. * Must be called after a schematic change in order to set the "modify" flag and update other
  148. * data structures and GUI elements.
  149. */
  150. void OnModify() override;
  151. SEVERITY GetSeverity( int aErrorCode ) const override;
  152. /**
  153. * Return a human-readable description of the current screen.
  154. */
  155. wxString GetScreenDesc() const override;
  156. wxString GetFullScreenDesc() const override;
  157. /**
  158. * Execute a remote command sent via a socket on port KICAD_SCH_PORT_SERVICE_NUMBER (which
  159. * defaults to 4243).
  160. *
  161. * When user selects a footprint or pin in Pcbnew, Eeschema shows that same symbol or pin
  162. * and moves cursor on the item.
  163. *
  164. * Valid commands are:
  165. * \li \c \$PART: \c "reference" Put cursor on symbol.
  166. * \li \c \$PART: \c "reference" \c \$REF: \c "ref" Put cursor on symbol reference.
  167. * \li \c \$PART: \c "reference" \c \$VAL: \c "value" Put cursor on symbol value.
  168. * \li \c \$PART: \c "reference" \c \$PAD: \c "pin name" Put cursor on the symbol pin.
  169. * \li \c \$NET: \c "netname" Highlight a specified net
  170. * \li \c \$CLEAR: \c "HIGHLIGHTED" Clear symbols highlight
  171. * <p>
  172. *
  173. * They are a keyword followed by a quoted string.
  174. *
  175. * @param cmdline is the command received from Pcbnew.
  176. */
  177. void ExecuteRemoteCommand( const char* cmdline ) override;
  178. void KiwayMailIn( KIWAY_EXPRESS& aEvent ) override;
  179. /**
  180. * Refresh the display of any operating points. Called after a .op simulation completes.
  181. */
  182. void RefreshOperatingPointDisplay();
  183. /**
  184. * Automatically set the rotation of an item (if the item supports it).
  185. */
  186. void AutoRotateItem( SCH_SCREEN* aScreen, SCH_ITEM* aItem );
  187. /**
  188. * Update the hierarchy navigation tree and history
  189. */
  190. void UpdateHierarchyNavigator( bool aRefreshNetNavigator = true, bool aClear = false );
  191. /**
  192. * Update the hierarchy navigation tree labels.
  193. *
  194. * No change for the tree, only the labels are updated, after editing a sheet
  195. * name or a sheet number.
  196. */
  197. void UpdateLabelsHierarchyNavigator();
  198. /**
  199. * Update the hierarchy navigation tree selection (cross-probe from schematic to hierarchy
  200. * pane).
  201. */
  202. void UpdateHierarchySelection();
  203. /**
  204. * Design block panel options have changed and the panel needs to be refreshed.
  205. */
  206. void UpdateDesignBlockOptions();
  207. /**
  208. * Test all of the connectable objects in the schematic for unused connection points.
  209. *
  210. * @return True if any connection state changes were made.
  211. */
  212. void TestDanglingEnds();
  213. /**
  214. * Send items to board editor for selection.
  215. *
  216. * This is used for when the Eeschema user is using the cross-probe tool.
  217. *
  218. * @param aItems are the items to select
  219. * @param aForce select the element in Pcbnew whether or not the user has the select option
  220. * chosen
  221. */
  222. void SendSelectItemsToPcb( const std::vector<EDA_ITEM*>& aItems, bool aForce );
  223. /**
  224. * Send a net name to Pcbnew for highlighting.
  225. *
  226. * @param aNetName is the name of a net, or empty string to clear highlight
  227. */
  228. void SendCrossProbeNetName( const wxString& aNetName );
  229. /**
  230. * Send a connection (net or bus) to Pcbnew for highlighting.
  231. *
  232. * @param aConnection is the connection to highlight
  233. */
  234. void SetCrossProbeConnection( const SCH_CONNECTION* aConnection );
  235. /**
  236. * Tell Pcbnew to clear the existing highlighted net, if one exists
  237. */
  238. void SendCrossProbeClearHighlight();
  239. const wxString& GetHighlightedConnection() const
  240. {
  241. return m_highlightedConn;
  242. }
  243. void SetHighlightedConnection( const wxString& aConnection,
  244. const NET_NAVIGATOR_ITEM_DATA* aSelection = nullptr );
  245. void DirtyHighlightedConnection() { m_highlightedConnChanged = true; }
  246. /**
  247. * Check if we are ready to write a netlist file for the current schematic.
  248. *
  249. * Test for some issues (missing or duplicate references and sheet names).
  250. *
  251. * @param aAnnotateMessage a message to put up in case annotation needs to be performed.
  252. * @return true if all is well (i.e. you can call WriteNetListFile next).
  253. */
  254. bool ReadyToNetlist( const wxString& aAnnotateMessage );
  255. /**
  256. * Create a netlist file.
  257. *
  258. * @param aFormat is the netlist format (NET_TYPE_PCBNEW ...).
  259. * @param aFullFileName is the full netlist file name.
  260. * @param aNetlistOptions is the netlist options using OR'ed bits.
  261. * <p>
  262. * For SPICE netlist only:
  263. * if NET_USE_NETNAMES is set, use net names from labels in schematic
  264. * else use net numbers (net codes)
  265. * if NET_USE_X_PREFIX is set : change "U" and "IC" reference prefix to "X"
  266. * </p>
  267. * @param aReporter is a #REPORTER to report error messages, can be a nullptr.
  268. * @return true if success.
  269. */
  270. bool WriteNetListFile( int aFormat, const wxString& aFullFileName, unsigned aNetlistOptions,
  271. REPORTER* aReporter = nullptr );
  272. /**
  273. * Clear the current symbol annotation.
  274. *
  275. * @param aAnnotateScope See #ANNOTATE_SCOPE_T
  276. * @param aRecursive Annotation should descend into and annotate subsheets
  277. * @param aReporter A sink for error messages. Use NULL_REPORTER if you don't need errors.
  278. */
  279. void DeleteAnnotation( ANNOTATE_SCOPE_T aAnnotateScope, bool aRecursive, REPORTER& aReporter );
  280. /**
  281. * Annotate the symbols in the schematic that are not currently annotated.
  282. *
  283. * Multi-unit symbols are annotated together. E.g. if two symbols were R8A and R8B, they may
  284. * become R3A and R3B, but not R3A and R3C or R3C and R4D.
  285. *
  286. * @param aCommit Transaction container used to record changes for undo/redo
  287. * @param aAnnotateScope See #ANNOTATE_SCOPE_T
  288. * @param aSortOption Define the annotation order. See #ANNOTATE_ORDER_T.
  289. * @param aAlgoOption Define the annotation style. See #ANNOTATE_ALGO_T.
  290. * @param aRecursive Annotation should descend into and annotate subsheets
  291. * @param aStartNumber The start number for non-sheet-based annotation styles.
  292. * @param aResetAnnotation Clear any previous annotation if true. Otherwise, keep the
  293. * existing symbol annotation.
  294. * @param aRepairTimestamps Test for and repair any duplicate time stamps if true.
  295. * Otherwise, keep the existing time stamps. This option
  296. * could change previous annotation because time stamps are
  297. * used to handle annotation in complex hierarchies.
  298. * @param aReporter A sink for error messages. Use NULL_REPORTER if you don't need errors.
  299. *
  300. * When the sheet number is used in annotation, each sheet annotation starts from sheet
  301. * number * 100. In other words the first sheet uses 100 to 199, the second sheet uses
  302. * 200 to 299, and so on.
  303. */
  304. void AnnotateSymbols( SCH_COMMIT* aCommit, ANNOTATE_SCOPE_T aAnnotateScope,
  305. ANNOTATE_ORDER_T aSortOption, ANNOTATE_ALGO_T aAlgoOption,
  306. bool aRecursive, int aStartNumber, bool aResetAnnotation,
  307. bool aRepairTimestamps, REPORTER& aReporter );
  308. /**
  309. * Check for annotation errors.
  310. *
  311. * The following list of items are checked:
  312. * - Symbols that are not annotated.
  313. * - Duplicate symbol references.
  314. * - Multiple part per package symbols where the part number is greater number of parts in
  315. * the package.
  316. * - Multiple part per package symbols where the reference designator is different between
  317. * parts.
  318. *
  319. * @return Number of annotation errors found.
  320. * @param aReporter A handler for error reporting.
  321. * @param aAnnotateScope See #ANNOTATE_SCOPE_T Check the current sheet only if true.
  322. * Otherwise check the entire schematic.
  323. */
  324. int CheckAnnotate( ANNOTATION_ERROR_HANDLER aErrorHandler,
  325. ANNOTATE_SCOPE_T aAnnotateScope = ANNOTATE_ALL,
  326. bool aRecursive = true );
  327. /**
  328. * Run a modal version of the annotate dialog for a specific purpose.
  329. *
  330. * @param aMessage A user message indicating the purpose.
  331. * @return the result of ShowModal()
  332. */
  333. int ModalAnnotate( const wxString& aMessage );
  334. // Functions used for hierarchy handling
  335. SCH_SHEET_PATH& GetCurrentSheet() const;
  336. void SetCurrentSheet( const SCH_SHEET_PATH& aSheet );
  337. void UpdateItem( EDA_ITEM* aItem, bool isAddOrDelete = false, bool aUpdateRtree = false ) override;
  338. /**
  339. * Rebuild the GAL and redraw the screen.
  340. *
  341. * Call when something went wrong.
  342. */
  343. void HardRedraw() override;
  344. /**
  345. * Draw the current sheet on the display.
  346. */
  347. void DisplayCurrentSheet();
  348. /**
  349. * Use the wxWidgets print code to draw an image of the current sheet onto the clipboard.
  350. */
  351. void DrawCurrentSheetToClipboard();
  352. /**
  353. * Called when modifying the page settings.
  354. *
  355. * In derived classes it can be used to modify parameters like draw area size, and any other
  356. * local parameter related to the page settings.
  357. */
  358. void OnPageSettingsChange() override;
  359. /**
  360. * Set the m_ScreenNumber and m_NumberOfScreens members for screens.
  361. *
  362. * @note This must be called after deleting or adding a sheet and when entering a sheet.
  363. */
  364. void SetSheetNumberAndCount();
  365. wxPageSetupDialogData& GetPageSetupData() { return m_pageSetupData; }
  366. void NewProject();
  367. void LoadProject();
  368. /**
  369. * Save the currently-open schematic (including its hierarchy) and associated project.
  370. *
  371. * @param aSaveAs is true to perform a Save As operation (rename the schematic and project).
  372. * This may only be done in standalone mode.
  373. * @return true if the schematic was saved
  374. */
  375. bool SaveProject( bool aSaveAs = false );
  376. bool OpenProjectFiles( const std::vector<wxString>& aFileSet, int aCtl = 0 ) override;
  377. void SetSchematic( SCHEMATIC* aSchematic );
  378. wxString GetCurrentFileName() const override;
  379. /**
  380. * Check if any of the screens has unsaved changes and asks the user whether to save or
  381. * drop them.
  382. *
  383. * @return True if user decided to save or drop changes, false if the operation should be
  384. * canceled.
  385. */
  386. bool AskToSaveChanges();
  387. SCH_JUNCTION* AddJunction( SCH_COMMIT* aCommit, SCH_SCREEN* aScreen, const VECTOR2I& aPos );
  388. /**
  389. * If any single wire passes through _both points_, remove the portion between the two points,
  390. * potentially splitting the wire into two.
  391. *
  392. * @param aCommit Transaction container used to record changes for undo/redo
  393. * @param aStart The starting point for trimming
  394. * @param aEnd The ending point for trimming
  395. * @return True if any wires were changed by this operation
  396. */
  397. bool TrimWire( SCH_COMMIT* aCommit, const VECTOR2I& aStart, const VECTOR2I& aEnd );
  398. void OnOpenPcbnew();
  399. void OnOpenCvpcb();
  400. void OnUpdatePCB();
  401. void OnAnnotate();
  402. /**
  403. * Verify that \a aSheet will not cause a recursion error in \a aCurrentSheet.
  404. *
  405. * @param aSheet is the #SCH_SHEET object to test.
  406. * @param aCurrentSheet is the #SCH_SHEET_PATH where \a aSheet is going to reside.
  407. * @return true if \a aSheet will cause a recursion error in \a aCurrentSheet.
  408. */
  409. bool CheckSheetForRecursion( SCH_SHEET* aSheet, SCH_SHEET_PATH* aCurrentSheet );
  410. /**
  411. * Check \a aSchematicFileName for a potential file name case sensitivity clashes.
  412. *
  413. * On platforms where file names are case sensitive, it is possible to schematic sheet
  414. * file names that would cause issues on platforms where file name are case insensitive.
  415. * File names foo.sch and Foo.sch are unique files on Linux and MacOS but on Windows
  416. * this would result in a broken schematic.
  417. *
  418. * @param aSchematicFileName is the absolute path and file name of the file to test.
  419. * @return true if the user accepts the potential file name clash risk.
  420. */
  421. bool AllowCaseSensitiveFileNameClashes( const wxString& aOldName,
  422. const wxString& aSchematicFileName );
  423. /**
  424. * Edit an existing sheet or add a new sheet to the schematic.
  425. *
  426. * When \a aSheet is a new sheet:
  427. * - and the file name already exists in the schematic hierarchy, the screen associated
  428. * with the sheet found in the hierarchy is associated with \a aSheet.
  429. * - and the file name already exists on the system, then \a aSheet is loaded with the
  430. * existing file.
  431. * - and the file name does not exist in the schematic hierarchy or on the file system,
  432. * then a new screen is created and associated with \a aSheet.
  433. *
  434. * When \a aSheet is an existing sheet:
  435. * - and the file name already exists in the schematic hierarchy, the current associated
  436. * screen is replace by the one found in the hierarchy.
  437. * - and the file name already exists on the system, the current associated screen file
  438. * name is changed and the file is loaded.
  439. * - and the file name does not exist in the schematic hierarchy or on the file system,
  440. * the current associated screen file name is changed and saved to disk.
  441. *
  442. * Note: the screen is not refresh. The caller is responsible to do that
  443. *
  444. * @param aSheet is the sheet to edit
  445. * @param aHierarchy is the current hierarchy containing aSheet
  446. * @param aIsUndoable is a reference to a bool to know if this operation must clear
  447. * the undo-redo list, since the operation is not reversible.
  448. * @param aClearAnnotationNewItems is a reference to a bool to know if the items managed by
  449. * this sheet need to have their annotation cleared i.e. when an existing item list is used.
  450. * it can happens when the edited sheet used an existing file, or becomes a new instance
  451. * of a already existing sheet.
  452. * @param aUpdateHierarchyNavigator is an optional flag to indicate the sheet changes require
  453. * the hierarchy navigator panel to be updated.
  454. * @param aSourceSheetFilename is an optional filename to copy the new sheet from
  455. */
  456. bool EditSheetProperties( SCH_SHEET* aSheet, SCH_SHEET_PATH* aHierarchy,
  457. bool* aIsUndoable = nullptr, bool* aClearAnnotationNewItems = nullptr,
  458. bool* aUpdateHierarchyNavigator = nullptr,
  459. wxString* aSourceSheetFilename = nullptr );
  460. void InitSheet( SCH_SHEET* aSheet, const wxString& aNewFilename );
  461. /**
  462. * Load a the KiCad schematic file \a aFileName into the sheet \a aSheet.
  463. *
  464. * If \a aSheet does not have a valid #SCH_SCREEN object, the schematic is loaded into
  465. * \a Sheet. Otherwise, it is appended to the current #SCH_SCREEN object.
  466. *
  467. * In order to import a schematic a lot of things have to happen to before the contents
  468. * of the imported schematic can be appended to the current page. The following list
  469. * describes this process:
  470. *
  471. * - Load the schematic into a temporary #SCH_SHEET object.
  472. * - Make sure the imported schematic does not cause any hierarchy recursion issues.
  473. * - Verify the imported schematic uses fully qualified #LIB_ID objects (symbol library table).
  474. * - Check all of the possible combinations that could cause broken symbol library links
  475. * and give the user the option to cancel the append process. The following conditions
  476. * are check but they still do not guarantee that there will not be any broken symbol
  477. * library links:
  478. * - The source schematic is in the current project path and contains symbol library
  479. * nicknames not found in the project symbol library table. This can happen if the
  480. * schematic is copied to the current project path from another project.
  481. * - The source schematic is in a different path and there are symbol library link nicknames
  482. * that do not exist in either the current symbol library table or the source project
  483. * symbol library table if it exists in the source path.
  484. * - The source schematic is in a different path and contains duplicate symbol library
  485. * nicknames that point to different libraries.
  486. * - Check to see if any symbol libraries need to be added to the current project's symbol
  487. * library table. This includes:
  488. * - Check if the symbol library already exists in the project or global symbol library
  489. * table.
  490. * - Convert symbol library URLS that use the ${KIPRJMOD} environment variable to absolute
  491. * paths. ${KIPRJMOD} will not be the same for this project.
  492. * - Clear all of the annotation in the imported schematic to prevent clashes.
  493. * - Append the objects from the temporary sheet to the current page.
  494. * - Replace any duplicate time stamps.
  495. * - Refresh the symbol library links.
  496. *
  497. * @param aSheet is the sheet to either append or load the schematic.
  498. * @param aCurrentSheet is the current position in the schematic hierarchy used to test for
  499. * possible file recursion issues.
  500. * @param aFileName is the file name to load. The file name is expected to have an absolute
  501. * path.
  502. * @param aSkipRecursionCheck is true to skip the recursion check. This is used when loading
  503. * a schematic sheet that is not part of the current project. If we are placing
  504. * sheet contents instead of a sheet, then we do not need to check for
  505. * recursion.
  506. * @param aSkipLibCheck is true to skip the new/duplicate lib check. This is always triggered
  507. * when placing design blocks so it is not necessary to check for
  508. * new/duplicate libs.
  509. * @return True if the schematic was imported properly.
  510. */
  511. bool LoadSheetFromFile( SCH_SHEET* aSheet, SCH_SHEET_PATH* aCurrentSheet, const wxString& aFileName,
  512. bool aSkipRecursionCheck = false, bool aSkipLibCheck = false );
  513. /**
  514. * Remove a given junction and heals any wire segments under the junction.
  515. *
  516. * @param aItem The junction to delete
  517. */
  518. void DeleteJunction( SCH_COMMIT* aCommit, SCH_ITEM* aItem );
  519. void UpdateHopOveredWires( SCH_ITEM* aItem );
  520. void SelectUnit( SCH_SYMBOL* aSymbol, int aUnit );
  521. void SelectBodyStyle( SCH_SYMBOL* aSymbol, int aBodyStyle );
  522. void SetAltPinFunction( SCH_PIN* aPin, const wxString& aFunction );
  523. /* Undo - redo */
  524. /**
  525. * Create a copy of the current schematic item, and put it in the undo list.
  526. *
  527. * aTypeCommand =
  528. * CHANGED
  529. * NEWITEM
  530. * DELETED
  531. *
  532. * If it is a delete command, items are put on list with the .Flags member
  533. * set to DELETED.
  534. *
  535. * @param aItemToCopy is the schematic item modified by the command to undo.
  536. * @param aTypeCommand is the command type (see enum UNDO_REDO).
  537. * @param aAppend set to true to add the item to the previous undo list.
  538. */
  539. void SaveCopyInUndoList( SCH_SCREEN* aScreen, SCH_ITEM* aItemToCopy, UNDO_REDO aTypeCommand,
  540. bool aAppend );
  541. /**
  542. * Create a new entry in undo list of commands.
  543. *
  544. * @param aItemsList is the list of items modified by the command to undo/
  545. * @param aTypeCommand is the command type (see enum UNDO_REDO).
  546. * @param aAppend set to true to add the item to the previous undo list.
  547. */
  548. void SaveCopyInUndoList( const PICKED_ITEMS_LIST& aItemsList, UNDO_REDO aTypeCommand,
  549. bool aAppend );
  550. /**
  551. * Restore an undo or redo command to put data pointed by \a aList in the previous state.
  552. *
  553. * @param aList a PICKED_ITEMS_LIST pointer to the list of items to undo/redo
  554. */
  555. void PutDataInPreviousState( PICKED_ITEMS_LIST* aList );
  556. /**
  557. * Free the undo or redo list from \a aList element.
  558. *
  559. * - Wrappers are deleted.
  560. * - data pointed by wrappers are deleted if not in use in schematic
  561. * i.e. when they are copy of a schematic item or they are no more in use (DELETED)
  562. *
  563. * @param whichList is the UNDO_REDO_CONTAINER to clear
  564. * @param aItemCount is the count of items to remove. Use < 0 to remove all items from
  565. * the beginning of the list.
  566. */
  567. void ClearUndoORRedoList( UNDO_REDO_LIST whichList, int aItemCount = -1 ) override;
  568. /**
  569. * Clone \a aItem and owns that clone in this container.
  570. */
  571. void SaveCopyForRepeatItem( const SCH_ITEM* aItem );
  572. void AddCopyForRepeatItem( const SCH_ITEM* aItem );
  573. /**
  574. * Return the items which are to be repeated with the insert key.
  575. *
  576. * Such objects are owned by this container and must be cloned.
  577. */
  578. const std::vector<std::unique_ptr<SCH_ITEM>>& GetRepeatItems() const
  579. {
  580. return m_items_to_repeat;
  581. }
  582. /**
  583. * Clear the list of items which are to be repeated with the insert key.
  584. *
  585. * These objects are owned by this container.
  586. */
  587. void ClearRepeatItemsList()
  588. {
  589. m_items_to_repeat.clear();
  590. }
  591. EDA_ITEM* ResolveItem( const KIID& aId, bool aAllowNullptrReturn = false ) const override;
  592. /**
  593. * Perform an undo of the last edit **without** logging a corresponding redo.
  594. *
  595. * Used to cancel an in-progress operation.
  596. */
  597. void RollbackSchematicFromUndo();
  598. /**
  599. * Create a library \a aFileName that contains all symbols used in the current schematic.
  600. *
  601. * @param aFileName The full path and file name of the archive library.
  602. * @return True if \a aFileName was written successfully.
  603. */
  604. bool CreateArchiveLibrary( const wxString& aFileName );
  605. bool SaveSheetAsDesignBlock( const wxString& aLibraryName, SCH_SHEET_PATH& aSheetPath );
  606. bool SaveSelectionAsDesignBlock( const wxString& aLibraryName );
  607. bool SaveSheetToDesignBlock( const LIB_ID& aLibId, SCH_SHEET_PATH& aSheetPath );
  608. bool SaveSelectionToDesignBlock( const LIB_ID& aLibId );
  609. SCH_DESIGN_BLOCK_PANE* GetDesignBlockPane() const { return m_designBlocksPane; }
  610. void SetNetListerCommand( const wxString& aCommand ) { m_netListerCommand = aCommand; }
  611. /**
  612. * Reset the execution flags to defaults for external netlist and bom generators.
  613. */
  614. void DefaultExecFlags() { m_exec_flags = wxEXEC_SYNC; }
  615. /**
  616. * Set (adds) specified flags for next execution of external generator of the netlist or bom.
  617. *
  618. * @param aFlags is the wxEXEC_* flags, see wxExecute documentation.
  619. */
  620. void SetExecFlags( const int aFlags ) { m_exec_flags |= aFlags; }
  621. /**
  622. * Clear (removes) specified flags that not needed for next execution of external generator
  623. * of the netlist or bom.
  624. *
  625. * @param aFlags is the wxEXEC_* flags, see wxExecute documentation.
  626. */
  627. void ClearExecFlags( const int aFlags ) { m_exec_flags &= ~( aFlags ); }
  628. wxString GetNetListerCommand() const { return m_netListerCommand; }
  629. /**
  630. * Generate the connection data for the entire schematic hierarchy.
  631. */
  632. void RecalculateConnections( SCH_COMMIT* aCommit, SCH_CLEANUP_FLAGS aCleanupFlags,
  633. PROGRESS_REPORTER* aProgressReporter = nullptr );
  634. /**
  635. * Called after the preferences dialog is run.
  636. */
  637. void CommonSettingsChanged( int aFlags ) override;
  638. void UpdateNetHighlightStatus();
  639. void ShowChangedLanguage() override;
  640. void SetScreen( BASE_SCREEN* aScreen ) override;
  641. const BOX2I GetDocumentExtents( bool aIncludeAllVisible = true ) const override;
  642. int GetSchematicJunctionSize();
  643. double GetSchematicHopOverScale();
  644. void FocusOnItem( EDA_ITEM* aItem, bool aAllowScroll = true ) override;
  645. bool IsSyncingSelection() { return m_syncingPcbToSchSelection; }
  646. /**
  647. * Update a schematic symbol from a LIB_SYMBOL.
  648. *
  649. * This is typically called from the symbol editor when editing symbols in place.
  650. *
  651. * @param aSymbol is the new symbol data.
  652. * @param aSchematicSymbolUUID refers to the schematic symbol to update.
  653. */
  654. void SaveSymbolToSchematic( const LIB_SYMBOL& aSymbol, const KIID& aSchematicSymbolUUID );
  655. /**
  656. * Update the schematic's page reference map for all global labels, and refresh the labels
  657. * so that they are redrawn with up-to-date references.
  658. */
  659. void RecomputeIntersheetRefs();
  660. /**
  661. * Callback from schematic ref update
  662. */
  663. void IntersheetRefUpdate( SCH_GLOBALLABEL* aItem ) override;
  664. void ShowAllIntersheetRefs( bool aShow );
  665. /**
  666. * This overloaded version checks if the auto save master file "#auto_saved_files#" exists
  667. * and recovers all of the schematic files listed in it.
  668. *
  669. * @param aFileName is the project auto save master file name.
  670. */
  671. virtual void CheckForAutoSaveFile( const wxFileName& aFileName ) override;
  672. virtual void DeleteAutoSaveFile( const wxFileName& aFileName ) override;
  673. /**
  674. * Toggle the show/hide state of the left side schematic navigation panel
  675. */
  676. void ToggleSchematicHierarchy();
  677. /**
  678. * Toggle the show/hide state of Search pane
  679. */
  680. void ToggleSearch();
  681. void ToggleProperties() override;
  682. void ToggleLibraryTree() override;
  683. DIALOG_BOOK_REPORTER* GetSymbolDiffDialog();
  684. DIALOG_ERC* GetErcDialog();
  685. DIALOG_SYMBOL_FIELDS_TABLE* GetSymbolFieldsTableDialog();
  686. wxTreeCtrl* GetNetNavigator() { return m_netNavigator; }
  687. const SCH_ITEM* GetSelectedNetNavigatorItem() const;
  688. /**
  689. * @return the name of the wxAuiPaneInfo managing the Hierarchy Navigator panel.
  690. */
  691. static const wxString SchematicHierarchyPaneName()
  692. {
  693. return wxT( "SchematicHierarchy" );
  694. }
  695. /**
  696. * @return the name of the wxAuiPaneInfo managing the Search panel.
  697. */
  698. static const wxString SearchPaneName() { return wxT( "Search" ); }
  699. bool IsSearchPaneShown() { return m_auimgr.GetPane( SearchPaneName() ).IsShown(); }
  700. void FocusSearch();
  701. /**
  702. * Add \a aListener to post #EDA_EVT_SCHEMATIC_CHANGED command events to.
  703. *
  704. * @warning The caller is responsible for removing any listeners that are no long valid.
  705. *
  706. * @note This only gets called when the schematic editor is in stand alone mode. Changing
  707. * projects in the project manager closes the schematic editor when a new project is
  708. * loaded.
  709. */
  710. void AddSchematicChangeListener( wxEvtHandler* aListener );
  711. /**
  712. * Remove \a aListener to from the schematic changed listener list.
  713. */
  714. void RemoveSchematicChangeListener( wxEvtHandler* aListener );
  715. static const wxString NetNavigatorPaneName()
  716. {
  717. return wxS( "NetNavigator" );
  718. }
  719. void RefreshNetNavigator( const NET_NAVIGATOR_ITEM_DATA* aSelection = nullptr );
  720. void MakeNetNavigatorNode( const wxString& aNetName, wxTreeItemId aParentId,
  721. const NET_NAVIGATOR_ITEM_DATA* aSelection,
  722. bool aSingleSheetSchematic );
  723. void SelectNetNavigatorItem( const NET_NAVIGATOR_ITEM_DATA* aSelection = nullptr );
  724. const SCH_ITEM* SelectNextPrevNetNavigatorItem( bool aNext );
  725. void ToggleNetNavigator();
  726. PLUGIN_ACTION_SCOPE PluginActionScope() const override
  727. {
  728. return PLUGIN_ACTION_SCOPE::SCHEMATIC;
  729. }
  730. DECLARE_EVENT_TABLE()
  731. protected:
  732. /**
  733. * Save the schematic files that have been modified and not yet saved.
  734. *
  735. * @return true if the auto save was successful otherwise false.
  736. */
  737. bool doAutoSave() override;
  738. void configureToolbars() override;
  739. void doReCreateMenuBar() override;
  740. /**
  741. * Send the KiCad netlist over to CVPCB.
  742. */
  743. void sendNetlistToCvpcb();
  744. void onSize( wxSizeEvent& aEvent );
  745. void saveProjectSettings() override;
  746. void onCloseSymbolDiffDialog( wxCommandEvent& aEvent );
  747. void onCloseErcDialog( wxCommandEvent& aEvent );
  748. void onCloseSymbolFieldsTableDialog( wxCommandEvent& aEvent );
  749. void unitsChangeRefresh() override;
  750. void updateSelectionFilterVisbility() override;
  751. #ifdef KICAD_IPC_API
  752. void onPluginAvailabilityChanged( wxCommandEvent& aEvt );
  753. #endif
  754. private:
  755. // Called when resizing the Hierarchy Navigator panel
  756. void OnResizeHierarchyNavigator( wxSizeEvent& aEvent );
  757. void onResizeNetNavigator( wxSizeEvent& aEvent );
  758. // Sets up the tool framework
  759. void setupTools();
  760. void OnExit( wxCommandEvent& event );
  761. void OnLoadFile( wxCommandEvent& event );
  762. void OnImportProject( wxCommandEvent& event );
  763. void OnClearFileHistory( wxCommandEvent& aEvent );
  764. bool canCloseWindow( wxCloseEvent& aCloseEvent ) override;
  765. void doCloseWindow() override;
  766. /**
  767. * Set the main window title bar text.
  768. *
  769. * If file name defined by SCH_SCREEN::m_FileName is not set, the title is set to the
  770. * application name appended with no file.
  771. * Otherwise, the title is set to the hierarchical sheet path and the full file name, and
  772. * read only is appended to the title if the user does not have write access to the file.
  773. */
  774. void updateTitle();
  775. /**
  776. * Initialize the zoom value of the current screen and mark the screen as zoom-initialized.
  777. */
  778. void initScreenZoom();
  779. /**
  780. * Verify that the symbol library links \a aSheet and all of its child sheets have
  781. * been remapped to the symbol library table.
  782. *
  783. * @param aSheet is the #SCH_SHEET object to test.
  784. *
  785. * @return true if \a aSheet and its child sheets have not been remapped.
  786. */
  787. bool checkForNoFullyDefinedLibIds( SCH_SHEET* aSheet );
  788. /**
  789. * Load the given filename but sets the path to the current project path.
  790. *
  791. * @param full filepath of file to be imported.
  792. * @param aFileType SCH_FILE_T value for file type
  793. */
  794. bool importFile( const wxString& aFileName, int aFileType,
  795. const std::map<std::string, UTF8>* aProperties = nullptr );
  796. /**
  797. * Save \a aSheet to a schematic file.
  798. *
  799. * @param aSheet is the #SCH_SHEET object to save.
  800. * @param aSavePath is the full path of the destination file
  801. * @return True if the file has been saved.
  802. */
  803. bool saveSchematicFile( SCH_SHEET* aSheet, const wxString& aSavePath );
  804. /**
  805. * Fill a map of uuid -> reference from the currently loaded schematic.
  806. *
  807. * @param aMap is a map to fill
  808. */
  809. void mapExistingAnnotation( std::map<wxString, wxString>& aMap );
  810. bool updateAutoSaveFile();
  811. const wxString& getAutoSaveFileName() const;
  812. wxTreeCtrl* createHighlightedNetNavigator();
  813. void onNetNavigatorSelection( wxTreeEvent& aEvent );
  814. void onNetNavigatorSelChanging( wxTreeEvent& aEvent );
  815. void CaptureHierarchyPaneSize();
  816. void StartCrossProbeFlash( const std::vector<SCH_ITEM*>& aItems );
  817. void OnCrossProbeFlashTimer( wxTimerEvent& aEvent );
  818. private:
  819. // The schematic editor control class should be able to access some internal
  820. // functions of the editor frame.
  821. friend class SCH_EDITOR_CONTROL;
  822. SCHEMATIC* m_schematic; ///< The currently loaded schematic
  823. wxString m_highlightedConn; ///< The highlighted net or bus or empty string.
  824. wxPageSetupDialogData m_pageSetupData;
  825. std::vector<std::unique_ptr<SCH_ITEM>> m_items_to_repeat; ///< For the repeat-last-item cmd
  826. wxString m_netListerCommand; ///< Command line to call a custom net list
  827. ///< generator.
  828. int m_exec_flags; ///< Flags of the wxExecute() function
  829. ///< to call a custom net list generator.
  830. DIALOG_ERC* m_ercDialog;
  831. DIALOG_BOOK_REPORTER* m_diffSymbolDialog;
  832. HIERARCHY_PANE* m_hierarchy;
  833. DIALOG_SYMBOL_FIELDS_TABLE* m_symbolFieldsTableDialog;
  834. DIALOG_SCHEMATIC_SETUP* m_schematicSetupDialog;
  835. wxTreeCtrl* m_netNavigator;
  836. bool m_syncingPcbToSchSelection; // Recursion guard when synchronizing selection from PCB
  837. // Cross-probe flashing support
  838. wxTimer m_crossProbeFlashTimer; ///< Timer to toggle selection visibility
  839. int m_crossProbeFlashPhase = 0;
  840. std::vector<KIID> m_crossProbeFlashItems; ///< Items to flash
  841. bool m_crossProbeFlashing = false;
  842. bool m_show_search;
  843. bool m_highlightedConnChanged;
  844. std::vector<wxEvtHandler*> m_schematicChangeListeners;
  845. std::vector<LIB_ID> m_designBlockHistoryList;
  846. SCH_DESIGN_BLOCK_PANE* m_designBlocksPane;
  847. #ifdef KICAD_IPC_API
  848. std::unique_ptr<API_HANDLER_SCH> m_apiHandler;
  849. #endif
  850. };
  851. #endif // SCH_EDIT_FRAME_H