Cosmetic CL for Section and Detail
This commit is contained in:
@@ -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 << "," <<
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -627,6 +627,7 @@ QPainterPath QGIFace::shape() const
|
||||
void QGIFace::paint ( QPainter * painter, const QStyleOptionGraphicsItem * option, QWidget * widget) {
|
||||
QStyleOptionGraphicsItem myOption(*option);
|
||||
myOption.state &= ~QStyle::State_Selected;
|
||||
// painter->drawRect(boundingRect()); //good for debugging
|
||||
|
||||
m_brush.setStyle(m_fillStyle);
|
||||
m_brush.setColor(m_fillColor);
|
||||
|
||||
@@ -447,7 +447,6 @@ void QGIViewPart::drawViewPart()
|
||||
if (ce != nullptr) {
|
||||
item->setNormalColor(ce->color.asValue<QColor>());
|
||||
item->setWidth(ce->width * lineScaleFactor);
|
||||
// item->setStyle((Qt::PenStyle)ce->style);
|
||||
item->setStyle(ce->style);
|
||||
}
|
||||
}
|
||||
@@ -472,23 +471,6 @@ void QGIViewPart::drawViewPart()
|
||||
// dumpPath(edgeId.str().c_str(),edgePath);
|
||||
}
|
||||
}
|
||||
// Draw Cosmetic Edges
|
||||
// int cosmoEdgeStart = 1000;
|
||||
// const std::vector<TechDrawGreometry::CosmeticEdge *> &cEdges = viewPart->getEdgeCosmetic();
|
||||
// std::vector<TechDrawGreometry::CosmeticEdge *>::const_iterator itcEdge = cEdges.begin();
|
||||
// QGIEdge* item;
|
||||
// for(int i = 0 ; itcEdge != cEdges.end(); itcEdge++, i++) {
|
||||
// item = new QGIEdge(cosmoEdgeStart + i);
|
||||
// addToGroup(item);
|
||||
// item->setPos(0.0,0.0);
|
||||
//// item->setPath(drawPainterPath(*itcEdge)); //this won't work
|
||||
// item->setWidth((*itcEdge)->width);
|
||||
// item->setColor((*itcEdge)->color.asValue<QColor>();
|
||||
// item->setZValue(ZVALUE::EDGE);
|
||||
// item->setPrettyNormal();
|
||||
//
|
||||
// }
|
||||
|
||||
|
||||
// Draw Vertexs:
|
||||
Base::Reference<ParameterGrp> hGrp = App::GetApplication().GetUserParameter().GetGroup("BaseApp")->
|
||||
|
||||
@@ -144,20 +144,22 @@ void QGIViewSection::drawSectionFace()
|
||||
|
||||
void QGIViewSection::updateView(bool update)
|
||||
{
|
||||
Q_UNUSED(update);
|
||||
auto viewPart( dynamic_cast<TechDraw::DrawViewSection *>(getViewObject()) );
|
||||
if( viewPart == nullptr ) {
|
||||
return;
|
||||
}
|
||||
|
||||
if(update ||
|
||||
viewPart->SectionNormal.isTouched() ||
|
||||
viewPart->SectionOrigin.isTouched()) {
|
||||
QGIViewPart::updateView(true);
|
||||
drawSectionFace();
|
||||
} else {
|
||||
QGIViewPart::updateView();
|
||||
drawSectionFace();
|
||||
}
|
||||
// if(update ||
|
||||
// viewPart->SectionNormal.isTouched() ||
|
||||
// viewPart->SectionOrigin.isTouched()) {
|
||||
//// QGIViewPart::updateView(true);
|
||||
//// drawSectionFace();
|
||||
// } else {
|
||||
//// QGIViewPart::updateView();
|
||||
//// drawSectionFace();
|
||||
// }
|
||||
draw();
|
||||
}
|
||||
|
||||
void QGIViewSection::drawSectionLine(TechDraw::DrawViewSection* s, bool b)
|
||||
|
||||
@@ -315,11 +315,13 @@ TechDraw::CosmeticEdge* TaskCenterLine::calcEndPoints(std::vector<std::string> f
|
||||
faceBox.Get(Xmin,Ymin,Zmin,Xmax,Ymax,Zmax);
|
||||
|
||||
double Xspan = fabs(Xmax - Xmin);
|
||||
Xspan = (Xspan / 2.0) + (ext);
|
||||
// Xspan = (Xspan / 2.0) + (ext * scale); //this should be right? edges in GO are scaled!
|
||||
Xspan = (Xspan / 2.0) + ext;
|
||||
double Xmid = Xmin + fabs(Xmax - Xmin) / 2.0;
|
||||
|
||||
double Yspan = fabs(Ymax - Ymin);
|
||||
Yspan = (Yspan / 2.0) + (ext);
|
||||
// Yspan = (Yspan / 2.0) + (ext * scale);
|
||||
Yspan = (Yspan / 2.0) + ext;
|
||||
double Ymid = Ymin + fabs(Ymax - Ymin) / 2.0;
|
||||
|
||||
Base::Vector3d bbxCenter(Xmid, Ymid, 0.0);
|
||||
@@ -328,16 +330,16 @@ TechDraw::CosmeticEdge* TaskCenterLine::calcEndPoints(std::vector<std::string> f
|
||||
if (vert) {
|
||||
Base::Vector3d top(Xmid, Ymid - Yspan, 0.0);
|
||||
Base::Vector3d bottom(Xmid, Ymid + Yspan, 0.0);
|
||||
p1 = top / scale;
|
||||
p2 = bottom / scale;
|
||||
p1 = top;
|
||||
p2 = bottom;
|
||||
} else {
|
||||
Base::Vector3d left(Xmid - Xspan, Ymid, 0.0);
|
||||
Base::Vector3d right(Xmid + Xspan, Ymid, 0.0);
|
||||
p1 = left / scale;
|
||||
p2 = right / scale;
|
||||
p1 = left;
|
||||
p2 = right;
|
||||
}
|
||||
|
||||
result = new TechDraw::CosmeticEdge(p1, p2, scale);
|
||||
result = new TechDraw::CosmeticEdge(p1, p2, scale); //p1 & p2 are as found in GO.
|
||||
App::Color ac;
|
||||
ac.setValue<QColor>(ui->cpLineColor->color());
|
||||
result->color = ac;
|
||||
@@ -363,7 +365,7 @@ Qt::PenStyle TaskCenterLine::getCenterStyle()
|
||||
{
|
||||
Base::Reference<ParameterGrp> hGrp = App::GetApplication().GetUserParameter().GetGroup("BaseApp")->
|
||||
GetGroup("Preferences")->GetGroup("Mod/TechDraw/Decorations");
|
||||
Qt::PenStyle centerStyle = static_cast<Qt::PenStyle> (hGrp->GetInt("CenterLine", 2));
|
||||
Qt::PenStyle centerStyle = static_cast<Qt::PenStyle> (hGrp->GetInt("CosmoCLStyle", 2));
|
||||
return centerStyle;
|
||||
}
|
||||
|
||||
@@ -371,13 +373,16 @@ QColor TaskCenterLine::getCenterColor()
|
||||
{
|
||||
Base::Reference<ParameterGrp> hGrp = App::GetApplication().GetUserParameter()
|
||||
.GetGroup("BaseApp")->GetGroup("Preferences")->GetGroup("Mod/TechDraw/Decorations");
|
||||
App::Color fcColor = App::Color((uint32_t) hGrp->GetUnsigned("CenterColor", 0x00000000));
|
||||
App::Color fcColor = App::Color((uint32_t) hGrp->GetUnsigned("CosmoCLColor", 0x00000000));
|
||||
return fcColor.asValue<QColor>();
|
||||
}
|
||||
|
||||
double TaskCenterLine::getExtendBy(void)
|
||||
{
|
||||
return 3.0;
|
||||
Base::Reference<ParameterGrp> hGrp = App::GetApplication().GetUserParameter().GetGroup("BaseApp")->
|
||||
GetGroup("Preferences")->GetGroup("Mod/TechDraw/Decorations");
|
||||
double ext = hGrp->GetFloat("CosmoCLExtend", 3.0);
|
||||
return ext;
|
||||
}
|
||||
|
||||
//******************************************************************************
|
||||
|
||||
Reference in New Issue
Block a user