diff --git a/include/base_struct.h b/include/base_struct.h index 8f5d7ee351..fcfb737583 100644 --- a/include/base_struct.h +++ b/include/base_struct.h @@ -257,6 +257,14 @@ public: void ClearFlags( STATUS_FLAGS aMask = EDA_ITEM_ALL_FLAGS ) { m_Flags &= ~aMask; } STATUS_FLAGS GetFlags() const { return m_Flags; } + STATUS_FLAGS GetEditFlags() const + { + int mask = EDA_ITEM_ALL_FLAGS - ( SELECTED | SELECTEDNODE | HIGHLIGHTED | BRIGHTENED | + STARTPOINT | ENDPOINT | + BEGIN_ONPAD | END_ONPAD | DP_COUPLED ); + return m_Flags & mask; + } + /** * Function IsType * Checks whether the item is one of the listed types diff --git a/pcbnew/tools/drawing_tool.cpp b/pcbnew/tools/drawing_tool.cpp index 9e2bc5851a..d2141d285f 100644 --- a/pcbnew/tools/drawing_tool.cpp +++ b/pcbnew/tools/drawing_tool.cpp @@ -1193,7 +1193,7 @@ bool DRAWING_TOOL::drawSegment( int aShape, DRAWSEGMENT*& aGraphic, * of an Arc Geometry Manager */ static void updateArcFromConstructionMgr( const KIGFX::PREVIEW::ARC_GEOM_MANAGER& aMgr, - DRAWSEGMENT& aArc ) + DRAWSEGMENT& aArc ) { auto vec = aMgr.GetOrigin(); @@ -1378,6 +1378,9 @@ bool DRAWING_TOOL::getSourceZoneForAction( ZONE_MODE aMode, ZONE_CONTAINER*& aZo int DRAWING_TOOL::drawZone( bool aKeepout, ZONE_MODE aMode ) { + if( m_editModules && !m_frame->GetModel() ) + return 0; + // get a source zone, if we need one. We need it for: // ZONE_MODE::CUTOUT (adding a hole to the source zone) // ZONE_MODE::SIMILAR (creating a new zone using settings of source zone diff --git a/pcbnew/tools/footprint_editor_tools.cpp b/pcbnew/tools/footprint_editor_tools.cpp index 73d714a9a5..45d464d05c 100644 --- a/pcbnew/tools/footprint_editor_tools.cpp +++ b/pcbnew/tools/footprint_editor_tools.cpp @@ -99,6 +99,9 @@ void MODULE_EDITOR_TOOLS::Reset( RESET_REASON aReason ) int MODULE_EDITOR_TOOLS::PlacePad( const TOOL_EVENT& aEvent ) { + if( !frame()->GetBoard()->m_Modules ) + return 0; + struct PAD_PLACER : public INTERACTIVE_PLACER_BASE { std::unique_ptr CreateItem() override @@ -129,8 +132,6 @@ int MODULE_EDITOR_TOOLS::PlacePad( const TOOL_EVENT& aEvent ) frame()->SetToolID( ID_MODEDIT_PAD_TOOL, wxCURSOR_PENCIL, _( "Add pads" ) ); - wxASSERT( board()->m_Modules ); - doInteractiveItemPlacement( &placer, _( "Place pad" ), IPO_REPEAT | IPO_SINGLE_CLICK | IPO_ROTATE | IPO_FLIP ); frame()->SetNoToolSelected(); diff --git a/pcbnew/tools/pcb_tool.cpp b/pcbnew/tools/pcb_tool.cpp index 91dca71323..8c163668c1 100644 --- a/pcbnew/tools/pcb_tool.cpp +++ b/pcbnew/tools/pcb_tool.cpp @@ -65,7 +65,8 @@ void PCB_TOOL::doInteractiveItemPlacement( INTERACTIVE_PLACER_BASE* aPlacer, { VECTOR2I cursorPos = controls()->GetCursorPosition(); - newItem = aPlacer->CreateItem(); + if( frame()->GetModel() ) + newItem = aPlacer->CreateItem(); if( newItem ) { diff --git a/pcbnew/tools/pcbnew_control.cpp b/pcbnew/tools/pcbnew_control.cpp index 7484ec05f7..3929320e8a 100644 --- a/pcbnew/tools/pcbnew_control.cpp +++ b/pcbnew/tools/pcbnew_control.cpp @@ -594,6 +594,9 @@ int PCBNEW_CONTROL::GridSetOrigin( const TOOL_EVENT& aEvent ) } else { + if( m_editModules && !getEditFrame()->GetModel() ) + return 0; + Activate(); PICKER_TOOL* picker = m_toolMgr->GetTool(); @@ -683,6 +686,9 @@ static bool deleteItem( TOOL_MANAGER* aToolMgr, const VECTOR2D& aPosition ) int PCBNEW_CONTROL::DeleteItemCursor( const TOOL_EVENT& aEvent ) { + if( m_editModules && !m_frame->GetBoard()->m_Modules ) + return 0; + Activate(); PICKER_TOOL* picker = m_toolMgr->GetTool();