From 953f71df3e6e4bbb2c44a32a1ccb67be05f1a6e1 Mon Sep 17 00:00:00 2001 From: Maciej Suminski Date: Wed, 9 Jul 2014 11:59:24 +0200 Subject: [PATCH] Move() method updates local coordinates in EDGE_MODULE, D_PAD and TEXTE_MODULE classes. --- pcbnew/class_edge_mod.cpp | 19 +++++++++++++++++++ pcbnew/class_edge_mod.h | 11 +++++++++++ pcbnew/class_pad.cpp | 32 ++++++++++++++++++++++++++++++++ pcbnew/class_pad.h | 9 ++++++++- pcbnew/class_text_mod.cpp | 5 ++--- pcbnew/class_text_mod.h | 7 ++++--- 6 files changed, 76 insertions(+), 7 deletions(-) diff --git a/pcbnew/class_edge_mod.cpp b/pcbnew/class_edge_mod.cpp index 2d1ba56e57..5791563007 100644 --- a/pcbnew/class_edge_mod.cpp +++ b/pcbnew/class_edge_mod.cpp @@ -90,6 +90,25 @@ void EDGE_MODULE::Copy( EDGE_MODULE* source ) } +void EDGE_MODULE::SetLocalCoord() +{ + MODULE* module = (MODULE*) m_Parent; + + if( module == NULL ) + { + m_Start0 = m_Start; + m_End0 = m_End; + return; + } + + m_Start0 = m_Start - module->GetPosition(); + m_End0 = m_End - module->GetPosition(); + double angle = module->GetOrientation(); + RotatePoint( &m_Start0.x, &m_Start0.y, -angle ); + RotatePoint( &m_End0.x, &m_End0.y, -angle ); +} + + void EDGE_MODULE::SetDrawCoord() { MODULE* module = (MODULE*) m_Parent; diff --git a/pcbnew/class_edge_mod.h b/pcbnew/class_edge_mod.h index 7b8d5b09c8..e7b945a9af 100644 --- a/pcbnew/class_edge_mod.h +++ b/pcbnew/class_edge_mod.h @@ -61,12 +61,23 @@ public: void Copy( EDGE_MODULE* source ); // copy structure + void Move( const wxPoint& aMoveVector ) + { + m_Start += aMoveVector; + m_End += aMoveVector; + SetLocalCoord(); + } + 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; } + ///> Set relative coordinates. + void SetLocalCoord(); + + ///> Set absolute coordinates. void SetDrawCoord(); /* drawing functions */ diff --git a/pcbnew/class_pad.cpp b/pcbnew/class_pad.cpp index a65bd54784..246a766c9d 100644 --- a/pcbnew/class_pad.cpp +++ b/pcbnew/class_pad.cpp @@ -228,6 +228,38 @@ const EDA_RECT D_PAD::GetBoundingBox() const } +void D_PAD::SetDrawCoord() +{ + MODULE* module = (MODULE*) m_Parent; + + m_Pos = m_Pos0; + + if( module == NULL ) + return; + + double angle = module->GetOrientation(); + + RotatePoint( &m_Pos.x, &m_Pos.y, angle ); + m_Pos += module->GetPosition(); +} + + +void D_PAD::SetLocalCoord() +{ + MODULE* module = (MODULE*) m_Parent; + + if( module == NULL ) + { + m_Pos0 = m_Pos; + return; + } + + m_Pos0 = m_Pos - module->GetPosition(); + double angle = module->GetOrientation(); + RotatePoint( &m_Pos0.x, &m_Pos0.y, -angle ); +} + + void D_PAD::SetAttribute( PAD_ATTR_T aAttribute ) { m_Attribute = aAttribute; diff --git a/pcbnew/class_pad.h b/pcbnew/class_pad.h index 1687989462..53666d9e4c 100644 --- a/pcbnew/class_pad.h +++ b/pcbnew/class_pad.h @@ -153,7 +153,7 @@ public: * Function GetOrientation * returns the rotation angle of the pad in tenths of degrees, but soon degrees. */ - double GetOrientation() const { return m_Orient; } + double GetOrientation() const { return m_Orient; } void SetDrillShape( PAD_DRILL_SHAPE_T aDrillShape ) { m_drillShape = aDrillShape; } @@ -381,6 +381,12 @@ public: // Virtual function: const EDA_RECT GetBoundingBox() const; + ///> Set absolute coordinates. + void SetDrawCoord(); + + ///> Set relative coordinates. + void SetLocalCoord(); + /** * Function Compare * compares two pads and return 0 if they are equal. @@ -391,6 +397,7 @@ public: void Move( const wxPoint& aMoveVector ) { m_Pos += aMoveVector; + SetLocalCoord(); } diff --git a/pcbnew/class_text_mod.cpp b/pcbnew/class_text_mod.cpp index 5eda7cba6e..48b43b161b 100644 --- a/pcbnew/class_text_mod.cpp +++ b/pcbnew/class_text_mod.cpp @@ -129,7 +129,7 @@ int TEXTE_MODULE::GetLength() const return m_Text.Len(); } -// Update draw coordinates + void TEXTE_MODULE::SetDrawCoord() { MODULE* module = (MODULE*) m_Parent; @@ -146,8 +146,6 @@ void TEXTE_MODULE::SetDrawCoord() } -// Update "local" coordinates (coordinates relatives to the footprint -// anchor point) void TEXTE_MODULE::SetLocalCoord() { MODULE* module = (MODULE*) m_Parent; @@ -163,6 +161,7 @@ void TEXTE_MODULE::SetLocalCoord() RotatePoint( &m_Pos0.x, &m_Pos0.y, -angle ); } + bool TEXTE_MODULE::HitTest( const wxPoint& aPosition ) const { wxPoint rel_pos; diff --git a/pcbnew/class_text_mod.h b/pcbnew/class_text_mod.h index e9595a307f..fff9f20547 100644 --- a/pcbnew/class_text_mod.h +++ b/pcbnew/class_text_mod.h @@ -71,7 +71,6 @@ public: return aItem && PCB_MODULE_TEXT_T == aItem->Type(); } - virtual const wxPoint& GetPosition() const { return m_Pos; @@ -117,9 +116,11 @@ public: // Virtual function const EDA_RECT GetBoundingBox() const; - void SetDrawCoord(); // Set absolute coordinates. + ///> Set absolute coordinates. + void SetDrawCoord(); - void SetLocalCoord(); // Set relative coordinates. + ///> Set relative coordinates. + void SetLocalCoord(); /* drawing functions */ void Draw( EDA_DRAW_PANEL* panel,