[TD]CI clang warnings

This commit is contained in:
wandererfan
2022-08-23 15:32:13 -04:00
committed by WandererFan
parent c075a298ae
commit aa2b1b8392
246 changed files with 3944 additions and 4241 deletions

View File

@@ -133,59 +133,59 @@ class Module : public Py::ExtensionModule<Module>
public:
Module() : Py::ExtensionModule<Module>("TechDraw")
{
add_varargs_method("edgeWalker",&Module::edgeWalker,
"[wires] = edgeWalker(edgePile,inclBiggest) -- Planar graph traversal finds wires in edge pile."
add_varargs_method("edgeWalker", &Module::edgeWalker,
"[wires] = edgeWalker(edgePile, inclBiggest) -- Planar graph traversal finds wires in edge pile."
);
add_varargs_method("findOuterWire",&Module::findOuterWire,
add_varargs_method("findOuterWire", &Module::findOuterWire,
"wire = findOuterWire(edgeList) -- Planar graph traversal finds OuterWire in edge pile."
);
add_varargs_method("findShapeOutline",&Module::findShapeOutline,
"wire = findShapeOutline(shape,scale,direction) -- Project shape in direction and find outer wire of result."
add_varargs_method("findShapeOutline", &Module::findShapeOutline,
"wire = findShapeOutline(shape, scale, direction) -- Project shape in direction and find outer wire of result."
);
add_varargs_method("viewPartAsDxf",&Module::viewPartAsDxf,
add_varargs_method("viewPartAsDxf", &Module::viewPartAsDxf,
"string = viewPartAsDxf(DrawViewPart) -- Return the edges of a DrawViewPart in Dxf format."
);
add_varargs_method("viewPartAsSvg",&Module::viewPartAsSvg,
add_varargs_method("viewPartAsSvg", &Module::viewPartAsSvg,
"string = viewPartAsSvg(DrawViewPart) -- Return the edges of a DrawViewPart in Svg format."
);
add_varargs_method("writeDXFView",&Module::writeDXFView,
"writeDXFView(view,filename): Exports a DrawViewPart to a DXF file."
add_varargs_method("writeDXFView", &Module::writeDXFView,
"writeDXFView(view, filename): Exports a DrawViewPart to a DXF file."
);
add_varargs_method("writeDXFPage",&Module::writeDXFPage,
"writeDXFPage(page,filename): Exports a DrawPage to a DXF file."
add_varargs_method("writeDXFPage", &Module::writeDXFPage,
"writeDXFPage(page, filename): Exports a DrawPage to a DXF file."
);
add_varargs_method("findCentroid",&Module::findCentroid,
"vector = findCentroid(shape,direction): finds geometric centroid of shape looking in direction."
add_varargs_method("findCentroid", &Module::findCentroid,
"vector = findCentroid(shape, direction): finds geometric centroid of shape looking in direction."
);
add_varargs_method("makeExtentDim",&Module::makeExtentDim,
add_varargs_method("makeExtentDim", &Module::makeExtentDim,
"makeExtentDim(DrawViewPart, [edges], direction) -- draw horizontal or vertical extent dimension for edges (or all of DrawViewPart if edge list is empty. direction: 0 - Horizontal, 1 - Vertical."
);
add_varargs_method("makeDistanceDim",&Module::makeDistanceDim,
add_varargs_method("makeDistanceDim", &Module::makeDistanceDim,
"makeDistanceDim(DrawViewPart, dimType, fromPoint, toPoint) -- draw a Length dimension between fromPoint to toPoint. FromPoint and toPoint are unscaled 2d View points. dimType is one of ['Distance', 'DistanceX', 'DistanceY'."
);
add_varargs_method("makeDistanceDim3d",&Module::makeDistanceDim3d,
add_varargs_method("makeDistanceDim3d", &Module::makeDistanceDim3d,
"makeDistanceDim(DrawViewPart, dimType, 3dFromPoint, 3dToPoint) -- draw a Length dimension between fromPoint to toPoint. FromPoint and toPoint are unscaled 3d model points. dimType is one of ['Distance', 'DistanceX', 'DistanceY'."
);
add_varargs_method("makeGeomHatch",&Module::makeGeomHatch,
add_varargs_method("makeGeomHatch", &Module::makeGeomHatch,
"makeGeomHatch(face, [patScale], [patName], [patFile]) -- draw a geom hatch on a given face, using optionally the given scale (default 1) and a given pattern name (ex. Diamond) and .pat file (the default pattern name and/or .pat files set in preferences are used if none are given). Returns a Part compound shape."
);
add_varargs_method("project",&Module::project,
"[visiblyG0,visiblyG1,hiddenG0,hiddenG1] = project(TopoShape[,App.Vector Direction, string type])\n"
add_varargs_method("project", &Module::project,
"[visiblyG0, visiblyG1, hiddenG0, hiddenG1] = project(TopoShape[, App.Vector Direction, string type])\n"
" -- Project a shape and return the visible/invisible parts of it."
);
add_varargs_method("projectEx",&Module::projectEx,
"[V,V1,VN,VO,VI,H,H1,HN,HO,HI] = projectEx(TopoShape[,App.Vector Direction, string type])\n"
add_varargs_method("projectEx", &Module::projectEx,
"[V, V1, VN, VO, VI, H,H1, HN, HO, HI] = projectEx(TopoShape[, App.Vector Direction, string type])\n"
" -- Project a shape and return the all parts of it."
);
add_keyword_method("projectToSVG",&Module::projectToSVG,
add_keyword_method("projectToSVG", &Module::projectToSVG,
"string = projectToSVG(TopoShape[, App.Vector direction, string type, float tolerance, dict vStyle, dict v0Style, dict v1Style, dict hStyle, dict h0Style, dict h1Style])\n"
" -- Project a shape and return the SVG representation as string."
);
add_varargs_method("projectToDXF",&Module::projectToDXF,
"string = projectToDXF(TopoShape[,App.Vector Direction, string type])\n"
add_varargs_method("projectToDXF", &Module::projectToDXF,
"string = projectToDXF(TopoShape[, App.Vector Direction, string type])\n"
" -- Project a shape and return the DXF representation as string."
);
add_varargs_method("removeSvgTags",&Module::removeSvgTags,
add_varargs_method("removeSvgTags", &Module::removeSvgTags,
"string = removeSvgTags(string) -- Removes the opening and closing svg tags\n"
"and other metatags from a svg code, making it embeddable"
);
@@ -229,10 +229,10 @@ private:
Py::Object edgeWalker(const Py::Tuple& args)
{
PyObject *pcObj;
PyObject *pcObj = nullptr;
PyObject *inclBig = Py_True;
if (!PyArg_ParseTuple(args.ptr(), "O!|O", &(PyList_Type), &pcObj, &inclBig)) {
throw Py::TypeError("expected (listofedges,boolean");
throw Py::TypeError("expected (listofedges, boolean");
}
std::vector<TopoDS_Edge> edgeList;
@@ -240,10 +240,10 @@ private:
Py::Sequence list(pcObj);
for (Py::Sequence::iterator it = list.begin(); it != list.end(); ++it) {
if (PyObject_TypeCheck((*it).ptr(), &(Part::TopoShapeEdgePy::Type))) {
const TopoDS_Shape& sh = static_cast<TopoShapePy*>((*it).ptr())->
const TopoDS_Shape& shape = static_cast<TopoShapePy*>((*it).ptr())->
getTopoShapePtr()->getShape();
const TopoDS_Edge e = TopoDS::Edge(sh);
edgeList.push_back(e);
const TopoDS_Edge edge = TopoDS::Edge(shape);
edgeList.push_back(edge);
}
}
}
@@ -257,22 +257,20 @@ private:
return Py::None();
}
bool biggie;
bool biggie = false;
if (inclBig == Py_True) {
biggie = true;
} else {
biggie = false;
}
Py::List result;
try {
EdgeWalker ew;
ew.loadEdges(edgeList);
bool success = ew.perform();
EdgeWalker eWalker;
eWalker.loadEdges(edgeList);
bool success = eWalker.perform();
if (success) {
std::vector<TopoDS_Wire> rw = ew.getResultNoDups();
std::vector<TopoDS_Wire> sortedWires = ew.sortStrip(rw,biggie); //false==>do not include biggest wires
std::vector<TopoDS_Wire> rWires = eWalker.getResultNoDups();
std::vector<TopoDS_Wire> sortedWires = eWalker.sortStrip(rWires, biggie); //false==>do not include biggest wires
for (auto& w:sortedWires) {
PyObject* wire = new TopoShapeWirePy(new TopoShape(w));
result.append(Py::asObject(wire));
@@ -291,7 +289,7 @@ private:
Py::Object findOuterWire(const Py::Tuple& args)
{
PyObject *pcObj;
PyObject *pcObj = nullptr;
if (!PyArg_ParseTuple(args.ptr(), "O!", &(PyList_Type), &pcObj)) {
throw Py::TypeError("expected (listofedges)");
}
@@ -302,10 +300,10 @@ private:
Py::Sequence list(pcObj);
for (Py::Sequence::iterator it = list.begin(); it != list.end(); ++it) {
if (PyObject_TypeCheck((*it).ptr(), &(Part::TopoShapeEdgePy::Type))) {
const TopoDS_Shape& sh = static_cast<TopoShapePy*>((*it).ptr())->
const TopoDS_Shape& shape = static_cast<TopoShapePy*>((*it).ptr())->
getTopoShapePtr()->getShape();
const TopoDS_Edge e = TopoDS::Edge(sh);
edgeList.push_back(e);
const TopoDS_Edge edge = TopoDS::Edge(shape);
edgeList.push_back(edge);
}
}
}
@@ -322,12 +320,12 @@ private:
PyObject* outerWire = nullptr;
bool success = false;
try {
EdgeWalker ew;
ew.loadEdges(edgeList);
success = ew.perform();
EdgeWalker eWalker;
eWalker.loadEdges(edgeList);
success = eWalker.perform();
if (success) {
std::vector<TopoDS_Wire> rw = ew.getResultNoDups();
std::vector<TopoDS_Wire> sortedWires = ew.sortStrip(rw,true);
std::vector<TopoDS_Wire> rWires = eWalker.getResultNoDups();
std::vector<TopoDS_Wire> sortedWires = eWalker.sortStrip(rWires, true);
outerWire = new TopoShapeWirePy(new TopoShape(*sortedWires.begin()));
} else {
Base::Console().Warning("findOuterWire: input is not planar graph. Wire detection not done\n");
@@ -345,13 +343,13 @@ private:
Py::Object findShapeOutline(const Py::Tuple& args)
{
PyObject *pcObjShape;
double scale;
PyObject *pcObjDir;
PyObject *pcObjShape(nullptr);
double scale(1.0);
PyObject *pcObjDir(nullptr);
if (!PyArg_ParseTuple(args.ptr(), "OdO", &pcObjShape,
&scale,
&pcObjDir)) {
throw Py::TypeError("expected (shape,scale,direction");
throw Py::TypeError("expected (shape, scale, direction");
}
if (!PyObject_TypeCheck(pcObjShape, &(TopoShapePy::Type))) {
@@ -372,7 +370,7 @@ private:
Base::Vector3d dir = static_cast<Base::VectorPy*>(pcObjDir)->value();
std::vector<TopoDS_Edge> edgeList;
try {
edgeList = DrawProjectSplit::getEdgesForWalker(shape,scale,dir);
edgeList = DrawProjectSplit::getEdgesForWalker(shape, scale, dir);
}
catch (Standard_Failure& e) {
@@ -387,11 +385,11 @@ private:
PyObject* outerWire = nullptr;
bool success = false;
try {
EdgeWalker ew;
ew.loadEdges(edgeList);
if(ew.perform()) {
std::vector<TopoDS_Wire> rw = ew.getResultNoDups();
std::vector<TopoDS_Wire> sortedWires = ew.sortStrip(rw,true);
EdgeWalker eWalker;
eWalker.loadEdges(edgeList);
if(eWalker.perform()) {
std::vector<TopoDS_Wire> rWires = eWalker.getResultNoDups();
std::vector<TopoDS_Wire> sortedWires = eWalker.sortStrip(rWires, true);
if(!sortedWires.empty()) {
outerWire = new TopoShapeWirePy(new TopoShape(*sortedWires.begin()));
success = true;
@@ -412,7 +410,7 @@ private:
Py::Object viewPartAsDxf(const Py::Tuple& args)
{
PyObject *viewObj;
PyObject *viewObj(nullptr);
if (!PyArg_ParseTuple(args.ptr(), "O", &viewObj)) {
throw Py::TypeError("expected (DrawViewPart)");
}
@@ -427,32 +425,32 @@ private:
if (PyObject_TypeCheck(viewObj, &(TechDraw::DrawViewPartPy::Type))) {
obj = static_cast<App::DocumentObjectPy*>(viewObj)->getDocumentObjectPtr();
dvp = static_cast<TechDraw::DrawViewPart*>(obj);
TechDraw::GeometryObject* go = dvp->getGeometryObject();
TopoDS_Shape s = TechDraw::mirrorShape(go->getVisHard());
ss << dxfOut.exportEdges(s);
s = TechDraw::mirrorShape(go->getVisOutline());
ss << dxfOut.exportEdges(s);
TechDraw::GeometryObject* gObj = dvp->getGeometryObject();
TopoDS_Shape shape = TechDraw::mirrorShape(gObj->getVisHard());
ss << dxfOut.exportEdges(shape);
shape = TechDraw::mirrorShape(gObj->getVisOutline());
ss << dxfOut.exportEdges(shape);
if (dvp->SmoothVisible.getValue()) {
s = TechDraw::mirrorShape(go->getVisSmooth());
ss << dxfOut.exportEdges(s);
shape = TechDraw::mirrorShape(gObj->getVisSmooth());
ss << dxfOut.exportEdges(shape);
}
if (dvp->SeamVisible.getValue()) {
s = TechDraw::mirrorShape(go->getVisSeam());
ss << dxfOut.exportEdges(s);
shape = TechDraw::mirrorShape(gObj->getVisSeam());
ss << dxfOut.exportEdges(shape);
}
if (dvp->HardHidden.getValue()) {
s = TechDraw::mirrorShape(go->getHidHard());
ss << dxfOut.exportEdges(s);
s = TechDraw::mirrorShape(go->getHidOutline());
ss << dxfOut.exportEdges(s);
shape = TechDraw::mirrorShape(gObj->getHidHard());
ss << dxfOut.exportEdges(shape);
shape = TechDraw::mirrorShape(gObj->getHidOutline());
ss << dxfOut.exportEdges(shape);
}
if (dvp->SmoothHidden.getValue()) {
s = TechDraw::mirrorShape(go->getHidSmooth());
ss << dxfOut.exportEdges(s);
shape = TechDraw::mirrorShape(gObj->getHidSmooth());
ss << dxfOut.exportEdges(shape);
}
if (dvp->SeamHidden.getValue()) {
s = TechDraw::mirrorShape(go->getHidSeam());
ss << dxfOut.exportEdges(s);
shape = TechDraw::mirrorShape(gObj->getHidSeam());
ss << dxfOut.exportEdges(shape);
}
// ss now contains all edges as Dxf
dxfReturn = Py::String(ss.str());
@@ -468,7 +466,7 @@ private:
Py::Object viewPartAsSvg(const Py::Tuple& args)
{
PyObject *viewObj;
PyObject *viewObj(nullptr);
if (!PyArg_ParseTuple(args.ptr(), "O", &viewObj)) {
throw Py::TypeError("expected (DrawViewPart)");
}
@@ -485,24 +483,24 @@ private:
if (PyObject_TypeCheck(viewObj, &(TechDraw::DrawViewPartPy::Type))) {
obj = static_cast<App::DocumentObjectPy*>(viewObj)->getDocumentObjectPtr();
dvp = static_cast<TechDraw::DrawViewPart*>(obj);
TechDraw::GeometryObject* go = dvp->getGeometryObject();
TechDraw::GeometryObject* gObj = dvp->getGeometryObject();
//visible group begin "<g ... >"
ss << grpHead1;
// double thick = dvp->LineWidth.getValue();
double thick = DrawUtil::getDefaultLineWeight("Thick");
ss << thick;
ss << grpHead2;
TopoDS_Shape s = go->getVisHard();
ss << svgOut.exportEdges(s);
s = (go->getVisOutline());
ss << svgOut.exportEdges(s);
TopoDS_Shape shape = gObj->getVisHard();
ss << svgOut.exportEdges(shape);
shape = gObj->getVisOutline();
ss << svgOut.exportEdges(shape);
if (dvp->SmoothVisible.getValue()) {
s = go->getVisSmooth();
ss << svgOut.exportEdges(s);
shape = gObj->getVisSmooth();
ss << svgOut.exportEdges(shape);
}
if (dvp->SeamVisible.getValue()) {
s = go->getVisSeam();
ss << svgOut.exportEdges(s);
shape = gObj->getVisSeam();
ss << svgOut.exportEdges(shape);
}
//visible group end "</g>"
ss << grpTail;
@@ -517,18 +515,18 @@ private:
ss << thick;
ss << grpHead2;
if (dvp->HardHidden.getValue()) {
s = go->getHidHard();
ss << svgOut.exportEdges(s);
s = go->getHidOutline();
ss << svgOut.exportEdges(s);
shape = gObj->getHidHard();
ss << svgOut.exportEdges(shape);
shape = gObj->getHidOutline();
ss << svgOut.exportEdges(shape);
}
if (dvp->SmoothHidden.getValue()) {
s = go->getHidSmooth();
ss << svgOut.exportEdges(s);
shape = gObj->getHidSmooth();
ss << svgOut.exportEdges(shape);
}
if (dvp->SeamHidden.getValue()) {
s = go->getHidSeam();
ss << svgOut.exportEdges(s);
shape = gObj->getHidSeam();
ss << svgOut.exportEdges(shape);
}
ss << grpTail;
//hidden group end
@@ -549,8 +547,8 @@ private:
{
if(!dvp->hasGeometry())
return;
TechDraw::GeometryObject* go = dvp->getGeometryObject();
TopoDS_Shape s = TechDraw::mirrorShape(go->getVisHard());
TechDraw::GeometryObject* gObj = dvp->getGeometryObject();
TopoDS_Shape shape = TechDraw::mirrorShape(gObj->getVisHard());
double offX = 0.0;
double offY = 0.0;
if (dvp->isDerivedFrom(TechDraw::DrawProjGroupItem::getClassTypeId())) {
@@ -561,56 +559,54 @@ private:
offY = dpg->Y.getValue();
}
}
double dvpX,dvpY;
double dvpX(0.0);
double dvpY(0.0);
if (alignPage) {
dvpX = dvp->X.getValue() + offX;
dvpY = dvp->Y.getValue() + offY;
} else {
dvpX = 0.0;
dvpY = 0.0;
}
gp_Trsf xLate;
xLate.SetTranslation(gp_Vec(dvpX,dvpY,0.0));
BRepBuilderAPI_Transform mkTrf(s, xLate);
s = mkTrf.Shape();
writer.exportShape(s);
s = TechDraw::mirrorShape(go->getVisOutline());
mkTrf.Perform(s);
s = mkTrf.Shape();
writer.exportShape(s);
xLate.SetTranslation(gp_Vec(dvpX, dvpY, 0.0));
BRepBuilderAPI_Transform mkTrf(shape, xLate);
shape = mkTrf.Shape();
writer.exportShape(shape);
shape = TechDraw::mirrorShape(gObj->getVisOutline());
mkTrf.Perform(shape);
shape = mkTrf.Shape();
writer.exportShape(shape);
if (dvp->SmoothVisible.getValue()) {
s = TechDraw::mirrorShape(go->getVisSmooth());
mkTrf.Perform(s);
s = mkTrf.Shape();
writer.exportShape(s);
shape = TechDraw::mirrorShape(gObj->getVisSmooth());
mkTrf.Perform(shape);
shape = mkTrf.Shape();
writer.exportShape(shape);
}
if (dvp->SeamVisible.getValue()) {
s = TechDraw::mirrorShape(go->getVisSeam());
mkTrf.Perform(s);
s = mkTrf.Shape();
writer.exportShape(s);
shape = TechDraw::mirrorShape(gObj->getVisSeam());
mkTrf.Perform(shape);
shape = mkTrf.Shape();
writer.exportShape(shape);
}
if (dvp->HardHidden.getValue()) {
s = TechDraw::mirrorShape(go->getHidHard());
mkTrf.Perform(s);
s = mkTrf.Shape();
writer.exportShape(s);
s = TechDraw::mirrorShape(go->getHidOutline());
mkTrf.Perform(s);
s = mkTrf.Shape();
writer.exportShape(s);
shape = TechDraw::mirrorShape(gObj->getHidHard());
mkTrf.Perform(shape);
shape = mkTrf.Shape();
writer.exportShape(shape);
shape = TechDraw::mirrorShape(gObj->getHidOutline());
mkTrf.Perform(shape);
shape = mkTrf.Shape();
writer.exportShape(shape);
}
if (dvp->SmoothHidden.getValue()) {
s = TechDraw::mirrorShape(go->getHidSmooth());
mkTrf.Perform(s);
s = mkTrf.Shape();
writer.exportShape(s);
shape = TechDraw::mirrorShape(gObj->getHidSmooth());
mkTrf.Perform(shape);
shape = mkTrf.Shape();
writer.exportShape(shape);
}
if (dvp->SeamHidden.getValue()) {
s = TechDraw::mirrorShape(go->getHidSeam());
mkTrf.Perform(s);
s = mkTrf.Shape();
writer.exportShape(s);
shape = TechDraw::mirrorShape(gObj->getHidSeam());
mkTrf.Perform(shape);
shape = mkTrf.Shape();
writer.exportShape(shape);
}
//add the cosmetic edges also
std::vector<TechDraw::BaseGeomPtr> geoms = dvp->getEdgeGeometry();
@@ -621,30 +617,28 @@ private:
}
}
if (!cosmeticEdges.empty()) {
s = TechDraw::mirrorShape(DrawUtil::vectorToCompound(cosmeticEdges));
mkTrf.Perform(s);
s = mkTrf.Shape();
writer.exportShape(s);
shape = TechDraw::mirrorShape(DrawUtil::vectorToCompound(cosmeticEdges));
mkTrf.Perform(shape);
shape = mkTrf.Shape();
writer.exportShape(shape);
}
}
Py::Object writeDXFView(const Py::Tuple& args)
{
PyObject *viewObj;
char* name;
PyObject *viewObj(nullptr);
char* name(nullptr);
PyObject *alignObj = Py_True;
if (!PyArg_ParseTuple(args.ptr(), "Oet|O", &viewObj, "utf-8",&name,&alignObj)) {
throw Py::TypeError("expected (view,path");
if (!PyArg_ParseTuple(args.ptr(), "Oet|O", &viewObj, "utf-8", &name, &alignObj)) {
throw Py::TypeError("expected (view, path");
}
std::string filePath = std::string(name);
std::string layerName = "none";
PyMem_Free(name);
bool align;
bool align = false;
if (alignObj == Py_True) {
align = true;
} else {
align = false;
}
try {
@@ -658,7 +652,7 @@ private:
layerName = dvp->getNameInDocument();
writer.setLayerName(layerName);
write1ViewDxf(writer,dvp,align);
write1ViewDxf(writer, dvp, align);
}
writer.endRun();
}
@@ -671,10 +665,10 @@ private:
Py::Object writeDXFPage(const Py::Tuple& args)
{
PyObject *pageObj;
char* name;
if (!PyArg_ParseTuple(args.ptr(), "Oet", &pageObj, "utf-8",&name)) {
throw Py::TypeError("expected (page,path");
PyObject *pageObj(nullptr);
char* name(nullptr);
if (!PyArg_ParseTuple(args.ptr(), "Oet", &pageObj, "utf-8", &name)) {
throw Py::TypeError("expected (page, path");
}
std::string filePath = std::string(name);
@@ -685,30 +679,30 @@ private:
ImpExpDxfWrite writer(filePath);
writer.init();
App::DocumentObject* obj = nullptr;
TechDraw::DrawPage* dp = nullptr;
TechDraw::DrawPage* dPage = nullptr;
if (PyObject_TypeCheck(pageObj, &(TechDraw::DrawPagePy::Type))) {
obj = static_cast<App::DocumentObjectPy*>(pageObj)->getDocumentObjectPtr();
dp = static_cast<TechDraw::DrawPage*>(obj);
auto views = dp->getAllViews();
for (auto& v: views) {
if (v->isDerivedFrom(TechDraw::DrawViewPart::getClassTypeId())) {
TechDraw::DrawViewPart* dvp = static_cast<TechDraw::DrawViewPart*>(v);
dPage = static_cast<TechDraw::DrawPage*>(obj);
auto views = dPage->getAllViews();
for (auto& view : views) {
if (view->isDerivedFrom(TechDraw::DrawViewPart::getClassTypeId())) {
TechDraw::DrawViewPart* dvp = static_cast<TechDraw::DrawViewPart*>(view);
layerName = dvp->getNameInDocument();
writer.setLayerName(layerName);
write1ViewDxf(writer,dvp,true);
} else if (v->isDerivedFrom(TechDraw::DrawViewAnnotation::getClassTypeId())) {
TechDraw::DrawViewAnnotation* dva = static_cast<TechDraw::DrawViewAnnotation*>(v);
write1ViewDxf(writer, dvp, true);
} else if (view->isDerivedFrom(TechDraw::DrawViewAnnotation::getClassTypeId())) {
TechDraw::DrawViewAnnotation* dva = static_cast<TechDraw::DrawViewAnnotation*>(view);
layerName = dva->getNameInDocument();
writer.setLayerName(layerName);
double height = dva->TextSize.getValue(); //mm
int just = 1; //centered
double x = dva->X.getValue();
double y = dva->Y.getValue();
Base::Vector3d loc(x,y,0.0);
Base::Vector3d loc(dva->X.getValue(), dva->Y.getValue(), 0.0);
auto lines = dva->Text.getValues();
writer.exportText(lines[0].c_str(),loc,loc, height,just);
} else if (v->isDerivedFrom(TechDraw::DrawViewDimension::getClassTypeId())) {
DrawViewDimension* dvd = static_cast<TechDraw::DrawViewDimension*>(v);
writer.exportText(lines[0].c_str(), loc, loc, height, just);
} else if (view->isDerivedFrom(TechDraw::DrawViewDimension::getClassTypeId())) {
DrawViewDimension* dvd = static_cast<TechDraw::DrawViewDimension*>(view);
TechDraw::DrawViewPart* dvp = dvd->getViewPart();
if (!dvp) {
continue;
@@ -726,7 +720,7 @@ private:
}
double parentX = dvp->X.getValue() + grandParentX;
double parentY = dvp->Y.getValue() + grandParentY;
Base::Vector3d parentPos(parentX,parentY,0.0);
Base::Vector3d parentPos(parentX, parentY, 0.0);
std::string sDimText;
//this is the same code as in QGIViewDimension::updateDim
if (dvd->isMultiValueSchema()) {
@@ -743,16 +737,16 @@ private:
dvd->Type.isValue("DistanceX") ||
dvd->Type.isValue("DistanceY") ) {
Base::Vector3d textLocn(dvd->X.getValue() + parentX, dvd->Y.getValue() + parentY, 0.0);
Base::Vector3d lineLocn(dvd->X.getValue() + parentX, dvd->Y.getValue() + parentY,0.0);
Base::Vector3d lineLocn(dvd->X.getValue() + parentX, dvd->Y.getValue() + parentY, 0.0);
pointPair pts = dvd->getLinearPoints();
Base::Vector3d dimLine = pts.first - pts.second;
Base::Vector3d norm(-dimLine.y,dimLine.x,0.0);
Base::Vector3d norm(-dimLine.y, dimLine.x, 0.0);
norm.Normalize();
lineLocn = lineLocn + (norm * gap);
Base::Vector3d extLine1Start = Base::Vector3d(pts.first.x,-pts.first.y,0.0) +
Base::Vector3d(parentX,parentY,0.0);
Base::Vector3d extLine1Start = Base::Vector3d(pts.first.x, -pts.first.y, 0.0) +
Base::Vector3d(parentX, parentY, 0.0);
Base::Vector3d extLine2Start = Base::Vector3d(pts.second.x, -pts.second.y, 0.0) +
Base::Vector3d(parentX,parentY,0.0);
Base::Vector3d(parentX, parentY, 0.0);
if (dvd->Type.isValue("DistanceX") ) {
type = 1;
} else if (dvd->Type.isValue("DistanceY") ) {
@@ -761,7 +755,7 @@ private:
writer.exportLinearDim(textLocn, lineLocn, extLine1Start, extLine2Start, dimText, type);
} else if (dvd->Type.isValue("Angle")) {
Base::Vector3d textLocn(dvd->X.getValue() + parentX, dvd->Y.getValue() + parentY, 0.0);
Base::Vector3d lineLocn(dvd->X.getValue() + parentX, dvd->Y.getValue() + parentY,0.0);
Base::Vector3d lineLocn(dvd->X.getValue() + parentX, dvd->Y.getValue() + parentY, 0.0);
anglePoints pts = dvd->getAnglePoints();
Base::Vector3d end1 = pts.ends.first;
end1.y = -end1.y;
@@ -773,7 +767,7 @@ private:
apex = apex + parentPos;
Base::Vector3d dimLine = end2 - end1;
Base::Vector3d norm(-dimLine.y,dimLine.x,0.0);
Base::Vector3d norm(-dimLine.y, dimLine.x, 0.0);
norm.Normalize();
lineLocn = lineLocn + (norm * gap);
end1 = end1 + parentPos;
@@ -815,11 +809,11 @@ private:
Py::Object findCentroid(const Py::Tuple& args)
{
PyObject *pcObjShape;
PyObject *pcObjDir;
PyObject *pcObjShape(nullptr);
PyObject *pcObjDir(nullptr);
if (!PyArg_ParseTuple(args.ptr(), "OO", &pcObjShape,
&pcObjDir)) {
throw Py::TypeError("expected (shape,direction");
throw Py::TypeError("expected (shape, direction");
}
if (!PyObject_TypeCheck(pcObjShape, &(TopoShapePy::Type))) {
@@ -838,16 +832,16 @@ private:
const TopoDS_Shape& shape = pShape->getTopoShapePtr()->getShape();
Base::Vector3d dir = static_cast<Base::VectorPy*>(pcObjDir)->value();
Base::Vector3d c = TechDraw::findCentroidVec(shape,dir);
Base::Vector3d centroid = TechDraw::findCentroidVec(shape, dir);
PyObject* result = nullptr;
result = new Base::VectorPy(new Base::Vector3d(c));
result = new Base::VectorPy(new Base::Vector3d(centroid));
return Py::asObject(result);
}
Py::Object makeExtentDim(const Py::Tuple& args)
{
PyObject* pDvp;
PyObject* pEdgeList;
PyObject* pDvp(nullptr);
PyObject* pEdgeList(nullptr);
int direction = 0; //Horizontal
TechDraw::DrawViewPart* dvp = nullptr;
@@ -882,12 +876,12 @@ private:
Py::Object makeDistanceDim(const Py::Tuple& args)
{
//points come in unscaled,but makeDistDim unscales them so we need to prescale here.
//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;
PyObject* pTo;
PyObject* pDvp(nullptr);
PyObject* pDimType(nullptr);
PyObject* pFrom(nullptr);
PyObject* pTo(nullptr);
TechDraw::DrawViewPart* dvp = nullptr;
std::string dimType;
Base::Vector3d from;
@@ -970,7 +964,7 @@ private:
Py::Object makeGeomHatch(const Py::Tuple& args)
{
PyObject* pFace;
PyObject* pFace(nullptr);
double scale = 1.0;
char* pPatName = "";
char* pPatFile = "";
@@ -987,8 +981,8 @@ private:
PyMem_Free(pPatFile);
if (PyObject_TypeCheck(pFace, &(TopoShapeFacePy::Type))) {
const TopoDS_Shape& sh = static_cast<TopoShapePy*>(pFace)->getTopoShapePtr()->getShape();
face = TopoDS::Face(sh);
const TopoDS_Shape& shape = static_cast<TopoShapePy*>(pFace)->getTopoShapePtr()->getShape();
face = TopoDS::Face(shape);
}
else {
throw Py::TypeError("first argument must be a Part.Face instance");
@@ -1001,15 +995,15 @@ private:
}
Base::FileInfo fi(patFile);
if (!fi.isReadable()) {
Base::Console().Error(".pat File: %s is not readable\n",patFile.c_str());
Base::Console().Error(".pat File: %s is not readable\n", patFile.c_str());
return Py::None();
}
std::vector<TechDraw::PATLineSpec> specs = TechDraw::DrawGeomHatch::getDecodedSpecsFromFile(patFile, patName);
std::vector<LineSet> lineSets;
for (auto& hl: specs) {
TechDraw::LineSet ls;
ls.setPATLineSpec(hl);
lineSets.push_back(ls);
for (auto& hLine : specs) {
TechDraw::LineSet lSet;
lSet.setPATLineSpec(hLine);
lineSets.push_back(lSet);
}
std::vector<LineSet> lsresult = TechDraw::DrawGeomHatch::getTrimmedLines(source, lineSets, face, scale);
if (!lsresult.empty()) {
@@ -1055,8 +1049,8 @@ private:
Py::Object project(const Py::Tuple& args)
{
PyObject *pcObjShape;
PyObject *pcObjDir=nullptr;
PyObject *pcObjShape(nullptr);
PyObject *pcObjDir(nullptr);
if (!PyArg_ParseTuple(args.ptr(), "O!|O!",
&(Part::TopoShapePy::Type), &pcObjShape,
@@ -1064,11 +1058,11 @@ private:
throw Py::Exception();
Part::TopoShapePy* pShape = static_cast<Part::TopoShapePy*>(pcObjShape);
Base::Vector3d Vector(0,0,1);
Base::Vector3d Vector(0, 0,1);
if (pcObjDir)
Vector = *static_cast<Base::VectorPy*>(pcObjDir)->getVectorPtr();
ProjectionAlgos Alg(pShape->getTopoShapePtr()->getShape(),Vector);
ProjectionAlgos Alg(pShape->getTopoShapePtr()->getShape(), Vector);
Py::List list;
list.append(Py::Object(new Part::TopoShapePy(new Part::TopoShape(Alg.V)) , true));
@@ -1080,8 +1074,8 @@ private:
}
Py::Object projectEx(const Py::Tuple& args)
{
PyObject *pcObjShape;
PyObject *pcObjDir=nullptr;
PyObject *pcObjShape(nullptr);
PyObject *pcObjDir(nullptr);
if (!PyArg_ParseTuple(args.ptr(), "O!|O!",
&(TopoShapePy::Type), &pcObjShape,
@@ -1089,11 +1083,11 @@ private:
throw Py::Exception();
TopoShapePy* pShape = static_cast<TopoShapePy*>(pcObjShape);
Base::Vector3d Vector(0,0,1);
Base::Vector3d Vector(0, 0,1);
if (pcObjDir)
Vector = *static_cast<Base::VectorPy*>(pcObjDir)->getVectorPtr();
ProjectionAlgos Alg(pShape->getTopoShapePtr()->getShape(),Vector);
ProjectionAlgos Alg(pShape->getTopoShapePtr()->getShape(), Vector);
Py::List list;
list.append(Py::Object(new TopoShapePy(new TopoShape(Alg.V)) , true));
@@ -1130,26 +1124,26 @@ private:
ProjectionAlgos::XmlAttributes h0Style;
PyObject* h1StylePy = nullptr;
ProjectionAlgos::XmlAttributes h1Style;
// Get the arguments
if (!PyArg_ParseTupleAndKeywords(
args.ptr(), keys.ptr(),
"O!|O!sfOOOOOO",
args.ptr(), keys.ptr(),
"O!|O!sfOOOOOO",
argNames,
&(TopoShapePy::Type), &pcObjShape,
&(Base::VectorPy::Type), &pcObjDir,
&extractionTypePy, &tol,
&vStylePy, &v0StylePy, &v1StylePy,
&(Base::VectorPy::Type), &pcObjDir,
&extractionTypePy, &tol,
&vStylePy, &v0StylePy, &v1StylePy,
&hStylePy, &h0StylePy, &h1StylePy))
throw Py::Exception();
// Convert all arguments into the right format
TopoShapePy* pShape = static_cast<TopoShapePy*>(pcObjShape);
Base::Vector3d directionVector(0,0,1);
Base::Vector3d directionVector(0, 0,1);
if (pcObjDir)
directionVector = static_cast<Base::VectorPy*>(pcObjDir)->value();
@@ -1168,20 +1162,20 @@ private:
copy(Py::Dict(h0StylePy), inserter(h0Style, h0Style.begin()));
if (h1StylePy)
copy(Py::Dict(h1StylePy), inserter(h1Style, h1Style.begin()));
// Execute the SVG generation
ProjectionAlgos Alg(pShape->getTopoShapePtr()->getShape(),
ProjectionAlgos Alg(pShape->getTopoShapePtr()->getShape(),
directionVector);
Py::String result(Alg.getSVG(extractionType, tol,
vStyle, v0Style, v1Style,
Py::String result(Alg.getSVG(extractionType, tol,
vStyle, v0Style, v1Style,
hStyle, h0Style, h1Style));
return result;
}
Py::Object projectToDXF(const Py::Tuple& args)
{
PyObject *pcObjShape;
PyObject *pcObjShape(nullptr);
PyObject *pcObjDir=nullptr;
const char *type=nullptr;
float scale=1.0f;
@@ -1193,10 +1187,10 @@ private:
throw Py::Exception();
TopoShapePy* pShape = static_cast<TopoShapePy*>(pcObjShape);
Base::Vector3d Vector(0,0,1);
Base::Vector3d Vector(0, 0,1);
if (pcObjDir)
Vector = static_cast<Base::VectorPy*>(pcObjDir)->value();
ProjectionAlgos Alg(pShape->getTopoShapePtr()->getShape(),Vector);
ProjectionAlgos Alg(pShape->getTopoShapePtr()->getShape(), Vector);
bool hidden = false;
if (type && std::string(type) == "ShowHiddenLines")
@@ -1208,7 +1202,7 @@ private:
Py::Object removeSvgTags(const Py::Tuple& args)
{
const char* svgcode;
if (!PyArg_ParseTuple(args.ptr(), "s",&svgcode))
if (!PyArg_ParseTuple(args.ptr(), "s", &svgcode))
throw Py::Exception();
std::string svg(svgcode);

View File

@@ -20,8 +20,8 @@
* *
***************************************************************************/
#ifndef _ARROWENUMS_H_
#define _ARROWENUMS_H_
#ifndef ARROWENUMS_H_
#define ARROWENUMS_H_
#include <Mod/TechDraw/TechDrawGlobal.h>

View File

@@ -1,422 +1,422 @@
/***************************************************************************
* Copyright (c) 2008 Werner Mayer <wmayer[at]users.sourceforge.net> *
* *
* This file is part of the FreeCAD CAx development system. *
* *
* This library is free software; you can redistribute it and/or *
* modify it under the terms of the GNU Library General Public *
* License as published by the Free Software Foundation; either *
* version 2 of the License, or (at your option) any later version. *
* *
* This library is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU Library General Public License for more details. *
* *
* You should have received a copy of the GNU Library General Public *
* License along with this library; see the file COPYING.LIB. If not, *
* write to the Free Software Foundation, Inc., 59 Temple Place, *
* Suite 330, Boston, MA 02111-1307, USA *
* *
***************************************************************************/
#include "PreCompiled.h"
#ifndef _PreComp_
# include <boost/uuid/uuid_io.hpp>
#endif
#include "DrawUtil.h"
#include "Cosmetic.h"
#include "CenterLinePy.h"
#include "CenterLinePy.cpp"
using namespace TechDraw;
// returns a string which represents the object e.g. when printed in python
std::string CenterLinePy::representation() const
{
std::stringstream ss;
ss << "<CenterLine object> at " << std::hex << this;
return ss.str();
}
PyObject *CenterLinePy::PyMake(struct _typeobject *, PyObject *, PyObject *) // Python wrapper
{
// never create such objects with the constructor
PyErr_SetString(PyExc_RuntimeError,
"You cannot create an instance of the abstract class 'CenterLine'.");
return nullptr;
}
// constructor method
int CenterLinePy::PyInit(PyObject* /*args*/, PyObject* /*kwd*/)
{
return 0;
}
PyObject* CenterLinePy::clone(PyObject *args)
{
if (!PyArg_ParseTuple(args, ""))
return nullptr;
TechDraw::CenterLine* geom = this->getCenterLinePtr();
PyTypeObject* type = this->GetType();
PyObject* cpy = nullptr;
// let the type object decide
if (type->tp_new)
cpy = type->tp_new(type, this, nullptr);
if (!cpy) {
PyErr_SetString(PyExc_TypeError, "failed to create clone of CenterLine");
return nullptr;
}
TechDraw::CenterLinePy* geompy = static_cast<TechDraw::CenterLinePy*>(cpy);
// the PyMake function must have created the corresponding instance of the 'CenterLine' subclass
// so delete it now to avoid a memory leak
if (geompy->_pcTwinPointer) {
TechDraw::CenterLine* clone = static_cast<TechDraw::CenterLine*>(geompy->_pcTwinPointer);
delete clone;
}
geompy->_pcTwinPointer = geom->clone();
return cpy;
}
PyObject* CenterLinePy::copy(PyObject *args)
{
if (!PyArg_ParseTuple(args, ""))
return nullptr;
TechDraw::CenterLine* geom = this->getCenterLinePtr();
PyTypeObject* type = this->GetType();
PyObject* cpy = nullptr;
// let the type object decide
if (type->tp_new)
cpy = type->tp_new(type, this, nullptr);
if (!cpy) {
PyErr_SetString(PyExc_TypeError, "failed to create copy of CenterLine");
return nullptr;
}
TechDraw::CenterLinePy* geompy = static_cast<TechDraw::CenterLinePy*>(cpy);
// the PyMake function must have created the corresponding instance of the 'CenterLine' subclass
// so delete it now to avoid a memory leak
if (geompy->_pcTwinPointer) {
TechDraw::CenterLine* copy = static_cast<TechDraw::CenterLine*>(geompy->_pcTwinPointer);
delete copy;
}
geompy->_pcTwinPointer = geom->copy();
return cpy;
}
Py::Object CenterLinePy::getFormat() const
{
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 Py::asObject(result);
}
void CenterLinePy::setFormat(Py::Object arg)
{
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;
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");
}
}
Py::String CenterLinePy::getTag() const
{
std::string tmp = boost::uuids::to_string(getCenterLinePtr()->getTag());
return Py::String(tmp);
}
Py::Long CenterLinePy::getType() const
{
int tmp = getCenterLinePtr()->m_type;
return Py::Long(tmp);
}
Py::Long CenterLinePy::getMode() const
{
int tmp = getCenterLinePtr()->m_mode;
return Py::Long(tmp);
}
void CenterLinePy::setMode(Py::Long arg)
{
PyObject* p = arg.ptr();
if (PyLong_Check(p)) {
long int temp = PyLong_AsLong(p);
getCenterLinePtr()->m_mode = (int) temp;
} else {
std::string error = std::string("type must be 'Integer', not ");
error += p->ob_type->tp_name;
throw Py::TypeError(error);
}
}
Py::Float CenterLinePy::getHorizShift() const
{
double shift = getCenterLinePtr()->getHShift();
return Py::asObject(PyFloat_FromDouble(shift));
}
void CenterLinePy::setHorizShift(Py::Float arg)
{
PyObject* p = arg.ptr();
if (PyFloat_Check(p)) {
double hshift = PyFloat_AsDouble(p);
double vshift = getCenterLinePtr()->getVShift();
getCenterLinePtr()->setShifts(hshift, vshift);
} else {
std::string error = std::string("type must be 'Float', not ");
error += p->ob_type->tp_name;
throw Py::TypeError(error);
}
}
Py::Float CenterLinePy::getVertShift() const
{
double shift = getCenterLinePtr()->getVShift();
return Py::asObject(PyFloat_FromDouble(shift));
}
void CenterLinePy::setVertShift(Py::Float arg)
{
PyObject* p = arg.ptr();
if (PyFloat_Check(p)) {
double vshift = PyFloat_AsDouble(p);
double hshift = getCenterLinePtr()->getHShift();
getCenterLinePtr()->setShifts(hshift, vshift);
} else {
std::string error = std::string("type must be 'Float', not ");
error += p->ob_type->tp_name;
throw Py::TypeError(error);
}
}
Py::Float CenterLinePy::getRotation() const
{
double rot = getCenterLinePtr()->getRotate();
return Py::asObject(PyFloat_FromDouble(rot));
}
void CenterLinePy::setRotation(Py::Float arg)
{
PyObject* p = arg.ptr();
if (PyFloat_Check(p)) {
double rot = PyFloat_AsDouble(p);
getCenterLinePtr()->setRotate(rot);
} else {
std::string error = std::string("type must be 'Float', not ");
error += p->ob_type->tp_name;
throw Py::TypeError(error);
}
}
Py::Float CenterLinePy::getExtension() const
{
double rot = getCenterLinePtr()->getExtend();
return Py::asObject(PyFloat_FromDouble(rot));
}
void CenterLinePy::setExtension(Py::Float arg)
{
PyObject* p = arg.ptr();
if (PyFloat_Check(p)) {
double ext = PyFloat_AsDouble(p);
getCenterLinePtr()->setExtend(ext);
} else {
std::string error = std::string("type must be 'Float', not ");
error += p->ob_type->tp_name;
throw Py::TypeError(error);
}
}
Py::Boolean CenterLinePy::getFlip() const
{
bool flip = getCenterLinePtr()->getFlip();
return Py::Boolean(flip);
}
void CenterLinePy::setFlip(Py::Boolean arg)
{
PyObject* p = arg.ptr();
if (PyBool_Check(p)) {
if (p == Py_True) {
getCenterLinePtr()->setFlip(true);
} else {
getCenterLinePtr()->setFlip(false);
}
} else {
std::string error = std::string("type must be 'Boolean', not ");
error += p->ob_type->tp_name;
throw Py::TypeError(error);
}
}
Py::Object CenterLinePy::getEdges() const
{
// Base::Console().Message("CLP::getEdges()\n");
TechDraw::CenterLine* cl = this->getCenterLinePtr();
std::vector<std::string> edges = cl->m_edges;
int size = edges.size();
Py::List result(size);
for (auto& e: edges) {
result.append(Py::asObject(PyUnicode_FromString(e.c_str())));
}
return result;
}
void CenterLinePy::setEdges(Py::Object arg)
{
// Base::Console().Message("CLP::setEdges()\n");
PyObject* pList = arg.ptr();
TechDraw::CenterLine* cl = this->getCenterLinePtr();
std::vector<std::string> temp;
if (PyList_Check(pList)) {
int tSize = (int) PyList_Size(pList);
int i = 0;
for ( ; i < tSize; i++) {
PyObject* item = PyList_GetItem(pList, (Py_ssize_t) i);
if (PyUnicode_Check(item)) {
std::string s = PyUnicode_AsUTF8(item); //py3 only!!!
temp.push_back(s);
}
}
cl->m_edges = temp;
} else {
Base::Console().Error("CLPI::setEdges - input not a list!\n");
}
}
Py::Object CenterLinePy::getFaces() const
{
// Base::Console().Message("CLP::getFaces()\n");
TechDraw::CenterLine* cl = this->getCenterLinePtr();
std::vector<std::string> faces = cl->m_faces;
int size = faces.size();
Py::List result(size);
for (auto& f: faces) {
result.append(Py::asObject(PyUnicode_FromString(f.c_str())));
}
return result;
}
void CenterLinePy::setFaces(Py::Object arg)
{
// Base::Console().Message("CLP::setFaces()\n");
PyObject* pList = arg.ptr();
TechDraw::CenterLine* cl = this->getCenterLinePtr();
std::vector<std::string> temp;
if (PyList_Check(pList)) {
int tSize = (int) PyList_Size(pList);
int i = 0;
for ( ; i < tSize; i++) {
PyObject* item = PyList_GetItem(pList, (Py_ssize_t) i);
if (PyUnicode_Check(item)) {
std::string s = PyUnicode_AsUTF8(item); //py3 only!!!
temp.push_back(s);
}
}
cl->m_faces = temp;
} else {
Base::Console().Error("CLPI::setFaces - input not a list!\n");
}
}
Py::Object CenterLinePy::getPoints() const
{
// Base::Console().Message("CLP::getPoints()\n");
TechDraw::CenterLine* cl = this->getCenterLinePtr();
std::vector<std::string> points = cl->m_verts;
int size = points.size();
Py::List result(size);
for (auto& p: points) {
result.append(Py::asObject(PyUnicode_FromString(p.c_str())));
}
return result;
}
void CenterLinePy::setPoints(Py::Object arg)
{
// Base::Console().Message("CLP::setPoints()\n");
PyObject* pList = arg.ptr();
TechDraw::CenterLine* cl = this->getCenterLinePtr();
std::vector<std::string> temp;
if (PyList_Check(pList)) {
int tSize = (int) PyList_Size(pList);
int i = 0;
for ( ; i < tSize; i++) {
PyObject* item = PyList_GetItem(pList, (Py_ssize_t) i);
if (PyUnicode_Check(item)) {
std::string s = PyUnicode_AsUTF8(item); //py3 only!!!
temp.push_back(s);
}
}
cl->m_verts = temp;
} else {
Base::Console().Error("CLPI::setPoints - input not a list!\n");
}
}
PyObject *CenterLinePy::getCustomAttributes(const char* /*attr*/) const
{
return nullptr;
}
int CenterLinePy::setCustomAttributes(const char* /*attr*/, PyObject* /*obj*/)
{
return 0;
}
/***************************************************************************
* Copyright (c) 2008 Werner Mayer <wmayer[at]users.sourceforge.net> *
* *
* This file is part of the FreeCAD CAx development system. *
* *
* This library is free software; you can redistribute it and/or *
* modify it under the terms of the GNU Library General Public *
* License as published by the Free Software Foundation; either *
* version 2 of the License, or (at your option) any later version. *
* *
* This library is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU Library General Public License for more details. *
* *
* You should have received a copy of the GNU Library General Public *
* License along with this library; see the file COPYING.LIB. If not, *
* write to the Free Software Foundation, Inc., 59 Temple Place, *
* Suite 330, Boston, MA 02111-1307, USA *
* *
***************************************************************************/
#include "PreCompiled.h"
#ifndef _PreComp_
# include <boost/uuid/uuid_io.hpp>
#endif
#include <Base/Console.h>
#include "DrawUtil.h"
#include "Cosmetic.h"
#include "CenterLinePy.h"
using namespace TechDraw;
// returns a string which represents the object e.g. when printed in python
std::string CenterLinePy::representation() const
{
std::stringstream sStream;
sStream << "<CenterLine object> at " << std::hex << this;
return sStream.str();
}
PyObject *CenterLinePy::PyMake(struct _typeobject *, PyObject *, PyObject *) // Python wrapper
{
// never create such objects with the constructor
PyErr_SetString(PyExc_RuntimeError,
"You cannot create an instance of the abstract class 'CenterLine'.");
return nullptr;
}
// constructor method
int CenterLinePy::PyInit(PyObject* /*args*/, PyObject* /*kwd*/)
{
return 0;
}
PyObject* CenterLinePy::clone(PyObject *args)
{
if (!PyArg_ParseTuple(args, ""))
return nullptr;
TechDraw::CenterLine* geom = this->getCenterLinePtr();
PyTypeObject* type = this->GetType();
PyObject* cpy = nullptr;
// let the type object decide
if (type->tp_new)
cpy = type->tp_new(type, this, nullptr);
if (!cpy) {
PyErr_SetString(PyExc_TypeError, "failed to create clone of CenterLine");
return nullptr;
}
TechDraw::CenterLinePy* geompy = static_cast<TechDraw::CenterLinePy*>(cpy);
// the PyMake function must have created the corresponding instance of the 'CenterLine' subclass
// so delete it now to avoid a memory leak
if (geompy->_pcTwinPointer) {
TechDraw::CenterLine* clone = static_cast<TechDraw::CenterLine*>(geompy->_pcTwinPointer);
delete clone;
}
geompy->_pcTwinPointer = geom->clone();
return cpy;
}
PyObject* CenterLinePy::copy(PyObject *args)
{
if (!PyArg_ParseTuple(args, ""))
return nullptr;
TechDraw::CenterLine* geom = this->getCenterLinePtr();
PyTypeObject* type = this->GetType();
PyObject* cpy = nullptr;
// let the type object decide
if (type->tp_new)
cpy = type->tp_new(type, this, nullptr);
if (!cpy) {
PyErr_SetString(PyExc_TypeError, "failed to create copy of CenterLine");
return nullptr;
}
TechDraw::CenterLinePy* geompy = static_cast<TechDraw::CenterLinePy*>(cpy);
// the PyMake function must have created the corresponding instance of the 'CenterLine' subclass
// so delete it now to avoid a memory leak
if (geompy->_pcTwinPointer) {
TechDraw::CenterLine* copy = static_cast<TechDraw::CenterLine*>(geompy->_pcTwinPointer);
delete copy;
}
geompy->_pcTwinPointer = geom->copy();
return cpy;
}
Py::Object CenterLinePy::getFormat() const
{
TechDraw::CenterLine* cLine= this->getCenterLinePtr();
PyObject* pStyle = PyLong_FromLong((long) cLine->m_format.m_style);
PyObject* pWeight = PyFloat_FromDouble(cLine->m_format.m_weight);
PyObject* pColor = DrawUtil::colorToPyTuple(cLine->m_format.m_color);
PyObject* pVisible = PyBool_FromLong((long) cLine->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 Py::asObject(result);
}
void CenterLinePy::setFormat(Py::Object arg)
{
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 color(red, blue, green, alpha);
bool visible = 1;
TechDraw::CenterLine* cLine= 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);
color = DrawUtil::pyTupleToColor(pColor);
PyObject* pVisible = PyTuple_GetItem(pTuple, 3);
visible = (bool) PyLong_AsLong(pVisible);
cLine->m_format.m_style = style;
cLine->m_format.m_weight = weight;
cLine->m_format.m_color = color;
cLine->m_format.m_visible = visible;
}
} else {
Base::Console().Error("CLPI::setFormat - not a tuple!\n");
}
}
Py::String CenterLinePy::getTag() const
{
std::string tmp = boost::uuids::to_string(getCenterLinePtr()->getTag());
return Py::String(tmp);
}
Py::Long CenterLinePy::getType() const
{
int tmp = getCenterLinePtr()->m_type;
return Py::Long(tmp);
}
Py::Long CenterLinePy::getMode() const
{
int tmp = getCenterLinePtr()->m_mode;
return Py::Long(tmp);
}
void CenterLinePy::setMode(Py::Long arg)
{
PyObject* pObj = arg.ptr();
if (PyLong_Check(pObj)) {
long int temp = PyLong_AsLong(pObj);
getCenterLinePtr()->m_mode = (int) temp;
} else {
std::string error = std::string("type must be 'Integer', not ");
error += pObj->ob_type->tp_name;
throw Py::TypeError(error);
}
}
Py::Float CenterLinePy::getHorizShift() const
{
double shift = getCenterLinePtr()->getHShift();
return Py::asObject(PyFloat_FromDouble(shift));
}
void CenterLinePy::setHorizShift(Py::Float arg)
{
PyObject* pObj = arg.ptr();
if (PyFloat_Check(pObj)) {
double hshift = PyFloat_AsDouble(pObj);
double vshift = getCenterLinePtr()->getVShift();
getCenterLinePtr()->setShifts(hshift, vshift);
} else {
std::string error = std::string("type must be 'Float', not ");
error += pObj->ob_type->tp_name;
throw Py::TypeError(error);
}
}
Py::Float CenterLinePy::getVertShift() const
{
double shift = getCenterLinePtr()->getVShift();
return Py::asObject(PyFloat_FromDouble(shift));
}
void CenterLinePy::setVertShift(Py::Float arg)
{
PyObject* pObj = arg.ptr();
if (PyFloat_Check(pObj)) {
double vshift = PyFloat_AsDouble(pObj);
double hshift = getCenterLinePtr()->getHShift();
getCenterLinePtr()->setShifts(hshift, vshift);
} else {
std::string error = std::string("type must be 'Float', not ");
error += pObj->ob_type->tp_name;
throw Py::TypeError(error);
}
}
Py::Float CenterLinePy::getRotation() const
{
double rot = getCenterLinePtr()->getRotate();
return Py::asObject(PyFloat_FromDouble(rot));
}
void CenterLinePy::setRotation(Py::Float arg)
{
PyObject* pObj = arg.ptr();
if (PyFloat_Check(pObj)) {
double rot = PyFloat_AsDouble(pObj);
getCenterLinePtr()->setRotate(rot);
} else {
std::string error = std::string("type must be 'Float', not ");
error += pObj->ob_type->tp_name;
throw Py::TypeError(error);
}
}
Py::Float CenterLinePy::getExtension() const
{
double rot = getCenterLinePtr()->getExtend();
return Py::asObject(PyFloat_FromDouble(rot));
}
void CenterLinePy::setExtension(Py::Float arg)
{
PyObject* pObj = arg.ptr();
if (PyFloat_Check(pObj)) {
double ext = PyFloat_AsDouble(pObj);
getCenterLinePtr()->setExtend(ext);
} else {
std::string error = std::string("type must be 'Float', not ");
error += pObj->ob_type->tp_name;
throw Py::TypeError(error);
}
}
Py::Boolean CenterLinePy::getFlip() const
{
bool flip = getCenterLinePtr()->getFlip();
return Py::Boolean(flip);
}
void CenterLinePy::setFlip(Py::Boolean arg)
{
PyObject* pObj = arg.ptr();
if (PyBool_Check(pObj)) {
if (pObj == Py_True) {
getCenterLinePtr()->setFlip(true);
} else {
getCenterLinePtr()->setFlip(false);
}
} else {
std::string error = std::string("type must be 'Boolean', not ");
error += pObj->ob_type->tp_name;
throw Py::TypeError(error);
}
}
Py::Object CenterLinePy::getEdges() const
{
// Base::Console().Message("CLP::getEdges()\n");
TechDraw::CenterLine* cLine= this->getCenterLinePtr();
std::vector<std::string> edges = cLine->m_edges;
int size = edges.size();
Py::List result(size);
for (auto& eName : edges) {
result.append(Py::asObject(PyUnicode_FromString(eName.c_str())));
}
return result;
}
void CenterLinePy::setEdges(Py::Object arg)
{
// Base::Console().Message("CLP::setEdges()\n");
PyObject* pList = arg.ptr();
TechDraw::CenterLine* cLine= this->getCenterLinePtr();
std::vector<std::string> temp;
if (PyList_Check(pList)) {
int tSize = (int) PyList_Size(pList);
int i = 0;
for ( ; i < tSize; i++) {
PyObject* item = PyList_GetItem(pList, (Py_ssize_t) i);
if (PyUnicode_Check(item)) {
temp.push_back(PyUnicode_AsUTF8(item));
}
}
cLine->m_edges = temp;
} else {
Base::Console().Error("CLPI::setEdges - input not a list!\n");
}
}
Py::Object CenterLinePy::getFaces() const
{
// Base::Console().Message("CLP::getFaces()\n");
TechDraw::CenterLine* cLine= this->getCenterLinePtr();
std::vector<std::string> faces = cLine->m_faces;
int size = faces.size();
Py::List result(size);
for (auto& f: faces) {
result.append(Py::asObject(PyUnicode_FromString(f.c_str())));
}
return result;
}
void CenterLinePy::setFaces(Py::Object arg)
{
// Base::Console().Message("CLP::setFaces()\n");
PyObject* pList = arg.ptr();
TechDraw::CenterLine* cLine= this->getCenterLinePtr();
std::vector<std::string> temp;
if (PyList_Check(pList)) {
int tSize = (int) PyList_Size(pList);
int i = 0;
for ( ; i < tSize; i++) {
PyObject* item = PyList_GetItem(pList, (Py_ssize_t) i);
if (PyUnicode_Check(item)) {
temp.push_back(PyUnicode_AsUTF8(item));
}
}
cLine->m_faces = temp;
} else {
Base::Console().Error("CLPI::setFaces - input not a list!\n");
}
}
Py::Object CenterLinePy::getPoints() const
{
// Base::Console().Message("CLP::getPoints()\n");
TechDraw::CenterLine* cLine= this->getCenterLinePtr();
std::vector<std::string> points = cLine->m_verts;
int size = points.size();
Py::List result(size);
for (auto& p: points) {
result.append(Py::asObject(PyUnicode_FromString(p.c_str())));
}
return result;
}
void CenterLinePy::setPoints(Py::Object arg)
{
// Base::Console().Message("CLP::setPoints()\n");
PyObject* pList = arg.ptr();
TechDraw::CenterLine* cLine= this->getCenterLinePtr();
std::vector<std::string> temp;
if (PyList_Check(pList)) {
int tSize = (int) PyList_Size(pList);
int i = 0;
for ( ; i < tSize; i++) {
PyObject* item = PyList_GetItem(pList, (Py_ssize_t) i);
if (PyUnicode_Check(item)) {
temp.push_back(PyUnicode_AsUTF8(item));
}
}
cLine->m_verts = temp;
} else {
Base::Console().Error("CLPI::setPoints - input not a list!\n");
}
}
PyObject *CenterLinePy::getCustomAttributes(const char* /*attr*/) const
{
return nullptr;
}
int CenterLinePy::setCustomAttributes(const char* /*attr*/, PyObject* /*obj*/)
{
return 0;
}
#include "CenterLinePy.cpp"

View File

@@ -87,16 +87,16 @@ LineFormat::LineFormat(int style,
void LineFormat::dump(const char* title)
{
Base::Console().Message("LF::dump - %s \n",title);
Base::Console().Message("LF::dump - %s \n",toString().c_str());
Base::Console().Message("LF::dump - %s \n", title);
Base::Console().Message("LF::dump - %s \n", toString().c_str());
}
std::string LineFormat::toString() const
{
std::stringstream ss;
ss << m_style << "," <<
m_weight << "," <<
m_color.asHexString() << "," <<
ss << m_style << ", " <<
m_weight << ", " <<
m_color.asHexString() << ", " <<
m_visible;
return ss.str();
}
@@ -130,7 +130,7 @@ CosmeticVertex::CosmeticVertex() : TechDraw::Vertex()
permaPoint = Base::Vector3d(0.0, 0.0, 0.0);
linkGeom = -1;
color = Preferences::vertexColor();
size = Preferences::vertexScale() *
size = Preferences::vertexScale() *
LineGroup::getDefaultWidth("Thin");
style = 1;
visible = true;
@@ -159,7 +159,7 @@ CosmeticVertex::CosmeticVertex(Base::Vector3d loc) : TechDraw::Vertex(loc)
permaPoint = loc;
linkGeom = -1;
color = Preferences::vertexColor();
size = Preferences::vertexScale() *
size = Preferences::vertexScale() *
LineGroup::getDefaultWidth("Thick");
style = 1; //TODO: implement styled vertexes
visible = true;
@@ -183,21 +183,21 @@ void CosmeticVertex::moveRelative(Base::Vector3d movement)
std::string CosmeticVertex::toString() const
{
std::stringstream ss;
ss << permaPoint.x << "," <<
permaPoint.y << "," <<
permaPoint.z << "," <<
ss << permaPoint.x << ", " <<
permaPoint.y << ", " <<
permaPoint.z << ", " <<
" / ";
ss << point().x << "," <<
point().y << "," <<
point().z << "," <<
ss << point().x << ", " <<
point().y << ", " <<
point().z << ", " <<
" / " <<
linkGeom << "," <<
linkGeom << ", " <<
" / " <<
color.asHexString() << "," <<
color.asHexString() << ", " <<
" / " <<
size << "," <<
size << ", " <<
" / " <<
style << "," <<
style << ", " <<
" / " <<
visible << " / " ;
ss << getTagAsString();
@@ -311,7 +311,7 @@ PyObject* CosmeticVertex::getPyObject()
{
if (PythonObject.is(Py::_None())) {
// ref counter is set to 1
PythonObject = Py::Object(new CosmeticVertexPy(this),true);
PythonObject = Py::Object(new CosmeticVertexPy(this), true);
}
return Py::new_reference_to(PythonObject);
}
@@ -319,13 +319,13 @@ PyObject* CosmeticVertex::getPyObject()
void CosmeticVertex::dump(const char* title)
{
Base::Console().Message("CV::dump - %s \n",title);
Base::Console().Message("CV::dump - %s \n",toString().c_str());
Base::Console().Message("CV::dump - %s \n", title);
Base::Console().Message("CV::dump - %s \n", toString().c_str());
}
//******************************************
TYPESYSTEM_SOURCE(TechDraw::CosmeticEdge,Base::Persistence)
TYPESYSTEM_SOURCE(TechDraw::CosmeticEdge, Base::Persistence)
//note this ctor has no occEdge or first/last point for geometry!
CosmeticEdge::CosmeticEdge()
@@ -343,7 +343,7 @@ CosmeticEdge::CosmeticEdge(CosmeticEdge* ce)
//these endpoints are already YInverted
permaStart = ce->permaStart;
permaEnd = ce->permaEnd;
permaRadius = ce->permaRadius;
permaRadius = ce->permaRadius;
m_geometry = newGeom;
m_format = ce->m_format;
initialize();
@@ -373,7 +373,7 @@ CosmeticEdge::CosmeticEdge(TechDraw::BaseGeomPtr g)
permaStart = circ->center;
permaEnd = circ->center;
permaRadius = circ->radius;
}
}
initialize();
}
@@ -395,11 +395,11 @@ void CosmeticEdge::initialize()
TopoDS_Edge CosmeticEdge::TopoDS_EdgeFromVectors(Base::Vector3d pt1, Base::Vector3d pt2)
{
// Base::Console().Message("CE::CE(p1,p2)\n");
// Base::Console().Message("CE::CE(p1, p2)\n");
Base::Vector3d p1 = DrawUtil::invertY(pt1);
Base::Vector3d p2 = DrawUtil::invertY(pt2);
gp_Pnt gp1(p1.x,p1.y,p1.z);
gp_Pnt gp2(p2.x,p2.y,p2.z);
gp_Pnt gp1(p1.x, p1.y, p1.z);
gp_Pnt gp2(p2.x, p2.y, p2.z);
TopoDS_Edge e = BRepBuilderAPI_MakeEdge(gp1, gp2);
return e;
}
@@ -423,10 +423,10 @@ std::string CosmeticEdge::toString() const
std::stringstream ss;
ss << getTagAsString() << ", $$$, ";
if (m_geometry) {
ss << m_geometry->geomType <<
",$$$," <<
ss << m_geometry->geomType <<
", $$$, " <<
m_geometry->toString() <<
",$$$," <<
", $$$, " <<
m_format.toString();
}
return ss.str();
@@ -434,8 +434,8 @@ std::string CosmeticEdge::toString() const
void CosmeticEdge::dump(const char* title)
{
Base::Console().Message("CE::dump - %s \n",title);
Base::Console().Message("CE::dump - %s \n",toString().c_str());
Base::Console().Message("CE::dump - %s \n", title);
Base::Console().Message("CE::dump - %s \n", toString().c_str());
}
// Persistence implementers
@@ -568,7 +568,7 @@ PyObject* CosmeticEdge::getPyObject()
{
if (PythonObject.is(Py::_None())) {
// ref counter is set to 1
PythonObject = Py::Object(new CosmeticEdgePy(this),true);
PythonObject = Py::Object(new CosmeticEdgePy(this), true);
}
return Py::new_reference_to(PythonObject);
}
@@ -576,7 +576,7 @@ PyObject* CosmeticEdge::getPyObject()
//*********************************************************
TYPESYSTEM_SOURCE(TechDraw::CenterLine,Base::Persistence)
TYPESYSTEM_SOURCE(TechDraw::CenterLine, Base::Persistence)
CenterLine::CenterLine()
{
@@ -613,7 +613,7 @@ CenterLine::CenterLine(TechDraw::CenterLine* cl)
}
CenterLine::CenterLine(TechDraw::BaseGeomPtr bg,
int m,
int m,
double h,
double v,
double r,
@@ -661,18 +661,18 @@ void CenterLine::initialize()
TechDraw::BaseGeomPtr CenterLine::BaseGeomPtrFromVectors(Base::Vector3d pt1, Base::Vector3d pt2)
{
// Base::Console().Message("CE::CE(p1,p2)\n");
// Base::Console().Message("CE::CE(p1, p2)\n");
Base::Vector3d p1 = DrawUtil::invertY(pt1);
Base::Vector3d p2 = DrawUtil::invertY(pt2);
gp_Pnt gp1(p1.x,p1.y,p1.z);
gp_Pnt gp2(p2.x,p2.y,p2.z);
gp_Pnt gp1(p1.x, p1.y, p1.z);
gp_Pnt gp2(p2.x, p2.y, p2.z);
TopoDS_Edge e = BRepBuilderAPI_MakeEdge(gp1, gp2);
TechDraw::BaseGeomPtr bg = TechDraw::BaseGeom::baseFactory(e);
return bg;
}
CenterLine* CenterLine::CenterLineBuilder(DrawViewPart* partFeat,
std::vector<std::string> subNames,
CenterLine* CenterLine::CenterLineBuilder(DrawViewPart* partFeat,
std::vector<std::string> subNames,
int mode,
bool flip)
{
@@ -681,7 +681,7 @@ CenterLine* CenterLine::CenterLineBuilder(DrawViewPart* partFeat,
std::vector<std::string> faces;
std::vector<std::string> edges;
std::vector<std::string> verts;
std::string geomType = TechDraw::DrawUtil::getGeomTypeFromName(subNames.front());
int type = CLTYPE::FACE;
if (geomType == "Face") {
@@ -739,12 +739,12 @@ TechDraw::BaseGeomPtr CenterLine::scaledGeometry(TechDraw::DrawViewPart* partFea
// Base::Console().Message("CL::scaledGeometry - no geometry to scale!\n");
//CenterLine was created by points without a geometry reference,
ends = calcEndPointsNoRef(m_start, m_end, scale, m_extendBy,
m_hShift,m_vShift, m_rotate);
m_hShift, m_vShift, m_rotate);
} else if (m_type == CLTYPE::FACE) {
ends = calcEndPoints(partFeat,
m_faces,
m_mode, m_extendBy,
m_hShift,m_vShift, m_rotate);
m_hShift, m_vShift, m_rotate);
} else if (m_type == CLTYPE::EDGE) {
ends = calcEndPoints2Lines(partFeat,
m_edges,
@@ -770,11 +770,11 @@ TechDraw::BaseGeomPtr CenterLine::scaledGeometry(TechDraw::DrawViewPart* partFea
if (p1.IsEqual(p2, 0.00001)) {
Base::Console().Warning("Centerline endpoints are equal. Could not draw.\n");
//what to do here? //return current geom?
return m_geometry;
return m_geometry;
}
gp_Pnt gp1(p1.x,p1.y,p1.z);
gp_Pnt gp2(p2.x,p2.y,p2.z);
gp_Pnt gp1(p1.x, p1.y, p1.z);
gp_Pnt gp2(p2.x, p2.y, p2.z);
TopoDS_Edge e = BRepBuilderAPI_MakeEdge(gp1, gp2);
TopoDS_Shape s = TechDraw::scaleShape(e, scale);
TopoDS_Edge newEdge = TopoDS::Edge(s);
@@ -784,48 +784,48 @@ TechDraw::BaseGeomPtr CenterLine::scaledGeometry(TechDraw::DrawViewPart* partFea
newGeom->cosmetic = true;
newGeom->source(CENTERLINE);
newGeom->setCosmeticTag(getTagAsString());
return newGeom;
}
std::string CenterLine::toString() const
{
std::stringstream ss;
ss << m_start.x << "," <<
m_start.y << "," <<
m_start.z << "," <<
m_end.x << "," <<
m_end.y << "," <<
m_end.z << "," <<
m_mode << "," <<
m_type << "," <<
m_hShift << "," <<
m_vShift << "," <<
m_rotate << "," <<
m_flip2Line << "," <<
m_extendBy << "," <<
ss << m_start.x << ", " <<
m_start.y << ", " <<
m_start.z << ", " <<
m_end.x << ", " <<
m_end.y << ", " <<
m_end.z << ", " <<
m_mode << ", " <<
m_type << ", " <<
m_hShift << ", " <<
m_vShift << ", " <<
m_rotate << ", " <<
m_flip2Line << ", " <<
m_extendBy << ", " <<
m_faces.size();
if (!m_faces.empty()) {
for (auto& f: m_faces) {
if (!f.empty()) {
ss << "," << f ;
ss << ", " << f ;
}
}
}
std::string clCSV = ss.str();
std::string fmtCSV = m_format.toString();
return clCSV + ",$$$," + fmtCSV;
return clCSV + ", $$$, " + fmtCSV;
}
void CenterLine::dump(const char* title)
{
Base::Console().Message("CL::dump - %s \n",title);
Base::Console().Message("CL::dump - %s \n",toString().c_str());
Base::Console().Message("CL::dump - %s \n", title);
Base::Console().Message("CL::dump - %s \n", toString().c_str());
}
std::tuple<Base::Vector3d, Base::Vector3d> CenterLine::rotatePointsAroundMid(Base::Vector3d p1, Base::Vector3d p2, Base::Vector3d mid, double rotate) {
//rotate p1, p2 about mid
//rotate p1, p2 about mid
double revRotate = -rotate;
double cosTheta = cos(revRotate * M_PI / 180.0);
double sinTheta = sin(revRotate * M_PI / 180.0);
@@ -888,7 +888,7 @@ std::pair<Base::Vector3d, Base::Vector3d> CenterLine::calcEndPointsNoRef(
//end points for face centerline
std::pair<Base::Vector3d, Base::Vector3d> CenterLine::calcEndPoints(DrawViewPart* partFeat,
std::vector<std::string> faceNames,
std::vector<std::string> faceNames,
int mode, double ext,
double hShift, double vShift,
double rotate)
@@ -909,7 +909,7 @@ std::pair<Base::Vector3d, Base::Vector3d> CenterLine::calcEndPoints(DrawViewPart
continue;
}
int idx = TechDraw::DrawUtil::getIndexFromName(fn);
std::vector<TechDraw::BaseGeomPtr> faceEdges =
std::vector<TechDraw::BaseGeomPtr> faceEdges =
partFeat->getFaceEdgesByIndex(idx);
if (!faceEdges.empty()) {
for (auto& fe: faceEdges) {
@@ -926,8 +926,8 @@ std::pair<Base::Vector3d, Base::Vector3d> CenterLine::calcEndPoints(DrawViewPart
throw Base::IndexError("CenterLine wrong number of faces.");
}
double Xmin,Ymin,Zmin,Xmax,Ymax,Zmax;
faceBox.Get(Xmin,Ymin,Zmin,Xmax,Ymax,Zmax);
double Xmin, Ymin, Zmin, Xmax, Ymax, Zmax;
faceBox.Get(Xmin, Ymin, Zmin, Xmax, Ymax, Zmax);
double Xspan = fabs(Xmax - Xmin);
Xspan = (Xspan / 2.0);
@@ -943,13 +943,13 @@ std::pair<Base::Vector3d, Base::Vector3d> CenterLine::calcEndPoints(DrawViewPart
p2 = Base::Vector3d(Xmid, Ymin, 0.0);
} else if (mode == 1) { //horizontal
p1 = Base::Vector3d(Xmin, Ymid, 0.0);
p2 = Base::Vector3d(Xmax,Ymid, 0.0);
p2 = Base::Vector3d(Xmax, Ymid, 0.0);
} else { //vert == 2 //aligned, but aligned doesn't make sense for face(s) bbox
Base::Console().Message("CL::calcEndPoints - aligned is not applicable to Face center lines\n");
p1 = Base::Vector3d(Xmid, Ymax, 0.0);
p2 = Base::Vector3d(Xmid, Ymin, 0.0);
}
Base::Vector3d mid = (p1 + p2) / 2.0;
//extend
@@ -983,11 +983,11 @@ std::pair<Base::Vector3d, Base::Vector3d> CenterLine::calcEndPoints(DrawViewPart
}
std::pair<Base::Vector3d, Base::Vector3d> CenterLine::calcEndPoints2Lines(DrawViewPart* partFeat,
std::vector<std::string> edgeNames,
std::vector<std::string> edgeNames,
int mode, double ext,
double hShift, double vShift,
double rotate, bool flip)
{
Q_UNUSED(flip)
@@ -1060,7 +1060,7 @@ std::pair<Base::Vector3d, Base::Vector3d> CenterLine::calcEndPoints2Lines(DrawVi
//rotate
if (!DrawUtil::fpCompare(rotate, 0.0)) {
//rotate p1, p2 about mid
//rotate p1, p2 about mid
tie(p1, p2) = rotatePointsAroundMid(p1, p2, mid, rotate);
}
@@ -1082,11 +1082,11 @@ std::pair<Base::Vector3d, Base::Vector3d> CenterLine::calcEndPoints2Lines(DrawVi
}
std::pair<Base::Vector3d, Base::Vector3d> CenterLine::calcEndPoints2Points(DrawViewPart* partFeat,
std::vector<std::string> vertNames,
std::vector<std::string> vertNames,
int mode, double ext,
double hShift, double vShift,
double rotate, bool flip)
{
// Base::Console().Message("CL::calc2Points()\n");
if (vertNames.empty()) {
@@ -1131,7 +1131,7 @@ std::pair<Base::Vector3d, Base::Vector3d> CenterLine::calcEndPoints2Points(DrawV
p1 = p2;
p2 = temp;
}
if (mode == 0) { //Vertical
p1.x = mid.x;
p2.x = mid.x;
@@ -1365,14 +1365,14 @@ void CenterLine::Restore(Base::XMLReader &reader)
m_geometry = aoc;
} else {
Base::Console().Warning("CL::Restore - unimplemented geomType: %d\n", gType);
}
}
}
CenterLine* CenterLine::copy() const
{
CenterLine* newCL = new CenterLine();
newCL->m_start = m_start;
newCL->m_end = m_end;
newCL->m_end = m_end;
newCL->m_mode = m_mode;
newCL->m_hShift = m_hShift;
newCL->m_vShift = m_vShift;
@@ -1384,7 +1384,7 @@ CenterLine* CenterLine::copy() const
newCL->m_faces = m_faces;
newCL->m_edges = m_edges;
newCL->m_verts = m_verts;
TechDraw::BaseGeomPtr newGeom = m_geometry->copy();
newCL->m_geometry = newGeom;
@@ -1439,7 +1439,7 @@ PyObject* CenterLine::getPyObject()
{
if (PythonObject.is(Py::_None())) {
// ref counter is set to 1
PythonObject = Py::Object(new CenterLinePy(this),true);
PythonObject = Py::Object(new CenterLinePy(this), true);
}
return Py::new_reference_to(PythonObject);
}
@@ -1492,7 +1492,7 @@ bool CenterLine::getFlip()
}
//------------------------------------------------------------------------------
TYPESYSTEM_SOURCE(TechDraw::GeomFormat,Base::Persistence)
TYPESYSTEM_SOURCE(TechDraw::GeomFormat, Base::Persistence)
GeomFormat::GeomFormat() :
m_geomIndex(-1)
@@ -1505,7 +1505,7 @@ GeomFormat::GeomFormat() :
createNewTag();
}
GeomFormat::GeomFormat(GeomFormat* gf)
GeomFormat::GeomFormat(GeomFormat* gf)
{
m_geomIndex = gf->m_geomIndex;
m_format.m_style = gf->m_format.m_style;
@@ -1534,14 +1534,14 @@ GeomFormat::~GeomFormat()
void GeomFormat::dump(const char* title) const
{
Base::Console().Message("GF::dump - %s \n",title);
Base::Console().Message("GF::dump - %s \n",toString().c_str());
Base::Console().Message("GF::dump - %s \n", title);
Base::Console().Message("GF::dump - %s \n", toString().c_str());
}
std::string GeomFormat::toString() const
{
std::stringstream ss;
ss << m_geomIndex << ",$$$," <<
ss << m_geomIndex << ", $$$, " <<
m_format.toString();
return ss.str();
}
@@ -1639,7 +1639,7 @@ PyObject* GeomFormat::getPyObject()
{
if (PythonObject.is(Py::_None())) {
// ref counter is set to 1
PythonObject = Py::Object(new GeomFormatPy(this),true);
PythonObject = Py::Object(new GeomFormatPy(this), true);
}
return Py::new_reference_to(PythonObject);
}

View File

@@ -28,6 +28,7 @@
#include <boost/uuid/uuid.hpp>
#include <App/FeaturePython.h>
#include <App/Material.h>
#include <Base/Persistence.h>
#include <Base/Vector3D.h>
@@ -148,7 +149,7 @@ public:
CosmeticEdge* clone() const;
Base::Vector3d permaStart; //persistent unscaled start/end points in View coords
Base::Vector3d permaEnd;
Base::Vector3d permaEnd;
double permaRadius;
// void unscaleEnds(double scale);
TechDraw::BaseGeomPtr m_geometry;
@@ -191,13 +192,13 @@ public:
CenterLine(CenterLine* cl);
//set m_faces after using next 3 ctors
CenterLine(TechDraw::BaseGeomPtr bg,
int m = CLMODE::VERTICAL,
int m = CLMODE::VERTICAL,
double h = 0.0,
double v = 0.0,
double r = 0.0,
double x = 0.0);
CenterLine(Base::Vector3d p1, Base::Vector3d p2,
int m = CLMODE::VERTICAL,
int m = CLMODE::VERTICAL,
double h = 0.0,
double v = 0.0,
double r = 0.0,
@@ -288,7 +289,7 @@ public:
protected:
void initialize();
void createNewTag();
void assignTag(const TechDraw::CenterLine* cl);

View File

@@ -132,19 +132,19 @@ void CosmeticEdgePy::setFormat(Py::Object arg)
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;
bool visible = 1;
TechDraw::CosmeticEdge* ce = this->getCosmeticEdgePtr();
if (PyTuple_Check(pTuple)) {
int tSize = (int) PyTuple_Size(pTuple);
if (tSize > 3) {
PyObject* pStyle = PyTuple_GetItem(pTuple,0);
PyObject* pStyle = PyTuple_GetItem(pTuple, 0);
style = (int) PyLong_AsLong(pStyle);
PyObject* pWeight = PyTuple_GetItem(pTuple,1);
PyObject* pWeight = PyTuple_GetItem(pTuple, 1);
weight = PyFloat_AsDouble(pWeight);
PyObject* pColor = PyTuple_GetItem(pTuple,2);
PyObject* pColor = PyTuple_GetItem(pTuple, 2);
c = DrawUtil::pyTupleToColor(pColor);
PyObject* pVisible = PyTuple_GetItem(pTuple,3);
PyObject* pVisible = PyTuple_GetItem(pTuple, 3);
visible = (bool) PyLong_AsLong(pVisible);
ce->m_format.m_style = style;
@@ -236,8 +236,8 @@ void CosmeticEdgePy::setStart(Py::Object arg)
pNew = DrawUtil::invertY(pNew);
Base::Vector3d pEnd = getCosmeticEdgePtr()->permaEnd;
gp_Pnt gp1(pNew.x,pNew.y,pNew.z);
gp_Pnt gp2(pEnd.x,pEnd.y,pEnd.z);
gp_Pnt gp1(pNew.x, pNew.y, pNew.z);
gp_Pnt gp2(pEnd.x, pEnd.y, pEnd.z);
TopoDS_Edge e = BRepBuilderAPI_MakeEdge(gp1, gp2);
// auto oldGeom = getCosmeticEdgePtr()->m_geometry;
getCosmeticEdgePtr()->m_geometry = TechDraw::BaseGeom::baseFactory(e);
@@ -270,8 +270,8 @@ void CosmeticEdgePy::setEnd(Py::Object arg)
pNew = DrawUtil::invertY(pNew);
Base::Vector3d pStart = getCosmeticEdgePtr()->permaStart;
gp_Pnt gp1(pNew.x,pNew.y,pNew.z);
gp_Pnt gp2(pStart.x,pStart.y,pStart.z);
gp_Pnt gp1(pNew.x, pNew.y, pNew.z);
gp_Pnt gp2(pStart.x, pStart.y, pStart.z);
TopoDS_Edge e = BRepBuilderAPI_MakeEdge(gp2, gp1);
// auto oldGeom = getCosmeticEdgePtr()->m_geometry;
getCosmeticEdgePtr()->m_geometry = TechDraw::BaseGeom::baseFactory(e);

View File

@@ -43,32 +43,32 @@ using namespace std;
EXTENSION_PROPERTY_SOURCE(TechDraw::CosmeticExtension, App::DocumentObjectExtension)
CosmeticExtension::CosmeticExtension()
CosmeticExtension::CosmeticExtension()
{
static const char *cgroup = "Cosmetics";
EXTENSION_ADD_PROPERTY_TYPE(CosmeticVertexes, (nullptr), cgroup, App::Prop_Output, "CosmeticVertex Save/Restore");
EXTENSION_ADD_PROPERTY_TYPE(CosmeticEdges, (nullptr), cgroup, App::Prop_Output, "CosmeticEdge Save/Restore");
EXTENSION_ADD_PROPERTY_TYPE(CenterLines ,(nullptr),cgroup,App::Prop_Output,"Geometry format Save/Restore");
EXTENSION_ADD_PROPERTY_TYPE(GeomFormats ,(nullptr),cgroup,App::Prop_Output,"Geometry format Save/Restore");
EXTENSION_ADD_PROPERTY_TYPE(CenterLines ,(nullptr), cgroup, App::Prop_Output, "Geometry format Save/Restore");
EXTENSION_ADD_PROPERTY_TYPE(GeomFormats ,(nullptr), cgroup, App::Prop_Output, "Geometry format Save/Restore");
initExtensionType(CosmeticExtension::getExtensionClassTypeId());
}
CosmeticExtension::~CosmeticExtension()
CosmeticExtension::~CosmeticExtension()
{
}
//void CosmeticExtension::extHandleChangedPropertyName(Base::XMLReader &reader,
// const char* TypeName,
//void CosmeticExtension::extHandleChangedPropertyName(Base::XMLReader &reader,
// const char* TypeName,
// const char* PropName)
//{
//}
//==============================================================================
//CosmeticVertex x,y are stored as unscaled, but mirrored (inverted Y) values.
//if you are creating a CV based on calculations of scaled geometry, you need to
//unscale x,y before creation.
//CosmeticVertex x, y are stored as unscaled, but mirrored (inverted Y) values.
//if you are creating a CV based on calculations of scaled geometry, you need to
//unscale x, y before creation.
//if you are creating a CV based on calculations of mirrored geometry, you need to
//mirror again before creation.
@@ -107,7 +107,7 @@ TechDraw::CosmeticVertex* CosmeticExtension::getCosmeticVertex(std::string tagSt
// used when selecting
TechDraw::CosmeticVertex* CosmeticExtension::getCosmeticVertexBySelection(std::string name) const
{
// Base::Console().Message("CEx::getCVBySelection(%s)\n",name.c_str());
// Base::Console().Message("CEx::getCVBySelection(%s)\n", name.c_str());
CosmeticVertex* result = nullptr;
App::DocumentObject* extObj = const_cast<App::DocumentObject*> (getExtendedObject());
TechDraw::DrawViewPart* dvp = dynamic_cast<TechDraw::DrawViewPart*>(extObj);
@@ -122,7 +122,7 @@ TechDraw::CosmeticVertex* CosmeticExtension::getCosmeticVertexBySelection(std::s
return result;
}
//overload for index only
//overload for index only
TechDraw::CosmeticVertex* CosmeticExtension::getCosmeticVertexBySelection(int i) const
{
// Base::Console().Message("CEx::getCVBySelection(%d)\n", i);
@@ -159,7 +159,7 @@ void CosmeticExtension::removeCosmeticVertex(std::vector<std::string> delTags)
std::string CosmeticExtension::addCosmeticEdge(Base::Vector3d start,
Base::Vector3d end)
{
// Base::Console().Message("CEx::addCosmeticEdge(s,e)\n");
// Base::Console().Message("CEx::addCosmeticEdge(s, e)\n");
std::vector<CosmeticEdge*> edges = CosmeticEdges.getValues();
TechDraw::CosmeticEdge* ce = new TechDraw::CosmeticEdge(start, end);
edges.push_back(ce);
@@ -204,7 +204,7 @@ TechDraw::CosmeticEdge* CosmeticExtension::getCosmeticEdge(std::string tagString
// used when selecting
TechDraw::CosmeticEdge* CosmeticExtension::getCosmeticEdgeBySelection(std::string name) const
{
// Base::Console().Message("CEx::getCEBySelection(%s)\n",name.c_str());
// Base::Console().Message("CEx::getCEBySelection(%s)\n", name.c_str());
CosmeticEdge* result = nullptr;
App::DocumentObject* extObj = const_cast<App::DocumentObject*> (getExtendedObject());
TechDraw::DrawViewPart* dvp = dynamic_cast<TechDraw::DrawViewPart*>(extObj);
@@ -214,13 +214,13 @@ TechDraw::CosmeticEdge* CosmeticExtension::getCosmeticEdgeBySelection(std::strin
TechDraw::BaseGeomPtr base = dvp->getGeomByIndex(idx);
if (!base)
return result;
if (!base->getCosmeticTag().empty())
result = getCosmeticEdge(base->getCosmeticTag());
return result;
}
//overload for index only
//overload for index only
TechDraw::CosmeticEdge* CosmeticExtension::getCosmeticEdgeBySelection(int i) const
{
// Base::Console().Message("CEx::getCEBySelection(%d)\n", i);
@@ -311,7 +311,7 @@ TechDraw::CenterLine* CosmeticExtension::getCenterLine(std::string tagString) co
// used when selecting
TechDraw::CenterLine* CosmeticExtension::getCenterLineBySelection(std::string name) const
{
// Base::Console().Message("CEx::getCLBySelection(%s)\n",name.c_str());
// Base::Console().Message("CEx::getCLBySelection(%s)\n", name.c_str());
CenterLine* result = nullptr;
App::DocumentObject* extObj = const_cast<App::DocumentObject*> (getExtendedObject());
TechDraw::DrawViewPart* dvp = dynamic_cast<TechDraw::DrawViewPart*>(extObj);
@@ -326,7 +326,7 @@ TechDraw::CenterLine* CosmeticExtension::getCenterLineBySelection(std::string na
return result;
}
//overload for index only
//overload for index only
TechDraw::CenterLine* CosmeticExtension::getCenterLineBySelection(int i) const
{
// Base::Console().Message("CEx::getCLBySelection(%d)\n", i);
@@ -392,7 +392,7 @@ TechDraw::GeomFormat* CosmeticExtension::getGeomFormat(std::string tagString) co
// used when selecting
TechDraw::GeomFormat* CosmeticExtension::getGeomFormatBySelection(std::string name) const
{
// Base::Console().Message("CEx::getCEBySelection(%s)\n",name.c_str());
// Base::Console().Message("CEx::getCEBySelection(%s)\n", name.c_str());
GeomFormat* result = nullptr;
App::DocumentObject* extObj = const_cast<App::DocumentObject*> (getExtendedObject());
TechDraw::DrawViewPart* dvp = dynamic_cast<TechDraw::DrawViewPart*>(extObj);
@@ -409,7 +409,7 @@ TechDraw::GeomFormat* CosmeticExtension::getGeomFormatBySelection(std::string na
return result;
}
//overload for index only
//overload for index only
TechDraw::GeomFormat* CosmeticExtension::getGeomFormatBySelection(int i) const
{
// Base::Console().Message("CEx::getCEBySelection(%d)\n", i);
@@ -436,7 +436,7 @@ void CosmeticExtension::removeGeomFormat(std::string delTag)
PyObject* CosmeticExtension::getExtensionPyObject(void) {
if (ExtensionPythonObject.is(Py::_None())){
// ref counter is set to 1
ExtensionPythonObject = Py::Object(new CosmeticExtensionPy(this),true);
ExtensionPythonObject = Py::Object(new CosmeticExtensionPy(this), true);
}
return Py::new_reference_to(ExtensionPythonObject);
}

View File

@@ -135,12 +135,12 @@ void CosmeticVertexPy::setPoint(Py::Object arg)
PyObject* p = arg.ptr();
if (PyObject_TypeCheck(p, &(Base::VectorPy::Type))) {
Base::Vector3d point = static_cast<Base::VectorPy*>(p)->value();
getCosmeticVertexPtr()->permaPoint =
getCosmeticVertexPtr()->permaPoint =
DrawUtil::invertY(point);
}
else if (PyObject_TypeCheck(p, &PyTuple_Type)) {
Base::Vector3d point = Base::getVectorFromTuple<double>(p);
getCosmeticVertexPtr()->permaPoint =
getCosmeticVertexPtr()->permaPoint =
DrawUtil::invertY(point);
}
else {

View File

@@ -203,7 +203,7 @@ std::pair<Base::Vector3d, Base::Vector3d> DrawDimHelper::minMax(DrawViewPart* dv
}
//can't use Bnd_Box2d here as BndLib_Add2dCurve::Add adds the poles of splines to the box.
//poles are not necessarily on the curve! 3d Bnd_Box does it properly.
//poles are not necessarily on the curve! 3d Bnd_Box does it properly.
//this has to be the bbx of the selected edges, not the dvp!!!
double minX, minY, minZ, maxX, maxY, maxZ;
edgeBbx.Get(minX, minY, minZ, maxX, maxY, maxZ);
@@ -236,7 +236,7 @@ std::pair<Base::Vector3d, Base::Vector3d> DrawDimHelper::minMax(DrawViewPart* dv
Handle(Geom2d_Line) boundaryTop = new Geom2d_Line(topMid, xDir);
gp_Pnt2d topPoint = findClosestPoint(hTCurve2dList,
boundaryTop);
refMin = Base::Vector3d(bottomPoint.X(),bottomPoint.Y(), 0.0);
refMin = Base::Vector3d(bottomPoint.X(), bottomPoint.Y(), 0.0);
refMax = Base::Vector3d(topPoint.X(), topPoint.Y(), 0.0);
}
@@ -352,7 +352,7 @@ DrawViewDimension* DrawDimHelper::makeDistDim(DrawViewPart* dvp,
Base::Vector3d cleanMin = DrawUtil::invertY(inMin);
std::string tag1 = dvp->addCosmeticVertex(cleanMin);
int iGV1 = dvp->add1CVToGV(tag1);
Base::Vector3d cleanMax = DrawUtil::invertY(inMax);
std::string tag2 = dvp->addCosmeticVertex(cleanMax);
int iGV2 = dvp->add1CVToGV(tag2);
@@ -374,11 +374,11 @@ DrawViewDimension* DrawDimHelper::makeDistDim(DrawViewPart* dvp,
objs.push_back(dvp);
if (extent) {
Base::Interpreter().runStringArg("App.activeDocument().addObject('TechDraw::DrawViewDimExtent','%s')",
Base::Interpreter().runStringArg("App.activeDocument().addObject('TechDraw::DrawViewDimExtent', '%s')",
dimName.c_str());
} else {
Base::Interpreter().runStringArg("App.activeDocument().addObject('TechDraw::DrawViewDimension','%s')",
Base::Interpreter().runStringArg("App.activeDocument().addObject('TechDraw::DrawViewDimension', '%s')",
dimName.c_str());
}
@@ -386,7 +386,7 @@ DrawViewDimension* DrawDimHelper::makeDistDim(DrawViewPart* dvp,
dimName.c_str(), dimType.c_str());
Base::Interpreter().runStringArg("App.activeDocument().%s.addView(App.activeDocument().%s)",
pageName.c_str(),dimName.c_str());
pageName.c_str(), dimName.c_str());
dim = dynamic_cast<TechDraw::DrawViewDimension *>(doc->getObject(dimName.c_str()));
if (!dim) {

View File

@@ -20,8 +20,8 @@
* *
***************************************************************************/
#ifndef _DrawDimHelper_h_
#define _DrawDimHelper_h_
#ifndef DrawDimHelper_h_
#define DrawDimHelper_h_
#include <Mod/TechDraw/TechDrawGlobal.h>
@@ -43,7 +43,7 @@ class TechDrawExport hTrimCurve {
hTrimCurve(Handle(Geom2d_Curve) hCurveIn,
double parm1,
double parm2);
~hTrimCurve() {}
~hTrimCurve() = default;
Handle(Geom2d_Curve) hCurve;
double first;

View File

@@ -95,13 +95,13 @@ DrawGeomHatch::DrawGeomHatch()
{
static const char *vgroup = "GeomHatch";
ADD_PROPERTY_TYPE(Source,(nullptr),vgroup,(App::PropertyType)(App::Prop_None),"The View + Face to be crosshatched");
ADD_PROPERTY_TYPE(Source, (nullptr), vgroup, (App::PropertyType)(App::Prop_None), "The View + Face to be crosshatched");
Source.setScope(App::LinkScope::Global);
ADD_PROPERTY_TYPE(FilePattern ,(prefGeomHatchFile()),vgroup,App::Prop_None,"The crosshatch pattern file for this area");
ADD_PROPERTY_TYPE(PatIncluded, (""), vgroup,App::Prop_None,
ADD_PROPERTY_TYPE(FilePattern ,(prefGeomHatchFile()), vgroup, App::Prop_None, "The crosshatch pattern file for this area");
ADD_PROPERTY_TYPE(PatIncluded, (""), vgroup, App::Prop_None,
"Embedded Pat hatch file. System use only."); // n/a to end users
ADD_PROPERTY_TYPE(NamePattern,(prefGeomHatchName()),vgroup,App::Prop_None,"The name of the pattern");
ADD_PROPERTY_TYPE(ScalePattern,(1.0),vgroup,App::Prop_None,"GeomHatch pattern size adjustment");
ADD_PROPERTY_TYPE(NamePattern, (prefGeomHatchName()), vgroup, App::Prop_None, "The name of the pattern");
ADD_PROPERTY_TYPE(ScalePattern, (1.0), vgroup, App::Prop_None, "GeomHatch pattern size adjustment");
ScalePattern.setConstraints(&scaleRange);
m_saveFile = "";
@@ -112,10 +112,6 @@ DrawGeomHatch::DrawGeomHatch()
}
DrawGeomHatch::~DrawGeomHatch()
{
}
void DrawGeomHatch::onChanged(const App::Property* prop)
{
if (!isRestoring()) {
@@ -212,7 +208,7 @@ std::vector<PATLineSpec> DrawGeomHatch::getDecodedSpecsFromFile()
{
std::string fileSpec = PatIncluded.getValue();
std::string myPattern = NamePattern.getValue();
return getDecodedSpecsFromFile(fileSpec,myPattern);
return getDecodedSpecsFromFile(fileSpec, myPattern);
}
@@ -223,10 +219,10 @@ std::vector<PATLineSpec> DrawGeomHatch::getDecodedSpecsFromFile(std::string file
std::vector<PATLineSpec> result;
Base::FileInfo fi(fileSpec);
if (!fi.isReadable()) {
Base::Console().Error("DrawGeomHatch::getDecodedSpecsFromFile not able to open %s!\n",fileSpec.c_str());
Base::Console().Error("DrawGeomHatch::getDecodedSpecsFromFile not able to open %s!\n", fileSpec.c_str());
return result;
}
result = PATLineSpec::getSpecsForPattern(fileSpec,myPattern);
result = PATLineSpec::getSpecsForPattern(fileSpec, myPattern);
return result;
}
@@ -240,7 +236,7 @@ std::vector<LineSet> DrawGeomHatch::getTrimmedLines(int i) //get the trimmed
Base::Console().Log("DGH::getTrimmedLines - no source geometry\n");
return result;
}
return getTrimmedLines(source, m_lineSets,i, ScalePattern.getValue());
return getTrimmedLines(source, m_lineSets, i, ScalePattern.getValue());
}
/* static */
@@ -252,7 +248,7 @@ std::vector<LineSet> DrawGeomHatch::getTrimmedLinesSection(DrawViewSection* sou
std::vector<LineSet> result;
gp_Pln p;
Base::Vector3d vfc = DrawUtil::getFaceCenter(f);
gp_Pnt fc(vfc.x, vfc.y, vfc.z);
gp_Pnt fc(vfc.x, vfc.y, vfc.z);
double dir = -1.0;
if (fc.Z() < 0.0) {
dir = -dir;
@@ -260,7 +256,7 @@ std::vector<LineSet> DrawGeomHatch::getTrimmedLinesSection(DrawViewSection* sou
Base::Vector3d stdZ(0.0, 0.0, 1.0);
Base::Vector3d offset = stdZ * p.Distance(fc) * dir;
//f may be above or below paper plane and must be moved so Common operation in
//f may be above or below paper plane and must be moved so Common operation in
//getTrimmedLines succeeds
TopoDS_Shape moved = TechDraw::moveShape(f,
offset);
@@ -275,7 +271,7 @@ std::vector<LineSet> DrawGeomHatch::getTrimmedLinesSection(DrawViewSection* sou
//! get hatch lines trimmed to face outline
std::vector<LineSet> DrawGeomHatch::getTrimmedLines(DrawViewPart* source, std::vector<LineSet> lineSets, int iface, double scale )
{
TopoDS_Face face = extractFace(source,iface);
TopoDS_Face face = extractFace(source, iface);
std::vector<LineSet> result = getTrimmedLines(source,
lineSets,
face,
@@ -314,7 +310,7 @@ std::vector<LineSet> DrawGeomHatch::getTrimmedLines(DrawViewPart* source,
builder.Add(grid, c);
}
//Common(Compound,Face)
//Common(Compound, Face)
BRepAlgoAPI_Common mkCommon(face, grid);
if ((!mkCommon.IsDone()) ||
(mkCommon.Shape().IsNull()) ) {
@@ -336,7 +332,7 @@ std::vector<LineSet> DrawGeomHatch::getTrimmedLines(DrawViewPart* source,
for ( int i = 1 ; i <= mapOfEdges.Extent() ; i++ ) { //remember, TopExp makes no promises about the order it finds edges
const TopoDS_Edge& edge = TopoDS::Edge(mapOfEdges(i));
if (edge.IsNull()) {
Base::Console().Log("INFO - DGH::getTrimmedLines - edge: %d is NULL\n",i);
Base::Console().Log("INFO - DGH::getTrimmedLines - edge: %d is NULL\n", i);
continue;
}
resultEdges.push_back(edge);
@@ -347,7 +343,7 @@ std::vector<LineSet> DrawGeomHatch::getTrimmedLines(DrawViewPart* source,
for (auto& e: resultEdges) {
TechDraw::BaseGeomPtr base = BaseGeom::baseFactory(e);
if (!base) {
Base::Console().Log("FAIL - DGH::getTrimmedLines - baseFactory failed for edge: %d\n",i);
Base::Console().Log("FAIL - DGH::getTrimmedLines - baseFactory failed for edge: %d\n", i);
throw Base::ValueError("DGH::getTrimmedLines - baseFactory failed");
}
resultGeoms.push_back(base);
@@ -365,8 +361,8 @@ std::vector<TopoDS_Edge> DrawGeomHatch::makeEdgeOverlay(PATLineSpec hl, Bnd_Box
{
std::vector<TopoDS_Edge> result;
double minX,maxX,minY,maxY,minZ,maxZ;
b.Get(minX,minY,minZ,maxX,maxY,maxZ);
double minX, maxX, minY, maxY, minZ, maxZ;
b.Get(minX, minY, minZ, maxX, maxY, maxZ);
Base::Vector3d start;
Base::Vector3d end;
@@ -392,9 +388,9 @@ std::vector<TopoDS_Edge> DrawGeomHatch::makeEdgeOverlay(PATLineSpec hl, Bnd_Box
// make repeats
for (int i = 0; i < repeatTotal; i++) {
Base::Vector3d newStart(minX,yStart + float(i)*interval,0);
Base::Vector3d newEnd(maxX,yStart + float(i)*interval,0);
TopoDS_Edge newLine = makeLine(newStart,newEnd);
Base::Vector3d newStart(minX, yStart + float(i)*interval, 0);
Base::Vector3d newEnd(maxX, yStart + float(i)*interval, 0);
TopoDS_Edge newLine = makeLine(newStart, newEnd);
result.push_back(newLine);
}
} else if ((angle == 90.0) ||
@@ -408,14 +404,14 @@ std::vector<TopoDS_Edge> DrawGeomHatch::makeEdgeOverlay(PATLineSpec hl, Bnd_Box
// make repeats
for (int i = 0; i < repeatTotal; i++) {
Base::Vector3d newStart(xStart + float(i)*interval,minY,0);
Base::Vector3d newEnd(xStart + float(i)*interval,maxY,0);
TopoDS_Edge newLine = makeLine(newStart,newEnd);
Base::Vector3d newStart(xStart + float(i)*interval, minY, 0);
Base::Vector3d newEnd(xStart + float(i)*interval, maxY, 0);
TopoDS_Edge newLine = makeLine(newStart, newEnd);
result.push_back(newLine);
}
//TODO: check if this makes 2-3 extra lines. might be some "left" lines on "right" side of vv
} else if (angle > 0) { //oblique (bottom left -> top right)
//ex: 60,0,0,0,4.0,25,-25
//ex: 60, 0,0, 0,4.0, 25, -25
// Base::Console().Message("TRACE - DGH-makeEdgeOverlay - making angle > 0\n");
double xLeftAtom = origin.x + (minY - origin.y)/slope; //the "atom" is the fill line that passes through the
//pattern-origin (not necc. R2 origin)
@@ -429,13 +425,13 @@ std::vector<TopoDS_Edge> DrawGeomHatch::makeEdgeOverlay(PATLineSpec hl, Bnd_Box
//make repeats
for (int i = 0; i < repeatTotal; i++) {
Base::Vector3d newStart(leftStartX + (float(i) * interval),minY,0);
Base::Vector3d newEnd (leftEndX + (float(i) * interval),maxY,0);
TopoDS_Edge newLine = makeLine(newStart,newEnd);
Base::Vector3d newStart(leftStartX + (float(i) * interval), minY, 0);
Base::Vector3d newEnd (leftEndX + (float(i) * interval), maxY, 0);
TopoDS_Edge newLine = makeLine(newStart, newEnd);
result.push_back(newLine);
}
} else { //oblique (bottom right -> top left)
// ex: -60,0,0,0,4.0,25.0,-12.5,12.5,-6
// ex: -60, 0,0, 0,4.0, 25.0, -12.5, 12.5, -6
// Base::Console().Message("TRACE - DGH-makeEdgeOverlay - making angle < 0\n");
double xRightAtom = origin.x + ((minY - origin.y)/slope); //x-coord of left end of Atom line
double xLeftAtom = origin.x + ((maxY - origin.y)/slope); //x-coord of right end of Atom line
@@ -447,9 +443,9 @@ std::vector<TopoDS_Edge> DrawGeomHatch::makeEdgeOverlay(PATLineSpec hl, Bnd_Box
// make repeats
for (int i = 0; i < repeatTotal; i++) {
Base::Vector3d newStart(leftStartX + float(i)*interval,minY,0);
Base::Vector3d newEnd(leftEndX + float(i)*interval,maxY,0);
TopoDS_Edge newLine = makeLine(newStart,newEnd);
Base::Vector3d newStart(leftStartX + float(i)*interval, minY, 0);
Base::Vector3d newEnd(leftEndX + float(i)*interval, maxY, 0);
TopoDS_Edge newLine = makeLine(newStart, newEnd);
result.push_back(newLine);
}
}
@@ -460,11 +456,11 @@ std::vector<TopoDS_Edge> DrawGeomHatch::makeEdgeOverlay(PATLineSpec hl, Bnd_Box
TopoDS_Edge DrawGeomHatch::makeLine(Base::Vector3d s, Base::Vector3d e)
{
TopoDS_Edge result;
gp_Pnt start(s.x,s.y,0.0);
gp_Pnt end(e.x,e.y,0.0);
gp_Pnt start(s.x, s.y, 0.0);
gp_Pnt end(e.x, e.y, 0.0);
TopoDS_Vertex v1 = BRepBuilderAPI_MakeVertex(start);
TopoDS_Vertex v2 = BRepBuilderAPI_MakeVertex(end);
BRepBuilderAPI_MakeEdge makeEdge1(v1,v2);
BRepBuilderAPI_MakeEdge makeEdge1(v1, v2);
result = makeEdge1.Edge();
return result;
}
@@ -473,7 +469,7 @@ TopoDS_Edge DrawGeomHatch::makeLine(Base::Vector3d s, Base::Vector3d e)
//! these will be clipped to shape on the gui side
std::vector<LineSet> DrawGeomHatch::getFaceOverlay(int fdx)
{
// Base::Console().Message("TRACE - DGH::getFaceOverlay(%d)\n",fdx);
// Base::Console().Message("TRACE - DGH::getFaceOverlay(%d)\n", fdx);
std::vector<LineSet> result;
DrawViewPart* source = getSourceView();
if (!source ||
@@ -482,7 +478,7 @@ std::vector<LineSet> DrawGeomHatch::getFaceOverlay(int fdx)
return result;
}
TopoDS_Face face = extractFace(source,fdx);
TopoDS_Face face = extractFace(source, fdx);
Bnd_Box bBox;
BRepBndLib::AddOptimal(face, bBox);
@@ -496,7 +492,7 @@ std::vector<LineSet> DrawGeomHatch::getFaceOverlay(int fdx)
for (auto& e: candidates) {
TechDraw::BaseGeomPtr base = BaseGeom::baseFactory(e);
if (!base) {
Base::Console().Log("FAIL - DGH::getFaceOverlay - baseFactory failed for edge: %d\n",i);
Base::Console().Log("FAIL - DGH::getFaceOverlay - baseFactory failed for edge: %d\n", i);
throw Base::ValueError("DGH::getFaceOverlay - baseFactory failed");
}
resultGeoms.push_back(base);
@@ -519,9 +515,9 @@ TopoDS_Face DrawGeomHatch::extractFace(DrawViewPart* source, int iface )
std::vector<TopoDS_Wire> faceWires = source->getWireForFace(iface);
//build face(s) from geometry
gp_Pnt gOrg(0.0,0.0,0.0);
gp_Dir gDir(0.0,0.0,1.0);
gp_Pln plane(gOrg,gDir);
gp_Pnt gOrg(0.0, 0.0, 0.0);
gp_Dir gDir(0.0, 0.0, 1.0);
gp_Pln plane(gOrg, gDir);
BRepBuilderAPI_MakeFace mkFace(plane, faceWires.front(), true);
std::vector<TopoDS_Wire>::iterator itWire = ++faceWires.begin(); //starting with second wire
@@ -538,7 +534,7 @@ TopoDS_Face DrawGeomHatch::extractFace(DrawViewPart* source, int iface )
try {
// mirror about the Y axis
gp_Trsf mirrorTransform;
mirrorTransform.SetMirror( gp_Ax2(gp_Pnt(0.0,0.0,0.0), gp_Dir(0, 1, 0)) );
mirrorTransform.SetMirror( gp_Ax2(gp_Pnt(0.0, 0.0, 0.0), gp_Dir(0, 1, 0)) );
BRepBuilderAPI_Transform mkTrf(face, mirrorTransform);
temp = mkTrf.Shape();
}
@@ -553,7 +549,7 @@ TopoDS_Face DrawGeomHatch::extractFace(DrawViewPart* source, int iface )
PyObject *DrawGeomHatch::getPyObject()
{
if (PythonObject.is(Py::_None())) {
PythonObject = Py::Object(new DrawGeomHatchPy(this),true);
PythonObject = Py::Object(new DrawGeomHatchPy(this), true);
}
return Py::new_reference_to(PythonObject);
}
@@ -570,7 +566,7 @@ void DrawGeomHatch::replacePatIncluded(std::string newPatFile)
}
}
void DrawGeomHatch::onDocumentRestored()
void DrawGeomHatch::onDocumentRestored()
{
// Base::Console().Message("DGH::onDocumentRestored()\n");
if (PatIncluded.isEmpty()) {
@@ -636,7 +632,7 @@ std::string DrawGeomHatch::prefGeomHatchName()
Base::Reference<ParameterGrp> hGrp = App::GetApplication().GetUserParameter()
.GetGroup("BaseApp")->GetGroup("Preferences")->GetGroup("Mod/TechDraw/PAT");
std::string defaultNamePattern = "Diamond";
std::string result = hGrp->GetASCII("NamePattern",defaultNamePattern.c_str());
std::string result = hGrp->GetASCII("NamePattern", defaultNamePattern.c_str());
if (result.empty()) {
result = defaultNamePattern;
}
@@ -648,7 +644,7 @@ App::Color DrawGeomHatch::prefGeomHatchColor()
Base::Reference<ParameterGrp> hGrp = App::GetApplication().GetUserParameter()
.GetGroup("BaseApp")->GetGroup("Preferences")->GetGroup("Mod/TechDraw/Colors");
App::Color fcColor;
fcColor.setPackedValue(hGrp->GetUnsigned("GeomHatch", 0x00FF0000));
fcColor.setPackedValue(hGrp->GetUnsigned("GeomHatch", 0x00FF0000));
return fcColor;
}

View File

@@ -20,8 +20,8 @@
* *
***************************************************************************/
#ifndef _TechDraw_DrawGeomHatch_h_
#define _TechDraw_DrawGeomHatch_h_
#ifndef TechDraw_DrawGeomHatch_h_
#define TechDraw_DrawGeomHatch_h_
#include <Mod/TechDraw/TechDrawGlobal.h>
@@ -54,7 +54,7 @@ class TechDrawExport DrawGeomHatch : public App::DocumentObject
public:
DrawGeomHatch();
virtual ~DrawGeomHatch();
~DrawGeomHatch() = default;
App::PropertyLinkSub Source; //the dvX & face(s) this crosshatch belongs to
App::PropertyFile FilePattern;

View File

@@ -63,16 +63,12 @@ DrawHatch::DrawHatch(void)
ADD_PROPERTY_TYPE(Source, (nullptr), vgroup, (App::PropertyType)(App::Prop_None), "The View + Face to be hatched");
Source.setScope(App::LinkScope::Global);
ADD_PROPERTY_TYPE(HatchPattern, (prefSvgHatch()), vgroup, App::Prop_None, "The hatch pattern file for this area");
ADD_PROPERTY_TYPE(SvgIncluded, (""), vgroup,App::Prop_None,
ADD_PROPERTY_TYPE(SvgIncluded, (""), vgroup, App::Prop_None,
"Embedded SVG hatch file. System use only."); // n/a to end users
std::string svgFilter("SVG files (*.svg *.SVG);;Bitmap files(*.jpg *.jpeg *.png *.bmp);;All files (*)");
HatchPattern.setFilter(svgFilter);
}
DrawHatch::~DrawHatch()
{
}
void DrawHatch::onChanged(const App::Property* prop)
{
if (!isRestoring()) {
@@ -123,12 +119,12 @@ PyObject *DrawHatch::getPyObject(void)
{
if (PythonObject.is(Py::_None())) {
// ref counter is set to 1
PythonObject = Py::Object(new DrawHatchPy(this),true);
PythonObject = Py::Object(new DrawHatchPy(this), true);
}
return Py::new_reference_to(PythonObject);
}
bool DrawHatch::faceIsHatched(int i,std::vector<TechDraw::DrawHatch*> hatchObjs)
bool DrawHatch::faceIsHatched(int i, std::vector<TechDraw::DrawHatch*> hatchObjs)
{
bool result = false;
bool found = false;
@@ -167,7 +163,7 @@ bool DrawHatch::affectsFace(int i)
//remove a subElement(Face) from Source PropertyLinkSub
bool DrawHatch::removeSub(std::string toRemove)
{
// Base::Console().Message("DH::removeSub(%s)\n",toRemove.c_str());
// Base::Console().Message("DH::removeSub(%s)\n", toRemove.c_str());
bool removed = false;
const std::vector<std::string> &sourceNames = Source.getSubValues();
std::vector<std::string> newList;
@@ -187,7 +183,7 @@ bool DrawHatch::removeSub(std::string toRemove)
bool DrawHatch::removeSub(int i)
{
// Base::Console().Message("DH::removeSub(%d)\n",i);
// Base::Console().Message("DH::removeSub(%d)\n", i);
std::stringstream ss;
ss << "Face" << i;
return removeSub(ss.str());
@@ -211,7 +207,7 @@ void DrawHatch::replaceFileIncluded(std::string newSvgFile)
}
}
void DrawHatch::onDocumentRestored()
void DrawHatch::onDocumentRestored()
{
//if this is a restore, we should be checking for SvgIncluded empty,
// if it is, set it up from hatchPattern,

View File

@@ -20,8 +20,8 @@
* *
***************************************************************************/
#ifndef _TechDraw_DrawHatch_h_
#define _TechDraw_DrawHatch_h_
#ifndef TechDraw_DrawHatch_h_
#define TechDraw_DrawHatch_h_
#include <Mod/TechDraw/TechDrawGlobal.h>
@@ -44,7 +44,7 @@ class TechDrawExport DrawHatch : public App::DocumentObject
public:
DrawHatch();
~DrawHatch() override;
~DrawHatch() = default;
App::PropertyLinkSub Source; // the dvp & face this hatch belongs to
App::PropertyFile HatchPattern;
@@ -66,10 +66,10 @@ public:
bool removeSub(std::string toRemove);
bool removeSub(int i);
bool empty();
static bool faceIsHatched(int i,std::vector<TechDraw::DrawHatch*> hatchObjs);
static bool faceIsHatched(int i, std::vector<TechDraw::DrawHatch*> hatchObjs);
static std::string prefSvgHatch();
static App::Color prefSvgHatchColor();
bool isSvgHatch() const;
bool isBitmapHatch() const;

View File

@@ -72,42 +72,38 @@ DrawLeaderLine::DrawLeaderLine()
{
static const char *group = "Leader";
ADD_PROPERTY_TYPE(LeaderParent,(nullptr),group,(App::PropertyType)(App::Prop_None),
ADD_PROPERTY_TYPE(LeaderParent, (nullptr), group, (App::PropertyType)(App::Prop_None),
"View to which this leader is attached");
LeaderParent.setScope(App::LinkScope::Global);
ADD_PROPERTY_TYPE(WayPoints,(Base::Vector3d()) ,group, App::Prop_None,
ADD_PROPERTY_TYPE(WayPoints, (Base::Vector3d()) ,group, App::Prop_None,
"Intermediate points for Leader line");
// EndType.setEnums(ArrowTypeEnums);
// ADD_PROPERTY(EndType,(prefEnd()));
// ADD_PROPERTY(EndType, (prefEnd()));
StartSymbol.setEnums(ArrowPropEnum::ArrowTypeEnums);
ADD_PROPERTY(StartSymbol,(0l)); //filled arrow
ADD_PROPERTY(StartSymbol, (0l)); //filled arrow
// ADD_PROPERTY_TYPE(StartSymbol, (0), group, App::Prop_None, "Symbol (arrowhead) for start of line");
EndSymbol.setEnums(ArrowPropEnum::ArrowTypeEnums);
ADD_PROPERTY(EndSymbol,(7l)); //no symbol
ADD_PROPERTY(EndSymbol, (7l)); //no symbol
// ADD_PROPERTY_TYPE(EndSymbol, (0), group, App::Prop_None, "Symbol (arrowhead) for end of line");
ADD_PROPERTY_TYPE(Scalable ,(false),group,App::Prop_None,"Scale line with LeaderParent");
ADD_PROPERTY_TYPE(AutoHorizontal ,(getDefAuto()),group,App::Prop_None,"Forces last line segment to be horizontal");
ADD_PROPERTY_TYPE(Scalable ,(false), group, App::Prop_None, "Scale line with LeaderParent");
ADD_PROPERTY_TYPE(AutoHorizontal ,(getDefAuto()), group, App::Prop_None, "Forces last line segment to be horizontal");
//hide the DrawView properties that don't apply to Leader
ScaleType.setStatus(App::Property::ReadOnly,true);
ScaleType.setStatus(App::Property::Hidden,true);
Scale.setStatus(App::Property::ReadOnly,true);
Scale.setStatus(App::Property::Hidden,true);
Rotation.setStatus(App::Property::ReadOnly,true);
Rotation.setStatus(App::Property::Hidden,true);
Caption.setStatus(App::Property::Hidden,true);
ScaleType.setStatus(App::Property::ReadOnly, true);
ScaleType.setStatus(App::Property::Hidden, true);
Scale.setStatus(App::Property::ReadOnly, true);
Scale.setStatus(App::Property::Hidden, true);
Rotation.setStatus(App::Property::ReadOnly, true);
Rotation.setStatus(App::Property::Hidden, true);
Caption.setStatus(App::Property::Hidden, true);
LockPosition.setValue(true);
LockPosition.setStatus(App::Property::Hidden,true);
}
DrawLeaderLine::~DrawLeaderLine()
{
LockPosition.setStatus(App::Property::Hidden, true);
}
void DrawLeaderLine::onChanged(const App::Property* prop)
@@ -142,7 +138,7 @@ App::DocumentObjectExecReturn *DrawLeaderLine::execute()
if (!keepUpdated()) {
return App::DocumentObject::StdReturn;
}
adjustLastSegment();
adjustLastSegment();
overrideKeepUpdated(false);
return DrawView::execute();
}
@@ -288,7 +284,7 @@ bool DrawLeaderLine::getDefAuto() const
{
Base::Reference<ParameterGrp> hGrp = App::GetApplication().GetUserParameter().GetGroup("BaseApp")->
GetGroup("Preferences")->GetGroup("Mod/TechDraw/LeaderLines");
bool result = hGrp->GetBool("AutoHorizontal",true);
bool result = hGrp->GetBool("AutoHorizontal", true);
return result;
}
@@ -297,7 +293,7 @@ PyObject *DrawLeaderLine::getPyObject()
{
if (PythonObject.is(Py::_None())) {
// ref counter is set to 1
PythonObject = Py::Object(new DrawLeaderLinePy(this),true);
PythonObject = Py::Object(new DrawLeaderLinePy(this), true);
}
return Py::new_reference_to(PythonObject);
}

View File

@@ -20,8 +20,8 @@
* *
***************************************************************************/
#ifndef _TechDraw_DrawLeaderLine_h_
#define _TechDraw_DrawLeaderLine_h_
#ifndef TechDraw_DrawLeaderLine_h_
#define TechDraw_DrawLeaderLine_h_
#include <Mod/TechDraw/TechDrawGlobal.h>
@@ -41,7 +41,7 @@ class TechDrawExport DrawLeaderLine : public TechDraw::DrawView
public:
DrawLeaderLine();
~DrawLeaderLine() override;
~DrawLeaderLine() = default;
App::PropertyLink LeaderParent;
App::PropertyVectorList WayPoints;
@@ -61,7 +61,7 @@ public:
return "TechDrawGui::ViewProviderLeader";
}
PyObject *getPyObject() override;
QRectF getRect() const override { return QRectF(0,0,1,1);}
QRectF getRect() const override { return { 0, 0,1, 1}; }
Base::Vector3d getAttachPoint();
DrawView* getBaseView() const;

View File

@@ -93,7 +93,7 @@ DrawPage::DrawPage(void)
Base::Reference<ParameterGrp> hGrp = App::GetApplication().GetUserParameter().
GetGroup("BaseApp")->GetGroup("Preferences")->
GetGroup("Mod/TechDraw/General");
double defScale = hGrp->GetFloat("DefaultScale",1.0);
double defScale = hGrp->GetFloat("DefaultScale", 1.0);
ADD_PROPERTY_TYPE(Scale, (defScale), group, (App::PropertyType)(App::Prop_None), "Scale factor for this Page");
ADD_PROPERTY_TYPE(NextBalloonIndex, (1), group, (App::PropertyType)(App::Prop_None),
@@ -119,7 +119,7 @@ void DrawPage::onChanged(const App::Property* prop)
if (!isRestoring() &&
!isUnsetting()) {
//would be nice if this message was displayed immediately instead of after the recomputeFeature
Base::Console().Message("Rebuilding Views for: %s/%s\n",getNameInDocument(),Label.getValue());
Base::Console().Message("Rebuilding Views for: %s/%s\n", getNameInDocument(), Label.getValue());
updateAllViews();
purgeTouched();
}
@@ -156,7 +156,7 @@ void DrawPage::onChanged(const App::Property* prop)
// TODO: Also update Template graphic.
}
App::DocumentObject::onChanged(prop);
App::DocumentObject::onChanged(prop);
}
//Page is just a container. It doesn't "do" anything.
@@ -165,7 +165,7 @@ App::DocumentObjectExecReturn *DrawPage::execute(void)
return App::DocumentObject::execute();
}
// this is now irrelevant, b/c DP::execute doesn't do anything.
// this is now irrelevant, b/c DP::execute doesn't do anything.
short DrawPage::mustExecute() const
{
short result = 0;
@@ -185,7 +185,7 @@ PyObject *DrawPage::getPyObject(void)
{
if (PythonObject.is(Py::_None())){
// ref counter is set to 1
PythonObject = Py::Object(new DrawPagePy(this),true);
PythonObject = Py::Object(new DrawPagePy(this), true);
}
return Py::new_reference_to(PythonObject);
@@ -271,7 +271,7 @@ int DrawPage::addView(App::DocumentObject *docObj)
//check if View fits on Page
if ( !view->checkFit(this) ) {
Base::Console().Warning("%s is larger than page. Will be scaled.\n",view->getNameInDocument());
Base::Console().Warning("%s is larger than page. Will be scaled.\n", view->getNameInDocument());
view->ScaleType.setValue("Automatic");
}
@@ -365,7 +365,7 @@ void DrawPage::updateAllViews()
}
}
std::vector<App::DocumentObject*> DrawPage::getAllViews(void)
std::vector<App::DocumentObject*> DrawPage::getAllViews(void)
{
auto views = Views.getValues(); //list of docObjects
std::vector<App::DocumentObject*> allViews;
@@ -375,7 +375,7 @@ std::vector<App::DocumentObject*> DrawPage::getAllViews(void)
TechDraw::DrawProjGroup* dpg = static_cast<TechDraw::DrawProjGroup*>(v);
if (dpg) { //can't really happen!
std::vector<App::DocumentObject*> pgViews = dpg->Views.getValues();
allViews.insert(allViews.end(),pgViews.begin(),pgViews.end());
allViews.insert(allViews.end(), pgViews.begin(), pgViews.end());
}
}
}
@@ -407,7 +407,7 @@ void DrawPage::unsetupObject()
}
std::vector<App::DocumentObject*> emptyViews; //probably superfluous
Views.setValues(emptyViews);
}
catch (...) {
Base::Console().Warning("DP::unsetupObject - %s - error while deleting children\n", getNameInDocument());
@@ -431,11 +431,11 @@ int DrawPage::getNextBalloonIndex(void)
}
void DrawPage::handleChangedPropertyType(
Base::XMLReader &reader, const char * TypeName, App::Property * prop)
Base::XMLReader &reader, const char * TypeName, App::Property * prop)
{
if (prop == &Scale) {
App::PropertyFloat tmp;
if (strcmp(tmp.getTypeId().getName(),TypeName)==0) { //property in file is Float
if (strcmp(tmp.getTypeId().getName(), TypeName)==0) { //property in file is Float
tmp.setContainer(this);
tmp.Restore(reader);
double tmpValue = tmp.getValue();
@@ -445,7 +445,7 @@ void DrawPage::handleChangedPropertyType(
Scale.setValue(1.0);
}
} else {
// has Scale prop that isn't Float!
// has Scale prop that isn't Float!
Base::Console().Log("DrawPage::Restore - old Document Scale is Not Float!\n");
// no idea
}
@@ -471,7 +471,7 @@ bool DrawPage::GlobalUpdateDrawings(void)
{
Base::Reference<ParameterGrp> hGrp = App::GetApplication().GetUserParameter()
.GetGroup("BaseApp")->GetGroup("Preferences")->GetGroup("Mod/TechDraw/General");
bool result = hGrp->GetBool("GlobalUpdateDrawings", true);
bool result = hGrp->GetBool("GlobalUpdateDrawings", true);
return result;
}
@@ -480,7 +480,7 @@ bool DrawPage::AllowPageOverride(void)
{
Base::Reference<ParameterGrp> hGrp = App::GetApplication().GetUserParameter()
.GetGroup("BaseApp")->GetGroup("Preferences")->GetGroup("Mod/TechDraw/General");
bool result = hGrp->GetBool("AllowPageOverride", true);
bool result = hGrp->GetBool("AllowPageOverride", true);
return result;
}

View File

@@ -20,8 +20,8 @@
* *
***************************************************************************/
#ifndef _DrawPage_h_
#define _DrawPage_h_
#ifndef DrawPage_h_
#define DrawPage_h_
#include <Mod/TechDraw/TechDrawGlobal.h>
@@ -50,7 +50,7 @@ public:
App::PropertyFloatConstraint Scale;
App::PropertyEnumeration ProjectionType; // First or Third Angle
App::PropertyInteger NextBalloonIndex;
/** @name methods override Feature */
@@ -94,10 +94,10 @@ public:
bool isUnsetting() { return nowUnsetting; }
void requestPaint();
std::vector<App::DocumentObject*> getAllViews() ;
DrawViewPart *balloonParent; //could be many balloons on page?
DrawViewPart *balloonParent; //could be many balloons on page?
int getNextBalloonIndex();
void updateAllViews();
static bool GlobalUpdateDrawings();
static bool AllowPageOverride();

View File

@@ -29,7 +29,7 @@ std::string DrawPagePy::representation() const
PyObject* DrawPagePy::addView(PyObject* args)
{
//this implements iRC = pyPage.addView(pyView) -or-
//doCommand(Doc,"App.activeDocument().%s.addView(App.activeDocument().%s)",PageName.c_str(),FeatName.c_str());
//doCommand(Doc, "App.activeDocument().%s.addView(App.activeDocument().%s)", PageName.c_str(), FeatName.c_str());
PyObject *pcDocObj;
if (!PyArg_ParseTuple(args, "O!", &(App::DocumentObjectPy::Type), &pcDocObj)) {
@@ -50,7 +50,7 @@ PyObject* DrawPagePy::addView(PyObject* args)
PyObject* DrawPagePy::removeView(PyObject* args)
{
//this implements iRC = pyPage.removeView(pyView) -or-
//doCommand(Doc,"App.activeDocument().%s.removeView(App.activeDocument().%s)",PageName.c_str(),FeatName.c_str());
//doCommand(Doc, "App.activeDocument().%s.removeView(App.activeDocument().%s)", PageName.c_str(), FeatName.c_str());
PyObject *pcDocObj;
if (!PyArg_ParseTuple(args, "O!", &(App::DocumentObjectPy::Type), &pcDocObj)) {

View File

@@ -51,7 +51,7 @@ PROPERTY_SOURCE(TechDraw::DrawParametricTemplate, TechDraw::DrawTemplate)
DrawParametricTemplate::DrawParametricTemplate()
{
static const char *group = "Page";
ADD_PROPERTY_TYPE(Template ,(""),group, (App::PropertyType) App::Prop_None,"Template script");
ADD_PROPERTY_TYPE(Template ,(""), group, (App::PropertyType) App::Prop_None, "Template script");
}
DrawParametricTemplate::~DrawParametricTemplate()
@@ -63,7 +63,7 @@ PyObject *DrawParametricTemplate::getPyObject()
{
if (PythonObject.is(Py::_None())) {
// ref counter is set to 1
PythonObject = Py::Object(new DrawParametricTemplatePy(this),true);
PythonObject = Py::Object(new DrawParametricTemplatePy(this), true);
}
return Py::new_reference_to(PythonObject);
}

View File

@@ -20,8 +20,8 @@
* *
***************************************************************************/
#ifndef _TECHDRAW_DrawParametricTemplate_h_
#define _TECHDRAW_DrawParametricTemplate_h_
#ifndef TECHDRAW_DrawParametricTemplate_h_
#define TECHDRAW_DrawParametricTemplate_h_
#include <Mod/TechDraw/TechDrawGlobal.h>

View File

@@ -74,7 +74,7 @@ PyObject* DrawParametricTemplatePy::drawLine(PyObject *args)
if (!PyArg_ParseTuple(args, "dddd", &x1, &y1, &x2, &y2))
return nullptr;
getDrawParametricTemplatePtr()->drawLine(x1,y1,x2,y2);
getDrawParametricTemplatePtr()->drawLine(x1, y1, x2, y2);
Py_Return;

View File

@@ -69,12 +69,12 @@ DrawProjGroup::DrawProjGroup()
Base::Reference<ParameterGrp> hGrp = App::GetApplication().GetUserParameter().GetGroup("BaseApp")->
GetGroup("Preferences")->GetGroup("Mod/TechDraw/General");
bool autoDist = hGrp->GetBool("AutoDist",true);
bool autoDist = hGrp->GetBool("AutoDist", true);
ADD_PROPERTY_TYPE(Source, (nullptr), group, App::Prop_None, "Shape to view");
Source.setScope(App::LinkScope::Global);
Source.setAllowExternal(true);
ADD_PROPERTY_TYPE(XSource, (nullptr), group,App::Prop_None, "External 3D Shape to view");
ADD_PROPERTY_TYPE(XSource, (nullptr), group, App::Prop_None, "External 3D Shape to view");
ADD_PROPERTY_TYPE(Anchor, (nullptr), group, App::Prop_None, "The root view to align projections with");
Anchor.setScope(App::LinkScope::Global);
@@ -91,10 +91,6 @@ DrawProjGroup::DrawProjGroup()
Caption.setStatus(App::Property::Hidden, true);
}
DrawProjGroup::~DrawProjGroup()
{
}
//TODO: this duplicates code in DVP
std::vector<App::DocumentObject*> DrawProjGroup::getAllSources() const
{
@@ -165,7 +161,7 @@ void DrawProjGroup::onChanged(const App::Property* prop)
// }
if (prop == &Rotation) {
if (!DrawUtil::fpCompare(Rotation.getValue(),0.0)) {
if (!DrawUtil::fpCompare(Rotation.getValue(), 0.0)) {
Rotation.setValue(0.0);
purgeTouched();
Base::Console().Log("DPG: Projection Groups do not rotate. Change ignored.\n");
@@ -312,7 +308,7 @@ double DrawProjGroup::autoScale(double w, double h) const
double xScale = w / bigBox.width(); // > 1 page bigger than figure
double yScale = h / bigBox.height(); // < 1 page is smaller than figure
double newScale = std::min(xScale,yScale);
double newScale = std::min(xScale, yScale);
return DrawUtil::sensibleScale(newScale);
}
@@ -325,7 +321,7 @@ QRectF DrawProjGroup::getRect() const
QRectF DrawProjGroup::getRect(bool scaled) const
{
// Base::Console().Message("DPG::getRect - views: %d\n", Views.getValues().size());
DrawProjGroupItem *viewPtrs[10];
std::array<DrawProjGroupItem*, MAXPROJECTIONCOUNT> viewPtrs;
arrangeViewPointers(viewPtrs);
double totalWidth, totalHeight;
getViewArea(viewPtrs, totalWidth, totalHeight, scaled);
@@ -337,19 +333,19 @@ QRectF DrawProjGroup::getRect(bool scaled) const
rectW *= fudge;
rectH *= fudge;
return QRectF(0,0,rectW,rectH);
return { 0, 0, rectW, rectH };
}
//find area consumed by Views only - scaled or unscaled
void DrawProjGroup::getViewArea(DrawProjGroupItem *viewPtrs[10],
void DrawProjGroup::getViewArea(std::array<DrawProjGroupItem*, MAXPROJECTIONCOUNT>& viewPtrs,
double &width, double &height,
bool scaled) const
{
// Get the child view bounding boxes
Base::BoundBox3d bboxes[10];
std::array<Base::BoundBox3d, MAXPROJECTIONCOUNT> bboxes;
makeViewBbs(viewPtrs, bboxes, scaled);
//TODO: note that TLF/TRF/BLF,BRF extend a bit farther than a strict row/col arrangement would suggest.
//TODO: note that TLF/TRF/BLF, BRF extend a bit farther than a strict row/col arrangement would suggest.
//get widest view in each row/column
double col0w = std::max(std::max(bboxes[0].LengthX(), bboxes[3].LengthX()), bboxes[7].LengthX()),
col1w = std::max(std::max(bboxes[1].LengthX(), bboxes[4].LengthX()), bboxes[8].LengthX()),
@@ -371,7 +367,7 @@ App::DocumentObject * DrawProjGroup::getProjObj(const char *viewProjType) const
if (!projPtr) {
//if an element in Views is not a DPGI, something really bad has happened somewhere
Base::Console().Log("PROBLEM - DPG::getProjObj - non DPGI entry in Views! %s / %s\n",
getNameInDocument(),viewProjType);
getNameInDocument(), viewProjType);
throw Base::TypeError("Error: projection in DPG list is not a DPGI!");
} else if(strcmp(viewProjType, projPtr->Type.getValueAsString()) == 0 ) {
return it;
@@ -388,7 +384,7 @@ DrawProjGroupItem* DrawProjGroup::getProjItem(const char *viewProjType) const
if (!result && docObj) {
//should never have a item in DPG that is not a DPGI.
Base::Console().Log("PROBLEM - DPG::getProjItem finds non-DPGI in Group %s / %s\n",
getNameInDocument(),viewProjType);
getNameInDocument(), viewProjType);
throw Base::TypeError("Error: projection in DPG list is not a DPGI!");
}
return result;
@@ -421,7 +417,7 @@ bool DrawProjGroup::hasProjection(const char *viewProjType) const
if (!view) {
//should never have a item in DPG that is not a DPGI.
Base::Console().Log("PROBLEM - DPG::hasProjection finds non-DPGI in Group %s / %s\n",
getNameInDocument(),viewProjType);
getNameInDocument(), viewProjType);
throw Base::TypeError("Error: projection in DPG list is not a DPGI!");
}
@@ -435,11 +431,11 @@ bool DrawProjGroup::hasProjection(const char *viewProjType) const
App::DocumentObject * DrawProjGroup::addProjection(const char *viewProjType)
{
DrawProjGroupItem *view( nullptr );
std::pair<Base::Vector3d,Base::Vector3d> vecs;
std::pair<Base::Vector3d, Base::Vector3d> vecs;
DrawPage* dp = findParentPage();
if (!dp)
Base::Console().Error("DPG:addProjection - %s - DPG is not on a page!\n",getNameInDocument());
Base::Console().Error("DPG:addProjection - %s - DPG is not on a page!\n", getNameInDocument());
if ( checkViewProjType(viewProjType) && !hasProjection(viewProjType) ) {
std::string FeatName = getDocument()->getUniqueObjectName("ProjItem");
@@ -449,7 +445,7 @@ App::DocumentObject * DrawProjGroup::addProjection(const char *viewProjType)
if (!view && docObj) {
//should never happen that we create a DPGI that isn't a DPGI!!
Base::Console().Log("PROBLEM - DPG::addProjection - created a non DPGI! %s / %s\n",
getNameInDocument(),viewProjType);
getNameInDocument(), viewProjType);
throw Base::TypeError("Error: new projection is not a DPGI!");
}
if (view) { //coverity CID 151722
@@ -474,7 +470,7 @@ App::DocumentObject * DrawProjGroup::addProjection(const char *viewProjType)
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.setStatus(App::Property::ReadOnly, true); //Front should stay locked.
view->LockPosition.purgeTouched();
}
// addView(view); //from DrawViewCollection
@@ -507,7 +503,7 @@ int DrawProjGroup::removeProjection(const char *viewProjType)
} else {
//if an element in Views is not a DPGI, something really bad has happened somewhere
Base::Console().Log("PROBLEM - DPG::removeProjection - tries to remove non DPGI! %s / %s\n",
getNameInDocument(),viewProjType);
getNameInDocument(), viewProjType);
throw Base::TypeError("Error: projection in DPG list is not a DPGI!");
}
}
@@ -542,31 +538,31 @@ int DrawProjGroup::purgeProjections()
return Views.getValues().size();
}
std::pair<Base::Vector3d,Base::Vector3d> DrawProjGroup::getDirsFromFront(DrawProjGroupItem* view)
std::pair<Base::Vector3d, Base::Vector3d> DrawProjGroup::getDirsFromFront(DrawProjGroupItem* view)
{
std::pair<Base::Vector3d,Base::Vector3d> result;
std::pair<Base::Vector3d, Base::Vector3d> result;
std::string viewType = view->Type.getValueAsString();
result = getDirsFromFront(viewType);
return result;
}
std::pair<Base::Vector3d,Base::Vector3d> DrawProjGroup::getDirsFromFront(std::string viewType)
std::pair<Base::Vector3d, Base::Vector3d> DrawProjGroup::getDirsFromFront(std::string viewType)
{
// Base::Console().Message("DPG::getDirsFromFront(%s)\n", viewType.c_str());
std::pair<Base::Vector3d,Base::Vector3d> result;
std::pair<Base::Vector3d, Base::Vector3d> result;
Base::Vector3d projDir, rotVec;
DrawProjGroupItem* anch = getAnchor();
if (!anch) {
Base::Console().Warning("DPG::getDirsFromFront - %s - No Anchor!\n",Label.getValue());
Base::Console().Warning("DPG::getDirsFromFront - %s - No Anchor!\n", Label.getValue());
throw Base::RuntimeError("Project Group missing Anchor projection item");
}
Base::Vector3d dirAnch = anch->Direction.getValue();
Base::Vector3d rotAnch = anch->getXDirection();
result = std::make_pair(dirAnch,rotAnch);
result = std::make_pair(dirAnch, rotAnch);
Base::Vector3d org(0.0,0.0,0.0);
Base::Vector3d org(0.0, 0.0, 0.0);
gp_Ax2 anchorCS = anch->getProjectionCS(org);
gp_Pnt gOrg(0.0, 0.0, 0.0);
gp_Dir gDir = anchorCS.Direction();
@@ -629,11 +625,11 @@ std::pair<Base::Vector3d,Base::Vector3d> DrawProjGroup::getDirsFromFront(std::st
gp_Vec(gDir));
rotVec = dir2vec(newXDir);
} else {
Base::Console().Error("DrawProjGroup - %s unknown projection: %s\n",getNameInDocument(),viewType.c_str());
Base::Console().Error("DrawProjGroup - %s unknown projection: %s\n", getNameInDocument(), viewType.c_str());
return result;
}
result = std::make_pair(projDir,rotVec);
result = std::make_pair(projDir, rotVec);
return result;
}
@@ -656,15 +652,15 @@ gp_Dir DrawProjGroup::vec2dir(Base::Vector3d v)
//this can be improved. this implementation positions views too far apart.
Base::Vector3d DrawProjGroup::getXYPosition(const char *viewTypeCStr)
{
// Base::Console().Message("DPG::getXYPosition(%s)\n",Label.getValue());
// Base::Console().Message("DPG::getXYPosition(%s)\n", Label.getValue());
Base::Vector3d result(0.0,0.0,0.0);
//Front view position is always (0,0)
Base::Vector3d result(0.0, 0.0, 0.0);
//Front view position is always (0, 0)
if (strcmp(viewTypeCStr, "Front") == 0 ) { // Front!
return result;
}
const int idxCount = 10;
DrawProjGroupItem *viewPtrs[idxCount];
const int idxCount = MAXPROJECTIONCOUNT;
std::array<DrawProjGroupItem*, MAXPROJECTIONCOUNT> viewPtrs;
arrangeViewPointers(viewPtrs);
int viewIndex = getViewIndex(viewTypeCStr);
@@ -681,7 +677,7 @@ Base::Vector3d DrawProjGroup::getXYPosition(const char *viewTypeCStr)
std::vector<Base::Vector3d> position(idxCount);
// Calculate bounding boxes for each displayed view
Base::BoundBox3d bboxes[10];
std::array<Base::BoundBox3d, MAXPROJECTIONCOUNT> bboxes;
makeViewBbs(viewPtrs, bboxes); //scaled
double xSpacing = spacingX.getValue(); //in mm, no scale
@@ -706,7 +702,7 @@ Base::Vector3d DrawProjGroup::getXYPosition(const char *viewTypeCStr)
//if we have iso's, make sure they fit the grid.
if (viewPtrs[0] || viewPtrs[2] || viewPtrs[7] || viewPtrs[9]) {
bigCol = std::max(bigCol,bigRow);
bigCol = std::max(bigCol, bigRow);
bigRow = bigCol;
}
@@ -851,9 +847,9 @@ int DrawProjGroup::getViewIndex(const char *viewTypeCStr) const
return result;
}
void DrawProjGroup::arrangeViewPointers(DrawProjGroupItem *viewPtrs[10]) const
void DrawProjGroup::arrangeViewPointers(std::array<DrawProjGroupItem *, MAXPROJECTIONCOUNT> &viewPtrs) const
{
for (int i=0; i<10; ++i) {
for (int i=0; i < MAXPROJECTIONCOUNT; ++i) {
viewPtrs[i] = nullptr;
}
@@ -919,23 +915,23 @@ void DrawProjGroup::arrangeViewPointers(DrawProjGroupItem *viewPtrs[10]) const
viewPtrs[thirdAngle ? 9 : 0] = oView;
} else {
Base::Console().Warning("DPG: %s - unknown view type: %s. \n",
getNameInDocument(),viewTypeCStr);
getNameInDocument(), viewTypeCStr);
throw Base::TypeError("Unknown view type in DrawProjGroup::arrangeViewPointers.");
}
}
}
} else {
Base::Console().Warning("DPG: %s - unknown Projection convention: %s\n",getNameInDocument(),projType);
Base::Console().Warning("DPG: %s - unknown Projection convention: %s\n", getNameInDocument(), projType);
throw Base::ValueError("Unknown Projection convention in DrawProjGroup::arrangeViewPointers");
}
}
void DrawProjGroup::makeViewBbs(DrawProjGroupItem *viewPtrs[10],
Base::BoundBox3d bboxes[10],
void DrawProjGroup::makeViewBbs(std::array<DrawProjGroupItem *, MAXPROJECTIONCOUNT> &viewPtrs,
std::array<Base::BoundBox3d, MAXPROJECTIONCOUNT> &bboxes,
bool scaled) const
{
Base::BoundBox3d empty(Base::Vector3d(0.0, 0.0, 0.0), 0.0);
for (int i = 0; i < 10; ++i) {
for (int i = 0; i < MAXPROJECTIONCOUNT; ++i) {
bboxes[i] = empty;
if (viewPtrs[i]) {
bboxes[i] = viewPtrs[i]->getBoundingBox();
@@ -1119,11 +1115,11 @@ void DrawProjGroup::updateSecondaryDirs()
Base::Vector3d anchDir = anchor->Direction.getValue();
Base::Vector3d anchRot = anchor->getXDirection();
std::map<std::string, std::pair<Base::Vector3d,Base::Vector3d> > saveVals;
std::map<std::string, std::pair<Base::Vector3d, Base::Vector3d> > saveVals;
std::string key;
std::pair<Base::Vector3d, Base::Vector3d> data;
for (auto& docObj: Views.getValues()) {
std::pair<Base::Vector3d,Base::Vector3d> newDirs;
std::pair<Base::Vector3d, Base::Vector3d> newDirs;
std::string pic;
DrawProjGroupItem* v = static_cast<DrawProjGroupItem*>(docObj);
ProjItemType t = static_cast<ProjItemType>(v->Type.getValue());
@@ -1199,7 +1195,7 @@ void DrawProjGroup::updateSecondaryDirs()
}
void DrawProjGroup::rotate(const std::string &rotationdirection) {
std::pair<Base::Vector3d,Base::Vector3d> newDirs;
std::pair<Base::Vector3d, Base::Vector3d> newDirs;
if(rotationdirection == "Right") newDirs = getDirsFromFront("Left"); // Front -> Right -> Rear -> Left -> Front
else if(rotationdirection == "Left") newDirs = getDirsFromFront("Right"); // Front -> Left -> Rear -> Right -> Front
else if(rotationdirection == "Up") newDirs = getDirsFromFront("Bottom"); // Front -> Top -> Rear -> Bottom -> Front
@@ -1219,10 +1215,10 @@ void DrawProjGroup::spin(const std::string &spindirection)
if(spindirection == "CCW") angle = - M_PI / 2.0; // Top -> Left -> Bottom -> Right -> Top
DrawProjGroupItem* anchor = getAnchor();
Base::Vector3d org(0.0,0.0,0.0);
Base::Vector3d org(0.0, 0.0, 0.0);
Base::Vector3d curRot = anchor->getXDirection();
Base::Vector3d curDir = anchor->Direction.getValue();
Base::Vector3d newRot = DrawUtil::vecRotate(curRot,angle,curDir,org);
Base::Vector3d newRot = DrawUtil::vecRotate(curRot, angle, curDir, org);
anchor->XDirection.setValue(newRot);
updateSecondaryDirs();
@@ -1259,7 +1255,7 @@ void DrawProjGroup::dumpISO(const char * title)
axis = v->getXDirection();
Base::Console().Message("%s: %s/%s\n",
t.c_str(),DrawUtil::formatVector(dir).c_str(),DrawUtil::formatVector(axis).c_str());
t.c_str(), DrawUtil::formatVector(dir).c_str(), DrawUtil::formatVector(axis).c_str());
}
}
@@ -1267,7 +1263,7 @@ PyObject *DrawProjGroup::getPyObject()
{
if (PythonObject.is(Py::_None())) {
// ref counter is set to 1
PythonObject = Py::Object(new DrawProjGroupPy(this),true);
PythonObject = Py::Object(new DrawProjGroupPy(this), true);
}
return Py::new_reference_to(PythonObject);
}

View File

@@ -20,8 +20,8 @@
* *
***************************************************************************/
#ifndef _TECHDRAW_FEATUREVIEWGROUP_H_
#define _TECHDRAW_FEATUREVIEWGROUP_H_
#ifndef TECHDRAW_FEATUREVIEWGROUP_H_
#define TECHDRAW_FEATUREVIEWGROUP_H_
#include <Mod/TechDraw/TechDrawGlobal.h>
@@ -41,6 +41,7 @@ class gp_Pnt;
namespace TechDraw
{
const int MAXPROJECTIONCOUNT = 10;
class DrawProjGroupItem;
@@ -55,7 +56,7 @@ class TechDrawExport DrawProjGroup : public TechDraw::DrawViewCollection
public:
/// Constructor
DrawProjGroup();
~DrawProjGroup() override;
~DrawProjGroup() = default;
App::PropertyLinkList Source;
App::PropertyXLinkList XSource;
@@ -156,15 +157,15 @@ protected:
*/
bool checkViewProjType(const char *in);
void arrangeViewPointers(DrawProjGroupItem *viewPtrs[10]) const;
void arrangeViewPointers(std::array<DrawProjGroupItem*, MAXPROJECTIONCOUNT>& viewPtrs) const;
/// Populates array of 10 BoundBox3d's given DrawProjGroupItem *s
/*!
* If documentScale is set, then returned bounding boxes are scaled as in
* the Drawing. Otherwise, the dimensions are as in object space.
*/
void makeViewBbs(DrawProjGroupItem *viewPtrs[10],
Base::BoundBox3d bboxes[10],
void makeViewBbs(std::array<DrawProjGroupItem*, MAXPROJECTIONCOUNT>& viewPtrs,
std::array<Base::BoundBox3d, MAXPROJECTIONCOUNT>& bboxes,
bool scaled = true) const;
/// Helper for calculateAutomaticScale
@@ -172,7 +173,7 @@ protected:
* Returns a width and height in object-space scale, for the enabled views
* without accounting for their actual X and Y positions or borders.
*/
void getViewArea(DrawProjGroupItem *viewPtrs[10],
void getViewArea(std::array<TechDraw::DrawProjGroupItem *, MAXPROJECTIONCOUNT>& viewPtrs,
double &width, double &height,
bool scaled = true) const;
@@ -192,4 +193,4 @@ protected:
} //namespace TechDraw
#endif // _TECHDRAW_FEATUREVIEWGROUP_H_
#endif // TECHDRAW_FEATUREVIEWGROUP_H_

View File

@@ -64,19 +64,15 @@ DrawProjGroupItem::DrawProjGroupItem(void)
{
Type.setEnums(TypeEnums);
ADD_PROPERTY(Type, ((long)0));
ADD_PROPERTY_TYPE(RotationVector ,(1.0,0.0,0.0) ,"Base",
App::Prop_None,"Deprecated. Use XDirection.");
ADD_PROPERTY_TYPE(RotationVector ,(1.0, 0.0, 0.0) ,"Base",
App::Prop_None, "Deprecated. Use XDirection.");
//projection group controls these
// Direction.setStatus(App::Property::ReadOnly,true);
RotationVector.setStatus(App::Property::ReadOnly,true); //Use XDirection
// Direction.setStatus(App::Property::ReadOnly, true);
RotationVector.setStatus(App::Property::ReadOnly, true); //Use XDirection
ScaleType.setValue("Custom");
Scale.setStatus(App::Property::Hidden,true);
ScaleType.setStatus(App::Property::Hidden,true);
}
DrawProjGroupItem::~DrawProjGroupItem()
{
Scale.setStatus(App::Property::Hidden, true);
ScaleType.setStatus(App::Property::Hidden, true);
}
short DrawProjGroupItem::mustExecute() const
@@ -115,9 +111,9 @@ bool DrawProjGroupItem::showLock(void) const
}
if (isAnchor() && //don't show lock for Front if DPG is not locked
!parentLock) {
!parentLock) {
result = false;
}
}
return result;
}
@@ -164,7 +160,7 @@ void DrawProjGroupItem::postHlrTasks(void)
void DrawProjGroupItem::autoPosition()
{
// Base::Console().Message("DPGI::autoPosition(%s)\n",Label.getValue());
// Base::Console().Message("DPGI::autoPosition(%s)\n", Label.getValue());
if (LockPosition.getValue()) {
return;
}
@@ -175,7 +171,7 @@ void DrawProjGroupItem::autoPosition()
Y.setValue(newPos.y);
requestPaint();
purgeTouched(); //prevents "still touched after recompute" message
getPGroup()->purgeTouched(); //changing dpgi x,y marks parent dpg as touched
getPGroup()->purgeTouched(); //changing dpgi x, y marks parent dpg as touched
}
}
@@ -212,7 +208,7 @@ bool DrawProjGroupItem::isAnchor(void) const
/// get a coord system aligned with Direction and Rotation Vector
gp_Ax2 DrawProjGroupItem::getViewAxis(const Base::Vector3d& pt,
const Base::Vector3d& axis,
const Base::Vector3d& axis,
const bool flip) const
{
Base::Console().Message("DPGI::getViewAxis - deprecated. use getProjectionCS\n");
@@ -222,23 +218,23 @@ gp_Ax2 DrawProjGroupItem::getViewAxis(const Base::Vector3d& pt,
Base::Vector3d rotVec = getXDirection();
// mirror projDir through XZ plane
Base::Vector3d yNorm(0.0,1.0,0.0);
Base::Vector3d yNorm(0.0, 1.0, 0.0);
projDir = projDir - (yNorm * 2.0) * (projDir.Dot(yNorm));
rotVec = rotVec - (yNorm * 2.0) * (rotVec.Dot(yNorm));
if (DrawUtil::checkParallel(projDir,rotVec)) {
if (DrawUtil::checkParallel(projDir, rotVec)) {
Base::Console().Warning("DPGI::getVA - %s - Direction and XDirection parallel. using defaults\n",
getNameInDocument());
}
try {
viewAxis = gp_Ax2(gp_Pnt(pt.x,pt.y,pt.z),
viewAxis = gp_Ax2(gp_Pnt(pt.x, pt.y, pt.z),
gp_Dir(projDir.x, projDir.y, projDir.z),
gp_Dir(rotVec.x, rotVec.y, rotVec.z));
}
catch (Standard_Failure& e4) {
Base::Console().Message("PROBLEM - DPGI (%s) failed to create viewAxis: %s **\n",
getNameInDocument(),e4.GetMessageString());
return TechDraw::getViewAxis(pt,axis,false);
getNameInDocument(), e4.GetMessageString());
return TechDraw::getViewAxis(pt, axis, false);
}
return viewAxis;
@@ -266,7 +262,7 @@ Base::Vector3d DrawProjGroupItem::getXDirection(void) const
prop = getPropertyByName("RotationVector");
if (prop) {
result = RotationVector.getValue();
} else {
Base::Console().Message("DPGI::getXDirection - missing RotationVector and XDirection\n");
}
@@ -313,11 +309,11 @@ double DrawProjGroupItem::getRotateAngle()
nx.Normalize();
Base::Vector3d na = Direction.getValue();
na.Normalize();
Base::Vector3d org(0.0,0.0,0.0);
Base::Vector3d org(0.0, 0.0, 0.0);
viewAxis = getProjectionCS(org);
gp_Dir gxDir = viewAxis.XDirection();
Base::Vector3d origX(gxDir.X(),gxDir.Y(),gxDir.Z());
Base::Vector3d origX(gxDir.X(), gxDir.Y(), gxDir.Z());
origX.Normalize();
double angle = origX.GetAngle(nx);
@@ -335,7 +331,7 @@ double DrawProjGroupItem::getScale(void) const
if (pgroup) {
result = pgroup->getScale();
if (!(result > 0.0)) {
Base::Console().Log("DPGI - %s - bad scale found (%.3f) using 1.0\n",getNameInDocument(),Scale.getValue());
Base::Console().Log("DPGI - %s - bad scale found (%.3f) using 1.0\n", getNameInDocument(), Scale.getValue());
result = 1.0; //kludgy protective fix. autoscale sometimes serves up 0.0!
}
}
@@ -357,7 +353,7 @@ void DrawProjGroupItem::unsetupObject()
if ( getPGroup()->getAnchor() == this &&
!getPGroup()->isUnsetting() ) {
Base::Console().Warning("Warning - DPG (%s/%s) may be corrupt - Anchor deleted\n",
getPGroup()->getNameInDocument(),getPGroup()->Label.getValue());
getPGroup()->getNameInDocument(), getPGroup()->Label.getValue());
getPGroup()->Anchor.setValue(nullptr); //this catches situation where DPGI is deleted w/o DPG::removeProjection
}
@@ -400,7 +396,7 @@ PyObject *DrawProjGroupItem::getPyObject(void)
{
if (PythonObject.is(Py::_None())) {
// ref counter is set to 1
PythonObject = Py::Object(new DrawProjGroupItemPy(this),true);
PythonObject = Py::Object(new DrawProjGroupItemPy(this), true);
}
return Py::new_reference_to(PythonObject);
}

View File

@@ -20,8 +20,8 @@
* *
***************************************************************************/
#ifndef _DrawProjGroupItem_h_
#define _DrawProjGroupItem_h_
#ifndef DrawProjGroupItem_h_
#define DrawProjGroupItem_h_
#include <Mod/TechDraw/TechDrawGlobal.h>
@@ -57,7 +57,7 @@ class TechDrawExport DrawProjGroupItem : public TechDraw::DrawViewPart
public:
/// Constructor
DrawProjGroupItem();
~DrawProjGroupItem() override;
~DrawProjGroupItem() = default;
App::PropertyEnumeration Type;
App::PropertyVector RotationVector; //this is superseded by dvp xdirection
@@ -93,7 +93,8 @@ public:
//DPGI always fits on page since DPG handles scaling
bool checkFit() const override { return true; }
bool checkFit(DrawPage*) const override { return true; }
bool checkFit(DrawPage* page) const override { (void) page; //avoid unused variable warning
return true; }
int countParentPages() const override;
DrawPage* findParentPage() const override;

View File

@@ -111,13 +111,13 @@ std::vector<TopoDS_Edge> DrawProjectSplit::getEdgesForWalker(TopoDS_Shape shape,
BRepBuilderAPI_Copy BuilderCopy(shape);
TopoDS_Shape copyShape = BuilderCopy.Shape();
gp_Pnt inputCenter(0,0,0);
gp_Pnt inputCenter(0, 0,0);
TopoDS_Shape scaledShape;
scaledShape = TechDraw::scaleShape(copyShape,
scale);
// gp_Ax2 viewAxis = TechDraw::getViewAxis(Base::Vector3d(0.0,0.0,0.0),direction);
gp_Ax2 viewAxis = TechDraw::legacyViewAxis1(Base::Vector3d(0.0,0.0,0.0),direction);
TechDraw::GeometryObject* go = buildGeometryObject(scaledShape,viewAxis);
// gp_Ax2 viewAxis = TechDraw::getViewAxis(Base::Vector3d(0.0, 0.0, 0.0), direction);
gp_Ax2 viewAxis = TechDraw::legacyViewAxis1(Base::Vector3d(0.0, 0.0, 0.0), direction);
TechDraw::GeometryObject* go = buildGeometryObject(scaledShape, viewAxis);
result = getEdges(go);
delete go;
@@ -128,7 +128,7 @@ std::vector<TopoDS_Edge> DrawProjectSplit::getEdgesForWalker(TopoDS_Shape shape,
TechDraw::GeometryObject* DrawProjectSplit::buildGeometryObject(TopoDS_Shape shape,
const gp_Ax2& viewAxis)
{
TechDraw::GeometryObject* geometryObject = new TechDraw::GeometryObject("DrawProjectSplit",nullptr);
TechDraw::GeometryObject* geometryObject = new TechDraw::GeometryObject("DrawProjectSplit", nullptr);
if (geometryObject->usePolygonHLR()){
geometryObject->projectShapeWithPolygonAlgo(shape,
@@ -138,7 +138,7 @@ TechDraw::GeometryObject* DrawProjectSplit::buildGeometryObject(TopoDS_Shape sha
geometryObject->projectShape(shape,
viewAxis);
}
geometryObject->extractGeometry(TechDraw::ecHARD, //always show the hard&outline visible lines
true);
geometryObject->extractGeometry(TechDraw::ecOUTLINE,
@@ -149,7 +149,7 @@ TechDraw::GeometryObject* DrawProjectSplit::buildGeometryObject(TopoDS_Shape sha
//! get the projected edges with all their new intersections.
std::vector<TopoDS_Edge> DrawProjectSplit::getEdges(TechDraw::GeometryObject* geometryObject)
{
const std::vector<TechDraw::BaseGeomPtr>& goEdges = geometryObject->getVisibleFaceEdges(true,true);
const std::vector<TechDraw::BaseGeomPtr>& goEdges = geometryObject->getVisibleFaceEdges(true, true);
std::vector<TechDraw::BaseGeomPtr>::const_iterator itEdge = goEdges.begin();
std::vector<TopoDS_Edge> origEdges;
for (;itEdge != goEdges.end(); itEdge++) {
@@ -184,12 +184,12 @@ std::vector<TopoDS_Edge> DrawProjectSplit::getEdges(TechDraw::GeometryObject* ge
continue;
}
if (DrawUtil::isZeroEdge(*itOuter)) {
Base::Console().Message("DPS::extractFaces - outerEdge: %d is ZeroEdge\n",iOuter); //this is not finding ZeroEdges
Base::Console().Message("DPS::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++) {
for (; itInner != faceEdges.end(); ++itInner, iInner++) {
if (iInner == iOuter) {
continue;
}
@@ -209,29 +209,29 @@ std::vector<TopoDS_Edge> DrawProjectSplit::getEdges(TechDraw::GeometryObject* ge
}
double param = -1;
if (isOnEdge((*itInner),v1,param,false)) {
if (isOnEdge((*itInner), v1, param, false)) {
gp_Pnt pnt1 = BRep_Tool::Pnt(v1);
splitPoint s1;
s1.i = iInner;
s1.v = Base::Vector3d(pnt1.X(),pnt1.Y(),pnt1.Z());
s1.v = Base::Vector3d(pnt1.X(), pnt1.Y(), pnt1.Z());
s1.param = param;
splits.push_back(s1);
}
if (isOnEdge((*itInner),v2,param,false)) {
if (isOnEdge((*itInner), v2, param, false)) {
gp_Pnt pnt2 = BRep_Tool::Pnt(v2);
splitPoint s2;
s2.i = iInner;
s2.v = Base::Vector3d(pnt2.X(),pnt2.Y(),pnt2.Z());
s2.v = Base::Vector3d(pnt2.X(), pnt2.Y(), pnt2.Z());
s2.param = param;
splits.push_back(s2);
}
} //inner loop
} //outer loop
std::vector<splitPoint> sorted = sortSplits(splits,true);
std::vector<splitPoint> sorted = sortSplits(splits, true);
auto last = std::unique(sorted.begin(), sorted.end(), DrawProjectSplit::splitEqual); //duplicates to back
sorted.erase(last, sorted.end()); //remove dupls
std::vector<TopoDS_Edge> newEdges = splitEdges(faceEdges,sorted);
std::vector<TopoDS_Edge> newEdges = splitEdges(faceEdges, sorted);
if (newEdges.empty()) {
Base::Console().Log("LOG - DPS::extractFaces - no newEdges\n");
@@ -262,9 +262,9 @@ bool DrawProjectSplit::isOnEdge(TopoDS_Edge e, TopoDS_Vertex v, double& param, b
}
}
if (!outOfBox) {
double dist = DrawUtil::simpleMinDist(v,e);
double dist = DrawUtil::simpleMinDist(v, e);
if (dist < 0.0) {
Base::Console().Error("DPS::isOnEdge - simpleMinDist failed: %.3f\n",dist);
Base::Console().Error("DPS::isOnEdge - simpleMinDist failed: %.3f\n", dist);
result = false;
} else if (dist < Precision::Confusion()) {
const gp_Pnt pt = BRep_Tool::Pnt(v); //have to duplicate method 3 to get param
@@ -272,13 +272,13 @@ bool DrawProjectSplit::isOnEdge(TopoDS_Edge e, TopoDS_Vertex v, double& param, b
const Handle(Geom_Curve) c = adapt.Curve().Curve();
double maxDist = 0.000001; //magic number. less than this gives false positives.
//bool found =
(void) GeomLib_Tool::Parameter(c,pt,maxDist,param); //already know point it on curve
(void) GeomLib_Tool::Parameter(c, pt, maxDist, param); //already know point it on curve
result = true;
}
if (result) {
TopoDS_Vertex v1 = TopExp::FirstVertex(e);
TopoDS_Vertex v2 = TopExp::LastVertex(e);
if (DrawUtil::isSamePoint(v,v1) || DrawUtil::isSamePoint(v,v2)) {
if (DrawUtil::isSamePoint(v, v1) || DrawUtil::isSamePoint(v, v2)) {
if (!allowEnds) {
result = false;
}
@@ -312,7 +312,7 @@ std::vector<TopoDS_Edge> DrawProjectSplit::splitEdges(std::vector<TopoDS_Edge> e
iSplit++;
} else if (ii > iEdge) {
if (!edgeSplits.empty()) { //save *iedge's splits
newEdges = split1Edge(edges[iEdge],edgeSplits);
newEdges = split1Edge(edges[iEdge], edgeSplits);
result.insert(result.end(), newEdges.begin(), newEdges.end());
edgeSplits.clear();
} else {
@@ -325,7 +325,7 @@ std::vector<TopoDS_Edge> DrawProjectSplit::splitEdges(std::vector<TopoDS_Edge> e
}
if (!edgeSplits.empty()) { //handle last batch
newEdges = split1Edge(edges[iEdge],edgeSplits);
newEdges = split1Edge(edges[iEdge], edgeSplits);
result.insert(result.end(), newEdges.begin(), newEdges.end());
edgeSplits.clear();
}
@@ -361,7 +361,7 @@ std::vector<TopoDS_Edge> DrawProjectSplit::split1Edge(TopoDS_Edge e, std::vector
auto parms2 = parms.begin() + 1;
std::vector<double>::iterator psecond = parms2;
std::vector<double>::iterator pstop = parms.end();
for (; psecond != pstop; ++pfirst,++psecond) {
for (; psecond != pstop; ++pfirst, ++psecond) {
try {
BRepBuilderAPI_MakeEdge mkEdge(c, *pfirst, *psecond);
if (mkEdge.IsDone()) {
@@ -381,7 +381,7 @@ std::vector<splitPoint> DrawProjectSplit::sortSplits(std::vector<splitPoint>& s,
std::vector<splitPoint> sorted = s;
std::sort(sorted.begin(), sorted.end(), DrawProjectSplit::splitCompare);
if (ascend) {
std::reverse(sorted.begin(),sorted.end());
std::reverse(sorted.begin(), sorted.end());
}
return sorted;
}
@@ -425,10 +425,10 @@ std::vector<TopoDS_Edge> DrawProjectSplit::removeDuplicateEdges(std::vector<Topo
TopoDS_Vertex v2 = TopExp::LastVertex(e);
item.start = DrawUtil::vertex2Vector(v1);
item.end = DrawUtil::vertex2Vector(v2);
item.startAngle = DrawUtil::angleWithX(e,v1);
item.endAngle = DrawUtil::angleWithX(e,v2);
item.startAngle = DrawUtil::angleWithX(e, v1);
item.endAngle = DrawUtil::angleWithX(e, v2);
//catch reverse-duplicates
if (DrawUtil::vectorLess(item.end,item.start)) {
if (DrawUtil::vectorLess(item.end, item.start)) {
Base::Vector3d vTemp = item.start;
item.start = item.end;
item.end = vTemp;
@@ -441,7 +441,7 @@ std::vector<TopoDS_Edge> DrawProjectSplit::removeDuplicateEdges(std::vector<Topo
idx++;
}
std::vector<edgeSortItem> sorted = sortEdges(temp,true);
std::vector<edgeSortItem> sorted = sortEdges(temp, true);
auto last = std::unique(sorted.begin(), sorted.end(), edgeSortItem::edgeEqual); //duplicates to back
sorted.erase(last, sorted.end()); //remove dupls
@@ -450,7 +450,7 @@ std::vector<TopoDS_Edge> DrawProjectSplit::removeDuplicateEdges(std::vector<Topo
if (e.idx < inEdges.size()) {
result.push_back(inEdges.at(e.idx)); //<<< ***here
} else {
Base::Console().Message("ERROR - DPS::removeDuplicateEdges - access: %d inEdges: %d\n",e.idx,inEdges.size());
Base::Console().Message("ERROR - DPS::removeDuplicateEdges - access: %d inEdges: %d\n", e.idx, inEdges.size());
}
}
return result;
@@ -461,7 +461,7 @@ std::vector<edgeSortItem> DrawProjectSplit::sortEdges(std::vector<edgeSortItem>&
std::vector<edgeSortItem> sorted = e;
std::sort(sorted.begin(), sorted.end(), edgeSortItem::edgeLess);
if (ascend) {
std::reverse(sorted.begin(),sorted.end());
std::reverse(sorted.begin(), sorted.end());
}
return sorted;
}
@@ -496,7 +496,7 @@ std::string edgeSortItem::dump()
} else if (!DrawUtil::fpCompare(e1.endAngle, e2.endAngle)) {
if (e1.endAngle < e2.endAngle) {
result = true;
}
}
} else if (e1.idx < e2.idx) {
result = true;
}
@@ -511,8 +511,8 @@ std::string edgeSortItem::dump()
double endDif = (e1.end - e2.end).Length();
if ( (startDif < Precision::Confusion()) &&
(endDif < Precision::Confusion()) &&
(DrawUtil::fpCompare(e1.startAngle,e2.startAngle)) &&
(DrawUtil::fpCompare(e1.endAngle,e2.endAngle)) ) {
(DrawUtil::fpCompare(e1.startAngle, e2.startAngle)) &&
(DrawUtil::fpCompare(e1.endAngle, e2.endAngle)) ) {
result = true;
}
return result;

View File

@@ -20,8 +20,8 @@
* *
***************************************************************************/
#ifndef _DrawProjectSplit_h_
#define _DrawProjectSplit_h_
#ifndef DrawProjectSplit_h_
#define DrawProjectSplit_h_
#include <Mod/TechDraw/TechDrawGlobal.h>
@@ -57,7 +57,7 @@ public:
startAngle = endAngle = 0.0;
idx = 0;
}
~edgeSortItem() {}
~edgeSortItem() = default;
Base::Vector3d start;
Base::Vector3d end;
@@ -101,4 +101,4 @@ using DrawProjectSplitPython = App::FeaturePythonT<DrawProjectSplit>;
} //namespace TechDraw
#endif // #ifndef _DrawProjectSplit_h_
#endif // #ifndef DrawProjectSplit_h_

View File

@@ -47,21 +47,17 @@ DrawRichAnno::DrawRichAnno()
{
static const char *group = "Text Block";
ADD_PROPERTY_TYPE(AnnoParent,(nullptr),group,(App::PropertyType)(App::Prop_None),
ADD_PROPERTY_TYPE(AnnoParent, (nullptr), group, (App::PropertyType)(App::Prop_None),
"Object to which this annontation is attached");
ADD_PROPERTY_TYPE(AnnoText, (""), group, App::Prop_None, "Annotation text");
ADD_PROPERTY_TYPE(ShowFrame, (true), group, App::Prop_None, "Outline rectangle on/off");
ADD_PROPERTY_TYPE(MaxWidth, (-1.0), group, App::Prop_None, "Width limit before auto wrap");
Caption.setStatus(App::Property::Hidden,true);
Scale.setStatus(App::Property::Hidden,true);
ScaleType.setStatus(App::Property::Hidden,true);
Caption.setStatus(App::Property::Hidden, true);
Scale.setStatus(App::Property::Hidden, true);
ScaleType.setStatus(App::Property::Hidden, true);
}
DrawRichAnno::~DrawRichAnno()
{
}
void DrawRichAnno::onChanged(const App::Property* prop)
{
if (!isRestoring()) {
@@ -71,7 +67,7 @@ void DrawRichAnno::onChanged(const App::Property* prop)
requestPaint();
}
}
DrawView::onChanged(prop);
}
@@ -90,7 +86,7 @@ short DrawRichAnno::mustExecute() const
}
App::DocumentObjectExecReturn *DrawRichAnno::execute()
{
{
// Base::Console().Message("DRA::execute() - @ (%.3f, %.3f)\n", X.getValue(), Y.getValue());
if (!keepUpdated()) {
return App::DocumentObject::StdReturn;
@@ -127,7 +123,7 @@ PyObject *DrawRichAnno::getPyObject()
{
if (PythonObject.is(Py::_None())) {
// ref counter is set to 1
PythonObject = Py::Object(new DrawRichAnnoPy(this),true);
PythonObject = Py::Object(new DrawRichAnnoPy(this), true);
}
return Py::new_reference_to(PythonObject);
}

View File

@@ -20,8 +20,8 @@
* *
***************************************************************************/
#ifndef _TechDraw_DrawRichAnno_h_
#define _TechDraw_DrawRichAnno_h_
#ifndef TechDraw_DrawRichAnno_h_
#define TechDraw_DrawRichAnno_h_
#include <Mod/TechDraw/TechDrawGlobal.h>
@@ -39,7 +39,7 @@ class TechDrawExport DrawRichAnno : public TechDraw::DrawView
public:
DrawRichAnno();
~DrawRichAnno() override;
~DrawRichAnno() = default;
App::PropertyLink AnnoParent;
App::PropertyString AnnoText;
@@ -53,7 +53,7 @@ public:
return "TechDrawGui::ViewProviderRichAnno";
}
PyObject *getPyObject() override;
QRectF getRect() const override { return QRectF(0,0,1,1);}
QRectF getRect() const override { return { 0, 0, 1, 1}; }
DrawView* getBaseView() const;
DrawPage* findParentPage() const override;

View File

@@ -73,9 +73,9 @@ DrawSVGTemplate::DrawSVGTemplate()
ADD_PROPERTY_TYPE(Template, (""), group, App::Prop_Transient, "Template for the page"); //sb TemplateFileName???
// Width and Height properties shouldn't be set by the user
Height.setStatus(App::Property::ReadOnly,true);
Width.setStatus(App::Property::ReadOnly,true);
Orientation.setStatus(App::Property::ReadOnly,true);
Height.setStatus(App::Property::ReadOnly, true);
Width.setStatus(App::Property::ReadOnly, true);
Orientation.setStatus(App::Property::ReadOnly, true);
std::string svgFilter("Svg files (*.svg *.SVG);;All files (*)");
Template.setFilter(svgFilter);
@@ -89,7 +89,7 @@ PyObject *DrawSVGTemplate::getPyObject()
{
if (PythonObject.is(Py::_None())) {
// ref counter is set to 1
PythonObject = Py::Object(new DrawSVGTemplatePy(this),true);
PythonObject = Py::Object(new DrawSVGTemplatePy(this), true);
}
return Py::new_reference_to(PythonObject);
}

View File

@@ -20,8 +20,8 @@
* *
***************************************************************************/
#ifndef _TECHDRAW_DrawSVGTemplate_h_
#define _TECHDRAW_DrawSVGTemplate_h_
#ifndef TECHDRAW_DrawSVGTemplate_h_
#define TECHDRAW_DrawSVGTemplate_h_
#include <Mod/TechDraw/TechDrawGlobal.h>
@@ -81,4 +81,4 @@ using DrawSVGTemplatePython = App::FeaturePythonT<DrawSVGTemplate>;
} //namespace TechDraw
#endif //_TECHDRAW_DrawSVGTemplate_h_
#endif //TECHDRAW_DrawSVGTemplate_h_

View File

@@ -65,7 +65,7 @@ PyObject* DrawSVGTemplatePy::getEditFieldContent(PyObject* args)
{
PyObject* result = nullptr;
char* fieldName;
if (!PyArg_ParseTuple(args, "s",&fieldName)) {
if (!PyArg_ParseTuple(args, "s", &fieldName)) {
Base::Console().Error("Error: DrawSVGTemplatePy::getEditFieldNames - Bad Arg\n");
return nullptr;
}
@@ -81,7 +81,7 @@ PyObject* DrawSVGTemplatePy::setEditFieldContent(PyObject* args)
PyObject* result = Py_True;
char* fieldName;
char* newContent;
if (!PyArg_ParseTuple(args, "ss", &fieldName,&newContent)) {
if (!PyArg_ParseTuple(args, "ss", &fieldName, &newContent)) {
Base::Console().Error("Error: DrawSVGTemplatePy::getEditFieldNames - Bad Args\n");
result = Py_False;
} else {

View File

@@ -78,7 +78,7 @@ PyObject *DrawTemplate::getPyObject()
{
if (PythonObject.is(Py::_None())) {
// ref counter is set to 1
PythonObject = Py::Object(new DrawTemplatePy(this),true);
PythonObject = Py::Object(new DrawTemplatePy(this), true);
}
return Py::new_reference_to(PythonObject);
}

View File

@@ -20,8 +20,8 @@
* *
***************************************************************************/
#ifndef _TECHDRAW_DrawTemplate_h_
#define _TECHDRAW_DrawTemplate_h_
#ifndef TECHDRAW_DrawTemplate_h_
#define TECHDRAW_DrawTemplate_h_
#include <Mod/TechDraw/TechDrawGlobal.h>
@@ -92,4 +92,4 @@ using DrawTemplatePython = App::FeaturePythonT<DrawTemplate>;
#endif //_TECHDRAW_DrawTemplate_h_
#endif //TECHDRAW_DrawTemplate_h_

View File

@@ -47,7 +47,7 @@ DrawTile::DrawTile()
{
static const char *group = "Tile";
ADD_PROPERTY_TYPE(TileParent,(nullptr),group,(App::PropertyType)(App::Prop_None),
ADD_PROPERTY_TYPE(TileParent, (nullptr), group, (App::PropertyType)(App::Prop_None),
"Object to which this tile is attached");
ADD_PROPERTY_TYPE(TileRow, (0), group, App::Prop_None, "Row in parent object\n 0 for arrow side, -1 for other side");
ADD_PROPERTY_TYPE(TileColumn, (0), group, App::Prop_None, "Column in parent object");
@@ -62,10 +62,6 @@ DrawTile::DrawTile()
TileRow.setConstraints(&TileRowConstraints);
}
DrawTile::~DrawTile()
{
}
void DrawTile::onChanged(const App::Property* prop)
{
if (!isRestoring()) {
@@ -108,7 +104,7 @@ PyObject *DrawTile::getPyObject()
{
if (PythonObject.is(Py::_None())) {
// ref counter is set to 1
PythonObject = Py::Object(new DrawTilePy(this),true);
PythonObject = Py::Object(new DrawTilePy(this), true);
}
return Py::new_reference_to(PythonObject);
}

View File

@@ -20,8 +20,8 @@
* *
***************************************************************************/
#ifndef _TechDraw_DrawTile_h_
#define _TechDraw_DrawTile_h_
#ifndef TechDraw_DrawTile_h_
#define TechDraw_DrawTile_h_
#include <Mod/TechDraw/TechDrawGlobal.h>
@@ -39,7 +39,7 @@ class TechDrawExport DrawTile : public App::DocumentObject
public:
DrawTile();
~DrawTile() override;
~DrawTile() = default;
App::PropertyLink TileParent; //eg DrawWeldSymbol
App::PropertyIntegerConstraint TileRow;

View File

@@ -52,7 +52,7 @@ DrawTileWeld::DrawTileWeld()
{
static const char *group = "TileWeld";
ADD_PROPERTY_TYPE(LeftText,(""),group,(App::PropertyType)(App::Prop_None),
ADD_PROPERTY_TYPE(LeftText, (""), group, (App::PropertyType)(App::Prop_None),
"Text before symbol");
ADD_PROPERTY_TYPE(RightText, (nullptr), group, App::Prop_None, "Text after symbol");
ADD_PROPERTY_TYPE(CenterText, (nullptr), group, App::Prop_None, "Text above/below symbol");
@@ -60,7 +60,7 @@ DrawTileWeld::DrawTileWeld()
ADD_PROPERTY_TYPE(SymbolIncluded, (""), group, App::Prop_None,
"Embedded Symbol. System use only."); // n/a to end users
// SymbolFile.setStatus(App::Property::ReadOnly,true);
// SymbolFile.setStatus(App::Property::ReadOnly, true);
std::string svgFilter("Symbol files (*.svg *.SVG);;All files (*)");
SymbolFile.setFilter(svgFilter);
@@ -93,7 +93,7 @@ short DrawTileWeld::mustExecute() const
}
App::DocumentObjectExecReturn *DrawTileWeld::execute()
{
{
// Base::Console().Message("DTW::execute()\n");
return DrawTile::execute();
}
@@ -110,7 +110,7 @@ void DrawTileWeld::replaceSymbolIncluded(std::string newSymbolFile)
}
}
void DrawTileWeld::onDocumentRestored()
void DrawTileWeld::onDocumentRestored()
{
// Base::Console().Message("DTW::onDocumentRestored()\n");
if (SymbolIncluded.isEmpty()) {
@@ -172,7 +172,7 @@ PyObject *DrawTileWeld::getPyObject()
{
if (PythonObject.is(Py::_None())) {
// ref counter is set to 1
PythonObject = Py::Object(new DrawTileWeldPy(this),true);
PythonObject = Py::Object(new DrawTileWeldPy(this), true);
}
return Py::new_reference_to(PythonObject);
}

View File

@@ -20,8 +20,8 @@
* *
***************************************************************************/
#ifndef _TechDraw_DrawTileWeld_h_
#define _TechDraw_DrawTileWeld_h_
#ifndef TechDraw_DrawTileWeld_h_
#define TechDraw_DrawTileWeld_h_
#include <Mod/TechDraw/TechDrawGlobal.h>
@@ -59,7 +59,7 @@ public:
return "TechDrawGui::ViewProviderTile";
}
PyObject *getPyObject() override;
virtual QRectF getRect() const { return QRectF(0,0,1,1);}
virtual QRectF getRect() const { return { 0, 0, 1, 1}; }
void replaceSymbolIncluded(std::string newSymbolFile);
void setupSymbolIncluded();

View File

@@ -23,16 +23,16 @@
#include "PreCompiled.h"
#ifndef _PreComp_
# include <sstream>
# include <cstring>
# include <cstdlib>
#include <sstream>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <string>
# include <exception>
# include <boost/regex.hpp>
# include <QString>
# include <QStringList>
# include <QRegExp>
#include <exception>
#include <boost/regex.hpp>
#include <QString>
#include <QStringList>
#include <QRegExp>
#include <QChar>
#include <QPointF>
@@ -75,8 +75,6 @@
#include <Mod/Part/App/PartFeature.h>
#include <Mod/Part/App/TopoShape.h>
#include "Preferences.h"
#include "GeometryObject.h"
#include "DrawUtil.h"
using namespace TechDraw;
@@ -96,7 +94,7 @@ using namespace TechDraw;
std::stringstream ErrorMsg;
if (geomName.empty()) {
Base::Console().Log("DU::getIndexFromName(%s) - empty geometry name\n",geomName.c_str());
Base::Console().Log("DU::getIndexFromName(%s) - empty geometry name\n", geomName.c_str());
throw Base::ValueError("getIndexFromName - empty geometry name");
}
@@ -145,7 +143,7 @@ bool DrawUtil::isSamePoint(TopoDS_Vertex v1, TopoDS_Vertex v2, double tolerance)
{
gp_Pnt p1 = BRep_Tool::Pnt(v1);
gp_Pnt p2 = BRep_Tool::Pnt(v2);
if (p1.IsEqual(p2,tolerance)) {
if (p1.IsEqual(p2, tolerance)) {
return true;
}
return false;
@@ -155,7 +153,7 @@ bool DrawUtil::isZeroEdge(TopoDS_Edge e, double tolerance)
{
TopoDS_Vertex vStart = TopExp::FirstVertex(e);
TopoDS_Vertex vEnd = TopExp::LastVertex(e);
if (isSamePoint(vStart,vEnd, tolerance)) {
if (isSamePoint(vStart, vEnd, tolerance)) {
//closed edge will have same V's but non-zero length
GProp_GProps props;
BRepGProp::LinearProperties(e, props);
@@ -186,16 +184,16 @@ double DrawUtil::simpleMinDist(TopoDS_Shape s1, TopoDS_Shape s2)
double DrawUtil::angleWithX(TopoDS_Edge e, bool reverse)
{
gp_Pnt gstart = BRep_Tool::Pnt(TopExp::FirstVertex(e));
Base::Vector3d start(gstart.X(),gstart.Y(),gstart.Z());
Base::Vector3d start(gstart.X(), gstart.Y(), gstart.Z());
gp_Pnt gend = BRep_Tool::Pnt(TopExp::LastVertex(e));
Base::Vector3d end(gend.X(),gend.Y(),gend.Z());
Base::Vector3d end(gend.X(), gend.Y(), gend.Z());
Base::Vector3d u;
if (reverse) {
u = start - end;
} else {
u = end - start;
}
double result = atan2(u.y,u.x);
double result = atan2(u.y, u.x);
if (result < 0) {
result += 2.0 * M_PI;
}
@@ -211,9 +209,9 @@ double DrawUtil::angleWithX(TopoDS_Edge e, TopoDS_Vertex v, double tolerance)
//find tangent @ v
double adjust = 1.0; //occ tangent points in direction of curve. at lastVert we need to reverse it.
BRepAdaptor_Curve adapt(e);
if (isFirstVert(e,v,tolerance)) {
if (isFirstVert(e, v,tolerance)) {
param = adapt.FirstParameter();
} else if (isLastVert(e,v,tolerance)) {
} else if (isLastVert(e, v,tolerance)) {
param = adapt.LastParameter();
adjust = -1;
} else {
@@ -222,29 +220,29 @@ double DrawUtil::angleWithX(TopoDS_Edge e, TopoDS_Vertex v, double tolerance)
//must be able to get non-terminal point parm from curve/
}
Base::Vector3d uVec(0.0,0.0,0.0);
Base::Vector3d uVec(0.0, 0.0, 0.0);
gp_Dir uDir;
BRepLProp_CLProps prop(adapt,param,2,tolerance);
BRepLProp_CLProps prop(adapt, param, 2,tolerance);
if (prop.IsTangentDefined()) {
prop.Tangent(uDir);
uVec = Base::Vector3d(uDir.X(),uDir.Y(),uDir.Z()) * adjust;
uVec = Base::Vector3d(uDir.X(), uDir.Y(), uDir.Z()) * adjust;
} else {
//this bit is a little sketchy
gp_Pnt gstart = BRep_Tool::Pnt(TopExp::FirstVertex(e));
Base::Vector3d start(gstart.X(),gstart.Y(),gstart.Z());
Base::Vector3d start(gstart.X(), gstart.Y(), gstart.Z());
gp_Pnt gend = BRep_Tool::Pnt(TopExp::LastVertex(e));
Base::Vector3d end(gend.X(),gend.Y(),gend.Z());
if (isFirstVert(e,v,tolerance)) {
Base::Vector3d end(gend.X(), gend.Y(), gend.Z());
if (isFirstVert(e, v,tolerance)) {
uVec = end - start;
} else if (isLastVert(e,v,tolerance)) {
} else if (isLastVert(e, v,tolerance)) {
uVec = end - start;
} else {
gp_Pnt errPnt = BRep_Tool::Pnt(v);
Base::Console().Warning("angleWithX: Tangent not defined at (%.3f,%.3f,%.3f)\n",errPnt.X(),errPnt.Y(),errPnt.Z());
Base::Console().Warning("angleWithX: Tangent not defined at (%.3f, %.3f, %.3f)\n", errPnt.X(), errPnt.Y(), errPnt.Z());
//throw ??????
}
}
double result = atan2(uVec.y,uVec.x);
double result = atan2(uVec.y, uVec.x);
if (result < 0) { //map from [-PI:PI] to [0:2PI]
result += 2.0 * M_PI;
}
@@ -254,7 +252,7 @@ double DrawUtil::angleWithX(TopoDS_Edge e, TopoDS_Vertex v, double tolerance)
bool DrawUtil::isFirstVert(TopoDS_Edge e, TopoDS_Vertex v, double tolerance)
{
TopoDS_Vertex first = TopExp::FirstVertex(e);
if (isSamePoint(first,v, tolerance)) {
if (isSamePoint(first, v, tolerance)) {
return true;
}
return false;
@@ -263,7 +261,7 @@ bool DrawUtil::isFirstVert(TopoDS_Edge e, TopoDS_Vertex v, double tolerance)
bool DrawUtil::isLastVert(TopoDS_Edge e, TopoDS_Vertex v, double tolerance)
{
TopoDS_Vertex last = TopExp::LastVertex(e);
if (isSamePoint(last,v, tolerance)) {
if (isSamePoint(last, v, tolerance)) {
return true;
}
return false;
@@ -281,7 +279,7 @@ bool DrawUtil::fpCompare(const double& d1, const double& d2, double tolerance)
std::pair<Base::Vector3d, Base::Vector3d> DrawUtil::boxIntersect2d(Base::Vector3d point,
Base::Vector3d dirIn,
double xRange,
double yRange)
double yRange)
{
std::pair<Base::Vector3d, Base::Vector3d> result;
Base::Vector3d p1, p2;
@@ -341,15 +339,15 @@ std::pair<Base::Vector3d, Base::Vector3d> DrawUtil::boxIntersect2d(Base::Vector3
Base::Vector3d DrawUtil::vertex2Vector(const TopoDS_Vertex& v)
{
gp_Pnt gp = BRep_Tool::Pnt(v);
return Base::Vector3d(gp.X(),gp.Y(),gp.Z());
return Base::Vector3d(gp.X(), gp.Y(), gp.Z());
}
std::string DrawUtil::formatVector(const Base::Vector3d& v)
{
std::stringstream builder;
builder << std::fixed << std::setprecision(3) ;
builder << " (" << v.x << "," << v.y << "," << v.z << ") ";
// builder << " (" << setw(6) << v.x << "," << setw(6) << v.y << "," << setw(6) << v.z << ") ";
builder << " (" << v.x << ", " << v.y << ", " << v.z << ") ";
// builder << " (" << setw(6) << v.x << ", " << setw(6) << v.y << ", " << setw(6) << v.z << ") ";
return builder.str();
}
@@ -357,7 +355,7 @@ std::string DrawUtil::formatVector(const gp_Dir& v)
{
std::stringstream builder;
builder << std::fixed << std::setprecision(3) ;
builder << " (" << v.X() << "," << v.Y() << "," << v.Z() << ") ";
builder << " (" << v.X() << ", " << v.Y() << ", " << v.Z() << ") ";
return builder.str();
}
@@ -365,14 +363,14 @@ std::string DrawUtil::formatVector(const gp_Dir2d& v)
{
std::stringstream builder;
builder << std::fixed << std::setprecision(3) ;
builder << " (" << v.X() << "," << v.Y() << ") ";
builder << " (" << v.X() << ", " << v.Y() << ") ";
return builder.str();
}
std::string DrawUtil::formatVector(const gp_Vec& v)
{
std::stringstream builder;
builder << std::fixed << std::setprecision(3) ;
builder << " (" << v.X() << "," << v.Y() << "," << v.Z() << ") ";
builder << " (" << v.X() << ", " << v.Y() << ", " << v.Z() << ") ";
return builder.str();
}
@@ -380,7 +378,7 @@ std::string DrawUtil::formatVector(const gp_Pnt& v)
{
std::stringstream builder;
builder << std::fixed << std::setprecision(3) ;
builder << " (" << v.X() << "," << v.Y() << "," << v.Z() << ") ";
builder << " (" << v.X() << ", " << v.Y() << ", " << v.Z() << ") ";
return builder.str();
}
@@ -388,7 +386,7 @@ std::string DrawUtil::formatVector(const gp_Pnt2d& v)
{
std::stringstream builder;
builder << std::fixed << std::setprecision(3) ;
builder << " (" << v.X() << "," << v.Y() << ") ";
builder << " (" << v.X() << ", " << v.Y() << ") ";
return builder.str();
}
@@ -396,7 +394,7 @@ std::string DrawUtil::formatVector(const QPointF& v)
{
std::stringstream builder;
builder << std::fixed << std::setprecision(3) ;
builder << " (" << v.x() << "," << v.y() << ") ";
builder << " (" << v.x() << ", " << v.y() << ") ";
return builder.str();
}
@@ -404,9 +402,9 @@ std::string DrawUtil::formatVector(const QPointF& v)
bool DrawUtil::vectorLess(const Base::Vector3d& v1, const Base::Vector3d& v2)
{
if ((v1 - v2).Length() > Precision::Confusion()) { //ie v1 != v2
if (!DrawUtil::fpCompare(v1.x,v2.x)) {
if (!DrawUtil::fpCompare(v1.x, v2.x)) {
return v1.x < v2.x;
} else if (!DrawUtil::fpCompare(v1.y,v2.y)) {
} else if (!DrawUtil::fpCompare(v1.y, v2.y)) {
return v1.y < v2.y;
} else {
return v1.z < v2.z;
@@ -418,13 +416,13 @@ bool DrawUtil::vectorLess(const Base::Vector3d& v1, const Base::Vector3d& v2)
//!convert fromPoint in coordinate system fromSystem to reference coordinate system
Base::Vector3d DrawUtil::toR3(const gp_Ax2& fromSystem, const Base::Vector3d& fromPoint)
{
gp_Pnt gFromPoint(fromPoint.x,fromPoint.y,fromPoint.z);
gp_Pnt gFromPoint(fromPoint.x, fromPoint.y, fromPoint.z);
gp_Trsf T;
gp_Ax3 gRef;
gp_Ax3 gFrom(fromSystem);
T.SetTransformation (gFrom, gRef);
gp_Pnt gToPoint = gFromPoint.Transformed(T);
Base::Vector3d toPoint(gToPoint.X(),gToPoint.Y(),gToPoint.Z());
Base::Vector3d toPoint(gToPoint.X(), gToPoint.Y(), gToPoint.Z());
return toPoint;
}
@@ -433,7 +431,7 @@ bool DrawUtil::checkParallel(const Base::Vector3d v1, Base::Vector3d v2, double
{
double dot = fabs(v1.Dot(v2));
double mag = v1.Length() * v2.Length();
if (DrawUtil::fpCompare(dot,mag,tolerance)) {
if (DrawUtil::fpCompare(dot, mag, tolerance)) {
return true;
}
return false;
@@ -446,29 +444,29 @@ Base::Vector3d DrawUtil::vecRotate(Base::Vector3d vec,
Base::Vector3d org)
{
Base::Matrix4D xForm;
xForm.rotLine(org,axis,angle);
xForm.rotLine(org, axis, angle);
return Base::Vector3d(xForm * (vec));
}
Base::Vector3d DrawUtil::closestBasis(Base::Vector3d v)
{
Base::Vector3d result(0.0,-1,0);
Base::Vector3d stdX(1.0,0.0,0.0);
Base::Vector3d stdY(0.0,1.0,0.0);
Base::Vector3d stdZ(0.0,0.0,1.0);
Base::Vector3d stdXr(-1.0,0.0,0.0);
Base::Vector3d stdYr(0.0,-1.0,0.0);
Base::Vector3d stdZr(0.0,0.0,-1.0);
Base::Vector3d result(0.0, -1, 0);
Base::Vector3d stdX(1.0, 0.0, 0.0);
Base::Vector3d stdY(0.0, 1.0, 0.0);
Base::Vector3d stdZ(0.0, 0.0, 1.0);
Base::Vector3d stdXr(-1.0, 0.0, 0.0);
Base::Vector3d stdYr(0.0, -1.0, 0.0);
Base::Vector3d stdZr(0.0, 0.0, -1.0);
//first check if already a basis
if (checkParallel(v,stdZ) ||
checkParallel(v,stdY) ||
checkParallel(v,stdX)) {
if (checkParallel(v, stdZ) ||
checkParallel(v, stdY) ||
checkParallel(v, stdX)) {
return v;
}
//not a basis. find smallest angle with a basis.
double angleX,angleY,angleZ,angleXr,angleYr,angleZr, angleMin;
double angleX, angleY, angleZ, angleXr, angleYr, angleZr, angleMin;
angleX = stdX.GetAngle(v);
angleY = stdY.GetAngle(v);
angleZ = stdZ.GetAngle(v);
@@ -532,7 +530,7 @@ bool DrawUtil::isBetween(const Base::Vector3d pt, const Base::Vector3d end1, con
double segLength = (end2 - end1).Length();
double l1 = (pt - end1).Length();
double l2 = (pt - end2).Length();
if (fpCompare(segLength,l1 + l2)) {
if (fpCompare(segLength, l1 + l2)) {
return true;
}
return false;
@@ -617,12 +615,12 @@ QPointF DrawUtil::invertY(QPointF v)
//obs? was used in CSV prototype of Cosmetics
std::vector<std::string> DrawUtil::split(std::string csvLine)
{
// Base::Console().Message("DU::split - csvLine: %s\n",csvLine.c_str());
// Base::Console().Message("DU::split - csvLine: %s\n", csvLine.c_str());
std::vector<std::string> result;
std::stringstream lineStream(csvLine);
std::string cell;
while(std::getline(lineStream,cell, ','))
while(std::getline(lineStream, cell, ','))
{
result.push_back(cell);
}
@@ -632,7 +630,7 @@ std::vector<std::string> DrawUtil::split(std::string csvLine)
//obs? was used in CSV prototype of Cosmetics
std::vector<std::string> DrawUtil::tokenize(std::string csvLine, std::string delimiter)
{
// Base::Console().Message("DU::tokenize - csvLine: %s delimit: %s\n",csvLine.c_str(), delimiter.c_str());
// Base::Console().Message("DU::tokenize - csvLine: %s delimit: %s\n", csvLine.c_str(), delimiter.c_str());
std::string s(csvLine);
size_t pos = 0;
std::vector<std::string> tokens;
@@ -656,15 +654,15 @@ App::Color DrawUtil::pyTupleToColor(PyObject* pColor)
int tSize = (int) PyTuple_Size(pColor);
if (tSize > 2) {
PyObject* pRed = PyTuple_GetItem(pColor,0);
PyObject* pRed = PyTuple_GetItem(pColor, 0);
red = PyFloat_AsDouble(pRed);
PyObject* pGreen = PyTuple_GetItem(pColor,1);
PyObject* pGreen = PyTuple_GetItem(pColor, 1);
green = PyFloat_AsDouble(pGreen);
PyObject* pBlue = PyTuple_GetItem(pColor,2);
PyObject* pBlue = PyTuple_GetItem(pColor, 2);
blue = PyFloat_AsDouble(pBlue);
}
if (tSize > 3) {
PyObject* pAlpha = PyTuple_GetItem(pColor,3);
PyObject* pAlpha = PyTuple_GetItem(pColor, 3);
alpha = PyFloat_AsDouble(pAlpha);
}
return App::Color(red, green, blue, alpha);
@@ -679,10 +677,10 @@ PyObject* DrawUtil::colorToPyTuple(App::Color color)
PyObject* pBlue = PyFloat_FromDouble(color.b);
PyObject* pAlpha = PyFloat_FromDouble(color.a);
PyTuple_SET_ITEM(pTuple, 0,pRed);
PyTuple_SET_ITEM(pTuple, 1,pGreen);
PyTuple_SET_ITEM(pTuple, 2,pBlue);
PyTuple_SET_ITEM(pTuple, 3,pAlpha);
PyTuple_SET_ITEM(pTuple, 0, pRed);
PyTuple_SET_ITEM(pTuple, 1, pGreen);
PyTuple_SET_ITEM(pTuple, 2, pBlue);
PyTuple_SET_ITEM(pTuple, 3, pAlpha);
return pTuple;
}
@@ -709,24 +707,24 @@ bool DrawUtil::isCrazy(TopoDS_Edge e)
Base::Console().Log("DU::isCrazy - edge crazy short: %.7f\n", edgeLength);
return true;
}
if (edgeLength > 9999.9) { //edge is scaled. this is 10 m on paper. can't be right?
if (edgeLength > 9999.9) { //edge is scaled. this is 10 m on paper. can't be right?
Base::Console().Log("DU::isCrazy - edge crazy long: %.3f\n", edgeLength);
return true;
}
double start = BRepLProp_CurveTool::FirstParameter(adapt);
double end = BRepLProp_CurveTool::LastParameter(adapt);
BRepLProp_CLProps propStart(adapt,start,0,Precision::Confusion());
BRepLProp_CLProps propStart(adapt, start, 0,Precision::Confusion());
const gp_Pnt& vStart = propStart.Value();
BRepLProp_CLProps propEnd(adapt,end,0,Precision::Confusion());
BRepLProp_CLProps propEnd(adapt, end, 0,Precision::Confusion());
const gp_Pnt& vEnd = propEnd.Value();
double distance = vStart.Distance(vEnd);
double ratio = edgeLength / distance;
if (adapt.GetType() == GeomAbs_BSplineCurve &&
distance > 0.001 && // not a closed loop
ratio > 9999.9) { // 10,000x
ratio > 9999.9) { // 10, 000x
return true; //this is crazy edge
}
}
else if (adapt.GetType() == GeomAbs_Ellipse) {
gp_Elips ellp = adapt.Ellipse();
double major = ellp.MajorRadius();
@@ -742,7 +740,7 @@ bool DrawUtil::isCrazy(TopoDS_Edge e)
// Base::Console().Message("DU::isCrazy - returns: %d ratio: %.3f\n", false, ratio);
return false;
}
}
//construct a compound shape from a list of edges
TopoDS_Shape DrawUtil::vectorToCompound(std::vector<TopoDS_Edge> vecIn)
@@ -765,13 +763,13 @@ Base::Vector3d DrawUtil::getFaceCenter(TopoDS_Face f)
double v1 = adapt.FirstVParameter();
double v2 = adapt.LastVParameter();
double mv = (v1 + v2) / 2.0;
BRepLProp_SLProps prop(adapt,mu,mv,0,Precision::Confusion());
BRepLProp_SLProps prop(adapt, mu, mv, 0,Precision::Confusion());
const gp_Pnt gv = prop.Value();
return Base::Vector3d(gv.X(), gv.Y(), gv.Z());
}
// test the circulation of the triangle A-B-C
bool DrawUtil::circulation(Base::Vector3d A, Base::Vector3d B, Base::Vector3d C)
bool DrawUtil::circulation(Base::Vector3d A, Base::Vector3d B, Base::Vector3d C)
{
if (A.x * B.y + A.y * C.x + B.x * C.y - C.x * B.y - C.y * A.x - B.x * A.y > 0.0)
return true;
@@ -1176,12 +1174,12 @@ void DrawUtil::copyFile(std::string inSpec, std::string outSpec)
// various debugging routines.
void DrawUtil::dumpVertexes(const char* text, const TopoDS_Shape& s)
{
Base::Console().Message("DUMP - %s\n",text);
Base::Console().Message("DUMP - %s\n", text);
TopExp_Explorer expl(s, TopAbs_VERTEX);
for (int i = 1 ; expl.More(); expl.Next(),i++) {
for (int i = 1 ; expl.More(); expl.Next(), i++) {
const TopoDS_Vertex& v = TopoDS::Vertex(expl.Current());
gp_Pnt pnt = BRep_Tool::Pnt(v);
Base::Console().Message("v%d: (%.3f,%.3f,%.3f)\n",i,pnt.X(),pnt.Y(),pnt.Z());
Base::Console().Message("v%d: (%.3f, %.3f, %.3f)\n", i,pnt.X(), pnt.Y(), pnt.Z());
}
}
@@ -1190,7 +1188,7 @@ void DrawUtil::countFaces(const char* text, const TopoDS_Shape& s)
TopTools_IndexedMapOfShape mapOfFaces;
TopExp::MapShapes(s, TopAbs_FACE, mapOfFaces);
int num = mapOfFaces.Extent();
Base::Console().Message("COUNT - %s has %d Faces\n",text,num);
Base::Console().Message("COUNT - %s has %d Faces\n", text, num);
}
//count # of unique Wires in shape.
@@ -1199,7 +1197,7 @@ void DrawUtil::countWires(const char* text, const TopoDS_Shape& s)
TopTools_IndexedMapOfShape mapOfWires;
TopExp::MapShapes(s, TopAbs_WIRE, mapOfWires);
int num = mapOfWires.Extent();
Base::Console().Message("COUNT - %s has %d wires\n",text,num);
Base::Console().Message("COUNT - %s has %d wires\n", text, num);
}
void DrawUtil::countEdges(const char* text, const TopoDS_Shape& s)
@@ -1207,14 +1205,14 @@ void DrawUtil::countEdges(const char* text, const TopoDS_Shape& s)
TopTools_IndexedMapOfShape mapOfEdges;
TopExp::MapShapes(s, TopAbs_EDGE, mapOfEdges);
int num = mapOfEdges.Extent();
Base::Console().Message("COUNT - %s has %d edges\n",text,num);
Base::Console().Message("COUNT - %s has %d edges\n", text, num);
}
void DrawUtil::dumpEdges(const char* text, const TopoDS_Shape& s)
{
Base::Console().Message("DUMP - %s\n",text);
Base::Console().Message("DUMP - %s\n", text);
TopExp_Explorer expl(s, TopAbs_EDGE);
for (int i = 1 ; expl.More(); expl.Next(),i++) {
for (int i = 1 ; expl.More(); expl.Next(), i++) {
const TopoDS_Edge& e = TopoDS::Edge(expl.Current());
dumpEdge("dumpEdges", i, e);
}
@@ -1222,9 +1220,9 @@ void DrawUtil::dumpEdges(const char* text, const TopoDS_Shape& s)
void DrawUtil::dump1Vertex(const char* text, const TopoDS_Vertex& v)
{
Base::Console().Message("DUMP - dump1Vertex - %s\n",text);
Base::Console().Message("DUMP - dump1Vertex - %s\n", text);
gp_Pnt pnt = BRep_Tool::Pnt(v);
Base::Console().Message("%s: (%.3f,%.3f,%.3f)\n",text,pnt.X(),pnt.Y(),pnt.Z());
Base::Console().Message("%s: (%.3f, %.3f, %.3f)\n", text, pnt.X(), pnt.Y(), pnt.Z());
}
void DrawUtil::dumpEdge(const char* label, int i, TopoDS_Edge e)
@@ -1232,14 +1230,14 @@ void DrawUtil::dumpEdge(const char* label, int i, TopoDS_Edge e)
BRepAdaptor_Curve adapt(e);
double start = BRepLProp_CurveTool::FirstParameter(adapt);
double end = BRepLProp_CurveTool::LastParameter(adapt);
BRepLProp_CLProps propStart(adapt,start,0,Precision::Confusion());
BRepLProp_CLProps propStart(adapt, start, 0,Precision::Confusion());
const gp_Pnt& vStart = propStart.Value();
BRepLProp_CLProps propEnd(adapt,end,0,Precision::Confusion());
BRepLProp_CLProps propEnd(adapt, end, 0,Precision::Confusion());
const gp_Pnt& vEnd = propEnd.Value();
//Base::Console().Message("%s edge:%d start:(%.3f,%.3f,%.3f)/%0.3f end:(%.2f,%.3f,%.3f)/%.3f\n",label,i,
// vStart.X(),vStart.Y(),vStart.Z(),start,vEnd.X(),vEnd.Y(),vEnd.Z(),end);
Base::Console().Message("%s edge:%d start:(%.3f,%.3f,%.3f) end:(%.2f,%.3f,%.3f) Orient: %d\n",label,i,
vStart.X(),vStart.Y(),vStart.Z(),vEnd.X(),vEnd.Y(),vEnd.Z(), e.Orientation());
//Base::Console().Message("%s edge:%d start:(%.3f, %.3f, %.3f)/%0.3f end:(%.2f, %.3f, %.3f)/%.3f\n", label, i,
// vStart.X(), vStart.Y(), vStart.Z(), start, vEnd.X(), vEnd.Y(), vEnd.Z(), end);
Base::Console().Message("%s edge:%d start:(%.3f, %.3f, %.3f) end:(%.2f, %.3f, %.3f) Orient: %d\n", label, i,
vStart.X(), vStart.Y(), vStart.Z(), vEnd.X(), vEnd.Y(), vEnd.Z(), e.Orientation());
double edgeLength = GCPnts_AbscissaPoint::Length(adapt, Precision::Confusion());
Base::Console().Message(">>>>>>> length: %.3f distance: %.3f ration: %.3f type: %d\n", edgeLength,
vStart.Distance(vEnd), edgeLength / vStart.Distance(vEnd), adapt.GetType());

View File

@@ -20,8 +20,8 @@
* *
***************************************************************************/
#ifndef _DrawUtil_h_
#define _DrawUtil_h_
#ifndef DrawUtil_h_
#define DrawUtil_h_
#include <Mod/TechDraw/TechDrawGlobal.h>
@@ -99,11 +99,11 @@ class TechDrawExport DrawUtil {
static Base::Vector3d vecRotate(Base::Vector3d vec,
double angle,
Base::Vector3d axis,
Base::Vector3d org = Base::Vector3d(0.0,0.0,0.0));
Base::Vector3d org = Base::Vector3d(0.0, 0.0, 0.0));
static Base::Vector3d closestBasis(Base::Vector3d v);
static double getDefaultLineWeight(std::string s);
/* static Base::Vector3d vector23(const Base::Vector3d& v2) { return Base::Vector3d(v2.x,v2.y,0.0); }*/
/* static Base::Vector3d vector32(const Base::Vector3d& v3) { return Base::Vector3d(v3.x,v3.y); }*/
/* static Base::Vector3d vector23(const Base::Vector3d& v2) { return Base::Vector3d(v2.x, v2.y, 0.0); }*/
/* static Base::Vector3d vector32(const Base::Vector3d& v3) { return Base::Vector3d(v3.x, v3.y); }*/
//! is pt between end1 and end2?
static bool isBetween(const Base::Vector3d pt, const Base::Vector3d end1, const Base::Vector3d end2);
//! find intersection in 2d for 2 lines in point+direction form
@@ -111,14 +111,14 @@ 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 gpPnt2V3(const gp_Pnt gp) { return Base::Vector3d(gp.X(),gp.Y(),gp.Z()); }
static gp_Pnt V32gpPnt(const Base::Vector3d v) { return gp_Pnt(v.x,v.y,v.z); }
static Base::Vector3d gpPnt2V3(const gp_Pnt gp) { return Base::Vector3d(gp.X(), gp.Y(), gp.Z()); }
static gp_Pnt V32gpPnt(const Base::Vector3d v) { return gp_Pnt(v.x, v.y, v.z); }
static std::string shapeToString(TopoDS_Shape s);
static TopoDS_Shape shapeFromString(std::string s);
static Base::Vector3d invertY(Base::Vector3d v);
static QPointF invertY(QPointF p);
static std::vector<std::string> split(std::string csvLine);
static std::vector<std::string> tokenize(std::string csvLine, std::string delimiter = ",$$$,");
static std::vector<std::string> tokenize(std::string csvLine, std::string delimiter = ", $$$, ");
static App::Color pyTupleToColor(PyObject* pColor);
static PyObject* colorToPyTuple(App::Color color);
static bool isCrazy(TopoDS_Edge e);

View File

@@ -43,13 +43,9 @@
#include "DrawPage.h"
#include "DrawViewCollection.h"
#include "DrawViewClip.h"
#include "DrawProjGroup.h"
#include "DrawProjGroupItem.h"
#include "DrawLeaderLine.h"
#include "Preferences.h"
#include "DrawUtil.h"
#include "Geometry.h"
#include "Cosmetic.h"
#include <Mod/TechDraw/App/DrawViewPy.h> // generated from DrawViewPy.xml
@@ -65,9 +61,10 @@ const char* DrawView::ScaleTypeEnums[]= {"Page",
"Automatic",
"Custom",
nullptr};
const double SCALEINCREMENT(0.1);
App::PropertyFloatConstraint::Constraints DrawView::scaleRange = {Precision::Confusion(),
std::numeric_limits<double>::max(),
(0.1)}; // increment by 0.1
(SCALEINCREMENT)}; // increment by 0.1
PROPERTY_SOURCE(TechDraw::DrawView, App::DocumentObject)
@@ -128,40 +125,46 @@ void DrawView::onChanged(const App::Property* prop)
//Coding note: calling execute, recompute or recomputeFeature inside an onChanged
//method can create infinite loops if the called method changes a property. In general
//don't do this! There are situations where it is OK, but careful analysis is a must.
if (!isRestoring()) {
if (prop == &ScaleType) {
auto page = findParentPage();
if (ScaleType.isValue("Page")) {
Scale.setStatus(App::Property::ReadOnly, true);
if (page) {
if(std::abs(page->Scale.getValue() - getScale()) > FLT_EPSILON) {
Scale.setValue(page->Scale.getValue());
}
}
} else if ( ScaleType.isValue("Custom") ) {
//don't change Scale
Scale.setStatus(App::Property::ReadOnly, false);
} else if ( ScaleType.isValue("Automatic") ) {
Scale.setStatus(App::Property::ReadOnly, true);
if (!checkFit(page)) {
double newScale = autoScale(page->getPageWidth(), page->getPageHeight());
if(std::abs(newScale - getScale()) > FLT_EPSILON) { //stops onChanged/execute loop
Scale.setValue(newScale);
}
if (isRestoring()) {
App::DocumentObject::onChanged(prop);
return;
}
if (prop == &ScaleType) {
auto page = findParentPage();
if (!page) {
//we don't belong to a page yet, so don't bother
return;
}
if (ScaleType.isValue("Page")) {
Scale.setStatus(App::Property::ReadOnly, true);
if(std::abs(page->Scale.getValue() - getScale()) > FLT_EPSILON) {
Scale.setValue(page->Scale.getValue());
}
} else if ( ScaleType.isValue("Custom") ) {
//don't change Scale
Scale.setStatus(App::Property::ReadOnly, false);
} else if ( ScaleType.isValue("Automatic") ) {
Scale.setStatus(App::Property::ReadOnly, true);
if (!checkFit(page)) {
double newScale = autoScale(page->getPageWidth(), page->getPageHeight());
if(std::abs(newScale - getScale()) > FLT_EPSILON) { //stops onChanged/execute loop
Scale.setValue(newScale);
}
}
} else if (prop == &LockPosition) {
handleXYLock();
requestPaint(); //change lock icon
LockPosition.purgeTouched();
} else if ((prop == &Caption) ||
(prop == &Label)) {
requestPaint();
} else if ((prop == &X) ||
(prop == &Y)) {
//X,Y changes are only interesting to DPGI and Gui side
}
} else if (prop == &LockPosition) {
handleXYLock();
requestPaint(); //change lock icon
LockPosition.purgeTouched();
} else if ((prop == &Caption) ||
(prop == &Label)) {
requestPaint();
} else if ( prop == &X ||
prop == &Y ) {
//X,Y changes are only interesting to DPGI and Gui side
}
App::DocumentObject::onChanged(prop);
}
@@ -215,7 +218,7 @@ short DrawView::mustExecute() const
////you must override this in derived class
QRectF DrawView::getRect() const
{
QRectF result(0,0,1,1);
QRectF result(0, 0,1, 1);
return result;
}
@@ -224,7 +227,6 @@ void DrawView::onDocumentRestored()
handleXYLock();
setScaleAttribute();
validateScale();
DrawView::execute();
}
//in versions before 0.20 Scale and ScaleType were mishandled.
@@ -244,7 +246,6 @@ void DrawView::validateScale()
double myScale = Scale.getValue();
if (!DrawUtil::fpCompare(pageScale, myScale)) {
ScaleType.setValue("Custom");
ScaleType.purgeTouched();
}
}
}
@@ -357,10 +358,10 @@ double DrawView::autoScale() const
auto page = findParentPage();
double w = page->getPageWidth();
double h = page->getPageHeight();
return autoScale(w,h);
return autoScale(w, h);
}
//compare 1:1 rect of view to pagesize(pw,h)
//compare 1:1 rect of view to pagesize(pw, h)
double DrawView::autoScale(double pw, double ph) const
{
// Base::Console().Message("DV::autoScale(Page: %.3f, %.3f) - %s\n", pw, ph, getNameInDocument());
@@ -374,7 +375,7 @@ double DrawView::autoScale(double pw, double ph) const
double vbh = viewBox.height()/getScale();
double xScale = pw/vbw; // > 1 page bigger than figure
double yScale = ph/vbh; // < 1 page is smaller than figure
double newScale = std::min(xScale,yScale) * fudgeFactor;
double newScale = std::min(xScale, yScale) * fudgeFactor;
double sensibleScale = DrawUtil::sensibleScale(newScale);
return sensibleScale;
}
@@ -413,7 +414,7 @@ bool DrawView::checkFit(TechDraw::DrawPage* p) const
void DrawView::setPosition(double x, double y, bool force)
{
// Base::Console().Message("DV::setPosition(%.3f,%.3f) - \n",x,y,getNameInDocument());
// Base::Console().Message("DV::setPosition(%.3f, %.3f) - \n", x,y, getNameInDocument());
if ( (!isLocked()) ||
(force) ) {
double currX = X.getValue();
@@ -438,7 +439,7 @@ double DrawView::getScale() const
}
if (!(result > 0.0)) {
result = 1.0;
Base::Console().Log("DrawView - %s - bad scale found (%.3f) using 1.0\n",getNameInDocument(),Scale.getValue());
Base::Console().Log("DrawView - %s - bad scale found (%.3f) using 1.0\n", getNameInDocument(), Scale.getValue());
}
return result;
}
@@ -461,7 +462,7 @@ void DrawView::handleChangedPropertyType(Base::XMLReader &reader, const char * T
{
if (prop == &Scale) {
App::PropertyFloat tmp;
if (strcmp(tmp.getTypeId().getName(),TypeName)==0) { //property in file is Float
if (strcmp(tmp.getTypeId().getName(), TypeName)==0) { //property in file is Float
tmp.setContainer(this);
tmp.Restore(reader);
double tmpValue = tmp.getValue();
@@ -499,7 +500,7 @@ void DrawView::handleChangedPropertyType(Base::XMLReader &reader, const char * T
}
// property X had App::PropertyFloat and was changed to App::PropertyLength
// and later to PropertyDistance because some X,Y are relative to existing points on page
// and later to PropertyDistance because some X, Y are relative to existing points on page
else if (prop == &X && strcmp(TypeName, "App::PropertyFloat") == 0) {
App::PropertyFloat XProperty;
XProperty.setContainer(this);
@@ -550,7 +551,7 @@ void DrawView::setScaleAttribute()
{
if (ScaleType.isValue("Page") ||
ScaleType.isValue("Automatic")) {
Scale.setStatus(App::Property::ReadOnly,true);
Scale.setStatus(App::Property::ReadOnly, true);
} else {
Scale.setStatus(App::Property::ReadOnly, false);
}
@@ -568,7 +569,7 @@ double DrawView::prefScale()
{
Base::Reference<ParameterGrp> hGrp = App::GetApplication().GetUserParameter()
.GetGroup("BaseApp")->GetGroup("Preferences")->GetGroup("Mod/TechDraw/General");
double result = hGrp->GetFloat("DefaultViewScale", 1.0);
double result = hGrp->GetFloat("DefaultViewScale", 1.0);
if (ScaleType.isValue("Page")) {
auto page = findParentPage();
if (page) {
@@ -595,7 +596,7 @@ PyObject *DrawView::getPyObject(void)
{
if (PythonObject.is(Py::_None())) {
// ref counter is set to 1
PythonObject = Py::Object(new DrawViewPy(this),true);
PythonObject = Py::Object(new DrawViewPy(this), true);
}
return Py::new_reference_to(PythonObject);
}

View File

@@ -20,8 +20,8 @@
* *
***************************************************************************/
#ifndef _DrawView_h_
#define _DrawView_h_
#ifndef DrawView_h_
#define DrawView_h_
#include <Mod/TechDraw/TechDrawGlobal.h>

View File

@@ -59,20 +59,20 @@ DrawViewAnnotation::DrawViewAnnotation()
{
static const char *vgroup = "Annotation";
ADD_PROPERTY_TYPE(Text ,("Default Text"),vgroup,App::Prop_None,"Annotation text");
ADD_PROPERTY_TYPE(Text ,("Default Text"), vgroup, App::Prop_None, "Annotation text");
ADD_PROPERTY_TYPE(Font ,(Preferences::labelFont().c_str()),
vgroup,App::Prop_None, "Font name");
ADD_PROPERTY_TYPE(TextColor,(0.0f,0.0f,0.0f),vgroup,App::Prop_None,"Text color");
vgroup, App::Prop_None, "Font name");
ADD_PROPERTY_TYPE(TextColor, (0.0f, 0.0f, 0.0f), vgroup, App::Prop_None, "Text color");
ADD_PROPERTY_TYPE(TextSize, (Preferences::labelFontSizeMM()),
vgroup,App::Prop_None,"Text size");
ADD_PROPERTY_TYPE(MaxWidth,(-1.0),vgroup,App::Prop_None,"Maximum width of the annotation block.\n -1 means no maximum width.");
ADD_PROPERTY_TYPE(LineSpace,(80),vgroup,App::Prop_None,"Line spacing in %. 100 means the height of a line.");
vgroup, App::Prop_None, "Text size");
ADD_PROPERTY_TYPE(MaxWidth, (-1.0), vgroup, App::Prop_None, "Maximum width of the annotation block.\n -1 means no maximum width.");
ADD_PROPERTY_TYPE(LineSpace, (80), vgroup, App::Prop_None, "Line spacing in %. 100 means the height of a line.");
TextStyle.setEnums(TextStyleEnums);
ADD_PROPERTY_TYPE(TextStyle,((long)0),vgroup,App::Prop_None,"Text style");
ADD_PROPERTY_TYPE(TextStyle, ((long)0), vgroup, App::Prop_None, "Text style");
Scale.setStatus(App::Property::Hidden,true);
ScaleType.setStatus(App::Property::Hidden,true);
Scale.setStatus(App::Property::Hidden, true);
ScaleType.setStatus(App::Property::Hidden, true);
}
DrawViewAnnotation::~DrawViewAnnotation()
@@ -100,7 +100,7 @@ void DrawViewAnnotation::handleChangedPropertyType(Base::XMLReader &reader, cons
{
// also check for changed properties of the base class
DrawView::handleChangedPropertyType(reader, TypeName, prop);
// property LineSpace had the App::PropertyInteger and was changed to App::PropertyPercent
if (prop == &LineSpace && strcmp(TypeName, "App::PropertyInteger") == 0) {
App::PropertyInteger LineSpaceProperty;
@@ -126,9 +126,9 @@ QRectF DrawViewAnnotation::getRect() const
chars = (int)l.size();
}
}
int w = chars * std::max(1,(int)tSize);
int h = lines * std::max(1,(int)tSize);
return QRectF(0,0,getScale() * w,getScale() * h);
int w = chars * std::max(1, (int)tSize);
int h = lines * std::max(1, (int)tSize);
return { 0, 0, getScale() * w, getScale() * h};
}
App::DocumentObjectExecReturn *DrawViewAnnotation::execute()

View File

@@ -21,8 +21,8 @@
* *
***************************************************************************/
#ifndef _DrawViewAnnotation_h_
#define _DrawViewAnnotation_h_
#ifndef DrawViewAnnotation_h_
#define DrawViewAnnotation_h_
#include <Mod/TechDraw/TechDrawGlobal.h>
@@ -51,7 +51,7 @@ public:
App::PropertyColor TextColor;
App::PropertyLength TextSize;
App::PropertyPercent LineSpace;
App::PropertyEnumeration TextStyle; // Plain,Bold,Italic,Bold-Italic
App::PropertyEnumeration TextStyle; // Plain, Bold, Italic, Bold-Italic
App::PropertyLength MaxWidth;
QRectF getRect() const override;

View File

@@ -56,25 +56,21 @@ DrawViewArch::DrawViewArch()
{
static const char *group = "Arch view";
ADD_PROPERTY_TYPE(Source ,(nullptr),group,App::Prop_None,"SectionPlane or BuildingPart object for this view");
ADD_PROPERTY_TYPE(Source ,(nullptr), group, App::Prop_None, "SectionPlane or BuildingPart object for this view");
Source.setScope(App::LinkScope::Global);
ADD_PROPERTY_TYPE(AllOn ,(false),group,App::Prop_None,"If hidden objects must be shown or not");
ADD_PROPERTY_TYPE(AllOn ,(false), group, App::Prop_None, "If hidden objects must be shown or not");
RenderMode.setEnums(RenderModeEnums);
ADD_PROPERTY_TYPE(RenderMode, ((long)0),group,App::Prop_None,"The render mode to use");
ADD_PROPERTY_TYPE(FillSpaces ,(false),group,App::Prop_None,"If True, Arch Spaces are shown as a colored area");
ADD_PROPERTY_TYPE(ShowHidden ,(false),group,App::Prop_None,"If the hidden geometry behind the section plane is shown or not");
ADD_PROPERTY_TYPE(ShowFill ,(false),group,App::Prop_None,"If cut areas must be filled with a hatch pattern or not");
ADD_PROPERTY_TYPE(LineWidth,(0.25),group,App::Prop_None,"Line width of this view");
ADD_PROPERTY_TYPE(FontSize,(12.0),group,App::Prop_None,"Text size for this view");
ADD_PROPERTY_TYPE(CutLineWidth,(0.50),group,App::Prop_None,"Width of cut lines of this view");
ADD_PROPERTY_TYPE(JoinArch ,(false),group,App::Prop_None,"If True, walls and structure will be fused by material");
ADD_PROPERTY_TYPE(RenderMode, ((long)0), group, App::Prop_None, "The render mode to use");
ADD_PROPERTY_TYPE(FillSpaces ,(false), group, App::Prop_None, "If True, Arch Spaces are shown as a colored area");
ADD_PROPERTY_TYPE(ShowHidden ,(false), group, App::Prop_None, "If the hidden geometry behind the section plane is shown or not");
ADD_PROPERTY_TYPE(ShowFill ,(false), group, App::Prop_None, "If cut areas must be filled with a hatch pattern or not");
ADD_PROPERTY_TYPE(LineWidth, (0.25), group, App::Prop_None, "Line width of this view");
ADD_PROPERTY_TYPE(FontSize, (12.0), group, App::Prop_None, "Text size for this view");
ADD_PROPERTY_TYPE(CutLineWidth, (0.50), group, App::Prop_None, "Width of cut lines of this view");
ADD_PROPERTY_TYPE(JoinArch ,(false), group, App::Prop_None, "If True, walls and structure will be fused by material");
ScaleType.setValue("Custom");
}
DrawViewArch::~DrawViewArch()
{
}
//NOTE: DocumentObject::mustExecute returns 1/0 and not true/false
short DrawViewArch::mustExecute() const
{
@@ -118,27 +114,27 @@ App::DocumentObjectExecReturn *DrawViewArch::execute()
std::string svgTail = getSVGTail();
std::string FeatName = getNameInDocument();
std::string SourceName = sourceObj->getNameInDocument();
// ArchSectionPlane.getSVG(section,allOn=False,renderMode="Wireframe",showHidden=False,showFill=False,scale=1,linewidth=1,fontsize=1):
// ArchSectionPlane.getSVG(section, allOn=False, renderMode="Wireframe", showHidden=False, showFill=False, scale=1, linewidth=1, fontsize=1):
std::stringstream paramStr;
paramStr << ",allOn=" << (AllOn.getValue() ? "True" : "False")
<< ",renderMode=" << RenderMode.getValue()
<< ",showHidden=" << (ShowHidden.getValue() ? "True" : "False")
<< ",showFill=" << (ShowFill.getValue() ? "True" : "False")
<< ",scale=" << getScale()
<< ",linewidth=" << LineWidth.getValue()
<< ",fontsize=" << FontSize.getValue()
<< ",techdraw=True"
<< ",rotation=" << Rotation.getValue()
<< ",fillSpaces=" << (FillSpaces.getValue() ? "True" : "False")
<< ",cutlinewidth=" << CutLineWidth.getValue()
<< ",joinArch=" << (JoinArch.getValue() ? "True" : "False");
paramStr << ", allOn=" << (AllOn.getValue() ? "True" : "False")
<< ", renderMode=" << RenderMode.getValue()
<< ", showHidden=" << (ShowHidden.getValue() ? "True" : "False")
<< ", showFill=" << (ShowFill.getValue() ? "True" : "False")
<< ", scale=" << getScale()
<< ", linewidth=" << LineWidth.getValue()
<< ", fontsize=" << FontSize.getValue()
<< ", techdraw=True"
<< ", rotation=" << Rotation.getValue()
<< ", fillSpaces=" << (FillSpaces.getValue() ? "True" : "False")
<< ", cutlinewidth=" << CutLineWidth.getValue()
<< ", joinArch=" << (JoinArch.getValue() ? "True" : "False");
Base::Interpreter().runString("import ArchSectionPlane");
Base::Interpreter().runStringArg("svgBody = ArchSectionPlane.getSVG(App.activeDocument().%s %s)",
SourceName.c_str(),paramStr.str().c_str());
SourceName.c_str(), paramStr.str().c_str());
Base::Interpreter().runStringArg("App.activeDocument().%s.Symbol = '%s' + svgBody + '%s'",
FeatName.c_str(),svgHead.c_str(),svgTail.c_str());
FeatName.c_str(), svgHead.c_str(), svgTail.c_str());
}
overrideKeepUpdated(false);
return DrawView::execute();

View File

@@ -20,8 +20,8 @@
* *
***************************************************************************/
#ifndef _DrawViewArch_h_
#define _DrawViewArch_h_
#ifndef DrawViewArch_h_
#define DrawViewArch_h_
#include <Mod/TechDraw/TechDrawGlobal.h>
@@ -42,11 +42,11 @@ class TechDrawExport DrawViewArch : public TechDraw::DrawViewSymbol
public:
/// Constructor
DrawViewArch();
~DrawViewArch() override;
~DrawViewArch() = default;
App::PropertyLink Source;
App::PropertyBool AllOn;
App::PropertyEnumeration RenderMode; // "Wireframe","Solid"
App::PropertyEnumeration RenderMode; // "Wireframe", "Solid"
App::PropertyBool FillSpaces;
App::PropertyBool ShowHidden;
App::PropertyBool ShowFill;

View File

@@ -71,7 +71,7 @@ App::PropertyFloatConstraint::Constraints DrawViewBalloon::SymbolScaleRange = {
// DrawViewBalloon
//===========================================================================
// Balloon coordinates are relative to the position of the SourceView
// X,Y is the center of the balloon bubble
// X, Y is the center of the balloon bubble
// OriginX, OriginY is the tip of the arrow
// these are in unscaled SourceView coordinates
// Note that if the SourceView coordinate system changes
@@ -100,7 +100,7 @@ DrawViewBalloon::DrawViewBalloon()
EndType.setEnums(ArrowPropEnum::ArrowTypeEnums);
ADD_PROPERTY_TYPE(EndType, (prefEnd()), "", (App::PropertyType)(App::Prop_None), "End symbol for the balloon line");
ADD_PROPERTY_TYPE(EndTypeScale, (1.0), "", (App::PropertyType)(App::Prop_None),"End symbol scale factor");
ADD_PROPERTY_TYPE(EndTypeScale, (1.0), "", (App::PropertyType)(App::Prop_None), "End symbol scale factor");
EndTypeScale.setConstraints(&SymbolScaleRange);
BubbleShape.setEnums(balloonTypeEnums);
@@ -115,8 +115,8 @@ DrawViewBalloon::DrawViewBalloon()
"Distance from symbol to leader kink");
SourceView.setScope(App::LinkScope::Global);
Rotation.setStatus(App::Property::Hidden,true);
Caption.setStatus(App::Property::Hidden,true);
Rotation.setStatus(App::Property::Hidden, true);
Caption.setStatus(App::Property::Hidden, true);
}
DrawViewBalloon::~DrawViewBalloon()
@@ -168,13 +168,13 @@ void DrawViewBalloon::handleChangedPropertyType(Base::XMLReader &reader, const c
DrawView::handleChangedPropertyType(reader, TypeName, prop);
// property OriginX had the App::PropertyFloat and was changed to App::PropertyDistance
if ( (prop == &OriginX) &&
if ( (prop == &OriginX) &&
(strcmp(TypeName, "App::PropertyFloat") == 0) ) {
App::PropertyFloat OriginXProperty;
// restore the PropertyFloat to be able to set its value
OriginXProperty.Restore(reader);
OriginX.setValue(OriginXProperty.getValue());
} else if ( (prop == &OriginX) &&
} else if ( (prop == &OriginX) &&
(strcmp(TypeName, "App::PropertyLength") == 0) ) {
App::PropertyLength OriginXProperty;
// restore the PropertyFloat to be able to set its value
@@ -182,13 +182,13 @@ void DrawViewBalloon::handleChangedPropertyType(Base::XMLReader &reader, const c
OriginX.setValue(OriginXProperty.getValue());
// property OriginY had the App::PropertyFloat and was changed to App::PropertyDistance
} else if ( (prop == &OriginY) &&
} else if ( (prop == &OriginY) &&
(strcmp(TypeName, "App::PropertyFloat") == 0) ) {
App::PropertyFloat OriginYProperty;
// restore the PropertyFloat to be able to set its value
OriginYProperty.Restore(reader);
OriginY.setValue(OriginYProperty.getValue());
} else if ( (prop == &OriginY) &&
} else if ( (prop == &OriginY) &&
(strcmp(TypeName, "App::PropertyLength") == 0) ) {
App::PropertyLength OriginYProperty;
// restore the PropertyLength to be able to set its value
@@ -298,7 +298,7 @@ PyObject *DrawViewBalloon::getPyObject(void)
{
if (PythonObject.is(Py::_None())) {
// ref counter is set to 1
PythonObject = Py::Object(new DrawViewBalloonPy(this),true);
PythonObject = Py::Object(new DrawViewBalloonPy(this), true);
}
return Py::new_reference_to(PythonObject);
}

View File

@@ -20,8 +20,8 @@
* *
***************************************************************************/
#ifndef _TechDraw_DrawViewBalloon_h_
#define _TechDraw_DrawViewBalloon_h_
#ifndef TechDraw_DrawViewBalloon_h_
#define TechDraw_DrawViewBalloon_h_
#include <Mod/TechDraw/TechDrawGlobal.h>
@@ -90,10 +90,10 @@ public:
protected:
void onChanged(const App::Property* prop) override;
void handleChangedPropertyType(Base::XMLReader &reader,
const char *TypeName,
const char *TypeName,
App::Property * prop) override;
void handleChangedPropertyName(Base::XMLReader &reader,
const char * TypeName,
const char * TypeName,
const char *PropName) override;
private:

View File

@@ -50,21 +50,17 @@ DrawViewClip::DrawViewClip()
static const char *group = "Clip Group";
//App::PropertyType hidden = (App::PropertyType)(App::Prop_Hidden);
ADD_PROPERTY_TYPE(Height ,(100),group,App::Prop_None,"The height of the view area of this clip");
ADD_PROPERTY_TYPE(Width ,(100),group,App::Prop_None,"The width of the view area of this clip");
ADD_PROPERTY_TYPE(ShowFrame ,(0) ,group,App::Prop_None,"Specifies if the clip frame appears on the page or not");
ADD_PROPERTY_TYPE(Views ,(nullptr) ,group,App::Prop_None,"The Views in this Clip group");
ADD_PROPERTY_TYPE(Height ,(100), group, App::Prop_None, "The height of the view area of this clip");
ADD_PROPERTY_TYPE(Width ,(100), group, App::Prop_None, "The width of the view area of this clip");
ADD_PROPERTY_TYPE(ShowFrame ,(0) ,group, App::Prop_None, "Specifies if the clip frame appears on the page or not");
ADD_PROPERTY_TYPE(Views ,(nullptr) ,group, App::Prop_None, "The Views in this Clip group");
Views.setScope(App::LinkScope::Global);
// hide N/A properties
ScaleType.setStatus(App::Property::ReadOnly,true);
ScaleType.setStatus(App::Property::Hidden,true);
Scale.setStatus(App::Property::ReadOnly,true);
Scale.setStatus(App::Property::Hidden,true);
}
DrawViewClip::~DrawViewClip()
{
ScaleType.setStatus(App::Property::ReadOnly, true);
ScaleType.setStatus(App::Property::Hidden, true);
Scale.setStatus(App::Property::ReadOnly, true);
Scale.setStatus(App::Property::Hidden, true);
}
void DrawViewClip::onChanged(const App::Property* prop)
@@ -164,7 +160,7 @@ PyObject *DrawViewClip::getPyObject()
{
if (PythonObject.is(Py::_None())) {
// ref counter is set to 1
PythonObject = Py::Object(new DrawViewClipPy(this),true);
PythonObject = Py::Object(new DrawViewClipPy(this), true);
}
return Py::new_reference_to(PythonObject);
}

View File

@@ -21,8 +21,8 @@
* *
***************************************************************************/
#ifndef _DrawViewClip_h_
#define _DrawViewClip_h_
#ifndef DrawViewClip_h_
#define DrawViewClip_h_
#include <Mod/TechDraw/TechDrawGlobal.h>
@@ -44,7 +44,7 @@ class TechDrawExport DrawViewClip: public TechDraw::DrawView
public:
/// Constructor
DrawViewClip();
~DrawViewClip() override;
~DrawViewClip() = default;
App::PropertyLength Width;
App::PropertyLength Height;
@@ -70,7 +70,7 @@ public:
std::vector<std::string> getChildViewNames();
bool isViewInClip(App::DocumentObject* view);
QRectF getRect() const override { return QRectF(0,0,Width.getValue(),Height.getValue()); }
QRectF getRect() const override { return { 0, 0, Width.getValue(), Height.getValue() }; }
protected:

View File

@@ -44,14 +44,14 @@ std::string DrawViewClipPy::representation() const
PyObject* DrawViewClipPy::addView(PyObject* args)
{
//this implements iRC = pyClip.addView(pyView) -or-
//doCommand(Doc,"App.activeDocument().%s.addView(App.activeDocument().%s)",PageName.c_str(),FeatName.c_str());
//doCommand(Doc, "App.activeDocument().%s.addView(App.activeDocument().%s)", PageName.c_str(), FeatName.c_str());
PyObject *pcDocObj;
if (!PyArg_ParseTuple(args, "O!", &(App::DocumentObjectPy::Type), &pcDocObj)) {
Base::Console().Error("Error: DrawViewClipPy::addView - Bad Arg - not DocumentObject\n");
return nullptr;
//TODO: sb PyErr??
//PyErr_SetString(PyExc_TypeError,"addView expects a DrawView");
//PyErr_SetString(PyExc_TypeError, "addView expects a DrawView");
//return -1;
}
@@ -68,14 +68,14 @@ PyObject* DrawViewClipPy::addView(PyObject* args)
PyObject* DrawViewClipPy::removeView(PyObject* args)
{
//this implements iRC = pyClip.removeView(pyView) -or-
//doCommand(Doc,"App.activeDocument().%s.removeView(App.activeDocument().%s)",PageName.c_str(),FeatName.c_str());
//doCommand(Doc, "App.activeDocument().%s.removeView(App.activeDocument().%s)", PageName.c_str(), FeatName.c_str());
PyObject *pcDocObj;
if (!PyArg_ParseTuple(args, "O!", &(App::DocumentObjectPy::Type), &pcDocObj)) {
Base::Console().Error("Error: DrawViewClipPy::removeView - Bad Arg - not DocumentObject\n");
return nullptr;
//TODO: sb PyErr??
//PyErr_SetString(PyExc_TypeError,"removeView expects a DrawView");
//PyErr_SetString(PyExc_TypeError, "removeView expects a DrawView");
//return -1;
}

View File

@@ -47,7 +47,7 @@ DrawViewCollection::DrawViewCollection()
{
nowUnsetting = false;
static const char *group = "Collection";
ADD_PROPERTY_TYPE(Views ,(nullptr), group, App::Prop_None,"Collection Views");
ADD_PROPERTY_TYPE(Views ,(nullptr), group, App::Prop_None, "Collection Views");
Views.setScope(App::LinkScope::Global);
}
@@ -196,7 +196,7 @@ QRectF DrawViewCollection::getRect() const
throw Base::ValueError("DrawViewCollection::getRect bad View\n");
}
result = result.united(view->getRect().translated(view->X.getValue(),view->Y.getValue()));
result = result.united(view->getRect().translated(view->X.getValue(), view->Y.getValue()));
}
return QRectF(0,0,getScale() * result.width(),getScale() * result.height());
return { 0, 0, getScale() * result.width(), getScale() * result.height()};
}

View File

@@ -21,8 +21,8 @@
* *
***************************************************************************/
#ifndef _TECHDRAW_FEATUREVIEWCOLLECTION_h_
#define _TECHDRAW_FEATUREVIEWCOLLECTION_h_
#ifndef TECHDRAW_FEATUREVIEWCOLLECTION_h_
#define TECHDRAW_FEATUREVIEWCOLLECTION_h_
#include <Mod/TechDraw/TechDrawGlobal.h>
@@ -73,4 +73,4 @@ protected:
} //namespace TechDraw
#endif // _TECHDRAW_FEATUREVIEWCOLLECTION_h_
#endif // TECHDRAW_FEATUREVIEWCOLLECTION_h_

View File

@@ -90,18 +90,18 @@ DrawViewDetail::DrawViewDetail() :
{
static const char *dgroup = "Detail";
ADD_PROPERTY_TYPE(BaseView ,(nullptr),dgroup,App::Prop_None,"2D View source for this Section");
ADD_PROPERTY_TYPE(BaseView ,(nullptr), dgroup, App::Prop_None, "2D View source for this Section");
BaseView.setScope(App::LinkScope::Global);
ADD_PROPERTY_TYPE(AnchorPoint ,(0,0,0) ,dgroup,App::Prop_None,"Location of detail in BaseView");
ADD_PROPERTY_TYPE(Radius,(10.0),dgroup, App::Prop_None, "Size of detail area");
ADD_PROPERTY_TYPE(Reference ,("1"),dgroup,App::Prop_None,"An identifier for this detail");
ADD_PROPERTY_TYPE(AnchorPoint ,(0, 0,0) ,dgroup, App::Prop_None, "Location of detail in BaseView");
ADD_PROPERTY_TYPE(Radius, (10.0), dgroup, App::Prop_None, "Size of detail area");
ADD_PROPERTY_TYPE(Reference ,("1"), dgroup, App::Prop_None, "An identifier for this detail");
getParameters();
m_fudge = 1.01;
//hide Properties not relevant to DVDetail
Direction.setStatus(App::Property::ReadOnly,true); //Should be same as BaseView
Rotation.setStatus(App::Property::ReadOnly,true); //same as BaseView
Direction.setStatus(App::Property::ReadOnly, true); //Should be same as BaseView
Rotation.setStatus(App::Property::ReadOnly, true); //same as BaseView
ScaleType.setValue("Custom"); //dvd uses scale from BaseView
}
@@ -171,7 +171,7 @@ App::DocumentObjectExecReturn *DrawViewDetail::execute()
//this can only happen via scripting?
return DrawView::execute();
}
DrawViewPart* dvp = static_cast<DrawViewPart*>(baseObj);
DrawViewSection* dvs = nullptr;
TopoDS_Shape shape;
@@ -248,7 +248,7 @@ void DrawViewDetail::makeDetailShape(TopoDS_Shape& shape,
gp_Pnt gpCenter = TechDraw::findCentroid(copyShape,
dirDetail);
Base::Vector3d shapeCenter = Base::Vector3d(gpCenter.X(),gpCenter.Y(),gpCenter.Z());
Base::Vector3d shapeCenter = Base::Vector3d(gpCenter.X(), gpCenter.Y(), gpCenter.Z());
m_saveCentroid = shapeCenter; //centroid of original shape
if (!dvs) {
@@ -272,8 +272,8 @@ void DrawViewDetail::makeDetailShape(TopoDS_Shape& shape,
Base::Vector3d toolPlaneOrigin = anchor + dirDetail * diag * -1.0; //center tool about anchor
double extrudeLength = 2.0 * toolPlaneOrigin.Length();
gp_Pnt gpnt(toolPlaneOrigin.x,toolPlaneOrigin.y,toolPlaneOrigin.z);
gp_Dir gdir(dirDetail.x,dirDetail.y,dirDetail.z);
gp_Pnt gpnt(toolPlaneOrigin.x, toolPlaneOrigin.y, toolPlaneOrigin.z);
gp_Dir gdir(dirDetail.x, dirDetail.y, dirDetail.z);
TopoDS_Face extrusionFace;
Base::Vector3d extrudeVec = dirDetail * extrudeLength;
@@ -281,7 +281,7 @@ void DrawViewDetail::makeDetailShape(TopoDS_Shape& shape,
TopoDS_Shape tool;
if (Preferences::mattingStyle()) {
//square mat
gp_Pln gpln(gpnt,gdir);
gp_Pln gpln(gpnt, gdir);
BRepBuilderAPI_MakeFace mkFace(gpln, -radius, radius, -radius, radius);
extrusionFace = mkFace.Face();
if(extrusionFace.IsNull()) {
@@ -315,7 +315,7 @@ void DrawViewDetail::makeDetailShape(TopoDS_Shape& shape,
for (; expl.More(); expl.Next()) {
const TopoDS_Solid& s = TopoDS::Solid(expl.Current());
BRepAlgoAPI_Common mkCommon(s,tool);
BRepAlgoAPI_Common mkCommon(s, tool);
if (!mkCommon.IsDone()) {
continue;
}
@@ -325,7 +325,7 @@ void DrawViewDetail::makeDetailShape(TopoDS_Shape& shape,
//this might be overkill for piecewise algo
//Did we get at least 1 solid?
TopExp_Explorer xp;
xp.Init(mkCommon.Shape(),TopAbs_SOLID);
xp.Init(mkCommon.Shape(), TopAbs_SOLID);
if (xp.More() != Standard_True) {
continue;
}
@@ -338,7 +338,7 @@ void DrawViewDetail::makeDetailShape(TopoDS_Shape& shape,
for (; expl.More(); expl.Next()) {
const TopoDS_Shell& s = TopoDS::Shell(expl.Current());
BRepAlgoAPI_Common mkCommon(s,tool);
BRepAlgoAPI_Common mkCommon(s, tool);
if (!mkCommon.IsDone()) {
continue;
}
@@ -348,7 +348,7 @@ void DrawViewDetail::makeDetailShape(TopoDS_Shape& shape,
//this might be overkill for piecewise algo
//Did we get at least 1 shell?
TopExp_Explorer xp;
xp.Init(mkCommon.Shape(),TopAbs_SHELL);
xp.Init(mkCommon.Shape(), TopAbs_SHELL);
if (xp.More() != Standard_True) {
continue;
}
@@ -395,10 +395,10 @@ void DrawViewDetail::makeDetailShape(TopoDS_Shape& shape,
getScale());
}
Base::Vector3d stdOrg(0.0,0.0,0.0);
Base::Vector3d stdOrg(0.0, 0.0, 0.0);
m_viewAxis = dvp->getProjectionCS(stdOrg);
if (!DrawUtil::fpCompare(Rotation.getValue(),0.0)) {
if (!DrawUtil::fpCompare(Rotation.getValue(), 0.0)) {
m_scaledShape = TechDraw::rotateShape(m_scaledShape,
m_viewAxis,
Rotation.getValue());
@@ -406,7 +406,7 @@ void DrawViewDetail::makeDetailShape(TopoDS_Shape& shape,
} //end try block
catch (Standard_Failure& e1) {
Base::Console().Message("DVD::makeDetailShape - failed to create detail %s - %s **\n",getNameInDocument(),e1.GetMessageString());
Base::Console().Message("DVD::makeDetailShape - failed to create detail %s - %s **\n", getNameInDocument(), e1.GetMessageString());
return;
}
@@ -491,7 +491,7 @@ bool DrawViewDetail::debugDetail() const
Base::Reference<ParameterGrp> hGrp = App::GetApplication().GetUserParameter()
.GetGroup("BaseApp")->GetGroup("Preferences")->GetGroup("Mod/TechDraw/debug");
return hGrp->GetBool("debugDetail",false);
return hGrp->GetBool("debugDetail", false);
}
void DrawViewDetail::unsetupObject()

View File

@@ -20,8 +20,8 @@
* *
***************************************************************************/
#ifndef _DrawViewDetail_h_
#define _DrawViewDetail_h_
#ifndef DrawViewDetail_h_
#define DrawViewDetail_h_
#include <Mod/TechDraw/TechDrawGlobal.h>

View File

@@ -49,8 +49,6 @@
#include "DrawViewPart.h"
#include "DrawViewDimExtent.h"
#include "DrawDimHelper.h"
#include "DrawUtil.h"
#include "LineGroup.h"
#include <Mod/TechDraw/App/DrawViewDimExtentPy.h> // generated from DrawViewDimExtentPy.xml
@@ -68,23 +66,19 @@ DrawViewDimExtent::DrawViewDimExtent(void)
//Cosmetic End points are stored in DVD::References2d
App::PropertyLinkSubList Source3d; //Part::Feature & SubElements TBI
ADD_PROPERTY_TYPE(Source,(nullptr,nullptr),"",(App::PropertyType)(App::Prop_Output),"View (Edges) to dimension");
ADD_PROPERTY_TYPE(Source, (nullptr, nullptr), "", (App::PropertyType)(App::Prop_Output), "View (Edges) to dimension");
Source.setScope(App::LinkScope::Global);
ADD_PROPERTY_TYPE(Source3d,(nullptr,nullptr),"",(App::PropertyType)(App::Prop_Output),"View (Edges) to dimension"); //TBI
ADD_PROPERTY_TYPE(Source3d, (nullptr, nullptr), "", (App::PropertyType)(App::Prop_Output), "View (Edges) to dimension"); //TBI
Source3d.setScope(App::LinkScope::Global);
ADD_PROPERTY_TYPE(DirExtent ,(0),"",App::Prop_Output,"Horizontal / Vertical");
ADD_PROPERTY_TYPE(DirExtent ,(0), "", App::Prop_Output, "Horizontal / Vertical");
ADD_PROPERTY_TYPE(CosmeticTags ,(""),"",App::Prop_Output,"Id of cosmetic endpoints");
ADD_PROPERTY_TYPE(CosmeticTags ,(""), "", App::Prop_Output, "Id of cosmetic endpoints");
//hide the properties the user can't edit in the property editor
Source3d.setStatus(App::Property::Hidden,true); //TBI
Source3d.setStatus(App::Property::Hidden, true); //TBI
}
DrawViewDimExtent::~DrawViewDimExtent()
{
}
void DrawViewDimExtent::onChanged(const App::Property* prop)
{
if (!isRestoring()) {
@@ -173,7 +167,7 @@ std::vector<std::string> DrawViewDimExtent::getSubNames(void)
pointPair DrawViewDimExtent::getPointsTwoVerts()
{
// Base::Console().Message("DVDE::getPointsTwoVerts() - %s\n",getNameInDocument());
// Base::Console().Message("DVDE::getPointsTwoVerts() - %s\n", getNameInDocument());
pointPair errorValue(
Base::Vector3d(0.0, 0.0, 0.0),
Base::Vector3d(0.0, 0.0, 0.0)
@@ -188,7 +182,7 @@ pointPair DrawViewDimExtent::getPointsTwoVerts()
if (cTags.empty()) {
return errorValue;
}
TechDraw::VertexPtr v0 = dvp->getProjVertexByCosTag(cTags[0]);
TechDraw::VertexPtr v1 = dvp->getProjVertexByCosTag(cTags[1]);
if (!v0 || !v1)
@@ -200,7 +194,7 @@ pointPair DrawViewDimExtent::getPointsTwoVerts()
//! validate 2D references - only checks if the target exists
bool DrawViewDimExtent::checkReferences2D() const
{
// Base::Console().Message("DVDE::checkReFerences2d() - %s\n",getNameInDocument());
// Base::Console().Message("DVDE::checkReFerences2d() - %s\n", getNameInDocument());
TechDraw::DrawViewPart* dvp = getViewPart();
if (!dvp) {
return false;
@@ -210,7 +204,7 @@ bool DrawViewDimExtent::checkReferences2D() const
if (cTags.empty()) {
return false;
}
CosmeticVertex* cv0 = dvp->getCosmeticVertex(cTags[0]);
CosmeticVertex* cv1 = dvp->getCosmeticVertex(cTags[1]);
if (!cv0 || !cv1)
@@ -238,7 +232,7 @@ PyObject *DrawViewDimExtent::getPyObject(void)
{
if (PythonObject.is(Py::_None())) {
// ref counter is set to 1
PythonObject = Py::Object(new DrawViewDimExtentPy(this),true);
PythonObject = Py::Object(new DrawViewDimExtentPy(this), true);
}
return Py::new_reference_to(PythonObject);
}

View File

@@ -20,8 +20,8 @@
* *
***************************************************************************/
#ifndef _TechDraw_DrawViewDimExtent_h_
#define _TechDraw_DrawViewDimExtent_h_
#ifndef TechDraw_DrawViewDimExtent_h_
#define TechDraw_DrawViewDimExtent_h_
#include <Mod/TechDraw/TechDrawGlobal.h>
@@ -42,7 +42,7 @@ class TechDrawExport DrawViewDimExtent : public TechDraw::DrawViewDimension
public:
/// Constructor
DrawViewDimExtent();
~DrawViewDimExtent() override;
~DrawViewDimExtent() = default;
App::PropertyLinkSubList Source; //DrawViewPart & SubElements(Edges)
//Cosmetic End points are stored in DVD::References2d

View File

@@ -105,22 +105,22 @@ static const App::PropertyQuantityConstraint::Constraints PositiveConstraint = {
DrawViewDimension::DrawViewDimension()
{
ADD_PROPERTY_TYPE(References2D, (nullptr,nullptr), "", (App::Prop_None), "Projected Geometry References");
ADD_PROPERTY_TYPE(References2D, (nullptr, nullptr), "", (App::Prop_None), "Projected Geometry References");
References2D.setScope(App::LinkScope::Global);
ADD_PROPERTY_TYPE(References3D, (nullptr,nullptr), "", (App::Prop_None), "3D Geometry References");
ADD_PROPERTY_TYPE(References3D, (nullptr, nullptr), "", (App::Prop_None), "3D Geometry References");
References3D.setScope(App::LinkScope::Global);
ADD_PROPERTY_TYPE(FormatSpec, (getDefaultFormatSpec()), "Format", App::Prop_Output,"Dimension format");
ADD_PROPERTY_TYPE(FormatSpec, (getDefaultFormatSpec()), "Format", App::Prop_Output, "Dimension format");
ADD_PROPERTY_TYPE(FormatSpecOverTolerance, (getDefaultFormatSpec(true)), "Format", App::Prop_Output, "Dimension overtolerance format");
ADD_PROPERTY_TYPE(FormatSpecUnderTolerance, (getDefaultFormatSpec(true)), "Format", App::Prop_Output, "Dimension undertolerance format");
ADD_PROPERTY_TYPE(Arbitrary,(false), "Format", App::Prop_Output, "Value overridden by user");
ADD_PROPERTY_TYPE(Arbitrary, (false), "Format", App::Prop_Output, "Value overridden by user");
ADD_PROPERTY_TYPE(ArbitraryTolerances, (false), "Format", App::Prop_Output, "Tolerance values overridden by user");
Type.setEnums(TypeEnums); //dimension type: length, radius etc
ADD_PROPERTY(Type, ((long)0));
MeasureType.setEnums(MeasureTypeEnums);
ADD_PROPERTY(MeasureType, ((long)1)); //Projected (or True) measurement
ADD_PROPERTY_TYPE(TheoreticalExact,(false), "", App::Prop_Output, "If theoretical exact (basic) dimension");
ADD_PROPERTY_TYPE(TheoreticalExact, (false), "", App::Prop_Output, "If theoretical exact (basic) dimension");
ADD_PROPERTY_TYPE(EqualTolerance, (true), "", App::Prop_Output, "If over- and undertolerance are equal");
ADD_PROPERTY_TYPE(OverTolerance, (0.0), "", App::Prop_Output, "Overtolerance value\nIf 'Equal Tolerance' is true this is also\nthe negated value for 'Under Tolerance'");
@@ -131,9 +131,9 @@ DrawViewDimension::DrawViewDimension()
UnderTolerance.setConstraints(&ToleranceConstraint);
ADD_PROPERTY_TYPE(Inverted, (false), "", App::Prop_Output, "The dimensional value is displayed inverted");
ADD_PROPERTY_TYPE(AngleOverride,(false), "Override", App::Prop_Output, "User specified angles");
ADD_PROPERTY_TYPE(LineAngle,(0.0), "Override", App::Prop_Output, "Dimension line angle");
ADD_PROPERTY_TYPE(ExtensionAngle,(0.0), "Override", App::Prop_Output, "Extension line angle");
ADD_PROPERTY_TYPE(AngleOverride, (false), "Override", App::Prop_Output, "User specified angles");
ADD_PROPERTY_TYPE(LineAngle, (0.0), "Override", App::Prop_Output, "Dimension line angle");
ADD_PROPERTY_TYPE(ExtensionAngle, (0.0), "Override", App::Prop_Output, "Extension line angle");
// hide the DrawView properties that don't apply to Dimensions
ScaleType.setStatus(App::Property::ReadOnly, true);
@@ -150,7 +150,7 @@ DrawViewDimension::DrawViewDimension()
FormatSpecUnderTolerance.setStatus(App::Property::ReadOnly, true);
measurement = new Measure::Measurement();
//TODO: should have better initial datumLabel position than (0,0) in the DVP?? something closer to the object being measured?
//TODO: should have better initial datumLabel position than (0, 0) in the DVP?? something closer to the object being measured?
//initialize the descriptive geometry.
//TODO: should this be more like DVP with a "geometry object"?
@@ -168,26 +168,26 @@ DrawViewDimension::~DrawViewDimension()
void DrawViewDimension::resetLinear()
{
m_linearPoints.first = Base::Vector3d(0,0,0);
m_linearPoints.second = Base::Vector3d(0,0,0);
m_linearPoints.first = Base::Vector3d(0, 0,0);
m_linearPoints.second = Base::Vector3d(0, 0,0);
}
void DrawViewDimension::resetAngular()
{
m_anglePoints.ends.first = Base::Vector3d(0,0,0);
m_anglePoints.ends.second = Base::Vector3d(0,0,0);
m_anglePoints.vertex = Base::Vector3d(0,0,0);
m_anglePoints.ends.first = Base::Vector3d(0, 0,0);
m_anglePoints.ends.second = Base::Vector3d(0, 0,0);
m_anglePoints.vertex = Base::Vector3d(0, 0,0);
}
void DrawViewDimension::resetArc()
{
m_arcPoints.isArc = false;
m_arcPoints.center = Base::Vector3d(0,0,0);
m_arcPoints.onCurve.first = Base::Vector3d(0,0,0);
m_arcPoints.onCurve.second = Base::Vector3d(0,0,0);
m_arcPoints.arcEnds.first = Base::Vector3d(0,0,0);
m_arcPoints.arcEnds.second = Base::Vector3d(0,0,0);
m_arcPoints.midArc = Base::Vector3d(0,0,0);
m_arcPoints.center = Base::Vector3d(0, 0,0);
m_arcPoints.onCurve.first = Base::Vector3d(0, 0,0);
m_arcPoints.onCurve.second = Base::Vector3d(0, 0,0);
m_arcPoints.arcEnds.first = Base::Vector3d(0, 0,0);
m_arcPoints.arcEnds.second = Base::Vector3d(0, 0,0);
m_arcPoints.midArc = Base::Vector3d(0, 0,0);
m_arcPoints.arcCW = false;
}
@@ -268,7 +268,7 @@ void DrawViewDimension::onChanged(const App::Property* prop)
}
}
requestPaint();
}
}
else if (prop == &OverTolerance) {
// if EqualTolerance set negated overtolerance for untertolerance
if (EqualTolerance.getValue()) {
@@ -440,26 +440,26 @@ App::DocumentObjectExecReturn *DrawViewDimension::execute()
TechDraw::BaseGeomPtr base = getViewPart()->getGeomByIndex(idx);
TechDraw::CirclePtr circle;
arcPoints pts;
pts.center = Base::Vector3d(0.0,0.0,0.0);
pts.center = Base::Vector3d(0.0, 0.0, 0.0);
pts.radius = 0.0;
if ( (base && base->geomType == TechDraw::GeomType::CIRCLE) ||
(base && base->geomType == TechDraw::GeomType::ARCOFCIRCLE)) {
circle = std::static_pointer_cast<TechDraw::Circle> (base);
pts.center = Base::Vector3d(circle->center.x,circle->center.y,0.0);
pts.center = Base::Vector3d(circle->center.x, circle->center.y, 0.0);
pts.radius = circle->radius;
if (base->geomType == TechDraw::GeomType::ARCOFCIRCLE) {
// TechDraw::AOCPtr aoc = std::static_pointer_cast<TechDraw::AOC> (circle);
TechDraw::AOCPtr aoc = std::static_pointer_cast<TechDraw::AOC> (base);
pts.isArc = true;
pts.onCurve.first = Base::Vector3d(aoc->midPnt.x,aoc->midPnt.y,0.0);
pts.midArc = Base::Vector3d(aoc->midPnt.x,aoc->midPnt.y,0.0);
pts.arcEnds.first = Base::Vector3d(aoc->startPnt.x,aoc->startPnt.y,0.0);
pts.arcEnds.second = Base::Vector3d(aoc->endPnt.x,aoc->endPnt.y,0.0);
pts.onCurve.first = Base::Vector3d(aoc->midPnt.x, aoc->midPnt.y, 0.0);
pts.midArc = Base::Vector3d(aoc->midPnt.x, aoc->midPnt.y, 0.0);
pts.arcEnds.first = Base::Vector3d(aoc->startPnt.x, aoc->startPnt.y, 0.0);
pts.arcEnds.second = Base::Vector3d(aoc->endPnt.x, aoc->endPnt.y, 0.0);
pts.arcCW = aoc->cw;
} else {
pts.isArc = false;
pts.onCurve.first = pts.center + Base::Vector3d(1,0,0) * circle->radius; //arbitrary point on edge
pts.onCurve.second = pts.center + Base::Vector3d(-1,0,0) * circle->radius; //arbitrary point on edge
pts.onCurve.first = pts.center + Base::Vector3d(1, 0,0) * circle->radius; //arbitrary point on edge
pts.onCurve.second = pts.center + Base::Vector3d(-1, 0,0) * circle->radius; //arbitrary point on edge
}
} else if ((base && base->geomType == TechDraw::GeomType::ELLIPSE) ||
(base && base->geomType == TechDraw::GeomType::ARCOFELLIPSE)) {
@@ -474,8 +474,8 @@ App::DocumentObjectExecReturn *DrawViewDimension::execute()
0.0);
pts.radius = rAvg;
pts.isArc = false;
pts.onCurve.first = pts.center + Base::Vector3d(1,0,0) * rAvg; //arbitrary point on edge
pts.onCurve.second = pts.center + Base::Vector3d(-1,0,0) * rAvg; //arbitrary point on edge
pts.onCurve.first = pts.center + Base::Vector3d(1, 0,0) * rAvg; //arbitrary point on edge
pts.onCurve.second = pts.center + Base::Vector3d(-1, 0,0) * rAvg; //arbitrary point on edge
} else {
TechDraw::AOEPtr aoe = std::static_pointer_cast<TechDraw::AOE> (base);
double r1 = aoe->minor;
@@ -486,41 +486,41 @@ App::DocumentObjectExecReturn *DrawViewDimension::execute()
aoe->center.y,
0.0);
pts.radius = rAvg;
pts.arcEnds.first = Base::Vector3d(aoe->startPnt.x,aoe->startPnt.y,0.0);
pts.arcEnds.second = Base::Vector3d(aoe->endPnt.x,aoe->endPnt.y,0.0);
pts.midArc = Base::Vector3d(aoe->midPnt.x,aoe->midPnt.y,0.0);
pts.arcEnds.first = Base::Vector3d(aoe->startPnt.x, aoe->startPnt.y, 0.0);
pts.arcEnds.second = Base::Vector3d(aoe->endPnt.x, aoe->endPnt.y, 0.0);
pts.midArc = Base::Vector3d(aoe->midPnt.x, aoe->midPnt.y, 0.0);
pts.arcCW = aoe->cw;
pts.onCurve.first = Base::Vector3d(aoe->midPnt.x,aoe->midPnt.y,0.0);
pts.onCurve.second = pts.center + Base::Vector3d(-1,0,0) * rAvg; //arbitrary point on edge
pts.onCurve.first = Base::Vector3d(aoe->midPnt.x, aoe->midPnt.y, 0.0);
pts.onCurve.second = pts.center + Base::Vector3d(-1, 0,0) * rAvg; //arbitrary point on edge
}
} else if (base && base->geomType == TechDraw::GeomType::BSPLINE) {
TechDraw::BSplinePtr spline;
spline = std::static_pointer_cast<TechDraw::BSpline> (base);
if (spline->isCircle()) {
bool circ,arc;
bool circ, arc;
double rad;
Base::Vector3d center;
spline->getCircleParms(circ,rad,center,arc);
pts.center = Base::Vector3d(center.x,center.y,0.0);
spline->getCircleParms(circ, rad, center, arc);
pts.center = Base::Vector3d(center.x, center.y, 0.0);
pts.radius = rad;
pts.arcEnds.first = Base::Vector3d(spline->startPnt.x,spline->startPnt.y,0.0);
pts.arcEnds.second = Base::Vector3d(spline->endPnt.x,spline->endPnt.y,0.0);
pts.midArc = Base::Vector3d(spline->midPnt.x,spline->midPnt.y,0.0);
pts.arcEnds.first = Base::Vector3d(spline->startPnt.x, spline->startPnt.y, 0.0);
pts.arcEnds.second = Base::Vector3d(spline->endPnt.x, spline->endPnt.y, 0.0);
pts.midArc = Base::Vector3d(spline->midPnt.x, spline->midPnt.y, 0.0);
pts.isArc = arc;
pts.arcCW = spline->cw;
if (arc) {
pts.onCurve.first = Base::Vector3d(spline->midPnt.x,spline->midPnt.y,0.0);
pts.onCurve.first = Base::Vector3d(spline->midPnt.x, spline->midPnt.y, 0.0);
} else {
pts.onCurve.first = pts.center + Base::Vector3d(1,0,0) * rad; //arbitrary point on edge
pts.onCurve.second = pts.center + Base::Vector3d(-1,0,0) * rad; //arbitrary point on edge
pts.onCurve.first = pts.center + Base::Vector3d(1, 0,0) * rad; //arbitrary point on edge
pts.onCurve.second = pts.center + Base::Vector3d(-1, 0,0) * rad; //arbitrary point on edge
}
} else {
//fubar - can't have non-circular spline as target of Radius dimension
Base::Console().Error("Dimension %s refers to invalid BSpline\n",getNameInDocument());
Base::Console().Error("Dimension %s refers to invalid BSpline\n", getNameInDocument());
return App::DocumentObject::StdReturn;
}
} else {
Base::Console().Log("Error: DVD - %s - 2D references are corrupt\n",getNameInDocument());
Base::Console().Log("Error: DVD - %s - 2D references are corrupt\n", getNameInDocument());
return App::DocumentObject::StdReturn;
}
m_arcPoints = pts;
@@ -530,25 +530,25 @@ App::DocumentObjectExecReturn *DrawViewDimension::execute()
TechDraw::BaseGeomPtr base = getViewPart()->getGeomByIndex(idx);
TechDraw::CirclePtr circle;
arcPoints pts;
pts.center = Base::Vector3d(0.0,0.0,0.0);
pts.center = Base::Vector3d(0.0, 0.0, 0.0);
pts.radius = 0.0;
if ((base && base->geomType == TechDraw::GeomType::CIRCLE) ||
(base && base->geomType == TechDraw::GeomType::ARCOFCIRCLE)) {
circle = std::static_pointer_cast<TechDraw::Circle> (base);
pts.center = Base::Vector3d(circle->center.x,circle->center.y,0.0);
pts.center = Base::Vector3d(circle->center.x, circle->center.y, 0.0);
pts.radius = circle->radius;
if (base->geomType == TechDraw::GeomType::ARCOFCIRCLE) {
TechDraw::AOCPtr aoc = std::static_pointer_cast<TechDraw::AOC> (circle);
pts.isArc = true;
pts.onCurve.first = Base::Vector3d(aoc->midPnt.x,aoc->midPnt.y,0.0);
pts.midArc = Base::Vector3d(aoc->midPnt.x,aoc->midPnt.y,0.0);
pts.arcEnds.first = Base::Vector3d(aoc->startPnt.x,aoc->startPnt.y,0.0);
pts.arcEnds.second = Base::Vector3d(aoc->endPnt.x,aoc->endPnt.y,0.0);
pts.onCurve.first = Base::Vector3d(aoc->midPnt.x, aoc->midPnt.y, 0.0);
pts.midArc = Base::Vector3d(aoc->midPnt.x, aoc->midPnt.y, 0.0);
pts.arcEnds.first = Base::Vector3d(aoc->startPnt.x, aoc->startPnt.y, 0.0);
pts.arcEnds.second = Base::Vector3d(aoc->endPnt.x, aoc->endPnt.y, 0.0);
pts.arcCW = aoc->cw;
} else {
pts.isArc = false;
pts.onCurve.first = pts.center + Base::Vector3d(1,0,0) * circle->radius; //arbitrary point on edge
pts.onCurve.second = pts.center + Base::Vector3d(-1,0,0) * circle->radius; //arbitrary point on edge
pts.onCurve.first = pts.center + Base::Vector3d(1, 0,0) * circle->radius; //arbitrary point on edge
pts.onCurve.second = pts.center + Base::Vector3d(-1, 0,0) * circle->radius; //arbitrary point on edge
}
} else if ( (base && base->geomType == TechDraw::GeomType::ELLIPSE) ||
(base && base->geomType == TechDraw::GeomType::ARCOFELLIPSE) ) {
@@ -562,8 +562,8 @@ App::DocumentObjectExecReturn *DrawViewDimension::execute()
0.0);
pts.radius = rAvg;
pts.isArc = false;
pts.onCurve.first = pts.center + Base::Vector3d(1,0,0) * rAvg; //arbitrary point on edge
pts.onCurve.second = pts.center + Base::Vector3d(-1,0,0) * rAvg; //arbitrary point on edge
pts.onCurve.first = pts.center + Base::Vector3d(1, 0,0) * rAvg; //arbitrary point on edge
pts.onCurve.second = pts.center + Base::Vector3d(-1, 0,0) * rAvg; //arbitrary point on edge
} else {
TechDraw::AOEPtr aoe = std::static_pointer_cast<TechDraw::AOE> (base);
double r1 = aoe->minor;
@@ -574,47 +574,47 @@ App::DocumentObjectExecReturn *DrawViewDimension::execute()
aoe->center.y,
0.0);
pts.radius = rAvg;
pts.arcEnds.first = Base::Vector3d(aoe->startPnt.x,aoe->startPnt.y,0.0);
pts.arcEnds.second = Base::Vector3d(aoe->endPnt.x,aoe->endPnt.y,0.0);
pts.midArc = Base::Vector3d(aoe->midPnt.x,aoe->midPnt.y,0.0);
pts.arcEnds.first = Base::Vector3d(aoe->startPnt.x, aoe->startPnt.y, 0.0);
pts.arcEnds.second = Base::Vector3d(aoe->endPnt.x, aoe->endPnt.y, 0.0);
pts.midArc = Base::Vector3d(aoe->midPnt.x, aoe->midPnt.y, 0.0);
pts.arcCW = aoe->cw;
pts.onCurve.first = pts.center + Base::Vector3d(1,0,0) * rAvg; //arbitrary point on edge
pts.onCurve.second = pts.center + Base::Vector3d(-1,0,0) * rAvg; //arbitrary point on edge
pts.onCurve.first = pts.center + Base::Vector3d(1, 0,0) * rAvg; //arbitrary point on edge
pts.onCurve.second = pts.center + Base::Vector3d(-1, 0,0) * rAvg; //arbitrary point on edge
}
} else if (base && base->geomType == TechDraw::GeomType::BSPLINE) {
TechDraw::BSplinePtr spline = std::static_pointer_cast<TechDraw::BSpline> (base);
if (spline->isCircle()) {
bool circ,arc;
bool circ, arc;
double rad;
Base::Vector3d center;
spline->getCircleParms(circ,rad,center,arc);
pts.center = Base::Vector3d(center.x,center.y,0.0);
spline->getCircleParms(circ, rad, center, arc);
pts.center = Base::Vector3d(center.x, center.y, 0.0);
pts.radius = rad;
pts.arcEnds.first = Base::Vector3d(spline->startPnt.x,spline->startPnt.y,0.0);
pts.arcEnds.second = Base::Vector3d(spline->endPnt.x,spline->endPnt.y,0.0);
pts.midArc = Base::Vector3d(spline->midPnt.x,spline->midPnt.y,0.0);
pts.arcEnds.first = Base::Vector3d(spline->startPnt.x, spline->startPnt.y, 0.0);
pts.arcEnds.second = Base::Vector3d(spline->endPnt.x, spline->endPnt.y, 0.0);
pts.midArc = Base::Vector3d(spline->midPnt.x, spline->midPnt.y, 0.0);
pts.isArc = arc;
pts.arcCW = spline->cw;
if (arc) {
pts.onCurve.first = Base::Vector3d(spline->midPnt.x,spline->midPnt.y,0.0);
pts.onCurve.first = Base::Vector3d(spline->midPnt.x, spline->midPnt.y, 0.0);
} else {
pts.onCurve.first = pts.center + Base::Vector3d(1,0,0) * rad; //arbitrary point on edge
pts.onCurve.second = pts.center + Base::Vector3d(-1,0,0) * rad; //arbitrary point on edge
pts.onCurve.first = pts.center + Base::Vector3d(1, 0,0) * rad; //arbitrary point on edge
pts.onCurve.second = pts.center + Base::Vector3d(-1, 0,0) * rad; //arbitrary point on edge
}
} else {
//fubar - can't have non-circular spline as target of Diameter dimension
Base::Console().Error("%s: can not make a Circle from this BSpline edge\n",getNameInDocument());
Base::Console().Error("%s: can not make a Circle from this BSpline edge\n", getNameInDocument());
return App::DocumentObject::StdReturn;
}
} else {
Base::Console().Log("Error: DVD - %s - 2D references are corrupt\n",getNameInDocument());
Base::Console().Log("Error: DVD - %s - 2D references are corrupt\n", getNameInDocument());
return App::DocumentObject::StdReturn;
}
m_arcPoints = pts;
m_hasGeometry = true;
} else if (Type.isValue("Angle")){
if (getRefType() != twoEdge) {
Base::Console().Log("Error: DVD - %s - 2D references are corrupt\n",getNameInDocument());
Base::Console().Log("Error: DVD - %s - 2D references are corrupt\n", getNameInDocument());
return App::DocumentObject::StdReturn;
}
int idx0 = DrawUtil::getIndexFromName(subElements[0]);
@@ -626,19 +626,19 @@ App::DocumentObjectExecReturn *DrawViewDimension::execute()
if (edge0 && edge0->geomType == TechDraw::GeomType::GENERIC) {
gen0 = std::static_pointer_cast<TechDraw::Generic>(edge0);
} else {
Base::Console().Log("Error: DVD - %s - 2D references are corrupt\n",getNameInDocument());
Base::Console().Log("Error: DVD - %s - 2D references are corrupt\n", getNameInDocument());
return App::DocumentObject::StdReturn;
}
if (edge1 && edge1->geomType == TechDraw::GeomType::GENERIC) {
gen1 = std::static_pointer_cast<TechDraw::Generic>(edge1);
} else {
Base::Console().Log("Error: DVD - %s - 2D references are corrupt\n",getNameInDocument());
Base::Console().Log("Error: DVD - %s - 2D references are corrupt\n", getNameInDocument());
return App::DocumentObject::StdReturn;
}
anglePoints pts;
Base::Vector3d apex = gen0->apparentInter(gen1);
Base::Vector3d extPoint0,extPoint1;
Base::Vector3d extPoint0, extPoint1;
Base::Vector3d farPoint0, farPoint1;
//pick the end of gen0 farthest from the apex
if ((gen0->getStartPoint() - apex).Length() >
@@ -710,7 +710,7 @@ App::DocumentObjectExecReturn *DrawViewDimension::execute()
m_hasGeometry = true;
} else if (Type.isValue("Angle3Pt")){
if (getRefType() != threeVertex) {
Base::Console().Log("Error: DVD - %s - 2D references are corrupt\n",getNameInDocument());
Base::Console().Log("Error: DVD - %s - 2D references are corrupt\n", getNameInDocument());
return App::DocumentObject::StdReturn;
}
int idx0 = DrawUtil::getIndexFromName(subElements[0]);
@@ -721,7 +721,7 @@ App::DocumentObjectExecReturn *DrawViewDimension::execute()
TechDraw::VertexPtr vert1 = getViewPart()->getProjVertexByIndex(idx1);
TechDraw::VertexPtr vert2 = getViewPart()->getProjVertexByIndex(idx2);
if (!vert0 || !vert1 || !vert2) {
Base::Console().Log("Error: DVD - %s - 2D references are corrupt\n",getNameInDocument());
Base::Console().Log("Error: DVD - %s - 2D references are corrupt\n", getNameInDocument());
return App::DocumentObject::StdReturn;
}
@@ -867,7 +867,7 @@ std::string DrawViewDimension::formatValue(qreal value,
if (pos != -1) {
qUserStringUnits = rxUnits.cap(0); // entire capture - non numerics at end of qUserString
}
// get value in the base unit with default decimals
// for the conversion we use the same method as in DlgUnitsCalculator::valueChanged
// get the conversion factor for the unit
@@ -924,7 +924,7 @@ std::string DrawViewDimension::formatValue(qreal value,
}
}
std::string formattedValueString = formattedValue.toStdString();
if (partial == 0) { //full text for multi-value schemas
@@ -1177,7 +1177,7 @@ double DrawViewDimension::getDimValue()
} else {
// Projected Values
if (!checkReferences2D()) {
Base::Console().Warning("DVD::getDimValue - %s - 2D references are corrupt (5)\n",getNameInDocument());
Base::Console().Warning("DVD::getDimValue - %s - 2D references are corrupt (5)\n", getNameInDocument());
return result;
}
if ( Type.isValue("Distance") ||
@@ -1227,14 +1227,14 @@ double DrawViewDimension::getDimValue()
pointPair DrawViewDimension::getPointsOneEdge()
{
// Base::Console().Message("DVD::getPointsOneEdge() - %s\n",getNameInDocument());
// Base::Console().Message("DVD::getPointsOneEdge() - %s\n", getNameInDocument());
const std::vector<std::string> &subElements = References2D.getSubValues();
//TODO: Check for straight line Edge?
int idx = DrawUtil::getIndexFromName(subElements[0]);
TechDraw::BaseGeomPtr geom = getViewPart()->getGeomByIndex(idx);
if (!geom || geom->geomType != TechDraw::GeomType::GENERIC) {
Base::Console().Error("Error: DVD - %s - 2D references are corrupt (1)\n",getNameInDocument());
Base::Console().Error("Error: DVD - %s - 2D references are corrupt (1)\n", getNameInDocument());
return pointPair();
}
@@ -1244,7 +1244,7 @@ pointPair DrawViewDimension::getPointsOneEdge()
pointPair DrawViewDimension::getPointsTwoEdges()
{
// Base::Console().Message("DVD::getPointsTwoEdges() - %s\n",getNameInDocument());
// Base::Console().Message("DVD::getPointsTwoEdges() - %s\n", getNameInDocument());
pointPair result;
const std::vector<std::string> &subElements = References2D.getSubValues();
@@ -1253,16 +1253,16 @@ pointPair DrawViewDimension::getPointsTwoEdges()
TechDraw::BaseGeomPtr geom0 = getViewPart()->getGeomByIndex(idx0);
TechDraw::BaseGeomPtr geom1 = getViewPart()->getGeomByIndex(idx1);
if (!geom0 || !geom1) {
Base::Console().Error("Error: DVD - %s - 2D references are corrupt (2)\n",getNameInDocument());
Base::Console().Error("Error: DVD - %s - 2D references are corrupt (2)\n", getNameInDocument());
return result;
}
result = closestPoints(geom0->occEdge,geom1->occEdge);
result = closestPoints(geom0->occEdge, geom1->occEdge);
return result;
}
pointPair DrawViewDimension::getPointsTwoVerts()
{
// Base::Console().Message("DVD::getPointsTwoVerts() - %s\n",getNameInDocument());
// Base::Console().Message("DVD::getPointsTwoVerts() - %s\n", getNameInDocument());
pointPair result;
const std::vector<std::string> &subElements = References2D.getSubValues();
@@ -1271,7 +1271,7 @@ pointPair DrawViewDimension::getPointsTwoVerts()
TechDraw::VertexPtr v0 = getViewPart()->getProjVertexByIndex(idx0);
TechDraw::VertexPtr v1 = getViewPart()->getProjVertexByIndex(idx1);
if (!v0 || !v1) {
Base::Console().Error("Error: DVD - %s - 2D references are corrupt (3)\n",getNameInDocument());
Base::Console().Error("Error: DVD - %s - 2D references are corrupt (3)\n", getNameInDocument());
return result;
}
result.first = v0->pnt;
@@ -1299,7 +1299,7 @@ pointPair DrawViewDimension::getPointsEdgeVert()
return result;
}
result = closestPoints(e->occEdge,v->occVertex);
result = closestPoints(e->occEdge, v->occVertex);
return result;
}
@@ -1339,16 +1339,16 @@ int DrawViewDimension::getRefTypeSubElements(const std::vector<std::string> &sub
//! validate 2D references - only checks if the target exists
bool DrawViewDimension::checkReferences2D() const
{
// Base::Console().Message("DVD::checkReFerences2d() - %s\n",getNameInDocument());
// Base::Console().Message("DVD::checkReFerences2d() - %s\n", getNameInDocument());
const std::vector<App::DocumentObject*> &objects = References2D.getValues();
if (objects.empty()) {
Base::Console().Log("DVD::checkReferences2d() - %s - objects empty!\n",getNameInDocument());
Base::Console().Log("DVD::checkReferences2d() - %s - objects empty!\n", getNameInDocument());
return false;
}
const std::vector<std::string> &subElements = References2D.getSubValues();
if (subElements.empty()) {
Base::Console().Log("DVD::checkRegerences2d() - %s - subelements empty!\n",getNameInDocument());
Base::Console().Log("DVD::checkRegerences2d() - %s - subelements empty!\n", getNameInDocument());
return false;
}
@@ -1356,7 +1356,7 @@ bool DrawViewDimension::checkReferences2D() const
if (s.empty()) {
return false;
}
int idx = DrawUtil::getIndexFromName(s);
if (DrawUtil::getGeomTypeFromName(s) == "Edge") {
TechDraw::BaseGeomPtr geom = getViewPart()->getGeomByIndex(idx);
@@ -1385,9 +1385,9 @@ pointPair DrawViewDimension::closestPoints(TopoDS_Shape s1,
int count = extss.NbSolution();
if (count != 0) {
gp_Pnt p = extss.PointOnShape1(1);
result.first = Base::Vector3d(p.X(),p.Y(),p.Z());
result.first = Base::Vector3d(p.X(), p.Y(), p.Z());
p = extss.PointOnShape2(1);
result.second = Base::Vector3d(p.X(),p.Y(),p.Z());
result.second = Base::Vector3d(p.X(), p.Y(), p.Z());
} //TODO: else { explode }
return result;
@@ -1415,14 +1415,14 @@ void DrawViewDimension::clear3DMeasurements()
void DrawViewDimension::dumpRefs2D(const char* text) const
{
Base::Console().Message("DUMP - %s\n",text);
Base::Console().Message("DUMP - %s\n", text);
const std::vector<App::DocumentObject*> &objects = References2D.getValues();
const std::vector<std::string> &subElements = References2D.getSubValues();
std::vector<App::DocumentObject*>::const_iterator objIt = objects.begin();
std::vector<std::string>::const_iterator subIt = subElements.begin();
int i = 0;
for( ;objIt != objects.end();objIt++,subIt++,i++) {
Base::Console().Message("DUMP - ref: %d object: %s subElement: %s\n",i,(*objIt)->getNameInDocument(),(*subIt).c_str());
for( ;objIt != objects.end();objIt++, subIt++, i++) {
Base::Console().Message("DUMP - ref: %d object: %s subElement: %s\n", i,(*objIt)->getNameInDocument(), (*subIt).c_str());
}
}
@@ -1431,18 +1431,18 @@ double DrawViewDimension::dist2Segs(Base::Vector3d s1,
Base::Vector3d s2,
Base::Vector3d e2) const
{
gp_Pnt start(s1.x,s1.y,0.0);
gp_Pnt end(e1.x,e1.y,0.0);
gp_Pnt start(s1.x, s1.y, 0.0);
gp_Pnt end(e1.x, e1.y, 0.0);
TopoDS_Vertex v1 = BRepBuilderAPI_MakeVertex(start);
TopoDS_Vertex v2 = BRepBuilderAPI_MakeVertex(end);
BRepBuilderAPI_MakeEdge makeEdge1(v1,v2);
BRepBuilderAPI_MakeEdge makeEdge1(v1, v2);
TopoDS_Edge edge1 = makeEdge1.Edge();
start = gp_Pnt(s2.x,s2.y,0.0);
end = gp_Pnt(e2.x,e2.y,0.0);
start = gp_Pnt(s2.x, s2.y, 0.0);
end = gp_Pnt(e2.x, e2.y, 0.0);
v1 = BRepBuilderAPI_MakeVertex(start);
v2 = BRepBuilderAPI_MakeVertex(end);
BRepBuilderAPI_MakeEdge makeEdge2(v1,v2);
BRepBuilderAPI_MakeEdge makeEdge2(v1, v2);
TopoDS_Edge edge2 = makeEdge2.Edge();
BRepExtrema_DistShapeShape extss(edge1, edge2);
@@ -1465,13 +1465,13 @@ bool DrawViewDimension::leaderIntersectsArc(Base::Vector3d s, Base::Vector3d poi
TechDraw::BaseGeomPtr base = getViewPart()->getGeomByIndex(idx);
if ( base && base->geomType == TechDraw::GeomType::ARCOFCIRCLE ) {
TechDraw::AOCPtr aoc = std::static_pointer_cast<TechDraw::AOC> (base);
if (aoc->intersectsArc(s,pointOnCircle)) {
if (aoc->intersectsArc(s, pointOnCircle)) {
result = true;
}
} else if ( base && base->geomType == TechDraw::GeomType::BSPLINE ) {
TechDraw::BSplinePtr spline = std::static_pointer_cast<TechDraw::BSpline> (base);
if (spline->isCircle()) {
if (spline->intersectsArc(s,pointOnCircle)) {
if (spline->intersectsArc(s, pointOnCircle)) {
result = true;
}
}
@@ -1501,7 +1501,7 @@ pointPair DrawViewDimension::getArrowPositions()
bool DrawViewDimension::has2DReferences() const
{
// Base::Console().Message("DVD::has2DReferences() - %s\n",getNameInDocument());
// Base::Console().Message("DVD::has2DReferences() - %s\n", getNameInDocument());
const std::vector<App::DocumentObject*> &objects = References2D.getValues();
const std::vector<std::string> &SubNames = References2D.getSubValues();
if (objects.empty() || SubNames.empty()) {
@@ -1552,7 +1552,7 @@ std::string DrawViewDimension::getPrefix() const
} else if (Type.isValue("Diameter")){
Base::Reference<ParameterGrp> hGrp = App::GetApplication().GetUserParameter()
.GetGroup("BaseApp")->GetGroup("Preferences")->GetGroup("Mod/TechDraw/Dimensions");
return std::string(hGrp->GetASCII("DiameterSymbol","\xe2\x8c\x80")); // Diameter symbol
return std::string(hGrp->GetASCII("DiameterSymbol", "\xe2\x8c\x80")); // Diameter symbol
}
return "";
@@ -1577,14 +1577,14 @@ std::string DrawViewDimension::getDefaultFormatSpec(bool isToleranceFormat) cons
std::string prefix = getPrefix();
if (!prefix.empty()) {
qPrefix = QString::fromUtf8(prefix.data(),prefix.size());
qPrefix = QString::fromUtf8(prefix.data(), prefix.size());
}
formatSpec = qPrefix + format1 + formatPrecision + format2;
} else {
std::string prefix = getPrefix();
qPrefix = QString::fromUtf8(prefix.data(),prefix.size());
qPrefix = QString::fromUtf8(prefix.data(), prefix.size());
formatSpec = qPrefix + QString::fromStdString(prefFormat);
}
@@ -1599,7 +1599,7 @@ std::string DrawViewDimension::getDefaultFormatSpec(bool isToleranceFormat) cons
////! is refName a target of this Dim (2D references)
//bool DrawViewDimension::references(std::string refName) const
//{
// Base::Console().Message("DVD::references(%s) - %s\n",refName.c_str(),getNameInDocument());
// Base::Console().Message("DVD::references(%s) - %s\n", refName.c_str(), getNameInDocument());
// bool result = false;
// const std::vector<App::DocumentObject*> &objects = References2D.getValues();
// if (!objects.empty()) {
@@ -1622,7 +1622,7 @@ PyObject *DrawViewDimension::getPyObject()
{
if (PythonObject.is(Py::_None())) {
// ref counter is set to 1
PythonObject = Py::Object(new DrawViewDimensionPy(this),true);
PythonObject = Py::Object(new DrawViewDimensionPy(this), true);
}
return Py::new_reference_to(PythonObject);
}

View File

@@ -20,8 +20,8 @@
* *
***************************************************************************/
#ifndef _TechDraw_DrawViewDimension_h_
#define _TechDraw_DrawViewDimension_h_
#ifndef TechDraw_DrawViewDimension_h_
#define TechDraw_DrawViewDimension_h_
#include <Mod/TechDraw/TechDrawGlobal.h>
@@ -57,9 +57,9 @@ struct anglePoints
anglePoints()
{
ends.first = Base::Vector3d(0.0,0.0,0.0);
ends.second = Base::Vector3d(0.0,0.0,0.0);
vertex = Base::Vector3d(0.0,0.0,0.0);
ends.first = Base::Vector3d(0.0, 0.0, 0.0);
ends.second = Base::Vector3d(0.0, 0.0, 0.0);
vertex = Base::Vector3d(0.0, 0.0, 0.0);
}
anglePoints(const anglePoints& ap)
@@ -87,16 +87,16 @@ struct arcPoints
Base::Vector3d midArc;
bool arcCW;
arcPoints()
arcPoints()
{
isArc = false;
radius = 0.0;
center = Base::Vector3d(0.0,0.0,0.0);
onCurve.first = Base::Vector3d(0.0,0.0,0.0);
onCurve.second = Base::Vector3d(0.0,0.0,0.0);
arcEnds.first = Base::Vector3d(0.0,0.0,0.0);
arcEnds.second = Base::Vector3d(0.0,0.0,0.0);
midArc = Base::Vector3d(0.0,0.0,0.0);
center = Base::Vector3d(0.0, 0.0, 0.0);
onCurve.first = Base::Vector3d(0.0, 0.0, 0.0);
onCurve.second = Base::Vector3d(0.0, 0.0, 0.0);
arcEnds.first = Base::Vector3d(0.0, 0.0, 0.0);
arcEnds.second = Base::Vector3d(0.0, 0.0, 0.0);
midArc = Base::Vector3d(0.0, 0.0, 0.0);
arcCW = false;
}
@@ -193,7 +193,7 @@ public:
QStringList getPrefixSuffixSpec(QString fSpec);
virtual DrawViewPart* getViewPart() const;
QRectF getRect() const override { return QRectF(0,0,1,1);} //pretend dimensions always fit!
QRectF getRect() const override { return {0, 0, 1, 1}; } //pretend dimensions always fit!
virtual int getRefType() const; //Vertex-Vertex, Edge, Edge-Edge
static int getRefTypeSubElements(const std::vector<std::string> &); //Vertex-Vertex, Edge, Edge-Edge
void setAll3DMeasurement();

View File

@@ -51,22 +51,18 @@ DrawViewDraft::DrawViewDraft()
{
static const char *group = "Draft view";
ADD_PROPERTY_TYPE(Source ,(nullptr),group,App::Prop_None,"Draft object for this view");
ADD_PROPERTY_TYPE(Source ,(nullptr), group, App::Prop_None, "Draft object for this view");
Source.setScope(App::LinkScope::Global);
ADD_PROPERTY_TYPE(LineWidth,(0.35),group,App::Prop_None,"Line width of this view. If Override Style is false, this value multiplies the object line width");
ADD_PROPERTY_TYPE(FontSize,(12.0),group,App::Prop_None,"Text size for this view");
ADD_PROPERTY_TYPE(Direction ,(0,0,1.0),group,App::Prop_None,"Projection direction. The direction you are looking from.");
ADD_PROPERTY_TYPE(Color,(0.0f,0.0f,0.0f),group,App::Prop_None,"The default color of text and lines");
ADD_PROPERTY_TYPE(LineStyle,("Solid") ,group,App::Prop_None,"A line style to use for this view. Can be Solid, Dashed, Dashdot, Dot or a SVG pattern like 0.20,0.20");
ADD_PROPERTY_TYPE(LineSpacing,(1.0f),group,App::Prop_None,"The spacing between lines to use for multiline texts");
ADD_PROPERTY_TYPE(OverrideStyle,(false),group,App::Prop_None,"If True, line color, width and style of this view will override those of rendered objects");
ADD_PROPERTY_TYPE(LineWidth, (0.35), group, App::Prop_None, "Line width of this view. If Override Style is false, this value multiplies the object line width");
ADD_PROPERTY_TYPE(FontSize, (12.0), group, App::Prop_None, "Text size for this view");
ADD_PROPERTY_TYPE(Direction ,(0, 0,1.0), group, App::Prop_None, "Projection direction. The direction you are looking from.");
ADD_PROPERTY_TYPE(Color, (0.0f, 0.0f, 0.0f), group, App::Prop_None, "The default color of text and lines");
ADD_PROPERTY_TYPE(LineStyle, ("Solid") ,group, App::Prop_None, "A line style to use for this view. Can be Solid, Dashed, Dashdot, Dot or a SVG pattern like 0.20, 0.20");
ADD_PROPERTY_TYPE(LineSpacing, (1.0f), group, App::Prop_None, "The spacing between lines to use for multiline texts");
ADD_PROPERTY_TYPE(OverrideStyle, (false), group, App::Prop_None, "If True, line color, width and style of this view will override those of rendered objects");
ScaleType.setValue("Custom");
}
DrawViewDraft::~DrawViewDraft()
{
}
short DrawViewDraft::mustExecute() const
{
if (!isRestoring()) {
@@ -100,34 +96,34 @@ App::DocumentObjectExecReturn *DrawViewDraft::execute()
std::string svgTail = getSVGTail();
std::string FeatName = getNameInDocument();
std::string SourceName = sourceObj->getNameInDocument();
// Draft.get_svg(obj,scale=1,linewidth=0.35,fontsize=12,fillstyle="shape color",direction=None,linestyle=None,color=None,linespacing=None,techdraw=False)
// Draft.get_svg(obj, scale=1, linewidth=0.35, fontsize=12, fillstyle="shape color", direction=None, linestyle=None, color=None, linespacing=None, techdraw=False)
std::stringstream paramStr;
App::Color col = Color.getValue();
paramStr << ",scale=" << getScale()
<< ",linewidth=" << LineWidth.getValue()
<< ",fontsize=" << FontSize.getValue()
paramStr << ", scale=" << getScale()
<< ", linewidth=" << LineWidth.getValue()
<< ", fontsize=" << FontSize.getValue()
// TODO treat fillstyle here
<< ",direction=FreeCAD.Vector(" << Direction.getValue().x << "," << Direction.getValue().y << "," << Direction.getValue().z << ")"
<< ",linestyle=\"" << LineStyle.getValue() << "\""
<< ",color=\"" << col.asHexString() << "\""
<< ",linespacing=" << LineSpacing.getValue()
<< ", direction=FreeCAD.Vector(" << Direction.getValue().x << ", " << Direction.getValue().y << ", " << Direction.getValue().z << ")"
<< ", linestyle=\"" << LineStyle.getValue() << "\""
<< ", color=\"" << col.asHexString() << "\""
<< ", linespacing=" << LineSpacing.getValue()
// We must set techdraw to "true" becausea couple of things behave differently than in Drawing
<< ",techdraw=True"
<< ",override=" << (OverrideStyle.getValue() ? "True" : "False");
<< ", techdraw=True"
<< ", override=" << (OverrideStyle.getValue() ? "True" : "False");
// this is ok for a starting point, but should eventually make dedicated Draft functions that build the svg for all the special cases
// (Arch section, etc)
// like Draft.makeDrawingView, but we don't need to create the actual document objects in Draft, just the svg.
Base::Interpreter().runString("import Draft");
Base::Interpreter().runStringArg("svgBody = Draft.get_svg(App.activeDocument().%s %s)",
SourceName.c_str(),paramStr.str().c_str());
SourceName.c_str(), paramStr.str().c_str());
// Base::Interpreter().runString("print svgBody");
Base::Interpreter().runStringArg("App.activeDocument().%s.Symbol = '%s' + svgBody + '%s'",
FeatName.c_str(),svgHead.c_str(),svgTail.c_str());
FeatName.c_str(), svgHead.c_str(), svgTail.c_str());
}
overrideKeepUpdated(false);
overrideKeepUpdated(false);
return DrawView::execute();
}

View File

@@ -20,8 +20,8 @@
* *
***************************************************************************/
#ifndef _DrawViewDraft_h_
#define _DrawViewDraft_h_
#ifndef DrawViewDraft_h_
#define DrawViewDraft_h_
#include <Mod/TechDraw/TechDrawGlobal.h>
@@ -43,7 +43,7 @@ class TechDrawExport DrawViewDraft : public TechDraw::DrawViewSymbol
public:
/// Constructor
DrawViewDraft();
~DrawViewDraft() override;
~DrawViewDraft() = default;
App::PropertyLink Source;
App::PropertyFloat LineWidth;

View File

@@ -54,21 +54,17 @@ DrawViewImage::DrawViewImage()
{
static const char *vgroup = "Image";
ADD_PROPERTY_TYPE(ImageFile,(""),vgroup,App::Prop_None,"The file containing this bitmap");
ADD_PROPERTY_TYPE(ImageIncluded, (""), vgroup,App::Prop_None,
ADD_PROPERTY_TYPE(ImageFile, (""), vgroup, App::Prop_None, "The file containing this bitmap");
ADD_PROPERTY_TYPE(ImageIncluded, (""), vgroup, App::Prop_None,
"Embedded image file. System use only."); // n/a to end users
ADD_PROPERTY_TYPE(Width ,(100),vgroup,App::Prop_None,"The width of cropped image");
ADD_PROPERTY_TYPE(Height ,(100),vgroup,App::Prop_None,"The height of cropped image");
ADD_PROPERTY_TYPE(Width ,(100), vgroup, App::Prop_None, "The width of cropped image");
ADD_PROPERTY_TYPE(Height ,(100), vgroup, App::Prop_None, "The height of cropped image");
ScaleType.setValue("Custom");
std::string imgFilter("Image files (*.jpg *.jpeg *.png);;All files (*)");
ImageFile.setFilter(imgFilter);
}
DrawViewImage::~DrawViewImage()
{
}
void DrawViewImage::onChanged(const App::Property* prop)
{
App::Document* doc = getDocument();
@@ -106,7 +102,7 @@ App::DocumentObjectExecReturn *DrawViewImage::execute()
QRectF DrawViewImage::getRect() const
{
return QRectF(0.0,0.0,Width.getValue(), Height.getValue());
return { 0.0, 0.0, Width.getValue(), Height.getValue()};
}
void DrawViewImage::replaceImageIncluded(std::string newFileName)

View File

@@ -20,8 +20,8 @@
* *
***************************************************************************/
#ifndef _DrawViewImage_h_
#define _DrawViewImage_h_
#ifndef DrawViewImage_h_
#define DrawViewImage_h_
#include <Mod/TechDraw/TechDrawGlobal.h>
@@ -43,7 +43,7 @@ class TechDrawExport DrawViewImage : public TechDraw::DrawView
public:
/// Constructor
DrawViewImage();
~DrawViewImage() override;
~DrawViewImage() = default;
App::PropertyFile ImageFile;
App::PropertyFileIncluded ImageIncluded;

View File

@@ -79,11 +79,11 @@ DrawViewMulti::DrawViewMulti()
static const char *group = "Projection";
//properties that affect Geometry
ADD_PROPERTY_TYPE(Sources ,(nullptr),group,App::Prop_None,"3D Shapes to view");
ADD_PROPERTY_TYPE(Sources ,(nullptr), group, App::Prop_None, "3D Shapes to view");
Sources.setScope(App::LinkScope::Global);
//Source is replaced by Sources in Multi
Source.setStatus(App::Property::ReadOnly,true);
Source.setStatus(App::Property::Hidden,true);
Source.setStatus(App::Property::ReadOnly, true);
Source.setStatus(App::Property::Hidden, true);
geometryObject = nullptr;
}
@@ -104,7 +104,7 @@ short DrawViewMulti::mustExecute() const
void DrawViewMulti::onChanged(const App::Property* prop)
{
if (!isRestoring()) {
//Base::Console().Message("TRACE - DVM::onChanged(%s) - %s\n",prop->getName(),Label.getValue());
//Base::Console().Message("TRACE - DVM::onChanged(%s) - %s\n", prop->getName(), Label.getValue());
if (prop == &Sources) {
const std::vector<App::DocumentObject*>& links = Sources.getValues();
if (!links.empty()) {
@@ -138,24 +138,24 @@ App::DocumentObjectExecReturn *DrawViewMulti::execute()
try {
inputCenter = TechDraw::findCentroid(comp,
Direction.getValue());
shapeCentroid = Base::Vector3d(inputCenter.X(),inputCenter.Y(),inputCenter.Z());
shapeCentroid = Base::Vector3d(inputCenter.X(), inputCenter.Y(), inputCenter.Z());
TopoDS_Shape mirroredShape = TechDraw::mirrorShape(comp,
inputCenter,
getScale());
gp_Ax2 viewAxis = getViewAxis(Base::Vector3d(inputCenter.X(),inputCenter.Y(),inputCenter.Z()),Direction.getValue());
if (!DrawUtil::fpCompare(Rotation.getValue(),0.0)) {
gp_Ax2 viewAxis = getViewAxis(Base::Vector3d(inputCenter.X(), inputCenter.Y(), inputCenter.Z()), Direction.getValue());
if (!DrawUtil::fpCompare(Rotation.getValue(), 0.0)) {
mirroredShape = TechDraw::rotateShape(mirroredShape,
viewAxis,
Rotation.getValue());
}
geometryObject = buildGeometryObject(mirroredShape,viewAxis);
geometryObject = buildGeometryObject(mirroredShape, viewAxis);
#if MOD_TECHDRAW_HANDLE_FACES
extractFaces();
#endif //#if MOD_TECHDRAW_HANDLE_FACES
}
catch (Standard_Failure& e1) {
Base::Console().Log("LOG - DVM::execute - projection failed for %s - %s **\n",getNameInDocument(),e1.GetMessageString());
Base::Console().Log("LOG - DVM::execute - projection failed for %s - %s **\n", getNameInDocument(), e1.GetMessageString());
return new App::DocumentObjectExecReturn(e1.GetMessageString());
}

View File

@@ -22,8 +22,8 @@
* *
***************************************************************************/
#ifndef _DrawViewMulti_h_
#define _DrawViewMulti_h_
#ifndef DrawViewMulti_h_
#define DrawViewMulti_h_
#include <Mod/TechDraw/TechDrawGlobal.h>
@@ -58,7 +58,7 @@ public:
/// Constructor
DrawViewMulti();
~DrawViewMulti() override;
App::PropertyLinkList Sources;
short mustExecute() const override;

View File

@@ -99,7 +99,7 @@ using namespace std;
//PROPERTY_SOURCE(TechDraw::DrawViewPart, TechDraw::DrawView)
PROPERTY_SOURCE_WITH_EXTENSIONS(TechDraw::DrawViewPart,
PROPERTY_SOURCE_WITH_EXTENSIONS(TechDraw::DrawViewPart,
TechDraw::DrawView)
DrawViewPart::DrawViewPart(void) :
@@ -118,34 +118,34 @@ DrawViewPart::DrawViewPart(void) :
Base::Reference<ParameterGrp> hGrp = App::GetApplication().
GetUserParameter().GetGroup("BaseApp")->
GetGroup("Preferences")->GetGroup("Mod/TechDraw/General");
double defDist = hGrp->GetFloat("FocusDistance",100.0);
double defDist = hGrp->GetFloat("FocusDistance", 100.0);
//properties that affect Geometry
ADD_PROPERTY_TYPE(Source ,(nullptr),group,App::Prop_None,"3D Shape to view");
ADD_PROPERTY_TYPE(Source ,(nullptr), group, App::Prop_None, "3D Shape to view");
Source.setScope(App::LinkScope::Global);
Source.setAllowExternal(true);
ADD_PROPERTY_TYPE(XSource ,(nullptr),group,App::Prop_None,"External 3D Shape to view");
ADD_PROPERTY_TYPE(XSource ,(nullptr), group, App::Prop_None, "External 3D Shape to view");
ADD_PROPERTY_TYPE(Direction ,(0.0,-1.0,0.0),
group,App::Prop_None,"Projection Plane normal. The direction you are looking from.");
ADD_PROPERTY_TYPE(XDirection ,(0.0,0.0,0.0),
group,App::Prop_None,"Projection Plane X Axis in R3. Rotates/Mirrors View");
ADD_PROPERTY_TYPE(Perspective ,(false),group,App::Prop_None,
ADD_PROPERTY_TYPE(Direction ,(0.0, -1.0, 0.0),
group, App::Prop_None, "Projection Plane normal. The direction you are looking from.");
ADD_PROPERTY_TYPE(XDirection ,(0.0, 0.0, 0.0),
group, App::Prop_None, "Projection Plane X Axis in R3. Rotates/Mirrors View");
ADD_PROPERTY_TYPE(Perspective ,(false), group, App::Prop_None,
"Perspective(true) or Orthographic(false) projection");
ADD_PROPERTY_TYPE(Focus,(defDist),group,App::Prop_None,"Perspective view focus distance");
ADD_PROPERTY_TYPE(Focus, (defDist), group, App::Prop_None, "Perspective view focus distance");
//properties that control HLR algo
bool coarseView = hGrp->GetBool("CoarseView", false);
ADD_PROPERTY_TYPE(CoarseView, (coarseView), sgroup, App::Prop_None, "Coarse View on/off");
ADD_PROPERTY_TYPE(SmoothVisible ,(prefSmoothViz()),sgroup,App::Prop_None,"Show Visible Smooth lines");
ADD_PROPERTY_TYPE(SeamVisible ,(prefSeamViz()),sgroup,App::Prop_None,"Show Visible Seam lines");
ADD_PROPERTY_TYPE(IsoVisible ,(prefIsoViz()),sgroup,App::Prop_None,"Show Visible Iso u,v lines");
ADD_PROPERTY_TYPE(HardHidden ,(prefHardHid()),sgroup,App::Prop_None,"Show Hidden Hard lines");
ADD_PROPERTY_TYPE(SmoothHidden ,(prefSmoothHid()),sgroup,App::Prop_None,"Show Hidden Smooth lines");
ADD_PROPERTY_TYPE(SeamHidden ,(prefSeamHid()),sgroup,App::Prop_None,"Show Hidden Seam lines");
ADD_PROPERTY_TYPE(IsoHidden ,(prefIsoHid()),sgroup,App::Prop_None,"Show Hidden Iso u,v lines");
ADD_PROPERTY_TYPE(IsoCount ,(prefIsoCount()),sgroup,App::Prop_None,"Number of iso parameters lines");
ADD_PROPERTY_TYPE(SmoothVisible ,(prefSmoothViz()), sgroup, App::Prop_None, "Show Visible Smooth lines");
ADD_PROPERTY_TYPE(SeamVisible ,(prefSeamViz()), sgroup, App::Prop_None, "Show Visible Seam lines");
ADD_PROPERTY_TYPE(IsoVisible ,(prefIsoViz()), sgroup, App::Prop_None, "Show Visible Iso u, v lines");
ADD_PROPERTY_TYPE(HardHidden ,(prefHardHid()), sgroup, App::Prop_None, "Show Hidden Hard lines");
ADD_PROPERTY_TYPE(SmoothHidden ,(prefSmoothHid()), sgroup, App::Prop_None, "Show Hidden Smooth lines");
ADD_PROPERTY_TYPE(SeamHidden ,(prefSeamHid()), sgroup, App::Prop_None, "Show Hidden Seam lines");
ADD_PROPERTY_TYPE(IsoHidden ,(prefIsoHid()), sgroup, App::Prop_None, "Show Hidden Iso u, v lines");
ADD_PROPERTY_TYPE(IsoCount ,(prefIsoCount()), sgroup, App::Prop_None, "Number of iso parameters lines");
//initialize bbox to non-garbage
bbox = Base::BoundBox3d(Base::Vector3d(0.0, 0.0, 0.0), 0.0);
@@ -243,7 +243,6 @@ void DrawViewPart::addShapes2d(void)
App::DocumentObjectExecReturn *DrawViewPart::execute(void)
{
// Base::Console().Message("DVP::execute() - %s\n", getNameInDocument());
if (!keepUpdated()) {
return DrawView::execute();
}
@@ -251,7 +250,7 @@ App::DocumentObjectExecReturn *DrawViewPart::execute(void)
if (waitingForHlr()) {
return DrawView::execute();
}
TopoDS_Shape shape = getSourceShape();
if (shape.IsNull()) {
Base::Console().Log("DVP::execute - %s - Source shape is Null.\n",
@@ -335,7 +334,7 @@ GeometryObject* DrawViewPart::makeGeometryForShape(TopoDS_Shape& shape)
{
// Base::Console().Message("DVP::makeGeometryForShape() - %s\n", getNameInDocument());
gp_Pnt inputCenter;
Base::Vector3d stdOrg(0.0,0.0,0.0);
Base::Vector3d stdOrg(0.0, 0.0, 0.0);
gp_Ax2 viewAxis = getProjectionCS(stdOrg);
inputCenter = TechDraw::findCentroid(shape,
viewAxis);
@@ -351,13 +350,13 @@ GeometryObject* DrawViewPart::makeGeometryForShape(TopoDS_Shape& shape)
TopoDS_Shape scaledShape = TechDraw::scaleShape(centeredShape,
getScale());
if (!DrawUtil::fpCompare(Rotation.getValue(),0.0)) {
if (!DrawUtil::fpCompare(Rotation.getValue(), 0.0)) {
scaledShape = TechDraw::rotateShape(scaledShape,
viewAxis,
Rotation.getValue()); //conventional rotation
}
// BRepTools::Write(scaledShape, "DVPScaled.brep"); //debug
GeometryObject* go = buildGeometryObject(scaledShape,viewAxis);
GeometryObject* go = buildGeometryObject(scaledShape, viewAxis);
return go;
}
@@ -429,7 +428,7 @@ void DrawViewPart::onHlrFinished(void)
}
catch (Standard_Failure& e) {
waitingForFaces(false);
Base::Console().Error("DVP::partExec - %s - extractFaces failed - %s **\n",getNameInDocument(), e.GetMessageString());
Base::Console().Error("DVP::partExec - %s - extractFaces failed - %s **\n", getNameInDocument(), e.GetMessageString());
throw Base::RuntimeError("DVP::onHlrFinished - error extracting faces");
}
}
@@ -485,7 +484,7 @@ void DrawViewPart::extractFaces()
//make a copy of the input edges so the loose tolerances of face finding are
//not applied to the real edge geometry. See TopoDS_Shape::TShape().
const std::vector<TechDraw::BaseGeomPtr>& goEdges =
geometryObject->getVisibleFaceEdges(SmoothVisible.getValue(),SeamVisible.getValue());
geometryObject->getVisibleFaceEdges(SmoothVisible.getValue(), SeamVisible.getValue());
if (goEdges.empty()) {
Base::Console().Message("DVP::extractFaces - %s - no face edges available!\n", getNameInDocument());
@@ -525,7 +524,7 @@ void DrawViewPart::extractFaces()
}
int iInner = 0;
std::vector<TopoDS_Edge>::iterator itInner = nonZero.begin(); //***sb itOuter + 1;
for (; itInner != nonZero.end(); ++itInner,iInner++) {
for (; itInner != nonZero.end(); ++itInner, iInner++) {
if (iInner == iOuter) {
continue;
}
@@ -544,19 +543,19 @@ void DrawViewPart::extractFaces()
}
double param = -1; //parametric point on edge where the vertex touches
if (DrawProjectSplit::isOnEdge((*itInner),v1,param,false)) {
if (DrawProjectSplit::isOnEdge((*itInner), v1, param, false)) {
gp_Pnt pnt1 = BRep_Tool::Pnt(v1);
splitPoint s1;
s1.i = iInner;
s1.v = Base::Vector3d(pnt1.X(),pnt1.Y(),pnt1.Z());
s1.v = Base::Vector3d(pnt1.X(), pnt1.Y(), pnt1.Z());
s1.param = param;
splits.push_back(s1);
}
if (DrawProjectSplit::isOnEdge((*itInner),v2,param,false)) {
if (DrawProjectSplit::isOnEdge((*itInner), v2, param, false)) {
gp_Pnt pnt2 = BRep_Tool::Pnt(v2);
splitPoint s2;
s2.i = iInner;
s2.v = Base::Vector3d(pnt2.X(),pnt2.Y(),pnt2.Z());
s2.v = Base::Vector3d(pnt2.X(), pnt2.Y(), pnt2.Z());
s2.param = param;
splits.push_back(s2);
}
@@ -564,11 +563,11 @@ void DrawViewPart::extractFaces()
} //outer loop
//if edge A was touched at the same point by multiple edges B, we only want to split A once
std::vector<splitPoint> sorted = DrawProjectSplit::sortSplits(splits,true);
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 duplicate splits
std::vector<TopoDS_Edge> newEdges = DrawProjectSplit::splitEdges(nonZero,sorted);
std::vector<TopoDS_Edge> newEdges = DrawProjectSplit::splitEdges(nonZero, sorted);
if (newEdges.empty()) {
Base::Console().Log("DVP::extractFaces - no edges return by splitting process\n");
@@ -590,7 +589,7 @@ void DrawViewPart::extractFaces()
}
std::vector<TopoDS_Wire> fw = ew.getResultNoDups();
std::vector<TopoDS_Wire> sortedWires = ew.sortStrip(fw,true);
std::vector<TopoDS_Wire> sortedWires = ew.sortStrip(fw, true);
std::vector<TopoDS_Wire>::iterator itWire = sortedWires.begin();
for (; itWire != sortedWires.end(); itWire++) {
@@ -657,8 +656,8 @@ std::vector<TechDraw::DrawViewDimension*> DrawViewPart::getDimensions() const
{
std::vector<TechDraw::DrawViewDimension*> result;
std::vector<App::DocumentObject*> children = getInList();
std::sort(children.begin(),children.end(),std::less<App::DocumentObject*>());
std::vector<App::DocumentObject*>::iterator newEnd = std::unique(children.begin(),children.end());
std::sort(children.begin(), children.end(), std::less<App::DocumentObject*>());
std::vector<App::DocumentObject*>::iterator newEnd = std::unique(children.begin(), children.end());
for (std::vector<App::DocumentObject*>::iterator it = children.begin(); it != newEnd; ++it) {
if ((*it)->getTypeId().isDerivedFrom(DrawViewDimension::getClassTypeId())) {
TechDraw::DrawViewDimension* dim = dynamic_cast<TechDraw::DrawViewDimension*>(*it);
@@ -672,8 +671,8 @@ std::vector<TechDraw::DrawViewBalloon*> DrawViewPart::getBalloons() const
{
std::vector<TechDraw::DrawViewBalloon*> result;
std::vector<App::DocumentObject*> children = getInList();
std::sort(children.begin(),children.end(),std::less<App::DocumentObject*>());
std::vector<App::DocumentObject*>::iterator newEnd = std::unique(children.begin(),children.end());
std::sort(children.begin(), children.end(), std::less<App::DocumentObject*>());
std::vector<App::DocumentObject*>::iterator newEnd = std::unique(children.begin(), children.end());
for (std::vector<App::DocumentObject*>::iterator it = children.begin(); it != newEnd; ++it) {
if ((*it)->getTypeId().isDerivedFrom(DrawViewBalloon::getClassTypeId())) {
TechDraw::DrawViewBalloon* balloon = dynamic_cast<TechDraw::DrawViewBalloon*>(*it);
@@ -715,7 +714,7 @@ TechDraw::BaseGeomPtr DrawViewPart::getGeomByIndex(int idx) const
{
const std::vector<TechDraw::BaseGeomPtr> &geoms = getEdgeGeometry();
if (geoms.empty()) {
Base::Console().Log("DVP::getGeomByIndex(%d) - no Edge Geometry. Probably restoring?\n",idx);
Base::Console().Log("DVP::getGeomByIndex(%d) - no Edge Geometry. Probably restoring?\n", idx);
return nullptr;
}
if ((unsigned)idx >= geoms.size()) {
@@ -730,11 +729,11 @@ TechDraw::VertexPtr DrawViewPart::getProjVertexByIndex(int idx) const
{
const std::vector<TechDraw::VertexPtr> &geoms = getVertexGeometry();
if (geoms.empty()) {
Base::Console().Log("DVP::getProjVertexByIndex(%d) - no Vertex Geometry. Probably restoring?\n",idx);
Base::Console().Log("DVP::getProjVertexByIndex(%d) - no Vertex Geometry. Probably restoring?\n", idx);
return nullptr;
}
if ((unsigned)idx >= geoms.size()) {
Base::Console().Error("DVP::getProjVertexByIndex(%d) - invalid index\n",idx);
Base::Console().Error("DVP::getProjVertexByIndex(%d) - invalid index\n", idx);
return nullptr;
}
return geoms.at(idx);
@@ -748,7 +747,7 @@ TechDraw::VertexPtr DrawViewPart::getProjVertexByCosTag(std::string cosTag)
Base::Console().Log("INFO - getProjVertexByCosTag(%s) - no Vertex Geometry.\n");
return result;
}
for (auto& gv: gVerts) {
if (gv->cosmeticTag == cosTag) {
result = gv;
@@ -830,14 +829,14 @@ QRectF DrawViewPart::getRect() const
Base::Vector3d DrawViewPart::projectPoint(const Base::Vector3d& pt, bool invert) const
{
// Base::Console().Message("DVP::projectPoint()\n");
Base::Vector3d stdOrg(0.0,0.0,0.0);
Base::Vector3d stdOrg(0.0, 0.0, 0.0);
gp_Ax2 viewAxis = getProjectionCS(stdOrg);
gp_Pnt gPt(pt.x,pt.y,pt.z);
gp_Pnt gPt(pt.x, pt.y, pt.z);
HLRAlgo_Projector projector( viewAxis );
gp_Pnt2d prjPnt;
projector.Project(gPt, prjPnt);
Base::Vector3d result(prjPnt.X(),prjPnt.Y(), 0.0);
Base::Vector3d result(prjPnt.X(), prjPnt.Y(), 0.0);
if (invert) {
result = DrawUtil::invertY(result);
}
@@ -848,7 +847,7 @@ Base::Vector3d DrawViewPart::projectPoint(const Base::Vector3d& pt, bool invert)
//TODO:: loose edges not supported yet
BaseGeomPtr DrawViewPart::projectEdge(const TopoDS_Edge& e) const
{
Base::Vector3d stdOrg(0.0,0.0,0.0);
Base::Vector3d stdOrg(0.0, 0.0, 0.0);
gp_Ax2 viewAxis = getProjectionCS(stdOrg);
gp_Pln plane(viewAxis);
@@ -971,7 +970,7 @@ std::vector<DrawViewDetail*> DrawViewPart::getDetailRefs() const
const BaseGeomPtrVector DrawViewPart::getVisibleFaceEdges() const
{
return geometryObject->getVisibleFaceEdges(SmoothVisible.getValue(),SeamVisible.getValue());
return geometryObject->getVisibleFaceEdges(SmoothVisible.getValue(), SeamVisible.getValue());
}
bool DrawViewPart::handleFaces()
@@ -982,7 +981,7 @@ bool DrawViewPart::handleFaces()
}
//! remove features that are useless without this DVP
//! hatches, geomhatches, dimensions,...
//! hatches, geomhatches, dimensions, ...
void DrawViewPart::unsetupObject()
{
nowUnsetting = true;
@@ -1045,8 +1044,8 @@ bool DrawViewPart::isIso() const
{
bool result = false;
Base::Vector3d dir = Direction.getValue();
if ( DrawUtil::fpCompare(fabs(dir.x),fabs(dir.y)) &&
DrawUtil::fpCompare(fabs(dir.x),fabs(dir.z)) ) {
if ( DrawUtil::fpCompare(fabs(dir.x), fabs(dir.y)) &&
DrawUtil::fpCompare(fabs(dir.x), fabs(dir.z)) ) {
result = true;
}
return result;
@@ -1058,7 +1057,7 @@ bool DrawViewPart::checkXDirection() const
Base::Vector3d xDir = XDirection.getValue();
if (DrawUtil::fpCompare(xDir.Length(), 0.0)) {
Base::Vector3d dir = Direction.getValue();
Base::Vector3d origin(0.0,0.0,0.0);
Base::Vector3d origin(0.0, 0.0, 0.0);
Base::Vector3d xDir = getLegacyX(origin,
dir);
Base::Console().Log("DVP - %s - XDirection property not set. Trying %s\n",
@@ -1130,7 +1129,7 @@ void DrawViewPart::addReferencesToGeom()
//ex. LandmarkDimension as a reference
std::string DrawViewPart::addReferenceVertex(Base::Vector3d v)
{
// Base::Console().Message("DVP::addReferenceVertex(%s) - %s\n",
// Base::Console().Message("DVP::addReferenceVertex(%s) - %s\n",
// DrawUtil::formatVector(v).c_str(), getNameInDocument());
std::string refTag;
// Base::Vector3d scaledV = v * getScale();
@@ -1154,7 +1153,7 @@ void DrawViewPart::removeReferenceVertex(std::string tag)
}
}
m_referenceVerts = newRefVerts;
resetReferenceVerts();
resetReferenceVerts();
}
void DrawViewPart::removeAllReferencesFromGeom()
@@ -1215,7 +1214,7 @@ int DrawViewPart::add1CVToGV(std::string tag)
return iGV;
}
//update Vertex geometry with current CV's
//update Vertex geometry with current CV's
void DrawViewPart::refreshCVGeoms()
{
// Base::Console().Message("DVP::refreshCVGeoms()\n");
@@ -1253,7 +1252,7 @@ int DrawViewPart::getCVIndex(std::string tag)
int base = gVerts.size();
int i = 0;
for (auto& cv: cVerts) {
// Base::Console().Message("DVP::getCVIndex - cv tag: %s\n",
// Base::Console().Message("DVP::getCVIndex - cv tag: %s\n",
// cv->getTagAsString().c_str());
if (cv->getTagAsString() == tag) {
result = base + i;
@@ -1285,7 +1284,7 @@ void DrawViewPart::addCosmeticEdgesToGeom()
TechDraw::BaseGeomPtr scaledGeom = ce->scaledGeometry(getScale());
if (!scaledGeom)
continue;
// int iGE =
// int iGE =
geometryObject->addCosmeticEdge(scaledGeom,
ce->getTagAsString());
}
@@ -1302,11 +1301,11 @@ int DrawViewPart::add1CEToGE(std::string tag)
TechDraw::BaseGeomPtr scaledGeom = ce->scaledGeometry(getScale());
int iGE = geometryObject->addCosmeticEdge(scaledGeom,
tag);
return iGE;
}
//update Edge geometry with current CE's
//update Edge geometry with current CE's
void DrawViewPart::refreshCEGeoms()
{
// Base::Console().Message("DVP::refreshCEGeoms()\n");
@@ -1340,11 +1339,11 @@ int DrawViewPart::add1CLToGE(std::string tag)
TechDraw::BaseGeomPtr scaledGeom = cl->scaledGeometry(this);
int iGE = geometryObject->addCenterLine(scaledGeom,
tag);
return iGE;
}
//update Edge geometry with current CL's
//update Edge geometry with current CL's
void DrawViewPart::refreshCLGeoms()
{
// Base::Console().Message("DVP::refreshCLGeoms()\n");
@@ -1423,21 +1422,11 @@ void DrawViewPart::dumpCosEdges(std::string text)
}
}
void DrawViewPart::onDocumentRestored()
{
// requestPaint();
//if execute has not run yet, there will be no GO, and paint will not do anything.
recomputeFeature();
DrawView::onDocumentRestored();
}
PyObject *DrawViewPart::getPyObject()
{
if (PythonObject.is(Py::_None())) {
// ref counter is set to 1
PythonObject = Py::Object(new DrawViewPartPy(this),true);
PythonObject = Py::Object(new DrawViewPartPy(this), true);
}
return Py::new_reference_to(PythonObject);
}
@@ -1452,7 +1441,7 @@ bool DrawViewPart::prefHardViz()
{
Base::Reference<ParameterGrp> hGrp = App::GetApplication().GetUserParameter()
.GetGroup("BaseApp")->GetGroup("Preferences")->GetGroup("Mod/TechDraw/HLR");
bool result = hGrp->GetBool("HardViz", true);
bool result = hGrp->GetBool("HardViz", true);
return result;
}
@@ -1460,7 +1449,7 @@ bool DrawViewPart::prefSeamViz()
{
Base::Reference<ParameterGrp> hGrp = App::GetApplication().GetUserParameter()
.GetGroup("BaseApp")->GetGroup("Preferences")->GetGroup("Mod/TechDraw/HLR");
bool result = hGrp->GetBool("SeamViz", true);
bool result = hGrp->GetBool("SeamViz", true);
return result;
}
@@ -1468,7 +1457,7 @@ bool DrawViewPart::prefSmoothViz()
{
Base::Reference<ParameterGrp> hGrp = App::GetApplication().GetUserParameter()
.GetGroup("BaseApp")->GetGroup("Preferences")->GetGroup("Mod/TechDraw/HLR");
bool result = hGrp->GetBool("SmoothViz", true);
bool result = hGrp->GetBool("SmoothViz", true);
return result;
}
@@ -1476,7 +1465,7 @@ bool DrawViewPart::prefIsoViz()
{
Base::Reference<ParameterGrp> hGrp = App::GetApplication().GetUserParameter()
.GetGroup("BaseApp")->GetGroup("Preferences")->GetGroup("Mod/TechDraw/HLR");
bool result = hGrp->GetBool("IsoViz", false);
bool result = hGrp->GetBool("IsoViz", false);
return result;
}
@@ -1484,7 +1473,7 @@ bool DrawViewPart::prefHardHid()
{
Base::Reference<ParameterGrp> hGrp = App::GetApplication().GetUserParameter()
.GetGroup("BaseApp")->GetGroup("Preferences")->GetGroup("Mod/TechDraw/HLR");
bool result = hGrp->GetBool("HardHid", false);
bool result = hGrp->GetBool("HardHid", false);
return result;
}
@@ -1492,7 +1481,7 @@ bool DrawViewPart::prefSeamHid()
{
Base::Reference<ParameterGrp> hGrp = App::GetApplication().GetUserParameter()
.GetGroup("BaseApp")->GetGroup("Preferences")->GetGroup("Mod/TechDraw/HLR");
bool result = hGrp->GetBool("SeamHid", false);
bool result = hGrp->GetBool("SeamHid", false);
return result;
}
@@ -1500,7 +1489,7 @@ bool DrawViewPart::prefSmoothHid()
{
Base::Reference<ParameterGrp> hGrp = App::GetApplication().GetUserParameter()
.GetGroup("BaseApp")->GetGroup("Preferences")->GetGroup("Mod/TechDraw/HLR");
bool result = hGrp->GetBool("SmoothHid", false);
bool result = hGrp->GetBool("SmoothHid", false);
return result;
}
@@ -1508,7 +1497,7 @@ bool DrawViewPart::prefIsoHid()
{
Base::Reference<ParameterGrp> hGrp = App::GetApplication().GetUserParameter()
.GetGroup("BaseApp")->GetGroup("Preferences")->GetGroup("Mod/TechDraw/HLR");
bool result = hGrp->GetBool("IsoHid", false);
bool result = hGrp->GetBool("IsoHid", false);
return result;
}
@@ -1516,7 +1505,7 @@ int DrawViewPart::prefIsoCount()
{
Base::Reference<ParameterGrp> hGrp = App::GetApplication().GetUserParameter()
.GetGroup("BaseApp")->GetGroup("Preferences")->GetGroup("Mod/TechDraw/HLR");
int result = hGrp->GetBool("IsoCount", 0);
int result = hGrp->GetBool("IsoCount", 0);
return result;
}

View File

@@ -22,8 +22,8 @@
* *
***************************************************************************/
#ifndef _DrawViewPart_h_
#define _DrawViewPart_h_
#ifndef DrawViewPart_h_
#define DrawViewPart_h_
#include <Mod/TechDraw/TechDrawGlobal.h>
@@ -110,7 +110,6 @@ public:
App::PropertyInteger IsoCount;
short mustExecute() const override;
void onDocumentRestored() override;
App::DocumentObjectExecReturn *execute() override;
const char* getViewProviderName() const override {
return "TechDrawGui::ViewProviderViewPart";
@@ -162,7 +161,7 @@ public:
bool handleFaces();
bool isUnsetting() { return nowUnsetting; }
virtual std::vector<TopoDS_Wire> getWireForFace(int idx) const;
virtual TopoDS_Shape getSourceShape() const;
@@ -273,4 +272,4 @@ using DrawViewPartPython = App::FeaturePythonT<DrawViewPart>;
} //namespace TechDraw
#endif // #ifndef _DrawViewPart_h_
#endif // #ifndef DrawViewPart_h_

View File

@@ -291,7 +291,7 @@ PyObject* DrawViewPartPy::makeCosmeticLine(PyObject *args)
&(Base::VectorPy::Type), &pPnt2,
&style, &weight,
&pColor)) {
throw Py::TypeError("expected (vector, vector,[style,weight,color])");
throw Py::TypeError("expected (vector, vector, [style, weight, color])");
}
DrawViewPart* dvp = getDrawViewPartPtr();
@@ -308,7 +308,7 @@ PyObject* DrawViewPartPy::makeCosmeticLine(PyObject *args)
ce->m_format.m_color = DrawUtil::pyTupleToColor(pColor);
} else {
std::string msg = "DVPPI:makeCosmeticLine - line creation failed";
Base::Console().Message("%s\n",msg.c_str());
Base::Console().Message("%s\n", msg.c_str());
throw Py::RuntimeError(msg);
}
//int link =
@@ -330,7 +330,7 @@ PyObject* DrawViewPartPy::makeCosmeticLine3D(PyObject *args)
&(Base::VectorPy::Type), &pPnt2,
&style, &weight,
&pColor)) {
throw Py::TypeError("expected (vector, vector,[style,weight,color])");
throw Py::TypeError("expected (vector, vector, [style, weight, color])");
}
DrawViewPart* dvp = getDrawViewPartPtr();
@@ -355,7 +355,7 @@ PyObject* DrawViewPartPy::makeCosmeticLine3D(PyObject *args)
ce->m_format.m_color = DrawUtil::pyTupleToColor(pColor);
} else {
std::string msg = "DVPPI:makeCosmeticLine - line creation failed";
Base::Console().Message("%s\n",msg.c_str());
Base::Console().Message("%s\n", msg.c_str());
throw Py::RuntimeError(msg);
}
//int link =
@@ -376,7 +376,7 @@ PyObject* DrawViewPartPy::makeCosmeticCircle(PyObject *args)
&radius,
&style, &weight,
&pColor)) {
throw Py::TypeError("expected (vector, vector,[style,weight,color])");
throw Py::TypeError("expected (vector, vector, [style, weight, color])");
}
DrawViewPart* dvp = getDrawViewPartPtr();
@@ -394,7 +394,7 @@ PyObject* DrawViewPartPy::makeCosmeticCircle(PyObject *args)
ce->m_format.m_color = DrawUtil::pyTupleToColor(pColor);
} else {
std::string msg = "DVPPI:makeCosmeticCircle - circle creation failed";
Base::Console().Message("%s\n",msg.c_str());
Base::Console().Message("%s\n", msg.c_str());
throw Py::RuntimeError(msg);
}
//int link =
@@ -417,7 +417,7 @@ PyObject* DrawViewPartPy::makeCosmeticCircleArc(PyObject *args)
if (!PyArg_ParseTuple(args, "O!ddd|idO", &(Base::VectorPy::Type), &pPnt1,
&radius, &angle1, &angle2,
&style, &weight, &pColor)) {
throw Py::TypeError("expected (vector, radius, start, end,[style, weight, color])");
throw Py::TypeError("expected (vector, radius, start, end, [style, weight, color])");
}
//from here on is almost duplicate of makeCosmeticCircle
@@ -436,7 +436,7 @@ PyObject* DrawViewPartPy::makeCosmeticCircleArc(PyObject *args)
ce->m_format.m_color = DrawUtil::pyTupleToColor(pColor);
} else {
std::string msg = "DVPPI:makeCosmeticCircleArc - arc creation failed";
Base::Console().Message("%s\n",msg.c_str());
Base::Console().Message("%s\n", msg.c_str());
throw Py::RuntimeError(msg);
}
@@ -507,7 +507,7 @@ PyObject* DrawViewPartPy::makeCenterLine(PyObject *args)
int mode = 0;
std::vector<std::string> subs;
if (!PyArg_ParseTuple(args, "Oi",&pSubs, &mode)) {
if (!PyArg_ParseTuple(args, "Oi", &pSubs, &mode)) {
throw Py::TypeError("expected (subNameList, mode)");
}
@@ -528,12 +528,12 @@ PyObject* DrawViewPartPy::makeCenterLine(PyObject *args)
if (!subs.empty()) {
cl = CenterLine::CenterLineBuilder(dvp,
subs,
mode); //vert,horiz,align
mode); //vert, horiz, align
if (cl) {
tag = dvp->addCenterLine(cl);
} else {
std::string msg = "DVPPI:makeCenterLine - line creation failed";
Base::Console().Message("%s\n",msg.c_str());
Base::Console().Message("%s\n", msg.c_str());
throw Py::RuntimeError(msg);
}
}
@@ -606,7 +606,7 @@ PyObject* DrawViewPartPy::formatGeometricEdge(PyObject *args)
int visible = 1;
PyObject* pColor;
if (!PyArg_ParseTuple(args, "iidOi",&idx, &style, &weight, &pColor, &visible)) {
if (!PyArg_ParseTuple(args, "iidOi", &idx, &style, &weight, &pColor, &visible)) {
throw Py::TypeError("expected (index, style, weight, color, visible)");
}

View File

@@ -108,29 +108,29 @@ DrawViewSection::DrawViewSection() :
static const char *sgroup = "Section";
static const char *fgroup = "Cut Surface Format";
ADD_PROPERTY_TYPE(SectionSymbol ,(""),sgroup,App::Prop_None,"The identifier for this section");
ADD_PROPERTY_TYPE(BaseView ,(nullptr),sgroup,App::Prop_None,"2D View source for this Section");
ADD_PROPERTY_TYPE(SectionSymbol ,(""), sgroup, App::Prop_None, "The identifier for this section");
ADD_PROPERTY_TYPE(BaseView ,(nullptr), sgroup, App::Prop_None, "2D View source for this Section");
BaseView.setScope(App::LinkScope::Global);
ADD_PROPERTY_TYPE(SectionNormal ,(0,0,1.0) ,sgroup,App::Prop_None,
ADD_PROPERTY_TYPE(SectionNormal ,(0, 0,1.0) ,sgroup, App::Prop_None,
"Section Plane normal direction"); //direction of extrusion of cutting prism
ADD_PROPERTY_TYPE(SectionOrigin ,(0,0,0) ,sgroup,App::Prop_None,"Section Plane Origin");
ADD_PROPERTY_TYPE(SectionOrigin ,(0, 0,0) ,sgroup, App::Prop_None, "Section Plane Origin");
SectionDirection.setEnums(SectionDirEnums);
ADD_PROPERTY_TYPE(SectionDirection,((long)0),sgroup, App::Prop_None, "Direction in Base View for this Section");
ADD_PROPERTY_TYPE(FuseBeforeCut ,(false),sgroup,App::Prop_None,"Merge Source(s) into a single shape before cutting");
ADD_PROPERTY_TYPE(SectionDirection, ((long)0), sgroup, App::Prop_None, "Direction in Base View for this Section");
ADD_PROPERTY_TYPE(FuseBeforeCut ,(false), sgroup, App::Prop_None, "Merge Source(s) into a single shape before cutting");
CutSurfaceDisplay.setEnums(CutSurfaceEnums);
ADD_PROPERTY_TYPE(CutSurfaceDisplay,(prefCutSurface()),fgroup, App::Prop_None, "Appearance of Cut Surface");
ADD_PROPERTY_TYPE(CutSurfaceDisplay, (prefCutSurface()), fgroup, App::Prop_None, "Appearance of Cut Surface");
//initialize these to defaults
ADD_PROPERTY_TYPE(FileHatchPattern ,(DrawHatch::prefSvgHatch()),fgroup,App::Prop_None,"The hatch pattern file for the cut surface");
ADD_PROPERTY_TYPE(FileGeomPattern ,(DrawGeomHatch::prefGeomHatchFile()),fgroup,App::Prop_None,"The PAT pattern file for geometric hatching");
ADD_PROPERTY_TYPE(FileHatchPattern ,(DrawHatch::prefSvgHatch()), fgroup, App::Prop_None, "The hatch pattern file for the cut surface");
ADD_PROPERTY_TYPE(FileGeomPattern ,(DrawGeomHatch::prefGeomHatchFile()), fgroup, App::Prop_None, "The PAT pattern file for geometric hatching");
ADD_PROPERTY_TYPE(SvgIncluded ,(""),fgroup,App::Prop_None,
ADD_PROPERTY_TYPE(SvgIncluded ,(""), fgroup, App::Prop_None,
"Embedded Svg hatch file. System use only."); // n/a to end users
ADD_PROPERTY_TYPE(PatIncluded ,(""),fgroup,App::Prop_None,
ADD_PROPERTY_TYPE(PatIncluded ,(""), fgroup, App::Prop_None,
"Embedded Pat pattern file. System use only."); // n/a to end users
ADD_PROPERTY_TYPE(NameGeomPattern ,(DrawGeomHatch::prefGeomHatchName()),fgroup,App::Prop_None,"The pattern name for geometric hatching");
ADD_PROPERTY_TYPE(HatchScale,(1.0),fgroup,App::Prop_None,"Hatch pattern size adjustment");
ADD_PROPERTY_TYPE(NameGeomPattern ,(DrawGeomHatch::prefGeomHatchName()), fgroup, App::Prop_None, "The pattern name for geometric hatching");
ADD_PROPERTY_TYPE(HatchScale, (1.0), fgroup, App::Prop_None, "Hatch pattern size adjustment");
getParameters();
@@ -139,8 +139,8 @@ DrawViewSection::DrawViewSection() :
hatchFilter = ("PAT files (*.pat *.PAT);;All files (*)");
FileGeomPattern.setFilter(hatchFilter);
SvgIncluded.setStatus(App::Property::ReadOnly,true);
PatIncluded.setStatus(App::Property::ReadOnly,true);
SvgIncluded.setStatus(App::Property::ReadOnly, true);
PatIncluded.setStatus(App::Property::ReadOnly, true);
}
DrawViewSection::~DrawViewSection()
@@ -238,7 +238,7 @@ App::DocumentObjectExecReturn *DrawViewSection::execute()
if (FuseBeforeCut.getValue()) {
baseShape = dvp->getSourceShapeFused();
}
if (baseShape.IsNull()) {
return DrawView::execute();
}
@@ -308,17 +308,17 @@ void DrawViewSection::makeSectionCut(TopoDS_Shape &baseShape)
gp_Dir gpNormal = pln.Axis().Direction();
Base::Vector3d orgPnt = SectionOrigin.getValue();
if(!isReallyInBox(gp_Pnt(orgPnt.x,orgPnt.y,orgPnt.z), centerBox)) {
Base::Console().Warning("DVS: SectionOrigin doesn't intersect part in %s\n",getNameInDocument());
if(!isReallyInBox(gp_Pnt(orgPnt.x, orgPnt.y, orgPnt.z), centerBox)) {
Base::Console().Warning("DVS: SectionOrigin doesn't intersect part in %s\n", getNameInDocument());
}
// make cutting tool
// Make the extrusion face
double dMax = sqrt(centerBox.SquareExtent());
BRepBuilderAPI_MakeFace mkFace(pln, -dMax,dMax,-dMax,dMax);
BRepBuilderAPI_MakeFace mkFace(pln, -dMax, dMax, -dMax, dMax);
TopoDS_Face aProjFace = mkFace.Face();
if(aProjFace.IsNull()) {
Base::Console().Warning("DVS: Section face is NULL in %s\n",getNameInDocument());
Base::Console().Warning("DVS: Section face is NULL in %s\n", getNameInDocument());
return;
}
gp_Vec extrudeDir = dMax * gp_Vec(gpNormal);
@@ -341,7 +341,7 @@ void DrawViewSection::makeSectionCut(TopoDS_Shape &baseShape)
const TopoDS_Solid& s = TopoDS::Solid(expl.Current());
BRepAlgoAPI_Cut mkCut(s, prism);
if (!mkCut.IsDone()) {
Base::Console().Warning("DVS: Section cut has failed in %s\n",getNameInDocument());
Base::Console().Warning("DVS: Section cut has failed in %s\n", getNameInDocument());
continue;
}
TopoDS_Shape cut = mkCut.Shape();
@@ -389,7 +389,7 @@ void DrawViewSection::makeSectionCut(TopoDS_Shape &baseShape)
m_scaledShape = TechDraw::scaleShape(centeredShape,
getScale());
if (!DrawUtil::fpCompare(Rotation.getValue(),0.0)) {
if (!DrawUtil::fpCompare(Rotation.getValue(), 0.0)) {
m_scaledShape = TechDraw::rotateShape(m_scaledShape,
m_viewAxis,
Rotation.getValue());
@@ -405,7 +405,7 @@ void DrawViewSection::makeSectionCut(TopoDS_Shape &baseShape)
}
catch (Standard_Failure& e1) {
Base::Console().Warning("DVS::makeSectionCut - failed to build base shape %s - %s **\n",
getNameInDocument(),e1.GetMessageString());
getNameInDocument(), e1.GetMessageString());
return;
}
@@ -456,7 +456,7 @@ void DrawViewSection::postHlrTasks(void)
TopoDS_Shape scaledSection = TechDraw::scaleShape(centeredShapeF,
getScale());
if (!DrawUtil::fpCompare(Rotation.getValue(),0.0)) {
if (!DrawUtil::fpCompare(Rotation.getValue(), 0.0)) {
scaledSection = TechDraw::rotateShape(scaledSection,
m_viewAxis,
Rotation.getValue());
@@ -658,7 +658,7 @@ Base::Vector3d DrawViewSection::getXDirection() const
return result;
}
void DrawViewSection::setCSFromBase(const std::string sectionName)
void DrawViewSection::setCSFromBase(const std::string sectionName)
{
// Base::Console().Message("DVS::setCSFromBase(%s)\n", sectionName.c_str());
gp_Dir gDir = getCSFromBase(sectionName).Direction();
@@ -683,7 +683,7 @@ gp_Ax2 DrawViewSection::getCSFromBase(const std::string sectionName) const
Base::Vector3d sectOrigin = SectionOrigin.getValue();
gp_Ax2 dvpCS = getBaseDVP()->getProjectionCS(sectOrigin);
if (debugSection()) {
DrawUtil::dumpCS("DVS::getCSFromBase - dvp CS", dvpCS);
}
@@ -709,7 +709,7 @@ gp_Ax2 DrawViewSection::getCSFromBase(const std::string sectionName) const
dvsDir = dvpRight.Reversed();
dvsXDir = dvpDir;
} else {
Base::Console().Log("Error - DVS::getCSFromBase - bad sectionName: %s\n",sectionName.c_str());
Base::Console().Log("Error - DVS::getCSFromBase - bad sectionName: %s\n", sectionName.c_str());
dvsDir = dvpRight;
dvsXDir = dvpDir;
}
@@ -744,7 +744,7 @@ gp_Ax2 DrawViewSection::getSectionCS() const
gp_Ax2 sectionCS(gOrigin,
gNormal);
try {
sectionCS = gp_Ax2(gOrigin,
sectionCS = gp_Ax2(gOrigin,
gNormal,
gXDir);
}
@@ -758,7 +758,7 @@ 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::getTrimmedLinesSection(this,m_lineSets,
result = DrawGeomHatch::getTrimmedLinesSection(this, m_lineSets,
getSectionTopoDSFace(i),
HatchScale.getValue());
return result;
@@ -812,7 +812,7 @@ void DrawViewSection::unsetupObject()
DrawViewPart::unsetupObject();
}
void DrawViewSection::onDocumentRestored()
void DrawViewSection::onDocumentRestored()
{
// Base::Console().Message("DVS::onDocumentRestored()\n");
if (SvgIncluded.isEmpty()) {
@@ -884,7 +884,7 @@ void DrawViewSection::setupSvgIncluded(void)
special += "SvgHatch.svg";
std::string dir = doc->TransientDir.getValue();
std::string svgName = dir + special;
//first time
std::string svgInclude = SvgIncluded.getValue();
if (svgInclude.empty()) {
@@ -963,7 +963,7 @@ bool DrawViewSection::debugSection(void) const
Base::Reference<ParameterGrp> hGrp = App::GetApplication().GetUserParameter()
.GetGroup("BaseApp")->GetGroup("Preferences")->GetGroup("Mod/TechDraw/debug");
return hGrp->GetBool("debugSection",false);
return hGrp->GetBool("debugSection", false);
}
int DrawViewSection::prefCutSurface(void) const

View File

@@ -22,8 +22,8 @@
* *
***************************************************************************/
#ifndef _DrawViewSection_h_
#define _DrawViewSection_h_
#ifndef DrawViewSection_h_
#define DrawViewSection_h_
#include <Mod/TechDraw/TechDrawGlobal.h>

View File

@@ -61,17 +61,17 @@ DrawViewSpreadsheet::DrawViewSpreadsheet()
{
static const char *vgroup = "Spreadsheet";
ADD_PROPERTY_TYPE(Source ,(nullptr),vgroup,App::Prop_None,"Spreadsheet to view");
ADD_PROPERTY_TYPE(Source ,(nullptr), vgroup, App::Prop_None, "Spreadsheet to view");
Source.setScope(App::LinkScope::Global);
ADD_PROPERTY_TYPE(CellStart ,("A1"),vgroup,App::Prop_None,"The top left cell of the range to display");
ADD_PROPERTY_TYPE(CellEnd ,("B2"),vgroup,App::Prop_None,"The bottom right cell of the range to display");
ADD_PROPERTY_TYPE(CellStart ,("A1"), vgroup, App::Prop_None, "The top left cell of the range to display");
ADD_PROPERTY_TYPE(CellEnd ,("B2"), vgroup, App::Prop_None, "The bottom right cell of the range to display");
ADD_PROPERTY_TYPE(Font ,(Preferences::labelFont().c_str()),
vgroup,App::Prop_None,"The name of the font to use");
ADD_PROPERTY_TYPE(TextColor,(0.0f,0.0f,0.0f),vgroup,App::Prop_None,"The default color of the text and lines");
ADD_PROPERTY_TYPE(TextSize,(12.0),vgroup,App::Prop_None,"The size of the text");
ADD_PROPERTY_TYPE(LineWidth,(0.35),vgroup,App::Prop_None,"The thickness of the cell lines");
vgroup, App::Prop_None, "The name of the font to use");
ADD_PROPERTY_TYPE(TextColor, (0.0f, 0.0f, 0.0f), vgroup, App::Prop_None, "The default color of the text and lines");
ADD_PROPERTY_TYPE(TextSize, (12.0), vgroup, App::Prop_None, "The size of the text");
ADD_PROPERTY_TYPE(LineWidth, (0.35), vgroup, App::Prop_None, "The thickness of the cell lines");
EditableTexts.setStatus(App::Property::Hidden,true);
EditableTexts.setStatus(App::Property::Hidden, true);
}
@@ -161,10 +161,10 @@ std::string DrawViewSpreadsheet::getSheetImage()
std::string scellstart = CellStart.getValue();
std::string scellend = CellEnd.getValue();
//s/s columns are A,B,C, ... ZX,ZY,ZZ
//s/s columns are A, B,C, ... ZX, ZY, ZZ
//lower case characters are not valid
transform(scellstart.begin(), scellstart.end(), scellstart.begin(), ::toupper);
transform(scellend.begin(), scellend.end(), scellend.begin(), ::toupper);
transform(scellstart.begin(), scellstart.end(), scellstart.begin(), ::toupper);
transform(scellend.begin(), scellend.end(), scellend.begin(), ::toupper);
std::string colPart;
std::string rowPart;
@@ -174,7 +174,7 @@ std::string DrawViewSpreadsheet::getSheetImage()
std::string sColStart, sColEnd;
if (boost::regex_search(scellstart, what, re)) {
if (what.size() < 3) {
Base::Console().Error("%s - start cell (%s) is invalid\n",getNameInDocument(),CellStart.getValue());
Base::Console().Error("%s - start cell (%s) is invalid\n", getNameInDocument(), CellStart.getValue());
return std::string();
}
@@ -193,7 +193,7 @@ std::string DrawViewSpreadsheet::getSheetImage()
if (boost::regex_search(scellend, what, re)) {
if (what.size() < 3) {
Base::Console().Error("%s - end cell (%s) is invalid\n",getNameInDocument(),CellEnd.getValue());
Base::Console().Error("%s - end cell (%s) is invalid\n", getNameInDocument(), CellEnd.getValue());
} else {
colPart = what[1];
sColEnd = colPart;
@@ -220,7 +220,7 @@ std::string DrawViewSpreadsheet::getSheetImage()
}
//validate range end column in sheet's available columns
int iAvailColEnd = colInList(availcolumns,sColEnd);
int iAvailColEnd = colInList(availcolumns, sColEnd);
if (iAvailColEnd < 0) {
Base::Console().Error("DVS - %s - end Column (%s) is invalid\n",
getNameInDocument(), sColEnd.c_str());
@@ -230,7 +230,7 @@ std::string DrawViewSpreadsheet::getSheetImage()
//check for logical range
if ( (iAvailColStart > iAvailColEnd) ||
(iRowStart > iRowEnd) ) {
Base::Console().Error("%s - cell range is illogical\n",getNameInDocument());
Base::Console().Error("%s - cell range is illogical\n", getNameInDocument());
return std::string();
}
@@ -242,7 +242,7 @@ std::string DrawViewSpreadsheet::getSheetImage()
for (; iCol <= iAvailColEnd; iCol++) {
validColNames.push_back(availcolumns.at(iCol));
}
int iRow = iRowStart;
for ( ; iRow <= iRowEnd ; iRow++) {
validRowNumbers.push_back(iRow);
@@ -301,7 +301,7 @@ std::string DrawViewSpreadsheet::getSheetImage()
std::string fcolor = c.asHexString();
std::string textstyle;
if (cell) {
App::Color f,b;
App::Color f, b;
std::set<std::string> st;
int colspan, rowspan;
if (cell->getBackground(b)) {
@@ -320,10 +320,10 @@ std::string DrawViewSpreadsheet::getSheetImage()
textstyle = textstyle + "text-decoration: underline; ";
}
}
if (cell->getSpans(rowspan,colspan)) {
if (cell->getSpans(rowspan, colspan)) {
for (int i=0; i<colspan; ++i) {
for (int j=0; j<rowspan; ++j) {
App::CellAddress nextcell(address.row()+j,address.col()+i);
App::CellAddress nextcell(address.row()+j, address.col()+i);
if (i > 0)
cellwidth = cellwidth + sheet->getColumnWidth(nextcell.col());
if (j > 0)

View File

@@ -20,8 +20,8 @@
* *
***************************************************************************/
#ifndef _DrawViewSpreadsheet_h_
#define _DrawViewSpreadsheet_h_
#ifndef DrawViewSpreadsheet_h_
#define DrawViewSpreadsheet_h_
#include <Mod/TechDraw/TechDrawGlobal.h>

View File

@@ -56,10 +56,10 @@ DrawViewSymbol::DrawViewSymbol()
{
static const char *vgroup = "Drawing view";
ADD_PROPERTY_TYPE(Symbol,(""),vgroup,App::Prop_None,"The SVG code defining this symbol");
ADD_PROPERTY_TYPE(EditableTexts,(""),vgroup,App::Prop_None,"Substitution values for the editable strings in this symbol");
ADD_PROPERTY_TYPE(Symbol, (""), vgroup, App::Prop_None, "The SVG code defining this symbol");
ADD_PROPERTY_TYPE(EditableTexts, (""), vgroup, App::Prop_None, "Substitution values for the editable strings in this symbol");
ScaleType.setValue("Custom");
Symbol.setStatus(App::Property::Hidden,true);
Symbol.setStatus(App::Property::Hidden, true);
}
DrawViewSymbol::~DrawViewSymbol()
@@ -94,7 +94,7 @@ QRectF DrawViewSymbol::getRect() const
{
double w = 64.0; //must default to something
double h = 64.0;
return (QRectF(0,0,w,h));
return (QRectF(0, 0,w, h));
}
//!Assume all svg files fit the page and/or the user will scale manually
@@ -209,7 +209,7 @@ PyObject *DrawViewSymbol::getPyObject()
{
if (PythonObject.is(Py::_None())) {
// ref counter is set to 1
PythonObject = Py::Object(new DrawViewSymbolPy(this),true);
PythonObject = Py::Object(new DrawViewSymbolPy(this), true);
}
return Py::new_reference_to(PythonObject);
}

View File

@@ -20,8 +20,8 @@
* *
***************************************************************************/
#ifndef _DrawViewSymbol_h_
#define _DrawViewSymbol_h_
#ifndef DrawViewSymbol_h_
#define DrawViewSymbol_h_
#include <Mod/TechDraw/TechDrawGlobal.h>

View File

@@ -57,7 +57,7 @@ PyObject* DrawViewSymbolPy::dumpSymbol(PyObject *args)
Base::FileInfo fi(fileSpec);
Base::ofstream outfile;
outfile.open(fi);
outfile.write (symbolRepr.c_str(),symbolRepr.size());
outfile.write (symbolRepr.c_str(), symbolRepr.size());
outfile.close();
if (outfile.good()) {
outfile.close();

View File

@@ -53,22 +53,18 @@ DrawWeldSymbol::DrawWeldSymbol()
{
static const char *group = "Weld Symbol";
ADD_PROPERTY_TYPE(Leader,(nullptr),group,(App::PropertyType)(App::Prop_None), "Parent Leader");
ADD_PROPERTY_TYPE(Leader, (nullptr), group, (App::PropertyType)(App::Prop_None), "Parent Leader");
ADD_PROPERTY_TYPE(AllAround, (false), group, App::Prop_None, "All Around Symbol on/off");
ADD_PROPERTY_TYPE(FieldWeld, (false), group, App::Prop_None, "Field Weld Symbol on/off");
ADD_PROPERTY_TYPE(AlternatingWeld, (false), group, App::Prop_None, "Alternating Weld true/false");
ADD_PROPERTY_TYPE(TailText, (""), group, App::Prop_None, "Text at tail of symbol");
Caption.setStatus(App::Property::Hidden,true);
Scale.setStatus(App::Property::Hidden,true);
ScaleType.setStatus(App::Property::Hidden,true);
Caption.setStatus(App::Property::Hidden, true);
Scale.setStatus(App::Property::Hidden, true);
ScaleType.setStatus(App::Property::Hidden, true);
Rotation.setStatus(App::Property::Hidden, true);
}
DrawWeldSymbol::~DrawWeldSymbol()
{
}
//DWS always has exactly 2 child tiles - ArrowSide and OtherSide.
//OtherSide tile may be hidden;
//once DWS has been added to the document, add 2x DrawTileWeld
@@ -122,7 +118,7 @@ App::DocumentObjectExecReturn *DrawWeldSymbol::execute()
if (!keepUpdated()) {
return DrawView::execute();
}
overrideKeepUpdated(false);
return DrawView::execute();
}
@@ -166,7 +162,7 @@ PyObject *DrawWeldSymbol::getPyObject()
{
if (PythonObject.is(Py::_None())) {
// ref counter is set to 1
PythonObject = Py::Object(new DrawWeldSymbolPy(this),true);
PythonObject = Py::Object(new DrawWeldSymbolPy(this), true);
}
return Py::new_reference_to(PythonObject);
}

View File

@@ -20,8 +20,8 @@
* *
***************************************************************************/
#ifndef _TechDraw_DrawWeldSymbol_h_
#define _TechDraw_DrawWeldSymbol_h_
#ifndef TechDraw_DrawWeldSymbol_h_
#define TechDraw_DrawWeldSymbol_h_
#include <Mod/TechDraw/TechDrawGlobal.h>
@@ -42,7 +42,7 @@ class TechDrawExport DrawWeldSymbol : public TechDraw::DrawView
public:
DrawWeldSymbol();
~DrawWeldSymbol() override;
~DrawWeldSymbol() = default;
App::PropertyLink Leader;
App::PropertyBool AllAround;
@@ -58,7 +58,7 @@ public:
return "TechDrawGui::ViewProviderWeld";
}
PyObject *getPyObject() override;
QRectF getRect() const override { return QRectF(0,0,1,1);}
QRectF getRect() const override { return { 0, 0, 1, 1}; }
bool isTailRightSide();
std::vector<DrawTileWeld*> getTiles() const;

View File

@@ -62,14 +62,14 @@ using namespace boost;
template <typename Edge>
void edgeVisitor::next_edge(Edge e)
{
graph_traits<graph>::vertex_descriptor s = source(e,m_g);
graph_traits<graph>::vertex_descriptor t = target(e,m_g);
graph_traits<graph>::vertex_descriptor s = source(e, m_g);
graph_traits<graph>::vertex_descriptor t = target(e, m_g);
WalkerEdge we;
we.v1 = s;
we.v2 = t;
we.ed = e;
we.idx = get(edge_index,m_g,e);
//Base::Console().Message("TRACE - EV::next_Edge - visiting (%d,%d) idx: %d\n",s,t,we.idx);
we.idx = get(edge_index, m_g, e);
//Base::Console().Message("TRACE - EV::next_Edge - visiting (%d, %d) idx: %d\n", s,t, we.idx);
wireEdges.push_back(we);
}
@@ -118,8 +118,8 @@ bool EdgeWalker::loadEdges(std::vector<TechDraw::WalkerEdge>& edges)
//Base::Console().Message("TRACE -EW::loadEdges(we)\n");
int idx = 0;
for (auto& e: edges) {
std::pair<edge_t,bool> p;
p = add_edge(e.v1,e.v2,m_g);
std::pair<edge_t, bool> p;
p = add_edge(e.v1, e.v2, m_g);
e.ed = p.first;
e.idx = idx;
idx++;
@@ -142,7 +142,7 @@ bool EdgeWalker::loadEdges(std::vector<TopoDS_Edge> edges)
std::vector<WalkerEdge> we = makeWalkerEdges(edges, verts);
loadEdges(we);
m_embedding = makeEmbedding(edges,verts);
m_embedding = makeEmbedding(edges, verts);
return true;
}
@@ -204,10 +204,10 @@ bool EdgeWalker::perform()
ss << "EW::perform - obstructing edges: ";
for(ki = kEdges.begin(); ki != ki_end; ++ki) {
e1 = *ki;
ss << boost::get(edge_index,m_g,e1) << ",";
ss << boost::get(edge_index, m_g, e1) << ", ";
}
ss << std::endl;
Base::Console().Log("LOG - %s\n",ss.str().c_str());
Base::Console().Log("LOG - %s\n", ss.str().c_str());
return false;
}
@@ -316,9 +316,9 @@ std::vector<TopoDS_Vertex> EdgeWalker:: makeUniqueVList(std::vector<TopoDS_Edge>
bool addv1 = true;
bool addv2 = true;
for (const auto& v:uniqueVert) {
if (DrawUtil::isSamePoint(v,v1,EWTOLERANCE))
if (DrawUtil::isSamePoint(v, v1, EWTOLERANCE))
addv1 = false;
if (DrawUtil::isSamePoint(v,v2,EWTOLERANCE))
if (DrawUtil::isSamePoint(v, v2, EWTOLERANCE))
addv2 = false;
}
if (addv1)
@@ -348,7 +348,7 @@ std::vector<WalkerEdge> EdgeWalker::makeWalkerEdges(std::vector<TopoDS_Edge> edg
walkerEdges.push_back(we);
}
//Base::Console().Message("TRACE - EW::makeWalkerEdges - returns we: %d\n",walkerEdges.size());
//Base::Console().Message("TRACE - EW::makeWalkerEdges - returns we: %d\n", walkerEdges.size());
return walkerEdges;
}
@@ -358,7 +358,7 @@ int EdgeWalker::findUniqueVert(TopoDS_Vertex vx, std::vector<TopoDS_Vertex> &uni
int idx = 0;
int result = 0;
for(auto& v:uniqueVert) { //we're always going to find vx, right?
if (DrawUtil::isSamePoint(v,vx,EWTOLERANCE)) {
if (DrawUtil::isSamePoint(v, vx, EWTOLERANCE)) {
result = idx;
break;
}
@@ -375,7 +375,7 @@ std::vector<TopoDS_Wire> EdgeWalker::sortStrip(std::vector<TopoDS_Wire> fw, bool
closedWires.push_back(w);
}
}
std::vector<TopoDS_Wire> sortedWires = sortWiresBySize(closedWires,false); //biggest 1st
std::vector<TopoDS_Wire> sortedWires = sortWiresBySize(closedWires, false); //biggest 1st
if (sortedWires.empty()) {
Base::Console().Log("INFO - EW::sortStrip - no sorted Wires!\n");
return sortedWires; // might happen in the middle of changes?
@@ -395,7 +395,7 @@ std::vector<TopoDS_Wire> EdgeWalker::sortWiresBySize(std::vector<TopoDS_Wire>& w
std::vector<TopoDS_Wire> wires = w;
std::sort(wires.begin(), wires.end(), EdgeWalker::wireCompare);
if (ascend) {
std::reverse(wires.begin(),wires.end());
std::reverse(wires.begin(), wires.end());
}
return wires;
}
@@ -412,7 +412,7 @@ std::vector<embedItem> EdgeWalker::makeEmbedding(const std::vector<TopoDS_Edge>
const std::vector<TopoDS_Vertex> uniqueVList)
{
// Base::Console().Message("TRACE - EW::makeEmbedding(edges: %d, verts: %d)\n",
// edges.size(),uniqueVList.size());
// edges.size(), uniqueVList.size());
std::vector<embedItem> result;
int iv = 0;
@@ -421,12 +421,12 @@ std::vector<embedItem> EdgeWalker::makeEmbedding(const std::vector<TopoDS_Edge>
std::vector<incidenceItem> iiList;
for (auto& e: edges) {
double angle = 0;
if (DrawUtil::isFirstVert(e,v,EWTOLERANCE)) {
angle = DrawUtil::angleWithX(e,v,EWTOLERANCE);
if (DrawUtil::isFirstVert(e, v,EWTOLERANCE)) {
angle = DrawUtil::angleWithX(e, v,EWTOLERANCE);
incidenceItem ii(ie, angle, m_saveWalkerEdges[ie].ed);
iiList.push_back(ii);
} else if (DrawUtil::isLastVert(e,v,EWTOLERANCE)) {
angle = DrawUtil::angleWithX(e,v,EWTOLERANCE);
} else if (DrawUtil::isLastVert(e, v,EWTOLERANCE)) {
angle = DrawUtil::angleWithX(e, v,EWTOLERANCE);
incidenceItem ii(ie, angle, m_saveWalkerEdges[ie].ed);
iiList.push_back(ii);
} else {
@@ -446,7 +446,7 @@ std::vector<embedItem> EdgeWalker::makeEmbedding(const std::vector<TopoDS_Edge>
//! get incidence row as edge indices for v'th vertex
std::vector<int> EdgeWalker::getEmbeddingRowIx(int v)
{
// //Base::Console().Message("TRACE - EW::getEmbeddingRowIx(%d)\n",v);
// //Base::Console().Message("TRACE - EW::getEmbeddingRowIx(%d)\n", v);
std::vector<int> result;
embedItem ei = m_embedding[v];
for (auto& ii: ei.incidenceList) {
@@ -458,7 +458,7 @@ std::vector<int> EdgeWalker::getEmbeddingRowIx(int v)
//! get incidence row as edgeDescriptors for v'th vertex
std::vector<edge_t> EdgeWalker::getEmbeddingRow(int v)
{
// //Base::Console().Message("TRACE - EW::getEmbeddingRow(%d)\n",v);
// //Base::Console().Message("TRACE - EW::getEmbeddingRow(%d)\n", v);
std::vector<edge_t> result;
embedItem ei = m_embedding[v];
for (auto& ii: ei.incidenceList) {
@@ -506,8 +506,8 @@ bool ewWire::isEqual(ewWire w2)
if (wedges.size() != w2.wedges.size()) {
result = false;
} else {
std::sort(wedges.begin(),wedges.end(),WalkerEdge::weCompare);
std::sort(w2.wedges.begin(),w2.wedges.end(),WalkerEdge::weCompare);
std::sort(wedges.begin(), wedges.end(), WalkerEdge::weCompare);
std::sort(w2.wedges.begin(), w2.wedges.end(), WalkerEdge::weCompare);
for (unsigned int i = 0; i < w2.wedges.size(); i ++) {
if (wedges.at(i).idx != w2.wedges.at(i).idx) {
result = false;
@@ -587,7 +587,7 @@ std::vector<incidenceItem> embedItem::sortIncidenceList (std::vector<incidenceIt
std::vector< incidenceItem > tempList = list;
std::sort(tempList.begin(), tempList.end(), incidenceItem::iiCompare);
if (ascend) {
std::reverse(tempList.begin(),tempList.end());
std::reverse(tempList.begin(), tempList.end());
}
return tempList;
}

View File

@@ -125,7 +125,7 @@ class TechDrawExport incidenceItem
public:
incidenceItem() {iEdge = 0; angle = 0.0;}
incidenceItem(int idx, double a, edge_t ed) {iEdge = idx; angle = a; eDesc = ed;}
~incidenceItem() {}
~incidenceItem() = default;
static bool iiCompare(const incidenceItem& i1, const incidenceItem& i2);
static bool iiEqual(const incidenceItem& i1, const incidenceItem& i2);
int iEdge;
@@ -139,7 +139,7 @@ public:
embedItem();
embedItem(int i,
std::vector<incidenceItem> list) { iVertex = i; incidenceList = list;}
~embedItem() {}
~embedItem() = default;
int iVertex;
std::vector<incidenceItem> incidenceList;

View File

@@ -50,18 +50,18 @@ PROPERTY_SOURCE(TechDraw::FeatureProjection, Part::Feature)
FeatureProjection::FeatureProjection()
{
static const char *group = "Projection";
ADD_PROPERTY_TYPE(Source ,(nullptr),group,App::Prop_None,"Shape to project");
ADD_PROPERTY_TYPE(Direction ,(Base::Vector3d(0,0,1)),group,App::Prop_None,"Projection direction");
ADD_PROPERTY_TYPE(VCompound ,(true),group,App::Prop_None,"Projection parameter");
ADD_PROPERTY_TYPE(Rg1LineVCompound ,(true),group,App::Prop_None,"Projection parameter");
ADD_PROPERTY_TYPE(RgNLineVCompound ,(true),group,App::Prop_None,"Projection parameter");
ADD_PROPERTY_TYPE(OutLineVCompound ,(true),group,App::Prop_None,"Projection parameter");
ADD_PROPERTY_TYPE(IsoLineVCompound ,(true),group,App::Prop_None,"Projection parameter");
ADD_PROPERTY_TYPE(HCompound ,(true),group,App::Prop_None,"Projection parameter");
ADD_PROPERTY_TYPE(Rg1LineHCompound ,(true),group,App::Prop_None,"Projection parameter");
ADD_PROPERTY_TYPE(RgNLineHCompound ,(true),group,App::Prop_None,"Projection parameter");
ADD_PROPERTY_TYPE(OutLineHCompound ,(true),group,App::Prop_None,"Projection parameter");
ADD_PROPERTY_TYPE(IsoLineHCompound ,(true),group,App::Prop_None,"Projection parameter");
ADD_PROPERTY_TYPE(Source ,(nullptr), group, App::Prop_None, "Shape to project");
ADD_PROPERTY_TYPE(Direction ,(Base::Vector3d(0, 0,1)), group, App::Prop_None, "Projection direction");
ADD_PROPERTY_TYPE(VCompound ,(true), group, App::Prop_None, "Projection parameter");
ADD_PROPERTY_TYPE(Rg1LineVCompound ,(true), group, App::Prop_None, "Projection parameter");
ADD_PROPERTY_TYPE(RgNLineVCompound ,(true), group, App::Prop_None, "Projection parameter");
ADD_PROPERTY_TYPE(OutLineVCompound ,(true), group, App::Prop_None, "Projection parameter");
ADD_PROPERTY_TYPE(IsoLineVCompound ,(true), group, App::Prop_None, "Projection parameter");
ADD_PROPERTY_TYPE(HCompound ,(true), group, App::Prop_None, "Projection parameter");
ADD_PROPERTY_TYPE(Rg1LineHCompound ,(true), group, App::Prop_None, "Projection parameter");
ADD_PROPERTY_TYPE(RgNLineHCompound ,(true), group, App::Prop_None, "Projection parameter");
ADD_PROPERTY_TYPE(OutLineHCompound ,(true), group, App::Prop_None, "Projection parameter");
ADD_PROPERTY_TYPE(IsoLineHCompound ,(true), group, App::Prop_None, "Projection parameter");
}
FeatureProjection::~FeatureProjection()

View File

@@ -215,21 +215,21 @@ BaseGeomPtr BaseGeom::copy()
result->sourceIndex(m_sourceIndex);
result->cosmeticTag = cosmeticTag;
}
return result;
}
std::string BaseGeom::toString() const
{
std::stringstream ss;
ss << geomType << "," <<
extractType << "," <<
classOfEdge << "," <<
hlrVisible << "," <<
reversed << "," <<
ref3D << "," <<
cosmetic << "," <<
m_source << "," <<
ss << geomType << ", " <<
extractType << ", " <<
classOfEdge << ", " <<
hlrVisible << ", " <<
reversed << ", " <<
ref3D << ", " <<
cosmetic << ", " <<
m_source << ", " <<
m_sourceIndex;
return ss.str();
}
@@ -293,9 +293,9 @@ std::vector<Base::Vector3d> BaseGeom::findEndPoints()
if (!occEdge.IsNull()) {
gp_Pnt p = BRep_Tool::Pnt(TopExp::FirstVertex(occEdge));
result.emplace_back(p.X(),p.Y(), p.Z());
result.emplace_back(p.X(), p.Y(), p.Z());
p = BRep_Tool::Pnt(TopExp::LastVertex(occEdge));
result.emplace_back(p.X(),p.Y(), p.Z());
result.emplace_back(p.X(), p.Y(), p.Z());
} else {
//TODO: this should throw something
Base::Console().Message("Geometry::findEndPoints - OCC edge not found\n");
@@ -367,24 +367,24 @@ std::vector<Base::Vector3d> BaseGeom::getQuads()
double q1 = u + (range / 4.0);
double q2 = u + (range / 2.0);
double q3 = u + (3.0 * range / 4.0);
BRepLProp_CLProps prop(adapt,q1,0,Precision::Confusion());
BRepLProp_CLProps prop(adapt, q1, 0,Precision::Confusion());
const gp_Pnt& p1 = prop.Value();
result.emplace_back(p1.X(),p1.Y(), 0.0);
result.emplace_back(p1.X(), p1.Y(), 0.0);
prop.SetParameter(q2);
const gp_Pnt& p2 = prop.Value();
result.emplace_back(p2.X(),p2.Y(), 0.0);
result.emplace_back(p2.X(), p2.Y(), 0.0);
prop.SetParameter(q3);
const gp_Pnt& p3 = prop.Value();
result.emplace_back(p3.X(),p3.Y(), 0.0);
result.emplace_back(p3.X(), p3.Y(), 0.0);
return result;
}
double BaseGeom::minDist(Base::Vector3d p)
{
double minDist = -1.0;
gp_Pnt pnt(p.x,p.y,0.0);
gp_Pnt pnt(p.x, p.y, 0.0);
TopoDS_Vertex v = BRepBuilderAPI_MakeVertex(pnt);
minDist = TechDraw::DrawUtil::simpleMinDist(occEdge,v);
minDist = TechDraw::DrawUtil::simpleMinDist(occEdge, v);
return minDist;
}
@@ -407,8 +407,8 @@ Base::Vector3d BaseGeom::nearPoint(const BaseGeomPtr p)
Base::Vector3d BaseGeom::nearPoint(Base::Vector3d p)
{
gp_Pnt pnt(p.x,p.y,0.0);
Base::Vector3d result(0.0,0.0, 0.0);
gp_Pnt pnt(p.x, p.y, 0.0);
Base::Vector3d result(0.0, 0.0, 0.0);
TopoDS_Vertex v = BRepBuilderAPI_MakeVertex(pnt);
BRepExtrema_DistShapeShape extss(occEdge, v);
if (extss.IsDone()) {
@@ -416,7 +416,7 @@ Base::Vector3d BaseGeom::nearPoint(Base::Vector3d p)
if (count != 0) {
gp_Pnt p1;
p1 = extss.PointOnShape1(1);
result = Base::Vector3d(p1.X(),p1.Y(), 0.0);
result = Base::Vector3d(p1.X(), p1.Y(), 0.0);
}
}
return result;
@@ -427,7 +427,7 @@ std::string BaseGeom::dump()
Base::Vector3d start = getStartPoint();
Base::Vector3d end = getEndPoint();
std::stringstream ss;
ss << "BaseGeom: s:(" << start.x << "," << start.y << ") e:(" << end.x << "," << end.y << ") ";
ss << "BaseGeom: s:(" << start.x << ", " << start.y << ") e:(" << end.x << ", " << end.y << ") ";
ss << "type: " << geomType << " class: " << classOfEdge << " viz: " << hlrVisible << " rev: " << reversed;
ss << "cosmetic: " << cosmetic << " source: " << source() << " iSource: " << sourceIndex();
return ss.str();
@@ -498,7 +498,7 @@ BaseGeomPtr BaseGeom::baseFactory(TopoDS_Edge edge)
result->reversed = true;
}
// OCC is quite happy with Degree > 3 but QtGui handles only 2,3
// OCC is quite happy with Degree > 3 but QtGui handles only 2, 3
} break;
case GeomAbs_BSplineCurve: {
TopoDS_Edge circEdge;
@@ -736,7 +736,7 @@ Ellipse::Ellipse(Base::Vector3d c, double mnr, double mjr)
minor = mnr;
angle = 0;
GC_MakeEllipse me(gp_Ax2(gp_Pnt(c.x,c.y,c.z), gp_Dir(0.0,0.0,1.0)),
GC_MakeEllipse me(gp_Ax2(gp_Pnt(c.x, c.y, c.z), gp_Dir(0.0, 0.0, 1.0)),
major, minor);
if (!me.IsDone()) {
Base::Console().Message("G:Ellipse - failed to make Ellipse\n");
@@ -761,18 +761,18 @@ AOE::AOE(const TopoDS_Edge &e) : Ellipse(e)
double a;
try {
gp_Vec v1(m,s);
gp_Vec v2(m,ePt);
gp_Vec v3(0,0,1);
a = v3.DotCross(v1,v2);
gp_Vec v1(m, s);
gp_Vec v2(m, ePt);
gp_Vec v3(0, 0,1);
a = v3.DotCross(v1, v2);
}
catch (const Standard_Failure& e) {
Base::Console().Error("Geom::AOE::AOE - OCC error - %s - while making AOE in ctor\n",
e.GetMessageString());
}
startAngle = fmod(f,2.0*M_PI);
endAngle = fmod(l,2.0*M_PI);
startAngle = fmod(f, 2.0*M_PI);
endAngle = fmod(l, 2.0*M_PI);
cw = (a < 0) ? true: false;
largeArc = (l-f > M_PI) ? true : false;
@@ -798,7 +798,7 @@ Circle::Circle(Base::Vector3d c, double r)
radius = r;
center = c;
gp_Pnt loc(c.x, c.y, c.z);
gp_Dir dir(0,0,1);
gp_Dir dir(0, 0,1);
gp_Ax1 axis(loc, dir);
gp_Circ circle;
circle.SetAxis(axis);
@@ -829,11 +829,11 @@ std::string Circle::toString() const
{
std::string baseCSV = BaseGeom::toString();
std::stringstream ss;
ss << center.x << "," <<
center.y << "," <<
center.z << "," <<
ss << center.x << ", " <<
center.y << ", " <<
center.z << ", " <<
radius;
return baseCSV + ",$$$," + ss.str();
return baseCSV + ", $$$, " + ss.str();
}
void Circle::Save(Base::Writer &writer) const
@@ -872,13 +872,13 @@ AOC::AOC(const TopoDS_Edge &e) : Circle(e)
gp_Pnt s = c.Value(f);
gp_Pnt m = c.Value((l+f)/2.0);
gp_Pnt ePt = c.Value(l); //if start == end, it isn't an arc!
gp_Vec v1(m,s); //vector mid to start
gp_Vec v2(m,ePt); //vector mid to end
gp_Vec v3(0,0,1); //stdZ
double a = v3.DotCross(v1,v2); //error if v1 = v2?
gp_Vec v1(m, s); //vector mid to start
gp_Vec v2(m, ePt); //vector mid to end
gp_Vec v3(0, 0,1); //stdZ
double a = v3.DotCross(v1, v2); //error if v1 = v2?
startAngle = fmod(f,2.0*M_PI);
endAngle = fmod(l,2.0*M_PI);
startAngle = fmod(f, 2.0*M_PI);
endAngle = fmod(l, 2.0*M_PI);
cw = (a < 0) ? true: false;
largeArc = (fabs(l-f) > M_PI) ? true : false;
@@ -897,7 +897,7 @@ AOC::AOC(Base::Vector3d c, double r, double sAng, double eAng) : Circle()
radius = r;
center = c;
gp_Pnt loc(c.x, c.y, c.z);
gp_Dir dir(0,0,1);
gp_Dir dir(0, 0,1);
gp_Ax1 axis(loc, dir);
gp_Circ circle;
circle.SetAxis(axis);
@@ -915,13 +915,13 @@ AOC::AOC(Base::Vector3d c, double r, double sAng, double eAng) : Circle()
gp_Pnt s = adp.Value(f);
gp_Pnt m = adp.Value((l+f)/2.0);
gp_Pnt ePt = adp.Value(l); //if start == end, it isn't an arc!
gp_Vec v1(m,s); //vector mid to start
gp_Vec v2(m,ePt); //vector mid to end
gp_Vec v3(0,0,1); //stdZ
double a = v3.DotCross(v1,v2); //error if v1 = v2?
gp_Vec v1(m, s); //vector mid to start
gp_Vec v2(m, ePt); //vector mid to end
gp_Vec v3(0, 0,1); //stdZ
double a = v3.DotCross(v1, v2); //error if v1 = v2?
startAngle = fmod(f,2.0*M_PI);
endAngle = fmod(l,2.0*M_PI);
startAngle = fmod(f, 2.0*M_PI);
endAngle = fmod(l, 2.0*M_PI);
cw = (a < 0) ? true: false;
largeArc = (fabs(l-f) > M_PI) ? true : false;
@@ -952,7 +952,7 @@ bool AOC::isOnArc(Base::Vector3d p)
{
bool result = false;
double minDist = -1.0;
gp_Pnt pnt(p.x,p.y,p.z);
gp_Pnt pnt(p.x, p.y, p.z);
TopoDS_Vertex v = BRepBuilderAPI_MakeVertex(pnt);
BRepExtrema_DistShapeShape extss(occEdge, v);
if (extss.IsDone()) {
@@ -979,11 +979,11 @@ bool AOC::intersectsArc(Base::Vector3d p1, Base::Vector3d p2)
{
bool result = false;
double minDist = -1.0;
gp_Pnt pnt1(p1.x,p1.y,p1.z);
gp_Pnt pnt1(p1.x, p1.y, p1.z);
TopoDS_Vertex v1 = BRepBuilderAPI_MakeVertex(pnt1);
gp_Pnt pnt2(p2.x,p2.y,p2.z);
gp_Pnt pnt2(p2.x, p2.y, p2.z);
TopoDS_Vertex v2 = BRepBuilderAPI_MakeVertex(pnt2);
BRepBuilderAPI_MakeEdge mkEdge(v1,v2);
BRepBuilderAPI_MakeEdge mkEdge(v1, v2);
TopoDS_Edge line = mkEdge.Edge();
BRepExtrema_DistShapeShape extss(occEdge, line);
if (extss.IsDone()) {
@@ -1003,21 +1003,21 @@ std::string AOC::toString() const
std::string circleCSV = Circle::toString();
std::stringstream ss;
ss << startPnt.x << "," <<
startPnt.y << "," <<
startPnt.z << "," <<
endPnt.x << "," <<
endPnt.y << "," <<
endPnt.z << "," <<
midPnt.x << "," <<
midPnt.y << "," <<
midPnt.z << "," <<
startAngle << "," <<
endAngle << "," <<
cw << "," <<
ss << startPnt.x << ", " <<
startPnt.y << ", " <<
startPnt.z << ", " <<
endPnt.x << ", " <<
endPnt.y << ", " <<
endPnt.z << ", " <<
midPnt.x << ", " <<
midPnt.y << ", " <<
midPnt.z << ", " <<
startAngle << ", " <<
endAngle << ", " <<
cw << ", " <<
largeArc;
std::string result = circleCSV + ",$$$," + ss.str();
std::string result = circleCSV + ", $$$, " + ss.str();
return result;
}
@@ -1110,22 +1110,22 @@ std::string Generic::toString() const
{
std::string baseCSV = BaseGeom::toString();
std::stringstream ss;
ss << points.size() << ",";
ss << points.size() << ", ";
for (auto& p: points) {
ss << p.x << "," <<
p.y << "," <<
p.z << ",";
ss << p.x << ", " <<
p.y << ", " <<
p.z << ", ";
}
std::string genericCSV = ss.str();
genericCSV.pop_back();
return baseCSV + ",$$$," + genericCSV;
return baseCSV + ", $$$, " + genericCSV;
}
void Generic::Save(Base::Writer &writer) const
{
BaseGeom::Save(writer);
writer.Stream() << writer.ind()
writer.Stream() << writer.ind()
<< "<Points PointsCount =\"" << points.size() << "\">" << endl;
writer.incInd();
for (auto& p: points) {
@@ -1205,7 +1205,7 @@ BSpline::BSpline(const TopoDS_Edge &e)
occEdge = e;
Handle(Geom_BSplineCurve) spline;
double f,l;
double f, l;
f = c.FirstParameter();
l = c.LastParameter();
gp_Pnt s = c.Value(f);
@@ -1214,17 +1214,17 @@ BSpline::BSpline(const TopoDS_Edge &e)
startPnt = Base::Vector3d(s.X(), s.Y(), s.Z());
endPnt = Base::Vector3d(ePt.X(), ePt.Y(), ePt.Z());
midPnt = Base::Vector3d(m.X(), m.Y(), m.Z());
gp_Vec v1(m,s);
gp_Vec v2(m,ePt);
gp_Vec v3(0,0,1);
double a = v3.DotCross(v1,v2);
gp_Vec v1(m, s);
gp_Vec v2(m, ePt);
gp_Vec v3(0, 0,1);
double a = v3.DotCross(v1, v2);
cw = (a < 0) ? true: false;
startAngle = atan2(startPnt.y,startPnt.x);
startAngle = atan2(startPnt.y, startPnt.x);
if (startAngle < 0) {
startAngle += 2.0 * M_PI;
}
endAngle = atan2(endPnt.y,endPnt.x);
endAngle = atan2(endPnt.y, endPnt.x);
if (endAngle < 0) {
endAngle += 2.0 * M_PI;
}
@@ -1246,12 +1246,12 @@ BSpline::BSpline(const TopoDS_Edge &e)
l = c.LastParameter();
s = c.Value(f);
ePt = c.Value(l);
Base::Console().Log("Error - Geometry::BSpline - no result- from:(%.3f,%.3f) to:(%.3f,%.3f) poles: %d\n",
s.X(),s.Y(),ePt.X(),ePt.Y(),spline->NbPoles());
TColgp_Array1OfPnt controlPoints(0,1);
controlPoints.SetValue(0,s);
controlPoints.SetValue(1,ePt);
spline = GeomAPI_PointsToBSpline(controlPoints,1).Curve();
Base::Console().Log("Error - Geometry::BSpline - no result- from:(%.3f, %.3f) to:(%.3f, %.3f) poles: %d\n",
s.X(), s.Y(), ePt.X(), ePt.Y(), spline->NbPoles());
TColgp_Array1OfPnt controlPoints(0, 1);
controlPoints.SetValue(0, s);
controlPoints.SetValue(1, ePt);
spline = GeomAPI_PointsToBSpline(controlPoints, 1).Curve();
}
}
@@ -1291,14 +1291,14 @@ bool BSpline::isLine()
gp_Pnt s = c.Value(f);
gp_Pnt e = c.Value(l);
bool samePnt = s.IsEqual(e,FLT_EPSILON);
bool samePnt = s.IsEqual(e, FLT_EPSILON);
if (!samePnt) {
Base::Vector3d vs = DrawUtil::gpPnt2V3(s);
Base::Vector3d ve = DrawUtil::gpPnt2V3(e);
double endLength = (vs - ve).Length();
int low = 0;
int high = spline->NbPoles() - 1;
TColgp_Array1OfPnt poles(low,high);
TColgp_Array1OfPnt poles(low, high);
spline->Poles(poles);
double lenTotal = 0.0;
for (int i = 0; i < high; i++) {
@@ -1309,7 +1309,7 @@ bool BSpline::isLine()
lenTotal += (v2-v1).Length();
}
if (DrawUtil::fpCompare(lenTotal,endLength)) {
if (DrawUtil::fpCompare(lenTotal, endLength)) {
result = true;
}
}
@@ -1323,7 +1323,7 @@ bool BSpline::isCircle()
double radius;
Base::Vector3d center;
bool isArc = false;
getCircleParms(result,radius,center,isArc);
getCircleParms(result, radius, center, isArc);
return result;
}
@@ -1333,7 +1333,7 @@ void BSpline::getCircleParms(bool& isCircle, double& radius, Base::Vector3d& cen
double curveLimit = 0.0001;
BRepAdaptor_Curve c(occEdge);
Handle(Geom_BSplineCurve) spline = c.BSpline();
double f,l;
double f, l;
f = c.FirstParameter();
l = c.LastParameter();
double parmRange = fabs(l - f);
@@ -1345,12 +1345,12 @@ void BSpline::getCircleParms(bool& isCircle, double& radius, Base::Vector3d& cen
double sumCurvature = 0;
Base::Vector3d sumCenter, valueAt;
try {
GeomLProp_CLProps prop(spline,f,3,Precision::Confusion());
GeomLProp_CLProps prop(spline, f,3, Precision::Confusion());
curvatures.push_back(prop.Curvature());
sumCurvature += prop.Curvature();
prop.CentreOfCurvature(curveCenter);
centers.push_back(curveCenter);
sumCenter += Base::Vector3d(curveCenter.X(),curveCenter.Y(),curveCenter.Z());
sumCenter += Base::Vector3d(curveCenter.X(), curveCenter.Y(), curveCenter.Z());
for (int i = 1; i < (testCount - 1); i++) {
prop.SetParameter(parmStep * i);
@@ -1358,14 +1358,14 @@ void BSpline::getCircleParms(bool& isCircle, double& radius, Base::Vector3d& cen
sumCurvature += prop.Curvature();
prop.CentreOfCurvature(curveCenter);
centers.push_back(curveCenter);
sumCenter += Base::Vector3d(curveCenter.X(),curveCenter.Y(),curveCenter.Z());
sumCenter += Base::Vector3d(curveCenter.X(), curveCenter.Y(), curveCenter.Z());
}
prop.SetParameter(l);
curvatures.push_back(prop.Curvature());
sumCurvature += prop.Curvature();
prop.CentreOfCurvature(curveCenter);
centers.push_back(curveCenter);
sumCenter += Base::Vector3d(curveCenter.X(),curveCenter.Y(),curveCenter.Z());
sumCenter += Base::Vector3d(curveCenter.X(), curveCenter.Y(), curveCenter.Z());
}
catch (Standard_Failure&) {
Base::Console().Log("TechDraw - GEO::BSpline::getCircleParms - CLProps failed\n");
@@ -1428,7 +1428,7 @@ TopoDS_Edge BSpline::asCircle(bool& arc)
gp_Pnt p2 = spline->Pole(nb_poles-1);
gp_Pnt pm;
if (nb_poles == 5) {
pm = spline->Pole(3); //5 poles => 2.5 => 2
pm = spline->Pole(3); //5 poles => 2.5 => 2
} else {
pm = spline->Pole(nb_poles / 2);
}
@@ -1456,16 +1456,16 @@ TopoDS_Edge BSpline::asCircle(bool& arc)
pcm = projm.NearestPoint();
// make 2 circles and find their radii
gce_MakeCirc gce_circ1 = gce_MakeCirc(s,pc1,pcm); //3 point circle
gce_MakeCirc gce_circ1 = gce_MakeCirc(s, pc1, pcm); //3 point circle
if (gce_circ1.Status() != gce_Done) {
return result;
}
gp_Circ circle1 = gce_circ1.Value();
double radius1 = circle1.Radius();
gp_Pnt center1 = circle1.Location();
gp_Pnt center1 = circle1.Location();
Base::Vector3d vc1 = DrawUtil::gpPnt2V3(center1);
gce_MakeCirc gce_circ2 = gce_MakeCirc(pcm,pc2,e);
gce_MakeCirc gce_circ2 = gce_MakeCirc(pcm, pc2, e);
if (gce_circ2.Status() != gce_Done) {
return result;
}
@@ -1478,19 +1478,19 @@ TopoDS_Edge BSpline::asCircle(bool& arc)
double allowError = 0.001; //mm^-3 good enough for printing
double radius;
Base::Vector3d center;
if ( (DrawUtil::fpCompare(radius2,radius1, allowError)) &&
(vc1.IsEqual(vc2,allowError)) ) {
if ( (DrawUtil::fpCompare(radius2, radius1, allowError)) &&
(vc1.IsEqual(vc2, allowError)) ) {
if (arc) {
GC_MakeArcOfCircle makeArc(s,pcm,e);
GC_MakeArcOfCircle makeArc(s, pcm, e);
Handle(Geom_TrimmedCurve) tCurve = makeArc.Value();
BRepBuilderAPI_MakeEdge newEdge(tCurve);
result = newEdge;
} else {
} else {
radius = (radius1 + radius2) / 2.0;
center = (vc1 + vc2) / 2.0;
gp_Pnt gCenter(center.x,center.y,center.z);
gp_Ax2 stdZ(gCenter,gp_Dir(0,0,1));
gp_Circ newCirc(stdZ,radius);
gp_Pnt gCenter(center.x, center.y, center.z);
gp_Ax2 stdZ(gCenter, gp_Dir(0, 0,1));
gp_Circ newCirc(stdZ, radius);
BRepBuilderAPI_MakeEdge newEdge(newCirc);
result = newEdge;
}
@@ -1511,15 +1511,15 @@ TopoDS_Edge BSpline::asCircle(bool& arc)
}
bool BSpline::intersectsArc(Base::Vector3d p1,Base::Vector3d p2)
bool BSpline::intersectsArc(Base::Vector3d p1, Base::Vector3d p2)
{
bool result = false;
double minDist = -1.0;
gp_Pnt pnt1(p1.x,p1.y,p1.z);
gp_Pnt pnt1(p1.x, p1.y, p1.z);
TopoDS_Vertex v1 = BRepBuilderAPI_MakeVertex(pnt1);
gp_Pnt pnt2(p2.x,p2.y,p2.z);
gp_Pnt pnt2(p2.x, p2.y, p2.z);
TopoDS_Vertex v2 = BRepBuilderAPI_MakeVertex(pnt2);
BRepBuilderAPI_MakeEdge mkEdge(v1,v2);
BRepBuilderAPI_MakeEdge mkEdge(v1, v2);
TopoDS_Edge line = mkEdge.Edge();
BRepExtrema_DistShapeShape extss(occEdge, line);
if (extss.IsDone()) {
@@ -1544,7 +1544,7 @@ BezierSegment::BezierSegment(const TopoDS_Edge &e)
poles = bez->NbPoles();
degree = bez->Degree();
if (poles > 4) {
Base::Console().Log("Warning - BezierSegment has degree > 3: %d\n",degree);
Base::Console().Log("Warning - BezierSegment has degree > 3: %d\n", degree);
}
for (int i = 1; i <= poles; ++i) {
gp_Pnt controlPoint = bez->Pole(i);
@@ -1595,7 +1595,7 @@ Vertex::Vertex(double x, double y)
hlrVisible = false;
ref3D = -1; //obs. never used.
isCenter = false;
BRepBuilderAPI_MakeVertex mkVert(gp_Pnt(x,y,0.0));
BRepBuilderAPI_MakeVertex mkVert(gp_Pnt(x, y,0.0));
occVertex = mkVert.Vertex();
cosmetic = false;
cosmeticLink = -1;
@@ -1604,7 +1604,7 @@ Vertex::Vertex(double x, double y)
createNewTag();
}
Vertex::Vertex(Base::Vector3d v) : Vertex(v.x,v.y)
Vertex::Vertex(Base::Vector3d v) : Vertex(v.x, v.y)
{
// Base::Console().Message("V::V(%s)\n",
// DrawUtil::formatVector(v).c_str());
@@ -1722,14 +1722,14 @@ void Vertex::dump(const char* title)
BaseGeomPtrVector GeometryUtils::chainGeoms(BaseGeomPtrVector geoms)
{
BaseGeomPtrVector result;
std::vector<bool> used(geoms.size(),false);
std::vector<bool> used(geoms.size(), false);
if (geoms.empty()) {
return result;
}
if (geoms.size() == 1) {
//don't bother for single geom (circles, ellipses,etc)
//don't bother for single geom (circles, ellipses, etc)
result.push_back(geoms[0]);
} else {
//start with first edge
@@ -1802,7 +1802,7 @@ TopoDS_Edge GeometryUtils::edgeFromGeneric(TechDraw::GenericPtr g)
TopoDS_Edge GeometryUtils::edgeFromCircle(TechDraw::CirclePtr c)
{
gp_Pnt loc(c->center.x, c->center.y, c->center.z);
gp_Dir dir(0,0,1);
gp_Dir dir(0, 0,1);
gp_Ax1 axis(loc, dir);
gp_Circ circle;
circle.SetAxis(axis);
@@ -1816,7 +1816,7 @@ TopoDS_Edge GeometryUtils::edgeFromCircle(TechDraw::CirclePtr c)
TopoDS_Edge GeometryUtils::edgeFromCircleArc(TechDraw::AOCPtr c)
{
gp_Pnt loc(c->center.x, c->center.y, c->center.z);
gp_Dir dir(0,0,1);
gp_Dir dir(0, 0,1);
gp_Ax1 axis(loc, dir);
gp_Circ circle;
circle.SetAxis(axis);

View File

@@ -240,7 +240,7 @@ class TechDrawExport AOC: public Circle
bool largeArc;
bool isOnArc(Base::Vector3d v);
bool intersectsArc(Base::Vector3d p1,Base::Vector3d p2);
bool intersectsArc(Base::Vector3d p1, Base::Vector3d p2);
double distToArc(Base::Vector3d p);
};
@@ -277,7 +277,7 @@ class TechDrawExport BSpline: public BaseGeom
bool isCircle();
TopoDS_Edge asCircle(bool& isArc);
void getCircleParms(bool& isCircle, double& radius, Base::Vector3d& center, bool& isArc);
bool intersectsArc(Base::Vector3d p1,Base::Vector3d p2);
bool intersectsArc(Base::Vector3d p1, Base::Vector3d p2);
std::vector<BezierSegment> segments;
};
@@ -329,7 +329,7 @@ class TechDrawExport Vertex
explicit Vertex(const Vertex* v);
Vertex(double x, double y);
explicit Vertex(Base::Vector3d v);
virtual ~Vertex() {}
virtual ~Vertex() = default;
virtual void Save(Base::Writer &/*writer*/) const;
virtual void Restore(Base::XMLReader &/*reader*/);
@@ -342,7 +342,7 @@ class TechDrawExport Vertex
bool isCenter;
TopoDS_Vertex occVertex;
bool isEqual(const Vertex& v, double tol);
Base::Vector3d point() const { return Base::Vector3d(pnt.x,pnt.y,0.0); }
Base::Vector3d point() const { return Base::Vector3d(pnt.x, pnt.y, 0.0); }
void point(Base::Vector3d v){ pnt = Base::Vector3d(v.x, v.y); }
bool cosmetic;
int cosmeticLink; //deprec. use cosmeticTag
@@ -380,7 +380,7 @@ class TechDrawExport GeometryUtils
/// Find an unused geom starts or ends at atPoint.
/*!
* returns index[1:geoms.size()),reversed [true,false]
* returns index[1:geoms.size()), reversed [true, false]
*/
static ReturnType nextGeom( Base::Vector3d atPoint,
std::vector<TechDraw::BaseGeomPtr> geoms,

View File

@@ -334,7 +334,7 @@ void GeometryObject::projectShapeWithPolygonAlgo(const TopoDS_Shape& input,
{
// Clear previous Geometry
clear();
//work around for Mantis issue #3332
//if 3332 gets fixed in OCC, this will produce shifted views and will need
//to be reverted.
@@ -342,8 +342,8 @@ void GeometryObject::projectShapeWithPolygonAlgo(const TopoDS_Shape& input,
if (!m_isPersp) {
gp_Pnt gCenter = findCentroid(input,
viewAxis);
Base::Vector3d motion(-gCenter.X(),-gCenter.Y(),-gCenter.Z());
inCopy = moveShape(input,motion);
Base::Vector3d motion(-gCenter.X(), -gCenter.Y(), -gCenter.Z());
inCopy = moveShape(input, motion);
} else {
BRepBuilderAPI_Copy BuilderCopy(input);
inCopy = BuilderCopy.Shape();
@@ -458,7 +458,7 @@ TopoDS_Shape GeometryObject::projectFace(const TopoDS_Shape &face,
//!add edges meeting filter criteria for category, visibility
void GeometryObject::extractGeometry(edgeClass category, bool hlrVisible)
{
// Base::Console().Message("GO::extractGeometry(%d, %d)\n",category, hlrVisible);
// Base::Console().Message("GO::extractGeometry(%d, %d)\n", category, hlrVisible);
TopoDS_Shape filtEdges;
if (hlrVisible) {
switch (category) {
@@ -478,7 +478,7 @@ void GeometryObject::extractGeometry(edgeClass category, bool hlrVisible)
filtEdges = visIso;
break;
default:
Base::Console().Warning("GeometryObject::ExtractGeometry - unsupported hlrVisible edgeClass: %d\n",category);
Base::Console().Warning("GeometryObject::ExtractGeometry - unsupported hlrVisible edgeClass: %d\n", category);
return;
}
} else {
@@ -499,7 +499,7 @@ void GeometryObject::extractGeometry(edgeClass category, bool hlrVisible)
filtEdges = hidIso;
break;
default:
Base::Console().Warning("GeometryObject::ExtractGeometry - unsupported hidden edgeClass: %d\n",category);
Base::Console().Warning("GeometryObject::ExtractGeometry - unsupported hidden edgeClass: %d\n", category);
return;
}
}
@@ -519,24 +519,24 @@ void GeometryObject::addGeomFromCompound(TopoDS_Shape edgeCompound, edgeClass ca
BaseGeomPtr base;
TopExp_Explorer edges(edgeCompound, TopAbs_EDGE);
int i = 1;
for ( ; edges.More(); edges.Next(),i++) {
for ( ; edges.More(); edges.Next(), i++) {
const TopoDS_Edge& edge = TopoDS::Edge(edges.Current());
if (edge.IsNull()) {
Base::Console().Log("GO::addGeomFromCompound - edge: %d is NULL\n",i);
Base::Console().Log("GO::addGeomFromCompound - edge: %d is NULL\n", i);
continue;
}
if (DrawUtil::isZeroEdge(edge)) {
Base::Console().Log("GO::addGeomFromCompound - edge: %d is zeroEdge\n",i);
Base::Console().Log("GO::addGeomFromCompound - edge: %d is zeroEdge\n", i);
continue;
}
if (DrawUtil::isCrazy(edge)) {
Base::Console().Log("GO::addGeomFromCompound - edge: %d is crazy\n",i);
Base::Console().Log("GO::addGeomFromCompound - edge: %d is crazy\n", i);
continue;
}
base = BaseGeom::baseFactory(edge);
if (!base) {
Base::Console().Log("Error - GO::addGeomFromCompound - baseFactory failed for edge: %d\n",i);
Base::Console().Log("Error - GO::addGeomFromCompound - baseFactory failed for edge: %d\n", i);
continue;
// throw Base::ValueError("GeometryObject::addGeomFromCompound - baseFactory failed");
}
@@ -564,14 +564,14 @@ void GeometryObject::addGeomFromCompound(TopoDS_Shape edgeCompound, edgeClass ca
std::vector<VertexPtr>::iterator itVertex = vertexGeom.begin();
for (; itVertex != vertexGeom.end(); itVertex++) {
if ((*itVertex)->isEqual(*v1,Precision::Confusion())) {
if ((*itVertex)->isEqual(*v1, Precision::Confusion())) {
v1Add = false;
}
if ((*itVertex)->isEqual(*v2,Precision::Confusion())) {
if ((*itVertex)->isEqual(*v2, Precision::Confusion())) {
v2Add = false;
}
if (circle ) {
if ((*itVertex)->isEqual(*c1,Precision::Confusion())) {
if ((*itVertex)->isEqual(*c1, Precision::Confusion())) {
c1Add = false;
}
}
@@ -817,15 +817,15 @@ Base::BoundBox3d GeometryObject::calcBoundingBox() const
BRepBndLib::AddOptimal((*it)->occEdge, testBox);
}
}
double xMin = 0,xMax = 0,yMin = 0,yMax = 0, zMin = 0, zMax = 0;
double xMin = 0, xMax = 0, yMin = 0, yMax = 0, zMin = 0, zMax = 0;
if (testBox.IsVoid()) {
Base::Console().Log("INFO - GO::calcBoundingBox - testBox is void\n");
} else {
testBox.Get(xMin,yMin,zMin,xMax,yMax,zMax);
testBox.Get(xMin, yMin, zMin, xMax, yMax, zMax);
}
Base::BoundBox3d bbox(xMin,yMin,zMin,xMax,yMax,zMax);
Base::BoundBox3d bbox(xMin, yMin, zMin, xMax, yMax, zMax);
return bbox;
}
@@ -836,7 +836,7 @@ void GeometryObject::pruneVertexGeom(Base::Vector3d center, double radius)
for (auto& v: oldVerts) {
Base::Vector3d v3 = v->point();
double length = (v3 - center).Length();
if (length < Precision::Confusion()) {
if (length < Precision::Confusion()) {
continue;
} else if (length < radius) {
newVerts.push_back(v);
@@ -872,23 +872,23 @@ gp_Ax2 TechDraw::getViewAxis(const Base::Vector3d origin,
// Base::Console().Message("GO::getViewAxis() - 1 - use only with getLegacyX\n");
(void) flip;
gp_Ax2 viewAxis;
gp_Pnt inputCenter(origin.x,origin.y,origin.z);
Base::Vector3d stdZ(0.0,0.0,1.0);
Base::Vector3d stdOrg(0.0,0.0,0.0);
gp_Pnt inputCenter(origin.x, origin.y, origin.z);
Base::Vector3d stdZ(0.0, 0.0, 1.0);
Base::Vector3d stdOrg(0.0, 0.0, 0.0);
Base::Vector3d cross = direction;
if (TechDraw::DrawUtil::checkParallel(direction, stdZ)) {
cross = Base::Vector3d(1.0,0.0,0.0);
cross = Base::Vector3d(1.0, 0.0, 0.0);
} else {
cross.Normalize();
cross = cross.Cross(stdZ);
}
if (cross.IsEqual(stdOrg,FLT_EPSILON)) {
if (cross.IsEqual(stdOrg, FLT_EPSILON)) {
viewAxis = gp_Ax2(inputCenter,
gp_Dir(direction.x, direction.y, direction.z));
return viewAxis;
}
viewAxis = gp_Ax2(inputCenter,
gp_Dir(direction.x, direction.y, direction.z),
gp_Dir(cross.x, cross.y, cross.z));
@@ -904,7 +904,7 @@ gp_Ax2 TechDraw::getViewAxis(const Base::Vector3d origin,
{
// Base::Console().Message("GO::getViewAxis() - 2\n");
(void) flip;
gp_Pnt inputCenter(origin.x,origin.y,origin.z);
gp_Pnt inputCenter(origin.x, origin.y, origin.z);
gp_Ax2 viewAxis;
viewAxis = gp_Ax2(inputCenter,
gp_Dir(direction.x, direction.y, direction.z),
@@ -920,28 +920,28 @@ gp_Ax2 TechDraw::legacyViewAxis1(const Base::Vector3d origin,
{
// Base::Console().Message("GO::legacyViewAxis1()\n");
gp_Ax2 viewAxis;
gp_Pnt inputCenter(origin.x,origin.y,origin.z);
Base::Vector3d stdZ(0.0,0.0,1.0);
Base::Vector3d stdOrg(0.0,0.0,0.0);
Base::Vector3d flipDirection(direction.x,-direction.y,direction.z);
gp_Pnt inputCenter(origin.x, origin.y, origin.z);
Base::Vector3d stdZ(0.0, 0.0, 1.0);
Base::Vector3d stdOrg(0.0, 0.0, 0.0);
Base::Vector3d flipDirection(direction.x, -direction.y, direction.z);
if (!flip) {
flipDirection = Base::Vector3d(direction.x,direction.y,direction.z);
flipDirection = Base::Vector3d(direction.x, direction.y, direction.z);
}
Base::Vector3d cross = flipDirection;
// //special case
if (TechDraw::DrawUtil::checkParallel(flipDirection, stdZ)) {
cross = Base::Vector3d(1.0,0.0,0.0);
cross = Base::Vector3d(1.0, 0.0, 0.0);
} else {
cross.Normalize();
cross = cross.Cross(stdZ);
}
if (cross.IsEqual(stdOrg,FLT_EPSILON)) {
if (cross.IsEqual(stdOrg, FLT_EPSILON)) {
viewAxis = gp_Ax2(inputCenter,
gp_Dir(flipDirection.x, flipDirection.y, flipDirection.z));
return viewAxis;
}
viewAxis = gp_Ax2(inputCenter,
gp_Dir(flipDirection.x, flipDirection.y, flipDirection.z),
gp_Dir(cross.x, cross.y, cross.z));
@@ -961,9 +961,9 @@ gp_Pnt TechDraw::findCentroid(const TopoDS_Shape &shape,
const Base::Vector3d &direction)
{
// Base::Console().Message("GO::findCentroid() - 1\n");
Base::Vector3d origin(0.0,0.0,0.0);
gp_Ax2 viewAxis = getViewAxis(origin,direction);
return findCentroid(shape,viewAxis);
Base::Vector3d origin(0.0, 0.0, 0.0);
gp_Ax2 viewAxis = getViewAxis(origin, direction);
return findCentroid(shape, viewAxis);
}
//! Returns the centroid of shape, as viewed according to direction
@@ -971,8 +971,8 @@ gp_Pnt TechDraw::findCentroid(const TopoDS_Shape &shape,
const gp_Ax2 &viewAxis)
{
// Base::Console().Message("GO::findCentroid() - 2\n");
// Base::Vector3d origin(0.0,0.0,0.0);
// gp_Ax2 viewAxis = getViewAxis(origin,direction);
// Base::Vector3d origin(0.0, 0.0, 0.0);
// gp_Ax2 viewAxis = getViewAxis(origin, direction);
gp_Trsf tempTransform;
tempTransform.SetTransformation(viewAxis);
@@ -999,8 +999,8 @@ Base::Vector3d TechDraw::findCentroidVec(const TopoDS_Shape &shape,
const Base::Vector3d &direction)
{
// Base::Console().Message("GO::findCentroidVec() - 1\n");
gp_Pnt p = TechDraw::findCentroid(shape,direction);
Base::Vector3d result(p.X(),p.Y(),p.Z());
gp_Pnt p = TechDraw::findCentroid(shape, direction);
Base::Vector3d result(p.X(), p.Y(), p.Z());
return result;
}
@@ -1008,8 +1008,8 @@ Base::Vector3d TechDraw::findCentroidVec(const TopoDS_Shape &shape,
const gp_Ax2 &cs)
{
// Base::Console().Message("GO::findCentroidVec() - 2\n");
gp_Pnt p = TechDraw::findCentroid(shape,cs);
Base::Vector3d result(p.X(),p.Y(),p.Z());
gp_Pnt p = TechDraw::findCentroid(shape, cs);
Base::Vector3d result(p.X(), p.Y(), p.Z());
return result;
}
@@ -1071,7 +1071,7 @@ TopoDS_Shape TechDraw::rotateShape(const TopoDS_Shape &input,
try {
gp_Trsf tempTransform;
tempTransform.SetRotation(rotAxis,rotation);
tempTransform.SetRotation(rotAxis, rotation);
BRepBuilderAPI_Transform mkTrf(input, tempTransform);
transShape = mkTrf.Shape();
}
@@ -1089,7 +1089,7 @@ TopoDS_Shape TechDraw::scaleShape(const TopoDS_Shape &input,
TopoDS_Shape transShape;
try {
gp_Trsf scaleTransform;
scaleTransform.SetScale(gp_Pnt(0,0,0), scale);
scaleTransform.SetScale(gp_Pnt(0, 0,0), scale);
BRepBuilderAPI_Transform mkTrf(input, scaleTransform);
transShape = mkTrf.Shape();
@@ -1108,7 +1108,7 @@ TopoDS_Shape TechDraw::moveShape(const TopoDS_Shape &input,
TopoDS_Shape transShape;
try {
gp_Trsf xlate;
xlate.SetTranslation(gp_Vec(motion.x,motion.y,motion.z));
xlate.SetTranslation(gp_Vec(motion.x, motion.y, motion.z));
BRepBuilderAPI_Transform mkTrf(input, xlate);
transShape = mkTrf.Shape();

View File

@@ -20,8 +20,8 @@
* *
***************************************************************************/
#ifndef _TECHDRAW_GEOMETRYOBJECT_H
#define _TECHDRAW_GEOMETRYOBJECT_H
#ifndef TECHDRAW_GEOMETRYOBJECT_H
#define TECHDRAW_GEOMETRYOBJECT_H
#include <Mod/TechDraw/TechDrawGlobal.h>
@@ -62,7 +62,7 @@ TopoDS_Shape TechDrawExport mirrorShapeVec(const TopoDS_Shape &input,
double scale = 1.0);
TopoDS_Shape TechDrawExport mirrorShape(const TopoDS_Shape &input,
const gp_Pnt& inputCenter = gp_Pnt(0.0,0.0,0.0),
const gp_Pnt& inputCenter = gp_Pnt(0.0, 0.0, 0.0),
double scale = 1.0);
TopoDS_Shape TechDrawExport scaleShape(const TopoDS_Shape &input,
@@ -111,7 +111,7 @@ public:
const BaseGeomPtrVector & getEdgeGeometry() const { return edgeGeom; }
const BaseGeomPtrVector getVisibleFaceEdges(bool smooth, bool seam) const;
const std::vector<FacePtr> & getFaceGeometry() const { return faceGeom; }
void setVertexGeometry(std::vector<VertexPtr> newVerts) {vertexGeom = newVerts; }
void setEdgeGeometry(BaseGeomPtrVector newGeoms) {edgeGeom = newGeoms; }

View File

@@ -48,29 +48,29 @@ using namespace TechDraw;
double LineSet::getMinX()
{
double xMin,yMin,zMin,xMax,yMax,zMax;
m_box.Get(xMin,yMin,zMin,xMax,yMax,zMax);
double xMin, yMin, zMin, xMax, yMax, zMax;
m_box.Get(xMin, yMin, zMin, xMax, yMax, zMax);
return xMin;
}
double LineSet::getMinY()
{
double xMin,yMin,zMin,xMax,yMax,zMax;
m_box.Get(xMin,yMin,zMin,xMax,yMax,zMax);
double xMin, yMin, zMin, xMax, yMax, zMax;
m_box.Get(xMin, yMin, zMin, xMax, yMax, zMax);
return yMin;
}
double LineSet::getMaxX()
{
double xMin,yMin,zMin,xMax,yMax,zMax;
m_box.Get(xMin,yMin,zMin,xMax,yMax,zMax);
double xMin, yMin, zMin, xMax, yMax, zMax;
m_box.Get(xMin, yMin, zMin, xMax, yMax, zMax);
return xMax;
}
double LineSet::getMaxY()
{
double xMin,yMin,zMin,xMax,yMax,zMax;
m_box.Get(xMin,yMin,zMin,xMax,yMax,zMax);
double xMin, yMin, zMin, xMax, yMax, zMax;
m_box.Get(xMin, yMin, zMin, xMax, yMax, zMax);
return yMax;
}
@@ -84,18 +84,18 @@ bool LineSet::isDashed()
Base::Vector3d LineSet::calcApparentStart(TechDraw::BaseGeomPtr g)
{
Base::Vector3d result;
Base::Vector3d start(g->getStartPoint().x,g->getStartPoint().y,0.0);
Base::Vector3d start(g->getStartPoint().x, g->getStartPoint().y, 0.0);
double angle = getPATLineSpec().getAngle();
if (angle == 0.0) { //horizontal
result = Base::Vector3d(getMinX(),start.y,0.0);
result = Base::Vector3d(getMinX(), start.y, 0.0);
} else if ((angle == 90.0) ||
(angle == -90.0)) { //vertical
result = Base::Vector3d(start.x,getMinY(),0.0);
result = Base::Vector3d(start.x, getMinY(), 0.0);
} else {
double slope = getPATLineSpec().getSlope();
double y = getMinY();
double x = ((y - start.y) / slope) + start.x;
result = Base::Vector3d(x,y,0);
result = Base::Vector3d(x, y,0);
}
return result;
}
@@ -118,16 +118,16 @@ Base::Vector3d LineSet::getUnitOrtho()
{
Base::Vector3d result;
Base::Vector3d unit = getUnitDir();
Base::Vector3d X(1.0,0.0,0.0);
Base::Vector3d Y(0.0,1.0,0.0);
if (unit.IsEqual(X,0.000001)) {
Base::Vector3d X(1.0, 0.0, 0.0);
Base::Vector3d Y(0.0, 1.0, 0.0);
if (unit.IsEqual(X, 0.000001)) {
result = Y;
} else if (unit.IsEqual(Y,0.000001)) {
} else if (unit.IsEqual(Y, 0.000001)) {
result = X;
} else {
double unitX = unit.x;
double unitY = unit.y;
result = Base::Vector3d(unitY,-unitX, 0.0); //perpendicular
result = Base::Vector3d(unitY, -unitX, 0.0); //perpendicular
}
result.Normalize(); //probably redundant
return result;
@@ -140,14 +140,14 @@ Base::Vector3d LineSet::findAtomStart()
Base::Vector3d origin = getOrigin();
double angle = getAngle();
if (angle == 0.0) {
result = Base::Vector3d(getMinX(),origin.y,0.0);
result = Base::Vector3d(getMinX(), origin.y, 0.0);
} else if ( (angle == 90.0) ||
(angle == -90.0) ) {
result = Base::Vector3d(origin.x,getMinY(),0.0);
result = Base::Vector3d(origin.x, getMinY(), 0.0);
} else {
double minY = getMinY();
double x = origin.x - (origin.y - minY)/getSlope();
result = Base::Vector3d(x,minY,0.0);
result = Base::Vector3d(x, minY, 0.0);
}
return result;
}
@@ -160,7 +160,7 @@ Base::Vector3d LineSet::getPatternStartPoint(TechDraw::BaseGeomPtr g, double &of
double angle = getAngle();
double patternLength = scale * getPatternLength();
Base::Vector3d lineOrigin;
double distX,distY;
double distX, distY;
int overlayIndex = 0;
//interval & offset are not patternscaled
@@ -168,7 +168,7 @@ Base::Vector3d LineSet::getPatternStartPoint(TechDraw::BaseGeomPtr g, double &of
if (angle == 0.0) { //odd case - horizontal line
distY = (thisStart.y - atomStart.y); //this is patternscaled
overlayIndex = (int) round(distY/(scale * getIntervalY())); //this is +/-
lineOrigin = getOrigin() + distY * Base::Vector3d(0.0,1.0,0.0); //move u/d
lineOrigin = getOrigin() + distY * Base::Vector3d(0.0, 1.0, 0.0); //move u/d
} else {
distX = (thisStart.x - atomStart.x); //this is patternscaled
overlayIndex = (int) round(distX/(scale * getIntervalX()));
@@ -197,7 +197,7 @@ Base::Vector3d LineSet::getPatternStartPoint(TechDraw::BaseGeomPtr g, double &of
double patsEndOrg = lenEndOrg/patternLength;
if (lenStartOrg < lenEndOrg) { //origin is before start
double c = ceil(patsStartOrg);
if (c <= patsEndOrg) { //c is an integer pattern count in [patsStartOrg,patsEndOrg]
if (c <= patsEndOrg) { //c is an integer pattern count in [patsStartOrg, patsEndOrg]
result = lineOrigin + c*patternLength*getUnitDir();
offset = 0.0;
} else {
@@ -208,7 +208,7 @@ Base::Vector3d LineSet::getPatternStartPoint(TechDraw::BaseGeomPtr g, double &of
}
} else if (lenStartOrg > lenEndOrg) { //origin is after end
double c = ceil(patsEndOrg);
if (c <= patsStartOrg) { //c is an integer pattern count in [patsStartOrg,patsEndOrg]
if (c <= patsStartOrg) { //c is an integer pattern count in [patsStartOrg, patsEndOrg]
result = lineOrigin - c*patternLength*getUnitDir();
offset = 0.0;
} else {
@@ -243,7 +243,7 @@ PATLineSpec::~PATLineSpec()
void PATLineSpec::init()
{
m_angle = 0.0;
m_origin = Base::Vector3d(0.0,0.0,0.0);
m_origin = Base::Vector3d(0.0, 0.0, 0.0);
m_interval = 1.0;
m_offset = 0.0;
}
@@ -252,11 +252,11 @@ void PATLineSpec::load(std::string& lineSpec)
{
std::vector<double> values = split(lineSpec);
if (values.size() < 5) {
Base::Console().Message( "PATLineSpec::load(%s) invalid entry in pattern\n",lineSpec.c_str() );
Base::Console().Message( "PATLineSpec::load(%s) invalid entry in pattern\n", lineSpec.c_str() );
return;
}
m_angle = values[0];
m_origin = Base::Vector3d(values[1],values[2],0.0);
m_origin = Base::Vector3d(values[1], values[2], 0.0);
m_offset = values[3];
m_interval = values[4];
if (values.size() > 5) {
@@ -272,13 +272,13 @@ std::vector<double> PATLineSpec::split(std::string line)
std::stringstream lineStream(line);
std::string cell;
while(std::getline(lineStream,cell, ','))
while(std::getline(lineStream, cell, ','))
{
try {
result.push_back(std::stod(cell));
}
catch (const std::invalid_argument& ia) {
Base::Console().Warning("Invalid number in cell: %s (%s) \n",cell.c_str(),ia.what());
Base::Console().Warning("Invalid number in cell: %s (%s) \n", cell.c_str(), ia.what());
result.push_back(0.0);
}
}
@@ -287,17 +287,17 @@ std::vector<double> PATLineSpec::split(std::string line)
void PATLineSpec::dump(const char* title)
{
Base::Console().Message( "DUMP: %s\n",title);
Base::Console().Message( "DUMP: %s\n", title);
Base::Console().Message( "Angle: %.3f\n", m_angle);
Base::Console().Message( "Origin: %s\n",DrawUtil::formatVector(m_origin).c_str());
Base::Console().Message( "Offset: %.3f\n",m_offset);
Base::Console().Message( "Interval: %.3f\n",m_interval);
Base::Console().Message( "Origin: %s\n", DrawUtil::formatVector(m_origin).c_str());
Base::Console().Message( "Offset: %.3f\n", m_offset);
Base::Console().Message( "Interval: %.3f\n", m_interval);
// std::stringstream ss;
// for (auto& d: m_dashParms) {
// ss << d << ", ";
// }
// ss << "end";
// Base::Console().Message( "DashSpec: %s\n",ss.str().c_str());
// Base::Console().Message( "DashSpec: %s\n", ss.str().c_str());
m_dashParms.dump("dashspec");
}
@@ -320,7 +320,7 @@ std::vector<PATLineSpec> PATLineSpec::getSpecsForPattern(std::string& parmFile,
lineSpecs = loadPatternDef(inFile);
} else {
//this message can come up when changing PAT file or pattern name
Base::Console().Log( "Could not find pattern: %s\n",parmName.c_str() );
Base::Console().Log( "Could not find pattern: %s\n", parmName.c_str() );
return result;
}
@@ -338,8 +338,8 @@ bool PATLineSpec::findPatternStart(std::ifstream& inFile, std::string& parmName
bool result = false;
while ( inFile.good() ){
std::string line;
std::getline(inFile,line);
std::string nameTag = line.substr(0,1);
std::getline(inFile, line);
std::string nameTag = line.substr(0, 1);
std::string patternName;
std::size_t commaPos;
if ((nameTag == ";") ||
@@ -349,7 +349,7 @@ bool PATLineSpec::findPatternStart(std::ifstream& inFile, std::string& parmName
} else if (nameTag == "*") {
commaPos = line.find(',',1);
if (commaPos != std::string::npos) {
patternName = line.substr(1,commaPos-1);
patternName = line.substr(1, commaPos-1);
} else {
patternName = line.substr(1);
}
@@ -369,8 +369,8 @@ std::vector<std::string> PATLineSpec::loadPatternDef(std::ifstream& inFile)
std::vector<std::string> result;
while ( inFile.good() ){
std::string line;
std::getline(inFile,line);
std::string nameTag = line.substr(0,1);
std::getline(inFile, line);
std::string nameTag = line.substr(0, 1);
if ((nameTag == ";") ||
(nameTag == " ") ||
(line.empty()) ) { //is cr/lf empty?
@@ -397,14 +397,14 @@ std::vector<std::string> PATLineSpec::getPatternList(std::string& parmFile)
while ( inFile.good() ){
std::string line;
std::getline(inFile,line);
std::string nameTag = line.substr(0,1); //dupl code here
std::getline(inFile, line);
std::string nameTag = line.substr(0, 1); //dupl code here
std::size_t commaPos;
if (nameTag == "*") { //found a pattern
commaPos = line.find(',',1);
std::string patternName;
if (commaPos != std::string::npos) {
patternName = line.substr(1,commaPos-1);
patternName = line.substr(1, commaPos-1);
} else {
patternName = line.substr(1);
}
@@ -475,7 +475,7 @@ double DashSpec::length()
DashSpec DashSpec::reversed()
{
std::vector<double> p = get();
std::reverse(p.begin(),p.end());
std::reverse(p.begin(), p.end());
DashSpec result(p);
return result;
}
@@ -487,7 +487,7 @@ void DashSpec::dump(const char* title)
for (auto& p: m_parms) {
ss << p << ", ";
}
Base::Console().Message("DUMP - DashSpec - %s\n",ss.str().c_str());
Base::Console().Message("DUMP - DashSpec - %s\n", ss.str().c_str());
}

View File

@@ -22,8 +22,8 @@
//! HatchLine - Classes related to processing PAT files
#ifndef _TechDraw_HATCHLINE_H_
#define _TechDraw_HATCHLINE_H_
#ifndef TechDraw_HATCHLINE_H_
#define TechDraw_HATCHLINE_H_
#include <Mod/TechDraw/TechDrawGlobal.h>
@@ -53,7 +53,7 @@ class TechDrawExport DashSpec
public:
DashSpec() {}
explicit DashSpec(std::vector<double> p) { m_parms = p; }
~DashSpec() {}
~DashSpec() = default;
double get(int i) {return m_parms.at(i); }
std::vector<double> get() {return m_parms;}
@@ -112,7 +112,7 @@ class TechDrawExport LineSet
{
public:
LineSet() {}
~LineSet() {}
~LineSet() = default;
void setPATLineSpec(const PATLineSpec& s) { m_hatchLine = s; }
void setEdges(std::vector<TopoDS_Edge> e) {m_edges = e;}

View File

@@ -72,7 +72,7 @@ LandmarkDimension::LandmarkDimension()
{
static const char *group = "Landmark";
//this leaves a blank entry in position 1.
ADD_PROPERTY_TYPE(ReferenceTags,("") , group, App::Prop_Output,"Tags of Dimension Endpoints");
ADD_PROPERTY_TYPE(ReferenceTags, ("") , group, App::Prop_Output, "Tags of Dimension Endpoints");
std::vector<std::string> noTags;
ReferenceTags.setValues(noTags);
}
@@ -132,7 +132,7 @@ App::DocumentObjectExecReturn *LandmarkDimension::execute()
std::string tag = dvp->addReferenceVertex(loc2d);
reprs.push_back(tag);
}
ReferenceTags.setValues(reprs);
ReferenceTags.setValues(reprs);
} else {
//update dvp referenceverts locations
int index = 0;
@@ -146,9 +146,9 @@ App::DocumentObjectExecReturn *LandmarkDimension::execute()
}
m_linearPoints.first = points.front();
m_linearPoints.second = points.back();
//m_anglePoints.first = //not implemented yet
App::DocumentObjectExecReturn* dvdResult = DrawViewDimension::execute();
// dvp->resetReferenceVerts();
@@ -161,7 +161,7 @@ App::DocumentObjectExecReturn *LandmarkDimension::execute()
Base::Vector3d LandmarkDimension::projectPoint(const Base::Vector3d& pt, DrawViewPart* dvp) const
{
Base::Vector3d stdOrg(0.0,0.0,0.0);
Base::Vector3d stdOrg(0.0, 0.0, 0.0);
gp_Ax2 viewAxis = dvp->getProjectionCS(stdOrg);
Base::Vector3d alignedPt = pt - dvp->getOriginalCentroid();
gp_Pnt gPt(alignedPt.x, alignedPt.y, alignedPt.z);
@@ -169,7 +169,7 @@ Base::Vector3d LandmarkDimension::projectPoint(const Base::Vector3d& pt, DrawVie
HLRAlgo_Projector projector( viewAxis );
gp_Pnt2d prjPnt;
projector.Project(gPt, prjPnt);
Base::Vector3d result(prjPnt.X(),prjPnt.Y(), 0.0);
Base::Vector3d result(prjPnt.X(), prjPnt.Y(), 0.0);
result = DrawUtil::invertY(result);
return result;
}
@@ -207,7 +207,7 @@ bool LandmarkDimension::checkReferences2D() const
pointPair LandmarkDimension::getPointsTwoVerts()
{
// Base::Console().Message("LD::getPointsTwoVerts() - %s\n",getNameInDocument());
// Base::Console().Message("LD::getPointsTwoVerts() - %s\n", getNameInDocument());
pointPair result;
TechDraw::DrawViewPart* dvp = getViewPart();
@@ -252,7 +252,7 @@ void LandmarkDimension::onDocumentRestored()
std::string tag = dvp->addReferenceVertex(loc2d);
tags.push_back(tag);
}
ReferenceTags.setValues(tags);
ReferenceTags.setValues(tags);
m_linearPoints.first = points.front();
m_linearPoints.second = points.back();
@@ -262,7 +262,7 @@ void LandmarkDimension::onDocumentRestored()
void LandmarkDimension::unsetupObject()
{
// bool isRemoving = testStatus(App::ObjectStatus::Remove);
// Base::Console().Message("LD::unsetupObject - isRemove: %d status: %X\n",
// isRemoving, getStatus());
@@ -282,7 +282,7 @@ void LandmarkDimension::unsetupObject()
//{
// if (PythonObject.is(Py::_None())) {
// // ref counter is set to 1
// PythonObject = Py::Object(new LandmarkDimensionPy(this),true);
// PythonObject = Py::Object(new LandmarkDimensionPy(this), true);
// }
// return Py::new_reference_to(PythonObject);
//}

View File

@@ -20,8 +20,8 @@
* *
***************************************************************************/
#ifndef _TechDraw_LandmarkDimension_h_
#define _TechDraw_LandmarkDimension_h_
#ifndef TechDraw_LandmarkDimension_h_
#define TechDraw_LandmarkDimension_h_
#include <Mod/TechDraw/TechDrawGlobal.h>
@@ -51,7 +51,7 @@ public:
~LandmarkDimension() override;
App::PropertyStringList ReferenceTags; //tags of 2d vertices in DVP
App::DocumentObjectExecReturn *execute() override;
short mustExecute() const override;
void unsetupObject() override;

View File

@@ -95,12 +95,12 @@ void LineGroup::setWeight(std::string s, double weight)
void LineGroup::dump(const char* title)
{
Base::Console().Message( "DUMP: %s\n",title);
Base::Console().Message( "DUMP: %s\n", title);
Base::Console().Message( "Name: %s\n", m_name.c_str());
Base::Console().Message( "Thin: %.3f\n", m_thin);
Base::Console().Message( "Graphic: %.3f\n",m_graphic);
Base::Console().Message( "Thick: %.3f\n",m_thick);
Base::Console().Message( "Extra: %.3f\n",m_extra);
Base::Console().Message( "Graphic: %.3f\n", m_graphic);
Base::Console().Message( "Thick: %.3f\n", m_thick);
Base::Console().Message( "Extra: %.3f\n", m_extra);
}
//static support function: split comma separated string of values into vector of numbers
@@ -111,7 +111,7 @@ std::vector<double> LineGroup::split(std::string line)
std::string cell;
bool nameCell = true;
while(std::getline(lineStream,cell, ','))
while(std::getline(lineStream, cell, ','))
{
if (nameCell) {
nameCell = false;
@@ -121,7 +121,7 @@ std::vector<double> LineGroup::split(std::string line)
result.push_back(std::stod(cell));
}
catch (const std::invalid_argument& ia) {
Base::Console().Warning("Invalid number in cell: %s (%s) \n",cell.c_str(),ia.what());
Base::Console().Warning("Invalid number in cell: %s (%s) \n", cell.c_str(), ia.what());
result.push_back(0.0);
}
}
@@ -135,7 +135,7 @@ std::string LineGroup::getRecordFromFile(std::string parmFile, int groupNumber)
Base::FileInfo fi(parmFile);
Base::ifstream inFile(fi, std::ifstream::in);
if(!inFile.is_open()) {
Base::Console().Message( "Cannot open LineGroup file: %s\n",parmFile.c_str());
Base::Console().Message( "Cannot open LineGroup file: %s\n", parmFile.c_str());
return record;
}
// parse file to get the groupNumber'th line
@@ -172,17 +172,17 @@ LineGroup* LineGroup::lineGroupFactory(int groupNumber)
if (values.size() < 4) {
Base::Console().Error( "LineGroup::invalid entry in %s\n", lgFileName.c_str() );
} else {
lg->setWeight("Thin",values[0]);
lg->setWeight("Graphic",values[1]);
lg->setWeight("Thick",values[2]);
lg->setWeight("Extra",values[3]);
lg->setWeight("Thin", values[0]);
lg->setWeight("Graphic", values[1]);
lg->setWeight("Thick", values[2]);
lg->setWeight("Extra", values[3]);
}
return lg;
}
/**
* @brief Returns the default line width given a weight name and group number.
*
*
* @param weightName can be "Thick", "Thin", "Graphic" or "Extra"
* @param lineGroupNumber if -1 will then use groupNumber in preferences. Default value is -1.
* @return the default line width.

View File

@@ -22,8 +22,8 @@
//! LineGroup - Classes related to processing LineGroup definition CSV files
#ifndef _TechDraw_LINEGROUP_H_
#define _TechDraw_LINEGROUP_H_
#ifndef TechDraw_LINEGROUP_H_
#define TechDraw_LINEGROUP_H_
#include <Mod/TechDraw/TechDrawGlobal.h>

View File

@@ -135,7 +135,7 @@ double Preferences::vertexScale()
//lightgray #D3D3D3
//lightgray #D3D3D3
bool Preferences::keepPagesUpToDate()
{
@@ -190,7 +190,7 @@ QString Preferences::defaultTemplate()
GetGroup("Mod/TechDraw/Files");
std::string defaultDir = App::Application::getResourceDir() + "Mod/TechDraw/Templates/";
std::string defaultFileName = defaultDir + "A4_LandscapeTD.svg";
std::string prefFileName = hGrp->GetASCII("TemplateFile",defaultFileName.c_str());
std::string prefFileName = hGrp->GetASCII("TemplateFile", defaultFileName.c_str());
if (prefFileName.empty()) {
prefFileName = defaultFileName;
}
@@ -229,7 +229,7 @@ std::string Preferences::lineGroupFile()
GetGroup("Preferences")->GetGroup("Mod/TechDraw/Files");
std::string defaultDir = App::Application::getResourceDir() + "Mod/TechDraw/LineGroup/";
std::string defaultFileName = defaultDir + "LineGroup.csv";
std::string lgFileName = hGrp->GetASCII("LineGroupFile",defaultFileName.c_str());
std::string lgFileName = hGrp->GetASCII("LineGroupFile", defaultFileName.c_str());
if (lgFileName.empty()) {
lgFileName = defaultFileName;
}
@@ -245,7 +245,7 @@ std::string Preferences::formatSpec()
{
Base::Reference<ParameterGrp> hGrp = App::GetApplication().GetUserParameter()
.GetGroup("BaseApp")->GetGroup("Preferences")->GetGroup("Mod/TechDraw/Dimensions");
return hGrp->GetASCII("formatSpec","%.2w");
return hGrp->GetASCII("formatSpec", "%.2w");
}
int Preferences::altDecimals()
@@ -271,7 +271,7 @@ std::string Preferences::svgFile()
std::string defaultDir = App::Application::getResourceDir() + "Mod/TechDraw/Patterns/";
std::string defaultFileName = defaultDir + "simple.svg";
std::string prefHatchFile = hGrp->GetASCII("FileHatch",defaultFileName.c_str());
std::string prefHatchFile = hGrp->GetASCII("FileHatch", defaultFileName.c_str());
if (prefHatchFile.empty()) {
prefHatchFile = defaultFileName;
}

View File

@@ -20,8 +20,8 @@
* *
***************************************************************************/
#ifndef _Preferences_h_
#define _Preferences_h_
#ifndef Preferences_h_
#define Preferences_h_
#include <App/Material.h>

View File

@@ -113,7 +113,7 @@ void ProjectionAlgos::execute()
Handle( HLRBRep_Algo ) brep_hlr = new HLRBRep_Algo;
brep_hlr->Add(Input);
gp_Ax2 transform(gp_Pnt(0,0,0),gp_Dir(Direction.x,Direction.y,Direction.z));
gp_Ax2 transform(gp_Pnt(0, 0,0), gp_Dir(Direction.x, Direction.y, Direction.z));
HLRAlgo_Projector projector( transform );
brep_hlr->Projector(projector);
brep_hlr->Update();
@@ -151,10 +151,10 @@ string ProjectionAlgos::getSVG(ExtractionType type,
H_style.insert({"stroke-width", "0.15"});
H_style.insert({"stroke-linecap", "butt"});
H_style.insert({"stroke-linejoin", "miter"});
H_style.insert({"stroke-dasharray", "0.2,0.1)"});
H_style.insert({"stroke-dasharray", "0.2, 0.1)"});
H_style.insert({"fill", "none"});
H_style.insert({"transform", "scale(1,-1)"});
BRepMesh_IncrementalMesh(H,tolerance);
H_style.insert({"transform", "scale(1, -1)"});
BRepMesh_IncrementalMesh(H, tolerance);
result << "<g";
for (const auto& attribute : H_style)
result << " " << attribute.first << "=\""
@@ -168,10 +168,10 @@ string ProjectionAlgos::getSVG(ExtractionType type,
H0_style.insert({"stroke-width", "0.15"});
H0_style.insert({"stroke-linecap", "butt"});
H0_style.insert({"stroke-linejoin", "miter"});
H0_style.insert({"stroke-dasharray", "0.02,0.1)"});
H0_style.insert({"stroke-dasharray", "0.02, 0.1)"});
H0_style.insert({"fill", "none"});
H0_style.insert({"transform", "scale(1,-1)"});
BRepMesh_IncrementalMesh(HO,tolerance);
H0_style.insert({"transform", "scale(1, -1)"});
BRepMesh_IncrementalMesh(HO, tolerance);
result << "<g";
for (const auto& attribute : H0_style)
result << " " << attribute.first << "=\""
@@ -186,8 +186,8 @@ string ProjectionAlgos::getSVG(ExtractionType type,
V0_style.insert({"stroke-linecap", "butt"});
V0_style.insert({"stroke-linejoin", "miter"});
V0_style.insert({"fill", "none"});
V0_style.insert({"transform", "scale(1,-1)"});
BRepMesh_IncrementalMesh(VO,tolerance);
V0_style.insert({"transform", "scale(1, -1)"});
BRepMesh_IncrementalMesh(VO, tolerance);
result << "<g";
for (const auto& attribute : V0_style)
result << " " << attribute.first << "=\""
@@ -202,8 +202,8 @@ string ProjectionAlgos::getSVG(ExtractionType type,
V_style.insert({"stroke-linecap", "butt"});
V_style.insert({"stroke-linejoin", "miter"});
V_style.insert({"fill", "none"});
V_style.insert({"transform", "scale(1,-1)"});
BRepMesh_IncrementalMesh(V,tolerance);
V_style.insert({"transform", "scale(1, -1)"});
BRepMesh_IncrementalMesh(V, tolerance);
result << "<g";
for (const auto& attribute : V_style)
result << " " << attribute.first << "=\""
@@ -218,8 +218,8 @@ string ProjectionAlgos::getSVG(ExtractionType type,
V1_style.insert({"stroke-linecap", "butt"});
V1_style.insert({"stroke-linejoin", "miter"});
V1_style.insert({"fill", "none"});
V1_style.insert({"transform", "scale(1,-1)"});
BRepMesh_IncrementalMesh(V1,tolerance);
V1_style.insert({"transform", "scale(1, -1)"});
BRepMesh_IncrementalMesh(V1, tolerance);
result << "<g";
for (const auto& attribute : V1_style)
result << " " << attribute.first << "=\""
@@ -233,10 +233,10 @@ string ProjectionAlgos::getSVG(ExtractionType type,
H1_style.insert({"stroke-width", "0.15"});
H1_style.insert({"stroke-linecap", "butt"});
H1_style.insert({"stroke-linejoin", "miter"});
H1_style.insert({"stroke-dasharray", "0.09,0.05)"});
H1_style.insert({"stroke-dasharray", "0.09, 0.05)"});
H1_style.insert({"fill", "none"});
H1_style.insert({"transform", "scale(1,-1)"});
BRepMesh_IncrementalMesh(H1,tolerance);
H1_style.insert({"transform", "scale(1, -1)"});
BRepMesh_IncrementalMesh(H1, tolerance);
result << "<g";
for (const auto& attribute : H1_style)
result << " " << attribute.first << "=\""
@@ -257,32 +257,32 @@ string ProjectionAlgos::getDXF(ExtractionType type, double /*scale*/, double tol
if (!H.IsNull() && (type & WithHidden)) {
//float width = 0.15f/scale;
BRepMesh_IncrementalMesh(H,tolerance);
BRepMesh_IncrementalMesh(H, tolerance);
result << output.exportEdges(H);
}
if (!HO.IsNull() && (type & WithHidden)) {
//float width = 0.15f/scale;
BRepMesh_IncrementalMesh(HO,tolerance);
BRepMesh_IncrementalMesh(HO, tolerance);
result << output.exportEdges(HO);
}
if (!VO.IsNull()) {
//float width = 0.35f/scale;
BRepMesh_IncrementalMesh(VO,tolerance);
BRepMesh_IncrementalMesh(VO, tolerance);
result << output.exportEdges(VO);
}
if (!V.IsNull()) {
//float width = 0.35f/scale;
BRepMesh_IncrementalMesh(V,tolerance);
BRepMesh_IncrementalMesh(V, tolerance);
result << output.exportEdges(V);
}
if (!V1.IsNull() && (type & WithSmooth)) {
//float width = 0.35f/scale;
BRepMesh_IncrementalMesh(V1,tolerance);
BRepMesh_IncrementalMesh(V1, tolerance);
result << output.exportEdges(V1);
}
if (!H1.IsNull() && (type & WithSmooth) && (type & WithHidden)) {
//float width = 0.15f/scale;
BRepMesh_IncrementalMesh(H1,tolerance);
BRepMesh_IncrementalMesh(H1, tolerance);
result << output.exportEdges(H1);
}

View File

@@ -23,11 +23,13 @@
//migrated to TechDraw workbench 2022-01-26 by Wandererfan
#ifndef _TechDrawProjectionAlgos_h_
#define _TechDrawProjectionAlgos_h_
#ifndef TechDrawProjectionAlgos_h_
#define TechDrawProjectionAlgos_h_
#include <Mod/TechDraw/TechDrawGlobal.h>
#include <map>
#include <TopoDS_Shape.hxx>
#include <Base/Vector3D.h>
#include <string>
@@ -43,7 +45,7 @@ class TechDrawExport ProjectionAlgos
{
public:
/// Constructor
ProjectionAlgos(const TopoDS_Shape &Input,const Base::Vector3d &Dir);
ProjectionAlgos(const TopoDS_Shape &Input, const Base::Vector3d &Dir);
virtual ~ProjectionAlgos();
void execute();
@@ -53,6 +55,7 @@ public:
WithHidden = 1,
WithSmooth = 2
};
using XmlAttributes = std::map<std::string,std::string>;
std::string getSVG(ExtractionType type, double tolerance=0.05,

View File

@@ -27,7 +27,7 @@
# include <cassert>
#endif
/// Here the FreeCAD includes sorted by Base,App,Gui......
/// Here the FreeCAD includes sorted by Base, App, Gui......
#include <Base/Exception.h>
#include <Base/Reader.h>
@@ -139,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();
@@ -167,7 +167,7 @@ void PropertyCenterLineList::Restore(Base::XMLReader &reader)
newG->Restore(reader);
if(reader.testStatus(Base::XMLReader::ReaderStatus::PartialRestoreInObject)) {
Base::Console().Error("CenterLine \"%s\" within a PropertyCenterLineList was subject to a partial restore.\n",reader.localName());
Base::Console().Error("CenterLine \"%s\" within a PropertyCenterLineList was subject to a partial restore.\n", reader.localName());
if(isOrderRelevant()) {
// Pushes the best try by the CenterLine class
values.push_back(newG);

View File

@@ -22,8 +22,8 @@
#ifndef TECHDRAW_PropertyCenterLineList_H
#define TECHDRAW_PropertyCenterLineList_H
#include <Mod/TechDraw/TechDrawGlobal.h>
#include <Mod/TechDraw/TechDrawGlobal.h>
#include <vector>
#include <App/Property.h>

View File

@@ -27,7 +27,7 @@
# include <cassert>
#endif
/// Here the FreeCAD includes sorted by Base,App,Gui......
/// Here the FreeCAD includes sorted by Base, App, Gui......
#include <Base/Exception.h>
#include <Base/Reader.h>
@@ -169,7 +169,7 @@ void PropertyCosmeticEdgeList::Restore(Base::XMLReader &reader)
newG->Restore(reader);
if(reader.testStatus(Base::XMLReader::ReaderStatus::PartialRestoreInObject)) {
Base::Console().Error("CosmeticEdge \"%s\" within a PropertyCosmeticEdgeList was subject to a partial restore.\n",reader.localName());
Base::Console().Error("CosmeticEdge \"%s\" within a PropertyCosmeticEdgeList was subject to a partial restore.\n", reader.localName());
if(isOrderRelevant()) {
// Pushes the best try by the CosmeticEdge class
values.push_back(newG);

View File

@@ -22,8 +22,8 @@
#ifndef TECHDRAW_PropertyCosmeticEdgeList_H
#define TECHDRAW_PropertyCosmeticEdgeList_H
#include <Mod/TechDraw/TechDrawGlobal.h>
#include <Mod/TechDraw/TechDrawGlobal.h>
#include <vector>
#include <App/Property.h>

View File

@@ -27,7 +27,7 @@
# include <cassert>
#endif
/// Here the FreeCAD includes sorted by Base,App,Gui......
/// Here the FreeCAD includes sorted by Base, App, Gui......
#include <Base/Exception.h>
#include <Base/Reader.h>
@@ -169,7 +169,7 @@ void PropertyCosmeticVertexList::Restore(Base::XMLReader &reader)
newG->Restore(reader);
if(reader.testStatus(Base::XMLReader::ReaderStatus::PartialRestoreInObject)) {
Base::Console().Error("CosmeticVertex \"%s\" within a PropertyCosmeticVertexList was subject to a partial restore.\n",reader.localName());
Base::Console().Error("CosmeticVertex \"%s\" within a PropertyCosmeticVertexList was subject to a partial restore.\n", reader.localName());
if(isOrderRelevant()) {
// Pushes the best try by the CosmeticVertex class
values.push_back(newG);

Some files were not shown because too many files have changed in this diff Show More