[TD]add section line marks for simple section
This commit is contained in:
@@ -123,31 +123,6 @@ using namespace TechDraw;
|
||||
using namespace std;
|
||||
using DU = DrawUtil;
|
||||
|
||||
//class to store geometry of points where the section line changes direction
|
||||
ChangePoint::ChangePoint(QPointF location, QPointF preDirection, QPointF postDirection)
|
||||
{
|
||||
m_location = location;
|
||||
m_preDirection = preDirection;
|
||||
m_postDirection = postDirection;
|
||||
}
|
||||
|
||||
ChangePoint::ChangePoint(gp_Pnt location, gp_Dir preDirection, gp_Dir postDirection)
|
||||
{
|
||||
m_location.setX(location.X());
|
||||
m_location.setY(location.Y());
|
||||
m_preDirection.setX(preDirection.X());
|
||||
m_preDirection.setY(preDirection.Y());
|
||||
m_postDirection.setX(postDirection.X());
|
||||
m_postDirection.setY(postDirection.Y());
|
||||
}
|
||||
|
||||
void ChangePoint::scale(double scaleFactor)
|
||||
{
|
||||
m_location = m_location * scaleFactor;
|
||||
m_preDirection = m_preDirection * scaleFactor;
|
||||
m_postDirection = m_postDirection * scaleFactor;
|
||||
}
|
||||
|
||||
//===========================================================================
|
||||
// DrawComplexSection
|
||||
//===========================================================================
|
||||
|
||||
@@ -35,27 +35,6 @@
|
||||
namespace TechDraw
|
||||
{
|
||||
|
||||
//changes in direction of complex section line
|
||||
class ChangePoint
|
||||
{
|
||||
public:
|
||||
ChangePoint(QPointF location, QPointF preDirection, QPointF postDirection);
|
||||
ChangePoint(gp_Pnt location, gp_Dir preDirection, gp_Dir postDirection);
|
||||
~ChangePoint() = default;
|
||||
|
||||
QPointF getLocation() const { return m_location; }
|
||||
QPointF getPreDirection() const { return m_preDirection; }
|
||||
QPointF getPostDirection() const { return m_postDirection; }
|
||||
void scale(double scaleFactor);
|
||||
|
||||
private:
|
||||
QPointF m_location;
|
||||
QPointF m_preDirection;
|
||||
QPointF m_postDirection;
|
||||
};
|
||||
|
||||
using ChangePointVector = std::vector<ChangePoint>;
|
||||
|
||||
class TechDrawExport DrawComplexSection: public DrawViewSection
|
||||
{
|
||||
PROPERTY_HEADER_WITH_OVERRIDE(Part::DrawComplexSection);
|
||||
@@ -94,7 +73,7 @@ public:
|
||||
std::pair<Base::Vector3d, Base::Vector3d> sectionArrowDirs();
|
||||
TopoDS_Wire makeSectionLineWire();
|
||||
|
||||
ChangePointVector getChangePointsFromSectionLine();
|
||||
ChangePointVector getChangePointsFromSectionLine() override;
|
||||
|
||||
bool validateProfilePosition(TopoDS_Wire profileWire, gp_Ax2 sectionCS,
|
||||
gp_Dir &gClosestBasis) const;
|
||||
|
||||
@@ -145,11 +145,17 @@ class TechDrawExport DrawUtil {
|
||||
Base::Vector3d p2, Base::Vector3d d2);
|
||||
static Base::Vector2d Intersect2d(Base::Vector2d p1, Base::Vector2d d1,
|
||||
Base::Vector2d p2, Base::Vector2d d2);
|
||||
|
||||
static Base::Vector3d toVector3d(const gp_Pnt gp) { return Base::Vector3d(gp.X(), gp.Y(), gp.Z()); }
|
||||
static Base::Vector3d toVector3d(const gp_Dir gp) { return Base::Vector3d(gp.X(), gp.Y(), gp.Z()); }
|
||||
static Base::Vector3d toVector3d(const gp_Vec gp) { return Base::Vector3d(gp.X(), gp.Y(), gp.Z()); }
|
||||
static Base::Vector3d toVector3d(const QPointF gp) { return Base::Vector3d(gp.x(), gp.y(), 0.0); }
|
||||
|
||||
static gp_Pnt togp_Pnt(const Base::Vector3d v) { return gp_Pnt(v.x, v.y, v.z); }
|
||||
static gp_Dir togp_Dir(const Base::Vector3d v) { return gp_Dir(v.x, v.y, v.z); }
|
||||
static gp_Vec togp_Vec(const Base::Vector3d v) { return gp_Vec(v.x, v.y, v.z); }
|
||||
static QPointF toQPointF(const Base::Vector3d v) { return QPointF(v.x, v.y); }
|
||||
|
||||
static std::string shapeToString(TopoDS_Shape s);
|
||||
static TopoDS_Shape shapeFromString(std::string s);
|
||||
static Base::Vector3d invertY(Base::Vector3d v);
|
||||
|
||||
@@ -95,6 +95,29 @@ using namespace TechDraw;
|
||||
|
||||
using DU = DrawUtil;
|
||||
|
||||
//class to store geometry of points where the section line changes direction
|
||||
ChangePoint::ChangePoint(QPointF location, QPointF preDirection, QPointF postDirection)
|
||||
{
|
||||
m_location = location;
|
||||
m_preDirection = preDirection;
|
||||
m_postDirection = postDirection;
|
||||
}
|
||||
|
||||
ChangePoint::ChangePoint(gp_Pnt location, gp_Dir preDirection, gp_Dir postDirection)
|
||||
{
|
||||
m_location.setX(location.X());
|
||||
m_location.setY(location.Y());
|
||||
m_preDirection.setX(preDirection.X());
|
||||
m_preDirection.setY(preDirection.Y());
|
||||
m_postDirection.setX(postDirection.X());
|
||||
m_postDirection.setY(postDirection.Y());
|
||||
}
|
||||
|
||||
void ChangePoint::scale(double scaleFactor)
|
||||
{
|
||||
m_location = m_location * scaleFactor;
|
||||
}
|
||||
|
||||
const char* DrawViewSection::SectionDirEnums[]= {"Right",
|
||||
"Left",
|
||||
"Up",
|
||||
@@ -726,6 +749,30 @@ std::pair<Base::Vector3d, Base::Vector3d> DrawViewSection::sectionLineEnds()
|
||||
return result;
|
||||
}
|
||||
|
||||
//find the points and directions to make the change point marks.
|
||||
ChangePointVector DrawViewSection::getChangePointsFromSectionLine()
|
||||
{
|
||||
// Base::Console().Message("Dvs::getChangePointsFromSectionLine()\n");
|
||||
ChangePointVector result;
|
||||
std::vector<gp_Pnt> allPoints;
|
||||
DrawViewPart *baseDvp = dynamic_cast<DrawViewPart *>(BaseView.getValue());
|
||||
if (baseDvp) {
|
||||
std::pair<Base::Vector3d, Base::Vector3d> lineEnds = sectionLineEnds();
|
||||
//make start and end marks
|
||||
gp_Pnt location0 = DU::togp_Pnt(lineEnds.first);
|
||||
gp_Pnt location1 = DU::togp_Pnt(lineEnds.second);
|
||||
gp_Dir postDir = gp_Dir(location1.XYZ() - location0.XYZ());
|
||||
gp_Dir preDir = postDir.Reversed();
|
||||
ChangePoint startPoint(location0, preDir, postDir);
|
||||
result.push_back(startPoint);
|
||||
preDir = gp_Dir(location0.XYZ() - location1.XYZ());
|
||||
postDir = preDir.Reversed();
|
||||
ChangePoint endPoint(location1, preDir, postDir);
|
||||
result.push_back(endPoint);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
//this should really be in BoundBox.h
|
||||
//!check if point is in box or on boundary of box
|
||||
//!compare to isInBox which doesn't allow on boundary
|
||||
|
||||
@@ -58,6 +58,28 @@ class PATLineSpec;
|
||||
class LineSet;
|
||||
class DashSet;
|
||||
|
||||
//changes in direction of complex section line. also marks at arrow positions.
|
||||
class ChangePoint
|
||||
{
|
||||
public:
|
||||
ChangePoint(QPointF location, QPointF preDirection, QPointF postDirection);
|
||||
ChangePoint(gp_Pnt location, gp_Dir preDirection, gp_Dir postDirection);
|
||||
~ChangePoint() = default;
|
||||
|
||||
QPointF getLocation() const { return m_location; }
|
||||
void setLocation(QPointF newLocation) { m_location = newLocation; }
|
||||
QPointF getPreDirection() const { return m_preDirection; }
|
||||
QPointF getPostDirection() const { return m_postDirection; }
|
||||
void scale(double scaleFactor);
|
||||
|
||||
private:
|
||||
QPointF m_location;
|
||||
QPointF m_preDirection;
|
||||
QPointF m_postDirection;
|
||||
};
|
||||
|
||||
using ChangePointVector = std::vector<ChangePoint>;
|
||||
|
||||
class TechDrawExport DrawViewSection : public DrawViewPart
|
||||
{
|
||||
PROPERTY_HEADER_WITH_OVERRIDE(Part::DrawViewSection);
|
||||
@@ -141,6 +163,7 @@ public:
|
||||
static const char* CutSurfaceEnums[];
|
||||
|
||||
virtual std::pair<Base::Vector3d, Base::Vector3d> sectionLineEnds();
|
||||
virtual ChangePointVector getChangePointsFromSectionLine();
|
||||
|
||||
bool showSectionEdges(void);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user