This patch restores some of the goodness in Vladimir's rev 3239, and in particular

the GetPosition() and SetPosition() changes.  It also starts towards making m_Orientation
and m_Thickness fields private with accessors, but does not complete this latter goal.
This commit is contained in:
Dick Hollenbeck 2011-11-29 11:25:30 -06:00
parent 701fa6b0a3
commit 8f79b14680
23 changed files with 157 additions and 145 deletions

View File

@ -643,7 +643,7 @@ void EDA_3D_CANVAS::Draw3D_DrawText( TEXTE_PCB* text )
SetGLColor( color );
s_Text3DZPos = g_Parm_3D_Visu.m_LayerZcoord[layer];
s_Text3DWidth = text->m_Thickness * g_Parm_3D_Visu.m_BoardScale;
s_Text3DWidth = text->GetThickness() * g_Parm_3D_Visu.m_BoardScale;
glNormal3f( 0.0, 0.0, Get3DLayerSide( layer ) );
wxSize size = text->m_Size;
@ -658,27 +658,27 @@ void EDA_3D_CANVAS::Draw3D_DrawText( TEXTE_PCB* text )
offset.y = text->GetInterline();
RotatePoint( &offset, text->m_Orient );
RotatePoint( &offset, text->GetOrientation() );
for( unsigned i = 0; i<list->Count(); i++ )
{
wxString txt = list->Item( i );
DrawGraphicText( NULL, NULL, pos, (EDA_Colors) color,
txt, text->m_Orient, size,
txt, text->GetOrientation(), size,
text->m_HJustify, text->m_VJustify,
text->m_Thickness, text->m_Italic,
text->GetThickness(), text->m_Italic,
true, Draw3dTextSegm );
pos += offset;
}
delete (list);
delete list;
}
else
{
DrawGraphicText( NULL, NULL, text->m_Pos, (EDA_Colors) color,
text->m_Text, text->m_Orient, size,
text->m_Text, text->GetOrientation(), size,
text->m_HJustify, text->m_VJustify,
text->m_Thickness, text->m_Italic,
text->GetThickness(), text->m_Italic,
true,
Draw3dTextSegm );
}
@ -820,7 +820,7 @@ void EDGE_MODULE::Draw3D( EDA_3D_CANVAS* glcanvas )
{
wxPoint& pt = points[ii];
RotatePoint( &pt.x, &pt.y, module->m_Orient );
RotatePoint( &pt.x, &pt.y, module->GetOrientation() );
pt += module->m_Pos;
}
@ -868,7 +868,7 @@ void EDGE_MODULE::Draw3D( EDA_3D_CANVAS* glcanvas )
{
wxPoint& pt = points[ii];
RotatePoint( &pt.x, &pt.y, module->m_Orient );
RotatePoint( &pt.x, &pt.y, module->GetOrientation() );
pt += module->m_Pos;
}

View File

@ -167,11 +167,16 @@ public:
* @return const wxPoint& - The position of this object.
* This function exists mainly to satisfy the virtual GetPosition() in parent class
*/
wxPoint& GetPosition()
const wxPoint GetPosition() const
{
return m_Start; // it had to be start or end.
}
void SetPosition( const wxPoint& aPos )
{
m_Start = aPos;
}
/**
* Function GetABPosition
* returns the image position of aPosition for this object.

View File

@ -239,7 +239,6 @@ public:
m_Size.x = pos.x - m_Pos.x; m_Size.y = pos.y - m_Pos.y;
}
/**
* Function Intersects
* @return bool - true if the argument rectangle intersects this rectangle.
@ -729,12 +728,14 @@ enum FILL_T {
*/
class EDA_TEXT
{
public:
int m_Thickness; /* pen size used to draw this text */
int m_Orient; /* Orient in 0.1 degrees */
wxString m_Text; /* text! */
wxPoint m_Pos; /* XY position of anchor text. */
wxSize m_Size; /* XY size of text */
int m_Thickness; /* pen size used to draw this text */
int m_Orient; /* Orient in 0.1 degrees */
bool m_Mirror; /* Display Normal / mirror */
int m_Attributs; /* flags (visible...) */
bool m_Italic; /* true to simulate (or use if exists)
@ -766,6 +767,9 @@ public:
*/
int GetThickness() const { return m_Thickness; };
void SetOrientation( int aOrientation ) { m_Orient = aOrientation; }
int GetOrientation() const { return m_Orient; }
/**
* Function SetSize
* sets text size.
@ -780,6 +784,9 @@ public:
*/
wxSize GetSize() const { return m_Size; };
//void SetPosition( const wxPoint& aPoint ) { m_Pos = aPoint; }
//wxPoint GetPosition() const { return m_Pos; }
int GetLength() const { return m_Text.Length(); };
/**

View File

@ -76,9 +76,16 @@ public:
/**
* Function GetPosition
* returns the position of this object.
* @return wxPoint& - The position of this object, non-const so it can be changed
* @return const wxPoint - The position of this object
*/
virtual wxPoint& GetPosition() = 0;
virtual const wxPoint GetPosition() const = 0;
/**
* Function SetPosition
* sets the position of this object.
* @param aPos is the new position of this object
*/
virtual void SetPosition( const wxPoint& aPos ) = 0;
/**
* Function GetLayer
@ -313,10 +320,9 @@ public:
{}
//-----< satisfy some virtual functions >------------------------------
wxPoint& GetPosition()
const wxPoint GetPosition()
{
static wxPoint dummy;
return dummy;
return wxPoint(0, 0); // dummy
}
void Draw( EDA_DRAW_PANEL* DrawPanel, wxDC* DC,

View File

@ -538,6 +538,7 @@ 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;
@ -549,7 +550,10 @@ void MirrorMarkedItems( MODULE* module, wxPoint offset )
if( pad->m_Selected == 0 )
continue;
SETMIRROR( pad->GetPosition().x );
tmp = pad->GetPosition();
SETMIRROR( tmp.x );
pad->SetPosition( tmp );
pad->m_Pos0.x = pad->GetPosition().x;
NEGATE( pad->m_Offset.x );
NEGATE( pad->m_DeltaSize.x );
@ -567,18 +571,19 @@ void MirrorMarkedItems( MODULE* module, wxPoint offset )
switch( item->Type() )
{
case PCB_MODULE_EDGE_T:
{
EDGE_MODULE * edge = (EDGE_MODULE*) item;
EDGE_MODULE * edge;
edge = (EDGE_MODULE*) item;
SETMIRROR( edge->m_Start.x );
edge->m_Start0.x = edge->m_Start.x;
SETMIRROR( edge->m_End.x );
edge->m_End0.x = edge->m_End.x;
NEGATE( edge->m_Angle );
}
break;
case PCB_MODULE_TEXT_T:
SETMIRROR( ( (TEXTE_MODULE*) item )->GetPosition().x );
tmp = ( (TEXTE_MODULE*) item )->GetPosition();
SETMIRROR( tmp.x );
( (TEXTE_MODULE*) item )->SetPosition( tmp );
( (TEXTE_MODULE*) item )->m_Pos0.x = ( (TEXTE_MODULE*) item )->GetPosition().x;
break;
@ -609,7 +614,10 @@ void RotateMarkedItems( MODULE* module, wxPoint offset )
if( pad->m_Selected == 0 )
continue;
ROTATE( pad->GetPosition() );
wxPoint pos = pad->GetPosition();
ROTATE( pos );
pad->SetPosition( pos );
pad->m_Pos0 = pad->GetPosition();
pad->m_Orient += 900;
NORMALIZE_ANGLE_POS( pad->m_Orient );
@ -632,7 +640,11 @@ void RotateMarkedItems( MODULE* module, wxPoint offset )
break;
case PCB_MODULE_TEXT_T:
ROTATE( ( (TEXTE_MODULE*) item )->GetPosition() );
{
wxPoint pos = ( (TEXTE_MODULE*) item )->GetPosition();
ROTATE( pos );
( (TEXTE_MODULE*) item )->SetPosition( pos );
}
( (TEXTE_MODULE*) item )->m_Pos0 = ( (TEXTE_MODULE*) item )->GetPosition();
( (TEXTE_MODULE*) item )->m_Orient += 900;
break;

View File

@ -643,15 +643,6 @@ bool BOARD::IsModuleLayerVisible( int layer )
}
wxPoint& BOARD::GetPosition()
{
static wxPoint dummy( 0, 0 );
return dummy; // a reference
}
void BOARD::Add( BOARD_ITEM* aBoardItem, int aControl )
{
if( aBoardItem == NULL )

View File

@ -259,13 +259,11 @@ public:
*/
static wxString GetDefaultLayerName( int aLayerNumber );
/**
* Function GetPosition
* is here to satisfy BOARD_ITEM's requirements, but this implementation
* is a dummy.
* @return const wxPoint& of (0,0)
*/
wxPoint& GetPosition();
const wxPoint GetPosition() const // overload
{
return wxPoint( 0, 0 ); // dummy for pure virtual
}
void SetPosition( const wxPoint& aPos ) {} // overload
/**
* Function Add

View File

@ -143,14 +143,18 @@ bool DIMENSION::ReadDimensionDescr( LINE_READER* aReader )
if( Line[0] == 'P' )
{
int normal_display = 1;
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_Thickness, &m_Text->m_Orient,
&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 );
continue;
}
@ -265,13 +269,16 @@ void DIMENSION::Rotate(const wxPoint& aRotCentre, int aAngle)
RotatePoint( &m_Pos, aRotCentre, aAngle );
RotatePoint( &m_Text->m_Pos, aRotCentre, aAngle );
m_Text->m_Orient += aAngle;
if( m_Text->m_Orient >= 3600 )
m_Text->m_Orient -= 3600;
int newAngle = m_Text->GetOrientation() + aAngle;
if( ( m_Text->m_Orient > 900 ) && ( m_Text->m_Orient <2700 ) )
m_Text->m_Orient -= 1800;
if( newAngle >= 3600 )
newAngle -= 3600;
if( newAngle > 900 && newAngle < 2700 )
newAngle -= 1800;
m_Text->SetOrientation( newAngle );
RotatePoint( &m_crossBarOx, &m_crossBarOy, aRotCentre.x, aRotCentre.y, aAngle );
RotatePoint( &m_crossBarFx, &m_crossBarFy, aRotCentre.x, aRotCentre.y, aAngle );
@ -300,16 +307,18 @@ void DIMENSION::Flip(const wxPoint& aCentre )
void DIMENSION::Mirror(const wxPoint& axis_pos)
{
#define INVERT( pos ) (pos) = axis_pos.y - ( (pos) - axis_pos.y )
#define INVERT_ANGLE( phi ) (phi) = -(phi)
INVERT( m_Pos.y );
INVERT( m_Text->m_Pos.y );
INVERT_ANGLE( m_Text->m_Orient );
if( m_Text->m_Orient >= 3600 )
m_Text->m_Orient -= 3600;
// invert angle
int newAngle = m_Text->GetOrientation();
if( newAngle >= 3600 )
newAngle -= 3600;
if( ( m_Text->m_Orient > 900 ) && ( m_Text->m_Orient < 2700 ) )
m_Text->m_Orient -= 1800;
if( newAngle > 900 && newAngle < 2700 )
newAngle -= 1800;
m_Text->SetOrientation( newAngle );
INVERT( m_crossBarOy );
INVERT( m_crossBarFy );
@ -352,7 +361,7 @@ bool DIMENSION::Save( FILE* aFile ) const
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->m_Thickness, m_Text->m_Orient,
m_Text->GetThickness(), m_Text->GetOrientation(),
m_Text->m_Mirror ? 0 : 1 );
fprintf( aFile, "Sb %d %d %d %d %d %d\n", S_SEGMENT,
@ -410,12 +419,12 @@ void DIMENSION::AdjustDimensionDetails( bool aDoNotChangeText )
/* calculate the size of the dimension (text + line above the text) */
ii = m_Text->m_Size.y +
m_Text->m_Thickness + (m_Width * 3);
m_Text->GetThickness() + (m_Width * 3);
deltax = m_featureLineDOx - m_featureLineGOx;
deltay = m_featureLineDOy - m_featureLineGOy;
/* Calculate dimension value */
// Calculate dimension value
mesure = wxRound(hypot( (double) deltax, (double) deltay ) );
if( deltax || deltay )
@ -423,10 +432,10 @@ void DIMENSION::AdjustDimensionDetails( bool aDoNotChangeText )
else
angle = 0.0;
/* Calculation of parameters X and Y dimensions of the arrows and lines. */
// Calculation of parameters X and Y dimensions of the arrows and lines.
hx = hy = ii;
/* Taking into account the slope of the side lines. */
// Taking into account the slope of the side lines.
if( mesure )
{
hx = (abs) ( (int) ( ( (double) deltay * hx ) / mesure ) );
@ -487,16 +496,17 @@ void DIMENSION::AdjustDimensionDetails( bool aDoNotChangeText )
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;
m_Text->m_Orient = -(int) (angle * 1800 / M_PI);
int newAngle = -(int) (angle * 1800 / M_PI);
if( newAngle < 0 )
newAngle += 3600;
if( m_Text->m_Orient < 0 )
m_Text->m_Orient += 3600;
if( newAngle >= 3600 )
newAngle -= 3600;
if( m_Text->m_Orient >= 3600 )
m_Text->m_Orient -= 3600;
if( newAngle > 900 && newAngle < 2700 )
newAngle -= 1800;
if( (m_Text->m_Orient > 900) && (m_Text->m_Orient <2700) )
m_Text->m_Orient -= 1800;
m_Text->SetOrientation( newAngle );
if( !aDoNotChangeText )
{

View File

@ -37,11 +37,13 @@ public:
DIMENSION( BOARD_ITEM* aParent );
~DIMENSION();
wxPoint& GetPosition()
const wxPoint GetPosition() const
{
return m_Pos;
}
void SetPosition( const wxPoint& aPos ) { m_Pos = aPos; }
/**
* Function SetLayer
* sets the layer this item is on.

View File

@ -453,7 +453,7 @@ EDA_RECT DRAWSEGMENT::GetBoundingBox() const
if( module ) // Transform, if we belong to a module
{
RotatePoint( &pt, module->m_Orient );
RotatePoint( &pt, module->GetOrientation() );
pt += module->m_Pos;
}

View File

@ -59,13 +59,15 @@ public:
* Function GetPosition
* returns the position of this object.
* Required by pure virtual BOARD_ITEM::GetPosition()
* @return const wxPoint& - The position of this object.
* @return const wxPoint - The position of this object.
*/
wxPoint& GetPosition()
const wxPoint GetPosition() const
{
return m_Start;
}
void SetPosition( const wxPoint& aPos ) { m_Start = aPos; }
/**
* Function GetStart
* returns the starting point of the graphic

View File

@ -60,17 +60,18 @@ void EDGE_MODULE::Copy( EDGE_MODULE* source )
void EDGE_MODULE::SetDrawCoord()
{
MODULE* Module = (MODULE*) m_Parent;
MODULE* module = (MODULE*) m_Parent;
m_Start = m_Start0;
m_End = m_End0;
if( Module )
if( module )
{
RotatePoint( &m_Start.x, &m_Start.y, Module->m_Orient );
RotatePoint( &m_End.x, &m_End.y, Module->m_Orient );
m_Start += Module->m_Pos;
m_End += Module->m_Pos;
RotatePoint( &m_Start.x, &m_Start.y, module->GetOrientation() );
RotatePoint( &m_End.x, &m_End.y, module->GetOrientation() );
m_Start += module->m_Pos;
m_End += module->m_Pos;
}
}
@ -196,7 +197,7 @@ void EDGE_MODULE::Draw( EDA_DRAW_PANEL* panel, wxDC* DC, int draw_mode, const wx
{
wxPoint& pt = points[ii];
RotatePoint( &pt.x, &pt.y, module->m_Orient );
RotatePoint( &pt.x, &pt.y, module->GetOrientation() );
pt += module->m_Pos - offset;
}

View File

@ -77,15 +77,12 @@ public:
DrawMarker( aPanel, aDC, aDrawMode, aOffset );
}
/**
* Function GetPosition
* returns the position of this MARKER_PCB.
*/
wxPoint& GetPosition()
const wxPoint GetPosition() const
{
return (wxPoint&) m_Pos;
return m_Pos;
}
void SetPosition( const wxPoint& aPos ) { m_Pos = aPos; }
/**
* Function HitTest

View File

@ -30,11 +30,12 @@ public:
PCB_TARGET* Next() const { return (PCB_TARGET*) Pnext; }
PCB_TARGET* Back() const { return (PCB_TARGET*) Pnext; }
wxPoint& GetPosition()
const wxPoint GetPosition() const
{
return m_Pos;
}
void SetPosition( const wxPoint& aPos ) { m_Pos = aPos; }
/**
* Function Move

View File

@ -41,7 +41,9 @@ enum Mod_Attribut /* Attributes used for modules */
class MODULE : public BOARD_ITEM
{
public:
int 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) */
@ -57,7 +59,6 @@ public:
* reannotation of the schematic */
int m_Attributs; /* Flag bits ( see Mod_Attribut ) */
int m_Orient; /* orientation in 0.1 degrees */
int flag; /* Use to trace ratsnest and auto routing. */
int m_ModuleStatus; /* For autoplace: flags (LOCKED, AUTOPLACED) */
EDA_RECT m_BoundaryBox; // Bounding box : coordinates on board, real orientation.
@ -100,7 +101,6 @@ public:
void Copy( MODULE* Module ); // Copy structure
/*
* Function Add
* adds the given item to this MODULE and takes ownership of its memory.
@ -131,22 +131,17 @@ public:
*/
EDA_RECT GetBoundingBox() const;
/**
* Function GetPosition
* returns the position of this object.
* Required by pure virtual BOARD_ITEM::GetPosition()
* @return const wxPoint& - The position of this object.
*/
wxPoint& GetPosition()
const wxPoint GetPosition() const // overload
{
return m_Pos;
}
// Moves
void SetPosition( const wxPoint& newpos );
void SetPosition( const wxPoint& aPos ); // overload
void SetOrientation( int newangle );
int GetOrientation() const { return m_Orient; }
/**
* Function Move
* move this object.

View File

@ -765,7 +765,7 @@ void D_PAD::DisplayInfo( EDA_DRAW_FRAME* frame )
frame->AppendMsgPanel( _( "Drill X / Y" ), Line, RED );
}
int module_orient = module ? module->m_Orient : 0;
int module_orient = module ? module->GetOrientation() : 0;
if( module_orient )
Line.Printf( wxT( "%3.1f(+%3.1f)" ),

View File

@ -168,21 +168,12 @@ public:
*/
int GetShape() const { return m_PadShape & 0xFF; }
/**
* Function GetPosition
* returns the position of this object.
* @return const wxPoint& - The position of this object.
*/
wxPoint& GetPosition()
const wxPoint GetPosition() const // overload
{
return m_Pos;
}
void SetPosition( const wxPoint& aPos )
{
m_Pos = aPos;
}
void SetPosition( const wxPoint& aPos ) { m_Pos = aPos; } // overload
/**
* Function TransformShapeWithClearanceToPolygon

View File

@ -21,16 +21,16 @@ public:
TEXTE_PCB( TEXTE_PCB* textepcb );
~TEXTE_PCB();
/**
* Function GetPosition
* returns the position of this object.
* @return wxPoint& - The position of this object, non-const so it can be changed
*/
wxPoint& GetPosition()
const wxPoint GetPosition() const // is an overload
{
return m_Pos; // within EDA_TEXT
}
void SetPosition( const wxPoint& aPos ) // is an overload
{
m_Pos = aPos; // within EDA_TEXT
}
/**
* Function Move
* move this object.

View File

@ -45,17 +45,15 @@ public:
TEXTE_MODULE* Back() const { return (TEXTE_MODULE*) Pback; }
/**
* Function GetPosition
* returns the position of this object.
* Required by pure virtual BOARD_ITEM::GetPosition()
* @return const wxPoint& - The position of this object.
*/
wxPoint& GetPosition()
const wxPoint GetPosition() const // overload a base
{
return m_Pos;
return m_Pos; // from EDA_TEXT
}
void SetPosition( const wxPoint& aPos ) // overload a base
{
m_Pos = aPos; // in EDA_TEXT
}
void Copy( TEXTE_MODULE* source ); // copy structure

View File

@ -127,6 +127,13 @@ public:
return m_Start; // it had to be start or end.
}
const wxPoint GetPosition() const // overload
{
return m_Start; // it had to be start or end.
}
void SetPosition( const wxPoint& aPos ) { m_Start = aPos; } // overload
EDA_RECT GetBoundingBox() const;
/**
@ -465,18 +472,12 @@ public:
*/
void ReturnLayerPair( int* top_layer, int* bottom_layer ) const;
/**
* Function GetPosition
* returns the position of this object.
* @return const wxPoint& - The position of this object.
*/
wxPoint& GetPosition()
const wxPoint GetPosition() const // overload
{
return m_Start;
}
void SetPosition( const wxPoint& aPoint ) { m_Start = aPoint; m_End = aPoint; }
void SetPosition( const wxPoint& aPoint ) { m_Start = aPoint; m_End = aPoint; } // overload
/**
* Function GetClass

View File

@ -84,19 +84,13 @@ bool ZONE_CONTAINER::UnFill()
}
wxPoint& ZONE_CONTAINER::GetPosition()
const wxPoint ZONE_CONTAINER::GetPosition() const
{
static wxPoint pos;
if( m_Poly )
{
pos = GetCornerPosition( 0 );
return m_Poly? GetCornerPosition( 0 ) : wxPoint( 0, 0 );
}
else
pos = wxPoint( 0, 0 );
return pos;
}
void ZONE_CONTAINER::SetPosition( const wxPoint& aPos ) {}
void ZONE_CONTAINER::SetNet( int aNetCode )

View File

@ -118,7 +118,8 @@ public:
* Function GetPosition
* @return a wxPoint, position of the first point of the outline
*/
wxPoint& GetPosition();
const wxPoint GetPosition() const; // overload
void SetPosition( const wxPoint& aPos ); // overload
/**
* Function copy