kicad/eeschema/class_schematic_items.h

404 lines
11 KiB
C
Raw Normal View History

2009-01-02 17:07:50 +00:00
/************************************************************************/
/* classes to handle items used in schematic: wires, bus, junctions ... */
/************************************************************************/
#ifndef CLASS_SCHEMATIC_ITEMS_H
#define CLASS_SCHEMATIC_ITEMS_H
/* Flags for BUS ENTRY (bus to bus or wire to bus */
2009-01-02 17:07:50 +00:00
#define WIRE_TO_BUS 0
#define BUS_TO_BUS 1
/**
* Class SCH_LINE
* is a segment description base class to describe items which have 2 end
2009-01-02 17:07:50 +00:00
* points (track, wire, draw line ...)
*/
class SCH_LINE : public SCH_ITEM
2009-01-02 17:07:50 +00:00
{
public:
int m_Width; // 0 = line, > 0 = tracks, bus ...
wxPoint m_Start; // Line start point
wxPoint m_End; // Line end point
bool m_StartIsDangling;
bool m_EndIsDangling; // TRUE if not connected (wires, tracks...)
2009-01-02 17:07:50 +00:00
public:
SCH_LINE( const wxPoint& pos, int layer );
~SCH_LINE() { }
2009-01-02 17:07:50 +00:00
SCH_LINE* Next() const { return (SCH_LINE*) Pnext; }
SCH_LINE* Back() const { return (SCH_LINE*) Pback; }
2009-01-02 17:07:50 +00:00
virtual wxString GetClass() const
{
return wxT( "SCH_LINE" );
2009-01-02 17:07:50 +00:00
}
bool IsOneEndPointAt( const wxPoint& pos );
SCH_LINE* GenCopy();
2009-01-02 17:07:50 +00:00
bool IsNull()
{
return m_Start == m_End;
}
2009-11-28 09:24:37 +00:00
/**
* Function GetBoundingBox
* returns the orthogonal, bounding box of this object for display purposes.
* This box should be an enclosing perimeter for visible components of this
* object, and the units should be in the pcb or schematic coordinate system.
* It is OK to overestimate the size by a few counts.
*/
2009-01-02 17:07:50 +00:00
EDA_Rect GetBoundingBox();
virtual void Draw( WinEDA_DrawPanel* panel, wxDC* DC, const wxPoint& offset,
int draw_mode, int Color = -1 );
2009-01-02 17:07:50 +00:00
/**
* Function Save
* writes the data structures for this object out to a FILE in "*.sch"
* format.
2009-01-02 17:07:50 +00:00
* @param aFile The FILE to write to.
* @return bool - true if success writing else false.
*/
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();
// Geometric transforms (used in block operations):
/** virtual function Move
* move item to a new position.
* @param aMoveVector = the displacement vector
*/
virtual void Move( const wxPoint& aMoveVector )
{
if( (m_Flags & STARTPOINT) == 0 )
m_Start += aMoveVector;
if( (m_Flags & ENDPOINT) == 0 )
m_End += aMoveVector;
}
/** virtual function Mirror_Y
* mirror item relative to an Y axis
* @param aYaxis_position = the y axis position
*/
virtual void Mirror_X( int aXaxis_position );
virtual void Mirror_Y( int aYaxis_position );
virtual void Rotate( wxPoint rotationPoint );
2009-01-02 17:07:50 +00:00
#if defined(DEBUG)
void Show( int nestLevel, std::ostream& os );
2009-01-02 17:07:50 +00:00
#endif
};
class SCH_NO_CONNECT : public SCH_ITEM
2009-01-02 17:07:50 +00:00
{
public:
wxPoint m_Pos; /* XY coordinates of NoConnect. */
wxSize m_Size; // size of this symbol
2009-01-02 17:07:50 +00:00
public:
SCH_NO_CONNECT( const wxPoint& pos );
~SCH_NO_CONNECT() { }
2009-01-02 17:07:50 +00:00
virtual wxString GetClass() const
{
return wxT( "SCH_NO_CONNECT" );
2009-01-02 17:07:50 +00:00
}
SCH_NO_CONNECT* 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 );
2009-01-02 17:07:50 +00:00
/**
* Function Save
* writes the data structures for this object out to a FILE in "*.sch"
* format.
2009-01-02 17:07:50 +00:00
* @param aFile The FILE to write to.
* @return bool - true if success writing else false.
*/
bool Save( FILE* aFile ) const;
2009-01-02 17:07:50 +00:00
/** Function HitTest
* @return true if the point aPosRef is within item area
* @param aPosRef = a wxPoint to test
*/
bool HitTest( const wxPoint& aPosRef );
2009-11-28 09:24:37 +00:00
/**
* Function GetBoundingBox
* returns the orthogonal, bounding box of this object for display
* purposes. This box should be an enclosing perimeter for visible
* components of this object, and the units should be in the pcb or
* schematic coordinate system. It is OK to overestimate the size
* by a few counts.
2009-11-28 09:24:37 +00:00
*/
EDA_Rect GetBoundingBox();
2009-11-28 09:24:37 +00:00
// Geometric transforms (used in block operations):
/** virtual function Move
* move item to a new position.
* @param aMoveVector = the displacement vector
*/
virtual void Move( const wxPoint& aMoveVector )
{
m_Pos += aMoveVector;
}
/** virtual function Mirror_Y
* mirror item relative to an Y axis
* @param aYaxis_position = the y axis position
*/
virtual void Mirror_Y( int aYaxis_position );
virtual void Mirror_X( int aXaxis_position );
virtual void Rotate( wxPoint rotationPoint );
2009-01-02 17:07:50 +00:00
};
/**
* Class SCH_BUS_ENTRY
*
* Defines a bus or wire entry.
2009-01-02 17:07:50 +00:00
*/
class SCH_BUS_ENTRY : public SCH_ITEM
2009-01-02 17:07:50 +00:00
{
public:
int m_Width;
wxPoint m_Pos;
wxSize m_Size;
public:
SCH_BUS_ENTRY( const wxPoint& pos, int shape, int id );
~SCH_BUS_ENTRY() { }
2009-01-02 17:07:50 +00:00
virtual wxString GetClass() const
{
return wxT( "SCH_BUS_ENTRY" );
2009-01-02 17:07:50 +00:00
}
SCH_BUS_ENTRY* GenCopy();
wxPoint m_End() const;
virtual void Draw( WinEDA_DrawPanel* panel, wxDC* DC,
const wxPoint& offset, int draw_mode,
int Color = -1 );
2009-01-02 17:07:50 +00:00
/**
* Function Save
* writes the data structures for this object out to a FILE in "*.sch"
* format.
2009-01-02 17:07:50 +00:00
* @param aFile The FILE to write to.
* @return bool - true if success writing else false.
*/
bool Save( FILE* aFile ) const;
2009-01-02 17:07:50 +00:00
2009-11-28 09:24:37 +00:00
/**
* Function GetBoundingBox
* returns the orthogonal, bounding box of this object for display
* purposes. This box should be an enclosing perimeter for visible
* components of this object, and the units should be in the pcb or
* schematic coordinate system. It is OK to overestimate the size
* by a few counts.
2009-11-28 09:24:37 +00:00
*/
EDA_Rect GetBoundingBox();
/** Function GetPenSize
* @return the size of the "pen" that be used to draw or plot this item
*/
virtual int GetPenSize();
// Geometric transforms (used in block operations):
/** virtual function Move
* move item to a new position.
* @param aMoveVector = the displacement vector
*/
virtual void Move( const wxPoint& aMoveVector )
{
m_Pos += aMoveVector;
}
/** virtual function Mirror_Y
* mirror item relative to an Y axis
* @param aYaxis_position = the y axis position
*/
virtual void Mirror_Y( int aYaxis_position );
virtual void Mirror_X( int aXaxis_position );
virtual void Rotate( wxPoint rotationPoint );
2009-01-02 17:07:50 +00:00
};
class SCH_POLYLINE : public SCH_ITEM
2009-01-02 17:07:50 +00:00
{
public:
int m_Width; /* Thickness */
2009-01-02 17:07:50 +00:00
std::vector<wxPoint> m_PolyPoints; // list of points (>= 2)
public:
SCH_POLYLINE( int layer );
~SCH_POLYLINE();
2009-01-02 17:07:50 +00:00
virtual wxString GetClass() const
{
return wxT( "SCH_POLYLINE" );
2009-01-02 17:07:50 +00:00
}
SCH_POLYLINE* GenCopy();
virtual void Draw( WinEDA_DrawPanel* panel, wxDC* DC,
const wxPoint& offset, int draw_mode,
int Color = -1 );
2009-01-02 17:07:50 +00:00
/**
* Function Save
* writes the data structures for this object out to a FILE in "*.sch"
* format.
2009-01-02 17:07:50 +00:00
* @param aFile The FILE to write to.
* @return bool - true if success writing else false.
*/
bool Save( FILE* aFile ) const;
2009-01-02 17:07:50 +00:00
/** Function AddPoint
* add a corner to m_PolyPoints
*/
void AddPoint( const wxPoint& point )
2009-01-02 17:07:50 +00:00
{
m_PolyPoints.push_back( point );
}
2009-01-02 17:07:50 +00:00
/** Function GetCornerCount
* @return the number of corners
*/
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();
// Geometric transforms (used in block operations):
/** virtual function Move
* move item to a new position.
* @param aMoveVector = the displacement vector
*/
virtual void Move( const wxPoint& aMoveVector )
{
for( unsigned ii = 0; ii < GetCornerCount(); ii++ )
m_PolyPoints[ii] += aMoveVector;
}
/** virtual function Mirror_Y
* mirror item relative to an Y axis
* @param aYaxis_position = the y axis position
*/
virtual void Mirror_Y( int aYaxis_position );
virtual void Mirror_X( int aXaxis_position );
virtual void Rotate( wxPoint rotationPoint );
2009-01-02 17:07:50 +00:00
};
class SCH_JUNCTION : public SCH_ITEM
2009-01-02 17:07:50 +00:00
{
public:
wxPoint m_Pos; /* XY coordinates of connection. */
wxSize m_Size;
2009-01-02 17:07:50 +00:00
public:
SCH_JUNCTION( const wxPoint& pos );
~SCH_JUNCTION() { }
2009-01-02 17:07:50 +00:00
virtual wxString GetClass() const
{
return wxT( "SCH_JUNCTION" );
2009-01-02 17:07:50 +00:00
}
/** Function HitTest
* @return true if the point aPosRef is within item area
* @param aPosRef = a wxPoint to test
*/
bool HitTest( const wxPoint& aPosRef );
2009-11-28 09:24:37 +00:00
/**
* Function GetBoundingBox
* returns the orthogonal, bounding box of this object for display
* purposes. This box should be an enclosing perimeter for visible
* components of this object, and the units should be in the pcb or
* schematic coordinate system. It is OK to overestimate the size
* by a few counts.
2009-11-28 09:24:37 +00:00
*/
EDA_Rect GetBoundingBox();
2009-01-02 17:07:50 +00:00
SCH_JUNCTION* GenCopy();
2009-01-02 17:07:50 +00:00
/** 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 );
2009-01-02 17:07:50 +00:00
/**
* Function Save
* writes the data structures for this object out to a FILE in "*.sch"
* format.
2009-01-02 17:07:50 +00:00
* @param aFile The FILE to write to.
* @return bool - true if success writing else false.
*/
bool Save( FILE* aFile ) const;
2009-01-02 17:07:50 +00:00
// Geometric transforms (used in block operations):
/** virtual function Move
* move item to a new position.
* @param aMoveVector = the displacement vector
*/
virtual void Move( const wxPoint& aMoveVector )
{
m_Pos += aMoveVector;
}
/** virtual function Mirror_Y
* mirror item relative to an Y axis
* @param aYaxis_position = the y axis position
*/
virtual void Mirror_Y( int aYaxis_position );
virtual void Mirror_X( int aXaxis_position );
virtual void Rotate( wxPoint rotationPoint );
2009-01-02 17:07:50 +00:00
#if defined(DEBUG)
void Show( int nestLevel, std::ostream& os );
2009-01-02 17:07:50 +00:00
#endif
};
#endif /* CLASS_SCHEMATIC_ITEMS_H */