From f6669b7845b2faef3ae08ab94b6ed3569bea3638 Mon Sep 17 00:00:00 2001 From: jean-pierre charras Date: Sat, 12 Mar 2011 10:50:21 +0100 Subject: [PATCH] Gerbview: code cleanup: remove dead code and obsolete options. Coding policy class naming fixes. others: fix minor issues. --- TODO.txt | 45 +-- common/projet_config.cpp | 4 +- gerbview/CMakeLists.txt | 2 - gerbview/block.cpp | 12 +- gerbview/class_GERBER.cpp | 2 +- gerbview/class_GERBER.h | 6 +- gerbview/class_gerbview_layer_widget.cpp | 4 +- gerbview/class_gerbview_layer_widget.h | 6 +- gerbview/controle.cpp | 2 +- gerbview/dcode.cpp | 6 +- gerbview/deltrack.cpp | 37 -- gerbview/dialogs/dialog_gerber_config.cpp | 146 -------- .../dialogs/dialog_print_using_printer.cpp | 8 +- .../gerbview_dialog_display_options_frame.cpp | 8 +- gerbview/draw_gerber_screen.cpp | 6 +- gerbview/edit.cpp | 25 +- gerbview/export_to_pcbnew.cpp | 6 +- gerbview/files.cpp | 18 +- gerbview/gerberframe.cpp | 152 ++++---- gerbview/gerbview.cpp | 25 +- gerbview/gerbview.h | 11 +- gerbview/gerbview_config.cpp | 116 +++--- gerbview/gerbview_config.h | 349 ------------------ gerbview/gerbview_id.h | 1 - gerbview/hotkeys.cpp | 2 +- gerbview/initpcb.cpp | 5 +- gerbview/locate.cpp | 2 +- gerbview/menubar.cpp | 9 +- gerbview/onrightclick.cpp | 2 +- gerbview/options.cpp | 5 +- gerbview/pcbplot.cpp | 3 +- gerbview/readgerb.cpp | 11 +- gerbview/select_layers_to_pcb.cpp | 28 +- gerbview/toolbars_gerber.cpp | 25 +- gerbview/wxGerberFrame.h | 27 +- include/param_config.h | 72 ++-- pcbnew/export_vrml.cpp | 32 +- pcbnew/onleftclick.cpp | 2 + pcbnew/onrightclick.cpp | 4 + 39 files changed, 324 insertions(+), 902 deletions(-) delete mode 100644 gerbview/deltrack.cpp delete mode 100644 gerbview/dialogs/dialog_gerber_config.cpp diff --git a/TODO.txt b/TODO.txt index 988977a039..6c877dc3e4 100644 --- a/TODO.txt +++ b/TODO.txt @@ -39,7 +39,6 @@ E4) Change add component dialog search text control to combobox and add compone search history save and restore capability. Also add session save and restore to component history list control. Add advanced search capability similar to new find dialog. -E5) Make escape key work correctly in add component dialog. E6) Start initial work for changing component library file format to use Dick's dsnlexer. See note C2 above. Come up with a workable library file format to handle the wishes of the library implementation group. Add initial clipboard @@ -48,55 +47,13 @@ E6) Start initial work for changing component library file format to use Dick's GerbView -------- -* Need work as good as gerbv from gEDA - * Named layers - * List control for layer sort on the fly +* List control for layer sort on the fly * Add excellon2 drill file support (small good library) -* Fix the polygon bug. -* Switch to use ZONE instead of SEGZONE for polygons. -* Separate application settings and project configuration settings by converting - static list of parameters in gerbview_config.h to dynamically created lists of - settings. See eeschema/eeschema_config.cpp for an example. - PCBNew ------ Dick: -P2) Write accessors for all items in PCB_VISIBLE such as grid control, so that - the write accessor can fire change notifications to known listeners. - (Accessors should always be used in general for every class, but in the case - of PCB_VISIBLE I think we need them in WinEDA_PcbFrame, BOARD and - EDA_Settings. - ::IsElementVisible( aPCB_VISIBLE ); - ::SetElementVisiblity( aPCB_VISIBLE, bool isVisible ); - Two of the 3 classes already have these functions. Once the functions are - in place, it is a simple matter to decide and move where the actual data - is stored without affecting client code. The top most access point should - be WinEDA_PcbVisible, because some data is best retained there and this is - the "controller" part of MVC in PCBNEW. Some data is best saved in the BOARD. - We should go through the list of PCB_VISIBLE and decide on this in a separate email. - -* Fix block copy/move preview to not view only a border, we should - see the moved/copied parts. - -* Fix DIALOG_PAD_PROPERTIES_BASE class to use actual layer names in the BOARD. * Use BOARD_ITEM::MenuIcon() in the onrightclick.cpp -* Add ARC support to gerber polygons. -* Need to add polygon aperture type. - Then example 2 in RS274xrevd_e.pdf will draw properly. - - -LAYER_WIDGET for PCBNEW (Dick) ------------------------ -L6) Test, and fix up any remaining issues with the PCB_VISIBLE support after P2) - is done. This way we can fire change notifications to multiple GUI items - all interested in the same setting, such as the two grid buttons which - have to remain synchronized. Using accessors makes this easy. - -L8) LAYER_WIDGET::GetBestSize() needs platform independence. - -L9) On board load, ReFill() is called, this should also update the Render - checkboxes and colors. diff --git a/common/projet_config.cpp b/common/projet_config.cpp index 99ddc953ed..37a044435b 100644 --- a/common/projet_config.cpp +++ b/common/projet_config.cpp @@ -664,11 +664,13 @@ PARAM_CFG_WXSTRING::PARAM_CFG_WXSTRING( const wxChar* ident, PARAM_CFG_WXSTRING::PARAM_CFG_WXSTRING( bool Insetup, const wxChar* ident, wxString* ptparam, + const wxString& default_val, const wxChar* group ) : PARAM_CFG_BASE( ident, PARAM_WXSTRING, group ) { m_Pt_param = ptparam; m_Setup = Insetup; + m_default = default_val; } @@ -680,7 +682,7 @@ void PARAM_CFG_WXSTRING::ReadParam( wxConfigBase* aConfig ) { if( m_Pt_param == NULL || aConfig == NULL ) return; - *m_Pt_param = aConfig->Read( m_Ident ); + *m_Pt_param = aConfig->Read( m_Ident, m_default ); } diff --git a/gerbview/CMakeLists.txt b/gerbview/CMakeLists.txt index 027781eacd..46c56f15d1 100644 --- a/gerbview/CMakeLists.txt +++ b/gerbview/CMakeLists.txt @@ -16,7 +16,6 @@ include_directories(${CMAKE_CURRENT_SOURCE_DIR} set(DIALOGS_SRCS dialogs/gerbview_dialog_display_options_frame_base.cpp dialogs/gerbview_dialog_display_options_frame.cpp - dialogs/dialog_gerber_config.cpp dialogs/dialog_print_using_printer.cpp dialogs/dialog_print_using_printer_base.cpp ) @@ -31,7 +30,6 @@ set(GERBVIEW_SRCS class_gerbview_layer_widget.cpp controle.cpp dcode.cpp - deltrack.cpp dummy_functions.cpp draw_gerber_screen.cpp edit.cpp diff --git a/gerbview/block.cpp b/gerbview/block.cpp index a666260deb..015aaa41a6 100644 --- a/gerbview/block.cpp +++ b/gerbview/block.cpp @@ -47,7 +47,7 @@ static void DrawMovingBlockOutlines( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wx /* Return the block command (BLOCK_MOVE, BLOCK_COPY...) corresponding to * the key (ALT, SHIFT ALT ..) */ -int WinEDA_GerberFrame::ReturnBlockCommand( int key ) +int GERBVIEW_FRAME::ReturnBlockCommand( int key ) { int cmd = 0; @@ -85,7 +85,7 @@ int WinEDA_GerberFrame::ReturnBlockCommand( int key ) /* Routine to handle the BLOCK PLACE command */ -void WinEDA_GerberFrame::HandleBlockPlace( wxDC* DC ) +void GERBVIEW_FRAME::HandleBlockPlace( wxDC* DC ) { bool err = false; @@ -162,7 +162,7 @@ void WinEDA_GerberFrame::HandleBlockPlace( wxDC* DC ) * @return false if no item selected, or command finished, * true if some items found and HandleBlockPlace must be called later */ -bool WinEDA_GerberFrame::HandleBlockEnd( wxDC* DC ) +bool GERBVIEW_FRAME::HandleBlockEnd( wxDC* DC ) { bool nextcmd = false; bool zoom_command = false; @@ -274,7 +274,7 @@ static void DrawMovingBlockOutlines( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wx /* * Erase the selected block. */ -void WinEDA_GerberFrame::Block_Delete( wxDC* DC ) +void GERBVIEW_FRAME::Block_Delete( wxDC* DC ) { if( !IsOK( this, _( "Ok to delete block ?" ) ) ) return; @@ -300,7 +300,7 @@ void WinEDA_GerberFrame::Block_Delete( wxDC* DC ) /* * Function to move items in the current selected block */ -void WinEDA_GerberFrame::Block_Move( wxDC* DC ) +void GERBVIEW_FRAME::Block_Move( wxDC* DC ) { wxPoint delta; wxPoint oldpos; @@ -332,7 +332,7 @@ void WinEDA_GerberFrame::Block_Move( wxDC* DC ) /* * Function to duplicate items in the current selected block */ -void WinEDA_GerberFrame::Block_Duplicate( wxDC* DC ) +void GERBVIEW_FRAME::Block_Duplicate( wxDC* DC ) { wxPoint delta; wxPoint oldpos; diff --git a/gerbview/class_GERBER.cpp b/gerbview/class_GERBER.cpp index 2ab541f3ea..540c259016 100644 --- a/gerbview/class_GERBER.cpp +++ b/gerbview/class_GERBER.cpp @@ -83,7 +83,7 @@ void GERBER_LAYER::ResetDefaultValues() } -GERBER_IMAGE::GERBER_IMAGE( WinEDA_GerberFrame* aParent, int aLayer ) +GERBER_IMAGE::GERBER_IMAGE( GERBVIEW_FRAME* aParent, int aLayer ) { m_Parent = aParent; m_GraphicLayer = aLayer; // Graphic layer Number diff --git a/gerbview/class_GERBER.h b/gerbview/class_GERBER.h index abece9021c..87c4b4112d 100644 --- a/gerbview/class_GERBER.h +++ b/gerbview/class_GERBER.h @@ -16,7 +16,7 @@ #define IsNumber( x ) ( ( ( (x) >= '0' ) && ( (x) <='9' ) ) \ || ( (x) == '-' ) || ( (x) == '+' ) || ( (x) == '.' ) ) -class WinEDA_GerberFrame; +class GERBVIEW_FRAME; class BOARD; class D_CODE; @@ -74,7 +74,7 @@ private: */ class GERBER_IMAGE { - WinEDA_GerberFrame* m_Parent; // the parent WinEDA_GerberFrame (used to display messages...) + GERBVIEW_FRAME* m_Parent; // the parent GERBVIEW_FRAME (used to display messages...) D_CODE* m_Aperture_List[TOOLS_MAX_COUNT]; ///< Dcode (Aperture) List for this layer (max 999) bool m_Exposure; ///< whether an aperture macro tool is flashed on or off BOARD* m_Pcb; @@ -138,7 +138,7 @@ private: // 1 = have negative items found public: - GERBER_IMAGE( WinEDA_GerberFrame* aParent, int layer ); + GERBER_IMAGE( GERBVIEW_FRAME* aParent, int layer ); ~GERBER_IMAGE(); void Clear_GERBER_IMAGE(); int ReturnUsedDcodeNumber(); diff --git a/gerbview/class_gerbview_layer_widget.cpp b/gerbview/class_gerbview_layer_widget.cpp index f2201bb087..d533d5902b 100644 --- a/gerbview/class_gerbview_layer_widget.cpp +++ b/gerbview/class_gerbview_layer_widget.cpp @@ -41,12 +41,12 @@ /* * Class GERBER_LAYER_WIDGET * is here to implement the abtract functions of LAYER_WIDGET so they - * may be tied into the WinEDA_GerberFrame's data and so we can add a popup + * may be tied into the GERBVIEW_FRAME's data and so we can add a popup * menu which is specific to PCBNEW's needs. */ -GERBER_LAYER_WIDGET::GERBER_LAYER_WIDGET( WinEDA_GerberFrame* aParent, wxWindow* aFocusOwner, int aPointSize ) : +GERBER_LAYER_WIDGET::GERBER_LAYER_WIDGET( GERBVIEW_FRAME* aParent, wxWindow* aFocusOwner, int aPointSize ) : LAYER_WIDGET( aParent, aFocusOwner, aPointSize ), myframe( aParent ) { diff --git a/gerbview/class_gerbview_layer_widget.h b/gerbview/class_gerbview_layer_widget.h index 1144d0b13f..3bb6ea57c6 100644 --- a/gerbview/class_gerbview_layer_widget.h +++ b/gerbview/class_gerbview_layer_widget.h @@ -36,12 +36,12 @@ /** * Class GERBER_LAYER_WIDGET * is here to implement the abtract functions of LAYER_WIDGET so they - * may be tied into the WinEDA_GerberFrame's data and so we can add a popup + * may be tied into the GERBVIEW_FRAME's data and so we can add a popup * menu which is specific to PCBNEW's needs. */ class GERBER_LAYER_WIDGET : public LAYER_WIDGET { - WinEDA_GerberFrame* myframe; + GERBVIEW_FRAME* myframe; // popup menu ids. #define ID_SHOW_ALL_COPPERS wxID_HIGHEST @@ -69,7 +69,7 @@ public: * effectively sets the overal size of the widget via the row height and bitmap * button sizes. */ - GERBER_LAYER_WIDGET( WinEDA_GerberFrame* aParent, wxWindow* aFocusOwner, int aPointSize = 10 ); + GERBER_LAYER_WIDGET( GERBVIEW_FRAME* aParent, wxWindow* aFocusOwner, int aPointSize = 10 ); void ReFill(); diff --git a/gerbview/controle.cpp b/gerbview/controle.cpp index 4cf6a6e62b..9fc8128001 100644 --- a/gerbview/controle.cpp +++ b/gerbview/controle.cpp @@ -8,7 +8,7 @@ #include "gerbview.h" -void WinEDA_GerberFrame::GeneralControl( wxDC* aDC, const wxPoint& aPosition, int aHotKey ) +void GERBVIEW_FRAME::GeneralControl( wxDC* aDC, const wxPoint& aPosition, int aHotKey ) { wxRealPoint gridSize; wxPoint oldpos; diff --git a/gerbview/dcode.cpp b/gerbview/dcode.cpp index efe76e8a6b..e3635c395a 100644 --- a/gerbview/dcode.cpp +++ b/gerbview/dcode.cpp @@ -147,7 +147,7 @@ int D_CODE::GetShapeDim( GERBER_DRAW_ITEM* aParent ) * tool, Horiz, Vert, drill, vitesse, acc. ,Type ; [DCODE (commentaire)] * ex: 1, 12, 12, 0, 0, 0, 3 ; D10 */ -int WinEDA_GerberFrame::Read_D_Code_File( const wxString& D_Code_FullFileName ) +int GERBVIEW_FRAME::Read_D_Code_File( const wxString& D_Code_FullFileName ) { int current_Dcode, ii, dcode_scale; char* ptcar; @@ -269,7 +269,7 @@ int WinEDA_GerberFrame::Read_D_Code_File( const wxString& D_Code_FullFileName ) /* Set Size Items (Lines, Flashes) from DCodes List */ -void WinEDA_GerberFrame::CopyDCodesSizeToItems() +void GERBVIEW_FRAME::CopyDCodesSizeToItems() { static D_CODE dummy( 999 ); //Used if D_CODE not found in list @@ -318,7 +318,7 @@ void WinEDA_GerberFrame::CopyDCodesSizeToItems() break; default: - wxMessageBox( wxT( "WinEDA_GerberFrame::CopyDCodesSizeToItems() error" ) ); + wxMessageBox( wxT( "GERBVIEW_FRAME::CopyDCodesSizeToItems() error" ) ); break; } } diff --git a/gerbview/deltrack.cpp b/gerbview/deltrack.cpp deleted file mode 100644 index 1e13103c77..0000000000 --- a/gerbview/deltrack.cpp +++ /dev/null @@ -1,37 +0,0 @@ -/*********************************************/ -/* Edit Track: Erase functions */ -/*********************************************/ - -#include "fctsys.h" -#include "common.h" - -#include "gerbview.h" -#include "class_gerber_draw_item.h" - - -void WinEDA_GerberFrame::Delete_DCode_Items( wxDC* DC, - int dcode_value, - int layer_number ) -{ - if( dcode_value < FIRST_DCODE ) // No tool selected - return; - - BOARD_ITEM* item = GetBoard()->m_Drawings; - BOARD_ITEM * next; - for( ; item; item = next ) - { - next = item->Next(); - GERBER_DRAW_ITEM* gerb_item = (GERBER_DRAW_ITEM*) item; - - if( dcode_value != gerb_item->m_DCode ) - continue; - - if( layer_number >= 0 && layer_number != gerb_item->GetLayer() ) - continue; - -// TODO: Delete_Item( DC, item ); - } - - GetScreen()->SetCurItem( NULL ); -} - diff --git a/gerbview/dialogs/dialog_gerber_config.cpp b/gerbview/dialogs/dialog_gerber_config.cpp deleted file mode 100644 index 87b0315f9a..0000000000 --- a/gerbview/dialogs/dialog_gerber_config.cpp +++ /dev/null @@ -1,146 +0,0 @@ -/*****************************/ -/* dialog_gerber_config.cpp */ -/****************************/ - -/* - * Options for file extensions - */ - - -#include "fctsys.h" -#include "appl_wxstruct.h" -#include "common.h" -#include "gerbview.h" -#include "dialog_helpers.h" - - -enum -{ - ID_SAVE_CFG = 1000 -}; - - -class WinEDA_ConfigFrame : public wxDialog -{ -private: - - WinEDA_GerberFrame* m_Parent; - wxListBox* ListLibr; - int LibModified; - - WinEDA_EnterText* TextDrillExt; - WinEDA_EnterText* TextPhotoExt; - WinEDA_EnterText* TextPenExt; - -public: - WinEDA_ConfigFrame( WinEDA_GerberFrame* parent, const wxPoint& pos ); - ~WinEDA_ConfigFrame() { }; - -private: - void SaveCfg( wxCommandEvent& event ); - void OnOkClick( wxCommandEvent& event ); - void OnCancelClick( wxCommandEvent& event ); - - DECLARE_EVENT_TABLE() -}; - - -BEGIN_EVENT_TABLE( WinEDA_ConfigFrame, wxDialog ) - EVT_BUTTON( ID_SAVE_CFG, WinEDA_ConfigFrame::SaveCfg ) - EVT_BUTTON( wxID_OK, WinEDA_ConfigFrame::OnOkClick ) - EVT_BUTTON( wxID_CANCEL, WinEDA_ConfigFrame::OnCancelClick ) -END_EVENT_TABLE() - - -/** - * Function InstallConfigFrame - * install the dialog box to configure some gerbview options - * mainly the default file extensions - */ -void WinEDA_GerberFrame::InstallConfigFrame( const wxPoint& pos ) -{ - WinEDA_ConfigFrame* CfgFrame = new WinEDA_ConfigFrame( this, pos ); - - CfgFrame->ShowModal(); - CfgFrame->Destroy(); -} - - -WinEDA_ConfigFrame::WinEDA_ConfigFrame( WinEDA_GerberFrame* parent, - const wxPoint& framepos ) : - wxDialog( parent, -1, wxEmptyString, framepos, wxSize( 300, 180 ), - wxDEFAULT_DIALOG_STYLE | wxFRAME_FLOAT_ON_PARENT ) -{ - const int LEN_EXT = 100; - wxString title; - - m_Parent = parent; - - /* Shows the config filename currently used : */ - title = _( "from " ) + wxGetApp().m_CurrentOptionFile; - SetTitle( title ); - - LibModified = FALSE; - wxBoxSizer* MainBoxSizer = new wxBoxSizer( wxHORIZONTAL ); - SetSizer( MainBoxSizer ); - wxBoxSizer* RightBoxSizer = new wxBoxSizer( wxVERTICAL ); - wxBoxSizer* LeftBoxSizer = new wxBoxSizer( wxVERTICAL ); - MainBoxSizer->Add( LeftBoxSizer, 0, wxGROW | wxALL, 5 ); - MainBoxSizer->Add( RightBoxSizer, 0, wxALIGN_CENTER_VERTICAL | wxALL, 5 ); - - /* Created the buttons */ - wxButton* Button = new wxButton( this, ID_SAVE_CFG, _( "Save Cfg..." ) ); - RightBoxSizer->Add( Button, 0, wxGROW | wxALL, 5 ); - - // Provide a spacer to improve appearance of dialog box - RightBoxSizer->AddSpacer( 20 ); - - Button = new wxButton( this, wxID_OK, _( "OK" ) ); - RightBoxSizer->Add( Button, 0, wxGROW | wxALL, 5 ); - - Button = new wxButton( this, wxID_CANCEL, _( "Cancel" ) ); - RightBoxSizer->Add( Button, 0, wxGROW | wxALL, 5 ); - - wxSize size; - size.x = LEN_EXT; - size.y = -1; - TextDrillExt = new WinEDA_EnterText( this, - _( "Drill File Ext:" ), - g_DrillFilenameExt, - LeftBoxSizer, size ); - - TextPhotoExt = new WinEDA_EnterText( this, - _( "Gerber File Ext:" ), - g_PhotoFilenameExt, - LeftBoxSizer, size ); - - TextPenExt = new WinEDA_EnterText( this, - _( "D code File Ext:" ), - g_PenFilenameExt, - LeftBoxSizer, size ); - - GetSizer()->Fit( this ); - GetSizer()->SetSizeHints( this ); -} - - -void WinEDA_ConfigFrame::OnOkClick( wxCommandEvent& event ) -{ - g_DrillFilenameExt = TextDrillExt->GetValue(); - g_PhotoFilenameExt = TextPhotoExt->GetValue(); - g_PenFilenameExt = TextPenExt->GetValue(); - - EndModal( 1 ); -} - - -void WinEDA_ConfigFrame::OnCancelClick( wxCommandEvent& event ) -{ - EndModal( -1 ); -} - - -void WinEDA_ConfigFrame::SaveCfg( wxCommandEvent& event ) -{ - m_Parent->Update_config(); -} diff --git a/gerbview/dialogs/dialog_print_using_printer.cpp b/gerbview/dialogs/dialog_print_using_printer.cpp index f82d8f3d0d..dbc8cb5a79 100644 --- a/gerbview/dialogs/dialog_print_using_printer.cpp +++ b/gerbview/dialogs/dialog_print_using_printer.cpp @@ -44,14 +44,14 @@ static PRINT_PARAMETERS s_Parameters; class DIALOG_PRINT_USING_PRINTER : public DIALOG_PRINT_USING_PRINTER_base { private: - WinEDA_GerberFrame* m_Parent; + GERBVIEW_FRAME* m_Parent; wxConfig* m_Config; wxCheckBox* m_BoxSelectLayer[32]; static wxPoint s_LastPos; static wxSize s_LastSize; public: - DIALOG_PRINT_USING_PRINTER( WinEDA_GerberFrame* parent ); + DIALOG_PRINT_USING_PRINTER( GERBVIEW_FRAME* parent ); ~DIALOG_PRINT_USING_PRINTER() {}; private: @@ -80,7 +80,7 @@ wxSize DIALOG_PRINT_USING_PRINTER::s_LastSize; /*******************************************************/ -void WinEDA_GerberFrame::ToPrinter( wxCommandEvent& event ) +void GERBVIEW_FRAME::ToPrinter( wxCommandEvent& event ) /*******************************************************/ /* Virtual function: @@ -106,7 +106,7 @@ void WinEDA_GerberFrame::ToPrinter( wxCommandEvent& event ) /*************************************************************************************/ -DIALOG_PRINT_USING_PRINTER::DIALOG_PRINT_USING_PRINTER( WinEDA_GerberFrame* parent ) : +DIALOG_PRINT_USING_PRINTER::DIALOG_PRINT_USING_PRINTER( GERBVIEW_FRAME* parent ) : DIALOG_PRINT_USING_PRINTER_base( parent ) /*************************************************************************************/ { diff --git a/gerbview/dialogs/gerbview_dialog_display_options_frame.cpp b/gerbview/dialogs/gerbview_dialog_display_options_frame.cpp index 1bbebebec7..eaaf1b27b7 100644 --- a/gerbview/dialogs/gerbview_dialog_display_options_frame.cpp +++ b/gerbview/dialogs/gerbview_dialog_display_options_frame.cpp @@ -19,11 +19,11 @@ class DIALOG_DISPLAY_OPTIONS : public DIALOG_DISPLAY_OPTIONS_BASE { private: - WinEDA_GerberFrame* m_Parent; + GERBVIEW_FRAME* m_Parent; public: - DIALOG_DISPLAY_OPTIONS( WinEDA_GerberFrame* parent ); + DIALOG_DISPLAY_OPTIONS( GERBVIEW_FRAME* parent ); ~DIALOG_DISPLAY_OPTIONS() {}; private: @@ -33,7 +33,7 @@ private: }; -void WinEDA_GerberFrame::InstallGerberOptionsDialog( wxCommandEvent& event ) +void GERBVIEW_FRAME::InstallGerberOptionsDialog( wxCommandEvent& event ) { DIALOG_DISPLAY_OPTIONS dlg( this ); int opt = dlg.ShowModal(); @@ -41,7 +41,7 @@ void WinEDA_GerberFrame::InstallGerberOptionsDialog( wxCommandEvent& event ) DrawPanel->Refresh(); } -DIALOG_DISPLAY_OPTIONS::DIALOG_DISPLAY_OPTIONS( WinEDA_GerberFrame *parent) : +DIALOG_DISPLAY_OPTIONS::DIALOG_DISPLAY_OPTIONS( GERBVIEW_FRAME *parent) : DIALOG_DISPLAY_OPTIONS_BASE( parent, wxID_ANY ) { m_Parent = parent; diff --git a/gerbview/draw_gerber_screen.cpp b/gerbview/draw_gerber_screen.cpp index 19b9b4a1a0..d741148c8c 100644 --- a/gerbview/draw_gerber_screen.cpp +++ b/gerbview/draw_gerber_screen.cpp @@ -28,7 +28,7 @@ * @param aPrintMirrorMode = true to plot mirrored * @param aData = a pointer to an optional data (not used here: can be NULL) */ -void WinEDA_GerberFrame::PrintPage( wxDC* aDC, int aPrintMasklayer, +void GERBVIEW_FRAME::PrintPage( wxDC* aDC, int aPrintMasklayer, bool aPrintMirrorMode, void* aData ) { // Save current draw options, because print mode has specfic options: @@ -58,7 +58,7 @@ void WinEDA_GerberFrame::PrintPage( wxDC* aDC, int aPrintMasklayer, /* Redraws the full screen, including axis and grid */ -void WinEDA_GerberFrame::RedrawActiveWindow( wxDC* DC, bool EraseBg ) +void GERBVIEW_FRAME::RedrawActiveWindow( wxDC* DC, bool EraseBg ) { PCB_SCREEN* screen = (PCB_SCREEN*) GetScreen(); @@ -267,7 +267,7 @@ void BOARD::Draw( EDA_DRAW_PANEL* aPanel, wxDC* aDC, int aDrawMode, const wxPoin * Draw the DCode value (if exists) corresponding to gerber item * Polygons do not have a DCode */ -void WinEDA_GerberFrame::DrawItemsDCodeID( wxDC* aDC, int aDrawMode ) +void GERBVIEW_FRAME::DrawItemsDCodeID( wxDC* aDC, int aDrawMode ) { wxPoint pos; int width, orient; diff --git a/gerbview/edit.cpp b/gerbview/edit.cpp index 68e171df4e..19a8e5b096 100644 --- a/gerbview/edit.cpp +++ b/gerbview/edit.cpp @@ -20,7 +20,7 @@ /* Process the command triggered by the left button of the mouse when a tool * is already selected. */ -void WinEDA_GerberFrame::OnLeftClick( wxDC* DC, const wxPoint& aPosition ) +void GERBVIEW_FRAME::OnLeftClick( wxDC* DC, const wxPoint& aPosition ) { BOARD_ITEM* DrawStruct = GetScreen()->GetCurItem(); wxString msg; @@ -29,7 +29,7 @@ void WinEDA_GerberFrame::OnLeftClick( wxDC* DC, const wxPoint& aPosition ) { if( DrawStruct && DrawStruct->m_Flags ) { - msg.Printf( wxT( "WinEDA_GerberFrame::ProcessCommand err: Struct %d, m_Flags = %X" ), + msg.Printf( wxT( "GERBVIEW_FRAME::ProcessCommand err: Struct %d, m_Flags = %X" ), (unsigned) DrawStruct->Type(), (unsigned) DrawStruct->m_Flags ); DisplayError( this, msg ); @@ -52,9 +52,6 @@ void WinEDA_GerberFrame::OnLeftClick( wxDC* DC, const wxPoint& aPosition ) case ID_NO_TOOL_SELECTED: break; - case ID_GERBVIEW_DELETE_ITEM_BUTT: - DrawStruct = Locate( aPosition, CURSEUR_OFF_GRILLE ); - if( DrawStruct == NULL ) break; /* TODO: @@ -65,7 +62,7 @@ void WinEDA_GerberFrame::OnLeftClick( wxDC* DC, const wxPoint& aPosition ) break; default: - DisplayError( this, wxT( "WinEDA_GerberFrame::ProcessCommand error" ) ); + DisplayError( this, wxT( "GERBVIEW_FRAME::ProcessCommand error" ) ); break; } } @@ -73,7 +70,7 @@ void WinEDA_GerberFrame::OnLeftClick( wxDC* DC, const wxPoint& aPosition ) /* Handles the selection of tools, menu, and popup menu commands. */ -void WinEDA_GerberFrame::Process_Special_Functions( wxCommandEvent& event ) +void GERBVIEW_FRAME::Process_Special_Functions( wxCommandEvent& event ) { int id = event.GetId(); int layer = GetScreen()->m_Active_Layer; @@ -140,10 +137,6 @@ void WinEDA_GerberFrame::Process_Special_Functions( wxCommandEvent& event ) case ID_POPUP_CANCEL_CURRENT_COMMAND: break; - case ID_GERBVIEW_DELETE_ITEM_BUTT: - SetToolID( id, wxCURSOR_BULLSEYE, wxT( "Delete item" ) ); - break; - case ID_TOOLBARH_GERBVIEW_SELECT_LAYER: setActiveLayer(m_SelLayerBox->GetChoice()); DrawPanel->Refresh(); @@ -196,14 +189,8 @@ void WinEDA_GerberFrame::Process_Special_Functions( wxCommandEvent& event ) HandleBlockEnd( &dc ); break; - case ID_GERBVIEW_POPUP_DELETE_DCODE_ITEMS: - if( gerber_layer ) - Delete_DCode_Items( &dc, gerber_layer->m_Selected_Tool, - ( (PCB_SCREEN*) GetScreen() )->m_Active_Layer ); - break; - default: - wxMessageBox( wxT( "WinEDA_GerberFrame::Process_Special_Functions error" ) ); + wxMessageBox( wxT( "GERBVIEW_FRAME::Process_Special_Functions error" ) ); break; } } @@ -211,7 +198,7 @@ void WinEDA_GerberFrame::Process_Special_Functions( wxCommandEvent& event ) /* Called on a double click of left mouse button. */ -void WinEDA_GerberFrame::OnLeftDClick( wxDC* DC, const wxPoint& aPosition ) +void GERBVIEW_FRAME::OnLeftDClick( wxDC* DC, const wxPoint& aPosition ) { // Currently: no nothing } diff --git a/gerbview/export_to_pcbnew.cpp b/gerbview/export_to_pcbnew.cpp index 8d3bbe0683..8d0bed9f70 100644 --- a/gerbview/export_to_pcbnew.cpp +++ b/gerbview/export_to_pcbnew.cpp @@ -15,13 +15,13 @@ #include "class_board_design_settings.h" #include "class_gerber_draw_item.h" -static int SavePcbFormatAscii( WinEDA_GerberFrame* frame, +static int SavePcbFormatAscii( GERBVIEW_FRAME* frame, FILE* File, int* LayerLookUpTable ); /* Export data in pcbnew format */ -void WinEDA_GerberFrame::ExportDataInPcbnewFormat( wxCommandEvent& event ) +void GERBVIEW_FRAME::ExportDataInPcbnewFormat( wxCommandEvent& event ) { int ii = 0; bool no_used_layers = true; // Changed to false if any used layer found @@ -124,7 +124,7 @@ static bool WriteGeneralDescrPcb( BOARD* Pcb, FILE* File ) * @param LayerLookUpTable = look up table: pcbnew layer for each gerber layer * @return 1 if OK, 0 if fail */ -static int SavePcbFormatAscii( WinEDA_GerberFrame* frame, FILE* aFile, +static int SavePcbFormatAscii( GERBVIEW_FRAME* frame, FILE* aFile, int* LayerLookUpTable ) { char line[256]; diff --git a/gerbview/files.cpp b/gerbview/files.cpp index 45513a71ba..712ddfa306 100644 --- a/gerbview/files.cpp +++ b/gerbview/files.cpp @@ -10,14 +10,14 @@ #include "gerbview.h" -static void LoadDCodeFile( WinEDA_GerberFrame* frame, +static void LoadDCodeFile( GERBVIEW_FRAME* frame, const wxString& FullFileName ); /* Load a Gerber file selected from history list on current layer * Previous data is deleted */ -void WinEDA_GerberFrame::OnFileHistory( wxCommandEvent& event ) +void GERBVIEW_FRAME::OnFileHistory( wxCommandEvent& event ) { wxString fn; @@ -32,7 +32,7 @@ void WinEDA_GerberFrame::OnFileHistory( wxCommandEvent& event ) /* File commands. */ -void WinEDA_GerberFrame::Files_io( wxCommandEvent& event ) +void GERBVIEW_FRAME::Files_io( wxCommandEvent& event ) { int id = event.GetId(); @@ -89,7 +89,7 @@ clear an existing layer to load any new layers." ), NB_LAYERS ); } -bool WinEDA_GerberFrame::LoadGerberFiles( const wxString& aFullFileName ) +bool GERBVIEW_FRAME::LoadGerberFiles( const wxString& aFullFileName ) { wxString filetypes; wxArrayString filenamesList; @@ -164,9 +164,6 @@ bool WinEDA_GerberFrame::LoadGerberFiles( const wxString& aFullFileName ) if( !filename.IsAbsolute() ) filename.SetPath( currentPath ); - if( !filename.HasExt() ) - filename.SetExt( g_PenFilenameExt ); - GetScreen()->SetFileName( filename.GetFullPath() ); setActiveLayer( layer, false ); @@ -208,19 +205,16 @@ bool WinEDA_GerberFrame::LoadGerberFiles( const wxString& aFullFileName ) * 0 if file not read (cancellation of order ...) * 1 if OK */ -static void LoadDCodeFile( WinEDA_GerberFrame* frame, const wxString& FullFileName ) +static void LoadDCodeFile( GERBVIEW_FRAME* frame, const wxString& FullFileName ) { wxString wildcard; wxFileName fn = FullFileName; if( !fn.IsOk() ) { - wildcard.Printf( _( "Gerber DCODE files (%s)|*.%s" ), - GetChars( g_PenFilenameExt ), - GetChars( g_PenFilenameExt ) ); + wildcard = _( "Gerber DCODE files" ); wildcard += AllFilesWildcard; fn = frame->GetScreen()->GetFileName(); - fn.SetExt( g_PenFilenameExt ); wxFileDialog dlg( (wxWindow*) frame, _( "Load GERBER DCODE File" ), fn.GetPath(), fn.GetFullName(), wildcard, wxFD_OPEN | wxFD_FILE_MUST_EXIST ); diff --git a/gerbview/gerberframe.cpp b/gerbview/gerberframe.cpp index 9c6096a446..96a7b55a96 100644 --- a/gerbview/gerberframe.cpp +++ b/gerbview/gerberframe.cpp @@ -21,106 +21,108 @@ #include "build_version.h" +// Config keywords +const wxString GerbviewShowPageSizeOption( wxT( "ShowPageSizeOpt" ) ); +const wxString GerbviewShowDCodes( wxT( "ShowDCodesOpt" ) ); + /****************************************/ -/* class WinEDA_GerberFrame for GerbView*/ +/* class GERBVIEW_FRAME for GerbView*/ /****************************************/ -BEGIN_EVENT_TABLE( WinEDA_GerberFrame, PCB_BASE_FRAME ) - EVT_CLOSE( WinEDA_GerberFrame::OnCloseWindow ) - EVT_SIZE( WinEDA_GerberFrame::OnSize ) +BEGIN_EVENT_TABLE( GERBVIEW_FRAME, PCB_BASE_FRAME ) + EVT_CLOSE( GERBVIEW_FRAME::OnCloseWindow ) + EVT_SIZE( GERBVIEW_FRAME::OnSize ) - EVT_TOOL( wxID_FILE, WinEDA_GerberFrame::Files_io ) - EVT_TOOL( ID_INC_LAYER_AND_APPEND_FILE, WinEDA_GerberFrame::Files_io ) - EVT_TOOL( ID_GERBVIEW_LOAD_DRILL_FILE, WinEDA_GerberFrame::Files_io ) - EVT_TOOL( ID_GERBVIEW_LOAD_DCODE_FILE, WinEDA_GerberFrame::Files_io ) - EVT_TOOL( ID_NEW_BOARD, WinEDA_GerberFrame::Files_io ) + EVT_TOOL( wxID_FILE, GERBVIEW_FRAME::Files_io ) + EVT_TOOL( ID_INC_LAYER_AND_APPEND_FILE, GERBVIEW_FRAME::Files_io ) + EVT_TOOL( ID_GERBVIEW_LOAD_DRILL_FILE, GERBVIEW_FRAME::Files_io ) + EVT_TOOL( ID_GERBVIEW_LOAD_DCODE_FILE, GERBVIEW_FRAME::Files_io ) + EVT_TOOL( ID_NEW_BOARD, GERBVIEW_FRAME::Files_io ) // Menu Files: - EVT_MENU( wxID_FILE, WinEDA_GerberFrame::Files_io ) - EVT_MENU( ID_MENU_INC_LAYER_AND_APPEND_FILE, WinEDA_GerberFrame::Files_io ) - EVT_MENU( ID_NEW_BOARD, WinEDA_GerberFrame::Files_io ) - EVT_MENU( ID_GEN_PLOT, WinEDA_GerberFrame::ToPlotter ) - EVT_MENU( ID_GERBVIEW_EXPORT_TO_PCBNEW, WinEDA_GerberFrame::ExportDataInPcbnewFormat ) + EVT_MENU( wxID_FILE, GERBVIEW_FRAME::Files_io ) + EVT_MENU( ID_MENU_INC_LAYER_AND_APPEND_FILE, GERBVIEW_FRAME::Files_io ) + EVT_MENU( ID_NEW_BOARD, GERBVIEW_FRAME::Files_io ) + EVT_MENU( ID_GEN_PLOT, GERBVIEW_FRAME::ToPlotter ) + EVT_MENU( ID_GERBVIEW_EXPORT_TO_PCBNEW, GERBVIEW_FRAME::ExportDataInPcbnewFormat ) - EVT_MENU_RANGE( wxID_FILE1, wxID_FILE9, WinEDA_GerberFrame::OnFileHistory ) + EVT_MENU_RANGE( wxID_FILE1, wxID_FILE9, GERBVIEW_FRAME::OnFileHistory ) - EVT_MENU( ID_EXIT, WinEDA_GerberFrame::Process_Special_Functions ) + EVT_MENU( ID_EXIT, GERBVIEW_FRAME::Process_Special_Functions ) // menu Preferences - EVT_MENU( ID_CONFIG_REQ, WinEDA_GerberFrame::Process_Config ) - EVT_MENU( ID_CONFIG_SAVE, WinEDA_GerberFrame::Process_Config ) + EVT_MENU( ID_CONFIG_REQ, GERBVIEW_FRAME::Process_Config ) EVT_MENU_RANGE( ID_PREFERENCES_HOTKEY_START, ID_PREFERENCES_HOTKEY_END, - WinEDA_GerberFrame::Process_Config ) + GERBVIEW_FRAME::Process_Config ) EVT_MENU( ID_MENU_GERBVIEW_SHOW_HIDE_LAYERS_MANAGER_DIALOG, - WinEDA_GerberFrame::OnSelectOptionToolbar ) - EVT_MENU( ID_GERBVIEW_OPTIONS_SETUP, WinEDA_GerberFrame::InstallGerberOptionsDialog ) + GERBVIEW_FRAME::OnSelectOptionToolbar ) + EVT_MENU( ID_GERBVIEW_OPTIONS_SETUP, GERBVIEW_FRAME::InstallGerberOptionsDialog ) EVT_MENU_RANGE( ID_LANGUAGE_CHOICE, ID_LANGUAGE_CHOICE_END, EDA_DRAW_FRAME::SetLanguage ) // menu Postprocess - EVT_MENU( ID_GERBVIEW_SHOW_LIST_DCODES, WinEDA_GerberFrame::Process_Special_Functions ) - EVT_MENU( ID_GERBVIEW_POPUP_DELETE_DCODE_ITEMS, WinEDA_GerberFrame::Process_Special_Functions ) - EVT_MENU( ID_GERBVIEW_SHOW_SOURCE, WinEDA_GerberFrame::Process_Special_Functions ) + EVT_MENU( ID_GERBVIEW_SHOW_LIST_DCODES, GERBVIEW_FRAME::Process_Special_Functions ) + EVT_MENU( ID_GERBVIEW_POPUP_DELETE_DCODE_ITEMS, GERBVIEW_FRAME::Process_Special_Functions ) + EVT_MENU( ID_GERBVIEW_SHOW_SOURCE, GERBVIEW_FRAME::Process_Special_Functions ) // menu Miscellaneous - EVT_MENU( ID_GERBVIEW_GLOBAL_DELETE, WinEDA_GerberFrame::Process_Special_Functions ) + EVT_MENU( ID_GERBVIEW_GLOBAL_DELETE, GERBVIEW_FRAME::Process_Special_Functions ) // Menu Help EVT_MENU( ID_GENERAL_HELP, EDA_DRAW_FRAME::GetKicadHelp ) EVT_MENU( ID_KICAD_ABOUT, EDA_DRAW_FRAME::GetKicadAbout ) - EVT_TOOL( wxID_CUT, WinEDA_GerberFrame::Process_Special_Functions ) - EVT_TOOL( wxID_COPY, WinEDA_GerberFrame::Process_Special_Functions ) - EVT_TOOL( wxID_PASTE, WinEDA_GerberFrame::Process_Special_Functions ) - EVT_TOOL( wxID_UNDO, WinEDA_GerberFrame::Process_Special_Functions ) - EVT_TOOL( wxID_PRINT, WinEDA_GerberFrame::ToPrinter ) - EVT_TOOL( ID_FIND_ITEMS, WinEDA_GerberFrame::Process_Special_Functions ) + EVT_TOOL( wxID_CUT, GERBVIEW_FRAME::Process_Special_Functions ) + EVT_TOOL( wxID_COPY, GERBVIEW_FRAME::Process_Special_Functions ) + EVT_TOOL( wxID_PASTE, GERBVIEW_FRAME::Process_Special_Functions ) + EVT_TOOL( wxID_UNDO, GERBVIEW_FRAME::Process_Special_Functions ) + EVT_TOOL( wxID_PRINT, GERBVIEW_FRAME::ToPrinter ) + EVT_TOOL( ID_FIND_ITEMS, GERBVIEW_FRAME::Process_Special_Functions ) EVT_KICAD_CHOICEBOX( ID_TOOLBARH_GERBVIEW_SELECT_LAYER, - WinEDA_GerberFrame::Process_Special_Functions ) + GERBVIEW_FRAME::Process_Special_Functions ) EVT_SELECT_DCODE( ID_TOOLBARH_GERBER_SELECT_TOOL, - WinEDA_GerberFrame::Process_Special_Functions ) + GERBVIEW_FRAME::Process_Special_Functions ) // Vertical toolbar: - EVT_TOOL( ID_NO_TOOL_SELECTED, WinEDA_GerberFrame::Process_Special_Functions ) - EVT_TOOL( ID_GERBVIEW_DELETE_ITEM_BUTT, WinEDA_GerberFrame::Process_Special_Functions ) + EVT_TOOL( ID_NO_TOOL_SELECTED, GERBVIEW_FRAME::Process_Special_Functions ) EVT_MENU_RANGE( ID_POPUP_GENERAL_START_RANGE, ID_POPUP_GENERAL_END_RANGE, - WinEDA_GerberFrame::Process_Special_Functions ) + GERBVIEW_FRAME::Process_Special_Functions ) // Pop up menu - EVT_MENU( ID_GERBVIEW_POPUP_DELETE_DCODE_ITEMS, WinEDA_GerberFrame::Process_Special_Functions ) + EVT_MENU( ID_GERBVIEW_POPUP_DELETE_DCODE_ITEMS, GERBVIEW_FRAME::Process_Special_Functions ) // Option toolbar EVT_TOOL( ID_TB_OPTIONS_SHOW_POLYGONS_SKETCH, - WinEDA_GerberFrame::OnSelectOptionToolbar ) - EVT_TOOL( ID_TB_OPTIONS_SHOW_FLASHED_ITEMS_SKETCH, WinEDA_GerberFrame::OnSelectOptionToolbar ) - EVT_TOOL( ID_TB_OPTIONS_SHOW_LINES_SKETCH, WinEDA_GerberFrame::OnSelectOptionToolbar ) + GERBVIEW_FRAME::OnSelectOptionToolbar ) + EVT_TOOL( ID_TB_OPTIONS_SHOW_FLASHED_ITEMS_SKETCH, GERBVIEW_FRAME::OnSelectOptionToolbar ) + EVT_TOOL( ID_TB_OPTIONS_SHOW_LINES_SKETCH, GERBVIEW_FRAME::OnSelectOptionToolbar ) EVT_TOOL( ID_TB_OPTIONS_SHOW_LAYERS_MANAGER_VERTICAL_TOOLBAR, - WinEDA_GerberFrame::OnSelectOptionToolbar ) - EVT_TOOL( ID_TB_OPTIONS_SHOW_DCODES, WinEDA_GerberFrame::OnSelectOptionToolbar ) + GERBVIEW_FRAME::OnSelectOptionToolbar ) + EVT_TOOL( ID_TB_OPTIONS_SHOW_DCODES, GERBVIEW_FRAME::OnSelectOptionToolbar ) EVT_TOOL_RANGE( ID_TB_OPTIONS_SHOW_GBR_MODE_0, ID_TB_OPTIONS_SHOW_GBR_MODE_2, - WinEDA_GerberFrame::OnSelectDisplayMode ) + GERBVIEW_FRAME::OnSelectDisplayMode ) EVT_UPDATE_UI( ID_TB_OPTIONS_SHOW_FLASHED_ITEMS_SKETCH, - WinEDA_GerberFrame::OnUpdateFlashedItemsDrawMode ) - EVT_UPDATE_UI( ID_TB_OPTIONS_SHOW_LINES_SKETCH, WinEDA_GerberFrame::OnUpdateLinesDrawMode ) + GERBVIEW_FRAME::OnUpdateFlashedItemsDrawMode ) + EVT_UPDATE_UI( ID_TB_OPTIONS_SHOW_LINES_SKETCH, GERBVIEW_FRAME::OnUpdateLinesDrawMode ) EVT_UPDATE_UI( ID_TB_OPTIONS_SHOW_POLYGONS_SKETCH, - WinEDA_GerberFrame::OnUpdatePolygonsDrawMode ) - EVT_UPDATE_UI( ID_TB_OPTIONS_SHOW_DCODES, WinEDA_GerberFrame::OnUpdateShowDCodes ) + GERBVIEW_FRAME::OnUpdatePolygonsDrawMode ) + EVT_UPDATE_UI( ID_TB_OPTIONS_SHOW_DCODES, GERBVIEW_FRAME::OnUpdateShowDCodes ) EVT_UPDATE_UI( ID_TB_OPTIONS_SHOW_LAYERS_MANAGER_VERTICAL_TOOLBAR, - WinEDA_GerberFrame::OnUpdateShowLayerManager ) + GERBVIEW_FRAME::OnUpdateShowLayerManager ) - EVT_UPDATE_UI( ID_TOOLBARH_GERBER_SELECT_TOOL, WinEDA_GerberFrame::OnUpdateSelectDCode ) - EVT_UPDATE_UI( ID_TOOLBARH_GERBVIEW_SELECT_LAYER, WinEDA_GerberFrame::OnUpdateLayerSelectBox ) + EVT_UPDATE_UI( ID_TOOLBARH_GERBER_SELECT_TOOL, GERBVIEW_FRAME::OnUpdateSelectDCode ) + EVT_UPDATE_UI( ID_TOOLBARH_GERBVIEW_SELECT_LAYER, GERBVIEW_FRAME::OnUpdateLayerSelectBox ) EVT_UPDATE_UI_RANGE( ID_TB_OPTIONS_SHOW_GBR_MODE_0, ID_TB_OPTIONS_SHOW_GBR_MODE_2, - WinEDA_GerberFrame::OnUpdateDrawMode ) + GERBVIEW_FRAME::OnUpdateDrawMode ) END_EVENT_TABLE() -WinEDA_GerberFrame::WinEDA_GerberFrame( wxWindow* father, +GERBVIEW_FRAME::GERBVIEW_FRAME( wxWindow* father, const wxString& title, const wxPoint& pos, const wxSize& size, @@ -221,22 +223,21 @@ WinEDA_GerberFrame::WinEDA_GerberFrame( wxWindow* father, } -WinEDA_GerberFrame::~WinEDA_GerberFrame() +GERBVIEW_FRAME::~GERBVIEW_FRAME() { SetScreen( ScreenPcb ); - extern PARAM_CFG_BASE* ParamCfgList[]; - wxGetApp().SaveCurrentSetupValues( ParamCfgList ); + wxGetApp().SaveCurrentSetupValues( m_configSettings ); } -void WinEDA_GerberFrame::OnCloseWindow( wxCloseEvent& Event ) +void GERBVIEW_FRAME::OnCloseWindow( wxCloseEvent& Event ) { SaveSettings(); Destroy(); } -int WinEDA_GerberFrame::BestZoom() +int GERBVIEW_FRAME::BestZoom() { // gives a minimal value to zoom, if no item in list if( GetBoard()->m_Drawings == NULL ) @@ -265,7 +266,7 @@ int WinEDA_GerberFrame::BestZoom() } -void WinEDA_GerberFrame::LoadSettings() +void GERBVIEW_FRAME::LoadSettings() { wxConfig* config = wxGetApp().m_EDA_Config; @@ -273,7 +274,9 @@ void WinEDA_GerberFrame::LoadSettings() return; PCB_BASE_FRAME::LoadSettings(); - config->Read( GerbviewDrawModeOption, &m_displayMode, 0l ); + + wxGetApp().ReadCurrentSetupValues( GetConfigurationSettings() ); + long pageSize_opt; config->Read( GerbviewShowPageSizeOption, &pageSize_opt, 0l ); int imax = 0; @@ -297,7 +300,7 @@ void WinEDA_GerberFrame::LoadSettings() } -void WinEDA_GerberFrame::SaveSettings() +void GERBVIEW_FRAME::SaveSettings() { wxConfig* config = wxGetApp().m_EDA_Config; @@ -306,6 +309,8 @@ void WinEDA_GerberFrame::SaveSettings() PCB_BASE_FRAME::SaveSettings(); + wxGetApp().SaveCurrentSetupValues( GetConfigurationSettings() ); + wxRealPoint GridSize = GetScreen()->GetGridSize(); long pageSize_opt = 0; @@ -322,13 +327,12 @@ void WinEDA_GerberFrame::SaveSettings() } } - config->Write( GerbviewDrawModeOption, m_displayMode ); config->Write( GerbviewShowPageSizeOption, pageSize_opt ); config->Write( GerbviewShowDCodes, IsElementVisible( DCODES_VISIBLE ) ); } -void WinEDA_GerberFrame::ReFillLayerWidget() +void GERBVIEW_FRAME::ReFillLayerWidget() { m_LayersManager->ReFill(); @@ -353,7 +357,7 @@ void WinEDA_GerberFrame::ReFillLayerWidget() * Function IsGridVisible() , virtual * @return true if the grid must be shown */ -bool WinEDA_GerberFrame::IsGridVisible() +bool GERBVIEW_FRAME::IsGridVisible() { return IsElementVisible( GERBER_GRID_VISIBLE ); } @@ -365,7 +369,7 @@ bool WinEDA_GerberFrame::IsGridVisible() * if you want to store/retrieve the grid visiblity in configuration. * @param aVisible = true if the grid must be shown */ -void WinEDA_GerberFrame::SetGridVisibility( bool aVisible ) +void GERBVIEW_FRAME::SetGridVisibility( bool aVisible ) { SetElementVisibility( GERBER_GRID_VISIBLE, aVisible ); } @@ -375,7 +379,7 @@ void WinEDA_GerberFrame::SetGridVisibility( bool aVisible ) * Function GetGridColor() , virtual * @return the color of the grid */ -int WinEDA_GerberFrame::GetGridColor() +int GERBVIEW_FRAME::GetGridColor() { return GetBoard()->GetVisibleElementColor( GERBER_GRID_VISIBLE ); } @@ -385,7 +389,7 @@ int WinEDA_GerberFrame::GetGridColor() * Function SetGridColor() , virtual * @param aColor = the new color of the grid */ -void WinEDA_GerberFrame::SetGridColor( int aColor ) +void GERBVIEW_FRAME::SetGridColor( int aColor ) { GetBoard()->SetVisibleElementColor( GERBER_GRID_VISIBLE, aColor ); } @@ -398,14 +402,14 @@ void WinEDA_GerberFrame::SetGridColor( int aColor ) * @param aNewState = The new visibility state of the element category * @see enum aGERBER_VISIBLE */ -void WinEDA_GerberFrame::SetElementVisibility( int aGERBER_VISIBLE, bool aNewState ) +void GERBVIEW_FRAME::SetElementVisibility( int aGERBER_VISIBLE, bool aNewState ) { GetBoard()->SetElementVisibility( aGERBER_VISIBLE, aNewState ); m_LayersManager->SetRenderState( aGERBER_VISIBLE, aNewState ); } -int WinEDA_GerberFrame::getNextAvailableLayer( int aLayer ) const +int GERBVIEW_FRAME::getNextAvailableLayer( int aLayer ) const { int layer = aLayer; @@ -426,7 +430,7 @@ int WinEDA_GerberFrame::getNextAvailableLayer( int aLayer ) const } -void WinEDA_GerberFrame::syncLayerWidget() +void GERBVIEW_FRAME::syncLayerWidget() { m_LayersManager->SelectLayer( getActiveLayer() ); UpdateTitleAndInfo(); @@ -439,7 +443,7 @@ void WinEDA_GerberFrame::syncLayerWidget() * The currently active layer, as defined by the return value of * getActiveLayer(). And updates the colored icon in the toolbar. */ -void WinEDA_GerberFrame::syncLayerBox() +void GERBVIEW_FRAME::syncLayerBox() { m_SelLayerBox->SetSelection( getActiveLayer() ); int dcodeSelected = -1; @@ -463,7 +467,7 @@ void WinEDA_GerberFrame::syncLayerBox() * called on a language menu selection * Update Layer manager title and tabs texts */ -void WinEDA_GerberFrame::SetLanguage( wxCommandEvent& event ) +void GERBVIEW_FRAME::SetLanguage( wxCommandEvent& event ) { EDA_DRAW_FRAME::SetLanguage( event ); m_LayersManager->SetLayersManagerTabsText(); @@ -475,7 +479,7 @@ void WinEDA_GerberFrame::SetLanguage( wxCommandEvent& event ) } -void WinEDA_GerberFrame::Liste_D_Codes() +void GERBVIEW_FRAME::Liste_D_Codes() { int ii, jj; D_CODE* pt_D_code; @@ -549,7 +553,7 @@ void WinEDA_GerberFrame::Liste_D_Codes() * Note layer name can change when reading a gerber file, and the layer name is the last found. * So, show the layer name is not very useful, and can be seen as a debug feature. */ -void WinEDA_GerberFrame::UpdateTitleAndInfo() +void GERBVIEW_FRAME::UpdateTitleAndInfo() { GERBER_IMAGE* gerber = g_GERBER_List[ GetScreen()->m_Active_Layer ]; wxString text; @@ -592,7 +596,7 @@ void WinEDA_GerberFrame::UpdateTitleAndInfo() /* Function OnSelectDisplayMode: called to select display mode * (fast display, or exact mode with stacked images or with transparency */ -void WinEDA_GerberFrame::OnSelectDisplayMode( wxCommandEvent& event ) +void GERBVIEW_FRAME::OnSelectDisplayMode( wxCommandEvent& event ) { int oldMode = GetDisplayMode(); diff --git a/gerbview/gerbview.cpp b/gerbview/gerbview.cpp index 1f91508ca6..938e0ef529 100644 --- a/gerbview/gerbview.cpp +++ b/gerbview/gerbview.cpp @@ -24,26 +24,12 @@ #include #include -extern bool Read_Config(); - -wxString g_PhotoFilenameExt; -wxString g_DrillFilenameExt; -wxString g_PenFilenameExt; - // Colors for layers and items COLORS_DESIGN_SETTINGS g_ColorsSettings; int g_Default_GERBER_Format; int g_DisplayPolygonsModeSketch; -const wxString GerbviewProjectFileExt( wxT( "cnf" ) ); -const wxString GerbviewProjectFileWildcard( _( "GerbView project files (.cnf)|*.cnf" ) ); - -// Config keywords -const wxString GerbviewDrawModeOption( wxT( "DrawModeOption" ) ); -const wxString GerbviewShowPageSizeOption( wxT( "ShowPageSizeOpt" ) ); -const wxString GerbviewShowDCodes( wxT( "ShowDCodesOpt" ) ); - GERBER_IMAGE* g_GERBER_List[32]; // List of page sizes @@ -65,7 +51,7 @@ IMPLEMENT_APP( WinEDA_App ) void WinEDA_App::MacOpenFile(const wxString &fileName) { wxFileName filename = fileName; - WinEDA_GerberFrame * frame = ((WinEDA_GerberFrame*)GetTopWindow()); + GERBVIEW_FRAME * frame = ((GERBVIEW_FRAME*)GetTopWindow()); if( !filename.FileExists() ) return; @@ -77,7 +63,7 @@ void WinEDA_App::MacOpenFile(const wxString &fileName) bool WinEDA_App::OnInit() { wxFileName fn; - WinEDA_GerberFrame* frame = NULL; + GERBVIEW_FRAME* frame = NULL; #ifdef __WXMAC__ wxApp::s_macAboutMenuItemId = ID_KICAD_ABOUT; @@ -99,16 +85,13 @@ bool WinEDA_App::OnInit() bool reopenLastUsedDirectory = argc == 1; GetSettings( reopenLastUsedDirectory ); - extern PARAM_CFG_BASE* ParamCfgList[]; - wxGetApp().ReadCurrentSetupValues( ParamCfgList ); - g_DrawBgColor = BLACK; /* Must be called before creating the main frame in order to * display the real hotkeys in menus or tool tips */ ReadHotkeyConfig( wxT("GerberFrame"), s_Gerbview_Hokeys_Descr ); - frame = new WinEDA_GerberFrame( NULL, wxT( "GerbView" ), + frame = new GERBVIEW_FRAME( NULL, wxT( "GerbView" ), wxPoint( 0, 0 ), wxSize( 600, 400 ) ); @@ -126,8 +109,6 @@ bool WinEDA_App::OnInit() frame->Zoom_Automatique( true ); // Zoom fit in frame frame->GetScreen()->m_FirstRedraw = false; - Read_Config(); - if( argc <= 1 ) return true; diff --git a/gerbview/gerbview.h b/gerbview/gerbview.h index 0601e0ceb1..3e8b2166cf 100644 --- a/gerbview/gerbview.h +++ b/gerbview/gerbview.h @@ -15,7 +15,7 @@ #define CURSEUR_ON_GRILLE 0 #define CURSEUR_OFF_GRILLE 1 -class WinEDA_GerberFrame; +class GERBVIEW_FRAME; //class BOARD; class GERBER_IMAGE; @@ -50,10 +50,6 @@ enum GERBER_VISIBLE */ #define GERBER_BUFZ 4000 -extern wxString g_PhotoFilenameExt; -extern wxString g_DrillFilenameExt; -extern wxString g_PenFilenameExt; - extern int g_DisplayPolygonsModeSketch; extern const wxString GerbviewProjectFileExt; @@ -61,11 +57,6 @@ extern const wxString GerbviewProjectFileWildcard; extern Ki_PageDescr* g_GerberPageSizeList[]; -// Config keywords -extern const wxString GerbviewDrawModeOption; -extern const wxString GerbviewShowPageSizeOption; -extern const wxString GerbviewShowDCodes; - // Interpolation type enum Gerb_Interpolation { diff --git a/gerbview/gerbview_config.cpp b/gerbview/gerbview_config.cpp index cb20696593..d593164354 100644 --- a/gerbview/gerbview_config.cpp +++ b/gerbview/gerbview_config.cpp @@ -16,7 +16,7 @@ #include "gerbview_config.h" #include "dialog_hotkeys_editor.h" -void WinEDA_GerberFrame::Process_Config( wxCommandEvent& event ) +void GERBVIEW_FRAME::Process_Config( wxCommandEvent& event ) { int id = event.GetId(); wxPoint pos; @@ -28,17 +28,7 @@ void WinEDA_GerberFrame::Process_Config( wxCommandEvent& event ) switch( id ) { - case ID_CONFIG_REQ: - { - InstallConfigFrame( pos ); - break; - } - - case ID_CONFIG_SAVE: - Update_config(); - break; - - /* Hotkey IDs */ + /* Hotkey IDs */ case ID_PREFERENCES_HOTKEY_EXPORT_CONFIG: ExportHotkeyConfigToFile( s_Gerbview_Hokeys_Descr ); break; @@ -52,50 +42,88 @@ void WinEDA_GerberFrame::Process_Config( wxCommandEvent& event ) break; case ID_PREFERENCES_HOTKEY_SHOW_CURRENT_LIST: + // Display current hotkey list for eeschema. DisplayHotkeyList( this, s_Gerbview_Hokeys_Descr ); break; default: DisplayError( this, - wxT( "WinEDA_GerberFrame::Process_Config internal error" ) ); + wxT( "GERBVIEW_FRAME::Process_Config internal error" ) ); } } -/* Read configuration, if it has not already read. - * 1 - bed gerbview.cnf - * 2 - if no bed is path> gerbview.exe> / gerbview.cnf - * 3 - If not found: init variables to default values +/* + * Return the Gerbview applications settings list. + * (list of parameters that must be saved in Gerbview parameters) + * + * This replaces the old statically define list that had the project + * file settings and the application settings mixed together. This + * was confusing and caused some settings to get saved and loaded + * incorrectly. Currently, only the settings that are needed at start + * up by the main window are defined here. There are other locally used + * settings scattered thoughout the EESchema source code. If you need + * to define a configuration setting that need to be loaded at run time, + * this is the place to define it. + * + * TODO: Define the configuration variables as member variables instead of + * global variables or move them to the object class where they are + * used. */ -bool Read_Config() + +PARAM_CFG_ARRAY& GERBVIEW_FRAME::GetConfigurationSettings( void ) { - wxGetApp().ReadProjectConfig( wxT( "gerbview.cnf" ), GROUP, ParamCfgList, - FALSE ); + if( !m_configSettings.empty() ) + return m_configSettings; - if( g_PhotoFilenameExt.IsEmpty() ) - g_PhotoFilenameExt = wxT( "pho" ); - if( g_DrillFilenameExt.IsEmpty() ) - g_DrillFilenameExt = wxT( "drl" ); - if( g_PenFilenameExt.IsEmpty() ) - g_PenFilenameExt = wxT( "pen" ); + m_configSettings.push_back( new PARAM_CFG_INT( true, wxT( "Units" ), + (int*) &g_UserUnit, 0, 0, 1 ) ); - return TRUE; + m_configSettings.push_back( new PARAM_CFG_INT( true, wxT( "DrawModeOption" ), + &m_displayMode, 2, 0, 2 ) ); + m_configSettings.push_back( new PARAM_CFG_SETCOLOR( true, + wxT( "DCodeColor" ), + &g_ColorsSettings.m_ItemsColors[ + DCODES_VISIBLE], + WHITE ) ); + + m_configSettings.push_back( new PARAM_CFG_BOOL( true, + wxT( "DisplayPolairCoordinates" ), + &DisplayOpt.DisplayPolarCood, + false ) ); + + // Color select parameters: + static const int color_default[32] = // Default values for color layers 0 to 31 + { + GREEN, BLUE, LIGHTGRAY, MAGENTA, + RED, DARKGREEN, BROWN, MAGENTA, + LIGHTGRAY, BLUE, GREEN, CYAN, + LIGHTRED, LIGHTMAGENTA, YELLOW, RED, + BLUE, BROWN, LIGHTCYAN, RED, + MAGENTA, CYAN, BROWN, MAGENTA, + LIGHTGRAY, BLUE, GREEN, DARKCYAN, + YELLOW, LIGHTMAGENTA, YELLOW, LIGHTGRAY + }; + + // List of keywords used as identifiers in config + // they *must* be static const and not temporary created, + // because the parameter list that used these keywords does not store them, + // just points on them + static const wxChar * keys[32] = + { + wxT("ColorLayer0"), wxT("ColorLayer1"), wxT("ColorLayer2"), wxT("ColorLayer3"), + wxT("ColorLayer4"), wxT("ColorLayer5"), wxT("ColorLayer6"), wxT("ColorLayer7"), + wxT("ColorLayer8"), wxT("ColorLayer9"), wxT("ColorLayer10"), wxT("ColorLayer11"), + wxT("ColorLayer12"), wxT("ColorLaye13"), wxT("ColorLayer14"), wxT("ColorLayer15") + }; + for( unsigned ii = 0; ii < 32; ii++ ) + { + int * prm = &g_ColorsSettings.m_LayersColors[1]; + PARAM_CFG_SETCOLOR * prm_entry = + new PARAM_CFG_SETCOLOR( true, keys[ii], prm, color_default[1] ); + m_configSettings.push_back( prm_entry ); + } + + return m_configSettings; } - - -void WinEDA_GerberFrame::Update_config() -{ - wxFileName fn = wxFileName( wxEmptyString, wxT( "gerbview" ), - GerbviewProjectFileExt ); - - wxFileDialog dlg( this, _( "Save GerbView Project File" ), wxEmptyString, - fn.GetFullName(), GerbviewProjectFileWildcard, - wxFD_SAVE | wxFD_OVERWRITE_PROMPT ); - - if( dlg.ShowModal() == wxID_CANCEL ) - return; - - wxGetApp().WriteProjectConfig( dlg.GetPath(), GROUP, ParamCfgList ); -} - diff --git a/gerbview/gerbview_config.h b/gerbview/gerbview_config.h index 9efbf8d990..fcd89b8258 100644 --- a/gerbview/gerbview_config.h +++ b/gerbview/gerbview_config.h @@ -8,352 +8,3 @@ #define GROUP wxT("/gerbview") #define INSETUP TRUE - -/* Useful macro : */ -#define LOC_COLOR(numlayer) &g_ColorsSettings.m_LayersColors[numlayer] - -/* Config parameters list */ - -static PARAM_CFG_WXSTRING PhotoExtBufCfg -( - INSETUP, - wxT("GerberFileExt"), - &g_PhotoFilenameExt -); - -static PARAM_CFG_WXSTRING PenExtBufCfg -( - INSETUP, - wxT("PenFileExt"), - &g_PenFilenameExt -); - -static PARAM_CFG_WXSTRING DrillExtBufCfg -( - INSETUP, - wxT("DrillFileExt"), - &g_DrillFilenameExt -); - -static PARAM_CFG_INT UnitsSelectionOptCfg // Units; 0 inches, 1 mm -( - INSETUP, - wxT("Units"), - (int*)&g_UserUnit, - MILLIMETRES -); - -static PARAM_CFG_SETCOLOR ColorLayer0Cfg -( - INSETUP, - wxT("ColLay0"), - LOC_COLOR(0), - GREEN -); - -static PARAM_CFG_SETCOLOR ColorLayer1Cfg -( - INSETUP, - wxT("ColLay1"), - LOC_COLOR(1), - BLUE -); - -static PARAM_CFG_SETCOLOR ColorLayer2Cfg -( - INSETUP, - wxT("ColLay2"), - LOC_COLOR(2), - LIGHTGRAY -); - -static PARAM_CFG_SETCOLOR ColorLayer3Cfg -( - INSETUP, - wxT("ColLay3"), - LOC_COLOR(3), - 5 -); - -static PARAM_CFG_SETCOLOR ColorLayer4Cfg -( - INSETUP, - wxT("ColLay4"), - LOC_COLOR(4), - 4 -); - -static PARAM_CFG_SETCOLOR ColorLayer5Cfg -( - INSETUP, - wxT("ColLay5"), - LOC_COLOR(5), - 5 -); - -static PARAM_CFG_SETCOLOR ColorLayer6Cfg -( - INSETUP, - wxT("ColLay6"), - LOC_COLOR(6), - 6 -); - -static PARAM_CFG_SETCOLOR ColorLayer7Cfg -( - INSETUP, - wxT("ColLay7"), - LOC_COLOR(7), - 5 -); - -static PARAM_CFG_SETCOLOR ColorLayer8Cfg -( - INSETUP, - wxT("ColLay8"), - LOC_COLOR(8), - 7 -); - -static PARAM_CFG_SETCOLOR ColorLayer9Cfg -( - INSETUP, - wxT("ColLay9"), - LOC_COLOR(9), - 1 -); - -static PARAM_CFG_SETCOLOR ColorLayer10Cfg -( - INSETUP, - wxT("ColLayA"), - LOC_COLOR(10), - 2 -); - -static PARAM_CFG_SETCOLOR ColorLayer11Cfg -( - INSETUP, - wxT("ColLayB"), - LOC_COLOR(11), - 3 -); - -static PARAM_CFG_SETCOLOR ColorLayer12Cfg -( - INSETUP, - wxT("ColLayC"), - LOC_COLOR(12), - 12 -); - -static PARAM_CFG_SETCOLOR ColorLayer13Cfg -( - INSETUP, - wxT("ColLayD"), - LOC_COLOR(13), - 13 -); - -static PARAM_CFG_SETCOLOR ColorLayer14Cfg -( - INSETUP, - wxT("ColLayE"), - LOC_COLOR(14), - 14 -); - -static PARAM_CFG_SETCOLOR ColorLayer15Cfg -( - INSETUP, - wxT("ColLayF"), - LOC_COLOR(15), - RED -); - -static PARAM_CFG_SETCOLOR ColorLayer16Cfg -( - INSETUP, - wxT("ColLayG"), - LOC_COLOR(16), - 1 -); - -static PARAM_CFG_SETCOLOR ColorLayer17Cfg -( - INSETUP, - wxT("ColLayH"), - LOC_COLOR(17), - 5 -); - -static PARAM_CFG_SETCOLOR ColorLayer18Cfg -( - INSETUP, - wxT("ColLayI"), - LOC_COLOR(18), - 11 -); - -static PARAM_CFG_SETCOLOR ColorLayer19Cfg -( - INSETUP, - wxT("ColLayJ"), - LOC_COLOR(19), - 4 -); - -static PARAM_CFG_SETCOLOR ColorLayer20Cfg -( - INSETUP, - wxT("ColLayK"), - LOC_COLOR(20), - 5 -); - -static PARAM_CFG_SETCOLOR ColorLayer21Cfg -( - INSETUP, - wxT("ColLayL"), - LOC_COLOR(21), - 3 -); - -static PARAM_CFG_SETCOLOR ColorLayer22Cfg -( - INSETUP, - wxT("ColLayM"), - LOC_COLOR(22), - 6 -); - -static PARAM_CFG_SETCOLOR ColorLayer23Cfg -( - INSETUP, - wxT("ColLayN"), - LOC_COLOR(23), - 5 -); - -static PARAM_CFG_SETCOLOR ColorLayer24Cfg -( - INSETUP, - wxT("ColLayO"), - LOC_COLOR(24), - LIGHTGRAY -); - -static PARAM_CFG_SETCOLOR ColorLayer25Cfg -( - INSETUP, - wxT("ColLayP"), - LOC_COLOR(25), - 1 -); - -static PARAM_CFG_SETCOLOR ColorLayer26Cfg -( - INSETUP, - wxT("ColLayQ"), - LOC_COLOR(26), - 2 -); - -static PARAM_CFG_SETCOLOR ColorLayer27Cfg -( - INSETUP, - wxT("ColLayR"), - LOC_COLOR(27), - 14 -); - -static PARAM_CFG_SETCOLOR ColorLayer28Cfg -( - INSETUP, - wxT("ColLayS"), - LOC_COLOR(28), - YELLOW -); - -static PARAM_CFG_SETCOLOR ColorLayer29Cfg -( - INSETUP, - wxT("ColLayT"), - LOC_COLOR(29), - 13 -); - -static PARAM_CFG_SETCOLOR ColorLayer30Cfg -( - INSETUP, - wxT("ColLayU"), - LOC_COLOR(30), - 14 -); - -static PARAM_CFG_SETCOLOR ColorLayer31Cfg -( - INSETUP, - wxT("ColLayV"), - LOC_COLOR(31), - 7 -); - -static PARAM_CFG_SETCOLOR DCodesDisplayOptCfg -( - INSETUP, - wxT("DCodeVisible"), - &g_ColorsSettings.m_ItemsColors[DCODES_VISIBLE], - WHITE -); - -static PARAM_CFG_BOOL DisplayPolairCoordinatesOptCfg -( - INSETUP, - wxT("DisplayPolairCoordinates"), - &DisplayOpt.DisplayPolarCood, - FALSE -); - -PARAM_CFG_BASE * ParamCfgList[] = -{ - & PhotoExtBufCfg, - & PenExtBufCfg, - & DrillExtBufCfg, - & UnitsSelectionOptCfg, - & ColorLayer0Cfg, - & ColorLayer1Cfg, - & ColorLayer2Cfg, - & ColorLayer3Cfg, - & ColorLayer4Cfg, - & ColorLayer5Cfg, - & ColorLayer6Cfg, - & ColorLayer7Cfg, - & ColorLayer8Cfg, - & ColorLayer9Cfg, - & ColorLayer10Cfg, - & ColorLayer11Cfg, - & ColorLayer12Cfg, - & ColorLayer13Cfg, - & ColorLayer14Cfg, - & ColorLayer15Cfg, - & ColorLayer16Cfg, - & ColorLayer17Cfg, - & ColorLayer18Cfg, - & ColorLayer19Cfg, - & ColorLayer20Cfg, - & ColorLayer21Cfg, - & ColorLayer22Cfg, - & ColorLayer23Cfg, - & ColorLayer24Cfg, - & ColorLayer25Cfg, - & ColorLayer26Cfg, - & ColorLayer27Cfg, - & ColorLayer28Cfg, - & ColorLayer29Cfg, - & ColorLayer30Cfg, - & ColorLayer31Cfg, - & DCodesDisplayOptCfg, - & DisplayPolairCoordinatesOptCfg, - NULL -}; diff --git a/gerbview/gerbview_id.h b/gerbview/gerbview_id.h index 8d1fb4e812..5d9befa09c 100644 --- a/gerbview/gerbview_id.h +++ b/gerbview/gerbview_id.h @@ -18,7 +18,6 @@ enum gerbview_ids ID_MENU_GERBVIEW_SHOW_HIDE_LAYERS_MANAGER_DIALOG, ID_TOOLBARH_GERBVIEW_SELECT_LAYER, - ID_GERBVIEW_DELETE_ITEM_BUTT, ID_GERBVIEW_GLOBAL_DELETE, ID_GERBVIEW_OPTIONS_SETUP, ID_TB_OPTIONS_SHOW_LAYERS_MANAGER_VERTICAL_TOOLBAR, diff --git a/gerbview/hotkeys.cpp b/gerbview/hotkeys.cpp index 8f71f9f205..8eae4a7bb0 100644 --- a/gerbview/hotkeys.cpp +++ b/gerbview/hotkeys.cpp @@ -69,7 +69,7 @@ struct Ki_HotkeyInfoSectionDescriptor s_Gerbview_Hokeys_Descr[] = /***********************************************************/ -void WinEDA_GerberFrame::OnHotKey( wxDC* DC, int hotkey, EDA_ITEM* DrawStruct ) +void GERBVIEW_FRAME::OnHotKey( wxDC* DC, int hotkey, EDA_ITEM* DrawStruct ) /***********************************************************/ /* Hot keys. Some commands are relatives to the item under the mouse cursor diff --git a/gerbview/initpcb.cpp b/gerbview/initpcb.cpp index 31f9059aca..1e8906900e 100644 --- a/gerbview/initpcb.cpp +++ b/gerbview/initpcb.cpp @@ -2,7 +2,6 @@ /******* initpcb.cpp ********************/ /****************************************/ - #include "fctsys.h" #include "common.h" #include "class_drawpanel.h" @@ -13,7 +12,7 @@ #include "class_GERBER.h" -bool WinEDA_GerberFrame::Clear_Pcb( bool query ) +bool GERBVIEW_FRAME::Clear_Pcb( bool query ) { int layer; @@ -52,7 +51,7 @@ bool WinEDA_GerberFrame::Clear_Pcb( bool query ) } -void WinEDA_GerberFrame::Erase_Current_Layer( bool query ) +void GERBVIEW_FRAME::Erase_Current_Layer( bool query ) { int layer = getActiveLayer(); wxString msg; diff --git a/gerbview/locate.cpp b/gerbview/locate.cpp index 878b8796ac..56628805cd 100644 --- a/gerbview/locate.cpp +++ b/gerbview/locate.cpp @@ -10,7 +10,7 @@ /* localize a gerber item and return a pointer to it. * Display info about this item */ -GERBER_DRAW_ITEM* WinEDA_GerberFrame::Locate( const wxPoint& aPosition, int aTypeloc ) +GERBER_DRAW_ITEM* GERBVIEW_FRAME::Locate( const wxPoint& aPosition, int aTypeloc ) { MsgPanel->EraseMsgBox(); wxPoint ref = aPosition; diff --git a/gerbview/menubar.cpp b/gerbview/menubar.cpp index 14230c74b8..76a99dea4b 100644 --- a/gerbview/menubar.cpp +++ b/gerbview/menubar.cpp @@ -13,7 +13,7 @@ #include "hotkeys.h" -void WinEDA_GerberFrame::ReCreateMenuBar( void ) +void GERBVIEW_FRAME::ReCreateMenuBar( void ) { wxMenuBar *menuBar = GetMenuBar(); @@ -63,8 +63,6 @@ void WinEDA_GerberFrame::ReCreateMenuBar( void ) // Configuration and preferences: wxMenu* configmenu = new wxMenu; - ADD_MENUITEM_WITH_HELP( configmenu, ID_CONFIG_REQ, _( "&File Ext" ), - _( "Set files extensions" ), config_xpm ); ADD_MENUITEM_WITH_HELP( configmenu, ID_MENU_GERBVIEW_SHOW_HIDE_LAYERS_MANAGER_DIALOG, _( "Hide &Layers Manager" ), _( "Show/hide the layers manager toolbar" ), @@ -80,11 +78,6 @@ void WinEDA_GerberFrame::ReCreateMenuBar( void ) AddHotkeyConfigMenu( configmenu ); - configmenu->AppendSeparator(); - ADD_MENUITEM_WITH_HELP( configmenu, ID_CONFIG_SAVE, _( "&Save Setup" ), - _( "Save application preferences" ), - save_setup_xpm ); - wxMenu* miscellaneous_menu = new wxMenu; ADD_MENUITEM_WITH_HELP( miscellaneous_menu, ID_GERBVIEW_SHOW_LIST_DCODES, _( "&List DCodes" ), diff --git a/gerbview/onrightclick.cpp b/gerbview/onrightclick.cpp index dfc0f7eaf2..960ccd9140 100644 --- a/gerbview/onrightclick.cpp +++ b/gerbview/onrightclick.cpp @@ -13,7 +13,7 @@ /* Prepare the right-click pullup menu. * The menu already has a list of zoom commands. */ -bool WinEDA_GerberFrame::OnRightClick( const wxPoint& aPosition, wxMenu* PopMenu ) +bool GERBVIEW_FRAME::OnRightClick( const wxPoint& aPosition, wxMenu* PopMenu ) { BOARD_ITEM* DrawStruct = GetScreen()->GetCurItem(); wxString msg; diff --git a/gerbview/options.cpp b/gerbview/options.cpp index 55b25260da..48797b3d1a 100644 --- a/gerbview/options.cpp +++ b/gerbview/options.cpp @@ -10,7 +10,6 @@ #include "fctsys.h" #include "common.h" #include "class_drawpanel.h" -#include "confirm.h" #include "gerbview.h" #include "gerbview_id.h" @@ -20,7 +19,7 @@ * Function OnSelectOptionToolbar * called to validate current choices */ -void WinEDA_GerberFrame::OnSelectOptionToolbar( wxCommandEvent& event ) +void GERBVIEW_FRAME::OnSelectOptionToolbar( wxCommandEvent& event ) { int id = event.GetId(); bool state; @@ -85,7 +84,7 @@ void WinEDA_GerberFrame::OnSelectOptionToolbar( wxCommandEvent& event ) break; default: - DisplayError( this, wxT( "WinEDA_PcbFrame::OnSelectOptionToolbar error" ) ); + wxMessageBox( wxT( "WinEDA_PcbFrame::OnSelectOptionToolbar error" ) ); break; } } diff --git a/gerbview/pcbplot.cpp b/gerbview/pcbplot.cpp index 93a08e1dac..bc63003c4e 100644 --- a/gerbview/pcbplot.cpp +++ b/gerbview/pcbplot.cpp @@ -9,7 +9,6 @@ #include "pcbplot.h" - /* The group of plot options - sadly global XXX */ PCB_Plot_Options g_pcb_plot_options; @@ -19,7 +18,7 @@ PCB_Plot_Options g_pcb_plot_options; /***************************************************************/ /** TODO */ -void WinEDA_GerberFrame::ToPlotter(wxCommandEvent& event) +void GERBVIEW_FRAME::ToPlotter(wxCommandEvent& event) { } diff --git a/gerbview/readgerb.cpp b/gerbview/readgerb.cpp index 526cb99f66..0e148bbb82 100644 --- a/gerbview/readgerb.cpp +++ b/gerbview/readgerb.cpp @@ -14,7 +14,7 @@ /* Read a gerber file, RS274D or RS274X format. */ -bool WinEDA_GerberFrame::Read_GERBER_File( const wxString& GERBER_FullFileName, +bool GERBVIEW_FRAME::Read_GERBER_File( const wxString& GERBER_FullFileName, const wxString& D_Code_FullFileName ) { int G_commande = 0; // command number for G commands like G04 @@ -149,6 +149,7 @@ bool WinEDA_GerberFrame::Read_GERBER_File( const wxString& GERBER_FullFileName, } } fclose( gerber->m_Current_File ); + SetLocaleTo_Default(); // Display errors list if( m_Messages.size() > 0 ) @@ -158,8 +159,6 @@ bool WinEDA_GerberFrame::Read_GERBER_File( const wxString& GERBER_FullFileName, dlg.ShowModal(); } - SetLocaleTo_Default(); - /* Init DCodes list and perhaps read a DCODES file, * if the gerber file is only a RS274D file * (i.e. without any aperture information) @@ -173,10 +172,8 @@ bool WinEDA_GerberFrame::Read_GERBER_File( const wxString& GERBER_FullFileName, wxString wildcard; fn = GERBER_FullFileName; - fn.SetExt( g_PenFilenameExt ); - wildcard.Printf( _( "Gerber DCODE files (%s)|*.%s" ), - GetChars( g_PenFilenameExt ), - GetChars( g_PenFilenameExt ) ); + fn.SetExt( wxEmptyString ); + wildcard = _( "Gerber DCODE files" ); wildcard += AllFilesWildcard; wxFileDialog dlg( this, _( "Load GERBER DCODE File" ), diff --git a/gerbview/select_layers_to_pcb.cpp b/gerbview/select_layers_to_pcb.cpp index f22f397941..ef234349f3 100644 --- a/gerbview/select_layers_to_pcb.cpp +++ b/gerbview/select_layers_to_pcb.cpp @@ -25,10 +25,10 @@ enum swap_layer_id { }; -class WinEDA_SwapLayerFrame : public wxDialog +class SWAP_LAYERS_DIALOG : public wxDialog { private: - WinEDA_GerberFrame* m_Parent; + GERBVIEW_FRAME* m_Parent; wxBoxSizer* OuterBoxSizer; wxBoxSizer* MainBoxSizer; wxFlexGridSizer* FlexColumnBoxSizer; @@ -40,8 +40,8 @@ private: public: - WinEDA_SwapLayerFrame( WinEDA_GerberFrame* parent ); - ~WinEDA_SwapLayerFrame() {}; + SWAP_LAYERS_DIALOG( GERBVIEW_FRAME* parent ); + ~SWAP_LAYERS_DIALOG() {}; private: void OnSelectLayer( wxCommandEvent& event ); @@ -52,12 +52,12 @@ private: }; -BEGIN_EVENT_TABLE( WinEDA_SwapLayerFrame, wxDialog ) +BEGIN_EVENT_TABLE( SWAP_LAYERS_DIALOG, wxDialog ) EVT_COMMAND_RANGE( ID_BUTTON_0, ID_BUTTON_0 + 31, wxEVT_COMMAND_BUTTON_CLICKED, - WinEDA_SwapLayerFrame::OnSelectLayer ) - EVT_BUTTON( wxID_OK, WinEDA_SwapLayerFrame::OnOkClick ) - EVT_BUTTON( wxID_CANCEL, WinEDA_SwapLayerFrame::OnCancelClick ) + SWAP_LAYERS_DIALOG::OnSelectLayer ) + EVT_BUTTON( wxID_OK, SWAP_LAYERS_DIALOG::OnOkClick ) + EVT_BUTTON( wxID_CANCEL, SWAP_LAYERS_DIALOG::OnCancelClick ) END_EVENT_TABLE() @@ -65,9 +65,9 @@ END_EVENT_TABLE() * between gerber layers and pcbnew layers * return the "lookup table" if ok, or NULL */ -int* WinEDA_GerberFrame::InstallDialogLayerPairChoice( ) +int* GERBVIEW_FRAME::InstallDialogLayerPairChoice( ) { - WinEDA_SwapLayerFrame* frame = new WinEDA_SwapLayerFrame( this ); + SWAP_LAYERS_DIALOG* frame = new SWAP_LAYERS_DIALOG( this ); int ii = frame->ShowModal(); @@ -79,7 +79,7 @@ int* WinEDA_GerberFrame::InstallDialogLayerPairChoice( ) } -WinEDA_SwapLayerFrame::WinEDA_SwapLayerFrame( WinEDA_GerberFrame* parent ) : +SWAP_LAYERS_DIALOG::SWAP_LAYERS_DIALOG( GERBVIEW_FRAME* parent ) : wxDialog( parent, -1, _( "Layer selection:" ), wxPoint( -1, -1 ), wxDefaultSize, wxDEFAULT_DIALOG_STYLE | MAYBE_RESIZE_BORDER ) { @@ -323,7 +323,7 @@ WinEDA_SwapLayerFrame::WinEDA_SwapLayerFrame( WinEDA_GerberFrame* parent ) : } -void WinEDA_SwapLayerFrame::OnSelectLayer( wxCommandEvent& event ) +void SWAP_LAYERS_DIALOG::OnSelectLayer( wxCommandEvent& event ) { int ii, jj; @@ -365,13 +365,13 @@ void WinEDA_SwapLayerFrame::OnSelectLayer( wxCommandEvent& event ) } -void WinEDA_SwapLayerFrame::OnCancelClick( wxCommandEvent& event ) +void SWAP_LAYERS_DIALOG::OnCancelClick( wxCommandEvent& event ) { EndModal( -1 ); } -void WinEDA_SwapLayerFrame::OnOkClick( wxCommandEvent& event ) +void SWAP_LAYERS_DIALOG::OnOkClick( wxCommandEvent& event ) { int ii; bool AsCmpLayer = false; diff --git a/gerbview/toolbars_gerber.cpp b/gerbview/toolbars_gerber.cpp index ed8f961641..d178c3f65e 100644 --- a/gerbview/toolbars_gerber.cpp +++ b/gerbview/toolbars_gerber.cpp @@ -16,7 +16,7 @@ #include "class_DCodeSelectionbox.h" #include "dialog_helpers.h" -void WinEDA_GerberFrame::ReCreateHToolbar( void ) +void GERBVIEW_FRAME::ReCreateHToolbar( void ) { int layer = 0; GERBER_IMAGE* gerber = NULL; @@ -106,8 +106,9 @@ void WinEDA_GerberFrame::ReCreateHToolbar( void ) /** * Create or update the right vertical toolbar + * Current no used */ -void WinEDA_GerberFrame::ReCreateVToolbar( void ) +void GERBVIEW_FRAME::ReCreateVToolbar( void ) { if( m_VToolBar ) return; @@ -117,8 +118,6 @@ void WinEDA_GerberFrame::ReCreateVToolbar( void ) // Set up toolbar m_VToolBar->AddTool( ID_NO_TOOL_SELECTED, wxEmptyString, wxBitmap( cursor_xpm ) ); m_VToolBar->AddSeparator(); - m_VToolBar->AddTool( ID_GERBVIEW_DELETE_ITEM_BUTT, wxEmptyString, wxBitmap( delete_body_xpm ), - _( "Delete items" ) ); m_VToolBar->Realize(); } @@ -127,7 +126,7 @@ void WinEDA_GerberFrame::ReCreateVToolbar( void ) /** * Create or update the left vertical toolbar (option toolbar */ -void WinEDA_GerberFrame::ReCreateOptToolbar( void ) +void GERBVIEW_FRAME::ReCreateOptToolbar( void ) { if( m_OptionsToolBar ) return; @@ -203,7 +202,7 @@ void WinEDA_GerberFrame::ReCreateOptToolbar( void ) } -void WinEDA_GerberFrame::OnUpdateDrawMode( wxUpdateUIEvent& aEvent ) +void GERBVIEW_FRAME::OnUpdateDrawMode( wxUpdateUIEvent& aEvent ) { switch( aEvent.GetId() ) { @@ -225,31 +224,31 @@ void WinEDA_GerberFrame::OnUpdateDrawMode( wxUpdateUIEvent& aEvent ) } -void WinEDA_GerberFrame::OnUpdateFlashedItemsDrawMode( wxUpdateUIEvent& aEvent ) +void GERBVIEW_FRAME::OnUpdateFlashedItemsDrawMode( wxUpdateUIEvent& aEvent ) { aEvent.Check( !m_DisplayPadFill ); } -void WinEDA_GerberFrame::OnUpdateLinesDrawMode( wxUpdateUIEvent& aEvent ) +void GERBVIEW_FRAME::OnUpdateLinesDrawMode( wxUpdateUIEvent& aEvent ) { aEvent.Check( !m_DisplayPcbTrackFill ); } -void WinEDA_GerberFrame::OnUpdatePolygonsDrawMode( wxUpdateUIEvent& aEvent ) +void GERBVIEW_FRAME::OnUpdatePolygonsDrawMode( wxUpdateUIEvent& aEvent ) { aEvent.Check( g_DisplayPolygonsModeSketch != 0 ); } -void WinEDA_GerberFrame::OnUpdateShowDCodes( wxUpdateUIEvent& aEvent ) +void GERBVIEW_FRAME::OnUpdateShowDCodes( wxUpdateUIEvent& aEvent ) { aEvent.Check( IsElementVisible( DCODES_VISIBLE ) ); } -void WinEDA_GerberFrame::OnUpdateShowLayerManager( wxUpdateUIEvent& aEvent ) +void GERBVIEW_FRAME::OnUpdateShowLayerManager( wxUpdateUIEvent& aEvent ) { aEvent.Check( m_show_layer_manager_tools ); @@ -263,7 +262,7 @@ void WinEDA_GerberFrame::OnUpdateShowLayerManager( wxUpdateUIEvent& aEvent ) } -void WinEDA_GerberFrame::OnUpdateSelectDCode( wxUpdateUIEvent& aEvent ) +void GERBVIEW_FRAME::OnUpdateSelectDCode( wxUpdateUIEvent& aEvent ) { int layer = GetScreen()->m_Active_Layer; GERBER_IMAGE* gerber = g_GERBER_List[layer]; @@ -276,7 +275,7 @@ void WinEDA_GerberFrame::OnUpdateSelectDCode( wxUpdateUIEvent& aEvent ) } -void WinEDA_GerberFrame::OnUpdateLayerSelectBox( wxUpdateUIEvent& aEvent ) +void GERBVIEW_FRAME::OnUpdateLayerSelectBox( wxUpdateUIEvent& aEvent ) { if( m_SelLayerBox && (m_SelLayerBox->GetSelection() != GetScreen()->m_Active_Layer) ) { diff --git a/gerbview/wxGerberFrame.h b/gerbview/wxGerberFrame.h index 6ce8c8d074..80eba0cbd5 100644 --- a/gerbview/wxGerberFrame.h +++ b/gerbview/wxGerberFrame.h @@ -7,6 +7,8 @@ #include "id.h" +#include "param_config.h" + #include "class_gerbview_layer_widget.h" #include "class_layerchoicebox.h" @@ -39,10 +41,10 @@ class DCODE_SELECTION_BOX; /****************************************************************** - * class WinEDA_GerberFrame: this is the main window used in gerbview + * class GERBVIEW_FRAME: this is the main window used in gerbview ******************************************************************/ -class WinEDA_GerberFrame : public PCB_BASE_FRAME +class GERBVIEW_FRAME : public PCB_BASE_FRAME { friend class PCB_LAYER_WIDGET; @@ -57,6 +59,7 @@ public: wxArrayString m_DCodesList; // an array string containing all decodes Id (10 to 999) private: + PARAM_CFG_ARRAY m_configSettings; // list of PARAM_CFG_xxx to read/write parameters saved in config int m_displayMode; // Gerber images ("layers" in Gerbview) can be drawn: // - in fast mode (write mode) but if there are negative // items only the last image is correctly drawn (no @@ -70,13 +73,12 @@ private: wxArrayString m_Messages; // An array sting to store warning messages when reaging // a gerber file -public: WinEDA_GerberFrame( wxWindow* father, const wxString& title, +public: GERBVIEW_FRAME( wxWindow* father, const wxString& title, const wxPoint& pos, const wxSize& size, long style = KICAD_DEFAULT_DRAWFRAME_STYLE ); - ~WinEDA_GerberFrame(); + ~GERBVIEW_FRAME(); - void Update_config(); void OnCloseWindow( wxCloseEvent& Event ); /** @@ -244,6 +246,18 @@ public: WinEDA_GerberFrame( wxWindow* father, const wxString& title, */ void UpdateTitleAndInfo(); + /** + * Function GetConfigurationSettings + * Populates the Gerbview applications settings list. + * (list of parameters that must be saved in Gerbview parameters) + * Currently, only the settings that are needed at start + * up by the main window are defined here. There are other locally used + * settings scattered thoughout the Gerbview source code (mainle in dialogs). + * If you need to define a configuration setting that need to be loaded at run time, + * this is the place to define it. + */ + PARAM_CFG_ARRAY& GetConfigurationSettings( void ); + /** * Load applications settings specific to the PCBNew. * @@ -298,9 +312,7 @@ public: WinEDA_GerberFrame( wxWindow* father, const wxString& title, void Process_Settings( wxCommandEvent& event ); void Process_Config( wxCommandEvent& event ); - void InstallConfigFrame( const wxPoint& pos ); void InstallGerberOptionsDialog( wxCommandEvent& event ); - void InstallPcbGlobalDeleteFrame( const wxPoint& pos ); void OnUpdateDrawMode( wxUpdateUIEvent& aEvent ); void OnUpdateFlashedItemsDrawMode( wxUpdateUIEvent& aEvent ); @@ -423,7 +435,6 @@ public: WinEDA_GerberFrame( wxWindow* father, const wxString& title, // PCB handling bool Clear_Pcb( bool query ); void Erase_Current_Layer( bool query ); - void Delete_DCode_Items( wxDC* DC, int dcode_value, int layer_number ); // Conversion function void ExportDataInPcbnewFormat( wxCommandEvent& event ); diff --git a/include/param_config.h b/include/param_config.h index 7a64c4058d..484f20ddf7 100644 --- a/include/param_config.h +++ b/include/param_config.h @@ -12,8 +12,7 @@ /** Type of parameter in the configuration file */ -enum paramcfg_id -{ +enum paramcfg_id { PARAM_INT, PARAM_SETCOLOR, PARAM_DOUBLE, @@ -25,8 +24,8 @@ enum paramcfg_id PARAM_FIELDNAME_LIST }; -#define MAX_COLOR 0x8001F -#define IS_VALID_COLOR( c ) ( ( c >= 0 ) && ( c <= 0x8001F ) ) +#define MAX_COLOR 0x8001F +#define IS_VALID_COLOR( c ) ( ( c >= 0 ) && ( c <= 0x8001F ) ) #define INT_MINVAL 0x80000000 #define INT_MAXVAL 0x7FFFFFFF @@ -46,8 +45,7 @@ public: const wxChar* m_Group; ///< Group name (this is like a path in the config data) bool m_Setup; ///< Install or Project based parameter, true == install -public: - PARAM_CFG_BASE( const wxChar* ident, const paramcfg_id type, const wxChar* group = NULL ); +public: PARAM_CFG_BASE( const wxChar* ident, const paramcfg_id type, const wxChar* group = NULL ); /** * Function ReadParam @@ -76,10 +74,9 @@ public: int m_Min, m_Max; ///< Minimum and maximum values of the param type int m_Default; ///< The default value of the parameter -public: - PARAM_CFG_INT( const wxChar* ident, int* ptparam, - int default_val = 0, int min = INT_MINVAL, int max = INT_MAXVAL, - const wxChar* group = NULL ); +public: PARAM_CFG_INT( const wxChar* ident, int* ptparam, + int default_val = 0, int min = INT_MINVAL, int max = INT_MAXVAL, + const wxChar* group = NULL ); PARAM_CFG_INT( bool Insetup, const wxChar* ident, int* ptparam, int default_val = 0, int min = INT_MINVAL, int max = INT_MAXVAL, const wxChar* group = NULL ); @@ -99,9 +96,8 @@ public: int* m_Pt_param; ///< Pointer to the parameter value int m_Default; ///< The default value of the parameter -public: - PARAM_CFG_SETCOLOR( const wxChar* ident, int* ptparam, - int default_val, const wxChar* group = NULL ); +public: PARAM_CFG_SETCOLOR( const wxChar* ident, int* ptparam, + int default_val, const wxChar* group = NULL ); PARAM_CFG_SETCOLOR( bool Insetup, const wxChar* ident, int* ptparam, int default_val, const wxChar* group = NULL ); @@ -117,14 +113,13 @@ public: class PARAM_CFG_DOUBLE : public PARAM_CFG_BASE { public: - double* m_Pt_param; ///< Pointer to the parameter value - double m_Default; ///< The default value of the parameter - double m_Min, m_Max; ///< Minimum and maximum values of the param type + double* m_Pt_param; ///< Pointer to the parameter value + double m_Default; ///< The default value of the parameter + double m_Min, m_Max; ///< Minimum and maximum values of the param type -public: - PARAM_CFG_DOUBLE( const wxChar* ident, double* ptparam, - double default_val = 0.0, double min = 0.0, double max = 10000.0, - const wxChar* group = NULL ); +public: PARAM_CFG_DOUBLE( const wxChar* ident, double* ptparam, + double default_val = 0.0, double min = 0.0, double max = 10000.0, + const wxChar* group = NULL ); PARAM_CFG_DOUBLE( bool Insetup, const wxChar* ident, double* ptparam, double default_val = 0.0, double min = 0.0, double max = 10000.0, const wxChar* group = NULL ); @@ -141,12 +136,11 @@ public: class PARAM_CFG_BOOL : public PARAM_CFG_BASE { public: - bool* m_Pt_param; ///< Pointer to the parameter value - int m_Default; ///< The default value of the parameter + bool* m_Pt_param; ///< Pointer to the parameter value + int m_Default; ///< The default value of the parameter -public: - PARAM_CFG_BOOL( const wxChar* ident, bool* ptparam, - int default_val = FALSE, const wxChar* group = NULL ); +public: PARAM_CFG_BOOL( const wxChar* ident, bool* ptparam, + int default_val = FALSE, const wxChar* group = NULL ); PARAM_CFG_BOOL( bool Insetup, const wxChar* ident, bool* ptparam, int default_val = FALSE, const wxChar* group = NULL ); @@ -162,14 +156,15 @@ public: class PARAM_CFG_WXSTRING : public PARAM_CFG_BASE { public: - wxString* m_Pt_param; ///< Pointer to the parameter value + wxString* m_Pt_param; ///< Pointer to the parameter value + wxString m_default; ///< The default value of the parameter -public: - PARAM_CFG_WXSTRING( const wxChar* ident, wxString* ptparam, const wxChar* group = NULL ); - PARAM_CFG_WXSTRING( bool Insetup, - const wxChar* ident, - wxString* ptparam, - const wxChar* group = NULL ); +public: PARAM_CFG_WXSTRING( const wxChar* ident, wxString* ptparam, const wxChar* group = NULL ); + PARAM_CFG_WXSTRING( bool Insetup, + const wxChar* ident, + wxString* ptparam, + const wxString& default_val = wxEmptyString, + const wxChar* group = NULL ); virtual void ReadParam( wxConfigBase* aConfig ); virtual void SaveParam( wxConfigBase* aConfig ); @@ -186,23 +181,20 @@ class PARAM_CFG_FILENAME : public PARAM_CFG_BASE public: wxString* m_Pt_param; ///< Pointer to the parameter value -public: - PARAM_CFG_FILENAME( const wxChar* ident, wxString* ptparam, const wxChar* group = NULL ); +public: PARAM_CFG_FILENAME( const wxChar* ident, wxString* ptparam, const wxChar* group = NULL ); virtual void ReadParam( wxConfigBase* aConfig ); virtual void SaveParam( wxConfigBase* aConfig ); }; - class PARAM_CFG_LIBNAME_LIST : public PARAM_CFG_BASE { public: wxArrayString* m_Pt_param; ///< Pointer to the parameter value -public: - PARAM_CFG_LIBNAME_LIST( const wxChar* ident, - wxArrayString* ptparam, - const wxChar* group = NULL ); +public: PARAM_CFG_LIBNAME_LIST( const wxChar* ident, + wxArrayString* ptparam, + const wxChar* group = NULL ); virtual void ReadParam( wxConfigBase* aConfig ); virtual void SaveParam( wxConfigBase* aConfig ); @@ -210,6 +202,6 @@ public: /** A list of parameters type */ -typedef boost::ptr_vector< PARAM_CFG_BASE > PARAM_CFG_ARRAY; +typedef boost::ptr_vector PARAM_CFG_ARRAY; #endif /* __PARAM_CONFIG_H__ */ diff --git a/pcbnew/export_vrml.cpp b/pcbnew/export_vrml.cpp index df16ee3d04..72cbead5d2 100644 --- a/pcbnew/export_vrml.cpp +++ b/pcbnew/export_vrml.cpp @@ -13,6 +13,11 @@ #include #include +/* helper function: + * some characters cannot be used in names, + * this function change them to "_" + */ +static void ChangeIllegalCharacters( wxString & aFileName, bool aDirSepIsIllegal ); /* the dialog to create VRML files, derived from DIALOG_EXPORT_3DFILE_BASE, @@ -641,8 +646,7 @@ static void vrml_text_callback( int x0, int y0, int xf, int yf ) } -static void export_vrml_pcbtext( TEXTE_PCB* text ) /*{{{*/ -/*************************************************************/ +static void export_vrml_pcbtext( TEXTE_PCB* text ) { /* Coupling by globals! Ewwww... */ s_text_layer = text->GetLayer(); @@ -1037,11 +1041,9 @@ static void export_vrml_module( BOARD* aPcb, MODULE* aModule, fname.Replace(wxT("\\"), wxT("/" ) ); wxString source_fname = fname; - if( aExport3DFiles ) // Change dangerous characters in filenames + if( aExport3DFiles ) // Change illegal characters in short filename { - fname.Replace(wxT("/"), wxT("_" ) ); - fname.Replace(wxT(":_"), wxT("_" ) ); - fname.Replace(wxT(" "), wxT("_" ) ); + ChangeIllegalCharacters( fname, true ); fname = a3D_Subdir + wxT("/") + fname; if( !wxFileExists( fname ) ) wxCopyFile( source_fname, fname ); @@ -1192,10 +1194,14 @@ bool PCB_EDIT_FRAME::ExportVRML_File( const wxString & aFullFileName, SetLocaleTo_C_standard(); /* Begin with the usual VRML boilerplate */ + wxString name = aFullFileName; + + name.Replace(wxT("\\"), wxT("/" ) ); + ChangeIllegalCharacters( name, false ); fprintf( output_file, "#VRML V2.0 utf8\n" "WorldInfo {\n" " title \"%s - Generated by PCBNEW\"\n" - "}\n", TO_UTF8( aFullFileName ) ); + "}\n", TO_UTF8( name ) ); /* The would be in decimils and not in meters, as the standard wants. * It is trivial to embed everything in a transform node to @@ -1272,3 +1278,15 @@ bool PCB_EDIT_FRAME::ExportVRML_File( const wxString & aFullFileName, return true; } + +/* + * some characters cannot be used in filenames, + * this function change them to "_" + */ +static void ChangeIllegalCharacters( wxString & aFileName, bool aDirSepIsIllegal ) +{ + if( aDirSepIsIllegal ) + aFileName.Replace(wxT("/"), wxT("_" ) ); + aFileName.Replace(wxT(" "), wxT("_" ) ); + aFileName.Replace(wxT(":"), wxT("_" ) ); +} diff --git a/pcbnew/onleftclick.cpp b/pcbnew/onleftclick.cpp index 6c28015360..f76fa2803a 100644 --- a/pcbnew/onleftclick.cpp +++ b/pcbnew/onleftclick.cpp @@ -124,6 +124,8 @@ void PCB_EDIT_FRAME::OnLeftClick( wxDC* aDC, const wxPoint& aPosition ) case TYPE_PAD: GetBoard()->SetCurrentNetClass( ((BOARD_CONNECTED_ITEM*)DrawStruct)->GetNetClassName() ); + updateTraceWidthSelectBox(); + updateViaSizeSelectBox(); break; default: diff --git a/pcbnew/onrightclick.cpp b/pcbnew/onrightclick.cpp index edba764a27..910d1d167a 100644 --- a/pcbnew/onrightclick.cpp +++ b/pcbnew/onrightclick.cpp @@ -393,6 +393,8 @@ void PCB_EDIT_FRAME::createPopupMenuForTracks( TRACK* Track, wxMenu* PopMenu ) wxString msg; GetBoard()->SetCurrentNetClass( Track->GetNetClassName() ); + updateTraceWidthSelectBox(); + updateViaSizeSelectBox(); int flags = Track->m_Flags; @@ -712,6 +714,8 @@ void PCB_EDIT_FRAME::createPopUpMenuForFpPads( D_PAD* Pad, wxMenu* menu ) return; GetBoard()->SetCurrentNetClass( Pad->GetNetClassName() ); + updateTraceWidthSelectBox(); + updateViaSizeSelectBox(); wxString msg = Pad->MenuText( GetBoard() );