[TechDraw] Improve DimensionGeometry.cpp typing
Make type safe by using const keywords when appropriate and improve memory handling by using references when appropriate.
This commit is contained in:
committed by
WandererFan
parent
575489b816
commit
bb50fd1079
@@ -44,14 +44,14 @@ pointPair::pointPair(const pointPair& pp)
|
||||
}
|
||||
|
||||
//move the points by offset
|
||||
void pointPair::move(Base::Vector3d offset)
|
||||
void pointPair::move(const Base::Vector3d& offset)
|
||||
{
|
||||
m_first = m_first - offset;
|
||||
m_second = m_second - offset;
|
||||
}
|
||||
|
||||
// project the points onto the dvp's paper plane.
|
||||
void pointPair::project(DrawViewPart* dvp)
|
||||
void pointPair::project(const DrawViewPart* dvp)
|
||||
{
|
||||
m_first = dvp->projectPoint(m_first) * dvp->getScale();
|
||||
m_second = dvp->projectPoint(m_second) * dvp->getScale();
|
||||
@@ -60,7 +60,7 @@ void pointPair::project(DrawViewPart* dvp)
|
||||
// map the points onto the dvp's XY coordinate system
|
||||
// this routine is no longer needed since we now use the hlr projector instead
|
||||
// of "projectToPlane" from Vector3d
|
||||
void pointPair::mapToPage(DrawViewPart* dvp)
|
||||
void pointPair::mapToPage(const DrawViewPart* dvp)
|
||||
{
|
||||
gp_Trsf xOXYZ;
|
||||
gp_Ax3 OXYZ;
|
||||
@@ -80,7 +80,7 @@ void pointPair::invertY()
|
||||
m_second = DU::invertY(m_second);
|
||||
}
|
||||
|
||||
void pointPair::dump(std::string text) const
|
||||
void pointPair::dump(const std::string& text) const
|
||||
{
|
||||
Base::Console().Message("pointPair - %s\n", text.c_str());
|
||||
Base::Console().Message("pointPair - first: %s second: %s\n",
|
||||
@@ -104,14 +104,14 @@ anglePoints& anglePoints::operator=(const anglePoints& ap)
|
||||
}
|
||||
|
||||
// move the points by offset
|
||||
void anglePoints::move(Base::Vector3d offset)
|
||||
void anglePoints::move(const Base::Vector3d& offset)
|
||||
{
|
||||
m_ends.move(offset);
|
||||
m_vertex = m_vertex - offset;
|
||||
}
|
||||
|
||||
// project the points onto the dvp's paper plane.
|
||||
void anglePoints::project(DrawViewPart* dvp)
|
||||
void anglePoints::project(const DrawViewPart* dvp)
|
||||
{
|
||||
m_ends.project(dvp);
|
||||
m_vertex = dvp->projectPoint(m_vertex) * dvp->getScale();
|
||||
@@ -119,7 +119,7 @@ void anglePoints::project(DrawViewPart* dvp)
|
||||
|
||||
// map the points onto the dvp's XY coordinate system
|
||||
// obsolete. see above.
|
||||
void anglePoints::mapToPage(DrawViewPart* dvp)
|
||||
void anglePoints::mapToPage(const DrawViewPart* dvp)
|
||||
{
|
||||
m_ends.mapToPage(dvp);
|
||||
|
||||
@@ -138,7 +138,7 @@ void anglePoints::invertY()
|
||||
m_vertex = DU::invertY(m_vertex);
|
||||
}
|
||||
|
||||
void anglePoints::dump(std::string text) const
|
||||
void anglePoints::dump(const std::string& text) const
|
||||
{
|
||||
Base::Console().Message("anglePoints - %s\n", text.c_str());
|
||||
Base::Console().Message("anglePoints - ends - first: %s second: %s\n",
|
||||
@@ -171,7 +171,7 @@ arcPoints& arcPoints::operator=(const arcPoints& ap)
|
||||
return *this;
|
||||
}
|
||||
|
||||
void arcPoints::move(Base::Vector3d offset)
|
||||
void arcPoints::move(const Base::Vector3d& offset)
|
||||
{
|
||||
center = center - offset;
|
||||
onCurve.first(onCurve.first() - offset);
|
||||
@@ -181,7 +181,7 @@ void arcPoints::move(Base::Vector3d offset)
|
||||
midArc = midArc - offset;
|
||||
}
|
||||
|
||||
void arcPoints::project(DrawViewPart* dvp)
|
||||
void arcPoints::project(const DrawViewPart* dvp)
|
||||
{
|
||||
radius = radius * dvp->getScale();
|
||||
center = dvp->projectPoint(center) * dvp->getScale();
|
||||
@@ -193,7 +193,7 @@ void arcPoints::project(DrawViewPart* dvp)
|
||||
}
|
||||
|
||||
// obsolete. see above
|
||||
void arcPoints::mapToPage(DrawViewPart* dvp)
|
||||
void arcPoints::mapToPage(const DrawViewPart* dvp)
|
||||
{
|
||||
gp_Trsf xOXYZ;
|
||||
gp_Ax3 OXYZ;
|
||||
@@ -222,7 +222,7 @@ void arcPoints::invertY()
|
||||
midArc = DU::invertY(midArc);
|
||||
}
|
||||
|
||||
void arcPoints::dump(std::string text) const
|
||||
void arcPoints::dump(const std::string& text) const
|
||||
{
|
||||
Base::Console().Message("arcPoints - %s\n", text.c_str());
|
||||
Base::Console().Message("arcPoints - radius: %.3f center: %s\n", radius,
|
||||
|
||||
@@ -38,10 +38,10 @@ class TechDrawExport pointPair
|
||||
{
|
||||
public:
|
||||
pointPair() = default;
|
||||
pointPair(Base::Vector3d point0, Base::Vector3d point1) { m_first = point0; m_second = point1; }
|
||||
pointPair(const Base::Vector3d& point0, const Base::Vector3d& point1) { m_first = point0; m_second = point1; }
|
||||
pointPair(const pointPair& pp);
|
||||
|
||||
pointPair& operator= (const pointPair& pp) {
|
||||
pointPair& operator=(const pointPair& pp) {
|
||||
m_first = pp.first();
|
||||
m_second = pp.second();
|
||||
return *this;
|
||||
@@ -52,11 +52,11 @@ public:
|
||||
Base::Vector3d second() const { return m_second; }
|
||||
void second(Base::Vector3d newSecond) { m_second = newSecond; }
|
||||
|
||||
void move(Base::Vector3d offset);
|
||||
void project(DrawViewPart* dvp);
|
||||
void mapToPage(DrawViewPart* dvp);
|
||||
void move(const Base::Vector3d& offset);
|
||||
void project(const DrawViewPart* dvp);
|
||||
void mapToPage(const DrawViewPart* dvp);
|
||||
void invertY();
|
||||
void dump(std::string text) const;
|
||||
void dump(const std::string& text) const;
|
||||
|
||||
private:
|
||||
Base::Vector3d m_first;
|
||||
@@ -68,26 +68,26 @@ class TechDrawExport anglePoints
|
||||
{
|
||||
public:
|
||||
anglePoints();
|
||||
anglePoints(Base::Vector3d apex, Base::Vector3d point0, Base::Vector3d point1) {
|
||||
anglePoints(const Base::Vector3d& apex, const Base::Vector3d& point0, Base::Vector3d point1) {
|
||||
vertex(apex); first(point0); second(point1); }
|
||||
anglePoints(const anglePoints& ap);
|
||||
|
||||
anglePoints& operator= (const anglePoints& ap);
|
||||
|
||||
pointPair ends() const { return m_ends; }
|
||||
void ends(pointPair newEnds) { m_ends = newEnds; }
|
||||
void ends(const pointPair& newEnds) { m_ends = newEnds; }
|
||||
Base::Vector3d first() const { return m_ends.first(); }
|
||||
void first(Base::Vector3d newFirst) { m_ends.first(newFirst); }
|
||||
void first(const Base::Vector3d& newFirst) { m_ends.first(newFirst); }
|
||||
Base::Vector3d second() const { return m_ends.second(); }
|
||||
void second(Base::Vector3d newSecond) { m_ends.second(newSecond); }
|
||||
void second(const Base::Vector3d& newSecond) { m_ends.second(newSecond); }
|
||||
Base::Vector3d vertex() const { return m_vertex; }
|
||||
void vertex(Base::Vector3d newVertex) { m_vertex = newVertex; }
|
||||
void vertex(const Base::Vector3d& newVertex) { m_vertex = newVertex; }
|
||||
|
||||
void move(Base::Vector3d offset);
|
||||
void project(DrawViewPart* dvp);
|
||||
void mapToPage(DrawViewPart* dvp);
|
||||
void move(const Base::Vector3d& offset);
|
||||
void project(const DrawViewPart* dvp);
|
||||
void mapToPage(const DrawViewPart* dvp);
|
||||
void invertY();
|
||||
void dump(std::string text) const;
|
||||
void dump(const std::string& text) const;
|
||||
|
||||
private:
|
||||
pointPair m_ends;
|
||||
@@ -103,11 +103,11 @@ public:
|
||||
|
||||
arcPoints& operator= (const arcPoints& ap);
|
||||
|
||||
void move(Base::Vector3d offset);
|
||||
void project(DrawViewPart* dvp);
|
||||
void mapToPage(DrawViewPart* dvp);
|
||||
void move(const Base::Vector3d& offset);
|
||||
void project(const DrawViewPart* dvp);
|
||||
void mapToPage(const DrawViewPart* dvp);
|
||||
void invertY();
|
||||
void dump(std::string text) const;
|
||||
void dump(const std::string& text) const;
|
||||
|
||||
//TODO: setters and getters
|
||||
bool isArc;
|
||||
|
||||
Reference in New Issue
Block a user