From 1ddde7426f8eb3ac54893d80b9bd36fe5e1306bc Mon Sep 17 00:00:00 2001 From: John Beard Date: Thu, 8 Jan 2015 09:02:27 -0500 Subject: [PATCH 1/4] Fix case statement indentation setting for uncrustify. --- uncrustify.cfg | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/uncrustify.cfg b/uncrustify.cfg index 3d52d457fd..8d5d47b971 100644 --- a/uncrustify.cfg +++ b/uncrustify.cfg @@ -169,7 +169,7 @@ indent_case_shift = 0 # number # Spaces to indent '{' from 'case'. # By default, the brace will appear under the 'c' in case. # Usually set to 0 or indent_columns. -indent_case_brace = 4 # number +indent_case_brace = 0 # number # Whether to indent comments found in first column indent_col1_comment = false # false/true From 6cf3b937fc3a8d9ce5620cab958b953d2805cf04 Mon Sep 17 00:00:00 2001 From: jean-pierre charras Date: Sat, 10 Jan 2015 10:28:09 +0100 Subject: [PATCH 2/4] Fix Eeschema drag Bug #1408661 --- eeschema/hotkeys.cpp | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/eeschema/hotkeys.cpp b/eeschema/hotkeys.cpp index 58458b954d..809a34ab82 100644 --- a/eeschema/hotkeys.cpp +++ b/eeschema/hotkeys.cpp @@ -31,6 +31,7 @@ #include #include #include +#include #include #include @@ -348,8 +349,6 @@ bool SCH_EDIT_FRAME::OnHotKey( wxDC* aDC, int aHotKey, const wxPoint& aPosition, wxCommandEvent cmd( wxEVT_COMMAND_MENU_SELECTED ); - cmd.SetEventObject( this ); - SCH_SCREEN* screen = GetScreen(); // itemInEdit == false means no item currently edited. We can ask for editing a new item @@ -393,12 +392,19 @@ bool SCH_EDIT_FRAME::OnHotKey( wxDC* aDC, int aHotKey, const wxPoint& aPosition, break; case HK_LEFT_CLICK: - OnLeftClick( aDC, aPosition ); - break; - case HK_LEFT_DCLICK: // Simulate a double left click: generate 2 events - OnLeftClick( aDC, aPosition ); - OnLeftDClick( aDC, aPosition ); + if( screen->m_BlockLocate.GetState() == STATE_BLOCK_MOVE ) + { + GetCanvas()->SetAutoPanRequest( false ); + HandleBlockPlace( aDC ); + } + else if( screen->m_BlockLocate.GetState() == STATE_NO_BLOCK ) + { + OnLeftClick( aDC, aPosition ); + + if( hotKey->m_Idcommand == HK_LEFT_DCLICK ) + OnLeftDClick( aDC, aPosition ); + } break; case HK_ZOOM_IN: From 9cfb97d8b41f2388226ba9a2c2f54eb47e504c0b Mon Sep 17 00:00:00 2001 From: jean-pierre charras Date: Sat, 10 Jan 2015 11:27:49 +0100 Subject: [PATCH 3/4] Add hight contrast option in Modedit. In hight contrast mode, solder masks and solder paste are shown. this option was possible only by modifying the way display options are managed. before these changes, display options were a global DISPLAY_OPTIONS class instance. Now each EDA_DRAW_FRAME(and derivated classes) includes its own DISPLAY_OPTIONS class instance. As a consequence, some duplicate display option variables in these classes have been removed, because there were just duplicate variables of the DISPLAY_OPTIONS class instance. --- common/draw_panel.cpp | 6 ++ cvpcb/class_DisplayFootprintsFrame.cpp | 47 +++++------ cvpcb/dialogs/dialog_display_options.cpp | 20 +++-- include/class_drawpanel.h | 7 ++ include/draw_frame.h | 8 ++ include/pcbstruct.h | 29 +++---- include/wxBasePcbFrame.h | 19 +++-- pcbnew/autorouter/auto_place_footprints.cpp | 7 +- pcbnew/basepcbframe.cpp | 72 +++++++++-------- pcbnew/block.cpp | 7 +- pcbnew/class_dimension.cpp | 3 +- pcbnew/class_drawsegment.cpp | 6 +- pcbnew/class_edge_mod.cpp | 9 +-- pcbnew/class_mire.cpp | 3 +- pcbnew/class_pad_draw_functions.cpp | 20 ++--- pcbnew/class_pcb_layer_widget.cpp | 3 +- pcbnew/class_pcb_text.cpp | 3 +- pcbnew/class_text_mod.cpp | 6 +- pcbnew/class_track.cpp | 48 ++++++----- pcbnew/class_zone.cpp | 17 ++-- pcbnew/classpcb.cpp | 40 ++++----- pcbnew/controle.cpp | 5 +- pcbnew/dialogs/dialog_display_options.cpp | 71 +++++++--------- pcbnew/dialogs/dialog_general_options.cpp | 29 ++++--- pcbnew/dialogs/dialog_pad_properties_base.cpp | 3 +- pcbnew/dialogs/dialog_pad_properties_base.fbp | 2 +- pcbnew/dialogs/dialog_pad_properties_base.h | 2 +- pcbnew/edit.cpp | 15 ++-- pcbnew/editedge.cpp | 14 ++-- pcbnew/editrack.cpp | 13 +-- pcbnew/files.cpp | 7 -- pcbnew/hotkeys_board_editor.cpp | 8 +- pcbnew/modeditoptions.cpp | 24 +++--- pcbnew/moduleframe.cpp | 8 ++ pcbnew/modules.cpp | 13 +-- pcbnew/modview_frame.cpp | 6 +- pcbnew/move_or_drag_track.cpp | 7 +- pcbnew/pcb_draw_panel_gal.cpp | 24 +++++- pcbnew/pcb_painter.cpp | 23 +++--- pcbnew/pcb_painter.h | 2 +- pcbnew/pcbframe.cpp | 9 --- pcbnew/pcbnew.cpp | 4 - pcbnew/pcbnew.h | 5 -- pcbnew/pcbnew_config.cpp | 33 ++++---- pcbnew/print_board_functions.cpp | 81 ++++++++----------- pcbnew/ratsnest.cpp | 3 +- pcbnew/router/router_tool.cpp | 5 +- pcbnew/tool_modedit.cpp | 5 ++ pcbnew/toolbars_update_user_interface.cpp | 25 +++--- pcbnew/tools/pcbnew_control.cpp | 32 ++++---- pcbnew/tracepcb.cpp | 12 ++- 51 files changed, 471 insertions(+), 399 deletions(-) diff --git a/common/draw_panel.cpp b/common/draw_panel.cpp index 9293f1ada9..4c425bfa09 100644 --- a/common/draw_panel.cpp +++ b/common/draw_panel.cpp @@ -172,6 +172,12 @@ EDA_DRAW_FRAME* EDA_DRAW_PANEL::GetParent() const } +void* EDA_DRAW_PANEL::GetDisplayOptions() +{ + return GetParent()->GetDisplayOptions(); +} + + BASE_SCREEN* EDA_DRAW_PANEL::GetScreen() { EDA_DRAW_FRAME* parentFrame = GetParent(); diff --git a/cvpcb/class_DisplayFootprintsFrame.cpp b/cvpcb/class_DisplayFootprintsFrame.cpp index feb10e01a1..49e8958fb2 100644 --- a/cvpcb/class_DisplayFootprintsFrame.cpp +++ b/cvpcb/class_DisplayFootprintsFrame.cpp @@ -53,9 +53,6 @@ #include <3d_viewer.h> -DISPLAY_OPTIONS DisplayOpt; // General display options - - BEGIN_EVENT_TABLE( DISPLAY_FOOTPRINTS_FRAME, PCB_BASE_FRAME ) EVT_CLOSE( DISPLAY_FOOTPRINTS_FRAME::OnCloseWindow ) EVT_SIZE( DISPLAY_FOOTPRINTS_FRAME::OnSize ) @@ -100,10 +97,11 @@ DISPLAY_FOOTPRINTS_FRAME::DISPLAY_FOOTPRINTS_FRAME( KIWAY* aKiway, CVPCB_MAINFRA GetScreen()->SetGrid( ID_POPUP_GRID_LEVEL_1000 + m_LastGridSizeId ); // Initialize some display options - DisplayOpt.DisplayPadIsol = false; // Pad clearance has no meaning here + DISPLAY_OPTIONS* displ_opts = (DISPLAY_OPTIONS*)GetDisplayOptions(); + displ_opts->m_DisplayPadIsol = false; // Pad clearance has no meaning here // Track and via clearance has no meaning here. - DisplayOpt.ShowTrackClearanceMode = DO_NOT_SHOW_CLEARANCE; + displ_opts->m_ShowTrackClearanceMode = DO_NOT_SHOW_CLEARANCE; SetSize( m_FramePos.x, m_FramePos.y, m_FrameSize.x, m_FrameSize.y ); ReCreateHToolbar(); @@ -248,34 +246,36 @@ void DISPLAY_FOOTPRINTS_FRAME::ReCreateHToolbar() void DISPLAY_FOOTPRINTS_FRAME::OnUpdateTextDrawMode( wxUpdateUIEvent& aEvent ) { - wxString msgTextsFill[3] = { _( "Show texts in line mode" ), - _( "Show texts in filled mode" ), + DISPLAY_OPTIONS* displ_opts = (DISPLAY_OPTIONS*)GetDisplayOptions(); + + wxString msgTextsFill[2] = { _( "Show texts in filled mode" ), _( "Show texts in sketch mode" ) }; - unsigned i = m_DisplayModText + 1; + unsigned i = displ_opts->m_DisplayModText + 1; if ( i > 2 ) - i = 0; + i = 1; - aEvent.Check( m_DisplayModText == 0 ); - m_optionsToolBar->SetToolShortHelp( ID_TB_OPTIONS_SHOW_MODULE_TEXT_SKETCH, msgTextsFill[i] ); + aEvent.Check( displ_opts->m_DisplayModText == 1 ); + m_optionsToolBar->SetToolShortHelp( ID_TB_OPTIONS_SHOW_MODULE_TEXT_SKETCH, msgTextsFill[i-1] ); } void DISPLAY_FOOTPRINTS_FRAME::OnUpdateLineDrawMode( wxUpdateUIEvent& aEvent ) { - wxString msgEdgesFill[3] = { _( "Show outlines in line mode" ), - _( "Show outlines in filled mode" ), + DISPLAY_OPTIONS* displ_opts = (DISPLAY_OPTIONS*)GetDisplayOptions(); + + wxString msgEdgesFill[3] = { _( "Show outlines in filled mode" ), _( "Show outlines in sketch mode" ) }; - int i = m_DisplayModEdge + 1; + int i = displ_opts->m_DisplayModEdge + 1; if ( i > 2 ) - i = 0; + i = 1; - aEvent.Check( m_DisplayModEdge == 0 ); - m_optionsToolBar->SetToolShortHelp( ID_TB_OPTIONS_SHOW_MODULE_EDGE_SKETCH, msgEdgesFill[i] ); + aEvent.Check( displ_opts->m_DisplayModEdge == 2 ); + m_optionsToolBar->SetToolShortHelp( ID_TB_OPTIONS_SHOW_MODULE_EDGE_SKETCH, msgEdgesFill[i-1] ); } @@ -298,23 +298,24 @@ bool DISPLAY_FOOTPRINTS_FRAME::OnRightClick( const wxPoint& MousePos, wxMenu* Po void DISPLAY_FOOTPRINTS_FRAME::OnSelectOptionToolbar( wxCommandEvent& event ) { int id = event.GetId(); + DISPLAY_OPTIONS* displ_opts = (DISPLAY_OPTIONS*)GetDisplayOptions(); switch( id ) { case ID_TB_OPTIONS_SHOW_MODULE_TEXT_SKETCH: - m_DisplayModText++; + displ_opts->m_DisplayModText++; - if( m_DisplayModText > 2 ) - m_DisplayModText = 0; + if( displ_opts->m_DisplayModText > 2 ) + displ_opts->m_DisplayModText = 0; m_canvas->Refresh( ); break; case ID_TB_OPTIONS_SHOW_MODULE_EDGE_SKETCH: - m_DisplayModEdge++; + displ_opts->m_DisplayModEdge++; - if( m_DisplayModEdge > 2 ) - m_DisplayModEdge = 0; + if( displ_opts->m_DisplayModEdge > 2 ) + displ_opts->m_DisplayModEdge = 0; m_canvas->Refresh(); break; diff --git a/cvpcb/dialogs/dialog_display_options.cpp b/cvpcb/dialogs/dialog_display_options.cpp index e216e2b08a..381cf976c9 100644 --- a/cvpcb/dialogs/dialog_display_options.cpp +++ b/cvpcb/dialogs/dialog_display_options.cpp @@ -72,10 +72,12 @@ void DIALOG_FOOTPRINTS_DISPLAY_OPTIONS::initDialog() /* mandatory to use escape key as cancel under wxGTK. */ SetFocus(); - m_EdgesDisplayOption->SetSelection( m_Parent->m_DisplayModEdge ); - m_TextDisplayOption->SetSelection( m_Parent->m_DisplayModText ); - m_IsShowPadFill->SetValue( m_Parent->m_DisplayPadFill ); - m_IsShowPadNum->SetValue( m_Parent->m_DisplayPadNum ); + DISPLAY_OPTIONS* displ_opts = (DISPLAY_OPTIONS*)m_Parent->GetDisplayOptions(); + + m_EdgesDisplayOption->SetSelection( displ_opts->m_DisplayModEdge ); + m_TextDisplayOption->SetSelection( displ_opts->m_DisplayModText ); + m_IsShowPadFill->SetValue( displ_opts->m_DisplayPadFill ); + m_IsShowPadNum->SetValue( displ_opts->m_DisplayPadNum ); m_IsZoomNoCenter->SetValue( m_Parent->GetCanvas()->GetEnableZoomNoCenter() ); m_IsMiddleButtonPan->SetValue( m_Parent->GetCanvas()->GetEnableMiddleButtonPan() ); m_IsMiddleButtonPanLimited->SetValue( m_Parent->GetCanvas()->GetMiddleButtonPanLimited() ); @@ -90,10 +92,12 @@ void DIALOG_FOOTPRINTS_DISPLAY_OPTIONS::initDialog() void DIALOG_FOOTPRINTS_DISPLAY_OPTIONS::UpdateObjectSettings( void ) { - m_Parent->m_DisplayModEdge = m_EdgesDisplayOption->GetSelection(); - m_Parent->m_DisplayModText = m_TextDisplayOption->GetSelection(); - m_Parent->m_DisplayPadNum = m_IsShowPadNum->GetValue(); - m_Parent->m_DisplayPadFill = m_IsShowPadFill->GetValue(); + DISPLAY_OPTIONS* displ_opts = (DISPLAY_OPTIONS*)m_Parent->GetDisplayOptions(); + + displ_opts->m_DisplayModEdge = m_EdgesDisplayOption->GetSelection(); + displ_opts->m_DisplayModText = m_TextDisplayOption->GetSelection(); + displ_opts->m_DisplayPadNum = m_IsShowPadNum->GetValue(); + displ_opts->m_DisplayPadFill = m_IsShowPadFill->GetValue(); m_Parent->GetCanvas()->SetEnableZoomNoCenter( m_IsZoomNoCenter->GetValue() ); m_Parent->GetCanvas()->SetEnableMiddleButtonPan( m_IsMiddleButtonPan->GetValue() ); m_Parent->GetCanvas()->SetMiddleButtonPanLimited( m_IsMiddleButtonPanLimited->GetValue() ); diff --git a/include/class_drawpanel.h b/include/class_drawpanel.h index d3e69371b3..b37dc69da1 100644 --- a/include/class_drawpanel.h +++ b/include/class_drawpanel.h @@ -121,6 +121,13 @@ public: EDA_DRAW_PANEL( EDA_DRAW_FRAME* parent, int id, const wxPoint& pos, const wxSize& size ); ~EDA_DRAW_PANEL(); + /** + * Function GetDisplayOptions + * A way to pass info to draw functions. + * this is just an accessor to the GetDisplayOptions() parent frame function. + */ + void* GetDisplayOptions(); + BASE_SCREEN* GetScreen(); EDA_DRAW_FRAME* GetParent() const; diff --git a/include/draw_frame.h b/include/draw_frame.h index c3a636f280..a8ea81e3a9 100644 --- a/include/draw_frame.h +++ b/include/draw_frame.h @@ -730,6 +730,14 @@ public: EDA_DRAW_PANEL_GAL* GetGalCanvas() const { return m_galCanvas; } void SetGalCanvas( EDA_DRAW_PANEL_GAL* aPanel ) { m_galCanvas = aPanel; } + /** + * Function GetDisplayOptions + * A way to pass info to draw functions. the base class has no knowledge about + * these options. It is virtual because this function must be overloaded to + * pass usefull info. + */ + virtual void* GetDisplayOptions() { return NULL; } + DECLARE_EVENT_TABLE() }; diff --git a/include/pcbstruct.h b/include/pcbstruct.h index 7ce19e346f..d55e6f802b 100644 --- a/include/pcbstruct.h +++ b/include/pcbstruct.h @@ -71,32 +71,33 @@ enum TRACE_CLEARANCE_DISPLAY_MODE_T { class DISPLAY_OPTIONS { public: - bool DisplayPadFill; - bool DisplayViaFill; - bool DisplayPadNum; - bool DisplayPadIsol; - - int DisplayModEdge; - int DisplayModText; - bool DisplayPcbTrackFill; /* false = sketch , true = filled */ + bool m_DisplayPadFill; + bool m_DisplayViaFill; + bool m_DisplayPadNum; // show pads numbers + bool m_DisplayPadIsol; + int m_DisplayModEdge; // How to display module drawings (line/ filled / sketch) + int m_DisplayModText; // How to display module texts (line/ filled / sketch) + bool m_DisplayPcbTrackFill; // false : tracks are show in sketch mode, true = filled. /// How trace clearances are displayed. @see TRACE_CLEARANCE_DISPLAY_MODE_T. - TRACE_CLEARANCE_DISPLAY_MODE_T ShowTrackClearanceMode; + TRACE_CLEARANCE_DISPLAY_MODE_T m_ShowTrackClearanceMode; VIA_DISPLAY_MODE_T m_DisplayViaMode; /* 0 do not show via hole, * 1 show via hole for non default value * 2 show all via hole */ - bool DisplayPolarCood; - int DisplayZonesMode; - int DisplayNetNamesMode; /* 0 do not show netnames, + bool m_DisplayPolarCood; + int m_DisplayZonesMode; + int m_DisplayNetNamesMode; /* 0 do not show netnames, * 1 show netnames on pads * 2 show netnames on tracks * 3 show netnames on tracks and pads */ - int DisplayDrawItems; - bool ContrastModeDisplay; + int m_DisplayDrawItems; + bool m_ContrastModeDisplay; + int m_MaxLinksShowed; // in track creation: number of hairwires shown + bool m_Show_Module_Ratsnest; // When moving a footprint: allows displaying a ratsnest public: DISPLAY_OPTIONS(); diff --git a/include/wxBasePcbFrame.h b/include/wxBasePcbFrame.h index 31202de1c9..9dea4c89d2 100644 --- a/include/wxBasePcbFrame.h +++ b/include/wxBasePcbFrame.h @@ -39,6 +39,7 @@ #include // EDA_DRAW_MODE_T #include #include +#include /* Forward declarations of classes. */ @@ -66,13 +67,7 @@ class TOOL_DISPATCHER; class PCB_BASE_FRAME : public EDA_DRAW_FRAME { public: - bool m_DisplayPadFill; // How show pads - bool m_DisplayViaFill; // How show vias - bool m_DisplayPadNum; // show pads numbers - - int m_DisplayModEdge; // How to display module drawings (line/ filled / sketch) - int m_DisplayModText; // How to display module texts (line/ filled / sketch) - bool m_DisplayPcbTrackFill; // false : tracks are show in sketch mode, true = filled. + DISPLAY_OPTIONS m_DisplayOptions; EDA_UNITS_T m_UserGridUnit; wxRealPoint m_UserGridSize; @@ -156,6 +151,16 @@ public: virtual BOARD_DESIGN_SETTINGS& GetDesignSettings() const; virtual void SetDesignSettings( const BOARD_DESIGN_SETTINGS& aSettings ); + /** + * Function GetDisplayOptions + * returns the display options current in use + * Display options are relative to the way tracks, vias, outlines + * and other things are shown (for instance solid or sketch mode) + * Must be overloaded in frames which have display options + * (board editor and footprint editor) + */ + void* GetDisplayOptions() { return &m_DisplayOptions; } + const ZONE_SETTINGS& GetZoneSettings() const; void SetZoneSettings( const ZONE_SETTINGS& aSettings ); diff --git a/pcbnew/autorouter/auto_place_footprints.cpp b/pcbnew/autorouter/auto_place_footprints.cpp index c72b90af7a..d3bd65ca3a 100644 --- a/pcbnew/autorouter/auto_place_footprints.cpp +++ b/pcbnew/autorouter/auto_place_footprints.cpp @@ -619,12 +619,13 @@ int getOptimalModulePlacement( PCB_EDIT_FRAME* aFrame, MODULE* aModule, wxDC* aD wxPoint LastPosOK; double min_cost, curr_cost, Score; bool TstOtherSide; - bool showRats = g_Show_Module_Ratsnest; + DISPLAY_OPTIONS* displ_opts = (DISPLAY_OPTIONS*)aFrame->GetDisplayOptions(); BOARD* brd = aFrame->GetBoard(); aModule->CalculateBoundingBox(); - g_Show_Module_Ratsnest = false; + bool showRats = displ_opts->m_Show_Module_Ratsnest; + displ_opts->m_Show_Module_Ratsnest = false; brd->m_Status_Pcb &= ~RATSNEST_ITEM_LOCAL_OK; aFrame->SetMsgPanel( aModule ); @@ -735,7 +736,7 @@ int getOptimalModulePlacement( PCB_EDIT_FRAME* aFrame, MODULE* aModule, wxDC* aD // erasing the last traces GRRect( aFrame->GetCanvas()->GetClipBox(), aDC, fpBBox, 0, BROWN ); - g_Show_Module_Ratsnest = showRats; + displ_opts->m_Show_Module_Ratsnest = showRats; // Regeneration of the modified variable. CurrPosition = LastPosOK; diff --git a/pcbnew/basepcbframe.cpp b/pcbnew/basepcbframe.cpp index 7a73ea51f5..6c18bef2d2 100644 --- a/pcbnew/basepcbframe.cpp +++ b/pcbnew/basepcbframe.cpp @@ -98,14 +98,6 @@ PCB_BASE_FRAME::PCB_BASE_FRAME( KIWAY* aKiway, wxWindow* aParent, FRAME_T aFrame m_Pcb = NULL; m_toolManager = NULL; m_toolDispatcher = NULL; - - m_DisplayPadFill = true; // How to draw pads - m_DisplayViaFill = true; // How to draw vias - m_DisplayPadNum = true; // show pads number - - m_DisplayModEdge = FILLED; // How to display module drawings (line/ filled / sketch) - m_DisplayModText = FILLED; // How to display module texts (line/ filled / sketch) - m_DisplayPcbTrackFill = true; // false = sketch , true = filled m_Draw3DFrame = NULL; // Display Window in 3D mode (OpenGL) m_UserGridSize = wxRealPoint( 100.0, 100.0 ); @@ -381,6 +373,7 @@ void PCB_BASE_FRAME::Show3D_Frame( wxCommandEvent& event ) void PCB_BASE_FRAME::SwitchLayer( wxDC* DC, LAYER_ID layer ) { LAYER_ID preslayer = ((PCB_SCREEN*)GetScreen())->m_Active_Layer; + DISPLAY_OPTIONS* displ_opts = (DISPLAY_OPTIONS*)GetDisplayOptions(); // Check if the specified layer matches the present layer if( layer == preslayer ) @@ -422,22 +415,27 @@ void PCB_BASE_FRAME::SwitchLayer( wxDC* DC, LAYER_ID layer ) GetScreen()->m_Active_Layer = layer; - if( DisplayOpt.ContrastModeDisplay ) + if( displ_opts->m_ContrastModeDisplay ) m_canvas->Refresh(); } void PCB_BASE_FRAME::OnTogglePolarCoords( wxCommandEvent& aEvent ) { + DISPLAY_OPTIONS* displ_opts = (DISPLAY_OPTIONS*)GetDisplayOptions(); SetStatusText( wxEmptyString ); - DisplayOpt.DisplayPolarCood = !DisplayOpt.DisplayPolarCood; + + displ_opts->m_DisplayPolarCood = !displ_opts->m_DisplayPolarCood; + UpdateStatusBar(); } void PCB_BASE_FRAME::OnTogglePadDrawMode( wxCommandEvent& aEvent ) { - m_DisplayPadFill = DisplayOpt.DisplayPadFill = !m_DisplayPadFill; + DISPLAY_OPTIONS* displ_opts = (DISPLAY_OPTIONS*)GetDisplayOptions(); + + displ_opts->m_DisplayPadFill = !displ_opts->m_DisplayPadFill; EDA_DRAW_PANEL_GAL* gal = GetGalCanvas(); if( gal ) @@ -447,7 +445,7 @@ void PCB_BASE_FRAME::OnTogglePadDrawMode( wxCommandEvent& aEvent ) static_cast ( gal->GetView()->GetPainter() ); KIGFX::PCB_RENDER_SETTINGS* settings = static_cast ( painter->GetSettings() ); - settings->LoadDisplayOptions( DisplayOpt ); + settings->LoadDisplayOptions( displ_opts ); // Update pads BOARD* board = GetBoard(); @@ -464,9 +462,11 @@ void PCB_BASE_FRAME::OnTogglePadDrawMode( wxCommandEvent& aEvent ) void PCB_BASE_FRAME::OnUpdateCoordType( wxUpdateUIEvent& aEvent ) { - aEvent.Check( DisplayOpt.DisplayPolarCood ); + DISPLAY_OPTIONS* displ_opts = (DISPLAY_OPTIONS*)GetDisplayOptions(); + + aEvent.Check( displ_opts->m_DisplayPolarCood ); m_optionsToolBar->SetToolShortHelp( ID_TB_OPTIONS_SHOW_POLAR_COORD, - DisplayOpt.DisplayPolarCood ? + displ_opts->m_DisplayPolarCood ? _( "Display rectangular coordinates" ) : _( "Display polar coordinates" ) ); } @@ -474,9 +474,10 @@ void PCB_BASE_FRAME::OnUpdateCoordType( wxUpdateUIEvent& aEvent ) void PCB_BASE_FRAME::OnUpdatePadDrawMode( wxUpdateUIEvent& aEvent ) { - aEvent.Check( !m_DisplayPadFill ); + DISPLAY_OPTIONS* displ_opts = (DISPLAY_OPTIONS*)GetDisplayOptions(); + aEvent.Check( !displ_opts->m_DisplayPadFill ); m_optionsToolBar->SetToolShortHelp( ID_TB_OPTIONS_SHOW_PADS_SKETCH, - m_DisplayPadFill ? + displ_opts->m_DisplayPadFill ? _( "Show pads in outline mode" ) : _( "Show pads in fill mode" ) ); } @@ -615,16 +616,18 @@ void PCB_BASE_FRAME::SetToolID( int aId, int aCursor, const wxString& aToolMsg ) if( aId < 0 ) return; + DISPLAY_OPTIONS* displ_opts = (DISPLAY_OPTIONS*)GetDisplayOptions(); + // handle color changes for transitions in and out of ID_TRACK_BUTT if( ( GetToolId() == ID_TRACK_BUTT && aId != ID_TRACK_BUTT ) || ( GetToolId() != ID_TRACK_BUTT && aId == ID_TRACK_BUTT ) ) { - if( DisplayOpt.ContrastModeDisplay ) + if( displ_opts->m_ContrastModeDisplay ) redraw = true; } // must do this after the tool has been set, otherwise pad::Draw() does - // not show proper color when DisplayOpt.ContrastModeDisplay is true. + // not show proper color when GetDisplayOptions().ContrastModeDisplay is true. if( redraw && m_canvas ) m_canvas->Refresh(); } @@ -646,10 +649,11 @@ void PCB_BASE_FRAME::UpdateStatusBar() double dYpos; wxString line; wxString locformatter; + DISPLAY_OPTIONS* displ_opts = (DISPLAY_OPTIONS*)GetDisplayOptions(); EDA_DRAW_FRAME::UpdateStatusBar(); - if( DisplayOpt.DisplayPolarCood ) // display polar coordinates + if( displ_opts->m_DisplayPolarCood ) // display polar coordinates { double theta, ro; @@ -708,7 +712,7 @@ void PCB_BASE_FRAME::UpdateStatusBar() line.Printf( absformatter, dXpos, dYpos ); SetStatusText( line, 2 ); - if( !DisplayOpt.DisplayPolarCood ) // display relative cartesian coordinates + if( !displ_opts->m_DisplayPolarCood ) // display relative cartesian coordinates { // Display relative coordinates: dx = GetCrossHairPosition().x - screen->m_O_Curseur.x; @@ -746,23 +750,23 @@ void PCB_BASE_FRAME::LoadSettings( wxConfigBase* aCfg ) long itmp; aCfg->Read( m_FrameName + UserGridUnitsEntry, &itmp, ( long )INCHES ); m_UserGridUnit = (EDA_UNITS_T) itmp; - aCfg->Read( m_FrameName + DisplayPadFillEntry, &m_DisplayPadFill, true ); - aCfg->Read( m_FrameName + DisplayViaFillEntry, &m_DisplayViaFill, true ); - aCfg->Read( m_FrameName + DisplayPadNumberEntry, &m_DisplayPadNum, true ); - aCfg->Read( m_FrameName + DisplayModuleEdgeEntry, &m_DisplayModEdge, ( long )FILLED ); + aCfg->Read( m_FrameName + DisplayPadFillEntry, &m_DisplayOptions.m_DisplayPadFill, true ); + aCfg->Read( m_FrameName + DisplayViaFillEntry, &m_DisplayOptions.m_DisplayViaFill, true ); + aCfg->Read( m_FrameName + DisplayPadNumberEntry, &m_DisplayOptions.m_DisplayPadNum, true ); + aCfg->Read( m_FrameName + DisplayModuleEdgeEntry, &m_DisplayOptions.m_DisplayModEdge, ( long )FILLED ); aCfg->Read( m_FrameName + FastGrid1Entry, &itmp, ( long )0); m_FastGrid1 = itmp; aCfg->Read( m_FrameName + FastGrid2Entry, &itmp, ( long )0); m_FastGrid2 = itmp; - if( m_DisplayModEdge < LINE || m_DisplayModEdge > SKETCH ) - m_DisplayModEdge = FILLED; + if( m_DisplayOptions.m_DisplayModEdge < LINE || m_DisplayOptions.m_DisplayModEdge > SKETCH ) + m_DisplayOptions.m_DisplayModEdge = FILLED; - aCfg->Read( m_FrameName + DisplayModuleTextEntry, &m_DisplayModText, ( long )FILLED ); + aCfg->Read( m_FrameName + DisplayModuleTextEntry, &m_DisplayOptions.m_DisplayModText, ( long )FILLED ); - if( m_DisplayModText < LINE || m_DisplayModText > SKETCH ) - m_DisplayModText = FILLED; + if( m_DisplayOptions.m_DisplayModText < LINE || m_DisplayOptions.m_DisplayModText > SKETCH ) + m_DisplayOptions.m_DisplayModText = FILLED; // WxWidgets 2.9.1 seems call setlocale( LC_NUMERIC, "" ) // when reading doubles in config, @@ -778,11 +782,11 @@ void PCB_BASE_FRAME::SaveSettings( wxConfigBase* aCfg ) aCfg->Write( m_FrameName + UserGridSizeXEntry, m_UserGridSize.x ); aCfg->Write( m_FrameName + UserGridSizeYEntry, m_UserGridSize.y ); aCfg->Write( m_FrameName + UserGridUnitsEntry, ( long )m_UserGridUnit ); - aCfg->Write( m_FrameName + DisplayPadFillEntry, m_DisplayPadFill ); - aCfg->Write( m_FrameName + DisplayViaFillEntry, m_DisplayViaFill ); - aCfg->Write( m_FrameName + DisplayPadNumberEntry, m_DisplayPadNum ); - aCfg->Write( m_FrameName + DisplayModuleEdgeEntry, ( long )m_DisplayModEdge ); - aCfg->Write( m_FrameName + DisplayModuleTextEntry, ( long )m_DisplayModText ); + aCfg->Write( m_FrameName + DisplayPadFillEntry, m_DisplayOptions.m_DisplayPadFill ); + aCfg->Write( m_FrameName + DisplayViaFillEntry, m_DisplayOptions.m_DisplayViaFill ); + aCfg->Write( m_FrameName + DisplayPadNumberEntry, m_DisplayOptions.m_DisplayPadNum ); + aCfg->Write( m_FrameName + DisplayModuleEdgeEntry, ( long )m_DisplayOptions.m_DisplayModEdge ); + aCfg->Write( m_FrameName + DisplayModuleTextEntry, ( long )m_DisplayOptions.m_DisplayModText ); aCfg->Write( m_FrameName + FastGrid1Entry, ( long )m_FastGrid1 ); aCfg->Write( m_FrameName + FastGrid2Entry, ( long )m_FastGrid2 ); } diff --git a/pcbnew/block.cpp b/pcbnew/block.cpp index fb6c7d62c2..71d6370056 100644 --- a/pcbnew/block.cpp +++ b/pcbnew/block.cpp @@ -565,8 +565,9 @@ static void drawMovingBlock( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint& a BASE_SCREEN* screen = aPanel->GetScreen(); // do not show local module rastnest in block move, it is not usable. - bool tmp = g_Show_Module_Ratsnest; - g_Show_Module_Ratsnest = false; + DISPLAY_OPTIONS* displ_opts = (DISPLAY_OPTIONS*)aPanel->GetDisplayOptions(); + bool showRats = displ_opts->m_Show_Module_Ratsnest; + displ_opts->m_Show_Module_Ratsnest = false; if( aErase ) { @@ -596,7 +597,7 @@ static void drawMovingBlock( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint& a drawPickedItems( aPanel, aDC, screen->m_BlockLocate.GetMoveVector() ); } - g_Show_Module_Ratsnest = tmp; + displ_opts->m_Show_Module_Ratsnest = showRats; } diff --git a/pcbnew/class_dimension.cpp b/pcbnew/class_dimension.cpp index 6fd4e2ef9d..af6f420f76 100644 --- a/pcbnew/class_dimension.cpp +++ b/pcbnew/class_dimension.cpp @@ -346,7 +346,8 @@ void DIMENSION::Draw( EDA_DRAW_PANEL* panel, wxDC* DC, GR_DRAWMODE mode_color, gcolor = brd->GetLayerColor( m_Layer ); GRSetDrawMode( DC, mode_color ); - typeaff = DisplayOpt.DisplayDrawItems; + DISPLAY_OPTIONS* displ_opts = (DISPLAY_OPTIONS*)panel->GetDisplayOptions(); + typeaff = displ_opts ? displ_opts->m_DisplayDrawItems : FILLED; width = m_Width; if( DC->LogicalToDeviceXRel( width ) <= MIN_DRAW_WIDTH ) diff --git a/pcbnew/class_drawsegment.cpp b/pcbnew/class_drawsegment.cpp index ed043ada0b..e19f2792ea 100644 --- a/pcbnew/class_drawsegment.cpp +++ b/pcbnew/class_drawsegment.cpp @@ -183,7 +183,9 @@ void DRAWSEGMENT::Draw( EDA_DRAW_PANEL* panel, wxDC* DC, GR_DRAWMODE draw_mode, color = brd->GetLayerColor( GetLayer() ); - if( ( draw_mode & GR_ALLOW_HIGHCONTRAST ) && DisplayOpt.ContrastModeDisplay ) + DISPLAY_OPTIONS* displ_opts = (DISPLAY_OPTIONS*)panel->GetDisplayOptions(); + + if( ( draw_mode & GR_ALLOW_HIGHCONTRAST ) && displ_opts && displ_opts->m_ContrastModeDisplay ) { if( !IsOnLayer( curr_layer ) && !IsOnLayer( Edge_Cuts ) ) ColorTurnToDarkDarkGray( &color ); @@ -200,7 +202,7 @@ void DRAWSEGMENT::Draw( EDA_DRAW_PANEL* panel, wxDC* DC, GR_DRAWMODE draw_mode, dx = m_End.x + aOffset.x; dy = m_End.y + aOffset.y; - mode = DisplayOpt.DisplayDrawItems; + mode = displ_opts ? displ_opts->m_DisplayDrawItems : FILLED; if( m_Flags & FORCE_SKETCH ) mode = SKETCH; diff --git a/pcbnew/class_edge_mod.cpp b/pcbnew/class_edge_mod.cpp index 62661bc46f..018ea36653 100644 --- a/pcbnew/class_edge_mod.cpp +++ b/pcbnew/class_edge_mod.cpp @@ -144,15 +144,14 @@ void EDGE_MODULE::Draw( EDA_DRAW_PANEL* panel, wxDC* DC, GR_DRAWMODE draw_mode, return; EDA_COLOR_T color = brd->GetLayerColor( m_Layer ); + DISPLAY_OPTIONS* displ_opts = (DISPLAY_OPTIONS*)panel->GetDisplayOptions(); - if(( draw_mode & GR_ALLOW_HIGHCONTRAST ) && DisplayOpt.ContrastModeDisplay ) + if(( draw_mode & GR_ALLOW_HIGHCONTRAST ) && displ_opts && displ_opts->m_ContrastModeDisplay ) { if( !IsOnLayer( curr_layer ) ) ColorTurnToDarkDarkGray( &color ); } - PCB_BASE_FRAME* frame = (PCB_BASE_FRAME*) panel->GetParent(); - ux0 = m_Start.x - offset.x; uy0 = m_Start.y - offset.y; @@ -160,11 +159,11 @@ void EDGE_MODULE::Draw( EDA_DRAW_PANEL* panel, wxDC* DC, GR_DRAWMODE draw_mode, dy = m_End.y - offset.y; GRSetDrawMode( DC, draw_mode ); - typeaff = frame->m_DisplayModEdge; + typeaff = displ_opts ? displ_opts->m_DisplayModEdge : FILLED; if( IsCopperLayer( m_Layer ) ) { - typeaff = frame->m_DisplayPcbTrackFill; + typeaff = displ_opts ? displ_opts->m_DisplayPcbTrackFill : FILLED; if( !typeaff ) typeaff = SKETCH; diff --git a/pcbnew/class_mire.cpp b/pcbnew/class_mire.cpp index e54946c335..8e63f5f275 100644 --- a/pcbnew/class_mire.cpp +++ b/pcbnew/class_mire.cpp @@ -102,7 +102,8 @@ void PCB_TARGET::Draw( EDA_DRAW_PANEL* panel, wxDC* DC, GR_DRAWMODE mode_color, EDA_COLOR_T gcolor = brd->GetLayerColor( m_Layer ); GRSetDrawMode( DC, mode_color ); - typeaff = DisplayOpt.DisplayDrawItems; + DISPLAY_OPTIONS* displ_opts = (DISPLAY_OPTIONS*)panel->GetDisplayOptions(); + typeaff = displ_opts ? displ_opts->m_DisplayDrawItems : FILLED; width = m_Width; if( DC->LogicalToDeviceXRel( width ) <= MIN_DRAW_WIDTH ) diff --git a/pcbnew/class_pad_draw_functions.cpp b/pcbnew/class_pad_draw_functions.cpp index 67a4627caf..48747bce1e 100644 --- a/pcbnew/class_pad_draw_functions.cpp +++ b/pcbnew/class_pad_draw_functions.cpp @@ -117,9 +117,10 @@ void D_PAD::Draw( EDA_DRAW_PANEL* aPanel, wxDC* aDC, GR_DRAWMODE aDraw_mode, return; PCB_BASE_FRAME* frame = (PCB_BASE_FRAME*) aPanel->GetParent(); + DISPLAY_OPTIONS* displ_opts = (DISPLAY_OPTIONS*)frame->GetDisplayOptions(); PCB_SCREEN* screen = frame->GetScreen(); - if( frame->m_DisplayPadFill == FILLED ) + if( displ_opts->m_DisplayPadFill == FILLED ) drawInfo.m_ShowPadFilled = true; else drawInfo.m_ShowPadFilled = false; @@ -165,7 +166,7 @@ void D_PAD::Draw( EDA_DRAW_PANEL* aPanel, wxDC* aDC, GR_DRAWMODE aDraw_mode, // if SMD or connector pad and high contrast mode if( ( aDraw_mode & GR_ALLOW_HIGHCONTRAST ) && ( GetAttribute() == PAD_SMD || GetAttribute() == PAD_CONN ) && - DisplayOpt.ContrastModeDisplay ) + displ_opts && displ_opts->m_ContrastModeDisplay ) { // when routing tracks if( frame && frame->GetToolId() == ID_TRACK_BUTT ) @@ -229,7 +230,7 @@ void D_PAD::Draw( EDA_DRAW_PANEL* aPanel, wxDC* aDC, GR_DRAWMODE aDraw_mode, // layer so we can see pads on paste or solder layer and the size of the // mask if( ( aDraw_mode & GR_ALLOW_HIGHCONTRAST ) && - DisplayOpt.ContrastModeDisplay && !IsCopperLayer( screen->m_Active_Layer ) ) + displ_opts && displ_opts->m_ContrastModeDisplay && !IsCopperLayer( screen->m_Active_Layer ) ) { if( IsOnLayer( screen->m_Active_Layer ) ) { @@ -263,7 +264,7 @@ void D_PAD::Draw( EDA_DRAW_PANEL* aPanel, wxDC* aDC, GR_DRAWMODE aDraw_mode, ColorApplyHighlightFlag( &color ); - bool DisplayIsol = DisplayOpt.DisplayPadIsol; + bool DisplayIsol = displ_opts && displ_opts->m_DisplayPadIsol; if( !( m_layerMask & LSET::AllCuMask() ).any() ) DisplayIsol = false; @@ -284,23 +285,24 @@ void D_PAD::Draw( EDA_DRAW_PANEL* aPanel, wxDC* aDC, GR_DRAWMODE aDraw_mode, SetAlpha( &color, 170 ); /* Get the pad clearance. This has a meaning only for Pcbnew. - * for CvPcb (and GerbView) GetClearance() creates debug errors because + * for CvPcb GetClearance() creates debug errors because * there is no net classes so a call to GetClearance() is made only when - * needed (never needed in CvPcb nor in GerbView) + * needed (never needed in CvPcb) */ drawInfo.m_PadClearance = DisplayIsol ? GetClearance() : 0; // Draw the pad number - if( frame && !frame->m_DisplayPadNum ) + if( displ_opts && !displ_opts->m_DisplayPadNum ) drawInfo.m_Display_padnum = false; - if( ( DisplayOpt.DisplayNetNamesMode == 0 ) || ( DisplayOpt.DisplayNetNamesMode == 2 ) ) + if( displ_opts && + (( displ_opts ->m_DisplayNetNamesMode == 0 ) || ( displ_opts->m_DisplayNetNamesMode == 2 )) ) drawInfo.m_Display_netname = false; // Display net names is restricted to pads that are on the active layer // in high contrast mode display if( ( aDraw_mode & GR_ALLOW_HIGHCONTRAST ) && - !IsOnLayer( screen->m_Active_Layer ) && DisplayOpt.ContrastModeDisplay ) + !IsOnLayer( screen->m_Active_Layer ) && displ_opts && displ_opts->m_ContrastModeDisplay ) drawInfo.m_Display_netname = false; DrawShape( aPanel->GetClipBox(), aDC, drawInfo ); diff --git a/pcbnew/class_pcb_layer_widget.cpp b/pcbnew/class_pcb_layer_widget.cpp index 9c778903f2..1e1b89f0b2 100644 --- a/pcbnew/class_pcb_layer_widget.cpp +++ b/pcbnew/class_pcb_layer_widget.cpp @@ -431,10 +431,11 @@ bool PCB_LAYER_WIDGET::OnLayerSelect( int aLayer ) return false; myframe->SetActiveLayer( layer ); + DISPLAY_OPTIONS* displ_opts = (DISPLAY_OPTIONS*)myframe->GetDisplayOptions(); if( m_alwaysShowActiveCopperLayer ) OnLayerSelected(); - else if( DisplayOpt.ContrastModeDisplay ) + else if( displ_opts->m_ContrastModeDisplay ) myframe->GetCanvas()->Refresh(); return true; diff --git a/pcbnew/class_pcb_text.cpp b/pcbnew/class_pcb_text.cpp index a296fcaf91..f9bdee7f7d 100644 --- a/pcbnew/class_pcb_text.cpp +++ b/pcbnew/class_pcb_text.cpp @@ -91,8 +91,9 @@ void TEXTE_PCB::Draw( EDA_DRAW_PANEL* panel, wxDC* DC, EDA_COLOR_T color = brd->GetLayerColor( m_Layer ); EDA_DRAW_MODE_T fillmode = FILLED; + DISPLAY_OPTIONS* displ_opts = (DISPLAY_OPTIONS*)panel->GetDisplayOptions(); - if( DisplayOpt.DisplayDrawItems == SKETCH ) + if( displ_opts && displ_opts->m_DisplayDrawItems == SKETCH ) fillmode = SKETCH; EDA_COLOR_T anchor_color = UNSPECIFIED_COLOR; diff --git a/pcbnew/class_text_mod.cpp b/pcbnew/class_text_mod.cpp index 50b9957fb2..91fad64a4f 100644 --- a/pcbnew/class_text_mod.cpp +++ b/pcbnew/class_text_mod.cpp @@ -287,12 +287,12 @@ void TEXTE_MODULE::Draw( EDA_DRAW_PANEL* panel, wxDC* DC, GR_DRAWMODE draw_mode, } // Draw mode compensation for the width - PCB_BASE_FRAME* frame = static_cast( panel->GetParent() ); + DISPLAY_OPTIONS* displ_opts = (DISPLAY_OPTIONS*)panel->GetDisplayOptions(); int width = m_Thickness; - if( ( frame->m_DisplayModText == LINE ) + if( ( displ_opts && displ_opts->m_DisplayModText == LINE ) || ( DC->LogicalToDeviceXRel( width ) <= MIN_DRAW_WIDTH ) ) width = 0; - else if( frame->m_DisplayModText == SKETCH ) + else if( displ_opts && displ_opts->m_DisplayModText == SKETCH ) width = -width; GRSetDrawMode( DC, draw_mode ); diff --git a/pcbnew/class_track.cpp b/pcbnew/class_track.cpp index d70e650dbc..f6c33ff06d 100644 --- a/pcbnew/class_track.cpp +++ b/pcbnew/class_track.cpp @@ -52,14 +52,14 @@ * tests to see if the clearance border is drawn on the given track. * @return bool - true if should draw clearance, else false. */ -static bool ShowClearance( const TRACK* aTrack ) +static bool ShowClearance( DISPLAY_OPTIONS* aDisplOpts, const TRACK* aTrack ) { // maybe return true for tracks and vias, not for zone segments return IsCopperLayer( aTrack->GetLayer() ) && ( aTrack->Type() == PCB_TRACE_T || aTrack->Type() == PCB_VIA_T ) - && ( ( DisplayOpt.ShowTrackClearanceMode == SHOW_CLEARANCE_NEW_AND_EDITED_TRACKS_AND_VIA_AREAS + && ( ( aDisplOpts->m_ShowTrackClearanceMode == SHOW_CLEARANCE_NEW_AND_EDITED_TRACKS_AND_VIA_AREAS && ( aTrack->IsDragging() || aTrack->IsMoving() || aTrack->IsNew() ) ) - || ( DisplayOpt.ShowTrackClearanceMode == SHOW_CLEARANCE_ALWAYS ) + || ( aDisplOpts->m_ShowTrackClearanceMode == SHOW_CLEARANCE_ALWAYS ) ); } @@ -312,11 +312,8 @@ const EDA_RECT TRACK::GetBoundingBox() const xmin = std::min( m_Start.x, m_End.x ); } - if( ShowClearance( this ) ) - { - // + 1 is for the clearance line itself. - radius += GetClearance() + 1; - } + // + 1 is for the clearance line itself. + radius += GetClearance() + 1; ymax += radius; xmax += radius; @@ -538,7 +535,9 @@ void TRACK::DrawShortNetname( EDA_DRAW_PANEL* panel, * - only tracks with a length > 10 * thickness are eligible * and, of course, if we are not printing the board */ - if( DisplayOpt.DisplayNetNamesMode == 0 || DisplayOpt.DisplayNetNamesMode == 1 ) + DISPLAY_OPTIONS* displ_opts = (DISPLAY_OPTIONS*)panel->GetDisplayOptions(); + + if( displ_opts->m_DisplayNetNamesMode == 0 || displ_opts->m_DisplayNetNamesMode == 1 ) return; #define THRESHOLD 10 @@ -596,7 +595,7 @@ void TRACK::DrawShortNetname( EDA_DRAW_PANEL* panel, LAYER_ID curr_layer = ( (PCB_SCREEN*) panel->GetScreen() )->m_Active_Layer; if( ( aDC->LogicalToDeviceXRel( tsize ) >= MIN_TEXT_SIZE ) - && ( !(!IsOnLayer( curr_layer )&& DisplayOpt.ContrastModeDisplay) ) ) + && ( !(!IsOnLayer( curr_layer )&& displ_opts->m_ContrastModeDisplay) ) ) { if( (aDrawMode & GR_XOR) == 0 ) GRSetDrawMode( aDC, GR_COPY ); @@ -629,7 +628,9 @@ void TRACK::Draw( EDA_DRAW_PANEL* panel, wxDC* aDC, GR_DRAWMODE aDrawMode, return; #endif - if( ( aDrawMode & GR_ALLOW_HIGHCONTRAST ) && DisplayOpt.ContrastModeDisplay ) + DISPLAY_OPTIONS* displ_opts = (DISPLAY_OPTIONS*) panel->GetDisplayOptions(); + + if( ( aDrawMode & GR_ALLOW_HIGHCONTRAST ) && displ_opts->m_ContrastModeDisplay ) { LAYER_ID curr_layer = ( (PCB_SCREEN*) panel->GetScreen() )->m_Active_Layer; @@ -654,7 +655,7 @@ void TRACK::Draw( EDA_DRAW_PANEL* panel, wxDC* aDC, GR_DRAWMODE aDrawMode, return; } - if( !DisplayOpt.DisplayPcbTrackFill || GetState( FORCE_SKETCH ) ) + if( !displ_opts->m_DisplayPcbTrackFill || GetState( FORCE_SKETCH ) ) { GRCSegm( panel->GetClipBox(), aDC, m_Start + aOffset, m_End + aOffset, m_Width, color ); } @@ -669,7 +670,7 @@ void TRACK::Draw( EDA_DRAW_PANEL* panel, wxDC* aDC, GR_DRAWMODE aDrawMode, return; // Show clearance for tracks, not for zone segments - if( ShowClearance( this ) ) + if( ShowClearance( displ_opts, this ) ) { GRCSegm( panel->GetClipBox(), aDC, m_Start + aOffset, m_End + aOffset, m_Width + (GetClearance() * 2), color ); @@ -682,7 +683,9 @@ void TRACK::Draw( EDA_DRAW_PANEL* panel, wxDC* aDC, GR_DRAWMODE aDrawMode, void SEGZONE::Draw( EDA_DRAW_PANEL* panel, wxDC* aDC, GR_DRAWMODE aDrawMode, const wxPoint& aOffset ) { - if( DisplayOpt.DisplayZonesMode != 0 ) + DISPLAY_OPTIONS* displ_opts = (DISPLAY_OPTIONS*)panel->GetDisplayOptions(); + + if( displ_opts->m_DisplayZonesMode != 0 ) return; BOARD * brd = GetBoard( ); @@ -697,7 +700,7 @@ void SEGZONE::Draw( EDA_DRAW_PANEL* panel, wxDC* aDC, GR_DRAWMODE aDrawMode, return; #endif - if( ( aDrawMode & GR_ALLOW_HIGHCONTRAST ) && DisplayOpt.ContrastModeDisplay ) + if( ( aDrawMode & GR_ALLOW_HIGHCONTRAST ) && displ_opts->m_ContrastModeDisplay ) { LAYER_ID curr_layer = ( (PCB_SCREEN*) panel->GetScreen() )->m_Active_Layer; @@ -722,7 +725,7 @@ void SEGZONE::Draw( EDA_DRAW_PANEL* panel, wxDC* aDC, GR_DRAWMODE aDrawMode, return; } - if( !DisplayOpt.DisplayPcbTrackFill || GetState( FORCE_SKETCH ) ) + if( !displ_opts->m_DisplayPcbTrackFill || GetState( FORCE_SKETCH ) ) { GRCSegm( panel->GetClipBox(), aDC, m_Start + aOffset, m_End + aOffset, m_Width, color ); } @@ -768,8 +771,9 @@ void VIA::Draw( EDA_DRAW_PANEL* panel, wxDC* aDC, GR_DRAWMODE aDrawMode, int fillvia = 0; PCB_BASE_FRAME* frame = (PCB_BASE_FRAME*) panel->GetParent(); PCB_SCREEN* screen = frame->GetScreen(); + DISPLAY_OPTIONS* displ_opts = (DISPLAY_OPTIONS*)frame->GetDisplayOptions(); - if( frame->m_DisplayViaFill == FILLED ) + if( displ_opts->m_DisplayViaFill == FILLED ) fillvia = 1; GRSetDrawMode( aDC, aDrawMode ); @@ -785,7 +789,7 @@ void VIA::Draw( EDA_DRAW_PANEL* panel, wxDC* aDC, GR_DRAWMODE aDrawMode, if( !( brd->GetVisibleLayers() & GetLayerSet() ).any() ) return; - if( DisplayOpt.ContrastModeDisplay ) + if( displ_opts->m_ContrastModeDisplay ) { if( !IsOnLayer( curr_layer ) ) ColorTurnToDarkDarkGray( &color ); @@ -832,10 +836,10 @@ void VIA::Draw( EDA_DRAW_PANEL* panel, wxDC* aDC, GR_DRAWMODE aDrawMode, } // Draw the via hole if the display option allows it - if( DisplayOpt.m_DisplayViaMode != VIA_HOLE_NOT_SHOW ) + if( displ_opts->m_DisplayViaMode != VIA_HOLE_NOT_SHOW ) { // Display all drill holes requested or Display non default holes requested - if( (DisplayOpt.m_DisplayViaMode == ALL_VIA_HOLE_SHOW) + if( (displ_opts->m_DisplayViaMode == ALL_VIA_HOLE_SHOW) || ( (drill_radius > 0 ) && !IsDrillDefault() ) ) { if( fillvia ) @@ -871,7 +875,7 @@ void VIA::Draw( EDA_DRAW_PANEL* panel, wxDC* aDC, GR_DRAWMODE aDrawMode, } } - if( ShowClearance( this ) ) + if( ShowClearance( displ_opts, this ) ) { GRCircle( panel->GetClipBox(), aDC, m_Start + aOffset, radius + GetClearance(), 0, color ); } @@ -945,7 +949,7 @@ void VIA::Draw( EDA_DRAW_PANEL* panel, wxDC* aDC, GR_DRAWMODE aDrawMode, if( GetNetCode() == NETINFO_LIST::UNCONNECTED ) return; - if( DisplayOpt.DisplayNetNamesMode == 0 || DisplayOpt.DisplayNetNamesMode == 1 ) + if( displ_opts->m_DisplayNetNamesMode == 0 || displ_opts->m_DisplayNetNamesMode == 1 ) return; NETINFO_ITEM* net = GetNet(); diff --git a/pcbnew/class_zone.cpp b/pcbnew/class_zone.cpp index 6acefe36c7..e7e3081e34 100644 --- a/pcbnew/class_zone.cpp +++ b/pcbnew/class_zone.cpp @@ -155,8 +155,9 @@ void ZONE_CONTAINER::Draw( EDA_DRAW_PANEL* panel, wxDC* DC, GR_DRAWMODE aDrawMod return; GRSetDrawMode( DC, aDrawMode ); + DISPLAY_OPTIONS* displ_opts = (DISPLAY_OPTIONS*)panel->GetDisplayOptions(); - if( DisplayOpt.ContrastModeDisplay ) + if( displ_opts->m_ContrastModeDisplay ) { if( !IsOnLayer( curr_layer ) ) ColorTurnToDarkDarkGray( &color ); @@ -215,15 +216,16 @@ void ZONE_CONTAINER::DrawFilledArea( EDA_DRAW_PANEL* panel, { static std::vector CornersTypeBuffer; static std::vector CornersBuffer; + DISPLAY_OPTIONS* displ_opts = (DISPLAY_OPTIONS*)panel->GetDisplayOptions(); // outline_mode is false to show filled polys, // and true to show polygons outlines only (test and debug purposes) - bool outline_mode = DisplayOpt.DisplayZonesMode == 2 ? true : false; + bool outline_mode = displ_opts->m_DisplayZonesMode == 2 ? true : false; if( DC == NULL ) return; - if( DisplayOpt.DisplayZonesMode == 1 ) // Do not show filled areas + if( displ_opts->m_DisplayZonesMode == 1 ) // Do not show filled areas return; if( m_FilledPolysList.GetCornersCount() == 0 ) // Nothing to draw @@ -238,7 +240,7 @@ void ZONE_CONTAINER::DrawFilledArea( EDA_DRAW_PANEL* panel, GRSetDrawMode( DC, aDrawMode ); - if( DisplayOpt.ContrastModeDisplay ) + if( displ_opts->m_ContrastModeDisplay ) { if( !IsOnLayer( curr_layer ) ) ColorTurnToDarkDarkGray( &color ); @@ -293,7 +295,7 @@ void ZONE_CONTAINER::DrawFilledArea( EDA_DRAW_PANEL* panel, // Draw only basic outlines, not extra segments. if( CornersTypeBuffer[ie] == 0 ) { - if( !DisplayOpt.DisplayPcbTrackFill || GetState( FORCE_SKETCH ) ) + if( !displ_opts->m_DisplayPcbTrackFill || GetState( FORCE_SKETCH ) ) GRCSegm( panel->GetClipBox(), DC, x0, y0, x1, y1, m_ZoneMinThickness, color ); @@ -323,7 +325,7 @@ void ZONE_CONTAINER::DrawFilledArea( EDA_DRAW_PANEL* panel, wxPoint start = m_FillSegmList[ic].m_Start + offset; wxPoint end = m_FillSegmList[ic].m_End + offset; - if( !DisplayOpt.DisplayPcbTrackFill || GetState( FORCE_SKETCH ) ) + if( !displ_opts->m_DisplayPcbTrackFill || GetState( FORCE_SKETCH ) ) GRCSegm( panel->GetClipBox(), DC, start.x, start.y, end.x, end.y, m_ZoneMinThickness, color ); else @@ -374,8 +376,9 @@ void ZONE_CONTAINER::DrawWhileCreateOutline( EDA_DRAW_PANEL* panel, wxDC* DC, LAYER_ID curr_layer = ( (PCB_SCREEN*) panel->GetScreen() )->m_Active_Layer; BOARD* brd = GetBoard(); EDA_COLOR_T color = brd->GetLayerColor( m_Layer ); + DISPLAY_OPTIONS* displ_opts = (DISPLAY_OPTIONS*)panel->GetDisplayOptions(); - if( DisplayOpt.ContrastModeDisplay ) + if( displ_opts->m_ContrastModeDisplay ) { if( !IsOnLayer( curr_layer ) ) ColorTurnToDarkDarkGray( &color ); diff --git a/pcbnew/classpcb.cpp b/pcbnew/classpcb.cpp index dd2ded140a..a1430fc600 100644 --- a/pcbnew/classpcb.cpp +++ b/pcbnew/classpcb.cpp @@ -202,26 +202,28 @@ int PCB_SCREEN::MilsToIuScalar() DISPLAY_OPTIONS::DISPLAY_OPTIONS() { - DisplayPadFill = FILLED; - DisplayViaFill = FILLED; - DisplayPadNum = true; - DisplayPadIsol = true; + m_DisplayPadFill = FILLED; + m_DisplayViaFill = FILLED; + m_DisplayPadNum = true; + m_DisplayPadIsol = true; - DisplayModEdge = true; - DisplayModText = true; - DisplayPcbTrackFill = true; // false = sketch , true = filled - ShowTrackClearanceMode = SHOW_CLEARANCE_NEW_TRACKS_AND_VIA_AREAS; + m_DisplayModEdge = true; + m_DisplayModText = true; + m_DisplayPcbTrackFill = true; // false = sketch , true = filled + m_ShowTrackClearanceMode = SHOW_CLEARANCE_NEW_TRACKS_AND_VIA_AREAS; m_DisplayViaMode = VIA_HOLE_NOT_SHOW; - DisplayPolarCood = false; /* false = display absolute coordinates, - * true = display polar cordinates */ - DisplayZonesMode = 0; /* 0 = Show filled areas outlines in zones, - * 1 = do not show filled areas outlines - * 2 = show outlines of filled areas */ - DisplayNetNamesMode = 3; /* 0 do not show netnames, - * 1 show netnames on pads - * 2 show netnames on tracks - * 3 show netnames on tracks and pads */ - DisplayDrawItems = true; - ContrastModeDisplay = false; + m_DisplayPolarCood = false; /* false = display absolute coordinates, + * true = display polar cordinates */ + m_DisplayZonesMode = 0; /* 0 = Show filled areas outlines in zones, + * 1 = do not show filled areas outlines + * 2 = show outlines of filled areas */ + m_DisplayNetNamesMode = 3; /* 0 do not show netnames, + * 1 show netnames on pads + * 2 show netnames on tracks + * 3 show netnames on tracks and pads */ + m_DisplayDrawItems = true; + m_ContrastModeDisplay = false; + m_MaxLinksShowed = 3; // in track creation: number of hairwires shown + m_Show_Module_Ratsnest = true; // When moving a footprint: allows displaying a ratsnest } diff --git a/pcbnew/controle.cpp b/pcbnew/controle.cpp index d9200c84b9..d9475f2179 100644 --- a/pcbnew/controle.cpp +++ b/pcbnew/controle.cpp @@ -104,6 +104,7 @@ BOARD_ITEM* PCB_BASE_FRAME::PcbGeneralLocateAndDisplay( int aHotKeyCode ) BOARD_ITEM* item; GENERAL_COLLECTORS_GUIDE guide = GetCollectorsGuide(); + DISPLAY_OPTIONS* displ_opts = (DISPLAY_OPTIONS*)GetDisplayOptions(); // Assign to scanList the proper item types desired based on tool type // or hotkey that is in play. @@ -120,7 +121,7 @@ BOARD_ITEM* PCB_BASE_FRAME::PcbGeneralLocateAndDisplay( int aHotKeyCode ) if( m_mainToolBar->GetToolToggled( ID_TOOLBARH_PCB_MODE_MODULE ) ) scanList = GENERAL_COLLECTOR::Modules; else - scanList = (DisplayOpt.DisplayZonesMode == 0) ? + scanList = (displ_opts->m_DisplayZonesMode == 0) ? GENERAL_COLLECTOR::AllBoardItems : GENERAL_COLLECTOR::AllButZones; } @@ -146,7 +147,7 @@ BOARD_ITEM* PCB_BASE_FRAME::PcbGeneralLocateAndDisplay( int aHotKeyCode ) break; default: - scanList = DisplayOpt.DisplayZonesMode == 0 ? + scanList = displ_opts->m_DisplayZonesMode == 0 ? GENERAL_COLLECTOR::AllBoardItems : GENERAL_COLLECTOR::AllButZones; } diff --git a/pcbnew/dialogs/dialog_display_options.cpp b/pcbnew/dialogs/dialog_display_options.cpp index a5f8548b3e..a452bc5747 100644 --- a/pcbnew/dialogs/dialog_display_options.cpp +++ b/pcbnew/dialogs/dialog_display_options.cpp @@ -68,13 +68,14 @@ DIALOG_DISPLAY_OPTIONS::DIALOG_DISPLAY_OPTIONS( PCB_EDIT_FRAME* parent ) : void DIALOG_DISPLAY_OPTIONS::init() { SetFocus(); + DISPLAY_OPTIONS* displ_opts = (DISPLAY_OPTIONS*)m_Parent->GetDisplayOptions(); - if ( DisplayOpt.DisplayPcbTrackFill ) + if ( displ_opts->m_DisplayPcbTrackFill ) m_OptDisplayTracks->SetSelection( 1 ); else m_OptDisplayTracks->SetSelection( 0 ); - switch ( DisplayOpt.ShowTrackClearanceMode ) + switch ( displ_opts->m_ShowTrackClearanceMode ) { case DO_NOT_SHOW_CLEARANCE: m_OptDisplayTracksClearance->SetSelection( 0 ); @@ -98,26 +99,26 @@ void DIALOG_DISPLAY_OPTIONS::init() break; } - if ( DisplayOpt.DisplayPadFill ) + if ( displ_opts->m_DisplayPadFill ) m_OptDisplayPads->SetSelection( 1 ); else m_OptDisplayPads->SetSelection( 0 ); - if ( DisplayOpt.DisplayViaFill ) + if ( displ_opts->m_DisplayViaFill ) m_OptDisplayVias->SetSelection( 1 ); else m_OptDisplayVias->SetSelection( 0 ); m_Show_Page_Limits->SetSelection( m_Parent->ShowPageLimits() ? 0 : 1 ); - m_OptDisplayViaHole->SetSelection( DisplayOpt.m_DisplayViaMode ); - m_OptDisplayModTexts->SetSelection( DisplayOpt.DisplayModText ); - m_OptDisplayModEdges->SetSelection( DisplayOpt.DisplayModEdge ); - m_OptDisplayPadClearence->SetValue( DisplayOpt.DisplayPadIsol ); - m_OptDisplayPadNumber->SetValue( DisplayOpt.DisplayPadNum ); + m_OptDisplayViaHole->SetSelection( displ_opts->m_DisplayViaMode ); + m_OptDisplayModTexts->SetSelection( displ_opts->m_DisplayModText ); + m_OptDisplayModEdges->SetSelection( displ_opts->m_DisplayModEdge ); + m_OptDisplayPadClearence->SetValue( displ_opts->m_DisplayPadIsol ); + m_OptDisplayPadNumber->SetValue( displ_opts->m_DisplayPadNum ); m_OptDisplayPadNoConn->SetValue( m_Parent->IsElementVisible( PCB_VISIBLE( NO_CONNECTS_VISIBLE ) ) ); - m_OptDisplayDrawings->SetSelection( DisplayOpt.DisplayDrawItems ); - m_ShowNetNamesOption->SetSelection( DisplayOpt.DisplayNetNamesMode ); + m_OptDisplayDrawings->SetSelection( displ_opts->m_DisplayDrawItems ); + m_ShowNetNamesOption->SetSelection( displ_opts->m_DisplayNetNamesMode ); } @@ -131,74 +132,62 @@ void DIALOG_DISPLAY_OPTIONS::OnCancelClick( wxCommandEvent& event ) */ void DIALOG_DISPLAY_OPTIONS::OnOkClick(wxCommandEvent& event) { + DISPLAY_OPTIONS* displ_opts = (DISPLAY_OPTIONS*)m_Parent->GetDisplayOptions(); + if ( m_Show_Page_Limits->GetSelection() == 0 ) m_Parent->SetShowPageLimits( true ); else m_Parent->SetShowPageLimits( false ); - if ( m_OptDisplayTracks->GetSelection() == 1 ) - DisplayOpt.DisplayPcbTrackFill = true; - else - DisplayOpt.DisplayPcbTrackFill = false; + displ_opts->m_DisplayPcbTrackFill = m_OptDisplayTracks->GetSelection() == 1; - m_Parent->m_DisplayPcbTrackFill = DisplayOpt.DisplayPcbTrackFill; - DisplayOpt.m_DisplayViaMode = (VIA_DISPLAY_MODE_T) m_OptDisplayViaHole->GetSelection(); + displ_opts->m_DisplayViaMode = (VIA_DISPLAY_MODE_T) m_OptDisplayViaHole->GetSelection(); switch ( m_OptDisplayTracksClearance->GetSelection() ) { case 0: - DisplayOpt.ShowTrackClearanceMode = DO_NOT_SHOW_CLEARANCE; + displ_opts->m_ShowTrackClearanceMode = DO_NOT_SHOW_CLEARANCE; break; case 1: - DisplayOpt.ShowTrackClearanceMode = SHOW_CLEARANCE_NEW_TRACKS; + displ_opts->m_ShowTrackClearanceMode = SHOW_CLEARANCE_NEW_TRACKS; break; case 2: - DisplayOpt.ShowTrackClearanceMode = SHOW_CLEARANCE_NEW_TRACKS_AND_VIA_AREAS; + displ_opts->m_ShowTrackClearanceMode = SHOW_CLEARANCE_NEW_TRACKS_AND_VIA_AREAS; break; case 3: - DisplayOpt.ShowTrackClearanceMode = SHOW_CLEARANCE_NEW_AND_EDITED_TRACKS_AND_VIA_AREAS; + displ_opts->m_ShowTrackClearanceMode = SHOW_CLEARANCE_NEW_AND_EDITED_TRACKS_AND_VIA_AREAS; break; case 4: - DisplayOpt.ShowTrackClearanceMode = SHOW_CLEARANCE_ALWAYS; + displ_opts->m_ShowTrackClearanceMode = SHOW_CLEARANCE_ALWAYS; break; } - m_Parent->m_DisplayModText = DisplayOpt.DisplayModText = m_OptDisplayModTexts->GetSelection(); - m_Parent->m_DisplayModEdge = DisplayOpt.DisplayModEdge = m_OptDisplayModEdges->GetSelection(); + displ_opts->m_DisplayModText = m_OptDisplayModTexts->GetSelection(); + displ_opts->m_DisplayModEdge = m_OptDisplayModEdges->GetSelection(); - if (m_OptDisplayPads->GetSelection() == 1 ) - DisplayOpt.DisplayPadFill = true; - else - DisplayOpt.DisplayPadFill = false; + displ_opts->m_DisplayPadFill = m_OptDisplayPads->GetSelection() == 1; + displ_opts->m_DisplayViaFill = m_OptDisplayVias->GetSelection() == 1; - if (m_OptDisplayVias->GetSelection() == 1 ) - DisplayOpt.DisplayViaFill = true; - else - DisplayOpt.DisplayViaFill = false; + displ_opts->m_DisplayPadIsol = m_OptDisplayPadClearence->GetValue(); - m_Parent->m_DisplayPadFill = DisplayOpt.DisplayPadFill; - m_Parent->m_DisplayViaFill = DisplayOpt.DisplayViaFill; - - DisplayOpt.DisplayPadIsol = m_OptDisplayPadClearence->GetValue(); - - m_Parent->m_DisplayPadNum = DisplayOpt.DisplayPadNum = m_OptDisplayPadNumber->GetValue(); + displ_opts->m_DisplayPadNum = m_OptDisplayPadNumber->GetValue(); m_Parent->SetElementVisibility( PCB_VISIBLE(NO_CONNECTS_VISIBLE), m_OptDisplayPadNoConn->GetValue() ); - DisplayOpt.DisplayDrawItems = m_OptDisplayDrawings->GetSelection(); - DisplayOpt.DisplayNetNamesMode = m_ShowNetNamesOption->GetSelection(); + displ_opts->m_DisplayDrawItems = m_OptDisplayDrawings->GetSelection(); + displ_opts->m_DisplayNetNamesMode = m_ShowNetNamesOption->GetSelection(); // Apply changes to the GAL KIGFX::VIEW* view = m_Parent->GetGalCanvas()->GetView(); KIGFX::PCB_PAINTER* painter = static_cast( view->GetPainter() ); KIGFX::PCB_RENDER_SETTINGS* settings = static_cast( painter->GetSettings() ); - settings->LoadDisplayOptions( DisplayOpt ); + settings->LoadDisplayOptions( displ_opts ); view->RecacheAllItems( true ); m_Parent->GetCanvas()->Refresh(); diff --git a/pcbnew/dialogs/dialog_general_options.cpp b/pcbnew/dialogs/dialog_general_options.cpp index d9346fef61..4c66d7e73e 100644 --- a/pcbnew/dialogs/dialog_general_options.cpp +++ b/pcbnew/dialogs/dialog_general_options.cpp @@ -63,9 +63,10 @@ void DIALOG_GENERALOPTIONS::init() m_sdbSizerOK->SetDefault(); m_Board = GetParent()->GetBoard(); + DISPLAY_OPTIONS* displ_opts = (DISPLAY_OPTIONS*)GetParent()->GetDisplayOptions(); /* Set display options */ - m_PolarDisplay->SetSelection( DisplayOpt.DisplayPolarCood ? 1 : 0 ); + m_PolarDisplay->SetSelection( displ_opts->m_DisplayPolarCood ? 1 : 0 ); m_UnitsSelection->SetSelection( g_UserUnit ? 1 : 0 ); m_CursorShape->SetSelection( GetParent()->GetCursorShape() ? 1 : 0 ); @@ -77,10 +78,10 @@ void DIALOG_GENERALOPTIONS::init() wxString timevalue; timevalue << GetParent()->GetAutoSaveInterval() / 60; m_SaveTime->SetValue( timevalue ); - m_MaxShowLinks->SetValue( g_MaxLinksShowed ); + m_MaxShowLinks->SetValue( displ_opts->m_MaxLinksShowed ); m_DrcOn->SetValue( g_Drc_On ); - m_ShowModuleRatsnest->SetValue( g_Show_Module_Ratsnest ); + m_ShowModuleRatsnest->SetValue( displ_opts->m_Show_Module_Ratsnest ); m_ShowGlobalRatsnest->SetValue( m_Board->IsElementVisible( RATSNEST_VISIBLE ) ); m_TrackAutodel->SetValue( g_AutoDeleteOldTrack ); m_Track_45_Only_Ctrl->SetValue( g_Track_45_Only_Allowed ); @@ -106,8 +107,9 @@ void DIALOG_GENERALOPTIONS::OnCancelClick( wxCommandEvent& event ) void DIALOG_GENERALOPTIONS::OnOkClick( wxCommandEvent& event ) { EDA_UNITS_T ii; + DISPLAY_OPTIONS* displ_opts = (DISPLAY_OPTIONS*)GetParent()->GetDisplayOptions(); - DisplayOpt.DisplayPolarCood = ( m_PolarDisplay->GetSelection() == 0 ) ? false : true; + displ_opts->m_DisplayPolarCood = ( m_PolarDisplay->GetSelection() == 0 ) ? false : true; ii = g_UserUnit; g_UserUnit = ( m_UnitsSelection->GetSelection() == 0 ) ? INCHES : MILLIMETRES; @@ -119,7 +121,7 @@ void DIALOG_GENERALOPTIONS::OnOkClick( wxCommandEvent& event ) GetParent()->SetRotationAngle( wxRound( 10.0 * wxAtof( m_RotationAngle->GetValue() ) ) ); /* Updating the combobox to display the active layer. */ - g_MaxLinksShowed = m_MaxShowLinks->GetValue(); + displ_opts->m_MaxLinksShowed = m_MaxShowLinks->GetValue(); g_Drc_On = m_DrcOn->GetValue(); if( m_Board->IsElementVisible(RATSNEST_VISIBLE) != m_ShowGlobalRatsnest->GetValue() ) @@ -128,7 +130,7 @@ void DIALOG_GENERALOPTIONS::OnOkClick( wxCommandEvent& event ) GetParent()->GetCanvas()->Refresh( ); } - g_Show_Module_Ratsnest = m_ShowModuleRatsnest->GetValue(); + displ_opts->m_Show_Module_Ratsnest = m_ShowModuleRatsnest->GetValue(); g_AutoDeleteOldTrack = m_TrackAutodel->GetValue(); g_Segments_45_Only = m_Segments_45_Only_Ctrl->GetValue(); g_Track_45_Only_Allowed = m_Track_45_Only_Ctrl->GetValue(); @@ -153,6 +155,7 @@ void PCB_EDIT_FRAME::OnSelectOptionToolbar( wxCommandEvent& event ) { int id = event.GetId(); bool state = event.IsChecked(); + DISPLAY_OPTIONS* displ_opts = (DISPLAY_OPTIONS*)GetDisplayOptions(); switch( id ) { @@ -178,7 +181,7 @@ void PCB_EDIT_FRAME::OnSelectOptionToolbar( wxCommandEvent& event ) break; case ID_TB_OPTIONS_SHOW_MODULE_RATSNEST: - g_Show_Module_Ratsnest = state; // TODO: use the visibility list + displ_opts->m_Show_Module_Ratsnest = state; // TODO: see if we can use the visibility list break; case ID_TB_OPTIONS_AUTO_DEL_TRACK: @@ -186,33 +189,33 @@ void PCB_EDIT_FRAME::OnSelectOptionToolbar( wxCommandEvent& event ) break; case ID_TB_OPTIONS_SHOW_ZONES: - DisplayOpt.DisplayZonesMode = 0; + displ_opts->m_DisplayZonesMode = 0; m_canvas->Refresh(); break; case ID_TB_OPTIONS_SHOW_ZONES_DISABLE: - DisplayOpt.DisplayZonesMode = 1; + displ_opts->m_DisplayZonesMode = 1; m_canvas->Refresh(); break; case ID_TB_OPTIONS_SHOW_ZONES_OUTLINES_ONLY: - DisplayOpt.DisplayZonesMode = 2; + displ_opts->m_DisplayZonesMode = 2; m_canvas->Refresh(); break; case ID_TB_OPTIONS_SHOW_VIAS_SKETCH: - m_DisplayViaFill = DisplayOpt.DisplayViaFill = !state; + displ_opts->m_DisplayViaFill = !state; m_canvas->Refresh(); break; case ID_TB_OPTIONS_SHOW_TRACKS_SKETCH: - m_DisplayPcbTrackFill = DisplayOpt.DisplayPcbTrackFill = !state; + displ_opts->m_DisplayPcbTrackFill = !state; m_canvas->Refresh(); break; case ID_TB_OPTIONS_SHOW_HIGH_CONTRAST_MODE: { - DisplayOpt.ContrastModeDisplay = state; + displ_opts->m_ContrastModeDisplay = state; m_canvas->Refresh(); break; } diff --git a/pcbnew/dialogs/dialog_pad_properties_base.cpp b/pcbnew/dialogs/dialog_pad_properties_base.cpp index d4386af6fc..0550e54d97 100644 --- a/pcbnew/dialogs/dialog_pad_properties_base.cpp +++ b/pcbnew/dialogs/dialog_pad_properties_base.cpp @@ -1,5 +1,5 @@ /////////////////////////////////////////////////////////////////////////// -// C++ code generated with wxFormBuilder (version Jun 6 2014) +// C++ code generated with wxFormBuilder (version Jun 5 2014) // http://www.wxformbuilder.org/ // // PLEASE DO "NOT" EDIT THIS FILE! @@ -531,6 +531,7 @@ DIALOG_PAD_PROPERTIES_BASE::DIALOG_PAD_PROPERTIES_BASE( wxWindow* parent, wxWind wxBoxSizer* bSizerDisplayPad; bSizerDisplayPad = new wxBoxSizer( wxVERTICAL ); + bSizerDisplayPad->SetMinSize( wxSize( 100,-1 ) ); m_panelShowPad = new wxPanel( this, wxID_ANY, wxDefaultPosition, wxSize( 200,200 ), wxFULL_REPAINT_ON_RESIZE|wxSIMPLE_BORDER ); m_panelShowPad->SetBackgroundColour( wxColour( 0, 0, 0 ) ); diff --git a/pcbnew/dialogs/dialog_pad_properties_base.fbp b/pcbnew/dialogs/dialog_pad_properties_base.fbp index e68730ff2f..39cf87be6a 100644 --- a/pcbnew/dialogs/dialog_pad_properties_base.fbp +++ b/pcbnew/dialogs/dialog_pad_properties_base.fbp @@ -8228,7 +8228,7 @@ wxEXPAND|wxTOP|wxBOTTOM 1 - + 100,-1 bSizerDisplayPad wxVERTICAL none diff --git a/pcbnew/dialogs/dialog_pad_properties_base.h b/pcbnew/dialogs/dialog_pad_properties_base.h index 14b57ce29d..7a2cca8b57 100644 --- a/pcbnew/dialogs/dialog_pad_properties_base.h +++ b/pcbnew/dialogs/dialog_pad_properties_base.h @@ -1,5 +1,5 @@ /////////////////////////////////////////////////////////////////////////// -// C++ code generated with wxFormBuilder (version Jun 6 2014) +// C++ code generated with wxFormBuilder (version Jun 5 2014) // http://www.wxformbuilder.org/ // // PLEASE DO "NOT" EDIT THIS FILE! diff --git a/pcbnew/edit.cpp b/pcbnew/edit.cpp index d5077f0d25..cc0db92b17 100644 --- a/pcbnew/edit.cpp +++ b/pcbnew/edit.cpp @@ -64,6 +64,7 @@ void PCB_EDIT_FRAME::Process_Special_Functions( wxCommandEvent& event ) INSTALL_UNBUFFERED_DC( dc, m_canvas ); MODULE* module; + DISPLAY_OPTIONS* displ_opts = (DISPLAY_OPTIONS*)GetDisplayOptions(); m_canvas->CrossHairOff( &dc ); @@ -442,7 +443,7 @@ void PCB_EDIT_FRAME::Process_Special_Functions( wxCommandEvent& event ) settings.m_CurrentViaType = v_type; - if( DisplayOpt.ContrastModeDisplay ) + if( displ_opts->m_ContrastModeDisplay ) m_canvas->Refresh(); } break; @@ -967,7 +968,7 @@ void PCB_EDIT_FRAME::Process_Special_Functions( wxCommandEvent& event ) { // if user changed colors and we are in high contrast mode, then redraw // because the PAD_SMD pads may change color. - if( DisplayOpt.ContrastModeDisplay && GetActiveLayer() != itmp ) + if( displ_opts->m_ContrastModeDisplay && GetActiveLayer() != itmp ) { m_canvas->Refresh(); } @@ -1010,7 +1011,7 @@ void PCB_EDIT_FRAME::Process_Special_Functions( wxCommandEvent& event ) case ID_TOOLBARH_PCB_SELECT_LAYER: SetActiveLayer( ToLAYER_ID( m_SelLayerBox->GetLayerSelection() ) ); - if( DisplayOpt.ContrastModeDisplay ) + if( displ_opts->m_ContrastModeDisplay ) m_canvas->Refresh( true ); break; @@ -1310,6 +1311,7 @@ void PCB_EDIT_FRAME::RemoveStruct( BOARD_ITEM* Item, wxDC* DC ) void PCB_EDIT_FRAME::SwitchLayer( wxDC* DC, LAYER_ID layer ) { LAYER_ID curLayer = GetActiveLayer(); + DISPLAY_OPTIONS* displ_opts = (DISPLAY_OPTIONS*)GetDisplayOptions(); // Check if the specified layer matches the present layer if( layer == curLayer ) @@ -1354,7 +1356,7 @@ void PCB_EDIT_FRAME::SwitchLayer( wxDC* DC, LAYER_ID layer ) if( Other_Layer_Route( (TRACK*) GetScreen()->GetCurItem(), DC ) ) { - if( DisplayOpt.ContrastModeDisplay ) + if( displ_opts->m_ContrastModeDisplay ) m_canvas->Refresh(); } @@ -1373,7 +1375,7 @@ void PCB_EDIT_FRAME::SwitchLayer( wxDC* DC, LAYER_ID layer ) SetActiveLayer( layer ); - if( DisplayOpt.ContrastModeDisplay ) + if( displ_opts->m_ContrastModeDisplay ) m_canvas->Refresh(); } @@ -1386,6 +1388,7 @@ void PCB_EDIT_FRAME::OnSelectTool( wxCommandEvent& aEvent ) return; INSTALL_UNBUFFERED_DC( dc, m_canvas ); + DISPLAY_OPTIONS* displ_opts = (DISPLAY_OPTIONS*)GetDisplayOptions(); // Stop the current command and deselect the current tool. m_canvas->EndMouseCapture( ID_NO_TOOL_SELECTED, m_canvas->GetDefaultCursor() ); @@ -1416,7 +1419,7 @@ void PCB_EDIT_FRAME::OnSelectTool( wxCommandEvent& aEvent ) case ID_PCB_ZONES_BUTT: SetToolID( id, wxCURSOR_PENCIL, _( "Add zones" ) ); - if( DisplayOpt.DisplayZonesMode != 0 ) + if( displ_opts->m_DisplayZonesMode != 0 ) DisplayInfoMessage( this, _( "Warning: zone display is OFF!!!" ) ); if( !GetBoard()->IsHighLightNetON() && (GetBoard()->GetHighLightNetCode() > 0 ) ) diff --git a/pcbnew/editedge.cpp b/pcbnew/editedge.cpp index 52b3f3c846..e5375b75e7 100644 --- a/pcbnew/editedge.cpp +++ b/pcbnew/editedge.cpp @@ -113,7 +113,8 @@ static void Move_Segment( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint& aPos void PCB_EDIT_FRAME::Delete_Segment_Edge( DRAWSEGMENT* Segment, wxDC* DC ) { EDA_ITEM* PtStruct; - int track_fill_copy = DisplayOpt.DisplayDrawItems; + DISPLAY_OPTIONS* displ_opts = (DISPLAY_OPTIONS*)GetDisplayOptions(); + int tmp = displ_opts->m_DisplayDrawItems; if( Segment == NULL ) return; @@ -121,7 +122,7 @@ void PCB_EDIT_FRAME::Delete_Segment_Edge( DRAWSEGMENT* Segment, wxDC* DC ) if( Segment->IsNew() ) // Trace in progress. { // Delete current segment. - DisplayOpt.DisplayDrawItems = SKETCH; + displ_opts->m_DisplayDrawItems = SKETCH; Segment->Draw( m_canvas, DC, GR_XOR ); PtStruct = Segment->Back(); Segment ->DeleteStructure(); @@ -129,7 +130,7 @@ void PCB_EDIT_FRAME::Delete_Segment_Edge( DRAWSEGMENT* Segment, wxDC* DC ) if( PtStruct && (PtStruct->Type() == PCB_LINE_T ) ) Segment = (DRAWSEGMENT*) PtStruct; - DisplayOpt.DisplayDrawItems = track_fill_copy; + displ_opts->m_DisplayDrawItems = tmp; SetCurItem( NULL ); } else if( Segment->GetFlags() == 0 ) @@ -334,13 +335,14 @@ void PCB_EDIT_FRAME::End_Edge( DRAWSEGMENT* Segment, wxDC* DC ) */ static void DrawSegment( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint& aPosition, bool aErase ) { + DISPLAY_OPTIONS* displ_opts = (DISPLAY_OPTIONS*)aPanel->GetDisplayOptions(); DRAWSEGMENT* Segment = (DRAWSEGMENT*) aPanel->GetScreen()->GetCurItem(); - int t_fill = DisplayOpt.DisplayDrawItems; + int tmp = displ_opts->m_DisplayDrawItems; if( Segment == NULL ) return; - DisplayOpt.DisplayDrawItems = SKETCH; + displ_opts->m_DisplayDrawItems = SKETCH; if( aErase ) Segment->Draw( aPanel, aDC, GR_XOR ); @@ -360,5 +362,5 @@ static void DrawSegment( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint& aPosi } Segment->Draw( aPanel, aDC, GR_XOR ); - DisplayOpt.DisplayDrawItems = t_fill; + displ_opts->m_DisplayDrawItems = tmp; } diff --git a/pcbnew/editrack.cpp b/pcbnew/editrack.cpp index 309e7e9c5d..d556096df6 100644 --- a/pcbnew/editrack.cpp +++ b/pcbnew/editrack.cpp @@ -677,10 +677,11 @@ void ShowNewTrackWhenMovingCursor( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPo PCB_SCREEN* screen = (PCB_SCREEN*) aPanel->GetScreen(); PCB_BASE_FRAME* frame = (PCB_BASE_FRAME*) aPanel->GetParent(); + DISPLAY_OPTIONS* displ_opts = (DISPLAY_OPTIONS*) aPanel->GetDisplayOptions(); - bool Track_fill_copy = DisplayOpt.DisplayPcbTrackFill; - DisplayOpt.DisplayPcbTrackFill = true; - TRACE_CLEARANCE_DISPLAY_MODE_T showTrackClearanceMode = DisplayOpt.ShowTrackClearanceMode; + bool tmp = displ_opts->m_DisplayPcbTrackFill; + displ_opts->m_DisplayPcbTrackFill = true; + TRACE_CLEARANCE_DISPLAY_MODE_T showTrackClearanceMode = displ_opts->m_ShowTrackClearanceMode; if ( g_FirstTrackSegment == NULL ) return; @@ -688,7 +689,7 @@ void ShowNewTrackWhenMovingCursor( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPo NETCLASSPTR netclass = g_FirstTrackSegment->GetNetClass(); if( showTrackClearanceMode != DO_NOT_SHOW_CLEARANCE ) - DisplayOpt.ShowTrackClearanceMode = SHOW_CLEARANCE_ALWAYS; + displ_opts->m_ShowTrackClearanceMode = SHOW_CLEARANCE_ALWAYS; // Values to Via circle int boardViaRadius = frame->GetDesignSettings().GetCurrentViaSize()/2; @@ -824,8 +825,8 @@ void ShowNewTrackWhenMovingCursor( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPo msg.Printf( wxT( "%d" ), g_CurrentTrackList.GetCount() ); frame->AppendMsgPanel( _( "Segs Count" ), msg, DARKCYAN ); - DisplayOpt.ShowTrackClearanceMode = showTrackClearanceMode; - DisplayOpt.DisplayPcbTrackFill = Track_fill_copy; + displ_opts->m_ShowTrackClearanceMode = showTrackClearanceMode; + displ_opts->m_DisplayPcbTrackFill = tmp; frame->BuildAirWiresTargetsList( NULL, g_CurrentTrackSegment->GetEnd(), false ); frame->TraceAirWiresToTargets( aDC ); diff --git a/pcbnew/files.cpp b/pcbnew/files.cpp index 4d8be1e126..73e4dc4de7 100644 --- a/pcbnew/files.cpp +++ b/pcbnew/files.cpp @@ -530,13 +530,6 @@ bool PCB_EDIT_FRAME::OpenProjectFiles( const std::vector& aFileSet, in } } - // Update the option toolbar - m_DisplayPcbTrackFill = DisplayOpt.DisplayPcbTrackFill; - m_DisplayModText = DisplayOpt.DisplayModText; - m_DisplayModEdge = DisplayOpt.DisplayModEdge; - m_DisplayPadFill = DisplayOpt.DisplayPadFill; - m_DisplayViaFill = DisplayOpt.DisplayViaFill; - { wxFileName fn = fullFileName; diff --git a/pcbnew/hotkeys_board_editor.cpp b/pcbnew/hotkeys_board_editor.cpp index 5682dd770c..02ecf4ff58 100644 --- a/pcbnew/hotkeys_board_editor.cpp +++ b/pcbnew/hotkeys_board_editor.cpp @@ -118,6 +118,7 @@ bool PCB_EDIT_FRAME::OnHotKey( wxDC* aDC, int aHotkeyCode, const wxPoint& aPosit MODULE* module = NULL; int evt_type = 0; //Used to post a wxCommandEvent on demand PCB_SCREEN* screen = GetScreen(); + DISPLAY_OPTIONS* displ_opts = (DISPLAY_OPTIONS*)GetDisplayOptions(); /* Convert lower to upper case * (the usual toupper function has problem with non ascii codes like function keys @@ -362,8 +363,7 @@ bool PCB_EDIT_FRAME::OnHotKey( wxDC* aDC, int aHotkeyCode, const wxPoint& aPosit break; case HK_SWITCH_TRACK_DISPLAY_MODE: - DisplayOpt.DisplayPcbTrackFill = !DisplayOpt.DisplayPcbTrackFill; - m_DisplayPcbTrackFill = DisplayOpt.DisplayPcbTrackFill; + displ_opts->m_DisplayPcbTrackFill = !displ_opts->m_DisplayPcbTrackFill; m_canvas->Refresh(); break; @@ -457,7 +457,7 @@ bool PCB_EDIT_FRAME::OnHotKey( wxDC* aDC, int aHotkeyCode, const wxPoint& aPosit if( !itemCurrentlyEdited ) // no track in progress: switch layer only { Other_Layer_Route( NULL, aDC ); - if( DisplayOpt.ContrastModeDisplay ) + if( displ_opts->m_ContrastModeDisplay ) m_canvas->Refresh(); break; } @@ -552,7 +552,7 @@ bool PCB_EDIT_FRAME::OnHotKey( wxDC* aDC, int aHotkeyCode, const wxPoint& aPosit break; case HK_SWITCH_HIGHCONTRAST_MODE: // switch to high contrast mode and refresh the canvas - DisplayOpt.ContrastModeDisplay = !DisplayOpt.ContrastModeDisplay; + displ_opts->m_ContrastModeDisplay = !displ_opts->m_ContrastModeDisplay; m_canvas->Refresh(); break; diff --git a/pcbnew/modeditoptions.cpp b/pcbnew/modeditoptions.cpp index 97a24151bc..2134d2a304 100644 --- a/pcbnew/modeditoptions.cpp +++ b/pcbnew/modeditoptions.cpp @@ -1,7 +1,7 @@ /* * This program source code file is part of KiCad, a free EDA CAD application. * - * Copyright (C) 2012 Jean-Pierre Charras, jean-pierre.charras@ujf-grenoble.fr + * Copyright (C) 2015 Jean-Pierre Charras, jp.charras at wanadoo.fr * Copyright (C) 2012 SoftPLC Corporation, Dick Hollenbeck * Copyright (C) 2012 Wayne Stambaugh * Copyright (C) 1992-2012 KiCad Developers, see AUTHORS.txt for contributors. @@ -31,46 +31,50 @@ #include #include -#include #include #include #include +#include #include -#include - void FOOTPRINT_EDIT_FRAME::OnSelectOptionToolbar( wxCommandEvent& event ) { int id = event.GetId(); + DISPLAY_OPTIONS* displ_opts = (DISPLAY_OPTIONS*)GetDisplayOptions(); + bool state = m_optionsToolBar->GetToolToggled( id ); switch( id ) { case ID_TB_OPTIONS_SHOW_PADS_SKETCH: - m_DisplayPadFill = !m_optionsToolBar->GetToolToggled( id ); + displ_opts->m_DisplayPadFill = !state; m_canvas->Refresh( ); break; case ID_TB_OPTIONS_SHOW_VIAS_SKETCH: - m_DisplayViaFill = !m_optionsToolBar->GetToolToggled( id ); + displ_opts->m_DisplayViaFill = !state; m_canvas->Refresh( ); break; case ID_TB_OPTIONS_SHOW_MODULE_TEXT_SKETCH: - m_DisplayModText = m_optionsToolBar->GetToolToggled( id ) ? SKETCH : FILLED; + displ_opts->m_DisplayModText = state ? SKETCH : FILLED; m_canvas->Refresh( ); break; case ID_TB_OPTIONS_SHOW_MODULE_EDGE_SKETCH: - m_DisplayModEdge = m_optionsToolBar->GetToolToggled( id ) ? SKETCH : FILLED; + displ_opts->m_DisplayModEdge = state ? SKETCH : FILLED; + m_canvas->Refresh( ); + break; + + case ID_TB_OPTIONS_SHOW_HIGH_CONTRAST_MODE: + displ_opts->m_ContrastModeDisplay = state; m_canvas->Refresh( ); break; default: - DisplayError( this, - wxT( "FOOTPRINT_EDIT_FRAME::OnSelectOptionToolbar error" ) ); + wxMessageBox( wxT( "FOOTPRINT_EDIT_FRAME::OnSelectOptionToolbar error" ) ); break; } } diff --git a/pcbnew/moduleframe.cpp b/pcbnew/moduleframe.cpp index 9664c4ffda..7682d00e2d 100644 --- a/pcbnew/moduleframe.cpp +++ b/pcbnew/moduleframe.cpp @@ -113,6 +113,7 @@ BEGIN_EVENT_TABLE( FOOTPRINT_EDIT_FRAME, PCB_BASE_FRAME ) EVT_TOOL( ID_TB_OPTIONS_SHOW_VIAS_SKETCH, FOOTPRINT_EDIT_FRAME::OnSelectOptionToolbar ) EVT_TOOL( ID_TB_OPTIONS_SHOW_MODULE_TEXT_SKETCH, FOOTPRINT_EDIT_FRAME::OnSelectOptionToolbar ) EVT_TOOL( ID_TB_OPTIONS_SHOW_MODULE_EDGE_SKETCH, FOOTPRINT_EDIT_FRAME::OnSelectOptionToolbar ) + EVT_TOOL( ID_TB_OPTIONS_SHOW_HIGH_CONTRAST_MODE, FOOTPRINT_EDIT_FRAME::OnSelectOptionToolbar ) // popup commands EVT_MENU_RANGE( ID_POPUP_PCB_START_RANGE, ID_POPUP_PCB_END_RANGE, @@ -160,6 +161,8 @@ BEGIN_EVENT_TABLE( FOOTPRINT_EDIT_FRAME, PCB_BASE_FRAME ) EVT_UPDATE_UI( ID_NO_TOOL_SELECTED, FOOTPRINT_EDIT_FRAME::OnUpdateVerticalToolbar ) EVT_UPDATE_UI_RANGE( ID_MODEDIT_PAD_TOOL, ID_MODEDIT_PLACE_GRID_COORD, FOOTPRINT_EDIT_FRAME::OnUpdateVerticalToolbar ) + EVT_UPDATE_UI( ID_TB_OPTIONS_SHOW_HIGH_CONTRAST_MODE, + FOOTPRINT_EDIT_FRAME::OnUpdateVerticalToolbar ) EVT_UPDATE_UI( ID_GEN_IMPORT_DXF_FILE, FOOTPRINT_EDIT_FRAME::OnUpdateModuleSelected ) @@ -193,6 +196,11 @@ FOOTPRINT_EDIT_FRAME::FOOTPRINT_EDIT_FRAME( KIWAY* aKiway, wxWindow* aParent ) : SetGalCanvas( drawPanel ); SetBoard( new BOARD() ); + // In modedit, the default net clearance is not known. + // (it depends on the actual board) + // So we do not show the default clearance, by setting it to 0 + // The footprint or pad specific clearance will be shown + GetBoard()->GetDesignSettings().GetDefault()->SetClearance(0); // restore the last footprint from the project, if any restoreLastFootprint(); diff --git a/pcbnew/modules.cpp b/pcbnew/modules.cpp index 0c6efb96e6..0f7393cfa4 100644 --- a/pcbnew/modules.cpp +++ b/pcbnew/modules.cpp @@ -387,7 +387,9 @@ void PCB_BASE_FRAME::PlaceModule( MODULE* aModule, wxDC* aDC, bool aDoNotRecreat s_PickedList.ClearItemsList(); } - if( g_Show_Module_Ratsnest && ( GetBoard()->m_Status_Pcb & LISTE_PAD_OK ) && aDC ) + DISPLAY_OPTIONS* displ_opts = (DISPLAY_OPTIONS*)GetDisplayOptions(); + + if( displ_opts->m_Show_Module_Ratsnest && ( GetBoard()->m_Status_Pcb & LISTE_PAD_OK ) && aDC ) TraceModuleRatsNest( aDC ); newpos = GetCrossHairPosition(); @@ -506,19 +508,20 @@ void DrawModuleOutlines( EDA_DRAW_PANEL* panel, wxDC* DC, MODULE* module ) return; module->DrawEdgesOnly( panel, DC, g_Offset_Module, GR_XOR ); + DISPLAY_OPTIONS* displ_opts = (DISPLAY_OPTIONS*)panel->GetDisplayOptions(); // Show pads in sketch mode to speedu up drawings - pad_fill_tmp = DisplayOpt.DisplayPadFill; - DisplayOpt.DisplayPadFill = true; + pad_fill_tmp = displ_opts->m_DisplayPadFill; + displ_opts->m_DisplayPadFill = true; pt_pad = module->Pads(); for( ; pt_pad != NULL; pt_pad = pt_pad->Next() ) pt_pad->Draw( panel, DC, GR_XOR, g_Offset_Module ); - DisplayOpt.DisplayPadFill = pad_fill_tmp; + displ_opts->m_DisplayPadFill = pad_fill_tmp; - if( g_Show_Module_Ratsnest && panel ) + if( displ_opts->m_Show_Module_Ratsnest && panel ) { PCB_BASE_FRAME* frame = (PCB_BASE_FRAME*) panel->GetParent(); frame->build_ratsnest_module( module ); diff --git a/pcbnew/modview_frame.cpp b/pcbnew/modview_frame.cpp index ba7a7aeebd..d11e85ab4e 100644 --- a/pcbnew/modview_frame.cpp +++ b/pcbnew/modview_frame.cpp @@ -30,14 +30,12 @@ #include #include #include -#include #include #include #include #include <3d_viewer.h> #include #include -#include #include #include #include @@ -133,6 +131,10 @@ FOOTPRINT_VIEWER_FRAME::FOOTPRINT_VIEWER_FRAME( KIWAY* aKiway, wxWindow* aParent wxDefaultPosition, wxDefaultSize, 0, NULL, wxLB_HSCROLL ); SetBoard( new BOARD() ); + // In viewer, the default net clearance is not known (it depends on the actual board). + // So we do not show the default clearance, by setting it to 0 + // The footprint or pad specific clearance will be shown + GetBoard()->GetDesignSettings().GetDefault()->SetClearance(0); // Ensure all layers and items are visible: GetBoard()->SetVisibleAlls(); diff --git a/pcbnew/move_or_drag_track.cpp b/pcbnew/move_or_drag_track.cpp index 6c93577c0f..8510540600 100644 --- a/pcbnew/move_or_drag_track.cpp +++ b/pcbnew/move_or_drag_track.cpp @@ -103,11 +103,12 @@ static void Abort_MoveTrack( EDA_DRAW_PANEL* aPanel, wxDC* aDC ) static void Show_MoveNode( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint& aPosition, bool aErase ) { + DISPLAY_OPTIONS* displ_opts = (DISPLAY_OPTIONS*) aPanel->GetDisplayOptions(); wxPoint moveVector; - int tmp = DisplayOpt.DisplayPcbTrackFill; + int tmp = displ_opts->m_DisplayPcbTrackFill; GR_DRAWMODE draw_mode = GR_XOR | GR_HIGHLIGHT; - DisplayOpt.DisplayPcbTrackFill = false; + displ_opts->m_DisplayPcbTrackFill = false; #ifndef USE_WX_OVERLAY aErase = true; @@ -142,7 +143,7 @@ static void Show_MoveNode( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint& aPo track->Draw( aPanel, aDC, draw_mode ); } - DisplayOpt.DisplayPcbTrackFill = tmp; + displ_opts->m_DisplayPcbTrackFill = tmp; // Display track length if( track ) diff --git a/pcbnew/pcb_draw_panel_gal.cpp b/pcbnew/pcb_draw_panel_gal.cpp index bb7ce1bae5..3e05f6af1b 100644 --- a/pcbnew/pcb_draw_panel_gal.cpp +++ b/pcbnew/pcb_draw_panel_gal.cpp @@ -33,6 +33,7 @@ #include #include #include +#include #include @@ -148,8 +149,16 @@ EDA_DRAW_PANEL_GAL( aParentWindow, aWindowId, aPosition, aSize, aGalType ) m_view->SetLayerTarget( ITEM_GAL_LAYER( GP_OVERLAY ), KIGFX::TARGET_OVERLAY ); m_view->SetLayerTarget( ITEM_GAL_LAYER( RATSNEST_VISIBLE ), KIGFX::TARGET_OVERLAY ); - // Load display options (such as filled/outline display of items) - static_cast( m_view->GetPainter()->GetSettings() )->LoadDisplayOptions( DisplayOpt ); + // Load display options (such as filled/outline display of items). + // Can be made only if the parent windos is a EDA_DRAW_FRAME (or a derived class) + // which is not always the case (namely when it is used from a wxDialog like the pad editor) + EDA_DRAW_FRAME* frame = dynamic_cast ( aParentWindow ); + + if( frame ) + { + DISPLAY_OPTIONS* displ_opts = (DISPLAY_OPTIONS*) frame->GetDisplayOptions(); + static_cast( m_view->GetPainter()->GetSettings() )->LoadDisplayOptions( displ_opts ); + } } @@ -198,7 +207,16 @@ void PCB_DRAW_PANEL_GAL::DisplayBoard( const BOARD* aBoard ) m_view->Add( m_ratsnest ); UseColorScheme( aBoard->GetColorsSettings() ); - static_cast( m_view->GetPainter()->GetSettings() )->LoadDisplayOptions( DisplayOpt ); + + // We are expecting here the parent frame is a EDA_DRAW_FRAME or a derived class + // (usually a BASE_PCB_FRAME, PCB_EDIT_FRAME ...) + EDA_DRAW_FRAME* frame = dynamic_cast ( GetParent() ); + + if( frame ) + { + DISPLAY_OPTIONS* displ_opts = (DISPLAY_OPTIONS*) frame->GetDisplayOptions(); + static_cast( m_view->GetPainter()->GetSettings() )->LoadDisplayOptions( displ_opts ); + } m_view->RecacheAllItems( true ); } diff --git a/pcbnew/pcb_painter.cpp b/pcbnew/pcb_painter.cpp index b83fab28f8..3eeb7c06a7 100644 --- a/pcbnew/pcb_painter.cpp +++ b/pcbnew/pcb_painter.cpp @@ -98,19 +98,22 @@ void PCB_RENDER_SETTINGS::ImportLegacyColors( const COLORS_DESIGN_SETTINGS* aSet } -void PCB_RENDER_SETTINGS::LoadDisplayOptions( const DISPLAY_OPTIONS& aOptions ) +void PCB_RENDER_SETTINGS::LoadDisplayOptions( const DISPLAY_OPTIONS* aOptions ) { - m_hiContrastEnabled = aOptions.ContrastModeDisplay; - m_padNumbers = aOptions.DisplayPadNum; + if( aOptions == NULL ) + return; + + m_hiContrastEnabled = aOptions->m_ContrastModeDisplay; + m_padNumbers = aOptions->m_DisplayPadNum; // Whether to draw tracks, vias & pads filled or as outlines - m_sketchMode[ITEM_GAL_LAYER( PADS_VISIBLE )] = !aOptions.DisplayPadFill; - m_sketchMode[ITEM_GAL_LAYER( VIA_THROUGH_VISIBLE )] = !aOptions.DisplayViaFill; - m_sketchMode[ITEM_GAL_LAYER( VIA_BBLIND_VISIBLE )] = !aOptions.DisplayViaFill; - m_sketchMode[ITEM_GAL_LAYER( VIA_MICROVIA_VISIBLE )] = !aOptions.DisplayViaFill; - m_sketchMode[ITEM_GAL_LAYER( TRACKS_VISIBLE )] = !aOptions.DisplayPcbTrackFill; + m_sketchMode[ITEM_GAL_LAYER( PADS_VISIBLE )] = !aOptions->m_DisplayPadFill; + m_sketchMode[ITEM_GAL_LAYER( VIA_THROUGH_VISIBLE )] = !aOptions->m_DisplayViaFill; + m_sketchMode[ITEM_GAL_LAYER( VIA_BBLIND_VISIBLE )] = !aOptions->m_DisplayViaFill; + m_sketchMode[ITEM_GAL_LAYER( VIA_MICROVIA_VISIBLE )] = !aOptions->m_DisplayViaFill; + m_sketchMode[ITEM_GAL_LAYER( TRACKS_VISIBLE )] = !aOptions->m_DisplayPcbTrackFill; - switch( aOptions.DisplayNetNamesMode ) + switch( aOptions->m_DisplayNetNamesMode ) { case 0: m_netNamesOnPads = false; @@ -133,7 +136,7 @@ void PCB_RENDER_SETTINGS::LoadDisplayOptions( const DISPLAY_OPTIONS& aOptions ) break; } - switch( aOptions.DisplayZonesMode ) + switch( aOptions->m_DisplayZonesMode ) { case 0: m_displayZoneMode = DZ_SHOW_FILLED; diff --git a/pcbnew/pcb_painter.h b/pcbnew/pcb_painter.h index d2487d66eb..c6ea211a21 100644 --- a/pcbnew/pcb_painter.h +++ b/pcbnew/pcb_painter.h @@ -87,7 +87,7 @@ public: * for vias/pads/tracks and so on). * @param aOptions are settings that you want to use for displaying items. */ - void LoadDisplayOptions( const DISPLAY_OPTIONS& aOptions ); + void LoadDisplayOptions( const DISPLAY_OPTIONS* aOptions ); /// @copydoc RENDER_SETTINGS::GetColor() virtual const COLOR4D& GetColor( const VIEW_ITEM* aItem, int aLayer ) const; diff --git a/pcbnew/pcbframe.cpp b/pcbnew/pcbframe.cpp index eb3d2daced..1acb59a136 100644 --- a/pcbnew/pcbframe.cpp +++ b/pcbnew/pcbframe.cpp @@ -370,15 +370,6 @@ PCB_EDIT_FRAME::PCB_EDIT_FRAME( KIWAY* aKiway, wxWindow* aParent ) : // initialize parameters in m_LayersManager LoadSettings( config() ); - // Be sure options are updated - m_DisplayPcbTrackFill = DisplayOpt.DisplayPcbTrackFill; - m_DisplayPadFill = DisplayOpt.DisplayPadFill; - m_DisplayViaFill = DisplayOpt.DisplayViaFill; - m_DisplayPadNum = DisplayOpt.DisplayPadNum; - - m_DisplayModEdge = DisplayOpt.DisplayModEdge; - m_DisplayModText = DisplayOpt.DisplayModText; - SetSize( m_FramePos.x, m_FramePos.y, m_FrameSize.x, m_FrameSize.y ); GetScreen()->AddGrid( m_UserGridSize, m_UserGridUnit, ID_POPUP_GRID_USER ); diff --git a/pcbnew/pcbnew.cpp b/pcbnew/pcbnew.cpp index 9049f42daa..6bd12c4cbb 100644 --- a/pcbnew/pcbnew.cpp +++ b/pcbnew/pcbnew.cpp @@ -65,7 +65,6 @@ COLORS_DESIGN_SETTINGS g_ColorsSettings; bool g_Drc_On = true; bool g_AutoDeleteOldTrack = true; -bool g_Show_Module_Ratsnest; bool g_Raccord_45_Auto = true; bool g_Alternate_Track_Posture = false; bool g_Track_45_Only_Allowed = true; // True to allow horiz, vert. and 45deg only tracks @@ -74,14 +73,11 @@ bool g_TwoSegmentTrackBuild = true; LAYER_ID g_Route_Layer_TOP; LAYER_ID g_Route_Layer_BOTTOM; -int g_MaxLinksShowed; int g_MagneticPadOption = capture_cursor_in_track_tool; int g_MagneticTrackOption = capture_cursor_in_track_tool; wxPoint g_Offset_Module; // module offset used when moving a footprint -DISPLAY_OPTIONS DisplayOpt; // General display options - /* Name of the document footprint list * usually located in share/modules/footprints_doc * this is of the responsibility to users to create this file diff --git a/pcbnew/pcbnew.h b/pcbnew/pcbnew.h index e8af07ede8..32329d727e 100644 --- a/pcbnew/pcbnew.h +++ b/pcbnew/pcbnew.h @@ -79,7 +79,6 @@ extern wxString g_DocModulesFileName; // variables extern bool g_Drc_On; extern bool g_AutoDeleteOldTrack; -extern bool g_Show_Module_Ratsnest; extern bool g_Raccord_45_Auto; extern bool g_Track_45_Only_Allowed; extern bool g_Alternate_Track_Posture; @@ -89,7 +88,6 @@ extern bool g_Segments_45_Only; extern LAYER_ID g_Route_Layer_TOP; extern LAYER_ID g_Route_Layer_BOTTOM; -extern int g_MaxLinksShowed; // Max count links showed in routing extern bool g_TwoSegmentTrackBuild; extern int g_MagneticPadOption; @@ -104,9 +102,6 @@ extern DLIST g_CurrentTrackList; #define g_FirstTrackSegment g_CurrentTrackList.GetFirst() ///< first segment created -class DISPLAY_OPTIONS; -extern DISPLAY_OPTIONS DisplayOpt; - enum MagneticPadOptionValues { no_effect, capture_cursor_in_track_tool, diff --git a/pcbnew/pcbnew_config.cpp b/pcbnew/pcbnew_config.cpp index 3443e3bc05..95fbb6e635 100644 --- a/pcbnew/pcbnew_config.cpp +++ b/pcbnew/pcbnew_config.cpp @@ -322,6 +322,8 @@ PARAM_CFG_ARRAY PCB_EDIT_FRAME::GetProjectFileParameters() PARAM_CFG_ARRAY& PCB_EDIT_FRAME::GetConfigurationSettings() { + DISPLAY_OPTIONS* displ_opts = (DISPLAY_OPTIONS*)GetDisplayOptions(); + if( m_configSettings.empty() ) { COLORS_DESIGN_SETTINGS cds; // constructor fills this with sensible colors @@ -331,35 +333,35 @@ PARAM_CFG_ARRAY& PCB_EDIT_FRAME::GetConfigurationSettings() (int*)&g_UserUnit, MILLIMETRES ) ); m_configSettings.push_back( new PARAM_CFG_BOOL( true, wxT( "DisplayPolarCoords" ), - &DisplayOpt.DisplayPolarCood, false ) ); + &displ_opts->m_DisplayPolarCood, false ) ); // Display options and modes: m_configSettings.push_back( new PARAM_CFG_INT( true, wxT( "ViaHoleDisplayMode" ), - (int*) &DisplayOpt.m_DisplayViaMode, + (int*) &displ_opts->m_DisplayViaMode, VIA_SPECIAL_HOLE_SHOW, VIA_HOLE_NOT_SHOW, OPT_VIA_HOLE_END - 1 ) ); m_configSettings.push_back( new PARAM_CFG_INT( true, wxT( "ShowNetNamesMode" ), - &DisplayOpt.DisplayNetNamesMode, 3, 0, 3 ) ); + &displ_opts->m_DisplayNetNamesMode, 3, 0, 3 ) ); m_configSettings.push_back( new PARAM_CFG_BOOL( true, wxT( "DisplayTrackFilled" ), - &DisplayOpt.DisplayPcbTrackFill, true ) ); + &displ_opts->m_DisplayPcbTrackFill, true ) ); m_configSettings.push_back( new PARAM_CFG_INT( true, wxT( "TrackDisplayClearance" ), - (int*) &DisplayOpt.ShowTrackClearanceMode, + (int*) &displ_opts->m_ShowTrackClearanceMode, SHOW_CLEARANCE_NEW_TRACKS_AND_VIA_AREAS ) ); m_configSettings.push_back( new PARAM_CFG_BOOL( true, wxT( "PadFill" ), - &DisplayOpt.DisplayPadFill, true ) ); + &displ_opts->m_DisplayPadFill, true ) ); m_configSettings.push_back( new PARAM_CFG_BOOL( true, wxT( "ViaFill" ), - &DisplayOpt.DisplayViaFill, true ) ); + &displ_opts->m_DisplayViaFill, true ) ); m_configSettings.push_back( new PARAM_CFG_BOOL( true, wxT( "PadAffG" ), - &DisplayOpt.DisplayPadIsol, true ) ); + &displ_opts->m_DisplayPadIsol, true ) ); m_configSettings.push_back( new PARAM_CFG_BOOL( true, wxT( "PadSNum" ), - &DisplayOpt.DisplayPadNum, true ) ); + &displ_opts->m_DisplayPadNum, true ) ); m_configSettings.push_back( new PARAM_CFG_INT( true, wxT( "ModAffC" ), - &DisplayOpt.DisplayModEdge, FILLED, 0, 2 ) ); + &displ_opts->m_DisplayModEdge, FILLED, 0, 2 ) ); m_configSettings.push_back( new PARAM_CFG_INT( true, wxT( "ModAffT" ), - &DisplayOpt.DisplayModText, FILLED, 0, 2 ) ); + &displ_opts->m_DisplayModText, FILLED, 0, 2 ) ); m_configSettings.push_back( new PARAM_CFG_INT( true, wxT( "PcbAffT" ), - &DisplayOpt.DisplayDrawItems, FILLED, 0, 2 ) ); + &displ_opts->m_DisplayDrawItems, FILLED, 0, 2 ) ); m_configSettings.push_back( new PARAM_CFG_INT( true, wxT( "PcbShowZonesMode" ), - &DisplayOpt.DisplayZonesMode, 0, 0, 2 ) ); + &displ_opts->m_DisplayZonesMode, 0, 0, 2 ) ); // layer colors: wxASSERT( DIM( cds.m_LayersColors ) == LAYER_ID_COUNT ); @@ -406,10 +408,11 @@ PARAM_CFG_ARRAY& PCB_EDIT_FRAME::GetConfigurationSettings() // Miscellaneous: m_configSettings.push_back( new PARAM_CFG_INT( true, wxT( "RotationAngle" ), &m_rotationAngle, 900, 1, 900 ) ); - m_configSettings.push_back( new PARAM_CFG_INT( true, wxT( "MaxLnkS" ), &g_MaxLinksShowed, + m_configSettings.push_back( new PARAM_CFG_INT( true, wxT( "MaxLnkS" ), + &displ_opts->m_MaxLinksShowed, 3, 0, 15 ) ); m_configSettings.push_back( new PARAM_CFG_BOOL( true, wxT( "ShowMRa" ), - &g_Show_Module_Ratsnest, true ) ); + &displ_opts->m_Show_Module_Ratsnest, true ) ); m_configSettings.push_back( new PARAM_CFG_BOOL( true, wxT( "TwoSegT" ), &g_TwoSegmentTrackBuild, true ) ); m_configSettings.push_back( new PARAM_CFG_BOOL( true, wxT( "SegmPcb45Only" ) diff --git a/pcbnew/print_board_functions.cpp b/pcbnew/print_board_functions.cpp index 456e57bfeb..b6e9c705ca 100644 --- a/pcbnew/print_board_functions.cpp +++ b/pcbnew/print_board_functions.cpp @@ -52,6 +52,7 @@ void FOOTPRINT_EDIT_FRAME::PrintPage( wxDC* aDC, { GR_DRAWMODE drawmode = GR_COPY; int defaultPenSize = Millimeter2iu( 0.2 ); + DISPLAY_OPTIONS* displ_opts = (DISPLAY_OPTIONS*)GetDisplayOptions(); DISPLAY_OPTIONS save_opt; @@ -61,25 +62,22 @@ void FOOTPRINT_EDIT_FRAME::PrintPage( wxDC* aDC, if( printParameters ) defaultPenSize = printParameters->m_PenDefaultSize; - save_opt = DisplayOpt; + save_opt = *displ_opts; - DisplayOpt.ContrastModeDisplay = false; - DisplayOpt.DisplayPadFill = true; - DisplayOpt.DisplayViaFill = true; - - m_DisplayPadFill = DisplayOpt.DisplayPadFill; - m_DisplayViaFill = DisplayOpt.DisplayViaFill; - m_DisplayPadNum = DisplayOpt.DisplayPadNum = false; + displ_opts->m_ContrastModeDisplay = false; + displ_opts->m_DisplayPadFill = true; + displ_opts->m_DisplayViaFill = true; + displ_opts->m_DisplayPadNum = false; bool nctmp = GetBoard()->IsElementVisible(NO_CONNECTS_VISIBLE); GetBoard()->SetElementVisibility(NO_CONNECTS_VISIBLE, false); - DisplayOpt.DisplayPadIsol = false; - DisplayOpt.DisplayModEdge = FILLED; - DisplayOpt.DisplayModText = FILLED; - m_DisplayPcbTrackFill = DisplayOpt.DisplayPcbTrackFill = true; - DisplayOpt.ShowTrackClearanceMode = DO_NOT_SHOW_CLEARANCE; - DisplayOpt.DisplayDrawItems = FILLED; - DisplayOpt.DisplayZonesMode = 0; - DisplayOpt.DisplayNetNamesMode = 0; + displ_opts->m_DisplayPadIsol = false; + displ_opts->m_DisplayModEdge = FILLED; + displ_opts->m_DisplayModText = FILLED; + displ_opts->m_DisplayPcbTrackFill = true; + displ_opts->m_ShowTrackClearanceMode = DO_NOT_SHOW_CLEARANCE; + displ_opts->m_DisplayDrawItems = FILLED; + displ_opts->m_DisplayZonesMode = 0; + displ_opts->m_DisplayNetNamesMode = 0; m_canvas->SetPrintMirrored( aPrintMirrorMode ); @@ -109,11 +107,7 @@ void FOOTPRINT_EDIT_FRAME::PrintPage( wxDC* aDC, m_canvas->SetPrintMirrored( false ); - DisplayOpt = save_opt; - m_DisplayPcbTrackFill = DisplayOpt.DisplayPcbTrackFill; - m_DisplayPadFill = DisplayOpt.DisplayPadFill; - m_DisplayViaFill = DisplayOpt.DisplayViaFill; - m_DisplayPadNum = DisplayOpt.DisplayPadNum; + *displ_opts = save_opt; GetBoard()->SetElementVisibility( NO_CONNECTS_VISIBLE, nctmp ); } @@ -130,6 +124,7 @@ void PCB_EDIT_FRAME::PrintPage( wxDC* aDC, bool onePagePerLayer = false; PRINT_PARAMETERS* printParameters = (PRINT_PARAMETERS*) aData; // can be null + DISPLAY_OPTIONS* displ_opts = (DISPLAY_OPTIONS*)GetDisplayOptions(); if( printParameters && printParameters->m_OptionPrintPage == 0 ) onePagePerLayer = true; @@ -142,13 +137,13 @@ void PCB_EDIT_FRAME::PrintPage( wxDC* aDC, defaultPenSize = printParameters->m_PenDefaultSize; } - save_opt = DisplayOpt; + save_opt = *displ_opts; LAYER_ID activeLayer = GetScreen()->m_Active_Layer; - DisplayOpt.ContrastModeDisplay = false; - DisplayOpt.DisplayPadFill = true; - DisplayOpt.DisplayViaFill = true; + displ_opts->m_ContrastModeDisplay = false; + displ_opts->m_DisplayPadFill = true; + displ_opts->m_DisplayViaFill = true; if( !( aPrintMask & LSET::AllCuMask() ).any() ) { @@ -157,8 +152,8 @@ void PCB_EDIT_FRAME::PrintPage( wxDC* aDC, // We can print mask layers (solder mask and solder paste) with the actual // pad sizes. To do that, we must set ContrastModeDisplay to true and set // the GetScreen()->m_Active_Layer to the current printed layer - DisplayOpt.ContrastModeDisplay = true; - DisplayOpt.DisplayPadFill = true; + displ_opts->m_ContrastModeDisplay = true; + displ_opts->m_DisplayPadFill = true; // Calculate the active layer number to print from its mask layer: GetScreen()->m_Active_Layer = B_Cu; @@ -176,18 +171,16 @@ void PCB_EDIT_FRAME::PrintPage( wxDC* aDC, if( GetScreen()->m_Active_Layer == B_SilkS || GetScreen()->m_Active_Layer == F_SilkS ) { - DisplayOpt.DisplayPadFill = false; + displ_opts->m_DisplayPadFill = false; } } else { - DisplayOpt.DisplayPadFill = false; + displ_opts->m_DisplayPadFill = false; } } - m_DisplayPadFill = DisplayOpt.DisplayPadFill; - m_DisplayViaFill = DisplayOpt.DisplayViaFill; - m_DisplayPadNum = DisplayOpt.DisplayPadNum = false; + displ_opts->m_DisplayPadNum = false; bool nctmp = GetBoard()->IsElementVisible( NO_CONNECTS_VISIBLE ); @@ -197,14 +190,14 @@ void PCB_EDIT_FRAME::PrintPage( wxDC* aDC, GetBoard()->SetElementVisibility( ANCHOR_VISIBLE, false ); - DisplayOpt.DisplayPadIsol = false; - m_DisplayModEdge = DisplayOpt.DisplayModEdge = FILLED; - m_DisplayModText = DisplayOpt.DisplayModText = FILLED; - m_DisplayPcbTrackFill = DisplayOpt.DisplayPcbTrackFill = true; - DisplayOpt.ShowTrackClearanceMode = DO_NOT_SHOW_CLEARANCE; - DisplayOpt.DisplayDrawItems = FILLED; - DisplayOpt.DisplayZonesMode = 0; - DisplayOpt.DisplayNetNamesMode = 0; + displ_opts->m_DisplayPadIsol = false; + displ_opts->m_DisplayModEdge = FILLED; + displ_opts->m_DisplayModText = FILLED; + displ_opts->m_DisplayPcbTrackFill = true; + displ_opts->m_ShowTrackClearanceMode = DO_NOT_SHOW_CLEARANCE; + displ_opts->m_DisplayDrawItems = FILLED; + displ_opts->m_DisplayZonesMode = 0; + displ_opts->m_DisplayNetNamesMode = 0; m_canvas->SetPrintMirrored( aPrintMirrorMode ); @@ -331,14 +324,8 @@ void PCB_EDIT_FRAME::PrintPage( wxDC* aDC, m_canvas->SetPrintMirrored( false ); - DisplayOpt = save_opt; + *displ_opts = save_opt; GetScreen()->m_Active_Layer = activeLayer; - m_DisplayPcbTrackFill = DisplayOpt.DisplayPcbTrackFill; - m_DisplayPadFill = DisplayOpt.DisplayPadFill; - m_DisplayViaFill = DisplayOpt.DisplayViaFill; - m_DisplayPadNum = DisplayOpt.DisplayPadNum; - m_DisplayModEdge = DisplayOpt.DisplayModEdge; - m_DisplayModText = DisplayOpt.DisplayModText; GetBoard()->SetElementVisibility( NO_CONNECTS_VISIBLE, nctmp ); GetBoard()->SetElementVisibility( ANCHOR_VISIBLE, anchorsTmp ); diff --git a/pcbnew/ratsnest.cpp b/pcbnew/ratsnest.cpp index 798e39468e..77a14e45e4 100644 --- a/pcbnew/ratsnest.cpp +++ b/pcbnew/ratsnest.cpp @@ -917,10 +917,11 @@ void PCB_BASE_FRAME::TraceAirWiresToTargets( wxDC* aDC ) return; GRSetDrawMode( aDC, GR_XOR ); + DISPLAY_OPTIONS* displ_opts = (DISPLAY_OPTIONS*)GetDisplayOptions(); for( int ii = 0; ii < (int) s_TargetsLocations.size(); ii++ ) { - if( ii >= g_MaxLinksShowed ) + if( ii >= displ_opts->m_MaxLinksShowed ) break; GRLine( m_canvas->GetClipBox(), aDC, s_CursorPos, s_TargetsLocations[ii], 0, YELLOW ); diff --git a/pcbnew/router/router_tool.cpp b/pcbnew/router/router_tool.cpp index cf7180ba68..db75478427 100644 --- a/pcbnew/router/router_tool.cpp +++ b/pcbnew/router/router_tool.cpp @@ -338,11 +338,14 @@ PNS_ITEM* ROUTER_TOOL::pickSingleItem( const VECTOR2I& aWhere, int aNet, int aLa } PNS_ITEM* rv = NULL; + PCB_EDIT_FRAME* frame = getEditFrame (); + DISPLAY_OPTIONS* displ_opts = (DISPLAY_OPTIONS*)frame->GetDisplayOptions(); + for( int i = 0; i < 4; i++ ) { PNS_ITEM* item = prioritized[i]; - if( DisplayOpt.ContrastModeDisplay ) + if( displ_opts->m_ContrastModeDisplay ) if( item && !item->Layers().Overlaps( tl ) ) item = NULL; diff --git a/pcbnew/tool_modedit.cpp b/pcbnew/tool_modedit.cpp index d5eac2b874..7fbf541ed3 100644 --- a/pcbnew/tool_modedit.cpp +++ b/pcbnew/tool_modedit.cpp @@ -240,6 +240,11 @@ void FOOTPRINT_EDIT_FRAME::ReCreateOptToolbar() KiBitmap( show_mod_edge_xpm ), _( "Show Edges Sketch" ), wxITEM_CHECK ); + m_optionsToolBar->AddTool( ID_TB_OPTIONS_SHOW_HIGH_CONTRAST_MODE, wxEmptyString, + KiBitmap( contrast_mode_xpm ), + _( "Enable high contrast display mode" ), + wxITEM_CHECK ); + m_optionsToolBar->Realize(); } diff --git a/pcbnew/toolbars_update_user_interface.cpp b/pcbnew/toolbars_update_user_interface.cpp index 3748780c43..6b5f7d4535 100644 --- a/pcbnew/toolbars_update_user_interface.cpp +++ b/pcbnew/toolbars_update_user_interface.cpp @@ -117,11 +117,12 @@ void PCB_EDIT_FRAME::OnUpdateScriptingConsoleState( wxUpdateUIEvent& aEvent ) void PCB_EDIT_FRAME::OnUpdateZoneDisplayStyle( wxUpdateUIEvent& aEvent ) { int selected = aEvent.GetId() - ID_TB_OPTIONS_SHOW_ZONES; + DISPLAY_OPTIONS* displ_opts = (DISPLAY_OPTIONS*)GetDisplayOptions(); - if( aEvent.IsChecked() && ( DisplayOpt.DisplayZonesMode == selected ) ) + if( aEvent.IsChecked() && ( displ_opts->m_DisplayZonesMode == selected ) ) return; - aEvent.Check( DisplayOpt.DisplayZonesMode == selected ); + aEvent.Check( displ_opts->m_DisplayZonesMode == selected ); } @@ -147,9 +148,10 @@ void PCB_EDIT_FRAME::OnUpdateShowBoardRatsnest( wxUpdateUIEvent& aEvent ) void PCB_EDIT_FRAME::OnUpdateShowModuleRatsnest( wxUpdateUIEvent& aEvent ) { - aEvent.Check( g_Show_Module_Ratsnest ); + DISPLAY_OPTIONS* displ_opts = (DISPLAY_OPTIONS*)GetDisplayOptions(); + aEvent.Check( displ_opts->m_Show_Module_Ratsnest ); m_optionsToolBar->SetToolShortHelp( ID_TB_OPTIONS_SHOW_MODULE_RATSNEST, - g_Show_Module_Ratsnest ? + displ_opts->m_Show_Module_Ratsnest ? _( "Hide footprint ratsnest" ) : _( "Show footprint ratsnest" ) ); } @@ -167,9 +169,10 @@ void PCB_EDIT_FRAME::OnUpdateAutoDeleteTrack( wxUpdateUIEvent& aEvent ) void PCB_EDIT_FRAME::OnUpdateViaDrawMode( wxUpdateUIEvent& aEvent ) { - aEvent.Check( !m_DisplayViaFill ); + DISPLAY_OPTIONS* displ_opts = (DISPLAY_OPTIONS*)GetDisplayOptions(); + aEvent.Check( !displ_opts->m_DisplayViaFill ); m_optionsToolBar->SetToolShortHelp( ID_TB_OPTIONS_SHOW_VIAS_SKETCH, - m_DisplayViaFill ? + displ_opts->m_DisplayViaFill ? _( "Show vias in outline mode" ) : _( "Show vias in fill mode" ) ); } @@ -177,9 +180,10 @@ void PCB_EDIT_FRAME::OnUpdateViaDrawMode( wxUpdateUIEvent& aEvent ) void PCB_EDIT_FRAME::OnUpdateTraceDrawMode( wxUpdateUIEvent& aEvent ) { - aEvent.Check( !m_DisplayPcbTrackFill ); + DISPLAY_OPTIONS* displ_opts = (DISPLAY_OPTIONS*)GetDisplayOptions(); + aEvent.Check( !displ_opts->m_DisplayPcbTrackFill ); m_optionsToolBar->SetToolShortHelp( ID_TB_OPTIONS_SHOW_TRACKS_SKETCH, - m_DisplayPcbTrackFill ? + displ_opts->m_DisplayPcbTrackFill ? _( "Show tracks in outline mode" ) : _( "Show tracks in fill mode" ) ); } @@ -187,9 +191,10 @@ void PCB_EDIT_FRAME::OnUpdateTraceDrawMode( wxUpdateUIEvent& aEvent ) void PCB_EDIT_FRAME::OnUpdateHighContrastDisplayMode( wxUpdateUIEvent& aEvent ) { - aEvent.Check( DisplayOpt.ContrastModeDisplay ); + DISPLAY_OPTIONS* displ_opts = (DISPLAY_OPTIONS*)GetDisplayOptions(); + aEvent.Check( displ_opts->m_ContrastModeDisplay ); m_optionsToolBar->SetToolShortHelp( ID_TB_OPTIONS_SHOW_HIGH_CONTRAST_MODE, - DisplayOpt.ContrastModeDisplay ? + displ_opts->m_ContrastModeDisplay ? _( "Normal contrast display mode" ) : _( "High contrast display mode" ) ); } diff --git a/pcbnew/tools/pcbnew_control.cpp b/pcbnew/tools/pcbnew_control.cpp index 7579d91290..f9561a8076 100644 --- a/pcbnew/tools/pcbnew_control.cpp +++ b/pcbnew/tools/pcbnew_control.cpp @@ -148,9 +148,9 @@ int PCBNEW_CONTROL::TrackDisplayMode( TOOL_EVENT& aEvent ) static_cast( painter->GetSettings() ); // Apply new display options to the GAL canvas - DisplayOpt.DisplayPcbTrackFill = !DisplayOpt.DisplayPcbTrackFill; - m_frame->m_DisplayPcbTrackFill = DisplayOpt.DisplayPcbTrackFill; - settings->LoadDisplayOptions( DisplayOpt ); + DISPLAY_OPTIONS* displ_opts = (DISPLAY_OPTIONS*)m_frame->GetDisplayOptions(); + displ_opts->m_DisplayPcbTrackFill = !displ_opts->m_DisplayPcbTrackFill; + settings->LoadDisplayOptions( displ_opts ); for( TRACK* track = getModel()->m_Track; track; track = track->Next() ) { @@ -171,11 +171,11 @@ int PCBNEW_CONTROL::PadDisplayMode( TOOL_EVENT& aEvent ) static_cast( m_frame->GetGalCanvas()->GetView()->GetPainter() ); KIGFX::PCB_RENDER_SETTINGS* settings = static_cast( painter->GetSettings() ); + DISPLAY_OPTIONS* displ_opts = (DISPLAY_OPTIONS*)m_frame->GetDisplayOptions(); // Apply new display options to the GAL canvas - DisplayOpt.DisplayPadFill = !DisplayOpt.DisplayPadFill; - m_frame->m_DisplayPadFill = DisplayOpt.DisplayPadFill; - settings->LoadDisplayOptions( DisplayOpt ); + displ_opts->m_DisplayPadFill = !displ_opts->m_DisplayPadFill; + settings->LoadDisplayOptions( displ_opts ); for( MODULE* module = getModel()->m_Modules; module; module = module->Next() ) { @@ -196,11 +196,11 @@ int PCBNEW_CONTROL::ViaDisplayMode( TOOL_EVENT& aEvent ) static_cast( m_frame->GetGalCanvas()->GetView()->GetPainter() ); KIGFX::PCB_RENDER_SETTINGS* settings = static_cast( painter->GetSettings() ); + DISPLAY_OPTIONS* displ_opts = (DISPLAY_OPTIONS*)m_frame->GetDisplayOptions(); // Apply new display options to the GAL canvas - DisplayOpt.DisplayViaFill = !DisplayOpt.DisplayViaFill; - m_frame->m_DisplayViaFill = DisplayOpt.DisplayViaFill; - settings->LoadDisplayOptions( DisplayOpt ); + displ_opts->m_DisplayViaFill = !displ_opts->m_DisplayViaFill; + settings->LoadDisplayOptions( displ_opts ); for( TRACK* track = getModel()->m_Track; track; track = track->Next() ) { @@ -221,18 +221,19 @@ int PCBNEW_CONTROL::ZoneDisplayMode( TOOL_EVENT& aEvent ) static_cast( m_frame->GetGalCanvas()->GetView()->GetPainter() ); KIGFX::PCB_RENDER_SETTINGS* settings = static_cast( painter->GetSettings() ); + DISPLAY_OPTIONS* displ_opts = (DISPLAY_OPTIONS*)m_frame->GetDisplayOptions(); // Apply new display options to the GAL canvas if( aEvent.IsAction( &COMMON_ACTIONS::zoneDisplayEnable ) ) - DisplayOpt.DisplayZonesMode = 0; + displ_opts->m_DisplayZonesMode = 0; else if( aEvent.IsAction( &COMMON_ACTIONS::zoneDisplayDisable ) ) - DisplayOpt.DisplayZonesMode = 1; + displ_opts->m_DisplayZonesMode = 1; else if( aEvent.IsAction( &COMMON_ACTIONS::zoneDisplayOutlines ) ) - DisplayOpt.DisplayZonesMode = 2; + displ_opts->m_DisplayZonesMode = 2; else assert( false ); - settings->LoadDisplayOptions( DisplayOpt ); + settings->LoadDisplayOptions( displ_opts ); BOARD* board = getModel(); for( int i = 0; i < board->GetAreaCount(); ++i ) @@ -251,9 +252,10 @@ int PCBNEW_CONTROL::HighContrastMode( TOOL_EVENT& aEvent ) static_cast( m_frame->GetGalCanvas()->GetView()->GetPainter() ); KIGFX::PCB_RENDER_SETTINGS* settings = static_cast ( painter->GetSettings() ); + DISPLAY_OPTIONS* displ_opts = (DISPLAY_OPTIONS*)m_frame->GetDisplayOptions(); - DisplayOpt.ContrastModeDisplay = !DisplayOpt.ContrastModeDisplay; - settings->LoadDisplayOptions( DisplayOpt ); + displ_opts->m_ContrastModeDisplay = !displ_opts->m_ContrastModeDisplay; + settings->LoadDisplayOptions( displ_opts ); m_frame->GetGalCanvas()->SetHighContrastLayer( m_frame->GetActiveLayer() ); setTransitions(); diff --git a/pcbnew/tracepcb.cpp b/pcbnew/tracepcb.cpp index 190dd6969c..f9bf65b09f 100644 --- a/pcbnew/tracepcb.cpp +++ b/pcbnew/tracepcb.cpp @@ -71,9 +71,7 @@ void FOOTPRINT_EDIT_FRAME::RedrawActiveWindow( wxDC* DC, bool EraseBg ) // Redraw the footprints for( MODULE* module = GetBoard()->m_Modules; module; module = module->Next() ) - { - module->Draw( m_canvas, DC, GR_OR ); - } + module->Draw( m_canvas, DC, GR_OR | GR_ALLOW_HIGHCONTRAST ); #ifdef USE_WX_OVERLAY @@ -297,11 +295,11 @@ void BOARD::DrawHighLight( EDA_DRAW_PANEL* am_canvas, wxDC* DC, int aNetCode ) static void Trace_Pads_Only( EDA_DRAW_PANEL* panel, wxDC* DC, MODULE* aModule, int ox, int oy, LSET aLayerMask, GR_DRAWMODE draw_mode ) { - PCB_BASE_FRAME* frame = (PCB_BASE_FRAME*) panel->GetParent(); + DISPLAY_OPTIONS* displ_opts = (DISPLAY_OPTIONS*)panel->GetDisplayOptions(); - int tmp = frame->m_DisplayPadFill; + int tmp = displ_opts->m_DisplayPadFill; - frame->m_DisplayPadFill = false; + displ_opts->m_DisplayPadFill = false; // Draw pads. for( D_PAD* pad = aModule->Pads(); pad; pad = pad->Next() ) @@ -312,5 +310,5 @@ static void Trace_Pads_Only( EDA_DRAW_PANEL* panel, wxDC* DC, MODULE* aModule, pad->Draw( panel, DC, draw_mode, wxPoint( ox, oy ) ); } - frame->m_DisplayPadFill = tmp; + displ_opts->m_DisplayPadFill = tmp; } From 0cb7c3dc7dee414856917955053da0a30450329e Mon Sep 17 00:00:00 2001 From: jean-pierre charras Date: Sat, 10 Jan 2015 12:08:12 +0100 Subject: [PATCH 4/4] ModEdit: fix incorrect size of the toolbar grid size combo box --- pcbnew/tool_modedit.cpp | 19 +++++-------------- 1 file changed, 5 insertions(+), 14 deletions(-) diff --git a/pcbnew/tool_modedit.cpp b/pcbnew/tool_modedit.cpp index 7fbf541ed3..c3819d1bb7 100644 --- a/pcbnew/tool_modedit.cpp +++ b/pcbnew/tool_modedit.cpp @@ -38,12 +38,6 @@ #include #include -#ifdef __UNIX__ -#define LISTBOX_WIDTH 140 -#else -#define LISTBOX_WIDTH 120 -#endif - void FOOTPRINT_EDIT_FRAME::ReCreateHToolbar() { @@ -266,9 +260,10 @@ void FOOTPRINT_EDIT_FRAME::ReCreateAuxiliaryToolbar() m_gridSelectBox = new wxComboBox( m_auxiliaryToolBar, ID_ON_GRID_SELECT, wxEmptyString, - wxPoint( -1, -1 ), - wxSize( LISTBOX_WIDTH, -1 ), + wxDefaultPosition, wxDefaultSize, 0, NULL, wxCB_READONLY ); + // Update tool bar to reflect setting. + updateGridSelectBox(); m_auxiliaryToolBar->AddControl( m_gridSelectBox ); // Zoom selection choice box. @@ -276,14 +271,10 @@ void FOOTPRINT_EDIT_FRAME::ReCreateAuxiliaryToolbar() m_zoomSelectBox = new wxComboBox( m_auxiliaryToolBar, ID_ON_ZOOM_SELECT, wxEmptyString, - wxPoint( -1, -1 ), - wxSize( LISTBOX_WIDTH, -1 ), + wxDefaultPosition, wxDefaultSize, 0, NULL, wxCB_READONLY ); - m_auxiliaryToolBar->AddControl( m_zoomSelectBox ); - - // Update tool bar to reflect setting. - updateGridSelectBox(); updateZoomSelectBox(); + m_auxiliaryToolBar->AddControl( m_zoomSelectBox ); // after adding the buttons to the toolbar, must call Realize() to reflect the changes m_auxiliaryToolBar->Realize();