Merge branch 'master' of github.com:FreeCAD/FreeCAD into TD-DetailWork

This commit is contained in:
donovaly
2020-05-31 00:24:29 +02:00
459 changed files with 22319 additions and 11994 deletions

View File

@@ -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,

View File

@@ -37,7 +37,9 @@ using namespace TechDraw;
// returns a string which represents the object e.g. when printed in python
std::string CenterLinePy::representation(void) const
{
return "<CenterLine object>";
std::stringstream ss;
ss << "<CenterLine object> at " << std::hex << this;
return ss.str();
}
PyObject *CenterLinePy::PyMake(struct _typeobject *, PyObject *, PyObject *) // Python wrapper
@@ -108,68 +110,8 @@ PyObject* CenterLinePy::copy(PyObject *args)
return cpy;
}
//PyObject* CenterLinePy::setFormat(PyObject* args)
//{
//// Base::Console().Message("CLPI::setFormat()\n");
// PyObject* pTuple;
// int style = 1;
// double weight = 0.50;
// double red = 0.0, green = 0.0, blue = 0.0, alpha = 0.0;
// App::Color c(red, blue, green, alpha);
// bool visible = 1;
// if (!PyArg_ParseTuple(args, "O", &pTuple)) {
// return NULL;
// }
//
// TechDraw::CenterLine* cl = this->getCenterLinePtr();
// if (PyTuple_Check(pTuple)) {
// int tSize = (int) PyTuple_Size(pTuple);
// if (tSize > 3) {
// PyObject* pStyle = PyTuple_GetItem(pTuple,0);
// style = (int) PyLong_AsLong(pStyle);
// PyObject* pWeight = PyTuple_GetItem(pTuple,1);
// weight = PyFloat_AsDouble(pWeight);
// PyObject* pColor = PyTuple_GetItem(pTuple,2);
// c = DrawUtil::pyTupleToColor(pColor);
// PyObject* pVisible = PyTuple_GetItem(pTuple,3);
// visible = (bool) PyLong_AsLong(pVisible);
// cl->m_format.m_style = style;
// cl->m_format.m_weight = weight;
// cl->m_format.m_color = c;
// cl->m_format.m_visible = visible;
// }
// } else {
// Base::Console().Error("CLPI::setFormat - not a tuple!\n");
// }
//
// return Py_None;
//}
//PyObject* CenterLinePy::getFormat(PyObject *args)
//{
// (void) args;
//// Base::Console().Message("CLPI::getFormat()\n");
// TechDraw::CenterLine* cl = this->getCenterLinePtr();
// PyObject* pStyle = PyLong_FromLong((long) cl->m_format.m_style);
// PyObject* pWeight = PyFloat_FromDouble(cl->m_format.m_weight);
// PyObject* pColor = DrawUtil::colorToPyTuple(cl->m_format.m_color);
// PyObject* pVisible = PyBool_FromLong((long) cl->m_format.m_visible);
// PyObject* result = PyTuple_New(4);
// PyTuple_SET_ITEM(result, 0, pStyle);
// PyTuple_SET_ITEM(result, 1, pWeight);
// PyTuple_SET_ITEM(result, 2, pColor);
// PyTuple_SET_ITEM(result, 3, pVisible);
// return result;
//}
Py::Object CenterLinePy::getFormat(void) const
{
// Base::Console().Message("CLP::getFormat()\n");
TechDraw::CenterLine* cl = this->getCenterLinePtr();
PyObject* pStyle = PyLong_FromLong((long) cl->m_format.m_style);
@@ -189,7 +131,6 @@ Py::Object CenterLinePy::getFormat(void) const
void CenterLinePy::setFormat(Py::Object arg)
{
// Base::Console().Message("CLP::setFormat()\n");
PyObject* pTuple = arg.ptr();
int style = 1;
double weight = 0.50;
@@ -209,7 +150,6 @@ void CenterLinePy::setFormat(Py::Object arg)
c = DrawUtil::pyTupleToColor(pColor);
PyObject* pVisible = PyTuple_GetItem(pTuple,3);
visible = (bool) PyLong_AsLong(pVisible);
cl->m_format.m_style = style;
cl->m_format.m_weight = weight;
cl->m_format.m_color = c;

View File

@@ -318,11 +318,14 @@ CosmeticVertex* CosmeticVertex::clone(void) const
PyObject* CosmeticVertex::getPyObject(void)
{
// return new CosmeticVertexPy(new CosmeticVertex(this->copy())); //shouldn't this be clone?
PyObject* result = new CosmeticVertexPy(this->clone());
return result;
if (PythonObject.is(Py::_None())) {
// ref counter is set to 1
PythonObject = Py::Object(new CosmeticVertexPy(this),true);
}
return Py::new_reference_to(PythonObject);
}
void CosmeticVertex::dump(const char* title)
{
Base::Console().Message("CV::dump - %s \n",title);
@@ -403,12 +406,13 @@ void CosmeticEdge::initialize(void)
m_geometry->setCosmeticTag(getTagAsString());
}
void CosmeticEdge::unscaleEnds(double scale)
{
permaStart = permaStart / scale;
permaEnd = permaEnd / scale;
permaRadius = permaRadius / scale;
}
//why is this needed? isn't permaxxxx always unscaled??
//void CosmeticEdge::unscaleEnds(double scale)
//{
// permaStart = permaStart / scale;
// permaEnd = permaEnd / scale;
// permaRadius = permaRadius / scale;
//}
TechDraw::BaseGeom* CosmeticEdge::scaledGeometry(double scale)
{
@@ -567,9 +571,14 @@ CosmeticEdge* CosmeticEdge::clone(void) const
PyObject* CosmeticEdge::getPyObject(void)
{
return new CosmeticEdgePy(this->clone());
if (PythonObject.is(Py::_None())) {
// ref counter is set to 1
PythonObject = Py::Object(new CosmeticEdgePy(this),true);
}
return Py::new_reference_to(PythonObject);
}
//*********************************************************
TYPESYSTEM_SOURCE(TechDraw::CenterLine,Base::Persistence)
@@ -1419,9 +1428,14 @@ CenterLine *CenterLine::clone(void) const
PyObject* CenterLine::getPyObject(void)
{
return new CenterLinePy(this->clone());
if (PythonObject.is(Py::_None())) {
// ref counter is set to 1
PythonObject = Py::Object(new CenterLinePy(this),true);
}
return Py::new_reference_to(PythonObject);
}
void CenterLine::setShifts(double h, double v)
{
m_hShift = h;
@@ -1615,7 +1629,11 @@ GeomFormat* GeomFormat::copy(void) const
PyObject* GeomFormat::getPyObject(void)
{
return new GeomFormatPy(new GeomFormat(this->copy()));
if (PythonObject.is(Py::_None())) {
// ref counter is set to 1
PythonObject = Py::Object(new GeomFormatPy(this),true);
}
return Py::new_reference_to(PythonObject);
}
bool CosmeticVertex::restoreCosmetic(void)

View File

@@ -113,6 +113,9 @@ protected:
boost::uuids::uuid tag;
Py::Object PythonObject;
};
//********** CosmeticEdge ******************************************************
@@ -147,7 +150,7 @@ public:
Base::Vector3d permaStart; //persistent unscaled start/end points in View coords?
Base::Vector3d permaEnd;
double permaRadius;
void unscaleEnds(double scale);
// void unscaleEnds(double scale);
TechDraw::BaseGeom* m_geometry;
LineFormat m_format;
@@ -158,8 +161,10 @@ protected:
//Uniqueness
void createNewTag();
void assignTag(const TechDraw::CosmeticEdge* ce);
boost::uuids::uuid tag;
Py::Object PythonObject;
};
//***** CenterLine *************************************************************
@@ -269,6 +274,8 @@ protected:
boost::uuids::uuid tag;
Py::Object PythonObject;
};
//********** GeomFormat ********************************************************
@@ -310,6 +317,7 @@ protected:
void assignTag(const TechDraw::GeomFormat* gf);
boost::uuids::uuid tag;
Py::Object PythonObject;
};
} //end namespace TechDraw

View File

@@ -57,7 +57,7 @@
<!-- </Attribute> -->
<Attribute Name="Format">
<Documentation>
<UserDocu>The appearance attributes (style, color, weight, visible) for this CosmeticEdge.</UserDocu>
<UserDocu>The appearance attributes (style, weight, color, visible) for this CosmeticEdge.</UserDocu>
</Documentation>
<Parameter Name="Format" Type="Object"/>
</Attribute>

View File

@@ -45,7 +45,10 @@ using namespace TechDraw;
// returns a string which represents the object e.g. when printed in python
std::string CosmeticEdgePy::representation(void) const
{
return "<CosmeticEdge object>";
std::stringstream ss;
ss << "<CosmeticEdge object> at " << std::hex << this;
return ss.str();
// return "<CosmeticEdge object>";
}
PyObject *CosmeticEdgePy::PyMake(struct _typeobject *, PyObject *, PyObject *) // Python wrapper
@@ -119,16 +122,12 @@ PyObject* CosmeticEdgePy::copy(PyObject *args)
void CosmeticEdgePy::setFormat(Py::Object arg)
{
// Base::Console().Message("CEP::setFormat()\n");
PyObject* pTuple = arg.ptr();
int style = 1;
double weight = 0.50;
double red = 0.0, green = 0.0, blue = 0.0, alpha = 0.0;
App::Color c(red, blue, green, alpha);
bool visible = 1;
// if (!PyArg_ParseTuple(args, "O", &pTuple)) {
// return NULL;
// }
TechDraw::CosmeticEdge* ce = this->getCosmeticEdgePtr();
if (PyTuple_Check(pTuple)) {
@@ -155,7 +154,6 @@ void CosmeticEdgePy::setFormat(Py::Object arg)
Py::Object CosmeticEdgePy::getFormat(void) const
{
// Base::Console().Message("CEP::getFormat()\n");
TechDraw::CosmeticEdge* ce = this->getCosmeticEdgePtr();
PyObject* pStyle = PyLong_FromLong((long) ce->m_format.m_style);

View File

@@ -157,20 +157,9 @@ void CosmeticExtension::removeCosmeticVertex(std::vector<std::string> delTags)
bool CosmeticExtension::replaceCosmeticVertex(CosmeticVertex* newCV)
{
// Base::Console().Message("DVP::replaceCV(%s)\n", newCV->getTagAsString().c_str());
(void) newCV;
Base::Console().Message("CX::replaceCosmeticVertex() - deprecated. do not use.\n");
bool result = false;
std::vector<CosmeticVertex*> cVerts = CosmeticVertexes.getValues();
std::vector<CosmeticVertex*> newVerts;
std::string tag = newCV->getTagAsString();
for (auto& cv: cVerts) {
if (cv->getTagAsString() == tag) {
newVerts.push_back(newCV);
result = true;
} else {
newVerts.push_back(cv);
}
}
CosmeticVertexes.setValues(newVerts);
return result;
}
@@ -275,21 +264,12 @@ void CosmeticExtension::removeCosmeticEdge(std::vector<std::string> delTags)
}
}
bool CosmeticExtension::replaceCosmeticEdge(CosmeticEdge* newCE)
{
(void) newCE;
Base::Console().Message("CX::replaceCosmeticEdge() - deprecated. do not use.\n");
bool result = false;
std::vector<CosmeticEdge*> cEdges = CosmeticEdges.getValues();
std::vector<CosmeticEdge*> newEdges;
std::string tag = newCE->getTagAsString();
for (auto& ce: cEdges) {
if (ce->getTagAsString() == tag) {
newEdges.push_back(newCE);
result = true;
} else {
newEdges.push_back(ce);
}
}
CosmeticEdges.setValues(newEdges);
return result;
}
@@ -403,20 +383,9 @@ void CosmeticExtension::removeCenterLine(std::vector<std::string> delTags)
bool CosmeticExtension::replaceCenterLine(CenterLine* newCL)
{
// Base::Console().Message("DVP::replaceCL(%s)\n", newCL->getTagAsString().c_str());
(void) newCL;
Base::Console().Message("CX::replaceCenterLine() - deprecated. do not use.\n");
bool result = false;
std::vector<CenterLine*> cLines = CenterLines.getValues();
std::vector<CenterLine*> newLines;
std::string tag = newCL->getTagAsString();
for (auto& cl: cLines) {
if (cl->getTagAsString() == tag) {
newLines.push_back(newCL);
result = true;
} else {
newLines.push_back(cl);
}
}
CenterLines.setValues(newLines);
return result;
}
@@ -486,20 +455,9 @@ TechDraw::GeomFormat* CosmeticExtension::getGeomFormatBySelection(int i) const
bool CosmeticExtension::replaceGeomFormat(GeomFormat* newGF)
{
// Base::Console().Message("CEx::replaceGF(%s)\n", newGF->getTagAsString().c_str());
(void) newGF;
Base::Console().Message("CX::replaceGeomFormat() - deprecated. do not use.\n");
bool result = false;
std::vector<GeomFormat*> gFormats = GeomFormats.getValues();
std::vector<GeomFormat*> newFormats;
std::string tag = newGF->getTagAsString();
for (auto& gf: gFormats) {
if (gf->getTagAsString() == tag) {
newFormats.push_back(newGF);
result = true;
} else {
newFormats.push_back(gf);
}
}
GeomFormats.setValues(newFormats);
return result;
}

View File

@@ -43,6 +43,23 @@
</Documentation>
<Parameter Name="Show" Type="Boolean"/>
</Attribute>
<Attribute Name="Color" ReadOnly="false">
<Documentation>
<UserDocu>set/return the vertex's colour using a tuple (rgba).</UserDocu>
</Documentation>
<Parameter Name="Color" Type="Object"/>
</Attribute>
<Attribute Name="Size" ReadOnly="false">
<Documentation>
<UserDocu>set/return the vertex's radius in mm.</UserDocu>
</Documentation>
<Parameter Name="Size" Type="Object"/>
</Attribute>
<Attribute Name="Style" ReadOnly="false">
<Documentation>
<UserDocu>set/return the vertex's style as integer.</UserDocu>
</Documentation>
<Parameter Name="Style" Type="Object"/>
</Attribute>
</PythonExport>
</GenerateModel>

View File

@@ -168,6 +168,71 @@ void CosmeticVertexPy::setShow(Py::Boolean arg)
}
}
Py::Object CosmeticVertexPy::getColor(void) const
{
App::Color color = getCosmeticVertexPtr()->color;
PyObject* pyColor = DrawUtil::colorToPyTuple(color);
return Py::asObject(pyColor);
}
void CosmeticVertexPy::setColor(Py::Object arg)
{
PyObject* pTuple = arg.ptr();
double red = 0.0, green = 0.0, blue = 0.0, alpha = 0.0;
App::Color c(red, green, blue, alpha);
if (PyTuple_Check(pTuple)) {
c = DrawUtil::pyTupleToColor(pTuple);
CosmeticVertex* cv = getCosmeticVertexPtr();
cv->color = c;
} else {
Base::Console().Error("CEPI::setColor - not a tuple!\n");
std::string error = std::string("type must be 'tuple', not ");
error += pTuple->ob_type->tp_name;
throw Py::TypeError(error);
}
}
Py::Object CosmeticVertexPy::getSize(void) const
{
CosmeticVertex* cv = getCosmeticVertexPtr();
double size = cv->size;
PyObject* pSize = PyFloat_FromDouble(size);
return Py::asObject(pSize);
}
void CosmeticVertexPy::setSize(Py::Object arg)
{
double size = 1.0;
PyObject* p = arg.ptr();
if (PyFloat_Check(p)) {
size = PyFloat_AsDouble(p);
} else {
throw Py::TypeError("expected (float)");
}
CosmeticVertex* cv = getCosmeticVertexPtr();
cv->size = size;
}
Py::Object CosmeticVertexPy::getStyle(void) const
{
CosmeticVertex* cv = getCosmeticVertexPtr();
double style = cv->style;
PyObject* pStyle = PyLong_FromLong((long) style);
return Py::asObject(pStyle);
}
void CosmeticVertexPy::setStyle(Py::Object arg)
{
int style = 1;
PyObject* p = arg.ptr();
if (PyLong_Check(p)) {
style = (int) PyLong_AsLong(p);
} else {
throw Py::TypeError("expected (float)");
}
CosmeticVertex* cv = getCosmeticVertexPtr();
cv->style = style;
}
PyObject *CosmeticVertexPy::getCustomAttributes(const char* /*attr*/) const
{

View File

@@ -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);

View File

@@ -557,9 +557,7 @@ void DrawGeomHatch::onDocumentRestored()
std::string patFileName = FilePattern.getValue();
Base::FileInfo tfi(patFileName);
if (tfi.isReadable()) {
if (PatIncluded.isEmpty()) {
setupPatIncluded();
}
setupPatIncluded();
}
}
}

View File

@@ -461,10 +461,10 @@ App::DocumentObject * DrawProjGroup::addProjection(const char *viewProjType)
} else { //Front
Anchor.setValue(view);
Anchor.purgeTouched();
requestPaint(); //make sure the group object is on the Gui page
view->LockPosition.setValue(true); //lock "Front" position within DPG (note not Page!).
view->LockPosition.setStatus(App::Property::ReadOnly,true); //Front should stay locked.
view->LockPosition.purgeTouched();
requestPaint(); //make sure the group object is on the Gui page
}
// addView(view); //from DrawViewCollection
// if (view != getAnchor()) { //anchor is done elsewhere
@@ -1004,6 +1004,8 @@ void DrawProjGroup::updateChildrenLock(void)
Base::Console().Log("PROBLEM - DPG::updateChildrenLock - non DPGI entry in Views! %s\n",
getNameInDocument());
throw Base::TypeError("Error: projection in DPG list is not a DPGI!");
} else {
view->requestPaint();
}
}
}

View File

@@ -103,16 +103,10 @@ void DrawProjGroupItem::onChanged(const App::Property *prop)
bool DrawProjGroupItem::isLocked(void) const
{
bool isLocked = DrawView::isLocked();
if (isAnchor()) { //Anchor view is always locked to DPG
return true;
}
DrawProjGroup* parent = getPGroup();
if (parent != nullptr) {
isLocked = isLocked || parent->LockPosition.getValue();
}
return isLocked;
return DrawView::isLocked();
}
bool DrawProjGroupItem::showLock(void) const

View File

@@ -284,6 +284,62 @@ bool DrawUtil::fpCompare(const double& d1, const double& d2, double tolerance)
return result;
}
//brute force intersection points of line(point, dir) with box(xRange, yRange)
std::pair<Base::Vector3d, Base::Vector3d> DrawUtil::boxIntersect2d(Base::Vector3d point,
Base::Vector3d dirIn,
double xRange,
double yRange)
{
std::pair<Base::Vector3d, Base::Vector3d> result;
Base::Vector3d p1, p2;
Base::Vector3d dir = dirIn;
dir.Normalize();
// y = mx + b
// m = (y1 - y0) / (x1 - x0)
if (DrawUtil::fpCompare(dir.x, 0.0) ) {
p1 = Base::Vector3d(point.x, - yRange / 2.0, 0.0);
p2 = Base::Vector3d(point.x, yRange / 2.0, 0.0);
} else {
double slope = dir.y / dir.x;
double left = -xRange / 2.0;
double right = xRange / 2.0;
double top = yRange / 2.0;
double bottom = -yRange / 2.0;
double yLeft = point.y - slope * (point.x - left) ;
double yRight = point.y - slope * (point.x - right);
double xTop = point.x - ( (point.y - top) / slope );
double xBottom = point.x - ( (point.y - bottom) / slope );
if ( (bottom < yLeft) &&
(top > yLeft) ) {
p1 = Base::Vector3d(left, yLeft);
} else if (yLeft <= bottom) {
p1 = Base::Vector3d(xBottom, bottom);
} else if (yLeft >= top) {
p1 = Base::Vector3d(xTop, top);
}
if ( (bottom < yRight) &&
(top > yRight) ) {
p2 = Base::Vector3d(right, yRight);
} else if (yRight <= bottom) {
p2 = Base::Vector3d(xBottom, bottom);
} else if (yRight >= top) {
p2 = Base::Vector3d(xTop, top);
}
}
result.first = p1;
result.second = p2;
Base::Vector3d dirCheck = p2 - p1;
dirCheck.Normalize();
if (!dir.IsEqual(dirCheck, 0.00001)) {
result.first = p2;
result.second = p1;
}
return result;
}
Base::Vector3d DrawUtil::vertex2Vector(const TopoDS_Vertex& v)
{
gp_Pnt gp = BRep_Tool::Pnt(v);
@@ -613,7 +669,7 @@ App::Color DrawUtil::pyTupleToColor(PyObject* pColor)
{
// Base::Console().Message("DU::pyTupleToColor()\n");
double red = 0.0, green = 0.0, blue = 0.0, alpha = 0.0;
App::Color c(red, blue, green, alpha);
App::Color c(red, green, blue, alpha);
if (PyTuple_Check(pColor)) {
int tSize = (int) PyTuple_Size(pColor);
if (tSize > 2) {
@@ -628,7 +684,7 @@ App::Color DrawUtil::pyTupleToColor(PyObject* pColor)
PyObject* pAlpha = PyTuple_GetItem(pColor,3);
alpha = PyFloat_AsDouble(pAlpha);
}
c = App::Color(red, blue, green, alpha);
c = App::Color(red, green, blue, alpha);
}
return c;
}

View File

@@ -79,6 +79,10 @@ class TechDrawExport DrawUtil {
static bool isFirstVert(TopoDS_Edge e, TopoDS_Vertex v, double tolerance = VERTEXTOLERANCE);
static bool isLastVert(TopoDS_Edge e, TopoDS_Vertex v, double tolerance = VERTEXTOLERANCE);
static bool fpCompare(const double& d1, const double& d2, double tolerance = FLT_EPSILON);
static std::pair<Base::Vector3d, Base::Vector3d> boxIntersect2d(Base::Vector3d point,
Base::Vector3d dir,
double xRange,
double yRange) ;
static Base::Vector3d vertex2Vector(const TopoDS_Vertex& v);
static std::string formatVector(const Base::Vector3d& v);
static std::string formatVector(const gp_Dir& v);

View File

@@ -76,17 +76,17 @@ DrawView::DrawView(void):
mouseMove(false)
{
static const char *group = "Base";
ADD_PROPERTY_TYPE(X, (0.0), group, App::Prop_None, "X position");
ADD_PROPERTY_TYPE(Y, (0.0), group, App::Prop_None, "Y position");
ADD_PROPERTY_TYPE(LockPosition, (false), group, App::Prop_None, "Lock View position to parent Page or Group");
ADD_PROPERTY_TYPE(Rotation, (0.0), group, App::Prop_None, "Rotation in degrees counterclockwise");
ADD_PROPERTY_TYPE(X, (0.0), group, (App::PropertyType)(App::Prop_Output | App::Prop_NoRecompute), "X position");
ADD_PROPERTY_TYPE(Y, (0.0), group, (App::PropertyType)(App::Prop_Output | App::Prop_NoRecompute), "Y position");
ADD_PROPERTY_TYPE(LockPosition, (false), group, App::Prop_Output, "Lock View position to parent Page or Group");
ADD_PROPERTY_TYPE(Rotation, (0.0), group, App::Prop_Output, "Rotation in degrees counterclockwise");
ScaleType.setEnums(ScaleTypeEnums);
ADD_PROPERTY_TYPE(ScaleType, (prefScaleType()), group, App::Prop_None, "Scale Type");
ADD_PROPERTY_TYPE(Scale, (prefScale()), group, App::Prop_None, "Scale factor of the view");
ADD_PROPERTY_TYPE(ScaleType, (prefScaleType()), group, App::Prop_Output, "Scale Type");
ADD_PROPERTY_TYPE(Scale, (prefScale()), group, App::Prop_Output, "Scale factor of the view");
Scale.setConstraints(&scaleRange);
ADD_PROPERTY_TYPE(Caption, (""), group, App::Prop_None, "Short text about the view");
ADD_PROPERTY_TYPE(Caption, (""), group, App::Prop_Output, "Short text about the view");
}
DrawView::~DrawView()
@@ -95,10 +95,17 @@ DrawView::~DrawView()
App::DocumentObjectExecReturn *DrawView::execute(void)
{
// Base::Console().Message("DV::execute() - %s\n", getNameInDocument());
// Base::Console().Message("DV::execute() - %s touched: %d\n", getNameInDocument(), isTouched());
if (findParentPage() == nullptr) {
return App::DocumentObject::execute();
}
handleXYLock();
requestPaint();
return App::DocumentObject::execute();
//documentobject::execute doesn't do anything useful for us.
//documentObject::recompute causes an infinite loop.
//should not be necessary to purgeTouched here, but it prevents a superfluous feature recompute
purgeTouched(); //this should not be necessary!
return App::DocumentObject::StdReturn;
}
void DrawView::checkScale(void)
@@ -146,11 +153,15 @@ void DrawView::onChanged(const App::Property* prop)
}
} else if (prop == &LockPosition) {
handleXYLock();
requestPaint(); //change lock icon
LockPosition.purgeTouched();
}
if ((prop == &Caption) ||
} else if ((prop == &Caption) ||
(prop == &Label)) {
requestPaint();
} else if ((prop == &X) ||
(prop == &Y)) {
X.purgeTouched();
Y.purgeTouched();
}
}
App::DocumentObject::onChanged(prop);
@@ -195,11 +206,7 @@ short DrawView::mustExecute() const
short result = 0;
if (!isRestoring()) {
result = (Scale.isTouched() ||
ScaleType.isTouched() ||
Caption.isTouched() ||
X.isTouched() ||
Y.isTouched() ||
LockPosition.isTouched());
ScaleType.isTouched());
}
if ((bool) result) {
return result;

View File

@@ -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>

View File

@@ -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;

View File

@@ -248,14 +248,10 @@ std::vector<App::DocumentObject*> DrawViewPart::getAllSources(void) const
App::DocumentObjectExecReturn *DrawViewPart::execute(void)
{
// Base::Console().Message("DVP::execute() - %s\n", Label.getValue());
if (!keepUpdated()) {
return App::DocumentObject::StdReturn;
}
// Base::Console().Message("DVP::execute - Source: %d XSource: %d\n",
// Source.getValues().size(), XSource.getValues().size());
App::Document* doc = getDocument();
bool isRestoring = doc->testStatus(App::Document::Status::Restoring);
const std::vector<App::DocumentObject*>& links = getAllSources();
@@ -291,7 +287,6 @@ App::DocumentObjectExecReturn *DrawViewPart::execute(void)
XDirection.purgeTouched(); //don't trigger updates!
//unblock
}
auto start = std::chrono::high_resolution_clock::now();
m_saveShape = shape;
partExec(shape);
@@ -312,14 +307,7 @@ App::DocumentObjectExecReturn *DrawViewPart::execute(void)
}
}
auto end = std::chrono::high_resolution_clock::now();
auto diff = end - start;
double diffOut = std::chrono::duration <double, std::milli> (diff).count();
Base::Console().Log("TIMING - %s DVP spent: %.3f millisecs handling Faces\n",
getNameInDocument(),diffOut);
//#endif //#if MOD_TECHDRAW_HANDLE_FACES
// Base::Console().Message("DVP::execute - exits\n");
return DrawView::execute();
}
@@ -366,7 +354,6 @@ void DrawViewPart::partExec(TopoDS_Shape shape)
}
#if MOD_TECHDRAW_HANDLE_FACES
// auto start = std::chrono::high_resolution_clock::now();
if (handleFaces() && !geometryObject->usePolygonHLR()) {
try {
extractFaces();
@@ -463,8 +450,6 @@ TechDraw::GeometryObject* DrawViewPart::buildGeometryObject(TopoDS_Shape shape,
viewAxis);
}
auto start = std::chrono::high_resolution_clock::now();
go->extractGeometry(TechDraw::ecHARD, //always show the hard&outline visible lines
true);
go->extractGeometry(TechDraw::ecOUTLINE,
@@ -499,10 +484,6 @@ TechDraw::GeometryObject* DrawViewPart::buildGeometryObject(TopoDS_Shape shape,
go->extractGeometry(TechDraw::ecUVISO,
false);
}
auto end = std::chrono::high_resolution_clock::now();
auto diff = end - start;
double diffOut = std::chrono::duration <double, std::milli> (diff).count();
Base::Console().Log("TIMING - %s DVP spent: %.3f millisecs in GO::extractGeometry\n",getNameInDocument(),diffOut);
const std::vector<TechDraw::BaseGeom *> & edges = go->getEdgeGeometry();
if (edges.empty()) {
@@ -533,34 +514,32 @@ void DrawViewPart::extractFaces()
if (!DrawUtil::isZeroEdge(e)) {
nonZero.push_back(e);
} else {
Base::Console().Message("INFO - DVP::extractFaces for %s found ZeroEdge!\n",getNameInDocument());
Base::Console().Log("INFO - DVP::extractFaces for %s found ZeroEdge!\n",getNameInDocument());
}
}
faceEdges = nonZero;
origEdges = nonZero;
//HLR algo does not provide all edge intersections for edge endpoints.
//need to split long edges touched by Vertex of another edge
std::vector<splitPoint> splits;
std::vector<TopoDS_Edge>::iterator itOuter = origEdges.begin();
std::vector<TopoDS_Edge>::iterator itOuter = nonZero.begin();
int iOuter = 0;
for (; itOuter != origEdges.end(); ++itOuter, iOuter++) {
for (; itOuter != nonZero.end(); ++itOuter, iOuter++) { //*** itOuter != nonZero.end() - 1
TopoDS_Vertex v1 = TopExp::FirstVertex((*itOuter));
TopoDS_Vertex v2 = TopExp::LastVertex((*itOuter));
Bnd_Box sOuter;
BRepBndLib::Add(*itOuter, sOuter);
sOuter.SetGap(0.1);
if (sOuter.IsVoid()) {
Base::Console().Message("DVP::Extract Faces - outer Bnd_Box is void for %s\n",getNameInDocument());
Base::Console().Log("DVP::Extract Faces - outer Bnd_Box is void for %s\n",getNameInDocument());
continue;
}
if (DrawUtil::isZeroEdge(*itOuter)) {
Base::Console().Message("DVP::extractFaces - outerEdge: %d is ZeroEdge\n",iOuter); //this is not finding ZeroEdges
Base::Console().Log("DVP::extractFaces - outerEdge: %d is ZeroEdge\n",iOuter); //this is not finding ZeroEdges
continue; //skip zero length edges. shouldn't happen ;)
}
int iInner = 0;
std::vector<TopoDS_Edge>::iterator itInner = faceEdges.begin();
for (; itInner != faceEdges.end(); ++itInner,iInner++) {
std::vector<TopoDS_Edge>::iterator itInner = nonZero.begin(); //***sb itOuter + 1;
for (; itInner != nonZero.end(); ++itInner,iInner++) {
if (iInner == iOuter) {
continue;
}
@@ -602,10 +581,10 @@ void DrawViewPart::extractFaces()
std::vector<splitPoint> sorted = DrawProjectSplit::sortSplits(splits,true);
auto last = std::unique(sorted.begin(), sorted.end(), DrawProjectSplit::splitEqual); //duplicates to back
sorted.erase(last, sorted.end()); //remove dupl splits
std::vector<TopoDS_Edge> newEdges = DrawProjectSplit::splitEdges(faceEdges,sorted);
std::vector<TopoDS_Edge> newEdges = DrawProjectSplit::splitEdges(nonZero,sorted);
if (newEdges.empty()) {
Base::Console().Log("LOG - DVP::extractFaces - no newEdges\n");
Base::Console().Log("DVP::extractFaces - no newEdges\n");
return;
}
@@ -646,8 +625,7 @@ std::vector<TechDraw::DrawHatch*> DrawViewPart::getHatches() const
std::vector<TechDraw::DrawHatch*> result;
std::vector<App::DocumentObject*> children = getInList();
for (std::vector<App::DocumentObject*>::iterator it = children.begin(); it != children.end(); ++it) {
if ( ((*it)->getTypeId().isDerivedFrom(DrawHatch::getClassTypeId())) &&
(!(*it)->isRemoving()) ) {
if ((*it)->getTypeId().isDerivedFrom(DrawHatch::getClassTypeId())) {
TechDraw::DrawHatch* hatch = dynamic_cast<TechDraw::DrawHatch*>(*it);
result.push_back(hatch);
}
@@ -1189,6 +1167,7 @@ void DrawViewPart::resetReferenceVerts()
//********
//* Cosmetics
//********
void DrawViewPart::clearCosmeticVertexes(void)
{
std::vector<CosmeticVertex*> noVerts;
@@ -1242,15 +1221,11 @@ int DrawViewPart::getCVIndex(std::string tag)
// Base::Console().Message("DVP::getCVIndex(%s)\n", tag.c_str());
int result = -1;
std::vector<TechDraw::Vertex *> gVerts = getVertexGeometry();
Base::Console().Message("DVP::getCVIndex - gVerts: %d\n", gVerts.size());
std::vector<TechDraw::CosmeticVertex*> cVerts = CosmeticVertexes.getValues();
Base::Console().Message("DVP::getCVIndex - cVerts: %d\n", cVerts.size());
int i = 0;
bool found = false;
for (auto& gv :gVerts) {
Base::Console().Message("DVP::getCVIndex - gv cosmetic: %d ctag: %s\n",
gv->cosmetic, gv->cosmeticTag.c_str());
if (gv->cosmeticTag == tag) {
result = i;
found = true;

View File

@@ -148,6 +148,11 @@
<UserDocu>getVertexByIndex(vertexIndex). Returns Part.TopoShape.</UserDocu>
</Documentation>
</Methode>
<Methode Name="requestPaint">
<Documentation>
<UserDocu>requestPaint(). Redraw the graphic for this View.</UserDocu>
</Documentation>
</Methode>
<CustomAttributes />
</PythonExport>
</GenerateModel>

View File

@@ -105,8 +105,16 @@ PyObject* DrawViewPartPy::getHiddenEdges(PyObject *args)
return pEdgeList;
}
// remove all cosmetics
PyObject* DrawViewPartPy::requestPaint(PyObject *args)
{
(void) args;
DrawViewPart* item = getDrawViewPartPtr();
item->requestPaint();
Py_INCREF(Py_None);
return Py_None;
}
// remove all cosmetics
PyObject* DrawViewPartPy::clearCosmeticVertices(PyObject *args)
{
(void) args;
@@ -273,17 +281,21 @@ PyObject* DrawViewPartPy::removeCosmeticVertex(PyObject *args)
PyObject* DrawViewPartPy::replaceCosmeticVertex(PyObject *args)
{
PyObject* pNewCV = nullptr;
if (!PyArg_ParseTuple(args, "O!", &(TechDraw::CosmeticVertexPy::Type), &pNewCV)) {
throw Py::TypeError("expected (CosmeticVertex)");
}
DrawViewPart* dvp = getDrawViewPartPtr();
TechDraw::CosmeticVertexPy* cvPy = static_cast<TechDraw::CosmeticVertexPy*>(pNewCV);
TechDraw::CosmeticVertex* cv = cvPy->getCosmeticVertexPtr();
bool result = dvp->replaceCosmeticVertex(cv);
dvp->refreshCVGeoms();
dvp->requestPaint();
return PyBool_FromLong((long) result);
(void) args;
Base::Console().Message("DVPP::replaceCosmeticVertex() - deprecated. do not use.\n");
return PyBool_FromLong(0l);
// PyObject* pNewCV = nullptr;
// if (!PyArg_ParseTuple(args, "O!", &(TechDraw::CosmeticVertexPy::Type), &pNewCV)) {
// throw Py::TypeError("expected (CosmeticVertex)");
// }
// DrawViewPart* dvp = getDrawViewPartPtr();
// TechDraw::CosmeticVertexPy* cvPy = static_cast<TechDraw::CosmeticVertexPy*>(pNewCV);
// TechDraw::CosmeticVertex* cv = cvPy->getCosmeticVertexPtr();
// bool result = dvp->replaceCosmeticVertex(cv);
// dvp->refreshCVGeoms();
// dvp->requestPaint();
// return PyBool_FromLong((long) result);
}
@@ -456,9 +468,7 @@ PyObject* DrawViewPartPy::getCosmeticEdge(PyObject *args)
DrawViewPart* dvp = getDrawViewPartPtr();
TechDraw::CosmeticEdge* ce = dvp->getCosmeticEdge(tag);
if (ce != nullptr) {
// result = new CosmeticEdgePy(new CosmeticEdge(ce));
result = new CosmeticEdgePy(ce->clone());
// result = ce->getPyObject();
result = ce->getPyObject();
} else {
Base::Console().Error("DVPPI::getCosmeticEdge - edge %s not found\n", tag);
}
@@ -478,8 +488,7 @@ PyObject* DrawViewPartPy::getCosmeticEdgeBySelection(PyObject *args)
TechDraw::CosmeticEdge* ce = dvp->getCosmeticEdgeBySelection(name);
if (ce != nullptr) {
// result = ce->getPyObject();
result = new CosmeticEdgePy(ce->clone());
result = ce->getPyObject();
} else {
Base::Console().Error("DVPPI::getCosmeticEdgebySelection - edge for name %s not found\n", name);
}
@@ -488,18 +497,25 @@ PyObject* DrawViewPartPy::getCosmeticEdgeBySelection(PyObject *args)
PyObject* DrawViewPartPy::replaceCosmeticEdge(PyObject *args)
{
(void) args;
Base::Console().Message("DVPP::replaceCosmeticEdge() - deprecated. do not use.\n");
return PyBool_FromLong(0l);
// Base::Console().Message("DVPPI::replaceCosmeticEdge()\n");
PyObject* pNewCE;
if (!PyArg_ParseTuple(args, "O!", &(TechDraw::CosmeticEdgePy::Type), &pNewCE)) {
throw Py::TypeError("expected (CosmeticEdge)");
}
DrawViewPart* dvp = getDrawViewPartPtr();
TechDraw::CosmeticEdgePy* cePy = static_cast<TechDraw::CosmeticEdgePy*>(pNewCE);
TechDraw::CosmeticEdge* ce = cePy->getCosmeticEdgePtr();
bool result = dvp->replaceCosmeticEdge(ce);
dvp->refreshCEGeoms();
dvp->requestPaint();
return PyBool_FromLong((long) result);
// bool result = false;
// PyObject* pNewCE;
// if (!PyArg_ParseTuple(args, "O!", &(TechDraw::CosmeticEdgePy::Type), &pNewCE)) {
// throw Py::TypeError("expected (CosmeticEdge)");
// }
// DrawViewPart* dvp = getDrawViewPartPtr();
// TechDraw::CosmeticEdgePy* cePy = static_cast<TechDraw::CosmeticEdgePy*>(pNewCE);
// TechDraw::CosmeticEdge* ce = cePy->getCosmeticEdgePtr();
// if (ce != nullptr) {
// result = dvp->replaceCosmeticEdge(ce); //<<<
// dvp->refreshCEGeoms();
// dvp->requestPaint();
// }
// return PyBool_FromLong((long) result);
}
PyObject* DrawViewPartPy::removeCosmeticEdge(PyObject *args)
@@ -578,7 +594,7 @@ PyObject* DrawViewPartPy::getCenterLine(PyObject *args)
DrawViewPart* dvp = getDrawViewPartPtr();
TechDraw::CenterLine* cl = dvp->getCenterLine(tag);
if (cl != nullptr) {
result = new CenterLinePy(cl->clone());
result = cl->getPyObject();
} else {
Base::Console().Error("DVPPI::getCenterLine - centerLine %s not found\n", tag);
}
@@ -598,7 +614,7 @@ PyObject* DrawViewPartPy::getCenterLineBySelection(PyObject *args)
TechDraw::CenterLine* cl = dvp->getCenterLineBySelection(tag);
if (cl != nullptr) {
result = new CenterLinePy(cl->clone());
result = cl->getPyObject();
} else {
Base::Console().Error("DVPPI::getCenterLinebySelection - centerLine for tag %s not found\n", tag);
}
@@ -607,18 +623,22 @@ PyObject* DrawViewPartPy::getCenterLineBySelection(PyObject *args)
PyObject* DrawViewPartPy::replaceCenterLine(PyObject *args)
{
(void) args;
Base::Console().Message("DVPP::replaceCenterLine() - deprecated. do not use.\n");
return PyBool_FromLong(0l);
// Base::Console().Message("DVPPI::replace CenterLine()\n");
PyObject* pNewCL;
if (!PyArg_ParseTuple(args, "O!", &(TechDraw::CenterLinePy::Type), &pNewCL)) {
throw Py::TypeError("expected (CenterLine)");
}
DrawViewPart* dvp = getDrawViewPartPtr();
TechDraw::CenterLinePy* clPy = static_cast<TechDraw::CenterLinePy*>(pNewCL);
TechDraw::CenterLine* cl = clPy->getCenterLinePtr();
bool result = dvp->replaceCenterLine(cl);
dvp->refreshCLGeoms();
dvp->requestPaint();
return PyBool_FromLong((long) result);
// PyObject* pNewCL;
// if (!PyArg_ParseTuple(args, "O!", &(TechDraw::CenterLinePy::Type), &pNewCL)) {
// throw Py::TypeError("expected (CenterLine)");
// }
// DrawViewPart* dvp = getDrawViewPartPtr();
// TechDraw::CenterLinePy* clPy = static_cast<TechDraw::CenterLinePy*>(pNewCL);
// TechDraw::CenterLine* cl = clPy->getCenterLinePtr();
// bool result = dvp->replaceCenterLine(cl);
// dvp->refreshCLGeoms();
// dvp->requestPaint();
// return PyBool_FromLong((long) result);
}
PyObject* DrawViewPartPy::removeCenterLine(PyObject *args)

View File

@@ -230,13 +230,12 @@ void DrawViewSection::onChanged(const App::Property* prop)
void DrawViewSection::makeLineSets(void)
{
// Base::Console().Message("DVS::makeLineSets()\n");
if (!FileGeomPattern.isEmpty()) {
std::string fileSpec = FileGeomPattern.getValue();
if (!PatIncluded.isEmpty()) {
std::string fileSpec = PatIncluded.getValue();
Base::FileInfo fi(fileSpec);
std::string ext = fi.extension();
if (!fi.isReadable()) {
Base::Console().Message("%s can not read hatch file: %s\n", getNameInDocument(), fileSpec.c_str());
Base::Console().Message("%s using included hatch file.\n", getNameInDocument());
} else {
if ( (ext == "pat") ||
(ext == "PAT") ) {
@@ -678,6 +677,36 @@ TopoDS_Face DrawViewSection::projectFace(const TopoDS_Shape &face,
return projectedFace;
}
//calculate the ends of the section line in BaseView's coords
std::pair<Base::Vector3d, Base::Vector3d> DrawViewSection::sectionLineEnds(void)
{
std::pair<Base::Vector3d, Base::Vector3d> result;
auto sNorm = SectionNormal.getValue();
double angle = M_PI / 2.0;
auto axis = getBaseDVP()->Direction.getValue();
Base::Vector3d stdOrg(0.0, 0.0, 0.0);
Base::Vector3d sLineDir = DrawUtil::vecRotate(sNorm, angle, axis, stdOrg);
sLineDir.Normalize();
Base::Vector3d sLineDir2 = - axis.Cross(sNorm);
sLineDir2.Normalize();
Base::Vector3d sLineOnBase = getBaseDVP()->projectPoint(sLineDir2);
sLineOnBase.Normalize();
auto sOrigin = SectionOrigin.getValue();
Base::Vector3d adjSectionOrg = sOrigin - getBaseDVP()->getOriginalCentroid();
Base::Vector3d sOrgOnBase = getBaseDVP()->projectPoint(adjSectionOrg);
auto bbx = getBaseDVP()->getBoundingBox();
double xRange = bbx.MaxX - bbx.MinX;
xRange /= getBaseDVP()->getScale();
double yRange = bbx.MaxY - bbx.MinY;
yRange /= getBaseDVP()->getScale();
result = DrawUtil::boxIntersect2d(sOrgOnBase, sLineOnBase, xRange, yRange); //unscaled
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
@@ -842,6 +871,7 @@ gp_Ax2 DrawViewSection::rotateCSArbitrary(gp_Ax2 oldCS,
std::vector<LineSet> DrawViewSection::getDrawableLines(int i)
{
// Base::Console().Message("DVS::getDrawableLines(%d) - lineSets: %d\n", i, m_lineSets.size());
std::vector<LineSet> result;
result = DrawGeomHatch::getTrimmedLines(this,m_lineSets,i,HatchScale.getValue());
return result;
@@ -919,26 +949,27 @@ int DrawViewSection::prefCutSurface(void) const
void DrawViewSection::onDocumentRestored()
{
// Base::Console().Message("DVS::onDocumentRestored()\n");
if (!FileHatchPattern.isEmpty()) {
std::string svgFileName = FileHatchPattern.getValue();
Base::FileInfo tfi(svgFileName);
if (tfi.isReadable()) {
if (SvgIncluded.isEmpty()) {
if (SvgIncluded.isEmpty()) {
if (!FileHatchPattern.isEmpty()) {
std::string svgFileName = FileHatchPattern.getValue();
Base::FileInfo tfi(svgFileName);
if (tfi.isReadable()) {
setupSvgIncluded();
}
}
}
if (!FileGeomPattern.isEmpty()) {
std::string patFileName = FileGeomPattern.getValue();
Base::FileInfo tfi(patFileName);
if (tfi.isReadable()) {
if (PatIncluded.isEmpty()) {
setupPatIncluded();
if (PatIncluded.isEmpty()) {
if (!FileGeomPattern.isEmpty()) {
std::string patFileName = FileGeomPattern.getValue();
Base::FileInfo tfi(patFileName);
if (tfi.isReadable()) {
setupPatIncluded();
}
makeLineSets();
}
}
makeLineSets();
DrawViewPart::onDocumentRestored();
}

View File

@@ -119,6 +119,8 @@ public:
static const char* SectionDirEnums[];
static const char* CutSurfaceEnums[];
std::pair<Base::Vector3d, Base::Vector3d> sectionLineEnds(void);
protected:
TopoDS_Compound sectionFaces;
std::vector<TopoDS_Wire> sectionFaceWires;

View File

@@ -636,7 +636,7 @@ int GeometryObject::addCosmeticVertex(Base::Vector3d pos, std::string tagString)
// insertGeomForCE(ce)
int GeometryObject::addCosmeticEdge(CosmeticEdge* ce)
{
Base::Console().Message("GO::addCosmeticEdge(%X)\n", ce);
// Base::Console().Message("GO::addCosmeticEdge(%X) 0\n", ce);
double scale = m_parent->getScale();
TechDraw::BaseGeom* e = ce->scaledGeometry(scale);
e->cosmetic = true;
@@ -652,7 +652,7 @@ int GeometryObject::addCosmeticEdge(CosmeticEdge* ce)
int GeometryObject::addCosmeticEdge(Base::Vector3d start,
Base::Vector3d end)
{
Base::Console().Message("GO::addCosmeticEdge() 1 - deprec?\n");
// Base::Console().Message("GO::addCosmeticEdge() 1 - deprec?\n");
gp_Pnt gp1(start.x, start.y, start.z);
gp_Pnt gp2(end.x, end.y, end.z);
TopoDS_Edge occEdge = BRepBuilderAPI_MakeEdge(gp1, gp2);
@@ -670,7 +670,7 @@ int GeometryObject::addCosmeticEdge(Base::Vector3d start,
Base::Vector3d end,
std::string tagString)
{
Base::Console().Message("GO::addCosmeticEdge() 2\n");
// Base::Console().Message("GO::addCosmeticEdge() 2\n");
gp_Pnt gp1(start.x, start.y, start.z);
gp_Pnt gp2(end.x, end.y, end.z);
TopoDS_Edge occEdge = BRepBuilderAPI_MakeEdge(gp1, gp2);
@@ -687,6 +687,7 @@ int GeometryObject::addCosmeticEdge(Base::Vector3d start,
int GeometryObject::addCosmeticEdge(TechDraw::BaseGeom* base,
std::string tagString)
{
// Base::Console().Message("GO::addCosmeticEdge(%X, %s) 3\n", base, tagString.c_str());
base->cosmetic = true;
base->hlrVisible = true;
base->source(1); //1-CosmeticEdge, 2-CenterLine

View File

@@ -63,14 +63,12 @@ PropertyCenterLineList::PropertyCenterLineList()
PropertyCenterLineList::~PropertyCenterLineList()
{
for (std::vector<CenterLine*>::iterator it = _lValueList.begin(); it != _lValueList.end(); ++it)
if (*it) delete *it;
}
void PropertyCenterLineList::setSize(int newSize)
{
for (unsigned int i = newSize; i < _lValueList.size(); i++)
delete _lValueList[i];
// for (unsigned int i = newSize; i < _lValueList.size(); i++)
// delete _lValueList[i];
_lValueList.resize(newSize);
}
@@ -79,15 +77,12 @@ int PropertyCenterLineList::getSize(void) const
return static_cast<int>(_lValueList.size());
}
void PropertyCenterLineList::setValue(const CenterLine* lValue)
void PropertyCenterLineList::setValue(CenterLine* lValue)
{
if (lValue) {
aboutToSetValue();
CenterLine* newVal = lValue->clone();
for (unsigned int i = 0; i < _lValueList.size(); i++)
delete _lValueList[i];
_lValueList.resize(1);
_lValueList[0] = newVal;
_lValueList[0] = lValue;
hasSetValue();
}
}
@@ -95,13 +90,9 @@ void PropertyCenterLineList::setValue(const CenterLine* lValue)
void PropertyCenterLineList::setValues(const std::vector<CenterLine*>& lValue)
{
aboutToSetValue();
std::vector<CenterLine*> oldVals(_lValueList);
_lValueList.resize(lValue.size());
// copy all objects
for (unsigned int i = 0; i < lValue.size(); i++)
_lValueList[i] = lValue[i]->clone();
for (unsigned int i = 0; i < oldVals.size(); i++)
delete oldVals[i];
_lValueList[i] = lValue[i];
hasSetValue();
}
@@ -115,9 +106,6 @@ PyObject *PropertyCenterLineList::getPyObject(void)
void PropertyCenterLineList::setPyObject(PyObject *value)
{
// check container of this property to notify about changes
// Part2DObject* part2d = dynamic_cast<Part2DObject*>(this->getContainer());
if (PySequence_Check(value)) {
Py_ssize_t nSize = PySequence_Size(value);
std::vector<CenterLine*> values;
@@ -135,8 +123,6 @@ void PropertyCenterLineList::setPyObject(PyObject *value)
}
setValues(values);
// if (part2d)
// part2d->acceptCenterLine();
}
else if (PyObject_TypeCheck(value, &(CenterLinePy::Type))) {
CenterLinePy *pcObject = static_cast<CenterLinePy*>(value);
@@ -153,7 +139,7 @@ void PropertyCenterLineList::Save(Writer &writer) const
{
writer.Stream() << writer.ind() << "<CenterLineList count=\"" << getSize() <<"\">" << endl;
writer.incInd();
for (int i = 0; i < getSize(); i++) {
for (int i = 0; i < getSize(); i++) {
writer.Stream() << writer.ind() << "<CenterLine type=\""
<< _lValueList[i]->getTypeId().getName() << "\">" << endl;
writer.incInd();

View File

@@ -47,16 +47,7 @@ class TechDrawExport PropertyCenterLineList: public App::PropertyLists
TYPESYSTEM_HEADER();
public:
/**
* A constructor.
* A more elaborate description of the constructor.
*/
PropertyCenterLineList();
/**
* A destructor.
* A more elaborate description of the destructor.
*/
virtual ~PropertyCenterLineList();
virtual void setSize(int newSize);
@@ -64,7 +55,7 @@ public:
/** Sets the property
*/
void setValue(const CenterLine*);
void setValue(CenterLine*);
void setValues(const std::vector<CenterLine*>&);
/// index operator

View File

@@ -63,14 +63,12 @@ PropertyCosmeticEdgeList::PropertyCosmeticEdgeList()
PropertyCosmeticEdgeList::~PropertyCosmeticEdgeList()
{
for (std::vector<CosmeticEdge*>::iterator it = _lValueList.begin(); it != _lValueList.end(); ++it)
if (*it) delete *it;
}
void PropertyCosmeticEdgeList::setSize(int newSize)
{
for (unsigned int i = newSize; i < _lValueList.size(); i++)
delete _lValueList[i];
// for (unsigned int i = newSize; i < _lValueList.size(); i++)
// delete _lValueList[i];
_lValueList.resize(newSize);
}
@@ -79,15 +77,14 @@ int PropertyCosmeticEdgeList::getSize(void) const
return static_cast<int>(_lValueList.size());
}
void PropertyCosmeticEdgeList::setValue(const CosmeticEdge* lValue)
//_lValueList is not const. so why do we pass a const paramter?
void PropertyCosmeticEdgeList::setValue(CosmeticEdge* lValue)
{
if (lValue) {
aboutToSetValue();
CosmeticEdge* newVal = lValue->clone();
for (unsigned int i = 0; i < _lValueList.size(); i++)
delete _lValueList[i];
_lValueList.resize(1);
_lValueList[0] = newVal;
_lValueList[0] = lValue;
hasSetValue();
}
}
@@ -95,13 +92,9 @@ void PropertyCosmeticEdgeList::setValue(const CosmeticEdge* lValue)
void PropertyCosmeticEdgeList::setValues(const std::vector<CosmeticEdge*>& lValue)
{
aboutToSetValue();
std::vector<CosmeticEdge*> oldVals(_lValueList);
_lValueList.resize(lValue.size());
// copy all objects
for (unsigned int i = 0; i < lValue.size(); i++)
_lValueList[i] = lValue[i]->clone();
for (unsigned int i = 0; i < oldVals.size(); i++)
delete oldVals[i];
_lValueList[i] = lValue[i];
hasSetValue();
}
@@ -115,8 +108,6 @@ PyObject *PropertyCosmeticEdgeList::getPyObject(void)
void PropertyCosmeticEdgeList::setPyObject(PyObject *value)
{
// check container of this property to notify about changes
if (PySequence_Check(value)) {
Py_ssize_t nSize = PySequence_Size(value);
std::vector<CosmeticEdge*> values;

View File

@@ -64,7 +64,8 @@ public:
/** Sets the property
*/
void setValue(const CosmeticEdge*);
/* void setValue(const CosmeticEdge*);*/
void setValue(CosmeticEdge*);
void setValues(const std::vector<CosmeticEdge*>&);
/// index operator

View File

@@ -63,8 +63,6 @@ PropertyCosmeticVertexList::PropertyCosmeticVertexList()
PropertyCosmeticVertexList::~PropertyCosmeticVertexList()
{
for (std::vector<CosmeticVertex*>::iterator it = _lValueList.begin(); it != _lValueList.end(); ++it)
if (*it) delete *it;
}
void PropertyCosmeticVertexList::setSize(int newSize)
@@ -79,15 +77,12 @@ int PropertyCosmeticVertexList::getSize(void) const
return static_cast<int>(_lValueList.size());
}
void PropertyCosmeticVertexList::setValue(const CosmeticVertex* lValue)
void PropertyCosmeticVertexList::setValue(CosmeticVertex* lValue)
{
if (lValue) {
aboutToSetValue();
CosmeticVertex* newVal = lValue->clone();
for (unsigned int i = 0; i < _lValueList.size(); i++)
delete _lValueList[i];
_lValueList.resize(1);
_lValueList[0] = newVal;
_lValueList[0] = lValue;
hasSetValue();
}
}
@@ -95,13 +90,9 @@ void PropertyCosmeticVertexList::setValue(const CosmeticVertex* lValue)
void PropertyCosmeticVertexList::setValues(const std::vector<CosmeticVertex*>& lValue)
{
aboutToSetValue();
std::vector<CosmeticVertex*> oldVals(_lValueList);
_lValueList.resize(lValue.size());
// copy all objects
for (unsigned int i = 0; i < lValue.size(); i++)
_lValueList[i] = lValue[i]->clone();
for (unsigned int i = 0; i < oldVals.size(); i++)
delete oldVals[i];
_lValueList[i] = lValue[i];
hasSetValue();
}
@@ -134,8 +125,6 @@ void PropertyCosmeticVertexList::setPyObject(PyObject *value)
}
setValues(values);
// if (part2d)
// part2d->acceptCosmeticVertex();
}
else if (PyObject_TypeCheck(value, &(CosmeticVertexPy::Type))) {
CosmeticVertexPy *pcObject = static_cast<CosmeticVertexPy*>(value);

View File

@@ -64,7 +64,7 @@ public:
/** Sets the property
*/
void setValue(const CosmeticVertex*);
void setValue(CosmeticVertex*);
void setValues(const std::vector<CosmeticVertex*>&);
/// index operator