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.

1248 lines
36 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
* 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
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
* 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
19 years ago
Introduction of Graphics Abstraction Layer based rendering for pcbnew. New classes: - VIEW - represents view that is seen by user, takes care of layer ordering & visibility and how it is displayed (which location, how much zoomed, etc.) - VIEW_ITEM - Base class for every item that can be displayed on VIEW (the biggest change is that now it may be necessary to override ViewBBox & ViewGetLayers method for derived classes). - EDA_DRAW_PANEL_GAL - Inherits after EDA_DRAW_PANEL, displays VIEW output, right now it is not editable (in opposite to usual EDA_DRAW_PANEL). - GAL/OPENGL_GAL/CAIRO_GAL - Base Graphics Abstraction Layer class + two different flavours (Cairo is not fully supported yet), that offers methods to draw primitives using different libraries. - WX_VIEW_CONTROLS - Controller for VIEW, handles user events, allows zooming, panning, etc. - PAINTER/PCB_PAINTER - Classes that uses GAL interface to draw items (as you may have already guessed - PCB_PAINTER is a class for drawing PCB specific object, PAINTER is an abstract class). Its methods are invoked by VIEW, when an item has to be drawn. To display a new type of item - you need to implement draw(ITEM_TYPE*) method that draws it using GAL methods. - STROKE_FONT - Implements stroke font drawing using GAL methods. Most important changes to Kicad original code: * EDA_ITEM now inherits from VIEW_ITEM, which is a base class for all drawable objects. * EDA_DRAW_FRAME contains both usual EDA_DRAW_PANEL and new EDA_DRAW_PANEL_GAL, that can be switched anytime. * There are some new layers for displaying multilayer pads, vias & pads holes (these are not shown yet on the right sidebar in pcbnew) * Display order of layers is different than in previous versions (if you are curious - you may check m_galLayerOrder@pcbnew/basepcbframe.cpp). Preserving usual order would result in not very natural display, such as showing silkscreen texts on the bottom. * Introduced new hotkey (Alt+F12) and new menu option (View->Switch canvas) for switching canvas during runtime. * Some of classes (mostly derived from BOARD_ITEM) now includes ViewBBox & ViewGetLayers methods. * Removed tools/class_painter.h, as now it is extended and included in source code. Build changes: * GAL-based rendering option is turned on by a new compilation CMake option KICAD_GAL. * When compiling with CMake option KICAD_GAL=ON, GLEW and Cairo libraries are required. * GAL-related code is compiled into a static library (common/libgal). * Build with KICAD_GAL=OFF should not need any new libraries and should come out as a standard version of Kicad Currently most of items in pcbnew can be displayed using OpenGL (to be done are DIMENSIONS and MARKERS). More details about GAL can be found in: http://www.ohwr.org/attachments/1884/view-spec.pdf
13 years ago
19 years ago
14 years ago
19 years ago
19 years ago
19 years ago
19 years ago
19 years ago
19 years ago
19 years ago
19 years ago
19 years ago
19 years ago
19 years ago
19 years ago
19 years ago
19 years ago
19 years ago
19 years ago
19 years ago
13 years ago
19 years ago
19 years ago
19 years ago
19 years ago
19 years ago
19 years ago
19 years ago
19 years ago
19 years ago
14 years ago
19 years ago
19 years ago
14 years ago
19 years ago
19 years ago
19 years ago
19 years ago
19 years ago
19 years ago
19 years ago
19 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
19 years ago
19 years ago
19 years ago
19 years ago
19 years ago
19 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
* 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
* 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
* 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
* 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
13 years ago
Introduction of Graphics Abstraction Layer based rendering for pcbnew. New classes: - VIEW - represents view that is seen by user, takes care of layer ordering & visibility and how it is displayed (which location, how much zoomed, etc.) - VIEW_ITEM - Base class for every item that can be displayed on VIEW (the biggest change is that now it may be necessary to override ViewBBox & ViewGetLayers method for derived classes). - EDA_DRAW_PANEL_GAL - Inherits after EDA_DRAW_PANEL, displays VIEW output, right now it is not editable (in opposite to usual EDA_DRAW_PANEL). - GAL/OPENGL_GAL/CAIRO_GAL - Base Graphics Abstraction Layer class + two different flavours (Cairo is not fully supported yet), that offers methods to draw primitives using different libraries. - WX_VIEW_CONTROLS - Controller for VIEW, handles user events, allows zooming, panning, etc. - PAINTER/PCB_PAINTER - Classes that uses GAL interface to draw items (as you may have already guessed - PCB_PAINTER is a class for drawing PCB specific object, PAINTER is an abstract class). Its methods are invoked by VIEW, when an item has to be drawn. To display a new type of item - you need to implement draw(ITEM_TYPE*) method that draws it using GAL methods. - STROKE_FONT - Implements stroke font drawing using GAL methods. Most important changes to Kicad original code: * EDA_ITEM now inherits from VIEW_ITEM, which is a base class for all drawable objects. * EDA_DRAW_FRAME contains both usual EDA_DRAW_PANEL and new EDA_DRAW_PANEL_GAL, that can be switched anytime. * There are some new layers for displaying multilayer pads, vias & pads holes (these are not shown yet on the right sidebar in pcbnew) * Display order of layers is different than in previous versions (if you are curious - you may check m_galLayerOrder@pcbnew/basepcbframe.cpp). Preserving usual order would result in not very natural display, such as showing silkscreen texts on the bottom. * Introduced new hotkey (Alt+F12) and new menu option (View->Switch canvas) for switching canvas during runtime. * Some of classes (mostly derived from BOARD_ITEM) now includes ViewBBox & ViewGetLayers methods. * Removed tools/class_painter.h, as now it is extended and included in source code. Build changes: * GAL-based rendering option is turned on by a new compilation CMake option KICAD_GAL. * When compiling with CMake option KICAD_GAL=ON, GLEW and Cairo libraries are required. * GAL-related code is compiled into a static library (common/libgal). * Build with KICAD_GAL=OFF should not need any new libraries and should come out as a standard version of Kicad Currently most of items in pcbnew can be displayed using OpenGL (to be done are DIMENSIONS and MARKERS). More details about GAL can be found in: http://www.ohwr.org/attachments/1884/view-spec.pdf
13 years ago
Introduction of Graphics Abstraction Layer based rendering for pcbnew. New classes: - VIEW - represents view that is seen by user, takes care of layer ordering & visibility and how it is displayed (which location, how much zoomed, etc.) - VIEW_ITEM - Base class for every item that can be displayed on VIEW (the biggest change is that now it may be necessary to override ViewBBox & ViewGetLayers method for derived classes). - EDA_DRAW_PANEL_GAL - Inherits after EDA_DRAW_PANEL, displays VIEW output, right now it is not editable (in opposite to usual EDA_DRAW_PANEL). - GAL/OPENGL_GAL/CAIRO_GAL - Base Graphics Abstraction Layer class + two different flavours (Cairo is not fully supported yet), that offers methods to draw primitives using different libraries. - WX_VIEW_CONTROLS - Controller for VIEW, handles user events, allows zooming, panning, etc. - PAINTER/PCB_PAINTER - Classes that uses GAL interface to draw items (as you may have already guessed - PCB_PAINTER is a class for drawing PCB specific object, PAINTER is an abstract class). Its methods are invoked by VIEW, when an item has to be drawn. To display a new type of item - you need to implement draw(ITEM_TYPE*) method that draws it using GAL methods. - STROKE_FONT - Implements stroke font drawing using GAL methods. Most important changes to Kicad original code: * EDA_ITEM now inherits from VIEW_ITEM, which is a base class for all drawable objects. * EDA_DRAW_FRAME contains both usual EDA_DRAW_PANEL and new EDA_DRAW_PANEL_GAL, that can be switched anytime. * There are some new layers for displaying multilayer pads, vias & pads holes (these are not shown yet on the right sidebar in pcbnew) * Display order of layers is different than in previous versions (if you are curious - you may check m_galLayerOrder@pcbnew/basepcbframe.cpp). Preserving usual order would result in not very natural display, such as showing silkscreen texts on the bottom. * Introduced new hotkey (Alt+F12) and new menu option (View->Switch canvas) for switching canvas during runtime. * Some of classes (mostly derived from BOARD_ITEM) now includes ViewBBox & ViewGetLayers methods. * Removed tools/class_painter.h, as now it is extended and included in source code. Build changes: * GAL-based rendering option is turned on by a new compilation CMake option KICAD_GAL. * When compiling with CMake option KICAD_GAL=ON, GLEW and Cairo libraries are required. * GAL-related code is compiled into a static library (common/libgal). * Build with KICAD_GAL=OFF should not need any new libraries and should come out as a standard version of Kicad Currently most of items in pcbnew can be displayed using OpenGL (to be done are DIMENSIONS and MARKERS). More details about GAL can be found in: http://www.ohwr.org/attachments/1884/view-spec.pdf
13 years ago
13 years ago
Introduction of Graphics Abstraction Layer based rendering for pcbnew. New classes: - VIEW - represents view that is seen by user, takes care of layer ordering & visibility and how it is displayed (which location, how much zoomed, etc.) - VIEW_ITEM - Base class for every item that can be displayed on VIEW (the biggest change is that now it may be necessary to override ViewBBox & ViewGetLayers method for derived classes). - EDA_DRAW_PANEL_GAL - Inherits after EDA_DRAW_PANEL, displays VIEW output, right now it is not editable (in opposite to usual EDA_DRAW_PANEL). - GAL/OPENGL_GAL/CAIRO_GAL - Base Graphics Abstraction Layer class + two different flavours (Cairo is not fully supported yet), that offers methods to draw primitives using different libraries. - WX_VIEW_CONTROLS - Controller for VIEW, handles user events, allows zooming, panning, etc. - PAINTER/PCB_PAINTER - Classes that uses GAL interface to draw items (as you may have already guessed - PCB_PAINTER is a class for drawing PCB specific object, PAINTER is an abstract class). Its methods are invoked by VIEW, when an item has to be drawn. To display a new type of item - you need to implement draw(ITEM_TYPE*) method that draws it using GAL methods. - STROKE_FONT - Implements stroke font drawing using GAL methods. Most important changes to Kicad original code: * EDA_ITEM now inherits from VIEW_ITEM, which is a base class for all drawable objects. * EDA_DRAW_FRAME contains both usual EDA_DRAW_PANEL and new EDA_DRAW_PANEL_GAL, that can be switched anytime. * There are some new layers for displaying multilayer pads, vias & pads holes (these are not shown yet on the right sidebar in pcbnew) * Display order of layers is different than in previous versions (if you are curious - you may check m_galLayerOrder@pcbnew/basepcbframe.cpp). Preserving usual order would result in not very natural display, such as showing silkscreen texts on the bottom. * Introduced new hotkey (Alt+F12) and new menu option (View->Switch canvas) for switching canvas during runtime. * Some of classes (mostly derived from BOARD_ITEM) now includes ViewBBox & ViewGetLayers methods. * Removed tools/class_painter.h, as now it is extended and included in source code. Build changes: * GAL-based rendering option is turned on by a new compilation CMake option KICAD_GAL. * When compiling with CMake option KICAD_GAL=ON, GLEW and Cairo libraries are required. * GAL-related code is compiled into a static library (common/libgal). * Build with KICAD_GAL=OFF should not need any new libraries and should come out as a standard version of Kicad Currently most of items in pcbnew can be displayed using OpenGL (to be done are DIMENSIONS and MARKERS). More details about GAL can be found in: http://www.ohwr.org/attachments/1884/view-spec.pdf
13 years ago
Introduction of Graphics Abstraction Layer based rendering for pcbnew. New classes: - VIEW - represents view that is seen by user, takes care of layer ordering & visibility and how it is displayed (which location, how much zoomed, etc.) - VIEW_ITEM - Base class for every item that can be displayed on VIEW (the biggest change is that now it may be necessary to override ViewBBox & ViewGetLayers method for derived classes). - EDA_DRAW_PANEL_GAL - Inherits after EDA_DRAW_PANEL, displays VIEW output, right now it is not editable (in opposite to usual EDA_DRAW_PANEL). - GAL/OPENGL_GAL/CAIRO_GAL - Base Graphics Abstraction Layer class + two different flavours (Cairo is not fully supported yet), that offers methods to draw primitives using different libraries. - WX_VIEW_CONTROLS - Controller for VIEW, handles user events, allows zooming, panning, etc. - PAINTER/PCB_PAINTER - Classes that uses GAL interface to draw items (as you may have already guessed - PCB_PAINTER is a class for drawing PCB specific object, PAINTER is an abstract class). Its methods are invoked by VIEW, when an item has to be drawn. To display a new type of item - you need to implement draw(ITEM_TYPE*) method that draws it using GAL methods. - STROKE_FONT - Implements stroke font drawing using GAL methods. Most important changes to Kicad original code: * EDA_ITEM now inherits from VIEW_ITEM, which is a base class for all drawable objects. * EDA_DRAW_FRAME contains both usual EDA_DRAW_PANEL and new EDA_DRAW_PANEL_GAL, that can be switched anytime. * There are some new layers for displaying multilayer pads, vias & pads holes (these are not shown yet on the right sidebar in pcbnew) * Display order of layers is different than in previous versions (if you are curious - you may check m_galLayerOrder@pcbnew/basepcbframe.cpp). Preserving usual order would result in not very natural display, such as showing silkscreen texts on the bottom. * Introduced new hotkey (Alt+F12) and new menu option (View->Switch canvas) for switching canvas during runtime. * Some of classes (mostly derived from BOARD_ITEM) now includes ViewBBox & ViewGetLayers methods. * Removed tools/class_painter.h, as now it is extended and included in source code. Build changes: * GAL-based rendering option is turned on by a new compilation CMake option KICAD_GAL. * When compiling with CMake option KICAD_GAL=ON, GLEW and Cairo libraries are required. * GAL-related code is compiled into a static library (common/libgal). * Build with KICAD_GAL=OFF should not need any new libraries and should come out as a standard version of Kicad Currently most of items in pcbnew can be displayed using OpenGL (to be done are DIMENSIONS and MARKERS). More details about GAL can be found in: http://www.ohwr.org/attachments/1884/view-spec.pdf
13 years ago
Introduction of Graphics Abstraction Layer based rendering for pcbnew. New classes: - VIEW - represents view that is seen by user, takes care of layer ordering & visibility and how it is displayed (which location, how much zoomed, etc.) - VIEW_ITEM - Base class for every item that can be displayed on VIEW (the biggest change is that now it may be necessary to override ViewBBox & ViewGetLayers method for derived classes). - EDA_DRAW_PANEL_GAL - Inherits after EDA_DRAW_PANEL, displays VIEW output, right now it is not editable (in opposite to usual EDA_DRAW_PANEL). - GAL/OPENGL_GAL/CAIRO_GAL - Base Graphics Abstraction Layer class + two different flavours (Cairo is not fully supported yet), that offers methods to draw primitives using different libraries. - WX_VIEW_CONTROLS - Controller for VIEW, handles user events, allows zooming, panning, etc. - PAINTER/PCB_PAINTER - Classes that uses GAL interface to draw items (as you may have already guessed - PCB_PAINTER is a class for drawing PCB specific object, PAINTER is an abstract class). Its methods are invoked by VIEW, when an item has to be drawn. To display a new type of item - you need to implement draw(ITEM_TYPE*) method that draws it using GAL methods. - STROKE_FONT - Implements stroke font drawing using GAL methods. Most important changes to Kicad original code: * EDA_ITEM now inherits from VIEW_ITEM, which is a base class for all drawable objects. * EDA_DRAW_FRAME contains both usual EDA_DRAW_PANEL and new EDA_DRAW_PANEL_GAL, that can be switched anytime. * There are some new layers for displaying multilayer pads, vias & pads holes (these are not shown yet on the right sidebar in pcbnew) * Display order of layers is different than in previous versions (if you are curious - you may check m_galLayerOrder@pcbnew/basepcbframe.cpp). Preserving usual order would result in not very natural display, such as showing silkscreen texts on the bottom. * Introduced new hotkey (Alt+F12) and new menu option (View->Switch canvas) for switching canvas during runtime. * Some of classes (mostly derived from BOARD_ITEM) now includes ViewBBox & ViewGetLayers methods. * Removed tools/class_painter.h, as now it is extended and included in source code. Build changes: * GAL-based rendering option is turned on by a new compilation CMake option KICAD_GAL. * When compiling with CMake option KICAD_GAL=ON, GLEW and Cairo libraries are required. * GAL-related code is compiled into a static library (common/libgal). * Build with KICAD_GAL=OFF should not need any new libraries and should come out as a standard version of Kicad Currently most of items in pcbnew can be displayed using OpenGL (to be done are DIMENSIONS and MARKERS). More details about GAL can be found in: http://www.ohwr.org/attachments/1884/view-spec.pdf
13 years ago
13 years ago
  1. /*
  2. * This program source code file is part of KiCad, a free EDA CAD application.
  3. *
  4. * Copyright (C) 2004 Jean-Pierre Charras, jean-pierre.charras@gipsa-lab.inpg.fr
  5. * Copyright (C) 2008-2011 Wayne Stambaugh <stambaughw@verizon.net>
  6. * Copyright (C) 2004-2011 KiCad Developers, see change_log.txt for contributors.
  7. *
  8. * This program is free software; you can redistribute it and/or
  9. * modify it under the terms of the GNU General Public License
  10. * as published by the Free Software Foundation; either version 2
  11. * of the License, or (at your option) any later version.
  12. *
  13. * This program is distributed in the hope that it will be useful,
  14. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  16. * GNU General Public License for more details.
  17. *
  18. * You should have received a copy of the GNU General Public License
  19. * along with this program; if not, you may find one here:
  20. * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
  21. * or you may search the http://www.gnu.org website for the version 2 license,
  22. * or you may write to the Free Software Foundation, Inc.,
  23. * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
  24. */
  25. /**
  26. * @file draw_frame.cpp
  27. */
  28. #include <fctsys.h>
  29. #include <pgm_base.h>
  30. #include <kiface_i.h>
  31. #include <gr_basic.h>
  32. #include <common.h>
  33. #include <bitmaps.h>
  34. #include <macros.h>
  35. #include <id.h>
  36. #include <class_drawpanel.h>
  37. #include <class_draw_panel_gal.h>
  38. #include <class_base_screen.h>
  39. #include <msgpanel.h>
  40. #include <draw_frame.h>
  41. #include <confirm.h>
  42. #include <kicad_device_context.h>
  43. #include <dialog_helpers.h>
  44. #include <base_units.h>
  45. #include <math/box2.h>
  46. #include <wx/fontdlg.h>
  47. #include <wx/snglinst.h>
  48. #include <view/view.h>
  49. #include <view/view_controls.h>
  50. #include <gal/graphics_abstraction_layer.h>
  51. /**
  52. * Definition for enabling and disabling scroll bar setting trace output. See the
  53. * wxWidgets documentation on useing the WXTRACE environment variable.
  54. */
  55. static const wxString traceScrollSettings( wxT( "KicadScrollSettings" ) );
  56. // Configuration entry names.
  57. static const wxString CursorShapeEntryKeyword( wxT( "CursorShape" ) );
  58. static const wxString ShowGridEntryKeyword( wxT( "ShowGrid" ) );
  59. static const wxString GridColorEntryKeyword( wxT( "GridColor" ) );
  60. static const wxString LastGridSizeIdKeyword( wxT( "_LastGridSize" ) );
  61. BEGIN_EVENT_TABLE( EDA_DRAW_FRAME, KIWAY_PLAYER )
  62. EVT_MOUSEWHEEL( EDA_DRAW_FRAME::OnMouseEvent )
  63. EVT_MENU_OPEN( EDA_DRAW_FRAME::OnMenuOpen )
  64. EVT_ACTIVATE( EDA_DRAW_FRAME::OnActivate )
  65. EVT_MENU_RANGE( ID_ZOOM_BEGIN, ID_ZOOM_END, EDA_DRAW_FRAME::OnZoom )
  66. EVT_MENU_RANGE( ID_POPUP_ZOOM_START_RANGE, ID_POPUP_ZOOM_END_RANGE,
  67. EDA_DRAW_FRAME::OnZoom )
  68. EVT_MENU_RANGE( ID_POPUP_GRID_LEVEL_1000, ID_POPUP_GRID_USER,
  69. EDA_DRAW_FRAME::OnSelectGrid )
  70. EVT_TOOL( ID_TB_OPTIONS_SHOW_GRID, EDA_DRAW_FRAME::OnToggleGridState )
  71. EVT_TOOL_RANGE( ID_TB_OPTIONS_SELECT_UNIT_MM, ID_TB_OPTIONS_SELECT_UNIT_INCH,
  72. EDA_DRAW_FRAME::OnSelectUnits )
  73. EVT_TOOL( ID_TB_OPTIONS_SELECT_CURSOR, EDA_DRAW_FRAME::OnToggleCrossHairStyle )
  74. EVT_UPDATE_UI( wxID_UNDO, EDA_DRAW_FRAME::OnUpdateUndo )
  75. EVT_UPDATE_UI( wxID_REDO, EDA_DRAW_FRAME::OnUpdateRedo )
  76. EVT_UPDATE_UI( ID_TB_OPTIONS_SHOW_GRID, EDA_DRAW_FRAME::OnUpdateGrid )
  77. EVT_UPDATE_UI( ID_TB_OPTIONS_SELECT_CURSOR, EDA_DRAW_FRAME::OnUpdateCrossHairStyle )
  78. EVT_UPDATE_UI_RANGE( ID_TB_OPTIONS_SELECT_UNIT_MM, ID_TB_OPTIONS_SELECT_UNIT_INCH,
  79. EDA_DRAW_FRAME::OnUpdateUnits )
  80. END_EVENT_TABLE()
  81. EDA_DRAW_FRAME::EDA_DRAW_FRAME( KIWAY* aKiway, wxWindow* aParent,
  82. FRAME_T aFrameType,
  83. const wxString& aTitle,
  84. const wxPoint& aPos, const wxSize& aSize,
  85. long aStyle, const wxString & aFrameName ) :
  86. KIWAY_PLAYER( aKiway, aParent, aFrameType, aTitle, aPos, aSize, aStyle, aFrameName )
  87. {
  88. m_file_checker = NULL;
  89. m_drawToolBar = NULL;
  90. m_optionsToolBar = NULL;
  91. m_gridSelectBox = NULL;
  92. m_zoomSelectBox = NULL;
  93. m_HotkeysZoomAndGridList = NULL;
  94. m_canvas = NULL;
  95. m_galCanvas = NULL;
  96. m_galCanvasActive = false;
  97. m_messagePanel = NULL;
  98. m_currentScreen = NULL;
  99. m_toolId = ID_NO_TOOL_SELECTED;
  100. m_lastDrawToolId = ID_NO_TOOL_SELECTED;
  101. m_showAxis = false; // true to draw axis.
  102. m_showBorderAndTitleBlock = false; // true to display reference sheet.
  103. m_showGridAxis = false; // true to draw the grid axis
  104. m_showOriginAxis = false; // true to draw the grid origin
  105. m_cursorShape = 0;
  106. m_LastGridSizeId = 0;
  107. m_drawGrid = true; // hide/Show grid. default = show
  108. m_gridColor = DARKGRAY; // Default grid color
  109. m_showPageLimits = false;
  110. m_drawBgColor = BLACK; // the background color of the draw canvas:
  111. // BLACK for Pcbnew, BLACK or WHITE for eeschema
  112. m_snapToGrid = true;
  113. m_MsgFrameHeight = EDA_MSG_PANEL::GetRequiredHeight();
  114. m_movingCursorWithKeyboard = false;
  115. m_auimgr.SetFlags(wxAUI_MGR_DEFAULT|wxAUI_MGR_LIVE_RESIZE);
  116. CreateStatusBar( 6 );
  117. // set the size of the status bar subwindows:
  118. wxWindow* stsbar = GetStatusBar();
  119. int dims[] = {
  120. // remainder of status bar on far left is set to a default or whatever is left over.
  121. -1,
  122. // When using GetTextSize() remember the width of character '1' is not the same
  123. // as the width of '0' unless the font is fixed width, and it usually won't be.
  124. // zoom:
  125. GetTextSize( wxT( "Z 762000" ), stsbar ).x + 10,
  126. // cursor coords
  127. GetTextSize( wxT( "X 0234.567890 Y 0234.567890" ), stsbar ).x + 10,
  128. // delta distances
  129. GetTextSize( wxT( "dx 0234.567890 dx 0234.567890 d 0234.567890" ), stsbar ).x + 10,
  130. // units display, Inches is bigger than mm
  131. GetTextSize( _( "Inches" ), stsbar ).x + 10,
  132. // Size for the panel used as "Current tool in play": will take longest string from
  133. // void PCB_EDIT_FRAME::OnSelectTool( wxCommandEvent& aEvent ) in pcbnew/edit.cpp
  134. GetTextSize( wxT( "Add layer alignment target" ), stsbar ).x + 10,
  135. };
  136. SetStatusWidths( DIM( dims ), dims );
  137. // Create child subwindows.
  138. GetClientSize( &m_FrameSize.x, &m_FrameSize.y );
  139. m_FramePos.x = m_FramePos.y = 0;
  140. m_FrameSize.y -= m_MsgFrameHeight;
  141. m_canvas = new EDA_DRAW_PANEL( this, -1, wxPoint( 0, 0 ), m_FrameSize );
  142. m_messagePanel = new EDA_MSG_PANEL( this, -1, wxPoint( 0, m_FrameSize.y ),
  143. wxSize( m_FrameSize.x, m_MsgFrameHeight ) );
  144. m_messagePanel->SetBackgroundColour( MakeColour( LIGHTGRAY ) );
  145. }
  146. EDA_DRAW_FRAME::~EDA_DRAW_FRAME()
  147. {
  148. delete m_currentScreen;
  149. m_currentScreen = NULL;
  150. m_auimgr.UnInit();
  151. ReleaseFile();
  152. }
  153. void EDA_DRAW_FRAME::ReleaseFile()
  154. {
  155. delete m_file_checker;
  156. m_file_checker = 0;
  157. }
  158. bool EDA_DRAW_FRAME::LockFile( const wxString& aFileName )
  159. {
  160. delete m_file_checker;
  161. m_file_checker = ::LockFile( aFileName );
  162. return bool( m_file_checker );
  163. }
  164. void EDA_DRAW_FRAME::unitsChangeRefresh()
  165. {
  166. UpdateStatusBar();
  167. EDA_ITEM* item = GetScreen()->GetCurItem();
  168. if( item )
  169. SetMsgPanel( item );
  170. }
  171. void EDA_DRAW_FRAME::EraseMsgBox()
  172. {
  173. if( m_messagePanel )
  174. m_messagePanel->EraseMsgBox();
  175. }
  176. void EDA_DRAW_FRAME::OnActivate( wxActivateEvent& event )
  177. {
  178. m_FrameIsActive = event.GetActive();
  179. if( m_canvas )
  180. m_canvas->SetCanStartBlock( -1 );
  181. event.Skip(); // required under wxMAC
  182. }
  183. void EDA_DRAW_FRAME::OnMenuOpen( wxMenuEvent& event )
  184. {
  185. if( m_canvas )
  186. m_canvas->SetCanStartBlock( -1 );
  187. event.Skip();
  188. }
  189. void EDA_DRAW_FRAME::SkipNextLeftButtonReleaseEvent()
  190. {
  191. m_canvas->SetIgnoreLeftButtonReleaseEvent( true );
  192. }
  193. void EDA_DRAW_FRAME::OnToggleGridState( wxCommandEvent& aEvent )
  194. {
  195. SetGridVisibility( !IsGridVisible() );
  196. if( IsGalCanvasActive() )
  197. {
  198. GetGalCanvas()->GetGAL()->SetGridVisibility( IsGridVisible() );
  199. GetGalCanvas()->GetView()->MarkTargetDirty( KIGFX::TARGET_NONCACHED );
  200. }
  201. m_canvas->Refresh();
  202. }
  203. void EDA_DRAW_FRAME::OnSelectUnits( wxCommandEvent& aEvent )
  204. {
  205. if( aEvent.GetId() == ID_TB_OPTIONS_SELECT_UNIT_MM && g_UserUnit != MILLIMETRES )
  206. {
  207. g_UserUnit = MILLIMETRES;
  208. unitsChangeRefresh();
  209. }
  210. else if( aEvent.GetId() == ID_TB_OPTIONS_SELECT_UNIT_INCH && g_UserUnit != INCHES )
  211. {
  212. g_UserUnit = INCHES;
  213. unitsChangeRefresh();
  214. }
  215. }
  216. void EDA_DRAW_FRAME::OnToggleCrossHairStyle( wxCommandEvent& aEvent )
  217. {
  218. INSTALL_UNBUFFERED_DC( dc, m_canvas );
  219. m_canvas->CrossHairOff( &dc );
  220. m_cursorShape = !m_cursorShape;
  221. m_canvas->CrossHairOn( &dc );
  222. }
  223. void EDA_DRAW_FRAME::OnUpdateUndo( wxUpdateUIEvent& aEvent )
  224. {
  225. if( GetScreen() )
  226. aEvent.Enable( GetScreen()->GetUndoCommandCount() > 0 );
  227. }
  228. void EDA_DRAW_FRAME::OnUpdateRedo( wxUpdateUIEvent& aEvent )
  229. {
  230. if( GetScreen() )
  231. aEvent.Enable( GetScreen()->GetRedoCommandCount() > 0 );
  232. }
  233. void EDA_DRAW_FRAME::OnUpdateUnits( wxUpdateUIEvent& aEvent )
  234. {
  235. bool enable;
  236. enable = ( ((aEvent.GetId() == ID_TB_OPTIONS_SELECT_UNIT_MM) && (g_UserUnit == MILLIMETRES))
  237. || ((aEvent.GetId() == ID_TB_OPTIONS_SELECT_UNIT_INCH) && (g_UserUnit == INCHES)) );
  238. aEvent.Check( enable );
  239. DisplayUnitsMsg();
  240. }
  241. void EDA_DRAW_FRAME::OnUpdateGrid( wxUpdateUIEvent& aEvent )
  242. {
  243. wxString tool_tip = IsGridVisible() ? _( "Hide grid" ) : _( "Show grid" );
  244. aEvent.Check( IsGridVisible() );
  245. m_optionsToolBar->SetToolShortHelp( ID_TB_OPTIONS_SHOW_GRID, tool_tip );
  246. }
  247. void EDA_DRAW_FRAME::OnUpdateCrossHairStyle( wxUpdateUIEvent& aEvent )
  248. {
  249. aEvent.Check( m_cursorShape );
  250. }
  251. void EDA_DRAW_FRAME::ReCreateAuxiliaryToolbar()
  252. {
  253. }
  254. void EDA_DRAW_FRAME::ReCreateMenuBar()
  255. {
  256. }
  257. bool EDA_DRAW_FRAME::OnHotKey( wxDC* aDC, int aHotKey, const wxPoint& aPosition, EDA_ITEM* aItem )
  258. {
  259. return false;
  260. }
  261. void EDA_DRAW_FRAME::ToolOnRightClick( wxCommandEvent& event )
  262. {
  263. }
  264. void EDA_DRAW_FRAME::PrintPage( wxDC* aDC, LSET aPrintMask, bool aPrintMirrorMode, void* aData )
  265. {
  266. wxMessageBox( wxT("EDA_DRAW_FRAME::PrintPage() error") );
  267. }
  268. void EDA_DRAW_FRAME::OnSelectGrid( wxCommandEvent& event )
  269. {
  270. int* clientData;
  271. int eventId = ID_POPUP_GRID_LEVEL_100;
  272. if( event.GetEventType() == wxEVT_COMMAND_COMBOBOX_SELECTED )
  273. {
  274. if( m_gridSelectBox == NULL )
  275. return;
  276. /*
  277. * Don't use wxCommandEvent::GetClientData() here. It always
  278. * returns NULL in GTK. This solution is not as elegant but
  279. * it works.
  280. */
  281. int index = m_gridSelectBox->GetSelection();
  282. wxASSERT( index != wxNOT_FOUND );
  283. clientData = (int*) m_gridSelectBox->wxItemContainer::GetClientData( index );
  284. if( clientData != NULL )
  285. eventId = *clientData;
  286. }
  287. else
  288. {
  289. eventId = event.GetId();
  290. /* Update the grid select combobox if the grid size was changed
  291. * by menu event.
  292. */
  293. if( m_gridSelectBox != NULL )
  294. {
  295. for( size_t i = 0; i < m_gridSelectBox->GetCount(); i++ )
  296. {
  297. clientData = (int*) m_gridSelectBox->wxItemContainer::GetClientData( i );
  298. if( clientData && eventId == *clientData )
  299. {
  300. m_gridSelectBox->SetSelection( i );
  301. break;
  302. }
  303. }
  304. }
  305. }
  306. // Be sure m_LastGridSizeId is up to date.
  307. m_LastGridSizeId = eventId - ID_POPUP_GRID_LEVEL_1000;
  308. BASE_SCREEN* screen = GetScreen();
  309. if( screen->GetGridId() == eventId )
  310. return;
  311. /*
  312. * This allows for saving non-sequential command ID offsets used that
  313. * may be used in the grid size combobox. Do not use the selection
  314. * index returned by GetSelection().
  315. */
  316. screen->SetGrid( eventId );
  317. SetCrossHairPosition( RefPos( true ) );
  318. if( IsGalCanvasActive() )
  319. {
  320. GetGalCanvas()->GetGAL()->SetGridSize( VECTOR2D( screen->GetGrid().m_Size.x,
  321. screen->GetGrid().m_Size.y ) );
  322. GetGalCanvas()->GetView()->MarkTargetDirty( KIGFX::TARGET_NONCACHED );
  323. }
  324. m_canvas->Refresh();
  325. }
  326. void EDA_DRAW_FRAME::OnSelectZoom( wxCommandEvent& event )
  327. {
  328. if( m_zoomSelectBox == NULL )
  329. return; // Should not happen!
  330. int id = m_zoomSelectBox->GetCurrentSelection();
  331. if( id < 0 || !( id < (int)m_zoomSelectBox->GetCount() ) )
  332. return;
  333. if( id == 0 ) // Auto zoom (Fit in Page)
  334. {
  335. Zoom_Automatique( true );
  336. }
  337. else
  338. {
  339. id--;
  340. double selectedZoom = GetScreen()->m_ZoomList[id];
  341. if( GetScreen()->GetZoom() == selectedZoom )
  342. return;
  343. GetScreen()->SetZoom( selectedZoom );
  344. if( IsGalCanvasActive() )
  345. {
  346. // Apply computed view settings to GAL
  347. KIGFX::VIEW* view = GetGalCanvas()->GetView();
  348. KIGFX::GAL* gal = GetGalCanvas()->GetGAL();
  349. double zoomFactor = gal->GetWorldScale() / gal->GetZoomFactor();
  350. double zoom = 1.0 / ( zoomFactor * GetZoom() );
  351. view->SetScale( zoom );
  352. GetGalCanvas()->Refresh();
  353. }
  354. else
  355. RedrawScreen( GetScrollCenterPosition(), false );
  356. }
  357. }
  358. double EDA_DRAW_FRAME::GetZoom()
  359. {
  360. return GetScreen()->GetZoom();
  361. }
  362. void EDA_DRAW_FRAME::OnMouseEvent( wxMouseEvent& event )
  363. {
  364. event.Skip();
  365. }
  366. void EDA_DRAW_FRAME::OnLeftDClick( wxDC* DC, const wxPoint& MousePos )
  367. {
  368. }
  369. void EDA_DRAW_FRAME::DisplayToolMsg( const wxString& msg )
  370. {
  371. SetStatusText( msg, 5 );
  372. }
  373. void EDA_DRAW_FRAME::DisplayUnitsMsg()
  374. {
  375. wxString msg;
  376. switch( g_UserUnit )
  377. {
  378. case INCHES:
  379. msg = _( "Inches" );
  380. break;
  381. case MILLIMETRES:
  382. msg = _( "mm" );
  383. break;
  384. default:
  385. msg = _( "Units" );
  386. break;
  387. }
  388. SetStatusText( msg, 4 );
  389. }
  390. void EDA_DRAW_FRAME::OnSize( wxSizeEvent& SizeEv )
  391. {
  392. m_FrameSize = GetClientSize( );
  393. SizeEv.Skip();
  394. }
  395. void EDA_DRAW_FRAME::SetToolID( int aId, int aCursor, const wxString& aToolMsg )
  396. {
  397. // Keep default cursor in toolbars
  398. SetCursor( wxNullCursor );
  399. // Change m_canvas cursor if requested.
  400. if( m_canvas && aCursor >= 0 )
  401. m_canvas->SetCurrentCursor( aCursor );
  402. DisplayToolMsg( aToolMsg );
  403. if( aId < 0 )
  404. return;
  405. wxCHECK2_MSG( aId >= ID_NO_TOOL_SELECTED, aId = ID_NO_TOOL_SELECTED,
  406. wxString::Format( wxT( "Current tool ID cannot be set to %d." ), aId ) );
  407. m_toolId = aId;
  408. }
  409. wxPoint EDA_DRAW_FRAME::GetGridPosition( const wxPoint& aPosition ) const
  410. {
  411. wxPoint pos = aPosition;
  412. if( m_currentScreen != NULL && m_snapToGrid )
  413. pos = GetNearestGridPosition( aPosition );
  414. return pos;
  415. }
  416. void EDA_DRAW_FRAME::SetNextGrid()
  417. {
  418. if( m_gridSelectBox )
  419. {
  420. m_gridSelectBox->SetSelection( ( m_gridSelectBox->GetSelection() + 1 ) %
  421. m_gridSelectBox->GetCount() );
  422. wxCommandEvent cmd( wxEVT_COMMAND_COMBOBOX_SELECTED );
  423. // cmd.SetEventObject( this );
  424. OnSelectGrid( cmd );
  425. }
  426. }
  427. void EDA_DRAW_FRAME::SetPrevGrid()
  428. {
  429. if( m_gridSelectBox )
  430. {
  431. int cnt = m_gridSelectBox->GetSelection();
  432. if( --cnt < 0 )
  433. cnt = m_gridSelectBox->GetCount() - 1;
  434. m_gridSelectBox->SetSelection( cnt );
  435. wxCommandEvent cmd( wxEVT_COMMAND_COMBOBOX_SELECTED );
  436. // cmd.SetEventObject( this );
  437. OnSelectGrid( cmd );
  438. }
  439. }
  440. int EDA_DRAW_FRAME::BlockCommand( int key )
  441. {
  442. return 0;
  443. }
  444. void EDA_DRAW_FRAME::InitBlockPasteInfos()
  445. {
  446. GetScreen()->m_BlockLocate.ClearItemsList();
  447. m_canvas->SetMouseCaptureCallback( NULL );
  448. }
  449. void EDA_DRAW_FRAME::HandleBlockPlace( wxDC* DC )
  450. {
  451. }
  452. bool EDA_DRAW_FRAME::HandleBlockEnd( wxDC* DC )
  453. {
  454. return false;
  455. }
  456. void EDA_DRAW_FRAME::UpdateStatusBar()
  457. {
  458. wxString Line;
  459. BASE_SCREEN* screen = GetScreen();
  460. if( !screen )
  461. return;
  462. // Display Zoom level: zoom = zoom_coeff/ZoomScalar
  463. Line.Printf( wxT( "Z %g" ), screen->GetZoom() );
  464. SetStatusText( Line, 1 );
  465. // Absolute and relative cursor positions are handled by overloading this function and
  466. // handling the internal to user units conversion at the appropriate level.
  467. // refresh units display
  468. DisplayUnitsMsg();
  469. }
  470. void EDA_DRAW_FRAME::LoadSettings( wxConfigBase* aCfg )
  471. {
  472. EDA_BASE_FRAME::LoadSettings( aCfg );
  473. aCfg->Read( m_FrameName + CursorShapeEntryKeyword, &m_cursorShape, ( long )0 );
  474. bool btmp;
  475. if( aCfg->Read( m_FrameName + ShowGridEntryKeyword, &btmp ) )
  476. SetGridVisibility( btmp );
  477. int itmp;
  478. if( aCfg->Read( m_FrameName + GridColorEntryKeyword, &itmp ) )
  479. SetGridColor( ColorFromInt( itmp ) );
  480. aCfg->Read( m_FrameName + LastGridSizeIdKeyword, &m_LastGridSizeId, 0L );
  481. // m_LastGridSizeId is an offset, expected to be >= 0
  482. if( m_LastGridSizeId < 0 )
  483. m_LastGridSizeId = 0;
  484. }
  485. void EDA_DRAW_FRAME::SaveSettings( wxConfigBase* aCfg )
  486. {
  487. EDA_BASE_FRAME::SaveSettings( aCfg );
  488. aCfg->Write( m_FrameName + CursorShapeEntryKeyword, m_cursorShape );
  489. aCfg->Write( m_FrameName + ShowGridEntryKeyword, IsGridVisible() );
  490. aCfg->Write( m_FrameName + GridColorEntryKeyword, ( long ) GetGridColor() );
  491. aCfg->Write( m_FrameName + LastGridSizeIdKeyword, ( long ) m_LastGridSizeId );
  492. }
  493. void EDA_DRAW_FRAME::AppendMsgPanel( const wxString& textUpper,
  494. const wxString& textLower,
  495. EDA_COLOR_T color, int pad )
  496. {
  497. if( m_messagePanel == NULL )
  498. return;
  499. m_messagePanel->AppendMessage( textUpper, textLower, color, pad );
  500. }
  501. void EDA_DRAW_FRAME::ClearMsgPanel()
  502. {
  503. if( m_messagePanel == NULL )
  504. return;
  505. m_messagePanel->EraseMsgBox();
  506. }
  507. void EDA_DRAW_FRAME::SetMsgPanel( const MSG_PANEL_ITEMS& aList )
  508. {
  509. if( m_messagePanel == NULL )
  510. return;
  511. ClearMsgPanel();
  512. for( unsigned i = 0; i < aList.size(); i++ )
  513. m_messagePanel->AppendMessage( aList[i] );
  514. }
  515. void EDA_DRAW_FRAME::SetMsgPanel( EDA_ITEM* aItem )
  516. {
  517. wxCHECK_RET( aItem != NULL, wxT( "Invalid EDA_ITEM pointer. Bad programmer." ) );
  518. MSG_PANEL_ITEMS items;
  519. aItem->GetMsgPanelInfo( items );
  520. SetMsgPanel( items );
  521. }
  522. wxString EDA_DRAW_FRAME::CoordinateToString( int aValue, bool aConvertToMils ) const
  523. {
  524. return ::CoordinateToString( aValue, aConvertToMils );
  525. }
  526. wxString EDA_DRAW_FRAME::LengthDoubleToString( double aValue, bool aConvertToMils ) const
  527. {
  528. return ::LengthDoubleToString( aValue, aConvertToMils );
  529. }
  530. bool EDA_DRAW_FRAME::HandleBlockBegin( wxDC* aDC, int aKey, const wxPoint& aPosition )
  531. {
  532. BLOCK_SELECTOR* Block = &GetScreen()->m_BlockLocate;
  533. if( ( Block->GetCommand() != BLOCK_IDLE ) || ( Block->GetState() != STATE_NO_BLOCK ) )
  534. return false;
  535. Block->SetCommand( (BLOCK_COMMAND_T) BlockCommand( aKey ) );
  536. if( Block->GetCommand() == 0 )
  537. return false;
  538. switch( Block->GetCommand() )
  539. {
  540. case BLOCK_IDLE:
  541. break;
  542. case BLOCK_MOVE: // Move
  543. case BLOCK_DRAG: // Drag (block defined)
  544. case BLOCK_DRAG_ITEM: // Drag from a drag item command
  545. case BLOCK_COPY: // Copy
  546. case BLOCK_DELETE: // Delete
  547. case BLOCK_SAVE: // Save
  548. case BLOCK_ROTATE: // Rotate 90 deg
  549. case BLOCK_FLIP: // Flip
  550. case BLOCK_ZOOM: // Window Zoom
  551. case BLOCK_MIRROR_X:
  552. case BLOCK_MIRROR_Y: // mirror
  553. case BLOCK_PRESELECT_MOVE: // Move with preselection list
  554. Block->InitData( m_canvas, aPosition );
  555. break;
  556. case BLOCK_PASTE:
  557. Block->InitData( m_canvas, aPosition );
  558. Block->SetLastCursorPosition( wxPoint( 0, 0 ) );
  559. InitBlockPasteInfos();
  560. if( Block->GetCount() == 0 ) // No data to paste
  561. {
  562. DisplayError( this, wxT( "No Block to paste" ), 20 );
  563. GetScreen()->m_BlockLocate.SetCommand( BLOCK_IDLE );
  564. m_canvas->SetMouseCaptureCallback( NULL );
  565. return true;
  566. }
  567. if( !m_canvas->IsMouseCaptured() )
  568. {
  569. Block->ClearItemsList();
  570. DisplayError( this,
  571. wxT( "EDA_DRAW_FRAME::HandleBlockBegin() Err: m_mouseCaptureCallback NULL" ) );
  572. return true;
  573. }
  574. Block->SetState( STATE_BLOCK_MOVE );
  575. m_canvas->CallMouseCapture( aDC, aPosition, false );
  576. break;
  577. default:
  578. {
  579. wxString msg;
  580. msg << wxT( "EDA_DRAW_FRAME::HandleBlockBegin() error: Unknown command " ) <<
  581. Block->GetCommand();
  582. DisplayError( this, msg );
  583. }
  584. break;
  585. }
  586. Block->SetMessageBlock( this );
  587. return true;
  588. }
  589. // I am not seeing a problem with this size yet:
  590. static const double MAX_AXIS = INT_MAX - 100;
  591. #define VIRT_MIN (-MAX_AXIS/2.0) ///< min X or Y coordinate in virtual space
  592. #define VIRT_MAX (MAX_AXIS/2.0) ///< max X or Y coordinate in virtual space
  593. void EDA_DRAW_FRAME::AdjustScrollBars( const wxPoint& aCenterPositionIU )
  594. {
  595. BASE_SCREEN* screen = GetScreen();
  596. if( !screen || !m_canvas )
  597. return;
  598. double scale = screen->GetScalingFactor();
  599. wxLogTrace( traceScrollSettings, wxT( "Center Position = ( %d, %d ), scale = %.10g" ),
  600. aCenterPositionIU.x, aCenterPositionIU.y, scale );
  601. // Calculate the portion of the drawing that can be displayed in the
  602. // client area at the current zoom level.
  603. // visible viewport in device units ~ pixels
  604. wxSize clientSizeDU = m_canvas->GetClientSize();
  605. // Size of the client window in IU
  606. DSIZE clientSizeIU( clientSizeDU.x / scale, clientSizeDU.y / scale );
  607. // Full drawing or "page" rectangle in internal units
  608. DBOX pageRectIU( wxPoint( 0, 0 ), wxSize( GetPageSizeIU().x, GetPageSizeIU().y ) );
  609. // The upper left corner of the client rectangle in internal units.
  610. double xIU = aCenterPositionIU.x - clientSizeIU.x / 2.0;
  611. double yIU = aCenterPositionIU.y - clientSizeIU.y / 2.0;
  612. // If drawn around the center, adjust the client rectangle accordingly.
  613. if( screen->m_Center )
  614. {
  615. // half page offset.
  616. xIU += pageRectIU.GetWidth() / 2.0;
  617. yIU += pageRectIU.GetHeight() / 2.0;
  618. }
  619. DBOX clientRectIU( wxPoint( xIU, yIU ), wxSize( clientSizeIU.x, clientSizeIU.y ) );
  620. wxPoint centerPositionIU;
  621. // put "int" limits on the clientRect
  622. if( clientRectIU.GetLeft() < VIRT_MIN )
  623. clientRectIU.MoveLeftTo( VIRT_MIN );
  624. if( clientRectIU.GetTop() < VIRT_MIN )
  625. clientRectIU.MoveTopTo( VIRT_MIN );
  626. if( clientRectIU.GetRight() > VIRT_MAX )
  627. clientRectIU.MoveRightTo( VIRT_MAX );
  628. if( clientRectIU.GetBottom() > VIRT_MAX )
  629. clientRectIU.MoveBottomTo( VIRT_MAX );
  630. centerPositionIU.x = KiROUND( clientRectIU.GetX() + clientRectIU.GetWidth() / 2 );
  631. centerPositionIU.y = KiROUND( clientRectIU.GetY() + clientRectIU.GetHeight() / 2 );
  632. if( screen->m_Center )
  633. {
  634. centerPositionIU.x -= KiROUND( pageRectIU.GetWidth() / 2.0 );
  635. centerPositionIU.y -= KiROUND( pageRectIU.GetHeight() / 2.0 );
  636. }
  637. DSIZE virtualSizeIU;
  638. if( pageRectIU.GetLeft() < clientRectIU.GetLeft() && pageRectIU.GetRight() > clientRectIU.GetRight() )
  639. {
  640. virtualSizeIU.x = pageRectIU.GetSize().x;
  641. }
  642. else
  643. {
  644. double pageCenterX = pageRectIU.GetX() + ( pageRectIU.GetWidth() / 2 );
  645. double clientCenterX = clientRectIU.GetX() + ( clientRectIU.GetWidth() / 2 );
  646. if( clientRectIU.GetWidth() > pageRectIU.GetWidth() )
  647. {
  648. if( pageCenterX > clientCenterX )
  649. virtualSizeIU.x = ( pageCenterX - clientRectIU.GetLeft() ) * 2;
  650. else if( pageCenterX < clientCenterX )
  651. virtualSizeIU.x = ( clientRectIU.GetRight() - pageCenterX ) * 2;
  652. else
  653. virtualSizeIU.x = clientRectIU.GetWidth();
  654. }
  655. else
  656. {
  657. if( pageCenterX > clientCenterX )
  658. virtualSizeIU.x = pageRectIU.GetWidth() + ( (pageRectIU.GetLeft() - clientRectIU.GetLeft() ) * 2 );
  659. else if( pageCenterX < clientCenterX )
  660. virtualSizeIU.x = pageRectIU.GetWidth() + ( (clientRectIU.GetRight() - pageRectIU.GetRight() ) * 2 );
  661. else
  662. virtualSizeIU.x = pageRectIU.GetWidth();
  663. }
  664. }
  665. if( pageRectIU.GetTop() < clientRectIU.GetTop() && pageRectIU.GetBottom() > clientRectIU.GetBottom() )
  666. {
  667. virtualSizeIU.y = pageRectIU.GetSize().y;
  668. }
  669. else
  670. {
  671. double pageCenterY = pageRectIU.GetY() + ( pageRectIU.GetHeight() / 2 );
  672. double clientCenterY = clientRectIU.GetY() + ( clientRectIU.GetHeight() / 2 );
  673. if( clientRectIU.GetHeight() > pageRectIU.GetHeight() )
  674. {
  675. if( pageCenterY > clientCenterY )
  676. virtualSizeIU.y = ( pageCenterY - clientRectIU.GetTop() ) * 2;
  677. else if( pageCenterY < clientCenterY )
  678. virtualSizeIU.y = ( clientRectIU.GetBottom() - pageCenterY ) * 2;
  679. else
  680. virtualSizeIU.y = clientRectIU.GetHeight();
  681. }
  682. else
  683. {
  684. if( pageCenterY > clientCenterY )
  685. virtualSizeIU.y = pageRectIU.GetHeight() +
  686. ( ( pageRectIU.GetTop() - clientRectIU.GetTop() ) * 2 );
  687. else if( pageCenterY < clientCenterY )
  688. virtualSizeIU.y = pageRectIU.GetHeight() +
  689. ( ( clientRectIU.GetBottom() - pageRectIU.GetBottom() ) * 2 );
  690. else
  691. virtualSizeIU.y = pageRectIU.GetHeight();
  692. }
  693. }
  694. // put "int" limits on the virtualSizeIU
  695. virtualSizeIU.x = std::min( virtualSizeIU.x, MAX_AXIS );
  696. virtualSizeIU.y = std::min( virtualSizeIU.y, MAX_AXIS );
  697. if( screen->m_Center )
  698. {
  699. screen->m_DrawOrg.x = -KiROUND( virtualSizeIU.x / 2.0 );
  700. screen->m_DrawOrg.y = -KiROUND( virtualSizeIU.y / 2.0 );
  701. }
  702. else
  703. {
  704. screen->m_DrawOrg.x = -KiROUND( ( virtualSizeIU.x - pageRectIU.GetWidth() ) / 2.0 );
  705. screen->m_DrawOrg.y = -KiROUND( ( virtualSizeIU.y - pageRectIU.GetHeight() ) / 2.0 );
  706. }
  707. /* Always set scrollbar pixels per unit to 1 unless you want the zoom
  708. * around cursor to jump around. This reported problem occurs when the
  709. * zoom point is not on a pixel per unit increment. If you set the
  710. * pixels per unit to 10, you have potential for the zoom point to
  711. * jump around +/-5 pixels from the nearest grid point.
  712. */
  713. screen->m_ScrollPixelsPerUnitX = screen->m_ScrollPixelsPerUnitY = 1;
  714. // Number of scroll bar units for the given zoom level in device units.
  715. double unitsX = virtualSizeIU.x * scale;
  716. double unitsY = virtualSizeIU.y * scale;
  717. // Calculate the scroll bar position in internal units to place the
  718. // center position at the center of client rectangle.
  719. SetScrollCenterPosition( centerPositionIU );
  720. double posX = centerPositionIU.x - clientRectIU.GetWidth() / 2.0 - screen->m_DrawOrg.x;
  721. double posY = centerPositionIU.y - clientRectIU.GetHeight() / 2.0 - screen->m_DrawOrg.y;
  722. // Convert scroll bar position to device units.
  723. posX = KiROUND( posX * scale );
  724. posY = KiROUND( posY * scale );
  725. if( posX < 0 )
  726. {
  727. wxLogTrace( traceScrollSettings, wxT( "Required scroll bar X position %.10g" ), posX );
  728. posX = 0;
  729. }
  730. if( posX > unitsX )
  731. {
  732. wxLogTrace( traceScrollSettings, wxT( "Required scroll bar X position %.10g" ), posX );
  733. posX = unitsX;
  734. }
  735. if( posY < 0 )
  736. {
  737. wxLogTrace( traceScrollSettings, wxT( "Required scroll bar Y position %.10g" ), posY );
  738. posY = 0;
  739. }
  740. if( posY > unitsY )
  741. {
  742. wxLogTrace( traceScrollSettings, wxT( "Required scroll bar Y position %.10g" ), posY );
  743. posY = unitsY;
  744. }
  745. screen->m_ScrollbarPos = wxPoint( KiROUND( posX ), KiROUND( posY ) );
  746. screen->m_ScrollbarNumber = wxSize( KiROUND( unitsX ), KiROUND( unitsY ) );
  747. wxLogTrace( traceScrollSettings,
  748. wxT( "Drawing = (%.10g, %.10g), Client = (%.10g, %.10g), Offset = (%d, %d), SetScrollbars(%d, %d, %d, %d, %d, %d)" ),
  749. virtualSizeIU.x, virtualSizeIU.y, clientSizeIU.x, clientSizeIU.y,
  750. screen->m_DrawOrg.x, screen->m_DrawOrg.y,
  751. screen->m_ScrollPixelsPerUnitX, screen->m_ScrollPixelsPerUnitY,
  752. screen->m_ScrollbarNumber.x, screen->m_ScrollbarNumber.y,
  753. screen->m_ScrollbarPos.x, screen->m_ScrollbarPos.y );
  754. bool noRefresh = true;
  755. m_canvas->SetScrollbars( screen->m_ScrollPixelsPerUnitX,
  756. screen->m_ScrollPixelsPerUnitY,
  757. screen->m_ScrollbarNumber.x,
  758. screen->m_ScrollbarNumber.y,
  759. screen->m_ScrollbarPos.x,
  760. screen->m_ScrollbarPos.y, noRefresh );
  761. }
  762. void EDA_DRAW_FRAME::UseGalCanvas( bool aEnable )
  763. {
  764. KIGFX::VIEW* view = GetGalCanvas()->GetView();
  765. KIGFX::GAL* gal = GetGalCanvas()->GetGAL();
  766. double zoomFactor = gal->GetWorldScale() / gal->GetZoomFactor();
  767. // Display the same view after canvas switching
  768. if( aEnable )
  769. {
  770. BASE_SCREEN* screen = GetScreen();
  771. // Switch to GAL rendering
  772. if( !IsGalCanvasActive() )
  773. {
  774. // Set up viewport
  775. double zoom = 1.0 / ( zoomFactor * m_canvas->GetZoom() );
  776. view->SetScale( zoom );
  777. view->SetCenter( VECTOR2D( m_canvas->GetScreenCenterLogicalPosition() ) );
  778. }
  779. // Set up grid settings
  780. gal->SetGridVisibility( IsGridVisible() );
  781. gal->SetGridSize( VECTOR2D( screen->GetGridSize().x, screen->GetGridSize().y ) );
  782. gal->SetGridOrigin( VECTOR2D( GetGridOrigin() ) );
  783. }
  784. else
  785. {
  786. // Switch to standard rendering
  787. if( IsGalCanvasActive() )
  788. {
  789. // Change view settings only if GAL was active previously
  790. double zoom = 1.0 / ( zoomFactor * view->GetScale() );
  791. m_canvas->SetZoom( zoom );
  792. VECTOR2D center = view->GetCenter();
  793. RedrawScreen( wxPoint( center.x, center.y ), false );
  794. }
  795. }
  796. m_canvas->SetEvtHandlerEnabled( !aEnable );
  797. GetGalCanvas()->SetEvtHandlerEnabled( aEnable );
  798. // Switch panes
  799. m_auimgr.GetPane( wxT( "DrawFrame" ) ).Show( !aEnable );
  800. m_auimgr.GetPane( wxT( "DrawFrameGal" ) ).Show( aEnable );
  801. m_auimgr.Update();
  802. // Reset current tool on switch();
  803. SetToolID( ID_NO_TOOL_SELECTED, wxCURSOR_DEFAULT, wxEmptyString );
  804. m_galCanvasActive = aEnable;
  805. }
  806. //-----< BASE_SCREEN API moved here >--------------------------------------------
  807. wxPoint EDA_DRAW_FRAME::GetCrossHairPosition( bool aInvertY ) const
  808. {
  809. // subject to change, borrow from old BASE_SCREEN for now.
  810. if( IsGalCanvasActive() )
  811. {
  812. VECTOR2I cursor = GetGalCanvas()->GetViewControls()->GetCursorPosition();
  813. return wxPoint( cursor.x, cursor.y );
  814. }
  815. else
  816. {
  817. BASE_SCREEN* screen = GetScreen(); // virtual call
  818. return screen->getCrossHairPosition( aInvertY );
  819. }
  820. }
  821. void EDA_DRAW_FRAME::SetCrossHairPosition( const wxPoint& aPosition, bool aSnapToGrid )
  822. {
  823. BASE_SCREEN* screen = GetScreen(); // virtual call
  824. screen->setCrossHairPosition( aPosition, GetGridOrigin(), aSnapToGrid );
  825. }
  826. wxPoint EDA_DRAW_FRAME::GetCursorPosition( bool aOnGrid, wxRealPoint* aGridSize ) const
  827. {
  828. BASE_SCREEN* screen = GetScreen(); // virtual call
  829. return screen->getCursorPosition( aOnGrid, GetGridOrigin(), aGridSize );
  830. }
  831. wxPoint EDA_DRAW_FRAME::GetNearestGridPosition( const wxPoint& aPosition, wxRealPoint* aGridSize ) const
  832. {
  833. BASE_SCREEN* screen = GetScreen(); // virtual call
  834. return screen->getNearestGridPosition( aPosition, GetGridOrigin(), aGridSize );
  835. }
  836. wxPoint EDA_DRAW_FRAME::GetCrossHairScreenPosition() const
  837. {
  838. BASE_SCREEN* screen = GetScreen(); // virtual call
  839. return screen->getCrossHairScreenPosition();
  840. }
  841. void EDA_DRAW_FRAME::SetMousePosition( const wxPoint& aPosition )
  842. {
  843. BASE_SCREEN* screen = GetScreen(); // virtual call
  844. screen->setMousePosition( aPosition );
  845. }
  846. wxPoint EDA_DRAW_FRAME::RefPos( bool useMouse ) const
  847. {
  848. BASE_SCREEN* screen = GetScreen(); // virtual call
  849. return screen->refPos( useMouse );
  850. }
  851. const wxPoint& EDA_DRAW_FRAME::GetScrollCenterPosition() const
  852. {
  853. BASE_SCREEN* screen = GetScreen(); // virtual call
  854. return screen->getScrollCenterPosition();
  855. }
  856. void EDA_DRAW_FRAME::SetScrollCenterPosition( const wxPoint& aPoint )
  857. {
  858. BASE_SCREEN* screen = GetScreen(); // virtual call
  859. screen->setScrollCenterPosition( aPoint );
  860. }
  861. //-----</BASE_SCREEN API moved here >--------------------------------------------
  862. void EDA_DRAW_FRAME::RefreshCrossHair( const wxPoint &aOldPos,
  863. const wxPoint &aEvtPos,
  864. wxDC* aDC )
  865. {
  866. wxPoint newpos = GetCrossHairPosition();
  867. // Redraw the crosshair if it moved
  868. if( aOldPos != newpos )
  869. {
  870. SetCrossHairPosition( aOldPos, false );
  871. m_canvas->CrossHairOff( aDC );
  872. SetCrossHairPosition( newpos, false );
  873. m_canvas->CrossHairOn( aDC );
  874. if( m_canvas->IsMouseCaptured() )
  875. {
  876. #ifdef USE_WX_OVERLAY
  877. wxDCOverlay oDC( m_overlay, (wxWindowDC*)aDC );
  878. oDC.Clear();
  879. m_canvas->CallMouseCapture( aDC, aEvtPos, false );
  880. #else
  881. m_canvas->CallMouseCapture( aDC, aEvtPos, true );
  882. #endif
  883. }
  884. #ifdef USE_WX_OVERLAY
  885. else
  886. {
  887. m_overlay.Reset();
  888. }
  889. #endif
  890. }
  891. }
  892. void EDA_DRAW_FRAME::GeneralControlKeyMovement( int aHotKey, wxPoint *aPos,
  893. bool aSnapToGrid )
  894. {
  895. // If requested snap the current position to the grid
  896. if( aSnapToGrid )
  897. *aPos = GetNearestGridPosition( *aPos );
  898. switch( aHotKey )
  899. {
  900. // All these keys have almost the same treatment
  901. case GR_KB_CTRL | WXK_NUMPAD8: case GR_KB_CTRL | WXK_UP:
  902. case GR_KB_CTRL | WXK_NUMPAD2: case GR_KB_CTRL | WXK_DOWN:
  903. case GR_KB_CTRL | WXK_NUMPAD4: case GR_KB_CTRL | WXK_LEFT:
  904. case GR_KB_CTRL | WXK_NUMPAD6: case GR_KB_CTRL | WXK_RIGHT:
  905. case WXK_NUMPAD8: case WXK_UP: case WXK_NUMPAD2: case WXK_DOWN:
  906. case WXK_NUMPAD4: case WXK_LEFT: case WXK_NUMPAD6: case WXK_RIGHT:
  907. {
  908. /* Here's a tricky part: when doing cursor key movement, the
  909. * 'previous' point should be taken from memory, *not* from the
  910. * freshly computed position in the event. Otherwise you can't do
  911. * sub-pixel movement. The m_movingCursorWithKeyboard oneshot 'eats'
  912. * the automatic motion event generated by cursor warping */
  913. wxRealPoint gridSize = GetScreen()->GetGridSize();
  914. *aPos = GetCrossHairPosition();
  915. // Bonus: ^key moves faster (x10)
  916. switch( aHotKey )
  917. {
  918. case GR_KB_CTRL|WXK_NUMPAD8:
  919. case GR_KB_CTRL|WXK_UP:
  920. aPos->y -= KiROUND( 10 * gridSize.y );
  921. break;
  922. case GR_KB_CTRL|WXK_NUMPAD2:
  923. case GR_KB_CTRL|WXK_DOWN:
  924. aPos->y += KiROUND( 10 * gridSize.y );
  925. break;
  926. case GR_KB_CTRL|WXK_NUMPAD4:
  927. case GR_KB_CTRL|WXK_LEFT:
  928. aPos->x -= KiROUND( 10 * gridSize.x );
  929. break;
  930. case GR_KB_CTRL|WXK_NUMPAD6:
  931. case GR_KB_CTRL|WXK_RIGHT:
  932. aPos->x += KiROUND( 10 * gridSize.x );
  933. break;
  934. case WXK_NUMPAD8:
  935. case WXK_UP:
  936. aPos->y -= KiROUND( gridSize.y );
  937. break;
  938. case WXK_NUMPAD2:
  939. case WXK_DOWN:
  940. aPos->y += KiROUND( gridSize.y );
  941. break;
  942. case WXK_NUMPAD4:
  943. case WXK_LEFT:
  944. aPos->x -= KiROUND( gridSize.x );
  945. break;
  946. case WXK_NUMPAD6:
  947. case WXK_RIGHT:
  948. aPos->x += KiROUND( gridSize.x );
  949. break;
  950. default: /* Can't happen since we entered the statement */
  951. break;
  952. }
  953. m_canvas->MoveCursor( *aPos );
  954. m_movingCursorWithKeyboard = true;
  955. }
  956. break;
  957. default:
  958. break;
  959. }
  960. }