diff --git a/eeschema/block_libedit.cpp b/eeschema/block_libedit.cpp index 0b8548adf3..59fd9193fb 100644 --- a/eeschema/block_libedit.cpp +++ b/eeschema/block_libedit.cpp @@ -462,8 +462,7 @@ static void DrawMovingBlockOutlines( WinEDA_DrawPanel* panel, wxDC* DC, if( CurrentConvert && item->m_Convert && (item->m_Convert != CurrentConvert) ) continue; DrawLibraryDrawStruct( panel, DC, CurrentLibEntry, - PtBlock->m_MoveVector.x, PtBlock->m_MoveVector.y, - item, CurrentUnit, g_XorMode ); + PtBlock->m_MoveVector, item, g_XorMode ); } } } @@ -491,8 +490,8 @@ static void DrawMovingBlockOutlines( WinEDA_DrawPanel* panel, wxDC* DC, if( CurrentConvert && item->m_Convert && (item->m_Convert != CurrentConvert) ) continue; DrawLibraryDrawStruct( panel, DC, CurrentLibEntry, - PtBlock->m_MoveVector.x, PtBlock->m_MoveVector.y, - item, CurrentUnit, g_XorMode ); + PtBlock->m_MoveVector, + item, g_XorMode ); } } } diff --git a/eeschema/class_pin.cpp b/eeschema/class_pin.cpp index 14f260e122..4e5cfef322 100644 --- a/eeschema/class_pin.cpp +++ b/eeschema/class_pin.cpp @@ -665,3 +665,166 @@ void LibDrawPin::PlotPinTexts( wxPoint& pin_pos, int orient, } } } + + + +/***************************************************************/ +LibDrawPin::LibDrawPin() : LibEDA_BaseStruct( COMPONENT_PIN_DRAW_TYPE ) +/***************************************************************/ +{ + m_PinLen = 300; /* default Pin len */ + m_Orient = PIN_RIGHT; /* Pin oprient: Up, Down, Left, Right */ + m_PinShape = NONE; /* Bit a bit: Pin shape (voir enum prec) */ + m_PinType = PIN_UNSPECIFIED; /* electrical type of pin */ + m_Attributs = 0; /* bit 0 != 0: pin invisible */ + m_PinNum = 0; /*pin number ( i.e. 4 codes Ascii ) */ + m_PinNumSize = 50; + m_PinNameSize = 50; /* Default size for pin name and num */ + m_Width = 0; + +// m_PinNumWidth = m_PinNameWidth = 0; // Unused +} + + +/******************************************/ +wxPoint LibDrawPin::ReturnPinEndPoint() +/******************************************/ + +/* return the pin end position, for a component in normal orient + */ +{ + wxPoint pos = m_Pos; + + switch( m_Orient ) + { + case PIN_UP: + pos.y += m_PinLen; break; + + case PIN_DOWN: + pos.y -= m_PinLen; break; + + case PIN_LEFT: + pos.x -= m_PinLen; break; + + case PIN_RIGHT: + pos.x += m_PinLen; break; + } + + return pos; +} + + +/********************************************************/ +int LibDrawPin::ReturnPinDrawOrient( int TransMat[2][2] ) +/********************************************************/ + +/* Return the pin real orientation (PIN_UP, PIN_DOWN, PIN_RIGHT, PIN_LEFT), + * according to its orientation, + * AND the matrix transform (rot, mirror) TransMat + */ +{ + int orient; + int x1 = 0, y1 = 0; + int t1, t2; + + switch( m_Orient ) + { + case PIN_UP: + y1 = 1; break; + + case PIN_DOWN: + y1 = -1; break; + + case PIN_LEFT: + x1 = -1; break; + + case PIN_RIGHT: + x1 = 1; break; + } + + t1 = TransMat[0][0] * x1 + TransMat[0][1] * y1; + t2 = TransMat[1][0] * x1 + TransMat[1][1] * y1; + orient = PIN_UP; + if( t1 == 0 ) + { + if( t2 > 0 ) + orient = PIN_DOWN; + } + else + { + orient = PIN_RIGHT; + if( t1 < 0 ) + orient = PIN_LEFT; + } + + return orient; +} + + +/****************************************************/ +void LibDrawPin::ReturnPinStringNum( wxString& buffer ) +/****************************************************/ + +/* fill the buffer with pin num as a wxString + * Pin num is coded as a long + * Used to print/draw the pin num + */ +{ + char ascii_buf[5]; + + strncpy( ascii_buf, (char*) &m_PinNum, 4 ); + ascii_buf[4] = 0; + + buffer = CONV_FROM_UTF8( ascii_buf ); +} + + +/****************************************************/ +void LibDrawPin::SetPinNumFromString( wxString& buffer ) +/****************************************************/ + +/* fill the buffer with pin num as a wxString + * Pin num is coded as a long + * Used to print/draw the pin num + */ +{ + char ascii_buf[4]; + unsigned ii, len = buffer.Len(); + + ascii_buf[0] = ascii_buf[1] = ascii_buf[2] = ascii_buf[3] = 0; + if( len > 4 ) + len = 4; + for( ii = 0; ii < len; ii++ ) + { + ascii_buf[ii] = buffer.GetChar( ii ) & 0xFF; + } + + strncpy( (char*) &m_PinNum, ascii_buf, 4 ); +} + + +/*************************************/ +LibDrawPin* LibDrawPin::GenCopy() +/*************************************/ +{ + LibDrawPin* newpin = new LibDrawPin(); + + newpin->m_Pos = m_Pos; + newpin->m_PinLen = m_PinLen; + newpin->m_Orient = m_Orient; + newpin->m_PinShape = m_PinShape; + newpin->m_PinType = m_PinType; + newpin->m_Attributs = m_Attributs; + newpin->m_PinNum = m_PinNum; + newpin->m_PinNumSize = m_PinNumSize; + newpin->m_PinNameSize = m_PinNameSize; + newpin->m_Unit = m_Unit; + newpin->m_Convert = m_Convert; + newpin->m_Flags = m_Flags; + newpin->m_Width = m_Width; + + newpin->m_PinName = m_PinName; + + return newpin; +} + diff --git a/eeschema/classes_body_items.cpp b/eeschema/classes_body_items.cpp index 0824a9cf8b..0d4fabaca7 100644 --- a/eeschema/classes_body_items.cpp +++ b/eeschema/classes_body_items.cpp @@ -15,6 +15,20 @@ //#define DRAW_ARC_WITH_ANGLE // Used to draw arcs +/* Basic class (abstract) for components bodies items */ +LibEDA_BaseStruct::LibEDA_BaseStruct( KICAD_T struct_type ) : + EDA_BaseStruct( struct_type ) +{ + m_Unit = 0; /* Unit identification (for multi part per package) + * 0 if the item is common to all units */ + m_Convert = 0; /* Shape identification (for parts which have a convert shape) + * 0 if the item is common to all shapes */ + m_Width = 0; /* Default value to draw lines or arc ... */ + m_Fill = NO_FILL; /* NO_FILL, FILLED_SHAPE or FILLED_WITH_BG_BODYCOLOR. + * has meaning only for some items */ +} + + /** Function Draw (virtual) * Draw A body item * @param aPanel = DrawPanel to use (can be null) mainly used for clipping purposes @@ -70,10 +84,14 @@ void LibDrawArc::Draw( WinEDA_DrawPanel* aPanel, wxDC* aDC, const wxPoint& aOffs else #ifdef DRAW_ARC_WITH_ANGLE + + GRArc( &aPanel->m_ClipBox, aDC, posc.x, posc.y, pt1, pt2, m_Rayon, LineWidth, color ); #else + + GRArc1( &aPanel->m_ClipBox, aDC, pos1.x, pos1.y, pos2.x, pos2.y, posc.x, posc.y, LineWidth, color ); #endif diff --git a/eeschema/classes_body_items.h b/eeschema/classes_body_items.h index 173520ef87..86d61aa127 100644 --- a/eeschema/classes_body_items.h +++ b/eeschema/classes_body_items.h @@ -132,6 +132,7 @@ public: * 0 if the item is common to all shapes */ wxPoint m_Pos; /* Position or centre (Arc and Circle) or start point (segments) */ int m_Width; /* Tickness */ + FILL_T m_Fill; /* NO_FILL, FILLED_SHAPE or FILLED_WITH_BG_BODYCOLOR. has meaning only for some items */ public: LibEDA_BaseStruct* Next() @@ -154,7 +155,7 @@ public: * 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 + * @param aTransformMatrix = Transform Matrix (rotaion, mirror ..) */ virtual void Draw( WinEDA_DrawPanel * aPanel, wxDC * aDC, const wxPoint &aOffset, int aColor, int aDrawMode, void * aData, int aTransformMatrix[2][2] ) = 0; @@ -223,7 +224,6 @@ class LibDrawArc : public LibEDA_BaseStruct { public: int m_Rayon; - FILL_T m_Fill; // NO_FILL, FILLED_SHAPE or FILLED_WITH_BG_BODYCOLOR 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*/ @@ -249,7 +249,6 @@ class LibDrawCircle : public LibEDA_BaseStruct { public: int m_Rayon; - FILL_T m_Fill; public: LibDrawCircle(); @@ -304,7 +303,6 @@ class LibDrawSquare : public LibEDA_BaseStruct { public: wxPoint m_End; - FILL_T m_Fill; public: LibDrawSquare(); @@ -352,7 +350,6 @@ class LibDrawPolyline : public LibEDA_BaseStruct public: int m_CornersCount; int* m_PolyList; - FILL_T m_Fill; public: LibDrawPolyline(); @@ -392,7 +389,6 @@ class LibDrawField : public LibEDA_BaseStruct public: int m_FieldId; // 0 a 11 // 0 = Name; 1 = Valeur; 2 .. 11 other fields - wxPoint m_Pos; wxSize m_Size; int m_Orient; /* Orientation */ int m_Attributs; /* Attributes (Non visible ...) */ diff --git a/eeschema/delete.cpp b/eeschema/delete.cpp index 70b395023a..16c1a7033f 100644 --- a/eeschema/delete.cpp +++ b/eeschema/delete.cpp @@ -540,7 +540,7 @@ void DeleteOneLibraryDrawStruct( WinEDA_DrawPanel* panel, wxDC* DC, /* Effacement du graphique */ if( Affiche && DC ) - DrawLibraryDrawStruct( panel, DC, LibEntry, 0, 0, DrawItem, CurrentUnit, g_XorMode ); + DrawLibraryDrawStruct( panel, DC, LibEntry, wxPoint(0, 0), DrawItem, g_XorMode ); /* Effacement de la structure en memoire */ if( LibEntry ) /* Recherche du predecesseur */ diff --git a/eeschema/eelibs_draw_components.cpp b/eeschema/eelibs_draw_components.cpp index 50725ccc52..ea5839b944 100644 --- a/eeschema/eelibs_draw_components.cpp +++ b/eeschema/eelibs_draw_components.cpp @@ -211,7 +211,7 @@ void DrawLibEntry( WinEDA_DrawPanel* panel, wxDC* DC, Field->m_HJustify, Field->m_VJustify, LineWidth ); } - // Trac� de l'ancre + // Trace de l'ancre int len = 3 * panel->GetZoom(); GRLine( &panel->m_ClipBox, DC, posX, posY - len, posX, posY + len, 0, color ); GRLine( &panel->m_ClipBox, DC, posX - len, posY, posX + len, posY, 0, color ); @@ -435,10 +435,8 @@ void DrawLibPartAux( WinEDA_DrawPanel* panel, wxDC* DC, int Color, bool DrawPinText ) { wxPoint pos1, pos2; - LibEDA_BaseStruct* DEntry = NULL; - bool force_nofill; - int SetHightColor; - int LineWidth; + LibEDA_BaseStruct* DEntry; + bool force_nofill; if( Entry->m_Drawings == NULL ) return; @@ -446,7 +444,7 @@ void DrawLibPartAux( WinEDA_DrawPanel* panel, wxDC* DC, for( DEntry = Entry->m_Drawings; DEntry != NULL; DEntry = DEntry->Next() ) { - /* Elimination des elements non relatifs a l'unite */ + /* Do not draw items not attached to the current part */ if( Multi && DEntry->m_Unit && (DEntry->m_Unit != Multi) ) continue; @@ -454,72 +452,33 @@ void DrawLibPartAux( WinEDA_DrawPanel* panel, wxDC* DC, continue; if( DEntry->m_Flags & IS_MOVED ) - continue; // Element en deplacement non trace + continue; // Do do draw here an item while moving (the cursor handler does that) - SetHightColor = (DEntry->m_Selected & IS_SELECTED) ? HIGHT_LIGHT_FLAG : 0; - LineWidth = MAX( DEntry->m_Width, g_DrawMinimunLineWidth ); + force_nofill = false; switch( DEntry->Type() ) { - case COMPONENT_ARC_DRAW_TYPE: + case COMPONENT_PIN_DRAW_TYPE: { - LibDrawArc* Arc = (LibDrawArc*) DEntry; - force_nofill = false; - if( g_IsPrinting && Arc->m_Fill == FILLED_WITH_BG_BODYCOLOR && GetGRForceBlackPenState() ) - force_nofill = true; - DEntry->Draw( panel, DC, Pos, Color, DrawMode, (void*)force_nofill, TransMat ); - break; - } - case COMPONENT_CIRCLE_DRAW_TYPE: - { - LibDrawCircle* Circle = (LibDrawCircle*) DEntry; - force_nofill = false; - if( g_IsPrinting && Circle->m_Fill == FILLED_WITH_BG_BODYCOLOR && GetGRForceBlackPenState() ) - force_nofill = true; - DEntry->Draw( panel, DC, Pos, Color, DrawMode, (void*)force_nofill, TransMat ); - } - break; - - case COMPONENT_GRAPHIC_TEXT_DRAW_TYPE: - DEntry->Draw( panel, DC, Pos, Color, DrawMode, NULL, TransMat ); - break; - - case COMPONENT_RECT_DRAW_TYPE: - { - LibDrawSquare* Square = (LibDrawSquare*) DEntry; - force_nofill = false; - if( g_IsPrinting && Square->m_Fill == FILLED_WITH_BG_BODYCOLOR && GetGRForceBlackPenState() ) - force_nofill = true; - DEntry->Draw( panel, DC, Pos, Color, DrawMode, (void*)force_nofill, TransMat ); - } - break; - - case COMPONENT_PIN_DRAW_TYPE: /* Trace des Pins */ - { - DrawPinPrms prms(Entry, DrawPinText); + 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: - { - LibDrawPolyline* polyline = (LibDrawPolyline*) DEntry; - force_nofill = false; - if( g_IsPrinting && polyline->m_Fill == FILLED_WITH_BG_BODYCOLOR && GetGRForceBlackPenState() ) - force_nofill = true; - DEntry->Draw( panel, DC, Pos, Color, DrawMode, (void*)force_nofill, TransMat ); - } - break; - default: - wxBell(); + 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; } - - /* Fin Switch */ } - /* Fin Boucle de dessin */ if( g_DebugLevel > 4 ) /* Draw the component boundary box */ { EDA_Rect BoundaryBox; @@ -548,7 +507,6 @@ void DrawLibPartAux( WinEDA_DrawPanel* panel, wxDC* DC, } - /***************************************************************************** * Routine to rotate the given angular direction by the given Transformation. * * Input (and output) angles must be as follows: * @@ -638,164 +596,42 @@ void DrawingLibInGhost( WinEDA_DrawPanel* panel, wxDC* DC, /* DrawMode = GrXOR, GrOR .. */ /************************************************************/ /* Utilise en LibEdit et Lib Browse */ -void DrawLibraryDrawStruct( WinEDA_DrawPanel* panel, wxDC* DC, - EDA_LibComponentStruct* LibEntry, - int PartX, int PartY, - LibEDA_BaseStruct* DrawItem, int Multi, - int DrawMode, int Color ) +void DrawLibraryDrawStruct( WinEDA_DrawPanel* aPanel, wxDC* aDC, + EDA_LibComponentStruct* aLibEntry, + wxPoint aPosition, + LibEDA_BaseStruct* aDrawItem, + int aDrawMode, int aColor ) { - int x1, y1, x2, y2, t1, t2, orient; - int CharColor; - int TransMat[2][2]; - int fill_option; - wxPoint position(PartX, PartY); + int TransMat[2][2]; + bool no_fill; -#undef GETCOLOR -#define GETCOLOR( l ) Color < 0 ? ReturnLayerColor( l ) : Color; - - Multi = 0; /* unused */ - /* Trace de la structure */ - CharColor = GETCOLOR( LAYER_DEVICE ); - GRSetDrawMode( DC, DrawMode ); + GRSetDrawMode( aDC, aDrawMode ); TransMat[0][0] = 1; TransMat[0][1] = TransMat[1][0] = 0; TransMat[1][1] = -1; - int LineWidth = MAX( DrawItem->m_Width, g_DrawMinimunLineWidth ); + no_fill = false; - switch( DrawItem->Type() ) + switch( aDrawItem->Type() ) { - case COMPONENT_ARC_DRAW_TYPE: - { - int xc, yc, x2, y2; - LibDrawArc* Arc = (LibDrawArc*) DrawItem; - t1 = Arc->t1; t2 = Arc->t2; - bool swap = MapAngles( &t1, &t2, TransMat ); - xc = PartX + Arc->m_Pos.x; - yc = PartY - Arc->m_Pos.y; - x2 = PartX + Arc->m_ArcStart.x; - y2 = PartY - Arc->m_ArcStart.y; - x1 = PartX + Arc->m_ArcEnd.x; - y1 = PartY - Arc->m_ArcEnd.y; - - if( swap ) - { - EXCHG( x1, x2 ); EXCHG( y1, y2 ) - } - fill_option = Arc->m_Fill; - if( g_IsPrinting && fill_option == FILLED_WITH_BG_BODYCOLOR && GetGRForceBlackPenState() ) - fill_option = NO_FILL; - if( fill_option == FILLED_WITH_BG_BODYCOLOR ) - GRFilledArc( &panel->m_ClipBox, DC, xc, yc, t1, t2, - Arc->m_Rayon, CharColor, - ReturnLayerColor( LAYER_DEVICE_BACKGROUND ) ); - else if( fill_option == FILLED_SHAPE ) - GRFilledArc( &panel->m_ClipBox, DC, xc, yc, t1, t2, - Arc->m_Rayon, LineWidth, CharColor, CharColor ); -#ifdef DRAW_ARC_WITH_ANGLE - else - GRArc( &panel->m_ClipBox, DC, xc, yc, t1, t2, - Arc->m_Rayon, CharColor ); -#else - else - GRArc1( &panel->m_ClipBox, DC, x1, y1, x2, y2, - xc, yc, LineWidth, CharColor ); -#endif - } - break; - - case COMPONENT_CIRCLE_DRAW_TYPE: - { - LibDrawCircle* Circle = (LibDrawCircle*) DrawItem; - x1 = PartX + Circle->m_Pos.x; - y1 = PartY - Circle->m_Pos.y; - fill_option = Circle->m_Fill; - if( g_IsPrinting && fill_option == FILLED_WITH_BG_BODYCOLOR && GetGRForceBlackPenState() ) - fill_option = NO_FILL; - if( fill_option == FILLED_WITH_BG_BODYCOLOR ) - GRFilledCircle( &panel->m_ClipBox, DC, x1, y1, - Circle->m_Rayon, LineWidth, CharColor, - ReturnLayerColor( LAYER_DEVICE_BACKGROUND ) ); - else if( fill_option == FILLED_SHAPE ) - GRFilledCircle( &panel->m_ClipBox, DC, x1, y1, - Circle->m_Rayon, 0, CharColor, CharColor ); - else - GRCircle( &panel->m_ClipBox, DC, x1, y1, - Circle->m_Rayon, LineWidth, CharColor ); - } - break; - - case COMPONENT_GRAPHIC_TEXT_DRAW_TYPE: - { - LibDrawText* Text = (LibDrawText*) DrawItem; - x1 = PartX + Text->m_Pos.x; - y1 = PartY - Text->m_Pos.y; - DrawGraphicText( panel, DC, wxPoint( x1, y1 ), CharColor, Text->m_Text, - Text->m_Horiz, - Text->m_Size, - GR_TEXT_HJUSTIFY_CENTER, GR_TEXT_VJUSTIFY_CENTER, LineWidth ); - } - break; - - case COMPONENT_RECT_DRAW_TYPE: - { - LibDrawSquare* Square = (LibDrawSquare*) DrawItem; - x1 = PartX + Square->m_Pos.x; - y1 = PartY - Square->m_Pos.y; - x2 = PartX + Square->m_End.x; - y2 = PartY - Square->m_End.y; - fill_option = Square->m_Fill; - if( g_IsPrinting && fill_option == FILLED_WITH_BG_BODYCOLOR && GetGRForceBlackPenState() ) - fill_option = NO_FILL; - if( fill_option == FILLED_WITH_BG_BODYCOLOR ) - GRFilledRect( &panel->m_ClipBox, DC, x1, y1, x2, y2, - CharColor, LineWidth, - ReturnLayerColor( LAYER_DEVICE_BACKGROUND ) ); - else if( fill_option == FILLED_SHAPE ) - GRFilledRect( &panel->m_ClipBox, DC, x1, y1, x2, y2, - CharColor, CharColor ); - else - GRRect( &panel->m_ClipBox, DC, x1, y1, x2, y2, LineWidth, - CharColor ); - } - break; - case COMPONENT_PIN_DRAW_TYPE: /* Trace des Pins */ { - LibDrawPin* Pin = (LibDrawPin*) DrawItem; - x2 = PartX + Pin->m_Pos.x; - y2 = PartY - Pin->m_Pos.y; - /* Compute the real pin orientation, i.e. pin orient + component orient */ - orient = Pin->ReturnPinDrawOrient( TransMat ); - - /* Dessin de la pin et du symbole special associe */ - if( Pin->m_Attributs & PINNOTDRAW ) - CharColor = DARKGRAY; - else - CharColor = -1; - - Pin->DrawPinSymbol( panel, DC, wxPoint( x2, y2 ), orient, DrawMode ); - wxPoint pinpos( x2, y2 ); - - Pin->DrawPinTexts( panel, DC, pinpos, orient, - LibEntry->m_TextInside, - LibEntry->m_DrawPinNum, LibEntry->m_DrawPinName, - CharColor, DrawMode ); + DrawPinPrms prms( aLibEntry, true ); + aDrawItem->Draw( aPanel, aDC, aPosition, aColor, aDrawMode, &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: - { - LibDrawPolyline* polyline = (LibDrawPolyline*) DrawItem; - fill_option = false; - if( g_IsPrinting && polyline->m_Fill == FILLED_WITH_BG_BODYCOLOR && GetGRForceBlackPenState() ) - fill_option = true; - DrawItem->Draw( panel, DC, position, Color,DrawMode, (void *) fill_option, TransMat ); - break; - } - default: - ; + if( g_IsPrinting && aDrawItem->m_Fill == FILLED_WITH_BG_BODYCOLOR + && GetGRForceBlackPenState() ) + no_fill = true; + aDrawItem->Draw( aPanel, aDC, aPosition, aColor, aDrawMode, (void*) no_fill, TransMat ); + break; } } diff --git a/eeschema/libclass.cpp b/eeschema/libclass.cpp index 8b41a2e2a7..0549a7cb66 100644 --- a/eeschema/libclass.cpp +++ b/eeschema/libclass.cpp @@ -434,179 +434,6 @@ void LibDrawField::Copy( LibDrawField* Target ) } -/* Elements Graphiques */ -LibEDA_BaseStruct::LibEDA_BaseStruct( KICAD_T struct_type ) : - EDA_BaseStruct( struct_type ) -{ - m_Unit = 0; /* Unit identification (for multi part per package) - * 0 if the item is common to all units */ - m_Convert = 0; /* Shape identification (for parts which have a convert shape) - * 0 if the item is common to all shapes */ - m_Width = 0; /* Default value to draw lines or arc ... */ -} - - -/***************************************************************/ -LibDrawPin::LibDrawPin() : LibEDA_BaseStruct( COMPONENT_PIN_DRAW_TYPE ) -/***************************************************************/ -{ - m_PinLen = 300; /* default Pin len */ - m_Orient = PIN_RIGHT; /* Pin oprient: Up, Down, Left, Right */ - m_PinShape = NONE; /* Bit a bit: Pin shape (voir enum prec) */ - m_PinType = PIN_UNSPECIFIED; /* electrical type of pin */ - m_Attributs = 0; /* bit 0 != 0: pin invisible */ - m_PinNum = 0; /*pin number ( i.e. 4 codes Ascii ) */ - m_PinNumSize = 50; - m_PinNameSize = 50; /* Default size for pin name and num */ - m_Width = 0; - -// m_PinNumWidth = m_PinNameWidth = 0; // Unused -} - - -/******************************************/ -wxPoint LibDrawPin::ReturnPinEndPoint() -/******************************************/ - -/* return the pin end position, for a component in normal orient - */ -{ - wxPoint pos = m_Pos; - - switch( m_Orient ) - { - case PIN_UP: - pos.y += m_PinLen; break; - - case PIN_DOWN: - pos.y -= m_PinLen; break; - - case PIN_LEFT: - pos.x -= m_PinLen; break; - - case PIN_RIGHT: - pos.x += m_PinLen; break; - } - - return pos; -} - - -/********************************************************/ -int LibDrawPin::ReturnPinDrawOrient( int TransMat[2][2] ) -/********************************************************/ - -/* Return the pin real orientation (PIN_UP, PIN_DOWN, PIN_RIGHT, PIN_LEFT), - * according to its orientation, - * AND the matrix transform (rot, mirror) TransMat - */ -{ - int orient; - int x1 = 0, y1 = 0; - int t1, t2; - - switch( m_Orient ) - { - case PIN_UP: - y1 = 1; break; - - case PIN_DOWN: - y1 = -1; break; - - case PIN_LEFT: - x1 = -1; break; - - case PIN_RIGHT: - x1 = 1; break; - } - - t1 = TransMat[0][0] * x1 + TransMat[0][1] * y1; - t2 = TransMat[1][0] * x1 + TransMat[1][1] * y1; - orient = PIN_UP; - if( t1 == 0 ) - { - if( t2 > 0 ) - orient = PIN_DOWN; - } - else - { - orient = PIN_RIGHT; - if( t1 < 0 ) - orient = PIN_LEFT; - } - - return orient; -} - - -/****************************************************/ -void LibDrawPin::ReturnPinStringNum( wxString& buffer ) -/****************************************************/ - -/* fill the buffer with pin num as a wxString - * Pin num is coded as a long - * Used to print/draw the pin num - */ -{ - char ascii_buf[5]; - - strncpy( ascii_buf, (char*) &m_PinNum, 4 ); - ascii_buf[4] = 0; - - buffer = CONV_FROM_UTF8( ascii_buf ); -} - - -/****************************************************/ -void LibDrawPin::SetPinNumFromString( wxString& buffer ) -/****************************************************/ - -/* fill the buffer with pin num as a wxString - * Pin num is coded as a long - * Used to print/draw the pin num - */ -{ - char ascii_buf[4]; - unsigned ii, len = buffer.Len(); - - ascii_buf[0] = ascii_buf[1] = ascii_buf[2] = ascii_buf[3] = 0; - if( len > 4 ) - len = 4; - for( ii = 0; ii < len; ii++ ) - { - ascii_buf[ii] = buffer.GetChar( ii ) & 0xFF; - } - - strncpy( (char*) &m_PinNum, ascii_buf, 4 ); -} - - -/*************************************/ -LibDrawPin* LibDrawPin::GenCopy() -/*************************************/ -{ - LibDrawPin* newpin = new LibDrawPin(); - - newpin->m_Pos = m_Pos; - newpin->m_PinLen = m_PinLen; - newpin->m_Orient = m_Orient; - newpin->m_PinShape = m_PinShape; - newpin->m_PinType = m_PinType; - newpin->m_Attributs = m_Attributs; - newpin->m_PinNum = m_PinNum; - newpin->m_PinNumSize = m_PinNumSize; - newpin->m_PinNameSize = m_PinNameSize; - newpin->m_Unit = m_Unit; - newpin->m_Convert = m_Convert; - newpin->m_Flags = m_Flags; - newpin->m_Width = m_Width; - - newpin->m_PinName = m_PinName; - - return newpin; -} - - /**************************************************************/ LibDrawArc::LibDrawArc() : LibEDA_BaseStruct( COMPONENT_ARC_DRAW_TYPE ) /**************************************************************/ diff --git a/eeschema/pinedit.cpp b/eeschema/pinedit.cpp index 2438d2d7b7..8cf52b902a 100644 --- a/eeschema/pinedit.cpp +++ b/eeschema/pinedit.cpp @@ -88,7 +88,7 @@ void WinEDA_PinPropertiesFrame::PinPropertiesAccept( wxCommandEvent& event ) m_Parent->DrawPanel->ManageCurseur( m_Parent->DrawPanel, &dc, FALSE ); else DrawLibraryDrawStruct( m_Parent->DrawPanel, &dc, CurrentLibEntry, - 0, 0, CurrentPin, CurrentUnit, g_XorMode ); + wxPoint(0, 0), CurrentPin, g_XorMode ); SetPinName( m_PinNameCtrl->GetValue(), LastPinNameSize ); msg = m_PinNumCtrl->GetValue(); if( msg.IsEmpty() ) @@ -103,7 +103,7 @@ void WinEDA_PinPropertiesFrame::PinPropertiesAccept( wxCommandEvent& event ) m_Parent->DrawPanel->ManageCurseur( m_Parent->DrawPanel, &dc, FALSE ); else DrawLibraryDrawStruct( m_Parent->DrawPanel, &dc, CurrentLibEntry, - 0, 0, CurrentPin, CurrentUnit, g_XorMode ); + wxPoint(0, 0), CurrentPin, g_XorMode ); } if( CurrentDrawItem ) @@ -250,7 +250,7 @@ void WinEDA_LibeditFrame::PlacePin( wxDC* DC ) } DrawPanel->CursorOff( DC ); - DrawLibraryDrawStruct( DrawPanel, DC, CurrentLibEntry, 0, 0, CurrentPin, CurrentUnit, + DrawLibraryDrawStruct( DrawPanel, DC, CurrentLibEntry, wxPoint(0, 0), CurrentPin, GR_DEFAULT_DRAWMODE ); DrawPanel->CursorOn( DC ); @@ -344,14 +344,14 @@ static void DrawMovePin( WinEDA_DrawPanel* panel, wxDC* DC, bool erase ) if( erase || (CurrentPin->m_Flags & IS_NEW) ) { CurrentPin->m_Pos = PinPreviousPos; - DrawLibraryDrawStruct( panel, DC, CurrentLibEntry, 0, 0, - CurrentPin, CurrentUnit, g_XorMode ); + DrawLibraryDrawStruct( panel, DC, CurrentLibEntry, wxPoint(0, 0), + CurrentPin, g_XorMode ); } /* Redraw pin in new position */ CurrentPin->m_Pos.x = panel->GetScreen()->m_Curseur.x; CurrentPin->m_Pos.y = -panel->GetScreen()->m_Curseur.y; - DrawLibraryDrawStruct( panel, DC, CurrentLibEntry, 0, 0, CurrentPin, CurrentUnit, g_XorMode ); + DrawLibraryDrawStruct( panel, DC, CurrentLibEntry, wxPoint(0, 0), CurrentPin, g_XorMode ); PinPreviousPos = CurrentPin->m_Pos; @@ -608,7 +608,7 @@ void WinEDA_LibeditFrame::CreatePin( wxDC* DC ) if( DC ) DrawLibraryDrawStruct( DrawPanel, DC, CurrentLibEntry, - 0, 0, CurrentPin, CurrentUnit, g_XorMode ); + wxPoint(0, 0), CurrentPin, g_XorMode ); DrawPanel->m_IgnoreMouseEvents = TRUE; InstallPineditFrame( this, DC, wxPoint( -1, -1 ) ); @@ -872,7 +872,7 @@ void WinEDA_LibeditFrame::GlobalSetPins( wxDC* DC, if( selected && (Pin->m_Selected & IS_SELECTED) == 0 ) continue; - DrawLibraryDrawStruct( DrawPanel, DC, CurrentLibEntry, 0, 0, Pin, CurrentUnit, g_XorMode ); + DrawLibraryDrawStruct( DrawPanel, DC, CurrentLibEntry, wxPoint(0, 0), Pin, g_XorMode ); switch( id ) { @@ -889,8 +889,7 @@ void WinEDA_LibeditFrame::GlobalSetPins( wxDC* DC, break; } - DrawLibraryDrawStruct( DrawPanel, DC, CurrentLibEntry, 0, 0, Pin, CurrentUnit, - GR_DEFAULT_DRAWMODE ); + DrawLibraryDrawStruct( DrawPanel, DC, CurrentLibEntry, wxPoint(0, 0), Pin, GR_DEFAULT_DRAWMODE ); } } diff --git a/eeschema/protos.h b/eeschema/protos.h index cc7cd0ce99..e094d60242 100644 --- a/eeschema/protos.h +++ b/eeschema/protos.h @@ -54,10 +54,10 @@ void DrawLibEntry(WinEDA_DrawPanel * panel, wxDC * DC, int Multi, int convert, int DrawMode, int Color = -1); -void DrawLibraryDrawStruct(WinEDA_DrawPanel * panel, wxDC * DC, - EDA_LibComponentStruct *LibEntry, int PartX, int PartY, - LibEDA_BaseStruct *DrawItem, int Multi, - int DrawMode, int Color = -1); +void DrawLibraryDrawStruct(WinEDA_DrawPanel * aPanel, wxDC * aDC, + EDA_LibComponentStruct *aLibEntry, wxPoint aPosition, + LibEDA_BaseStruct *aDrawItem, + int aDrawMode, int aColor = -1); bool MapAngles(int *Angle1, int *Angle2, int TransMat[2][2]); diff --git a/eeschema/symbdraw.cpp b/eeschema/symbdraw.cpp index 515fa4baf3..c87bd27c58 100644 --- a/eeschema/symbdraw.cpp +++ b/eeschema/symbdraw.cpp @@ -60,8 +60,8 @@ bodygraphics_PropertiesAccept( wxCommandEvent& event ) m_Parent->DrawPanel->PrepareGraphicContext( &dc ); - DrawLibraryDrawStruct( m_Parent->DrawPanel, &dc, CurrentLibEntry, 0, 0, - CurrentDrawItem, CurrentUnit, g_XorMode ); + DrawLibraryDrawStruct( m_Parent->DrawPanel, &dc, CurrentLibEntry, wxPoint(0, 0), + CurrentDrawItem, g_XorMode ); if( g_FlDrawSpecificUnit ) CurrentDrawItem->m_Unit = CurrentUnit; @@ -104,8 +104,8 @@ bodygraphics_PropertiesAccept( wxCommandEvent& event ) m_Parent->GetScreen()->SetModify(); - DrawLibraryDrawStruct( m_Parent->DrawPanel, &dc, CurrentLibEntry, 0, 0, - CurrentDrawItem, CurrentUnit, g_XorMode ); + DrawLibraryDrawStruct( m_Parent->DrawPanel, &dc, CurrentLibEntry, wxPoint(0, 0), + CurrentDrawItem, g_XorMode ); } Close(); @@ -150,8 +150,8 @@ static void AbortSymbolTraceOn( WinEDA_DrawPanel* Panel, wxDC* DC ) Panel->m_Parent->RedrawActiveWindow( DC, TRUE ); } else - DrawLibraryDrawStruct( Panel, DC, CurrentLibEntry, 0, 0, - CurrentDrawItem, CurrentUnit, g_XorMode ); + DrawLibraryDrawStruct( Panel, DC, CurrentLibEntry, wxPoint(0, 0), + CurrentDrawItem, g_XorMode ); SAFE_DELETE( CurrentDrawItem ); } else @@ -161,8 +161,8 @@ static void AbortSymbolTraceOn( WinEDA_DrawPanel* Panel, wxDC* DC ) Panel->GetScreen()->m_Curseur = StartCursor; RedrawWhileMovingCursor( Panel, DC, TRUE ); Panel->GetScreen()->m_Curseur = curpos; - DrawLibraryDrawStruct( Panel, DC, CurrentLibEntry, 0, 0, - CurrentDrawItem, CurrentUnit, GR_DEFAULT_DRAWMODE ); + DrawLibraryDrawStruct( Panel, DC, CurrentLibEntry, wxPoint(0, 0), + CurrentDrawItem, GR_DEFAULT_DRAWMODE ); CurrentDrawItem->m_Flags = 0; } @@ -303,8 +303,8 @@ LibEDA_BaseStruct* WinEDA_LibeditFrame::CreateGraphicItem( wxDC* DC ) else { StartMoveDrawSymbol( DC ); - DrawLibraryDrawStruct( DrawPanel, DC, CurrentLibEntry, 0, 0, - Text, CurrentUnit, g_XorMode ); + DrawLibraryDrawStruct( DrawPanel, DC, CurrentLibEntry, wxPoint(0, 0), + Text, g_XorMode ); } } break; @@ -383,23 +383,20 @@ static void RedrawWhileMovingCursor( WinEDA_DrawPanel* panel, wxDC* DC, bool era */ { BASE_SCREEN* Screen = panel->GetScreen(); - int mx, my; + wxPoint pos; /* Erase shape in the old positon*/ if( erase ) { - mx = ItemPreviousPos.x - StartCursor.x, - my = ItemPreviousPos.y - StartCursor.y; - - DrawLibraryDrawStruct( panel, DC, CurrentLibEntry, mx, my, - CurrentDrawItem, CurrentUnit, g_XorMode ); + pos = ItemPreviousPos - StartCursor, + DrawLibraryDrawStruct( panel, DC, CurrentLibEntry, pos, + CurrentDrawItem, g_XorMode ); } /* Redraw moved shape */ - mx = Screen->m_Curseur.x - StartCursor.x, - my = Screen->m_Curseur.y - StartCursor.y; - DrawLibraryDrawStruct( panel, DC, CurrentLibEntry, mx, my, - CurrentDrawItem, CurrentUnit, g_XorMode ); + pos = Screen->m_Curseur - StartCursor, + DrawLibraryDrawStruct( panel, DC, CurrentLibEntry, pos, + CurrentDrawItem, g_XorMode ); ItemPreviousPos = Screen->m_Curseur; } @@ -543,8 +540,8 @@ static void SymbolDisplayDraw( WinEDA_DrawPanel* panel, wxDC* DC, bool erase ) } else { - DrawLibraryDrawStruct( panel, DC, CurrentLibEntry, 0, 0, - CurrentDrawItem, CurrentUnit, DrawMode ); + DrawLibraryDrawStruct( panel, DC, CurrentLibEntry, wxPoint(0, 0), + CurrentDrawItem, DrawMode ); if( CurrentDrawItem->Type() == COMPONENT_ARC_DRAW_TYPE ) { int Color = ReturnLayerColor( LAYER_DEVICE ); @@ -615,8 +612,8 @@ static void SymbolDisplayDraw( WinEDA_DrawPanel* panel, wxDC* DC, bool erase ) } else { - DrawLibraryDrawStruct( panel, DC, CurrentLibEntry, 0, 0, - CurrentDrawItem, CurrentUnit, DrawMode ); + DrawLibraryDrawStruct( panel, DC, CurrentLibEntry, wxPoint(0, 0), + CurrentDrawItem, DrawMode ); if( CurrentDrawItem->Type() == COMPONENT_ARC_DRAW_TYPE ) { int Color = ReturnLayerColor( LAYER_DEVICE ); @@ -824,8 +821,8 @@ void WinEDA_LibeditFrame::DeleteDrawPoly( wxDC* DC ) int* ptpoly; LibDrawPolyline* Poly = (LibDrawPolyline*) CurrentDrawItem; - DrawLibraryDrawStruct( DrawPanel, DC, CurrentLibEntry, 0, 0, - CurrentDrawItem, CurrentUnit, g_XorMode ); + DrawLibraryDrawStruct( DrawPanel, DC, CurrentLibEntry, wxPoint(0, 0), + CurrentDrawItem, g_XorMode ); while( Poly->m_CornersCount > 2 ) // First segment is kept, only its end point is changed { @@ -843,6 +840,6 @@ void WinEDA_LibeditFrame::DeleteDrawPoly( wxDC* DC ) int allocsize = 2 * sizeof(int) * Poly->m_CornersCount; Poly->m_PolyList = (int*) realloc( Poly->m_PolyList, allocsize ); - DrawLibraryDrawStruct( DrawPanel, DC, CurrentLibEntry, 0, 0, - CurrentDrawItem, CurrentUnit, g_XorMode ); + DrawLibraryDrawStruct( DrawPanel, DC, CurrentLibEntry, wxPoint(0, 0), + CurrentDrawItem, g_XorMode ); } diff --git a/eeschema/symbtext.cpp b/eeschema/symbtext.cpp index 021ec44adf..4137f149da 100644 --- a/eeschema/symbtext.cpp +++ b/eeschema/symbtext.cpp @@ -291,8 +291,8 @@ int DrawMode = g_XorMode; /* Effacement ancien texte */ if( ((LibDrawText*)DrawItem)->m_Text && DC) - DrawLibraryDrawStruct(DrawPanel, DC, CurrentLibEntry, 0 , 0, - DrawItem, CurrentUnit, DrawMode); + DrawLibraryDrawStruct(DrawPanel, DC, CurrentLibEntry, wxPoint(0, 0), + DrawItem, DrawMode); WinEDA_bodytext_PropertiesFrame * frame = @@ -306,8 +306,8 @@ int DrawMode = g_XorMode; { if ( (DrawItem->m_Flags & IS_MOVED) == 0 ) DrawMode = GR_DEFAULT_DRAWMODE; - DrawLibraryDrawStruct(DrawPanel, DC, CurrentLibEntry, 0 , 0, - DrawItem, CurrentUnit, DrawMode); + DrawLibraryDrawStruct(DrawPanel, DC, CurrentLibEntry, wxPoint(0, 0), + DrawItem, DrawMode); } } @@ -325,8 +325,8 @@ LibDrawText * DrawItem = (LibDrawText *) CurrentDrawItem; /* Erase drawing (can be within a move command) */ if ( DrawPanel->ManageCurseur == NULL) - DrawLibraryDrawStruct(DrawPanel, DC, CurrentLibEntry, 0 , 0, - DrawItem, CurrentUnit, g_XorMode); + DrawLibraryDrawStruct(DrawPanel, DC, CurrentLibEntry, wxPoint(0, 0), + DrawItem, g_XorMode); else DrawPanel->ManageCurseur(DrawPanel, DC, FALSE); if( DrawItem->m_Horiz == TEXT_ORIENT_HORIZ) @@ -337,8 +337,8 @@ LibDrawText * DrawItem = (LibDrawText *) CurrentDrawItem; /* Redraw item with new orient */ if ( DrawPanel->ManageCurseur == NULL) - DrawLibraryDrawStruct(DrawPanel, DC, CurrentLibEntry, 0 , 0, - DrawItem, CurrentUnit, GR_DEFAULT_DRAWMODE); + DrawLibraryDrawStruct(DrawPanel, DC, CurrentLibEntry, wxPoint(0, 0), + DrawItem, GR_DEFAULT_DRAWMODE); else DrawPanel->ManageCurseur(DrawPanel, DC, FALSE); }