[TD]move dvp cosmetic functions to extension
This commit is contained in:
@@ -1292,6 +1292,8 @@ Base::Vector3d DrawViewPart::getLegacyX(const Base::Vector3d& pt, const Base::Ve
|
||||
return Base::Vector3d(gXDir.X(), gXDir.Y(), gXDir.Z());
|
||||
}
|
||||
|
||||
// reference dimensions & their vertices
|
||||
// these routines may be obsolete
|
||||
|
||||
void DrawViewPart::updateReferenceVert(std::string tag, Base::Vector3d loc2d)
|
||||
{
|
||||
@@ -1365,206 +1367,7 @@ void DrawViewPart::resetReferenceVerts()
|
||||
addReferencesToGeom();
|
||||
}
|
||||
|
||||
//********
|
||||
//* Cosmetics
|
||||
//********
|
||||
|
||||
void DrawViewPart::clearCosmeticVertexes()
|
||||
{
|
||||
std::vector<CosmeticVertex*> noVerts;
|
||||
CosmeticVertexes.setValues(noVerts);
|
||||
}
|
||||
|
||||
//add the cosmetic verts to geometry vertex list
|
||||
void DrawViewPart::addCosmeticVertexesToGeom()
|
||||
{
|
||||
// Base::Console().Message("DVP::addCosmeticVertexesToGeom()\n");
|
||||
const std::vector<TechDraw::CosmeticVertex*> cVerts = CosmeticVertexes.getValues();
|
||||
for (auto& cv : cVerts) {
|
||||
int iGV = geometryObject->addCosmeticVertex(cv->scaled(getScale()), cv->getTagAsString());
|
||||
cv->linkGeom = iGV;
|
||||
}
|
||||
}
|
||||
|
||||
int DrawViewPart::add1CVToGV(std::string tag)
|
||||
{
|
||||
// Base::Console().Message("DVP::add1CVToGV(%s)\n", tag.c_str());
|
||||
TechDraw::CosmeticVertex* cv = getCosmeticVertex(tag);
|
||||
if (!cv) {
|
||||
Base::Console().Message("DVP::add1CVToGV - cv %s not found\n", tag.c_str());
|
||||
return 0;
|
||||
}
|
||||
int iGV = geometryObject->addCosmeticVertex(cv->scaled(getScale()), cv->getTagAsString());
|
||||
cv->linkGeom = iGV;
|
||||
return iGV;
|
||||
}
|
||||
|
||||
//update Vertex geometry with current CV's
|
||||
void DrawViewPart::refreshCVGeoms()
|
||||
{
|
||||
// Base::Console().Message("DVP::refreshCVGeoms()\n");
|
||||
|
||||
std::vector<TechDraw::VertexPtr> gVerts = getVertexGeometry();
|
||||
std::vector<TechDraw::VertexPtr> newGVerts;
|
||||
for (auto& gv : gVerts) {
|
||||
if (gv->getCosmeticTag().empty()) {//keep only non-cv vertices
|
||||
newGVerts.push_back(gv);
|
||||
}
|
||||
}
|
||||
getGeometryObject()->setVertexGeometry(newGVerts);
|
||||
addCosmeticVertexesToGeom();
|
||||
}
|
||||
|
||||
//what is the CV's position in the big geometry q
|
||||
int DrawViewPart::getCVIndex(std::string tag)
|
||||
{
|
||||
// Base::Console().Message("DVP::getCVIndex(%s)\n", tag.c_str());
|
||||
std::vector<TechDraw::VertexPtr> gVerts = getVertexGeometry();
|
||||
std::vector<TechDraw::CosmeticVertex*> cVerts = CosmeticVertexes.getValues();
|
||||
|
||||
int i = 0;
|
||||
for (auto& gv : gVerts) {
|
||||
if (gv->getCosmeticTag() == tag) {
|
||||
return i;
|
||||
}
|
||||
i++;
|
||||
}
|
||||
|
||||
// Nothing found
|
||||
int base = gVerts.size();
|
||||
i = 0;
|
||||
for (auto& cv : cVerts) {
|
||||
// Base::Console().Message("DVP::getCVIndex - cv tag: %s\n",
|
||||
// cv->getTagAsString().c_str());
|
||||
if (cv->getTagAsString() == tag) {
|
||||
return base + i;
|
||||
}
|
||||
i++;
|
||||
}
|
||||
|
||||
// Base::Console().Message("DVP::getCVIndex - returns: %d\n", result);
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
||||
//CosmeticEdges -------------------------------------------------------------------
|
||||
|
||||
//for completeness. not actually used anywhere?
|
||||
void DrawViewPart::clearCosmeticEdges()
|
||||
{
|
||||
std::vector<CosmeticEdge*> noEdges;
|
||||
CosmeticEdges.setValues(noEdges);
|
||||
}
|
||||
|
||||
//add the cosmetic edges to geometry edge list
|
||||
void DrawViewPart::addCosmeticEdgesToGeom()
|
||||
{
|
||||
// Base::Console().Message("CEx::addCosmeticEdgesToGeom()\n");
|
||||
const std::vector<TechDraw::CosmeticEdge*> cEdges = CosmeticEdges.getValues();
|
||||
for (auto& ce : cEdges) {
|
||||
TechDraw::BaseGeomPtr scaledGeom = ce->scaledGeometry(getScale());
|
||||
if (!scaledGeom)
|
||||
continue;
|
||||
// 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) {
|
||||
Base::Console().Message("CEx::add1CEToGE 2 - ce %s not found\n", tag.c_str());
|
||||
return -1;
|
||||
}
|
||||
TechDraw::BaseGeomPtr scaledGeom = ce->scaledGeometry(getScale());
|
||||
int iGE = geometryObject->addCosmeticEdge(scaledGeom, tag);
|
||||
|
||||
return iGE;
|
||||
}
|
||||
|
||||
//update Edge geometry with current CE's
|
||||
void DrawViewPart::refreshCEGeoms()
|
||||
{
|
||||
// Base::Console().Message("DVP::refreshCEGeoms()\n");
|
||||
std::vector<TechDraw::BaseGeomPtr> gEdges = getEdgeGeometry();
|
||||
std::vector<TechDraw::BaseGeomPtr> oldGEdges;
|
||||
for (auto& ge : gEdges) {
|
||||
if (ge->source() != SourceType::COSEDGE) {
|
||||
oldGEdges.push_back(ge);
|
||||
}
|
||||
}
|
||||
getGeometryObject()->setEdgeGeometry(oldGEdges);
|
||||
addCosmeticEdgesToGeom();
|
||||
}
|
||||
|
||||
|
||||
// CenterLines -----------------------------------------------------------------
|
||||
void DrawViewPart::clearCenterLines()
|
||||
{
|
||||
std::vector<CenterLine*> noLines;
|
||||
CenterLines.setValues(noLines);
|
||||
}
|
||||
|
||||
int DrawViewPart::add1CLToGE(std::string tag)
|
||||
{
|
||||
// Base::Console().Message("CEx::add1CLToGE(%s) 2\n", tag.c_str());
|
||||
TechDraw::CenterLine* cl = getCenterLine(tag);
|
||||
if (!cl) {
|
||||
Base::Console().Message("CEx::add1CLToGE 2 - cl %s not found\n", tag.c_str());
|
||||
return -1;
|
||||
}
|
||||
TechDraw::BaseGeomPtr scaledGeom = cl->scaledGeometry(this);
|
||||
int iGE = geometryObject->addCenterLine(scaledGeom, tag);
|
||||
|
||||
return iGE;
|
||||
}
|
||||
|
||||
//update Edge geometry with current CL's
|
||||
void DrawViewPart::refreshCLGeoms()
|
||||
{
|
||||
// Base::Console().Message("DVP::refreshCLGeoms()\n");
|
||||
std::vector<TechDraw::BaseGeomPtr> gEdges = getEdgeGeometry();
|
||||
std::vector<TechDraw::BaseGeomPtr> newGEdges;
|
||||
for (auto& ge : gEdges) {
|
||||
if (ge->source() != SourceType::CENTERLINE) {
|
||||
newGEdges.push_back(ge);
|
||||
}
|
||||
}
|
||||
getGeometryObject()->setEdgeGeometry(newGEdges);
|
||||
addCenterLinesToGeom();
|
||||
}
|
||||
|
||||
//add the center lines to geometry Edges list
|
||||
void DrawViewPart::addCenterLinesToGeom()
|
||||
{
|
||||
// Base::Console().Message("DVP::addCenterLinesToGeom()\n");
|
||||
const std::vector<TechDraw::CenterLine*> lines = CenterLines.getValues();
|
||||
for (auto& cl : lines) {
|
||||
TechDraw::BaseGeomPtr scaledGeom = cl->scaledGeometry(this);
|
||||
if (!scaledGeom) {
|
||||
Base::Console().Error("DVP::addCenterLinesToGeom - scaledGeometry is null\n");
|
||||
continue;
|
||||
}
|
||||
// int idx =
|
||||
(void)geometryObject->addCenterLine(scaledGeom, cl->getTagAsString());
|
||||
}
|
||||
}
|
||||
|
||||
// GeomFormats -----------------------------------------------------------------
|
||||
|
||||
void DrawViewPart::clearGeomFormats()
|
||||
{
|
||||
std::vector<GeomFormat*> noFormats;
|
||||
std::vector<GeomFormat*> fmts = GeomFormats.getValues();
|
||||
GeomFormats.setValues(noFormats);
|
||||
for (auto& f : fmts) {
|
||||
delete f;
|
||||
}
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
// debugging ----------------------------------------------------------------------------
|
||||
|
||||
void DrawViewPart::dumpVerts(std::string text)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user