Commit 96bb90de authored by Dick Hollenbeck's avatar Dick Hollenbeck

kicad_plugin

parent 0498f265
......@@ -568,11 +568,14 @@ void EDA_3D_CANVAS::Draw3D_DrawSegment( DRAWSEGMENT* segment )
int color = g_ColorsSettings.GetLayerColor( layer );
SetGLColor( color );
w = segment->m_Width * g_Parm_3D_Visu.m_BoardScale;
x = segment->m_Start.x * g_Parm_3D_Visu.m_BoardScale;
y = segment->m_Start.y * g_Parm_3D_Visu.m_BoardScale;
xf = segment->m_End.x * g_Parm_3D_Visu.m_BoardScale;
yf = segment->m_End.y * g_Parm_3D_Visu.m_BoardScale;
w = segment->GetWidth() * g_Parm_3D_Visu.m_BoardScale;
x = segment->GetStart().x * g_Parm_3D_Visu.m_BoardScale;
y = segment->GetStart().y * g_Parm_3D_Visu.m_BoardScale;
xf = segment->GetEnd().x * g_Parm_3D_Visu.m_BoardScale;
yf = segment->GetEnd().y * g_Parm_3D_Visu.m_BoardScale;
if( layer == EDGE_N )
{
......@@ -581,10 +584,10 @@ void EDA_3D_CANVAS::Draw3D_DrawSegment( DRAWSEGMENT* segment )
glNormal3f( 0.0, 0.0, (layer == LAYER_N_BACK) ? -1.0 : 1.0 );
zpos = g_Parm_3D_Visu.m_LayerZcoord[layer];
switch( segment->m_Shape )
switch( segment->GetShape() )
{
case S_ARC:
Draw3D_ArcSegment( x, -y, xf, -yf, (double) segment->m_Angle, w, zpos );
Draw3D_ArcSegment( x, -y, xf, -yf, segment->GetAngle(), w, zpos );
break;
case S_CIRCLE:
......@@ -604,10 +607,10 @@ void EDA_3D_CANVAS::Draw3D_DrawSegment( DRAWSEGMENT* segment )
if( Get3DLayerEnable( layer ) )
{
switch( segment->m_Shape )
switch( segment->GetShape() )
{
case S_ARC:
Draw3D_ArcSegment( x, -y, xf, -yf, (double) segment->m_Angle, w, zpos );
Draw3D_ArcSegment( x, -y, xf, -yf, segment->GetAngle(), w, zpos );
break;
case S_CIRCLE:
......
......@@ -5,6 +5,19 @@ Please add newer entries at the top, list the date and your name with
email address.
2011-Dec-13 UPDATE Dick Hollenbeck <dick@softplc.com>
================================================================================
++common
* changed all the RotatePoint() functions in trigo.{h,cpp} to take a double as the
angle, which is still in tenths of degrees for now.
++pcbnew
* DRAWSEGMENT::GetStart() and GetEnd() do not operate for S_ARC like they used to.
They are now simply accessors for m_Start and m_End. Use DRAWSEGMENT::GetArcStart()
and GetArcEnd() and GetCenter() for arcs. specctra_export.cpp was the only
source file dependent on the old behavior.
* DIMENSION::m_Text is now contained, not dynamically allocated.
* more kicad_plugin work.
2011-Dec-9 UPDATE Dick Hollenbeck <dick@softplc.com>
================================================================================
++PCBNew
......
......@@ -215,7 +215,7 @@ int ArcTangente( int dy, int dx )
}
void RotatePoint( int* pX, int* pY, int angle )
void RotatePoint( int* pX, int* pY, double angle )
{
int tmp;
......@@ -248,7 +248,7 @@ void RotatePoint( int* pX, int* pY, int angle )
}
else
{
double fangle = DEG2RAD( (double) angle / 10.0 );
double fangle = DEG2RAD( angle / 10.0 );
double sinus = sin( fangle );
double cosinus = cos( fangle );
double fpx = (*pY * sinus ) + (*pX * cosinus );
......@@ -259,7 +259,7 @@ void RotatePoint( int* pX, int* pY, int angle )
}
void RotatePoint( int* pX, int* pY, int cx, int cy, int angle )
void RotatePoint( int* pX, int* pY, int cx, int cy, double angle )
{
int ox, oy;
......@@ -273,7 +273,7 @@ void RotatePoint( int* pX, int* pY, int cx, int cy, int angle )
}
void RotatePoint( wxPoint* point, int angle )
void RotatePoint( wxPoint* point, double angle )
{
int ox, oy;
......@@ -286,7 +286,7 @@ void RotatePoint( wxPoint* point, int angle )
}
void RotatePoint( wxPoint* point, const wxPoint& centre, int angle )
void RotatePoint( wxPoint* point, const wxPoint& centre, double angle )
{
int ox, oy;
......@@ -299,7 +299,7 @@ void RotatePoint( wxPoint* point, const wxPoint& centre, int angle )
}
void RotatePoint( double* pX, double* pY, double cx, double cy, int angle )
void RotatePoint( double* pX, double* pY, double cx, double cy, double angle )
{
double ox, oy;
......@@ -313,7 +313,7 @@ void RotatePoint( double* pX, double* pY, double cx, double cy, int angle )
}
void RotatePoint( double* pX, double* pY, int angle )
void RotatePoint( double* pX, double* pY, double angle )
{
double tmp;
......@@ -346,7 +346,7 @@ void RotatePoint( double* pX, double* pY, int angle )
}
else
{
double fangle = DEG2RAD( (double) angle / 10.0 );
double fangle = DEG2RAD( angle / 10.0 );
double sinus = sin( fangle );
double cosinus = cos( fangle );
......
......@@ -72,7 +72,7 @@ GERBER_DRAW_ITEM::GERBER_DRAW_ITEM( const GERBER_DRAW_ITEM& aSource ) :
m_Flags = aSource.m_Flags;
SetTimeStamp( aSource.m_TimeStamp );
SetStatus( aSource.ReturnStatus() );
SetStatus( aSource.GetStatus() );
m_Start = aSource.m_Start;
m_End = aSource.m_End;
m_Size = aSource.m_Size;
......
......@@ -256,9 +256,9 @@ void GBR_TO_PCB_EXPORTER::export_non_copper_item( GERBER_DRAW_ITEM* aGbrItem, in
DRAWSEGMENT* drawitem = new DRAWSEGMENT( m_pcb, PCB_LINE_T );
drawitem->SetLayer( aLayer );
drawitem->m_Start = aGbrItem->m_Start;
drawitem->m_End = aGbrItem->m_End;
drawitem->m_Width = aGbrItem->m_Size.x;
drawitem->SetStart( aGbrItem->m_Start );
drawitem->SetEnd( aGbrItem->m_End );
drawitem->SetWidth( aGbrItem->m_Size.x );
if( aGbrItem->m_Shape == GBR_ARC )
{
......@@ -267,20 +267,20 @@ void GBR_TO_PCB_EXPORTER::export_non_copper_item( GERBER_DRAW_ITEM* aGbrItem, in
double b = atan2( (double)( aGbrItem->m_End.y - aGbrItem->m_ArcCentre.y ),
(double)( aGbrItem->m_End.x - aGbrItem->m_ArcCentre.x ) );
drawitem->m_Shape = S_ARC;
drawitem->m_Angle = wxRound( (a - b) / M_PI * 1800.0 );
drawitem->m_Start = aGbrItem->m_ArcCentre;
drawitem->SetShape( S_ARC );
drawitem->SetAngle( wxRound( (a - b) / M_PI * 1800.0 ) );
drawitem->SetStart( aGbrItem->m_ArcCentre );
if( drawitem->m_Angle < 0 )
if( drawitem->GetAngle() < 0 )
{
NEGATE( drawitem->m_Angle );
drawitem->m_End = aGbrItem->m_Start;
drawitem->SetAngle( -drawitem->GetAngle() );
drawitem->SetEnd( aGbrItem->m_Start );
}
}
// Reverse Y axis:
NEGATE( drawitem->m_Start.y );
NEGATE( drawitem->m_End.y );
drawitem->SetStartY( -drawitem->GetStart().y );
drawitem->SetEndY( -drawitem->GetEnd().y );
m_pcb->Add( drawitem );
}
......
......@@ -444,7 +444,6 @@ public:
return m_Status & type;
}
void SetState( int type, int state )
{
if( state )
......@@ -453,13 +452,8 @@ public:
m_Status &= ~type;
}
int ReturnStatus() const { return m_Status; }
void SetStatus( int new_status )
{
m_Status = new_status;
}
int GetStatus() const { return m_Status; }
void SetStatus( int aStatus ) { m_Status = aStatus; }
void SetFlags( int aMask ) { m_Flags |= aMask; }
void ClearFlags( int aMask = EDA_ITEM_ALL_FLAGS ) { m_Flags &= ~aMask; }
......@@ -760,7 +754,7 @@ class EDA_TEXT
public:
wxString m_Text;
int m_Thickness; ///< pen size used to draw this text
int m_Orient; ///< Orient in 0.1 degrees
double m_Orient; ///< Orient in 0.1 degrees
wxPoint m_Pos; ///< XY position of anchor text.
wxSize m_Size; ///< XY size of text
bool m_Mirror; ///< true iff mirrored
......@@ -794,8 +788,8 @@ public:
*/
int GetThickness() const { return m_Thickness; };
void SetOrientation( int aOrientation ) { m_Orient = aOrientation; }
int GetOrientation() const { return m_Orient; }
void SetOrientation( double aOrientation ) { m_Orient = aOrientation; }
double GetOrientation() const { return m_Orient; }
void SetItalic( bool isItalic ) { m_Italic = isItalic; }
bool IsItalic() const { return m_Italic; }
......
......@@ -194,7 +194,7 @@ public:
* @param aRotCentre - the rotation point.
* @param aAngle - the rotation angle in 0.1 degree.
*/
virtual void Rotate( const wxPoint& aRotCentre, int aAngle )
virtual void Rotate( const wxPoint& aRotCentre, double aAngle )
{
wxMessageBox( wxT( "virtual BOARD_ITEM::Rotate used, should not occur" ), GetClass() );
}
......
......@@ -43,7 +43,7 @@ public:
* Function GetCount
* @return the number of items stored in list
*/
unsigned GetCount() { return m_List.size(); }
unsigned GetCount() const { return m_List.size(); }
/**
* Function GetModuleInfo
......
......@@ -10,29 +10,29 @@
* Calculate the new point of coord coord pX, pY,
* for a rotation center 0, 0, and angle in (1 / 10 degree)
*/
void RotatePoint( int *pX, int *pY, int angle );
void RotatePoint( int *pX, int *pY, double angle );
/*
* Calculate the new point of coord coord pX, pY,
* for a rotation center cx, cy, and angle in (1 / 10 degree)
*/
void RotatePoint( int *pX, int *pY, int cx, int cy, int angle );
void RotatePoint( int *pX, int *pY, int cx, int cy, double angle );
/*
* Calculates the new coord point point
* for a rotation angle in (1 / 10 degree)
*/
void RotatePoint( wxPoint* point, int angle );
void RotatePoint( wxPoint* point, double angle );
/*
* Calculates the new coord point point
* for a center rotation center and angle in (1 / 10 degree)
*/
void RotatePoint( wxPoint *point, const wxPoint & centre, int angle );
void RotatePoint( wxPoint *point, const wxPoint & centre, double angle );
void RotatePoint( double *pX, double *pY, int angle );
void RotatePoint( double *pX, double *pY, double angle );
void RotatePoint( double *pX, double *pY, double cx, double cy, int angle );
void RotatePoint( double *pX, double *pY, double cx, double cy, double angle );
/* Return the arc tangent of 0.1 degrees coord vector dx, dy
* between -1800 and 1800
......
......@@ -484,10 +484,10 @@ int PCB_EDIT_FRAME::GenPlaceBoard()
if( DrawSegm->GetLayer() != EDGE_N )
break;
TmpSegm.m_Start = DrawSegm->m_Start;
TmpSegm.m_End = DrawSegm->m_End;
TmpSegm.m_Shape = DrawSegm->m_Shape;
TmpSegm.m_Param = DrawSegm->m_Angle;
TmpSegm.SetStart( DrawSegm->GetStart() );
TmpSegm.SetEnd( DrawSegm->GetEnd() );
TmpSegm.SetShape( DrawSegm->GetShape() );
TmpSegm.m_Param = DrawSegm->GetAngle();
TraceSegmentPcb( GetBoard(), &TmpSegm, HOLE | CELL_is_EDGE,
Board.m_GridRouting, WRITE_CELL );
......
......@@ -483,10 +483,10 @@ void MoveMarkedItems( MODULE* module, wxPoint offset )
case PCB_MODULE_EDGE_T:
{
EDGE_MODULE* em = (EDGE_MODULE*) item;
em->m_Start += offset;
em->m_End += offset;
em->m_Start0 += offset;
em->m_End0 += offset;
em->SetStart( em->GetStart() + offset );
em->SetEnd( em->GetEnd() + offset );
em->SetStart0( em->GetStart0() + offset );
em->SetEnd0( em->GetEnd0() + offset );
}
break;
......@@ -537,20 +537,17 @@ void DeleteMarkedItems( MODULE* module )
}
/* Mirror marked items, refer to a Vertical axis at position offset
/** Mirror marked items, refer to a Vertical axis at position offset
*/
void MirrorMarkedItems( MODULE* module, wxPoint offset )
{
#define SETMIRROR( z ) (z) -= offset.x; (z) = -(z); (z) += offset.x;
EDA_ITEM* item;
wxPoint tmp;
if( module == NULL )
return;
D_PAD* pad = module->m_Pads;
for( ; pad != NULL; pad = pad->Next() )
for( D_PAD* pad = module->m_Pads; pad; pad = pad->Next() )
{
if( pad->m_Selected == 0 )
continue;
......@@ -566,9 +563,7 @@ void MirrorMarkedItems( MODULE* module, wxPoint offset )
NORMALIZE_ANGLE_POS( pad->m_Orient );
}
item = module->m_Drawings;
for( ; item != NULL; item = item->Next() )
for( EDA_ITEM* item = module->m_Drawings; item; item = item->Next() )
{
if( item->m_Selected == 0 )
continue;
......@@ -578,11 +573,18 @@ void MirrorMarkedItems( MODULE* module, wxPoint offset )
case PCB_MODULE_EDGE_T:
{
EDGE_MODULE* em = (EDGE_MODULE*) item;
SETMIRROR( em->m_Start.x );
em->m_Start0.x = em->m_Start.x;
SETMIRROR( em->m_End.x );
em->m_End0.x = em->m_End.x;
NEGATE( em->m_Angle );
tmp = em->GetStart0();
SETMIRROR( tmp.x );
em->SetStart0( tmp );
em->SetStartX( tmp.x );
tmp = em->GetEnd0();
SETMIRROR( tmp.x );
em->SetEnd0( tmp );
em->SetEndX( tmp.x );
em->SetAngle( -em->GetAngle() );
}
break;
......@@ -607,19 +609,16 @@ void MirrorMarkedItems( MODULE* module, wxPoint offset )
}
/* Rotate marked items, refer to a Vertical axis at position offset
/** Rotate marked items, refer to a Vertical axis at position offset
*/
void RotateMarkedItems( MODULE* module, wxPoint offset )
{
#define ROTATE( z ) RotatePoint( (&z), offset, 900 )
EDA_ITEM* item;
if( module == NULL )
return;
D_PAD* pad = module->m_Pads;
for( ; pad != NULL; pad = pad->Next() )
for( D_PAD* pad = module->m_Pads; pad; pad = pad->Next() )
{
if( pad->m_Selected == 0 )
continue;
......@@ -633,9 +632,7 @@ void RotateMarkedItems( MODULE* module, wxPoint offset )
NORMALIZE_ANGLE_POS( pad->m_Orient );
}
item = module->m_Drawings;
for( ; item != NULL; item = item->Next() )
for( EDA_ITEM* item = module->m_Drawings; item; item = item->Next() )
{
if( item->m_Selected == 0 )
continue;
......@@ -645,10 +642,16 @@ void RotateMarkedItems( MODULE* module, wxPoint offset )
case PCB_MODULE_EDGE_T:
{
EDGE_MODULE* em = (EDGE_MODULE*) item;
ROTATE( em->m_Start );
em->m_Start0 = em->m_Start;
ROTATE( em->m_End );
em->m_End0 = em->m_End;
wxPoint tmp = em->GetStart();
ROTATE( tmp );
em->SetStart( tmp );
em->SetStart0( tmp );
tmp = em->GetEnd();
ROTATE( tmp );
em->SetEnd( tmp );
em->SetEnd0( tmp );
}
break;
......
......@@ -234,11 +234,11 @@ void PlaceCells( BOARD* aPcb, int net_code, int flag )
if( tmpSegm.GetLayer() == EDGE_N )
tmpSegm.SetLayer( -1 );
tmpSegm.m_Start = edge->m_Start;
tmpSegm.m_End = edge->m_End;
tmpSegm.m_Shape = edge->m_Shape;
tmpSegm.m_Width = edge->m_Width;
tmpSegm.m_Param = edge->m_Angle;
tmpSegm.SetStart( edge->GetStart() );
tmpSegm.SetEnd( edge->GetEnd() );
tmpSegm.SetShape( edge->GetShape() );
tmpSegm.SetWidth( edge->GetWidth() );
tmpSegm.m_Param = edge->GetAngle();
tmpSegm.SetNet( -1 );
TraceSegmentPcb( aPcb, &tmpSegm, HOLE, marge, WRITE_CELL );
......@@ -271,11 +271,11 @@ void PlaceCells( BOARD* aPcb, int net_code, int flag )
type_cell |= CELL_is_EDGE;
}
tmpSegm.m_Start = DrawSegm->m_Start;
tmpSegm.m_End = DrawSegm->m_End;
tmpSegm.m_Shape = DrawSegm->m_Shape;
tmpSegm.m_Width = DrawSegm->m_Width;
tmpSegm.m_Param = DrawSegm->m_Angle;
tmpSegm.SetStart( DrawSegm->GetStart() );
tmpSegm.SetEnd( DrawSegm->GetEnd() );
tmpSegm.SetShape( DrawSegm->GetShape() );
tmpSegm.SetWidth( DrawSegm->GetWidth() );
tmpSegm.m_Param = DrawSegm->GetAngle();
tmpSegm.SetNet( -1 );
TraceSegmentPcb( aPcb, &tmpSegm, type_cell, marge, WRITE_CELL );
......
......@@ -203,10 +203,18 @@ void SwapData( BOARD_ITEM* aItem, BOARD_ITEM* aImage )
break;
case PCB_LINE_T:
#if 0
EXCHG( ( (DRAWSEGMENT*) aItem )->m_Start, ( (DRAWSEGMENT*) aImage )->m_Start );
EXCHG( ( (DRAWSEGMENT*) aItem )->m_End, ( (DRAWSEGMENT*) aImage )->m_End );
EXCHG( ( (DRAWSEGMENT*) aItem )->m_Width, ( (DRAWSEGMENT*) aImage )->m_Width );
EXCHG( ( (DRAWSEGMENT*) aItem )->m_Shape, ( (DRAWSEGMENT*) aImage )->m_Shape );
#else
{
DRAWSEGMENT tmp = *(DRAWSEGMENT*) aImage;
*aImage = *aItem;
*aItem = tmp;
}
#endif
break;
case PCB_TRACE_T:
......@@ -231,12 +239,12 @@ void SwapData( BOARD_ITEM* aItem, BOARD_ITEM* aImage )
EXCHG(itmp, atmp );
if( atmp > 0 )
track->SetDrillValue( atmp );
track->SetDrill( atmp );
else
track->SetDrillDefault();
if( itmp > 0 )
image->SetDrillValue( itmp );
image->SetDrill( itmp );
else
image->SetDrillDefault();
}
......@@ -256,10 +264,7 @@ void SwapData( BOARD_ITEM* aItem, BOARD_ITEM* aImage )
break;
case PCB_TARGET_T:
EXCHG( ( (PCB_TARGET*) aItem )->m_Pos, ( (PCB_TARGET*) aImage )->m_Pos );
EXCHG( ( (PCB_TARGET*) aItem )->m_Width, ( (PCB_TARGET*) aImage )->m_Width );
EXCHG( ( (PCB_TARGET*) aItem )->m_Size, ( (PCB_TARGET*) aImage )->m_Size );
EXCHG( ( (PCB_TARGET*) aItem )->m_Shape, ( (PCB_TARGET*) aImage )->m_Shape );
( (PCB_TARGET*) aItem )->Exchg( (PCB_TARGET*) aImage );
break;
case PCB_DIMENSION_T:
......@@ -268,12 +273,12 @@ void SwapData( BOARD_ITEM* aItem, BOARD_ITEM* aImage )
( (DIMENSION*) aItem )->SetText( ( (DIMENSION*) aImage )->GetText() );
( (DIMENSION*) aImage )->SetText( txt );
EXCHG( ( (DIMENSION*) aItem )->m_Width, ( (DIMENSION*) aImage )->m_Width );
EXCHG( ( (DIMENSION*) aItem )->m_Text->m_Size, ( (DIMENSION*) aImage )->m_Text->m_Size );
EXCHG( ( (DIMENSION*) aItem )->m_Text->m_Pos, ( (DIMENSION*) aImage )->m_Text->m_Pos );
EXCHG( ( (DIMENSION*) aItem )->m_Text->m_Thickness,
( (DIMENSION*) aImage )->m_Text->m_Thickness );
EXCHG( ( (DIMENSION*) aItem )->m_Text->m_Mirror,
( (DIMENSION*) aImage )->m_Text->m_Mirror );
EXCHG( ( (DIMENSION*) aItem )->m_Text.m_Size, ( (DIMENSION*) aImage )->m_Text.m_Size );
EXCHG( ( (DIMENSION*) aItem )->m_Text.m_Pos, ( (DIMENSION*) aImage )->m_Text.m_Pos );
EXCHG( ( (DIMENSION*) aItem )->m_Text.m_Thickness,
( (DIMENSION*) aImage )->m_Text.m_Thickness );
EXCHG( ( (DIMENSION*) aItem )->m_Text.m_Mirror,
( (DIMENSION*) aImage )->m_Text.m_Mirror );
}
break;
......
......@@ -115,25 +115,30 @@ NETCLASS* BOARD_CONNECTED_ITEM::GetNetClass() const
// It is important that this be implemented without any sequential searching.
// Simple array lookups should be fine, performance-wise.
BOARD* board = GetBoard();
// DO NOT use wxASSERT, because GetNetClass is called inside an OnPaint event
// and a call to wxASSERT can crash the application.
if( board == NULL ) // Should not occurs
if( board == NULL ) // Should not occur
{
#ifdef __WXDEBUG__
wxLogWarning(wxT("BOARD_CONNECTED_ITEM::GetNetClass():NULL board,type %d"), Type() );
wxLogWarning( wxT("BOARD_CONNECTED_ITEM::GetNetClass():NULL board,type %d"), Type() );
#endif
return NULL;
}
NETCLASS* netclass = NULL;
NETINFO_ITEM* net = board->FindNet( GetNet() );
int netcode = GetNet();
NETINFO_ITEM* net = board->FindNet( netcode );
if( net )
{
netclass = net->GetNetClass();
#ifdef __WXDEBUG__
if( netclass == NULL )
{
wxLogWarning(wxT("BOARD_CONNECTED_ITEM::GetNetClass():NULL netclass,type %d"), Type());
wxLogWarning( wxT("BOARD_CONNECTED_ITEM::GetNetClass():NULL netclass,type %d"), Type() );
}
#endif
}
......
......@@ -15,7 +15,7 @@ class D_PAD;
/**
* Class BOARD_CONNECTED_ITEM
* This is a base class derived from BOARD_ITEM for items that can be connected
* is a base class derived from BOARD_ITEM for items that can be connected
* and have a net, a netname, a clearance ...
* mainly: tracks, pads and zones
* Handle connection info
......@@ -88,9 +88,9 @@ public:
};
/*
* class BOARD_ITEM_LIST
* Handles a collection of BOARD_ITEM elements
/**
* Class BOARD_ITEM_LIST
* is a container for a list of BOARD_ITEMs.
*/
class BOARD_ITEM_LIST : public BOARD_ITEM
{
......@@ -203,4 +203,4 @@ public:
};
#endif /* BOARD_CONNECTED_ITEM_H */
#endif // BOARD_CONNECTED_ITEM_H
......@@ -20,46 +20,45 @@
DIMENSION::DIMENSION( BOARD_ITEM* aParent ) :
BOARD_ITEM( aParent, PCB_DIMENSION_T )
BOARD_ITEM( aParent, PCB_DIMENSION_T ),
m_Text( this )
{
m_Layer = DRAW_LAYER;
m_Width = 50;
m_Value = 0;
m_Shape = 0;
m_Unit = INCHES;
m_Text = new TEXTE_PCB( this );
}
DIMENSION::~DIMENSION()
{
delete m_Text;
}
void DIMENSION::SetPosition( const wxPoint& aPos )
{
m_Pos = aPos;
m_Text->SetPos( aPos );
m_Text.SetPos( aPos );
}
void DIMENSION::SetText( const wxString& aNewText )
{
m_Text->SetText( aNewText );
m_Text.SetText( aNewText );
}
const wxString DIMENSION::GetText() const
{
return m_Text->GetText();
return m_Text.GetText();
}
void DIMENSION::SetLayer( int aLayer )
{
m_Layer = aLayer;
m_Text->SetLayer( aLayer);
m_Text.SetLayer( aLayer);
}
......@@ -72,7 +71,7 @@ void DIMENSION::Copy( DIMENSION* source )
m_Shape = source->m_Shape;
m_Unit = source->m_Unit;
SetTimeStamp( GetNewTimeStamp() );
m_Text->Copy( source->m_Text );
m_Text.Copy( &source->m_Text );
m_crossBarOx = source->m_crossBarOx;
m_crossBarOy = source->m_crossBarOy;
......@@ -105,10 +104,10 @@ void DIMENSION::Copy( DIMENSION* source )
}
void DIMENSION::Move(const wxPoint& offset)
void DIMENSION::Move( const wxPoint& offset )
{
m_Pos += offset;
m_Text->m_Pos += offset;
m_Text.m_Pos += offset;
m_crossBarOx += offset.x;
m_crossBarOy += offset.y;
m_crossBarFx += offset.x;
......@@ -140,13 +139,13 @@ void DIMENSION::Move(const wxPoint& offset)
}
void DIMENSION::Rotate( const wxPoint& aRotCentre, int aAngle )
void DIMENSION::Rotate( const wxPoint& aRotCentre, double aAngle )
{
RotatePoint( &m_Pos, aRotCentre, aAngle );
RotatePoint( &m_Text->m_Pos, aRotCentre, aAngle );
RotatePoint( &m_Text.m_Pos, aRotCentre, aAngle );
int newAngle = m_Text->GetOrientation() + aAngle;
double newAngle = m_Text.GetOrientation() + aAngle;
if( newAngle >= 3600 )
newAngle -= 3600;
......@@ -154,7 +153,7 @@ void DIMENSION::Rotate( const wxPoint& aRotCentre, int aAngle )
if( newAngle > 900 && newAngle < 2700 )
newAngle -= 1800;
m_Text->SetOrientation( newAngle );
m_Text.SetOrientation( newAngle );
RotatePoint( &m_crossBarOx, &m_crossBarOy, aRotCentre.x, aRotCentre.y, aAngle );
RotatePoint( &m_crossBarFx, &m_crossBarFy, aRotCentre.x, aRotCentre.y, aAngle );
......@@ -180,21 +179,21 @@ void DIMENSION::Flip( const wxPoint& aCentre )
}
void DIMENSION::Mirror(const wxPoint& axis_pos)
void DIMENSION::Mirror( const wxPoint& axis_pos )
{
#define INVERT( pos ) (pos) = axis_pos.y - ( (pos) - axis_pos.y )
INVERT( m_Pos.y );
INVERT( m_Text->m_Pos.y );
INVERT( m_Text.m_Pos.y );
// invert angle
int newAngle = m_Text->GetOrientation();
double newAngle = m_Text.GetOrientation();
if( newAngle >= 3600 )
newAngle -= 3600;
if( newAngle > 900 && newAngle < 2700 )
newAngle -= 1800;
m_Text->SetOrientation( newAngle );
m_Text.SetOrientation( newAngle );
INVERT( m_crossBarOy );
INVERT( m_crossBarFy );
......@@ -217,25 +216,25 @@ void DIMENSION::AdjustDimensionDetails( bool aDoNotChangeText )
{
#define ARROW_SIZE 500 //size of arrows
int ii;
int mesure, deltax, deltay; /* value of the measure on X and Y axes */
int arrow_up_X = 0, arrow_up_Y = 0; /* coordinates of arrow line / */
int arrow_dw_X = 0, arrow_dw_Y = 0; /* coordinates of arrow line \ */
int hx, hy; /* dimension line interval */
float angle, angle_f;
int mesure, deltax, deltay; // value of the measure on X and Y axes
int arrow_up_X = 0, arrow_up_Y = 0; // coordinates of arrow line /
int arrow_dw_X = 0, arrow_dw_Y = 0; // coordinates of arrow line '\'
int hx, hy; // dimension line interval
double angle, angle_f;
wxString msg;
/* Init layer : */
m_Text->SetLayer( GetLayer() );
// Init layer :
m_Text.SetLayer( GetLayer() );
/* calculate the size of the dimension (text + line above the text) */
ii = m_Text->m_Size.y +
m_Text->GetThickness() + (m_Width * 3);
// calculate the size of the dimension (text + line above the text)
ii = m_Text.m_Size.y +
m_Text.GetThickness() + (m_Width * 3);
deltax = m_featureLineDOx - m_featureLineGOx;
deltay = m_featureLineDOy - m_featureLineGOy;
// Calculate dimension value
mesure = wxRound(hypot( (double) deltax, (double) deltay ) );
mesure = wxRound( hypot( (double) deltax, (double) deltay ) );
if( deltax || deltay )
angle = atan2( (double) deltay, (double) deltax );
......@@ -302,11 +301,11 @@ void DIMENSION::AdjustDimensionDetails( bool aDoNotChangeText )
m_featureLineDFx = m_crossBarFx + hx;
m_featureLineDFy = m_crossBarFy + hy;
/* Calculate the better text position and orientation: */
m_Pos.x = m_Text->m_Pos.x = (m_crossBarFx + m_featureLineGFx) / 2;
m_Pos.y = m_Text->m_Pos.y = (m_crossBarFy + m_featureLineGFy) / 2;
// Calculate the better text position and orientation:
m_Pos.x = m_Text.m_Pos.x = (m_crossBarFx + m_featureLineGFx) / 2;
m_Pos.y = m_Text.m_Pos.y = (m_crossBarFy + m_featureLineGFy) / 2;
int newAngle = -(int) (angle * 1800 / M_PI);
double newAngle = -(angle * 1800 / M_PI);
if( newAngle < 0 )
newAngle += 3600;
......@@ -316,7 +315,7 @@ void DIMENSION::AdjustDimensionDetails( bool aDoNotChangeText )
if( newAngle > 900 && newAngle < 2700 )
newAngle -= 1800;
m_Text->SetOrientation( newAngle );
m_Text.SetOrientation( newAngle );
if( !aDoNotChangeText )
{
......@@ -334,7 +333,7 @@ void DIMENSION::Draw( EDA_DRAW_PANEL* panel, wxDC* DC, int mode_color, const wxP
ox = -offset.x;
oy = -offset.y;
m_Text->Draw( panel, DC, mode_color, offset );
m_Text.Draw( panel, DC, mode_color, offset );
BOARD * brd = GetBoard( );
......@@ -417,7 +416,7 @@ void DIMENSION::Draw( EDA_DRAW_PANEL* panel, wxDC* DC, int mode_color, const wxP
void DIMENSION::DisplayInfo( EDA_DRAW_FRAME* frame )
{
// for now, display only the text within the DIMENSION using class TEXTE_PCB.
m_Text->DisplayInfo( frame );
m_Text.DisplayInfo( frame );
}
......@@ -426,14 +425,14 @@ bool DIMENSION::HitTest( const wxPoint& aPoint )
int ux0, uy0;
int dx, dy, spot_cX, spot_cY;
if( m_Text && m_Text->TextHitTest( aPoint ) )
if( m_Text.TextHitTest( aPoint ) )
return true;
/* Locate SEGMENTS? */
// Locate SEGMENTS?
ux0 = m_crossBarOx;
uy0 = m_crossBarOy;
/* Recalculate coordinates with ux0, uy0 = origin. */
// Recalculate coordinates with ux0, uy0 = origin.
dx = m_crossBarFx - ux0;
dy = m_crossBarFy - uy0;
......@@ -533,7 +532,7 @@ EDA_RECT DIMENSION::GetBoundingBox() const
EDA_RECT bBox;
int xmin, xmax, ymin, ymax;
bBox = m_Text->GetTextBox( -1 );
bBox = m_Text.GetTextBox( -1 );
xmin = bBox.GetX();
xmax = bBox.GetRight();
ymin = bBox.GetY();
......
......@@ -3,8 +3,8 @@
* @brief DIMENSION class definition.
*/
#ifndef DIMENSION_H
#define DIMENSION_H
#ifndef DIMENSION_H_
#define DIMENSION_H_
#include "class_board_item.h"
......@@ -21,10 +21,10 @@ public:
int m_Width;
wxPoint m_Pos;
int m_Shape;
int m_Unit; /* 0 = inches, 1 = mm */
int m_Value; /* value of PCB dimensions. */
int m_Unit; /// 0 = inches, 1 = mm
int m_Value; /// value of PCB dimensions.
TEXTE_PCB* m_Text;
TEXTE_PCB m_Text;
int m_crossBarOx, m_crossBarOy, m_crossBarFx, m_crossBarFy;
int m_featureLineGOx, m_featureLineGOy, m_featureLineGFx, m_featureLineGFy;
int m_featureLineDOx, m_featureLineDOy, m_featureLineDFx, m_featureLineDFy;
......@@ -43,7 +43,7 @@ public:
void SetTextSize( const wxSize& aTextSize )
{
m_Text->SetSize( aTextSize );
m_Text.SetSize( aTextSize );
}
/**
......@@ -53,6 +53,12 @@ public:
*/
void SetLayer( int aLayer );
void SetShape( int aShape ) { m_Shape = aShape; }
int GetShape() const { return m_Shape; }
int GetWidth() const { return m_Width; }
void SetWidth( int aWidth ) { m_Width = aWidth; }
/**
* Function AdjustDimensionDetails
* Calculate coordinates of segments used to draw the dimension.
......@@ -90,7 +96,7 @@ public:
* @param aRotCentre - the rotation point.
* @param aAngle - the rotation angle in 0.1 degree.
*/
virtual void Rotate( const wxPoint& aRotCentre, int aAngle );
virtual void Rotate( const wxPoint& aRotCentre, double aAngle );
/**
* Function Flip
......@@ -151,4 +157,4 @@ public:
virtual BITMAP_DEF GetMenuImage() const { return add_dimension_xpm; }
};
#endif // #define DIMENSION_H
#endif // DIMENSION_H_
......@@ -31,31 +31,40 @@ DRAWSEGMENT::DRAWSEGMENT( BOARD_ITEM* aParent, KICAD_T idtype ) :
}
DRAWSEGMENT:: ~DRAWSEGMENT()
DRAWSEGMENT::~DRAWSEGMENT()
{
}
const DRAWSEGMENT& DRAWSEGMENT::operator = ( const DRAWSEGMENT& rhs )
{
// skip the linked list stuff, and parent
m_Type = rhs.m_Type;
m_Layer = rhs.m_Layer;
m_Width = rhs.m_Width;
m_Start = rhs.m_Start;
m_End = rhs.m_End;
m_Shape = rhs.m_Shape;
m_Angle = rhs.m_Angle;
m_TimeStamp = rhs.m_TimeStamp;
m_BezierC1 = rhs.m_BezierC1;
m_BezierC2 = rhs.m_BezierC1;
m_BezierPoints = rhs.m_BezierPoints;
return *this;
}
void DRAWSEGMENT::Copy( DRAWSEGMENT* source )
{
if( source == NULL )
if( source == NULL ) // who would do this?
return;
m_Type = source->m_Type;
m_Layer = source->m_Layer;
m_Width = source->m_Width;
m_Start = source->m_Start;
m_End = source->m_End;
m_Shape = source->m_Shape;
m_Angle = source->m_Angle;
SetTimeStamp( source->m_TimeStamp );
m_BezierC1 = source->m_BezierC1;
m_BezierC2 = source->m_BezierC1;
m_BezierPoints = source->m_BezierPoints;
*this = *source; // operator = ()
}
void DRAWSEGMENT::Rotate( const wxPoint& aRotCentre, int aAngle )
void DRAWSEGMENT::Rotate( const wxPoint& aRotCentre, double aAngle )
{
RotatePoint( &m_Start, aRotCentre, aAngle );
RotatePoint( &m_End, aRotCentre, aAngle );
......@@ -74,7 +83,26 @@ void DRAWSEGMENT::Flip( const wxPoint& aCentre )
}
wxPoint DRAWSEGMENT::GetStart() const
const wxPoint DRAWSEGMENT::GetArcEnd() const
{
wxPoint endPoint; // start of arc
switch( m_Shape )
{
case S_ARC:
// rotate the starting point of the arc, given by m_End, through the
// angle m_Angle to get the ending point of the arc.
// m_Start is the arc centre
endPoint = m_End; // m_End = start point of arc
RotatePoint( &endPoint, m_Start, -m_Angle );
}
return endPoint; // after rotation, the end of the arc.
}
/* use GetArcStart() now
const wxPoint DRAWSEGMENT::GetStart() const
{
switch( m_Shape )
{
......@@ -88,7 +116,7 @@ wxPoint DRAWSEGMENT::GetStart() const
}
wxPoint DRAWSEGMENT::GetEnd() const
const wxPoint DRAWSEGMENT::GetEnd() const
{
wxPoint endPoint; // start of arc
......@@ -108,6 +136,7 @@ wxPoint DRAWSEGMENT::GetEnd() const
return m_End;
}
}
*/
void DRAWSEGMENT::SetAngle( double aAngle )
......
......@@ -18,35 +18,33 @@ class MODULE;
class DRAWSEGMENT : public BOARD_ITEM
{
public:
int m_Width; // thickness of lines ...
wxPoint m_Start; // Line start point or Circle and Arc center
wxPoint m_End; // Line end point or circle and arc start point
protected:
int m_Width; ///< thickness of lines ...
wxPoint m_Start; ///< Line start point or Circle and Arc center
wxPoint m_End; ///< Line end point or circle and arc start point
int m_Shape; // Shape: line, Circle, Arc
int m_Type; // Used in complex associations ( Dimensions.. )
int m_Angle; // Used only for Arcs: Arc angle in 1/10 deg
wxPoint m_BezierC1; // Bezier Control Point 1
wxPoint m_BezierC2; // Bezier Control Point 1
int m_Shape; ///< Shape: line, Circle, Arc
int m_Type; ///< Used in complex associations ( Dimensions.. )
double m_Angle; ///< Used only for Arcs: Arc angle in 1/10 deg
wxPoint m_BezierC1; ///< Bezier Control Point 1
wxPoint m_BezierC2; ///< Bezier Control Point 1
protected:
std::vector<wxPoint> m_BezierPoints;
std::vector<wxPoint> m_PolyPoints;
public:
DRAWSEGMENT( BOARD_ITEM* aParent, KICAD_T idtype = PCB_LINE_T );
DRAWSEGMENT( BOARD_ITEM* aParent = NULL, KICAD_T idtype = PCB_LINE_T );
~DRAWSEGMENT();
/// skip the linked list stuff, and parent
const DRAWSEGMENT& operator = ( const DRAWSEGMENT& rhs );
DRAWSEGMENT* Next() const { return (DRAWSEGMENT*) Pnext; }
DRAWSEGMENT* Back() const { return (DRAWSEGMENT*) Pback; }
void SetWidth( int aWidth ) { m_Width = aWidth; }
int GetWidth() const { return m_Width; }
void SetStart( const wxPoint& aStart ) { m_Start = aStart; }
void SetEnd( const wxPoint& aEnd ) { m_End = aEnd; }
/**
* Function SetAngle
* sets the angle for arcs, and normalizes it within the range 0 - 360 degrees.
......@@ -56,37 +54,44 @@ public:
double GetAngle() const { return m_Angle; }
void SetType( int aType ) { m_Type = aType; }
int GetType() const { return m_Type; }
void SetShape( int aShape ) { m_Shape = aShape; }
int GetShape() const { return m_Shape; }
void SetBezControl1( const wxPoint& aPoint ) { m_BezierC1 = aPoint; }
void SetBezControl2( const wxPoint& aPoint ) { m_BezierC2 = aPoint; }
const wxPoint& GetBezControl1() const { return m_BezierC1; }
/**
* Function GetPosition
* returns the position of this object.
* Required by pure virtual BOARD_ITEM::GetPosition()
* @return const wxPoint - The position of this object.
*/
const wxPoint GetPosition() const
{
return m_Start;
}
void SetBezControl2( const wxPoint& aPoint ) { m_BezierC2 = aPoint; }
const wxPoint& GetBezControl2() const { return m_BezierC2; }
void SetPosition( const wxPoint& aPos ) { m_Start = aPos; }
void SetPosition( const wxPoint& aPos ) { m_Start = aPos; } // override
const wxPoint GetPosition() const { return m_Start; } // override
/**
* Function GetStart
* returns the starting point of the graphic
*/
wxPoint GetStart() const;
const wxPoint& GetStart() const { return m_Start; }
void SetStart( const wxPoint& aStart ) { m_Start = aStart; }
void SetStartY( int y ) { m_Start.y = y; }
void SetStartX( int x ) { m_Start.x = x; }
/**
* Function GetEnd
* returns the ending point of the graphic
*/
wxPoint GetEnd() const;
const wxPoint& GetEnd() const { return m_End; }
void SetEnd( const wxPoint& aEnd ) { m_End = aEnd; }
void SetEndY( int y ) { m_End.y = y; }
void SetEndX( int x ) { m_End.x = x; }
// Arc attributes are read only, since they are "calculated" from
// m_Start, m_End, and m_Angle. No Set...() functions.
const wxPoint& GetCenter() const { return m_Start; }
const wxPoint& GetArcStart() const { return m_End; }
const wxPoint GetArcEnd() const;
/**
* Function GetRadius
......@@ -132,7 +137,6 @@ public:
void Copy( DRAWSEGMENT* source );
void Draw( EDA_DRAW_PANEL* panel, wxDC* DC,
int aDrawMode, const wxPoint& aOffset = ZeroOffset );
......@@ -145,7 +149,6 @@ public:
*/
virtual void DisplayInfo( EDA_DRAW_FRAME* frame );
/**
* Function GetBoundingBox
* returns the orthogonal, bounding box of this object for display purposes.
......@@ -155,7 +158,6 @@ public:
*/
virtual EDA_RECT GetBoundingBox() const;
/**
* Function HitTest
* tests if the given wxPoint is within the bounds of this object.
......@@ -183,7 +185,6 @@ public:
return wxT( "DRAWSEGMENT" );
}
/**
* Function GetLength
* returns the length of the track using the hypotenuse calculation.
......@@ -196,7 +197,6 @@ public:
return hypot( double( delta.x ), double( delta.y ) );
}
/**
* Function Move
* move this object.
......@@ -208,14 +208,13 @@ public:
m_End += aMoveVector;
}
/**
* Function Rotate
* Rotate this object.
* @param aRotCentre - the rotation point.
* @param aAngle - the rotation angle in 0.1 degree.
*/
virtual void Rotate( const wxPoint& aRotCentre, int aAngle );
virtual void Rotate( const wxPoint& aRotCentre, double aAngle );
/**
* Function Flip
......
......@@ -3,8 +3,8 @@
* @brief EDGE_MODULE class definition.
*/
#ifndef _CLASS_EDGE_MOD_H_
#define _CLASS_EDGE_MOD_H_
#ifndef CLASS_EDGE_MOD_H_
#define CLASS_EDGE_MOD_H_
#include "class_drawsegment.h"
......@@ -31,6 +31,12 @@ public:
void Copy( EDGE_MODULE* source ); // copy structure
void SetStart0( const wxPoint& aPoint ) { m_Start0 = aPoint; }
const wxPoint& GetStart0() const { return m_Start0; }
void SetEnd0( const wxPoint& aPoint ) { m_End0 = aPoint; }
const wxPoint& GetEnd0() const { return m_End0; }
/**
* Function Save
* writes the data structures for this object out to a FILE in "*.brd" format.
......@@ -88,4 +94,4 @@ public:
#endif
};
#endif // _CLASS_EDGE_MOD_H_
#endif // CLASS_EDGE_MOD_H_
......@@ -80,25 +80,12 @@ void MARKER_PCB::DisplayInfo( EDA_DRAW_FRAME* frame )
}
/**
* Function Rotate
* Rotate this object.
* @param aRotCentre - the rotation point.
* @param aAngle - the rotation angle in 0.1 degree.
*/
void MARKER_PCB::Rotate(const wxPoint& aRotCentre, int aAngle)
void MARKER_PCB::Rotate(const wxPoint& aRotCentre, double aAngle)
{
RotatePoint( &m_Pos, aRotCentre, aAngle );
}
/**
* Function Flip
* Flip this object, i.e. change the board side for this object
* this function has not really sense for a marker.
* It moves just the marker to keep its position on board, when the board is flipped
* @param aCentre - the rotation point.
*/
void MARKER_PCB::Flip(const wxPoint& aCentre )
{
m_Pos.y = aCentre.y - (m_Pos.y - aCentre.y);
......
......@@ -59,7 +59,7 @@ public:
* @param aRotCentre - the rotation point.
* @param aAngle - the rotation angle in 0.1 degree.
*/
virtual void Rotate( const wxPoint& aRotCentre, int aAngle );
virtual void Rotate( const wxPoint& aRotCentre, double aAngle );
/**
* Function Flip
......
......@@ -43,6 +43,15 @@ PCB_TARGET::~PCB_TARGET()
}
void PCB_TARGET::Exchg( PCB_TARGET* source )
{
EXCHG( m_Pos, source->m_Pos );
EXCHG( m_Width, source->m_Width );
EXCHG( m_Size, source->m_Size );
EXCHG( m_Shape, source->m_Shape );
}
void PCB_TARGET::Copy( PCB_TARGET* source )
{
m_Layer = source->m_Layer;
......@@ -143,12 +152,6 @@ bool PCB_TARGET::HitTest( const wxPoint& refPos )
}
/**
* Function HitTest (overlayed)
* tests if the given EDA_RECT intersect this object.
* @param refArea : the given EDA_RECT
* @return bool - true if a hit, else false
*/
bool PCB_TARGET::HitTest( EDA_RECT& refArea )
{
if( refArea.Contains( m_Pos ) )
......@@ -158,23 +161,12 @@ bool PCB_TARGET::HitTest( EDA_RECT& refArea )
}
/**
* Function Rotate
* Rotate this object.
* @param aRotCentre - the rotation point.
* @param aAngle - the rotation angle in 0.1 degree.
*/
void PCB_TARGET::Rotate(const wxPoint& aRotCentre, int aAngle)
void PCB_TARGET::Rotate(const wxPoint& aRotCentre, double aAngle)
{
RotatePoint( &m_Pos, aRotCentre, aAngle );
}
/**
* Function Flip
* Flip this object, i.e. change the board side for this object
* @param aCentre - the rotation point.
*/
void PCB_TARGET::Flip(const wxPoint& aCentre )
{
m_Pos.y = aCentre.y - ( m_Pos.y - aCentre.y );
......
......@@ -17,11 +17,10 @@ class EDA_DRAW_PANEL;
class PCB_TARGET : public BOARD_ITEM
{
public:
int m_Width;
wxPoint m_Pos;
int m_Shape; // bit 0 : 0 = draw +, 1 = draw X
int m_Size;
int m_Width;
wxPoint m_Pos;
public:
PCB_TARGET( BOARD_ITEM* aParent );
......@@ -33,12 +32,23 @@ public:
PCB_TARGET* Next() const { return (PCB_TARGET*) Pnext; }
PCB_TARGET* Back() const { return (PCB_TARGET*) Pnext; }
const wxPoint GetPosition() const
{
return m_Pos;
}
void SetPosition( const wxPoint& aPos ) { m_Pos = aPos; } // override
const wxPoint GetPosition() const { return m_Pos; } // override
void SetPosition( const wxPoint& aPos ) { m_Pos = aPos; }
void SetShape( int aShape ) { m_Shape = aShape; }
int GetShape() const { return m_Shape; }
void SetSize( int aSize ) { m_Size = aSize; }
int GetSize() const { return m_Size; }
void SetWidth( int aWidth ) { m_Width = aWidth; }
int GetWidth() const { return m_Width; }
/**
* Function Exchg
* swaps data with another PCB_TARGET for use by undo-redo.
*/
void Exchg( PCB_TARGET* aTarget );
/**
* Function Move
......@@ -56,7 +66,7 @@ public:
* @param aRotCentre - the rotation point.
* @param aAngle - the rotation angle in 0.1 degree.
*/
virtual void Rotate( const wxPoint& aRotCentre, int aAngle );
virtual void Rotate( const wxPoint& aRotCentre, double aAngle );
/**
* Function Flip
......@@ -80,7 +90,6 @@ public:
void Draw( EDA_DRAW_PANEL* panel, wxDC* DC, int aDrawMode,
const wxPoint& offset = ZeroOffset );
/**
* Function HitTest
* tests if the given wxPoint is within the bounds of this object.
......
......@@ -43,7 +43,7 @@ class MODULE : public BOARD_ITEM
{
public:
int m_Orient; // orientation in 0.1 degrees
double m_Orient; // orientation in 0.1 degrees
wxPoint m_Pos; // Real coord on board
DLIST<D_PAD> m_Pads; /* Pad list (linked list) */
DLIST<BOARD_ITEM> m_Drawings; /* Graphic items list (linked list) */
......@@ -142,15 +142,11 @@ public:
*/
EDA_RECT GetBoundingBox() const;
const wxPoint GetPosition() const // overload
{
return m_Pos;
}
void SetPosition( const wxPoint& aPos ); // overload
const wxPoint GetPosition() const { return m_Pos; } // overload
void SetOrientation( int newangle );
int GetOrientation() const { return m_Orient; }
void SetOrientation( double newangle );
double GetOrientation() const { return m_Orient; }
const wxString& GetLibRef() const { return m_LibRef; }
void SetLibRef( const wxString& aLibRef ) { m_LibRef = aLibRef; }
......@@ -192,7 +188,7 @@ public:
* @param aRotCentre - the rotation point.
* @param aAngle - the rotation angle in 0.1 degree.
*/
virtual void Rotate( const wxPoint& aRotCentre, int aAngle );
virtual void Rotate( const wxPoint& aRotCentre, double aAngle );
/**
* Function Flip
......
......@@ -127,25 +127,14 @@ int ChangeSideMaskLayer( int aMask )
}
/**
* Function Move (virtual)
* move this object.
* @param aMoveVector - the move vector for this object.
*/
void MODULE::Move(const wxPoint& aMoveVector)
void MODULE::Move( const wxPoint& aMoveVector )
{
wxPoint newpos = m_Pos + aMoveVector;
SetPosition( newpos );
}
/**
* Function Rotate
* Rotate this object.
* @param aRotCentre - the rotation point.
* @param aAngle - the rotation angle in 0.1 degree.
*/
void MODULE::Rotate(const wxPoint& aRotCentre, int aAngle)
void MODULE::Rotate( const wxPoint& aRotCentre, double aAngle )
{
wxPoint newpos = m_Pos;
RotatePoint( &newpos, aRotCentre, aAngle );
......@@ -154,48 +143,42 @@ void MODULE::Rotate(const wxPoint& aRotCentre, int aAngle)
}
/**
* Function Flip
* Flip this object, i.e. change the board side for this object
* @param aCentre - the rotation point.
*/
void MODULE::Flip( const wxPoint& aCentre )
{
D_PAD* pt_pad;
TEXTE_MODULE* pt_texte;
EDGE_MODULE* pt_edgmod;
EDA_ITEM* PtStruct;
// Move module to its final position:
wxPoint finalPos = m_Pos;
finalPos.y = aCentre.y - ( finalPos.y - aCentre.y ); /// Mirror the Y position
SetPosition(finalPos);
/* Flip layer */
SetPosition( finalPos );
// Flip layer
SetLayer( ChangeSideNumLayer( GetLayer() ) );
/* Reverse mirror orientation. */
// Reverse mirror orientation.
NEGATE( m_Orient );
NORMALIZE_ANGLE_POS( m_Orient );
/* Mirror inversion layers pads. */
pt_pad = m_Pads;
for( ; pt_pad != NULL; pt_pad = pt_pad->Next() )
// Mirror inversion layers pads.
for( D_PAD* pad = m_Pads; pad; pad = pad->Next() )
{
pt_pad->m_Pos.y -= m_Pos.y;
pt_pad->m_Pos.y = -pt_pad->m_Pos.y;
pt_pad->m_Pos.y += m_Pos.y;
NEGATE( pt_pad->m_Pos0.y );
NEGATE( pt_pad->m_Offset.y );
NEGATE( pt_pad->m_DeltaSize.y );
NEGATE_AND_NORMALIZE_ANGLE_POS( pt_pad->m_Orient );
/* flip pads layers*/
pt_pad->m_layerMask = ChangeSideMaskLayer( pt_pad->m_layerMask );
pad->m_Pos.y -= m_Pos.y;
pad->m_Pos.y = -pad->m_Pos.y;
pad->m_Pos.y += m_Pos.y;
NEGATE( pad->m_Pos0.y );
NEGATE( pad->m_Offset.y );
NEGATE( pad->m_DeltaSize.y );
NEGATE_AND_NORMALIZE_ANGLE_POS( pad->m_Orient );
// flip pads layers
pad->m_layerMask = ChangeSideMaskLayer( pad->m_layerMask );
}
/* Mirror reference. */
// Mirror reference.
pt_texte = m_Reference;
pt_texte->m_Pos.y -= m_Pos.y;
pt_texte->m_Pos.y = -pt_texte->m_Pos.y;
......@@ -216,7 +199,7 @@ void MODULE::Flip( const wxPoint& aCentre )
|| (GetLayer() == ADHESIVE_N_BACK) || (GetLayer() == LAYER_N_BACK) )
pt_texte->m_Mirror = true;
/* Mirror value. */
// Mirror value.
pt_texte = m_Value;
pt_texte->m_Pos.y -= m_Pos.y;
NEGATE( pt_texte->m_Pos.y );
......@@ -237,33 +220,42 @@ void MODULE::Flip( const wxPoint& aCentre )
|| (GetLayer() == ADHESIVE_N_BACK) || (GetLayer() == LAYER_N_BACK) )
pt_texte->m_Mirror = true;
/* Reverse mirror footprints. */
PtStruct = m_Drawings;
for( ; PtStruct != NULL; PtStruct = PtStruct->Next() )
// Reverse mirror module graphics and texts.
for( EDA_ITEM* item = m_Drawings; item; item = item->Next() )
{
switch( PtStruct->Type() )
switch( item->Type() )
{
case PCB_MODULE_EDGE_T:
pt_edgmod = (EDGE_MODULE*) PtStruct;
pt_edgmod->m_Start.y -= m_Pos.y;
pt_edgmod->m_Start.y = -pt_edgmod->m_Start.y;
pt_edgmod->m_Start.y += m_Pos.y;
pt_edgmod->m_End.y -= m_Pos.y;
pt_edgmod->m_End.y = -pt_edgmod->m_End.y;
pt_edgmod->m_End.y += m_Pos.y;
NEGATE( pt_edgmod->m_Start0.y );
NEGATE( pt_edgmod->m_End0.y );
if( pt_edgmod->m_Shape == S_ARC )
{
NEGATE(pt_edgmod->m_Angle);
EDGE_MODULE* em = (EDGE_MODULE*) item;
wxPoint s = em->GetStart();
s.y -= m_Pos.y;
s.y = -s.y;
s.y += m_Pos.y;
em->SetStart( s );
wxPoint e = em->GetEnd();
e.y -= m_Pos.y;
e.y = -e.y;
e.y += m_Pos.y;
em->SetEnd( e );
NEGATE( em->m_Start0.y );
NEGATE( em->m_End0.y );
if( em->GetShape() == S_ARC )
{
em->SetAngle( -em->GetAngle() );
}
pt_edgmod->SetLayer( ChangeSideNumLayer( pt_edgmod->GetLayer() ) );
em->SetLayer( ChangeSideNumLayer( em->GetLayer() ) );
}
break;
case PCB_MODULE_TEXT_T:
/* Reverse mirror position and mirror. */
pt_texte = (TEXTE_MODULE*) PtStruct;
// Reverse mirror position and mirror.
pt_texte = (TEXTE_MODULE*) item;
pt_texte->m_Pos.y -= m_Pos.y;
pt_texte->m_Pos.y = -pt_texte->m_Pos.y;
pt_texte->m_Pos.y += m_Pos.y;
......@@ -298,6 +290,7 @@ void MODULE::Flip( const wxPoint& aCentre )
CalculateBoundingBox();
}
void MODULE::SetPosition( const wxPoint& newpos )
{
wxPoint delta = newpos - m_Pos;
......@@ -311,22 +304,20 @@ void MODULE::SetPosition( const wxPoint& newpos )
pad->m_Pos += delta;
}
EDA_ITEM* PtStruct = m_Drawings;
for( ; PtStruct != NULL; PtStruct = PtStruct->Next() )
for( EDA_ITEM* item = m_Drawings; item; item = item->Next() )
{
switch( PtStruct->Type() )
switch( item->Type() )
{
case PCB_MODULE_EDGE_T:
{
EDGE_MODULE* pt_edgmod = (EDGE_MODULE*) PtStruct;
EDGE_MODULE* pt_edgmod = (EDGE_MODULE*) item;
pt_edgmod->SetDrawCoord();
break;
}
case PCB_MODULE_TEXT_T:
{
TEXTE_MODULE* pt_texte = (TEXTE_MODULE*) PtStruct;
TEXTE_MODULE* pt_texte = (TEXTE_MODULE*) item;
pt_texte->m_Pos += delta;
break;
}
......@@ -341,13 +332,14 @@ void MODULE::SetPosition( const wxPoint& newpos )
}
void MODULE::SetOrientation( int newangle )
void MODULE::SetOrientation( double newangle )
{
int px, py;
newangle -= m_Orient; // = Change in rotation
m_Orient += newangle;
NORMALIZE_ANGLE_POS( m_Orient );
for( D_PAD* pad = m_Pads; pad; pad = pad->Next() )
......@@ -355,7 +347,7 @@ void MODULE::SetOrientation( int newangle )
px = pad->m_Pos0.x;
py = pad->m_Pos0.y;
pad->m_Orient += newangle; /* change m_Orientation */
pad->m_Orient += newangle; // change m_Orientation
NORMALIZE_ANGLE_POS( pad->m_Orient );
RotatePoint( &px, &py, m_Orient );
......@@ -363,11 +355,11 @@ void MODULE::SetOrientation( int newangle )
pad->m_Pos.y = m_Pos.y + py;
}
/* Update of the reference and value. */
// Update of the reference and value.
m_Reference->SetDrawCoord();
m_Value->SetDrawCoord();
/* Displace contours and text of the footprint. */
// Displace contours and text of the footprint.
for( BOARD_ITEM* item = m_Drawings; item; item = item->Next() )
{
if( item->Type() == PCB_MODULE_EDGE_T )
......@@ -376,7 +368,7 @@ void MODULE::SetOrientation( int newangle )
pt_edgmod->SetDrawCoord();
}
if( item->Type() == PCB_MODULE_TEXT_T )
else if( item->Type() == PCB_MODULE_TEXT_T )
{
TEXTE_MODULE* pt_texte = (TEXTE_MODULE*) item;
pt_texte->SetDrawCoord();
......
......@@ -56,12 +56,6 @@ void TEXTE_PCB::Copy( TEXTE_PCB* source )
}
/*
* Function Draw
* Like tracks, texts are drawn in filled or sketch mode, never in line mode
* because the line mode does not keep the actual size of the text
* and the actual size is very important, especially for copper texts
*/
void TEXTE_PCB::Draw( EDA_DRAW_PANEL* panel, wxDC* DC,
int DrawMode, const wxPoint& offset )
{
......@@ -85,7 +79,6 @@ void TEXTE_PCB::Draw( EDA_DRAW_PANEL* panel, wxDC* DC,
}
// see class_pcb_text.h
void TEXTE_PCB::DisplayInfo( EDA_DRAW_FRAME* frame )
{
wxString msg;
......@@ -130,13 +123,7 @@ void TEXTE_PCB::DisplayInfo( EDA_DRAW_FRAME* frame )
}
/**
* Function Rotate
* Rotate this object.
* @param aRotCentre - the rotation point.
* @param aAngle - the rotation angle in 0.1 degree.
*/
void TEXTE_PCB::Rotate(const wxPoint& aRotCentre, int aAngle)
void TEXTE_PCB::Rotate( const wxPoint& aRotCentre, double aAngle )
{
RotatePoint( &m_Pos, aRotCentre, aAngle );
m_Orient += aAngle;
......@@ -144,11 +131,6 @@ void TEXTE_PCB::Rotate(const wxPoint& aRotCentre, int aAngle)
}
/**
* Function Flip
* Flip this object, i.e. change the board side for this object
* @param aCentre - the rotation point.
*/
void TEXTE_PCB::Flip(const wxPoint& aCentre )
{
m_Pos.y = aCentre.y - ( m_Pos.y - aCentre.y );
......
......@@ -47,7 +47,7 @@ public:
* @param aRotCentre - the rotation point.
* @param aAngle - the rotation angle in 0.1 degree.
*/
virtual void Rotate( const wxPoint& aRotCentre, int aAngle );
virtual void Rotate( const wxPoint& aRotCentre, double aAngle );
/**
* Function Flip
......
......@@ -186,7 +186,7 @@ wxString SEGVIA::GetSelectMenuText() const
text << _( "Via" ) << wxT( " " ) << ShowWidth();
int shape = Shape();
int shape = GetShape();
if( shape == VIA_BLIND_BURIED )
text << wxT( " " ) << _( "Blind/Buried" );
......@@ -231,7 +231,7 @@ TRACK::TRACK( const TRACK& Source ) :
m_Flags = Source.m_Flags;
SetTimeStamp( Source.m_TimeStamp );
SetStatus( Source.ReturnStatus() );
SetStatus( Source.GetStatus() );
m_Start = Source.m_Start;
m_End = Source.m_End;
m_Width = Source.m_Width;
......@@ -390,7 +390,7 @@ EDA_RECT TRACK::GetBoundingBox() const
}
void TRACK::Rotate( const wxPoint& aRotCentre, int aAngle )
void TRACK::Rotate( const wxPoint& aRotCentre, double aAngle )
{
RotatePoint( &m_Start, aRotCentre, aAngle );
RotatePoint( &m_End, aRotCentre, aAngle );
......@@ -451,7 +451,7 @@ int TRACK::ReturnMaskLayer() const
{
if( Type() == PCB_VIA_T )
{
int via_type = Shape();
int via_type = GetShape();
if( via_type == VIA_THROUGH )
return ALL_CU_LAYERS;
......@@ -481,7 +481,7 @@ int TRACK::ReturnMaskLayer() const
void SEGVIA::SetLayerPair( int top_layer, int bottom_layer )
{
if( Shape() == VIA_THROUGH )
if( GetShape() == VIA_THROUGH )
{
top_layer = LAYER_N_FRONT;
bottom_layer = LAYER_N_BACK;
......@@ -499,7 +499,7 @@ void SEGVIA::ReturnLayerPair( int* top_layer, int* bottom_layer ) const
int b_layer = LAYER_N_BACK;
int t_layer = LAYER_N_FRONT;
if( Shape() != VIA_THROUGH )
if( GetShape() != VIA_THROUGH )
{
b_layer = (m_Layer >> 4) & 15;
t_layer = m_Layer & 15;
......@@ -888,7 +888,7 @@ void SEGVIA::Draw( EDA_DRAW_PANEL* panel, wxDC* DC, int draw_mode, const wxPoint
// for Micro Vias, draw a partial cross : X on component layer, or + on copper layer
// (so we can see 2 superimposed microvias ):
if( Shape() == VIA_MICROVIA )
if( GetShape() == VIA_MICROVIA )
{
int ax, ay, bx, by;
......@@ -926,7 +926,7 @@ void SEGVIA::Draw( EDA_DRAW_PANEL* panel, wxDC* DC, int draw_mode, const wxPoint
// for Buried Vias, draw a partial line : orient depending on layer pair
// (so we can see superimposed buried vias ):
if( Shape() == VIA_BLIND_BURIED )
if( GetShape() == VIA_BLIND_BURIED )
{
int ax = 0, ay = radius, bx = 0, by = drill_radius;
int layer_top, layer_bottom;
......@@ -1041,7 +1041,7 @@ void TRACK::DisplayInfoBase( EDA_DRAW_FRAME* frame )
switch( Type() )
{
case PCB_VIA_T:
switch( Shape() )
switch( GetShape() )
{
default:
case 0:
......@@ -1593,7 +1593,7 @@ void SEGVIA::Show( int nestLevel, std::ostream& os )
{
const char* cp;
switch( Shape() )
switch( GetShape() )
{
case VIA_THROUGH:
cp = "through";
......
......@@ -67,7 +67,7 @@ public:
std::vector<TRACK*> m_TracksConnected; // list of other tracks connected to me
std::vector<D_PAD*> m_PadsConnected; // list of pads connected to me
int m_Param; // Auxiliary variable ( used in some computations )
double m_Param; // Auxiliary variable ( used in some computations )
protected:
TRACK( const TRACK& track ); // protected so Copy() is used instead.
......@@ -110,7 +110,7 @@ public:
* @param aRotCentre - the rotation point.
* @param aAngle - the rotation angle in 0.1 degree.
*/
virtual void Rotate( const wxPoint& aRotCentre, int aAngle );
virtual void Rotate( const wxPoint& aRotCentre, double aAngle );
/**
* Function Flip
......@@ -119,17 +119,17 @@ public:
*/
virtual void Flip( const wxPoint& aCentre );
const wxPoint GetPosition() const // overload
{
return m_Start; // it had to be start or end.
}
void SetPosition( const wxPoint& aPos ) { m_Start = aPos; } // overload
const wxPoint GetPosition() const { return m_Start; } // overload
int GetWidth() const { return m_Width; }
void SetWidth( int aWidth ) { m_Width = aWidth; }
void SetPosition( const wxPoint& aPos ) { m_Start = aPos; } // overload
int GetWidth() const { return m_Width; }
void SetEnd( const wxPoint& aEnd ) { m_End = aEnd; }
const wxPoint& GetEnd() const { return m_End; }
void SetStart( const wxPoint& aStart ) { m_Start = aStart; }
const wxPoint& GetStart() const { return m_Start; }
EDA_RECT GetBoundingBox() const;
......@@ -168,8 +168,8 @@ public:
*/
double GetLength() const
{
int dx = m_Start.x - m_End.x;
int dy = m_Start.y - m_End.y;
double dx = m_Start.x - m_End.x;
double dy = m_Start.y - m_End.y;
return hypot( dx, dy );
}
......@@ -179,7 +179,7 @@ public:
const wxPoint& aOffset = ZeroOffset );
/* divers */
int Shape() const { return m_Shape & 0xFF; }
int GetShape() const { return m_Shape & 0xFF; }
void SetShape( int aShape ) { m_Shape = aShape; }
/**
......@@ -203,26 +203,34 @@ public:
* Set the drill value for vias
* @param drill_value = new drill value
*/
void SetDrillValue( int drill_value ) { m_Drill = drill_value; }
void SetDrill( int aDrill ) { m_Drill = aDrill; }
/**
* Function GetDrill
* returns the local drill setting for this VIA. If you want the calculated value,
* use GetDrillValue() instead.
*/
int GetDrill() const { return m_Drill; }
/**
* Function GetDrillValue
* "calculates" the drill value for vias (m-Drill if > 0, or default
* drill value for the board.
* @return real drill_value
*/
int GetDrillValue() const;
/**
* Function SetDrillDefault
* Set the drill value for vias at default value (-1)
*/
void SetDrillDefault( void ) { m_Drill = -1; }
void SetDrillDefault() { m_Drill = -1; }
/**
* Function IsDrillDefault
* @return true if the drill value is default value (-1)
*/
bool IsDrillDefault( void ) { return m_Drill <= 0; }
/**
* Function GetDrillValue
* calculate the drill value for vias (m-Drill if > 0, or default drill value for the board
* @return real drill_value
*/
int GetDrillValue() const;
bool IsDrillDefault() { return m_Drill <= 0; }
/**
* Function ReturnMaskLayer
......
......@@ -737,7 +737,7 @@ void ZONE_CONTAINER::MoveEdge( const wxPoint& offset )
}
void ZONE_CONTAINER::Rotate( const wxPoint& centre, int angle )
void ZONE_CONTAINER::Rotate( const wxPoint& centre, double angle )
{
wxPoint pos;
......
......@@ -3,8 +3,8 @@
* @brief Classes to handle copper zones
*/
#ifndef CLASS_ZONE_H
#define CLASS_ZONE_H
#ifndef CLASS_ZONE_H_
#define CLASS_ZONE_H_
#include <vector>
......@@ -41,7 +41,7 @@ struct SEGMENT
m_Start = aStart;
m_End = aEnd;
}
};
};
/**
......@@ -103,7 +103,6 @@ private:
public:
ZONE_CONTAINER( BOARD* parent );
~ZONE_CONTAINER();
bool Save( FILE* aFile ) const;
......@@ -224,9 +223,9 @@ public:
/**
* Function GetNetName
* returns the net name.
* @return wxString - The net name.
* @return const wxString& - The net name.
*/
wxString GetNetName() const { return m_Netname; };
const wxString& GetNetName() const { return m_Netname; };
void SetNetName( const wxString& aName ) { m_Netname = aName; }
void SetFillMode( int aFillMode ) { m_FillMode = aFillMode; }
......@@ -392,7 +391,7 @@ public:
* @param centre = rot centre
* @param angle = in 0.1 degree
*/
void Rotate( const wxPoint& centre, int angle );
void Rotate( const wxPoint& centre, double angle );
/**
* Function Flip
......@@ -420,10 +419,10 @@ public:
return wxT( "ZONE_CONTAINER" );
}
/** Access to m_Poly parameters
*/
int GetNumCorners( void ) const
{
return m_Poly->GetNumCorners();
......@@ -500,4 +499,4 @@ public:
};
#endif // #ifndef CLASS_ZONE_H
#endif // CLASS_ZONE_H_
......@@ -121,7 +121,7 @@ void clean_vias( BOARD * aPcb )
for( track = aPcb->m_Track; track; track = track->Next() )
{
if( track->Shape() != VIA_THROUGH )
if( track->GetShape() != VIA_THROUGH )
continue;
// Search and delete others vias at same location
......
......@@ -73,7 +73,7 @@ void DIALOG_MODULE_BOARD_EDITOR::InitBoardProperties()
(m_CurrentModule->GetLayer() == LAYER_N_BACK) ? 1 : 0 );
bool select = FALSE;
switch( m_CurrentModule->m_Orient )
switch( (int) m_CurrentModule->GetOrientation() )
{
case 0:
m_OrientCtrl->SetSelection( 0 );
......
......@@ -164,11 +164,11 @@ void DIALOG_GENDRILL::InitDisplayParams( void )
if( track->Type() != PCB_VIA_T )
continue;
if( track->Shape() == VIA_THROUGH )
if( track->GetShape() == VIA_THROUGH )
m_throughViasCount++;
else if( track->Shape() == VIA_MICROVIA )
else if( track->GetShape() == VIA_MICROVIA )
m_microViasCount++;
else if( track->Shape() == VIA_BLIND_BURIED )
else if( track->GetShape() == VIA_BLIND_BURIED )
m_blindOrBuriedViasCount++;
}
......
......@@ -90,7 +90,7 @@ void DialogGraphicItemProperties::initDlg( )
wxString msg;
// Change texts according to the segment shape:
switch ( m_Item->m_Shape )
switch ( m_Item->GetShape() )
{
case S_CIRCLE:
m_Start_Center_XText->SetLabel(_("Center X"));
......@@ -106,7 +106,7 @@ void DialogGraphicItemProperties::initDlg( )
m_Start_Center_YText->SetLabel(_("Center Y"));
m_EndX_Radius_Text->SetLabel(_("Start Point X"));
m_EndY_Text->SetLabel(_("Start Point Y"));
msg << m_Item->m_Angle;
msg << m_Item->GetAngle();
m_Angle_Ctrl->SetValue(msg);
break;
......@@ -118,23 +118,23 @@ void DialogGraphicItemProperties::initDlg( )
AddUnitSymbol( *m_Start_Center_XText );
PutValueInLocalUnits( *m_Center_StartXCtrl, m_Item->m_Start.x,
PutValueInLocalUnits( *m_Center_StartXCtrl, m_Item->GetStart().x,
m_Parent->m_InternalUnits );
AddUnitSymbol( *m_Start_Center_YText );
PutValueInLocalUnits( *m_Center_StartYCtrl, m_Item->m_Start.y,
PutValueInLocalUnits( *m_Center_StartYCtrl, m_Item->GetStart().y,
m_Parent->m_InternalUnits );
AddUnitSymbol( *m_EndX_Radius_Text );
PutValueInLocalUnits( *m_EndX_Radius_Ctrl, m_Item->m_End.x,
PutValueInLocalUnits( *m_EndX_Radius_Ctrl, m_Item->GetEnd().x,
m_Parent->m_InternalUnits );
AddUnitSymbol( *m_EndY_Text );
PutValueInLocalUnits( *m_EndY_Ctrl, m_Item->m_End.y,
PutValueInLocalUnits( *m_EndY_Ctrl, m_Item->GetEnd().y,
m_Parent->m_InternalUnits );
AddUnitSymbol( *m_ItemThicknessText );
PutValueInLocalUnits( *m_ThicknessCtrl, m_Item->m_Width,
PutValueInLocalUnits( *m_ThicknessCtrl, m_Item->GetWidth(),
m_Parent->m_InternalUnits );
AddUnitSymbol( *m_DefaultThicknessText );
......@@ -192,28 +192,22 @@ void DialogGraphicItemProperties::OnOkClick( wxCommandEvent& event )
m_Item->Draw( m_Parent->DrawPanel, m_DC, GR_XOR );
msg = m_Center_StartXCtrl->GetValue();
m_Item->m_Start.x = ReturnValueFromString( g_UserUnit, msg,
m_Parent->m_InternalUnits );
m_Item->SetStartX( ReturnValueFromString( g_UserUnit, msg, m_Parent->m_InternalUnits ));
msg = m_Center_StartYCtrl->GetValue();
m_Item->m_Start.y = ReturnValueFromString( g_UserUnit, msg,
m_Parent->m_InternalUnits );
m_Item->SetStartY( ReturnValueFromString( g_UserUnit, msg, m_Parent->m_InternalUnits ));
msg = m_EndX_Radius_Ctrl->GetValue();
m_Item->m_End.x = ReturnValueFromString( g_UserUnit, msg,
m_Parent->m_InternalUnits );
m_Item->SetEndX( ReturnValueFromString( g_UserUnit, msg, m_Parent->m_InternalUnits ));
msg = m_EndY_Ctrl->GetValue();
m_Item->m_End.y = ReturnValueFromString( g_UserUnit, msg,
m_Parent->m_InternalUnits );
m_Item->SetEndY( ReturnValueFromString( g_UserUnit, msg, m_Parent->m_InternalUnits ));
msg = m_ThicknessCtrl->GetValue();
m_Item->m_Width = ReturnValueFromString( g_UserUnit, msg,
m_Parent->m_InternalUnits );
m_Item->SetWidth( ReturnValueFromString( g_UserUnit, msg, m_Parent->m_InternalUnits ));
msg = m_DefaultThicknessCtrl->GetValue();
int thickness = ReturnValueFromString( g_UserUnit, msg,
m_Parent->m_InternalUnits );
int thickness = ReturnValueFromString( g_UserUnit, msg, m_Parent->m_InternalUnits );
m_Item->SetLayer( m_LayerSelection->GetCurrentSelection() + FIRST_NO_COPPER_LAYER);
......@@ -222,12 +216,12 @@ void DialogGraphicItemProperties::OnOkClick( wxCommandEvent& event )
else
m_BrdSettings.m_DrawSegmentWidth = thickness;
if( m_Item->m_Shape == S_ARC )
if( m_Item->GetShape() == S_ARC )
{
long angle;
m_Angle_Ctrl->GetValue().ToLong(&angle);
double angle;
m_Angle_Ctrl->GetValue().ToDouble( &angle );
NORMALIZE_ANGLE_360(angle);
m_Item->m_Angle = angle;
m_Item->SetAngle( angle );
}
m_Parent->OnModify();
......
......@@ -114,7 +114,7 @@ void DIALOG_PCB_TEXT_PROPERTIES::MyInit()
}
}
switch( m_SelectedPCBText->m_Orient )
switch( (int) m_SelectedPCBText->GetOrientation() )
{
default:
m_OrientationCtrl->SetSelection( 0 );
......
......@@ -83,18 +83,18 @@ DIALOG_DIMENSION_EDITOR::DIALOG_DIMENSION_EDITOR( PCB_EDIT_FRAME* aParent,
CurrentDimension = aDimension;
if( aDimension->m_Text->m_Mirror )
if( aDimension->m_Text.m_Mirror )
m_rbMirror->SetSelection( 1 );
else
m_rbMirror->SetSelection( 0 );
m_Name->SetValue( aDimension->m_Text->m_Text );
m_Name->SetValue( aDimension->m_Text.m_Text );
// Enter size value in dialog
PutValueInLocalUnits( *m_TxtSizeXCtrl, aDimension->m_Text->m_Size.x,
PutValueInLocalUnits( *m_TxtSizeXCtrl, aDimension->m_Text.m_Size.x,
m_Parent->m_InternalUnits );
AddUnitSymbol( *m_staticTextSizeX );
PutValueInLocalUnits( *m_TxtSizeYCtrl, aDimension->m_Text->m_Size.y,
PutValueInLocalUnits( *m_TxtSizeYCtrl, aDimension->m_Text.m_Size.y,
m_Parent->m_InternalUnits );
AddUnitSymbol( *m_staticTextSizeY );
......@@ -104,10 +104,10 @@ DIALOG_DIMENSION_EDITOR::DIALOG_DIMENSION_EDITOR( PCB_EDIT_FRAME* aParent,
AddUnitSymbol( *m_staticTextWidth );
// Enter position value in dialog
PutValueInLocalUnits( *m_textCtrlPosX, aDimension->m_Text->m_Pos.x,
PutValueInLocalUnits( *m_textCtrlPosX, aDimension->m_Text.m_Pos.x,
m_Parent->m_InternalUnits );
AddUnitSymbol( *m_staticTextPosX );
PutValueInLocalUnits( *m_textCtrlPosY, aDimension->m_Text->m_Pos.y,
PutValueInLocalUnits( *m_textCtrlPosY, aDimension->m_Text.m_Pos.y,
m_Parent->m_InternalUnits );
AddUnitSymbol( *m_staticTextPosY );
......@@ -148,26 +148,26 @@ void DIALOG_DIMENSION_EDITOR::OnOKClick( wxCommandEvent& event )
// Get new size value:
msg = m_TxtSizeXCtrl->GetValue();
CurrentDimension->m_Text->m_Size.x = ReturnValueFromString( g_UserUnit, msg,
CurrentDimension->m_Text.m_Size.x = ReturnValueFromString( g_UserUnit, msg,
m_Parent->m_InternalUnits );
msg = m_TxtSizeYCtrl->GetValue();
CurrentDimension->m_Text->m_Size.y = ReturnValueFromString( g_UserUnit, msg,
CurrentDimension->m_Text.m_Size.y = ReturnValueFromString( g_UserUnit, msg,
m_Parent->m_InternalUnits );
// Get new position value:
// It will be copied later in dimension, because
msg = m_textCtrlPosX->GetValue();
CurrentDimension->m_Text->m_Pos.x = ReturnValueFromString( g_UserUnit, msg,
CurrentDimension->m_Text.m_Pos.x = ReturnValueFromString( g_UserUnit, msg,
m_Parent->m_InternalUnits );
msg = m_textCtrlPosY->GetValue();
CurrentDimension->m_Text->m_Pos.y = ReturnValueFromString( g_UserUnit, msg,
CurrentDimension->m_Text.m_Pos.y = ReturnValueFromString( g_UserUnit, msg,
m_Parent->m_InternalUnits );
// Get new line thickness value:
msg = m_TxtWidthCtrl->GetValue();
int width = ReturnValueFromString( g_UserUnit, msg,
m_Parent->m_InternalUnits );
int maxthickness = Clamp_Text_PenSize( width, CurrentDimension->m_Text->m_Size );
int maxthickness = Clamp_Text_PenSize( width, CurrentDimension->m_Text.m_Size );
if( width > maxthickness )
{
......@@ -176,9 +176,9 @@ void DIALOG_DIMENSION_EDITOR::OnOKClick( wxCommandEvent& event )
width = maxthickness;
}
CurrentDimension->m_Text->m_Thickness = CurrentDimension->m_Width = width ;
CurrentDimension->m_Text.m_Thickness = CurrentDimension->m_Width = width ;
CurrentDimension->m_Text->m_Mirror = ( m_rbMirror->GetSelection() == 1 ) ? true : false;
CurrentDimension->m_Text.m_Mirror = ( m_rbMirror->GetSelection() == 1 ) ? true : false;
CurrentDimension->SetLayer( m_SelLayerBox->GetCurrentSelection() + FIRST_NO_COPPER_LAYER );
......@@ -249,16 +249,16 @@ DIMENSION* PCB_EDIT_FRAME::EditDimension( DIMENSION* aDimension, wxDC* aDC )
aDimension->m_arrowD2Ox = aDimension->m_arrowD2Fx = pos.x;
aDimension->m_arrowD2Oy = aDimension->m_arrowD2Fy = pos.y;
aDimension->m_Text->m_Size = GetBoard()->GetDesignSettings().m_PcbTextSize;
aDimension->m_Text.m_Size = GetBoard()->GetDesignSettings().m_PcbTextSize;
int width = GetBoard()->GetDesignSettings().m_PcbTextWidth;
int maxthickness = Clamp_Text_PenSize(width, aDimension->m_Text->m_Size );
int maxthickness = Clamp_Text_PenSize(width, aDimension->m_Text.m_Size );
if( width > maxthickness )
{
width = maxthickness;
}
aDimension->m_Text->m_Thickness = aDimension->m_Width = width ;
aDimension->m_Text.m_Thickness = aDimension->m_Width = width ;
aDimension->AdjustDimensionDetails( );
......@@ -377,13 +377,13 @@ void PCB_EDIT_FRAME::BeginMoveDimensionText( DIMENSION* aItem, wxDC* DC )
return;
// Store the initial position for undo/abort command
initialTextPosition = aItem->m_Text->m_Pos;
initialTextPosition = aItem->m_Text.m_Pos;
aItem->Draw( DrawPanel, DC, GR_XOR );
aItem->m_Flags |= IS_MOVED;
aItem->DisplayInfo( this );
GetScreen()->SetCrossHairPosition( aItem->m_Text->m_Pos );
GetScreen()->SetCrossHairPosition( aItem->m_Text.m_Pos );
DrawPanel->MoveCursorToCrossHair();
DrawPanel->SetMouseCapture( MoveDimensionText, AbortMoveDimensionText );
......@@ -404,7 +404,7 @@ static void MoveDimensionText( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint&
if( aErase )
dimension->Draw( aPanel, aDC, GR_XOR );
dimension->m_Text->m_Pos = aPanel->GetScreen()->GetCrossHairPosition();
dimension->m_Text.m_Pos = aPanel->GetScreen()->GetCrossHairPosition();
dimension->Draw( aPanel, aDC, GR_XOR );
}
......@@ -425,7 +425,7 @@ void AbortMoveDimensionText( EDA_DRAW_PANEL* aPanel, wxDC* aDC )
return;
dimension->Draw( aPanel, aDC, GR_XOR );
dimension->m_Text->m_Pos = initialTextPosition;
dimension->m_Text.m_Pos = initialTextPosition;
dimension->m_Flags = 0;
dimension->Draw( aPanel, aDC, GR_OR );
}
......@@ -444,9 +444,9 @@ void PCB_EDIT_FRAME::PlaceDimensionText( DIMENSION* aItem, wxDC* DC )
aItem->Draw( DrawPanel, DC, GR_OR );
OnModify();
EXCHG( aItem->m_Text->m_Pos, initialTextPosition );
EXCHG( aItem->m_Text.m_Pos, initialTextPosition );
SaveCopyInUndoList( aItem, UR_CHANGED );
EXCHG( aItem->m_Text->m_Pos, initialTextPosition );
EXCHG( aItem->m_Text.m_Pos, initialTextPosition );
aItem->m_Flags = 0;
}
......@@ -175,7 +175,7 @@ bool DRC::doTrackDrc( TRACK* aRefSeg, TRACK* aStart, bool testPads )
if( aRefSeg->Type() == PCB_VIA_T )
{
// test if the via size is smaller than minimum
if( aRefSeg->Shape() == VIA_MICROVIA )
if( aRefSeg->GetShape() == VIA_MICROVIA )
{
if( aRefSeg->m_Width < netclass->GetuViaMinDiameter() )
{
......@@ -207,7 +207,7 @@ bool DRC::doTrackDrc( TRACK* aRefSeg, TRACK* aStart, bool testPads )
// For microvias: test if they are blind vias and only between 2 layers
// because they are used for very small drill size and are drill by laser
// and **only one layer** can be drilled
if( aRefSeg->Shape() == VIA_MICROVIA )
if( aRefSeg->GetShape() == VIA_MICROVIA )
{
int layer1, layer2;
bool err = true;
......
......@@ -29,7 +29,7 @@ static void Abort_Move_ModuleOutline( EDA_DRAW_PANEL* Panel, wxDC* DC );
static void ShowCurrentOutlineWhileMoving( EDA_DRAW_PANEL* aPanel, wxDC* aDC,
const wxPoint& aPosition, bool aErase );
int ArcValue = 900;
static double ArcValue = 900;
static wxPoint MoveVector; // Move vector for move edge
static wxPoint CursorInitialPosition; // Mouse cursor initial position for move command
......@@ -49,23 +49,25 @@ void FOOTPRINT_EDIT_FRAME::Start_Move_EdgeMod( EDGE_MODULE* Edge, wxDC* DC )
}
void FOOTPRINT_EDIT_FRAME::Place_EdgeMod( EDGE_MODULE* Edge )
void FOOTPRINT_EDIT_FRAME::Place_EdgeMod( EDGE_MODULE* aEdge )
{
if( Edge == NULL )
if( aEdge == NULL )
return;
Edge->m_Start -= MoveVector;
Edge->m_End -= MoveVector;
aEdge->SetStart( aEdge->GetStart() - MoveVector );
aEdge->SetEnd( aEdge->GetEnd() - MoveVector );
Edge->m_Start0 -= MoveVector;
Edge->m_End0 -= MoveVector;
aEdge->SetStart0( aEdge->GetStart0() - MoveVector );
aEdge->SetEnd0( aEdge->GetEnd0() - MoveVector );
Edge->m_Flags = 0;
aEdge->m_Flags = 0;
DrawPanel->SetMouseCapture( NULL, NULL );
SetCurItem( NULL );
OnModify();
MODULE* Module = (MODULE*) Edge->GetParent();
Module->CalculateBoundingBox();
MODULE* module = (MODULE*) aEdge->GetParent();
module->CalculateBoundingBox();
DrawPanel->Refresh( );
}
......@@ -109,22 +111,27 @@ static void ShowNewEdgeModule( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint&
if( Edge == NULL )
return;
MODULE* Module = (MODULE*) Edge->GetParent();
MODULE* module = (MODULE*) Edge->GetParent();
// if( erase )
{
Edge->Draw( aPanel, aDC, GR_XOR );
}
Edge->m_End = screen->GetCrossHairPosition();
Edge->SetEnd( screen->GetCrossHairPosition() );
// Update relative coordinate.
Edge->SetEnd0( Edge->GetEnd() - module->GetPosition() );
wxPoint pt( Edge->GetEnd0() );
/* Update relative coordinate. */
Edge->m_End0 = Edge->m_End - Module->m_Pos;
RotatePoint( &Edge->m_End0, -Module->m_Orient );
RotatePoint( &pt, -module->GetOrientation() );
Edge->SetEnd0( pt );
Edge->Draw( aPanel, aDC, GR_XOR );
Module->CalculateBoundingBox();
module->CalculateBoundingBox();
}
......@@ -143,12 +150,12 @@ void FOOTPRINT_EDIT_FRAME::Edit_Edge_Width( EDGE_MODULE* aEdge )
if( aEdge->Type() != PCB_MODULE_EDGE_T )
continue;
aEdge->m_Width = g_ModuleSegmentWidth;
aEdge->SetWidth( g_ModuleSegmentWidth );
}
}
else
{
aEdge->m_Width = g_ModuleSegmentWidth;
aEdge->SetWidth( g_ModuleSegmentWidth );
}
OnModify();
......@@ -222,9 +229,9 @@ void FOOTPRINT_EDIT_FRAME::Enter_Edge_Width( EDGE_MODULE* aEdge )
if( aEdge )
{
MODULE* Module = GetBoard()->m_Modules;
aEdge->m_Width = g_ModuleSegmentWidth;
Module->CalculateBoundingBox();
MODULE* module = GetBoard()->m_Modules;
aEdge->SetWidth( g_ModuleSegmentWidth );
module->CalculateBoundingBox();
OnModify();
}
}
......@@ -297,18 +304,18 @@ EDGE_MODULE* FOOTPRINT_EDIT_FRAME::Begin_Edge_Module( EDGE_MODULE* Edge,
Edge = new EDGE_MODULE( module );
MoveVector.x = MoveVector.y = 0;
/* Add the new item to the Drawings list head*/
// Add the new item to the Drawings list head
module->m_Drawings.PushFront( Edge );
/* Update characteristics of the segment or arc. */
// Update characteristics of the segment or arc.
Edge->m_Flags = IS_NEW;
Edge->m_Angle = angle;
Edge->m_Shape = type_edge;
Edge->SetAngle( angle );
Edge->SetShape( type_edge );
if( Edge->m_Shape == S_ARC )
Edge->m_Angle = ArcValue;
if( Edge->GetShape() == S_ARC )
Edge->SetAngle( ArcValue );
Edge->m_Width = g_ModuleSegmentWidth;
Edge->SetWidth( g_ModuleSegmentWidth );
Edge->SetLayer( module->GetLayer() );
if( module->GetLayer() == LAYER_N_FRONT )
......@@ -317,14 +324,14 @@ EDGE_MODULE* FOOTPRINT_EDIT_FRAME::Begin_Edge_Module( EDGE_MODULE* Edge,
if( module->GetLayer() == LAYER_N_BACK )
Edge->SetLayer( SILKSCREEN_N_BACK );
/* Initialize the starting point of the new segment or arc */
Edge->m_Start = GetScreen()->GetCrossHairPosition();
// Initialize the starting point of the new segment or arc
Edge->SetStart( GetScreen()->GetCrossHairPosition() );
/* Initialize the ending point of the new segment or arc */
Edge->m_End = Edge->m_Start;
// Initialize the ending point of the new segment or arc
Edge->SetEnd( Edge->GetStart() );
/* Initialize the relative coordinates */
Edge->m_Start0 = Edge->m_Start - module->m_Pos;
// Initialize the relative coordinates
Edge->SetStart0( Edge->GetStart() - module->GetPosition() );
RotatePoint( &Edge->m_Start0, -module->m_Orient );
......@@ -355,16 +362,20 @@ EDGE_MODULE* FOOTPRINT_EDIT_FRAME::Begin_Edge_Module( EDGE_MODULE* Edge,
Edge = newedge; // point now new item
Edge->m_Flags = IS_NEW;
Edge->m_Width = g_ModuleSegmentWidth;
Edge->m_Start = GetScreen()->GetCrossHairPosition();
Edge->m_End = Edge->m_Start;
Edge->SetWidth( g_ModuleSegmentWidth );
Edge->SetStart( GetScreen()->GetCrossHairPosition() );
Edge->SetEnd( Edge->GetStart() );
/* Update relative coordinate. */
Edge->m_Start0 = Edge->m_Start - module->m_Pos;
// Update relative coordinate.
Edge->SetStart0( Edge->GetStart() - module->GetPosition() );
RotatePoint( &Edge->m_Start0, -module->m_Orient );
wxPoint pt( Edge->GetStart0() );
Edge->m_End0 = Edge->m_Start0;
RotatePoint( &pt, -module->GetOrientation() );
Edge->SetStart0( pt );
Edge->SetEnd0( Edge->GetStart0() );
module->CalculateBoundingBox();
module->m_LastEdit_Time = time( NULL );
......@@ -390,7 +401,7 @@ void FOOTPRINT_EDIT_FRAME::End_Edge_Module( EDGE_MODULE* Edge )
Edge->m_Flags = 0;
/* If last segment length is 0: remove it */
if( Edge->m_Start == Edge->m_End )
if( Edge->GetStart() == Edge->GetEnd() )
Edge->DeleteStructure();
}
......
......@@ -108,7 +108,7 @@ bool PCB_EDIT_FRAME::SetTrackSegmentWidth( TRACK* aTrackItem,
{
// Set new drill value. Note: currently microvias have only a default drill value
if( new_drill > 0 )
aTrackItem->SetDrillValue(new_drill);
aTrackItem->SetDrill( new_drill );
else
aTrackItem->SetDrillDefault();
}
......
......@@ -64,21 +64,23 @@ void PCB_EDIT_FRAME::Place_DrawItem( DRAWSEGMENT* drawitem, wxDC* DC )
static void Move_Segment( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint& aPosition,
bool aErase )
{
DRAWSEGMENT* Segment = (DRAWSEGMENT*) aPanel->GetScreen()->GetCurItem();
DRAWSEGMENT* segment = (DRAWSEGMENT*) aPanel->GetScreen()->GetCurItem();
if( Segment == NULL )
if( segment == NULL )
return;
if( aErase )
Segment->Draw( aPanel, aDC, GR_XOR );
segment->Draw( aPanel, aDC, GR_XOR );
wxPoint delta;
delta = aPanel->GetScreen()->GetCrossHairPosition() - s_LastPosition;
Segment->m_Start += delta;
Segment->m_End += delta;
segment->SetStart( segment->GetStart() + delta );
segment->SetEnd( segment->GetEnd() + delta );
s_LastPosition = aPanel->GetScreen()->GetCrossHairPosition();
Segment->Draw( aPanel, aDC, GR_XOR );
segment->Draw( aPanel, aDC, GR_XOR );
}
......@@ -221,10 +223,11 @@ DRAWSEGMENT* PCB_EDIT_FRAME::Begin_DrawSegment( DRAWSEGMENT* Segment, int shape,
SetCurItem( Segment = new DRAWSEGMENT( GetBoard() ) );
Segment->m_Flags = IS_NEW;
Segment->SetLayer( getActiveLayer() );
Segment->m_Width = s_large;
Segment->m_Shape = shape;
Segment->m_Angle = 900;
Segment->m_Start = Segment->m_End = GetScreen()->GetCrossHairPosition();
Segment->SetWidth( s_large );
Segment->SetShape( shape );
Segment->SetAngle( 900 );
Segment->SetStart( GetScreen()->GetCrossHairPosition() );
Segment->SetEnd( GetScreen()->GetCrossHairPosition() );
DrawPanel->SetMouseCapture( DrawSegment, Abort_EditEdge );
}
else /* The ending point ccordinate Segment->m_End was updated by he function
......@@ -232,11 +235,11 @@ DRAWSEGMENT* PCB_EDIT_FRAME::Begin_DrawSegment( DRAWSEGMENT* Segment, int shape,
* during the segment creation
*/
{
if( Segment->m_Start != Segment->m_End )
if( Segment->GetStart() != Segment->GetEnd() )
{
if( Segment->m_Shape == S_SEGMENT )
if( Segment->GetShape() == S_SEGMENT )
{
SaveCopyInUndoList(Segment, UR_NEW );
SaveCopyInUndoList( Segment, UR_NEW );
GetBoard()->Add( Segment );
OnModify();
......@@ -250,11 +253,12 @@ DRAWSEGMENT* PCB_EDIT_FRAME::Begin_DrawSegment( DRAWSEGMENT* Segment, int shape,
Segment->m_Flags = IS_NEW;
Segment->SetLayer( DrawItem->GetLayer() );
Segment->m_Width = s_large;
Segment->m_Shape = DrawItem->m_Shape;
Segment->m_Type = DrawItem->m_Type;
Segment->m_Angle = DrawItem->m_Angle;
Segment->m_Start = Segment->m_End = DrawItem->m_End;
Segment->SetWidth( s_large );
Segment->SetShape( DrawItem->GetShape() );
Segment->SetType( DrawItem->GetType() );
Segment->SetAngle( DrawItem->GetAngle() );
Segment->SetStart( DrawItem->GetEnd() );
Segment->SetEnd( DrawItem->GetEnd() );
DrawSegment( DrawPanel, DC, wxDefaultPosition, false );
}
else
......@@ -276,10 +280,10 @@ void PCB_EDIT_FRAME::End_Edge( DRAWSEGMENT* Segment, wxDC* DC )
Segment->Draw( DrawPanel, DC, GR_OR );
/* Delete if segment length is zero. */
if( Segment->m_Start == Segment->m_End )
// Delete if segment length is zero.
if( Segment->GetStart() == Segment->GetEnd() )
{
Segment ->DeleteStructure();
Segment->DeleteStructure();
}
else
{
......@@ -309,15 +313,18 @@ static void DrawSegment( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint& aPosi
if( aErase )
Segment->Draw( aPanel, aDC, GR_XOR );
if( Segments_45_Only && ( Segment->m_Shape == S_SEGMENT ) )
if( Segments_45_Only && Segment->GetShape() == S_SEGMENT )
{
wxPoint pt;
CalculateSegmentEndPoint( aPanel->GetScreen()->GetCrossHairPosition(),
Segment->m_Start.x, Segment->m_Start.y,
&Segment->m_End.x, &Segment->m_End.y );
Segment->GetStart().x, Segment->GetStart().y,
&pt.x, &pt.y );
Segment->SetEnd( pt );
}
else /* here the angle is arbitrary */
else // here the angle is arbitrary
{
Segment->m_End = aPanel->GetScreen()->GetCrossHairPosition();
Segment->SetEnd( aPanel->GetScreen()->GetCrossHairPosition() );
}
Segment->Draw( aPanel, aDC, GR_XOR );
......
......@@ -105,7 +105,7 @@ bool PCB_EDIT_FRAME::Other_Layer_Route( TRACK* aTrack, wxDC* DC )
// Usual via is from copper to component.
// layer pair is LAYER_N_BACK and LAYER_N_FRONT.
via->SetLayerPair( LAYER_N_BACK, LAYER_N_FRONT );
via->SetDrillValue( GetBoard()->GetCurrentViaDrill() );
via->SetDrill( GetBoard()->GetCurrentViaDrill() );
int first_layer = getActiveLayer();
int last_layer;
......@@ -117,7 +117,7 @@ bool PCB_EDIT_FRAME::Other_Layer_Route( TRACK* aTrack, wxDC* DC )
last_layer = GetScreen()->m_Route_Layer_BOTTOM;
/* Adjust the actual via layer pair */
switch ( via->Shape() )
switch ( via->GetShape() )
{
case VIA_BLIND_BURIED:
via->SetLayerPair( first_layer, last_layer );
......
......@@ -891,8 +891,8 @@ static void CreateBoardSection( FILE* aFile, BOARD* aPcb )
{
// XXX GenCAD supports arc boundaries but I've seen nothing that reads them
fprintf( aFile, "LINE %g %g %g %g\n",
MapXTo( drawseg->m_Start.x ), MapYTo( drawseg->m_Start.y ),
MapXTo( drawseg->m_End.x ), MapYTo( drawseg->m_End.y ) );
MapXTo( drawseg->GetStart().x ), MapYTo( drawseg->GetStart().y ),
MapXTo( drawseg->GetEnd().x ), MapYTo( drawseg->GetEnd().y ) );
}
}
}
......@@ -1041,7 +1041,7 @@ static void FootprintWriteShape( FILE* aFile, MODULE* module )
if( PtEdge->GetLayer() == SILKSCREEN_N_FRONT
|| PtEdge->GetLayer() == SILKSCREEN_N_BACK )
{
switch( PtEdge->m_Shape )
switch( PtEdge->GetShape() )
{
case S_SEGMENT:
fprintf( aFile, "LINE %g %g %g %g\n",
......@@ -1068,9 +1068,9 @@ static void FootprintWriteShape( FILE* aFile, MODULE* module )
int arcendx, arcendy;
arcendx = PtEdge->m_End0.x - PtEdge->m_Start0.x;
arcendy = PtEdge->m_End0.y - PtEdge->m_Start0.y;
RotatePoint( &arcendx, &arcendy, -PtEdge->m_Angle );
arcendx += PtEdge->m_Start0.x;
arcendy += PtEdge->m_Start0.y;
RotatePoint( &arcendx, &arcendy, -PtEdge->GetAngle() );
arcendx += PtEdge->GetStart0().x;
arcendy += PtEdge->GetStart0().y;
if( Yaxis_sign == -1 )
{
// Flipping Y flips the arc direction too
......@@ -1078,19 +1078,19 @@ static void FootprintWriteShape( FILE* aFile, MODULE* module )
(arcendx) / SCALE_FACTOR,
(Yaxis_sign * arcendy) / SCALE_FACTOR,
(PtEdge->m_End0.x) / SCALE_FACTOR,
(Yaxis_sign * PtEdge->m_End0.y) / SCALE_FACTOR,
(PtEdge->m_Start0.x) / SCALE_FACTOR,
(Yaxis_sign * PtEdge->m_Start0.y) / SCALE_FACTOR );
(Yaxis_sign * PtEdge->GetEnd0().y) / SCALE_FACTOR,
(PtEdge->GetStart0().x) / SCALE_FACTOR,
(Yaxis_sign * PtEdge->GetStart0().y) / SCALE_FACTOR );
}
else
{
fprintf( aFile, "ARC %g %g %g %g %g %g\n",
(PtEdge->m_End0.x) / SCALE_FACTOR,
(Yaxis_sign * PtEdge->m_End0.y) / SCALE_FACTOR,
(PtEdge->GetEnd0().x) / SCALE_FACTOR,
(Yaxis_sign * PtEdge->GetEnd0().y) / SCALE_FACTOR,
(arcendx) / SCALE_FACTOR,
(Yaxis_sign * arcendy) / SCALE_FACTOR,
(PtEdge->m_Start0.x) / SCALE_FACTOR,
(Yaxis_sign * PtEdge->m_Start0.y) / SCALE_FACTOR );
(PtEdge->GetStart0().x) / SCALE_FACTOR,
(Yaxis_sign * PtEdge->GetStart0().y) / SCALE_FACTOR );
}
break;
}
......
......@@ -593,16 +593,16 @@ static void export_vrml_arc( int layer, double startx, double starty, /*{{{*/
static void export_vrml_drawsegment( DRAWSEGMENT* drawseg ) /*{{{*/
{
int layer = drawseg->GetLayer();
double w = drawseg->m_Width;
double x = drawseg->m_Start.x;
double y = drawseg->m_Start.y;
double xf = drawseg->m_End.x;
double yf = drawseg->m_End.y;
double w = drawseg->GetWidth();
double x = drawseg->GetStart().x;
double y = drawseg->GetStart().y;
double xf = drawseg->GetEnd().x;
double yf = drawseg->GetEnd().y;
/* Items on the edge layer are high, not thick */
if( layer == EDGE_N )
{
switch( drawseg->m_Shape )
switch( drawseg->GetShape() )
{
/* There is a special 'varc' primitive for this */
case S_ARC:
......@@ -630,7 +630,7 @@ static void export_vrml_drawsegment( DRAWSEGMENT* drawseg ) /*{{{*/
}
else
{
switch( drawseg->m_Shape )
switch( drawseg->GetShape() )
{
case S_ARC:
export_vrml_arc( layer, x, y, xf, yf, w, 3 );
......@@ -856,13 +856,13 @@ static void export_vrml_text_module( TEXTE_MODULE* module ) /*{{{*/
static void export_vrml_edge_module( EDGE_MODULE* module ) /*{{{*/
{
int layer = module->GetLayer();
double x = module->m_Start.x;
double y = module->m_Start.y;
double xf = module->m_End.x;
double yf = module->m_End.y;
double w = module->m_Width;
double x = module->GetStart().x;
double y = module->GetStart().y;
double xf = module->GetEnd().x;
double yf = module->GetEnd().y;
double w = module->GetWidth();
switch( module->m_Shape )
switch( module->GetShape() )
{
case S_ARC:
export_vrml_arc( layer, x, y, xf, yf, w, 3 );
......
......@@ -515,15 +515,15 @@ void WriteDrawSegmentPcb( DRAWSEGMENT* PtDrawSegment, FILE* rptfile )
double radius, width;
char line[1024];
ux0 = PtDrawSegment->m_Start.x * conv_unit;
uy0 = PtDrawSegment->m_Start.y * conv_unit;
ux0 = PtDrawSegment->GetStart().x * conv_unit;
uy0 = PtDrawSegment->GetStart().y * conv_unit;
dx = PtDrawSegment->m_End.x * conv_unit;
dy = PtDrawSegment->m_End.y * conv_unit;
dx = PtDrawSegment->GetEnd().x * conv_unit;
dy = PtDrawSegment->GetEnd().y * conv_unit;
width = PtDrawSegment->m_Width * conv_unit;
width = PtDrawSegment->GetWidth() * conv_unit;
switch( PtDrawSegment->m_Shape )
switch( PtDrawSegment->GetShape() )
{
case S_CIRCLE:
radius = hypot( dx - ux0, dy - uy0 );
......@@ -536,13 +536,15 @@ void WriteDrawSegmentPcb( DRAWSEGMENT* PtDrawSegment, FILE* rptfile )
case S_ARC:
{
int endx = PtDrawSegment->m_End.x, endy = PtDrawSegment->m_End.y;
int endx = PtDrawSegment->GetEnd().x;
int endy = PtDrawSegment->GetEnd().y;
radius = hypot( dx - ux0, dy - uy0 );
RotatePoint( &endx,
&endy,
PtDrawSegment->m_Start.x,
PtDrawSegment->m_Start.y,
PtDrawSegment->m_Angle );
PtDrawSegment->GetStart().x,
PtDrawSegment->GetStart().y,
PtDrawSegment->GetAngle() );
fprintf( rptfile, "$ARC \n" );
fprintf( rptfile, "centre %.6lf %.6lf\n", ux0, uy0 );
......
......@@ -158,13 +158,15 @@ bool MODULE::Read_GPCB_Descr( const wxString& CmpFullFileName )
#define TEXT_DEFAULT_SIZE 400
#define OLD_GPCB_UNIT_CONV 10
#define NEW_GPCB_UNIT_CONV 0.1
FILE* cmpfile;
double conv_unit = NEW_GPCB_UNIT_CONV; // GPCB unit = 0.01 mils and Pcbnew 0.1
// Old version unit = 1 mil, so conv_unit is 10 or 0.1
bool success = true;
char* Line;
char* line;
long ibuf[100];
EDGE_MODULE* DrawSegm;
EDGE_MODULE* drawSeg;
D_PAD* Pad;
wxArrayString params;
int iprmcnt, icnt_max, iflgidx;
......@@ -178,10 +180,10 @@ bool MODULE::Read_GPCB_Descr( const wxString& CmpFullFileName )
reader.ReadLine();
Line = reader.Line();
line = reader.Line();
params.Clear();
Extract_Parameters( params, Line );
Extract_Parameters( params, line );
iprmcnt = 0;
icnt_max = params.GetCount();
......@@ -224,6 +226,7 @@ bool MODULE::Read_GPCB_Descr( const wxString& CmpFullFileName )
iprmcnt++;
for( int ii = 0; ii < 20; ii++ )
ibuf[ii] = 0;
for( int ii = 0; ii <= 8; ii++, iprmcnt++ ) // upt to 6 params + terminal char.
{
if( iprmcnt >= icnt_max )
......@@ -265,9 +268,10 @@ bool MODULE::Read_GPCB_Descr( const wxString& CmpFullFileName )
while( reader.ReadLine() )
{
Line = reader.Line();
line = reader.Line();
params.Clear();
Extract_Parameters( params, Line );
Extract_Parameters( params, line );
if( params.GetCount() > 3 ) // Test units value for a string line param (more than 3 params : ident [ xx ] )
{
if( params[1] == wxT( "(" ) )
......@@ -278,16 +282,14 @@ bool MODULE::Read_GPCB_Descr( const wxString& CmpFullFileName )
if( params[0].CmpNoCase( wxT( "ElementLine" ) ) == 0 ) // line descr
{ // Format: ElementLine [X1 Y1 X2 Y2 Thickness]
DrawSegm = new EDGE_MODULE( this );
DrawSegm->SetLayer( SILKSCREEN_N_FRONT );
DrawSegm->m_Shape = S_SEGMENT;
m_Drawings.PushBack( DrawSegm );
wxPoint start0;
wxPoint end0;
int width;
int* list[5] = {
&DrawSegm->m_Start0.x, &DrawSegm->m_Start0.y,
&DrawSegm->m_End0.x, &DrawSegm->m_End0.y,
&DrawSegm->m_Width
&start0.x, &start0.y,
&end0.x, &end0.y,
&width
};
for( unsigned ii = 0; ii < 5; ii++ )
......@@ -301,18 +303,29 @@ bool MODULE::Read_GPCB_Descr( const wxString& CmpFullFileName )
}
}
DrawSegm->SetDrawCoord();
drawSeg = new EDGE_MODULE( this );
drawSeg->SetLayer( SILKSCREEN_N_FRONT );
drawSeg->SetShape( S_SEGMENT );
drawSeg->SetStart0( start0 );
drawSeg->SetEnd0( end0 );
drawSeg->SetWidth( width );
drawSeg->SetDrawCoord();
m_Drawings.PushBack( drawSeg );
continue;
}
if( params[0].CmpNoCase( wxT( "ElementArc" ) ) == 0 ) // Arc descr
{ // format: ElementArc [X Y Width Height StartAngle DeltaAngle Thickness]
// Pcbnew does know ellipse so we must have Width = Height
DrawSegm = new EDGE_MODULE( this );
DrawSegm->SetLayer( SILKSCREEN_N_FRONT );
DrawSegm->m_Shape = S_ARC;
drawSeg = new EDGE_MODULE( this );
drawSeg->SetLayer( SILKSCREEN_N_FRONT );
drawSeg->SetShape( S_ARC );
m_Drawings.PushBack( DrawSegm );
m_Drawings.PushBack( drawSeg );
for( unsigned ii = 0; ii < 7; ii++ )
{
......@@ -328,21 +341,29 @@ bool MODULE::Read_GPCB_Descr( const wxString& CmpFullFileName )
ibuf[ii] = 0;
}
int radius = (ibuf[2] + ibuf[3]) / 4; // for and arc: ibuf[3] = ibuf[4]. Pcbnew does not know ellipses
// for and arc: ibuf[3] = ibuf[4]. Pcbnew does not know ellipses
int radius = (ibuf[2] + ibuf[3]) / 4;
wxPoint centre;
centre.x = wxRound( ibuf[0] * conv_unit );
centre.y = wxRound( ibuf[1] * conv_unit );
DrawSegm->m_Start0 = centre;
int start_angle = ibuf[4] * 10; // Pcbnew uses 0.1 degrees as units
drawSeg->SetStart0( centre );
double start_angle = ibuf[4] * 10; // Pcbnew uses 0.1 degrees as units
start_angle -= 1800; // Use normal X axis as reference
DrawSegm->m_Angle = ibuf[5] * 10; // Angle value is clockwise in gpcb and Pcbnew
DrawSegm->m_End0.x = wxRound( radius * conv_unit );
DrawSegm->m_End0.y = 0;
RotatePoint( &DrawSegm->m_End0, -start_angle );// Calculate start point coordinate of arc
DrawSegm->m_End0 += centre;
DrawSegm->m_Width = wxRound( ibuf[6] * conv_unit );
DrawSegm->SetDrawCoord();
drawSeg->SetAngle( ibuf[5] * 10 ); // Angle value is clockwise in gpcb and Pcbnew
drawSeg->SetEnd0( wxPoint( wxRound( radius * conv_unit ), 0 ) );
// Calculate start point coordinate of arc
wxPoint arcStart( drawSeg->GetEnd0() );
RotatePoint( &arcStart, -start_angle );
drawSeg->SetEnd0( centre + arcStart );
drawSeg->SetWidth( wxRound( ibuf[6] * conv_unit ) );
drawSeg->SetDrawCoord();
continue;
}
......
......@@ -178,13 +178,13 @@ int PCB_BASE_FRAME::ReadListeSegmentDescr( LINE_READER* aReader,
if( arg_count < 7 || drill <= 0 )
newTrack->SetDrillDefault();
else
newTrack->SetDrillValue( drill );
newTrack->SetDrill( drill );
newTrack->SetLayer( layer );
if( makeType == PCB_VIA_T ) // Ensure layers are OK when possible:
{
if( newTrack->Shape() == VIA_THROUGH )
if( newTrack->GetShape() == VIA_THROUGH )
( (SEGVIA*) newTrack )->SetLayerPair( LAYER_N_FRONT, LAYER_N_BACK );
}
......@@ -857,6 +857,8 @@ bool WriteSheetDescr( BASE_SCREEN* screen, FILE* File )
}
#if !defined( USE_NEW_PCBNEW_LOAD )
static bool ReadSheetDescr( BASE_SCREEN* screen, LINE_READER* aReader )
{
char buf[1024];
......@@ -963,8 +965,6 @@ static bool ReadSheetDescr( BASE_SCREEN* screen, LINE_READER* aReader )
}
#if !defined( USE_NEW_PCBNEW_LOAD )
int PCB_EDIT_FRAME::ReadPcbFile( LINE_READER* aReader, bool Append )
{
wxBusyCursor dummy;
......@@ -975,8 +975,6 @@ int PCB_EDIT_FRAME::ReadPcbFile( LINE_READER* aReader, bool Append )
BOARD* board = GetBoard();
NbDraw = NbTrack = NbZone = NbMod = NbNets = -1;
board->m_Status_Pcb = 0;
board->m_NetClasses.Clear();
......
......@@ -148,15 +148,15 @@ bool DRAWSEGMENT::Save( FILE* aFile ) const
if( m_Type != S_CURVE )
{
fprintf( aFile, "De %d %d %d %lX %X\n",
m_Layer, m_Type, m_Angle,
m_TimeStamp, ReturnStatus() );
fprintf( aFile, "De %d %d %g %lX %X\n",
m_Layer, m_Type, GetAngle(),
m_TimeStamp, GetStatus() );
}
else
{
fprintf( aFile, "De %d %d %d %lX %X %d %d %d %d\n",
m_Layer, m_Type, m_Angle,
m_TimeStamp, ReturnStatus(),
fprintf( aFile, "De %d %d %g %lX %X %d %d %d %d\n",
m_Layer, m_Type, GetAngle(),
m_TimeStamp, GetStatus(),
m_BezierC1.x,m_BezierC1.y,
m_BezierC2.x,m_BezierC2.y);
}
......@@ -437,8 +437,8 @@ bool TEXTE_PCB::Save( FILE* aFile ) const
delete list;
fprintf( aFile, "Po %d %d %d %d %d %d\n",
m_Pos.x, m_Pos.y, m_Size.x, m_Size.y, m_Thickness, m_Orient );
fprintf( aFile, "Po %d %d %d %d %d %g\n",
m_Pos.x, m_Pos.y, m_Size.x, m_Size.y, m_Thickness, GetOrientation() );
char hJustify = 'L';
switch( m_HJustify )
......@@ -521,10 +521,10 @@ bool EDGE_MODULE::Save( FILE* aFile ) const
break;
case S_ARC:
ret = fprintf( aFile, "DA %d %d %d %d %d %d %d\n",
ret = fprintf( aFile, "DA %d %d %d %d %g %d %d\n",
m_Start0.x, m_Start0.y,
m_End0.x, m_End0.y,
m_Angle,
GetAngle(),
m_Width, m_Layer );
break;
......@@ -565,7 +565,7 @@ bool TRACK::Save( FILE* aFile ) const
fprintf( aFile, "De %d %d %d %lX %X\n",
m_Layer, type, GetNet(),
m_TimeStamp, ReturnStatus() );
m_TimeStamp, GetStatus() );
return true;
}
......@@ -587,16 +587,16 @@ bool DIMENSION::Save( FILE* aFile ) const
fprintf( aFile, "Va %d\n", m_Value );
if( !m_Text->m_Text.IsEmpty() )
fprintf( aFile, "Te %s\n", EscapedUTF8( m_Text->m_Text ).c_str() );
if( !m_Text.GetText().IsEmpty() )
fprintf( aFile, "Te %s\n", EscapedUTF8( m_Text.GetText() ).c_str() );
else
fprintf( aFile, "Te \"?\"\n" );
fprintf( aFile, "Po %d %d %d %d %d %d %d\n",
m_Text->m_Pos.x, m_Text->m_Pos.y,
m_Text->m_Size.x, m_Text->m_Size.y,
m_Text->GetThickness(), m_Text->GetOrientation(),
m_Text->m_Mirror ? 0 : 1 );
fprintf( aFile, "Po %d %d %d %d %d %g %d\n",
m_Text.m_Pos.x, m_Text.m_Pos.y,
m_Text.m_Size.x, m_Text.m_Size.y,
m_Text.GetThickness(), m_Text.GetOrientation(),
m_Text.m_Mirror ? 0 : 1 );
fprintf( aFile, "Sb %d %d %d %d %d %d\n", S_SEGMENT,
m_crossBarOx, m_crossBarOy,
......@@ -747,9 +747,9 @@ bool MODULE::Save( FILE* aFile ) const
else
statusTxt[1] = '~';
fprintf( aFile, "Po %d %d %d %d %8.8lX %8.8lX %s\n",
fprintf( aFile, "Po %d %d %g %d %8.8lX %8.8lX %s\n",
m_Pos.x, m_Pos.y,
m_Orient, m_Layer, m_LastEdit_Time,
GetOrientation(), m_Layer, m_LastEdit_Time,
m_TimeStamp, statusTxt );
fprintf( aFile, "Li %s\n", TO_UTF8( m_LibRef ) );
......@@ -1158,12 +1158,15 @@ int MODULE::ReadDescr( LINE_READER* aReader )
switch( Line[0] )
{
case 'P':
double orientation;
memset( BufCar1, 0, sizeof(BufCar1) );
sscanf( PtLine, "%d %d %d %d %lX %lX %s",
sscanf( PtLine, "%d %d %lf %d %lX %lX %s",
&m_Pos.x, &m_Pos.y,
&m_Orient, &m_Layer,
&orientation, &m_Layer,
&m_LastEdit_Time, &m_TimeStamp, BufCar1 );
SetOrientation( orientation );
m_ModuleStatus = 0;
if( BufCar1[0] == 'F' )
......@@ -1331,11 +1334,14 @@ int EDGE_MODULE::ReadDescr( LINE_READER* aReader )
switch( m_Shape )
{
case S_ARC:
sscanf( Line + 3, "%d %d %d %d %d %d %d",
double angle;
sscanf( Line + 3, "%d %d %d %d %lf %d %d",
&m_Start0.x, &m_Start0.y,
&m_End0.x, &m_End0.y,
&m_Angle, &m_Width, &m_Layer );
NORMALIZE_ANGLE_360( m_Angle );
&angle, &m_Width, &m_Layer );
NORMALIZE_ANGLE_360( angle );
SetAngle( angle );
break;
case S_SEGMENT:
......@@ -1441,14 +1447,14 @@ bool DIMENSION::ReadDimensionDescr( LINE_READER* aReader )
layer = LAST_NO_COPPER_LAYER;
SetLayer( layer );
m_Text->SetLayer( layer );
m_Text.SetLayer( layer );
continue;
}
if( Line[0] == 'T' )
{
ReadDelimitedText( Text, Line + 2, sizeof(Text) );
m_Text->m_Text = FROM_UTF8( Text );
m_Text.m_Text = FROM_UTF8( Text );
continue;
}
......@@ -1458,15 +1464,15 @@ bool DIMENSION::ReadDimensionDescr( LINE_READER* aReader )
int orientation;
int thickness;
sscanf( Line + 2, " %d %d %d %d %d %d %d",
&m_Text->m_Pos.x, &m_Text->m_Pos.y,
&m_Text->m_Size.x, &m_Text->m_Size.y,
&m_Text.m_Pos.x, &m_Text.m_Pos.y,
&m_Text.m_Size.x, &m_Text.m_Size.y,
&thickness, &orientation,
&normal_display );
m_Text->m_Mirror = normal_display ? false : true;
m_Pos = m_Text->m_Pos;
m_Text->SetOrientation( orientation );
m_Text->SetThickness( thickness );
m_Text.m_Mirror = normal_display ? false : true;
m_Pos = m_Text.m_Pos;
m_Text.SetOrientation( orientation );
m_Text.SetThickness( thickness );
continue;
}
......@@ -1580,7 +1586,9 @@ bool DRAWSEGMENT::ReadDrawSegmentDescr( LINE_READER* aReader )
sscanf( token,"%d",&m_Type );
break;
case 2:
sscanf( token,"%d",&m_Angle );
double angle;
sscanf( token, "%lf", &angle );
SetAngle( angle );
break;
case 3:
sscanf( token,"%lX",&m_TimeStamp );
......@@ -2062,9 +2070,12 @@ int TEXTE_PCB::ReadTextePcbDescr( LINE_READER* aReader )
}
if( strncmp( line, "Po", 2 ) == 0 )
{
sscanf( line + 2, " %d %d %d %d %d %d",
double angle;
sscanf( line + 2, " %d %d %d %d %d %lf",
&m_Pos.x, &m_Pos.y, &m_Size.x, &m_Size.y,
&m_Thickness, &m_Orient );
&m_Thickness, &angle );
SetOrientation( angle );
// Ensure the text has minimal size to see this text on screen:
if( m_Size.x < 5 )
......@@ -2135,6 +2146,7 @@ int TEXTE_MODULE::ReadDescr( LINE_READER* aReader )
int type;
char BufCar1[128], BufCar2[128], BufCar3[128];
char* line = aReader->Line();
double angle;
int layer = SILKSCREEN_N_FRONT;
......@@ -2142,16 +2154,19 @@ int TEXTE_MODULE::ReadDescr( LINE_READER* aReader )
BufCar2[0] = 0;
BufCar3[0] = 0;
if( sscanf( line + 1, "%d %d %d %d %d %d %d %s %s %d %s",
if( sscanf( line + 1, "%d %d %d %d %d %lf %d %s %s %d %s",
&type,
&m_Pos0.x, &m_Pos0.y,
&m_Size.y, &m_Size.x,
&m_Orient, &m_Thickness,
&angle, &m_Thickness,
BufCar1, BufCar2, &layer, BufCar3 ) >= 10 )
{
success = true;
SetOrientation( angle );
}
if( (type != TEXT_is_REFERENCE) && (type != TEXT_is_VALUE) )
type = TEXT_is_DIVERS;
......
......@@ -225,7 +225,7 @@ void KICAD_PLUGIN::loadAllSections( bool doAppend )
else if( TESTLINE( "$DRAWSEGMENT" ) )
{
loadDRAWSEGMENT();
loadPCB_LINE();
}
else if( TESTLINE( "$EQUIPOT" ) )
......@@ -408,7 +408,7 @@ void KICAD_PLUGIN::loadGENERAL()
m_board->SetBoundingBox( bbbox );
}
// Read the number of segments of type DRAW, TRACK, ZONE
/* Read the number of segments of type DRAW, TRACK, ZONE
else if( TESTLINE( "Ndraw" ) )
{
NbDraw = intParse( line + SZ( "Ndraw" ) );
......@@ -433,6 +433,7 @@ void KICAD_PLUGIN::loadGENERAL()
{
NbNets = intParse( line + SZ( "Nnets" ) );
}
*/
else if( TESTLINE( "$EndGENERAL" ) )
return; // preferred exit
......@@ -854,7 +855,7 @@ void KICAD_PLUGIN::loadMODULE()
if( TESTLINE( "D" ) ) // read a drawing item, e.g. "DS"
{
loadEDGE_MODULE( module.get() );
loadMODULE_EDGE( module.get() );
}
else if( TESTLINE( "$PAD" ) )
......@@ -1204,7 +1205,7 @@ void KICAD_PLUGIN::loadPAD( MODULE* aModule )
}
void KICAD_PLUGIN::loadEDGE_MODULE( MODULE* aModule )
void KICAD_PLUGIN::loadMODULE_EDGE( MODULE* aModule )
{
STROKE_T shape;
char* line = m_reader->Line(); // obtain current (old) line
......@@ -1494,7 +1495,7 @@ void KICAD_PLUGIN::load3D( MODULE* aModule )
}
void KICAD_PLUGIN::loadDRAWSEGMENT()
void KICAD_PLUGIN::loadPCB_LINE()
{
/* example:
$DRAWSEGMENT
......@@ -1808,7 +1809,7 @@ void KICAD_PLUGIN::loadTrackList( TRACK* aInsertBeforeMe, int aStructType )
// "De 0 0 463 0 800000\r\n"
#if 1
assert( TESTLINE( "Po" ) );
assert( TESTLINE( "De" ) );
#else
if( !TESTLINE( "De" ) )
{
......@@ -1861,13 +1862,13 @@ void KICAD_PLUGIN::loadTrackList( TRACK* aInsertBeforeMe, int aStructType )
if( drill <= 0 )
newTrack->SetDrillDefault();
else
newTrack->SetDrillValue( drill );
newTrack->SetDrill( drill );
newTrack->SetLayer( layer );
if( makeType == PCB_VIA_T ) // Ensure layers are OK when possible:
{
if( newTrack->Shape() == VIA_THROUGH )
if( newTrack->GetShape() == VIA_THROUGH )
( (SEGVIA*) newTrack )->SetLayerPair( LAYER_N_FRONT, LAYER_N_BACK );
}
......@@ -2083,7 +2084,10 @@ void KICAD_PLUGIN::loadZONE_CONTAINER()
zc->SetFillMode( fillmode ? 1 : 0 );
if( arcsegcount >= 32 /* ARC_APPROX_SEGMENTS_COUNT_HIGHT_DEF: don't really want pcbnew.h in here, after all, its a PLUGIN and global data is evil. */ )
// @todo ARC_APPROX_SEGMENTS_COUNT_HIGHT_DEF: don't really want pcbnew.h
// in here, after all, its a PLUGIN and global data is evil.
// put in accessor
if( arcsegcount >= 32 )
arcsegcount = 32;
zc->SetArcSegCount( arcsegcount );
......@@ -2228,7 +2232,7 @@ void KICAD_PLUGIN::loadDIMENSION()
dim->SetLayer( layer );
dim->SetTimeStamp( timestamp );
dim->m_Shape = shape;
dim->SetShape( shape );
}
else if( TESTLINE( "Te" ) )
......@@ -2236,7 +2240,7 @@ void KICAD_PLUGIN::loadDIMENSION()
char buf[2048];
ReadDelimitedText( buf, line + SZ( "Te" ), sizeof(buf) );
dim->m_Text->SetText( FROM_UTF8( buf ) );
dim->m_Text.SetText( FROM_UTF8( buf ) );
}
else if( TESTLINE( "Po" ) )
......@@ -2244,28 +2248,23 @@ void KICAD_PLUGIN::loadDIMENSION()
// sscanf( Line + 2, " %d %d %d %d %d %d %d", &m_Text->m_Pos.x, &m_Text->m_Pos.y,
// &m_Text->m_Size.x, &m_Text->m_Size.y, &thickness, &orientation, &normal_display );
int normal_display = 1;
BIU pos_x = biuParse( line + SZ( "Po" ), &data );
BIU pos_y = biuParse( data, &data );
BIU width = biuParse( data, &data );
BIU height = biuParse( data, &data );
BIU thickn = biuParse( data, &data );
int orient = intParse( data, &data );
data = strtok( (char*) data, delims );
if( data ) // optional from old days?
normal_display = intParse( data );
double orient = degParse( data, &data );
char* mirror = strtok( (char*) data, delims );
// This sets both DIMENSION's position and internal m_Text's.
// @todo: But why do we even know about internal m_Text?
dim->SetPosition( wxPoint( pos_x, pos_y ) );
dim->SetTextSize( wxSize( width, height ) );
dim->m_Text->m_Mirror = normal_display ? false : true;
dim->m_Text.SetMirrored( mirror && *mirror == '0' );
dim->m_Text->SetThickness( thickn );
dim->m_Text->SetOrientation( orient );
dim->m_Text.SetThickness( thickn );
dim->m_Text.SetOrientation( orient );
}
else if( TESTLINE( "Sb" ) )
......@@ -2396,6 +2395,7 @@ void KICAD_PLUGIN::loadPCB_TARGET()
{
while( READLINE() )
{
const char* data;
char* line = m_reader->Line();
if( TESTLINE( "$EndPCB_TARGET" ) )
......@@ -2405,8 +2405,6 @@ void KICAD_PLUGIN::loadPCB_TARGET()
else if( TESTLINE( "Po" ) )
{
const char* data;
// sscanf( Line + 2, " %X %d %d %d %d %d %lX", &m_Shape, &m_Layer, &m_Pos.x, &m_Pos.y, &m_Size, &m_Width, &m_TimeStamp );
int shape = intParse( line + SZ( "Po" ), &data );
......@@ -2549,16 +2547,20 @@ double KICAD_PLUGIN::degParse( const char* aValue, const char** nptrptr )
void KICAD_PLUGIN::init( PROPERTIES* aProperties )
{
NbDraw = NbTrack = NbZone = NbMod = NbNets = -1;
// conversion factor for saving RAM BIUs to KICAD legacy file format.
#if defined(KICAD_NANOMETRE)
biuToDisk = 1/1000000.0; // BIUs are nanometers
biuToDisk = 1/1000000.0; // BIUs are nanometers & file is mm
#else
biuToDisk = 1.0; // BIUs are deci-mils
#endif
// start by assuming the board is in deci-mils.
// if we see "Units mm" in the $GENERAL section, switch to 1000000.0 then.
// conversion factor for loading KICAD legacy file format into BIUs in RAM
// Start by assuming the *.brd file is in deci-mils.
// if we see "Units mm" in the $GENERAL section, set diskToBiu to 1000000.0
// then, during the file loading process, to start a conversion from
// mm to nanometers.
#if defined(KICAD_NANOMETRE)
diskToBiu = 2540.0; // BIUs are nanometers
......@@ -2605,12 +2607,12 @@ wxString KICAD_PLUGIN::writeError() const
}
#define CHECK_WRITE_ERROR() \
do { \
do { \
if( ferror( m_fp ) ) \
{ \
THROW_IO_ERROR( writeError() ); \
} \
} while(0)
} while(0)
void KICAD_PLUGIN::saveAllSections() const
......@@ -2644,7 +2646,6 @@ void KICAD_PLUGIN::saveSETUP() const
void KICAD_PLUGIN::saveBOARD() const
{
#if 1
// save the nets
int netcount = m_board->GetNetCount();
for( int i = 0; i < netcount; ++i )
......@@ -2666,10 +2667,10 @@ void KICAD_PLUGIN::saveBOARD() const
savePCB_TEXT( (TEXTE_PCB*) gr );
break;
case PCB_LINE_T:
saveEDGE_MODULE( (EDGE_MODULE*) gr );
saveMODULE_EDGE( (EDGE_MODULE*) gr );
break;
case PCB_TARGET_T:
saveTARGET( (PCB_TARGET*) gr );
savePCB_TARGET( (PCB_TARGET*) gr );
break;
case PCB_DIMENSION_T:
saveDIMENTION( (DIMENSION*) gr );
......@@ -2684,13 +2685,13 @@ void KICAD_PLUGIN::saveBOARD() const
// save the tracks & vias
fprintf( m_fp, "$TRACK\n" );
for( TRACK* track = m_board->m_Track; track; track = track->Next() )
saveTRACK( (TRACK*) track );
saveTRACK( track );
fprintf( m_fp, "$EndTRACK\n" );
// save the zones
// save the old obsolete zones which were done by segments (tracks)
fprintf( m_fp, "$ZONE\n" );
for( SEGZONE* zone = m_board->m_Zone; zone; zone = zone->Next() )
saveSEGZONE( zone );
saveTRACK( zone );
fprintf( m_fp, "$EndZONE\n" );
// save the polygon (which are the newer technology) zones
......@@ -2698,7 +2699,8 @@ void KICAD_PLUGIN::saveBOARD() const
saveZONE_CONTAINER( m_board->GetArea( i ) );
fprintf( m_fp, "$EndBOARD\n" );
#endif
CHECK_WRITE_ERROR();
}
......@@ -2935,7 +2937,7 @@ void KICAD_PLUGIN::saveMODULE( const MODULE* me ) const
statusTxt[2] = '\0';
fprintf( m_fp, "Po %s %g %d %8.8lX %8.8lX %s\n",
fprintf( m_fp, "Po %s %g %d %8lX %8lX %s\n",
fmtBIUPoint( me->GetPosition() ).c_str(), // m_Pos.x, m_Pos.y,
orient,
me->GetLayer(),
......@@ -2955,7 +2957,7 @@ void KICAD_PLUGIN::saveMODULE( const MODULE* me ) const
fprintf( m_fp, "Kw %s\n", TO_UTF8( me->GetKeywords() ) );
}
fprintf( m_fp, "Sc %8.8lX\n", me->GetTimeStamp() );
fprintf( m_fp, "Sc %8lX\n", me->GetTimeStamp() );
fprintf( m_fp, "AR %s\n", TO_UTF8( me->GetPath() ) );
fprintf( m_fp, "Op %X %X 0\n", me->m_CntRot90, me->m_CntRot180 );
......@@ -3011,6 +3013,8 @@ void KICAD_PLUGIN::saveMODULE( const MODULE* me ) const
save3D( me );
fprintf( m_fp, "$EndMODULE %s\n", TO_UTF8( me->GetLibRef() ) );
CHECK_WRITE_ERROR();
}
......@@ -3045,234 +3049,177 @@ void KICAD_PLUGIN::save3D( const MODULE* me ) const
}
void KICAD_PLUGIN::saveTARGET(PCB_TARGET const*) const
{
}
void KICAD_PLUGIN::saveTRACK(TRACK const*) const
{
}
void KICAD_PLUGIN::saveSEGZONE(SEGZONE const*) const
{
}
void KICAD_PLUGIN::saveZONE_CONTAINER(ZONE_CONTAINER const*) const
{
}
void KICAD_PLUGIN::saveDIMENTION(DIMENSION const*) const
void KICAD_PLUGIN::savePCB_TARGET( const PCB_TARGET* me ) const
{
}
fprintf( m_fp, "$PCB_TARGET\n" );
void KICAD_PLUGIN::savePCB_TEXT(TEXTE_PCB const*) const
{
}
fprintf( m_fp, "Po %X %d %s %s %s %8lX\n",
me->GetShape(),
me->GetLayer(),
fmtBIUPoint( me->GetPosition() ).c_str(),
fmtBIU( me->GetSize() ).c_str(),
fmtBIU( me->GetWidth() ).c_str(),
me->GetTimeStamp()
);
fprintf( m_fp, "$EndPCB_TARGET\n" );
void KICAD_PLUGIN::saveEDGE_MODULE(EDGE_MODULE const*) const
{
CHECK_WRITE_ERROR();
}
#if 0
bool DRAWSEGMENT::Save( FILE* m_fp ) const
void KICAD_PLUGIN::savePCB_LINE( const DRAWSEGMENT* me ) const
{
if( fprintf( m_fp, "$DRAWSEGMENT\n" ) != sizeof("$DRAWSEGMENT\n") - 1 )
return false;
fprintf( m_fp, "$DRAWSEGMENT\n" );
fprintf( m_fp, "Po %d %d %d %d %d %d\n",
m_Shape,
m_Start.x, m_Start.y,
m_End.x, m_End.y, m_Width );
fprintf( m_fp, "Po %d %s %s %s\n",
me->GetShape(),
fmtBIUPoint( me->GetStart() ).c_str(),
fmtBIUPoint( me->GetEnd() ).c_str(),
fmtBIU( me->GetWidth() ).c_str()
);
if( m_Type != S_CURVE )
if( me->GetType() != S_CURVE )
{
fprintf( m_fp, "De %d %d %d %lX %X\n",
m_Layer, m_Type, m_Angle,
m_TimeStamp, ReturnStatus() );
fprintf( m_fp, "De %d %d %g %8lX %X\n",
me->GetLayer(),
me->GetType(),
me->GetAngle(),
me->GetTimeStamp(),
me->GetStatus()
);
}
else
{
fprintf( m_fp, "De %d %d %d %lX %X %d %d %d %d\n",
m_Layer, m_Type, m_Angle,
m_TimeStamp, ReturnStatus(),
m_BezierC1.x,m_BezierC1.y,
m_BezierC2.x,m_BezierC2.y);
fprintf( m_fp, "De %d %d %g %8lX %X %s %s\n",
me->GetLayer(),
me->GetType(),
me->GetAngle(),
me->GetTimeStamp(),
me->GetStatus(),
fmtBIUPoint( me->GetBezControl1() ).c_str(),
fmtBIUPoint( me->GetBezControl2() ).c_str()
);
}
if( fprintf( m_fp, "$EndDRAWSEGMENT\n" ) != sizeof("$EndDRAWSEGMENT\n") - 1 )
return false;
return true;
fprintf( m_fp, "$EndDRAWSEGMENT\n" );
}
bool PCB_TARGET::Save( FILE* m_fp ) const
void KICAD_PLUGIN::saveTRACK( const TRACK* me ) const
{
bool rc = false;
if( fprintf( m_fp, "$PCB_TARGET\n" ) != sizeof("$PCB_TARGET\n")-1 )
goto out;
fprintf( m_fp, "Po %X %d %d %d %d %d %8.8lX\n",
m_Shape, m_Layer,
m_Pos.x, m_Pos.y,
m_Size, m_Width, m_TimeStamp );
int type = 0;
if( fprintf( m_fp, "$EndPCB_TARGET\n" ) != sizeof("$EndPCB_TARGET\n")-1 )
goto out;
if( me->Type() == PCB_VIA_T )
type = 1;
rc = true;
fprintf(m_fp, "Po %d %s %s %s %s\n",
me->GetShape(),
fmtBIUPoint( me->GetStart() ).c_str(),
fmtBIUPoint( me->GetEnd() ).c_str(),
fmtBIU( me->GetWidth() ).c_str(),
fmtBIU( me->GetDrill() ).c_str() );
out:
return rc;
fprintf(m_fp, "De %d %d %d %8lX %X\n",
me->GetLayer(), type, me->GetNet(),
me->GetTimeStamp(), me->GetStatus() );
}
bool ZONE_CONTAINER::Save( FILE* m_fp ) const
void KICAD_PLUGIN::saveZONE_CONTAINER( const ZONE_CONTAINER* me ) const
{
unsigned item_pos;
int ret;
unsigned corners_count = m_Poly->corner.size();
int outline_hatch;
char padoption;
fprintf( m_fp, "$CZONE_OUTLINE\n" );
// Save the outline main info
ret = fprintf( m_fp, "ZInfo %8.8lX %d %s\n",
m_TimeStamp, m_NetCode,
EscapedUTF8( m_Netname ).c_str() );
if( ret < 3 )
return false;
fprintf( m_fp, "ZInfo %8lX %d %s\n",
me->GetTimeStamp(), me->GetNet(),
EscapedUTF8( me->GetNetName() ).c_str() );
// Save the outline layer info
ret = fprintf( m_fp, "ZLayer %d\n", m_Layer );
if( ret < 1 )
return false;
fprintf( m_fp, "ZLayer %d\n", me->GetLayer() );
// Save the outline aux info
switch( m_Poly->GetHatchStyle() )
int outline_hatch;
switch( me->GetHatchStyle() )
{
default:
case CPolyLine::NO_HATCH:
outline_hatch = 'N';
break;
case CPolyLine::DIAGONAL_EDGE:
outline_hatch = 'E';
break;
case CPolyLine::DIAGONAL_FULL:
outline_hatch = 'F';
break;
case CPolyLine::NO_HATCH: outline_hatch = 'N'; break;
case CPolyLine::DIAGONAL_EDGE: outline_hatch = 'E'; break;
case CPolyLine::DIAGONAL_FULL: outline_hatch = 'F'; break;
}
ret = fprintf( m_fp, "ZAux %d %c\n", corners_count, outline_hatch );
if( ret < 2 )
return false;
fprintf( m_fp, "ZAux %d %c\n", me->GetNumCorners(), outline_hatch );
// Save pad option and clearance
switch( m_PadOption )
char padoption;
switch( me->GetPadOption() )
{
default:
case PAD_IN_ZONE:
padoption = 'I';
break;
case THERMAL_PAD:
padoption = 'T';
break;
case PAD_NOT_IN_ZONE:
padoption = 'X';
break;
case PAD_IN_ZONE: padoption = 'I'; break;
case THERMAL_PAD: padoption = 'T'; break;
case PAD_NOT_IN_ZONE: padoption = 'X'; break;
}
ret = fprintf( m_fp, "ZClearance %d %c\n", m_ZoneClearance, padoption );
fprintf( m_fp, "ZClearance %s %c\n",
fmtBIU( me->GetZoneClearance() ).c_str(),
padoption );
if( ret < 2 )
return false;
fprintf( m_fp, "ZMinThickness %s\n", fmtBIU( me->GetMinThickness() ).c_str() );
ret = fprintf( m_fp, "ZMinThickness %d\n", m_ZoneMinThickness );
fprintf( m_fp, "ZOptions %d %d %c %s %s\n",
me->GetFillMode(),
me->GetArcSegCount(),
me->IsFilled() ? 'S' : 'F',
fmtBIU( me->GetThermalReliefGap() ).c_str(),
fmtBIU( me->GetThermalReliefCopperBridge() ).c_str() );
if( ret < 1 )
return false;
fprintf( m_fp, "ZSmoothing %d %s\n",
me->GetCornerSmoothingType(),
fmtBIU( me->GetCornerRadius() ).c_str() );
ret = fprintf( m_fp,
"ZOptions %d %d %c %d %d\n",
m_FillMode,
m_ArcToSegmentsCount,
m_IsFilled ? 'S' : 'F',
m_ThermalReliefGap,
m_ThermalReliefCopperBridge );
if( ret < 3 )
return false;
ret = fprintf( m_fp,
"ZSmoothing %d %d\n",
cornerSmoothingType, cornerRadius );
if( ret < 2 )
return false;
typedef std::vector< CPolyPt > CPOLY_PTS;
// Save the corner list
for( item_pos = 0; item_pos < corners_count; item_pos++ )
const CPOLY_PTS& cv = me->m_Poly->corner;
for( CPOLY_PTS::const_iterator it = cv.begin(); it != cv.end(); ++it )
{
ret = fprintf( m_fp, "ZCorner %d %d %d\n",
m_Poly->corner[item_pos].x, m_Poly->corner[item_pos].y,
m_Poly->corner[item_pos].end_contour );
if( ret < 3 )
return false;
fprintf( m_fp, "ZCorner %s %d\n",
fmtBIUPair( it->x, it->y ).c_str(),
it->end_contour );
}
// Save the PolysList
if( m_FilledPolysList.size() )
const CPOLY_PTS& fv = me->m_FilledPolysList;
if( fv.size() )
{
fprintf( m_fp, "$POLYSCORNERS\n" );
for( unsigned ii = 0; ii < m_FilledPolysList.size(); ii++ )
for( CPOLY_PTS::const_iterator it = fv.begin(); it != fv.end(); ++it )
{
const CPolyPt* corner = &m_FilledPolysList[ii];
ret = fprintf( m_fp,
"%d %d %d %d\n",
corner->x,
corner->y,
corner->end_contour,
corner->utility );
if( ret < 4 )
return false;
fprintf( m_fp, "%s %d %d\n",
fmtBIUPair( it->x, it->y ).c_str(),
it->end_contour,
it->utility );
}
fprintf( m_fp, "$endPOLYSCORNERS\n" );
}
typedef std::vector< SEGMENT > SEGMENTS;
// Save the filling segments list
if( m_FillSegmList.size() )
const SEGMENTS& segs = me->m_FillSegmList;
if( segs.size() )
{
fprintf( m_fp, "$FILLSEGMENTS\n" );
for( unsigned ii = 0; ii < m_FillSegmList.size(); ii++ )
for( SEGMENTS::const_iterator it = segs.begin(); it != segs.end(); ++it )
{
ret = fprintf( m_fp, "%d %d %d %d\n",
m_FillSegmList[ii].m_Start.x, m_FillSegmList[ii].m_Start.y,
m_FillSegmList[ii].m_End.x, m_FillSegmList[ii].m_End.y );
if( ret < 4 )
return false;
fprintf( m_fp, "%s %s\n",
fmtBIUPoint( it->m_Start ).c_str(),
fmtBIUPoint( it->m_End ).c_str() );
}
fprintf( m_fp, "$endFILLSEGMENTS\n" );
......@@ -3280,146 +3227,117 @@ bool ZONE_CONTAINER::Save( FILE* m_fp ) const
fprintf( m_fp, "$endCZONE_OUTLINE\n" );
return true;
CHECK_WRITE_ERROR();
}
bool TEXTE_PCB::Save( FILE* m_fp ) const
void KICAD_PLUGIN::saveDIMENTION( const DIMENSION* me ) const
{
if( m_Text.IsEmpty() )
return true;
if( fprintf( m_fp, "$TEXTPCB\n" ) != sizeof("$TEXTPCB\n") - 1 )
return false;
// note: COTATION was the previous name of DIMENSION
// this old keyword is used here for compatibility
fprintf( m_fp, "$COTATION\n" );
const char* style = m_Italic ? "Italic" : "Normal";
fprintf( m_fp, "Ge %d %d %8lX\n", me->GetShape(), me->GetLayer(), me->GetTimeStamp() );
wxArrayString* list = wxStringSplit( m_Text, '\n' );
fprintf( m_fp, "Va %d\n", me->m_Value );
for( unsigned ii = 0; ii < list->Count(); ii++ )
{
wxString txt = list->Item( ii );
if ( ii == 0 )
fprintf( m_fp, "Te %s\n", EscapedUTF8( txt ).c_str() );
if( !me->m_Text.GetText().IsEmpty() )
fprintf( m_fp, "Te %s\n", EscapedUTF8( me->m_Text.GetText() ).c_str() );
else
fprintf( m_fp, "nl %s\n", EscapedUTF8( txt ).c_str() );
}
delete list;
fprintf( m_fp, "Po %d %d %d %d %d %d\n",
m_Pos.x, m_Pos.y, m_Size.x, m_Size.y, m_Thickness, m_Orient );
fprintf( m_fp, "Te \"?\"\n" );
char hJustify = 'L';
switch( m_HJustify )
{
case GR_TEXT_HJUSTIFY_LEFT:
hJustify = 'L';
break;
case GR_TEXT_HJUSTIFY_CENTER:
hJustify = 'C';
break;
case GR_TEXT_HJUSTIFY_RIGHT:
hJustify = 'R';
break;
default:
hJustify = 'C';
break;
}
fprintf( m_fp, "Po %s %s %s %g %d\n",
fmtBIUPoint( me->m_Text.GetPosition() ).c_str(),
fmtBIUSize( me->m_Text.GetSize() ).c_str(),
fmtBIU( me->m_Text.GetThickness() ).c_str(),
me->m_Text.GetOrientation(),
me->m_Text.IsMirrored() ? 0 : 1 // strange but true
);
fprintf( m_fp, "De %d %d %lX %s %c\n", m_Layer,
m_Mirror ? 0 : 1,
m_TimeStamp, style, hJustify );
fprintf( m_fp, "Sb %d %s %s %s\n", S_SEGMENT,
fmtBIUPair( me->m_crossBarOx, me->m_crossBarOy ).c_str(),
fmtBIUPair( me->m_crossBarFx, me->m_crossBarFy ).c_str(),
fmtBIU( me->GetWidth() ).c_str() );
if( fprintf( m_fp, "$EndTEXTPCB\n" ) != sizeof("$EndTEXTPCB\n") - 1 )
return false;
fprintf( m_fp, "Sd %d %s %s %s\n", S_SEGMENT,
fmtBIUPair( me->m_featureLineDOx, me->m_featureLineDOy ).c_str(),
fmtBIUPair( me->m_featureLineDFx, me->m_featureLineDFy ).c_str(),
fmtBIU( me->GetWidth() ).c_str() );
return true;
}
fprintf( m_fp, "Sg %d %s %s %s\n", S_SEGMENT,
fmtBIUPair( me->m_featureLineGOx, me->m_featureLineGOy ).c_str(),
fmtBIUPair( me->m_featureLineGFx, me->m_featureLineGFy ).c_str(),
fmtBIU( me->GetWidth() ).c_str() );
fprintf( m_fp, "S1 %d %s %s %s\n", S_SEGMENT,
fmtBIUPair( me->m_arrowD1Ox, me->m_arrowD1Oy ).c_str(),
fmtBIUPair( me->m_arrowD1Fx, me->m_arrowD1Fy ).c_str(),
fmtBIU( me->GetWidth() ).c_str() );
bool TRACK::Save( FILE* m_fp ) const
{
int type = 0;
fprintf( m_fp, "S2 %d %s %s %s\n", S_SEGMENT,
fmtBIUPair( me->m_arrowD2Ox, me->m_arrowD2Oy ).c_str(),
fmtBIUPair( me->m_arrowD2Fx, me->m_arrowD2Fy ).c_str(),
fmtBIU( me->GetWidth() ).c_str() );
if( Type() == PCB_VIA_T )
type = 1;
fprintf( m_fp, "S3 %d %s %s %s\n", S_SEGMENT,
fmtBIUPair( me->m_arrowG1Ox, me->m_arrowG1Oy ).c_str(),
fmtBIUPair( me->m_arrowG1Fx, me->m_arrowG1Fy ).c_str(),
fmtBIU( me->GetWidth() ).c_str() );
fprintf( m_fp, "Po %d %d %d %d %d %d %d\n", m_Shape,
m_Start.x, m_Start.y, m_End.x, m_End.y, m_Width, m_Drill );
fprintf( m_fp, "S4 %d %s %s %s\n", S_SEGMENT,
fmtBIUPair( me->m_arrowG2Ox, me->m_arrowG2Oy ).c_str(),
fmtBIUPair( me->m_arrowG2Fx, me->m_arrowG2Fy ).c_str(),
fmtBIU( me->GetWidth() ).c_str() );
fprintf( m_fp, "De %d %d %d %lX %X\n",
m_Layer, type, GetNet(),
m_TimeStamp, ReturnStatus() );
fprintf( m_fp, "$endCOTATION\n" );
return true;
CHECK_WRITE_ERROR();
}
bool DIMENSION::Save( FILE* m_fp ) const
void KICAD_PLUGIN::savePCB_TEXT( const TEXTE_PCB* me ) const
{
bool rc = false;
if( me->GetText().IsEmpty() )
return;
// note: COTATION was the previous name of DIMENSION
// this old keyword is used here for compatibility
const char keyWordLine[] = "$COTATION\n";
const char keyWordLineEnd[] = "$endCOTATION\n";
if( fputs( keyWordLine, m_fp ) == EOF )
goto out;
fprintf( m_fp, "$TEXTPCB\n" );
fprintf( m_fp, "Ge %d %d %lX\n", m_Shape, m_Layer, m_TimeStamp );
wxArrayString* list = wxStringSplit( me->GetText(), '\n' );
fprintf( m_fp, "Va %d\n", m_Value );
for( unsigned ii = 0; ii < list->Count(); ii++ )
{
wxString txt = list->Item( ii );
if( !m_Text->m_Text.IsEmpty() )
fprintf( m_fp, "Te %s\n", EscapedUTF8( m_Text->m_Text ).c_str() );
if ( ii == 0 )
fprintf( m_fp, "Te %s\n", EscapedUTF8( txt ).c_str() );
else
fprintf( m_fp, "Te \"?\"\n" );
fprintf( m_fp, "Po %d %d %d %d %d %d %d\n",
m_Text->m_Pos.x, m_Text->m_Pos.y,
m_Text->m_Size.x, m_Text->m_Size.y,
m_Text->GetThickness(), m_Text->GetOrientation(),
m_Text->m_Mirror ? 0 : 1 );
fprintf( m_fp, "Sb %d %d %d %d %d %d\n", S_SEGMENT,
m_crossBarOx, m_crossBarOy,
m_crossBarFx, m_crossBarFy, m_Width );
fprintf( m_fp, "Sd %d %d %d %d %d %d\n", S_SEGMENT,
m_featureLineDOx, m_featureLineDOy,
m_featureLineDFx, m_featureLineDFy, m_Width );
fprintf( m_fp, "Sg %d %d %d %d %d %d\n", S_SEGMENT,
m_featureLineGOx, m_featureLineGOy,
m_featureLineGFx, m_featureLineGFy, m_Width );
fprintf( m_fp, "S1 %d %d %d %d %d %d\n", S_SEGMENT,
m_arrowD1Ox, m_arrowD1Oy,
m_arrowD1Fx, m_arrowD1Fy, m_Width );
fprintf( m_fp, "S2 %d %d %d %d %d %d\n", S_SEGMENT,
m_arrowD2Ox, m_arrowD2Oy,
m_arrowD2Fx, m_arrowD2Fy, m_Width );
fprintf( m_fp, "nl %s\n", EscapedUTF8( txt ).c_str() );
}
delete list;
fprintf( m_fp, "S3 %d %d %d %d %d %d\n", S_SEGMENT,
m_arrowG1Ox, m_arrowG1Oy,
m_arrowG1Fx, m_arrowG1Fy, m_Width );
fprintf( m_fp, "Po %s %s %s %g\n",
fmtBIUPoint( me->GetPosition() ).c_str(),
fmtBIUSize( me->GetSize() ).c_str(),
fmtBIU( me->GetThickness() ).c_str(),
me->GetOrientation() );
fprintf( m_fp, "S4 %d %d %d %d %d %d\n", S_SEGMENT,
m_arrowG2Ox, m_arrowG2Oy,
m_arrowG2Fx, m_arrowG2Fy, m_Width );
char hJustify;
if( fputs( keyWordLineEnd, m_fp ) == EOF )
goto out;
switch( me->GetHorizJustify() )
{
default:
case GR_TEXT_HJUSTIFY_CENTER: hJustify = 'C'; break;
case GR_TEXT_HJUSTIFY_LEFT: hJustify = 'L'; break;
case GR_TEXT_HJUSTIFY_RIGHT: hJustify = 'R'; break;
}
rc = true;
fprintf( m_fp, "De %d %d %8lX %s %c\n",
me->GetLayer(),
!me->IsMirrored(),
me->GetTimeStamp(),
me->IsItalic() ? "Italic" : "Normal",
hJustify );
out:
return rc;
fprintf( m_fp, "$EndTEXTPCB\n" );
}
#endif
......@@ -83,12 +83,6 @@ protected:
/// initialize PLUGIN like a constructor would, and futz with fresh BOARD if needed.
void init( PROPERTIES* aProperties );
int NbDraw;
int NbTrack;
int NbZone;
int NbMod;
int NbNets;
double biuToDisk; ///< convert from BIUs to disk engineering units with this scale factor
double diskToBiu; ///< convert from disk engineering units to BIUs with this scale factor
......@@ -135,9 +129,9 @@ protected:
void load3D( MODULE* aModule );
void loadPAD( MODULE* aModule );
void loadMODULE_TEXT( TEXTE_MODULE* aText );
void loadEDGE_MODULE( MODULE* aModule );
void loadMODULE_EDGE( MODULE* aModule );
void loadDRAWSEGMENT();
void loadPCB_LINE();
void loadNETINFO_ITEM();
void loadPCB_TEXT();
void loadNETCLASS();
......@@ -206,17 +200,11 @@ protected:
void saveNETCLASS( const NETCLASS* aNetclass ) const;
void savePCB_TEXT( const TEXTE_PCB* aText ) const;
void saveEDGE_MODULE( const EDGE_MODULE* aEdge ) const;
void saveTARGET( const PCB_TARGET* aTarget ) const;
void savePCB_TARGET( const PCB_TARGET* aTarget ) const;
void savePCB_LINE( const DRAWSEGMENT* aStroke ) const;
void saveDIMENTION( const DIMENSION* aDimension ) const;
void saveTRACK( const TRACK* aTrack ) const;
/**
* Function saveSEGZONE
* saves the oldschool zones, now outdated in favor of polygon zones.
*/
void saveSEGZONE( const SEGZONE* aZone ) const;
/**
* Function saveZONE_CONTAINER
* saves the new polygon zones.
......
......@@ -102,13 +102,13 @@ TARGET_PROPERTIES_DIALOG_EDITOR::TARGET_PROPERTIES_DIALOG_EDITOR( PCB_EDIT_FRAME
// Size:
m_MireSizeCtrl = new EDA_VALUE_CTRL( this, _( "Size" ),
m_Target->m_Size,
m_Target->GetSize(),
g_UserUnit, LeftBoxSizer,
m_Parent->m_InternalUnits );
// Width:
m_MireWidthCtrl = new EDA_VALUE_CTRL( this, _( "Width" ),
m_Target->m_Width,
m_Target->GetWidth(),
g_UserUnit, LeftBoxSizer,
m_Parent->m_InternalUnits );
......@@ -118,7 +118,7 @@ TARGET_PROPERTIES_DIALOG_EDITOR::TARGET_PROPERTIES_DIALOG_EDITOR( PCB_EDIT_FRAME
_( "Target Shape:" ),
wxDefaultPosition, wxSize( -1, -1 ),
2, shape_list, 1 );
m_MireShape->SetSelection( m_Target->m_Shape ? 1 : 0 );
m_MireShape->SetSelection( m_Target->GetShape() ? 1 : 0 );
LeftBoxSizer->Add( m_MireShape, 0, wxGROW | wxALL, 5 );
GetSizer()->Fit( this );
......@@ -146,9 +146,10 @@ void TARGET_PROPERTIES_DIALOG_EDITOR::OnOkClick( wxCommandEvent& event )
m_Target->m_Flags |= IN_EDIT; // set flag in edit to force
// undo/redo/abort proper operation
m_Target->m_Width = m_MireWidthCtrl->GetValue();
MireDefaultSize = m_Target->m_Size = m_MireSizeCtrl->GetValue();
m_Target->m_Shape = m_MireShape->GetSelection() ? 1 : 0;
m_Target->SetWidth( m_MireWidthCtrl->GetValue() );
MireDefaultSize = m_MireSizeCtrl->GetValue();
m_Target->SetSize( m_MireSizeCtrl->GetValue() );
m_Target->SetShape( m_MireShape->GetSelection() ? 1 : 0 );
m_Target->Draw( m_Parent->DrawPanel, m_DC, ( m_Target->m_Flags & IS_MOVED ) ? GR_XOR : GR_OR );
......@@ -188,14 +189,14 @@ static void AbortMoveAndEditTarget( EDA_DRAW_PANEL* Panel, wxDC* DC )
target->DeleteStructure();
target = NULL;
}
else /* it is an existing item: retrieve initial values of parameters */
else // it is an existing item: retrieve initial values of parameters
{
if( ( target->m_Flags & (IN_EDIT | IS_MOVED) ) )
{
target->m_Pos = s_TargetCopy.m_Pos;
target->m_Width = s_TargetCopy.m_Width;
target->m_Size = s_TargetCopy.m_Size;
target->m_Shape = s_TargetCopy.m_Shape;
target->SetPosition( s_TargetCopy.GetPosition() );
target->SetWidth( s_TargetCopy.GetWidth() );
target->SetSize( s_TargetCopy.GetSize() );
target->SetShape( s_TargetCopy.GetShape() );
}
target->m_Flags = 0;
target->Draw( Panel, DC, GR_OR );
......@@ -214,9 +215,9 @@ PCB_TARGET* PCB_EDIT_FRAME::CreateTarget( wxDC* DC )
GetBoard()->Add( target );
target->SetLayer( EDGE_N );
target->m_Width = GetBoard()->GetDesignSettings().m_EdgeSegmentWidth;
target->m_Size = MireDefaultSize;
target->m_Pos = DrawPanel->GetScreen()->GetCrossHairPosition();
target->SetWidth( GetBoard()->GetDesignSettings().m_EdgeSegmentWidth );
target->SetSize( MireDefaultSize );
target->SetPosition( DrawPanel->GetScreen()->GetCrossHairPosition() );
PlaceTarget( target, DC );
......@@ -257,7 +258,7 @@ void PCB_EDIT_FRAME::PlaceTarget( PCB_TARGET* aTarget, wxDC* DC )
if( aTarget->m_Flags == IS_MOVED )
{
SaveCopyInUndoList( aTarget, UR_MOVED, aTarget->m_Pos - s_TargetCopy.m_Pos );
SaveCopyInUndoList( aTarget, UR_MOVED, aTarget->GetPosition() - s_TargetCopy.GetPosition() );
aTarget->m_Flags = 0;
return;
}
......@@ -286,7 +287,7 @@ static void ShowTargetShapeWhileMovingMouse( EDA_DRAW_PANEL* aPanel, wxDC* aDC,
if( aErase )
target->Draw( aPanel, aDC, GR_XOR );
target->m_Pos = screen->GetCrossHairPosition();
target->SetPosition( screen->GetCrossHairPosition() );
target->Draw( aPanel, aDC, GR_XOR );
}
......@@ -696,17 +696,17 @@ void FOOTPRINT_EDIT_FRAME::Process_Special_Functions( wxCommandEvent& event )
void FOOTPRINT_EDIT_FRAME::Transform( MODULE* module, int transform )
{
D_PAD* pad = module->m_Pads;
EDA_ITEM* PtStruct = module->m_Drawings;
EDA_ITEM* item = module->m_Drawings;
TEXTE_MODULE* textmod;
EDGE_MODULE* edgemod;
int angle = 900; // Necessary +- 900 (+- 90 degrees) )
double angle = 900; // Necessary +- 900 (+- 90 degrees) )
switch( transform )
{
case ID_MODEDIT_MODULE_ROTATE:
module->SetOrientation( angle );
for( ; pad != NULL; pad = (D_PAD*) pad->Next() )
for( ; pad; pad = pad->Next() )
{
pad->SetPos0( pad->m_Pos );
pad->m_Orient -= angle;
......@@ -727,18 +727,18 @@ void FOOTPRINT_EDIT_FRAME::Transform( MODULE* module, int transform )
if( module->m_Value->m_Orient >= 1800 )
module->m_Value->m_Orient -= 1800;
for( ; PtStruct != NULL; PtStruct = PtStruct->Next() )
for( ; item != NULL; item = item->Next() )
{
if( PtStruct->Type() == PCB_MODULE_EDGE_T )
if( item->Type() == PCB_MODULE_EDGE_T )
{
edgemod = (EDGE_MODULE*) PtStruct;
edgemod->m_Start0 = edgemod->m_Start;
edgemod->m_End0 = edgemod->m_End;
edgemod = (EDGE_MODULE*) item;
edgemod->SetStart0( edgemod->GetStart() );
edgemod->SetEnd0( edgemod->GetEnd() );
}
if( PtStruct->Type() == PCB_MODULE_TEXT_T )
else if( item->Type() == PCB_MODULE_TEXT_T )
{
textmod = (TEXTE_MODULE*) PtStruct;
textmod = (TEXTE_MODULE*) item;
textmod->SetPos0( textmod->m_Pos );
}
}
......@@ -758,7 +758,7 @@ void FOOTPRINT_EDIT_FRAME::Transform( MODULE* module, int transform )
pad->m_Orient = 3600 - pad->m_Orient;
}
/* Reverse mirror of reference. */
// Reverse mirror of reference.
textmod = module->m_Reference;
NEGATE( textmod->m_Pos.y );
NEGATE( textmod->m_Pos0.y );
......@@ -766,7 +766,7 @@ void FOOTPRINT_EDIT_FRAME::Transform( MODULE* module, int transform )
if( textmod->m_Orient )
textmod->m_Orient = 3600 - textmod->m_Orient;
/* Reverse mirror of value. */
// Reverse mirror of value.
textmod = module->m_Value;
NEGATE( textmod->m_Pos.y );
NEGATE( textmod->m_Pos0.y );
......@@ -774,26 +774,28 @@ void FOOTPRINT_EDIT_FRAME::Transform( MODULE* module, int transform )
if( textmod->m_Orient )
textmod->m_Orient = 3600 - textmod->m_Orient;
/* Reverse mirror of footprints. */
PtStruct = module->m_Drawings;
// Reverse mirror of footprints.
item = module->m_Drawings;
for( ; PtStruct != NULL; PtStruct = PtStruct->Next() )
for( ; item; item = item->Next() )
{
switch( PtStruct->Type() )
switch( item->Type() )
{
case PCB_MODULE_EDGE_T:
edgemod = (EDGE_MODULE*) PtStruct;
NEGATE( edgemod->m_Start.y );
NEGATE( edgemod->m_End.y );
/* Invert local coordinates */
edgemod = (EDGE_MODULE*) item;
edgemod->SetStartY( -edgemod->GetStart().y );
edgemod->SetEndY( -edgemod->GetEnd().y );
// Invert local coordinates
NEGATE( edgemod->m_Start0.y );
NEGATE( edgemod->m_End0.y );
NEGATE( edgemod->m_Angle );
edgemod->SetAngle( -edgemod->GetAngle() );
break;
case PCB_MODULE_TEXT_T:
/* Reverse mirror position and mirror. */
textmod = (TEXTE_MODULE*) PtStruct;
// Reverse mirror position and mirror.
textmod = (TEXTE_MODULE*) item;
NEGATE( textmod->m_Pos.y );
NEGATE( textmod->m_Pos0.y );
......
......@@ -92,19 +92,19 @@ void FOOTPRINT_EDIT_FRAME::OnLeftClick( wxDC* DC, const wxPoint& MousePos )
}
else if( item->IsNew() )
{
if( ( (EDGE_MODULE*) item )->m_Shape == S_CIRCLE )
if( ( (EDGE_MODULE*) item )->GetShape() == S_CIRCLE )
{
End_Edge_Module( (EDGE_MODULE*) item );
SetCurItem( NULL );
DrawPanel->Refresh();
}
else if( ( (EDGE_MODULE*) item )->m_Shape == S_ARC )
else if( ( (EDGE_MODULE*) item )->GetShape() == S_ARC )
{
End_Edge_Module( (EDGE_MODULE*) item );
SetCurItem( NULL );
DrawPanel->Refresh();
}
else if( ( (EDGE_MODULE*) item )->m_Shape == S_SEGMENT )
else if( ( (EDGE_MODULE*) item )->GetShape() == S_SEGMENT )
{
SetCurItem( Begin_Edge_Module( (EDGE_MODULE*) item, DC, 0 ) );
}
......
......@@ -196,7 +196,7 @@ MODULE* PCB_EDIT_FRAME::Genere_Self( wxDC* DC )
int min_len = wxRound( sqrt( (double) pt.x * pt.x + (double) pt.y * pt.y ) );
Mself.lng = min_len;
/* Enter the desired length. */
// Enter the desired length.
msg = ReturnStringFromValue( g_UserUnit, Mself.lng, GetScreen()->GetInternalUnits() );
wxTextEntryDialog dlg( this, _( "Length:" ), _( "Length" ), msg );
......@@ -206,14 +206,14 @@ MODULE* PCB_EDIT_FRAME::Genere_Self( wxDC* DC )
msg = dlg.GetValue();
Mself.lng = ReturnValueFromString( g_UserUnit, msg, GetScreen()->GetInternalUnits() );
/* Control values (ii = minimum length) */
// Control values (ii = minimum length)
if( Mself.lng < min_len )
{
DisplayError( this, _( "Requested length < minimum length" ) );
return NULL;
}
/* Calculate the elements. */
// Calculate the elements.
Mself.m_Width = GetBoard()->GetCurrentTrackWidth();
std::vector <wxPoint> buffer;
......@@ -225,75 +225,74 @@ MODULE* PCB_EDIT_FRAME::Genere_Self( wxDC* DC )
return NULL;
}
// Generate module.
MODULE* module;
module = Create_1_Module( wxEmptyString );
/* Generate module. */
MODULE* Module;
Module = Create_1_Module( wxEmptyString );
if( Module == NULL )
if( module == NULL )
return NULL;
// here the Module is already in the BOARD, Create_1_Module() does that.
Module->m_LibRef = wxT( "MuSelf" );
Module->m_Attributs = MOD_VIRTUAL | MOD_CMS;
Module->m_Flags = 0;
Module->m_Pos = Mself.m_End;
// here the module is already in the BOARD, Create_1_Module() does that.
module->m_LibRef = wxT( "MuSelf" );
module->m_Attributs = MOD_VIRTUAL | MOD_CMS;
module->m_Flags = 0;
module->m_Pos = Mself.m_End;
/* Generate segments. */
// Generate segments
for( unsigned jj = 1; jj < buffer.size(); jj++ )
{
EDGE_MODULE* PtSegm;
PtSegm = new EDGE_MODULE( Module );
PtSegm->m_Start = buffer[jj - 1];
PtSegm->m_End = buffer[jj];
PtSegm->m_Width = Mself.m_Width;
PtSegm->SetLayer( Module->GetLayer() );
PtSegm->m_Shape = S_SEGMENT;
PtSegm->m_Start0 = PtSegm->m_Start - Module->m_Pos;
PtSegm->m_End0 = PtSegm->m_End - Module->m_Pos;
Module->m_Drawings.PushBack( PtSegm );
PtSegm = new EDGE_MODULE( module );
PtSegm->SetStart( buffer[jj - 1] );
PtSegm->SetEnd( buffer[jj] );
PtSegm->SetWidth( Mself.m_Width );
PtSegm->SetLayer( module->GetLayer() );
PtSegm->SetShape( S_SEGMENT );
PtSegm->SetStart0( PtSegm->GetStart() - module->GetPosition() );
PtSegm->SetEnd0( PtSegm->GetEnd() - module->GetPosition() );
module->m_Drawings.PushBack( PtSegm );
}
/* Place a pad on each end of coil. */
PtPad = new D_PAD( Module );
// Place a pad on each end of coil.
PtPad = new D_PAD( module );
Module->m_Pads.PushFront( PtPad );
module->m_Pads.PushFront( PtPad );
PtPad->SetPadName( wxT( "1" ) );
PtPad->m_Pos = Mself.m_End;
PtPad->m_Pos0 = PtPad->m_Pos - Module->m_Pos;
PtPad->m_Pos0 = PtPad->m_Pos - module->m_Pos;
PtPad->m_Size.x = PtPad->m_Size.y = Mself.m_Width;
PtPad->m_layerMask = GetLayerMask( Module->GetLayer() );
PtPad->m_layerMask = GetLayerMask( module->GetLayer() );
PtPad->m_Attribut = PAD_SMD;
PtPad->m_PadShape = PAD_CIRCLE;
PtPad->ComputeShapeMaxRadius();
D_PAD* newpad = new D_PAD( Module );
D_PAD* newpad = new D_PAD( module );
newpad->Copy( PtPad );
Module->m_Pads.Insert( newpad, PtPad->Next() );
module->m_Pads.Insert( newpad, PtPad->Next() );
PtPad = newpad;
PtPad->SetPadName( wxT( "2" ) );
PtPad->m_Pos = Mself.m_Start;
PtPad->m_Pos0 = PtPad->m_Pos - Module->m_Pos;
PtPad->m_Pos0 = PtPad->m_Pos - module->m_Pos;
/* Modify text positions. */
Module->DisplayInfo( this );
Module->m_Value->m_Pos.x = Module->m_Reference->m_Pos.x =
// Modify text positions.
module->DisplayInfo( this );
module->m_Value->m_Pos.x = module->m_Reference->m_Pos.x =
( Mself.m_Start.x + Mself.m_End.x ) / 2;
Module->m_Value->m_Pos.y = Module->m_Reference->m_Pos.y =
module->m_Value->m_Pos.y = module->m_Reference->m_Pos.y =
( Mself.m_Start.y + Mself.m_End.y ) / 2;
Module->m_Reference->m_Pos.y -= Module->m_Reference->m_Size.y;
Module->m_Value->m_Pos.y += Module->m_Value->m_Size.y;
Module->m_Reference->SetPos0( Module->m_Reference->m_Pos - Module->m_Pos );
Module->m_Value->SetPos0( Module->m_Value->m_Pos - Module->m_Pos );
module->m_Reference->m_Pos.y -= module->m_Reference->m_Size.y;
module->m_Value->m_Pos.y += module->m_Value->m_Size.y;
module->m_Reference->SetPos0( module->m_Reference->m_Pos - module->m_Pos );
module->m_Value->SetPos0( module->m_Value->m_Pos - module->m_Pos );
Module->CalculateBoundingBox();
Module->Draw( DrawPanel, DC, GR_OR );
module->CalculateBoundingBox();
module->Draw( DrawPanel, DC, GR_OR );
return Module;
return module;
}
......@@ -522,33 +521,33 @@ int BuildCornersList_S_Shape( std::vector <wxPoint>& aBuffer,
MODULE* PCB_EDIT_FRAME::Create_MuWaveBasicShape( const wxString& name, int pad_count )
{
MODULE* Module;
MODULE* module;
int pad_num = 1;
wxString Line;
Module = Create_1_Module( name );
module = Create_1_Module( name );
if( Module == NULL )
if( module == NULL )
return NULL;
#define DEFAULT_SIZE 30
Module->SetTimeStamp( GetNewTimeStamp() );
module->SetTimeStamp( GetNewTimeStamp() );
Module->m_Value->m_Size = wxSize( DEFAULT_SIZE, DEFAULT_SIZE );
module->m_Value->m_Size = wxSize( DEFAULT_SIZE, DEFAULT_SIZE );
Module->m_Value->SetPos0( wxPoint( 0, -DEFAULT_SIZE ) );
module->m_Value->SetPos0( wxPoint( 0, -DEFAULT_SIZE ) );
Module->m_Value->m_Pos.y += Module->m_Value->GetPos0().y;
module->m_Value->m_Pos.y += module->m_Value->GetPos0().y;
Module->m_Value->m_Thickness = DEFAULT_SIZE / 4;
module->m_Value->m_Thickness = DEFAULT_SIZE / 4;
Module->m_Reference->m_Size = wxSize( DEFAULT_SIZE, DEFAULT_SIZE );
module->m_Reference->m_Size = wxSize( DEFAULT_SIZE, DEFAULT_SIZE );
Module->m_Reference->SetPos0( wxPoint( 0, DEFAULT_SIZE ) );
module->m_Reference->SetPos0( wxPoint( 0, DEFAULT_SIZE ) );
Module->m_Reference->m_Pos.y += Module->m_Reference->GetPos0().y;
module->m_Reference->m_Pos.y += module->m_Reference->GetPos0().y;
Module->m_Reference->m_Thickness = DEFAULT_SIZE / 4;
module->m_Reference->m_Thickness = DEFAULT_SIZE / 4;
/* Create 2 pads used in gaps and stubs.
* The gap is between these 2 pads
......@@ -556,12 +555,12 @@ MODULE* PCB_EDIT_FRAME::Create_MuWaveBasicShape( const wxString& name, int pad_c
*/
while( pad_count-- )
{
D_PAD* pad = new D_PAD( Module );
D_PAD* pad = new D_PAD( module );
Module->m_Pads.PushFront( pad );
module->m_Pads.PushFront( pad );
pad->m_Size.x = pad->m_Size.y = GetBoard()->GetCurrentTrackWidth();
pad->m_Pos = Module->m_Pos;
pad->m_Pos = module->m_Pos;
pad->m_PadShape = PAD_RECT;
pad->m_Attribut = PAD_SMD;
pad->m_layerMask = LAYER_FRONT;
......@@ -570,7 +569,7 @@ MODULE* PCB_EDIT_FRAME::Create_MuWaveBasicShape( const wxString& name, int pad_c
pad_num++;
}
return Module;
return module;
}
......@@ -578,7 +577,7 @@ MODULE* PCB_EDIT_FRAME::Create_MuWaveComponent( int shape_type )
{
int oX;
D_PAD* pad;
MODULE* Module;
MODULE* module;
wxString msg, cmp_name;
int pad_count = 2;
int angle = 0;
......@@ -658,8 +657,8 @@ MODULE* PCB_EDIT_FRAME::Create_MuWaveComponent( int shape_type )
return NULL;
}
Module = Create_MuWaveBasicShape( cmp_name, pad_count );
pad = Module->m_Pads;
module = Create_MuWaveBasicShape( cmp_name, pad_count );
pad = module->m_Pads;
switch( shape_type )
{
......@@ -681,10 +680,10 @@ MODULE* PCB_EDIT_FRAME::Create_MuWaveComponent( int shape_type )
case 2: // Arc Stub created by a polygonal approach:
{
EDGE_MODULE* edge = new EDGE_MODULE( Module );
Module->m_Drawings.PushFront( edge );
EDGE_MODULE* edge = new EDGE_MODULE( module );
module->m_Drawings.PushFront( edge );
edge->m_Shape = S_POLYGON;
edge->SetShape( S_POLYGON );
edge->SetLayer( LAYER_N_FRONT );
int numPoints = angle / 50 + 3; // Note: angles are in 0.1 degrees
......@@ -720,10 +719,10 @@ MODULE* PCB_EDIT_FRAME::Create_MuWaveComponent( int shape_type )
break;
}
Module->CalculateBoundingBox();
module->CalculateBoundingBox();
GetBoard()->m_Status_Pcb = 0;
OnModify();
return Module;
return module;
}
......@@ -934,7 +933,7 @@ void WinEDA_SetParamShapeFrame::ReadDataShapeDescr( wxCommandEvent& event )
MODULE* PCB_EDIT_FRAME::Create_MuWavePolygonShape()
{
D_PAD* pad1, * pad2;
MODULE* Module;
MODULE* module;
wxString cmp_name;
int pad_count = 2;
EDGE_MODULE* edge;
......@@ -973,8 +972,8 @@ MODULE* PCB_EDIT_FRAME::Create_MuWavePolygonShape()
cmp_name = wxT( "POLY" );
Module = Create_MuWaveBasicShape( cmp_name, pad_count );
pad1 = Module->m_Pads;
module = Create_MuWaveBasicShape( cmp_name, pad_count );
pad1 = module->m_Pads;
pad1->m_Pos0.x = -ShapeSize.x / 2;
pad1->m_Pos.x += pad1->m_Pos0.x;
......@@ -983,11 +982,11 @@ MODULE* PCB_EDIT_FRAME::Create_MuWavePolygonShape()
pad2->m_Pos0.x = pad1->m_Pos0.x + ShapeSize.x;
pad2->m_Pos.x += pad2->m_Pos0.x;
edge = new EDGE_MODULE( Module );
edge = new EDGE_MODULE( module );
Module->m_Drawings.PushFront( edge );
module->m_Drawings.PushFront( edge );
edge->m_Shape = S_POLYGON;
edge->SetShape( S_POLYGON );
edge->SetLayer( LAYER_N_FRONT );
npoints = PolyEdges.size();
......@@ -1020,8 +1019,8 @@ MODULE* PCB_EDIT_FRAME::Create_MuWavePolygonShape()
pad2->m_Size.x = pad2->m_Size.y = ABS( last_coordinate.y );
pad1->m_Pos0.y = first_coordinate.y / 2;
pad2->m_Pos0.y = last_coordinate.y / 2;
pad1->m_Pos.y = pad1->m_Pos0.y + Module->m_Pos.y;
pad2->m_Pos.y = pad2->m_Pos0.y + Module->m_Pos.y;
pad1->m_Pos.y = pad1->m_Pos0.y + module->m_Pos.y;
pad2->m_Pos.y = pad2->m_Pos0.y + module->m_Pos.y;
break;
case 1: // Symmetric
......@@ -1040,10 +1039,10 @@ MODULE* PCB_EDIT_FRAME::Create_MuWavePolygonShape()
}
PolyEdges.clear();
Module->CalculateBoundingBox();
module->CalculateBoundingBox();
GetBoard()->m_Status_Pcb = 0;
OnModify();
return Module;
return module;
}
......
......@@ -266,114 +266,90 @@ static void PlotTextModule( PLOTTER* plotter, TEXTE_MODULE* pt_texte, GRTraceMod
}
void PlotDimension( PLOTTER* plotter, DIMENSION* Dimension, int aLayerMask,
void PlotDimension( PLOTTER* plotter, DIMENSION* aDim, int aLayerMask,
GRTraceMode trace_mode )
{
DRAWSEGMENT* DrawTmp;
if( (GetLayerMask( Dimension->GetLayer() ) & aLayerMask) == 0 )
if( (GetLayerMask( aDim->GetLayer() ) & aLayerMask) == 0 )
return;
DrawTmp = new DRAWSEGMENT( NULL );
DrawTmp->m_Width = (trace_mode==FILAIRE) ? -1 : Dimension->m_Width;
DrawTmp->SetLayer( Dimension->GetLayer() );
PlotTextePcb( plotter, Dimension->m_Text, aLayerMask, trace_mode );
DrawTmp->m_Start.x = Dimension->m_crossBarOx;
DrawTmp->m_Start.y = Dimension->m_crossBarOy;
DrawTmp->m_End.x = Dimension->m_crossBarFx;
DrawTmp->m_End.y = Dimension->m_crossBarFy;
PlotDrawSegment( plotter, DrawTmp, aLayerMask, trace_mode );
DrawTmp->m_Start.x = Dimension->m_featureLineGOx;
DrawTmp->m_Start.y = Dimension->m_featureLineGOy;
DrawTmp->m_End.x = Dimension->m_featureLineGFx;
DrawTmp->m_End.y = Dimension->m_featureLineGFy;
PlotDrawSegment( plotter, DrawTmp, aLayerMask, trace_mode );
DrawTmp->m_Start.x = Dimension->m_featureLineDOx;
DrawTmp->m_Start.y = Dimension->m_featureLineDOy;
DrawTmp->m_End.x = Dimension->m_featureLineDFx;
DrawTmp->m_End.y = Dimension->m_featureLineDFy;
PlotDrawSegment( plotter, DrawTmp, aLayerMask, trace_mode );
DrawTmp->m_Start.x = Dimension->m_arrowD1Ox;
DrawTmp->m_Start.y = Dimension->m_arrowD1Oy;
DrawTmp->m_End.x = Dimension->m_arrowD1Fx;
DrawTmp->m_End.y = Dimension->m_arrowD1Fy;
PlotDrawSegment( plotter, DrawTmp, aLayerMask, trace_mode );
DrawTmp->m_Start.x = Dimension->m_arrowD2Ox;
DrawTmp->m_Start.y = Dimension->m_arrowD2Oy;
DrawTmp->m_End.x = Dimension->m_arrowD2Fx;
DrawTmp->m_End.y = Dimension->m_arrowD2Fy;
PlotDrawSegment( plotter, DrawTmp, aLayerMask, trace_mode );
DrawTmp->m_Start.x = Dimension->m_arrowG1Ox;
DrawTmp->m_Start.y = Dimension->m_arrowG1Oy;
DrawTmp->m_End.x = Dimension->m_arrowG1Fx;
DrawTmp->m_End.y = Dimension->m_arrowG1Fy;
PlotDrawSegment( plotter, DrawTmp, aLayerMask, trace_mode );
DrawTmp->m_Start.x = Dimension->m_arrowG2Ox;
DrawTmp->m_Start.y = Dimension->m_arrowG2Oy;
DrawTmp->m_End.x = Dimension->m_arrowG2Fx;
DrawTmp->m_End.y = Dimension->m_arrowG2Fy;
PlotDrawSegment( plotter, DrawTmp, aLayerMask, trace_mode );
delete DrawTmp;
DRAWSEGMENT draw;
draw.SetWidth( (trace_mode==FILAIRE) ? -1 : aDim->GetWidth() );
draw.SetLayer( aDim->GetLayer() );
PlotTextePcb( plotter, &aDim->m_Text, aLayerMask, trace_mode );
draw.SetStart( wxPoint( aDim->m_crossBarOx, aDim->m_crossBarOy ));
draw.SetEnd( wxPoint( aDim->m_crossBarFx, aDim->m_crossBarFy ));
PlotDrawSegment( plotter, &draw, aLayerMask, trace_mode );
draw.SetStart( wxPoint( aDim->m_featureLineGOx, aDim->m_featureLineGOy ));
draw.SetEnd( wxPoint( aDim->m_featureLineGFx, aDim->m_featureLineGFy ));
PlotDrawSegment( plotter, &draw, aLayerMask, trace_mode );
draw.SetStart( wxPoint( aDim->m_featureLineDOx, aDim->m_featureLineDOy ));
draw.SetEnd( wxPoint( aDim->m_featureLineDFx, aDim->m_featureLineDFy ));
PlotDrawSegment( plotter, &draw, aLayerMask, trace_mode );
draw.SetStart( wxPoint( aDim->m_arrowD1Ox, aDim->m_arrowD1Oy ));
draw.SetEnd( wxPoint( aDim->m_arrowD1Fx, aDim->m_arrowD1Fy ));
PlotDrawSegment( plotter, &draw, aLayerMask, trace_mode );
draw.SetStart( wxPoint( aDim->m_arrowD2Ox, aDim->m_arrowD2Oy ));
draw.SetEnd( wxPoint( aDim->m_arrowD2Fx, aDim->m_arrowD2Fy ));
PlotDrawSegment( plotter, &draw, aLayerMask, trace_mode );
draw.SetStart( wxPoint( aDim->m_arrowG1Ox, aDim->m_arrowG1Oy ));
draw.SetEnd( wxPoint( aDim->m_arrowG1Fx, aDim->m_arrowG1Fy ));
PlotDrawSegment( plotter, &draw, aLayerMask, trace_mode );
draw.SetStart( wxPoint( aDim->m_arrowG2Ox, aDim->m_arrowG2Oy ));
draw.SetEnd( wxPoint( aDim->m_arrowG2Fx, aDim->m_arrowG2Fy ));
PlotDrawSegment( plotter, &draw, aLayerMask, trace_mode );
}
void PlotPcbTarget( PLOTTER* plotter, PCB_TARGET* Mire, int aLayerMask, GRTraceMode trace_mode )
void PlotPcbTarget( PLOTTER* plotter, PCB_TARGET* aMire, int aLayerMask, GRTraceMode trace_mode )
{
DRAWSEGMENT* DrawTmp;
int dx1, dx2, dy1, dy2, radius;
if( (GetLayerMask( Mire->GetLayer() ) & aLayerMask) == 0 )
if( (GetLayerMask( aMire->GetLayer() ) & aLayerMask) == 0 )
return;
DrawTmp = new DRAWSEGMENT( NULL );
DRAWSEGMENT draw;
DrawTmp->m_Width = ( trace_mode == FILAIRE ) ? -1 : Mire->m_Width;
DrawTmp->SetLayer( Mire->GetLayer() );
draw.SetShape( S_CIRCLE );
draw.SetWidth( ( trace_mode == FILAIRE ) ? -1 : aMire->GetWidth() );
draw.SetLayer( aMire->GetLayer() );
DrawTmp->m_Start.x = Mire->m_Pos.x; DrawTmp->m_Start.y = Mire->m_Pos.y;
DrawTmp->m_End.x = DrawTmp->m_Start.x + ( Mire->m_Size / 4 );
DrawTmp->m_End.y = DrawTmp->m_Start.y;
DrawTmp->m_Shape = S_CIRCLE;
PlotDrawSegment( plotter, DrawTmp, aLayerMask, trace_mode );
draw.SetStart( aMire->GetPosition() );
draw.SetEnd( wxPoint( draw.GetStart().x + ( aMire->GetSize() / 4 ), draw.GetStart().y ));
PlotDrawSegment( plotter, &draw, aLayerMask, trace_mode );
DrawTmp->m_Shape = S_SEGMENT;
draw.SetShape( S_SEGMENT );
radius = Mire->m_Size / 2;
radius = aMire->GetSize() / 2;
dx1 = radius;
dy1 = 0;
dx2 = 0;
dy2 = radius;
if( Mire->m_Shape ) /* Shape X */
if( aMire->GetShape() ) // Shape X
{
dx1 = dy1 = ( radius * 7 ) / 5;
dx2 = dx1;
dy2 = -dy1;
}
DrawTmp->m_Start.x = Mire->m_Pos.x - dx1;
DrawTmp->m_Start.y = Mire->m_Pos.y - dy1;
DrawTmp->m_End.x = Mire->m_Pos.x + dx1;
DrawTmp->m_End.y = Mire->m_Pos.y + dy1;
PlotDrawSegment( plotter, DrawTmp, aLayerMask, trace_mode );
wxPoint mirePos( aMire->GetPosition() );
DrawTmp->m_Start.x = Mire->m_Pos.x - dx2;
DrawTmp->m_Start.y = Mire->m_Pos.y - dy2;
DrawTmp->m_End.x = Mire->m_Pos.x + dx2;
DrawTmp->m_End.y = Mire->m_Pos.y + dy2;
PlotDrawSegment( plotter, DrawTmp, aLayerMask, trace_mode );
draw.SetStart( wxPoint( mirePos.x - dx1, mirePos.y - dy1 ));
draw.SetEnd( wxPoint( mirePos.x + dx1, mirePos.y + dy1 ));
PlotDrawSegment( plotter, &draw, aLayerMask, trace_mode );
delete DrawTmp;
draw.SetStart( wxPoint( mirePos.x - dx2, mirePos.y - dy2 ));
draw.SetEnd( wxPoint( mirePos.x + dx2, mirePos.y + dy2 ));
PlotDrawSegment( plotter, &draw, aLayerMask, trace_mode );
}
......@@ -398,23 +374,21 @@ void Plot_Edges_Modules( PLOTTER* plotter, BOARD* pcb, int aLayerMask, GRTraceMo
}
/* Plot a graphic item (outline) relative to a footprint */
void Plot_1_EdgeModule( PLOTTER* plotter, EDGE_MODULE* PtEdge, GRTraceMode trace_mode )
/** Plot a graphic item (outline) relative to a footprint */
void Plot_1_EdgeModule( PLOTTER* plotter, EDGE_MODULE* aEdge, GRTraceMode trace_mode )
{
int type_trace; /* Type of item to plot. */
int thickness; /* Segment thickness. */
int radius; /* Circle radius. */
int StAngle, EndAngle;
wxPoint pos, end;
int type_trace; // Type of item to plot.
int thickness; // Segment thickness.
int radius; // Circle radius.
if( PtEdge->Type() != PCB_MODULE_EDGE_T )
if( aEdge->Type() != PCB_MODULE_EDGE_T )
return;
type_trace = PtEdge->m_Shape;
thickness = PtEdge->m_Width;
type_trace = aEdge->GetShape();
thickness = aEdge->GetWidth();
pos = PtEdge->m_Start;
end = PtEdge->m_End;
wxPoint pos( aEdge->GetStart() );
wxPoint end( aEdge->GetEnd() );
switch( type_trace )
{
......@@ -429,31 +403,37 @@ void Plot_1_EdgeModule( PLOTTER* plotter, EDGE_MODULE* PtEdge, GRTraceMode trace
break;
case S_ARC:
{
radius = (int) hypot( (double) ( end.x - pos.x ),
(double) ( end.y - pos.y ) );
StAngle = ArcTangente( end.y - pos.y, end.x - pos.x );
EndAngle = StAngle + PtEdge->m_Angle;
double startAngle = ArcTangente( end.y - pos.y, end.x - pos.x );
double endAngle = startAngle + aEdge->GetAngle();
plotter->thick_arc( pos,
-EndAngle,
-StAngle,
-endAngle,
-startAngle,
radius,
thickness,
trace_mode );
}
break;
case S_POLYGON:
{
std::vector<wxPoint> polyPoints = PtEdge->GetPolyPoints();
const std::vector<wxPoint>& polyPoints = aEdge->GetPolyPoints();
if( polyPoints.size() <= 1 ) // Malformed polygon
break;
// We must compute true coordinates from m_PolyList
// which are relative to module position, orientation 0
MODULE* module = PtEdge->GetParentModule();
MODULE* module = aEdge->GetParentModule();
static std::vector< wxPoint > cornerList;
cornerList.clear();
std::vector< wxPoint > cornerList;
cornerList.reserve( polyPoints.size() );
for( unsigned ii = 0; ii < polyPoints.size(); ii++ )
{
......@@ -461,8 +441,8 @@ void Plot_1_EdgeModule( PLOTTER* plotter, EDGE_MODULE* PtEdge, GRTraceMode trace
if( module )
{
RotatePoint( &corner, module->m_Orient );
corner += module->m_Pos;
RotatePoint( &corner, module->GetOrientation() );
corner += module->GetPosition();
}
cornerList.push_back( corner );
......@@ -613,27 +593,26 @@ void PlotFilledAreas( PLOTTER* plotter, ZONE_CONTAINER* aZone, GRTraceMode trace
/* Plot items type DRAWSEGMENT on layers allowed by aLayerMask
*/
void PlotDrawSegment( PLOTTER* plotter, DRAWSEGMENT* pt_segm, int aLayerMask,
void PlotDrawSegment( PLOTTER* plotter, DRAWSEGMENT* aSeg, int aLayerMask,
GRTraceMode trace_mode )
{
wxPoint start, end;
int thickness;
int radius = 0, StAngle = 0, EndAngle = 0;
if( (GetLayerMask( pt_segm->GetLayer() ) & aLayerMask) == 0 )
if( (GetLayerMask( aSeg->GetLayer() ) & aLayerMask) == 0 )
return;
if( trace_mode == FILAIRE )
thickness = g_PcbPlotOptions.m_PlotLineWidth;
else
thickness = pt_segm->m_Width;
thickness = aSeg->GetWidth();
start = pt_segm->m_Start;
end = pt_segm->m_End;
wxPoint start( aSeg->GetStart() );
wxPoint end( aSeg->GetEnd() );
plotter->set_current_line_width( thickness );
switch( pt_segm->m_Shape )
switch( aSeg->GetShape() )
{
case S_CIRCLE:
radius = (int) hypot( (double) ( end.x - start.x ),
......@@ -645,20 +624,21 @@ void PlotDrawSegment( PLOTTER* plotter, DRAWSEGMENT* pt_segm, int aLayerMask,
radius = (int) hypot( (double) ( end.x - start.x ),
(double) ( end.y - start.y ) );
StAngle = ArcTangente( end.y - start.y, end.x - start.x );
EndAngle = StAngle + pt_segm->m_Angle;
EndAngle = StAngle + aSeg->GetAngle();
plotter->thick_arc( start, -EndAngle, -StAngle, radius, thickness, trace_mode );
break;
case S_CURVE:
{
std::vector<wxPoint> bezierPoints = pt_segm->GetBezierPoints();
const std::vector<wxPoint>& bezierPoints = aSeg->GetBezierPoints();
for( unsigned i = 1; i < bezierPoints.size(); i++ )
plotter->thick_segment( bezierPoints[i - 1],
bezierPoints[i],
thickness,
trace_mode );
break;
}
break;
default:
plotter->thick_segment( start, end, thickness, trace_mode );
......
......@@ -69,7 +69,8 @@ TRACK* LocateIntrusion( TRACK* listStart, TRACK* aTrack, int aLayer, const wxPoi
void ShowNewTrackWhenMovingCursor( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint& aPosition,
bool aErase );
/* Determine coordinate for a segment direction of 0, 90 or 45 degrees,
/**
* Determine coordinate for a segment direction of 0, 90 or 45 degrees,
* depending on it's position from the origin (ox, oy) and \a aPosiition..
*/
void CalculateSegmentEndPoint( const wxPoint& aPosition, int ox, int oy, int* fx, int* fy );
......
......@@ -212,13 +212,24 @@ static DRAWSEGMENT* findPoint( const wxPoint& aPoint, TYPE_COLLECTOR* items )
wxASSERT( graphic->Type() == PCB_LINE_T );
switch( graphic->GetShape() )
{
case S_ARC:
if( aPoint == graphic->GetArcStart() || aPoint == graphic->GetArcEnd() )
{
items->Remove(i);
return graphic;
}
break;
default:
if( aPoint == graphic->GetStart() || aPoint == graphic->GetEnd() )
{
items->Remove(i);
return graphic;
}
}
}
#if defined(DEBUG)
printf("Unable to find segment matching point (%d,%d)\n",
......@@ -229,7 +240,7 @@ static DRAWSEGMENT* findPoint( const wxPoint& aPoint, TYPE_COLLECTOR* items )
DRAWSEGMENT* graphic = (DRAWSEGMENT*) (*items)[i];
printf( "type=%s, GetStart()=%d,%d GetEnd()=%d,%d\n",
TO_UTF8( BOARD_ITEM::ShowShape( (STROKE_T) graphic->m_Shape ) ),
TO_UTF8( BOARD_ITEM::ShowShape( (STROKE_T) graphic->GetShape() ) ),
graphic->GetStart().x,
graphic->GetStart().y,
graphic->GetEnd().x,
......@@ -614,17 +625,17 @@ IMAGE* SPECCTRA_DB::makeIMAGE( BOARD* aBoard, MODULE* aModule )
SHAPE* outline;
PATH* path;
switch( graphic->m_Shape )
switch( graphic->GetShape() )
{
case S_SEGMENT:
outline = new SHAPE( image, T_outline );
image->Append( outline );
path = new PATH( outline );
outline->SetShape( path );
path->SetAperture( scale( graphic->m_Width ) );
path->SetAperture( scale( graphic->GetWidth() ) );
path->SetLayerId( "signal" );
path->AppendPoint( mapPt( graphic->m_Start0 ) );
path->AppendPoint( mapPt( graphic->m_End0 ) );
path->AppendPoint( mapPt( graphic->GetStart0() ) );
path->AppendPoint( mapPt( graphic->GetEnd0() ) );
break;
case S_CIRCLE:
......@@ -636,7 +647,7 @@ IMAGE* SPECCTRA_DB::makeIMAGE( BOARD* aBoard, MODULE* aModule )
image->Append( outline );
path = new PATH( outline );
outline->SetShape( path );
path->SetAperture( scale( graphic->m_Width ) );
path->SetAperture( scale( graphic->GetWidth() ) );
path->SetLayerId( "signal" );
// Do the math using KiCad units, that way we stay out of the
......@@ -645,8 +656,8 @@ IMAGE* SPECCTRA_DB::makeIMAGE( BOARD* aBoard, MODULE* aModule )
// lexer/beautifier, and the spec is not clear that this is
// required. Fixed point floats are all that should be needed.
double radius = hypot( double( graphic->m_Start.x - graphic->m_End.x ),
double( graphic->m_Start.y - graphic->m_End.y ) );
double radius = hypot( double( graphic->GetStart().x - graphic->GetEnd().x ),
double( graphic->GetStart().y - graphic->GetEnd().y ) );
// better if evenly divisible into 360
const int DEGREE_INTERVAL = 18; // 18 means 20 line segments
......@@ -667,7 +678,7 @@ IMAGE* SPECCTRA_DB::makeIMAGE( BOARD* aBoard, MODULE* aModule )
case S_ARC:
default:
D( printf("makeIMAGE(): unsupported shape %s\n",
TO_UTF8( BOARD_ITEM::ShowShape( (STROKE_T) graphic->m_Shape)) );)
TO_UTF8( BOARD_ITEM::ShowShape( (STROKE_T) graphic->GetShape() )) );)
continue;
}
}
......@@ -778,7 +789,7 @@ void SPECCTRA_DB::fillBOUNDARY( BOARD* aBoard, BOUNDARY* boundary ) throw( IO_ER
for(;;)
{
switch( graphic->m_Shape )
switch( graphic->GetShape() )
{
case S_SEGMENT:
{
......@@ -807,14 +818,14 @@ void SPECCTRA_DB::fillBOUNDARY( BOARD* aBoard, BOUNDARY* boundary ) throw( IO_ER
{
const int STEPS = 9; // in an arc of 90 degrees
wxPoint start = graphic->GetStart();
wxPoint end = graphic->GetEnd();
wxPoint center = graphic->m_Start;
int angle = -graphic->m_Angle;
wxPoint start = graphic->GetArcStart();
wxPoint end = graphic->GetArcEnd();
wxPoint center = graphic->GetCenter();
double angle = -graphic->GetAngle();
if( prevPt != start )
{
wxASSERT( prevPt == graphic->GetEnd() );
wxASSERT( prevPt == graphic->GetArcEnd() );
angle = -angle;
EXCHG( start, end );
......@@ -824,7 +835,7 @@ void SPECCTRA_DB::fillBOUNDARY( BOARD* aBoard, BOUNDARY* boundary ) throw( IO_ER
for( int step=1; step<=STEPS; ++step )
{
int rotation = ( angle * step )/STEPS;
double rotation = ( angle * step )/STEPS;
nextPt = start;
......@@ -858,7 +869,7 @@ void SPECCTRA_DB::fillBOUNDARY( BOARD* aBoard, BOUNDARY* boundary ) throw( IO_ER
wxString error;
error.Printf( _("Unsupported DRAWSEGMENT type %s"),
GetChars( BOARD_ITEM::ShowShape( (STROKE_T) graphic->m_Shape ) ) );
GetChars( BOARD_ITEM::ShowShape( (STROKE_T) graphic->GetShape() ) ) );
ThrowIOError( error );
}
......
......@@ -270,7 +270,7 @@ SEGVIA* SPECCTRA_DB::makeVIA( PADSTACK* aPadstack, const POINT& aPoint, int aNet
via = new SEGVIA( sessionBoard );
via->SetPosition( mapPt( aPoint, routeResolution ) );
via->SetDrillValue( drillDiam );
via->SetDrill( drillDiam );
via->m_Shape = VIA_THROUGH;
via->m_Width = viaDiam;
via->SetLayerPair( LAYER_N_FRONT, LAYER_N_BACK );
......@@ -288,7 +288,7 @@ SEGVIA* SPECCTRA_DB::makeVIA( PADSTACK* aPadstack, const POINT& aPoint, int aNet
via = new SEGVIA( sessionBoard );
via->SetPosition( mapPt( aPoint, routeResolution ) );
via->SetDrillValue( drillDiam );
via->SetDrill( drillDiam );
via->m_Shape = VIA_THROUGH;
via->m_Width = viaDiam;
via->SetLayerPair( LAYER_N_FRONT, LAYER_N_BACK );
......@@ -329,7 +329,7 @@ SEGVIA* SPECCTRA_DB::makeVIA( PADSTACK* aPadstack, const POINT& aPoint, int aNet
via = new SEGVIA( sessionBoard );
via->SetPosition( mapPt( aPoint, routeResolution ) );
via->SetDrillValue( drillDiam );
via->SetDrill( drillDiam );
if( (topLayerNdx==0 && botLayerNdx==1)
|| (topLayerNdx==copperLayerCount-2 && botLayerNdx==copperLayerCount-1))
......
......@@ -371,7 +371,7 @@ void PCB_EDIT_FRAME::Swap_Layers( wxCommandEvent& event )
{
SEGVIA* Via = (SEGVIA*) pt_segm;
if( Via->Shape() == VIA_THROUGH )
if( Via->GetShape() == VIA_THROUGH )
continue;
int top_layer, bottom_layer;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment