2009-11-12 15:43:38 +00:00
|
|
|
/*******************************************************/
|
|
|
|
/* class_edge_module.h : EDGE_MODULE class definition. */
|
|
|
|
/*******************************************************/
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2011-01-14 17:43:30 +00:00
|
|
|
#include "richio.h"
|
|
|
|
|
2007-06-05 12:10:51 +00:00
|
|
|
class Pcb3D_GLCanvas;
|
|
|
|
|
|
|
|
|
2007-08-23 04:28:46 +00:00
|
|
|
class EDGE_MODULE : public BOARD_ITEM
|
2007-08-06 20:26:59 +00:00
|
|
|
{
|
|
|
|
public:
|
2007-08-23 04:28:46 +00:00
|
|
|
int m_Width; // 0 = line, > 0 = tracks, bus ...
|
2011-02-27 19:54:01 +00:00
|
|
|
wxPoint m_Start; // Line start point and circle and arc center
|
|
|
|
wxPoint m_End; // Line end point and circle and arc starting point
|
2008-02-22 17:34:11 +00:00
|
|
|
|
2009-11-12 15:43:38 +00:00
|
|
|
int m_Shape; // enum Track_Shapes
|
2010-07-11 16:24:44 +00:00
|
|
|
wxPoint m_Start0; // Start point or centre, relative to module origin, orient 0.
|
|
|
|
wxPoint m_End0; // End point, relative to module origin, orient 0.
|
2008-02-22 17:34:11 +00:00
|
|
|
|
2009-11-12 15:43:38 +00:00
|
|
|
int m_Angle; // Arcs: angle in 0.1 degrees
|
2008-02-22 17:34:11 +00:00
|
|
|
|
2010-07-11 16:24:44 +00:00
|
|
|
std::vector<wxPoint> m_PolyPoints; /* For polygons: number of points (> 2)
|
|
|
|
* Coord are relative to Origin, orient 0
|
|
|
|
* m_Start0 and m_End0 are not used for polygons
|
|
|
|
*/
|
2007-08-06 20:26:59 +00:00
|
|
|
|
|
|
|
public:
|
|
|
|
EDGE_MODULE( MODULE* parent );
|
|
|
|
EDGE_MODULE( EDGE_MODULE* edge );
|
|
|
|
~EDGE_MODULE();
|
|
|
|
|
2008-11-24 06:53:43 +00:00
|
|
|
EDGE_MODULE* Next() const { return (EDGE_MODULE*) Pnext; }
|
|
|
|
EDGE_MODULE* Back() const { return (EDGE_MODULE*) Pback; }
|
|
|
|
|
|
|
|
|
2007-12-01 03:42:52 +00:00
|
|
|
/**
|
|
|
|
* Function GetPosition
|
|
|
|
* returns the position of this object.
|
|
|
|
* @return const wxPoint& - The position of this object.
|
|
|
|
*/
|
|
|
|
wxPoint& GetPosition()
|
|
|
|
{
|
|
|
|
return m_Start;
|
|
|
|
}
|
2008-02-22 17:34:11 +00:00
|
|
|
|
2011-02-27 19:54:01 +00:00
|
|
|
/**
|
|
|
|
* Function GetStart
|
|
|
|
* returns the starting point of the graphic
|
|
|
|
*/
|
|
|
|
wxPoint GetStart() const;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Function GetEnd
|
|
|
|
* returns the ending point of the graphic
|
|
|
|
*/
|
|
|
|
wxPoint GetEnd() const;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Function GetRadius
|
|
|
|
* returns the radius of this item
|
|
|
|
* Has meaning only for arc and circle
|
|
|
|
*/
|
|
|
|
int GetRadius() const
|
|
|
|
{
|
|
|
|
double radius = hypot( (double) (m_End.x - m_Start.x), (double) (m_End.y - m_Start.y) );
|
|
|
|
return wxRound(radius);
|
|
|
|
}
|
2010-07-11 16:24:44 +00:00
|
|
|
|
|
|
|
void Copy( EDGE_MODULE* source ); // copy structure
|
2007-08-06 20:26:59 +00:00
|
|
|
|
2007-10-30 21:30:58 +00:00
|
|
|
/**
|
|
|
|
* Function Save
|
2007-10-31 14:14:21 +00:00
|
|
|
* writes the data structures for this object out to a FILE in "*.brd" format.
|
2007-10-30 21:30:58 +00:00
|
|
|
* @param aFile The FILE to write to.
|
|
|
|
* @return bool - true if success writing else false.
|
2008-02-22 17:34:11 +00:00
|
|
|
*/
|
2010-07-11 16:24:44 +00:00
|
|
|
bool Save( FILE* aFile ) const;
|
2008-02-22 17:34:11 +00:00
|
|
|
|
2011-01-14 17:43:30 +00:00
|
|
|
int ReadDescr( LINE_READER* aReader );
|
2007-08-06 20:26:59 +00:00
|
|
|
|
2010-07-11 16:24:44 +00:00
|
|
|
void SetDrawCoord();
|
2007-08-06 20:26:59 +00:00
|
|
|
|
|
|
|
/* drawing functions */
|
2011-01-21 19:30:59 +00:00
|
|
|
void Draw( EDA_DRAW_PANEL* panel, wxDC* DC,
|
2010-07-11 16:24:44 +00:00
|
|
|
int aDrawMode, const wxPoint& offset = ZeroOffset );
|
2007-08-08 20:51:08 +00:00
|
|
|
|
2010-07-11 16:24:44 +00:00
|
|
|
void Draw3D( Pcb3D_GLCanvas* glcanvas );
|
2007-08-20 19:33:15 +00:00
|
|
|
|
|
|
|
/**
|
2009-04-17 08:51:02 +00:00
|
|
|
* Function DisplayInfo
|
2007-08-20 19:33:15 +00:00
|
|
|
* has knowledge about the frame and how and where to put status information
|
|
|
|
* about this object into the frame's message panel.
|
2010-12-08 20:12:46 +00:00
|
|
|
* Is virtual from EDA_ITEM.
|
2011-01-21 19:30:59 +00:00
|
|
|
* @param frame A EDA_DRAW_FRAME in which to print status information.
|
2008-02-22 17:34:11 +00:00
|
|
|
*/
|
2011-01-21 19:30:59 +00:00
|
|
|
void DisplayInfo( EDA_DRAW_FRAME* frame );
|
2008-02-22 17:34:11 +00:00
|
|
|
|
|
|
|
|
2009-11-20 19:51:39 +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.
|
|
|
|
*/
|
2010-12-10 19:47:44 +00:00
|
|
|
virtual EDA_Rect GetBoundingBox() const;
|
2009-11-20 19:51:39 +00:00
|
|
|
|
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
|
|
|
|
*/
|
2010-07-11 16:24:44 +00:00
|
|
|
bool HitTest( const wxPoint& refPos );
|
2008-02-22 17:34:11 +00:00
|
|
|
|
2011-02-27 19:54:01 +00:00
|
|
|
/**
|
|
|
|
* Function HitTest (overlayed)
|
|
|
|
* tests if the given EDA_Rect intersect this object.
|
|
|
|
* For now, for segments and arcs, an ending point must be inside this rect.
|
|
|
|
* @param refArea the given EDA_Rect to test
|
|
|
|
* @return bool - true if a hit, else false
|
|
|
|
*/
|
|
|
|
bool HitTest( EDA_Rect& refArea );
|
|
|
|
|
2007-08-07 06:21:19 +00:00
|
|
|
/**
|
|
|
|
* Function GetClass
|
|
|
|
* returns the class name.
|
|
|
|
* @return wxString
|
|
|
|
*/
|
|
|
|
virtual wxString GetClass() const
|
|
|
|
{
|
2007-08-08 20:51:08 +00:00
|
|
|
return wxT( "MGRAPHIC" );
|
2010-07-11 16:24:44 +00:00
|
|
|
|
2007-08-07 06:21:19 +00:00
|
|
|
// return wxT( "EDGE" ); ?
|
|
|
|
}
|
|
|
|
|
2010-07-11 16:24:44 +00:00
|
|
|
|
2010-11-12 15:17:10 +00:00
|
|
|
/**
|
|
|
|
* Function TransformShapeWithClearanceToPolygon
|
2009-11-20 19:51:39 +00:00
|
|
|
* Convert the track shape to a closed polygon
|
|
|
|
* Used in filling zones calculations
|
|
|
|
* Circles and arcs are approximated by segments
|
|
|
|
* @param aCornerBuffer = a buffer to store the polygon
|
|
|
|
* @param aClearanceValue = the clearance around the pad
|
|
|
|
* @param aCircleToSegmentsCount = the number of segments to approximate a circle
|
|
|
|
* @param aCorrectionFactor = the correction to apply to circles radius to keep
|
|
|
|
* clearance when the circle is approxiamted by segment bigger or equal
|
|
|
|
* to the real clearance value (usually near from 1.0)
|
|
|
|
*/
|
2010-07-11 16:24:44 +00:00
|
|
|
void TransformShapeWithClearanceToPolygon(
|
2009-11-20 19:51:39 +00:00
|
|
|
std::vector <CPolyPt>& aCornerBuffer,
|
|
|
|
int aClearanceValue,
|
|
|
|
int
|
|
|
|
aCircleToSegmentsCount,
|
|
|
|
double aCorrectionFactor );
|
2008-05-05 19:53:31 +00:00
|
|
|
|
2007-09-13 11:28:58 +00:00
|
|
|
#if defined(DEBUG)
|
2010-07-11 16:24:44 +00:00
|
|
|
|
2007-08-06 20:26:59 +00:00
|
|
|
/**
|
|
|
|
* Function Show
|
|
|
|
* is used to output the object tree, currently for debugging only.
|
2008-02-22 17:34:11 +00:00
|
|
|
* @param nestLevel An aid to prettier tree indenting, and is the level
|
2007-08-06 20:26:59 +00:00
|
|
|
* of nesting of this object within the overall tree.
|
|
|
|
* @param os The ostream& to output to.
|
|
|
|
*/
|
|
|
|
virtual void Show( int nestLevel, std::ostream& os );
|
2008-02-22 17:34:11 +00:00
|
|
|
|
2007-08-06 20:26:59 +00:00
|
|
|
#endif
|
2007-06-05 12:10:51 +00:00
|
|
|
};
|