Commit c1e1da1f 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. Work in progress
parent 7f9e9144
......@@ -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,
const wxPoint& aOffset,
......
......@@ -59,6 +59,11 @@ public:
#endif
/** Function GetPenSize
* @return the size of the "pen" that be used to draw or plot this item
*/
virtual int GetPenSize( );
/** function CreateGraphicShape
* Calculates the graphic shape (a polygon) associated to the text
* @param aCorner_list = list to fill with polygon corners coordinates
......@@ -121,6 +126,11 @@ public:
*/
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
* Draw the hierarchical sheet shape
* @param aPanel = the current DrawPanel
......
......@@ -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,
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;
int LineWidth = g_DrawDefaultLineThickness;
int LineWidth = GetPenSize( );
if( Color >= 0 )
txtcolor = (EDA_Colors) Color;
......
......@@ -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,
const wxPoint& offset, int DrawMode, int Color )
{
int color;
int width = (m_Width == 0) ? g_DrawDefaultLineThickness : m_Width;
if( Color >= 0 )
color = Color;
......@@ -124,14 +139,8 @@ void DrawBusEntryStruct::Draw( WinEDA_DrawPanel* panel, wxDC* DC,
color = ReturnLayerColor( m_Layer );
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,
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. *
*****************************************************************************/
......@@ -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,
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,
const wxPoint& offset, int DrawMode, int Color )
{
int color;
int width = (m_Width == 0) ? g_DrawDefaultLineThickness : m_Width;
int width = GetPenSize( );
if( Color >= 0 )
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,
const wxPoint& offset, int DrawMode, int Color )
{
int color;
int width = (m_Width == 0) ? g_DrawDefaultLineThickness : m_Width;
int width = GetPenSize( );
if( Color >= 0 )
color = Color;
......
......@@ -78,6 +78,11 @@ public:
*/
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)
void Show( int nestLevel, std::ostream& os );
#endif
......@@ -116,6 +121,12 @@ public:
*/
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)
void Show( int nestLevel, std::ostream& os );
#endif
......@@ -137,6 +148,12 @@ public:
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,
const wxPoint& offset, int draw_mode,
int Color = -1 );
......@@ -197,6 +214,12 @@ public:
bool Save( FILE* aFile ) const;
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) */
......@@ -242,6 +265,12 @@ public:
*/
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();
/** 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,
const wxPoint& offset, int draw_mode,
int Color = -1 );
......
......@@ -279,6 +279,12 @@ public:
void SetUnitSelection( DrawSheetPath* aSheet,
int aUnitSelection );
/** Function GetPenSize
* @return the size of the "pen" that be used to draw or plot this item
* for a component, has no meaning, but it is necessary to satisfy the SCH_ITEM class requirements
*/
virtual int GetPenSize( ) { return 0; }
#if defined (DEBUG)
/**
......
......@@ -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( -1 );
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 ) );
......@@ -126,9 +126,7 @@ static void PlotLibPart( Plotter* plotter, SCH_COMPONENT* DrawLibItem )
* transformation matrix causes xy axes to be flipped. */
t1 = (TransMat[0][0] != 0) ^ (Text->m_Orient != 0);
pos = TransformCoordinate( TransMat, Text->m_Pos ) + DrawLibItem->m_Pos;
int thickness = (Text->m_Width == 0) ? g_DrawDefaultLineThickness : Text->m_Width;
thickness = Clamp_Text_PenSize( thickness, Text->m_Size, Text->m_Bold );
int thickness = Text->GetPenSize( );
plotter->text( pos, CharColor,
Text->m_Text,
t1 ? TEXT_ORIENT_HORIZ : TEXT_ORIENT_VERT,
......@@ -167,8 +165,9 @@ static void PlotLibPart( Plotter* plotter, SCH_COMPONENT* DrawLibItem )
pos = TransformCoordinate( TransMat, Pin->m_Pos ) + DrawLibItem->m_Pos;
/* Dessin de la pin et du symbole special associe */
int thickness = Pin->GetPenSize();
plotter->set_current_line_width( thickness );
PlotPinSymbol( plotter, pos, Pin->m_PinLen, orient, Pin->m_PinShape );
int thickness = g_DrawDefaultLineThickness;
Pin->PlotPinTexts( plotter, pos, orient,
Entry->m_TextInside,
Entry->m_DrawPinNum, Entry->m_DrawPinName,
......@@ -414,8 +413,6 @@ static void PlotPinSymbol( Plotter* plotter, const wxPoint& pos,
plotter->set_color( color );
plotter->set_current_line_width( -1 );
MapX1 = MapY1 = 0; x1 = pos.x; y1 = pos.y;
switch( orient )
......@@ -607,12 +604,7 @@ static void Plot_Hierarchical_PIN_Sheet( Plotter* plotter,
side = GR_TEXT_HJUSTIFY_LEFT;
}
int thickness =
(aHierarchical_PIN->m_Width ==
0) ? g_DrawDefaultLineThickness : aHierarchical_PIN->m_Width;
thickness = Clamp_Text_PenSize( thickness,
aHierarchical_PIN->m_Size,
aHierarchical_PIN->m_Bold );
int thickness = aHierarchical_PIN->GetPenSize( );
plotter->set_current_line_width( thickness );
plotter->text( wxPoint( tposx, posy ), txtcolor,
......@@ -640,7 +632,7 @@ static void PlotSheetStruct( Plotter* plotter, DrawSheetStruct* Struct )
plotter->set_color( ReturnLayerColor( Struct->m_Layer ) );
int thickness = g_DrawDefaultLineThickness;
int thickness = Struct->GetPenSize( );
plotter->set_current_line_width( thickness );
plotter->move_to( Struct->m_Pos );
......@@ -706,6 +698,7 @@ void PlotDrawlist( Plotter* plotter, SCH_ITEM* drawlist )
int layer;
wxPoint StartPos, EndPos;
plotter->set_current_line_width( drawlist->GetPenSize( ) );
switch( drawlist->Type() )
{
case DRAW_BUSENTRY_STRUCT_TYPE: /* Struct Raccord et Segment sont identiques */
......@@ -732,7 +725,6 @@ void PlotDrawlist( Plotter* plotter, SCH_ITEM* drawlist )
switch( layer )
{
case LAYER_NOTES: /* Trace en pointilles */
plotter->set_current_line_width( g_DrawDefaultLineThickness );
plotter->set_dash( true );
plotter->move_to( StartPos );
plotter->finish_to( EndPos );
......@@ -740,18 +732,10 @@ void PlotDrawlist( Plotter* plotter, SCH_ITEM* drawlist )
break;
case LAYER_BUS: /* Trait large */
{
int thickness = wxRound( g_DrawDefaultLineThickness * 2 );
if( thickness < 3 )
thickness = 3;
/* We NEED it to be thick, even on HPGL */
plotter->thick_segment( StartPos, EndPos, thickness, FILLED );
plotter->set_current_line_width( g_DrawDefaultLineThickness );
}
plotter->thick_segment( StartPos, EndPos, drawlist->GetPenSize( ), FILLED );
break;
default:
plotter->set_current_line_width( g_DrawDefaultLineThickness );
plotter->move_to( StartPos );
plotter->finish_to( EndPos );
break;
......
......@@ -47,6 +47,11 @@ public:
*/
void SetLayer( int aLayer ) { m_Layer = aLayer; }
/** Function GetPenSize virtual pure
* @return the size of the "pen" that be used to draw or plot this item
*/
virtual int GetPenSize( ) = 0;
/**
* Function Draw
*/
......
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