Global variable unobfuscation, new library path search, and lots of other changes. See CHANGELOG.txt.
This commit is contained in:
parent
7a351249ec
commit
689579bde1
|
@ -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,
|
||||
|
|
|
@ -20,12 +20,24 @@
|
|||
#include "bitmaps.h"
|
||||
#include "id.h"
|
||||
|
||||
#define VIEWER_MAIN
|
||||
#include "3d_viewer.h"
|
||||
#include "trackball.h"
|
||||
|
||||
#include <wx/colordlg.h>
|
||||
|
||||
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 )
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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();
|
||||
|
||||
|
|
|
@ -20,12 +20,6 @@
|
|||
# include <GL/glu.h>
|
||||
#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[];
|
||||
|
|
|
@ -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 <stambaughw@verizon.net>
|
||||
================================================================================
|
||||
++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 <jean-pierre.charras@gipsa-lab.inpg.fr>
|
||||
================================================================================
|
||||
++pcbnew:
|
||||
added BOM generator (in postprocess menu)
|
||||
|
||||
|
||||
2009-mar-28 UPDATE Jean-Pierre Charras <jean-pierre.charras@gipsa-lab.inpg.fr>
|
||||
================================================================================
|
||||
++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 <vesa.solonen@hut.fi>
|
||||
================================================================================
|
||||
++pcbnew:
|
||||
|
|
|
@ -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})
|
||||
|
|
|
@ -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__
|
||||
|
|
|
@ -17,6 +17,7 @@
|
|||
#include <wx/arrimpl.cpp>
|
||||
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 )
|
||||
{
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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"
|
||||
|
|
|
@ -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() );
|
||||
|
|
|
@ -12,13 +12,124 @@
|
|||
#include "confirm.h"
|
||||
#include <wx/process.h>
|
||||
|
||||
/**
|
||||
* 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 (<curr projet>.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;
|
||||
|
@ -163,9 +268,7 @@ ReturnUnitSymbol( int Units )
|
|||
* 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 );
|
||||
|
@ -179,10 +282,7 @@ AddUnitSymbol(wxStaticText& Stext,
|
|||
* 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;
|
||||
|
@ -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
|
||||
|
||||
|
|
|
@ -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 )
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -21,6 +21,11 @@
|
|||
#include <wx/fontdlg.h>
|
||||
|
||||
|
||||
/* 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<69>
|
||||
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 );
|
||||
}
|
||||
|
|
|
@ -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: */
|
||||
|
|
|
@ -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 );
|
||||
}
|
||||
|
||||
|
|
|
@ -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 <pyhandler.h>
|
||||
#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 <install dir>/kicad/doc/help
|
||||
// (often /usr/local/kicad/kicad/doc/help)
|
||||
// <install dir>/kicad/ is retrievered from m_BinDir
|
||||
// <install dir>/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();
|
||||
|
|
|
@ -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( "\"" );
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
wxButton* Button;
|
||||
wxStaticText* Text;
|
||||
|
||||
m_Parent = parent;
|
||||
m_AuxTool = show_extra_tool;
|
||||
m_GetExtraFunction = FALSE;
|
||||
m_Parent = parent;
|
||||
m_AuxTool = show_extra_tool;
|
||||
m_GetExtraFunction = FALSE;
|
||||
|
||||
SetFont(*g_DialogFont);
|
||||
s_ItemName.Empty();
|
||||
m_Text = & s_ItemName;
|
||||
SetFont( *g_DialogFont );
|
||||
s_ItemName.Empty();
|
||||
m_Text = &s_ItemName;
|
||||
|
||||
wxBoxSizer* MainBoxSizer = new wxBoxSizer(wxHORIZONTAL);
|
||||
SetSizer(MainBoxSizer);
|
||||
wxBoxSizer* MainBoxSizer = new wxBoxSizer( wxHORIZONTAL );
|
||||
SetSizer( MainBoxSizer );
|
||||
|
||||
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);
|
||||
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);
|
||||
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);
|
||||
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);
|
||||
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);
|
||||
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_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_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_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);
|
||||
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);
|
||||
}
|
||||
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_CANCEL:
|
||||
*m_Text = wxEmptyString;
|
||||
break;
|
||||
|
||||
case ID_LIST_ALL:
|
||||
*m_Text = wxT("*");
|
||||
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);
|
||||
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;
|
||||
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();
|
||||
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;
|
||||
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;
|
||||
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--;
|
||||
}
|
||||
}
|
||||
/* 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(""));
|
||||
/* 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];
|
||||
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);
|
||||
/* Add the new name at the beginning of the history list */
|
||||
HistoryList[0] = Name;
|
||||
}
|
||||
else
|
||||
HistoryList.Add( Name );
|
||||
}
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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 )
|
||||
{
|
||||
|
|
|
@ -0,0 +1,144 @@
|
|||
/*
|
||||
* This program source code file is part of KICAD, a free EDA CAD application.
|
||||
*
|
||||
* Copyright (C) 2008 Wayne Stambaugh <stambaughw@verizon.net>
|
||||
* 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<TRACK> 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 );
|
|
@ -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;
|
||||
|
|
|
@ -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
|
||||
}
|
||||
}
|
|
@ -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 );
|
||||
}
|
||||
}
|
||||
|
||||
|
|
1278
common/worksheet.cpp
1278
common/worksheet.cpp
File diff suppressed because it is too large
Load Diff
|
@ -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 )
|
||||
|
|
|
@ -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}
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
|
@ -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 );
|
||||
}
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -1,8 +1,6 @@
|
|||
/*******************/
|
||||
/* File: cvpcb.cpp */
|
||||
/*******************/
|
||||
#define MAIN
|
||||
#define eda_global
|
||||
|
||||
#include "fctsys.h"
|
||||
#include "appl_wxstruct.h"
|
||||
|
@ -19,7 +17,36 @@
|
|||
|
||||
#include <wx/snglinst.h>
|
||||
|
||||
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;
|
||||
}
|
||||
|
|
100
cvpcb/cvpcb.h
100
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__ */
|
||||
|
|
|
@ -6,12 +6,8 @@
|
|||
#ifndef CVSTRUCT_H
|
||||
#define CVSTRUCT_H
|
||||
|
||||
#ifndef eda_global
|
||||
#define eda_global extern
|
||||
#endif
|
||||
|
||||
|
||||
#include "wx/listctrl.h"
|
||||
#include <wx/filename.h>
|
||||
|
||||
/* 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 );
|
||||
|
|
|
@ -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() );
|
||||
}
|
||||
|
||||
/*!
|
||||
|
|
|
@ -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 */
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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 */
|
||||
|
|
116
cvpcb/init.cpp
116
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;
|
||||
}
|
||||
|
|
|
@ -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 ) )
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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();
|
||||
|
|
|
@ -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 */
|
||||
|
||||
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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 );
|
||||
}
|
||||
|
||||
|
|
|
@ -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" );
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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 );
|
||||
}
|
|
@ -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 );
|
||||
|
||||
|
|
|
@ -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() )
|
||||
|
|
|
@ -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 */
|
||||
|
|
|
@ -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 )
|
||||
{
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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:
|
||||
|
|
|
@ -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 <wx/tokenzr.h>
|
||||
#include <wx/txtstrm.h>
|
||||
|
||||
|
||||
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 <EFBFBD>l<EFBFBD>ments graphiques d'un composant lib pour am<EFBFBD>liorer
|
||||
* le trac<EFBFBD>:
|
||||
* 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 <LibDrawField> 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 <LibDrawField> 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;
|
||||
}
|
||||
|
|
|
@ -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<LibDrawField> m_Fields; /* Auxiliairy Field list (id >= 2 ) */
|
||||
LibEDA_BaseStruct* m_Drawings; /* How to draw this part */
|
||||
long m_LastDate; // Last change Date
|
||||
DLIST<LibDrawField> m_Fields; /* Auxiliairy Field list (id >= 2 ) */
|
||||
LibEDA_BaseStruct* m_Drawings; /* How to draw this part */
|
||||
long m_LastDate; // Last change Date
|
||||
DLIST<LibEDA_BaseStruct> 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 <LibDrawField> to import.
|
||||
*/
|
||||
void SetFields( const std::vector <LibDrawField> aFields );
|
||||
void SetFields( const std::vector <LibDrawField> 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 */
|
||||
|
|
|
@ -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 <wx/tokenzr.h>
|
||||
#include <wx/stream.h>
|
||||
#include <wx/txtstrm.h>
|
||||
|
||||
|
||||
/***************************/
|
||||
/* 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;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -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 <LibDrawField> 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
|
||||
|
|
|
@ -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 <wx/tokenzr.h>
|
||||
#include <wx/wfstream.h>
|
||||
#include <wx/txtstrm.h>
|
||||
#include <wx/listimpl.cpp>
|
||||
|
||||
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();
|
||||
}
|
||||
|
|
|
@ -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
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -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 );
|
||||
}
|
||||
|
|
|
@ -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<70>cis<69>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<69> 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 )
|
|||
"</" << GetClass().Lower().mb_str() << ">\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 );
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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
|
||||
};
|
||||
|
||||
|
|
|
@ -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 */
|
||||
/***********************************************************************/
|
||||
|
|
|
@ -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 )
|
||||
|
|
|
@ -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
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -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<wxPoint> 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
|
||||
|
|
|
@ -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"
|
||||
|
|
|
@ -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 <wx/arrimpl.cpp>
|
||||
#include <wx/tokenzr.h>
|
||||
|
||||
#include "component_class.h"
|
||||
|
||||
|
||||
WX_DEFINE_OBJARRAY( ArrayOfSheetLists );
|
||||
|
||||
|
||||
/* Local variables */
|
||||
static EDA_LibComponentStruct* DummyCmp;
|
||||
|
||||
/* Descr component <DUMMY> 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; i<NUMBER_OF_FIELDS; ++i )
|
||||
for( int i = 0; i < NUMBER_OF_FIELDS; ++i )
|
||||
{
|
||||
SCH_CMP_FIELD field( aPos, i, this, ReturnDefaultFieldName( i ) );
|
||||
|
||||
|
@ -60,28 +189,89 @@ SCH_COMPONENT::SCH_COMPONENT( const wxPoint& aPos, SCH_ITEM* aParent ) :
|
|||
SCH_COMPONENT::SCH_COMPONENT( const SCH_COMPONENT& aTemplate ) :
|
||||
SCH_ITEM( NULL, TYPE_SCH_COMPONENT )
|
||||
{
|
||||
// assignment of all fields, including field vector elements, and linked list pointers
|
||||
/* assignment of all fields, including field vector elements, and linked
|
||||
* list pointers */
|
||||
*this = aTemplate;
|
||||
|
||||
// set linked list pointers to null, before this they were copies of aTemplate's
|
||||
/* set linked list pointers to null, before this they were copies of
|
||||
* aTemplate's */
|
||||
Pback = NULL;
|
||||
Pnext = NULL;
|
||||
m_Son = NULL;
|
||||
|
||||
// Re-parent the fields, which before this had aTemplate as parent
|
||||
for( int i=0; i<GetFieldCount(); ++i )
|
||||
for( int i=0; i<GetFieldCount(); ++i )
|
||||
{
|
||||
GetField( i )->SetParent( 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 (/<sheet timestamp>/component timestamp> like /05678E50/A23EF560)
|
||||
* @param aPath = hierarchical path (/<sheet timestamp>/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; ii<m_PathsAndReferences.GetCount(); ii++ )
|
||||
for( unsigned ii = 0; ii < m_PathsAndReferences.GetCount(); ii++ )
|
||||
{
|
||||
tokenizer.SetString( m_PathsAndReferences[ii], separators );
|
||||
h_path = tokenizer.GetNextToken();
|
||||
|
||||
if( h_path.Cmp( aPath ) == 0 )
|
||||
{
|
||||
m_PathsAndReferences.RemoveAt( ii );
|
||||
|
@ -104,7 +295,6 @@ void SCH_COMPONENT::AddHierarchicalReference( const wxString& aPath,
|
|||
}
|
||||
|
||||
h_ref = aPath + wxT( " " ) + aRef;
|
||||
|
||||
h_ref << wxT( " " ) << aMulti;
|
||||
m_PathsAndReferences.Add( h_ref );
|
||||
}
|
||||
|
@ -148,15 +338,17 @@ const wxString SCH_COMPONENT::GetRef( DrawSheetPath* sheet )
|
|||
wxStringTokenizer tokenizer;
|
||||
wxString separators( wxT( " " ) );
|
||||
|
||||
for( unsigned ii = 0; ii<m_PathsAndReferences.GetCount(); ii++ )
|
||||
for( unsigned ii = 0; ii < m_PathsAndReferences.GetCount(); ii++ )
|
||||
{
|
||||
tokenizer.SetString( m_PathsAndReferences[ii], separators );
|
||||
h_path = tokenizer.GetNextToken();
|
||||
|
||||
if( h_path.Cmp( path ) == 0 )
|
||||
{
|
||||
h_ref = tokenizer.GetNextToken();
|
||||
|
||||
//printf("GetRef hpath: %s\n",CONV_TO_UTF8(m_PathsAndReferences[ii]));
|
||||
/* printf( "GetRef hpath: %s\n",
|
||||
CONV_TO_UTF8( m_PathsAndReferences[ii] ) ); */
|
||||
return h_ref;
|
||||
}
|
||||
}
|
||||
|
@ -188,7 +380,7 @@ void SCH_COMPONENT::SetRef( DrawSheetPath* sheet, const wxString& ref )
|
|||
wxString separators( wxT( " " ) );
|
||||
|
||||
//check to see if it is already there before inserting it
|
||||
for( unsigned ii = 0; ii<m_PathsAndReferences.GetCount(); ii++ )
|
||||
for( unsigned ii = 0; ii < m_PathsAndReferences.GetCount(); ii++ )
|
||||
{
|
||||
tokenizer.SetString( m_PathsAndReferences[ii], separators );
|
||||
h_path = tokenizer.GetNextToken();
|
||||
|
@ -211,8 +403,8 @@ void SCH_COMPONENT::SetRef( DrawSheetPath* sheet, const wxString& ref )
|
|||
SCH_CMP_FIELD* rf = GetField( REFERENCE );
|
||||
|
||||
if( rf->m_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; ii<m_PathsAndReferences.GetCount(); ii++ )
|
||||
for( unsigned ii = 0; ii < m_PathsAndReferences.GetCount(); ii++ )
|
||||
{
|
||||
tokenizer.SetString( m_PathsAndReferences[ii], separators );
|
||||
h_path = tokenizer.GetNextToken();
|
||||
|
||||
if( h_path.Cmp( path ) == 0 )
|
||||
{
|
||||
tokenizer.GetNextToken(); // Skip reference
|
||||
|
@ -249,17 +441,16 @@ int SCH_COMPONENT::GetUnitSelection( DrawSheetPath* aSheet )
|
|||
}
|
||||
}
|
||||
|
||||
//if it was not found in m_Paths array, then use m_Multi.
|
||||
// if it was not found in m_Paths array, then use m_Multi.
|
||||
// this will happen if we load a version 1 schematic file.
|
||||
return m_Multi;
|
||||
}
|
||||
|
||||
|
||||
/********************************************************************************/
|
||||
void SCH_COMPONENT::SetUnitSelection( DrawSheetPath* aSheet, int aUnitSelection )
|
||||
/********************************************************************************/
|
||||
|
||||
/****************************************************************************/
|
||||
//Set the unit selection, for the given sheet path.
|
||||
/****************************************************************************/
|
||||
void SCH_COMPONENT::SetUnitSelection( DrawSheetPath* aSheet, int aUnitSelection )
|
||||
{
|
||||
wxString path = GetPath( aSheet );
|
||||
|
||||
|
@ -270,10 +461,11 @@ void SCH_COMPONENT::SetUnitSelection( DrawSheetPath* aSheet, int aUnitSelection
|
|||
wxString separators( wxT( " " ) );
|
||||
|
||||
//check to see if it is already there before inserting it
|
||||
for( unsigned ii = 0; ii<m_PathsAndReferences.GetCount(); ii++ )
|
||||
for( unsigned ii = 0; ii < m_PathsAndReferences.GetCount(); ii++ )
|
||||
{
|
||||
tokenizer.SetString( m_PathsAndReferences[ii], separators );
|
||||
h_path = tokenizer.GetNextToken();
|
||||
|
||||
if( h_path.Cmp( path ) == 0 )
|
||||
{
|
||||
//just update the unit selection.
|
||||
|
@ -292,9 +484,7 @@ void SCH_COMPONENT::SetUnitSelection( DrawSheetPath* aSheet, int aUnitSelection
|
|||
}
|
||||
|
||||
|
||||
/******************************************************************/
|
||||
SCH_CMP_FIELD* SCH_COMPONENT::GetField( int aFieldNdx ) const
|
||||
/******************************************************************/
|
||||
{
|
||||
const SCH_CMP_FIELD* field;
|
||||
|
||||
|
@ -310,19 +500,16 @@ SCH_CMP_FIELD* SCH_COMPONENT::GetField( int aFieldNdx ) const
|
|||
}
|
||||
|
||||
|
||||
/******************************************************************/
|
||||
void SCH_COMPONENT::AddField( const SCH_CMP_FIELD& aField )
|
||||
/******************************************************************/
|
||||
{
|
||||
m_Fields.push_back( aField );
|
||||
}
|
||||
|
||||
|
||||
/************************************************/
|
||||
EDA_Rect SCH_COMPONENT::GetBoundaryBox() const
|
||||
/************************************************/
|
||||
{
|
||||
EDA_LibComponentStruct* Entry = FindLibPart( m_ChipName.GetData(), wxEmptyString, FIND_ROOT );
|
||||
EDA_LibComponentStruct* Entry = FindLibPart( m_ChipName.GetData(),
|
||||
wxEmptyString, FIND_ROOT );
|
||||
EDA_Rect BoundaryBox;
|
||||
int x0, xm, y0, ym;
|
||||
|
||||
|
@ -330,7 +517,8 @@ EDA_Rect SCH_COMPONENT::GetBoundaryBox() const
|
|||
if( Entry )
|
||||
{
|
||||
BoundaryBox = Entry->GetBoundaryBox( 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<6E>e du point coord, en fonction de l'orientation
|
||||
/**
|
||||
* Renvoie la coordonn<EFBFBD>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; i<GetFieldCount(); ++i )
|
||||
for( int i = 1; i < GetFieldCount(); ++i )
|
||||
{
|
||||
wxString value = GetField( i )->m_Text;
|
||||
|
||||
if( !value.IsEmpty() )
|
||||
{
|
||||
NestedSpace( nestLevel + 1, os ) << "<field" <<
|
||||
" name=\"" << ReturnFieldName( i ).mb_str() << '"' <<
|
||||
" value=\"" << value.mb_str() << "\"/>\n";
|
||||
NestedSpace( nestLevel + 1, os ) << "<field" << " name=\"" <<
|
||||
ReturnFieldName( i ).mb_str() << '"' << " value=\"" <<
|
||||
value.mb_str() << "\"/>\n";
|
||||
}
|
||||
}
|
||||
|
||||
NestedSpace( nestLevel, os ) << "</" << GetClass().Lower().mb_str() << ">\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; fieldNdx<GetFieldCount(); ++fieldNdx )
|
||||
for( int fieldNdx = 0; fieldNdx < GetFieldCount(); ++fieldNdx )
|
||||
{
|
||||
SCH_CMP_FIELD* field = GetField( fieldNdx );
|
||||
|
||||
wxString defaultName = ReturnDefaultFieldName( fieldNdx );
|
||||
|
||||
// only save the field if there is a value in the field or if field name
|
||||
|
@ -862,34 +1030,22 @@ bool SCH_COMPONENT::Save( FILE* f ) const
|
|||
continue;
|
||||
|
||||
if( !field->Save( 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 );
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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 = /<timestamp1>/<timestamp2> (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 (/<sheet timestamp>/component timestamp> like /05678E50/A23EF560)
|
||||
* @param aPath = hierarchical path (/<sheet timestamp>/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)
|
||||
|
||||
|
|
|
@ -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();
|
||||
}
|
||||
|
|
|
@ -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();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
|
@ -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.)
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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();
|
||||
|
|
|
@ -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 );
|
||||
|
|
|
@ -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 )
|
||||
/**************************************************************************************************/
|
||||
|
|
|
@ -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 =
|
||||
|
|
|
@ -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();
|
||||
}
|
||||
|
|
|
@ -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,
|
||||
|
|
|
@ -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 )
|
||||
|
|
|
@ -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 <DUMMY> 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;
|
||||
}
|
||||
}
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -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<70>cis<69>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<69> 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) )
|
||||
|
|
|
@ -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 <wx/snglinst.h>
|
||||
|
||||
|
||||
// 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 );
|
||||
}
|
||||
|
|
|
@ -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 ) );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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() );
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -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" ) );
|
||||
|
|
|
@ -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" )
|
||||
|
|
|
@ -22,42 +22,44 @@
|
|||
|
||||
#include "id.h"
|
||||
|
||||
#include <wx/filename.h>
|
||||
|
||||
|
||||
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 );
|
||||
}
|
||||
|
|
|
@ -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 );
|
||||
}
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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 );
|
||||
}
|
||||
}
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue