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.

934 lines
28 KiB

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
16 years ago
16 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
++PCBNew * Removed Pcb_Frame argument from BOARD() constructor, since it precludes having a BOARD being edited by more than one editor, it was a bad design. And this meant removing m_PcbFrame from BOARD. * removed BOARD::SetWindowFrame(), and BOARD::m_PcbFrame * Removed the global BOARD_DESIGN_SETTINGS which was in class_board.cpp * added BOARD_DESIGN_SETTINGS to the BOARD class, a full instance * a couple dialogs now only change BOARD_DESIGN_SETTINGS when OK is pressed, such as dialog_mask_clearance, dialog_drc, etc. * Removed common/pcbcommon.cpp's int g_CurrentVersionPCB = 1 and replaced it with build_version.h's #define BOARD_FILE_VERSION, although there may be a better place for this constant. * Made the public functions in PARAM_CFG_ARRAY be type const. void SaveParam(..) const and void ReadParam(..) const * PARAM_CFG_BASE now has virtual destructor since we have various way of destroying the derived class and boost::ptr_vector must be told about this. * Pass const PARAM_CFG_ARRAY& instead of PARAM_CFG_ARRAY so that we can use an automatic PARAM_CFG_ARRAY which is on the stack.\ * PCB_EDIT_FRAME::GetProjectFileParameters() may no longer cache the array, since it has to access the current BOARD and the BOARD can change. Remember BOARD_DESIGN_SETTINGS are now in the BOARD. * Made the m_BoundingBox member private, this was a brutally hard task, and indicative of the lack of commitment to accessors and object oriented design on the part of KiCad developers. We must do better. Added BOARD::GetBoundingBox, SetBoundingBox(), ComputeBoundingBox(). * Added PCB_BASE_FRAME::GetBoardBoundingBox() which calls BOARD::ComputeBoundingBox()
14 years ago
14 years ago
++PCBNew * Removed Pcb_Frame argument from BOARD() constructor, since it precludes having a BOARD being edited by more than one editor, it was a bad design. And this meant removing m_PcbFrame from BOARD. * removed BOARD::SetWindowFrame(), and BOARD::m_PcbFrame * Removed the global BOARD_DESIGN_SETTINGS which was in class_board.cpp * added BOARD_DESIGN_SETTINGS to the BOARD class, a full instance * a couple dialogs now only change BOARD_DESIGN_SETTINGS when OK is pressed, such as dialog_mask_clearance, dialog_drc, etc. * Removed common/pcbcommon.cpp's int g_CurrentVersionPCB = 1 and replaced it with build_version.h's #define BOARD_FILE_VERSION, although there may be a better place for this constant. * Made the public functions in PARAM_CFG_ARRAY be type const. void SaveParam(..) const and void ReadParam(..) const * PARAM_CFG_BASE now has virtual destructor since we have various way of destroying the derived class and boost::ptr_vector must be told about this. * Pass const PARAM_CFG_ARRAY& instead of PARAM_CFG_ARRAY so that we can use an automatic PARAM_CFG_ARRAY which is on the stack.\ * PCB_EDIT_FRAME::GetProjectFileParameters() may no longer cache the array, since it has to access the current BOARD and the BOARD can change. Remember BOARD_DESIGN_SETTINGS are now in the BOARD. * Made the m_BoundingBox member private, this was a brutally hard task, and indicative of the lack of commitment to accessors and object oriented design on the part of KiCad developers. We must do better. Added BOARD::GetBoundingBox, SetBoundingBox(), ComputeBoundingBox(). * Added PCB_BASE_FRAME::GetBoardBoundingBox() which calls BOARD::ComputeBoundingBox()
14 years ago
++PCBNew * Removed Pcb_Frame argument from BOARD() constructor, since it precludes having a BOARD being edited by more than one editor, it was a bad design. And this meant removing m_PcbFrame from BOARD. * removed BOARD::SetWindowFrame(), and BOARD::m_PcbFrame * Removed the global BOARD_DESIGN_SETTINGS which was in class_board.cpp * added BOARD_DESIGN_SETTINGS to the BOARD class, a full instance * a couple dialogs now only change BOARD_DESIGN_SETTINGS when OK is pressed, such as dialog_mask_clearance, dialog_drc, etc. * Removed common/pcbcommon.cpp's int g_CurrentVersionPCB = 1 and replaced it with build_version.h's #define BOARD_FILE_VERSION, although there may be a better place for this constant. * Made the public functions in PARAM_CFG_ARRAY be type const. void SaveParam(..) const and void ReadParam(..) const * PARAM_CFG_BASE now has virtual destructor since we have various way of destroying the derived class and boost::ptr_vector must be told about this. * Pass const PARAM_CFG_ARRAY& instead of PARAM_CFG_ARRAY so that we can use an automatic PARAM_CFG_ARRAY which is on the stack.\ * PCB_EDIT_FRAME::GetProjectFileParameters() may no longer cache the array, since it has to access the current BOARD and the BOARD can change. Remember BOARD_DESIGN_SETTINGS are now in the BOARD. * Made the m_BoundingBox member private, this was a brutally hard task, and indicative of the lack of commitment to accessors and object oriented design on the part of KiCad developers. We must do better. Added BOARD::GetBoundingBox, SetBoundingBox(), ComputeBoundingBox(). * Added PCB_BASE_FRAME::GetBoardBoundingBox() which calls BOARD::ComputeBoundingBox()
14 years ago
++PCBNew * Removed Pcb_Frame argument from BOARD() constructor, since it precludes having a BOARD being edited by more than one editor, it was a bad design. And this meant removing m_PcbFrame from BOARD. * removed BOARD::SetWindowFrame(), and BOARD::m_PcbFrame * Removed the global BOARD_DESIGN_SETTINGS which was in class_board.cpp * added BOARD_DESIGN_SETTINGS to the BOARD class, a full instance * a couple dialogs now only change BOARD_DESIGN_SETTINGS when OK is pressed, such as dialog_mask_clearance, dialog_drc, etc. * Removed common/pcbcommon.cpp's int g_CurrentVersionPCB = 1 and replaced it with build_version.h's #define BOARD_FILE_VERSION, although there may be a better place for this constant. * Made the public functions in PARAM_CFG_ARRAY be type const. void SaveParam(..) const and void ReadParam(..) const * PARAM_CFG_BASE now has virtual destructor since we have various way of destroying the derived class and boost::ptr_vector must be told about this. * Pass const PARAM_CFG_ARRAY& instead of PARAM_CFG_ARRAY so that we can use an automatic PARAM_CFG_ARRAY which is on the stack.\ * PCB_EDIT_FRAME::GetProjectFileParameters() may no longer cache the array, since it has to access the current BOARD and the BOARD can change. Remember BOARD_DESIGN_SETTINGS are now in the BOARD. * Made the m_BoundingBox member private, this was a brutally hard task, and indicative of the lack of commitment to accessors and object oriented design on the part of KiCad developers. We must do better. Added BOARD::GetBoundingBox, SetBoundingBox(), ComputeBoundingBox(). * Added PCB_BASE_FRAME::GetBoardBoundingBox() which calls BOARD::ComputeBoundingBox()
14 years ago
++PCBNew * Removed Pcb_Frame argument from BOARD() constructor, since it precludes having a BOARD being edited by more than one editor, it was a bad design. And this meant removing m_PcbFrame from BOARD. * removed BOARD::SetWindowFrame(), and BOARD::m_PcbFrame * Removed the global BOARD_DESIGN_SETTINGS which was in class_board.cpp * added BOARD_DESIGN_SETTINGS to the BOARD class, a full instance * a couple dialogs now only change BOARD_DESIGN_SETTINGS when OK is pressed, such as dialog_mask_clearance, dialog_drc, etc. * Removed common/pcbcommon.cpp's int g_CurrentVersionPCB = 1 and replaced it with build_version.h's #define BOARD_FILE_VERSION, although there may be a better place for this constant. * Made the public functions in PARAM_CFG_ARRAY be type const. void SaveParam(..) const and void ReadParam(..) const * PARAM_CFG_BASE now has virtual destructor since we have various way of destroying the derived class and boost::ptr_vector must be told about this. * Pass const PARAM_CFG_ARRAY& instead of PARAM_CFG_ARRAY so that we can use an automatic PARAM_CFG_ARRAY which is on the stack.\ * PCB_EDIT_FRAME::GetProjectFileParameters() may no longer cache the array, since it has to access the current BOARD and the BOARD can change. Remember BOARD_DESIGN_SETTINGS are now in the BOARD. * Made the m_BoundingBox member private, this was a brutally hard task, and indicative of the lack of commitment to accessors and object oriented design on the part of KiCad developers. We must do better. Added BOARD::GetBoundingBox, SetBoundingBox(), ComputeBoundingBox(). * Added PCB_BASE_FRAME::GetBoardBoundingBox() which calls BOARD::ComputeBoundingBox()
14 years ago
18 years ago
18 years ago
18 years ago
18 years ago
18 years ago
14 years ago
  1. /*
  2. * This program source code file is part of KiCad, a free EDA CAD application.
  3. *
  4. * Copyright (C) 2012 Jean-Pierre Charras, jean-pierre.charras@ujf-grenoble.fr
  5. * Copyright (C) 2012 SoftPLC Corporation, Dick Hollenbeck <dick@softplc.com>
  6. * Copyright (C) 2011 Wayne Stambaugh <stambaughw@verizon.net>
  7. * Copyright (C) 1992-2011 KiCad Developers, see AUTHORS.txt for contributors.
  8. *
  9. * This program is free software; you can redistribute it and/or
  10. * modify it under the terms of the GNU General Public License
  11. * as published by the Free Software Foundation; either version 2
  12. * of the License, or (at your option) any later version.
  13. *
  14. * This program is distributed in the hope that it will be useful,
  15. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  16. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  17. * GNU General Public License for more details.
  18. *
  19. * You should have received a copy of the GNU General Public License
  20. * along with this program; if not, you may find one here:
  21. * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
  22. * or you may search the http://www.gnu.org website for the version 2 license,
  23. * or you may write to the Free Software Foundation, Inc.,
  24. * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
  25. */
  26. /**
  27. * @file basepcbframe.cpp
  28. */
  29. #include <fctsys.h>
  30. #include <wxstruct.h>
  31. #include <pcbcommon.h>
  32. #include <confirm.h>
  33. #include <appl_wxstruct.h>
  34. #include <dialog_helpers.h>
  35. #include <kicad_device_context.h>
  36. #include <wxBasePcbFrame.h>
  37. #include <base_units.h>
  38. #include <msgpanel.h>
  39. #include <pcbnew.h>
  40. #include <pcbnew_id.h>
  41. #include <class_board.h>
  42. #include <class_track.h>
  43. #include <class_module.h>
  44. #include <class_drawsegment.h>
  45. #include <collectors.h>
  46. #include <class_drawpanel.h>
  47. #include <class_drawpanel_gal.h>
  48. #include <view/view.h>
  49. #include <math/vector2d.h>
  50. #include <trigo.h>
  51. #include <pcb_painter.h>
  52. #include <worksheet_viewitem.h>
  53. #include <ratsnest_data.h>
  54. #include <ratsnest_viewitem.h>
  55. #include <tool/tool_manager.h>
  56. #include <tool/tool_dispatcher.h>
  57. // Configuration entry names.
  58. static const wxString UserGridSizeXEntry( wxT( "PcbUserGrid_X" ) );
  59. static const wxString UserGridSizeYEntry( wxT( "PcbUserGrid_Y" ) );
  60. static const wxString UserGridUnitsEntry( wxT( "PcbUserGrid_Unit" ) );
  61. static const wxString DisplayPadFillEntry( wxT( "DiPadFi" ) );
  62. static const wxString DisplayViaFillEntry( wxT( "DiViaFi" ) );
  63. static const wxString DisplayPadNumberEntry( wxT( "DiPadNu" ) );
  64. static const wxString DisplayModuleEdgeEntry( wxT( "DiModEd" ) );
  65. static const wxString DisplayModuleTextEntry( wxT( "DiModTx" ) );
  66. static const wxString FastGrid1Entry( wxT( "FastGrid1" ) );
  67. static const wxString FastGrid2Entry( wxT( "FastGrid2" ) );
  68. const LAYER_NUM PCB_BASE_FRAME::GAL_LAYER_ORDER[] =
  69. {
  70. ITEM_GAL_LAYER( GP_OVERLAY ),
  71. NETNAMES_GAL_LAYER( PADS_NETNAMES_VISIBLE ),
  72. DRAW_N, COMMENT_N, ECO1_N, ECO2_N, EDGE_N,
  73. UNUSED_LAYER_29, UNUSED_LAYER_30, UNUSED_LAYER_31,
  74. ITEM_GAL_LAYER( MOD_TEXT_FR_VISIBLE ),
  75. ITEM_GAL_LAYER( MOD_REFERENCES_VISIBLE), ITEM_GAL_LAYER( MOD_VALUES_VISIBLE ),
  76. ITEM_GAL_LAYER( RATSNEST_VISIBLE ),
  77. ITEM_GAL_LAYER( VIAS_HOLES_VISIBLE ), ITEM_GAL_LAYER( PADS_HOLES_VISIBLE ),
  78. ITEM_GAL_LAYER( VIAS_VISIBLE ), ITEM_GAL_LAYER( PADS_VISIBLE ),
  79. NETNAMES_GAL_LAYER( PAD_FR_NETNAMES_VISIBLE ), ITEM_GAL_LAYER( PAD_FR_VISIBLE ), SOLDERMASK_N_FRONT,
  80. NETNAMES_GAL_LAYER( LAYER_16_NETNAMES_VISIBLE ), LAYER_N_FRONT,
  81. SILKSCREEN_N_FRONT, SOLDERPASTE_N_FRONT, ADHESIVE_N_FRONT,
  82. NETNAMES_GAL_LAYER( LAYER_15_NETNAMES_VISIBLE ), LAYER_N_15,
  83. NETNAMES_GAL_LAYER( LAYER_14_NETNAMES_VISIBLE ), LAYER_N_14,
  84. NETNAMES_GAL_LAYER( LAYER_13_NETNAMES_VISIBLE ), LAYER_N_13,
  85. NETNAMES_GAL_LAYER( LAYER_12_NETNAMES_VISIBLE ), LAYER_N_12,
  86. NETNAMES_GAL_LAYER( LAYER_11_NETNAMES_VISIBLE ), LAYER_N_11,
  87. NETNAMES_GAL_LAYER( LAYER_10_NETNAMES_VISIBLE ), LAYER_N_10,
  88. NETNAMES_GAL_LAYER( LAYER_9_NETNAMES_VISIBLE ), LAYER_N_9,
  89. NETNAMES_GAL_LAYER( LAYER_8_NETNAMES_VISIBLE ), LAYER_N_8,
  90. NETNAMES_GAL_LAYER( LAYER_7_NETNAMES_VISIBLE ), LAYER_N_7,
  91. NETNAMES_GAL_LAYER( LAYER_6_NETNAMES_VISIBLE ), LAYER_N_6,
  92. NETNAMES_GAL_LAYER( LAYER_5_NETNAMES_VISIBLE ), LAYER_N_5,
  93. NETNAMES_GAL_LAYER( LAYER_4_NETNAMES_VISIBLE ), LAYER_N_4,
  94. NETNAMES_GAL_LAYER( LAYER_3_NETNAMES_VISIBLE ), LAYER_N_3,
  95. NETNAMES_GAL_LAYER( LAYER_2_NETNAMES_VISIBLE ), LAYER_N_2,
  96. NETNAMES_GAL_LAYER( PAD_BK_NETNAMES_VISIBLE ), ITEM_GAL_LAYER( PAD_BK_VISIBLE ), SOLDERMASK_N_BACK,
  97. NETNAMES_GAL_LAYER( LAYER_1_NETNAMES_VISIBLE ), LAYER_N_BACK,
  98. ADHESIVE_N_BACK, SOLDERPASTE_N_BACK, SILKSCREEN_N_BACK,
  99. ITEM_GAL_LAYER( MOD_TEXT_BK_VISIBLE ),
  100. ITEM_GAL_LAYER( WORKSHEET )
  101. };
  102. BEGIN_EVENT_TABLE( PCB_BASE_FRAME, EDA_DRAW_FRAME )
  103. EVT_MENU_RANGE( ID_POPUP_PCB_ITEM_SELECTION_START, ID_POPUP_PCB_ITEM_SELECTION_END,
  104. PCB_BASE_FRAME::ProcessItemSelection )
  105. EVT_TOOL( ID_TB_OPTIONS_SHOW_POLAR_COORD, PCB_BASE_FRAME::OnTogglePolarCoords )
  106. EVT_TOOL( ID_TB_OPTIONS_SHOW_PADS_SKETCH, PCB_BASE_FRAME::OnTogglePadDrawMode )
  107. EVT_UPDATE_UI( ID_TB_OPTIONS_SHOW_POLAR_COORD, PCB_BASE_FRAME::OnUpdateCoordType )
  108. EVT_UPDATE_UI( ID_TB_OPTIONS_SHOW_PADS_SKETCH, PCB_BASE_FRAME::OnUpdatePadDrawMode )
  109. EVT_UPDATE_UI( ID_ON_GRID_SELECT, PCB_BASE_FRAME::OnUpdateSelectGrid )
  110. EVT_UPDATE_UI( ID_ON_ZOOM_SELECT, PCB_BASE_FRAME::OnUpdateSelectZoom )
  111. EVT_UPDATE_UI_RANGE( ID_ZOOM_IN, ID_ZOOM_PAGE, PCB_BASE_FRAME::OnUpdateSelectZoom )
  112. END_EVENT_TABLE()
  113. PCB_BASE_FRAME::PCB_BASE_FRAME( wxWindow* aParent, ID_DRAWFRAME_TYPE aFrameType,
  114. const wxString& aTitle,
  115. const wxPoint& aPos, const wxSize& aSize,
  116. long aStyle, const wxString & aFrameName) :
  117. EDA_DRAW_FRAME( aParent, aFrameType, aTitle, aPos, aSize, aStyle, aFrameName )
  118. {
  119. m_Pcb = NULL;
  120. m_toolManager = NULL;
  121. m_toolDispatcher = NULL;
  122. m_DisplayPadFill = true; // How to draw pads
  123. m_DisplayViaFill = true; // How to draw vias
  124. m_DisplayPadNum = true; // show pads number
  125. m_DisplayModEdge = FILLED; // How to display module drawings (line/ filled / sketch)
  126. m_DisplayModText = FILLED; // How to display module texts (line/ filled / sketch)
  127. m_DisplayPcbTrackFill = true; // false = sketch , true = filled
  128. m_Draw3DFrame = NULL; // Display Window in 3D mode (OpenGL)
  129. m_UserGridSize = wxRealPoint( 100.0, 100.0 );
  130. m_UserGridUnit = INCHES;
  131. m_Collector = new GENERAL_COLLECTOR();
  132. m_FastGrid1 = 0;
  133. m_FastGrid2 = 0;
  134. SetGalCanvas( new EDA_DRAW_PANEL_GAL(
  135. this, -1, wxPoint( 0, 0 ), m_FrameSize,
  136. EDA_DRAW_PANEL_GAL::GAL_TYPE_OPENGL ) );
  137. // Hide by default, it has to be explicitly shown
  138. GetGalCanvas()->Hide();
  139. m_auxiliaryToolBar = NULL;
  140. }
  141. PCB_BASE_FRAME::~PCB_BASE_FRAME()
  142. {
  143. delete m_Collector;
  144. delete m_Pcb; // is already NULL for FOOTPRINT_EDIT_FRAME
  145. delete GetGalCanvas();
  146. }
  147. void PCB_BASE_FRAME::SetBoard( BOARD* aBoard )
  148. {
  149. delete m_Pcb;
  150. m_Pcb = aBoard;
  151. }
  152. void PCB_BASE_FRAME::SetPageSettings( const PAGE_INFO& aPageSettings )
  153. {
  154. wxASSERT( m_Pcb );
  155. m_Pcb->SetPageSettings( aPageSettings );
  156. if( GetScreen() )
  157. GetScreen()->InitDataPoints( aPageSettings.GetSizeIU() );
  158. }
  159. const PAGE_INFO& PCB_BASE_FRAME::GetPageSettings() const
  160. {
  161. wxASSERT( m_Pcb );
  162. return m_Pcb->GetPageSettings();
  163. }
  164. const wxSize PCB_BASE_FRAME::GetPageSizeIU() const
  165. {
  166. wxASSERT( m_Pcb );
  167. // this function is only needed because EDA_DRAW_FRAME is not compiled
  168. // with either -DPCBNEW or -DEESCHEMA, so the virtual is used to route
  169. // into an application specific source file.
  170. return m_Pcb->GetPageSettings().GetSizeIU();
  171. }
  172. const wxPoint& PCB_BASE_FRAME::GetAuxOrigin() const
  173. {
  174. wxASSERT( m_Pcb );
  175. return m_Pcb->GetAuxOrigin();
  176. }
  177. void PCB_BASE_FRAME::SetAuxOrigin( const wxPoint& aPoint )
  178. {
  179. wxASSERT( m_Pcb );
  180. m_Pcb->SetAuxOrigin( aPoint );
  181. }
  182. const wxPoint& PCB_BASE_FRAME::GetGridOrigin() const
  183. {
  184. wxASSERT( m_Pcb );
  185. return m_Pcb->GetGridOrigin();
  186. }
  187. void PCB_BASE_FRAME::SetGridOrigin( const wxPoint& aPoint )
  188. {
  189. wxASSERT( m_Pcb );
  190. m_Pcb->SetGridOrigin( aPoint );
  191. }
  192. const TITLE_BLOCK& PCB_BASE_FRAME::GetTitleBlock() const
  193. {
  194. wxASSERT( m_Pcb );
  195. return m_Pcb->GetTitleBlock();
  196. }
  197. void PCB_BASE_FRAME::SetTitleBlock( const TITLE_BLOCK& aTitleBlock )
  198. {
  199. wxASSERT( m_Pcb );
  200. m_Pcb->SetTitleBlock( aTitleBlock );
  201. }
  202. BOARD_DESIGN_SETTINGS& PCB_BASE_FRAME::GetDesignSettings() const
  203. {
  204. wxASSERT( m_Pcb );
  205. return m_Pcb->GetDesignSettings();
  206. }
  207. void PCB_BASE_FRAME::SetDesignSettings( const BOARD_DESIGN_SETTINGS& aSettings )
  208. {
  209. wxASSERT( m_Pcb );
  210. m_Pcb->SetDesignSettings( aSettings );
  211. }
  212. const ZONE_SETTINGS& PCB_BASE_FRAME::GetZoneSettings() const
  213. {
  214. wxASSERT( m_Pcb );
  215. return m_Pcb->GetZoneSettings();
  216. }
  217. void PCB_BASE_FRAME::SetZoneSettings( const ZONE_SETTINGS& aSettings )
  218. {
  219. wxASSERT( m_Pcb );
  220. m_Pcb->SetZoneSettings( aSettings );
  221. }
  222. const PCB_PLOT_PARAMS& PCB_BASE_FRAME::GetPlotSettings() const
  223. {
  224. wxASSERT( m_Pcb );
  225. return m_Pcb->GetPlotOptions();
  226. }
  227. void PCB_BASE_FRAME::SetPlotSettings( const PCB_PLOT_PARAMS& aSettings )
  228. {
  229. wxASSERT( m_Pcb );
  230. m_Pcb->SetPlotOptions( aSettings );
  231. }
  232. EDA_RECT PCB_BASE_FRAME::GetBoardBoundingBox( bool aBoardEdgesOnly ) const
  233. {
  234. wxASSERT( m_Pcb );
  235. EDA_RECT area = m_Pcb->ComputeBoundingBox( aBoardEdgesOnly );
  236. if( area.GetWidth() == 0 && area.GetHeight() == 0 )
  237. {
  238. wxSize pageSize = GetPageSizeIU();
  239. if( m_showBorderAndTitleBlock )
  240. {
  241. area.SetOrigin( 0, 0 );
  242. area.SetEnd( pageSize.x, pageSize.y );
  243. }
  244. else
  245. {
  246. area.SetOrigin( -pageSize.x / 2, -pageSize.y / 2 );
  247. area.SetEnd( pageSize.x / 2, pageSize.y / 2 );
  248. }
  249. }
  250. return area;
  251. }
  252. double PCB_BASE_FRAME::BestZoom()
  253. {
  254. if( m_Pcb == NULL )
  255. return 1.0;
  256. EDA_RECT ibbbox = GetBoardBoundingBox();
  257. DSIZE clientz = m_canvas->GetClientSize();
  258. DSIZE boardz( ibbbox.GetWidth(), ibbbox.GetHeight() );
  259. double iu_per_du_X = clientz.x ? boardz.x / clientz.x : 1.0;
  260. double iu_per_du_Y = clientz.y ? boardz.y / clientz.y : 1.0;
  261. double bestzoom = std::max( iu_per_du_X, iu_per_du_Y );
  262. SetScrollCenterPosition( ibbbox.Centre() );
  263. return bestzoom;
  264. }
  265. void PCB_BASE_FRAME::CursorGoto( const wxPoint& aPos, bool aWarp )
  266. {
  267. // factored out of pcbnew/find.cpp
  268. INSTALL_UNBUFFERED_DC( dc, m_canvas );
  269. // There may be need to reframe the drawing.
  270. if( !m_canvas->IsPointOnDisplay( aPos ) )
  271. {
  272. SetCrossHairPosition( aPos );
  273. RedrawScreen( aPos, aWarp );
  274. }
  275. else
  276. {
  277. // Put cursor on item position
  278. m_canvas->CrossHairOff( &dc );
  279. SetCrossHairPosition( aPos );
  280. if( aWarp )
  281. m_canvas->MoveCursorToCrossHair();
  282. }
  283. m_canvas->CrossHairOn( &dc );
  284. m_canvas->CrossHairOn( &dc );
  285. }
  286. // Virtual function
  287. void PCB_BASE_FRAME::ReCreateMenuBar( void )
  288. {
  289. }
  290. // Virtual functions: Do nothing for PCB_BASE_FRAME window
  291. void PCB_BASE_FRAME::Show3D_Frame( wxCommandEvent& event )
  292. {
  293. }
  294. // Note: virtual, overridden in PCB_EDIT_FRAME;
  295. void PCB_BASE_FRAME::SwitchLayer( wxDC* DC, LAYER_NUM layer )
  296. {
  297. LAYER_NUM preslayer = ((PCB_SCREEN*)GetScreen())->m_Active_Layer;
  298. // Check if the specified layer matches the present layer
  299. if( layer == preslayer )
  300. return;
  301. // Copper layers cannot be selected unconditionally; how many
  302. // of those layers are currently enabled needs to be checked.
  303. if( IsCopperLayer( layer ) )
  304. {
  305. // If only one copper layer is enabled, the only such layer
  306. // that can be selected to is the "Copper" layer (so the
  307. // selection of any other copper layer is disregarded).
  308. if( m_Pcb->GetCopperLayerCount() < 2 )
  309. {
  310. if( layer != LAYER_N_BACK )
  311. {
  312. return;
  313. }
  314. }
  315. // If more than one copper layer is enabled, the "Copper"
  316. // and "Component" layers can be selected, but the total
  317. // number of copper layers determines which internal
  318. // layers are also capable of being selected.
  319. else
  320. {
  321. if( ( layer != LAYER_N_BACK ) && ( layer != LAYER_N_FRONT )
  322. && ( layer >= m_Pcb->GetCopperLayerCount() - 1 ) )
  323. {
  324. return;
  325. }
  326. }
  327. }
  328. // Is yet more checking required? E.g. when the layer to be selected
  329. // is a non-copper layer, or when switching between a copper layer
  330. // and a non-copper layer, or vice-versa?
  331. // ...
  332. GetScreen()->m_Active_Layer = layer;
  333. if( DisplayOpt.ContrastModeDisplay )
  334. m_canvas->Refresh();
  335. }
  336. void PCB_BASE_FRAME::OnTogglePolarCoords( wxCommandEvent& aEvent )
  337. {
  338. SetStatusText( wxEmptyString );
  339. DisplayOpt.DisplayPolarCood = !DisplayOpt.DisplayPolarCood;
  340. UpdateStatusBar();
  341. }
  342. void PCB_BASE_FRAME::OnTogglePadDrawMode( wxCommandEvent& aEvent )
  343. {
  344. m_DisplayPadFill = DisplayOpt.DisplayPadFill = !m_DisplayPadFill;
  345. // Apply new display options to the GAL canvas
  346. KIGFX::PCB_PAINTER* painter =
  347. static_cast<KIGFX::PCB_PAINTER*> ( GetGalCanvas()->GetView()->GetPainter() );
  348. KIGFX::PCB_RENDER_SETTINGS* settings =
  349. static_cast<KIGFX::PCB_RENDER_SETTINGS*> ( painter->GetSettings() );
  350. settings->LoadDisplayOptions( DisplayOpt );
  351. GetGalCanvas()->GetView()->RecacheAllItems( true );
  352. m_canvas->Refresh();
  353. }
  354. void PCB_BASE_FRAME::OnUpdateCoordType( wxUpdateUIEvent& aEvent )
  355. {
  356. aEvent.Check( DisplayOpt.DisplayPolarCood );
  357. m_optionsToolBar->SetToolShortHelp( ID_TB_OPTIONS_SHOW_POLAR_COORD,
  358. DisplayOpt.DisplayPolarCood ?
  359. _( "Display rectangular coordinates" ) :
  360. _( "Display polar coordinates" ) );
  361. }
  362. void PCB_BASE_FRAME::OnUpdatePadDrawMode( wxUpdateUIEvent& aEvent )
  363. {
  364. aEvent.Check( !m_DisplayPadFill );
  365. m_optionsToolBar->SetToolShortHelp( ID_TB_OPTIONS_SHOW_PADS_SKETCH,
  366. m_DisplayPadFill ?
  367. _( "Show pads in outline mode" ) :
  368. _( "Show pads in fill mode" ) );
  369. }
  370. void PCB_BASE_FRAME::OnUpdateSelectGrid( wxUpdateUIEvent& aEvent )
  371. {
  372. // No need to update the grid select box if it doesn't exist or the grid setting change
  373. // was made using the select box.
  374. if( m_gridSelectBox == NULL || m_auxiliaryToolBar == NULL )
  375. return;
  376. int select = wxNOT_FOUND;
  377. for( size_t i = 0; i < GetScreen()->GetGridCount(); i++ )
  378. {
  379. if( GetScreen()->GetGridId() == GetScreen()->GetGrid( i ).m_Id )
  380. {
  381. select = (int) i;
  382. break;
  383. }
  384. }
  385. if( select != m_gridSelectBox->GetSelection() )
  386. m_gridSelectBox->SetSelection( select );
  387. }
  388. void PCB_BASE_FRAME::OnUpdateSelectZoom( wxUpdateUIEvent& aEvent )
  389. {
  390. if( m_zoomSelectBox == NULL || m_auxiliaryToolBar == NULL )
  391. return;
  392. int current = 0;
  393. for( unsigned i = 0; i < GetScreen()->m_ZoomList.size(); i++ )
  394. {
  395. if( GetScreen()->GetZoom() == GetScreen()->m_ZoomList[i] )
  396. {
  397. current = i + 1;
  398. break;
  399. }
  400. }
  401. if( current != m_zoomSelectBox->GetSelection() )
  402. m_zoomSelectBox->SetSelection( current );
  403. }
  404. void PCB_BASE_FRAME::ProcessItemSelection( wxCommandEvent& aEvent )
  405. {
  406. int id = aEvent.GetId();
  407. // index into the collector list:
  408. int itemNdx = id - ID_POPUP_PCB_ITEM_SELECTION_START;
  409. if( id >= ID_POPUP_PCB_ITEM_SELECTION_START && id <= ID_POPUP_PCB_ITEM_SELECTION_END )
  410. {
  411. BOARD_ITEM* item = (*m_Collector)[itemNdx];
  412. m_canvas->SetAbortRequest( false );
  413. #if 0 && defined (DEBUG)
  414. item->Show( 0, std::cout );
  415. #endif
  416. SetCurItem( item );
  417. }
  418. }
  419. void PCB_BASE_FRAME::SetCurItem( BOARD_ITEM* aItem, bool aDisplayInfo )
  420. {
  421. GetScreen()->SetCurItem( aItem );
  422. if( aItem )
  423. {
  424. if( aDisplayInfo )
  425. {
  426. MSG_PANEL_ITEMS items;
  427. aItem->GetMsgPanelInfo( items );
  428. SetMsgPanel( items );
  429. }
  430. #if 0 && defined(DEBUG)
  431. aItem->Show( 0, std::cout );
  432. #endif
  433. }
  434. else
  435. {
  436. // we can use either of these two:
  437. MSG_PANEL_ITEMS items;
  438. m_Pcb->GetMsgPanelInfo( items ); // show the BOARD stuff
  439. SetMsgPanel( items );
  440. #if 0 && defined(DEBUG)
  441. std::cout << "SetCurItem(NULL)\n";
  442. #endif
  443. }
  444. }
  445. BOARD_ITEM* PCB_BASE_FRAME::GetCurItem()
  446. {
  447. return GetScreen()->GetCurItem();
  448. }
  449. GENERAL_COLLECTORS_GUIDE PCB_BASE_FRAME::GetCollectorsGuide()
  450. {
  451. GENERAL_COLLECTORS_GUIDE guide( m_Pcb->GetVisibleLayers(),
  452. ( (PCB_SCREEN*)GetScreen())->m_Active_Layer );
  453. // account for the globals
  454. guide.SetIgnoreMTextsMarkedNoShow( ! m_Pcb->IsElementVisible( MOD_TEXT_INVISIBLE ));
  455. guide.SetIgnoreMTextsOnCopper( ! m_Pcb->IsElementVisible( MOD_TEXT_BK_VISIBLE ));
  456. guide.SetIgnoreMTextsOnCmp( ! m_Pcb->IsElementVisible( MOD_TEXT_FR_VISIBLE ));
  457. guide.SetIgnoreModulesOnCu( ! m_Pcb->IsElementVisible( MOD_BK_VISIBLE ) );
  458. guide.SetIgnoreModulesOnCmp( ! m_Pcb->IsElementVisible( MOD_FR_VISIBLE ) );
  459. guide.SetIgnorePadsOnBack( ! m_Pcb->IsElementVisible( PAD_BK_VISIBLE ) );
  460. guide.SetIgnorePadsOnFront( ! m_Pcb->IsElementVisible( PAD_FR_VISIBLE ) );
  461. guide.SetIgnoreModulesVals( ! m_Pcb->IsElementVisible( MOD_VALUES_VISIBLE ) );
  462. guide.SetIgnoreModulesRefs( ! m_Pcb->IsElementVisible( MOD_REFERENCES_VISIBLE ) );
  463. return guide;
  464. }
  465. void PCB_BASE_FRAME::SetToolID( int aId, int aCursor, const wxString& aToolMsg )
  466. {
  467. bool redraw = false;
  468. EDA_DRAW_FRAME::SetToolID( aId, aCursor, aToolMsg );
  469. if( aId < 0 )
  470. return;
  471. // handle color changes for transitions in and out of ID_TRACK_BUTT
  472. if( ( GetToolId() == ID_TRACK_BUTT && aId != ID_TRACK_BUTT )
  473. || ( GetToolId() != ID_TRACK_BUTT && aId== ID_TRACK_BUTT ) )
  474. {
  475. if( DisplayOpt.ContrastModeDisplay )
  476. redraw = true;
  477. }
  478. // must do this after the tool has been set, otherwise pad::Draw() does
  479. // not show proper color when DisplayOpt.ContrastModeDisplay is true.
  480. if( redraw && m_canvas)
  481. m_canvas->Refresh();
  482. }
  483. /*
  484. * Update the status bar information.
  485. */
  486. void PCB_BASE_FRAME::UpdateStatusBar()
  487. {
  488. EDA_DRAW_FRAME::UpdateStatusBar();
  489. PCB_SCREEN* screen = GetScreen();
  490. if( !screen )
  491. return;
  492. int dx;
  493. int dy;
  494. double dXpos;
  495. double dYpos;
  496. wxString line;
  497. wxString locformatter;
  498. if( DisplayOpt.DisplayPolarCood ) // display polar coordinates
  499. {
  500. double theta, ro;
  501. dx = GetCrossHairPosition().x - screen->m_O_Curseur.x;
  502. dy = GetCrossHairPosition().y - screen->m_O_Curseur.y;
  503. theta = ArcTangente( -dy, dx ) / 10;
  504. ro = hypot( dx, dy );
  505. wxString formatter;
  506. switch( g_UserUnit )
  507. {
  508. #if defined( USE_PCBNEW_NANOMETRE )
  509. case INCHES:
  510. formatter = wxT( "Ro %.6f Th %.1f" );
  511. break;
  512. case MILLIMETRES:
  513. formatter = wxT( "Ro %.6f Th %.1f" );
  514. break;
  515. #else
  516. case INCHES:
  517. formatter = wxT( "Ro %.4f Th %.1f" );
  518. break;
  519. case MILLIMETRES:
  520. formatter = wxT( "Ro %.3f Th %.1f" );
  521. break;
  522. #endif
  523. case UNSCALED_UNITS:
  524. formatter = wxT( "Ro %f Th %f" );
  525. break;
  526. }
  527. line.Printf( formatter, To_User_Unit( g_UserUnit, ro ), theta );
  528. SetStatusText( line, 3 );
  529. }
  530. // Display absolute coordinates:
  531. dXpos = To_User_Unit( g_UserUnit, GetCrossHairPosition().x );
  532. dYpos = To_User_Unit( g_UserUnit, GetCrossHairPosition().y );
  533. // The following sadly is an if Eeschema/if Pcbnew
  534. wxString absformatter;
  535. switch( g_UserUnit )
  536. {
  537. case INCHES:
  538. absformatter = wxT( "X %.6f Y %.6f" );
  539. locformatter = wxT( "dx %.6f dy %.6f d %.6f" );
  540. break;
  541. case MILLIMETRES:
  542. absformatter = wxT( "X %.6f Y %.6f" );
  543. locformatter = wxT( "dx %.6f dy %.6f d %.6f" );
  544. break;
  545. case UNSCALED_UNITS:
  546. absformatter = wxT( "X %f Y %f" );
  547. locformatter = wxT( "dx %f dy %f d %f" );
  548. break;
  549. }
  550. line.Printf( absformatter, dXpos, dYpos );
  551. SetStatusText( line, 2 );
  552. if( !DisplayOpt.DisplayPolarCood ) // display relative cartesian coordinates
  553. {
  554. // Display relative coordinates:
  555. dx = GetCrossHairPosition().x - screen->m_O_Curseur.x;
  556. dy = GetCrossHairPosition().y - screen->m_O_Curseur.y;
  557. dXpos = To_User_Unit( g_UserUnit, dx );
  558. dYpos = To_User_Unit( g_UserUnit, dy );
  559. // We already decided the formatter above
  560. line.Printf( locformatter, dXpos, dYpos, hypot( dXpos, dYpos ) );
  561. SetStatusText( line, 3 );
  562. }
  563. }
  564. void PCB_BASE_FRAME::unitsChangeRefresh()
  565. {
  566. EDA_DRAW_FRAME::unitsChangeRefresh(); // Update the status bar.
  567. updateGridSelectBox();
  568. }
  569. void PCB_BASE_FRAME::LoadSettings()
  570. {
  571. wxASSERT( wxGetApp().GetSettings() != NULL );
  572. wxConfig* cfg = wxGetApp().GetSettings();
  573. EDA_DRAW_FRAME::LoadSettings();
  574. // Ensure grid id is an existent grid id:
  575. if( (m_LastGridSizeId <= 0) ||
  576. (m_LastGridSizeId > (ID_POPUP_GRID_USER - ID_POPUP_GRID_LEVEL_1000)) )
  577. m_LastGridSizeId = ID_POPUP_GRID_LEVEL_500 - ID_POPUP_GRID_LEVEL_1000;
  578. cfg->Read( m_FrameName + UserGridSizeXEntry, &m_UserGridSize.x, 0.01 );
  579. cfg->Read( m_FrameName + UserGridSizeYEntry, &m_UserGridSize.y, 0.01 );
  580. long itmp;
  581. cfg->Read( m_FrameName + UserGridUnitsEntry, &itmp, ( long )INCHES );
  582. m_UserGridUnit = (EDA_UNITS_T) itmp;
  583. cfg->Read( m_FrameName + DisplayPadFillEntry, &m_DisplayPadFill, true );
  584. cfg->Read( m_FrameName + DisplayViaFillEntry, &m_DisplayViaFill, true );
  585. cfg->Read( m_FrameName + DisplayPadNumberEntry, &m_DisplayPadNum, true );
  586. cfg->Read( m_FrameName + DisplayModuleEdgeEntry, &m_DisplayModEdge, ( long )FILLED );
  587. cfg->Read( m_FrameName + FastGrid1Entry, &itmp, ( long )0);
  588. m_FastGrid1 = itmp;
  589. cfg->Read( m_FrameName + FastGrid2Entry, &itmp, ( long )0);
  590. m_FastGrid2 = itmp;
  591. if( m_DisplayModEdge < LINE || m_DisplayModEdge > SKETCH )
  592. m_DisplayModEdge = FILLED;
  593. cfg->Read( m_FrameName + DisplayModuleTextEntry, &m_DisplayModText, ( long )FILLED );
  594. if( m_DisplayModText < LINE || m_DisplayModText > SKETCH )
  595. m_DisplayModText = FILLED;
  596. // Apply display settings for GAL
  597. KIGFX::VIEW* view = GetGalCanvas()->GetView();
  598. // Set rendering order and properties of layers
  599. for( LAYER_NUM i = 0; (unsigned) i < sizeof(GAL_LAYER_ORDER) / sizeof(LAYER_NUM); ++i )
  600. {
  601. LAYER_NUM layer = GAL_LAYER_ORDER[i];
  602. wxASSERT( layer < KIGFX::VIEW::VIEW_MAX_LAYERS );
  603. view->SetLayerOrder( layer, i );
  604. if( IsCopperLayer( layer ) )
  605. {
  606. // Copper layers are required for netname layers
  607. view->SetRequired( GetNetnameLayer( layer ), layer );
  608. view->SetLayerTarget( layer, KIGFX::TARGET_CACHED );
  609. }
  610. else if( IsNetnameLayer( layer ) )
  611. {
  612. // Netnames are drawn only when scale is sufficient (level of details)
  613. // so there is no point in caching them
  614. view->SetLayerTarget( layer, KIGFX::TARGET_NONCACHED );
  615. }
  616. }
  617. // Some more required layers settings
  618. view->SetRequired( ITEM_GAL_LAYER( VIAS_HOLES_VISIBLE ), ITEM_GAL_LAYER( VIAS_VISIBLE ) );
  619. view->SetRequired( ITEM_GAL_LAYER( PADS_HOLES_VISIBLE ), ITEM_GAL_LAYER( PADS_VISIBLE ) );
  620. view->SetRequired( NETNAMES_GAL_LAYER( PADS_NETNAMES_VISIBLE ), ITEM_GAL_LAYER( PADS_VISIBLE ) );
  621. view->SetRequired( NETNAMES_GAL_LAYER( PAD_FR_NETNAMES_VISIBLE ), ITEM_GAL_LAYER( PAD_FR_VISIBLE ) );
  622. view->SetRequired( ADHESIVE_N_FRONT, ITEM_GAL_LAYER( PAD_FR_VISIBLE ) );
  623. view->SetRequired( SOLDERPASTE_N_FRONT, ITEM_GAL_LAYER( PAD_FR_VISIBLE ) );
  624. view->SetRequired( SOLDERMASK_N_FRONT, ITEM_GAL_LAYER( PAD_FR_VISIBLE ) );
  625. view->SetRequired( NETNAMES_GAL_LAYER( PAD_BK_NETNAMES_VISIBLE ), ITEM_GAL_LAYER( PAD_BK_VISIBLE ) );
  626. view->SetRequired( ADHESIVE_N_BACK, ITEM_GAL_LAYER( PAD_BK_VISIBLE ) );
  627. view->SetRequired( SOLDERPASTE_N_BACK, ITEM_GAL_LAYER( PAD_BK_VISIBLE ) );
  628. view->SetRequired( SOLDERMASK_N_BACK, ITEM_GAL_LAYER( PAD_BK_VISIBLE ) );
  629. view->SetLayerTarget( ITEM_GAL_LAYER( GP_OVERLAY ), KIGFX::TARGET_OVERLAY );
  630. view->SetLayerTarget( ITEM_GAL_LAYER( RATSNEST_VISIBLE ), KIGFX::TARGET_OVERLAY );
  631. // Apply layer coloring scheme & display options
  632. if( view->GetPainter() )
  633. {
  634. KIGFX::PCB_RENDER_SETTINGS* settings = new KIGFX::PCB_RENDER_SETTINGS();
  635. // Load layers' colors from PCB data
  636. settings->ImportLegacyColors( m_Pcb->GetColorsSettings() );
  637. view->GetPainter()->ApplySettings( settings );
  638. // Load display options (such as filled/outline display of items)
  639. settings->LoadDisplayOptions( DisplayOpt );
  640. }
  641. // WxWidgets 2.9.1 seems call setlocale( LC_NUMERIC, "" )
  642. // when reading doubles in config,
  643. // but forget to back to current locale. So we call SetLocaleTo_Default
  644. SetLocaleTo_Default( );
  645. }
  646. void PCB_BASE_FRAME::SaveSettings()
  647. {
  648. wxASSERT( wxGetApp().GetSettings() != NULL );
  649. wxConfig* cfg = wxGetApp().GetSettings();
  650. EDA_DRAW_FRAME::SaveSettings();
  651. cfg->Write( m_FrameName + UserGridSizeXEntry, m_UserGridSize.x );
  652. cfg->Write( m_FrameName + UserGridSizeYEntry, m_UserGridSize.y );
  653. cfg->Write( m_FrameName + UserGridUnitsEntry, ( long )m_UserGridUnit );
  654. cfg->Write( m_FrameName + DisplayPadFillEntry, m_DisplayPadFill );
  655. cfg->Write( m_FrameName + DisplayViaFillEntry, m_DisplayViaFill );
  656. cfg->Write( m_FrameName + DisplayPadNumberEntry, m_DisplayPadNum );
  657. cfg->Write( m_FrameName + DisplayModuleEdgeEntry, ( long )m_DisplayModEdge );
  658. cfg->Write( m_FrameName + DisplayModuleTextEntry, ( long )m_DisplayModText );
  659. cfg->Write( m_FrameName + FastGrid1Entry, ( long )m_FastGrid1 );
  660. cfg->Write( m_FrameName + FastGrid2Entry, ( long )m_FastGrid2 );
  661. }
  662. void PCB_BASE_FRAME::OnModify()
  663. {
  664. GetScreen()->SetModify();
  665. GetScreen()->SetSave();
  666. }
  667. void PCB_BASE_FRAME::updateGridSelectBox()
  668. {
  669. UpdateStatusBar();
  670. DisplayUnitsMsg();
  671. if( m_gridSelectBox == NULL )
  672. return;
  673. // Update grid values with the current units setting.
  674. m_gridSelectBox->Clear();
  675. wxString msg;
  676. wxString format = _( "Grid:");
  677. switch( g_UserUnit )
  678. {
  679. case INCHES: // the grid size is displayed in mils
  680. case MILLIMETRES:
  681. format += wxT( " %.6f" );
  682. break;
  683. case UNSCALED_UNITS:
  684. format += wxT( " %f" );
  685. break;
  686. }
  687. for( size_t i = 0; i < GetScreen()->GetGridCount(); i++ )
  688. {
  689. GRID_TYPE& grid = GetScreen()->GetGrid( i );
  690. double value = To_User_Unit( g_UserUnit, grid.m_Size.x );
  691. if( g_UserUnit == INCHES )
  692. value *= 1000;
  693. if( grid.m_Id != ID_POPUP_GRID_USER )
  694. {
  695. msg.Printf( format.GetData(), value );
  696. StripTrailingZeros( msg );
  697. }
  698. else
  699. msg = _( "User Grid" );
  700. m_gridSelectBox->Append( msg, (void*) &grid.m_Id );
  701. if( ( m_LastGridSizeId + ID_POPUP_GRID_LEVEL_1000 ) == GetScreen()->GetGrid( i ).m_Id )
  702. m_gridSelectBox->SetSelection( i );
  703. }
  704. }
  705. void PCB_BASE_FRAME::updateZoomSelectBox()
  706. {
  707. if( m_zoomSelectBox == NULL )
  708. return;
  709. wxString msg;
  710. m_zoomSelectBox->Clear();
  711. m_zoomSelectBox->Append( _( "Auto" ) );
  712. m_zoomSelectBox->SetSelection( 0 );
  713. for( unsigned i = 0; i < GetScreen()->m_ZoomList.size(); ++i )
  714. {
  715. msg = _( "Zoom " );
  716. wxString value = wxString::Format( wxT( "%g" ),
  717. // @todo could do scaling here and show a "percentage"
  718. GetScreen()->m_ZoomList[i]
  719. );
  720. msg += value;
  721. m_zoomSelectBox->Append( msg );
  722. if( GetScreen()->GetZoom() == GetScreen()->m_ZoomList[i] )
  723. m_zoomSelectBox->SetSelection( i + 1 );
  724. }
  725. }