diff --git a/common/render_settings.cpp b/common/render_settings.cpp index 5eee1b5664..62dbf93ee2 100644 --- a/common/render_settings.cpp +++ b/common/render_settings.cpp @@ -28,6 +28,7 @@ using namespace KIGFX; RENDER_SETTINGS::RENDER_SETTINGS() : m_highlightNetcodes(), + m_drawBoundingBoxes( false ), m_dashLengthRatio( 12 ), // From ISO 128-2 m_gapLengthRatio( 3 ), // From ISO 128-2 m_printDC( nullptr ) diff --git a/common/tool/actions.cpp b/common/tool/actions.cpp index a2c40ed8c3..dad619085b 100644 --- a/common/tool/actions.cpp +++ b/common/tool/actions.cpp @@ -544,6 +544,11 @@ TOOL_ACTION ACTIONS::highContrastModeCycle( "common.Control.highContrastModeCycl _( "Cycle inactive layers between normal, dimmed, and hidden" ), BITMAPS::contrast_mode ); +TOOL_ACTION ACTIONS::toggleBoundingBoxes( "common.Control.toggleBoundingBoxes", + AS_GLOBAL, 0, "", + _( "Draw Bounding Boxes" ), "", + BITMAPS::gerbview_show_negative_objects ); + TOOL_ACTION ACTIONS::selectionTool( "common.InteractiveSelection.selectionTool", AS_GLOBAL, 0, "", _( "Select item(s)" ), _( "Select item(s)" ), diff --git a/common/tool/common_tools.cpp b/common/tool/common_tools.cpp index 3802c2e305..d320ee1c1e 100644 --- a/common/tool/common_tools.cpp +++ b/common/tool/common_tools.cpp @@ -25,6 +25,7 @@ #include #include +#include #include #include #include @@ -32,14 +33,12 @@ #include #include #include -#include #include #include #include #include #include #include -#include COMMON_TOOLS::COMMON_TOOLS() : @@ -579,62 +578,81 @@ int COMMON_TOOLS::ToggleCursorStyle( const TOOL_EVENT& aEvent ) } -void COMMON_TOOLS::setTransitions() +int COMMON_TOOLS::ToggleBoundingBoxes( const TOOL_EVENT& aEvent ) { - Go( &COMMON_TOOLS::SelectionTool, ACTIONS::selectionTool.MakeEvent() ); + EDA_DRAW_PANEL_GAL* canvas = m_frame->GetCanvas(); - // Cursor control - Go( &COMMON_TOOLS::CursorControl, ACTIONS::cursorUp.MakeEvent() ); - Go( &COMMON_TOOLS::CursorControl, ACTIONS::cursorDown.MakeEvent() ); - Go( &COMMON_TOOLS::CursorControl, ACTIONS::cursorLeft.MakeEvent() ); - Go( &COMMON_TOOLS::CursorControl, ACTIONS::cursorRight.MakeEvent() ); - Go( &COMMON_TOOLS::CursorControl, ACTIONS::cursorUpFast.MakeEvent() ); - Go( &COMMON_TOOLS::CursorControl, ACTIONS::cursorDownFast.MakeEvent() ); - Go( &COMMON_TOOLS::CursorControl, ACTIONS::cursorLeftFast.MakeEvent() ); - Go( &COMMON_TOOLS::CursorControl, ACTIONS::cursorRightFast.MakeEvent() ); + if( canvas ) + { + KIGFX::RENDER_SETTINGS* rs = canvas->GetView()->GetPainter()->GetSettings(); - Go( &COMMON_TOOLS::CursorControl, ACTIONS::cursorClick.MakeEvent() ); - Go( &COMMON_TOOLS::CursorControl, ACTIONS::cursorDblClick.MakeEvent() ); - Go( &COMMON_TOOLS::CursorControl, ACTIONS::showContextMenu.MakeEvent() ); + rs->SetDrawBoundingBoxes( !rs->GetDrawBoundingBoxes() ); - // Pan control - Go( &COMMON_TOOLS::PanControl, ACTIONS::panUp.MakeEvent() ); - Go( &COMMON_TOOLS::PanControl, ACTIONS::panDown.MakeEvent() ); - Go( &COMMON_TOOLS::PanControl, ACTIONS::panLeft.MakeEvent() ); - Go( &COMMON_TOOLS::PanControl, ACTIONS::panRight.MakeEvent() ); + canvas->GetView()->UpdateAllItems( KIGFX::ALL ); + canvas->ForceRefresh(); + } - // Zoom control - Go( &COMMON_TOOLS::ZoomRedraw, ACTIONS::zoomRedraw.MakeEvent() ); - Go( &COMMON_TOOLS::ZoomInOut, ACTIONS::zoomIn.MakeEvent() ); - Go( &COMMON_TOOLS::ZoomInOut, ACTIONS::zoomOut.MakeEvent() ); - Go( &COMMON_TOOLS::ZoomInOutCenter, ACTIONS::zoomInCenter.MakeEvent() ); - Go( &COMMON_TOOLS::ZoomInOutCenter, ACTIONS::zoomOutCenter.MakeEvent() ); - Go( &COMMON_TOOLS::ZoomCenter, ACTIONS::zoomCenter.MakeEvent() ); - Go( &COMMON_TOOLS::ZoomFitScreen, ACTIONS::zoomFitScreen.MakeEvent() ); - Go( &COMMON_TOOLS::ZoomFitObjects, ACTIONS::zoomFitObjects.MakeEvent() ); - Go( &COMMON_TOOLS::ZoomPreset, ACTIONS::zoomPreset.MakeEvent() ); - Go( &COMMON_TOOLS::CenterContents, ACTIONS::centerContents.MakeEvent() ); - - // Grid control - Go( &COMMON_TOOLS::GridNext, ACTIONS::gridNext.MakeEvent() ); - Go( &COMMON_TOOLS::GridPrev, ACTIONS::gridPrev.MakeEvent() ); - Go( &COMMON_TOOLS::GridPreset, ACTIONS::gridPreset.MakeEvent() ); - Go( &COMMON_TOOLS::GridFast1, ACTIONS::gridFast1.MakeEvent() ); - Go( &COMMON_TOOLS::GridFast2, ACTIONS::gridFast2.MakeEvent() ); - Go( &COMMON_TOOLS::ToggleGrid, ACTIONS::toggleGrid.MakeEvent() ); - Go( &COMMON_TOOLS::GridProperties, ACTIONS::gridProperties.MakeEvent() ); - - // Units and coordinates - Go( &COMMON_TOOLS::SwitchUnits, ACTIONS::inchesUnits.MakeEvent() ); - Go( &COMMON_TOOLS::SwitchUnits, ACTIONS::milsUnits.MakeEvent() ); - Go( &COMMON_TOOLS::SwitchUnits, ACTIONS::millimetersUnits.MakeEvent() ); - Go( &COMMON_TOOLS::ToggleUnits, ACTIONS::toggleUnits.MakeEvent() ); - Go( &COMMON_TOOLS::TogglePolarCoords, ACTIONS::togglePolarCoords.MakeEvent() ); - Go( &COMMON_TOOLS::ResetLocalCoords, ACTIONS::resetLocalCoords.MakeEvent() ); - - // Misc - Go( &COMMON_TOOLS::ToggleCursor, ACTIONS::toggleCursor.MakeEvent() ); - Go( &COMMON_TOOLS::ToggleCursorStyle, ACTIONS::toggleCursorStyle.MakeEvent() ); + return 0; +} + + +void COMMON_TOOLS::setTransitions() +{ + Go( &COMMON_TOOLS::SelectionTool, ACTIONS::selectionTool.MakeEvent() ); + + // Cursor control + Go( &COMMON_TOOLS::CursorControl, ACTIONS::cursorUp.MakeEvent() ); + Go( &COMMON_TOOLS::CursorControl, ACTIONS::cursorDown.MakeEvent() ); + Go( &COMMON_TOOLS::CursorControl, ACTIONS::cursorLeft.MakeEvent() ); + Go( &COMMON_TOOLS::CursorControl, ACTIONS::cursorRight.MakeEvent() ); + Go( &COMMON_TOOLS::CursorControl, ACTIONS::cursorUpFast.MakeEvent() ); + Go( &COMMON_TOOLS::CursorControl, ACTIONS::cursorDownFast.MakeEvent() ); + Go( &COMMON_TOOLS::CursorControl, ACTIONS::cursorLeftFast.MakeEvent() ); + Go( &COMMON_TOOLS::CursorControl, ACTIONS::cursorRightFast.MakeEvent() ); + + Go( &COMMON_TOOLS::CursorControl, ACTIONS::cursorClick.MakeEvent() ); + Go( &COMMON_TOOLS::CursorControl, ACTIONS::cursorDblClick.MakeEvent() ); + Go( &COMMON_TOOLS::CursorControl, ACTIONS::showContextMenu.MakeEvent() ); + + // Pan control + Go( &COMMON_TOOLS::PanControl, ACTIONS::panUp.MakeEvent() ); + Go( &COMMON_TOOLS::PanControl, ACTIONS::panDown.MakeEvent() ); + Go( &COMMON_TOOLS::PanControl, ACTIONS::panLeft.MakeEvent() ); + Go( &COMMON_TOOLS::PanControl, ACTIONS::panRight.MakeEvent() ); + + // Zoom control + Go( &COMMON_TOOLS::ZoomRedraw, ACTIONS::zoomRedraw.MakeEvent() ); + Go( &COMMON_TOOLS::ZoomInOut, ACTIONS::zoomIn.MakeEvent() ); + Go( &COMMON_TOOLS::ZoomInOut, ACTIONS::zoomOut.MakeEvent() ); + Go( &COMMON_TOOLS::ZoomInOutCenter, ACTIONS::zoomInCenter.MakeEvent() ); + Go( &COMMON_TOOLS::ZoomInOutCenter, ACTIONS::zoomOutCenter.MakeEvent() ); + Go( &COMMON_TOOLS::ZoomCenter, ACTIONS::zoomCenter.MakeEvent() ); + Go( &COMMON_TOOLS::ZoomFitScreen, ACTIONS::zoomFitScreen.MakeEvent() ); + Go( &COMMON_TOOLS::ZoomFitObjects, ACTIONS::zoomFitObjects.MakeEvent() ); + Go( &COMMON_TOOLS::ZoomPreset, ACTIONS::zoomPreset.MakeEvent() ); + Go( &COMMON_TOOLS::CenterContents, ACTIONS::centerContents.MakeEvent() ); + + // Grid control + Go( &COMMON_TOOLS::GridNext, ACTIONS::gridNext.MakeEvent() ); + Go( &COMMON_TOOLS::GridPrev, ACTIONS::gridPrev.MakeEvent() ); + Go( &COMMON_TOOLS::GridPreset, ACTIONS::gridPreset.MakeEvent() ); + Go( &COMMON_TOOLS::GridFast1, ACTIONS::gridFast1.MakeEvent() ); + Go( &COMMON_TOOLS::GridFast2, ACTIONS::gridFast2.MakeEvent() ); + Go( &COMMON_TOOLS::ToggleGrid, ACTIONS::toggleGrid.MakeEvent() ); + Go( &COMMON_TOOLS::GridProperties, ACTIONS::gridProperties.MakeEvent() ); + + // Units and coordinates + Go( &COMMON_TOOLS::SwitchUnits, ACTIONS::inchesUnits.MakeEvent() ); + Go( &COMMON_TOOLS::SwitchUnits, ACTIONS::milsUnits.MakeEvent() ); + Go( &COMMON_TOOLS::SwitchUnits, ACTIONS::millimetersUnits.MakeEvent() ); + Go( &COMMON_TOOLS::ToggleUnits, ACTIONS::toggleUnits.MakeEvent() ); + Go( &COMMON_TOOLS::TogglePolarCoords, ACTIONS::togglePolarCoords.MakeEvent() ); + Go( &COMMON_TOOLS::ResetLocalCoords, ACTIONS::resetLocalCoords.MakeEvent() ); + + // Misc + Go( &COMMON_TOOLS::ToggleCursor, ACTIONS::toggleCursor.MakeEvent() ); + Go( &COMMON_TOOLS::ToggleCursorStyle, ACTIONS::toggleCursorStyle.MakeEvent() ); + Go( &COMMON_TOOLS::ToggleBoundingBoxes, ACTIONS::toggleBoundingBoxes.MakeEvent() ); } diff --git a/common/tool/editor_conditions.cpp b/common/tool/editor_conditions.cpp index b09d4271eb..a780f37a56 100644 --- a/common/tool/editor_conditions.cpp +++ b/common/tool/editor_conditions.cpp @@ -23,6 +23,8 @@ */ +#include +#include #include #include #include @@ -104,6 +106,16 @@ SELECTION_CONDITION EDITOR_CONDITIONS::FullscreenCursor() } +SELECTION_CONDITION EDITOR_CONDITIONS::BoundingBoxes() +{ + EDA_DRAW_FRAME* drwFrame = dynamic_cast( m_frame ); + + wxASSERT( drwFrame ); + + return std::bind( &EDITOR_CONDITIONS::bboxesFunc, _1, drwFrame ); +} + + SELECTION_CONDITION EDITOR_CONDITIONS::ScriptingConsoleVisible() { EDA_DRAW_FRAME* drwFrame = dynamic_cast( m_frame ); @@ -170,6 +182,12 @@ bool EDITOR_CONDITIONS::cursorFunc( const SELECTION& aSelection, EDA_DRAW_FRAME* } +bool EDITOR_CONDITIONS::bboxesFunc( const SELECTION& aSelection, EDA_DRAW_FRAME* aFrame ) +{ + return aFrame->GetCanvas()->GetView()->GetPainter()->GetSettings()->GetDrawBoundingBoxes(); +} + + bool EDITOR_CONDITIONS::consoleVisibleFunc( const SELECTION& aSelection, EDA_DRAW_FRAME* aFrame ) { return aFrame->IsScriptingConsoleVisible(); diff --git a/cvpcb/display_footprints_frame.cpp b/cvpcb/display_footprints_frame.cpp index 6e0d3068ab..b44ed12a4e 100644 --- a/cvpcb/display_footprints_frame.cpp +++ b/cvpcb/display_footprints_frame.cpp @@ -203,13 +203,10 @@ void DISPLAY_FOOTPRINTS_FRAME::setupUIConditions() mgr->SetConditions( ACTIONS::inchesUnits, CHECK( cond.Units( EDA_UNITS::INCHES ) ) ); mgr->SetConditions( ACTIONS::milsUnits, CHECK( cond.Units( EDA_UNITS::MILS ) ) ); - - mgr->SetConditions( PCB_ACTIONS::showPadNumbers, - CHECK( cond.PadNumbersDisplay() ) ); - mgr->SetConditions( PCB_ACTIONS::padDisplayMode, CHECK( !cond.PadFillDisplay() ) ); - mgr->SetConditions( PCB_ACTIONS::textOutlines, CHECK( !cond.TextFillDisplay() ) ); - mgr->SetConditions( PCB_ACTIONS::graphicsOutlines, - CHECK( !cond.GraphicsFillDisplay() ) ); + mgr->SetConditions( PCB_ACTIONS::showPadNumbers, CHECK( cond.PadNumbersDisplay() ) ); + mgr->SetConditions( PCB_ACTIONS::padDisplayMode, CHECK( !cond.PadFillDisplay() ) ); + mgr->SetConditions( PCB_ACTIONS::textOutlines, CHECK( !cond.TextFillDisplay() ) ); + mgr->SetConditions( PCB_ACTIONS::graphicsOutlines, CHECK( !cond.GraphicsFillDisplay() ) ); #undef CHECK } diff --git a/eeschema/sch_edit_frame.cpp b/eeschema/sch_edit_frame.cpp index 9c37b08d8b..c721177baa 100644 --- a/eeschema/sch_edit_frame.cpp +++ b/eeschema/sch_edit_frame.cpp @@ -499,6 +499,7 @@ void SCH_EDIT_FRAME::setupUIConditions() mgr->SetConditions( EE_ACTIONS::toggleERCWarnings, CHECK( showERCWarningsCond ) ); mgr->SetConditions( EE_ACTIONS::toggleERCExclusions, CHECK( showERCExclusionsCond ) ); mgr->SetConditions( EE_ACTIONS::toggleForceHV, CHECK( forceHVCond ) ); + mgr->SetConditions( ACTIONS::toggleBoundingBoxes, CHECK( cond.BoundingBoxes() ) ); #define CURRENT_TOOL( action ) mgr->SetConditions( action, CHECK( cond.CurrentTool( action ) ) ) diff --git a/eeschema/sch_painter.cpp b/eeschema/sch_painter.cpp index f62fcb395a..ccb46c4d80 100644 --- a/eeschema/sch_painter.cpp +++ b/eeschema/sch_painter.cpp @@ -197,7 +197,7 @@ bool SCH_PAINTER::Draw( const VIEW_ITEM *aItem, int aLayer ) #endif - if( ADVANCED_CFG::GetCfg().m_DrawBoundingBoxes ) + if( m_schSettings.GetDrawBoundingBoxes() ) { BOX2I box = item->GetBoundingBox(); diff --git a/eeschema/symbol_editor/symbol_edit_frame.cpp b/eeschema/symbol_editor/symbol_edit_frame.cpp index b0f0d5a837..cadea00891 100644 --- a/eeschema/symbol_editor/symbol_edit_frame.cpp +++ b/eeschema/symbol_editor/symbol_edit_frame.cpp @@ -429,7 +429,8 @@ void SYMBOL_EDIT_FRAME::setupUIConditions() }; mgr->SetConditions( EE_ACTIONS::showElectricalTypes, CHECK( pinTypeCond ) ); - mgr->SetConditions( EE_ACTIONS::showSymbolTree, CHECK( showCompTreeCond ) ); + mgr->SetConditions( ACTIONS::toggleBoundingBoxes, CHECK( cond.BoundingBoxes() ) ); + mgr->SetConditions( EE_ACTIONS::showSymbolTree, CHECK( showCompTreeCond ) ); auto demorganCond = [this]( const SELECTION& ) diff --git a/eeschema/symbol_editor/toolbars_symbol_editor.cpp b/eeschema/symbol_editor/toolbars_symbol_editor.cpp index bf2c8297c0..de14a17041 100644 --- a/eeschema/symbol_editor/toolbars_symbol_editor.cpp +++ b/eeschema/symbol_editor/toolbars_symbol_editor.cpp @@ -23,6 +23,7 @@ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA */ +#include #include #include #include @@ -159,6 +160,11 @@ void SYMBOL_EDIT_FRAME::ReCreateOptToolbar() m_optionsToolBar->Add( ACTIONS::millimetersUnits, ACTION_TOOLBAR::TOGGLE ); m_optionsToolBar->Add( ACTIONS::toggleCursorStyle, ACTION_TOOLBAR::TOGGLE ); m_optionsToolBar->Add( EE_ACTIONS::showElectricalTypes, ACTION_TOOLBAR::TOGGLE ); + + if( ADVANCED_CFG::GetCfg().m_DrawBoundingBoxes ) + m_optionsToolBar->Add( ACTIONS::toggleBoundingBoxes, ACTION_TOOLBAR::TOGGLE ); + + m_optionsToolBar->AddScaledSeparator( this ); m_optionsToolBar->Add( EE_ACTIONS::showSymbolTree, ACTION_TOOLBAR::TOGGLE ); EE_SELECTION_TOOL* selTool = m_toolManager->GetTool(); diff --git a/eeschema/toolbars_sch_editor.cpp b/eeschema/toolbars_sch_editor.cpp index 257baa7bc0..49416e5160 100644 --- a/eeschema/toolbars_sch_editor.cpp +++ b/eeschema/toolbars_sch_editor.cpp @@ -24,6 +24,7 @@ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA */ +#include #include #include #include @@ -192,6 +193,9 @@ void SCH_EDIT_FRAME::ReCreateOptToolbar() m_optionsToolBar->Add( EE_ACTIONS::toggleHiddenPins, ACTION_TOOLBAR::TOGGLE ); m_optionsToolBar->Add( EE_ACTIONS::toggleForceHV, ACTION_TOOLBAR::TOGGLE ); + if( ADVANCED_CFG::GetCfg().m_DrawBoundingBoxes ) + m_optionsToolBar->Add( ACTIONS::toggleBoundingBoxes, ACTION_TOOLBAR::TOGGLE ); + EE_SELECTION_TOOL* selTool = m_toolManager->GetTool(); std::unique_ptr gridMenu = std::make_unique( false, selTool ); gridMenu->Add( ACTIONS::gridProperties ); diff --git a/include/render_settings.h b/include/render_settings.h index f92a156a0b..2e14fef18b 100644 --- a/include/render_settings.h +++ b/include/render_settings.h @@ -185,6 +185,9 @@ public: void SetHighContrast( bool aEnabled ) { m_hiContrastEnabled = aEnabled; } bool GetHighContrast() const { return m_hiContrastEnabled; } + void SetDrawBoundingBoxes( bool aEnabled ) { m_drawBoundingBoxes = aEnabled; } + bool GetDrawBoundingBoxes() const { return m_drawBoundingBoxes; } + /** * Returns the color that should be used to draw the specific VIEW_ITEM on the specific layer * using currently used render settings. @@ -309,6 +312,8 @@ protected: std::set m_highlightNetcodes; // Set of net cods to be highlighted float m_highlightFactor; // Factor used for computing highlight color + bool m_drawBoundingBoxes; // Visual aid for debugging + float m_selectFactor; // Specifies how color of selected items is changed float m_outlineWidth; // Line width used when drawing outlines float m_drawingSheetLineWidth;// Line width used for borders and titleblock diff --git a/include/tool/actions.h b/include/tool/actions.h index 1411bc3368..3909874744 100644 --- a/include/tool/actions.h +++ b/include/tool/actions.h @@ -102,6 +102,7 @@ public: static TOOL_ACTION toggleCursorStyle; static TOOL_ACTION highContrastMode; static TOOL_ACTION highContrastModeCycle; + static TOOL_ACTION toggleBoundingBoxes; static TOOL_ACTION refreshPreview; // Similar to a synthetic mouseMoved event, but also // used after a rotate, mirror, etc. diff --git a/include/tool/common_tools.h b/include/tool/common_tools.h index dd9438305c..270cc914ac 100644 --- a/include/tool/common_tools.h +++ b/include/tool/common_tools.h @@ -64,6 +64,8 @@ public: int ToggleCursor( const TOOL_EVENT& aEvent ); int ToggleCursorStyle( const TOOL_EVENT& aEvent ); + int ToggleBoundingBoxes( const TOOL_EVENT& aEvent ); + // Units control int SwitchUnits( const TOOL_EVENT& aEvent ); int ToggleUnits( const TOOL_EVENT& aEvent ); diff --git a/include/tool/editor_conditions.h b/include/tool/editor_conditions.h index 11a893f65b..f542f069ea 100644 --- a/include/tool/editor_conditions.h +++ b/include/tool/editor_conditions.h @@ -118,6 +118,8 @@ public: */ SELECTION_CONDITION FullscreenCursor(); + SELECTION_CONDITION BoundingBoxes(); + /** * Create a functor testing if the python scripting console window is visible. * @@ -156,6 +158,9 @@ protected: ///< Helper function used by FullscreenCursor(). static bool cursorFunc( const SELECTION& aSelection, EDA_DRAW_FRAME* aFrame ); + ///< Helper function used by DrawBoundingBoxes(). + static bool bboxesFunc( const SELECTION& aSelection, EDA_DRAW_FRAME* aFrame ); + ///< Helper function used by ScriptingConsoleVisible(). static bool consoleVisibleFunc( const SELECTION& aSelection, EDA_DRAW_FRAME* aFrame ); diff --git a/pcbnew/footprint_edit_frame.cpp b/pcbnew/footprint_edit_frame.cpp index e0ab7f3b37..61dde2296a 100644 --- a/pcbnew/footprint_edit_frame.cpp +++ b/pcbnew/footprint_edit_frame.cpp @@ -1122,6 +1122,8 @@ void FOOTPRINT_EDIT_FRAME::setupUIConditions() mgr->SetConditions( ACTIONS::highContrastMode, CHECK( highContrastCond ) ); mgr->SetConditions( PCB_ACTIONS::flipBoard, CHECK( boardFlippedCond ) ); + mgr->SetConditions( ACTIONS::toggleBoundingBoxes, CHECK( cond.BoundingBoxes() ) ); + mgr->SetConditions( PCB_ACTIONS::showFootprintTree, CHECK( footprintTreeCond ) ); mgr->SetConditions( PCB_ACTIONS::showLayersManager, CHECK( layerManagerCond ) ); diff --git a/pcbnew/footprint_viewer_frame.cpp b/pcbnew/footprint_viewer_frame.cpp index 5372353a2c..ce2a9df811 100644 --- a/pcbnew/footprint_viewer_frame.cpp +++ b/pcbnew/footprint_viewer_frame.cpp @@ -322,12 +322,11 @@ void FOOTPRINT_VIEWER_FRAME::setupUIConditions() #define ENABLE( x ) ACTION_CONDITIONS().Enable( x ) #define CHECK( x ) ACTION_CONDITIONS().Check( x ) - mgr->SetConditions( ACTIONS::toggleGrid, CHECK( cond.GridVisible() ) ); - mgr->SetConditions( ACTIONS::toggleCursorStyle, CHECK( cond.FullscreenCursor() ) ); - mgr->SetConditions( ACTIONS::millimetersUnits, - CHECK( cond.Units( EDA_UNITS::MILLIMETRES ) ) ); - mgr->SetConditions( ACTIONS::inchesUnits, CHECK( cond.Units( EDA_UNITS::INCHES ) ) ); - mgr->SetConditions( ACTIONS::milsUnits, CHECK( cond.Units( EDA_UNITS::MILS ) ) ); + mgr->SetConditions( ACTIONS::toggleGrid, CHECK( cond.GridVisible() ) ); + mgr->SetConditions( ACTIONS::toggleCursorStyle, CHECK( cond.FullscreenCursor() ) ); + mgr->SetConditions( ACTIONS::millimetersUnits, CHECK( cond.Units( EDA_UNITS::MILLIMETRES ) ) ); + mgr->SetConditions( ACTIONS::inchesUnits, CHECK( cond.Units( EDA_UNITS::INCHES ) ) ); + mgr->SetConditions( ACTIONS::milsUnits, CHECK( cond.Units( EDA_UNITS::MILS ) ) ); mgr->SetConditions( ACTIONS::zoomTool, @@ -341,6 +340,7 @@ void FOOTPRINT_VIEWER_FRAME::setupUIConditions() mgr->SetConditions( PCB_ACTIONS::padDisplayMode, CHECK( !cond.PadFillDisplay() ) ); mgr->SetConditions( PCB_ACTIONS::textOutlines, CHECK( !cond.TextFillDisplay() ) ); mgr->SetConditions( PCB_ACTIONS::graphicsOutlines, CHECK( !cond.GraphicsFillDisplay() ) ); + mgr->SetConditions( ACTIONS::toggleBoundingBoxes, CHECK( cond.BoundingBoxes() ) ); #undef ENABLE #undef CHECK diff --git a/pcbnew/pcb_edit_frame.cpp b/pcbnew/pcb_edit_frame.cpp index cce94917ba..41de505793 100644 --- a/pcbnew/pcb_edit_frame.cpp +++ b/pcbnew/pcb_edit_frame.cpp @@ -638,13 +638,19 @@ void PCB_EDIT_FRAME::setupUIConditions() }; mgr->SetConditions( PCB_ACTIONS::zoneDisplayFilled, - ENABLE( enableZoneControlConition ).Check( cond.ZoneDisplayMode( ZONE_DISPLAY_MODE::SHOW_FILLED ) ) ); + ENABLE( enableZoneControlConition ) + .Check( cond.ZoneDisplayMode( ZONE_DISPLAY_MODE::SHOW_FILLED ) ) ); mgr->SetConditions( PCB_ACTIONS::zoneDisplayOutline, - ENABLE( enableZoneControlConition ).Check( cond.ZoneDisplayMode( ZONE_DISPLAY_MODE::SHOW_ZONE_OUTLINE ) ) ); + ENABLE( enableZoneControlConition ) + .Check( cond.ZoneDisplayMode( ZONE_DISPLAY_MODE::SHOW_ZONE_OUTLINE ) ) ); mgr->SetConditions( PCB_ACTIONS::zoneDisplayFractured, - ENABLE( enableZoneControlConition ).Check( cond.ZoneDisplayMode( ZONE_DISPLAY_MODE::SHOW_FRACTURE_BORDERS ) ) ); + ENABLE( enableZoneControlConition ) + .Check( cond.ZoneDisplayMode( ZONE_DISPLAY_MODE::SHOW_FRACTURE_BORDERS ) ) ); mgr->SetConditions( PCB_ACTIONS::zoneDisplayTriangulated, - ENABLE( enableZoneControlConition ).Check( cond.ZoneDisplayMode( ZONE_DISPLAY_MODE::SHOW_TRIANGULATION ) ) ); + ENABLE( enableZoneControlConition ) + .Check( cond.ZoneDisplayMode( ZONE_DISPLAY_MODE::SHOW_TRIANGULATION ) ) ); + + mgr->SetConditions( ACTIONS::toggleBoundingBoxes, CHECK( cond.BoundingBoxes() ) ); auto enableBoardSetupCondition = [this] ( const SELECTION& ) @@ -704,10 +710,9 @@ void PCB_EDIT_FRAME::setupUIConditions() mgr->SetConditions( PCB_ACTIONS::showLayersManager, CHECK( layerManagerCond ) ); mgr->SetConditions( PCB_ACTIONS::showRatsnest, CHECK( globalRatsnestCond ) ); mgr->SetConditions( PCB_ACTIONS::ratsnestLineMode, CHECK( curvedRatsnestCond ) ); - mgr->SetConditions( PCB_ACTIONS::toggleNetHighlight, - CHECK( netHighlightCond ).Enable( enableNetHighlightCond ) ); - mgr->SetConditions( PCB_ACTIONS::boardSetup , ENABLE( enableBoardSetupCondition ) ); - + mgr->SetConditions( PCB_ACTIONS::toggleNetHighlight, CHECK( netHighlightCond ) + .Enable( enableNetHighlightCond ) ); + mgr->SetConditions( PCB_ACTIONS::boardSetup, ENABLE( enableBoardSetupCondition ) ); auto isHighlightMode = [this]( const SELECTION& ) diff --git a/pcbnew/pcb_painter.cpp b/pcbnew/pcb_painter.cpp index 69a2c94101..c3301452a9 100644 --- a/pcbnew/pcb_painter.cpp +++ b/pcbnew/pcb_painter.cpp @@ -504,7 +504,7 @@ bool PCB_PAINTER::Draw( const VIEW_ITEM* aItem, int aLayer ) } // Draw bounding boxes after drawing objects so they can be seen. - if( ADVANCED_CFG::GetCfg().m_DrawBoundingBoxes ) + if( m_pcbSettings.GetDrawBoundingBoxes() ) { // Show bounding boxes of painted objects for debugging. EDA_RECT box = item->GetBoundingBox(); diff --git a/pcbnew/toolbars_footprint_editor.cpp b/pcbnew/toolbars_footprint_editor.cpp index e89bd0bc97..b9a619790d 100644 --- a/pcbnew/toolbars_footprint_editor.cpp +++ b/pcbnew/toolbars_footprint_editor.cpp @@ -31,6 +31,7 @@ #include #include #include +#include void FOOTPRINT_EDIT_FRAME::ReCreateHToolbar() { @@ -224,6 +225,9 @@ void FOOTPRINT_EDIT_FRAME::ReCreateOptToolbar() m_optionsToolBar->Add( PCB_ACTIONS::textOutlines, ACTION_TOOLBAR::TOGGLE ); m_optionsToolBar->Add( ACTIONS::highContrastMode, ACTION_TOOLBAR::TOGGLE ); + if( ADVANCED_CFG::GetCfg().m_DrawBoundingBoxes ) + m_optionsToolBar->Add( ACTIONS::toggleBoundingBoxes, ACTION_TOOLBAR::TOGGLE ); + m_optionsToolBar->AddScaledSeparator( this ); m_optionsToolBar->Add( PCB_ACTIONS::showFootprintTree, ACTION_TOOLBAR::TOGGLE ); m_optionsToolBar->Add( PCB_ACTIONS::showLayersManager, ACTION_TOOLBAR::TOGGLE ); diff --git a/pcbnew/toolbars_footprint_viewer.cpp b/pcbnew/toolbars_footprint_viewer.cpp index 5b8e93c5fd..e08d89ecd7 100644 --- a/pcbnew/toolbars_footprint_viewer.cpp +++ b/pcbnew/toolbars_footprint_viewer.cpp @@ -21,6 +21,7 @@ */ +#include #include #include #include @@ -137,6 +138,9 @@ void FOOTPRINT_VIEWER_FRAME::ReCreateOptToolbar() m_optionsToolBar->Add( PCB_ACTIONS::textOutlines, ACTION_TOOLBAR::TOGGLE ); m_optionsToolBar->Add( PCB_ACTIONS::graphicsOutlines, ACTION_TOOLBAR::TOGGLE ); + if( ADVANCED_CFG::GetCfg().m_DrawBoundingBoxes ) + m_optionsToolBar->Add( ACTIONS::toggleBoundingBoxes, ACTION_TOOLBAR::TOGGLE ); + m_optionsToolBar->KiRealize(); } diff --git a/pcbnew/toolbars_pcb_editor.cpp b/pcbnew/toolbars_pcb_editor.cpp index 41a75ec38d..d7ed5ac486 100644 --- a/pcbnew/toolbars_pcb_editor.cpp +++ b/pcbnew/toolbars_pcb_editor.cpp @@ -369,6 +369,9 @@ void PCB_EDIT_FRAME::ReCreateOptToolbar() m_optionsToolBar->Add( PCB_ACTIONS::viaDisplayMode, ACTION_TOOLBAR::TOGGLE ); m_optionsToolBar->Add( PCB_ACTIONS::trackDisplayMode, ACTION_TOOLBAR::TOGGLE ); + if( ADVANCED_CFG::GetCfg().m_DrawBoundingBoxes ) + m_optionsToolBar->Add( ACTIONS::toggleBoundingBoxes, ACTION_TOOLBAR::TOGGLE ); + // Tools to show/hide toolbars: m_optionsToolBar->AddScaledSeparator( this ); m_optionsToolBar->Add( PCB_ACTIONS::showLayersManager, ACTION_TOOLBAR::TOGGLE );