Commit c1e1da1f authored by charras's avatar charras
Browse files

Eeschema: added GetPenSize() used in Draw and Plot functions to get the...

Eeschema: added GetPenSize() used in Draw and Plot functions to get the thickness of lines. Work in progress
parent 7f9e9144
Loading
Loading
Loading
Loading
+8 −0
Original line number Original line Diff line number Diff line
@@ -285,6 +285,14 @@ void DrawSheetStruct::CleanupSheet( WinEDA_SchematicFrame* aFrame, bool aRedraw
}
}




/** Function GetPenSize
 * @return the size of the "pen" that be used to draw or plot this item
 */
int DrawSheetStruct::GetPenSize( )
{
    return g_DrawDefaultLineThickness;
}

/**************************************************************************************/
/**************************************************************************************/
void DrawSheetStruct::Draw( WinEDA_DrawPanel* aPanel, wxDC* aDC,
void DrawSheetStruct::Draw( WinEDA_DrawPanel* aPanel, wxDC* aDC,
                            const wxPoint& aOffset,
                            const wxPoint& aOffset,
+10 −0
Original line number Original line Diff line number Diff line
@@ -59,6 +59,11 @@ public:


#endif
#endif


    /** Function GetPenSize
     * @return the size of the "pen" that be used to draw or plot this item
     */
    virtual int GetPenSize( );

    /** function CreateGraphicShape
    /** function CreateGraphicShape
     * Calculates the graphic shape (a polygon) associated to the text
     * Calculates the graphic shape (a polygon) associated to the text
     * @param aCorner_list = list to fill with polygon corners coordinates
     * @param aCorner_list = list to fill with polygon corners coordinates
@@ -121,6 +126,11 @@ public:
     */
     */
    void             CleanupSheet( WinEDA_SchematicFrame* frame, bool aRedraw );
    void             CleanupSheet( WinEDA_SchematicFrame* frame, bool aRedraw );


    /** Function GetPenSize
     * @return the size of the "pen" that be used to draw or plot this item
     */
    virtual int GetPenSize( );

    /** Function Draw
    /** Function Draw
     *  Draw the hierarchical sheet shape
     *  Draw the hierarchical sheet shape
     *  @param aPanel = the current DrawPanel
     *  @param aPanel = the current DrawPanel
+10 −1
Original line number Original line Diff line number Diff line
@@ -57,6 +57,15 @@ Hierarchical_PIN_Sheet_Struct* Hierarchical_PIN_Sheet_Struct::GenCopy()
}
}




/** Function GetPenSize
 * @return the size of the "pen" that be used to draw or plot this item
 */
int Hierarchical_PIN_Sheet_Struct::GetPenSize( )
{
    return g_DrawDefaultLineThickness;
}


/********************************************************************************************/
/********************************************************************************************/
void Hierarchical_PIN_Sheet_Struct::Draw( WinEDA_DrawPanel* panel, wxDC* DC, const wxPoint& offset,
void Hierarchical_PIN_Sheet_Struct::Draw( WinEDA_DrawPanel* panel, wxDC* DC, const wxPoint& offset,
                                          int DrawMode, int Color )
                                          int DrawMode, int Color )
@@ -69,7 +78,7 @@ void Hierarchical_PIN_Sheet_Struct::Draw( WinEDA_DrawPanel* panel, wxDC* DC, con


    static std::vector <wxPoint> Poly;
    static std::vector <wxPoint> Poly;


    int LineWidth = g_DrawDefaultLineThickness;
    int LineWidth = GetPenSize( );


    if( Color >= 0 )
    if( Color >= 0 )
        txtcolor = (EDA_Colors) Color;
        txtcolor = (EDA_Colors) Color;
+54 −10
Original line number Original line Diff line number Diff line
@@ -112,11 +112,26 @@ EDA_Rect DrawBusEntryStruct::GetBoundingBox()
}
}




/** Function GetPenSize
 * @return the size of the "pen" that be used to draw or plot this item
 */
int DrawBusEntryStruct::GetPenSize( )
{
    int pensize = (m_Width == 0) ? g_DrawDefaultLineThickness : m_Width;
    if( m_Layer == LAYER_BUS )      // TODO: find a better way to handle bus thickness
    {
        pensize = wxRound(pensize * 1.3);
        pensize = MAX(pensize, 3);
    }

    return pensize;
}


void DrawBusEntryStruct::Draw( WinEDA_DrawPanel* panel, wxDC* DC,
void DrawBusEntryStruct::Draw( WinEDA_DrawPanel* panel, wxDC* DC,
                               const wxPoint& offset, int DrawMode, int Color )
                               const wxPoint& offset, int DrawMode, int Color )
{
{
    int color;
    int color;
    int width = (m_Width == 0) ? g_DrawDefaultLineThickness : m_Width;


    if( Color >= 0 )
    if( Color >= 0 )
        color = Color;
        color = Color;
@@ -124,14 +139,8 @@ void DrawBusEntryStruct::Draw( WinEDA_DrawPanel* panel, wxDC* DC,
        color = ReturnLayerColor( m_Layer );
        color = ReturnLayerColor( m_Layer );
    GRSetDrawMode( DC, DrawMode );
    GRSetDrawMode( DC, DrawMode );


    if( m_Layer == LAYER_BUS )      // TODO: find a better way to handle bus thickness
    {
        width = wxRound(width * 1.3);
        width = MAX(width, 3);
    }

    GRLine( &panel->m_ClipBox, DC, m_Pos.x + offset.x, m_Pos.y + offset.y,
    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 );
            m_End().x + offset.x, m_End().y + offset.y, GetPenSize( ), color );
}
}




@@ -203,6 +212,15 @@ bool DrawJunctionStruct::HitTest( const wxPoint& aPosRef )
}
}




/** Function GetPenSize
 * @return the size of the "pen" that be used to draw or plot this item
 * has no meaning for DrawJunctionStruct
 */
int DrawJunctionStruct::GetPenSize( )
{
    return 0;
}

/*****************************************************************************
/*****************************************************************************
* Routine to redraw connection struct.										 *
* Routine to redraw connection struct.										 *
*****************************************************************************/
*****************************************************************************/
@@ -303,6 +321,14 @@ bool DrawNoConnectStruct::Save( FILE* aFile ) const
}
}




/** Function GetPenSize
 * @return the size of the "pen" that be used to draw or plot this item
 */
int DrawNoConnectStruct::GetPenSize( )
{
    return g_DrawDefaultLineThickness;
}

void DrawNoConnectStruct::Draw( WinEDA_DrawPanel* panel, wxDC* DC,
void DrawNoConnectStruct::Draw( WinEDA_DrawPanel* panel, wxDC* DC,
                                const wxPoint& offset, int DrawMode, int Color )
                                const wxPoint& offset, int DrawMode, int Color )
{
{
@@ -577,11 +603,20 @@ bool EDA_DrawLineStruct::Save( FILE* aFile ) const
}
}




/** Function GetPenSize
 * @return the size of the "pen" that be used to draw or plot this item
 */
int EDA_DrawLineStruct::GetPenSize( )
{
    int pensize = (m_Width == 0) ? g_DrawDefaultLineThickness : m_Width;
    return pensize;
}

void EDA_DrawLineStruct::Draw( WinEDA_DrawPanel* panel, wxDC* DC,
void EDA_DrawLineStruct::Draw( WinEDA_DrawPanel* panel, wxDC* DC,
                               const wxPoint& offset, int DrawMode, int Color )
                               const wxPoint& offset, int DrawMode, int Color )
{
{
    int color;
    int color;
    int width = (m_Width == 0) ? g_DrawDefaultLineThickness : m_Width;
    int width = GetPenSize( );


    if( Color >= 0 )
    if( Color >= 0 )
        color = Color;
        color = Color;
@@ -687,11 +722,20 @@ bool DrawPolylineStruct::Save( FILE* aFile ) const
}
}




/** Function GetPenSize
 * @return the size of the "pen" that be used to draw or plot this item
 */
int DrawPolylineStruct::GetPenSize( )
{
    int pensize = (m_Width == 0) ? g_DrawDefaultLineThickness : m_Width;
    return pensize;
}

void DrawPolylineStruct::Draw( WinEDA_DrawPanel* panel, wxDC* DC,
void DrawPolylineStruct::Draw( WinEDA_DrawPanel* panel, wxDC* DC,
                               const wxPoint& offset, int DrawMode, int Color )
                               const wxPoint& offset, int DrawMode, int Color )
{
{
    int color;
    int color;
    int width = (m_Width == 0) ? g_DrawDefaultLineThickness : m_Width;
    int width = GetPenSize( );


    if( Color >= 0 )
    if( Color >= 0 )
        color = Color;
        color = Color;
+34 −0
Original line number Original line Diff line number Diff line
@@ -78,6 +78,11 @@ public:
     */
     */
    bool         Save( FILE* aFile ) const;
    bool         Save( FILE* aFile ) const;


    /** Function GetPenSize
     * @return the size of the "pen" that be used to draw or plot this item
     */
    virtual int GetPenSize( );

#if defined(DEBUG)
#if defined(DEBUG)
    void         Show( int nestLevel, std::ostream& os );
    void         Show( int nestLevel, std::ostream& os );
#endif
#endif
@@ -116,6 +121,12 @@ public:
     */
     */
    bool              Save( FILE* aFile ) const;
    bool              Save( FILE* aFile ) const;


    /** Function GetPenSize
     * @return the size of the "pen" that be used to draw or plot this item
     * for a marker, has no meaning, but it is necessary to satisfy the SCH_ITEM class requirements
     */
    virtual int GetPenSize( ) { return 0; };

#if defined(DEBUG)
#if defined(DEBUG)
    void              Show( int nestLevel, std::ostream& os );
    void              Show( int nestLevel, std::ostream& os );
#endif
#endif
@@ -137,6 +148,12 @@ public:




    DrawNoConnectStruct* GenCopy();
    DrawNoConnectStruct* GenCopy();

    /** Function GetPenSize
     * @return the size of the "pen" that be used to draw or plot this item
     */
    virtual int GetPenSize( );

    virtual void         Draw( WinEDA_DrawPanel* panel, wxDC* DC,
    virtual void         Draw( WinEDA_DrawPanel* panel, wxDC* DC,
                               const wxPoint& offset, int draw_mode,
                               const wxPoint& offset, int draw_mode,
                               int Color = -1 );
                               int Color = -1 );
@@ -197,6 +214,12 @@ public:
    bool                Save( FILE* aFile ) const;
    bool                Save( FILE* aFile ) const;


    EDA_Rect            GetBoundingBox();
    EDA_Rect            GetBoundingBox();

    /** Function GetPenSize
     * @return the size of the "pen" that be used to draw or plot this item
     */
    virtual int GetPenSize( );

};
};


class DrawPolylineStruct  : public SCH_ITEM /* Polyligne (serie de segments) */
class DrawPolylineStruct  : public SCH_ITEM /* Polyligne (serie de segments) */
@@ -242,6 +265,12 @@ public:
     */
     */


    unsigned GetCornerCount() const { return m_PolyPoints.size(); }
    unsigned GetCornerCount() const { return m_PolyPoints.size(); }

    /** Function GetPenSize
     * @return the size of the "pen" that be used to draw or plot this item
     */
    virtual int GetPenSize( );

};
};




@@ -270,6 +299,11 @@ public:


    DrawJunctionStruct* GenCopy();
    DrawJunctionStruct* GenCopy();


    /** Function GetPenSize
     * @return the size of the "pen" that be used to draw or plot this item
     */
    virtual int GetPenSize( );

    virtual void        Draw( WinEDA_DrawPanel* panel, wxDC* DC,
    virtual void        Draw( WinEDA_DrawPanel* panel, wxDC* DC,
                              const wxPoint& offset, int draw_mode,
                              const wxPoint& offset, int draw_mode,
                              int Color = -1 );
                              int Color = -1 );
Loading