Cosmetic CL for Section and Detail

This commit is contained in:
wandererfan
2019-06-05 16:03:57 -04:00
committed by WandererFan
parent 9f3a61aec5
commit 5eb7145d97
10 changed files with 119 additions and 63 deletions

View File

@@ -22,6 +22,7 @@
#include "PreCompiled.h"
#ifndef _PreComp_
#include <TopoDS.hxx>
# include <TopoDS_Edge.hxx>
# include <gp_Pnt.hxx>
# include <BRepBuilderAPI_MakeEdge.hxx>
@@ -37,6 +38,7 @@
#include <App/Material.h>
#include "DrawUtil.h"
#include "GeometryObject.h"
#include "Geometry.h"
#include "Cosmetic.h"
@@ -162,19 +164,45 @@ CosmeticEdge::CosmeticEdge()
width = getDefEdgeWidth();
style = getDefEdgeStyle();
visible = true;
}
CosmeticEdge::CosmeticEdge(Base::Vector3d p1, Base::Vector3d p2)
CosmeticEdge::CosmeticEdge(Base::Vector3d p1, Base::Vector3d p2, double scale)
{
// Base:: Console().Message("CE::CE(%s, %s, %.3f) \n",
// DrawUtil::formatVector(p1).c_str(),
// DrawUtil::formatVector(p2).c_str(), scale);
p1 = p1 / scale;
p2 = p2 / scale;
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);
geometry = TechDrawGeometry::BaseGeom::baseFactory(e);
geometry->geomType = GENERIC;
geometry->geomType = GENERIC; //treat every CE as a line for now
geometry->classOfEdge = ecHARD;
geometry->visible = true;
geometry->cosmetic = true;
linkGeom = -1;
color = getDefEdgeColor();
width = getDefEdgeWidth();
style = getDefEdgeStyle();
visible = true;
}
CosmeticEdge::CosmeticEdge(TopoDS_Edge e, double scale)
{
// Base:: Console().Message("CE::CE(occEdge, %.3f) \n", scale);
TechDrawGeometry::BaseGeom* newGeom = nullptr;
TopoDS_Shape s = TechDrawGeometry::scaleShape(e, scale);
TopoDS_Edge newEdge = TopoDS::Edge(s);
newGeom = TechDrawGeometry::BaseGeom::baseFactory(newEdge);
newGeom->geomType = GENERIC;
newGeom->classOfEdge = ecHARD;
newGeom->visible = true;
newGeom->cosmetic = true;
linkGeom = -1;
color = getDefEdgeColor();
width = getDefEdgeWidth();
@@ -182,19 +210,20 @@ CosmeticEdge::CosmeticEdge(Base::Vector3d p1, Base::Vector3d p2)
visible = true;
}
CosmeticEdge::CosmeticEdge(TopoDS_Edge e)
TechDrawGeometry::BaseGeom* CosmeticEdge::scaledGeometry(double scale)
{
geometry = TechDrawGeometry::BaseGeom::baseFactory(e);
geometry->geomType = GENERIC;
geometry->classOfEdge = ecHARD;
geometry->visible = true;
geometry->cosmetic = true;
linkGeom = -1;
color = getDefEdgeColor();
width = getDefEdgeWidth();
style = getDefEdgeStyle();
visible = true;
// Base::Console().Message("CE::getScaledGeometry(%.3f)\n",scale);
TechDrawGeometry::BaseGeom* newGeom = nullptr;
TopoDS_Edge e = geometry->occEdge;
TopoDS_Shape s = TechDrawGeometry::scaleShape(e, scale);
TopoDS_Edge newEdge = TopoDS::Edge(s);
newGeom = TechDrawGeometry::BaseGeom::baseFactory(newEdge);
newGeom->geomType = GENERIC; //treat all geoms as lines for now
//TODO: handle at least circles
newGeom->classOfEdge = ecHARD;
newGeom->visible = true;
newGeom->cosmetic = true;
return newGeom;
}
double CosmeticEdge::getDefEdgeWidth()
@@ -220,7 +249,10 @@ App::Color CosmeticEdge::getDefEdgeColor()
int CosmeticEdge::getDefEdgeStyle()
{
return 1;
Base::Reference<ParameterGrp> hGrp = App::GetApplication().GetUserParameter()
.GetGroup("BaseApp")->GetGroup("Preferences")->GetGroup("Mod/TechDraw/Decorations");
int style = hGrp->GetInt("CosmoCLStyle", 2);
return style;
}
std::string CosmeticEdge::toCSV(void) const
@@ -233,6 +265,7 @@ std::string CosmeticEdge::toCSV(void) const
p2d = geometry->getEndPoint();
end = Base::Vector3d(p2d.x, p2d.y, 0.0);
}
ss << start.x << "," <<
start.y << "," <<
start.z << "," <<

View File

@@ -62,10 +62,12 @@ class TechDrawExport CosmeticEdge
{
public:
CosmeticEdge();
CosmeticEdge(Base::Vector3d p1, Base::Vector3d p2);
CosmeticEdge(TopoDS_Edge e);
CosmeticEdge(Base::Vector3d p1, Base::Vector3d p2, double scale = 1.0);
CosmeticEdge(TopoDS_Edge e, double scale = 1.0);
virtual ~CosmeticEdge() = default;
TechDrawGeometry::BaseGeom* scaledGeometry(double scale);
std::string toCSV(void) const;
bool fromCSV(std::string& lineSpec);
void dump(char* title);

View File

@@ -80,6 +80,7 @@
#include "Geometry.h"
#include "GeometryObject.h"
#include "Cosmetic.h"
#include "EdgeWalker.h"
#include "DrawProjectSplit.h"
#include "DrawUtil.h"
@@ -157,6 +158,9 @@ App::DocumentObjectExecReturn *DrawViewDetail::execute(void)
return App::DocumentObject::StdReturn;
}
rebuildCosmoVertex();
rebuildCosmoEdge();
App::DocumentObject* baseObj = BaseView.getValue();
if (!baseObj) {
bool isRestoring = getDocument()->testStatus(App::Document::Status::Restoring);
@@ -347,8 +351,21 @@ App::DocumentObjectExecReturn *DrawViewDetail::execute(void)
return new App::DocumentObjectExecReturn(e1.GetMessageString());
}
//add back the cosmetic vertices
for (auto& v: cosmoVertex) {
int idx = geometryObject->addRandomVertex(v->pageLocation * getScale());
v->linkGeom = idx;
}
//add the cosmetic Edges to geometry Edges list
for (auto& e: cosmoEdge) {
TechDrawGeometry::BaseGeom* scaledGeom = e->scaledGeometry(getScale());
int idx = geometryObject->addRandomEdge(scaledGeom);
e->linkGeom = idx;
}
requestPaint();
dvp->requestPaint();
dvp->requestPaint(); //to refresh detail highlight!
return App::DocumentObject::StdReturn;
}

View File

@@ -291,12 +291,8 @@ App::DocumentObjectExecReturn *DrawViewPart::execute(void)
return App::DocumentObject::StdReturn;
}
//this is ghastly! but no convenient method for "object ready"
if (on1) {
rebuildCosmoVertex();
rebuildCosmoEdge();
on1 = false;
}
rebuildCosmoVertex();
rebuildCosmoEdge();
App::Document* doc = getDocument();
bool isRestoring = doc->testStatus(App::Document::Status::Restoring);
@@ -362,9 +358,10 @@ App::DocumentObjectExecReturn *DrawViewPart::execute(void)
v->linkGeom = idx;
}
//add back the cosmetic Edges
//add the cosmetic Edges to geometry Edges list
for (auto& e: cosmoEdge) {
int idx = geometryObject->addRandomEdge(e->geometry);
TechDrawGeometry::BaseGeom* scaledGeom = e->scaledGeometry(getScale());
int idx = geometryObject->addRandomEdge(scaledGeom);
e->linkGeom = idx;
}

View File

@@ -76,6 +76,7 @@
#include "Geometry.h"
#include "GeometryObject.h"
#include "Cosmetic.h"
#include "HatchLine.h"
#include "EdgeWalker.h"
#include "DrawUtil.h"
@@ -192,6 +193,9 @@ App::DocumentObjectExecReturn *DrawViewSection::execute(void)
return App::DocumentObject::StdReturn;
}
rebuildCosmoVertex();
rebuildCosmoEdge();
App::DocumentObject* base = BaseView.getValue();
if (!base->getTypeId().isDerivedFrom(TechDraw::DrawViewPart::getClassTypeId()))
return new App::DocumentObjectExecReturn("BaseView object is not a DrawViewPart object");
@@ -324,6 +328,18 @@ App::DocumentObjectExecReturn *DrawViewSection::execute(void)
Base::Console().Log("LOG - DVS::execute - failed building section faces for %s - %s **\n",getNameInDocument(),e2.GetMessageString());
return new App::DocumentObjectExecReturn(e2.GetMessageString());
}
//add back the cosmetic vertices
for (auto& v: cosmoVertex) {
int idx = geometryObject->addRandomVertex(v->pageLocation * getScale());
v->linkGeom = idx;
}
//add the cosmetic Edges to geometry Edges list
for (auto& e: cosmoEdge) {
TechDrawGeometry::BaseGeom* scaledGeom = e->scaledGeometry(getScale());
int idx = geometryObject->addRandomEdge(scaledGeom);
e->linkGeom = idx;
}
requestPaint();
return App::DocumentObject::StdReturn;

View File

@@ -496,6 +496,7 @@ int GeometryObject::addRandomVertex(Base::Vector3d pos)
int GeometryObject::addRandomEdge(TechDrawGeometry::BaseGeom* base)
{
// Base::Console().Message("GO::addRandomEdge() - cosmetic: %d\n", base->cosmetic);
base->cosmetic = true;
edgeGeom.push_back(base);
int idx = edgeGeom.size() - 1;