Commit 3370b134 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. Finished
parent c20d9b93
Loading
Loading
Loading
Loading
+71 −53
Original line number Diff line number Diff line
@@ -14,6 +14,11 @@

#include "protos.h"

/* used to calculate the pen size from default value
 * the actual pen size is default value * BUS_WIDTH_EXPAND
 */
 #define BUS_WIDTH_EXPAND 1.4

/****************************/
/* class DrawBusEntryStruct */
/***************************/
@@ -118,9 +123,10 @@ EDA_Rect DrawBusEntryStruct::GetBoundingBox()
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

    if( m_Layer == LAYER_BUS && m_Width == 0 )
    {
        pensize = wxRound(pensize * 1.3);
        pensize = wxRound( g_DrawDefaultLineThickness * BUS_WIDTH_EXPAND );
        pensize = MAX( pensize, 3 );
    }

@@ -187,6 +193,7 @@ bool DrawJunctionStruct::Save( FILE* aFile ) const


EDA_Rect DrawJunctionStruct::GetBoundingBox()

// return a bounding box
{
    int      width = DRAWJUNCTION_SIZE * 2;
@@ -221,6 +228,7 @@ int DrawJunctionStruct::GetPenSize( )
    return 0;
}


/*****************************************************************************
* Routine to redraw connection struct.										 *
*****************************************************************************/
@@ -250,6 +258,7 @@ void DrawJunctionStruct::Show( int nestLevel, std::ostream& os )
                                 << m_Pos << "/>\n";
}


#endif


@@ -296,6 +305,7 @@ bool DrawNoConnectStruct::HitTest( const wxPoint& aPosRef )
    int     delta = ( DRAWNOCONNECT_SIZE + width) / 2;

    wxPoint dist = aPosRef - m_Pos;

    if( (ABS( dist.x ) <= delta) && (ABS( dist.y ) <= delta) )
        return true;
    return false;
@@ -329,6 +339,7 @@ int DrawNoConnectStruct::GetPenSize( )
    return g_DrawDefaultLineThickness;
}


void DrawNoConnectStruct::Draw( WinEDA_DrawPanel* panel, wxDC* DC,
                                const wxPoint& offset, int DrawMode, int Color )
{
@@ -435,6 +446,8 @@ void DrawMarkerStruct::Show( int nestLevel, std::ostream& os )
    NestedSpace( nestLevel, os ) << '<' << GetClass().Lower().mb_str() << m_Pos
                                 << "/>\n";
}


#endif

/**
@@ -551,6 +564,7 @@ void EDA_DrawLineStruct::Show( int nestLevel, std::ostream& os )
    "</" << GetClass().Lower().mb_str() << ">\n";
}


#endif


@@ -609,9 +623,17 @@ bool EDA_DrawLineStruct::Save( FILE* aFile ) const
int EDA_DrawLineStruct::GetPenSize()
{
    int pensize = (m_Width == 0) ? g_DrawDefaultLineThickness : m_Width;

    if( m_Layer == LAYER_BUS && m_Width == 0 )
    {
        pensize = wxRound( g_DrawDefaultLineThickness * BUS_WIDTH_EXPAND );
        pensize = MAX( pensize, 3 );
    }

    return pensize;
}


void EDA_DrawLineStruct::Draw( WinEDA_DrawPanel* panel, wxDC* DC,
                               const wxPoint& offset, int DrawMode, int Color )
{
@@ -625,13 +647,6 @@ void EDA_DrawLineStruct::Draw( WinEDA_DrawPanel* panel, wxDC* DC,

    GRSetDrawMode( DC, DrawMode );

    // FIXME: Not compatable with new zoom.
    if( m_Layer == LAYER_BUS)
    {
        width = wxRound(width * 1.4);
        width = MAX(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,
@@ -681,6 +696,7 @@ DrawPolylineStruct::~DrawPolylineStruct()
DrawPolylineStruct* DrawPolylineStruct::GenCopy()
{
    DrawPolylineStruct* newitem = new DrawPolylineStruct( m_Layer );

    newitem->m_PolyPoints = m_PolyPoints;   // std::vector copy
    return newitem;
}
@@ -728,9 +744,11 @@ bool DrawPolylineStruct::Save( FILE* aFile ) const
int DrawPolylineStruct::GetPenSize()
{
    int pensize = (m_Width == 0) ? g_DrawDefaultLineThickness : m_Width;

    return pensize;
}


void DrawPolylineStruct::Draw( WinEDA_DrawPanel* panel, wxDC* DC,
                               const wxPoint& offset, int DrawMode, int Color )
{
+15 −27
Original line number Diff line number Diff line
@@ -701,7 +701,7 @@ void PlotDrawlist( Plotter* plotter, SCH_ITEM* aDrawlist )
        plotter->set_current_line_width( aDrawlist->GetPenSize() );
        switch( aDrawlist->Type() )
        {
        case DRAW_BUSENTRY_STRUCT_TYPE:             /* Struct Raccord et Segment sont identiques */
        case DRAW_BUSENTRY_STRUCT_TYPE:
        case DRAW_SEGMENT_STRUCT_TYPE:
            if( aDrawlist->Type() == DRAW_BUSENTRY_STRUCT_TYPE )
            {
@@ -722,24 +722,12 @@ void PlotDrawlist( Plotter* plotter, SCH_ITEM* aDrawlist )
                plotter->set_color( ReturnLayerColor( layer ) );
            }

            switch( layer )
            {
            case LAYER_NOTES:         /* Trace en pointilles */
            if( layer == LAYER_NOTES )
                plotter->set_dash( true );
            plotter->move_to( StartPos );
            plotter->finish_to( EndPos );
            if( layer == LAYER_NOTES )
                plotter->set_dash( false );
                break;

            case LAYER_BUS:         /* Trait large */
                plotter->thick_segment( StartPos, EndPos, aDrawlist->GetPenSize( ), FILLED );
            break;

            default:
                plotter->move_to( StartPos );
                plotter->finish_to( EndPos );
                break;
            }

            break;