|
|
|
@ -646,17 +646,35 @@ int SCH_DRAWING_TOOLS::PlaceNextSymbolUnit( const TOOL_EVENT& aEvent ) |
|
|
|
|
|
|
|
int SCH_DRAWING_TOOLS::ImportSheet( const TOOL_EVENT& aEvent ) |
|
|
|
{ |
|
|
|
COMMON_SETTINGS* common_settings = Pgm().GetCommonSettings(); |
|
|
|
EESCHEMA_SETTINGS* cfg = m_frame->eeconfig(); |
|
|
|
SCHEMATIC_SETTINGS& schSettings = m_frame->Schematic().Settings(); |
|
|
|
SCH_SCREEN* screen = m_frame->GetScreen(); |
|
|
|
SCH_SHEET_PATH& sheetPath = m_frame->GetCurrentSheet(); |
|
|
|
|
|
|
|
KIGFX::VIEW_CONTROLS* controls = getViewControls(); |
|
|
|
EE_GRID_HELPER grid( m_toolMgr ); |
|
|
|
VECTOR2I cursorPos; |
|
|
|
|
|
|
|
if( !cfg || !common_settings ) |
|
|
|
return 0; |
|
|
|
|
|
|
|
if( m_inDrawingTool ) |
|
|
|
return 0; |
|
|
|
|
|
|
|
bool placingDesignBlock = aEvent.IsAction( &SCH_ACTIONS::placeDesignBlock ); |
|
|
|
|
|
|
|
DESIGN_BLOCK* designBlock = nullptr; |
|
|
|
std::unique_ptr<DESIGN_BLOCK> designBlock; |
|
|
|
wxString sheetFileName = wxEmptyString; |
|
|
|
|
|
|
|
if( placingDesignBlock ) |
|
|
|
{ |
|
|
|
if( m_frame->GetDesignBlockPane()->GetSelectedLibId().IsValid() ) |
|
|
|
SCH_DESIGN_BLOCK_PANE* designBlockPane = m_frame->GetDesignBlockPane(); |
|
|
|
|
|
|
|
if( designBlockPane->GetSelectedLibId().IsValid() ) |
|
|
|
{ |
|
|
|
designBlock = m_frame->GetDesignBlockPane()->GetDesignBlock( |
|
|
|
m_frame->GetDesignBlockPane()->GetSelectedLibId(), true, true ); |
|
|
|
designBlock.reset( designBlockPane->GetDesignBlock( designBlockPane->GetSelectedLibId(), |
|
|
|
true, true ) ); |
|
|
|
|
|
|
|
if( !designBlock ) |
|
|
|
return 0; |
|
|
|
@ -672,22 +690,6 @@ int SCH_DRAWING_TOOLS::ImportSheet( const TOOL_EVENT& aEvent ) |
|
|
|
sheetFileName = *importSourceFile; |
|
|
|
} |
|
|
|
|
|
|
|
COMMON_SETTINGS* common_settings = Pgm().GetCommonSettings(); |
|
|
|
EESCHEMA_SETTINGS* cfg = m_frame->eeconfig(); |
|
|
|
SCHEMATIC_SETTINGS& schSettings = m_frame->Schematic().Settings(); |
|
|
|
SCH_SCREEN* screen = m_frame->GetScreen(); |
|
|
|
SCH_SHEET_PATH& sheetPath = m_frame->GetCurrentSheet(); |
|
|
|
|
|
|
|
KIGFX::VIEW_CONTROLS* controls = getViewControls(); |
|
|
|
EE_GRID_HELPER grid( m_toolMgr ); |
|
|
|
VECTOR2I cursorPos; |
|
|
|
|
|
|
|
if( !cfg || !common_settings ) |
|
|
|
return 0; |
|
|
|
|
|
|
|
if( m_inDrawingTool ) |
|
|
|
return 0; |
|
|
|
|
|
|
|
auto setCursor = |
|
|
|
[&]() |
|
|
|
{ |
|
|
|
@ -875,9 +877,6 @@ int SCH_DRAWING_TOOLS::ImportSheet( const TOOL_EVENT& aEvent ) |
|
|
|
|
|
|
|
m_toolMgr->RunAction( ACTIONS::selectionClear ); |
|
|
|
m_view->ClearPreview(); |
|
|
|
delete designBlock; |
|
|
|
designBlock = nullptr; |
|
|
|
|
|
|
|
return 0; |
|
|
|
} |
|
|
|
|
|
|
|
@ -921,11 +920,12 @@ int SCH_DRAWING_TOOLS::ImportSheet( const TOOL_EVENT& aEvent ) |
|
|
|
{ |
|
|
|
if( placingDesignBlock ) |
|
|
|
{ |
|
|
|
m_toolMgr->PostAction( SCH_ACTIONS::drawSheetFromDesignBlock, designBlock ); |
|
|
|
// drawSheet must delete designBlock
|
|
|
|
m_toolMgr->PostAction( SCH_ACTIONS::drawSheetFromDesignBlock, designBlock.release() ); |
|
|
|
} |
|
|
|
else |
|
|
|
{ |
|
|
|
// drawSheet must delete
|
|
|
|
// drawSheet must delete sheetFileName
|
|
|
|
m_toolMgr->PostAction( SCH_ACTIONS::drawSheetFromFile, |
|
|
|
new wxString( sheetFileName ) ); |
|
|
|
} |
|
|
|
@ -2950,7 +2950,8 @@ int SCH_DRAWING_TOOLS::DrawSheet( const TOOL_EVENT& aEvent ) |
|
|
|
bool isDrawSheetCopy = aEvent.IsAction( &SCH_ACTIONS::drawSheetFromFile ); |
|
|
|
bool isDrawSheetFromDesignBlock = aEvent.IsAction( &SCH_ACTIONS::drawSheetFromDesignBlock ); |
|
|
|
|
|
|
|
DESIGN_BLOCK* designBlock = nullptr; |
|
|
|
std::unique_ptr<DESIGN_BLOCK> designBlock; |
|
|
|
|
|
|
|
SCH_SHEET* sheet = nullptr; |
|
|
|
wxString filename; |
|
|
|
|
|
|
|
@ -2965,7 +2966,7 @@ int SCH_DRAWING_TOOLS::DrawSheet( const TOOL_EVENT& aEvent ) |
|
|
|
} |
|
|
|
else if( isDrawSheetFromDesignBlock ) |
|
|
|
{ |
|
|
|
designBlock = aEvent.Parameter<DESIGN_BLOCK*>(); |
|
|
|
designBlock.reset( aEvent.Parameter<DESIGN_BLOCK*>() ); |
|
|
|
wxCHECK( designBlock, 0 ); |
|
|
|
filename = designBlock->GetSchematicFile(); |
|
|
|
} |
|
|
|
|