Commit 3370b134 authored by charras's avatar charras

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
......@@ -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 */
/***************************/
......@@ -115,13 +120,14 @@ 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 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 = MAX(pensize, 3);
pensize = wxRound( g_DrawDefaultLineThickness * BUS_WIDTH_EXPAND );
pensize = MAX( pensize, 3 );
}
return pensize;
......@@ -140,7 +146,7 @@ void DrawBusEntryStruct::Draw( WinEDA_DrawPanel* panel, wxDC* DC,
GRSetDrawMode( DC, DrawMode );
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, GetPenSize( ), color );
m_End().x + offset.x, m_End().y + offset.y, GetPenSize(), color );
}
......@@ -187,6 +193,7 @@ bool DrawJunctionStruct::Save( FILE* aFile ) const
EDA_Rect DrawJunctionStruct::GetBoundingBox()
// return a bounding box
{
int width = DRAWJUNCTION_SIZE * 2;
......@@ -216,11 +223,12 @@ bool DrawJunctionStruct::HitTest( const wxPoint& aPosRef )
* @return the size of the "pen" that be used to draw or plot this item
* has no meaning for DrawJunctionStruct
*/
int DrawJunctionStruct::GetPenSize( )
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,7 +305,8 @@ 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) )
if( (ABS( dist.x ) <= delta) && (ABS( dist.y ) <= delta) )
return true;
return false;
}
......@@ -324,11 +334,12 @@ 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( )
int DrawNoConnectStruct::GetPenSize()
{
return g_DrawDefaultLineThickness;
}
void DrawNoConnectStruct::Draw( WinEDA_DrawPanel* panel, wxDC* DC,
const wxPoint& offset, int DrawMode, int Color )
{
......@@ -420,7 +431,7 @@ wxString DrawMarkerStruct::GetComment()
}
#if defined (DEBUG)
#if defined(DEBUG)
/**
* Function Show
......@@ -435,6 +446,8 @@ void DrawMarkerStruct::Show( int nestLevel, std::ostream& os )
NestedSpace( nestLevel, os ) << '<' << GetClass().Lower().mb_str() << m_Pos
<< "/>\n";
}
#endif
/**
......@@ -448,7 +461,7 @@ 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,
int(m_Type) + 'A', m_Pos.x, m_Pos.y,
CONV_TO_UTF8( m_Comment ), m_MarkFlags ) == EOF )
{
success = false;
......@@ -530,7 +543,7 @@ bool EDA_DrawLineStruct::IsOneEndPointAt( const wxPoint& pos )
}
#if defined (DEBUG)
#if defined(DEBUG)
/**
* Function Show
......@@ -551,6 +564,7 @@ void EDA_DrawLineStruct::Show( int nestLevel, std::ostream& os )
"</" << GetClass().Lower().mb_str() << ">\n";
}
#endif
......@@ -593,8 +607,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;
}
......@@ -606,17 +620,25 @@ 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 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 )
{
int color;
int width = GetPenSize( );
int width = GetPenSize();
if( Color >= 0 )
color = 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;
}
......@@ -725,17 +741,19 @@ 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 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 )
{
int color;
int width = GetPenSize( );
int width = GetPenSize();
if( Color >= 0 )
color = Color;
......
......@@ -38,7 +38,7 @@ static void PlotNoConnectStruct( Plotter* plotter, DrawNoConnectStruct* Struct )
pX = Struct->m_Pos.x; pY = Struct->m_Pos.y;
plotter->set_current_line_width( Struct->GetPenSize( ) );
plotter->set_current_line_width( Struct->GetPenSize() );
plotter->move_to( wxPoint( pX - DELTA, pY - DELTA ) );
plotter->finish_to( wxPoint( pX + DELTA, pY + DELTA ) );
plotter->move_to( wxPoint( pX + DELTA, pY - DELTA ) );
......@@ -74,7 +74,7 @@ static void PlotLibPart( Plotter* plotter, SCH_COMPONENT* DrawLibItem )
if( convert && DEntry->m_Convert && (DEntry->m_Convert != convert) )
continue;
int thickness = DEntry->GetPenSize( );
int thickness = DEntry->GetPenSize();
plotter->set_color( ReturnLayerColor( LAYER_DEVICE ) );
draw_bgfill = plotter->get_color_mode();
......@@ -367,7 +367,7 @@ static void PlotTextField( Plotter* plotter, SCH_COMPONENT* DrawLibItem,
}
int thickness = field->GetPenSize( );
int thickness = field->GetPenSize();
if( !IsMulti || (FieldNumber != REFERENCE) )
{
......@@ -529,7 +529,7 @@ static void PlotTextStruct( Plotter* plotter, SCH_TEXT* aSchText )
EDA_Colors color = UNSPECIFIED_COLOR;
color = ReturnLayerColor( aSchText->m_Layer );
wxPoint textpos = aSchText->m_Pos + aSchText->GetSchematicTextOffset();
int thickness = aSchText->GetPenSize( );
int thickness = aSchText->GetPenSize();
plotter->set_current_line_width( thickness );
......@@ -604,7 +604,7 @@ static void Plot_Hierarchical_PIN_Sheet( Plotter* plotter,
side = GR_TEXT_HJUSTIFY_LEFT;
}
int thickness = aHierarchical_PIN->GetPenSize( );
int thickness = aHierarchical_PIN->GetPenSize();
plotter->set_current_line_width( thickness );
plotter->text( wxPoint( tposx, posy ), txtcolor,
......@@ -632,7 +632,7 @@ static void PlotSheetStruct( Plotter* plotter, DrawSheetStruct* Struct )
plotter->set_color( ReturnLayerColor( Struct->m_Layer ) );
int thickness = Struct->GetPenSize( );
int thickness = Struct->GetPenSize();
plotter->set_current_line_width( thickness );
plotter->move_to( Struct->m_Pos );
......@@ -698,10 +698,10 @@ void PlotDrawlist( Plotter* plotter, SCH_ITEM* aDrawlist )
int layer;
wxPoint StartPos, EndPos;
plotter->set_current_line_width( aDrawlist->GetPenSize( ) );
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;
......@@ -747,7 +735,7 @@ void PlotDrawlist( Plotter* plotter, SCH_ITEM* aDrawlist )
#undef STRUCT
#define STRUCT ( (DrawJunctionStruct*) aDrawlist )
plotter->set_color( ReturnLayerColor( STRUCT->GetLayer() ) );
plotter->circle( STRUCT->m_Pos, DRAWJUNCTION_SIZE*2, FILLED_SHAPE );
plotter->circle( STRUCT->m_Pos, DRAWJUNCTION_SIZE * 2, FILLED_SHAPE );
break;
case TYPE_SCH_TEXT:
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment