KiCad PCB EDA Suite
GERBV::IFACE Struct Reference
Inheritance diagram for GERBV::IFACE:
KIFACE_BASE KIFACE

Public Member Functions

 IFACE (const char *aName, KIWAY::FACE_T aType)
 
bool OnKifaceStart (PGM_BASE *aProgram, int aCtlBits) override
 Typically start_common() is called from here. More...
 
void OnKifaceEnd () override
 Called just once just before the DSO is to be unloaded. More...
 
wxWindow * CreateKiWindow (wxWindow *aParent, int aClassId, KIWAY *aKiway, int aCtlBits=0) override
 Create a wxWindow for the current project. More...
 
void * IfaceOrAddress (int aDataId) override
 Return a pointer to the requested object. More...
 
void SaveFileAs (const wxString &aProjectBasePath, const wxString &aProjectName, const wxString &aNewProjectBasePath, const wxString &aNewProjectName, const wxString &aSrcFilePath, wxString &aErrors) override
 Saving a file under a different name is delegated to the various KIFACEs because the project doesn't know the internal format of the various files (which may have paths in them that need updating). More...
 
const wxString Name ()
 
APP_SETTINGS_BASEKifaceSettings () const
 
void InitSettings (APP_SETTINGS_BASE *aSettings)
 
int StartFlags () const
 Return whatever was passed as aCtlBits to OnKifaceStart(). More...
 
bool IsSingle () const
 Is this KIFACE running under single_top? More...
 
const wxString & GetHelpFileName () const
 Return just the basename portion of the current help file. More...
 
SEARCH_STACKKifaceSearch ()
 Only for DSO specific 'non-library' files. More...
 
void GetActions (std::vector< TOOL_ACTION * > &aActions) const override
 Append this Kiface's registered actions to the given list. More...
 
virtual int HandleJob (JOB *aJob)
 

Protected Member Functions

bool start_common (int aCtlBits)
 Common things to do for a top program module, during OnKifaceStart(). More...
 
void end_common ()
 Common things to do for a top program module, during OnKifaceEnd();. More...
 

Private Attributes

KIWAY::FACE_T m_id
 
BIN_MOD m_bm
 
int m_start_flags
 flags provided in OnKifaceStart() More...
 

Detailed Description

Definition at line 49 of file gerbview.cpp.

Constructor & Destructor Documentation

◆ IFACE()

GERBV::IFACE::IFACE ( const char *  aName,
KIWAY::FACE_T  aType 
)
inline

Definition at line 53 of file gerbview.cpp.

53 :
54 KIFACE_BASE( aName, aType )
55 {}
KIFACE_BASE(const char *aKifaceName, KIWAY::FACE_T aId)
Definition: kiface_base.h:65

Member Function Documentation

◆ CreateKiWindow()

wxWindow * GERBV::IFACE::CreateKiWindow ( wxWindow *  aParent,
int  aClassId,
KIWAY aKIWAY,
int  aCtlBits = 0 
)
inlineoverridevirtual

Create a wxWindow for the current project.

The caller must cast the return value into the known type.

Parameters
aParentmay be NULL or is otherwise the parent to connect under. If NULL then caller may want to connect the returned wxWindow into some hierarchy after this function returns.
aClassIdidentifies which wxFrame or wxDialog to retrieve, using a value known to the implementing KIFACE.
aKIWAYtells the window which KIWAY (and PROJECT) it is a participant in.
aCtlBitsconsists of bit flags from the set of KFCTL_* #defines above.
Returns
the window created and if not NULL, should be cast into the known type using and old school cast. dynamic_cast is problematic since it needs typeinfo probably not contained in the caller's link image.

Implements KIFACE_BASE.

Definition at line 61 of file gerbview.cpp.

63 {
64 switch( aClassId )
65 {
66 case FRAME_GERBER:
67 return new GERBVIEW_FRAME( aKiway, aParent );
68
70 return new PANEL_GERBVIEW_DISPLAY_OPTIONS( aParent );
71
73 return new PANEL_GERBVIEW_EXCELLON_SETTINGS( aParent );
74
76 return new PANEL_GERBVIEW_COLOR_SETTINGS( aParent );
77
78 default:
79 ;
80 }
81
82 return nullptr;
83 }
@ PANEL_GBR_DISPLAY_OPTIONS
Definition: frame_type.h:94
@ FRAME_GERBER
Definition: frame_type.h:53
@ PANEL_GBR_COLORS
Definition: frame_type.h:97
@ PANEL_GBR_EXCELLON_OPTIONS
Definition: frame_type.h:96

References FRAME_GERBER, PANEL_GBR_COLORS, PANEL_GBR_DISPLAY_OPTIONS, and PANEL_GBR_EXCELLON_OPTIONS.

◆ end_common()

void KIFACE_BASE::end_common ( )
protectedinherited

Common things to do for a top program module, during OnKifaceEnd();.

Definition at line 42 of file kiface_base.cpp.

43{
44 m_bm.End();
45}
BIN_MOD m_bm
Definition: kiface_base.h:125
void End()
Definition: bin_mod.cpp:50

References BIN_MOD::End(), and KIFACE_BASE::m_bm.

Referenced by CV::IFACE::OnKifaceEnd(), SCH::IFACE::OnKifaceEnd(), OnKifaceEnd(), KIFACE_BASE::OnKifaceEnd(), PGE::IFACE::OnKifaceEnd(), PCBCALC::IFACE::OnKifaceEnd(), and PCB::IFACE::OnKifaceEnd().

◆ GetActions()

void KIFACE_BASE::GetActions ( std::vector< TOOL_ACTION * > &  aActions) const
inlineoverridevirtualinherited

Append this Kiface's registered actions to the given list.

Implements KIFACE.

Definition at line 116 of file kiface_base.h.

117 {
119 aActions.push_back( action );
120 }
static std::list< TOOL_ACTION * > & GetActionList()
Return list of TOOL_ACTIONs.
Represent a single user action.
Definition: tool_action.h:68

References ACTION_MANAGER::GetActionList().

◆ GetHelpFileName()

const wxString & KIFACE_BASE::GetHelpFileName ( ) const
inlineinherited

Return just the basename portion of the current help file.

Definition at line 110 of file kiface_base.h.

110{ return m_bm.m_help_file; }
wxString m_help_file
Definition: bin_mod.h:58

References KIFACE_BASE::m_bm, and BIN_MOD::m_help_file.

Referenced by EDA_BASE_FRAME::help_name().

◆ HandleJob()

virtual int KIFACE::HandleJob ( JOB aJob)
inlinevirtualinherited

Reimplemented in SCH::IFACE, and PCB::IFACE.

Definition at line 239 of file kiway.h.

240 {
241 return 0;
242 }

◆ IfaceOrAddress()

void * GERBV::IFACE::IfaceOrAddress ( int  aDataId)
inlineoverridevirtual

Return a pointer to the requested object.

The safest way to use this is to retrieve a pointer to a static instance of an interface, similar to how the KIFACE interface is exported. But if you know what you are doing use it to retrieve anything you want.

Parameters
aDataIdidentifies which object you want the address of.
Returns
the object requested and must be cast into the know type.

Implements KIFACE_BASE.

Definition at line 95 of file gerbview.cpp.

96 {
97 return nullptr;
98 }

◆ InitSettings()

void KIFACE_BASE::InitSettings ( APP_SETTINGS_BASE aSettings)
inlineinherited

Definition at line 95 of file kiface_base.h.

95{ m_bm.InitSettings( aSettings ); }
void InitSettings(APP_SETTINGS_BASE *aPtr)
Takes ownership of a new application settings object.
Definition: bin_mod.h:53

References BIN_MOD::InitSettings(), and KIFACE_BASE::m_bm.

Referenced by BMP2CMP::IFACE::CreateKiWindow(), CV::IFACE::OnKifaceStart(), SCH::IFACE::OnKifaceStart(), OnKifaceStart(), PGE::IFACE::OnKifaceStart(), PCBCALC::IFACE::OnKifaceStart(), and PCB::IFACE::OnKifaceStart().

◆ IsSingle()

bool KIFACE_BASE::IsSingle ( ) const
inlineinherited

Is this KIFACE running under single_top?

Definition at line 105 of file kiface_base.h.

int m_start_flags
flags provided in OnKifaceStart()
Definition: kiface_base.h:127
#define KFCTL_STANDALONE
Running as a standalone Top.
Definition: kiway.h:158

References KFCTL_STANDALONE, and KIFACE_BASE::m_start_flags.

Referenced by ACTION_MENU::AddQuitOrClose(), SCH::IFACE::CreateKiWindow(), PCB::IFACE::CreateKiWindow(), DIALOG_DRC::DIALOG_DRC(), SCH_EDIT_FRAME::OnImportProject(), SCH_EDIT_FRAME::SaveProject(), and SCH_EDIT_FRAME::SendSelectItemsToPcb().

◆ KifaceSearch()

SEARCH_STACK & KIFACE_BASE::KifaceSearch ( )
inlineinherited

Only for DSO specific 'non-library' files.

(The library search path is in the PROJECT class.)

Definition at line 114 of file kiface_base.h.

114{ return m_bm.m_search; }
SEARCH_STACK m_search
Definition: bin_mod.h:60

References KIFACE_BASE::m_bm, and BIN_MOD::m_search.

Referenced by CVPCB_MAINFRAME::buildEquivalenceList(), DS_DATA_MODEL::ResolvePath(), and EDA_BASE_FRAME::sys_search().

◆ KifaceSettings()

APP_SETTINGS_BASE * KIFACE_BASE::KifaceSettings ( ) const
inlineinherited

Definition at line 93 of file kiface_base.h.

93{ return m_bm.m_config; }
APP_SETTINGS_BASE * m_config
maybe from $HOME/.${m_name}
Definition: bin_mod.h:57

References KIFACE_BASE::m_bm, and BIN_MOD::m_config.

Referenced by DIALOG_SYMBOL_FIELDS_TABLE::AddField(), AUTOPLACER::AUTOPLACER(), EDA_BASE_FRAME::config(), BMP2CMP::IFACE::CreateKiWindow(), DIALOG_BOARD_REANNOTATE::DIALOG_BOARD_REANNOTATE(), DIALOG_COLOR_PICKER::DIALOG_COLOR_PICKER(), DIALOG_ERC::DIALOG_ERC(), DIALOG_LABEL_PROPERTIES::DIALOG_LABEL_PROPERTIES(), DIALOG_PRINT_GERBVIEW::DIALOG_PRINT_GERBVIEW(), DIALOG_PRINT_PCBNEW::DIALOG_PRINT_PCBNEW(), DIALOG_SHEET_PROPERTIES::DIALOG_SHEET_PROPERTIES(), DIALOG_SYMBOL_FIELDS_TABLE::DIALOG_SYMBOL_FIELDS_TABLE(), DIALOG_SYMBOL_PROPERTIES::DIALOG_SYMBOL_PROPERTIES(), KIGFX::eeconfig(), PCB_PLUGIN::FootprintSave(), DIALOG_PLOT_SCHEMATIC::getPlotOptions(), LAYERS_MAP_DIALOG::initDialog(), DIALOG_PLOT_SCHEMATIC::initDlg(), DIALOG_ANNOTATE::InitValues(), DIALOG_EXPORT_NETLIST::InstallCustomPages(), LIB_TREE_MODEL_ADAPTER::LIB_TREE_MODEL_ADAPTER(), EDA_DRAW_FRAME::loadCanvasTypeSetting(), DIALOG_SYMBOL_FIELDS_TABLE::LoadFieldNames(), DIALOG_SYMBOL_FIELDS_TABLE::OnAddField(), DIALOG_SYMBOL_FIELDS_TABLE::OnColumnItemToggled(), LAYERS_MAP_DIALOG::OnGetSetup(), DIALOG_SHEET_PROPERTIES::OnInitDlg(), DIALOG_SYMBOL_PROPERTIES::OnInitDlg(), CV::IFACE::OnKifaceStart(), SCH::IFACE::OnKifaceStart(), OnKifaceStart(), PGE::IFACE::OnKifaceStart(), PCBCALC::IFACE::OnKifaceStart(), PCB::IFACE::OnKifaceStart(), DIALOG_RESCUE_EACH::OnNeverShowClick(), SCH_EDIT_FRAME::OnResizeHierarchyNavigator(), LAYERS_MAP_DIALOG::OnStoreSetup(), DIALOG_SYMBOL_FIELDS_TABLE::OnTableColSize(), DIALOG_EESCHEMA_PAGE_SETTINGS::onTransferDataToWindow(), SCH_EDIT_FRAME::OpenProjectFiles(), pcbconfig(), TRANSLINE_IDENT::ReadConfig(), PCB_EDIT_FRAME::redrawNetnames(), EDA_DRAW_FRAME::saveCanvasTypeSetting(), LIB_TREE_MODEL_ADAPTER::SaveSettings(), PCB_CALCULATOR_FRAME::SaveSettings(), PANEL_PCBNEW_ACTION_PLUGINS::TransferDataFromWindow(), RATSNEST_VIEW_ITEM::ViewDraw(), TRANSLINE_IDENT::WriteConfig(), DIALOG_EXPORT_NETLIST::WriteCurrentNetlistSetup(), DIALOG_ANNOTATE::~DIALOG_ANNOTATE(), DIALOG_COLOR_PICKER::~DIALOG_COLOR_PICKER(), DIALOG_EESCHEMA_PAGE_SETTINGS::~DIALOG_EESCHEMA_PAGE_SETTINGS(), DIALOG_ERC::~DIALOG_ERC(), DIALOG_LABEL_PROPERTIES::~DIALOG_LABEL_PROPERTIES(), DIALOG_SHEET_PROPERTIES::~DIALOG_SHEET_PROPERTIES(), and DIALOG_SYMBOL_PROPERTIES::~DIALOG_SYMBOL_PROPERTIES().

◆ Name()

const wxString KIFACE_BASE::Name ( )
inlineinherited

Definition at line 88 of file kiface_base.h.

89 {
90 return wxString::FromUTF8( m_bm.m_name );
91 }
const char * m_name
name of this binary module, static C string.
Definition: bin_mod.h:55

References KIFACE_BASE::m_bm, and BIN_MOD::m_name.

◆ OnKifaceEnd()

void IFACE::OnKifaceEnd ( )
overridevirtual

Called just once just before the DSO is to be unloaded.

It is called before static C++ destructors are called. A default implementation is supplied.

Reimplemented from KIFACE_BASE.

Definition at line 155 of file gerbview.cpp.

156{
157 end_common();
158}
void end_common()
Common things to do for a top program module, during OnKifaceEnd();.
Definition: kiface_base.cpp:42

References KIFACE_BASE::end_common().

◆ OnKifaceStart()

bool IFACE::OnKifaceStart ( PGM_BASE aProgram,
int  aCtlBits 
)
overridevirtual

Typically start_common() is called from here.

Implements KIFACE_BASE.

Definition at line 146 of file gerbview.cpp.

147{
150 start_common( aCtlBits );
151 return true;
152}
void InitSettings(APP_SETTINGS_BASE *aSettings)
Definition: kiface_base.h:95
APP_SETTINGS_BASE * KifaceSettings() const
Definition: kiface_base.h:93
bool start_common(int aCtlBits)
Common things to do for a top program module, during OnKifaceStart().
Definition: kiface_base.cpp:32
virtual SETTINGS_MANAGER & GetSettingsManager() const
Definition: pgm_base.h:135
T * RegisterSettings(T *aSettings, bool aLoadNow=true)
Takes ownership of the pointer passed in.
int PGM_BASE * aProgram
Definition: gerbview.cpp:126

References aProgram, PGM_BASE::GetSettingsManager(), KIFACE_BASE::InitSettings(), KIFACE_BASE::KifaceSettings(), SETTINGS_MANAGER::RegisterSettings(), and KIFACE_BASE::start_common().

◆ SaveFileAs()

void IFACE::SaveFileAs ( const wxString &  aProjectBasePath,
const wxString &  aProjectName,
const wxString &  aNewProjectBasePath,
const wxString &  aNewProjectName,
const wxString &  aSrcFilePath,
wxString &  aErrors 
)
overridevirtual

Saving a file under a different name is delegated to the various KIFACEs because the project doesn't know the internal format of the various files (which may have paths in them that need updating).

Reimplemented from KIFACE.

Definition at line 161 of file gerbview.cpp.

164{
165 wxFileName destFile( aSrcFilePath );
166 wxString destPath = destFile.GetPathWithSep();
167 wxUniChar pathSep = wxFileName::GetPathSeparator();
168 wxString ext = destFile.GetExt();
169
170 if( destPath.StartsWith( aProjectBasePath + pathSep ) )
171 {
172 destPath.Replace( aProjectBasePath, aNewProjectBasePath, false );
173 destFile.SetPath( destPath );
174 }
175
176 if( IsGerberFileExtension( ext ) )
177 {
178 wxString destFileName = destFile.GetName();
179
180 if( destFileName.StartsWith( aProjectName + "-" ) )
181 {
182 destFileName.Replace( aProjectName, aNewProjectName, false );
183 destFile.SetName( destFileName );
184 }
185
186 KiCopyFile( aSrcFilePath, destFile.GetFullPath(), aErrors );
187 }
188 else if( ext == GerberJobFileExtension )
189 {
190 if( destFile.GetName() == aProjectName + wxT( "-job" ) )
191 destFile.SetName( aNewProjectName + wxT( "-job" ) );
192
193 FILE_LINE_READER jobfileReader( aSrcFilePath );
194
195 char* line;
196 wxString data;
197
198 while( ( line = jobfileReader.ReadLine() ) )
199 data << line << '\n';
200
201 // detect the file format: old (deprecated) gerber format or official JSON format
202 if( !data.Contains( wxT( "{" ) ) )
203 {
204 KiCopyFile( aSrcFilePath, destFile.GetFullPath(), aErrors );
205 return;
206 }
207
208 bool success = false;
209
210 try
211 {
212 // Will throw on parse error
213 json js = json::parse( TO_UTF8( data ) );
214
215 for( auto& entry : js["FilesAttributes"] )
216 {
217 wxString path = wxString( entry["Path"].get<std::string>() );
218
219 if( path.StartsWith( aProjectName + wxT( "-" ) ) )
220 {
221 path.Replace( aProjectName, aNewProjectName, false );
222 entry["Path"] = path.ToStdString();
223 }
224 }
225
226 wxFFile destJobFile( destFile.GetFullPath(), wxT( "wb" ) );
227
228 if( destJobFile.IsOpened() )
229 success = destJobFile.Write( js.dump( 0 ) );
230
231 // wxFFile dtor will close the file
232 }
233 catch( ... )
234 {
235 success = false;
236 }
237
238 if( !success )
239 {
240 wxString msg;
241
242 if( !aErrors.empty() )
243 aErrors += wxT( "\n" );
244
245 msg.Printf( _( "Cannot copy file '%s'." ), destFile.GetFullPath() );
246 aErrors += msg;
247 }
248 }
249 else if( ext == DrillFileExtension )
250 {
251 wxString destFileName = destFile.GetName();
252
253 if( destFileName == aProjectName )
254 destFileName = aNewProjectName;
255 else if( destFileName.StartsWith( aProjectName + wxT( "-" ) ) )
256 destFileName.Replace( aProjectName, aNewProjectName, false );
257
258 destFile.SetName( destFileName );
259
260 KiCopyFile( aSrcFilePath, destFile.GetFullPath(), aErrors );
261 }
262 else
263 {
264 wxFAIL_MSG( wxT( "Unexpected filetype for GerbView::SaveFileAs()" ) );
265 }
266}
A LINE_READER that reads from an open file.
Definition: richio.h:173
#define _(s)
nlohmann::json json
Definition: gerbview.cpp:44
void KiCopyFile(const wxString &aSrcPath, const wxString &aDestPath, wxString &aErrors)
Definition: gestfich.cpp:214
const std::string GerberJobFileExtension
const std::string DrillFileExtension
bool IsGerberFileExtension(const wxString &ext)
#define TO_UTF8(wxstring)
Convert a wxString to a UTF8 encoded C string for all wxWidgets build modes.
Definition: macros.h:96
bool parse(std::istream &aStream, bool aVerbose)
Parse a PCB or footprint file from the given input stream.

References _, DrillFileExtension, GerberJobFileExtension, IsGerberFileExtension(), KiCopyFile(), parse(), path, FILE_LINE_READER::ReadLine(), and TO_UTF8.

◆ start_common()

bool KIFACE_BASE::start_common ( int  aCtlBits)
protectedinherited

Common things to do for a top program module, during OnKifaceStart().

Definition at line 32 of file kiface_base.cpp.

33{
34 m_start_flags = aCtlBits;
35 m_bm.Init();
37
38 return true;
39}
KIWAY::FACE_T m_id
Definition: kiface_base.h:123
void Init()
Definition: bin_mod.cpp:38
void GlobalPathsAppend(SEARCH_STACK *aDst, KIWAY::FACE_T aId)
Initialize aDst SEARCH_STACK with KIFACE (DSO) specific settings.

References GlobalPathsAppend(), BIN_MOD::Init(), KIFACE_BASE::m_bm, KIFACE_BASE::m_id, BIN_MOD::m_search, and KIFACE_BASE::m_start_flags.

Referenced by BMP2CMP::IFACE::OnKifaceStart(), CV::IFACE::OnKifaceStart(), SCH::IFACE::OnKifaceStart(), OnKifaceStart(), PGE::IFACE::OnKifaceStart(), PCBCALC::IFACE::OnKifaceStart(), and PCB::IFACE::OnKifaceStart().

◆ StartFlags()

int KIFACE_BASE::StartFlags ( ) const
inlineinherited

Return whatever was passed as aCtlBits to OnKifaceStart().

Definition at line 100 of file kiface_base.h.

100{ return m_start_flags; }

References KIFACE_BASE::m_start_flags.

Member Data Documentation

◆ m_bm

◆ m_id

KIWAY::FACE_T KIFACE_BASE::m_id
privateinherited

Definition at line 123 of file kiface_base.h.

Referenced by KIFACE_BASE::start_common().

◆ m_start_flags

int KIFACE_BASE::m_start_flags
privateinherited

flags provided in OnKifaceStart()

Definition at line 127 of file kiface_base.h.

Referenced by KIFACE_BASE::IsSingle(), KIFACE_BASE::start_common(), and KIFACE_BASE::StartFlags().


The documentation for this struct was generated from the following file: