mirror of
https://gitlab.com/kicad/code/kicad.git
synced 2025-09-14 10:13:19 +02:00
design blocks: copy sheet to project dir instead of linking
This commit is contained in:
parent
074d858631
commit
018d02eb02
@ -51,12 +51,14 @@
|
|||||||
|
|
||||||
DIALOG_SHEET_PROPERTIES::DIALOG_SHEET_PROPERTIES( SCH_EDIT_FRAME* aParent, SCH_SHEET* aSheet,
|
DIALOG_SHEET_PROPERTIES::DIALOG_SHEET_PROPERTIES( SCH_EDIT_FRAME* aParent, SCH_SHEET* aSheet,
|
||||||
bool* aIsUndoable, bool* aClearAnnotationNewItems,
|
bool* aIsUndoable, bool* aClearAnnotationNewItems,
|
||||||
bool* aUpdateHierarchyNavigator ) :
|
bool* aUpdateHierarchyNavigator,
|
||||||
|
wxString* aSourceSheetFilename ) :
|
||||||
DIALOG_SHEET_PROPERTIES_BASE( aParent ),
|
DIALOG_SHEET_PROPERTIES_BASE( aParent ),
|
||||||
m_frame( aParent ),
|
m_frame( aParent ),
|
||||||
m_isUndoable( aIsUndoable ),
|
m_isUndoable( aIsUndoable ),
|
||||||
m_clearAnnotationNewItems( aClearAnnotationNewItems ),
|
m_clearAnnotationNewItems( aClearAnnotationNewItems ),
|
||||||
m_updateHierarchyNavigator( aUpdateHierarchyNavigator ),
|
m_updateHierarchyNavigator( aUpdateHierarchyNavigator ),
|
||||||
|
m_sourceSheetFilename( aSourceSheetFilename ),
|
||||||
m_borderWidth( aParent, m_borderWidthLabel, m_borderWidthCtrl, m_borderWidthUnits ),
|
m_borderWidth( aParent, m_borderWidthLabel, m_borderWidthCtrl, m_borderWidthUnits ),
|
||||||
m_dummySheet( *aSheet ),
|
m_dummySheet( *aSheet ),
|
||||||
m_dummySheetNameField( VECTOR2I( -1, -1 ), SHEETNAME, &m_dummySheet )
|
m_dummySheetNameField( VECTOR2I( -1, -1 ), SHEETNAME, &m_dummySheet )
|
||||||
@ -510,6 +512,21 @@ bool DIALOG_SHEET_PROPERTIES::onSheetFilenameChanged( const wxString& aNewFilena
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
// If we are drawing a sheet from a design block/sheet import, we need to copy the sheet to the current directory.
|
||||||
|
else if( m_sourceSheetFilename )
|
||||||
|
{
|
||||||
|
loadFromFile = true;
|
||||||
|
|
||||||
|
if( !wxCopyFile( *m_sourceSheetFilename, newAbsoluteFilename, false ) )
|
||||||
|
{
|
||||||
|
msg.Printf( _( "Failed to copy schematic file '%s' to destination '%s'." ),
|
||||||
|
currentScreenFileName.GetFullPath(), newAbsoluteFilename );
|
||||||
|
|
||||||
|
DisplayError( m_frame, msg );
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
else // New file.
|
else // New file.
|
||||||
{
|
{
|
||||||
m_frame->InitSheet( m_sheet, newAbsoluteFilename );
|
m_frame->InitSheet( m_sheet, newAbsoluteFilename );
|
||||||
|
@ -38,7 +38,8 @@ class DIALOG_SHEET_PROPERTIES : public DIALOG_SHEET_PROPERTIES_BASE
|
|||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
DIALOG_SHEET_PROPERTIES( SCH_EDIT_FRAME* aParent, SCH_SHEET* aSheet, bool* aIsUndoable,
|
DIALOG_SHEET_PROPERTIES( SCH_EDIT_FRAME* aParent, SCH_SHEET* aSheet, bool* aIsUndoable,
|
||||||
bool* aClearAnnotationNewItems, bool* aUpdateHierarchyNavigator );
|
bool* aClearAnnotationNewItems, bool* aUpdateHierarchyNavigator,
|
||||||
|
wxString* aSourceSheetFilename );
|
||||||
|
|
||||||
~DIALOG_SHEET_PROPERTIES() override;
|
~DIALOG_SHEET_PROPERTIES() override;
|
||||||
|
|
||||||
@ -68,6 +69,7 @@ private:
|
|||||||
bool* m_isUndoable;
|
bool* m_isUndoable;
|
||||||
bool* m_clearAnnotationNewItems;
|
bool* m_clearAnnotationNewItems;
|
||||||
bool* m_updateHierarchyNavigator;
|
bool* m_updateHierarchyNavigator;
|
||||||
|
wxString* m_sourceSheetFilename;
|
||||||
|
|
||||||
wxSize m_size;
|
wxSize m_size;
|
||||||
int m_delayedFocusRow;
|
int m_delayedFocusRow;
|
||||||
|
@ -578,10 +578,12 @@ public:
|
|||||||
* of a already existing sheet.
|
* of a already existing sheet.
|
||||||
* @param aUpdateHierarchyNavigator is an optional flag to indicate the sheet changes require
|
* @param aUpdateHierarchyNavigator is an optional flag to indicate the sheet changes require
|
||||||
* the hierarchy navigator panel to be updated.
|
* the hierarchy navigator panel to be updated.
|
||||||
|
* @param aSourceSheetFilename is an optional filename to copy the new sheet from
|
||||||
*/
|
*/
|
||||||
bool EditSheetProperties( SCH_SHEET* aSheet, SCH_SHEET_PATH* aHierarchy,
|
bool EditSheetProperties( SCH_SHEET* aSheet, SCH_SHEET_PATH* aHierarchy,
|
||||||
bool* aIsUndoable = nullptr, bool* aClearAnnotationNewItems = nullptr,
|
bool* aIsUndoable = nullptr, bool* aClearAnnotationNewItems = nullptr,
|
||||||
bool* aUpdateHierarchyNavigator = nullptr );
|
bool* aUpdateHierarchyNavigator = nullptr,
|
||||||
|
wxString* aSourceSheetFilename = nullptr );
|
||||||
|
|
||||||
void InitSheet( SCH_SHEET* aSheet, const wxString& aNewFilename );
|
void InitSheet( SCH_SHEET* aSheet, const wxString& aNewFilename );
|
||||||
|
|
||||||
|
@ -598,14 +598,15 @@ bool SCH_EDIT_FRAME::LoadSheetFromFile( SCH_SHEET* aSheet, SCH_SHEET_PATH* aCurr
|
|||||||
|
|
||||||
bool SCH_EDIT_FRAME::EditSheetProperties( SCH_SHEET* aSheet, SCH_SHEET_PATH* aHierarchy,
|
bool SCH_EDIT_FRAME::EditSheetProperties( SCH_SHEET* aSheet, SCH_SHEET_PATH* aHierarchy,
|
||||||
bool* aIsUndoable, bool* aClearAnnotationNewItems,
|
bool* aIsUndoable, bool* aClearAnnotationNewItems,
|
||||||
bool* aUpdateHierarchyNavigator )
|
bool* aUpdateHierarchyNavigator,
|
||||||
|
wxString* aSourceSheetFilename )
|
||||||
{
|
{
|
||||||
if( aSheet == nullptr || aHierarchy == nullptr )
|
if( aSheet == nullptr || aHierarchy == nullptr )
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
// Get the new texts
|
// Get the new texts
|
||||||
DIALOG_SHEET_PROPERTIES dlg( this, aSheet, aIsUndoable, aClearAnnotationNewItems,
|
DIALOG_SHEET_PROPERTIES dlg( this, aSheet, aIsUndoable, aClearAnnotationNewItems,
|
||||||
aUpdateHierarchyNavigator );
|
aUpdateHierarchyNavigator, aSourceSheetFilename );
|
||||||
|
|
||||||
if( dlg.ShowModal() == wxID_CANCEL )
|
if( dlg.ShowModal() == wxID_CANCEL )
|
||||||
return false;
|
return false;
|
||||||
|
@ -2966,8 +2966,11 @@ int SCH_DRAWING_TOOLS::DrawSheet( const TOOL_EVENT& aEvent )
|
|||||||
}
|
}
|
||||||
else if( isDrawSheetFromDesignBlock )
|
else if( isDrawSheetFromDesignBlock )
|
||||||
{
|
{
|
||||||
|
wxFileName fn( filename );
|
||||||
|
|
||||||
sheet->GetFields()[SHEETNAME].SetText( designBlock->GetLibId().GetLibItemName() );
|
sheet->GetFields()[SHEETNAME].SetText( designBlock->GetLibId().GetLibItemName() );
|
||||||
sheet->GetFields()[SHEETFILENAME].SetText( designBlock->GetSchematicFile() );
|
sheet->GetFields()[SHEETFILENAME].SetText( fn.GetName() + wxT( "." )
|
||||||
|
+ FILEEXT::KiCadSchematicFileExtension );
|
||||||
|
|
||||||
std::vector<SCH_FIELD>& sheetFields = sheet->GetFields();
|
std::vector<SCH_FIELD>& sheetFields = sheet->GetFields();
|
||||||
|
|
||||||
@ -3016,7 +3019,8 @@ int SCH_DRAWING_TOOLS::DrawSheet( const TOOL_EVENT& aEvent )
|
|||||||
getViewControls()->CaptureCursor( false );
|
getViewControls()->CaptureCursor( false );
|
||||||
|
|
||||||
if( m_frame->EditSheetProperties( static_cast<SCH_SHEET*>( sheet ),
|
if( m_frame->EditSheetProperties( static_cast<SCH_SHEET*>( sheet ),
|
||||||
&m_frame->GetCurrentSheet() ) )
|
&m_frame->GetCurrentSheet(), nullptr, nullptr,
|
||||||
|
nullptr, &filename ) )
|
||||||
{
|
{
|
||||||
m_view->ClearPreview();
|
m_view->ClearPreview();
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user