From 7207de9beae4af09a8fc01ce74621b44ca59c936 Mon Sep 17 00:00:00 2001 From: Maciej Suminski Date: Mon, 16 Sep 2013 14:44:03 +0200 Subject: [PATCH] Fixed bounding box for dimension. --- pcbnew/class_dimension.cpp | 19 +++++++++++++++++++ pcbnew/class_dimension.h | 3 +++ 2 files changed, 22 insertions(+) diff --git a/pcbnew/class_dimension.cpp b/pcbnew/class_dimension.cpp index c6dab49476..f7dacdc2a6 100644 --- a/pcbnew/class_dimension.cpp +++ b/pcbnew/class_dimension.cpp @@ -468,6 +468,15 @@ EDA_RECT DIMENSION::GetBoundingBox() const ymax = std::max( ymax, m_featureLineGO.y ); ymax = std::max( ymax, m_featureLineGF.y ); + xmin = std::min( xmin, m_featureLineDO.x ); + xmin = std::min( xmin, m_featureLineDF.x ); + ymin = std::min( ymin, m_featureLineDO.y ); + ymin = std::min( ymin, m_featureLineDF.y ); + xmax = std::max( xmax, m_featureLineDO.x ); + xmax = std::max( xmax, m_featureLineDF.x ); + ymax = std::max( ymax, m_featureLineDO.y ); + ymax = std::max( ymax, m_featureLineDF.y ); + bBox.SetX( xmin ); bBox.SetY( ymin ); bBox.SetWidth( xmax - xmin + 1 ); @@ -489,6 +498,16 @@ wxString DIMENSION::GetSelectMenuText() const } +const BOX2I DIMENSION::ViewBBox() const +{ + BOX2I dimBBox = BOX2I( VECTOR2I( GetBoundingBox().GetPosition() ), + VECTOR2I( GetBoundingBox().GetSize() ) ); + dimBBox.Merge( m_Text.ViewBBox() ); + + return dimBBox; +} + + void DIMENSION::ViewGetLayers( int aLayers[], int& aCount ) const { // Layer that simply displays the text diff --git a/pcbnew/class_dimension.h b/pcbnew/class_dimension.h index c92aae7433..25baeca80f 100644 --- a/pcbnew/class_dimension.h +++ b/pcbnew/class_dimension.h @@ -144,6 +144,9 @@ public: EDA_ITEM* Clone() const; + /// @copydoc VIEW_ITEM::ViewBBox() + virtual const BOX2I ViewBBox() const; + /// @copydoc VIEW_ITEM::ViewGetLayers() virtual void ViewGetLayers( int aLayers[], int& aCount ) const;