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

This commit is contained in:
charras 2009-07-01 16:07:18 +00:00
parent c20d9b9328
commit 3370b1348c
2 changed files with 86 additions and 80 deletions

View File

@ -14,6 +14,11 @@
#include "protos.h" #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 */ /* class DrawBusEntryStruct */
/***************************/ /***************************/
@ -118,9 +123,10 @@ EDA_Rect DrawBusEntryStruct::GetBoundingBox()
int DrawBusEntryStruct::GetPenSize() int DrawBusEntryStruct::GetPenSize()
{ {
int pensize = (m_Width == 0) ? g_DrawDefaultLineThickness : m_Width; 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 ); pensize = MAX( pensize, 3 );
} }
@ -187,6 +193,7 @@ bool DrawJunctionStruct::Save( FILE* aFile ) const
EDA_Rect DrawJunctionStruct::GetBoundingBox() EDA_Rect DrawJunctionStruct::GetBoundingBox()
// return a bounding box // return a bounding box
{ {
int width = DRAWJUNCTION_SIZE * 2; int width = DRAWJUNCTION_SIZE * 2;
@ -221,6 +228,7 @@ int DrawJunctionStruct::GetPenSize( )
return 0; return 0;
} }
/***************************************************************************** /*****************************************************************************
* Routine to redraw connection struct. * * Routine to redraw connection struct. *
*****************************************************************************/ *****************************************************************************/
@ -250,6 +258,7 @@ void DrawJunctionStruct::Show( int nestLevel, std::ostream& os )
<< m_Pos << "/>\n"; << m_Pos << "/>\n";
} }
#endif #endif
@ -296,6 +305,7 @@ bool DrawNoConnectStruct::HitTest( const wxPoint& aPosRef )
int delta = ( DRAWNOCONNECT_SIZE + width) / 2; int delta = ( DRAWNOCONNECT_SIZE + width) / 2;
wxPoint dist = aPosRef - m_Pos; 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 true;
return false; return false;
@ -329,6 +339,7 @@ int DrawNoConnectStruct::GetPenSize( )
return g_DrawDefaultLineThickness; 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 )
{ {
@ -435,6 +446,8 @@ void DrawMarkerStruct::Show( int nestLevel, std::ostream& os )
NestedSpace( nestLevel, os ) << '<' << GetClass().Lower().mb_str() << m_Pos NestedSpace( nestLevel, os ) << '<' << GetClass().Lower().mb_str() << m_Pos
<< "/>\n"; << "/>\n";
} }
#endif #endif
/** /**
@ -551,6 +564,7 @@ void EDA_DrawLineStruct::Show( int nestLevel, std::ostream& os )
"</" << GetClass().Lower().mb_str() << ">\n"; "</" << GetClass().Lower().mb_str() << ">\n";
} }
#endif #endif
@ -609,9 +623,17 @@ bool EDA_DrawLineStruct::Save( FILE* aFile ) const
int EDA_DrawLineStruct::GetPenSize() int EDA_DrawLineStruct::GetPenSize()
{ {
int pensize = (m_Width == 0) ? g_DrawDefaultLineThickness : m_Width; 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; 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 )
{ {
@ -625,13 +647,6 @@ void EDA_DrawLineStruct::Draw( WinEDA_DrawPanel* panel, wxDC* DC,
GRSetDrawMode( DC, DrawMode ); 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 ) if( m_Layer == LAYER_NOTES )
GRDashedLine( &panel->m_ClipBox, DC, m_Start.x + offset.x, GRDashedLine( &panel->m_ClipBox, DC, m_Start.x + offset.x,
m_Start.y + offset.y, m_End.x + offset.x, m_Start.y + offset.y, m_End.x + offset.x,
@ -681,6 +696,7 @@ DrawPolylineStruct::~DrawPolylineStruct()
DrawPolylineStruct* DrawPolylineStruct::GenCopy() DrawPolylineStruct* DrawPolylineStruct::GenCopy()
{ {
DrawPolylineStruct* newitem = new DrawPolylineStruct( m_Layer ); DrawPolylineStruct* newitem = new DrawPolylineStruct( m_Layer );
newitem->m_PolyPoints = m_PolyPoints; // std::vector copy newitem->m_PolyPoints = m_PolyPoints; // std::vector copy
return newitem; return newitem;
} }
@ -728,9 +744,11 @@ bool DrawPolylineStruct::Save( FILE* aFile ) const
int DrawPolylineStruct::GetPenSize() int DrawPolylineStruct::GetPenSize()
{ {
int pensize = (m_Width == 0) ? g_DrawDefaultLineThickness : m_Width; int pensize = (m_Width == 0) ? g_DrawDefaultLineThickness : m_Width;
return pensize; 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 )
{ {

View File

@ -701,7 +701,7 @@ void PlotDrawlist( Plotter* plotter, SCH_ITEM* aDrawlist )
plotter->set_current_line_width( aDrawlist->GetPenSize() ); plotter->set_current_line_width( aDrawlist->GetPenSize() );
switch( aDrawlist->Type() ) switch( aDrawlist->Type() )
{ {
case DRAW_BUSENTRY_STRUCT_TYPE: /* Struct Raccord et Segment sont identiques */ case DRAW_BUSENTRY_STRUCT_TYPE:
case DRAW_SEGMENT_STRUCT_TYPE: case DRAW_SEGMENT_STRUCT_TYPE:
if( aDrawlist->Type() == DRAW_BUSENTRY_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 ) ); plotter->set_color( ReturnLayerColor( layer ) );
} }
switch( layer ) if( layer == LAYER_NOTES )
{
case LAYER_NOTES: /* Trace en pointilles */
plotter->set_dash( true ); plotter->set_dash( true );
plotter->move_to( StartPos ); plotter->move_to( StartPos );
plotter->finish_to( EndPos ); plotter->finish_to( EndPos );
if( layer == LAYER_NOTES )
plotter->set_dash( false ); 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; break;