diff --git a/common/eda_draw_frame.cpp b/common/eda_draw_frame.cpp index ff25315bef..70c54ee459 100644 --- a/common/eda_draw_frame.cpp +++ b/common/eda_draw_frame.cpp @@ -869,7 +869,3 @@ bool EDA_DRAW_FRAME::LibraryFileBrowser( bool doOpen, wxFileName& aFilename, } -bool EDA_DRAW_FRAME::saveCanvasImageToFile( const wxString& aFileName, wxBitmapType aBitmapType ) -{ - return SaveCanvasImageToFile( this, aFileName, aBitmapType ); -} diff --git a/eeschema/CMakeLists.txt b/eeschema/CMakeLists.txt index 6850a16d35..b375d45f0b 100644 --- a/eeschema/CMakeLists.txt +++ b/eeschema/CMakeLists.txt @@ -130,7 +130,7 @@ set( EESCHEMA_SRCS sch_painter.cpp annotate.cpp autoplace_fields.cpp - backanno.cpp + tools/backanno.cpp bus_alias.cpp bus-wire-junction.cpp class_libentry.cpp diff --git a/eeschema/cross-probing.cpp b/eeschema/cross-probing.cpp index f502ea8e0a..7c8bfdaaae 100644 --- a/eeschema/cross-probing.cpp +++ b/eeschema/cross-probing.cpp @@ -42,6 +42,7 @@ #include #include #include +#include /** * Execute a remote command sent by Pcbnew via a socket connection. @@ -302,7 +303,8 @@ void SCH_EDIT_FRAME::KiwayMailIn( KIWAY_EXPRESS& mail ) case MAIL_BACKANNOTATE_FOOTPRINTS: try { - backAnnotateFootprints( payload ); + SCH_EDITOR_CONTROL* controlTool = m_toolManager->GetTool(); + controlTool->BackAnnotateFootprints( payload ); } catch( const IO_ERROR& DBG( ioe ) ) { diff --git a/eeschema/eeschema_id.h b/eeschema/eeschema_id.h index ec7f21a800..75e085313b 100644 --- a/eeschema/eeschema_id.h +++ b/eeschema/eeschema_id.h @@ -61,7 +61,6 @@ enum id_eeschema_frm ID_REMAP_SYMBOLS, /* Schematic editor horizontal toolbar IDs */ - ID_BACKANNO_ITEMS, ID_ADD_PART_TO_SCHEMATIC, /* Library editor horizontal toolbar IDs. */ diff --git a/eeschema/libedit/lib_edit_frame.cpp b/eeschema/libedit/lib_edit_frame.cpp index 83b4352bbf..a64dd32644 100644 --- a/eeschema/libedit/lib_edit_frame.cpp +++ b/eeschema/libedit/lib_edit_frame.cpp @@ -95,8 +95,6 @@ BEGIN_EVENT_TABLE( LIB_EDIT_FRAME, EDA_DRAW_FRAME ) // menubar commands EVT_MENU( wxID_EXIT, LIB_EDIT_FRAME::CloseWindow ) - EVT_MENU( ID_LIBEDIT_GEN_PNG_FILE, LIB_EDIT_FRAME::OnPlotCurrentComponent ) - EVT_MENU( ID_LIBEDIT_GEN_SVG_FILE, LIB_EDIT_FRAME::OnPlotCurrentComponent ) EVT_MENU( ID_GRID_SETTINGS, SCH_BASE_FRAME::OnGridSettings ) // Update user interface elements. diff --git a/eeschema/libedit/lib_edit_frame.h b/eeschema/libedit/lib_edit_frame.h index 43eaa8bfb6..d7b7416b7f 100644 --- a/eeschema/libedit/lib_edit_frame.h +++ b/eeschema/libedit/lib_edit_frame.h @@ -197,10 +197,6 @@ public: */ bool SynchronizePins(); - /** - * Plot the current symbol in SVG or PNG format. - */ - void OnPlotCurrentComponent( wxCommandEvent& event ); void OnSyncPinEditClick( wxCommandEvent& event ); void OnImportBody( wxCommandEvent& aEvent ); @@ -423,14 +419,6 @@ public: */ bool LoadComponentAndSelectLib( const LIB_ID& aLibId, int aUnit, int aConvert ); - /** - * Creates an image (screenshot) of the current symbol. - * - * @param aFileName = the full filename - * @param aBitmapType = bitmap file format - */ - void CreateImageFile( const wxString& aFileName, wxBitmapType aBitmapType = wxBITMAP_TYPE_PNG ); - /** * Print a page * diff --git a/eeschema/libedit/libedit_plot_component.cpp b/eeschema/libedit/libedit_plot_component.cpp index 93b263b9a8..6847fa11a7 100644 --- a/eeschema/libedit/libedit_plot_component.cpp +++ b/eeschema/libedit/libedit_plot_component.cpp @@ -1,11 +1,7 @@ -/** - * @file libedit_plot_component.cpp - */ - /* * This program source code file is part of KiCad, a free EDA CAD application. * - * Copyright (C) 1992-2018 KiCad Developers, see AUTHORS.txt for contributors. + * Copyright (C) 1992-2019 KiCad Developers, see AUTHORS.txt for contributors. * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License @@ -27,103 +23,13 @@ #include - #include -#include #include -#include -#include -#include #include -#include - #include #include #include -#include - - -void LIB_EDIT_FRAME::OnPlotCurrentComponent( wxCommandEvent& event ) -{ - wxString fullFileName; - wxString file_ext; - wxString mask; - - LIB_PART* part = GetCurPart(); - - if( !part ) - { - wxMessageBox( _( "No component" ) ); - return; - } - - switch( event.GetId() ) - { - case ID_LIBEDIT_GEN_PNG_FILE: - { - mask = wxT( "*." ) + file_ext; - wxFileName fn( part->GetName() ); - fn.SetExt( "png" ); - - wxString projectPath = wxPathOnly( Prj().GetProjectFullName() ); - - wxFileDialog dlg( this, _( "Image File Name" ), projectPath, - fn.GetFullName(), PngFileWildcard(), wxFD_SAVE | wxFD_OVERWRITE_PROMPT ); - - if( dlg.ShowModal() == wxID_CANCEL || dlg.GetPath().IsEmpty() ) - return; - - // calling wxYield is mandatory under Linux, after closing the file selector dialog - // to refresh the screen before creating the PNG or JPEG image from screen - wxYield(); - CreateImageFile( dlg.GetPath(), wxBITMAP_TYPE_PNG ); - } - break; - - case ID_LIBEDIT_GEN_SVG_FILE: - { - file_ext = wxT( "svg" ); - mask = wxT( "*." ) + file_ext; - wxFileName fn( part->GetName() ); - fn.SetExt( file_ext ); - - wxString pro_dir = wxPathOnly( Prj().GetProjectFullName() ); - - fullFileName = EDA_FILE_SELECTOR( _( "Filename:" ), pro_dir, - fn.GetFullName(), file_ext, mask, this, - wxFD_SAVE, true ); - - if( fullFileName.IsEmpty() ) - return; - - PAGE_INFO pageSave = GetScreen()->GetPageSettings(); - PAGE_INFO pageTemp = pageSave; - - wxSize componentSize = part->GetUnitBoundingBox( m_unit, m_convert ).GetSize(); - - // Add a small margin to the plot bounding box - pageTemp.SetWidthMils( int( componentSize.x * 1.2 ) ); - pageTemp.SetHeightMils( int( componentSize.y * 1.2 ) ); - - GetScreen()->SetPageSettings( pageTemp ); - SVG_PlotComponent( fullFileName ); - GetScreen()->SetPageSettings( pageSave ); - } - break; - } -} - - -void LIB_EDIT_FRAME::CreateImageFile( const wxString& aFileName, wxBitmapType aBitmapType ) -{ - if( !saveCanvasImageToFile( aFileName, aBitmapType ) ) - { - wxString msg; - msg.Printf( _( "Can't save file \"%s\"." ), aFileName ); - wxMessageBox( msg ); - } -} - +#include void LIB_EDIT_FRAME::SVG_PlotComponent( const wxString& aFullFileName ) { diff --git a/eeschema/libedit/menubar_libedit.cpp b/eeschema/libedit/menubar_libedit.cpp index a4fbdc547c..dbd5036bcd 100644 --- a/eeschema/libedit/menubar_libedit.cpp +++ b/eeschema/libedit/menubar_libedit.cpp @@ -76,15 +76,9 @@ void LIB_EDIT_FRAME::ReCreateMenuBar() submenuExport->SetTool( selTool ); submenuExport->SetTitle( _( "Export" ) ); submenuExport->SetIcon( export_xpm ); - submenuExport->Add( EE_ACTIONS::exportSymbol ); - submenuExport->Add( _( "View as PNG..." ), - _( "Create a PNG file from the current view" ), - ID_LIBEDIT_GEN_PNG_FILE, plot_xpm ); - submenuExport->Add( _( "Symbol as SVG..." ), - _( "Create a SVG file from the current symbol" ), - ID_LIBEDIT_GEN_SVG_FILE, plot_svg_xpm ); - + submenuExport->Add( EE_ACTIONS::exportSymbolView ); + submenuExport->Add( EE_ACTIONS::exportSymbolAsSVG ); fileMenu->AddMenu( submenuExport, EE_CONDITIONS::ShowAlways ); fileMenu->AddSeparator(); diff --git a/eeschema/menubar.cpp b/eeschema/menubar.cpp index e2a72deacf..007496bcda 100644 --- a/eeschema/menubar.cpp +++ b/eeschema/menubar.cpp @@ -96,11 +96,7 @@ void SCH_EDIT_FRAME::ReCreateMenuBar() submenuImport->SetTool( selTool ); submenuImport->SetTitle( _( "Import" ) ); submenuImport->SetIcon( import_xpm ); - - submenuImport->Add( _( "Footprint Association File..." ), - _( "Back-import symbol footprint associations from .cmp file created by Pcbnew" ), - ID_BACKANNO_ITEMS, import_footprint_names_xpm ); - + submenuImport->Add( EE_ACTIONS::importFPAssignments ); fileMenu->AddMenu( submenuImport, EE_CONDITIONS::ShowAlways ); @@ -109,11 +105,8 @@ void SCH_EDIT_FRAME::ReCreateMenuBar() submenuExport->SetTool( selTool ); submenuExport->SetTitle( _( "Export" ) ); submenuExport->SetIcon( export_xpm ); - - submenuExport->Add( _( "Drawing to Clipboard" ), _( "Export drawings to clipboard" ), - ID_GEN_COPY_SHEET_TO_CLIPBOARD, copy_xpm ); + submenuExport->Add( EE_ACTIONS::drawSheetOnClipboard ); submenuExport->Add( EE_ACTIONS::exportNetlist ); - fileMenu->AddMenu( submenuExport, EE_CONDITIONS::ShowAlways ); fileMenu->AddSeparator(); @@ -271,11 +264,11 @@ void SCH_EDIT_FRAME::ReCreateMenuBar() toolsMenu->AddSeparator(); toolsMenu->AddItem( ACTIONS::showSymbolEditor, EE_CONDITIONS::ShowAlways ); - toolsMenu->AddItem( ID_RESCUE_CACHED, _( "&Rescue Symbols..." ), + toolsMenu->AddItem( ID_RESCUE_CACHED, _( "Rescue Symbols..." ), _( "Find old symbols in project and rename/rescue them" ), rescue_xpm, EE_CONDITIONS::ShowAlways ); - toolsMenu->AddItem( ID_REMAP_SYMBOLS, _( "Remap S&ymbols..." ), + toolsMenu->AddItem( ID_REMAP_SYMBOLS, _( "Remap Symbols..." ), _( "Remap legacy library symbols to symbol library table" ), rescue_xpm, remapSymbolsCondition ); diff --git a/eeschema/sch_edit_frame.cpp b/eeschema/sch_edit_frame.cpp index b7c942f9a1..026be726ca 100644 --- a/eeschema/sch_edit_frame.cpp +++ b/eeschema/sch_edit_frame.cpp @@ -221,13 +221,11 @@ BEGIN_EVENT_TABLE( SCH_EDIT_FRAME, EDA_DRAW_FRAME ) EVT_MENU( ID_APPEND_PROJECT, SCH_EDIT_FRAME::OnAppendProject ) EVT_MENU( ID_IMPORT_NON_KICAD_SCH, SCH_EDIT_FRAME::OnImportProject ) - EVT_MENU( ID_GEN_COPY_SHEET_TO_CLIPBOARD, SCH_EDIT_FRAME::DrawCurrentSheetToClipboard ) EVT_MENU( wxID_EXIT, SCH_EDIT_FRAME::OnExit ) EVT_TOOL( ID_RESCUE_CACHED, SCH_EDIT_FRAME::OnRescueProject ) EVT_MENU( ID_REMAP_SYMBOLS, SCH_EDIT_FRAME::OnRemapSymbols ) - EVT_TOOL( ID_BACKANNO_ITEMS, SCH_EDIT_FRAME::OnLoadCmpToFootprintLinkFile ) EVT_MENU( ID_GRID_SETTINGS, SCH_BASE_FRAME::OnGridSettings ) END_EVENT_TABLE() @@ -746,13 +744,6 @@ void SCH_EDIT_FRAME::OnLoadFile( wxCommandEvent& event ) } -void SCH_EDIT_FRAME::OnLoadCmpToFootprintLinkFile( wxCommandEvent& event ) -{ - LoadCmpToFootprintLinkFile(); - GetCanvas()->Refresh(); -} - - void SCH_EDIT_FRAME::NewProject() { wxString pro_dir = m_mruPath; diff --git a/eeschema/sch_edit_frame.h b/eeschema/sch_edit_frame.h index af1e2d01a7..6201876f52 100644 --- a/eeschema/sch_edit_frame.h +++ b/eeschema/sch_edit_frame.h @@ -178,8 +178,6 @@ protected: */ virtual bool isAutoSaveRequired() const override; - void backAnnotateFootprints( const std::string& aChangedSetOfReferences ); - /** * Verify that annotation is complete so that a proper netlist is even * possible. If not, asks the user if annotation should be done. @@ -647,38 +645,6 @@ public: */ bool AppendSchematic(); - /** - * Loads a .cmp file from CvPcb and update the footprint field of components. - * - * Prepares parameters and calls ProcessCmpToFootprintLinkFileto actually read the file and - * update the footprint fields - */ - bool LoadCmpToFootprintLinkFile(); - - /** - * Read the footprint info from each line in the stuff file by reference designator. - * - * The footprint link file (.cmp) entries created by CvPcb: - * - * BeginCmp - * TimeStamp = /32307DE2/AA450F67; - * Reference = C1; - * ValeurCmp = 47uF; - * IdModule = CP6; - * EndCmp - * - * @param aFullFilename = the full filename to read - * @param aForceVisibilityState = Set to true to change the footprint field visibility - * state to \a aVisibilityState. False retains the - * current footprint field visibility state. - * @param aVisibilityState True to show the footprint field or false to hide the footprint - * field if \a aForceVisibilityState is true. - * @return bool = true if success. - */ - bool ProcessCmpToFootprintLinkFile( const wxString& aFullFilename, - bool aForceVisibilityState, - bool aVisibilityState ); - /** * Save \a aScreen to a schematic file. * @@ -755,7 +721,6 @@ private: void OnExit( wxCommandEvent& event ); void OnLoadFile( wxCommandEvent& event ); - void OnLoadCmpToFootprintLinkFile( wxCommandEvent& event ); void OnAppendProject( wxCommandEvent& event ); void OnImportProject( wxCommandEvent& event ); diff --git a/eeschema/toolbars_sch_editor.cpp b/eeschema/toolbars_sch_editor.cpp index edd10ee3f2..112aacfe0a 100644 --- a/eeschema/toolbars_sch_editor.cpp +++ b/eeschema/toolbars_sch_editor.cpp @@ -95,10 +95,7 @@ void SCH_EDIT_FRAME::ReCreateHToolbar() KiScaledSeparator( m_mainToolBar, this ); m_mainToolBar->Add( EE_ACTIONS::showPcbNew ); - - m_mainToolBar->AddTool( ID_BACKANNO_ITEMS, wxEmptyString, - KiScaledBitmap( import_footprint_names_xpm, this ), - _( "Back-import symbol footprint associations from .cmp file created by Pcbnew" ) ); + m_mainToolBar->Add( EE_ACTIONS::importFPAssignments ); // after adding the tools to the toolbar, must call Realize() to reflect the changes m_mainToolBar->Realize(); diff --git a/eeschema/backanno.cpp b/eeschema/tools/backanno.cpp similarity index 84% rename from eeschema/backanno.cpp rename to eeschema/tools/backanno.cpp index b060f0386e..16c004ae8f 100644 --- a/eeschema/backanno.cpp +++ b/eeschema/tools/backanno.cpp @@ -3,7 +3,7 @@ * * Copyright (C) 2015 Jean-Pierre Charras, jp.charras at wanadoo.fr * Copyright (C) 2008 Wayne Stambaugh - * Copyright (C) 2004-2017 KiCad Developers, see AUTHORS.txt for contributors. + * Copyright (C) 2004-2019 KiCad Developers, see AUTHORS.txt for contributors. * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License @@ -23,11 +23,6 @@ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA */ -/** - * @file backanno.cpp - * @brief Functions for backannotating footprint information. - */ - #include #include #include @@ -36,19 +31,19 @@ #include #include #include - #include #include #include #include - #include #include #include #include +#include +#include -void SCH_EDIT_FRAME::backAnnotateFootprints( const std::string& aChangedSetOfReferences ) +void SCH_EDITOR_CONTROL::BackAnnotateFootprints( const std::string& aChangedSetOfReferences ) { // Build a flat list of components in schematic: SCH_REFERENCE_LIST refs; @@ -57,8 +52,8 @@ void SCH_EDIT_FRAME::backAnnotateFootprints( const std::string& aChangedSetOfRef sheets.GetComponents( refs, false ); - DSNLEXER lexer( aChangedSetOfReferences, FROM_UTF8( __func__ ) ); - PTREE doc; + DSNLEXER lexer( aChangedSetOfReferences, FROM_UTF8( __func__ ) ); + PTREE doc; try { @@ -102,9 +97,7 @@ void SCH_EDIT_FRAME::backAnnotateFootprints( const std::string& aChangedSetOfRef const wxString& oldfp = fpfield->GetText(); if( !oldfp && fpfield->IsVisible() ) - { fpfield->SetVisible( false ); - } if( oldfp != footprint ) isChanged = true; @@ -122,16 +115,16 @@ void SCH_EDIT_FRAME::backAnnotateFootprints( const std::string& aChangedSetOfRef if( isChanged ) { - SyncView(); - GetCanvas()->Refresh(); - OnModify(); + m_frame->SyncView(); + m_frame->GetCanvas()->Refresh(); + m_frame->OnModify(); } } -bool SCH_EDIT_FRAME::ProcessCmpToFootprintLinkFile( const wxString& aFullFilename, - bool aForceVisibilityState, - bool aVisibilityState ) +bool SCH_EDITOR_CONTROL::processCmpToFootprintLinkFile( const wxString& aFullFilename, + bool aForceVisibilityState, + bool aVisibilityState ) { // Build a flat list of components in schematic: SCH_REFERENCE_LIST referencesList; @@ -179,13 +172,9 @@ bool SCH_EDIT_FRAME::ProcessCmpToFootprintLinkFile( const wxString& aFullFilenam value.Trim(false); if( buffer.StartsWith( wxT( "Reference" ) ) ) - { reference = value; - } else if( buffer.StartsWith( wxT( "IdModule" ) ) ) - { footprint = value; - } } // A block is read: initialize the footprint field of the corresponding component @@ -207,9 +196,7 @@ bool SCH_EDIT_FRAME::ProcessCmpToFootprintLinkFile( const wxString& aFullFilenam fpfield->SetText( footprint ); if( aForceVisibilityState ) - { component->GetField( FOOTPRINT )->SetVisible( aVisibilityState ); - } } } } @@ -218,17 +205,17 @@ bool SCH_EDIT_FRAME::ProcessCmpToFootprintLinkFile( const wxString& aFullFilenam } -bool SCH_EDIT_FRAME::LoadCmpToFootprintLinkFile() +int SCH_EDITOR_CONTROL::ImportFPAssignments( const TOOL_EVENT& aEvent ) { - wxString path = wxPathOnly( Prj().GetProjectFullName() ); + wxString path = wxPathOnly( m_frame->Prj().GetProjectFullName() ); - wxFileDialog dlg( this, _( "Load Symbol Footprint Link File" ), + wxFileDialog dlg( m_frame, _( "Load Symbol Footprint Link File" ), path, wxEmptyString, ComponentFileWildcard(), wxFD_OPEN | wxFD_FILE_MUST_EXIST ); if( dlg.ShowModal() == wxID_CANCEL ) - return false; + return 0; wxString filename = dlg.GetPath(); @@ -237,27 +224,26 @@ bool SCH_EDIT_FRAME::LoadCmpToFootprintLinkFile() choices.Add( _( "Show all footprint fields" ) ); choices.Add( _( "Hide all footprint fields" ) ); - wxSingleChoiceDialog choiceDlg( this, _( "Select the footprint field visibility setting." ), + wxSingleChoiceDialog choiceDlg( m_frame, _( "Select the footprint field visibility setting." ), _( "Change Visibility" ), choices ); - if( choiceDlg.ShowModal() == wxID_CANCEL ) - return false; + return 0; bool forceVisibility = (choiceDlg.GetSelection() != 0 ); bool visibilityState = (choiceDlg.GetSelection() == 1 ); - if( !ProcessCmpToFootprintLinkFile( filename, forceVisibility, visibilityState ) ) + if( !processCmpToFootprintLinkFile( filename, forceVisibility, visibilityState ) ) { wxString msg = wxString::Format( _( "Failed to open component-footprint link file \"%s\"" ), filename.GetData() ); - DisplayError( this, msg ); - return false; + DisplayError( m_frame, msg ); + return 0; } - SyncView(); - GetCanvas()->Refresh(); - OnModify(); - return true; + m_frame->SyncView(); + m_frame->GetCanvas()->Refresh(); + m_frame->OnModify(); + return 0; } diff --git a/eeschema/tools/ee_actions.h b/eeschema/tools/ee_actions.h index cc8c1530ed..baab2dd415 100644 --- a/eeschema/tools/ee_actions.h +++ b/eeschema/tools/ee_actions.h @@ -92,6 +92,7 @@ public: static TOOL_ACTION placeSchematicText; static TOOL_ACTION drawLines; static TOOL_ACTION placeImage; + static TOOL_ACTION deleteItemCursor; static TOOL_ACTION finishLineWireOrBus; static TOOL_ACTION finishWire; static TOOL_ACTION finishBus; @@ -144,6 +145,7 @@ public: static TOOL_ACTION annotate; static TOOL_ACTION editSymbolFields; static TOOL_ACTION editSymbolLibraryLinks; + static TOOL_ACTION symbolProperties; static TOOL_ACTION pinTable; static TOOL_ACTION updateFieldsFromLibrary; static TOOL_ACTION assignFootprints; @@ -152,6 +154,7 @@ public: // Suite operations static TOOL_ACTION editWithLibEdit; static TOOL_ACTION showPcbNew; + static TOOL_ACTION importFPAssignments; static TOOL_ACTION exportNetlist; static TOOL_ACTION generateBOM; static TOOL_ACTION runSimulation; @@ -175,8 +178,6 @@ public: // Miscellaneous static TOOL_ACTION cleanupSheetPins; static TOOL_ACTION toggleHiddenPins; - static TOOL_ACTION symbolProperties; - static TOOL_ACTION deleteItemCursor; static TOOL_ACTION refreshPreview; static TOOL_ACTION restartMove; static TOOL_ACTION explicitCrossProbe; @@ -186,6 +187,9 @@ public: static TOOL_ACTION showElectricalTypes; static TOOL_ACTION showComponentTree; static TOOL_ACTION toggleForceHV; + static TOOL_ACTION drawSheetOnClipboard; + static TOOL_ACTION exportSymbolView; + static TOOL_ACTION exportSymbolAsSVG; // SPICE static TOOL_ACTION simProbe; diff --git a/eeschema/tools/lib_control.cpp b/eeschema/tools/lib_control.cpp index 613f2b7969..64f57c7cbc 100644 --- a/eeschema/tools/lib_control.cpp +++ b/eeschema/tools/lib_control.cpp @@ -29,7 +29,10 @@ #include #include #include - +#include +#include +#include +#include TOOL_ACTION EE_ACTIONS::newSymbol( "eeschema.SymbolLibraryControl.newSymbol", AS_GLOBAL, 0, "", @@ -81,12 +84,21 @@ TOOL_ACTION EE_ACTIONS::showElectricalTypes( "eeschema.SymbolLibraryControl.show _( "Show Pin Electrical Types" ), _( "Annotate pins with their electrical types" ), pin_show_etype_xpm ); - TOOL_ACTION EE_ACTIONS::showComponentTree( "eeschema.SymbolLibraryControl.showComponentTree", AS_GLOBAL, 0, "", _( "Show Symbol Tree" ), "", search_tree_xpm ); +TOOL_ACTION EE_ACTIONS::exportSymbolView( "eeschema.SymbolLibraryControl.exportSymbolView", + AS_GLOBAL, 0, "", + _( "Export View as PNG..." ), _( "Create PNG file from the current view" ), + plot_xpm ); + +TOOL_ACTION EE_ACTIONS::exportSymbolAsSVG( "eeschema.SymbolLibraryControl.exportSymbolAsSVG", + AS_GLOBAL, 0, "", + _( "Export Symbol as SVG..." ), _( "Create SVG file from the current symbol" ), + plot_svg_xpm ); + bool LIB_CONTROL::Init() { @@ -297,6 +309,91 @@ int LIB_CONTROL::ShowElectricalTypes( const TOOL_EVENT& aEvent ) } +int LIB_CONTROL::ExportView( const TOOL_EVENT& aEvent ) +{ + if( !m_isLibEdit ) + return 0; + + LIB_EDIT_FRAME* editFrame = getEditFrame(); + LIB_PART* part = editFrame->GetCurPart(); + + if( !part ) + { + wxMessageBox( _( "No symbol to export" ) ); + return 0; + } + + wxString file_ext = wxT( "png" ); + wxString mask = wxT( "*." ) + file_ext; + wxFileName fn( part->GetName() ); + fn.SetExt( "png" ); + + wxString projectPath = wxPathOnly( m_frame->Prj().GetProjectFullName() ); + + wxFileDialog dlg( editFrame, _( "Image File Name" ), projectPath, fn.GetFullName(), + PngFileWildcard(), wxFD_SAVE | wxFD_OVERWRITE_PROMPT ); + + if( dlg.ShowModal() == wxID_OK && !dlg.GetPath().IsEmpty() ) + { + // calling wxYield is mandatory under Linux, after closing the file selector dialog + // to refresh the screen before creating the PNG or JPEG image from screen + wxYield(); + + if( !SaveCanvasImageToFile( editFrame, dlg.GetPath(), wxBITMAP_TYPE_PNG ) ) + { + wxMessageBox( wxString::Format( _( "Can't save file \"%s\"." ), dlg.GetPath() ) ); + } + } + + return 0; +} + + +int LIB_CONTROL::ExportSymbolAsSVG( const TOOL_EVENT& aEvent ) +{ + if( !m_isLibEdit ) + return 0; + + LIB_EDIT_FRAME* editFrame = getEditFrame(); + LIB_PART* part = editFrame->GetCurPart(); + + if( !part ) + { + wxMessageBox( _( "No symbol to export" ) ); + return 0; + } + + wxString file_ext = wxT( "svg" ); + wxString mask = wxT( "*." ) + file_ext; + wxFileName fn( part->GetName() ); + fn.SetExt( file_ext ); + + wxString pro_dir = wxPathOnly( m_frame->Prj().GetProjectFullName() ); + + wxString fullFileName = EDA_FILE_SELECTOR( _( "Filename:" ), pro_dir, fn.GetFullName(), + file_ext, mask, m_frame, wxFD_SAVE, true ); + + if( !fullFileName.IsEmpty() ) + { + PAGE_INFO pageSave = editFrame->GetScreen()->GetPageSettings(); + PAGE_INFO pageTemp = pageSave; + + wxSize componentSize = part->GetUnitBoundingBox( editFrame->GetUnit(), + editFrame->GetConvert() ).GetSize(); + + // Add a small margin to the plot bounding box + pageTemp.SetWidthMils( int( componentSize.x * 1.2 ) ); + pageTemp.SetHeightMils( int( componentSize.y * 1.2 ) ); + + editFrame->GetScreen()->SetPageSettings( pageTemp ); + editFrame->SVG_PlotComponent( fullFileName ); + editFrame->GetScreen()->SetPageSettings( pageSave ); + } + + return 0; +} + + void LIB_CONTROL::setTransitions() { Go( &LIB_CONTROL::AddLibrary, ACTIONS::newLibrary.MakeEvent() ); @@ -317,6 +414,8 @@ void LIB_CONTROL::setTransitions() Go( &LIB_CONTROL::CutCopyDelete, EE_ACTIONS::copySymbol.MakeEvent() ); Go( &LIB_CONTROL::DuplicateSymbol, EE_ACTIONS::pasteSymbol.MakeEvent() ); Go( &LIB_CONTROL::ExportSymbol, EE_ACTIONS::exportSymbol.MakeEvent() ); + Go( &LIB_CONTROL::ExportView, EE_ACTIONS::exportSymbolView.MakeEvent() ); + Go( &LIB_CONTROL::ExportSymbolAsSVG, EE_ACTIONS::exportSymbolAsSVG.MakeEvent() ); Go( &LIB_CONTROL::OnDeMorgan, EE_ACTIONS::showDeMorganStandard.MakeEvent() ); Go( &LIB_CONTROL::OnDeMorgan, EE_ACTIONS::showDeMorganAlternate.MakeEvent() ); diff --git a/eeschema/tools/lib_control.h b/eeschema/tools/lib_control.h index 63ec658d3c..82a9e15ef1 100644 --- a/eeschema/tools/lib_control.h +++ b/eeschema/tools/lib_control.h @@ -57,6 +57,8 @@ public: int CutCopyDelete( const TOOL_EVENT& aEvent ); int DuplicateSymbol( const TOOL_EVENT& aEvent ); int ExportSymbol( const TOOL_EVENT& aEvent ); + int ExportView( const TOOL_EVENT& aEvent ); + int ExportSymbolAsSVG( const TOOL_EVENT& aEvent ); int OnDeMorgan( const TOOL_EVENT& aEvent ); diff --git a/eeschema/tools/sch_editor_control.cpp b/eeschema/tools/sch_editor_control.cpp index 62910a785f..86b4703398 100644 --- a/eeschema/tools/sch_editor_control.cpp +++ b/eeschema/tools/sch_editor_control.cpp @@ -100,6 +100,12 @@ TOOL_ACTION EE_ACTIONS::assignFootprints( "eeschema.EditorControl.assignFootprin _( "Assign Footprints..." ), _( "Run Cvpcb" ), cvpcb_xpm ); +TOOL_ACTION EE_ACTIONS::importFPAssignments( "eeschema.EditorControl.importFPAssignments", + AS_GLOBAL, 0, "", + _( "Import Footprint Assignments..." ), + _( "Import symbol footprint assignments from .cmp file created by Pcbnew" ), + import_footprint_names_xpm ); + TOOL_ACTION EE_ACTIONS::annotate( "eeschema.EditorControl.annotate", AS_GLOBAL, 0, "", _( "Annotate Schematic..." ), _( "Fill in schematic symbol reference designators" ), @@ -110,6 +116,11 @@ TOOL_ACTION EE_ACTIONS::showBusManager( "eeschema.EditorControl.showBusManager", _( "Bus Definitions..." ), _( "Manage bus definitions" ), bus_definition_tool_xpm ); +TOOL_ACTION EE_ACTIONS::drawSheetOnClipboard( "eeschema.EditorControl.drawSheetOnClipboard", + AS_GLOBAL, 0, "", + _( "Export Drawing to Clipboard" ), _( "Export drawing of current sheet to clipboard" ), + copy_xpm ); + TOOL_ACTION EE_ACTIONS::showPcbNew( "eeschema.EditorControl.showPcbNew", AS_GLOBAL, 0, "", _( "Open PCB Editor" ), _( "Run Pcbnew" ), @@ -1144,6 +1155,13 @@ int SCH_EDITOR_CONTROL::GenerateBOM( const TOOL_EVENT& aEvent ) } +int SCH_EDITOR_CONTROL::DrawSheetOnClipboard( const TOOL_EVENT& aEvent ) +{ + m_frame->DrawCurrentSheetToClipboard(); + return 0; +} + + int SCH_EDITOR_CONTROL::ShowBusManager( const TOOL_EVENT& aEvent ) { InvokeDialogBusManager( m_frame ); @@ -1260,6 +1278,7 @@ void SCH_EDITOR_CONTROL::setTransitions() Go( &SCH_EDITOR_CONTROL::EditWithLibEdit, EE_ACTIONS::editWithLibEdit.MakeEvent() ); Go( &SCH_EDITOR_CONTROL::ShowCvpcb, EE_ACTIONS::assignFootprints.MakeEvent() ); + Go( &SCH_EDITOR_CONTROL::ImportFPAssignments, EE_ACTIONS::importFPAssignments.MakeEvent() ); Go( &SCH_EDITOR_CONTROL::Annotate, EE_ACTIONS::annotate.MakeEvent() ); Go( &SCH_EDITOR_CONTROL::EditSymbolFields, EE_ACTIONS::editSymbolFields.MakeEvent() ); Go( &SCH_EDITOR_CONTROL::EditSymbolLibraryLinks,EE_ACTIONS::editSymbolLibraryLinks.MakeEvent() ); @@ -1267,6 +1286,7 @@ void SCH_EDITOR_CONTROL::setTransitions() Go( &SCH_EDITOR_CONTROL::UpdatePCB, ACTIONS::updatePcbFromSchematic.MakeEvent() ); Go( &SCH_EDITOR_CONTROL::ExportNetlist, EE_ACTIONS::exportNetlist.MakeEvent() ); Go( &SCH_EDITOR_CONTROL::GenerateBOM, EE_ACTIONS::generateBOM.MakeEvent() ); + Go( &SCH_EDITOR_CONTROL::DrawSheetOnClipboard, EE_ACTIONS::drawSheetOnClipboard.MakeEvent() ); Go( &SCH_EDITOR_CONTROL::ShowBusManager, EE_ACTIONS::showBusManager.MakeEvent() ); diff --git a/eeschema/tools/sch_editor_control.h b/eeschema/tools/sch_editor_control.h index c3a4394cd1..b97370f5a2 100644 --- a/eeschema/tools/sch_editor_control.h +++ b/eeschema/tools/sch_editor_control.h @@ -108,8 +108,10 @@ public: int EditSymbolLibraryLinks( const TOOL_EVENT& aEvent ); int ShowPcbNew( const TOOL_EVENT& aEvent ); int UpdatePCB( const TOOL_EVENT& aEvent ); + int ImportFPAssignments( const TOOL_EVENT& aEvent ); int ExportNetlist( const TOOL_EVENT& aEvent ); int GenerateBOM( const TOOL_EVENT& aEvent ); + int DrawSheetOnClipboard( const TOOL_EVENT& aEvent ); int ShowBusManager( const TOOL_EVENT& aEvent ); @@ -120,12 +122,46 @@ public: int ToggleHiddenPins( const TOOL_EVENT& aEvent ); int ToggleForceHV( const TOOL_EVENT& aEvent ); + void BackAnnotateFootprints( const std::string& aChangedSetOfReferences ); + private: ///> copy selection to clipboard bool doCopy(); void doCrossProbeSchToPcb( const TOOL_EVENT& aEvent, bool aForce ); + /** + * Loads a .cmp file from CvPcb and update the footprint field of components. + * + * Prepares parameters and calls ProcessCmpToFootprintLinkFileto actually read the file and + * update the footprint fields + */ + bool loadCmpToFootprintLinkFile(); + + /** + * Read the footprint info from each line in the stuff file by reference designator. + * + * The footprint link file (.cmp) entries created by CvPcb: + * + * BeginCmp + * TimeStamp = /32307DE2/AA450F67; + * Reference = C1; + * ValeurCmp = 47uF; + * IdModule = CP6; + * EndCmp + * + * @param aFullFilename = the full filename to read + * @param aForceVisibilityState = Set to true to change the footprint field visibility + * state to \a aVisibilityState. False retains the + * current footprint field visibility state. + * @param aVisibilityState True to show the footprint field or false to hide the footprint + * field if \a aForceVisibilityState is true. + * @return bool = true if success. + */ + bool processCmpToFootprintLinkFile( const wxString& aFullFilename, + bool aForceVisibilityState, + bool aVisibilityState ); + ///> Sets up handlers for various events. void setTransitions() override; diff --git a/include/eda_draw_frame.h b/include/eda_draw_frame.h index 8540cb0cf1..f2d99ca4e9 100644 --- a/include/eda_draw_frame.h +++ b/include/eda_draw_frame.h @@ -166,9 +166,6 @@ protected: */ bool saveCanvasTypeSetting( EDA_DRAW_PANEL_GAL::GAL_TYPE aCanvasType ); - bool saveCanvasImageToFile( const wxString& aFileName, - wxBitmapType aBitmapType = wxBITMAP_TYPE_PNG ); - /** @return the key in KifaceSettings to store the canvas type. * the base version returns only CanvasTypeKeyBase. * Can be overriden to return a key specific of a frame name @@ -230,8 +227,6 @@ public: int GetLastGridSizeId() const { return m_LastGridSizeId; } void SetLastGridSizeId( int aId ) { m_LastGridSizeId = aId; } - //----------------------------------------------- - /** * Return the nearest \a aGridSize location to \a aPosition. * @@ -240,9 +235,6 @@ public: */ wxPoint GetNearestGridPosition( const wxPoint& aPosition ) const; - - //---------------------------------------------- - virtual const TITLE_BLOCK& GetTitleBlock() const = 0; virtual void SetTitleBlock( const TITLE_BLOCK& aTitleBlock ) = 0; diff --git a/include/id.h b/include/id.h index ea22479e8d..e0d4c99985 100644 --- a/include/id.h +++ b/include/id.h @@ -104,8 +104,6 @@ enum main_id ID_GEN_PLOT_SVG, ID_GEN_PLOT_DXF, ID_GEN_PLOT_PDF, - ID_GEN_COPY_SHEET_TO_CLIPBOARD, - ID_GEN_COPY_BLOCK_TO_CLIPBOARD, ID_GEN_EXPORT_FILE, ID_GEN_IMPORT_FILE, diff --git a/pcbnew/footprint_edit_frame.cpp b/pcbnew/footprint_edit_frame.cpp index 98d35eca36..af0aa9393d 100644 --- a/pcbnew/footprint_edit_frame.cpp +++ b/pcbnew/footprint_edit_frame.cpp @@ -846,7 +846,7 @@ void FOOTPRINT_EDIT_FRAME::OnSaveFootprintAsPng( wxCommandEvent& event ) // calling wxYield is mandatory under Linux, after closing the file selector dialog // to refresh the screen before creating the PNG or JPEG image from screen wxYield(); - saveCanvasImageToFile( dlg.GetPath() ); + SaveCanvasImageToFile( this, dlg.GetPath() ); }