[TD]Python routines and extension for Cosmetic Edges
This commit is contained in:
@@ -41,6 +41,8 @@ class TopoDS_Edge;
|
||||
namespace TechDraw {
|
||||
class DrawViewPart;
|
||||
|
||||
|
||||
//general purpose line format specifier
|
||||
class TechDrawExport LineFormat
|
||||
{
|
||||
public:
|
||||
@@ -64,6 +66,7 @@ public:
|
||||
std::string toString() const;
|
||||
};
|
||||
|
||||
//********** Cosmetic Vertex ***************************************************
|
||||
class TechDrawExport CosmeticVertex: public Base::Persistence, public TechDraw::Vertex
|
||||
{
|
||||
TYPESYSTEM_HEADER();
|
||||
@@ -110,6 +113,9 @@ protected:
|
||||
|
||||
};
|
||||
|
||||
//********** CosmeticEdge ******************************************************
|
||||
|
||||
//?? should this inherit BaseGeom or have a BaseGeom member?
|
||||
class TechDrawExport CosmeticEdge : public Base::Persistence, public TechDraw::BaseGeom
|
||||
{
|
||||
TYPESYSTEM_HEADER();
|
||||
@@ -125,7 +131,6 @@ public:
|
||||
TechDraw::BaseGeom* scaledGeometry(double scale);
|
||||
|
||||
virtual std::string toString(void) const;
|
||||
/* virtual bool fromCSV(std::string& lineSpec);*/
|
||||
void dump(const char* title);
|
||||
|
||||
// Persistence implementer ---------------------
|
||||
@@ -137,6 +142,8 @@ public:
|
||||
CosmeticEdge* copy(void) const;
|
||||
CosmeticEdge* clone(void) const;
|
||||
|
||||
//Base::Vector3d permaStart; //persistent unscaled start/end points in View coords
|
||||
//Base::Vector3d permaEnd;
|
||||
TechDraw::BaseGeom* m_geometry;
|
||||
LineFormat m_format;
|
||||
|
||||
@@ -151,6 +158,8 @@ protected:
|
||||
boost::uuids::uuid tag;
|
||||
};
|
||||
|
||||
//***** CenterLine *************************************************************
|
||||
|
||||
class TechDrawExport CenterLine: public Base::Persistence
|
||||
{
|
||||
TYPESYSTEM_HEADER();
|
||||
@@ -255,6 +264,9 @@ protected:
|
||||
|
||||
};
|
||||
|
||||
//********** GeomFormat ********************************************************
|
||||
|
||||
// format specifier for geometric edges (Edge5)
|
||||
class TechDrawExport GeomFormat: public Base::Persistence
|
||||
{
|
||||
TYPESYSTEM_HEADER();
|
||||
@@ -278,7 +290,8 @@ public:
|
||||
std::string toString(void) const;
|
||||
void dump(const char* title) const;
|
||||
|
||||
int m_geomIndex;
|
||||
//std::string linkTag;
|
||||
int m_geomIndex; //connection to edgeGeom
|
||||
LineFormat m_format;
|
||||
|
||||
//Uniqueness
|
||||
|
||||
@@ -171,6 +171,123 @@ bool CosmeticExtension::replaceCosmeticVertex(CosmeticVertex* newCV)
|
||||
return result;
|
||||
}
|
||||
|
||||
//********** Cosmetic Edge *****************************************************
|
||||
|
||||
//returns unique CE id
|
||||
//only adds ce to celist property. does not add to display geometry until dvp executes.
|
||||
std::string CosmeticExtension::addCosmeticEdge(Base::Vector3d start,
|
||||
Base::Vector3d end)
|
||||
{
|
||||
// Base::Console().Message("CEx::addCosmeticEdge(%s)\n",
|
||||
// DrawUtil::formatVector(pos).c_str());
|
||||
std::vector<CosmeticEdge*> edges = CosmeticEdges.getValues();
|
||||
TechDraw::CosmeticEdge* ce = new TechDraw::CosmeticEdge(start, end);
|
||||
edges.push_back(ce);
|
||||
CosmeticEdges.setValues(edges);
|
||||
std::string result = ce->getTagAsString();
|
||||
return result;
|
||||
}
|
||||
|
||||
std::string CosmeticExtension::addCosmeticEdge(TechDraw::BaseGeom* bg)
|
||||
{
|
||||
// Base::Console().Message("CEx::addCosmeticEdge(bg: %X)\n", bg);
|
||||
std::vector<CosmeticEdge*> edges = CosmeticEdges.getValues();
|
||||
TechDraw::CosmeticEdge* ce = new TechDraw::CosmeticEdge(bg);
|
||||
edges.push_back(ce);
|
||||
CosmeticEdges.setValues(edges);
|
||||
std::string result = ce->getTagAsString();
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
//get CE by unique id
|
||||
TechDraw::CosmeticEdge* CosmeticExtension::getCosmeticEdge(std::string tagString) const
|
||||
{
|
||||
// Base::Console().Message("CEx::getCosmeticEdge(%s)\n", tagString.c_str());
|
||||
CosmeticEdge* result = nullptr;
|
||||
const std::vector<TechDraw::CosmeticEdge*> edges = CosmeticEdges.getValues();
|
||||
for (auto& ce: edges) {
|
||||
std::string ceTag = ce->getTagAsString();
|
||||
if (ceTag == tagString) {
|
||||
result = ce;
|
||||
break;
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
// find the cosmetic edge corresponding to selection name (Edge5)
|
||||
// used when selecting
|
||||
TechDraw::CosmeticEdge* CosmeticExtension::getCosmeticEdgeBySelection(std::string name) const
|
||||
{
|
||||
// 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);
|
||||
if (dvp == nullptr) {
|
||||
return result;
|
||||
}
|
||||
int idx = DrawUtil::getIndexFromName(name);
|
||||
TechDraw::BaseGeom* base = dvp->getGeomByIndex(idx);
|
||||
if (base == nullptr) {
|
||||
return result;
|
||||
}
|
||||
if (!base->getCosmeticTag().empty()) {
|
||||
result = getCosmeticEdge(base->getCosmeticTag());
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
//overload for index only
|
||||
TechDraw::CosmeticEdge* CosmeticExtension::getCosmeticEdgeBySelection(int i) const
|
||||
{
|
||||
// Base::Console().Message("CEx::getCEBySelection(%d)\n", i);
|
||||
std::stringstream ss;
|
||||
ss << "Edge" << i;
|
||||
std::string eName = ss.str();
|
||||
return getCosmeticEdgeBySelection(eName);
|
||||
}
|
||||
|
||||
void CosmeticExtension::removeCosmeticEdge(std::string delTag)
|
||||
{
|
||||
// Base::Console().Message("DVP::removeCE(%s)\n", delTag.c_str());
|
||||
std::vector<CosmeticEdge*> cEdges = CosmeticEdges.getValues();
|
||||
std::vector<CosmeticEdge*> newEdges;
|
||||
for (auto& ce: cEdges) {
|
||||
if (ce->getTagAsString() != delTag) {
|
||||
newEdges.push_back(ce);
|
||||
}
|
||||
}
|
||||
CosmeticEdges.setValues(newEdges);
|
||||
}
|
||||
|
||||
void CosmeticExtension::removeCosmeticEdge(std::vector<std::string> delTags)
|
||||
{
|
||||
for (auto& t: delTags) {
|
||||
removeCosmeticEdge(t);
|
||||
}
|
||||
}
|
||||
|
||||
bool CosmeticExtension::replaceCosmeticEdge(CosmeticEdge* newCE)
|
||||
{
|
||||
// Base::Console().Message("DVP::replaceCE(%s)\n", newCE->getTagAsString().c_str());
|
||||
bool result = false;
|
||||
std::vector<CosmeticEdge*> cEdges = CosmeticEdges.getValues();
|
||||
std::vector<CosmeticEdge*> newEdges;
|
||||
std::string tag = newCE->getTagAsString();
|
||||
for (auto& ce: cEdges) {
|
||||
if (ce->getTagAsString() == tag) {
|
||||
newEdges.push_back(newCE);
|
||||
result = true;
|
||||
} else {
|
||||
newEdges.push_back(ce);
|
||||
}
|
||||
}
|
||||
CosmeticEdges.setValues(newEdges);
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
//================================================================================
|
||||
PyObject* CosmeticExtension::getExtensionPyObject(void) {
|
||||
if (ExtensionPythonObject.is(Py::_None())){
|
||||
|
||||
@@ -32,6 +32,7 @@
|
||||
#include <Base/Exception.h>
|
||||
|
||||
#include "PropertyCosmeticVertexList.h"
|
||||
#include "PropertyCosmeticEdgeList.h"
|
||||
|
||||
|
||||
namespace TechDraw {
|
||||
@@ -46,6 +47,7 @@ public:
|
||||
virtual ~CosmeticExtension();
|
||||
|
||||
TechDraw::PropertyCosmeticVertexList CosmeticVertexes;
|
||||
TechDraw::PropertyCosmeticEdgeList CosmeticEdges;
|
||||
|
||||
virtual std::string addCosmeticVertex(Base::Vector3d pos);
|
||||
virtual CosmeticVertex* getCosmeticVertexBySelection(std::string name) const;
|
||||
@@ -55,6 +57,16 @@ public:
|
||||
virtual void removeCosmeticVertex(std::string tag);
|
||||
virtual void removeCosmeticVertex(std::vector<std::string> delTags);
|
||||
|
||||
virtual std::string addCosmeticEdge(Base::Vector3d start, Base::Vector3d end);
|
||||
virtual std::string addCosmeticEdge(TechDraw::BaseGeom* bg);
|
||||
virtual CosmeticEdge* getCosmeticEdgeBySelection(std::string name) const;
|
||||
virtual CosmeticEdge* getCosmeticEdgeBySelection(int i) const;
|
||||
virtual CosmeticEdge* getCosmeticEdge(std::string id) const;
|
||||
virtual bool replaceCosmeticEdge(CosmeticEdge* newEdge);
|
||||
virtual void removeCosmeticEdge(std::string tag);
|
||||
virtual void removeCosmeticEdge(std::vector<std::string> delTags);
|
||||
|
||||
|
||||
PyObject* getExtensionPyObject(void);
|
||||
|
||||
protected:
|
||||
|
||||
@@ -1051,171 +1051,54 @@ void DrawViewPart::clearCosmeticEdges(void)
|
||||
CosmeticEdges.setValues(noEdges);
|
||||
}
|
||||
|
||||
// adds a cosmetic edge to CosmeticEdges property
|
||||
// this should probably return tag instead of index
|
||||
int DrawViewPart::addCosmeticEdge(Base::Vector3d p1, Base::Vector3d p2)
|
||||
{
|
||||
// Base::Console().Message("DVP::addCosmeticEdge(p1,p2)\n");
|
||||
TechDraw::CosmeticEdge* ce = new TechDraw::CosmeticEdge(p1, p2);
|
||||
std::vector<CosmeticEdge*> edges = CosmeticEdges.getValues();
|
||||
int newIdx = (int) (edges.size());
|
||||
edges.push_back(ce);
|
||||
CosmeticEdges.setValues(edges);
|
||||
recomputeFeature(); //execute needs to run to replace Geoms
|
||||
return newIdx;
|
||||
}
|
||||
|
||||
// adds a cosmetic edge to CosmeticEdges property
|
||||
// this should probably return tag instead of index
|
||||
int DrawViewPart::addCosmeticEdge(TopoDS_Edge e)
|
||||
{
|
||||
// Base::Console().Message("DVP::addCosmeticEdge(occ edge)\n");
|
||||
TechDraw::CosmeticEdge* ce = new TechDraw::CosmeticEdge(e);
|
||||
std::vector<CosmeticEdge*> edges = CosmeticEdges.getValues();
|
||||
int newIdx = (int) (edges.size());
|
||||
edges.push_back(ce);
|
||||
CosmeticEdges.setValues(edges);
|
||||
recomputeFeature(); //execute needs to run to replace Geoms
|
||||
return newIdx;
|
||||
}
|
||||
|
||||
// adds a cosmetic edge to CosmeticEdges property
|
||||
// this should probably return tag instead of index
|
||||
int DrawViewPart::addCosmeticEdge(CosmeticEdge* ce)
|
||||
{
|
||||
// Base::Console().Message("DVP::addCosmeticEdge(%X)\n", ce);
|
||||
std::vector<CosmeticEdge*> edges = CosmeticEdges.getValues();
|
||||
int newIdx = (int) (edges.size());
|
||||
edges.push_back(ce);
|
||||
CosmeticEdges.setValues(edges);
|
||||
recomputeFeature(); //execute needs to run to replace Geoms
|
||||
return newIdx;
|
||||
}
|
||||
|
||||
void DrawViewPart::removeCosmeticEdge(TechDraw::CosmeticEdge* ce)
|
||||
{
|
||||
// Base::Console().Message("DVP::removeCosmeticEdge(%X)\n", ce);
|
||||
if (ce != nullptr) {
|
||||
std::string ceTag = ce->getTagAsString();
|
||||
removeCosmeticEdge(ceTag);
|
||||
}
|
||||
}
|
||||
|
||||
void DrawViewPart::removeCosmeticEdge(int idx)
|
||||
{
|
||||
// Base::Console().Message("DVP::removeCosmeticEdge(%d) - deprecated. use by tag.\n", idx);
|
||||
std::vector<CosmeticEdge*> edges = CosmeticEdges.getValues();
|
||||
if (idx < (int) edges.size()) {
|
||||
edges.erase(edges.begin() + idx);
|
||||
CosmeticEdges.setValues(edges);
|
||||
recomputeFeature(); //execute needs to run to replace Geoms
|
||||
}
|
||||
}
|
||||
|
||||
void DrawViewPart::removeCosmeticEdge(std::string delTag)
|
||||
{
|
||||
// Base::Console().Message("DVP::removeCE(%s)\n", delTag.c_str());
|
||||
std::vector<CosmeticEdge*> cEdges = CosmeticEdges.getValues();
|
||||
std::vector<CosmeticEdge*> newEdges;
|
||||
for (auto& ce: cEdges) {
|
||||
if (ce->getTagAsString() != delTag) {
|
||||
newEdges.push_back(ce);
|
||||
}
|
||||
}
|
||||
CosmeticEdges.setValues(newEdges);
|
||||
}
|
||||
|
||||
void DrawViewPart::removeCosmeticEdge(std::vector<std::string> delTags)
|
||||
{
|
||||
std::vector<CosmeticEdge*> cEdges = CosmeticEdges.getValues();
|
||||
std::vector<CosmeticEdge*> newEdges;
|
||||
for (auto& ce: cEdges) {
|
||||
bool found = false;
|
||||
for (auto& dt: delTags) {
|
||||
if (ce->getTagAsString() == dt) {
|
||||
found = true; //this ce is in delete list
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!found) {
|
||||
newEdges.push_back(ce);
|
||||
}
|
||||
}
|
||||
CosmeticEdges.setValues(newEdges);
|
||||
}
|
||||
|
||||
TechDraw::CosmeticEdge* DrawViewPart::getCosmeticEdge(std::string tagString) const
|
||||
{
|
||||
// Base::Console().Message("DVP::getCosmeticEdge(%s)\n", tagString.c_str());
|
||||
TechDraw::CosmeticEdge* result = nullptr;
|
||||
const std::vector<TechDraw::CosmeticEdge*> cEdges = CosmeticEdges.getValues();
|
||||
for (auto& ce: cEdges) {
|
||||
if (ce->getTagAsString() == tagString) {
|
||||
result = ce;
|
||||
break;
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
TechDraw::CosmeticEdge* DrawViewPart::getCosmeticEdgeByIndex(int idx) const
|
||||
{
|
||||
// Base::Console().Message("DVP::getCosmeticEdgeByIndex(%d)\n",idx);
|
||||
CosmeticEdge* result = nullptr;
|
||||
const std::vector<TechDraw::CosmeticEdge*> edges = CosmeticEdges.getValues();
|
||||
if (idx < (int) edges.size()) {
|
||||
result = edges.at(idx);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
//find the cosmetic edge corresponding to geometry edge idx
|
||||
TechDraw::CosmeticEdge* DrawViewPart::getCosmeticEdgeByGeom(int idx) const
|
||||
{
|
||||
// Base::Console().Message("DVP::getCosmeticEdgeByGeom(%d)\n",idx);
|
||||
CosmeticEdge* result = nullptr;
|
||||
BaseGeom* geom = getGeomByIndex(idx);
|
||||
if (geom == nullptr) {
|
||||
return result;
|
||||
}
|
||||
if (!geom->getCosmeticTag().empty()) {
|
||||
result = getCosmeticEdge(geom->getCosmeticTag());
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
//find the index of a cosmetic edge
|
||||
int DrawViewPart::getCosmeticEdgeIndex(TechDraw::CosmeticEdge* ce) const
|
||||
{
|
||||
// Base::Console().Message("DVP::getCosmeticEdgeIndex(%X) - deprec?\n",ce);
|
||||
int result = -1;
|
||||
const std::vector<TechDraw::CosmeticEdge*> edges = CosmeticEdges.getValues();
|
||||
int i = 0;
|
||||
int stop = (int) edges.size();
|
||||
for (; i < stop; i++) {
|
||||
if (edges.at(i) == ce) {
|
||||
result = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
//add the cosmetic edges to geometryObject edges list
|
||||
//add the cosmetic edges to geometry edge list
|
||||
void DrawViewPart::addCosmeticEdgesToGeom(void)
|
||||
{
|
||||
const std::vector<TechDraw::CosmeticEdge*> edges = CosmeticEdges.getValues();
|
||||
for (auto& ce: edges) {
|
||||
// Base::Console().Message("CEx::addCosmeticEdgesToGeom()\n");
|
||||
const std::vector<TechDraw::CosmeticEdge*> cEdges = CosmeticEdges.getValues();
|
||||
for (auto& ce: cEdges) {
|
||||
TechDraw::BaseGeom* scaledGeom = ce->scaledGeometry(getScale());
|
||||
if (scaledGeom == nullptr) {
|
||||
Base::Console().Error("DVP::addCosmeticEdgesToGeom - scaledGeometry is null\n");
|
||||
continue;
|
||||
}
|
||||
// int idx =
|
||||
(void) geometryObject->addCosmeticEdge(scaledGeom, 1);
|
||||
// int iGE =
|
||||
geometryObject->addCosmeticEdge(scaledGeom,
|
||||
ce->getTagAsString());
|
||||
}
|
||||
}
|
||||
|
||||
int DrawViewPart::add1CEToGE(std::string tag)
|
||||
{
|
||||
// Base::Console().Message("CEx::add1CEToGE(%s) 2\n", tag.c_str());
|
||||
TechDraw::CosmeticEdge* ce = getCosmeticEdge(tag);
|
||||
if (ce == nullptr) {
|
||||
Base::Console().Message("CEx::add1CEToGE 2 - ce %s not found\n", tag.c_str());
|
||||
return -1;
|
||||
}
|
||||
TechDraw::BaseGeom* scaledGeom = ce->scaledGeometry(getScale());
|
||||
int iGE = geometryObject->addCosmeticEdge(scaledGeom,
|
||||
tag);
|
||||
|
||||
return iGE;
|
||||
}
|
||||
|
||||
//update Edge geometry with current CE's
|
||||
void DrawViewPart::refreshCEGeoms(void)
|
||||
{
|
||||
// Base::Console().Message("CEx::refreshCEGeoms()\n");
|
||||
|
||||
std::vector<TechDraw::BaseGeom *> gEdges = getEdgeGeometry();
|
||||
std::vector<TechDraw::BaseGeom *> newGEdges;
|
||||
for (auto& ge :gEdges) {
|
||||
if (ge->getTagAsString().empty()) { //keep only non-ce edges
|
||||
newGEdges.push_back(ge);
|
||||
}
|
||||
}
|
||||
getGeometryObject()->setEdgeGeometry(newGEdges);
|
||||
addCosmeticEdgesToGeom();
|
||||
}
|
||||
|
||||
|
||||
// CenterLines -----------------------------------------------------------------
|
||||
void DrawViewPart::clearCenterLines(void)
|
||||
{
|
||||
|
||||
@@ -111,8 +111,6 @@ public:
|
||||
App::PropertyBool IsoHidden;
|
||||
App::PropertyInteger IsoCount;
|
||||
|
||||
/* TechDraw::PropertyCosmeticVertexList CosmeticVertexes;*/
|
||||
TechDraw::PropertyCosmeticEdgeList CosmeticEdges;
|
||||
TechDraw::PropertyCenterLineList CenterLines;
|
||||
TechDraw::PropertyGeomFormatList GeomFormats;
|
||||
|
||||
@@ -180,19 +178,11 @@ public:
|
||||
void add1CosmeticVertexToGeom(int iCV);
|
||||
int add1CVToGV(std::string tag);
|
||||
|
||||
virtual int addCosmeticEdge(Base::Vector3d start, Base::Vector3d end);
|
||||
virtual int addCosmeticEdge(TopoDS_Edge e);
|
||||
virtual int addCosmeticEdge(TechDraw::CosmeticEdge*);
|
||||
virtual void removeCosmeticEdge(TechDraw::CosmeticEdge* ce);
|
||||
virtual void removeCosmeticEdge(int idx);
|
||||
virtual void removeCosmeticEdge(std::string delTag);
|
||||
virtual void removeCosmeticEdge(std::vector<std::string> delTags);
|
||||
TechDraw::CosmeticEdge* getCosmeticEdge(std::string tagString) const;
|
||||
TechDraw::CosmeticEdge* getCosmeticEdgeByIndex(int idx) const;
|
||||
TechDraw::CosmeticEdge* getCosmeticEdgeByGeom(int idx) const;
|
||||
int getCosmeticEdgeIndex(TechDraw::CosmeticEdge* ce) const;
|
||||
void clearCosmeticEdges(void);
|
||||
void clearCosmeticEdges(void);
|
||||
void refreshCEGeoms(void);
|
||||
void addCosmeticEdgesToGeom(void);
|
||||
void add1CosmeticEdgeToGeom(int iCE);
|
||||
int add1CEToGE(std::string tag);
|
||||
|
||||
virtual int addCenterLine(TechDraw::CenterLine*);
|
||||
virtual void removeCenterLine(TechDraw::CenterLine* cl);
|
||||
|
||||
@@ -73,19 +73,24 @@
|
||||
<UserDocu>makeCosmeticCircleArc(center, radius, start, end) - add a CosmeticEdge at center with radius radius(View coordinates) from start angle to end angle. Returns index of created edge.</UserDocu>
|
||||
</Documentation>
|
||||
</Methode>
|
||||
<Methode Name="getCosmeticEdgeByIndex">
|
||||
<Methode Name="getCosmeticEdge">
|
||||
<Documentation>
|
||||
<UserDocu>getCosmeticEdgeByIndex(idx) - returns CosmeticEdge[idx].</UserDocu>
|
||||
<UserDocu>ce = getCosmeticEdge(id) - returns CosmeticEdge with unique id.</UserDocu>
|
||||
</Documentation>
|
||||
</Methode>
|
||||
<Methode Name="getCosmeticEdgeByGeom">
|
||||
<Methode Name="getCosmeticEdgeBySelection">
|
||||
<Documentation>
|
||||
<UserDocu>getCosmeticEdgeByGeom(idx) - returns CosmeticEdge using geometry index.</UserDocu>
|
||||
<UserDocu>ce = getCosmeticEdgeBySelection(name) - returns CosmeticEdge by name (Edge25). Used in selections</UserDocu>
|
||||
</Documentation>
|
||||
</Methode>
|
||||
<Methode Name="replaceCosmeticEdge">
|
||||
<Documentation>
|
||||
<UserDocu>replaceCosmeticEdge(ce) - replaces CosmeticEdge ce in View. Returns True/False.</UserDocu>
|
||||
</Documentation>
|
||||
</Methode>
|
||||
<Methode Name="removeCosmeticEdge">
|
||||
<Documentation>
|
||||
<UserDocu>removeCosmeticEdge(idx) - remove CosmeticEdge[idx] from View. Returns None.</UserDocu>
|
||||
<UserDocu>removeCosmeticEdge(ce) - remove CosmeticEdge ce from View. Returns None.</UserDocu>
|
||||
</Documentation>
|
||||
</Methode>
|
||||
<Methode Name="makeCenterLine">
|
||||
|
||||
@@ -307,8 +307,8 @@ PyObject* DrawViewPartPy::makeCosmeticLine(PyObject *args)
|
||||
//points inverted in addCosmeticEdge(p1, p2)
|
||||
Base::Vector3d pnt1 = static_cast<Base::VectorPy*>(pPnt1)->value();
|
||||
Base::Vector3d pnt2 = static_cast<Base::VectorPy*>(pPnt2)->value();
|
||||
int idx = dvp->addCosmeticEdge(pnt1, pnt2);
|
||||
TechDraw::CosmeticEdge* ce = dvp->getCosmeticEdgeByIndex(idx);
|
||||
std::string newTag = dvp->addCosmeticEdge(pnt1, pnt2);
|
||||
TechDraw::CosmeticEdge* ce = dvp->getCosmeticEdge(newTag);
|
||||
if (ce != nullptr) {
|
||||
ce->m_format.m_style = style;
|
||||
ce->m_format.m_weight = weight;
|
||||
@@ -322,7 +322,8 @@ PyObject* DrawViewPartPy::makeCosmeticLine(PyObject *args)
|
||||
Base::Console().Message("%s\n",msg.c_str());
|
||||
throw Py::RuntimeError(msg);
|
||||
}
|
||||
return PyLong_FromLong(idx);
|
||||
PyObject* result = new CosmeticEdgePy(new CosmeticEdge(ce));
|
||||
return result;
|
||||
}
|
||||
|
||||
PyObject* DrawViewPartPy::makeCosmeticCircle(PyObject *args)
|
||||
@@ -355,8 +356,9 @@ PyObject* DrawViewPartPy::makeCosmeticCircle(PyObject *args)
|
||||
Handle(Geom_Circle) hCircle = new Geom_Circle (circle);
|
||||
BRepBuilderAPI_MakeEdge aMakeEdge(hCircle, angle1*(M_PI/180), angle2*(M_PI/180));
|
||||
TopoDS_Edge edge = aMakeEdge.Edge();
|
||||
int idx = dvp->addCosmeticEdge(edge);
|
||||
TechDraw::CosmeticEdge* ce = dvp->getCosmeticEdgeByIndex(idx);
|
||||
TechDraw::BaseGeom* bg = TechDraw::BaseGeom::baseFactory(edge);
|
||||
std::string tag = dvp->addCosmeticEdge(bg);
|
||||
TechDraw::CosmeticEdge* ce = dvp->getCosmeticEdge(tag);
|
||||
if (ce != nullptr) {
|
||||
ce->m_format.m_style = style;
|
||||
ce->m_format.m_weight = weight;
|
||||
@@ -370,7 +372,8 @@ PyObject* DrawViewPartPy::makeCosmeticCircle(PyObject *args)
|
||||
Base::Console().Message("%s\n",msg.c_str());
|
||||
throw Py::RuntimeError(msg);
|
||||
}
|
||||
return PyLong_FromLong(idx);
|
||||
PyObject* result = new CosmeticEdgePy(new CosmeticEdge(ce));
|
||||
return result;
|
||||
}
|
||||
|
||||
PyObject* DrawViewPartPy::makeCosmeticCircleArc(PyObject *args)
|
||||
@@ -406,8 +409,9 @@ PyObject* DrawViewPartPy::makeCosmeticCircleArc(PyObject *args)
|
||||
// Qt -y is up, OCC -y is down
|
||||
|
||||
TopoDS_Edge edge = aMakeEdge.Edge();
|
||||
int idx = dvp->addCosmeticEdge(edge);
|
||||
TechDraw::CosmeticEdge* ce = dvp->getCosmeticEdgeByIndex(idx);
|
||||
TechDraw::BaseGeom* bg = TechDraw::BaseGeom::baseFactory(edge);
|
||||
std::string tag = dvp->addCosmeticEdge(bg);
|
||||
TechDraw::CosmeticEdge* ce = dvp->getCosmeticEdge(tag);
|
||||
if (ce != nullptr) {
|
||||
ce->m_format.m_style = style;
|
||||
ce->m_format.m_weight = weight;
|
||||
@@ -421,102 +425,81 @@ PyObject* DrawViewPartPy::makeCosmeticCircleArc(PyObject *args)
|
||||
Base::Console().Message("%s\n",msg.c_str());
|
||||
throw Py::RuntimeError(msg);
|
||||
}
|
||||
return PyLong_FromLong(idx);
|
||||
|
||||
PyObject* result = new CosmeticEdgePy(new CosmeticEdge(ce));
|
||||
return result;
|
||||
}
|
||||
|
||||
//PyObject* DrawViewPartPy::getCosmeticVertexByIndex(PyObject *args)
|
||||
//{
|
||||
// PyObject* result = nullptr;
|
||||
// int idx = -1;
|
||||
// if (!PyArg_ParseTuple(args, "i", &idx)) {
|
||||
// throw Py::TypeError("expected (index)");
|
||||
// }
|
||||
// DrawViewPart* dvp = getDrawViewPartPtr();
|
||||
// TechDraw::CosmeticVertex* cv = dvp->getCosmeticVertexByIndex(idx);
|
||||
// if (cv != nullptr) {
|
||||
// result = new CosmeticVertexPy(new CosmeticVertex(cv));
|
||||
// } else {
|
||||
// result = Py_None;
|
||||
// }
|
||||
// return result;
|
||||
//}
|
||||
//********** Cosmetic Edge *****************************************************
|
||||
|
||||
|
||||
PyObject* DrawViewPartPy::getCosmeticEdgeByIndex(PyObject *args)
|
||||
PyObject* DrawViewPartPy::getCosmeticEdge(PyObject *args)
|
||||
{
|
||||
int idx = 0;
|
||||
char* tag;
|
||||
PyObject* result = Py_None;
|
||||
if (!PyArg_ParseTuple(args, "i", &idx)) {
|
||||
throw Py::TypeError("expected (index)");
|
||||
if (!PyArg_ParseTuple(args, "s", &tag)) {
|
||||
throw Py::TypeError("expected (tag)");
|
||||
}
|
||||
DrawViewPart* dvp = getDrawViewPartPtr();
|
||||
TechDraw::CosmeticEdge* ce = dvp->getCosmeticEdgeByIndex(idx);
|
||||
TechDraw::CosmeticEdge* ce = dvp->getCosmeticEdge(tag);
|
||||
if (ce != nullptr) {
|
||||
result = new CosmeticEdgePy(new CosmeticEdge(ce));
|
||||
} else {
|
||||
Base::Console().Error("DVPPI::getCosEdgebyIdx - edge %d not found\n", idx);
|
||||
Base::Console().Error("DVPPI::getCosmeticEdge - edge %s not found\n", tag);
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
PyObject* DrawViewPartPy::getCosmeticEdgeByGeom(PyObject *args)
|
||||
PyObject* DrawViewPartPy::getCosmeticEdgeBySelection(PyObject *args)
|
||||
{
|
||||
// Base::Console().Message("DVPPI::getCosmeticEdgeByGeom()\n");
|
||||
int idx = 0;
|
||||
// Base::Console().Message("DVPPI::getCosmeticEdgeBySelection()\n");
|
||||
char* tag;
|
||||
PyObject* result = Py_None;
|
||||
if (!PyArg_ParseTuple(args, "i", &idx)) {
|
||||
throw Py::TypeError("expected (index)");
|
||||
if (!PyArg_ParseTuple(args, "s", &tag)) {
|
||||
throw Py::TypeError("expected (tag)");
|
||||
}
|
||||
DrawViewPart* dvp = getDrawViewPartPtr();
|
||||
|
||||
TechDraw::BaseGeom* bg = dvp->getGeomByIndex(idx);
|
||||
if (bg == nullptr) {
|
||||
Base::Console().Error("DVPPI::getCEbyGeom - geom: %d not found\n",idx);
|
||||
return result;
|
||||
}
|
||||
int source = bg->source();
|
||||
int sourceIndex = bg->sourceIndex();
|
||||
if (source == 1) { //cosmetic edge
|
||||
TechDraw::CosmeticEdge* ce = dvp->getCosmeticEdgeByIndex(sourceIndex);
|
||||
if (ce != nullptr) {
|
||||
result = new CosmeticEdgePy(new CosmeticEdge(ce));
|
||||
} else {
|
||||
Base::Console().Error("DVPPI::getCosEdgebyGeom - edge %d not found\n", idx);
|
||||
}
|
||||
TechDraw::CosmeticEdge* ce = dvp->getCosmeticEdgeBySelection(tag);
|
||||
if (ce != nullptr) {
|
||||
result = new CosmeticEdgePy(new CosmeticEdge(ce));
|
||||
} else {
|
||||
Base::Console().Error("DVPPI::getCosmeticEdgebySelection - edge for tag %s not found\n", tag);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
//PyObject* DrawViewPartPy::replaceCosmeticEdge(PyObject *args)
|
||||
//{
|
||||
//// Base::Console().Message("DVPPI::replaceCosmeticEdge()\n");
|
||||
// int idx = 0;
|
||||
// PyObject* result = Py_None;
|
||||
// PyObject* pCE;
|
||||
// if (!PyArg_ParseTuple(args, "iO!", &idx, &(TechDraw::CosmeticEdgePy::Type), &pCE)) {
|
||||
// throw Py::TypeError("expected (index, CosmeticEdge)");
|
||||
// }
|
||||
// TechDraw::CosmeticEdge* ce = static_cast<CosmeticEdgePy*>(pCE)->getCosmeticEdgePtr();
|
||||
// DrawViewPart* dvp = getDrawViewPartPtr();
|
||||
// dvp->replaceCosmeticEdge(idx, ce);
|
||||
|
||||
// return result;
|
||||
//}
|
||||
PyObject* DrawViewPartPy::replaceCosmeticEdge(PyObject *args)
|
||||
{
|
||||
// Base::Console().Message("DVPPI::replaceCosmeticEdge()\n");
|
||||
PyObject* pNewCE;
|
||||
if (!PyArg_ParseTuple(args, "O!", &(TechDraw::CosmeticEdgePy::Type), &pNewCE)) {
|
||||
throw Py::TypeError("expected (CosmeticEdge)");
|
||||
}
|
||||
DrawViewPart* dvp = getDrawViewPartPtr();
|
||||
TechDraw::CosmeticEdgePy* cePy = static_cast<TechDraw::CosmeticEdgePy*>(pNewCE);
|
||||
TechDraw::CosmeticEdge* ce = cePy->getCosmeticEdgePtr();
|
||||
bool result = dvp->replaceCosmeticEdge(ce);
|
||||
dvp->refreshCEGeoms();
|
||||
dvp->requestPaint();
|
||||
return PyBool_FromLong((long) result);
|
||||
}
|
||||
|
||||
PyObject* DrawViewPartPy::removeCosmeticEdge(PyObject *args)
|
||||
{
|
||||
// Base::Console().Message("DVPPI::removeCosEdge()\n");
|
||||
int idx = 0;
|
||||
if (!PyArg_ParseTuple(args, "i", &idx)) {
|
||||
throw Py::TypeError("expected (index)");
|
||||
// Base::Console().Message("DVPPI::removeCosmeticEdge()\n");
|
||||
char* tag;
|
||||
if (!PyArg_ParseTuple(args, "s", &tag)) {
|
||||
throw Py::TypeError("expected (tag)");
|
||||
}
|
||||
DrawViewPart* dvp = getDrawViewPartPtr();
|
||||
dvp->removeCosmeticEdge(idx);
|
||||
Py_INCREF(Py_None);
|
||||
dvp->removeCosmeticEdge(tag);
|
||||
Py_INCREF(Py_None);
|
||||
return Py_None;
|
||||
}
|
||||
|
||||
//********** Center Line *******************************************************
|
||||
|
||||
PyObject* DrawViewPartPy::makeCenterLine(PyObject *args)
|
||||
{
|
||||
// Base::Console().Message("DVPPI::makeCenterLine()\n");
|
||||
|
||||
@@ -33,6 +33,7 @@
|
||||
#include <Bnd_Box.hxx>
|
||||
#include <BRepBndLib.hxx>
|
||||
#include <BRepBuilderAPI_Transform.hxx>
|
||||
#include <BRepBuilderAPI_MakeEdge.hxx>
|
||||
#include <BRepBuilderAPI_MakeFace.hxx>
|
||||
#include <BRepBuilderAPI_Copy.hxx>
|
||||
#include <Geom_BSplineCurve.hxx>
|
||||
@@ -572,6 +573,8 @@ void GeometryObject::addGeomFromCompound(TopoDS_Shape edgeCompound, edgeClass ca
|
||||
} //end TopExp
|
||||
}
|
||||
|
||||
//********** Cosmetic Vertex ***************************************************
|
||||
|
||||
//adds a new GeomVert surrogate for CV
|
||||
//returns GeomVert selection index ("Vertex3")
|
||||
// insertGeomForCV(cv)
|
||||
@@ -617,17 +620,72 @@ int GeometryObject::addCosmeticVertex(Base::Vector3d pos, std::string tagString,
|
||||
return idx;
|
||||
}
|
||||
|
||||
//================================================================================
|
||||
//********** Cosmetic Edge *****************************************************
|
||||
|
||||
//adds a new GeomEdge surrogate for CE
|
||||
//returns GeomEdge selection index ("Edge3")
|
||||
// insertGeomForCE(ce)
|
||||
int GeometryObject::addCosmeticEdge(CosmeticEdge* ce)
|
||||
{
|
||||
Base::Console().Message("GO::addCosmeticEdge(%X)\n", ce);
|
||||
double scale = m_parent->getScale();
|
||||
TechDraw::BaseGeom* e = ce->scaledGeometry(scale);
|
||||
e->cosmetic = true;
|
||||
e->setCosmeticTag(ce->getTagAsString());
|
||||
e->hlrVisible = true;
|
||||
int idx = edgeGeom.size();
|
||||
edgeGeom.push_back(e);
|
||||
return idx;
|
||||
}
|
||||
|
||||
//adds a new GeomEdge to list for ce[link]
|
||||
//this should be made obsolete and the variant with tag used instead
|
||||
int GeometryObject::addCosmeticEdge(Base::Vector3d start,
|
||||
Base::Vector3d end,
|
||||
int link)
|
||||
{
|
||||
Base::Console().Message("GO::addCosmeticEdge() 1 - deprec?\n");
|
||||
gp_Pnt gp1(start.x, start.y, start.z);
|
||||
gp_Pnt gp2(end.x, end.y, end.z);
|
||||
TopoDS_Edge occEdge = BRepBuilderAPI_MakeEdge(gp1, gp2);
|
||||
TechDraw::BaseGeom* e = BaseGeom::baseFactory(occEdge);
|
||||
e->cosmetic = true;
|
||||
// e->cosmeticLink = link;
|
||||
e->setCosmeticTag("tbi");
|
||||
e->hlrVisible = true;
|
||||
int idx = edgeGeom.size();
|
||||
edgeGeom.push_back(e);
|
||||
return idx;
|
||||
}
|
||||
|
||||
int GeometryObject::addCosmeticEdge(Base::Vector3d start,
|
||||
Base::Vector3d end,
|
||||
std::string tagString,
|
||||
int link)
|
||||
{
|
||||
Base::Console().Message("GO::addCosmeticEdge() 2\n");
|
||||
gp_Pnt gp1(start.x, start.y, start.z);
|
||||
gp_Pnt gp2(end.x, end.y, end.z);
|
||||
TopoDS_Edge occEdge = BRepBuilderAPI_MakeEdge(gp1, gp2);
|
||||
TechDraw::BaseGeom* base = BaseGeom::baseFactory(occEdge);
|
||||
base->cosmetic = true;
|
||||
base->setCosmeticTag(tagString);
|
||||
base->hlrVisible = true;
|
||||
int idx = edgeGeom.size();
|
||||
edgeGeom.push_back(base);
|
||||
return idx;
|
||||
}
|
||||
|
||||
//do not need source index anymore. base has CosmeticTag
|
||||
int GeometryObject::addCosmeticEdge(TechDraw::BaseGeom* base,
|
||||
int s)
|
||||
std::string tagString)
|
||||
{
|
||||
base->cosmetic = true;
|
||||
base->source(s); //1-CosmeticEdge, 2-CenterLine
|
||||
|
||||
base->hlrVisible = true;
|
||||
base->source(1); //1-CosmeticEdge, 2-CenterLine
|
||||
base->setCosmeticTag(tagString);
|
||||
base->sourceIndex(-1);
|
||||
int idx = edgeGeom.size();
|
||||
edgeGeom.push_back(base);
|
||||
int idx = edgeGeom.size() - 1;
|
||||
return idx;
|
||||
}
|
||||
|
||||
|
||||
@@ -110,6 +110,7 @@ public:
|
||||
const std::vector<Face *> & getFaceGeometry() const { return faceGeom; }
|
||||
|
||||
void setVertexGeometry(std::vector<Vertex*> newVerts) {vertexGeom = newVerts; }
|
||||
void setEdgeGeometry(std::vector<BaseGeom*> newGeoms) {edgeGeom = newGeoms; }
|
||||
|
||||
void projectShape(const TopoDS_Shape &input,
|
||||
const gp_Ax2 viewAxis);
|
||||
@@ -143,11 +144,26 @@ public:
|
||||
TopoDS_Shape getHidSeam(void) { return hidSeam; }
|
||||
TopoDS_Shape getHidIso(void) { return hidIso; }
|
||||
|
||||
//Are removeXXXXX functions really needed for GO?
|
||||
int addCosmeticVertex(CosmeticVertex* cv);
|
||||
int addCosmeticVertex(Base::Vector3d pos, int link = -1); //obs?
|
||||
int addCosmeticVertex(Base::Vector3d pos, std::string tagString, int link = -1); //obs??
|
||||
int addCosmeticEdge(TechDraw::BaseGeom* bg, int s = 0);
|
||||
int addCosmeticVertex(Base::Vector3d pos,
|
||||
int link = -1); //obs?
|
||||
int addCosmeticVertex(Base::Vector3d pos,
|
||||
std::string tagString,
|
||||
int link = -1); //obs??
|
||||
|
||||
int addCosmeticEdge(CosmeticEdge* ce);
|
||||
int addCosmeticEdge(Base::Vector3d start,
|
||||
Base::Vector3d end,
|
||||
int link = -1); //obs?
|
||||
int addCosmeticEdge(Base::Vector3d start,
|
||||
Base::Vector3d end,
|
||||
std::string tagString,
|
||||
int link = -1); //obs??
|
||||
int addCosmeticEdge(TechDraw::BaseGeom* base,
|
||||
std::string tagString);
|
||||
|
||||
|
||||
/* int addCosmeticEdge(TechDraw::BaseGeom* bg, int s = 0);*/
|
||||
int addCenterLine(TechDraw::BaseGeom* bg, int s = 0, int si = -1);
|
||||
|
||||
protected:
|
||||
|
||||
@@ -687,21 +687,6 @@ void QGIViewPart::drawViewPart()
|
||||
}
|
||||
}
|
||||
|
||||
bool QGIViewPart::formatGeomFromCosmetic(int sourceIndex, QGIEdge* item)
|
||||
{
|
||||
// Base::Console().Message("QGIVP::formatGeomFromCosmetic(%d)\n",sourceIndex);
|
||||
bool result = true;
|
||||
auto partFeat( dynamic_cast<TechDraw::DrawViewPart *>(getViewObject()) );
|
||||
TechDraw::CosmeticEdge* ce = partFeat->getCosmeticEdgeByIndex(sourceIndex);
|
||||
if (ce != nullptr) {
|
||||
item->setNormalColor(ce->m_format.m_color.asValue<QColor>());
|
||||
item->setWidth(ce->m_format.m_weight * lineScaleFactor);
|
||||
item->setStyle(ce->m_format.m_style);
|
||||
result = ce->m_format.m_visible;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
bool QGIViewPart::formatGeomFromCosmetic(std::string cTag, QGIEdge* item)
|
||||
{
|
||||
// Base::Console().Message("QGIVP::formatGeomFromCosmetic(%s)\n", cTag.c_str());
|
||||
|
||||
@@ -106,7 +106,6 @@ protected:
|
||||
bool prefFaceEdges(void);
|
||||
bool prefPrintCenters(void);
|
||||
|
||||
bool formatGeomFromCosmetic(int sourceIndex, QGIEdge* item);
|
||||
bool formatGeomFromCosmetic(std::string cTag, QGIEdge* item);
|
||||
bool formatGeomFromCenterLine(int sourceIndex, QGIEdge* item);
|
||||
|
||||
|
||||
@@ -119,7 +119,7 @@ void TaskLineDecor::getDefaults(void)
|
||||
if (bg != nullptr) {
|
||||
if (bg->cosmetic) {
|
||||
if (bg->source() == 1) {
|
||||
TechDraw::CosmeticEdge* ce = m_partFeat->getCosmeticEdgeByIndex(bg->sourceIndex());
|
||||
TechDraw::CosmeticEdge* ce = m_partFeat->getCosmeticEdgeBySelection(m_edges.front());
|
||||
m_style = ce->m_format.m_style;
|
||||
m_color = ce->m_format.m_color;
|
||||
m_weight = ce->m_format.m_weight;
|
||||
@@ -186,7 +186,7 @@ void TaskLineDecor::applyDecorations(void)
|
||||
if (bg != nullptr) {
|
||||
if (bg->cosmetic) {
|
||||
if (bg->source() == 1) {
|
||||
TechDraw::CosmeticEdge* ce = m_partFeat->getCosmeticEdgeByIndex(bg->sourceIndex());
|
||||
TechDraw::CosmeticEdge* ce = m_partFeat->getCosmeticEdgeBySelection(e);
|
||||
ce->m_format.m_style = m_style;
|
||||
ce->m_format.m_color = m_color;
|
||||
ce->m_format.m_weight = m_weight;
|
||||
@@ -218,7 +218,6 @@ void TaskLineDecor::applyDecorations(void)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
bool TaskLineDecor::accept()
|
||||
|
||||
Reference in New Issue
Block a user