diff --git a/3d-viewer/3d_canvas.cpp b/3d-viewer/3d_canvas.cpp index dc8299dca6..3b7a5b98e3 100644 --- a/3d-viewer/3d_canvas.cpp +++ b/3d-viewer/3d_canvas.cpp @@ -21,7 +21,6 @@ #include "wx/dataobj.h" #include "wx/clipbrd.h" -#include "fctsys.h" #include "id.h" #include "gestfich.h" @@ -620,6 +619,7 @@ void Pcb3D_GLCanvas::TakeScreenshot( wxCommandEvent& event ) * Output file format is png or jpeg, or image is copied on clipboard */ { + wxFileName fn( m_Parent->m_Parent->GetScreen()->m_FileName ); wxString FullFileName; wxString file_ext, mask; bool fmt_is_jpeg = FALSE; @@ -628,15 +628,15 @@ void Pcb3D_GLCanvas::TakeScreenshot( wxCommandEvent& event ) fmt_is_jpeg = TRUE; if( event.GetId() != ID_TOOL_SCREENCOPY_TOCLIBBOARD ) { - file_ext = fmt_is_jpeg ? wxT( ".jpg" ) : wxT( ".png"; ) - mask = wxT( "*" ) + file_ext; + file_ext = fmt_is_jpeg ? wxT( "jpg" ) : wxT( "png"; ) + mask = wxT( "*." ) + file_ext; FullFileName = m_Parent->m_Parent->GetScreen()->m_FileName; - ChangeFileNameExt( FullFileName, file_ext ); + fn.SetExt( file_ext ); FullFileName = EDA_FileSelector( _( "3D Image filename:" ), wxEmptyString, /* Chemin par defaut */ - FullFileName, /* nom fichier par defaut */ + fn.GetFullName(), /* nom fichier par defaut */ file_ext, /* extension par defaut */ mask, /* Masque d'affichage */ this, diff --git a/3d-viewer/3d_frame.cpp b/3d-viewer/3d_frame.cpp index 4152f96478..df5fa9a0b4 100644 --- a/3d-viewer/3d_frame.cpp +++ b/3d-viewer/3d_frame.cpp @@ -20,12 +20,24 @@ #include "bitmaps.h" #include "id.h" -#define VIEWER_MAIN #include "3d_viewer.h" #include "trackball.h" #include +Info_3D_Visu g_Parm_3D_Visu; +double g_Draw3d_dx; +double g_Draw3d_dy; +double ZBottom; +double ZTop; +double DataScale3D; // coeff de conversion unites utilsateut -> unites 3D + +int gl_attrib[] = +{ + WX_GL_RGBA, WX_GL_MIN_RED, 8, WX_GL_MIN_GREEN, 8, WX_GL_MIN_BLUE, 8, + WX_GL_DEPTH_SIZE, 16, WX_GL_DOUBLEBUFFER, GL_NONE +}; + BEGIN_EVENT_TABLE( WinEDA3D_DrawFrame, wxFrame ) EVT_TOOL_RANGE( ID_ZOOM_IN, ID_ZOOM_PAGE, WinEDA3D_DrawFrame::Process_Zoom ) @@ -358,9 +370,9 @@ void WinEDA3D_DrawFrame::Set3DBgColor() S3D_Color color; wxColour newcolor, oldcolor; - oldcolor.Set( (int) round( g_Parm_3D_Visu.m_BgColor.m_Red * 255 ), - (int) round( g_Parm_3D_Visu.m_BgColor.m_Green * 255 ), - (int) round( g_Parm_3D_Visu.m_BgColor.m_Blue * 255 ) ); + oldcolor.Set( wxRound( g_Parm_3D_Visu.m_BgColor.m_Red * 255 ), + wxRound( g_Parm_3D_Visu.m_BgColor.m_Green * 255 ), + wxRound( g_Parm_3D_Visu.m_BgColor.m_Blue * 255 ) ); newcolor = wxGetColourFromUser( this, oldcolor ); if( newcolor != oldcolor ) diff --git a/3d-viewer/3d_read_mesh.cpp b/3d-viewer/3d_read_mesh.cpp index 7cbccbd3fe..541ebb7ba3 100644 --- a/3d-viewer/3d_read_mesh.cpp +++ b/3d-viewer/3d_read_mesh.cpp @@ -13,6 +13,7 @@ #include "common.h" #include "macros.h" #include "kicad_string.h" +#include "appl_wxstruct.h" #include "3d_struct.h" #include "3d_viewer.h" @@ -22,30 +23,35 @@ int S3D_MASTER:: ReadData() /************************************/ { - char line[1024], * text; - wxString fullfilename; - FILE* file; - int LineNum = 0; + char line[1024], * text; + wxFileName fn; + wxString tmp; + FILE* file; + int LineNum = 0; if( m_Shape3DName.IsEmpty() ) { return 1; } - if( wxIsAbsolutePath( m_Shape3DName ) ) - fullfilename.Empty(); - else - fullfilename = g_RealLibDirBuffer + LIB3D_PATH; - fullfilename += m_Shape3DName; -#if defined (__WINDOWS__) - fullfilename.Replace( UNIX_STRING_DIR_SEP, WIN_STRING_DIR_SEP ); -#else -#if defined (__UNIX__) - fullfilename.Replace( WIN_STRING_DIR_SEP, UNIX_STRING_DIR_SEP ); -#endif -#endif + fn = m_Shape3DName; + + if( !fn.FileExists() ) + { + tmp = wxGetApp().GetLibraryPathList().FindValidPath( fn.GetFullPath() ); + + if( !tmp ) + { + wxLogDebug( _( "3D part library <%s> could not be found." ), + fn.GetFullPath().c_str() ); + return -1; + } + + fn = tmp; + } + + file = wxFopen( fn.GetFullPath(), wxT( "rt" ) ); - file = wxFopen( fullfilename, wxT( "rt" ) ); if( file == NULL ) { return -1; diff --git a/3d-viewer/3d_toolbar.cpp b/3d-viewer/3d_toolbar.cpp index e3babb6edd..1d7333705b 100644 --- a/3d-viewer/3d_toolbar.cpp +++ b/3d-viewer/3d_toolbar.cpp @@ -9,7 +9,6 @@ #include "id.h" -#define BITMAP wxBitmap #include "3d_viewer.h" @@ -29,62 +28,70 @@ void WinEDA3D_DrawFrame::ReCreateHToolbar() SetToolBar( m_HToolBar ); // Set up toolbar - m_HToolBar->AddTool( ID_RELOAD3D_BOARD, wxEmptyString, BITMAP( import3d_xpm ), - _( "Reload board" ) ); + m_HToolBar->AddTool( ID_RELOAD3D_BOARD, wxEmptyString, + wxBitmap( import3d_xpm ), + _( "Reload board" ) ); #ifdef __WINDOWS__ // do not work properly under linux m_HToolBar-> AddSeparator(); - m_HToolBar->AddTool( ID_TOOL_SCREENCOPY_TOCLIBBOARD, wxEmptyString, BITMAP( copy_button ), + m_HToolBar->AddTool( ID_TOOL_SCREENCOPY_TOCLIBBOARD, wxEmptyString, + wxBitmap( copy_button ), _( "Copy 3D Image to Clipboard" ) ); #endif m_HToolBar->AddSeparator(); - m_HToolBar->AddTool( ID_ZOOM_IN, wxEmptyString, BITMAP( zoom_in_xpm ), - _( "Zoom in" ) ); + m_HToolBar->AddTool( ID_ZOOM_IN, wxEmptyString, wxBitmap( zoom_in_xpm ), + _( "Zoom in" ) ); - m_HToolBar->AddTool( ID_ZOOM_OUT, wxEmptyString, BITMAP( zoom_out_xpm ), - _( "Zoom out" ) ); + m_HToolBar->AddTool( ID_ZOOM_OUT, wxEmptyString, wxBitmap( zoom_out_xpm ), + _( "Zoom out" ) ); - m_HToolBar->AddTool( ID_ZOOM_REDRAW, wxEmptyString, BITMAP( zoom_redraw_xpm ), - _( "Redraw view" ) ); + m_HToolBar->AddTool( ID_ZOOM_REDRAW, wxEmptyString, + wxBitmap( zoom_redraw_xpm ), + _( "Redraw view" ) ); - m_HToolBar->AddTool( ID_ZOOM_PAGE, wxEmptyString, BITMAP( zoom_auto_xpm ), - _( "Zoom auto" ) ); + m_HToolBar->AddTool( ID_ZOOM_PAGE, wxEmptyString, wxBitmap( zoom_auto_xpm ), + _( "Zoom auto" ) ); m_HToolBar->AddSeparator(); - m_HToolBar->AddTool( ID_ROTATE3D_X_NEG, wxEmptyString, BITMAP( rotate_neg_X_xpm ), - _( "Rotate X <-" ) ); + m_HToolBar->AddTool( ID_ROTATE3D_X_NEG, wxEmptyString, + wxBitmap( rotate_neg_X_xpm ), + _( "Rotate X <-" ) ); - m_HToolBar->AddTool( ID_ROTATE3D_X_POS, wxEmptyString, BITMAP( rotate_pos_X_xpm ), - _( "Rotate X ->" ) ); + m_HToolBar->AddTool( ID_ROTATE3D_X_POS, wxEmptyString, + wxBitmap( rotate_pos_X_xpm ), + _( "Rotate X ->" ) ); m_HToolBar->AddSeparator(); - m_HToolBar->AddTool( ID_ROTATE3D_Y_NEG, wxEmptyString, BITMAP( rotate_neg_Y_xpm ), - _( "Rotate Y <-" ) ); + m_HToolBar->AddTool( ID_ROTATE3D_Y_NEG, wxEmptyString, + wxBitmap( rotate_neg_Y_xpm ), + _( "Rotate Y <-" ) ); - m_HToolBar->AddTool( ID_ROTATE3D_Y_POS, wxEmptyString, BITMAP( rotate_pos_Y_xpm ), - _( "Rotate Y ->" ) ); + m_HToolBar->AddTool( ID_ROTATE3D_Y_POS, wxEmptyString, + wxBitmap( rotate_pos_Y_xpm ), + _( "Rotate Y ->" ) ); m_HToolBar->AddSeparator(); - m_HToolBar->AddTool( ID_ROTATE3D_Z_NEG, wxEmptyString, BITMAP( rotate_neg_Z_xpm ), - _( "Rotate Z <-" ) ); + m_HToolBar->AddTool( ID_ROTATE3D_Z_NEG, wxEmptyString, + wxBitmap( rotate_neg_Z_xpm ), + _( "Rotate Z <-" ) ); - m_HToolBar->AddTool( ID_ROTATE3D_Z_POS, wxEmptyString, BITMAP( rotate_pos_Z_xpm ), - _( "Rotate Z ->" ) ); + m_HToolBar->AddTool( ID_ROTATE3D_Z_POS, wxEmptyString, + wxBitmap( rotate_pos_Z_xpm ), + _( "Rotate Z ->" ) ); m_HToolBar->AddSeparator(); - m_HToolBar->AddTool( ID_MOVE3D_LEFT, wxEmptyString, BITMAP( left_xpm ), - _( "Move left <-" ) ); + m_HToolBar->AddTool( ID_MOVE3D_LEFT, wxEmptyString, wxBitmap( left_xpm ), + _( "Move left <-" ) ); - m_HToolBar->AddTool( ID_MOVE3D_RIGHT, wxEmptyString, BITMAP( right_xpm ), - _( "Move right ->" ) ); + m_HToolBar->AddTool( ID_MOVE3D_RIGHT, wxEmptyString, wxBitmap( right_xpm ), + _( "Move right ->" ) ); - m_HToolBar->AddTool( ID_MOVE3D_UP, wxEmptyString, BITMAP( up_xpm ), - _( "Move Up ^" ) ); - - m_HToolBar->AddTool( ID_MOVE3D_DOWN, wxEmptyString, BITMAP( down_xpm ), - _( "Move Down" ) ); + m_HToolBar->AddTool( ID_MOVE3D_UP, wxEmptyString, wxBitmap( up_xpm ), + _( "Move Up ^" ) ); + m_HToolBar->AddTool( ID_MOVE3D_DOWN, wxEmptyString, wxBitmap( down_xpm ), + _( "Move Down" ) ); m_HToolBar->Realize(); diff --git a/3d-viewer/3d_viewer.h b/3d-viewer/3d_viewer.h index 898bf909dc..d530b06283 100644 --- a/3d-viewer/3d_viewer.h +++ b/3d-viewer/3d_viewer.h @@ -20,12 +20,6 @@ # include #endif -#ifdef VIEWER_MAIN -#define global_3d -#else -#define global_3d extern -#endif - #include "pcbstruct.h" #include "3d_struct.h" @@ -49,73 +43,73 @@ class SEGVIA; class Info_3D_Visu { public: - double m_Beginx, m_Beginy; /* position of mouse */ - double m_Quat[4]; /* orientation of object */ - double m_Rot[4]; /* man rotation of object */ - double m_Zoom; /* field of view in degrees */ - S3D_Color m_BgColor; - bool m_Draw3DAxis; - bool m_Draw3DModule; - bool m_Draw3DZone; - bool m_Draw3DComments; - bool m_Draw3DDrawings; - bool m_Draw3DEco1; - bool m_Draw3DEco2; - wxPoint m_BoardPos; - wxSize m_BoardSize; - int m_Layers; - EDA_BoardDesignSettings * m_BoardSettings; // Link to current board design settings - double m_Epoxy_Width; /* Epoxy tickness (normalized) */ + double m_Beginx, m_Beginy; /* position of mouse */ + double m_Quat[4]; /* orientation of object */ + double m_Rot[4]; /* man rotation of object */ + double m_Zoom; /* field of view in degrees */ + S3D_Color m_BgColor; + bool m_Draw3DAxis; + bool m_Draw3DModule; + bool m_Draw3DZone; + bool m_Draw3DComments; + bool m_Draw3DDrawings; + bool m_Draw3DEco1; + bool m_Draw3DEco2; + wxPoint m_BoardPos; + wxSize m_BoardSize; + int m_Layers; + EDA_BoardDesignSettings * m_BoardSettings; // Link to current board design settings + double m_Epoxy_Width; /* Epoxy tickness (normalized) */ - double m_BoardScale; /* Normalisation scale for coordinates: - when scaled tey are between -1.0 and +1.0 */ - double m_LayerZcoord[32]; + double m_BoardScale; /* Normalisation scale for coordinates: + when scaled tey are between -1.0 and +1.0 */ + double m_LayerZcoord[32]; public: - Info_3D_Visu(); - ~Info_3D_Visu(); + Info_3D_Visu(); + ~Info_3D_Visu(); }; class Pcb3D_GLCanvas: public wxGLCanvas { public: - WinEDA3D_DrawFrame * m_Parent; + WinEDA3D_DrawFrame * m_Parent; private: - bool m_init; - GLuint m_gllist; + bool m_init; + GLuint m_gllist; public: - Pcb3D_GLCanvas(WinEDA3D_DrawFrame *parent, const wxWindowID id = -1, - int* gl_attrib = NULL); - ~Pcb3D_GLCanvas(); + Pcb3D_GLCanvas( WinEDA3D_DrawFrame *parent, const wxWindowID id = -1, + int* gl_attrib = NULL); + ~Pcb3D_GLCanvas(); - void ClearLists(); + void ClearLists(); - void OnPaint(wxPaintEvent& event); - void OnSize(wxSizeEvent& event); - void OnEraseBackground(wxEraseEvent& event); - void OnChar(wxKeyEvent& event); - void OnMouseEvent(wxMouseEvent& event); - void OnRightClick(wxMouseEvent& event); - void OnPopUpMenu(wxCommandEvent & event); - void TakeScreenshot(wxCommandEvent & event); - void SetView3D(int keycode); - void DisplayStatus(); - void Redraw(bool finish = false); - GLuint DisplayCubeforTest(); + void OnPaint(wxPaintEvent& event); + void OnSize(wxSizeEvent& event); + void OnEraseBackground(wxEraseEvent& event); + void OnChar(wxKeyEvent& event); + void OnMouseEvent(wxMouseEvent& event); + void OnRightClick(wxMouseEvent& event); + void OnPopUpMenu(wxCommandEvent & event); + void TakeScreenshot(wxCommandEvent & event); + void SetView3D(int keycode); + void DisplayStatus(); + void Redraw(bool finish = false); + GLuint DisplayCubeforTest(); - void OnEnterWindow( wxMouseEvent& event ); + void OnEnterWindow( wxMouseEvent& event ); - void Render(); - GLuint CreateDrawGL_List(); - void InitGL(); - void SetLights(); - void Draw3D_Track(TRACK * track); - void Draw3D_Via(SEGVIA * via); - void Draw3D_DrawSegment(DRAWSEGMENT * segment); - void Draw3D_DrawText(TEXTE_PCB * text); - //int Get3DLayerEnable(int act_layer); + void Render(); + GLuint CreateDrawGL_List(); + void InitGL(); + void SetLights(); + void Draw3D_Track(TRACK * track); + void Draw3D_Via(SEGVIA * via); + void Draw3D_DrawSegment(DRAWSEGMENT * segment); + void Draw3D_DrawText(TEXTE_PCB * text); + //int Get3DLayerEnable(int act_layer); DECLARE_EVENT_TABLE() }; @@ -124,50 +118,50 @@ DECLARE_EVENT_TABLE() class WinEDA3D_DrawFrame: public wxFrame { public: - WinEDA_BasePcbFrame * m_Parent; + WinEDA_BasePcbFrame * m_Parent; Pcb3D_GLCanvas * m_Canvas; - wxToolBar * m_HToolBar; - wxToolBar * m_VToolBar; - int m_InternalUnits; - wxPoint m_FramePos; - wxSize m_FrameSize; + wxToolBar * m_HToolBar; + wxToolBar * m_VToolBar; + int m_InternalUnits; + wxPoint m_FramePos; + wxSize m_FrameSize; private: - wxString m_FrameName; // name used for writting and reading setup - // It is "Frame3D" + wxString m_FrameName; // name used for writting and reading setup + // It is "Frame3D" public: - WinEDA3D_DrawFrame(WinEDA_BasePcbFrame * parent, - const wxString& title, - long style = KICAD_DEFAULT_3D_DRAWFRAME_STYLE ); + WinEDA3D_DrawFrame( WinEDA_BasePcbFrame * parent, + const wxString& title, + long style = KICAD_DEFAULT_3D_DRAWFRAME_STYLE ); void Exit3DFrame(wxCommandEvent& event); - void OnCloseWindow(wxCloseEvent & Event); - void ReCreateMenuBar(); - void ReCreateHToolbar(); - void ReCreateVToolbar(); - void SetToolbars(); - void GetSettings(); - void SaveSettings(); + void OnCloseWindow(wxCloseEvent & Event); + void ReCreateMenuBar(); + void ReCreateHToolbar(); + void ReCreateVToolbar(); + void SetToolbars(); + void GetSettings(); + void SaveSettings(); - void OnLeftClick(wxDC * DC, const wxPoint& MousePos); - void OnRightClick(const wxPoint& MousePos, wxMenu * PopMenu); - void OnKeyEvent(wxKeyEvent& event); - int BestZoom(); // Retourne le meilleur zoom - void RedrawActiveWindow(wxDC * DC, bool EraseBg); - void Process_Special_Functions(wxCommandEvent& event); - void Process_Zoom(wxCommandEvent& event); + void OnLeftClick(wxDC * DC, const wxPoint& MousePos); + void OnRightClick(const wxPoint& MousePos, wxMenu * PopMenu); + void OnKeyEvent(wxKeyEvent& event); + int BestZoom(); // Retourne le meilleur zoom + void RedrawActiveWindow(wxDC * DC, bool EraseBg); + void Process_Special_Functions(wxCommandEvent& event); + void Process_Zoom(wxCommandEvent& event); - void NewDisplay(); - void Set3DBgColor(); - void Set3DAxisOnOff(); - void Set3DModuleOnOff(); - void Set3DPlaceOnOff(); - void Set3DZoneOnOff(); - void Set3DCommentsOnOff(); - void Set3DDrawingsOnOff(); - void Set3DEco1OnOff(); - void Set3DEco2OnOff(); + void NewDisplay(); + void Set3DBgColor(); + void Set3DAxisOnOff(); + void Set3DModuleOnOff(); + void Set3DPlaceOnOff(); + void Set3DZoneOnOff(); + void Set3DCommentsOnOff(); + void Set3DDrawingsOnOff(); + void Set3DEco1OnOff(); + void Set3DEco2OnOff(); DECLARE_EVENT_TABLE() }; @@ -175,17 +169,8 @@ public: void SetGLColor(int color); void Set_Object_Data(const S3D_Vertex * coord, int nbcoord ); -global_3d Info_3D_Visu g_Parm_3D_Visu; -global_3d double g_Draw3d_dx, g_Draw3d_dy; -global_3d double ZBottom, ZTop; -global_3d double DataScale3D; // coeff de conversion unites utilsateut -> unites 3D -global_3d int gl_attrib[] -#ifdef VIEWER_MAIN -= { WX_GL_RGBA, WX_GL_MIN_RED, 8, WX_GL_MIN_GREEN, 8, - WX_GL_MIN_BLUE, 8, WX_GL_DEPTH_SIZE, 16, - WX_GL_DOUBLEBUFFER, - GL_NONE } -#endif -; - - +extern Info_3D_Visu g_Parm_3D_Visu; +extern double g_Draw3d_dx, g_Draw3d_dy; +extern double ZBottom, ZTop; +extern double DataScale3D; // coeff de conversion unites utilsateut -> unites 3D +extern int gl_attrib[]; diff --git a/CHANGELOG.txt b/CHANGELOG.txt index 1964f397e7..23dc54077b 100644 --- a/CHANGELOG.txt +++ b/CHANGELOG.txt @@ -4,11 +4,56 @@ KiCad ChangeLog 2009 Please add newer entries at the top, list the date and your name with email address. +2009-xxx-xx UPDATE Wayne Stambaugh +================================================================================ +++All + * Removed all instances #ifdef eda_global, COMMON_GLOBL, and MAIN in order + to unobfuscate global variables. + * Moved global variables common to all applications into common.cpp. + * Moved global variables common to Pcbnew, Gerbview, and Cvpcb into + pcbcommon.cpp. + * Create pcbcommon library to prevent compiling shared PCB drawing object + files multiple times. + * Replaced round() with wxRound and eliminate MSVC specific implementation. + * Moved project configuration files into the application class. + * Moved editor name global variable into the application class. + * Created load and save settings methods for basic frame class and begin + putting global variables in the class where they are used. + * Start replacing obsolete wxWidgets file functions and redundant Kicad + file name manipulation code with wxFileName. + * Initial library search path implementation using wxPathList. + * Define correct wxFileDialog wild cards. + * Apply patch Fix typo in about box to keep MAC folks happy. + * Lots of general code clean up, spelling error fixes, and uncrustification. + * Renamed Affiche_Status_Box to UpdateStatusBar. +++EESchema + * Defined Load() method so library file drawing objects can load themselves. + * Defined GetBoundingBox() method so library file drawing objects can + calculate their own bounding box. + * Fix arc library drawing object bounding box calculation. + * Remember last import and export library path in library editor. + * Add new library search path support. +++Kicad + * Eliminate the one giant case statement to rule them all command event + handler and create per command event handlers. +++CvPcb + * Add new library search path support. + * Add message dialogs to prompt user of library file load errors instead of + failing silently. + * Fix NULL pointer bug were display frame would crash CvPcb when + WinEDA_DisplayFrame::Get_Module() could not find foot print module. +++PcbNew + * Add new library search path support. + * Add message dialogs to prompt user of library file load errors instead of + failing silently. + + 2009-mar-30 UPDATE Jean-Pierre Charras ================================================================================ ++pcbnew: added BOM generator (in postprocess menu) + 2009-mar-28 UPDATE Jean-Pierre Charras ================================================================================ ++All @@ -24,7 +69,6 @@ email address. ================================================================================ ++pcbnew: in DRC: added test pads to holes. - ++Al: minor changes. @@ -66,7 +110,6 @@ email address. print,plot: error message displayed when no layer selected. - 2009-Mar-5 UPDATE Vesa Solonen ================================================================================ ++pcbnew: diff --git a/common/CMakeLists.txt b/common/CMakeLists.txt index 939668cd8d..66ff01fd27 100644 --- a/common/CMakeLists.txt +++ b/common/CMakeLists.txt @@ -1,5 +1,6 @@ include_directories(${CMAKE_CURRENT_SOURCE_DIR} ${Boost_INCLUDE_DIR} + ../3d-viewer ../pcbnew ../polygon ) @@ -41,23 +42,36 @@ set(COMMON_SRCS worksheet.cpp wxwineda.cpp zoom.cpp +) +add_library(common ${COMMON_SRCS}) + +set(PCB_COMMON_SRCS + pcbcommon.cpp ../pcbnew/basepcbframe.cpp ../pcbnew/class_board.cpp ../pcbnew/class_board_connected_item.cpp + ../pcbnew/class_board_item.cpp ../pcbnew/class_cotation.cpp + ../pcbnew/class_drawsegment.cpp ../pcbnew/class_drc_item.cpp + ../pcbnew/class_edge_mod.cpp + ../pcbnew/class_equipot.cpp ../pcbnew/class_marker.cpp ../pcbnew/class_mire.cpp + ../pcbnew/class_module.cpp ../pcbnew/class_pad.cpp ../pcbnew/class_pad_draw_functions.cpp ../pcbnew/class_pcb_text.cpp + ../pcbnew/class_text_mod.cpp + ../pcbnew/class_track.cpp ../pcbnew/class_zone.cpp ../pcbnew/class_zone_setting.cpp ../pcbnew/classpcb.cpp ../pcbnew/collectors.cpp ../pcbnew/sel_layer.cpp + ../pcbnew/tracemod.cpp ../pcbnew/dialog_print_using_printer_base.cpp ) -add_library(common ${COMMON_SRCS}) +add_library(pcbcommon ${PCB_COMMON_SRCS}) diff --git a/common/about_kicad.cpp b/common/about_kicad.cpp index 49647890ce..a8d4d5f284 100644 --- a/common/about_kicad.cpp +++ b/common/about_kicad.cpp @@ -5,8 +5,30 @@ #include "fctsys.h" #include "common.h" +#include "appl_wxstruct.h" + + +#define BUILD_VERSION wxT("(20090325-unstable)") + +wxString g_BuildVersion + +#ifdef HAVE_SVN_VERSION +#include "config.h" +( wxT( KICAD_SVN_VERSION ) ) +#else +( BUILD_VERSION ) +#endif +; + +wxString g_BuildAboutVersion +#if defined(HAVE_SVN_VERSION) || defined(HAVE_SVN_REVISION) +# include "config.h" +( wxT( KICAD_ABOUT_VERSION ) ) +#else +( BUILD_VERSION ) +#endif +; -extern wxString g_Main_Title; // Import program title /**********************************/ wxString SetMsg( const wxString& msg ) @@ -33,7 +55,7 @@ void InitKiCadAbout( wxAboutDialogInfo& info ) /**************************************************/ { /* Set name and title */ - info.SetName( g_Main_Title ); + info.SetName( wxGetApp().GetTitle() ); /* Set description */ wxString description; @@ -65,7 +87,7 @@ void InitKiCadAbout( wxAboutDialogInfo& info ) /* Check for wxMAC */ # elif defined __WXMAC__ - description << ( wxT( "on Macintosch" ) ); + description << ( wxT( "on Macintosh" ) ); /* Linux 64 bits */ # elif defined _LP64 && __LINUX__ diff --git a/common/base_screen.cpp b/common/base_screen.cpp index 251a09c2cd..de2e872785 100644 --- a/common/base_screen.cpp +++ b/common/base_screen.cpp @@ -17,6 +17,7 @@ #include WX_DEFINE_OBJARRAY( GridArray ); +BASE_SCREEN* ActiveScreen = NULL; /* defines locaux */ #define CURSOR_SIZE 12 /* taille de la croix du curseur PCB */ @@ -39,6 +40,7 @@ BASE_SCREEN::BASE_SCREEN( KICAD_T aType ) : EDA_BaseStruct( aType ) m_UserGridIsON = FALSE; m_Center = true; m_CurrentSheetDesc = &g_Sheet_A4; + m_IsPrinting = false; InitDatas(); } @@ -165,6 +167,20 @@ int BASE_SCREEN::Scale( int coord ) #endif } +double BASE_SCREEN::Scale( double coord ) +{ +#ifdef WX_ZOOM + return coord; +#else + if( !m_Zoom ) + return 0; + + if( !m_ZoomScalar || !m_Zoom ) + return 0; + + return ( coord * (double) m_ZoomScalar ) / (double) m_Zoom; +#endif +} void BASE_SCREEN::Scale( wxPoint& pt ) { diff --git a/common/basicframe.cpp b/common/basicframe.cpp index 1c30938e2b..43bea77a1f 100644 --- a/common/basicframe.cpp +++ b/common/basicframe.cpp @@ -77,18 +77,21 @@ WinEDA_BasicFrame::~WinEDA_BasicFrame() * Virtual function */ /***********************************/ -void -WinEDA_BasicFrame::ReCreateMenuBar() +void WinEDA_BasicFrame::ReCreateMenuBar() /***********************************/ { } -/*******************************/ -void -WinEDA_BasicFrame::GetSettings() -/*******************************/ +/** + * Load common frame parameters from configuration. + * + * The method is virtual so you can override it to load frame specific + * parameters. Don't forget to call the base method or your frames won't + * remember their positions and sizes. + */ +void WinEDA_BasicFrame::LoadSettings() { wxString text; int Ypos_min; @@ -121,10 +124,14 @@ WinEDA_BasicFrame::GetSettings() } -/********************************/ -void -WinEDA_BasicFrame::SaveSettings() -/********************************/ +/** + * Save common frame parameters from configuration. + * + * The method is virtual so you can override it to save frame specific + * parameters. Don't forget to call the base method or your frames won't + * remember their positions and sizes. + */ +void WinEDA_BasicFrame::SaveSettings() { wxString text; wxConfig* config; @@ -149,8 +156,7 @@ WinEDA_BasicFrame::SaveSettings() /******************************************************/ -void -WinEDA_BasicFrame::PrintMsg( const wxString& text ) +void WinEDA_BasicFrame::PrintMsg( const wxString& text ) /******************************************************/ { SetStatusText( text ); @@ -161,9 +167,7 @@ WinEDA_BasicFrame::PrintMsg( const wxString& text ) * Display a bargraph (0 to 50 point length) for a PerCent value from 0 to 100 */ /*************************************************************************/ -void -WinEDA_BasicFrame::DisplayActivity( int PerCent, - const wxString& Text ) +void WinEDA_BasicFrame::DisplayActivity( int PerCent, const wxString& Text ) /*************************************************************************/ { wxString Line; @@ -184,8 +188,7 @@ WinEDA_BasicFrame::DisplayActivity( int PerCent, * Met a jour la liste des anciens projets */ /*******************************************************************/ -void -WinEDA_BasicFrame::SetLastProject( const wxString& FullFileName ) +void WinEDA_BasicFrame::SetLastProject( const wxString& FullFileName ) /*******************************************************************/ { wxGetApp().m_fileHistory.AddFileToHistory( FullFileName ); @@ -231,8 +234,7 @@ wxString WinEDA_BasicFrame::GetFileFromHistory( int cmdId, * */ /**************************************************************/ -void -WinEDA_BasicFrame::GetKicadHelp( wxCommandEvent& event ) +void WinEDA_BasicFrame::GetKicadHelp( wxCommandEvent& event ) /**************************************************************/ { wxString msg; @@ -286,8 +288,7 @@ WinEDA_BasicFrame::GetKicadHelp( wxCommandEvent& event ) * */ /***********************************************************************/ -void -WinEDA_BasicFrame::GetKicadAbout( wxCommandEvent& WXUNUSED(event) ) +void WinEDA_BasicFrame::GetKicadAbout( wxCommandEvent& WXUNUSED(event) ) /***********************************************************************/ { wxAboutDialogInfo info; @@ -300,8 +301,7 @@ WinEDA_BasicFrame::GetKicadAbout( wxCommandEvent& WXUNUSED(event) ) * */ /********************************************************************/ -void -WinEDA_BasicFrame::ProcessFontPreferences( int id ) +void WinEDA_BasicFrame::ProcessFontPreferences( int id ) /********************************************************************/ { wxFont font; diff --git a/common/block_commande.cpp b/common/block_commande.cpp index 00c8987315..5354517231 100644 --- a/common/block_commande.cpp +++ b/common/block_commande.cpp @@ -11,7 +11,7 @@ #include "common.h" #include "macros.h" #include "base_struct.h" -#include "sch_item_struct.h" +#include "class_drawpickedstruct.h" #include "class_base_screen.h" #include "class_drawpanel.h" #include "confirm.h" diff --git a/common/class_drawpickedstruct.cpp b/common/class_drawpickedstruct.cpp index a55426bfa4..0c32c6d6bf 100644 --- a/common/class_drawpickedstruct.cpp +++ b/common/class_drawpickedstruct.cpp @@ -4,29 +4,9 @@ #include "fctsys.h" #include "common.h" -#include "base_struct.h" -#include "sch_item_struct.h" +#include "class_drawpickedstruct.h" -/* Constructor and destructor for SCH_ITEM */ -/* They are not inline because this creates problems with gcc at linking time - * in debug mode -*/ - -SCH_ITEM::SCH_ITEM( EDA_BaseStruct* aParent, KICAD_T aType ) : - EDA_BaseStruct( aParent, aType ) -{ - m_Layer = 0; -} - -SCH_ITEM::~SCH_ITEM() -{ -} - -/**************************/ -/* class DrawPickedStruct */ -/**************************/ - /* This class has only one useful member: .m_PickedStruct, used as a link. * It does not describe really an item. * It is used to create a linked list of selected items (in block selection). @@ -35,8 +15,8 @@ SCH_ITEM::~SCH_ITEM() */ /*******************************************************************/ -DrawPickedStruct::DrawPickedStruct( SCH_ITEM * pickedstruct ) : - SCH_ITEM( NULL, DRAW_PICK_ITEM_STRUCT_TYPE ) +DrawPickedStruct::DrawPickedStruct( EDA_BaseStruct* pickedstruct ) : + EDA_BaseStruct( NULL, DRAW_PICK_ITEM_STRUCT_TYPE ) /*******************************************************************/ { m_PickedStruct = pickedstruct; @@ -68,10 +48,10 @@ EDA_Rect DrawPickedStruct::GetBoundingBox() EDA_Rect DrawPickedStruct::GetBoundingBoxUnion() { - EDA_Rect ret; + EDA_Rect ret; + EDA_BaseStruct* item; + DrawPickedStruct* cur = this; - DrawPickedStruct* cur = this; - SCH_ITEM* item; while( cur && (item = cur->m_PickedStruct) != NULL ) { ret.Merge( item->GetBoundingBox() ); diff --git a/common/common.cpp b/common/common.cpp index 051f7364da..727c5ffea6 100644 --- a/common/common.cpp +++ b/common/common.cpp @@ -12,13 +12,124 @@ #include "confirm.h" #include +/** + * Global variables definitions. + * + * TODO: All if these variables should be moved into the class were they + * are defined and used. Most of them probably belong in the + * application class. + */ + +/* Standard page sizes in 1/1000 inch */ +Ki_PageDescr g_Sheet_A4( wxSize( 11700, 8267 ), wxPoint( 0, 0 ), wxT( "A4" ) ); +Ki_PageDescr g_Sheet_A3( wxSize( 16535, 11700 ), wxPoint( 0, 0 ), wxT( "A3" ) ); +Ki_PageDescr g_Sheet_A2( wxSize( 23400, 16535 ), wxPoint( 0, 0 ), wxT( "A2" ) ); +Ki_PageDescr g_Sheet_A1( wxSize( 33070, 23400 ), wxPoint( 0, 0 ), wxT( "A1" ) ); +Ki_PageDescr g_Sheet_A0( wxSize( 46800, 33070 ), wxPoint( 0, 0 ), wxT( "A0" ) ); +Ki_PageDescr g_Sheet_A( wxSize( 11000, 8500 ), wxPoint( 0, 0 ), wxT( "A" ) ); +Ki_PageDescr g_Sheet_B( wxSize( 17000, 11000 ), wxPoint( 0, 0 ), wxT( "B" ) ); +Ki_PageDescr g_Sheet_C( wxSize( 22000, 17000 ), wxPoint( 0, 0 ), wxT( "C" ) ); +Ki_PageDescr g_Sheet_D( wxSize( 34000, 22000 ), wxPoint( 0, 0 ), wxT( "D" ) ); +Ki_PageDescr g_Sheet_E( wxSize( 44000, 34000 ), wxPoint( 0, 0 ), wxT( "E" ) ); +Ki_PageDescr g_Sheet_GERBER( wxSize( 32000, 32000 ), wxPoint( 0, 0 ), + wxT( "GERBER" ) ); +Ki_PageDescr g_Sheet_user( wxSize( 17000, 11000 ), wxPoint( 0, 0 ), + wxT( "User" ) ); + +Ki_PageDescr* g_SheetSizeList[NB_ITEMS + 1] = +{ + &g_Sheet_A4, &g_Sheet_A3, &g_Sheet_A2, &g_Sheet_A1, &g_Sheet_A0, + &g_Sheet_A, &g_Sheet_B, &g_Sheet_C, &g_Sheet_D, &g_Sheet_E, + &g_Sheet_user, NULL +}; + + +/* File extension definitions. Please do not changes these. If a different + * file extension is needed, create a new definition in the application. + * Please note, just because they are defined as const dosen't guarentee + * that they cannot be changed. */ +const wxString ProjectFileExtension( wxT( "pro" ) ); +const wxString SchematicFileExtension( wxT( "sch" ) ); +const wxString BoardFileExtension( wxT( "brd" ) ); +const wxString NetlistFileExtension( wxT( "net" ) ); +const wxString GerberFileExtension( wxT( "pho" ) ); + +/* Proper wxFileDialog wild card definitions. */ +const wxString ProjectFileWildcard( _( "Kicad project files (*.pro)|*.pro" ) ); +const wxString BoardFileWildcard( _( "Kicad PCB files (*.brd)|*.brd") ); +const wxString SchematicFileWildcard( _( "Kicad schematic files (*.sch)|*.sch" ) ); +const wxString NetlistFileWildcard( _( "Kicad netlist files (*.net)|*.net" ) ); +const wxString GerberFileWildcard( _( "Gerber files (*.pho)|*.pho" ) ); +const wxString AllFilesWildcard( _( "All files (*)|*") ); + + +wxString g_ProductName = wxT( "KiCad E.D.A. " ); +bool g_ShowPageLimits = true; +int g_GridColor = DARKGRAY; +wxString g_RealLibDirBuffer; +wxString g_UserLibDirBuffer; +int g_DebugLevel; +int g_MouseOldButtons; +int g_KeyPressed; +wxFont* g_StdFont = NULL; +wxFont* g_DialogFont = NULL; /* Normal font used in dialog box */ +wxFont* g_ItalicFont = NULL; /* Italic font used in dialog box */ +wxFont* g_MsgFont = NULL; /* Italic font used in message panel */ +wxFont* g_FixedFont = NULL; /* Affichage de Texte en fenetres de dialogue, + * fonte a pas fixe)*/ +int g_StdFontPointSize; /* taille de la fonte */ +int g_DialogFontPointSize; /* taille de la fonte */ +int g_FixedFontPointSize; /* taille de la fonte */ +int g_MsgFontPointSize; /* taille de la fonte */ +int g_FontMinPointSize; /* taille minimum des fontes */ + + +// Nom (full file name) du file Configuration par defaut (kicad.pro) +wxString g_Prj_Default_Config_FullFilename; + +// Nom du file Configuration local (.pro) +wxString g_Prj_Config_LocalFilename; + +// Handle the preferd editor for browsing report files: +int g_UnitMetric; // display units mm = 1, inches = 0, cm = 2 + +/* Draw color for moving objects: */ +int g_GhostColor; + +StructColors ColorRefs[NBCOLOR] = +{ + { 0, 0, 0, BLACK, wxT("BLACK"), DARKDARKGRAY}, + { 192, 0, 0, BLUE, wxT("BLUE"), LIGHTBLUE}, + { 0, 160, 0, GREEN, wxT("GREEN"), LIGHTGREEN }, + { 160, 160, 0, CYAN, wxT("CYAN"), LIGHTCYAN }, + { 0, 0, 160, RED, wxT("RED"), LIGHTRED }, + { 160, 0, 160, MAGENTA, wxT("MAGENTA"), LIGHTMAGENTA }, + { 0, 128, 128, BROWN, wxT("BROWN"), YELLOW }, + { 192, 192, 192, LIGHTGRAY, wxT("GRAY"), WHITE }, + { 128, 128, 128, DARKGRAY, wxT("DARKGRAY"), LIGHTGRAY }, + { 255, 0, 0, LIGHTBLUE, wxT("LIGHTBLUE"), LIGHTBLUE }, + { 0, 255, 0, LIGHTGREEN, wxT("LIGHTGREEN"), LIGHTGREEN }, + { 255, 255, 0, LIGHTCYAN, wxT("LIGHTCYAN"), LIGHTCYAN }, + { 0, 0, 255, LIGHTRED, wxT("LIGHTRED"), LIGHTRED }, + { 255, 0, 255, LIGHTMAGENTA, wxT("LIGHTMAGENTA"), LIGHTMAGENTA }, + { 0, 255, 255, YELLOW, wxT("YELLOW"), YELLOW }, + { 255, 255, 255, WHITE, wxT("WHITE"), WHITE }, + { 64, 64, 64, DARKDARKGRAY, wxT("DARKDARKGRAY"), DARKGRAY }, + { 64, 0, 0, DARKBLUE, wxT("DARKBLUE"), BLUE }, + { 0, 64, 0, DARKGREEN, wxT("DARKGREEN"), GREEN }, + { 64, 64, 0, DARKCYAN, wxT("DARKCYAN"), CYAN }, + { 0, 0, 80, DARKRED, wxT("DARKRED"), RED }, + { 64, 0, 64, DARKMAGENTA, wxT("DARKMAGENTA"), MAGENTA }, + { 0, 64, 64, DARKBROWN, wxT("DARKBROWN"), BROWN }, + { 128, 255, 255, LIGHTYELLOW, wxT("LIGHTYELLOW"), LIGHTYELLOW } +}; + /* * Return the build date */ /****************/ -wxString -GetBuildVersion() +wxString GetBuildVersion() /****************/ { return g_BuildVersion; @@ -28,9 +139,7 @@ GetBuildVersion() /* * Return custom build date for about dialog */ -wxString -GetAboutBuildVersion() -/*********************************************/ +wxString GetAboutBuildVersion() { return g_BuildAboutVersion; } @@ -47,9 +156,7 @@ GetAboutBuildVersion() * but could make more easier an optional use of locale in kicad */ /********************************/ -void -SetLocaleTo_C_standard( void ) -/********************************/ +void SetLocaleTo_C_standard( void ) { setlocale( LC_NUMERIC, "C" ); // Switch the locale to standard C } @@ -73,9 +180,8 @@ void SetLocaleTo_Default( void ) /********************************************************************/ -bool -EnsureTextCtrlWidth(wxTextCtrl* aCtrl, - const wxString* aString ) +bool EnsureTextCtrlWidth(wxTextCtrl* aCtrl, + const wxString* aString ) /********************************************************************/ { wxWindow* window = aCtrl->GetParent(); @@ -134,8 +240,7 @@ Ki_PageDescr::Ki_PageDescr(const wxSize& size, /************************************/ -wxString -ReturnUnitSymbol( int Units ) +wxString ReturnUnitSymbol( int Units ) /************************************/ { wxString label; @@ -158,14 +263,12 @@ ReturnUnitSymbol( int Units ) } -/* +/* * Add string " (mm):" or " ("):" to the static text Stext. * Used in dialog boxes for entering values depending on selected units */ /**************************************************/ -void -AddUnitSymbol(wxStaticText& Stext, - int Units ) +void AddUnitSymbol( wxStaticText& Stext, int Units ) /**************************************************/ { wxString msg = Stext.GetLabel() + ReturnUnitSymbol( Units ); @@ -174,15 +277,12 @@ AddUnitSymbol(wxStaticText& Stext, } -/* +/* * Convert the number Value in a string according to the internal units * and the selected unit (g_UnitMetric) and put it in the wxTextCtrl TextCtrl */ /******************************************/ -void -PutValueInLocalUnits( wxTextCtrl& TextCtr, - int Value, - int Internal_Unit ) +void PutValueInLocalUnits( wxTextCtrl& TextCtr, int Value, int Internal_Unit ) /*****************************************/ { wxString msg = ReturnStringFromValue( g_UnitMetric, Value, Internal_Unit ); @@ -196,9 +296,7 @@ PutValueInLocalUnits( wxTextCtrl& TextCtr, * according to the internal units and the selected unit (g_UnitMetric) */ /***************************************************/ -int -ReturnValueFromTextCtrl( const wxTextCtrl& TextCtr, - int Internal_Unit ) +int ReturnValueFromTextCtrl( const wxTextCtrl& TextCtr, int Internal_Unit ) /***************************************************/ { int value; @@ -220,11 +318,8 @@ ReturnValueFromTextCtrl( const wxTextCtrl& TextCtr, * @return a wxString what contains value and optionnaly the sumbol unit (like 2.000 mm) */ /*******************************************/ -wxString -ReturnStringFromValue(int aUnits, - int aValue, - int aInternal_Unit, - bool aAdd_unit_symbol) +wxString ReturnStringFromValue( int aUnits, int aValue, int aInternal_Unit, + bool aAdd_unit_symbol ) /*******************************************/ { wxString StringValue; @@ -258,7 +353,7 @@ ReturnStringFromValue(int aUnits, } -/* +/* * Return the string from Value, according to units (inch, mm ...) for display, * and the initial unit for value * Unit = display units (INCH, MM ..) @@ -266,10 +361,8 @@ ReturnStringFromValue(int aUnits, * Internal_Unit = units per inch for computed value */ /****************************************************************************/ -int -ReturnValueFromString( int Units, - const wxString& TextValue, - int Internal_Unit ) +int ReturnValueFromString( int Units, const wxString& TextValue, + int Internal_Unit ) /****************************************************************************/ { int Value; @@ -277,7 +370,7 @@ ReturnValueFromString( int Units, TextValue.ToDouble( &dtmp ); if( Units >= CENTIMETRE ) - Value = (int) round( dtmp ); + Value = wxRound( dtmp ); else Value = From_User_Unit( Units, dtmp, Internal_Unit ); @@ -286,9 +379,7 @@ ReturnValueFromString( int Units, /******************************************************************/ -double To_User_Unit( bool is_metric, - int val, - int internal_unit_value ) +double To_User_Unit( bool is_metric, int val, int internal_unit_value ) /******************************************************************/ /** * Function To_User_Unit @@ -339,10 +430,7 @@ double To_User_Unit( bool is_metric, * Return in internal units the value "val" given in inch or mm */ /*****************************************/ -int -From_User_Unit( bool is_metric, - double val, - int internal_unit_value ) +int From_User_Unit( bool is_metric, double val, int internal_unit_value ) /*****************************************/ { double value; @@ -352,7 +440,7 @@ From_User_Unit( bool is_metric, else value = val * internal_unit_value; - return (int) round( value ); + return wxRound( value ); } @@ -360,8 +448,7 @@ From_User_Unit( bool is_metric, * Return the string date "day month year" like "23 jun 2005" */ /********/ -wxString -GenDate() +wxString GenDate() /********/ { static const wxString mois[12] = @@ -387,8 +474,7 @@ GenDate() * My memory allocation */ /***********************************/ -void* -MyMalloc( size_t nb_octets ) +void* MyMalloc( size_t nb_octets ) /***********************************/ { void* pt_mem; @@ -417,9 +503,7 @@ MyMalloc( size_t nb_octets ) * @return bool - true if success, else false */ /********************************************/ -bool -ProcessExecute( const wxString& aCommandLine, - int aFlags ) +bool ProcessExecute( const wxString& aCommandLine, int aFlags ) /********************************************/ { #ifdef __WINDOWS__ @@ -436,8 +520,7 @@ ProcessExecute( const wxString& aCommandLine, * My memory allocation, memory space is cleared */ /*****************************/ -void* -MyZMalloc( size_t nb_octets ) +void* MyZMalloc( size_t nb_octets ) /*****************************/ { void* pt_mem = MyMalloc( nb_octets ); @@ -449,8 +532,7 @@ MyZMalloc( size_t nb_octets ) /*******************************/ -void -MyFree( void* pt_mem ) +void MyFree( void* pt_mem ) /*******************************/ { if( pt_mem ) @@ -464,9 +546,7 @@ MyFree( void* pt_mem ) * (no spaces, replaced by _) */ /**************************************************************/ -wxString -ReturnPcbLayerName( int layer_number, - bool omitSpacePadding ) +wxString ReturnPcbLayerName( int layer_number, bool omitSpacePadding ) /**************************************************************/ { const unsigned LAYER_LIMIT = 29; @@ -527,11 +607,11 @@ WinEDA_TextFrame::WinEDA_TextFrame( wxWindow* parent, MAYBE_RESIZE_BORDER ) /***************************************************************************/ { - /* - * TODO background and foreground colors of WinEDA_TextFrame should be - * controllable / settable with project settings or config file and not - * hardcoded in binairy ! - */ + /* + * TODO background and foreground colors of WinEDA_TextFrame should be + * controllable / settable with project settings or config file and not + * hardcoded in binairy ! + */ wxSize size; @@ -547,10 +627,10 @@ WinEDA_TextFrame::WinEDA_TextFrame( wxWindow* parent, 0, NULL, wxLB_ALWAYS_SB | wxLB_SINGLE ); - /* The color of the text in the wxListBox (black) */ + /* The color of the text in the wxListBox (black) */ m_List->SetBackgroundColour( wxColour( 255, 255, 255 ) ); - /* The foreground color of the wxListBox (white) */ + /* The foreground color of the wxListBox (white) */ m_List->SetForegroundColour( wxColour( 0, 0, 0 ) ); SetReturnCode( -1 ); @@ -558,8 +638,7 @@ WinEDA_TextFrame::WinEDA_TextFrame( wxWindow* parent, /***************************************************/ -void -WinEDA_TextFrame::Append( const wxString& text ) +void WinEDA_TextFrame::Append( const wxString& text ) /***************************************************/ { m_List->Append( text ); @@ -567,8 +646,7 @@ WinEDA_TextFrame::Append( const wxString& text ) /**********************************************************/ -void -WinEDA_TextFrame::D_ClickOnList( wxCommandEvent& event ) +void WinEDA_TextFrame::D_ClickOnList( wxCommandEvent& event ) /**********************************************************/ { int ii = m_List->GetSelection(); @@ -578,8 +656,7 @@ WinEDA_TextFrame::D_ClickOnList( wxCommandEvent& event ) /*************************************************/ -void -WinEDA_TextFrame::OnClose( wxCloseEvent& event ) +void WinEDA_TextFrame::OnClose( wxCloseEvent& event ) /*************************************************/ { EndModal( -1 ); @@ -598,17 +675,12 @@ WinEDA_TextFrame::OnClose( wxCloseEvent& event ) * color = couleur d'affichage */ /*****************************************************************************/ -void Affiche_1_Parametre( WinEDA_DrawFrame* frame, - int pos_X, - const wxString& texte_H, - const wxString& texte_L, +void Affiche_1_Parametre( WinEDA_DrawFrame* frame, int pos_X, + const wxString& texte_H, const wxString& texte_L, int color ) /*****************************************************************************/ { - frame->MsgPanel->Affiche_1_Parametre( pos_X, - texte_H, - texte_L, - color ); + frame->MsgPanel->Affiche_1_Parametre( pos_X, texte_H, texte_L, color ); } @@ -616,8 +688,8 @@ void Affiche_1_Parametre( WinEDA_DrawFrame* frame, * Routine d'affichage de la documentation associee a un composant */ /****************************************************************************/ -void -AfficheDoc( WinEDA_DrawFrame* frame, const wxString& Doc, const wxString& KeyW ) +void AfficheDoc( WinEDA_DrawFrame* frame, const wxString& Doc, + const wxString& KeyW ) /****************************************************************************/ { wxString Line1( wxT( "Doc: " ) ), Line2( wxT( "KeyW: " ) ); @@ -660,9 +732,7 @@ int GetTimeStamp() * suivie de " ou mm */ /*********************************************/ -const -wxString& valeur_param( int valeur, - wxString& buf_texte ) +const wxString& valeur_param( int valeur, wxString& buf_texte ) /*********************************************/ { if( g_UnitMetric ) @@ -682,9 +752,7 @@ wxString& valeur_param( int valeur, * */ /**********************************/ -wxString& -operator <<( wxString& aString, - const wxPoint& aPos ) +wxString& operator <<( wxString& aString, const wxPoint& aPos ) /*********************************/ { wxString temp; @@ -695,20 +763,3 @@ operator <<( wxString& aString, return aString; } - - -/* compilers that does not have the round function (posix) */ -#ifdef __MSVC__ -/* - * return the nearest rounded ( equivalent to the nearest integer value) - * from aNumber - */ -/**********************/ -double -round( double aNumber ) -/**********************/ -{ - return floor( aNumber + 0.5 ); -} -#endif - diff --git a/common/copy_to_clipboard.cpp b/common/copy_to_clipboard.cpp index 130e1c0cf0..280f0a1dc0 100644 --- a/common/copy_to_clipboard.cpp +++ b/common/copy_to_clipboard.cpp @@ -69,6 +69,7 @@ bool DrawPage( WinEDA_DrawPanel* panel ) int ClipboardSizeX, ClipboardSizeY; bool DrawBlock = FALSE; wxRect DrawArea; + BASE_SCREEN* screen = panel->GetScreen(); /* scale is the ratio resolution/internal units */ float scale = 82.0 / panel->m_Parent->m_InternalUnits; @@ -103,7 +104,7 @@ bool DrawPage( WinEDA_DrawPanel* panel ) EDA_Rect tmp = panel->m_ClipBox; GRResetPenAndBrush( &dc ); GRForceBlackPen( s_PlotBlackAndWhite ); - g_IsPrinting = TRUE; + screen->m_IsPrinting = true; dc.SetUserScale( scale, scale ); ClipboardSizeX = dc.MaxX() + 10; ClipboardSizeY = dc.MaxY() + 10; @@ -115,7 +116,7 @@ bool DrawPage( WinEDA_DrawPanel* panel ) dc.SetClippingRegion( DrawArea ); } panel->PrintPage( &dc, Print_Sheet_Ref, -1, false ); - g_IsPrinting = FALSE; + screen->m_IsPrinting = false; panel->m_ClipBox = tmp; wxMetafile* mf = dc.Close(); if( mf ) diff --git a/common/dcsvg.cpp b/common/dcsvg.cpp index 7b0e1a460c..d843452b95 100644 --- a/common/dcsvg.cpp +++ b/common/dcsvg.cpp @@ -29,7 +29,6 @@ #define newline wxString( wxT( "\n" ) ) #define space wxString( wxT( " " ) ) #define semicolon wxString( wxT( ";" ) ) -#define wx_round( a ) (int) ( (a) + .5 ) #ifdef __BORLANDC__ #pragma warn -rch diff --git a/common/drawframe.cpp b/common/drawframe.cpp index eaee5f3fbe..19f1f3f994 100644 --- a/common/drawframe.cpp +++ b/common/drawframe.cpp @@ -21,6 +21,11 @@ #include +/* Configuration entry names. */ +static const wxString CursorShapeEntry( wxT( "CuShape" ) ); +static const wxString ShowGridEntry( wxT( "ShGrid" ) ); + + BEGIN_EVENT_TABLE( WinEDA_DrawFrame, WinEDA_BasicFrame ) EVT_MOUSEWHEEL( WinEDA_DrawFrame::OnMouseEvent ) EVT_MENU_OPEN( WinEDA_DrawFrame::OnMenuOpen ) @@ -60,6 +65,7 @@ WinEDA_DrawFrame::WinEDA_DrawFrame( wxWindow* father, int idtype, m_Print_Sheet_Ref = TRUE; // TRUE pour avoir le cartouche imprim� m_Draw_Auxiliary_Axis = FALSE; // TRUE pour avoir les axes auxiliares dessines m_UnitType = INTERNAL_UNIT_TYPE; // Internal unit = inch + m_CursorShape = 0; // Internal units per inch: = 1000 for schema, = 10000 for PCB m_InternalUnits = EESCHEMA_INTERNAL_UNIT; @@ -105,7 +111,7 @@ WinEDA_DrawFrame::~WinEDA_DrawFrame() { if( DrawPanel ) // Required: in WinEDA3D_DrawFrame, DrawPanel == NULL ! wxGetApp().m_EDA_Config->Write( wxT( "AutoPAN" ), - DrawPanel->m_AutoPAN_Enable ); + DrawPanel->m_AutoPAN_Enable ); } @@ -113,7 +119,7 @@ WinEDA_DrawFrame::~WinEDA_DrawFrame() void WinEDA_DrawFrame::AddFontSelectionMenu( wxMenu* main_menu ) /*****************************************************************/ -/* create the submenu for fonte selection and setup font size +/* create the submenu for font selection and setup font size */ { wxMenu* fontmenu = new wxMenu(); @@ -180,7 +186,7 @@ void WinEDA_DrawFrame::Affiche_Message( const wxString& message ) /**************************************************************/ /* - * Dispaly the meesage on yhe bottomon the frame + * Display the message on the bottom the frame */ { SetStatusText( message ); @@ -532,7 +538,7 @@ void WinEDA_DrawFrame::SetToolID( int id, int new_cursor_id, /*****************************/ -/* default virtual fonctions */ +/* default virtual functions */ /*****************************/ void WinEDA_DrawFrame::OnGrid( int grid_type ) @@ -577,11 +583,11 @@ void WinEDA_DrawFrame::AdjustScrollBars() if( screen == NULL || DrawPanel == NULL ) return; - // La zone d'affichage est reglee a une taille double de la feuille de travail: + // The drawing size is twice the current page size. draw_size = screen->ReturnPageSize() * 2; - // On utilise le centre de l'ecran comme position de reference, donc - // la surface de trace doit etre augmentee + // Calculate the portion of the drawing that can be displayed in the + // client area at the current zoom level. panel_size = DrawPanel->GetClientSize(); screen->Unscale( panel_size ); @@ -603,8 +609,14 @@ void WinEDA_DrawFrame::AdjustScrollBars() screen->m_DrawOrg.y = -panel_size.y / 2; } - // Calcul du nombre de scrolls (en unites de scrool ) - scrollbar_number = draw_size / screen->Unscale( screen->m_ZoomScalar ); + // Calculate the number of scroll bar units for the given zoom level. */ + scrollbar_number.x = + wxRound( (double) draw_size.x / + (double) screen->Unscale( screen->m_ZoomScalar ) ); + scrollbar_number.y = + wxRound( (double) draw_size.y / + (double) screen->Unscale( screen->m_ZoomScalar ) ); + xUnit = yUnit = screen->m_ZoomScalar; if( xUnit <= 1 ) @@ -620,16 +632,21 @@ void WinEDA_DrawFrame::AdjustScrollBars() scrollbar_pos.x -= panel_size.x / 2; scrollbar_pos.y -= panel_size.y / 2; - if( scrollbar_pos.x < 0 ) + if( scrollbar_pos.x <= 0 ) scrollbar_pos.x = 0; - if( scrollbar_pos.y < 0 ) + if( scrollbar_pos.y <= 0 ) scrollbar_pos.y = 0; - scrollbar_pos.x /= xUnit; - scrollbar_pos.y /= yUnit; + scrollbar_pos.x = wxRound( (double) scrollbar_pos.x / (double) xUnit ); + scrollbar_pos.y = wxRound( (double) scrollbar_pos.y / (double) yUnit ); screen->m_ScrollbarPos = scrollbar_pos; screen->m_ScrollbarNumber = scrollbar_number; + wxLogDebug( wxT( "SetScrollbars(%d, %d, %d, %d, %d, %d)" ), + screen->m_ZoomScalar, screen->m_ZoomScalar, + screen->m_ScrollbarNumber.x, screen->m_ScrollbarNumber.y, + screen->m_ScrollbarPos.x, screen->m_ScrollbarPos.y ); + DrawPanel->SetScrollbars( screen->m_ZoomScalar, screen->m_ZoomScalar, screen->m_ScrollbarNumber.x, @@ -648,7 +665,7 @@ void WinEDA_DrawFrame::SetDrawBgColor( int color_num ) * le parametre XorMode est mis a jour selon la couleur du fond */ { - if( (color_num != WHITE) && (color_num != BLACK) ) + if( ( color_num != WHITE ) && ( color_num != BLACK ) ) color_num = BLACK; g_DrawBgColor = color_num; if( color_num == WHITE ) @@ -688,11 +705,11 @@ void WinEDA_DrawFrame::SetLanguage( wxCommandEvent& event ) /* * Update the status bar information. * - * The base method updates the absolute and relative cooridinates and the + * The base method updates the absolute and relative coordinates and the * zoom information. If you override this virtual method, make sure to call * this subclassed method. */ -void WinEDA_DrawFrame::Affiche_Status_Box() +void WinEDA_DrawFrame::UpdateStatusBar() { wxString Line; int dx, dy; @@ -703,7 +720,7 @@ void WinEDA_DrawFrame::Affiche_Status_Box() /* Display Zoom level: zoom = zoom_coeff/ZoomScalar */ if ( (screen->GetZoom() % screen->m_ZoomScalar) == 0 ) - Line.Printf( wxT( "Z %d" ),screen->GetZoom() / screen->m_ZoomScalar ); + Line.Printf( wxT( "Z %d" ), screen->GetZoom() / screen->m_ZoomScalar ); else Line.Printf( wxT( "Z %.1f" ), (float)screen->GetZoom() / screen->m_ZoomScalar ); SetStatusText( Line, 1 ); @@ -726,3 +743,38 @@ void WinEDA_DrawFrame::Affiche_Status_Box() SetStatusText( Line, 3 ); } + +/** + * Load draw frame specific configuration settings. + * + * Don't forget to call this base method from any derived classes or the + * settings will not get loaded. + */ +void WinEDA_DrawFrame::LoadSettings() +{ + wxASSERT( wxGetApp().m_EDA_Config != NULL ); + + wxConfig* cfg = wxGetApp().m_EDA_Config; + + WinEDA_BasicFrame::LoadSettings(); + cfg->Read( m_FrameName + CursorShapeEntry, &m_CursorShape, ( long )0 ); + cfg->Read( m_FrameName + ShowGridEntry, &m_Draw_Grid, true ); +} + + +/** + * Save draw frame specific configuration settings. + * + * Don't forget to call this base method from any derived classes or the + * settings will not get saved. + */ +void WinEDA_DrawFrame::SaveSettings() +{ + wxASSERT( wxGetApp().m_EDA_Config != NULL ); + + wxConfig* cfg = wxGetApp().m_EDA_Config; + + WinEDA_BasicFrame::SaveSettings(); + cfg->Write( m_FrameName + CursorShapeEntry, m_CursorShape ); + cfg->Write( m_FrameName + ShowGridEntry, m_Draw_Grid ); +} diff --git a/common/drawpanel.cpp b/common/drawpanel.cpp index 1072f31b34..ccaec19aed 100644 --- a/common/drawpanel.cpp +++ b/common/drawpanel.cpp @@ -16,7 +16,7 @@ // Local defines #define CURSOR_SIZE 12 // Cursor size in pixels -// Locad variables +// Local variables /* Used to inhibit a response to a mouse left button release, after a double click * (when releasing the left button at the end of the second click @@ -73,8 +73,7 @@ WinEDA_DrawPanel::WinEDA_DrawPanel( WinEDA_DrawFrame* parent, int id, ForceCloseManageCurseur = NULL; if( wxGetApp().m_EDA_Config ) - m_AutoPAN_Enable = wxGetApp().m_EDA_Config->Read( wxT( "AutoPAN" ), - TRUE ); + m_AutoPAN_Enable = wxGetApp().m_EDA_Config->Read( wxT( "AutoPAN" ), true ); m_AutoPAN_Request = FALSE; m_Block_Enable = FALSE; @@ -107,7 +106,7 @@ void WinEDA_DrawPanel::Trace_Curseur( wxDC* DC, int color ) wxPoint Cursor = GetScreen()->m_Curseur; GRSetDrawMode( DC, GR_XOR ); - if( g_CursorShape == 1 ) /* Trace d'un reticule */ + if( m_Parent->m_CursorShape == 1 ) /* Trace d'un reticule */ { int dx = GetScreen()->Unscale( m_ClipBox.GetWidth() ); int dy = GetScreen()->Unscale( m_ClipBox.GetHeight() ); @@ -214,7 +213,7 @@ wxPoint WinEDA_DrawPanel::CursorRealPosition( const wxPoint& ScreenPos ) bool WinEDA_DrawPanel::IsPointOnDisplay( wxPoint ref_pos ) /********************************************************/ -/** Funcion IsPointOnDisplay +/** Function IsPointOnDisplay * @param ref_pos is the position to test in pixels, relative to the panel. * @return TRUE if ref_pos is a point currently visible on screen * FALSE if ref_pos is out of screen @@ -312,11 +311,10 @@ wxPoint WinEDA_DrawPanel::CursorScreenPosition() /********************************************************/ /** Function CursorScreenPosition - * @return the curseur current position in pixels in the screen draw area + * @return the cursor current position in pixels in the screen draw area */ { - wxPoint pos = GetScreen()->m_Curseur; - pos -= GetScreen()->m_DrawOrg; + wxPoint pos = GetScreen()->m_Curseur - GetScreen()->m_DrawOrg; GetScreen()->Scale( pos ); return pos; } @@ -416,7 +414,7 @@ void WinEDA_DrawPanel::OnActivate( wxActivateEvent& event ) /** * Called on window activation. * init the member m_CanStartBlock to avoid a block start command - * on activation (because a left mouse buton can be pressed and no block command wanted + * on activation (because a left mouse button can be pressed and no block command wanted * This happens when enter on a hierarchycat sheet on double click */ { @@ -544,7 +542,7 @@ void WinEDA_DrawPanel::EraseScreen( wxDC* DC ) // see setup.h in wx Widgets. // wxWidgets configure can need option --enable-graphics_ctx // Currently, **only for tests** -//#define USE_GCDC_IN_KICAD // uncommment it to use wxGCDC +//#define USE_GCDC_IN_KICAD // uncomment it to use wxGCDC #endif /***************************************************/ @@ -553,8 +551,8 @@ void WinEDA_DrawPanel::OnPaint( wxPaintEvent& event ) { #ifdef USE_GCDC_IN_KICAD wxPaintDC pDC( this ); - wxGCDC paintDC(pDC); // Following line should be disabled on MSW and OS X - paintDC.GetGraphicsContext()->Translate(0.5, 0.5); // Fix for pixel offset bug http://trac.wxwidgets.org/ticket/4187 + wxGCDC paintDC(pDC); // Following line should be disabled on MSW and OS X + paintDC.GetGraphicsContext()->Translate(0.5, 0.5); // Fix for pixel offset bug http://trac.wxwidgets.org/ticket/4187 #else wxPaintDC paintDC( this ); #endif @@ -703,14 +701,14 @@ void WinEDA_DrawPanel::DrawBackGround( wxDC* DC ) wxRealPoint dgrid = screen_grid_size; screen->Scale( dgrid ); // dgrid = grid size in pixels - // if the grid size is sall ( < 5 pixels) do not display all points + // if the grid size is small ( < 5 pixels) do not display all points if( dgrid.x < 5 ) { screen_grid_size.x *= 2; dgrid.x *= 2; } if( dgrid.x < 5 ) - drawgrid = FALSE; // The gris is too small: do not show it + drawgrid = FALSE; // The grid is too small: do not show it if( dgrid.y < 5 ) { @@ -718,7 +716,7 @@ void WinEDA_DrawPanel::DrawBackGround( wxDC* DC ) dgrid.y *= 2; } if( dgrid.y < 5 ) - drawgrid = FALSE; // The gris is too small + drawgrid = FALSE; // The grid is too small GetViewStart( &org.x, &org.y ); GetScrollPixelsPerUnit( &ii, &jj ); @@ -739,12 +737,12 @@ void WinEDA_DrawPanel::DrawBackGround( wxDC* DC ) GRSetColorPen( DC, color ); for( ii = 0; ; ii++ ) { - xg = (int) round(ii * screen_grid_size.x); + xg = wxRound(ii * screen_grid_size.x); int xpos = org.x + xg; for( jj = 0; ; jj++ ) { - yg = (int) round(jj * screen_grid_size.y); + yg = wxRound(jj * screen_grid_size.y); GRPutPixel( &m_ClipBox, DC, xpos, org.y + yg, color ); if( yg > size.y ) break; @@ -850,7 +848,7 @@ void WinEDA_DrawPanel::OnMouseLeaving( wxMouseEvent& event ) if( !m_AutoPAN_Enable || !m_AutoPAN_Request || m_IgnoreMouseEvents ) return; - // Auto pan if mouse is leave working aera: + // Auto pan if mouse is leave working area: wxSize size = GetClientSize(); if( ( size.x < event.GetX() ) || ( size.y < event.GetY() ) @@ -867,17 +865,12 @@ void WinEDA_DrawPanel::OnMouseLeaving( wxMouseEvent& event ) * Handle mouse wheel events. * * The mouse wheel is used to provide support for zooming and panning. This - * is accomplished by converting mouse wheel events in psuedo menu command + * is accomplished by converting mouse wheel events in pseudo menu command * events. */ void WinEDA_DrawPanel::OnMouseWheel( wxMouseEvent& event ) { - wxRect rect = GetRect(); - - /* This fixes a bad rectangle horizontal position returned by the - * schematic library veiwer panel. It may have something to do with - * the sash window. */ - rect.Offset( -rect.x, -rect.y ); + wxRect rect = wxRect( wxPoint( 0, 0), GetClientSize() ); /* Ignore scroll events if the cursor is outside the drawing area. */ if( event.GetWheelRotation() == 0 || !GetParent()->IsEnabled() @@ -892,6 +885,9 @@ void WinEDA_DrawPanel::OnMouseWheel( wxMouseEvent& event ) return; } + GetScreen()->m_Curseur = + CursorRealPosition( CalcUnscrolledPosition( event.GetPosition() ) ); + wxCommandEvent cmd( wxEVT_COMMAND_MENU_SELECTED ); cmd.SetEventObject( this ); @@ -930,12 +926,12 @@ void WinEDA_DrawPanel::OnMouseEvent( wxMouseEvent& event ) if( !screen ) return; - #define MIN_DRAG_COUNT_FOR_START_BLOCK_COMMAND 5 /* Adjust value to filter mouse deplacement before + #define MIN_DRAG_COUNT_FOR_START_BLOCK_COMMAND 5 /* Adjust value to filter mouse displacement before * consider the drag mouse is really a drag command, not just a movement while click */ static int MinDragEventCount; /* counts the drag events. * used to filter mouse moves before starting a block command - * a block comman can be started only if MinDragEventCount > MIN_DRAG_COUNT_FOR_START_BLOCK_COMMAND + * a block command can be started only if MinDragEventCount > MIN_DRAG_COUNT_FOR_START_BLOCK_COMMAND * in order to avoid spurious block commands */ if( event.Leaving() || event.Entering() ) @@ -986,7 +982,7 @@ void WinEDA_DrawPanel::OnMouseEvent( wxMouseEvent& event ) } ; // Unused - localrealbutt |= localbutt; /* compensation defaut wxGTK */ + localrealbutt |= localbutt; /* compensation default wxGTK */ /* Compute absolute m_MousePosition in pixel units: */ screen->m_MousePositionInPixels = CalcUnscrolledPosition( event.GetPosition() ); @@ -1040,7 +1036,7 @@ void WinEDA_DrawPanel::OnMouseEvent( wxMouseEvent& event ) if( event.ButtonUp( 2 ) && (screen->BlockLocate.m_State == STATE_NO_BLOCK) ) { - // The middle button has been relached, with no block command: + // The middle button has been released, with no block command: // We use it for a zoom center at cursor position command wxCommandEvent cmd( wxEVT_COMMAND_MENU_SELECTED, ID_POPUP_ZOOM_CENTER ); @@ -1049,7 +1045,7 @@ void WinEDA_DrawPanel::OnMouseEvent( wxMouseEvent& event ) } - /* Calling the general function on mouse changes (and pseudo key commands) */ + /* Calling the general function on mouse changes (and pseudo key commands) */ m_Parent->GeneralControle( &DC, screen->m_MousePositionInPixels ); @@ -1065,9 +1061,9 @@ void WinEDA_DrawPanel::OnMouseEvent( wxMouseEvent& event ) } /* A new command block can start after a release buttons - * and if the drag is enougth + * and if the drag is enough * This is to avoid a false start block when a dialog box is demiss, - * or when changing panels in hierachy navigation + * or when changing panels in hierarchy navigation * or when clicking while and moving mouse */ if( !event.LeftIsDown() && !event.MiddleIsDown() ) @@ -1076,8 +1072,8 @@ void WinEDA_DrawPanel::OnMouseEvent( wxMouseEvent& event ) m_CanStartBlock = 0; /* remember the last cursor position when a drag mouse starts - * this is the last postion ** before ** clicking a button - * this is usefull to start a block command from the point where the mouse was clicked first + * this is the last position ** before ** clicking a button + * this is useful to start a block command from the point where the mouse was clicked first * (a filter creates a delay for the real block command start, and we must remember this point) */ m_CursorStartPos = screen->m_Curseur; @@ -1111,7 +1107,7 @@ void WinEDA_DrawPanel::OnMouseEvent( wxMouseEvent& event ) if( event.MiddleIsDown() ) cmd_type |= MOUSE_MIDDLE; - /* A block command is started if the drag is enought. + /* A block command is started if the drag is enough. * A small drag is ignored (it is certainly a little mouse move when clicking) * not really a drag mouse */ @@ -1138,7 +1134,7 @@ void WinEDA_DrawPanel::OnMouseEvent( wxMouseEvent& event ) { /* Release the mouse button: end of block. * The command can finish (DELETE) or have a next command (MOVE, COPY). - * However the block command is cancelled if the block size is small + * However the block command is canceled if the block size is small * Because a block command filtering is already made, this case happens, * but only when the on grid cursor has not moved. */ @@ -1255,7 +1251,7 @@ void WinEDA_DrawPanel::OnKeyEvent( wxKeyEvent& event ) pos = CalcUnscrolledPosition( wxGetMousePosition() - GetScreenPosition() ); /* Compute absolute mouse position in pixel units (i.e. considering the - current scrool) : */ + current scroll) : */ Screen->m_MousePositionInPixels = pos; /* Compute absolute mouse position in user units: */ diff --git a/common/eda_doc.cpp b/common/eda_doc.cpp index 57c2f047fb..c9e537e737 100644 --- a/common/eda_doc.cpp +++ b/common/eda_doc.cpp @@ -20,13 +20,15 @@ void WinEDA_App::ReadPdfBrowserInfos() /* Read from Common config the Pdf browser choice */ { - if( m_EDA_CommonConfig ) - { - m_PdfBrowserIsDefault = m_EDA_CommonConfig->Read( wxT( "PdfBrowserIsDefault" ), TRUE ); - m_PdfBrowser = m_EDA_CommonConfig->Read( wxT( "PdfBrowserName" ), wxEmptyString ); - } + wxASSERT( m_EDA_CommonConfig != NULL ); + + m_PdfBrowserIsDefault = m_EDA_CommonConfig->Read( wxT( "PdfBrowserIsDefault" ), + true ); + m_PdfBrowser = m_EDA_CommonConfig->Read( wxT( "PdfBrowserName" ), + wxEmptyString ); + if( m_PdfBrowser.IsEmpty() ) - m_PdfBrowserIsDefault = TRUE; + m_PdfBrowserIsDefault = true; } @@ -37,11 +39,13 @@ void WinEDA_App::WritePdfBrowserInfos() /* Write into Common config the Pdf browser choice */ { - if( !m_EDA_CommonConfig ) - return; + wxASSERT( m_EDA_CommonConfig != NULL ); + if( m_PdfBrowser.IsEmpty() ) - m_PdfBrowserIsDefault = TRUE; - m_EDA_CommonConfig->Write( wxT( "PdfBrowserIsDefault" ), m_PdfBrowserIsDefault ); + m_PdfBrowserIsDefault = true; + + m_EDA_CommonConfig->Write( wxT( "PdfBrowserIsDefault" ), + m_PdfBrowserIsDefault ); m_EDA_CommonConfig->Write( wxT( "PdfBrowserName" ), m_PdfBrowser ); } diff --git a/common/edaappl.cpp b/common/edaappl.cpp index 299215cef0..f5e2a39e11 100644 --- a/common/edaappl.cpp +++ b/common/edaappl.cpp @@ -4,12 +4,11 @@ /*** * @file edaapl.cpp - * @brief For the main application: init functions, and language selection (locale handling) + * + * @brief For the main application: init functions, and language selection + * (locale handling) ***/ -#define EDA_BASE -#define COMMON_GLOBL - #ifdef KICAD_PYTHON # include #endif @@ -37,6 +36,9 @@ #include "gestfich.h" +static const wxChar* CommonConfigPath = wxT( "kicad_common" ); + + #ifdef __UNIX__ # define TMP_FILE "/tmp/kicad.tmp" #endif @@ -44,7 +46,7 @@ /* Just add new languages to the list. This macro will properly recalculate * the size of the array. */ #define LANGUAGE_DESCR_COUNT ( sizeof( s_Language_List ) / \ - sizeof( struct LANGUAGE_DESCR ) ) + sizeof( struct LANGUAGE_DESCR ) ) /* Default font size */ #define FONT_DEFAULT_SIZE 10 /* Default font size. */ @@ -52,11 +54,11 @@ /** * The real font size will be computed at run time - * A small class to handle the list od existing translations. + * A small class to handle the list on existing translations. * the locale translation is automatic. - * the selection of languages is mainly for mainteners's convenience (tests...)\n - * To add a support to a new tranlation: - * create a new icon (flag of the country) (see Lang_Fr.xpm as an exemple) + * the selection of languages is mainly for maintainer's convenience + * To add a support to a new translation: + * create a new icon (flag of the country) (see Lang_Fr.xpm as an example) * add a new item to s_Language_List[LANGUAGE_DESCR_COUNT] * and set LANGUAGE_DESCR_COUNT to the new value */ @@ -117,7 +119,7 @@ static struct LANGUAGE_DESCR s_Language_List[] = _( "Spanish" ) }, - /* Portugese language */ + /* Portuguese language */ { wxLANGUAGE_PORTUGUESE, ID_LANGUAGE_PORTUGUESE, @@ -222,12 +224,13 @@ WinEDA_App::WinEDA_App() { m_Checker = NULL; m_HtmlCtrl = NULL; - m_EDA_CommonConfig = NULL; m_EDA_Config = NULL; m_Env_Defined = FALSE; m_LanguageId = wxLANGUAGE_DEFAULT; m_PdfBrowserIsDefault = TRUE; m_Locale = NULL; + m_ProjectConfig = NULL; + m_EDA_CommonConfig = NULL; } @@ -239,9 +242,11 @@ WinEDA_App::~WinEDA_App() SaveSettings(); /* delete user datas */ - delete g_Prj_Config; + if( m_ProjectConfig ) + delete m_ProjectConfig; + if( m_EDA_CommonConfig ) + delete m_EDA_CommonConfig; delete m_EDA_Config; - delete m_EDA_CommonConfig; delete g_StdFont; delete g_DialogFont; delete g_ItalicFont; @@ -258,11 +263,10 @@ WinEDA_App::~WinEDA_App() */ void WinEDA_App::InitEDA_Appl( const wxString& name ) { - wxString ident; wxString EnvLang; - ident = name + wxT( "-" ) + wxGetUserId(); - m_Checker = new wxSingleInstanceChecker( ident ); + m_Checker = new wxSingleInstanceChecker( name.Lower() + wxT( "-" ) + + wxGetUserId() ); /* Init kicad environment * the environment variable KICAD (if exists) gives the kicad path: @@ -289,8 +293,11 @@ void WinEDA_App::InitEDA_Appl( const wxString& name ) /* Init parameters for configuration */ SetVendorName( wxT( "kicad" ) ); SetAppName( name.Lower() ); - m_EDA_Config = new wxConfig( name ); - m_EDA_CommonConfig = new wxConfig( wxT( "kicad_common" ) ); + SetTitle( name ); + m_EDA_Config = new wxConfig( ); + wxASSERT( m_EDA_Config != NULL ); + m_EDA_CommonConfig = new wxConfig( CommonConfigPath ); + wxASSERT( m_EDA_CommonConfig != NULL ); /* Create the fonts used in dialogs and messages */ g_StdFontPointSize = FONT_DEFAULT_SIZE; @@ -319,13 +326,13 @@ void WinEDA_App::InitEDA_Appl( const wxString& name ) wxImage::AddHandler( new wxJPEGHandler ); wxFileSystem::AddHandler( new wxZipFSHandler ); - // Analyse the command line & init binary path + // Analise the command line & init binary path SetBinDir(); SetDefaultSearchPaths(); SetLanguagePath(); ReadPdfBrowserInfos(); - // Internationalisation: loading the kicad suitable Dictionnary + // Internationalization: loading the kicad suitable Dictionary m_EDA_CommonConfig->Read( wxT( "Language" ), &m_LanguageId, wxLANGUAGE_DEFAULT ); @@ -345,11 +352,10 @@ void WinEDA_App::InitEDA_Appl( const wxString& name ) /** * Init online help + * * @return none */ -/*****************************************/ void WinEDA_App::InitOnLineHelp() -/*****************************************/ { wxString fullfilename = FindKicadHelpPath(); @@ -378,11 +384,10 @@ void WinEDA_App::InitOnLineHelp() /** * Find the path to the executable and store it in WinEDA_App::m_BinDir + * * @return TODO */ -/*******************************/ bool WinEDA_App::SetBinDir() -/*******************************/ { /* Apple MacOSx */ #ifdef __APPLE__ @@ -459,7 +464,7 @@ bool WinEDA_App::SetBinDir() wxLogDebug( wxT( "Windows path: " ) + wfn.GetFullPath() ); wxLogDebug( wxT( "Executable path the Kicad way: " ) + m_BinDir ); wxLogDebug( wxT( "Executable path the wxWidgets way: " ) + - GetTraits()->GetStandardPaths().GetExecutablePath() ); + GetTraits()->GetStandardPaths().GetExecutablePath() ); return TRUE; } @@ -474,17 +479,18 @@ void WinEDA_App::SetDefaultSearchPaths( void ) wxString path = m_BinDir; #ifdef __WINDOWS__ - /* m_BinDir path is in unix notation. + /* m_BinDir path is in unix notation. * But wxFileName expect (to work fine) native notation - * specifically when using a path including a server, like \\myserver\local_path . - */ + * specifically when using a path including a server, like + * \\myserver\local_path . + */ path.Replace( UNIX_STRING_DIR_SEP, WIN_STRING_DIR_SEP ); #endif wxFileName fn( path, wxEmptyString ); - /* User environment variable path is the first search path. Chances are + /* User environment variable path is the first search path. Chances are * if the user is savvy enough to set an environment variable they know * what they are doing. */ if( ::wxGetEnv( wxT( "KICAD" ), NULL ) ) @@ -500,51 +506,85 @@ void WinEDA_App::SetDefaultSearchPaths( void ) m_searchPaths.Add( GetTraits()->GetStandardPaths().GetDataDir() ); } - /* Up on level relative to binary path with "share" appended for Windows. */ + /* Up one level relative to binary path with "share" appended for Windows. */ fn.RemoveLastDir(); m_searchPaths.Add( fn.GetPath() ); + fn.AppendDir( wxT( "share" ) ); + m_searchPaths.Add( fn.GetPath() ); + fn.AppendDir( wxT( "kicad" ) ); + m_searchPaths.Add( fn.GetPath() ); - /* Remove all non-existant paths from the list. */ + /* Remove all non-existent paths from the list. */ for( i = 0; i < m_searchPaths.GetCount(); i++ ) { wxLogDebug( wxT( "Checking if search path <" ) + - m_searchPaths[i] + wxT( "> exists." ) ); + m_searchPaths[i] + wxT( "> exists." ) ); if( !wxFileName::IsDirReadable( m_searchPaths[i] ) ) { - wxLogDebug( wxT( "Removing non-existant path <" ) + - m_searchPaths[i] + wxT( "> from search path list." ) ); + wxLogDebug( wxT( "Removing non-existent path <" ) + + m_searchPaths[i] + wxT( "> from search path list." ) ); m_searchPaths.RemoveAt( i ); i -= 1; } + else + { + /* Build schematic, PCB, and 3D module library file search path + * list based on the known existing default search paths. */ + fn.Clear(); + fn.SetPath( m_searchPaths[i] ); + fn.AppendDir( wxT( "library") ); + + wxLogDebug( wxT( "Checking if search path <%s> exists." ), + fn.GetPath().c_str() ); + + if( fn.IsDirReadable() ) + { + wxLogDebug( wxT( "Adding <%s> to library search path list" ), + fn.GetPath().c_str() ); + m_libSearchPaths.Add( fn.GetPath() ); + } + fn.RemoveLastDir(); + fn.AppendDir( wxT( "modules" ) ); + + if( fn.IsDirReadable() ) + { + wxLogDebug( wxT( "Adding <%s> to library search path list" ), + fn.GetPath().c_str() ); + m_libSearchPaths.Add( fn.GetPath() ); + } + fn.AppendDir( wxT( "packages3d" ) ); + + if( fn.IsDirReadable() ) + { + wxLogDebug( wxT( "Adding <%s> to library search path list" ), + fn.GetPath().c_str() ); + m_libSearchPaths.Add( fn.GetPath() ); + } + } } } /** * Get application settings + * * @return none */ -/*********************************/ void WinEDA_App::GetSettings() -/*********************************/ { + wxASSERT( m_EDA_Config != NULL && m_EDA_CommonConfig != NULL ); + wxString Line, entry; unsigned ii; m_HelpSize.x = 500; m_HelpSize.y = 400; - if( m_EDA_CommonConfig ) - { - m_LanguageId = m_EDA_CommonConfig->Read( wxT( "Language" ), - wxLANGUAGE_DEFAULT ); - g_EditorName = m_EDA_CommonConfig->Read( wxT( "Editor" ) ); - g_ConfigFileLocationChoice = m_EDA_CommonConfig->Read( HOTKEY_CFG_PATH_OPT, - 0L ); - } - - if( !m_EDA_Config ) - return; + m_LanguageId = m_EDA_CommonConfig->Read( wxT( "Language" ), + wxLANGUAGE_DEFAULT ); + m_EditorName = m_EDA_CommonConfig->Read( wxT( "Editor" ) ); + g_ConfigFileLocationChoice = m_EDA_CommonConfig->Read( HOTKEY_CFG_PATH_OPT, + 0L ); m_fileHistory.Load( *m_EDA_Config ); @@ -579,7 +619,7 @@ void WinEDA_App::GetSettings() g_FixedFontPointSize = m_EDA_Config->Read( wxT( "FixedFontSize" ), FONT_DEFAULT_SIZE ); - /* Sdt font type */ + /* Std font type */ Line = m_EDA_Config->Read( wxT( "SdtFontType" ), wxEmptyString ); if( !Line.IsEmpty() ) g_StdFont->SetFaceName( Line ); @@ -622,25 +662,23 @@ void WinEDA_App::GetSettings() m_EDA_Config->Read( wxT( "ShowPageLimits" ), &g_ShowPageLimits ); - if( m_EDA_Config->Read( wxT( "WorkingDir" ), &Line ) ) + if( m_EDA_Config->Read( wxT( "WorkingDir" ), &Line ) && wxDirExists( Line ) ) { - if( wxDirExists( Line ) ) - wxSetWorkingDirectory( Line ); + wxSetWorkingDirectory( Line ); } + m_EDA_Config->Read( wxT( "BgColor" ), &g_DrawBgColor ); } /** * Save application settings + * * @return none */ -/**********************************/ void WinEDA_App::SaveSettings() -/**********************************/ { - if( m_EDA_Config == NULL ) - return; + wxASSERT( m_EDA_Config != NULL ); /* Sdt font settings */ m_EDA_Config->Write( wxT( "SdtFontSize" ), g_StdFontPointSize ); @@ -662,9 +700,7 @@ void WinEDA_App::SaveSettings() /* Misc settings */ m_EDA_Config->Write( wxT( "FixedFontSize" ), g_FixedFontPointSize ); - m_EDA_Config->Write( wxT( "ShowPageLimits" ), g_ShowPageLimits ); - m_EDA_Config->Write( wxT( "WorkingDir" ), wxGetCwd() ); /* Save the file history list */ @@ -674,15 +710,14 @@ void WinEDA_App::SaveSettings() /** * Set the dictionary file name for internationalization - * the files are in kicad/internat/xx or kicad/internat/xx_XX - * and are named kicad.mo + * the files are in kicad/internat/xx or kicad/internat/xx_XX + * and are named kicad.mo * - * @param first_time must be set to true the first time this funct is called, false otherwise + * @param first_time must be set to true the first time this funct is + * called, false otherwise * @return true if the language can be set (i.e. if the locale is available) */ -/*********************************************/ bool WinEDA_App::SetLanguage( bool first_time ) -/*********************************************/ { bool retv = true; @@ -705,8 +740,10 @@ bool WinEDA_App::SetLanguage( bool first_time ) retv = false; } - if( !first_time && m_EDA_CommonConfig ) + if( !first_time ) + { m_EDA_CommonConfig->Write( wxT( "Language" ), m_LanguageId ); + } if( !m_Locale->IsLoaded( DictionaryName ) ) m_Locale->AddCatalog( DictionaryName ); @@ -718,15 +755,17 @@ bool WinEDA_App::SetLanguage( bool first_time ) } -/** Function SetLanguageIdentifier - * Set in .m_LanguageId member the wxWidgets language identifier Id - * from the kicad menu id (internal menu identifier) - * @param menu_id = the kicad menuitem id (returned by Menu Event, when clicking on a menu item) +/** + * Function SetLanguageIdentifier + * + * Set in .m_LanguageId member the wxWidgets language identifier Id from + * the kicad menu id (internal menu identifier) + * + * @param menu_id = the kicad menuitem id (returned by Menu Event, when + * clicking on a menu item) * @return none */ -/**************************************************/ void WinEDA_App::SetLanguageIdentifier( int menu_id ) -/**************************************************/ { unsigned int ii; @@ -761,21 +800,23 @@ void WinEDA_App::SetLanguagePath( void ) if( fn.DirExists() ) { wxLogDebug( wxT( "Adding locale lookup path: " ) + - fn.GetPath() ); + fn.GetPath() ); wxLocale::AddCatalogLookupPathPrefix( fn.GetPath() ); } // Append path for unix standard install fn.RemoveLastDir(); + + // Append path for unix standard install fn.AppendDir( wxT( "kicad" ) ); fn.AppendDir( wxT( "internat" ) ); + if( fn.DirExists() ) { wxLogDebug( wxT( "Adding locale lookup path: " ) + - fn.GetPath() ); + fn.GetPath() ); wxLocale::AddCatalogLookupPathPrefix( fn.GetPath() ); } - } } } @@ -783,12 +824,11 @@ void WinEDA_App::SetLanguagePath( void ) /** Function AddMenuLanguageList * Create menu list for language choice, and add it as submenu to a main menu - * @param MasterMenu : The main menu. The sub menu list will be accessible from the menu item with id ID_LANGUAGE_CHOICE + * @param MasterMenu : The main menu. The sub menu list will be accessible + * from the menu item with id ID_LANGUAGE_CHOICE * @return none */ -/*********************************************************/ void WinEDA_App::AddMenuLanguageList( wxMenu* MasterMenu ) -/*********************************************************/ { wxMenu* menu = NULL; wxMenuItem* item; @@ -855,7 +895,7 @@ wxString WinEDA_App::FindFileInSearchPaths( const wxString& filename, if( fn.DirExists() ) { wxLogDebug( _T( "Adding <" ) + fn.GetPath() + _T( "> to " ) + - _T( "file \"" ) + filename + _T( "\" search path." ) ); + _T( "file \"" ) + filename + _T( "\" search path." ) ); paths.Add( fn.GetPath() ); } } @@ -884,27 +924,28 @@ wxString WinEDA_App::GetHelpFile( void ) wxString fn; wxArrayString subdirs, altsubdirs; - /* FIXME: This is not the ideal way to handle this. Unfortunely, the + /* FIXME: This is not the ideal way to handle this. Unfortunately, the * CMake install paths seem to be a moving target so this crude * hack solve the problem of install path differences between * Windows and non-Windows platforms. */ // Partially fixed, but must be enhanced - // Create subdir tree for "standard" linux distributions, when kicad comes from a distribution - // files are in /usr/share/doc/kicad/help - // and binaries in /usr/bin or /usr/local/bin + // Create subdir tree for "standard" linux distributions, when kicad comes + // from a distribution files are in /usr/share/doc/kicad/help and binaries + // in /usr/bin or /usr/local/bin subdirs.Add( wxT( "share" ) ); subdirs.Add( _T( "doc" ) ); subdirs.Add( wxT( "kicad" ) ); subdirs.Add( _T( "help" ) ); - // Create subdir tree for linux and Windows kicad pack - // Note the pack form under linux is also useful if an user want to install kicad to a server. - // because there is only one path to mount or export (something like /usr/local/kicad). + // Create subdir tree for linux and Windows kicad pack. + // Note the pack form under linux is also useful if a user wants to + // install kicad to a server because there is only one path to mount + // or export (something like /usr/local/kicad). // files are in /kicad/doc/help // (often /usr/local/kicad/kicad/doc/help) - // /kicad/ is retrievered from m_BinDir + // /kicad/ is retrieved from m_BinDir altsubdirs.Add( _T( "doc" ) ); altsubdirs.Add( _T( "help" ) ); @@ -929,8 +970,9 @@ wxString WinEDA_App::GetHelpFile( void ) { subdirs.RemoveAt( subdirs.GetCount() - 1 ); altsubdirs.RemoveAt( altsubdirs.GetCount() - 1 ); - subdirs.Add( m_Locale->GetName().BeforeLast( '_' ) ); // GetName( ) does not return always the short name - altsubdirs.Add( m_Locale->GetName().BeforeLast( '_' ) ); // GetName( ) does not return always the short name + // wxLocale::GetName() does not return always the short name + subdirs.Add( m_Locale->GetName().BeforeLast( '_' ) ); + altsubdirs.Add( m_Locale->GetName().BeforeLast( '_' ) ); fn = FindFileInSearchPaths( m_HelpFileName, &altsubdirs ); if ( ! fn ) fn = FindFileInSearchPaths( m_HelpFileName, &subdirs ); @@ -944,8 +986,8 @@ wxString WinEDA_App::GetHelpFile( void ) subdirs.Add( _T( "en" ) ); altsubdirs.Add( _T( "en" ) ); fn = FindFileInSearchPaths( m_HelpFileName, &altsubdirs ); - if ( ! fn ) - fn = FindFileInSearchPaths( m_HelpFileName, &subdirs ); + if ( ! fn ) + fn = FindFileInSearchPaths( m_HelpFileName, &subdirs ); } return fn; @@ -968,12 +1010,12 @@ wxString WinEDA_App::GetLibraryFile( const wxString& filename ) /** - * Run init scripts - * @return the default OnRun() value (exit codes not used in kicad, so value has no special mening) + * Run Python scripts + * + * @return The default OnRun() value (exit codes not used in kicad, so value + * has no special meaning) */ -/**********************/ int WinEDA_App::OnRun() -/**********************/ { #ifdef KICAD_PYTHON PyHandler::GetInstance()->RunScripts(); diff --git a/common/gestfich.cpp b/common/gestfich.cpp index 30a8d07d96..6680a91171 100644 --- a/common/gestfich.cpp +++ b/common/gestfich.cpp @@ -175,88 +175,6 @@ wxString MakeReducedFileName( const wxString& fullfilename, } -/***************************************************************************/ -wxString MakeFileName( const wxString& dir, - const wxString& shortname, const wxString& ext ) -/***************************************************************************/ - -/** Function MakeFileName - * Calculate the full file name from dir, shortname and ext - * @param dir = path (can be empty) - * @param shortname = filename with or without path and/or extension - * @param ext = extension (can be empty) - * If shortname has an absolute path, or a path starts by ./ or ../, - * the path will not be modified - * If shortname has an extension, it will not be modified - * @return full filename - */ -{ - wxString fullfilename; - int ii; - - if( !dir.IsEmpty() ) - { - if( !wxIsAbsolutePath( shortname ) ) - { - if( !shortname.StartsWith( wxT( "./" ) ) && !shortname.StartsWith( wxT( "../" ) ) // under unix - && !shortname.StartsWith( wxT( ".\\" ) ) && !shortname.StartsWith( wxT( "..\\" ) )) // under Windows - - { /* no absolute path in shortname, add dir to shortname */ - fullfilename = dir; - } - } - } - - fullfilename += shortname; // Add shortname to dir or use shortname only - - fullfilename.Replace( WIN_STRING_DIR_SEP, UNIX_STRING_DIR_SEP ); - - /* Add an extension if shortname has no extension */ - if( ext.IsEmpty() ) - return fullfilename; - - /* search for an extension */ - ii = fullfilename.Length(); /* Get the end of name */ - for( ; ii >= 0; ii-- ) - { - if( fullfilename.GetChar( ii ) == '/' ) - { - /* not extension: add ext */ - fullfilename += ext; - break; - } - if( fullfilename.GetChar( ii ) == '.' ) /* extension exists, do nothing */ - break; - } - - return fullfilename; -} - - -/*************************************************************************/ -void ChangeFileNameExt( wxString& FullFileName, const wxString& NewExt ) -/**************************************************************************/ - -/** Function ChangeFileNameExt - * change the extension of FullFileName to NewExt. - * @param FullFileName = filename to modify - * @param NewExt = new extension for FullFileName - */ -{ - wxString FileName; - - FileName = FullFileName.BeforeLast( '.' ); - if( !FileName.IsEmpty() ) - FileName += NewExt; - else - FileName = FullFileName + NewExt; - - if( FileName.StartsWith( wxT( "\"" ) ) && ( FileName.Last() != '"' ) ) - FileName += wxT( "\"" ); - FullFileName = FileName; -} - - /*******************************************/ void AddDelimiterString( wxString& string ) /*******************************************/ @@ -504,12 +422,10 @@ wxString FindKicadFile( const wxString& shortname ) } -/***********************************************************************************/ -int ExecuteFile( wxWindow* frame, const wxString& ExecFile, const wxString& param ) -/***********************************************************************************/ - /* Call the executable file "ExecFile", with params "param" */ +int ExecuteFile( wxWindow* frame, const wxString& ExecFile, + const wxString& param ) { wxString FullFileName; @@ -525,7 +441,7 @@ int ExecuteFile( wxWindow* frame, const wxString& ExecFile, const wxString& para } wxString msg; - msg.Printf( wxT( "Command file <%s> not found" ), FullFileName.GetData() ); + msg.Printf( _( "Command <%s> could not found" ), ExecFile.c_str() ); DisplayError( frame, msg, 20 ); return -1; } @@ -653,16 +569,15 @@ wxString ReturnKicadDatasPath() } -/***************************/ -wxString GetEditorName() -/***************************/ - -/* Return the prefered editor name +/* + * Return the prefered editor name */ +wxString& WinEDA_App::GetEditorName() { - wxString editorname = g_EditorName; + wxString editorname = m_EditorName; - if( editorname.IsEmpty() ) // We get the prefered editor name from environment variable + // We get the prefered editor name from environment variable first. + if( editorname.IsEmpty() ) { wxGetEnv( wxT( "EDITOR" ), &editorname ); } @@ -674,23 +589,18 @@ wxString GetEditorName() #ifdef __WINDOWS__ mask += wxT( ".exe" ); #endif - editorname = EDA_FileSelector( _( "Prefered Editor:" ), - wxEmptyString, /* Default path */ - wxEmptyString, /* default filename */ - wxEmptyString, /* default filename extension */ - mask, /* filter for filename list */ - NULL, /* parent frame */ - wxFD_OPEN, /* wxFD_SAVE, wxFD_OPEN ..*/ - TRUE /* true = keep the current path */ - ); + editorname = EDA_FileSelector( _( "Prefered Editor:" ), wxEmptyString, + wxEmptyString, wxEmptyString, mask, + NULL, wxFD_OPEN, true ); } - if( ( !editorname.IsEmpty() ) && wxGetApp().m_EDA_CommonConfig ) + if( !editorname.IsEmpty() ) { - g_EditorName = editorname; - wxGetApp().m_EDA_CommonConfig->Write( wxT( "Editor" ), g_EditorName ); + m_EditorName = editorname; + m_EDA_CommonConfig->Write( wxT( "Editor" ), m_EditorName ); } - return g_EditorName; + + return m_EditorName; } @@ -815,3 +725,9 @@ void OpenFile( const wxString& file ) if( success && !command.IsEmpty() ) ProcessExecute( command ); } + + +wxString QuoteFullPath( wxFileName& fn, wxPathFormat format ) +{ + return wxT( "\"" ) + fn.GetFullPath() + wxT( "\"" ); +} diff --git a/common/get_component_dialog.cpp b/common/get_component_dialog.cpp index 7d455fbac0..823dd1a0b3 100644 --- a/common/get_component_dialog.cpp +++ b/common/get_component_dialog.cpp @@ -14,240 +14,267 @@ /* to select a component or a module */ /****************************************************************************/ -static unsigned s_HistoryMaxCount = 8; // Max number of items displayed in history list +static unsigned s_HistoryMaxCount = 8; // Max number of items displayed in history list static wxString s_ItemName; enum selcmp_id { - ID_ACCEPT_NAME = 3900, - ID_ACCEPT_KEYWORD, - ID_ENTER_NAME, - ID_CANCEL, - ID_LIST_ALL, - ID_EXTRA_TOOL, - ID_SEL_BY_LISTBOX + ID_ACCEPT_NAME = 3900, + ID_ACCEPT_KEYWORD, + ID_ENTER_NAME, + ID_CANCEL, + ID_LIST_ALL, + ID_EXTRA_TOOL, + ID_SEL_BY_LISTBOX }; /***************************************/ -class WinEDA_SelectCmp: public wxDialog +class WinEDA_SelectCmp : public wxDialog /***************************************/ { private: - WinEDA_DrawFrame * m_Parent; - bool m_AuxTool; - wxString * m_Text; - wxTextCtrl * m_TextCtrl; - wxListBox * m_List; + WinEDA_DrawFrame* m_Parent; + bool m_AuxTool; + wxString* m_Text; + wxTextCtrl* m_TextCtrl; + wxListBox* m_List; public: - bool m_GetExtraFunction; + bool m_GetExtraFunction; public: - // Constructor and destructor - WinEDA_SelectCmp(WinEDA_DrawFrame *parent, const wxPoint& framepos, - wxArrayString & HistoryList, const wxString & Title, - bool show_extra_tool ); - ~WinEDA_SelectCmp() {}; + // Constructor and destructor + WinEDA_SelectCmp( WinEDA_DrawFrame* parent, const wxPoint& framepos, + wxArrayString& HistoryList, const wxString& Title, + bool show_extra_tool ); + ~WinEDA_SelectCmp() {}; private: - void Accept(wxCommandEvent& event); - void GetExtraSelection(wxCommandEvent& event); - - DECLARE_EVENT_TABLE() + void Accept( wxCommandEvent& event ); + void GetExtraSelection( wxCommandEvent& event ); + DECLARE_EVENT_TABLE() }; -BEGIN_EVENT_TABLE(WinEDA_SelectCmp, wxDialog) - EVT_BUTTON(ID_ACCEPT_NAME, WinEDA_SelectCmp::Accept) - EVT_BUTTON(ID_ACCEPT_KEYWORD, WinEDA_SelectCmp::Accept) - EVT_BUTTON(ID_CANCEL, WinEDA_SelectCmp::Accept) - EVT_BUTTON(ID_LIST_ALL, WinEDA_SelectCmp::Accept) - EVT_BUTTON(ID_EXTRA_TOOL, WinEDA_SelectCmp::GetExtraSelection) - EVT_LISTBOX(ID_SEL_BY_LISTBOX, WinEDA_SelectCmp::Accept) + +BEGIN_EVENT_TABLE( WinEDA_SelectCmp, wxDialog ) + EVT_BUTTON( ID_ACCEPT_NAME, WinEDA_SelectCmp::Accept ) + EVT_BUTTON( ID_ACCEPT_KEYWORD, WinEDA_SelectCmp::Accept ) + EVT_BUTTON( ID_CANCEL, WinEDA_SelectCmp::Accept ) + EVT_BUTTON( ID_LIST_ALL, WinEDA_SelectCmp::Accept ) + EVT_BUTTON( ID_EXTRA_TOOL, WinEDA_SelectCmp::GetExtraSelection ) + EVT_LISTBOX( ID_SEL_BY_LISTBOX, WinEDA_SelectCmp::Accept ) END_EVENT_TABLE() /****************************************************************************/ -WinEDA_SelectCmp::WinEDA_SelectCmp(WinEDA_DrawFrame *parent, const wxPoint& framepos, - wxArrayString & HistoryList, const wxString & Title, - bool show_extra_tool ): - wxDialog(parent, -1, Title, framepos, - wxDefaultSize, DIALOG_STYLE) +WinEDA_SelectCmp::WinEDA_SelectCmp( WinEDA_DrawFrame* parent, + const wxPoint& framepos, + wxArrayString& HistoryList, + const wxString& Title, + bool show_extra_tool ) : + wxDialog( parent, -1, Title, framepos, wxDefaultSize, DIALOG_STYLE ) /****************************************************************************/ + /* Dialog frame to choose a component or a footprint - This dialog shows an history of last selected items -*/ + * This dialog shows an history of last selected items + */ { -wxButton * Button; -wxStaticText * Text; - - m_Parent = parent; - m_AuxTool = show_extra_tool; - m_GetExtraFunction = FALSE; - - SetFont(*g_DialogFont); - s_ItemName.Empty(); - m_Text = & s_ItemName; - - wxBoxSizer* MainBoxSizer = new wxBoxSizer(wxHORIZONTAL); - SetSizer(MainBoxSizer); + wxButton* Button; + wxStaticText* Text; - wxBoxSizer* LeftBoxSizer = new wxBoxSizer(wxVERTICAL); - MainBoxSizer->Add(LeftBoxSizer, 0, wxALIGN_CENTER_HORIZONTAL|wxALL|wxADJUST_MINSIZE, 5); - wxBoxSizer* RightBoxSizer = new wxBoxSizer(wxVERTICAL); - MainBoxSizer->Add(RightBoxSizer, 0, wxALIGN_CENTER_HORIZONTAL|wxALL, 5); - - Text = new wxStaticText(this, -1, _("Name:")); - LeftBoxSizer->Add(Text, 0, wxALIGN_LEFT|wxLEFT|wxRIGHT|wxTOP, 5); - - m_TextCtrl = new wxTextCtrl(this, ID_ENTER_NAME, *m_Text); - m_TextCtrl->SetInsertionPoint(1); - LeftBoxSizer->Add(m_TextCtrl, 0, wxGROW|wxLEFT|wxRIGHT|wxBOTTOM|wxADJUST_MINSIZE, 5); - - Text = new wxStaticText(this, -1, _("History list:")); - LeftBoxSizer->Add(Text, 0, wxALIGN_LEFT|wxLEFT|wxRIGHT|wxTOP, 5); + m_Parent = parent; + m_AuxTool = show_extra_tool; + m_GetExtraFunction = FALSE; - m_List = new wxListBox(this, ID_SEL_BY_LISTBOX, wxDefaultPosition, - wxSize(220, -1), HistoryList, wxLB_SINGLE ); - LeftBoxSizer->Add(m_List, 0, wxGROW|wxLEFT|wxRIGHT|wxBOTTOM|wxADJUST_MINSIZE, 5); - - Button = new wxButton(this, ID_ACCEPT_NAME, _("OK")); - Button->SetForegroundColour(*wxRED); - Button->SetDefault(); - RightBoxSizer->Add(Button, 0, wxGROW|wxLEFT|wxRIGHT|wxTOP|wxBOTTOM, 5); + SetFont( *g_DialogFont ); + s_ItemName.Empty(); + m_Text = &s_ItemName; - Button = new wxButton(this, ID_ACCEPT_KEYWORD, _("Search KeyWord")); - Button->SetForegroundColour(*wxRED); - RightBoxSizer->Add(Button, 0, wxGROW|wxLEFT|wxRIGHT|wxBOTTOM, 5); + wxBoxSizer* MainBoxSizer = new wxBoxSizer( wxHORIZONTAL ); + SetSizer( MainBoxSizer ); - Button = new wxButton(this, ID_CANCEL, _("Cancel")); - Button->SetForegroundColour(*wxBLUE); - RightBoxSizer->Add(Button, 0, wxGROW|wxLEFT|wxRIGHT|wxBOTTOM, 5); + wxBoxSizer* LeftBoxSizer = new wxBoxSizer( wxVERTICAL ); + MainBoxSizer->Add( LeftBoxSizer, + 0, + wxALIGN_CENTER_HORIZONTAL | wxALL | wxADJUST_MINSIZE, + 5 ); + wxBoxSizer* RightBoxSizer = new wxBoxSizer( wxVERTICAL ); + MainBoxSizer->Add( RightBoxSizer, 0, wxALIGN_CENTER_HORIZONTAL | wxALL, 5 ); - Button = new wxButton(this, ID_LIST_ALL, _("List All")); - Button->SetForegroundColour(wxColor(0, 80, 0)); - RightBoxSizer->Add(Button, 0, wxGROW|wxLEFT|wxRIGHT|wxBOTTOM, 5); + Text = new wxStaticText( this, -1, _( "Name:" ) ); + LeftBoxSizer->Add( Text, 0, wxALIGN_LEFT | wxLEFT | wxRIGHT | wxTOP, 5 ); + + m_TextCtrl = new wxTextCtrl( this, ID_ENTER_NAME, *m_Text ); + m_TextCtrl->SetInsertionPoint( 1 ); + LeftBoxSizer->Add( m_TextCtrl, + 0, + wxGROW | wxLEFT | wxRIGHT | wxBOTTOM | wxADJUST_MINSIZE, + 5 ); + + Text = new wxStaticText( this, -1, _( "History list:" ) ); + LeftBoxSizer->Add( Text, 0, wxALIGN_LEFT | wxLEFT | wxRIGHT | wxTOP, 5 ); + + m_List = new wxListBox( this, ID_SEL_BY_LISTBOX, wxDefaultPosition, + wxSize( 220, -1 ), HistoryList, wxLB_SINGLE ); + LeftBoxSizer->Add( m_List, + 0, + wxGROW | wxLEFT | wxRIGHT | wxBOTTOM | wxADJUST_MINSIZE, + 5 ); + + Button = new wxButton( this, ID_ACCEPT_NAME, _( "OK" ) ); + Button->SetForegroundColour( *wxRED ); + Button->SetDefault(); + RightBoxSizer->Add( Button, + 0, + wxGROW | wxLEFT | wxRIGHT | wxTOP | wxBOTTOM, + 5 ); + + Button = new wxButton( this, ID_ACCEPT_KEYWORD, _( "Search KeyWord" ) ); + Button->SetForegroundColour( *wxRED ); + RightBoxSizer->Add( Button, 0, wxGROW | wxLEFT | wxRIGHT | wxBOTTOM, 5 ); + + Button = new wxButton( this, ID_CANCEL, _( "Cancel" ) ); + Button->SetForegroundColour( *wxBLUE ); + RightBoxSizer->Add( Button, 0, wxGROW | wxLEFT | wxRIGHT | wxBOTTOM, 5 ); + + Button = new wxButton( this, ID_LIST_ALL, _( "List All" ) ); + Button->SetForegroundColour( wxColor( 0, 80, 0 ) ); + RightBoxSizer->Add( Button, 0, wxGROW | wxLEFT | wxRIGHT | wxBOTTOM, 5 ); #ifndef __WXMAC__ - if ( m_AuxTool ) /* The selection can be done by an extra function */ - { - - Button = new wxButton(this, ID_EXTRA_TOOL, _("By Lib Browser")); - Button->SetForegroundColour(wxColor(0, 0, 0)); // Listbox Color - RightBoxSizer->Add(Button, 0, wxGROW|wxLEFT|wxRIGHT|wxBOTTOM, 5); - } -#endif + if( m_AuxTool ) /* The selection can be done by an extra function */ + { + Button = new wxButton( this, ID_EXTRA_TOOL, _( "By Lib Browser" ) ); + Button->SetForegroundColour( wxColor( 0, 0, 0 ) ); // Listbox Color + RightBoxSizer->Add( Button, 0, wxGROW | wxLEFT | wxRIGHT | wxBOTTOM, 5 ); + } +#endif - GetSizer()->Fit(this); - GetSizer()->SetSizeHints(this); + GetSizer()->Fit( this ); + GetSizer()->SetSizeHints( this ); } + /*********************************************************/ -void WinEDA_SelectCmp::Accept(wxCommandEvent& event) +void WinEDA_SelectCmp::Accept( wxCommandEvent& event ) /*********************************************************/ { - switch (event.GetId() ) - { - case ID_SEL_BY_LISTBOX: - *m_Text = m_List->GetStringSelection(); - break; + switch( event.GetId() ) + { + case ID_SEL_BY_LISTBOX: + *m_Text = m_List->GetStringSelection(); + break; - case ID_ACCEPT_NAME: - *m_Text = m_TextCtrl->GetValue(); - break; + case ID_ACCEPT_NAME: + *m_Text = m_TextCtrl->GetValue(); + break; - case ID_ACCEPT_KEYWORD: - *m_Text = wxT("= ") + m_TextCtrl->GetValue(); - break; + case ID_ACCEPT_KEYWORD: + *m_Text = wxT( "= " ) + m_TextCtrl->GetValue(); + break; - case ID_CANCEL: - *m_Text = wxEmptyString; - break; - - case ID_LIST_ALL: - *m_Text = wxT("*"); - break; - - } - m_Text->Trim(FALSE); // Remove blanks at beginning - m_Text->Trim(TRUE); // Remove blanks at end - Close(TRUE); + case ID_CANCEL: + *m_Text = wxEmptyString; + break; + + case ID_LIST_ALL: + *m_Text = wxT( "*" ); + break; + } + + m_Text->Trim( FALSE ); // Remove blanks at beginning + m_Text->Trim( TRUE ); // Remove blanks at end + Close( TRUE ); } /**************************************************************/ -void WinEDA_SelectCmp::GetExtraSelection(wxCommandEvent& event) +void WinEDA_SelectCmp::GetExtraSelection( wxCommandEvent& event ) /**************************************************************/ + /* Get the component name by the extra function -*/ + */ { - m_GetExtraFunction = TRUE; - Close(TRUE); + m_GetExtraFunction = TRUE; + Close( TRUE ); } - /******************************************************************************/ -wxString GetComponentName(WinEDA_DrawFrame * frame, - wxArrayString & HistoryList, const wxString & Title, - wxString(*AuxTool)(WinEDA_DrawFrame *parent)) +wxString GetComponentName( WinEDA_DrawFrame* frame, + wxArrayString& HistoryList, const wxString& Title, + wxString (*AuxTool)( WinEDA_DrawFrame* parent ) ) /*******************************************************************************/ + /* Dialog frame to choose a component name -*/ + */ { -wxPoint framepos; -int x, y, w, h; -bool GetExtraFunction; - - framepos = wxGetMousePosition(); - wxClientDisplayRect(&x, &y, &w, &h); - framepos.x -= 100; framepos.y -= 50; - if ( framepos.x < x ) framepos.x = x; - if ( framepos.y < y ) framepos.y = y; - if ( framepos.x < x ) framepos.x = x; - x += w -350; if ( framepos.x > x ) framepos.x = x; - if ( framepos.y < y ) framepos.y = y; -WinEDA_SelectCmp * selframe = - new WinEDA_SelectCmp(frame, framepos, HistoryList, Title, AuxTool ? TRUE : FALSE); - selframe->ShowModal(); - GetExtraFunction = selframe->m_GetExtraFunction; - selframe->Destroy(); - - if ( GetExtraFunction ) s_ItemName = AuxTool(frame); - return s_ItemName; + wxPoint framepos; + int x, y, w, h; + bool GetExtraFunction; + + framepos = wxGetMousePosition(); + wxClientDisplayRect( &x, &y, &w, &h ); + framepos.x -= 100; + framepos.y -= 50; + if( framepos.x < x ) + framepos.x = x; + if( framepos.y < y ) + framepos.y = y; + if( framepos.x < x ) + framepos.x = x; + x += w - 350; + if( framepos.x > x ) + framepos.x = x; + if( framepos.y < y ) + framepos.y = y; + WinEDA_SelectCmp* selframe = + new WinEDA_SelectCmp( frame, framepos, HistoryList, Title, + AuxTool ? TRUE : FALSE ); + selframe->ShowModal(); + GetExtraFunction = selframe->m_GetExtraFunction; + selframe->Destroy(); + + if( GetExtraFunction ) + s_ItemName = AuxTool( frame ); + return s_ItemName; } /*******************************************************************************/ -void AddHistoryComponentName(wxArrayString & HistoryList, const wxString & Name) +void AddHistoryComponentName( wxArrayString& HistoryList, const wxString& Name ) /*******************************************************************************/ + /* Add the string "Name" to the history list HistoryList -*/ + */ { -int ii, c_max; + int ii, c_max; - if ( HistoryList.GetCount() > 0) - { - if (Name == HistoryList[0] ) return; - - /* remove an old identical selection if exists */ - for ( ii = 1; (unsigned)ii < HistoryList.GetCount(); ii ++ ) - { - if ( Name == HistoryList[ii] ) - { - HistoryList.RemoveAt(ii); ii--; - } - } - - /* shift the list */ - if ( HistoryList.GetCount() < s_HistoryMaxCount ) - HistoryList.Add(wxT("")); - - c_max = HistoryList.GetCount() - 2; - for ( ii = c_max; ii >= 0 ; ii -- ) HistoryList[ii+1] = HistoryList[ii]; - - /* Add the new name at the beginning of the history list */ - HistoryList[0] = Name; - } - else - HistoryList.Add(Name); + if( HistoryList.GetCount() > 0 ) + { + if( Name == HistoryList[0] ) + return; + + /* remove an old identical selection if exists */ + for( ii = 1; (unsigned) ii < HistoryList.GetCount(); ii++ ) + { + if( Name == HistoryList[ii] ) + { + HistoryList.RemoveAt( ii ); ii--; + } + } + + /* shift the list */ + if( HistoryList.GetCount() < s_HistoryMaxCount ) + HistoryList.Add( wxT( "" ) ); + + c_max = HistoryList.GetCount() - 2; + for( ii = c_max; ii >= 0; ii-- ) + HistoryList[ii + 1] = HistoryList[ii]; + + /* Add the new name at the beginning of the history list */ + HistoryList[0] = Name; + } + else + HistoryList.Add( Name ); } diff --git a/common/gr_basic.cpp b/common/gr_basic.cpp index 6fcee097a0..10ec2c6263 100644 --- a/common/gr_basic.cpp +++ b/common/gr_basic.cpp @@ -31,6 +31,14 @@ * and remember users can have old versions with bugs */ +/* variables generales */ + +// pour les tracés en mode XOR = GR_XOR ou GR_NXOR selon couleur de fond +int g_XorMode = GR_NXOR; +// couleur de fond de la frame de dessin +int g_DrawBgColor = WHITE; + + #define USE_CLIP_FILLED_POLYGONS #ifdef USE_CLIP_FILLED_POLYGONS @@ -1480,21 +1488,17 @@ void GRSetTextFgColor( wxDC* DC, int Color ) /*********************************************************/ /* Set the foreground color used to draw texts */ { - DC->SetTextForeground( wxColour( - ColorRefs[Color].m_Red, - ColorRefs[Color].m_Green, - ColorRefs[Color].m_Blue ) - ); + DC->SetTextForeground( wxColour( ColorRefs[Color].m_Red, + ColorRefs[Color].m_Green, + ColorRefs[Color].m_Blue ) ); } void GRSetTextFgColor( wxDC* DC, wxFont*, int Color ) { - DC->SetTextForeground( wxColour( - ColorRefs[Color].m_Red, - ColorRefs[Color].m_Green, - ColorRefs[Color].m_Blue ) - ); + DC->SetTextForeground( wxColour( ColorRefs[Color].m_Red, + ColorRefs[Color].m_Green, + ColorRefs[Color].m_Blue ) ); } @@ -1533,22 +1537,18 @@ void GRSetTextBgColor( wxDC* DC, int Color ) /* Set the background color used to draw texts */ { Color &= MASKCOLOR; // keep only the bits used to select the color - DC->SetTextBackground( wxColour( - ColorRefs[Color].m_Red, - ColorRefs[Color].m_Green, - ColorRefs[Color].m_Blue ) - ); + DC->SetTextBackground( wxColour( ColorRefs[Color].m_Red, + ColorRefs[Color].m_Green, + ColorRefs[Color].m_Blue ) ); } void GRSetTextBgColor( wxDC* DC, wxFont*, int Color ) { Color &= MASKCOLOR; // keep only the bits used to select the color - DC->SetTextBackground( wxColour( - ColorRefs[Color].m_Red, - ColorRefs[Color].m_Green, - ColorRefs[Color].m_Blue ) - ); + DC->SetTextBackground( wxColour( ColorRefs[Color].m_Red, + ColorRefs[Color].m_Green, + ColorRefs[Color].m_Blue ) ); } #ifdef USE_CLIP_FILLED_POLYGONS diff --git a/common/hotkeys_basic.cpp b/common/hotkeys_basic.cpp index 65771de1d6..29bfe68b47 100644 --- a/common/hotkeys_basic.cpp +++ b/common/hotkeys_basic.cpp @@ -18,6 +18,19 @@ #include "wxstruct.h" +wxString g_CommonSectionTag( wxT( "[common]" ) ); +wxString g_SchematicSectionTag( wxT( "[eeschema]" ) ); +wxString g_LibEditSectionTag( wxT( "[libedit]" ) ); +wxString g_BoardEditorSectionTag( wxT( "[pcbnew]" ) ); +wxString g_ModuleEditSectionTag( wxT( "[footprinteditor]" ) ); + +/* 0 = files are in Home directory (usefull under unix) + * 1 = kicad/template ( usefull only under windows ) + * 2 ... = unused + */ +int g_ConfigFileLocationChoice; + + /* Class to handle hotkey commnands. hotkeys have a default value * This class allows the real key code changed by user from a key code list file */ @@ -618,8 +631,7 @@ void AddHotkeyConfigMenu( wxMenu* menu ) item = new wxMenuItem( menu, ID_PREFERENCES_HOTKEY_SHOW_CURRENT_LIST, _( "Show Current Hotkey List" ), - _( "Show the current hotkey config" ) - ); + _( "Show the current hotkey config" ) ); item->SetBitmap( info_xpm ); menu->Append( item ); @@ -631,8 +643,8 @@ void AddHotkeyConfigMenu( wxMenu* menu ) menu->Append( item ); item = new wxMenuItem( menu, ID_PREFERENCES_READ_CONFIG_HOTKEYS, - _( "Reread Hotkey config file" ), - _( "Reread the hotkey config file" ) ); + _( "Reread Hotkey config file" ), + _( "Reread the hotkey config file" ) ); item->SetBitmap( reload_xpm ); menu->Append( item ); item = new wxMenuItem( menu, ID_PREFERENCES_EDIT_CONFIG_HOTKEYS, @@ -654,12 +666,11 @@ void AddHotkeyConfigMenu( wxMenu* menu ) wxITEM_CHECK ); submenu_hkcfg->Append( item ); - ADD_MENUITEM_WITH_HELP_AND_SUBMENU( menu, submenu_hkcfg, - -1, + ADD_MENUITEM_WITH_HELP_AND_SUBMENU( menu, submenu_hkcfg, -1, _( "Hotkey config location" ), - _( - "Hotkey config file location selection (home directory or kicad tree)" ), - right_xpm ); + _( "Hotkey config file location " \ + "selection (home directory or " \ + "kicad tree)" ), right_xpm ); submenu_hkcfg->Check( ID_PREFERENCES_HOTKEY_PATH_IS_HOME, g_ConfigFileLocationChoice == 0 ); submenu_hkcfg->Check( ID_PREFERENCES_HOTKEY_PATH_IS_KICAD, @@ -678,8 +689,8 @@ void HandleHotkeyConfigMenuSelection( WinEDA_DrawFrame* frame, int id ) */ { wxMenuBar* menu = frame->GetMenuBar(); - wxConfig * config = wxGetApp().m_EDA_CommonConfig; - wxASSERT( config != NULL ); + + wxConfig* config = wxGetApp().m_EDA_CommonConfig; switch( id ) { diff --git a/common/pcbcommon.cpp b/common/pcbcommon.cpp new file mode 100644 index 0000000000..026f38a301 --- /dev/null +++ b/common/pcbcommon.cpp @@ -0,0 +1,144 @@ +/* + * This program source code file is part of KICAD, a free EDA CAD application. + * + * Copyright (C) 2008 Wayne Stambaugh + * Copyright (C) 1992-2008 Kicad Developers, see change_log.txt for contributors. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, you may find one here: + * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html + * or you may search the http://www.gnu.org website for the version 2 license, + * or you may write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA + */ + +/* + * This file contains the global constants and variables used in the PCB + * applications PCBNEW, CvPcb, and GervView. The goal of this was to + * unobfuscate the original header file design that made it very difficult + * to figure out where these variables lived. Ideally, they should be pushed + * back into the application layer. + */ + +#include "fctsys.h" +#include "pcbcommon.h" +#include "plot_common.h" +#include "class_zone_setting.h" + + +/* Look up Table for conversion one layer number -> one bit layer mask: */ +int g_TabOneLayerMask[LAYER_COUNT] = { + 0x00000001, 0x00000002, 0x00000004, 0x00000008, + 0x00000010, 0x00000020, 0x00000040, 0x00000080, + 0x00000100, 0x00000200, 0x00000400, 0x00000800, + 0x00001000, 0x00002000, 0x00004000, 0x00008000, + 0x00010000, 0x00020000, 0x00040000, 0x00080000, + 0x00100000, 0x00200000, 0x00400000, 0x00800000, + 0x01000000, 0x02000000, 0x04000000, 0x08000000, + 0x10000000, 0x20000000, 0x40000000, 0x80000000 +}; + +/* Look up Table for conversion copper layer count -> general copper layer + * mask: */ +int g_TabAllCopperLayerMask[NB_COPPER_LAYERS] = { + 0x0001, 0x8001, 0x8003, 0x8007, + 0x800F, 0x801F, 0x803F, 0x807F, + 0x80FF, 0x81FF, 0x83FF, 0x87FF, + 0x8FFF, 0x9FFF, 0xCFFF, 0xFFFF +}; + +wxString g_ViaType_Name[4] = { + _( "??? Via" ), // Not used yet + _( "Micro Via" ), // from external layer (TOP or BOTTOM) from the near neightbour inner layer only + _( "Blind/Buried Via" ), // from inner or external to inner or external layer (no restriction) + _( "Through Via" ) // Usual via (from TOP to BOTTOM layer only ) +}; + + +wxArrayString g_LibName_List; // library list to load + +BOARD_ITEM* g_UnDeleteStack[UNDELETE_STACK_SIZE]; // Linked list of deleted items +int g_UnDeleteStackPtr; +bool g_ShowGrid = true; + +DISPLAY_OPTIONS DisplayOpt; /* Display options for board items */ + +/* PCB file name extension definitions. */ +wxString PcbExtBuffer( wxT( "brd" ) ); +wxString g_SaveFileName( wxT( "$savepcb" ) ); +wxString NetExtBuffer( wxT( "net" ) ); +wxString NetCmpExtBuffer( wxT( "cmp" ) ); +wxString g_Shapes3DExtBuffer( wxT( "wrl" ) ); +const wxString ModuleFileExtension( wxT( "mod" ) ); + +/* PCB file name wild card definitions. */ +const wxString ModuleFileWildcard( _( "Kicad footprint library files " \ + "(*.mod)|*.mod") ); + +int g_CurrentVersionPCB = 1; + +/* variables generales */ +int g_TimeOut; // Timer for automatic saving +int g_SaveTime; // Time for next saving + +int g_AnchorColor = BLUE; +int g_ModuleTextCMPColor = LIGHTGRAY; +int g_ModuleTextCUColor = MAGENTA; +int g_ModuleTextNOVColor = DARKGRAY; +int g_PadCUColor = GREEN; +int g_PadCMPColor = RED; + +// Current designe settings: +class EDA_BoardDesignSettings g_DesignSettings; + +/** + * Used in track creation, a list of track segments currently being created, + * with the newest track at the end of the list, sorted by new-ness. e.g. use + * TRACK->Back() to get the next older track, TRACK->Next() to get the next + * newer track. + */ +DLIST g_CurrentTrackList; + +PCB_SCREEN* ScreenPcb = NULL; +BOARD* g_ModuleEditor_Pcb = NULL; + +int g_GridRoutingSize = 250; + +bool g_Zone_45_Only = FALSE; + +/* HPGL plot settings. */ +int g_HPGL_Pen_Num = 1; /* num de plume a charger */ +int g_HPGL_Pen_Speed = 40; /* vitesse en cm/s */ +int g_HPGL_Pen_Diam; /* diametre en mils */ +int g_HPGL_Pen_Recouvrement; /* recouvrement en mils ( pour remplissages */ + +float Scale_X; +float Scale_Y; /* coeff d'agrandissement en X et Y demandes */ + +int PlotMarge; +int g_PlotLine_Width; +int g_PlotFormat = PLOT_FORMAT_GERBER; +int g_PlotOrient; + +wxPoint g_PlotOffset; + +FILE* dest = NULL; + +/* id for plot format (see enum PlotFormat in plot_common.h) */ +int g_PlotScaleOpt; +int g_DrillShapeOpt; + +// Default setting used when creating a new zone +ZONE_SETTING g_Zone_Default_Setting; + +D_PAD g_Pad_Master( (MODULE*) NULL ); diff --git a/common/projet_config.cpp b/common/projet_config.cpp index 8cd7047c6f..bb5eb10ec5 100644 --- a/common/projet_config.cpp +++ b/common/projet_config.cpp @@ -8,20 +8,17 @@ #include "common.h" #include "kicad_string.h" #include "gestfich.h" +#include "wxstruct.h" #include "param_config.h" + #define CONFIG_VERSION 1 #define FORCE_LOCAL_CONFIG true -/*********************************************************************/ -static bool ReCreatePrjConfig( const wxString& local_config_filename, - const wxString& GroupName, - bool ForceUseLocalConfig ) -/*********************************************************************/ - -/* Cree ou recree la configuration locale de kicad (filename.pro) +/** + * Cree ou recree la configuration locale de kicad (filename.pro) * initialise: * g_Prj_Config * g_Prj_Config_LocalFilename @@ -30,111 +27,126 @@ static bool ReCreatePrjConfig( const wxString& local_config_filename, * true si config locale * false si default config */ +bool WinEDA_App::ReCreatePrjConfig( const wxString& fileName, + const wxString& GroupName, + bool ForceUseLocalConfig ) { - // free old config - if( g_Prj_Config ) - delete g_Prj_Config; - g_Prj_Config = NULL; + wxFileName fn = fileName; + wxString defaultFileName; - // Init local Config filename - if( local_config_filename.IsEmpty() ) - g_Prj_Config_LocalFilename = wxT( "kicad" ); - else - g_Prj_Config_LocalFilename = local_config_filename; + // Free old config file. + if( m_ProjectConfig ) + { + delete m_ProjectConfig; + m_ProjectConfig = NULL; + } - ChangeFileNameExt( g_Prj_Config_LocalFilename, g_Prj_Config_Filename_ext ); + /* Check just in case the file name does not a kicad project extension. */ + if( fn.GetExt() != ProjectFileExtension ) + { + wxLogDebug( _( "ReCreatePrjConfig() called with project file <%s> " \ + "which does not have the correct file extension." ), + fn.GetFullPath().c_str() ); + fn.SetExt( ProjectFileExtension ); + } + + /* Update the library search path list if a new project file is loaded. */ + if( m_projectFileName != fn ) + { + if( m_libSearchPaths.Index( fn.GetPath() ) != wxNOT_FOUND ) + m_libSearchPaths.Remove( fn.GetPath() ); + + m_libSearchPaths.Insert( fn.GetPath(), 0 ); + m_projectFileName = fn; + } // Init local config filename - if( ForceUseLocalConfig || wxFileExists( g_Prj_Config_LocalFilename ) ) + if( ForceUseLocalConfig || fn.FileExists() ) { - g_Prj_Default_Config_FullFilename.Empty(); - g_Prj_Config = new wxFileConfig( wxEmptyString, - wxEmptyString, - g_Prj_Config_LocalFilename, - wxEmptyString, - wxCONFIG_USE_RELATIVE_PATH ); - - g_Prj_Config->DontCreateOnDemand(); + m_ProjectConfig = new wxFileConfig( wxEmptyString, wxEmptyString, + fn.GetFullPath(), wxEmptyString ); + m_ProjectConfig->DontCreateOnDemand(); if( ForceUseLocalConfig ) return true; - // Test de la bonne version du fichier (ou groupe) de configuration - int version = -1, def_version = 0; - g_Prj_Config->SetPath( GroupName ); - version = g_Prj_Config->Read( wxT( "version" ), def_version ); - g_Prj_Config->SetPath( UNIX_STRING_DIR_SEP ); + /* Check the application version against the version saved in the + * project file. + * + * TODO: Push the version test up the stack so that when one of the + * Kicad application version changes, the other applications + * settings do not get updated. Practically, this can go away. + * It isn't used anywhere as far as I know (WLS). + */ + int version = -1; + int def_version = 0; + + m_ProjectConfig->SetPath( GroupName ); + version = m_ProjectConfig->Read( wxT( "version" ), def_version ); + m_ProjectConfig->SetPath( wxCONFIG_PATH_SEPARATOR ); + if( version > 0 ) return true; else - delete g_Prj_Config; // Version incorrecte + { + delete m_ProjectConfig; // Version incorrecte + } } - // Fichier local non trouve ou invalide - g_Prj_Config_LocalFilename.Empty(); - g_Prj_Default_Config_FullFilename = - ReturnKicadDatasPath() + - wxT( "template/kicad" ) + - g_Prj_Config_Filename_ext; + defaultFileName = ReturnKicadDatasPath() + wxT( "template/kicad" ) + + wxT( "." ) + ProjectFileExtension; - // Recreate new config - g_Prj_Config = new wxFileConfig( wxEmptyString, - wxEmptyString, - wxEmptyString, - g_Prj_Default_Config_FullFilename, - wxCONFIG_USE_RELATIVE_PATH ); - - g_Prj_Config->DontCreateOnDemand(); + // Create new project file using the default name. + m_ProjectConfig = new wxFileConfig( wxEmptyString, wxEmptyString, + wxEmptyString, defaultFileName ); + m_ProjectConfig->DontCreateOnDemand(); return false; } -/***************************************************************************************/ -void WinEDA_App::WriteProjectConfig( const wxString& local_config_filename, - const wxString& GroupName, - PARAM_CFG_BASE** List ) -/***************************************************************************************/ - -/** Function WriteProjectConfig +/** + * Function WriteProjectConfig * Save the current "projet" parameters * saved parameters are parameters that have the .m_Setup member set to false * saving file is the .pro file project */ +void WinEDA_App::WriteProjectConfig( const wxString& fileName, + const wxString& GroupName, + PARAM_CFG_BASE** List ) { PARAM_CFG_BASE* pt_cfg; wxString msg; - ReCreatePrjConfig( local_config_filename, GroupName, - FORCE_LOCAL_CONFIG ); + ReCreatePrjConfig( fileName, GroupName, FORCE_LOCAL_CONFIG ); /* Write date ( surtout pour eviter bug de wxFileConfig * qui se trompe de rubrique si declaration [xx] en premiere ligne * (en fait si groupe vide) */ - g_Prj_Config->SetPath( UNIX_STRING_DIR_SEP ); + m_ProjectConfig->SetPath( wxCONFIG_PATH_SEPARATOR ); + msg = DateAndTime(); + m_ProjectConfig->Write( wxT( "update" ), msg ); - g_Prj_Config->Write( wxT( "update" ), msg ); msg = GetAppName(); - - g_Prj_Config->Write( wxT( "last_client" ), msg ); + m_ProjectConfig->Write( wxT( "last_client" ), msg ); /* Save parameters */ - g_Prj_Config->DeleteGroup( GroupName ); // Erase all datas - g_Prj_Config->Flush(); + m_ProjectConfig->DeleteGroup( GroupName ); // Erase all datas + m_ProjectConfig->Flush(); - g_Prj_Config->SetPath( GroupName ); - g_Prj_Config->Write( wxT( "version" ), CONFIG_VERSION ); - g_Prj_Config->SetPath( UNIX_STRING_DIR_SEP ); + m_ProjectConfig->SetPath( GroupName ); + m_ProjectConfig->Write( wxT( "version" ), CONFIG_VERSION ); + m_ProjectConfig->SetPath( wxCONFIG_PATH_SEPARATOR ); - for( ; *List != NULL; List++ ) + for( ; List != NULL && *List != NULL; List++ ) { pt_cfg = *List; if( pt_cfg->m_Group ) - g_Prj_Config->SetPath( pt_cfg->m_Group ); + m_ProjectConfig->SetPath( pt_cfg->m_Group ); else - g_Prj_Config->SetPath( GroupName ); + m_ProjectConfig->SetPath( GroupName ); if( pt_cfg->m_Setup ) continue; @@ -142,18 +154,17 @@ void WinEDA_App::WriteProjectConfig( const wxString& local_config_filename, if ( pt_cfg->m_Type == PARAM_COMMAND_ERASE ) // Erase all data { if( pt_cfg->m_Ident ) - g_Prj_Config->DeleteGroup( pt_cfg->m_Ident ); + m_ProjectConfig->DeleteGroup( pt_cfg->m_Ident ); } else - pt_cfg->SaveParam( g_Prj_Config ); + pt_cfg->SaveParam( m_ProjectConfig ); } - g_Prj_Config->SetPath( UNIX_STRING_DIR_SEP ); - delete g_Prj_Config; - g_Prj_Config = NULL; + m_ProjectConfig->SetPath( UNIX_STRING_DIR_SEP ); + delete m_ProjectConfig; + m_ProjectConfig = NULL; } - /*****************************************************************/ void WinEDA_App::SaveCurrentSetupValues( PARAM_CFG_BASE** aList ) /*****************************************************************/ @@ -187,13 +198,6 @@ void WinEDA_App::SaveCurrentSetupValues( PARAM_CFG_BASE** aList ) } -/***************************************************************************************/ -bool WinEDA_App::ReadProjectConfig( const wxString& local_config_filename, - const wxString& GroupName, - PARAM_CFG_BASE** List, - bool Load_Only_if_New ) -/***************************************************************************************/ - /** Function ReadProjectConfig * Read the current "projet" parameters * Parameters are parameters that have the .m_Setup member set to false @@ -207,52 +211,53 @@ bool WinEDA_App::ReadProjectConfig( const wxString& local_config_filename, * wxGetApp().m_CurrentOptionFileDateAndTime * wxGetApp().m_CurrentOptionFile */ +bool WinEDA_App::ReadProjectConfig( const wxString& local_config_filename, + const wxString& GroupName, + PARAM_CFG_BASE** List, + bool Load_Only_if_New ) { PARAM_CFG_BASE* pt_cfg; wxString timestamp; - if( List == NULL ) - return false; - ReCreatePrjConfig( local_config_filename, GroupName, false ); - g_Prj_Config->SetPath( UNIX_STRING_DIR_SEP ); - timestamp = g_Prj_Config->Read( wxT( "update" ) ); + m_ProjectConfig->SetPath( wxCONFIG_PATH_SEPARATOR ); + timestamp = m_ProjectConfig->Read( wxT( "update" ) ); if( Load_Only_if_New && ( !timestamp.IsEmpty() ) - && (timestamp == wxGetApp().m_CurrentOptionFileDateAndTime) ) + && (timestamp == m_CurrentOptionFileDateAndTime) ) { return false; } - wxGetApp().m_CurrentOptionFileDateAndTime = timestamp; + m_CurrentOptionFileDateAndTime = timestamp; if( !g_Prj_Default_Config_FullFilename.IsEmpty() ) - wxGetApp().m_CurrentOptionFile = g_Prj_Default_Config_FullFilename; + m_CurrentOptionFile = g_Prj_Default_Config_FullFilename; else { if( wxPathOnly( g_Prj_Config_LocalFilename ).IsEmpty() ) - wxGetApp().m_CurrentOptionFile = - wxGetCwd() + STRING_DIR_SEP + g_Prj_Config_LocalFilename; + m_CurrentOptionFile = wxGetCwd() + STRING_DIR_SEP + + g_Prj_Config_LocalFilename; else - wxGetApp().m_CurrentOptionFile = g_Prj_Config_LocalFilename; + m_CurrentOptionFile = g_Prj_Config_LocalFilename; } - for( ; *List != NULL; List++ ) + for( ; List != NULL && *List != NULL; List++ ) { pt_cfg = *List; if( pt_cfg->m_Group ) - g_Prj_Config->SetPath( pt_cfg->m_Group ); + m_ProjectConfig->SetPath( pt_cfg->m_Group ); else - g_Prj_Config->SetPath( GroupName ); + m_ProjectConfig->SetPath( GroupName ); if( pt_cfg->m_Setup ) continue; - pt_cfg->ReadParam( g_Prj_Config ); + pt_cfg->ReadParam( m_ProjectConfig ); } - delete g_Prj_Config; - g_Prj_Config = NULL; + delete m_ProjectConfig; + m_ProjectConfig = NULL; return true; } @@ -441,7 +446,7 @@ void PARAM_CFG_DOUBLE::ReadParam( wxConfigBase* aConfig ) return; double ftmp = 0; wxString msg; - msg = g_Prj_Config->Read( m_Ident, wxT( "" ) ); + msg = aConfig->Read( m_Ident, wxT( "" ) ); if( msg.IsEmpty() ) ftmp = m_Default; diff --git a/common/sch_item_struct.cpp b/common/sch_item_struct.cpp new file mode 100644 index 0000000000..cccf474692 --- /dev/null +++ b/common/sch_item_struct.cpp @@ -0,0 +1,63 @@ +/****************************************************/ +/* class_drawpickedstruct.cpp */ +/****************************************************/ + +#include "fctsys.h" +#include "common.h" +#include "gr_basic.h" +#include "base_struct.h" +#include "sch_item_struct.h" +#include "class_sch_screen.h" +#include "class_drawpanel.h" +#include "wxEeschemaStruct.h" + +#include "program.h" +#include "general.h" +#include "libcmp.h" +#include "protos.h" + +/* Constructor and destructor for SCH_ITEM */ +/* They are not inline because this creates problems with gcc at linking time + * in debug mode +*/ + +SCH_ITEM::SCH_ITEM( EDA_BaseStruct* aParent, KICAD_T aType ) : + EDA_BaseStruct( aParent, aType ) +{ + m_Layer = 0; +} + +SCH_ITEM::~SCH_ITEM() +{ +} + +/** + * place the struct in EEDrawList. + * if it is a new item, it it also put in undo list + * for an "old" item, saving it in undo list must be done before editiing, + * and not here! + */ +void SCH_ITEM::Place( WinEDA_SchematicFrame* frame, wxDC* DC ) +{ + if( m_Flags & IS_NEW ) + { + SCH_SCREEN* screen = frame->GetScreen(); + if( !screen->CheckIfOnDrawList( this ) ) //don't want a loop! + screen->AddToDrawList( this ); + g_ItemToRepeat = this; + frame->SaveCopyInUndoList( this, IS_NEW ); + } + + m_Flags = 0; + frame->GetScreen()->SetModify(); + frame->GetScreen()->SetCurItem( NULL ); + frame->DrawPanel->ManageCurseur = NULL; + frame->DrawPanel->ForceCloseManageCurseur = NULL; + + if( DC ) + { + frame->DrawPanel->CursorOff( DC ); // Erase schematic cursor + RedrawOneStruct( frame->DrawPanel, DC, this, GR_DEFAULT_DRAWMODE ); + frame->DrawPanel->CursorOn( DC ); // Display schematic cursor + } +} diff --git a/common/trigo.cpp b/common/trigo.cpp index c36b4c7c3f..d0b6efb7ab 100644 --- a/common/trigo.cpp +++ b/common/trigo.cpp @@ -213,7 +213,7 @@ int ArcTangente( int dy, int dx ) } fangle = atan2( (double) dy, (double) dx ) / M_PI * 1800; - return (int) round( fangle ); + return wxRound( fangle ); } @@ -265,8 +265,8 @@ void RotatePoint( int* pX, int* pY, int angle ) fpx = (*pY * fsinus[angle]) + (*pX * fcosinus[angle]); fpy = (*pY * fcosinus[angle]) - (*pX * fsinus[angle]); - *pX = (int) round( fpx ); - *pY = (int) round( fpy ); + *pX = wxRound( fpx ); + *pY = wxRound( fpy ); } } diff --git a/common/worksheet.cpp b/common/worksheet.cpp index 23a2fab7c3..d03837b55f 100644 --- a/common/worksheet.cpp +++ b/common/worksheet.cpp @@ -11,11 +11,910 @@ #include "drawtxt.h" #include "confirm.h" #include "wxstruct.h" +#include "appl_wxstruct.h" #include "worksheet.h" /* Must be defined in main applications: */ -extern wxString g_Main_Title; + +Ki_WorkSheetData WS_Date = +{ + WS_DATE, + &WS_Licence, + BLOCK_DATE_X, BLOCK_DATE_Y, + 0,0, +#if defined(KICAD_GOST) + NULL, NULL +#else + wxT("Date: "), NULL +#endif +}; + +Ki_WorkSheetData WS_Licence = +{ + WS_KICAD_VERSION, + &WS_Revision, + BLOCK_KICAD_VERSION_X, BLOCK_KICAD_VERSION_Y, + 0,0, + NULL, NULL +}; + +Ki_WorkSheetData WS_Revision = +{ + WS_REV, + &WS_SizeSheet, +#if defined(KICAD_GOST) + STAMP_X_185 - 30, STAMP_Y_30 + 90, +#else + BLOCK_REV_X, BLOCK_REV_Y, +#endif + 0,0, +#if defined(KICAD_GOST) + NULL, NULL +#else + wxT("Rev: "), NULL +#endif +}; + +Ki_WorkSheetData WS_SizeSheet = +{ + WS_SIZESHEET, +#if defined(KICAD_GOST) + &WS_Title, + BLOCK_SIZE_SHEET_X, BLOCK_SIZE_SHEET_Y, + 0,0, + NULL, NULL +}; +#else +&WS_IdentSheet, + BLOCK_SIZE_SHEET_X, BLOCK_SIZE_SHEET_Y, + 0,0, + wxT("Size: "),NULL + }; + +Ki_WorkSheetData WS_IdentSheet = +{ + WS_IDENTSHEET, + &WS_Title, + BLOCK_ID_SHEET_X, BLOCK_ID_SHEET_Y, + 0,0, + wxT("Id: "),NULL +}; +#endif + +Ki_WorkSheetData WS_Title = +{ + WS_TITLE, + &WS_SheetFilename, + BLOCK_TITLE_X, BLOCK_TITLE_Y, + 0,0, +#if defined(KICAD_GOST) + NULL, NULL +#else + wxT("Title: "),NULL +#endif +}; + +Ki_WorkSheetData WS_SheetFilename = +{ + WS_FILENAME, + &WS_FullSheetName, + BLOCK_FILENAME_X, BLOCK_FILENAME_Y, + 0,0, + wxT("File: "),NULL +}; + +Ki_WorkSheetData WS_FullSheetName = +{ + WS_FULLSHEETNAME, + &WS_Company, + BLOCK_FULLSHEETNAME_X, BLOCK_FULLSHEETNAME_Y, + 0,0, + wxT("Sheet: "),NULL +}; + +Ki_WorkSheetData WS_Company = +{ + WS_COMPANY_NAME, + &WS_Comment1, + BLOCK_COMMENT_X, BLOCK_COMPANY_Y, + 0,0, + NULL,NULL +}; + +Ki_WorkSheetData WS_Comment1 = +{ + WS_COMMENT1, + &WS_Comment2, +#if defined(KICAD_GOST) + STAMP_OX, STAMP_OY, + STAMP_OX, 0, +#else + BLOCK_COMMENT_X, BLOCK_COMMENT1_Y, + 0,0, +#endif + NULL,NULL +}; + +Ki_WorkSheetData WS_Comment2 = +{ + WS_COMMENT2, + &WS_Comment3, +#if defined(KICAD_GOST) + STAMP_OX, STAMP_OY, + STAMP_OX, 0, +#else + BLOCK_COMMENT_X, BLOCK_COMMENT2_Y, + 0,0, +#endif + NULL,NULL +}; + +Ki_WorkSheetData WS_Comment3 = +{ + WS_COMMENT3, + &WS_Comment4, +#if defined(KICAD_GOST) + STAMP_OX, STAMP_OY, + STAMP_OX, 0, +#else + BLOCK_COMMENT_X, BLOCK_COMMENT3_Y, + 0,0, +#endif + NULL,NULL +}; + +Ki_WorkSheetData WS_Comment4 = +{ + WS_COMMENT4, + &WS_MostLeftLine, +#if defined(KICAD_GOST) + STAMP_OX, STAMP_OY, + STAMP_OX, 0, +#else + BLOCK_COMMENT_X, BLOCK_COMMENT4_Y, + 0,0, +#endif + NULL,NULL +}; + +Ki_WorkSheetData WS_MostLeftLine = /* segment vertical gauche */ +{ + WS_LEFT_SEGMENT, +#if defined(KICAD_GOST) + &WS_MostUpperLine, + STAMP_OX, STAMP_OY, + STAMP_OX, 0, +#else + &WS_SeparatorLine, + BLOCK_OX, SIZETEXT * 16, + BLOCK_OX, 0, + NULL,NULL +}; + +Ki_WorkSheetData WS_SeparatorLine = /* horizontal segment between filename and comments*/ +{ + WS_SEGMENT, + &WS_MostUpperLine, + BLOCK_OX, VARIABLE_BLOCK_START_POSITION, + 0, VARIABLE_BLOCK_START_POSITION, +#endif + NULL,NULL +}; + +Ki_WorkSheetData WS_MostUpperLine = /* segment horizontal superieur */ +{ + WS_UPPER_SEGMENT, + &WS_Segm3, +#if defined(KICAD_GOST) + STAMP_OX, STAMP_OY, + 0, STAMP_OY, +#else + BLOCK_OX, SIZETEXT * 16, + 0, SIZETEXT * 16, +#endif + NULL,NULL +}; + +Ki_WorkSheetData WS_Segm3 = /* segment horizontal au dessus de NAME COMPANY */ +{ + WS_SEGMENT, + &WS_Segm4, +#if defined(KICAD_GOST) + STAMP_OX, STAMP_Y_50, + STAMP_X_120, STAMP_Y_50, +#else + BLOCK_OX, SIZETEXT * 6, + 0, SIZETEXT * 6, +#endif + NULL,NULL +}; + +Ki_WorkSheetData WS_Segm4 = /* segment vertical a gauche de SHEET et REV */ +{ + WS_SEGMENT, + &WS_Segm5, +#if defined(KICAD_GOST) + STAMP_OX, STAMP_Y_45, + STAMP_X_120, STAMP_Y_45, +#else + BLOCK_REV_X + SIZETEXT, SIZETEXT * 4, + BLOCK_REV_X + SIZETEXT, 0, +#endif + NULL,NULL +}; + +Ki_WorkSheetData WS_Segm5 = /* 1er segment horizontal */ +{ + WS_SEGMENT, + &WS_Segm6, +#if defined(KICAD_GOST) + STAMP_OX, STAMP_Y_40, + 0, STAMP_Y_40, +#else + BLOCK_OX, SIZETEXT * 2, + 0, SIZETEXT * 2, +#endif + NULL,NULL +}; + +Ki_WorkSheetData WS_Segm6 = /* 2eme segment horizontal */ +{ + WS_SEGMENT, + &WS_Segm7, +#if defined(KICAD_GOST) + STAMP_OX, STAMP_Y_35, + STAMP_X_120, STAMP_Y_35, +#else + BLOCK_OX, SIZETEXT * 4, + 0, SIZETEXT * 4, +#endif + NULL,NULL +}; + +Ki_WorkSheetData WS_Segm7 = /* segment vertical apres SIZE */ +{ + WS_SEGMENT, +#if defined(KICAD_GOST) + &WS_Segm8, + STAMP_X_50, STAMP_Y_35, + 0, STAMP_Y_35, + NULL,NULL +}; + +Ki_WorkSheetData WS_Segm8 = /* segment vertical apres SIZE */ +{ + WS_SEGMENT, + &WS_Segm9, + STAMP_OX, STAMP_Y_30, + STAMP_X_120, STAMP_Y_30, + NULL,NULL +}; + +Ki_WorkSheetData WS_Segm9 = /* segment vertical apres SIZE */ +{ + WS_SEGMENT, + &WS_Segm10, + STAMP_OX, STAMP_Y_25, + STAMP_X_120, STAMP_Y_25, + NULL,NULL +}; + +Ki_WorkSheetData WS_Segm10 = /* segment vertical apres SIZE */ +{ + WS_SEGMENT, + &WS_Segm11, + STAMP_OX, STAMP_Y_20, + STAMP_X_120, STAMP_Y_20, + NULL,NULL +}; + +Ki_WorkSheetData WS_Segm11 = /* segment vertical apres SIZE */ +{ + WS_SEGMENT, + &WS_Segm12, + STAMP_X_50, STAMP_Y_20, + 0, STAMP_Y_20, + NULL,NULL +}; + +Ki_WorkSheetData WS_Segm12 = /* segment vertical apres SIZE */ +{ + WS_SEGMENT, + &WS_Segm13, + STAMP_OX, STAMP_Y_15, + 0, STAMP_Y_15, + NULL,NULL +}; + +Ki_WorkSheetData WS_Segm13 = /* segment vertical apres SIZE */ +{ + WS_SEGMENT, + &WS_Segm14, + STAMP_OX, STAMP_Y_10, + STAMP_X_120, STAMP_Y_10, + NULL,NULL +}; + +Ki_WorkSheetData WS_Segm14 = /* segment vertical apres SIZE */ +{ + WS_SEGMENT, + &WS_Segm15, + STAMP_OX, STAMP_Y_5, + STAMP_X_120, STAMP_Y_5, + NULL,NULL +}; + +Ki_WorkSheetData WS_Segm15 = /* segment vertical apres SIZE */ +{ + WS_SEGMENT, + &WS_Segm16, + STAMP_X_178, STAMP_OY, + STAMP_X_178, STAMP_Y_30, + NULL,NULL +}; + +Ki_WorkSheetData WS_Segm16 = /* segment vertical apres SIZE */ +{ + WS_SEGMENT, + &WS_Segm17, + STAMP_X_168, STAMP_OY, + STAMP_X_168, 0, + NULL,NULL +}; + +Ki_WorkSheetData WS_Segm17 = /* segment vertical apres SIZE */ +{ + WS_SEGMENT, + &WS_Segm18, + STAMP_X_145, STAMP_OY, + STAMP_X_145, 0, + NULL,NULL +}; + +Ki_WorkSheetData WS_Segm18 = /* segment vertical apres SIZE */ +{ + WS_SEGMENT, + &WS_Segm19, + STAMP_X_130, STAMP_OY, + STAMP_X_130, 0, + NULL,NULL +}; + +Ki_WorkSheetData WS_Segm19 = /* segment vertical apres SIZE */ +{ + WS_SEGMENT, + &WS_Segm20, + STAMP_X_120, STAMP_OY, + STAMP_X_120, 0, + NULL,NULL +}; + +Ki_WorkSheetData WS_Segm20 = /* segment vertical apres SIZE */ +{ + WS_SEGMENT, + &WS_Segm21, + STAMP_X_50, STAMP_Y_40, + STAMP_X_50, 0, + NULL,NULL +}; + +Ki_WorkSheetData WS_Segm21 = /* segment vertical apres SIZE */ +{ + WS_SEGMENT, + &WS_Segm22, + STAMP_X_45, STAMP_Y_35, + STAMP_X_45, STAMP_Y_20, + NULL,NULL +}; + +Ki_WorkSheetData WS_Segm22 = /* segment vertical apres SIZE */ +{ + WS_SEGMENT, + &WS_Segm23, + STAMP_X_40, STAMP_Y_35, + STAMP_X_40, STAMP_Y_20, + NULL,NULL +}; + +Ki_WorkSheetData WS_Segm23 = /* segment vertical apres SIZE */ +{ + WS_SEGMENT, + &WS_Segm24, + STAMP_X_35, STAMP_Y_40, + STAMP_X_35, STAMP_Y_20, + NULL,NULL +}; + +Ki_WorkSheetData WS_Segm24 = /* segment vertical apres SIZE */ +{ + WS_SEGMENT, + &WS_Segm25, + STAMP_X_30, STAMP_Y_20, + STAMP_X_30, STAMP_Y_15, + NULL,NULL +}; + +Ki_WorkSheetData WS_Segm25 = /* segment vertical apres SIZE */ +{ + WS_SEGMENT, + &WS_Izm, + STAMP_X_18, STAMP_Y_40, + STAMP_X_18, STAMP_Y_20, + NULL,NULL +}; + +Ki_WorkSheetData WS_Izm = +{ + WS_PODPIS, + &WS_Razr, + STAMP_X_185 - 30,STAMP_Y_30 + 90, + 0,0, + wxT("§ª§Ù§Þ."), NULL +}; + +Ki_WorkSheetData WS_Razr = +{ + WS_PODPIS, + &WS_Prov, + STAMP_X_185 - 30,STAMP_Y_25 + 90, + 0,0, + wxT("§²§Ñ§Ù§â§Ñ§Ò."), NULL +}; + +Ki_WorkSheetData WS_Prov = +{ + WS_PODPIS, + &WS_TKon, + STAMP_X_185 - 30,STAMP_Y_20 + 90, + 0,0, + wxT("§±§â§à§Ó."), NULL +}; + +Ki_WorkSheetData WS_TKon = +{ + WS_PODPIS, + &WS_NKon, + STAMP_X_185 - 30,STAMP_Y_15 + 90, + 0,0, + wxT("§´.§Ü§à§ß§ä§â."), NULL +}; + +Ki_WorkSheetData WS_NKon = +{ + WS_PODPIS, + &WS_Utv, + STAMP_X_185 - 30,STAMP_Y_5 + 90, + 0,0, + wxT("§¯.§Ü§à§ß§ä§â."), NULL +}; + +Ki_WorkSheetData WS_Utv = +{ + WS_PODPIS, + &WS_List, + STAMP_X_185 - 30,STAMP_Y_0 + 90, + 0,0, + wxT("§µ§ä§Ó."), NULL +}; + +Ki_WorkSheetData WS_List = +{ + WS_PODPIS, + &WS_NDoc, + STAMP_X_178 - 30,STAMP_Y_30 + 90, + 0,0, + wxT("§­§Ú§ã§ä"), NULL +}; + +Ki_WorkSheetData WS_NDoc = +{ + WS_PODPIS, + &WS_Podp, + STAMP_X_168 - 30,STAMP_Y_30 + 90, + 0,0, + wxT("N §Õ§à§Ü§å§Þ."), NULL +}; + +Ki_WorkSheetData WS_Podp = +{ + WS_PODPIS, + &WS_Data, + STAMP_X_145 - 30,STAMP_Y_30 + 90, + 0,0, + wxT("§±§à§Õ§á."), NULL +}; + +Ki_WorkSheetData WS_Data = +{ + WS_PODPIS, + &WS_Art, + STAMP_X_130 - 30,STAMP_Y_30 + 90, + 0,0, + wxT("§¥§Ñ§ä§Ñ"), NULL +}; + +Ki_WorkSheetData WS_Art = +{ + WS_PODPIS, + &WS_Mass, + STAMP_X_50 - 30,STAMP_Y_35 + 90, + 0,0, + wxT("§¡§â§ä."), NULL +}; + +Ki_WorkSheetData WS_Mass = +{ + WS_PODPIS, + &WS_Msht, + STAMP_X_35 - 30,STAMP_Y_35 + 90, + 0,0, + wxT("§®§Ñ§ã§ã§Ñ"), NULL +}; + +Ki_WorkSheetData WS_Msht = +{ + WS_PODPIS, + &WS_List1, + STAMP_X_18 - 30,STAMP_Y_35 + 90, + 0,0, + wxT("§®§Ñ§ã§ê§ä§Ñ§Ò"), NULL +}; + +Ki_WorkSheetData WS_List1 = +{ + WS_IDENTSHEET, + &WS_List2, + STAMP_X_50 - 30,STAMP_Y_15 + 90, + 0,0, + wxT("§­§Ú§ã§ä "), NULL +}; + +Ki_WorkSheetData WS_List2 = +{ + WS_SHEETS, + NULL, + STAMP_X_30 - 30,STAMP_Y_15 + 90, + 0,0, + wxT("§­§Ú§ã§ä§à§Ó "), NULL +}; + +Ki_WorkSheetData WS_CADRE_D = +{ + WS_CADRE, + &WS_Segm1_D, + STAMP_OX, 0, + 0,0, + NULL, NULL +}; + +Ki_WorkSheetData WS_Segm1_D = +{ + WS_LEFT_SEGMENT_D, + &WS_Segm2_D, + STAMP_OX, STAMP_Y_15, + STAMP_OX, 0, + NULL, NULL +}; + +Ki_WorkSheetData WS_Segm2_D = +{ + WS_SEGMENT_D, + &WS_Segm3_D, + STAMP_X_178, STAMP_Y_15, + STAMP_X_178, 0, + NULL, NULL +}; + +Ki_WorkSheetData WS_Segm3_D = +{ + WS_SEGMENT_D, + &WS_Segm4_D, + STAMP_X_168, STAMP_Y_15, + STAMP_X_168, 0, + NULL, NULL +}; + +Ki_WorkSheetData WS_Segm4_D = +{ + WS_SEGMENT_D, + &WS_Segm5_D, + STAMP_X_145, STAMP_Y_15, + STAMP_X_145, 0, + NULL, NULL +}; + +Ki_WorkSheetData WS_Segm5_D = +{ + WS_SEGMENT_D, + &WS_Segm6_D, + STAMP_X_130, STAMP_Y_15, + STAMP_X_130, 0, + NULL, NULL +}; + +Ki_WorkSheetData WS_Segm6_D = +{ + WS_SEGMENT_D, + &WS_Segm7_D, + STAMP_X_120, STAMP_Y_15, + STAMP_X_120, 0, + NULL, NULL +}; + +Ki_WorkSheetData WS_Segm7_D = +{ + WS_SEGMENT_D, + &WS_Segm8_D, + STAMP_X_10, STAMP_Y_15, + STAMP_X_10, 0, + NULL, NULL +}; + +Ki_WorkSheetData WS_Segm8_D = +{ + WS_SEGMENT_D, + &WS_Segm9_D, + STAMP_X_185, STAMP_Y_10, + STAMP_X_120, STAMP_Y_10, + NULL, NULL +}; + +Ki_WorkSheetData WS_Segm9_D = +{ + WS_SEGMENT_D, + &WS_Segm10_D, + STAMP_X_185, STAMP_Y_5, + STAMP_X_120, STAMP_Y_5, + NULL, NULL +}; + +Ki_WorkSheetData WS_Segm10_D = +{ + WS_SEGMENT_D, + &WS_Segm11_D, + STAMP_X_10, STAMP_Y_8, + 0, STAMP_Y_8, + NULL, NULL +}; + +Ki_WorkSheetData WS_Segm11_D = +{ + WS_SEGMENT_D, + &WS_Izm_D, + STAMP_X_185, STAMP_Y_15, + 0, STAMP_Y_15, + NULL, NULL +}; + +Ki_WorkSheetData WS_Izm_D = +{ + WS_PODPIS_D, + &WS_List_D, + STAMP_X_185 - 30, STAMP_Y_0 + 90, + 0, 0, + wxT("§ª§Ù§Þ."), NULL +}; + +Ki_WorkSheetData WS_List_D = +{ + WS_PODPIS_D, + &WS_NDoc_D, + STAMP_X_178 - 30, STAMP_Y_0 + 90, + 0, 0, + wxT("§­§Ú§ã§ä"), NULL +}; + +Ki_WorkSheetData WS_NDoc_D = +{ + WS_PODPIS_D, + &WS_Podp_D, + STAMP_X_168 - 30, STAMP_Y_0 + 90, + 0, 0, + wxT("N §Õ§à§Ü§å§Þ."), NULL +}; + +Ki_WorkSheetData WS_Podp_D = +{ + WS_PODPIS_D, + &WS_Date_D, + STAMP_X_145 - 30, STAMP_Y_0 + 90, + 0, 0, + wxT("§±§à§Õ§á."), NULL +}; + +Ki_WorkSheetData WS_Date_D = +{ + WS_PODPIS_D, + &WS_List1_D, + STAMP_X_130 - 30, STAMP_Y_0 + 90, + 0, 0, + wxT("§¥§Ñ§ä§Ñ"), NULL +}; + +Ki_WorkSheetData WS_List1_D = +{ + WS_PODPIS_D, + &WS_ListN_D, + STAMP_X_10 - 30, STAMP_Y_8 + 90, + 0, 0, + wxT("§­§Ú§ã§ä"), NULL +}; + +Ki_WorkSheetData WS_ListN_D = +{ + WS_IDENTSHEET_D, + NULL, + STAMP_Y_0 + 196, STAMP_Y_0 + 90, + 0, 0, + NULL, NULL +}; + +Ki_WorkSheetData WS_Segm1_LU = +{ + WS_SEGMENT_LU, + &WS_Segm2_LU, + STAMP_12, STAMP_145, + STAMP_12, 0, + NULL, NULL +}; + +Ki_WorkSheetData WS_Segm2_LU = +{ + WS_SEGMENT_LU, + &WS_Segm3_LU, + STAMP_7, STAMP_145, + STAMP_7, 0, + NULL, NULL +}; + +Ki_WorkSheetData WS_Segm3_LU = +{ + WS_SEGMENT_LU, + &WS_Segm4_LU, + STAMP_12, STAMP_145, + 0, STAMP_145, + NULL, NULL +}; + +Ki_WorkSheetData WS_Segm4_LU = +{ + WS_SEGMENT_LU, + &WS_Segm5_LU, + STAMP_12, STAMP_110, + 0, STAMP_110, + NULL, NULL +}; + +Ki_WorkSheetData WS_Segm5_LU = +{ + WS_SEGMENT_LU, + &WS_Segm6_LU, + STAMP_12, STAMP_85, + 0, STAMP_85, + NULL, NULL +}; + +Ki_WorkSheetData WS_Segm6_LU = +{ + WS_SEGMENT_LU, + &WS_Segm7_LU, + STAMP_12, STAMP_60, + 0, STAMP_60, + NULL, NULL +}; + +Ki_WorkSheetData WS_Segm7_LU = +{ + WS_SEGMENT_LU, + &WS_Segm8_LU, + STAMP_12, STAMP_25, + 0, STAMP_25, + NULL, NULL +}; + +Ki_WorkSheetData WS_Segm8_LU = +{ + WS_SEGMENT_LU, + &WS_Podp1_LU, + STAMP_12, 0, + 0, 0, + NULL, NULL +}; + +Ki_WorkSheetData WS_Podp1_LU = +{ + WS_PODPIS_LU, + &WS_Podp2_LU, + STAMP_7 + 90, 0 + 30, + 0, 0, + wxT("§ª§ß§Ó.N §á§à§Õ§Ý."), NULL +}; + +Ki_WorkSheetData WS_Podp2_LU = +{ + WS_PODPIS_LU, + &WS_Podp3_LU, + STAMP_7 + 90, STAMP_25 + 30, + 0, 0, + wxT("§±§à§Õ§á. §Ú §Õ§Ñ§ä§Ñ"), NULL +}; + +Ki_WorkSheetData WS_Podp3_LU = +{ + WS_PODPIS_LU, + &WS_Podp4_LU, + STAMP_7 + 90, STAMP_60 + 30, + 0, 0, + wxT("§£§Ù§Ñ§Þ.§Ú§ß§Ó.N"), NULL +}; + +Ki_WorkSheetData WS_Podp4_LU = +{ + WS_PODPIS_LU, + &WS_Podp5_LU, + STAMP_7 + 90, STAMP_85 + 30, + 0, 0, + wxT("§ª§ß§Ó.N §Õ§å§Ò§Ý."), NULL +}; + +Ki_WorkSheetData WS_Podp5_LU = +{ + WS_PODPIS_LU, + NULL, + STAMP_7 + 90, STAMP_110 + 30, + 0, 0, + wxT("§±§à§Õ§á. §Ú §Õ§Ñ§ä§Ñ"), NULL +}; + +Ki_WorkSheetData WS_Segm1_LT = +{ + WS_SEGMENT_LT, + &WS_Segm2_LT, + STAMP_X_0, STAMP_Y_14, + STAMP_X_137, STAMP_Y_14, + NULL, NULL +}; + +Ki_WorkSheetData WS_Segm2_LT = +{ + WS_SEGMENT_LT, + &WS_Segm3_LT, + STAMP_X_137, STAMP_Y_14, + STAMP_X_137, 0, + NULL, NULL +}; + +Ki_WorkSheetData WS_Segm3_LT = +{ + WS_SEGMENT_LT, + &WS_Segm4_LT, + STAMP_X_137, STAMP_Y_7, + STAMP_X_84, STAMP_Y_7, + NULL, NULL +}; + +Ki_WorkSheetData WS_Segm4_LT = +{ + WS_SEGMENT_LT, + &WS_Segm5_LT, + STAMP_X_84, STAMP_Y_14, + STAMP_X_84, 0, + NULL, NULL +}; +Ki_WorkSheetData WS_Segm5_LT = +{ + WS_SEGMENT_LT, + NULL, + STAMP_X_70, STAMP_Y_14, + STAMP_X_70, 0, +#else + NULL, + BLOCK_OX - (SIZETEXT * 11), SIZETEXT * 4, + BLOCK_OX - (SIZETEXT * 11), SIZETEXT * 2, +#endif + NULL, NULL +}; /*************************************************************************************/ void WinEDA_DrawFrame::TraceWorkSheet( wxDC* DC, BASE_SCREEN* screen, int line_width ) @@ -46,17 +945,17 @@ void WinEDA_DrawFrame::TraceWorkSheet( wxDC* DC, BASE_SCREEN* screen, int line_w if( Sheet == NULL ) { DisplayError( this, - wxT( "WinEDA_DrawFrame::TraceWorkSheet() error: NULL Sheet" ) ); + wxT( "WinEDA_DrawFrame::TraceWorkSheet() error: NULL Sheet" ) ); return; } // if not printing, draw the page limits: - if( !g_IsPrinting & g_ShowPageLimits ) + if( !screen->m_IsPrinting & g_ShowPageLimits ) { GRSetDrawMode( DC, GR_COPY ); GRRect( &DrawPanel->m_ClipBox, DC, 0, 0, - Sheet->m_Size.x * scale, Sheet->m_Size.y * scale, width, - g_DrawBgColor == WHITE ? LIGHTGRAY : DARKDARKGRAY ); + Sheet->m_Size.x * scale, Sheet->m_Size.y * scale, width, + g_DrawBgColor == WHITE ? LIGHTGRAY : DARKDARKGRAY ); } GRSetDrawMode( DC, GR_COPY ); @@ -68,13 +967,13 @@ void WinEDA_DrawFrame::TraceWorkSheet( wxDC* DC, BASE_SCREEN* screen, int line_w #if defined(KICAD_GOST) GRRect( &DrawPanel->m_ClipBox, DC, refx * scale, refy * scale, - xg * scale, yg * scale, width, Color ); + xg * scale, yg * scale, width, Color ); #else for( ii = 0; ii < 2; ii++ ) { GRRect( &DrawPanel->m_ClipBox, DC, refx * scale, refy * scale, - xg * scale, yg * scale, width, Color ); + xg * scale, yg * scale, width, Color ); refx += GRID_REF_W; refy += GRID_REF_W; xg -= GRID_REF_W; yg -= GRID_REF_W; @@ -87,42 +986,42 @@ void WinEDA_DrawFrame::TraceWorkSheet( wxDC* DC, BASE_SCREEN* screen, int line_w refy = Sheet->m_Size.y - Sheet->m_BottomMargin; /* Lower left corner */ for( WsItem = &WS_Segm1_LU; WsItem != NULL; WsItem = WsItem->Pnext ) { - pos.x = (refx - WsItem->m_Posx)* scale; - pos.y = (refy - WsItem->m_Posy)* scale; - msg.Empty(); - switch( WsItem->m_Type ) - { + pos.x = (refx - WsItem->m_Posx)* scale; + pos.y = (refy - WsItem->m_Posy)* scale; + msg.Empty(); + switch( WsItem->m_Type ) + { case WS_CADRE: - break; + break; case WS_PODPIS_LU: - if(WsItem->m_Legende) msg = WsItem->m_Legende; - DrawGraphicText(DrawPanel, DC, pos, Color, - msg, TEXT_ORIENT_VERT, size, - GR_TEXT_HJUSTIFY_CENTER, GR_TEXT_VJUSTIFY_BOTTOM,width); - break; + if(WsItem->m_Legende) msg = WsItem->m_Legende; + DrawGraphicText(DrawPanel, DC, pos, Color, + msg, TEXT_ORIENT_VERT, size, + GR_TEXT_HJUSTIFY_CENTER, GR_TEXT_VJUSTIFY_BOTTOM,width); + break; case WS_SEGMENT_LU: - xg = Sheet->m_LeftMargin - WsItem->m_Endx; - yg = Sheet->m_Size.y - Sheet->m_BottomMargin - WsItem->m_Endy; - GRLine(&DrawPanel->m_ClipBox, DC, pos.x, pos.y, - xg * scale, yg * scale, width, Color); - break; - } + xg = Sheet->m_LeftMargin - WsItem->m_Endx; + yg = Sheet->m_Size.y - Sheet->m_BottomMargin - WsItem->m_Endy; + GRLine(&DrawPanel->m_ClipBox, DC, pos.x, pos.y, + xg * scale, yg * scale, width, Color); + break; + } } refy = Sheet->m_BottomMargin; /* Left Top corner */ for( WsItem = &WS_Segm1_LT; WsItem != NULL; WsItem = WsItem->Pnext ) { - pos.x = (refx + WsItem->m_Posx)* scale; - pos.y = (refy + WsItem->m_Posy)* scale; - msg.Empty(); - switch( WsItem->m_Type ) - { + pos.x = (refx + WsItem->m_Posx)* scale; + pos.y = (refy + WsItem->m_Posy)* scale; + msg.Empty(); + switch( WsItem->m_Type ) + { case WS_SEGMENT_LT: - xg = Sheet->m_LeftMargin + WsItem->m_Endx; - yg = Sheet->m_BottomMargin + WsItem->m_Endy; - GRLine(&DrawPanel->m_ClipBox, DC, pos.x, pos.y, - xg * scale, yg * scale, width, Color); - break; - } + xg = Sheet->m_LeftMargin + WsItem->m_Endx; + yg = Sheet->m_BottomMargin + WsItem->m_Endy; + GRLine(&DrawPanel->m_ClipBox, DC, pos.x, pos.y, + xg * scale, yg * scale, width, Color); + break; + } } #else refy = Sheet->m_TopMargin; /* Upper left corner */ @@ -138,23 +1037,25 @@ void WinEDA_DrawFrame::TraceWorkSheet( wxDC* DC, BASE_SCREEN* screen, int line_w if( ii < xg - PAS_REF / 2 ) { GRLine( &DrawPanel->m_ClipBox, DC, ii * scale, refy * scale, - ii * scale, (refy + GRID_REF_W) * scale, width, Color ); + ii * scale, (refy + GRID_REF_W) * scale, width, Color ); } DrawGraphicText( DrawPanel, DC, - wxPoint( (ii - gxpas / 2) * scale, (refy + GRID_REF_W / 2) * scale ), - Color, - Line, TEXT_ORIENT_HORIZ, size_ref, - GR_TEXT_HJUSTIFY_CENTER, GR_TEXT_VJUSTIFY_CENTER, width ); + wxPoint( (ii - gxpas / 2) * scale, (refy + GRID_REF_W / 2) * scale ), + Color, + Line, TEXT_ORIENT_HORIZ, size_ref, + GR_TEXT_HJUSTIFY_CENTER, GR_TEXT_VJUSTIFY_CENTER, + width ); if( ii < xg - PAS_REF / 2 ) { GRLine( &DrawPanel->m_ClipBox, DC, ii * scale, yg * scale, - ii * scale, (yg - GRID_REF_W) * scale, width, Color ); + ii * scale, (yg - GRID_REF_W) * scale, width, Color ); } DrawGraphicText( DrawPanel, DC, - wxPoint( (ii - gxpas / 2) * scale, (yg - GRID_REF_W / 2) * scale ), - Color, - Line, TEXT_ORIENT_HORIZ, size_ref, - GR_TEXT_HJUSTIFY_CENTER, GR_TEXT_VJUSTIFY_CENTER, width ); + wxPoint( (ii - gxpas / 2) * scale, + (yg - GRID_REF_W / 2) * scale ), + Color, Line, TEXT_ORIENT_HORIZ, size_ref, + GR_TEXT_HJUSTIFY_CENTER, GR_TEXT_VJUSTIFY_CENTER, + width ); } /* Trace des reperes selon l'axe Y */ @@ -170,23 +1071,26 @@ void WinEDA_DrawFrame::TraceWorkSheet( wxDC* DC, BASE_SCREEN* screen, int line_w if( ii < yg - PAS_REF / 2 ) { GRLine( &DrawPanel->m_ClipBox, DC, refx * scale, ii * scale, - (refx + GRID_REF_W) * scale, ii * scale, width, Color ); + (refx + GRID_REF_W) * scale, ii * scale, width, Color ); } DrawGraphicText( DrawPanel, DC, - wxPoint( (refx + GRID_REF_W / 2) * scale, (ii - gypas / 2) * scale ), - Color, - Line, TEXT_ORIENT_HORIZ, size_ref, - GR_TEXT_HJUSTIFY_CENTER, GR_TEXT_VJUSTIFY_CENTER, width ); + wxPoint( (refx + GRID_REF_W / 2) * scale, + (ii - gypas / 2) * scale ), + Color, + Line, TEXT_ORIENT_HORIZ, size_ref, + GR_TEXT_HJUSTIFY_CENTER, GR_TEXT_VJUSTIFY_CENTER, + width ); if( ii < yg - PAS_REF / 2 ) { GRLine( &DrawPanel->m_ClipBox, DC, xg * scale, ii * scale, - (xg - GRID_REF_W) * scale, ii * scale, width, Color ); + (xg - GRID_REF_W) * scale, ii * scale, width, Color ); } DrawGraphicText( DrawPanel, DC, - wxPoint( (xg - GRID_REF_W / 2) * scale, (ii - gxpas / 2) * scale ), - Color, - Line, TEXT_ORIENT_HORIZ, size_ref, - GR_TEXT_HJUSTIFY_CENTER, GR_TEXT_VJUSTIFY_CENTER, width ); + wxPoint( (xg - GRID_REF_W / 2) * scale, + (ii - gxpas / 2) * scale ), + Color, Line, TEXT_ORIENT_HORIZ, size_ref, + GR_TEXT_HJUSTIFY_CENTER, GR_TEXT_VJUSTIFY_CENTER, + width ); } #endif @@ -196,104 +1100,108 @@ void WinEDA_DrawFrame::TraceWorkSheet( wxDC* DC, BASE_SCREEN* screen, int line_w refy = Sheet->m_Size.y - Sheet->m_BottomMargin; /* lower right corner */ if (screen->m_ScreenNumber == 1) { - for( WsItem = &WS_Date; WsItem != NULL; WsItem = WsItem->Pnext ) - { - pos.x = (refx - WsItem->m_Posx)* scale; - pos.y = (refy - WsItem->m_Posy)* scale; - msg.Empty(); - switch( WsItem->m_Type ) - { - case WS_DATE: - break; - case WS_REV: - break; - case WS_KICAD_VERSION: - break; - case WS_PODPIS: - if(WsItem->m_Legende) msg = WsItem->m_Legende; - DrawGraphicText(DrawPanel, DC, pos, Color, - msg, TEXT_ORIENT_HORIZ, size, - GR_TEXT_HJUSTIFY_LEFT, GR_TEXT_VJUSTIFY_CENTER, width); - break; - case WS_SIZESHEET: - break; - case WS_IDENTSHEET: - if(WsItem->m_Legende) msg = WsItem->m_Legende; - msg << screen->m_ScreenNumber; - DrawGraphicText(DrawPanel, DC, pos, Color, - msg, TEXT_ORIENT_HORIZ, size, - GR_TEXT_HJUSTIFY_LEFT, GR_TEXT_VJUSTIFY_CENTER, width); - break; - case WS_SHEETS: - if(WsItem->m_Legende) msg = WsItem->m_Legende; - msg << screen->m_NumberOfScreen; - DrawGraphicText(DrawPanel, DC, pos, Color, - msg, TEXT_ORIENT_HORIZ, size, - GR_TEXT_HJUSTIFY_LEFT, GR_TEXT_VJUSTIFY_CENTER, width); - break; - case WS_COMPANY_NAME: - break; - case WS_TITLE: - break; - case WS_COMMENT1: - break; - case WS_COMMENT2: - break; - case WS_COMMENT3: - break; - case WS_COMMENT4: - break; - case WS_UPPER_SEGMENT: - case WS_LEFT_SEGMENT: - WS_MostUpperLine.m_Posy = - WS_MostUpperLine.m_Endy = - WS_MostLeftLine.m_Posy = STAMP_OY; - pos.y = (refy - WsItem->m_Posy)* scale; - case WS_SEGMENT: - xg = Sheet->m_Size.x - - Sheet->m_RightMargin - WsItem->m_Endx; - yg = Sheet->m_Size.y - - Sheet->m_BottomMargin - WsItem->m_Endy; - GRLine(&DrawPanel->m_ClipBox, DC, pos.x, pos.y, - xg * scale, yg * scale, width, Color); - break; - } - } + for( WsItem = &WS_Date; WsItem != NULL; WsItem = WsItem->Pnext ) + { + pos.x = (refx - WsItem->m_Posx)* scale; + pos.y = (refy - WsItem->m_Posy)* scale; + msg.Empty(); + switch( WsItem->m_Type ) + { + case WS_DATE: + break; + case WS_REV: + break; + case WS_KICAD_VERSION: + break; + case WS_PODPIS: + if( WsItem->m_Legende ) + msg = WsItem->m_Legende; + DrawGraphicText( DrawPanel, DC, pos, Color, + msg, TEXT_ORIENT_HORIZ, size, + GR_TEXT_HJUSTIFY_LEFT, GR_TEXT_VJUSTIFY_CENTER, + width ); + break; + case WS_SIZESHEET: + break; + case WS_IDENTSHEET: + if(WsItem->m_Legende) + msg = WsItem->m_Legende; + msg << screen->m_ScreenNumber; + DrawGraphicText( DrawPanel, DC, pos, Color, msg, + TEXT_ORIENT_HORIZ, size, GR_TEXT_HJUSTIFY_LEFT, + GR_TEXT_VJUSTIFY_CENTER, width); + break; + case WS_SHEETS: + if(WsItem->m_Legende) + msg = WsItem->m_Legende; + msg << screen->m_NumberOfScreen; + DrawGraphicText( DrawPanel, DC, pos, Color, msg, + TEXT_ORIENT_HORIZ, size, GR_TEXT_HJUSTIFY_LEFT, + GR_TEXT_VJUSTIFY_CENTER, width); + break; + case WS_COMPANY_NAME: + break; + case WS_TITLE: + break; + case WS_COMMENT1: + break; + case WS_COMMENT2: + break; + case WS_COMMENT3: + break; + case WS_COMMENT4: + break; + case WS_UPPER_SEGMENT: + case WS_LEFT_SEGMENT: + WS_MostUpperLine.m_Posy = + WS_MostUpperLine.m_Endy = + WS_MostLeftLine.m_Posy = STAMP_OY; + pos.y = (refy - WsItem->m_Posy)* scale; + case WS_SEGMENT: + xg = Sheet->m_Size.x - + Sheet->m_RightMargin - WsItem->m_Endx; + yg = Sheet->m_Size.y - + Sheet->m_BottomMargin - WsItem->m_Endy; + GRLine(&DrawPanel->m_ClipBox, DC, pos.x, pos.y, + xg * scale, yg * scale, width, Color); + break; + } + } } else { - for( WsItem = &WS_CADRE_D; WsItem != NULL; WsItem = WsItem->Pnext ) - { - pos.x = (refx - WsItem->m_Posx)* scale; - pos.y = (refy - WsItem->m_Posy)* scale; - msg.Empty(); - switch( WsItem->m_Type ) - { - case WS_CADRE: - /* Begin list number > 1 */ - case WS_PODPIS_D: - if(WsItem->m_Legende) msg = WsItem->m_Legende; - DrawGraphicText(DrawPanel, DC, pos, Color, - msg, TEXT_ORIENT_HORIZ, size, - GR_TEXT_HJUSTIFY_LEFT, GR_TEXT_VJUSTIFY_CENTER,width); - break; - case WS_IDENTSHEET_D: - if(WsItem->m_Legende) msg = WsItem->m_Legende; - msg << screen->m_ScreenNumber; - DrawGraphicText(DrawPanel, DC, pos, Color, - msg, TEXT_ORIENT_HORIZ, size, - GR_TEXT_HJUSTIFY_LEFT, GR_TEXT_VJUSTIFY_CENTER,width); - break; - case WS_LEFT_SEGMENT_D: - pos.y = (refy - WsItem->m_Posy)* scale; - case WS_SEGMENT_D: - xg = Sheet->m_Size.x - - Sheet->m_RightMargin - WsItem->m_Endx; - yg = Sheet->m_Size.y - - Sheet->m_BottomMargin - WsItem->m_Endy; - GRLine(&DrawPanel->m_ClipBox, DC, pos.x, pos.y, - xg * scale, yg * scale, width, Color); - break; - } - } + for( WsItem = &WS_CADRE_D; WsItem != NULL; WsItem = WsItem->Pnext ) + { + pos.x = (refx - WsItem->m_Posx)* scale; + pos.y = (refy - WsItem->m_Posy)* scale; + msg.Empty(); + switch( WsItem->m_Type ) + { + case WS_CADRE: + /* Begin list number > 1 */ + case WS_PODPIS_D: + if(WsItem->m_Legende) msg = WsItem->m_Legende; + DrawGraphicText(DrawPanel, DC, pos, Color, + msg, TEXT_ORIENT_HORIZ, size, + GR_TEXT_HJUSTIFY_LEFT, GR_TEXT_VJUSTIFY_CENTER,width); + break; + case WS_IDENTSHEET_D: + if(WsItem->m_Legende) msg = WsItem->m_Legende; + msg << screen->m_ScreenNumber; + DrawGraphicText(DrawPanel, DC, pos, Color, + msg, TEXT_ORIENT_HORIZ, size, + GR_TEXT_HJUSTIFY_LEFT, GR_TEXT_VJUSTIFY_CENTER,width); + break; + case WS_LEFT_SEGMENT_D: + pos.y = (refy - WsItem->m_Posy)* scale; + case WS_SEGMENT_D: + xg = Sheet->m_Size.x - + Sheet->m_RightMargin - WsItem->m_Endx; + yg = Sheet->m_Size.y - + Sheet->m_BottomMargin - WsItem->m_Endy; + GRLine(&DrawPanel->m_ClipBox, DC, pos.x, pos.y, + xg * scale, yg * scale, width, Color); + break; + } + } } #else refx = Sheet->m_Size.x - Sheet->m_RightMargin - GRID_REF_W; @@ -312,8 +1220,8 @@ void WinEDA_DrawFrame::TraceWorkSheet( wxDC* DC, BASE_SCREEN* screen, int line_w msg = WsItem->m_Legende; msg += screen->m_Date; DrawGraphicText( DrawPanel, DC, pos, Color, - msg, TEXT_ORIENT_HORIZ, size, - GR_TEXT_HJUSTIFY_LEFT, GR_TEXT_VJUSTIFY_CENTER, width ); + msg, TEXT_ORIENT_HORIZ, size, + GR_TEXT_HJUSTIFY_LEFT, GR_TEXT_VJUSTIFY_CENTER, width ); break; case WS_REV: @@ -321,18 +1229,18 @@ void WinEDA_DrawFrame::TraceWorkSheet( wxDC* DC, BASE_SCREEN* screen, int line_w msg = WsItem->m_Legende; msg += screen->m_Revision; DrawGraphicText( DrawPanel, DC, pos, Color, - msg, TEXT_ORIENT_HORIZ, size, - GR_TEXT_HJUSTIFY_LEFT, GR_TEXT_VJUSTIFY_CENTER, width ); + msg, TEXT_ORIENT_HORIZ, size, + GR_TEXT_HJUSTIFY_LEFT, GR_TEXT_VJUSTIFY_CENTER, width ); break; case WS_KICAD_VERSION: if( WsItem->m_Legende ) msg = WsItem->m_Legende; - msg += g_ProductName + g_Main_Title; + msg += g_ProductName + wxGetApp().GetAppName(); msg += wxT( " " ) + GetBuildVersion(); DrawGraphicText( DrawPanel, DC, pos, Color, - msg, TEXT_ORIENT_HORIZ, size, - GR_TEXT_HJUSTIFY_LEFT, GR_TEXT_VJUSTIFY_CENTER, width ); + msg, TEXT_ORIENT_HORIZ, size, + GR_TEXT_HJUSTIFY_LEFT, GR_TEXT_VJUSTIFY_CENTER, width ); break; case WS_SIZESHEET: @@ -340,8 +1248,8 @@ void WinEDA_DrawFrame::TraceWorkSheet( wxDC* DC, BASE_SCREEN* screen, int line_w msg = WsItem->m_Legende; msg += Sheet->m_Name; DrawGraphicText( DrawPanel, DC, pos, Color, - msg, TEXT_ORIENT_HORIZ, size, - GR_TEXT_HJUSTIFY_LEFT, GR_TEXT_VJUSTIFY_CENTER, width ); + msg, TEXT_ORIENT_HORIZ, size, + GR_TEXT_HJUSTIFY_LEFT, GR_TEXT_VJUSTIFY_CENTER, width ); break; @@ -350,8 +1258,8 @@ void WinEDA_DrawFrame::TraceWorkSheet( wxDC* DC, BASE_SCREEN* screen, int line_w msg = WsItem->m_Legende; msg << screen->m_ScreenNumber << wxT( "/" ) << screen->m_NumberOfScreen; DrawGraphicText( DrawPanel, DC, pos, Color, - msg, TEXT_ORIENT_HORIZ, size, - GR_TEXT_HJUSTIFY_LEFT, GR_TEXT_VJUSTIFY_CENTER, width ); + msg, TEXT_ORIENT_HORIZ, size, + GR_TEXT_HJUSTIFY_LEFT, GR_TEXT_VJUSTIFY_CENTER, width ); break; case WS_FILENAME: @@ -362,18 +1270,18 @@ void WinEDA_DrawFrame::TraceWorkSheet( wxDC* DC, BASE_SCREEN* screen, int line_w msg = WsItem->m_Legende; msg << fname << wxT( "." ) << fext; DrawGraphicText( DrawPanel, DC, pos, Color, - msg, TEXT_ORIENT_HORIZ, size, - GR_TEXT_HJUSTIFY_LEFT, GR_TEXT_VJUSTIFY_CENTER, width ); + msg, TEXT_ORIENT_HORIZ, size, + GR_TEXT_HJUSTIFY_LEFT, GR_TEXT_VJUSTIFY_CENTER, width ); } - break; + break; case WS_FULLSHEETNAME: if( WsItem->m_Legende ) msg = WsItem->m_Legende; msg += GetScreenDesc(); DrawGraphicText( DrawPanel, DC, pos, Color, - msg, TEXT_ORIENT_HORIZ, size, - GR_TEXT_HJUSTIFY_LEFT, GR_TEXT_VJUSTIFY_CENTER, width ); + msg, TEXT_ORIENT_HORIZ, size, + GR_TEXT_HJUSTIFY_LEFT, GR_TEXT_VJUSTIFY_CENTER, width ); break; @@ -384,8 +1292,8 @@ void WinEDA_DrawFrame::TraceWorkSheet( wxDC* DC, BASE_SCREEN* screen, int line_w if( !msg.IsEmpty() ) { DrawGraphicText( DrawPanel, DC, pos, Color, - msg, TEXT_ORIENT_HORIZ, size, - GR_TEXT_HJUSTIFY_LEFT, GR_TEXT_VJUSTIFY_CENTER, width ); + msg, TEXT_ORIENT_HORIZ, size, + GR_TEXT_HJUSTIFY_LEFT, GR_TEXT_VJUSTIFY_CENTER, width ); UpperLimit = MAX( UpperLimit, WsItem->m_Posy + SIZETEXT ); } break; @@ -395,8 +1303,8 @@ void WinEDA_DrawFrame::TraceWorkSheet( wxDC* DC, BASE_SCREEN* screen, int line_w msg = WsItem->m_Legende; msg += screen->m_Title; DrawGraphicText( DrawPanel, DC, pos, Color, - msg, TEXT_ORIENT_HORIZ, size, - GR_TEXT_HJUSTIFY_LEFT, GR_TEXT_VJUSTIFY_CENTER, width ); + msg, TEXT_ORIENT_HORIZ, size, + GR_TEXT_HJUSTIFY_LEFT, GR_TEXT_VJUSTIFY_CENTER, width ); break; case WS_COMMENT1: @@ -406,8 +1314,8 @@ void WinEDA_DrawFrame::TraceWorkSheet( wxDC* DC, BASE_SCREEN* screen, int line_w if( !msg.IsEmpty() ) { DrawGraphicText( DrawPanel, DC, pos, Color, - msg, TEXT_ORIENT_HORIZ, size, - GR_TEXT_HJUSTIFY_LEFT, GR_TEXT_VJUSTIFY_CENTER, width ); + msg, TEXT_ORIENT_HORIZ, size, + GR_TEXT_HJUSTIFY_LEFT, GR_TEXT_VJUSTIFY_CENTER, width ); UpperLimit = MAX( UpperLimit, WsItem->m_Posy + SIZETEXT ); } break; @@ -419,8 +1327,8 @@ void WinEDA_DrawFrame::TraceWorkSheet( wxDC* DC, BASE_SCREEN* screen, int line_w if( !msg.IsEmpty() ) { DrawGraphicText( DrawPanel, DC, pos, Color, - msg, TEXT_ORIENT_HORIZ, size, - GR_TEXT_HJUSTIFY_LEFT, GR_TEXT_VJUSTIFY_CENTER, width ); + msg, TEXT_ORIENT_HORIZ, size, + GR_TEXT_HJUSTIFY_LEFT, GR_TEXT_VJUSTIFY_CENTER, width ); UpperLimit = MAX( UpperLimit, WsItem->m_Posy + SIZETEXT ); } break; @@ -432,8 +1340,8 @@ void WinEDA_DrawFrame::TraceWorkSheet( wxDC* DC, BASE_SCREEN* screen, int line_w if( !msg.IsEmpty() ) { DrawGraphicText( DrawPanel, DC, pos, Color, - msg, TEXT_ORIENT_HORIZ, size, - GR_TEXT_HJUSTIFY_LEFT, GR_TEXT_VJUSTIFY_CENTER, width ); + msg, TEXT_ORIENT_HORIZ, size, + GR_TEXT_HJUSTIFY_LEFT, GR_TEXT_VJUSTIFY_CENTER, width ); UpperLimit = MAX( UpperLimit, WsItem->m_Posy + SIZETEXT ); } break; @@ -445,8 +1353,8 @@ void WinEDA_DrawFrame::TraceWorkSheet( wxDC* DC, BASE_SCREEN* screen, int line_w if( !msg.IsEmpty() ) { DrawGraphicText( DrawPanel, DC, pos, Color, - msg, TEXT_ORIENT_HORIZ, size, - GR_TEXT_HJUSTIFY_LEFT, GR_TEXT_VJUSTIFY_CENTER, width ); + msg, TEXT_ORIENT_HORIZ, size, + GR_TEXT_HJUSTIFY_LEFT, GR_TEXT_VJUSTIFY_CENTER, width ); UpperLimit = MAX( UpperLimit, WsItem->m_Posy + SIZETEXT ); } break; @@ -458,16 +1366,16 @@ void WinEDA_DrawFrame::TraceWorkSheet( wxDC* DC, BASE_SCREEN* screen, int line_w case WS_LEFT_SEGMENT: WS_MostUpperLine.m_Posy = WS_MostUpperLine.m_Endy = - WS_MostLeftLine.m_Posy = UpperLimit; + WS_MostLeftLine.m_Posy = UpperLimit; pos.y = (refy - WsItem->m_Posy) * scale; case WS_SEGMENT: xg = Sheet->m_Size.x - - GRID_REF_W - Sheet->m_RightMargin - WsItem->m_Endx; + GRID_REF_W - Sheet->m_RightMargin - WsItem->m_Endx; yg = Sheet->m_Size.y - - GRID_REF_W - Sheet->m_BottomMargin - WsItem->m_Endy; + GRID_REF_W - Sheet->m_BottomMargin - WsItem->m_Endy; GRLine( &DrawPanel->m_ClipBox, DC, pos.x, pos.y, - xg * scale, yg * scale, width, Color ); + xg * scale, yg * scale, width, Color ); break; } } @@ -494,7 +1402,7 @@ wxString WinEDA_DrawFrame::GetXYSheetReferences( BASE_SCREEN* aScreen, const wxP if( Sheet == NULL ) { DisplayError( this, - wxT( "WinEDA_DrawFrame::GetXYSheetReferences() error: NULL Sheet" ) ); + wxT( "WinEDA_DrawFrame::GetXYSheetReferences() error: NULL Sheet" ) ); return msg; } diff --git a/common/zoom.cpp b/common/zoom.cpp index 4940ab1265..9ef22dde7f 100644 --- a/common/zoom.cpp +++ b/common/zoom.cpp @@ -51,11 +51,11 @@ void WinEDA_DrawFrame::PutOnGrid( wxPoint* coord ) if( !GetBaseScreen()->m_UserGridIsON ) { - int tmp = (int) round( coord->x / grid_size.x ); - coord->x = (int) round( tmp * grid_size.x ); + int tmp = wxRound( coord->x / grid_size.x ); + coord->x = wxRound( tmp * grid_size.x ); - tmp = (int) round( coord->y / grid_size.y ); - coord->y = (int) round ( tmp * grid_size.y ); + tmp = wxRound( coord->y / grid_size.y ); + coord->y = wxRound ( tmp * grid_size.y ); } } @@ -180,7 +180,7 @@ void WinEDA_DrawFrame::OnZoom( wxCommandEvent& event ) Recadre_Trace( true ); } - Affiche_Status_Box(); + UpdateStatusBar(); } void WinEDA_DrawPanel::OnPopupGridSelect( wxCommandEvent& event ) diff --git a/cvpcb/CMakeLists.txt b/cvpcb/CMakeLists.txt index 60099f01cc..3e5a40caa0 100644 --- a/cvpcb/CMakeLists.txt +++ b/cvpcb/CMakeLists.txt @@ -29,15 +29,15 @@ set(CVPCB_SRCS writenetlistpcbnew.cpp) set(CVPCB_EXTRA_SRCS - ../pcbnew/class_board_item.cpp - ../pcbnew/class_drawsegment.cpp - ../pcbnew/class_edge_mod.cpp - ../pcbnew/class_equipot.cpp - ../pcbnew/class_module.cpp - ../pcbnew/class_text_mod.cpp - ../pcbnew/class_track.cpp +# ../pcbnew/class_board_item.cpp +# ../pcbnew/class_drawsegment.cpp +# ../pcbnew/class_edge_mod.cpp +# ../pcbnew/class_equipot.cpp +# ../pcbnew/class_module.cpp +# ../pcbnew/class_text_mod.cpp ../pcbnew/ioascii.cpp - ../pcbnew/tracemod.cpp) +# ../pcbnew/tracemod.cpp +) if(WIN32) if(MINGW) @@ -59,7 +59,7 @@ endif(APPLE) add_executable(cvpcb WIN32 MACOSX_BUNDLE ${CVPCB_SRCS} ${CVPCB_EXTRA_SRCS} ${CVPCB_RESOURCES}) -target_link_libraries(cvpcb 3d-viewer common polygon bitmaps kbool ${OPENGL_LIBRARIES} ${wxWidgets_LIBRARIES}) +target_link_libraries(cvpcb 3d-viewer common pcbcommon polygon bitmaps kbool ${OPENGL_LIBRARIES} ${wxWidgets_LIBRARIES}) install(TARGETS cvpcb DESTINATION ${KICAD_BIN} diff --git a/cvpcb/autosel.cpp b/cvpcb/autosel.cpp index a1bb9f1b21..17c9556bb1 100644 --- a/cvpcb/autosel.cpp +++ b/cvpcb/autosel.cpp @@ -1,6 +1,6 @@ - /**********************/ - /* CVPCB: autosel.cpp */ - /**********************/ +/**********************/ +/* CVPCB: autosel.cpp */ +/**********************/ /* Routines de selection automatique des modules */ @@ -8,6 +8,7 @@ #include "common.h" #include "confirm.h" #include "gestfich.h" +#include "appl_wxstruct.h" #include "cvpcb.h" #include "protos.h" @@ -18,155 +19,184 @@ class AUTOMODULE { public: - int m_Type; - AUTOMODULE * Pnext; - wxString m_Name; - wxString m_LibName; - wxString m_Library; + int m_Type; + AUTOMODULE* Pnext; + wxString m_Name; + wxString m_LibName; + wxString m_Library; - AUTOMODULE() { m_Type = 0; Pnext = NULL; } -} ; + AUTOMODULE() { m_Type = 0; Pnext = NULL; } +}; /* routines locales : */ -static int auto_select(WinEDA_CvpcbFrame * frame, STORECMP * Cmp, AUTOMODULE * BaseListeMod); -static void auto_associe(WinEDA_CvpcbFrame * frame); +static int auto_select( WinEDA_CvpcbFrame* frame, + STORECMP* Cmp, + AUTOMODULE* BaseListeMod ); +static void auto_associe( WinEDA_CvpcbFrame* frame ); - /*************************************************************/ -void WinEDA_CvpcbFrame::AssocieModule(wxCommandEvent& event) /*************************************************************/ +void WinEDA_CvpcbFrame::AssocieModule( wxCommandEvent& event ) +/*************************************************************/ + /* Fonction liee au boutton "Auto" - Lance l'association automatique modules/composants -*/ + * Lance l'association automatique modules/composants + */ { - auto_associe(this); + auto_associe( this ); } + /**************************************************/ -static void auto_associe(WinEDA_CvpcbFrame * frame) +static void auto_associe( WinEDA_CvpcbFrame* frame ) /**************************************************/ { -unsigned ii, j, k; -wxString EquivFileName, msg; -char Line[1024]; -FILE *fichierstf ; /* sert en lecture des differents fichiers *.STF */ -AUTOMODULE * ItemModule,* NextMod; -AUTOMODULE * BaseListeMod = NULL; -STORECMP * Component; + wxFileName fn; + unsigned ii, j, k; + wxString msg, tmp; + char Line[1024]; + FILE* file; + AUTOMODULE* ItemModule, * NextMod; + AUTOMODULE* BaseListeMod = NULL; + STORECMP* Component; + int nb_correspondances = 0; -int nb_correspondances = 0; + if( nbcomp <= 0 ) + return; - if( nbcomp <= 0 ) return; + /* recherche des equivalences a travers les fichiers possibles */ + for( ii = 0; ii < g_ListName_Equ.GetCount(); ii++ ) + { + fn = g_ListName_Equ[ii]; + fn.SetExt( EquivFileExtension ); - /* recherche des equivalences a travers les fichiers possibles */ - for( ii= 0 ; ii < g_ListName_Equ.GetCount(); ii++) - { - /* Calcul du nom complet avec son chemin */ - EquivFileName = MakeFileName(g_RealLibDirBuffer,g_ListName_Equ[ii],g_EquivExtBuffer); + tmp = wxGetApp().GetLibraryPathList().FindValidPath( fn.GetFullName() ); - if ( (fichierstf = wxFopen(EquivFileName, wxT("rt"))) == 0) - { - msg.Printf( _("Library: <%s> not found"),EquivFileName.GetData()); - DisplayError(frame, msg,10); - continue ; - } + if( !tmp ) + { + msg.Printf( _( "Footprint alias library file <%s> could not be " \ + "found in the default search paths." ), + fn.GetFullName().c_str() ); + wxMessageBox( msg, titleLibLoadError, wxOK | wxICON_ERROR ); + continue; + } - /* lecture fichier n */ - while ( fgets(Line,79,fichierstf) != 0 ) - { - /* elimination des lignes vides */ - for (j = 0 ; j < 40 ; j++ ) - { - if (Line[j] == 0 ) goto fin_de_while ; - if (Line[j] == QUOTE ) break ; - } + file = wxFopen( tmp, wxT( "rt" ) ); - ItemModule = new AUTOMODULE(); - ItemModule->Pnext = BaseListeMod; - BaseListeMod = ItemModule; + if( file == NULL ) + { + msg.Printf( _( "Error opening alias library <%s>." ), tmp.c_str() ); + wxMessageBox( msg, titleLibLoadError, wxOK | wxICON_ERROR ); + continue; + } - /* stockage du composant ( 'namecmp' 'namelib') - name et namelib */ - for ( j++ ; j < 40 ; j++, k++) - { - if ( Line[j] == QUOTE) break ; - ItemModule->m_Name.Append(Line[j]); - } - j++ ; - for ( ; j < 80 ; ) if (Line[j++] == QUOTE) break ; - for (; ; j++) - { - if (Line[j] == QUOTE) break ; - ItemModule->m_LibName.Append(Line[j]); - } - nb_correspondances++ ; - fin_de_while:; - } - fclose(fichierstf) ; + /* lecture fichier n */ + while( fgets( Line, 79, file ) != 0 ) + { + /* elimination des lignes vides */ + for( j = 0; j < 40; j++ ) + { + if( Line[j] == 0 ) + goto fin_de_while; + if( Line[j] == QUOTE ) + break; + } - /* Affichage Statistiques */ - msg.Printf(_("%d equivalences"),nb_correspondances); - frame->SetStatusText(msg, 0); - } + ItemModule = new AUTOMODULE(); + ItemModule->Pnext = BaseListeMod; + BaseListeMod = ItemModule; - Component = g_BaseListeCmp; - for ( ii = 0; Component != NULL; Component = Component->Pnext, ii++ ) - { - frame->m_ListCmp->SetSelection(ii,TRUE); - if( Component->m_Module.IsEmpty() ) - auto_select(frame, Component, BaseListeMod); - } + /* stockage du composant ( 'namecmp' 'namelib') + * name et namelib */ + for( j++; j < 40; j++, k++ ) + { + if( Line[j] == QUOTE ) + break; + ItemModule->m_Name.Append( Line[j] ); + } - /* Liberation memoire */ - for( ItemModule = BaseListeMod; ItemModule != NULL; ItemModule = NextMod) - { - NextMod = ItemModule->Pnext; delete ItemModule; - } - BaseListeMod = NULL; + j++; + for( ; j < 80; ) + if( Line[j++] == QUOTE ) + break; + + for( ; ; j++ ) + { + if( Line[j] == QUOTE ) + break; + ItemModule->m_LibName.Append( Line[j] ); + } + + nb_correspondances++; +fin_de_while:; + } + + fclose( file ); + + /* Affichage Statistiques */ + msg.Printf( _( "%d equivalences" ), nb_correspondances ); + frame->SetStatusText( msg, 0 ); + } + + Component = g_BaseListeCmp; + for( ii = 0; Component != NULL; Component = Component->Pnext, ii++ ) + { + frame->m_ListCmp->SetSelection( ii, TRUE ); + if( Component->m_Module.IsEmpty() ) + auto_select( frame, Component, BaseListeMod ); + } + + /* Liberation memoire */ + for( ItemModule = BaseListeMod; ItemModule != NULL; ItemModule = NextMod ) + { + NextMod = ItemModule->Pnext; delete ItemModule; + } + + BaseListeMod = NULL; } /****************************************************************/ -static int auto_select(WinEDA_CvpcbFrame * frame, STORECMP * Cmp, - AUTOMODULE * BaseListeMod) +static int auto_select( WinEDA_CvpcbFrame* frame, STORECMP* Cmp, + AUTOMODULE* BaseListeMod ) /****************************************************************/ /* associe automatiquement composant et Module - Retourne; - 0 si OK - 1 si module specifie non trouve en liste librairie - 2 si pas de module specifie dans la liste des equivalences -*/ + * Retourne; + * 0 si OK + * 1 si module specifie non trouve en liste librairie + * 2 si pas de module specifie dans la liste des equivalences + */ { -AUTOMODULE * ItemModule; -STOREMOD * Module; -wxString msg; + AUTOMODULE* ItemModule; + STOREMOD* Module; + wxString msg; - /* examen de la liste des correspondances */ - ItemModule = BaseListeMod; - for ( ; ItemModule != NULL; ItemModule = ItemModule->Pnext ) - { - if ( ItemModule->m_Name.CmpNoCase(Cmp->m_Valeur) != 0) continue; + /* examen de la liste des correspondances */ + ItemModule = BaseListeMod; + for( ; ItemModule != NULL; ItemModule = ItemModule->Pnext ) + { + if( ItemModule->m_Name.CmpNoCase( Cmp->m_Valeur ) != 0 ) + continue; - /* Correspondance trouvee, recherche nom module dans la liste des - modules disponibles en librairie */ - Module= g_BaseListePkg; - for ( ;Module != NULL; Module = Module->Pnext ) - { + /* Correspondance trouvee, recherche nom module dans la liste des + * modules disponibles en librairie */ + Module = g_BaseListePkg; + for( ; Module != NULL; Module = Module->Pnext ) + { + if( ItemModule->m_LibName.CmpNoCase( Module->m_Module ) == 0 ) + { + frame->SetNewPkg( Module->m_Module ); + return 0; + } + } - if( ItemModule->m_LibName.CmpNoCase(Module->m_Module) == 0 ) - { /* empreinte trouv‚e */ - frame->SetNewPkg(Module->m_Module); - return(0); - } - } - msg.Printf( - _("Component %s: Footprint %s not found in libraries"), - Cmp->m_Valeur.GetData(), ItemModule->m_LibName.GetData()); - DisplayError(frame, msg, 10); - return( 2 ); - } - return(1); + msg.Printf( _( "Component %s: Footprint %s not found in libraries" ), + Cmp->m_Valeur.GetData(), ItemModule->m_LibName.GetData() ); + DisplayError( frame, msg, 10 ); + return 2; + } + + return 1; } - diff --git a/cvpcb/cfg.cpp b/cvpcb/cfg.cpp index 93c629b939..d7c4107628 100644 --- a/cvpcb/cfg.cpp +++ b/cvpcb/cfg.cpp @@ -30,20 +30,35 @@ void Read_Config( const wxString& FileName ) * le chemin de l'executable cvpcb.exe doit etre dans BinDir */ { - wxString FullFileName = FileName; + wxFileName fn = FileName; /* Init des valeurs par defaut */ g_LibName_List.Clear(); g_ListName_Equ.Clear(); - wxGetApp().ReadProjectConfig( FullFileName, + if( fn.GetExt() != ProjectFileExtension ) + fn.SetExt( ProjectFileExtension ); + + if( wxGetApp().GetLibraryPathList().Index( g_UserLibDirBuffer ) != wxNOT_FOUND ) + { + wxLogDebug( wxT( "Removing path <%s> to library path search list." ), + g_UserLibDirBuffer.c_str() ); + wxGetApp().GetLibraryPathList().Remove( g_UserLibDirBuffer ); + } + + wxGetApp().ReadProjectConfig( fn.GetFullPath(), GROUP, ParamCfgList, FALSE ); - if( NetInExtBuffer.IsEmpty() ) - NetInExtBuffer = wxT( ".net" ); + if( g_NetlistFileExtension.IsEmpty() ) + g_NetlistFileExtension = wxT( "net" ); - /* Inits autres variables */ - SetRealLibraryPath( wxT( "modules" ) ); + if( wxFileName::DirExists( g_UserLibDirBuffer ) + && wxGetApp().GetLibraryPathList().Index( g_UserLibDirBuffer ) == wxNOT_FOUND ) + { + wxLogDebug( wxT( "Adding path <%s> to library path search list." ), + g_UserLibDirBuffer.c_str() ); + wxGetApp().GetLibraryPathList().Add( g_UserLibDirBuffer ); + } } @@ -55,36 +70,22 @@ void WinEDA_CvpcbFrame::Update_Config( wxCommandEvent& event ) * la vraie fonction de sauvegarde de la config */ { - Save_Config( this ); + Save_Config( this, m_NetlistFileName.GetFullPath() ); } -/************************************/ -void Save_Config( wxWindow* parent ) -/************************************/ -/* enregistrement de la config */ +void Save_Config( wxWindow* parent, const wxString& fileName ) { - wxString path, FullFileName; + wxFileName fn = fileName; - wxString mask( wxT( "*" ) ); + fn.SetExt( ProjectFileExtension ); - FullFileName = FFileName; - ChangeFileNameExt( FullFileName, g_Prj_Config_Filename_ext ); + wxFileDialog dlg( parent, _( "Save Project File" ), fn.GetPath(), + fn.GetFullName(), ProjectFileWildcard, wxFD_SAVE ); - path = wxGetCwd(); - FullFileName = EDA_FileSelector( _( "Save preferences" ), - path, /* Chemin par defaut */ - FullFileName, /* nom fichier par defaut */ - g_Prj_Config_Filename_ext, /* extension par defaut */ - mask, /* Masque d'affichage */ - parent, - wxFD_SAVE, - TRUE - ); - - if( FullFileName.IsEmpty() ) + if( dlg.ShowModal() == wxID_CANCEL ) return; /* ecriture de la configuration */ - wxGetApp().WriteProjectConfig( FullFileName, GROUP, ParamCfgList ); + wxGetApp().WriteProjectConfig( dlg.GetPath(), GROUP, ParamCfgList ); } diff --git a/cvpcb/cfg.h b/cvpcb/cfg.h index 5a3f7a3af6..c3c18031ab 100644 --- a/cvpcb/cfg.h +++ b/cvpcb/cfg.h @@ -2,10 +2,6 @@ /** cfg.h : configuration: definition des structures **/ /*******************************************************/ -#ifndef eda_global -#define eda_global extern -#endif - #include "param_config.h" #define INSETUP TRUE @@ -40,7 +36,7 @@ static PARAM_CFG_LIBNAME_LIST EquivNameBufCfg static PARAM_CFG_WXSTRING NetInExtBufCfg ( wxT("NetIExt"), /* identification */ - &NetInExtBuffer + &g_NetlistFileExtension ); static PARAM_CFG_WXSTRING NetDirBufCfg diff --git a/cvpcb/cvframe.cpp b/cvpcb/cvframe.cpp index 991f69bb3c..600f36f3b5 100644 --- a/cvpcb/cvframe.cpp +++ b/cvpcb/cvframe.cpp @@ -23,104 +23,6 @@ #define FRAME_MIN_SIZE_X 450 #define FRAME_MIN_SIZE_Y 300 -/*******************************************************/ -/* Constructeur de WinEDA_CvpcbFrame: la fenetre generale */ -/*******************************************************/ -WinEDA_CvpcbFrame::WinEDA_CvpcbFrame( const wxString& title, long style ) : - WinEDA_BasicFrame( NULL, CVPCB_FRAME, title, wxDefaultPosition, - wxDefaultSize, style ) -{ - m_FrameName = wxT( "CvpcbFrame" ); - - //m_AboutTitle = g_CvpcbAboutTitle; - m_ListCmp = NULL; - m_FootprintList = NULL; - DrawFrame = NULL; - m_HToolBar = NULL; - - // Give an icon - #ifdef __WINDOWS__ - SetIcon( wxICON( a_icon_cvpcb ) ); - #else - SetIcon( wxICON( icon_cvpcb ) ); - #endif - - SetFont( *g_StdFont ); - - SetAutoLayout( TRUE ); - - GetSettings(); - if( m_FrameSize.x < FRAME_MIN_SIZE_X ) - m_FrameSize.x = FRAME_MIN_SIZE_X; - if( m_FrameSize.y < FRAME_MIN_SIZE_Y ) - m_FrameSize.y = FRAME_MIN_SIZE_Y; - - // create the status bar - int dims[3] = { -1, -1, 250 }; - CreateStatusBar( 3 ); - SetStatusWidths( 3, dims ); - ReCreateMenuBar(); - ReCreateHToolbar(); - - // Creation des listes de modules disponibles et des composants du schema - // Create child subwindows. - BuildCmpListBox(); - BuildFootprintListBox(); - - /* Creation des contraintes de dimension de la fenetre d'affichage des composants - * du schema */ - wxLayoutConstraints* linkpos = new wxLayoutConstraints; - linkpos->top.SameAs( this, wxTop ); - linkpos->bottom.SameAs( this, wxBottom ); - linkpos->left.SameAs( this, wxLeft ); - linkpos->width.PercentOf( this, wxWidth, 66 ); - if( m_ListCmp ) - m_ListCmp->SetConstraints( linkpos ); - - /* Creation des contraintes de dimension de la fenetre d'affichage des modules - * de la librairie */ - linkpos = new wxLayoutConstraints; - linkpos->top.SameAs( m_ListCmp, wxTop ); - linkpos->bottom.SameAs( m_ListCmp, wxBottom ); - linkpos->right.SameAs( this, wxRight ); - linkpos->left.SameAs( m_ListCmp, wxRight ); - if( m_FootprintList ) - m_FootprintList->SetConstraints( linkpos ); - - // Set minimal frame width and height - SetSizeHints( FRAME_MIN_SIZE_X, - FRAME_MIN_SIZE_Y, -1, -1, -1, -1 ); - - // Framesize and position - SetSize( m_FramePos.x, - m_FramePos.y, - m_FrameSize.x, - m_FrameSize.y ); -} - - -/******************************************/ -WinEDA_CvpcbFrame::~WinEDA_CvpcbFrame() -/******************************************/ -{ - wxConfig* config = wxGetApp().m_EDA_Config; - - if( config ) - { - int state = m_HToolBar->GetToolState( - ID_CVPCB_FOOTPRINT_DISPLAY_FILTERED_LIST ); - config->Write( wxT( FILTERFOOTPRINTKEY ), state ); - } -} - - -/************************************************/ -void WinEDA_CvpcbFrame::OnSize( wxSizeEvent& event ) -/************************************************/ -{ - event.Skip(); -} - /*************************************/ /* Event table for WinEDA_CvpcbFrame */ @@ -194,6 +96,98 @@ BEGIN_EVENT_TABLE( WinEDA_CvpcbFrame, wxFrame ) END_EVENT_TABLE() +/*******************************************************/ +/* Constructeur de WinEDA_CvpcbFrame: la fenetre generale */ +/*******************************************************/ +WinEDA_CvpcbFrame::WinEDA_CvpcbFrame( const wxString& title, long style ) : + WinEDA_BasicFrame( NULL, CVPCB_FRAME, title, wxDefaultPosition, + wxDefaultSize, style ) +{ + m_FrameName = wxT( "CvpcbFrame" ); + + m_ListCmp = NULL; + m_FootprintList = NULL; + DrawFrame = NULL; + m_HToolBar = NULL; + + // Give an icon + #ifdef __WINDOWS__ + SetIcon( wxICON( a_icon_cvpcb ) ); + #else + SetIcon( wxICON( icon_cvpcb ) ); + #endif + + SetAutoLayout( TRUE ); + + LoadSettings(); + if( m_FrameSize.x < FRAME_MIN_SIZE_X ) + m_FrameSize.x = FRAME_MIN_SIZE_X; + if( m_FrameSize.y < FRAME_MIN_SIZE_Y ) + m_FrameSize.y = FRAME_MIN_SIZE_Y; + + // create the status bar + int dims[3] = { -1, -1, 250 }; + CreateStatusBar( 3 ); + SetStatusWidths( 3, dims ); + ReCreateMenuBar(); + ReCreateHToolbar(); + + // Creation des listes de modules disponibles et des composants du schema + // Create child subwindows. + BuildCmpListBox(); + BuildFootprintListBox(); + + /* Creation des contraintes de dimension de la fenetre d'affichage des composants + * du schema */ + wxLayoutConstraints* linkpos = new wxLayoutConstraints; + linkpos->top.SameAs( this, wxTop ); + linkpos->bottom.SameAs( this, wxBottom ); + linkpos->left.SameAs( this, wxLeft ); + linkpos->width.PercentOf( this, wxWidth, 66 ); + if( m_ListCmp ) + m_ListCmp->SetConstraints( linkpos ); + + /* Creation des contraintes de dimension de la fenetre d'affichage des modules + * de la librairie */ + linkpos = new wxLayoutConstraints; + linkpos->top.SameAs( m_ListCmp, wxTop ); + linkpos->bottom.SameAs( m_ListCmp, wxBottom ); + linkpos->right.SameAs( this, wxRight ); + linkpos->left.SameAs( m_ListCmp, wxRight ); + if( m_FootprintList ) + m_FootprintList->SetConstraints( linkpos ); + + // Set minimal frame width and height + SetSizeHints( FRAME_MIN_SIZE_X, FRAME_MIN_SIZE_Y, -1, -1, -1, -1 ); + + // Framesize and position + SetSize( m_FramePos.x, m_FramePos.y, m_FrameSize.x, m_FrameSize.y ); +} + + +/******************************************/ +WinEDA_CvpcbFrame::~WinEDA_CvpcbFrame() +/******************************************/ +{ + wxConfig* config = wxGetApp().m_EDA_Config; + + if( config ) + { + int state = m_HToolBar->GetToolState( + ID_CVPCB_FOOTPRINT_DISPLAY_FILTERED_LIST ); + config->Write( wxT( FILTERFOOTPRINTKEY ), state ); + } +} + + +/************************************************/ +void WinEDA_CvpcbFrame::OnSize( wxSizeEvent& event ) +/************************************************/ +{ + event.Skip(); +} + + /******************************************************/ void WinEDA_CvpcbFrame::OnQuit( wxCommandEvent& event ) /******************************************************/ @@ -212,7 +206,7 @@ void WinEDA_CvpcbFrame::OnCloseWindow( wxCloseEvent& Event ) { unsigned ii; wxMessageDialog dialog( this, - _( "Net and component list modified.\n Save before exit ?" ), + _( "Net and component list modified.\nSave before exit ?" ), _( "Confirmation" ), wxYES_NO | wxCANCEL | wxICON_EXCLAMATION | wxYES_DEFAULT ); @@ -252,9 +246,9 @@ void WinEDA_CvpcbFrame::OnCloseWindow( wxCloseEvent& Event ) wxGetApp().m_HtmlCtrl->GetFrame()->Close( TRUE ); } - if( !NetInNameBuffer.IsEmpty() ) + if( m_NetlistFileName.IsOk() ) { - SetLastProject( NetInNameBuffer ); + SetLastProject( m_NetlistFileName.GetFullPath() ); } FreeMemoryModules(); @@ -345,7 +339,7 @@ void WinEDA_CvpcbFrame::ToPreviousNA( wxCommandEvent& event ) void WinEDA_CvpcbFrame::SaveQuitCvpcb( wxCommandEvent& event ) /**********************************************************/ { - if( SaveNetList( wxEmptyString ) > 0 ) + if( SaveNetList( wxEmptyString ) > 0 ) { modified = 0; Close( TRUE ); @@ -384,37 +378,56 @@ void WinEDA_CvpcbFrame::DelAssociations( wxCommandEvent& event ) } -/***********************************************************/ -void WinEDA_CvpcbFrame::LoadNetList( wxCommandEvent& event ) -/***********************************************************/ - -/* Called when click on Load Netlist button or by menu files - * Read a netlist slected by user +/* + * Called when click on Load Netlist button or by file history menu entries + * Read a netlist slected by user */ +void WinEDA_CvpcbFrame::LoadNetList( wxCommandEvent& event ) { - bool newfile; - wxString oldfilename; - wxString fullfilename; - int id = event.GetId(); + wxString oldPath; + wxFileName newFileName; + int id = event.GetId(); - // Get a filename from history. if fullfilename is void, - // a name will be asked to user, later. - if ( id >= wxID_FILE1 && id <= wxID_FILE9 ) // Called by clicking on an old filename in file history - fullfilename = GetFileFromHistory( event.GetId(), _( "Netlist" ) ); - - if( !NetInNameBuffer.IsEmpty() ) + if ( id >= wxID_FILE1 && id <= wxID_FILE9 ) { - oldfilename = NetInNameBuffer; + newFileName = GetFileFromHistory( id, _( "Netlist" ) ); + } + else + { + newFileName = wxFileName( wxGetCwd(), _( "unnamed" ), wxT( "net" ) ); + + wxFileDialog dlg( this, _( "Open Net List" ), newFileName.GetPath(), + newFileName.GetFullName(), NetlistFileWildcard, + wxFD_OPEN | wxFD_FILE_MUST_EXIST | wxFD_CHANGE_DIR ); + + if( dlg.ShowModal() == wxID_CANCEL ) + return; + + newFileName = dlg.GetPath(); } - // Read the file fullfilename. If fullfilename is void, - // The user will be prompted for a filename. - // newfile = true if a file is read. - newfile = ReadInputNetList( fullfilename ); + if( newFileName == m_NetlistFileName ) + return; - if( newfile && !oldfilename.IsEmpty() ) + if( m_NetlistFileName.DirExists() ) + oldPath = m_NetlistFileName.GetPath(); + + /* Update the library search path list. */ + if( wxGetApp().GetLibraryPathList().Index( oldPath ) != wxNOT_FOUND ) + wxGetApp().GetLibraryPathList().Remove( oldPath ); + wxGetApp().GetLibraryPathList().Insert( newFileName.GetPath(), 0 ); + m_NetlistFileName = newFileName; + + if( ReadNetList() ) { - SetLastProject( NetInNameBuffer ); + SetLastProject( m_NetlistFileName.GetFullPath() ); + + SetTitle( wxGetApp().GetTitle() + wxT( " " ) + GetBuildVersion() + + wxT( " " ) + m_NetlistFileName.GetFullPath() ); + } + else + { + SetTitle( wxGetApp().GetTitle() + wxT( " " ) + GetBuildVersion() ); } ReCreateMenuBar(); @@ -497,11 +510,12 @@ void WinEDA_CvpcbFrame::SetLanguage( wxCommandEvent& event ) void WinEDA_CvpcbFrame::DisplayDocFile( wxCommandEvent& event ) /*************************************************************/ { - wxString DocModuleFileName, fullfilename; + wxASSERT( wxGetApp().m_EDA_CommonConfig != NULL ); - DocModuleFileName = wxGetApp().m_EDA_CommonConfig->Read( - DOC_FOOTPRINTS_LIST_KEY, - DEFAULT_FOOTPRINTS_LIST_FILENAME ); + wxString DocModuleFileName, fullfilename; + wxConfig* cfg = wxGetApp().m_EDA_CommonConfig; + DocModuleFileName = cfg->Read( DOC_FOOTPRINTS_LIST_KEY, + DEFAULT_FOOTPRINTS_LIST_FILENAME ); if( wxIsAbsolutePath( DocModuleFileName ) ) fullfilename = DocModuleFileName; else diff --git a/cvpcb/cvpcb.cpp b/cvpcb/cvpcb.cpp index 1183b0b8cd..be93ad4c5f 100644 --- a/cvpcb/cvpcb.cpp +++ b/cvpcb/cvpcb.cpp @@ -1,8 +1,6 @@ /*******************/ /* File: cvpcb.cpp */ /*******************/ -#define MAIN -#define eda_global #include "fctsys.h" #include "appl_wxstruct.h" @@ -19,7 +17,36 @@ #include -wxString g_Main_Title = wxT( "CVpcb" ); + +/* Constant string definitions for CvPcb */ +const wxString ComponentFileExtension( wxT( "cmp" ) ); +const wxString RetroFileExtension( wxT( "stf" ) ); +const wxString EquivFileExtension( wxT( "equ" ) ); + +/* TODO: What is a stuff file??? Please fix this wild card in English if + * you know. */ +const wxString RetroFileWildcard( _( "Kicad component list files (*.stf)|*.stf" ) ); +const wxString EquivFileWildcard( _( "Kicad footprint alias files (*.equ)|*.equ" ) ); + +const wxString titleLibLoadError( _( "Library Load Error" ) ); + + +/* Global variables used in CVPcb. */ +int g_FlagEESchema; +int Rjustify; +int modified; +int nbcomp; +int nblib; +int composants_non_affectes; + +STOREMOD* g_BaseListePkg = NULL; +STORECMP* g_BaseListeCmp = NULL; + +wxString g_UserNetDirBuffer; // Netlist path (void = current working directory) +wxString g_NetlistFileExtension; + +wxArrayString g_ListName_Equ; // list of .equ files to load + // Create a new application object IMPLEMENT_APP( WinEDA_App ) @@ -32,11 +59,12 @@ IMPLEMENT_APP( WinEDA_App ) bool WinEDA_App::OnInit() { + wxFileName fn; wxString msg; wxString currCWD = wxGetCwd(); WinEDA_CvpcbFrame* frame = NULL; - InitEDA_Appl( wxT( "cvpcb" ) ); + InitEDA_Appl( wxT( "CVpcb" ) ); if( m_Checker && m_Checker->IsAnotherRunning() ) { @@ -51,17 +79,14 @@ bool WinEDA_App::OnInit() if( argc > 1 ) { - NetInNameBuffer = argv[1]; - NetNameBuffer = argv[1]; + wxLogDebug( wxT( "CvPcb opening file <%s>" ), argv[1] ); + fn = argv[1]; + wxSetWorkingDirectory( fn.GetPath() ); } - if( !NetInNameBuffer.IsEmpty() ) - wxSetWorkingDirectory( wxPathOnly( NetInNameBuffer ) ); g_DrawBgColor = BLACK; - Read_Config( NetInNameBuffer ); - - wxString Title = g_Main_Title + wxT( " " ) + GetBuildVersion(); + wxString Title = GetTitle() + wxT( " " ) + GetBuildVersion(); frame = new WinEDA_CvpcbFrame( Title ); msg.Printf( wxT( "Modules: %d" ), nblib ); @@ -70,25 +95,28 @@ bool WinEDA_App::OnInit() // Show the frame SetTopWindow( frame ); - frame->Show( TRUE ); + Read_Config( fn.GetFullPath() ); - listlib(); + frame->Show( TRUE ); frame->BuildFootprintListBox(); - if( !NetInNameBuffer.IsEmpty() ) /* nom de fichier passe a la commande */ + if( fn.IsOk() && fn.FileExists() ) { - FFileName = MakeFileName( NetDirBuffer, - NetInNameBuffer, NetInExtBuffer ); + frame->m_NetlistFileName = fn; - frame->ReadNetListe(); - } - else /* Mise a jour du titre de la fenetre principale */ - { - wxString Title = g_Main_Title + wxT( " " ) + GetBuildVersion(); - msg.Printf( wxT( "%s {%s%c} [no file]" ), - Title.GetData(), wxGetCwd().GetData(), DIR_SEP ); - frame->SetTitle( msg ); + if( frame->ReadNetList() ) + { + g_NetlistFileExtension = fn.GetExt(); + return true; + } } - return TRUE; + listlib(); + g_NetlistFileExtension = wxT( "net" ); + frame->m_NetlistFileName.Clear(); + frame->SetTitle( GetTitle() + wxT( " " ) + GetBuildVersion() + + wxGetCwd() + wxFileName::GetPathSeparator() + + _( " [no file]" ) ); + + return true; } diff --git a/cvpcb/cvpcb.h b/cvpcb/cvpcb.h index 1f1911e02e..9ac24c15dc 100644 --- a/cvpcb/cvpcb.h +++ b/cvpcb/cvpcb.h @@ -2,23 +2,28 @@ /* CVPCB : declaration des variables globales */ /**********************************************/ +#ifndef __CVPCB_H__ +#define __CVPCB_H__ -#ifndef eda_global -#define eda_global extern -#endif - -#include "pcbnew.h" +#include "pcbcommon.h" // config for footprints doc file acces #define DOC_FOOTPRINTS_LIST_KEY wxT("footprints_doc_file") #define DEFAULT_FOOTPRINTS_LIST_FILENAME wxT("footprints_doc/footprints.pdf") - // Define print format to display a schematic component line #define CMP_FORMAT wxT( "%3d %8s - %16s : %-.32s" ) #define FILTERFOOTPRINTKEY "FilterFootprint" +/* Types de netliste: */ +#define TYPE_NON_SPECIFIE 0 +#define TYPE_ORCADPCB2 1 +#define TYPE_PCAD 2 +#define TYPE_VIEWLOGIC_WIR 3 +#define TYPE_VIEWLOGIC_NET 4 + + enum TypeOfStruct { STRUCT_NOT_INIT, STRUCT_COMPONENT, @@ -79,75 +84,36 @@ public: }; -eda_global STOREMOD* g_BaseListePkg; -eda_global STORECMP* g_BaseListeCmp; - -eda_global FILE* source; -eda_global FILE* dest; -eda_global FILE* libcmp; -eda_global FILE* lib_module; - -/* nom des fichiers a traiter */ -eda_global wxString FFileName; -eda_global wxString NetNameBuffer; - -/* Types de netliste: */ -#define TYPE_NON_SPECIFIE 0 -#define TYPE_ORCADPCB2 1 -#define TYPE_PCAD 2 -#define TYPE_VIEWLOGIC_WIR 3 -#define TYPE_VIEWLOGIC_NET 4 - /* Gestion des noms des librairies */ -eda_global wxString g_EquivExtBuffer -#ifdef MAIN -( wxT( ".equ" ) ) -#endif -; -eda_global wxString g_ExtCmpBuffer -#ifdef MAIN -( wxT( ".cmp" ) ) -#endif -; +extern const wxString EquivFileExtension; +extern const wxString RetroFileExtension; +extern const wxString ComponentFileExtension; -eda_global wxString g_UserNetDirBuffer; // Netlist path (void = current working directory) +extern const wxString RetroFileWildcard; +extern const wxString EquivFileWildcard; -eda_global wxArrayString g_ListName_Equ; // list of .equ files to load +extern const wxString titleLibLoadError; -eda_global int g_FlagEESchema; -eda_global int Rjustify; /* flag pout troncature des noms de Net: - * = 0: debut de chaine conservee (->ORCADPCB2) - * = 1: fin de chaine conservee (->VIEWLOGIC) */ -eda_global int selection_type; /* 0 pour sel par U??, 1 pour sel par ref ORCADPCB */ +/* CvPcb global variable definition references. */ +extern STOREMOD* g_BaseListePkg; +extern STORECMP* g_BaseListeCmp; -eda_global int modified; /* Flag != 0 si modif attribution des modules */ -eda_global int ListModIsModified; /* Flag != 0 si modif liste des lib modules */ +extern wxString g_NetlistFileExtension; +extern wxString g_UserNetDirBuffer; -eda_global char alim[1024]; +extern wxArrayString g_ListName_Equ; // list of .equ files to load -eda_global int nbcomp; /* nombre de composants trouves */ -eda_global int nblib; /* nombre d'empreintes trouvees */ -eda_global int composants_non_affectes; /* nbre de composants non affectes */ +extern int g_FlagEESchema; +extern int Rjustify; /* flag pout troncature des noms de Net: + * = 0: debut de chaine conservee (->ORCADPCB2) + * = 1: fin de chaine conservee (->VIEWLOGIC) */ -eda_global wxString NameBuffer; -eda_global wxString NetInNameBuffer; -eda_global wxString NetInExtBuffer; -eda_global wxString NetDirBuffer; +extern int modified; /* Flag != 0 si modif attribution des module. */ -eda_global wxString ExtRetroBuffer -#ifdef MAIN -( wxT( ".stf" ) ) -#endif -; +extern int nbcomp; /* nombre de composants trouves */ +extern int nblib; /* nombre d'empreintes trouvees */ +extern int composants_non_affectes; /* nbre de composants non affectes */ - -// Variables generales */ -// Unused, for pcbnew compatibility: -eda_global Ki_PageDescr* SheetList[] -#ifdef MAIN -= { NULL } -#endif -; - -// Unused, for pcbnew compatibility: void Plume( int state ); + +#endif /* __CVPCB_H__ */ diff --git a/cvpcb/cvstruct.h b/cvpcb/cvstruct.h index 6a02710eef..94add8be57 100644 --- a/cvpcb/cvstruct.h +++ b/cvpcb/cvstruct.h @@ -6,12 +6,8 @@ #ifndef CVSTRUCT_H #define CVSTRUCT_H -#ifndef eda_global -#define eda_global extern -#endif - - #include "wx/listctrl.h" +#include /* Forward declarations of all top-level window classes. */ class FootprintListBox; @@ -33,6 +29,7 @@ public: ListBoxCmp* m_ListCmp; WinEDA_DisplayFrame* DrawFrame; WinEDA_Toolbar* m_HToolBar; // Toolbar horizontal haut d'ecran + wxFileName m_NetlistFileName; // Constructor and destructor public: @@ -73,8 +70,7 @@ public: void CreateConfigWindow(); int SaveNetList( const wxString& FullFileName ); int SaveComponentList( const wxString& FullFileName ); - bool ReadInputNetList( const wxString& FullFileName ); - void ReadNetListe(); + bool ReadNetList(); int rdpcad(); int ReadSchematicNetlist(); int ReadFootprintFilterList( FILE* f ); @@ -177,7 +173,7 @@ class WinEDA_DisplayFrame : public WinEDA_BasePcbFrame public: public: - WinEDA_DisplayFrame( wxWindow * father, + WinEDA_DisplayFrame( WinEDA_CvpcbFrame* father, const wxString &title, const wxPoint &pos, const wxSize &size, long style = KICAD_DEFAULT_DRAWFRAME_STYLE ); diff --git a/cvpcb/dialog_display_options.cpp b/cvpcb/dialog_display_options.cpp index 81dc039ee1..d929faf3a8 100644 --- a/cvpcb/dialog_display_options.cpp +++ b/cvpcb/dialog_display_options.cpp @@ -262,7 +262,9 @@ void WinEDA_FootprintDisplayOptionsFrame::UpdateObjectSettings(void) void WinEDA_FootprintDisplayOptionsFrame::OnSaveConfigClick( wxCommandEvent& event ) { - Save_Config(this); + WinEDA_CvpcbFrame* parent = ( WinEDA_CvpcbFrame* )GetParent(); + wxASSERT( parent && parent->IsKindOf( CLASSINFO( WinEDA_CvpcbFrame ) ) ); + Save_Config( this, parent->m_NetlistFileName.GetFullPath() ); } /*! diff --git a/cvpcb/displayframe.cpp b/cvpcb/displayframe.cpp index 9fd2d2d5d1..246715df44 100644 --- a/cvpcb/displayframe.cpp +++ b/cvpcb/displayframe.cpp @@ -8,6 +8,7 @@ #include "class_drawpanel.h" #include "id.h" #include "confirm.h" +#include "macros.h" #include "3d_viewer.h" @@ -34,17 +35,14 @@ END_EVENT_TABLE() /* WinEDA_DisplayFrame: the frame to display the current focused footprint */ /***************************************************************************/ -WinEDA_DisplayFrame::WinEDA_DisplayFrame( wxWindow* father, +WinEDA_DisplayFrame::WinEDA_DisplayFrame( WinEDA_CvpcbFrame* father, const wxString& title, const wxPoint& pos, const wxSize& size, long style ) : WinEDA_BasePcbFrame( father, CVPCB_DISPLAY_FRAME, title, pos, size, style ) { - m_FrameName = wxT( "CmpFrame" ); - m_Draw_Axis = TRUE; // TRUE if we want the axis - m_Draw_Grid = TRUE; // TRUE if we want the grid - m_Draw_Sheet_Ref = FALSE; // TRUE if we want the sheet references + m_FrameName = wxT( "CmpFrame" ); // Give an icon #ifdef __WINDOWS__ @@ -55,10 +53,9 @@ WinEDA_DisplayFrame::WinEDA_DisplayFrame( wxWindow* father, SetTitle( title ); SetBoard( new BOARD( NULL, this ) ); - SetBaseScreen( new PCB_SCREEN() ); - GetSettings(); + LoadSettings(); SetSize( m_FramePos.x, m_FramePos.y, m_FrameSize.x, m_FrameSize.y ); ReCreateHToolbar(); ReCreateVToolbar(); @@ -234,25 +231,25 @@ void WinEDA_DisplayFrame::GeneralControle( wxDC* DC, wxPoint Mouse ) case WXK_NUMPAD8: /* cursor moved up */ case WXK_UP: - Mouse.y -= (int) round(delta.y); + Mouse.y -= wxRound(delta.y); DrawPanel->MouseTo( Mouse ); break; case WXK_NUMPAD2: /* cursor moved down */ case WXK_DOWN: - Mouse.y += (int) round(delta.y); + Mouse.y += wxRound(delta.y); DrawPanel->MouseTo( Mouse ); break; case WXK_NUMPAD4: /* cursor moved left */ case WXK_LEFT: - Mouse.x -= (int) round(delta.x); + Mouse.x -= wxRound(delta.x); DrawPanel->MouseTo( Mouse ); break; case WXK_NUMPAD6: /* cursor moved right */ case WXK_RIGHT: - Mouse.x += (int) round(delta.x); + Mouse.x += wxRound(delta.x); DrawPanel->MouseTo( Mouse ); break; } @@ -285,7 +282,7 @@ void WinEDA_DisplayFrame::GeneralControle( wxDC* DC, wxPoint Mouse ) } } - Affiche_Status_Box(); /* Display new cursor coordinates */ + UpdateStatusBar(); /* Display new cursor coordinates */ } diff --git a/cvpcb/genequiv.cpp b/cvpcb/genequiv.cpp index 9a3fa9f0e6..ae5dcbd820 100644 --- a/cvpcb/genequiv.cpp +++ b/cvpcb/genequiv.cpp @@ -8,6 +8,7 @@ #include "wxstruct.h" #include "confirm.h" #include "gestfich.h" +#include "macros.h" #include "cvpcb.h" #include "protos.h" @@ -18,31 +19,27 @@ void WinEDA_CvpcbFrame::WriteStuffList( wxCommandEvent& event ) { FILE* FileEquiv; STORECMP* Cmp; - wxString Line, FullFileName, Mask; + wxString Line; + wxFileName fn = m_NetlistFileName; if( nbcomp <= 0 ) return; /* calcul du nom du fichier */ - Mask = wxT( "*" ) + ExtRetroBuffer; - FullFileName = FFileName; - ChangeFileNameExt( FullFileName, ExtRetroBuffer ); + fn.SetExt( RetroFileExtension ); - FullFileName = EDA_FileSelector( wxT( "Create Stuff File" ), - wxGetCwd(), /* Chemin par defaut */ - FullFileName, /* nom fichier par defaut */ - ExtRetroBuffer, /* extension par defaut */ - Mask, /* Masque d'affichage */ - this, - wxFD_SAVE, - TRUE ); - if( FullFileName.IsEmpty() ) + wxFileDialog dlg( this, wxT( "Save Stuff File" ), fn.GetPath(), + fn.GetFullName(), RetroFileWildcard, + wxFD_SAVE | wxFD_OVERWRITE_PROMPT ); + + if( dlg.ShowModal() == wxID_CANCEL ) return; - FileEquiv = wxFopen( FullFileName, wxT( "wt" ) ); + FileEquiv = wxFopen( dlg.GetPath(), wxT( "wt" ) ); + if( FileEquiv == 0 ) { - Line = _( "Unable to create " ) + FullFileName; + Line = _( "Unable to create " ) + dlg.GetPath(); DisplayError( this, Line, 30 ); return; } diff --git a/cvpcb/genorcad.cpp b/cvpcb/genorcad.cpp index a0e3cfdf46..37f461b6a3 100644 --- a/cvpcb/genorcad.cpp +++ b/cvpcb/genorcad.cpp @@ -27,14 +27,14 @@ int NetNumCode; /* Nombre utilise pour cree des NetNames lors de int genorcad() { -char Line[1024]; -STOREPIN * Pin; -STORECMP * CurrentCmp; -wxString Title = g_Main_Title + wxT(" ") + GetBuildVersion(); + char Line[1024]; + STOREPIN * Pin; + STORECMP * CurrentCmp; + wxString Title = wxGetApp().GetAppName() + wxT(" ") + GetBuildVersion(); NetNumCode = 1; DateAndTime(Line); fprintf(dest,"( { Netlist by %s, date = %s }\n", - CONV_TO_UTF8(Title), Line ) ; + CONV_TO_UTF8(Title), Line ) ; /***********************/ /* Lecture de la liste */ diff --git a/cvpcb/init.cpp b/cvpcb/init.cpp index 04d7bf8476..ea8503e9ac 100644 --- a/cvpcb/init.cpp +++ b/cvpcb/init.cpp @@ -9,6 +9,7 @@ #include "gr_basic.h" #include "gestfich.h" #include "id.h" +#include "appl_wxstruct.h" #include "cvpcb.h" #include "protos.h" @@ -77,7 +78,7 @@ void WinEDA_CvpcbFrame::SetNewPkg( const wxString& package ) /********************************************/ -void WinEDA_CvpcbFrame::ReadNetListe() +bool WinEDA_CvpcbFrame::ReadNetList() /*******************************************/ /* Lecture de la netliste selon format, ainsi que du fichier des composants @@ -91,18 +92,21 @@ void WinEDA_CvpcbFrame::ReadNetListe() error_level = ReadSchematicNetlist(); if( error_level < 0 ) - return; + { + msg.Printf( _( "File <%s> does not appear to be a valid Kicad " \ + "net list file." ), + m_NetlistFileName.GetFullPath().c_str() ); + ::wxMessageBox( msg, _( "File Error" ), wxOK | wxICON_ERROR, this ); + return false; + } /* lecture des correspondances */ - loadcmp(); + loadcmp( m_NetlistFileName.GetFullPath() ); if( m_ListCmp == NULL ) - return; + return false; - if( !NetInNameBuffer.IsEmpty() ) - wxSetWorkingDirectory( wxPathOnly( NetInNameBuffer ) ); - - Read_Config( NetInNameBuffer ); // relecture de la config (elle peut etre modifiée) + Read_Config( m_NetlistFileName.GetFullPath() ); listlib(); BuildFootprintListBox(); @@ -130,14 +134,14 @@ void WinEDA_CvpcbFrame::ReadNetListe() SetStatusText( msg, 1 ); /* Mise a jour du titre de la fenetre principale */ - wxString Title = g_Main_Title + wxT( " " ) + GetBuildVersion(); - msg.Printf( wxT( "%s [%s]" ), Title.GetData(), FFileName.GetData() ); - SetTitle( msg ); + SetTitle( wxGetApp().GetTitle() + wxT( " " ) + GetBuildVersion() + + wxT( " " ) + m_NetlistFileName.GetFullPath() ); + return true; } /*****************************************************************/ -int WinEDA_CvpcbFrame::SaveNetList( const wxString& FullFilename ) +int WinEDA_CvpcbFrame::SaveNetList( const wxString& fileName ) /*****************************************************************/ /* Sauvegarde des fichiers netliste et cmp @@ -145,93 +149,35 @@ int WinEDA_CvpcbFrame::SaveNetList( const wxString& FullFilename ) * Le nom du fichier cmp en est deduit */ { - wxString NetlistFullFileName = FullFilename; + wxFileName fn; - if( NetlistFullFileName.IsEmpty() ) - { - wxString Mask = wxT( "*" ) + NetExtBuffer; - if( !NetNameBuffer.IsEmpty() ) - { - NetlistFullFileName = NetNameBuffer; - ChangeFileNameExt( NetlistFullFileName, NetExtBuffer ); - } + if( !fileName && m_NetlistFileName.IsOk() ) + fn = m_NetlistFileName; + else + fn = wxFileName( wxGetCwd(), _( "unamed" ), NetExtBuffer ); - NetlistFullFileName = - EDA_FileSelector( _( "Save NetList and Components List files" ), - NetDirBuffer, /* Chemin par defaut */ - NetlistFullFileName, /* nom fichier par defaut */ - NetExtBuffer, /* extension par defaut */ - Mask, /* Masque d'affichage */ - this, - wxFD_SAVE, - TRUE - ); - } - if( NetlistFullFileName.IsEmpty() ) + wxFileDialog dlg( this, _( "Save Net and Component List" ), fn.GetPath(), + fn.GetFullName(), NetlistFileWildcard, + wxFD_SAVE | wxFD_OVERWRITE_PROMPT ); + + if( dlg.ShowModal() == wxID_CANCEL ) return -1; - FFileName = NetlistFullFileName; - NetNameBuffer = NetlistFullFileName; - if( SaveComponentList( NetlistFullFileName ) == 0 ) + if( SaveComponentList( dlg.GetPath() ) == 0 ) { DisplayError( this, _( "Unable to create component file (.cmp)" ) ); return 0; } - dest = wxFopen( NetlistFullFileName, wxT( "wt" ) ); - if( dest == 0 ) + FILE* netlist = wxFopen( dlg.GetPath(), wxT( "wt" ) ); + + if( netlist == 0 ) { DisplayError( this, _( "Unable to create netlist file" ) ); return 0; } - GenNetlistPcbnew(); + GenNetlistPcbnew( netlist ); return 1; } - - -/**********************************************************************/ -bool WinEDA_CvpcbFrame::ReadInputNetList( const wxString& FullFileName ) -/**********************************************************************/ - -/* Routine de selection du nom de la netliste d'entree, et de lecure de - * celle-ci - */ -{ - wxString Mask, Line; - - if( FullFileName.IsEmpty() ) - { - if( !NetInExtBuffer.IsEmpty() ) - Mask = wxT( "*" ) + NetInExtBuffer; - else - Mask = wxT( "*.net" ); - Line = EDA_FileSelector( _( "Open NetList File:" ), - NetDirBuffer, /* Chemin par defaut */ - NetInNameBuffer, /* nom fichier par defaut */ - NetInExtBuffer, /* extension par defaut */ - Mask, /* Masque d'affichage */ - this, - 0, - FALSE - ); - if( Line.IsEmpty() ) - return FALSE; - } - else - Line = FullFileName; - - NetInNameBuffer = Line; - NetNameBuffer = Line; - FFileName = NetInNameBuffer; - - /* Mise a jour du titre de la fenetre principale */ - Line = g_Main_Title + wxT( " " ) + GetBuildVersion(); - Line += wxT( " " ) + NetInNameBuffer; - SetTitle( Line ); - - ReadNetListe(); - - return TRUE; -} diff --git a/cvpcb/listlib.cpp b/cvpcb/listlib.cpp index 99ace64287..799559cb22 100644 --- a/cvpcb/listlib.cpp +++ b/cvpcb/listlib.cpp @@ -13,21 +13,20 @@ #include "confirm.h" #include "kicad_string.h" #include "gestfich.h" +#include "macros.h" +#include "appl_wxstruct.h" #include "cvpcb.h" #include "protos.h" -FILE* name_libmodules; /* pour lecture librairie */ - /* routines locales : */ static void ReadDocLib( const wxString& ModLibName ); static int LibCompare( void* mod1, void* mod2 ); static STOREMOD* TriListeModules( STOREMOD* BaseListe, int nbitems ); -/**/ /*********************/ -int listlib() +bool listlib() /*********************/ /* Routine lisant la liste des librairies, et generant la liste chainee @@ -42,13 +41,13 @@ int listlib() * */ { - char buffer[1024]; - wxString FullLibName; - int errorlevel = 0, end; - int flag_librairie; - STOREMOD* ItemLib; - unsigned ii; - wxString msg; + FILE* file; /* pour lecture librairie */ + char buffer[1024]; + wxFileName fn; + int end; + STOREMOD* ItemLib; + unsigned ii; + wxString tmp, msg; if( g_BaseListePkg ) /* Liste Deja existante, a supprimer */ { @@ -57,50 +56,65 @@ int listlib() } if( g_LibName_List.GetCount() == 0 ) - return -4; + { + wxMessageBox( _( "No PCB foot print libraries are listed in the " \ + "current project file." ), _( "Project File Error" ), + wxOK | wxICON_ERROR ); + return false; + } - /* init recherche */ - SetRealLibraryPath( wxT( "modules" ) ); nblib = 0; /* Lecture des Librairies */ for( ii = 0; ii < g_LibName_List.GetCount(); ii++ ) { /* Calcul du nom complet de la librairie */ - FullLibName = MakeFileName( g_RealLibDirBuffer, - g_LibName_List[ii], - LibExtBuffer ); - /* acces a une librairie */ - if( ( name_libmodules = wxFopen( FullLibName, wxT( "rt" ) ) ) == NULL ) + fn = g_LibName_List[ii]; + fn.SetExt( ModuleFileExtension ); + + tmp = wxGetApp().GetLibraryPathList().FindValidPath( fn.GetFullName() ); + + if( !tmp ) { - msg.Printf( _( "Library file <%s> not found" ), - FullLibName.GetData() ); - DisplayError( NULL, msg, 20 ); + msg.Printf( _( "PCB foot print library file <%s> could not be " \ + "found in the default search paths." ), + fn.GetFullName().c_str() ); + wxMessageBox( msg, titleLibLoadError, wxOK | wxICON_ERROR ); + continue; + } + + /* acces a une librairie */ + file = wxFopen( tmp, wxT( "rt" ) ); + + if( file == NULL ) + { + msg.Printf( _( "Could not open PCB foot print library file <%s>." ), + tmp.c_str() ); + wxMessageBox( msg, titleLibLoadError, wxOK | wxICON_ERROR ); continue; } /* Controle du type de la librairie : */ - flag_librairie = 0; - fgets( buffer, 32, name_libmodules ); + fgets( buffer, 32, file ); if( strncmp( buffer, ENTETE_LIBRAIRIE, L_ENTETE_LIB ) != 0 ) { - msg.Printf( _( "Library file <%s> is not a module library" ), - FullLibName.GetData() ); - DisplayError( NULL, msg, 20 ); - fclose( name_libmodules ); + msg.Printf( _( "<%s> is not a valid Kicad PCB foot print library" ), + tmp.c_str() ); + wxMessageBox( msg, titleLibLoadError, wxOK | wxICON_ERROR ); + fclose( file ); continue; } /* Lecture du nombre de composants */ - fseek( name_libmodules, 0, 0 ); + fseek( file, 0, 0 ); /* lecture nom des composants : */ end = 0; - while( !end && fgets( buffer, 255, name_libmodules ) != NULL ) + while( !end && fgets( buffer, 255, file ) != NULL ) { if( strnicmp( buffer, "$INDEX", 6 ) == 0 ) { - while( fgets( buffer, 255, name_libmodules ) != NULL ) + while( fgets( buffer, 255, file ) != NULL ) { if( strnicmp( buffer, "$EndINDEX", 6 ) == 0 ) { @@ -112,25 +126,29 @@ int listlib() ItemLib->Pnext = g_BaseListePkg; g_BaseListePkg = ItemLib; ItemLib->m_Module = CONV_FROM_UTF8( StrPurge( buffer ) ); - ItemLib->m_LibName = FullLibName; - + ItemLib->m_LibName = tmp; nblib++; } if( !end ) - errorlevel = -3; + { + msg.Printf( _( "Unexpected end of file occurred while " \ + "parsing PCB foot print library <%s>." ), + tmp.c_str() ); + wxMessageBox( msg, titleLibLoadError, wxOK | wxICON_ERROR ); + } } } - fclose( name_libmodules ); - ReadDocLib( FullLibName ); + fclose( file ); + ReadDocLib( tmp ); } /* classement alphabetique: */ if( g_BaseListePkg ) g_BaseListePkg = TriListeModules( g_BaseListePkg, nblib ); - return errorlevel; + return true; } @@ -218,18 +236,28 @@ static void ReadDocLib( const wxString& ModLibName ) STOREMOD* NewMod; char Line[1024]; wxString ModuleName; - wxString docfilename; + wxString msg; FILE* LibDoc; + wxFileName fn = ModLibName; - docfilename = ModLibName; - ChangeFileNameExt( docfilename, EXT_DOC ); + fn.SetExt( wxT( "mdc" ) ); - if( ( LibDoc = wxFopen( docfilename, wxT( "rt" ) ) ) == NULL ) + if( ( LibDoc = wxFopen( fn.GetFullPath(), wxT( "rt" ) ) ) == NULL ) + { + msg.Printf( _( "Could not open PCB foot print library document " \ + "file <%s>." ), fn.GetFullPath().c_str() ); + wxMessageBox( msg, titleLibLoadError, wxOK | wxICON_ERROR ); return; + } GetLine( LibDoc, Line, NULL, sizeof(Line) - 1 ); if( strnicmp( Line, ENTETE_LIBDOC, L_ENTETE_LIB ) != 0 ) + { + msg.Printf( _( "<%s> is not a valid PCB foot print library " \ + "document file." ), fn.GetFullPath().c_str() ); + wxMessageBox( msg, titleLibLoadError, wxOK | wxICON_ERROR ); return; + } /* Lecture de la librairie */ while( GetLine( LibDoc, Line, NULL, sizeof(Line) - 1 ) ) diff --git a/cvpcb/loadcmp.cpp b/cvpcb/loadcmp.cpp index 903255c78f..10f326c8f9 100644 --- a/cvpcb/loadcmp.cpp +++ b/cvpcb/loadcmp.cpp @@ -8,17 +8,16 @@ #include "confirm.h" #include "kicad_string.h" #include "gestfich.h" +#include "macros.h" +#include "appl_wxstruct.h" #include "cvpcb.h" #include "protos.h" #include "cvstruct.h" -/*****************************************************************/ -MODULE* WinEDA_DisplayFrame::Get_Module( const wxString& CmpName ) -/*****************************************************************/ - -/* +/***************************************************************** + * * Analyse les LIBRAIRIES pour trouver le module demande * Si ce module est trouve, le copie en memoire, et le * chaine en fin de liste des modules @@ -26,45 +25,69 @@ MODULE* WinEDA_DisplayFrame::Get_Module( const wxString& CmpName ) * name_cmp = nom du module * - Retour: * Pointeur sur le nouveau module. - */ + * + *****************************************************************/ +MODULE* WinEDA_DisplayFrame::Get_Module( const wxString& CmpName ) { - int LineNum, Found = 0; - unsigned ii; - char Line[1024], Name[255]; - wxString libname; - MODULE* Module = NULL; + int LineNum, Found = 0; + unsigned ii; + char Line[1024], Name[255]; + wxString tmp, msg; + wxFileName fn; + MODULE* Module = NULL; + FILE* file; for( ii = 0; ii < g_LibName_List.GetCount(); ii++ ) { /* Calcul du nom complet de la librairie */ - libname = MakeFileName( g_RealLibDirBuffer, g_LibName_List[ii], LibExtBuffer ); + fn = g_LibName_List[ii]; + fn.SetExt( ModuleFileExtension ); - if( ( lib_module = wxFopen( libname, wxT( "rt" ) ) ) == NULL ) + tmp = wxGetApp().GetLibraryPathList().FindValidPath( fn.GetFullName() ); + + if( !tmp ) { + msg.Printf( _( "PCB foot print library file <%s> could not be " \ + "found in the default search paths." ), + fn.GetFullName().c_str() ); + wxMessageBox( msg, titleLibLoadError, wxOK | wxICON_ERROR, this ); + continue; + } + + file = wxFopen( tmp, wxT( "rt" ) ); + + if( file == NULL ) + { + msg.Printf( _( "Could not open PCB foot print library file <%s>." ), + tmp.c_str() ); + wxMessageBox( msg, titleLibLoadError, wxOK | wxICON_ERROR, this ); continue; } /* lecture entete chaine definie par ENTETE_LIBRAIRIE */ LineNum = 0; - GetLine( lib_module, Line, &LineNum ); + GetLine( file, Line, &LineNum ); StrPurge( Line ); if( strnicmp( Line, ENTETE_LIBRAIRIE, L_ENTETE_LIB ) != 0 ) { - DisplayError( this, _( "This file is NOT a library file" ) ); + msg.Printf( _( "<%s> is not a valid Kicad PCB foot print library." ), + tmp.c_str() ); + wxMessageBox( msg, titleLibLoadError, wxOK | wxICON_ERROR, this ); + fclose( file ); return NULL; } /* Lecture de la liste des composants de la librairie */ Found = 0; - while( !Found && GetLine( lib_module, Line, &LineNum ) ) + while( !Found && GetLine( file, Line, &LineNum ) ) { if( strncmp( Line, "$MODULE", 6 ) == 0 ) break; if( strnicmp( Line, "$INDEX", 6 ) == 0 ) { - while( GetLine( lib_module, Line, &LineNum ) ) + while( GetLine( file, Line, &LineNum ) ) { if( strnicmp( Line, "$EndINDEX", 9 ) == 0 ) break; @@ -80,7 +103,7 @@ MODULE* WinEDA_DisplayFrame::Get_Module( const wxString& CmpName ) } /* Lecture de la librairie */ - while( Found && GetLine( lib_module, Line, &LineNum ) ) + while( Found && GetLine( file, Line, &LineNum ) ) { if( Line[0] != '$' ) continue; @@ -99,22 +122,21 @@ MODULE* WinEDA_DisplayFrame::Get_Module( const wxString& CmpName ) // Switch the locale to standard C (needed to print floating point numbers like 1.3) SetLocaleTo_C_standard(); - Module->ReadDescr( lib_module, &LineNum ); + Module->ReadDescr( file, &LineNum ); SetLocaleTo_Default(); // revert to the current locale Module->SetPosition( wxPoint( 0, 0 ) ); - fclose( lib_module ); + fclose( file ); return Module; } } - fclose( lib_module ); - lib_module = 0; + fclose( file ); + file = 0; } - if( lib_module ) - fclose( lib_module ); + if( file ) + fclose( file ); - wxString msg; msg.Printf( _( "Module %s not found" ), CmpName.GetData() ); DisplayError( this, msg ); return NULL; diff --git a/cvpcb/menucfg.cpp b/cvpcb/menucfg.cpp index 28776fe290..d69dc9ab78 100644 --- a/cvpcb/menucfg.cpp +++ b/cvpcb/menucfg.cpp @@ -28,7 +28,8 @@ void WinEDA_CvpcbFrame::CreateConfigWindow() { KiConfigCvpcbFrame* ConfigFrame = new KiConfigCvpcbFrame( this ); - ConfigFrame->ShowModal(); ConfigFrame->Destroy(); + ConfigFrame->ShowModal(); + ConfigFrame->Destroy(); } @@ -36,21 +37,21 @@ void WinEDA_CvpcbFrame::CreateConfigWindow() void KiConfigCvpcbFrame::SetDialogDatas() /*********************************************/ { + wxConfig* cfg = wxGetApp().m_EDA_CommonConfig; + m_ListLibr->InsertItems( g_LibName_List, 0 ); m_ListEquiv->InsertItems( g_ListName_Equ, 0 ); - m_LibDirCtrl = new WinEDA_EnterText( this, - _( "Lib Dir:" ), g_UserLibDirBuffer, + m_LibDirCtrl = new WinEDA_EnterText( this, _( "Lib Dir:" ), + g_UserLibDirBuffer, m_RightBoxSizer, wxDefaultSize ); - m_NetInputExtCtrl = new WinEDA_EnterText( this, - _( "Net Input Ext:" ), - NetInExtBuffer, + m_NetInputExtCtrl = new WinEDA_EnterText( this, _( "Net Input Ext:" ), + g_NetlistFileExtension, m_NetExtBoxSizer, wxDefaultSize ); - wxString DocModuleFileName = - wxGetApp().m_EDA_CommonConfig->Read( DOC_FOOTPRINTS_LIST_KEY, - DEFAULT_FOOTPRINTS_LIST_FILENAME ); + wxString DocModuleFileName = cfg->Read( DOC_FOOTPRINTS_LIST_KEY, + DEFAULT_FOOTPRINTS_LIST_FILENAME ); m_TextHelpModulesFileName = new WinEDA_EnterText( this, _( "Module Doc File:" ), DocModuleFileName, @@ -60,41 +61,39 @@ void KiConfigCvpcbFrame::SetDialogDatas() /* Create info on Files ext */ wxStaticText* StaticText; wxString text; - text.Printf( wxT( "%s %s" ), _( "Cmp ext:" ), g_ExtCmpBuffer.GetData() ); + text.Printf( wxT( "%s .%s" ), _( "Cmp ext:" ), + ComponentFileExtension.c_str() ); StaticText = new wxStaticText( this, -1, text ); - m_FileExtList->Add( - StaticText, - wxGROW | wxLEFT | wxRIGHT | wxTOP | wxBOTTOM | - wxADJUST_MINSIZE ); + m_FileExtList->Add( StaticText, + wxGROW | wxLEFT | wxRIGHT | wxTOP | wxBOTTOM | + wxADJUST_MINSIZE ); - text.Printf( wxT( "%s %s" ), _( "Lib ext:" ), LibExtBuffer.GetData() ); + text.Printf( wxT( "%s .%s" ), _( "Lib ext:" ), + ModuleFileExtension.c_str() ); StaticText = new wxStaticText( this, -1, text ); - m_FileExtList->Add( - StaticText, - wxGROW | wxLEFT | wxRIGHT | wxTOP | wxBOTTOM | - wxADJUST_MINSIZE ); + m_FileExtList->Add( StaticText, + wxGROW | wxLEFT | wxRIGHT | wxTOP | wxBOTTOM | + wxADJUST_MINSIZE ); - text.Printf( wxT( "%s %s" ), _( "NetOut ext:" ), NetExtBuffer.GetData() ); + text.Printf( wxT( "%s .%s" ), _( "NetOut ext:" ), NetExtBuffer.c_str() ); StaticText = new wxStaticText( this, -1, text ); - m_FileExtList->Add( - StaticText, - wxGROW | wxLEFT | wxRIGHT | wxTOP | wxBOTTOM | - wxADJUST_MINSIZE ); + m_FileExtList->Add( StaticText, + wxGROW | wxLEFT | wxRIGHT | wxTOP | wxBOTTOM | + wxADJUST_MINSIZE ); - text.Printf( wxT( "%s %s" ), _( "Equiv ext:" ), - g_EquivExtBuffer.GetData() ); + text.Printf( wxT( "%s .%s" ), _( "Equiv ext:" ), + EquivFileExtension.c_str() ); StaticText = new wxStaticText( this, -1, text ); - m_FileExtList->Add( - StaticText, - wxGROW | wxLEFT | wxRIGHT | wxTOP | wxBOTTOM | - wxADJUST_MINSIZE ); + m_FileExtList->Add( StaticText, + wxGROW | wxLEFT | wxRIGHT | wxTOP | wxBOTTOM | + wxADJUST_MINSIZE ); - text.Printf( wxT( "%s %s" ), _( "Retro ext:" ), ExtRetroBuffer.GetData() ); + text.Printf( wxT( "%s .%s" ), _( "Retro ext:" ), + RetroFileExtension.c_str() ); StaticText = new wxStaticText( this, -1, text ); - m_FileExtList->Add( - StaticText, - wxGROW | wxLEFT | wxRIGHT | wxTOP | wxBOTTOM | - wxADJUST_MINSIZE ); + m_FileExtList->Add( StaticText, + wxGROW | wxLEFT | wxRIGHT | wxTOP | wxBOTTOM | + wxADJUST_MINSIZE ); } @@ -111,13 +110,15 @@ void KiConfigCvpcbFrame::AcceptCfg( wxCommandEvent& event ) void KiConfigCvpcbFrame::Update() /**********************************/ { - wxString msg; + wxASSERT( wxGetApp().m_EDA_CommonConfig != NULL ); + + wxString msg; + wxConfig* cfg = wxGetApp().m_EDA_CommonConfig; if( !m_DoUpdate ) return; - NetInExtBuffer = m_NetInputExtCtrl->GetValue(); - wxGetApp().m_EDA_CommonConfig->Write( DOC_FOOTPRINTS_LIST_KEY, - m_TextHelpModulesFileName->GetValue() ); + g_NetlistFileExtension = m_NetInputExtCtrl->GetValue(); + cfg->Write( DOC_FOOTPRINTS_LIST_KEY, m_TextHelpModulesFileName->GetValue() ); msg = m_LibDirCtrl->GetValue(); if( msg != g_UserLibDirBuffer ) @@ -125,7 +126,6 @@ void KiConfigCvpcbFrame::Update() g_UserLibDirBuffer = m_LibDirCtrl->GetValue(); SetRealLibraryPath( wxT( "modules" ) ); listlib(); - ListModIsModified = 1; m_Parent->BuildFootprintListBox(); } } @@ -135,41 +135,31 @@ void KiConfigCvpcbFrame::Update() void KiConfigCvpcbFrame::SaveCfg( wxCommandEvent& event ) /****************************************************/ { + WinEDA_CvpcbFrame* parent = ( WinEDA_CvpcbFrame* )GetParent(); + wxASSERT( parent && parent->IsKindOf( CLASSINFO( WinEDA_CvpcbFrame ) ) ); + Update(); - Save_Config( this ); + Save_Config( this, parent->m_NetlistFileName.GetFullPath() ); } /******************************************************/ void KiConfigCvpcbFrame::ReadOldCfg( wxCommandEvent& event ) -/******************************************************/ { - wxString line; + WinEDA_CvpcbFrame* parent = ( WinEDA_CvpcbFrame* )GetParent(); + wxASSERT( parent && parent->IsKindOf( CLASSINFO( WinEDA_CvpcbFrame ) ) ); - NetInNameBuffer.Replace( WIN_STRING_DIR_SEP, UNIX_STRING_DIR_SEP ); + wxFileName fn = parent->m_NetlistFileName; + fn.SetExt( ProjectFileExtension ); - wxString FullFileName = NetInNameBuffer.AfterLast( '/' ); + wxFileDialog dlg( this, _( "Load Project File" ), fn.GetPath(), + fn.GetFullName(), ProjectFileWildcard, + wxFD_OPEN | wxFD_FILE_MUST_EXIST ); - ChangeFileNameExt( FullFileName, g_Prj_Config_Filename_ext ); - - FullFileName = EDA_FileSelector( _( "Read config file" ), - wxGetCwd(), /* Chemin par defaut */ - FullFileName, /* nom fichier par defaut */ - g_Prj_Config_Filename_ext, /* extension par defaut */ - FullFileName, /* Masque d'affichage */ - this, - wxFD_OPEN, - TRUE /* ne change pas de repertoire courant */ - ); - if( FullFileName.IsEmpty() ) + if( dlg.ShowModal() == wxID_CANCEL ) return; - if( !wxFileExists( FullFileName ) ) - { - line.Printf( _( "File %s not found" ), FullFileName.GetData() ); - DisplayError( this, line ); return; - } - Read_Config( FullFileName ); + Read_Config( dlg.GetPath() ); m_DoUpdate = FALSE; Close( TRUE ); } @@ -185,14 +175,13 @@ void KiConfigCvpcbFrame::LibDelFct( wxCommandEvent& event ) if( ii < 0 ) return; - ListModIsModified = 1; g_LibName_List.RemoveAt( ii ); /* suppression de la reference dans la liste des librairies */ m_ListLibr->Delete( ii ); g_UserLibDirBuffer = m_LibDirCtrl->GetValue(); - SetRealLibraryPath( wxT( "modules" ) ); + listlib(); m_Parent->BuildFootprintListBox(); @@ -203,8 +192,10 @@ void KiConfigCvpcbFrame::LibDelFct( wxCommandEvent& event ) void KiConfigCvpcbFrame::LibAddFct( wxCommandEvent& event ) /********************************************************/ { - int ii; - wxString FullFileName, ShortLibName, mask; + int ii; + wxFileName fn; + wxString tmp; + wxArrayString Filenames; ii = m_ListLibr->GetSelection(); if( event.GetId() == ADD_LIB ) /* Ajout apres selection */ @@ -215,47 +206,47 @@ void KiConfigCvpcbFrame::LibAddFct( wxCommandEvent& event ) ii = 0; Update(); - mask = wxT( "*" ) + LibExtBuffer; - wxFileDialog FilesDialog( this, _( "Library files:" ), g_RealLibDirBuffer, - wxEmptyString, mask, - wxFD_DEFAULT_STYLE | wxFD_MULTIPLE ); + wxFileDialog dlg( this, _( "Foot Print Library Files" ), g_RealLibDirBuffer, + wxEmptyString, ModuleFileWildcard, + wxFD_OPEN | wxFD_MULTIPLE | wxFD_FILE_MUST_EXIST ); - FilesDialog.ShowModal(); - wxArrayString Filenames; - FilesDialog.GetPaths( Filenames ); + if( dlg.ShowModal() == wxID_CANCEL ) + return; + + dlg.GetPaths( Filenames ); if( Filenames.GetCount() == 0 ) return; for( unsigned jj = 0; jj < Filenames.GetCount(); jj++ ) { - FullFileName = Filenames[jj]; - ShortLibName = MakeReducedFileName( FullFileName, - g_RealLibDirBuffer, - LibExtBuffer ); + fn = Filenames[jj]; - //Add or insert new library name - if( g_LibName_List.Index( ShortLibName ) == wxNOT_FOUND ) - { - ListModIsModified = 1; - g_LibName_List.Insert( ShortLibName, ii++ ); + /* If the library path is already in the library search paths + * list, just add the library name to the list. Otherwise, add + * the library name with the full path. */ + if( wxGetApp().GetLibraryPathList().Index( fn.GetPath() ) == wxNOT_FOUND ) + tmp = fn.GetPathWithSep() + fn.GetName(); + else + tmp = fn.GetName(); + + // Add or insert new library name. + if( g_LibName_List.Index( tmp ) == wxNOT_FOUND ) + { + g_LibName_List.Insert( tmp, ii++ ); } else { - wxString msg; - msg << wxT( "<" ) << ShortLibName << wxT( "> : " ) << _( - "Library already in use" ); + wxString msg = wxT( "<" ) + tmp + wxT( "> : " ) + + _( "Library already in use" ); DisplayError( this, msg ); } } g_UserLibDirBuffer = m_LibDirCtrl->GetValue(); - SetRealLibraryPath( wxT( "modules" ) ); listlib(); - m_Parent->BuildFootprintListBox(); - m_ListLibr->Clear(); m_ListLibr->InsertItems( g_LibName_List, 0 ); } @@ -280,8 +271,9 @@ void KiConfigCvpcbFrame::EquDelFct( wxCommandEvent& event ) void KiConfigCvpcbFrame::EquAddFct( wxCommandEvent& event ) /********************************************************/ { - int ii; - wxString FullFileName, ShortLibName, mask; + int ii; + wxFileName fn; + wxString libName; ii = m_ListEquiv->GetSelection(); if( event.GetId() == ADD_EQU ) @@ -290,43 +282,48 @@ void KiConfigCvpcbFrame::EquAddFct( wxCommandEvent& event ) ii = 0; Update(); - mask = wxT( "*" ) + g_EquivExtBuffer; - wxFileDialog FilesDialog( this, _( "Equiv Files:" ), g_RealLibDirBuffer, - wxEmptyString, mask, - wxFD_DEFAULT_STYLE | wxFD_MULTIPLE ); + wxFileDialog dlg( this, _( "Open Footprint Alias Files" ), + g_RealLibDirBuffer, wxEmptyString, EquivFileWildcard, + wxFD_OPEN | wxFD_MULTIPLE | wxFD_FILE_MUST_EXIST ); + + if( dlg.ShowModal() == wxID_CANCEL ) + return; - FilesDialog.ShowModal(); wxArrayString Filenames; - FilesDialog.GetFilenames( Filenames ); + dlg.GetFilenames( Filenames ); if( Filenames.GetCount() == 0 ) return; for( unsigned jj = 0; jj < Filenames.GetCount(); jj++ ) { - FullFileName = Filenames[jj]; - ShortLibName = MakeReducedFileName( FullFileName, - g_RealLibDirBuffer, - g_EquivExtBuffer ); + fn = Filenames[jj]; + + /* Use the file name without extension if the library path is + * already in the default library search path. Otherwise, use + * the full path and file name without the extension. */ + if( wxGetApp().GetLibraryPathList().Index( fn.GetPath() ) == wxNOT_FOUND ) + libName = fn.GetPathWithSep() + fn.GetName(); + else + libName = fn.GetName(); //Add or insert new equiv library name - if( g_ListName_Equ.Index( ShortLibName ) == wxNOT_FOUND ) + if( g_ListName_Equ.Index( libName ) == wxNOT_FOUND ) { - g_ListName_Equ.Insert( ShortLibName, ii++ ); + g_ListName_Equ.Insert( libName, ii++ ); } else { wxString msg; - msg << wxT( "<" ) << ShortLibName << wxT( "> : " ) << _( - "Library already in use" ); + msg << wxT( "<" ) << libName << wxT( "> : " ) << + _( "Library already in use" ); DisplayError( this, msg ); } } /* Update display list */ g_UserLibDirBuffer = m_LibDirCtrl->GetValue(); - SetRealLibraryPath( wxT( "modules" ) ); listlib(); m_ListEquiv->Clear(); diff --git a/cvpcb/protos.h b/cvpcb/protos.h index 49308539fa..5c64a32002 100644 --- a/cvpcb/protos.h +++ b/cvpcb/protos.h @@ -5,16 +5,17 @@ #ifndef PROTOS_H #define PROTOS_H -int GenNetlistPcbnew() ; -int loadcmp() ; -int listlib() ; +int GenNetlistPcbnew( FILE* f ) ; +bool loadcmp( const wxString& fileName ) ; +bool listlib() ; + STOREMOD * GetModuleDescrByName(const wxString & FootprintName); /***********/ /* CFG.CPP */ /***********/ -void Save_Config(wxWindow * parent); +void Save_Config( wxWindow* parent, const wxString& fileName ); void Read_Config( const wxString & FullFileName ); /* lit la configuration */ diff --git a/cvpcb/readschematicnetlist.cpp b/cvpcb/readschematicnetlist.cpp index 8ac1cdd8b7..100e174a64 100644 --- a/cvpcb/readschematicnetlist.cpp +++ b/cvpcb/readschematicnetlist.cpp @@ -12,6 +12,7 @@ #include "common.h" #include "confirm.h" #include "kicad_string.h" +#include "macros.h" #include "cvpcb.h" #include "protos.h" @@ -22,9 +23,9 @@ /* routines locales : */ -static int ReadPinConnection( STORECMP* CurrentCmp ); -static int CmpCompare( void* cmp1, void* cmp2 ); /* routine pour qsort() de tri de liste des composants */ -static STORECMP* TriListeComposants( STORECMP* BaseListe, int nbitems ); +static int ReadPinConnection( FILE* f, STORECMP* CurrentCmp ); +static int CmpCompare( void* cmp1, void* cmp2 ); /* routine pour qsort() de tri de liste des composants */ +static STORECMP* TriListeComposants( STORECMP* BaseListe, int nbitems ); /* Tri la liste des composants par ordre alphabetique et met a jour le nouveau chainage avant/arriere * retourne un pointeur sur le 1er element de la liste */ @@ -87,6 +88,7 @@ int WinEDA_CvpcbFrame::ReadSchematicNetlist() * } */ { + char alim[1024]; int i, k, l; char* LibName; char Line[BUFFER_CHAR_SIZE + 1]; @@ -96,6 +98,7 @@ int WinEDA_CvpcbFrame::ReadSchematicNetlist() wxString component_value; /* buffer for component values (470K, 22nF ...) */ char* ptchar; STORECMP* Cmp; + FILE* source; modified = 0; Rjustify = 0; @@ -105,12 +108,13 @@ int WinEDA_CvpcbFrame::ReadSchematicNetlist() if( g_BaseListeCmp ) FreeMemoryComponents(); - source = wxFopen( FFileName, wxT( "rt" ) ); + source = wxFopen( m_NetlistFileName.GetFullPath(), wxT( "rt" ) ); + if( source == 0 ) { - wxString msg; - msg.Printf( _( "File <%s> not found" ), FFileName.GetData() ); - DisplayError( this, msg ); return -1; + DisplayError( this, _( "File <" ) + m_NetlistFileName.GetFullPath() + + _( "> not found" ) ); + return -1; } /* Read the file header (must be "( { OrCAD PCB" or "({ OrCAD PCB" ) @@ -270,7 +274,7 @@ int WinEDA_CvpcbFrame::ReadSchematicNetlist() } Cmp->m_TimeStamp = schematic_timestamp; - ReadPinConnection( Cmp ); + ReadPinConnection( source, Cmp ); nbcomp++; } @@ -294,7 +298,7 @@ int WinEDA_CvpcbFrame::ReadFootprintFilterList( FILE* f ) for( ; ; ) { - if( fgets( Line, BUFFER_CHAR_SIZE, source ) == 0 ) + if( fgets( Line, BUFFER_CHAR_SIZE, f ) == 0 ) break; if( strnicmp( Line, "$endlist", 8 ) == 0 ) { @@ -307,7 +311,8 @@ int WinEDA_CvpcbFrame::ReadFootprintFilterList( FILE* f ) if( strnicmp( Line, "$component", 10 ) == 0 ) // New component ref found { CmpRef = CONV_FROM_UTF8( Line + 11 ); - CmpRef.Trim( TRUE ); CmpRef.Trim( FALSE ); + CmpRef.Trim( TRUE ); + CmpRef.Trim( FALSE ); /* Search the new component in list */ for( Cmp = g_BaseListeCmp; Cmp != NULL; Cmp = Cmp->Pnext ) { @@ -318,7 +323,8 @@ int WinEDA_CvpcbFrame::ReadFootprintFilterList( FILE* f ) else if( Cmp ) { wxString fp = CONV_FROM_UTF8( Line + 1 ); - fp.Trim( FALSE ); fp.Trim( TRUE ); + fp.Trim( FALSE ); + fp.Trim( TRUE ); Cmp->m_FootprintFilter.Add( fp ); } } @@ -328,7 +334,7 @@ int WinEDA_CvpcbFrame::ReadFootprintFilterList( FILE* f ) /***********************************/ -int ReadPinConnection( STORECMP* Cmp ) +int ReadPinConnection( FILE* f, STORECMP* Cmp ) /***********************************/ { int i, jj; @@ -343,7 +349,7 @@ int ReadPinConnection( STORECMP* Cmp ) /* debut description trouv‚ */ for( ; ; ) { - if( fgets( Line, BUFFER_CHAR_SIZE, source ) == 0 ) + if( fgets( Line, BUFFER_CHAR_SIZE, f ) == 0 ) return -1; /* remove blanks from the beginning of the line */ @@ -387,7 +393,8 @@ int ReadPinConnection( STORECMP* Cmp ) } Pin = new STOREPIN(); - *LastPin = Pin; LastPin = &Pin->Pnext; + *LastPin = Pin; + LastPin = &Pin->Pnext; Pin->m_PinNum = numpin; Pin->m_PinNet = net; } diff --git a/cvpcb/savecmp.cpp b/cvpcb/savecmp.cpp index 486f751db5..fd0fc7c8e1 100644 --- a/cvpcb/savecmp.cpp +++ b/cvpcb/savecmp.cpp @@ -10,6 +10,8 @@ #include "confirm.h" #include "kicad_string.h" #include "gestfich.h" +#include "macros.h" +#include "appl_wxstruct.h" #include "cvpcb.h" #include "protos.h" @@ -19,25 +21,27 @@ /* Chaines de caractere d'identification */ char EnteteCmpMod[] = { "Cmp-Mod V01" }; -/****************************************************************************/ -int WinEDA_CvpcbFrame::SaveComponentList( const wxString& NetlistFullFileName ) -/*****************************************************************************/ +const wxString titleComponentLibErr( _( "Component Library Error" ) ); + +/*****************************************************************************/ /* Routine de sauvegarde du fichier des modules * Retourne 1 si OK * 0 si ecriture non faite */ +/****************************************************************************/ +int WinEDA_CvpcbFrame::SaveComponentList( const wxString& NetlistFullFileName ) { - STORECMP* Cmp; - wxString FullFileName; - char Line[1024]; - wxString Title = g_Main_Title + wxT( " " ) + GetBuildVersion(); + STORECMP* Cmp; + FILE* dest; + wxFileName fn( NetlistFullFileName ); + char Line[1024]; + wxString Title = wxGetApp().GetAppName() + wxT( " " ) + GetBuildVersion(); /* calcul du nom du fichier */ - FullFileName = NetlistFullFileName; - ChangeFileNameExt( FullFileName, g_ExtCmpBuffer ); + fn.SetExt( ComponentFileExtension ); - dest = wxFopen( FullFileName, wxT( "wt" ) ); + dest = wxFopen( fn.GetFullPath(), wxT( "wt" ) ); if( dest == NULL ) return 0; /* Erreur ecriture */ @@ -62,38 +66,47 @@ int WinEDA_CvpcbFrame::SaveComponentList( const wxString& NetlistFullFileName ) } -/****************/ -int loadcmp() /***************/ - /* recupere la liste des associations composants/empreintes */ +/****************/ +bool loadcmp( const wxString& fileName ) { - wxString timestamp, valeur, ilib, namecmp; - bool read_cmp_data = FALSE, eof = FALSE; - STORECMP* Cmp; - char Line[1024], * ident, * data; - wxString FullFileName; + wxString timestamp, valeur, ilib, namecmp, msg; + bool read_cmp_data = FALSE, eof = FALSE; + STORECMP* Cmp; + char Line[1024], * ident, * data; + FILE* source; + wxFileName fn = fileName; /* calcul du nom du fichier */ - FullFileName = FFileName; - ChangeFileNameExt( FullFileName, g_ExtCmpBuffer ); + fn.SetExt( ComponentFileExtension ); - source = wxFopen( FullFileName, wxT( "rt" ) ); + source = wxFopen( fn.GetFullPath(), wxT( "rt" ) ); if( source == NULL ) { - return 0; + msg.Printf( _( "Cannot open component library <%s>." ), + fn.GetFullPath().c_str() ); + wxMessageBox( msg, titleComponentLibErr, wxOK | wxICON_ERROR ); + return false; } /* Identification du Type de fichier CmpMod */ if( fgets( Line, 79, source ) == 0 ) - return 0; + { + msg.Printf( _( " <%s> does not appear to be a valid Kicad component " \ + "library." ), fn.GetFullPath().c_str() ); + wxMessageBox( msg, titleComponentLibErr, wxOK | wxICON_ERROR ); + fclose( source ); + return false; + } + if( strnicmp( Line, EnteteCmpMod, 11 ) != 0 ) /* old file version*/ { + msg.Printf( _( "<%s> is an old version component file." ) ); + wxMessageBox( msg, titleComponentLibErr, wxOK | wxICON_ERROR ); fclose( source ); - DisplayError( NULL, - wxT( "Old version of Componaent file, recreate it!" ) ); - return 0; + return false; } /* lecture de la liste */ @@ -115,16 +128,19 @@ int loadcmp() { if( fgets( Line, 1024, source ) == 0 ) { - eof = TRUE; break; + eof = TRUE; + break; } if( strnicmp( Line, "EndCmp", 6 ) == 0 ) { - read_cmp_data = TRUE; break; + read_cmp_data = TRUE; + break; } ident = strtok( Line, "=;\n\r" ); data = strtok( NULL, ";\n\r" ); + if( strnicmp( ident, "TimeStamp", 9 ) == 0 ) { timestamp = CONV_FROM_UTF8( data ); @@ -162,14 +178,8 @@ int loadcmp() * mise a jour de ses parametres */ for( Cmp = g_BaseListeCmp; Cmp != NULL; Cmp = Cmp->Pnext ) { - if( selection_type == 1 ) - { - if( timestamp != Cmp->m_TimeStamp ) - continue; - } - else - if( namecmp != Cmp->m_Reference ) - continue; + if( namecmp != Cmp->m_Reference ) + continue; /* composant identifie , copie du nom du module correspondant */ Cmp->m_Module = ilib; @@ -177,5 +187,5 @@ int loadcmp() } fclose( source ); - return 1; + return true; } diff --git a/cvpcb/setvisu.cpp b/cvpcb/setvisu.cpp index cc1ed3dc13..ecef1e1ed3 100644 --- a/cvpcb/setvisu.cpp +++ b/cvpcb/setvisu.cpp @@ -59,7 +59,9 @@ void WinEDA_CvpcbFrame::CreateScreenCmp() DrawFrame->GetBoard()->m_Modules.DeleteAll(); } - DrawFrame->GetBoard()->m_Modules.PushBack( DrawFrame->Get_Module( FootprintName ) ); + MODULE* mod = DrawFrame->Get_Module( FootprintName ); + if( mod ) + DrawFrame->GetBoard()->m_Modules.PushBack( mod ); DrawFrame->Zoom_Automatique( FALSE ); if( DrawFrame->m_Draw3DFrame ) @@ -94,7 +96,7 @@ void WinEDA_DisplayFrame::RedrawActiveWindow( wxDC* DC, bool EraseBg ) MODULE* Module = GetBoard()->m_Modules; if ( Module ) Module->Display_Infos( this ); - Affiche_Status_Box(); + UpdateStatusBar(); DrawPanel->Trace_Curseur( DC ); } diff --git a/cvpcb/writenetlistpcbnew.cpp b/cvpcb/writenetlistpcbnew.cpp index f203d462c2..d42a44dd43 100644 --- a/cvpcb/writenetlistpcbnew.cpp +++ b/cvpcb/writenetlistpcbnew.cpp @@ -10,6 +10,8 @@ #include "common.h" #include "confirm.h" #include "kicad_string.h" +#include "macros.h" +#include "appl_wxstruct.h" #include "cvpcb.h" #include "protos.h" @@ -28,20 +30,19 @@ int NetNumCode; /* Nombre utilise pour cree des NetNames lors de /*************************/ -int GenNetlistPcbnew() -/*************************/ +int GenNetlistPcbnew( FILE* file ) { #define NETLIST_HEAD_STRING "EESchema Netlist Version 1.1" char Line[1024]; STOREPIN* Pin; STORECMP* CurrentCmp; - wxString Title = g_Main_Title + wxT( " " ) + GetBuildVersion(); + wxString Title = wxGetApp().GetAppName() + wxT( " " ) + GetBuildVersion(); NetNumCode = 1; DateAndTime( Line ); if( g_FlagEESchema ) - fprintf( dest, "# %s created %s\n(\n", NETLIST_HEAD_STRING, Line ); + fprintf( file, "# %s created %s\n(\n", NETLIST_HEAD_STRING, Line ); else - fprintf( dest, "( { netlist created %s }\n", Line ); + fprintf( file, "( { netlist created %s }\n", Line ); /***********************/ /* Lecture de la liste */ @@ -50,18 +51,18 @@ int GenNetlistPcbnew() CurrentCmp = g_BaseListeCmp; for( ; CurrentCmp != NULL; CurrentCmp = CurrentCmp->Pnext ) { - fprintf( dest, " ( %s ", CONV_TO_UTF8( CurrentCmp->m_TimeStamp ) ); + fprintf( file, " ( %s ", CONV_TO_UTF8( CurrentCmp->m_TimeStamp ) ); if( !CurrentCmp->m_Module.IsEmpty() ) - fprintf( dest, CONV_TO_UTF8( CurrentCmp->m_Module ) ); + fprintf( file, CONV_TO_UTF8( CurrentCmp->m_Module ) ); else - fprintf( dest, "$noname$" ); + fprintf( file, "$noname$" ); - fprintf( dest, " %s ", CONV_TO_UTF8( CurrentCmp->m_Reference ) ); + fprintf( file, " %s ", CONV_TO_UTF8( CurrentCmp->m_Reference ) ); /* placement de la valeur */ - fprintf( dest, "%s\n", CONV_TO_UTF8( CurrentCmp->m_Valeur ) ); + fprintf( file, "%s\n", CONV_TO_UTF8( CurrentCmp->m_Valeur ) ); /* Tri des pins */ TriPinsModule( CurrentCmp ); @@ -74,26 +75,28 @@ int GenNetlistPcbnew() ChangePinNet( Pin->m_PinNet ); if( !Pin->m_PinNet.IsEmpty() ) - fprintf( dest, " ( %s %s )\n", + fprintf( file, " ( %s %s )\n", CONV_TO_UTF8( Pin->m_PinNum ), CONV_TO_UTF8( Pin->m_PinNet ) ); else - fprintf( dest, " ( %s ? )\n", CONV_TO_UTF8( Pin->m_PinNum ) ); + fprintf( file, " ( %s ? )\n", CONV_TO_UTF8( Pin->m_PinNum ) ); } - fprintf( dest, " )\n" ); + fprintf( file, " )\n" ); } - fprintf( dest, ")\n*\n" ); + fprintf( file, ")\n*\n" ); + if( g_FlagEESchema ) - WriteFootprintFilterInfos( dest ); - fclose( dest ); + WriteFootprintFilterInfos( file ); + + fclose( file ); return 0; } /******************************************/ -void WriteFootprintFilterInfos( FILE* dest ) +void WriteFootprintFilterInfos( FILE* file ) /******************************************/ /* Write the allowed footprint list for each component */ { @@ -108,23 +111,23 @@ void WriteFootprintFilterInfos( FILE* dest ) continue; if( !WriteHeader ) { - fprintf( dest, "{ Allowed footprints by component:\n" ); + fprintf( file, "{ Allowed footprints by component:\n" ); WriteHeader = TRUE; } - fprintf( dest, "$component %s\n", + fprintf( file, "$component %s\n", CONV_TO_UTF8( component->m_Reference ) ); /* Write the footprint list */ for( unsigned int jj = 0; jj < FilterCount; jj++ ) { - fprintf( dest, " %s\n", + fprintf( file, " %s\n", CONV_TO_UTF8( component->m_FootprintFilter[jj] ) ); } - fprintf( dest, "$endlist\n" ); + fprintf( file, "$endlist\n" ); } if( WriteHeader ) - fprintf( dest, "$endfootprintlist\n}\n" ); + fprintf( file, "$endfootprintlist\n}\n" ); } diff --git a/eeschema/CMakeLists.txt b/eeschema/CMakeLists.txt index 590d36ddee..9bbe2217d7 100644 --- a/eeschema/CMakeLists.txt +++ b/eeschema/CMakeLists.txt @@ -5,7 +5,7 @@ include_directories(${CMAKE_CURRENT_SOURCE_DIR} ) set(EESCHEMA_SRCS - affiche.cpp +# affiche.cpp annotate.cpp annotate_dialog.cpp backanno.cpp @@ -113,7 +113,9 @@ set(EESCHEMA_SRCS viewlibs.cpp) set(EESCHEMA_EXTRA_SRCS - ../share/setpage.cpp) + ../common/sch_item_struct.cpp + ../share/setpage.cpp +) if(WIN32) if(MINGW) diff --git a/eeschema/affiche.cpp b/eeschema/affiche.cpp deleted file mode 100644 index 67f41e7b9f..0000000000 --- a/eeschema/affiche.cpp +++ /dev/null @@ -1,197 +0,0 @@ -/**********************************************************/ -/* Routines d'affichage de parametres et caracteristiques */ -/**********************************************************/ - -/* Fichier AFFICHE.CPP */ - -#include "fctsys.h" -#include "gr_basic.h" -#include "common.h" -#include "wxstruct.h" -#include "program.h" -#include "libcmp.h" -#include "general.h" - -#include "protos.h" - - -/***********************************************************/ -void DrawSheetStruct::Display_Infos( WinEDA_DrawFrame* frame ) -/************************************************************/ -{ - frame->MsgPanel->EraseMsgBox(); - Affiche_1_Parametre( frame, 1, _( "Name" ), m_SheetName, CYAN ); - Affiche_1_Parametre( frame, 30, _( "FileName" ), m_FileName, BROWN ); -} - - -/***************************************************************/ -void SCH_COMPONENT::Display_Infos( WinEDA_DrawFrame* frame ) -/***************************************************************/ -{ - EDA_LibComponentStruct* Entry = FindLibPart( m_ChipName.GetData(), wxEmptyString, FIND_ROOT );; - - wxString msg; - - frame->MsgPanel->EraseMsgBox(); - - Affiche_1_Parametre( frame, 1, _( "Ref" ), - GetRef(((WinEDA_SchematicFrame*)frame)->GetSheet()), DARKCYAN ); - - if( Entry && Entry->m_Options == ENTRY_POWER ) - msg = _( "Pwr Symb" ); - else - msg = _( "Val" ); - - Affiche_1_Parametre( frame, 10, msg, GetField(VALUE)->m_Text, DARKCYAN ); - - Affiche_1_Parametre( frame, 28, _( "RefLib" ), m_ChipName.GetData(), BROWN ); - - msg = FindLibName; - Affiche_1_Parametre( frame, 40, _( "Lib" ), msg, DARKRED ); - - if( Entry ) - { - Affiche_1_Parametre( frame, 52, Entry->m_Doc, Entry->m_KeyWord, DARKCYAN ); - } -} - - -/*******************************************************/ -void LibDrawPin::Display_Infos( WinEDA_DrawFrame* frame ) -/*******************************************************/ - -/* Affiche en bas d'ecran les caracteristiques de la pin - */ -{ - wxString Text; - int ii; - - frame->MsgPanel->EraseMsgBox(); - - /* Affichage du nom */ - Affiche_1_Parametre( frame, 30, _( "PinName" ), m_PinName, DARKCYAN ); - - /* Affichage du numero */ - if( m_PinNum == 0 ) - Text = wxT( "?" ); - else - ReturnPinStringNum( Text ); - - Affiche_1_Parametre( frame, 38, _( "PinNum" ), Text, DARKCYAN ); - - /* Affichage du type */ - ii = m_PinType; - Affiche_1_Parametre( frame, 44, _( "PinType" ), MsgPinElectricType[ii], RED ); - - /* Affichage de la visiblite */ - ii = m_Attributs; - if( ii & 1 ) - Text = _( "no" ); - else - Text = _( "yes" ); - Affiche_1_Parametre( frame, 50, _( "Display" ), Text, DARKGREEN ); - - /* Display pin length */ - Text = ReturnStringFromValue( g_UnitMetric, m_PinLen, EESCHEMA_INTERNAL_UNIT, true ); - Affiche_1_Parametre( frame, 56, _( "Length" ), Text, MAGENTA ); - - /* Affichage de l'orientation */ - switch( m_Orient ) - { - case PIN_UP: - Text = _( "Up" ); break; - - case PIN_DOWN: - Text = _( "Down" ); break; - - case PIN_LEFT: - Text = _( "Left" ); break; - - case PIN_RIGHT: - Text = _( "Right" ); break; - - default: - Text = wxT( "??" ); break; - } - - Affiche_1_Parametre( frame, 62, _( "Orient" ), Text, MAGENTA ); -} - - -/***********************************************************************/ -void LibEDA_BaseStruct::Display_Infos_DrawEntry( WinEDA_DrawFrame* frame ) -/***********************************************************************/ - -/* Affiche en bas d'ecran les caracteristiques de l'element - */ -{ - wxString msg; - int thickness = 0; - - frame->MsgPanel->EraseMsgBox(); - - /* affichage du type */ - msg = wxT( "??" ); - - switch( Type() ) - { - case COMPONENT_ARC_DRAW_TYPE: - thickness = ( (LibDrawArc*) this )->m_Width; - msg = wxT( "Arc" ); break; - - case COMPONENT_CIRCLE_DRAW_TYPE: - thickness = ( (LibDrawCircle*) this )->m_Width; - msg = wxT( "Circle" ); break; - - case COMPONENT_GRAPHIC_TEXT_DRAW_TYPE: - thickness = ( (LibDrawText*) this )->m_Width; - msg = wxT( "Text" ); break; - - case COMPONENT_RECT_DRAW_TYPE: - thickness = ( (LibDrawSquare*) this )->m_Width; - msg = wxT( "Rect" ); break; - - case COMPONENT_POLYLINE_DRAW_TYPE: - thickness = ( (LibDrawPolyline*) this )->m_Width; - msg = wxT( "PolyLine" ); break; - - case COMPONENT_LINE_DRAW_TYPE: - thickness = ( (LibDrawSegment*) this )->m_Width; - msg = wxT( "Segment" ); break; - - case COMPONENT_PIN_DRAW_TYPE: - ( (LibDrawPin*) this )->Display_Infos( frame ); - msg = wxT( "Pin" ); - break; - - default: - ; - } - - Affiche_1_Parametre( frame, 1, wxT( "Type" ), msg, CYAN ); - - - /* Affichage de l'appartenance */ - if( m_Unit == 0 ) - msg = _( "All" ); - else - msg.Printf( wxT( "%d" ), m_Unit ); - Affiche_1_Parametre( frame, 8, _( "Unit" ), msg, BROWN ); - - if( m_Convert == 0 ) - msg = _( "All" ); - else if( m_Convert == 1 ) - msg = _( "no" ); - else if( m_Convert == 2 ) - msg = _( "yes" ); - else - msg = wxT( "?" ); - Affiche_1_Parametre( frame, 14, _( "Convert" ), msg, BROWN ); - - if( thickness ) - msg = ReturnStringFromValue( g_UnitMetric, thickness, EESCHEMA_INTERNAL_UNIT, true ); - else - msg = _( "default" ); - Affiche_1_Parametre( frame, 20, _( "Thickness" ), msg, BLUE ); -} diff --git a/eeschema/backanno.cpp b/eeschema/backanno.cpp index bbf805bdc6..642b99a04d 100644 --- a/eeschema/backanno.cpp +++ b/eeschema/backanno.cpp @@ -11,6 +11,7 @@ #include "gestfich.h" #include "libcmp.h" #include "general.h" +#include "appl_wxstruct.h" /* Variables Locales */ @@ -146,7 +147,7 @@ bool WinEDA_SchematicFrame::ReadInputStuffFile() if( filename.IsEmpty() ) return FALSE; - Line = g_Main_Title + wxT( " " ) + GetBuildVersion(); + Line = wxGetApp().GetAppName() + wxT( " " ) + GetBuildVersion(); Line += wxT( " " ) + filename; SetTitle( Line ); diff --git a/eeschema/block.cpp b/eeschema/block.cpp index 60cbdb7d40..c70b4144cc 100644 --- a/eeschema/block.cpp +++ b/eeschema/block.cpp @@ -10,6 +10,7 @@ #include "class_drawpanel.h" #include "confirm.h" #include "block_commande.h" +#include "class_drawpickedstruct.h" #include "program.h" #include "libcmp.h" @@ -595,10 +596,11 @@ bool MoveStruct( WinEDA_DrawPanel* panel, wxDC* DC, SCH_ITEM* DrawStruct ) if( DC ) panel->PostDirtyRect( pickedList->GetBoundingBoxUnion() ); - PlaceStruct( panel->GetScreen(), pickedList ); // Place it in its new position. + PlaceStruct( panel->GetScreen(), (SCH_ITEM *) pickedList ); // Place it in its new position. if( DC ) - RedrawStructList( panel, DC, pickedList, GR_DEFAULT_DRAWMODE ); + RedrawStructList( panel, DC, (SCH_ITEM *) pickedList, + GR_DEFAULT_DRAWMODE ); // Free the wrapper DrawPickedStruct chain pickedList->DeleteWrapperList(); @@ -808,7 +810,8 @@ bool MirrorStruct( WinEDA_DrawPanel* panel, } if( DC ) - RedrawStructList( panel, DC, pickedList, GR_DEFAULT_DRAWMODE ); + RedrawStructList( panel, DC, (SCH_ITEM*) pickedList, + GR_DEFAULT_DRAWMODE ); // Free the wrapper DrawPickedStruct chain pickedList->DeleteWrapperList(); @@ -899,7 +902,7 @@ static SCH_ITEM* CopyStruct( WinEDA_DrawPanel* panel, while( PickedList ) { PickedList->m_PickedStruct->SetNext( screen->EEDrawList ); - screen->EEDrawList = PickedList->m_PickedStruct; + screen->EEDrawList = (SCH_ITEM*) PickedList->m_PickedStruct; PickedList = PickedList->Next(); } } @@ -988,7 +991,7 @@ void DeleteStruct( WinEDA_DrawPanel* panel, wxDC* DC, SCH_ITEM* DrawStruct ) cur; cur = cur->Next() ) { - SCH_ITEM* item = cur->m_PickedStruct; + SCH_ITEM* item = (SCH_ITEM*)cur->m_PickedStruct; screen->RemoveFromDrawList( item ); panel->PostDirtyRect( item->GetBoundingBox() ); item->SetNext( 0 ); @@ -1103,7 +1106,7 @@ void WinEDA_SchematicFrame::PasteStruct( wxDC* DC ) RedrawStructList( DrawPanel, DC, DrawStruct, GR_DEFAULT_DRAWMODE ); for( PickedList = (DrawPickedStruct*) DrawStruct; PickedList != NULL; ) { - SCH_ITEM* Struct = PickedList->m_PickedStruct; + SCH_ITEM* Struct = (SCH_ITEM*) PickedList->m_PickedStruct; Struct->SetNext( GetScreen()->EEDrawList ); SetaParent( Struct, GetScreen() ); GetScreen()->EEDrawList = Struct; @@ -1179,7 +1182,8 @@ bool PlaceStruct( BASE_SCREEN* screen, SCH_ITEM* DrawStruct ) DrawStructs = (DrawPickedStruct*) DrawStruct; while( DrawStructs ) { - MoveOneStruct( DrawStructs->m_PickedStruct, move_vector ); + MoveOneStruct( (SCH_ITEM*) DrawStructs->m_PickedStruct, + move_vector ); DrawStructs = DrawStructs->Next(); } @@ -1383,12 +1387,12 @@ SCH_ITEM* DuplicateStruct( SCH_ITEM* DrawStruct ) { NewPickedItem = new DrawPickedStruct(); if( NewDrawStruct == NULL ) - NewDrawStruct = NewPickedItem; + NewDrawStruct = (SCH_ITEM*) NewPickedItem; if( LastPickedItem ) LastPickedItem->SetNext( NewPickedItem ); LastPickedItem = NewPickedItem; NewPickedItem->m_PickedStruct = - DuplicateStruct( PickedList->m_PickedStruct ); + DuplicateStruct( (SCH_ITEM*) PickedList->m_PickedStruct ); PickedList = PickedList->Next(); } @@ -1445,7 +1449,7 @@ static void CollectStructsToDrag( SCH_SCREEN* screen ) (DrawPickedStruct*) screen->BlockLocate.m_BlockDrawStruct; while( DrawStructs ) { - Struct = DrawStructs->m_PickedStruct; + Struct = (SCH_ITEM*) DrawStructs->m_PickedStruct; DrawStructs = DrawStructs->Next(); Struct->m_Flags = SELECTED; } @@ -1481,7 +1485,7 @@ static void CollectStructsToDrag( SCH_SCREEN* screen ) DrawStructs = (DrawPickedStruct*) screen->BlockLocate.m_BlockDrawStruct; while( DrawStructs ) { - Struct = DrawStructs->m_PickedStruct; + Struct = (SCH_ITEM*) DrawStructs->m_PickedStruct; DrawStructs = DrawStructs->Next(); if( Struct->Type() == DRAW_SEGMENT_STRUCT_TYPE ) { @@ -1500,11 +1504,10 @@ static void CollectStructsToDrag( SCH_SCREEN* screen ) */ FirstPicked = DrawStructs = - (DrawPickedStruct*) screen->BlockLocate. - m_BlockDrawStruct; + (DrawPickedStruct*) screen->BlockLocate.m_BlockDrawStruct; while( DrawStructs ) { - Struct = DrawStructs->m_PickedStruct; + Struct = (SCH_ITEM*) DrawStructs->m_PickedStruct; DrawStructs = DrawStructs->Next(); if( Struct->Type() == TYPE_SCH_COMPONENT ) { // Add all pins of the selected component to list @@ -1557,7 +1560,7 @@ static void AddPickedItem( SCH_SCREEN* screen, wxPoint position ) DrawStructs = (DrawPickedStruct*) screen->BlockLocate.m_BlockDrawStruct; while( DrawStructs ) { - Struct = DrawStructs->m_PickedStruct; + Struct = (SCH_ITEM*) DrawStructs->m_PickedStruct; DrawStructs = (DrawPickedStruct*) DrawStructs->Next(); switch( Struct->Type() ) diff --git a/eeschema/build_BOM.cpp b/eeschema/build_BOM.cpp index e58f9aef49..daf2a62ab2 100644 --- a/eeschema/build_BOM.cpp +++ b/eeschema/build_BOM.cpp @@ -13,6 +13,7 @@ #include "confirm.h" #include "kicad_string.h" #include "gestfich.h" +#include "appl_wxstruct.h" #include "program.h" #include "libcmp.h" #include "general.h" @@ -47,7 +48,8 @@ public: // Filename extension for BOM list -#define EXT_LIST wxT( ".lst" ) +static const wxString BomFileExtension( wxT( "lst" ) ); +static const wxString BomFileWildcard( wxT( "Bill of Materials file (*.lst)|*.lst" ) ); /* Local functions */ @@ -80,31 +82,23 @@ void DIALOG_BUILD_BOM::Create_BOM_Lists( bool aTypeFileIsExport, bool aRunBrowser ) /**************************************************************************/ { + wxFileName fn; wxString mask, filename; s_ExportSeparatorSymbol = aExportSeparatorSymbol; m_ListFileName = g_RootSheet->m_AssociatedScreen->m_FileName; - ChangeFileNameExt( m_ListFileName, EXT_LIST ); + fn = m_ListFileName; + fn.SetExt( BomFileExtension ); - //need to get rid of the path. - m_ListFileName = m_ListFileName.AfterLast( '/' ); - mask = wxT( "*" ); - mask += EXT_LIST; + wxFileDialog dlg( this, _( "Bill of Materials" ), fn.GetPath(), + fn.GetFullName(), BomFileWildcard, + wxFD_SAVE | wxFD_OVERWRITE_PROMPT ); - filename = EDA_FileSelector( _( "Bill of materials:" ), - wxEmptyString, /* Chemin par defaut (ici dir courante) */ - m_ListFileName, /* nom fichier par defaut, et resultat */ - EXT_LIST, /* extension par defaut */ - mask, /* Masque d'affichage */ - this, - wxFD_SAVE, - TRUE - ); - if( filename.IsEmpty() ) + if( dlg.ShowModal() == wxID_CANCEL ) return; - else - m_ListFileName = filename; + + m_ListFileName = dlg.GetPath(); /* Close dialog, then show the list (if so requested) */ @@ -117,7 +111,7 @@ void DIALOG_BUILD_BOM::Create_BOM_Lists( bool aTypeFileIsExport, if( aRunBrowser ) { - wxString editorname = GetEditorName(); + wxString editorname = wxGetApp().GetEditorName(); AddDelimiterString( filename ); ExecuteFile( this, editorname, filename ); } @@ -194,7 +188,8 @@ void DIALOG_BUILD_BOM::GenereListeOfItems( const wxString& aFullFileName, { /* creates the list file */ DateAndTime( Line ); - wxString Title = g_Main_Title + wxT( " " ) + GetBuildVersion(); + wxString Title = wxGetApp().GetAppName() + wxT( " " ) + + GetBuildVersion(); fprintf( f, "%s >> Creation date: %s\n", CONV_TO_UTF8( Title ), Line ); /* sort component list */ diff --git a/eeschema/class_drawsheet.cpp b/eeschema/class_drawsheet.cpp index 6754c16988..7302f3621e 100644 --- a/eeschema/class_drawsheet.cpp +++ b/eeschema/class_drawsheet.cpp @@ -686,6 +686,15 @@ bool DrawSheetStruct::ChangeFileName( WinEDA_SchematicFrame* aFrame, } +/***********************************************************/ +void DrawSheetStruct::Display_Infos( WinEDA_DrawFrame* frame ) +{ + frame->MsgPanel->EraseMsgBox(); + Affiche_1_Parametre( frame, 1, _( "Name" ), m_SheetName, CYAN ); + Affiche_1_Parametre( frame, 30, _( "FileName" ), m_FileName, BROWN ); +} + + #if defined(DEBUG) void DrawSheetStruct::Show( int nestLevel, std::ostream& os ) { diff --git a/eeschema/class_drawsheet.h b/eeschema/class_drawsheet.h index 797f6905ff..16b45fb8d8 100644 --- a/eeschema/class_drawsheet.h +++ b/eeschema/class_drawsheet.h @@ -5,10 +5,6 @@ #ifndef CLASS_DRAWSHEET_H #define CLASS_DRAWSHEET_H -#ifndef eda_global -#define eda_global extern -#endif - #include "base_struct.h" extern DrawSheetStruct* g_RootSheet; diff --git a/eeschema/class_drawsheetpath.h b/eeschema/class_drawsheetpath.h index d0f58c045b..34e2b3ae0a 100644 --- a/eeschema/class_drawsheetpath.h +++ b/eeschema/class_drawsheetpath.h @@ -5,10 +5,6 @@ #ifndef CLASS_DRAWSHEET_PATH_H #define CLASS_DRAWSHEET_PATH_H -#ifndef eda_global -#define eda_global extern -#endif - #include "base_struct.h" /** Info about complex hierarchies handling: diff --git a/eeschema/class_libentry.cpp b/eeschema/class_libentry.cpp index e18a538c0f..e0ed1ec61f 100644 --- a/eeschema/class_libentry.cpp +++ b/eeschema/class_libentry.cpp @@ -1,22 +1,155 @@ /**********************************************************/ -/* lib_entry.cpp */ +/* lib_entry.cpp */ /**********************************************************/ #include "fctsys.h" - #include "common.h" +#include "kicad_string.h" +#include "confirm.h" + #include "program.h" #include "libcmp.h" #include "general.h" - #include "protos.h" +#include +#include + + +int SortItemsFct(const void* ref, const void* item) +{ +#define Ref ( *(LibEDA_BaseStruct**) (ref) ) +#define Item ( *(LibEDA_BaseStruct**) (item) ) +#define BEFORE -1 +#define AFTER 1 + + int fill_ref = 0, fill_item = 0; + + switch( Ref->Type() ) + { + case COMPONENT_ARC_DRAW_TYPE: + { + const LibDrawArc* draw = (const LibDrawArc*) Ref; + fill_ref = draw->m_Fill; + break; + } + + case COMPONENT_CIRCLE_DRAW_TYPE: + { + const LibDrawCircle* draw = (const LibDrawCircle*) Ref; + fill_ref = draw->m_Fill; + break; + } + + case COMPONENT_RECT_DRAW_TYPE: + { + const LibDrawSquare* draw = (const LibDrawSquare*) Ref; + fill_ref = draw->m_Fill; + break; + } + + case COMPONENT_POLYLINE_DRAW_TYPE: + { + const LibDrawPolyline* draw = (const LibDrawPolyline*) Ref; + fill_ref = draw->m_Fill; + break; + } + + case COMPONENT_GRAPHIC_TEXT_DRAW_TYPE: + if( Item->Type() == COMPONENT_PIN_DRAW_TYPE ) + return BEFORE; + if( Item->Type() == COMPONENT_GRAPHIC_TEXT_DRAW_TYPE ) + return 0; + return 1; + break; + + case COMPONENT_PIN_DRAW_TYPE: + if( Item->Type() == COMPONENT_PIN_DRAW_TYPE ) + { + int ii; + + // Sort the pins by orientation + ii = ( (LibDrawPin*) Ref )->m_Orient - + ( (LibDrawPin*) Item )->m_Orient; + if( ii ) + return ii; + + /* We sort the pins by position (x or y). + * note: at this point, most of pins have same x pos or y pos, + * because they are sorted by orientation and generally are + * vertically or horizontally aligned */ + wxPoint pos_ref, pos_tst; + pos_ref = ( (LibDrawPin*) Ref )->m_Pos; + pos_tst = ( (LibDrawPin*) Item )->m_Pos; + if( (ii = pos_ref.x - pos_tst.x) ) + return ii; + ii = pos_ref.y - pos_tst.y; + return ii; + } + else + return AFTER; + break; + + default: + ; + } + + /* Test de l'item */ + switch( Item->Type() ) + { + case COMPONENT_ARC_DRAW_TYPE: + { + const LibDrawArc* draw = (const LibDrawArc*) Item; + fill_item = draw->m_Fill; + break; + } + + case COMPONENT_CIRCLE_DRAW_TYPE: + { + const LibDrawCircle* draw = (const LibDrawCircle*) Item; + fill_item = draw->m_Fill; + break; + } + + case COMPONENT_RECT_DRAW_TYPE: + { + const LibDrawSquare* draw = (const LibDrawSquare*) Item; + fill_item = draw->m_Fill; + break; + } + + case COMPONENT_POLYLINE_DRAW_TYPE: + { + const LibDrawPolyline* draw = (const LibDrawPolyline*) Item; + fill_item = draw->m_Fill; + break; + } + + case COMPONENT_GRAPHIC_TEXT_DRAW_TYPE: + return BEFORE; + break; + + case COMPONENT_PIN_DRAW_TYPE: + return BEFORE; + break; + + default: + ; + } + + if( fill_ref & fill_item ) + return 0; + if( fill_ref ) + return BEFORE; + return AFTER; +} + /*********************/ /* class LibCmpEntry */ /*********************/ -/* Basic class for librarty oomponent description +/* Basic class for library component description * Not directly used * Used to create the 2 derived classes : * - EDA_LibCmpAliasStruct @@ -26,7 +159,6 @@ /********************************************************************/ LibCmpEntry::LibCmpEntry( LibrEntryType CmpType, const wxChar* CmpName ) : EDA_BaseStruct( LIBCOMPONENT_STRUCT_TYPE ) -/********************************************************************/ { Type = CmpType; m_Name.m_FieldId = VALUE; @@ -37,7 +169,6 @@ LibCmpEntry::LibCmpEntry( LibrEntryType CmpType, const wxChar* CmpName ) : /******************************/ LibCmpEntry::~LibCmpEntry() -/******************************/ { } @@ -47,15 +178,16 @@ LibCmpEntry::~LibCmpEntry() /*******************************/ /* Class to define an alias of a component - * An alias uses the component defintion (graphic, pins...) + * An alias uses the component definition (graphic, pins...) * but has its own name and documentation. - * Therefore, when the component is modified, alias of this component are modified. + * Therefore, when the component is modified, alias of this component are + * modified. * This is a simple method to create components with differs very few * (like 74LS00, 74HC00 ... and many op amps ) */ -EDA_LibCmpAliasStruct:: EDA_LibCmpAliasStruct( const wxChar* CmpName, - const wxChar* CmpRootName ) : +EDA_LibCmpAliasStruct::EDA_LibCmpAliasStruct( const wxChar* CmpName, + const wxChar* CmpRootName ) : LibCmpEntry( ALIAS, CmpName ) { if( CmpRootName == NULL ) @@ -85,19 +217,21 @@ EDA_LibComponentStruct:: EDA_LibComponentStruct( const wxChar* CmpName ) : m_TextInside = 40; m_Options = ENTRY_NORMAL; m_UnitSelectionLocked = FALSE; - m_DrawPinNum = m_DrawPinName = 1; + m_DrawPinNum = 1; + m_DrawPinName = 1; m_Prefix.m_FieldId = REFERENCE; } -/******************************************************/ EDA_LibComponentStruct::~EDA_LibComponentStruct() -/******************************************************/ { - LibEDA_BaseStruct* DrawItem, * NextDrawItem; + LibEDA_BaseStruct* DrawItem; + LibEDA_BaseStruct* NextDrawItem; /* suppression des elements dependants */ - DrawItem = m_Drawings; m_Drawings = NULL; + DrawItem = m_Drawings; + m_Drawings = NULL; + while( DrawItem ) { NextDrawItem = DrawItem->Next(); @@ -107,156 +241,443 @@ EDA_LibComponentStruct::~EDA_LibComponentStruct() } -/**********************************************************************/ -EDA_Rect EDA_LibComponentStruct::GetBoundaryBox( int Unit, int Convert ) -/**********************************************************************/ +/** + * Function Save + * writes the data structures for this object out to a FILE in "*.brd" format. + * @param aFile The FILE to write to. + * @return bool - true if success writing else false. + */ +bool EDA_LibComponentStruct::Save( FILE* aFile ) +{ + LibEDA_BaseStruct* DrawEntry; + LibDrawField* Field; -/* Return the componenty boundary box ( in user coordinates ) + if( Type != ROOT ) // should not happen, but just in case + return false; + + /* First line: it s a comment (component name for readers) */ + fprintf( aFile, "#\n# %s\n#\n", CONV_TO_UTF8( m_Name.m_Text ) ); + + /* Save data */ + fprintf( aFile, "DEF" ); + if( (m_Name.m_Attributs & TEXT_NO_VISIBLE) == 0 ) + fprintf( aFile, " %s", CONV_TO_UTF8( m_Name.m_Text ) ); + else + fprintf( aFile, " ~%s", CONV_TO_UTF8( m_Name.m_Text ) ); + + if( !m_Prefix.m_Text.IsEmpty() ) + fprintf( aFile, " %s", CONV_TO_UTF8( m_Prefix.m_Text ) ); + else + fprintf( aFile, " ~" ); + fprintf( aFile, " %d %d %c %c %d %c %c\n", + 0, m_TextInside, + m_DrawPinNum ? 'Y' : 'N', + m_DrawPinName ? 'Y' : 'N', + m_UnitCount, m_UnitSelectionLocked ? 'L' : 'F', + m_Options == ENTRY_POWER ? 'P' : 'N' ); + + SaveDateAndTime( aFile ); + + /* Save fields */ + m_Prefix.Save( aFile ); + m_Name.Save( aFile ); + + for( Field = m_Fields; Field != NULL; Field = Field->Next() ) + { + if( Field->m_Text.IsEmpty() && Field->m_Name.IsEmpty() ) + continue; + Field->Save( aFile ); + } + + /* Save the alias list: a line starting by "ALIAS" */ + if( m_AliasList.GetCount() != 0 ) + { + fprintf( aFile, "ALIAS" ); + unsigned ii; + for( ii = 0; ii < m_AliasList.GetCount(); ii++ ) + fprintf( aFile, " %s", CONV_TO_UTF8( m_AliasList[ii] ) ); + + fprintf( aFile, "\n" ); + } + + /* Write the footprint filter list */ + if( m_FootprintList.GetCount() != 0 ) + { + fprintf( aFile, "$FPLIST\n" ); + unsigned ii; + for( ii = 0; ii < m_FootprintList.GetCount(); ii++ ) + fprintf( aFile, " %s\n", CONV_TO_UTF8( m_FootprintList[ii] ) ); + + fprintf( aFile, "$ENDFPLIST\n" ); + } + + /* Save graphics items (including pins) */ + if( m_Drawings ) + { + /* we sort the draw items, in order to have an edition more easy, + * when a file editing "by hand" is made */ + SortDrawItems(); + + fprintf( aFile, "DRAW\n" ); + DrawEntry = m_Drawings; + while( DrawEntry ) + { + DrawEntry->Save( aFile ); + DrawEntry = DrawEntry->Next(); + } + fprintf( aFile, "ENDDRAW\n" ); + } + + fprintf( aFile, "ENDDEF\n" ); + + return true; +} + +bool EDA_LibComponentStruct::Load( FILE* file, char* line, int* lineNum, + wxString& errorMsg ) +{ + int unused; + char* p; + char* name; + char* prefix = NULL; + + bool Res; + wxString Msg; + + p = strtok( line, " \t\r\n" ); + + if( strcmp( p, "DEF" ) != 0 ) + { + errorMsg.Printf( wxT( "DEF command expected in line %d, aborted." ), + *lineNum ); + return false; + } + + /* Read DEF line: */ + char drawnum = 0; + char drawname = 0; + + if( ( name = strtok( NULL, " \t\n" ) ) == NULL /* Part name: */ + || ( prefix = strtok( NULL, " \t\n" ) ) == NULL /* Prefix name: */ + || ( p = strtok( NULL, " \t\n" ) ) == NULL /* NumOfPins: */ + || sscanf( p, "%d", &unused ) != 1 + || ( p = strtok( NULL, " \t\n" ) ) == NULL /* TextInside: */ + || sscanf( p, "%d", &m_TextInside ) != 1 + || ( p = strtok( NULL, " \t\n" ) ) == NULL /* DrawNums: */ + || sscanf( p, "%c", &drawnum ) != 1 + || ( p = strtok( NULL, " \t\n" ) ) == NULL /* DrawNums: */ + || sscanf( p, "%c", &drawname ) != 1 + || ( p = strtok( NULL, " \t\n" ) ) == NULL /* m_UnitCount: */ + || sscanf( p, "%d", &m_UnitCount ) != 1 ) + { + errorMsg.Printf( wxT( "Wrong DEF format in line %d, skipped." ), + *lineNum ); + while( GetLine( file, line, lineNum, 1024 ) ) + { + p = strtok( line, " \t\n" ); + if( stricmp( p, "ENDDEF" ) == 0 ) + break; + } + + return false; + } + + m_DrawPinNum = (drawnum == 'N') ? FALSE : TRUE; + m_DrawPinName = (drawname == 'N') ? FALSE : TRUE; + + /* Copy part name and prefix. */ + strupper( name ); + if( name[0] != '~' ) + m_Name.m_Text = CONV_FROM_UTF8( name ); + else + { + m_Name.m_Text = CONV_FROM_UTF8( &name[1] ); + m_Name.m_Attributs |= TEXT_NO_VISIBLE; + } + + if( strcmp( prefix, "~" ) == 0 ) + { + m_Prefix.m_Text.Empty(); + m_Prefix.m_Attributs |= TEXT_NO_VISIBLE; + } + else + m_Prefix.m_Text = CONV_FROM_UTF8( prefix ); + + // Copy optional infos + if( ( p = strtok( NULL, " \t\n" ) ) != NULL && *p == 'L' ) + m_UnitSelectionLocked = TRUE; + if( ( p = strtok( NULL, " \t\n" ) ) != NULL && *p == 'P' ) + m_Options = ENTRY_POWER; + + /* Read next lines */ + while( GetLine( file, line, lineNum, 1024 ) ) + { + p = strtok( line, " \t\n" ); + + /* This is the error flag ( if an error occurs, Res = FALSE) */ + Res = true; + + if( (line[0] == 'T') && (line[1] == 'i') ) + Res = LoadDateAndTime( line ); + else if( line[0] == 'F' ) + Res = LoadField( strcat( p, line ), errorMsg ); + else if( strcmp( p, "ENDDEF" ) == 0 ) + break; + else if( strcmp( p, "DRAW" ) == 0 ) + Res = LoadDrawEntries( file, line, lineNum, errorMsg ); + else if( strncmp( p, "ALIAS", 5 ) == 0 ) + { + p = strtok( NULL, "\r\n" ); + Res = LoadAliases( p, errorMsg ); + } + else if( strncmp( p, "$FPLIST", 5 ) == 0 ) + Res = LoadFootprints( file, line, lineNum, errorMsg ); + + /* End line or block analysis: test for an error */ + if( !Res ) + { + Msg.Printf( wxT( "%d " ), *lineNum ); + + if( errorMsg.IsEmpty() ) + errorMsg = wxT( "error at line " ) + Msg; + else + errorMsg = wxT( "error <" ) + errorMsg + + wxT( "> at line " ) + Msg; + return false; + } + } + + /* If we are here, this part is O.k. - put it in: */ + SortDrawItems(); + + return true; +} + + +bool EDA_LibComponentStruct::LoadDrawEntries( FILE* f, char* line, + int* lineNum, wxString& errorMsg ) +{ + bool entryLoaded; + LibEDA_BaseStruct* newEntry = NULL; + LibEDA_BaseStruct* headEntry = NULL; + LibEDA_BaseStruct* tailEntry = NULL; + + while( true ) + { + if( GetLine( f, line, lineNum, 1024 ) == NULL ) + { + errorMsg = wxT( "File ended prematurely" ); + return false; + } + + if( strncmp( line, "ENDDRAW", 7 ) == 0 ) + break; + + newEntry = NULL; + + switch( line[0] ) + { + case 'A': /* Arc */ + newEntry = ( LibEDA_BaseStruct* ) new LibDrawArc(); + entryLoaded = newEntry->Load( line, errorMsg ); + break; + + case 'C': /* Circle */ + newEntry = ( LibEDA_BaseStruct* ) new LibDrawCircle(); + entryLoaded = newEntry->Load( line, errorMsg ); + break; + + case 'T': /* Text */ + newEntry = ( LibEDA_BaseStruct* ) new LibDrawText(); + entryLoaded = newEntry->Load( line, errorMsg ); + break; + + case 'S': /* Square */ + newEntry = ( LibEDA_BaseStruct* ) new LibDrawSquare(); + entryLoaded = newEntry->Load( line, errorMsg ); + break; + + case 'X': /* Pin Description */ + newEntry = ( LibEDA_BaseStruct* ) new LibDrawPin(); + entryLoaded = newEntry->Load( line, errorMsg ); + break; + + case 'P': /* Polyline */ + newEntry = ( LibEDA_BaseStruct* ) new LibDrawPolyline(); + entryLoaded = newEntry->Load( line, errorMsg ); + break; + + default: + errorMsg.Printf( wxT( "Undefined DRAW command in line %d\n" \ + "%s, aborted." ), *lineNum, line ); + m_Drawings = headEntry; + return false; + } + + if( !entryLoaded ) + { + errorMsg.Printf( wxT( "> in DRAW command %c in line %d" ), line[0], + *lineNum ); + errorMsg = wxT( "Error <" ) + errorMsg + wxT( ", aborted." ); + SAFE_DELETE( newEntry ); + + /* Flush till end of draw section */ + do + { + if( GetLine( f, line, lineNum, 1024 ) == NULL ) + { + errorMsg = wxT( "File ended prematurely while attempting" \ + "to flush to end of drawing section." ); + return false; + } + } while( strncmp( line, "ENDDRAW", 7 ) != 0 ); + + + SAFE_DELETE( headEntry ); + return false; + } + else + { + if( headEntry == NULL ) + headEntry = tailEntry = newEntry; + else + { + tailEntry->SetNext( newEntry ); + tailEntry = newEntry; + } + } + } + + return true; +} + + +bool EDA_LibComponentStruct::LoadAliases( char* line, wxString& errorMsg ) +{ + char* text = strtok( line, " \t\r\n" ); + + while( text ) + { + m_AliasList.Add( CONV_FROM_UTF8( text ) ); + text = strtok( NULL, " \t\r\n" ); + } + + return true; +} + + +bool EDA_LibComponentStruct::LoadField( char* line, wxString& errorMsg ) +{ + LibDrawField* field = new LibDrawField(); + + if ( !field->Load( line, errorMsg ) ) + { + SAFE_DELETE( field ); + return false; + } + + if( field->m_FieldId == REFERENCE ) + field = &m_Prefix; + else if ( field->m_FieldId == VALUE ) + field = &m_Name; + else + m_Fields.PushBack( field ); + + return true; +} + + +bool EDA_LibComponentStruct::LoadFootprints( FILE* file, char* line, + int* lineNum, wxString& errorMsg ) +{ + while( stricmp( line, "$ENDFPLIST" ) != 0 ) + { + if( GetLine( file, line, lineNum, 1024 ) == NULL ) + { + errorMsg = wxT( "file ended prematurely while loading footprints" ); + return false; + } + + m_FootprintList.Add( CONV_FROM_UTF8( line + 1 ) ); + } + + return true; +} + + +/* TODO translate comment to english TODO + * Trie les �l�ments graphiques d'un composant lib pour am�liorer + * le trac�: + * items remplis en premier, pins en dernier + * En cas de superposition d'items, c'est plus lisible + */ +void EDA_LibComponentStruct::SortDrawItems() +{ + LibEDA_BaseStruct** Bufentry, ** BufentryBase, * Entry = m_Drawings; + int ii, nbitems; + + if( Entry == NULL ) + return; /* Pas d'alias pour ce composant */ + /* calcul du nombre d'items */ + for( nbitems = 0; Entry != NULL; Entry = Entry->Next() ) + nbitems++; + + BufentryBase = + (LibEDA_BaseStruct**) MyZMalloc( (nbitems + 1) * + sizeof(LibEDA_BaseStruct*) ); + + /* memorisation du chainage : */ + for( Entry = m_Drawings, ii = 0; Entry != NULL; Entry = Entry->Next() ) + BufentryBase[ii++] = Entry; + + /* Tri du chainage */ + qsort( BufentryBase, nbitems, sizeof(LibEDA_BaseStruct*), SortItemsFct ); + + /* Mise a jour du chainage. Remarque: + * le dernier element de BufEntryBase (BufEntryBase[nbitems]) est NULL*/ + m_Drawings = *BufentryBase; + Bufentry = BufentryBase; + for( ii = 0; ii < nbitems; ii++ ) + { + (*Bufentry)->SetNext( *(Bufentry + 1) ); + Bufentry++; + } + + MyFree( BufentryBase ); +} + + +/**********************************************************************/ +/* Return the component boundary box ( in user coordinates ) * The unit Unit, and the shape Convert are considered. * If Unit == 0, Unit is not used * if Convert == 0 Convert is non used **/ +/**********************************************************************/ +EDA_Rect EDA_LibComponentStruct::GetBoundaryBox( int Unit, int Convert ) { - int xmin, xmax, ymin, ymax, x1, y1; LibEDA_BaseStruct* DrawEntry; - EDA_Rect BoundaryBox; + EDA_Rect bBox( wxPoint( 0, 0 ), wxSize( 0, 0 ) ); - DrawEntry = m_Drawings; - if( DrawEntry ) - { - xmin = ymin = 0x7FFFFFFF; - xmax = ymax = 0x80000000; - } - else - { - xmin = ymin = -50; - xmax = ymax = 50; // Min size in 1/1000 inch - } - - for( ; DrawEntry != NULL; DrawEntry = DrawEntry->Next() ) + for( DrawEntry = m_Drawings; DrawEntry != NULL; + DrawEntry = DrawEntry->Next() ) { if( DrawEntry->m_Unit > 0 ) // The item is non common to units - if( (m_UnitCount > 1 ) && (Unit > 0) && (Unit != DrawEntry->m_Unit) ) + if( ( m_UnitCount > 1 ) && ( Unit > 0 ) + && ( Unit != DrawEntry->m_Unit ) ) continue; - if( DrawEntry->m_Convert > 0 ) //The item is not common to alls convert - if( (Convert > 0) && (Convert != DrawEntry->m_Convert) ) + if( DrawEntry->m_Convert > 0 ) // The item is not common to all convert + if( ( Convert > 0 ) && ( Convert != DrawEntry->m_Convert ) ) continue; - switch( DrawEntry->Type() ) - { - case COMPONENT_ARC_DRAW_TYPE: - { - // Arc is reduced to a line from m_Start to m_End. - // TODO better. - LibDrawArc* Arc = (LibDrawArc*) DrawEntry; - x1 = Arc->m_ArcStart.x; - y1 = Arc->m_ArcStart.y; - xmin = MIN( xmin, x1 ); - ymin = MIN( ymin, y1 ); - xmax = MAX( xmax, x1 ); - ymax = MAX( ymax, y1 ); - x1 = Arc->m_ArcEnd.x; - y1 = Arc->m_ArcEnd.y; - xmin = MIN( xmin, x1 ); - ymin = MIN( ymin, y1 ); - xmax = MAX( xmax, x1 ); - ymax = MAX( ymax, y1 ); - } - break; - - case COMPONENT_CIRCLE_DRAW_TYPE: - { - LibDrawCircle* Circle = (LibDrawCircle*) DrawEntry; - x1 = Circle->m_Pos.x - Circle->m_Rayon; - y1 = Circle->m_Pos.y - Circle->m_Rayon; - xmin = MIN( xmin, x1 ); - ymin = MIN( ymin, y1 ); - x1 = Circle->m_Pos.x + Circle->m_Rayon; - y1 = Circle->m_Pos.y + Circle->m_Rayon; - xmax = MAX( xmax, x1 ); - ymax = MAX( ymax, y1 ); - } - break; - - case COMPONENT_RECT_DRAW_TYPE: - { - LibDrawSquare* Square = (LibDrawSquare*) DrawEntry; - xmin = MIN( xmin, Square->m_Pos.x ); - xmin = MIN( xmin, Square->m_End.x ); - xmax = MAX( xmax, Square->m_Pos.x ); - xmax = MAX( xmax, Square->m_End.x ); - ymin = MIN( ymin, Square->m_Pos.y ); - ymin = MIN( ymin, Square->m_End.y ); - ymax = MAX( ymax, Square->m_Pos.y ); - ymax = MAX( ymax, Square->m_End.y ); - } - break; - - case COMPONENT_PIN_DRAW_TYPE: - { - LibDrawPin* Pin = (LibDrawPin*) DrawEntry; - x1 = Pin->m_Pos.x; - y1 = Pin->m_Pos.y; - xmin = MIN( xmin, x1 ); - xmax = MAX( xmax, x1 ); - ymin = MIN( ymin, y1 ); - ymax = MAX( ymax, y1 ); -#if 0 - // 0 pour englober le point origine de la pin, 1 pour englober toute la pin - switch( Pin->Orient ) - { - case PIN_UP: - y1 += Pin->Len; break; - - case PIN_DOWN: - y1 -= Pin->Len; break; - - case PIN_LEFT: - x1 -= Pin->Len; break; - - case PIN_RIGHT: - x1 += Pin->Len; break; - } - - xmin = MIN( xmin, x1 ); - xmax = MAX( xmax, x1 ); - ymin = MIN( ymin, y1 ); - ymax = MAX( ymax, y1 ); -#endif - } - break; - - case COMPONENT_GRAPHIC_TEXT_DRAW_TYPE: - break; - - case COMPONENT_POLYLINE_DRAW_TYPE: - { - EDA_Rect rect = ((LibDrawPolyline*) DrawEntry)->GetBoundaryBox( ); - xmin = MIN( xmin, rect.GetX() ); - xmax = MAX( xmax, rect.GetX() ); - ymin = MIN( ymin, rect.GetY() ); - ymax = MAX( ymax, rect.GetY() ); - xmin = MIN( xmin, rect.GetEnd().x ); - xmax = MAX( xmax, rect.GetEnd().x ); - ymin = MIN( ymin, rect.GetEnd().y ); - ymax = MAX( ymax, rect.GetEnd().y ); - } - break; - - default: - ; - } + bBox.Merge( DrawEntry->GetBoundingBox() ); } - // Update the BoundaryBox. Remember the fact the screen Y axis is the reverse */ - NEGATE(ymax); NEGATE(ymin); // y coordinates are screen oriented - // Ensure H > 0 - if( ymax < ymin ) - EXCHG( ymax, ymin ); - BoundaryBox.SetX( xmin ); BoundaryBox.SetWidth( xmax - xmin ); - BoundaryBox.SetY( ymin ); BoundaryBox.SetHeight( ymax - ymin ); + wxRect r = bBox; + wxLogDebug( wxT( "New boundary box = (%d, %d, %d, %d)" ), r.GetLeft(), + r.GetRight(), r.GetBottom(), r.GetTop() ); - return BoundaryBox; + return bBox; } @@ -275,26 +696,28 @@ void EDA_LibComponentStruct::SetFields( const std::vector aFields for( unsigned ii = FOOTPRINT; ii < aFields.size(); ii++ ) { - bool create = FALSE; - if( !aFields[ii].m_Text.IsEmpty() ) - create = TRUE; - if( !aFields[ii].m_Name.IsEmpty() - && ( aFields[ii].m_Name != ReturnDefaultFieldName( ii ) ) ) - create = TRUE; - if( create ) - { - LibDrawField*Field = new LibDrawField( ii ); - aFields[ii].Copy( Field ); - CurrentLibEntry->m_Fields.PushBack( Field ); - } + bool create = FALSE; + if( !aFields[ii].m_Text.IsEmpty() ) + create = TRUE; + if( !aFields[ii].m_Name.IsEmpty() + && ( aFields[ii].m_Name != ReturnDefaultFieldName( ii ) ) ) + create = TRUE; + if( create ) + { + LibDrawField*Field = new LibDrawField( ii ); + aFields[ii].Copy( Field ); + CurrentLibEntry->m_Fields.PushBack( Field ); + } } /* for a user field (FieldId >= FIELD1), if a field value is void, - * fill it with "~" because for a library component a void field is not a very good idea - * (we do not see anything...) and in schematic this text is like a void text - * and for non editable names, remove the name (set to the default name) + * fill it with "~" because for a library component a void field is not + * a very good idea (we do not see anything...) and in schematic this + * text is like a void text and for non editable names, remove the name + * (set to the default name) */ - for( LibDrawField* Field = CurrentLibEntry->m_Fields; Field; Field = Field->Next() ) + for( LibDrawField* Field = CurrentLibEntry->m_Fields; Field; + Field = Field->Next() ) { if( Field->m_FieldId >= FIELD1 ) { @@ -305,3 +728,82 @@ void EDA_LibComponentStruct::SetFields( const std::vector aFields Field->m_Name.Empty(); } } + + +/* + * lit date et time de modif composant sous le format: + * "Ti yy/mm/jj hh:mm:ss" + */ +bool EDA_LibComponentStruct::SaveDateAndTime( FILE* file ) +{ + int year, mon, day, hour, min, sec; + + if( m_LastDate == 0 ) + return true; + + sec = m_LastDate & 63; + min = (m_LastDate >> 6) & 63; + hour = (m_LastDate >> 12) & 31; + day = (m_LastDate >> 17) & 31; + mon = (m_LastDate >> 22) & 15; + year = (m_LastDate >> 26) + 1990; + + if ( fprintf( file, "Ti %d/%d/%d %d:%d:%d\n", + year, mon, day, hour, min, sec ) == EOF ) + return false; + + return true; +} + +/* lit date et time de modif composant sous le format: + * "Ti yy/mm/jj hh:mm:ss" + */ +bool EDA_LibComponentStruct::LoadDateAndTime( char* Line ) +{ + int year, mon, day, hour, min, sec; + char* text; + + year = mon = day = hour = min = sec = 0; + text = strtok( Line, " \r\t\n" ); + text = strtok( NULL, " \r\t\n" ); // text pointe donnees utiles + + if (sscanf( Line, "%d/%d/%d %d:%d:%d", + &year, &mon, &day, &hour, &min, &sec ) != 6 ) + return false; + + m_LastDate = ( sec & 63 ) + ( ( min & 63 ) << 6 ) + + ( ( hour & 31 ) << 12 ) + ( ( day & 31 ) << 17 ) + + ( ( mon & 15 ) << 22 ) + ( ( year - 1990 ) << 26 ); + + return true; +} + + +/** + * Function SaveDoc + * writes the doc info out to a FILE in "*.dcm" format. + * Only non empty fields are written. + * If all fields are empty, does not write anything + * @param aFile The FILE to write to. + * @return bool - true if success writing else false. + */ +bool LibCmpEntry::SaveDoc( FILE* aFile ) +{ + if( m_Doc.IsEmpty() && m_KeyWord.IsEmpty() && m_DocFile.IsEmpty() ) + return true; + + /* Generation des lignes utiles */ + fprintf( aFile, "#\n$CMP %s\n", CONV_TO_UTF8( m_Name.m_Text ) ); + + if( ! m_Doc.IsEmpty() ) + fprintf( aFile, "D %s\n", CONV_TO_UTF8( m_Doc ) ); + + if( ! m_KeyWord.IsEmpty() ) + fprintf( aFile, "K %s\n", CONV_TO_UTF8( m_KeyWord ) ); + + if( ! m_DocFile.IsEmpty() ) + fprintf( aFile, "F %s\n", CONV_TO_UTF8( m_DocFile ) ); + + fprintf( aFile, "$ENDCMP\n" ); + return true; +} diff --git a/eeschema/class_libentry.h b/eeschema/class_libentry.h index 0026d79ad4..41a04d7f81 100644 --- a/eeschema/class_libentry.h +++ b/eeschema/class_libentry.h @@ -25,15 +25,17 @@ enum LibrEntryOptions { }; -/* basic class to describe components in libraries (true component or alias), non used directly */ -class LibCmpEntry : public EDA_BaseStruct +/* basic class to describe components in libraries (true component or alias), + * non used directly */ +class LibCmpEntry : public EDA_BaseStruct { public: LibrEntryType Type; /* Type = ROOT; * = ALIAS pour struct LibraryAliasType */ LibDrawField m_Name; // name (74LS00 ..) in lib ( = VALUE ) wxString m_Doc; /* documentation for info */ - wxString m_KeyWord; /* keyword list (used to select a group of components by keyword) */ + wxString m_KeyWord; /* keyword list (used to select a group of + * components by keyword) */ wxString m_DocFile; /* Associed doc filename */ LibrEntryOptions m_Options; // special features (i.e. Entry is a POWER) @@ -62,20 +64,27 @@ public: class EDA_LibComponentStruct : public LibCmpEntry { public: - LibDrawField m_Prefix; /* Prefix ( U, IC ... ) = REFERENCE */ - wxArrayString m_AliasList; /* ALIAS list for the component */ - wxArrayString m_FootprintList; /* list of suitable footprint names for the component (wildcard names accepted)*/ - int m_UnitCount; /* Units (or sections) per package */ - bool m_UnitSelectionLocked; // True if units are differents and their selection is locked - // (i.e. if part A cannot be automatically changed in part B - int m_TextInside; /* if 0: pin name drawn on the pin itself - * if > 0 pin name drawn inside the component, - * with a distance of m_TextInside in mils */ + LibDrawField m_Prefix; /* Prefix ( U, IC ... ) = REFERENCE */ + wxArrayString m_AliasList; /* ALIAS list for the component */ + wxArrayString m_FootprintList; /* list of suitable footprint names + * for the component (wildcard names + * accepted) */ + int m_UnitCount; /* Units (or sections) per package */ + bool m_UnitSelectionLocked; /* True if units are differents + * and their selection is + * locked (i.e. if part A cannot + * be automatically changed in + * part B */ + int m_TextInside; /* if 0: pin name drawn on the pin + * itself if > 0 pin name drawn inside + * the component, with a distance of + * m_TextInside in mils */ bool m_DrawPinNum; bool m_DrawPinName; - DLIST m_Fields; /* Auxiliairy Field list (id >= 2 ) */ - LibEDA_BaseStruct* m_Drawings; /* How to draw this part */ - long m_LastDate; // Last change Date + DLIST m_Fields; /* Auxiliairy Field list (id >= 2 ) */ + LibEDA_BaseStruct* m_Drawings; /* How to draw this part */ + long m_LastDate; // Last change Date + DLIST m_DrawItems; public: virtual wxString GetClass() const @@ -85,31 +94,54 @@ public: EDA_LibComponentStruct( const wxChar* CmpName ); - EDA_Rect GetBoundaryBox( int Unit, int Convert ); /* return Box around the part. */ - ~EDA_LibComponentStruct(); + + EDA_Rect GetBoundaryBox( int Unit, int Convert ); + void SortDrawItems(); + bool SaveDateAndTime( FILE* ExportFile ); + bool LoadDateAndTime( char* Line ); + /** * Function Save - * writes the data structures for this object out to a FILE in "*.lib" format. + * writes the data structures for this object out to a FILE in "*.lib" + * format. * @param aFile The FILE to write to. * @return bool - true if success writing else false. */ - bool Save( FILE* aFile ); + bool Save( FILE* aFile ); + + /** + * Load component definition from file. + * + * @param file - File discriptor of file to load form. + * @param line - The first line of the component definition. + * @param lineNum - The current line number in the file. + * @param parent - The parent window for displaying message boxes. + * + * @return bool - Result of the load, false if there was an error. + */ + bool Load( FILE* file, char* line, int* lineNum, wxString& errorMsg ); + bool LoadField( char* line, wxString& errorMsg ); + bool LoadDrawEntries( FILE* f, char* line, + int* lineNum, wxString& errorMsg ); + bool LoadAliases( char* line, wxString& Error ); + bool LoadFootprints( FILE* file, char* line, + int* lineNum, wxString& errorMsg ); /** Function SetFields * initialize fields from a vector of fields * @param aFields a std::vector to import. */ - void SetFields( const std::vector aFields ); + void SetFields( const std::vector aFields ); }; /**************************************************************************/ /* class to handle an alias of an usual component in lib (root component) */ /**************************************************************************/ -class EDA_LibCmpAliasStruct : public LibCmpEntry +class EDA_LibCmpAliasStruct : public LibCmpEntry { public: wxString m_RootName; /* Root component Part name */ diff --git a/eeschema/class_libentry_fields.cpp b/eeschema/class_libentry_fields.cpp index a997d86c42..011ceb3850 100644 --- a/eeschema/class_libentry_fields.cpp +++ b/eeschema/class_libentry_fields.cpp @@ -1,40 +1,48 @@ /**********************************************************/ -/* libclass.cpp */ +/* libclass.cpp */ /**********************************************************/ #include "fctsys.h" #include "gr_basic.h" - #include "common.h" +#include "base_struct.h" +#include "drawtxt.h" +#include "kicad_string.h" + #include "program.h" #include "libcmp.h" #include "general.h" #include "protos.h" +#include +#include +#include + + /***************************/ /* class LibraryFieldEntry */ /***************************/ -/* a Field is a string linked to a component. +/** + * a Field is a string linked to a component. * Unlike a pure graphic text, fields can be used in netlist generation - * and other told (BOM). + * and other tools (BOM). * - * 4 fields have a special meaning: - * REFERENCE - * VALUE - * FOOTPRINT NAME - * DOCUMENTATION LINK (reserved but not used in kicad) + * The first 4 fields have a special meaning: + * + * 0 = REFERENCE + * 1 = VALUE + * 3 = FOOTPRINT (default Footprint) + * 4 = DOCUMENTATION (user doc link) + * + * others = free fields */ -LibDrawField::LibDrawField( int idfield ) : LibEDA_BaseStruct( COMPONENT_FIELD_DRAW_TYPE ) +LibDrawField::LibDrawField( int idfield ) : + LibEDA_BaseStruct( COMPONENT_FIELD_DRAW_TYPE ) { - m_FieldId = idfield; /* 0 = REFERENCE - * 1 = VALUE - * 3 = FOOTPRINT (default Footprint) - * 4 = DOCUMENTATION (user doc link) - * others = free fields - */ - m_Size.x = m_Size.y = DEFAULT_SIZE_TEXT; + m_FieldId = idfield; + m_Size.x = m_Size.y = DEFAULT_SIZE_TEXT; } @@ -43,6 +51,249 @@ LibDrawField::~LibDrawField() } +bool LibDrawField::Save( FILE* ExportFile ) const +{ + int hjustify, vjustify; + wxString text = m_Text; + + hjustify = 'C'; + if( m_HJustify == GR_TEXT_HJUSTIFY_LEFT ) + hjustify = 'L'; + else if( m_HJustify == GR_TEXT_HJUSTIFY_RIGHT ) + hjustify = 'R'; + vjustify = 'C'; + if( m_VJustify == GR_TEXT_VJUSTIFY_BOTTOM ) + vjustify = 'B'; + else if( m_VJustify == GR_TEXT_VJUSTIFY_TOP ) + vjustify = 'T'; + if( text.IsEmpty() ) + text = wxT( "~" ); + fprintf( ExportFile, "F%d \"%s\" %d %d %d %c %c %c %c%c%c", + m_FieldId, CONV_TO_UTF8( text ), m_Pos.x, m_Pos.y, m_Size.x, + m_Orient == 0 ? 'H' : 'V', + (m_Attributs & TEXT_NO_VISIBLE ) ? 'I' : 'V', + hjustify, vjustify, + m_Italic ? 'I' : 'N', + m_Width > 1 ? 'B' : 'N' ); + + /* Save field name, if necessary + * Field name is saved only if it is not the default name. + * Just because default name depends on the language and can change from + * a country to an other + */ + if( m_FieldId >= FIELD1 && !m_Name.IsEmpty() + && m_Name != ReturnDefaultFieldName( m_FieldId )) + fprintf( ExportFile, " \"%s\"", CONV_TO_UTF8( m_Name ) ); + + fprintf( ExportFile, "\n" ); + return true; +} + + +bool LibDrawField::Load( char* line, wxString& errorMsg ) +{ + int cnt; + char textOrient; + char textVisible; + char textHJustify; + char textVJustify[256]; + char fieldUserName[1024]; + char* text; + + if( sscanf( line + 1, "%d", &m_FieldId ) != 1 + || m_FieldId < REFERENCE || m_FieldId >= NUMBER_OF_FIELDS ) + return false; + + /* Recherche du debut des donnees (debut du texte suivant) */ + while( *line != 0 ) + line++; + + while( *line == 0 ) + line++; + + /* recherche du texte */ + while( *line && (*line != '"') ) + line++; + + if( *line == 0 ) + return false; + line++; + + text = line; + + /* recherche fin de texte */ + while( *line && (*line != '"') ) + line++; + + if( *line == 0 ) + return false; + + *line = 0; + line++; + + fieldUserName[0] = 0; + memset( textVJustify, 0, sizeof( textVJustify ) ); + + cnt = sscanf( line, " %d %d %d %c %c %c %s", &m_Pos.x, &m_Pos.y, &m_Size.y, + &textOrient, &textVisible, &textHJustify, textVJustify ); + + if( cnt < 5 ) + return false; + + m_Text = CONV_FROM_UTF8( text ); + m_Size.x = m_Size.y; + + if( textOrient == 'H' ) + m_Orient = TEXT_ORIENT_HORIZ; + else if( textOrient == 'V' ) + m_Orient = TEXT_ORIENT_VERT; + else + return false; + + if( textVisible == 'V' ) + m_Attributs &= ~TEXT_NO_VISIBLE; + else if ( textVisible == 'I' ) + m_Attributs |= TEXT_NO_VISIBLE; + else + return false; + + m_HJustify = GR_TEXT_HJUSTIFY_CENTER; + m_VJustify = GR_TEXT_VJUSTIFY_CENTER; + + if( cnt >= 6 ) + { + if( textHJustify == 'C' ) + m_HJustify = GR_TEXT_HJUSTIFY_CENTER; + else if( textHJustify == 'L' ) + m_HJustify = GR_TEXT_HJUSTIFY_LEFT; + else if( textHJustify == 'R' ) + m_HJustify = GR_TEXT_HJUSTIFY_RIGHT; + else + return false; + + if( textVJustify[0] == 'C' ) + m_VJustify = GR_TEXT_VJUSTIFY_CENTER; + else if( textVJustify[0] == 'B' ) + m_VJustify = GR_TEXT_VJUSTIFY_BOTTOM; + else if( textVJustify[0] == 'T' ) + m_VJustify = GR_TEXT_VJUSTIFY_TOP; + else + return false; + + if ( strlen( textVJustify ) >= 2 && textVJustify[1] == 'I' ) // Italic + m_Italic = true; + if ( strlen( textVJustify ) >= 2 && textVJustify[2] == 'B' ) // Bold + m_Width = m_Size.x / 4; + + } + + if( m_FieldId >= FIELD1 ) + { + ReadDelimitedText( fieldUserName, line, sizeof( fieldUserName ) ); + m_Name = CONV_FROM_UTF8( fieldUserName ); + } + + return true; +} + + +/* + * if aData not NULL, aData must point a wxString which is used instead of + * the m_Text + */ +void LibDrawField::Draw( WinEDA_DrawPanel* aPanel, wxDC* aDC, + const wxPoint& aOffset, int aColor, int aDrawMode, + void* aData, const int aTransformMatrix[2][2] ) +{ + wxPoint text_pos; + + int color = aColor; + int linewidth = MAX( m_Width, g_DrawMinimunLineWidth ); + + if( aColor < 0 ) // Used normal color or selected color + { + if( (m_Selected & IS_SELECTED) ) + color = g_ItemSelectetColor; + } + else + color = aColor; + + if( color < 0 ) + { + switch( m_FieldId ) + { + case REFERENCE: + color = ReturnLayerColor( LAYER_REFERENCEPART ); + break; + + case VALUE: + color = ReturnLayerColor( LAYER_VALUEPART ); + break; + + default: + color = ReturnLayerColor( LAYER_FIELDS ); + break; + } + } + text_pos = TransformCoordinate( aTransformMatrix, m_Pos ) + aOffset; + + wxString* text = aData ? (wxString*) aData : &m_Text; + GRSetDrawMode( aDC, aDrawMode ); + DrawGraphicText( aPanel, aDC, text_pos, (EDA_Colors) color, text->GetData(), + m_Orient ? TEXT_ORIENT_VERT : TEXT_ORIENT_HORIZ, + m_Size, m_HJustify, m_VJustify, linewidth, m_Italic ); +} + + +/** + * Function HitTest + * tests if the given wxPoint is within the bounds of this object. + * @param refPos A wxPoint to test, in Field coordinate system + * @return bool - true if a hit, else false + */ +bool LibDrawField::HitTest( const wxPoint& refPos ) +{ + EDA_Rect bbox; // bounding box for the text + int dx; // X size for the full text + + bbox.SetOrigin( m_Pos ); + + dx = m_Size.x * m_Text.Len(); + + // Reference designator text has one additional character (displays U?) + if( m_FieldId == REFERENCE ) + dx += m_Size.x; + + // spacing between characters is 0.1 the character size + dx = (int) ( (double) dx * 10.0 / 9 ); + int dy = m_Size.y; + + if( m_Orient ) + EXCHG( dx, dy ); // Swap X and Y size for a vertical text + + // adjust position of the left bottom corner according to the justification + // pos is at this point correct for a left and top justified text + // Horizontal justification + if( m_HJustify == GR_TEXT_HJUSTIFY_CENTER ) + bbox.Offset( -dx / 2, 0 ); + else if( m_HJustify == GR_TEXT_HJUSTIFY_RIGHT ) + bbox.Offset( -dx, 0 ); + + // Vertical justification + if( m_VJustify == GR_TEXT_VJUSTIFY_CENTER ) + bbox.Offset( 0, -dy / 2 ); + else if( m_VJustify == GR_TEXT_VJUSTIFY_TOP ) + bbox.Offset( 0, -dy ); + + bbox.SetSize( dx, dy ); + + if( bbox.Inside( refPos ) ) + return true; + + return false; +} + + // Creation et Duplication d'un field LibDrawField* LibDrawField::GenCopy() { @@ -73,62 +324,22 @@ void LibDrawField::Copy( LibDrawField* Target ) const } -/**************************************************/ -bool LibDrawField::Save( FILE* ExportFile ) const -/**************************************************/ -{ - int hjustify, vjustify; - wxString text = m_Text; - - hjustify = 'C'; - if( m_HJustify == GR_TEXT_HJUSTIFY_LEFT ) - hjustify = 'L'; - else if( m_HJustify == GR_TEXT_HJUSTIFY_RIGHT ) - hjustify = 'R'; - vjustify = 'C'; - if( m_VJustify == GR_TEXT_VJUSTIFY_BOTTOM ) - vjustify = 'B'; - else if( m_VJustify == GR_TEXT_VJUSTIFY_TOP ) - vjustify = 'T'; - if( text.IsEmpty() ) - text = wxT( "~" ); - fprintf( ExportFile, "F%d \"%s\" %d %d %d %c %c %c %c%c%c", - m_FieldId, CONV_TO_UTF8( text ), - m_Pos.x, m_Pos.y, - m_Size.x, - m_Orient == 0 ? 'H' : 'V', - (m_Attributs & TEXT_NO_VISIBLE ) ? 'I' : 'V', - hjustify, vjustify, - m_Italic ? 'I' : 'N', - m_Width > 1 ? 'B' : 'N' ); - - /* Save field name, if necessary - * Field name is saved only if it is not the default name. - * Just because default name depends on the language and can change from a country to an other - */ - if( m_FieldId >= FIELD1 && !m_Name.IsEmpty() && m_Name != ReturnDefaultFieldName( m_FieldId )) - fprintf( ExportFile, " \"%s\"", CONV_TO_UTF8( m_Name ) ); - - fprintf( ExportFile, "\n" ); - return true; -} - - -/****************************************************************/ -wxString ReturnDefaultFieldName( int aFieldNdx ) -/****************************************************************/ - -/** Function ReturnDefaultFieldName +/** + * Function ReturnDefaultFieldName * Return the default field name from its index (REFERENCE, VALUE ..) - * FieldDefaultNameList is not static, because we want the text translation for I18n + * FieldDefaultNameList is not static, because we want the text translation + * for I18n * @param aFieldNdx = Filed number (>= 0) */ +wxString ReturnDefaultFieldName( int aFieldNdx ) { // avoid unnecessarily copying wxStrings at runtime. static const wxString defaults[] = { _( "Reference" ), // Reference of part, i.e. "IC21" - _( "Value" ), // Value of part, i.e. "3.3K" and name in lib for lib entries - _( "Footprint" ), // Footprint, used by cvpcb or pcbnew, i.e. "16DIP300" + _( "Value" ), // Value of part, i.e. "3.3K" and name in lib + // for lib entries + _( "Footprint" ), // Footprint, used by cvpcb or pcbnew, i.e. + // "16DIP300" _( "Datasheet" ), // A link to an user document, if wanted }; @@ -142,4 +353,3 @@ wxString ReturnDefaultFieldName( int aFieldNdx ) return ret; } } - diff --git a/eeschema/class_libentry_fields.h b/eeschema/class_libentry_fields.h index 80ee38ed31..a95c9fd923 100644 --- a/eeschema/class_libentry_fields.h +++ b/eeschema/class_libentry_fields.h @@ -7,23 +7,26 @@ /* Fields , same as component fields. - * can be defined in libraries (mandatory for ref and value, ca be useful for footprints) + * can be defined in libraries (mandatory for ref and value, ca be useful for + * footprints) * 2 Fields are always defined : * Prefix (U, IC..) with gives the reference in schematic) - * Name (74LS00..) used to find the component in libraries, and give the default value in schematic + * Name (74LS00..) used to find the component in libraries, and give the + * default value in schematic */ -class LibDrawField : public LibEDA_BaseStruct, +class LibDrawField : public LibEDA_BaseStruct, public EDA_TextStruct { public: - int m_FieldId; /* 0 = REFERENCE - * 1 = VALUE - * 3 = FOOTPRINT (default Footprint) - * 4 = DOCUMENTATION (user doc link) - * others = free fields - */ - wxString m_Name; /* Field Name (not the field text itself, that is .m_Text) */ + int m_FieldId; /* 0 = REFERENCE + * 1 = VALUE + * 3 = FOOTPRINT (default Footprint) + * 4 = DOCUMENTATION (user doc link) + * others = free fields + */ + wxString m_Name; /* Field Name (not the field text itself, that is + * .m_Text) */ public: @@ -41,12 +44,13 @@ public: /** * Function Save - * writes the data structures for this object out to a FILE in "*.brd" format. + * writes the data structures for this object out to a FILE in "*.brd" + * format. * @param aFile The FILE to write to. * @return bool - true if success writing else false. */ - virtual bool Save( FILE* aFile ) const; - + virtual bool Save( FILE* aFile ) const; + virtual bool Load( char* line, wxString& errorMsg ); LibDrawField* GenCopy(); @@ -58,8 +62,9 @@ public: void SetFields( const std::vector aFields ); - void Draw( WinEDA_DrawPanel * aPanel, wxDC * aDC, const wxPoint &aOffset, int aColor, - int aDrawMode, void* aData, const int aTransformMatrix[2][2] ); + void Draw( WinEDA_DrawPanel * aPanel, wxDC * aDC, const wxPoint &aOffset, + int aColor, int aDrawMode, void* aData, + const int aTransformMatrix[2][2] ); /** * Function HitTest @@ -68,6 +73,21 @@ public: * @return bool - true if a hit, else false */ bool HitTest( const wxPoint& refPos ); + + void operator=( const LibDrawField& field ) + { + m_FieldId = field.m_FieldId; + m_Text = field.m_Text; + m_Pos = field.m_Pos; + m_Size = field.m_Size; + m_Width = field.m_Width; + m_Orient = field.m_Orient; + m_Mirror = field.m_Mirror; + m_Attributs = field.m_Attributs; + m_Italic = field.m_Italic; + m_HJustify = field.m_HJustify; + m_VJustify = field.m_VJustify; + } }; #endif // CLASS_LIBENTRY_FIELDS_H diff --git a/eeschema/class_library.cpp b/eeschema/class_library.cpp index b26fe340cb..d6cef15dfe 100644 --- a/eeschema/class_library.cpp +++ b/eeschema/class_library.cpp @@ -4,36 +4,56 @@ #include "fctsys.h" #include "gr_basic.h" +#include "common.h" #include "kicad_string.h" +#include "confirm.h" +#include "gestfich.h" + #include "program.h" #include "libcmp.h" #include "general.h" - #include "protos.h" +#include "class_library.h" -/***************************************************************************************/ -LibraryStruct::LibraryStruct( int type, const wxString& name, const wxString& fullname ) -/***************************************************************************************/ +#include +#include +#include +#include + +WX_DEFINE_LIST( LIB_CMP_LIST ); + + +LibraryStruct::LibraryStruct( int type, const wxString& name, + const wxString& fullname ) { - m_Type = type; /* type indicator */ - m_Name = name; /* Name of library loaded. */ - m_FullFileName = fullname; /* Full File Name (with path) of library loaded. */ - m_NumOfParts = 0; /* Number of parts this library has. */ - m_Entries = NULL; /* Parts themselves are saved here. */ - m_Pnext = NULL; /* Point on next lib in chain. */ - m_Modified = FALSE; /* flag indicateur d'edition */ + m_Type = type; /* type indicator */ + m_Name = name; /* Name of library loaded. */ + m_FullFileName = fullname; /* File name (with path) of library loaded. */ + m_NumOfParts = 0; /* Number of parts this library has. */ + m_Entries = NULL; /* Parts themselves are saved here. */ + m_Pnext = NULL; /* Point to next library in chain. */ + m_Modified = FALSE; /* flag indicateur d'edition */ m_TimeStamp = 0; m_Flags = 0; m_IsLibCache = FALSE; + m_DateTime = wxDateTime::Now(); +} + + +LibraryStruct::LibraryStruct( const wxChar* fileName ) +{ + if( fileName == NULL ) + m_fileName = wxT( "unnamed.lib" ); + else + m_fileName = fileName; } /*****************************************/ -void FreeLibraryEntry( LibCmpEntry* Entry ) -/*****************************************/ - /* Used by PQFreeFunc() to delete all entries */ +/*****************************************/ +void FreeLibraryEntry( LibCmpEntry* Entry ) { SAFE_DELETE( Entry ); } @@ -41,27 +61,26 @@ void FreeLibraryEntry( LibCmpEntry* Entry ) /******************************/ LibraryStruct::~LibraryStruct() -/******************************/ { if( m_Entries ) PQFreeFunc( m_Entries, ( void( * ) ( void* ) )FreeLibraryEntry ); + + m_componentList.DeleteContents( true ); } /*******************************************/ -bool LibraryStruct::WriteHeader( FILE* file ) -/*******************************************/ - /* Ecrit l'entete du fichier librairie */ +/*******************************************/ +bool LibraryStruct::WriteHeader( FILE* file ) { char BufLine[1024]; bool succes = TRUE; DateAndTime( BufLine ); if( fprintf( file, "%s %d.%d Date: %s\n", LIBFILE_IDENT, - LIB_VERSION_MAJOR, LIB_VERSION_MINOR, - BufLine ) != 5 ) + LIB_VERSION_MAJOR, LIB_VERSION_MINOR, BufLine ) != 5 ) succes = FALSE; #if 0 if( fprintf( file, "$HEADER\n" ) != 1 ) @@ -78,11 +97,10 @@ bool LibraryStruct::WriteHeader( FILE* file ) /***********************************************************/ -bool LibraryStruct::ReadHeader( FILE* libfile, int* LineNum ) -/***********************************************************/ - /* Ecrit l'entete du fichier librairie */ +/***********************************************************/ +bool LibraryStruct::ReadHeader( FILE* libfile, int* LineNum ) { char Line[1024], * text, * data; @@ -99,3 +117,117 @@ bool LibraryStruct::ReadHeader( FILE* libfile, int* LineNum ) return FALSE; } + +/** + * Function SaveLibrary + * writes the data structures for this object out to 2 file + * the library in "*.lib" format. + * the doc file in "*.dcm" format. + * creates a backup file for each file (.bak and .bck) + * @param aFullFileName The full lib filename. + * @return bool - true if success writing else false. + */ +bool LibraryStruct::SaveLibrary( const wxString& FullFileName ) +{ + FILE* libfile, *docfile; + EDA_LibComponentStruct* LibEntry; + wxString msg; + wxFileName libFileName = FullFileName; + wxFileName backupFileName = FullFileName; + wxFileName docFileName = FullFileName; + + /* the old .lib file is renamed .bak */ + if( libFileName.FileExists() ) + { + backupFileName.SetExt( wxT( "bak" ) ); + wxRemoveFile( backupFileName.GetFullPath() ); + + if( !wxRenameFile( libFileName.GetFullPath(), + backupFileName.GetFullPath() ) ) + { + msg = wxT( "Failed to rename old lib file " ) + + backupFileName.GetFullPath(); + DisplayError( NULL, msg, 20 ); + } + } + + docFileName.SetExt( DOC_EXT ); + /* L'ancien fichier doc lib est renomme en .bck */ + if( wxFileExists( docFileName.GetFullPath() ) ) + { + backupFileName = docFileName; + backupFileName.SetExt( wxT( "bck" ) ); + wxRemoveFile( backupFileName.GetFullPath() ); + + if( !wxRenameFile( docFileName.GetFullPath(), + backupFileName.GetFullPath() ) ) + { + msg = wxT( "Failed to save old doc lib file " ) + + backupFileName.GetFullPath(); + DisplayError( NULL, msg, 20 ); + } + } + + + libfile = wxFopen( libFileName.GetFullPath(), wxT( "wt" ) ); + + if( libfile == NULL ) + { + msg = wxT( "Failed to create Lib File " ) + libFileName.GetFullPath(); + DisplayError( NULL, msg, 20 ); + return false; + } + + docfile = wxFopen( docFileName.GetFullPath(), wxT( "wt" ) ); + + if( docfile == NULL ) + { + msg = wxT( "Failed to create DocLib File " ) + + docFileName.GetFullPath(); + DisplayError( NULL, msg, 20 ); + } + + m_Modified = 0; + + /* Creation de l'entete de la librairie */ + m_TimeStamp = GetTimeStamp(); + WriteHeader( libfile ); + + /* Sauvegarde des composant: */ + PQCompFunc( (PQCompFuncType) LibraryEntryCompare ); + LibEntry = (EDA_LibComponentStruct*) PQFirst( &m_Entries, FALSE ); + char Line[256]; + fprintf( docfile, "%s Date: %s\n", DOCFILE_IDENT, + DateAndTime( Line ) ); + + bool success = true; + while( LibEntry ) + { + if ( LibEntry->Type == ROOT ) + { + if ( ! LibEntry->Save( libfile ) ) + success = false; + } + if ( docfile ) + { + if ( ! LibEntry->SaveDoc( docfile ) ) + success = false; + } + + LibEntry = (EDA_LibComponentStruct*) PQNext( m_Entries, + LibEntry, NULL ); + } + + fprintf( libfile, "#\n#End Library\n" ); + if ( docfile ) + fprintf( docfile, "#\n#End Doc Library\n" ); + fclose( libfile ); + fclose( docfile ); + return success; +} + + +wxString LibraryStruct::GetName() +{ + return m_fileName.GetName(); +} diff --git a/eeschema/class_library.h b/eeschema/class_library.h index 5a7b6667b1..c3c864848b 100644 --- a/eeschema/class_library.h +++ b/eeschema/class_library.h @@ -5,8 +5,11 @@ #ifndef CLASS_LIBRARY_H #define CLASS_LIBRARY_H + #include "class_libentry.h" +WX_DECLARE_LIST( EDA_LibComponentStruct, LIB_CMP_LIST ); + /******************************/ /* Classe to handle a library */ @@ -15,23 +18,24 @@ class LibraryStruct { public: - int m_Type; /* type indicator */ - wxString m_Name; /* Short Name of the loaded library (without path). */ - wxString m_FullFileName; /* Full File Name (with path) of library. */ - wxString m_Header; /* first line of loaded library. */ - int m_NumOfParts; /* Number of parts this library has. */ - PriorQue* m_Entries; /* Parts themselves are saved here. */ - LibraryStruct* m_Pnext; /* Point on next lib in chain. */ - int m_Modified; /* flag indicateur d'edition */ - int m_Size; // Size in bytes (for statistics) - unsigned long m_TimeStamp; // Signature temporelle - int m_Flags; // variable used in some functions - bool m_IsLibCache; /* False for the "standard" libraries, - * True for the library cache */ + int m_Type; /* type indicator */ + wxString m_Name; /* Library file name (without path). */ + wxString m_FullFileName; /* Full File Name (with path) of library. */ + wxString m_Header; /* first line of loaded library. */ + int m_NumOfParts; /* Number of parts this library has. */ + PriorQue* m_Entries; /* Parts themselves are saved here. */ + LibraryStruct* m_Pnext; /* Point on next lib in chain. */ + int m_Modified; /* flag indicateur d'edition */ + int m_Size; // Size in bytes (for statistics) + unsigned long m_TimeStamp; // Signature temporelle + int m_Flags; // variable used in some functions + bool m_IsLibCache; /* False for the "standard" libraries, + * True for the library cache */ public: LibraryStruct( int type, const wxString& name, const wxString& fullname ); ~LibraryStruct(); + /** * Function SaveLibrary * writes the data structures for this object out to 2 file @@ -42,11 +46,27 @@ public: * @return bool - true if success writing else false. */ bool SaveLibrary( const wxString& aFullFileName ); - bool ReadHeader( FILE* file, int* LineNum ); + private: bool WriteHeader( FILE* file ); + + /* NOTE: For future expansion, do not delete. */ +public: + LibraryStruct( const wxChar* fileName = NULL ); + + bool Save( const wxString& saveAsFile ); + + wxString GetName(); + +protected: + wxFileName m_fileName; /* Library file name. */ + wxDateTime m_DateTime; /* Library save time and date. */ + wxString m_Version; /* Library save version. */ + LIB_CMP_LIST m_componentList; /* List of components in this library. */ + + friend class EDA_LibComponentStruct; }; #endif // CLASS_LIBRARY_H diff --git a/eeschema/class_pin.cpp b/eeschema/class_pin.cpp index 40893350e9..d56d596645 100644 --- a/eeschema/class_pin.cpp +++ b/eeschema/class_pin.cpp @@ -15,18 +15,216 @@ #include "protos.h" -/**********************************************************************************************/ -void LibDrawPin::Draw( WinEDA_DrawPanel* aPanel, - wxDC* aDC, - const wxPoint& aOffset, - int aColor, - int aDrawMode, - void* aData, - const int aTransformMatrix[2][2] ) -/**********************************************************************************************/ +LibDrawPin::LibDrawPin() : LibEDA_BaseStruct( COMPONENT_PIN_DRAW_TYPE ) +{ + m_PinLen = 300; /* default Pin len */ + m_Orient = PIN_RIGHT; /* Pin oprient: Up, Down, Left, Right */ + m_PinShape = NONE; /* Bit a bit: Pin shape (voir enum prec) */ + m_PinType = PIN_UNSPECIFIED; /* electrical type of pin */ + m_Attributs = 0; /* bit 0 != 0: pin invisible */ + m_PinNum = 0; /*pin number ( i.e. 4 codes Ascii ) */ + m_PinNumSize = 50; + m_PinNameSize = 50; /* Default size for pin name and num */ + m_Width = 0; + m_typeName = _( "Pin" ); +// m_PinNumWidth = m_PinNameWidth = 0; // Unused +} + + +bool LibDrawPin::Save( FILE* ExportFile ) const +{ + wxString StringPinNum; + int Etype; + + switch( m_PinType ) + { + default: + case PIN_INPUT: + Etype = 'I'; + break; + case PIN_OUTPUT: + Etype = 'O'; + break; + case PIN_BIDI: + Etype = 'B'; + break; + case PIN_TRISTATE: + Etype = 'T'; + break; + case PIN_PASSIVE: + Etype = 'P'; + break; + case PIN_UNSPECIFIED: + Etype = 'U'; + break; + case PIN_POWER_IN: + Etype = 'W'; + break; + case PIN_POWER_OUT: + Etype = 'w'; + break; + case PIN_OPENCOLLECTOR: + Etype = 'C'; + break; + case PIN_OPENEMITTER: + Etype = 'E'; + break; + } + + ReturnPinStringNum( StringPinNum ); + if( StringPinNum.IsEmpty() ) + StringPinNum = wxT( "~" ); + + if( !m_PinName.IsEmpty() ) + fprintf( ExportFile, "X %s", CONV_TO_UTF8( m_PinName ) ); + else + fprintf( ExportFile, "X ~" ); + + fprintf( ExportFile, " %s %d %d %d %c %d %d %d %d %c", + CONV_TO_UTF8( StringPinNum ), m_Pos.x, m_Pos.y, + (int) m_PinLen, (int) m_Orient, m_PinNumSize, m_PinNameSize, + m_Unit, m_Convert, Etype ); + + if( (m_PinShape) || (m_Attributs & PINNOTDRAW) ) + fprintf( ExportFile, " " ); + if( m_Attributs & PINNOTDRAW ) + fprintf( ExportFile, "N" ); + if( m_PinShape & INVERT ) + fprintf( ExportFile, "I" ); + if( m_PinShape & CLOCK ) + fprintf( ExportFile, "C" ); + if( m_PinShape & LOWLEVEL_IN ) + fprintf( ExportFile, "L" ); + if( m_PinShape & LOWLEVEL_OUT ) + fprintf( ExportFile, "V" ); + + fprintf( ExportFile, "\n" ); + return true; +} + + +bool LibDrawPin::Load( char* line, wxString& errorMsg ) +{ + int i, j; + char pinAttrs[64]; + char pinName[256]; + char pinNum[64]; + char pinOrient[64]; + char pinType[64]; + + *pinAttrs = 0; + + i = sscanf( line + 2, "%s %s %d %d %d %s %d %d %d %d %s %s", pinName, + pinNum, &m_Pos.x, &m_Pos.y, &m_PinLen, pinOrient, &m_PinNumSize, + &m_PinNameSize, &m_Unit, &m_Convert, pinType, pinAttrs ); + + if( i < 11 ) + { + errorMsg.Printf( wxT( "pin only had %d parameters of the " \ + "required 11 or 12" ), i ); + return false; + } + + m_Orient = pinOrient[0] & 255; + strncpy( (char*) &m_PinNum, pinNum, 4 ); + m_PinName = CONV_FROM_UTF8( pinName ); + + switch( *pinType & 255 ) + { + case 'I': + m_PinType = PIN_INPUT; + break; + + case 'O': + m_PinType = PIN_OUTPUT; + break; + + case 'B': + m_PinType = PIN_BIDI; + break; + + case 'T': + m_PinType = PIN_TRISTATE; + break; + + case 'P': + m_PinType = PIN_PASSIVE; + break; + + case 'U': + m_PinType = PIN_UNSPECIFIED; + break; + + case 'W': + m_PinType = PIN_POWER_IN; + break; + + case 'w': + m_PinType = PIN_POWER_OUT; + break; + + case 'C': + m_PinType = PIN_OPENCOLLECTOR; + break; + + case 'E': + m_PinType = PIN_OPENEMITTER; + break; + + default: + errorMsg.Printf( wxT( "unknown pin type [%c]" ), *pinType & 255 ); + return false; + } + + if( i == 12 ) /* Special Symbole defined */ + { + for( j = strlen( pinAttrs ); j > 0; ) + { + switch( pinAttrs[--j] ) + { + case '~': + break; + + case 'N': + m_Attributs |= PINNOTDRAW; + break; + + case 'I': + m_PinShape |= INVERT; + break; + + case 'C': + m_PinShape |= CLOCK; + break; + + case 'L': + m_PinShape |= LOWLEVEL_IN; + break; + + case 'V': + m_PinShape |= LOWLEVEL_OUT; + break; + + default: + errorMsg.Printf( wxT( "unknown pin attribute [%c]" ), + pinAttrs[j] ); + return false; + } + } + } + + return true; +} + + +void LibDrawPin::Draw( WinEDA_DrawPanel* aPanel, wxDC* aDC, + const wxPoint& aOffset, int aColor, + int aDrawMode, void* aData, + const int aTransformMatrix[2][2] ) { // Invisibles pins are only drawn on request. - // But in libedit they are drawn in g_InvisibleItemColor because we must see them + // But in libedit they are drawn in g_InvisibleItemColor because we must + // see them WinEDA_SchematicFrame* frame = (WinEDA_SchematicFrame*) wxGetApp().GetTopWindow(); @@ -53,37 +251,30 @@ void LibDrawPin::Draw( WinEDA_DrawPanel* aPanel, if( DrawPinText ) { - DrawPinTexts( aPanel, aDC, pos1, orient, - Entry->m_TextInside, + DrawPinTexts( aPanel, aDC, pos1, orient, Entry->m_TextInside, Entry->m_DrawPinNum, Entry->m_DrawPinName, aColor, aDrawMode ); } } -/********************************************************************************/ -void LibDrawPin::DrawPinSymbol( WinEDA_DrawPanel* aPanel, - wxDC* aDC, - const wxPoint& aPinPos, - int aOrient, - int aDrawMode, - int aColor ) -/*******************************************************************************/ - /* Draw the pin symbol (without texts) * if Color != 0 draw with Color, else with the normal pin color */ +void LibDrawPin::DrawPinSymbol( WinEDA_DrawPanel* aPanel, wxDC* aDC, + const wxPoint& aPinPos, int aOrient, + int aDrawMode, int aColor ) { int MapX1, MapY1, x1, y1; int color; int width = MAX( m_Width, g_DrawMinimunLineWidth ); int posX = aPinPos.x, posY = aPinPos.y, len = m_PinLen; - + BASE_SCREEN* screen = aPanel->GetScreen(); color = ReturnLayerColor( LAYER_PIN ); if( aColor < 0 ) // Used normal color or selected color { - if( (m_Selected & IS_SELECTED) ) + if( m_Selected & IS_SELECTED ) color = g_ItemSelectetColor; } else @@ -91,32 +282,38 @@ void LibDrawPin::DrawPinSymbol( WinEDA_DrawPanel* aPanel, GRSetDrawMode( aDC, aDrawMode ); - MapX1 = MapY1 = 0; x1 = posX; y1 = posY; + MapX1 = MapY1 = 0; + x1 = posX; + y1 = posY; switch( aOrient ) { case PIN_UP: - y1 = posY - len; MapY1 = 1; + y1 = posY - len; + MapY1 = 1; break; case PIN_DOWN: - y1 = posY + len; MapY1 = -1; + y1 = posY + len; + MapY1 = -1; break; case PIN_LEFT: - x1 = posX - len, MapX1 = 1; + x1 = posX - len; + MapX1 = 1; break; case PIN_RIGHT: - x1 = posX + len; MapX1 = -1; + x1 = posX + len; + MapX1 = -1; break; } if( m_PinShape & INVERT ) { GRCircle( &aPanel->m_ClipBox, aDC, MapX1 * INVERT_PIN_RADIUS + x1, - MapY1 * INVERT_PIN_RADIUS + y1, - INVERT_PIN_RADIUS, width, color ); + MapY1 * INVERT_PIN_RADIUS + y1, INVERT_PIN_RADIUS, width, + color ); GRMoveTo( MapX1 * INVERT_PIN_RADIUS * 2 + x1, MapY1 * INVERT_PIN_RADIUS * 2 + y1 ); @@ -133,33 +330,17 @@ void LibDrawPin::DrawPinSymbol( WinEDA_DrawPanel* aPanel, if( MapY1 == 0 ) /* MapX1 = +- 1 */ { GRMoveTo( x1, y1 + CLOCK_PIN_DIM ); - GRLineTo( &aPanel->m_ClipBox, - aDC, - x1 - MapX1 * CLOCK_PIN_DIM, - y1, - width, - color ); - GRLineTo( &aPanel->m_ClipBox, - aDC, - x1, - y1 - CLOCK_PIN_DIM, - width, + GRLineTo( &aPanel->m_ClipBox, aDC, x1 - MapX1 * CLOCK_PIN_DIM, + y1, width, color ); + GRLineTo( &aPanel->m_ClipBox, aDC, x1, y1 - CLOCK_PIN_DIM, width, color ); } else /* MapX1 = 0 */ { GRMoveTo( x1 + CLOCK_PIN_DIM, y1 ); - GRLineTo( &aPanel->m_ClipBox, - aDC, - x1, - y1 - MapY1 * CLOCK_PIN_DIM, - width, - color ); - GRLineTo( &aPanel->m_ClipBox, - aDC, - x1 - CLOCK_PIN_DIM, - y1, - width, + GRLineTo( &aPanel->m_ClipBox, aDC, x1, y1 - MapY1 * CLOCK_PIN_DIM, + width, color ); + GRLineTo( &aPanel->m_ClipBox, aDC, x1 - CLOCK_PIN_DIM, y1, width, color ); } } @@ -169,12 +350,9 @@ void LibDrawPin::DrawPinSymbol( WinEDA_DrawPanel* aPanel, if( MapY1 == 0 ) /* MapX1 = +- 1 */ { GRMoveTo( x1 + MapX1 * IEEE_SYMBOL_PIN_DIM * 2, y1 ); - GRLineTo( &aPanel->m_ClipBox, - aDC, + GRLineTo( &aPanel->m_ClipBox, aDC, x1 + MapX1 * IEEE_SYMBOL_PIN_DIM * 2, - y1 - IEEE_SYMBOL_PIN_DIM, - width, - color ); + y1 - IEEE_SYMBOL_PIN_DIM, width, color ); GRLineTo( &aPanel->m_ClipBox, aDC, x1, y1, width, color ); } else /* MapX1 = 0 */ @@ -192,34 +370,22 @@ void LibDrawPin::DrawPinSymbol( WinEDA_DrawPanel* aPanel, if( MapY1 == 0 ) /* MapX1 = +- 1 */ { GRMoveTo( x1, y1 - IEEE_SYMBOL_PIN_DIM ); - GRLineTo( &aPanel->m_ClipBox, - aDC, - x1 + MapX1 * IEEE_SYMBOL_PIN_DIM * 2, - y1, - width, - color ); + GRLineTo( &aPanel->m_ClipBox, aDC, + x1 + MapX1 * IEEE_SYMBOL_PIN_DIM * 2, y1, width, color ); } else /* MapX1 = 0 */ { GRMoveTo( x1 - IEEE_SYMBOL_PIN_DIM, y1 ); - GRLineTo( &aPanel->m_ClipBox, - aDC, - x1, - y1 + MapY1 * IEEE_SYMBOL_PIN_DIM * 2, - width, - color ); + GRLineTo( &aPanel->m_ClipBox, aDC, x1, + y1 + MapY1 * IEEE_SYMBOL_PIN_DIM * 2, width, color ); } } /* Draw the pin end target (active end of the pin) */ - if( !g_IsPrinting ) // Draw but do not print the pin end target 1 pixel width */ - GRCircle( &aPanel->m_ClipBox, - aDC, - posX, - posY, - TARGET_PIN_DIAM, - 0, - color ); + /* Draw but do not print the pin end target 1 pixel width */ + if( !screen->m_IsPrinting ) + GRCircle( &aPanel->m_ClipBox, aDC, posX, posY, TARGET_PIN_DIAM, + 0, color ); } @@ -231,16 +397,11 @@ void LibDrawPin::DrawPinSymbol( WinEDA_DrawPanel* aPanel, * If TextInside then the text is been put inside,otherwise all is drawn outside. * Pin Name: substring beteween '~' is negated *****************************************************************************/ -void LibDrawPin::DrawPinTexts( WinEDA_DrawPanel* panel, - wxDC* DC, - wxPoint& pin_pos, - int orient, - int TextInside, - bool DrawPinNum, - bool DrawPinName, - int Color, - int DrawMode ) /* DrawMode = GR_OR, XOR ... */ +void LibDrawPin::DrawPinTexts( WinEDA_DrawPanel* panel, wxDC* DC, + wxPoint& pin_pos, int orient, + int TextInside, bool DrawPinNum, + bool DrawPinName, int Color, int DrawMode ) { int ii, x, y, x1, y1, dx, dy, len; wxString StringPinNum; @@ -260,34 +421,43 @@ void LibDrawPin::DrawPinTexts( WinEDA_DrawPanel* panel, /* Get the num and name colors */ if( (Color < 0) && (m_Selected & IS_SELECTED) ) Color = g_ItemSelectetColor; - NameColor = (EDA_Colors) (Color == -1 ? ReturnLayerColor( LAYER_PINNAM ) : Color); - NumColor = (EDA_Colors) (Color == -1 ? ReturnLayerColor( LAYER_PINNUM ) : Color); + NameColor = (EDA_Colors) ( ( Color == -1 ) ? + ReturnLayerColor( LAYER_PINNAM ) : Color ); + NumColor = (EDA_Colors) ( ( Color == -1 ) ? + ReturnLayerColor( LAYER_PINNUM ) : Color ); /* Create the pin num string */ ReturnPinStringNum( StringPinNum ); - x1 = pin_pos.x; y1 = pin_pos.y; + x1 = pin_pos.x; + y1 = pin_pos.y; switch( orient ) { case PIN_UP: - y1 -= m_PinLen; break; + y1 -= m_PinLen; + break; case PIN_DOWN: - y1 += m_PinLen; break; + y1 += m_PinLen; + break; case PIN_LEFT: - x1 -= m_PinLen; break; + x1 -= m_PinLen; + break; case PIN_RIGHT: - x1 += m_PinLen; break; + x1 += m_PinLen; + break; } const wxChar* textsrc = m_PinName.GetData(); float fPinTextPitch = (PinNameSize.x * 1.1) + LineWidth; /* Do we need to invert the string? Is this string has only "~"? */ - PinTextBarCount = 0; PinTxtLen = 0; + PinTextBarCount = 0; + PinTxtLen = 0; ii = 0; + while( *textsrc ) { if( *textsrc == '~' ) @@ -321,11 +491,8 @@ void LibDrawPin::DrawPinTexts( WinEDA_DrawPanel* panel, if( orient == PIN_RIGHT ) { x = x1 + TextInside; - DrawGraphicText( panel, DC, wxPoint( x, - y1 ), NameColor, - PinText, - TEXT_ORIENT_HORIZ, - PinNameSize, + DrawGraphicText( panel, DC, wxPoint( x, y1 ), NameColor, + PinText, TEXT_ORIENT_HORIZ, PinNameSize, GR_TEXT_HJUSTIFY_LEFT, GR_TEXT_VJUSTIFY_CENTER, LineWidth ); @@ -337,22 +504,15 @@ void LibDrawPin::DrawPinTexts( WinEDA_DrawPanel* panel, dx = PinTextBarPos[ii++]; // Get the line pos GRMoveRel( dx, 0 ); len = PinTextBarPos[ii++] - dx; // Get the line length - GRLineRel( &panel->m_ClipBox, - DC, - len, - 0, - LineWidth, + GRLineRel( &panel->m_ClipBox, DC, len, 0, LineWidth, NameColor ); } } else // Orient == PIN_LEFT { x = x1 - TextInside; - DrawGraphicText( panel, DC, wxPoint( x, - y1 ), NameColor, - PinText, - TEXT_ORIENT_HORIZ, - PinNameSize, + DrawGraphicText( panel, DC, wxPoint( x, y1 ), NameColor, + PinText, TEXT_ORIENT_HORIZ, PinNameSize, GR_TEXT_HJUSTIFY_RIGHT, GR_TEXT_VJUSTIFY_CENTER, LineWidth ); @@ -364,11 +524,7 @@ void LibDrawPin::DrawPinTexts( WinEDA_DrawPanel* panel, dx = PinTextBarPos[ii++]; // Get the line pos GRMoveRel( dx - PinTxtLen, 0 ); len = PinTextBarPos[ii++] - dx; // Get the line length - GRLineRel( &panel->m_ClipBox, - DC, - len, - 0, - LineWidth, + GRLineRel( &panel->m_ClipBox, DC, len, 0, LineWidth, NameColor ); } } @@ -376,28 +532,25 @@ void LibDrawPin::DrawPinTexts( WinEDA_DrawPanel* panel, if( DrawPinNum ) { - DrawGraphicText( panel, DC, - wxPoint( (x1 + pin_pos.x) / 2, - y1 - TXTMARGE ), NumColor, - StringPinNum, - TEXT_ORIENT_HORIZ, PinNumSize, + DrawGraphicText( panel, DC, wxPoint( (x1 + pin_pos.x) / 2, + y1 - TXTMARGE ), NumColor, + StringPinNum, TEXT_ORIENT_HORIZ, PinNumSize, GR_TEXT_HJUSTIFY_CENTER, GR_TEXT_VJUSTIFY_BOTTOM, LineWidth ); } } else /* Its a vertical line. */ { - // Text is drawn from bottom to top (i.e. to negative value for Y axis) + // Text is drawn from bottom to top (i.e. to negative value for + // Y axis) if( PinText && DrawPinName ) { if( orient == PIN_DOWN ) { y = y1 + TextInside; - DrawGraphicText( panel, DC, wxPoint( x1, - y ), NameColor, - PinText, - TEXT_ORIENT_VERT, PinNameSize, + DrawGraphicText( panel, DC, wxPoint( x1, y ), NameColor, + PinText, TEXT_ORIENT_VERT, PinNameSize, GR_TEXT_HJUSTIFY_CENTER, GR_TEXT_VJUSTIFY_TOP, LineWidth ); @@ -409,11 +562,7 @@ void LibDrawPin::DrawPinTexts( WinEDA_DrawPanel* panel, dx = PinTextBarPos[ii++]; // Get the line pos GRMoveRel( 0, PinTxtLen - dx ); len = PinTextBarPos[ii++] - dx; // Get the line length - GRLineRel( &panel->m_ClipBox, - DC, - 0, - -len, - LineWidth, + GRLineRel( &panel->m_ClipBox, DC, 0, -len, LineWidth, NameColor ); } } @@ -421,10 +570,8 @@ void LibDrawPin::DrawPinTexts( WinEDA_DrawPanel* panel, { y = y1 - TextInside; - DrawGraphicText( panel, DC, wxPoint( x1, - y ), NameColor, - PinText, - TEXT_ORIENT_VERT, PinNameSize, + DrawGraphicText( panel, DC, wxPoint( x1, y ), NameColor, + PinText, TEXT_ORIENT_VERT, PinNameSize, GR_TEXT_HJUSTIFY_CENTER, GR_TEXT_VJUSTIFY_BOTTOM, LineWidth ); @@ -436,11 +583,7 @@ void LibDrawPin::DrawPinTexts( WinEDA_DrawPanel* panel, dx = PinTextBarPos[ii++]; // Get the line pos GRMoveRel( 0, -dx ); len = PinTextBarPos[ii++] - dx; // Get the line length - GRLineRel( &panel->m_ClipBox, - DC, - 0, - -len, - LineWidth, + GRLineRel( &panel->m_ClipBox, DC, 0, -len, LineWidth, NameColor ); } } @@ -451,8 +594,7 @@ void LibDrawPin::DrawPinTexts( WinEDA_DrawPanel* panel, DrawGraphicText( panel, DC, wxPoint( x1 - TXTMARGE, (y1 + pin_pos.y) / 2 ), NumColor, - StringPinNum, - TEXT_ORIENT_VERT, PinNumSize, + StringPinNum, TEXT_ORIENT_VERT, PinNumSize, GR_TEXT_HJUSTIFY_RIGHT, GR_TEXT_VJUSTIFY_CENTER, LineWidth ); } @@ -466,11 +608,9 @@ void LibDrawPin::DrawPinTexts( WinEDA_DrawPanel* panel, if( PinText && DrawPinName ) { x = (x1 + pin_pos.x) / 2; - DrawGraphicText( panel, DC, wxPoint( x, - y1 - TXTMARGE ), - NameColor, PinText, - TEXT_ORIENT_HORIZ, PinNameSize, - GR_TEXT_HJUSTIFY_CENTER, + DrawGraphicText( panel, DC, wxPoint( x, y1 - TXTMARGE ), + NameColor, PinText, TEXT_ORIENT_HORIZ, + PinNameSize, GR_TEXT_HJUSTIFY_CENTER, GR_TEXT_VJUSTIFY_BOTTOM, LineWidth ); for( ii = 0; ii < PinTextBarCount; ) @@ -480,23 +620,17 @@ void LibDrawPin::DrawPinTexts( WinEDA_DrawPanel* panel, dx = PinTextBarPos[ii++]; // Get the line pos GRMoveRel( dx, 0 ); len = PinTextBarPos[ii++] - dx; // Get the line length - GRLineRel( &panel->m_ClipBox, - DC, - len, - 0, - LineWidth, + GRLineRel( &panel->m_ClipBox, DC, len, 0, LineWidth, NameColor ); } } if( DrawPinNum ) { x = (x1 + pin_pos.x) / 2; - DrawGraphicText( panel, DC, wxPoint( x, - y1 + TXTMARGE ), - NumColor, StringPinNum, - TEXT_ORIENT_HORIZ, PinNumSize, - GR_TEXT_HJUSTIFY_CENTER, GR_TEXT_VJUSTIFY_TOP, - LineWidth ); + DrawGraphicText( panel, DC, wxPoint( x, y1 + TXTMARGE ), + NumColor, StringPinNum, TEXT_ORIENT_HORIZ, + PinNumSize, GR_TEXT_HJUSTIFY_CENTER, + GR_TEXT_VJUSTIFY_TOP, LineWidth ); } } else /* Its a vertical line. */ @@ -504,11 +638,9 @@ void LibDrawPin::DrawPinTexts( WinEDA_DrawPanel* panel, if( PinText && DrawPinName ) { y = (y1 + pin_pos.y) / 2; - DrawGraphicText( panel, DC, wxPoint( x1 - TXTMARGE, - y ), - NameColor, PinText, - TEXT_ORIENT_VERT, PinNameSize, - GR_TEXT_HJUSTIFY_RIGHT, + DrawGraphicText( panel, DC, wxPoint( x1 - TXTMARGE, y ), + NameColor, PinText, TEXT_ORIENT_VERT, + PinNameSize, GR_TEXT_HJUSTIFY_RIGHT, GR_TEXT_VJUSTIFY_CENTER, LineWidth ); for( ii = 0; ii < PinTextBarCount; ) @@ -518,11 +650,7 @@ void LibDrawPin::DrawPinTexts( WinEDA_DrawPanel* panel, dx = PinTextBarPos[ii++]; // Get the line pos GRMoveRel( 0, PinTxtLen - dx ); len = PinTextBarPos[ii++] - dx; // Get the line length - GRLineRel( &panel->m_ClipBox, - DC, - 0, - -len, - LineWidth, + GRLineRel( &panel->m_ClipBox, DC, 0, -len, LineWidth, NameColor ); } } @@ -532,9 +660,8 @@ void LibDrawPin::DrawPinTexts( WinEDA_DrawPanel* panel, DrawGraphicText( panel, DC, wxPoint( x1 + TXTMARGE, (y1 + pin_pos.y) / 2 ), - NumColor, StringPinNum, - TEXT_ORIENT_VERT, PinNumSize, - GR_TEXT_HJUSTIFY_LEFT, + NumColor, StringPinNum, TEXT_ORIENT_VERT, + PinNumSize, GR_TEXT_HJUSTIFY_LEFT, GR_TEXT_VJUSTIFY_CENTER, LineWidth ); } } @@ -559,7 +686,7 @@ void LibDrawPin::PlotPinTexts( wxPoint& pin_pos, int TextInside, bool DrawPinNum, bool DrawPinName, - int aWidth, bool aItalic ) + int aWidth, bool aItalic ) { int dx, len, start; int ii, x, y, x1, y1, cte; @@ -575,33 +702,42 @@ void LibDrawPin::PlotPinTexts( wxPoint& pin_pos, && g_PlotPSColorOpt; /* Get the num and name colors */ - NameColor = (EDA_Colors) (plot_color ? ReturnLayerColor( LAYER_PINNAM ) : -1); - NumColor = (EDA_Colors) (plot_color ? ReturnLayerColor( LAYER_PINNUM ) : -1); + NameColor = (EDA_Colors) ( ( plot_color ) ? + ReturnLayerColor( LAYER_PINNAM ) : -1 ); + NumColor = (EDA_Colors) ( ( plot_color ) ? + ReturnLayerColor( LAYER_PINNUM ) : -1 ); /* Create the pin num string */ ReturnPinStringNum( StringPinNum ); - x1 = pin_pos.x; y1 = pin_pos.y; + x1 = pin_pos.x; + y1 = pin_pos.y; switch( orient ) { case PIN_UP: - y1 -= m_PinLen; break; + y1 -= m_PinLen; + break; case PIN_DOWN: - y1 += m_PinLen; break; + y1 += m_PinLen; + break; case PIN_LEFT: - x1 -= m_PinLen; break; + x1 -= m_PinLen; + break; case PIN_RIGHT: - x1 += m_PinLen; break; + x1 += m_PinLen; + break; } const wxChar* textsrc = m_PinName.GetData(); float fPinTextPitch = (PinNameSize.x * 1.1) + aWidth; /* Do we need to invert the string? Is this string has only "~"? */ - PinTextBarCount = 0; PinTxtLen = 0; + PinTextBarCount = 0; + PinTxtLen = 0; ii = 0; + while( *textsrc ) { if( *textsrc == '~' ) @@ -633,14 +769,10 @@ void LibDrawPin::PlotPinTexts( wxPoint& pin_pos, if( orient == PIN_RIGHT ) { x = x1 + TextInside; - PlotGraphicText( g_PlotFormat, wxPoint( x, - y1 ), NameColor, - PinText, - TEXT_ORIENT_HORIZ, - PinNameSize, + PlotGraphicText( g_PlotFormat, wxPoint( x, y1 ), NameColor, + PinText, TEXT_ORIENT_HORIZ, PinNameSize, GR_TEXT_HJUSTIFY_LEFT, - GR_TEXT_VJUSTIFY_CENTER, - aWidth, aItalic ); + GR_TEXT_VJUSTIFY_CENTER, aWidth, aItalic ); for( ii = 0; ii < PinTextBarCount; ) { @@ -654,13 +786,10 @@ void LibDrawPin::PlotPinTexts( wxPoint& pin_pos, else // orient == PIN_LEFT { x = x1 - TextInside; - PlotGraphicText( g_PlotFormat, wxPoint( x, - y1 ), + PlotGraphicText( g_PlotFormat, wxPoint( x, y1 ), NameColor, PinText, TEXT_ORIENT_HORIZ, - PinNameSize, - GR_TEXT_HJUSTIFY_RIGHT, - GR_TEXT_VJUSTIFY_CENTER, - aWidth, aItalic ); + PinNameSize, GR_TEXT_HJUSTIFY_RIGHT, + GR_TEXT_VJUSTIFY_CENTER, aWidth, aItalic ); for( ii = 0; ii < PinTextBarCount; ) { @@ -676,13 +805,11 @@ void LibDrawPin::PlotPinTexts( wxPoint& pin_pos, if( DrawPinNum ) { PlotGraphicText( g_PlotFormat, - wxPoint( (x1 + pin_pos.x) / 2, - y1 - TXTMARGE ), - NumColor, StringPinNum, - TEXT_ORIENT_HORIZ, PinNumSize, - GR_TEXT_HJUSTIFY_CENTER, - GR_TEXT_VJUSTIFY_BOTTOM, - aWidth, aItalic ); + wxPoint( ( x1 + pin_pos.x ) / 2, + y1 - TXTMARGE ), + NumColor, StringPinNum, TEXT_ORIENT_HORIZ, + PinNumSize, GR_TEXT_HJUSTIFY_CENTER, + GR_TEXT_VJUSTIFY_BOTTOM, aWidth, aItalic ); } } else /* Its a vertical line. */ @@ -693,13 +820,10 @@ void LibDrawPin::PlotPinTexts( wxPoint& pin_pos, { y = y1 + TextInside; - PlotGraphicText( g_PlotFormat, wxPoint( x1, - y ), NameColor, - PinText, - TEXT_ORIENT_VERT, PinNameSize, + PlotGraphicText( g_PlotFormat, wxPoint( x1, y ), NameColor, + PinText, TEXT_ORIENT_VERT, PinNameSize, GR_TEXT_HJUSTIFY_CENTER, - GR_TEXT_VJUSTIFY_TOP, - aWidth, aItalic); + GR_TEXT_VJUSTIFY_TOP, aWidth, aItalic); for( ii = 0; ii < PinTextBarCount; ) { @@ -714,13 +838,10 @@ void LibDrawPin::PlotPinTexts( wxPoint& pin_pos, { y = y1 - TextInside; - PlotGraphicText( g_PlotFormat, wxPoint( x1, - y ), NameColor, - PinText, - TEXT_ORIENT_VERT, PinNameSize, + PlotGraphicText( g_PlotFormat, wxPoint( x1, y ), NameColor, + PinText, TEXT_ORIENT_VERT, PinNameSize, GR_TEXT_HJUSTIFY_CENTER, - GR_TEXT_VJUSTIFY_BOTTOM, - aWidth, aItalic); + GR_TEXT_VJUSTIFY_BOTTOM, aWidth, aItalic); for( ii = 0; ii < PinTextBarCount; ) { @@ -737,12 +858,10 @@ void LibDrawPin::PlotPinTexts( wxPoint& pin_pos, { PlotGraphicText( g_PlotFormat, wxPoint( x1 - TXTMARGE, - (y1 + pin_pos.y) / 2 ), - NumColor, StringPinNum, - TEXT_ORIENT_VERT, PinNumSize, - GR_TEXT_HJUSTIFY_RIGHT, - GR_TEXT_VJUSTIFY_CENTER, - aWidth, aItalic); + ( y1 + pin_pos.y ) / 2 ), + NumColor, StringPinNum, TEXT_ORIENT_VERT, + PinNumSize, GR_TEXT_HJUSTIFY_RIGHT, + GR_TEXT_VJUSTIFY_CENTER, aWidth, aItalic); } } } @@ -754,13 +873,10 @@ void LibDrawPin::PlotPinTexts( wxPoint& pin_pos, if( PinText && DrawPinName ) { x = (x1 + pin_pos.x) / 2; - PlotGraphicText( g_PlotFormat, wxPoint( x, - y1 - TXTMARGE ), - NameColor, PinText, - TEXT_ORIENT_HORIZ, PinNameSize, - GR_TEXT_HJUSTIFY_CENTER, - GR_TEXT_VJUSTIFY_BOTTOM, - aWidth, aItalic); + PlotGraphicText( g_PlotFormat, wxPoint( x, y1 - TXTMARGE ), + NameColor, PinText, TEXT_ORIENT_HORIZ, + PinNameSize, GR_TEXT_HJUSTIFY_CENTER, + GR_TEXT_VJUSTIFY_BOTTOM, aWidth, aItalic); for( ii = 0; ii < PinTextBarCount; ) { @@ -774,12 +890,11 @@ void LibDrawPin::PlotPinTexts( wxPoint& pin_pos, } if( DrawPinNum ) { - x = (x1 + pin_pos.x) / 2; + x = ( x1 + pin_pos.x ) / 2; PlotGraphicText( g_PlotFormat, wxPoint( x, y1 + TXTMARGE ), - NumColor, StringPinNum, - TEXT_ORIENT_HORIZ, PinNumSize, - GR_TEXT_HJUSTIFY_CENTER, GR_TEXT_VJUSTIFY_TOP, - aWidth, aItalic); + NumColor, StringPinNum, TEXT_ORIENT_HORIZ, + PinNumSize, GR_TEXT_HJUSTIFY_CENTER, + GR_TEXT_VJUSTIFY_TOP, aWidth, aItalic); } } else /* Its a vertical line. */ @@ -787,13 +902,10 @@ void LibDrawPin::PlotPinTexts( wxPoint& pin_pos, if( PinText && DrawPinName ) { y = (y1 + pin_pos.y) / 2; - PlotGraphicText( g_PlotFormat, wxPoint( x1 - TXTMARGE, - y ), - NameColor, PinText, - TEXT_ORIENT_VERT, PinNameSize, - GR_TEXT_HJUSTIFY_RIGHT, - GR_TEXT_VJUSTIFY_CENTER, - aWidth, aItalic); + PlotGraphicText( g_PlotFormat, wxPoint( x1 - TXTMARGE, y ), + NameColor, PinText, TEXT_ORIENT_VERT, + PinNameSize, GR_TEXT_HJUSTIFY_RIGHT, + GR_TEXT_VJUSTIFY_CENTER, aWidth, aItalic); for( ii = 0; ii < PinTextBarCount; ) { @@ -810,94 +922,80 @@ void LibDrawPin::PlotPinTexts( wxPoint& pin_pos, { PlotGraphicText( g_PlotFormat, wxPoint( x1 + TXTMARGE, - (y1 + pin_pos.y) / 2 ), - NumColor, StringPinNum, - TEXT_ORIENT_VERT, PinNumSize, - GR_TEXT_HJUSTIFY_LEFT, - GR_TEXT_VJUSTIFY_CENTER, - aWidth, aItalic); + ( y1 + pin_pos.y ) / 2 ), + NumColor, StringPinNum, TEXT_ORIENT_VERT, + PinNumSize, GR_TEXT_HJUSTIFY_LEFT, + GR_TEXT_VJUSTIFY_CENTER, aWidth, aItalic); } } } } -/***************************************************************/ -LibDrawPin::LibDrawPin() : LibEDA_BaseStruct( COMPONENT_PIN_DRAW_TYPE ) -/***************************************************************/ -{ - m_PinLen = 300; /* default Pin len */ - m_Orient = PIN_RIGHT; /* Pin oprient: Up, Down, Left, Right */ - m_PinShape = NONE; /* Bit a bit: Pin shape (voir enum prec) */ - m_PinType = PIN_UNSPECIFIED; /* electrical type of pin */ - m_Attributs = 0; /* bit 0 != 0: pin invisible */ - m_PinNum = 0; /*pin number ( i.e. 4 codes Ascii ) */ - m_PinNumSize = 50; - m_PinNameSize = 50; /* Default size for pin name and num */ - m_Width = 0; - -// m_PinNumWidth = m_PinNameWidth = 0; // Unused -} - - -/******************************************/ -wxPoint LibDrawPin::ReturnPinEndPoint() -/******************************************/ - /* return the pin end position, for a component in normal orient */ +wxPoint LibDrawPin::ReturnPinEndPoint() { wxPoint pos = m_Pos; switch( m_Orient ) { case PIN_UP: - pos.y += m_PinLen; break; + pos.y += m_PinLen; + break; case PIN_DOWN: - pos.y -= m_PinLen; break; + pos.y -= m_PinLen; + break; case PIN_LEFT: - pos.x -= m_PinLen; break; + pos.x -= m_PinLen; + break; case PIN_RIGHT: - pos.x += m_PinLen; break; + pos.x += m_PinLen; + break; } return pos; } -/********************************************************/ -int LibDrawPin::ReturnPinDrawOrient( const int TransMat[2][2] ) -/********************************************************/ - -/** Function ReturnPinDrawOrient +/** + * Function ReturnPinDrawOrient * Return the pin real orientation (PIN_UP, PIN_DOWN, PIN_RIGHT, PIN_LEFT), * according to its orientation and the matrix transform (rot, mirror) TransMat * @param TransMat = transform matrix */ +int LibDrawPin::ReturnPinDrawOrient( const int TransMat[2][2] ) { int orient; - wxPoint end; // position of a end pin starting at 0,0 according to its orientation, lenght = 1 + wxPoint end; /* position of a end pin starting at 0,0 according to + * its orientation, lenght = 1 */ switch( m_Orient ) { case PIN_UP: - end.y = 1; break; + end.y = 1; + break; case PIN_DOWN: - end.y = -1; break; + end.y = -1; + break; case PIN_LEFT: - end.x = -1; break; + end.x = -1; + break; case PIN_RIGHT: - end.x = 1; break; + end.x = 1; + break; } - end = TransformCoordinate( TransMat, end ); // = pos of end point, accordint to the component orientation + // = pos of end point, accordint to the component orientation + end = TransformCoordinate( TransMat, end ); orient = PIN_UP; + if( end.x == 0 ) { if( end.y > 0 ) @@ -914,14 +1012,13 @@ int LibDrawPin::ReturnPinDrawOrient( const int TransMat[2][2] ) } -/***********************************************************/ -void LibDrawPin::ReturnPinStringNum( wxString& buffer ) const -/***********************************************************/ -/* fill the buffer with pin num as a wxString +/** + * fill the buffer with pin num as a wxString * Pin num is coded as a long * Used to print/draw the pin num */ +void LibDrawPin::ReturnPinStringNum( wxString& buffer ) const { char ascii_buf[5]; @@ -932,14 +1029,12 @@ void LibDrawPin::ReturnPinStringNum( wxString& buffer ) const } -/****************************************************/ -void LibDrawPin::SetPinNumFromString( wxString& buffer ) -/****************************************************/ - -/* fill the buffer with pin num as a wxString +/* + * fill the buffer with pin num as a wxString * Pin num is coded as a long * Used to print/draw the pin num */ +void LibDrawPin::SetPinNumFromString( wxString& buffer ) { char ascii_buf[4]; unsigned ii, len = buffer.Len(); @@ -956,9 +1051,7 @@ void LibDrawPin::SetPinNumFromString( wxString& buffer ) } -/*************************************/ LibDrawPin* LibDrawPin::GenCopy() -/*************************************/ { LibDrawPin* newpin = new LibDrawPin(); @@ -980,3 +1073,81 @@ LibDrawPin* LibDrawPin::GenCopy() return newpin; } + + +/*******************************************************/ +/* Affiche en bas d'ecran les caracteristiques de la pin + */ +/*******************************************************/ +void LibDrawPin::DisplayInfo( WinEDA_DrawFrame* frame ) +{ + wxString Text; + int ii; + + LibEDA_BaseStruct::DisplayInfo( frame ); + + /* Affichage du nom */ + frame->MsgPanel->Affiche_1_Parametre( 30, _( "PinName" ), m_PinName, + DARKCYAN ); + + /* Affichage du numero */ + if( m_PinNum == 0 ) + Text = wxT( "?" ); + else + ReturnPinStringNum( Text ); + + frame->MsgPanel->Affiche_1_Parametre( 38, _( "PinNum" ), Text, DARKCYAN ); + + /* Affichage du type */ + ii = m_PinType; + frame->MsgPanel->Affiche_1_Parametre( 44, _( "PinType" ), + MsgPinElectricType[ii], RED ); + + /* Affichage de la visiblite */ + ii = m_Attributs; + if( ii & 1 ) + Text = _( "no" ); + else + Text = _( "yes" ); + frame->MsgPanel->Affiche_1_Parametre( 50, _( "Display" ), Text, DARKGREEN ); + + /* Display pin length */ + Text = ReturnStringFromValue( g_UnitMetric, m_PinLen, + EESCHEMA_INTERNAL_UNIT, true ); + frame->MsgPanel->Affiche_1_Parametre( 56, _( "Length" ), Text, MAGENTA ); + + /* Affichage de l'orientation */ + switch( m_Orient ) + { + case PIN_UP: + Text = _( "Up" ); + break; + + case PIN_DOWN: + Text = _( "Down" ); + break; + + case PIN_LEFT: + Text = _( "Left" ); + break; + + case PIN_RIGHT: + Text = _( "Right" ); + break; + + default: + Text = wxT( "??" ); + break; + } + + frame->MsgPanel->Affiche_1_Parametre( 62, _( "Orient" ), Text, MAGENTA ); +} + + +EDA_Rect LibDrawPin::GetBoundingBox() +{ + wxPoint pt = m_Pos; + pt.y *= -1; + + return EDA_Rect( pt, wxSize( 1, 1 ) ); +} diff --git a/eeschema/class_sch_cmp_field.cpp b/eeschema/class_sch_cmp_field.cpp index a6044db1b9..6133481bda 100644 --- a/eeschema/class_sch_cmp_field.cpp +++ b/eeschema/class_sch_cmp_field.cpp @@ -11,9 +11,12 @@ */ #include "fctsys.h" -#include "gr_basic.h" - #include "common.h" +#include "class_drawpanel.h" +#include "base_struct.h" +#include "gr_basic.h" +#include "drawtxt.h" + #include "program.h" #include "libcmp.h" #include "general.h" @@ -22,11 +25,10 @@ #include "protos.h" -/***************************************************************************/ -SCH_CMP_FIELD::SCH_CMP_FIELD( const wxPoint& aPos, int aFieldId, SCH_COMPONENT* aParent, wxString aName ) : +SCH_CMP_FIELD::SCH_CMP_FIELD( const wxPoint& aPos, int aFieldId, + SCH_COMPONENT* aParent, wxString aName ) : SCH_ITEM( aParent, DRAW_PART_TEXT_STRUCT_TYPE ), EDA_TextStruct() -/***************************************************************************/ { m_Pos = aPos; m_FieldId = aFieldId; @@ -38,13 +40,139 @@ SCH_CMP_FIELD::SCH_CMP_FIELD( const wxPoint& aPos, int aFieldId, SCH_COMPONENT* } -/************************************/ SCH_CMP_FIELD::~SCH_CMP_FIELD() -/************************************/ { } -/** Function ImportValues + +/** + * Routine de trace des textes type Field du composant. + * entree: + * DrawMode: mode de trace + */ +void SCH_CMP_FIELD::Draw( WinEDA_DrawPanel* panel, wxDC* DC, + const wxPoint& offset, int DrawMode, int Color ) +{ + int orient; + EDA_Colors color; + wxPoint pos; /* Position des textes */ + SCH_COMPONENT* DrawLibItem = (SCH_COMPONENT*) m_Parent; + GRTextHorizJustifyType hjustify; + GRTextVertJustifyType vjustify; + int LineWidth = MAX( m_Width, g_DrawMinimunLineWidth ); + + if( ( m_Attributs & TEXT_NO_VISIBLE ) || IsVoid() ) + return; + + GRSetDrawMode( DC, DrawMode ); + + /* Calcul de la position des textes, selon orientation du composant */ + orient = m_Orient; + hjustify = m_HJustify; vjustify = m_VJustify; + pos = m_Pos - DrawLibItem->m_Pos; + + pos = DrawLibItem->GetScreenCoord( pos ); + pos += DrawLibItem->m_Pos; + + /* Y a t-il rotation (pour l'orientation, la justification)*/ + if( DrawLibItem->m_Transform[0][1] ) // Rotation du composant de 90deg + { + if( orient == TEXT_ORIENT_HORIZ ) + orient = TEXT_ORIENT_VERT; + else + orient = TEXT_ORIENT_HORIZ; + /* Y a t-il rotation, miroir (pour les justifications)*/ + GRTextHorizJustifyType tmp = hjustify; + hjustify = (GRTextHorizJustifyType) vjustify; + vjustify = (GRTextVertJustifyType) tmp; + if( DrawLibItem->m_Transform[1][0] < 0 ) + switch ( vjustify ) + { + case GR_TEXT_VJUSTIFY_BOTTOM: + vjustify = GR_TEXT_VJUSTIFY_TOP; + break; + case GR_TEXT_VJUSTIFY_TOP: + vjustify = GR_TEXT_VJUSTIFY_BOTTOM; + break; + default: + break; + } + if( DrawLibItem->m_Transform[1][0] > 0 ) + switch ( hjustify ) + { + case GR_TEXT_HJUSTIFY_LEFT: + hjustify = GR_TEXT_HJUSTIFY_RIGHT; + break; + case GR_TEXT_HJUSTIFY_RIGHT: + hjustify = GR_TEXT_HJUSTIFY_LEFT; + break; + default: + break; + } + } + else + { + /* Texte horizontal: Y a t-il miroir (pour les justifications)*/ + if( DrawLibItem->m_Transform[0][0] < 0 ) + switch ( hjustify ) + { + case GR_TEXT_HJUSTIFY_LEFT: + hjustify = GR_TEXT_HJUSTIFY_RIGHT; + break; + case GR_TEXT_HJUSTIFY_RIGHT: + hjustify = GR_TEXT_HJUSTIFY_LEFT; + break; + default: + break; + } + if( DrawLibItem->m_Transform[1][1] > 0 ) + switch ( vjustify ) + { + case GR_TEXT_VJUSTIFY_BOTTOM: + vjustify = GR_TEXT_VJUSTIFY_TOP; + break; + case GR_TEXT_VJUSTIFY_TOP: + vjustify = GR_TEXT_VJUSTIFY_BOTTOM; + break; + default: + break; + } + } + + if( m_FieldId == REFERENCE ) + color = ReturnLayerColor( LAYER_REFERENCEPART ); + else if( m_FieldId == VALUE ) + color = ReturnLayerColor( LAYER_VALUEPART ); + else + color = ReturnLayerColor( LAYER_FIELDS ); + + if( !m_AddExtraText || (m_FieldId != REFERENCE) ) + { + DrawGraphicText( panel, DC, pos, color, m_Text, + orient ? TEXT_ORIENT_VERT : TEXT_ORIENT_HORIZ, + m_Size, hjustify, vjustify, LineWidth, m_Italic ); + } + else + { + /* For more than one part per package, we must add the part selection + * A, B, ... or 1, 2, .. to the reference. */ + wxString fulltext = m_Text; +#if defined(KICAD_GOST) + fulltext.Append( '.'); + fulltext.Append( '1' - 1 + DrawLibItem->m_Multi ); +#else + fulltext.Append( 'A' - 1 + DrawLibItem->m_Multi ); +#endif + + DrawGraphicText( panel, DC, pos, color, fulltext, + orient ? TEXT_ORIENT_VERT : TEXT_ORIENT_HORIZ, + m_Size, hjustify, vjustify, LineWidth, m_Italic ); + } +} + + +/** + * Function ImportValues * copy parameters from a source. * Pointers and specific values (position, texts) are not copied * used to init a field from the model read from a lib entry @@ -62,13 +190,11 @@ void SCH_CMP_FIELD::ImportValues( const LibDrawField& aSource ) m_Mirror = aSource.m_Mirror; } -/**************************************************************************/ -void SCH_CMP_FIELD::SwapData( SCH_CMP_FIELD* copyitem ) -/**************************************************************************/ - -/* Used if undo / redo command: +/** + * Used if undo / redo command: * swap data between this and copyitem */ +void SCH_CMP_FIELD::SwapData( SCH_CMP_FIELD* copyitem ) { EXCHG( m_Text, copyitem->m_Text ); EXCHG( m_Layer, copyitem->m_Layer ); @@ -84,13 +210,11 @@ void SCH_CMP_FIELD::SwapData( SCH_CMP_FIELD* copyitem ) } -/*********************************/ -bool SCH_CMP_FIELD::IsVoid() -/*********************************/ - -/* return True if the field is void, i.e.: +/** + * return True if the field is void, i.e.: * contains "~" or "" */ +bool SCH_CMP_FIELD::IsVoid() { if( m_Text.IsEmpty() || m_Text == wxT( "~" ) ) return true; @@ -98,15 +222,13 @@ bool SCH_CMP_FIELD::IsVoid() } -/********************************************/ -EDA_Rect SCH_CMP_FIELD::GetBoundaryBox() const -/********************************************/ - -/** Function GetBoundaryBox() - * @return an EDA_Rect contains the real (user coordinates) boundary box for a text field, +/** + * Function GetBoundaryBox() + * @return an EDA_Rect contains the real (user coordinates) boundary box for + * a text field, * according to the component position, rotation, mirror ... - * */ +EDA_Rect SCH_CMP_FIELD::GetBoundaryBox() const { EDA_Rect BoundaryBox; int hjustify, vjustify; @@ -125,7 +247,8 @@ EDA_Rect SCH_CMP_FIELD::GetBoundaryBox() const if( m_FieldId == REFERENCE ) // Real Text can be U1 or U1A { EDA_LibComponentStruct* Entry = - FindLibPart( DrawLibItem->m_ChipName.GetData(), wxEmptyString, FIND_ROOT ); + FindLibPart( DrawLibItem->m_ChipName.GetData(), wxEmptyString, + FIND_ROOT ); if( Entry && (Entry->m_UnitCount > 1) ) textlen++; // because U1 is show as U1A or U1B ... } @@ -143,7 +266,8 @@ EDA_Rect SCH_CMP_FIELD::GetBoundaryBox() const y2 = pos.y + (DrawLibItem->m_Transform[1][0] * x1) + (DrawLibItem->m_Transform[1][1] * y1); - /* If the component orientation is +/- 90 deg, the text orientation must be changed */ + /* If the component orientation is +/- 90 deg, the text orientation must + * be changed */ if( DrawLibItem->m_Transform[0][1] ) { if( orient == TEXT_ORIENT_HORIZ ) @@ -207,9 +331,7 @@ EDA_Rect SCH_CMP_FIELD::GetBoundaryBox() const } -/*********************************************/ bool SCH_CMP_FIELD::Save( FILE* aFile ) const -/*********************************************/ { char hjustify = 'C'; if( m_HJustify == GR_TEXT_HJUSTIFY_LEFT ) @@ -224,15 +346,15 @@ bool SCH_CMP_FIELD::Save( FILE* aFile ) const vjustify = 'T'; if( fprintf( aFile, "F %d \"%s\" %c %-3d %-3d %-3d %4.4X %c %c%c%c", - m_FieldId, - CONV_TO_UTF8( m_Text ), - m_Orient == TEXT_ORIENT_HORIZ ? 'H' : 'V', - m_Pos.x, m_Pos.y, - m_Size.x, - m_Attributs, - hjustify, vjustify, - m_Italic ? 'I' : 'N', - m_Width > 1 ? 'B' : 'N' ) == EOF ) + m_FieldId, + CONV_TO_UTF8( m_Text ), + m_Orient == TEXT_ORIENT_HORIZ ? 'H' : 'V', + m_Pos.x, m_Pos.y, + m_Size.x, + m_Attributs, + hjustify, vjustify, + m_Italic ? 'I' : 'N', + m_Width > 1 ? 'B' : 'N' ) == EOF ) { return false; } @@ -253,3 +375,42 @@ bool SCH_CMP_FIELD::Save( FILE* aFile ) const return true; } + + +void SCH_CMP_FIELD::Place( WinEDA_SchematicFrame* frame, wxDC* DC ) +{ + int fieldNdx; + EDA_LibComponentStruct* Entry; + + frame->DrawPanel->ManageCurseur = NULL; + frame->DrawPanel->ForceCloseManageCurseur = NULL; + + SCH_COMPONENT* component = (SCH_COMPONENT*) GetParent(); + + // save old cmp in undo list + if( g_ItemToUndoCopy && ( g_ItemToUndoCopy->Type() == component->Type()) ) + { + component->SwapData( (SCH_COMPONENT*) g_ItemToUndoCopy ); + frame->SaveCopyInUndoList( component, IS_CHANGED ); + component->SwapData( (SCH_COMPONENT*) g_ItemToUndoCopy ); + } + + fieldNdx = m_FieldId; + m_AddExtraText = 0; + if( fieldNdx == REFERENCE ) + { + Entry = FindLibPart( component->m_ChipName.GetData(), wxEmptyString, + FIND_ROOT ); + if( Entry != NULL ) + { + if( Entry->m_UnitCount > 1 ) + m_AddExtraText = 1; + } + } + + Draw( frame->DrawPanel, DC, wxPoint(0,0), GR_DEFAULT_DRAWMODE ); + m_Flags = 0; + frame->GetScreen()->SetCurItem( NULL ); + frame->GetScreen()->SetModify(); + frame->SetCurrentField( NULL ); +} diff --git a/eeschema/class_schematic_items.cpp b/eeschema/class_schematic_items.cpp index c4e1dc00da..8c0b2e7a75 100644 --- a/eeschema/class_schematic_items.cpp +++ b/eeschema/class_schematic_items.cpp @@ -4,6 +4,7 @@ #include "fctsys.h" #include "gr_basic.h" +#include "class_drawpanel.h" #include "common.h" #include "program.h" @@ -17,11 +18,18 @@ /* class DrawBusEntryStruct */ /***************************/ +const wxChar* NameMarqueurType[] = +{ + wxT( "" ), + wxT( "ERC" ), + wxT( "PCB" ), + wxT( "SIMUL" ), + wxT( "?????" ) +}; + -/*******************************************************************/ DrawBusEntryStruct::DrawBusEntryStruct( const wxPoint& pos, int shape, int id ) : SCH_ITEM( NULL, DRAW_BUSENTRY_STRUCT_TYPE ) -/*******************************************************************/ { m_Pos = pos; m_Size.x = 100; @@ -40,19 +48,13 @@ DrawBusEntryStruct::DrawBusEntryStruct( const wxPoint& pos, int shape, int id ) } -/****************************************/ wxPoint DrawBusEntryStruct::m_End() const -/****************************************/ - -// retourne la coord de fin du raccord { return wxPoint( m_Pos.x + m_Size.x, m_Pos.y + m_Size.y ); } -/***************************************************/ DrawBusEntryStruct* DrawBusEntryStruct::GenCopy() -/***************************************************/ { DrawBusEntryStruct* newitem = new DrawBusEntryStruct( m_Pos, 0, 0 ); @@ -88,8 +90,7 @@ bool DrawBusEntryStruct::Save( FILE* aFile ) const success = false; } if( fprintf( aFile, "\t%-4d %-4d %-4d %-4d\n", - m_Pos.x, m_Pos.y, - m_End().x, m_End().y ) == EOF ) + m_Pos.x, m_Pos.y, m_End().x, m_End().y ) == EOF ) { success = false; } @@ -98,9 +99,7 @@ bool DrawBusEntryStruct::Save( FILE* aFile ) const } -/*********************************************/ EDA_Rect DrawBusEntryStruct::GetBoundingBox() -/*********************************************/ { int dx = m_Pos.x - m_End().x; int dy = m_Pos.y - m_End().y; @@ -108,19 +107,38 @@ EDA_Rect DrawBusEntryStruct::GetBoundingBox() box.Normalize(); int width = MAX( m_Width, g_DrawMinimunLineWidth ); - box.Inflate(width/2, width/2); + box.Inflate( width / 2, width / 2 ); return box; } + +void DrawBusEntryStruct::Draw( WinEDA_DrawPanel* panel, wxDC* DC, + const wxPoint& offset, int DrawMode, int Color ) +{ + int color; + int width = MAX( m_Width, g_DrawMinimunLineWidth ); + + if( Color >= 0 ) + color = Color; + else + color = ReturnLayerColor( m_Layer ); + GRSetDrawMode( DC, DrawMode ); + + if( m_Layer == LAYER_BUS ) + width *= 3; + + GRLine( &panel->m_ClipBox, DC, m_Pos.x + offset.x, m_Pos.y + offset.y, + m_End().x + offset.x, m_End().y + offset.y, width, color ); +} + + /****************************/ /* class DrawJunctionStruct */ /***************************/ -/************************************************************/ DrawJunctionStruct::DrawJunctionStruct( const wxPoint& pos ) : SCH_ITEM( NULL, DRAW_JUNCTION_STRUCT_TYPE ) -/************************************************************/ { m_Pos = pos; m_Layer = LAYER_JUNCTION; @@ -169,19 +187,36 @@ EDA_Rect DrawJunctionStruct::GetBoundingBox() return ret; }; -/*********************************************************/ -bool DrawJunctionStruct::HitTest( const wxPoint& aPosRef ) -/*********************************************************/ + /** Function HitTest * @return true if the point aPosRef is within item area * @param aPosRef = a wxPoint to test */ +bool DrawJunctionStruct::HitTest( const wxPoint& aPosRef ) { wxPoint dist = aPosRef - m_Pos; - if( sqrt( ((double) dist.x * dist.x) + ((double) dist.y * dist.y) ) < DRAWJUNCTION_SIZE ) - return true; - return false; + return sqrt( ( (double) ( dist.x * dist.x ) ) + + ( (double) ( dist.y * dist.y ) ) ) < DRAWJUNCTION_SIZE; +} + + +/***************************************************************************** +* Routine to redraw connection struct. * +*****************************************************************************/ +void DrawJunctionStruct::Draw( WinEDA_DrawPanel* panel, wxDC* DC, + const wxPoint& offset, int DrawMode, int Color ) +{ + int color; + + if( Color >= 0 ) + color = Color; + else + color = ReturnLayerColor( m_Layer ); + GRSetDrawMode( DC, DrawMode ); + + GRFilledCircle( &panel->m_ClipBox, DC, m_Pos.x + offset.x, + m_Pos.y + offset.y, DRAWJUNCTION_SIZE, 0, color, color ); } @@ -192,8 +227,7 @@ void DrawJunctionStruct::Show( int nestLevel, std::ostream& os ) wxString s = GetClass(); NestedSpace( nestLevel, os ) << '<' << s.Lower().mb_str() - << m_Pos - << "/>\n"; + << m_Pos << "/>\n"; } #endif @@ -219,25 +253,24 @@ DrawNoConnectStruct* DrawNoConnectStruct::GenCopy() return newitem; } -/*********************************************/ + EDA_Rect DrawNoConnectStruct::GetBoundingBox() -/*********************************************/ { const int DELTA = DRAWNOCONNECT_SIZE / 2; - EDA_Rect box( wxPoint( m_Pos.x - DELTA, m_Pos.y - DELTA ), wxSize( 2 * DELTA, 2 * DELTA ) ); + EDA_Rect box( wxPoint( m_Pos.x - DELTA, m_Pos.y - DELTA ), + wxSize( 2 * DELTA, 2 * DELTA ) ); box.Normalize(); return box; } -/*********************************************************/ -bool DrawNoConnectStruct::HitTest( const wxPoint& aPosRef ) -/*********************************************************/ -/** Function HitTest +/** + * Function HitTest * @return true if the point aPosRef is within item area * @param aPosRef = a wxPoint to test */ +bool DrawNoConnectStruct::HitTest( const wxPoint& aPosRef ) { int width = g_DrawMinimunLineWidth; int delta = ( DRAWNOCONNECT_SIZE + width) / 2; @@ -268,10 +301,65 @@ bool DrawNoConnectStruct::Save( FILE* aFile ) const } +void DrawNoConnectStruct::Draw( WinEDA_DrawPanel* panel, wxDC* DC, + const wxPoint& offset, int DrawMode, int Color ) +{ + const int DELTA = (DRAWNOCONNECT_SIZE / 2); + int pX, pY, color; + int width = g_DrawMinimunLineWidth; + + pX = m_Pos.x + offset.x; pY = m_Pos.y + offset.y; + + if( Color >= 0 ) + color = Color; + else + color = ReturnLayerColor( LAYER_NOCONNECT ); + GRSetDrawMode( DC, DrawMode ); + + GRLine( &panel->m_ClipBox, DC, pX - DELTA, pY - DELTA, pX + DELTA, + pY + DELTA, width, color ); + GRLine( &panel->m_ClipBox, DC, pX + DELTA, pY - DELTA, pX - DELTA, + pY + DELTA, width, color ); +} + + /**************************/ /* class DrawMarkerStruct */ /**************************/ +char marq_bitmap[] = +{ + 12, 12, 0, 0, /* Dimensions x et y, offsets x et y du bitmap de marqueurs*/ + YELLOW, /* Couleur */ + 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, /* bitmap: >= 1 : color, */ + 1, 1, 1, 0, 1, 0, 1, 1, 0, 0, 0, 0, /* 0 = notrace */ + 1, 1, 1, 1, 0, 0, 0, 1, 0, 0, 0, 0, + 1, 0, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, + 1, 1, 0, 1, 1, 1, 0, 0, 0, 0, 0, 0, + 1, 1, 0, 0, 1, 1, 1, 0, 0, 0, 0, 0, + 1, 1, 1, 0, 0, 1, 1, 1, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 1, 1, 1, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0 +}; + +char marqERC_bitmap[] = +{ + 8, 8, 0, 0, /* Dimensions x et y , offsets x et y du bitmap de marqueurs*/ + -1, /* Color: -1 = couleur non pr�cis�e */ + 1, 1, 1, 1, 1, 0, 0, 0, + 1, 1, 1, 0, 1, 0, 0, 0, + 1, 1, 1, 1, 0, 0, 0, 0, + 1, 0, 1, 1, 1, 0, 0, 0, + 1, 1, 0, 1, 1, 1, 0, 0, + 0, 0, 0, 0, 1, 1, 1, 0, + 0, 0, 0, 0, 0, 1, 1, 1, + 0, 0, 0, 0, 0, 0, 1, 0, +}; + + DrawMarkerStruct::DrawMarkerStruct( const wxPoint& pos, const wxString& text ) : SCH_ITEM( NULL, DRAW_MARKER_STRUCT_TYPE ) { @@ -332,9 +420,8 @@ bool DrawMarkerStruct::Save( FILE* aFile ) const bool success = true; if( fprintf( aFile, "Kmarq %c %-4d %-4d \"%s\" F=%X\n", - int( m_Type ) + 'A', - m_Pos.x, m_Pos.y, - CONV_TO_UTF8( m_Comment ), m_MarkFlags ) == EOF ) + int( m_Type ) + 'A', m_Pos.x, m_Pos.y, + CONV_TO_UTF8( m_Comment ), m_MarkFlags ) == EOF ) { success = false; } @@ -343,6 +430,28 @@ bool DrawMarkerStruct::Save( FILE* aFile ) const } +void DrawMarkerStruct::Draw( WinEDA_DrawPanel* panel, wxDC* DC, + const wxPoint& offset, int DrawMode, int Color ) +{ +#define WAR 1 // utilis� aussi dans erc.cpp + + if( m_Type == MARQ_ERC ) + { + int color = Color; + if( Color <= 0 ) + { + color = (m_MarkFlags == WAR ) ? + g_LayerDescr.LayerColor[LAYER_ERC_WARN] : + g_LayerDescr.LayerColor[LAYER_ERC_ERR]; + } + + Draw_Marqueur( panel, DC, m_Pos + offset, marqERC_bitmap, DrawMode, + color ); + } + else + Draw_Marqueur( panel, DC, m_Pos + offset, marq_bitmap, DrawMode, Color ); +} + /***************************/ /* Class EDA_DrawLineStruct */ @@ -375,9 +484,7 @@ EDA_DrawLineStruct::EDA_DrawLineStruct( const wxPoint& pos, int layer ) : } -/***************************************************/ EDA_DrawLineStruct* EDA_DrawLineStruct::GenCopy() -/***************************************************/ { EDA_DrawLineStruct* newitem = new EDA_DrawLineStruct( m_Start, m_Layer ); @@ -387,12 +494,7 @@ EDA_DrawLineStruct* EDA_DrawLineStruct::GenCopy() } -/************************************************************/ bool EDA_DrawLineStruct::IsOneEndPointAt( const wxPoint& pos ) -/************************************************************/ - -/* Return TRUE if the start or the end point is in position pos - */ { if( (pos.x == m_Start.x) && (pos.y == m_Start.y) ) return TRUE; @@ -423,7 +525,6 @@ void EDA_DrawLineStruct::Show( int nestLevel, std::ostream& os ) "\n"; } - #endif @@ -438,7 +539,8 @@ EDA_Rect EDA_DrawLineStruct::GetBoundingBox() int ymax = MAX( m_Start.y, m_End.y ) + width; // return a rectangle which is [pos,dim) in nature. therefore the +1 - EDA_Rect ret( wxPoint( xmin, ymin ), wxSize( xmax - xmin + 1, ymax - ymin + 1 ) ); + EDA_Rect ret( wxPoint( xmin, ymin ), + wxSize( xmax - xmin + 1, ymax - ymin + 1 ) ); return ret; } @@ -467,9 +569,8 @@ bool EDA_DrawLineStruct::Save( FILE* aFile ) const { success = false; } - if (fprintf( aFile, "\t%-4d %-4d %-4d %-4d\n", - m_Start.x,m_Start.y, - m_End.x,m_End.y) == EOF) + if ( fprintf( aFile, "\t%-4d %-4d %-4d %-4d\n", m_Start.x,m_Start.y, + m_End.x,m_End.y ) == EOF ) { success = false; } @@ -478,14 +579,46 @@ bool EDA_DrawLineStruct::Save( FILE* aFile ) const } +void EDA_DrawLineStruct::Draw( WinEDA_DrawPanel* panel, wxDC* DC, + const wxPoint& offset, int DrawMode, int Color ) +{ + int color; + int width = MAX( m_Width, g_DrawMinimunLineWidth ); + + if( Color >= 0 ) + color = Color; + else + color = ReturnLayerColor( m_Layer ); + + GRSetDrawMode( DC, DrawMode ); + + // FIXME: Not compatable with new zoom. + if( (m_Layer == LAYER_BUS) && panel->GetScreen()->Scale( width ) <= 1 ) + width *= 3; + + if( m_Layer == LAYER_NOTES ) + GRDashedLine( &panel->m_ClipBox, DC, m_Start.x + offset.x, + m_Start.y + offset.y, m_End.x + offset.x, + m_End.y + offset.y, width, color ); + else + GRLine( &panel->m_ClipBox, DC, m_Start.x + offset.x, + m_Start.y + offset.y, m_End.x + offset.x, m_End.y + offset.y, + width, color ); + + if( m_StartIsDangling ) + DrawDanglingSymbol( panel, DC, m_Start + offset, color ); + + if( m_EndIsDangling ) + DrawDanglingSymbol( panel, DC, m_End + offset, color ); +} + + /****************************/ /* Class DrawPolylineStruct */ /****************************/ -/***********************************************************/ DrawPolylineStruct::DrawPolylineStruct( int layer ) : SCH_ITEM( NULL, DRAW_POLYLINE_STRUCT_TYPE ) -/***********************************************************/ { m_Width = GR_NORM_WIDTH; @@ -508,19 +641,14 @@ DrawPolylineStruct::DrawPolylineStruct( int layer ) : } -/********************************************/ DrawPolylineStruct::~DrawPolylineStruct() -/*********************************************/ { } -/*****************************************************/ DrawPolylineStruct* DrawPolylineStruct::GenCopy() -/*****************************************************/ { - DrawPolylineStruct* newitem = - new DrawPolylineStruct( m_Layer ); + DrawPolylineStruct* newitem = new DrawPolylineStruct( m_Layer ); newitem->m_PolyPoints = m_PolyPoints; // std::vector copy return newitem; } @@ -546,15 +674,14 @@ bool DrawPolylineStruct::Save( FILE* aFile ) const if( m_Width != GR_NORM_WIDTH ) width = "Bus"; if( fprintf( aFile, "Poly %s %s %d\n", - width, layer, GetCornerCount() ) == EOF ) + width, layer, GetCornerCount() ) == EOF ) { - success = false; - return success; + return false; } for( unsigned ii = 0; ii < GetCornerCount(); ii++ ) { if( fprintf( aFile, "\t%-4d %-4d\n", - m_PolyPoints[ii ].x, m_PolyPoints[ii].y ) == EOF ) + m_PolyPoints[ii ].x, m_PolyPoints[ii].y ) == EOF ) { success = false; break; @@ -563,3 +690,38 @@ bool DrawPolylineStruct::Save( FILE* aFile ) const return success; } + + +void DrawPolylineStruct::Draw( WinEDA_DrawPanel* panel, wxDC* DC, + const wxPoint& offset, int DrawMode, int Color ) +{ + int color; + int width = MAX( m_Width, g_DrawMinimunLineWidth ); + + if( Color >= 0 ) + color = Color; + else + color = ReturnLayerColor( m_Layer ); + + GRSetDrawMode( DC, DrawMode ); + + if( m_Layer == LAYER_BUS ) + { + width *= 3; + } + + GRMoveTo( m_PolyPoints[0].x, m_PolyPoints[0].y ); + + if( m_Layer == LAYER_NOTES ) + { + for( unsigned i = 1; i < GetCornerCount(); i++ ) + GRDashedLineTo( &panel->m_ClipBox, DC, m_PolyPoints[i].x + offset.x, + m_PolyPoints[i].y + offset.y, width, color ); + } + else + { + for( unsigned i = 1; i < GetCornerCount(); i++ ) + GRLineTo( &panel->m_ClipBox, DC, m_PolyPoints[i].x + offset.x, + m_PolyPoints[i].y + offset.y, width, color ); + } +} diff --git a/eeschema/class_schematic_items.h b/eeschema/class_schematic_items.h index bebe5747db..26d9a5bde4 100644 --- a/eeschema/class_schematic_items.h +++ b/eeschema/class_schematic_items.h @@ -5,10 +5,6 @@ #ifndef CLASS_SCHEMATIC_ITEMS_H #define CLASS_SCHEMATIC_ITEMS_H -#ifndef eda_global -#define eda_global extern -#endif - #define DRAWJUNCTION_SIZE 16 /* Rayon du symbole connexion */ #define DRAWMARKER_SIZE 16 /* Rayon du symbole marqueur */ #define DRAWNOCONNECT_SIZE 48 /* Rayon du symbole No Connexion */ @@ -28,18 +24,7 @@ enum TypeMarker { /* Type des Marqueurs */ /* Messages correspondants aux types des marqueurs */ -#ifdef MAIN -const wxChar* NameMarqueurType[] = -{ - wxT( "" ), - wxT( "ERC" ), - wxT( "PCB" ), - wxT( "SIMUL" ), - wxT( "?????" ) -}; -#else extern const wxChar* NameMarqueurType[]; -#endif /** @@ -55,7 +40,7 @@ public: wxPoint m_End; // Line end point bool m_StartIsDangling; - bool m_EndIsDangling; // TRUE si Start ou End not connected (wires, tracks...) + bool m_EndIsDangling; // TRUE si Start ou End not connected (wires, tracks...) public: EDA_DrawLineStruct( const wxPoint& pos, int layer ); @@ -81,12 +66,13 @@ public: EDA_Rect GetBoundingBox(); - virtual void Draw( WinEDA_DrawPanel* panel, wxDC* DC, const wxPoint& offset, int draw_mode, - int Color = -1 ); + virtual void Draw( WinEDA_DrawPanel* panel, wxDC* DC, const wxPoint& offset, + int draw_mode, int Color = -1 ); /** * Function Save - * writes the data structures for this object out to a FILE in "*.brd" format. + * writes the data structures for this object out to a FILE in "*.brd" + * format. * @param aFile The FILE to write to. * @return bool - true if success writing else false. */ @@ -94,12 +80,11 @@ public: #if defined(DEBUG) void Show( int nestLevel, std::ostream& os ); - #endif }; -class DrawMarkerStruct : public SCH_ITEM /* marqueurs */ +class DrawMarkerStruct : public SCH_ITEM /* marqueurs */ { public: wxPoint m_Pos; /* XY coordinates of marker. */ @@ -118,12 +103,14 @@ public: DrawMarkerStruct* GenCopy(); wxString GetComment(); - virtual void Draw( WinEDA_DrawPanel* panel, wxDC* DC, const wxPoint& offset, - int draw_mode, int Color = -1 ); + virtual void Draw( WinEDA_DrawPanel* panel, wxDC* DC, + const wxPoint& offset, int draw_mode, + int Color = -1 ); /** * Function Save - * writes the data structures for this object out to a FILE in "*.brd" format. + * writes the data structures for this object out to a FILE in "*.brd" + * format. * @param aFile The FILE to write to. * @return bool - true if success writing else false. */ @@ -131,7 +118,6 @@ public: #if defined(DEBUG) void Show( int nestLevel, std::ostream& os ); - #endif }; @@ -151,12 +137,14 @@ public: DrawNoConnectStruct* GenCopy(); - virtual void Draw( WinEDA_DrawPanel* panel, wxDC* DC, const wxPoint& offset, - int draw_mode, int Color = -1 ); + virtual void Draw( WinEDA_DrawPanel* panel, wxDC* DC, + const wxPoint& offset, int draw_mode, + int Color = -1 ); /** * Function Save - * writes the data structures for this object out to a FILE in "*.brd" format. + * writes the data structures for this object out to a FILE in "*.brd" + * format. * @param aFile The FILE to write to. * @return bool - true if success writing else false. */ @@ -195,12 +183,14 @@ public: DrawBusEntryStruct* GenCopy(); wxPoint m_End() const; // retourne la coord de fin du raccord - virtual void Draw( WinEDA_DrawPanel* panel, wxDC* DC, const wxPoint& offset, - int draw_mode, int Color = -1 ); + virtual void Draw( WinEDA_DrawPanel* panel, wxDC* DC, + const wxPoint& offset, int draw_mode, + int Color = -1 ); /** * Function Save - * writes the data structures for this object out to a FILE in "*.brd" format. + * writes the data structures for this object out to a FILE in "*.brd" + * format. * @param aFile The FILE to write to. * @return bool - true if success writing else false. */ @@ -226,12 +216,14 @@ public: DrawPolylineStruct* GenCopy(); - virtual void Draw( WinEDA_DrawPanel* panel, wxDC* DC, const wxPoint& offset, - int draw_mode, int Color = -1 ); + virtual void Draw( WinEDA_DrawPanel* panel, wxDC* DC, + const wxPoint& offset, int draw_mode, + int Color = -1 ); /** * Function Save - * writes the data structures for this object out to a FILE in "*.brd" format. + * writes the data structures for this object out to a FILE in "*.brd" + * format. * @param aFile The FILE to write to. * @return bool - true if success writing else false. */ @@ -252,7 +244,8 @@ public: unsigned GetCornerCount() const { return m_PolyPoints.size(); } }; -class DrawJunctionStruct : public SCH_ITEM + +class DrawJunctionStruct : public SCH_ITEM { public: wxPoint m_Pos; /* XY coordinates of connection. */ @@ -277,8 +270,9 @@ public: DrawJunctionStruct* GenCopy(); - virtual void Draw( WinEDA_DrawPanel* panel, wxDC* DC, const wxPoint& offset, - int draw_mode, int Color = -1 ); + virtual void Draw( WinEDA_DrawPanel* panel, wxDC* DC, + const wxPoint& offset, int draw_mode, + int Color = -1 ); /** * Function Save * writes the data structures for this object out to a FILE in "*.brd" format. @@ -289,7 +283,6 @@ public: #if defined(DEBUG) void Show( int nestLevel, std::ostream& os ); - #endif }; diff --git a/eeschema/class_screen.cpp b/eeschema/class_screen.cpp index 685888e5a5..7de56ae282 100644 --- a/eeschema/class_screen.cpp +++ b/eeschema/class_screen.cpp @@ -41,40 +41,6 @@ void SetaParent( EDA_BaseStruct* Struct, BASE_SCREEN* Screen ) } -/***************************************************************/ -void SCH_ITEM::Place( WinEDA_SchematicFrame* frame, wxDC* DC ) -/***************************************************************/ - -/* place the struct in EEDrawList. - * if it is a new item, it it also put in undo list - * for an "old" item, saving it in undo list must be done before editiing, - * and not here! - */ -{ - if( m_Flags & IS_NEW ) - { - SCH_SCREEN* screen = frame->GetScreen(); - if( !screen->CheckIfOnDrawList( this ) ) //don't want a loop! - screen->AddToDrawList( this ); - g_ItemToRepeat = this; - frame->SaveCopyInUndoList( this, IS_NEW ); - } - - m_Flags = 0; - frame->GetScreen()->SetModify(); - frame->GetScreen()->SetCurItem( NULL ); - frame->DrawPanel->ManageCurseur = NULL; - frame->DrawPanel->ForceCloseManageCurseur = NULL; - - if( DC ) - { - frame->DrawPanel->CursorOff( DC ); // Erase schematic cursor - RedrawOneStruct( frame->DrawPanel, DC, this, GR_DEFAULT_DRAWMODE ); - frame->DrawPanel->CursorOn( DC ); // Display schematic cursor - } -} - - /***********************************************************************/ /* Class SCH_SCREEN: classe de gestion d'un affichage pour schematique */ /***********************************************************************/ diff --git a/eeschema/class_text-label.cpp b/eeschema/class_text-label.cpp index 47c8fe8845..f842515e4c 100644 --- a/eeschema/class_text-label.cpp +++ b/eeschema/class_text-label.cpp @@ -23,6 +23,52 @@ /* class SCH_HIERLABEL */ /************************/ +/* Messages correspondants aux types ou forme des labels */ +const char* SheetLabelType[] = +{ + "Input", + "Output", + "BiDi", + "3State", + "UnSpc", + "?????" +}; + +int TemplateIN_HN[] = { 6, 0, 0, -1, -1, -2, -1, -2, 1, -1, 1, 0, 0 }; +int TemplateIN_HI[] = { 6, 0, 0, 1, 1, 2, 1, 2, -1, 1, -1, 0, 0 }; +int TemplateIN_BOTTOM[] = { 6, 0, 0, 1, -1, 1, -2, -1, -2, -1, -1, 0, 0 }; +int TemplateIN_UP[] = { 6, 0, 0, 1, 1, 1, 2, -1, 2, -1, 1, 0, 0 }; + +int TemplateOUT_HN[] = { 6, -2, 0, -1, 1, 0, 1, 0, -1, -1, -1, -2, 0 }; +int TemplateOUT_HI[] = { 6, 2, 0, 1, -1, 0, -1, 0, 1, 1, 1, 2, 0 }; +int TemplateOUT_BOTTOM[] = { 6, 0, -2, 1, -1, 1, 0, -1, 0, -1, -1, 0, -2 }; +int TemplateOUT_UP[] = { 6, 0, 2, 1, 1, 1, 0, -1, 0, -1, 1, 0, 2 }; + +int TemplateUNSPC_HN[] = { 5, 0, -1, -2, -1, -2, 1, 0, 1, 0, -1 }; +int TemplateUNSPC_HI[] = { 5, 0, -1, 2, -1, 2, 1, 0, 1, 0, -1 }; +int TemplateUNSPC_BOTTOM[] = { 5, 1, 0, 1, -2, -1, -2, -1, 0, 1, 0 }; +int TemplateUNSPC_UP[] = { 5, 1, 0, 1, 2, -1, 2, -1, 0, 1, 0 }; + +int TemplateBIDI_HN[] = { 5, 0, 0, -1, -1, -2, 0, -1, 1, 0, 0 }; +int TemplateBIDI_HI[] = { 5, 0, 0, 1, -1, 2, 0, 1, 1, 0, 0 }; +int TemplateBIDI_BOTTOM[] = { 5, 0, 0, -1, -1, 0, -2, 1, -1, 0, 0 }; +int TemplateBIDI_UP[] = { 5, 0, 0, -1, 1, 0, 2, 1, 1, 0, 0 }; + +int Template3STATE_HN[] = { 5, 0, 0, -1, -1, -2, 0, -1, 1, 0, 0 }; +int Template3STATE_HI[] = { 5, 0, 0, 1, -1, 2, 0, 1, 1, 0, 0 }; +int Template3STATE_BOTTOM[] = { 5, 0, 0, -1, -1, 0, -2, 1, -1, 0, 0 }; +int Template3STATE_UP[] = { 5, 0, 0, -1, 1, 0, 2, 1, 1, 0, 0 }; + +int* TemplateShape[5][4] = +{ + { TemplateIN_HN, TemplateIN_UP, TemplateIN_HI, TemplateIN_BOTTOM }, + { TemplateOUT_HN, TemplateOUT_UP, TemplateOUT_HI, TemplateOUT_BOTTOM }, + { TemplateBIDI_HN, TemplateBIDI_UP, TemplateBIDI_HI, TemplateBIDI_BOTTOM }, + { Template3STATE_HN, Template3STATE_UP, Template3STATE_HI, Template3STATE_BOTTOM }, + { TemplateUNSPC_HN, TemplateUNSPC_UP, TemplateUNSPC_HI, TemplateUNSPC_BOTTOM } +}; + + /**************************************************************************/ SCH_TEXT::SCH_TEXT( const wxPoint& pos, const wxString& text, KICAD_T aType ) : SCH_ITEM( NULL, aType ) diff --git a/eeschema/class_text-label.h b/eeschema/class_text-label.h index 8b5734488c..062102581c 100644 --- a/eeschema/class_text-label.h +++ b/eeschema/class_text-label.h @@ -5,10 +5,6 @@ #ifndef CLASS_TEXT_LABEL_H #define CLASS_TEXT_LABEL_H -#ifndef eda_global -#define eda_global extern -#endif - #include "macros.h" #include "base_struct.h" @@ -23,58 +19,9 @@ typedef enum { } TypeSheetLabel; /* Messages correspondants aux types ou forme des labels */ -#ifdef MAIN -const char* SheetLabelType[] = -{ - "Input", - "Output", - "BiDi", - "3State", - "UnSpc", - "?????" -}; -#else extern const char* SheetLabelType[]; -#endif - -/* Description du graphisme des icones associes aux types des Global_Labels */ -#ifdef MAIN -int TemplateIN_HN[] = { 6, 0, 0, -1, -1, -2, -1, -2, 1, -1, 1, 0, 0 }; -int TemplateIN_HI[] = { 6, 0, 0, 1, 1, 2, 1, 2, -1, 1, -1, 0, 0 }; -int TemplateIN_BOTTOM[] = { 6, 0, 0, 1, -1, 1, -2, -1, -2, -1, -1, 0, 0 }; -int TemplateIN_UP[] = { 6, 0, 0, 1, 1, 1, 2, -1, 2, -1, 1, 0, 0 }; - -int TemplateOUT_HN[] = { 6, -2, 0, -1, 1, 0, 1, 0, -1, -1, -1, -2, 0 }; -int TemplateOUT_HI[] = { 6, 2, 0, 1, -1, 0, -1, 0, 1, 1, 1, 2, 0 }; -int TemplateOUT_BOTTOM[] = { 6, 0, -2, 1, -1, 1, 0, -1, 0, -1, -1, 0, -2 }; -int TemplateOUT_UP[] = { 6, 0, 2, 1, 1, 1, 0, -1, 0, -1, 1, 0, 2 }; - -int TemplateUNSPC_HN[] = { 5, 0, -1, -2, -1, -2, 1, 0, 1, 0, -1 }; -int TemplateUNSPC_HI[] = { 5, 0, -1, 2, -1, 2, 1, 0, 1, 0, -1 }; -int TemplateUNSPC_BOTTOM[] = { 5, 1, 0, 1, -2, -1, -2, -1, 0, 1, 0 }; -int TemplateUNSPC_UP[] = { 5, 1, 0, 1, 2, -1, 2, -1, 0, 1, 0 }; - -int TemplateBIDI_HN[] = { 5, 0, 0, -1, -1, -2, 0, -1, 1, 0, 0 }; -int TemplateBIDI_HI[] = { 5, 0, 0, 1, -1, 2, 0, 1, 1, 0, 0 }; -int TemplateBIDI_BOTTOM[] = { 5, 0, 0, -1, -1, 0, -2, 1, -1, 0, 0 }; -int TemplateBIDI_UP[] = { 5, 0, 0, -1, 1, 0, 2, 1, 1, 0, 0 }; - -int Template3STATE_HN[] = { 5, 0, 0, -1, -1, -2, 0, -1, 1, 0, 0 }; -int Template3STATE_HI[] = { 5, 0, 0, 1, -1, 2, 0, 1, 1, 0, 0 }; -int Template3STATE_BOTTOM[] = { 5, 0, 0, -1, -1, 0, -2, 1, -1, 0, 0 }; -int Template3STATE_UP[] = { 5, 0, 0, -1, 1, 0, 2, 1, 1, 0, 0 }; - -int* TemplateShape[5][4] = -{ - { TemplateIN_HN, TemplateIN_UP, TemplateIN_HI, TemplateIN_BOTTOM }, - { TemplateOUT_HN, TemplateOUT_UP, TemplateOUT_HI, TemplateOUT_BOTTOM }, - { TemplateBIDI_HN, TemplateBIDI_UP, TemplateBIDI_HI, TemplateBIDI_BOTTOM }, - { Template3STATE_HN, Template3STATE_UP, Template3STATE_HI, Template3STATE_BOTTOM }, - { TemplateUNSPC_HN, TemplateUNSPC_UP, TemplateUNSPC_HI, TemplateUNSPC_BOTTOM } -}; -#else extern int* TemplateShape[5][4]; -#endif + class SCH_TEXT : public SCH_ITEM , public EDA_TextStruct diff --git a/eeschema/classes_body_items.cpp b/eeschema/classes_body_items.cpp index 6a21db7133..a1736e1ab4 100644 --- a/eeschema/classes_body_items.cpp +++ b/eeschema/classes_body_items.cpp @@ -7,6 +7,7 @@ #include "common.h" #include "class_drawpanel.h" #include "drawtxt.h" +#include "trigo.h" #include "program.h" #include "libcmp.h" @@ -14,35 +15,184 @@ #include "protos.h" +const wxChar* MsgPinElectricType[] = +{ + wxT( "input" ), + wxT( "output" ), + wxT( "BiDi" ), + wxT( "3state" ), + wxT( "passive" ), + wxT( "unspc" ), + wxT( "power_in" ), + wxT( "power_out" ), + wxT( "openCol" ), + wxT( "openEm" ), + wxT( "?????" ) +}; + +static int fill_tab[3] = { 'N', 'F', 'f' }; + //#define DRAW_ARC_WITH_ANGLE // Used to draw arcs -/* Basic class (abstract) for components bodies items */ +/* Base class (abstract) for components bodies items */ LibEDA_BaseStruct::LibEDA_BaseStruct( KICAD_T struct_type ) : EDA_BaseStruct( struct_type ) { - m_Unit = 0; /* Unit identification (for multi part per package) - * 0 if the item is common to all units */ - m_Convert = 0; /* Shape identification (for parts which have a convert shape) - * 0 if the item is common to all shapes */ - m_Fill = NO_FILL; + m_Unit = 0; /* Unit identification (for multi part per package) + * 0 if the item is common to all units */ + m_Convert = 0; /* Shape identification (for parts which have a convert + * shape) 0 if the item is common to all shapes */ + m_Fill = NO_FILL; + + m_typeName = _( "Undefined" ); } -/** Function Draw (virtual) - * Draw A body item - * @param aPanel = DrawPanel to use (can be null) mainly used for clipping purposes - * @param aDC = Device Context (can be null) - * @param aOffset = offset to draw - * @param aDrawMode = GR_OR, GR_XOR, ... - * @param aDisplay_mode = FILL_T value ( has meaning only for items what can be filled ) - * @param aTransformMatrix = Transform Matrix +/** + * Update the message panel information with the drawing information. + * + * This base function is used to display the information common to the + * all library items. Call the base class from the derived class or the + * common information will not be updated in the message panel. */ +void LibEDA_BaseStruct::DisplayInfo( WinEDA_DrawFrame* frame ) +{ + wxString msg; -/**********************************************************************************************/ -void LibDrawArc::Draw( WinEDA_DrawPanel* aPanel, wxDC* aDC, const wxPoint& aOffset, int aColor, - int aDrawMode, void* aData, const int aTransformMatrix[2][2] ) -/**********************************************************************************************/ + frame->MsgPanel->EraseMsgBox(); + + frame->MsgPanel->Affiche_1_Parametre( 1, _( "Type" ), m_typeName, CYAN ); + + /* Affichage de l'appartenance */ + if( m_Unit == 0 ) + msg = _( "All" ); + else + msg.Printf( wxT( "%d" ), m_Unit ); + Affiche_1_Parametre( frame, 8, _( "Unit" ), msg, BROWN ); + + if( m_Convert == 0 ) + msg = _( "All" ); + else if( m_Convert == 1 ) + msg = _( "no" ); + else if( m_Convert == 2 ) + msg = _( "yes" ); + else + msg = wxT( "?" ); + Affiche_1_Parametre( frame, 14, _( "Convert" ), msg, BROWN ); +} + + +LibDrawArc::LibDrawArc() : LibEDA_BaseStruct( COMPONENT_ARC_DRAW_TYPE ) +{ + m_Rayon = 0; + t1 = t2 = 0; + m_Width = 0; + m_Fill = NO_FILL; + m_typeName = _( "Arc" ); +} + + +/** + * format: + * A centre_posx centre_posy rayon start_angle end_angle unit convert + * fill('N', 'F' ou 'f') startx starty endx endy + */ +bool LibDrawArc::Save( FILE* ExportFile ) const +{ + int x1 = t1; + + if( x1 > 1800 ) + x1 -= 3600; + + int x2 = t2; + + if( x2 > 1800 ) + x2 -= 3600; + + fprintf( ExportFile, "A %d %d %d %d %d %d %d %d %c %d %d %d %d\n", + m_Pos.x, m_Pos.y, m_Rayon, x1, x2, m_Unit, m_Convert, m_Width, + fill_tab[m_Fill], m_ArcStart.x, m_ArcStart.y, m_ArcEnd.x, + m_ArcEnd.y ); + + return true; +} + + +bool LibDrawArc::Load( char* line, wxString& errorMsg ) +{ + int startx, starty, endx, endy, cnt; + char tmp[256]; + + cnt = sscanf( &line[2], "%d %d %d %d %d %d %d %d %s %d %d %d %d", + &m_Pos.x, &m_Pos.y, &m_Rayon, &t1, &t2, &m_Unit, &m_Convert, + &m_Width, tmp, &startx, &starty, &endx, &endy ); + if( cnt < 8 ) + { + errorMsg.Printf( wxT( "arc only had %d parameters of the " \ + "required 8" ), cnt ); + return false; + } + + if( tmp[0] == 'F' ) + m_Fill = FILLED_SHAPE; + if( tmp[0] == 'f' ) + m_Fill = FILLED_WITH_BG_BODYCOLOR; + + NORMALIZE_ANGLE( t1 ); + NORMALIZE_ANGLE( t2 ); + + // Actual Coordinates of arc ends are read from file + if( cnt >= 13 ) + { + m_ArcStart.x = startx; + m_ArcStart.y = starty; + m_ArcEnd.x = endx; + m_ArcEnd.y = endy; + } + else + { + // Actual Coordinates of arc ends are not read from file + // (old library), calculate them + m_ArcStart.x = m_Rayon; + m_ArcStart.y = 0; + m_ArcEnd.x = m_Rayon; + m_ArcEnd.y = 0; + RotatePoint( &m_ArcStart.x, &m_ArcStart.y, -t1 ); + m_ArcStart.x += m_Pos.x; + m_ArcStart.y += m_Pos.y; + RotatePoint( &m_ArcEnd.x, &m_ArcEnd.y, -t2 ); + m_ArcEnd.x += m_Pos.x; + m_ArcEnd.y += m_Pos.y; + } + + return true; +} + + +LibDrawArc* LibDrawArc::GenCopy() +{ + LibDrawArc* newitem = new LibDrawArc(); + + newitem->m_Pos = m_Pos; + newitem->m_ArcStart = m_ArcStart; + newitem->m_ArcEnd = m_ArcEnd; + newitem->m_Rayon = m_Rayon; + newitem->t1 = t1; + newitem->t2 = t2; + newitem->m_Width = m_Width; + newitem->m_Unit = m_Unit; + newitem->m_Convert = m_Convert; + newitem->m_Flags = m_Flags; + newitem->m_Fill = m_Fill; + return newitem; +} + + +void LibDrawArc::Draw( WinEDA_DrawPanel* aPanel, wxDC* aDC, + const wxPoint& aOffset, int aColor, + int aDrawMode, void* aData, + const int aTransformMatrix[2][2] ) { wxPoint pos1, pos2, posc; @@ -83,351 +233,150 @@ void LibDrawArc::Draw( WinEDA_DrawPanel* aPanel, wxDC* aDC, const wxPoint& aOffs GRFilledArc( &aPanel->m_ClipBox, aDC, posc.x, posc.y, pt1, pt2, m_Rayon, color, color ); else + { #ifdef DRAW_ARC_WITH_ANGLE - - GRArc( &aPanel->m_ClipBox, aDC, posc.x, posc.y, pt1, pt2, m_Rayon, linewidth, color ); + #else - - GRArc1( &aPanel->m_ClipBox, aDC, pos1.x, pos1.y, pos2.x, pos2.y, posc.x, posc.y, linewidth, color ); + +#endif + } + + /* Set to one (1) to draw bounding box around arc to validate bounding box + * calculation. */ +#if 0 + EDA_Rect bBox = GetBoundingBox(); + GRRect( &aPanel->m_ClipBox, aDC, bBox.GetOrigin().x, bBox.GetOrigin().y, + bBox.GetEnd().x, bBox.GetEnd().y, 0, LIGHTMAGENTA ); #endif } -/*************************************************************************************************/ -void LibDrawCircle::Draw( WinEDA_DrawPanel* aPanel, wxDC* aDC, const wxPoint& aOffset, int aColor, - int aDrawMode, void* aData, const int aTransformMatrix[2][2] ) -/*************************************************************************************************/ +EDA_Rect LibDrawArc::GetBoundingBox() { - wxPoint pos1; + int minX, minY, maxX, maxY, angleStart, angleEnd; + EDA_Rect rect; + wxPoint nullPoint, startPos, endPos, centerPos; + wxPoint normStart = m_ArcStart - m_Pos; + wxPoint normEnd = m_ArcEnd - m_Pos; - int color = ReturnLayerColor( LAYER_DEVICE ); - int linewidth = MAX( m_Width, g_DrawMinimunLineWidth ); - - if( aColor < 0 ) // Used normal color or selected color + if( ( normStart == nullPoint ) || ( normEnd == nullPoint ) + || ( m_Rayon == 0 ) ) { - if( (m_Selected & IS_SELECTED) ) - color = g_ItemSelectetColor; + wxLogDebug( wxT(" Invalid arc drawing definition, center(%d, %d) " \ + "start(%d, %d), end(%d, %d), radius %d" ), + m_Pos.x, m_Pos.y, m_ArcStart.x, m_ArcStart.y, m_ArcEnd.x, + m_ArcEnd.y, m_Rayon ); + return rect; } - else - color = aColor; - pos1 = TransformCoordinate( aTransformMatrix, m_Pos ) + aOffset; - GRSetDrawMode( aDC, aDrawMode ); + endPos = TransformCoordinate( DefaultTransformMatrix, m_ArcEnd ); + startPos = TransformCoordinate( DefaultTransformMatrix, m_ArcStart ); + centerPos = TransformCoordinate( DefaultTransformMatrix, m_Pos ); + angleStart = t1; + angleEnd = t2; - FILL_T fill = aData ? NO_FILL : m_Fill; - if( aColor >= 0 ) - fill = NO_FILL; + if( MapAngles( &angleStart, &angleEnd, DefaultTransformMatrix ) ) + { + EXCHG( endPos.x, startPos.x ); + EXCHG( endPos.y, startPos.y ); + } - if( fill == FILLED_WITH_BG_BODYCOLOR ) - GRFilledCircle( &aPanel->m_ClipBox, aDC, pos1.x, pos1.y, - m_Rayon, linewidth, color, - ReturnLayerColor( LAYER_DEVICE_BACKGROUND ) ); - else if( fill == FILLED_SHAPE ) - GRFilledCircle( &aPanel->m_ClipBox, aDC, pos1.x, pos1.y, - m_Rayon, 0, color, color ); - else - GRCircle( &aPanel->m_ClipBox, aDC, pos1.x, pos1.y, - m_Rayon, linewidth, color ); + /* Start with the start and end point of the arc. */ + minX = MIN( startPos.x, endPos.x ); + minY = MIN( startPos.y, endPos.y ); + maxX = MAX( startPos.x, endPos.x ); + maxY = MAX( startPos.y, endPos.y ); + + /* Zero degrees is a special case. */ + if( angleStart == 0 ) + maxX = centerPos.x + m_Rayon; + + /* Arc end angle wrapped passed 360. */ + if( angleStart > angleEnd ) + angleEnd += 3600; + + if( angleStart <= 900 && angleEnd >= 900 ) /* 90 deg */ + maxY = centerPos.y + m_Rayon; + if( angleStart <= 1800 && angleEnd >= 1800 ) /* 180 deg */ + minX = centerPos.x - m_Rayon; + if( angleStart <= 2700 && angleEnd >= 2700 ) /* 270 deg */ + minY = centerPos.y - m_Rayon; + if( angleStart <= 3600 && angleEnd >= 3600 ) /* 0 deg */ + maxX = centerPos.x + m_Rayon; + + rect.SetOrigin( minX, minY ); + rect.SetEnd( maxX, maxY ); + rect.Inflate( m_Width / 2, m_Width / 2 ); + + return rect; } -/*************************************************************************************************/ -void LibDrawText::Draw( WinEDA_DrawPanel* aPanel, wxDC* aDC, const wxPoint& aOffset, int aColor, - int aDrawMode, void* aData, const int aTransformMatrix[2][2] ) -/*************************************************************************************************/ +void LibDrawArc::DisplayInfo( WinEDA_DrawFrame* frame ) { - wxPoint pos1, pos2; + wxString msg; + EDA_Rect bBox = GetBoundingBox(); - int color = ReturnLayerColor( LAYER_DEVICE ); - int linewidth = MAX( m_Width, g_DrawMinimunLineWidth ); + LibEDA_BaseStruct::DisplayInfo( frame ); - if( aColor < 0 ) // Used normal color or selected color - { - if( (m_Selected & IS_SELECTED) ) - color = g_ItemSelectetColor; - } - else - color = aColor; + msg = ReturnStringFromValue( g_UnitMetric, m_Width, + EESCHEMA_INTERNAL_UNIT, true ); - pos1 = TransformCoordinate( aTransformMatrix, m_Pos ) + aOffset; + frame->MsgPanel->Affiche_1_Parametre( 20, _( "Line width" ), msg, BLUE ); - /* The text orientation may need to be flipped if the - * transformation matrix causes xy axes to be flipped. */ - int t1 = (aTransformMatrix[0][0] != 0) ^ (m_Orient != 0); + msg.Printf( wxT( "(%d, %d, %d, %d)" ), bBox.GetOrigin().x, + bBox.GetOrigin().y, bBox.GetEnd().x, bBox.GetEnd().y ); - DrawGraphicText( aPanel, aDC, pos1, (EDA_Colors) color, m_Text, - t1 ? TEXT_ORIENT_HORIZ : TEXT_ORIENT_VERT, - m_Size, - GR_TEXT_HJUSTIFY_CENTER, GR_TEXT_VJUSTIFY_CENTER, linewidth, m_Italic ); + frame->MsgPanel->Affiche_1_Parametre( 40, _( "Bounding box" ), msg, BROWN ); } -/*************************************************************************************************/ -void LibDrawSquare::Draw( WinEDA_DrawPanel* aPanel, wxDC* aDC, const wxPoint& aOffset, int aColor, - int aDrawMode, void* aData, const int aTransformMatrix[2][2] ) -/*************************************************************************************************/ -{ - wxPoint pos1, pos2; - - int color = ReturnLayerColor( LAYER_DEVICE ); - int linewidth = MAX( m_Width, g_DrawMinimunLineWidth ); - - if( aColor < 0 ) // Used normal color or selected color - { - if( (m_Selected & IS_SELECTED) ) - color = g_ItemSelectetColor; - } - else - color = aColor; - - pos1 = TransformCoordinate( aTransformMatrix, m_Pos ) + aOffset; - pos2 = TransformCoordinate( aTransformMatrix, m_End ) + aOffset; - - FILL_T fill = aData ? NO_FILL : m_Fill; - if( aColor >= 0 ) - fill = NO_FILL; - - if( fill == FILLED_WITH_BG_BODYCOLOR && !aData ) - GRFilledRect( &aPanel->m_ClipBox, aDC, pos1.x, pos1.y, pos2.x, pos2.y, - linewidth, color, - ReturnLayerColor( LAYER_DEVICE_BACKGROUND ) ); - else if( m_Fill == FILLED_SHAPE && !aData ) - GRFilledRect( &aPanel->m_ClipBox, aDC, pos1.x, pos1.y, pos2.x, pos2.y, - linewidth, color, color ); - else - GRRect( &aPanel->m_ClipBox, aDC, pos1.x, pos1.y, pos2.x, pos2.y, - linewidth, color ); -} - - -/*************************************************************************************************/ -void LibDrawSegment::Draw( WinEDA_DrawPanel* aPanel, wxDC* aDC, const wxPoint& aOffset, int aColor, - int aDrawMode, void* aData, const int aTransformMatrix[2][2] ) -/*************************************************************************************************/ -{ - wxPoint pos1, pos2; - - int color = ReturnLayerColor( LAYER_DEVICE ); - int linewidth = MAX( m_Width, g_DrawMinimunLineWidth ); - - if( aColor < 0 ) // Used normal color or selected color - { - if( (m_Selected & IS_SELECTED) ) - color = g_ItemSelectetColor; - } - else - color = aColor; - - pos1 = TransformCoordinate( aTransformMatrix, m_Pos ) + aOffset; - pos2 = TransformCoordinate( aTransformMatrix, m_End ) + aOffset; - - GRLine( &aPanel->m_ClipBox, aDC, pos1.x, pos1.y, pos2.x, pos2.y, linewidth, color ); -} - - -/*************************************************************************************************/ -void LibDrawPolyline::Draw( WinEDA_DrawPanel* aPanel, wxDC* aDC, - const wxPoint& aOffset, int aColor, - int aDrawMode, void* aData, - const int aTransformMatrix[2][2] ) -/*************************************************************************************************/ -{ - wxPoint pos1; - - int color = ReturnLayerColor( LAYER_DEVICE ); - int linewidth = MAX( m_Width, g_DrawMinimunLineWidth ); - static wxPoint* Buf_Poly_Drawings = NULL; // Buffer used to store current corners coordinates for drawings - static unsigned Buf_Poly_Size = 0; // Buffer used to store current corners coordinates for drawings - - if( aColor < 0 ) // Used normal color or selected color - { - if( (m_Selected & IS_SELECTED) ) - color = g_ItemSelectetColor; - } - else - color = aColor; - - // Set the size of the buffer od coordinates - if( Buf_Poly_Drawings == NULL ) - { - Buf_Poly_Size = m_PolyPoints.size(); - Buf_Poly_Drawings = (wxPoint*) MyMalloc( sizeof(wxPoint) * Buf_Poly_Size ); - } - else if( Buf_Poly_Size < m_PolyPoints.size() ) - { - Buf_Poly_Size = m_PolyPoints.size(); - Buf_Poly_Drawings = (wxPoint*) realloc( Buf_Poly_Drawings, - sizeof(wxPoint) * Buf_Poly_Size ); - } - - for( unsigned ii = 0; ii < m_PolyPoints.size(); ii++ ) - { - Buf_Poly_Drawings[ii] = - TransformCoordinate( aTransformMatrix, m_PolyPoints[ii] ) + aOffset; - } - - FILL_T fill = aData ? NO_FILL : m_Fill; - if( aColor >= 0 ) - fill = NO_FILL; - - if( fill == FILLED_WITH_BG_BODYCOLOR ) - GRPoly( &aPanel->m_ClipBox, aDC, m_PolyPoints.size(), - Buf_Poly_Drawings, 1, linewidth, color, - ReturnLayerColor( LAYER_DEVICE_BACKGROUND ) ); - else if( fill == FILLED_SHAPE ) - GRPoly( &aPanel->m_ClipBox, aDC, m_PolyPoints.size(), - Buf_Poly_Drawings, 1, linewidth, color, color ); - else - GRPoly( &aPanel->m_ClipBox, aDC, m_PolyPoints.size(), - Buf_Poly_Drawings, 0, linewidth, color, color ); -} - - -/*************************************************************************************************/ -void LibDrawField::Draw( WinEDA_DrawPanel* aPanel, wxDC* aDC, const wxPoint& aOffset, int aColor, - int aDrawMode, void* aData, const int aTransformMatrix[2][2] ) -/*************************************************************************************************/ - -/* if aData not NULL, aData must point a wxString which is used instead of the m_Text - */ -{ - wxPoint text_pos; - - int color = aColor; - int linewidth = MAX( m_Width, g_DrawMinimunLineWidth ); - - if( aColor < 0 ) // Used normal color or selected color - { - if( (m_Selected & IS_SELECTED) ) - color = g_ItemSelectetColor; - } - else - color = aColor; - - if( color < 0 ) - { - switch( m_FieldId ) - { - case REFERENCE: - color = ReturnLayerColor( LAYER_REFERENCEPART ); - break; - - case VALUE: - color = ReturnLayerColor( LAYER_VALUEPART ); - break; - - default: - color = ReturnLayerColor( LAYER_FIELDS ); - break; - } - } - text_pos = TransformCoordinate( aTransformMatrix, m_Pos ) + aOffset; - - wxString* text = aData ? (wxString*) aData : &m_Text; - GRSetDrawMode( aDC, aDrawMode ); - DrawGraphicText( aPanel, aDC, text_pos, - (EDA_Colors) color, text->GetData(), - m_Orient ? TEXT_ORIENT_VERT : TEXT_ORIENT_HORIZ, - m_Size, - m_HJustify, m_VJustify, linewidth, m_Italic ); -} - - -/** - * Function HitTest - * tests if the given wxPoint is within the bounds of this object. - * @param refPos A wxPoint to test, in Field coordinate system - * @return bool - true if a hit, else false - */ -bool LibDrawField::HitTest( const wxPoint& refPos ) -{ - EDA_Rect bbox; // bounding box for the text - - bbox.SetOrigin( m_Pos ); - int dx; // X size for the full text - if( m_FieldId == REFERENCE ) - dx = m_Size.x * (m_Text.Len() + 1); // The displayed text has one char more (U is displayed U?) - else - dx = m_Size.x * m_Text.Len(); - dx = (int) ( (double) dx * 10.0 / 9 ); // spacing between char is 0.1 the char size - int dy = m_Size.y; - - if( m_Orient ) - EXCHG( dx, dy ); // Swap X and Y size for a vertical text - - // adjust position of the left bottom corner according to the justification - // pos is at this point correct for a left and top justified text - // Horizontal justification - if( m_HJustify == GR_TEXT_HJUSTIFY_CENTER ) - bbox.Offset( -dx / 2, 0 ); - else if( m_HJustify == GR_TEXT_HJUSTIFY_RIGHT ) - bbox.Offset( -dx, 0 ); - - // Vertical justification - if( m_VJustify == GR_TEXT_VJUSTIFY_CENTER ) - bbox.Offset( 0, -dy / 2 ); - else if( m_VJustify == GR_TEXT_VJUSTIFY_TOP ) - bbox.Offset( 0, -dy ); - - bbox.SetSize( dx, dy ); - - if( bbox.Inside( refPos ) ) - return true; - - return false; -} - - -/**************************************************************/ -LibDrawArc::LibDrawArc() : LibEDA_BaseStruct( COMPONENT_ARC_DRAW_TYPE ) -/**************************************************************/ -{ - m_Rayon = 0; - t1 = t2 = 0; - m_Width = 0; - m_Fill = NO_FILL; -} - - -/************************************/ -LibDrawArc* LibDrawArc::GenCopy() -/************************************/ -{ - LibDrawArc* newitem = new LibDrawArc(); - - newitem->m_Pos = m_Pos; - newitem->m_ArcStart = m_ArcStart; - newitem->m_ArcEnd = m_ArcEnd; - newitem->m_Rayon = m_Rayon; - newitem->t1 = t1; - newitem->t2 = t2; - newitem->m_Width = m_Width; - newitem->m_Unit = m_Unit; - newitem->m_Convert = m_Convert; - newitem->m_Flags = m_Flags; - newitem->m_Fill = m_Fill; - return newitem; -} - - -/**********************************************************************/ LibDrawCircle::LibDrawCircle() : LibEDA_BaseStruct( COMPONENT_CIRCLE_DRAW_TYPE ) -/**********************************************************************/ { m_Rayon = 0; m_Fill = NO_FILL; + m_typeName = _( "Circle" ); +} + + +bool LibDrawCircle::Save( FILE* ExportFile ) const +{ + fprintf( ExportFile, "C %d %d %d %d %d %d %c\n", m_Pos.x, m_Pos.y, + m_Rayon, m_Unit, m_Convert, m_Width, fill_tab[m_Fill] ); + + return true; +} + + +bool LibDrawCircle::Load( char* line, wxString& errorMsg ) +{ + char tmp[256]; + + int cnt = sscanf( &line[2], "%d %d %d %d %d %d %s", &m_Pos.x, &m_Pos.y, + &m_Rayon, &m_Unit, &m_Convert, &m_Width, tmp ); + if( cnt < 6 ) + { + errorMsg.Printf( wxT( "circle only had %d parameters of the " \ + "required 6" ), cnt ); + return false; + } + + if( tmp[0] == 'F' ) + m_Fill = FILLED_SHAPE; + if( tmp[0] == 'f' ) + m_Fill = FILLED_WITH_BG_BODYCOLOR; + + return true; } -/*******************************************/ LibDrawCircle* LibDrawCircle::GenCopy() -/*******************************************/ { LibDrawCircle* newitem = new LibDrawCircle(); @@ -442,18 +391,135 @@ LibDrawCircle* LibDrawCircle::GenCopy() } -/*****************************************************************/ -LibDrawText::LibDrawText() : LibEDA_BaseStruct( COMPONENT_GRAPHIC_TEXT_DRAW_TYPE ), - EDA_TextStruct() -/*****************************************************************/ +void LibDrawCircle::Draw( WinEDA_DrawPanel* aPanel, wxDC* aDC, + const wxPoint& aOffset, int aColor, int aDrawMode, + void* aData, const int aTransformMatrix[2][2] ) { - m_Size = wxSize( 50, 50 ); + wxPoint pos1; + + int color = ReturnLayerColor( LAYER_DEVICE ); + int linewidth = MAX( m_Width, g_DrawMinimunLineWidth ); + + if( aColor < 0 ) // Used normal color or selected color + { + if( ( m_Selected & IS_SELECTED ) ) + color = g_ItemSelectetColor; + } + else + color = aColor; + + pos1 = TransformCoordinate( aTransformMatrix, m_Pos ) + aOffset; + GRSetDrawMode( aDC, aDrawMode ); + + FILL_T fill = aData ? NO_FILL : m_Fill; + if( aColor >= 0 ) + fill = NO_FILL; + + if( fill == FILLED_WITH_BG_BODYCOLOR ) + GRFilledCircle( &aPanel->m_ClipBox, aDC, pos1.x, pos1.y, + m_Rayon, linewidth, color, + ReturnLayerColor( LAYER_DEVICE_BACKGROUND ) ); + else if( fill == FILLED_SHAPE ) + GRFilledCircle( &aPanel->m_ClipBox, aDC, pos1.x, pos1.y, + m_Rayon, 0, color, color ); + else + GRCircle( &aPanel->m_ClipBox, aDC, pos1.x, pos1.y, + m_Rayon, linewidth, color ); +} + + +EDA_Rect LibDrawCircle::GetBoundingBox() +{ + EDA_Rect rect; + rect.SetOrigin( m_Pos.x - m_Rayon, ( m_Pos.y - m_Rayon ) * -1 ); + rect.SetEnd( m_Pos.x + m_Rayon, ( m_Pos.y + m_Rayon ) * -1 ); + rect.Inflate( m_Width / 2, m_Width / 2 ); + return rect; +} + + +void LibDrawCircle::DisplayInfo( WinEDA_DrawFrame* frame ) +{ + wxString msg; + EDA_Rect bBox = GetBoundingBox(); + + LibEDA_BaseStruct::DisplayInfo( frame ); + + msg = ReturnStringFromValue( g_UnitMetric, m_Width, + EESCHEMA_INTERNAL_UNIT, true ); + + frame->MsgPanel->Affiche_1_Parametre( 20, _( "Line width" ), msg, BLUE ); + + msg = ReturnStringFromValue( g_UnitMetric, m_Rayon, + EESCHEMA_INTERNAL_UNIT, true ); + frame->MsgPanel->Affiche_1_Parametre( 40, _( "Radius" ), msg, RED ); + + msg.Printf( wxT( "(%d, %d, %d, %d)" ), bBox.GetOrigin().x, + bBox.GetOrigin().y, bBox.GetEnd().x, bBox.GetEnd().y ); + + frame->MsgPanel->Affiche_1_Parametre( 60, _( "Bounding box" ), msg, BROWN ); +} + + +LibDrawText::LibDrawText() : + LibEDA_BaseStruct( COMPONENT_GRAPHIC_TEXT_DRAW_TYPE ), EDA_TextStruct() +{ + m_Size = wxSize( 50, 50 ); + m_typeName = _( "Text" ); +} + + +bool LibDrawText::Save( FILE* ExportFile ) const +{ + wxString text = m_Text; + // Spaces are not allowed in text because it is not double quoted: + // changed to '~' + text.Replace( wxT( " " ), wxT( "~" ) ); + + fprintf( ExportFile, "T %d %d %d %d %d %d %d %s ", m_Orient, + m_Pos.x, m_Pos.y, m_Size.x, m_Attributs, m_Unit, m_Convert, + CONV_TO_UTF8( text )); + fprintf( ExportFile, " %s %d", m_Italic ? "Italic" : "Normal", m_Width ); + fprintf( ExportFile, "\n"); + + return true; +} + + +bool LibDrawText::Load( char* line, wxString& errorMsg ) +{ + int cnt; + char buf[256]; + char tmp[256]; + + buf[0] = 0; + tmp[0] = 0; // For italic option, Not in old versions + + cnt = sscanf( &line[2], "%d %d %d %d %d %d %d %s %s %d", + &m_Orient, &m_Pos.x, &m_Pos.y, &m_Size.x, &m_Attributs, + &m_Unit, &m_Convert, buf, tmp, &m_Width ); + + if( cnt < 8 ) + { + errorMsg.Printf( wxT( "text only had %d parameters of the " \ + "required 8" ), cnt ); + return false; + } + + m_Size.y = m_Size.x; + + if ( strnicmp( tmp, "Italic", 6 ) == 0 ) + m_Italic = true; + + /* Convert '~' to spaces. */ + m_Text = CONV_FROM_UTF8( buf ); + m_Text.Replace( wxT( "~" ), wxT( " " ) ); + + return true; } -/***************************************/ LibDrawText* LibDrawText::GenCopy() -/***************************************/ { LibDrawText* newitem = new LibDrawText(); @@ -473,10 +539,87 @@ LibDrawText* LibDrawText::GenCopy() } +void LibDrawText::Draw( WinEDA_DrawPanel* aPanel, wxDC* aDC, + const wxPoint& aOffset, int aColor, int aDrawMode, + void* aData, const int aTransformMatrix[2][2] ) +{ + wxPoint pos1, pos2; + + int color = ReturnLayerColor( LAYER_DEVICE ); + int linewidth = MAX( m_Width, g_DrawMinimunLineWidth ); + + if( aColor < 0 ) // Used normal color or selected color + { + if( ( m_Selected & IS_SELECTED ) ) + color = g_ItemSelectetColor; + } + else + color = aColor; + + pos1 = TransformCoordinate( aTransformMatrix, m_Pos ) + aOffset; + + /* The text orientation may need to be flipped if the + * transformation matrix causes xy axes to be flipped. */ + int t1 = ( aTransformMatrix[0][0] != 0 ) ^ ( m_Orient != 0 ); + + DrawGraphicText( aPanel, aDC, pos1, (EDA_Colors) color, m_Text, + t1 ? TEXT_ORIENT_HORIZ : TEXT_ORIENT_VERT, + m_Size, GR_TEXT_HJUSTIFY_CENTER, GR_TEXT_VJUSTIFY_CENTER, + linewidth, m_Italic ); +} + + +void LibDrawText::DisplayInfo( WinEDA_DrawFrame* frame ) +{ + wxString msg; + + LibEDA_BaseStruct::DisplayInfo( frame ); + + msg = ReturnStringFromValue( g_UnitMetric, m_Width, + EESCHEMA_INTERNAL_UNIT, true ); + + frame->MsgPanel->Affiche_1_Parametre( 20, _( "Line width" ), msg, BLUE ); +} + + LibDrawSquare::LibDrawSquare() : LibEDA_BaseStruct( COMPONENT_RECT_DRAW_TYPE ) { m_Width = 0; m_Fill = NO_FILL; + m_typeName = _( "Rectangle" ); +} + + +bool LibDrawSquare::Save( FILE* ExportFile ) const +{ + fprintf( ExportFile, "S %d %d %d %d %d %d %d %c\n", m_Pos.x, m_Pos.y, + m_End.x, m_End.y, m_Unit, m_Convert, m_Width, fill_tab[m_Fill] ); + + return true; +} + + +bool LibDrawSquare::Load( char* line, wxString& errorMsg ) +{ + int cnt; + char tmp[256]; + + cnt = sscanf( &line[2], "%d %d %d %d %d %d %d %s", &m_Pos.x, &m_Pos.y, + &m_End.x, &m_End.y, &m_Unit, &m_Convert, &m_Width, tmp ); + + if( cnt < 7 ) + { + errorMsg.Printf( wxT( "rectangle only had %d parameters of the " \ + "required 7" ), cnt ); + return false; + } + + if( tmp[0] == 'F' ) + m_Fill = FILLED_SHAPE; + if( tmp[0] == 'f' ) + m_Fill = FILLED_WITH_BG_BODYCOLOR; + + return true; } @@ -495,9 +638,84 @@ LibDrawSquare* LibDrawSquare::GenCopy() } +void LibDrawSquare::Draw( WinEDA_DrawPanel* aPanel, wxDC* aDC, + const wxPoint& aOffset, int aColor, int aDrawMode, + void* aData, const int aTransformMatrix[2][2] ) +{ + wxPoint pos1, pos2; + + int color = ReturnLayerColor( LAYER_DEVICE ); + int linewidth = MAX( m_Width, g_DrawMinimunLineWidth ); + + if( aColor < 0 ) // Used normal color or selected color + { + if( m_Selected & IS_SELECTED ) + color = g_ItemSelectetColor; + } + else + color = aColor; + + pos1 = TransformCoordinate( aTransformMatrix, m_Pos ) + aOffset; + pos2 = TransformCoordinate( aTransformMatrix, m_End ) + aOffset; + + FILL_T fill = aData ? NO_FILL : m_Fill; + if( aColor >= 0 ) + fill = NO_FILL; + + if( fill == FILLED_WITH_BG_BODYCOLOR && !aData ) + GRFilledRect( &aPanel->m_ClipBox, aDC, pos1.x, pos1.y, pos2.x, pos2.y, + linewidth, color, + ReturnLayerColor( LAYER_DEVICE_BACKGROUND ) ); + else if( m_Fill == FILLED_SHAPE && !aData ) + GRFilledRect( &aPanel->m_ClipBox, aDC, pos1.x, pos1.y, pos2.x, pos2.y, + linewidth, color, color ); + else + GRRect( &aPanel->m_ClipBox, aDC, pos1.x, pos1.y, pos2.x, pos2.y, + linewidth, color ); +} + + +void LibDrawSquare::DisplayInfo( WinEDA_DrawFrame* frame ) +{ + wxString msg; + + LibEDA_BaseStruct::DisplayInfo( frame ); + + msg = ReturnStringFromValue( g_UnitMetric, m_Width, + EESCHEMA_INTERNAL_UNIT, true ); + + frame->MsgPanel->Affiche_1_Parametre( 20, _( "Line width" ), msg, BLUE ); +} + + +EDA_Rect LibDrawSquare::GetBoundingBox() +{ + EDA_Rect rect; + rect.SetOrigin( m_Pos.x, m_Pos.y * -1 ); + rect.SetEnd( m_End.x, m_End.y * -1 ); + rect.Inflate( m_Width / 2, m_Width / 2 ); + return rect; +} + + LibDrawSegment::LibDrawSegment() : LibEDA_BaseStruct( COMPONENT_LINE_DRAW_TYPE ) { m_Width = 0; + m_typeName = _( "Segment" ); +} + + +bool LibDrawSegment::Save( FILE* ExportFile ) const +{ + fprintf( ExportFile, "L %d %d %d", m_Unit, m_Convert, m_Width ); + + return true; +} + + +bool LibDrawSegment::Load( char* line, wxString& errorMsg ) +{ + return true; } @@ -515,16 +733,138 @@ LibDrawSegment* LibDrawSegment::GenCopy() } -LibDrawPolyline::LibDrawPolyline() : LibEDA_BaseStruct( COMPONENT_POLYLINE_DRAW_TYPE ) +void LibDrawSegment::Draw( WinEDA_DrawPanel* aPanel, wxDC* aDC, + const wxPoint& aOffset, int aColor, int aDrawMode, + void* aData, const int aTransformMatrix[2][2] ) { - m_Fill = NO_FILL; - m_Width = 0; + wxPoint pos1, pos2; + + int color = ReturnLayerColor( LAYER_DEVICE ); + int linewidth = MAX( m_Width, g_DrawMinimunLineWidth ); + + if( aColor < 0 ) // Used normal color or selected color + { + if( m_Selected & IS_SELECTED ) + color = g_ItemSelectetColor; + } + else + color = aColor; + + pos1 = TransformCoordinate( aTransformMatrix, m_Pos ) + aOffset; + pos2 = TransformCoordinate( aTransformMatrix, m_End ) + aOffset; + + GRLine( &aPanel->m_ClipBox, aDC, pos1.x, pos1.y, pos2.x, pos2.y, + linewidth, color ); +} + + +void LibDrawSegment::DisplayInfo( WinEDA_DrawFrame* frame ) +{ + wxString msg; + EDA_Rect bBox = GetBoundingBox(); + + LibEDA_BaseStruct::DisplayInfo( frame ); + + msg = ReturnStringFromValue( g_UnitMetric, m_Width, + EESCHEMA_INTERNAL_UNIT, true ); + + frame->MsgPanel->Affiche_1_Parametre( 20, _( "Line width" ), msg, BLUE ); + + msg.Printf( wxT( "(%d, %d, %d, %d)" ), bBox.GetOrigin().x, + bBox.GetOrigin().y, bBox.GetEnd().x, bBox.GetEnd().y ); + + frame->MsgPanel->Affiche_1_Parametre( 60, _( "Bounding box" ), msg, BROWN ); +} + + +LibDrawPolyline::LibDrawPolyline() : + LibEDA_BaseStruct( COMPONENT_POLYLINE_DRAW_TYPE ) +{ + m_Fill = NO_FILL; + m_Width = 0; + m_typeName = _( "PolyLine" ); +} + + +bool LibDrawPolyline::Save( FILE* ExportFile ) const +{ + int ccount = GetCornerCount(); + + fprintf( ExportFile, "P %d %d %d %d", ccount, m_Unit, m_Convert, m_Width ); + + for( unsigned i = 0; i < GetCornerCount(); i++ ) + { + fprintf( ExportFile, " %d %d", m_PolyPoints[i].x, m_PolyPoints[i].y ); + } + + fprintf( ExportFile, " %c\n", fill_tab[m_Fill] ); + + return true; +} + + +bool LibDrawPolyline::Load( char* line, wxString& errorMsg ) +{ + char* p; + int i, ccount = 0; + wxPoint pt; + + i = sscanf( &line[2], "%d %d %d %d", &ccount, &m_Unit, &m_Convert, + &m_Width ); + + if( i < 4 ) + { + errorMsg.Printf( wxT( "polyline only had %d parameters of the " \ + "required 4" ), i ); + return false; + } + if ( ccount <= 0 ) + { + errorMsg.Printf( wxT( "polyline count parameter %d is invalid" ), + ccount ); + return false; + } + + p = strtok( &line[2], " \t\n" ); + p = strtok( NULL, " \t\n" ); + p = strtok( NULL, " \t\n" ); + p = strtok( NULL, " \t\n" ); + + for( i = 0; i < ccount; i++ ) + { + wxPoint point; + p = strtok( NULL, " \t\n" ); + if( sscanf( p, "%d", &pt.x ) != 1 ) + { + errorMsg.Printf( wxT( "polyline point %d X position not defined" ), + i ); + return false; + } + p = strtok( NULL, " \t\n" ); + if( sscanf( p, "%d", &pt.y ) != 1 ) + { + errorMsg.Printf( wxT( "polyline point %d Y position not defined" ), + i ); + return false; + } + AddPoint(pt); + } + + m_Fill = NO_FILL; + + if( ( p = strtok( NULL, " \t\n" ) ) != NULL ) + { + if( p[0] == 'F' ) + m_Fill = FILLED_SHAPE; + if( p[0] == 'f' ) + m_Fill = FILLED_WITH_BG_BODYCOLOR; + } + + return true; } -/************************************************/ LibDrawPolyline* LibDrawPolyline::GenCopy() -/************************************************/ { LibDrawPolyline* newitem = new LibDrawPolyline(); @@ -538,24 +878,79 @@ LibDrawPolyline* LibDrawPolyline::GenCopy() } -/***************************************************/ void LibDrawPolyline::AddPoint( const wxPoint& point ) -/***************************************************/ - -/* add a point to the polyline coordinate list - */ { m_PolyPoints.push_back( point ); } +void LibDrawPolyline::Draw( WinEDA_DrawPanel* aPanel, wxDC* aDC, + const wxPoint& aOffset, int aColor, int aDrawMode, + void* aData, const int aTransformMatrix[2][2] ) +{ + wxPoint pos1; + + int color = ReturnLayerColor( LAYER_DEVICE ); + int linewidth = MAX( m_Width, g_DrawMinimunLineWidth ); + + // Buffer used to store current corners coordinates for drawings + static wxPoint* Buf_Poly_Drawings = NULL; + static unsigned Buf_Poly_Size = 0; + + if( aColor < 0 ) // Used normal color or selected color + { + if( m_Selected & IS_SELECTED ) + color = g_ItemSelectetColor; + } + else + color = aColor; + + // Set the size of the buffer od coordinates + if( Buf_Poly_Drawings == NULL ) + { + Buf_Poly_Size = m_PolyPoints.size(); + Buf_Poly_Drawings = + (wxPoint*) MyMalloc( sizeof(wxPoint) * Buf_Poly_Size ); + } + else if( Buf_Poly_Size < m_PolyPoints.size() ) + { + Buf_Poly_Size = m_PolyPoints.size(); + Buf_Poly_Drawings = + (wxPoint*) realloc( Buf_Poly_Drawings, + sizeof(wxPoint) * Buf_Poly_Size ); + } + + for( unsigned ii = 0; ii < m_PolyPoints.size(); ii++ ) + { + Buf_Poly_Drawings[ii] = + TransformCoordinate( aTransformMatrix, m_PolyPoints[ii] ) + aOffset; + } + + FILL_T fill = aData ? NO_FILL : m_Fill; + if( aColor >= 0 ) + fill = NO_FILL; + + if( fill == FILLED_WITH_BG_BODYCOLOR ) + GRPoly( &aPanel->m_ClipBox, aDC, m_PolyPoints.size(), + Buf_Poly_Drawings, 1, linewidth, color, + ReturnLayerColor( LAYER_DEVICE_BACKGROUND ) ); + else if( fill == FILLED_SHAPE ) + GRPoly( &aPanel->m_ClipBox, aDC, m_PolyPoints.size(), + Buf_Poly_Drawings, 1, linewidth, color, color ); + else + GRPoly( &aPanel->m_ClipBox, aDC, m_PolyPoints.size(), + Buf_Poly_Drawings, 0, linewidth, color, color ); +} + + /** Function HitTest * @return true if the point aPosRef is near a segment * @param aPosRef = a wxPoint to test * @param aThreshold = max distance to a segment * @param aTransMat = the transform matrix */ -bool LibDrawPolyline::HitTest( wxPoint aPosRef, int aThreshold, const int aTransMat[2][2] ) +bool LibDrawPolyline::HitTest( wxPoint aPosRef, int aThreshold, + const int aTransMat[2][2] ) { wxPoint ref, start, end; @@ -574,16 +969,17 @@ bool LibDrawPolyline::HitTest( wxPoint aPosRef, int aThreshold, const int aTrans } -/** Function GetBoundaryBox +/** Function GetBoundingBox * @return the boundary box for this, in library coordinates */ -EDA_Rect LibDrawPolyline::GetBoundaryBox() +EDA_Rect LibDrawPolyline::GetBoundingBox() { - EDA_Rect BoundaryBox; + EDA_Rect rect; int xmin, xmax, ymin, ymax; xmin = xmax = m_PolyPoints[0].x; ymin = ymax = m_PolyPoints[0].y; + for( unsigned ii = 1; ii < GetCornerCount(); ii++ ) { xmin = MIN( xmin, m_PolyPoints[ii].x ); @@ -592,9 +988,28 @@ EDA_Rect LibDrawPolyline::GetBoundaryBox() ymax = MAX( ymax, m_PolyPoints[ii].y ); } - BoundaryBox.SetX( xmin ); BoundaryBox.SetWidth( xmax - xmin ); - BoundaryBox.SetY( ymin ); BoundaryBox.SetHeight( ymax - ymin ); - BoundaryBox.Inflate(m_Width, m_Width); + rect.SetOrigin( xmin, ymin * -1 ); + rect.SetEnd( xmax, ymax * -1 ); + rect.Inflate( m_Width / 2, m_Width / 2 ); - return BoundaryBox; + return rect; +} + + +void LibDrawPolyline::DisplayInfo( WinEDA_DrawFrame* frame ) +{ + wxString msg; + EDA_Rect bBox = GetBoundingBox(); + + LibEDA_BaseStruct::DisplayInfo( frame ); + + msg = ReturnStringFromValue( g_UnitMetric, m_Width, + EESCHEMA_INTERNAL_UNIT, true ); + + frame->MsgPanel->Affiche_1_Parametre( 20, _( "Line width" ), msg, BLUE ); + + msg.Printf( wxT( "(%d, %d, %d, %d)" ), bBox.GetOrigin().x, + bBox.GetOrigin().y, bBox.GetEnd().x, bBox.GetEnd().y ); + + frame->MsgPanel->Affiche_1_Parametre( 40, _( "Bounding box" ), msg, BROWN ); } diff --git a/eeschema/classes_body_items.h b/eeschema/classes_body_items.h index b21f312c92..5180f0b033 100644 --- a/eeschema/classes_body_items.h +++ b/eeschema/classes_body_items.h @@ -2,22 +2,23 @@ /* Headers fo library definition and lib component definitions */ /****************************************************************/ -/* Definitions of graphic items used to create shapes of component in libraries (libentry) +/* Definitions of graphic items used to create shapes in component libraries. */ #ifndef CLASSES_BODY_ITEMS_H #define CLASSES_BODY_ITEMS_H -#define TARGET_PIN_DIAM 12 /* Circle diameter drawn at the active end of pins */ +#define TARGET_PIN_DIAM 12 /* Circle diameter drawn at the active end of + * pins */ -#define DEFAULT_TEXT_SIZE 50 /* Default size for field texts */ -#define PART_NAME_LEN 15 /* Maximum length of part name. */ -#define PREFIX_NAME_LEN 5 /* Maximum length of prefix (IC, R, SW etc.). */ -#define PIN_WIDTH 100 /* Width between 2 pins in internal units. */ -#define PIN_LENGTH 300 /* Default Length of each pin to be drawn. */ +#define DEFAULT_TEXT_SIZE 50 /* Default size for field texts */ +#define PART_NAME_LEN 15 /* Maximum length of part name. */ +#define PREFIX_NAME_LEN 5 /* Maximum length of prefix (IC, R, SW etc.). */ +#define PIN_WIDTH 100 /* Width between 2 pins in internal units. */ +#define PIN_LENGTH 300 /* Default Length of each pin to be drawn. */ -#define INVERT_PIN_RADIUS 35 /* Radius of inverted pin circle. */ -#define CLOCK_PIN_DIM 40 /* Dim of clock pin symbol. */ -#define IEEE_SYMBOL_PIN_DIM 40 /* Dim of special pin symbol. */ +#define INVERT_PIN_RADIUS 35 /* Radius of inverted pin circle. */ +#define CLOCK_PIN_DIM 40 /* Dim of clock pin symbol. */ +#define IEEE_SYMBOL_PIN_DIM 40 /* Dim of special pin symbol. */ /** @@ -25,12 +26,14 @@ * is the set of fill types used in plotting or drawing enclosed areas. */ enum FILL_T { - NO_FILL, // Poly, Square, Circle, Arc = option No Fill - FILLED_SHAPE, // Poly, Square, Circle, Arc = option Fill with current color ("Solid shape") - FILLED_WITH_BG_BODYCOLOR, /* Poly, Square, Circle, Arc = option Fill with background body color, - * translucent (texts inside this shape can be seen) - * not filled in B&W mode when plotting or printing - */ + NO_FILL, // Poly, Square, Circle, Arc = option No Fill + FILLED_SHAPE, /* Poly, Square, Circle, Arc = option Fill + * with current color ("Solid shape") */ + FILLED_WITH_BG_BODYCOLOR, /* Poly, Square, Circle, Arc = option Fill + * with background body color, translucent + * (texts inside this shape can be seen) + * not filled in B&W mode when plotting or + * printing */ }; @@ -38,7 +41,7 @@ enum FILL_T { * Enum ElectricPinType * is the set of schematic pin types, used in ERC tests. */ -enum ElectricPinType { /* Type des Pins. si modif: modifier tableau des mgs suivant */ +enum ElectricPinType { PIN_INPUT, PIN_OUTPUT, PIN_BIDI, @@ -54,25 +57,7 @@ enum ElectricPinType { /* Type des Pins. si modif: modifier tableau des mgs }; /* Messages d'affichage du type electrique */ -eda_global const wxChar* MsgPinElectricType[] -#ifdef MAIN - = { - wxT( "input" ), - wxT( "output" ), - wxT( "BiDi" ), - wxT( "3state" ), - wxT( "passive" ), - wxT( "unspc" ), - wxT( "power_in" ), - wxT( "power_out" ), - wxT( "openCol" ), - wxT( "openEm" ), - wxT( "?????" ) - } - - -#endif -; +extern const wxChar* MsgPinElectricType[]; /* Autres bits: bits du membre .Flag des Pins */ #define PINNOTDRAW 1 /* si 1: pin invisible */ @@ -128,11 +113,13 @@ public: class LibEDA_BaseStruct : public EDA_BaseStruct { public: - int m_Unit; /* Unit identification (for multi part per parkage) - * 0 if the item is common to all units */ - int m_Convert; /* Shape identification (for parts which have a convert shape) - * 0 if the item is common to all shapes */ - FILL_T m_Fill; /* NO_FILL, FILLED_SHAPE or FILLED_WITH_BG_BODYCOLOR. has meaning only for some items */ + int m_Unit; /* Unit identification (for multi part per parkage) + * 0 if the item is common to all units */ + int m_Convert; /* Shape identification (for parts which have a convert + * shape) 0 if the item is common to all shapes */ + FILL_T m_Fill; /* NO_FILL, FILLED_SHAPE or FILLED_WITH_BG_BODYCOLOR. + * has meaning only for some items */ + wxString m_typeName; /* Name of object displayed in the message panel. */ public: LibEDA_BaseStruct* Next() @@ -146,29 +133,40 @@ public: /** Function Draw (virtual pure) * Draw A body item - * @param aPanel = DrawPanel to use (can be null) mainly used for clipping purposes + * @param aPanel = DrawPanel to use (can be null) mainly used for clipping + * purposes * @param aDC = Device Context (can be null) * @param aOffset = offset to draw - * @param aColor = -1 to use the normal body item color, or use this color if >= 0 + * @param aColor = -1 to use the normal body item color, or use this color + * if >= 0 * @param aDrawMode = GR_OR, GR_XOR, ... - * @param aData = value or pointer used to pass others parametres, depending on body items. - * used for some items to force to force no fill mode - * ( has meaning only for items what can be filled ). used in printing or moving objects mode - * or to pass refernce to the lib component for pins + * @param aData = value or pointer used to pass others parametres, + * depending on body items. used for some items to force + * to force no fill mode ( has meaning only for items what + * can be filled ). used in printing or moving objects mode + * or to pass refernce to the lib component for pins * @param aTransformMatrix = Transform Matrix (rotaion, mirror ..) */ - virtual void Draw( WinEDA_DrawPanel * aPanel, wxDC * aDC, const wxPoint &aOffset, int aColor, - int aDrawMode, void* aData, const int aTransformMatrix[2][2] ) = 0; + virtual void Draw( WinEDA_DrawPanel * aPanel, wxDC * aDC, + const wxPoint &aOffset, int aColor, int aDrawMode, + void* aData, const int aTransformMatrix[2][2] ) = 0; /** * Function Save - * writes the data structures for this object out to a FILE in "*.brd" format. + * writes the data structures for this object out to a FILE in "*.brd" + * format. * @param aFile The FILE to write to. * @return bool - true if success writing else false. */ virtual bool Save( FILE* aFile ) const = 0; + virtual bool Load( char* line, wxString& errorMsg ) = 0; - void Display_Infos_DrawEntry( WinEDA_DrawFrame* frame ); + virtual EDA_Rect GetBoundingBox() + { + return EDA_BaseStruct::GetBoundingBox(); + } + + virtual void DisplayInfo( WinEDA_DrawFrame* frame ); }; @@ -183,14 +181,17 @@ public: int m_PinShape; /* Bitwise ORed: Pin shape (see enum DrawPinShape) */ int m_PinType; /* Electrical pin properties */ int m_Attributs; /* bit 0 != 0: pin invisible */ - long m_PinNum; /* Pin number: 4 Ascii code like "12" or "anod" or "G6" - * "12" is stored as "12\0\0" ans does not depend on endian type*/ + long m_PinNum; /* Pin number: 4 Ascii code like "12" or "anod" + * or "G6" "12" is stored as "12\0\0" ans does not + * depend on endian type*/ wxString m_PinName; - int m_PinNumSize, m_PinNameSize; /* Pin num and Pin name sizes */ + int m_PinNumSize; + int m_PinNameSize; /* Pin num and Pin name sizes */ // int m_PinNumWidth, m_PinNameWidth; /* (Currently Unused) Pin num and Pin name text width */ - wxPoint m_Pos; /* Position or centre (Arc and Circle) or start point (segments) */ - int m_Width; /* Tickness */ + wxPoint m_Pos; /* Position or centre (Arc and Circle) or start + * point (segments) */ + int m_Width; /* Line width */ public: LibDrawPin(); @@ -207,32 +208,36 @@ public: /** * Function Save - * writes the data structures for this object out to a FILE in "*.brd" format. + * writes the data structures for this object out to a FILE in "*.brd" + * format. * @param aFile The FILE to write to. * @return bool - true if success writing else false. */ virtual bool Save( FILE* aFile ) const; + virtual bool Load( char* line, wxString& errorMsg ); LibDrawPin* GenCopy(); - void Display_Infos( WinEDA_DrawFrame* frame ); + virtual void DisplayInfo( WinEDA_DrawFrame* frame ); + virtual EDA_Rect GetBoundingBox(); wxPoint ReturnPinEndPoint(); int ReturnPinDrawOrient( const int TransMat[2][2] ); void ReturnPinStringNum( wxString& buffer ) const; void SetPinNumFromString( wxString& buffer ); - void Draw( WinEDA_DrawPanel * aPanel, wxDC * aDC, const wxPoint &aOffset, int aColor, - int aDrawMode, void* aData, const int aTransformMatrix[2][2] ); + void Draw( WinEDA_DrawPanel * aPanel, wxDC * aDC, const wxPoint &aOffset, + int aColor, int aDrawMode, void* aData, + const int aTransformMatrix[2][2] ); - void DrawPinSymbol( WinEDA_DrawPanel* panel, wxDC* DC, const wxPoint& pin_pos, - int orient, + void DrawPinSymbol( WinEDA_DrawPanel* panel, wxDC* DC, + const wxPoint& pin_pos, int orient, int DrawMode, int Color = -1 ); void DrawPinTexts( WinEDA_DrawPanel* panel, wxDC* DC, wxPoint& pin_pos, int orient, - int TextInside, bool DrawPinNum, bool DrawPinName, - int Color, int DrawMode ); + int TextInside, bool DrawPinNum, + bool DrawPinName, int Color, int DrawMode ); void PlotPinTexts( wxPoint& pin_pos, int orient, int TextInside, @@ -247,14 +252,16 @@ public: /* Graphic Body Item: Arc */ /**************************/ -class LibDrawArc : public LibEDA_BaseStruct +class LibDrawArc : public LibEDA_BaseStruct { public: int m_Rayon; - int t1, t2; /* position des 2 extremites de l'arc en 0.1 degres */ - wxPoint m_ArcStart, m_ArcEnd; /* position des 2 extremites de l'arc en coord reelles*/ - wxPoint m_Pos; /* Position or centre (Arc and Circle) or start point (segments) */ - int m_Width; /* Tickness */ + int t1, t2; /* position des 2 extremites de l'arc en 0.1 degres */ + wxPoint m_ArcStart; + wxPoint m_ArcEnd; /* position des 2 extremites de l'arc en coord reelles*/ + wxPoint m_Pos; /* Position or centre (Arc and Circle) or start point + * (segments) */ + int m_Width; /* Line width */ public: LibDrawArc(); @@ -267,28 +274,35 @@ public: /** * Function Save - * writes the data structures for this object out to a FILE in "*.brd" format. + * writes the data structures for this object out to a FILE in "*.brd" + * format. * @param aFile The FILE to write to. * @return bool - true if success writing else false. */ virtual bool Save( FILE* aFile ) const; - + virtual bool Load( char* line, wxString& errorMsg ); LibDrawArc* GenCopy(); - void Draw( WinEDA_DrawPanel * aPanel, wxDC * aDC, const wxPoint &aOffset, int aColor, - int aDrawMode, void* aData, const int aTransformMatrix[2][2] ); + void Draw( WinEDA_DrawPanel * aPanel, wxDC * aDC, const wxPoint &aOffset, + int aColor, int aDrawMode, void* aData, + const int aTransformMatrix[2][2] ); + + virtual EDA_Rect GetBoundingBox(); + virtual void DisplayInfo( WinEDA_DrawFrame* frame ); }; + /*****************************/ /* Graphic Body Item: Circle */ /*****************************/ -class LibDrawCircle : public LibEDA_BaseStruct +class LibDrawCircle : public LibEDA_BaseStruct { public: int m_Rayon; - wxPoint m_Pos; /* Position or centre (Arc and Circle) or start point (segments) */ - int m_Width; /* Tickness */ + wxPoint m_Pos; /* Position or centre (Arc and Circle) or start + * point (segments) */ + int m_Width; /* Line width */ public: LibDrawCircle(); @@ -301,17 +315,22 @@ public: /** * Function Save - * writes the data structures for this object out to a FILE in "*.brd" format. + * writes the data structures for this object out to a FILE in "*.brd" + * format. * @param aFile The FILE to write to. * @return bool - true if success writing else false. */ - virtual bool Save( FILE* aFile ) const; - + virtual bool Save( FILE* aFile ) const; + virtual bool Load( char* line, wxString& errorMsg ); LibDrawCircle* GenCopy(); - void Draw( WinEDA_DrawPanel * aPanel, wxDC * aDC, const wxPoint &aOffset, int aColor, - int aDrawMode, void* aData, const int aTransformMatrix[2][2] ); + void Draw( WinEDA_DrawPanel * aPanel, wxDC * aDC, const wxPoint &aOffset, + int aColor, int aDrawMode, void* aData, + const int aTransformMatrix[2][2] ); + + virtual EDA_Rect GetBoundingBox(); + virtual void DisplayInfo( WinEDA_DrawFrame* frame ); }; @@ -321,8 +340,7 @@ public: /* Fields like Ref , value... are not Text, */ /* they are a separate class */ /*********************************************/ -class LibDrawText : public LibEDA_BaseStruct, - public EDA_TextStruct +class LibDrawText : public LibEDA_BaseStruct, public EDA_TextStruct { public: LibDrawText(); @@ -335,17 +353,21 @@ public: /** * Function Save - * writes the data structures for this object out to a FILE in "*.brd" format. + * writes the data structures for this object out to a FILE in "*.brd" + * format. * @param aFile The FILE to write to. * @return bool - true if success writing else false. */ virtual bool Save( FILE* aFile ) const; - + virtual bool Load( char* line, wxString& errorMsg ); LibDrawText* GenCopy(); - void Draw( WinEDA_DrawPanel * aPanel, wxDC * aDC, const wxPoint &aOffset, int aColor, - int aDrawMode, void* aData, const int aTransformMatrix[2][2] ); + void Draw( WinEDA_DrawPanel * aPanel, wxDC * aDC, const wxPoint &aOffset, + int aColor, int aDrawMode, void* aData, + const int aTransformMatrix[2][2] ); + + virtual void DisplayInfo( WinEDA_DrawFrame* frame ); }; @@ -355,9 +377,9 @@ public: class LibDrawSquare : public LibEDA_BaseStruct { public: - wxPoint m_End; - wxPoint m_Pos; /* Position or centre (Arc and Circle) or start point (segments) */ - int m_Width; /* Tickness */ + wxPoint m_End; /* Rectangle end point. */ + wxPoint m_Pos; /* Rectangle start point. */ + int m_Width; /* Line width */ public: LibDrawSquare(); @@ -370,17 +392,22 @@ public: /** * Function Save - * writes the data structures for this object out to a FILE in "*.brd" format. + * writes the data structures for this object out to a FILE in "*.brd" + * format. * @param aFile The FILE to write to. * @return bool - true if success writing else false. */ - virtual bool Save( FILE* aFile ) const; - + virtual bool Save( FILE* aFile ) const; + virtual bool Load( char* line, wxString& errorMsg ); LibDrawSquare* GenCopy(); - void Draw( WinEDA_DrawPanel * aPanel, wxDC * aDC, const wxPoint &aOffset, int aColor, - int aDrawMode, void* aData, const int aTransformMatrix[2][2] ); + void Draw( WinEDA_DrawPanel * aPanel, wxDC * aDC, const wxPoint &aOffset, + int aColor, int aDrawMode, void* aData, + const int aTransformMatrix[2][2] ); + + virtual EDA_Rect GetBoundingBox(); + virtual void DisplayInfo( WinEDA_DrawFrame* frame ); }; /**********************************/ @@ -390,8 +417,9 @@ class LibDrawSegment : public LibEDA_BaseStruct { public: wxPoint m_End; - wxPoint m_Pos; /* Position or centre (Arc and Circle) or start point (segments) */ - int m_Width; /* Tickness */ + wxPoint m_Pos; /* Position or centre (Arc and Circle) or start point + * (segments) */ + int m_Width; /* Line width */ public: LibDrawSegment(); @@ -404,26 +432,31 @@ public: /** * Function Save - * writes the data structures for this object out to a FILE in "*.brd" format. + * writes the data structures for this object out to a FILE in "*.brd" + * format. * @param aFile The FILE to write to. * @return bool - true if success writing else false. */ - virtual bool Save( FILE* aFile ) const; - + virtual bool Save( FILE* aFile ) const; + virtual bool Load( char* line, wxString& errorMsg ); LibDrawSegment* GenCopy(); - void Draw( WinEDA_DrawPanel * aPanel, wxDC * aDC, const wxPoint &aOffset, int aColor, - int aDrawMode, void* aData, const int aTransformMatrix[2][2] ); + void Draw( WinEDA_DrawPanel * aPanel, wxDC * aDC, const wxPoint &aOffset, + int aColor, int aDrawMode, void* aData, + const int aTransformMatrix[2][2] ); + + virtual void DisplayInfo( WinEDA_DrawFrame* frame ); }; + /**********************************************************/ /* Graphic Body Item: Polygon and polyline (set of lines) */ /**********************************************************/ class LibDrawPolyline : public LibEDA_BaseStruct { public: - int m_Width; /* Tickness */ + int m_Width; /* Line width */ std::vector m_PolyPoints; // list of points (>= 2) public: @@ -438,11 +471,13 @@ public: /** * Function Save - * writes the data structures for this object out to a FILE in "*.brd" format. + * writes the data structures for this object out to a FILE in "*.brd" + * format. * @param aFile The FILE to write to. * @return bool - true if success writing else false. */ - virtual bool Save( FILE* aFile ) const; + virtual bool Save( FILE* aFile ) const; + virtual bool Load( char* line, wxString& errorMsg ); LibDrawPolyline* GenCopy(); void AddPoint( const wxPoint& point ); @@ -460,13 +495,16 @@ public: */ bool HitTest( wxPoint aPosRef, int aThreshold, const int aTransMat[2][2] ); - /** Function GetBoundaryBox + /** Function GetBoundingBox * @return the boundary box for this, in library coordinates */ - EDA_Rect GetBoundaryBox(); + virtual EDA_Rect GetBoundingBox(); - void Draw( WinEDA_DrawPanel * aPanel, wxDC * aDC, const wxPoint &aOffset, int aColor, - int aDrawMode, void* aData, const int aTransformMatrix[2][2] ); + void Draw( WinEDA_DrawPanel * aPanel, wxDC * aDC, const wxPoint &aOffset, + int aColor, int aDrawMode, void* aData, + const int aTransformMatrix[2][2] ); + + virtual void DisplayInfo( WinEDA_DrawFrame* frame ); }; #endif // CLASSES_BODY_ITEMS_H diff --git a/eeschema/cleanup.cpp b/eeschema/cleanup.cpp index 1100170e1d..81c1dc971b 100644 --- a/eeschema/cleanup.cpp +++ b/eeschema/cleanup.cpp @@ -6,6 +6,7 @@ #include "appl_wxstruct.h" #include "common.h" #include "confirm.h" +#include "class_drawpickedstruct.h" #include "program.h" #include "libcmp.h" #include "general.h" diff --git a/eeschema/component_class.cpp b/eeschema/component_class.cpp index fa84339449..64b5478668 100644 --- a/eeschema/component_class.cpp +++ b/eeschema/component_class.cpp @@ -3,6 +3,7 @@ /***********************************************************************/ #include "fctsys.h" +#include "class_drawpanel.h" #include "gr_basic.h" #include "common.h" #include "confirm.h" @@ -16,13 +17,141 @@ #include #include +#include "component_class.h" + + WX_DEFINE_OBJARRAY( ArrayOfSheetLists ); +/* Local variables */ +static EDA_LibComponentStruct* DummyCmp; + +/* Descr component used when a component is not found in library, + * to draw a dummy shape + * This component is a 400 mils square with the text ?? + * DEF DUMMY U 0 40 Y Y 1 0 N + * F0 "U" 0 -350 60 H V + * F1 "DUMMY" 0 350 60 H V + * DRAW + * T 0 0 0 150 0 0 0 ?? + * S -200 200 200 -200 0 1 0 + * ENDDRAW + * ENDDEF + */ +void CreateDummyCmp() +{ + DummyCmp = new EDA_LibComponentStruct( NULL ); + + LibDrawSquare* Square = new LibDrawSquare(); + + Square->m_Pos = wxPoint( -200, 200 ); + Square->m_End = wxPoint( 200, -200 ); + Square->m_Width = 4; + + LibDrawText* Text = new LibDrawText(); + + Text->m_Size.x = Text->m_Size.y = 150; + Text->m_Text = wxT( "??" ); + + DummyCmp->m_Drawings = Square; + Square->SetNext( Text ); +} + + +/***************************************************************************** +* Routine to draw the given part at given position, transformed/mirror as +* specified, and in the given drawing mode. +* if Color < 0: Draw in normal color +* else draw in color = Color +*****************************************************************************/ +/* DrawMode = GrXOR, GrOR ..*/ +void DrawLibPartAux( WinEDA_DrawPanel* panel, wxDC* DC, + SCH_COMPONENT* Component, + EDA_LibComponentStruct* Entry, + const wxPoint& Pos, const int TransMat[2][2], + int Multi, int convert, int DrawMode, + int Color, bool DrawPinText ) +{ + wxPoint pos1, pos2; + bool force_nofill; + LibEDA_BaseStruct* DEntry; + BASE_SCREEN* screen = panel->GetScreen(); + + if( Entry->m_Drawings == NULL ) + return; + GRSetDrawMode( DC, DrawMode ); + + for( DEntry = Entry->m_Drawings; DEntry != NULL; DEntry = DEntry->Next() ) + { + /* Do not draw items not attached to the current part */ + if( Multi && DEntry->m_Unit && (DEntry->m_Unit != Multi) ) + continue; + + if( convert && DEntry->m_Convert && (DEntry->m_Convert != convert) ) + continue; + + // Do not draw an item while moving (the cursor handler does that) + if( DEntry->m_Flags & IS_MOVED ) + continue; + + force_nofill = false; + + switch( DEntry->Type() ) + { + case COMPONENT_PIN_DRAW_TYPE: + { + DrawPinPrms prms( Entry, DrawPinText ); + DEntry->Draw( panel, DC, Pos, Color, DrawMode, &prms, TransMat ); + } + break; + + case COMPONENT_ARC_DRAW_TYPE: + case COMPONENT_CIRCLE_DRAW_TYPE: + case COMPONENT_GRAPHIC_TEXT_DRAW_TYPE: + case COMPONENT_RECT_DRAW_TYPE: + case COMPONENT_POLYLINE_DRAW_TYPE: + default: + if( screen->m_IsPrinting + && DEntry->m_Fill == FILLED_WITH_BG_BODYCOLOR + && GetGRForceBlackPenState() ) + force_nofill = true; + DEntry->Draw( panel, DC, Pos, Color, DrawMode, (void*) force_nofill, + TransMat ); + break; + } + } + + if( g_DebugLevel > 4 ) /* Draw the component boundary box */ + { + EDA_Rect BoundaryBox; + if( Component ) + BoundaryBox = Component->GetBoundaryBox(); + else + BoundaryBox = Entry->GetBoundaryBox( Multi, convert ); + int x1 = BoundaryBox.GetX(); + int y1 = BoundaryBox.GetY(); + int x2 = BoundaryBox.GetRight(); + int y2 = BoundaryBox.GetBottom(); + GRRect( &panel->m_ClipBox, DC, x1, y1, x2, y2, BROWN ); + BoundaryBox = Component->GetField( REFERENCE )->GetBoundaryBox(); + x1 = BoundaryBox.GetX(); + y1 = BoundaryBox.GetY(); + x2 = BoundaryBox.GetRight(); + y2 = BoundaryBox.GetBottom(); + GRRect( &panel->m_ClipBox, DC, x1, y1, x2, y2, BROWN ); + BoundaryBox = Component->GetField( VALUE )->GetBoundaryBox(); + x1 = BoundaryBox.GetX(); + y1 = BoundaryBox.GetY(); + x2 = BoundaryBox.GetRight(); + y2 = BoundaryBox.GetBottom(); + GRRect( &panel->m_ClipBox, DC, x1, y1, x2, y2, BROWN ); + } +} + + /*******************************************************************/ SCH_COMPONENT::SCH_COMPONENT( const wxPoint& aPos, SCH_ITEM* aParent ) : SCH_ITEM( aParent, TYPE_SCH_COMPONENT ) -/*******************************************************************/ { m_Multi = 0; /* In multi unit chip - which unit to draw. */ @@ -38,7 +167,7 @@ SCH_COMPONENT::SCH_COMPONENT( const wxPoint& aPos, SCH_ITEM* aParent ) : m_Fields.reserve( NUMBER_OF_FIELDS ); - for( int i = 0; iSetParent( this ); } } +/***************************************************************************** +* Routine to draw the given part at given position, transformed/mirror as * +* specified, and in the given drawing mode. Only this one is visible... * +*****************************************************************************/ +void SCH_COMPONENT::Draw( WinEDA_DrawPanel* panel, wxDC* DC, + const wxPoint& offset, int DrawMode, int Color ) +{ + EDA_LibComponentStruct* Entry; + int ii; + bool dummy = FALSE; + + if( ( Entry = FindLibPart( m_ChipName.GetData(), wxEmptyString, + FIND_ROOT ) ) == NULL ) + { + /* composant non trouve, on affiche un composant "dummy" */ + dummy = TRUE; + if( DummyCmp == NULL ) + CreateDummyCmp(); + Entry = DummyCmp; + } + + DrawLibPartAux( panel, DC, this, Entry, m_Pos + offset, m_Transform, + dummy ? 0 : m_Multi, dummy ? 0 : m_Convert, DrawMode ); + + /* Trace des champs, avec placement et orientation selon orient. du + * composant + */ + + SCH_CMP_FIELD* field = GetField( REFERENCE ); + + if( ( ( field->m_Attributs & TEXT_NO_VISIBLE ) == 0 ) + && !( field->m_Flags & IS_MOVED ) ) + { + if( Entry->m_UnitCount > 1 ) + { + field->m_AddExtraText = true; + field->Draw( panel, DC, offset, DrawMode ); + } + else + { + field->m_AddExtraText = false; + field->Draw( panel, DC, offset, DrawMode ); + } + } + + for( ii = VALUE; ii < GetFieldCount(); ii++ ) + { + field = GetField( ii ); + + if( field->m_Flags & IS_MOVED ) + continue; + + field->Draw( panel, DC, offset, DrawMode ); + } +} + + /** * Function AddHierarchicalReference * adds a full hierachical reference (path + local reference) - * @param aPath = hierarchical path (//component timestamp> like /05678E50/A23EF560) + * @param aPath = hierarchical path (//component timestamp> + * like /05678E50/A23EF560) * @param aRef = local reference like C45, R56 - * @param aMulti = part selection, used in multi part per package (0 or 1 for non multi) + * @param aMulti = part selection, used in multi part per package (0 or 1 for + * non multi) */ void SCH_COMPONENT::AddHierarchicalReference( const wxString& aPath, const wxString& aRef, @@ -92,10 +282,11 @@ void SCH_COMPONENT::AddHierarchicalReference( const wxString& aPath, wxString separators( wxT( " " ) ); // Search for an existing path and remove it if found (should not occur) - for( unsigned ii = 0; iim_Text.IsEmpty() - || ( abs( rf->m_Pos.x - m_Pos.x ) + - abs( rf->m_Pos.y - m_Pos.y ) > 10000) ) + || ( abs( rf->m_Pos.x - m_Pos.x ) + + abs( rf->m_Pos.y - m_Pos.y ) > 10000 ) ) { // move it to a reasonable position rf->m_Pos = m_Pos; @@ -225,20 +417,20 @@ void SCH_COMPONENT::SetRef( DrawSheetPath* sheet, const wxString& ref ) /***********************************************************/ -int SCH_COMPONENT::GetUnitSelection( DrawSheetPath* aSheet ) -/***********************************************************/ - //returns the unit selection, for the given sheet path. +/***********************************************************/ +int SCH_COMPONENT::GetUnitSelection( DrawSheetPath* aSheet ) { wxString path = GetPath( aSheet ); wxString h_path, h_multi; wxStringTokenizer tokenizer; wxString separators( wxT( " " ) ); - for( unsigned ii = 0; iiGetBoundaryBox( m_Multi, m_Convert ); - x0 = BoundaryBox.GetX(); xm = BoundaryBox.GetRight(); + x0 = BoundaryBox.GetX(); + xm = BoundaryBox.GetRight(); // We must reverse Y values, because matrix orientation // suppose Y axis normal for the library items coordinates, @@ -346,11 +534,8 @@ EDA_Rect SCH_COMPONENT::GetBoundaryBox() const /* Compute the real Boundary box (rotated, mirrored ...)*/ int x1 = m_Transform[0][0] * x0 + m_Transform[0][1] * y0; - int y1 = m_Transform[1][0] * x0 + m_Transform[1][1] * y0; - int x2 = m_Transform[0][0] * xm + m_Transform[0][1] * ym; - int y2 = m_Transform[1][0] * xm + m_Transform[1][1] * ym; // H and W must be > 0: @@ -359,7 +544,8 @@ EDA_Rect SCH_COMPONENT::GetBoundaryBox() const if( y2 < y1 ) EXCHG( y2, y1 ); - BoundaryBox.SetX( x1 ); BoundaryBox.SetY( y1 ); + BoundaryBox.SetX( x1 ); + BoundaryBox.SetY( y1 ); BoundaryBox.SetWidth( x2 - x1 ); BoundaryBox.SetHeight( y2 - y1 ); @@ -369,12 +555,11 @@ EDA_Rect SCH_COMPONENT::GetBoundaryBox() const /**************************************************************************/ -void SCH_COMPONENT::SwapData( SCH_COMPONENT* copyitem ) -/**************************************************************************/ - /* Used if undo / redo command: * swap data between this and copyitem */ +/**************************************************************************/ +void SCH_COMPONENT::SwapData( SCH_COMPONENT* copyitem ) { EXCHG( m_ChipName, copyitem->m_ChipName ); EXCHG( m_Pos, copyitem->m_Pos ); @@ -407,8 +592,8 @@ void SCH_COMPONENT::Place( WinEDA_SchematicFrame* frame, wxDC* DC ) { /* save old text in undo list */ if( g_ItemToUndoCopy - && ( g_ItemToUndoCopy->Type() == Type() ) - && ( (m_Flags & IS_NEW) == 0 ) ) + && ( g_ItemToUndoCopy->Type() == Type() ) + && ( ( m_Flags & IS_NEW ) == 0 ) ) { /* restore old values and save new ones */ SwapData( (SCH_COMPONENT*) g_ItemToUndoCopy ); @@ -426,15 +611,12 @@ void SCH_COMPONENT::Place( WinEDA_SchematicFrame* frame, wxDC* DC ) } -/**********************************************************/ -void SCH_COMPONENT::ClearAnnotation( DrawSheetPath* aSheet ) -/**********************************************************/ - /** * Suppress annotation ( i.i IC23 changed to IC? and part reset to 1) * @param aSheet: DrawSheetPath value: if NULL remove all annotations, - * else remove annotation relative to this sheetpath + * else remove annotation relative to this sheetpath */ +void SCH_COMPONENT::ClearAnnotation( DrawSheetPath* aSheet ) { wxString defRef = m_PrefixString; bool KeepMulti = false; @@ -454,16 +636,18 @@ void SCH_COMPONENT::ClearAnnotation( DrawSheetPath* aSheet ) wxString multi = wxT( "1" ); - if( KeepMulti ) // We cannot remove all annotations: part selection must be kept + // We cannot remove all annotations: part selection must be kept + if( KeepMulti ) { wxString NewHref; wxString path; if( aSheet ) - path = GetPath( aSheet );; - for( unsigned int ii = 0; ii< m_PathsAndReferences.GetCount(); ii++ ) + path = GetPath( aSheet ); + for( unsigned int ii = 0; ii < m_PathsAndReferences.GetCount(); ii++ ) { // Break hierachical reference in path, ref and multi selection: - reference_fields = wxStringTokenize( m_PathsAndReferences[ii], separators ); + reference_fields = wxStringTokenize( m_PathsAndReferences[ii], + separators ); if( aSheet == NULL || reference_fields[0].Cmp( path ) == 0 ) { if( KeepMulti ) // Get and keep part selection @@ -476,7 +660,9 @@ void SCH_COMPONENT::ClearAnnotation( DrawSheetPath* aSheet ) } else { - m_PathsAndReferences.Empty(); // Empty strings, but does not free memory because a new annotation will reuse it + // Empty strings, but does not free memory because a new annotation + // will reuse it + m_PathsAndReferences.Empty(); m_Multi = 1; } @@ -489,14 +675,13 @@ void SCH_COMPONENT::ClearAnnotation( DrawSheetPath* aSheet ) } -/*****************************************************************/ -void SCH_COMPONENT::SetRotationMiroir( int type_rotate ) /******************************************************************/ - /* Compute the new matrix transform for a schematic component * in order to have the requested transform (type_rotate = rot, mirror..) * which is applied to the initial transform. */ +/*****************************************************************/ +void SCH_COMPONENT::SetRotationMiroir( int type_rotate ) { int TempMat[2][2]; bool Transform = FALSE; @@ -603,12 +788,13 @@ void SCH_COMPONENT::SetRotationMiroir( int type_rotate ) if( Transform ) { /* The new matrix transform is the old matrix transform modified by the - * requested transformation, which is the TempMat transform (rot, mirror ..) - * in order to have (in term of matrix transform): + * requested transformation, which is the TempMat transform (rot, + * mirror ..) in order to have (in term of matrix transform): * transform coord = new_m_Transform * coord - * where transform coord is the coord modified by new_m_Transform from the initial - * value coord. - * new_m_Transform is computed (from old_m_Transform and TempMat) to have: + * where transform coord is the coord modified by new_m_Transform from + * the initial value coord. + * new_m_Transform is computed (from old_m_Transform and TempMat) to + * have: * transform coord = old_m_Transform * coord * TempMat */ int NewMatrix[2][2]; @@ -633,18 +819,16 @@ void SCH_COMPONENT::SetRotationMiroir( int type_rotate ) } -/****************************************************/ int SCH_COMPONENT::GetRotationMiroir() -/****************************************************/ { int type_rotate = CMP_ORIENT_0; int TempMat[2][2], MatNormal[2][2]; int ii; bool found = FALSE; - memcpy( TempMat, m_Transform, sizeof(TempMat) ); + memcpy( TempMat, m_Transform, sizeof( TempMat ) ); SetRotationMiroir( CMP_ORIENT_0 ); - memcpy( MatNormal, m_Transform, sizeof(MatNormal) ); + memcpy( MatNormal, m_Transform, sizeof( MatNormal ) ); for( ii = 0; ii < 4; ii++ ) { @@ -663,7 +847,7 @@ int SCH_COMPONENT::GetRotationMiroir() SetRotationMiroir( CMP_MIROIR_X ); for( ii = 0; ii < 4; ii++ ) { - if( memcmp( TempMat, m_Transform, sizeof(MatNormal) ) == 0 ) + if( memcmp( TempMat, m_Transform, sizeof( MatNormal ) ) == 0 ) { found = TRUE; break; @@ -679,7 +863,7 @@ int SCH_COMPONENT::GetRotationMiroir() SetRotationMiroir( CMP_MIROIR_Y ); for( ii = 0; ii < 4; ii++ ) { - if( memcmp( TempMat, m_Transform, sizeof(MatNormal) ) == 0 ) + if( memcmp( TempMat, m_Transform, sizeof( MatNormal ) ) == 0 ) { found = TRUE; break; @@ -688,7 +872,7 @@ int SCH_COMPONENT::GetRotationMiroir() } } - memcpy( m_Transform, TempMat, sizeof(m_Transform) ); + memcpy( m_Transform, TempMat, sizeof( m_Transform ) ); if( found ) { @@ -702,14 +886,12 @@ int SCH_COMPONENT::GetRotationMiroir() } -/***********************************************************************/ -wxPoint SCH_COMPONENT::GetScreenCoord( const wxPoint& coord ) -/***********************************************************************/ - -/* Renvoie la coordonn�e du point coord, en fonction de l'orientation +/** + * Renvoie la coordonn�e du point coord, en fonction de l'orientation * du composant (rotation, miroir). * Les coord sont toujours relatives a l'ancre (coord 0,0) du composant */ +wxPoint SCH_COMPONENT::GetScreenCoord( const wxPoint& coord ) { wxPoint screenpos; @@ -732,37 +914,32 @@ void SCH_COMPONENT::Show( int nestLevel, std::ostream& os ) { // for now, make it look like XML: NestedSpace( nestLevel, os ) << '<' << GetClass().Lower().mb_str() << - " ref=\"" << ReturnFieldName( 0 ) << '"' << - " chipName=\"" << m_ChipName.mb_str() << '"' << - m_Pos << - " layer=\"" << m_Layer << '"' << - "/>\n"; + " ref=\"" << ReturnFieldName( 0 ) << '"' << " chipName=\"" << + m_ChipName.mb_str() << '"' << m_Pos << " layer=\"" << m_Layer << + '"' << "/>\n"; // skip the reference, it's been output already. - for( int i = 1; im_Text; if( !value.IsEmpty() ) { - NestedSpace( nestLevel + 1, os ) << "\n"; + NestedSpace( nestLevel + 1, os ) << "\n"; } } NestedSpace( nestLevel, os ) << "\n"; } - #endif -/****************************************/ bool SCH_COMPONENT::Save( FILE* f ) const -/****************************************/ { - int ii, Success = true; + int ii; char Name1[256], Name2[256]; wxArrayString reference_fields; @@ -772,15 +949,17 @@ bool SCH_COMPONENT::Save( FILE* f ) const //files backwards-compatible. if( m_PathsAndReferences.GetCount() > 0 ) { - reference_fields = wxStringTokenize( m_PathsAndReferences[0], delimiters ); - strncpy( Name1, CONV_TO_UTF8( reference_fields[1] ), sizeof(Name1) ); + reference_fields = wxStringTokenize( m_PathsAndReferences[0], + delimiters ); + strncpy( Name1, CONV_TO_UTF8( reference_fields[1] ), sizeof( Name1 ) ); } else { if( GetField( REFERENCE )->m_Text.IsEmpty() ) - strncpy( Name1, CONV_TO_UTF8( m_PrefixString ), sizeof(Name1) ); + strncpy( Name1, CONV_TO_UTF8( m_PrefixString ), sizeof( Name1 ) ); else - strncpy( Name1, CONV_TO_UTF8( GetField( REFERENCE )->m_Text ), sizeof(Name1) ); + strncpy( Name1, CONV_TO_UTF8( GetField( REFERENCE )->m_Text ), + sizeof( Name1 ) ); } for( ii = 0; ii < (int) strlen( Name1 ); ii++ ) { @@ -790,35 +969,28 @@ bool SCH_COMPONENT::Save( FILE* f ) const if( !m_ChipName.IsEmpty() ) { - strncpy( Name2, CONV_TO_UTF8( m_ChipName ), sizeof(Name2) ); + strncpy( Name2, CONV_TO_UTF8( m_ChipName ), sizeof( Name2 ) ); for( ii = 0; ii < (int) strlen( Name2 ); ii++ ) if( Name2[ii] <= ' ' ) Name2[ii] = '~'; } else - strncpy( Name2, NULL_STRING, sizeof(Name2) ); + strncpy( Name2, NULL_STRING, sizeof( Name2 ) ); - fprintf( f, "$Comp\n" ); + if ( fprintf( f, "$Comp\n" ) == EOF ) + return false; if( fprintf( f, "L %s %s\n", Name2, Name1 ) == EOF ) - { - Success = false; - return Success; - } + return false; /* Generation de numero d'unit, convert et Time Stamp*/ - if( fprintf( f, "U %d %d %8.8lX\n", m_Multi, m_Convert, m_TimeStamp ) == EOF ) - { - Success = false; - return Success; - } + if( fprintf( f, "U %d %d %8.8lX\n", m_Multi, m_Convert, + m_TimeStamp ) == EOF ) + return false; /* Save the position */ if( fprintf( f, "P %d %d\n", m_Pos.x, m_Pos.y ) == EOF ) - { - Success = false; - return Success; - } + return false; /* If this is a complex hierarchy; save hierarchical references. * but for simple hierarchies it is not necessary. @@ -827,7 +999,7 @@ bool SCH_COMPONENT::Save( FILE* f ) const */ if( m_PathsAndReferences.GetCount() > 1 ) { - for( unsigned int ii = 0; ii< m_PathsAndReferences.GetCount(); ii++ ) + for( unsigned int ii = 0; ii < m_PathsAndReferences.GetCount(); ii++ ) { /*format: * AR Path="/140/2" Ref="C99" Part="1" @@ -837,23 +1009,19 @@ bool SCH_COMPONENT::Save( FILE* f ) const * Ref is the conventional component reference for this 'path' * Part is the conventional component part selection for this 'path' */ - reference_fields = wxStringTokenize( m_PathsAndReferences[ii], delimiters ); + reference_fields = wxStringTokenize( m_PathsAndReferences[ii], + delimiters ); if( fprintf( f, "AR Path=\"%s\" Ref=\"%s\" Part=\"%s\" \n", - CONV_TO_UTF8( reference_fields[0] ), - CONV_TO_UTF8( reference_fields[1] ), - CONV_TO_UTF8( reference_fields[2] ) - ) == EOF ) - { - Success = false; - return Success; - } + CONV_TO_UTF8( reference_fields[0] ), + CONV_TO_UTF8( reference_fields[1] ), + CONV_TO_UTF8( reference_fields[2] ) ) == EOF ) + return false; } } - for( int fieldNdx = 0; fieldNdxSave( f ) ) - { - Success = false; - break; - } + return false; } - if( !Success ) - return Success; - /* Generation du num unit, position, box ( ancienne norme )*/ if( fprintf( f, "\t%-4d %-4d %-4d\n", m_Multi, m_Pos.x, m_Pos.y ) == EOF ) - { - Success = false; - return Success; - } + return false; if( fprintf( f, "\t%-4d %-4d %-4d %-4d\n", - m_Transform[0][0], - m_Transform[0][1], - m_Transform[1][0], - m_Transform[1][1] ) == EOF ) - { - Success = false; - return Success; - } + m_Transform[0][0], m_Transform[0][1], + m_Transform[1][0], m_Transform[1][1] ) == EOF ) + return false; - fprintf( f, "$EndComp\n" ); - return Success; + if( fprintf( f, "$EndComp\n" ) == EOF ) + return false; + + return true; } @@ -911,3 +1067,36 @@ EDA_Rect SCH_COMPONENT::GetBoundingBox() return bbox; } + + +void SCH_COMPONENT::Display_Infos( WinEDA_DrawFrame* frame ) +{ + EDA_LibComponentStruct* Entry = FindLibPart( m_ChipName.GetData(), + wxEmptyString, FIND_ROOT ); + + wxString msg; + + frame->MsgPanel->EraseMsgBox(); + + Affiche_1_Parametre( frame, 1, _( "Ref" ), + GetRef(((WinEDA_SchematicFrame*)frame)->GetSheet()), + DARKCYAN ); + + if( Entry && Entry->m_Options == ENTRY_POWER ) + msg = _( "Pwr Symb" ); + else + msg = _( "Val" ); + + Affiche_1_Parametre( frame, 10, msg, GetField( VALUE )->m_Text, DARKCYAN ); + + Affiche_1_Parametre( frame, 28, _( "RefLib" ), m_ChipName.GetData(), BROWN ); + + msg = FindLibName; + Affiche_1_Parametre( frame, 40, _( "Lib" ), msg, DARKRED ); + + if( Entry ) + { + Affiche_1_Parametre( frame, 52, Entry->m_Doc, Entry->m_KeyWord, + DARKCYAN ); + } +} diff --git a/eeschema/component_class.h b/eeschema/component_class.h index b264c60212..a5d7577184 100644 --- a/eeschema/component_class.h +++ b/eeschema/component_class.h @@ -5,9 +5,6 @@ #ifndef COMPONENT_CLASS_H #define COMPONENT_CLASS_H -#ifndef eda_global -#define eda_global extern -#endif #include "base_struct.h" #include "class_sch_screen.h" @@ -17,6 +14,14 @@ #include "class_sch_cmp_field.h" +extern void DrawLibPartAux( WinEDA_DrawPanel* panel, wxDC* DC, + SCH_COMPONENT* Component, + EDA_LibComponentStruct* Entry, + const wxPoint& Pos, const int TransMat[2][2], + int Multi, int convert, int DrawMode, + int Color = -1, bool DrawPinText = TRUE ); + + WX_DECLARE_OBJARRAY( DrawSheetPath, ArrayOfSheetLists ); @@ -76,23 +81,29 @@ class SCH_COMPONENT : public SCH_ITEM friend class DIALOG_EDIT_COMPONENT_IN_SCHEMATIC; public: - int m_Multi; ///< In multi unit chip - which unit to draw. + int m_Multi; // In multi unit chip - which unit to draw. - wxPoint m_Pos; + wxPoint m_Pos; - wxString m_ChipName; ///< Key to look for in the library, i.e. "74LS00". + wxString m_ChipName; /* Key to look for in the library, + * i.e. "74LS00". */ - wxString m_PrefixString; /* C, R, U, Q etc - the first character which typically indicates what the component is. - * determined, upon placement, from the library component. - * determined, upon file load, by the first non-digits in the reference fields. - */ + wxString m_PrefixString; /* C, R, U, Q etc - the first character + * which typically indicates what the + * component is. Determined, upon + * placement, from the library component. + * determined, upon file load, by the + * first non-digits in the reference + * fields. */ - int m_Convert; /* Handle mutiple shape (for instance De Morgan conversion) */ - int m_Transform[2][2]; /* The rotation/mirror transformation matrix. */ + int m_Convert; /* Handle mutiple shape (for instance + * De Morgan conversion) */ + int m_Transform[2][2]; /* The rotation/mirror transformation + * matrix. */ private: - SCH_CMP_FIELDS m_Fields; ///< variable length list of fields + SCH_CMP_FIELDS m_Fields; ///< variable length list of fields /* Hierarchical references. @@ -101,12 +112,14 @@ private: * with: * path = // (subsheet path, = / for the root scheet) * reference = reference for this path (C23, R5, U78 ... ) - * multi = part selection in multi parts per package (0 or 1 for àne part per package) + * multi = part selection in multi parts per package (0 or 1 for àne part + * per package) */ wxArrayString m_PathsAndReferences; public: - SCH_COMPONENT( const wxPoint& pos = wxPoint( 0, 0 ), SCH_ITEM* aParent = NULL ); + SCH_COMPONENT( const wxPoint& pos = wxPoint( 0, 0 ), + SCH_ITEM* aParent = NULL ); /** * Copy Constructor @@ -127,7 +140,8 @@ public: /** * Function Save - * writes the data structures for this object out to a FILE in "*.brd" format. + * writes the data structures for this object out to a FILE in "*.brd" + * format. * @param aFile The FILE to write to. * @return bool - true if success writing else false. */ @@ -136,8 +150,8 @@ public: /** * Function Load - * reads a component in from a file. The file stream must be positioned at the - * first field of the file, not at the component tag. + * reads a component in from a file. The file stream must be positioned at + * the first field of the file, not at the component tag. * @param aFile The FILE to read from. * @throw Error containing the error message text if there is a file format * error or if the disk read has failed. @@ -173,7 +187,8 @@ public: /** * Function ReturnFieldName * returns the Field name given a field index like (REFERENCE, VALUE ..) - * @reeturn wxString - the field name or wxEmptyString if invalid field index. + * @reeturn wxString - the field name or wxEmptyString if invalid field + * index. */ wxString ReturnFieldName( int aFieldNdx ) const; @@ -230,17 +245,22 @@ public: /** * Function AddHierarchicalReference * adds a full hierachical reference (path + local reference) - * @param aPath = hierarchical path (//component timestamp> like /05678E50/A23EF560) + * @param aPath = hierarchical path (//component + * timestamp> like /05678E50/A23EF560) * @param aRef = local reference like C45, R56 - * @param aMulti = part selection, used in multi part per package (0 or 1 for non multi) + * @param aMulti = part selection, used in multi part per package (0 or 1 + * for non multi) */ - void AddHierarchicalReference( const wxString& aPath, const wxString& aRef, int aMulti ); + void AddHierarchicalReference( const wxString& aPath, + const wxString& aRef, + int aMulti ); //returns the unit selection, for the given sheet path. int GetUnitSelection( DrawSheetPath* aSheet ); //Set the unit selection, for the given sheet path. - void SetUnitSelection( DrawSheetPath* aSheet, int aUnitSelection ); + void SetUnitSelection( DrawSheetPath* aSheet, + int aUnitSelection ); #if defined (DEBUG) diff --git a/eeschema/controle.cpp b/eeschema/controle.cpp index 205eaa4069..b3ed34b1c0 100644 --- a/eeschema/controle.cpp +++ b/eeschema/controle.cpp @@ -223,7 +223,7 @@ SCH_ITEM* WinEDA_SchematicFrame:: SchematicGeneralLocateAndDisplay( const wxPoin void WinEDA_SchematicFrame::GeneralControle( wxDC* DC, wxPoint MousePositionInPixels ) /*************************************************************************************/ { - wxRealPoint delta; + wxRealPoint delta; SCH_SCREEN* screen = GetScreen(); wxPoint curpos, oldpos; int hotkey = 0; @@ -248,25 +248,25 @@ void WinEDA_SchematicFrame::GeneralControle( wxDC* DC, wxPoint MousePositionInPi case WXK_NUMPAD8: /* Deplacement curseur vers le haut */ case WXK_UP: - MousePositionInPixels.y -= (int) round(delta.y); + MousePositionInPixels.y -= wxRound(delta.y); DrawPanel->MouseTo( MousePositionInPixels ); break; case WXK_NUMPAD2: /* Deplacement curseur vers le bas */ case WXK_DOWN: - MousePositionInPixels.y += (int) round(delta.y); + MousePositionInPixels.y += wxRound(delta.y); DrawPanel->MouseTo( MousePositionInPixels ); break; case WXK_NUMPAD4: /* Deplacement curseur vers la gauche */ case WXK_LEFT: - MousePositionInPixels.x -= (int) round(delta.x); + MousePositionInPixels.x -= wxRound(delta.x); DrawPanel->MouseTo( MousePositionInPixels ); break; case WXK_NUMPAD6: /* Deplacement curseur vers la droite */ case WXK_RIGHT: - MousePositionInPixels.x += (int) round(delta.x); + MousePositionInPixels.x += wxRound(delta.x); DrawPanel->MouseTo( MousePositionInPixels ); break; @@ -308,7 +308,7 @@ void WinEDA_SchematicFrame::GeneralControle( wxDC* DC, wxPoint MousePositionInPi OnHotKey( DC, hotkey, NULL ); } - Affiche_Status_Box(); /* Display cursor coordintes info */ + UpdateStatusBar(); /* Display cursor coordintes info */ SetToolbars(); } @@ -342,25 +342,25 @@ void WinEDA_LibeditFrame::GeneralControle( wxDC* DC, wxPoint MousePositionInPixe case WXK_NUMPAD8: /* Deplacement curseur vers le haut */ case WXK_UP: - MousePositionInPixels.y -= (int) round(delta.y); + MousePositionInPixels.y -= wxRound(delta.y); DrawPanel->MouseTo( MousePositionInPixels ); break; case WXK_NUMPAD2: /* Deplacement curseur vers le bas */ case WXK_DOWN: - MousePositionInPixels.y += (int) round(delta.y); + MousePositionInPixels.y += wxRound(delta.y); DrawPanel->MouseTo( MousePositionInPixels ); break; case WXK_NUMPAD4: /* Deplacement curseur vers la gauche */ case WXK_LEFT: - MousePositionInPixels.x -= (int) round(delta.x); + MousePositionInPixels.x -= wxRound(delta.x); DrawPanel->MouseTo( MousePositionInPixels ); break; case WXK_NUMPAD6: /* Deplacement curseur vers la droite */ case WXK_RIGHT: - MousePositionInPixels.x += (int) round(delta.x); + MousePositionInPixels.x += wxRound(delta.x); DrawPanel->MouseTo( MousePositionInPixels ); break; @@ -402,7 +402,7 @@ void WinEDA_LibeditFrame::GeneralControle( wxDC* DC, wxPoint MousePositionInPixe OnHotKey( DC, hotkey, NULL ); } - Affiche_Status_Box(); /* Affichage des coord curseur */ + UpdateStatusBar(); /* Affichage des coord curseur */ SetToolbars(); } @@ -436,25 +436,25 @@ void WinEDA_ViewlibFrame::GeneralControle( wxDC* DC, case WXK_NUMPAD8: /* Deplacement curseur vers le haut */ case WXK_UP: - MousePositionInPixels.y -= (int) round(delta.y); + MousePositionInPixels.y -= wxRound(delta.y); DrawPanel->MouseTo( MousePositionInPixels ); break; case WXK_NUMPAD2: /* Deplacement curseur vers le bas */ case WXK_DOWN: - MousePositionInPixels.y += (int) round(delta.y); + MousePositionInPixels.y += wxRound(delta.y); DrawPanel->MouseTo( MousePositionInPixels ); break; case WXK_NUMPAD4: /* Deplacement curseur vers la gauche */ case WXK_LEFT: - MousePositionInPixels.x -= (int) round(delta.x); + MousePositionInPixels.x -= wxRound(delta.x); DrawPanel->MouseTo( MousePositionInPixels ); break; case WXK_NUMPAD6: /* Deplacement curseur vers la droite */ case WXK_RIGHT: - MousePositionInPixels.x += (int) round(delta.x); + MousePositionInPixels.x += wxRound(delta.x); DrawPanel->MouseTo( MousePositionInPixels ); break; @@ -496,6 +496,6 @@ void WinEDA_ViewlibFrame::GeneralControle( wxDC* DC, OnHotKey( DC, hotkey, NULL ); } - Affiche_Status_Box(); /* Affichage des coord curseur */ + UpdateStatusBar(); /* Affichage des coord curseur */ SetToolbars(); } diff --git a/eeschema/delete.cpp b/eeschema/delete.cpp index 6f6e779af5..a4700e6bc4 100644 --- a/eeschema/delete.cpp +++ b/eeschema/delete.cpp @@ -4,13 +4,12 @@ #include "fctsys.h" #include "gr_basic.h" - #include "common.h" +#include "class_drawpickedstruct.h" #include "program.h" #include "libcmp.h" #include "general.h" - #include "protos.h" @@ -305,7 +304,7 @@ void WinEDA_SchematicFrame::DeleteConnection( wxDC* DC, bool DeleteFullConnectio if( PickedList ) { - DeleteStruct( DrawPanel, DC, PickedList ); + DeleteStruct( DrawPanel, DC, (SCH_ITEM*) PickedList ); GetScreen()->SetModify(); } } diff --git a/eeschema/dialog_SVG_print.cpp b/eeschema/dialog_SVG_print.cpp index 2a53108e00..1ee9dca8be 100644 --- a/eeschema/dialog_SVG_print.cpp +++ b/eeschema/dialog_SVG_print.cpp @@ -130,11 +130,11 @@ void DIALOG_SVG_PRINT::SetPenWidth() void DIALOG_SVG_PRINT::PrintSVGDoc( bool aPrintAll, bool aPrint_Sheet_Ref ) /***************************************************************************/ { - wxString msg; + wxString msg; + wxFileName fn; SetPenWidth(); - wxString FullFileName; BASE_SCREEN* screen = m_Parent->GetBaseScreen(); BASE_SCREEN* oldscreen = screen; @@ -165,10 +165,11 @@ void DIALOG_SVG_PRINT::PrintSVGDoc( bool aPrintAll, bool aPrint_Sheet_Ref ) return; sheetpath = SheetList.GetNext(); - FullFileName = schframe->GetUniqueFilenameForCurrentSheet( ) + wxT( ".svg" ); + fn = schframe->GetUniqueFilenameForCurrentSheet( ) + wxT( ".svg" ); - bool success = DrawPage( FullFileName, schscreen, aPrint_Sheet_Ref ); - msg = _( "Create file " ) + FullFileName; + bool success = DrawPage( fn.GetFullPath(), schscreen, + aPrint_Sheet_Ref ); + msg = _( "Create file " ) + fn.GetFullPath(); if( !success ) msg += _( " error" ); msg += wxT( "\n" ); @@ -180,16 +181,20 @@ void DIALOG_SVG_PRINT::PrintSVGDoc( bool aPrintAll, bool aPrint_Sheet_Ref ) } else { - FullFileName = m_FileNameCtrl->GetValue(); - if( FullFileName.IsEmpty() ) + fn = m_FileNameCtrl->GetValue(); + + if( !fn.IsOk() ) { - FullFileName = screen->m_FileName; - ChangeFileNameExt( FullFileName, wxT( ".svg" ) ); + fn = screen->m_FileName; + fn.SetExt( wxT( "svg" ) ); } - bool success = DrawPage( FullFileName, screen, aPrint_Sheet_Ref ); - msg = _( "Create file " ) + FullFileName; + + bool success = DrawPage( fn.GetFullPath(), screen, aPrint_Sheet_Ref ); + msg = _( "Create file " ) + fn.GetFullPath(); + if( !success ) msg += _( " error" ); + msg += wxT( "\n" ); m_MessagesBox->AppendText( msg ); } @@ -247,11 +252,11 @@ bool DIALOG_SVG_PRINT::DrawPage( const wxString& FullFileName, BASE_SCREEN* scre panel->m_ClipBox.SetX( 0 ); panel->m_ClipBox.SetY( 0 ); panel->m_ClipBox.SetWidth( 0x7FFFFF0 ); panel->m_ClipBox.SetHeight( 0x7FFFFF0 ); - g_IsPrinting = true; + screen->m_IsPrinting = true; SetLocaleTo_C_standard( ); // Switch the locale to standard C (needed to print floating point numbers like 1.3) panel->PrintPage( &dc, aPrint_Sheet_Ref, 1, false ); SetLocaleTo_Default( ); // revert to the current locale - g_IsPrinting = FALSE; + screen->m_IsPrinting = false; panel->m_ClipBox = tmp; } diff --git a/eeschema/dialog_build_BOM.cpp b/eeschema/dialog_build_BOM.cpp index 25307bfdc4..f16745ea6e 100644 --- a/eeschema/dialog_build_BOM.cpp +++ b/eeschema/dialog_build_BOM.cpp @@ -81,7 +81,7 @@ DIALOG_BUILD_BOM::DIALOG_BUILD_BOM( WinEDA_DrawFrame* parent ): wxASSERT( m_Config != NULL ); m_Parent = parent; - + Init( ); if (GetSizer()) @@ -99,7 +99,7 @@ DIALOG_BUILD_BOM::DIALOG_BUILD_BOM( WinEDA_DrawFrame* parent ): void DIALOG_BUILD_BOM::Init() { SetFont( *g_DialogFont ); - + SetFocus(); /* Get options */ @@ -203,6 +203,9 @@ void DIALOG_BUILD_BOM::OnCancelClick( wxCommandEvent& event ) void DIALOG_BUILD_BOM::SavePreferences() /**************************************************/ { + wxConfig* config = wxGetApp().m_EDA_Config; + wxASSERT( config != NULL ); + // Determine current settings of "List items" and "Options" checkboxes // (NOTE: These 6 settings are restored when the dialog box is next // invoked, but are *not* still saved after EESchema is next shut down.) diff --git a/eeschema/dialog_eeschema_config.cpp b/eeschema/dialog_eeschema_config.cpp index c89fe30451..2a884604bf 100644 --- a/eeschema/dialog_eeschema_config.cpp +++ b/eeschema/dialog_eeschema_config.cpp @@ -229,11 +229,11 @@ wxString msg = _("Cmp file Ext: ") + g_NetCmpExtBuffer; wxStaticText * text = new wxStaticText( itemDialog1, -1, msg, wxDefaultPosition, wxDefaultSize, 0 ); m_FileExtList->Add(text, 0, wxALIGN_LEFT|wxLEFT|wxRIGHT|wxADJUST_MINSIZE, 5); - msg = _("Net file Ext: ") + g_NetExtBuffer; + msg = _("Net file Ext: ") + NetlistFileExtension; text = new wxStaticText( itemDialog1, -1, msg, wxDefaultPosition, wxDefaultSize, 0 ); m_FileExtList->Add(text, 0, wxALIGN_LEFT|wxLEFT|wxRIGHT|wxADJUST_MINSIZE, 5); - msg = _("Library file Ext: ") + g_LibExtBuffer; + msg = _("Library file Ext: ") + CompLibFileExtension; text = new wxStaticText( itemDialog1, -1, msg, wxDefaultPosition, wxDefaultSize, 0 ); m_FileExtList->Add(text, 0, wxALIGN_LEFT|wxLEFT|wxRIGHT|wxADJUST_MINSIZE, 5); @@ -241,7 +241,7 @@ wxString msg = _("Cmp file Ext: ") + g_NetCmpExtBuffer; text = new wxStaticText( itemDialog1, -1, msg, wxDefaultPosition, wxDefaultSize, 0 ); m_FileExtList->Add(text, 0, wxALIGN_LEFT|wxLEFT|wxRIGHT|wxADJUST_MINSIZE, 5); - msg = _("Schematic file Ext: ") + g_SchExtBuffer; + msg = _("Schematic file Ext: ") + SchematicFileExtension; text = new wxStaticText( itemDialog1, -1, msg, wxDefaultPosition, wxDefaultSize, 0 ); m_FileExtList->Add(text, 0, wxALIGN_LEFT|wxLEFT|wxRIGHT|wxADJUST_MINSIZE, 5); @@ -316,7 +316,6 @@ void KiConfigEeschemaFrame::ChangeSetup() /*********************************************/ { g_UserLibDirBuffer = m_LibDirCtrl->GetValue(); - SetRealLibraryPath( wxT("library") ); } @@ -344,49 +343,58 @@ void KiConfigEeschemaFrame::AddOrInsertLibrary(wxCommandEvent& event) the selection */ { -int ii; -wxString FullLibName,ShortLibName, Mask; + int ii; + wxString tmp; + wxFileName fn; + /* TODO: Fix this, it's broken. Add should add the new library to the + * end of the list and insert should insert the new library ahead + * of the selected library in the list or at the beginning if no + * library is selected. */ ii = m_ListLibr->GetSelection(); - if ( ii < 0 ) ii = 0; + if ( ii < 0 ) + ii = 0; ChangeSetup(); if( event.GetId() == ADD_LIB) { - if( g_LibName_List.GetCount() != 0 ) ii ++; /* Add after selection */ + if( g_LibName_List.GetCount() != 0 ) + ii++; /* Add after selection */ } - Mask = wxT("*") + g_LibExtBuffer; + wxFileDialog dlg( this, _( "Schematic Component Library Files" ), + g_RealLibDirBuffer, wxEmptyString, CompLibFileWildcard, + wxFD_OPEN | wxFD_MULTIPLE | wxFD_FILE_MUST_EXIST ); - wxFileDialog FilesDialog(this, _("Library files:"), g_RealLibDirBuffer, - wxEmptyString, Mask, - wxFD_DEFAULT_STYLE | wxFD_MULTIPLE); - - int diag = FilesDialog.ShowModal(); - if ( diag != wxID_OK ) + if ( dlg.ShowModal() != wxID_OK ) return; wxArrayString Filenames; - FilesDialog.GetPaths(Filenames); + dlg.GetPaths(Filenames); for ( unsigned jj = 0; jj < Filenames.GetCount(); jj ++ ) { - FullLibName = Filenames[jj]; - ShortLibName = MakeReducedFileName(FullLibName,g_RealLibDirBuffer,g_LibExtBuffer); - if ( ShortLibName.IsEmpty() ) //Just in case... - continue; - //Add or insert new library name - if ( g_LibName_List.Index(ShortLibName) == wxNOT_FOUND) + fn = Filenames[jj]; + + /* If the library path is already in the library search paths + * list, just add the library name to the list. Otherwise, add + * the library name with the full path. */ + if( wxGetApp().GetLibraryPathList().Index( fn.GetPath() ) == wxNOT_FOUND ) + tmp = fn.GetPathWithSep() + fn.GetName(); + else + tmp = fn.GetName(); + + // Add or insert new library name. + if( g_LibName_List.Index( tmp ) == wxNOT_FOUND ) { m_LibListChanged = TRUE; - g_LibName_List.Insert(ShortLibName, ii); + g_LibName_List.Insert( tmp, ii++ ); m_ListLibr->Clear(); m_ListLibr->InsertItems(g_LibName_List, 0); } - else { - wxString msg; - msg << wxT("<") << ShortLibName << wxT("> : ") << _("Library already in use"); + wxString msg = wxT("<") + tmp + wxT("> : ") + + _("Library already in use"); DisplayError(this, msg); } } diff --git a/eeschema/dialog_options.cpp b/eeschema/dialog_options.cpp index 0c15d41aa4..0473d9007d 100644 --- a/eeschema/dialog_options.cpp +++ b/eeschema/dialog_options.cpp @@ -439,7 +439,7 @@ void WinEDA_SetOptionsFrame::Accept( wxCommandEvent& event ) else g_ShowAllPins = TRUE; - g_ShowGrid = m_Parent->m_Draw_Grid = m_ShowGridOpt->GetValue(); + m_Parent->m_Draw_Grid = m_ShowGridOpt->GetValue(); m_Parent->DrawPanel->m_AutoPAN_Enable = m_AutoPANOpt->GetValue(); m_Parent->m_Draw_Grid = m_ShowGridOpt->GetValue(); diff --git a/eeschema/dialog_print_using_printer.cpp b/eeschema/dialog_print_using_printer.cpp index 2b6e96bc49..7b5ee657ed 100644 --- a/eeschema/dialog_print_using_printer.cpp +++ b/eeschema/dialog_print_using_printer.cpp @@ -455,21 +455,22 @@ void EDA_Printout::DrawPage() * in order to keep the requested value */ dc->GetUserScale( &xdcscale, &ydcscale ); ftmp /= xdcscale; - SetPenMinWidth( (int) round( ftmp ) ); + SetPenMinWidth( wxRound( ftmp ) ); WinEDA_DrawPanel* panel = m_Parent->DrawPanel; + BASE_SCREEN* screen = panel->GetScreen(); EDA_Rect tmp = panel->m_ClipBox; panel->m_ClipBox.SetOrigin( wxPoint( 0, 0 ) ); panel->m_ClipBox.SetSize( wxSize( 0x7FFFFF0, 0x7FFFFF0 ) ); - g_IsPrinting = true; + screen->m_IsPrinting = true; int bg_color = g_DrawBgColor; panel->PrintPage( dc, m_Print_Sheet_Ref, 0xFFFFFFFF, false ); g_DrawBgColor = bg_color; - g_IsPrinting = false; + screen->m_IsPrinting = false; panel->m_ClipBox = tmp; SetPenMinWidth( 1 ); diff --git a/eeschema/edit_component_in_schematic.cpp b/eeschema/edit_component_in_schematic.cpp index 0860a6af90..62ada9c33a 100644 --- a/eeschema/edit_component_in_schematic.cpp +++ b/eeschema/edit_component_in_schematic.cpp @@ -287,46 +287,6 @@ void WinEDA_SchematicFrame::RotateCmpField( SCH_CMP_FIELD* Field, wxDC* DC ) } -/*********************************************************************/ -void SCH_CMP_FIELD::Place( WinEDA_SchematicFrame* frame, wxDC* DC ) -/*********************************************************************/ -{ - int fieldNdx; - EDA_LibComponentStruct* Entry; - - frame->DrawPanel->ManageCurseur = NULL; - frame->DrawPanel->ForceCloseManageCurseur = NULL; - - SCH_COMPONENT* component = (SCH_COMPONENT*) GetParent(); - - // save old cmp in undo list - if( g_ItemToUndoCopy && ( g_ItemToUndoCopy->Type() == component->Type()) ) - { - component->SwapData( (SCH_COMPONENT*) g_ItemToUndoCopy ); - frame->SaveCopyInUndoList( component, IS_CHANGED ); - component->SwapData( (SCH_COMPONENT*) g_ItemToUndoCopy ); - } - - fieldNdx = m_FieldId; - m_AddExtraText = 0; - if( fieldNdx == REFERENCE ) - { - Entry = FindLibPart( component->m_ChipName.GetData(), wxEmptyString, FIND_ROOT ); - if( Entry != NULL ) - { - if( Entry->m_UnitCount > 1 ) - m_AddExtraText = 1; - } - } - - Draw( frame->DrawPanel, DC, wxPoint(0,0), GR_DEFAULT_DRAWMODE ); - m_Flags = 0; - frame->GetScreen()->SetCurItem( NULL ); - frame->GetScreen()->SetModify(); - frame->SetCurrentField( NULL ); -} - - /**************************************************************************************************/ void WinEDA_SchematicFrame::EditComponentReference( SCH_COMPONENT* Cmp, wxDC* DC ) /**************************************************************************************************/ diff --git a/eeschema/edit_graphic_bodyitem_text.cpp b/eeschema/edit_graphic_bodyitem_text.cpp index 39f0d37c8b..e293a0f2f9 100644 --- a/eeschema/edit_graphic_bodyitem_text.cpp +++ b/eeschema/edit_graphic_bodyitem_text.cpp @@ -134,26 +134,25 @@ wxString Line; Close(); if ( CurrentDrawItem ) - CurrentDrawItem->Display_Infos_DrawEntry(m_Parent); + CurrentDrawItem->DisplayInfo( m_Parent ); Close(); } -/*******************************************************/ void WinEDA_LibeditFrame::EditSymbolText(wxDC * DC, - LibEDA_BaseStruct * DrawItem) -/*******************************************************/ + LibEDA_BaseStruct * DrawItem) { -int DrawMode = g_XorMode; + int DrawMode = g_XorMode; - if ( DrawItem == NULL ) return; - if ( DrawItem->Type() != COMPONENT_GRAPHIC_TEXT_DRAW_TYPE ) return; + if ( ( DrawItem == NULL ) + || ( DrawItem->Type() != COMPONENT_GRAPHIC_TEXT_DRAW_TYPE ) ) + return; /* Effacement ancien texte */ if( ((LibDrawText*)DrawItem)->m_Text && DC) DrawLibraryDrawStruct(DrawPanel, DC, CurrentLibEntry, wxPoint(0, 0), - DrawItem, DrawMode); + DrawItem, DrawMode); Dialog_BodyGraphicText_Properties * frame = diff --git a/eeschema/eeconfig.cpp b/eeschema/eeconfig.cpp index df2adb9c78..db9d5ce12e 100644 --- a/eeschema/eeconfig.cpp +++ b/eeschema/eeconfig.cpp @@ -29,9 +29,9 @@ void WinEDA_SchematicFrame::Process_Config( wxCommandEvent& event ) /*********************************************************************/ { - int id = event.GetId(); - wxPoint pos; - wxString FullFileName; + int id = event.GetId(); + wxPoint pos; + wxFileName fn; wxGetMousePosition( &pos.x, &pos.y ); @@ -58,35 +58,25 @@ void WinEDA_SchematicFrame::Process_Config( wxCommandEvent& event ) case ID_CONFIG_READ: { - wxString mask( wxT( "*" ) ); mask += g_Prj_Config_Filename_ext; - FullFileName = g_RootSheet->m_AssociatedScreen->m_FileName; - ChangeFileNameExt( FullFileName, g_Prj_Config_Filename_ext ); + fn = g_RootSheet->m_AssociatedScreen->m_FileName; + fn.SetExt( ProjectFileExtension ); - FullFileName = EDA_FileSelector( _( "Read config file" ), - wxGetCwd(), /* Chemin par defaut */ - FullFileName, /* nom fichier par defaut */ - g_Prj_Config_Filename_ext, /* extension par defaut */ - mask, /* Masque d'affichage */ - this, - wxFD_OPEN, - TRUE /* ne change pas de repertoire courant */ - ); - if( FullFileName.IsEmpty() ) + wxFileDialog dlg( this, _( "Read Project File" ), fn.GetPath(), + fn.GetFullName(), ProjectFileWildcard, + wxFD_OPEN | wxFD_FILE_MUST_EXIST ); + + if( dlg.ShowModal() == wxID_CANCEL ) break; - if( !wxFileExists( FullFileName ) ) - { - wxString msg = _( "File " ) + FullFileName + _( "not found" );; - DisplayError( this, msg ); break; - } - Read_Config( FullFileName, TRUE ); + + Read_Config( fn.GetFullPath(), TRUE ); } break; case ID_PREFERENCES_CREATE_CONFIG_HOTKEYS: - FullFileName = ReturnHotkeyConfigFilePath( g_ConfigFileLocationChoice ); - FullFileName += HOTKEY_FILENAME; - FullFileName += DEFAULT_HOTKEY_FILENAME_EXT; - WriteHotkeyConfigFile( FullFileName, s_Eeschema_Hokeys_Descr, true ); + fn = wxFileName( ReturnHotkeyConfigFilePath( g_ConfigFileLocationChoice ), + HOTKEY_FILENAME, + DEFAULT_HOTKEY_FILENAME_EXT ); + WriteHotkeyConfigFile( fn.GetFullPath(), s_Eeschema_Hokeys_Descr, true ); break; case ID_PREFERENCES_READ_CONFIG_HOTKEYS: @@ -95,13 +85,11 @@ void WinEDA_SchematicFrame::Process_Config( wxCommandEvent& event ) case ID_PREFERENCES_EDIT_CONFIG_HOTKEYS: { - FullFileName = ReturnHotkeyConfigFilePath( g_ConfigFileLocationChoice ); - FullFileName += HOTKEY_FILENAME; - FullFileName += DEFAULT_HOTKEY_FILENAME_EXT; - AddDelimiterString( FullFileName ); - wxString editorname = GetEditorName(); + fn = wxFileName( ReturnHotkeyConfigFilePath( g_ConfigFileLocationChoice ), + HOTKEY_FILENAME, DEFAULT_HOTKEY_FILENAME_EXT ); + wxString editorname = wxGetApp().GetEditorName(); if( !editorname.IsEmpty() ) - ExecuteFile( this, editorname, FullFileName ); + ExecuteFile( this, editorname, QuoteFullPath( fn ) ); } break; @@ -115,9 +103,8 @@ void WinEDA_SchematicFrame::Process_Config( wxCommandEvent& event ) break; default: - DisplayError( this, - wxT( - "WinEDA_SchematicFrame::Process_Config internal error" ) ); + DisplayError( this, wxT( "WinEDA_SchematicFrame::Process_Config " \ + "internal error" ) ); } } @@ -155,7 +142,7 @@ bool Read_Config( const wxString& CfgFileName, bool ForceRereadConfig ) * Retourne TRUE si lu, FALSE si config non lue */ { - wxString FullFileName; + wxFileName fn; bool IsRead = TRUE; wxArrayString liblist_tmp = g_LibName_List; WinEDA_SchematicFrame* frame; @@ -163,21 +150,36 @@ bool Read_Config( const wxString& CfgFileName, bool ForceRereadConfig ) frame = (WinEDA_SchematicFrame*)wxGetApp().GetTopWindow(); if( CfgFileName.IsEmpty() ) - FullFileName = g_RootSheet->m_AssociatedScreen->m_FileName; + fn = g_RootSheet->m_AssociatedScreen->m_FileName; else - FullFileName = CfgFileName; + fn = CfgFileName; g_LibName_List.Clear(); - if( !wxGetApp().ReadProjectConfig( FullFileName, - GROUP, ParamCfgList, - ForceRereadConfig ? FALSE : TRUE ) ) // Config non lue + /* Change the schematic file extension (.sch) to the project file + * extension (.pro). */ + fn.SetExt( ProjectFileExtension ); + + if( wxGetApp().GetLibraryPathList().Index( g_UserLibDirBuffer ) != wxNOT_FOUND ) + { + wxLogDebug( wxT( "Removing path <%s> to library path search list." ), + g_UserLibDirBuffer.c_str() ); + wxGetApp().GetLibraryPathList().Remove( g_UserLibDirBuffer ); + } + + if( !wxGetApp().ReadProjectConfig( fn.GetFullPath(), GROUP, ParamCfgList, + ForceRereadConfig ? FALSE : TRUE ) ) { g_LibName_List = liblist_tmp; IsRead = FALSE; } - /* Traitement des variables particulieres: */ - SetRealLibraryPath( wxT( "library" ) ); + if( wxFileName::DirExists( g_UserLibDirBuffer ) + && wxGetApp().GetLibraryPathList().Index( g_UserLibDirBuffer ) == wxNOT_FOUND ) + { + wxLogDebug( wxT( "Adding path <%s> to library path search list." ), + g_UserLibDirBuffer.c_str() ); + wxGetApp().GetLibraryPathList().Add( g_UserLibDirBuffer ); + } // If the list is void, load the libraries "power.lib" and "device.lib" if( g_LibName_List.GetCount() == 0 ) @@ -189,7 +191,6 @@ bool Read_Config( const wxString& CfgFileName, bool ForceRereadConfig ) if( frame ) { frame->SetDrawBgColor( g_DrawBgColor ); - frame->m_Draw_Grid = g_ShowGrid; } LoadLibraries( frame ); @@ -202,27 +203,36 @@ bool Read_Config( const wxString& CfgFileName, bool ForceRereadConfig ) void WinEDA_SchematicFrame::Save_Config( wxWindow* displayframe ) /***************************************************************/ { - wxString path; - wxString FullFileName; - wxString mask( wxT( "*" ) ); + wxFileName fn; - mask += g_Prj_Config_Filename_ext; - FullFileName = g_RootSheet->m_AssociatedScreen->m_FileName.AfterLast( '/' ) /*ConfigFileName*/; - ChangeFileNameExt( FullFileName, g_Prj_Config_Filename_ext ); + fn = g_RootSheet->m_AssociatedScreen->m_FileName /*ConfigFileName*/; + fn.SetExt( ProjectFileExtension ); - path = wxGetCwd(); - FullFileName = EDA_FileSelector( _( "Save preferences" ), - path, /* Chemin par defaut */ - FullFileName, /* nom fichier par defaut */ - g_Prj_Config_Filename_ext, /* extension par defaut */ - mask, /* Masque d'affichage */ - displayframe, - wxFD_SAVE, - TRUE - ); - if( FullFileName.IsEmpty() ) + wxFileDialog dlg( this, _( "Save Project Settings" ), wxGetCwd(), + fn.GetFullName(), ProjectFileWildcard, + wxFD_SAVE | wxFD_OVERWRITE_PROMPT ); + + if( dlg.ShowModal() == wxID_CANCEL ) return; /* ecriture de la configuration */ - wxGetApp().WriteProjectConfig( FullFileName, GROUP, ParamCfgList ); + wxGetApp().WriteProjectConfig( dlg.GetPath(), GROUP, ParamCfgList ); +} + + +/* + * Load the EESchema configuration parameters. + */ +void WinEDA_SchematicFrame::LoadSettings() +{ + WinEDA_DrawFrame::LoadSettings(); +} + + +/* + * Save the EESchema configuration parameters. + */ +void WinEDA_SchematicFrame::SaveSettings() +{ + WinEDA_DrawFrame::SaveSettings(); } diff --git a/eeschema/eeconfig.h b/eeschema/eeconfig.h index f507708cea..75b69de907 100644 --- a/eeschema/eeconfig.h +++ b/eeschema/eeconfig.h @@ -2,10 +2,6 @@ /** eeconfig.h : configuration: definition des structures **/ /************************************************************/ -#ifndef eda_global -#define eda_global extern -#endif - #include "param_config.h" #define GROUP wxT( "/eeschema" ) @@ -54,24 +50,6 @@ static PARAM_CFG_INT UnitCfg 0, 1 /* Min and Max values for the parameter */ ); -static PARAM_CFG_INT CursorShapeCfg -( - INSETUP, - wxT( "CuShape" ), /* Ident String */ - &g_CursorShape, /* Parameter address */ - 0, /* Default value */ - 0, 1 /* Min and Max values for the parameter */ -); - -static PARAM_CFG_INT ShowGridCfg -( - INSETUP, - wxT( "ShGrid" ), /* Ident String */ - &g_ShowGrid, /* Parameter address */ - 0, 1, /* Min and Max values for the parameter */ - 1 /* Default value */ -); - static PARAM_CFG_SETCOLOR DrawBgColorCfg ( INSETUP, @@ -496,8 +474,6 @@ PARAM_CFG_BASE* ParamCfgList[] = &NetFormatCfg, &UnitCfg, - &CursorShapeCfg, - &ShowGridCfg, &DrawBgColorCfg, &ColorLayerWireCfg, &ColorLayerBusCfg, diff --git a/eeschema/eelayer.cpp b/eeschema/eelayer.cpp index 1a6d62be2a..c5f849182c 100644 --- a/eeschema/eelayer.cpp +++ b/eeschema/eelayer.cpp @@ -337,12 +337,10 @@ void WinEDA_SetColorsFrame::UpdateLayerSettings() } // Update whether grid is actually displayed or otherwise -// m_Parent->m_Draw_Grid = g_ShowGrid = m_ShowGrid->GetValue(); // The previous command compiles OK, but to prevent a warning // from being generated when the Linux version is being compiled, // the next two commands are provided instead. - g_ShowGrid = m_ShowGrid->GetValue(); - m_Parent->m_Draw_Grid = g_ShowGrid; + m_Parent->m_Draw_Grid = m_ShowGrid->GetValue(); // Update color of background if( m_SelBgColor->GetSelection() == 0 ) diff --git a/eeschema/eelibs_draw_components.cpp b/eeschema/eelibs_draw_components.cpp index 9cb2627ff5..6302ee0b4b 100644 --- a/eeschema/eelibs_draw_components.cpp +++ b/eeschema/eelibs_draw_components.cpp @@ -14,83 +14,36 @@ #include "trigo.h" #include "protos.h" -//#define DRAW_ARC_WITH_ANGLE // Used to select function to draw arcs +//#define DRAW_ARC_WITH_ANGLE // Used to select function to draw arcs /* Local functions */ -/* Descr component used when a component is not found in library, - * to draw a dummy shape - * This component is a 400 mils square with the text ?? - * DEF DUMMY U 0 40 Y Y 1 0 N - * F0 "U" 0 -350 60 H V - * F1 "DUMMY" 0 350 60 H V - * DRAW - * T 0 0 0 150 0 0 0 ?? - * S -200 200 200 -200 0 1 0 - * ENDDRAW - * ENDDEF - */ -static void CreateDummyCmp(); -static void DrawLibPartAux( WinEDA_DrawPanel * panel, wxDC * DC, - SCH_COMPONENT * Component, - EDA_LibComponentStruct * Entry, - const wxPoint &Pos, - const int TransMat[2][2], - int Multi, int convert, - int DrawMode, int Color = -1, bool DrawPinText = TRUE ); -/* Local variables */ -static EDA_LibComponentStruct* DummyCmp; /***************************************************************************/ -wxPoint TransformCoordinate( const int aTransformMatrix[2][2], const wxPoint& aPosition ) -/***************************************************************************/ - /** Function TransformCoordinate - * Calculate the wew coordinate from the old one, according to the transform matrix. + * Calculate the wew coordinate from the old one, according to the transform + * matrix. * @param aTransformMatrix = rotation, mirror .. matrix * @param aPosition = the position to transform * @return the new coordinate */ +/***************************************************************************/ +wxPoint TransformCoordinate( const int aTransformMatrix[2][2], + const wxPoint& aPosition ) { wxPoint new_pos; - new_pos.x = (aTransformMatrix[0][0] * aPosition.x) + (aTransformMatrix[0][1] * aPosition.y); - new_pos.y = (aTransformMatrix[1][0] * aPosition.x) + (aTransformMatrix[1][1] * aPosition.y); + new_pos.x = ( aTransformMatrix[0][0] * aPosition.x ) + + ( aTransformMatrix[0][1] * aPosition.y ); + new_pos.y = ( aTransformMatrix[1][0] * aPosition.x ) + + ( aTransformMatrix[1][1] * aPosition.y ); + return new_pos; } -/******************************/ -void CreateDummyCmp() -/******************************/ -{ - DummyCmp = new EDA_LibComponentStruct( NULL ); - - LibDrawSquare* Square = new LibDrawSquare(); - - Square->m_Pos = wxPoint( -200, 200 ); - Square->m_End = wxPoint( 200, -200 ); - Square->m_Width = 4; - - LibDrawText* Text = new LibDrawText(); - - Text->m_Size.x = Text->m_Size.y = 150; - Text->m_Text = wxT( "??" ); - - DummyCmp->m_Drawings = Square; - Square->SetNext( Text ); -} - - -/*************************************************************/ -void DrawLibEntry( WinEDA_DrawPanel* panel, wxDC* DC, - EDA_LibComponentStruct* LibEntry, - const wxPoint & aOffset, - int Multi, int convert, - int DrawMode, int Color ) /**************************************************************/ - /* Routine de dessin d'un composant d'une librairie * LibEntry = pointeur sur la description en librairie * posX, posY = position du composant @@ -101,6 +54,12 @@ void DrawLibEntry( WinEDA_DrawPanel* panel, wxDC* DC, * * Le composant est toujours trace avec orientation 0 */ +/*************************************************************/ +void DrawLibEntry( WinEDA_DrawPanel* panel, wxDC* DC, + EDA_LibComponentStruct* LibEntry, + const wxPoint& aOffset, + int Multi, int convert, + int DrawMode, int Color ) { int color; wxString Prefix; @@ -109,8 +68,8 @@ void DrawLibEntry( WinEDA_DrawPanel* panel, wxDC* DC, DrawLibPartAux( panel, DC, NULL, LibEntry, aOffset, - DefaultTransformMatrix, Multi, - convert, DrawMode, Color ); + DefaultTransformMatrix, Multi, + convert, DrawMode, Color ); /* Trace des 2 champs ref et value (Attention aux coord: la matrice * de transformation change de signe les coord Y */ @@ -124,19 +83,25 @@ void DrawLibEntry( WinEDA_DrawPanel* panel, wxDC* DC, else color = g_InvisibleItemColor; } - else color = Color; + else + color = Color; if( LibEntry->m_UnitCount > 1 ) #if defined(KICAD_GOST) - Prefix.Printf( wxT( "%s?.%c" ), LibEntry->m_Prefix.m_Text.GetData(), Multi + '1' - 1); + + Prefix.Printf( wxT( "%s?.%c" ), + LibEntry->m_Prefix.m_Text.GetData(), Multi + '1' - 1 ); #else - Prefix.Printf( wxT( "%s?%c" ), LibEntry->m_Prefix.m_Text.GetData(), Multi + 'A' - 1 ); + + Prefix.Printf( wxT( "%s?%c" ), + LibEntry->m_Prefix.m_Text.GetData(), Multi + 'A' - 1 ); #endif else Prefix = LibEntry->m_Prefix.m_Text + wxT( "?" ); if( (LibEntry->m_Prefix.m_Flags & IS_MOVED) == 0 ) - LibEntry->m_Prefix.Draw( panel, DC, aOffset, color, DrawMode, &Prefix, DefaultTransformMatrix ); + LibEntry->m_Prefix.Draw( panel, DC, aOffset, color, DrawMode, + &Prefix, DefaultTransformMatrix ); if( LibEntry->m_Name.m_Attributs & TEXT_NO_VISIBLE ) { @@ -145,10 +110,12 @@ void DrawLibEntry( WinEDA_DrawPanel* panel, wxDC* DC, else color = g_InvisibleItemColor; } - else color = Color; + else + color = Color; if( (LibEntry->m_Name.m_Flags & IS_MOVED) == 0 ) - LibEntry->m_Name.Draw( panel, DC, aOffset, color, DrawMode, NULL, DefaultTransformMatrix ); + LibEntry->m_Name.Draw( panel, DC, aOffset, color, DrawMode, NULL, + DefaultTransformMatrix ); for( Field = LibEntry->m_Fields; Field != NULL; Field = Field->Next() ) { @@ -163,215 +130,31 @@ void DrawLibEntry( WinEDA_DrawPanel* panel, wxDC* DC, else color = g_InvisibleItemColor; } - else color = Color; - Field->Draw( panel, DC, aOffset, color, DrawMode, NULL, DefaultTransformMatrix ); + else + color = Color; + Field->Draw( panel, DC, aOffset, color, DrawMode, NULL, + DefaultTransformMatrix ); } // Trace de l'ancre int len = panel->GetScreen()->Unscale( 3 ); - GRLine( &panel->m_ClipBox, DC, aOffset.x, aOffset.y - len, aOffset.x, aOffset.y + len, 0, color ); - GRLine( &panel->m_ClipBox, DC, aOffset.x - len, aOffset.y, aOffset.x + len, aOffset.y, 0, color ); -} + GRLine( &panel->m_ClipBox, DC, aOffset.x, aOffset.y - len, aOffset.x, + aOffset.y + len, 0, color ); + GRLine( &panel->m_ClipBox, DC, aOffset.x - len, aOffset.y, aOffset.x + len, + aOffset.y, 0, color ); - -/***************************************************************************** -* Routine to draw the given part at given position, transformed/mirror as * -* specified, and in the given drawing mode. Only this one is visible... * -*****************************************************************************/ -void SCH_COMPONENT::Draw( WinEDA_DrawPanel* panel, wxDC* DC, - const wxPoint& offset, int DrawMode, int Color ) -{ - EDA_LibComponentStruct* Entry; - int ii; - bool dummy = FALSE; - - if( ( Entry = FindLibPart( m_ChipName.GetData(), wxEmptyString, FIND_ROOT ) ) == NULL ) - { - /* composant non trouve, on affiche un composant "dummy" */ - dummy = TRUE; - if( DummyCmp == NULL ) - CreateDummyCmp(); - Entry = DummyCmp; - } - - DrawLibPartAux( panel, DC, this, Entry, m_Pos + offset, - m_Transform, - dummy ? 0 : m_Multi, - dummy ? 0 : m_Convert, - DrawMode ); - - /* Trace des champs, avec placement et orientation selon orient. du - * composant - */ - - SCH_CMP_FIELD* field = GetField( REFERENCE ); - - if( ( (field->m_Attributs & TEXT_NO_VISIBLE) == 0 ) - && !(field->m_Flags & IS_MOVED) ) - { - if( Entry->m_UnitCount > 1 ) - { - field->m_AddExtraText = true; - field->Draw( panel, DC, offset, DrawMode ); - } - else - { - field->m_AddExtraText = false; - field->Draw( panel, DC, offset, DrawMode ); - } - } - - for( ii = VALUE; ii < GetFieldCount(); ii++ ) - { - field = GetField( ii ); - - if( field->m_Flags & IS_MOVED ) - continue; - - field->Draw( panel, DC, offset, DrawMode ); - } -} - - -/***********************************************************/ -void SCH_CMP_FIELD::Draw( WinEDA_DrawPanel* panel, - wxDC* DC, - const wxPoint& offset, - int DrawMode, - int Color ) -/***********************************************************/ - -/* Routine de trace des textes type Field du composant. - * entree: - * DrawMode: mode de trace - */ -{ - int orient; - EDA_Colors color; - wxPoint pos; /* Position des textes */ - SCH_COMPONENT* DrawLibItem = (SCH_COMPONENT*) m_Parent; - GRTextHorizJustifyType hjustify; - GRTextVertJustifyType vjustify; - int LineWidth = MAX( m_Width, g_DrawMinimunLineWidth ); - - if( m_Attributs & TEXT_NO_VISIBLE ) - return; - - if( IsVoid() ) - return; - - GRSetDrawMode( DC, DrawMode ); - - /* Calcul de la position des textes, selon orientation du composant */ - orient = m_Orient; - hjustify = m_HJustify; vjustify = m_VJustify; - pos = m_Pos - DrawLibItem->m_Pos; - - pos = DrawLibItem->GetScreenCoord( pos ); - pos += DrawLibItem->m_Pos; - - /* Y a t-il rotation (pour l'orientation, la justification)*/ - if( DrawLibItem->m_Transform[0][1] ) // Rotation du composant de 90deg - { - if( orient == TEXT_ORIENT_HORIZ ) - orient = TEXT_ORIENT_VERT; - else - orient = TEXT_ORIENT_HORIZ; - /* Y a t-il rotation, miroir (pour les justifications)*/ - GRTextHorizJustifyType tmp = hjustify; - hjustify = (GRTextHorizJustifyType) vjustify; - vjustify = (GRTextVertJustifyType) tmp; - if( DrawLibItem->m_Transform[1][0] < 0 ) - switch ( vjustify ) - { - case GR_TEXT_VJUSTIFY_BOTTOM: - vjustify = GR_TEXT_VJUSTIFY_TOP; - break; - case GR_TEXT_VJUSTIFY_TOP: - vjustify = GR_TEXT_VJUSTIFY_BOTTOM; - break; - default: - break; - } - if( DrawLibItem->m_Transform[1][0] > 0 ) - switch ( hjustify ) - { - case GR_TEXT_HJUSTIFY_LEFT: - hjustify = GR_TEXT_HJUSTIFY_RIGHT; - break; - case GR_TEXT_HJUSTIFY_RIGHT: - hjustify = GR_TEXT_HJUSTIFY_LEFT; - break; - default: - break; - } - } - else - { - /* Texte horizontal: Y a t-il miroir (pour les justifications)*/ - if( DrawLibItem->m_Transform[0][0] < 0 ) - switch ( hjustify ) - { - case GR_TEXT_HJUSTIFY_LEFT: - hjustify = GR_TEXT_HJUSTIFY_RIGHT; - break; - case GR_TEXT_HJUSTIFY_RIGHT: - hjustify = GR_TEXT_HJUSTIFY_LEFT; - break; - default: - break; - } - if( DrawLibItem->m_Transform[1][1] > 0 ) - switch ( vjustify ) - { - case GR_TEXT_VJUSTIFY_BOTTOM: - vjustify = GR_TEXT_VJUSTIFY_TOP; - break; - case GR_TEXT_VJUSTIFY_TOP: - vjustify = GR_TEXT_VJUSTIFY_BOTTOM; - break; - default: - break; - } - } - - if( m_FieldId == REFERENCE ) - color = ReturnLayerColor( LAYER_REFERENCEPART ); - else if( m_FieldId == VALUE ) - color = ReturnLayerColor( LAYER_VALUEPART ); - else - color = ReturnLayerColor( LAYER_FIELDS ); - - if( !m_AddExtraText || (m_FieldId != REFERENCE) ) - { - DrawGraphicText( panel, DC, pos, color, m_Text, - orient ? TEXT_ORIENT_VERT : TEXT_ORIENT_HORIZ, - m_Size, - hjustify, vjustify, LineWidth, m_Italic ); - } - else // For more than one part per package, we must add the part selection to the reference ) - { - /* Adding A ou B ... or .1 .2 ... to the reference */ - wxString fulltext = m_Text; -#if defined(KICAD_GOST) - fulltext.Append( '.'); - fulltext.Append( '1' - 1 + DrawLibItem->m_Multi ); -#else - fulltext.Append( 'A' - 1 + DrawLibItem->m_Multi ); + /* Enable this to draw the bounding box around the component to validate + * the bounding box calculations. */ +#if 0 + EDA_Rect bBox = LibEntry->GetBoundaryBox( Multi, convert ); + GRRect( &panel->m_ClipBox, DC, bBox.GetOrigin().x, bBox.GetOrigin().y, + bBox.GetEnd().x, bBox.GetEnd().y, 0, LIGHTMAGENTA ); #endif - DrawGraphicText( panel, DC, pos, color, fulltext, - orient ? TEXT_ORIENT_VERT : TEXT_ORIENT_HORIZ, - m_Size, - hjustify, vjustify, LineWidth, m_Italic ); - } } -/********************************************************************************/ -EDA_LibComponentStruct* FindLibPart( const wxChar* Name, const wxString& LibName, int Alias ) -/********************************************************************************/ - +/*****************************************************************************/ /* * Routine to find a part in one of the libraries given its name. * Name = Name of part. @@ -381,10 +164,15 @@ EDA_LibComponentStruct* FindLibPart( const wxChar* Name, const wxString& LibName * correspond a un alias * Alias = FIND_ROOT, ou Alias = FIND_ALIAS */ +/*****************************************************************************/ +EDA_LibComponentStruct* FindLibPart( const wxChar* Name, + const wxString& LibName, + int Alias ) { EDA_LibComponentStruct* Entry; - static EDA_LibComponentStruct DummyEntry( wxEmptyString ); /* Used only to call PQFind. */ + /* Used only to call PQFind. */ + static EDA_LibComponentStruct DummyEntry( wxEmptyString ); LibraryStruct* Lib = g_LibraryList; @@ -424,7 +212,8 @@ EDA_LibComponentStruct* FindLibPart( const wxChar* Name, const wxString& LibName if( Entry ) { if( (Entry->Type != ROOT ) && (Alias == FIND_ROOT) ) - Entry = FindLibPart( ( (EDA_LibCmpAliasStruct*) Entry )->m_RootName.GetData(), + Entry = FindLibPart( + ( (EDA_LibCmpAliasStruct*) Entry )->m_RootName.GetData(), Lib->m_Name, FIND_ROOT ); } @@ -433,104 +222,16 @@ EDA_LibComponentStruct* FindLibPart( const wxChar* Name, const wxString& LibName /***************************************************************************** -* Routine to draw the given part at given position, transformed/mirror as -* specified, and in the given drawing mode. -* if Color < 0: Draw in normal color -* else draw in color = Color -*****************************************************************************/ -/* DrawMode = GrXOR, GrOR ..*/ -void DrawLibPartAux( WinEDA_DrawPanel* panel, wxDC* DC, - SCH_COMPONENT* Component, - EDA_LibComponentStruct* Entry, - const wxPoint& Pos, - const int TransMat[2][2], - int Multi, int convert, int DrawMode, - int Color, bool DrawPinText ) -{ - wxPoint pos1, pos2; - LibEDA_BaseStruct* DEntry; - bool force_nofill; - - if( Entry->m_Drawings == NULL ) - return; - GRSetDrawMode( DC, DrawMode ); - - for( DEntry = Entry->m_Drawings; DEntry != NULL; DEntry = DEntry->Next() ) - { - /* Do not draw items not attached to the current part */ - if( Multi && DEntry->m_Unit && (DEntry->m_Unit != Multi) ) - continue; - - if( convert && DEntry->m_Convert && (DEntry->m_Convert != convert) ) - continue; - - if( DEntry->m_Flags & IS_MOVED ) - continue; // Do do draw here an item while moving (the cursor handler does that) - - force_nofill = false; - - switch( DEntry->Type() ) - { - case COMPONENT_PIN_DRAW_TYPE: - { - DrawPinPrms prms( Entry, DrawPinText ); - DEntry->Draw( panel, DC, Pos, Color, DrawMode, &prms, TransMat ); - } - break; - - case COMPONENT_ARC_DRAW_TYPE: - case COMPONENT_CIRCLE_DRAW_TYPE: - case COMPONENT_GRAPHIC_TEXT_DRAW_TYPE: - case COMPONENT_RECT_DRAW_TYPE: - case COMPONENT_POLYLINE_DRAW_TYPE: - default: - if( g_IsPrinting && DEntry->m_Fill == FILLED_WITH_BG_BODYCOLOR - && GetGRForceBlackPenState() ) - force_nofill = true; - DEntry->Draw( panel, DC, Pos, Color, DrawMode, (void*) force_nofill, TransMat ); - break; - } - } - - if( g_DebugLevel > 4 ) /* Draw the component boundary box */ - { - EDA_Rect BoundaryBox; - if( Component ) - BoundaryBox = Component->GetBoundaryBox(); - else - BoundaryBox = Entry->GetBoundaryBox( Multi, convert ); - int x1 = BoundaryBox.GetX(); - int y1 = BoundaryBox.GetY(); - int x2 = BoundaryBox.GetRight(); - int y2 = BoundaryBox.GetBottom(); - GRRect( &panel->m_ClipBox, DC, x1, y1, x2, y2, BROWN ); - BoundaryBox = Component->GetField( REFERENCE )->GetBoundaryBox(); - x1 = BoundaryBox.GetX(); - y1 = BoundaryBox.GetY(); - x2 = BoundaryBox.GetRight(); - y2 = BoundaryBox.GetBottom(); - GRRect( &panel->m_ClipBox, DC, x1, y1, x2, y2, BROWN ); - BoundaryBox = Component->GetField( VALUE )->GetBoundaryBox(); - x1 = BoundaryBox.GetX(); - y1 = BoundaryBox.GetY(); - x2 = BoundaryBox.GetRight(); - y2 = BoundaryBox.GetBottom(); - GRRect( &panel->m_ClipBox, DC, x1, y1, x2, y2, BROWN ); - } -} - - -/***************************************************************************** -* Routine to rotate the given angular direction by the given Transformation. * -* Input (and output) angles must be as follows: * -* Unit is 0.1 degre * -* Angle1 in [0..3600], Angle2 > Angle1 in [0..7200]. Arc is assumed to be less * -* than 180.0 degrees. * -* Algorithm: * -* Map the angles to a point on the unit circle which is mapped using the * -* transform (only mirror and rotate so it remains on the unit circle) to * -* a new point which is used to detect new angle. * -*****************************************************************************/ + * Routine to rotate the given angular direction by the given Transformation. * + * Input (and output) angles must be as follows: * + * Unit is 0.1 degre * + * Angle1 in [0..3600], Angle2 > Angle1 in [0..7200]. Arc is assumed to be * + * less than 180.0 degrees. * + * Algorithm: * + * Map the angles to a point on the unit circle which is mapped using the * + * transform (only mirror and rotate so it remains on the unit circle) to * + * a new point which is used to detect new angle. * + *****************************************************************************/ bool MapAngles( int* Angle1, int* Angle2, const int TransMat[2][2] ) { int Angle, Delta; @@ -549,22 +250,22 @@ bool MapAngles( int* Angle1, int* Angle2, const int TransMat[2][2] ) t = x * TransMat[0][0] + y * TransMat[0][1]; y = x * TransMat[1][0] + y * TransMat[1][1]; x = t; - *Angle1 = (int) (atan2( y, x ) * 1800.0 / M_PI + 0.5); + *Angle1 = (int) ( atan2( y, x ) * 1800.0 / M_PI + 0.5 ); x = cos( *Angle2 * M_PI / 1800.0 ); y = sin( *Angle2 * M_PI / 1800.0 ); t = x * TransMat[0][0] + y * TransMat[0][1]; y = x * TransMat[1][0] + y * TransMat[1][1]; x = t; - *Angle2 = (int) (atan2( y, x ) * 1800.0 / M_PI + 0.5); + *Angle2 = (int) ( atan2( y, x ) * 1800.0 / M_PI + 0.5 ); NORMALIZE_ANGLE( *Angle1 ); NORMALIZE_ANGLE( *Angle2 ); if( *Angle2 < *Angle1 ) *Angle2 += 3600; - if( *Angle2 - *Angle1 > 1800 ) - { /* Need to swap the two angles. */ + if( *Angle2 - *Angle1 > 1800 ) /* Need to swap the two angles. */ + { Angle = (*Angle1); *Angle1 = (*Angle2); *Angle2 = Angle; @@ -587,8 +288,8 @@ bool MapAngles( int* Angle1, int* Angle2, const int TransMat[2][2] ) /***************************************************************************** -* Routine to display an outline version of given library entry. * -* This routine is applied by the PlaceLibItem routine above. * +* Routine to display an outline version of given library entry. * +* This routine is applied by the PlaceLibItem routine above. * *****************************************************************************/ void DrawingLibInGhost( WinEDA_DrawPanel* panel, wxDC* DC, EDA_LibComponentStruct* LibEntry, @@ -598,25 +299,25 @@ void DrawingLibInGhost( WinEDA_DrawPanel* panel, wxDC* DC, int DrawMode = g_XorMode; DrawLibPartAux( panel, DC, DrawLibItem, LibEntry, wxPoint( PartX, PartY ), - DrawLibItem->m_Transform, - multi, convert, DrawMode, Color, DrawPinText ); + DrawLibItem->m_Transform, multi, convert, DrawMode, Color, + DrawPinText ); } /************************************************************/ /* Routine to draw One LibraryDrawStruct at given position, */ -/* matrice de transformation 1 0 0 -1 (normale) */ -/* DrawMode = GrXOR, GrOR .. */ +/* matrice de transformation 1 0 0 -1 (normale) */ +/* DrawMode = GrXOR, GrOR .. */ /************************************************************/ /* Utilise en LibEdit et Lib Browse */ void DrawLibraryDrawStruct( WinEDA_DrawPanel* aPanel, wxDC* aDC, EDA_LibComponentStruct* aLibEntry, - wxPoint aPosition, - LibEDA_BaseStruct* aDrawItem, + wxPoint aPosition, LibEDA_BaseStruct* aDrawItem, int aDrawMode, int aColor ) { int TransMat[2][2]; bool no_fill; + BASE_SCREEN* screen = aPanel->GetScreen(); GRSetDrawMode( aDC, aDrawMode ); @@ -631,9 +332,10 @@ void DrawLibraryDrawStruct( WinEDA_DrawPanel* aPanel, wxDC* aDC, case COMPONENT_PIN_DRAW_TYPE: /* Trace des Pins */ { DrawPinPrms prms( aLibEntry, true ); - aDrawItem->Draw( aPanel, aDC, aPosition, aColor, aDrawMode, &prms, TransMat ); + aDrawItem->Draw( aPanel, aDC, aPosition, aColor, aDrawMode, &prms, + TransMat ); } - break; + break; case COMPONENT_ARC_DRAW_TYPE: case COMPONENT_CIRCLE_DRAW_TYPE: @@ -641,10 +343,12 @@ void DrawLibraryDrawStruct( WinEDA_DrawPanel* aPanel, wxDC* aDC, case COMPONENT_RECT_DRAW_TYPE: case COMPONENT_POLYLINE_DRAW_TYPE: default: - if( g_IsPrinting && aDrawItem->m_Fill == FILLED_WITH_BG_BODYCOLOR - && GetGRForceBlackPenState() ) + if( screen->m_IsPrinting + && aDrawItem->m_Fill == FILLED_WITH_BG_BODYCOLOR + && GetGRForceBlackPenState() ) no_fill = true; - aDrawItem->Draw( aPanel, aDC, aPosition, aColor, aDrawMode, (void*) no_fill, TransMat ); + aDrawItem->Draw( aPanel, aDC, aPosition, aColor, aDrawMode, + (void*) no_fill, TransMat ); break; } } diff --git a/eeschema/eelibs_read_libraryfiles.cpp b/eeschema/eelibs_read_libraryfiles.cpp index bf8d573bba..363a694684 100644 --- a/eeschema/eelibs_read_libraryfiles.cpp +++ b/eeschema/eelibs_read_libraryfiles.cpp @@ -9,6 +9,7 @@ #include "confirm.h" #include "kicad_string.h" #include "gestfich.h" +#include "appl_wxstruct.h" #include "program.h" #include "libcmp.h" @@ -16,40 +17,37 @@ #include "protos.h" /* Local Functions */ -static LibEDA_BaseStruct* GetDrawEntry( WinEDA_DrawFrame* frame, FILE* f, - char* Line, int* LineNum ); -static bool GetLibEntryField( EDA_LibComponentStruct* LibEntry, char* line ); -static bool AddAliasNames( EDA_LibComponentStruct* LibEntry, char* line ); -static void InsertAlias( PriorQue** PQ, - EDA_LibComponentStruct* LibEntry, int* NumOfParts ); -static bool ReadLibEntryDateAndTime( EDA_LibComponentStruct* LibEntry, char* Line ); -static int AddFootprintFilterList( EDA_LibComponentStruct* LibEntryLibEntry, - FILE* f, char* Line, int* LineNum ); +static LibEDA_BaseStruct* GetDrawEntry( WinEDA_DrawFrame* frame, FILE* f, + char* Line, int* LineNum ); +static bool AddAliasNames( EDA_LibComponentStruct* LibEntry, char* line ); +static void InsertAlias( PriorQue** PQ, EDA_LibComponentStruct* LibEntry, + int* NumOfParts ); +static int AddFootprintFilterList( EDA_LibComponentStruct* LibEntryLibEntry, + FILE* f, char* Line, int* LineNum ); + + +// If this code was written in C++ then this would not be needed. +static wxString currentLibraryName; -static wxString currentLibraryName; // If this code was written in C++ then this would not be needed. - - - -/*************************************************************************************/ -LibraryStruct* LoadLibraryName( WinEDA_DrawFrame* frame, - const wxString& FullLibName, - const wxString& LibName ) -/*************************************************************************************/ - +/****************************************************************************/ /** Function LoadLibraryName * Routine to load the given library name. FullLibName should hold full path * of file name to open, while LibName should hold only its name. * IF library already exists, it is NOT reloaded. * @return : new lib or NULL */ +/****************************************************************************/ +LibraryStruct* LoadLibraryName( WinEDA_DrawFrame* frame, + const wxString& FullLibName, + const wxString& LibName ) { int NumOfParts; FILE* f; LibraryStruct* NewLib; PriorQue* Entries; - wxString FullFileName; + wxFileName fn; if( ( NewLib = FindLibrary( LibName ) ) != NULL ) { @@ -90,11 +88,12 @@ LibraryStruct* LoadLibraryName( WinEDA_DrawFrame* frame, tmplib->m_Pnext = NewLib; } - FullFileName = FullLibName; - ChangeFileNameExt( FullFileName, DOC_EXT ); - LoadDocLib( frame, FullFileName, NewLib->m_Name ); + fn = FullLibName; + fn.SetExt( DOC_EXT ); + LoadDocLib( frame, fn.GetFullPath(), NewLib->m_Name ); } - else{ + else + { SAFE_DELETE( NewLib ); } fclose( f ); @@ -103,51 +102,64 @@ LibraryStruct* LoadLibraryName( WinEDA_DrawFrame* frame, /******************************************/ -void LoadLibraries (WinEDA_DrawFrame* frame) -/******************************************/ - /* Function LoadLibraries * Clear all alredy loaded librries and load all librairies * given in g_LibName_List */ +/******************************************/ +void LoadLibraries (WinEDA_DrawFrame* frame) { - wxString FullLibName, msg; - wxString LibName; + wxFileName fn; + wxString msg, tmp; unsigned ii, iimax = g_LibName_List.GetCount(); - frame->PrintMsg( _( "Start loading schematic libs" ) ); + frame->PrintMsg( _( "Loading schematic component libraries" ) ); // Free the unwanted libraries (i.e. not in list) but keep the .cache lib LibraryStruct* nextlib, * lib = g_LibraryList; + for( ; lib != NULL; lib = nextlib ) { nextlib = lib->m_Pnext; if( lib->m_IsLibCache ) continue; - wxString libname = lib->m_Name; - // is this library in "wanted list" g_LibName_List ? - int test = g_LibName_List.Index( libname ); - if( test == wxNOT_FOUND ) - FreeCmpLibrary( frame, libname ); + if( g_LibName_List.Index( lib->m_Name ) == wxNOT_FOUND ) + FreeCmpLibrary( frame, lib->m_Name ); } // Load missing libraries (if any) for( ii = 0; ii < iimax; ii++ ) { - LibName = g_LibName_List[ii]; + fn = g_LibName_List[ii]; + fn.SetExt( CompLibFileExtension ); - if( LibName.IsEmpty() ) + if( !fn.IsOk() ) continue; - FullLibName = MakeFileName( g_RealLibDirBuffer, LibName, g_LibExtBuffer ); + if( !fn.FileExists() ) + { + tmp = wxGetApp().GetLibraryPathList().FindValidPath( fn.GetFullName() ); + if( !tmp ) + { + msg.Printf( _( "Library file <%s> not found." ), + fn.GetName().c_str() ); + wxMessageBox( msg, _( "Library Load Error" ), + wxOK | wxICON_ERROR, frame ); + continue; + } + } + else + { + tmp = fn.GetFullPath(); + } // Loaded library statusbar message - msg = _( "Library " ) + FullLibName; + msg = _( "Library " ) + tmp; frame->PrintMsg( msg ); - if( LoadLibraryName( frame, FullLibName, LibName ) ) + if( LoadLibraryName( frame, tmp, fn.GetName() ) ) msg += _( " loaded" ); else msg += _( " error!" ); @@ -205,12 +217,11 @@ void LoadLibraries (WinEDA_DrawFrame* frame) /**************************************************************/ -void FreeCmpLibrary (wxWindow* frame, const wxString& LibName) -/**************************************************************/ - /** Function FreeCmpLibrary * Routine to remove and free a library from the current loaded libraries. */ +/**************************************************************/ +void FreeCmpLibrary (wxWindow* frame, const wxString& LibName) { int NumOfLibs = NumOfLibraries(); LibraryStruct* Lib, * TempLib; @@ -235,7 +246,8 @@ void FreeCmpLibrary (wxWindow* frame, const wxString& LibName) g_LibraryList = Lib->m_Pnext; else { - for( TempLib = g_LibraryList; TempLib->m_Pnext != Lib; TempLib = TempLib->m_Pnext ) + for( TempLib = g_LibraryList; TempLib->m_Pnext != Lib; + TempLib = TempLib->m_Pnext ) ; TempLib->m_Pnext = TempLib->m_Pnext->m_Pnext; @@ -251,13 +263,12 @@ void FreeCmpLibrary (wxWindow* frame, const wxString& LibName) /******************************/ -const wxChar** GetLibNames() -/******************************/ - /** GetLibNames() * Routine to return pointers to all library names. * User is responsible to deallocate memory */ +/******************************/ +const wxChar** GetLibNames() { int ii, NumOfLibs = NumOfLibraries(); const wxChar** Names; @@ -279,7 +290,8 @@ const wxChar** GetLibNames() * Routine to compare two EDA_LibComponentStruct for the PriorQue module. * Comparison (insensitive case) is based on Part name. */ -int LibraryEntryCompare (EDA_LibComponentStruct* LE1, EDA_LibComponentStruct* LE2) +int LibraryEntryCompare (EDA_LibComponentStruct* LE1, + EDA_LibComponentStruct* LE2) { return LE1->m_Name.m_Text.CmpNoCase( LE2->m_Name.m_Text ); } @@ -288,11 +300,8 @@ int LibraryEntryCompare (EDA_LibComponentStruct* LE1, EDA_LibComponentStruct* LE /**************************************************/ /* Routine to load a library from given open file */ /**************************************************/ -PriorQue* LoadLibraryAux( WinEDA_DrawFrame* frame, - LibraryStruct* Library, - FILE* libfile, - int* NumOfParts ) -/**************************************************/ +PriorQue* LoadLibraryAux( WinEDA_DrawFrame* frame, LibraryStruct* Library, + FILE* libfile, int* NumOfParts ) { int LineNum = 0; char Line[1024]; @@ -313,7 +322,8 @@ PriorQue* LoadLibraryAux( WinEDA_DrawFrame* frame, if( strnicmp( Line, LIBFILE_IDENT, 10 ) != 0 ) { - msg = _( "File <" ) + Library->m_Name + _( "> is NOT EESCHEMA library!" ); + msg = _( "File <" ) + Library->m_Name + + _( "> is NOT EESCHEMA library!" ); DisplayError( frame, msg ); return NULL; } @@ -328,13 +338,11 @@ PriorQue* LoadLibraryAux( WinEDA_DrawFrame* frame, { if( strnicmp( Line, "$HEADER", 7 ) == 0 ) { - if( Library ) + if( Library && !Library->ReadHeader( libfile, &LineNum ) ) { - if( !Library->ReadHeader( libfile, &LineNum ) ) - { - msg = _( "Library <" ) + Library->m_Name + _( "> header read error" ); - DisplayError( frame, msg, 30 ); - } + msg = _( "Library <" ) + Library->m_Name + + _( "> header read error" ); + DisplayError( frame, msg, 30 ); } continue; } @@ -342,7 +350,8 @@ PriorQue* LoadLibraryAux( WinEDA_DrawFrame* frame, if( strnicmp( Line, "DEF", 3 ) == 0 ) { /* Read one DEF/ENDDEF part entry from library: */ - LibEntry = Read_Component_Definition( frame, Line, libfile, &LineNum ); + LibEntry = Read_Component_Definition( frame, Line, libfile, + &LineNum ); if( LibEntry ) { /* If we are here, this part is O.k. - put it in: */ @@ -357,15 +366,52 @@ PriorQue* LoadLibraryAux( WinEDA_DrawFrame* frame, } -/*********************************************************************************************/ +/*****************************************************************************/ +/* Analyse la ligne de description du champ de la forme: + * Fn "CA3130" 150 -200 50 H V + * ou n = 0 (REFERENCE), 1 (VALUE) , 2 .. 11 = autres champs, facultatifs + */ +/*****************************************************************************/ +static bool GetLibEntryField ( EDA_LibComponentStruct* LibEntry, char* line, + wxString& errorMsg ) +{ + LibDrawField* field = new LibDrawField(); + + if ( !field->Load( line, errorMsg ) ) + { + SAFE_DELETE( field ); + return false; + } + + switch( field->m_FieldId ) + { + case REFERENCE: + LibEntry->m_Prefix = *field; + SAFE_DELETE( field ); + break; + + case VALUE: + LibEntry->m_Name = *field; + SAFE_DELETE( field ); + break; + + default: + LibEntry->m_Fields.PushBack( field ); + break; + } + + return true; +} + + +/*****************************************************************************/ +/* Routine to Read a DEF/ENDDEF part entry from given open file. + */ +/*****************************************************************************/ EDA_LibComponentStruct* Read_Component_Definition( WinEDA_DrawFrame* frame, char* Line, FILE* f, int* LineNum ) -/*********************************************************************************************/ - -/* Routine to Read a DEF/ENDDEF part entry from given open file. - */ { int unused; char* p; @@ -374,33 +420,36 @@ EDA_LibComponentStruct* Read_Component_Definition( WinEDA_DrawFrame* frame, EDA_LibComponentStruct* LibEntry = NULL; bool Res; - wxString Msg; + wxString Msg, errorMsg; p = strtok( Line, " \t\r\n" ); if( strcmp( p, "DEF" ) != 0 ) { - Msg.Printf( wxT( "DEF command expected in line %d, aborted." ), *LineNum ); + Msg.Printf( wxT( "DEF command expected in line %d, aborted." ), + *LineNum ); DisplayError( frame, Msg ); return NULL; } /* Read DEF line: */ - char drawnum = 0, drawname = 0; + char drawnum = 0; + char drawname = 0; + LibEntry = new EDA_LibComponentStruct( NULL ); if( ( name = strtok( NULL, " \t\n" ) ) == NULL /* Part name: */ - || ( prefix = strtok( NULL, " \t\n" ) ) == NULL /* Prefix name: */ - || ( p = strtok( NULL, " \t\n" ) ) == NULL /* NumOfPins: */ - || sscanf( p, "%d", &unused ) != 1 - || ( p = strtok( NULL, " \t\n" ) ) == NULL /* TextInside: */ - || sscanf( p, "%d", &LibEntry->m_TextInside ) != 1 - || ( p = strtok( NULL, " \t\n" ) ) == NULL /* DrawNums: */ - || sscanf( p, "%c", &drawnum ) != 1 - || ( p = strtok( NULL, " \t\n" ) ) == NULL /* DrawNums: */ - || sscanf( p, "%c", &drawname ) != 1 - || ( p = strtok( NULL, " \t\n" ) ) == NULL /* m_UnitCount: */ - || sscanf( p, "%d", &LibEntry->m_UnitCount ) != 1 ) + || ( prefix = strtok( NULL, " \t\n" ) ) == NULL /* Prefix name: */ + || ( p = strtok( NULL, " \t\n" ) ) == NULL /* NumOfPins: */ + || sscanf( p, "%d", &unused ) != 1 + || ( p = strtok( NULL, " \t\n" ) ) == NULL /* TextInside: */ + || sscanf( p, "%d", &LibEntry->m_TextInside ) != 1 + || ( p = strtok( NULL, " \t\n" ) ) == NULL /* DrawNums: */ + || sscanf( p, "%c", &drawnum ) != 1 + || ( p = strtok( NULL, " \t\n" ) ) == NULL /* DrawNums: */ + || sscanf( p, "%c", &drawname ) != 1 + || ( p = strtok( NULL, " \t\n" ) ) == NULL /* m_UnitCount: */ + || sscanf( p, "%d", &LibEntry->m_UnitCount ) != 1 ) { Msg.Printf( wxT( "Wrong DEF format in line %d, skipped." ), *LineNum ); DisplayError( frame, Msg ); @@ -437,7 +486,8 @@ EDA_LibComponentStruct* Read_Component_Definition( WinEDA_DrawFrame* frame, LibEntry->m_Prefix.m_Text = CONV_FROM_UTF8( prefix ); // Copy optional infos - if( ( p = strtok( NULL, " \t\n" ) ) != NULL ) // m_UnitSelectionLocked param + // m_UnitSelectionLocked param + if( ( p = strtok( NULL, " \t\n" ) ) != NULL ) { if( *p == 'L' ) LibEntry->m_UnitSelectionLocked = TRUE; @@ -452,19 +502,22 @@ EDA_LibComponentStruct* Read_Component_Definition( WinEDA_DrawFrame* frame, /* Read next lines */ while( GetLine( f, Line, LineNum, 1024 ) ) { - p = strtok( Line, " \t\n" ); - Res = TRUE; /* This is the error flag ( if an error occurs, Res = FALSE) */ + p = strtok( Line, " \t\n" ); + + /* This is the error flag ( if an error occurs, Res = FALSE) */ + Res = TRUE; if( (Line[0] == 'T') && (Line[1] == 'i') ) { - Res = ReadLibEntryDateAndTime( LibEntry, Line ); + Res = LibEntry->LoadDateAndTime( Line ); } else if( Line[0] == 'F' ) { - Res = GetLibEntryField( LibEntry, Line ); + Res = GetLibEntryField( LibEntry, Line, errorMsg ); } else if( strcmp( p, "ENDDEF" ) == 0 ) { + p = strtok( Line, " \t\n" ); break; } else if( strcmp( p, "DRAW" ) == 0 ) @@ -473,7 +526,7 @@ EDA_LibComponentStruct* Read_Component_Definition( WinEDA_DrawFrame* frame, } else if( strncmp( p, "ALIAS", 5 ) == 0 ) { - p = strtok( NULL, "\r\n" ); + p = strtok( NULL, "\r\n" ); Res = AddAliasNames( LibEntry, p ); } else if( strncmp( p, "$FPLIST", 5 ) == 0 ) @@ -482,15 +535,23 @@ EDA_LibComponentStruct* Read_Component_Definition( WinEDA_DrawFrame* frame, } else { - Msg.Printf( wxT( "Undefined command \"%s\" in line %d, skipped." ), p, *LineNum ); + Msg.Printf( wxT( "Undefined command \"%s\" in line %d, skipped." ), + p, *LineNum ); frame->PrintMsg( Msg ); } /* End line or block analysis: test for an error */ if( !Res ) { /* Something went wrong there. */ - Msg.Printf( wxT( " Error at line %d of library \n\"%s\",\nlibrary not loaded" ), - *LineNum, currentLibraryName.GetData() ); + if( errorMsg.IsEmpty() ) + Msg.Printf( wxT( "Error at line %d of library \n\"%s\",\n" \ + "library not loaded" ), + *LineNum, currentLibraryName.GetData() ); + else + Msg.Printf( wxT( "Error <%s> at line %d of library \n\"%s\"," \ + "\nlibrary not loaded" ), + errorMsg.c_str(), *LineNum, + currentLibraryName.GetData() ); DisplayError( frame, Msg ); SAFE_DELETE( LibEntry ); return NULL; @@ -508,21 +569,14 @@ EDA_LibComponentStruct* Read_Component_Definition( WinEDA_DrawFrame* frame, * been read already. Reads upto and include ENDDRAW, or an error (NULL ret). * *****************************************************************************/ -static -LibEDA_BaseStruct* GetDrawEntry (WinEDA_DrawFrame* frame, - FILE* f, - char* Line, - int* LineNum) +static LibEDA_BaseStruct* GetDrawEntry (WinEDA_DrawFrame* frame, FILE* f, + char* Line, int* LineNum) { - int i = 0, jj, ll, Unit, Convert, size1, size2; - char* p, Buffer[1024], BufName[256], - PinNum[256], - chartmp[256], chartmp1[256]; - wxString MsgLine; - bool Error = FALSE; - LibEDA_BaseStruct* Tail = NULL, - * New = NULL, - * Head = NULL; + wxString MsgLine, errorMsg; + bool entryLoaded; + LibEDA_BaseStruct* Tail = NULL; + LibEDA_BaseStruct* New = NULL; + LibEDA_BaseStruct* Head = NULL; while( TRUE ) { @@ -542,274 +596,60 @@ LibEDA_BaseStruct* GetDrawEntry (WinEDA_DrawFrame* frame, switch( Line[0] ) { case 'A': /* Arc */ - { - int startx, starty, endx, endy; - LibDrawArc* Arc = new LibDrawArc(); - - New = Arc; - ll = 0; - int nbarg = sscanf( &Line[2], "%d %d %d %d %d %d %d %d %s %d %d %d %d", - &Arc->m_Pos.x, &Arc->m_Pos.y, &Arc->m_Rayon, - &Arc->t1, &Arc->t2, &Unit, &Convert, - &Arc->m_Width, chartmp, &startx, &starty, &endx, &endy ); - if( nbarg < 8 ) - Error = TRUE; - - Arc->m_Unit = Unit; - Arc->m_Convert = Convert; - - if( chartmp[0] == 'F' ) - Arc->m_Fill = FILLED_SHAPE; - if( chartmp[0] == 'f' ) - Arc->m_Fill = FILLED_WITH_BG_BODYCOLOR; - - NORMALIZE_ANGLE( Arc->t1 ); - NORMALIZE_ANGLE( Arc->t2 ); - - if( nbarg >= 13 ) // Actual Coordinates of arc ends are read from file - { - Arc->m_ArcStart.x = startx; Arc->m_ArcStart.y = starty; - Arc->m_ArcEnd.x = endx; Arc->m_ArcEnd.y = endy; - } - else // Actual Coordinates of arc ends are not read from file (old library), calculate them - { - Arc->m_ArcStart.x = Arc->m_Rayon; Arc->m_ArcStart.y = 0; - Arc->m_ArcEnd.x = Arc->m_Rayon; Arc->m_ArcEnd.y = 0; - RotatePoint( &Arc->m_ArcStart.x, &Arc->m_ArcStart.y, -Arc->t1 ); - Arc->m_ArcStart.x += Arc->m_Pos.x; Arc->m_ArcStart.y += Arc->m_Pos.y; - RotatePoint( &Arc->m_ArcEnd.x, &Arc->m_ArcEnd.y, -Arc->t2 ); - Arc->m_ArcEnd.x += Arc->m_Pos.x; Arc->m_ArcEnd.y += Arc->m_Pos.y; - } - } + New = ( LibEDA_BaseStruct* ) new LibDrawArc(); + entryLoaded = New->Load( Line, errorMsg ); break; case 'C': /* Circle */ - { - LibDrawCircle* Circle = new LibDrawCircle(); - - New = Circle; ll = 0; - Error = sscanf( &Line[2], "%d %d %d %d %d %d %s", - &Circle->m_Pos.x, &Circle->m_Pos.y, &Circle->m_Rayon, - &Unit, &Convert, &Circle->m_Width, chartmp ) < 6; - Circle->m_Unit = Unit; - Circle->m_Convert = Convert; - if( chartmp[0] == 'F' ) - Circle->m_Fill = FILLED_SHAPE; - if( chartmp[0] == 'f' ) - Circle->m_Fill = FILLED_WITH_BG_BODYCOLOR; - } + New = ( LibEDA_BaseStruct* ) new LibDrawCircle(); + entryLoaded = New->Load( Line, errorMsg ); break; case 'T': /* Text */ - { - LibDrawText* Text = new LibDrawText(); - - New = Text; - Buffer[0] = 0; - chartmp[0] = 0; // For italic option, Not in old versions - int thickness = 0; // Not in old versions - Error = sscanf( &Line[2], "%d %d %d %d %d %d %d %s %s %d", - &Text->m_Orient, - &Text->m_Pos.x, &Text->m_Pos.y, - &Text->m_Size.x, &Text->m_Attributs, - &Unit, &Convert, Buffer, chartmp, &thickness ) < 8; - - Text->m_Unit = Unit; Text->m_Convert = Convert; - Text->m_Size.y = Text->m_Size.x; - if ( strnicmp(chartmp, "Italic", 6) == 0 ) - Text->m_Italic = true; - - Text->m_Width = thickness; - - if( !Error ) - { /* Convert '~' to spaces. */ - Text->m_Text = CONV_FROM_UTF8( Buffer ); - Text->m_Text.Replace( wxT( "~" ), wxT( " " ) ); // Les espaces sont restitu�s - } - } + New = ( LibEDA_BaseStruct* ) new LibDrawText(); + entryLoaded = New->Load( Line, errorMsg ); break; case 'S': /* Square */ - { - LibDrawSquare* Square = new LibDrawSquare(); - - New = Square; ll = 0; - Error = sscanf( &Line[2], "%d %d %d %d %d %d %d %s", - &Square->m_Pos.x, &Square->m_Pos.y, - &Square->m_End.x, &Square->m_End.y, - &Unit, &Convert, &Square->m_Width, chartmp ) < 7; - Square->m_Unit = Unit; Square->m_Convert = Convert; - if( chartmp[0] == 'F' ) - Square->m_Fill = FILLED_SHAPE; - if( chartmp[0] == 'f' ) - Square->m_Fill = FILLED_WITH_BG_BODYCOLOR; - } + New = ( LibEDA_BaseStruct* ) new LibDrawSquare(); + entryLoaded = New->Load( Line, errorMsg ); break; case 'X': /* Pin Description */ - { - *Buffer = 0; - LibDrawPin* Pin = new LibDrawPin(); - - New = Pin; - i = sscanf( Line + 2, "%s %s %d %d %d %s %d %d %d %d %s %s", - BufName, PinNum, - &Pin->m_Pos.x, &Pin->m_Pos.y, - &ll, chartmp1, - &size1, &size2, - &Unit, &Convert, chartmp, Buffer ); - - Pin->m_PinNumSize = size1; /* Parametres type short */ - Pin->m_PinNameSize = size2; - Pin->m_PinLen = ll; - Pin->m_Orient = chartmp1[0] & 255; - - Pin->m_Unit = Unit; - Pin->m_Convert = Convert; - - strncpy( (char*) &Pin->m_PinNum, PinNum, 4 ); - - Error = (i != 11 && i != 12); - - Pin->m_PinName = CONV_FROM_UTF8( BufName ); - - jj = *chartmp & 255; - - switch( jj ) - { - case 'I': - Pin->m_PinType = PIN_INPUT; break; - - case 'O': - Pin->m_PinType = PIN_OUTPUT; break; - - case 'B': - Pin->m_PinType = PIN_BIDI; break; - - case 'T': - Pin->m_PinType = PIN_TRISTATE; break; - - case 'P': - Pin->m_PinType = PIN_PASSIVE; break; - - case 'U': - Pin->m_PinType = PIN_UNSPECIFIED; break; - - case 'W': - Pin->m_PinType = PIN_POWER_IN; break; - - case 'w': - Pin->m_PinType = PIN_POWER_OUT; break; - - case 'C': - Pin->m_PinType = PIN_OPENCOLLECTOR; break; - - case 'E': - Pin->m_PinType = PIN_OPENEMITTER; break; - - default: - MsgLine.Printf( wxT( "Unknown Pin Type [%c] line %d" ), - jj, *LineNum ); - DisplayError( frame, MsgLine ); - } - - if( i == 12 ) /* Special Symbole defined */ - { - for( jj = strlen( Buffer ); jj > 0; ) - { - switch( Buffer[--jj] ) - { - case '~': - break; - - case 'N': - Pin->m_Attributs |= PINNOTDRAW; break; - - case 'I': - Pin->m_PinShape |= INVERT; break; - - case 'C': - Pin->m_PinShape |= CLOCK; break; - - case 'L': - Pin->m_PinShape |= LOWLEVEL_IN; break; - - case 'V': - Pin->m_PinShape |= LOWLEVEL_OUT; break; - - default: - MsgLine.Printf( wxT( "Unknown Pin Shape [%c] line %d" ), - Buffer[jj], *LineNum ); - DisplayError( frame, MsgLine ); break; - } - } - } - } + New = ( LibEDA_BaseStruct* ) new LibDrawPin(); + entryLoaded = New->Load( Line, errorMsg ); break; case 'P': /* Polyline */ - { - LibDrawPolyline* Polyl = new LibDrawPolyline(); - int ccount = 0; - New = Polyl; - - if( sscanf( &Line[2], "%d %d %d %d", - &ccount, &Unit, &Convert, - &Polyl->m_Width ) == 4 - && ccount > 0 ) - { - Polyl->m_Unit = Unit; Polyl->m_Convert = Convert; - p = strtok( &Line[2], " \t\n" ); - p = strtok( NULL, " \t\n" ); - p = strtok( NULL, " \t\n" ); - p = strtok( NULL, " \t\n" ); - - for( i = 0; i < ccount && !Error; i++ ) - { - wxPoint point; - p = strtok( NULL, " \t\n" ); - Error = sscanf( p, "%d", &point.x ) != 1; - p = strtok( NULL, " \t\n" ); - Error = Error || sscanf( p, "%d", &point.y ) != 1; - Polyl->AddPoint(point); - } - - Polyl->m_Fill = NO_FILL; - if( ( p = strtok( NULL, " \t\n" ) ) != NULL ) - { - if( p[0] == 'F' ) - Polyl->m_Fill = FILLED_SHAPE; - if( p[0] == 'f' ) - Polyl->m_Fill = FILLED_WITH_BG_BODYCOLOR; - } - } - else - Error = TRUE; - } + New = ( LibEDA_BaseStruct* ) new LibDrawPolyline(); + entryLoaded = New->Load( Line, errorMsg ); break; default: - MsgLine.Printf( wxT( "Undefined DRAW command in line %d\n%s, aborted." ), - *LineNum, Line ); + MsgLine.Printf( wxT( "Undefined DRAW command in line %d\n" \ + "%s, aborted." ), *LineNum, Line ); DisplayError( frame, MsgLine ); return Head; } - if( Error ) + if( !entryLoaded ) { - MsgLine.Printf( wxT( "Error in %c DRAW command in line %d, aborted." ), - Line[0], *LineNum ); + MsgLine.Printf( wxT( "> in DRAW command %c in line %d" ), Line[0], + *LineNum ); + MsgLine = wxT( "Error <" ) + errorMsg + MsgLine + + wxT( ", aborted." ); DisplayError( frame, MsgLine ); SAFE_DELETE( New ); /* FLush till end of draw: */ - do { - if( GetLine( f, Line, LineNum, 1024 ) == NULL ) + do + { + if( GetLine( f, Line, LineNum, 1024 ) == NULL ) { DisplayError( frame, wxT( "File ended prematurely" ) ); return Head; } - } while( strncmp( Line, "ENDDRAW", 7 ) != 0 ); + } while( strncmp( Line, "ENDDRAW", 7 ) != 0 ); return Head; } @@ -850,8 +690,7 @@ LibraryStruct* FindLibrary (const wxString& Name) /***************************************************************************** * Routine to find the number of libraries currently loaded. * *****************************************************************************/ -int -NumOfLibraries() +int NumOfLibraries() { int ii; LibraryStruct* Lib = g_LibraryList; @@ -863,135 +702,12 @@ NumOfLibraries() } -/*****************************************************************************/ -static bool GetLibEntryField (EDA_LibComponentStruct* LibEntry, - char* line) -/*****************************************************************************/ - -/* Analyse la ligne de description du champ de la forme: - * Fn "CA3130" 150 -200 50 H V - * ou n = 0 (REFERENCE), 1 (VALUE) , 2 .. 11 = autres champs, facultatifs - */ -{ - int posx, posy, size, orient; - bool draw; - char* Text, - Char1[256], Char2[256], - Char3[256], Char4[256], - FieldUserName[1024]; - int NumOfField, nbparam; - LibDrawField* Field = NULL; - - if( sscanf( line + 1, "%d", &NumOfField ) != 1 ) - return 0; - - /* Recherche du debut des donnees (debut du texte suivant) */ - while( *line != 0 ) - line++; - - while( *line == 0 ) - line++; - - /* recherche du texte */ - while( *line && (*line != '"') ) - line++; - - if( *line == 0 ) - return 0; - line++; - Text = line; - - /* recherche fin de texte */ - while( *line && (*line != '"') ) - line++; - - if( *line == 0 ) - return 0; - *line = 0; - line++; - - FieldUserName[0] = 0; - memset( Char4, 0, sizeof(Char4)); - nbparam = sscanf( line, " %d %d %d %c %c %c %s", - &posx, &posy, &size, Char1, Char2, Char3, Char4 ); - orient = TEXT_ORIENT_HORIZ; - - if( Char1[0] == 'V' ) - orient = TEXT_ORIENT_VERT; - draw = TRUE; if( Char2[0] == 'I' ) - draw = FALSE; - - GRTextHorizJustifyType hjustify = GR_TEXT_HJUSTIFY_CENTER; - GRTextVertJustifyType vjustify = GR_TEXT_VJUSTIFY_CENTER; - - if( nbparam >= 6 ) - { - if( *Char3 == 'L' ) - hjustify = GR_TEXT_HJUSTIFY_LEFT; - else if( *Char3 == 'R' ) - hjustify = GR_TEXT_HJUSTIFY_RIGHT; - if( Char4[0] == 'B' ) - vjustify = GR_TEXT_VJUSTIFY_BOTTOM; - else if( Char4[0] == 'T' ) - vjustify = GR_TEXT_VJUSTIFY_TOP; - } - - switch( NumOfField ) - { - case REFERENCE: - Field = &LibEntry->m_Prefix; - Field->m_FieldId = REFERENCE; - break; - - case VALUE: - Field = &LibEntry->m_Name; - Field->m_FieldId = VALUE; - break; - - default: - Field = new LibDrawField( NumOfField ); - LibEntry->m_Fields.PushBack( Field ); - break; - } - - if( Field == NULL ) - return FALSE; - - Field->m_Pos.x = posx; Field->m_Pos.y = posy; - Field->m_Orient = orient; - - if ( Char4[1] == 'I' ) // Italic - Field->m_Italic = true; - if ( Char4[2] == 'B' ) // Bold - Field->m_Width = size / 4; - - if( draw == FALSE ) - Field->m_Attributs |= TEXT_NO_VISIBLE; - - Field->m_Size.x = Field->m_Size.y = size; - Field->m_Text = CONV_FROM_UTF8( Text ); - - if( NumOfField >= FIELD1 ) - { - ReadDelimitedText( FieldUserName, line, sizeof(FieldUserName) ); - Field->m_Name = CONV_FROM_UTF8( FieldUserName ); - } - - Field->m_HJustify = hjustify; - Field->m_VJustify = vjustify; - return TRUE; -} - - /********************************************************************/ -static bool -AddAliasNames (EDA_LibComponentStruct* LibEntry, - char* line ) -/********************************************************************/ - /* Read the alias names (in buffer line) and add them in alias list * names are separated by spaces */ +/********************************************************************/ +static bool AddAliasNames (EDA_LibComponentStruct* LibEntry, char* line ) { char* text; wxString name; @@ -1009,13 +725,11 @@ AddAliasNames (EDA_LibComponentStruct* LibEntry, } -/********************************************************************/ -static void -InsertAlias (PriorQue** PQ, - EDA_LibComponentStruct* LibEntry, - int* NumOfParts) /********************************************************************/ /* create in library (in list PQ) aliases of the "root" component LibEntry*/ +/********************************************************************/ +static void InsertAlias (PriorQue** PQ, EDA_LibComponentStruct* LibEntry, + int* NumOfParts) { EDA_LibCmpAliasStruct* AliasEntry; unsigned ii; @@ -1025,8 +739,9 @@ InsertAlias (PriorQue** PQ, for( ii = 0; ii < LibEntry->m_AliasList.GetCount(); ii++ ) { - AliasEntry = new EDA_LibCmpAliasStruct( LibEntry->m_AliasList[ii], - LibEntry->m_Name.m_Text.GetData() ); + AliasEntry = + new EDA_LibCmpAliasStruct( LibEntry->m_AliasList[ii], + LibEntry->m_Name.m_Text.GetData() ); ++ * NumOfParts; PQInsert( PQ, AliasEntry ); @@ -1038,13 +753,9 @@ InsertAlias (PriorQue** PQ, /* Routines de lecture des Documentation de composants */ /*******************************************************/ -/**********************************************************************************************/ -int -LoadDocLib (WinEDA_DrawFrame* frame, - const wxString& FullDocLibName, - const wxString& Libname) -/**********************************************************************************************/ /* Routine to load a library from given open file.*/ +int LoadDocLib( WinEDA_DrawFrame* frame, const wxString& FullDocLibName, + const wxString& Libname ) { int LineNum = 0; char Line[1024], * Name, * Text; @@ -1074,7 +785,8 @@ LoadDocLib (WinEDA_DrawFrame* frame, { if( strncmp( Line, "$CMP", 4 ) != 0 ) { - msg.Printf( wxT( "$CMP command expected in line %d, aborted." ), LineNum ); + msg.Printf( wxT( "$CMP command expected in line %d, aborted." ), + LineNum ); DisplayError( frame, msg ); fclose( f ); return 0; @@ -1082,7 +794,8 @@ LoadDocLib (WinEDA_DrawFrame* frame, /* Read one $CMP/$ENDCMP part entry from library: */ Name = strtok( Line + 5, "\n\r" ); - wxString cmpname; cmpname = CONV_FROM_UTF8( Name ); + wxString cmpname; + cmpname = CONV_FROM_UTF8( Name ); Entry = FindLibPart( cmpname.GetData(), Libname, FIND_ALIAS ); while( GetLine( f, Line, &LineNum, sizeof(Line) ) ) { @@ -1115,227 +828,15 @@ LoadDocLib (WinEDA_DrawFrame* frame, } -/*********************************************************************************/ -static bool -ReadLibEntryDateAndTime (EDA_LibComponentStruct* LibEntry, - char* Line ) -/*********************************************************************************/ - -/* lit date et time de modif composant sous le format: - * "Ti yy/mm/jj hh:mm:ss" - */ -{ - int year, mon, day, hour, min, sec; - char* text; - - year = mon = day = hour = min = sec = 0; - text = strtok( Line, " \r\t\n" ); - text = strtok( NULL, " \r\t\n" ); // text pointe donnees utiles - - sscanf( Line, "%d/%d/%d %d:%d:%d", &year, &mon, &day, &hour, &min, &sec ); - - LibEntry->m_LastDate = (sec & 63) - + ( (min & 63) << 6 ) - + ( (hour & 31) << 12 ) - + ( (day & 31) << 17 ) - + ( (mon & 15) << 22 ) - + ( (year - 1990) << 26 ); - - return TRUE; -} - - -/*******************************************/ -static int -SortItemsFct (const void* ref, - const void* item ); - -void -EDA_LibComponentStruct::SortDrawItems() -/*******************************************/ -/* TODO translate comment to english TODO - * Trie les �l�ments graphiques d'un composant lib pour am�liorer - * le trac�: - * items remplis en premier, pins en dernier - * En cas de superposition d'items, c'est plus lisible - */ -{ - LibEDA_BaseStruct** Bufentry, ** BufentryBase, * Entry = m_Drawings; - int ii, nbitems; - - if( Entry == NULL ) - return; /* Pas d'alias pour ce composant */ - /* calcul du nombre d'items */ - for( nbitems = 0; Entry != NULL; Entry = Entry->Next() ) - nbitems++; - - BufentryBase = - (LibEDA_BaseStruct**) MyZMalloc( (nbitems + 1) * sizeof(LibEDA_BaseStruct*) ); - - /* memorisation du chainage : */ - for( Entry = m_Drawings, ii = 0; Entry != NULL; Entry = Entry->Next() ) - BufentryBase[ii++] = Entry; - - /* Tri du chainage */ - qsort( BufentryBase, nbitems, sizeof(LibEDA_BaseStruct*), SortItemsFct ); - - /* Mise a jour du chainage. Remarque: - * le dernier element de BufEntryBase (BufEntryBase[nbitems]) est NULL*/ - m_Drawings = *BufentryBase; - Bufentry = BufentryBase; - for( ii = 0; ii < nbitems; ii++ ) - { - (*Bufentry)->SetNext( *(Bufentry + 1) ); - Bufentry++; - } - - MyFree( BufentryBase ); -} - - -int -SortItemsFct(const void* ref, - const void* item) -{ -#define Ref ( *(LibEDA_BaseStruct**) (ref) ) -#define Item ( *(LibEDA_BaseStruct**) (item) ) -#define BEFORE -1 -#define AFTER 1 - - int fill_ref = 0, fill_item = 0; - - switch( Ref->Type() ) - { - case COMPONENT_ARC_DRAW_TYPE: - { - const LibDrawArc* draw = (const LibDrawArc*) Ref; - fill_ref = draw->m_Fill; - break; - } - - case COMPONENT_CIRCLE_DRAW_TYPE: - { - const LibDrawCircle* draw = (const LibDrawCircle*) Ref; - fill_ref = draw->m_Fill; - break; - } - - case COMPONENT_RECT_DRAW_TYPE: - { - const LibDrawSquare* draw = (const LibDrawSquare*) Ref; - fill_ref = draw->m_Fill; - break; - } - - case COMPONENT_POLYLINE_DRAW_TYPE: - { - const LibDrawPolyline* draw = (const LibDrawPolyline*) Ref; - fill_ref = draw->m_Fill; - break; - } - - case COMPONENT_GRAPHIC_TEXT_DRAW_TYPE: - if( Item->Type() == COMPONENT_PIN_DRAW_TYPE ) - return BEFORE; - if( Item->Type() == COMPONENT_GRAPHIC_TEXT_DRAW_TYPE ) - return 0; - return 1; - break; - - case COMPONENT_PIN_DRAW_TYPE: - if( Item->Type() == COMPONENT_PIN_DRAW_TYPE ) - { - int ii; - - // We sort the pins by orientation - ii = ( (LibDrawPin*) Ref )->m_Orient - ( (LibDrawPin*) Item )->m_Orient; - if( ii ) - return ii; - - /* We sort the pins by position (x or y). - * note: at this point, most of pins have same x pos or y pos, - * because they are sorted by orientation and generally are vertically or - * horizontally aligned */ - wxPoint pos_ref, pos_tst; - pos_ref = ( (LibDrawPin*) Ref )->m_Pos; - pos_tst = ( (LibDrawPin*) Item )->m_Pos; - if( (ii = pos_ref.x - pos_tst.x) ) - return ii; - ii = pos_ref.y - pos_tst.y; - return ii; - } - else - return AFTER; - break; - - default: - ; - } - - /* Test de l'item */ - switch( Item->Type() ) - { - case COMPONENT_ARC_DRAW_TYPE: - { - const LibDrawArc* draw = (const LibDrawArc*) Item; - fill_item = draw->m_Fill; - break; - } - - case COMPONENT_CIRCLE_DRAW_TYPE: - { - const LibDrawCircle* draw = (const LibDrawCircle*) Item; - fill_item = draw->m_Fill; - break; - } - - case COMPONENT_RECT_DRAW_TYPE: - { - const LibDrawSquare* draw = (const LibDrawSquare*) Item; - fill_item = draw->m_Fill; - break; - } - - case COMPONENT_POLYLINE_DRAW_TYPE: - { - const LibDrawPolyline* draw = (const LibDrawPolyline*) Item; - fill_item = draw->m_Fill; - break; - } - - case COMPONENT_GRAPHIC_TEXT_DRAW_TYPE: - return BEFORE; - break; - - case COMPONENT_PIN_DRAW_TYPE: - return BEFORE; - break; - - default: - ; - } - - if( fill_ref & fill_item ) - return 0; - if( fill_ref ) - return BEFORE; - return AFTER; -} - - /*****************************************************************************/ -int -AddFootprintFilterList(EDA_LibComponentStruct* LibEntryLibEntry, - FILE* f, - char* Line, - int* LineNum) -/******************************************************************************/ - /* read the FootprintFilter List stating with: * FPLIST * and ending with: * ENDFPLIST */ +/*****************************************************************************/ +int AddFootprintFilterList(EDA_LibComponentStruct* LibEntryLibEntry, + FILE* f, char* Line, int* LineNum) { for( ; ; ) { diff --git a/eeschema/eeredraw.cpp b/eeschema/eeredraw.cpp index 7520ff6544..a53d1a3701 100644 --- a/eeschema/eeredraw.cpp +++ b/eeschema/eeredraw.cpp @@ -7,6 +7,8 @@ #include "gr_basic.h" #include "common.h" #include "class_drawpanel.h" +#include "class_drawpickedstruct.h" +#include "appl_wxstruct.h" #include "program.h" #include "libcmp.h" @@ -14,47 +16,18 @@ #include "protos.h" -char marq_bitmap[] = -{ - 12, 12, 0, 0, /* Dimensions x et y, offsets x et y du bitmap de marqueurs*/ - YELLOW, /* Couleur */ - 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, /* bitmap: >= 1 : color, 0 = notrace */ - 1, 1, 1, 0, 1, 0, 1, 1, 0, 0, 0, 0, - 1, 1, 1, 1, 0, 0, 0, 1, 0, 0, 0, 0, - 1, 0, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, - 1, 1, 0, 1, 1, 1, 0, 0, 0, 0, 0, 0, - 1, 1, 0, 0, 1, 1, 1, 0, 0, 0, 0, 0, - 1, 1, 1, 0, 0, 1, 1, 1, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 1, 1, 1, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0 -}; - -char marqERC_bitmap[] = -{ - 8, 8, 0, 0, /* Dimensions x et y , offsets x et y du bitmap de marqueurs*/ - -1, /* Color: -1 = couleur non pr�cis�e */ - 1, 1, 1, 1, 1, 0, 0, 0, - 1, 1, 1, 0, 1, 0, 0, 0, - 1, 1, 1, 1, 0, 0, 0, 0, - 1, 0, 1, 1, 1, 0, 0, 0, - 1, 1, 0, 1, 1, 1, 0, 0, - 0, 0, 0, 0, 1, 1, 1, 0, - 0, 0, 0, 0, 0, 1, 1, 1, - 0, 0, 0, 0, 0, 0, 1, 0, -}; +extern char marq_bitmap[]; static EDA_BaseStruct* HighLightStruct = NULL; -/************************************************************/ + void DrawDanglingSymbol( WinEDA_DrawPanel* panel, wxDC* DC, const wxPoint& pos, int Color ) -/************************************************************/ { - if( !g_IsPrinting ) // Draw but do not print the Dangling Symbol */ + BASE_SCREEN* screen = panel->GetScreen(); + + if( !screen->m_IsPrinting ) /* Draw but do not print the Dangling Symbol */ { GRRect( &panel->m_ClipBox, DC, pos.x - DANGLING_SYMBOL_SIZE, pos.y - DANGLING_SYMBOL_SIZE, @@ -64,21 +37,16 @@ void DrawDanglingSymbol( WinEDA_DrawPanel* panel, wxDC* DC, } -/*************************************************/ void SetHighLightStruct( EDA_BaseStruct* HighLight ) -/*************************************************/ { HighLightStruct = HighLight; } -/**********************************************************************/ -void WinEDA_SchematicFrame::RedrawActiveWindow( wxDC* DC, bool EraseBg ) -/**********************************************************************/ - /* * Redraws only the active window which is assumed to be whole visible. */ +void WinEDA_SchematicFrame::RedrawActiveWindow( wxDC* DC, bool EraseBg ) { wxString title; @@ -104,7 +72,8 @@ void WinEDA_SchematicFrame::RedrawActiveWindow( wxDC* DC, bool EraseBg ) DrawPanel->DrawBackGround( DC ); - RedrawStructList( DrawPanel, DC, GetScreen()->EEDrawList, GR_DEFAULT_DRAWMODE ); + RedrawStructList( DrawPanel, DC, GetScreen()->EEDrawList, + GR_DEFAULT_DRAWMODE ); TraceWorkSheet( DC, GetScreen(), g_DrawMinimunLineWidth ); @@ -114,14 +83,15 @@ void WinEDA_SchematicFrame::RedrawActiveWindow( wxDC* DC, bool EraseBg ) DrawPanel->ManageCurseur( DrawPanel, DC, FALSE ); } - Affiche_Status_Box(); + UpdateStatusBar(); GetScreen()->ClrRefreshReq(); // Display the sheet filename, and the sheet path, for non root sheets - if( GetScreen()->m_FileName == g_DefaultSchematicFileName ) // This is the root sheet + if( GetScreen()->m_FileName == g_DefaultSchematicFileName ) { - wxString msg = g_Main_Title + wxT( " " ) + GetBuildVersion(); - title.Printf( wxT( "%s [%s]" ), msg.GetData(), GetScreen()->m_FileName.GetData() ); + wxString msg = wxGetApp().GetAppName() + wxT( " " ) + GetBuildVersion(); + title.Printf( wxT( "%s [%s]" ), msg.GetData(), + GetScreen()->m_FileName.GetData() ); SetTitle( title ); } else @@ -134,14 +104,8 @@ void WinEDA_SchematicFrame::RedrawActiveWindow( wxDC* DC, bool EraseBg ) } -/******************************************************************************************************/ -void WinEDA_DrawPanel::PrintPage( wxDC* DC, - bool Print_Sheet_Ref, - int PrintMask, - bool aPrintMirrorMode ) -/******************************************************************************************************/ - -/** PrintPage +/** + * PrintPage * used to print a page. * Print the page pointed by ActiveScreen, set by the calling print function * @param DC = wxDC given by the calling print function @@ -149,6 +113,8 @@ void WinEDA_DrawPanel::PrintPage( wxDC* DC, * @param PrintMask = not used here * @param aPrintMirrorMode = not used here (Set when printing in mirror mode) */ +void WinEDA_DrawPanel::PrintPage( wxDC* DC, bool Print_Sheet_Ref, + int PrintMask, bool aPrintMirrorMode ) { wxBeginBusyCursor(); @@ -172,7 +138,8 @@ void RedrawStructList( WinEDA_DrawPanel* panel, wxDC* DC, { if( Structs->Type() == DRAW_PICK_ITEM_STRUCT_TYPE ) { - SCH_ITEM* item = ( (DrawPickedStruct*) Structs )->m_PickedStruct; + SCH_ITEM* item = + (SCH_ITEM*) ( (DrawPickedStruct*) Structs )->m_PickedStruct; // uncomment line below when there is a virtual EDA_BaseStruct::GetBoundingBox() // if( panel->m_ClipBox.Intersects( item->GetBoundingBox() ) ) @@ -211,189 +178,14 @@ void RedrawOneStruct( WinEDA_DrawPanel* panel, wxDC* DC, } -/****************************************************************************/ -/* Draw wires, Bus, and dashed liges.. */ -/****************************************************************************/ -void EDA_DrawLineStruct::Draw( WinEDA_DrawPanel* panel, wxDC* DC, - const wxPoint& offset, int DrawMode, int Color ) -{ - int color; - int width = m_Width; - - if( Color >= 0 ) - color = Color; - else - color = ReturnLayerColor( m_Layer ); - - GRSetDrawMode( DC, DrawMode ); - - // Busses are draw with thick lines - if( m_Layer == LAYER_BUS ) - width = MAX( m_Width, MIN_BUSLINES_THICKNESS ); - - width = MAX( width, g_DrawMinimunLineWidth ); - - if( m_Layer == LAYER_NOTES ) - GRDashedLine( &panel->m_ClipBox, DC, m_Start.x + offset.x, - m_Start.y + offset.y, m_End.x + offset.x, - m_End.y + offset.y, width, color ); - else - GRLine( &panel->m_ClipBox, DC, m_Start.x + offset.x, - m_Start.y + offset.y, m_End.x + offset.x, m_End.y + offset.y, - width, color ); - - if( m_StartIsDangling ) - DrawDanglingSymbol( panel, DC, m_Start + offset, color ); - - if( m_EndIsDangling ) - DrawDanglingSymbol( panel, DC, m_End + offset, color ); -} - - -/****************************************************************************************/ -void DrawMarkerStruct::Draw( WinEDA_DrawPanel* panel, wxDC* DC, const wxPoint& offset, - int DrawMode, int Color ) -/****************************************************************************************/ -{ -#define WAR 1 // utilis� aussi dans erc.cpp - - if( m_Type == MARQ_ERC ) - { - int color = Color; - if( Color <= 0 ) - { - color = (m_MarkFlags == WAR ) ? - g_LayerDescr.LayerColor[LAYER_ERC_WARN] : - g_LayerDescr.LayerColor[LAYER_ERC_ERR]; - } - Draw_Marqueur( panel, DC, m_Pos + offset, marqERC_bitmap, DrawMode, color ); - } - else - Draw_Marqueur( panel, DC, m_Pos + offset, marq_bitmap, DrawMode, Color ); -} - - -/*************************************************************************/ -void DrawNoConnectStruct::Draw( WinEDA_DrawPanel* panel, wxDC* DC, const wxPoint& offset, - int DrawMode, int Color ) -/*************************************************************************/ -/* DRaw the "No Connect" symbol.. */ -{ - const int DELTA = (DRAWNOCONNECT_SIZE / 2); - int pX, pY, color; - int width = g_DrawMinimunLineWidth; - - pX = m_Pos.x + offset.x; pY = m_Pos.y + offset.y; - - if( Color >= 0 ) - color = Color; - else - color = ReturnLayerColor( LAYER_NOCONNECT ); - GRSetDrawMode( DC, DrawMode ); - - GRLine( &panel->m_ClipBox, DC, pX - DELTA, pY - DELTA, pX + DELTA, pY + DELTA, width, color ); - GRLine( &panel->m_ClipBox, DC, pX + DELTA, pY - DELTA, pX - DELTA, pY + DELTA, width, color ); -} - - -/**************************************************************/ -void DrawBusEntryStruct::Draw( WinEDA_DrawPanel* panel, wxDC* DC, const wxPoint& offset, - int DrawMode, int Color ) -/***************************************************************/ - -/* Draw the bus entries .. */ - -{ - int color; - int width = m_Width; - - if( Color >= 0 ) - color = Color; - else - color = ReturnLayerColor( m_Layer ); - GRSetDrawMode( DC, DrawMode ); - - if( m_Layer == LAYER_BUS ) - width = MAX( m_Width, MIN_BUSLINES_THICKNESS ); - - width = MAX( width, g_DrawMinimunLineWidth ); - - GRLine( &panel->m_ClipBox, DC, m_Pos.x + offset.x, m_Pos.y + offset.y, - m_End().x + offset.x, m_End().y + offset.y, width, color ); -} - - - -/***************************************************************************** -* Routine to redraw polyline struct. * -*****************************************************************************/ -void DrawPolylineStruct::Draw( WinEDA_DrawPanel* panel, wxDC* DC, const wxPoint& offset, - int DrawMode, int Color ) -{ - int color; - int width = m_Width; - - if( Color >= 0 ) - color = Color; - else - color = ReturnLayerColor( m_Layer ); - - GRSetDrawMode( DC, DrawMode ); - - if( m_Layer == LAYER_BUS ) - width = MAX( m_Width, MIN_BUSLINES_THICKNESS ); - - width = MAX( width, g_DrawMinimunLineWidth ); - - GRMoveTo( m_PolyPoints[0].x, m_PolyPoints[0].y ); - if( m_Layer == LAYER_NOTES ) - { - for( unsigned i = 1; i < GetCornerCount(); i++ ) - GRDashedLineTo( &panel->m_ClipBox, DC, m_PolyPoints[i].x + offset.x, - m_PolyPoints[i].y + offset.y, width, color ); - } - else - { - for( unsigned i = 1; i < GetCornerCount(); i++ ) - GRLineTo( &panel->m_ClipBox, - DC, - m_PolyPoints[i].x + offset.x, - m_PolyPoints[i].y + offset.y, - width, - color ); - } -} - - -/***************************************************************************** -* Routine to redraw connection struct. * -*****************************************************************************/ -void DrawJunctionStruct::Draw( WinEDA_DrawPanel* panel, wxDC* DC, const wxPoint& offset, - int DrawMode, int Color ) -{ - int color; - - if( Color >= 0 ) - color = Color; - else - color = ReturnLayerColor( m_Layer ); - GRSetDrawMode( DC, DrawMode ); - - GRFilledCircle( &panel->m_ClipBox, DC, m_Pos.x + offset.x, m_Pos.y + offset.y, - DRAWJUNCTION_SIZE, 0, color, color ); -} - - -/**********************************************************/ -void DrawStructsInGhost( WinEDA_DrawPanel* panel, wxDC* DC, - SCH_ITEM* DrawStruct, int dx, int dy ) -/**********************************************************/ /* Routine de redessin en mode fantome (Dessin simplifie en g_XorMode et * g_GhostColor * de structures. * Utilisee dans les deplacements de blocs */ +void DrawStructsInGhost( WinEDA_DrawPanel* panel, wxDC* DC, + SCH_ITEM* DrawStruct, int dx, int dy ) { int DrawMode = g_XorMode; int width = g_DrawMinimunLineWidth; @@ -406,7 +198,8 @@ void DrawStructsInGhost( WinEDA_DrawPanel* panel, wxDC* DC, case DRAW_POLYLINE_STRUCT_TYPE: { DrawPolylineStruct* Struct = (DrawPolylineStruct*) DrawStruct; - GRMoveTo( Struct->m_PolyPoints[0].x + dx, Struct->m_PolyPoints[0].y + dy ); + GRMoveTo( Struct->m_PolyPoints[0].x + dx, + Struct->m_PolyPoints[0].y + dy ); for( unsigned ii = 1; ii < Struct->GetCornerCount(); ii++ ) GRLineTo( &panel->m_ClipBox, DC, Struct->m_PolyPoints[ii].x + dx, Struct->m_PolyPoints[ii].y + dy, width, g_GhostColor ); @@ -428,16 +221,13 @@ void DrawStructsInGhost( WinEDA_DrawPanel* panel, wxDC* DC, } if( (Struct->m_Flags & ENDPOINT) == 0 ) { - GRLineTo( &panel->m_ClipBox, - DC, - Struct->m_End.x + dx, - Struct->m_End.y + dy, - width, - g_GhostColor ); + GRLineTo( &panel->m_ClipBox, DC, Struct->m_End.x + dx, + Struct->m_End.y + dy, width, g_GhostColor ); } else { - GRLineTo( &panel->m_ClipBox, DC, Struct->m_End.x, Struct->m_End.y, width, g_GhostColor ); + GRLineTo( &panel->m_ClipBox, DC, Struct->m_End.x, + Struct->m_End.y, width, g_GhostColor ); } break; } @@ -447,12 +237,8 @@ void DrawStructsInGhost( WinEDA_DrawPanel* panel, wxDC* DC, DrawBusEntryStruct* Struct = (DrawBusEntryStruct*) DrawStruct; int xx = Struct->m_Pos.x + dx, yy = Struct->m_Pos.y + dy; GRMoveTo( xx, yy ); - GRLineTo( &panel->m_ClipBox, - DC, - Struct->m_Size.x + xx, - Struct->m_Size.y + yy, - width, - g_GhostColor ); + GRLineTo( &panel->m_ClipBox, DC, Struct->m_Size.x + xx, + Struct->m_Size.y + yy, width, g_GhostColor ); break; } @@ -495,21 +281,21 @@ void DrawStructsInGhost( WinEDA_DrawPanel* panel, wxDC* DC, EDA_LibComponentStruct* LibEntry; SCH_COMPONENT* Struct; Struct = (SCH_COMPONENT*) DrawStruct; - LibEntry = FindLibPart( Struct->m_ChipName.GetData(), wxEmptyString, FIND_ROOT ); + LibEntry = FindLibPart( Struct->m_ChipName.GetData(), wxEmptyString, + FIND_ROOT ); if( LibEntry == NULL ) break; DrawingLibInGhost( panel, DC, LibEntry, Struct, Struct->m_Pos.x + dx, - Struct->m_Pos.y + dy, - Struct->m_Multi, Struct->m_Convert, - g_GhostColor, FALSE ); + Struct->m_Pos.y + dy, Struct->m_Multi, + Struct->m_Convert, g_GhostColor, FALSE ); break; } case DRAW_SHEET_STRUCT_TYPE: { DrawSheetStruct* Struct = (DrawSheetStruct*) DrawStruct; - GRRect( &panel->m_ClipBox, DC, Struct->m_Pos.x + dx, Struct->m_Pos.y + dy, - Struct->m_Pos.x + Struct->m_Size.x + dx, + GRRect( &panel->m_ClipBox, DC, Struct->m_Pos.x + dx, + Struct->m_Pos.y + dy, Struct->m_Pos.x + Struct->m_Size.x + dx, Struct->m_Pos.y + Struct->m_Size.y + dy, width, g_GhostColor ); break; } @@ -524,10 +310,6 @@ void DrawStructsInGhost( WinEDA_DrawPanel* panel, wxDC* DC, } -/************************************************************/ -void Draw_Marqueur( WinEDA_DrawPanel* panel, wxDC* DC, - wxPoint pos, char* pt_bitmap, int DrawMode, int Color ) -/************************************************************/ /* * Place un repere sur l'ecran au point de coordonnees PCB pos_X, pos_Y @@ -538,6 +320,8 @@ void Draw_Marqueur( WinEDA_DrawPanel* panel, wxDC* DC, * * copie la description du marqueur en current_marqueur (global) */ +void Draw_Marqueur( WinEDA_DrawPanel* panel, wxDC* DC, + wxPoint pos, char* pt_bitmap, int DrawMode, int Color ) { int px, py, color; char ii, ii_max, jj, jj_max; @@ -545,13 +329,16 @@ void Draw_Marqueur( WinEDA_DrawPanel* panel, wxDC* DC, if( pt_bitmap == NULL ) pt_bitmap = marq_bitmap; - px = GRMapX( pos.x ); py = GRMapY( pos.y ); + px = GRMapX( pos.x ); + py = GRMapY( pos.y ); /* Lecture des dimensions */ - ii_max = *(pt_bitmap++); jj_max = *(pt_bitmap++); + ii_max = *(pt_bitmap++); + jj_max = *(pt_bitmap++); /* lecture des offsets */ - px += *(pt_bitmap++); py += *(pt_bitmap++); + px += *(pt_bitmap++); + py += *(pt_bitmap++); color = *(pt_bitmap++); if( (Color > 0) ) diff --git a/eeschema/eeschema.cpp b/eeschema/eeschema.cpp index 6babdd0916..c31b83670c 100644 --- a/eeschema/eeschema.cpp +++ b/eeschema/eeschema.cpp @@ -6,9 +6,6 @@ #pragma implementation #endif -#define eda_global -#define MAIN - #include "fctsys.h" #include "appl_wxstruct.h" #include "common.h" @@ -16,20 +13,122 @@ #include "confirm.h" #include "gestfich.h" #include "program.h" -#include "libcmp.h" #include "general.h" -#include "netlist.h" -#include "worksheet.h" #include "bitmaps.h" #include "eda_dde.h" +#include "libcmp.h" #include "protos.h" #include // Global variables -wxString g_Main_Title( wxT( "EESchema" ) ); + +wxString g_DefaultSchematicFileName( wxT( "noname.sch" ) ); +wxArrayString g_LibName_List; // library list (short filenames) to load +LibraryStruct* g_LibraryList; // All part libs are saved here. + +int g_NetFormat; /* Numero de reference du type de netliste */ +int g_OptNetListUseNames; /* TRUE pour utiliser les noms de net plutot que + * les numeros (netlist PSPICE seulement) */ +SCH_ITEM* g_ItemToRepeat; /* pointeur sur la derniere structure + * dessinee pouvant etre dupliquee par la commande + * Repeat ( NULL si aucune struct existe ) */ +wxSize g_RepeatStep; +int g_RepeatDeltaLabel; + +SCH_ITEM* g_ItemToUndoCopy; /* copy of last modified schematic item + * before it is modified (used for undo managing + * to restore old values ) */ + +bool g_LastSearchIsMarker; /* True if last seach is a marker serach + * False for a schematic item search + * Used for hotkey next search */ + +/* Block operation (copy, paste) */ +SCH_ITEM* g_BlockSaveDataList; // List of items to paste (Created by Block Save) + +// Gestion d'options +int g_ShowAllPins; +int g_HVLines = 1; // Bool: force H or V directions (Wires, Bus ..) + +int g_PlotPSColorOpt; // True = plot postcript color (see plotps.cpp) + +struct EESchemaVariables g_EESchemaVar; + +/* Variables globales pour Libview */ +wxString g_CurrentViewLibraryName; /* nom de la librairie en cours d'examen */ +wxString g_CurrentViewComponentName; /* nom du le composant en cours d'examen */ +int g_ViewConvert; /* Vue normal / convert */ +int g_ViewUnit; /* part a afficher (A, B ..) */ + +/* Variables globales pour Schematic Edit */ +int g_DefaultTextLabelSize = DEFAULT_SIZE_TEXT; + +/* Variables globales pour LibEdit */ +int g_LastTextSize = DEFAULT_SIZE_TEXT; +int g_LastTextOrient = TEXT_ORIENT_HORIZ; + +bool g_FlDrawSpecificUnit = FALSE; +bool g_FlDrawSpecificConvert = TRUE; + +int g_PlotFormat; /* flag = TYPE_HPGL, TYPE_PS... */ +int g_PlotMargin; /* Marge pour traces du cartouche */ +float g_PlotScaleX; +float g_PlotScaleY; /* coeff d'echelle de trace en unites table tracante */ + +HPGL_Pen_Descr_Struct g_HPGL_Pen_Descr; + +//SCH_SCREEN * ScreenSch; +DrawSheetStruct* g_RootSheet = NULL; +SCH_SCREEN* g_ScreenLib = NULL; + +wxString g_NetCmpExtBuffer( wxT( "cmp" ) ); +wxString g_SymbolExtBuffer( wxT( "sym" ) ); + +const wxString CompLibFileExtension( wxT( "lib" ) ); + +const wxString CompLibFileWildcard( wxT( "Kicad component library file " \ + "(*.lib)|*.lib" ) ); + +wxString g_SimulatorCommandLine; // ligne de commande pour l'appel au simulateur (gnucap, spice..) +wxString g_NetListerCommandLine; // ligne de commande pour l'appel au simulateur (gnucap, spice..) + +LayerStruct g_LayerDescr; /* couleurs des couches */ + +/* bool: TRUE si edition des pins pin a pin au lieu */ +bool g_EditPinByPinIsOn = FALSE; + +int g_LibSymbolDefaultLineWidth; /* default line width (in EESCHEMA units) used when creating a new graphic item in libedit : 0 = default */ +int g_DrawMinimunLineWidth; /* Minimum line (in EESCHEMA units) thickness used to draw items on screen; 0 = single pixel line width */ +int g_PlotLine_Width; /* Minimum line (in EESCHEMA units) thickness used to Plot/Print items */ +// Color to draw selected items +int g_ItemSelectetColor = BROWN; +// Color to draw items flagged invisible, in libedit (they are insisible in eeschema +int g_InvisibleItemColor = DARKGRAY; + +/* Variables used by LibEdit */ +LibEDA_BaseStruct* LibItemToRepeat = NULL; /* pointer on a graphic item than + * can be duplicated by the Ins key + * (usually the last created item */ +LibraryStruct* CurrentLib = NULL; /* Current opened library */ +EDA_LibComponentStruct* CurrentLibEntry = NULL; /* Current component */ +LibEDA_BaseStruct* CurrentDrawItem = NULL; /* current edited item */ + +// Current selected alias (for components which have aliases) +wxString CurrentAliasName; + +// True if the current component has a "De Morgan" representation +bool g_AsDeMorgan; +int CurrentUnit = 1; +int CurrentConvert = 1; + +/* Library (name) containing the last component find by FindLibPart() */ +wxString FindLibName; + +int DefaultTransformMatrix[2][2] = { { 1, 0 }, { 0, -1 } }; + /************************************/ /* Called to initialize the program */ @@ -44,12 +143,12 @@ IMPLEMENT_APP( WinEDA_App ) bool WinEDA_App::OnInit() { - wxString FFileName; + wxFileName fn; WinEDA_SchematicFrame* frame = NULL; g_DebugLevel = 0; // Debug level */ - InitEDA_Appl( wxT( "eeschema" ) ); + InitEDA_Appl( wxT( "EESchema" ) ); if( m_Checker && m_Checker->IsAnotherRunning() ) { @@ -58,10 +157,9 @@ bool WinEDA_App::OnInit() } if( argc > 1 ) - FFileName = argv[1]; + fn = argv[1]; /* init EESCHEMA */ - GetSettings(); // read current setup SeedLayers(); extern PARAM_CFG_BASE* ParamCfgList[]; wxGetApp().ReadCurrentSetupValues( ParamCfgList ); @@ -88,17 +186,19 @@ bool WinEDA_App::OnInit() frame->Zoom_Automatique( TRUE ); /* Load file specified in the command line. */ - if( !FFileName.IsEmpty() ) + if( fn.IsOk() ) { - ChangeFileNameExt( FFileName, g_SchExtBuffer ); - wxSetWorkingDirectory( wxPathOnly( FFileName ) ); - if( frame->DrawPanel ) - if( frame->LoadOneEEProject( FFileName, FALSE ) <= 0 ) - frame->DrawPanel->Refresh( TRUE ); // File not found or error + if( fn.GetExt() != SchematicFileExtension ) + fn.SetExt( SchematicFileExtension ); + wxSetWorkingDirectory( fn.GetPath() ); + if( frame->DrawPanel + && frame->LoadOneEEProject( fn.GetFullPath(), false ) <= 0 ) + frame->DrawPanel->Refresh( true ); } else { - Read_Config( wxEmptyString, TRUE ); // Read a default config file if no file to load + // Read a default config file if no file to load. + Read_Config( wxEmptyString, TRUE ); if( frame->DrawPanel ) frame->DrawPanel->Refresh( TRUE ); } diff --git a/eeschema/erc.cpp b/eeschema/erc.cpp index cc31532b72..b7f5e29e69 100644 --- a/eeschema/erc.cpp +++ b/eeschema/erc.cpp @@ -9,6 +9,7 @@ #include "confirm.h" #include "kicad_string.h" #include "gestfich.h" +#include "appl_wxstruct.h" #include "program.h" #include "libcmp.h" @@ -270,6 +271,7 @@ void WinEDA_ErcFrame::ReBuildMatrixPanel() void WinEDA_ErcFrame::TestErc( wxCommandEvent& event ) /**************************************************/ { + wxFileName fn; ObjetNetListStruct* NetItemRef; ObjetNetListStruct* OldItem; ObjetNetListStruct* StartNet; @@ -389,28 +391,21 @@ void WinEDA_ErcFrame::TestErc( wxCommandEvent& event ) /* Generation ouverture fichier diag */ if( WriteFichierERC == TRUE ) { - wxString ErcFullFileName; - ErcFullFileName = g_RootSheet->m_AssociatedScreen->m_FileName; - ChangeFileNameExt( ErcFullFileName, wxT( ".erc" ) ); + fn = g_RootSheet->m_AssociatedScreen->m_FileName; + fn.SetExt( wxT( "erc" ) ); - ErcFullFileName = EDA_FileSelector( _( "ERC file:" ), - wxEmptyString, /* Chemin par defaut */ - ErcFullFileName, /* nom fichier par defaut */ - wxT( ".erc" ), /* extension par defaut */ - wxT( "*.erc" ), /* Masque d'affichage */ - this, - wxFD_SAVE, - TRUE - ); - if( ErcFullFileName.IsEmpty() ) + wxFileDialog dlg( this, _( "ERC File" ), fn.GetPath(), fn.GetFullName(), + _( "Electronic rule check file (.erc)|*.erc" ), + wxFD_SAVE | wxFD_OVERWRITE_PROMPT ); + + if( dlg.ShowModal() == wxID_CANCEL ) return; - if( WriteDiagnosticERC( ErcFullFileName ) ) + if( WriteDiagnosticERC( dlg.GetPath() ) ) { Close( TRUE ); - wxString editorname = GetEditorName(); - AddDelimiterString( ErcFullFileName ); - ExecuteFile( this, editorname, ErcFullFileName ); + ExecuteFile( this, wxGetApp().GetEditorName(), + QuoteFullPath( fn ) ); } } } diff --git a/eeschema/files-io.cpp b/eeschema/files-io.cpp index 83f19dcdd4..a59febbdec 100644 --- a/eeschema/files-io.cpp +++ b/eeschema/files-io.cpp @@ -80,11 +80,11 @@ int WinEDA_SchematicFrame::LoadOneEEProject( const wxString& FileName, FullFileName = FileName; if( ( FullFileName.IsEmpty() ) && !IsNew ) { - wxString mask = wxT( "*" ) + g_SchExtBuffer; + wxString mask = wxT( "*." ) + SchematicFileExtension; FullFileName = EDA_FileSelector( _( "Schematic files:" ), wxEmptyString, /* Chemin par defaut */ wxEmptyString, /* nom fichier par defaut */ - g_SchExtBuffer, /* extension par defaut */ + SchematicFileExtension, /* extension par defaut */ mask, /* Masque d'affichage */ this, wxFD_OPEN, @@ -154,18 +154,16 @@ int WinEDA_SchematicFrame::LoadOneEEProject( const wxString& FileName, } // Loading the project library cache - wxString FullLibName; - wxString shortfilename; - wxSplitPath( g_RootSheet->m_AssociatedScreen->m_FileName, NULL, &shortfilename, NULL ); - FullLibName << wxT( "." ) << STRING_DIR_SEP << shortfilename << wxT( ".cache" ) << - g_LibExtBuffer; - if( wxFileExists( FullLibName ) ) + wxFileName fn = g_RootSheet->m_AssociatedScreen->m_FileName; + fn.SetExt( wxT( "cache.lib" ) ); + wxLogDebug( wxT( "Load schematic cache library file <%s>" ), + fn.GetFullPath().c_str() ); + + if( fn.FileExists() ) { - wxString libname; - libname = FullLibName; - ChangeFileNameExt( libname, wxEmptyString ); - msg = wxT( "Load " ) + FullLibName; - LibraryStruct* LibCache = LoadLibraryName( this, FullLibName, libname ); + msg = wxT( "Load " ) + fn.GetFullPath(); + LibraryStruct* LibCache = LoadLibraryName( this, fn.GetFullPath(), + fn.GetName() ); if( LibCache ) { LibCache->m_IsLibCache = TRUE; @@ -233,8 +231,7 @@ void WinEDA_SchematicFrame::SaveProject() */ { SCH_SCREEN* screen; - wxString LibArchiveFileName; - + wxFileName fn; EDA_ScreenList ScreenList; for( screen = ScreenList.GetFirst(); screen != NULL; @@ -245,12 +242,9 @@ void WinEDA_SchematicFrame::SaveProject() } /* Creation du fichier d'archivage composants en repertoire courant */ - LibArchiveFileName = MakeFileName( wxEmptyString, g_RootSheet->GetFileName(), wxEmptyString ); - ChangeFileNameExt( LibArchiveFileName, wxEmptyString ); - - /* mise a jour extension */ - LibArchiveFileName += wxT( ".cache" ) + g_LibExtBuffer; - LibArchive( this, LibArchiveFileName ); + fn = g_RootSheet->GetFileName(); + fn.SetExt( wxT( "cache." ) + CompLibFileExtension ); + LibArchive( this, fn.GetFullPath() ); } diff --git a/eeschema/find.cpp b/eeschema/find.cpp index aea3d2db7d..280447ccef 100644 --- a/eeschema/find.cpp +++ b/eeschema/find.cpp @@ -713,9 +713,9 @@ int WinEDA_FindFrame::ExploreAllLibraries( const wxString& wildmask, wxString& F int nbitems = 0, LineNum = 0; char Line[2048], * name; - FullFileName = MakeFileName( g_RealLibDirBuffer, wxT( "*" ), g_LibExtBuffer ); + FullFileName = wxFindFirstFile( g_RealLibDirBuffer + wxT( "*." ) + + CompLibFileExtension ); - FullFileName = wxFindFirstFile( FullFileName ); while( !FullFileName.IsEmpty() ) { file = wxFopen( FullFileName, wxT( "rt" ) ); diff --git a/eeschema/general.h b/eeschema/general.h index fe59978373..a78900c399 100644 --- a/eeschema/general.h +++ b/eeschema/general.h @@ -5,13 +5,6 @@ #ifndef _GENERAL_H_ #define _GENERAL_H_ -#ifndef eda_global -#define eda_global extern -#endif - -#define us unsigned short -#define uc unsigned char -#define ul unsigned long /* Entete des fichiers schematique */ #define EESCHEMA_VERSION 2 @@ -23,7 +16,7 @@ #define MAX_PIN_INFO 10 #define TXTMARGE 10 /* Decalage (en 1/1000") des textes places - * sur fils ( labels, num pins ) */ + * sur fils ( labels, num pins ) */ #define HIGHLIGHT_COLOR WHITE @@ -40,12 +33,7 @@ #define DANGLING_SYMBOL_SIZE 12 /* Message de presentation */ -extern wxString g_Main_Title; -eda_global wxString g_DefaultSchematicFileName -#ifdef MAIN -( wxT( "noname.sch" ) ) -#endif -; +extern wxString g_DefaultSchematicFileName; /* Masque de recherche pour localisation d'objets a editer */ #define LIBITEM 1 @@ -106,41 +94,33 @@ typedef enum { /* variables generales */ -eda_global wxArrayString g_LibName_List; // library list (short filenames) to load -eda_global LibraryStruct* g_LibraryList; // All part libs are saved here. +extern wxArrayString g_LibName_List; // library list (short filenames) to load +extern LibraryStruct* g_LibraryList; // All part libs are saved here. -eda_global int g_NetFormat; /* Numero de reference du type de netliste */ -eda_global int g_OptNetListUseNames; /* TRUE pour utiliser les noms de net plutot que +extern int g_NetFormat; /* Numero de reference du type de netliste */ +extern int g_OptNetListUseNames; /* TRUE pour utiliser les noms de net plutot que * les numeros (netlist PSPICE seulement) */ -eda_global int g_BGColor; /* couleur fond d'ecran (normalement blanc) */ -eda_global SCH_ITEM* g_ItemToRepeat; /* pointeur sur la derniere structure +extern SCH_ITEM* g_ItemToRepeat; /* pointeur sur la derniere structure * dessinee pouvant etre dupliquee par la commande * Repeat ( NULL si aucune struct existe ) */ -eda_global wxSize g_RepeatStep; -eda_global int g_RepeatDeltaLabel; +extern wxSize g_RepeatStep; +extern int g_RepeatDeltaLabel; -eda_global SCH_ITEM* g_ItemToUndoCopy; /* copy of last modified schematic item +extern SCH_ITEM* g_ItemToUndoCopy; /* copy of last modified schematic item * before it is modified (used for undo managing to restore old values ) */ -eda_global bool g_LastSearchIsMarker; // True if last seach is a marker serach +extern bool g_LastSearchIsMarker; // True if last seach is a marker serach // False for a schematic item search // Used for hotkey next search /* Block operation (copy, paste) */ -eda_global SCH_ITEM* g_BlockSaveDataList; // List of items to paste (Created by Block Save) +extern SCH_ITEM* g_BlockSaveDataList; // List of items to paste (Created by Block Save) // Gestion d'options -eda_global int g_ShowAllPins; -eda_global int g_ShowGrid; // Bool: display grid -#ifdef MAIN -wxSize g_User_Grid( 50, 50 ); -int g_HVLines = 1; // Bool: force H or V directions (Wires, Bus ..) -#else -extern wxSize g_User_Grid; -extern int g_HVLines; -#endif +extern int g_ShowAllPins; +extern int g_HVLines; -eda_global int g_PlotPSColorOpt; // True = plot postcript color (see plotps.cpp) +extern int g_PlotPSColorOpt; // True = plot postcript color (see plotps.cpp) // Gestion de diverses variables, options... devant etre memorisees mais @@ -151,43 +131,23 @@ struct EESchemaVariables int NbWarningErc; }; -eda_global struct EESchemaVariables g_EESchemaVar; +extern struct EESchemaVariables g_EESchemaVar; /* Variables globales pour Libview */ -eda_global wxString g_CurrentViewLibraryName; /* nom de la librairie en cours d'examen */ -eda_global wxString g_CurrentViewComponentName; /* nom du le composant en cours d'examen */ -eda_global int g_ViewConvert; /* Vue normal / convert */ -eda_global int g_ViewUnit; /* part a afficher (A, B ..) */ +extern wxString g_CurrentViewLibraryName; /* nom de la librairie en cours d'examen */ +extern wxString g_CurrentViewComponentName; /* nom du le composant en cours d'examen */ +extern int g_ViewConvert; /* Vue normal / convert */ +extern int g_ViewUnit; /* part a afficher (A, B ..) */ /* Variables globales pour Schematic Edit */ -eda_global int g_DefaultTextLabelSize -#ifdef MAIN -= DEFAULT_SIZE_TEXT -#endif -; +extern int g_DefaultTextLabelSize; /* Variables globales pour LibEdit */ -eda_global int g_LastTextSize -#ifdef MAIN -= DEFAULT_SIZE_TEXT -#endif -; -eda_global int g_LastTextOrient -#ifdef MAIN -= TEXT_ORIENT_HORIZ -#endif -; +extern int g_LastTextSize; +extern int g_LastTextOrient; -eda_global bool g_FlDrawSpecificUnit -#ifdef MAIN -= FALSE -#endif -; -eda_global bool g_FlDrawSpecificConvert -#ifdef MAIN -= TRUE -#endif -; +extern bool g_FlDrawSpecificUnit; +extern bool g_FlDrawSpecificConvert; /********************************************************/ /* Description des structures des parametres principaux */ @@ -195,9 +155,9 @@ eda_global bool g_FlDrawSpecificConvert /* Gestion des trace sur table tracante */ -eda_global int g_PlotFormat; /* flag = TYPE_HPGL, TYPE_PS... */ -eda_global int g_PlotMargin; /* Marge pour traces du cartouche */ -eda_global float g_PlotScaleX, g_PlotScaleY; /* coeff d'echelle de trace en unites table tracante */ +extern int g_PlotFormat; /* flag = TYPE_HPGL, TYPE_PS... */ +extern int g_PlotMargin; /* Marge pour traces du cartouche */ +extern float g_PlotScaleX, g_PlotScaleY; /* coeff d'echelle de trace en unites table tracante */ /* For HPGL plotting: Pen caract : */ @@ -207,13 +167,13 @@ struct HPGL_Pen_Descr_Struct int m_Pen_Speed; /* vitesse en cm/s */ int m_Pen_Diam; /* Pen diameter in mils */ }; -eda_global HPGL_Pen_Descr_Struct g_HPGL_Pen_Descr; +extern HPGL_Pen_Descr_Struct g_HPGL_Pen_Descr; /* Ecrans usuels */ -//eda_global SCH_SCREEN * ScreenSch; -eda_global DrawSheetStruct* g_RootSheet; -eda_global SCH_SCREEN* g_ScreenLib; +//extern SCH_SCREEN * ScreenSch; +extern DrawSheetStruct* g_RootSheet; +extern SCH_SCREEN* g_ScreenLib; /*************************************/ /* Gestion de recherche des elements */ @@ -225,48 +185,28 @@ eda_global SCH_SCREEN* g_ScreenLib; #define CURSEUR_OFF_GRILLE 1 /* Gestion des librairies schematiques */ -eda_global wxString g_NetNameBuffer; +extern wxString g_NetCmpExtBuffer; +extern wxString g_SymbolExtBuffer; -#ifdef MAIN -wxString g_NetCmpExtBuffer( wxT( ".cmp" ) ); -wxString g_SymbolExtBuffer( wxT( ".sym" ) ); -wxString g_NetExtBuffer( wxT( ".net" ) ); -wxString g_SchExtBuffer( wxT( ".sch" ) ); -wxString g_LibExtBuffer( wxT( ".lib" ) ); -#else -eda_global wxString g_NetCmpExtBuffer; -eda_global wxString g_SymbolExtBuffer; -eda_global wxString g_NetExtBuffer; -eda_global wxString g_SchExtBuffer; -eda_global wxString g_LibExtBuffer; -#endif +extern const wxString CompLibFileExtension; +extern const wxString CompLibFileWildcard; -eda_global wxString g_SimulatorCommandLine; // ligne de commande pour l'appel au simulateur (gnucap, spice..) -eda_global wxString g_NetListerCommandLine; // ligne de commande pour l'appel au simulateur (gnucap, spice..) +extern wxString g_SimulatorCommandLine; // ligne de commande pour l'appel au simulateur (gnucap, spice..) +extern wxString g_NetListerCommandLine; // ligne de commande pour l'appel au simulateur (gnucap, spice..) -eda_global LayerStruct g_LayerDescr; /* couleurs des couches */ +extern LayerStruct g_LayerDescr; /* couleurs des couches */ -eda_global bool g_EditPinByPinIsOn /* bool: TRUE si edition des pins pin a pin au lieu */ -#ifdef MAIN /* de l'edition simultanee des pins de meme coordonnees */ -= FALSE -#endif -; +/* bool: TRUE si edition des pins pin a pin au lieu */ +extern bool g_EditPinByPinIsOn; -eda_global int g_LibSymbolDefaultLineWidth; /* default line width (in EESCHEMA units) used when creating a new graphic item in libedit : 0 = default */ -eda_global int g_DrawMinimunLineWidth; /* Minimum line (in EESCHEMA units) thickness used to draw items on screen; 0 = single pixel line width */ -eda_global int g_PlotLine_Width; /* Minimum line (in EESCHEMA units) thickness used to Plot/Print items */ +extern int g_LibSymbolDefaultLineWidth; /* default line width (in EESCHEMA units) used when creating a new graphic item in libedit : 0 = default */ +extern int g_DrawMinimunLineWidth; /* Minimum line (in EESCHEMA units) thickness used to draw items on screen; 0 = single pixel line width */ +extern int g_PlotLine_Width; /* Minimum line (in EESCHEMA units) thickness used to Plot/Print items */ -eda_global int g_ItemSelectetColor // Color to draw selected items -#ifdef MAIN -= BROWN -#endif -; - -eda_global int g_InvisibleItemColor // Color to draw items flagged invisible, in libedit (they are insisible in eeschema -#ifdef MAIN -= DARKGRAY -#endif -; +// Color to draw selected items +extern int g_ItemSelectetColor; +// Color to draw items flagged invisible, in libedit (they are insisible in eeschema +extern int g_InvisibleItemColor; /* Config keys */ #define MINI_DRAW_LINE_WIDTH_KEY wxT( "MinimunDrawLineWidth" ) diff --git a/eeschema/lib_export.cpp b/eeschema/lib_export.cpp index fd078df481..d67152dc4b 100644 --- a/eeschema/lib_export.cpp +++ b/eeschema/lib_export.cpp @@ -22,42 +22,44 @@ #include "id.h" +#include + + +extern int ExportPartId; + /*************************************************/ -void WinEDA_LibeditFrame::ImportOnePart() -/*************************************************/ - /* Routine de lecture de 1 description. * Le format est celui des librairies, mais on ne charge que 1 composant * ou le 1er composant s'il y en a plusieurs. * Si le premier composant est un alias, on chargera la racine correspondante */ +/*************************************************/ +void WinEDA_LibeditFrame::OnImportPart( wxCommandEvent& event ) { - wxString Name, mask; + wxFileName fn; LibraryStruct* LibTmp; EDA_LibComponentStruct* LibEntry; int err = 1; - mask = wxT( "*" ) + g_LibExtBuffer; - Name = EDA_FileSelector( _( "Import component:" ), - wxEmptyString, /* Chemin par defaut */ - wxEmptyString, /* nom fichier par defaut */ - g_LibExtBuffer, /* extension par defaut */ - mask, /* Masque d'affichage */ - this, - 0, - TRUE - ); - if( Name == wxEmptyString ) + LibItemToRepeat = NULL; + + wxFileDialog dlg( this, _( "Import Component" ), m_LastLibImportPath, + wxEmptyString, CompLibFileWildcard, + wxFD_OPEN | wxFILE_MUST_EXIST ); + + if( dlg.ShowModal() == wxID_CANCEL ) return; - LibTmp = g_LibraryList; g_LibraryList = NULL; + LibTmp = g_LibraryList; + g_LibraryList = NULL; - LoadLibraryName( this, Name, wxT( "$tmplib$" ) ); + LoadLibraryName( this, dlg.GetPath(), wxT( "$tmplib$" ) ); if( g_LibraryList ) { - LibEntry = (EDA_LibComponentStruct*) PQFirst( &g_LibraryList->m_Entries, FALSE ); + LibEntry = (EDA_LibComponentStruct*) PQFirst( &g_LibraryList->m_Entries, + false ); if( LibEntry ) err = LoadOneLibraryPartAux( LibEntry, g_LibraryList, 1 ); @@ -65,75 +67,73 @@ void WinEDA_LibeditFrame::ImportOnePart() if( err == 0 ) { + fn = dlg.GetPath(); + m_LastLibImportPath = fn.GetPath(); ReCreateHToolbar(); DisplayLibInfos(); + GetScreen()->ClearUndoRedoList(); DrawPanel->Refresh(); } + else + DisplayError( this, _( "File is empty" ), 30 ); } g_LibraryList = LibTmp; - if( err ) - DisplayError( this, _( "File is empty" ), 30 ); } -/************************************************************/ -void WinEDA_LibeditFrame::ExportOnePart( bool create_lib ) -/************************************************************/ - /* Routine de creation d'une nouvelle librairie et de sauvegarde du - * composant courant dans cette librarie - * si create_lib == TRUE sauvegarde dans le repertoire des libr - * sinon: sauvegarde sous le nom demande sans modifications. + * composant courant dans cette librarie + * si create_lib == TRUE sauvegarde dans le repertoire des libr + * sinon: sauvegarde sous le nom demande sans modifications. * - * Le format du fichier cree est dans tous les cas le meme. + * Le format du fichier cree est dans tous les cas le meme. */ +void WinEDA_LibeditFrame::OnExportPart( wxCommandEvent& event ) { - wxString Name, mask; + wxFileName fn; + wxString Name, mask, title; LibraryStruct* NewLib, * LibTmp, * CurLibTmp; + bool createLib = ( event.GetId() == ExportPartId ) ? false : true; if( CurrentLibEntry == NULL ) { - DisplayError( this, _( "No Part to Save" ), 10 ); return; + DisplayError( this, _( "No Part to Save" ), 10 ); + return; } - Name = CurrentLibEntry->m_Name.m_Text; - Name.MakeLower(); + fn = CurrentLibEntry->m_Name.m_Text.Lower(); + fn.SetExt( CompLibFileExtension ); - mask = wxT( "*" ) + g_LibExtBuffer; - wxString def_path; + title = createLib ? _( "New Library" ) : _( "Export Component" ); - if( create_lib ) - def_path = g_RealLibDirBuffer; + wxFileDialog dlg( this, title, wxGetCwd(), fn.GetFullName(), + CompLibFileWildcard, wxFD_SAVE | wxFD_OVERWRITE_PROMPT ); - Name = EDA_FileSelector( create_lib ? _( "New Library" ) : _( "Export component:" ), - def_path, /* Chemin par defaut */ - Name, /* nom fichier par defaut */ - g_LibExtBuffer, /* extension par defaut */ - mask, /* Masque d'affichage */ - this, - wxFD_SAVE, - TRUE - ); - - if( Name == wxEmptyString ) + if( dlg.ShowModal() == wxID_CANCEL ) return; + fn = dlg.GetPath(); /* Creation d'une librairie standard pour sauvegarde */ - ChangeFileNameExt( Name, g_LibExtBuffer ); LibTmp = g_LibraryList; CurLibTmp = CurrentLib; - NewLib = new LibraryStruct( LIBRARY_TYPE_EESCHEMA, wxT( "$libTmp$" ), Name ); + NewLib = new LibraryStruct( LIBRARY_TYPE_EESCHEMA, wxT( "$libTmp$" ), + fn.GetFullName() ); g_LibraryList = NewLib; /* Sauvegarde du composant: */ CurrentLib = NewLib; SaveOnePartInMemory(); - bool success = NewLib->SaveLibrary( Name ); + bool success = NewLib->SaveLibrary( fn.GetFullPath() ); + + if( success ) + { + m_LastLibExportPath = fn.GetPath(); + } /* Suppression de la librarie temporaire */ FreeCmpLibrary( this, NewLib->m_Name ); @@ -141,13 +141,14 @@ void WinEDA_LibeditFrame::ExportOnePart( bool create_lib ) CurrentLib = CurLibTmp; wxString msg; - if( create_lib && success ) + if( createLib && success ) { - msg = Name + _( "Ok" ); - DisplayInfo( this, - _("Note: this new library will be available only if it is loaded by eeschema.\nModify eeschema config if you want use it.") ); + msg = fn.GetFullPath() + _( " - OK" ); + DisplayInfo( this, _( "Note: this new library will be available " \ + "only if it is loaded by eeschema.\nModify " + "eeschema config if you want use it." ) ); } else - msg = _( "Error while create " ) + Name; + msg = _( "Error creating " ) + fn.GetFullName(); Affiche_Message( msg ); } diff --git a/eeschema/libarch.cpp b/eeschema/libarch.cpp index 51aed04226..344fe132be 100644 --- a/eeschema/libarch.cpp +++ b/eeschema/libarch.cpp @@ -31,7 +31,8 @@ bool LibArchive( wxWindow* frame, const wxString& ArchFullFileName ) * return true if success */ { - wxString DocFileName, msg; + wxFileName docFileName; + wxString msg; char Line[256]; FILE* ArchiveFile, * DocFile; EDA_LibComponentStruct* Entry; @@ -62,8 +63,8 @@ bool LibArchive( wxWindow* frame, const wxString& ArchFullFileName ) sort( ListEntry.begin(), ListEntry.end(), SortCmpByName ); /* calculate the file name for the associated doc file */ - DocFileName = ArchFullFileName; - ChangeFileNameExt( DocFileName, DOC_EXT ); + docFileName = ArchFullFileName; + docFileName.SetExt( DOC_EXT ); if( ( ArchiveFile = wxFopen( ArchFullFileName, wxT( "wt" ) ) ) == NULL ) { @@ -72,9 +73,9 @@ bool LibArchive( wxWindow* frame, const wxString& ArchFullFileName ) return FALSE; } - if( ( DocFile = wxFopen( DocFileName, wxT( "wt" ) ) ) == NULL ) + if( ( DocFile = wxFopen( docFileName.GetFullPath(), wxT( "wt" ) ) ) == NULL ) { - msg = _( "Failed to create doc lib file " ) + DocFileName; + msg = _( "Failed to create doc lib file " ) + docFileName.GetFullPath(); DisplayError( frame, msg ); } diff --git a/eeschema/libcmp.h b/eeschema/libcmp.h index 659c0bf7e3..69d0309fc7 100644 --- a/eeschema/libcmp.h +++ b/eeschema/libcmp.h @@ -5,17 +5,13 @@ #ifndef LIBCMP_H #define LIBCMP_H -#ifndef eda_global -#define eda_global extern -#endif - #include "priorque.h" #define LIB_VERSION_MAJOR 2 #define LIB_VERSION_MINOR 3 #define LIBFILE_IDENT "EESchema-LIBRARY Version" /* Must be the first line of lib files. */ #define DOCFILE_IDENT "EESchema-DOCLIB Version 2.0" /* Must be the first line of doc files. */ -#define DOC_EXT wxT( ".dcm" ) /* Ext. of documentation files */ +#define DOC_EXT wxT( "dcm" ) /* Ext. of documentation files */ //Offsets used in editing library component, for handle aliad dats @@ -48,28 +44,20 @@ enum LocateDrawStructType { /* Variables */ -extern LibraryStruct* LibraryList; /* All part libs are saved here. */ +extern LibraryStruct* LibraryList; /* All part libs are saved here. */ /* Variables used by LibEdit */ -eda_global LibEDA_BaseStruct* LibItemToRepeat; /* pointer on a graphic item than can be duplicated by the Ins key +extern LibEDA_BaseStruct* LibItemToRepeat; /* pointer on a graphic item than can be duplicated by the Ins key * (usually the last created item */ -eda_global LibraryStruct* CurrentLib; /* Current opened library */ -eda_global EDA_LibComponentStruct* CurrentLibEntry; /* Current component */ -eda_global LibEDA_BaseStruct* CurrentDrawItem; /* current edited item */ +extern LibraryStruct* CurrentLib; /* Current opened library */ +extern EDA_LibComponentStruct* CurrentLibEntry; /* Current component */ +extern LibEDA_BaseStruct* CurrentDrawItem; /* current edited item */ -eda_global wxString CurrentAliasName; // Current selected alias (for components which have aliases) -eda_global bool g_AsDeMorgan; // True if the current component has a "De Morgan" representation -eda_global int CurrentUnit // Current selected part -#ifdef MAIN -= 1 -#endif -; -eda_global int CurrentConvert /* Convert = 1 .. 255 */ -#ifdef MAIN -= 1 -#endif -; +extern wxString CurrentAliasName; +extern bool g_AsDeMorgan; +extern int CurrentUnit; +extern int CurrentConvert; -eda_global wxString FindLibName; /* Library (name) containing the last component find by FindLibPart() */ +extern wxString FindLibName; #endif // LIBCMP_H diff --git a/eeschema/libedit.cpp b/eeschema/libedit.cpp index 3dc3c7c098..d612527bed 100644 --- a/eeschema/libedit.cpp +++ b/eeschema/libedit.cpp @@ -237,7 +237,7 @@ void WinEDA_LibeditFrame::RedrawActiveWindow( wxDC* DC, bool EraseBg ) GetScreen()->ClrRefreshReq(); DisplayLibInfos(); - Affiche_Status_Box(); + UpdateStatusBar(); } @@ -249,7 +249,8 @@ void WinEDA_LibeditFrame::SaveActiveLibrary() * if exists the old file is renamed (.bak) */ { - wxString Name, msg; + wxFileName fn; + wxString msg; if( CurrentLib == NULL ) { @@ -257,29 +258,31 @@ void WinEDA_LibeditFrame::SaveActiveLibrary() return; } - Name = MakeFileName( g_RealLibDirBuffer, - CurrentLib->m_Name, - g_LibExtBuffer ); + fn = wxFileName( g_RealLibDirBuffer, CurrentLib->m_Name, + CompLibFileExtension ); + + msg = _( "Modify Library File \"" ) + fn.GetFullPath() + _( "\"?" ); - msg = _( "Modify Library File \"" ) + Name + _( "\"?" ); if( !IsOK( this, msg ) ) return; - bool success = CurrentLib->SaveLibrary( Name ); + bool success = CurrentLib->SaveLibrary( fn.GetFullPath() ); MsgPanel->EraseMsgBox(); if( !success ) { - msg = _( "Error while saving Library File \"" ) + Name + _( "\"." ); + msg = _( "Error while saving Library File \"" ) + fn.GetFullPath() + + _( "\"." ); Affiche_1_Parametre( this, 1, wxT( " *** ERROR : **" ), msg, BLUE ); DisplayError( this, msg ); } else { - msg = _( "Library File \"" ) + Name + wxT( "\" Ok" ); - ChangeFileNameExt( Name, DOC_EXT ); - wxString msg1 = _( "Document File \"" ) + Name + wxT( "\" Ok" ); + msg = _( "Library File \"" ) + fn.GetFullName() + wxT( "\" Ok" ); + fn.SetExt( DOC_EXT ); + wxString msg1 = _( "Document File \"" ) + fn.GetFullPath() + + wxT( "\" Ok" ); Affiche_1_Parametre( this, 1, msg, msg1, BLUE ); } } diff --git a/eeschema/libedit_onleftclick.cpp b/eeschema/libedit_onleftclick.cpp index b433e2f36f..7dec982d54 100644 --- a/eeschema/libedit_onleftclick.cpp +++ b/eeschema/libedit_onleftclick.cpp @@ -74,7 +74,7 @@ void WinEDA_LibeditFrame::OnLeftClick( wxDC* DC, const wxPoint& MousePos ) } if( DrawEntry ) - DrawEntry->Display_Infos_DrawEntry( this ); + DrawEntry->DisplayInfo( this ); else { @@ -235,7 +235,7 @@ void WinEDA_LibeditFrame::OnLeftDClick( wxDC* DC, const wxPoint& MousePos ) } if( DrawEntry ) - DrawEntry->Display_Infos_DrawEntry( this ); + DrawEntry->DisplayInfo( this ); else return; diff --git a/eeschema/libedit_onrightclick.cpp b/eeschema/libedit_onrightclick.cpp index cff4029ee2..e33ecac13a 100644 --- a/eeschema/libedit_onrightclick.cpp +++ b/eeschema/libedit_onrightclick.cpp @@ -59,8 +59,10 @@ bool BlockActive = (GetScreen()->BlockLocate.m_Command != BLOCK_IDLE); } } - if ( DrawEntry ) DrawEntry->Display_Infos_DrawEntry(this); - else return true; + if ( DrawEntry ) + DrawEntry->DisplayInfo( this ); + else + return true; CurrentDrawItem = DrawEntry; wxString msg; diff --git a/eeschema/libframe.cpp b/eeschema/libframe.cpp index 5beffce0a7..ec167eb9a9 100644 --- a/eeschema/libframe.cpp +++ b/eeschema/libframe.cpp @@ -18,6 +18,20 @@ #include "protos.h" #include "id.h" + +/* Library editor wxConfig entry names. */ +const wxString lastLibExportPathEntry( wxT( "LastLibraryExportPath" ) ); +const wxString lastLibImportPathEntry( wxT( "LastLibraryImportPath" ) ); +const wxString showGridPathEntry( wxT( "ShowGrid" ) ); + +/* This method guarentees unique IDs for the library this run of Eeschema + * which prevents ID conflicts and eliminates the need to recompile every + * source file in the project when adding IDs to include/id.h. */ +int ExportPartId = ::wxNewId(); +int ImportPartId = ::wxNewId(); +int CreateNewLibAndSavePartId = ::wxNewId(); + + /*****************************/ /* class WinEDA_LibeditFrame */ /*****************************/ @@ -50,6 +64,13 @@ BEGIN_EVENT_TABLE( WinEDA_LibeditFrame, WinEDA_DrawFrame ) EVT_MENU_RANGE( ID_POPUP_GENERAL_START_RANGE, ID_POPUP_GENERAL_END_RANGE, WinEDA_LibeditFrame::Process_Special_Functions ) + EVT_TOOL( ExportPartId, WinEDA_LibeditFrame::OnExportPart ) + EVT_TOOL( CreateNewLibAndSavePartId, WinEDA_LibeditFrame::OnExportPart ) + EVT_TOOL( ImportPartId, WinEDA_LibeditFrame::OnImportPart ) + EVT_UPDATE_UI( ExportPartId, WinEDA_LibeditFrame::OnUpdateEditingPart ) + EVT_UPDATE_UI( CreateNewLibAndSavePartId, + WinEDA_LibeditFrame::OnUpdateEditingPart ) + // PopUp Menus pour Zooms trait�s dans drawpanel.cpp END_EVENT_TABLE() @@ -58,18 +79,19 @@ WinEDA_LibeditFrame::WinEDA_LibeditFrame( wxWindow* father, const wxString& title, const wxPoint& pos, const wxSize& size, - long style ) : + long style ) : WinEDA_DrawFrame( father, LIBEDITOR_FRAME, title, pos, size, style ) { m_FrameName = wxT( "LibeditFrame" ); m_Draw_Axis = true; // true pour avoir les axes dessines m_Draw_Grid = true; // true pour avoir la axes dessinee + m_ConfigPath = wxT( "LibraryEditor" ); // Give an icon SetIcon( wxIcon( libedit_xpm ) ); SetBaseScreen( g_ScreenLib ); GetScreen()->m_Center = true; // set to true to have the coordinates origine -0,0) centered on screen - GetSettings(); + LoadSettings(); SetSize( m_FramePos.x, m_FramePos.y, m_FrameSize.x, m_FrameSize.y ); if( DrawPanel ) DrawPanel->m_Block_Enable = true; @@ -91,6 +113,46 @@ WinEDA_LibeditFrame::~WinEDA_LibeditFrame() } +/** + * Load library editor frame specific configuration settings. + * + * Don't forget to call this base method from any derived classes or the + * settings will not get loaded. + */ +void WinEDA_LibeditFrame::LoadSettings( ) +{ + wxConfig* cfg; + + WinEDA_DrawFrame::LoadSettings(); + + wxConfigPathChanger cpc( wxGetApp().m_EDA_Config, m_ConfigPath ); + cfg = wxGetApp().m_EDA_Config; + + m_LastLibExportPath = cfg->Read( lastLibExportPathEntry, ::wxGetCwd() ); + m_LastLibImportPath = cfg->Read( lastLibImportPathEntry, ::wxGetCwd() ); +} + + +/** + * Save library editor frame specific configuration settings. + * + * Don't forget to call this base method from any derived classes or the + * settings will not get saved. + */ +void WinEDA_LibeditFrame::SaveSettings() +{ + wxConfig* cfg; + + WinEDA_DrawFrame::SaveSettings(); + + wxConfigPathChanger cpc( wxGetApp().m_EDA_Config, m_ConfigPath ); + cfg = wxGetApp().m_EDA_Config; + + cfg->Write( lastLibExportPathEntry, m_LastLibExportPath ); + cfg->Write( lastLibImportPathEntry, m_LastLibImportPath ); +} + + /***********************************************************/ void WinEDA_LibeditFrame::OnCloseWindow( wxCloseEvent& Event ) /***********************************************************/ @@ -101,7 +163,8 @@ void WinEDA_LibeditFrame::OnCloseWindow( wxCloseEvent& Event ) { if( !IsOK( this, _( "Component was modified!\nDiscard changes?" ) ) ) { - Event.Veto(); return; + Event.Veto(); + return; } else GetScreen()->ClrModify(); @@ -112,7 +175,8 @@ void WinEDA_LibeditFrame::OnCloseWindow( wxCloseEvent& Event ) if( Lib->m_Modified ) { wxString msg; - msg.Printf( _( "Library \"%s\" was modified!\nDiscard changes?" ), Lib->m_Name.GetData() ); + msg.Printf( _( "Library \"%s\" was modified!\nDiscard changes?" ), + Lib->m_Name.GetData() ); if( !IsOK( this, msg ) ) { Event.Veto(); @@ -152,9 +216,6 @@ void WinEDA_LibeditFrame::SetToolbars() { if( m_HToolBar ) { - m_HToolBar->EnableTool( ID_LIBEDIT_IMPORT_PART, true ); - m_HToolBar->EnableTool( ID_LIBEDIT_EXPORT_PART, false ); - m_HToolBar->EnableTool( ID_LIBEDIT_CREATE_NEW_LIB_AND_SAVE_CURRENT_PART, false ); m_HToolBar->EnableTool( ID_LIBEDIT_SAVE_CURRENT_PART, false ); m_HToolBar->EnableTool( ID_DE_MORGAN_CONVERT_BUTT, false ); m_HToolBar->EnableTool( ID_DE_MORGAN_NORMAL_BUTT, false ); @@ -186,9 +247,6 @@ void WinEDA_LibeditFrame::SetToolbars() { if( m_HToolBar ) { - m_HToolBar->EnableTool( ID_LIBEDIT_IMPORT_PART, true ); - m_HToolBar->EnableTool( ID_LIBEDIT_EXPORT_PART, true ); - m_HToolBar->EnableTool( ID_LIBEDIT_CREATE_NEW_LIB_AND_SAVE_CURRENT_PART, true ); m_HToolBar->EnableTool( ID_LIBEDIT_SAVE_CURRENT_PART, true ); m_HToolBar->EnableTool( ID_LIBEDIT_GET_FRAME_EDIT_FIELDS, true ); if( (CurrentLibEntry->m_UnitCount > 1) || g_AsDeMorgan ) @@ -286,6 +344,17 @@ int WinEDA_LibeditFrame::BestZoom() } +void WinEDA_LibeditFrame::OnUpdateEditingPart( wxUpdateUIEvent& event ) +{ + event.Enable( CurrentLibEntry != NULL ); +} + +void WinEDA_LibeditFrame::OnUpdateNotEditingPart( wxUpdateUIEvent& event ) +{ + event.Enable( CurrentLibEntry == NULL ); +} + + /*************************************************************************/ void WinEDA_LibeditFrame::Process_Special_Functions( wxCommandEvent& event ) /*************************************************************************/ @@ -389,21 +458,6 @@ void WinEDA_LibeditFrame::Process_Special_Functions( wxCommandEvent& event ) DeleteOnePart(); break; - case ID_LIBEDIT_IMPORT_PART: - LibItemToRepeat = NULL; - ImportOnePart(); - GetScreen()->ClearUndoRedoList(); - DrawPanel->Refresh(); - break; - - case ID_LIBEDIT_EXPORT_PART: - ExportOnePart( false ); - break; - - case ID_LIBEDIT_CREATE_NEW_LIB_AND_SAVE_CURRENT_PART: - ExportOnePart( true ); - break; - case ID_LIBEDIT_CHECK_PART: if( CurrentLibEntry ) if( TestPins( CurrentLibEntry ) == false ) diff --git a/eeschema/load_one_schematic_file.cpp b/eeschema/load_one_schematic_file.cpp index 18bc6ad621..8745c25fe9 100644 --- a/eeschema/load_one_schematic_file.cpp +++ b/eeschema/load_one_schematic_file.cpp @@ -12,37 +12,31 @@ /* in read_from_file_schematic_items_description.cpp */ SCH_ITEM* ReadTextDescr( FILE* aFile, wxString& aMsgDiag, char* aLine, - int aBufsize, int* aLineNum, int aSchematicFileVersion ); -int ReadSheetDescr( wxWindow* frame, - char* Line, - FILE* f, - wxString& aMsgDiag, - int* aLineNum, - BASE_SCREEN* Window ); -int ReadSchemaDescr( wxWindow* frame, - char* Line, - FILE* f, - wxString& aMsgDiag, - int* aLineNum, - BASE_SCREEN* Window ); + int aBufsize, int* aLineNum, + int aSchematicFileVersion ); -int ReadPartDescr( wxWindow* frame, - char* Line, - FILE* f, - wxString& aMsgDiag, - int* aLineNum, - BASE_SCREEN* Window ); +extern int ReadSheetDescr( wxWindow* frame, char* Line, FILE* f, + wxString& aMsgDiag, int* aLineNum, + BASE_SCREEN* Window ); + +extern int ReadSchemaDescr( wxWindow* frame, char* Line, FILE* f, + wxString& aMsgDiag, int* aLineNum, + BASE_SCREEN* Window ); + +extern int ReadPartDescr( wxWindow* frame, char* Line, FILE* f, + wxString& aMsgDiag, int* aLineNum, + BASE_SCREEN* Window ); /* Fonctions locales */ static void LoadLayers( FILE* f, int* linecnt ); -/************************************************************************************************/ -bool WinEDA_SchematicFrame::LoadOneEEFile( SCH_SCREEN* screen, const wxString& FullFileName ) -/************************************************************************************************/ -/* Routine to load an EESchema file. +/** + * Routine to load an EESchema file. * Returns true if file has been loaded (at least partially.) */ +bool WinEDA_SchematicFrame::LoadOneEEFile( SCH_SCREEN* screen, + const wxString& FullFileName ) { char Line[1024], * SLine; char Name1[256], @@ -57,7 +51,7 @@ bool WinEDA_SchematicFrame::LoadOneEEFile( SCH_SCREEN* screen, const wxString& F DrawBusEntryStruct* RaccordStruct; DrawMarkerStruct* MarkerStruct; DrawNoConnectStruct* NoConnectStruct; - int LineCount; /* Decompte de num de ligne lue dans eeload() */ + int LineCount; wxString MsgDiag; /* Error and log messages */ FILE* f; @@ -82,8 +76,8 @@ bool WinEDA_SchematicFrame::LoadOneEEFile( SCH_SCREEN* screen, const wxString& F PrintMsg( MsgDiag ); if( fgets( Line, sizeof(Line), f ) == NULL - || strncmp( Line + 9, SCHEMATIC_HEAD_STRING, sizeof(SCHEMATIC_HEAD_STRING) - 1 ) - != 0 ) + || strncmp( Line + 9, SCHEMATIC_HEAD_STRING, + sizeof(SCHEMATIC_HEAD_STRING) - 1 ) != 0 ) { MsgDiag = FullFileName + _( " is NOT an EESchema file!" ); DisplayError( this, MsgDiag ); @@ -96,18 +90,20 @@ bool WinEDA_SchematicFrame::LoadOneEEFile( SCH_SCREEN* screen, const wxString& F int ver = version - '0'; if( ver > EESCHEMA_VERSION ) { - MsgDiag = FullFileName + _( - " was created by a more recent version of EESchema and may not load correctly. Please consider updating!" ); + MsgDiag = FullFileName + _( " was created by a more recent " \ + "version of EESchema and may not load " \ + "correctly. Please consider updating!" ); DisplayInfo( this, MsgDiag ); } #if 0 - // Compile it if the new version is unreadable by previous eeschema versions else if( ver < EESCHEMA_VERSION ) { - MsgDiag = FullFileName + _( - " was created by an older version of EESchema. It will be stored in the new file format when you save this file again." ); + MsgDiag = FullFileName + _( " was created by an older version of " \ + "EESchema. It will be stored in the new " \ + "file format when you save this file " \ + "again." ); DisplayInfo( this, MsgDiag ); } #endif @@ -142,13 +138,16 @@ bool WinEDA_SchematicFrame::LoadOneEEFile( SCH_SCREEN* screen, const wxString& F { case '$': /* identification de bloc */ if( Line[1] == 'C' ) - Failed = ReadPartDescr( this, Line, f, MsgDiag, &LineCount, screen ); + Failed = ReadPartDescr( this, Line, f, MsgDiag, &LineCount, + screen ); else if( Line[1] == 'S' ) - Failed = ReadSheetDescr( this, Line, f, MsgDiag, &LineCount, screen ); + Failed = ReadSheetDescr( this, Line, f, MsgDiag, &LineCount, + screen ); else if( Line[1] == 'D' ) - Failed = ReadSchemaDescr( this, Line, f, MsgDiag, &LineCount, screen ); + Failed = ReadSchemaDescr( this, Line, f, MsgDiag, &LineCount, + screen ); break; @@ -160,9 +159,8 @@ bool WinEDA_SchematicFrame::LoadOneEEFile( SCH_SCREEN* screen, const wxString& F case 'W': /* Its a Segment (WIRE or BUS) item. */ if( sscanf( SLine, "%s %s", Name1, Name2 ) != 2 ) { - MsgDiag.Printf( - wxT( "EESchema file Segment struct error at line %d, aborted" ), - LineCount ); + MsgDiag.Printf( wxT( "EESchema file Segment struct error " \ + "at line %d, aborted" ), LineCount ); MsgDiag << wxT( "\n" ) << CONV_FROM_UTF8( Line ); Failed = true; break; @@ -177,13 +175,12 @@ bool WinEDA_SchematicFrame::LoadOneEEFile( SCH_SCREEN* screen, const wxString& F LineCount++; if( fgets( Line, 256 - 1, f ) == NULL - || sscanf( Line, "%d %d %d %d ", - &SegmentStruct->m_Start.x, &SegmentStruct->m_Start.y, - &SegmentStruct->m_End.x, &SegmentStruct->m_End.y ) != 4 ) + || sscanf( Line, "%d %d %d %d ", &SegmentStruct->m_Start.x, + &SegmentStruct->m_Start.y, &SegmentStruct->m_End.x, + &SegmentStruct->m_End.y ) != 4 ) { - MsgDiag.Printf( - wxT( "EESchema file Segment struct error at line %d, aborted" ), - LineCount ); + MsgDiag.Printf( wxT( "EESchema file Segment struct error " \ + "at line %d, aborted" ), LineCount ); MsgDiag << wxT( "\n" ) << CONV_FROM_UTF8( Line ); Failed = true; SAFE_DELETE( SegmentStruct ); @@ -201,9 +198,8 @@ bool WinEDA_SchematicFrame::LoadOneEEFile( SCH_SCREEN* screen, const wxString& F case 'E': /* Its a Raccord (WIRE or BUS) item. */ if( sscanf( SLine, "%s %s", Name1, Name2 ) != 2 ) { - MsgDiag.Printf( - wxT( "EESchema file record struct error at line %d, aborted" ), - LineCount ); + MsgDiag.Printf( wxT( "EESchema file record struct error at " \ + "line %d, aborted" ), LineCount ); MsgDiag << wxT( "\n" ) << CONV_FROM_UTF8( Line ); Failed = true; break; @@ -216,13 +212,12 @@ bool WinEDA_SchematicFrame::LoadOneEEFile( SCH_SCREEN* screen, const wxString& F LineCount++; if( fgets( Line, 256 - 1, f ) == NULL - || sscanf( Line, "%d %d %d %d ", - &RaccordStruct->m_Pos.x, &RaccordStruct->m_Pos.y, - &RaccordStruct->m_Size.x, &RaccordStruct->m_Size.y ) != 4 ) + || sscanf( Line, "%d %d %d %d ", &RaccordStruct->m_Pos.x, + &RaccordStruct->m_Pos.y, &RaccordStruct->m_Size.x, + &RaccordStruct->m_Size.y ) != 4 ) { - MsgDiag.Printf( - wxT( "EESchema file Bus Entry struct error at line %d, aborted" ), - LineCount ); + MsgDiag.Printf( wxT( "EESchema file Bus Entry struct error " \ + "at line %d, aborted" ), LineCount ); MsgDiag << wxT( "\n" ) << CONV_FROM_UTF8( Line ); Failed = true; SAFE_DELETE( RaccordStruct ); @@ -241,9 +236,8 @@ bool WinEDA_SchematicFrame::LoadOneEEFile( SCH_SCREEN* screen, const wxString& F case 'P': /* Its a polyline item. */ if( sscanf( SLine, "%s %s %d", Name1, Name2, &ii ) != 3 ) { - MsgDiag.Printf( - wxT( "EESchema file polyline struct error at line %d, aborted" ), - LineCount ); + MsgDiag.Printf( wxT( "EESchema file polyline struct error " \ + "at line %d, aborted" ), LineCount ); MsgDiag << wxT( "\n" ) << CONV_FROM_UTF8( Line ); Failed = true; break; @@ -262,9 +256,9 @@ bool WinEDA_SchematicFrame::LoadOneEEFile( SCH_SCREEN* screen, const wxString& F if( fgets( Line, 256 - 1, f ) == NULL || sscanf( Line, "%d %d", &point.x, &point.y ) != 2 ) { - MsgDiag.Printf( - wxT( "EESchema file polyline struct error at line %d, aborted" ), - LineCount ); + MsgDiag.Printf( wxT( "EESchema file polyline struct " \ + "error at line %d, aborted" ), + LineCount ); MsgDiag << wxT( "\n" ) << CONV_FROM_UTF8( Line ); Failed = true; SAFE_DELETE( PolylineStruct ); @@ -284,13 +278,11 @@ bool WinEDA_SchematicFrame::LoadOneEEFile( SCH_SCREEN* screen, const wxString& F case 'C': /* It is a connection item. */ ConnectionStruct = new DrawJunctionStruct( wxPoint( 0, 0 ) ); - if( sscanf( SLine, "%s %d %d", Name1, - &ConnectionStruct->m_Pos.x, - &ConnectionStruct->m_Pos.y ) != 3 ) + if( sscanf( SLine, "%s %d %d", Name1, &ConnectionStruct->m_Pos.x, + &ConnectionStruct->m_Pos.y ) != 3 ) { - MsgDiag.Printf( - wxT( "EESchema file connection struct error at line %d, aborted" ), - LineCount ); + MsgDiag.Printf( wxT( "EESchema file connection struct error " \ + "at line %d, aborted" ), LineCount ); MsgDiag << wxT( "\n" ) << CONV_FROM_UTF8( Line ); Failed = true; SAFE_DELETE( ConnectionStruct ); @@ -305,16 +297,14 @@ bool WinEDA_SchematicFrame::LoadOneEEFile( SCH_SCREEN* screen, const wxString& F case 'N': /* It is a NoConnect item. */ if( sscanf( SLine, "%s %d %d", Name1, &pos.x, &pos.y ) != 3 ) { - MsgDiag.Printf( - wxT( "EESchema file NoConnect struct error at line %d, aborted" ), - LineCount ); + MsgDiag.Printf( wxT( "EESchema file NoConnect struct error " \ + "at line %d, aborted" ), LineCount ); MsgDiag << wxT( "\n" ) << CONV_FROM_UTF8( Line ); Failed = true; } else { NoConnectStruct = new DrawNoConnectStruct( pos ); - NoConnectStruct->SetNext( screen->EEDrawList ); screen->EEDrawList = NoConnectStruct; } @@ -323,9 +313,8 @@ bool WinEDA_SchematicFrame::LoadOneEEFile( SCH_SCREEN* screen, const wxString& F case 'K': /* It is a Marker item. */ if( sscanf( SLine, "%s %d %d", Name1, &pos.x, &pos.y ) != 3 ) { - MsgDiag.Printf( - wxT( "EESchema file marker struct error line %d, aborted" ), - LineCount ); + MsgDiag.Printf( wxT( "EESchema file marker struct error " \ + "line %d, aborted" ), LineCount ); MsgDiag << wxT( "\n" ) << CONV_FROM_UTF8( Line ); Failed = true; } @@ -355,7 +344,8 @@ bool WinEDA_SchematicFrame::LoadOneEEFile( SCH_SCREEN* screen, const wxString& F case 'T': /* It is a text item. */ { SCH_ITEM* Struct; - Struct = ReadTextDescr( f, MsgDiag, Line, sizeof(Line), &LineCount, version); + Struct = ReadTextDescr( f, MsgDiag, Line, sizeof(Line), + &LineCount, version); if( Struct ) { Struct->SetNext( screen->EEDrawList ); @@ -368,9 +358,8 @@ bool WinEDA_SchematicFrame::LoadOneEEFile( SCH_SCREEN* screen, const wxString& F default: Failed = true; - MsgDiag.Printf( - wxT( "EESchema file undef structdef at line %d, aborted" ), - LineCount ); + MsgDiag.Printf( wxT( "EESchema file undefined object at line " \ + "%d, aborted" ), LineCount ); MsgDiag << wxT( "\n" ) << CONV_FROM_UTF8( Line ); break; } @@ -409,12 +398,7 @@ bool WinEDA_SchematicFrame::LoadOneEEFile( SCH_SCREEN* screen, const wxString& F } -/***********************************/ static void LoadLayers( FILE* f, int* linecnt ) -/***********************************/ - -/* Load the Layer Struct from a file - */ { int Number; char Line[1024]; diff --git a/eeschema/locate.cpp b/eeschema/locate.cpp index 6ea41dd8f4..7a8f77a250 100644 --- a/eeschema/locate.cpp +++ b/eeschema/locate.cpp @@ -11,6 +11,7 @@ #include "general.h" #include "trigo.h" #include "macros.h" +#include "class_drawpickedstruct.h" #include "protos.h" @@ -176,7 +177,7 @@ SCH_ITEM* PickStruct( EDA_Rect& block, BASE_SCREEN* screen, int SearchMask ) PickedBoxMaxX = x; PickedBoxMaxY = y; } - return PickedList; + return (SCH_ITEM*) PickedList; } diff --git a/eeschema/makefile.include b/eeschema/makefile.include index d015849881..38bf937646 100644 --- a/eeschema/makefile.include +++ b/eeschema/makefile.include @@ -54,7 +54,6 @@ OBJECTS = eeschema.o\ dialog_eeschema_config.o\ eelayer.o \ priorque.o eeconfig.o \ - affiche.o \ getpart.o\ netlist.o\ netlist_control.o\ diff --git a/eeschema/netform.cpp b/eeschema/netform.cpp index 1f083a49b5..b04336b2ad 100644 --- a/eeschema/netform.cpp +++ b/eeschema/netform.cpp @@ -12,6 +12,7 @@ #include "libcmp.h" #include "general.h" #include "netlist.h" +#include "appl_wxstruct.h" #include "protos.h" @@ -271,13 +272,13 @@ void Write_GENERIC_NetList( WinEDA_SchematicFrame* frame, wxString netname; int ii; FILE* tmpfile; - wxString TmpFullFileName = FullFileName; + wxFileName fn = FullFileName; - ChangeFileNameExt( TmpFullFileName, wxT( ".tmp" ) ); + fn.SetExt( wxT( "tmp" ) ); - if( ( tmpfile = wxFopen( TmpFullFileName, wxT( "wt" ) ) ) == NULL ) + if( ( tmpfile = wxFopen( fn.GetFullPath(), wxT( "wt" ) ) ) == NULL ) { - wxString msg = _( "Failed to create file " ) + TmpFullFileName; + wxString msg = _( "Failed to create file " ) + fn.GetFullPath(); DisplayError( frame, msg ); return; } @@ -361,7 +362,7 @@ void Write_GENERIC_NetList( WinEDA_SchematicFrame* frame, else CommandFile = FindKicadFile( g_NetListerCommandLine ); - CommandFile += wxT( " " ) + TmpFullFileName; + CommandFile += wxT( " " ) + fn.GetFullPath(); CommandFile += wxT( " " ) + FullFileName; ProcessExecute( CommandFile, wxEXEC_SYNC ); @@ -947,7 +948,7 @@ static void WriteNetListCADSTAR( WinEDA_SchematicFrame* frame, FILE* f ) DrawSheetPath* sheet; EDA_BaseStruct* DrawList; SCH_COMPONENT* Component; - wxString Title = g_Main_Title + wxT( " " ) + GetBuildVersion(); + wxString Title = wxGetApp().GetAppName() + wxT( " " ) + GetBuildVersion(); fprintf( f, "%sHEA\n", CONV_TO_UTF8( StartLine ) ); DateAndTime( Line ); diff --git a/eeschema/netlist.cpp b/eeschema/netlist.cpp index c933dc4d54..b659d7c6e6 100644 --- a/eeschema/netlist.cpp +++ b/eeschema/netlist.cpp @@ -13,6 +13,10 @@ #include "netlist.h" /* Definitions generales liees au calcul de netliste */ #include "protos.h" +int g_NbrObjNet; +ObjetNetListStruct* g_TabObjNet = NULL; + + //#define NETLIST_DEBUG /* Routines locales */ diff --git a/eeschema/netlist.h b/eeschema/netlist.h index 99785a4cd6..bb07c9ad77 100644 --- a/eeschema/netlist.h +++ b/eeschema/netlist.h @@ -5,10 +5,6 @@ #ifndef _NETLIST_H_ #define _NETLIST_H_ -#ifndef eda_global -#define eda_global extern -#endif - #define NETLIST_HEAD_STRING "EESchema Netlist Version 1.1" #define ISBUS 1 @@ -147,8 +143,9 @@ public: /* Global Variables */ -eda_global int g_NbrObjNet; -eda_global ObjetNetListStruct* g_TabObjNet; +extern int g_NbrObjNet; +extern ObjetNetListStruct* g_TabObjNet; + /* Prototypes: */ void WriteNetList( WinEDA_SchematicFrame* frame, diff --git a/eeschema/netlist_control.cpp b/eeschema/netlist_control.cpp index 6e19de7712..25b836c12b 100644 --- a/eeschema/netlist_control.cpp +++ b/eeschema/netlist_control.cpp @@ -437,7 +437,8 @@ void WinEDA_NetlistFrame::GenNetlist( wxCommandEvent& event ) * and run the netlist creator */ { - wxString FullFileName, FileExt, Mask; + wxFileName fn; + wxString FileWildcard, FileExt; wxString msg, Command; int netformat_tmp = g_NetFormat; @@ -449,36 +450,33 @@ void WinEDA_NetlistFrame::GenNetlist( wxCommandEvent& event ) g_NetFormat = CurrPage->m_IdNetType; /* Calculate the netlist filename */ - FullFileName = g_RootSheet->m_AssociatedScreen->m_FileName; + fn = g_RootSheet->m_AssociatedScreen->m_FileName; switch( g_NetFormat ) { case NET_TYPE_SPICE: - FileExt = wxT( ".cir" ); + FileExt = wxT( "cir" ); + FileWildcard = _( "SPICE netlist file (.cir)|*.cir" ); break; case NET_TYPE_CADSTAR: - FileExt = wxT( ".frp" ); + FileExt = wxT( "frp" ); + FileWildcard = _( "CadStar netlist file (.frp)|*.frp" ); break; default: - FileExt = g_NetExtBuffer; + FileExt = NetlistFileExtension; + FileWildcard = NetlistFileWildcard; break; } - Mask = wxT( "*" ) + FileExt; - ChangeFileNameExt( FullFileName, FileExt ); - FullFileName = FullFileName.AfterLast( '/' ); - FullFileName = EDA_FileSelector( _( "Netlist files:" ), - wxEmptyString, /* Defaut path */ - FullFileName, /* Defaut filename */ - FileExt, /* Defaut extension */ - Mask, /* Mask for filename selection */ - this, - wxFD_SAVE, - TRUE - ); - if( FullFileName.IsEmpty() ) + fn.SetExt( FileExt ); + + wxFileDialog dlg( this, _( "Save Netlist Files" ), fn.GetPath(), + fn.GetFullName(), FileWildcard, + wxFD_SAVE | wxFD_OVERWRITE_PROMPT ); + + if( dlg.ShowModal() == wxID_CANCEL ) return; m_Parent->MsgPanel->EraseMsgBox(); @@ -514,18 +512,18 @@ void WinEDA_NetlistFrame::GenNetlist( wxCommandEvent& event ) switch( g_NetFormat ) { default: - WriteNetList( m_Parent, FullFileName, TRUE ); + WriteNetList( m_Parent, dlg.GetPath(), TRUE ); break; case NET_TYPE_CADSTAR: case NET_TYPE_ORCADPCB2: - WriteNetList( m_Parent, FullFileName, FALSE ); + WriteNetList( m_Parent, dlg.GetPath(), FALSE ); case NET_TYPE_SPICE: g_OptNetListUseNames = TRUE; // Used for pspice, gnucap if( m_UseNetNamesInNetlist->GetSelection() == 1 ) g_OptNetListUseNames = FALSE; - WriteNetList( m_Parent, FullFileName, g_OptNetListUseNames ); + WriteNetList( m_Parent, dlg.GetPath(), g_OptNetListUseNames ); break; } @@ -550,7 +548,8 @@ void WinEDA_NetlistFrame::OnCancelClick( wxCommandEvent& event ) void WinEDA_NetlistFrame::RunSimulator( wxCommandEvent& event ) /***********************************************************/ { - wxString NetlistFullFileName, ExecFile, CommandLine; + wxFileName fn; + wxString ExecFile, CommandLine; g_SimulatorCommandLine = m_PanelNetType[PANELSPICE]->m_CommandStringCtrl->GetValue(); @@ -561,10 +560,9 @@ void WinEDA_NetlistFrame::RunSimulator( wxCommandEvent& event ) CommandLine = g_SimulatorCommandLine.AfterFirst( ' ' ); /* Calculate the netlist filename */ - NetlistFullFileName = g_RootSheet->m_AssociatedScreen->m_FileName; - ChangeFileNameExt( NetlistFullFileName, wxT( ".cir" ) ); - AddDelimiterString( NetlistFullFileName ); - CommandLine += wxT( " " ) + NetlistFullFileName; + fn = g_RootSheet->m_AssociatedScreen->m_FileName; + fn.SetExt( wxT( "cir" ) ); + CommandLine += wxT( " \"" ) + fn.GetFullPath() + wxT( "\"" ); ExecuteFile( this, ExecFile, CommandLine ); } diff --git a/eeschema/pinedit.cpp b/eeschema/pinedit.cpp index 9c2801becf..40422e385c 100644 --- a/eeschema/pinedit.cpp +++ b/eeschema/pinedit.cpp @@ -107,7 +107,7 @@ void WinEDA_PinPropertiesFrame::PinPropertiesAccept( wxCommandEvent& event ) } if( CurrentDrawItem ) - CurrentDrawItem->Display_Infos_DrawEntry( m_Parent ); + CurrentDrawItem->DisplayInfo( m_Parent ); Close(); } @@ -151,7 +151,7 @@ void WinEDA_LibeditFrame::InitEditOnePin() Pin->m_Flags = 0; } - CurrentPin->Display_Infos_DrawEntry( this ); + CurrentPin->DisplayInfo( this ); } @@ -323,7 +323,7 @@ void WinEDA_LibeditFrame::StartMovePin( wxDC* DC ) GetScreen()->m_Curseur = startPos; DrawPanel->MouseToCursorSchema(); - CurrentPin->Display_Infos_DrawEntry( this ); + CurrentPin->DisplayInfo( this ); DrawPanel->ManageCurseur = DrawMovePin; DrawPanel->ForceCloseManageCurseur = AbortPinMove; @@ -378,7 +378,7 @@ void WinEDA_PinPropertiesFrame::SetPinShape( int newshape ) { CurrentPin->m_PinShape = newshape; m_Parent->GetScreen()->SetModify(); - CurrentPin->Display_Infos_DrawEntry( m_Parent ); + CurrentPin->DisplayInfo( m_Parent ); Pin = (LibDrawPin*) CurrentLibEntry->m_Drawings; for( ; Pin != NULL; Pin = Pin->Next() ) @@ -621,7 +621,7 @@ void WinEDA_LibeditFrame::CreatePin( wxDC* DC ) DrawPanel->ManageCurseur = DrawMovePin; DrawPanel->ForceCloseManageCurseur = AbortPinMove; - CurrentPin->Display_Infos_DrawEntry( this ); + CurrentPin->DisplayInfo( this ); GetScreen()->SetModify(); } @@ -759,7 +759,7 @@ void WinEDA_PinPropertiesFrame::NewSizePin( int newsize ) Pin->m_PinLen = newsize; - Pin->Display_Infos_DrawEntry( m_Parent ); + Pin->DisplayInfo( m_Parent ); RefPin = Pin; @@ -941,7 +941,7 @@ void WinEDA_LibeditFrame::RepeatPinItem( wxDC* DC, LibDrawPin* SourcePin ) // DrawPanel->MouseToCursorSchema(); DrawPanel->CursorOn( DC ); - Pin->Display_Infos_DrawEntry( this ); + Pin->DisplayInfo( this ); GetScreen()->SetModify(); } diff --git a/eeschema/program.h b/eeschema/program.h index 1fc52cd6b2..6373d94e45 100644 --- a/eeschema/program.h +++ b/eeschema/program.h @@ -5,10 +5,6 @@ #ifndef PROGRAM_H #define PROGRAM_H -#ifndef eda_global -#define eda_global extern -#endif - #include "wxEeschemaStruct.h" #include "macros.h" #include "base_struct.h" @@ -25,23 +21,20 @@ #define TEXT_NO_VISIBLE 1 -#define MIN_BUSLINES_THICKNESS 12 // min bus lines and entries thickness - -/* Rotation, mirror of graphic items in components bodies are handled by a transform matrix - * The default matix is useful to draw lib entries with a defualt matix ( no rotation, no mirrot - * but Y axis is bottom to top, and Y draw axis is to to bottom - * so we must have a default matix that reverses the Y coordinate and keeps the X coordiante +/* Rotation, mirror of graphic items in components bodies are handled by a + * transform matrix. The default matix is useful to draw lib entries with + * a defualt matix ( no rotation, no mirror but Y axis is bottom to top, and + * Y draw axis is to to bottom so we must have a default matix that reverses + * the Y coordinate and keeps the X coordiate * DefaultTransformMatrix[0][0] = 1; DefaultTransformMatrix[1][1] = -1; * DefaultTransformMatrix[1][0] = DefaultTransformMatrix[0][1] = 0; */ -eda_global int DefaultTransformMatrix[2][2] -#ifdef MAIN - = { {1, 0}, {0, -1} } -#endif -; +extern int DefaultTransformMatrix[2][2]; +#define MIN_BUSLINES_THICKNESS 12 // min bus lines and entries thickness #define MAX_LAYERS 44 + class LayerStruct { public: diff --git a/eeschema/protos.h b/eeschema/protos.h index bcb4c06751..7e9c0f4b85 100644 --- a/eeschema/protos.h +++ b/eeschema/protos.h @@ -1,6 +1,7 @@ //*****************************************/ /* prototypage des fonctions de EESchema */ /*****************************************/ + void FreeLibraryEntry(LibCmpEntry * Entry); LibEDA_BaseStruct * LocatePin(const wxPoint & RefPos, diff --git a/eeschema/read_from_file_schematic_items_descriptions.cpp b/eeschema/read_from_file_schematic_items_descriptions.cpp index 0a94180e95..686943a521 100644 --- a/eeschema/read_from_file_schematic_items_descriptions.cpp +++ b/eeschema/read_from_file_schematic_items_descriptions.cpp @@ -13,12 +13,13 @@ #include "protos.h" -SCH_ITEM* ReadTextDescr( FILE * aFile, - wxString & aMsgDiag, - char* aLine, - int aBufsize, - int* aLineNum, - int aSchematicFileVersion ) { +SCH_ITEM* ReadTextDescr( FILE* aFile, + wxString& aMsgDiag, + char* aLine, + int aBufsize, + int* aLineNum, + int aSchematicFileVersion ) +{ /** * Function ReadTextDescr * Reads the data structures for a Text (Comment, label, Hlabel and Hlabel @@ -44,8 +45,8 @@ SCH_ITEM* ReadTextDescr( FILE * aFile, // SLine points the start of parameters Name1[0] = 0; Name2[0] = 0; Name3[0] = 0; - int ii = sscanf( SLine, "%s %d %d %d %d %s %s %d", - Name1, &pos.x, &pos.y, &orient, &size, Name2, Name3, &thickness ); + int ii = sscanf( SLine, "%s %d %d %d %d %s %s %d", Name1, &pos.x, &pos.y, + &orient, &size, Name2, Name3, &thickness ); if( ii < 4 ) { @@ -86,7 +87,8 @@ SCH_ITEM* ReadTextDescr( FILE * aFile, } else if( Name1[0] == 'G' && aSchematicFileVersion > '1' ) { - SCH_GLOBALLABEL* TextStruct = new SCH_GLOBALLABEL( pos, CONV_FROM_UTF8( text ) ); + SCH_GLOBALLABEL* TextStruct = + new SCH_GLOBALLABEL( pos, CONV_FROM_UTF8( text ) ); Struct = TextStruct; TextStruct->m_Size.x = TextStruct->m_Size.y = size; @@ -105,9 +107,11 @@ SCH_ITEM* ReadTextDescr( FILE * aFile, if( stricmp( Name3, "Italic" ) == 0 ) TextStruct->m_Italic = 1; } - else if( (Name1[0] == 'H') || (Name1[0] == 'G' && aSchematicFileVersion == '1') ) - { //in schematic file version 1, glabels were actually hierarchal labels. - SCH_HIERLABEL* TextStruct = new SCH_HIERLABEL( pos, CONV_FROM_UTF8( text ) ); + else if( (Name1[0] == 'H') + || (Name1[0] == 'G' && aSchematicFileVersion == '1') ) //in schematic file version 1, glabels were actually hierarchal labels. + { + SCH_HIERLABEL* TextStruct = + new SCH_HIERLABEL( pos, CONV_FROM_UTF8( text ) ); Struct = TextStruct; TextStruct->m_Size.x = TextStruct->m_Size.y = size; @@ -148,19 +152,13 @@ SCH_ITEM* ReadTextDescr( FILE * aFile, } -/*************************************************************************************/ -int ReadSheetDescr( wxWindow* frame, - char* Line, - FILE* f, - wxString& aMsgDiag, int* aLineNum, - BASE_SCREEN* Window ) -/*************************************************************************************/ - /* Fonction utilisee par LoadEEFile(). * Lit les lignes relatives a la description d'une feuille de hierarchie */ +int ReadSheetDescr( wxWindow* frame, char* Line, FILE* f, wxString& aMsgDiag, + int* aLineNum, BASE_SCREEN* Window ) { - int ii, fieldNdx, size; + int ii, fieldNdx, size; char Name1[256], Char1[256], Char2[256]; DrawSheetStruct* SheetStruct; Hierarchical_PIN_Sheet_Struct* SheetLabelStruct, * OldSheetLabel = NULL; @@ -242,7 +240,8 @@ int ReadSheetDescr( wxWindow* frame, if( *ptcar == 0 ) { aMsgDiag.Printf( - wxT( "EESchema file sheet field F at line %d, aborted\n" ), *aLineNum ); + wxT( "EESchema file sheet field F at line %d, aborted\n" ), + *aLineNum ); aMsgDiag << CONV_FROM_UTF8( Line ); return TRUE; } @@ -257,9 +256,8 @@ int ReadSheetDescr( wxWindow* frame, { if( sscanf( ptcar, "%d", &size ) != 1 ) { - aMsgDiag.Printf( - wxT( - "EESchema file sheet Label Caract error line %d, aborted\n" ), *aLineNum ); + aMsgDiag.Printf( wxT( "EESchema file sheet Label Caract " \ + "error line %d, aborted\n" ), *aLineNum ); aMsgDiag << CONV_FROM_UTF8( Line ); DisplayError( frame, aMsgDiag ); } @@ -274,17 +272,17 @@ int ReadSheetDescr( wxWindow* frame, { SheetStruct->SetFileName( CONV_FROM_UTF8( Name1 ) ); - //printf("in ReadSheetDescr : SheetStruct->m_FileName = %s \n", Name1); + //printf( "in ReadSheetDescr : SheetStruct->m_FileName = %s \n", + // Name1 ); SheetStruct->m_FileNameSize = size; } } if( fieldNdx > 1 ) { - SheetLabelStruct = new Hierarchical_PIN_Sheet_Struct( SheetStruct, - wxPoint( 0, - 0 ), - CONV_FROM_UTF8( Name1 ) ); + SheetLabelStruct = + new Hierarchical_PIN_Sheet_Struct( SheetStruct, wxPoint( 0, 0 ), + CONV_FROM_UTF8( Name1 ) ); if( SheetStruct->m_Label == NULL ) OldSheetLabel = SheetStruct->m_Label = SheetLabelStruct; @@ -297,9 +295,8 @@ int ReadSheetDescr( wxWindow* frame, &SheetLabelStruct->m_Pos.x, &SheetLabelStruct->m_Pos.y, &size ) != 5 ) { - aMsgDiag.Printf( - wxT( - "EESchema file Sheet Label Caract error line %d, aborted\n" ), *aLineNum ); + aMsgDiag.Printf( wxT( "EESchema file Sheet Label Caract " \ + "error line %d, aborted\n" ), *aLineNum ); aMsgDiag << CONV_FROM_UTF8( Line ); DisplayError( frame, aMsgDiag ); continue; @@ -335,9 +332,8 @@ int ReadSheetDescr( wxWindow* frame, if( strnicmp( "$End", Line, 4 ) != 0 ) { - aMsgDiag.Printf( - wxT( " **EESchema file end_sheet struct error at line %d, aborted\n" ), - *aLineNum ); + aMsgDiag.Printf( wxT( "**EESchema file end_sheet struct error at " \ + "line %d, aborted\n" ), *aLineNum ); aMsgDiag << CONV_FROM_UTF8( Line ); Failed = TRUE; } @@ -352,22 +348,19 @@ int ReadSheetDescr( wxWindow* frame, /******************************************************************/ -bool ReadSchemaDescr( wxWindow* frame, - char* Line, - FILE* f, - wxString& aMsgDiag, int* aLineNum, - BASE_SCREEN* Window ) -/******************************************************************/ - /* Analyse de l'entete du schema ( dims feuille, cartouche..) */ +/******************************************************************/ +bool ReadSchemaDescr( wxWindow* frame, char* Line, FILE* f, wxString& aMsgDiag, + int* aLineNum, BASE_SCREEN* Window ) { - char Text[256], buf[1024]; - int ii; + char Text[256], buf[1024]; + int ii; Ki_PageDescr* wsheet = &g_Sheet_A4; - static Ki_PageDescr* SheetFormatList[] = { - &g_Sheet_A4, &g_Sheet_A3, &g_Sheet_A2, &g_Sheet_A1, &g_Sheet_A0, - &g_Sheet_A, &g_Sheet_B, &g_Sheet_C, &g_Sheet_D, &g_Sheet_E, + static Ki_PageDescr* SheetFormatList[] = + { + &g_Sheet_A4, &g_Sheet_A3, &g_Sheet_A2, &g_Sheet_A1, &g_Sheet_A0, + &g_Sheet_A, &g_Sheet_B, &g_Sheet_C, &g_Sheet_D, &g_Sheet_E, &g_Sheet_user, NULL }; wxSize PageSize; @@ -378,9 +371,10 @@ bool ReadSchemaDescr( wxWindow* frame, for( ii = 0; SheetFormatList[ii] != NULL; ii++ ) { wsheet = SheetFormatList[ii]; - if( wsheet->m_Name.CmpNoCase( pagename ) == 0 ) - { /* Descr found ! */ - if( wsheet == &g_Sheet_user ) // Get the user page size and make it the default + if( wsheet->m_Name.CmpNoCase( pagename ) == 0 ) /* Descr found ! */ + { + // Get the user page size and make it the default + if( wsheet == &g_Sheet_user ) { g_Sheet_user.m_Size = PageSize; } @@ -391,8 +385,8 @@ bool ReadSchemaDescr( wxWindow* frame, if( SheetFormatList[ii] == NULL ) { /* Erreur ici: descr non trouvee */ - aMsgDiag.Printf( - wxT( "EESchema file Dims Caract error line %d, aborted\n" ), *aLineNum ); + aMsgDiag.Printf( wxT( "EESchema file Dims Caract error line %d, " \ + "aborted\n" ), *aLineNum ); aMsgDiag << CONV_FROM_UTF8( Line ); DisplayError( frame, aMsgDiag ); } @@ -473,15 +467,11 @@ bool ReadSchemaDescr( wxWindow* frame, } -/*************************************************************/ -int ReadPartDescr( wxWindow* frame, char* Line, FILE* f, - wxString& aMsgDiag, int* aLineNum, - BASE_SCREEN* Window ) -/*************************************************************/ - /* Fonction utilisee par LoadEEFile(). * Lit les lignes relatives a la description d'un composant en schema */ +int ReadPartDescr( wxWindow* frame, char* Line, FILE* f, wxString& aMsgDiag, + int* aLineNum, BASE_SCREEN* Window ) { int ii; char Name1[256], Name2[256], @@ -698,12 +688,14 @@ int ReadPartDescr( wxWindow* frame, char* Line, FILE* f, if( fieldNdx >= component->GetFieldCount() ) { - // add as many fields as needed so the m_FieldId's are contiguous, no gaps. + // add as many fields as needed so the m_FieldId's are + // contiguous, no gaps. while( fieldNdx >= component->GetFieldCount() ) { int newNdx = component->GetFieldCount(); - SCH_CMP_FIELD field( wxPoint( 0, 0 ), newNdx, component, fieldName ); + SCH_CMP_FIELD field( wxPoint( 0, 0 ), newNdx, component, + fieldName ); component->AddField( field ); } } @@ -732,7 +724,8 @@ int ReadPartDescr( wxWindow* frame, char* Line, FILE* f, component->GetField( fieldNdx )->m_Size.x = DEFAULT_SIZE_TEXT; component->GetField( fieldNdx )->m_Orient = TEXT_ORIENT_HORIZ; - component->GetField( fieldNdx )->m_Size.y = component->GetField( fieldNdx )->m_Size.x; + component->GetField( fieldNdx )->m_Size.y = + component->GetField( fieldNdx )->m_Size.x; if( Char1[0] == 'V' ) component->GetField( fieldNdx )->m_Orient = TEXT_ORIENT_VERT; @@ -752,8 +745,8 @@ int ReadPartDescr( wxWindow* frame, char* Line, FILE* f, else component->GetField( fieldNdx )->m_Italic = false; if( Char3[2] == 'B' ) - component->GetField( fieldNdx )->m_Width = component->GetField( fieldNdx )-> - m_Size.x / 4; + component->GetField( fieldNdx )->m_Width = + component->GetField( fieldNdx )->m_Size.x / 4; else component->GetField( fieldNdx )->m_Width = 0; @@ -763,15 +756,15 @@ int ReadPartDescr( wxWindow* frame, char* Line, FILE* f, if( fieldNdx == REFERENCE ) if( component->GetField( fieldNdx )->m_Text[0] == '#' ) - component->GetField( fieldNdx )->m_Attributs |= TEXT_NO_VISIBLE; + component->GetField( fieldNdx )->m_Attributs |= + TEXT_NO_VISIBLE; } else break; } /* Lecture multi et position du composant */ - if( sscanf( Line, "%d %d %d", - &component->m_Multi, + if( sscanf( Line, "%d %d %d", &component->m_Multi, &component->m_Pos.x, &component->m_Pos.y ) != 3 ) { aMsgDiag.Printf( diff --git a/eeschema/save_schemas.cpp b/eeschema/save_schemas.cpp index 60cb20ad46..cf98900e91 100644 --- a/eeschema/save_schemas.cpp +++ b/eeschema/save_schemas.cpp @@ -27,8 +27,8 @@ static void SaveLayers( FILE* f ); *****************************************************************************/ bool WinEDA_SchematicFrame::SaveEEFile( SCH_SCREEN* screen, int FileSave ) { - wxString msg; - wxString Name, BakName; + wxString msg, tmp; + wxFileName schematicFileName, backupFileName; FILE* f; wxString dirbuf; @@ -42,39 +42,35 @@ bool WinEDA_SchematicFrame::SaveEEFile( SCH_SCREEN* screen, int FileSave ) switch( FileSave ) { case FILE_SAVE_AS: - dirbuf = wxGetCwd() + STRING_DIR_SEP; - Name = MakeFileName( dirbuf, screen->m_FileName, g_SchExtBuffer ); + schematicFileName = screen->m_FileName; + backupFileName = schematicFileName; + /* Rename the old file to a '.bak' one: */ - BakName = Name; - if( wxFileExists( Name ) ) + if( schematicFileName.FileExists() ) { - ChangeFileNameExt( BakName, wxT( ".bak" ) ); - wxRemoveFile( BakName ); /* delete Old .bak file */ - if( !wxRenameFile( Name, BakName ) ) + backupFileName.SetExt( wxT( "bak" ) ); + wxRemoveFile( backupFileName.GetFullPath() ); + + if( !wxRenameFile( schematicFileName.GetFullPath(), + backupFileName.GetFullPath() ) ) { - DisplayError( this, wxT( "Warning: unable to rename old file" ), 10 ); + DisplayError( this, + wxT( "Warning: unable to rename old file" ), 10 ); } } break; case FILE_SAVE_NEW: { - wxString mask = wxT( "*" ) + g_SchExtBuffer; - Name = EDA_FileSelector( _( "Schematic files:" ), - wxEmptyString, /* Chemin par defaut */ - screen->m_FileName, /* nom fichier par defaut, et resultat */ - g_SchExtBuffer, /* extension par defaut */ - mask, /* Masque d'affichage */ - this, - wxFD_SAVE, - FALSE - ); - if( Name.IsEmpty() ) - return FALSE; + wxFileDialog dlg( this, _( "Schematic Files" ), wxEmptyString, + screen->m_FileName, SchematicFileWildcard, + wxFD_SAVE | wxFD_OVERWRITE_PROMPT ); - screen->m_FileName = Name; - dirbuf = wxGetCwd() + STRING_DIR_SEP; - Name = MakeFileName( dirbuf, Name, g_SchExtBuffer ); + if( dlg.ShowModal() == wxID_CANCEL ) + return false; + + screen->m_FileName = dlg.GetPath(); + schematicFileName = dlg.GetPath(); break; } @@ -83,17 +79,18 @@ bool WinEDA_SchematicFrame::SaveEEFile( SCH_SCREEN* screen, int FileSave ) break; } - if( ( f = wxFopen( Name, wxT( "wt" ) ) ) == NULL ) + if( ( f = wxFopen( schematicFileName.GetFullPath(), wxT( "wt" ) ) ) == NULL ) { - msg = _( "Failed to create file " ) + Name; + msg = _( "Failed to create file " ) + schematicFileName.GetFullPath(); DisplayError( this, msg ); - return FALSE; + return false; } if( FileSave == FILE_SAVE_NEW ) - screen->m_FileName = Name; + screen->m_FileName = schematicFileName.GetFullPath(); bool success = screen->Save( f ); + if( !success ) DisplayError( this, _( "File write operation failed." ) ); else @@ -135,7 +132,7 @@ bool SCH_SCREEN::Save( FILE* aFile ) const // Creates header if( fprintf( aFile, "%s %s %d", EESCHEMA_FILE_STAMP, - SCHEMATIC_HEAD_STRING, EESCHEMA_VERSION ) == EOF ) + SCHEMATIC_HEAD_STRING, EESCHEMA_VERSION ) == EOF ) return FALSE; if( fprintf( aFile, " date %s\n", CONV_TO_UTF8(datetime) ) == EOF ) @@ -150,14 +147,13 @@ bool SCH_SCREEN::Save( FILE* aFile ) const PlotSheet = m_CurrentSheetDesc; fprintf( aFile, "$Descr %s %d %d\n", CONV_TO_UTF8( PlotSheet->m_Name ), - PlotSheet->m_Size.x, PlotSheet->m_Size.y ); + PlotSheet->m_Size.x, PlotSheet->m_Size.y ); /* Write ScreenNumber and NumberOfScreen; not very meaningfull for SheetNumber and Sheet Count * in a complex hierarchy, but usefull in simple hierarchy and flat hierarchy * Used also to serach the root sheet ( ScreenNumber = 1 ) withing the files */ fprintf( aFile, "Sheet %d %d\n", m_ScreenNumber, m_NumberOfScreen ); - fprintf( aFile, "Title \"%s\"\n", CONV_TO_UTF8( m_Title ) ); fprintf( aFile, "Date \"%s\"\n", CONV_TO_UTF8( m_Date ) ); fprintf( aFile, "Rev \"%s\"\n", CONV_TO_UTF8( m_Revision ) ); @@ -170,43 +166,16 @@ bool SCH_SCREEN::Save( FILE* aFile ) const fprintf( aFile, "$EndDescr\n" ); /* Saving schematic items */ - bool failed = FALSE; - for( SCH_ITEM* item = EEDrawList; item; item = item->Next() ) + bool failed = false; + + for( SCH_ITEM* item = EEDrawList; item && !failed; item = item->Next() ) { - switch( item->Type() ) - { - case TYPE_SCH_COMPONENT: /* Its a library item. */ - case DRAW_SHEET_STRUCT_TYPE: /* Its a Sheet item. */ - case DRAW_SEGMENT_STRUCT_TYPE: /* Its a Segment item. */ - case DRAW_BUSENTRY_STRUCT_TYPE: /* Its a Raccord item. */ - case DRAW_POLYLINE_STRUCT_TYPE: /* Its a polyline item. */ - case DRAW_JUNCTION_STRUCT_TYPE: /* Its a connection item. */ - case DRAW_NOCONNECT_STRUCT_TYPE: /* Its a NoConnection item. */ - case TYPE_SCH_TEXT: /* Its a text item. */ - case TYPE_SCH_LABEL: /* Its a label item. */ - case TYPE_SCH_GLOBALLABEL: /* Its a Global label item. */ - case TYPE_SCH_HIERLABEL: /* Its a Hierarchical label item. */ - case DRAW_MARKER_STRUCT_TYPE: /* Its a marker item. */ - if( !item->Save( aFile ) ) - failed = TRUE; - break; - - /* - * case DRAW_HIERARCHICAL_PIN_SHEET_STRUCT_TYPE: - * case DRAW_PICK_ITEM_STRUCT_TYPE: - * break; - */ - - default: - break; - } - - if( failed ) - break; + if( !item->Save( aFile ) ) + failed = true; } if( fprintf( aFile, "$EndSCHEMATC\n" ) == EOF ) - failed = TRUE; + failed = true; return !failed; } diff --git a/eeschema/savelib.cpp b/eeschema/savelib.cpp index 622aa59247..9c6640e0e8 100644 --- a/eeschema/savelib.cpp +++ b/eeschema/savelib.cpp @@ -2,7 +2,8 @@ /* EESchema - eesavlib.cpp */ /****************************/ -/* Functions to save schematic libraries and library components (::Save() members) +/* Functions to save schematic libraries and library components (::Save() + * members) */ #include "fctsys.h" @@ -17,185 +18,18 @@ #include "protos.h" -/* Routines locales */ - -/* Variables locales */ - - -static bool WriteLibEntryDateAndTime( FILE* ExportFile, - EDA_LibComponentStruct* LibEntry ); - - -static int fill_tab[3] = { 'N', 'F', 'f' }; - -/***********************************************/ -bool LibDrawArc::Save( FILE* ExportFile ) const -/***********************************************/ - -/* format - * A centre_posx centre_posy rayon start_angle end_angle unit convert fill('N', 'F' ou 'f') startx starty endx endy - */ -{ - int x1 = t1; if( x1 > 1800 ) - x1 -= 3600; - - int x2 = t2; if( x2 > 1800 ) - x2 -= 3600; - - fprintf( ExportFile, "A %d %d %d %d %d %d %d %d %c %d %d %d %d\n", - m_Pos.x, m_Pos.y, - m_Rayon, x1, x2, - m_Unit, m_Convert, - m_Width, fill_tab[m_Fill], - m_ArcStart.x, m_ArcStart.y, m_ArcEnd.x, m_ArcEnd.y ); - return true; -} - - -/***************************************************/ -bool LibDrawCircle::Save( FILE* ExportFile ) const -/***************************************************/ -{ - fprintf( ExportFile, "C %d %d %d %d %d %d %c\n", - m_Pos.x, m_Pos.y, - m_Rayon, - m_Unit, m_Convert, - m_Width, fill_tab[m_Fill] ); - return true; -} - - -/************************************************/ -bool LibDrawText::Save( FILE* ExportFile ) const -/************************************************/ -{ - wxString text = m_Text; - // Spaces are not allowed in text because it is not double quoted: changed to '~' - text.Replace( wxT( " " ), wxT( "~" ) ); - - fprintf( ExportFile, "T %d %d %d %d %d %d %d %s ", - m_Orient, - m_Pos.x, m_Pos.y, - m_Size.x, m_Attributs, - m_Unit, m_Convert, - CONV_TO_UTF8( text )); - - fprintf( ExportFile, " %s %d", m_Italic ? "Italic" : "Normal", m_Width ); - - fprintf( ExportFile, "\n"); - return true; -} - - -/***************************************************/ -bool LibDrawSquare::Save( FILE* ExportFile ) const -/***************************************************/ -{ - fprintf( ExportFile, "S %d %d %d %d %d %d %d %c\n", - m_Pos.x, m_Pos.y, m_End.x, m_End.y, - m_Unit, m_Convert, - m_Width, fill_tab[m_Fill] ); - return true; -} - - -/************************************************/ -bool LibDrawPin::Save( FILE* ExportFile ) const -/************************************************/ -{ - wxString StringPinNum; - int Etype; - - switch( m_PinType ) - { - default: - case PIN_INPUT: Etype = 'I'; break; - case PIN_OUTPUT: Etype = 'O'; break; - case PIN_BIDI: Etype = 'B'; break; - case PIN_TRISTATE: Etype = 'T'; break; - case PIN_PASSIVE: Etype = 'P'; break; - case PIN_UNSPECIFIED: Etype = 'U'; break; - case PIN_POWER_IN: Etype = 'W'; break; - case PIN_POWER_OUT: Etype = 'w'; break; - case PIN_OPENCOLLECTOR: Etype = 'C'; break; - case PIN_OPENEMITTER: Etype = 'E'; break; - } - - ReturnPinStringNum( StringPinNum ); - if( StringPinNum.IsEmpty() ) - StringPinNum = wxT( "~" ); - - if( !m_PinName.IsEmpty() ) - fprintf( ExportFile, "X %s", CONV_TO_UTF8( m_PinName ) ); - else - fprintf( ExportFile, "X ~" ); - - fprintf( ExportFile, " %s %d %d %d %c %d %d %d %d %c", - CONV_TO_UTF8( StringPinNum ), - m_Pos.x, m_Pos.y, - (int) m_PinLen, (int) m_Orient, - m_PinNumSize, m_PinNameSize, - m_Unit, m_Convert, Etype ); - - if( (m_PinShape) || (m_Attributs & PINNOTDRAW) ) - fprintf( ExportFile, " " ); - if( m_Attributs & PINNOTDRAW ) - fprintf( ExportFile, "N" ); - if( m_PinShape & INVERT ) - fprintf( ExportFile, "I" ); - if( m_PinShape & CLOCK ) - fprintf( ExportFile, "C" ); - if( m_PinShape & LOWLEVEL_IN ) - fprintf( ExportFile, "L" ); - if( m_PinShape & LOWLEVEL_OUT ) - fprintf( ExportFile, "V" ); - - fprintf( ExportFile, "\n" ); - return true; -} - - -/****************************************************/ -bool LibDrawPolyline::Save( FILE* ExportFile ) const -/****************************************************/ -{ - int ccount = GetCornerCount(); - fprintf( ExportFile, "P %d %d %d %d", - ccount, - m_Unit, m_Convert, - m_Width ); - for( unsigned ii = 0; ii < GetCornerCount(); ii++ ) - { - fprintf( ExportFile, " %d %d", m_PolyPoints[ii].x, m_PolyPoints[ii].y ); - } - - fprintf( ExportFile, " %c\n", fill_tab[m_Fill] ); - return true; -} - -/****************************************************/ -bool LibDrawSegment::Save( FILE* ExportFile ) const -/****************************************************/ -{ - fprintf( ExportFile, "L %d %d %d", - m_Unit, m_Convert, - m_Width ); - return true; -} - - -/**********************************************************/ -LibEDA_BaseStruct* CopyDrawEntryStruct( wxWindow* frame, - LibEDA_BaseStruct* DrawItem ) -/**********************************************************/ /** Function CopyDrawEntryStruct * Duplicate a DrawLibItem - * the new item is only created, it is not put in the current component linked list + * the new item is only created, it is not put in the current component linked + * list * @param DrawEntry = DrawLibItem * item to duplicate * @return a pointer to the new item - * A better way to duplicate a DrawLibItem is to have a virtual GenCopy() in LibEDA_BaseStruct class (ToDo). + * A better way to duplicate a DrawLibItem is to have a virtual GenCopy() in + * LibEDA_BaseStruct class (ToDo). */ +LibEDA_BaseStruct* CopyDrawEntryStruct( wxWindow* frame, + LibEDA_BaseStruct* DrawItem ) { LibEDA_BaseStruct* NewDrawItem = NULL; wxString msg; @@ -228,7 +62,7 @@ LibEDA_BaseStruct* CopyDrawEntryStruct( wxWindow* frame, default: msg.Printf( wxT( "CopyDrawLibEntryStruct: unknown Draw Type %d" ), - DrawItem->Type() ); + DrawItem->Type() ); DisplayError( frame, msg ); break; } @@ -237,15 +71,14 @@ LibEDA_BaseStruct* CopyDrawEntryStruct( wxWindow* frame, } -/*************************************************************************************************/ -EDA_LibComponentStruct* CopyLibEntryStruct( wxWindow* frame, EDA_LibComponentStruct* OldEntry ) -/*************************************************************************************************/ - -/* Routine de copie d'une partlib +/* + * Routine de copie d'une partlib * Parametres d'entree: pointeur sur la structure de depart * Parametres de sortie: pointeur sur la structure creee * Do not copy new items ( i.e. with m_Flag & IS_NEW) */ +EDA_LibComponentStruct* CopyLibEntryStruct( wxWindow* frame, + EDA_LibComponentStruct* OldEntry ) { EDA_LibComponentStruct* NewStruct; LibEDA_BaseStruct* NewDrawings, * OldDrawings; @@ -277,7 +110,8 @@ EDA_LibComponentStruct* CopyLibEntryStruct( wxWindow* frame, EDA_LibComponentStr NewStruct->m_DocFile = OldEntry->m_DocFile; /* Copie des champs */ - for( OldField = OldEntry->m_Fields; OldField != NULL; OldField = OldField->Next() ) + for( OldField = OldEntry->m_Fields; OldField != NULL; + OldField = OldField->Next() ) { NewField = OldField->GenCopy(); NewStruct->m_Fields.PushBack( NewField ); @@ -285,7 +119,8 @@ EDA_LibComponentStruct* CopyLibEntryStruct( wxWindow* frame, EDA_LibComponentStr /* Copie des elements type Drawing */ LastItem = NULL; - for( OldDrawings = OldEntry->m_Drawings; OldDrawings != NULL; OldDrawings = OldDrawings->Next() ) + for( OldDrawings = OldEntry->m_Drawings; OldDrawings != NULL; + OldDrawings = OldDrawings->Next() ) { if( ( OldDrawings->m_Flags & IS_NEW) != 0 ) continue; @@ -302,7 +137,8 @@ EDA_LibComponentStruct* CopyLibEntryStruct( wxWindow* frame, EDA_LibComponentStr NewDrawings->SetNext( NULL ); } else // Should nevers occurs, just in case... - { // CopyDrawEntryStruct() was not able to duplicate the type of OldDrawings + { // CopyDrawEntryStruct() was not able to duplicate the type + // of OldDrawings // occurs when an unexpected type is encountered DisplayError( frame, wxT( "CopyLibEntryStruct(): error: aborted" ) ); break; @@ -315,256 +151,3 @@ EDA_LibComponentStruct* CopyLibEntryStruct( wxWindow* frame, EDA_LibComponentStr return NewStruct; } - -/************************************************/ -bool EDA_LibComponentStruct::Save( FILE* aFile ) -/***********************************************/ -/** - * Function Save - * writes the data structures for this object out to a FILE in "*.brd" format. - * @param aFile The FILE to write to. - * @return bool - true if success writing else false. - */ -#define UNUSED 0 -{ - LibEDA_BaseStruct* DrawEntry; - LibDrawField* Field; - - if( Type != ROOT ) // should not happen, but just in case - return false; - - /* First line: it s a comment (component name for readers) */ - fprintf( aFile, "#\n# %s\n#\n", CONV_TO_UTF8( m_Name.m_Text ) ); - - /* Save data */ - fprintf( aFile, "DEF" ); - if( (m_Name.m_Attributs & TEXT_NO_VISIBLE) == 0 ) - fprintf( aFile, " %s", CONV_TO_UTF8( m_Name.m_Text ) ); - else - fprintf( aFile, " ~%s", CONV_TO_UTF8( m_Name.m_Text ) ); - - if( !m_Prefix.m_Text.IsEmpty() ) - fprintf( aFile, " %s", CONV_TO_UTF8( m_Prefix.m_Text ) ); - else - fprintf( aFile, " ~" ); - fprintf( aFile, " %d %d %c %c %d %c %c\n", - UNUSED, m_TextInside, - m_DrawPinNum ? 'Y' : 'N', - m_DrawPinName ? 'Y' : 'N', - m_UnitCount, m_UnitSelectionLocked ? 'L' : 'F', - m_Options == ENTRY_POWER ? 'P' : 'N' ); - - WriteLibEntryDateAndTime( aFile, this ); - - /* Save fields */ - m_Prefix.Save( aFile ); - m_Name.Save( aFile ); - - for( Field = m_Fields; Field != NULL; Field = Field->Next() ) - { - if( Field->m_Text.IsEmpty() && Field->m_Name.IsEmpty() ) - continue; - Field->Save( aFile ); - } - - /* Save the alias list: a line starting by "ALIAS" */ - if( m_AliasList.GetCount() != 0 ) - { - fprintf( aFile, "ALIAS" ); - unsigned ii; - for( ii = 0; ii < m_AliasList.GetCount(); ii++ ) - fprintf( aFile, " %s", CONV_TO_UTF8( m_AliasList[ii] ) ); - - fprintf( aFile, "\n" ); - } - - /* Write the footprint filter list */ - if( m_FootprintList.GetCount() != 0 ) - { - fprintf( aFile, "$FPLIST\n" ); - unsigned ii; - for( ii = 0; ii < m_FootprintList.GetCount(); ii++ ) - fprintf( aFile, " %s\n", CONV_TO_UTF8( m_FootprintList[ii] ) ); - - fprintf( aFile, "$ENDFPLIST\n" ); - } - - /* Save graphics items (including pins) */ - if( m_Drawings ) - { - /* we sort the draw items, in order to have an edition more easy, - * when a file editing "by hand" is made */ - SortDrawItems(); - - fprintf( aFile, "DRAW\n" ); - DrawEntry = m_Drawings; - while( DrawEntry ) - { - DrawEntry->Save( aFile ); - DrawEntry = DrawEntry->Next(); - } - fprintf( aFile, "ENDDRAW\n" ); - } - - fprintf( aFile, "ENDDEF\n" ); - - return true; -} - - -/***************************************/ -bool LibCmpEntry::SaveDoc( FILE* aFile ) -/***************************************/ -/** - * Function SaveDoc - * writes the doc info out to a FILE in "*.dcm" format. - * Only non empty fields are written. - * If all fielsd are empty, does not write anything - * @param aFile The FILE to write to. - * @return bool - true if success writing else false. - */ -{ - if( m_Doc.IsEmpty() && m_KeyWord.IsEmpty() && m_DocFile.IsEmpty() ) - return true; - - /* Generation des lignes utiles */ - fprintf( aFile, "#\n$CMP %s\n", CONV_TO_UTF8( m_Name.m_Text ) ); - - if( ! m_Doc.IsEmpty() ) - fprintf( aFile, "D %s\n", CONV_TO_UTF8( m_Doc ) ); - - if( ! m_KeyWord.IsEmpty() ) - fprintf( aFile, "K %s\n", CONV_TO_UTF8( m_KeyWord ) ); - - if( ! m_DocFile.IsEmpty() ) - fprintf( aFile, "F %s\n", CONV_TO_UTF8( m_DocFile ) ); - - fprintf( aFile, "$ENDCMP\n" ); - return true; -} - - -/*********************************************************************************/ -bool LibraryStruct::SaveLibrary( const wxString& FullFileName ) -/*********************************************************************************/ -/** - * Function SaveLibrary - * writes the data structures for this object out to 2 file - * the library in "*.lib" format. - * the doc file in "*.dcm" format. - * creates a backup file for each file (.bak and .bck) - * @param aFullFileName The full lib filename. - * @return bool - true if success writing else false. - */ -{ - FILE* libfile, *docfile; - EDA_LibComponentStruct* LibEntry; - wxString libname, docname, backupname, msg; - - libname = FullFileName; - - /* the old .lib file is renamed .bak */ - if( wxFileExists( libname ) ) - { - backupname = libname; ChangeFileNameExt( backupname, wxT( ".bak" ) ); - wxRemoveFile( backupname ); - if( !wxRenameFile( libname, backupname ) ) - { - msg = wxT( "Failed to rename old lib file " ) + backupname; - DisplayError( NULL, msg, 20 ); - } - } - - docname = FullFileName; ChangeFileNameExt( docname, DOC_EXT ); - /* L'ancien fichier doc lib est renomme en .bck */ - if( wxFileExists( docname ) ) - { - backupname = docname; ChangeFileNameExt( backupname, wxT( ".bck" ) ); - wxRemoveFile( backupname ); - if( !wxRenameFile( docname, backupname ) ) - { - msg = wxT( "Failed to save old doc lib file " ) + backupname; - DisplayError( NULL, msg, 20 ); - } - } - - - libfile = wxFopen( libname, wxT( "wt" ) ); - if( libfile == NULL ) - { - msg = wxT( "Failed to create Lib File " ) + libname; - DisplayError( NULL, msg, 20 ); - return false; - } - - docfile = wxFopen( docname, wxT( "wt" ) ); - if( docfile == NULL ) - { - msg = wxT( "Failed to create DocLib File " ) + docname; - DisplayError( NULL, msg, 20 ); - } - - m_Modified = 0; - - /* Creation de l'entete de la librairie */ - m_TimeStamp = GetTimeStamp(); - WriteHeader( libfile ); - - /* Sauvegarde des composant: */ - PQCompFunc( (PQCompFuncType) LibraryEntryCompare ); - LibEntry = (EDA_LibComponentStruct*) PQFirst( &m_Entries, FALSE ); - char Line[256]; - fprintf( docfile, "%s Date: %s\n", DOCFILE_IDENT, - DateAndTime( Line ) ); - - bool success = true; - while( LibEntry ) - { - if ( LibEntry->Type == ROOT ) - { - if ( ! LibEntry->Save( libfile ) ) - success = false; - } - if ( docfile ) - { - if ( ! LibEntry->SaveDoc( docfile ) ) - success = false; - } - - LibEntry = (EDA_LibComponentStruct*) - PQNext( m_Entries, LibEntry, NULL ); - } - - fprintf( libfile, "#\n#End Library\n" ); - if ( docfile ) - fprintf( docfile, "#\n#End Doc Library\n" ); - fclose( libfile ); - fclose( docfile ); - return success; -} - - -/*************************************************************************************/ -static bool WriteLibEntryDateAndTime( FILE* ExportFile, EDA_LibComponentStruct* LibEntry ) -/*************************************************************************************/ - -/* lit date et time de modif composant sous le format: - * "Ti yy/mm/jj hh:mm:ss" - */ -{ - int year, mon, day, hour, min, sec; - - if( LibEntry->m_LastDate == 0 ) - return TRUE; - - sec = LibEntry->m_LastDate & 63; - min = (LibEntry->m_LastDate >> 6) & 63; - hour = (LibEntry->m_LastDate >> 12) & 31; - day = (LibEntry->m_LastDate >> 17) & 31; - mon = (LibEntry->m_LastDate >> 22) & 15; - year = (LibEntry->m_LastDate >> 26) + 1990; - - fprintf( ExportFile, "Ti %d/%d/%d %d:%d:%d\n", year, mon, day, hour, min, sec ); - - return TRUE; -} diff --git a/eeschema/schedit.cpp b/eeschema/schedit.cpp index 357423d262..12a3b4723b 100644 --- a/eeschema/schedit.cpp +++ b/eeschema/schedit.cpp @@ -8,6 +8,7 @@ #include "class_drawpanel.h" #include "confirm.h" #include "eda_doc.h" +#include "class_drawpickedstruct.h" #include "program.h" #include "libcmp.h" @@ -337,7 +338,7 @@ void WinEDA_SchematicFrame::Process_Special_Functions( wxCommandEvent& event ) DrawPanel->MouseToCursorSchema(); ListForUndo = BreakSegment( screen, screen->m_Curseur, TRUE ); if( ListForUndo ) - SaveCopyInUndoList( ListForUndo, IS_NEW | IS_CHANGED ); + SaveCopyInUndoList( (SCH_ITEM*) ListForUndo, IS_NEW | IS_CHANGED ); TestDanglingEnds( screen->EEDrawList, &dc ); } break; diff --git a/eeschema/schematic_undo_redo.cpp b/eeschema/schematic_undo_redo.cpp index 038d8d3947..ccaa2a91d3 100644 --- a/eeschema/schematic_undo_redo.cpp +++ b/eeschema/schematic_undo_redo.cpp @@ -6,6 +6,7 @@ #include "gr_basic.h" #include "common.h" #include "confirm.h" +#include "class_drawpickedstruct.h" #include "program.h" #include "libcmp.h" @@ -225,7 +226,7 @@ void WinEDA_SchematicFrame::SaveCopyInUndoList( SCH_ITEM * ItemToCopy, DrawPickedStruct* PickedList = (DrawPickedStruct*) CopyItem; while( PickedList ) { - CopyItem = PickedList->m_PickedStruct; + CopyItem = (SCH_ITEM*) PickedList->m_PickedStruct; CopyItem->m_Flags = flag_type_command; PickedList->m_Image = CopyItem->m_Image; PickedList = PickedList->Next(); @@ -245,7 +246,7 @@ void WinEDA_SchematicFrame::SaveCopyInUndoList( SCH_ITEM * ItemToCopy, DrawPickedStruct* PickedList = (DrawPickedStruct*) ItemToCopy; while( PickedList ) { - CopyItem = PickedList->m_PickedStruct; + CopyItem = (SCH_ITEM*) PickedList->m_PickedStruct; PickedList->m_Image = CopyItem; PickedList->m_PickedStruct = NULL; PickedList->m_Flags = flag_type_command; @@ -271,7 +272,7 @@ void WinEDA_SchematicFrame::SaveCopyInUndoList( SCH_ITEM * ItemToCopy, DrawPickedStruct* PickedList = (DrawPickedStruct*) ItemToCopy; while( PickedList ) { - CopyItem = PickedList->m_PickedStruct; + CopyItem = (SCH_ITEM*) PickedList->m_PickedStruct; CopyItem->m_Flags = flag_type_command; PickedList->m_Flags = flag_type_command; PickedList = PickedList->Next(); @@ -388,7 +389,7 @@ void WinEDA_SchematicFrame::PutDataInPreviousState( DrawPickedStruct* List ) PickedList = (DrawPickedStruct*) FirstItem; while( PickedList ) { - item = PickedList->m_PickedStruct; + item = (SCH_ITEM*) PickedList->m_PickedStruct; item->SetNext( GetScreen()->EEDrawList ); GetScreen()->EEDrawList = item; item->m_Flags = 0; @@ -447,7 +448,7 @@ void WinEDA_SchematicFrame::PutDataInPreviousState( DrawPickedStruct* List ) break; case IS_DELETED: - item = PickedList->m_PickedStruct; + item = (SCH_ITEM*) PickedList->m_PickedStruct; item->SetNext( GetScreen()->EEDrawList ); GetScreen()->EEDrawList = item; item->m_Flags = 0; diff --git a/eeschema/schframe.cpp b/eeschema/schframe.cpp index e1b6900765..03b5f5d40b 100644 --- a/eeschema/schframe.cpp +++ b/eeschema/schframe.cpp @@ -137,7 +137,6 @@ WinEDA_SchematicFrame::WinEDA_SchematicFrame( wxWindow* father, m_FrameName = wxT( "SchematicFrame" ); m_Draw_Axis = FALSE; // TRUE to show axis - m_Draw_Grid = g_ShowGrid; // TRUE to show a grid m_Draw_Sheet_Ref = TRUE; // TRUE to show sheet references m_CurrentSheet = new DrawSheetPath(); m_CurrentField = NULL; @@ -158,14 +157,14 @@ WinEDA_SchematicFrame::WinEDA_SchematicFrame( wxWindow* father, g_ItemToRepeat = NULL; /* Get config */ - GetSettings(); + LoadSettings(); if( config ) { g_DrawMinimunLineWidth = config->Read( MINI_DRAW_LINE_WIDTH_KEY, (long) 0 ); g_PlotLine_Width = config->Read( OPTKEY_PLOT_LINEWIDTH_VALUE, - (long) 4 ); + (long) 4 ); } SetSize( m_FramePos.x, m_FramePos.y, m_FrameSize.x, m_FrameSize.y ); @@ -423,7 +422,7 @@ void WinEDA_SchematicFrame::SetToolbars() g_UnitMetric == INCHES ? TRUE : FALSE ); m_OptionsToolBar->ToggleTool( ID_TB_OPTIONS_SELECT_CURSOR, - g_CursorShape ); + m_CursorShape ); m_OptionsToolBar->ToggleTool( ID_TB_OPTIONS_HIDDEN_PINS, g_ShowAllPins ); m_OptionsToolBar->SetToolShortHelp( ID_TB_OPTIONS_HIDDEN_PINS, g_ShowAllPins ? _( "No show Hidden Pins" ) : _( @@ -443,22 +442,21 @@ void WinEDA_SchematicFrame::SetToolbars() int WinEDA_SchematicFrame::BestZoom() /************************************/ { - int dx, dy, ii, jj; - int bestzoom; + int dx, dy; wxSize size; + double zoom; dx = GetScreen()->m_CurrentSheetDesc->m_Size.x; dy = GetScreen()->m_CurrentSheetDesc->m_Size.y; - size = DrawPanel->GetClientSize(); - ii = dx / size.x; - jj = dy / size.y; - bestzoom = MAX( ii, jj ) + 1; + size = DrawPanel->GetClientSize(); + zoom = MAX( (double) dx / (double) size.x, + (double) dy / (double) size.y ); GetScreen()->m_Curseur.x = dx / 2; GetScreen()->m_Curseur.y = dy / 2; - return bestzoom * GetScreen()->m_ZoomScalar; + return wxRound( zoom * (double) GetScreen()->m_ZoomScalar ); } /*******************************************************************/ @@ -606,13 +604,12 @@ void WinEDA_SchematicFrame::OnLoadProject( wxCommandEvent& event ) void WinEDA_SchematicFrame::OnOpenPcbnew( wxCommandEvent& event ) /****************************************************************/ { - wxString Line = g_RootSheet->m_AssociatedScreen->m_FileName; + wxFileName fn = g_RootSheet->m_AssociatedScreen->m_FileName; - if( Line != wxEmptyString ) + if( fn.IsOk() ) { - AddDelimiterString( Line ); - ChangeFileNameExt( Line, wxEmptyString ); - ExecuteFile( this, PCBNEW_EXE, Line ); + fn.ClearExt(); + ExecuteFile( this, PCBNEW_EXE, QuoteFullPath( fn ) ); } else ExecuteFile( this, PCBNEW_EXE ); @@ -623,13 +620,12 @@ void WinEDA_SchematicFrame::OnOpenPcbnew( wxCommandEvent& event ) void WinEDA_SchematicFrame::OnOpenCvpcb( wxCommandEvent& event ) /***************************************************************/ { - wxString Line = g_RootSheet->m_AssociatedScreen->m_FileName; + wxFileName fn = g_RootSheet->m_AssociatedScreen->m_FileName; + fn.SetExt( NetlistFileExtension ); - if( Line != wxEmptyString ) + if( fn.IsOk() && fn.FileExists() ) { - AddDelimiterString( Line ); - ChangeFileNameExt( Line, wxEmptyString ); - ExecuteFile( this, CVPCB_EXE, Line ); + ExecuteFile( this, CVPCB_EXE, QuoteFullPath( fn ) ); } else ExecuteFile( this, CVPCB_EXE ); diff --git a/eeschema/sheet.cpp b/eeschema/sheet.cpp index cfd6914423..512bf09a3c 100644 --- a/eeschema/sheet.cpp +++ b/eeschema/sheet.cpp @@ -248,36 +248,38 @@ void WinEDA_SheetPropertiesFrame::SheetPropertiesAccept( wxCommandEvent& event ) * sheetname and filename (text and size) */ { - wxString FileName, msg; + wxFileName fn; + wxString msg; - FileName = m_FileNameWin->GetValue(); - FileName.Trim( FALSE ); FileName.Trim( TRUE ); + fn = m_FileNameWin->GetValue(); - if( FileName.IsEmpty() ) + if( !fn.IsOk() ) { DisplayError( this, _( "No Filename! Aborted" ) ); EndModal( FALSE ); return; } - ChangeFileNameExt( FileName, g_SchExtBuffer ); + fn.SetExt( SchematicFileExtension ); /* m_CurrentSheet->m_AssociatedScreen must be a valide screen, and the sheet must have a valid associated filename, * so we must call m_CurrentSheet->ChangeFileName to set a filename, * AND always when a new sheet is created ( when m_CurrentSheet->m_AssociatedScreen is null ), * to create or set an Associated Screen */ - if( ( FileName != m_CurrentSheet->GetFileName() ) - || ( m_CurrentSheet->m_AssociatedScreen == NULL) ) + if( ( fn.GetFullPath() != m_CurrentSheet->GetFileName() ) + || ( m_CurrentSheet->m_AssociatedScreen == NULL) ) { - msg = _( "Changing a Filename can change all the schematic structure and cannot be undone" ); + msg = _( "Changing a Filename can change all the schematic " \ + "structures and cannot be undone." ); msg << wxT( "\n" ); msg << _( "Ok to continue renaming?" ); + if( m_CurrentSheet->m_AssociatedScreen == NULL || IsOK( NULL, msg ) ) { //do not prompt on a new sheet. in fact, we should not allow a sheet to be created //without a valid associated filename to be read from. m_Parent->GetScreen()->ClearUndoRedoList(); - m_CurrentSheet->ChangeFileName( m_Parent, FileName ); // set filename and the associated screen + m_CurrentSheet->ChangeFileName( m_Parent, fn.GetFullPath() ); // set filename and the associated screen } } @@ -294,7 +296,8 @@ void WinEDA_SheetPropertiesFrame::SheetPropertiesAccept( wxCommandEvent& event ) if( ( m_CurrentSheet->m_SheetName.IsEmpty() ) ) { - m_CurrentSheet->m_SheetName.Printf( wxT( "Sheet%8.8lX" ), GetTimeStamp() ); + m_CurrentSheet->m_SheetName.Printf( wxT( "Sheet%8.8lX" ), + GetTimeStamp() ); } diff --git a/eeschema/symbdraw.cpp b/eeschema/symbdraw.cpp index c6166f7043..03138d3d8b 100644 --- a/eeschema/symbdraw.cpp +++ b/eeschema/symbdraw.cpp @@ -125,7 +125,7 @@ bodygraphics_PropertiesAccept( wxCommandEvent& event ) Close(); if( CurrentDrawItem ) - CurrentDrawItem->Display_Infos_DrawEntry( m_Parent ); + CurrentDrawItem->DisplayInfo( m_Parent ); m_Parent->DrawPanel->Refresh(); } diff --git a/eeschema/tool_lib.cpp b/eeschema/tool_lib.cpp index c0e60bfc41..0de962b37e 100644 --- a/eeschema/tool_lib.cpp +++ b/eeschema/tool_lib.cpp @@ -27,6 +27,10 @@ #include "id.h" +extern int ExportPartId; +extern int ImportPartId; +extern int CreateNewLibAndSavePartId; + /****************************************************/ void WinEDA_LibeditFrame::ReCreateVToolbar() @@ -130,14 +134,14 @@ void WinEDA_LibeditFrame::ReCreateHToolbar() wxBitmap( save_part_in_mem_xpm ), _( "Save current component into current loaded library (in memory)" ) ); - m_HToolBar->AddTool( ID_LIBEDIT_IMPORT_PART, wxEmptyString, wxBitmap( import_xpm ), + m_HToolBar->AddTool( ImportPartId, wxEmptyString, wxBitmap( import_xpm ), _( "import component" ) ); - m_HToolBar->AddTool( ID_LIBEDIT_EXPORT_PART, wxEmptyString, wxBitmap( export_xpm ), + m_HToolBar->AddTool( ExportPartId, wxEmptyString, wxBitmap( export_xpm ), _( "export component" ) ); - m_HToolBar->AddTool( ID_LIBEDIT_CREATE_NEW_LIB_AND_SAVE_CURRENT_PART, - wxEmptyString, wxBitmap( new_library_xpm ), + m_HToolBar->AddTool( CreateNewLibAndSavePartId, wxEmptyString, + wxBitmap( new_library_xpm ), _( "Create a new library an save current component into" ) ); m_HToolBar->AddSeparator(); diff --git a/eeschema/tool_sch.cpp b/eeschema/tool_sch.cpp index bab6c7a7cd..cf1a50fbb3 100644 --- a/eeschema/tool_sch.cpp +++ b/eeschema/tool_sch.cpp @@ -289,23 +289,23 @@ void WinEDA_SchematicFrame::OnSelectOptionToolbar( wxCommandEvent& event ) switch( id ) { case ID_TB_OPTIONS_SHOW_GRID: - g_ShowGrid = m_Draw_Grid = m_OptionsToolBar->GetToolState( id ); + m_Draw_Grid = m_OptionsToolBar->GetToolState( id ); DrawPanel->Refresh(); break; case ID_TB_OPTIONS_SELECT_UNIT_MM: g_UnitMetric = MILLIMETRE; - Affiche_Status_Box(); /* Reaffichage des coord curseur */ + UpdateStatusBar(); /* Reaffichage des coord curseur */ break; case ID_TB_OPTIONS_SELECT_UNIT_INCH: g_UnitMetric = INCHES; - Affiche_Status_Box(); /* Reaffichage des coord curseur */ + UpdateStatusBar(); /* Reaffichage des coord curseur */ break; case ID_TB_OPTIONS_SELECT_CURSOR: DrawPanel->CursorOff( &dc ); - g_CursorShape = m_OptionsToolBar->GetToolState( id ); + m_CursorShape = m_OptionsToolBar->GetToolState( id ); DrawPanel->CursorOn( &dc ); break; diff --git a/eeschema/viewlib_frame.cpp b/eeschema/viewlib_frame.cpp index 5a4c8f22f3..9965fb56d7 100644 --- a/eeschema/viewlib_frame.cpp +++ b/eeschema/viewlib_frame.cpp @@ -64,9 +64,6 @@ WinEDA_ViewlibFrame::WinEDA_ViewlibFrame( wxWindow* father, m_FrameName = wxT( "ViewlibFrame" ); - m_Draw_Axis = TRUE; // TRUE to dispaly Axis - m_Draw_Grid = TRUE; // TRUE to display grid - // Give an icon SetIcon( wxIcon( library_browse_xpm ) ); @@ -97,12 +94,12 @@ WinEDA_ViewlibFrame::WinEDA_ViewlibFrame( wxWindow* father, m_CmpListSize.y = -1; m_CmpList = new wxListBox( this, ID_LIBVIEW_CMP_LIST, wxPoint( m_LibListSize.x, 0 ), - m_CmpListSize, 0, NULL, wxLB_HSCROLL ); + m_CmpListSize, 0, NULL, wxLB_HSCROLL ); m_CmpList->SetFont( *g_DialogFont ); m_CmpList->SetBackgroundColour( wxColour( 255, 255, 255 ) ); // Component background listbox color (white) m_CmpList->SetForegroundColour( wxColour( 0, 0, 0 ) ); // Component foreground listbox color (black) - GetSettings(); + LoadSettings(); SetSize( m_FramePos.x, m_FramePos.y, m_FrameSize.x, m_FrameSize.y ); ReCreateHToolbar(); ReCreateVToolbar(); diff --git a/gerbview/CMakeLists.txt b/gerbview/CMakeLists.txt index 9b0b51d204..9175abd8d8 100644 --- a/gerbview/CMakeLists.txt +++ b/gerbview/CMakeLists.txt @@ -36,9 +36,8 @@ set(GERBVIEW_SRCS trpiste.cpp ) set(GERBVIEW_EXTRA_SRCS - ../pcbnew/class_board_item.cpp - ../pcbnew/class_drawsegment.cpp - ../pcbnew/class_track.cpp +# ../pcbnew/class_board_item.cpp +# ../pcbnew/class_drawsegment.cpp ../pcbnew/undelete.cpp ../share/setpage.cpp @@ -65,7 +64,7 @@ endif(APPLE) add_executable(gerbview WIN32 MACOSX_BUNDLE ${GERBVIEW_SRCS} ${GERBVIEW_EXTRA_SRCS} ${GERBVIEW_RESOURCES}) -target_link_libraries(gerbview 3d-viewer common polygon bitmaps kbool ${wxWidgets_LIBRARIES}) +target_link_libraries(gerbview 3d-viewer common pcbcommon polygon bitmaps kbool ${wxWidgets_LIBRARIES}) install(TARGETS gerbview DESTINATION ${KICAD_BIN} diff --git a/gerbview/controle.cpp b/gerbview/controle.cpp index d09dd4f350..6ec24aa4bf 100644 --- a/gerbview/controle.cpp +++ b/gerbview/controle.cpp @@ -13,6 +13,7 @@ #include "id.h" #include "class_drawpanel.h" +#include "pcbnew.h" #include "gerbview.h" #include "protos.h" @@ -74,25 +75,25 @@ void WinEDA_GerberFrame::GeneralControle( wxDC* DC, wxPoint Mouse ) { case WXK_NUMPAD8: /* Deplacement curseur vers le haut */ case WXK_UP: - Mouse.y -= (int) round(delta.y); + Mouse.y -= wxRound(delta.y); DrawPanel->MouseTo( Mouse ); break; case WXK_NUMPAD2: /* Deplacement curseur vers le bas */ case WXK_DOWN: - Mouse.y += (int) round(delta.y); + Mouse.y += wxRound(delta.y); DrawPanel->MouseTo( Mouse ); break; case WXK_NUMPAD4: /* Deplacement curseur vers la gauche */ case WXK_LEFT: - Mouse.x -= (int) round(delta.x); + Mouse.x -= wxRound(delta.x); DrawPanel->MouseTo( Mouse ); break; case WXK_NUMPAD6: /* Deplacement curseur vers la droite */ case WXK_RIGHT: - Mouse.x += (int) round(delta.x); + Mouse.x += wxRound(delta.x); DrawPanel->MouseTo( Mouse ); break; @@ -133,5 +134,5 @@ void WinEDA_GerberFrame::GeneralControle( wxDC* DC, wxPoint Mouse ) } SetToolbars(); - Affiche_Status_Box(); /* Affichage des coord curseur */ + UpdateStatusBar(); /* Affichage des coord curseur */ } diff --git a/gerbview/dcode.cpp b/gerbview/dcode.cpp index 44b232429a..8c18554928 100644 --- a/gerbview/dcode.cpp +++ b/gerbview/dcode.cpp @@ -6,6 +6,7 @@ #include "common.h" #include "class_drawpanel.h" #include "confirm.h" +#include "macros.h" #include "gerbview.h" #include "pcbplot.h" diff --git a/gerbview/deltrack.cpp b/gerbview/deltrack.cpp index ad811eca83..9c48db90e4 100644 --- a/gerbview/deltrack.cpp +++ b/gerbview/deltrack.cpp @@ -68,7 +68,7 @@ TRACK* WinEDA_GerberFrame::Delete_Segment( wxDC* DC, TRACK* Track ) delete g_CurrentTrackList.PopBack(); } - Affiche_Status_Box(); + UpdateStatusBar(); if( g_CurrentTrackList.GetCount() == 0 ) { diff --git a/gerbview/edit.cpp b/gerbview/edit.cpp index 56f8c24c0a..703d4c8d72 100644 --- a/gerbview/edit.cpp +++ b/gerbview/edit.cpp @@ -7,6 +7,7 @@ #include "class_drawpanel.h" #include "confirm.h" #include "gestfich.h" +#include "appl_wxstruct.h" #include "gerbview.h" #include "pcbplot.h" @@ -251,7 +252,7 @@ void WinEDA_GerberFrame::Process_Special_Functions( wxCommandEvent& event ) case ID_GERBVIEW_SHOW_SOURCE: if( gerber_layer ) { - wxString editorname = GetEditorName(); + wxString editorname = wxGetApp().GetEditorName(); if( !editorname.IsEmpty() ) ExecuteFile( this, editorname, gerber_layer->m_FileName ); } diff --git a/gerbview/files.cpp b/gerbview/files.cpp index 7682083607..fcf59469e7 100644 --- a/gerbview/files.cpp +++ b/gerbview/files.cpp @@ -112,8 +112,8 @@ void WinEDA_GerberFrame::Files_io( wxCommandEvent& event ) /*******************************************************************************************/ -int WinEDA_GerberFrame::LoadOneGerberFile( const wxString& FullFileName, - wxDC* DC, int mode ) +bool WinEDA_GerberFrame::LoadOneGerberFile( const wxString& FullFileName, + wxDC* DC, int mode ) /*******************************************************************************************/ /* @@ -123,44 +123,40 @@ int WinEDA_GerberFrame::LoadOneGerberFile( const wxString& FullFileName, * 1 si OK */ { - wxString filename = FullFileName; - wxString path = wxPathOnly( FullFileName ); + wxString wildcard; + wxFileName fn = FullFileName; ActiveScreen = GetScreen(); - if( filename == wxEmptyString ) + + if( !fn.IsOk() ) { - wxString mask = wxT( "*" ) + g_PhotoFilenameExt; + wildcard.Printf( _( "Gerber files (.%s .gbr .gbx .lgr .ger .pho)|" \ + "*.%s;*.gbr;*.gbx;*.lgr;*.ger;*.pho|" ), + g_PenFilenameExt.c_str(), g_PenFilenameExt.c_str()); + wildcard += AllFilesWildcard; - mask += wxT( ";*.gbr;*.gbx;*.lgr;*.ger" ); + wxFileDialog dlg( this, _( "Open Gerber File" ), fn.GetPath(), + fn.GetFullName(), wildcard, + wxFD_OPEN | wxFD_FILE_MUST_EXIST ); - filename = EDA_FileSelector( _( "Open Gerber File:" ), - path, /* Chemin par defaut */ - wxEmptyString, /* nom fichier par defaut */ - g_PhotoFilenameExt, /* extension par defaut */ - mask, /* Masque d'affichage */ - this, - 0, - FALSE - ); - if( filename == wxEmptyString ) - return FALSE; + if( dlg.ShowModal() == wxID_CANCEL ) + return false; + + fn = dlg.GetPath(); } - GetScreen()->m_FileName = filename; + GetScreen()->m_FileName = fn.GetFullPath(); + wxSetWorkingDirectory( fn.GetPath() ); + fn.SetExt( g_PenFilenameExt ); - if( path != wxEmptyString ) - wxSetWorkingDirectory( path ); - - ChangeFileNameExt( filename, g_PenFilenameExt ); - - if( Read_GERBER_File( DC, GetScreen()->m_FileName, filename ) ) + if( Read_GERBER_File( DC, GetScreen()->m_FileName, fn.GetFullPath() ) ) SetLastProject( GetScreen()->m_FileName ); Zoom_Automatique( FALSE ); GetScreen()->SetRefreshReq(); g_SaveTime = time( NULL ); - return 1; + return true; } @@ -175,31 +171,29 @@ static void LoadDCodeFile( WinEDA_GerberFrame* frame, const wxString& FullFileNa * 1 si OK */ { - wxString filename = FullFileName; + wxString wildcard; + wxFileName fn = FullFileName; ActiveScreen = frame->GetScreen(); - if( filename == wxEmptyString ) + if( !fn.IsOk() ) { - wxString penfilesmask( wxT( "*" ) ); + wildcard.Printf( _( "Gerber DCODE files (%s)|*.%s" ), + g_PenFilenameExt.c_str(), g_PenFilenameExt.c_str()); + wildcard += AllFilesWildcard; + fn = frame->GetScreen()->m_FileName; + fn.SetExt( g_PenFilenameExt ); + wxFileDialog dlg( ( wxWindow* )frame, _( "Load GERBER DCODE File" ), + fn.GetPath(), fn.GetFullName(), wildcard, + wxFD_OPEN | wxFD_FILE_MUST_EXIST ); - penfilesmask += g_PenFilenameExt; - filename = frame->GetScreen()->m_FileName; - ChangeFileNameExt( filename, g_PenFilenameExt ); - filename = EDA_FileSelector( _( "D codes files:" ), - wxEmptyString, /* Chemin par defaut */ - filename, /* nom fichier par defaut */ - g_PenFilenameExt, /* extension par defaut */ - penfilesmask, /* Masque d'affichage */ - frame, - 0, - TRUE - ); - if( filename == wxEmptyString ) + if( dlg.ShowModal() == wxID_CANCEL ) return; + + fn = dlg.GetPath(); } - frame->Read_D_Code_File( filename ); + frame->Read_D_Code_File( fn.GetFullPath() ); frame->CopyDCodesSizeToItems(); frame->GetScreen()->SetRefreshReq(); } @@ -212,29 +206,29 @@ bool WinEDA_GerberFrame::SaveGerberFile( const wxString& FullFileName, wxDC* DC /* Sauvegarde du fichier PCB en format ASCII */ { - wxString filename = FullFileName; + wxString wildcard; + wxFileName fn = FullFileName; - if( filename == wxEmptyString ) + if( !fn.IsOk() ) { - wxString mask( wxT( "*" ) ); + fn = GetScreen()->m_FileName; - mask += g_PhotoFilenameExt; - filename = EDA_FileSelector( _( "Save gerber file" ), - wxEmptyString, /* Chemin par defaut */ - GetScreen()->m_FileName, /* nom fichier par defaut */ - g_PhotoFilenameExt, /* extension par defaut */ - mask, /* Masque d'affichage */ - this, - wxFD_SAVE, - FALSE - ); - if( filename.IsEmpty() ) - return FALSE; + wildcard.Printf( _( "Gerber DCODE files (%s)|*.%s" ), + g_PenFilenameExt.c_str(), g_PenFilenameExt.c_str()); + + wxFileDialog dlg( this, _( "Save Gerber File" ), fn.GetPath(), + fn.GetFullName(), wildcard, + wxFD_SAVE | wxFD_OVERWRITE_PROMPT ); + + if( dlg.ShowModal() == wxID_CANCEL ) + return false; + + fn = dlg.GetPath(); } - GetScreen()->m_FileName = filename; + GetScreen()->m_FileName = fn.GetFullPath(); // TODO - return TRUE; + return true; } diff --git a/gerbview/gerberframe.cpp b/gerbview/gerberframe.cpp index 936e935649..b37e0f11b9 100644 --- a/gerbview/gerberframe.cpp +++ b/gerbview/gerberframe.cpp @@ -135,8 +135,6 @@ WinEDA_GerberFrame::WinEDA_GerberFrame( wxWindow* father, m_FrameName = wxT( "GerberFrame" ); //m_AboutTitle = g_GerbviewAboutTitle; - m_Draw_Axis = TRUE; // TRUE pour avoir les axes dessines - m_Draw_Grid = TRUE; // TRUE pour avoir la axes dessinee m_Draw_Sheet_Ref = FALSE; // TRUE pour avoir le cartouche dessin� m_Ident = GERBER_FRAME; if( DrawPanel ) @@ -152,7 +150,7 @@ WinEDA_GerberFrame::WinEDA_GerberFrame( wxWindow* father, SetBaseScreen( ScreenPcb ); ActiveScreen = ScreenPcb; - GetSettings(); + LoadSettings(); SetSize( m_FramePos.x, m_FramePos.y, m_FrameSize.x, m_FrameSize.y ); ReCreateMenuBar(); ReCreateHToolbar(); @@ -286,7 +284,7 @@ void WinEDA_GerberFrame::SetToolbars() m_Draw_Grid ); m_OptionsToolBar->ToggleTool( ID_TB_OPTIONS_SELECT_CURSOR, - g_CursorShape ); + m_CursorShape ); m_OptionsToolBar->ToggleTool( ID_TB_OPTIONS_SHOW_PADS_SKETCH, !m_DisplayPadFill ); @@ -309,15 +307,16 @@ void WinEDA_GerberFrame::SetToolbars() int WinEDA_GerberFrame::BestZoom() /*************************************/ { - double ii, jj; - double bestzoom; + double x, y; wxSize size; GetBoard()->ComputeBoundaryBox(); - size = DrawPanel->GetClientSize(); - ii = GetBoard()->m_BoundaryBox.GetWidth() / size.x; - jj = GetBoard()->m_BoundaryBox.GetHeight() / size.y; - bestzoom = MAX( ii, jj ); + size = DrawPanel->GetClientSize(); + x = ( (double) GetBoard()->m_BoundaryBox.GetWidth() + + GetScreen()->GetGrid().x ) / (double) size.x; + y = ( (double) GetBoard()->m_BoundaryBox.GetHeight() + + GetScreen()->GetGrid().y ) / (double) size.y; GetScreen()->m_Curseur = GetBoard()->m_BoundaryBox.Centre(); - return (int) round(bestzoom * GetScreen()->m_ZoomScalar); + + return wxRound( MAX( x, y ) * (double)GetScreen()->m_ZoomScalar ); } diff --git a/gerbview/gerbview.cpp b/gerbview/gerbview.cpp index 174fb70200..e15829cca0 100644 --- a/gerbview/gerbview.cpp +++ b/gerbview/gerbview.cpp @@ -2,9 +2,6 @@ /* GERBVIEW main file */ /************************************************/ -#define MAIN -#define eda_global - #include "fctsys.h" #include "common.h" #include "appl_wxstruct.h" @@ -22,15 +19,27 @@ #include -wxString g_Main_Title = wxT( "GerbView" ); +wxString g_PhotoFilenameExt; +wxString g_DrillFilenameExt; +wxString g_PenFilenameExt; + +int g_DCodesColor; +int g_Default_GERBER_Format; +int g_Plot_Spot_Mini; /* Diametre mini de l'ouverture pour */ +int g_DisplayPolygonsModeSketch; + +GERBER* g_GERBER_List[32]; + IMPLEMENT_APP( WinEDA_App ) + bool WinEDA_App::OnInit() { + wxFileName fn; WinEDA_GerberFrame* frame = NULL; - InitEDA_Appl( wxT( "gerbview" ) ); + InitEDA_Appl( wxT( "GerbView" ) ); ScreenPcb = new PCB_SCREEN(); ScreenPcb->m_CurrentSheetDesc = &g_Sheet_GERBER; @@ -57,8 +66,7 @@ bool WinEDA_App::OnInit() wxSize( 600, 400 ) ); /* Gerbview mainframe title */ - wxString Title = g_Main_Title + wxT( " " ) + GetBuildVersion(); - frame->SetTitle( Title ); + frame->SetTitle( GetTitle() + wxT( " " ) + GetBuildVersion() ); frame->SetBoard( new BOARD( NULL, frame ) ); SetTopWindow( frame ); // Set GerbView mainframe on top @@ -67,38 +75,36 @@ bool WinEDA_App::OnInit() Read_Config(); - if( argc > 1 ) + if( argc == 0 ) + return true; + + fn = argv[1]; + fn.SetExt( g_PhotoFilenameExt ); + + if( fn.IsOk() ) { - wxString fileName = MakeFileName( wxEmptyString, - argv[1], - g_PhotoFilenameExt ); + wxClientDC dc( frame->DrawPanel ); + frame->DrawPanel->PrepareGraphicContext( &dc ); - if( !fileName.IsEmpty() ) + if( fn.DirExists() ) + wxSetWorkingDirectory( fn.GetPath() ); + + // Load all files specified on the command line. + for( int i = 1; i < argc; ++i ) { - wxClientDC dc( frame->DrawPanel ); - frame->DrawPanel->PrepareGraphicContext( &dc ); + fn = wxFileName( argv[i] ); + fn.SetExt( g_PhotoFilenameExt ); - wxString path = wxPathOnly( fileName ); + wxLogDebug( wxT( "Opening file <%s> in GerbView." ), + fn.GetFullPath().c_str() ); - if( path != wxEmptyString ) - wxSetWorkingDirectory( path ); - - // Load all files specified on the command line. - for( int i = 1; iGetScreen() )-> - m_Active_Layer = i - 1; - frame->LoadOneGerberFile( fileName, &dc, FALSE ); - } + ( (PCB_SCREEN*) frame->GetScreen() )->m_Active_Layer = i - 1; + frame->LoadOneGerberFile( fn.GetFullPath(), &dc, FALSE ); } } } - return TRUE; + return true; } diff --git a/gerbview/gerbview.h b/gerbview/gerbview.h index 1a6d36f7cd..3ac7f20545 100644 --- a/gerbview/gerbview.h +++ b/gerbview/gerbview.h @@ -12,10 +12,6 @@ class WinEDA_GerberFrame; class BOARD; -#ifndef eda_global -#define eda_global extern -#endif - // Type d'action du phototraceur: #define GERB_ACTIVE_DRAW 1 // activation de lumiere ( baisser de plume) #define GERB_STOP_DRAW 2 // extinction de lumiere ( lever de plume) @@ -29,17 +25,15 @@ typedef enum { } PlotFormat; -//eda_global wxString g_Plot_FileName; -eda_global wxString g_PhotoFilenameExt; -eda_global wxString g_DrillFilenameExt; -eda_global wxString g_PenFilenameExt; - -eda_global int g_DCodesColor; -eda_global int g_Default_GERBER_Format; +extern wxString g_PhotoFilenameExt; +extern wxString g_DrillFilenameExt; +extern wxString g_PenFilenameExt; +extern int g_DCodesColor; +extern int g_Default_GERBER_Format; /* Gestion des ouvertures GERBER */ -eda_global int g_Plot_Spot_Mini; /* Diametre mini de l'ouverture pour trace GERBER */ +extern int g_Plot_Spot_Mini; /* Diametre mini de l'ouverture pour trace GERBER */ /*************************************/ @@ -442,17 +436,10 @@ public: bool GetEndOfBlock( char buff[GERBER_BUFZ], char*& text, FILE* gerber_file ); -eda_global GERBER* g_GERBER_List[32]; +extern GERBER* g_GERBER_List[32]; +extern int g_DisplayPolygonsModeSketch; -/** - * How to show filled polygons : - * 0 = filled - * 1 = Sketch mode - */ -eda_global int g_DisplayPolygonsModeSketch; - - -#include "pcbnew.h" +#include "pcbcommon.h" #endif // ifndef GERBVIEW_H diff --git a/gerbview/gerbview_config.cpp b/gerbview/gerbview_config.cpp index 6f675c6dbc..c1cccc9381 100644 --- a/gerbview/gerbview_config.cpp +++ b/gerbview/gerbview_config.cpp @@ -10,6 +10,7 @@ #include "class_drawpanel.h" #include "confirm.h" #include "gestfich.h" +#include "pcbcommon.h" #include "gerbview.h" #include "pcbplot.h" #include "id.h" @@ -21,10 +22,9 @@ #define HOTKEY_FILENAME wxT( "gerbview" ) -/* Routines Locales */ - - -/* Variables locales */ +const wxString GerbviewProjectFileExt( wxT( "cnf" ) ); +const wxString GerbviewProjectFileWildcard( _( "GervView project files " \ + "(.cnf)|*.cnf" ) ); /*************************************************************/ @@ -78,7 +78,7 @@ void WinEDA_GerberFrame::Process_Config( wxCommandEvent& event ) FullFileName += HOTKEY_FILENAME; FullFileName += DEFAULT_HOTKEY_FILENAME_EXT; AddDelimiterString( FullFileName ); - wxString editorname = GetEditorName(); + wxString editorname = wxGetApp().GetEditorName(); if( !editorname.IsEmpty() ) ExecuteFile( this, editorname, FullFileName ); } @@ -112,17 +112,16 @@ bool Read_Config() * Retourne un pointeur su le message d'erreur a afficher */ { - g_Prj_Config_Filename_ext = wxT( ".cnf" ); - wxGetApp().ReadProjectConfig( wxT( "gerbview" ), GROUP, ParamCfgList, + wxGetApp().ReadProjectConfig( wxT( "gerbview.cnf" ), GROUP, ParamCfgList, FALSE ); /* Inits autres variables */ if( g_PhotoFilenameExt.IsEmpty() ) - g_PhotoFilenameExt = wxT( ".pho" ); + g_PhotoFilenameExt = wxT( "pho" ); if( g_DrillFilenameExt.IsEmpty() ) - g_DrillFilenameExt = wxT( ".drl" ); + g_DrillFilenameExt = wxT( "drl" ); if( g_PenFilenameExt.IsEmpty() ) - g_PenFilenameExt = wxT( ".pen" ); + g_PenFilenameExt = wxT( "pen" ); return TRUE; } @@ -136,29 +135,18 @@ void WinEDA_GerberFrame::Update_config() * creation du fichier de config */ { - wxString FullFileName; - wxString mask( wxT( "*" ) ); + wxFileName fn = wxFileName( wxEmptyString, wxT( "gerbview" ), + GerbviewProjectFileExt ); - g_Prj_Config_Filename_ext = wxT( ".cnf" ); - mask += g_Prj_Config_Filename_ext; + wxFileDialog dlg( this, _( "Save GerbView Project File" ), wxEmptyString, + fn.GetFullName(), GerbviewProjectFileWildcard, + wxFD_SAVE | wxFD_OVERWRITE_PROMPT ); - FullFileName = wxT( "gerbview" ); - ChangeFileNameExt( FullFileName, g_Prj_Config_Filename_ext ); - - FullFileName = EDA_FileSelector( _( "Save config file" ), - wxEmptyString, /* Chemin par defaut */ - FullFileName, /* nom fichier par defaut */ - g_Prj_Config_Filename_ext, /* extension par defaut */ - mask, /* Masque d'affichage */ - this, - wxFD_SAVE, - TRUE - ); - if( FullFileName.IsEmpty() ) + if( dlg.ShowModal() == wxID_CANCEL ) return; /* ecriture de la configuration */ - wxGetApp().WriteProjectConfig( FullFileName, GROUP, ParamCfgList ); + wxGetApp().WriteProjectConfig( dlg.GetPath(), GROUP, ParamCfgList ); } diff --git a/gerbview/gerbview_config.h b/gerbview/gerbview_config.h index 820084fb29..9ab8f4b253 100644 --- a/gerbview/gerbview_config.h +++ b/gerbview/gerbview_config.h @@ -1,6 +1,6 @@ - /**********************************************************/ - /* gerber_config.h : configuration: setup parameters list */ - /**********************************************************/ +/**********************************************************/ +/** cfg.h : configuration: definition des structures **/ +/**********************************************************/ #include "param_config.h" @@ -345,7 +345,7 @@ static PARAM_CFG_SETCOLOR ColorDCodesCfg static PARAM_CFG_INT HPGLpenNumCfg ( wxT("HPGLnum"), /* identification */ - &HPGL_Pen_Num, /* Adresse du parametre */ + &g_HPGL_Pen_Num, /* Adresse du parametre */ 1, /* Valeur par defaut */ 1, 16 /* Valeurs extremes */ ); @@ -353,7 +353,7 @@ static PARAM_CFG_INT HPGLpenNumCfg static PARAM_CFG_INT HPGLdiamCfg ( wxT("HPGdiam"), /* identification */ - &HPGL_Pen_Diam, /* Adresse du parametre */ + &g_HPGL_Pen_Diam, /* Adresse du parametre */ 15, /* Valeur par defaut */ 0,0xFFFF /* Valeurs extremes */ ); @@ -361,7 +361,7 @@ static PARAM_CFG_INT HPGLdiamCfg static PARAM_CFG_INT HPGLspeedCfg ( wxT("HPGLSpd"), /* identification */ - &HPGL_Pen_Speed, /* Adresse du parametre */ + &g_HPGL_Pen_Speed, /* Adresse du parametre */ 25, /* Valeur par defaut */ 0,100 /* Valeurs extremes */ ); @@ -369,7 +369,7 @@ static PARAM_CFG_INT HPGLspeedCfg static PARAM_CFG_INT HPGLrecouvrementCfg ( wxT("HPGLrec"), /* identification */ - &HPGL_Pen_Recouvrement, /* Adresse du parametre */ + &g_HPGL_Pen_Recouvrement, /* Adresse du parametre */ 2, /* Valeur par defaut */ 0, 100 /* Valeurs extremes */ ); @@ -398,30 +398,6 @@ static PARAM_CFG_INT EdgeSegmLargeurCfg 0,10000 /* Valeurs extremes */ ); -static PARAM_CFG_DOUBLE UserGrilleXCfg -( - wxT("UserGrX"), /* identification */ - &g_UserGrid.x, /* Adresse du parametre */ - 100.0, /* Valeur par defaut */ - 0.0,10000.0 /* Valeurs extremes */ -); - -static PARAM_CFG_DOUBLE UserGrilleYCfg -( - wxT("UserGrY"), /* identification */ - &g_UserGrid.y, /* Adresse du parametre */ - 100.0, /* Valeur par defaut */ - 0.0,10000.0 /* Valeurs extremes */ -); - -static PARAM_CFG_INT UserGrilleUnitCfg // USER Grid Unit (inches/mm) -( - wxT("UserGrU"), /* identification */ - &g_UserGrid_Unit, /* Adresse du parametre */ - 1, /* Valeur par defaut */ - 0, 1 /* Valeurs extremes */ -); - static PARAM_CFG_INT TimeOutCfg ( wxT("TimeOut"), /* identification */ @@ -438,15 +414,6 @@ static PARAM_CFG_BOOL DisplPolairCfg FALSE /* Valeur par defaut */ ); -static PARAM_CFG_INT CursorShapeCfg -( - INSETUP, - wxT("CuShape"), /* identification */ - &g_CursorShape, /* Adresse du parametre */ - 0, /* Valeur par defaut */ - 0, 1 /* Valeurs extremes */ -); - PARAM_CFG_BASE * ParamCfgList[] = { & PhotoExtBufCfg, @@ -494,12 +461,8 @@ PARAM_CFG_BASE * ParamCfgList[] = & GERBERSpotMiniCfg, & DrawSegmLargeurCfg, & EdgeSegmLargeurCfg, - & UserGrilleXCfg, - & UserGrilleYCfg, - & UserGrilleUnitCfg, & TimeOutCfg, & DisplPolairCfg, - & CursorShapeCfg, NULL }; diff --git a/gerbview/locate.cpp b/gerbview/locate.cpp index 2b1019a8bb..d838d53715 100644 --- a/gerbview/locate.cpp +++ b/gerbview/locate.cpp @@ -6,6 +6,7 @@ #include "common.h" #include "class_drawpanel.h" +#include "pcbnew.h" #include "gerbview.h" #include "trigo.h" #include "protos.h" diff --git a/gerbview/options.cpp b/gerbview/options.cpp index ee316305e4..42f3b16bc2 100644 --- a/gerbview/options.cpp +++ b/gerbview/options.cpp @@ -42,22 +42,22 @@ void WinEDA_GerberFrame::OnSelectOptionToolbar( wxCommandEvent& event ) case ID_TB_OPTIONS_SELECT_UNIT_MM: g_UnitMetric = MILLIMETRE; - Affiche_Status_Box(); + UpdateStatusBar(); break; case ID_TB_OPTIONS_SELECT_UNIT_INCH: g_UnitMetric = INCHES; - Affiche_Status_Box(); + UpdateStatusBar(); break; case ID_TB_OPTIONS_SHOW_POLAR_COORD: Affiche_Message( wxEmptyString ); DisplayOpt.DisplayPolarCood = m_OptionsToolBar->GetToolState( id ); - Affiche_Status_Box(); + UpdateStatusBar(); break; case ID_TB_OPTIONS_SELECT_CURSOR: - g_CursorShape = m_OptionsToolBar->GetToolState( id ); + m_CursorShape = m_OptionsToolBar->GetToolState( id ); DrawPanel->Refresh( TRUE ); break; @@ -206,7 +206,7 @@ WinEDA_GerberGeneralOptionsFrame::WinEDA_GerberGeneralOptionsFrame( m_CursorShape = new wxRadioBox( this, -1, _( "Cursor" ), wxDefaultPosition, wxDefaultSize, 2, list_cursors, 1 ); - m_CursorShape->SetSelection( g_CursorShape ? 1 : 0 ); + m_CursorShape->SetSelection( parent->m_CursorShape ? 1 : 0 ); MiddleBoxSizer->Add( m_CursorShape, 0, wxGROW | wxALL, 5 ); /* Selection Default Scale (i.e. format 2.3 ou 3.4) */ @@ -239,7 +239,7 @@ void WinEDA_GerberGeneralOptionsFrame::OnOkClick( wxCommandEvent& event ) DisplayOpt.DisplayPolarCood = (m_PolarDisplay->GetSelection() == 0) ? FALSE : TRUE; g_UnitMetric = (m_BoxUnits->GetSelection() == 0) ? 0 : 1; - g_CursorShape = m_CursorShape->GetSelection(); + m_Parent->m_CursorShape = m_CursorShape->GetSelection(); g_Default_GERBER_Format = (m_GerberDefaultScale->GetSelection() == 0) ? 23 : 34; diff --git a/gerbview/pcbplot.h b/gerbview/pcbplot.h index a6dc0662b9..ce4d727aa2 100644 --- a/gerbview/pcbplot.h +++ b/gerbview/pcbplot.h @@ -1,33 +1,16 @@ - /******************/ - /* file pcbplot.h */ - /******************/ +/******************/ +/* file pcbplot.h */ +/******************/ #ifndef PCBPLOT_H #define PCBPLOT_H -#ifndef eda_global -#define eda_global extern -#endif - /* Shared Config keys for plot and print */ -#define OPTKEY_PLOT_LINEWIDTH_VALUE wxT( "PlotLineWidth" ) -#define OPTKEY_LAYERBASE wxT( "PlotLayer_%d" ) +#define OPTKEY_PLOT_LINEWIDTH_VALUE wxT( "PlotLineWidth" ) +#define OPTKEY_LAYERBASE wxT( "PlotLayer_%d" ) #define OPTKEY_PRINT_X_FINESCALE_ADJ wxT( "PrintXFineScaleAdj" ) #define OPTKEY_PRINT_Y_FINESCALE_ADJ wxT( "PrintYFineScaleAdj" ) #define OPTKEY_PRINT_SCALE wxT( "PrintScale" ) -/* Gestion des plumes en plot format HPGL */ -eda_global int HPGL_Pen_Num, /* num de plume a charger */ - HPGL_Pen_Speed, /* vitesse en cm/s */ - HPGL_Pen_Diam, /* diametre en mils */ - HPGL_Pen_Recouvrement; /* recouvrement en mils ( pour remplissages */ - -eda_global float Scale_X, Scale_Y ; /* coeff d'agrandissement en X et Y demandes */ - -eda_global int PlotMarge; - -eda_global int g_PlotLine_Width; /* Largeur du trait en mode filaire (utilise en serigraphie, - pour traces en mode sketch et filaire) */ - -#endif // ifndef PCBPLOT_H +#endif // ifndef PCBPLOT_H diff --git a/gerbview/protos.h b/gerbview/protos.h index d624817579..da9a67e683 100644 --- a/gerbview/protos.h +++ b/gerbview/protos.h @@ -3,108 +3,123 @@ /***************************/ /* select_layers_to_pcb.cpp*/ /***************************/ -int * InstallDialogLayerPairChoice(WinEDA_GerberFrame * parent); +int* InstallDialogLayerPairChoice( WinEDA_GerberFrame* parent ); /***********************/ /* gerbview_config.cpp */ /***********************/ bool Read_Config(); -bool Read_Hotkey_Config( WinEDA_DrawFrame * frame, bool verbose ); +bool Read_Hotkey_Config( WinEDA_DrawFrame* frame, bool verbose ); /* pcbplot.cpp */ -void Plume(int state); +void Plume( int state ); /****************/ /* lay2plot.cpp */ -void Print_PcbItems(BOARD * Pcb, wxDC *DC, int drawmode, int printmasklayer); +void Print_PcbItems( BOARD* Pcb, wxDC* DC, int drawmode, int printmasklayer ); /*****************/ /* set_color.cpp */ /*****************/ -void DisplayColorSetupFrame(WinEDA_DrawFrame * parent, const wxPoint & framepos); +void DisplayColorSetupFrame( WinEDA_DrawFrame* parent, const wxPoint& framepos ); /* PLOT_RTN.CC */ -void ComputePlotFileName( char * FullFileName, char * Ext ); -void calcule_coord_plot(int * dx, int * dy ) ; -void calcule_dim_plot(int * dx, int * dy ) ; -void Trace_Un_TextePcb( TEXTE_PCB * pt_texte,int format_plot,int masque_layer); - /* Trace 1 Texte type PCB , c.a.d autre que les textes sur modules, - prepare les parametres de trace de texte */ -void trace_1_arc(int format_plot,int cx,int cy,int start,int end, - int rayon,int epaisseur); -void trace_1_cercle(int format_plot,int epaisseur,int cx, int cy, int rayon); +void ComputePlotFileName( char* FullFileName, char* Ext ); +void calcule_coord_plot( int* dx, int* dy ); +void calcule_dim_plot( int* dx, int* dy ); +void Trace_Un_TextePcb( TEXTE_PCB* pt_texte, int format_plot, int masque_layer ); -void Trace_Un_DrawSegment( DRAWSEGMENT* PtSegm, int format_plot,int masque_layer ); +/* Trace 1 Texte type PCB , c.a.d autre que les textes sur modules, + * prepare les parametres de trace de texte */ +void trace_1_arc( int format_plot, int cx, int cy, int start, int end, + int rayon, int epaisseur ); +void trace_1_cercle( int format_plot, int epaisseur, int cx, int cy, int rayon ); -void Trace_Une_MirePcb( MIREPCB* PtMire, int format_plot,int masque_layer ); +void Trace_Un_DrawSegment( DRAWSEGMENT* PtSegm, + int format_plot, + int masque_layer ); + +void Trace_Une_MirePcb( MIREPCB* PtMire, int format_plot, int masque_layer ); /* PLOTGERB.CC */ -void trace_1_segment_GERBER(int pos_X0,int pos_Y0,int pos_X1,int pos_Y1, - int hauteur); -void trace_1_cercle_GERBER( int cx, int cy, int rayon, int epaisseur); -void trace_1_contour_GERBER(int cX,int cY, int dimX,int dimY, - int deltaX, int deltaY, - int dim_trait, int orient); - /* Trace 1 contour rectangulaire ou trapezoidal d'orientation quelconque - donne par son centre cX, cY, ses dimensions dimX et dimY, - ses variations deltaX et deltaY et son orientation orient */ +void trace_1_segment_GERBER( int pos_X0, int pos_Y0, int pos_X1, int pos_Y1, + int hauteur ); +void trace_1_cercle_GERBER( int cx, int cy, int rayon, int epaisseur ); +void trace_1_contour_GERBER( int cX, int cY, int dimX, int dimY, + int deltaX, int deltaY, + int dim_trait, int orient ); + +/* Trace 1 contour rectangulaire ou trapezoidal d'orientation quelconque + * donne par son centre cX, cY, ses dimensions dimX et dimY, + * ses variations deltaX et deltaY et son orientation orient */ /* PLOTHPGL.CC */ void Init_Trace_HPGL(); void Fin_Trace_HPGL(); -void trace_1_segment_HPGL(int pos_X0,int pos_Y0,int pos_X1,int pos_Y1, - int hauteur); +void trace_1_segment_HPGL( int pos_X0, int pos_Y0, int pos_X1, int pos_Y1, + int hauteur ); -void trace_1_pad_TRAPEZE_HPGL(int cX,int cY, - int dimX,int dimY,int deltaX, int deltaY, - int orient,int modetrace); +void trace_1_pad_TRAPEZE_HPGL( int cX, int cY, + int dimX, int dimY, int deltaX, int deltaY, + int orient, int modetrace ); -void trace_1_pastille_RONDE_HPGL(int pos_X,int pos_Y,int diametre,int modetrace) ; +void trace_1_pastille_RONDE_HPGL( int pos_X, + int pos_Y, + int diametre, + int modetrace ); -void trace_1_pastille_OVALE_HPGL(int pos_X,int pos_Y,int dx,int dy, - int orient,int modetrace) ; -void trace_1_pad_rectangulaire_HPGL(int cX,int cY,int dimX,int dimY, - int orient,int modetrace) ; -void Move_Plume_HPGL( int x,int y,int plume); - /* deplace la plume levee (plume = 'U') ou baissee (plume = 'D') - en position x,y */ +void trace_1_pastille_OVALE_HPGL( int pos_X, int pos_Y, int dx, int dy, + int orient, int modetrace ); +void trace_1_pad_rectangulaire_HPGL( int cX, int cY, int dimX, int dimY, + int orient, int modetrace ); +void Move_Plume_HPGL( int x, int y, int plume ); + +/* deplace la plume levee (plume = 'U') ou baissee (plume = 'D') + * en position x,y */ void Plume_HPGL( int plume ); - /* leve (plume = 'U') ou baisse (plume = 'D') la plume */ + +/* leve (plume = 'U') ou baisse (plume = 'D') la plume */ /**************/ /* PRINTPS.CC */ /**************/ -void trace_1_pastille_OVALE_POST(int pos_X,int pos_Y, - int dx, int dy, int orient, int modetrace); -void trace_1_pastille_RONDE_POST(int pos_X,int pos_Y,int diametre, - int modetrace); -void trace_1_pad_rectangulaire_POST(int cX,int cY, - int dimX,int dimY,int orient, - int modetrace); -void trace_1_contour_POST(int cX,int cY, int dimX,int dimY, - int deltaX, int deltaY, - int dim_trait, int orient); -void trace_1_pad_TRAPEZE_POST(int cX,int cY, - int dimX,int dimY,int deltaX, int deltaY, - int orient,int modetrace); -void trace_1_segment_POST(int pos_X0,int pos_Y0,int pos_X1,int pos_Y1, - int large); -void trace_1_Cercle_POST(int pos_X,int pos_Y,int diametre, int width); -void PlotArcPS(int x, int y, int StAngle, int EndAngle, int rayon, int width); +void trace_1_pastille_OVALE_POST( int pos_X, int pos_Y, + int dx, int dy, int orient, int modetrace ); +void trace_1_pastille_RONDE_POST( int pos_X, int pos_Y, int diametre, + int modetrace ); +void trace_1_pad_rectangulaire_POST( int cX, int cY, + int dimX, int dimY, int orient, + int modetrace ); +void trace_1_contour_POST( int cX, int cY, int dimX, int dimY, + int deltaX, int deltaY, + int dim_trait, int orient ); +void trace_1_pad_TRAPEZE_POST( int cX, int cY, + int dimX, int dimY, int deltaX, int deltaY, + int orient, int modetrace ); +void trace_1_segment_POST( int pos_X0, int pos_Y0, int pos_X1, int pos_Y1, + int large ); +void trace_1_Cercle_POST( int pos_X, int pos_Y, int diametre, int width ); +void PlotArcPS( int x, int y, int StAngle, int EndAngle, int rayon, int width ); /***************/ /* trpiste.cpp */ /***************/ -void Draw_Track_Buffer(WinEDA_DrawPanel * panel, wxDC * DC, BOARD * Pcb, int drawmode, int printmasklayer); -void Trace_Segment(WinEDA_DrawPanel * panel, wxDC * DC, TRACK* pt_piste, int draw_mode); -void Trace_1_texte_pcb(WinEDA_DrawPanel * panel, wxDC * DC, - TEXTE_PCB * pt_texte,int ox,int oy, int DrawMode); - -void Affiche_DCodes_Pistes(WinEDA_DrawPanel * panel, wxDC * DC, - BOARD * Pcb, int drawmode); +void Draw_Track_Buffer( WinEDA_DrawPanel* panel, + wxDC* DC, + BOARD* Pcb, + int drawmode, + int printmasklayer ); +void Trace_Segment( WinEDA_DrawPanel* panel, + wxDC* DC, + TRACK* pt_piste, + int draw_mode ); +void Trace_1_texte_pcb( WinEDA_DrawPanel* panel, wxDC* DC, + TEXTE_PCB* pt_texte, int ox, int oy, int DrawMode ); +void Affiche_DCodes_Pistes( WinEDA_DrawPanel* panel, wxDC* DC, + BOARD* Pcb, int drawmode ); diff --git a/gerbview/readgerb.cpp b/gerbview/readgerb.cpp index 55e11e86f8..bb2bf8aa14 100644 --- a/gerbview/readgerb.cpp +++ b/gerbview/readgerb.cpp @@ -252,7 +252,7 @@ bool WinEDA_GerberFrame::Read_GERBER_File( wxDC* DC, if( error ) { msg.Printf( _( "%d errors while reading Gerber file [%s]" ), - error, GERBER_FullFileName.GetData() ); + error, GERBER_FullFileName.GetData() ); DisplayError( this, msg ); } fclose( gerber->m_Current_File ); @@ -264,32 +264,33 @@ bool WinEDA_GerberFrame::Read_GERBER_File( wxDC* DC, */ if( !gerber->m_Has_DCode ) { - wxString DCodeFileName; + wxFileName fn; + if( D_Code_FullFileName.IsEmpty() ) { - wxString mask; - DCodeFileName = GERBER_FullFileName; - ChangeFileNameExt( DCodeFileName, g_PenFilenameExt ); - mask = wxT( "*" ) + g_PenFilenameExt; - DCodeFileName = EDA_FileSelector( _( "D codes files:" ), - wxEmptyString, /* Chemin par defaut */ - DCodeFileName, /* nom fichier par defaut */ - g_PenFilenameExt, /* extension par defaut */ - mask, /* Masque d'affichage */ - this, - 0, - TRUE - ); + wxString wildcard; + + fn = GERBER_FullFileName; + fn.SetExt( g_PenFilenameExt ); + wildcard.Printf( _( "Gerber DCODE files (%s)|*.%s" ), + g_PenFilenameExt.c_str(), g_PenFilenameExt.c_str()); + wildcard += AllFilesWildcard; + + wxFileDialog dlg( this, _( "Load GERBER DCODE File" ), + wxEmptyString, fn.GetFullName(), wildcard, + wxFD_OPEN | wxFD_FILE_MUST_EXIST ); } else - DCodeFileName = D_Code_FullFileName; + fn = D_Code_FullFileName; - if( !DCodeFileName.IsEmpty() ) + if( fn.IsOk() ) { - Read_D_Code_File( DCodeFileName ); + Read_D_Code_File( fn.GetFullPath() ); CopyDCodesSizeToItems(); } + else + return false; } - return TRUE; + return true; } diff --git a/gerbview/rs274d.cpp b/gerbview/rs274d.cpp index d8dfb9577a..cbb6106609 100644 --- a/gerbview/rs274d.cpp +++ b/gerbview/rs274d.cpp @@ -6,6 +6,7 @@ #include "fctsys.h" #include "common.h" #include "confirm.h" +#include "macros.h" #include "gerbview.h" #include "pcbplot.h" #include "protos.h" @@ -399,9 +400,9 @@ wxPoint GERBER::ReadXYCoord( char*& Text ) if( is_float ) { if( m_GerbMetric ) - current_coord = (int) round( atof( line ) / 0.00254 ); + current_coord = wxRound( atof( line ) / 0.00254 ); else - current_coord = (int) round( atof( line ) * PCB_INTERNAL_UNIT ); + current_coord = wxRound( atof( line ) * PCB_INTERNAL_UNIT ); } else { @@ -465,7 +466,7 @@ wxPoint GERBER::ReadXYCoord( char*& Text ) if( m_GerbMetric ) real_scale = real_scale / 25.4; - current_coord = (int) round( current_coord * real_scale ); + current_coord = wxRound( current_coord * real_scale ); } if( type_coord == 'X' ) @@ -531,9 +532,9 @@ wxPoint GERBER::ReadIJCoord( char*& Text ) if( is_float ) { if( m_GerbMetric ) - current_coord = (int) round( atof( line ) / 0.00254 ); + current_coord = wxRound( atof( line ) / 0.00254 ); else - current_coord = (int) round( atof( line ) * PCB_INTERNAL_UNIT ); + current_coord = wxRound( atof( line ) * PCB_INTERNAL_UNIT ); } else { @@ -596,7 +597,7 @@ wxPoint GERBER::ReadIJCoord( char*& Text ) if( m_GerbMetric ) real_scale = real_scale / 25.4; - current_coord = (int) round( current_coord * real_scale ); + current_coord = wxRound( current_coord * real_scale ); } if( type_coord == 'I' ) pos.x = current_coord; @@ -773,9 +774,9 @@ static int scale( double aCoord, bool isMetric ) int ret; if( isMetric ) - ret = (int) round( aCoord / 0.00254 ); + ret = wxRound( aCoord / 0.00254 ); else - ret = (int) round( aCoord * PCB_INTERNAL_UNIT ); + ret = wxRound( aCoord * PCB_INTERNAL_UNIT ); return ret; } diff --git a/gerbview/rs274x.cpp b/gerbview/rs274x.cpp index 9f493d9728..f76d47f782 100644 --- a/gerbview/rs274x.cpp +++ b/gerbview/rs274x.cpp @@ -5,6 +5,7 @@ #include "fctsys.h" #include "common.h" #include "confirm.h" +#include "macros.h" #include "gerbview.h" #include "pcbplot.h" #include "protos.h" @@ -271,13 +272,13 @@ bool GERBER::ExecuteRS274XCommand( int command, char buff[GERBER_BUFZ], char*& t case 'A': // A axis offset in current unit (inch ou mm) text++; fcoord = ReadDouble( text ); - m_Offset.x = (int) round( fcoord * conv_scale ); + m_Offset.x = wxRound( fcoord * conv_scale ); break; case 'B': // B axis offset in current unit (inch ou mm) text++; fcoord = ReadDouble( text ); - m_Offset.y = (int) round( fcoord * conv_scale ); + m_Offset.y = wxRound( fcoord * conv_scale ); break; } } @@ -383,7 +384,7 @@ bool GERBER::ExecuteRS274XCommand( int command, char buff[GERBER_BUFZ], char*& t text += 2; // skip "C," for example dcode->m_Size.x = dcode->m_Size.y = - (int) round( ReadDouble( text ) * conv_scale ); + wxRound( ReadDouble( text ) * conv_scale ); switch( stdAperture ) { @@ -396,7 +397,7 @@ bool GERBER::ExecuteRS274XCommand( int command, char buff[GERBER_BUFZ], char*& t { text++; dcode->m_Drill.x = dcode->m_Drill.y = - (int) round( ReadDouble( text ) * conv_scale ); + wxRound( ReadDouble( text ) * conv_scale ); dcode->m_DrillShape = 1; } @@ -407,7 +408,7 @@ bool GERBER::ExecuteRS274XCommand( int command, char buff[GERBER_BUFZ], char*& t { text++; dcode->m_Drill.y = - (int) round( ReadDouble( text ) * conv_scale ); + wxRound( ReadDouble( text ) * conv_scale ); dcode->m_DrillShape = 2; } @@ -425,7 +426,7 @@ bool GERBER::ExecuteRS274XCommand( int command, char buff[GERBER_BUFZ], char*& t { text++; dcode->m_Size.y = - (int) round( ReadDouble( text ) * conv_scale ); + wxRound( ReadDouble( text ) * conv_scale ); } while( *text == ' ' ) @@ -435,7 +436,7 @@ bool GERBER::ExecuteRS274XCommand( int command, char buff[GERBER_BUFZ], char*& t { text++; dcode->m_Drill.x = dcode->m_Drill.y = - (int) round( ReadDouble( text ) * conv_scale ); + wxRound( ReadDouble( text ) * conv_scale ); dcode->m_DrillShape = 1; } @@ -446,7 +447,7 @@ bool GERBER::ExecuteRS274XCommand( int command, char buff[GERBER_BUFZ], char*& t { text++; dcode->m_Drill.y = - (int) round( ReadDouble( text ) * conv_scale ); + wxRound( ReadDouble( text ) * conv_scale ); dcode->m_DrillShape = 2; } dcode->m_Defined = TRUE; diff --git a/gerbview/tool_gerber.cpp b/gerbview/tool_gerber.cpp index d334563809..a165d982db 100644 --- a/gerbview/tool_gerber.cpp +++ b/gerbview/tool_gerber.cpp @@ -5,6 +5,7 @@ #include "fctsys.h" #include "appl_wxstruct.h" #include "common.h" +#include "macros.h" #include "gerbview.h" #include "pcbplot.h" #include "protos.h" diff --git a/gerbview/tracepcb.cpp b/gerbview/tracepcb.cpp index ac4906c16e..b68cd5f69e 100644 --- a/gerbview/tracepcb.cpp +++ b/gerbview/tracepcb.cpp @@ -84,7 +84,7 @@ void WinEDA_GerberFrame::RedrawActiveWindow( wxDC* DC, bool EraseBg ) Trace_Gerber( DC, GR_COPY, -1 ); TraceWorkSheet( DC, screen, 0 ); - Affiche_Status_Box(); + UpdateStatusBar(); if( DrawPanel->ManageCurseur ) DrawPanel->ManageCurseur( DrawPanel, DC, FALSE ); diff --git a/include/appl_wxstruct.h b/include/appl_wxstruct.h index fe9d0ff0cc..a634eb0112 100644 --- a/include/appl_wxstruct.h +++ b/include/appl_wxstruct.h @@ -13,8 +13,11 @@ /* Use wxFileHistory for most recently used file handling. */ #include #include +#include +class wxConfigBase; +class wxFileConfig; class PARAM_CFG_BASE; class wxSingleInstanceChecker; class wxHtmlHelpController; @@ -33,9 +36,11 @@ public: wxPoint m_HelpPos; wxSize m_HelpSize; wxHtmlHelpController* m_HtmlCtrl; - wxConfig* m_EDA_Config; // Config courante (tailles et positions fenetres ...*/ - wxConfig* m_EDA_CommonConfig; // common setup (language ...) */ + wxConfig* m_EDA_Config; + wxConfig* m_EDA_CommonConfig; + wxFileConfig* m_ProjectConfig; wxString m_HelpFileName; + wxString m_EditorName; wxString m_CurrentOptionFile; // dernier fichier .cnf utilisé wxString m_CurrentOptionFileDateAndTime; @@ -54,6 +59,11 @@ public: wxPathList m_searchPaths; wxFileHistory m_fileHistory; +protected: + wxString m_Title; + wxPathList m_libSearchPaths; + wxFileName m_projectFileName; + public: WinEDA_App(); ~WinEDA_App(); @@ -66,8 +76,13 @@ public: bool SetLanguage( bool first_time = FALSE ); /** Function AddMenuLanguageList - * Create menu list for language choice, and add it as submenu to a main menu - * @param MasterMenu : The main menu. The sub menu list will be accessible from the menu item with id ID_LANGUAGE_CHOICE + * + * Create menu list for language choice, and add it as submenu to a main + * menu + * + * @param MasterMenu : The main menu. The sub menu list will be accessible + * from the menu item with id ID_LANGUAGE_CHOICE + * * @return the sub menu Language list */ void AddMenuLanguageList( wxMenu* MasterMenu ); @@ -78,10 +93,10 @@ public: // Sauvegarde de configurations et options: void GetSettings(); void SaveSettings(); + void WriteProjectConfig( const wxString& local_config_filename, const wxString& GroupName, PARAM_CFG_BASE** List ); - /** Function SaveCurrentSetupValues() * Save the current setup values in m_EDA_Config * saved parameters are parameters that have the .m_Setup member set to true @@ -99,6 +114,9 @@ public: bool ReadProjectConfig( const wxString& local_config_filename, const wxString& GroupName, PARAM_CFG_BASE** List, bool Load_Only_if_New ); + bool ReCreatePrjConfig( const wxString& local_config_filename, + const wxString& GroupName, + bool ForceUseLocalConfig ); void ReadPdfBrowserInfos(); void WritePdfBrowserInfos(); @@ -108,6 +126,12 @@ public: wxString GetHelpFile( void ); wxString GetLibraryFile( const wxString& filename ); + wxString& GetEditorName(); + + const wxString& GetTitle() { return m_Title; } + void SetTitle( const wxString& title ) { m_Title = title; } + + wxPathList& GetLibraryPathList() { return m_libSearchPaths; } }; /* diff --git a/include/base_struct.h b/include/base_struct.h index 6d5994039e..31745e9f42 100644 --- a/include/base_struct.h +++ b/include/base_struct.h @@ -178,6 +178,7 @@ public: void SetY( int val ) { m_Pos.y = val; } void SetWidth( int val ) { m_Size.x = val; } void SetHeight( int val ) { m_Size.y = val; } + void SetEnd( int x, int y ) { SetEnd( wxPoint( x, y ) ); } void SetEnd( const wxPoint& pos ) { m_Size.x = pos.x - m_Pos.x; m_Size.y = pos.y - m_Pos.y; @@ -374,8 +375,7 @@ public: #endif // return a zero-sized box per default. derived classes should override this - EDA_Rect ret( wxPoint( 0, 0 ), wxSize( 0, 0 ) ); - return ret; + return EDA_Rect( wxPoint( 0, 0 ), wxSize( 0, 0 ) ); } diff --git a/include/build_version.h b/include/build_version.h index 3c837133de..a43c4cbb95 100644 --- a/include/build_version.h +++ b/include/build_version.h @@ -3,29 +3,7 @@ #ifndef KICAD_BUILD_VERSION #define KICAD_BUILD_VERSION -#define BUILD_VERSION wxT("(20090325-unstable)") - -COMMON_GLOBL wxString g_BuildVersion -#ifdef EDA_BASE -# ifdef HAVE_SVN_VERSION -# include "config.h" - (wxT(KICAD_SVN_VERSION)) -# else - (BUILD_VERSION) /* main program version */ -# endif -#endif -; - -COMMON_GLOBL wxString g_BuildAboutVersion -#ifdef EDA_BASE -# if defined(HAVE_SVN_VERSION) || defined(HAVE_SVN_REVISION) -# include "config.h" - (wxT(KICAD_ABOUT_VERSION)) -# else - (BUILD_VERSION) /* svn date & rev (normally overridden) */ -# endif -#endif -; - +extern wxString g_BuildVersion; +extern wxString g_BuildAboutVersion; #endif // KICAD_BUILD_VERSION diff --git a/include/class_base_screen.h b/include/class_base_screen.h index fa4c7472b0..a501194142 100644 --- a/include/class_base_screen.h +++ b/include/class_base_screen.h @@ -92,30 +92,34 @@ WX_DECLARE_OBJARRAY( GRID_TYPE, GridArray ); class BASE_SCREEN : public EDA_BaseStruct { public: - wxPoint m_DrawOrg; /* offsets pour tracer le circuit sur l'ecran */ - wxPoint m_Curseur; /* Screen cursor coordinate (on grid) in user units. */ - wxPoint m_MousePosition; /* Mouse cursor coordinate (off grid) in user units. */ - wxPoint m_MousePositionInPixels; /* Mouse cursor coordinate (off grid) in pixels. */ - wxPoint m_O_Curseur; /* Relative Screen cursor coordinate (on grid) in user units. - * (coordinates from last reset position)*/ - wxPoint m_ScrollbarPos; // Position effective des Curseurs de scroll - wxSize m_ScrollbarNumber; /* Valeur effective des Nombres de Scrool - * c.a.d taille en unites de scroll de la surface totale affichable */ - wxPoint m_StartVisu; // Coord absolues du 1er pixel visualis�a l'ecran (en nombre de pixels) + wxPoint m_DrawOrg; /* offsets pour tracer le circuit sur l'ecran */ + wxPoint m_Curseur; /* Screen cursor coordinate (on grid) in user units. */ + wxPoint m_MousePosition; /* Mouse cursor coordinate (off grid) in user units. */ + wxPoint m_MousePositionInPixels; + wxPoint m_O_Curseur; /* Relative Screen cursor coordinate (on grid) in user units. + * (coordinates from last reset position)*/ + wxPoint m_ScrollbarPos; // Position effective des Curseurs de scroll + wxSize m_ScrollbarNumber; /* Valeur effective des Nombres de Scrool + * c.a.d taille en unites de scroll de la + * surface totale affichable */ + wxPoint m_StartVisu; /* Coord absolues du 1er pixel visualis�a + * l'ecran (en nombre de pixels) */ - wxSize m_SizeVisu; /* taille en pixels de l'ecran (fenetre de visu - * Utile pour recadrer les affichages lors de la - * navigation dans la hierarchie */ - bool m_Center; /* fix the coordinate (0,0) position on screen : if TRUE (0,0) in centered on screen - * TRUE: when coordiantaes can be < 0 and > 0 all but schematic - * FALSE: when coordinates can be only >= 0 Schematic - */ - bool m_FirstRedraw; + wxSize m_SizeVisu; /* taille en pixels de l'ecran (fenetre de visu + * Utile pour recadrer les affichages lors de la + * navigation dans la hierarchie */ + bool m_Center; /* fix the coordinate (0,0) position on + * screen : if TRUE (0,0) in centered on screen + * TRUE: when coordiantaes can be < 0 and + * > 0 all but schematic + * FALSE: when coordinates can be only >= 0 + * Schematic */ + bool m_FirstRedraw; /* Gestion des editions */ - SCH_ITEM* EEDrawList; /* Object list (main data) for schematic */ - EDA_BaseStruct* m_UndoList; /* Object list for the undo command (old data) */ - EDA_BaseStruct* m_RedoList; /* Object list for the redo command (old data) */ + SCH_ITEM* EEDrawList; /* Object list (main data) for schematic */ + EDA_BaseStruct* m_UndoList; /* Object list for the undo command (old data) */ + EDA_BaseStruct* m_RedoList; /* Object list for the redo command (old data) */ int m_UndoRedoCountMax; /* undo/Redo command Max depth */ /* block control */ @@ -149,9 +153,10 @@ public: GridArray m_GridList; bool m_UserGridIsON; - wxArrayInt m_ZoomList; /* Array of standard zoom coefficients. */ - int m_Zoom; /* Current zoom coefficient. */ - int m_ZoomScalar; /* Allow zooming to non-integer increments. */ + wxArrayInt m_ZoomList; /* Array of standard zoom coefficients. */ + int m_Zoom; /* Current zoom coefficient. */ + int m_ZoomScalar; /* Allow zooming to non-integer increments. */ + bool m_IsPrinting; public: BASE_SCREEN( KICAD_T aType = SCREEN_STRUCT_TYPE ); @@ -238,6 +243,7 @@ public: void SetZoomList( const wxArrayInt& zoomlist ); int Scale( int coord ); + double Scale( double coord ); void Scale( wxPoint& pt ); void Scale( wxSize& sz ); void Scale( wxRealPoint& sz ); diff --git a/include/class_drawpickedstruct.h b/include/class_drawpickedstruct.h new file mode 100644 index 0000000000..f823aeecd3 --- /dev/null +++ b/include/class_drawpickedstruct.h @@ -0,0 +1,73 @@ +/*****************************************************************************/ +/* sch_item_struct.h : Basic classes for most eeschema items descriptions */ +/*****************************************************************************/ + +#ifndef __CLASS_DRAWPICKEDSTRUCT_H__ +#define __CLASS_DRAWPICKEDSTRUCT_H__ + + +#include "base_struct.h" + + +/** + * Class DrawPickedStruct + * holds structures picked by pick events (like block selection). + * This class has only one useful member: .m_PickedStruct, used as a link. + * It is used to create a linked list of selected items (in block selection). + * Each DrawPickedStruct item has is member: .m_PickedStruct pointing the + * real selected item. + */ +class DrawPickedStruct : public EDA_BaseStruct +{ +public: + EDA_BaseStruct * m_PickedStruct; + +public: + DrawPickedStruct( EDA_BaseStruct * pickedstruct = NULL ); + ~DrawPickedStruct(); + void Place( WinEDA_DrawFrame* frame, wxDC* DC ) { }; + void DeleteWrapperList(); + + DrawPickedStruct* Next() { return (DrawPickedStruct*) Pnext; } + + EDA_Rect GetBoundingBox(); + + /** + * Function GetBoundingBoxUnion + * returns the union of all the BoundingBox rectangles of all held items + * in the picklist whose list head is this DrawPickedStruct. + * @return EDA_Rect - The combined, composite, bounding box. + */ + EDA_Rect GetBoundingBoxUnion(); + + wxString GetClass() const { return wxT( "DrawPickedStruct" ); } + + /** + * Function Draw + * Do nothing, needed for SCH_ITEM compat. + */ + void Draw( WinEDA_DrawPanel* panel, + wxDC* DC, + const wxPoint& offset, + int draw_mode, + int Color = -1 ) + { + } + + /** + * Function Save + * Do nothing, needed for SCH_ITEM compat. + * @param aFile The FILE to write to. + * @return bool - true if success writing else false. + */ + bool Save( FILE* aFile ) const + { + return false; + } + +#if defined(DEBUG) + void Show( int nestLevel, std::ostream& os ); +#endif +}; + +#endif /* __CLASS_DRAWPICKEDSTRUCT_H__ */ diff --git a/include/class_sch_screen.h b/include/class_sch_screen.h index e0251b1bf9..d37b03ed6b 100644 --- a/include/class_sch_screen.h +++ b/include/class_sch_screen.h @@ -5,10 +5,6 @@ #ifndef CLASS_SCREEN_H #define CLASS_SCREEN_H -#ifndef eda_global - #define eda_global extern -#endif - #include "macros.h" #include "base_struct.h" #include "class_base_screen.h" @@ -37,7 +33,10 @@ public: * sets the currently selected object, m_CurrentItem. * @param current Any object derived from SCH_ITEM */ - void SetCurItem( SCH_ITEM* aItem ) { BASE_SCREEN::SetCurItem( aItem ); } + void SetCurItem( SCH_ITEM* aItem ) + { + BASE_SCREEN::SetCurItem( (BASE_SCREEN*) aItem ); + } virtual wxString GetClass() const @@ -78,6 +77,7 @@ public: // screens are unique, and correspond to .sch files. WX_DEFINE_ARRAY( SCH_SCREEN *, ScreenGrowArray ); + class EDA_ScreenList { private: diff --git a/include/colors.h b/include/colors.h index 0601ea37c3..f3341c2b59 100644 --- a/include/colors.h +++ b/include/colors.h @@ -5,10 +5,6 @@ #ifndef _COLORS_H #define _COLORS_H -#ifndef COMMON_GLOBL -#define COMMON_GLOBL extern -#endif - /* Definitions des Numeros des Couleurs ( palette de 32) */ #define NBCOLOR 32 @@ -88,36 +84,6 @@ struct StructColors extern StructColors ColorRefs[NBCOLOR]; -#ifdef MAIN -StructColors ColorRefs[NBCOLOR] = -{ - { 0, 0, 0, BLACK, wxT("BLACK"), DARKDARKGRAY}, - { 192, 0, 0, BLUE, wxT("BLUE"), LIGHTBLUE}, - { 0, 160, 0, GREEN, wxT("GREEN"), LIGHTGREEN }, - { 160, 160, 0, CYAN, wxT("CYAN"), LIGHTCYAN }, - { 0, 0, 160, RED, wxT("RED"), LIGHTRED }, - { 160, 0, 160, MAGENTA, wxT("MAGENTA"), LIGHTMAGENTA }, - { 0, 128, 128, BROWN, wxT("BROWN"), YELLOW }, - { 192, 192, 192, LIGHTGRAY, wxT("GRAY"), WHITE }, - { 128, 128, 128, DARKGRAY, wxT("DARKGRAY"), LIGHTGRAY }, - { 255, 0, 0, LIGHTBLUE, wxT("LIGHTBLUE"), LIGHTBLUE }, - { 0, 255, 0, LIGHTGREEN, wxT("LIGHTGREEN"), LIGHTGREEN }, - { 255, 255, 0, LIGHTCYAN, wxT("LIGHTCYAN"), LIGHTCYAN }, - { 0, 0, 255, LIGHTRED, wxT("LIGHTRED"), LIGHTRED }, - { 255, 0, 255, LIGHTMAGENTA, wxT("LIGHTMAGENTA"), LIGHTMAGENTA }, - { 0, 255, 255, YELLOW, wxT("YELLOW"), YELLOW }, - { 255, 255, 255, WHITE, wxT("WHITE"), WHITE }, - { 64, 64, 64, DARKDARKGRAY, wxT("DARKDARKGRAY"), DARKGRAY }, - { 64, 0, 0, DARKBLUE, wxT("DARKBLUE"), BLUE }, - { 0, 64, 0, DARKGREEN, wxT("DARKGREEN"), GREEN }, - { 64, 64, 0, DARKCYAN, wxT("DARKCYAN"), CYAN }, - { 0, 0, 80, DARKRED, wxT("DARKRED"), RED }, - { 64, 0, 64, DARKMAGENTA, wxT("DARKMAGENTA"), MAGENTA }, - { 0, 64, 64, DARKBROWN, wxT("DARKBROWN"), BROWN }, - { 128, 255, 255, LIGHTYELLOW, wxT("LIGHTYELLOW"), LIGHTYELLOW } - }; -#endif /* ifdef MAIN */ - /** * Function MakeColour diff --git a/include/common.h b/include/common.h index 96d63572af..9e075687f4 100644 --- a/include/common.h +++ b/include/common.h @@ -9,10 +9,6 @@ #include "wx/confbase.h" #include "wx/fileconf.h" -#ifndef COMMON_GLOBL -# define COMMON_GLOBL extern -#endif - class wxAboutDialogInfo; class BASE_SCREEN; class WinEDA_DrawFrame; @@ -29,6 +25,8 @@ class WinEDA_DrawPanel; #define GR_KB_SHIFTCTRL (GR_KB_SHIFT | GR_KB_CTRL) #define MOUSE_MIDDLE 0x08000000 /* Middle button mouse flag for block commands */ +#define NB_ITEMS 11 + /* Pseudo key codes for command panning */ enum pseudokeys { EDA_PANNING_UP_KEY = 1, @@ -126,26 +124,11 @@ public: int m_BottomMargin; public: - Ki_PageDescr( const wxSize& size, const wxPoint& offset, const wxString& name ); + Ki_PageDescr( const wxSize& size, const wxPoint& offset, + const wxString& name ); }; -/* Standard page sizes in 1/1000 inch */ -#if defined EDA_BASE -Ki_PageDescr g_Sheet_A4( wxSize( 11700, 8267 ), wxPoint( 0, 0 ), wxT( "A4" ) ); -Ki_PageDescr g_Sheet_A3( wxSize( 16535, 11700 ), wxPoint( 0, 0 ), wxT( "A3" ) ); -Ki_PageDescr g_Sheet_A2( wxSize( 23400, 16535 ), wxPoint( 0, 0 ), wxT( "A2" ) ); -Ki_PageDescr g_Sheet_A1( wxSize( 33070, 23400 ), wxPoint( 0, 0 ), wxT( "A1" ) ); -Ki_PageDescr g_Sheet_A0( wxSize( 46800, 33070 ), wxPoint( 0, 0 ), wxT( "A0" ) ); -Ki_PageDescr g_Sheet_A( wxSize( 11000, 8500 ), wxPoint( 0, 0 ), wxT( "A" ) ); -Ki_PageDescr g_Sheet_B( wxSize( 17000, 11000 ), wxPoint( 0, 0 ), wxT( "B" ) ); -Ki_PageDescr g_Sheet_C( wxSize( 22000, 17000 ), wxPoint( 0, 0 ), wxT( "C" ) ); -Ki_PageDescr g_Sheet_D( wxSize( 34000, 22000 ), wxPoint( 0, 0 ), wxT( "D" ) ); -Ki_PageDescr g_Sheet_E( wxSize( 44000, 34000 ), wxPoint( 0, 0 ), wxT( "E" ) ); -Ki_PageDescr g_Sheet_GERBER( wxSize( 32000, 32000 ), wxPoint( 0, 0 ), wxT( "GERBER" ) ); -Ki_PageDescr g_Sheet_user( wxSize( 17000, 11000 ), wxPoint( 0, 0 ), wxT( "User" ) ); - -#else extern Ki_PageDescr g_Sheet_A4; extern Ki_PageDescr g_Sheet_A3; extern Ki_PageDescr g_Sheet_A2; @@ -158,93 +141,69 @@ extern Ki_PageDescr g_Sheet_D; extern Ki_PageDescr g_Sheet_E; extern Ki_PageDescr g_Sheet_GERBER; extern Ki_PageDescr g_Sheet_user; -#endif +extern Ki_PageDescr* g_SheetSizeList[]; -COMMON_GLOBL int g_LastKey; /* code de la derniere touche actionn�� */ -COMMON_GLOBL wxString g_ProductName -#ifdef EDA_BASE -= wxT( "KiCad E.D.A. " ) -#endif -; +extern wxString g_ProductName; /* Gestion des librairies */ -COMMON_GLOBL wxString g_RealLibDirBuffer; // Chemin reel des librairies de module +extern wxString g_RealLibDirBuffer; // Chemin reel des librairies de module // = UserLibDirBuffer si non vide // = chemin par defaut sinon -COMMON_GLOBL wxString g_UserLibDirBuffer; // Chemin des librairies de module donne par +extern wxString g_UserLibDirBuffer; // Chemin des librairies de module donne par // le file de config -/* variables globales generales */ - -COMMON_GLOBL int g_DebugLevel; // 0= Pas de debug */ -COMMON_GLOBL int g_MouseOldButtons; -COMMON_GLOBL int g_KeyPressed; +extern int g_DebugLevel; // 0= Pas de debug */ +extern int g_MouseOldButtons; +extern int g_KeyPressed; // Font used by kicad. // these font have a size which do not depend on default size system font -COMMON_GLOBL wxFont* g_StdFont; /* Standard font used for status display ,in message panel */ -COMMON_GLOBL wxFont* g_DialogFont; /* Normal font used in dialog box */ -COMMON_GLOBL wxFont* g_ItalicFont; /* Italic font used in dialog box */ -COMMON_GLOBL wxFont* g_MsgFont; /* Italic font used in msg panel (lower window) */ -COMMON_GLOBL wxFont* g_FixedFont; /* Affichage de Texte en fenetres de dialogue, +extern wxFont* g_StdFont; /* Standard font used for status display ,in message panel */ +extern wxFont* g_DialogFont; /* Normal font used in dialog box */ +extern wxFont* g_ItalicFont; /* Italic font used in dialog box */ +extern wxFont* g_MsgFont; /* Italic font used in msg panel (lower window) */ +extern wxFont* g_FixedFont; /* Affichage de Texte en fenetres de dialogue, * fonte a pas fixe)*/ -COMMON_GLOBL int g_StdFontPointSize; /* taille de la fonte */ -COMMON_GLOBL int g_DialogFontPointSize; /* taille de la fonte */ -COMMON_GLOBL int g_FixedFontPointSize; /* taille de la fonte */ -COMMON_GLOBL int g_MsgFontPointSize; /* taille de la fonte */ -COMMON_GLOBL int g_FontMinPointSize; /* taille minimum des fontes */ +extern int g_StdFontPointSize; /* taille de la fonte */ +extern int g_DialogFontPointSize; /* taille de la fonte */ +extern int g_FixedFontPointSize; /* taille de la fonte */ +extern int g_MsgFontPointSize; /* taille de la fonte */ +extern int g_FontMinPointSize; /* taille minimum des fontes */ -COMMON_GLOBL bool g_IsPrinting; // TRUE si impression au lieu de trace a l'ecran -COMMON_GLOBL bool g_ShowPageLimits // TRUE to display the page limits -#ifdef EDA_BASE -= TRUE -#endif -; +extern bool g_ShowPageLimits; // TRUE to display the page limits -/* Gloabl variables for project handling */ -COMMON_GLOBL wxString g_Prj_Config_Filename_ext -#ifdef EDA_BASE -= wxT( ".pro" ) -#endif -; -COMMON_GLOBL wxFileConfig* g_Prj_Config; // Configuration locale, propre au projet -COMMON_GLOBL wxString g_Prj_Default_Config_FullFilename; // Nom (full file name) du file Configuration par defaut (kicad.pro) -COMMON_GLOBL wxString g_Prj_Config_LocalFilename; // Nom du file Configuration local (.pro) +/* File name extension definitions. */ +extern const wxString ProjectFileExtension; +extern const wxString SchematicFileExtension; +extern const wxString BoardFileExtension; +extern const wxString NetlistFileExtension; +extern const wxString GerberFileExtension; -// Handle the preferd editor for browsing report files: -COMMON_GLOBL wxString g_EditorName; +extern const wxString ProjectFileWildcard; +extern const wxString SchematicFileWildcard; +extern const wxString BoardFileWildcard; +extern const wxString NetlistFileWildcard; +extern const wxString GerberFileWildcard; +extern const wxString AllFilesWildcard; -// Gestion de la grille "utilisateur" (User Grid) -#ifdef EDA_BASE -wxRealPoint g_UserGrid( 0.01, 0.01 ); +// Nom (full file name) du file Configuration par defaut (kicad.pro) +extern wxString g_Prj_Default_Config_FullFilename; +// Nom du file Configuration local (.pro) +extern wxString g_Prj_Config_LocalFilename; -int g_UserGrid_Unit = INCHES; -#else -extern wxRealPoint g_UserGrid; -extern int g_UserGrid_Unit; -#endif - -COMMON_GLOBL int g_UnitMetric; // display units mm = 1, inches = 0, cm = 2 - - -// shape selector for cursor screen -COMMON_GLOBL int g_CursorShape; +extern int g_UnitMetric; // display units mm = 1, inches = 0, cm = 2 /* Draw color for moving objects: */ -COMMON_GLOBL int g_GhostColor; +extern int g_GhostColor; /* Draw color for grid: */ -COMMON_GLOBL int g_GridColor -#ifdef EDA_BASE -= DARKGRAY -#endif -; +extern int g_GridColor; /* Current used screen: (not used in eeshema)*/ -COMMON_GLOBL BASE_SCREEN* ActiveScreen; +extern BASE_SCREEN* ActiveScreen; /* COMMON.CPP */ @@ -305,7 +264,8 @@ wxString& operator <<( wxString& aString, const wxPoint& aPoint ); * @param aFlags The same args as allowed for wxExecute() * @return bool - true if success, else false */ -bool ProcessExecute( const wxString& aCommandLine, int aFlags = wxEXEC_ASYNC ); +bool ProcessExecute( const wxString& aCommandLine, + int aFlags = wxEXEC_ASYNC ); @@ -313,21 +273,16 @@ bool ProcessExecute( const wxString& aCommandLine, int aFlags = w * Function ReturnPcbLayerName * @return a wxString containing the name of the layer number "layer_number". * @param layer_number the layer number of the layer - * @param is_filename if TRUE, the name can be used for a file name (not internatinalized, no space) + * @param is_filename if TRUE, the name can be used for a file name (not + * internatinalized, no space) */ -wxString ReturnPcbLayerName( int layer_number, bool is_filename = FALSE ); - -/* Microsoft Visual C++ compiler does not have round function (posix) */ -#ifdef __MSVC__ - /* return the near rounded (like the equivalent integer value) from aNumber */ - double round( double aNumber ); -#endif +wxString ReturnPcbLayerName( int layer_number, bool is_filename = FALSE ); /*******************/ /* about_kicad.cpp */ /*******************/ -void InitKiCadAbout( wxAboutDialogInfo& info); +void InitKiCadAbout( wxAboutDialogInfo& info); /**************/ @@ -354,16 +309,18 @@ void Affiche_1_Parametre( WinEDA_DrawFrame* frame, * color = couleur d'affichage */ -void AfficheDoc( WinEDA_DrawFrame* frame, const wxString& Doc, const wxString& KeyW ); +void AfficheDoc( WinEDA_DrawFrame* frame, const wxString& Doc, + const wxString& KeyW ); /* Routine d'affichage de la documentation associee a un composant */ -int GetTimeStamp(); +int GetTimeStamp(); /* Retoure une identification temporelle (Time stamp) differente a chaque appel */ -int DisplayColorFrame( wxWindow* parent, int OldColor ); -int GetCommandOptions( const int argc, const char** argv, const char* stringtst, - const char** optarg, int* optind ); +int DisplayColorFrame( wxWindow* parent, int OldColor ); +int GetCommandOptions( const int argc, const char** argv, + const char* stringtst, const char** optarg, + int* optind ); /* Retourne pour affichage la valeur d'un parametre, selon type d'unites choisies @@ -373,8 +330,9 @@ int GetCommandOptions( const int argc, const char** argv, const char */ const wxString& valeur_param( int valeur, wxString& buf_texte ); -wxString ReturnUnitSymbol( int Units = g_UnitMetric ); -int ReturnValueFromString( int Units, const wxString& TextValue, int Internal_Unit ); +wxString ReturnUnitSymbol( int Units = g_UnitMetric ); +int ReturnValueFromString( int Units, const wxString& TextValue, + int Internal_Unit ); /** Function ReturnStringFromValue * Return the string from Value, according to units (inch, mm ...) for display, @@ -385,19 +343,20 @@ int ReturnValueFromString( int Units, const wxString& TextValue, int * @param aAdd_unit_symbol = true to add symbol unit to the string value * @return a wxString what contains value and optionnaly the sumbol unit (like 2.000 mm) */ -wxString ReturnStringFromValue( int aUnits, int aValue, int aInternal_Unit, bool aAdd_unit_symbol = false ); +wxString ReturnStringFromValue( int aUnits, int aValue, int aInternal_Unit, + bool aAdd_unit_symbol = false ); + +void AddUnitSymbol( wxStaticText& Stext, int Units = g_UnitMetric ); /* Add string " (mm):" or " ("):" to the static text Stext. * Used in dialog boxes for entering values depending on selected units */ -void AddUnitSymbol( wxStaticText& Stext, int Units = g_UnitMetric ); +void PutValueInLocalUnits( wxTextCtrl& TextCtr, int Value, + int Internal_Unit ); /* Convert the number Value in a string according to the internal units * and the selected unit (g_UnitMetric) and put it in the wxTextCtrl TextCtrl */ -void PutValueInLocalUnits( wxTextCtrl& TextCtr, int Value, int Internal_Unit ); - -/* Convert the Value in the wxTextCtrl TextCtrl in an integer, - * according to the internal units and the selected unit (g_UnitMetric) */ -int ReturnValueFromTextCtrl( const wxTextCtrl& TextCtr, int Internal_Unit ); +int ReturnValueFromTextCtrl( const wxTextCtrl& TextCtr, + int Internal_Unit ); /** * Function To_User_Unit @@ -407,22 +366,12 @@ int ReturnValueFromTextCtrl( const wxTextCtrl& TextCtr, int Internal * @param val : double : the given value * @param internal_unit_value = internal units per inch */ -double To_User_Unit( bool is_metric, double val, int internal_unit_value ); +double To_User_Unit( bool is_metric, double val, int internal_unit_value ); -/** - * Function To_User_Unit - * Convert in inch or mm the variable "val" (double)given in internal units - * @return the converted value, in double - * @param is_metric : true if the result must be returned in mm , false if inches - * @param val : integer : the given value - * @param internal_unit_value = internal units per inch - */ -double To_User_Unit( bool is_metric, int val, int internal_unit_value ); - -int From_User_Unit( bool is_metric, double val, int internal_unit_value ); -wxString GenDate(); -void MyFree( void* pt_mem ); -void* MyZMalloc( size_t nb_octets ); -void* MyMalloc( size_t nb_octets ); +int From_User_Unit( bool is_metric, double val, int internal_unit_value ); +wxString GenDate(); +void MyFree( void* pt_mem ); +void* MyZMalloc( size_t nb_octets ); +void* MyMalloc( size_t nb_octets ); #endif /* __INCLUDE__COMMON_H__ */ diff --git a/include/gestfich.h b/include/gestfich.h index a0a34c7dcf..837bf02c43 100644 --- a/include/gestfich.h +++ b/include/gestfich.h @@ -9,13 +9,13 @@ #ifndef __INCLUDE__GESTFICH_H__ #define __INCLUDE__GESTFICH_H__ 1 +#include + /* Forward class declarations. */ class WinEDAListBox; -wxString GetEditorName(); // Return the prefered editor name - /** Function OpenPDF * run the PDF viewer and display a PDF file * @param file = PDF file to open @@ -42,8 +42,6 @@ wxString EDA_FileSelector( const wxString &Title, /* Window ti const wxPoint& Pos = wxPoint( -1, -1 ) ); -wxString MakeFileName( const wxString& dir, - const wxString& shortname, const wxString& ext ); /* Calcule le nom complet d'un file d'apres les chaines * dir = prefixe (chemin) @@ -74,7 +72,6 @@ wxString MakeReducedFileName( const wxString& fullfilename, WinEDAListBox* GetFileNames( char* Directory, char* Mask ); -void ChangeFileNameExt( wxString& FullFileName, const wxString& NewExt ); /* Change l'extension du "filename FullFileName" en NewExt. * Retourne FullFileName */ @@ -105,5 +102,15 @@ wxString FindKicadFile( const wxString& shortname ); * full file name if found or shortname */ +/** + * Quote return value of wxFileName::GetFullPath(). + * + * This allows file name paths with spaces to be used as parameters to + * ProcessExecute function calls. This is a cheap and dirty hack and + * should probably should be done in a class derived from wxFileName. + */ +extern wxString QuoteFullPath( wxFileName& fn, + wxPathFormat format = wxPATH_NATIVE ); + #endif /* __INCLUDE__GESTFICH_H__ */ diff --git a/include/gr_basic.h b/include/gr_basic.h index 4ad423ffa4..2f35b9d8d1 100644 --- a/include/gr_basic.h +++ b/include/gr_basic.h @@ -32,16 +32,8 @@ class EDA_Rect; /* variables generales */ -COMMON_GLOBL int g_XorMode // = GR_XOR ou GR_NXOR selon couleur de fond -#ifdef EDA_BASE // pour les tracés en mode XOR -= GR_NXOR -#endif -; -COMMON_GLOBL int g_DrawBgColor // couleur de fond de la frame de dessin -#ifdef EDA_BASE - = WHITE -#endif -; +extern int g_XorMode; +extern int g_DrawBgColor; typedef enum { /* Line styles for Get/SetLineStyle. */ diff --git a/include/hotkeys_basic.h b/include/hotkeys_basic.h index d291b9f1ea..bf50b79f40 100644 --- a/include/hotkeys_basic.h +++ b/include/hotkeys_basic.h @@ -8,10 +8,6 @@ #ifndef HOTKEYS_BASIC_H #define HOTKEYS_BASIC_H -#ifndef COMMON_GLOBL -#define COMMON_GLOBL extern -#endif - #define DEFAULT_HOTKEY_FILENAME_EXT wxT( ".key" ) /* keyword idetifier in kicad config use ti store/retrieve path option */ @@ -54,36 +50,14 @@ public: /* Identifiers (tags) in key code configuration file (or section names) * .m_SectionTag member of a Ki_HotkeyInfoSectionDescriptor */ -COMMON_GLOBL wxString g_CommonSectionTag -#ifdef EDA_BASE -( wxT( "[common]" ) ) -#endif -; -COMMON_GLOBL wxString g_SchematicSectionTag -#ifdef EDA_BASE -( wxT( "[eeschema]" ) ) -#endif -; -COMMON_GLOBL wxString g_LibEditSectionTag -#ifdef EDA_BASE -( wxT( "[libedit]" ) ) -#endif -; -COMMON_GLOBL wxString g_BoardEditorSectionTag -#ifdef EDA_BASE -( wxT( "[pcbnew]" ) ) -#endif -; -COMMON_GLOBL wxString g_ModuleEditSectionTag -#ifdef EDA_BASE -( wxT( "[footprinteditor]" ) ) -#endif -; +extern wxString g_CommonSectionTag; +extern wxString g_SchematicSectionTag; +extern wxString g_LibEditSectionTag; +extern wxString g_BoardEditorSectionTag; +extern wxString g_ModuleEditSectionTag; + +extern int g_ConfigFileLocationChoice; -COMMON_GLOBL int g_ConfigFileLocationChoice; /* 0 = files are in Home directory (usefull under unix) - * 1 = kicad/template ( usefull only under windows ) - * 2 ... = unused - */ /* Functions: */ diff --git a/include/id.h b/include/id.h index ba610816c6..dad65a150b 100644 --- a/include/id.h +++ b/include/id.h @@ -409,9 +409,6 @@ enum main_id { ID_LIBEDIT_GET_FRAME_EDIT_PART, ID_LIBEDIT_GET_FRAME_EDIT_FIELDS, ID_LIBEDIT_DELETE_PART, - ID_LIBEDIT_IMPORT_PART, - ID_LIBEDIT_EXPORT_PART, - ID_LIBEDIT_CREATE_NEW_LIB_AND_SAVE_CURRENT_PART, ID_LIBEDIT_UNDO, ID_LIBEDIT_REDO, ID_DE_MORGAN_NORMAL_BUTT, @@ -765,6 +762,9 @@ enum main_id { ID_MODEDIT_MODULE_SCALEY, ID_MODEDIT_UNDO, ID_MODEDIT_REDO, + ID_MODEDIT_IMPORT_PART, + ID_MODEDIT_EXPORT_PART, + ID_MODEDIT_CREATE_NEW_LIB_AND_SAVE_CURRENT_PART, ID_MODEDIT_UNUSED6, ID_MODEDIT_UNUSED7, ID_MODEDIT_UNUSED8, diff --git a/include/kicad_msvc.h b/include/kicad_msvc.h index 4094aed5c3..398be30d65 100644 --- a/include/kicad_msvc.h +++ b/include/kicad_msvc.h @@ -37,12 +37,6 @@ #define typeof(expr) BOOST_TYPEOF(expr) #endif // def _MSC_VER -inline double round(double x) -{ - return x >= 0.5 ? ceil(x) : floor(x); -} - #endif // def __MSVC__ #endif // ndef __KICAD_MSVC_ INC__ - diff --git a/include/pcbcommon.h b/include/pcbcommon.h new file mode 100644 index 0000000000..f5d930f097 --- /dev/null +++ b/include/pcbcommon.h @@ -0,0 +1,93 @@ + +#ifndef __PCBCOMMON_H__ +#define __PCBCOMMON_H__ + +#include "pcbstruct.h" +#include "dlist.h" + +#define UNDELETE_STACK_SIZE 10 +#define L_MIN_DESSIN 1 /* Min width segments to allow draws with tickness */ + +class DPAD; +class BOARD_ITEM; +class PCB_SCREEN; +class DISPLAY_OPTIONS; +class EDA_BoardDesignSettings; + +/* Look up Table for conversion one layer number -> one bit layer mask: */ +extern int g_TabOneLayerMask[LAYER_COUNT]; +/* Look up Table for conversion copper layer count -> general copper layer + * mask: */ +extern int g_TabAllCopperLayerMask[NB_COPPER_LAYERS]; + + + +extern wxArrayString g_LibName_List; // library list to load +extern bool g_ShowGrid; +extern BOARD_ITEM* g_UnDeleteStack[UNDELETE_STACK_SIZE]; +extern int g_UnDeleteStackPtr; +extern DISPLAY_OPTIONS DisplayOpt; + +extern wxString PcbExtBuffer; +extern wxString g_SaveFileName; +extern wxString NetExtBuffer; +extern wxString NetCmpExtBuffer; +extern const wxString ModuleFileExtension; + +extern const wxString ModuleFileWildcard; + +extern wxString g_ViaType_Name[4]; + +extern int g_CurrentVersionPCB; +extern int g_AnchorColor; +extern int g_ModuleTextCMPColor; +extern int g_ModuleTextCUColor; +extern int g_ModuleTextNOVColor; +extern int g_PadCUColor; +extern int g_PadCMPColor; + + + +/* variables generales */ +extern int g_TimeOut; // Timer for automatic saving +extern int g_SaveTime; // Time for next saving + +// Current design settings: +extern class EDA_BoardDesignSettings g_DesignSettings; + +extern DLIST g_CurrentTrackList; + +#define g_CurrentTrackSegment \ + g_CurrentTrackList.GetLast() ///< most recently created segment +#define g_FirstTrackSegment \ + g_CurrentTrackList.GetFirst() ///< first segment created + +extern PCB_SCREEN* ScreenPcb; /* Ecran principal */ +extern BOARD* g_ModuleEditor_Pcb; + +/* Pad editing */ +extern wxString g_Current_PadName; // Last used pad name (pad num) + +extern D_PAD g_Pad_Master; + +/* Gestion des plumes en plot format HPGL */ +extern int g_HPGL_Pen_Num; +extern int g_HPGL_Pen_Speed; +extern int g_HPGL_Pen_Diam; +extern int g_HPGL_Pen_Recouvrement; + +extern float Scale_X; +extern float Scale_Y; + +extern wxPoint g_PlotOffset; + +extern int g_PlotLine_Width; + +extern int g_PlotFormat; +extern int g_PlotOrient; + +/* id for plot format (see enum PlotFormat in plot_common.h) */ +extern int g_PlotScaleOpt; +extern int g_DrillShapeOpt; + +#endif /* __PCBCOMMON_H__ */ diff --git a/include/pcbstruct.h b/include/pcbstruct.h index 505629e4eb..877ed4197e 100644 --- a/include/pcbstruct.h +++ b/include/pcbstruct.h @@ -13,8 +13,6 @@ #define ENTETE_LIBRAIRIE "PCBNEW-LibModule-V1" #define ENTETE_LIBDOC "PCBNEW-LibDoc----V1" #define L_ENTETE_LIB 18 -#define EXT_CMP wxT( ".emp" ) -#define EXT_CMP_MASK wxT( "*.emp" ) #define EXT_DOC wxT( ".mdc" ) diff --git a/include/plot_common.h b/include/plot_common.h index cf67d7dc05..9312b9d572 100644 --- a/include/plot_common.h +++ b/include/plot_common.h @@ -8,13 +8,6 @@ #ifndef __INCLUDE__PLOT_COMMON_H__ #define __INCLUDE__PLOT_COMMON_H__ 1 -#ifndef EDA_BASE -# define COMMON_GLOBL extern -#else -# define COMMON_GLOBL -#endif - - /** * Enum PlotFormat * must be kept in order of the radio buttons in the plot panel/window. diff --git a/include/sch_item_struct.h b/include/sch_item_struct.h index 1fe77cdf9a..cc8eaba8f9 100644 --- a/include/sch_item_struct.h +++ b/include/sch_item_struct.h @@ -62,73 +62,12 @@ public: /** * Function Save - * writes the data structures for this object out to a FILE in "*.sch" format. + * writes the data structures for this object out to a FILE in "*.sch" + * format. * @param aFile The FILE to write to. * @return bool - true if success writing else false. */ virtual bool Save( FILE* aFile ) const = 0; }; - -/** - * Class DrawPickedStruct - * holds structures picked by pick events (like block selection). - * This class has only one useful member: .m_PickedStruct, used as a link. - * It is used to create a linked list of selected items (in block selection). - * Each DrawPickedStruct item has is member: .m_PickedStruct pointing the - * real selected item. - */ -class DrawPickedStruct : public SCH_ITEM -{ -public: - SCH_ITEM * m_PickedStruct; - -public: - DrawPickedStruct( SCH_ITEM * pickedstruct = NULL ); - ~DrawPickedStruct(); - void Place( WinEDA_SchematicFrame* frame, wxDC* DC ) { }; - void DeleteWrapperList(); - - DrawPickedStruct* Next() { return (DrawPickedStruct*) Pnext; } - - EDA_Rect GetBoundingBox(); - - /** - * Function GetBoundingBoxUnion - * returns the union of all the BoundingBox rectangles of all held items - * in the picklist whose list head is this DrawPickedStruct. - * @return EDA_Rect - The combined, composite, bounding box. - */ - EDA_Rect GetBoundingBoxUnion(); - - wxString GetClass() const { return wxT( "DrawPickedStruct" ); } - - /** - * Function Draw - * Do nothing, needed for SCH_ITEM compat. - */ - void Draw( WinEDA_DrawPanel* panel, - wxDC* DC, - const wxPoint& offset, - int draw_mode, - int Color = -1 ) - { - } - - /** - * Function Save - * Do nothing, needed for SCH_ITEM compat. - * @param aFile The FILE to write to. - * @return bool - true if success writing else false. - */ - bool Save( FILE* aFile ) const - { - return false; - } - -#if defined(DEBUG) - void Show( int nestLevel, std::ostream& os ); -#endif -}; - #endif /* SCH_ITEM_STRUCT_H */ diff --git a/include/worksheet.h b/include/worksheet.h index 1192c0e4f7..30b3e95fc4 100644 --- a/include/worksheet.h +++ b/include/worksheet.h @@ -1,75 +1,78 @@ - /***************************************************/ - /* WORKSHEET.H: constantes pour trace du cartouche */ - /***************************************************/ +/***************************************************/ +/* WORKSHEET.H: constantes pour trace du cartouche */ +/***************************************************/ - /****************************/ - /* Description du cartouche */ - /****************************/ +/****************************/ +/* Description du cartouche */ +/****************************/ /* Values are in 1/1000 inch */ -#define GRID_REF_W 70 /* hauteur de la bande de reference grille */ -#define SIZETEXT 60 /* Dimension des textes du cartouche */ -#define SIZETEXT_REF 50 /* Dimension des lettres du marquage des reperes */ -#define PAS_REF 2000 /* pas des marquages de reference des reperes */ +#ifndef __WORKSHEET_H__ +#define __WORKSHEET_H__ + +#define GRID_REF_W 70 /* hauteur de la bande de reference grille */ +#define SIZETEXT 60 /* Dimension des textes du cartouche */ +#define SIZETEXT_REF 50 /* Dimension des lettres du marquage des reperes */ +#define PAS_REF 2000 /* pas des marquages de reference des reperes */ #define TEXT_VTAB_HEIGHT SIZETEXT*2 #if defined(KICAD_GOST) /* Shtamp */ -#define STAMP_OX 185 * 10000 / 254 -#define STAMP_OY 55 * 10000 / 254 +#define STAMP_OX 185 * 10000 / 254 +#define STAMP_OY 55 * 10000 / 254 -#define STAMP_Y_0 0 -#define STAMP_Y_5 5 * 10000 / 254 -#define STAMP_Y_8 8 * 10000 / 254 -#define STAMP_Y_7 7 * 10000 / 254 -#define STAMP_Y_10 10 * 10000 / 254 -#define STAMP_Y_14 14 * 10000 / 254 -#define STAMP_Y_15 15 * 10000 / 254 -#define STAMP_Y_20 20 * 10000 / 254 -#define STAMP_Y_25 25 * 10000 / 254 -#define STAMP_Y_30 30 * 10000 / 254 -#define STAMP_Y_35 35 * 10000 / 254 -#define STAMP_Y_40 40 * 10000 / 254 -#define STAMP_Y_45 45 * 10000 / 254 -#define STAMP_Y_50 50 * 10000 / 254 -#define STAMP_Y_55 55 * 10000 / 254 +#define STAMP_Y_0 0 +#define STAMP_Y_5 5 * 10000 / 254 +#define STAMP_Y_8 8 * 10000 / 254 +#define STAMP_Y_7 7 * 10000 / 254 +#define STAMP_Y_10 10 * 10000 / 254 +#define STAMP_Y_14 14 * 10000 / 254 +#define STAMP_Y_15 15 * 10000 / 254 +#define STAMP_Y_20 20 * 10000 / 254 +#define STAMP_Y_25 25 * 10000 / 254 +#define STAMP_Y_30 30 * 10000 / 254 +#define STAMP_Y_35 35 * 10000 / 254 +#define STAMP_Y_40 40 * 10000 / 254 +#define STAMP_Y_45 45 * 10000 / 254 +#define STAMP_Y_50 50 * 10000 / 254 +#define STAMP_Y_55 55 * 10000 / 254 -#define STAMP_X_0 0 -#define STAMP_X_10 10 * 10000 / 254 -#define STAMP_X_14 14 * 10000 / 254 -#define STAMP_X_18 18 * 10000 / 254 -#define STAMP_X_30 30 * 10000 / 254 -#define STAMP_X_35 35 * 10000 / 254 -#define STAMP_X_40 40 * 10000 / 254 -#define STAMP_X_45 45 * 10000 / 254 -#define STAMP_X_50 50 * 10000 / 254 -#define STAMP_X_53 53 * 10000 / 254 -#define STAMP_X_70 70 * 10000 / 254 -#define STAMP_X_84 84 * 10000 / 254 -#define STAMP_X_120 120 * 10000 / 254 -#define STAMP_X_130 130 * 10000 / 254 -#define STAMP_X_137 137 * 10000 / 254 -#define STAMP_X_145 145 * 10000 / 254 -#define STAMP_X_168 168 * 10000 / 254 -#define STAMP_X_178 178 * 10000 / 254 -#define STAMP_X_185 185 * 10000 / 254 +#define STAMP_X_0 0 +#define STAMP_X_10 10 * 10000 / 254 +#define STAMP_X_14 14 * 10000 / 254 +#define STAMP_X_18 18 * 10000 / 254 +#define STAMP_X_30 30 * 10000 / 254 +#define STAMP_X_35 35 * 10000 / 254 +#define STAMP_X_40 40 * 10000 / 254 +#define STAMP_X_45 45 * 10000 / 254 +#define STAMP_X_50 50 * 10000 / 254 +#define STAMP_X_53 53 * 10000 / 254 +#define STAMP_X_70 70 * 10000 / 254 +#define STAMP_X_84 84 * 10000 / 254 +#define STAMP_X_120 120 * 10000 / 254 +#define STAMP_X_130 130 * 10000 / 254 +#define STAMP_X_137 137 * 10000 / 254 +#define STAMP_X_145 145 * 10000 / 254 +#define STAMP_X_168 168 * 10000 / 254 +#define STAMP_X_178 178 * 10000 / 254 +#define STAMP_X_185 185 * 10000 / 254 -#define STAMP_5 5 * 10000 / 254 -#define STAMP_7 7 * 10000 / 254 -#define STAMP_12 12 * 10000 / 254 +#define STAMP_5 5 * 10000 / 254 +#define STAMP_7 7 * 10000 / 254 +#define STAMP_12 12 * 10000 / 254 -#define STAMP_145 145 * 10000 / 254 -#define STAMP_110 110 * 10000 / 254 -#define STAMP_85 85 * 10000 / 254 -#define STAMP_60 60 * 10000 / 254 -#define STAMP_25 25 * 10000 / 254 +#define STAMP_145 145 * 10000 / 254 +#define STAMP_110 110 * 10000 / 254 +#define STAMP_85 85 * 10000 / 254 +#define STAMP_60 60 * 10000 / 254 +#define STAMP_25 25 * 10000 / 254 #endif /* Les coord ci dessous sont relatives au coin bas - droit de la feuille, et seront soustraires de cette origine */ -#define BLOCK_OX 4200 +#define BLOCK_OX 4200 #define BLOCK_KICAD_VERSION_X BLOCK_OX - SIZETEXT #define BLOCK_KICAD_VERSION_Y SIZETEXT #define BLOCK_REV_X 820 @@ -97,50 +100,50 @@ seront soustraires de cette origine struct Ki_WorkSheetData { public: - int m_Type; /* nombre permettant de reconnaitre la description */ - Ki_WorkSheetData * Pnext; - int m_Posx, m_Posy; /* position de l'element ou point de depart du segment */ - int m_Endx, m_Endy; /* extremite d'un element type segment ou cadre */ - const wxChar * m_Legende; /* Pour m_Textes: texte a afficher avant le texte lui meme */ - const wxChar * m_Text; /* Pour m_Textes:pointeur sur le texte a afficher */ + int m_Type; /* nombre permettant de reconnaitre la description */ + Ki_WorkSheetData * Pnext; + int m_Posx, m_Posy; /* position de l'element ou point de depart du segment */ + int m_Endx, m_Endy; /* extremite d'un element type segment ou cadre */ + const wxChar * m_Legende; /* Pour m_Textes: texte a afficher avant le texte lui meme */ + const wxChar * m_Text; /* Pour m_Textes:pointeur sur le texte a afficher */ }; /* Type des descriptions Ki_WorkSheetData */ enum TypeKi_WorkSheetData { - WS_DATE, - WS_REV, - WS_KICAD_VERSION, + WS_DATE, + WS_REV, + WS_KICAD_VERSION, #if defined(KICAD_GOST) - WS_PODPIS, + WS_PODPIS, #endif - WS_SIZESHEET, - WS_IDENTSHEET, + WS_SIZESHEET, + WS_IDENTSHEET, #if defined(KICAD_GOST) - WS_SHEETS, + WS_SHEETS, #endif - WS_TITLE, - WS_FILENAME, - WS_FULLSHEETNAME, - WS_COMPANY_NAME, - WS_COMMENT1, - WS_COMMENT2, - WS_COMMENT3, - WS_COMMENT4, - WS_SEGMENT, - WS_UPPER_SEGMENT, - WS_LEFT_SEGMENT, + WS_TITLE, + WS_FILENAME, + WS_FULLSHEETNAME, + WS_COMPANY_NAME, + WS_COMMENT1, + WS_COMMENT2, + WS_COMMENT3, + WS_COMMENT4, + WS_SEGMENT, + WS_UPPER_SEGMENT, + WS_LEFT_SEGMENT, #if defined(KICAD_GOST) - WS_CADRE, - WS_LEFT_SEGMENT_D, - WS_SEGMENT_D, - WS_PODPIS_D, - WS_IDENTSHEET_D, - WS_SEGMENT_LU, - WS_SEGMENT_LT, - WS_PODPIS_LU + WS_CADRE, + WS_LEFT_SEGMENT_D, + WS_SEGMENT_D, + WS_PODPIS_D, + WS_IDENTSHEET_D, + WS_SEGMENT_LU, + WS_SEGMENT_LT, + WS_PODPIS_LU #else - WS_CADRE + WS_CADRE #endif }; @@ -239,905 +242,4 @@ extern Ki_WorkSheetData WS_Segm4_LT; extern Ki_WorkSheetData WS_Segm5_LT; #endif -#ifdef EDA_BASE - -Ki_WorkSheetData WS_Date = - { - WS_DATE, - &WS_Licence, - BLOCK_DATE_X, BLOCK_DATE_Y, - 0,0, -#if defined(KICAD_GOST) - NULL, NULL -#else - wxT("Date: "), NULL -#endif - }; - -Ki_WorkSheetData WS_Licence = - { - WS_KICAD_VERSION, - &WS_Revision, - BLOCK_KICAD_VERSION_X, BLOCK_KICAD_VERSION_Y, - 0,0, - NULL, NULL - }; - -Ki_WorkSheetData WS_Revision = - { - WS_REV, - &WS_SizeSheet, -#if defined(KICAD_GOST) - STAMP_X_185 - 30, STAMP_Y_30 + 90, -#else - BLOCK_REV_X, BLOCK_REV_Y, -#endif - 0,0, -#if defined(KICAD_GOST) - NULL, NULL -#else - wxT("Rev: "), NULL -#endif - }; - -Ki_WorkSheetData WS_SizeSheet = - { - WS_SIZESHEET, -#if defined(KICAD_GOST) - &WS_Title, - BLOCK_SIZE_SHEET_X, BLOCK_SIZE_SHEET_Y, - 0,0, - NULL, NULL - }; -#else - &WS_IdentSheet, - BLOCK_SIZE_SHEET_X, BLOCK_SIZE_SHEET_Y, - 0,0, - wxT("Size: "),NULL - }; - -Ki_WorkSheetData WS_IdentSheet = - { - WS_IDENTSHEET, - &WS_Title, - BLOCK_ID_SHEET_X, BLOCK_ID_SHEET_Y, - 0,0, - wxT("Id: "),NULL - }; -#endif - -Ki_WorkSheetData WS_Title = - { - WS_TITLE, - &WS_SheetFilename, - BLOCK_TITLE_X, BLOCK_TITLE_Y, - 0,0, -#if defined(KICAD_GOST) - NULL, NULL -#else - wxT("Title: "),NULL -#endif - }; - -Ki_WorkSheetData WS_SheetFilename = - { - WS_FILENAME, - &WS_FullSheetName, - BLOCK_FILENAME_X, BLOCK_FILENAME_Y, - 0,0, - wxT("File: "),NULL - }; - -Ki_WorkSheetData WS_FullSheetName = - { - WS_FULLSHEETNAME, - &WS_Company, - BLOCK_FULLSHEETNAME_X, BLOCK_FULLSHEETNAME_Y, - 0,0, - wxT("Sheet: "),NULL - }; - -Ki_WorkSheetData WS_Company = - { - WS_COMPANY_NAME, - &WS_Comment1, - BLOCK_COMMENT_X, BLOCK_COMPANY_Y, - 0,0, - NULL,NULL - }; - -Ki_WorkSheetData WS_Comment1 = - { - WS_COMMENT1, - &WS_Comment2, -#if defined(KICAD_GOST) - STAMP_OX, STAMP_OY, - STAMP_OX, 0, -#else - BLOCK_COMMENT_X, BLOCK_COMMENT1_Y, - 0,0, -#endif - NULL,NULL - }; - -Ki_WorkSheetData WS_Comment2 = - { - WS_COMMENT2, - &WS_Comment3, -#if defined(KICAD_GOST) - STAMP_OX, STAMP_OY, - STAMP_OX, 0, -#else - BLOCK_COMMENT_X, BLOCK_COMMENT2_Y, - 0,0, -#endif - NULL,NULL - }; - -Ki_WorkSheetData WS_Comment3 = - { - WS_COMMENT3, - &WS_Comment4, -#if defined(KICAD_GOST) - STAMP_OX, STAMP_OY, - STAMP_OX, 0, -#else - BLOCK_COMMENT_X, BLOCK_COMMENT3_Y, - 0,0, -#endif - NULL,NULL - }; - -Ki_WorkSheetData WS_Comment4 = - { - WS_COMMENT4, - &WS_MostLeftLine, -#if defined(KICAD_GOST) - STAMP_OX, STAMP_OY, - STAMP_OX, 0, -#else - BLOCK_COMMENT_X, BLOCK_COMMENT4_Y, - 0,0, -#endif - NULL,NULL - }; - -Ki_WorkSheetData WS_MostLeftLine = /* segment vertical gauche */ - { - WS_LEFT_SEGMENT, -#if defined(KICAD_GOST) - &WS_MostUpperLine, - STAMP_OX, STAMP_OY, - STAMP_OX, 0, -#else - &WS_SeparatorLine, - BLOCK_OX, SIZETEXT * 16, - BLOCK_OX, 0, - NULL,NULL - }; - -Ki_WorkSheetData WS_SeparatorLine = /* horizontal segment between filename and comments*/ - { - WS_SEGMENT, - &WS_MostUpperLine, - BLOCK_OX, VARIABLE_BLOCK_START_POSITION, - 0, VARIABLE_BLOCK_START_POSITION, -#endif - NULL,NULL - }; - -Ki_WorkSheetData WS_MostUpperLine = /* segment horizontal superieur */ - { - WS_UPPER_SEGMENT, - &WS_Segm3, -#if defined(KICAD_GOST) - STAMP_OX, STAMP_OY, - 0, STAMP_OY, -#else - BLOCK_OX, SIZETEXT * 16, - 0, SIZETEXT * 16, -#endif - NULL,NULL - }; - -Ki_WorkSheetData WS_Segm3 = /* segment horizontal au dessus de NAME COMPANY */ - { - WS_SEGMENT, - &WS_Segm4, -#if defined(KICAD_GOST) - STAMP_OX, STAMP_Y_50, - STAMP_X_120, STAMP_Y_50, -#else - BLOCK_OX, SIZETEXT * 6, - 0, SIZETEXT * 6, -#endif - NULL,NULL - }; - -Ki_WorkSheetData WS_Segm4 = /* segment vertical a gauche de SHEET et REV */ - { - WS_SEGMENT, - &WS_Segm5, -#if defined(KICAD_GOST) - STAMP_OX, STAMP_Y_45, - STAMP_X_120, STAMP_Y_45, -#else - BLOCK_REV_X + SIZETEXT, SIZETEXT * 4, - BLOCK_REV_X + SIZETEXT, 0, -#endif - NULL,NULL - }; - -Ki_WorkSheetData WS_Segm5 = /* 1er segment horizontal */ - { - WS_SEGMENT, - &WS_Segm6, -#if defined(KICAD_GOST) - STAMP_OX, STAMP_Y_40, - 0, STAMP_Y_40, -#else - BLOCK_OX, SIZETEXT * 2, - 0, SIZETEXT * 2, -#endif - NULL,NULL - }; - -Ki_WorkSheetData WS_Segm6 = /* 2eme segment horizontal */ - { - WS_SEGMENT, - &WS_Segm7, -#if defined(KICAD_GOST) - STAMP_OX, STAMP_Y_35, - STAMP_X_120, STAMP_Y_35, -#else - BLOCK_OX, SIZETEXT * 4, - 0, SIZETEXT * 4, -#endif - NULL,NULL - }; - -Ki_WorkSheetData WS_Segm7 = /* segment vertical apres SIZE */ - { - WS_SEGMENT, -#if defined(KICAD_GOST) - &WS_Segm8, - STAMP_X_50, STAMP_Y_35, - 0, STAMP_Y_35, - NULL,NULL - }; - -Ki_WorkSheetData WS_Segm8 = /* segment vertical apres SIZE */ - { - WS_SEGMENT, - &WS_Segm9, - STAMP_OX, STAMP_Y_30, - STAMP_X_120, STAMP_Y_30, - NULL,NULL - }; - -Ki_WorkSheetData WS_Segm9 = /* segment vertical apres SIZE */ - { - WS_SEGMENT, - &WS_Segm10, - STAMP_OX, STAMP_Y_25, - STAMP_X_120, STAMP_Y_25, - NULL,NULL - }; - -Ki_WorkSheetData WS_Segm10 = /* segment vertical apres SIZE */ - { - WS_SEGMENT, - &WS_Segm11, - STAMP_OX, STAMP_Y_20, - STAMP_X_120, STAMP_Y_20, - NULL,NULL - }; - -Ki_WorkSheetData WS_Segm11 = /* segment vertical apres SIZE */ - { - WS_SEGMENT, - &WS_Segm12, - STAMP_X_50, STAMP_Y_20, - 0, STAMP_Y_20, - NULL,NULL - }; - -Ki_WorkSheetData WS_Segm12 = /* segment vertical apres SIZE */ - { - WS_SEGMENT, - &WS_Segm13, - STAMP_OX, STAMP_Y_15, - 0, STAMP_Y_15, - NULL,NULL - }; - -Ki_WorkSheetData WS_Segm13 = /* segment vertical apres SIZE */ - { - WS_SEGMENT, - &WS_Segm14, - STAMP_OX, STAMP_Y_10, - STAMP_X_120, STAMP_Y_10, - NULL,NULL - }; - -Ki_WorkSheetData WS_Segm14 = /* segment vertical apres SIZE */ - { - WS_SEGMENT, - &WS_Segm15, - STAMP_OX, STAMP_Y_5, - STAMP_X_120, STAMP_Y_5, - NULL,NULL - }; - -Ki_WorkSheetData WS_Segm15 = /* segment vertical apres SIZE */ - { - WS_SEGMENT, - &WS_Segm16, - STAMP_X_178, STAMP_OY, - STAMP_X_178, STAMP_Y_30, - NULL,NULL - }; - -Ki_WorkSheetData WS_Segm16 = /* segment vertical apres SIZE */ - { - WS_SEGMENT, - &WS_Segm17, - STAMP_X_168, STAMP_OY, - STAMP_X_168, 0, - NULL,NULL - }; - -Ki_WorkSheetData WS_Segm17 = /* segment vertical apres SIZE */ - { - WS_SEGMENT, - &WS_Segm18, - STAMP_X_145, STAMP_OY, - STAMP_X_145, 0, - NULL,NULL - }; - -Ki_WorkSheetData WS_Segm18 = /* segment vertical apres SIZE */ - { - WS_SEGMENT, - &WS_Segm19, - STAMP_X_130, STAMP_OY, - STAMP_X_130, 0, - NULL,NULL - }; - -Ki_WorkSheetData WS_Segm19 = /* segment vertical apres SIZE */ - { - WS_SEGMENT, - &WS_Segm20, - STAMP_X_120, STAMP_OY, - STAMP_X_120, 0, - NULL,NULL - }; - -Ki_WorkSheetData WS_Segm20 = /* segment vertical apres SIZE */ - { - WS_SEGMENT, - &WS_Segm21, - STAMP_X_50, STAMP_Y_40, - STAMP_X_50, 0, - NULL,NULL - }; - -Ki_WorkSheetData WS_Segm21 = /* segment vertical apres SIZE */ - { - WS_SEGMENT, - &WS_Segm22, - STAMP_X_45, STAMP_Y_35, - STAMP_X_45, STAMP_Y_20, - NULL,NULL - }; - -Ki_WorkSheetData WS_Segm22 = /* segment vertical apres SIZE */ - { - WS_SEGMENT, - &WS_Segm23, - STAMP_X_40, STAMP_Y_35, - STAMP_X_40, STAMP_Y_20, - NULL,NULL - }; - -Ki_WorkSheetData WS_Segm23 = /* segment vertical apres SIZE */ - { - WS_SEGMENT, - &WS_Segm24, - STAMP_X_35, STAMP_Y_40, - STAMP_X_35, STAMP_Y_20, - NULL,NULL - }; - -Ki_WorkSheetData WS_Segm24 = /* segment vertical apres SIZE */ - { - WS_SEGMENT, - &WS_Segm25, - STAMP_X_30, STAMP_Y_20, - STAMP_X_30, STAMP_Y_15, - NULL,NULL - }; - -Ki_WorkSheetData WS_Segm25 = /* segment vertical apres SIZE */ - { - WS_SEGMENT, - &WS_Izm, - STAMP_X_18, STAMP_Y_40, - STAMP_X_18, STAMP_Y_20, - NULL,NULL - }; - -Ki_WorkSheetData WS_Izm = - { - WS_PODPIS, - &WS_Razr, - STAMP_X_185 - 30,STAMP_Y_30 + 90, - 0,0, - wxT("Изм."), NULL - }; - -Ki_WorkSheetData WS_Razr = - { - WS_PODPIS, - &WS_Prov, - STAMP_X_185 - 30,STAMP_Y_25 + 90, - 0,0, - wxT("Разраб."), NULL - }; - -Ki_WorkSheetData WS_Prov = - { - WS_PODPIS, - &WS_TKon, - STAMP_X_185 - 30,STAMP_Y_20 + 90, - 0,0, - wxT("Пров."), NULL - }; - -Ki_WorkSheetData WS_TKon = - { - WS_PODPIS, - &WS_NKon, - STAMP_X_185 - 30,STAMP_Y_15 + 90, - 0,0, - wxT("Т.контр."), NULL - }; - -Ki_WorkSheetData WS_NKon = - { - WS_PODPIS, - &WS_Utv, - STAMP_X_185 - 30,STAMP_Y_5 + 90, - 0,0, - wxT("Ð.контр."), NULL - }; - -Ki_WorkSheetData WS_Utv = - { - WS_PODPIS, - &WS_List, - STAMP_X_185 - 30,STAMP_Y_0 + 90, - 0,0, - wxT("Утв."), NULL - }; - -Ki_WorkSheetData WS_List = - { - WS_PODPIS, - &WS_NDoc, - STAMP_X_178 - 30,STAMP_Y_30 + 90, - 0,0, - wxT("ЛиÑÑ‚"), NULL - }; - -Ki_WorkSheetData WS_NDoc = - { - WS_PODPIS, - &WS_Podp, - STAMP_X_168 - 30,STAMP_Y_30 + 90, - 0,0, - wxT("N докум."), NULL - }; - -Ki_WorkSheetData WS_Podp = - { - WS_PODPIS, - &WS_Data, - STAMP_X_145 - 30,STAMP_Y_30 + 90, - 0,0, - wxT("Подп."), NULL - }; - -Ki_WorkSheetData WS_Data = - { - WS_PODPIS, - &WS_Art, - STAMP_X_130 - 30,STAMP_Y_30 + 90, - 0,0, - wxT("Дата"), NULL - }; - -Ki_WorkSheetData WS_Art = - { - WS_PODPIS, - &WS_Mass, - STAMP_X_50 - 30,STAMP_Y_35 + 90, - 0,0, - wxT("Ðрт."), NULL - }; - -Ki_WorkSheetData WS_Mass = - { - WS_PODPIS, - &WS_Msht, - STAMP_X_35 - 30,STAMP_Y_35 + 90, - 0,0, - wxT("МаÑÑа"), NULL - }; - -Ki_WorkSheetData WS_Msht = - { - WS_PODPIS, - &WS_List1, - STAMP_X_18 - 30,STAMP_Y_35 + 90, - 0,0, - wxT("МаÑштаб"), NULL - }; - -Ki_WorkSheetData WS_List1 = - { - WS_IDENTSHEET, - &WS_List2, - STAMP_X_50 - 30,STAMP_Y_15 + 90, - 0,0, - wxT("ЛиÑÑ‚ "), NULL - }; - -Ki_WorkSheetData WS_List2 = - { - WS_SHEETS, - NULL, - STAMP_X_30 - 30,STAMP_Y_15 + 90, - 0,0, - wxT("ЛиÑтов "), NULL - }; - -Ki_WorkSheetData WS_CADRE_D = - { - WS_CADRE, - &WS_Segm1_D, - STAMP_OX, 0, - 0,0, - NULL, NULL - }; - -Ki_WorkSheetData WS_Segm1_D = - { - WS_LEFT_SEGMENT_D, - &WS_Segm2_D, - STAMP_OX, STAMP_Y_15, - STAMP_OX, 0, - NULL, NULL - }; - -Ki_WorkSheetData WS_Segm2_D = - { - WS_SEGMENT_D, - &WS_Segm3_D, - STAMP_X_178, STAMP_Y_15, - STAMP_X_178, 0, - NULL, NULL - }; - -Ki_WorkSheetData WS_Segm3_D = - { - WS_SEGMENT_D, - &WS_Segm4_D, - STAMP_X_168, STAMP_Y_15, - STAMP_X_168, 0, - NULL, NULL - }; - -Ki_WorkSheetData WS_Segm4_D = - { - WS_SEGMENT_D, - &WS_Segm5_D, - STAMP_X_145, STAMP_Y_15, - STAMP_X_145, 0, - NULL, NULL - }; - -Ki_WorkSheetData WS_Segm5_D = - { - WS_SEGMENT_D, - &WS_Segm6_D, - STAMP_X_130, STAMP_Y_15, - STAMP_X_130, 0, - NULL, NULL - }; - -Ki_WorkSheetData WS_Segm6_D = - { - WS_SEGMENT_D, - &WS_Segm7_D, - STAMP_X_120, STAMP_Y_15, - STAMP_X_120, 0, - NULL, NULL - }; - -Ki_WorkSheetData WS_Segm7_D = - { - WS_SEGMENT_D, - &WS_Segm8_D, - STAMP_X_10, STAMP_Y_15, - STAMP_X_10, 0, - NULL, NULL - }; - -Ki_WorkSheetData WS_Segm8_D = - { - WS_SEGMENT_D, - &WS_Segm9_D, - STAMP_X_185, STAMP_Y_10, - STAMP_X_120, STAMP_Y_10, - NULL, NULL - }; - -Ki_WorkSheetData WS_Segm9_D = - { - WS_SEGMENT_D, - &WS_Segm10_D, - STAMP_X_185, STAMP_Y_5, - STAMP_X_120, STAMP_Y_5, - NULL, NULL - }; - -Ki_WorkSheetData WS_Segm10_D = - { - WS_SEGMENT_D, - &WS_Segm11_D, - STAMP_X_10, STAMP_Y_8, - 0, STAMP_Y_8, - NULL, NULL - }; - -Ki_WorkSheetData WS_Segm11_D = - { - WS_SEGMENT_D, - &WS_Izm_D, - STAMP_X_185, STAMP_Y_15, - 0, STAMP_Y_15, - NULL, NULL - }; - -Ki_WorkSheetData WS_Izm_D = - { - WS_PODPIS_D, - &WS_List_D, - STAMP_X_185 - 30, STAMP_Y_0 + 90, - 0, 0, - wxT("Изм."), NULL - }; - -Ki_WorkSheetData WS_List_D = - { - WS_PODPIS_D, - &WS_NDoc_D, - STAMP_X_178 - 30, STAMP_Y_0 + 90, - 0, 0, - wxT("ЛиÑÑ‚"), NULL - }; - -Ki_WorkSheetData WS_NDoc_D = - { - WS_PODPIS_D, - &WS_Podp_D, - STAMP_X_168 - 30, STAMP_Y_0 + 90, - 0, 0, - wxT("N докум."), NULL - }; - -Ki_WorkSheetData WS_Podp_D = - { - WS_PODPIS_D, - &WS_Date_D, - STAMP_X_145 - 30, STAMP_Y_0 + 90, - 0, 0, - wxT("Подп."), NULL - }; - -Ki_WorkSheetData WS_Date_D = - { - WS_PODPIS_D, - &WS_List1_D, - STAMP_X_130 - 30, STAMP_Y_0 + 90, - 0, 0, - wxT("Дата"), NULL - }; - -Ki_WorkSheetData WS_List1_D = - { - WS_PODPIS_D, - &WS_ListN_D, - STAMP_X_10 - 30, STAMP_Y_8 + 90, - 0, 0, - wxT("ЛиÑÑ‚"), NULL - }; - -Ki_WorkSheetData WS_ListN_D = - { - WS_IDENTSHEET_D, - NULL, - STAMP_Y_0 + 196, STAMP_Y_0 + 90, - 0, 0, - NULL, NULL - }; - -Ki_WorkSheetData WS_Segm1_LU = - { - WS_SEGMENT_LU, - &WS_Segm2_LU, - STAMP_12, STAMP_145, - STAMP_12, 0, - NULL, NULL - }; - -Ki_WorkSheetData WS_Segm2_LU = - { - WS_SEGMENT_LU, - &WS_Segm3_LU, - STAMP_7, STAMP_145, - STAMP_7, 0, - NULL, NULL - }; - -Ki_WorkSheetData WS_Segm3_LU = - { - WS_SEGMENT_LU, - &WS_Segm4_LU, - STAMP_12, STAMP_145, - 0, STAMP_145, - NULL, NULL - }; - -Ki_WorkSheetData WS_Segm4_LU = - { - WS_SEGMENT_LU, - &WS_Segm5_LU, - STAMP_12, STAMP_110, - 0, STAMP_110, - NULL, NULL - }; - -Ki_WorkSheetData WS_Segm5_LU = - { - WS_SEGMENT_LU, - &WS_Segm6_LU, - STAMP_12, STAMP_85, - 0, STAMP_85, - NULL, NULL - }; - -Ki_WorkSheetData WS_Segm6_LU = - { - WS_SEGMENT_LU, - &WS_Segm7_LU, - STAMP_12, STAMP_60, - 0, STAMP_60, - NULL, NULL - }; - -Ki_WorkSheetData WS_Segm7_LU = - { - WS_SEGMENT_LU, - &WS_Segm8_LU, - STAMP_12, STAMP_25, - 0, STAMP_25, - NULL, NULL - }; - -Ki_WorkSheetData WS_Segm8_LU = - { - WS_SEGMENT_LU, - &WS_Podp1_LU, - STAMP_12, 0, - 0, 0, - NULL, NULL - }; - -Ki_WorkSheetData WS_Podp1_LU = - { - WS_PODPIS_LU, - &WS_Podp2_LU, - STAMP_7 + 90, 0 + 30, - 0, 0, - wxT("Инв.N подл."), NULL - }; - -Ki_WorkSheetData WS_Podp2_LU = - { - WS_PODPIS_LU, - &WS_Podp3_LU, - STAMP_7 + 90, STAMP_25 + 30, - 0, 0, - wxT("Подп. и дата"), NULL - }; - -Ki_WorkSheetData WS_Podp3_LU = - { - WS_PODPIS_LU, - &WS_Podp4_LU, - STAMP_7 + 90, STAMP_60 + 30, - 0, 0, - wxT("Взам.инв.N"), NULL - }; - -Ki_WorkSheetData WS_Podp4_LU = - { - WS_PODPIS_LU, - &WS_Podp5_LU, - STAMP_7 + 90, STAMP_85 + 30, - 0, 0, - wxT("Инв.N дубл."), NULL - }; - -Ki_WorkSheetData WS_Podp5_LU = - { - WS_PODPIS_LU, - NULL, - STAMP_7 + 90, STAMP_110 + 30, - 0, 0, - wxT("Подп. и дата"), NULL - }; - -Ki_WorkSheetData WS_Segm1_LT = - { - WS_SEGMENT_LT, - &WS_Segm2_LT, - STAMP_X_0, STAMP_Y_14, - STAMP_X_137, STAMP_Y_14, - NULL, NULL - }; - -Ki_WorkSheetData WS_Segm2_LT = - { - WS_SEGMENT_LT, - &WS_Segm3_LT, - STAMP_X_137, STAMP_Y_14, - STAMP_X_137, 0, - NULL, NULL - }; - -Ki_WorkSheetData WS_Segm3_LT = - { - WS_SEGMENT_LT, - &WS_Segm4_LT, - STAMP_X_137, STAMP_Y_7, - STAMP_X_84, STAMP_Y_7, - NULL, NULL - }; - -Ki_WorkSheetData WS_Segm4_LT = - { - WS_SEGMENT_LT, - &WS_Segm5_LT, - STAMP_X_84, STAMP_Y_14, - STAMP_X_84, 0, - NULL, NULL - }; -Ki_WorkSheetData WS_Segm5_LT = - { - WS_SEGMENT_LT, - NULL, - STAMP_X_70, STAMP_Y_14, - STAMP_X_70, 0, -#else - NULL, - BLOCK_OX - (SIZETEXT * 11), SIZETEXT * 4, - BLOCK_OX - (SIZETEXT * 11), SIZETEXT * 2, -#endif - NULL, NULL - }; - -#endif +#endif /* __WORKSHEET_H__ */ diff --git a/include/wxEeschemaStruct.h b/include/wxEeschemaStruct.h index 92b85950f7..cd1ffca9a9 100644 --- a/include/wxEeschemaStruct.h +++ b/include/wxEeschemaStruct.h @@ -65,6 +65,7 @@ public: private: SCH_CMP_FIELD* m_CurrentField; int m_TextFieldSize; + bool m_ShowGrid; public: @@ -83,6 +84,9 @@ public: void Save_Config( wxWindow* displayframe ); + void LoadSettings(); + void SaveSettings(); + void RedrawActiveWindow( wxDC* DC, bool EraseBg ); void CreateScreens(); @@ -386,6 +390,11 @@ public: ~WinEDA_LibeditFrame(); void Process_Special_Functions( wxCommandEvent& event ); + void OnImportPart( wxCommandEvent& event ); + void OnExportPart( wxCommandEvent& event ); + void OnUpdateEditingPart( wxUpdateUIEvent& event ); + void OnUpdateNotEditingPart( wxUpdateUIEvent& event ); + void DisplayLibInfos(); void RedrawActiveWindow( wxDC* DC, bool EraseBg ); void OnCloseWindow( wxCloseEvent& Event ); @@ -398,9 +407,13 @@ public: void OnLeftDClick( wxDC* DC, const wxPoint& MousePos ); SCH_SCREEN* GetScreen() { return (SCH_SCREEN*) GetBaseScreen(); } - void OnHotKey( wxDC* DC, int hotkey, EDA_BaseStruct* DrawStruct ); + void OnHotKey( wxDC* DC, int hotkey, + EDA_BaseStruct* DrawStruct ); - void GeneralControle( wxDC* DC, wxPoint MousePositionInPixels ); + void GeneralControle( wxDC* DC, + wxPoint MousePositionInPixels ); + void LoadSettings(); + void SaveSettings(); private: @@ -411,10 +424,10 @@ private: void SelectActiveLibrary(); bool LoadOneLibraryPart(); void SaveActiveLibrary(); - void ImportOnePart(); - void ExportOnePart( bool create_lib ); + int LoadOneLibraryPartAux( EDA_LibComponentStruct* LibEntry, - LibraryStruct* Library, int noMsg = 0 ); + LibraryStruct* Library, + int noMsg = 0 ); void DisplayCmpDoc( const wxString& Name ); void InstallLibeditFrame( ); @@ -473,6 +486,11 @@ public: // Repetition automatique de placement de pins void RepeatPinItem( wxDC* DC, LibDrawPin* Pin ); +protected: + wxString m_ConfigPath; + wxString m_LastLibImportPath; + wxString m_LastLibExportPath; + DECLARE_EVENT_TABLE() }; diff --git a/include/wxPcbStruct.h b/include/wxPcbStruct.h index c8424aeece..638bb30e15 100644 --- a/include/wxPcbStruct.h +++ b/include/wxPcbStruct.h @@ -57,6 +57,9 @@ public: int m_DisplayModEdge; // How show module drawings int m_DisplayModText; // How show module texts bool m_DisplayPcbTrackFill; /* FALSE : tracks are show in sketch mode, TRUE = filled */ + int m_UserGridUnits; + wxRealPoint m_UserGridSize; + WinEDA3D_DrawFrame* m_Draw3DFrame; WinEDA_ModuleEditFrame* m_ModuleEditFrame; @@ -99,7 +102,7 @@ public: virtual void ReCreateMenuBar(); virtual void SetToolID( int id, int new_cursor_id, const wxString& title ); - virtual void Affiche_Status_Box(); + virtual void UpdateStatusBar(); PCB_SCREEN* GetScreen() const { return (PCB_SCREEN*) WinEDA_DrawFrame::GetBaseScreen(); } @@ -313,6 +316,9 @@ public: void AddHistory( int value, KICAD_T type ); // Add value in data list history void InstallGridFrame( const wxPoint& pos ); + virtual void LoadSettings(); + virtual void SaveSettings(); + DECLARE_EVENT_TABLE() }; @@ -825,7 +831,7 @@ public: void Files_io( wxCommandEvent& event ); void OnFileHistory( wxCommandEvent& event ); - int LoadOneGerberFile( const wxString& FileName, wxDC* DC, int mode ); + bool LoadOneGerberFile( const wxString& FileName, wxDC* DC, int mode ); int ReadGerberFile( wxDC* DC, FILE* File, bool Append ); bool Read_GERBER_File( wxDC* DC, const wxString& GERBER_FullFileName, diff --git a/include/wxstruct.h b/include/wxstruct.h index c5101edd0a..5a526cd6f3 100644 --- a/include/wxstruct.h +++ b/include/wxstruct.h @@ -7,10 +7,6 @@ #define WXSTRUCT_H -#ifndef eda_global -#define eda_global extern -#endif - #include @@ -122,8 +118,10 @@ public: void GetKicadHelp( wxCommandEvent& event ); void GetKicadAbout( wxCommandEvent& event ); void PrintMsg( const wxString& text ); - void GetSettings(); - void SaveSettings(); + + virtual void LoadSettings(); + virtual void SaveSettings(); + int WriteHotkeyConfigFile( const wxString& Filename, struct Ki_HotkeyInfoSectionDescriptor* DescList, bool verbose ); @@ -157,7 +155,7 @@ public: WinEDAChoiceBox* m_SelGridBox; // Dialog box to choose the grid size WinEDAChoiceBox* m_SelZoomBox; // Dialog box to choose the Zoom value - int m_CurrentCursorShape; // shape for cursor (0 = default cursor) + int m_CursorShape; // shape for cursor (0 = default cursor) int m_ID_current_state; // Id of active button on the vertical toolbar int m_HTOOL_current_state; // Id of active button on horizontal toolbar @@ -270,7 +268,7 @@ public: virtual bool OnRightClick( const wxPoint& MousePos, wxMenu* PopMenu ) = 0; virtual void ToolOnRightClick( wxCommandEvent& event ); void AdjustScrollBars(); - virtual void Affiche_Status_Box(); /* Affichage des coord curseur, zoom .. */ + virtual void UpdateStatusBar(); /* Affichage des coord curseur, zoom .. */ void DisplayUnitsMsg(); /* Handlers for block commands */ @@ -286,6 +284,9 @@ public: void OnSockRequest( wxSocketEvent& evt ); void OnSockRequestServer( wxSocketEvent& evt ); + virtual void LoadSettings(); + virtual void SaveSettings(); + DECLARE_EVENT_TABLE(); }; diff --git a/kicad/buildmnu.cpp b/kicad/buildmnu.cpp index ac8a74e2fc..c5d48661d6 100644 --- a/kicad/buildmnu.cpp +++ b/kicad/buildmnu.cpp @@ -17,93 +17,70 @@ /*****************************************************************************/ BEGIN_EVENT_TABLE( WinEDA_MainFrame, WinEDA_BasicFrame ) -/*****************************************************************************/ /* Window events */ EVT_SIZE( WinEDA_MainFrame::OnSize ) EVT_CLOSE( WinEDA_MainFrame::OnCloseWindow ) /* Sash drag events */ - EVT_SASH_DRAGGED( ID_LEFT_FRAME, - WinEDA_MainFrame::OnSashDrag ) - EVT_SASH_DRAGGED( ID_BOTTOM_FRAME, - WinEDA_MainFrame::OnSashDrag ) - EVT_SASH_DRAGGED( ID_MAIN_COMMAND, - WinEDA_MainFrame::OnSashDrag ) + EVT_SASH_DRAGGED( ID_LEFT_FRAME, WinEDA_MainFrame::OnSashDrag ) + EVT_SASH_DRAGGED( ID_BOTTOM_FRAME, WinEDA_MainFrame::OnSashDrag ) + EVT_SASH_DRAGGED( ID_MAIN_COMMAND, WinEDA_MainFrame::OnSashDrag ) /* Toolbar events */ - EVT_TOOL( ID_NEW_PROJECT, - WinEDA_MainFrame::Process_Files ) - EVT_TOOL( ID_LOAD_PROJECT, - WinEDA_MainFrame::Process_Files ) - EVT_TOOL( ID_SAVE_PROJECT, - WinEDA_MainFrame::Process_Files ) - EVT_TOOL( ID_SAVE_AND_ZIP_FILES, - WinEDA_MainFrame::Process_Files ) + EVT_TOOL( ID_NEW_PROJECT, WinEDA_MainFrame::OnLoadProject ) + EVT_TOOL( ID_LOAD_PROJECT, WinEDA_MainFrame::OnLoadProject ) + EVT_TOOL( ID_SAVE_PROJECT, WinEDA_MainFrame::OnSaveProject ) + EVT_TOOL( ID_SAVE_AND_ZIP_FILES, WinEDA_MainFrame::OnArchiveFiles ) /* Menu events */ - EVT_MENU( ID_SAVE_PROJECT, - WinEDA_MainFrame::Process_Files ) - EVT_MENU( ID_EXIT, - WinEDA_MainFrame::Process_Special_Functions ) - EVT_MENU( ID_TO_EDITOR, - WinEDA_MainFrame::Process_Fct ) + EVT_MENU( ID_SAVE_PROJECT, WinEDA_MainFrame::OnSaveProject ) + EVT_MENU( ID_EXIT, WinEDA_MainFrame::OnExit ) + EVT_MENU( ID_TO_EDITOR, WinEDA_MainFrame::OnOpenTextEditor ) EVT_MENU( ID_BROWSE_AN_SELECT_FILE, - WinEDA_MainFrame::Process_Fct ) + WinEDA_MainFrame::OnOpenFileInTextEditor ) EVT_MENU( ID_SELECT_PREFERED_EDITOR, - WinEDA_MainFrame::Process_Preferences ) + WinEDA_MainFrame::OnSelectPreferredEditor ) EVT_MENU( ID_SELECT_DEFAULT_PDF_BROWSER, - WinEDA_MainFrame::Process_Preferences ) + WinEDA_MainFrame::OnSelectDefaultPdfBrowser ) EVT_MENU( ID_SELECT_PREFERED_PDF_BROWSER, - WinEDA_MainFrame::Process_Preferences ) + WinEDA_MainFrame::OnSelectPreferredPdfBrowser ) EVT_MENU( ID_SELECT_PREFERED_PDF_BROWSER_NAME, - WinEDA_MainFrame::Process_Preferences ) - EVT_MENU( ID_SAVE_AND_ZIP_FILES, - WinEDA_MainFrame::Process_Files ) - EVT_MENU( ID_READ_ZIP_ARCHIVE, - WinEDA_MainFrame::Process_Files ) - EVT_MENU( ID_PROJECT_TREE_REFRESH, - WinEDA_MainFrame::OnRefresh ) - EVT_MENU( ID_PREFERENCES_FONT_INFOSCREEN, - WinEDA_MainFrame::Process_Preferences ) - EVT_MENU( ID_GENERAL_HELP, - WinEDA_MainFrame::GetKicadHelp ) - EVT_MENU( ID_KICAD_ABOUT, - WinEDA_MainFrame::GetKicadAbout ) + WinEDA_MainFrame::OnSelectPreferredPdfBrowser ) + EVT_MENU( ID_SAVE_AND_ZIP_FILES, WinEDA_MainFrame::OnArchiveFiles ) + EVT_MENU( ID_READ_ZIP_ARCHIVE, WinEDA_MainFrame::OnUnarchiveFiles ) + EVT_MENU( ID_PROJECT_TREE_REFRESH, WinEDA_MainFrame::OnRefresh ) + EVT_MENU( ID_PREFERENCES_FONT_INFOSCREEN, WinEDA_MainFrame::OnSelectFont ) + EVT_MENU( ID_GENERAL_HELP, WinEDA_MainFrame::GetKicadHelp ) + EVT_MENU( ID_KICAD_ABOUT, WinEDA_MainFrame::GetKicadAbout ) /* Range menu events */ - EVT_MENU_RANGE( ID_LANGUAGE_CHOICE, - ID_LANGUAGE_CHOICE_END, + EVT_MENU_RANGE( ID_LANGUAGE_CHOICE, ID_LANGUAGE_CHOICE_END, WinEDA_MainFrame::SetLanguage ) - EVT_MENU_RANGE( wxID_FILE1, wxID_FILE9, - WinEDA_MainFrame::OnFileHistory ) + EVT_MENU_RANGE( wxID_FILE1, wxID_FILE9, WinEDA_MainFrame::OnFileHistory ) /* Button events */ - EVT_BUTTON( ID_TO_PCB, - WinEDA_MainFrame::Process_Fct ) - EVT_BUTTON( ID_TO_CVPCB, - WinEDA_MainFrame::Process_Fct ) - EVT_BUTTON( ID_TO_EESCHEMA, - WinEDA_MainFrame::Process_Fct ) - EVT_BUTTON( ID_TO_GERBVIEW, - WinEDA_MainFrame::Process_Fct ) + EVT_BUTTON( ID_TO_PCB, WinEDA_MainFrame::OnRunPcbNew ) + EVT_BUTTON( ID_TO_CVPCB, WinEDA_MainFrame::OnRunCvpcb ) + EVT_BUTTON( ID_TO_EESCHEMA, WinEDA_MainFrame::OnRunEeschema ) + EVT_BUTTON( ID_TO_GERBVIEW, WinEDA_MainFrame::OnRunGerbview ) + EVT_UPDATE_UI( ID_SELECT_DEFAULT_PDF_BROWSER, + WinEDA_MainFrame::OnUpdateDefaultPdfBrowser ) + EVT_UPDATE_UI( ID_SELECT_PREFERED_PDF_BROWSER, + WinEDA_MainFrame::OnUpdatePreferredPdfBrowser ) #ifdef KICAD_PYTHON - EVT_BUTTON( ID_RUN_PYTHON, WinEDA_MainFrame::Process_Fct ) + EVT_BUTTON( ID_RUN_PYTHON, WinEDA_MainFrame::OnRunPythonScript ) #endif -/*****************************************************************************/ END_EVENT_TABLE() -/*****************************************************************************/ /** * @brief TODO */ -/*****************************************************************************/ void WinEDA_MainFrame::ReCreateMenuBar() -/*****************************************************************************/ { wxMenuItem *item; wxMenuBar *menuBar = GetMenuBar(); @@ -119,20 +96,20 @@ void WinEDA_MainFrame::ReCreateMenuBar() wxMenu* filesMenu = new wxMenu; // Open project - item = new wxMenuItem( filesMenu, ID_LOAD_PROJECT, _( "&Open" ), + item = new wxMenuItem( filesMenu, ID_LOAD_PROJECT, _( "&Open\tCtrl+O" ), _( "Open an existing project" ) ); item->SetBitmap( open_project_xpm ); filesMenu->Append( item ); // New project - item = new wxMenuItem( filesMenu, ID_NEW_PROJECT, _( "&New" ), + item = new wxMenuItem( filesMenu, ID_NEW_PROJECT, _( "&New\tCtrl+N" ), _( "Start a new project" ) ); item->SetBitmap( new_project_xpm ); filesMenu->Append( item ); // Save project - item = new wxMenuItem( filesMenu, ID_SAVE_PROJECT, _( "&Save" ), + item = new wxMenuItem( filesMenu, ID_SAVE_PROJECT, _( "&Save\tCtrl+S" ), _( "Save current project" ) ); item->SetBitmap( save_project_xpm ); filesMenu->Append( item ); @@ -142,15 +119,13 @@ void WinEDA_MainFrame::ReCreateMenuBar() // Archive project - item = new wxMenuItem( filesMenu, ID_SAVE_AND_ZIP_FILES, - _( "&Archive" ), + item = new wxMenuItem( filesMenu, ID_SAVE_AND_ZIP_FILES, _( "&Archive" ), _( "Archive project files in zip archive" ) ); item->SetBitmap( zip_xpm ); filesMenu->Append( item ); // Unarchive project - item = new wxMenuItem( filesMenu, ID_READ_ZIP_ARCHIVE, - _( "&Unarchive" ), + item = new wxMenuItem( filesMenu, ID_READ_ZIP_ARCHIVE, _( "&Unarchive" ), _( "Unarchive project files from zip file" ) ); item->SetBitmap( unzip_xpm ); filesMenu->Append( item ); @@ -278,9 +253,7 @@ void WinEDA_MainFrame::ReCreateMenuBar() /** * @brief TODO */ -/*****************************************************************************/ void WinEDA_MainFrame::RecreateBaseHToolbar() -/*****************************************************************************/ { // Check if toolbar is not already set if( m_HToolBar != NULL ) @@ -290,61 +263,36 @@ void WinEDA_MainFrame::RecreateBaseHToolbar() m_HToolBar = new WinEDA_Toolbar( TOOLBAR_MAIN, this, ID_H_TOOLBAR, TRUE ); SetToolBar( m_HToolBar ); - // Set up toolbar - m_HToolBar->AddTool( ID_NEW_PROJECT, // Entry ID - wxBitmap( new_project_xpm ), // XPM Bitmap - wxNullBitmap, - FALSE, - -1, -1, - (wxObject*) NULL, - _( "Start a new project" ) ); // Tooltip - + m_HToolBar->AddTool( ID_NEW_PROJECT, wxBitmap( new_project_xpm ), + wxNullBitmap, FALSE, -1, -1, (wxObject*) NULL, + _( "Start a new project" ) ); // Load project - m_HToolBar->AddTool( ID_LOAD_PROJECT, // Entry ID - wxBitmap( open_project_xpm ), // XPM Bitmap - wxNullBitmap, - FALSE, - -1, -1, (wxObject*) NULL, - _( "Load existing project" ) ); // Tooltip - + m_HToolBar->AddTool( ID_LOAD_PROJECT, wxBitmap( open_project_xpm ), + wxNullBitmap, FALSE, -1, -1, (wxObject*) NULL, + _( "Load existing project" ) ); // Save project - m_HToolBar->AddTool( ID_SAVE_PROJECT, // Entry ID - wxBitmap( save_project_xpm ), // XPM Bitmap - wxNullBitmap, - FALSE, - -1, -1, - (wxObject*) NULL, - _( "Save current project" ) ); // Tooltip - + m_HToolBar->AddTool( ID_SAVE_PROJECT, wxBitmap( save_project_xpm ), + wxNullBitmap, FALSE, -1, -1, (wxObject*) NULL, + _( "Save current project" ) ); // Separator m_HToolBar->AddSeparator(); - // Save and archive files - m_HToolBar->AddTool( ID_SAVE_AND_ZIP_FILES, // Entry ID - wxBitmap( zip_xpm ), // XPM Bitmap - wxNullBitmap, - FALSE, - -1, -1, (wxObject*) NULL, + m_HToolBar->AddTool( ID_SAVE_AND_ZIP_FILES, wxBitmap( zip_xpm ), + wxNullBitmap, FALSE, -1, -1, (wxObject*) NULL, _( "Archive all project files" ) ); // Tooltip - // Separator m_HToolBar->AddSeparator(); - // Refresh project tree - m_HToolBar->AddTool( ID_PROJECT_TREE_REFRESH, // Entry ID - wxBitmap( reload_xpm ), // XPM Bitmap - wxNullBitmap, - FALSE, - -1, -1, (wxObject*) NULL, - _( "Refresh project tree" ) ); // Tooltip - + m_HToolBar->AddTool( ID_PROJECT_TREE_REFRESH, wxBitmap( reload_xpm ), + wxNullBitmap, FALSE, -1, -1, (wxObject*) NULL, + _( "Refresh project tree" ) ); m_HToolBar->Realize(); // Create m_HToolBar } diff --git a/kicad/commandframe.cpp b/kicad/commandframe.cpp index c2769930ce..23884bcdfe 100644 --- a/kicad/commandframe.cpp +++ b/kicad/commandframe.cpp @@ -8,8 +8,6 @@ #include "kicad.h" #include "macros.h" -#define BITMAP wxBitmap - // ---------------------------------------------------------------------------- // resources // ---------------------------------------------------------------------------- @@ -54,30 +52,29 @@ void WinEDA_CommandFrame::CreateCommandToolbar( void ) m_ButtonLastPosition.x = 20; m_ButtonLastPosition.y = 20; - btn = new wxBitmapButton( this, ID_TO_EESCHEMA, BITMAP( icon_eeschema_xpm ) ); + btn = new wxBitmapButton( this, ID_TO_EESCHEMA, wxBitmap( icon_eeschema_xpm ) ); btn->SetToolTip( _( "EESchema (Schematic editor)" ) ); AddFastLaunch( btn ); - btn = new wxBitmapButton( this, ID_TO_CVPCB, BITMAP( icon_cvpcb_xpm ) ); + btn = new wxBitmapButton( this, ID_TO_CVPCB, wxBitmap( icon_cvpcb_xpm ) ); btn->SetToolTip( _( "CVpcb (Components to modules)" ) ); AddFastLaunch( btn ); - btn = new wxBitmapButton( this, ID_TO_PCB, BITMAP( a_icon_pcbnew_xpm ) ); + btn = new wxBitmapButton( this, ID_TO_PCB, wxBitmap( a_icon_pcbnew_xpm ) ); btn->SetToolTip( _( "PCBnew (PCB editor)" ) ); AddFastLaunch( btn ); - btn = new wxBitmapButton( this, ID_TO_GERBVIEW, BITMAP( icon_gerbview_xpm ) ); + btn = new wxBitmapButton( this, ID_TO_GERBVIEW, wxBitmap( icon_gerbview_xpm ) ); btn->SetToolTip( _( "GerbView (Gerber viewer)" ) ); AddFastLaunch( btn ); // Set up toolbar - - #ifdef KICAD_PYTHON - btn = new wxBitmapButton( this, ID_RUN_PYTHON, BITMAP( icon_python_xpm ) ); +#ifdef KICAD_PYTHON + btn = new wxBitmapButton( this, ID_RUN_PYTHON, wxBitmap( icon_python_xpm ) ); btn->SetToolTip( _( "Run Python Script" ) ); AddFastLaunch( btn ); - #endif +#endif } diff --git a/kicad/files-io.cpp b/kicad/files-io.cpp index 8f15e3c69b..d6b9ade5f7 100644 --- a/kicad/files-io.cpp +++ b/kicad/files-io.cpp @@ -12,22 +12,20 @@ #include #include #include +#include #include "common.h" #include "bitmaps.h" #include "confirm.h" #include "gestfich.h" - -#include "protos.h" #include "id.h" #include "kicad.h" #include "prjconfig.h" -#define ZIP_EXT wxT( ".zip" ) -#define ZIP_MASK wxT( "*.zip" ) +static const wxString ZipFileExtension( wxT( "zip" ) ); +static const wxString ZipFileWildcard( wxT( "Zip file (*.zip) | *.zip" ) ); -static void Create_NewPrj_Config( const wxString PrjFullFileName ); void WinEDA_MainFrame::OnFileHistory( wxCommandEvent& event ) { @@ -37,161 +35,40 @@ void WinEDA_MainFrame::OnFileHistory( wxCommandEvent& event ) if( fn != wxEmptyString ) { - m_PrjFileName = fn; - Load_Prj_Config(); + wxCommandEvent cmd( 0, wxID_ANY ); + m_ProjectFileName = fn; + OnLoadProject( cmd ); } ReCreateMenuBar(); } -/***********************************************************/ -void WinEDA_MainFrame::Process_Files( wxCommandEvent& event ) -/***********************************************************/ - -/* Gestion generale des commandes de sauvegarde - */ +void WinEDA_MainFrame::OnUnarchiveFiles( wxCommandEvent& event ) { - int id = event.GetId(); - wxString path = wxGetCwd(); + wxFileName fn = m_ProjectFileName; + fn.SetExt( ZipFileExtension ); - wxString fullfilename; - bool IsNew = FALSE; + wxFileDialog dlg( this, _( "Unzip Project" ), fn.GetPath(), + fn.GetFullName(), ZipFileWildcard, + wxFD_OPEN | wxFD_FILE_MUST_EXIST ); - switch( id ) - { - case ID_SAVE_PROJECT: /* Update project File */ - Save_Prj_Config(); - break; - - case ID_NEW_PROJECT: - IsNew = TRUE; - - case ID_LOAD_PROJECT: - SetLastProject( m_PrjFileName ); - fullfilename = EDA_FileSelector( IsNew ? _( "Create Project file:" ) : - _( "Open Project file:" ), - path, /* Chemin par defaut */ - wxEmptyString, /* nom fichier par defaut */ - g_Prj_Config_Filename_ext, /* extension par defaut */ - wxT( "*" ) + g_Prj_Config_Filename_ext, /* Masque d'affichage */ - this, - IsNew ? wxFD_SAVE : wxFD_OPEN, - FALSE - ); - if( fullfilename.IsEmpty() ) - break; - - ChangeFileNameExt( fullfilename, g_Prj_Config_Filename_ext ); - m_PrjFileName = fullfilename; - if( IsNew ) - Create_NewPrj_Config( m_PrjFileName ); - SetLastProject( m_PrjFileName ); - Load_Prj_Config(); - break; - - - case ID_SAVE_AND_ZIP_FILES: - CreateZipArchive( wxEmptyString ); - break; - - case ID_READ_ZIP_ARCHIVE: - UnZipArchive( wxEmptyString ); - break; - - default: - DisplayError( this, wxT( "WinEDA_MainFrame::Process_Files error" ) ); - break; - } -} - - -/**************************************************************/ -static void Create_NewPrj_Config( const wxString PrjFullFileName ) -/**************************************************************/ - -/* Cree un nouveau fichier projet a partir du modele - */ -{ - wxString msg; - - // Init default config filename - g_Prj_Config_LocalFilename.Empty(); - - g_Prj_Default_Config_FullFilename = ReturnKicadDatasPath() + - wxT( "template/kicad" ) + g_Prj_Config_Filename_ext; - - if( !wxFileExists( g_Prj_Default_Config_FullFilename ) ) - { - msg = _( "Template file non found " ) + g_Prj_Default_Config_FullFilename; - DisplayInfo( NULL, msg ); - } - else - { - if( wxFileExists( PrjFullFileName ) ) - { - msg = _( "File " ) + PrjFullFileName - + _( " exists! OK to continue?" ); - if( IsOK( NULL, msg ) ) - { - wxCopyFile( g_Prj_Default_Config_FullFilename, - PrjFullFileName ); - } - } - } - - g_SchematicRootFileName = wxFileNameFromPath( PrjFullFileName ); - ChangeFileNameExt( g_SchematicRootFileName, g_SchExtBuffer ); - - g_BoardFileName = wxFileNameFromPath( PrjFullFileName ); - ChangeFileNameExt( g_BoardFileName, g_BoardExtBuffer ); - - wxGetApp().WriteProjectConfig( PrjFullFileName, wxT( "/general" ), - CfgParamList ); -} - - -/**********************************************************************/ -void WinEDA_MainFrame::UnZipArchive( const wxString FullFileName ) -/**********************************************************************/ - -/* Lit un fichier archive .zip et le decompresse dans le repertoire courant - */ -{ - wxString filename = FullFileName; - wxString msg; - wxString old_cwd = wxGetCwd(); - - if( filename.IsEmpty() ) - filename = EDA_FileSelector( _( "Unzip Project:" ), - wxEmptyString, /* Chemin par defaut */ - wxEmptyString, /* nom fichier par defaut */ - ZIP_EXT, /* extension par defaut */ - ZIP_MASK, /* Masque d'affichage */ - this, - wxFD_OPEN, - TRUE - ); - if( filename.IsEmpty() ) + if( dlg.ShowModal() == wxID_CANCEL ) return; - msg = _( "\nOpen " ) + filename + wxT( "\n" ); - PrintMsg( msg ); + PrintMsg( _( "\nOpen " ) + dlg.GetPath() + wxT( "\n" ) ); - wxString target_dirname = wxDirSelector( _( "Target Directory" ), - wxEmptyString, 0, - wxDefaultPosition, this ); - if( target_dirname.IsEmpty() ) + wxDirDialog dirDlg( this, _( "Target Directory" ), fn.GetPath(), + wxDD_DEFAULT_STYLE | wxDD_DIR_MUST_EXIST ); + + if( dirDlg.ShowModal() == wxID_CANCEL ) return; - wxSetWorkingDirectory( target_dirname ); - msg = _( "Unzip in " ) + target_dirname + wxT( "\n" ); - PrintMsg( msg ); + wxSetWorkingDirectory( dirDlg.GetPath() ); + PrintMsg( _( "Unzipping project in " ) + dirDlg.GetPath() + wxT( "\n" ) ); wxFileSystem zipfilesys; zipfilesys.AddHandler( new wxZipFSHandler ); - - filename += wxT( "#zip:" ); - zipfilesys.ChangePathTo( filename ); + zipfilesys.ChangePathTo( dlg.GetPath() + wxT( "#zip:" ) ); wxFSFile* zipfile = NULL; wxString localfilename = zipfilesys.FindFirst( wxT( "*.*" ) ); @@ -207,8 +84,7 @@ void WinEDA_MainFrame::UnZipArchive( const wxString FullFileName ) wxString unzipfilename = localfilename.AfterLast( ':' ); - msg = _( "Extract file " ) + unzipfilename; - PrintMsg( msg ); + PrintMsg( _( "Extract file " ) + unzipfilename ); wxInputStream* stream = zipfile->GetStream(); @@ -229,74 +105,56 @@ void WinEDA_MainFrame::UnZipArchive( const wxString FullFileName ) PrintMsg( wxT( "** end **\n" ) ); - wxSetWorkingDirectory( old_cwd ); + wxSetWorkingDirectory( fn.GetPath() ); } -/********************************************************************/ -void WinEDA_MainFrame::CreateZipArchive( const wxString FullFileName ) -/********************************************************************/ +void WinEDA_MainFrame::OnArchiveFiles( wxCommandEvent& event ) { - wxString filename = FullFileName; - wxString zip_file_fullname; - wxString msg; - wxString curr_path = wxGetCwd(); + size_t i; + wxFileName fileName = m_ProjectFileName; + wxString oldPath = wxGetCwd(); - if( filename.IsEmpty() ) - { - filename = m_PrjFileName; - ChangeFileNameExt( filename, wxT( ".zip" ) ); - filename = EDA_FileSelector( _( "Archive Project files:" ), - wxEmptyString, /* Chemin par defaut */ - filename, /* nom fichier par defaut */ - ZIP_EXT, /* extension par defaut */ - ZIP_MASK, /* Masque d'affichage */ - this, - wxFD_SAVE, - FALSE - ); - } - if( filename.IsEmpty() ) + fileName.SetExt( wxT( ".zip" ) ); + + wxFileDialog dlg( this, _( "Archive Project Files" ), + fileName.GetPath(), fileName.GetFullName(), + ZipFileWildcard, wxFD_SAVE | wxFD_OVERWRITE_PROMPT ); + + if( dlg.ShowModal() == wxID_CANCEL ) return; - wxFileName zip_name( filename ); - - zip_file_fullname = zip_name.GetFullName(); - AddDelimiterString( zip_file_fullname ); + wxFileName zip = dlg.GetPath(); /* Liste des extensions des fichiers à sauver */ - static const wxChar* Ext_to_arch[] = { + static const wxChar* extList[] = { wxT( "*.sch" ), wxT( "*.lib" ), wxT( "*.cmp" ), wxT( "*.brd" ), wxT( "*.net" ), wxT( "*.pro" ), wxT( "*.pho" ), wxT( "*.py" ), wxT( "*.pdf" ), wxT( "*.txt" ), NULL }; - int ii = 0; + wxString cmd = wxT( "-O " ) + zip.GetPathSeparator() + zip.GetFullName(); - wxString zip_cmd = wxT( "-O " ) + zip_file_fullname; - filename = wxFindFirstFile( Ext_to_arch[ii] ); + wxDir dir( wxT( "." ) + zip.GetPathSeparator() ); - while( !filename.IsEmpty() ) + if( !dir.IsOpened() ) + return; + + wxString f; + + for( i = 0; extList[i] != 0; i++ ) { - wxFileName name( filename ); + bool cont = dir.GetFirst( &f, extList[i] ); - wxString fullname = name.GetFullName(); - AddDelimiterString( fullname ); - zip_cmd += wxT( " " ) + fullname; - - msg = _( "Compress file " ) + fullname + wxT( "\n" ); - PrintMsg( msg ); - - filename = wxFindNextFile(); - while( filename.IsEmpty() ) + while( cont ) { - ii++; - if( Ext_to_arch[ii] ) - filename = wxFindFirstFile( Ext_to_arch[ii] ); - else - break; + wxFileName fn( f ); + + cmd += wxT( " ." ) + zip.GetPathSeparator() + fn.GetFullName(); + PrintMsg( _( "Compress file " ) + fn.GetFullName() + wxT( "\n" ) ); + cont = dir.GetNext( &f ); } } @@ -305,14 +163,13 @@ void WinEDA_MainFrame::CreateZipArchive( const wxString FullFileName ) #else #define ZIPPER wxT( "minizip" ) #endif - if( ExecuteFile( this, ZIPPER, zip_cmd ) >= 0 ) + if( ExecuteFile( this, ZIPPER, cmd ) >= 0 ) { - msg = _( "\nCreate Zip Archive " ) + zip_file_fullname; - PrintMsg( msg ); + PrintMsg( _( "\nCreate Zip Archive " ) + zip.GetFullName() ); PrintMsg( wxT( "\n** end **\n" ) ); } else PrintMsg( wxT( "Minizip command error, abort\n" ) ); - wxSetWorkingDirectory( curr_path ); + wxSetWorkingDirectory( oldPath ); } diff --git a/kicad/kicad.cpp b/kicad/kicad.cpp index 37879cb5cb..5b2744a39e 100644 --- a/kicad/kicad.cpp +++ b/kicad/kicad.cpp @@ -11,8 +11,6 @@ #pragma implementation #endif -#define MAIN - #include "fctsys.h" #include "appl_wxstruct.h" #include "common.h" @@ -32,13 +30,6 @@ #include #endif -/* Global definitions for Kicad */ -wxString g_Main_Title = wxT( "KiCad" ); -wxString g_SchematicRootFileName; -wxString g_BoardFileName; - - -/* Export functions */ /* Import functions */ char* GetFileName( char* FullPathName ); @@ -384,27 +375,35 @@ bool WinEDA_App::OnInit() GetSettings(); // read current setup /* Make nameless project translatable */ - wxString project_ext = _T( ".pro" ); - wxString nameless_project = _( "noname" ) + project_ext; + wxFileName namelessProject( wxGetCwd(), _( "noname" ), + + ProjectFileExtension ); frame = new WinEDA_MainFrame( NULL, wxT( "KiCad" ), wxPoint( 30, 20 ), wxSize( 600, 400 ) ); if( argc > 1 ) - frame->m_PrjFileName = argv[1]; + frame->m_ProjectFileName = argv[1]; else if( m_fileHistory.GetCount() ) { - frame->m_PrjFileName = m_fileHistory.GetHistoryFile( 0 ); - if( !wxFileName::FileExists( frame->m_PrjFileName ) ) + frame->m_ProjectFileName = m_fileHistory.GetHistoryFile( 0 ); + if( !frame->m_ProjectFileName.FileExists() ) m_fileHistory.RemoveFileFromHistory( 0 ); + else + { + wxCommandEvent cmd( 0, wxID_FILE1 ); + frame->OnFileHistory( cmd ); + } } - if( !wxFileName::FileExists( frame->m_PrjFileName ) ) - frame->m_PrjFileName = nameless_project; + if( !frame->m_ProjectFileName.FileExists() ) + { + wxCommandEvent cmd( 0, wxID_ANY ); + frame->m_ProjectFileName = namelessProject; + frame->OnLoadProject( cmd ); + } - wxString Title = g_Main_Title + wxT( " " ) + GetBuildVersion(); - Title += wxT( " " ) + frame->m_PrjFileName; - frame->SetTitle( Title ); + frame->SetTitle( GetTitle() + wxT( " " ) + GetBuildVersion() + + wxT( " " ) + frame->m_ProjectFileName.GetFullPath() ); frame->ReCreateMenuBar(); frame->RecreateBaseHToolbar(); @@ -414,7 +413,10 @@ bool WinEDA_App::OnInit() /* Splash screen logo */ #ifdef USE_SPLASH_IMAGE wxBitmap bmp; - if( bmp.LoadFile( m_BinDir + _T( "logokicad.png" ), wxBITMAP_TYPE_PNG ) ) + wxString binDir = GetTraits()->GetStandardPaths().GetExecutablePath() + + wxFileName::GetPathSeparator(); + + if( bmp.LoadFile( binDir + _T( "logokicad.png" ), wxBITMAP_TYPE_PNG ) ) { wxSplashScreen* splash = new wxSplashScreen( splash_screen, wxSPLASH_CENTRE_ON_SCREEN | wxSPLASH_TIMEOUT, @@ -431,11 +433,6 @@ bool WinEDA_App::OnInit() frame->Raise(); - if( wxFileExists( frame->m_PrjFileName ) ) - { - frame->Load_Prj_Config(); - } - #ifdef KICAD_PYTHON PyHandler::GetInstance()->AddToModule( wxT( "kicad" ), &py_kicad_init ); PyHandler::GetInstance()->AddToModule( wxT( "common" ), &py_common_init ); diff --git a/kicad/kicad.h b/kicad/kicad.h index c9533a4e4a..84356f92dd 100644 --- a/kicad/kicad.h +++ b/kicad/kicad.h @@ -9,20 +9,22 @@ #include #endif -#include #include + +#include #include +#include #include "wxstruct.h" +#include "appl_wxstruct.h" -/* Message de presentation */ -extern wxString g_Main_Title; - class WinEDA_CommandFrame; class WinEDA_TreePrj; class WinEDA_PrjFrame; + + /*******************************************/ /* classe pour la Fenetre generale de kicad*/ /*******************************************/ @@ -40,7 +42,9 @@ public: wxSashLayoutWindow* m_BottomWin; wxTextCtrl* m_DialogWin; WinEDA_Toolbar* m_VToolBar; // Verticam Toolbar (not used) - wxString m_PrjFileName; + wxString m_BoardFileName; + wxString m_SchematicRootFileName; + wxFileName m_ProjectFileName; int m_LeftWin_Width; int m_CommandWin_Height; @@ -53,31 +57,52 @@ public: ~WinEDA_MainFrame(); - void OnCloseWindow( wxCloseEvent& Event ); - void OnSize( wxSizeEvent& event ); - void OnPaint( wxPaintEvent& event ); - void ReDraw( wxDC* DC ); - void OnSashDrag( wxSashEvent& event ); - void Load_Prj_Config(); - void Save_Prj_Config(); - void Process_Fct( wxCommandEvent& event ); - void OnFileHistory( wxCommandEvent& event ); - void Process_Files( wxCommandEvent& event ); - void Process_Config( wxCommandEvent& event ); - void Process_Special_Functions( wxCommandEvent& event ); - void Process_Preferences( wxCommandEvent& event ); - void ReCreateMenuBar(); - void RecreateBaseHToolbar(); - void PrintMsg( const wxString& text ); - void ClearMsg(); - void SetLanguage( wxCommandEvent& event ); - void OnRefresh( wxCommandEvent& event ); - - void CreateZipArchive( const wxString FullFileName ); - void UnZipArchive( const wxString FullFileName ); + void OnCloseWindow( wxCloseEvent& Event ); + void OnSize( wxSizeEvent& event ); + void OnPaint( wxPaintEvent& event ); + void ReDraw( wxDC* DC ); + void OnSashDrag( wxSashEvent& event ); + void OnLoadProject( wxCommandEvent& event ); + void OnSaveProject( wxCommandEvent& event ); + void OnArchiveFiles( wxCommandEvent& event ); + void OnUnarchiveFiles( wxCommandEvent& event ); + void OnRunPcbNew( wxCommandEvent& event ); + void OnRunCvpcb( wxCommandEvent& event ); + void OnRunEeschema( wxCommandEvent& event ); + void OnRunGerbview( wxCommandEvent& event ); #ifdef KICAD_PYTHON - void OnRefreshPy(); + void OnRunPythonScript( wxCommandEvent& event ); +#endif + + void OnOpenTextEditor( wxCommandEvent& event ); + void OnOpenFileInTextEditor( wxCommandEvent& event ); + void OnOpenFileInEditor( wxCommandEvent& event ); + + void OnFileHistory( wxCommandEvent& event ); + void OnExit( wxCommandEvent& event ); + void Process_Preferences( wxCommandEvent& event ); + void ReCreateMenuBar(); + void RecreateBaseHToolbar(); + void PrintMsg( const wxString& text ); + void ClearMsg(); + void SetLanguage( wxCommandEvent& event ); + void OnRefresh( wxCommandEvent& event ); + void OnSelectDefaultPdfBrowser( wxCommandEvent& event ); + void OnSelectPreferredPdfBrowser( wxCommandEvent& event ); + void OnSelectPreferredEditor( wxCommandEvent& event ); + void OnSelectFont( wxCommandEvent& event ); + + void OnUpdateDefaultPdfBrowser( wxUpdateUIEvent& event ); + void OnUpdatePreferredPdfBrowser( wxUpdateUIEvent& event ); + + void CreateNewProject( const wxString PrjFullFileName ); + + void LoadSettings(); + void SaveSettings(); + +#ifdef KICAD_PYTHON + void OnRefreshPy(); boost::python::object GetPrjName() const; @@ -250,6 +275,7 @@ public: public: static wxString GetFileExt( TreeFileType type ); + static wxString GetFileWildcard( TreeFileType type ); WinEDA_PrjFrame( WinEDA_MainFrame* parent, const wxPoint& pos, const wxSize& size ); @@ -348,23 +374,4 @@ private: int OnCompareItems( const wxTreeItemId& item1, const wxTreeItemId& item2 ); }; - -extern wxString g_SchematicRootFileName; -extern wxString g_BoardFileName; - -#ifdef MAIN -wxString g_SchExtBuffer( wxT( ".sch" ) ); -wxString g_BoardExtBuffer( wxT( ".brd" ) ); -wxString g_NetlistExtBuffer( wxT( ".net" ) ); -wxString g_GerberExtBuffer( wxT( ".pho" ) ); - -#else -extern wxString g_SchExtBuffer; -extern wxString g_BoardExtBuffer; -extern wxString g_NetlistExtBuffer; -extern wxString g_GerberExtBuffer; #endif - -#endif - -// vim: tabstop=4 : noexpandtab : diff --git a/kicad/mainframe.cpp b/kicad/mainframe.cpp index 120f15b3c2..ca8da2db78 100644 --- a/kicad/mainframe.cpp +++ b/kicad/mainframe.cpp @@ -15,28 +15,25 @@ #include "common.h" #include "confirm.h" #include "gestfich.h" - #include "bitmaps.h" -#include "protos.h" - #include "id.h" #include "kicad.h" -// Constructor -/*****************************************************************************/ +static const wxString TreeFrameWidthEntry( wxT( "LeftWinWidth" ) ); +static const wxString CommandFrameWidthEntry( wxT( "CommandWinWidth" ) ); + + WinEDA_MainFrame::WinEDA_MainFrame( wxWindow* parent, const wxString& title, const wxPoint& pos, const wxSize& size ) : WinEDA_BasicFrame( parent, KICAD_MAIN_FRAME, title, pos, size ) -/*****************************************************************************/ { wxString msg; wxString line; wxSize clientsize; - wxConfig* config = wxGetApp().m_EDA_Config; m_FrameName = wxT( "KicadFrame" ); m_VToolBar = NULL; @@ -46,13 +43,7 @@ WinEDA_MainFrame::WinEDA_MainFrame( wxWindow* parent, m_LeftWin_Width = 200; m_CommandWin_Height = 82; - GetSettings(); - - if( config ) - { - config->Read( wxT( "LeftWinWidth" ), &m_LeftWin_Width ); - config->Read( wxT( "CommandWinWidth" ), &m_CommandWin_Height ); - } + LoadSettings(); SetSize( m_FramePos.x, m_FramePos.y, m_FrameSize.x, m_FrameSize.y ); @@ -91,16 +82,12 @@ WinEDA_MainFrame::WinEDA_MainFrame( wxWindow* parent, m_DialogWin = new wxTextCtrl( m_BottomWin, ID_MAIN_DIALOG, wxEmptyString, wxDefaultPosition, wxDefaultSize, - wxTE_MULTILINE | - wxNO_BORDER | - wxTE_READONLY ); + wxTE_MULTILINE | wxNO_BORDER | wxTE_READONLY ); m_DialogWin->SetFont( *g_StdFont ); // m_CommandWin is the box with buttons which launch eechema, pcbnew ... - m_CommandWin = new WinEDA_CommandFrame( this, - ID_MAIN_COMMAND, - wxPoint( m_LeftWin_Width, - 0 ), + m_CommandWin = new WinEDA_CommandFrame( this, ID_MAIN_COMMAND, + wxPoint( m_LeftWin_Width, 0 ), wxSize( clientsize.x, m_CommandWin_Height ), wxNO_BORDER | wxSW_3D ); @@ -119,15 +106,6 @@ WinEDA_MainFrame::WinEDA_MainFrame( wxWindow* parent, WinEDA_MainFrame::~WinEDA_MainFrame() /*****************************************************************************/ { - wxConfig* config = wxGetApp().m_EDA_Config; - - if( config ) - { - m_LeftWin_Width = m_LeftWin->GetSize().x; - m_CommandWin_Height = m_CommandWin->GetSize().y; - config->Write( wxT( "LeftWinWidth" ), m_LeftWin_Width ); - config->Write( wxT( "CommandWinWidth" ), m_CommandWin_Height ); - } } @@ -214,7 +192,6 @@ void WinEDA_MainFrame::OnSize( wxSizeEvent& event ) m_CommandWin->SetDefaultSize( wxSize( -1, hsize.y ) ); m_BottomWin->SetDefaultSize( wxSize( -1, dy ) ); } - ; wxLayoutAlgorithm layout; layout.LayoutFrame( this ); @@ -231,7 +208,7 @@ void WinEDA_MainFrame::OnCloseWindow( wxCloseEvent& Event ) { int px, py; - SetLastProject( m_PrjFileName ); + SetLastProject( m_ProjectFileName.GetFullPath() ); if( !IsIconized() ) // save main frame position and size { @@ -277,120 +254,84 @@ void WinEDA_MainFrame::ReDraw( wxDC* DC ) } -/**********************************************************************/ -void WinEDA_MainFrame::Process_Special_Functions( wxCommandEvent& event ) -/**********************************************************************/ +void WinEDA_MainFrame::OnExit( wxCommandEvent& event ) { - int id = event.GetId(); - - switch( id ) - { - case ID_EXIT: - Close( TRUE ); - break; - - default: - DisplayError( this, - wxT( "WinEDA_MainFrame::Process_Special_Functions error" ) ); - break; - } + Close( true ); } -/********************************************************/ -void WinEDA_MainFrame::Process_Fct( wxCommandEvent& event ) -/*********************************************************/ +void WinEDA_MainFrame::OnRunPcbNew( wxCommandEvent& event ) { - int id = event.GetId(); - wxString FullFileName = m_PrjFileName; + wxFileName fn( m_ProjectFileName ); + fn.SetExt( BoardFileExtension ); + ExecuteFile( this, PCBNEW_EXE, QuoteFullPath( fn ) ); +} - switch( id ) - { - case ID_TO_PCB: - ChangeFileNameExt( FullFileName, g_BoardExtBuffer ); - AddDelimiterString( FullFileName ); - ExecuteFile( this, PCBNEW_EXE, FullFileName ); - break; +void WinEDA_MainFrame::OnRunCvpcb( wxCommandEvent& event ) +{ + wxFileName fn( m_ProjectFileName ); + fn.SetExt( NetlistFileExtension ); + ExecuteFile( this, CVPCB_EXE, QuoteFullPath( fn ) ); +} - case ID_TO_CVPCB: - ChangeFileNameExt( FullFileName, g_NetlistExtBuffer ); - AddDelimiterString( FullFileName ); - ExecuteFile( this, CVPCB_EXE, FullFileName ); - break; - case ID_TO_EESCHEMA: - ChangeFileNameExt( FullFileName, g_SchExtBuffer ); - AddDelimiterString( FullFileName ); - ExecuteFile( this, EESCHEMA_EXE, FullFileName ); - break; +void WinEDA_MainFrame::OnRunEeschema( wxCommandEvent& event ) +{ + wxFileName fn( m_ProjectFileName ); + fn.SetExt( SchematicFileExtension ); + wxLogDebug( wxT( "Loading EESchema with file <%s>." ), + fn.GetFullPath().c_str() ); + ExecuteFile( this, EESCHEMA_EXE, QuoteFullPath( fn ) ); +} - case ID_TO_GERBVIEW: - FullFileName = wxGetCwd() + STRING_DIR_SEP; - AddDelimiterString( FullFileName ); - ExecuteFile( this, GERBVIEW_EXE, FullFileName ); - break; - case ID_TO_EDITOR: - { - wxString editorname = GetEditorName(); - if( !editorname.IsEmpty() ) - ExecuteFile( this, editorname, wxEmptyString ); - } - break; +void WinEDA_MainFrame::OnRunGerbview( wxCommandEvent& event ) +{ + wxFileName fn( m_ProjectFileName ); + ExecuteFile( this, GERBVIEW_EXE, + fn.GetPath( wxPATH_GET_SEPARATOR | wxPATH_GET_VOLUME ) ); +} + + +void WinEDA_MainFrame::OnOpenTextEditor( wxCommandEvent& event ) +{ + wxString editorname = wxGetApp().GetEditorName(); + + if( !editorname.IsEmpty() ) + ExecuteFile( this, editorname, wxEmptyString ); +} + #ifdef KICAD_PYTHON - case ID_RUN_PYTHON: - { - wxString script = EDA_FileSelector( _( "Execute Python Script:" ), - wxEmptyString, /* Default path */ - wxEmptyString, /* default filename */ - wxT( ".py" ), /* default ext. */ - wxT( "*.py" ), /* mask for filename filter */ - this, - wxFD_OPEN, - FALSE - ); - if( script.IsEmpty() ) - break; - PyHandler::GetInstance()->RunScript( script ); - } - break; +void WinEDA_MainFrame::OnRunPythonScript( wxCommandEvent& event ) +{ + wxFileDialog dlg( this, _( "Execute Python Script" ), wxEmptyString, + wxEmptyString, _( "Python script (*.py)|*.py" ), + wxFD_OPEN | wxFD_FILE_MUST_EXIST ); + if( dlg.ShowModal() == wxID_CANCEL ) + return; + + PyHandler::GetInstance()->RunScript( dlg.GetPath() ); +} #endif - case ID_BROWSE_AN_SELECT_FILE: - { - wxString mask( wxT( "*" ) ), extension; + + +void WinEDA_MainFrame::OnOpenFileInTextEditor( wxCommandEvent& event ) +{ + wxString mask( wxT( "*" ) ); #ifdef __WINDOWS__ - mask += wxT( ".*" ); - extension = wxT( ".*" ); + mask += wxT( ".*" ); #endif - FullFileName = EDA_FileSelector( _( "Load file:" ), - wxGetCwd(), /* Default path */ - wxEmptyString, /* default filename */ - extension, /* default ext. */ - mask, /* mask for filename filter */ - this, - wxFD_OPEN, - TRUE - ); - if( !FullFileName.IsEmpty() ) - { - AddDelimiterString( FullFileName ); - wxString editorname = GetEditorName(); - if( !editorname.IsEmpty() ) - ExecuteFile( this, editorname, FullFileName ); - } - } - break; - break; + mask = _( "Text file (" ) + mask + wxT( ")|" ) + mask; - default: - DisplayError( this, - wxT( "WinEDA_MainFrame::Process_Fct Internal Error" ) ); - break; - } + wxFileDialog dlg( this, _( "Load File to Edit" ), wxGetCwd(), + wxEmptyString, mask,wxFD_OPEN ); + + if( dlg.GetPath() && wxGetApp().GetEditorName() ) + ExecuteFile( this, wxGetApp().GetEditorName(), dlg.GetPath() ); } @@ -411,12 +352,48 @@ void WinEDA_MainFrame::ClearMsg() } +/** + * Load Kicad main frame specific configuration settings. + * + * Don't forget to call this base method from any derived classes or the + * settings will not get loaded. + */ +void WinEDA_MainFrame::LoadSettings() +{ + wxASSERT( wxGetApp().m_EDA_Config != NULL ); + + wxConfig* cfg = wxGetApp().m_EDA_Config; + + WinEDA_BasicFrame::LoadSettings(); + cfg->Read( TreeFrameWidthEntry, &m_LeftWin_Width ); + cfg->Read( CommandFrameWidthEntry, &m_CommandWin_Height ); +} + + +/** + * Save Kicad main frame specific configuration settings. + * + * Don't forget to call this base method from any derived classes or the + * settings will not get saved. + */ +void WinEDA_MainFrame::SaveSettings() +{ + wxASSERT( wxGetApp().m_EDA_Config != NULL ); + + wxConfig* cfg = wxGetApp().m_EDA_Config; + + WinEDA_BasicFrame::SaveSettings(); + + cfg->Write( TreeFrameWidthEntry, m_LeftWin->GetSize().x ); + cfg->Write( CommandFrameWidthEntry, m_CommandWin->GetSize().y ); +} + #ifdef KICAD_PYTHON /*****************************************************************************/ void WinEDA_MainFrame::OnRefreshPy() /*****************************************************************************/ { - m_LeftWin->ReCreateTreePrj(); + m_LeftWin->ReCreateTreePrj(); } #endif diff --git a/kicad/preferences.cpp b/kicad/preferences.cpp index fb6a0b3459..505729ce4d 100644 --- a/kicad/preferences.cpp +++ b/kicad/preferences.cpp @@ -11,142 +11,112 @@ #include "common.h" #include "confirm.h" #include "gestfich.h" - #include "bitmaps.h" -#include "protos.h" #include "id.h" #include "kicad.h" #include -static bool ChoosePdfBrowser( WinEDA_MainFrame* parent_frame ) -/* routine to choose the prefered Pdf browser - */ +void WinEDA_MainFrame::OnUpdateDefaultPdfBrowser( wxUpdateUIEvent& event ) { - wxString mask( wxT( "*" ) ); + event.Check( wxGetApp().m_PdfBrowserIsDefault ); +} + + +void WinEDA_MainFrame::OnSelectDefaultPdfBrowser( wxCommandEvent& event ) +{ + wxGetApp().m_PdfBrowserIsDefault = true; + wxGetApp().WritePdfBrowserInfos(); +} + + +void WinEDA_MainFrame::OnUpdatePreferredPdfBrowser( wxUpdateUIEvent& event ) +{ + event.Check( !wxGetApp().m_PdfBrowserIsDefault ); +} + + +void WinEDA_MainFrame::OnSelectPreferredPdfBrowser( wxCommandEvent& event ) +{ + bool select = event.GetId() == ID_SELECT_PREFERED_PDF_BROWSER_NAME; + + if( !wxGetApp().m_PdfBrowser || select ) + { + if( !select ) + DisplayError( this, _( "You must choose a PDF viewer before use " \ + "this option" ) ); + } + + wxString wildcard( wxT( "*" ) ); #ifdef __WINDOWS__ - mask += wxT( ".exe" ); + wildcard += wxT( ".exe" ); #endif + wildcard = _( "Executable files (" ) + wildcard + wxT( ")|" ) + wildcard; + wxGetApp().ReadPdfBrowserInfos(); - wxString FullFileName = wxGetApp().m_PdfBrowser; - FullFileName = EDA_FileSelector( _( "Prefered Pdf Browser:" ), - wxPathOnly( FullFileName ), /* Default path */ - FullFileName, /* default filename */ - wxEmptyString, /* default filename extension */ - mask, /* filter for filename list */ - parent_frame, /* parent frame */ - wxFD_OPEN, /* wxFD_SAVE, wxFD_OPEN ..*/ - TRUE /* true = keep the current path */ - ); - if( !FullFileName.IsEmpty() && (wxGetApp().m_PdfBrowser != FullFileName) ) - { - wxGetApp().m_PdfBrowser = FullFileName; - wxGetApp().WritePdfBrowserInfos(); - return TRUE; - } - return FALSE; + wxFileName fn = wxGetApp().m_PdfBrowser; + wxFileDialog dlg( this, _( "Select Preferred Pdf Browser" ), fn.GetPath(), + fn.GetFullName(), wildcard, + wxFD_OPEN | wxFD_FILE_MUST_EXIST ); + + if( dlg.ShowModal() == wxID_CANCEL ) + return; + + wxGetApp().m_PdfBrowser = dlg.GetPath(); + wxGetApp().m_PdfBrowserIsDefault = wxGetApp().m_PdfBrowser.IsEmpty(); + wxGetApp().WritePdfBrowserInfos(); } -/****************************************************************/ -void WinEDA_MainFrame::Process_Preferences( wxCommandEvent& event ) -/*****************************************************************/ +void WinEDA_MainFrame::OnSelectPreferredEditor( wxCommandEvent& event ) { - int id = event.GetId(); - wxString FullFileName; - wxString mask( wxT( "*" ) ); + wxFileName fn = wxGetApp().m_EditorName; + wxString wildcard( wxT( "*" ) ); #ifdef __WINDOWS__ - mask += wxT( ".exe" ); + wildcard += wxT( ".exe" ); #endif - switch( id ) + wildcard = _( "Executable file (" ) + wildcard + wxT( ")|" ) + wildcard; + + wxFileDialog dlg( this, _( "Select Prefered Editor" ), fn.GetPath(), + fn.GetFullName(), wildcard, + wxFD_OPEN | wxFD_FILE_MUST_EXIST ); + + if( dlg.ShowModal() == wxID_CANCEL ) + return; + + wxASSERT( wxGetApp().m_EDA_CommonConfig ); + + wxConfig* cfg = wxGetApp().m_EDA_CommonConfig; + wxGetApp().m_EditorName = dlg.GetPath(); + cfg->Write( wxT( "Editor" ), wxGetApp().m_EditorName ); +} + + +void WinEDA_MainFrame::OnSelectFont( wxCommandEvent& event ) +{ + wxFont font = wxGetFontFromUser( this, *g_StdFont ); + + if( font.Ok() ) { - case ID_SELECT_DEFAULT_PDF_BROWSER: - wxGetApp().m_PdfBrowserIsDefault = TRUE; - GetMenuBar()->Check( ID_SELECT_DEFAULT_PDF_BROWSER, - wxGetApp().m_PdfBrowserIsDefault ); - GetMenuBar()->Check( ID_SELECT_PREFERED_PDF_BROWSER, - !wxGetApp().m_PdfBrowserIsDefault ); - wxGetApp().WritePdfBrowserInfos(); - break; - - case ID_SELECT_PREFERED_PDF_BROWSER: - if( wxGetApp().m_PdfBrowser.IsEmpty() ) - { - DisplayError( this, - _( "You must choose a PDF viewer before use this option" ) ); - ChoosePdfBrowser( this ); - } - if( wxGetApp().m_PdfBrowser.IsEmpty() ) - { - wxGetApp().m_PdfBrowserIsDefault = TRUE; - GetMenuBar()->Check( ID_SELECT_DEFAULT_PDF_BROWSER, TRUE ); - GetMenuBar()->Check( ID_SELECT_PREFERED_PDF_BROWSER, FALSE ); - } - else - { - wxGetApp().m_PdfBrowserIsDefault = FALSE; - GetMenuBar()->Check( ID_SELECT_DEFAULT_PDF_BROWSER, FALSE ); - GetMenuBar()->Check( ID_SELECT_PREFERED_PDF_BROWSER, TRUE ); - } - wxGetApp().WritePdfBrowserInfos(); - break; - - case ID_SELECT_PREFERED_PDF_BROWSER_NAME: - ChoosePdfBrowser( this ); - break; - - case ID_SELECT_PREFERED_EDITOR: - FullFileName = EDA_FileSelector( _( "Prefered Editor:" ), - wxPathOnly( g_EditorName ), /* Default path */ - g_EditorName, /* default filename */ - wxEmptyString, /* default filename extension */ - mask, /* filter for filename list */ - this, /* parent frame */ - wxFD_OPEN, /* wxFD_SAVE, wxFD_OPEN ..*/ - TRUE /* true = keep the current path */ - ); - if( ( !FullFileName.IsEmpty() ) && wxGetApp().m_EDA_CommonConfig ) - { - g_EditorName = FullFileName; - wxGetApp().m_EDA_CommonConfig->Write( wxT( "Editor" ), - g_EditorName ); - } - break; - - case ID_PREFERENCES_FONT_INFOSCREEN: - { - wxFont font = wxGetFontFromUser( this, *g_StdFont ); - if( font.Ok() ) - { - int pointsize = font.GetPointSize(); - *g_StdFont = font; - g_StdFontPointSize = pointsize; - g_DialogFontPointSize = pointsize; - g_FixedFontPointSize = pointsize; - m_LeftWin->ReCreateTreePrj(); - m_DialogWin->SetFont( *g_StdFont ); - m_DialogWin->Refresh(); - } - break; - } - - default: - DisplayError( this, - wxT( "WinEDA_MainFrame::Process_Preferences Internal Error" ) ); - break; + int pointsize = font.GetPointSize(); + *g_StdFont = font; + g_StdFontPointSize = pointsize; + g_DialogFontPointSize = pointsize; + g_FixedFontPointSize = pointsize; + m_LeftWin->ReCreateTreePrj(); + m_DialogWin->SetFont( *g_StdFont ); + m_DialogWin->Refresh(); } } -/********************************************************/ void WinEDA_MainFrame::SetLanguage( wxCommandEvent& event ) -/********************************************************/ { wxGetApp().SetLanguageIdentifier( event.GetId() ); if ( wxGetApp().SetLanguage() ) diff --git a/kicad/prjconfig.cpp b/kicad/prjconfig.cpp index 9e460ddf31..2c00fa8cce 100644 --- a/kicad/prjconfig.cpp +++ b/kicad/prjconfig.cpp @@ -12,90 +12,129 @@ #include "common.h" #include "confirm.h" #include "gestfich.h" -#include "kicad.h" -#include "protos.h" #include "prjconfig.h" +#include "id.h" +#include "kicad.h" + +static const wxString GeneralGroupName( wxT( "/general" ) ); + +/* Kicad project file entry namse. */ +static const wxString SchematicRootNameEntry( wxT( "RootSch" ) ); +static const wxString BoardFileNameEntry( wxT( "BoardNm" ) ); -/* Variables locales */ -PARAM_CFG_WXSTRING SchematicRootFileNameCfg -( - wxT("RootSch"), /* identification */ - &g_SchematicRootFileName /* Adresse du parametre */ -); - -PARAM_CFG_WXSTRING BoardFileNameCfg -( - wxT("BoardNm"), /* identification */ - &g_BoardFileName /* Adresse du parametre */ -); - - -PARAM_CFG_BASE * CfgParamList[] = +void WinEDA_MainFrame::CreateNewProject( const wxString PrjFullFileName ) { - & SchematicRootFileNameCfg, - & BoardFileNameCfg, - NULL -}; + wxFileName fn; + wxFileName newProjectName = PrjFullFileName; + // Init default config filename + fn.SetPath( ReturnKicadDatasPath() ); + fn.AppendDir( wxT( "template" ) ); + fn.SetName( wxT( "kicad" ) ); + fn.SetExt( ProjectFileExtension ); - -/*******************************************/ -void WinEDA_MainFrame::Load_Prj_Config() -/*******************************************/ -{ - if( !wxFileExists( m_PrjFileName ) ) + if( !fn.FileExists() ) { - wxString msg = _( "Kicad project file <" ) + m_PrjFileName + - _( "> not found" ); - DisplayError( this, msg ); + DisplayInfo( NULL, _( "Template file not found " ) + fn.GetFullPath() ); + return; + } + else + { + wxCopyFile( fn.GetFullPath(), PrjFullFileName ); + } + + m_SchematicRootFileName = wxFileName( newProjectName.GetName(), + SchematicFileExtension ).GetFullName(); + + m_BoardFileName = wxFileName( newProjectName.GetName(), + BoardFileExtension ).GetFullName(); + + m_ProjectFileName = newProjectName; + wxGetApp().WriteProjectConfig( PrjFullFileName, GeneralGroupName, NULL ); +} + + +void WinEDA_MainFrame::OnLoadProject( wxCommandEvent& event ) +{ + int style; + wxString title; + + if( event.GetId() != wxID_ANY ) + { + if( event.GetId() == ID_NEW_PROJECT ) + { + title = _( "Create New Project" ); + style = wxFD_SAVE | wxFD_OVERWRITE_PROMPT; + } + else + { + title = _( "Open Existing Project" ); + style = wxFD_OPEN | wxFD_FILE_MUST_EXIST; + } + + SetLastProject( m_ProjectFileName.GetFullPath() ); + wxFileDialog dlg( this, title, wxGetCwd(), wxEmptyString, + ProjectFileWildcard, style ); + + if( dlg.ShowModal() == wxID_CANCEL ) + return; + + m_ProjectFileName = dlg.GetPath(); + + if( event.GetId() == ID_NEW_PROJECT ) + CreateNewProject( m_ProjectFileName.GetFullPath() ); + + SetLastProject( m_ProjectFileName.GetFullPath() ); + } + + wxLogDebug( wxT( "Loading Kicad project file: " ) + + m_ProjectFileName.GetFullPath() ); + + if( !m_ProjectFileName.FileExists() ) + { + DisplayError( this, _( "Kicad project file <" ) + + m_ProjectFileName.GetFullPath() + _( "> not found" ) ); return; } - wxSetWorkingDirectory( wxPathOnly( m_PrjFileName ) ); - SetTitle( g_Main_Title + wxT( " " ) + GetBuildVersion() + wxT( " " ) + - m_PrjFileName ); - SetLastProject( m_PrjFileName ); + wxSetWorkingDirectory( m_ProjectFileName.GetPath() ); + wxGetApp().ReadProjectConfig( m_ProjectFileName.GetFullPath(), + GeneralGroupName, NULL, false ); + + SetTitle( wxGetApp().GetTitle() + wxT( " " ) + GetBuildVersion() + + wxT( " " ) + m_ProjectFileName.GetFullPath() ); + SetLastProject( m_ProjectFileName.GetFullPath() ); m_LeftWin->ReCreateTreePrj(); - wxString msg = _( "\nWorking dir: " ) + wxGetCwd(); - msg << _( "\nProject: " ) << m_PrjFileName << wxT( "\n" ); - PrintMsg( msg ); + PrintMsg( _( "Working dir: " ) + m_ProjectFileName.GetPath() + + _( "\nProject: " ) + m_ProjectFileName.GetFullName() + + wxT( "\n" ) ); #ifdef KICAD_PYTHON PyHandler::GetInstance()->TriggerEvent( wxT( "kicad::LoadProject" ), - PyHandler::Convert( m_PrjFileName ) ); + PyHandler::Convert( m_ProjectFileName.GetFullPath() ) ); #endif } -/*********************************************/ -void WinEDA_MainFrame::Save_Prj_Config() -/*********************************************/ +/** + * Save the project top level configuration parameters. + */ +void WinEDA_MainFrame::OnSaveProject( wxCommandEvent& event ) { - wxString FullFileName; + wxString fn; - wxString mask( wxT( "*" ) ); + wxFileDialog dlg( this, _( "Save Project File" ), wxGetCwd(), + m_ProjectFileName.GetFullName(), ProjectFileWildcard, + wxFD_SAVE | wxFD_OVERWRITE_PROMPT ); - g_Prj_Config_Filename_ext = wxT( ".pro" ); - mask += g_Prj_Config_Filename_ext; - FullFileName = m_PrjFileName; - ChangeFileNameExt( FullFileName, g_Prj_Config_Filename_ext ); - - FullFileName = EDA_FileSelector( _( "Save Project File:" ), - wxGetCwd(), /* Chemin par defaut */ - FullFileName, /* nom fichier par defaut */ - g_Prj_Config_Filename_ext, /* extension par defaut */ - mask, /* Masque d'affichage */ - this, - wxFD_SAVE, - TRUE - ); - - if( FullFileName.IsEmpty() ) + if( dlg.ShowModal() == wxID_CANCEL ) return; + m_ProjectFileName = dlg.GetPath(); + /* ecriture de la configuration */ - wxGetApp().WriteProjectConfig( FullFileName, wxT( "/general" ), - CfgParamList ); + wxGetApp().WriteProjectConfig( m_ProjectFileName.GetFullPath(), + GeneralGroupName, NULL ); } diff --git a/kicad/protos.h b/kicad/protos.h deleted file mode 100644 index eaed65ed7b..0000000000 --- a/kicad/protos.h +++ /dev/null @@ -1,2 +0,0 @@ -/* prototypes de fonctions */ - diff --git a/kicad/treeprj_datas.cpp b/kicad/treeprj_datas.cpp index b2b0b5c365..3bb92b2891 100644 --- a/kicad/treeprj_datas.cpp +++ b/kicad/treeprj_datas.cpp @@ -10,9 +10,9 @@ #include "gr_basic.h" #include "common.h" #include "gestfich.h" +#include "appl_wxstruct.h" #include "kicad.h" -#include "protos.h" #include "wx/image.h" #include "wx/imaglist.h" @@ -259,7 +259,7 @@ bool TreePrjItemData::Rename( const wxString& name, bool check ) //this is broken & unsafe to use on linux. if( m_Type == TREE_DIRECTORY ) return false; - + if( name.IsEmpty() ) return false; @@ -383,16 +383,17 @@ void TreePrjItemData::Activate( WinEDA_PrjFrame* prjframe ) } } while( dir->GetNext( &dir_filename ) ); } - + if( count == 0 ) { /* The AddFile() text below should match the filter added to handle it in treeprj_frame.cpp in the line looking like this: m_Filters.push_back( wxT( "^no kicad files found" ) ); */ - prjframe->AddFile( wxString(_("no kicad files found in this directory")), id ); + prjframe->AddFile( wxString( _( "no kicad files found in " \ + "this directory" ) ), id ); } - + /* Sort filenames by alphabetic order */ m_Parent->SortChildren( id ); delete dir; @@ -432,7 +433,7 @@ void TreePrjItemData::Activate( WinEDA_PrjFrame* prjframe ) case TREE_TXT: { - wxString editorname = GetEditorName(); + wxString editorname = wxGetApp().GetEditorName(); if( !editorname.IsEmpty() ) ExecuteFile( m_Parent, editorname, FullFileName ); break; diff --git a/kicad/treeprj_frame.cpp b/kicad/treeprj_frame.cpp index 899ef12409..2b206ab831 100644 --- a/kicad/treeprj_frame.cpp +++ b/kicad/treeprj_frame.cpp @@ -13,9 +13,9 @@ #include "common.h" #include "confirm.h" #include "gestfich.h" +#include "appl_wxstruct.h" #include "kicad.h" -#include "protos.h" #include "wx/image.h" #include "wx/imaglist.h" @@ -53,6 +53,21 @@ const wxChar* s_AllowedExtensionsToList[] = }; +/* TODO: Check if these file extension and wildcard definitions are used + * in any of the other Kicad programs and move them into the common + * library as required. */ + +/* File extension definitions. */ +const wxString PythonFileExtension( wxT( "py" ) ); +const wxString PdfFileExtension( wxT( "pdf" ) ); +const wxString TextFileExtension( wxT( "txt" ) ); + +/* File wildcard definitions. */ +const wxString PythonFileWildcard( wxT( "Python files (*.py)|*.py" ) ); +const wxString PdfFileWildcard( wxT( "Portable document files (*.pdf)|*.pdf" ) ); +const wxString TextFileWildcard( wxT( "Text files (*.txt)|*.txt" ) ); + + /** * @brief TODO */ @@ -119,9 +134,9 @@ WinEDA_PrjFrame::WinEDA_PrjFrame( WinEDA_MainFrame* parent, // ID_PROJECT_TXTEDIT item = new wxMenuItem( menu, - ID_PROJECT_TXTEDIT, - _( "&Edit in a text editor" ), - _( "&Open the file in a Text Editor" ) ); + ID_PROJECT_TXTEDIT, + _( "&Edit in a text editor" ), + _( "&Open the file in a Text Editor" ) ); item->SetBitmap( icon_txt_xpm ); menu->Append( item ); @@ -265,7 +280,7 @@ void WinEDA_PrjFrame::OnDragStart( wxTreeEvent& event ) m_TreeProject->SelectItem( curr_item ); TreePrjItemData* data = GetSelectedData(); - if( data->GetFileName() == m_Parent->m_PrjFileName ) + if( data->GetFileName() == m_Parent->m_ProjectFileName.GetFullPath() ) return; wxTreeItemId id = m_TreeProject->GetSelection(); @@ -512,36 +527,29 @@ void WinEDA_PrjFrame::OnNewTxtFile( wxCommandEvent& event ) void WinEDA_PrjFrame::NewFile( TreeFileType type ) /*****************************************************************************/ { - wxString filename; wxString mask = GetFileExt( type ); - const wxString sep = wxFileName().GetPathSeparator(); + wxString wildcard = GetFileWildcard( type ); // Get the directory: wxString dir; + wxString title; TreePrjItemData* treeData; - wxString FullFileName; + title = ( TREE_DIRECTORY != type ) ? _( "Create New File" ) : + _( "Create New Directory" ); treeData = GetSelectedData(); if( !treeData ) return; - dir = treeData->GetDir(); + dir = wxGetCwd() + wxFileName().GetPathSeparator() + treeData->GetDir(); // Ask for the new file name - filename = EDA_FileSelector( TREE_DIRECTORY != - type ? _( "Create New File:" ) : _( - "Create New Directory" ), - wxGetCwd() + sep + dir, /* Chemin par defaut */ - _( "noname" ) + mask, /* nom fichier par defaut */ - mask, /* extension par defaut */ - mask, /* Masque d'affichage */ - this, - wxFD_SAVE | wxFD_OVERWRITE_PROMPT, - TRUE - ); - if( filename.IsEmpty() ) + wxFileDialog dlg( this, title, dir, _( "noname." ) + mask, + wildcard, wxFD_SAVE | wxFD_OVERWRITE_PROMPT ); + + if( dlg.ShowModal() == wxID_CANCEL ) return; TreeFileType rootType = treeData->GetType(); @@ -559,7 +567,7 @@ void WinEDA_PrjFrame::NewFile( TreeFileType type ) root = m_TreeProject->GetSelection(); } - NewFile( filename, type, root ); + NewFile( dlg.GetPath(), type, root ); } @@ -606,42 +614,85 @@ wxString WinEDA_PrjFrame::GetFileExt( TreeFileType type ) switch( type ) { - case 0: // 0 is not used - break; - case TREE_PROJECT: - ext = wxT( ".pro" ); + ext = ProjectFileExtension; break; case TREE_SCHEMA: - ext = g_SchExtBuffer; + ext = SchematicFileExtension; break; case TREE_PCB: - ext = g_BoardExtBuffer; + ext = BoardFileExtension; break; case TREE_PY: - ext = wxT( ".py" ); + ext = PythonFileExtension; break; case TREE_GERBER: - ext = g_GerberExtBuffer; + ext = GerberFileExtension; break; case TREE_PDF: - ext = wxT( ".pdf" ); + ext = PdfFileExtension; break; case TREE_TXT: - ext = wxT( ".txt" ); + ext = TextFileExtension; break; case TREE_NET: - ext = wxT( ".net" ); + ext = NetlistFileExtension; + break; + default: /* Eliminates unnecessary GCC warning. */ + break; + } + + return ext; +} + +/* + * Return the wxFileDialog wildcard string for the selected file type. + */ +wxString WinEDA_PrjFrame::GetFileWildcard( TreeFileType type ) +{ + wxString ext; + + switch( type ) + { + case TREE_PROJECT: + ext = ProjectFileWildcard; break; - default: + case TREE_SCHEMA: + ext = SchematicFileWildcard; + break; + + case TREE_PCB: + ext = BoardFileWildcard; + break; + + case TREE_PY: + ext = PythonFileWildcard; + break; + + case TREE_GERBER: + ext = GerberFileWildcard; + break; + + case TREE_PDF: + ext = PdfFileWildcard; + break; + + case TREE_TXT: + ext = TextFileWildcard; + break; + + case TREE_NET: + ext = NetlistFileWildcard; + break; + default: /* Eliminates unnecessary GCC warning. */ break; } @@ -770,7 +821,7 @@ bool WinEDA_PrjFrame::AddFile( const wxString& name, wxTreeItemId& root ) data->SetState( 0 ); /* Mark root files (files which have the same name as the project) */ - wxFileName project( m_Parent->m_PrjFileName ); + wxFileName project( m_Parent->m_ProjectFileName ); wxFileName currfile( file ); if( currfile.GetName().CmpNoCase( project.GetName() ) == 0 ) @@ -821,7 +872,7 @@ void WinEDA_PrjFrame::ReCreateTreePrj() /*****************************************************************************/ { wxTreeItemId rootcellule; - wxString Text; + wxFileName fn; bool prjOpened = false; if( !m_TreeProject ) @@ -831,15 +882,20 @@ void WinEDA_PrjFrame::ReCreateTreePrj() m_TreeProject->SetFont( *g_StdFont ); - if( m_Parent->m_PrjFileName.IsEmpty() ) - Text = wxT( "noname" ); + if( !m_Parent->m_ProjectFileName.IsOk() ) + { + fn.Clear(); + fn.SetPath( ::wxGetCwd() ); + fn.SetName( wxT( "noname" ) ); + fn.SetExt( ProjectFileExtension ); + } else - Text = wxFileNameFromPath( m_Parent->m_PrjFileName ); + fn = m_Parent->m_ProjectFileName; - prjOpened = wxFileExists( Text ); + prjOpened = fn.FileExists(); // root tree: - m_root = rootcellule = m_TreeProject->AddRoot( Text, + m_root = rootcellule = m_TreeProject->AddRoot( fn.GetFullName(), TREE_PROJECT - 1, TREE_PROJECT - 1 ); @@ -852,32 +908,32 @@ void WinEDA_PrjFrame::ReCreateTreePrj() m_TreeProject->SetItemFont( rootcellule, *g_StdFont ); - ChangeFileNameExt( Text, wxEmptyString ); + fn.SetExt( SchematicFileExtension ); // Add at least a .sch / .brd if not existing: - if( !wxFileExists( Text + g_SchExtBuffer ) ) - AddFile( Text + g_SchExtBuffer, m_root ); + if( !fn.FileExists() ) + AddFile( fn.GetFullName(), m_root ); - if( !wxFileExists( Text + g_BoardExtBuffer ) ) - AddFile( Text + g_BoardExtBuffer, m_root ); + fn.SetExt( BoardFileExtension ); + + if( !fn.FileExists( ) ) + AddFile( fn.GetFullName(), m_root ); + + fn.SetExt( ProjectFileExtension ); // Now adding all current files if available if( prjOpened ) { - wxDir dir( wxGetCwd() ); - wxString dir_str = dir.GetName(); - wxString sep = wxFileName().GetPathSeparator(); wxString filename; + wxDir dir( wxGetCwd() ); + bool cont = dir.GetFirst( &filename ); - if( dir.GetFirst( &filename ) ) + while( cont ) { - do - { - if( filename == Text + wxT( ".pro" ) ) - continue; - - AddFile( dir_str + sep + filename, m_root ); - } while( dir.GetNext( &filename ) ); + if( filename != fn.GetFullName() ) + AddFile( dir.GetName() + wxFileName::GetPathSeparator() + + filename, m_root ); + cont = dir.GetNext( &filename ); } } @@ -885,6 +941,8 @@ void WinEDA_PrjFrame::ReCreateTreePrj() /* Sort filenames by alphabetic order */ m_TreeProject->SortChildren( m_root ); + + m_Parent->m_ProjectFileName = fn; } @@ -975,7 +1033,7 @@ void WinEDA_PrjFrame::OnTxtEdit( wxCommandEvent& event ) wxString FullFileName = tree_data->GetFileName(); AddDelimiterString( FullFileName ); - wxString editorname = GetEditorName(); + wxString editorname = wxGetApp().GetEditorName(); if( !editorname.IsEmpty() ) { @@ -1094,7 +1152,7 @@ void WinEDA_PrjFrame::OnRenameAsk( wxTreeEvent& event ) if( !tree_data ) return; - if( m_Parent->m_PrjFileName == tree_data->GetFileName() ) + if( m_Parent->m_ProjectFileName.GetFullPath() == tree_data->GetFileName() ) event.Veto(); } diff --git a/pcbnew/CMakeLists.txt b/pcbnew/CMakeLists.txt index 7cfaa687c3..65a08032e6 100644 --- a/pcbnew/CMakeLists.txt +++ b/pcbnew/CMakeLists.txt @@ -16,13 +16,13 @@ set(PCBNEW_SRCS block_module_editor.cpp board.cpp build_BOM_from_board.cpp - class_board_item.cpp - class_drawsegment.cpp - class_edge_mod.cpp - class_equipot.cpp - class_module.cpp - class_text_mod.cpp - class_track.cpp +# class_board_item.cpp +# class_drawsegment.cpp +# class_edge_mod.cpp +# class_equipot.cpp +# class_module.cpp +# class_text_mod.cpp +# class_track.cpp clean.cpp # cleaningoptions_dialog.cpp connect.cpp @@ -129,7 +129,7 @@ set(PCBNEW_SRCS tool_modedit.cpp tool_onrightclick.cpp tool_pcb.cpp - tracemod.cpp +# tracemod.cpp tracepcb.cpp track.cpp tr_modif.cpp @@ -147,7 +147,8 @@ set(PCBNEW_SRCS ) set(PCBNEW_EXTRA_SRCS - ../share/setpage.cpp ) + ../share/setpage.cpp +) if(WIN32) if(MINGW) @@ -169,7 +170,7 @@ endif(APPLE) add_executable(pcbnew WIN32 MACOSX_BUNDLE ${PCBNEW_SRCS} ${PCBNEW_EXTRA_SRCS} ${PCBNEW_RESOURCES}) -target_link_libraries(pcbnew 3d-viewer common polygon bitmaps kbool ${wxWidgets_LIBRARIES} ${OPENGL_LIBRARIES}) +target_link_libraries(pcbnew 3d-viewer common pcbcommon polygon bitmaps kbool ${wxWidgets_LIBRARIES} ${OPENGL_LIBRARIES}) install(TARGETS pcbnew DESTINATION ${KICAD_BIN} diff --git a/pcbnew/autorout.cpp b/pcbnew/autorout.cpp index 57fd53cf58..7b1d5c207a 100644 --- a/pcbnew/autorout.cpp +++ b/pcbnew/autorout.cpp @@ -14,9 +14,19 @@ #include "protos.h" -/* routines internes */ -/* Variables locales */ +int E_scale; /* facteur d'echelle des tables de distance */ +int Nb_Sides; /* Nombre de couches pour autoroutage (0 ou 1) */ +int Nrows = ILLEGAL; +int Ncols = ILLEGAL; +int Ntotal; +int OpenNodes; /* total number of nodes opened */ +int ClosNodes; /* total number of nodes closed */ +int MoveNodes; /* total number of nodes moved */ +int MaxNodes; /* maximum number of nodes opened at one time */ + +BOARDHEAD Board; /* 2-sided board */ + /********************************************************/ void WinEDA_PcbFrame::Autoroute( wxDC* DC, int mode ) diff --git a/pcbnew/autorout.h b/pcbnew/autorout.h index 7d13eaf5c3..444332a8de 100644 --- a/pcbnew/autorout.h +++ b/pcbnew/autorout.h @@ -99,29 +99,26 @@ enum CommandOpt { /* Variables et structures d'autoroutage */ -eda_global int E_scale; /* facteur d'echelle des tables de distance */ +extern int E_scale; /* facteur d'echelle des tables de distance */ #define ONE_SIDE 0 #define TWO_SIDES 1 -eda_global int Nb_Sides; /* Nombre de couches pour autoroutage (0 ou 1) */ + +extern int Nb_Sides; /* Nombre de couches pour autoroutage (0 ou 1) */ /* Bits Flags de gestion de remplissage du BOARD */ -#define FORCE_PADS 1 /* pour forcage placement pads quel que soit le netcode */ +#define FORCE_PADS 1 /* pour forcage placement pads quel que soit le netcode */ /* board dimensions */ -extern int Nrows, Ncols; -#if defined MAIN -int Nrows = ILLEGAL; -int Ncols = ILLEGAL; -#endif - -eda_global int Ntotal; +extern int Nrows; +extern int Ncols; +extern int Ntotal; /* search statistics */ -eda_global int OpenNodes; /* total number of nodes opened */ -eda_global int ClosNodes; /* total number of nodes closed */ -eda_global int MoveNodes; /* total number of nodes moved */ -eda_global int MaxNodes; /* maximum number of nodes opened at one time */ +extern int OpenNodes; /* total number of nodes opened */ +extern int ClosNodes; /* total number of nodes closed */ +extern int MoveNodes; /* total number of nodes moved */ +extern int MaxNodes; /* maximum number of nodes opened at one time */ /* Structures utiles a la generation du board en Bit Map */ @@ -147,7 +144,7 @@ public: void UnInitBoard(); }; -eda_global BOARDHEAD Board; /* 2-sided board */ +extern BOARDHEAD Board; /* 2-sided board */ /* Constantes utilisees pour le trace des cellules sur le BOARD */ diff --git a/pcbnew/basepcbframe.cpp b/pcbnew/basepcbframe.cpp index 952382826c..1e0b0adba8 100644 --- a/pcbnew/basepcbframe.cpp +++ b/pcbnew/basepcbframe.cpp @@ -10,6 +10,7 @@ #include "wxstruct.h" #include "common.h" #include "confirm.h" +#include "appl_wxstruct.h" #include "pcbnew.h" #include "bitmaps.h" @@ -20,6 +21,11 @@ #include "class_drawpanel.h" +/* Configuration entry names. */ +static const wxString UserGridSizeXEntry( wxT( "PcbUserGrid_X" ) ); +static const wxString UserGridSizeYEntry( wxT( "PcbUserGrid_Y" ) ); +static const wxString UserGridUnitsEntry( wxT( "PcbUserGrid_Unit" ) ); + /*******************************/ /* class WinEDA_BasePcbFrame */ /*******************************/ @@ -43,11 +49,11 @@ WinEDA_BasePcbFrame::WinEDA_BasePcbFrame( wxWindow* father, long style) : WinEDA_DrawFrame( father, idtype, title, pos, size, style ) { - m_InternalUnits = PCB_INTERNAL_UNIT; // Internal unit = 1/10000 inch - m_Pcb = NULL; + m_InternalUnits = PCB_INTERNAL_UNIT; // Internal unit = 1/10000 inch + m_Pcb = NULL; - m_DisplayPadFill = TRUE; // How to draw pads - m_DisplayPadNum = TRUE; // show pads number + m_DisplayPadFill = TRUE; // How to draw pads + m_DisplayPadNum = TRUE; // show pads number m_DisplayModEdge = FILLED; // How to show module drawings m_DisplayModText = FILLED; // How to show module texts @@ -55,7 +61,10 @@ WinEDA_BasePcbFrame::WinEDA_BasePcbFrame( wxWindow* father, m_Draw3DFrame = NULL; // Display Window in 3D mode (OpenGL) m_ModuleEditFrame = NULL; // Frame for footprint edition - m_Collector = new GENERAL_COLLECTOR(); + m_UserGridSize = wxRealPoint( 100.0, 100.0 ); + m_UserGridUnits = INCHES; + + m_Collector = new GENERAL_COLLECTOR(); } @@ -322,7 +331,7 @@ void WinEDA_BasePcbFrame::SetToolID( int id, int new_cursor_id, DrawPanel->Refresh(); } -void WinEDA_BasePcbFrame::Affiche_Status_Box() +void WinEDA_BasePcbFrame::UpdateStatusBar() /* * Update the status bar information. */ @@ -335,7 +344,7 @@ void WinEDA_BasePcbFrame::Affiche_Status_Box() if( !screen ) return; - WinEDA_DrawFrame::Affiche_Status_Box(); + WinEDA_DrawFrame::UpdateStatusBar(); dx = screen->m_Curseur.x - screen->m_O_Curseur.x; dy = screen->m_Curseur.y - screen->m_O_Curseur.y; @@ -357,3 +366,42 @@ void WinEDA_BasePcbFrame::Affiche_Status_Box() SetStatusText( Line, 0 ); } + + +/** + * Load PCB base frame specific configuration settings. + * + * Don't forget to call this base method from any derived classes or the + * settings will not get loaded. + */ +void WinEDA_BasePcbFrame::LoadSettings() +{ + wxASSERT( wxGetApp().m_EDA_Config != NULL ); + + wxConfig* cfg = wxGetApp().m_EDA_Config; + + WinEDA_DrawFrame::LoadSettings(); + cfg->Read( m_FrameName + UserGridSizeXEntry, &m_UserGridSize.x, 0.01 ); + cfg->Read( m_FrameName + UserGridSizeYEntry, &m_UserGridSize.y, 0.01 ); + cfg->Read( m_FrameName + UserGridUnitsEntry, &m_UserGridUnits, + ( long )INCHES ); +} + + +/** + * Save PCB base frame specific configuration settings. + * + * Don't forget to call this base method from any derived classes or the + * settings will not get saved. + */ +void WinEDA_BasePcbFrame::SaveSettings() +{ + wxASSERT( wxGetApp().m_EDA_Config != NULL ); + + wxConfig* cfg = wxGetApp().m_EDA_Config; + + WinEDA_DrawFrame::SaveSettings(); + cfg->Write( m_FrameName + UserGridSizeXEntry, m_UserGridSize.x ); + cfg->Write( m_FrameName + UserGridSizeYEntry, m_UserGridSize.y ); + cfg->Write( m_FrameName + UserGridUnitsEntry, ( long )m_UserGridUnits ); +} diff --git a/pcbnew/build_BOM_from_board.cpp b/pcbnew/build_BOM_from_board.cpp index 00cb02ebb7..a4c8048aff 100644 --- a/pcbnew/build_BOM_from_board.cpp +++ b/pcbnew/build_BOM_from_board.cpp @@ -27,7 +27,10 @@ The format is: 12;"C1,C4,C5,C6";"CP6";4;"47uF";;; */ -wxString NetBomExtBuffer( wxT( ".csv" ) ); // BOM file extension +const wxString CsvFileExtension( wxT( "csv" ) ); // BOM file extension + +const wxString CsvFileWildcard( _( "Comma separated value files (*.csv)|*.csv" ) ); + class cmp { @@ -44,10 +47,10 @@ WX_DEFINE_LIST( CmpList ); void WinEDA_PcbFrame::RecreateBOMFileFromBoard( wxCommandEvent& aEvent ) { - wxString FullFileName, mask; - FILE* FichBom; - MODULE* Module = GetBoard()->m_Modules; - wxString msg; + wxFileName fn; + FILE* FichBom; + MODULE* Module = GetBoard()->m_Modules; + wxString msg; if( Module == NULL ) @@ -57,27 +60,23 @@ void WinEDA_PcbFrame::RecreateBOMFileFromBoard( wxCommandEvent& aEvent ) } /* Set the file extension: */ - FullFileName = GetScreen()->m_FileName; - ChangeFileNameExt( FullFileName, NetBomExtBuffer ); + fn = GetScreen()->m_FileName; + fn.SetExt( CsvFileExtension ); - mask = wxT( "*" ) + NetBomExtBuffer; - FullFileName = EDA_FileSelector( _( "Bom files:" ), - wxEmptyString, /* Chemin par defaut */ - FullFileName, /* nom fichier par defaut */ - NetBomExtBuffer, /* extension par defaut */ - mask, /* Masque d'affichage */ - this, - wxFD_SAVE, - FALSE - ); - if( FullFileName.IsEmpty() ) + wxFileDialog dlg( this, _( "Save Bill of Materials" ), wxEmptyString, + fn.GetFullName(), CsvFileWildcard, + wxFD_SAVE | wxFD_OVERWRITE_PROMPT ); + + if( dlg.ShowModal() == wxID_CANCEL ) return; + fn = dlg.GetPath(); + + FichBom = wxFopen( fn.GetFullPath(), wxT( "wt" ) ); - FichBom = wxFopen( FullFileName, wxT( "wt" ) ); if( FichBom == NULL ) { - msg = _( "Unable to create file " ) + FullFileName; + msg = _( "Unable to create file " ) + fn.GetFullPath(); DisplayError( this, msg ); return; } diff --git a/pcbnew/class_board.cpp b/pcbnew/class_board.cpp index ad25c9132c..4dad69875e 100644 --- a/pcbnew/class_board.cpp +++ b/pcbnew/class_board.cpp @@ -13,17 +13,6 @@ wxPoint BOARD_ITEM::ZeroOffset(0,0); - -// define SCH_ITEM::Place() (defined and used in eeschema but not for pcbnew) -// this is an ugly workaround to a linking problem in debug mode -// which needs to define SCH_ITEM::Place() when not really used. -#include "sch_item_struct.h" -void SCH_ITEM::Place( WinEDA_SchematicFrame* frame, wxDC* DC ) -{ -} - - - /*****************/ /* Class BOARD: */ /*****************/ diff --git a/pcbnew/class_board_item.cpp b/pcbnew/class_board_item.cpp index ceef22f1d7..d141079ea0 100644 --- a/pcbnew/class_board_item.cpp +++ b/pcbnew/class_board_item.cpp @@ -36,8 +36,6 @@ wxString BOARD_ITEM::ShowShape( Track_Shapes aShape ) } -#if !defined(GERBVIEW) - /********************************************************/ wxString BOARD_ITEM::MenuText( const BOARD* aPcb ) const /********************************************************/ @@ -325,8 +323,6 @@ const char** BOARD_ITEM::MenuIcon() const return (const char**) xpm; } -#endif // !defined(GERBVIEW) - void BOARD_ITEM::UnLink() { DLIST* list = (DLIST*) GetList(); diff --git a/pcbnew/class_drawsegment.cpp b/pcbnew/class_drawsegment.cpp index f3a5c8b878..d4c16b872e 100644 --- a/pcbnew/class_drawsegment.cpp +++ b/pcbnew/class_drawsegment.cpp @@ -11,10 +11,6 @@ #include "pcbnew.h" -#ifdef CVPCB -#include "cvpcb.h" -#endif - #include "trigo.h" /* DRAWSEGMENT: constructor */ diff --git a/pcbnew/class_edge_mod.cpp b/pcbnew/class_edge_mod.cpp index 7ea6b1c7e8..ee2f5ef4af 100644 --- a/pcbnew/class_edge_mod.cpp +++ b/pcbnew/class_edge_mod.cpp @@ -10,16 +10,11 @@ #include "class_drawpanel.h" #include "confirm.h" #include "kicad_string.h" +#include "macros.h" -#ifdef PCBNEW #include "pcbnew.h" #include "autorout.h" #include "drag.h" -#endif - -#ifdef CVPCB -#include "cvpcb.h" -#endif #include "protos.h" diff --git a/pcbnew/class_equipot.cpp b/pcbnew/class_equipot.cpp index ad8c252ae2..23aba3b996 100644 --- a/pcbnew/class_equipot.cpp +++ b/pcbnew/class_equipot.cpp @@ -7,11 +7,6 @@ #include "gr_basic.h" #include "kicad_string.h" #include "pcbnew.h" - -#ifdef CVPCB -#include "cvpcb.h" -#endif - #include "protos.h" diff --git a/pcbnew/class_module.cpp b/pcbnew/class_module.cpp index f42c561a73..f79e79d176 100644 --- a/pcbnew/class_module.cpp +++ b/pcbnew/class_module.cpp @@ -11,17 +11,12 @@ #include "trigo.h" #include "confirm.h" #include "kicad_string.h" +#include "pcbcommon.h" #include "pcbnew.h" -#ifdef PCBNEW #include "autorout.h" #include "drag.h" -#endif - -#ifdef CVPCB -#include "cvpcb.h" -#endif #include "3d_struct.h" #include "protos.h" diff --git a/pcbnew/class_pad.cpp b/pcbnew/class_pad.cpp index 5c6062636e..3f06691b6a 100644 --- a/pcbnew/class_pad.cpp +++ b/pcbnew/class_pad.cpp @@ -644,7 +644,7 @@ bool D_PAD::HitTest( const wxPoint& ref_pos ) { case PAD_CIRCLE: dist = hypot( deltaX, deltaY ); - if( (int) ( round( dist ) ) <= dx ) + if( wxRound( dist ) <= dx ) return true; break; diff --git a/pcbnew/class_pad_draw_functions.cpp b/pcbnew/class_pad_draw_functions.cpp index 5fd39cd35b..9b7c6ed8e1 100644 --- a/pcbnew/class_pad_draw_functions.cpp +++ b/pcbnew/class_pad_draw_functions.cpp @@ -335,7 +335,7 @@ void D_PAD::Draw( WinEDA_DrawPanel* panel, wxDC* DC, int draw_mode, const wxPoin if( fillpad && hole ) { bool blackpenstate = false; - if( g_IsPrinting ) + if( screen->m_IsPrinting ) { blackpenstate = GetGRForceBlackPenState(); GRForceBlackPen( false ); @@ -382,7 +382,7 @@ void D_PAD::Draw( WinEDA_DrawPanel* panel, wxDC* DC, int draw_mode, const wxPoin break; } - if( g_IsPrinting ) + if( screen->m_IsPrinting ) GRForceBlackPen( blackpenstate ); } diff --git a/pcbnew/class_text_mod.cpp b/pcbnew/class_text_mod.cpp index ed30af3ac1..000a8e5864 100644 --- a/pcbnew/class_text_mod.cpp +++ b/pcbnew/class_text_mod.cpp @@ -11,18 +11,13 @@ #include "class_drawpanel.h" #include "drawtxt.h" #include "kicad_string.h" +#include "pcbcommon.h" -#ifdef PCBNEW #include "autorout.h" #include "drag.h" -#endif - -#ifdef CVPCB -#include "cvpcb.h" -#endif - #include "protos.h" + /************************************************************************/ /* Class TEXTE_MODULE classe de base des elements type Texte sur module */ /************************************************************************/ diff --git a/pcbnew/class_track.cpp b/pcbnew/class_track.cpp index 06ae63728e..a1595507d5 100644 --- a/pcbnew/class_track.cpp +++ b/pcbnew/class_track.cpp @@ -11,11 +11,6 @@ #include "drawtxt.h" #include "pcbnew.h" - -#ifdef CVPCB -#include "cvpcb.h" -#endif - #include "protos.h" @@ -630,15 +625,15 @@ void TRACK::Draw( WinEDA_DrawPanel* panel, wxDC* DC, int draw_mode, const wxPoin m_End.x, m_End.y, m_Width, color ); } - if( g_IsPrinting ) + if( panel->GetScreen()->m_IsPrinting ) return; // Show clearance for tracks, not for zone segments if( ShowClearance( this ) ) { GRCSegm( &panel->m_ClipBox, DC, m_Start.x, m_Start.y, - m_End.x, m_End.y, - m_Width + (g_DesignSettings.m_TrackClearence * 2), color ); + m_End.x, m_End.y, + m_Width + (g_DesignSettings.m_TrackClearence * 2), color ); } /* Display the short netname for tracks, not for zone segments. diff --git a/pcbnew/class_zone_setting.h b/pcbnew/class_zone_setting.h index bf039f67bd..9fbf422dd5 100644 --- a/pcbnew/class_zone_setting.h +++ b/pcbnew/class_zone_setting.h @@ -6,11 +6,6 @@ #define ZONE_SETTING_H -#ifndef eda_global -#define eda_global extern -#endif - - /*************************************************/ /* Class ZONE_SETTING to handle zones parameters */ /*************************************************/ diff --git a/pcbnew/controle.cpp b/pcbnew/controle.cpp index 9c3fbb7c13..11e1f33815 100644 --- a/pcbnew/controle.cpp +++ b/pcbnew/controle.cpp @@ -258,8 +258,8 @@ static bool Join( wxPoint* res, wxPoint a0, wxPoint a1, wxPoint b0, wxPoint b1 ) t = min( max( t, 0.0 ), 1.0 ); - res->x = (int) round( a0.x + t * a1.x ); - res->y = (int) round( a0.y + t * a1.y ); + res->x = wxRound( a0.x + t * a1.x ); + res->y = wxRound( a0.y + t * a1.y ); return true; } @@ -282,8 +282,8 @@ bool Project( wxPoint* res, wxPoint on_grid, const TRACK* track ) t /= (double) vec.x * vec.x + (double) vec.y * vec.y; t = min( max( t, 0.0 ), 1.0 ); - res->x = (int) round( track->m_Start.x + t * vec.x ); - res->y = (int) round( track->m_Start.y + t * vec.y ); + res->x = wxRound( track->m_Start.x + t * vec.x ); + res->y = wxRound( track->m_Start.y + t * vec.y ); return true; } @@ -530,25 +530,25 @@ void WinEDA_PcbFrame::GeneralControle( wxDC* DC, wxPoint Mouse ) { case WXK_NUMPAD8: /* Deplacement curseur vers le haut */ case WXK_UP: - Mouse.y -= (int) round(delta.y); + Mouse.y -= wxRound(delta.y); DrawPanel->MouseTo( Mouse ); break; case WXK_NUMPAD2: /* Deplacement curseur vers le bas */ case WXK_DOWN: - Mouse.y += (int) round(delta.y); + Mouse.y += wxRound(delta.y); DrawPanel->MouseTo( Mouse ); break; case WXK_NUMPAD4: /* Deplacement curseur vers la gauche */ case WXK_LEFT: - Mouse.x -= (int) round(delta.x); + Mouse.x -= wxRound(delta.x); DrawPanel->MouseTo( Mouse ); break; case WXK_NUMPAD6: /* Deplacement curseur vers la droite */ case WXK_RIGHT: - Mouse.x += (int) round(delta.x); + Mouse.x += wxRound(delta.x); DrawPanel->MouseTo( Mouse ); break; @@ -631,5 +631,5 @@ void WinEDA_PcbFrame::GeneralControle( wxDC* DC, wxPoint Mouse ) SetToolbars(); - Affiche_Status_Box(); /* Display new cursor coordinates */ + UpdateStatusBar(); /* Display new cursor coordinates */ } diff --git a/pcbnew/deltrack.cpp b/pcbnew/deltrack.cpp index e85e21a9af..0924600d88 100644 --- a/pcbnew/deltrack.cpp +++ b/pcbnew/deltrack.cpp @@ -76,7 +76,7 @@ TRACK* WinEDA_PcbFrame::Delete_Segment( wxDC* DC, TRACK* aTrack ) // a ete effacee ( (PCB_SCREEN*) GetScreen() )->m_Active_Layer = previous_layer; - Affiche_Status_Box(); + UpdateStatusBar(); if( g_TwoSegmentTrackBuild ) // We must have 2 segments or more, or 0 { if( g_CurrentTrackList.GetCount()==1 && g_CurrentTrackSegment->Type() != TYPE_VIA ) diff --git a/pcbnew/dialog_SVG_print.cpp b/pcbnew/dialog_SVG_print.cpp index b8e34b3339..2bd1f65c6c 100644 --- a/pcbnew/dialog_SVG_print.cpp +++ b/pcbnew/dialog_SVG_print.cpp @@ -167,11 +167,11 @@ void DIALOG_SVG_PRINT::SetPenWidth() void DIALOG_SVG_PRINT::PrintSVGDoc( bool aPrintAll, bool aPrint_Framet_Ref ) /***************************************************************************/ { + wxFileName fn; wxString msg; SetPenWidth(); - wxString FullFileName; BASE_SCREEN* screen = m_Parent->GetBaseScreen(); if( aPrintAll ) @@ -182,28 +182,29 @@ void DIALOG_SVG_PRINT::PrintSVGDoc( bool aPrintAll, bool aPrint_Framet_Ref ) if ( ! aPrintAll && ! m_BoxSelectLayer[layer]->GetValue( ) ) continue; - FullFileName = m_FileNameCtrl->GetValue(); - if( FullFileName.IsEmpty() ) + fn = m_FileNameCtrl->GetValue(); + if( !fn.IsOk() ) { - FullFileName = screen->m_FileName; - ChangeFileNameExt( FullFileName, wxT( "" ) ); + fn = screen->m_FileName; } if( aPrintAll ) - FullFileName += wxT("-brd"); + fn.SetName( fn.GetName() + wxT("-brd") ); else { - FullFileName << wxT("-") << m_BoxSelectLayer[layer]->GetLabel( ); + fn.SetName( fn.GetName() + wxT("-") + + m_BoxSelectLayer[layer]->GetLabel( ) ); + m_PrintMaskLayer = 1 << layer; if ( m_PrintBoardEdgesCtrl->IsChecked() ) m_PrintMaskLayer |= EDGE_LAYER; } - FullFileName += wxT( ".svg" ); + fn.SetExt( wxT( ".svg" ) ); - bool success = DrawPage( FullFileName, screen, aPrint_Framet_Ref ); - msg = _( "Create file " ) + FullFileName; + bool success = DrawPage( fn.GetFullPath(), screen, aPrint_Framet_Ref ); + msg = _( "Create file " ) + fn.GetFullPath(); if( !success ) msg += _( " error" ); msg += wxT( "\n" ); @@ -265,11 +266,11 @@ bool DIALOG_SVG_PRINT::DrawPage( const wxString& FullFileName, BASE_SCREEN* scre panel->m_ClipBox.SetX( 0 ); panel->m_ClipBox.SetY( 0 ); panel->m_ClipBox.SetWidth( 0x7FFFFF0 ); panel->m_ClipBox.SetHeight( 0x7FFFFF0 ); - g_IsPrinting = true; + screen->m_IsPrinting = true; SetLocaleTo_C_standard(); // Switch the locale to standard C (needed to print floating point numbers like 1.3) panel->PrintPage( &dc, aPrint_Framet_Ref, m_PrintMaskLayer, false ); SetLocaleTo_Default(); // revert to the current locale - g_IsPrinting = FALSE; + screen->m_IsPrinting = false; panel->m_ClipBox = tmp; } diff --git a/pcbnew/dialog_drc.cpp b/pcbnew/dialog_drc.cpp index f4c0c38afb..87138da689 100644 --- a/pcbnew/dialog_drc.cpp +++ b/pcbnew/dialog_drc.cpp @@ -763,27 +763,21 @@ void DrcDialog::OnListUnconnectedClick( wxCommandEvent& event ) void DrcDialog::OnButtonBrowseRptFileClick( wxCommandEvent& event ) { - wxString FileName; - wxString Mask(wxT("*")); - wxString Ext(wxT(".rpt")); + wxFileName fn; + wxString wildcard( _( "DRC report files (.rpt)|*.rpt" ) ); + wxString Ext( wxT( "rpt" ) ); - FileName = m_Parent->GetScreen()->m_FileName; - ChangeFileNameExt(FileName, wxT("-drc") + Ext); - Mask += Ext; + fn = m_Parent->GetScreen()->m_FileName + wxT("-drc"); + fn.SetExt( Ext ); - FileName = EDA_FileSelector( _("DRC Report file"), - wxEmptyString, /* Chemin par defaut */ - FileName, /* nom fichier par defaut */ - Ext, /* extension par defaut */ - Mask, /* Masque d'affichage */ - this, - wxFD_SAVE, - TRUE - ); - if( FileName.IsEmpty() ) + wxFileDialog dlg( this, _( "Save DRC Report File" ), wxEmptyString, + fn.GetFullName(), wildcard, + wxFD_SAVE | wxFD_OVERWRITE_PROMPT | wxFD_CHANGE_DIR ); + + if( dlg.ShowModal() == wxID_CANCEL ) return; - m_RptFilenameCtrl->SetValue(FileName); + m_RptFilenameCtrl->SetValue(dlg.GetPath()); } diff --git a/pcbnew/dialog_general_options.cpp b/pcbnew/dialog_general_options.cpp index c9d7dafb10..1569be3969 100644 --- a/pcbnew/dialog_general_options.cpp +++ b/pcbnew/dialog_general_options.cpp @@ -41,7 +41,7 @@ void Dialog_GeneralOptions::init() /* Set display options */ m_PolarDisplay->SetSelection( DisplayOpt.DisplayPolarCood ? 1 : 0 ); m_UnitsSelection->SetSelection( g_UnitMetric ? 1 : 0 ); - m_CursorShape->SetSelection( g_CursorShape ? 1 : 0 ); + m_CursorShape->SetSelection( m_Parent->m_CursorShape ? 1 : 0 ); wxString timevalue; timevalue << g_TimeOut / 60; @@ -100,7 +100,7 @@ void Dialog_GeneralOptions::OnOkClick( wxCommandEvent& event ) if( ii != g_UnitMetric ) m_Parent->ReCreateAuxiliaryToolbar(); - g_CursorShape = m_CursorShape->GetSelection(); + m_Parent->m_CursorShape = m_CursorShape->GetSelection(); g_TimeOut = 60 * m_SaveTime->GetValue(); /* Mise a jour de la combobox d'affichage de la couche active */ @@ -343,7 +343,7 @@ void WinEDA_PcbFrame::OnSelectOptionToolbar( wxCommandEvent& event ) if( id == ID_TB_OPTIONS_SELECT_UNIT_INCH ) g_UnitMetric = INCHES; m_SelTrackWidthBox_Changed = TRUE; - Affiche_Status_Box(); /* Reaffichage des coord curseur */ + UpdateStatusBar(); /* Reaffichage des coord curseur */ ReCreateAuxiliaryToolbar(); DisplayUnitsMsg(); break; @@ -351,11 +351,11 @@ void WinEDA_PcbFrame::OnSelectOptionToolbar( wxCommandEvent& event ) case ID_TB_OPTIONS_SHOW_POLAR_COORD: Affiche_Message( wxEmptyString ); DisplayOpt.DisplayPolarCood = m_OptionsToolBar->GetToolState( id ); - Affiche_Status_Box(); /* Reaffichage des coord curseur */ + UpdateStatusBar(); /* Reaffichage des coord curseur */ break; case ID_TB_OPTIONS_SELECT_CURSOR: - g_CursorShape = m_OptionsToolBar->GetToolState( id ); + m_CursorShape = m_OptionsToolBar->GetToolState( id ); break; case ID_TB_OPTIONS_AUTO_DEL_TRACK: diff --git a/pcbnew/dialog_netlist.cpp b/pcbnew/dialog_netlist.cpp index cb97b1b80a..5bddce3772 100644 --- a/pcbnew/dialog_netlist.cpp +++ b/pcbnew/dialog_netlist.cpp @@ -335,13 +335,11 @@ void WinEDA_NetlistFrame::OnOpenNelistClick( wxCommandEvent& event ) void WinEDA_NetlistFrame::OnReadNetlistFileClick( wxCommandEvent& event ) { - wxString CmpFullFileName; - CmpFullFileName = m_NetlistFilenameCtrl->GetValue(); - ChangeFileNameExt( CmpFullFileName, NetCmpExtBuffer ); + wxFileName fn = m_NetlistFilenameCtrl->GetValue(); + fn.SetExt( NetCmpExtBuffer ); ReadPcbNetlist( m_Parent, m_NetlistFilenameCtrl->GetValue(), - CmpFullFileName, - m_MessageWindow, + fn.GetFullPath(), m_MessageWindow, m_ChangeExistingFootprintCtrl->GetSelection() == 1 ? TRUE : FALSE, m_DeleteBadTracks->GetSelection() == 1 ? TRUE : FALSE, m_RemoveExtraFootprintsCtrl->IsChecked(), diff --git a/pcbnew/dialog_orient_footprints.cpp b/pcbnew/dialog_orient_footprints.cpp index 79b6fd8550..2a41ab1fc7 100644 --- a/pcbnew/dialog_orient_footprints.cpp +++ b/pcbnew/dialog_orient_footprints.cpp @@ -278,7 +278,7 @@ void dialog_orient_footprints::OnOkClick( wxCommandEvent& event ) return; } - s_NewOrientation = (int) round(d_orient * 10); + s_NewOrientation = wxRound(d_orient * 10); if ( s_NewOrientation > 3600 ) s_NewOrientation = 3600; if ( s_NewOrientation < -3600 ) diff --git a/pcbnew/dialog_print_using_printer.cpp b/pcbnew/dialog_print_using_printer.cpp index 40f8d09d57..9457a78c37 100644 --- a/pcbnew/dialog_print_using_printer.cpp +++ b/pcbnew/dialog_print_using_printer.cpp @@ -696,7 +696,7 @@ void EDA_Printout::DrawPage() panel->m_ClipBox.SetOrigin( wxPoint( 0, 0 ) ); panel->m_ClipBox.SetSize( wxSize( 0x7FFFFF0, 0x7FFFFF0 ) ); - g_IsPrinting = TRUE; + m_Parent->GetBaseScreen()->m_IsPrinting = true; int bg_color = g_DrawBgColor; if( m_Print_Sheet_Ref ) @@ -761,7 +761,7 @@ void EDA_Printout::DrawPage() panel->PrintPage( dc, 0, s_PrintMaskLayer, s_PrintMirror ); g_DrawBgColor = bg_color; - g_IsPrinting = false; + m_Parent->GetBaseScreen()->m_IsPrinting = false; panel->m_ClipBox = tmp; SetPenMinWidth( 1 ); diff --git a/pcbnew/dialog_setup_libs.cpp b/pcbnew/dialog_setup_libs.cpp index d8d50e716e..7faeb3c287 100644 --- a/pcbnew/dialog_setup_libs.cpp +++ b/pcbnew/dialog_setup_libs.cpp @@ -1,4 +1,5 @@ ///////////////////////////////////////////////////////////////////////////// + // Name: dialog_pcbnew_config.cpp // Purpose: // Author: jean-pierre Charras @@ -10,7 +11,8 @@ ///////////////////////////////////////////////////////////////////////////// /* Handle the pcbnew libary config (library list, and default lib path) -*/ + */ + // Generated by DialogBlocks (unregistered), 18/02/2006 16:41:57 #if defined(__GNUG__) && !defined(NO_GCC_PRAGMA) @@ -34,11 +36,12 @@ ////@end XPM images /*****************************************************************/ -void WinEDA_PcbFrame::InstallConfigFrame(const wxPoint & pos) +void WinEDA_PcbFrame::InstallConfigFrame( const wxPoint& pos ) /*****************************************************************/ { -KiConfigPcbnewFrame * CfgFrame = new KiConfigPcbnewFrame(this); - CfgFrame->ShowModal(); CfgFrame->Destroy(); + KiConfigPcbnewFrame* CfgFrame = new KiConfigPcbnewFrame( this ); + + CfgFrame->ShowModal(); CfgFrame->Destroy(); } @@ -73,173 +76,288 @@ END_EVENT_TABLE() * KiConfigPcbnewFrame constructors */ -KiConfigPcbnewFrame::KiConfigPcbnewFrame( ) +KiConfigPcbnewFrame::KiConfigPcbnewFrame() { } -KiConfigPcbnewFrame::KiConfigPcbnewFrame( WinEDA_PcbFrame* parent, wxWindowID id, const wxString& caption, const wxPoint& pos, const wxSize& size, long style ) + +KiConfigPcbnewFrame::KiConfigPcbnewFrame( WinEDA_PcbFrame* parent, + wxWindowID id, + const wxString& caption, + const wxPoint& pos, + const wxSize& size, + long style ) { -wxString title; + wxString title; + wxConfig* cfg = wxGetApp().m_EDA_CommonConfig; - m_Parent = parent; - m_LibModified = FALSE; + m_Parent = parent; + m_LibModified = FALSE; - Create(parent, id, caption, pos, size, style); + Create( parent, id, caption, pos, size, style ); - title = _("from ") + wxGetApp().m_CurrentOptionFile; - SetTitle(title); - m_ListLibr->InsertItems(g_LibName_List, 0); - wxString DocModuleFileName = - wxGetApp().m_EDA_CommonConfig->Read( wxT("module_doc_file"), - wxT("pcbnew/footprints.pdf")); - m_TextHelpModulesFileName->SetValue(DocModuleFileName); + title = _( "from " ) + wxGetApp().m_CurrentOptionFile; + SetTitle( title ); + m_ListLibr->InsertItems( g_LibName_List, 0 ); + wxString DocModuleFileName = cfg->Read( wxT( "module_doc_file" ), + wxT( "pcbnew/footprints.pdf" ) ); + m_TextHelpModulesFileName->SetValue( DocModuleFileName ); } + /*! * KiConfigPcbnewFrame creator */ -bool KiConfigPcbnewFrame::Create( wxWindow* parent, wxWindowID id, const wxString& caption, const wxPoint& pos, const wxSize& size, long style ) +bool KiConfigPcbnewFrame::Create( wxWindow* parent, + wxWindowID id, + const wxString& caption, + const wxPoint& pos, + const wxSize& size, + long style ) { ////@begin KiConfigPcbnewFrame member initialisation m_FileExtList = NULL; - m_ListLibr = NULL; - m_TextLibDir = NULL; + m_ListLibr = NULL; + m_TextLibDir = NULL; m_TextHelpModulesFileName = NULL; + ////@end KiConfigPcbnewFrame member initialisation ////@begin KiConfigPcbnewFrame creation - SetExtraStyle(GetExtraStyle()|wxWS_EX_BLOCK_EVENTS); + SetExtraStyle( GetExtraStyle() | wxWS_EX_BLOCK_EVENTS ); wxDialog::Create( parent, id, caption, pos, size, style ); CreateControls(); - GetSizer()->Fit(this); - GetSizer()->SetSizeHints(this); + GetSizer()->Fit( this ); + GetSizer()->SetSizeHints( this ); Centre(); + ////@end KiConfigPcbnewFrame creation return true; } + /*! * Control creation for KiConfigPcbnewFrame */ void KiConfigPcbnewFrame::CreateControls() { - SetFont(*g_DialogFont); + SetFont( *g_DialogFont ); ////@begin KiConfigPcbnewFrame content construction // Generated by DialogBlocks, 18/02/2006 17:19:54 (unregistered) KiConfigPcbnewFrame* itemDialog1 = this; - wxBoxSizer* itemBoxSizer2 = new wxBoxSizer(wxVERTICAL); - itemDialog1->SetSizer(itemBoxSizer2); + wxBoxSizer* itemBoxSizer2 = new wxBoxSizer( wxVERTICAL ); + itemDialog1->SetSizer( itemBoxSizer2 ); - wxBoxSizer* itemBoxSizer3 = new wxBoxSizer(wxHORIZONTAL); - itemBoxSizer2->Add(itemBoxSizer3, 0, wxALIGN_CENTER_HORIZONTAL|wxALL, 5); + wxBoxSizer* itemBoxSizer3 = new wxBoxSizer( wxHORIZONTAL ); + itemBoxSizer2->Add( itemBoxSizer3, 0, wxALIGN_CENTER_HORIZONTAL | wxALL, 5 ); - wxBoxSizer* itemBoxSizer4 = new wxBoxSizer(wxVERTICAL); - itemBoxSizer3->Add(itemBoxSizer4, 0, wxGROW|wxALL, 5); + wxBoxSizer* itemBoxSizer4 = new wxBoxSizer( wxVERTICAL ); + itemBoxSizer3->Add( itemBoxSizer4, 0, wxGROW | wxALL, 5 ); - wxButton* itemButton5 = new wxButton( itemDialog1, SAVE_CFG, _("Save Cfg"), wxDefaultPosition, wxDefaultSize, 0 ); - itemButton5->SetForegroundColour(wxColour(204, 0, 0)); - itemBoxSizer4->Add(itemButton5, 0, wxGROW|wxALL, 5); + wxButton* itemButton5 = + new wxButton( itemDialog1, SAVE_CFG, _( + "Save Cfg" ), wxDefaultPosition, wxDefaultSize, 0 ); + itemButton5->SetForegroundColour( wxColour( 204, 0, 0 ) ); + itemBoxSizer4->Add( itemButton5, 0, wxGROW | wxALL, 5 ); - itemBoxSizer4->Add(5, 5, 0, wxALIGN_CENTER_HORIZONTAL|wxALL, 5); + itemBoxSizer4->Add( 5, 5, 0, wxALIGN_CENTER_HORIZONTAL | wxALL, 5 ); - wxStaticBox* itemStaticBoxSizer7Static = new wxStaticBox(itemDialog1, wxID_ANY, _("Files ext:")); - m_FileExtList = new wxStaticBoxSizer(itemStaticBoxSizer7Static, wxVERTICAL); - itemBoxSizer4->Add(m_FileExtList, 0, wxGROW|wxALL, 5); + wxStaticBox* itemStaticBoxSizer7Static = + new wxStaticBox( itemDialog1, wxID_ANY, _( + "Files ext:" ) ); + m_FileExtList = new wxStaticBoxSizer( itemStaticBoxSizer7Static, + wxVERTICAL ); + itemBoxSizer4->Add( m_FileExtList, 0, wxGROW | wxALL, 5 ); - wxBoxSizer* itemBoxSizer8 = new wxBoxSizer(wxVERTICAL); - itemBoxSizer3->Add(itemBoxSizer8, 0, wxGROW|wxLEFT|wxRIGHT|wxBOTTOM, 5); + wxBoxSizer* itemBoxSizer8 = new wxBoxSizer( wxVERTICAL ); + itemBoxSizer3->Add( itemBoxSizer8, + 0, + wxGROW | wxLEFT | wxRIGHT | wxBOTTOM, + 5 ); - wxBoxSizer* itemBoxSizer9 = new wxBoxSizer(wxHORIZONTAL); - itemBoxSizer8->Add(itemBoxSizer9, 0, wxALIGN_CENTER_HORIZONTAL|wxLEFT|wxRIGHT|wxBOTTOM, 5); + wxBoxSizer* itemBoxSizer9 = new wxBoxSizer( wxHORIZONTAL ); + itemBoxSizer8->Add( itemBoxSizer9, + 0, + wxALIGN_CENTER_HORIZONTAL | wxLEFT | wxRIGHT | + wxBOTTOM, + 5 ); - wxBoxSizer* itemBoxSizer10 = new wxBoxSizer(wxVERTICAL); - itemBoxSizer9->Add(itemBoxSizer10, 0, wxALIGN_CENTER_VERTICAL, 5); + wxBoxSizer* itemBoxSizer10 = new wxBoxSizer( wxVERTICAL ); + itemBoxSizer9->Add( itemBoxSizer10, 0, wxALIGN_CENTER_VERTICAL, 5 ); - wxBoxSizer* itemBoxSizer11 = new wxBoxSizer(wxHORIZONTAL); - itemBoxSizer10->Add(itemBoxSizer11, 0, wxALIGN_CENTER_HORIZONTAL|wxALL, 5); + wxBoxSizer* itemBoxSizer11 = new wxBoxSizer( wxHORIZONTAL ); + itemBoxSizer10->Add( itemBoxSizer11, + 0, + wxALIGN_CENTER_HORIZONTAL | wxALL, + 5 ); - wxButton* itemButton12 = new wxButton( itemDialog1, DEL_LIB, _("Del"), wxDefaultPosition, wxDefaultSize, 0 ); - itemButton12->SetForegroundColour(wxColour(204, 0, 0)); - itemBoxSizer11->Add(itemButton12, 0, wxGROW|wxALL, 5); + wxButton* itemButton12 = new wxButton( itemDialog1, DEL_LIB, _( + "Del" ), wxDefaultPosition, + wxDefaultSize, 0 ); + itemButton12->SetForegroundColour( wxColour( 204, 0, 0 ) ); + itemBoxSizer11->Add( itemButton12, 0, wxGROW | wxALL, 5 ); - wxButton* itemButton13 = new wxButton( itemDialog1, ADD_LIB, _("Add"), wxDefaultPosition, wxDefaultSize, 0 ); - itemButton13->SetForegroundColour(wxColour(0, 128, 0)); - itemBoxSizer11->Add(itemButton13, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5); + wxButton* itemButton13 = new wxButton( itemDialog1, ADD_LIB, _( + "Add" ), wxDefaultPosition, + wxDefaultSize, 0 ); + itemButton13->SetForegroundColour( wxColour( 0, 128, 0 ) ); + itemBoxSizer11->Add( itemButton13, 0, wxALIGN_CENTER_VERTICAL | wxALL, 5 ); - wxButton* itemButton14 = new wxButton( itemDialog1, INSERT_LIB, _("Ins"), wxDefaultPosition, wxDefaultSize, 0 ); + wxButton* itemButton14 = new wxButton( itemDialog1, INSERT_LIB, _( + "Ins" ), wxDefaultPosition, + wxDefaultSize, 0 ); itemButton14->SetDefault(); - itemButton14->SetForegroundColour(wxColour(0, 0, 255)); - itemBoxSizer11->Add(itemButton14, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5); + itemButton14->SetForegroundColour( wxColour( 0, 0, 255 ) ); + itemBoxSizer11->Add( itemButton14, 0, wxALIGN_CENTER_VERTICAL | wxALL, 5 ); - wxBoxSizer* itemBoxSizer15 = new wxBoxSizer(wxVERTICAL); - itemBoxSizer10->Add(itemBoxSizer15, 0, wxGROW|wxALL, 5); + wxBoxSizer* itemBoxSizer15 = new wxBoxSizer( wxVERTICAL ); + itemBoxSizer10->Add( itemBoxSizer15, 0, wxGROW | wxALL, 5 ); - wxStaticText* itemStaticText16 = new wxStaticText( itemDialog1, wxID_STATIC, _("Libraries"), wxDefaultPosition, wxDefaultSize, 0 ); - itemStaticText16->SetForegroundColour(wxColour(204, 0, 0)); - itemBoxSizer15->Add(itemStaticText16, 0, wxALIGN_LEFT|wxLEFT|wxRIGHT|wxADJUST_MINSIZE, 5); + wxStaticText* itemStaticText16 = new wxStaticText( itemDialog1, + wxID_STATIC, + _( "Libraries" ), + wxDefaultPosition, + wxDefaultSize, + 0 ); + itemStaticText16->SetForegroundColour( wxColour( 204, 0, 0 ) ); + itemBoxSizer15->Add( itemStaticText16, + 0, + wxALIGN_LEFT | wxLEFT | wxRIGHT | wxADJUST_MINSIZE, + 5 ); wxString* m_ListLibrStrings = NULL; - m_ListLibr = new wxListBox( itemDialog1, ID_LIST_LIBS, wxDefaultPosition, wxSize(-1, 200), 0, m_ListLibrStrings, wxLB_SINGLE|wxSUNKEN_BORDER ); - itemBoxSizer15->Add(m_ListLibr, 0, wxGROW|wxLEFT|wxRIGHT|wxBOTTOM, 5); + m_ListLibr = new wxListBox( itemDialog1, + ID_LIST_LIBS, + wxDefaultPosition, + wxSize( -1, 200 ), + 0, + m_ListLibrStrings, + wxLB_SINGLE | wxSUNKEN_BORDER ); + itemBoxSizer15->Add( m_ListLibr, + 0, + wxGROW | wxLEFT | wxRIGHT | wxBOTTOM, + 5 ); - wxStaticText* itemStaticText18 = new wxStaticText( itemDialog1, wxID_STATIC, _("Lib Modules Dir:"), wxDefaultPosition, wxDefaultSize, wxALIGN_LEFT ); - itemStaticText18->SetForegroundColour(wxColour(204, 0, 0)); - itemBoxSizer2->Add(itemStaticText18, 0, wxALIGN_LEFT|wxLEFT|wxRIGHT|wxADJUST_MINSIZE, 5); + wxStaticText* itemStaticText18 = new wxStaticText( itemDialog1, + wxID_STATIC, + _( "Lib Modules Dir:" ), + wxDefaultPosition, + wxDefaultSize, + wxALIGN_LEFT ); + itemStaticText18->SetForegroundColour( wxColour( 204, 0, 0 ) ); + itemBoxSizer2->Add( itemStaticText18, + 0, + wxALIGN_LEFT | wxLEFT | wxRIGHT | wxADJUST_MINSIZE, + 5 ); - m_TextLibDir = new wxTextCtrl( itemDialog1, ID_TEXTCTRL, _T(""), wxDefaultPosition, wxDefaultSize, 0 ); - itemBoxSizer2->Add(m_TextLibDir, 0, wxGROW|wxLEFT|wxRIGHT|wxBOTTOM, 5); + m_TextLibDir = new wxTextCtrl( itemDialog1, ID_TEXTCTRL, _T( + "" ), wxDefaultPosition, wxDefaultSize, + 0 ); + itemBoxSizer2->Add( m_TextLibDir, + 0, + wxGROW | wxLEFT | wxRIGHT | wxBOTTOM, + 5 ); - wxStaticText* itemStaticText20 = new wxStaticText( itemDialog1, wxID_STATIC, _("Module Doc File:"), wxDefaultPosition, wxDefaultSize, wxALIGN_LEFT ); - itemStaticText20->SetForegroundColour(wxColour(204, 0, 0)); - itemBoxSizer2->Add(itemStaticText20, 0, wxALIGN_LEFT|wxLEFT|wxRIGHT|wxADJUST_MINSIZE, 5); + wxStaticText* itemStaticText20 = new wxStaticText( itemDialog1, + wxID_STATIC, + _( "Module Doc File:" ), + wxDefaultPosition, + wxDefaultSize, + wxALIGN_LEFT ); + itemStaticText20->SetForegroundColour( wxColour( 204, 0, 0 ) ); + itemBoxSizer2->Add( itemStaticText20, + 0, + wxALIGN_LEFT | wxLEFT | wxRIGHT | wxADJUST_MINSIZE, + 5 ); - m_TextHelpModulesFileName = new wxTextCtrl( itemDialog1, ID_TEXTCTRL1, _T(""), wxDefaultPosition, wxDefaultSize, 0 ); - itemBoxSizer2->Add(m_TextHelpModulesFileName, 0, wxGROW|wxLEFT|wxRIGHT|wxBOTTOM, 5); + m_TextHelpModulesFileName = + new wxTextCtrl( itemDialog1, ID_TEXTCTRL1, _T( + "" ), wxDefaultPosition, wxDefaultSize, 0 ); + itemBoxSizer2->Add( m_TextHelpModulesFileName, + 0, + wxGROW | wxLEFT | wxRIGHT | wxBOTTOM, + 5 ); // Set validators - m_TextLibDir->SetValidator( wxTextValidator(wxFILTER_NONE, & g_UserLibDirBuffer) ); + m_TextLibDir->SetValidator( wxTextValidator( wxFILTER_NONE, + &g_UserLibDirBuffer ) ); + ////@end KiConfigPcbnewFrame content construction -wxString msg = _("Board ext: ") + PcbExtBuffer; - wxStaticText * text = new wxStaticText( itemDialog1, -1, msg, wxDefaultPosition, wxDefaultSize, 0 ); - m_FileExtList->Add(text, 0, wxALIGN_LEFT|wxLEFT|wxRIGHT|wxADJUST_MINSIZE, 5); + wxString msg = _( "Board ext: " ) + PcbExtBuffer; + wxStaticText* text = new wxStaticText( itemDialog1, + -1, + msg, + wxDefaultPosition, + wxDefaultSize, + 0 ); + m_FileExtList->Add( text, + 0, + wxALIGN_LEFT | wxLEFT | wxRIGHT | wxADJUST_MINSIZE, + 5 ); - msg = _("Cmp ext: ") + NetCmpExtBuffer; - text = new wxStaticText( itemDialog1, -1, msg, wxDefaultPosition, wxDefaultSize, 0 ); - m_FileExtList->Add(text, 0, wxALIGN_LEFT|wxLEFT|wxRIGHT|wxADJUST_MINSIZE, 5); + msg = _( "Cmp ext: " ) + NetCmpExtBuffer; + text = new wxStaticText( itemDialog1, + -1, + msg, + wxDefaultPosition, + wxDefaultSize, + 0 ); + m_FileExtList->Add( text, + 0, + wxALIGN_LEFT | wxLEFT | wxRIGHT | wxADJUST_MINSIZE, + 5 ); - msg = _("Lib ext: ") + LibExtBuffer; - text = new wxStaticText( itemDialog1, -1, msg, wxDefaultPosition, wxDefaultSize, 0 ); - m_FileExtList->Add(text, 0, wxALIGN_LEFT|wxLEFT|wxRIGHT|wxADJUST_MINSIZE, 5); + msg = _( "Lib ext: " ) + ModuleFileExtension; + text = new wxStaticText( itemDialog1, + -1, + msg, + wxDefaultPosition, + wxDefaultSize, + 0 ); + m_FileExtList->Add( text, + 0, + wxALIGN_LEFT | wxLEFT | wxRIGHT | wxADJUST_MINSIZE, + 5 ); - msg = _("Net ext: ") + NetExtBuffer; - text = new wxStaticText( itemDialog1, -1, msg, wxDefaultPosition, wxDefaultSize, 0 ); - m_FileExtList->Add(text, 0, wxALIGN_LEFT|wxLEFT|wxRIGHT|wxADJUST_MINSIZE, 5); + msg = _( "Net ext: " ) + NetExtBuffer; + text = new wxStaticText( itemDialog1, + -1, + msg, + wxDefaultPosition, + wxDefaultSize, + 0 ); + m_FileExtList->Add( text, + 0, + wxALIGN_LEFT | wxLEFT | wxRIGHT | wxADJUST_MINSIZE, + 5 ); } + /*! * wxEVT_CLOSE_WINDOW event handler for ID_DIALOG */ void KiConfigPcbnewFrame::OnCloseWindow( wxCloseEvent& event ) { - SetNewOptions(); - EndModal(0); + SetNewOptions(); + EndModal( 0 ); } + /*! * wxEVT_COMMAND_BUTTON_CLICKED event handler for SAVE_CFG */ void KiConfigPcbnewFrame::OnSaveCfgClick( wxCommandEvent& event ) { - SetNewOptions(); - m_Parent->Update_config(this); + SetNewOptions(); + m_Parent->Update_config( this ); } @@ -249,27 +367,30 @@ void KiConfigPcbnewFrame::OnSaveCfgClick( wxCommandEvent& event ) void KiConfigPcbnewFrame::OnDelLibClick( wxCommandEvent& event ) { - LibDelFct(event); + LibDelFct( event ); } + /*! * wxEVT_COMMAND_BUTTON_CLICKED event handler for ADD_LIB */ void KiConfigPcbnewFrame::OnAddLibClick( wxCommandEvent& event ) { - LibInsertFct(event); + LibInsertFct( event ); } + /*! * wxEVT_COMMAND_BUTTON_CLICKED event handler for INSERT_LIB */ void KiConfigPcbnewFrame::OnInsertLibClick( wxCommandEvent& event ) { - LibInsertFct(event); + LibInsertFct( event ); } + /*! * Should we show tooltips? */ @@ -279,6 +400,7 @@ bool KiConfigPcbnewFrame::ShowToolTips() return true; } + /*! * Get bitmap resources */ @@ -287,11 +409,13 @@ wxBitmap KiConfigPcbnewFrame::GetBitmapResource( const wxString& name ) { // Bitmap retrieval ////@begin KiConfigPcbnewFrame bitmap retrieval - wxUnusedVar(name); + wxUnusedVar( name ); return wxNullBitmap; + ////@end KiConfigPcbnewFrame bitmap retrieval } + /*! * Get icon resources */ @@ -300,93 +424,103 @@ wxIcon KiConfigPcbnewFrame::GetIconResource( const wxString& name ) { // Icon retrieval ////@begin KiConfigPcbnewFrame icon retrieval - wxUnusedVar(name); + wxUnusedVar( name ); return wxNullIcon; + ////@end KiConfigPcbnewFrame icon retrieval } + /********************************************/ void KiConfigPcbnewFrame::SetNewOptions() /********************************************/ { - g_UserLibDirBuffer = m_TextLibDir->GetValue(); - wxGetApp().m_EDA_CommonConfig->Write( wxT("module_doc_file"), - m_TextHelpModulesFileName->GetValue()); - SetRealLibraryPath( wxT("modules") ); + wxConfig* cfg = wxGetApp().m_EDA_CommonConfig; + + g_UserLibDirBuffer = m_TextLibDir->GetValue(); + cfg->Write( wxT( "module_doc_file" ), + m_TextHelpModulesFileName->GetValue() ); } /********************************************************/ -void KiConfigPcbnewFrame::LibDelFct(wxCommandEvent& event) +void KiConfigPcbnewFrame::LibDelFct( wxCommandEvent& event ) /********************************************************/ { -int ii; + int ii; - ii = m_ListLibr->GetSelection(); - if ( ii < 0 ) return; - - g_LibName_List.RemoveAt(ii); - - m_ListLibr->Clear(); - m_ListLibr->InsertItems(g_LibName_List, 0); - m_LibModified = TRUE; -} - - -/*************************************************************/ -void KiConfigPcbnewFrame::LibInsertFct(wxCommandEvent& event) -/*************************************************************/ -/* Insert or add a library to the existing library list: - New library is put in list before (insert) or after (add) - the selection -*/ -{ -int ii; -wxString fullfilename, ShortLibName; -wxString mask = wxT("*"); - - ii = m_ListLibr->GetSelection(); - if ( ii < 0 ) ii = 0; - if( event.GetId() == ADD_LIB) - { - if( g_LibName_List.GetCount() != 0 ) ii ++; /* Add after selection */ - } - - SetNewOptions(); - mask += LibExtBuffer; - g_RealLibDirBuffer.Replace( wxT("\\"), wxT("/")); - - wxFileDialog FilesDialog(this, _("Library files:"), g_RealLibDirBuffer, - wxEmptyString, mask, - wxFD_DEFAULT_STYLE | wxFD_MULTIPLE); - - int diag = FilesDialog.ShowModal(); - if ( diag != wxID_OK ) + ii = m_ListLibr->GetSelection(); + if( ii < 0 ) return; - wxArrayString Filenames; - FilesDialog.GetPaths(Filenames); + g_LibName_List.RemoveAt( ii ); - for ( unsigned jj = 0; jj < Filenames.GetCount(); jj ++ ) - { - fullfilename = Filenames[jj]; - ShortLibName = - MakeReducedFileName(fullfilename, g_RealLibDirBuffer, LibExtBuffer); - - //Add or insert new library name - if ( g_LibName_List.Index(ShortLibName) == wxNOT_FOUND) - { - m_LibModified = TRUE; - g_LibName_List.Insert(ShortLibName, ii); - m_ListLibr->Clear(); - m_ListLibr->InsertItems(g_LibName_List, 0); - } - else - { - wxString msg; - msg << wxT("<") << ShortLibName << wxT("> : ") << _("Library already in use"); - DisplayError(this, msg); - } - } + m_ListLibr->Clear(); + m_ListLibr->InsertItems( g_LibName_List, 0 ); + m_LibModified = TRUE; } + +/*************************************************************/ +void KiConfigPcbnewFrame::LibInsertFct( wxCommandEvent& event ) +/*************************************************************/ + +/* Insert or add a library to the existing library list: + * New library is put in list before (insert) or after (add) + * the selection + */ +{ + int ii; + wxFileName fn; + wxString tmp; + + ii = m_ListLibr->GetSelection(); + if( ii < 0 ) + ii = 0; + if( event.GetId() == ADD_LIB ) + { + if( g_LibName_List.GetCount() != 0 ) + ii++; /* Add after selection */ + } + + SetNewOptions(); + g_RealLibDirBuffer.Replace( wxT( "\\" ), wxT( "/" ) ); + + wxFileDialog FilesDialog( this, _( "Foot Print Library Files" ), + g_RealLibDirBuffer, wxEmptyString, + ModuleFileWildcard, wxFD_OPEN | wxFD_MULTIPLE ); + + if( FilesDialog.ShowModal() != wxID_OK ) + return; + + wxArrayString Filenames; + FilesDialog.GetPaths( Filenames ); + + for( unsigned jj = 0; jj < Filenames.GetCount(); jj++ ) + { + fn = Filenames[jj]; + + /* If the library path is already in the library search paths + * list, just add the library name to the list. Otherwise, add + * the library name with the full path. */ + if( wxGetApp().GetLibraryPathList().Index( fn.GetPath() ) == wxNOT_FOUND ) + tmp = fn.GetPathWithSep() + fn.GetName(); + else + tmp = fn.GetName(); + + // Add or insert new library name. + if( g_LibName_List.Index( tmp ) == wxNOT_FOUND ) + { + m_LibModified = TRUE; + g_LibName_List.Insert( tmp, ii++ ); + m_ListLibr->Clear(); + m_ListLibr->InsertItems( g_LibName_List, 0 ); + } + else + { + wxString msg = wxT( "<" ) + tmp + wxT( "> : " ) + + _( "Library already in use" ); + DisplayError( this, msg ); + } + } +} diff --git a/pcbnew/drag.h b/pcbnew/drag.h index 568d1be816..050a9910c8 100644 --- a/pcbnew/drag.h +++ b/pcbnew/drag.h @@ -29,8 +29,8 @@ public: /* Variables */ -eda_global DRAG_SEGM* g_DragSegmentList; /* pointe le debut de la liste - * des structures DRAG_SEGM */ +extern DRAG_SEGM* g_DragSegmentList; /* pointe le debut de la liste + * des structures DRAG_SEGM */ /* routines specifiques */ void Dessine_Segments_Dragges( WinEDA_DrawPanel* panel, wxDC* DC ); diff --git a/pcbnew/dragsegm.cpp b/pcbnew/dragsegm.cpp index 9a28151370..b6a231e757 100644 --- a/pcbnew/dragsegm.cpp +++ b/pcbnew/dragsegm.cpp @@ -15,7 +15,9 @@ #include "drag.h" -/* fonctions locales */ + +DRAG_SEGM* g_DragSegmentList = NULL; /* pointe le debut de la liste + * des structures DRAG_SEGM */ DRAG_SEGM::DRAG_SEGM( TRACK* segm ) { diff --git a/pcbnew/edit.cpp b/pcbnew/edit.cpp index f2ed3ca934..b79dc41a9b 100644 --- a/pcbnew/edit.cpp +++ b/pcbnew/edit.cpp @@ -8,10 +8,10 @@ #include "confirm.h" #include "eda_doc.h" #include "gestfich.h" +#include "id.h" + #include "pcbnew.h" #include "autorout.h" - -#include "id.h" #include "protos.h" // Uncomment following line to enable wxBell() command (which beeps speaker) @@ -1028,9 +1028,10 @@ void WinEDA_PcbFrame::Process_Special_Functions( wxCommandEvent& event ) case ID_POPUP_PCB_DISPLAY_FOOTPRINT_DOC: { + wxConfig* cfg = wxGetApp().m_EDA_CommonConfig; wxString msg = FindKicadHelpPath(); - msg += wxGetApp().m_EDA_CommonConfig->Read( wxT( "module_doc_file" ), - wxT( "pcbnew/footprints.pdf" ) ); + msg += cfg->Read( wxT( "module_doc_file" ), + wxT( "pcbnew/footprints.pdf" ) ); GetAssociatedDocument( this, wxEmptyString, msg ); } break; diff --git a/pcbnew/editrack-part2.cpp b/pcbnew/editrack-part2.cpp index cc41e6c144..2d3b9a50e3 100644 --- a/pcbnew/editrack-part2.cpp +++ b/pcbnew/editrack-part2.cpp @@ -168,7 +168,7 @@ bool WinEDA_PcbFrame::Other_Layer_Route( TRACK* aTrack, wxDC* DC ) else ((PCB_SCREEN*)GetScreen())->m_Active_Layer = ((PCB_SCREEN*)GetScreen())->m_Route_Layer_BOTTOM; - Affiche_Status_Box(); + UpdateStatusBar(); SetToolbars(); return true; } @@ -307,7 +307,7 @@ bool WinEDA_PcbFrame::Other_Layer_Route( TRACK* aTrack, wxDC* DC ) DrawPanel->ManageCurseur( DrawPanel, DC, FALSE ); via->Display_Infos( this ); - Affiche_Status_Box(); + UpdateStatusBar(); SetToolbars(); diff --git a/pcbnew/editrack.cpp b/pcbnew/editrack.cpp index 7de68e0274..e940849bbe 100644 --- a/pcbnew/editrack.cpp +++ b/pcbnew/editrack.cpp @@ -646,8 +646,8 @@ static void PushTrack( WinEDA_DrawPanel* panel ) n.y = vec.x; } f = dist / hypot( double(n.x), double(n.y) ); - n.x = (int) round( f * n.x ); - n.y = (int) round( f * n.y ); + n.x = wxRound( f * n.x ); + n.y = wxRound( f * n.y ); Project( &track->m_End, cursor, other ); track->m_End += n; diff --git a/pcbnew/export_gencad.cpp b/pcbnew/export_gencad.cpp index 36f1ef17ad..a42660fef1 100644 --- a/pcbnew/export_gencad.cpp +++ b/pcbnew/export_gencad.cpp @@ -7,6 +7,7 @@ #include "class_drawpanel.h" #include "confirm.h" #include "gestfich.h" +#include "appl_wxstruct.h" #include "pcbnew.h" #include "trigo.h" @@ -62,28 +63,24 @@ void WinEDA_PcbFrame::ExportToGenCAD( wxCommandEvent& event ) * Exporte le board au format GenCAD 1.4 */ { - wxString FullFileName = GetScreen()->m_FileName; - wxString msg, std_ext, mask; + wxFileName fn = GetScreen()->m_FileName; + wxString msg, ext, wildcard; FILE* file; - std_ext = wxT( ".gcd" ); - mask = wxT( "*" ) + std_ext; - ChangeFileNameExt( FullFileName, std_ext ); - FullFileName = EDA_FileSelector( _( "GenCAD file:" ), - wxEmptyString, /* Chemin par defaut */ - FullFileName, /* nom fichier par defaut */ - std_ext, /* extension par defaut */ - mask, /* Masque d'affichage */ - this, - wxFD_SAVE, - FALSE - ); - if( FullFileName == wxEmptyString ) + ext = wxT( "gcd" ); + wildcard = _( "GenCAD board files (.gcd)|*.gcd" ); + fn.SetExt( ext ); + + wxFileDialog dlg( this, _( "Save GenCAD Board File" ), wxEmptyString, + fn.GetFullName(), wildcard, + wxFD_SAVE | wxFD_OVERWRITE_PROMPT ); + + if( dlg.ShowModal() == wxID_CANCEL ) return; - if( ( file = wxFopen( FullFileName, wxT( "wt" ) ) ) == NULL ) + if( ( file = wxFopen( dlg.GetPath(), wxT( "wt" ) ) ) == NULL ) { - msg = _( "Unable to create " ) + FullFileName; + msg = _( "Unable to create " ) + dlg.GetPath(); DisplayError( this, msg ); return; } @@ -493,7 +490,8 @@ bool CreateHeaderInfoData( FILE* file, WinEDA_PcbFrame* frame ) fputs( "$HEADER\n", file ); fputs( "GENCAD 1.4\n", file ); - msg = wxT( "USER " ) + g_Main_Title + wxT( " " ) + GetBuildVersion(); + msg = wxT( "USER " ) + wxGetApp().GetAppName() + wxT( " " ) + + GetBuildVersion(); fputs( CONV_TO_UTF8( msg ), file ); fputs( "\n", file ); msg = wxT( "DRAWING " ) + screen->m_FileName; fputs( CONV_TO_UTF8( msg ), file ); fputs( "\n", file ); diff --git a/pcbnew/files.cpp b/pcbnew/files.cpp index 0b9fab9074..2f06d84395 100644 --- a/pcbnew/files.cpp +++ b/pcbnew/files.cpp @@ -67,35 +67,39 @@ void WinEDA_PcbFrame::Files_io( wxCommandEvent& event ) case ID_MENU_READ_LAST_SAVED_VERSION_BOARD: case ID_MENU_RECOVER_BOARD: + { + wxFileName fn; + + if( id == ID_MENU_RECOVER_BOARD ) { - wxString filename, oldfilename = GetScreen()->m_FileName; - if( id == ID_MENU_RECOVER_BOARD ) - { - filename = g_SaveFileName + PcbExtBuffer; - } - else - { - filename = oldfilename; - ChangeFileNameExt( filename, wxT( ".000" ) ); - } - if( !wxFileExists( filename ) ) - { - msg = _( "Recovery file " ) + filename + _( " not found" ); - DisplayInfo( this, msg ); - break; - } - else - { - msg = _( "Ok to load Recovery file " ) + filename; - if( !IsOK( this, msg ) ) - break; - } - LoadOnePcbFile( filename, false ); - GetScreen()->m_FileName = oldfilename; - SetTitle( GetScreen()->m_FileName ); - ReCreateAuxiliaryToolbar(); + fn = wxFileName( wxEmptyString, g_SaveFileName, PcbExtBuffer ); } + else + { + fn = GetScreen()->m_FileName; + fn.SetExt( wxT( "000" ) ); + } + + if( !fn.FileExists() ) + { + msg = _( "Recovery file " ) + fn.GetFullPath() + _( " not found" ); + DisplayInfo( this, msg ); + break; + } + else + { + msg = _( "Ok to load Recovery file " ) + fn.GetFullPath(); + if( !IsOK( this, msg ) ) + break; + } + + LoadOnePcbFile( fn.GetFullPath(), false ); + fn.SetExt( PcbExtBuffer ); + GetScreen()->m_FileName = fn.GetFullPath(); + SetTitle( GetScreen()->m_FileName ); + ReCreateAuxiliaryToolbar(); break; + } case ID_MENU_APPEND_FILE: case ID_APPEND_FILE: @@ -289,8 +293,8 @@ bool WinEDA_PcbFrame::SavePcbFile( const wxString& FileName ) /* Write the board file */ { - wxString BackupFileName; - wxString FullFileName; + wxFileName backupFileName; + wxFileName pcbFileName; wxString upperTxt; wxString lowerTxt; wxString msg; @@ -300,21 +304,14 @@ bool WinEDA_PcbFrame::SavePcbFile( const wxString& FileName ) if( FileName == wxEmptyString ) { - msg = wxT( "*" ) + PcbExtBuffer; + wxFileDialog dlg( this, _( "Save Board File" ), wxEmptyString, + GetScreen()->m_FileName, BoardFileWildcard, + wxFD_SAVE | wxFD_OVERWRITE_PROMPT ); - FullFileName = EDA_FileSelector( _( "Save board files:" ), - wxEmptyString, /* Chemin par defaut */ - GetScreen()->m_FileName, /* nom fichier par defaut */ - PcbExtBuffer, /* extension par defaut */ - msg, /* Masque d'affichage */ - this, - wxFD_SAVE, - FALSE - ); - if( FullFileName == wxEmptyString ) - return FALSE; + if( dlg.ShowModal() == wxID_CANCEL ) + return false; - GetScreen()->m_FileName = FullFileName; + GetScreen()->m_FileName = dlg.GetPath(); } else GetScreen()->m_FileName = FileName; @@ -325,45 +322,47 @@ bool WinEDA_PcbFrame::SavePcbFile( const wxString& FileName ) GetScreen()->m_Date = GenDate(); } - /* Get the filename */ - FullFileName = MakeFileName( wxEmptyString, GetScreen()->m_FileName, PcbExtBuffer ); + pcbFileName = GetScreen()->m_FileName; /* Get the backup file name */ - BackupFileName = FullFileName; - ChangeFileNameExt( BackupFileName, wxT( ".000" ) ); + backupFileName = pcbFileName; + backupFileName.SetExt( wxT( "000" ) ); /* If an old backup file exists, delete it. if an old board file existes, rename it to the backup file name */ - if( wxFileExists( FullFileName ) ) + if( backupFileName.FileExists() ) { /* rename the "old" file" from xxx.brd to xxx.000 */ - wxRemoveFile( BackupFileName ); /* Remove the old file xxx.000 (if exists) */ - if( !wxRenameFile( FullFileName, BackupFileName ) ) + wxRemoveFile( backupFileName.GetFullPath() ); /* Remove the old file xxx.000 (if exists) */ + if( !wxRenameFile( pcbFileName.GetFullPath(), + backupFileName.GetFullPath() ) ) { - msg = _( "Warning: unable to create bakfile " ) + BackupFileName; + msg = _( "Warning: unable to create backup file " ) + + backupFileName.GetFullPath(); DisplayError( this, msg, 15 ); saveok = FALSE; } } else { - BackupFileName = wxEmptyString; + backupFileName.Clear(); saveok = FALSE; } /* Create the file */ - dest = wxFopen( FullFileName, wxT( "wt" ) ); + dest = wxFopen( pcbFileName.GetFullPath(), wxT( "wt" ) ); + if( dest == 0 ) { - msg = _( "Unable to create " ) + FullFileName; + msg = _( "Unable to create " ) + pcbFileName.GetFullPath(); DisplayError( this, msg ); saveok = FALSE; } if( dest ) { - GetScreen()->m_FileName = FullFileName; + GetScreen()->m_FileName = pcbFileName.GetFullPath(); SetTitle( GetScreen()->m_FileName ); SavePcbFormatAscii( dest ); @@ -375,14 +374,14 @@ bool WinEDA_PcbFrame::SavePcbFile( const wxString& FileName ) if( saveok ) { - upperTxt = _( "Backup file: " ) + BackupFileName; + upperTxt = _( "Backup file: " ) + backupFileName.GetFullPath(); } if( dest ) lowerTxt = _( "Wrote board file: " ); else lowerTxt = _( "Failed to create " ); - lowerTxt += FullFileName; + lowerTxt += pcbFileName.GetFullPath(); Affiche_1_Parametre( this, 1, upperTxt, lowerTxt, CYAN ); diff --git a/pcbnew/gen_modules_placefile.cpp b/pcbnew/gen_modules_placefile.cpp index da54d2f768..90c8b45fae 100644 --- a/pcbnew/gen_modules_placefile.cpp +++ b/pcbnew/gen_modules_placefile.cpp @@ -13,6 +13,7 @@ #include "gestfich.h" #include "pcbnew.h" #include "trigo.h" +#include "appl_wxstruct.h" class LIST_MOD /* Permet de lister les elements utiles des modules */ { @@ -75,9 +76,8 @@ void WinEDA_PcbFrame::GenModulesPosition( wxCommandEvent& event ) LIST_MOD* Liste = 0; char line[1024]; char Buff[80]; - wxString fnFront; - wxString fnBack; - wxString extension; + wxFileName fnFront; + wxFileName fnBack; wxString msg; wxString frontLayerName; wxString backLayerName; @@ -135,16 +135,14 @@ void WinEDA_PcbFrame::GenModulesPosition( wxCommandEvent& event ) } fnFront = GetScreen()->m_FileName; - frontLayerName = GetBoard()->GetLayerName( CMP_N ); - extension.Printf( wxT("-%s.pos"), frontLayerName.GetData() ); + fnFront.SetName( fnFront.GetName() + frontLayerName.GetData() ); + fnFront.SetExt( wxT( "pos") ); - ChangeFileNameExt( fnFront, extension ); - - fpFront = wxFopen( fnFront, wxT( "wt" ) ); + fpFront = wxFopen( fnFront.GetFullPath(), wxT( "wt" ) ); if( fpFront == 0 ) { - msg = _( "Unable to create " ) + fnFront; + msg = _( "Unable to create " ) + fnFront.GetFullPath(); DisplayError( this, msg ); goto exit; } @@ -152,15 +150,15 @@ void WinEDA_PcbFrame::GenModulesPosition( wxCommandEvent& event ) if( doBoardBack ) { fnBack = GetScreen()->m_FileName; - backLayerName = GetBoard()->GetLayerName( COPPER_LAYER_N ); - extension.Printf( wxT("-%s.pos"), backLayerName.GetData() ); + fnBack.SetName( fnBack.GetName() + backLayerName.GetData() ); + fnBack.SetExt( wxT( "pos" ) ); + + fpBack = wxFopen( fnBack.GetFullPath(), wxT( "wt" ) ); - ChangeFileNameExt( fnBack, extension ); - fpBack = wxFopen( fnBack, wxT( "wt" ) ); if( fpBack == 0 ) { - msg = _( "Unable to create " ) + fnBack; + msg = _( "Unable to create " ) + fnBack.GetFullPath(); DisplayError( this, msg ); goto exit; } @@ -172,10 +170,12 @@ void WinEDA_PcbFrame::GenModulesPosition( wxCommandEvent& event ) /* Affichage du bilan : */ MsgPanel->EraseMsgBox(); - Affiche_1_Parametre( this, 0, _( "Component side place file:" ), fnFront, BLUE ); + Affiche_1_Parametre( this, 0, _( "Component side place file:" ), + fnFront.GetFullPath(), BLUE ); if( doBoardBack ) - Affiche_1_Parametre( this, 32, _( "Copper side place file:" ), fnBack, BLUE ); + Affiche_1_Parametre( this, 32, _( "Copper side place file:" ), + fnBack.GetFullPath(), BLUE ); msg.Empty(); msg << moduleCount; Affiche_1_Parametre( this, 65, _( "Module count" ), msg, RED ); @@ -207,7 +207,7 @@ void WinEDA_PcbFrame::GenModulesPosition( wxCommandEvent& event ) if( doBoardBack ) fputs( line, fpBack ); - Title = g_Main_Title + wxT( " " ) + GetBuildVersion(); + Title = wxGetApp().GetAppName() + wxT( " " ) + GetBuildVersion(); sprintf( line, "### Printed by PcbNew version %s\n", CONV_TO_UTF8( Title ) ); fputs( line, fpFront ); if( doBoardBack ) @@ -275,10 +275,11 @@ void WinEDA_PcbFrame::GenModulesPosition( wxCommandEvent& event ) if( doBoardBack ) fputs( "## End\n", fpBack ); - msg = frontLayerName + wxT( " File: " ) + fnFront; + msg = frontLayerName + wxT( " File: " ) + fnFront.GetFullPath(); if( doBoardBack ) - msg += wxT("\n\n") + backLayerName + wxT( " File: " ) + fnBack; + msg += wxT("\n\n") + backLayerName + wxT( " File: " ) + + fnBack.GetFullPath(); DisplayInfo( this, msg ); @@ -310,7 +311,8 @@ void WinEDA_PcbFrame::GenModuleReport( wxCommandEvent& event ) MODULE* Module; D_PAD* pad; char line[1024], Buff[80]; - wxString FullFileName, fnFront, msg; + wxFileName fn; + wxString fnFront, msg; FILE* rptfile; wxPoint module_pos; @@ -322,14 +324,15 @@ void WinEDA_PcbFrame::GenModuleReport( wxCommandEvent& event ) File_Place_Offset = wxPoint( 0, 0 ); /* Init nom fichier */ - FullFileName = GetScreen()->m_FileName; - ChangeFileNameExt( FullFileName, wxT( ".rpt" ) ); + fn = GetScreen()->m_FileName; + fn.SetExt( wxT( "rpt" ) ); - rptfile = wxFopen( FullFileName, wxT( "wt" ) ); + rptfile = wxFopen( fn.GetFullPath(), wxT( "wt" ) ); if( rptfile == NULL ) { - msg = _( "Unable to create " ) + FullFileName; - DisplayError( this, msg ); return; + msg = _( "Unable to create " ) + fn.GetFullPath(); + DisplayError( this, msg ); + return; } // Switch the locale to standard C (needed to print floating point numbers like 1.3) @@ -339,7 +342,7 @@ void WinEDA_PcbFrame::GenModuleReport( wxCommandEvent& event ) sprintf( line, "## Module report - date %s\n", DateAndTime( Buff ) ); fputs( line, rptfile ); - wxString Title = g_Main_Title + wxT( " " ) + GetBuildVersion(); + wxString Title = wxGetApp().GetAppName() + wxT( " " ) + GetBuildVersion(); sprintf( line, "## Created by PcbNew version %s\n", CONV_TO_UTF8( Title ) ); fputs( line, rptfile ); fputs( "## Unit = inches, Angle = deg.\n", rptfile ); diff --git a/pcbnew/gendrill.cpp b/pcbnew/gendrill.cpp index d5149fe656..02da3687ca 100644 --- a/pcbnew/gendrill.cpp +++ b/pcbnew/gendrill.cpp @@ -18,9 +18,14 @@ using namespace std; #include "pcbnew.h" #include "pcbplot.h" #include "macros.h" +#include "appl_wxstruct.h" #include "gendrill.h" +const wxString DrillFileExtension( wxT( "drl" ) ); + +const wxString DrillFileWildcard( _( "Drill files (*.drl)|*.drl" ) ); + /* * Creates the drill files in EXCELLON format * Number format: @@ -211,7 +216,7 @@ void WinEDA_PcbFrame::InstallDrillFrame( wxCommandEvent& event ) /* This function displays and deletes the dialog frame for drill tools */ { - wxConfig* Config = wxGetApp().m_EDA_Config; + wxConfig* Config = wxGetApp().m_EDA_Config; if( Config ) { @@ -225,8 +230,8 @@ void WinEDA_PcbFrame::InstallDrillFrame( wxCommandEvent& event ) } WinEDA_DrillFrame* frame = new WinEDA_DrillFrame( this ); - - frame->ShowModal(); frame->Destroy(); + frame->ShowModal(); + frame->Destroy(); } @@ -238,6 +243,7 @@ void WinEDA_DrillFrame::UpdateConfig() SetParams(); wxConfig* Config = wxGetApp().m_EDA_Config; + if( Config ) { Config->Write( ZerosFormatKey, s_Zeros_Format ); @@ -264,8 +270,7 @@ void WinEDA_DrillFrame::GenDrillFiles( wxCommandEvent& event ) * And one file per layer pair, which have one or more holes, excluding through holes, already in the first file. */ { - wxString FullFileName, Mask( wxT( "*" ) ), Ext( wxT( ".drl" ) ); - wxString BaseFileName; + wxFileName fn; wxString layer_extend; // added to the Board FileName to create FullFileName (= Board FileName + layer pair names) wxString msg; bool ExistsBuriedVias = false; // If true, drill files are created layer pair by layer pair for buried vias @@ -285,15 +290,17 @@ void WinEDA_DrillFrame::GenDrillFiles( wxCommandEvent& event ) if( m_MicroViasCount || m_BlindOrBuriedViasCount ) ExistsBuriedVias = true; - Mask += Ext; for( ; ; ) { - Build_Holes_List( m_Parent->GetBoard(), s_HoleListBuffer, s_ToolListBuffer, - layer1, layer2, gen_through_holes ? false : true ); + Build_Holes_List( m_Parent->GetBoard(), s_HoleListBuffer, + s_ToolListBuffer, layer1, layer2, + gen_through_holes ? false : true ); + if( s_ToolListBuffer.size() > 0 ) //holes? { - FullFileName = m_Parent->GetScreen()->m_FileName; + fn = m_Parent->GetScreen()->m_FileName; layer_extend.Empty(); + if( !gen_through_holes ) { if( layer1 == COPPER_LAYER_N ) @@ -305,67 +312,67 @@ void WinEDA_DrillFrame::GenDrillFiles( wxCommandEvent& event ) else layer_extend << wxT( "-inner" ) << layer2; } - layer_extend << Ext; - ChangeFileNameExt( FullFileName, layer_extend ); - FullFileName = EDA_FileSelector( _( "Drill file" ), - wxEmptyString, /* Chemin par defaut */ - FullFileName, /* nom fichier par defaut */ - Ext, /* extension par defaut */ - Mask, /* Masque d'affichage */ - this, - wxFD_SAVE, - TRUE - ); + fn.SetName( fn.GetName() + layer_extend ); + fn.SetExt( DrillFileExtension ); - if( FullFileName != wxEmptyString ) + wxFileDialog dlg( this, _( "Save Drill File" ), wxEmptyString, + fn.GetFullName(), DrillFileWildcard, + wxFD_SAVE | wxFD_OVERWRITE_PROMPT ); + + if( dlg.ShowModal() == wxID_CANCEL ) + continue; + + dest = wxFopen( dlg.GetPath(), wxT( "w" ) ); + + if( dest == 0 ) { - dest = wxFopen( FullFileName, wxT( "w" ) ); - if( dest == 0 ) - { - msg = _( "Unable to create file " ) + FullFileName; - DisplayError( this, msg ); - EndModal( 0 ); - return; - } - - Create_Drill_File_EXCELLON( s_HoleListBuffer, s_ToolListBuffer ); + msg = _( "Unable to create file " ) + dlg.GetPath(); + DisplayError( this, msg ); + EndModal( 0 ); + return; } + Create_Drill_File_EXCELLON( s_HoleListBuffer, s_ToolListBuffer ); + switch( m_Choice_Drill_Map->GetSelection() ) { case 0: break; case 1: - GenDrillMap( FullFileName, s_HoleListBuffer, s_ToolListBuffer, PLOT_FORMAT_HPGL ); + GenDrillMap( dlg.GetPath(), s_HoleListBuffer, s_ToolListBuffer, + PLOT_FORMAT_HPGL ); break; case 2: - GenDrillMap( FullFileName, s_HoleListBuffer, s_ToolListBuffer, PLOT_FORMAT_POST ); + GenDrillMap( dlg.GetPath(), s_HoleListBuffer, s_ToolListBuffer, + PLOT_FORMAT_POST ); break; } - if( !ExistsBuriedVias ) + if( !ExistsBuriedVias ) break; } if( gen_through_holes ) layer2 = layer1 + 1; else { - if( layer2 >= LAYER_CMP_N ) // no more layer pair to consider + if( layer2 >= LAYER_CMP_N ) // no more layer pair to consider break; - layer1++; layer2++; // use next layer pair - if( layer2 == g_DesignSettings.m_CopperLayerCount - 1 ) // The last layer is reached - layer2 = LAYER_CMP_N; // the last layer is always the component layer + layer1++; + layer2++; // use next layer pair + + if( layer2 == g_DesignSettings.m_CopperLayerCount - 1 ) + layer2 = LAYER_CMP_N; // the last layer is always the component layer } + gen_through_holes = false; } if( m_Choice_Drill_Report->GetSelection() > 0 ) { - FullFileName = m_Parent->GetScreen()->m_FileName; - GenDrillReport( FullFileName ); + GenDrillReport( m_Parent->GetScreen()->m_FileName ); } @@ -578,7 +585,7 @@ void Gen_Line_EXCELLON( char* line, float x, float y ) x *= 10; y *= 10; } - sprintf( line, "X%dY%d\n", (int) round( x ), (int) round( y ) ); + sprintf( line, "X%dY%d\n", wxRound( x ), wxRound( y ) ); break; case SUPPRESS_TRAILING: @@ -593,8 +600,8 @@ void Gen_Line_EXCELLON( char* line, float x, float y ) if( y<0 ) ypad++; - xs.Printf( wxT( "%0*d" ), xpad, (int) round( x ) ); - ys.Printf( wxT( "%0*d" ), ypad, (int) round( y ) ); + xs.Printf( wxT( "%0*d" ), xpad, wxRound( x ) ); + ys.Printf( wxT( "%0*d" ), ypad, wxRound( y ) ); size_t j = xs.Len() - 1; while( xs[j] == '0' && j ) @@ -618,8 +625,8 @@ void Gen_Line_EXCELLON( char* line, float x, float y ) xpad++; if( y<0 ) ypad++; - xs.Printf( wxT( "%0*d" ), xpad, (int) round( x ) ); - ys.Printf( wxT( "%0*d" ), ypad, (int) round( y ) ); + xs.Printf( wxT( "%0*d" ), xpad, wxRound( x ) ); + ys.Printf( wxT( "%0*d" ), ypad, wxRound( y ) ); sprintf( line, "X%sY%s\n", CONV_TO_UTF8( xs ), CONV_TO_UTF8( ys ) ); break; } @@ -652,7 +659,7 @@ void WinEDA_DrillFrame::Write_Excellon_Header( FILE* aFile ) int ii = m_Choice_Zeros_Format->GetSelection(); DateAndTime( Line ); // The next 2 lines in EXCELLON files are comments: - wxString msg = g_Main_Title + wxT( " " ) + GetBuildVersion(); + wxString msg = wxGetApp().GetTitle() + wxT( " " ) + GetBuildVersion(); fprintf( aFile, ";DRILL file {%s} date %s\n", CONV_TO_UTF8( msg ), Line ); msg = wxT( ";FORMAT={" ); // Print precision: @@ -726,18 +733,21 @@ void WinEDA_DrillFrame::GenDrillMap( const wxString aFileName, /* Genere le plan de percage (Drill map) format HPGL ou POSTSCRIPT */ { - wxString FullFileName, Mask( wxT( "*" ) ), Ext; + wxFileName fn; + wxString ext, wildcard; wxString msg; /* Init extension */ switch( format ) { case PLOT_FORMAT_HPGL: - Ext = wxT( "-drl.plt" ); + ext = wxT( "plt" ); + wildcard = _( "HPGL plot files (.plt)|*.plt" ); break; case PLOT_FORMAT_POST: - Ext = wxT( "-drl.ps" ); + ext = wxT( "ps" ); + wildcard = _( "PostScript files (.ps)|*.ps" ); break; default: @@ -746,38 +756,35 @@ void WinEDA_DrillFrame::GenDrillMap( const wxString aFileName, } /* Init file name */ - FullFileName = aFileName; - ChangeFileNameExt( FullFileName, Ext ); - Mask += Ext; + fn = aFileName; + fn.SetName( fn.GetName() + wxT( "-drl" ) ); + fn.SetExt( ext ); - FullFileName = EDA_FileSelector( _( "Drill Map file" ), - wxEmptyString, /* Chemin par defaut */ - FullFileName, /* nom fichier par defaut */ - Ext, /* extension par defaut */ - Mask, /* Masque d'affichage */ - this, - wxFD_SAVE, - TRUE - ); - if( FullFileName.IsEmpty() ) + wxFileDialog dlg( this, _( "Save Drill Plot File" ), wxEmptyString, + fn.GetFullName(), wildcard, + wxFD_SAVE | wxFD_OVERWRITE_PROMPT | wxFD_CHANGE_DIR ); + + if( dlg.ShowModal() == wxID_CANCEL ) return; - dest = wxFopen( FullFileName, wxT( "wt" ) ); + dest = wxFopen( dlg.GetPath(), wxT( "wt" ) ); + if( dest == 0 ) { msg = _( "Unable to create file" ); - msg << wxT( " <" ) << FullFileName << wxT( ">" ); - DisplayError( this, msg ); return; + msg << wxT( " <" ) << dlg.GetPath() << wxT( ">" ); + DisplayError( this, msg ); + return; } GenDrillMapFile( m_Parent->GetBoard(), - dest, - FullFileName, - m_Parent->GetScreen()->m_CurrentSheetDesc->m_Size, - s_HoleListBuffer, - s_ToolListBuffer, - s_Unit_Drill_is_Inch, - format ); + dest, + dlg.GetPath(), + m_Parent->GetScreen()->m_CurrentSheetDesc->m_Size, + s_HoleListBuffer, + s_ToolListBuffer, + s_Unit_Drill_is_Inch, + format ); } @@ -789,35 +796,33 @@ void WinEDA_DrillFrame::GenDrillReport( const wxString aFileName ) * Create a list of drill values and drill count */ { - wxString FileName, Mask( wxT( "*" ) ), Ext( wxT( ".rpt" ) ); + wxFileName fn; wxString msg; + wxString wildcard = _( "Drill report files (.rpt)|*.rpt" ); - FileName = aFileName; - ChangeFileNameExt( FileName, wxT( "-drl" ) + Ext ); - Mask += Ext; + fn = aFileName; + fn.SetName( fn.GetName() + wxT( "-drl" ) ); + fn.SetExt( wxT( "rpt" ) ); - FileName = EDA_FileSelector( _( "Drill Report file" ), - wxEmptyString, /* Chemin par defaut */ - FileName, /* nom fichier par defaut */ - Ext, /* extension par defaut */ - Mask, /* Masque d'affichage */ - this, - wxFD_SAVE, - TRUE - ); - if( FileName.IsEmpty() ) + wxFileDialog dlg( this, _( "Save Drill Report File" ), wxEmptyString, + fn.GetFullName(), wildcard, + wxFD_SAVE | wxFD_OVERWRITE_PROMPT | wxFD_CHANGE_DIR ); + + if( dlg.ShowModal() == wxID_CANCEL ) return; - dest = wxFopen( FileName, wxT( "w" ) ); + dest = wxFopen( dlg.GetPath(), wxT( "w" ) ); + if( dest == 0 ) { - msg = _( "Unable to create file " ) + FileName; + msg = _( "Unable to create file " ) + dlg.GetPath(); DisplayError( this, msg ); return; } + GenDrillReportFile( dest, m_Parent->GetBoard(), - m_Parent->GetScreen()->m_FileName, - s_Unit_Drill_is_Inch, - s_HoleListBuffer, - s_ToolListBuffer ); + m_Parent->GetScreen()->m_FileName, + s_Unit_Drill_is_Inch, + s_HoleListBuffer, + s_ToolListBuffer ); } diff --git a/pcbnew/gpcb_exchange.cpp b/pcbnew/gpcb_exchange.cpp index 222ccb702c..f8f37f3015 100644 --- a/pcbnew/gpcb_exchange.cpp +++ b/pcbnew/gpcb_exchange.cpp @@ -219,8 +219,8 @@ bool MODULE::Read_GPCB_Descr( const wxString& CmpFullFileName ) iprmcnt++; } - m_Reference->m_Pos.x = (int) round( ibuf[2] * conv_unit ); - m_Reference->m_Pos.y = (int) round( ibuf[3] * conv_unit );; + m_Reference->m_Pos.x = wxRound( ibuf[2] * conv_unit ); + m_Reference->m_Pos.y = wxRound( ibuf[3] * conv_unit );; m_Reference->m_Orient = ibuf[4] * 900; // Calculate size: default is 40 mils (400 pcb units) @@ -264,7 +264,7 @@ bool MODULE::Read_GPCB_Descr( const wxString& CmpFullFileName ) if( ii < (params.GetCount() - 2) ) { if( params[ii + 2].ToLong( &dim ) ) - *list[ii] = (int) round( dim * conv_unit ); + *list[ii] = wxRound( dim * conv_unit ); } } @@ -297,18 +297,18 @@ bool MODULE::Read_GPCB_Descr( const wxString& CmpFullFileName ) int rayon = (ibuf[2] + ibuf[3]) / 4; // for and arc: ibuf[3] = ibuf[4]. pcbnew does not know ellipses wxPoint centre; - centre.x = (int) round( ibuf[0] * conv_unit ); - centre.y = (int) round( ibuf[1] * conv_unit ); + centre.x = wxRound( ibuf[0] * conv_unit ); + centre.y = wxRound( ibuf[1] * conv_unit ); DrawSegm->m_Start0 = centre; int start_angle = ibuf[4] * 10; // Pcbnew uses 0.1 degrees as units start_angle -= 1800; // Use normal X axis as reference DrawSegm->m_Angle = ibuf[5] * 10; // Angle value is clockwise in gpcb and pcbnew - DrawSegm->m_End0.x = (int) round( rayon * conv_unit ); + DrawSegm->m_End0.x = wxRound( rayon * conv_unit ); DrawSegm->m_End0.y = 0; RotatePoint( &DrawSegm->m_End0, -start_angle ); // Calculate start point coordinate of arc DrawSegm->m_End0 += centre; - DrawSegm->m_Width = (int) round( ibuf[6] * conv_unit ); + DrawSegm->m_Width = wxRound( ibuf[6] * conv_unit ); DrawSegm->SetDrawCoord(); continue; } @@ -330,7 +330,7 @@ bool MODULE::Read_GPCB_Descr( const wxString& CmpFullFileName ) { long dim; if( params[ii + 2].ToLong( &dim ) ) - ibuf[ii] = (int) round( dim * conv_unit ); + ibuf[ii] = wxRound( dim * conv_unit ); } else ibuf[ii] = 0; @@ -381,7 +381,7 @@ bool MODULE::Read_GPCB_Descr( const wxString& CmpFullFileName ) { long dim; if( params[ii + 2].ToLong( &dim ) ) - ibuf[ii] = (int) round( dim * conv_unit ); + ibuf[ii] = wxRound( dim * conv_unit ); } else ibuf[ii] = 0; diff --git a/pcbnew/hotkeys.cpp b/pcbnew/hotkeys.cpp index c6b85b3f74..932e893730 100644 --- a/pcbnew/hotkeys.cpp +++ b/pcbnew/hotkeys.cpp @@ -8,8 +8,8 @@ #include "id.h" #include "class_drawpanel.h" #include "confirm.h" -#include "hotkeys.h" +#include "hotkeys.h" #include "protos.h" /* How to add a new hotkey: diff --git a/pcbnew/ioascii.cpp b/pcbnew/ioascii.cpp index 3e38aab450..e34da67e90 100644 --- a/pcbnew/ioascii.cpp +++ b/pcbnew/ioascii.cpp @@ -75,7 +75,6 @@ $EndMODULE */ -extern Ki_PageDescr* SheetList[]; /* Local Variables */ int NbDraw, NbTrack, NbZone, NbMod, NbNets; @@ -639,9 +638,9 @@ static bool ReadSheetDescr( BASE_SCREEN* screen, FILE* File, int* LineNum ) { text = strtok( Line, " \t\n\r" ); text = strtok( NULL, " \t\n\r" ); - Ki_PageDescr* sheet = SheetList[0]; + Ki_PageDescr* sheet = g_SheetSizeList[0]; int ii; - for( ii = 0; sheet != NULL; ii++, sheet = SheetList[ii] ) + for( ii = 0; sheet != NULL; ii++, sheet = g_SheetSizeList[ii] ) { if( stricmp( CONV_TO_UTF8( sheet->m_Name ), text ) == 0 ) { diff --git a/pcbnew/librairi.cpp b/pcbnew/librairi.cpp index 53c591bdea..74d3ea40e1 100644 --- a/pcbnew/librairi.cpp +++ b/pcbnew/librairi.cpp @@ -24,10 +24,16 @@ * $EndLIBRARY */ -#define OLD_EXT wxT( ".bak" ) -#define FILETMP_EXT wxT( ".$$$" ) +#define OLD_EXT wxT( "bak" ) +#define FILETMP_EXT wxT( "$$$" ) #define EXPORT_IMPORT_LASTPATH_KEY wxT( "import_last_path" ) +const wxString ModExportFileExtension( wxT( "emp" ) ); + +const wxString ModExportFileWildcard( _( "Kicad foot print export files " \ + "(*.emp)|*.emp" ) ); + + /* Fonctions locales */ static bool CreateDocLibrary( const wxString& LibName ); @@ -48,11 +54,9 @@ MODULE* WinEDA_ModuleEditFrame::Import_Module( wxDC* DC ) { int NbLine = 0; char Line[1024]; - wxString CmpFullFileName; - FILE* dest; + FILE* file; MODULE* module = NULL; bool Footprint_Is_GPCB_Format = false; - wxString mask = wxT( "*.*;" ); mask += EXT_CMP_MASK; wxString LastOpenedPathForLoading; wxConfig* Config = wxGetApp().m_EDA_Config; @@ -61,42 +65,38 @@ MODULE* WinEDA_ModuleEditFrame::Import_Module( wxDC* DC ) Config->Read( EXPORT_IMPORT_LASTPATH_KEY, &LastOpenedPathForLoading ); /* Lecture Fichier module */ - CmpFullFileName = EDA_FileSelector( _( "Import Module:" ), - LastOpenedPathForLoading, /* Chemin par defaut */ - wxEmptyString, /* nom fichier par defaut */ - wxEmptyString, /* extension par defaut */ - mask, /* Masque d'affichage */ - this, - wxFD_OPEN, - true - ); + wxFileDialog dlg( this, _( "Import Footprint Module" ), + LastOpenedPathForLoading, wxEmptyString, + ModExportFileWildcard, wxFD_OPEN | wxFD_FILE_MUST_EXIST ); - if( CmpFullFileName == wxEmptyString ) + if( dlg.ShowModal() == wxID_CANCEL ) return NULL; - if( ( dest = wxFopen( CmpFullFileName, wxT( "rt" ) ) ) == NULL ) + file = wxFopen( dlg.GetPath(), wxT( "rt" ) ); + + if( file == NULL ) { wxString msg; - msg.Printf( _( "File <%s> not found" ), CmpFullFileName.GetData() ); + msg.Printf( _( "File <%s> not found" ), dlg.GetPath() ); DisplayError( this, msg ); return NULL; } if( Config ) // Save file path { - LastOpenedPathForLoading = wxPathOnly( CmpFullFileName ); + LastOpenedPathForLoading = wxPathOnly( dlg.GetPath() ); Config->Write( EXPORT_IMPORT_LASTPATH_KEY, LastOpenedPathForLoading ); } /* Read header and test file type */ - GetLine( dest, Line, &NbLine ); + GetLine( file, Line, &NbLine ); if( strnicmp( Line, ENTETE_LIBRAIRIE, L_ENTETE_LIB ) != 0 ) { if( strnicmp( Line, "Element", 7 ) == 0 ) Footprint_Is_GPCB_Format = true; else { - fclose( dest ); + fclose( file ); DisplayError( this, _( "Not a module file" ) ); return NULL; } @@ -105,7 +105,7 @@ MODULE* WinEDA_ModuleEditFrame::Import_Module( wxDC* DC ) /* Read file: Search the description starting line (skip lib header)*/ if( !Footprint_Is_GPCB_Format ) { - while( GetLine( dest, Line, &NbLine ) != NULL ) + while( GetLine( file, Line, &NbLine ) != NULL ) { if( strnicmp( Line, "$MODULE", 7 ) == 0 ) break; @@ -116,13 +116,13 @@ MODULE* WinEDA_ModuleEditFrame::Import_Module( wxDC* DC ) if( Footprint_Is_GPCB_Format ) { - fclose( dest ); - module->Read_GPCB_Descr( CmpFullFileName ); + fclose( file ); + module->Read_GPCB_Descr( dlg.GetPath() ); } else { - module->ReadDescr( dest, &NbLine ); - fclose( dest ); + module->ReadDescr( file, &NbLine ); + fclose( file ); } /* Insert footprint in list*/ @@ -154,72 +154,59 @@ void WinEDA_ModuleEditFrame::Export_Module( MODULE* ptmod, bool createlib ) * false = use current path or last used path to export footprint */ { - wxString FullFileName, Mask( wxT( "*" ) ); - char Line[1025]; - FILE* dest; - wxString msg, path; - wxConfig* Config = wxGetApp().m_EDA_Config; + wxFileName fn; + char Line[1025]; + FILE* file; + wxString msg, path, title, wildcard; + wxConfig* Config = wxGetApp().m_EDA_Config; if( ptmod == NULL ) return; ptmod->m_LibRef = ptmod->m_Reference->m_Text; - FullFileName = ptmod->m_LibRef; - FullFileName += createlib ? LibExtBuffer : EXT_CMP; - - Mask += createlib ? LibExtBuffer : EXT_CMP; + fn.SetName( ptmod->m_LibRef ); + fn.SetExt( createlib ? ModuleFileExtension : ModExportFileExtension ); if( createlib ) path = g_RealLibDirBuffer; else if( Config ) Config->Read( EXPORT_IMPORT_LASTPATH_KEY, &path ); - FullFileName = EDA_FileSelector( createlib ? _( "Create lib" ) : _( "Export Module:" ), - path, /* Chemin par defaut */ - FullFileName, /* nom fichier par defaut */ - createlib ? LibExtBuffer : EXT_CMP, /* extension par defaut */ - Mask, /* Masque d'affichage */ - this, - wxFD_SAVE, - true - ); + fn.SetPath( path ); + title = createlib ? _( "Create New Library" ) : _( "Export Module" ); + wildcard = createlib ? ModuleFileWildcard : ModExportFileWildcard; + wxFileDialog dlg( this, msg, fn.GetPath(), fn.GetFullName(), wildcard, + wxFD_SAVE | wxFD_OVERWRITE_PROMPT ); - if( FullFileName.IsEmpty() ) + if( dlg.ShowModal() == wxCANCEL ) return; - if( wxFileExists( FullFileName ) ) - { - msg.Printf( _( "File %s exists, OK to replace ?" ), - FullFileName.GetData() ); - if( !IsOK( this, msg ) ) - return; - } + fn = dlg.GetPath(); /* Generation du fichier Empreinte */ - if( ( dest = wxFopen( FullFileName, wxT( "wt" ) ) ) == NULL ) + if( ( file = wxFopen( fn.GetFullPath(), wxT( "wt" ) ) ) == NULL ) { - msg.Printf( _( "Unable to create <%s>" ), FullFileName.GetData() ); + msg.Printf( _( "Unable to create <%s>" ), fn.GetFullPath().c_str() ); DisplayError( this, msg ); return; } if( !createlib && Config ) // Save file path { - path = wxPathOnly( FullFileName ); - Config->Write( EXPORT_IMPORT_LASTPATH_KEY, path ); + Config->Write( EXPORT_IMPORT_LASTPATH_KEY, fn.GetPath() ); } - fprintf( dest, "%s %s\n", ENTETE_LIBRAIRIE, DateAndTime( Line ) ); - fputs( "$INDEX\n", dest ); + fprintf( file, "%s %s\n", ENTETE_LIBRAIRIE, DateAndTime( Line ) ); + fputs( "$INDEX\n", file ); - fprintf( dest, "%s\n", CONV_TO_UTF8( ptmod->m_LibRef ) ); - fputs( "$EndINDEX\n", dest ); + fprintf( file, "%s\n", CONV_TO_UTF8( ptmod->m_LibRef ) ); + fputs( "$EndINDEX\n", file ); - GetBoard()->m_Modules->Save( dest ); + GetBoard()->m_Modules->Save( file ); - fputs( "$EndLIBRARY\n", dest ); - fclose( dest ); - msg.Printf( _( "Module exported in file <%s>" ), FullFileName.GetData() ); + fputs( "$EndLIBRARY\n", file ); + fclose( file ); + msg.Printf( _( "Module exported in file <%s>" ), fn.GetFullPath().c_str() ); DisplayInfo( this, msg ); } @@ -229,11 +216,12 @@ void WinEDA_ModuleEditFrame::Delete_Module_In_Library( const wxString& libname ) /**********************************************************/ { - int ii, NoFound = 1, LineNum = 0; - char Line[1024], Name[256]; - wxString NewLib, OldLib; - FILE* dest, * lib_module; - wxString CmpName, msg; + wxFileName newFileName; + wxFileName oldFileName; + int ii, NoFound = 1, LineNum = 0; + char Line[1024], Name[256]; + FILE* dest, * lib_module; + wxString CmpName, msg; /* Demande du nom du composant a supprimer */ CmpName = Select_1_Module_From_List( this, libname, wxEmptyString, wxEmptyString ); @@ -246,12 +234,13 @@ void WinEDA_ModuleEditFrame::Delete_Module_In_Library( const if( !IsOK( this, msg ) ) return; - OldLib = libname; + oldFileName = libname; - if( ( lib_module = wxFopen( OldLib, wxT( "rt" ) ) ) == NULL ) + if( ( lib_module = wxFopen( oldFileName.GetFullPath(), + wxT( "rt" ) ) ) == NULL ) { wxString msg; - msg = _( "Library " ) + OldLib + _( " not found" ); + msg = _( "Library " ) + oldFileName.GetFullPath() + _( " not found" ); DisplayError( this, msg ); return; } @@ -297,13 +286,14 @@ void WinEDA_ModuleEditFrame::Delete_Module_In_Library( const } /* Creation de la nouvelle librairie */ - NewLib = OldLib; - ChangeFileNameExt( NewLib, FILETMP_EXT ); - if( ( dest = wxFopen( NewLib, wxT( "wt" ) ) ) == NULL ) + newFileName = oldFileName; + newFileName.SetExt( FILETMP_EXT ); + + if( ( dest = wxFopen( newFileName.GetFullPath(), wxT( "wt" ) ) ) == NULL ) { fclose( lib_module ); wxString msg; - msg = _( "Unable to create " ) + NewLib; + msg = _( "Unable to create " ) + newFileName.GetFullPath(); DisplayError( this, msg ); return; } @@ -314,7 +304,9 @@ void WinEDA_ModuleEditFrame::Delete_Module_In_Library( const fprintf( dest, ENTETE_LIBRAIRIE ); fprintf( dest, " %s\n$INDEX\n", DateAndTime( Line ) ); - fseek( lib_module, 0, 0 ); GetLine( lib_module, Line, &ii ); + fseek( lib_module, 0, 0 ); + GetLine( lib_module, Line, &ii ); + while( GetLine( lib_module, Line, &ii ) ) { if( strnicmp( Line, "$M", 2 ) == 0 ) @@ -366,29 +358,31 @@ void WinEDA_ModuleEditFrame::Delete_Module_In_Library( const wxEndBusyCursor(); /* Le fichier ancienne librairie est renommee en .bak */ - wxString BakFilename = OldLib; - ChangeFileNameExt( BakFilename, OLD_EXT ); + wxFileName backupFileName = oldFileName; + backupFileName.SetExt( OLD_EXT ); - if( wxFileExists( BakFilename ) ) - wxRemoveFile( BakFilename ); + if( backupFileName.FileExists() ) + wxRemoveFile( backupFileName.GetFullPath() ); - if( !wxRenameFile( OldLib, BakFilename ) ) + if( !wxRenameFile( newFileName.GetFullPath(), + backupFileName.GetFullPath() ) ) { DisplayError( this, wxT( "Librairi.cpp: rename .bak err" ) ); return; } /* Le fichier temporaire est renommee comme l'ancienne Lib */ - if( !wxRenameFile( NewLib, OldLib ) ) + if( !wxRenameFile( newFileName.GetFullPath(), oldFileName.GetFullPath() ) ) { DisplayError( this, wxT( "Librairi.cpp: rename err 2" ) ); return; } - msg.Printf( _( "Component %s deleted in library %s" ), CmpName.GetData(), OldLib.GetData() ); + msg.Printf( _( "Component %s deleted in library %s" ), CmpName.GetData(), + oldFileName.GetFullPath().c_str() ); Affiche_Message( msg ); - CreateDocLibrary( OldLib ); + CreateDocLibrary( oldFileName.GetFullPath() ); } @@ -407,7 +401,7 @@ void WinEDA_BasePcbFrame::Archive_Modules( const wxString& LibName, int ii, NbModules = 0; float Pas; MODULE* Module; - wxString FullFileName = LibName; + wxString fileName = LibName; if( GetBoard()->m_Modules == NULL ) { @@ -415,28 +409,24 @@ void WinEDA_BasePcbFrame::Archive_Modules( const wxString& LibName, return; } - if( FullFileName.IsEmpty() ) + if( LibName.IsEmpty() ) { - wxString Mask = wxT( "*" ) + LibExtBuffer; - FullFileName = EDA_FileSelector( _( "Library" ), - g_RealLibDirBuffer, /* Chemin par defaut */ - FullFileName, /* nom fichier par defaut */ - LibExtBuffer, /* extension par defaut */ - Mask, /* Masque d'affichage */ - this, - wxFD_SAVE, - true - ); + wxFileDialog dlg( this, _( "Library" ), g_RealLibDirBuffer, + wxEmptyString, ModuleFileWildcard, + wxFD_SAVE | wxFD_OVERWRITE_PROMPT ); - if( FullFileName.IsEmpty() ) + if( dlg.ShowModal() == wxCANCEL ) return; + + fileName = dlg.GetPath(); } - bool file_exists = wxFileExists( FullFileName ); + bool file_exists = wxFileExists( fileName ); + if( !NewModulesOnly && file_exists ) { wxString msg; - msg.Printf( _( "File %s exists, OK to replace ?" ), FullFileName.GetData() ); + msg.Printf( _( "File %s exists, OK to replace ?" ), fileName.c_str() ); if( !IsOK( this, msg ) ) return; } @@ -447,9 +437,9 @@ void WinEDA_BasePcbFrame::Archive_Modules( const wxString& LibName, if( !NewModulesOnly || !file_exists ) { FILE* lib_module; - if( ( lib_module = wxFopen( FullFileName, wxT( "w+t" ) ) ) == NULL ) + if( ( lib_module = wxFopen( fileName, wxT( "w+t" ) ) ) == NULL ) { - wxString msg = _( "Unable to create " ) + FullFileName; + wxString msg = _( "Unable to create " ) + fileName; DisplayError( this, msg ); return; } @@ -472,7 +462,7 @@ void WinEDA_BasePcbFrame::Archive_Modules( const wxString& LibName, Module = (MODULE*) GetBoard()->m_Modules; for( ii = 1; Module != NULL; ii++, Module = (MODULE*) Module->Next() ) { - if( Save_Module_In_Library( FullFileName, Module, + if( Save_Module_In_Library( fileName, Module, NewModulesOnly ? FALSE : true, FALSE, false ) == 0 ) break; DisplayActivity( (int) ( ii * Pas ), wxEmptyString ); @@ -481,7 +471,7 @@ void WinEDA_BasePcbFrame::Archive_Modules( const wxString& LibName, break; } - CreateDocLibrary( FullFileName ); + CreateDocLibrary( fileName ); } @@ -501,13 +491,15 @@ int WinEDA_BasePcbFrame::Save_Module_In_Library( const wxString& aLibName, * @return : 1 if OK, 0 if abort */ { - int newmodule, end; - int LineNum = 0, tmp; - char Name[256], Line[1024]; - wxString Name_Cmp; - wxString NewLib, OldLib, msg; - FILE* lib_module, * dest; - bool added = true; + wxFileName oldFileName; + wxFileName newFileName; + int newmodule, end; + int LineNum = 0, tmp; + char Name[256], Line[1024]; + wxString Name_Cmp; + wxString msg; + FILE* lib_module, * dest; + bool added = true; aModule->Display_Infos( this ); @@ -596,12 +588,13 @@ int WinEDA_BasePcbFrame::Save_Module_In_Library( const wxString& aLibName, return 0; } - NewLib = aLibName; - ChangeFileNameExt( NewLib, FILETMP_EXT ); - if( ( dest = wxFopen( NewLib, wxT( "w+t" ) ) ) == NULL ) + newFileName = aLibName; + newFileName.SetExt( FILETMP_EXT ); + + if( ( dest = wxFopen( newFileName.GetFullPath(), wxT( "w+t" ) ) ) == NULL ) { fclose( lib_module ); - msg = _( "Unable to create " ) + NewLib; + msg = _( "Unable to create " ) + newFileName.GetFullPath(); DisplayError( this, msg ); return 0; } @@ -672,17 +665,17 @@ int WinEDA_BasePcbFrame::Save_Module_In_Library( const wxString& aLibName, wxEndBusyCursor(); /* The old library file is renamed .bak */ - OldLib = aLibName; - ChangeFileNameExt( OldLib, OLD_EXT ); + oldFileName = aLibName; + oldFileName.SetExt( OLD_EXT ); - if( wxFileExists( OldLib ) ) - wxRemoveFile( OldLib ); + if( oldFileName.FileExists() ) + wxRemoveFile( oldFileName.GetFullPath() ); - if( !wxRenameFile( aLibName, OldLib ) ) + if( !wxRenameFile( aLibName, oldFileName.GetFullPath() ) ) DisplayError( this, wxT( "Librairi.cpp: rename .bak err" ) ); /* The new library file is renamed */ - if( !wxRenameFile( NewLib, aLibName ) ) + if( !wxRenameFile( newFileName.GetFullPath(), aLibName ) ) { DisplayError( this, wxT( "Librairi.cpp: rename NewLib err" ) ); return 0; @@ -771,8 +764,8 @@ void WinEDA_ModuleEditFrame::Select_Active_Library() return; WinEDAListBox* LibListBox = new WinEDAListBox( this, _( "Active Lib:" ), - NULL, m_CurrentLib, NULL, - wxColour( 200, 200, 255 ) ); + NULL, m_CurrentLib, NULL, + wxColour( 200, 200, 255 ) ); LibListBox->InsertItems( g_LibName_List ); @@ -834,14 +827,14 @@ static bool CreateDocLibrary( const wxString& LibName ) * (full file name) */ { - char Line[1024]; - char cbuf[256]; - wxString Name, Doc, KeyWord; - wxString LibDocName; - FILE* LibMod, * LibDoc; + char Line[1024]; + char cbuf[256]; + wxString Name, Doc, KeyWord; + wxFileName fn; + FILE* LibMod, * LibDoc; - LibDocName = LibName; - ChangeFileNameExt( LibDocName, EXT_DOC ); + fn = LibName; + fn.SetExt( EXT_DOC ); LibMod = wxFopen( LibName, wxT( "rt" ) ); if( LibMod == NULL ) @@ -855,7 +848,7 @@ static bool CreateDocLibrary( const wxString& LibName ) return FALSE; } - LibDoc = wxFopen( LibDocName, wxT( "wt" ) ); + LibDoc = wxFopen( fn.GetFullPath(), wxT( "wt" ) ); if( LibDoc == NULL ) { fclose( LibMod ); diff --git a/pcbnew/loadcmp.cpp b/pcbnew/loadcmp.cpp index f7be00abd2..8ec537b64d 100644 --- a/pcbnew/loadcmp.cpp +++ b/pcbnew/loadcmp.cpp @@ -11,6 +11,7 @@ #include "kicad_string.h" #include "gestfich.h" #include "get_component_dialog.h" +#include "appl_wxstruct.h" #include "pcbnew.h" #include "protos.h" @@ -162,7 +163,6 @@ MODULE* WinEDA_BasePcbFrame::Load_Module_From_Library( const wxString& library, GetBoard()->m_Status_Pcb = 0; module->SetPosition( curspos ); build_liste_pads(); - module->Draw( DrawPanel, DC, GR_OR ); } @@ -170,13 +170,8 @@ MODULE* WinEDA_BasePcbFrame::Load_Module_From_Library( const wxString& library, } -/*******************************************************************************/ -MODULE* WinEDA_BasePcbFrame::Get_Librairie_Module( wxWindow* winaff, - const wxString& library, - const wxString& ModuleName, bool show_msg_err ) -/*******************************************************************************/ - -/* +/***************************************************************************** + * * Analyse les LIBRAIRIES pour trouver le module demande * Si ce module est trouve, le copie en memoire, et le * chaine en fin de liste des modules @@ -184,70 +179,91 @@ MODULE* WinEDA_BasePcbFrame::Get_Librairie_Module( wxWindow* winaff, * name_cmp = nom du module * - Retour: * Pointeur sur le nouveau module. - */ + * + *****************************************************************************/ +MODULE* WinEDA_BasePcbFrame::Get_Librairie_Module( wxWindow* winaff, + const wxString& library, + const wxString& ModuleName, + bool show_msg_err ) { - int LineNum, Found = 0; - wxString fulllibname; - char Line[512]; - wxString Name; - wxString ComponentName, msg; - MODULE* NewModule; - FILE* lib_module = NULL; - unsigned ii; - - ComponentName = ModuleName; + int LineNum, Found = 0; + wxFileName fn; + char Line[512]; + wxString Name; + wxString msg, tmp; + MODULE* NewModule; + FILE* file = NULL; + unsigned ii; for( ii = 0; ii < g_LibName_List.GetCount(); ii++ ) { - fulllibname = g_LibName_List[ii]; + fn = wxFileName( wxEmptyString, g_LibName_List[ii], + ModuleFileExtension ); - /* Calcul du nom complet de la librairie */ - fulllibname = MakeFileName( g_RealLibDirBuffer, fulllibname, LibExtBuffer ); + tmp = wxGetApp().GetLibraryPathList().FindValidPath( fn.GetFullName() ); - if( ( lib_module = wxFopen( fulllibname, wxT( "rt" ) ) ) == NULL ) + if( !tmp ) { - msg.Printf( _( "Library <%s> not found" ), fulllibname.GetData() ); - Affiche_Message( msg ); + msg.Printf( _( "PCB footprint library file <%s> not found in " \ + "search paths." ), fn.GetFullName().c_str() ); + wxMessageBox( msg, _( "Library Load Error" ), + wxOK | wxICON_ERROR, this ); continue; } - msg.Printf( _( "Scan Lib: %s" ), fulllibname.GetData() ); + file = wxFopen( tmp, wxT( "rt" ) ); + + if( file == NULL ) + { + msg.Printf( _( "Could not open PCB footprint library file <%s>." ), + tmp.c_str() ); + wxMessageBox( msg, _( "Library Load Error" ), + wxOK | wxICON_ERROR, this ); + continue; + } + + msg.Printf( _( "Scan Lib: %s" ), tmp.c_str() ); Affiche_Message( msg ); /* lecture entete chaine definie par ENTETE_LIBRAIRIE */ LineNum = 0; - GetLine( lib_module, Line, &LineNum ); + GetLine( file, Line, &LineNum ); StrPurge( Line ); if( strnicmp( Line, ENTETE_LIBRAIRIE, L_ENTETE_LIB ) != 0 ) { - DisplayError( winaff, _( "File is not a library" ) ); + msg.Printf( _( "<%s> is not a valid Kicad PCB footprint library " \ + "file." ), tmp.c_str() ); + wxMessageBox( msg, _( "Library Load Error" ), + wxOK | wxICON_ERROR, this ); + fclose( file ); return NULL; } /* Lecture de la liste des composants de la librairie */ Found = 0; - while( !Found && GetLine( lib_module, Line, &LineNum ) ) + while( !Found && GetLine( file, Line, &LineNum ) ) { if( strnicmp( Line, "$MODULE", 6 ) == 0 ) break; if( strnicmp( Line, "$INDEX", 6 ) == 0 ) { - while( GetLine( lib_module, Line, &LineNum ) ) + while( GetLine( file, Line, &LineNum ) ) { if( strnicmp( Line, "$EndINDEX", 9 ) == 0 ) break; StrPurge( Line ); msg = CONV_FROM_UTF8( Line ); - if( msg.CmpNoCase( ComponentName ) == 0 ) + if( msg.CmpNoCase( ModuleName ) == 0 ) { - Found = 1; break; /* Trouve! */ + Found = 1; + break; /* Trouve! */ } } } } /* Lecture de la librairie */ - while( Found && GetLine( lib_module, Line, &LineNum ) ) + while( Found && GetLine( file, Line, &LineNum ) ) { if( Line[0] != '$' ) continue; @@ -257,33 +273,32 @@ MODULE* WinEDA_BasePcbFrame::Get_Librairie_Module( wxWindow* winaff, continue; /* Lecture du nom du composant */ Name = CONV_FROM_UTF8( Line + 8 ); - if( Name.CmpNoCase( ComponentName ) == 0 ) /* composant localise */ + + if( Name.CmpNoCase( ModuleName ) == 0 ) /* composant localise */ { NewModule = new MODULE( GetBoard() ); - // Switch the locale to standard C (needed to print floating point numbers like 1.3) + // Switch the locale to standard C (needed to print + // floating point numbers like 1.3) SetLocaleTo_C_standard( ); - NewModule->ReadDescr( lib_module, &LineNum ); - SetLocaleTo_Default( ); // revert to the current locale - + NewModule->ReadDescr( file, &LineNum ); + SetLocaleTo_Default( ); // revert to the current locale GetBoard()->Add( NewModule, ADD_APPEND ); - fclose( lib_module ); + fclose( file ); Affiche_Message( wxEmptyString ); return NewModule; } } - fclose( lib_module ); lib_module = 0; + fclose( file ); } - if( lib_module ) - fclose( lib_module ); - if( show_msg_err ) { - msg.Printf( _( "Module <%s> not found" ), ComponentName.GetData() ); + msg.Printf( _( "Module <%s> not found" ), ModuleName.c_str() ); DisplayError( winaff, msg ); } + return NULL; } @@ -309,15 +324,15 @@ wxString WinEDA_BasePcbFrame::Select_1_Module_From_List( int LineNum; unsigned ii, NbModules; char Line[1024]; - wxString FullLibName; + wxFileName fn; static wxString OldName;/* Memorise le nom du dernier composant charge */ - wxString CmpName; - FILE* lib_module; + wxString CmpName, tmp; + FILE* file; wxString msg; WinEDAListBox* ListBox = new WinEDAListBox( active_window, wxEmptyString, - NULL, OldName, DisplayCmpDoc, - wxColour( 200, 200, 255 ) ); + NULL, OldName, DisplayCmpDoc, + wxColour( 200, 200, 255 ) ); wxBeginBusyCursor(); @@ -328,13 +343,25 @@ wxString WinEDA_BasePcbFrame::Select_1_Module_From_List( /* Calcul du nom complet de la librairie */ if( Library.IsEmpty() ) { - FullLibName = MakeFileName( g_RealLibDirBuffer, - g_LibName_List[ii], LibExtBuffer ); + fn = wxFileName( wxEmptyString, g_LibName_List[ii], + ModuleFileExtension ); } else - FullLibName = MakeFileName( g_RealLibDirBuffer, Library, LibExtBuffer ); + fn = wxFileName( wxEmptyString, Library, ModuleFileExtension ); - ReadDocLib( FullLibName ); + + tmp = wxGetApp().GetLibraryPathList().FindValidPath( fn.GetFullName() ); + + if( !tmp ) + { + msg.Printf( _( "PCB footprint library file <%s> not found in " \ + "search paths." ), fn.GetFullName().c_str() ); + wxMessageBox( msg, _( "Library Load Error" ), + wxOK | wxICON_ERROR, this ); + continue; + } + + ReadDocLib( tmp ); if( !KeyWord.IsEmpty() ) /* Inutile de lire la librairie si selection * par mots cles, deja lus */ @@ -344,7 +371,9 @@ wxString WinEDA_BasePcbFrame::Select_1_Module_From_List( continue; } - if( ( lib_module = wxFopen( FullLibName, wxT( "rt" ) ) ) == NULL ) + file = wxFopen( tmp, wxT( "rt" ) ); + + if( file == NULL ) { if( !Library.IsEmpty() ) break; @@ -352,20 +381,25 @@ wxString WinEDA_BasePcbFrame::Select_1_Module_From_List( } // Statusbar library loaded message - msg = _( "Library " ); msg << FullLibName; msg << _(" loaded"); + msg = _( "Library " ) + fn.GetFullPath() + _(" loaded"); Affiche_Message( msg ); /* lecture entete */ LineNum = 0; - GetLine( lib_module, Line, &LineNum, sizeof(Line) - 1 ); + GetLine( file, Line, &LineNum, sizeof(Line) - 1 ); if( strnicmp( Line, ENTETE_LIBRAIRIE, L_ENTETE_LIB ) != 0 ) { - DisplayError( this, wxT( "This file is not an Eeschema libray file" ), 20 ); continue; + msg.Printf( _( "<%s> is not a valid Kicad PCB footprint library " \ + "file." ), tmp.c_str() ); + wxMessageBox( msg, _( "Library Load Error" ), + wxOK | wxICON_ERROR, this ); + fclose( file ); + continue; } /* Lecture de la librairie */ - while( GetLine( lib_module, Line, &LineNum, sizeof(Line) - 1 ) ) + while( GetLine( file, Line, &LineNum, sizeof(Line) - 1 ) ) { if( Line[0] != '$' ) continue; @@ -373,7 +407,7 @@ wxString WinEDA_BasePcbFrame::Select_1_Module_From_List( break; if( strnicmp( Line, "$INDEX", 6 ) == 0 ) { - while( GetLine( lib_module, Line, &LineNum ) ) + while( GetLine( file, Line, &LineNum ) ) { if( strnicmp( Line, "$EndINDEX", 9 ) == 0 ) break; @@ -394,8 +428,9 @@ wxString WinEDA_BasePcbFrame::Select_1_Module_From_List( } /* Fin lecture 1 Librairie */ + fclose( file ); + file = NULL; - fclose( lib_module ); lib_module = NULL; if( !Library.IsEmpty() ) break; } @@ -456,7 +491,8 @@ static void DisplayCmpDoc( wxString& Name ) if( !Mod ) { - Name.Empty(); return; + Name.Empty(); + return; } /* Recherche de la description */ @@ -487,14 +523,14 @@ static void ReadDocLib( const wxString& ModLibName ) * ModLibName = full file Name de la librairie Modules */ { - ModList* NewMod; - char Line[1024]; - FILE* LibDoc; - wxString FullModLibName = ModLibName; + ModList* NewMod; + char Line[1024]; + FILE* LibDoc; + wxFileName fn = ModLibName; - ChangeFileNameExt( FullModLibName, EXT_DOC ); + fn.SetExt( EXT_DOC ); - if( ( LibDoc = wxFopen( FullModLibName, wxT( "rt" ) ) ) == NULL ) + if( ( LibDoc = wxFopen( fn.GetFullPath(), wxT( "rt" ) ) ) == NULL ) return; GetLine( LibDoc, Line, NULL, sizeof(Line) - 1 ); @@ -556,8 +592,8 @@ MODULE* WinEDA_BasePcbFrame::Select_1_Module_From_BOARD( BOARD* Pcb ) wxString CmpName, msg; WinEDAListBox* ListBox = new WinEDAListBox( this, wxEmptyString, - NULL, wxEmptyString, NULL, - wxColour( 200, 200, 255 ) ); + NULL, wxEmptyString, NULL, + wxColour( 200, 200, 255 ) ); /* Recherche des composants en BOARD */ ii = 0; diff --git a/pcbnew/modedit.cpp b/pcbnew/modedit.cpp index 7c72a293af..b6b3db2ed9 100644 --- a/pcbnew/modedit.cpp +++ b/pcbnew/modedit.cpp @@ -10,14 +10,14 @@ #include "class_drawpanel.h" #include "confirm.h" #include "gestfich.h" - -#include "pcbnew.h" -#include "trigo.h" -#include "3d_viewer.h" - +#include "appl_wxstruct.h" #include "bitmaps.h" -#include "protos.h" #include "id.h" +#include "trigo.h" + +#include "3d_viewer.h" +#include "pcbnew.h" +#include "protos.h" #include "collectors.h" @@ -202,39 +202,43 @@ void WinEDA_ModuleEditFrame::Process_Special_Functions( wxCommandEvent& event ) break; case ID_LIBEDIT_DELETE_PART: - { - wxString Line; - Line = MakeFileName( g_RealLibDirBuffer, m_CurrentLib, LibExtBuffer ); - Delete_Module_In_Library( Line ); - } + { + wxFileName fn = wxFileName( wxEmptyString, m_CurrentLib, + ModuleFileExtension ); + wxString tmp = + wxGetApp().GetLibraryPathList().FindValidPath( fn.GetFullName() ); + if( wxFileName::FileExists( tmp ) ) + Delete_Module_In_Library( tmp ); break; + } case ID_MODEDIT_NEW_MODULE: - { - Clear_Pcb( true ); - GetScreen()->ClearUndoRedoList(); - SetCurItem( NULL ); - GetScreen()->m_Curseur = wxPoint( 0, 0 ); + { + Clear_Pcb( true ); + GetScreen()->ClearUndoRedoList(); + SetCurItem( NULL ); + GetScreen()->m_Curseur = wxPoint( 0, 0 ); - MODULE* module = Create_1_Module( &dc, wxEmptyString ); - if ( module ) // i.e. if create module command not aborted - { - module->SetPosition( wxPoint(0, 0) ); - if( GetBoard()->m_Modules ) - GetBoard()->m_Modules->m_Flags = 0; - Zoom_Automatique( true ); - } + MODULE* module = Create_1_Module( &dc, wxEmptyString ); + if ( module ) // i.e. if create module command not aborted + { + module->SetPosition( wxPoint(0, 0) ); + if( GetBoard()->m_Modules ) + GetBoard()->m_Modules->m_Flags = 0; + Zoom_Automatique( true ); } break; + } case ID_MODEDIT_SAVE_LIBMODULE: - { - wxString Line; - Line = MakeFileName( g_RealLibDirBuffer, m_CurrentLib.GetData(), LibExtBuffer ); - Save_Module_In_Library( Line, GetBoard()->m_Modules, true, true, true ); - GetScreen()->ClrModify(); - } + { + wxFileName fn; + fn = wxFileName( g_RealLibDirBuffer, m_CurrentLib, ModuleFileExtension ); + Save_Module_In_Library( fn.GetFullPath(), GetBoard()->m_Modules, + true, true, true ); + GetScreen()->ClrModify(); break; + } case ID_MODEDIT_LOAD_MODULE_FROM_BOARD: GetScreen()->ClearUndoRedoList(); @@ -314,7 +318,7 @@ void WinEDA_ModuleEditFrame::Process_Special_Functions( wxCommandEvent& event ) } break; - case ID_LIBEDIT_IMPORT_PART: + case ID_MODEDIT_IMPORT_PART: GetScreen()->ClearUndoRedoList(); SetCurItem( NULL ); Clear_Pcb( true ); @@ -328,12 +332,12 @@ void WinEDA_ModuleEditFrame::Process_Special_Functions( wxCommandEvent& event ) m_Draw3DFrame->NewDisplay(); break; - case ID_LIBEDIT_EXPORT_PART: + case ID_MODEDIT_EXPORT_PART: if( GetBoard()->m_Modules ) Export_Module( GetBoard()->m_Modules, FALSE ); break; - case ID_LIBEDIT_CREATE_NEW_LIB_AND_SAVE_CURRENT_PART: + case ID_MODEDIT_CREATE_NEW_LIB_AND_SAVE_CURRENT_PART: if( GetBoard()->m_Modules ) Export_Module( GetBoard()->m_Modules, true ); break; diff --git a/pcbnew/modeditoptions.cpp b/pcbnew/modeditoptions.cpp index 472cc58194..f78e8631da 100644 --- a/pcbnew/modeditoptions.cpp +++ b/pcbnew/modeditoptions.cpp @@ -48,18 +48,18 @@ wxClientDC dc(DrawPanel); case ID_TB_OPTIONS_SELECT_UNIT_INCH: if ( id == ID_TB_OPTIONS_SELECT_UNIT_INCH ) g_UnitMetric = INCHES; - Affiche_Status_Box(); /* Reaffichage des coord curseur */ + UpdateStatusBar(); /* Reaffichage des coord curseur */ ReCreateAuxiliaryToolbar(); break; case ID_TB_OPTIONS_SHOW_POLAR_COORD: Affiche_Message(wxEmptyString); DisplayOpt.DisplayPolarCood = m_OptionsToolBar->GetToolState(id); - Affiche_Status_Box(); /* Reaffichage des coord curseur */ + UpdateStatusBar(); /* Reaffichage des coord curseur */ break; case ID_TB_OPTIONS_SELECT_CURSOR: - g_CursorShape = m_OptionsToolBar->GetToolState(id); + m_CursorShape = m_OptionsToolBar->GetToolState(id); break; case ID_TB_OPTIONS_SHOW_PADS_SKETCH: diff --git a/pcbnew/moduleframe.cpp b/pcbnew/moduleframe.cpp index c51b64d04f..eeddf25f54 100644 --- a/pcbnew/moduleframe.cpp +++ b/pcbnew/moduleframe.cpp @@ -46,11 +46,11 @@ BEGIN_EVENT_TABLE( WinEDA_ModuleEditFrame, WinEDA_BasePcbFrame ) WinEDA_ModuleEditFrame::Process_Special_Functions ) EVT_TOOL( ID_MODEDIT_LOAD_MODULE, WinEDA_ModuleEditFrame::Process_Special_Functions ) - EVT_TOOL( ID_LIBEDIT_IMPORT_PART, + EVT_TOOL( ID_MODEDIT_IMPORT_PART, WinEDA_ModuleEditFrame::Process_Special_Functions ) - EVT_TOOL( ID_LIBEDIT_EXPORT_PART, + EVT_TOOL( ID_MODEDIT_EXPORT_PART, WinEDA_ModuleEditFrame::Process_Special_Functions ) - EVT_TOOL( ID_LIBEDIT_CREATE_NEW_LIB_AND_SAVE_CURRENT_PART, + EVT_TOOL( ID_MODEDIT_CREATE_NEW_LIB_AND_SAVE_CURRENT_PART, WinEDA_ModuleEditFrame::Process_Special_Functions ) EVT_TOOL( ID_MODEDIT_SHEET_SET, WinEDA_ModuleEditFrame::Process_Special_Functions ) @@ -160,8 +160,6 @@ WinEDA_ModuleEditFrame::WinEDA_ModuleEditFrame( wxWindow* father, wxConfig* config = wxGetApp().m_EDA_Config; m_FrameName = wxT( "ModEditFrame" ); - m_Draw_Axis = TRUE; // TRUE pour avoir les axes dessines - m_Draw_Grid = TRUE; // TRUE pour avoir la axes dessinee m_Draw_Sheet_Ref = FALSE; // TRUE pour avoir le cartouche dessin� // Give an icon @@ -185,9 +183,9 @@ WinEDA_ModuleEditFrame::WinEDA_ModuleEditFrame( wxWindow* father, SetBaseScreen( ScreenModule ); GetScreen()->SetCurItem( NULL ); - GetSettings(); + LoadSettings(); - GetScreen()->AddGrid( g_UserGrid, g_UserGrid_Unit, ID_POPUP_GRID_USER ); + GetScreen()->AddGrid( m_UserGridSize, m_UserGridUnits, ID_POPUP_GRID_USER ); SetSize( m_FramePos.x, m_FramePos.y, m_FrameSize.x, m_FrameSize.y ); ReCreateMenuBar(); @@ -263,8 +261,8 @@ void WinEDA_ModuleEditFrame::SetToolbars() else active = TRUE; - m_HToolBar->EnableTool( ID_LIBEDIT_EXPORT_PART, active ); - m_HToolBar->EnableTool( ID_LIBEDIT_CREATE_NEW_LIB_AND_SAVE_CURRENT_PART, + m_HToolBar->EnableTool( ID_MODEDIT_EXPORT_PART, active ); + m_HToolBar->EnableTool( ID_MODEDIT_CREATE_NEW_LIB_AND_SAVE_CURRENT_PART, active ); m_HToolBar->EnableTool( ID_MODEDIT_SAVE_LIBMODULE, active && islib ); MODULE* module_in_edit = GetBoard()->m_Modules; @@ -338,7 +336,7 @@ void WinEDA_ModuleEditFrame::SetToolbars() m_Draw_Grid ); m_OptionsToolBar->ToggleTool( ID_TB_OPTIONS_SELECT_CURSOR, - g_CursorShape ); + m_CursorShape ); m_OptionsToolBar->ToggleTool( ID_TB_OPTIONS_SHOW_PADS_SKETCH, !m_DisplayPadFill ); @@ -432,25 +430,25 @@ void WinEDA_ModuleEditFrame::GeneralControle( wxDC* DC, wxPoint Mouse ) { case WXK_NUMPAD8: /* Deplacement curseur vers le haut */ case WXK_UP: - Mouse.y -= (int) round(delta.y); + Mouse.y -= wxRound(delta.y); DrawPanel->MouseTo( Mouse ); break; case WXK_NUMPAD2: /* Deplacement curseur vers le bas */ case WXK_DOWN: - Mouse.y += (int) round(delta.y); + Mouse.y += wxRound(delta.y); DrawPanel->MouseTo( Mouse ); break; case WXK_NUMPAD4: /* Deplacement curseur vers la gauche */ case WXK_LEFT: - Mouse.x -= (int) round(delta.x); + Mouse.x -= wxRound(delta.x); DrawPanel->MouseTo( Mouse ); break; case WXK_NUMPAD6: /* Deplacement curseur vers la droite */ case WXK_RIGHT: - Mouse.x += (int) round(delta.x); + Mouse.x += wxRound(delta.x); DrawPanel->MouseTo( Mouse ); break; @@ -491,7 +489,7 @@ void WinEDA_ModuleEditFrame::GeneralControle( wxDC* DC, wxPoint Mouse ) } SetToolbars(); - Affiche_Status_Box(); /* Affichage des coord curseur */ + UpdateStatusBar(); /* Affichage des coord curseur */ } @@ -503,7 +501,7 @@ void WinEDA_ModuleEditFrame::OnSelectGrid( wxCommandEvent& event ) if( m_SelGridBox == NULL ) return; // Should not occurs - GetScreen()->AddGrid( g_UserGrid, g_UserGrid_Unit, ID_POPUP_GRID_USER ); + GetScreen()->AddGrid( m_UserGridSize, m_UserGridUnits, ID_POPUP_GRID_USER ); WinEDA_DrawFrame::OnSelectGrid( event ); diff --git a/pcbnew/move_or_drag_track.cpp b/pcbnew/move_or_drag_track.cpp index 7595a2905d..6779efdaec 100644 --- a/pcbnew/move_or_drag_track.cpp +++ b/pcbnew/move_or_drag_track.cpp @@ -424,10 +424,10 @@ static void Show_Drag_Track_Segment_With_Cte_Slope( WinEDA_DrawPanel* panel, if( update ) { s_LastPos = Pos; - Track->m_Start.x = (int) round( xi1 ); - Track->m_Start.y = (int) round( yi1 ); - Track->m_End.x = (int) round( xi2 ); - Track->m_End.y = (int) round( yi2 ); + Track->m_Start.x = wxRound( xi1 ); + Track->m_Start.y = wxRound( yi1 ); + Track->m_End.x = wxRound( xi2 ); + Track->m_End.y = wxRound( yi2 ); if( tSegmentToEnd ) { if( tSegmentToEnd->m_Flags & STARTPOINT ) diff --git a/pcbnew/muonde.cpp b/pcbnew/muonde.cpp index f41acd683f..79963b9210 100644 --- a/pcbnew/muonde.cpp +++ b/pcbnew/muonde.cpp @@ -132,7 +132,7 @@ void WinEDA_PcbFrame::Begin_Self( wxDC* DC ) /* Mise a jour de l'origine des coord relatives */ GetScreen()->m_O_Curseur = GetScreen()->m_Curseur; - Affiche_Status_Box(); + UpdateStatusBar(); Bl_X0 = Mself.m_Start.x; Bl_Y0 = Mself.m_Start.y; @@ -708,7 +708,7 @@ MODULE* WinEDA_PcbFrame::Create_MuWaveComponent( int shape_type ) DisplayError( this, _( "Incorrect number, abort" ) ); abort = TRUE; } - gap_size = ABS( (int) round( fval * fcoeff ) ); + gap_size = ABS( wxRound( fval * fcoeff ) ); if( !abort && (shape_type == 2) ) { @@ -721,7 +721,7 @@ MODULE* WinEDA_PcbFrame::Create_MuWaveComponent( int shape_type ) DisplayError( this, _( "Incorrect number, abort" ) ); abort = TRUE; } - angle = ABS( (int) round( fval * fcoeff ) ); + angle = ABS( wxRound( fval * fcoeff ) ); if( angle > 1800 ) angle = 1800; } @@ -1061,8 +1061,8 @@ MODULE* WinEDA_PcbFrame::Create_MuWavePolygonShape( ) if( PolyShapeType == 2 ) // mirrored ShapeScaleY = -ShapeScaleY; - ShapeSize.x = (int) round( ShapeScaleX ); - ShapeSize.y = (int) round( ShapeScaleY ); + ShapeSize.x = wxRound( ShapeScaleX ); + ShapeSize.y = wxRound( ShapeScaleY ); if( (ShapeSize.x) == 0 || (ShapeSize.y == 0) ) { @@ -1104,8 +1104,8 @@ MODULE* WinEDA_PcbFrame::Create_MuWavePolygonShape( ) wxPoint first_coordinate, last_coordinate; for( ii = 0; ii < npoints; ii++ ) // Copy points { - last_coordinate.x = (int) round( *dptr++ * ShapeScaleX ) + pad1->m_Pos0.x; - last_coordinate.y = -(int) round( *dptr++ * ShapeScaleY ); + last_coordinate.x = wxRound( *dptr++ * ShapeScaleX ) + pad1->m_Pos0.x; + last_coordinate.y = -wxRound( *dptr++ * ShapeScaleY ); edge->m_PolyPoints.push_back( last_coordinate ); } diff --git a/pcbnew/netlist.cpp b/pcbnew/netlist.cpp index 1a077d601b..4be4daefeb 100644 --- a/pcbnew/netlist.cpp +++ b/pcbnew/netlist.cpp @@ -107,13 +107,15 @@ void WinEDA_PcbFrame::InstallNetlistFrame( wxDC* DC, const wxPoint& pos ) /*************************************************************************/ { /* Setup the default netlist file name according to the board file name */ - wxString default_netfilename = GetScreen()->m_FileName; + wxFileName fn = GetScreen()->m_FileName; - ChangeFileNameExt( default_netfilename, NetExtBuffer ); + fn.SetExt( NetExtBuffer ); - WinEDA_NetlistFrame* frame = new WinEDA_NetlistFrame( this, DC, default_netfilename ); + WinEDA_NetlistFrame* frame = new WinEDA_NetlistFrame( this, DC, + fn.GetFullPath() ); - frame->ShowModal(); frame->Destroy(); + frame->ShowModal(); + frame->Destroy(); } diff --git a/pcbnew/pcbcfg.cpp b/pcbnew/pcbcfg.cpp index 7a5c6ea01b..e5959d558f 100644 --- a/pcbnew/pcbcfg.cpp +++ b/pcbnew/pcbcfg.cpp @@ -33,7 +33,7 @@ void WinEDA_PcbFrame::Process_Config( wxCommandEvent& event ) wxClientDC dc( DrawPanel ); - wxString FullFileName; + wxFileName fn; DrawPanel->PrepareGraphicContext( &dc ); @@ -67,34 +67,33 @@ void WinEDA_PcbFrame::Process_Config( wxCommandEvent& event ) break; case ID_CONFIG_READ: - FullFileName = GetScreen()->m_FileName.AfterLast( '/' ); - ChangeFileNameExt( FullFileName, g_Prj_Config_Filename_ext ); - FullFileName = EDA_FileSelector( _( "Read Config File" ), - wxPathOnly( GetScreen()->m_FileName ), /* Chemin par defaut */ - FullFileName, /* nom fichier par defaut */ - g_Prj_Config_Filename_ext, /* extension par defaut */ - wxString( wxT("*")) + g_Prj_Config_Filename_ext, - this, - wxFD_OPEN, - TRUE /* ne change pas de repertoire courant */ - ); - if( FullFileName.IsEmpty() ) + { + fn = GetScreen()->m_FileName; + fn.SetExt( ProjectFileExtension ); + + wxFileDialog dlg( this, _( "Read Project File" ), fn.GetPath(), + fn.GetFullName(), ProjectFileWildcard, + wxFD_OPEN | wxFD_FILE_MUST_EXIST | wxFD_CHANGE_DIR ); + + if( dlg.ShowModal() == wxID_CANCEL ) break; - if( !wxFileExists( FullFileName ) ) + + if( !wxFileExists( dlg.GetPath() ) ) { wxString msg; - msg.Printf( _( "File %s not found" ), FullFileName.GetData() ); - DisplayError( this, msg ); break; + msg.Printf( _( "File %s not found" ), dlg.GetPath().c_str() ); + DisplayError( this, msg ); + break; } - Read_Config( FullFileName ); - break; + Read_Config( dlg.GetPath() ); + break; + } case ID_PREFERENCES_CREATE_CONFIG_HOTKEYS: - FullFileName = ReturnHotkeyConfigFilePath( g_ConfigFileLocationChoice ); - FullFileName += HOTKEY_FILENAME; - FullFileName += DEFAULT_HOTKEY_FILENAME_EXT; - WriteHotkeyConfigFile( FullFileName, - s_Pcbnew_Editor_Hokeys_Descr, + fn.SetPath( ReturnHotkeyConfigFilePath( g_ConfigFileLocationChoice ) ); + fn.SetName( HOTKEY_FILENAME ); + fn.SetExt( DEFAULT_HOTKEY_FILENAME_EXT ); + WriteHotkeyConfigFile( fn.GetFullPath(), s_Pcbnew_Editor_Hokeys_Descr, true ); break; @@ -104,13 +103,13 @@ void WinEDA_PcbFrame::Process_Config( wxCommandEvent& event ) case ID_PREFERENCES_EDIT_CONFIG_HOTKEYS: { - FullFileName = ReturnHotkeyConfigFilePath( g_ConfigFileLocationChoice ); - FullFileName += HOTKEY_FILENAME; - FullFileName += DEFAULT_HOTKEY_FILENAME_EXT; - AddDelimiterString( FullFileName ); - wxString editorname = GetEditorName(); + fn.SetPath( ReturnHotkeyConfigFilePath( g_ConfigFileLocationChoice ) ); + fn.SetName( HOTKEY_FILENAME ); + fn.SetExt( DEFAULT_HOTKEY_FILENAME_EXT ); + + wxString editorname = wxGetApp().GetEditorName(); if( !editorname.IsEmpty() ) - ExecuteFile( this, editorname, FullFileName ); + ExecuteFile( this, editorname, QuoteFullPath( fn ) ); break; } @@ -119,7 +118,7 @@ void WinEDA_PcbFrame::Process_Config( wxCommandEvent& event ) HandleHotkeyConfigMenuSelection( this, id ); break; - case ID_PREFERENCES_HOTKEY_SHOW_CURRENT_LIST: // Display Current hotkey list for eeschema + case ID_PREFERENCES_HOTKEY_SHOW_CURRENT_LIST: DisplayHotkeyList( this, s_Board_Editor_Hokeys_Descr ); break; @@ -150,7 +149,7 @@ bool Read_Hotkey_Config( WinEDA_DrawFrame* frame, bool verbose ) /**************************************************************************/ -bool Read_Config( const wxString& project_name ) +bool Read_Config( const wxString& projectFileName ) /*************************************************************************/ /* lit la configuration, si elle n'a pas deja ete lue @@ -161,26 +160,38 @@ bool Read_Config( const wxString& project_name ) * Retourne TRUE si lu, FALSE si config non lue ou non modifiée */ { - wxString FullFileName; + wxFileName fn = projectFileName; int ii; - g_Prj_Config_Filename_ext = wxT( ".pro" ); - FullFileName = project_name; - ChangeFileNameExt( FullFileName, g_Prj_Config_Filename_ext ); + if( fn.GetExt() != ProjectFileExtension ) + { + wxLogDebug( wxT( "Attempting to open project file <%s>. Changing " \ + "file extension to a Kicad project file extension " \ + "(.pro)." ), fn.GetFullPath().c_str() ); + fn.SetExt( ProjectFileExtension ); + } + + if( wxGetApp().GetLibraryPathList().Index( g_UserLibDirBuffer ) != wxNOT_FOUND ) + { + wxLogDebug( wxT( "Removing path <%s> to library path search list." ), + g_UserLibDirBuffer.c_str() ); + wxGetApp().GetLibraryPathList().Remove( g_UserLibDirBuffer ); + } /* Init des valeurs par defaut */ g_LibName_List.Clear(); - wxGetApp().ReadProjectConfig( FullFileName, + wxGetApp().ReadProjectConfig( fn.GetFullPath(), GROUP, ParamCfgList, FALSE ); /* Traitement des variables particulieres: */ - SetRealLibraryPath( wxT( "modules" ) ); - - if( ScreenPcb ) + if( wxFileName::DirExists( g_UserLibDirBuffer ) + && wxGetApp().GetLibraryPathList().Index( g_UserLibDirBuffer ) == wxNOT_FOUND ) { - ScreenPcb->AddGrid( g_UserGrid, g_UserGrid_Unit, ID_POPUP_GRID_USER ); + wxLogDebug( wxT( "Adding path <%s> to library path search list." ), + g_UserLibDirBuffer.c_str() ); + wxGetApp().GetLibraryPathList().Add( g_UserLibDirBuffer ); } g_DesignSettings.m_TrackWidthHistory[0] = g_DesignSettings.m_CurrentTrackWidth; @@ -201,26 +212,19 @@ void WinEDA_PcbFrame::Update_config( wxWindow* displayframe ) /***********************************************************/ /* enregistrement de la config */ { - wxString FullFileName; - wxString mask; + wxFileName fn; - mask = wxT( "*" ) + g_Prj_Config_Filename_ext; - FullFileName = GetScreen()->m_FileName.AfterLast( '/' ); - ChangeFileNameExt( FullFileName, g_Prj_Config_Filename_ext ); + fn = GetScreen()->m_FileName; + fn.SetExt( ProjectFileExtension ); - FullFileName = EDA_FileSelector( _( "Save preferences" ), - wxPathOnly( GetScreen()->m_FileName ), /* Chemin par defaut */ - FullFileName, /* nom fichier par defaut */ - g_Prj_Config_Filename_ext, /* extension par defaut */ - mask, /* Masque d'affichage */ - displayframe, - wxFD_SAVE, - TRUE - ); - if( FullFileName.IsEmpty() ) + wxFileDialog dlg( this, _( "Save Project File" ), fn.GetPath(), + fn.GetFullName(), ProjectFileWildcard, + wxFD_SAVE | wxFD_CHANGE_DIR ); + + if( dlg.ShowModal() == wxID_CANCEL ) return; /* ecriture de la configuration */ - wxGetApp().WriteProjectConfig( FullFileName, wxT( "/pcbnew" ), + wxGetApp().WriteProjectConfig( fn.GetFullPath(), wxT( "/pcbnew" ), ParamCfgList ); } diff --git a/pcbnew/pcbcfg.h b/pcbnew/pcbcfg.h index 2de2effc71..544f088170 100644 --- a/pcbnew/pcbcfg.h +++ b/pcbnew/pcbcfg.h @@ -756,15 +756,6 @@ static PARAM_CFG_BOOL DisplPolairCfg FALSE /* Default value */ ); -static PARAM_CFG_INT CursorShapeCfg -( - INSETUP, - wxT( "CuShape" ), /* Keyword */ - &g_CursorShape, /* Parameter address */ - 0, /* Default value */ - 0, 1 /* Min and max values*/ -); - static PARAM_CFG_INT PrmMaxLinksShowed ( INSETUP, @@ -895,7 +886,6 @@ PARAM_CFG_BASE* ParamCfgList[] = &WTraitSerigraphiePlotCfg, &TimeOutCfg, &DisplPolairCfg, - &CursorShapeCfg, &PrmMaxLinksShowed, &ShowRatsnestCfg, &ShowModuleRatsnestCfg, diff --git a/pcbnew/pcbframe.cpp b/pcbnew/pcbframe.cpp index 0ff09d34ed..76e382e890 100644 --- a/pcbnew/pcbframe.cpp +++ b/pcbnew/pcbframe.cpp @@ -22,9 +22,6 @@ #define PCB_MAGNETIC_TRACKS_OPT wxT( "PcbMagTrackOpt" ) #define SHOW_MICROWAVE_TOOLS wxT( "ShowMicrowaveTools" ) -#define PCB_USER_GRID_X wxT( "PcbUserGrid_X" ) -#define PCB_USER_GRID_Y wxT( "PcbUserGrid_Y" ) -#define PCB_USER_GRID_UNIT wxT( "PcbUserGrid_Unit" ) /*******************************/ /* class WinEDA_PcbFrame */ @@ -212,9 +209,7 @@ WinEDA_PcbFrame::WinEDA_PcbFrame( wxWindow* father, wxConfig* config = wxGetApp().m_EDA_Config; m_FrameName = wxT( "PcbFrame" ); - m_Draw_Axis = TRUE; // TRUE pour avoir les axes dessines - m_Draw_Grid = g_ShowGrid; // TRUE pour avoir la grille dessinee - m_Draw_Sheet_Ref = TRUE; // TRUE pour avoir le cartouche dessine + m_Draw_Sheet_Ref = TRUE; // TRUE pour avoir le cartouche dessine m_Draw_Auxiliary_Axis = TRUE; m_SelTrackWidthBox = NULL; m_SelViaSizeBox = NULL; @@ -238,33 +233,18 @@ WinEDA_PcbFrame::WinEDA_PcbFrame( wxWindow* father, m_InternalUnits = PCB_INTERNAL_UNIT; // Unites internes = 1/10000 inch SetBaseScreen( ScreenPcb ); - GetSettings(); + LoadSettings(); SetSize( m_FramePos.x, m_FramePos.y, m_FrameSize.x, m_FrameSize.y ); - // Read some parameters from config - g_UserGrid.x = g_UserGrid.y = 0.5; // Default user grid size - g_UserGrid_Unit = 1; // Default user grid unit (0 = inch, 1 = mm) - wxRealPoint GridSize( 500, 500 ); // Default current grid size if( config ) { - double SizeX, SizeY; - - if( config->Read( PCB_USER_GRID_X, &SizeX ) - && config->Read( PCB_USER_GRID_Y, &SizeY ) ) - { - g_UserGrid.x = SizeX; - g_UserGrid.y = SizeY; - } - config->Read( PCB_USER_GRID_UNIT, &g_UserGrid_Unit ); - config->Read( PCB_MAGNETIC_PADS_OPT, &g_MagneticPadOption ); - config->Read( PCB_MAGNETIC_TRACKS_OPT, &g_MagneticTrackOption ); + config->Read( PCB_MAGNETIC_TRACKS_OPT, &g_MagneticTrackOption ); } - GetScreen()->AddGrid( g_UserGrid, g_UserGrid_Unit, ID_POPUP_GRID_USER ); - + GetScreen()->AddGrid( m_UserGridSize, m_UserGridUnits, ID_POPUP_GRID_USER ); GetScreen()->SetGrid( GridSize ); if( DrawPanel ) @@ -361,9 +341,6 @@ void WinEDA_PcbFrame::OnCloseWindow( wxCloseEvent& Event ) { wxRealPoint GridSize = GetScreen()->GetGrid(); - config->Write( PCB_USER_GRID_X, g_UserGrid.x ); - config->Write( PCB_USER_GRID_Y, g_UserGrid.y ); - config->Write( PCB_USER_GRID_UNIT, g_UserGrid_Unit ); config->Write( PCB_CURR_GRID, m_SelGridBox->GetSelection() ); config->Write( PCB_MAGNETIC_PADS_OPT, (long) g_MagneticPadOption ); config->Write( PCB_MAGNETIC_TRACKS_OPT, (long) g_MagneticTrackOption ); @@ -453,7 +430,7 @@ void WinEDA_PcbFrame::SetToolbars() m_Draw_Grid ? _( "Grid not show" ) : _( "Show Grid" ) ); m_OptionsToolBar->ToggleTool( ID_TB_OPTIONS_SELECT_CURSOR, - g_CursorShape ); + m_CursorShape ); m_OptionsToolBar->ToggleTool( ID_TB_OPTIONS_SHOW_RATSNEST, g_Show_Ratsnest ); diff --git a/pcbnew/pcbnew.cpp b/pcbnew/pcbnew.cpp index 1ad59b18a5..37bf5c9f87 100644 --- a/pcbnew/pcbnew.cpp +++ b/pcbnew/pcbnew.cpp @@ -2,9 +2,6 @@ /* PCBNEW: main program */ /*************************/ -#define MAIN -#define eda_global - #include "fctsys.h" #include "appl_wxstruct.h" #include "confirm.h" @@ -28,19 +25,78 @@ #include "eda_dde.h" -wxString g_Main_Title( wxT( "PCBnew" ) ); +bool Drc_On = TRUE; +bool g_AutoDeleteOldTrack = TRUE; +bool g_No_Via_Route; +bool g_Drag_Pistes_On; +bool g_Show_Ratsnest; +bool g_Show_Module_Ratsnest; +bool g_Show_Pads_Module_in_Move = TRUE; +bool g_Raccord_45_Auto = TRUE; +bool g_ShowIsolDuringCreateTrack; +bool Track_45_Only; +bool Segments_45_Only; +bool g_TwoSegmentTrackBuild = TRUE; +bool g_HightLigt_Status; extern PARAM_CFG_BASE* ParamCfgList[]; +char* buf_work = NULL; /* pointeur sur le buffer de travail */ +char* adr_lowmem = NULL; /* adresse de base memoire de calcul disponible*/ +char* adr_himem = NULL; /* adresse haute limite de la memoire disponible*/ +char* adr_max = NULL; /* adresse haute maxi utilisee pour la memoire */ + +int Angle_Rot_Module; +int ModuleSegmentWidth; +int ModuleTextWidth; +int Route_Layer_TOP; +int Route_Layer_BOTTOM; +int g_MaxLinksShowed; +int g_MagneticPadOption = capture_cursor_in_track_tool; +int g_MagneticTrackOption = capture_cursor_in_track_tool; +int g_HightLigth_NetCode = -1; + +wxSize ModuleTextSize; /* Default footprint texts size */ +wxPoint g_Offset_Module; /* Offset de trace du modul en depl */ +wxString g_Current_PadName; // Last used pad name (pad num) + +PCB_SCREEN* ScreenModule = NULL; + +/* Options : */ +// True to exclude contents of Edges Pcb layer +bool g_Exclude_Edges_Pcb = FALSE; +bool g_Plot_Frame_Ref; // True to plot/print frame references +bool g_DrawViaOnMaskLayer; // True if vias are drawn on Mask layer (ie protected by mask) + +// = FILAIRE, FILL or SKETCH +int g_Plot_Mode = FILLED; +bool Plot_Set_MIROIR; +bool Sel_Rotate_Window; +bool HPGL_Org_Centre; // TRUE si en HPGL, l'origine le centre de la feuille +int g_PlotPSColorOpt; // True for color Postscript output +bool g_Plot_PS_Negative; // True to create a negative board ps plot + +/* Autorisation de trace des divers items en serigraphie */ +bool Sel_Texte_Reference = TRUE; +bool Sel_Texte_Valeur = TRUE; +bool Sel_Texte_Divers = TRUE; +bool Sel_Texte_Invisible; + +/* Plot pads sur couche serigraphie */ +bool PlotPadsOnSilkLayer = TRUE; +bool Plot_Pads_All_Layers; /* Plot pads meme n'appartenant pas a la + couche ( utile pour serigraphie) */ + + IMPLEMENT_APP( WinEDA_App ) /****************************/ bool WinEDA_App::OnInit() /****************************/ { - wxString FFileName; + wxFileName fn; WinEDA_PcbFrame* frame = NULL; - InitEDA_Appl( wxT( "pcbnew" ) ); + InitEDA_Appl( wxT( "PCBnew" ) ); if( m_Checker && m_Checker->IsAnotherRunning() ) { @@ -53,11 +109,20 @@ bool WinEDA_App::OnInit() if( argc > 1 ) { - FFileName = MakeFileName( wxEmptyString, argv[1], PcbExtBuffer ); - wxSetWorkingDirectory( wxPathOnly( FFileName ) ); + fn = argv[1]; + + if( fn.GetExt() != BoardFileExtension ) + { + wxLogDebug( wxT( "PcbNew file <%s> has the wrong extension." \ + " Changing extension to .brd." ), + fn.GetFullPath().c_str() ); + fn.SetExt( BoardFileExtension ); + } + + if( fn.IsOk() && fn.DirExists() ) + wxSetWorkingDirectory( fn.GetPath() ); } - Read_Config( FFileName ); wxGetApp().ReadCurrentSetupValues( ParamCfgList ); g_DrawBgColor = BLACK; Read_Hotkey_Config( frame, false ); /* Must be called before creating the @@ -78,8 +143,7 @@ bool WinEDA_App::OnInit() } frame = new WinEDA_PcbFrame( NULL, wxT( "PcbNew" ), wxPoint( 0, 0 ), wxSize( 600, 400 ) ); - wxString Title = g_Main_Title + wxT( " " ) + GetBuildVersion(); - frame->SetTitle( Title ); + frame->SetTitle( GetTitle() + wxT( " " ) + GetBuildVersion() ); ActiveScreen = ScreenPcb; SetTopWindow( frame ); @@ -92,11 +156,12 @@ bool WinEDA_App::OnInit() frame->Zoom_Automatique( TRUE ); - /* Load file specified in the command line. */ - if( !FFileName.IsEmpty() ) - { - frame->LoadOnePcbFile( FFileName, FALSE ); + Read_Config( fn.GetFullPath() ); + /* Load file specified in the command line. */ + if( fn.IsOk() ) + { + frame->LoadOnePcbFile( fn.GetFullPath(), FALSE ); // update the layer names in the listbox frame->ReCreateLayerBox( NULL ); } diff --git a/pcbnew/pcbnew.h b/pcbnew/pcbnew.h index c03e8585a3..6036c1ffec 100644 --- a/pcbnew/pcbnew.h +++ b/pcbnew/pcbnew.h @@ -4,12 +4,9 @@ #ifndef PCBNEW_H #define PCBNEW_H -#ifndef eda_global -#define eda_global extern -#endif - #include "pcbstruct.h" #include "macros.h" +#include "pcbcommon.h" #define U_PCB (PCB_INTERNAL_UNIT / EESCHEMA_INTERNAL_UNIT) @@ -48,85 +45,16 @@ #define NEWPCB 0 /* used for normal load file */ -eda_global wxArrayString g_LibName_List; // library list to load - - -#define UNDELETE_STACK_SIZE 10 -eda_global BOARD_ITEM* g_UnDeleteStack[UNDELETE_STACK_SIZE]; // Linked list of deleted items -eda_global int g_UnDeleteStackPtr; - -eda_global bool g_ShowGrid -#ifdef MAIN -= TRUE -#endif -; - -/* Look up Table for conversion one layer number -> one bit layer mask: */ -eda_global int g_TabOneLayerMask[LAYER_COUNT] -#if defined MAIN -= { - 0x00000001, 0x00000002, 0x00000004, 0x00000008, - 0x00000010, 0x00000020, 0x00000040, 0x00000080, - 0x00000100, 0x00000200, 0x00000400, 0x00000800, - 0x00001000, 0x00002000, 0x00004000, 0x00008000, - 0x00010000, 0x00020000, 0x00040000, 0x00080000, - 0x00100000, 0x00200000, 0x00400000, 0x00800000, - 0x01000000, 0x02000000, 0x04000000, 0x08000000, - 0x10000000, 0x20000000, 0x40000000, 0x80000000 -} - - -#endif -; - -/* Look up Table for conversion copper layer count -> general copper layer mask: */ -eda_global int g_TabAllCopperLayerMask[NB_COPPER_LAYERS] -#if defined MAIN -= { - 0x0001, 0x8001, 0x8003, 0x8007, - 0x800F, 0x801F, 0x803F, 0x807F, - 0x80FF, 0x81FF, 0x83FF, 0x87FF, - 0x8FFF, 0x9FFF, 0xCFFF, 0xFFFF -}; -#endif -; - /* variables */ - -extern wxString g_Main_Title; - -eda_global bool Drc_On -#ifdef MAIN -= TRUE -#endif -; -eda_global bool g_AutoDeleteOldTrack /* Allows automatic deletion of the old track after - * creation of a new track */ -#ifdef MAIN -= TRUE -#endif -; -eda_global bool g_No_Via_Route; -eda_global bool g_Drag_Pistes_On; -eda_global bool g_Show_Ratsnest; -eda_global bool g_Show_Module_Ratsnest; -eda_global bool g_Show_Pads_Module_in_Move -#ifdef MAIN -= TRUE -#endif -; -eda_global bool g_Raccord_45_Auto -#ifdef MAIN -= TRUE -#endif -; -eda_global bool g_ShowIsolDuringCreateTrack; /* Show clearance while track creation */ - -/*********************************/ -/* Display options for board items */ -/*********************************/ - -eda_global DISPLAY_OPTIONS DisplayOpt; +extern bool Drc_On; +extern bool g_AutoDeleteOldTrack; +extern bool g_No_Via_Route; +extern bool g_Drag_Pistes_On; +extern bool g_Show_Ratsnest; +extern bool g_Show_Module_Ratsnest; +extern bool g_Show_Pads_Module_in_Move; +extern bool g_Raccord_45_Auto; +extern bool g_ShowIsolDuringCreateTrack; /** * Function IsModuleLayerVisible @@ -147,180 +75,50 @@ bool inline IsModuleLayerVisible( int layer ) { } -eda_global bool Track_45_Only; /* Flag pour limiter l'inclinaison - * pistes a 45 degres seulement */ -eda_global bool Segments_45_Only; /* Flag pour limiter l'inclinaison - * edge pcb a 45 degres seulement */ -eda_global wxString PcbExtBuffer // Board file extension -#ifdef MAIN -( wxT( ".brd" ) ) -#endif -; -eda_global wxString g_SaveFileName // File Name for periodic saving -#ifdef MAIN -( wxT( "$savepcb" ) ) -#endif -; -eda_global wxString NetExtBuffer // Netlist file extension -#ifdef MAIN -( wxT( ".net" ) ) -#endif -; -eda_global wxString NetCmpExtBuffer // cmp/footprint association file extension -#ifdef MAIN -( wxT( ".cmp" ) ) -#endif -; - -// Gestion de la liste des librairies -eda_global wxString LibExtBuffer -#ifdef MAIN -( wxT( ".mod" ) ) -#endif -; -eda_global wxString g_Shapes3DExtBuffer //3D shape file extension -#ifdef MAIN -( wxT( ".wrl" ) ) -#endif -; - -eda_global int g_CurrentVersionPCB -#ifdef MAIN -= 1 -#endif -; - -/* A buffer used in some computations (will be removed in next cleanup code, do not use) */ -#define BUFMEMSIZE 256000 /* buffer size (in bytes) */ -eda_global char* buf_work; /* pointeur sur le buffer de travail */ -eda_global char* adr_lowmem; /* adresse de base memoire de calcul disponible*/ -eda_global char* adr_himem; /* adresse haute limite de la memoire disponible*/ -eda_global char* adr_max; /* adresse haute maxi utilisee pour la memoire */ - - -/* variables generales */ -eda_global int g_TimeOut; // Timer for automatic saving -eda_global int g_SaveTime; // Time for next saving +extern bool Track_45_Only; +extern bool Segments_45_Only; +extern wxString g_Shapes3DExtBuffer; +/* A buffer used in some computations (will be removed in next cleanup code, + * do not use) */ +#define BUFMEMSIZE 256000 /* buffer size (in bytes) */ +extern char* buf_work; /* pointeur sur le buffer de travail */ +extern char* adr_lowmem; /* adresse de base memoire de calcul disponible*/ +extern char* adr_himem; /* adresse haute limite de la memoire disponible*/ +extern char* adr_max; /* adresse haute maxi utilisee pour la memoire */ /* Variables used in footprint handling */ -extern int Angle_Rot_Module; -eda_global wxSize ModuleTextSize; /* Default footprint texts size */ -eda_global int ModuleTextWidth; -eda_global int ModuleSegmentWidth; -eda_global int Texte_Module_Type; - - -/***********************/ -/* pistes , vias , pads*/ -/***********************/ - -#define L_MIN_DESSIN 1 /* Min width segments to allow draws with tickness */ - -// Current designe settings: -eda_global class EDA_BoardDesignSettings g_DesignSettings; - -// Default values for pad editions -#ifndef GERBVIEW -#ifdef MAIN -D_PAD g_Pad_Master( (MODULE*) NULL ); - -#else -extern D_PAD g_Pad_Master; -#endif -#endif - +extern int Angle_Rot_Module; +extern wxSize ModuleTextSize; /* Default footprint texts size */ +extern int ModuleTextWidth; +extern int ModuleSegmentWidth; /* Layer pair for auto routing and switch layers by hotkey */ -eda_global int Route_Layer_TOP; -eda_global int Route_Layer_BOTTOM; +extern int Route_Layer_TOP; +extern int Route_Layer_BOTTOM; + +extern int g_MaxLinksShowed; // Max count links showed in routing +extern bool g_TwoSegmentTrackBuild; + +extern int g_MagneticPadOption; +extern int g_MagneticTrackOption; + +/* Variables to handle hightlight nets */ +extern bool g_HightLigt_Status; +extern int g_HightLigth_NetCode; + +extern PCB_SCREEN* ScreenModule; /* Ecran de l'editeur de modules */ + +extern wxPoint g_Offset_Module; /* Offset de trace du modul en depl */ + +extern wxString g_Current_PadName; // Last used pad name (pad num) -eda_global int g_MaxLinksShowed; // Mxa count links showed in routing -eda_global bool g_TwoSegmentTrackBuild // FALSE = 1 segment build, TRUE = 2 45 deg segm build -#ifdef MAIN -= TRUE -#endif -; -/* How to handle magnetic pads & tracks: feature to move the pcb cursor on a pad center / track length */ enum MagneticPadOptionValues { no_effect, capture_cursor_in_track_tool, capture_always }; -eda_global int g_MagneticPadOption -#ifdef MAIN -= capture_cursor_in_track_tool -#endif -; -eda_global int g_MagneticTrackOption -#ifdef MAIN -= capture_cursor_in_track_tool -#endif -; -/* Variables to handle hightlight nets */ -eda_global bool g_HightLigt_Status; -eda_global int g_HightLigth_NetCode -#ifdef MAIN -= -1 -#endif -; - - -/** - * Used in track creation, a list of track segments currently being created, - * with the newest track at the end of the list, sorted by new-ness. e.g. use - * TRACK->Back() to get the next older track, TRACK->Next() to get the next - * newer track. - */ -eda_global DLIST g_CurrentTrackList; - -#define g_CurrentTrackSegment g_CurrentTrackList.GetLast() ///< most recently created segment -#define g_FirstTrackSegment g_CurrentTrackList.GetFirst() ///< first segment created - -eda_global wxString g_ViaType_Name[4] -#if defined MAIN -= { - _( "??? Via" ), // Not used yet - _( "Micro Via" ), // from external layer (TOP or BOTTOM) from the near neightbour inner layer only - _( "Blind/Buried Via" ), // from inner or external to inner or external layer (no restriction) - _( "Through Via" ) // Usual via (from TOP to BOTTOM layer only ) -} - - -#endif -; -/* couleurs des autres items des empreintes */ -#if defined MAIN -int g_PadCMPColor = RED; -int g_PadCUColor = GREEN; -int g_AnchorColor = BLUE; -int g_ModuleTextCMPColor = LIGHTGRAY; -int g_ModuleTextCUColor = MAGENTA; -int g_ModuleTextNOVColor = DARKGRAY; -#else -eda_global int g_ModuleTextCMPColor; -eda_global int g_ModuleTextCUColor; -eda_global int g_ModuleTextNOVColor; -eda_global int g_AnchorColor; -eda_global int g_PadCUColor; -eda_global int g_PadCMPColor; -#endif - -eda_global PCB_SCREEN* ScreenPcb; /* Ecran principal */ -eda_global BOARD* g_ModuleEditor_Pcb; /* board used to edit footprints (used by modedit)*/ -eda_global PCB_SCREEN* ScreenModule; /* Ecran de l'editeur de modules */ - - -/****************************************************/ -/* Gestion du deplacement des modules et des pistes */ -/****************************************************/ - -eda_global wxPoint g_Offset_Module; /* Offset de trace du modul en depl */ - -/* Pad editing */ -eda_global wxString g_Current_PadName; // Last used pad name (pad num) - #endif /* PCBNEW_H */ diff --git a/pcbnew/pcbplot.cpp b/pcbnew/pcbplot.cpp index 4712651e51..147120c611 100644 --- a/pcbnew/pcbplot.cpp +++ b/pcbnew/pcbplot.cpp @@ -644,11 +644,12 @@ void WinEDA_PlotFrame::SaveOptPlot( wxCommandEvent& event ) void WinEDA_PlotFrame::Plot( wxCommandEvent& event ) /***************************************************/ { - int layer_to_plot; - wxString FullFileName, BaseFileName; - wxString ext; + int layer_to_plot; + wxFileName fn; + wxString ext; + wxString wildcard; - BOARD* board = m_Parent->GetBoard(); + BOARD* board = m_Parent->GetBoard(); SaveOptPlot( event ); @@ -676,23 +677,23 @@ void WinEDA_PlotFrame::Plot( wxCommandEvent& event ) int format = getFormat(); - BaseFileName = m_Parent->GetScreen()->m_FileName; - ChangeFileNameExt( BaseFileName, wxT( "-" ) ); - switch( format ) { case PLOT_FORMAT_POST: - ext = wxT( ".ps" ); + ext = wxT( "ps" ); + wildcard = _( "Adobe post script files (.ps)|*.ps" ); break; default: case PLOT_FORMAT_GERBER: Scale_X = Scale_Y = 1.0; // No scale option allowed in gerber format - ext = wxT( ".pho" ); + ext = wxT( "pho" ); + wildcard = _( "GERBER photo plot files (.pho)|*.pho" ); break; case PLOT_FORMAT_HPGL: - ext = wxT( ".plt" ); + ext = wxT( "plt" ); + wildcard = _( "HPGL plat files (.plt)|*.plt" ); break; } @@ -711,22 +712,27 @@ void WinEDA_PlotFrame::Plot( wxCommandEvent& event ) { s_SelectedLayers |= mask; + fn = m_Parent->GetScreen()->m_FileName; + // Calcul du nom du fichier - FullFileName = BaseFileName + board->GetLayerName( layer_to_plot ) + ext; + fn.SetName( fn.GetName() + wxT( "-" ) + + board->GetLayerName( layer_to_plot ) ); + fn.SetExt( ext ); switch( format ) { case PLOT_FORMAT_POST: - m_Parent->Genere_PS( FullFileName, layer_to_plot, useA4() ); + m_Parent->Genere_PS( fn.GetFullPath(), layer_to_plot, useA4() ); break; default: case PLOT_FORMAT_GERBER: - m_Parent->Genere_GERBER( FullFileName, layer_to_plot, s_PlotOriginIsAuxAxis ); + m_Parent->Genere_GERBER( fn.GetFullPath(), layer_to_plot, + s_PlotOriginIsAuxAxis ); break; case PLOT_FORMAT_HPGL: - m_Parent->Genere_HPGL( FullFileName, layer_to_plot ); + m_Parent->Genere_HPGL( fn.GetFullPath(), layer_to_plot ); break; } } diff --git a/pcbnew/pcbplot.h b/pcbnew/pcbplot.h index e1eb037108..fab4b4ccbc 100644 --- a/pcbnew/pcbplot.h +++ b/pcbnew/pcbplot.h @@ -6,10 +6,6 @@ #define PCBPLOT_H -#ifndef eda_global -#define eda_global extern -#endif - /* Shared Config keys for plot and print */ #define OPTKEY_PLOT_LINEWIDTH_VALUE wxT( "PlotLineWidth" ) #define OPTKEY_LAYERBASE wxT( "PlotLayer_%d" ) @@ -24,97 +20,33 @@ #define SCALE_HPGL 0.102041 /* Options : */ -eda_global bool g_Exclude_Edges_Pcb // True to exclude contents of Edges Pcb layer -#ifdef MAIN -= FALSE -#endif -; -eda_global bool g_Plot_Frame_Ref; // True to plot/print frame references -eda_global bool g_DrawViaOnMaskLayer; // True if vias are drawn on Mask layer (ie protected by mask) -eda_global int g_Plot_Mode // = FILAIRE, FILL or SKETCH -#ifdef MAIN -= FILLED -#endif -; -eda_global bool Plot_Set_MIROIR; -eda_global bool Sel_Rotate_Window; -eda_global bool HPGL_Org_Centre; // TRUE si en HPGL, l'origine le centre de la feuille -eda_global int g_PlotPSColorOpt; // True for color Postscript output -eda_global bool g_Plot_PS_Negative; // True to create a negative board ps plot +extern bool g_Exclude_Edges_Pcb; +extern bool g_Plot_Frame_Ref; // True to plot/print frame references +extern bool g_DrawViaOnMaskLayer; // True if vias are drawn on Mask layer (ie protected by mask) +extern int g_Plot_Mode; +extern bool Plot_Set_MIROIR; +extern bool Sel_Rotate_Window; +extern bool HPGL_Org_Centre; // TRUE si en HPGL, l'origine le centre de la feuille +extern int g_PlotPSColorOpt; // True for color Postscript output +extern bool g_Plot_PS_Negative; // True to create a negative board ps plot /* Autorisation de trace des divers items en serigraphie */ -eda_global bool Sel_Texte_Reference -#ifdef MAIN -= TRUE -#endif -; -eda_global bool Sel_Texte_Valeur -#ifdef MAIN -= TRUE -#endif -; -eda_global bool Sel_Texte_Divers -#ifdef MAIN -= TRUE -#endif -; -eda_global bool Sel_Texte_Invisible; -eda_global bool PlotPadsOnSilkLayer /* Plot pads sur couche serigraphie */ -#ifdef MAIN -= TRUE -#endif -; -eda_global bool Plot_Pads_All_Layers; /* Plot pads meme n'appartenant pas a la - * couche ( utile pour serigraphie) */ +extern bool Sel_Texte_Reference; +extern bool Sel_Texte_Valeur; +extern bool Sel_Texte_Divers; +extern bool Sel_Texte_Invisible; +extern bool PlotPadsOnSilkLayer; +extern bool Plot_Pads_All_Layers; /* Plot pads meme n'appartenant pas a la + couche ( utile pour serigraphie) */ /* Variables utiles */ -eda_global FILE* dest; - -/* Gestion des plumes en plot format HPGL */ -eda_global int g_HPGL_Pen_Num /* num de plume a charger */ -#ifdef MAIN -= 1 -#endif -; -eda_global int g_HPGL_Pen_Speed /* vitesse en cm/s */ -#ifdef MAIN -= 40 -#endif -; -eda_global int g_HPGL_Pen_Diam; /* diametre en mils */ -eda_global int g_HPGL_Pen_Recouvrement; /* recouvrement en mils ( pour remplissages */ - -/* Gestion des cadrages et echelles de trace */ -eda_global float Scale_X, Scale_Y; /* coeff d'agrandissement en X et Y demandes */ -eda_global wxPoint g_PlotOffset; /* Offset de trace modifies par l'echelle */ - -eda_global int g_PlotLine_Width; /* Largeur du trait en mode filaire (utilise en serigraphie, - * pour traces en mode sketch et filaire) */ - -eda_global int g_PlotFormat /* id for plot format (see enum PlotFormat in plot_common.h) */ -#ifdef MAIN -= PLOT_FORMAT_GERBER -#endif -; -eda_global int g_PlotOrient; /* numero de code de l'orientation du trace ( voir - * defines precedents): - * 0 = normal - * PLOT_MIROIR = MIROIR - */ -eda_global int g_PlotScaleOpt // 0 = automatique, >=1 echelle specifiee -#ifdef MAIN -= 1 -#endif -; - -eda_global int g_DrillShapeOpt -#ifdef MAIN -= 1 // 0 = no drill mark, 1 = small mark, 2 = real drill -#endif -; +extern FILE * dest; +/* id for plot format (see enum PlotFormat in plot_common.h) */ +extern int g_PlotScaleOpt; +extern int g_DrillShapeOpt; /*************************************/ /* Constantes utiles en trace GERBER */ @@ -181,7 +113,7 @@ void PlotRectangularPad_HPGL( wxPoint padpos, wxSize padsize, int orient, int void trace_1_pastille_OVALE_POST( wxPoint centre, wxSize size, int orient, int modetrace ); void trace_1_pastille_RONDE_POST( wxPoint centre, int diametre, int modetrace ); void trace_1_pad_rectangulaire_POST( wxPoint centre, wxSize size, int orient, - int modetrace ); + int modetrace ); void trace_1_contour_POST( wxPoint centre, wxSize size, wxSize delta, int dim_trait, int orient ); void trace_1_pad_TRAPEZE_POST( wxPoint centre, wxSize size, wxSize delta, diff --git a/pcbnew/plotgerb.cpp b/pcbnew/plotgerb.cpp index b2576ec40a..e517035a3e 100644 --- a/pcbnew/plotgerb.cpp +++ b/pcbnew/plotgerb.cpp @@ -1,3 +1,4 @@ + /*********************************************************/ /****Function to plot a board in GERBER RS274X format ****/ /*********************************************************/ @@ -16,6 +17,7 @@ #include "pcbnew.h" #include "pcbplot.h" #include "trigo.h" +#include "appl_wxstruct.h" /* Class to handle a D_CODE when plotting a board : */ #define FIRST_DCODE_VALUE 10 // D_CODE < 10 is a command, D_CODE >= 10 is a tool @@ -113,7 +115,7 @@ void WinEDA_BasePcbFrame::Genere_GERBER( const wxString& FullFileName, int Layer s_Last_D_code = 0; - Write_Header_GERBER( g_Main_Title, g_Plot_PlotOutputFile ); + Write_Header_GERBER( wxGetApp().GetAppName(), g_Plot_PlotOutputFile ); int layer_mask = g_TabOneLayerMask[Layer]; diff --git a/pcbnew/plothpgl.cpp b/pcbnew/plothpgl.cpp index 0b405d28dd..3f56faccd1 100644 --- a/pcbnew/plothpgl.cpp +++ b/pcbnew/plothpgl.cpp @@ -49,7 +49,7 @@ void WinEDA_BasePcbFrame::Genere_HPGL( const wxString& FullFileName, int Layer ) // Compute pen_dim (from g_HPGL_Pen_Diam in mils) in pcb units, // with plot scale (if Scale is 2, pen diametre is always g_HPGL_Pen_Diam // so apparent pen diam is real pen diam / Scale - pen_diam = (int) round( (g_HPGL_Pen_Diam * U_PCB) / Scale_X ); // Assume Scale_X # Scale_Y + pen_diam = wxRound( (g_HPGL_Pen_Diam * U_PCB) / Scale_X ); // Assume Scale_X # Scale_Y pen_rayon = pen_diam / 2; s_Nb_Plot_Errors = 0; @@ -60,7 +60,7 @@ void WinEDA_BasePcbFrame::Genere_HPGL( const wxString& FullFileName, int Layer ) g_HPGL_Pen_Recouvrement = 0; if( g_HPGL_Pen_Recouvrement >= g_HPGL_Pen_Diam ) g_HPGL_Pen_Recouvrement = g_HPGL_Pen_Diam - 1; - pen_recouvrement = (int) round( g_HPGL_Pen_Recouvrement * 10.0 / Scale_X ); + pen_recouvrement = wxRound( g_HPGL_Pen_Recouvrement * 10.0 / Scale_X ); dest = wxFopen( FullFileName, wxT( "wt" ) ); if( dest == NULL ) diff --git a/pcbnew/router.cpp b/pcbnew/router.cpp index d348cfee0d..52ddf45deb 100644 --- a/pcbnew/router.cpp +++ b/pcbnew/router.cpp @@ -37,10 +37,11 @@ void WinEDA_PcbFrame::GlobalRoute( wxDC* DC ) /******************************************/ { #ifdef ROUTER - FILE* outfile; - wxString FullFileName, ExecFileName, msg; - int ii; - int net_number; + wxFileName fn; + FILE* outfile; + wxString ExecFileName, msg; + int ii; + int net_number; #ifdef __UNIX__ ExecFileName = FindKicadFile( wxT( "anneal" ) ); @@ -56,17 +57,17 @@ void WinEDA_PcbFrame::GlobalRoute( wxDC* DC ) } /* Calcule du nom du fichier intermediaire de communication */ - FullFileName = GetScreen()->m_FileName; - ChangeFileNameExt( FullFileName, wxT( ".ipt" ) ); + fn = GetScreen()->m_FileName; + fn.SetExt( wxT( "ipt" ) ); - if( ( outfile = wxFopen( FullFileName, wxT( "wt" ) ) ) == NULL ) + if( ( outfile = wxFopen( fn.GetFullPath(), wxT( "wt" ) ) ) == NULL ) { - msg = _( "Unable to create temporary file " ) + FullFileName; + msg = _( "Unable to create temporary file " ) + fn.GetFullPath(); DisplayError( this, msg, 20 ); return; } - msg = _( "Create temporary file " ) + FullFileName; + msg = _( "Create temporary file " ) + fn.GetFullPath(); SetStatusText( msg ); /* calcul ratsnest */ @@ -134,7 +135,7 @@ void WinEDA_PcbFrame::GlobalRoute( wxDC* DC ) fclose( outfile ); - ExecFileName += wxT( " " ) + FullFileName; + ExecFileName += wxT( " " ) + fn.GetFullPath(); Affiche_Message( ExecFileName ); @@ -551,30 +552,31 @@ int GenEdges( BOARD* Pcb, FILE* outfile ) void WinEDA_PcbFrame::ReadAutoroutedTracks( wxDC* DC ) /****************************************************/ { - char Line[1024]; - wxString FullFileName, msg; - int LineNum = 0, NbTrack = 0, NetCode = 0; - FILE* File; - TRACK* newTrack; - SEGVIA* newVia; - int track_count, track_layer, image, track_width; - int via_layer1, via_layer2, via_size; - wxPoint track_start, track_end; - int max_layer = GetBoard()->m_BoardSettings->m_CopperLayerCount; + wxFileName fn; + char Line[1024]; + wxString msg; + int LineNum = 0, NbTrack = 0, NetCode = 0; + FILE* File; + TRACK* newTrack; + SEGVIA* newVia; + int track_count, track_layer, image, track_width; + int via_layer1, via_layer2, via_size; + wxPoint track_start, track_end; + int max_layer = GetBoard()->m_BoardSettings->m_CopperLayerCount; /* Calcule du nom du fichier intermediaire de communication */ - FullFileName = GetScreen()->m_FileName; - ChangeFileNameExt( FullFileName, wxT( ".trc" ) ); + fn = GetScreen()->m_FileName; + fn.SetExt( wxT( "trc" ) ); - if( ( File = wxFopen( FullFileName, wxT( "rt" ) ) ) == NULL ) + if( ( File = wxFopen( fn.GetFullPath(), wxT( "rt" ) ) ) == NULL ) { - msg = _( "Unable to find data file " ) + FullFileName; + msg = _( "Unable to find data file " ) + fn.GetFullPath(); DisplayError( this, msg, 20 ); return; } else { - msg = _( "Reading autorouter data file " ) + FullFileName; + msg = _( "Reading autorouter data file " ) + fn.GetFullPath(); Affiche_Message( msg ); } diff --git a/pcbnew/set_grid.cpp b/pcbnew/set_grid.cpp index be65150b97..5b33a57141 100644 --- a/pcbnew/set_grid.cpp +++ b/pcbnew/set_grid.cpp @@ -19,39 +19,23 @@ #include "set_grid.h" -/****************************************************************/ -void WinEDA_PcbGridFrame::AcceptPcbOptions(wxCommandEvent& event) -/****************************************************************/ -{ - double dtmp = 0; - - g_UserGrid_Unit = m_UnitGrid->GetSelection(); - m_OptGridSizeX->GetValue().ToDouble( &dtmp ); - g_UserGrid.x = dtmp; - m_OptGridSizeY->GetValue().ToDouble( &dtmp ); - g_UserGrid.y = dtmp; - - m_Parent->GetScreen()->AddGrid( g_UserGrid, g_UserGrid_Unit, ID_POPUP_GRID_USER ); - - EndModal(1); - - // If the user grid is the current selection , ensure grid size value = new user grid value - int ii = m_Parent->m_SelGridBox->GetSelection(); - if ( ii == (int)(m_Parent->m_SelGridBox->GetCount() - 1) ) - m_Parent->GetScreen()->SetGrid( ID_POPUP_GRID_USER ); - - m_Parent->DrawPanel->Refresh( TRUE ); -} - - /************************************************************/ void WinEDA_BasePcbFrame::InstallGridFrame(const wxPoint & pos) -/************************************************************/ { - WinEDA_PcbGridFrame * GridFrame = - new WinEDA_PcbGridFrame( this, pos ); - GridFrame->ShowModal(); GridFrame->Destroy(); + WinEDA_PcbGridFrame dlg( this, pos ); + + dlg.SetGridSize( m_UserGridSize ); + dlg.SetGridUnits( m_UserGridUnits ); + + if( dlg.ShowModal() == wxID_CANCEL ) + return; + + m_UserGridSize = dlg.GetGridSize(); + m_UserGridUnits = dlg.GetGridUnits(); + + GetScreen()->AddGrid( m_UserGridSize, m_UserGridUnits, ID_POPUP_GRID_USER ); + DrawPanel->Refresh(); } @@ -90,21 +74,7 @@ WinEDA_PcbGridFrame::WinEDA_PcbGridFrame( WinEDA_BasePcbFrame* parent, const wxString& caption, const wxSize& size, long style ) { - wxString msg; - PCB_SCREEN * screen; - - m_Parent = parent; - screen = (PCB_SCREEN*)(m_Parent->GetScreen()); - Create(parent, id, caption, pos, size, style); - - if ( g_UserGrid_Unit != INCHES ) - m_UnitGrid->SetSelection(1); - - msg.Printf( wxT("%.4f"), g_UserGrid.x ); - m_OptGridSizeX->SetValue(msg); - msg.Printf( wxT("%.4f"), g_UserGrid.y ); - m_OptGridSizeY->SetValue(msg); } /*! @@ -227,7 +197,6 @@ wxIcon WinEDA_PcbGridFrame::GetIconResource( const wxString& name ) void WinEDA_PcbGridFrame::OnOkClick( wxCommandEvent& event ) { - AcceptPcbOptions(event); } /*! @@ -242,4 +211,35 @@ void WinEDA_PcbGridFrame::OnCancelClick( wxCommandEvent& event ) ////@end wxEVT_COMMAND_BUTTON_CLICKED event handler for wxID_CANCEL in WinEDA_PcbGridFrame. } +void WinEDA_PcbGridFrame::SetGridSize( const wxRealPoint& grid ) +{ + wxString msg; + msg.Printf( wxT( "%.4f" ), grid.x ); + m_OptGridSizeX->SetValue( msg ); + msg.Printf( wxT( "%.4f" ), grid.y ); + m_OptGridSizeY->SetValue( msg ); +} + +wxRealPoint WinEDA_PcbGridFrame::GetGridSize() +{ + wxRealPoint grid; + + + /* TODO: Some error checking here would be a good thing. */ + m_OptGridSizeX->GetValue().ToDouble( &grid.x ); + m_OptGridSizeY->GetValue().ToDouble( &grid.y ); + + return grid; +} + +void WinEDA_PcbGridFrame::SetGridUnits( int units ) +{ + if ( units != INCHES ) + m_UnitGrid->SetSelection( 1 ); +} + +int WinEDA_PcbGridFrame::GetGridUnits() +{ + return m_UnitGrid->GetSelection(); +} diff --git a/pcbnew/set_grid.h b/pcbnew/set_grid.h index 13c67e25eb..fb3985ae6d 100644 --- a/pcbnew/set_grid.h +++ b/pcbnew/set_grid.h @@ -96,14 +96,18 @@ public: /// Should we show tooltips? static bool ShowToolTips(); - void AcceptPcbOptions(wxCommandEvent& event); ////@begin WinEDA_PcbGridFrame member variables wxRadioBox* m_UnitGrid; wxTextCtrl* m_OptGridSizeX; wxTextCtrl* m_OptGridSizeY; ////@end WinEDA_PcbGridFrame member variables - WinEDA_BasePcbFrame * m_Parent; + + void SetGridUnits( int units ); + int GetGridUnits(); + + void SetGridSize( const wxRealPoint& grid ); + wxRealPoint GetGridSize(); }; #endif diff --git a/pcbnew/specctra_import.cpp b/pcbnew/specctra_import.cpp index a87018fe77..d3b10b4741 100644 --- a/pcbnew/specctra_import.cpp +++ b/pcbnew/specctra_import.cpp @@ -172,7 +172,7 @@ static int scale( double distance, UNIT_RES* aResolution ) // used within Kicad. factor *= 10.0; - int ret = (int) round( factor * distance / resValue ); + int ret = wxRound( factor * distance / resValue ); return ret; } diff --git a/pcbnew/tool_modedit.cpp b/pcbnew/tool_modedit.cpp index f5bc3da6b0..7fb79098f5 100644 --- a/pcbnew/tool_modedit.cpp +++ b/pcbnew/tool_modedit.cpp @@ -44,7 +44,7 @@ void WinEDA_ModuleEditFrame::ReCreateHToolbar() wxBitmap( save_library_xpm ), _( "Save Module in working library" ) ); - m_HToolBar->AddTool( ID_LIBEDIT_CREATE_NEW_LIB_AND_SAVE_CURRENT_PART, + m_HToolBar->AddTool( ID_MODEDIT_CREATE_NEW_LIB_AND_SAVE_CURRENT_PART, wxEmptyString, wxBitmap( new_library_xpm ), _( "Create new library and save current module" ) ); @@ -77,11 +77,11 @@ void WinEDA_ModuleEditFrame::ReCreateHToolbar() _( "Insert module into current board" ) ); m_HToolBar->AddSeparator(); - m_HToolBar->AddTool( ID_LIBEDIT_IMPORT_PART, wxEmptyString, + m_HToolBar->AddTool( ID_MODEDIT_IMPORT_PART, wxEmptyString, wxBitmap( import_module_xpm ), _( "import module" ) ); - m_HToolBar->AddTool( ID_LIBEDIT_EXPORT_PART, wxEmptyString, + m_HToolBar->AddTool( ID_MODEDIT_EXPORT_PART, wxEmptyString, wxBitmap( export_module_xpm ), _( "export module" ) ); diff --git a/pcbnew/tracemod.cpp b/pcbnew/tracemod.cpp index 127c25bd0b..b417e3f40b 100644 --- a/pcbnew/tracemod.cpp +++ b/pcbnew/tracemod.cpp @@ -9,14 +9,7 @@ #include "class_drawpanel.h" #include "pcbnew.h" - -#ifdef PCBNEW #include "drag.h" -#endif - -#ifdef CVPCB -#include "cvpcb.h" -#endif /* Police des caracteres de la routine de trace des textes */ extern char* graphic_fonte_shape[]; diff --git a/pcbnew/tracepcb.cpp b/pcbnew/tracepcb.cpp index 8f8b9d4da5..f6355e434f 100644 --- a/pcbnew/tracepcb.cpp +++ b/pcbnew/tracepcb.cpp @@ -49,7 +49,7 @@ void WinEDA_ModuleEditFrame::RedrawActiveWindow( wxDC* DC, bool EraseBg ) module->Draw( DrawPanel, DC, GR_OR ); } - Affiche_Status_Box(); + UpdateStatusBar(); if( DrawPanel->ManageCurseur ) DrawPanel->ManageCurseur( DrawPanel, DC, FALSE ); @@ -89,7 +89,7 @@ void WinEDA_PcbFrame::RedrawActiveWindow( wxDC* DC, bool EraseBg ) GetScreen()->ClrRefreshReq(); - Affiche_Status_Box(); + UpdateStatusBar(); if( DrawPanel->ManageCurseur ) DrawPanel->ManageCurseur( DrawPanel, DC, FALSE ); diff --git a/pcbnew/xchgmod.cpp b/pcbnew/xchgmod.cpp index 22374861e6..02d2128f25 100644 --- a/pcbnew/xchgmod.cpp +++ b/pcbnew/xchgmod.cpp @@ -68,12 +68,18 @@ private: }; BEGIN_EVENT_TABLE( WinEDA_ExchangeModuleFrame, wxDialog ) -EVT_BUTTON( ID_EXEC_EXCHANGE_MODULE, WinEDA_ExchangeModuleFrame::Change_Module ) -EVT_BUTTON( ID_EXEC_EXCHANGE_ID_MODULES, WinEDA_ExchangeModuleFrame::Change_ModuleId ) -EVT_BUTTON( ID_EXEC_EXCHANGE_ID_MODULE_AND_VALUE, WinEDA_ExchangeModuleFrame::Change_ModuleId ) -EVT_BUTTON( ID_EXEC_EXCHANGE_ALL_MODULES, WinEDA_ExchangeModuleFrame::Change_ModuleAll ) -EVT_BUTTON( ID_CLOSE_EXCHANGE_MODULE, WinEDA_ExchangeModuleFrame::OnQuit ) -EVT_BUTTON( ID_BROWSE_LIB_MODULES, WinEDA_ExchangeModuleFrame::Sel_NewMod_By_Liste ) + EVT_BUTTON( ID_EXEC_EXCHANGE_MODULE, + WinEDA_ExchangeModuleFrame::Change_Module ) + EVT_BUTTON( ID_EXEC_EXCHANGE_ID_MODULES, + WinEDA_ExchangeModuleFrame::Change_ModuleId ) + EVT_BUTTON( ID_EXEC_EXCHANGE_ID_MODULE_AND_VALUE, + WinEDA_ExchangeModuleFrame::Change_ModuleId ) + EVT_BUTTON( ID_EXEC_EXCHANGE_ALL_MODULES, + WinEDA_ExchangeModuleFrame::Change_ModuleAll ) + EVT_BUTTON( ID_CLOSE_EXCHANGE_MODULE, + WinEDA_ExchangeModuleFrame::OnQuit ) + EVT_BUTTON( ID_BROWSE_LIB_MODULES, + WinEDA_ExchangeModuleFrame::Sel_NewMod_By_Liste ) END_EVENT_TABLE() @@ -107,59 +113,61 @@ WinEDA_ExchangeModuleFrame::WinEDA_ExchangeModuleFrame( WinEDA_BasePcbFrame* par /* Creation des boutons de commande */ Button = new wxButton( this, ID_EXEC_EXCHANGE_MODULE, - _( "Change module" ) ); + _( "Change module" ) ); Button->SetForegroundColour( *wxBLUE ); RightBoxSizer->Add( Button, 0, wxGROW | wxLEFT | wxRIGHT | wxTOP, 5 ); Button = new wxButton( this, ID_EXEC_EXCHANGE_ID_MODULES, - _( "Change same modules" ) ); + _( "Change same modules" ) ); Button->SetForegroundColour( *wxRED ); RightBoxSizer->Add( Button, 0, wxGROW | wxLEFT | wxRIGHT, 5 ); Button = new wxButton( this, ID_EXEC_EXCHANGE_ID_MODULE_AND_VALUE, - _( "Ch. same module+value" ) ); + _( "Ch. same module+value" ) ); Button->SetForegroundColour( *wxRED ); RightBoxSizer->Add( Button, 0, wxGROW | wxLEFT | wxRIGHT, 5 ); Button = new wxButton( this, ID_EXEC_EXCHANGE_ALL_MODULES, - _( "Change all" ) ); + _( "Change all" ) ); Button->SetForegroundColour( *wxRED ); RightBoxSizer->Add( Button, 0, wxGROW | wxLEFT | wxRIGHT, 5 ); Button = new wxButton( this, ID_BROWSE_LIB_MODULES, - _( "Browse Libs modules" ) ); + _( "Browse Libs modules" ) ); Button->SetForegroundColour( wxColour( 0, 100, 0 ) ); RightBoxSizer->Add( Button, 0, wxGROW | wxLEFT | wxRIGHT, 5 ); Button = new wxButton( this, ID_CLOSE_EXCHANGE_MODULE, - _( "Close" ) ); + _( "Close" ) ); Button->SetForegroundColour( *wxBLUE ); RightBoxSizer->Add( Button, 0, wxGROW | wxLEFT | wxRIGHT | wxBOTTOM, 5 ); m_OldModule = new WinEDA_EnterText( this, _( "Current Module" ), - m_CurrentModule ? - m_CurrentModule->m_LibRef.GetData () : wxEmptyString, - LeftBoxSizer, wxSize( 150, -1 ) ); + m_CurrentModule ? + m_CurrentModule->m_LibRef.GetData () : wxEmptyString, + LeftBoxSizer, wxSize( 150, -1 ) ); m_OldModule->Enable( FALSE ); m_OldValue = new WinEDA_EnterText( this, _( "Current Value" ), - m_CurrentModule ? - m_CurrentModule->m_Value->m_Text.GetData () : wxEmptyString, - LeftBoxSizer, wxSize( 150, -1 ) ); + m_CurrentModule ? + m_CurrentModule->m_Value->m_Text.GetData () : wxEmptyString, + LeftBoxSizer, wxSize( 150, -1 ) ); m_OldValue->Enable( FALSE ); m_NewModule = new WinEDA_EnterText( this, _( "New Module" ), - m_OldModule->GetValue(), LeftBoxSizer, wxSize( 150, -1 ) ); + m_OldModule->GetValue(), + LeftBoxSizer, wxSize( 150, -1 ) ); - m_WinMsg = new wxTextCtrl( this, -1, wxEmptyString, wxDefaultPosition, wxSize( 340, 230 ), + m_WinMsg = new wxTextCtrl( this, -1, wxEmptyString, wxDefaultPosition, + wxSize( 340, 230 ), wxTE_READONLY | wxTE_MULTILINE ); MainBoxSizer->Add( m_WinMsg, 0, wxGROW | wxALL, 5 ); @@ -171,13 +179,14 @@ WinEDA_ExchangeModuleFrame::WinEDA_ExchangeModuleFrame( WinEDA_BasePcbFrame* par /*********************************************************************/ void WinEDA_BasePcbFrame::InstallExchangeModuleFrame( MODULE* Module, - wxDC* DC, const wxPoint& pos ) -/*********************************************************************/ + wxDC* DC, + const wxPoint& pos ) { - WinEDA_ExchangeModuleFrame* frame = new WinEDA_ExchangeModuleFrame( this, - Module, DC, pos ); + WinEDA_ExchangeModuleFrame* frame = + new WinEDA_ExchangeModuleFrame( this, Module, DC, pos ); - frame->ShowModal(); frame->Destroy(); + frame->ShowModal(); + frame->Destroy(); } @@ -205,39 +214,41 @@ int WinEDA_ExchangeModuleFrame::Maj_ListeCmp( * Retoure 1 si erreur */ { - wxString FileNameCmp, tmpfile; - FILE* FichCmp, * NewFile; - char Line[1024]; - wxString msg; + wxFileName fn; + wxFileName tmpFileName; + FILE* FichCmp, * NewFile; + char Line[1024]; + wxString msg; if( old_name == new_name ) return 0; /* pas de changement de nom */ /* Calcul nom fichier CMP par changement de l'extension du nom netliste */ - FileNameCmp = m_Parent->GetScreen()->m_FileName; - ChangeFileNameExt( FileNameCmp, NetCmpExtBuffer ); + fn = m_Parent->GetScreen()->m_FileName; + fn.SetExt( NetCmpExtBuffer ); // Modification du fichier .cmp correcpondant - FichCmp = wxFopen( FileNameCmp, wxT( "rt" ) ); + FichCmp = wxFopen( fn.GetFullPath(), wxT( "rt" ) ); if( FichCmp == NULL ) { if( ShowError ) { - msg.Printf( _( "file %s not found" ), FileNameCmp.GetData() ); + msg.Printf( _( "file %s not found" ), fn.GetFullPath().c_str() ); m_WinMsg->WriteText( msg ); } return 1; } /* Analyse du fichier et modif */ - tmpfile = FileNameCmp; - ChangeFileNameExt( tmpfile, wxT( ".$$$" ) ); - NewFile = wxFopen( tmpfile, wxT( "wt" ) ); + tmpFileName = fn; + tmpFileName.SetExt( wxT( "$$$" ) ); + NewFile = wxFopen( tmpFileName.GetFullPath(), wxT( "wt" ) ); if( NewFile == NULL ) { if( ShowError ) { - msg.Printf( _( "Unable to create file %s" ), tmpfile.GetData() ); + msg.Printf( _( "Unable to create file %s" ), + tmpFileName.GetFullPath().c_str() ); m_WinMsg->WriteText( msg ); } return 1; @@ -270,7 +281,7 @@ int WinEDA_ExchangeModuleFrame::Maj_ListeCmp( { sprintf( Line + 8, " = %s;\n", CONV_TO_UTF8( new_name ) ); - msg.Printf( wxT( " * in %s\n" ), FileNameCmp.GetData() ); + msg = wxT( " * in <" ) + fn.GetFullPath() + wxT( ">.\n" ); m_WinMsg->WriteText( msg ); start_descr = FALSE; @@ -280,8 +291,8 @@ int WinEDA_ExchangeModuleFrame::Maj_ListeCmp( fclose( FichCmp ); fclose( NewFile ); - wxRemoveFile( FileNameCmp ); - wxRenameFile( tmpfile, FileNameCmp ); + wxRemoveFile( fn.GetFullPath() ); + wxRenameFile( tmpFileName.GetFullPath(), fn.GetFullPath() ); return 0; } @@ -478,7 +489,7 @@ MODULE* WinEDA_ExchangeModuleFrame::Change_1_Module( MODULE* Module, /* Chargement du module */ Line.Printf( _( "Change module %s (%s) " ), - Module->m_Reference->m_Text.GetData(), oldnamecmp.GetData() ); + Module->m_Reference->m_Text.GetData(), oldnamecmp.GetData() ); m_WinMsg->WriteText( Line ); namecmp.Trim( TRUE ); @@ -610,11 +621,12 @@ void WinEDA_PcbFrame::RecreateCmpFileFromBoard(wxCommandEvent& aEvent) * can be used if this file is lost */ { - wxString FullFileNameCmp, mask; - FILE* FichCmp; - char Line[1024]; - MODULE* Module = GetBoard()->m_Modules; - wxString msg; + wxFileName fn; + FILE* FichCmp; + char Line[1024]; + MODULE* Module = GetBoard()->m_Modules; + wxString msg; + wxString wildcard; if( Module == NULL ) { @@ -623,33 +635,31 @@ void WinEDA_PcbFrame::RecreateCmpFileFromBoard(wxCommandEvent& aEvent) } /* Calcul nom fichier CMP par changement de l'extension du nom netliste */ - FullFileNameCmp = GetScreen()->m_FileName; - ChangeFileNameExt( FullFileNameCmp, NetCmpExtBuffer ); + fn = GetScreen()->m_FileName; + fn.SetExt( NetCmpExtBuffer ); + wildcard = _( "Component files (." ) + NetCmpExtBuffer + wxT( ")|*." ) + + NetCmpExtBuffer; - mask = wxT( "*" ) + NetCmpExtBuffer; - FullFileNameCmp = EDA_FileSelector( _( "Cmp files:" ), - wxEmptyString, /* Chemin par defaut */ - FullFileNameCmp, /* nom fichier par defaut */ - NetCmpExtBuffer, /* extension par defaut */ - mask, /* Masque d'affichage */ - this, - wxFD_SAVE, - FALSE - ); - if( FullFileNameCmp.IsEmpty() ) + wxFileDialog dlg( this, _( "Save Component Files" ), wxEmptyString, + fn.GetFullName(), wildcard, + wxFD_SAVE | wxFD_OVERWRITE_PROMPT ); + + if( dlg.ShowModal() == wxID_CANCEL ) return; + fn = dlg.GetPath(); - FichCmp = wxFopen( FullFileNameCmp, wxT( "wt" ) ); + FichCmp = wxFopen( fn.GetFullPath(), wxT( "wt" ) ); if( FichCmp == NULL ) { - msg = _( "Unable to create file " ) + FullFileNameCmp; + msg = _( "Unable to create file " ) + fn.GetFullPath(); DisplayError( this, msg ); return; } fgets( Line, sizeof(Line), FichCmp ); - fprintf( FichCmp, "Cmp-Mod V01 Genere par PcbNew le %s\n", DateAndTime( Line ) ); + fprintf( FichCmp, "Cmp-Mod V01 Genere par PcbNew le %s\n", + DateAndTime( Line ) ); for( ; Module != NULL; Module = Module->Next() ) { @@ -662,7 +672,8 @@ void WinEDA_PcbFrame::RecreateCmpFileFromBoard(wxCommandEvent& aEvent) fprintf( FichCmp, "ValeurCmp = %s;\n", !Module->m_Value->m_Text.IsEmpty() ? CONV_TO_UTF8( Module->m_Value->m_Text ) : "[NoVal]" ); - fprintf( FichCmp, "IdModule = %s;\n", CONV_TO_UTF8( Module->m_LibRef ) ); + fprintf( FichCmp, "IdModule = %s;\n", + CONV_TO_UTF8( Module->m_LibRef ) ); fprintf( FichCmp, "EndCmp\n" ); } diff --git a/pcbnew/zones.h b/pcbnew/zones.h index ec8a48a1a6..0103bc2403 100644 --- a/pcbnew/zones.h +++ b/pcbnew/zones.h @@ -6,10 +6,6 @@ #define ZONES_H -#ifndef eda_global -#define eda_global extern -#endif - #include "class_zone_setting.h" @@ -38,17 +34,10 @@ enum { // How pads are covered by copper in zone /************************************************/ /* parametre grid size for automatic routing */ -#if defined MAIN -int g_GridRoutingSize = 250; -#else -extern int g_GridRoutingSize; -#endif +extern int g_GridRoutingSize; +extern bool g_Zone_45_Only; -eda_global bool g_Zone_45_Only -#ifdef MAIN -= FALSE -#endif -; +// Default setting used when creating a new zone +extern ZONE_SETTING g_Zone_Default_Setting; -eda_global ZONE_SETTING g_Zone_Default_Setting; // Default setting used when creating a new zone #endif // ifndef ZONES_H diff --git a/polygon/PolyLine.h b/polygon/PolyLine.h index 75e216cdb2..db0db68822 100644 --- a/polygon/PolyLine.h +++ b/polygon/PolyLine.h @@ -45,7 +45,7 @@ void ArmBoolEng( Bool_Engine* aBooleng, bool aConvertHoles = false ); #define PCBU_PER_MIL 10 #define NM_PER_MIL 10 // 25400 -#define to_int( x ) (int) round( (x) ) +#define to_int( x ) wxRound( (x) ) #ifndef MIN #define MIN( x1, x2 ) ( (x1) > (x2) ? (x2) : (x1) ) #endif