libs/kimath: SHAPE::Format() can now produce C++ object construction and simple test dump of shapes
This commit is contained in:
parent
99bcdf7979
commit
cd29dcf6e0
|
@ -243,7 +243,7 @@ public:
|
|||
|
||||
virtual bool Parse( std::stringstream& aStream );
|
||||
|
||||
virtual const std::string Format( ) const;
|
||||
virtual const std::string Format( bool aCplusPlus = true ) const;
|
||||
|
||||
protected:
|
||||
typedef VECTOR2I::extended_type ecoord;
|
||||
|
|
|
@ -135,6 +135,8 @@ public:
|
|||
return true;
|
||||
}
|
||||
|
||||
virtual const std::string Format( bool aCplusPlus = true ) const override;
|
||||
|
||||
private:
|
||||
CIRCLE m_circle;
|
||||
};
|
||||
|
|
|
@ -51,7 +51,7 @@ public:
|
|||
~SHAPE_COMPOUND();
|
||||
|
||||
SHAPE_COMPOUND* Clone() const override;
|
||||
const std::string Format() const override;
|
||||
const std::string Format( bool aCplusPlus = true ) const override;
|
||||
|
||||
bool Collide( const SEG& aSeg, int aClearance = 0, int* aActual = nullptr,
|
||||
VECTOR2I* aLocation = nullptr ) const override;
|
||||
|
|
|
@ -714,7 +714,7 @@ public:
|
|||
const VECTOR2I NearestPoint( const SEG& aSeg, int& dist ) const;
|
||||
|
||||
/// @copydoc SHAPE::Format()
|
||||
const std::string Format() const override;
|
||||
const std::string Format( bool aCplusPlus = true ) const override;
|
||||
|
||||
/// @copydoc SHAPE::Parse()
|
||||
bool Parse( std::stringstream& aStream ) override;
|
||||
|
|
|
@ -1054,7 +1054,7 @@ public:
|
|||
int NormalizeAreaOutlines();
|
||||
|
||||
/// @copydoc SHAPE::Format()
|
||||
const std::string Format() const override;
|
||||
const std::string Format( bool aCplusPlus = true ) const override;
|
||||
|
||||
/// @copydoc SHAPE::Parse()
|
||||
bool Parse( std::stringstream& aStream ) override;
|
||||
|
|
|
@ -188,7 +188,7 @@ public:
|
|||
return rv;
|
||||
}
|
||||
|
||||
virtual const std::string Format( ) const override;
|
||||
virtual const std::string Format( bool aCplusPlus = true ) const override;
|
||||
|
||||
private:
|
||||
VECTOR2I m_p0; ///< Top-left corner
|
||||
|
|
|
@ -157,7 +157,7 @@ public:
|
|||
m_seg.B += aVector;
|
||||
}
|
||||
|
||||
virtual const std::string Format( ) const override;
|
||||
virtual const std::string Format( bool aCplusPlus = true ) const override;
|
||||
|
||||
private:
|
||||
SEG m_seg;
|
||||
|
|
|
@ -38,10 +38,11 @@ bool SHAPE::Parse( std::stringstream& aStream )
|
|||
}
|
||||
|
||||
|
||||
const std::string SHAPE::Format() const
|
||||
const std::string SHAPE::Format( bool aCplusPlus ) const
|
||||
{
|
||||
assert( false );
|
||||
return std::string( "" );
|
||||
std::stringstream ss;
|
||||
ss << "shape " << m_type;
|
||||
return ss.str();
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -27,7 +27,7 @@
|
|||
|
||||
#include <geometry/shape_compound.h>
|
||||
|
||||
const std::string SHAPE_COMPOUND::Format() const
|
||||
const std::string SHAPE_COMPOUND::Format( bool aCplusPlus ) const
|
||||
{
|
||||
std::stringstream ss;
|
||||
|
||||
|
|
|
@ -1974,7 +1974,7 @@ int SHAPE_LINE_CHAIN::NearestSegment( const VECTOR2I& aP ) const
|
|||
}
|
||||
|
||||
|
||||
const std::string SHAPE_LINE_CHAIN::Format() const
|
||||
const std::string SHAPE_LINE_CHAIN::Format( bool aCplusPlus ) const
|
||||
{
|
||||
std::stringstream ss;
|
||||
|
||||
|
|
|
@ -1624,7 +1624,7 @@ int SHAPE_POLY_SET::NormalizeAreaOutlines()
|
|||
}
|
||||
|
||||
|
||||
const std::string SHAPE_POLY_SET::Format() const
|
||||
const std::string SHAPE_POLY_SET::Format( bool aCplusPlus ) const
|
||||
{
|
||||
std::stringstream ss;
|
||||
|
||||
|
|
|
@ -91,7 +91,7 @@ bool SHAPE_RECT::Collide( const SEG& aSeg, int aClearance, int* aActual, VECTOR2
|
|||
return false;
|
||||
}
|
||||
|
||||
const std::string SHAPE_RECT::Format( ) const
|
||||
const std::string SHAPE_RECT::Format( bool aCplusPlus ) const
|
||||
{
|
||||
std::stringstream ss;
|
||||
|
||||
|
|
|
@ -25,11 +25,14 @@
|
|||
#include <sstream>
|
||||
|
||||
#include <geometry/shape_segment.h>
|
||||
#include <geometry/shape_circle.h>
|
||||
|
||||
const std::string SHAPE_SEGMENT::Format() const
|
||||
const std::string SHAPE_SEGMENT::Format( bool aCplusPlus ) const
|
||||
{
|
||||
std::stringstream ss;
|
||||
|
||||
if( aCplusPlus )
|
||||
{
|
||||
ss << "SHAPE_SEGMENT( VECTOR2I( ";
|
||||
ss << m_seg.A.x;
|
||||
ss << ", ";
|
||||
|
@ -41,6 +44,46 @@ const std::string SHAPE_SEGMENT::Format() const
|
|||
ss << "), ";
|
||||
ss << m_width;
|
||||
ss << "); ";
|
||||
}
|
||||
else
|
||||
{
|
||||
ss << SHAPE::Format( aCplusPlus ) << " ";
|
||||
ss << m_seg.A.x;
|
||||
ss << " ";
|
||||
ss << m_seg.A.y;
|
||||
ss << " ";
|
||||
ss << m_seg.B.x;
|
||||
ss << " ";
|
||||
ss << m_seg.B.y;
|
||||
ss << " ";
|
||||
ss << m_width;
|
||||
}
|
||||
|
||||
return ss.str();
|
||||
}
|
||||
|
||||
const std::string SHAPE_CIRCLE::Format( bool aCplusPlus ) const
|
||||
{
|
||||
std::stringstream ss;
|
||||
|
||||
if( aCplusPlus )
|
||||
{
|
||||
ss << "SHAPE_CIRCLE( VECTOR2I( ";
|
||||
ss << m_circle.Center.x;
|
||||
ss << ", ";
|
||||
ss << m_circle.Center.y;
|
||||
ss << "), ";
|
||||
ss << m_circle.Radius;
|
||||
ss << "); ";
|
||||
} else
|
||||
{
|
||||
ss << SHAPE::Format( aCplusPlus ) << " ";
|
||||
ss << m_circle.Center.x;
|
||||
ss << " ";
|
||||
ss << m_circle.Center.y;
|
||||
ss << " ";
|
||||
ss << m_circle.Radius;
|
||||
}
|
||||
return ss.str();
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue