[TD]Dimension Py Routine fixes
This commit is contained in:
@@ -794,6 +794,8 @@ private:
|
||||
|
||||
Py::Object makeDistanceDim(const Py::Tuple& args)
|
||||
{
|
||||
//points come in unscaled,but makeDistDim unscales them so we need to prescale here.
|
||||
//makeDistDim was built for extent dims which work from scaled geometry
|
||||
PyObject* pDvp;
|
||||
PyObject* pDimType;
|
||||
PyObject* pFrom;
|
||||
@@ -827,12 +829,14 @@ private:
|
||||
if (PyObject_TypeCheck(pTo, &(Base::VectorPy::Type))) {
|
||||
to = static_cast<Base::VectorPy*>(pTo)->value();
|
||||
}
|
||||
DrawViewDimension* dvd =
|
||||
DrawDimHelper::makeDistDim(dvp,
|
||||
dimType,
|
||||
from,
|
||||
to);
|
||||
|
||||
return Py::None();
|
||||
DrawUtil::invertY(from),
|
||||
DrawUtil::invertY(to));
|
||||
PyObject* dvdPy = dvd->getPyObject();
|
||||
return Py::asObject(dvdPy);
|
||||
// return Py::None();
|
||||
}
|
||||
|
||||
Py::Object makeDistanceDim3d(const Py::Tuple& args)
|
||||
@@ -869,8 +873,10 @@ private:
|
||||
if (PyObject_TypeCheck(pTo, &(Base::VectorPy::Type))) {
|
||||
to = static_cast<Base::VectorPy*>(pTo)->value();
|
||||
}
|
||||
//3d points are not scaled
|
||||
from = DrawUtil::invertY(dvp->projectPoint(from));
|
||||
to = DrawUtil::invertY(dvp->projectPoint(to));
|
||||
//DrawViewDimension* =
|
||||
DrawDimHelper::makeDistDim(dvp,
|
||||
dimType,
|
||||
from,
|
||||
|
||||
@@ -107,8 +107,8 @@ void DrawDimHelper::makeExtentDim(DrawViewPart* dvp,
|
||||
std::pair<Base::Vector3d, Base::Vector3d> endPoints = minMax(dvp,
|
||||
edgeNames,
|
||||
direction);
|
||||
Base::Vector3d refMin = endPoints.first;
|
||||
Base::Vector3d refMax = endPoints.second;
|
||||
Base::Vector3d refMin = endPoints.first / dvp->getScale(); //unscale from geometry
|
||||
Base::Vector3d refMax = endPoints.second / dvp->getScale();
|
||||
|
||||
//pause recomputes
|
||||
dvp->getDocument()->setStatus(App::Document::Status::SkipRecompute, true);
|
||||
@@ -326,11 +326,10 @@ gp_Pnt2d DrawDimHelper::findClosestPoint(std::vector<hTrimCurve> hTCurve2dList,
|
||||
return result;
|
||||
}
|
||||
|
||||
//TODO: this needs to be exposed to Python
|
||||
DrawViewDimension* DrawDimHelper::makeDistDim(DrawViewPart* dvp,
|
||||
std::string dimType,
|
||||
Base::Vector3d inMin,
|
||||
Base::Vector3d inMax,
|
||||
Base::Vector3d inMin, //is this scaled or unscaled??
|
||||
Base::Vector3d inMax, //expects scaled from makeExtentDim
|
||||
bool extent)
|
||||
{
|
||||
// Base::Console().Message("DDH::makeDistDim() - inMin: %s inMax: %s\n",
|
||||
@@ -346,13 +345,11 @@ DrawViewDimension* DrawDimHelper::makeDistDim(DrawViewPart* dvp,
|
||||
dimName = doc->getUniqueObjectName("DimExtent");
|
||||
}
|
||||
|
||||
double scale = dvp->getScale();
|
||||
|
||||
//regular dims will have trouble with geom indexes!
|
||||
Base::Vector3d cleanMin = DrawUtil::invertY(inMin) / scale;
|
||||
Base::Vector3d cleanMin = DrawUtil::invertY(inMin);
|
||||
std::string tag1 = dvp->addCosmeticVertex(cleanMin);
|
||||
int iGV1 = dvp->add1CVToGV(tag1);
|
||||
Base::Vector3d cleanMax = DrawUtil::invertY(inMax) / scale;
|
||||
|
||||
Base::Vector3d cleanMax = DrawUtil::invertY(inMax);
|
||||
std::string tag2 = dvp->addCosmeticVertex(cleanMax);
|
||||
int iGV2 = dvp->add1CVToGV(tag2);
|
||||
|
||||
@@ -366,6 +363,7 @@ DrawViewDimension* DrawDimHelper::makeDistDim(DrawViewPart* dvp,
|
||||
objs.push_back(dvp);
|
||||
|
||||
ss.clear();
|
||||
ss.str(std::string());
|
||||
ss << "Vertex" << iGV2;
|
||||
vertexName = ss.str();
|
||||
subs.push_back(vertexName);
|
||||
|
||||
@@ -13,6 +13,11 @@
|
||||
<Author Licence="LGPL" Name="WandererFan" EMail="wandererfan@gmail.com" />
|
||||
<UserDocu>Feature for creating and manipulating Technical Drawing Dimensions</UserDocu>
|
||||
</Documentation>
|
||||
<Methode Name="getRawValue">
|
||||
<Documentation>
|
||||
<UserDocu>getRawValue() - returns Dimension value in mm.</UserDocu>
|
||||
</Documentation>
|
||||
</Methode>
|
||||
<Methode Name="getText">
|
||||
<Documentation>
|
||||
<UserDocu>getText() - returns Dimension text.</UserDocu>
|
||||
|
||||
@@ -42,6 +42,16 @@ std::string DrawViewDimensionPy::representation(void) const
|
||||
{
|
||||
return std::string("<DrawViewDimension object>");
|
||||
}
|
||||
|
||||
PyObject* DrawViewDimensionPy::getRawValue(PyObject* args)
|
||||
{
|
||||
(void) args;
|
||||
DrawViewDimension* dvd = getDrawViewDimensionPtr();
|
||||
double val = dvd->getDimValue();
|
||||
PyObject* pyVal = PyFloat_FromDouble(val);
|
||||
return pyVal;
|
||||
}
|
||||
|
||||
PyObject* DrawViewDimensionPy::getText(PyObject* args)
|
||||
{
|
||||
(void) args;
|
||||
|
||||
Reference in New Issue
Block a user