2007-06-05 12:10:51 +00:00
|
|
|
/*********************************************************************/
|
2008-03-15 04:18:32 +00:00
|
|
|
/* base_struct.h : Basic classes for most kicad item descriptions */
|
2007-06-05 12:10:51 +00:00
|
|
|
/*********************************************************************/
|
|
|
|
|
|
|
|
#ifndef BASE_STRUCT_H
|
|
|
|
#define BASE_STRUCT_H
|
|
|
|
|
|
|
|
|
2007-10-31 17:47:44 +00:00
|
|
|
#if defined (DEBUG)
|
2007-08-06 02:02:39 +00:00
|
|
|
#include <iostream> // needed for Show()
|
2007-10-31 17:47:44 +00:00
|
|
|
extern std::ostream& operator <<( std::ostream& out, const wxSize& size );
|
|
|
|
|
|
|
|
extern std::ostream& operator <<( std::ostream& out, const wxPoint& pt );
|
|
|
|
|
2007-08-06 02:02:39 +00:00
|
|
|
#endif
|
|
|
|
|
|
|
|
|
2007-06-05 12:10:51 +00:00
|
|
|
/* Id for class identification, at run time */
|
2007-08-24 15:10:46 +00:00
|
|
|
enum KICAD_T {
|
2007-10-31 17:47:44 +00:00
|
|
|
NOT_USED = -1, // the 3d code uses this value
|
|
|
|
|
2007-08-06 20:26:59 +00:00
|
|
|
EOT = 0, // search types array terminator (End Of Types)
|
2007-10-31 17:47:44 +00:00
|
|
|
|
2007-08-04 04:42:49 +00:00
|
|
|
TYPE_NOT_INIT = 0,
|
2008-12-04 04:28:11 +00:00
|
|
|
TYPE_PCB,
|
2007-08-04 04:42:49 +00:00
|
|
|
|
|
|
|
// Items in pcb
|
2008-12-04 04:28:11 +00:00
|
|
|
TYPE_EQUIPOT,
|
|
|
|
TYPE_MODULE,
|
|
|
|
TYPE_PAD,
|
|
|
|
TYPE_DRAWSEGMENT,
|
|
|
|
TYPE_TEXTE,
|
|
|
|
TYPE_TEXTE_MODULE,
|
|
|
|
TYPE_EDGE_MODULE,
|
|
|
|
TYPE_TRACK,
|
|
|
|
TYPE_ZONE,
|
|
|
|
TYPE_VIA,
|
|
|
|
TYPE_MARKER,
|
|
|
|
TYPE_COTATION,
|
|
|
|
TYPE_MIRE,
|
|
|
|
TYPE_SCREEN,
|
|
|
|
TYPE_BLOCK,
|
|
|
|
TYPE_ZONE_UNUSED,
|
|
|
|
TYPE_ZONE_EDGE_CORNER,
|
|
|
|
TYPE_ZONE_CONTAINER,
|
|
|
|
TYPE_BOARD_ITEM_LIST,
|
2007-08-04 04:42:49 +00:00
|
|
|
|
|
|
|
// Draw Items in schematic
|
|
|
|
DRAW_POLYLINE_STRUCT_TYPE,
|
|
|
|
DRAW_JUNCTION_STRUCT_TYPE,
|
2008-03-20 01:50:21 +00:00
|
|
|
TYPE_SCH_TEXT,
|
|
|
|
TYPE_SCH_LABEL,
|
|
|
|
TYPE_SCH_GLOBALLABEL,
|
|
|
|
TYPE_SCH_HIERLABEL,
|
|
|
|
TYPE_SCH_COMPONENT,
|
2007-08-04 04:42:49 +00:00
|
|
|
DRAW_PICK_ITEM_STRUCT_TYPE,
|
|
|
|
DRAW_SEGMENT_STRUCT_TYPE,
|
|
|
|
DRAW_BUSENTRY_STRUCT_TYPE,
|
|
|
|
DRAW_SHEET_STRUCT_TYPE,
|
2008-04-15 19:38:19 +00:00
|
|
|
DRAW_HIERARCHICAL_PIN_SHEET_STRUCT_TYPE,
|
2007-08-04 04:42:49 +00:00
|
|
|
DRAW_MARKER_STRUCT_TYPE,
|
|
|
|
DRAW_NOCONNECT_STRUCT_TYPE,
|
|
|
|
DRAW_PART_TEXT_STRUCT_TYPE,
|
|
|
|
|
|
|
|
// General
|
|
|
|
SCREEN_STRUCT_TYPE,
|
|
|
|
BLOCK_LOCATE_STRUCT_TYPE,
|
|
|
|
|
|
|
|
// Draw Items in library component
|
|
|
|
LIBCOMPONENT_STRUCT_TYPE,
|
|
|
|
COMPONENT_ARC_DRAW_TYPE,
|
|
|
|
COMPONENT_CIRCLE_DRAW_TYPE,
|
|
|
|
COMPONENT_GRAPHIC_TEXT_DRAW_TYPE,
|
|
|
|
COMPONENT_RECT_DRAW_TYPE,
|
|
|
|
COMPONENT_POLYLINE_DRAW_TYPE,
|
|
|
|
COMPONENT_LINE_DRAW_TYPE,
|
|
|
|
COMPONENT_PIN_DRAW_TYPE,
|
|
|
|
COMPONENT_FIELD_DRAW_TYPE,
|
|
|
|
|
|
|
|
// End value
|
|
|
|
MAX_STRUCT_TYPE_ID
|
2007-06-05 12:10:51 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
2007-08-06 20:26:59 +00:00
|
|
|
enum SEARCH_RESULT {
|
|
|
|
SEARCH_QUIT,
|
|
|
|
SEARCH_CONTINUE
|
2007-10-31 17:47:44 +00:00
|
|
|
};
|
2007-08-06 20:26:59 +00:00
|
|
|
|
|
|
|
|
|
|
|
class EDA_BaseStruct;
|
2007-08-20 19:33:15 +00:00
|
|
|
class WinEDA_DrawFrame;
|
2007-09-15 04:25:54 +00:00
|
|
|
class BOARD;
|
2008-01-06 12:43:57 +00:00
|
|
|
class EDA_Rect;
|
2007-08-06 20:26:59 +00:00
|
|
|
|
2008-11-24 06:53:43 +00:00
|
|
|
|
2007-08-06 20:26:59 +00:00
|
|
|
/**
|
|
|
|
* Class INSPECTOR
|
2007-10-31 17:47:44 +00:00
|
|
|
* is an abstract class that is used to inspect and possibly collect the
|
2007-08-06 20:26:59 +00:00
|
|
|
* (search) results of Iterating over a list or tree of KICAD_T objects.
|
2007-08-06 21:02:23 +00:00
|
|
|
* Extend from this class and implement the Inspect function and provide for
|
2007-08-06 20:26:59 +00:00
|
|
|
* a way for the extension to collect the results of the search/scan data and
|
|
|
|
* provide them to the caller.
|
|
|
|
*/
|
|
|
|
class INSPECTOR
|
|
|
|
{
|
|
|
|
public:
|
2007-08-20 01:20:48 +00:00
|
|
|
virtual ~INSPECTOR()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2007-10-31 17:47:44 +00:00
|
|
|
|
2007-08-06 20:26:59 +00:00
|
|
|
/**
|
|
|
|
* Function Inspect
|
2007-10-31 17:47:44 +00:00
|
|
|
* is the examining function within the INSPECTOR which is passed to the
|
2007-08-06 21:02:23 +00:00
|
|
|
* Iterate function. It is used primarily for searching, but not limited to
|
|
|
|
* that. It can also collect or modify the scanned objects.
|
|
|
|
*
|
|
|
|
* @param testItem An EDA_BaseStruct to examine.
|
2007-08-06 20:26:59 +00:00
|
|
|
* @param testData is arbitrary data needed by the inspector to determine
|
2007-08-23 04:28:46 +00:00
|
|
|
* if the BOARD_ITEM under test meets its match criteria.
|
2007-08-06 20:26:59 +00:00
|
|
|
* @return SEARCH_RESULT - SEARCH_QUIT if the Iterator is to stop the scan,
|
|
|
|
* else SCAN_CONTINUE;
|
2007-10-31 17:47:44 +00:00
|
|
|
*/
|
|
|
|
SEARCH_RESULT virtual Inspect( EDA_BaseStruct * testItem,
|
|
|
|
const void* testData ) = 0;
|
2007-08-06 20:26:59 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
2008-03-15 04:18:32 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Class EDA_Rect
|
|
|
|
* handles the component boundary box.
|
|
|
|
* This class is similar to wxRect, but some wxRect functions are very curious,
|
|
|
|
* so I prefer this suitable class
|
|
|
|
*/
|
|
|
|
class EDA_Rect
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
wxPoint m_Pos; // Rectangle Origin
|
|
|
|
wxSize m_Size; // Rectangle Size
|
|
|
|
|
|
|
|
public:
|
|
|
|
EDA_Rect() { };
|
|
|
|
|
|
|
|
EDA_Rect( const wxPoint& aPos, const wxSize& aSize ) :
|
|
|
|
m_Pos( aPos ), m_Size( aSize )
|
|
|
|
{}
|
|
|
|
|
|
|
|
wxPoint Centre()
|
|
|
|
{
|
|
|
|
return wxPoint( m_Pos.x + (m_Size.x >> 1), m_Pos.y + (m_Size.y >> 1) );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void Normalize(); // Ensure the height and width are >= 0
|
|
|
|
bool Inside( const wxPoint& point ); // Return TRUE if point is in Rect
|
|
|
|
|
|
|
|
bool Inside( int x, int y ) { return Inside( wxPoint( x, y ) ); }
|
|
|
|
wxSize GetSize() { return m_Size; }
|
|
|
|
int GetX() { return m_Pos.x; }
|
|
|
|
int GetY() { return m_Pos.y; }
|
|
|
|
wxPoint GetOrigin() { return m_Pos; }
|
|
|
|
wxPoint GetPosition() { return m_Pos; }
|
|
|
|
wxPoint GetEnd() { return wxPoint( GetRight(), GetBottom() ); }
|
|
|
|
int GetWidth() { return m_Size.x; }
|
|
|
|
int GetHeight() { return m_Size.y; }
|
|
|
|
int GetRight() { return m_Pos.x + m_Size.x; }
|
|
|
|
int GetBottom() { return m_Pos.y + m_Size.y; }
|
|
|
|
void SetOrigin( const wxPoint& pos ) { m_Pos = pos; }
|
|
|
|
void SetOrigin( int x, int y ) { m_Pos.x = x; m_Pos.y = y; }
|
|
|
|
void SetSize( const wxSize& size ) { m_Size = size; }
|
|
|
|
void SetSize( int w, int h ) { m_Size.x = w; m_Size.y = h; }
|
|
|
|
void Offset( int dx, int dy ) { m_Pos.x += dx; m_Pos.y += dy; }
|
|
|
|
void Offset( const wxPoint& offset ) { m_Pos.x += offset.x; m_Pos.y += offset.y; }
|
|
|
|
void SetX( int val ) { m_Pos.x = val; }
|
|
|
|
void SetY( int val ) { m_Pos.y = val; }
|
|
|
|
void SetWidth( int val ) { m_Size.x = val; }
|
|
|
|
void SetHeight( int val ) { m_Size.y = val; }
|
|
|
|
void SetEnd( const wxPoint& pos )
|
|
|
|
{
|
|
|
|
m_Size.x = pos.x - m_Pos.x; m_Size.y = pos.y - m_Pos.y;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Function Intersects
|
|
|
|
* @return bool - true if the argument rectangle intersects this rectangle.
|
|
|
|
*/
|
|
|
|
bool Intersects( const EDA_Rect aRect ) const;
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Function operator(wxRect)
|
|
|
|
* overloads the cast operator to return a wxRect
|
|
|
|
*/
|
|
|
|
operator wxRect() const { return wxRect( m_Pos, m_Size ); }
|
|
|
|
|
|
|
|
EDA_Rect& Inflate( wxCoord dx, wxCoord dy );
|
2008-03-20 01:50:21 +00:00
|
|
|
|
|
|
|
/** Function Merge
|
|
|
|
* Modify Position and Size of this in order to contain the given rect
|
|
|
|
* mainly used to calculate bounding boxes
|
|
|
|
* @param aRect = given rect to merge with this
|
|
|
|
*/
|
|
|
|
void Merge( const EDA_Rect & aRect );
|
2008-03-15 10:24:32 +00:00
|
|
|
|
2008-03-15 04:18:32 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
2008-03-15 10:24:32 +00:00
|
|
|
/******************************************************/
|
|
|
|
/* Basic Classes : used classes are derived from them */
|
|
|
|
/******************************************************/
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2008-11-24 06:53:43 +00:00
|
|
|
class DHEAD;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Class EDA_BaseStruct
|
|
|
|
* is a base class for most all the kicad significant classes, used in schematics and boards.
|
2007-10-31 17:47:44 +00:00
|
|
|
*/
|
|
|
|
class EDA_BaseStruct
|
2007-06-05 12:10:51 +00:00
|
|
|
{
|
2007-09-01 12:00:30 +00:00
|
|
|
private:
|
2007-10-31 17:47:44 +00:00
|
|
|
|
|
|
|
/**
|
2007-09-01 12:00:30 +00:00
|
|
|
* Run time identification, _keep private_ so it can never be changed after
|
|
|
|
* a constructor sets it. See comment near SetType() regarding virtual functions.
|
|
|
|
*/
|
2007-10-31 17:47:44 +00:00
|
|
|
KICAD_T m_StructType;
|
|
|
|
|
2008-11-24 06:53:43 +00:00
|
|
|
protected:
|
2007-08-04 04:42:49 +00:00
|
|
|
EDA_BaseStruct* Pnext; /* Linked list: Link (next struct) */
|
|
|
|
EDA_BaseStruct* Pback; /* Linked list: Link (previous struct) */
|
|
|
|
EDA_BaseStruct* m_Parent; /* Linked list: Link (parent struct) */
|
|
|
|
EDA_BaseStruct* m_Son; /* Linked list: Link (son struct) */
|
2008-11-24 06:53:43 +00:00
|
|
|
DHEAD* m_List; ///< which DLIST I am on.
|
2007-08-20 19:33:15 +00:00
|
|
|
|
2008-11-24 06:53:43 +00:00
|
|
|
|
|
|
|
public:
|
2007-08-24 03:40:04 +00:00
|
|
|
int m_Flags; // flags for editing and other misc. uses
|
2007-10-31 17:47:44 +00:00
|
|
|
#define IS_CHANGED (1 << 0)
|
|
|
|
#define IS_LINKED (1 << 1)
|
|
|
|
#define IN_EDIT (1 << 2)
|
|
|
|
#define IS_MOVED (1 << 3)
|
|
|
|
#define IS_NEW (1 << 4)
|
|
|
|
#define IS_RESIZED (1 << 5)
|
|
|
|
#define IS_DRAGGED (1 << 6)
|
|
|
|
#define IS_DELETED (1 << 7)
|
|
|
|
#define IS_WIRE_IMAGE (1 << 8)
|
|
|
|
#define STARTPOINT (1 << 9)
|
|
|
|
#define ENDPOINT (1 << 10)
|
|
|
|
#define SELECTED (1 << 11)
|
|
|
|
#define SELECTEDNODE (1 << 12) ///< flag indiquant que la structure a deja selectionnee
|
|
|
|
#define STRUCT_DELETED (1 << 13) ///< Bit flag de Status pour structures effacee
|
|
|
|
#define CANDIDATE (1 << 14) ///< flag indiquant que la structure est connectee
|
|
|
|
#define SKIP_STRUCT (1 << 15) ///< flag indiquant que la structure ne doit pas etre traitee
|
2008-03-13 21:18:05 +00:00
|
|
|
#define DO_NOT_DRAW (1 << 16) ///< Used to disable draw function
|
2008-11-24 06:53:43 +00:00
|
|
|
#define DRAW_ERASED (1 << 17) ///< draw in background color, used by classs TRACK in gerbview
|
|
|
|
|
|
|
|
|
|
|
|
EDA_BaseStruct* m_Image; /* Link to an image copy for undelete or abort command */
|
2007-10-31 17:47:44 +00:00
|
|
|
|
|
|
|
unsigned long m_TimeStamp; // Time stamp used for logical links
|
|
|
|
int m_Selected; /* Used by block commands, and selective editing */
|
2007-06-05 12:10:51 +00:00
|
|
|
|
|
|
|
private:
|
2007-10-31 17:47:44 +00:00
|
|
|
int m_Status;
|
2007-06-05 12:10:51 +00:00
|
|
|
|
|
|
|
private:
|
2007-08-30 22:20:52 +00:00
|
|
|
void InitVars();
|
2007-10-31 17:47:44 +00:00
|
|
|
|
2007-06-05 12:10:51 +00:00
|
|
|
|
|
|
|
public:
|
|
|
|
|
2007-08-24 15:10:46 +00:00
|
|
|
EDA_BaseStruct( EDA_BaseStruct* parent, KICAD_T idType );
|
2007-11-27 22:49:35 +00:00
|
|
|
EDA_BaseStruct( KICAD_T idType );
|
2007-08-04 04:42:49 +00:00
|
|
|
virtual ~EDA_BaseStruct() { };
|
2007-09-01 12:00:30 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Function Type
|
|
|
|
* returns the type of object. This attribute should never be changed after
|
|
|
|
* a constructor sets it, so there is no public "setter" method.
|
|
|
|
* @return KICAD_T - the type of object.
|
|
|
|
*/
|
2007-10-31 17:47:44 +00:00
|
|
|
KICAD_T Type() const { return m_StructType; }
|
|
|
|
|
|
|
|
|
2008-11-24 06:53:43 +00:00
|
|
|
EDA_BaseStruct* Next() const { return (EDA_BaseStruct*) Pnext; }
|
|
|
|
EDA_BaseStruct* Back() const { return (EDA_BaseStruct*) Pback; }
|
|
|
|
EDA_BaseStruct* GetParent() const { return m_Parent; }
|
|
|
|
EDA_BaseStruct* GetSon() const { return m_Son; }
|
|
|
|
DHEAD* GetList() const { return m_List; }
|
2007-10-31 17:47:44 +00:00
|
|
|
|
2008-11-24 06:53:43 +00:00
|
|
|
void SetNext( EDA_BaseStruct* aNext ) { Pnext = aNext; }
|
|
|
|
void SetBack( EDA_BaseStruct* aBack ) { Pback = aBack; }
|
|
|
|
void SetParent( EDA_BaseStruct* aParent ) { m_Parent = aParent; }
|
|
|
|
void SetSon( EDA_BaseStruct* aSon ) { m_Son = aSon; }
|
|
|
|
void SetList( DHEAD* aList ) { m_List = aList; }
|
2007-10-31 17:47:44 +00:00
|
|
|
|
2007-08-04 04:42:49 +00:00
|
|
|
/* Gestion de l'etat (status) de la structure (active, deleted..) */
|
2007-10-31 17:47:44 +00:00
|
|
|
|
2007-10-31 06:40:15 +00:00
|
|
|
int GetState( int type ) const
|
|
|
|
{
|
|
|
|
return m_Status & type;
|
|
|
|
}
|
|
|
|
|
2007-10-31 17:47:44 +00:00
|
|
|
|
2007-10-31 06:40:15 +00:00
|
|
|
void SetState( int type, int state )
|
|
|
|
{
|
|
|
|
if( state )
|
2007-10-31 17:47:44 +00:00
|
|
|
m_Status |= type; // state = ON or OFF
|
2007-10-31 06:40:15 +00:00
|
|
|
else
|
|
|
|
m_Status &= ~type;
|
|
|
|
}
|
2007-08-04 04:42:49 +00:00
|
|
|
|
2007-10-31 17:47:44 +00:00
|
|
|
|
2007-09-01 12:00:30 +00:00
|
|
|
int ReturnStatus() const { return m_Status; }
|
2007-08-04 04:42:49 +00:00
|
|
|
|
|
|
|
void SetStatus( int new_status )
|
|
|
|
{
|
|
|
|
m_Status = new_status;
|
|
|
|
}
|
|
|
|
|
2007-08-20 19:33:15 +00:00
|
|
|
/**
|
|
|
|
* Function Display_Infos
|
|
|
|
* has knowledge about the frame and how and where to put status information
|
|
|
|
* about this object into the frame's message panel.
|
|
|
|
* @param frame A WinEDA_DrawFrame in which to print status information.
|
2007-10-31 17:47:44 +00:00
|
|
|
*/
|
2007-08-20 19:33:15 +00:00
|
|
|
virtual void Display_Infos( WinEDA_DrawFrame* frame )
|
|
|
|
{
|
2007-10-31 17:47:44 +00:00
|
|
|
// derived classes may implement this
|
2007-08-20 19:33:15 +00:00
|
|
|
}
|
2007-10-31 17:47:44 +00:00
|
|
|
|
|
|
|
|
2007-08-08 03:50:44 +00:00
|
|
|
/**
|
|
|
|
* Function HitTest
|
|
|
|
* tests if the given wxPoint is within the bounds of this object.
|
|
|
|
* @param refPos A wxPoint to test
|
|
|
|
* @return bool - true if a hit, else false
|
|
|
|
*/
|
|
|
|
virtual bool HitTest( const wxPoint& refPos )
|
|
|
|
{
|
|
|
|
return false; // derived classes should override this function
|
|
|
|
}
|
|
|
|
|
2008-03-05 22:40:52 +00:00
|
|
|
/**
|
|
|
|
* Function HitTest (overlayed)
|
|
|
|
* tests if the given EDA_Rect intersect this object.
|
|
|
|
* For now, an ending point must be inside this rect.
|
|
|
|
* @param refArea : the given EDA_Rect
|
|
|
|
* @return bool - true if a hit, else false
|
|
|
|
*/
|
2008-01-06 12:43:57 +00:00
|
|
|
virtual bool HitTest( EDA_Rect& refArea )
|
|
|
|
{
|
|
|
|
return false; // derived classes should override this function
|
|
|
|
}
|
|
|
|
|
2008-03-15 04:18:32 +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.
|
|
|
|
*/
|
|
|
|
virtual EDA_Rect GetBoundingBox()
|
|
|
|
{
|
2008-03-20 01:50:21 +00:00
|
|
|
#if defined (DEBUG)
|
2008-03-30 09:46:14 +00:00
|
|
|
printf("Missing GetBoundingBox()\n");
|
2008-03-20 01:50:21 +00:00
|
|
|
Show( 0, std::cout ); // tell me which classes still need GetBoundingBox support
|
|
|
|
#endif
|
2008-03-15 04:18:32 +00:00
|
|
|
// return a zero-sized box per default. derived classes should override this
|
|
|
|
EDA_Rect ret( wxPoint( 0, 0 ), wxSize( 0, 0 ) );
|
|
|
|
return ret;
|
|
|
|
}
|
2007-08-09 21:15:08 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Function IterateForward
|
2007-10-31 17:47:44 +00:00
|
|
|
* walks through the object tree calling the inspector() on each object
|
2007-08-09 21:15:08 +00:00
|
|
|
* type requested in scanTypes.
|
|
|
|
*
|
2007-10-31 17:47:44 +00:00
|
|
|
* @param listStart The first in a list of EDA_BaseStructs to iterate over.
|
|
|
|
* @param inspector Is an INSPECTOR to call on each object that is one of
|
2007-08-09 21:15:08 +00:00
|
|
|
* the requested scanTypes.
|
2007-10-31 17:47:44 +00:00
|
|
|
* @param testData Is an aid to testFunc, and should be sufficient to
|
2007-08-09 21:15:08 +00:00
|
|
|
* allow it to fully determine if an item meets the match criteria, but it
|
|
|
|
* may also be used to collect output.
|
2007-10-31 17:47:44 +00:00
|
|
|
* @param scanTypes A KICAD_T array that is EOT
|
2007-08-09 21:15:08 +00:00
|
|
|
* terminated, and provides both the order and interest level of of
|
|
|
|
* the types of objects to be iterated over.
|
2007-10-31 17:47:44 +00:00
|
|
|
* @return SEARCH_RESULT - SEARCH_QUIT if the called INSPECTOR returned
|
2007-08-09 21:15:08 +00:00
|
|
|
* SEARCH_QUIT, else SCAN_CONTINUE;
|
|
|
|
*/
|
2007-10-31 17:47:44 +00:00
|
|
|
static SEARCH_RESULT IterateForward( EDA_BaseStruct* listStart,
|
|
|
|
INSPECTOR* inspector,
|
|
|
|
const void* testData,
|
|
|
|
const KICAD_T scanTypes[] );
|
|
|
|
|
2007-08-09 21:15:08 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Function Visit
|
|
|
|
* may be re-implemented for each derived class in order to handle
|
|
|
|
* all the types given by its member data. Implementations should call
|
|
|
|
* inspector->Inspect() on types in scanTypes[], and may use IterateForward()
|
|
|
|
* to do so on lists of such data.
|
|
|
|
* @param inspector An INSPECTOR instance to use in the inspection.
|
|
|
|
* @param testData Arbitrary data used by the inspector.
|
2007-10-31 17:47:44 +00:00
|
|
|
* @param scanTypes Which KICAD_T types are of interest and the order
|
2007-08-09 21:15:08 +00:00
|
|
|
* is significant too, terminated by EOT.
|
|
|
|
* @return SEARCH_RESULT - SEARCH_QUIT if the Iterator is to stop the scan,
|
|
|
|
* else SCAN_CONTINUE, and determined by the inspector.
|
|
|
|
*/
|
2007-10-31 17:47:44 +00:00
|
|
|
virtual SEARCH_RESULT Visit( INSPECTOR* inspector, const void* testData,
|
|
|
|
const KICAD_T scanTypes[] );
|
|
|
|
|
2007-08-09 21:15:08 +00:00
|
|
|
|
2007-08-07 06:21:19 +00:00
|
|
|
/**
|
|
|
|
* Function GetClass
|
|
|
|
* returns the class name.
|
|
|
|
* @return wxString
|
|
|
|
*/
|
|
|
|
virtual wxString GetClass() const
|
|
|
|
{
|
2007-10-31 17:47:44 +00:00
|
|
|
return wxT( "EDA_BaseStruct" );
|
2007-08-07 06:21:19 +00:00
|
|
|
}
|
|
|
|
|
2007-10-31 17:47:44 +00:00
|
|
|
|
2007-10-03 15:21:13 +00:00
|
|
|
/**
|
|
|
|
* Function DeleteStructList
|
2007-10-31 17:47:44 +00:00
|
|
|
* deletes each item in a linked list of EDA_BaseStructs, starting with
|
2007-10-03 15:21:13 +00:00
|
|
|
* "this" object.
|
|
|
|
*/
|
|
|
|
void DeleteStructList();
|
|
|
|
|
2007-10-31 17:47:44 +00:00
|
|
|
|
2007-11-27 22:49:35 +00:00
|
|
|
/**
|
|
|
|
* Function AddToChain
|
|
|
|
* adds this item just after laststruct in a linked list established
|
|
|
|
* by the Prev and Back pointers of my base EDA_BaseStruct.
|
|
|
|
* @deprecated
|
|
|
|
* @param laststruct The item to add after
|
|
|
|
*/
|
|
|
|
void AddToChain( EDA_BaseStruct* laststruct );
|
|
|
|
|
2008-03-05 22:40:52 +00:00
|
|
|
|
2007-10-31 17:47:44 +00:00
|
|
|
#if defined (DEBUG)
|
2007-09-13 11:28:58 +00:00
|
|
|
|
2007-08-06 02:02:39 +00:00
|
|
|
/**
|
|
|
|
* Function Show
|
|
|
|
* is used to output the object tree, currently for debugging only.
|
2007-10-31 17:47:44 +00:00
|
|
|
* @param nestLevel An aid to prettier tree indenting, and is the level
|
2007-08-06 02:02:39 +00:00
|
|
|
* of nesting of this object within the overall tree.
|
|
|
|
* @param os The ostream& to output to.
|
|
|
|
*/
|
2007-10-31 17:47:44 +00:00
|
|
|
virtual void Show( int nestLevel, std::ostream& os );
|
|
|
|
|
2007-08-06 20:26:59 +00:00
|
|
|
|
2007-10-31 17:47:44 +00:00
|
|
|
/**
|
2007-08-06 02:02:39 +00:00
|
|
|
* Function NestedSpace
|
|
|
|
* outputs nested space for pretty indenting.
|
|
|
|
* @param nestLevel The nest count
|
|
|
|
* @param os The ostream&, where to output
|
|
|
|
* @return std::ostream& - for continuation.
|
|
|
|
**/
|
2007-10-31 17:47:44 +00:00
|
|
|
static std::ostream& NestedSpace( int nestLevel, std::ostream& os );
|
2007-08-06 20:26:59 +00:00
|
|
|
|
2007-08-06 02:02:39 +00:00
|
|
|
#endif
|
2007-06-05 12:10:51 +00:00
|
|
|
};
|
|
|
|
|
2007-08-06 02:02:39 +00:00
|
|
|
|
2007-06-05 12:10:51 +00:00
|
|
|
// Text justify:
|
|
|
|
// Values -1,0,1 are used in computations, do not change them
|
|
|
|
typedef enum {
|
2007-08-04 04:42:49 +00:00
|
|
|
GR_TEXT_HJUSTIFY_LEFT = -1,
|
|
|
|
GR_TEXT_HJUSTIFY_CENTER = 0,
|
|
|
|
GR_TEXT_HJUSTIFY_RIGHT = 1
|
2007-06-05 12:10:51 +00:00
|
|
|
} GRTextHorizJustifyType;
|
|
|
|
|
2007-08-04 04:42:49 +00:00
|
|
|
|
2007-06-05 12:10:51 +00:00
|
|
|
typedef enum {
|
2007-08-04 04:42:49 +00:00
|
|
|
GR_TEXT_VJUSTIFY_TOP = -1,
|
|
|
|
GR_TEXT_VJUSTIFY_CENTER = 0,
|
|
|
|
GR_TEXT_VJUSTIFY_BOTTOM = 1
|
2007-06-05 12:10:51 +00:00
|
|
|
} GRTextVertJustifyType;
|
|
|
|
|
2007-08-04 04:42:49 +00:00
|
|
|
|
2007-06-05 12:10:51 +00:00
|
|
|
/* controle des remplissages a l'ecran (Segments textes...)*/
|
|
|
|
#define FILAIRE 0
|
2007-08-04 04:42:49 +00:00
|
|
|
#define FILLED 1
|
|
|
|
#define SKETCH 2
|
2007-06-05 12:10:51 +00:00
|
|
|
|
|
|
|
|
2007-08-08 08:01:06 +00:00
|
|
|
#define DEFAULT_SIZE_TEXT 60 /* default text height (in mils or 1/1000") */
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2008-10-06 05:44:29 +00:00
|
|
|
/**
|
|
|
|
* Class EDA_TextStruct
|
|
|
|
* is a basic class to handle texts (labels, texts on components or footprints ..)
|
2007-10-31 17:47:44 +00:00
|
|
|
* not used directly.
|
2008-10-06 05:44:29 +00:00
|
|
|
* The text classes are derived from EDA_BaseStruct and EDA_TextStruct
|
2007-10-31 17:47:44 +00:00
|
|
|
*/
|
2007-06-05 12:10:51 +00:00
|
|
|
class EDA_TextStruct
|
|
|
|
{
|
|
|
|
public:
|
2007-08-04 04:42:49 +00:00
|
|
|
wxString m_Text; /* text! */
|
|
|
|
wxPoint m_Pos; /* XY position of anchor text. */
|
|
|
|
wxSize m_Size; /* XY size of text */
|
2007-10-31 17:47:44 +00:00
|
|
|
int m_Width; /* text width */
|
2007-08-04 04:42:49 +00:00
|
|
|
int m_Orient; /* Orient in 0.1 degrees */
|
|
|
|
int m_Miroir; // Display Normal / mirror
|
2007-10-31 17:47:44 +00:00
|
|
|
int m_Attributs; /* flags (visible...) */
|
2007-08-04 04:42:49 +00:00
|
|
|
int m_CharType; /* normal, bold, italic ... */
|
2007-10-31 17:47:44 +00:00
|
|
|
int m_HJustify, m_VJustify; /* Horiz and Vert Justifications */
|
|
|
|
int m_ZoomLevelDrawable; /* zoom level to draw text.
|
2008-10-06 05:44:29 +00:00
|
|
|
* if zoom < m_ZoomLevelDrawable: the text is drawn as a single line
|
|
|
|
*/
|
2007-10-31 17:47:44 +00:00
|
|
|
int* m_TextDrawings; /* list of segments to draw, for the Draw function */
|
|
|
|
int m_TextDrawingsSize; /* segment count */
|
2007-06-05 12:10:51 +00:00
|
|
|
|
|
|
|
public:
|
2007-08-04 04:42:49 +00:00
|
|
|
EDA_TextStruct( const wxString& text = wxEmptyString );
|
2007-08-30 22:20:52 +00:00
|
|
|
virtual ~EDA_TextStruct();
|
|
|
|
void CreateDrawData();
|
2007-08-04 04:42:49 +00:00
|
|
|
|
2008-03-15 04:18:32 +00:00
|
|
|
int GetLength() const { return m_Text.Length(); };
|
2007-10-31 17:47:44 +00:00
|
|
|
|
2008-10-06 05:44:29 +00:00
|
|
|
/**
|
|
|
|
* Function Pitch
|
|
|
|
* @return distance between 2 characters
|
2007-10-31 17:47:44 +00:00
|
|
|
*/
|
|
|
|
int Pitch();
|
2008-10-06 05:44:29 +00:00
|
|
|
|
2007-08-04 04:42:49 +00:00
|
|
|
void Draw( WinEDA_DrawPanel* panel, wxDC* DC,
|
|
|
|
const wxPoint& offset, int color,
|
|
|
|
int draw_mode, int display_mode = FILAIRE, int anchor_color = -1 );
|
|
|
|
|
2007-08-04 20:05:54 +00:00
|
|
|
/**
|
|
|
|
* Function HitTest
|
|
|
|
* tests if the given wxPoint is within the bounds of this object.
|
2007-08-08 03:50:44 +00:00
|
|
|
* @param ref_pos A wxPoint to test
|
2007-08-04 20:05:54 +00:00
|
|
|
* @return bool - true if a hit, else false
|
|
|
|
*/
|
2007-08-08 03:50:44 +00:00
|
|
|
bool HitTest( const wxPoint& ref_pos );
|
2007-10-31 17:47:44 +00:00
|
|
|
|
|
|
|
/**
|
2008-01-06 12:43:57 +00:00
|
|
|
* Function HitTest (overlayed)
|
|
|
|
* tests if the given EDA_Rect intersect this object.
|
2008-03-05 22:40:52 +00:00
|
|
|
* For now, the anchor must be inside this rect.
|
2008-01-06 12:43:57 +00:00
|
|
|
* @param refArea : the given EDA_Rect
|
|
|
|
* @return bool - true if a hit, else false
|
|
|
|
*/
|
|
|
|
bool HitTest( EDA_Rect& refArea );
|
|
|
|
|
2008-03-05 22:40:52 +00:00
|
|
|
/**
|
2007-10-31 17:47:44 +00:00
|
|
|
* Function Len_Size
|
|
|
|
* Return the text lenght in internal units
|
|
|
|
*/
|
|
|
|
int Len_Size();
|
2007-06-05 12:10:51 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif /* BASE_STRUCT_H */
|