From 78bbe949235403b2207bf3c6500e4a1434fcfcc4 Mon Sep 17 00:00:00 2001 From: charras Date: Thu, 30 Oct 2008 10:55:46 +0000 Subject: [PATCH] Use double instead float when possible, ande code cleaning. change EXCHG macro to equivalent inline functions (better code compatibility with some compilers) --- 3d-viewer/3d_canvas.cpp | 4 +- 3d-viewer/3d_draw.cpp | 6 +-- 3d-viewer/3d_viewer.h | 14 +++--- 3d-viewer/trackball.cpp | 76 +++++++++++++++--------------- 3d-viewer/trackball.h | 12 ++--- change_log.txt | 9 ++++ eeschema/classes_body_items.cpp | 68 ++++++++++++++------------- eeschema/component_class.h | 2 +- eeschema/dialog_options.cpp | 17 +++++-- include/macros.h | 83 +++++++++++++++++++++++++++++++-- pcbnew/pcbplot.cpp | 26 +++++++---- pcbnew/plot_rtn.cpp | 2 +- 12 files changed, 209 insertions(+), 110 deletions(-) diff --git a/3d-viewer/3d_canvas.cpp b/3d-viewer/3d_canvas.cpp index d924ef9d74..9868355554 100644 --- a/3d-viewer/3d_canvas.cpp +++ b/3d-viewer/3d_canvas.cpp @@ -230,7 +230,7 @@ void Pcb3D_GLCanvas::OnMouseEvent( wxMouseEvent& event ) /********************************************************/ { wxSize size( GetClientSize() ); - float spin_quat[4]; + double spin_quat[4]; if( event.RightDown() ) @@ -298,7 +298,7 @@ void Pcb3D_GLCanvas::OnMouseEvent( wxMouseEvent& event ) { /* middle button drag -> pan */ /* Current zoom and an additional factor are taken into account for the amount of panning. */ - const float PAN_FACTOR = 8.0 * g_Parm_3D_Visu.m_Zoom; + const double PAN_FACTOR = 8.0 * g_Parm_3D_Visu.m_Zoom; g_Draw3d_dx -= PAN_FACTOR * ( g_Parm_3D_Visu.m_Beginx - event.GetX() ) / size.x; g_Draw3d_dy -= PAN_FACTOR * (event.GetY() - g_Parm_3D_Visu.m_Beginy) / size.y; } diff --git a/3d-viewer/3d_draw.cpp b/3d-viewer/3d_draw.cpp index bc8afe5cf6..2cc94de9b7 100644 --- a/3d-viewer/3d_draw.cpp +++ b/3d-viewer/3d_draw.cpp @@ -21,8 +21,6 @@ #include "pcbstruct.h" #include "macros.h" -// #include "pcbnew.h" - #include "3d_viewer.h" #include "trackball.h" @@ -111,7 +109,7 @@ GLuint Pcb3D_GLCanvas::CreateDrawGL_List() g_Parm_3D_Visu.m_Layers = pcb->m_BoardSettings->m_CopperLayerCount; g_Parm_3D_Visu.m_BoardScale = 2.0 / MAX( g_Parm_3D_Visu.m_BoardSize.x, g_Parm_3D_Visu.m_BoardSize.y ); - float epoxy_width = 1.6; // epoxy width in mm + double epoxy_width = 1.6; // epoxy width in mm g_Parm_3D_Visu.m_Epoxy_Width = epoxy_width / 2.54 * 1000 * g_Parm_3D_Visu.m_BoardScale; @@ -591,7 +589,7 @@ void D_PAD::Draw3D( Pcb3D_GLCanvas* glcanvas ) int angle, delta_angle; int coord[4][2]; double fcoord[8][2], f_hole_coord[8][2]; - float scale; + double scale; double zpos; wxPoint shape_pos; double x, y, r, w, hole, holeX, holeY; diff --git a/3d-viewer/3d_viewer.h b/3d-viewer/3d_viewer.h index 9912a90a3c..1b64fd4e30 100644 --- a/3d-viewer/3d_viewer.h +++ b/3d-viewer/3d_viewer.h @@ -49,10 +49,10 @@ class SEGVIA; class Info_3D_Visu { public: - float m_Beginx, m_Beginy; /* position of mouse */ - float m_Quat[4]; /* orientation of object */ - float m_Rot[4]; /* man rotation of object */ - float m_Zoom; /* field of view in degrees */ + 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; @@ -65,11 +65,11 @@ public: wxSize m_BoardSize; int m_Layers; EDA_BoardDesignSettings * m_BoardSettings; // Link to current board design settings - float m_Epoxy_Width; /* Epoxy tickness (normalized) */ + double m_Epoxy_Width; /* Epoxy tickness (normalized) */ - float m_BoardScale; /* Normalisation scale for coordinates: + double m_BoardScale; /* Normalisation scale for coordinates: when scaled tey are between -1.0 and +1.0 */ - float m_LayerZcoord[32]; + double m_LayerZcoord[32]; public: Info_3D_Visu(); ~Info_3D_Visu(); diff --git a/3d-viewer/trackball.cpp b/3d-viewer/trackball.cpp index c4b8501c21..39fd77dda5 100644 --- a/3d-viewer/trackball.cpp +++ b/3d-viewer/trackball.cpp @@ -50,6 +50,8 @@ * Gavin Bell */ #include +#include "fctsys.h" // used only to define GLfloat +#include "3d_viewer.h" // used only to define GLfloat #include "trackball.h" /* @@ -64,11 +66,11 @@ /* * Local function prototypes (not defined in trackball.h) */ -static float tb_project_to_sphere(float, float, float); -static void normalize_quat(float [4]); +static double tb_project_to_sphere(double, double, double); +static void normalize_quat(double [4]); void -vzero(float *v) +vzero(double *v) { v[0] = 0.0; v[1] = 0.0; @@ -76,7 +78,7 @@ vzero(float *v) } void -vset(float *v, float x, float y, float z) +vset(double *v, double x, double y, double z) { v[0] = x; v[1] = y; @@ -84,7 +86,7 @@ vset(float *v, float x, float y, float z) } void -vsub(const float *src1, const float *src2, float *dst) +vsub(const double *src1, const double *src2, double *dst) { dst[0] = src1[0] - src2[0]; dst[1] = src1[1] - src2[1]; @@ -92,7 +94,7 @@ vsub(const float *src1, const float *src2, float *dst) } void -vcopy(const float *v1, float *v2) +vcopy(const double *v1, double *v2) { register int i; for (i = 0 ; i < 3 ; i++) @@ -100,9 +102,9 @@ vcopy(const float *v1, float *v2) } void -vcross(const float *v1, const float *v2, float *cross) +vcross(const double *v1, const double *v2, double *cross) { - float temp[3]; + double temp[3]; temp[0] = (v1[1] * v2[2]) - (v1[2] * v2[1]); temp[1] = (v1[2] * v2[0]) - (v1[0] * v2[2]); @@ -110,14 +112,14 @@ vcross(const float *v1, const float *v2, float *cross) vcopy(temp, cross); } -float -vlength(const float *v) +double +vlength(const double *v) { - return (float) sqrt(v[0] * v[0] + v[1] * v[1] + v[2] * v[2]); + return (double) sqrt(v[0] * v[0] + v[1] * v[1] + v[2] * v[2]); } void -vscale(float *v, float div) +vscale(double *v, double div) { v[0] *= div; v[1] *= div; @@ -125,19 +127,19 @@ vscale(float *v, float div) } void -vnormal(float *v) +vnormal(double *v) { vscale(v, 1.0f/vlength(v)); } -float -vdot(const float *v1, const float *v2) +double +vdot(const double *v1, const double *v2) { return v1[0]*v2[0] + v1[1]*v2[1] + v1[2]*v2[2]; } void -vadd(const float *src1, const float *src2, float *dst) +vadd(const double *src1, const double *src2, double *dst) { dst[0] = src1[0] + src2[0]; dst[1] = src1[1] + src2[1]; @@ -157,12 +159,12 @@ vadd(const float *src1, const float *src2, float *dst) * (-1.0 ... 1.0) */ void -trackball(float q[4], float p1x, float p1y, float p2x, float p2y) +trackball(double q[4], double p1x, double p1y, double p2x, double p2y) { - float a[3]; /* Axis of rotation */ - float phi; /* how much to rotate about axis */ - float p1[3], p2[3], d[3]; - float t; + double a[3]; /* Axis of rotation */ + double phi; /* how much to rotate about axis */ + double p1[3], p2[3], d[3]; + double t; if (p1x == p2x && p1y == p2y) { /* Zero rotation */ @@ -194,7 +196,7 @@ trackball(float q[4], float p1x, float p1y, float p2x, float p2y) */ if (t > 1.0) t = 1.0; if (t < -1.0) t = -1.0; - phi = 2.0f * (float) asin(t); + phi = 2.0f * (double) asin(t); axis_to_quat(a,phi,q); } @@ -203,26 +205,26 @@ trackball(float q[4], float p1x, float p1y, float p2x, float p2y) * Given an axis and angle, compute quaternion. */ void -axis_to_quat(float a[3], float phi, float q[4]) +axis_to_quat(double a[3], double phi, double q[4]) { vnormal(a); vcopy(a, q); - vscale(q, (float) sin(phi/2.0)); - q[3] = (float) cos(phi/2.0); + vscale(q, (double) sin(phi/2.0)); + q[3] = (double) cos(phi/2.0); } /* * Project an x,y pair onto a sphere of radius r OR a hyperbolic sheet * if we are away from the center of the sphere. */ -static float -tb_project_to_sphere(float r, float x, float y) +static double +tb_project_to_sphere(double r, double x, double y) { - float d, t, z; + double d, t, z; - d = (float) sqrt(x*x + y*y); + d = (double) sqrt(x*x + y*y); if (d < r * 0.70710678118654752440) { /* Inside sphere */ - z = (float) sqrt(r*r - d*d); + z = (double) sqrt(r*r - d*d); } else { /* On hyperbola */ t = r / 1.41421356237309504880f; z = t*t / d; @@ -244,11 +246,11 @@ tb_project_to_sphere(float r, float x, float y) #define RENORMCOUNT 97 void -add_quats(float q1[4], float q2[4], float dest[4]) +add_quats(double q1[4], double q2[4], double dest[4]) { static int count=0; - float t1[4], t2[4], t3[4]; - float tf[4]; + double t1[4], t2[4], t3[4]; + double tf[4]; vcopy(q1,t1); vscale(t1,q2[3]); @@ -284,11 +286,10 @@ add_quats(float q1[4], float q2[4], float dest[4]) * - Pletinckx, D., Quaternion calculus as a basic tool in computer * graphics, The Visual Computer 5, 2-13, 1989. */ -static void -normalize_quat(float q[4]) +static void normalize_quat(double q[4]) { int i; - float mag; + double mag; mag = (q[0]*q[0] + q[1]*q[1] + q[2]*q[2] + q[3]*q[3]); for (i = 0; i < 4; i++) q[i] /= mag; @@ -298,8 +299,7 @@ normalize_quat(float q[4]) * Build a rotation matrix, given a quaternion rotation. * */ -void -build_rotmatrix(float m[4][4], float q[4]) +void build_rotmatrix(GLfloat m[4][4], double q[4]) { m[0][0] = 1.0f - 2.0f * (q[1] * q[1] + q[2] * q[2]); m[0][1] = 2.0f * (q[0] * q[1] - q[2] * q[3]); diff --git a/3d-viewer/trackball.h b/3d-viewer/trackball.h index ed0c267e80..04e819a565 100644 --- a/3d-viewer/trackball.h +++ b/3d-viewer/trackball.h @@ -47,8 +47,7 @@ * The resulting rotation is returned as a quaternion rotation in the * first paramater. */ -void -trackball(float q[4], float p1x, float p1y, float p2x, float p2y); +void trackball(double q[4], double p1x, double p1y, double p2x, double p2y); /* * Given two quaternions, add them together to get a third quaternion. @@ -58,21 +57,18 @@ trackball(float q[4], float p1x, float p1y, float p2x, float p2y); * rotation, the second and third the total rotation (which will be * over-written with the resulting new total rotation). */ -void -add_quats(float *q1, float *q2, float *dest); +void add_quats(double *q1, double *q2, double *dest); /* * A useful function, builds a rotation matrix in Matrix based on * given quaternion. */ -void -build_rotmatrix(float m[4][4], float q[4]); +void build_rotmatrix(GLfloat m[4][4], double q[4]); /* * This function computes a quaternion based on an axis (defined by * the given vector) and an angle about which to rotate. The angle is * expressed in radians. The result is put into the third argument. */ -void -axis_to_quat(float a[3], float phi, float q[4]); +void axis_to_quat(double a[3], double phi, double q[4]); diff --git a/change_log.txt b/change_log.txt index fdae4cac41..cfb08f8013 100644 --- a/change_log.txt +++ b/change_log.txt @@ -5,6 +5,15 @@ Started 2007-June-11 Please add newer entries at the top, list the date and your name with email address. + +2008-oct-30 UPDATE Jean-Pierre Charras +================================================================================ +++All + Use double instead float when possible, ande code cleaning. + change EXCHG macro to equivalent inline functions + (better code compatibility with some compilers) + + 2008-Oct-19 UPDATE Dick Hollenbeck ================================================================================ +eeschema diff --git a/eeschema/classes_body_items.cpp b/eeschema/classes_body_items.cpp index d8eefd5956..0c84680cff 100644 --- a/eeschema/classes_body_items.cpp +++ b/eeschema/classes_body_items.cpp @@ -65,7 +65,8 @@ void LibDrawArc::Draw( WinEDA_DrawPanel* aPanel, wxDC* aDC, const wxPoint& aOffs bool swap = MapAngles( &pt1, &pt2, aTransformMatrix ); if( swap ) { - EXCHG( pos1.x, pos2.x ); EXCHG( pos1.y, pos2.y ) + EXCHG( pos1.x, pos2.x ); + EXCHG( pos1.y, pos2.y ); } GRSetDrawMode( aDC, aDrawMode ); @@ -76,24 +77,24 @@ void LibDrawArc::Draw( WinEDA_DrawPanel* aPanel, wxDC* aDC, const wxPoint& aOffs if( fill == FILLED_WITH_BG_BODYCOLOR ) GRFilledArc( &aPanel->m_ClipBox, aDC, posc.x, posc.y, pt1, pt2, - m_Rayon, linewidth, color, - ReturnLayerColor( LAYER_DEVICE_BACKGROUND ) ); + m_Rayon, linewidth, color, + ReturnLayerColor( LAYER_DEVICE_BACKGROUND ) ); else if( fill == FILLED_SHAPE && !aData ) GRFilledArc( &aPanel->m_ClipBox, aDC, posc.x, posc.y, pt1, pt2, - m_Rayon, color, color ); + m_Rayon, color, color ); else #ifdef DRAW_ARC_WITH_ANGLE GRArc( &aPanel->m_ClipBox, aDC, posc.x, posc.y, pt1, pt2, - m_Rayon, linewidth, color ); + m_Rayon, linewidth, color ); #else GRArc1( &aPanel->m_ClipBox, aDC, pos1.x, pos1.y, pos2.x, pos2.y, - posc.x, posc.y, linewidth, color ); + posc.x, posc.y, linewidth, color ); #endif } @@ -125,14 +126,14 @@ void LibDrawCircle::Draw( WinEDA_DrawPanel* aPanel, wxDC* aDC, const wxPoint& aO if( fill == FILLED_WITH_BG_BODYCOLOR ) GRFilledCircle( &aPanel->m_ClipBox, aDC, pos1.x, pos1.y, - m_Rayon, linewidth, color, - ReturnLayerColor( LAYER_DEVICE_BACKGROUND ) ); + m_Rayon, linewidth, color, + ReturnLayerColor( LAYER_DEVICE_BACKGROUND ) ); else if( fill == FILLED_SHAPE ) GRFilledCircle( &aPanel->m_ClipBox, aDC, pos1.x, pos1.y, - m_Rayon, 0, color, color ); + m_Rayon, 0, color, color ); else GRCircle( &aPanel->m_ClipBox, aDC, pos1.x, pos1.y, - m_Rayon, linewidth, color ); + m_Rayon, linewidth, color ); } @@ -161,9 +162,9 @@ void LibDrawText::Draw( WinEDA_DrawPanel* aPanel, wxDC* aDC, const wxPoint& aOff int t1 = (aTransformMatrix[0][0] != 0) ^ (m_Horiz != 0); DrawGraphicText( aPanel, aDC, pos1, color, m_Text, - t1 ? TEXT_ORIENT_HORIZ : TEXT_ORIENT_VERT, - m_Size, - GR_TEXT_HJUSTIFY_CENTER, GR_TEXT_VJUSTIFY_CENTER, linewidth ); + t1 ? TEXT_ORIENT_HORIZ : TEXT_ORIENT_VERT, + m_Size, + GR_TEXT_HJUSTIFY_CENTER, GR_TEXT_VJUSTIFY_CENTER, linewidth ); } @@ -194,14 +195,14 @@ void LibDrawSquare::Draw( WinEDA_DrawPanel* aPanel, wxDC* aDC, const wxPoint& aO if( fill == FILLED_WITH_BG_BODYCOLOR && !aData ) GRFilledRect( &aPanel->m_ClipBox, aDC, pos1.x, pos1.y, pos2.x, pos2.y, - color, linewidth, - ReturnLayerColor( LAYER_DEVICE_BACKGROUND ) ); + color, linewidth, + ReturnLayerColor( LAYER_DEVICE_BACKGROUND ) ); else if( m_Fill == FILLED_SHAPE && !aData ) GRFilledRect( &aPanel->m_ClipBox, aDC, pos1.x, pos1.y, pos2.x, pos2.y, - color, color ); + color, color ); else GRRect( &aPanel->m_ClipBox, aDC, pos1.x, pos1.y, pos2.x, pos2.y, - linewidth, color ); + linewidth, color ); } @@ -262,7 +263,7 @@ void LibDrawPolyline::Draw( WinEDA_DrawPanel* aPanel, wxDC* aDC, { Buf_Poly_Size = m_CornersCount; Buf_Poly_Drawings = (int*) realloc( Buf_Poly_Drawings, - sizeof(int) * 2 * Buf_Poly_Size ); + sizeof(int) * 2 * Buf_Poly_Size ); } for( int ii = 0, jj = 0; ii < m_CornersCount; ii++, jj += 2 ) @@ -282,14 +283,14 @@ void LibDrawPolyline::Draw( WinEDA_DrawPanel* aPanel, wxDC* aDC, if( fill == FILLED_WITH_BG_BODYCOLOR ) GRPoly( &aPanel->m_ClipBox, aDC, m_CornersCount, - Buf_Poly_Drawings, 1, linewidth, color, - ReturnLayerColor( LAYER_DEVICE_BACKGROUND ) ); + Buf_Poly_Drawings, 1, linewidth, color, + ReturnLayerColor( LAYER_DEVICE_BACKGROUND ) ); else if( fill == FILLED_SHAPE ) GRPoly( &aPanel->m_ClipBox, aDC, m_CornersCount, - Buf_Poly_Drawings, 1, linewidth, color, color ); + Buf_Poly_Drawings, 1, linewidth, color, color ); else GRPoly( &aPanel->m_ClipBox, aDC, m_CornersCount, - Buf_Poly_Drawings, 0, linewidth, color, color ); + Buf_Poly_Drawings, 0, linewidth, color, color ); } @@ -297,13 +298,14 @@ void LibDrawPolyline::Draw( WinEDA_DrawPanel* aPanel, wxDC* aDC, void LibDrawField::Draw( WinEDA_DrawPanel* aPanel, wxDC* aDC, const wxPoint& aOffset, int aColor, int aDrawMode, void* aData, int aTransformMatrix[2][2] ) /*************************************************************************************************/ -/* if aData not NULL, adat must point a wxString which is used instead of the m_Text -*/ -{ - wxPoint text_pos; - int color = aColor; - int linewidth = MAX( m_Width, g_DrawMinimunLineWidth ); +/* if aData not NULL, adat must point a wxString which is used instead of the m_Text + */ +{ + wxPoint text_pos; + + int color = aColor; + int linewidth = MAX( m_Width, g_DrawMinimunLineWidth ); if( aColor < 0 ) // Used normal color or selected color { @@ -332,11 +334,11 @@ void LibDrawField::Draw( WinEDA_DrawPanel* aPanel, wxDC* aDC, const wxPoint& aOf } text_pos = TransformCoordinate( aTransformMatrix, m_Pos ) + aOffset; - wxString * text = aData ? (wxString *) aData : &m_Text; + wxString* text = aData ? (wxString*) aData : &m_Text; GRSetDrawMode( aDC, aDrawMode ); DrawGraphicText( aPanel, aDC, text_pos, - color, text->GetData(), - m_Orient ? TEXT_ORIENT_VERT : TEXT_ORIENT_HORIZ, - m_Size, - m_HJustify, m_VJustify, linewidth ); + color, text->GetData(), + m_Orient ? TEXT_ORIENT_VERT : TEXT_ORIENT_HORIZ, + m_Size, + m_HJustify, m_VJustify, linewidth ); } diff --git a/eeschema/component_class.h b/eeschema/component_class.h index 7911a31382..bbe274dddd 100644 --- a/eeschema/component_class.h +++ b/eeschema/component_class.h @@ -75,7 +75,7 @@ public: * determined, upon placement, from the library component. * determined, upon file load, by the first non-digits in the reference fields. */ - int m_Convert; /* Gestion (management) des mutiples representations (ex: conversion De Morgan) */ + int m_Convert; /* Handle mutiple shape (for instance De Morgan conversion) */ int m_Transform[2][2]; /* The rotation/mirror transformation matrix. */ private: diff --git a/eeschema/dialog_options.cpp b/eeschema/dialog_options.cpp index b50405220b..54609447a4 100644 --- a/eeschema/dialog_options.cpp +++ b/eeschema/dialog_options.cpp @@ -407,7 +407,6 @@ void WinEDA_SetOptionsFrame::Accept( wxCommandEvent& event ) /**************************************************************************/ { wxSize grid; - bool setgrid = TRUE; wxString msg; g_DrawMinimunLineWidth = m_DefaultDrawLineWidthCtrl->GetValue(); @@ -459,7 +458,6 @@ void WinEDA_SetOptionsFrame::Accept( wxCommandEvent& event ) switch( m_SelGridSize->GetSelection() ) { default: - setgrid = FALSE; break; case 0: @@ -473,12 +471,23 @@ void WinEDA_SetOptionsFrame::Accept( wxCommandEvent& event ) case 2: grid = wxSize( 10, 10 ); break; + + case 3: + grid = wxSize( 5, 5 ); + break; + + case 4: + grid = wxSize( 2, 2 ); + break; + + case 5: + grid = wxSize( 1, 1 ); + break; } if( m_Parent->GetBaseScreen() ) { - if( setgrid ) - m_Parent->GetBaseScreen()->SetGrid( grid ); + m_Parent->GetBaseScreen()->SetGrid( grid ); m_Parent->GetBaseScreen()->SetRefreshReq(); } } diff --git a/include/macros.h b/include/macros.h index 06888ae796..c7fd25029e 100644 --- a/include/macros.h +++ b/include/macros.h @@ -1,4 +1,6 @@ -/* Macros utiles */ +/**************************************/ +/* Useful macros and inline functions */ +/**************************************/ #ifndef MACROS_H #define MACROS_H @@ -48,10 +50,85 @@ Angle -= 1800; } -/* exchange 2 items */ -#define EXCHG( a, b ) { typeof(a) __temp__ = (a); (a) = (b); (b) = __temp__; } +/****************************************/ +/* inline functions to exchange 2 items */ +/****************************************/ +static inline void EXCHG( int a, int b ) +{ + int temp = a; + a = b; + b = temp; +}; +static inline void EXCHG( int* a, int* b ) +{ + int* temp = a; + a = b; + b = temp; +}; + +static inline void EXCHG( double a, double b ) +{ + double temp = a; + a = b; + b = temp; +}; + +static inline void EXCHG( wxPoint a, wxPoint b ) +{ + wxPoint temp = a; + a = b; + b = temp; +}; + +static inline void EXCHG( wxSize a, wxSize b ) +{ + wxSize temp = a; + a = b; + b = temp; +}; + +static inline void EXCHG( const wxChar* a, const wxChar* b ) +{ + const wxChar* temp = a; + a = b; + b = temp; +}; + +class Hierarchical_PIN_Sheet_Struct; +static inline void EXCHG( const Hierarchical_PIN_Sheet_Struct* a, const Hierarchical_PIN_Sheet_Struct* b ) +{ + const Hierarchical_PIN_Sheet_Struct* temp = a; + a = b; + b = temp; +}; + +class SCH_CMP_FIELD; +static inline void EXCHG( const SCH_CMP_FIELD* a, const SCH_CMP_FIELD* b ) +{ + const SCH_CMP_FIELD* temp = a; + a = b; + b = temp; +}; + +class BOARD_ITEM; +static inline void EXCHG( const BOARD_ITEM* a, const BOARD_ITEM* b ) +{ + const BOARD_ITEM* temp = a; + a = b; + b = temp; +}; + +class D_PAD; +static inline void EXCHG( const D_PAD* a, const D_PAD* b ) +{ + const D_PAD* temp = a; + a = b; + b = temp; +}; +/*****************************************************/ /* inline functions to insert menuitems with a icon: */ +/*****************************************************/ static inline void ADD_MENUITEM( wxMenu* menu, int id, const wxString& text, const wxBitmap& icon ) diff --git a/pcbnew/pcbplot.cpp b/pcbnew/pcbplot.cpp index d0b5cde12e..fa87e292c7 100644 --- a/pcbnew/pcbplot.cpp +++ b/pcbnew/pcbplot.cpp @@ -119,6 +119,7 @@ public: public: WinEDA_PlotFrame( WinEDA_BasePcbFrame* parent ); private: + void OnInitDialog( wxInitDialogEvent& event ); void Plot( wxCommandEvent& event ); void OnQuit( wxCommandEvent& event ); void OnClose( wxCloseEvent& event ); @@ -130,6 +131,7 @@ private: }; BEGIN_EVENT_TABLE( WinEDA_PlotFrame, wxDialog ) +EVT_INIT_DIALOG( WinEDA_PlotFrame::OnInitDialog ) EVT_CLOSE( WinEDA_PlotFrame::OnClose ) EVT_BUTTON( wxID_CANCEL, WinEDA_PlotFrame::OnQuit ) EVT_BUTTON( ID_EXEC_PLOT, WinEDA_PlotFrame::Plot ) @@ -149,18 +151,25 @@ WinEDA_PlotFrame::WinEDA_PlotFrame( WinEDA_BasePcbFrame* parent ) : wxDEFAULT_DIALOG_STYLE ) /********************************************************************/ { + m_Parent = parent; + Centre(); + +} + + +/**************************************************************/ +void WinEDA_PlotFrame::OnInitDialog( wxInitDialogEvent& event ) +/**************************************************************/ +{ + wxButton* button; - m_Parent = parent; - - BOARD* board = parent->m_Pcb; + BOARD* board = m_Parent->m_Pcb; wxConfig* config = m_Parent->m_Parent->m_EDA_Config; // Current config used by application SetFont( *g_DialogFont ); - Centre(); - m_Plot_Sheet_Ref = NULL; wxBoxSizer* MainBoxSizer = new wxBoxSizer( wxHORIZONTAL ); @@ -443,17 +452,16 @@ WinEDA_PlotFrame::WinEDA_PlotFrame( WinEDA_BasePcbFrame* parent ) : MidLeftBoxSizer->Add( m_HPGL_PlotCenter_Opt, 0, wxGROW | wxALL, 5 ); // Mise a jour des activations des menus: - wxCommandEvent event; - SetCommands( event ); + wxCommandEvent cmd_event; + SetCommands( cmd_event ); GetSizer()->Fit( this ); GetSizer()->SetSizeHints( this ); // without this line, the ESC key does not work - m_PlotButton->SetFocus(); + SetFocus(); } - /***************************************************************/ void WinEDA_PlotFrame::OnQuit( wxCommandEvent& WXUNUSED (event) ) /***************************************************************/ diff --git a/pcbnew/plot_rtn.cpp b/pcbnew/plot_rtn.cpp index 0a68c11754..57e1051055 100644 --- a/pcbnew/plot_rtn.cpp +++ b/pcbnew/plot_rtn.cpp @@ -613,7 +613,7 @@ void Plot_1_texte( int format_plot, const wxString& Text, int angle, /* calcul de la position du debut du texte */ if( centreX ) - sx = cX - ( (espacement * nbcodes) / 2 ) + (espacement / 9); + sx = cX - ( (espacement * nbcodes) / 2 ); else sx = cX; if( centreY )