set eol-style native on new files

This commit is contained in:
raburton 2007-12-29 19:27:58 +00:00
parent 5eda8a52ce
commit e126042b1e
8 changed files with 4471 additions and 4471 deletions

File diff suppressed because it is too large Load Diff

View File

@ -1,177 +1,177 @@
// PolyLine.h ... definition of CPolyLine class // PolyLine.h ... definition of CPolyLine class
// //
// A polyline contains one or more contours, where each contour // A polyline contains one or more contours, where each contour
// is defined by a list of corners and side-styles // is defined by a list of corners and side-styles
// There may be multiple contours in a polyline. // There may be multiple contours in a polyline.
// The last contour may be open or closed, any others must be closed. // The last contour may be open or closed, any others must be closed.
// All of the corners and side-styles are concatenated into 2 arrays, // All of the corners and side-styles are concatenated into 2 arrays,
// separated by setting the end_contour flag of the last corner of // separated by setting the end_contour flag of the last corner of
// each contour. // each contour.
// //
// When used for copper areas, the first contour is the outer edge // When used for copper areas, the first contour is the outer edge
// of the area, subsequent ones are "holes" in the copper. // of the area, subsequent ones are "holes" in the copper.
// //
// If a CDisplayList pointer is provided, the polyline can draw itself // If a CDisplayList pointer is provided, the polyline can draw itself
#ifndef POLYLINE_H #ifndef POLYLINE_H
#define POLYLINE_H #define POLYLINE_H
#include <vector> #include <vector>
#include "defs-macros.h" #include "defs-macros.h"
#include "GenericPolygonClipperLibrary.h" #include "GenericPolygonClipperLibrary.h"
#include "php_polygon.h" #include "php_polygon.h"
#include "php_polygon_vertex.h" #include "php_polygon_vertex.h"
#include "PolyLine2Kicad.h" #include "PolyLine2Kicad.h"
#include "freepcb_ids.h" #include "freepcb_ids.h"
#include "freepcbDisplayList.h" #include "freepcbDisplayList.h"
#include "math_for_graphics.h" #include "math_for_graphics.h"
class CSegment { class CSegment {
public: public:
int xi, yi, xf, yf; int xi, yi, xf, yf;
CSegment() {}; CSegment() {};
CSegment(int x0, int y0, int x1, int y1) { CSegment(int x0, int y0, int x1, int y1) {
xi = x0; yi = y0; xf = x1; yf = y1; } xi = x0; yi = y0; xf = x1; yf = y1; }
}; };
class CArc { class CArc {
public: public:
enum{ MAX_STEP = 50*25400 }; // max step is 20 mils enum{ MAX_STEP = 50*25400 }; // max step is 20 mils
enum{ MIN_STEPS = 18 }; // min step is 5 degrees enum{ MIN_STEPS = 18 }; // min step is 5 degrees
int style; int style;
int xi, yi, xf, yf; int xi, yi, xf, yf;
int n_steps; // number of straight-line segments in gpc_poly int n_steps; // number of straight-line segments in gpc_poly
BOOL bFound; BOOL bFound;
}; };
class CPolyPt class CPolyPt
{ {
public: public:
CPolyPt( int qx=0, int qy=0, BOOL qf=FALSE ) CPolyPt( int qx=0, int qy=0, BOOL qf=FALSE )
{ x=qx; y=qy; end_contour=qf; utility = 0; }; { x=qx; y=qy; end_contour=qf; utility = 0; };
int x; int x;
int y; int y;
BOOL end_contour; BOOL end_contour;
int utility; int utility;
}; };
class CPolyLine class CPolyLine
{ {
public: public:
enum { STRAIGHT, ARC_CW, ARC_CCW }; // side styles enum { STRAIGHT, ARC_CW, ARC_CCW }; // side styles
enum { NO_HATCH, DIAGONAL_FULL, DIAGONAL_EDGE }; // hatch styles enum { NO_HATCH, DIAGONAL_FULL, DIAGONAL_EDGE }; // hatch styles
enum { DEF_SIZE = 50, DEF_ADD = 50 }; // number of array elements to add at a time enum { DEF_SIZE = 50, DEF_ADD = 50 }; // number of array elements to add at a time
// constructors/destructor // constructors/destructor
CPolyLine( CDisplayList * dl ); CPolyLine( CDisplayList * dl );
CPolyLine(); CPolyLine();
~CPolyLine(); ~CPolyLine();
// functions for modifying polyline // functions for modifying polyline
void Start( int layer, int w, int sel_box, int x, int y, void Start( int layer, int w, int sel_box, int x, int y,
int hatch ); int hatch );
void AppendCorner( int x, int y, int style = STRAIGHT, BOOL bDraw=TRUE ); void AppendCorner( int x, int y, int style = STRAIGHT, BOOL bDraw=TRUE );
void InsertCorner( int ic, int x, int y ); void InsertCorner( int ic, int x, int y );
void DeleteCorner( int ic, BOOL bDraw=TRUE ); void DeleteCorner( int ic, BOOL bDraw=TRUE );
void MoveCorner( int ic, int x, int y ); void MoveCorner( int ic, int x, int y );
void Close( int style = STRAIGHT, BOOL bDraw=TRUE ); void Close( int style = STRAIGHT, BOOL bDraw=TRUE );
void RemoveContour( int icont ); void RemoveContour( int icont );
// drawing functions // drawing functions
void HighlightSide( int is ); void HighlightSide( int is );
void HighlightCorner( int ic ); void HighlightCorner( int ic );
void StartDraggingToInsertCorner( CDC * pDC, int ic, int x, int y); void StartDraggingToInsertCorner( CDC * pDC, int ic, int x, int y);
void StartDraggingToMoveCorner( CDC * pDC, int ic, int x, int y); void StartDraggingToMoveCorner( CDC * pDC, int ic, int x, int y);
void CancelDraggingToInsertCorner( int ic ); void CancelDraggingToInsertCorner( int ic );
void CancelDraggingToMoveCorner( int ic ); void CancelDraggingToMoveCorner( int ic );
void Undraw(); void Undraw();
void Draw( CDisplayList * dl = NULL ); void Draw( CDisplayList * dl = NULL );
void Hatch(); void Hatch();
void MakeVisible( BOOL visible = TRUE ); void MakeVisible( BOOL visible = TRUE );
void MoveOrigin( int x_off, int y_off ); void MoveOrigin( int x_off, int y_off );
// misc. functions // misc. functions
CRect GetBounds(); CRect GetBounds();
CRect GetCornerBounds(); CRect GetCornerBounds();
CRect GetCornerBounds( int icont ); CRect GetCornerBounds( int icont );
void Copy( CPolyLine * src ); void Copy( CPolyLine * src );
BOOL TestPointInside( int x, int y ); BOOL TestPointInside( int x, int y );
BOOL TestPointInsideContour( int icont, int x, int y ); BOOL TestPointInsideContour( int icont, int x, int y );
int TestIntersection( CPolyLine * poly ); int TestIntersection( CPolyLine * poly );
void AppendArc( int xi, int yi, int xf, int yf, int xc, int yc, int num ); void AppendArc( int xi, int yi, int xf, int yf, int xc, int yc, int num );
// access functions // access functions
int GetNumCorners(); int GetNumCorners();
int GetNumSides(); int GetNumSides();
int GetClosed(); int GetClosed();
int GetNumContours(); int GetNumContours();
int GetContour( int ic ); int GetContour( int ic );
int GetContourStart( int icont ); int GetContourStart( int icont );
int GetContourEnd( int icont ); int GetContourEnd( int icont );
int GetContourSize( int icont ); int GetContourSize( int icont );
int GetX( int ic ); int GetX( int ic );
int GetY( int ic ); int GetY( int ic );
int GetEndContour( int ic ); int GetEndContour( int ic );
int GetUtility( int ic ){ return corner[ic].utility; }; int GetUtility( int ic ){ return corner[ic].utility; };
void SetUtility( int ic, int utility ){ corner[ic].utility = utility; }; void SetUtility( int ic, int utility ){ corner[ic].utility = utility; };
int GetW(); int GetW();
int GetSideStyle( int is ); int GetSideStyle( int is );
id GetId(); id GetId();
int GetSelBoxSize(); int GetSelBoxSize();
CDisplayList * GetDisplayList(){ return m_dlist; }; CDisplayList * GetDisplayList(){ return m_dlist; };
int GetHatch(){ return m_HatchStyle; } int GetHatch(){ return m_HatchStyle; }
void SetHatch( int hatch ){ Undraw(); m_HatchStyle = hatch; Draw(); }; void SetHatch( int hatch ){ Undraw(); m_HatchStyle = hatch; Draw(); };
void SetX( int ic, int x ); void SetX( int ic, int x );
void SetY( int ic, int y ); void SetY( int ic, int y );
void SetEndContour( int ic, BOOL end_contour ); void SetEndContour( int ic, BOOL end_contour );
// void SetLayer( int layer ); // void SetLayer( int layer );
void SetW( int w ); void SetW( int w );
void SetSideStyle( int is, int style ); void SetSideStyle( int is, int style );
void SetSelBoxSize( int sel_box ); void SetSelBoxSize( int sel_box );
void SetDisplayList( CDisplayList * dl ); void SetDisplayList( CDisplayList * dl );
// GPC functions // GPC functions
int MakeGpcPoly( int icontour=0, std::vector<CArc> * arc_array=NULL ); int MakeGpcPoly( int icontour=0, std::vector<CArc> * arc_array=NULL );
int FreeGpcPoly(); int FreeGpcPoly();
gpc_polygon * GetGpcPoly(){ return m_gpc_poly; }; gpc_polygon * GetGpcPoly(){ return m_gpc_poly; };
int NormalizeWithGpc( std::vector<CPolyLine*> * pa=NULL, BOOL bRetainArcs=FALSE ); int NormalizeWithGpc( std::vector<CPolyLine*> * pa=NULL, BOOL bRetainArcs=FALSE );
int RestoreArcs( std::vector<CArc> * arc_array, std::vector<CPolyLine*> * pa=NULL ); int RestoreArcs( std::vector<CArc> * arc_array, std::vector<CPolyLine*> * pa=NULL );
CPolyLine * MakePolylineForPad( int type, int x, int y, int w, int l, int r, int angle ); CPolyLine * MakePolylineForPad( int type, int x, int y, int w, int l, int r, int angle );
void AddContourForPadClearance( int type, int x, int y, int w, void AddContourForPadClearance( int type, int x, int y, int w,
int l, int r, int angle, int fill_clearance, int l, int r, int angle, int fill_clearance,
int hole_w, int hole_clearance, BOOL bThermal=FALSE, int spoke_w=0 ); int hole_w, int hole_clearance, BOOL bThermal=FALSE, int spoke_w=0 );
void ClipGpcPolygon( gpc_op op, CPolyLine * poly ); void ClipGpcPolygon( gpc_op op, CPolyLine * poly );
// PHP functions // PHP functions
int MakePhpPoly(); int MakePhpPoly();
void FreePhpPoly(); void FreePhpPoly();
void ClipPhpPolygon( int php_op, CPolyLine * poly ); void ClipPhpPolygon( int php_op, CPolyLine * poly );
private: private:
CDisplayList * m_dlist; // display list CDisplayList * m_dlist; // display list
int m_layer; // layer to draw on int m_layer; // layer to draw on
int m_Width; // line width int m_Width; // line width
int m_sel_box; // corner selection box width/2 int m_sel_box; // corner selection box width/2
public: public:
std::vector <CPolyPt> corner; // array of points for corners std::vector <CPolyPt> corner; // array of points for corners
std::vector <int> side_style; // array of styles for sides std::vector <int> side_style; // array of styles for sides
private: private:
std::vector <dl_element*> dl_side; // graphic elements std::vector <dl_element*> dl_side; // graphic elements
std::vector <dl_element*> dl_side_sel; std::vector <dl_element*> dl_side_sel;
std::vector <dl_element*> dl_corner_sel; std::vector <dl_element*> dl_corner_sel;
public: public:
int m_HatchStyle; // hatch style, see enum above int m_HatchStyle; // hatch style, see enum above
std::vector <CSegment> m_HatchLines; // hatch lines std::vector <CSegment> m_HatchLines; // hatch lines
private: private:
gpc_polygon * m_gpc_poly; // polygon in gpc format gpc_polygon * m_gpc_poly; // polygon in gpc format
polygon * m_php_poly; polygon * m_php_poly;
BOOL bDrawn; BOOL bDrawn;
}; };
#endif // #ifndef POLYLINE_H #endif // #ifndef POLYLINE_H

View File

@ -1,94 +1,94 @@
// PolyLine.h ... definition of CPolyLine class // PolyLine.h ... definition of CPolyLine class
// //
// A polyline contains one or more contours, where each contour // A polyline contains one or more contours, where each contour
// is defined by a list of corners and side-styles // is defined by a list of corners and side-styles
// There may be multiple contours in a polyline. // There may be multiple contours in a polyline.
// The last contour may be open or closed, any others must be closed. // The last contour may be open or closed, any others must be closed.
// All of the corners and side-styles are concatenated into 2 arrays, // All of the corners and side-styles are concatenated into 2 arrays,
// separated by setting the end_contour flag of the last corner of // separated by setting the end_contour flag of the last corner of
// each contour. // each contour.
// //
// When used for copper areas, the first contour is the outer edge // When used for copper areas, the first contour is the outer edge
// of the area, subsequent ones are "holes" in the copper. // of the area, subsequent ones are "holes" in the copper.
// //
// If a CDisplayList pointer is provided, the polyline can draw itself // If a CDisplayList pointer is provided, the polyline can draw itself
#ifndef POLYLINE2KICAD_H #ifndef POLYLINE2KICAD_H
#define POLYLINE2KICAD_H #define POLYLINE2KICAD_H
#define PCBU_PER_MIL 10 #define PCBU_PER_MIL 10
#define MAX_LAYERS 32 #define MAX_LAYERS 32
#define NM_PER_MIL 10 // 25400 #define NM_PER_MIL 10 // 25400
// pad shapes // pad shapes
enum enum
{ {
PAD_NONE = 0, PAD_NONE = 0,
PAD_ROUND, PAD_ROUND,
PAD_SQUARE, PAD_SQUARE,
PAD_RECT, PAD_RECT,
PAD_RRECT, PAD_RRECT,
PAD_OVAL, PAD_OVAL,
PAD_OCTAGON PAD_OCTAGON
}; };
/* /*
enum enum
{ {
// visible layers // visible layers
LAY_SELECTION = 0, LAY_SELECTION = 0,
LAY_BACKGND, LAY_BACKGND,
LAY_VISIBLE_GRID, LAY_VISIBLE_GRID,
LAY_HILITE, LAY_HILITE,
LAY_DRC_ERROR, LAY_DRC_ERROR,
LAY_BOARD_OUTLINE, LAY_BOARD_OUTLINE,
LAY_RAT_LINE, LAY_RAT_LINE,
LAY_SILK_TOP, LAY_SILK_TOP,
LAY_SILK_BOTTOM, LAY_SILK_BOTTOM,
LAY_SM_TOP, LAY_SM_TOP,
LAY_SM_BOTTOM, LAY_SM_BOTTOM,
LAY_PAD_THRU, LAY_PAD_THRU,
LAY_TOP_COPPER, LAY_TOP_COPPER,
LAY_BOTTOM_COPPER, LAY_BOTTOM_COPPER,
// invisible layers // invisible layers
LAY_MASK_TOP = -100, LAY_MASK_TOP = -100,
LAY_MASK_BOTTOM = -101, LAY_MASK_BOTTOM = -101,
LAY_PASTE_TOP = -102, LAY_PASTE_TOP = -102,
LAY_PASTE_BOTTOM = -103 LAY_PASTE_BOTTOM = -103
}; };
*/ */
#define LAY_SELECTION 0 #define LAY_SELECTION 0
#define LAY_TOP_COPPER 0 #define LAY_TOP_COPPER 0
#define CDC wxDC #define CDC wxDC
class wxDC; class wxDC;
#if 0 #if 0
class dl_element; class dl_element;
class CDisplayList { class CDisplayList {
public: public:
void Set_visible(void*, int) {}; void Set_visible(void*, int) {};
int Get_x(void) { return 0;}; int Get_x(void) { return 0;};
int Get_y(void) { return 0;}; int Get_y(void) { return 0;};
void StopDragging(void) {}; void StopDragging(void) {};
void CancelHighLight(void) {}; void CancelHighLight(void) {};
void StartDraggingLineVertex(...) {}; void StartDraggingLineVertex(...) {};
void Add() {}; void Add() {};
}; };
#endif #endif
class CRect { class CRect {
public: public:
int left, right, top, bottom; int left, right, top, bottom;
}; };
class CPoint { class CPoint {
public: public:
int x, y; int x, y;
public: public:
CPoint(void) { x = y = 0;}; CPoint(void) { x = y = 0;};
CPoint(int i, int j) { x = i; y = j;}; CPoint(int i, int j) { x = i; y = j;};
}; };
#endif // #ifndef POLYLINE2KICAD_H #endif // #ifndef POLYLINE2KICAD_H

View File

@ -1,85 +1,85 @@
/* stuff for class CDisplayList */ /* stuff for class CDisplayList */
#include "PolyLine.h" #include "PolyLine.h"
dl_element * CDisplayList::Add( id id, void * ptr, int glayer, int gtype, int visible, dl_element * CDisplayList::Add( id id, void * ptr, int glayer, int gtype, int visible,
int w, int holew, int x, int y, int xf, int yf, int xo, int yo, int w, int holew, int x, int y, int xf, int yf, int xo, int yo,
int radius, int orig_layer ) int radius, int orig_layer )
{ {
return NULL; return NULL;
} }
dl_element * CDisplayList::AddSelector( id id, void * ptr, int glayer, int gtype, int visible, dl_element * CDisplayList::AddSelector( id id, void * ptr, int glayer, int gtype, int visible,
int w, int holew, int x, int y, int xf, int yf, int xo, int yo, int radius ) int w, int holew, int x, int y, int xf, int yf, int xo, int yo, int radius )
{ {
return NULL; return NULL;
} }
void CDisplayList::Set_visible( dl_element * el, int visible ) void CDisplayList::Set_visible( dl_element * el, int visible )
{ {
} }
int CDisplayList::StopDragging() int CDisplayList::StopDragging()
{ {
return 0; return 0;
} }
int CDisplayList::CancelHighLight() int CDisplayList::CancelHighLight()
{ {
return 0; return 0;
} }
void CDisplayList::Set_id( dl_element * el, id * id ) void CDisplayList::Set_id( dl_element * el, id * id )
{ {
} }
id CDisplayList::Remove( dl_element * element ) id CDisplayList::Remove( dl_element * element )
{ {
return 0; return 0;
} }
int CDisplayList::Get_w( dl_element * el ) int CDisplayList::Get_w( dl_element * el )
{ {
return 0; return 0;
} }
int CDisplayList::Get_x( dl_element * el ) int CDisplayList::Get_x( dl_element * el )
{ {
return 0; return 0;
} }
int CDisplayList::Get_y( dl_element * el ) int CDisplayList::Get_y( dl_element * el )
{ {
return 0; return 0;
} }
int CDisplayList::Get_xf( dl_element * el ) int CDisplayList::Get_xf( dl_element * el )
{ {
return 0; return 0;
} }
int CDisplayList::Get_yf( dl_element * el ) int CDisplayList::Get_yf( dl_element * el )
{ {
return 0; return 0;
} }
int CDisplayList::HighLight( int gtype, int x, int y, int xf, int yf, int w, int orig_layer ) int CDisplayList::HighLight( int gtype, int x, int y, int xf, int yf, int w, int orig_layer )
{ {
return 0; return 0;
} }
int CDisplayList::StartDraggingLineVertex( CDC * pDC, int x, int y, int xi, int yi, int CDisplayList::StartDraggingLineVertex( CDC * pDC, int x, int y, int xi, int yi,
int xf, int yf, int xf, int yf,
int layer1, int layer2, int w1, int w2, int layer1, int layer2, int w1, int w2,
int style1, int style2, int style1, int style2,
int layer_no_via, int via_w, int via_holew, int dir, int layer_no_via, int via_w, int via_holew, int dir,
int crosshair ) int crosshair )
{ {
return 0; return 0;
} }
int CDisplayList::StartDraggingArc( CDC * pDC, int style, int x, int y, int xi, int yi, int CDisplayList::StartDraggingArc( CDC * pDC, int style, int x, int y, int xi, int yi,
int layer, int w, int crosshair ) int layer, int w, int crosshair )
{ {
return 0; return 0;
} }

View File

@ -1,269 +1,269 @@
// DisplayList.h : header file for CDisplayList class // DisplayList.h : header file for CDisplayList class
// //
#ifndef FP_DISPLAY_LIST_H #ifndef FP_DISPLAY_LIST_H
#define FP_DISPLAY_LIST_H #define FP_DISPLAY_LIST_H
//#define DL_MAX_LAYERS 32 //#define DL_MAX_LAYERS 32
#define DL_MAGIC 2674 #define DL_MAGIC 2674
#define PCBU_PER_WU 25400 // conversion from PCB units to world units #define PCBU_PER_WU 25400 // conversion from PCB units to world units
// graphics element types // graphics element types
enum enum
{ {
DL_NONE = 0, DL_NONE = 0,
DL_LINE, // line segment with round end-caps DL_LINE, // line segment with round end-caps
DL_CIRC, // filled circle DL_CIRC, // filled circle
DL_HOLLOW_CIRC, // circle outline DL_HOLLOW_CIRC, // circle outline
DL_DONUT, // annulus DL_DONUT, // annulus
DL_SQUARE, // filled square DL_SQUARE, // filled square
DL_RECT, // filled rectangle DL_RECT, // filled rectangle
DL_RRECT, // filled rounded rectangle DL_RRECT, // filled rounded rectangle
DL_OVAL, // filled oval DL_OVAL, // filled oval
DL_OCTAGON, // filled octagon DL_OCTAGON, // filled octagon
DL_HOLE, // hole, shown as circle DL_HOLE, // hole, shown as circle
DL_HOLLOW_RECT, // rectangle outline DL_HOLLOW_RECT, // rectangle outline
DL_RECT_X, // rectangle outline with X DL_RECT_X, // rectangle outline with X
DL_POINT, // shape to highlight a point DL_POINT, // shape to highlight a point
DL_ARC_CW, // arc with clockwise curve DL_ARC_CW, // arc with clockwise curve
DL_ARC_CCW, // arc with counter-clockwise curve DL_ARC_CCW, // arc with counter-clockwise curve
DL_X // X DL_X // X
}; };
// dragging line shapes // dragging line shapes
enum enum
{ {
DS_NONE = 0, DS_NONE = 0,
DS_LINE_VERTEX, // vertex between two lines DS_LINE_VERTEX, // vertex between two lines
DS_LINE, // line DS_LINE, // line
DS_ARC_STRAIGHT, // straight line (used when drawing polylines) DS_ARC_STRAIGHT, // straight line (used when drawing polylines)
DS_ARC_CW, // clockwise arc (used when drawing polylines) DS_ARC_CW, // clockwise arc (used when drawing polylines)
DS_ARC_CCW // counterclockwise arc (used when drawing polylines) DS_ARC_CCW // counterclockwise arc (used when drawing polylines)
}; };
// styles of line segment when dragging line or line vertex // styles of line segment when dragging line or line vertex
enum enum
{ {
DSS_STRAIGHT = 100, // straight line DSS_STRAIGHT = 100, // straight line
DSS_ARC_CW, // clockwise arc DSS_ARC_CW, // clockwise arc
DSS_ARC_CCW // counterclockwise arc DSS_ARC_CCW // counterclockwise arc
}; };
// inflection modes for DS_LINE and DS_LINE_VERTEX // inflection modes for DS_LINE and DS_LINE_VERTEX
enum enum
{ {
IM_NONE = 0, IM_NONE = 0,
IM_90_45, IM_90_45,
IM_45_90, IM_45_90,
IM_90 IM_90
}; };
class CDisplayList; class CDisplayList;
// this structure contains an element of the display list // this structure contains an element of the display list
class dl_element class dl_element
{ {
friend class CDisplayList; friend class CDisplayList;
public: public:
CDisplayList * dlist; CDisplayList * dlist;
int magic; int magic;
dl_element * prev; dl_element * prev;
dl_element * next; dl_element * next;
id m_id; // identifier (see ids.h) id m_id; // identifier (see ids.h)
void * ptr; // pointer to object drawing this element void * ptr; // pointer to object drawing this element
int gtype; // type of primitive int gtype; // type of primitive
int visible; // 0 to hide int visible; // 0 to hide
//private: //private:
int sel_vert; // for selection rectangles, 1 if part is vertical int sel_vert; // for selection rectangles, 1 if part is vertical
int w; // width (for round or square shapes) int w; // width (for round or square shapes)
int holew; // hole width (for round holes) int holew; // hole width (for round holes)
int x_org, y_org; // x origin (for rotation, reflection, etc.) int x_org, y_org; // x origin (for rotation, reflection, etc.)
int x, y; // starting or center position of element int x, y; // starting or center position of element
int xf, yf; // opposite corner (for rectangle or line) int xf, yf; // opposite corner (for rectangle or line)
int radius; // radius of corners for DL_RRECT int radius; // radius of corners for DL_RRECT
int layer; // layer to draw on int layer; // layer to draw on
int orig_layer; // for elements on highlight layer, int orig_layer; // for elements on highlight layer,
// the original layer, the highlight will // the original layer, the highlight will
// only be drawn if this layer is visible // only be drawn if this layer is visible
}; };
class CDisplayList class CDisplayList
{ {
private: private:
// display-list parameters for each layer // display-list parameters for each layer
dl_element m_start[MAX_LAYERS], m_end[MAX_LAYERS]; dl_element m_start[MAX_LAYERS], m_end[MAX_LAYERS];
int m_rgb[MAX_LAYERS][3]; // layer colors int m_rgb[MAX_LAYERS][3]; // layer colors
BOOL m_vis[MAX_LAYERS]; // layer visibility flags BOOL m_vis[MAX_LAYERS]; // layer visibility flags
int m_layer_in_order[MAX_LAYERS]; // array of layers in draw order int m_layer_in_order[MAX_LAYERS]; // array of layers in draw order
int m_order_for_layer[MAX_LAYERS]; // draw order for each layer int m_order_for_layer[MAX_LAYERS]; // draw order for each layer
// window parameters // window parameters
int m_pcbu_per_wu; // i.e. nm per world unit int m_pcbu_per_wu; // i.e. nm per world unit
CRect m_client_r; // client rect (pixels) CRect m_client_r; // client rect (pixels)
CRect m_screen_r; // client rect (screen coords) CRect m_screen_r; // client rect (screen coords)
int m_pane_org_x; // left border of drawing pane (pixels) int m_pane_org_x; // left border of drawing pane (pixels)
int m_pane_org_y; // bottom border of drawing pane (pixels) int m_pane_org_y; // bottom border of drawing pane (pixels)
int m_bottom_pane_h; // height of bottom pane int m_bottom_pane_h; // height of bottom pane
CDC * memDC; // pointer to memory DC CDC * memDC; // pointer to memory DC
double m_scale; // world units per pixel double m_scale; // world units per pixel
int m_org_x; // world x-coord of left side of screen (world units) int m_org_x; // world x-coord of left side of screen (world units)
int m_org_y; // world y-coord of bottom of screen (world units) int m_org_y; // world y-coord of bottom of screen (world units)
int m_max_x; // world x_coord of right side of screen (world units) int m_max_x; // world x_coord of right side of screen (world units)
int m_max_y; // world y_coord of top of screen (world units) int m_max_y; // world y_coord of top of screen (world units)
int w_ext_x, w_ext_y; // window extents (world units) int w_ext_x, w_ext_y; // window extents (world units)
int v_ext_x, v_ext_y; // viewport extents (pixels) int v_ext_x, v_ext_y; // viewport extents (pixels)
double m_wu_per_pixel_x; // ratio w_ext_x/v_ext_x (world units per pixel) double m_wu_per_pixel_x; // ratio w_ext_x/v_ext_x (world units per pixel)
double m_wu_per_pixel_y; // ratio w_ext_y/v_ext_y (world units per pixel) double m_wu_per_pixel_y; // ratio w_ext_y/v_ext_y (world units per pixel)
double m_pcbu_per_pixel_x; double m_pcbu_per_pixel_x;
double m_pcbu_per_pixel_y; double m_pcbu_per_pixel_y;
// general dragging parameters // general dragging parameters
int m_drag_angle; // angle of rotation of selection rectangle (starts at 0) int m_drag_angle; // angle of rotation of selection rectangle (starts at 0)
int m_drag_side; // 0 = no change, 1 = switch to opposite int m_drag_side; // 0 = no change, 1 = switch to opposite
int m_drag_vert; // 1 if item being dragged is a vertical part int m_drag_vert; // 1 if item being dragged is a vertical part
// parameters for dragging polyline sides and trace segments // parameters for dragging polyline sides and trace segments
// that can be modified while dragging // that can be modified while dragging
int m_drag_flag; // 1 if dragging something int m_drag_flag; // 1 if dragging something
int m_drag_shape; // shape int m_drag_shape; // shape
int m_last_drag_shape; // last shape drawn int m_last_drag_shape; // last shape drawn
int m_drag_x; // last cursor position for dragged shape int m_drag_x; // last cursor position for dragged shape
int m_drag_y; int m_drag_y;
int m_drag_xi; // start of rubberband drag line int m_drag_xi; // start of rubberband drag line
int m_drag_yi; int m_drag_yi;
int m_drag_xf; // end of rubberband drag line int m_drag_xf; // end of rubberband drag line
int m_drag_yf; int m_drag_yf;
int m_drag_layer_1; // line layer int m_drag_layer_1; // line layer
int m_drag_w1; // line width int m_drag_w1; // line width
int m_drag_style1; // line style int m_drag_style1; // line style
int m_inflection_mode; // inflection mode int m_inflection_mode; // inflection mode
int m_last_inflection_mode; // last mode drawn int m_last_inflection_mode; // last mode drawn
// extra parameters when dragging vertex between 2 line segments // extra parameters when dragging vertex between 2 line segments
int m_drag_style2; int m_drag_style2;
int m_drag_layer_2; int m_drag_layer_2;
int m_drag_w2; int m_drag_w2;
// parameters used to draw leading via if necessary // parameters used to draw leading via if necessary
int m_drag_layer_no_via; int m_drag_layer_no_via;
int m_drag_via_w; int m_drag_via_w;
int m_drag_via_holew; int m_drag_via_holew;
int m_drag_via_drawn; int m_drag_via_drawn;
// arrays of lines and ratlines being dragged // arrays of lines and ratlines being dragged
// these can be rotated and flipped while being dragged // these can be rotated and flipped while being dragged
int m_drag_layer; // layer int m_drag_layer; // layer
int m_drag_max_lines; // max size of array for line segments int m_drag_max_lines; // max size of array for line segments
int m_drag_num_lines; // number of line segments to drag int m_drag_num_lines; // number of line segments to drag
CPoint * m_drag_line_pt; // array of relative coords for line endpoints CPoint * m_drag_line_pt; // array of relative coords for line endpoints
int m_drag_max_ratlines; // max size of ratline array int m_drag_max_ratlines; // max size of ratline array
int m_drag_num_ratlines; // number of ratlines to drag int m_drag_num_ratlines; // number of ratlines to drag
CPoint * m_drag_ratline_start_pt; // absolute coords for ratline start points CPoint * m_drag_ratline_start_pt; // absolute coords for ratline start points
CPoint * m_drag_ratline_end_pt; // relative coords for ratline endpoints CPoint * m_drag_ratline_end_pt; // relative coords for ratline endpoints
int m_drag_ratline_width; int m_drag_ratline_width;
// cursor parameters // cursor parameters
int m_cross_hairs; // 0 = none, 1 = cross-hairs, 2 = diagonals int m_cross_hairs; // 0 = none, 1 = cross-hairs, 2 = diagonals
CPoint m_cross_left, m_cross_right, m_cross_top, m_cross_bottom; // end-points CPoint m_cross_left, m_cross_right, m_cross_top, m_cross_bottom; // end-points
CPoint m_cross_topleft, m_cross_topright, m_cross_botleft, m_cross_botright; CPoint m_cross_topleft, m_cross_topright, m_cross_botleft, m_cross_botright;
// grid // grid
int m_visual_grid_on; int m_visual_grid_on;
double m_visual_grid_spacing; // in world units double m_visual_grid_spacing; // in world units
public: public:
CDisplayList( int pcbu_per_wu ); CDisplayList( int pcbu_per_wu );
~CDisplayList(); ~CDisplayList();
void SetVisibleGrid( BOOL on, double grid ); void SetVisibleGrid( BOOL on, double grid );
void SetMapping( CRect *client_r, CRect *screen_r, int pane_org_x, int pane_bottom_h, double scale, int org_x, int org_y ); void SetMapping( CRect *client_r, CRect *screen_r, int pane_org_x, int pane_bottom_h, double scale, int org_x, int org_y );
void SetDCToWorldCoords( CDC * pDC, CDC * mDC, int pcbu_org_x, int pcbu_org_y ); void SetDCToWorldCoords( CDC * pDC, CDC * mDC, int pcbu_org_x, int pcbu_org_y );
void SetLayerRGB( int layer, int r, int g, int b ); void SetLayerRGB( int layer, int r, int g, int b );
void SetLayerVisible( int layer, BOOL vis ); void SetLayerVisible( int layer, BOOL vis );
void SetLayerDrawOrder( int layer, int order ) void SetLayerDrawOrder( int layer, int order )
{ m_layer_in_order[order] = layer; m_order_for_layer[layer] = order; }; { m_layer_in_order[order] = layer; m_order_for_layer[layer] = order; };
dl_element * Add( id id, void * ptr, int glayer, int gtype, int visible, dl_element * Add( id id, void * ptr, int glayer, int gtype, int visible,
int w, int holew, int x, int y, int xf, int yf, int xo, int yo, int w, int holew, int x, int y, int xf, int yf, int xo, int yo,
int radius=0, int orig_layer=LAY_SELECTION ); int radius=0, int orig_layer=LAY_SELECTION );
dl_element * AddSelector( id id, void * ptr, int glayer, int gtype, int visible, dl_element * AddSelector( id id, void * ptr, int glayer, int gtype, int visible,
int w, int holew, int x, int y, int xf, int yf, int xo, int yo, int radius=0 ); int w, int holew, int x, int y, int xf, int yf, int xo, int yo, int radius=0 );
void RemoveAll(); void RemoveAll();
void RemoveAllFromLayer( int layer ); void RemoveAllFromLayer( int layer );
id Remove( dl_element * element ); id Remove( dl_element * element );
void Draw( CDC * pDC ); void Draw( CDC * pDC );
int HighLight( int gtype, int x, int y, int xf, int yf, int w, int orig_layer=LAY_SELECTION ); int HighLight( int gtype, int x, int y, int xf, int yf, int w, int orig_layer=LAY_SELECTION );
int CancelHighLight(); int CancelHighLight();
void * TestSelect( int x, int y, id * sel_id, int * layer, void * TestSelect( int x, int y, id * sel_id, int * layer,
id * exclude_id = NULL, void * exclude_ptr = NULL, id * include_id = NULL, id * exclude_id = NULL, void * exclude_ptr = NULL, id * include_id = NULL,
int n_include_ids=1 ); int n_include_ids=1 );
int StartDraggingArray( CDC * pDC, int x, int y, int vert, int layer, int crosshair = 1 ); int StartDraggingArray( CDC * pDC, int x, int y, int vert, int layer, int crosshair = 1 );
int StartDraggingRatLine( CDC * pDC, int x, int y, int xf, int yf, int layer, int StartDraggingRatLine( CDC * pDC, int x, int y, int xf, int yf, int layer,
int w, int crosshair = 1 ); int w, int crosshair = 1 );
int StartDraggingRectangle( CDC * pDC, int x, int y, int xi, int yi, int StartDraggingRectangle( CDC * pDC, int x, int y, int xi, int yi,
int xf, int yf, int vert, int layer ); int xf, int yf, int vert, int layer );
int StartDraggingLineVertex( CDC * pDC, int x, int y, int xi, int yi, int StartDraggingLineVertex( CDC * pDC, int x, int y, int xi, int yi,
int xf, int yf, int xf, int yf,
int layer1, int layer2, int w1, int w2, int layer1, int layer2, int w1, int w2,
int style1, int style2, int style1, int style2,
int layer_no_via, int via_w, int via_holew, int dir, int layer_no_via, int via_w, int via_holew, int dir,
int crosshair ); int crosshair );
int StartDraggingLine( CDC * pDC, int x, int y, int xi, int yi, int layer1, int w, int StartDraggingLine( CDC * pDC, int x, int y, int xi, int yi, int layer1, int w,
int layer_no_via, int via_w, int via_holew, int layer_no_via, int via_w, int via_holew,
int crosshair, int style, int inflection_mode ); int crosshair, int style, int inflection_mode );
int StartDraggingArc( CDC * pDC, int style, int x, int y, int xi, int yi, int StartDraggingArc( CDC * pDC, int style, int x, int y, int xi, int yi,
int layer, int w, int crosshair ); int layer, int w, int crosshair );
void SetDragArcStyle( int style ); void SetDragArcStyle( int style );
void Drag( CDC * pDC, int x, int y ); void Drag( CDC * pDC, int x, int y );
int StopDragging(); int StopDragging();
void ChangeRoutingLayer( CDC * pDC, int layer1, int layer2, int w ); void ChangeRoutingLayer( CDC * pDC, int layer1, int layer2, int w );
void IncrementDragAngle( CDC * pDC ); void IncrementDragAngle( CDC * pDC );
int MakeDragLineArray( int num_lines ); int MakeDragLineArray( int num_lines );
int MakeDragRatlineArray( int num_ratlines, int width ); int MakeDragRatlineArray( int num_ratlines, int width );
int AddDragLine( CPoint pi, CPoint pf ); int AddDragLine( CPoint pi, CPoint pf );
int AddDragRatline( CPoint pi, CPoint pf ); int AddDragRatline( CPoint pi, CPoint pf );
int GetDragAngle(); int GetDragAngle();
void FlipDragSide( CDC * pDC ); void FlipDragSide( CDC * pDC );
int GetDragSide(); int GetDragSide();
void SetUpCrosshairs( int type, int x, int y ); void SetUpCrosshairs( int type, int x, int y );
void SetInflectionMode( int mode ){ m_inflection_mode = mode; }; void SetInflectionMode( int mode ){ m_inflection_mode = mode; };
CPoint ScreenToPCB( CPoint point ); CPoint ScreenToPCB( CPoint point );
CPoint PCBToScreen( CPoint point ); CPoint PCBToScreen( CPoint point );
CPoint WindowToPCB( CPoint point ); CPoint WindowToPCB( CPoint point );
// set element parameters // set element parameters
void Set_gtype( dl_element * el, int gtype ); void Set_gtype( dl_element * el, int gtype );
void Set_visible( dl_element * el, int visible ); void Set_visible( dl_element * el, int visible );
void Set_sel_vert( dl_element * el, int sel_vert ); void Set_sel_vert( dl_element * el, int sel_vert );
void Set_w( dl_element * el, int w ); void Set_w( dl_element * el, int w );
void Set_holew( dl_element * el, int holew ); void Set_holew( dl_element * el, int holew );
void Set_x_org( dl_element * el, int x_org ); void Set_x_org( dl_element * el, int x_org );
void Set_y_org( dl_element * el, int y_org ); void Set_y_org( dl_element * el, int y_org );
void Set_x( dl_element * el, int x ); void Set_x( dl_element * el, int x );
void Set_y( dl_element * el, int y ); void Set_y( dl_element * el, int y );
void Set_xf( dl_element * el, int xf ); void Set_xf( dl_element * el, int xf );
void Set_yf( dl_element * el, int yf ); void Set_yf( dl_element * el, int yf );
void Set_id( dl_element * el, id * id ); void Set_id( dl_element * el, id * id );
void Set_layer( dl_element * el, int layer ); void Set_layer( dl_element * el, int layer );
void Set_radius( dl_element * el, int radius ); void Set_radius( dl_element * el, int radius );
void Move( dl_element * el, int dx, int dy ); void Move( dl_element * el, int dx, int dy );
// get element parameters // get element parameters
void * Get_ptr( dl_element * el ); void * Get_ptr( dl_element * el );
int Get_gtype( dl_element * el ); int Get_gtype( dl_element * el );
int Get_visible( dl_element * el ); int Get_visible( dl_element * el );
int Get_sel_vert( dl_element * el ); int Get_sel_vert( dl_element * el );
int Get_w( dl_element * el ); int Get_w( dl_element * el );
int Get_holew( dl_element * el ); int Get_holew( dl_element * el );
int Get_x_org( dl_element * el ); int Get_x_org( dl_element * el );
int Get_y_org( dl_element * el ); int Get_y_org( dl_element * el );
int Get_x( dl_element * el ); int Get_x( dl_element * el );
int Get_y( dl_element * el ); int Get_y( dl_element * el );
int Get_xf( dl_element * el ); int Get_xf( dl_element * el );
int Get_yf( dl_element * el ); int Get_yf( dl_element * el );
int Get_radius( dl_element * el ); int Get_radius( dl_element * el );
int Get_layer( dl_element * el ); int Get_layer( dl_element * el );
id Get_id( dl_element * el ); id Get_id( dl_element * el );
}; };
#endif // #ifndef FP_DISPLAY_LIST_H #endif // #ifndef FP_DISPLAY_LIST_H

View File

@ -1,118 +1,118 @@
// definition of ID structure used by FreePCB // definition of ID structure used by FreePCB
// //
#pragma once #pragma once
// struct id : this structure is used to identify PCB design elements // struct id : this structure is used to identify PCB design elements
// such as instances of parts or nets, and their subelements // such as instances of parts or nets, and their subelements
// Each element will have its own id. // Each element will have its own id.
// An id is attached to each item of the Display List so that it can // An id is attached to each item of the Display List so that it can
// be linked back to the PCB design element which drew it. // be linked back to the PCB design element which drew it.
// These are mainly used to identify items selected by clicking the mouse // These are mainly used to identify items selected by clicking the mouse
// //
// In general: // In general:
// id.type = type of PCB element (e.g. part, net, text) // id.type = type of PCB element (e.g. part, net, text)
// id.st = subelement type (e.g. part pad, net connection) // id.st = subelement type (e.g. part pad, net connection)
// id.i = subelement index (zero-based) // id.i = subelement index (zero-based)
// id.sst = subelement of subelement (e.g. net connection segment) // id.sst = subelement of subelement (e.g. net connection segment)
// id.ii = subsubelement index (zero-based) // id.ii = subsubelement index (zero-based)
// //
// For example, the id for segment 0 of connection 4 of net 12 would be // For example, the id for segment 0 of connection 4 of net 12 would be
// id = { ID_NET, 12, ID_CONNECT, 4, ID_SEG, 0 }; // id = { ID_NET, 12, ID_CONNECT, 4, ID_SEG, 0 };
// //
// //
class id { class id {
public: public:
// constructor // constructor
id( int qt=0, int qst=0, int qis=0, int qsst=0, int qiis=0 ) id( int qt=0, int qst=0, int qis=0, int qsst=0, int qiis=0 )
{ type=qt; st=qst; i=qis; sst=qsst; ii=qiis; } { type=qt; st=qst; i=qis; sst=qsst; ii=qiis; }
// operators // operators
friend int operator ==(id id1, id id2) friend int operator ==(id id1, id id2)
{ return (id1.type==id2.type { return (id1.type==id2.type
&& id1.st==id2.st && id1.st==id2.st
&& id1.sst==id2.sst && id1.sst==id2.sst
&& id1.i==id2.i && id1.i==id2.i
&& id1.ii==id2.ii ); && id1.ii==id2.ii );
} }
// member functions // member functions
void Clear() void Clear()
{ type=0; st=0; i=0; sst=0; ii=0; } { type=0; st=0; i=0; sst=0; ii=0; }
void Set( int qt, int qst=0, int qis=0, int qsst=0, int qiis=0 ) void Set( int qt, int qst=0, int qis=0, int qsst=0, int qiis=0 )
{ type=qt; st=qst; i=qis; sst=qsst; ii=qiis; } { type=qt; st=qst; i=qis; sst=qsst; ii=qiis; }
// member variables // member variables
unsigned int type; // type of element unsigned int type; // type of element
unsigned int st; // type of subelement unsigned int st; // type of subelement
unsigned int i; // index of subelement unsigned int i; // index of subelement
unsigned int sst; // type of subsubelement unsigned int sst; // type of subsubelement
unsigned int ii; // index of subsubelement unsigned int ii; // index of subsubelement
}; };
// these are constants used in ids // these are constants used in ids
// root types // root types
enum { enum {
ID_NONE = 0, // an undefined type or st (or an error) ID_NONE = 0, // an undefined type or st (or an error)
ID_BOARD, // board outline ID_BOARD, // board outline
ID_PART, // part ID_PART, // part
ID_NET, // net ID_NET, // net
ID_TEXT, // free-standing text ID_TEXT, // free-standing text
ID_DRC, // DRC error ID_DRC, // DRC error
ID_SM_CUTOUT, // cutout for solder mask ID_SM_CUTOUT, // cutout for solder mask
ID_MULTI // if multiple selections ID_MULTI // if multiple selections
}; };
// subtypes of ID_PART // subtypes of ID_PART
enum { enum {
ID_PAD = 1, // pad_stack in a part ID_PAD = 1, // pad_stack in a part
ID_SEL_PAD, // selection rectangle for pad_stack in a part ID_SEL_PAD, // selection rectangle for pad_stack in a part
ID_OUTLINE, // part outline ID_OUTLINE, // part outline
ID_REF_TXT, // text showing ref num for part ID_REF_TXT, // text showing ref num for part
ID_ORIG, // part origin ID_ORIG, // part origin
ID_SEL_RECT, // selection rectangle for part ID_SEL_RECT, // selection rectangle for part
ID_SEL_REF_TXT // selection rectangle for ref text ID_SEL_REF_TXT // selection rectangle for ref text
}; };
// subtypes of ID_TEXT // subtypes of ID_TEXT
enum { enum {
ID_SEL_TXT = 1, // selection rectangle ID_SEL_TXT = 1, // selection rectangle
ID_STROKE // stroke for text ID_STROKE // stroke for text
}; };
// subtypes of ID_NET // subtypes of ID_NET
enum { enum {
ID_ENTIRE_NET = 0, ID_ENTIRE_NET = 0,
ID_CONNECT, // connection ID_CONNECT, // connection
ID_AREA // copper area ID_AREA // copper area
}; };
// subtypes of ID_BOARD // subtypes of ID_BOARD
enum { enum {
ID_BOARD_OUTLINE = 1, ID_BOARD_OUTLINE = 1,
}; };
// subsubtypes of ID_NET.ID_CONNECT // subsubtypes of ID_NET.ID_CONNECT
enum { enum {
ID_ENTIRE_CONNECT = 0, ID_ENTIRE_CONNECT = 0,
ID_SEG, ID_SEG,
ID_SEL_SEG, ID_SEL_SEG,
ID_VERTEX, ID_VERTEX,
ID_SEL_VERTEX, ID_SEL_VERTEX,
ID_VIA ID_VIA
}; };
// subsubtypes of ID_NET.ID_AREA, ID_BOARD.ID_BOARD_OUTLINE, ID_SM_CUTOUT // subsubtypes of ID_NET.ID_AREA, ID_BOARD.ID_BOARD_OUTLINE, ID_SM_CUTOUT
enum { enum {
ID_SIDE = 1, ID_SIDE = 1,
ID_SEL_SIDE, ID_SEL_SIDE,
ID_SEL_CORNER, ID_SEL_CORNER,
ID_HATCH, ID_HATCH,
ID_PIN_X, // only used by ID_AREA ID_PIN_X, // only used by ID_AREA
ID_STUB_X // only used by ID_AREA ID_STUB_X // only used by ID_AREA
}; };
// subtypes of ID_DRC // subtypes of ID_DRC
// for subsubtypes, use types in DesignRules.h // for subsubtypes, use types in DesignRules.h
enum { enum {
ID_DRE = 1, ID_DRE = 1,
ID_SEL_DRE ID_SEL_DRE
}; };

File diff suppressed because it is too large Load Diff

View File

@ -1,104 +1,104 @@
// math stuff for graphics, from FreePCB // math stuff for graphics, from FreePCB
typedef struct PointTag typedef struct PointTag
{ {
double X,Y; double X,Y;
} Point; } Point;
typedef struct EllipseTag typedef struct EllipseTag
{ {
Point Center; /* ellipse center */ Point Center; /* ellipse center */
// double MaxRad,MinRad; /* major and minor axis */ // double MaxRad,MinRad; /* major and minor axis */
// double Phi; /* major axis rotation */ // double Phi; /* major axis rotation */
double xrad, yrad; // radii on x and y double xrad, yrad; // radii on x and y
double theta1, theta2; // start and end angle for arc double theta1, theta2; // start and end angle for arc
} EllipseKH; } EllipseKH;
const CPoint zero(0,0); const CPoint zero(0,0);
class my_circle { class my_circle {
public: public:
my_circle(){}; my_circle(){};
my_circle( int xx, int yy, int rr ) my_circle( int xx, int yy, int rr )
{ {
x = xx; x = xx;
y = yy; y = yy;
r = rr; r = rr;
}; };
int x, y, r; int x, y, r;
}; };
class my_rect { class my_rect {
public: public:
my_rect(){}; my_rect(){};
my_rect( int xi, int yi, int xf, int yf ) my_rect( int xi, int yi, int xf, int yf )
{ {
xlo = min(xi,xf); xlo = min(xi,xf);
xhi = max(xi,xf); xhi = max(xi,xf);
ylo = min(yi,yf); ylo = min(yi,yf);
yhi = max(yi,yf); yhi = max(yi,yf);
}; };
int xlo, ylo, xhi, yhi; int xlo, ylo, xhi, yhi;
}; };
class my_seg { class my_seg {
public: public:
my_seg(){}; my_seg(){};
my_seg( int xxi, int yyi, int xxf, int yyf ) my_seg( int xxi, int yyi, int xxf, int yyf )
{ {
xi = xxi; xi = xxi;
yi = yyi; yi = yyi;
xf = xxf; xf = xxf;
yf = yyf; yf = yyf;
}; };
int xi, yi, xf, yf; int xi, yi, xf, yf;
}; };
// math stuff for graphics // math stuff for graphics
BOOL Quadratic( double a, double b, double c, double *x1, double *x2 ); BOOL Quadratic( double a, double b, double c, double *x1, double *x2 );
void DrawArc( CDC * pDC, int shape, int xxi, int yyi, int xxf, int yyf, BOOL bMeta=FALSE ); void DrawArc( CDC * pDC, int shape, int xxi, int yyi, int xxf, int yyf, BOOL bMeta=FALSE );
void RotatePoint( CPoint *p, int angle, CPoint org ); void RotatePoint( CPoint *p, int angle, CPoint org );
void RotateRect( CRect *r, int angle, CPoint org ); void RotateRect( CRect *r, int angle, CPoint org );
int TestLineHit( int xi, int yi, int xf, int yf, int x, int y, double dist ); int TestLineHit( int xi, int yi, int xf, int yf, int x, int y, double dist );
int FindLineIntersection( double a, double b, double c, double d, double * x, double * y ); int FindLineIntersection( double a, double b, double c, double d, double * x, double * y );
int FindLineSegmentIntersection( double a, double b, int xi, int yi, int xf, int yf, int style, int FindLineSegmentIntersection( double a, double b, int xi, int yi, int xf, int yf, int style,
double * x1, double * y1, double * x2, double * y2, double * dist=NULL ); double * x1, double * y1, double * x2, double * y2, double * dist=NULL );
int FindSegmentIntersections( int xi, int yi, int xf, int yf, int style, int FindSegmentIntersections( int xi, int yi, int xf, int yf, int style,
int xi2, int yi2, int xf2, int yf2, int style2, int xi2, int yi2, int xf2, int yf2, int style2,
double x[]=NULL, double y[]=NULL ); double x[]=NULL, double y[]=NULL );
BOOL FindLineEllipseIntersections( double a, double b, double c, double d, double *x1, double *x2 ); BOOL FindLineEllipseIntersections( double a, double b, double c, double d, double *x1, double *x2 );
BOOL FindVerticalLineEllipseIntersections( double a, double b, double x, double *y1, double *y2 ); BOOL FindVerticalLineEllipseIntersections( double a, double b, double x, double *y1, double *y2 );
BOOL TestForIntersectionOfStraightLineSegments( int x1i, int y1i, int x1f, int y1f, BOOL TestForIntersectionOfStraightLineSegments( int x1i, int y1i, int x1f, int y1f,
int x2i, int y2i, int x2f, int y2f, int x2i, int y2i, int x2f, int y2f,
int * x=NULL, int * y=NULL, double * dist=NULL ); int * x=NULL, int * y=NULL, double * dist=NULL );
void GetPadElements( int type, int x, int y, int wid, int len, int radius, int angle, void GetPadElements( int type, int x, int y, int wid, int len, int radius, int angle,
int * nr, my_rect r[], int * nc, my_circle c[], int * ns, my_seg s[] ); int * nr, my_rect r[], int * nc, my_circle c[], int * ns, my_seg s[] );
int GetClearanceBetweenPads( int type1, int x1, int y1, int w1, int l1, int r1, int angle1, int GetClearanceBetweenPads( int type1, int x1, int y1, int w1, int l1, int r1, int angle1,
int type2, int x2, int y2, int w2, int l2, int r2, int angle2 ); int type2, int x2, int y2, int w2, int l2, int r2, int angle2 );
int GetClearanceBetweenSegmentAndPad( int x1, int y1, int x2, int y2, int w, int GetClearanceBetweenSegmentAndPad( int x1, int y1, int x2, int y2, int w,
int type, int x, int y, int wid, int len, int type, int x, int y, int wid, int len,
int radius, int angle ); int radius, int angle );
int GetClearanceBetweenSegments( int x1i, int y1i, int x1f, int y1f, int style1, int w1, int GetClearanceBetweenSegments( int x1i, int y1i, int x1f, int y1f, int style1, int w1,
int x2i, int y2i, int x2f, int y2f, int style2, int w2, int x2i, int y2i, int x2f, int y2f, int style2, int w2,
int max_cl, int * x, int * y ); int max_cl, int * x, int * y );
/** Function GetPointToLineSegmentDistance /** Function GetPointToLineSegmentDistance
* Get distance between line segment and point * Get distance between line segment and point
* @param x,y = point * @param x,y = point
* @param xi,yi and xf,yf = the end-points of the line segment * @param xi,yi and xf,yf = the end-points of the line segment
* @return the distance * @return the distance
*/ */
double GetPointToLineSegmentDistance( int x, int y, int xi, int yi, int xf, int yf ); double GetPointToLineSegmentDistance( int x, int y, int xi, int yi, int xf, int yf );
double GetPointToLineDistance( double a, double b, int x, int y, double * xp=NULL, double * yp=NULL ); double GetPointToLineDistance( double a, double b, int x, int y, double * xp=NULL, double * yp=NULL );
BOOL InRange( double x, double xi, double xf ); BOOL InRange( double x, double xi, double xf );
double Distance( int x1, int y1, int x2, int y2 ); double Distance( int x1, int y1, int x2, int y2 );
int GetArcIntersections( EllipseKH * el1, EllipseKH * el2, int GetArcIntersections( EllipseKH * el1, EllipseKH * el2,
double * x1=NULL, double * y1=NULL, double * x1=NULL, double * y1=NULL,
double * x2=NULL, double * y2=NULL ); double * x2=NULL, double * y2=NULL );
CPoint GetInflectionPoint( CPoint pi, CPoint pf, int mode ); CPoint GetInflectionPoint( CPoint pi, CPoint pf, int mode );
// quicksort (2-way or 3-way) // quicksort (2-way or 3-way)
void quickSort(int numbers[], int index[], int array_size); void quickSort(int numbers[], int index[], int array_size);
void q_sort(int numbers[], int index[], int left, int right); void q_sort(int numbers[], int index[], int left, int right);
void q_sort_3way( int a[], int b[], int left, int right ); void q_sort_3way( int a[], int b[], int left, int right );