Implement DXF INSERT scale

This has a chance of being wrong due to how the dimensions are stored in these intermediate objects
This commit is contained in:
Marek Roszko 2020-11-25 00:54:44 -05:00
parent e4d0ffd607
commit cac0d93dfd
2 changed files with 55 additions and 0 deletions

View File

@ -491,6 +491,7 @@ void DXF_IMPORT_PLUGIN::addInsert( const DL_InsertData& aData )
std::unique_ptr<IMPORTED_SHAPE> newShape = shape->clone();
newShape->Translate( translation );
newShape->Scale( aData.sx, aData.sy );
m_internalImporter.AddShape( newShape );
}

View File

@ -39,6 +39,7 @@ public:
virtual std::unique_ptr<IMPORTED_SHAPE> clone() const = 0;
virtual void Translate( const VECTOR2D& aVec ) = 0;
virtual void Scale( double scaleX, double scaleY ) = 0;
};
@ -68,6 +69,14 @@ public:
m_end += aVec;
}
void Scale( double scaleX, double scaleY ) override
{
m_start.x *= scaleX;
m_start.y *= scaleY;
m_end.x *= scaleX;
m_end.y *= scaleY;
}
private:
VECTOR2D m_start;
VECTOR2D m_end;
@ -101,6 +110,15 @@ public:
m_center += aVec;
}
void Scale( double scaleX, double scaleY ) override
{
m_center.x *= scaleX;
m_center.y *= scaleY;
// we really can't handle scalex != scaleY cleanly...it would be an ellipse
m_radius *= scaleX;
}
private:
VECTOR2D m_center;
double m_radius;
@ -136,6 +154,15 @@ public:
m_start += aVec;
}
void Scale( double scaleX, double scaleY ) override
{
m_center.x *= scaleX;
m_center.y *= scaleY;
m_start.x *= scaleX;
m_start.y *= scaleY;
}
private:
VECTOR2D m_center;
VECTOR2D m_start;
@ -171,6 +198,15 @@ public:
}
}
void Scale( double scaleX, double scaleY ) override
{
for( auto& vertex : m_vertices )
{
vertex.x *= scaleX;
vertex.y *= scaleY;
}
}
private:
std::vector<VECTOR2D> m_vertices;
double m_width;
@ -210,6 +246,12 @@ public:
m_origin += aVec;
}
void Scale( double scaleX, double scaleY ) override
{
m_origin.x *= scaleX;
m_origin.y *= scaleY;
}
private:
VECTOR2D m_origin;
const wxString m_text;
@ -253,6 +295,18 @@ public:
m_end += aVec;
}
void Scale( double scaleX, double scaleY ) override
{
m_start.x *= scaleX;
m_start.y *= scaleY;
m_bezierControl1.x *= scaleX;
m_bezierControl1.y *= scaleY;
m_bezierControl2.x *= scaleX;
m_bezierControl2.y *= scaleY;
m_end.x *= scaleX;
m_end.y *= scaleY;
}
private:
VECTOR2D m_start;
VECTOR2D m_bezierControl1;