kicad/pcbnew/class_track.h

233 lines
7.0 KiB
C
Raw Normal View History

/*******************************************************************/
/* class_track.h: definition des structures de donnees type track */
/*******************************************************************/
#ifndef CLASS_TRACK_H
#define CLASS_TRACK_H
#include "base_struct.h"
/* Type des Vias (shape)*/
/* Forme des Vias ( parametre .shape ) */
2007-08-08 20:51:08 +00:00
#define VIA_NORMALE 3 /* type via : traversante (throught via) */
#define VIA_ENTERREE 2 /* type via : enterree ou aveugle (blind via) */
#define VIA_BORGNE 1 /* type via : borgne ou demi-traversante (buried via) */
#define VIA_NOT_DEFINED 0 /* reserved */
#define SQUARE_VIA 0x80000000 /* Flag pour forme carree */
/***/
2007-08-23 04:28:46 +00:00
class TRACK : public BOARD_ITEM
{
public:
2007-08-23 04:28:46 +00:00
int m_Width; // 0 = line, > 0 = tracks, bus ...
wxPoint m_Start; // Line start point
wxPoint m_End; // Line end point
2007-08-08 20:51:08 +00:00
int m_Shape; // vias: shape and type, Track = shape..
int m_Drill; // for vias: via drill (- 1 for default value)
2007-08-23 04:28:46 +00:00
BOARD_ITEM* start; // pointers on a connected item (pad or track)
BOARD_ITEM* end;
2007-08-08 20:51:08 +00:00
int m_NetCode; // Net number
int m_Sous_Netcode; /* In rastnest routines : for the current net,
* block number (number common to the current connected items found) */
2007-08-08 20:51:08 +00:00
// chain = 0 indique une connexion non encore traitee
int m_Param; // Auxiliary variable ( used in some computations )
2007-09-15 04:25:54 +00:00
protected:
TRACK( const TRACK& track ); // protected so Copy() is used instead.
2007-09-01 12:00:30 +00:00
2007-08-08 20:51:08 +00:00
public:
TRACK( BOARD_ITEM* StructFather, KICAD_T idtype = TYPETRACK );
2007-09-01 12:00:30 +00:00
/**
* Function Copy
* will copy this object whether it is a TRACK or a SEGVIA returning
* the corresponding type.
2007-09-15 04:25:54 +00:00
* @return - TRACK*, SEGVIA*, or SEGZONE*, declared as the least common
* demoninator: TRACK
2007-09-01 12:00:30 +00:00
*/
TRACK* Copy() const;
2007-08-08 20:51:08 +00:00
2007-09-01 12:00:30 +00:00
TRACK* Next() const { return (TRACK*) Pnext; }
2007-08-08 20:51:08 +00:00
2007-09-01 12:00:30 +00:00
TRACK* Back() const { return (TRACK*) Pback; }
2007-08-08 20:51:08 +00:00
/* supprime du chainage la structure Struct */
2007-08-30 22:20:52 +00:00
void UnLink();
2007-08-08 20:51:08 +00:00
// Read/write data
bool WriteTrackDescr( FILE* File );
2007-09-01 12:00:30 +00:00
/**
* Function Insert
* inserts a TRACK, SEGVIA or SEGZONE into its proper list, either at the
* list's front or immediately after the InsertPoint.
* If Insertpoint == NULL, then insert at the beginning of the proper list.
* If InsertPoint != NULL, then insert immediately after InsertPoint.
* TRACKs and SEGVIAs are put on the m_Track list, SEGZONE on the m_Zone list.
* @param InsertPoint See above
*/
void Insert( BOARD* Pcb, BOARD_ITEM* InsertPoint );
2007-08-08 20:51:08 +00:00
/* Recherche du meilleur point d'insertion */
TRACK* GetBestInsertPoint( BOARD* Pcb );
2007-09-11 04:13:51 +00:00
/* Copie d'un Element d'une chaine de n elements
TRACK* CopyList( int NbSegm = 1 ) const;
*/
2007-08-08 20:51:08 +00:00
/* Recherche du debut du net
* ( les elements sont classes par net_code croissant ) */
TRACK* GetStartNetCode( int NetCode );
/* Recherche de la fin du net */
TRACK* GetEndNetCode( int NetCode );
/* Display on screen: */
void Draw( WinEDA_DrawPanel* panel, wxDC* DC, int draw_mode );
/* divers */
2007-08-30 22:20:52 +00:00
int Shape() const { return m_Shape & 0xFF; }
2007-08-08 20:51:08 +00:00
2007-08-30 22:20:52 +00:00
int ReturnMaskLayer();
2007-08-08 20:51:08 +00:00
int IsPointOnEnds( const wxPoint& point, int min_dist = 0 );
2007-08-30 22:20:52 +00:00
bool IsNull(); // return TRUE if segment lenght = 0
2007-08-08 20:51:08 +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.
* Is virtual from EDA_BaseStruct.
2007-08-30 22:20:52 +00:00
* @param frame A WinEDA_DrawFrame in which to print status information.
*/
void Display_Infos( WinEDA_DrawFrame* frame );
2007-08-30 22:20:52 +00:00
/**
* Function Visit
* is re-implemented here because TRACKs and SEGVIAs are in the same list
* within BOARD. If that were not true, then we could inherit the
* version from EDA_BaseStruct. This one does not iterate through scanTypes
* but only looks at the first item in the list.
* @param inspector An INSPECTOR instance to use in the inspection.
* @param testData Arbitrary data used by the inspector.
* @param scanTypes Which KICAD_T types are of interest and the order
* 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.
*/
SEARCH_RESULT Visit( INSPECTOR* inspector, const void* testData,
const KICAD_T scanTypes[] );
2007-08-08 20:51:08 +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
*/
bool HitTest( const wxPoint& refPos );
/**
* Function GetClass
* returns the class name.
* @return wxString
*/
wxString GetClass() const
{
return wxT("TRACK");
}
#if defined(DEBUG)
2007-08-09 01:41:30 +00:00
/**
* Function Show
* is used to output the object tree, currently for debugging only.
* @param nestLevel An aid to prettier tree indenting, and is the level
* of nesting of this object within the overall tree.
* @param os The ostream& to output to.
*/
void Show( int nestLevel, std::ostream& os );
#endif
};
2007-09-01 12:00:30 +00:00
2007-08-08 20:51:08 +00:00
class SEGZONE : public TRACK
{
public:
2007-08-23 04:28:46 +00:00
SEGZONE( BOARD_ITEM* StructFather );
2007-08-08 20:51:08 +00:00
/**
* Function GetClass
* returns the class name.
* @return wxString
*/
wxString GetClass() const
{
return wxT("ZONE");
}
SEGZONE* Next() const { return (SEGZONE*) Pnext; }
};
2007-09-01 12:00:30 +00:00
2007-08-08 20:51:08 +00:00
class SEGVIA : public TRACK
{
public:
2007-08-23 04:28:46 +00:00
SEGVIA( BOARD_ITEM* StructFather );
2007-09-01 12:00:30 +00:00
SEGVIA( const SEGVIA& source ) :
TRACK( source )
{
}
2007-08-30 22:20:52 +00:00
/**
* Function IsOnLayer
* tests to see if this object is on the given layer. Is virtual
* from BOARD_ITEM. Tests the starting and ending range of layers for the
* via.
* @param aLayer The layer to test for.
* @return bool - true if on given layer, else false.
*/
bool IsOnLayer( int aLayer ) const;
2007-08-08 20:51:08 +00:00
void SetLayerPair( int top_layer, int bottom_layer );
2007-08-30 22:20:52 +00:00
void ReturnLayerPair( int* top_layer, int* bottom_layer ) const;
2007-08-08 20:51:08 +00:00
/**
* Function GetClass
* returns the class name.
* @return wxString
*/
wxString GetClass() const
{
return wxT("VIA");
}
#if defined(DEBUG)
/**
* Function Show
* is used to output the object tree, currently for debugging only.
* @param nestLevel An aid to prettier tree indenting, and is the level
* of nesting of this object within the overall tree.
* @param os The ostream& to output to.
*/
void Show( int nestLevel, std::ostream& os );
#endif
};
#endif /* CLASS_TRACK_H */