[TD]fix 3d dimension position on DetailView
This commit is contained in:
@@ -32,6 +32,7 @@
|
||||
#include "DimensionGeometry.h"
|
||||
#include "DrawUtil.h"
|
||||
#include "DrawViewPart.h"
|
||||
#include "DrawViewDetail.h"
|
||||
|
||||
|
||||
using namespace TechDraw;
|
||||
@@ -72,6 +73,14 @@ void pointPair::scale(double factor)
|
||||
// project the points onto the dvp's paper plane.
|
||||
void pointPair::project(const DrawViewPart* dvp)
|
||||
{
|
||||
auto detailView = dynamic_cast<const DrawViewDetail*>(dvp);
|
||||
if (detailView) {
|
||||
m_first = detailView->mapPoint3dToDetail(m_first) * detailView->getScale();
|
||||
m_second = detailView->mapPoint3dToDetail(m_second) * detailView->getScale();
|
||||
m_overrideFirst = detailView->mapPoint3dToDetail(m_overrideFirst) * detailView->getScale();
|
||||
m_overrideSecond = detailView->mapPoint3dToDetail(m_overrideSecond) * detailView->getScale();
|
||||
return;
|
||||
}
|
||||
m_first = dvp->projectPoint(m_first) * dvp->getScale();
|
||||
m_second = dvp->projectPoint(m_second) * dvp->getScale();
|
||||
m_overrideFirst = dvp->projectPoint(m_overrideFirst) * dvp->getScale();
|
||||
|
||||
@@ -437,6 +437,20 @@ TopoDS_Shape DrawViewDetail::projectEdgesOntoFace(TopoDS_Shape& edgeShape, TopoD
|
||||
return TopoDS_Shape(std::move(edges));
|
||||
}
|
||||
|
||||
//! given a 3d point, find the corresponding point in this view.
|
||||
Base::Vector3d DrawViewDetail::mapPoint3dToDetail(const Base::Vector3d& inPoint) const
|
||||
{
|
||||
auto baseObj = BaseView.getValue();
|
||||
auto baseDvp = dynamic_cast<DrawViewPart*>(baseObj);
|
||||
if (!baseDvp) {
|
||||
throw Base::RuntimeError("Detail has no BaseView");
|
||||
}
|
||||
auto pointOnBase = baseDvp->projectPoint(inPoint, false);
|
||||
auto detailCenter = AnchorPoint.getValue();
|
||||
auto pointOnDetail = DU::invertY(pointOnBase - detailCenter);
|
||||
return pointOnDetail;
|
||||
}
|
||||
|
||||
//we don't want to paint detail highlights on top of detail views,
|
||||
//so tell the Gui that there are no details for this view
|
||||
std::vector<DrawViewDetail*> DrawViewDetail::getDetailRefs() const
|
||||
|
||||
@@ -92,6 +92,8 @@ public:
|
||||
std::vector<DrawViewDetail*> getDetailRefs() const override;
|
||||
TopoDS_Shape getDetailShape() const { return m_detailShape; }
|
||||
|
||||
Base::Vector3d mapPoint3dToDetail(const Base::Vector3d& inPoint) const;
|
||||
|
||||
public Q_SLOTS:
|
||||
void onMakeDetailFinished(void);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user