Commit 74ccc4b5 authored by Dick Hollenbeck's avatar Dick Hollenbeck

++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.
  * EDA_TEXT::m_Orient is now double, still in tenths of degrees (for a short while),
    but the double means parsing files and saving them use a different format string.
++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.
parents bced8c97 96bb90de
......@@ -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,22 @@ 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.
* EDA_TEXT::m_Orient is now double, still in tenths of degrees (for a short while),
but the double means parsing files and saving them use a different format string.
++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 @@ bool LIB_TEXT::Save( OUTPUTFORMATTER& aFormatter )
text.Replace( wxT( " " ), wxT( "~" ) );
}
aFormatter.Print( 0, "T %d %d %d %d %d %d %d %s ", m_Orient, m_Pos.x, m_Pos.y,
aFormatter.Print( 0, "T %g %d %d %d %d %d %d %s ", GetOrientation(), m_Pos.x, m_Pos.y,
m_Size.x, m_Attributs, m_Unit, m_Convert, TO_UTF8( text ) );
aFormatter.Print( 0, " %s %d", m_Italic ? "Italic" : "Normal", ( m_Bold > 0 ) ? 1 : 0 );
......@@ -104,12 +104,13 @@ bool LIB_TEXT::Load( LINE_READER& aLineReader, wxString& errorMsg )
char buf[256];
char tmp[256];
char* line = (char*) aLineReader;
double angle;
buf[0] = 0;
tmp[0] = 0; // For italic option, Not in old versions
cnt = sscanf( line + 2, "%d %d %d %d %d %d %d \"%[^\"]\" %s %d %c %c",
&m_Orient, &m_Pos.x, &m_Pos.y, &m_Size.x, &m_Attributs,
cnt = sscanf( line + 2, "%lf %d %d %d %d %d %d \"%[^\"]\" %s %d %c %c",
&angle, &m_Pos.x, &m_Pos.y, &m_Size.x, &m_Attributs,
&m_Unit, &m_Convert, buf, tmp, &thickness, &hjustify,
&vjustify );
......@@ -123,7 +124,7 @@ bool LIB_TEXT::Load( LINE_READER& aLineReader, wxString& errorMsg )
else
{
cnt = sscanf( line + 2, "%d %d %d %d %d %d %d %s %s %d %c %c",
&m_Orient, &m_Pos.x, &m_Pos.y, &m_Size.x, &m_Attributs,
&angle, &m_Pos.x, &m_Pos.y, &m_Size.x, &m_Attributs,
&m_Unit, &m_Convert, buf, tmp, &thickness, &hjustify,
&vjustify );
......@@ -138,6 +139,8 @@ bool LIB_TEXT::Load( LINE_READER& aLineReader, wxString& errorMsg )
m_Text.Replace( wxT( "~" ), wxT( " " ) );
}
SetOrientation( angle );
m_Size.y = m_Size.x;
if( strnicmp( tmp, "Italic", 6 ) == 0 )
......
......@@ -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 );
}
......
......@@ -447,7 +447,6 @@ public:
return m_Status & type;
}
void SetState( int type, int state )
{
if( state )
......@@ -456,13 +455,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; }
......@@ -798,7 +792,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
......@@ -832,8 +826,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
......
......@@ -519,10 +519,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
}
......@@ -148,7 +153,7 @@ NETCLASS* BOARD_CONNECTED_ITEM::GetNetClass() const
* Function GetNetClassName
* @return the Net Class name of this item
*/
wxString BOARD_CONNECTED_ITEM::GetNetClassName( ) const
wxString BOARD_CONNECTED_ITEM::GetNetClassName() const
{
wxString name;
NETCLASS* myclass = GetNetClass();
......
......@@ -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
......@@ -89,9 +89,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
{
......@@ -204,4 +204,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";
......
......@@ -65,7 +65,7 @@ public:
BOARD_CONNECTED_ITEM* start; // pointers to a connected item (pad or track)
BOARD_CONNECTED_ITEM* end;
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.
......@@ -108,7 +108,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
......@@ -117,17 +117,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;
......@@ -166,8 +166,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 );
}
......@@ -177,7 +177,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; }
/**
......@@ -201,26 +201,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_
......@@ -147,7 +147,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;
......
This diff is collapsed.
......@@ -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 ) );
}
......
This diff is collapsed.
This diff is collapsed.
......@@ -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