Transition some more stuff from the MVC view to the controller.

This commit is contained in:
Jeff Young 2019-06-16 17:07:15 +01:00
parent c7bfa9857e
commit 909aeba3d9
21 changed files with 204 additions and 238 deletions

View File

@ -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 );
}

View File

@ -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

View File

@ -42,6 +42,7 @@
#include <reporter.h>
#include <netlist_exporters/netlist_exporter_kicad.h>
#include <tools/ee_actions.h>
#include <tools/sch_editor_control.h>
/**
* 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<SCH_EDITOR_CONTROL>();
controlTool->BackAnnotateFootprints( payload );
}
catch( const IO_ERROR& DBG( ioe ) )
{

View File

@ -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. */

View File

@ -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.

View File

@ -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
*

View File

@ -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 <fctsys.h>
#include <gr_basic.h>
#include <pgm_base.h>
#include <sch_draw_panel.h>
#include <confirm.h>
#include <gestfich.h>
#include <eeschema_id.h>
#include <sch_screen.h>
#include <wildcards_and_files_ext.h>
#include <general.h>
#include <lib_edit_frame.h>
#include <class_library.h>
#include <dialogs/dialog_plot_schematic.h>
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 <plotter.h>
void LIB_EDIT_FRAME::SVG_PlotComponent( const wxString& aFullFileName )
{

View File

@ -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();

View File

@ -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 );

View File

@ -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;

View File

@ -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 );

View File

@ -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();

View File

@ -3,7 +3,7 @@
*
* Copyright (C) 2015 Jean-Pierre Charras, jp.charras at wanadoo.fr
* Copyright (C) 2008 Wayne Stambaugh <stambaughw@gmail.com>
* 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 <fctsys.h>
#include <confirm.h>
#include <kicad_string.h>
@ -36,19 +31,19 @@
#include <sch_edit_frame.h>
#include <build_version.h>
#include <wildcards_and_files_ext.h>
#include <general.h>
#include <sch_sheet_path.h>
#include <sch_component.h>
#include <sch_reference_list.h>
#include <dsnlexer.h>
#include <ptree.h>
#include <boost/property_tree/ptree.hpp>
#include <wx/choicdlg.h>
#include <tools/sch_editor_control.h>
#include <kicad/kicad_manager_frame.h>
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;
@ -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,14 +115,14 @@ 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 SCH_EDITOR_CONTROL::processCmpToFootprintLinkFile( const wxString& aFullFilename,
bool aForceVisibilityState,
bool aVisibilityState )
{
@ -179,14 +172,10 @@ 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
// if the footprint name is not empty
@ -207,28 +196,26 @@ bool SCH_EDIT_FRAME::ProcessCmpToFootprintLinkFile( const wxString& aFullFilenam
fpfield->SetText( footprint );
if( aForceVisibilityState )
{
component->GetField( FOOTPRINT )->SetVisible( aVisibilityState );
}
}
}
}
return true;
}
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;
}

View File

@ -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;

View File

@ -29,7 +29,10 @@
#include <eeschema_id.h>
#include <lib_edit_frame.h>
#include <viewlib_frame.h>
#include <kicad/kicad_manager_frame.h>
#include <wildcards_and_files_ext.h>
#include <gestfich.h>
#include <project.h>
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_EDIT_FRAME>();
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_EDIT_FRAME>();
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() );

View File

@ -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 );

View File

@ -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() );

View File

@ -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;

View File

@ -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; }
//-----<BASE_SCREEN API moved here>------------------------------------------
/**
* Return the nearest \a aGridSize location to \a aPosition.
*
@ -240,9 +235,6 @@ public:
*/
wxPoint GetNearestGridPosition( const wxPoint& aPosition ) const;
//-----</BASE_SCREEN API moved here>-----------------------------------------
virtual const TITLE_BLOCK& GetTitleBlock() const = 0;
virtual void SetTitleBlock( const TITLE_BLOCK& aTitleBlock ) = 0;

View File

@ -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,

View File

@ -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() );
}