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)
# 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)
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)
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)
# Path to local CMake modules.
......
......@@ -26,7 +26,7 @@ bool sort_schematic_items( const SCH_ITEM* aItem1, const SCH_ITEM* aItem2 )
/* Constructor and destructor for SCH_ITEM */
/* They are not inline because this creates problems with gcc at linking time
* in debug mode
*/
*/
SCH_ITEM::SCH_ITEM( EDA_ITEM* aParent, KICAD_T aType ) :
EDA_ITEM( aParent, aType )
......@@ -127,3 +127,9 @@ bool SCH_ITEM::operator < ( const SCH_ITEM& aItem ) const
wxCHECK_MSG( false, this->Type() < aItem.Type(),
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
onrightclick.cpp
operations_on_items_lists.cpp
pinedit.cpp
plot.cpp
sch_bus_entry.cpp
sch_collectors.cpp
sch_component.cpp
......
......@@ -242,7 +242,7 @@ void DIALOG_PLOT_SCHEMATIC_DXF::PlotOneSheetDXF( const wxString& FileName,
m_Parent->PlotWorkSheet( plotter, screen );
}
PlotDrawlist( plotter, screen->GetDrawItems() );
screen->Plot( plotter );
/* fin */
plotter->end_plot();
......
......@@ -392,7 +392,7 @@ void DIALOG_PLOT_SCHEMATIC_HPGL::Plot_1_Page_HPGL( const wxString& FileName,
if( m_plot_Sheet_Ref )
m_Parent->PlotWorkSheet( plotter, screen );
PlotDrawlist( plotter, screen->GetDrawItems() );
screen->Plot( plotter );
plotter->end_plot();
delete plotter;
......
......@@ -293,7 +293,7 @@ void DIALOG_PLOT_SCHEMATIC_PS::plotOneSheetPS( const wxString& FileName,
m_Parent->PlotWorkSheet( plotter, screen );
}
PlotDrawlist( plotter, screen->GetDrawItems() );
screen->Plot( plotter );
plotter->end_plot();
delete plotter;
......
......@@ -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_ITEM( LIB_PIN_T, aParent )
{
......@@ -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. *
* Same as DrawPinTexts((), but output is the plotter
......@@ -1748,7 +1848,7 @@ void LIB_PIN::DoPlot( PLOTTER* plotter, const wxPoint& offset, bool fill,
wxPoint pos = aTransform.TransformCoordinate( m_position ) + offset;
plotter->set_current_line_width( GetPenSize() );
PlotPinSymbol( plotter, pos, m_length, orient, m_shape );
PlotSymbol( plotter, pos, orient );
PlotPinTexts( plotter, pos, orient, GetParent()->GetPinNameOffset(),
GetParent()->ShowPinNumbers(), GetParent()->ShowPinNames(),
GetPenSize() );
......
......@@ -372,6 +372,8 @@ public:
bool aDrawPinName,
int aWidth );
void PlotSymbol( PLOTTER* aPlotter, const wxPoint& aPosition, int aOrientation );
/**
* Get a list of pin orientation names.
*
......
This diff is collapsed.
......@@ -76,12 +76,6 @@ EDA_Colors ReturnLayerColor( int Layer );
int IsBusLabel( const wxString& LabelDrawList );
/************/
/* PLOT.CPP */
/************/
void PlotDrawlist( PLOTTER* plotter, SCH_ITEM* drawlist );
/***************/
/* PINEDIT.CPP */
/***************/
......
......@@ -9,6 +9,7 @@
#include "trigo.h"
#include "common.h"
#include "richio.h"
#include "plot_common.h"
#include "general.h"
#include "protos.h"
......@@ -250,3 +251,12 @@ bool SCH_BUS_ENTRY::doHitTest( const EDA_RECT& aRect, bool aContained, int aAccu
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:
virtual bool doHitTest( const wxPoint& aPoint, int aAccuracy ) const;
virtual bool doHitTest( const EDA_RECT& aRect, bool aContained, int aAccuracy ) const;
virtual EDA_ITEM* doClone() const;
virtual void doPlot( PLOTTER* aPlotter );
};
......
......@@ -11,6 +11,7 @@
#include "kicad_string.h"
#include "richio.h"
#include "wxEeschemaStruct.h"
#include "plot_common.h"
#include "general.h"
#include "class_library.h"
......@@ -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,
int DrawMode, int Color, bool DrawPinText )
{
......@@ -1778,3 +1791,24 @@ bool SCH_COMPONENT::doIsConnected( const wxPoint& aPosition ) const
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:
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
* writes the data structures for this object out to a FILE in "*.sch" format.
......@@ -395,6 +403,7 @@ private:
virtual bool doHitTest( const EDA_RECT& aRect, bool aContained, int aAccuracy ) const;
virtual bool doIsConnected( const wxPoint& aPosition ) const;
virtual EDA_ITEM* doClone() const;
virtual void doPlot( PLOTTER* aPlotter );
};
......
......@@ -20,6 +20,7 @@
#include "trigo.h"
#include "class_sch_screen.h"
#include "wxEeschemaStruct.h"
#include "plot_common.h"
#include "general.h"
#include "protos.h"
......@@ -501,3 +502,75 @@ bool SCH_FIELD::doHitTest( const EDA_RECT& aRect, bool aContained, int aAccuracy
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:
/**
* 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.
* @return The name of the field.
*/
......@@ -165,7 +165,7 @@ public:
* @param aSearchData - Criteria to search against.
* @param aAuxData - a pointer on auxiliary data, if needed.
* 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)
* @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.
......@@ -181,6 +181,7 @@ private:
virtual bool doHitTest( const wxPoint& aPoint, int aAccuracy ) const;
virtual bool doHitTest( const EDA_RECT& aRect, bool aContained, int aAccuracy ) const;
virtual EDA_ITEM* doClone() const;
virtual void doPlot( PLOTTER* aPlotter );
};
......
/*****************************/
/* class_schematic_items.cpp */
/*****************************/
/********************/
/* sch_junction.cpp */
/********************/
#include "fctsys.h"
#include "gr_basic.h"
......@@ -9,6 +9,7 @@
#include "trigo.h"
#include "common.h"
#include "richio.h"
#include "plot_common.h"
#include "general.h"
#include "protos.h"
......@@ -204,3 +205,10 @@ bool SCH_JUNCTION::doIsConnected( const wxPoint& aPosition ) const
{
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:
virtual bool doHitTest( const EDA_RECT& aRect, bool aContained, int aAccuracy ) const;
virtual bool doIsConnected( const wxPoint& aPosition ) const;
virtual EDA_ITEM* doClone() const;
virtual void doPlot( PLOTTER* aPlotter );
};
......
......@@ -8,6 +8,7 @@
#include "class_drawpanel.h"
#include "trigo.h"
#include "richio.h"
#include "plot_common.h"
#include "general.h"
#include "protos.h"
......@@ -440,7 +441,7 @@ wxString SCH_LINE::GetSelectMenuText() const
break;
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 ),
......@@ -510,3 +511,19 @@ bool SCH_LINE::doIsConnected( const wxPoint& aPosition ) const
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:
* 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
* 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.
*
* @param aLine - Line to compare.
......@@ -148,6 +148,7 @@ private:
virtual bool doHitTest( const EDA_RECT& aRect, bool aContained, int aAccuracy ) const;
virtual bool doIsConnected( const wxPoint& aPosition ) const;
virtual EDA_ITEM* doClone() const;
virtual void doPlot( PLOTTER* aPlotter );
};
......
......@@ -9,6 +9,7 @@
#include "common.h"
#include "trigo.h"
#include "richio.h"
#include "plot_common.h"
#include "general.h"
#include "protos.h"
......@@ -22,6 +23,8 @@ SCH_NO_CONNECT::SCH_NO_CONNECT( const wxPoint& pos ) :
m_Pos = pos;
m_Size.x = m_Size.y = 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
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:
virtual bool doHitTest( const wxPoint& aPoint, int aAccuracy ) const;
virtual bool doHitTest( const EDA_RECT& aRect, bool aContained, int aAccuracy ) const;
virtual EDA_ITEM* doClone() const;
virtual void doPlot( PLOTTER* aPlotter );
};
......
......@@ -9,6 +9,7 @@
#include "sch_item_struct.h"
#include "class_sch_screen.h"
#include "wxEeschemaStruct.h"
#include "plot_common.h"
#include "general.h"
#include "protos.h"
......@@ -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 )
{
if( aItemCount == 0 )
......
......@@ -20,6 +20,7 @@
#include "richio.h"
#include "class_sch_screen.h"
#include "wxEeschemaStruct.h"
#include "plot_common.h"
#include "general.h"
#include "protos.h"
......@@ -28,6 +29,7 @@
#include "sch_component.h"
#include "kicad_string.h"
SCH_SHEET::SCH_SHEET( const wxPoint& pos ) :
SCH_ITEM( NULL, SCH_SHEET_T )
{
......@@ -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 )
{
......@@ -827,7 +829,7 @@ int SCH_SHEET::CountSheets()
}
wxString SCH_SHEET::GetFileName( void )
wxString SCH_SHEET::GetFileName( void ) const
{
return m_FileName;
}
......@@ -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)
void SCH_SHEET::Show( int nestLevel, std::ostream& os )
......
......@@ -80,10 +80,10 @@ public:
/**
* Function CreateGraphicShape (virtual)
* 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
*/
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 );
......@@ -289,7 +289,7 @@ public:
/* there is no member for orientation in sch_sheet, to preserve file
* format, we detect orientation based on pin edges
*/
bool IsVerticalOrientation();
bool IsVerticalOrientation() const;
/**
* Add aSheetPin to the sheet.
......@@ -475,7 +475,7 @@ public:
* return the filename corresponding to this sheet
* @return a wxString containing the filename
*/
wxString GetFileName( void );
wxString GetFileName( void ) const;
// Set a new filename without changing anything else
void SetFileName( const wxString& aFilename )
......@@ -589,6 +589,7 @@ private:
virtual bool doHitTest( const wxPoint& aPoint, int aAccuracy ) const;
virtual bool doHitTest( const EDA_RECT& aRect, bool aContained, int aAccuracy ) const;
virtual EDA_ITEM* doClone() const;
virtual void doPlot( PLOTTER* aPlotter );
};
......
......@@ -460,8 +460,7 @@ void SCH_SHEET_PIN::Rotate( wxPoint rotationPoint )
}
void SCH_SHEET_PIN::CreateGraphicShape( std::vector <wxPoint>& aCorner_list,
const wxPoint& aPos )
void SCH_SHEET_PIN::CreateGraphicShape( std::vector <wxPoint>& aPoints, const wxPoint& aPos )
{
/* This is the same icon shapes as SCH_HIERLABEL
* but the graphic icon is slightly different in 2 cases:
......@@ -484,7 +483,7 @@ void SCH_SHEET_PIN::CreateGraphicShape( std::vector <wxPoint>& aCorner_list,
break;
}
SCH_HIERLABEL::CreateGraphicShape( aCorner_list, aPos );
SCH_HIERLABEL::CreateGraphicShape( aPoints, aPos );
m_Shape = tmp;
}
......
......@@ -11,6 +11,7 @@
#include "class_drawpanel.h"
#include "drawtxt.h"
#include "wxEeschemaStruct.h"
#include "plot_common.h"
#include "general.h"
#include "protos.h"
......@@ -112,7 +113,7 @@ void SCH_TEXT::IncrementLabel()
}
wxPoint SCH_TEXT::GetSchematicTextOffset()
wxPoint SCH_TEXT::GetSchematicTextOffset() const
{
wxPoint text_offset;
......@@ -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)
void SCH_TEXT::Show( int nestLevel, std::ostream& os )
......@@ -691,7 +738,7 @@ EDA_ITEM* SCH_LABEL::doClone() const
}
wxPoint SCH_LABEL::GetSchematicTextOffset()
wxPoint SCH_LABEL::GetSchematicTextOffset() const
{
return SCH_TEXT::GetSchematicTextOffset();
}
......@@ -1037,7 +1084,7 @@ void SCH_GLOBALLABEL::Rotate( wxPoint rotationPoint )
}
wxPoint SCH_GLOBALLABEL::GetSchematicTextOffset()
wxPoint SCH_GLOBALLABEL::GetSchematicTextOffset() const
{
wxPoint text_offset;
int width = (m_Thickness == 0) ? g_DrawDefaultLineThickness : m_Thickness;
......@@ -1159,15 +1206,14 @@ void SCH_GLOBALLABEL::Draw( EDA_DRAW_PANEL* panel,
}
void SCH_GLOBALLABEL::CreateGraphicShape( std::vector <wxPoint>& aCorner_list,
const wxPoint& Pos )
void SCH_GLOBALLABEL::CreateGraphicShape( std::vector <wxPoint>& aPoints, const wxPoint& Pos )
{
int HalfSize = m_Size.y / 2;
int linewidth = (m_Thickness == 0) ? g_DrawDefaultLineThickness : m_Thickness;
linewidth = Clamp_Text_PenSize( linewidth, m_Size, m_Bold );
aCorner_list.clear();
aPoints.clear();
int symb_len = LenSize( m_Text ) + ( TXTMARGE * 2 );
......@@ -1178,12 +1224,12 @@ void SCH_GLOBALLABEL::CreateGraphicShape( std::vector <wxPoint>& aCorner_list,
int y = wxRound( (double) HalfSize * 1.5 + (double) linewidth + 3.0 );
// Starting point(anchor)
aCorner_list.push_back( wxPoint( 0, 0 ) );
aCorner_list.push_back( wxPoint( 0, -y ) ); // Up
aCorner_list.push_back( wxPoint( -x, -y ) ); // left
aCorner_list.push_back( wxPoint( -x, 0 ) ); // Up left
aCorner_list.push_back( wxPoint( -x, y ) ); // left down
aCorner_list.push_back( wxPoint( 0, y ) ); // down
aPoints.push_back( wxPoint( 0, 0 ) );
aPoints.push_back( wxPoint( 0, -y ) ); // Up
aPoints.push_back( wxPoint( -x, -y ) ); // left
aPoints.push_back( wxPoint( -x, 0 ) ); // Up left
aPoints.push_back( wxPoint( -x, y ) ); // left down
aPoints.push_back( wxPoint( 0, y ) ); // down
int x_offset = 0;
......@@ -1191,18 +1237,18 @@ void SCH_GLOBALLABEL::CreateGraphicShape( std::vector <wxPoint>& aCorner_list,
{
case NET_INPUT:
x_offset = -HalfSize;
aCorner_list[0].x += HalfSize;
aPoints[0].x += HalfSize;
break;
case NET_OUTPUT:
aCorner_list[3].x -= HalfSize;
aPoints[3].x -= HalfSize;
break;
case NET_BIDI:
case NET_TRISTATE:
x_offset = -HalfSize;
aCorner_list[0].x += HalfSize;
aCorner_list[3].x -= HalfSize;
aPoints[0].x += HalfSize;
aPoints[3].x -= HalfSize;
break;
case NET_UNSPECIFIED:
......@@ -1231,15 +1277,15 @@ void SCH_GLOBALLABEL::CreateGraphicShape( std::vector <wxPoint>& aCorner_list,
}
// 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 )
RotatePoint( &aCorner_list[ii], angle );
aCorner_list[ii] += Pos;
RotatePoint( &aPoints[ii], angle );
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,
}
void SCH_HIERLABEL::CreateGraphicShape( std::vector <wxPoint>& aCorner_list,
const wxPoint& Pos )
void SCH_HIERLABEL::CreateGraphicShape( std::vector <wxPoint>& aPoints, const wxPoint& Pos )
{
int* Template = TemplateShape[m_Shape][m_SchematicOrientation];
int HalfSize = m_Size.x / 2;
int imax = *Template; Template++;
aCorner_list.clear();
aPoints.clear();
for( int ii = 0; ii < imax; ii++ )
{
......@@ -1513,7 +1558,7 @@ void SCH_HIERLABEL::CreateGraphicShape( std::vector <wxPoint>& aCorner_list,
corner.y = ( HalfSize * (*Template) ) + Pos.y;
Template++;
aCorner_list.push_back( corner );
aPoints.push_back( corner );
}
}
......@@ -1570,7 +1615,7 @@ EDA_RECT SCH_HIERLABEL::GetBoundingBox() const
}
wxPoint SCH_HIERLABEL::GetSchematicTextOffset()
wxPoint SCH_HIERLABEL::GetSchematicTextOffset() const
{
wxPoint text_offset;
......
......@@ -97,7 +97,7 @@ public:
* (room to draw an associated graphic symbol, or put the text above a
* wire)
*/
virtual wxPoint GetSchematicTextOffset();
virtual wxPoint GetSchematicTextOffset() const;
SCH_TEXT* GenCopy();
......@@ -110,14 +110,14 @@ public:
/**
* Function CreateGraphicShape
* 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
* for texts and labels: do nothing
* 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 );
......@@ -214,6 +214,7 @@ private:
virtual bool doHitTest( const wxPoint& aPoint, int aAccuracy ) const;
virtual bool doHitTest( const EDA_RECT& aRect, bool aContained, int aAccuracy ) const;
virtual EDA_ITEM* doClone() const;
virtual void doPlot( PLOTTER* aPlotter );
};
......@@ -260,7 +261,7 @@ public:
* (room to draw an associated graphic symbol, or put the text above a
* wire)
*/
virtual wxPoint GetSchematicTextOffset();
virtual wxPoint GetSchematicTextOffset() const;
virtual void Mirror_X( int aXaxis_position );
......@@ -350,7 +351,7 @@ public:
* (room to draw an associated graphic symbol, or put the text above a
* wire)
*/
virtual wxPoint GetSchematicTextOffset();
virtual wxPoint GetSchematicTextOffset() const;
/**
* Function Save
......@@ -383,10 +384,10 @@ public:
/**
* Function CreateGraphicShape (virual)
* 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
*/
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
* mirror item relative to an Y axis
......@@ -456,15 +457,15 @@ public:
* (room to draw an associated graphic symbol, or put the text above a
* wire)
*/
virtual wxPoint GetSchematicTextOffset();
virtual wxPoint GetSchematicTextOffset() const;
/**
* Function CreateGraphicShape
* 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
*/
virtual void CreateGraphicShape( std::vector <wxPoint>& aCorner_list, const wxPoint& Pos );
virtual void CreateGraphicShape( std::vector <wxPoint>& aPoints, const wxPoint& Pos );
/**
* Function Save
......
......@@ -18,6 +18,7 @@ class SCH_SHEET_PATH;
class SCH_SHEET_PIN;
class SCH_LINE;
class SCH_TEXT;
class PLOTTER;
enum SCH_LINE_TEST_T
......@@ -123,6 +124,14 @@ public:
*/
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.
*
......
......@@ -15,6 +15,7 @@ class SCH_ITEM;
class LINE_READER;
class SCH_EDIT_FRAME;
class wxFindReplaceData;
class PLOTTER;
typedef boost::ptr_vector< SCH_ITEM > SCH_ITEMS;
......@@ -303,6 +304,8 @@ public:
virtual bool CanIncrementLabel() const { return false; }
void Plot( PLOTTER* aPlotter ) { doPlot( aPlotter ); }
virtual bool operator <( const SCH_ITEM& aItem ) const;
/**
......@@ -323,6 +326,8 @@ private:
}
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