2008-04-14 19:22:48 +00:00
|
|
|
/*****************************************************************************/
|
|
|
|
/* sch_item_struct.h : Basic classes for most eeschema items descriptions */
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
|
|
#ifndef SCH_ITEM_STRUCT_H
|
|
|
|
#define SCH_ITEM_STRUCT_H
|
|
|
|
|
2010-11-03 14:13:15 +00:00
|
|
|
#include <vector>
|
|
|
|
#include <class_base_screen.h>
|
2008-04-14 19:22:48 +00:00
|
|
|
|
2010-11-03 14:13:15 +00:00
|
|
|
using namespace std;
|
|
|
|
|
|
|
|
|
|
|
|
class SCH_ITEM;
|
2010-11-10 15:30:12 +00:00
|
|
|
class LINE_READER;
|
2010-12-08 20:12:46 +00:00
|
|
|
class SCH_EDIT_FRAME;
|
2010-03-16 18:22:59 +00:00
|
|
|
class wxFindReplaceData;
|
2009-02-04 15:25:03 +00:00
|
|
|
|
2008-04-14 19:22:48 +00:00
|
|
|
|
2010-11-03 14:13:15 +00:00
|
|
|
enum DANGLING_END_T {
|
|
|
|
UNKNOWN = 0,
|
|
|
|
WIRE_START_END,
|
|
|
|
WIRE_END_END,
|
|
|
|
BUS_START_END,
|
|
|
|
BUS_END_END,
|
|
|
|
JUNCTION_END,
|
|
|
|
PIN_END,
|
|
|
|
LABEL_END,
|
|
|
|
ENTRY_END,
|
|
|
|
SHEET_LABEL_END
|
|
|
|
};
|
|
|
|
|
|
|
|
// A helper class to store a list of items that can be connected to something:
|
|
|
|
class DANGLING_END_ITEM
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
const void* m_Item; // a pointer to the parent
|
|
|
|
wxPoint m_Pos; // the position of the connecting point
|
|
|
|
DANGLING_END_T m_Type; // type of parent
|
|
|
|
|
|
|
|
DANGLING_END_ITEM( DANGLING_END_T type, const void* aItem )
|
|
|
|
{
|
|
|
|
m_Item = aItem;
|
|
|
|
m_Type = type;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
|
2008-04-14 19:22:48 +00:00
|
|
|
/**
|
|
|
|
* Class SCH_ITEM
|
|
|
|
* is a base class for any item which can be embedded within the SCHEMATIC
|
|
|
|
* container class, and therefore instances of derived classes should only be
|
|
|
|
* found in EESCHEMA or other programs that use class SCHEMATIC and its contents.
|
|
|
|
* The corresponding class in PCBNEW is BOARD_ITEM.
|
|
|
|
*/
|
2010-12-08 20:12:46 +00:00
|
|
|
class SCH_ITEM : public EDA_ITEM
|
2008-04-14 19:22:48 +00:00
|
|
|
{
|
|
|
|
protected:
|
|
|
|
int m_Layer;
|
2010-11-03 14:13:15 +00:00
|
|
|
EDA_ITEMS m_connections; ///< List of items connected to this item.
|
2008-04-14 19:22:48 +00:00
|
|
|
|
|
|
|
public:
|
2010-12-08 20:12:46 +00:00
|
|
|
SCH_ITEM( EDA_ITEM* aParent, KICAD_T aType );
|
2008-04-14 19:22:48 +00:00
|
|
|
|
2008-04-15 19:38:19 +00:00
|
|
|
~SCH_ITEM();
|
2008-04-14 19:22:48 +00:00
|
|
|
|
|
|
|
virtual wxString GetClass() const
|
|
|
|
{
|
|
|
|
return wxT( "SCH_ITEM" );
|
|
|
|
}
|
|
|
|
|
|
|
|
SCH_ITEM* Next() { return (SCH_ITEM*) Pnext; }
|
2010-03-16 18:22:59 +00:00
|
|
|
SCH_ITEM* Back() { return (SCH_ITEM*) Pback; }
|
2008-04-14 19:22:48 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Function GetLayer
|
|
|
|
* returns the layer this item is on.
|
|
|
|
*/
|
|
|
|
int GetLayer() const { return m_Layer; }
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Function SetLayer
|
|
|
|
* sets the layer this item is on.
|
|
|
|
* @param aLayer The layer number.
|
|
|
|
*/
|
2010-12-10 19:47:44 +00:00
|
|
|
void SetLayer( int aLayer ) { m_Layer = aLayer; }
|
2008-04-14 19:22:48 +00:00
|
|
|
|
2010-11-12 15:17:10 +00:00
|
|
|
/**
|
|
|
|
* Function GetPenSize virtual pure
|
2009-06-30 19:21:41 +00:00
|
|
|
* @return the size of the "pen" that be used to draw or plot this item
|
|
|
|
*/
|
2010-12-10 19:47:44 +00:00
|
|
|
virtual int GetPenSize() const { return 0; }
|
2009-06-30 19:21:41 +00:00
|
|
|
|
2008-04-14 19:22:48 +00:00
|
|
|
/**
|
|
|
|
* Function Draw
|
|
|
|
*/
|
2010-12-10 19:47:44 +00:00
|
|
|
virtual void Draw( WinEDA_DrawPanel* aPanel,
|
|
|
|
wxDC* aDC,
|
|
|
|
const wxPoint& aOffset,
|
|
|
|
int aDrawMode,
|
|
|
|
int aColor = -1 ) = 0;
|
2008-04-14 19:22:48 +00:00
|
|
|
|
|
|
|
|
2009-07-27 14:32:40 +00:00
|
|
|
/* Place function */
|
2010-12-10 19:47:44 +00:00
|
|
|
virtual void Place( SCH_EDIT_FRAME* aFrame, wxDC* aDC );
|
2008-04-14 19:22:48 +00:00
|
|
|
|
2009-07-27 14:32:40 +00:00
|
|
|
// Geometric transforms (used in block operations):
|
|
|
|
/** virtual function Move
|
|
|
|
* move item to a new position.
|
|
|
|
* @param aMoveVector = the deplacement vector
|
|
|
|
*/
|
2010-11-03 14:13:15 +00:00
|
|
|
virtual void Move( const wxPoint& aMoveVector ) = 0;
|
2009-07-27 14:32:40 +00:00
|
|
|
|
|
|
|
/** virtual function Mirror_Y
|
|
|
|
* mirror item relative to an Y axis
|
|
|
|
* @param aYaxis_position = the y axis position
|
|
|
|
*/
|
2010-11-03 14:13:15 +00:00
|
|
|
virtual void Mirror_Y( int aYaxis_position ) = 0;
|
|
|
|
virtual void Mirror_X( int aXaxis_position ) = 0;
|
|
|
|
virtual void Rotate( wxPoint rotationPoint ) = 0;
|
2010-09-05 17:01:48 +00:00
|
|
|
|
2009-07-27 14:32:40 +00:00
|
|
|
|
2008-04-15 19:38:19 +00:00
|
|
|
/**
|
|
|
|
* Function Save
|
2009-04-05 20:49:15 +00:00
|
|
|
* writes the data structures for this object out to a FILE in "*.sch"
|
|
|
|
* format.
|
2008-04-15 19:38:19 +00:00
|
|
|
* @param aFile The FILE to write to.
|
|
|
|
* @return bool - true if success writing else false.
|
|
|
|
*/
|
2010-12-10 19:47:44 +00:00
|
|
|
virtual bool Save( FILE* aFile ) const = 0;
|
2010-03-16 18:22:59 +00:00
|
|
|
|
2010-11-10 15:30:12 +00:00
|
|
|
/**
|
|
|
|
* Load schematic item from \a aLine in a .sch file.
|
|
|
|
*
|
|
|
|
* @param aLine - Essentially this is file to read the object from.
|
|
|
|
* @param aErrorMsg - Description of the error if an error occurs while loading the object.
|
|
|
|
* @return True if the object loaded successfully.
|
|
|
|
*/
|
|
|
|
virtual bool Load( LINE_READER& aLine, wxString& aErrorMsg ) { return false; }
|
|
|
|
|
2010-03-16 18:22:59 +00:00
|
|
|
/**
|
|
|
|
* Compare schematic item against search string.
|
|
|
|
*
|
|
|
|
* The base class returns false since many of the objects derived from
|
|
|
|
* SCH_ITEM do not have any text to search.
|
|
|
|
*
|
2010-12-08 20:12:46 +00:00
|
|
|
* @todo - This should probably be pushed down to EDA_ITEM so that
|
2010-03-16 18:22:59 +00:00
|
|
|
* searches can be done on all of the Kicad applications that use
|
2010-12-08 20:12:46 +00:00
|
|
|
* objects derived from EDA_ITEM.
|
2010-03-16 18:22:59 +00:00
|
|
|
*
|
|
|
|
* @param aSearchData - The search criteria.
|
2010-04-01 13:15:48 +00:00
|
|
|
* @param aAuxData - a pointer on auxiliary data, if needed (NULL if not used).
|
|
|
|
* When searching string in REFERENCE field we must know the sheet path
|
|
|
|
* This param is used in such cases
|
2010-10-20 19:43:58 +00:00
|
|
|
* @param aFindLocation - a wxPoint where to put the location of matched item. can be NULL.
|
2010-03-16 18:22:59 +00:00
|
|
|
* @return True if this schematic text item matches the search criteria.
|
|
|
|
*/
|
2010-11-03 14:13:15 +00:00
|
|
|
virtual bool Matches( wxFindReplaceData& aSearchData, void* aAuxData, wxPoint* aFindLocation )
|
2010-04-01 13:15:48 +00:00
|
|
|
{ return false; }
|
2010-03-16 18:22:59 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Compare schematic item against search string.
|
|
|
|
*
|
|
|
|
* @param aText - String test.
|
|
|
|
* @param aSearchData - The criteria to search against.
|
|
|
|
* @return True if this item matches the search criteria.
|
|
|
|
*/
|
|
|
|
bool Matches( const wxString& aText, wxFindReplaceData& aSearchData );
|
2010-11-03 14:13:15 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Add schematic item end points to \a aItemList if the item has endpoints.
|
|
|
|
*
|
|
|
|
* The default version doesn't do anything since many of the schematic object cannot
|
|
|
|
* be tested for dangling ends. If you add a new schematic item that can have a
|
|
|
|
* dangling end ( no connect ), override this method to provide the correct end
|
|
|
|
* points.
|
|
|
|
*
|
|
|
|
* @param aItemList - List of DANGLING_END_ITEMS to add to.
|
|
|
|
*/
|
|
|
|
virtual void GetEndPoints( vector< DANGLING_END_ITEM >& aItemList ) {}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Test the schematic item to \a aItemList to check if it's dangling state has changed.
|
|
|
|
*
|
|
|
|
* Note that the return value only true when the state of the test has changed. Use
|
|
|
|
* the IsDangling() method to get the current dangling state of the item. Some of
|
|
|
|
* the schematic objects cannot be tested for a dangling state, the default method
|
|
|
|
* always returns false. Only override the method if the item can be tested for a
|
|
|
|
* dangling state.
|
|
|
|
*
|
|
|
|
* @param aItemList - List of items to test item against.
|
|
|
|
* @return True if the dangling state has changed from it's current setting.
|
|
|
|
*/
|
|
|
|
virtual bool IsDanglingStateChanged( vector< DANGLING_END_ITEM >& aItemList ) { return false; }
|
|
|
|
|
|
|
|
virtual bool IsDangling() const { return false; }
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Check if the selection state of an item inside \a aRect has changed.
|
|
|
|
*
|
|
|
|
* The is used by the block selection code to verify if an item is selected or not.
|
|
|
|
* True is be return anytime the select state changes. If you need to know the
|
|
|
|
* the current selection state, use the IsSelected() method.
|
|
|
|
*
|
|
|
|
* @param aRect - Rectange to test against.
|
|
|
|
*/
|
|
|
|
virtual bool IsSelectStateChanged( const wxRect& aRect ) { return false; }
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Get a list of connection points for this item.
|
|
|
|
*
|
|
|
|
* Not all schematic items have connection points so the default method does nothing.
|
|
|
|
*
|
|
|
|
* @param aPoints - List of connection points to add to.
|
|
|
|
*/
|
|
|
|
virtual void GetConnectionPoints( vector< wxPoint >& aPoints ) const { }
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Clear all of the connection items from the list.
|
|
|
|
*
|
|
|
|
* The vector release method is used to prevent the item pointers from being deleted.
|
|
|
|
* Do not use the vector erase method on the connection list.
|
|
|
|
*/
|
|
|
|
void ClearConnections() { m_connections.release(); }
|
2010-12-10 19:47:44 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Function HitTest().
|
|
|
|
* Test if \a aPoint is contained within the bounding box or on an item.
|
|
|
|
*
|
|
|
|
* @param aPoint - Point to test.
|
|
|
|
* @param aAccuracy - Increase the item bounding box by this amount.
|
|
|
|
* @return True if \aPoint is within the item.
|
|
|
|
*/
|
|
|
|
bool HitTest( const wxPoint& aPoint, int aAccuracy = 0 ) const
|
|
|
|
{
|
|
|
|
return DoHitTest( aPoint, aAccuracy );
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Function HitTest().
|
|
|
|
* Test if \a aRect intersects or is contained within the bounding box of an item.
|
|
|
|
*
|
|
|
|
* @param aRect - Rectangle to test.
|
|
|
|
* @param aContained - Set to true to test for containment instead of an intersection.
|
|
|
|
* @param aAccuracy - Increase the item bounding box by this amount.
|
|
|
|
* @return True if \aRect contains or intersects the item bounding box.
|
|
|
|
*/
|
|
|
|
bool HitTest( const EDA_Rect& aRect, bool aContained = false, int aAccuracy = 0 ) const
|
|
|
|
{
|
|
|
|
return DoHitTest( aRect, aContained, aAccuracy );
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @note - The DoXXX() functions below are used to enforce the interface while retaining
|
|
|
|
* the ability of change the implementation behavior of derived classes. See
|
|
|
|
* Herb Sutters explanation of virtuality as to why you might want to do this at:
|
|
|
|
* http://www.gotw.ca/publications/mill18.htm.
|
|
|
|
*/
|
|
|
|
private:
|
|
|
|
virtual bool DoHitTest( const wxPoint& aPoint, int aAccuracy ) const { return false; }
|
|
|
|
virtual bool DoHitTest( const EDA_Rect& aRect, bool aContained, int aAccuracy ) const
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
2008-04-14 19:22:48 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif /* SCH_ITEM_STRUCT_H */
|