Commit c1802037 authored by Wayne Stambaugh's avatar Wayne Stambaugh

Schematic object plot code refactoring and CMake required version changes.

* Change the minimum required CMake version to 2.6.4 for all build platforms
  except Windows and OSX.
* Move all schematic plot code from plot.cpp into the appropriate schematic
  objects.
* Create SCH_SCREEN plot method to plot all objects in the schematic
  screen.
* Delete plot.cpp and remove it from the CMakeList file.
parent 3ea0c106
project(kicad) project(kicad)
# test the minimum Cmake version requirement (could be different under unix or Windows # The minimum CMake version requirement could be different under unix, OSX, or Windows
if(WIN32) if(WIN32)
cmake_minimum_required(VERSION 2.8.0 FATAL_ERROR) cmake_minimum_required(VERSION 2.8.0 FATAL_ERROR) # win32 and win64
elseif(APPLE)
cmake_minimum_required(VERSION 2.8.0 FATAL_ERROR) # OSX
else(WIN32) else(WIN32)
cmake_minimum_required(VERSION 2.8.0 FATAL_ERROR) cmake_minimum_required(VERSION 2.6.4 FATAL_ERROR) # Linux, Unix, and everything else.
endif(WIN32) endif(WIN32)
# Path to local CMake modules. # Path to local CMake modules.
......
...@@ -26,7 +26,7 @@ bool sort_schematic_items( const SCH_ITEM* aItem1, const SCH_ITEM* aItem2 ) ...@@ -26,7 +26,7 @@ bool sort_schematic_items( const SCH_ITEM* aItem1, const SCH_ITEM* aItem2 )
/* Constructor and destructor for SCH_ITEM */ /* Constructor and destructor for SCH_ITEM */
/* They are not inline because this creates problems with gcc at linking time /* They are not inline because this creates problems with gcc at linking time
* in debug mode * in debug mode
*/ */
SCH_ITEM::SCH_ITEM( EDA_ITEM* aParent, KICAD_T aType ) : SCH_ITEM::SCH_ITEM( EDA_ITEM* aParent, KICAD_T aType ) :
EDA_ITEM( aParent, aType ) EDA_ITEM( aParent, aType )
...@@ -127,3 +127,9 @@ bool SCH_ITEM::operator < ( const SCH_ITEM& aItem ) const ...@@ -127,3 +127,9 @@ bool SCH_ITEM::operator < ( const SCH_ITEM& aItem ) const
wxCHECK_MSG( false, this->Type() < aItem.Type(), wxCHECK_MSG( false, this->Type() < aItem.Type(),
wxT( "Less than operator not defined for " ) + GetClass() ); wxT( "Less than operator not defined for " ) + GetClass() );
} }
void SCH_ITEM::doPlot( PLOTTER* aPlotter )
{
wxFAIL_MSG( wxT( "doPlot() method not implemented for class " ) + GetClass() );
}
...@@ -112,7 +112,6 @@ set(EESCHEMA_SRCS ...@@ -112,7 +112,6 @@ set(EESCHEMA_SRCS
onrightclick.cpp onrightclick.cpp
operations_on_items_lists.cpp operations_on_items_lists.cpp
pinedit.cpp pinedit.cpp
plot.cpp
sch_bus_entry.cpp sch_bus_entry.cpp
sch_collectors.cpp sch_collectors.cpp
sch_component.cpp sch_component.cpp
......
...@@ -242,7 +242,7 @@ void DIALOG_PLOT_SCHEMATIC_DXF::PlotOneSheetDXF( const wxString& FileName, ...@@ -242,7 +242,7 @@ void DIALOG_PLOT_SCHEMATIC_DXF::PlotOneSheetDXF( const wxString& FileName,
m_Parent->PlotWorkSheet( plotter, screen ); m_Parent->PlotWorkSheet( plotter, screen );
} }
PlotDrawlist( plotter, screen->GetDrawItems() ); screen->Plot( plotter );
/* fin */ /* fin */
plotter->end_plot(); plotter->end_plot();
......
...@@ -392,7 +392,7 @@ void DIALOG_PLOT_SCHEMATIC_HPGL::Plot_1_Page_HPGL( const wxString& FileName, ...@@ -392,7 +392,7 @@ void DIALOG_PLOT_SCHEMATIC_HPGL::Plot_1_Page_HPGL( const wxString& FileName,
if( m_plot_Sheet_Ref ) if( m_plot_Sheet_Ref )
m_Parent->PlotWorkSheet( plotter, screen ); m_Parent->PlotWorkSheet( plotter, screen );
PlotDrawlist( plotter, screen->GetDrawItems() ); screen->Plot( plotter );
plotter->end_plot(); plotter->end_plot();
delete plotter; delete plotter;
......
...@@ -293,7 +293,7 @@ void DIALOG_PLOT_SCHEMATIC_PS::plotOneSheetPS( const wxString& FileName, ...@@ -293,7 +293,7 @@ void DIALOG_PLOT_SCHEMATIC_PS::plotOneSheetPS( const wxString& FileName,
m_Parent->PlotWorkSheet( plotter, screen ); m_Parent->PlotWorkSheet( plotter, screen );
} }
PlotDrawlist( plotter, screen->GetDrawItems() ); screen->Plot( plotter );
plotter->end_plot(); plotter->end_plot();
delete plotter; delete plotter;
......
...@@ -157,10 +157,6 @@ const wxChar* MsgPinElectricType[] = ...@@ -157,10 +157,6 @@ const wxChar* MsgPinElectricType[] =
}; };
extern void PlotPinSymbol( PLOTTER* plotter, const wxPoint& pos,
int len, int orient, int Shape );
LIB_PIN::LIB_PIN( LIB_COMPONENT* aParent ) : LIB_PIN::LIB_PIN( LIB_COMPONENT* aParent ) :
LIB_ITEM( LIB_PIN_T, aParent ) LIB_ITEM( LIB_PIN_T, aParent )
{ {
...@@ -1284,6 +1280,110 @@ void LIB_PIN::DrawPinTexts( EDA_DRAW_PANEL* panel, ...@@ -1284,6 +1280,110 @@ void LIB_PIN::DrawPinTexts( EDA_DRAW_PANEL* panel,
} }
void LIB_PIN::PlotSymbol( PLOTTER* aPlotter, const wxPoint& aPosition, int aOrientation )
{
int MapX1, MapY1, x1, y1;
EDA_Colors color = UNSPECIFIED_COLOR;
color = ReturnLayerColor( LAYER_PIN );
aPlotter->set_color( color );
MapX1 = MapY1 = 0;
x1 = aPosition.x; y1 = aPosition.y;
switch( aOrientation )
{
case PIN_UP:
y1 = aPosition.y - m_length;
MapY1 = 1;
break;
case PIN_DOWN:
y1 = aPosition.y + m_length;
MapY1 = -1;
break;
case PIN_LEFT:
x1 = aPosition.x - m_length;
MapX1 = 1;
break;
case PIN_RIGHT:
x1 = aPosition.x + m_length;
MapX1 = -1;
break;
}
if( m_shape & INVERT )
{
aPlotter->circle( wxPoint( MapX1 * INVERT_PIN_RADIUS + x1,
MapY1 * INVERT_PIN_RADIUS + y1 ),
INVERT_PIN_RADIUS * 2, // diameter
NO_FILL, // fill
-1 ); // width
aPlotter->move_to( wxPoint( MapX1 * INVERT_PIN_RADIUS * 2 + x1,
MapY1 * INVERT_PIN_RADIUS * 2 + y1 ) );
aPlotter->finish_to( aPosition );
}
else
{
aPlotter->move_to( wxPoint( x1, y1 ) );
aPlotter->finish_to( aPosition );
}
if( m_shape & CLOCK )
{
if( MapY1 == 0 ) /* MapX1 = +- 1 */
{
aPlotter->move_to( wxPoint( x1, y1 + CLOCK_PIN_DIM ) );
aPlotter->line_to( wxPoint( x1 - MapX1 * CLOCK_PIN_DIM, y1 ) );
aPlotter->finish_to( wxPoint( x1, y1 - CLOCK_PIN_DIM ) );
}
else /* MapX1 = 0 */
{
aPlotter->move_to( wxPoint( x1 + CLOCK_PIN_DIM, y1 ) );
aPlotter->line_to( wxPoint( x1, y1 - MapY1 * CLOCK_PIN_DIM ) );
aPlotter->finish_to( wxPoint( x1 - CLOCK_PIN_DIM, y1 ) );
}
}
if( m_shape & LOWLEVEL_IN ) /* IEEE symbol "Active Low Input" */
{
if( MapY1 == 0 ) /* MapX1 = +- 1 */
{
aPlotter->move_to( wxPoint( x1 + MapX1 * IEEE_SYMBOL_PIN_DIM * 2, y1 ) );
aPlotter->line_to( wxPoint( x1 + MapX1 * IEEE_SYMBOL_PIN_DIM * 2,
y1 - IEEE_SYMBOL_PIN_DIM ) );
aPlotter->finish_to( wxPoint( x1, y1 ) );
}
else /* MapX1 = 0 */
{
aPlotter->move_to( wxPoint( x1, y1 + MapY1 * IEEE_SYMBOL_PIN_DIM * 2 ) );
aPlotter->line_to( wxPoint( x1 - IEEE_SYMBOL_PIN_DIM,
y1 + MapY1 * IEEE_SYMBOL_PIN_DIM * 2 ) );
aPlotter->finish_to( wxPoint( x1, y1 ) );
}
}
if( m_shape & LOWLEVEL_OUT ) /* IEEE symbol "Active Low Output" */
{
if( MapY1 == 0 ) /* MapX1 = +- 1 */
{
aPlotter->move_to( wxPoint( x1, y1 - IEEE_SYMBOL_PIN_DIM ) );
aPlotter->finish_to( wxPoint( x1 + MapX1 * IEEE_SYMBOL_PIN_DIM * 2, y1 ) );
}
else /* MapX1 = 0 */
{
aPlotter->move_to( wxPoint( x1 - IEEE_SYMBOL_PIN_DIM, y1 ) );
aPlotter->finish_to( wxPoint( x1, y1 + MapY1 * IEEE_SYMBOL_PIN_DIM * 2 ) );
}
}
}
/***************************************************************************** /*****************************************************************************
* Plot pin number and pin text info, given the pin line coordinates. * * Plot pin number and pin text info, given the pin line coordinates. *
* Same as DrawPinTexts((), but output is the plotter * Same as DrawPinTexts((), but output is the plotter
...@@ -1748,7 +1848,7 @@ void LIB_PIN::DoPlot( PLOTTER* plotter, const wxPoint& offset, bool fill, ...@@ -1748,7 +1848,7 @@ void LIB_PIN::DoPlot( PLOTTER* plotter, const wxPoint& offset, bool fill,
wxPoint pos = aTransform.TransformCoordinate( m_position ) + offset; wxPoint pos = aTransform.TransformCoordinate( m_position ) + offset;
plotter->set_current_line_width( GetPenSize() ); plotter->set_current_line_width( GetPenSize() );
PlotPinSymbol( plotter, pos, m_length, orient, m_shape ); PlotSymbol( plotter, pos, orient );
PlotPinTexts( plotter, pos, orient, GetParent()->GetPinNameOffset(), PlotPinTexts( plotter, pos, orient, GetParent()->GetPinNameOffset(),
GetParent()->ShowPinNumbers(), GetParent()->ShowPinNames(), GetParent()->ShowPinNumbers(), GetParent()->ShowPinNames(),
GetPenSize() ); GetPenSize() );
......
...@@ -372,6 +372,8 @@ public: ...@@ -372,6 +372,8 @@ public:
bool aDrawPinName, bool aDrawPinName,
int aWidth ); int aWidth );
void PlotSymbol( PLOTTER* aPlotter, const wxPoint& aPosition, int aOrientation );
/** /**
* Get a list of pin orientation names. * Get a list of pin orientation names.
* *
......
/***************************************************/
/* Plot functions common to different plot formats */
/***************************************************/
#include "fctsys.h"
#include "common.h"
#include "plot_common.h"
#include "worksheet.h"
#include "base_struct.h"
#include "drawtxt.h"
#include "trigo.h"
#include "general.h"
#include "protos.h"
#include "class_library.h"
#include "lib_pin.h"
#include "sch_bus_entry.h"
#include "sch_junction.h"
#include "sch_line.h"
#include "sch_no_connect.h"
#include "sch_component.h"
#include "sch_sheet.h"
#include "sch_text.h"
#include "template_fieldnames.h"
/* Local functions : */
static void PlotTextField( PLOTTER* plotter, SCH_COMPONENT* DrawLibItem,
int FieldNumber, bool IsMulti, int DrawMode );
static void PlotNoConnectStruct( PLOTTER* plotter, SCH_NO_CONNECT* Struct )
{
int delta = Struct->m_Size.x / 2;
int pX, pY;
pX = Struct->m_Pos.x; pY = Struct->m_Pos.y;
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 ) );
plotter->finish_to( wxPoint( pX - delta, pY + delta ) );
}
static void PlotLibPart( PLOTTER* plotter, SCH_COMPONENT* DrawLibItem )
{
LIB_COMPONENT* Entry;
TRANSFORM temp = TRANSFORM();
Entry = CMP_LIBRARY::FindLibraryComponent( DrawLibItem->GetLibName() );
if( Entry == NULL )
return;
temp = DrawLibItem->GetTransform();
Entry->Plot( plotter, DrawLibItem->GetUnit(), DrawLibItem->GetConvert(),
DrawLibItem->m_Pos, temp );
bool isMulti = Entry->GetPartCount() > 1;
for( int fieldId = 0; fieldId < DrawLibItem->GetFieldCount(); fieldId++ )
{
PlotTextField( plotter, DrawLibItem, fieldId, isMulti, 0 );
}
}
/* Plot field text.
* Input:
* DrawLibItem: pointer to the component
* FieldNumber: Number Field
* IsMulti: true flag if there are several parts per package.
* Only useful for the field to add a reference to this one
* The identification from (A, B ...)
* DrawMode: trace mode
*/
static void PlotTextField( PLOTTER* plotter, SCH_COMPONENT* DrawLibItem,
int FieldNumber, bool IsMulti, int DrawMode )
{
SCH_FIELD* field = DrawLibItem->GetField( FieldNumber );
EDA_Colors color = UNSPECIFIED_COLOR;
color = ReturnLayerColor( field->GetLayer() );
DrawMode = 0; /* Unused */
if( field->m_Attributs & TEXT_NO_VISIBLE )
return;
if( field->IsVoid() )
return;
/* Calculate the text orientation, according to the component
* orientation/mirror */
int orient = field->m_Orient;
if( DrawLibItem->GetTransform().y1 ) // Rotate component 90 deg.
{
if( orient == TEXT_ORIENT_HORIZ )
orient = TEXT_ORIENT_VERT;
else
orient = TEXT_ORIENT_HORIZ;
}
/* Calculate the text justification, according to the component
* orientation/mirror
* this is a bit complicated due to cumulative calculations:
* - numerous cases (mirrored or not, rotation)
* - the DrawGraphicText function recalculate also H and H justifications
* according to the text orientation.
* - When a component is mirrored, the text is not mirrored and
* justifications are complicated to calculate
* so the more easily way is to use no justifications ( Centered text )
* and use GetBoundaryBox to know the text coordinate considered as centered
*/
EDA_RECT BoundaryBox = field->GetBoundingBox();
GRTextHorizJustifyType hjustify = GR_TEXT_HJUSTIFY_CENTER;
GRTextVertJustifyType vjustify = GR_TEXT_VJUSTIFY_CENTER;
wxPoint textpos = BoundaryBox.Centre();
int thickness = field->GetPenSize();
if( !IsMulti || (FieldNumber != REFERENCE) )
{
plotter->text( textpos, color, field->m_Text,
orient,
field->m_Size,
hjustify, vjustify,
thickness, field->m_Italic, field->m_Bold );
}
else /* We plot the reference, for a multiple parts per package */
{
/* Adding A, B ... to the reference */
wxString Text;
Text = field->m_Text + LIB_COMPONENT::ReturnSubReference( DrawLibItem->GetUnit() );
plotter->text( textpos, color, Text,
orient,
field->m_Size, hjustify, vjustify,
thickness, field->m_Italic, field->m_Bold );
}
}
void PlotPinSymbol( PLOTTER* plotter, const wxPoint& pos,
int len, int orient, int Shape )
{
int MapX1, MapY1, x1, y1;
EDA_Colors color = UNSPECIFIED_COLOR;
color = ReturnLayerColor( LAYER_PIN );
plotter->set_color( color );
MapX1 = MapY1 = 0; x1 = pos.x; y1 = pos.y;
switch( orient )
{
case PIN_UP:
y1 = pos.y - len; MapY1 = 1;
break;
case PIN_DOWN:
y1 = pos.y + len; MapY1 = -1;
break;
case PIN_LEFT:
x1 = pos.x - len, MapX1 = 1;
break;
case PIN_RIGHT:
x1 = pos.x + len; MapX1 = -1;
break;
}
if( Shape & INVERT )
{
plotter->circle( wxPoint( MapX1 * INVERT_PIN_RADIUS + x1,
MapY1 * INVERT_PIN_RADIUS + y1 ),
INVERT_PIN_RADIUS * 2, // diameter
NO_FILL, // fill
-1 ); // width
plotter->move_to( wxPoint( MapX1 * INVERT_PIN_RADIUS * 2 + x1,
MapY1 * INVERT_PIN_RADIUS * 2 + y1 ) );
plotter->finish_to( pos );
}
else
{
plotter->move_to( wxPoint( x1, y1 ) );
plotter->finish_to( pos );
}
if( Shape & CLOCK )
{
if( MapY1 == 0 ) /* MapX1 = +- 1 */
{
plotter->move_to( wxPoint( x1, y1 + CLOCK_PIN_DIM ) );
plotter->line_to( wxPoint( x1 - MapX1 * CLOCK_PIN_DIM, y1 ) );
plotter->finish_to( wxPoint( x1, y1 - CLOCK_PIN_DIM ) );
}
else /* MapX1 = 0 */
{
plotter->move_to( wxPoint( x1 + CLOCK_PIN_DIM, y1 ) );
plotter->line_to( wxPoint( x1, y1 - MapY1 * CLOCK_PIN_DIM ) );
plotter->finish_to( wxPoint( x1 - CLOCK_PIN_DIM, y1 ) );
}
}
if( Shape & LOWLEVEL_IN ) /* IEEE symbol "Active Low Input" */
{
if( MapY1 == 0 ) /* MapX1 = +- 1 */
{
plotter->move_to( wxPoint( x1 + MapX1 * IEEE_SYMBOL_PIN_DIM * 2,
y1 ) );
plotter->line_to( wxPoint( x1 + MapX1 * IEEE_SYMBOL_PIN_DIM * 2,
y1 - IEEE_SYMBOL_PIN_DIM ) );
plotter->finish_to( wxPoint( x1, y1 ) );
}
else /* MapX1 = 0 */
{
plotter->move_to( wxPoint( x1,
y1 + MapY1 * IEEE_SYMBOL_PIN_DIM * 2 ) );
plotter->line_to( wxPoint( x1 - IEEE_SYMBOL_PIN_DIM,
y1 + MapY1 * IEEE_SYMBOL_PIN_DIM * 2 ) );
plotter->finish_to( wxPoint( x1, y1 ) );
}
}
if( Shape & LOWLEVEL_OUT ) /* IEEE symbol "Active Low Output" */
{
if( MapY1 == 0 ) /* MapX1 = +- 1 */
{
plotter->move_to( wxPoint( x1, y1 - IEEE_SYMBOL_PIN_DIM ) );
plotter->finish_to( wxPoint( x1 + MapX1 * IEEE_SYMBOL_PIN_DIM * 2,
y1 ) );
}
else /* MapX1 = 0 */
{
plotter->move_to( wxPoint( x1 - IEEE_SYMBOL_PIN_DIM, y1 ) );
plotter->finish_to( wxPoint( x1,
y1 + MapY1 * IEEE_SYMBOL_PIN_DIM * 2 ) );
}
}
}
static void PlotTextStruct( PLOTTER* plotter, SCH_TEXT* aSchText )
{
static std::vector <wxPoint> Poly;
switch( aSchText->Type() )
{
case SCH_SHEET_PIN_T:
case SCH_GLOBAL_LABEL_T:
case SCH_HIERARCHICAL_LABEL_T:
case SCH_LABEL_T:
case SCH_TEXT_T:
break;
default:
return;
}
EDA_Colors color = UNSPECIFIED_COLOR;
color = ReturnLayerColor( aSchText->GetLayer() );
wxPoint textpos = aSchText->m_Pos + aSchText->GetSchematicTextOffset();
int thickness = aSchText->GetPenSize();
plotter->set_current_line_width( thickness );
if( aSchText->m_MultilineAllowed )
{
wxPoint pos = textpos;
wxArrayString* list = wxStringSplit( aSchText->m_Text, '\n' );
wxPoint offset;
offset.y = aSchText->GetInterline();
RotatePoint( &offset, aSchText->m_Orient );
for( unsigned i = 0; i<list->Count(); i++ )
{
wxString txt = list->Item( i );
plotter->text( pos, color, txt, aSchText->m_Orient,
aSchText->m_Size, aSchText->m_HJustify,
aSchText->m_VJustify, thickness,
aSchText->m_Italic, aSchText->m_Bold );
pos += offset;
}
delete (list);
}
else
plotter->text( textpos, color, aSchText->m_Text, aSchText->m_Orient,
aSchText->m_Size, aSchText->m_HJustify,
aSchText->m_VJustify, thickness, aSchText->m_Italic,
aSchText->m_Bold );
/* Draw graphic symbol for global or hierarchical labels */
aSchText->CreateGraphicShape( Poly, aSchText->m_Pos );
if( Poly.size() )
plotter->PlotPoly( Poly, NO_FILL );
}
static void PlotSheetStruct( PLOTTER* plotter, SCH_SHEET* Struct )
{
EDA_Colors txtcolor = UNSPECIFIED_COLOR;
wxSize size;
wxString Text;
int name_orientation;
wxPoint pos_sheetname, pos_filename;
wxPoint pos;
plotter->set_color( ReturnLayerColor( Struct->GetLayer() ) );
int thickness = Struct->GetPenSize();
plotter->set_current_line_width( thickness );
plotter->move_to( Struct->m_Pos );
pos = Struct->m_Pos; pos.x += Struct->m_Size.x;
plotter->line_to( pos );
pos.y += Struct->m_Size.y;
plotter->line_to( pos );
pos = Struct->m_Pos; pos.y += Struct->m_Size.y;
plotter->line_to( pos );
plotter->finish_to( Struct->m_Pos );
if( Struct->IsVerticalOrientation() )
{
pos_sheetname = wxPoint( Struct->m_Pos.x - 8, Struct->m_Pos.y + Struct->m_Size.y );
pos_filename = wxPoint( Struct->m_Pos.x + Struct->m_Size.x + 4,
Struct->m_Pos.y + Struct->m_Size.y );
name_orientation = TEXT_ORIENT_VERT;
}
else
{
pos_sheetname = wxPoint( Struct->m_Pos.x, Struct->m_Pos.y - 4 );
pos_filename = wxPoint( Struct->m_Pos.x, Struct->m_Pos.y + Struct->m_Size.y + 4 );
name_orientation = TEXT_ORIENT_HORIZ;
}
/* Draw texts: SheetName */
Text = Struct->m_SheetName;
size = wxSize( Struct->m_SheetNameSize, Struct->m_SheetNameSize );
//pos = Struct->m_Pos; pos.y -= 4;
thickness = g_DrawDefaultLineThickness;
thickness = Clamp_Text_PenSize( thickness, size, false );
plotter->set_color( ReturnLayerColor( LAYER_SHEETNAME ) );
bool italic = false;
plotter->text( pos_sheetname, txtcolor,
Text, name_orientation, size,
GR_TEXT_HJUSTIFY_LEFT, GR_TEXT_VJUSTIFY_BOTTOM,
thickness, italic, false );
/*Draw texts : FileName */
Text = Struct->GetFileName();
size = wxSize( Struct->m_FileNameSize, Struct->m_FileNameSize );
thickness = g_DrawDefaultLineThickness;
thickness = Clamp_Text_PenSize( thickness, size, false );
plotter->set_color( ReturnLayerColor( LAYER_SHEETFILENAME ) );
plotter->text( pos_filename, txtcolor,
Text, name_orientation, size,
GR_TEXT_HJUSTIFY_LEFT, GR_TEXT_VJUSTIFY_TOP,
thickness, italic, false );
plotter->set_color( ReturnLayerColor( Struct->GetLayer() ) );
/* Draw texts : SheetLabel */
BOOST_FOREACH( SCH_SHEET_PIN& pin_sheet, Struct->GetPins() )
{
//pin_sheet.Plot( plotter );
PlotTextStruct( plotter, &pin_sheet );
}
}
void PlotDrawlist( PLOTTER* plotter, SCH_ITEM* aDrawlist )
{
while( aDrawlist ) /* Plot each item in draw list */
{
SCH_COMPONENT* DrawLibItem;
int layer;
wxPoint StartPos, EndPos;
plotter->set_current_line_width( aDrawlist->GetPenSize() );
switch( aDrawlist->Type() )
{
case SCH_BUS_ENTRY_T:
case SCH_LINE_T:
if( aDrawlist->Type() == SCH_BUS_ENTRY_T )
{
#undef STRUCT
#define STRUCT ( (SCH_BUS_ENTRY*) aDrawlist )
StartPos = STRUCT->m_Pos;
EndPos = STRUCT->m_End();
layer = STRUCT->GetLayer();
plotter->set_color( ReturnLayerColor( layer ) );
}
else
{
#undef STRUCT
#define STRUCT ( (SCH_LINE*) aDrawlist )
StartPos = STRUCT->m_Start;
EndPos = STRUCT->m_End;
layer = STRUCT->GetLayer();
plotter->set_color( ReturnLayerColor( layer ) );
}
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 SCH_JUNCTION_T:
#undef STRUCT
#define STRUCT ( (SCH_JUNCTION*) aDrawlist )
plotter->set_color( ReturnLayerColor( STRUCT->GetLayer() ) );
plotter->circle( STRUCT->m_Pos, STRUCT->m_Size.x, FILLED_SHAPE );
break;
case SCH_TEXT_T:
case SCH_LABEL_T:
case SCH_GLOBAL_LABEL_T:
case SCH_HIERARCHICAL_LABEL_T:
PlotTextStruct( plotter, (SCH_TEXT*) aDrawlist );
break;
case SCH_COMPONENT_T:
DrawLibItem = (SCH_COMPONENT*) aDrawlist;
PlotLibPart( plotter, DrawLibItem );
break;
case SCH_POLYLINE_T:
break;
case SCH_SHEET_PIN_T:
break;
case SCH_MARKER_T:
break;
case SCH_SHEET_T:
PlotSheetStruct( plotter, (SCH_SHEET*) aDrawlist );
break;
case SCH_NO_CONNECT_T:
plotter->set_color( ReturnLayerColor( LAYER_NOCONNECT ) );
PlotNoConnectStruct( plotter, (SCH_NO_CONNECT*) aDrawlist );
break;
default:
break;
}
aDrawlist = aDrawlist->Next();
}
}
...@@ -76,12 +76,6 @@ EDA_Colors ReturnLayerColor( int Layer ); ...@@ -76,12 +76,6 @@ EDA_Colors ReturnLayerColor( int Layer );
int IsBusLabel( const wxString& LabelDrawList ); int IsBusLabel( const wxString& LabelDrawList );
/************/
/* PLOT.CPP */
/************/
void PlotDrawlist( PLOTTER* plotter, SCH_ITEM* drawlist );
/***************/ /***************/
/* PINEDIT.CPP */ /* PINEDIT.CPP */
/***************/ /***************/
......
...@@ -9,6 +9,7 @@ ...@@ -9,6 +9,7 @@
#include "trigo.h" #include "trigo.h"
#include "common.h" #include "common.h"
#include "richio.h" #include "richio.h"
#include "plot_common.h"
#include "general.h" #include "general.h"
#include "protos.h" #include "protos.h"
...@@ -250,3 +251,12 @@ bool SCH_BUS_ENTRY::doHitTest( const EDA_RECT& aRect, bool aContained, int aAccu ...@@ -250,3 +251,12 @@ bool SCH_BUS_ENTRY::doHitTest( const EDA_RECT& aRect, bool aContained, int aAccu
return rect.Intersects( GetBoundingBox() ); return rect.Intersects( GetBoundingBox() );
} }
void SCH_BUS_ENTRY::doPlot( PLOTTER* aPlotter )
{
aPlotter->set_current_line_width( GetPenSize() );
aPlotter->set_color( ReturnLayerColor( GetLayer() ) );
aPlotter->move_to( m_Pos );
aPlotter->finish_to( m_End() );
}
...@@ -115,6 +115,7 @@ private: ...@@ -115,6 +115,7 @@ private:
virtual bool doHitTest( const wxPoint& aPoint, int aAccuracy ) const; virtual bool doHitTest( const wxPoint& aPoint, int aAccuracy ) const;
virtual bool doHitTest( const EDA_RECT& aRect, bool aContained, int aAccuracy ) const; virtual bool doHitTest( const EDA_RECT& aRect, bool aContained, int aAccuracy ) const;
virtual EDA_ITEM* doClone() const; virtual EDA_ITEM* doClone() const;
virtual void doPlot( PLOTTER* aPlotter );
}; };
......
...@@ -11,6 +11,7 @@ ...@@ -11,6 +11,7 @@
#include "kicad_string.h" #include "kicad_string.h"
#include "richio.h" #include "richio.h"
#include "wxEeschemaStruct.h" #include "wxEeschemaStruct.h"
#include "plot_common.h"
#include "general.h" #include "general.h"
#include "class_library.h" #include "class_library.h"
...@@ -225,6 +226,18 @@ void SCH_COMPONENT::SetTransform( const TRANSFORM& aTransform ) ...@@ -225,6 +226,18 @@ void SCH_COMPONENT::SetTransform( const TRANSFORM& aTransform )
} }
int SCH_COMPONENT::GetPartCount() const
{
LIB_COMPONENT* Entry = CMP_LIBRARY::FindLibraryComponent( m_ChipName );
if( Entry == NULL )
return 0;
return Entry->GetPartCount();
}
void SCH_COMPONENT::Draw( EDA_DRAW_PANEL* panel, wxDC* DC, const wxPoint& offset, void SCH_COMPONENT::Draw( EDA_DRAW_PANEL* panel, wxDC* DC, const wxPoint& offset,
int DrawMode, int Color, bool DrawPinText ) int DrawMode, int Color, bool DrawPinText )
{ {
...@@ -1778,3 +1791,24 @@ bool SCH_COMPONENT::doIsConnected( const wxPoint& aPosition ) const ...@@ -1778,3 +1791,24 @@ bool SCH_COMPONENT::doIsConnected( const wxPoint& aPosition ) const
return false; return false;
} }
void SCH_COMPONENT::doPlot( PLOTTER* aPlotter )
{
LIB_COMPONENT* Entry;
TRANSFORM temp = TRANSFORM();
Entry = CMP_LIBRARY::FindLibraryComponent( GetLibName() );
if( Entry == NULL )
return;
temp = GetTransform();
Entry->Plot( aPlotter, GetUnit(), GetConvert(), m_Pos, temp );
for( size_t i = 0; i < m_Fields.size(); i++ )
{
m_Fields[i].Plot( aPlotter );
}
}
...@@ -113,6 +113,14 @@ public: ...@@ -113,6 +113,14 @@ public:
void SetTransform( const TRANSFORM& aTransform ); void SetTransform( const TRANSFORM& aTransform );
/**
* Function GetPartCount
* returns the number of parts per package of the component.
*
* @return The number of parts per package or zero if the library entry cannot be found.
*/
int GetPartCount() const;
/** /**
* Function Save * Function Save
* writes the data structures for this object out to a FILE in "*.sch" format. * writes the data structures for this object out to a FILE in "*.sch" format.
...@@ -395,6 +403,7 @@ private: ...@@ -395,6 +403,7 @@ private:
virtual bool doHitTest( const EDA_RECT& aRect, bool aContained, int aAccuracy ) const; virtual bool doHitTest( const EDA_RECT& aRect, bool aContained, int aAccuracy ) const;
virtual bool doIsConnected( const wxPoint& aPosition ) const; virtual bool doIsConnected( const wxPoint& aPosition ) const;
virtual EDA_ITEM* doClone() const; virtual EDA_ITEM* doClone() const;
virtual void doPlot( PLOTTER* aPlotter );
}; };
......
...@@ -20,6 +20,7 @@ ...@@ -20,6 +20,7 @@
#include "trigo.h" #include "trigo.h"
#include "class_sch_screen.h" #include "class_sch_screen.h"
#include "wxEeschemaStruct.h" #include "wxEeschemaStruct.h"
#include "plot_common.h"
#include "general.h" #include "general.h"
#include "protos.h" #include "protos.h"
...@@ -501,3 +502,75 @@ bool SCH_FIELD::doHitTest( const EDA_RECT& aRect, bool aContained, int aAccuracy ...@@ -501,3 +502,75 @@ bool SCH_FIELD::doHitTest( const EDA_RECT& aRect, bool aContained, int aAccuracy
return rect.Intersects( GetBoundingBox() ); return rect.Intersects( GetBoundingBox() );
} }
/* Plot field text.
* Input:
* DrawLibItem: pointer to the component
* FieldNumber: Number Field
* IsMulti: true flag if there are several parts per package.
* Only useful for the field to add a reference to this one
* The identification from (A, B ...)
* DrawMode: trace mode
*/
void SCH_FIELD::doPlot( PLOTTER* aPlotter )
{
SCH_COMPONENT* parent = ( SCH_COMPONENT* ) GetParent();
wxCHECK_RET( parent != NULL && parent->Type() == SCH_COMPONENT_T,
wxT( "Cannot plot field with invalid parent." ) );
EDA_Colors color = UNSPECIFIED_COLOR;
color = ReturnLayerColor( GetLayer() );
if( m_Attributs & TEXT_NO_VISIBLE )
return;
if( IsVoid() )
return;
/* Calculate the text orientation, according to the component
* orientation/mirror */
int orient = m_Orient;
if( parent->GetTransform().y1 ) // Rotate component 90 deg.
{
if( orient == TEXT_ORIENT_HORIZ )
orient = TEXT_ORIENT_VERT;
else
orient = TEXT_ORIENT_HORIZ;
}
/* Calculate the text justification, according to the component
* orientation/mirror
* this is a bit complicated due to cumulative calculations:
* - numerous cases (mirrored or not, rotation)
* - the DrawGraphicText function recalculate also H and H justifications
* according to the text orientation.
* - When a component is mirrored, the text is not mirrored and
* justifications are complicated to calculate
* so the more easily way is to use no justifications ( Centered text )
* and use GetBoundaryBox to know the text coordinate considered as centered
*/
EDA_RECT BoundaryBox = GetBoundingBox();
GRTextHorizJustifyType hjustify = GR_TEXT_HJUSTIFY_CENTER;
GRTextVertJustifyType vjustify = GR_TEXT_VJUSTIFY_CENTER;
wxPoint textpos = BoundaryBox.Centre();
int thickness = GetPenSize();
if( (parent->GetPartCount() <= 1) || (m_FieldId != REFERENCE) )
{
aPlotter->text( textpos, color, m_Text, orient, m_Size, hjustify, vjustify,
thickness, m_Italic, m_Bold );
}
else /* We plot the reference, for a multiple parts per package */
{
/* Adding A, B ... to the reference */
wxString Text = m_Text + LIB_COMPONENT::ReturnSubReference( parent->GetUnit() );
aPlotter->text( textpos, color, Text, orient, m_Size, hjustify, vjustify,
thickness, m_Italic, m_Bold );
}
}
...@@ -52,7 +52,7 @@ public: ...@@ -52,7 +52,7 @@ public:
/** /**
* Function GetName * Function GetName
* returns the field name. If the field name is emply, the default field name is * returns the field name. If the field name is empty, the default field name is
* returned. Field names are VALUE, REFERENCE, etc. * returned. Field names are VALUE, REFERENCE, etc.
* @return The name of the field. * @return The name of the field.
*/ */
...@@ -165,7 +165,7 @@ public: ...@@ -165,7 +165,7 @@ public:
* @param aSearchData - Criteria to search against. * @param aSearchData - Criteria to search against.
* @param aAuxData - a pointer on auxiliary data, if needed. * @param aAuxData - a pointer on auxiliary data, if needed.
* the sheet path is needed for REFERENCE field because m_Text * the sheet path is needed for REFERENCE field because m_Text
* value is just the valeur displayed, and in complex hierarchies * value is just the value displayed, and in complex hierarchies
* this is only one of all references (one per sheet path) * this is only one of all references (one per sheet path)
* @param aFindLocation - a wxPoint where to put the location of matched item. can be NULL. * @param aFindLocation - a wxPoint where to put the location of matched item. can be NULL.
* @return True if this field text matches the search criteria. * @return True if this field text matches the search criteria.
...@@ -181,6 +181,7 @@ private: ...@@ -181,6 +181,7 @@ private:
virtual bool doHitTest( const wxPoint& aPoint, int aAccuracy ) const; virtual bool doHitTest( const wxPoint& aPoint, int aAccuracy ) const;
virtual bool doHitTest( const EDA_RECT& aRect, bool aContained, int aAccuracy ) const; virtual bool doHitTest( const EDA_RECT& aRect, bool aContained, int aAccuracy ) const;
virtual EDA_ITEM* doClone() const; virtual EDA_ITEM* doClone() const;
virtual void doPlot( PLOTTER* aPlotter );
}; };
......
/*****************************/ /********************/
/* class_schematic_items.cpp */ /* sch_junction.cpp */
/*****************************/ /********************/
#include "fctsys.h" #include "fctsys.h"
#include "gr_basic.h" #include "gr_basic.h"
...@@ -9,6 +9,7 @@ ...@@ -9,6 +9,7 @@
#include "trigo.h" #include "trigo.h"
#include "common.h" #include "common.h"
#include "richio.h" #include "richio.h"
#include "plot_common.h"
#include "general.h" #include "general.h"
#include "protos.h" #include "protos.h"
...@@ -204,3 +205,10 @@ bool SCH_JUNCTION::doIsConnected( const wxPoint& aPosition ) const ...@@ -204,3 +205,10 @@ bool SCH_JUNCTION::doIsConnected( const wxPoint& aPosition ) const
{ {
return m_Pos == aPosition; return m_Pos == aPosition;
} }
void SCH_JUNCTION::doPlot( PLOTTER* aPlotter )
{
aPlotter->set_color( ReturnLayerColor( GetLayer() ) );
aPlotter->circle( m_Pos, m_Size.x, FILLED_SHAPE );
}
...@@ -104,6 +104,7 @@ private: ...@@ -104,6 +104,7 @@ private:
virtual bool doHitTest( const EDA_RECT& aRect, bool aContained, int aAccuracy ) const; virtual bool doHitTest( const EDA_RECT& aRect, bool aContained, int aAccuracy ) const;
virtual bool doIsConnected( const wxPoint& aPosition ) const; virtual bool doIsConnected( const wxPoint& aPosition ) const;
virtual EDA_ITEM* doClone() const; virtual EDA_ITEM* doClone() const;
virtual void doPlot( PLOTTER* aPlotter );
}; };
......
...@@ -8,6 +8,7 @@ ...@@ -8,6 +8,7 @@
#include "class_drawpanel.h" #include "class_drawpanel.h"
#include "trigo.h" #include "trigo.h"
#include "richio.h" #include "richio.h"
#include "plot_common.h"
#include "general.h" #include "general.h"
#include "protos.h" #include "protos.h"
...@@ -440,7 +441,7 @@ wxString SCH_LINE::GetSelectMenuText() const ...@@ -440,7 +441,7 @@ wxString SCH_LINE::GetSelectMenuText() const
break; break;
default: default:
txtfmt += _( "%s Line on Unkown Layer from (%s,%s) to (%s,%s)" ); txtfmt += _( "%s Line on Unknown Layer from (%s,%s) to (%s,%s)" );
} }
menuText.Printf( txtfmt, GetChars( orient ), menuText.Printf( txtfmt, GetChars( orient ),
...@@ -510,3 +511,19 @@ bool SCH_LINE::doIsConnected( const wxPoint& aPosition ) const ...@@ -510,3 +511,19 @@ bool SCH_LINE::doIsConnected( const wxPoint& aPosition ) const
return IsEndPoint( aPosition ); return IsEndPoint( aPosition );
} }
void SCH_LINE::doPlot( PLOTTER* aPlotter )
{
aPlotter->set_color( ReturnLayerColor( GetLayer() ) );
aPlotter->set_current_line_width( GetPenSize() );
if( m_Layer == LAYER_NOTES )
aPlotter->set_dash( true );
aPlotter->move_to( m_Start );
aPlotter->finish_to( m_End );
if( m_Layer == LAYER_NOTES )
aPlotter->set_dash( false );
}
...@@ -109,7 +109,7 @@ public: ...@@ -109,7 +109,7 @@ public:
* Check line against \a aLine to see if it overlaps and merge if it does. * Check line against \a aLine to see if it overlaps and merge if it does.
* *
* This method will change the line to be equivalent of the line and \a aLine if the * This method will change the line to be equivalent of the line and \a aLine if the
* two lines overlap. This method is used to merge multple line segments into a single * two lines overlap. This method is used to merge multiple line segments into a single
* line. * line.
* *
* @param aLine - Line to compare. * @param aLine - Line to compare.
...@@ -148,6 +148,7 @@ private: ...@@ -148,6 +148,7 @@ private:
virtual bool doHitTest( const EDA_RECT& aRect, bool aContained, int aAccuracy ) const; virtual bool doHitTest( const EDA_RECT& aRect, bool aContained, int aAccuracy ) const;
virtual bool doIsConnected( const wxPoint& aPosition ) const; virtual bool doIsConnected( const wxPoint& aPosition ) const;
virtual EDA_ITEM* doClone() const; virtual EDA_ITEM* doClone() const;
virtual void doPlot( PLOTTER* aPlotter );
}; };
......
...@@ -9,6 +9,7 @@ ...@@ -9,6 +9,7 @@
#include "common.h" #include "common.h"
#include "trigo.h" #include "trigo.h"
#include "richio.h" #include "richio.h"
#include "plot_common.h"
#include "general.h" #include "general.h"
#include "protos.h" #include "protos.h"
...@@ -22,6 +23,8 @@ SCH_NO_CONNECT::SCH_NO_CONNECT( const wxPoint& pos ) : ...@@ -22,6 +23,8 @@ SCH_NO_CONNECT::SCH_NO_CONNECT( const wxPoint& pos ) :
m_Pos = pos; m_Pos = pos;
m_Size.x = m_Size.y = DRAWNOCONNECT_SIZE; m_Size.x = m_Size.y = DRAWNOCONNECT_SIZE;
#undef DRAWNOCONNECT_SIZE #undef DRAWNOCONNECT_SIZE
SetLayer( LAYER_NOCONNECT );
} }
...@@ -181,3 +184,20 @@ bool SCH_NO_CONNECT::doHitTest( const EDA_RECT& aRect, bool aContained, int aAcc ...@@ -181,3 +184,20 @@ bool SCH_NO_CONNECT::doHitTest( const EDA_RECT& aRect, bool aContained, int aAcc
return rect.Intersects( GetBoundingBox() ); return rect.Intersects( GetBoundingBox() );
} }
void SCH_NO_CONNECT::doPlot( PLOTTER* aPlotter )
{
int delta = m_Size.x / 2;
int pX, pY;
pX = m_Pos.x;
pY = m_Pos.y;
aPlotter->set_current_line_width( GetPenSize() );
aPlotter->set_color( ReturnLayerColor( GetLayer() ) );
aPlotter->move_to( wxPoint( pX - delta, pY - delta ) );
aPlotter->finish_to( wxPoint( pX + delta, pY + delta ) );
aPlotter->move_to( wxPoint( pX + delta, pY - delta ) );
aPlotter->finish_to( wxPoint( pX - delta, pY + delta ) );
}
...@@ -103,6 +103,7 @@ private: ...@@ -103,6 +103,7 @@ private:
virtual bool doHitTest( const wxPoint& aPoint, int aAccuracy ) const; virtual bool doHitTest( const wxPoint& aPoint, int aAccuracy ) const;
virtual bool doHitTest( const EDA_RECT& aRect, bool aContained, int aAccuracy ) const; virtual bool doHitTest( const EDA_RECT& aRect, bool aContained, int aAccuracy ) const;
virtual EDA_ITEM* doClone() const; virtual EDA_ITEM* doClone() const;
virtual void doPlot( PLOTTER* aPlotter );
}; };
......
...@@ -9,6 +9,7 @@ ...@@ -9,6 +9,7 @@
#include "sch_item_struct.h" #include "sch_item_struct.h"
#include "class_sch_screen.h" #include "class_sch_screen.h"
#include "wxEeschemaStruct.h" #include "wxEeschemaStruct.h"
#include "plot_common.h"
#include "general.h" #include "general.h"
#include "protos.h" #include "protos.h"
...@@ -582,6 +583,16 @@ void SCH_SCREEN::Draw( EDA_DRAW_PANEL* aCanvas, wxDC* aDC, int aDrawMode, int aC ...@@ -582,6 +583,16 @@ void SCH_SCREEN::Draw( EDA_DRAW_PANEL* aCanvas, wxDC* aDC, int aDrawMode, int aC
} }
void SCH_SCREEN::Plot( PLOTTER* aPlotter )
{
for( SCH_ITEM* item = GetDrawItems(); item != NULL; item = item->Next() )
{
aPlotter->set_current_line_width( item->GetPenSize() );
item->Plot( aPlotter );
}
}
void SCH_SCREEN::ClearUndoORRedoList( UNDO_REDO_CONTAINER& aList, int aItemCount ) void SCH_SCREEN::ClearUndoORRedoList( UNDO_REDO_CONTAINER& aList, int aItemCount )
{ {
if( aItemCount == 0 ) if( aItemCount == 0 )
......
...@@ -20,6 +20,7 @@ ...@@ -20,6 +20,7 @@
#include "richio.h" #include "richio.h"
#include "class_sch_screen.h" #include "class_sch_screen.h"
#include "wxEeschemaStruct.h" #include "wxEeschemaStruct.h"
#include "plot_common.h"
#include "general.h" #include "general.h"
#include "protos.h" #include "protos.h"
...@@ -28,6 +29,7 @@ ...@@ -28,6 +29,7 @@
#include "sch_component.h" #include "sch_component.h"
#include "kicad_string.h" #include "kicad_string.h"
SCH_SHEET::SCH_SHEET( const wxPoint& pos ) : SCH_SHEET::SCH_SHEET( const wxPoint& pos ) :
SCH_ITEM( NULL, SCH_SHEET_T ) SCH_ITEM( NULL, SCH_SHEET_T )
{ {
...@@ -366,7 +368,7 @@ bool SCH_SHEET::HasPin( const wxString& aName ) ...@@ -366,7 +368,7 @@ bool SCH_SHEET::HasPin( const wxString& aName )
} }
bool SCH_SHEET::IsVerticalOrientation() bool SCH_SHEET::IsVerticalOrientation() const
{ {
BOOST_FOREACH( SCH_SHEET_PIN pin, m_pins ) BOOST_FOREACH( SCH_SHEET_PIN pin, m_pins )
{ {
...@@ -827,7 +829,7 @@ int SCH_SHEET::CountSheets() ...@@ -827,7 +829,7 @@ int SCH_SHEET::CountSheets()
} }
wxString SCH_SHEET::GetFileName( void ) wxString SCH_SHEET::GetFileName( void ) const
{ {
return m_FileName; return m_FileName;
} }
...@@ -1076,6 +1078,83 @@ wxPoint SCH_SHEET::GetResizePosition() const ...@@ -1076,6 +1078,83 @@ wxPoint SCH_SHEET::GetResizePosition() const
} }
void SCH_SHEET::doPlot( PLOTTER* aPlotter )
{
EDA_Colors txtcolor = UNSPECIFIED_COLOR;
wxSize size;
wxString Text;
int name_orientation;
wxPoint pos_sheetname, pos_filename;
wxPoint pos;
aPlotter->set_color( ReturnLayerColor( GetLayer() ) );
int thickness = GetPenSize();
aPlotter->set_current_line_width( thickness );
aPlotter->move_to( m_Pos );
pos = m_Pos;
pos.x += m_Size.x;
aPlotter->line_to( pos );
pos.y += m_Size.y;
aPlotter->line_to( pos );
pos = m_Pos;
pos.y += m_Size.y;
aPlotter->line_to( pos );
aPlotter->finish_to( m_Pos );
if( IsVerticalOrientation() )
{
pos_sheetname = wxPoint( m_Pos.x - 8, m_Pos.y + m_Size.y );
pos_filename = wxPoint( m_Pos.x + m_Size.x + 4, m_Pos.y + m_Size.y );
name_orientation = TEXT_ORIENT_VERT;
}
else
{
pos_sheetname = wxPoint( m_Pos.x, m_Pos.y - 4 );
pos_filename = wxPoint( m_Pos.x, m_Pos.y + m_Size.y + 4 );
name_orientation = TEXT_ORIENT_HORIZ;
}
/* Draw texts: SheetName */
Text = m_SheetName;
size = wxSize( m_SheetNameSize, m_SheetNameSize );
//pos = m_Pos; pos.y -= 4;
thickness = g_DrawDefaultLineThickness;
thickness = Clamp_Text_PenSize( thickness, size, false );
aPlotter->set_color( ReturnLayerColor( LAYER_SHEETNAME ) );
bool italic = false;
aPlotter->text( pos_sheetname, txtcolor, Text, name_orientation, size,
GR_TEXT_HJUSTIFY_LEFT, GR_TEXT_VJUSTIFY_BOTTOM,
thickness, italic, false );
/*Draw texts : FileName */
Text = GetFileName();
size = wxSize( m_FileNameSize, m_FileNameSize );
thickness = g_DrawDefaultLineThickness;
thickness = Clamp_Text_PenSize( thickness, size, false );
aPlotter->set_color( ReturnLayerColor( LAYER_SHEETFILENAME ) );
aPlotter->text( pos_filename, txtcolor, Text, name_orientation, size,
GR_TEXT_HJUSTIFY_LEFT, GR_TEXT_VJUSTIFY_TOP,
thickness, italic, false );
aPlotter->set_color( ReturnLayerColor( GetLayer() ) );
/* Draw texts : SheetLabel */
for( size_t i = 0; i < m_pins.size(); i++ )
{
m_pins[i].Plot( aPlotter );
}
}
#if defined(DEBUG) #if defined(DEBUG)
void SCH_SHEET::Show( int nestLevel, std::ostream& os ) void SCH_SHEET::Show( int nestLevel, std::ostream& os )
......
...@@ -80,10 +80,10 @@ public: ...@@ -80,10 +80,10 @@ public:
/** /**
* Function CreateGraphicShape (virtual) * Function CreateGraphicShape (virtual)
* Calculates the graphic shape (a polygon) associated to the text * Calculates the graphic shape (a polygon) associated to the text
* @param aCorner_list = a buffer to fill with polygon corners coordinates * @param aPoints = a buffer to fill with polygon corners coordinates
* @param aPos = Position of the shape * @param aPos = Position of the shape
*/ */
virtual void CreateGraphicShape( std::vector <wxPoint>& aCorner_list, const wxPoint& aPos ); virtual void CreateGraphicShape( std::vector <wxPoint>& aPoints, const wxPoint& aPos );
virtual void SwapData( SCH_ITEM* aItem ); virtual void SwapData( SCH_ITEM* aItem );
...@@ -289,7 +289,7 @@ public: ...@@ -289,7 +289,7 @@ public:
/* there is no member for orientation in sch_sheet, to preserve file /* there is no member for orientation in sch_sheet, to preserve file
* format, we detect orientation based on pin edges * format, we detect orientation based on pin edges
*/ */
bool IsVerticalOrientation(); bool IsVerticalOrientation() const;
/** /**
* Add aSheetPin to the sheet. * Add aSheetPin to the sheet.
...@@ -475,7 +475,7 @@ public: ...@@ -475,7 +475,7 @@ public:
* return the filename corresponding to this sheet * return the filename corresponding to this sheet
* @return a wxString containing the filename * @return a wxString containing the filename
*/ */
wxString GetFileName( void ); wxString GetFileName( void ) const;
// Set a new filename without changing anything else // Set a new filename without changing anything else
void SetFileName( const wxString& aFilename ) void SetFileName( const wxString& aFilename )
...@@ -589,6 +589,7 @@ private: ...@@ -589,6 +589,7 @@ private:
virtual bool doHitTest( const wxPoint& aPoint, int aAccuracy ) const; virtual bool doHitTest( const wxPoint& aPoint, int aAccuracy ) const;
virtual bool doHitTest( const EDA_RECT& aRect, bool aContained, int aAccuracy ) const; virtual bool doHitTest( const EDA_RECT& aRect, bool aContained, int aAccuracy ) const;
virtual EDA_ITEM* doClone() const; virtual EDA_ITEM* doClone() const;
virtual void doPlot( PLOTTER* aPlotter );
}; };
......
...@@ -460,8 +460,7 @@ void SCH_SHEET_PIN::Rotate( wxPoint rotationPoint ) ...@@ -460,8 +460,7 @@ void SCH_SHEET_PIN::Rotate( wxPoint rotationPoint )
} }
void SCH_SHEET_PIN::CreateGraphicShape( std::vector <wxPoint>& aCorner_list, void SCH_SHEET_PIN::CreateGraphicShape( std::vector <wxPoint>& aPoints, const wxPoint& aPos )
const wxPoint& aPos )
{ {
/* This is the same icon shapes as SCH_HIERLABEL /* This is the same icon shapes as SCH_HIERLABEL
* but the graphic icon is slightly different in 2 cases: * but the graphic icon is slightly different in 2 cases:
...@@ -484,7 +483,7 @@ void SCH_SHEET_PIN::CreateGraphicShape( std::vector <wxPoint>& aCorner_list, ...@@ -484,7 +483,7 @@ void SCH_SHEET_PIN::CreateGraphicShape( std::vector <wxPoint>& aCorner_list,
break; break;
} }
SCH_HIERLABEL::CreateGraphicShape( aCorner_list, aPos ); SCH_HIERLABEL::CreateGraphicShape( aPoints, aPos );
m_Shape = tmp; m_Shape = tmp;
} }
......
...@@ -11,6 +11,7 @@ ...@@ -11,6 +11,7 @@
#include "class_drawpanel.h" #include "class_drawpanel.h"
#include "drawtxt.h" #include "drawtxt.h"
#include "wxEeschemaStruct.h" #include "wxEeschemaStruct.h"
#include "plot_common.h"
#include "general.h" #include "general.h"
#include "protos.h" #include "protos.h"
...@@ -112,7 +113,7 @@ void SCH_TEXT::IncrementLabel() ...@@ -112,7 +113,7 @@ void SCH_TEXT::IncrementLabel()
} }
wxPoint SCH_TEXT::GetSchematicTextOffset() wxPoint SCH_TEXT::GetSchematicTextOffset() const
{ {
wxPoint text_offset; wxPoint text_offset;
...@@ -650,6 +651,52 @@ bool SCH_TEXT::doHitTest( const EDA_RECT& aRect, bool aContained, int aAccuracy ...@@ -650,6 +651,52 @@ bool SCH_TEXT::doHitTest( const EDA_RECT& aRect, bool aContained, int aAccuracy
} }
void SCH_TEXT::doPlot( PLOTTER* aPlotter )
{
static std::vector <wxPoint> Poly;
EDA_Colors color = ReturnLayerColor( GetLayer() );
wxPoint textpos = m_Pos + GetSchematicTextOffset();
int thickness = GetPenSize();
aPlotter->set_current_line_width( thickness );
if( m_MultilineAllowed )
{
wxPoint pos = textpos;
wxArrayString* list = wxStringSplit( m_Text, '\n' );
wxPoint offset;
offset.y = GetInterline();
RotatePoint( &offset, m_Orient );
for( unsigned i = 0; i<list->Count(); i++ )
{
wxString txt = list->Item( i );
aPlotter->text( pos, color, txt, m_Orient, m_Size, m_HJustify,
m_VJustify, thickness, m_Italic, m_Bold );
pos += offset;
}
delete (list);
}
else
{
aPlotter->text( textpos, color, m_Text, m_Orient, m_Size, m_HJustify,
m_VJustify, thickness, m_Italic, m_Bold );
}
/* Draw graphic symbol for global or hierarchical labels */
CreateGraphicShape( Poly, m_Pos );
aPlotter->set_current_line_width( GetPenSize() );
if( Poly.size() )
aPlotter->PlotPoly( Poly, NO_FILL );
}
#if defined(DEBUG) #if defined(DEBUG)
void SCH_TEXT::Show( int nestLevel, std::ostream& os ) void SCH_TEXT::Show( int nestLevel, std::ostream& os )
...@@ -691,7 +738,7 @@ EDA_ITEM* SCH_LABEL::doClone() const ...@@ -691,7 +738,7 @@ EDA_ITEM* SCH_LABEL::doClone() const
} }
wxPoint SCH_LABEL::GetSchematicTextOffset() wxPoint SCH_LABEL::GetSchematicTextOffset() const
{ {
return SCH_TEXT::GetSchematicTextOffset(); return SCH_TEXT::GetSchematicTextOffset();
} }
...@@ -1037,7 +1084,7 @@ void SCH_GLOBALLABEL::Rotate( wxPoint rotationPoint ) ...@@ -1037,7 +1084,7 @@ void SCH_GLOBALLABEL::Rotate( wxPoint rotationPoint )
} }
wxPoint SCH_GLOBALLABEL::GetSchematicTextOffset() wxPoint SCH_GLOBALLABEL::GetSchematicTextOffset() const
{ {
wxPoint text_offset; wxPoint text_offset;
int width = (m_Thickness == 0) ? g_DrawDefaultLineThickness : m_Thickness; int width = (m_Thickness == 0) ? g_DrawDefaultLineThickness : m_Thickness;
...@@ -1159,15 +1206,14 @@ void SCH_GLOBALLABEL::Draw( EDA_DRAW_PANEL* panel, ...@@ -1159,15 +1206,14 @@ void SCH_GLOBALLABEL::Draw( EDA_DRAW_PANEL* panel,
} }
void SCH_GLOBALLABEL::CreateGraphicShape( std::vector <wxPoint>& aCorner_list, void SCH_GLOBALLABEL::CreateGraphicShape( std::vector <wxPoint>& aPoints, const wxPoint& Pos )
const wxPoint& Pos )
{ {
int HalfSize = m_Size.y / 2; int HalfSize = m_Size.y / 2;
int linewidth = (m_Thickness == 0) ? g_DrawDefaultLineThickness : m_Thickness; int linewidth = (m_Thickness == 0) ? g_DrawDefaultLineThickness : m_Thickness;
linewidth = Clamp_Text_PenSize( linewidth, m_Size, m_Bold ); linewidth = Clamp_Text_PenSize( linewidth, m_Size, m_Bold );
aCorner_list.clear(); aPoints.clear();
int symb_len = LenSize( m_Text ) + ( TXTMARGE * 2 ); int symb_len = LenSize( m_Text ) + ( TXTMARGE * 2 );
...@@ -1178,12 +1224,12 @@ void SCH_GLOBALLABEL::CreateGraphicShape( std::vector <wxPoint>& aCorner_list, ...@@ -1178,12 +1224,12 @@ void SCH_GLOBALLABEL::CreateGraphicShape( std::vector <wxPoint>& aCorner_list,
int y = wxRound( (double) HalfSize * 1.5 + (double) linewidth + 3.0 ); int y = wxRound( (double) HalfSize * 1.5 + (double) linewidth + 3.0 );
// Starting point(anchor) // Starting point(anchor)
aCorner_list.push_back( wxPoint( 0, 0 ) ); aPoints.push_back( wxPoint( 0, 0 ) );
aCorner_list.push_back( wxPoint( 0, -y ) ); // Up aPoints.push_back( wxPoint( 0, -y ) ); // Up
aCorner_list.push_back( wxPoint( -x, -y ) ); // left aPoints.push_back( wxPoint( -x, -y ) ); // left
aCorner_list.push_back( wxPoint( -x, 0 ) ); // Up left aPoints.push_back( wxPoint( -x, 0 ) ); // Up left
aCorner_list.push_back( wxPoint( -x, y ) ); // left down aPoints.push_back( wxPoint( -x, y ) ); // left down
aCorner_list.push_back( wxPoint( 0, y ) ); // down aPoints.push_back( wxPoint( 0, y ) ); // down
int x_offset = 0; int x_offset = 0;
...@@ -1191,18 +1237,18 @@ void SCH_GLOBALLABEL::CreateGraphicShape( std::vector <wxPoint>& aCorner_list, ...@@ -1191,18 +1237,18 @@ void SCH_GLOBALLABEL::CreateGraphicShape( std::vector <wxPoint>& aCorner_list,
{ {
case NET_INPUT: case NET_INPUT:
x_offset = -HalfSize; x_offset = -HalfSize;
aCorner_list[0].x += HalfSize; aPoints[0].x += HalfSize;
break; break;
case NET_OUTPUT: case NET_OUTPUT:
aCorner_list[3].x -= HalfSize; aPoints[3].x -= HalfSize;
break; break;
case NET_BIDI: case NET_BIDI:
case NET_TRISTATE: case NET_TRISTATE:
x_offset = -HalfSize; x_offset = -HalfSize;
aCorner_list[0].x += HalfSize; aPoints[0].x += HalfSize;
aCorner_list[3].x -= HalfSize; aPoints[3].x -= HalfSize;
break; break;
case NET_UNSPECIFIED: case NET_UNSPECIFIED:
...@@ -1231,15 +1277,15 @@ void SCH_GLOBALLABEL::CreateGraphicShape( std::vector <wxPoint>& aCorner_list, ...@@ -1231,15 +1277,15 @@ void SCH_GLOBALLABEL::CreateGraphicShape( std::vector <wxPoint>& aCorner_list,
} }
// Rotate outlines and move corners in real position // Rotate outlines and move corners in real position
for( unsigned ii = 0; ii < aCorner_list.size(); ii++ ) for( unsigned ii = 0; ii < aPoints.size(); ii++ )
{ {
aCorner_list[ii].x += x_offset; aPoints[ii].x += x_offset;
if( angle ) if( angle )
RotatePoint( &aCorner_list[ii], angle ); RotatePoint( &aPoints[ii], angle );
aCorner_list[ii] += Pos; aPoints[ii] += Pos;
} }
aCorner_list.push_back( aCorner_list[0] ); // closing aPoints.push_back( aPoints[0] ); // closing
} }
...@@ -1494,15 +1540,14 @@ void SCH_HIERLABEL::Draw( EDA_DRAW_PANEL* panel, ...@@ -1494,15 +1540,14 @@ void SCH_HIERLABEL::Draw( EDA_DRAW_PANEL* panel,
} }
void SCH_HIERLABEL::CreateGraphicShape( std::vector <wxPoint>& aCorner_list, void SCH_HIERLABEL::CreateGraphicShape( std::vector <wxPoint>& aPoints, const wxPoint& Pos )
const wxPoint& Pos )
{ {
int* Template = TemplateShape[m_Shape][m_SchematicOrientation]; int* Template = TemplateShape[m_Shape][m_SchematicOrientation];
int HalfSize = m_Size.x / 2; int HalfSize = m_Size.x / 2;
int imax = *Template; Template++; int imax = *Template; Template++;
aCorner_list.clear(); aPoints.clear();
for( int ii = 0; ii < imax; ii++ ) for( int ii = 0; ii < imax; ii++ )
{ {
...@@ -1513,7 +1558,7 @@ void SCH_HIERLABEL::CreateGraphicShape( std::vector <wxPoint>& aCorner_list, ...@@ -1513,7 +1558,7 @@ void SCH_HIERLABEL::CreateGraphicShape( std::vector <wxPoint>& aCorner_list,
corner.y = ( HalfSize * (*Template) ) + Pos.y; corner.y = ( HalfSize * (*Template) ) + Pos.y;
Template++; Template++;
aCorner_list.push_back( corner ); aPoints.push_back( corner );
} }
} }
...@@ -1570,7 +1615,7 @@ EDA_RECT SCH_HIERLABEL::GetBoundingBox() const ...@@ -1570,7 +1615,7 @@ EDA_RECT SCH_HIERLABEL::GetBoundingBox() const
} }
wxPoint SCH_HIERLABEL::GetSchematicTextOffset() wxPoint SCH_HIERLABEL::GetSchematicTextOffset() const
{ {
wxPoint text_offset; wxPoint text_offset;
......
...@@ -97,7 +97,7 @@ public: ...@@ -97,7 +97,7 @@ public:
* (room to draw an associated graphic symbol, or put the text above a * (room to draw an associated graphic symbol, or put the text above a
* wire) * wire)
*/ */
virtual wxPoint GetSchematicTextOffset(); virtual wxPoint GetSchematicTextOffset() const;
SCH_TEXT* GenCopy(); SCH_TEXT* GenCopy();
...@@ -110,14 +110,14 @@ public: ...@@ -110,14 +110,14 @@ public:
/** /**
* 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 = a buffer to fill with polygon corners coordinates * @param aPoints = a buffer to fill with polygon corners coordinates
* @param Pos = Postion of the shape * @param Pos = Postion of the shape
* for texts and labels: do nothing * for texts and labels: do nothing
* Mainly for derived classes (SCH_SHEET_PIN and Hierarchical labels) * Mainly for derived classes (SCH_SHEET_PIN and Hierarchical labels)
*/ */
virtual void CreateGraphicShape( std::vector <wxPoint>& aCorner_list, const wxPoint& Pos ) virtual void CreateGraphicShape( std::vector <wxPoint>& aPoints, const wxPoint& Pos )
{ {
aCorner_list.clear(); aPoints.clear();
} }
void SwapData( SCH_TEXT* copyitem ); void SwapData( SCH_TEXT* copyitem );
...@@ -214,6 +214,7 @@ private: ...@@ -214,6 +214,7 @@ private:
virtual bool doHitTest( const wxPoint& aPoint, int aAccuracy ) const; virtual bool doHitTest( const wxPoint& aPoint, int aAccuracy ) const;
virtual bool doHitTest( const EDA_RECT& aRect, bool aContained, int aAccuracy ) const; virtual bool doHitTest( const EDA_RECT& aRect, bool aContained, int aAccuracy ) const;
virtual EDA_ITEM* doClone() const; virtual EDA_ITEM* doClone() const;
virtual void doPlot( PLOTTER* aPlotter );
}; };
...@@ -260,7 +261,7 @@ public: ...@@ -260,7 +261,7 @@ public:
* (room to draw an associated graphic symbol, or put the text above a * (room to draw an associated graphic symbol, or put the text above a
* wire) * wire)
*/ */
virtual wxPoint GetSchematicTextOffset(); virtual wxPoint GetSchematicTextOffset() const;
virtual void Mirror_X( int aXaxis_position ); virtual void Mirror_X( int aXaxis_position );
...@@ -350,7 +351,7 @@ public: ...@@ -350,7 +351,7 @@ public:
* (room to draw an associated graphic symbol, or put the text above a * (room to draw an associated graphic symbol, or put the text above a
* wire) * wire)
*/ */
virtual wxPoint GetSchematicTextOffset(); virtual wxPoint GetSchematicTextOffset() const;
/** /**
* Function Save * Function Save
...@@ -383,10 +384,10 @@ public: ...@@ -383,10 +384,10 @@ public:
/** /**
* Function CreateGraphicShape (virual) * Function CreateGraphicShape (virual)
* Calculates the graphic shape (a polygon) associated to the text * Calculates the graphic shape (a polygon) associated to the text
* @param aCorner_list = a buffer to fill with polygon corners coordinates * @param aPoints = a buffer to fill with polygon corners coordinates
* @param aPos = Position of the shape * @param aPos = Position of the shape
*/ */
virtual void CreateGraphicShape( std::vector <wxPoint>& aCorner_list, const wxPoint& aPos ); virtual void CreateGraphicShape( std::vector <wxPoint>& aPoints, const wxPoint& aPos );
/** virtual function Mirror_Y /** virtual function Mirror_Y
* mirror item relative to an Y axis * mirror item relative to an Y axis
...@@ -456,15 +457,15 @@ public: ...@@ -456,15 +457,15 @@ public:
* (room to draw an associated graphic symbol, or put the text above a * (room to draw an associated graphic symbol, or put the text above a
* wire) * wire)
*/ */
virtual wxPoint GetSchematicTextOffset(); virtual wxPoint GetSchematicTextOffset() const;
/** /**
* 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 = a buffer to fill with polygon corners coordinates * @param aPoints = a buffer to fill with polygon corners coordinates
* @param Pos = Postion of the shape * @param Pos = Postion of the shape
*/ */
virtual void CreateGraphicShape( std::vector <wxPoint>& aCorner_list, const wxPoint& Pos ); virtual void CreateGraphicShape( std::vector <wxPoint>& aPoints, const wxPoint& Pos );
/** /**
* Function Save * Function Save
......
...@@ -18,6 +18,7 @@ class SCH_SHEET_PATH; ...@@ -18,6 +18,7 @@ class SCH_SHEET_PATH;
class SCH_SHEET_PIN; class SCH_SHEET_PIN;
class SCH_LINE; class SCH_LINE;
class SCH_TEXT; class SCH_TEXT;
class PLOTTER;
enum SCH_LINE_TEST_T enum SCH_LINE_TEST_T
...@@ -123,6 +124,14 @@ public: ...@@ -123,6 +124,14 @@ public:
*/ */
void Draw( EDA_DRAW_PANEL* aCanvas, wxDC* aDC, int aDrawMode, int aColor = -1 ); void Draw( EDA_DRAW_PANEL* aCanvas, wxDC* aDC, int aDrawMode, int aColor = -1 );
/**
* Function Plot
* plots all the schematic objects to \a aPlotter.
*
* @param aPlotter The plotter object to plot to.
*/
void Plot( PLOTTER* aPlotter );
/** /**
* Remove \a aItem from the schematic associated with this screen. * Remove \a aItem from the schematic associated with this screen.
* *
......
...@@ -15,6 +15,7 @@ class SCH_ITEM; ...@@ -15,6 +15,7 @@ class SCH_ITEM;
class LINE_READER; class LINE_READER;
class SCH_EDIT_FRAME; class SCH_EDIT_FRAME;
class wxFindReplaceData; class wxFindReplaceData;
class PLOTTER;
typedef boost::ptr_vector< SCH_ITEM > SCH_ITEMS; typedef boost::ptr_vector< SCH_ITEM > SCH_ITEMS;
...@@ -303,6 +304,8 @@ public: ...@@ -303,6 +304,8 @@ public:
virtual bool CanIncrementLabel() const { return false; } virtual bool CanIncrementLabel() const { return false; }
void Plot( PLOTTER* aPlotter ) { doPlot( aPlotter ); }
virtual bool operator <( const SCH_ITEM& aItem ) const; virtual bool operator <( const SCH_ITEM& aItem ) const;
/** /**
...@@ -323,6 +326,8 @@ private: ...@@ -323,6 +326,8 @@ private:
} }
virtual bool doIsConnected( const wxPoint& aPosition ) const { return false; } virtual bool doIsConnected( const wxPoint& aPosition ) const { return false; }
virtual void doPlot( PLOTTER* aPlotter );
}; };
......
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