diff --git a/3d-viewer/3d_draw.cpp b/3d-viewer/3d_draw.cpp index a6f4e7bc28..11906269ee 100644 --- a/3d-viewer/3d_draw.cpp +++ b/3d-viewer/3d_draw.cpp @@ -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; iCount(); 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; } diff --git a/gerbview/class_gerber_draw_item.h b/gerbview/class_gerber_draw_item.h index 83298c6c0f..42beff5ae6 100644 --- a/gerbview/class_gerber_draw_item.h +++ b/gerbview/class_gerber_draw_item.h @@ -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. diff --git a/include/base_struct.h b/include/base_struct.h index 9f24117a6e..2a9bb38a95 100644 --- a/include/base_struct.h +++ b/include/base_struct.h @@ -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(); }; /** diff --git a/include/class_board_item.h b/include/class_board_item.h index ead8d83f31..4f1d4aca09 100644 --- a/include/class_board_item.h +++ b/include/class_board_item.h @@ -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, diff --git a/pcbnew/block_module_editor.cpp b/pcbnew/block_module_editor.cpp index 056fd77d65..ea4856d460 100644 --- a/pcbnew/block_module_editor.cpp +++ b/pcbnew/block_module_editor.cpp @@ -537,7 +537,8 @@ void DeleteMarkedItems( MODULE* module ) void MirrorMarkedItems( MODULE* module, wxPoint offset ) { #define SETMIRROR( z ) (z) -= offset.x; (z) = -(z); (z) += offset.x; - EDA_ITEM* item; + 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; diff --git a/pcbnew/class_board.cpp b/pcbnew/class_board.cpp index 99f631c919..2f9cf66cd3 100644 --- a/pcbnew/class_board.cpp +++ b/pcbnew/class_board.cpp @@ -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 ) diff --git a/pcbnew/class_board.h b/pcbnew/class_board.h index 798de32e30..8d7f773672 100644 --- a/pcbnew/class_board.h +++ b/pcbnew/class_board.h @@ -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 diff --git a/pcbnew/class_dimension.cpp b/pcbnew/class_dimension.cpp index 1bcde051d5..47a13745b8 100644 --- a/pcbnew/class_dimension.cpp +++ b/pcbnew/class_dimension.cpp @@ -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; } @@ -260,18 +264,21 @@ void DIMENSION::Move(const wxPoint& offset) } -void DIMENSION::Rotate(const wxPoint& aRotCentre, int aAngle) +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 ); @@ -290,7 +297,7 @@ void DIMENSION::Rotate(const wxPoint& aRotCentre, int aAngle) } -void DIMENSION::Flip(const wxPoint& aCentre ) +void DIMENSION::Flip( const wxPoint& aCentre ) { Mirror( aCentre ); SetLayer( ChangeSideNumLayer( GetLayer() ) ); @@ -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 ) { diff --git a/pcbnew/class_dimension.h b/pcbnew/class_dimension.h index e2cc04e175..e1b2ffa8f5 100644 --- a/pcbnew/class_dimension.h +++ b/pcbnew/class_dimension.h @@ -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. diff --git a/pcbnew/class_drawsegment.cpp b/pcbnew/class_drawsegment.cpp index 55d743e406..02ae2682d3 100644 --- a/pcbnew/class_drawsegment.cpp +++ b/pcbnew/class_drawsegment.cpp @@ -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; } diff --git a/pcbnew/class_drawsegment.h b/pcbnew/class_drawsegment.h index 9639ee5f6e..ee86ecd1d3 100644 --- a/pcbnew/class_drawsegment.h +++ b/pcbnew/class_drawsegment.h @@ -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 diff --git a/pcbnew/class_edge_mod.cpp b/pcbnew/class_edge_mod.cpp index 0ef709e0c0..a6174e0aa2 100644 --- a/pcbnew/class_edge_mod.cpp +++ b/pcbnew/class_edge_mod.cpp @@ -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; } diff --git a/pcbnew/class_marker_pcb.h b/pcbnew/class_marker_pcb.h index 2396061164..5bf7913291 100644 --- a/pcbnew/class_marker_pcb.h +++ b/pcbnew/class_marker_pcb.h @@ -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 diff --git a/pcbnew/class_mire.h b/pcbnew/class_mire.h index 8106a3874b..c61f2de623 100644 --- a/pcbnew/class_mire.h +++ b/pcbnew/class_mire.h @@ -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 diff --git a/pcbnew/class_module.h b/pcbnew/class_module.h index 881b9d1f3e..f47a34e1a5 100644 --- a/pcbnew/class_module.h +++ b/pcbnew/class_module.h @@ -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 m_Pads; /* Pad list (linked list) */ DLIST 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. diff --git a/pcbnew/class_module_transform_functions.cpp b/pcbnew/class_module_transform_functions.cpp index 79afa57d46..8b64e6f20c 100644 --- a/pcbnew/class_module_transform_functions.cpp +++ b/pcbnew/class_module_transform_functions.cpp @@ -159,7 +159,7 @@ void MODULE::Rotate(const wxPoint& aRotCentre, int aAngle) * Flip this object, i.e. change the board side for this object * @param aCentre - the rotation point. */ -void MODULE::Flip(const wxPoint& aCentre ) +void MODULE::Flip( const wxPoint& aCentre ) { D_PAD* pt_pad; TEXTE_MODULE* pt_texte; diff --git a/pcbnew/class_pad.cpp b/pcbnew/class_pad.cpp index e73408a2fb..8f42a17bcf 100644 --- a/pcbnew/class_pad.cpp +++ b/pcbnew/class_pad.cpp @@ -496,7 +496,7 @@ int D_PAD::ReadDescr( LINE_READER* aReader ) break; case 'L': - int lengthdie; + int lengthdie; nn = sscanf( PtLine, "%d", &lengthdie ); m_LengthDie = lengthdie; break; @@ -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)" ), diff --git a/pcbnew/class_pad.h b/pcbnew/class_pad.h index 37d4914287..9dbaf45c0e 100644 --- a/pcbnew/class_pad.h +++ b/pcbnew/class_pad.h @@ -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 diff --git a/pcbnew/class_pcb_text.h b/pcbnew/class_pcb_text.h index 21cd41b90e..a8478b8558 100644 --- a/pcbnew/class_pcb_text.h +++ b/pcbnew/class_pcb_text.h @@ -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. diff --git a/pcbnew/class_text_mod.h b/pcbnew/class_text_mod.h index d1a28b1def..49fffc4675 100644 --- a/pcbnew/class_text_mod.h +++ b/pcbnew/class_text_mod.h @@ -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 diff --git a/pcbnew/class_track.h b/pcbnew/class_track.h index c360aeefdb..9a141cdb22 100644 --- a/pcbnew/class_track.h +++ b/pcbnew/class_track.h @@ -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 diff --git a/pcbnew/class_zone.cpp b/pcbnew/class_zone.cpp index 2b2c4748d2..a23ba7975e 100644 --- a/pcbnew/class_zone.cpp +++ b/pcbnew/class_zone.cpp @@ -84,21 +84,15 @@ bool ZONE_CONTAINER::UnFill() } -wxPoint& ZONE_CONTAINER::GetPosition() +const wxPoint ZONE_CONTAINER::GetPosition() const { - static wxPoint pos; - - if( m_Poly ) - { - pos = GetCornerPosition( 0 ); - } - else - pos = wxPoint( 0, 0 ); - - return pos; + return m_Poly? GetCornerPosition( 0 ) : wxPoint( 0, 0 ); } +void ZONE_CONTAINER::SetPosition( const wxPoint& aPos ) {} + + void ZONE_CONTAINER::SetNet( int aNetCode ) { m_NetCode = aNetCode; diff --git a/pcbnew/class_zone.h b/pcbnew/class_zone.h index 114c22be55..fd9fadca70 100644 --- a/pcbnew/class_zone.h +++ b/pcbnew/class_zone.h @@ -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