53using json = nlohmann::json;
101 std::vector<TOOL_ACTION*> actions;
102 std::vector<ACTION_TOOLBAR_CONTROL*> controls;
105 actions.push_back( action );
108 controls.push_back( control );
110 return new PANEL_TOOLBAR_CUSTOMIZATION( aParent, cfg, tb,
FRAME_GERBER, actions, controls );
136 void SaveFileAs(
const wxString& aProjectBasePath,
const wxString& aProjectName,
137 const wxString& aNewProjectBasePath,
const wxString& aNewProjectName,
const wxString& aSrcFilePath,
138 wxString& aErrors )
override;
152using namespace GERBV;
175 m_jobHandler = std::make_unique<GERBVIEW_JOBS_HANDLER>( aKiway );
195 return m_jobHandler->RunJob( aJob, aReporter, aProgressReporter );
206 const wxString& aNewProjectBasePath,
const wxString& aNewProjectName,
207 const wxString& aSrcFilePath, wxString& aErrors )
209 wxFileName destFile( aSrcFilePath );
210 wxString destPath = destFile.GetPathWithSep();
211 wxUniChar pathSep = wxFileName::GetPathSeparator();
212 wxString ext = destFile.GetExt();
214 if( destPath.StartsWith( aProjectBasePath + pathSep ) )
216 destPath.Replace( aProjectBasePath, aNewProjectBasePath,
false );
217 destFile.SetPath( destPath );
222 wxString destFileName = destFile.GetName();
224 if( destFileName.StartsWith( aProjectName +
"-" ) )
226 destFileName.Replace( aProjectName, aNewProjectName,
false );
227 destFile.SetName( destFileName );
230 KiCopyFile( aSrcFilePath, destFile.GetFullPath(), aErrors );
234 if( destFile.GetName() == aProjectName + wxT(
"-job" ) )
235 destFile.SetName( aNewProjectName + wxT(
"-job" ) );
242 while( ( line = jobfileReader.
ReadLine() ) !=
nullptr )
243 data << line <<
'\n';
246 if( !data.Contains( wxT(
"{" ) ) )
248 KiCopyFile( aSrcFilePath, destFile.GetFullPath(), aErrors );
252 bool success =
false;
259 for(
auto& entry : js[
"FilesAttributes"] )
261 wxString
path = wxString( entry[
"Path"].get<std::string>() );
263 if(
path.StartsWith( aProjectName + wxT(
"-" ) ) )
265 path.Replace( aProjectName, aNewProjectName,
false );
266 entry[
"Path"] =
path.ToStdString();
270 wxFFile destJobFile( destFile.GetFullPath(), wxT(
"wb" ) );
272 if( destJobFile.IsOpened() )
273 success = destJobFile.Write( js.dump( 0 ) );
286 if( !aErrors.empty() )
287 aErrors += wxT(
"\n" );
289 msg.Printf(
_(
"Cannot copy file '%s'." ), destFile.GetFullPath() );
295 wxString destFileName = destFile.GetName();
297 if( destFileName == aProjectName )
298 destFileName = aNewProjectName;
299 else if( destFileName.StartsWith( aProjectName + wxT(
"-" ) ) )
300 destFileName.Replace( aProjectName, aNewProjectName,
false );
302 destFile.SetName( destFileName );
304 KiCopyFile( aSrcFilePath, destFile.GetFullPath(), aErrors );
308 wxFAIL_MSG( wxT(
"Unexpected filetype for GerbView::SaveFileAs()" ) );
constexpr EDA_IU_SCALE gerbIUScale
static std::list< TOOL_ACTION * > & GetActionList()
Return list of TOOL_ACTIONs.
static CLI_PROGRESS_REPORTER & GetInstance()
static CLI_REPORTER & GetInstance()
The base frame for deriving all KiCad main window classes.
A LINE_READER that reads from an open file.
char * ReadLine() override
Read a line of text into the buffer and increments the line number counter.
An simple container class that lets us dispatch output jobs to kifaces.
KIFACE_BASE(const char *aKifaceName, KIWAY::FACE_T aId)
void InitSettings(APP_SETTINGS_BASE *aSettings)
void end_common()
Common things to do for a top program module, during OnKifaceEnd();.
APP_SETTINGS_BASE * KifaceSettings() const
bool start_common(int aCtlBits)
Common things to do for a top program module, during OnKifaceStart().
int m_start_flags
flags provided in OnKifaceStart()
A minimalistic software bus for communications between various DLLs/DSOs (DSOs) within the same KiCad...
virtual KIWAY_PLAYER * Player(FRAME_T aFrameType, bool doCreate=true, wxTopLevelWindow *aParent=nullptr)
Return the KIWAY_PLAYER* given a FRAME_T.
FACE_T
Known KIFACE implementations.
Container for data for KiCad programs.
virtual SETTINGS_MANAGER & GetSettingsManager() const
A progress reporter interface for use in multi-threaded environments.
A pure virtual class used to derive REPORTER objects from.
T * RegisterSettings(T *aSettings, bool aLoadNow=true)
Take ownership of the pointer passed in.
UNITS_PROVIDER(const EDA_IU_SCALE &aIuScale, EDA_UNITS aUnits)
EDA_UNITS GetUserUnits() const
void SetUserUnits(EDA_UNITS aUnits)
@ PANEL_GBR_DISPLAY_OPTIONS
@ PANEL_GBR_EXCELLON_OPTIONS
KIFACE_BASE & Kiface()
Global KIFACE_BASE "get" accessor.
void KiCopyFile(const wxString &aSrcPath, const wxString &aDestPath, wxString &aErrors)
static const std::string GerberJobFileExtension
static const std::string DrillFileExtension
static bool IsGerberFileExtension(const wxString &ext)
#define KFCTL_CLI
Running as CLI app.
This file contains miscellaneous commonly used macros and functions.
GERBV::IFACE KIFACE_BASE, UNITS_PROVIDER kiface("gerbview", KIWAY::FACE_GERBVIEW)
T * GetToolbarSettings(const wxString &aFilename)
T * GetAppSettings(const char *aFilename)
#define TO_UTF8(wxstring)
Convert a wxString to a UTF8 encoded C string for all wxWidgets build modes.
bool OnKifaceStart(PGM_BASE *aProgram, int aCtlBits, KIWAY *aKiway) override
Typically start_common() is called from here.
std::unique_ptr< GERBVIEW_JOBS_HANDLER > m_jobHandler
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 ...
int HandleJob(JOB *aJob, REPORTER *aReporter, PROGRESS_REPORTER *aProgressReporter) override
wxWindow * CreateKiWindow(wxWindow *aParent, int aClassId, KIWAY *aKiway, int aCtlBits=0) override
Create a wxWindow for the current project.
void * IfaceOrAddress(int aDataId) override
Return a pointer to the requested object.
bool HandleJobConfig(JOB *aJob, wxWindow *aParent) override
void OnKifaceEnd() override
Called just once just before the DSO is to be unloaded.
IFACE(const char *aName, KIWAY::FACE_T aType)
bool OnKifaceStart(PGM_BASE *aProgram, int aCtlBits, KIWAY *aKiway) override
Typically start_common() is called from here.
Implement a participant in the KIWAY alchemy.
Definition of file extensions used in Kicad.