[TD]Py Cosmetic Vertex, Line, Circle Arc
This commit is contained in:
@@ -343,31 +343,31 @@ private:
|
||||
if (PyObject_TypeCheck(viewObj, &(TechDraw::DrawViewPartPy::Type))) {
|
||||
obj = static_cast<App::DocumentObjectPy*>(viewObj)->getDocumentObjectPtr();
|
||||
dvp = static_cast<TechDraw::DrawViewPart*>(obj);
|
||||
TechDrawGeometry::GeometryObject* go = dvp->getGeometryObject();
|
||||
TopoDS_Shape s = TechDrawGeometry::mirrorShape(go->getVisHard());
|
||||
TechDraw::GeometryObject* go = dvp->getGeometryObject();
|
||||
TopoDS_Shape s = TechDraw::mirrorShape(go->getVisHard());
|
||||
ss << dxfOut.exportEdges(s);
|
||||
s = TechDrawGeometry::mirrorShape(go->getVisOutline());
|
||||
s = TechDraw::mirrorShape(go->getVisOutline());
|
||||
ss << dxfOut.exportEdges(s);
|
||||
if (dvp->SmoothVisible.getValue()) {
|
||||
s = TechDrawGeometry::mirrorShape(go->getVisSmooth());
|
||||
s = TechDraw::mirrorShape(go->getVisSmooth());
|
||||
ss << dxfOut.exportEdges(s);
|
||||
}
|
||||
if (dvp->SeamVisible.getValue()) {
|
||||
s = TechDrawGeometry::mirrorShape(go->getVisSeam());
|
||||
s = TechDraw::mirrorShape(go->getVisSeam());
|
||||
ss << dxfOut.exportEdges(s);
|
||||
}
|
||||
if (dvp->HardHidden.getValue()) {
|
||||
s = TechDrawGeometry::mirrorShape(go->getHidHard());
|
||||
s = TechDraw::mirrorShape(go->getHidHard());
|
||||
ss << dxfOut.exportEdges(s);
|
||||
s = TechDrawGeometry::mirrorShape(go->getHidOutline());
|
||||
s = TechDraw::mirrorShape(go->getHidOutline());
|
||||
ss << dxfOut.exportEdges(s);
|
||||
}
|
||||
if (dvp->SmoothHidden.getValue()) {
|
||||
s = TechDrawGeometry::mirrorShape(go->getHidSmooth());
|
||||
s = TechDraw::mirrorShape(go->getHidSmooth());
|
||||
ss << dxfOut.exportEdges(s);
|
||||
}
|
||||
if (dvp->SeamHidden.getValue()) {
|
||||
s = TechDrawGeometry::mirrorShape(go->getHidSeam());
|
||||
s = TechDraw::mirrorShape(go->getHidSeam());
|
||||
ss << dxfOut.exportEdges(s);
|
||||
}
|
||||
// ss now contains all edges as Dxf
|
||||
@@ -400,7 +400,7 @@ private:
|
||||
if (PyObject_TypeCheck(viewObj, &(TechDraw::DrawViewPartPy::Type))) {
|
||||
obj = static_cast<App::DocumentObjectPy*>(viewObj)->getDocumentObjectPtr();
|
||||
dvp = static_cast<TechDraw::DrawViewPart*>(obj);
|
||||
TechDrawGeometry::GeometryObject* go = dvp->getGeometryObject();
|
||||
TechDraw::GeometryObject* go = dvp->getGeometryObject();
|
||||
//visible group begin "<g ... >"
|
||||
ss << grpHead1;
|
||||
// double thick = dvp->LineWidth.getValue();
|
||||
@@ -461,8 +461,8 @@ private:
|
||||
|
||||
void write1ViewDxf( ImpExpDxfWrite& writer, TechDraw::DrawViewPart* dvp, bool alignPage)
|
||||
{
|
||||
TechDrawGeometry::GeometryObject* go = dvp->getGeometryObject();
|
||||
TopoDS_Shape s = TechDrawGeometry::mirrorShape(go->getVisHard());
|
||||
TechDraw::GeometryObject* go = dvp->getGeometryObject();
|
||||
TopoDS_Shape s = TechDraw::mirrorShape(go->getVisHard());
|
||||
double offX = 0.0;
|
||||
double offY = 0.0;
|
||||
if (dvp->isDerivedFrom(TechDraw::DrawProjGroupItem::getClassTypeId())) {
|
||||
@@ -486,40 +486,40 @@ private:
|
||||
BRepBuilderAPI_Transform mkTrf(s, xLate);
|
||||
s = mkTrf.Shape();
|
||||
writer.exportShape(s);
|
||||
s = TechDrawGeometry::mirrorShape(go->getVisOutline());
|
||||
s = TechDraw::mirrorShape(go->getVisOutline());
|
||||
mkTrf.Perform(s);
|
||||
s = mkTrf.Shape();
|
||||
writer.exportShape(s);
|
||||
if (dvp->SmoothVisible.getValue()) {
|
||||
s = TechDrawGeometry::mirrorShape(go->getVisSmooth());
|
||||
s = TechDraw::mirrorShape(go->getVisSmooth());
|
||||
mkTrf.Perform(s);
|
||||
s = mkTrf.Shape();
|
||||
writer.exportShape(s);
|
||||
}
|
||||
if (dvp->SeamVisible.getValue()) {
|
||||
s = TechDrawGeometry::mirrorShape(go->getVisSeam());
|
||||
s = TechDraw::mirrorShape(go->getVisSeam());
|
||||
mkTrf.Perform(s);
|
||||
s = mkTrf.Shape();
|
||||
writer.exportShape(s);
|
||||
}
|
||||
if (dvp->HardHidden.getValue()) {
|
||||
s = TechDrawGeometry::mirrorShape(go->getHidHard());
|
||||
s = TechDraw::mirrorShape(go->getHidHard());
|
||||
mkTrf.Perform(s);
|
||||
s = mkTrf.Shape();
|
||||
writer.exportShape(s);
|
||||
s = TechDrawGeometry::mirrorShape(go->getHidOutline());
|
||||
s = TechDraw::mirrorShape(go->getHidOutline());
|
||||
mkTrf.Perform(s);
|
||||
s = mkTrf.Shape();
|
||||
writer.exportShape(s);
|
||||
}
|
||||
if (dvp->SmoothHidden.getValue()) {
|
||||
s = TechDrawGeometry::mirrorShape(go->getHidSmooth());
|
||||
s = TechDraw::mirrorShape(go->getHidSmooth());
|
||||
mkTrf.Perform(s);
|
||||
s = mkTrf.Shape();
|
||||
writer.exportShape(s);
|
||||
}
|
||||
if (dvp->SeamHidden.getValue()) {
|
||||
s = TechDrawGeometry::mirrorShape(go->getHidSeam());
|
||||
s = TechDraw::mirrorShape(go->getHidSeam());
|
||||
mkTrf.Perform(s);
|
||||
s = mkTrf.Shape();
|
||||
writer.exportShape(s);
|
||||
@@ -723,7 +723,7 @@ private:
|
||||
|
||||
const TopoDS_Shape& shape = pShape->getTopoShapePtr()->getShape();
|
||||
Base::Vector3d dir = static_cast<Base::VectorPy*>(pcObjDir)->value();
|
||||
Base::Vector3d c = TechDrawGeometry::findCentroidVec(shape,dir);
|
||||
Base::Vector3d c = TechDraw::findCentroidVec(shape,dir);
|
||||
PyObject* result = nullptr;
|
||||
result = new Base::VectorPy(new Base::Vector3d(c));
|
||||
return Py::asObject(result);
|
||||
|
||||
@@ -22,10 +22,15 @@
|
||||
|
||||
#include "PreCompiled.h"
|
||||
#ifndef _PreComp_
|
||||
#include <gp_Pnt.hxx>
|
||||
#include <gp_Dir.hxx>
|
||||
#include <gp_Ax1.hxx>
|
||||
#include <gp_Circ.hxx>
|
||||
#include <Geom_Circle.hxx>
|
||||
#include <BRepBuilderAPI_MakeEdge.hxx>
|
||||
#include <TopoDS.hxx>
|
||||
# include <TopoDS_Edge.hxx>
|
||||
# include <gp_Pnt.hxx>
|
||||
# include <BRepBuilderAPI_MakeEdge.hxx>
|
||||
#include <TopoDS_Shape.hxx>
|
||||
#include <TopoDS_Edge.hxx>
|
||||
#endif // #ifndef _PreComp_
|
||||
|
||||
#include <Base/Console.h>
|
||||
@@ -44,12 +49,96 @@
|
||||
#include "Cosmetic.h"
|
||||
|
||||
using namespace TechDraw;
|
||||
using namespace TechDrawGeometry;
|
||||
|
||||
CosmeticVertex::CosmeticVertex()
|
||||
LineFormat::LineFormat()
|
||||
{
|
||||
pageLocation = Base::Vector3d(0.0, 0.0, 0.0);
|
||||
modelLocation = Base::Vector3d(0.0, 0.0, 0.0);
|
||||
m_style = getDefEdgeStyle();
|
||||
m_weight = getDefEdgeWidth();
|
||||
m_color = getDefEdgeColor();
|
||||
m_visible = true;
|
||||
}
|
||||
|
||||
LineFormat::LineFormat(int style,
|
||||
double weight,
|
||||
App::Color color,
|
||||
bool visible ) :
|
||||
m_style(style),
|
||||
m_weight(weight),
|
||||
m_color(color),
|
||||
m_visible(visible)
|
||||
{
|
||||
}
|
||||
|
||||
void LineFormat::dump(char* title)
|
||||
{
|
||||
Base::Console().Message("LF::dump - %s \n",title);
|
||||
Base::Console().Message("LF::dump - %s \n",toCSV().c_str());
|
||||
}
|
||||
|
||||
std::string LineFormat::toCSV(void) const
|
||||
{
|
||||
std::stringstream ss;
|
||||
ss << m_style << "," <<
|
||||
m_weight << "," <<
|
||||
m_color.asHexString() << "," <<
|
||||
m_visible;
|
||||
return ss.str();
|
||||
}
|
||||
|
||||
bool LineFormat::fromCSV(std::string& lineSpec)
|
||||
{
|
||||
unsigned int maxCells = 4;
|
||||
if (lineSpec.length() == 0) {
|
||||
Base::Console().Message( "LineFormat::fromCSV - lineSpec empty\n");
|
||||
return false;
|
||||
}
|
||||
std::vector<std::string> values = DrawUtil::split(lineSpec);
|
||||
if (values.size() < maxCells) {
|
||||
Base::Console().Message( "LineFormat::fromCSV(%s) invalid CSV entry\n",lineSpec.c_str() );
|
||||
return false;
|
||||
}
|
||||
m_style = atoi(values[0].c_str());
|
||||
m_weight= atof(values[1].c_str());
|
||||
m_color.fromHexString(values[2]);
|
||||
m_visible = atoi(values[3].c_str());
|
||||
return true;
|
||||
}
|
||||
|
||||
//static preference getters.
|
||||
double LineFormat::getDefEdgeWidth()
|
||||
{
|
||||
Base::Reference<ParameterGrp> hGrp = App::GetApplication().GetUserParameter().GetGroup("BaseApp")->
|
||||
GetGroup("Preferences")->GetGroup("Mod/TechDraw/Decorations");
|
||||
std::string lgName = hGrp->GetASCII("LineGroup","FC 0.70mm");
|
||||
auto lg = TechDraw::LineGroup::lineGroupFactory(lgName);
|
||||
|
||||
double width = lg->getWeight("Graphic");
|
||||
delete lg;
|
||||
return width;
|
||||
}
|
||||
|
||||
App::Color LineFormat::getDefEdgeColor()
|
||||
{
|
||||
Base::Reference<ParameterGrp> hGrp = App::GetApplication().GetUserParameter()
|
||||
.GetGroup("BaseApp")->GetGroup("Preferences")->GetGroup("Mod/TechDraw/Colors");
|
||||
App::Color fcColor;
|
||||
fcColor.setPackedValue(hGrp->GetUnsigned("NormalColor", 0x00000000)); //black
|
||||
return fcColor;
|
||||
}
|
||||
|
||||
int LineFormat::getDefEdgeStyle()
|
||||
{
|
||||
Base::Reference<ParameterGrp> hGrp = App::GetApplication().GetUserParameter()
|
||||
.GetGroup("BaseApp")->GetGroup("Preferences")->GetGroup("Mod/TechDraw/Decorations");
|
||||
int style = hGrp->GetInt("CosmoCLStyle", 2); //dashed
|
||||
return style;
|
||||
}
|
||||
|
||||
//****************************************************************************************
|
||||
|
||||
CosmeticVertex::CosmeticVertex() : TechDraw::Vertex()
|
||||
{
|
||||
point(Base::Vector3d(0.0, 0.0, 0.0));
|
||||
Base::Reference<ParameterGrp> hGrp = App::GetApplication().GetUserParameter().GetGroup("BaseApp")->
|
||||
GetGroup("Preferences")->GetGroup("Mod/TechDraw/Decorations");
|
||||
App::Color fcColor;
|
||||
@@ -62,11 +151,9 @@ CosmeticVertex::CosmeticVertex()
|
||||
visible = true;
|
||||
}
|
||||
|
||||
CosmeticVertex::CosmeticVertex(Base::Vector3d loc)
|
||||
//CosmeticVertex::CosmeticVertex(Base::Vector3d loc) : TechDraw::Vertex(DrawUtil::invertY(loc))
|
||||
CosmeticVertex::CosmeticVertex(Base::Vector3d loc) : TechDraw::Vertex(loc)
|
||||
{
|
||||
pageLocation = loc;
|
||||
modelLocation = loc;
|
||||
|
||||
Base::Reference<ParameterGrp> hGrp = App::GetApplication().GetUserParameter().GetGroup("BaseApp")->
|
||||
GetGroup("Preferences")->GetGroup("Mod/TechDraw/Decorations");
|
||||
App::Color fcColor;
|
||||
@@ -83,13 +170,9 @@ CosmeticVertex::CosmeticVertex(Base::Vector3d loc)
|
||||
std::string CosmeticVertex::toCSV(void) const
|
||||
{
|
||||
std::stringstream ss;
|
||||
ss << pageLocation.x << "," <<
|
||||
pageLocation.y << "," <<
|
||||
pageLocation.z << "," <<
|
||||
|
||||
modelLocation.x << "," <<
|
||||
modelLocation.y << "," <<
|
||||
modelLocation.z << "," <<
|
||||
ss << point().x << "," <<
|
||||
point().y << "," <<
|
||||
point().z << "," <<
|
||||
|
||||
linkGeom << "," <<
|
||||
color.asHexString() << "," <<
|
||||
@@ -102,12 +185,12 @@ std::string CosmeticVertex::toCSV(void) const
|
||||
|
||||
bool CosmeticVertex::fromCSV(std::string& lineSpec)
|
||||
{
|
||||
unsigned int maxCells = 11;
|
||||
unsigned int maxCells = 8;
|
||||
if (lineSpec.length() == 0) {
|
||||
Base::Console().Message( "CosmeticVertex::fromCSV - lineSpec empty\n");
|
||||
return false;
|
||||
}
|
||||
std::vector<std::string> values = split(lineSpec);
|
||||
std::vector<std::string> values = DrawUtil::split(lineSpec);
|
||||
if (values.size() < maxCells) {
|
||||
Base::Console().Message( "CosmeticVertex::fromCSV(%s) invalid CSV entry\n",lineSpec.c_str() );
|
||||
return false;
|
||||
@@ -115,33 +198,15 @@ bool CosmeticVertex::fromCSV(std::string& lineSpec)
|
||||
double x = atof(values[0].c_str());
|
||||
double y = atof(values[1].c_str());
|
||||
double z = atof(values[2].c_str());
|
||||
pageLocation = Base::Vector3d (x,y,z);
|
||||
x = atof(values[3].c_str());
|
||||
y = atof(values[4].c_str());
|
||||
z = atof(values[5].c_str());
|
||||
modelLocation = Base::Vector3d (x,y,z);
|
||||
linkGeom = atoi(values[6].c_str());
|
||||
color.fromHexString(values[7]);
|
||||
size = atof(values[8].c_str());
|
||||
style = atoi(values[9].c_str());
|
||||
visible = atoi(values[10].c_str());
|
||||
point(Base::Vector3d (x,y,z));
|
||||
linkGeom = atoi(values[3].c_str());
|
||||
color.fromHexString(values[4]);
|
||||
size = atof(values[5].c_str());
|
||||
style = atoi(values[6].c_str());
|
||||
visible = atoi(values[7].c_str());
|
||||
return true;
|
||||
}
|
||||
|
||||
std::vector<std::string> CosmeticVertex::split(std::string csvLine)
|
||||
{
|
||||
// Base::Console().Message("CV::split - csvLine: %s\n",csvLine.c_str());
|
||||
std::vector<std::string> result;
|
||||
std::stringstream lineStream(csvLine);
|
||||
std::string cell;
|
||||
|
||||
while(std::getline(lineStream,cell, ','))
|
||||
{
|
||||
result.push_back(cell);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
void CosmeticVertex::dump(char* title)
|
||||
{
|
||||
Base::Console().Message("CV::dump - %s \n",title);
|
||||
@@ -153,188 +218,160 @@ void CosmeticVertex::dump(char* title)
|
||||
//note this ctor has no occEdge or first/last point for geometry!
|
||||
CosmeticEdge::CosmeticEdge()
|
||||
{
|
||||
geometry = new TechDrawGeometry::BaseGeom();
|
||||
geometry->geomType = GENERIC;
|
||||
geometry->classOfEdge = ecHARD;
|
||||
geometry->visible = true;
|
||||
geometry->cosmetic = true;
|
||||
|
||||
linkGeom = -1;
|
||||
color = getDefEdgeColor();
|
||||
width = getDefEdgeWidth();
|
||||
style = getDefEdgeStyle();
|
||||
visible = true;
|
||||
m_geometry = new TechDraw::BaseGeom();
|
||||
m_geometry->geomType = GENERIC;
|
||||
m_geometry->classOfEdge = ecHARD;
|
||||
m_geometry->visible = true;
|
||||
m_geometry->cosmetic = true;
|
||||
|
||||
m_linkGeom = -1;
|
||||
m_format = LineFormat();
|
||||
}
|
||||
|
||||
CosmeticEdge::CosmeticEdge(Base::Vector3d p1, Base::Vector3d p2, double scale)
|
||||
//CosmeticEdge::CosmeticEdge(Base::Vector3d pt1, Base::Vector3d pt2)
|
||||
CosmeticEdge::CosmeticEdge(Base::Vector3d pt1, Base::Vector3d pt2)
|
||||
{
|
||||
// Base:: Console().Message("CE::CE(%s, %s, %.3f) \n",
|
||||
// Base:: Console().Message("CE::CE(%s, %s) \n",
|
||||
// DrawUtil::formatVector(p1).c_str(),
|
||||
// DrawUtil::formatVector(p2).c_str(), scale);
|
||||
p1 = p1 / scale;
|
||||
p2 = p2 / scale;
|
||||
// DrawUtil::formatVector(p2).c_str());
|
||||
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);
|
||||
TopoDS_Edge e = BRepBuilderAPI_MakeEdge(gp1, gp2);
|
||||
geometry = TechDrawGeometry::BaseGeom::baseFactory(e);
|
||||
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;
|
||||
m_geometry = TechDraw::BaseGeom::baseFactory(e);
|
||||
m_geometry->classOfEdge = ecHARD;
|
||||
m_geometry->visible = true;
|
||||
m_geometry->cosmetic = true;
|
||||
|
||||
if (m_geometry->geomType == TechDraw::GeomType::GENERIC) {
|
||||
//
|
||||
} else if (m_geometry->geomType == TechDraw::GeomType::CIRCLE) {
|
||||
//
|
||||
}
|
||||
m_linkGeom = -1;
|
||||
m_format = LineFormat();
|
||||
}
|
||||
|
||||
CosmeticEdge::CosmeticEdge(TopoDS_Edge e, double scale)
|
||||
//CosmeticEdge::CosmeticEdge(TopoDS_Edge e, Base::Vector3d mirrorPoint)
|
||||
CosmeticEdge::CosmeticEdge(TopoDS_Edge e)
|
||||
{
|
||||
// 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;
|
||||
// Base:: Console().Message("CE::CE(occEdge) \n");
|
||||
m_geometry = TechDraw::BaseGeom::baseFactory(e);
|
||||
m_geometry->classOfEdge = ecHARD;
|
||||
m_geometry->visible = true;
|
||||
m_geometry->cosmetic = true;
|
||||
|
||||
linkGeom = -1;
|
||||
color = getDefEdgeColor();
|
||||
width = getDefEdgeWidth();
|
||||
style = getDefEdgeStyle();
|
||||
visible = true;
|
||||
m_linkGeom = -1;
|
||||
m_format = LineFormat();
|
||||
}
|
||||
|
||||
TechDrawGeometry::BaseGeom* CosmeticEdge::scaledGeometry(double scale)
|
||||
CosmeticEdge::CosmeticEdge(TechDraw::BaseGeom* g)
|
||||
{
|
||||
// Base:: Console().Message("CE::CE(Base::Geom) \n");
|
||||
m_geometry = g;
|
||||
m_geometry->classOfEdge = ecHARD;
|
||||
m_geometry->visible = true;
|
||||
m_geometry->cosmetic = true;
|
||||
m_linkGeom = -1;
|
||||
m_format = LineFormat();
|
||||
}
|
||||
|
||||
TechDraw::BaseGeom* CosmeticEdge::scaledGeometry(double scale)
|
||||
{
|
||||
// Base::Console().Message("CE::getScaledGeometry(%.3f)\n",scale);
|
||||
TechDrawGeometry::BaseGeom* newGeom = nullptr;
|
||||
TopoDS_Edge e = geometry->occEdge;
|
||||
TopoDS_Shape s = TechDrawGeometry::scaleShape(e, scale);
|
||||
TechDraw::BaseGeom* newGeom = nullptr;
|
||||
TopoDS_Edge e = m_geometry->occEdge;
|
||||
TopoDS_Shape s = TechDraw::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 = TechDraw::BaseGeom::baseFactory(newEdge);
|
||||
newGeom->classOfEdge = ecHARD;
|
||||
newGeom->visible = true;
|
||||
newGeom->cosmetic = true;
|
||||
return newGeom;
|
||||
}
|
||||
|
||||
double CosmeticEdge::getDefEdgeWidth()
|
||||
{
|
||||
Base::Reference<ParameterGrp> hGrp = App::GetApplication().GetUserParameter().GetGroup("BaseApp")->
|
||||
GetGroup("Preferences")->GetGroup("Mod/TechDraw/Decorations");
|
||||
std::string lgName = hGrp->GetASCII("LineGroup","FC 0.70mm");
|
||||
auto lg = TechDraw::LineGroup::lineGroupFactory(lgName);
|
||||
|
||||
double width = lg->getWeight("Graphic");
|
||||
delete lg;
|
||||
return width;
|
||||
}
|
||||
|
||||
App::Color CosmeticEdge::getDefEdgeColor()
|
||||
{
|
||||
Base::Reference<ParameterGrp> hGrp = App::GetApplication().GetUserParameter()
|
||||
.GetGroup("BaseApp")->GetGroup("Preferences")->GetGroup("Mod/TechDraw/Colors");
|
||||
App::Color fcColor;
|
||||
fcColor.setPackedValue(hGrp->GetUnsigned("NormalColor", 0x00000000));
|
||||
return fcColor;
|
||||
}
|
||||
|
||||
int CosmeticEdge::getDefEdgeStyle()
|
||||
{
|
||||
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
|
||||
{
|
||||
// Base::Console().Message( "CosmeticEdge::toCSV()\n");
|
||||
std::stringstream ss;
|
||||
Base::Vector3d start, end;
|
||||
if (geometry != nullptr) {
|
||||
Base::Vector2d p2d = geometry->getStartPoint();
|
||||
start = Base::Vector3d(p2d.x, p2d.y, 0.0);
|
||||
p2d = geometry->getEndPoint();
|
||||
end = Base::Vector3d(p2d.x, p2d.y, 0.0);
|
||||
if (m_geometry != nullptr) {
|
||||
ss << m_geometry->geomType << "," <<
|
||||
m_linkGeom <<
|
||||
",$$$," <<
|
||||
m_geometry->toCSV() <<
|
||||
",$$$," <<
|
||||
m_format.toCSV() <<
|
||||
std::endl;
|
||||
}
|
||||
|
||||
ss << start.x << "," <<
|
||||
start.y << "," <<
|
||||
start.z << "," <<
|
||||
end.x << "," <<
|
||||
end.y << "," <<
|
||||
end.z << "," <<
|
||||
linkGeom << "," <<
|
||||
color.asHexString() << "," <<
|
||||
width << "," <<
|
||||
style << "," <<
|
||||
visible <<
|
||||
std::endl;
|
||||
return ss.str();
|
||||
}
|
||||
|
||||
bool CosmeticEdge::fromCSV(std::string& lineSpec)
|
||||
{
|
||||
unsigned int maxCells = 11;
|
||||
if (lineSpec.length() == 0) {
|
||||
Base::Console().Message( "CosmeticEdge::fromCSV - lineSpec empty\n");
|
||||
// Base::Console().Message( "CosmeticEdge::fromCSV() - lineSpec: %s\n", lineSpec.c_str());
|
||||
std::vector<std::string> tokens = DrawUtil::tokenize(lineSpec);
|
||||
if (tokens.empty()) {
|
||||
Base::Console().Message("CosmeticEdge::fromCSV - tokenize failed - no tokens\n");
|
||||
return false;
|
||||
}
|
||||
std::vector<std::string> values = split(lineSpec);
|
||||
|
||||
if (tokens[0].length() == 0) {
|
||||
Base::Console().Message( "CosmeticEdge::fromCSV - token0 empty\n");
|
||||
return false;
|
||||
}
|
||||
|
||||
std::vector<std::string> values = DrawUtil::split(tokens[0]);
|
||||
unsigned int maxCells = 2;
|
||||
if (values.size() < maxCells) {
|
||||
Base::Console().Message( "CosmeticEdge::fromCSV(%s) invalid CSV entry\n",lineSpec.c_str() );
|
||||
return false;
|
||||
}
|
||||
Base::Vector3d start, end;
|
||||
double x = atof(values[0].c_str());
|
||||
double y = atof(values[1].c_str());
|
||||
double z = atof(values[2].c_str());
|
||||
start = Base::Vector3d (x,y,z);
|
||||
x = atof(values[3].c_str());
|
||||
y = atof(values[4].c_str());
|
||||
z = atof(values[5].c_str());
|
||||
end = Base::Vector3d (x,y,z);
|
||||
int geomType = atoi(values[0].c_str());
|
||||
m_linkGeom = atoi(values[1].c_str());
|
||||
|
||||
linkGeom = atoi(values[6].c_str());
|
||||
color.fromHexString(values[7]);
|
||||
width = atof(values[8].c_str());
|
||||
style = atoi(values[9].c_str());
|
||||
visible = atoi(values[10].c_str());
|
||||
|
||||
//dupl of ctor(p1,p2)
|
||||
gp_Pnt gp1(start.x,start.y,start.z);
|
||||
gp_Pnt gp2(end.x,end.y,end.z);
|
||||
TopoDS_Edge e = BRepBuilderAPI_MakeEdge(gp1, gp2);
|
||||
geometry = TechDrawGeometry::BaseGeom::baseFactory(e);
|
||||
geometry->geomType = GENERIC;
|
||||
geometry->classOfEdge = ecHARD;
|
||||
geometry->visible = true;
|
||||
geometry->cosmetic = true;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
//duplicate of CV routine. make static? or base class?
|
||||
std::vector<std::string> CosmeticEdge::split(std::string csvLine)
|
||||
{
|
||||
// Base::Console().Message("CE::split - csvLine: %s\n",csvLine.c_str());
|
||||
std::vector<std::string> result;
|
||||
std::stringstream lineStream(csvLine);
|
||||
std::string cell;
|
||||
|
||||
while(std::getline(lineStream,cell, ','))
|
||||
{
|
||||
result.push_back(cell);
|
||||
int lastToken = 0;
|
||||
if (geomType == TechDraw::GeomType::GENERIC) {
|
||||
if (tokens.size() != 4) {
|
||||
Base::Console().Message("CE::fromCSV - wrong number of tokens\n");
|
||||
return false;
|
||||
}
|
||||
TechDraw::Generic* tempGeom = new TechDraw::Generic();
|
||||
tempGeom->fromCSV(tokens[1] + ",$$$," + tokens[2]);
|
||||
lastToken = 3;
|
||||
m_geometry = tempGeom;
|
||||
m_geometry->occEdge = GeometryUtils::edgeFromGeneric(tempGeom);
|
||||
} else if (geomType == TechDraw::GeomType::CIRCLE) {
|
||||
if (tokens.size() != 4) {
|
||||
Base::Console().Message("CE::fromCSV - wrong number of tokens\n");
|
||||
return false;
|
||||
}
|
||||
TechDraw::Circle* tempGeom = new TechDraw::Circle();
|
||||
tempGeom->fromCSV(tokens[1] + ",$$$," + tokens[2]);
|
||||
lastToken = 3;
|
||||
m_geometry = tempGeom;
|
||||
m_geometry->occEdge = GeometryUtils::edgeFromCircle(tempGeom);
|
||||
} else if (geomType == TechDraw::GeomType::ARCOFCIRCLE) {
|
||||
if (tokens.size() != 5) {
|
||||
Base::Console().Message("CE::fromCSV - wrong number of tokens\n");
|
||||
return false;
|
||||
}
|
||||
TechDraw::AOC* tempGeom = new TechDraw::AOC();
|
||||
tempGeom->fromCSV(tokens[1] + ",$$$," + tokens[2] + ",$$$," + tokens[3]);
|
||||
lastToken = 4;
|
||||
m_geometry = tempGeom;
|
||||
m_geometry->occEdge = GeometryUtils::edgeFromCircleArc(tempGeom);
|
||||
} else {
|
||||
Base::Console().Message("Cosmetic::fromCSV - unimplemented geomType: %d\n", geomType);
|
||||
return false;
|
||||
}
|
||||
return result;
|
||||
|
||||
m_format.fromCSV(tokens[lastToken]);
|
||||
|
||||
m_geometry->classOfEdge = ecHARD;
|
||||
m_geometry->visible = true;
|
||||
m_geometry->cosmetic = true;
|
||||
return true;
|
||||
}
|
||||
|
||||
//duplicate of CV routine. make static? or base class?
|
||||
|
||||
@@ -26,15 +26,41 @@
|
||||
#include <Base/Vector3D.h>
|
||||
#include <App/Material.h>
|
||||
|
||||
#include "Geometry.h"
|
||||
|
||||
class TopoDS_Edge;
|
||||
|
||||
namespace TechDrawGeometry {
|
||||
class BaseGeom;
|
||||
}
|
||||
/*namespace TechDraw {*/
|
||||
/*class BaseGeom;*/
|
||||
/*}*/
|
||||
|
||||
namespace TechDraw {
|
||||
|
||||
class TechDrawExport CosmeticVertex
|
||||
class TechDrawExport LineFormat
|
||||
{
|
||||
public:
|
||||
LineFormat();
|
||||
LineFormat(int style,
|
||||
double weight,
|
||||
App::Color color,
|
||||
bool visible );
|
||||
~LineFormat() = default;
|
||||
|
||||
int m_style;
|
||||
double m_weight;
|
||||
App::Color m_color;
|
||||
bool m_visible;
|
||||
|
||||
static double getDefEdgeWidth();
|
||||
static App::Color getDefEdgeColor();
|
||||
static int getDefEdgeStyle();
|
||||
|
||||
void dump(char* title);
|
||||
std::string toCSV() const;
|
||||
bool fromCSV(std::string& lineSpec);
|
||||
};
|
||||
|
||||
class TechDrawExport CosmeticVertex: public TechDraw::Vertex
|
||||
{
|
||||
public:
|
||||
CosmeticVertex();
|
||||
@@ -45,8 +71,6 @@ public:
|
||||
bool fromCSV(std::string& lineSpec);
|
||||
void dump(char* title);
|
||||
|
||||
Base::Vector3d pageLocation;
|
||||
Base::Vector3d modelLocation;
|
||||
int linkGeom; //connection to corresponding "real" Vertex
|
||||
App::Color color;
|
||||
double size;
|
||||
@@ -54,39 +78,32 @@ public:
|
||||
bool visible;
|
||||
|
||||
protected:
|
||||
std::vector<std::string> split(std::string csvLine);
|
||||
/* std::vector<std::string> split(std::string csvLine);*/
|
||||
|
||||
};
|
||||
|
||||
//class TechDrawExport CosmeticEdge: publix TechDraw::BaseGeom
|
||||
class TechDrawExport CosmeticEdge
|
||||
{
|
||||
public:
|
||||
CosmeticEdge();
|
||||
CosmeticEdge(Base::Vector3d p1, Base::Vector3d p2, double scale = 1.0);
|
||||
CosmeticEdge(TopoDS_Edge e, double scale = 1.0);
|
||||
CosmeticEdge(Base::Vector3d p1, Base::Vector3d p2);
|
||||
CosmeticEdge(TopoDS_Edge e);
|
||||
CosmeticEdge(TechDraw::BaseGeom* g);
|
||||
virtual ~CosmeticEdge() = default;
|
||||
|
||||
TechDrawGeometry::BaseGeom* scaledGeometry(double scale);
|
||||
TechDraw::BaseGeom* scaledGeometry(double scale);
|
||||
|
||||
std::string toCSV(void) const;
|
||||
bool fromCSV(std::string& lineSpec);
|
||||
void dump(char* title);
|
||||
|
||||
TechDrawGeometry::BaseGeom* geometry;
|
||||
|
||||
Base::Vector3d start;
|
||||
Base::Vector3d end;
|
||||
int linkGeom; //connection to corresponding "real" Edge
|
||||
App::Color color;
|
||||
double width;
|
||||
int style;
|
||||
bool visible;
|
||||
TechDraw::BaseGeom* m_geometry;
|
||||
LineFormat m_format;
|
||||
int m_linkGeom;
|
||||
|
||||
protected:
|
||||
std::vector<std::string> split(std::string csvLine);
|
||||
double getDefEdgeWidth();
|
||||
App::Color getDefEdgeColor();
|
||||
int getDefEdgeStyle();
|
||||
/* std::vector<std::string> split(std::string csvLine);*/
|
||||
|
||||
};
|
||||
|
||||
|
||||
@@ -77,7 +77,6 @@
|
||||
#include <Mod/TechDraw/App/DrawGeomHatchPy.h> // generated from DrawGeomHatchPy.xml
|
||||
|
||||
using namespace TechDraw;
|
||||
using namespace TechDrawGeometry;
|
||||
using namespace std;
|
||||
|
||||
App::PropertyFloatConstraint::Constraints DrawGeomHatch::scaleRange = {Precision::Confusion(),
|
||||
@@ -263,10 +262,10 @@ std::vector<LineSet> DrawGeomHatch::getTrimmedLines(DrawViewPart* source, std::v
|
||||
resultEdges.push_back(edge);
|
||||
}
|
||||
|
||||
std::vector<TechDrawGeometry::BaseGeom*> resultGeoms;
|
||||
std::vector<TechDraw::BaseGeom*> resultGeoms;
|
||||
int i = 0;
|
||||
for (auto& e: resultEdges) {
|
||||
TechDrawGeometry::BaseGeom* base = BaseGeom::baseFactory(e);
|
||||
TechDraw::BaseGeom* base = BaseGeom::baseFactory(e);
|
||||
if (base == nullptr) {
|
||||
Base::Console().Log("FAIL - DGH::getTrimmedLines - baseFactory failed for edge: %d\n",i);
|
||||
throw Base::ValueError("DGH::getTrimmedLines - baseFactory failed");
|
||||
@@ -411,10 +410,10 @@ std::vector<LineSet> DrawGeomHatch::getFaceOverlay(int fdx)
|
||||
for (auto& ls: m_lineSets) {
|
||||
PATLineSpec hl = ls.getPATLineSpec();
|
||||
std::vector<TopoDS_Edge> candidates = DrawGeomHatch::makeEdgeOverlay(hl, bBox, ScalePattern.getValue());
|
||||
std::vector<TechDrawGeometry::BaseGeom*> resultGeoms;
|
||||
std::vector<TechDraw::BaseGeom*> resultGeoms;
|
||||
int i = 0;
|
||||
for (auto& e: candidates) {
|
||||
TechDrawGeometry::BaseGeom* base = BaseGeom::baseFactory(e);
|
||||
TechDraw::BaseGeom* base = BaseGeom::baseFactory(e);
|
||||
if (base == nullptr) {
|
||||
Base::Console().Log("FAIL - DGH::getFaceOverlay - baseFactory failed for edge: %d\n",i);
|
||||
throw Base::ValueError("DGH::getFaceOverlay - baseFactory failed");
|
||||
|
||||
@@ -32,7 +32,7 @@ class TopoDS_Edge;
|
||||
class TopoDS_Face;
|
||||
class Bnd_Box;
|
||||
|
||||
namespace TechDrawGeometry
|
||||
namespace TechDraw
|
||||
{
|
||||
class BaseGeom;
|
||||
}
|
||||
|
||||
@@ -117,10 +117,10 @@ App::DocumentObjectExecReturn *DrawParametricTemplate::execute(void)
|
||||
|
||||
int DrawParametricTemplate::drawLine(double x1, double y1, double x2, double y2)
|
||||
{
|
||||
TechDrawGeometry::Generic *line = new TechDrawGeometry::Generic();
|
||||
TechDraw::Generic *line = new TechDraw::Generic();
|
||||
|
||||
line->points.push_back(Base::Vector2d(x1, y1));
|
||||
line->points.push_back(Base::Vector2d(x2, y2));
|
||||
line->points.push_back(Base::Vector3d(x1, y1));
|
||||
line->points.push_back(Base::Vector3d(x2, y2));
|
||||
|
||||
geom.push_back(line); // Push onto geometry stack
|
||||
return geom.size() -1;
|
||||
@@ -128,7 +128,7 @@ int DrawParametricTemplate::drawLine(double x1, double y1, double x2, double y2)
|
||||
|
||||
int DrawParametricTemplate::clearGeometry()
|
||||
{
|
||||
for(std::vector<TechDrawGeometry::BaseGeom *>::iterator it = geom.begin(); it != geom.end(); ++it) {
|
||||
for(std::vector<TechDraw::BaseGeom *>::iterator it = geom.begin(); it != geom.end(); ++it) {
|
||||
delete *it;
|
||||
*it = 0;
|
||||
}
|
||||
|
||||
@@ -28,7 +28,7 @@
|
||||
|
||||
#include "DrawTemplate.h"
|
||||
|
||||
namespace TechDrawGeometry
|
||||
namespace TechDraw
|
||||
{
|
||||
class BaseGeom;
|
||||
}
|
||||
@@ -67,7 +67,7 @@ public:
|
||||
virtual unsigned int getMemSize(void) const;
|
||||
|
||||
public:
|
||||
std::vector<TechDrawGeometry::BaseGeom *> getGeometry() { return geom; }
|
||||
std::vector<TechDraw::BaseGeom *> getGeometry() { return geom; }
|
||||
int clearGeometry();
|
||||
|
||||
// Template Drawing Methods
|
||||
@@ -80,7 +80,7 @@ protected:
|
||||
void onChanged(const App::Property* prop);
|
||||
|
||||
protected:
|
||||
std::vector<TechDrawGeometry::BaseGeom *> geom;
|
||||
std::vector<TechDraw::BaseGeom *> geom;
|
||||
|
||||
private:
|
||||
static const char* OrientationEnums[];
|
||||
|
||||
@@ -208,7 +208,7 @@ gp_Ax2 DrawProjGroupItem::getViewAxis(const Base::Vector3d& pt,
|
||||
catch (Standard_Failure& e4) {
|
||||
Base::Console().Message("PROBLEM - DPGI (%s) failed to create viewAxis: %s **\n",
|
||||
getNameInDocument(),e4.GetMessageString());
|
||||
return TechDrawGeometry::getViewAxis(pt,axis,false);
|
||||
return TechDraw::getViewAxis(pt,axis,false);
|
||||
}
|
||||
|
||||
return viewAxis;
|
||||
@@ -225,7 +225,7 @@ double DrawProjGroupItem::getRotateAngle()
|
||||
na.Normalize();
|
||||
Base::Vector3d org(0.0,0.0,0.0);
|
||||
|
||||
viewAxis = TechDrawGeometry::getViewAxis(org,na,true); //default orientation
|
||||
viewAxis = TechDraw::getViewAxis(org,na,true); //default orientation
|
||||
|
||||
gp_Dir gxDir = viewAxis.XDirection();
|
||||
Base::Vector3d origX(gxDir.X(),gxDir.Y(),gxDir.Z());
|
||||
|
||||
@@ -113,10 +113,10 @@ std::vector<TopoDS_Edge> DrawProjectSplit::getEdgesForWalker(TopoDS_Shape shape,
|
||||
|
||||
gp_Pnt inputCenter(0,0,0);
|
||||
TopoDS_Shape scaledShape;
|
||||
scaledShape = TechDrawGeometry::scaleShape(copyShape,
|
||||
scaledShape = TechDraw::scaleShape(copyShape,
|
||||
scale);
|
||||
gp_Ax2 viewAxis = TechDrawGeometry::getViewAxis(Base::Vector3d(0.0,0.0,0.0),direction);
|
||||
TechDrawGeometry::GeometryObject* go = buildGeometryObject(scaledShape,viewAxis);
|
||||
gp_Ax2 viewAxis = TechDraw::getViewAxis(Base::Vector3d(0.0,0.0,0.0),direction);
|
||||
TechDraw::GeometryObject* go = buildGeometryObject(scaledShape,viewAxis);
|
||||
result = getEdges(go);
|
||||
|
||||
delete go;
|
||||
@@ -124,10 +124,10 @@ std::vector<TopoDS_Edge> DrawProjectSplit::getEdgesForWalker(TopoDS_Shape shape,
|
||||
}
|
||||
|
||||
|
||||
TechDrawGeometry::GeometryObject* DrawProjectSplit::buildGeometryObject(TopoDS_Shape shape,
|
||||
TechDraw::GeometryObject* DrawProjectSplit::buildGeometryObject(TopoDS_Shape shape,
|
||||
const gp_Ax2& viewAxis)
|
||||
{
|
||||
TechDrawGeometry::GeometryObject* geometryObject = new TechDrawGeometry::GeometryObject("DrawProjectSplit",nullptr);
|
||||
TechDraw::GeometryObject* geometryObject = new TechDraw::GeometryObject("DrawProjectSplit",nullptr);
|
||||
|
||||
if (geometryObject->usePolygonHLR()){
|
||||
geometryObject->projectShapeWithPolygonAlgo(shape,
|
||||
@@ -138,18 +138,18 @@ TechDrawGeometry::GeometryObject* DrawProjectSplit::buildGeometryObject(TopoDS_S
|
||||
viewAxis);
|
||||
}
|
||||
|
||||
geometryObject->extractGeometry(TechDrawGeometry::ecHARD, //always show the hard&outline visible lines
|
||||
geometryObject->extractGeometry(TechDraw::ecHARD, //always show the hard&outline visible lines
|
||||
true);
|
||||
geometryObject->extractGeometry(TechDrawGeometry::ecOUTLINE,
|
||||
geometryObject->extractGeometry(TechDraw::ecOUTLINE,
|
||||
true);
|
||||
return geometryObject;
|
||||
}
|
||||
|
||||
//! get the projected edges with all their new intersections.
|
||||
std::vector<TopoDS_Edge> DrawProjectSplit::getEdges(TechDrawGeometry::GeometryObject* geometryObject)
|
||||
std::vector<TopoDS_Edge> DrawProjectSplit::getEdges(TechDraw::GeometryObject* geometryObject)
|
||||
{
|
||||
const std::vector<TechDrawGeometry::BaseGeom*>& goEdges = geometryObject->getVisibleFaceEdges(true,true);
|
||||
std::vector<TechDrawGeometry::BaseGeom*>::const_iterator itEdge = goEdges.begin();
|
||||
const std::vector<TechDraw::BaseGeom*>& goEdges = geometryObject->getVisibleFaceEdges(true,true);
|
||||
std::vector<TechDraw::BaseGeom*>::const_iterator itEdge = goEdges.begin();
|
||||
std::vector<TopoDS_Edge> origEdges;
|
||||
for (;itEdge != goEdges.end(); itEdge++) {
|
||||
origEdges.push_back((*itEdge)->occEdge);
|
||||
|
||||
@@ -37,7 +37,7 @@
|
||||
class gp_Pnt;
|
||||
class gp_Ax2;
|
||||
|
||||
namespace TechDrawGeometry
|
||||
namespace TechDraw
|
||||
{
|
||||
class GeometryObject;
|
||||
class Vertex;
|
||||
@@ -79,7 +79,7 @@ public:
|
||||
|
||||
public:
|
||||
static std::vector<TopoDS_Edge> getEdgesForWalker(TopoDS_Shape shape, double scale, Base::Vector3d direction);
|
||||
static TechDrawGeometry::GeometryObject* buildGeometryObject(TopoDS_Shape shape, const gp_Ax2& viewAxis);
|
||||
static TechDraw::GeometryObject* buildGeometryObject(TopoDS_Shape shape, const gp_Ax2& viewAxis);
|
||||
|
||||
static bool isOnEdge(TopoDS_Edge e, TopoDS_Vertex v, double& param, bool allowEnds = false);
|
||||
static std::vector<TopoDS_Edge> splitEdges(std::vector<TopoDS_Edge> orig, std::vector<splitPoint> splits);
|
||||
@@ -92,7 +92,7 @@ public:
|
||||
static std::vector<edgeSortItem> sortEdges(std::vector<edgeSortItem>& e, bool ascend);
|
||||
|
||||
protected:
|
||||
static std::vector<TopoDS_Edge> getEdges(TechDrawGeometry::GeometryObject* geometryObject);
|
||||
static std::vector<TopoDS_Edge> getEdges(TechDraw::GeometryObject* geometryObject);
|
||||
|
||||
|
||||
private:
|
||||
|
||||
@@ -42,6 +42,7 @@
|
||||
#include <gp_Pnt.hxx>
|
||||
#include <gp_Vec.hxx>
|
||||
#include <Precision.hxx>
|
||||
#include <BRep_Builder.hxx>
|
||||
#include <BRepAdaptor_Curve.hxx>
|
||||
#include <BRepExtrema_DistShapeShape.hxx>
|
||||
#include <BRepGProp.hxx>
|
||||
@@ -56,6 +57,7 @@
|
||||
#include <BRepAdaptor_Surface.hxx>
|
||||
#include <BRepLProp_SLProps.hxx>
|
||||
#include <BRepGProp_Face.hxx>
|
||||
#include <BRepTools.hxx>
|
||||
|
||||
#endif
|
||||
|
||||
@@ -290,16 +292,6 @@ std::string DrawUtil::formatVector(const Base::Vector3d& v)
|
||||
return result;
|
||||
}
|
||||
|
||||
std::string DrawUtil::formatVector(const Base::Vector2d& v)
|
||||
{
|
||||
std::string result;
|
||||
std::stringstream builder;
|
||||
builder << std::fixed << std::setprecision(3) ;
|
||||
builder << " (" << v.x << "," << v.y << ") ";
|
||||
result = builder.str();
|
||||
return result;
|
||||
}
|
||||
|
||||
std::string DrawUtil::formatVector(const gp_Dir& v)
|
||||
{
|
||||
std::string result;
|
||||
@@ -528,6 +520,59 @@ Base::Vector3d DrawUtil::Intersect2d(Base::Vector3d p1, Base::Vector3d d1,
|
||||
return result;
|
||||
}
|
||||
|
||||
std::string DrawUtil::shapeToString(TopoDS_Shape s)
|
||||
{
|
||||
std::ostringstream buffer;
|
||||
BRepTools::Write(s, buffer);
|
||||
return buffer.str();
|
||||
}
|
||||
|
||||
TopoDS_Shape DrawUtil::shapeFromString(std::string s)
|
||||
{
|
||||
TopoDS_Shape result;
|
||||
BRep_Builder builder;
|
||||
std::istringstream buffer(s);
|
||||
BRepTools::Read(result, buffer, builder);
|
||||
return result;
|
||||
}
|
||||
|
||||
Base::Vector3d DrawUtil::invertY(Base::Vector3d v)
|
||||
{
|
||||
Base::Vector3d result(v.x, -v.y, v.z);
|
||||
return result;
|
||||
}
|
||||
|
||||
std::vector<std::string> DrawUtil::split(std::string csvLine)
|
||||
{
|
||||
// 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, ','))
|
||||
{
|
||||
result.push_back(cell);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
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());
|
||||
std::string s(csvLine);
|
||||
size_t pos = 0;
|
||||
std::vector<std::string> tokens;
|
||||
while ((pos = s.find(delimiter)) != std::string::npos) {
|
||||
tokens.push_back(s.substr(0, pos));
|
||||
s.erase(0, pos + delimiter.length());
|
||||
}
|
||||
if (!s.empty()) {
|
||||
tokens.push_back(s);
|
||||
}
|
||||
return tokens;
|
||||
}
|
||||
|
||||
|
||||
//============================
|
||||
// various debugging routines.
|
||||
void DrawUtil::dumpVertexes(const char* text, const TopoDS_Shape& s)
|
||||
|
||||
@@ -71,7 +71,6 @@ class TechDrawExport DrawUtil {
|
||||
static bool fpCompare(const double& d1, const double& d2, double tolerance = FLT_EPSILON);
|
||||
static Base::Vector3d vertex2Vector(const TopoDS_Vertex& v);
|
||||
static std::string formatVector(const Base::Vector3d& v);
|
||||
static std::string formatVector(const Base::Vector2d& v);
|
||||
static std::string formatVector(const gp_Dir& v);
|
||||
static std::string formatVector(const gp_Vec& v);
|
||||
static std::string formatVector(const gp_Pnt& v);
|
||||
@@ -87,8 +86,8 @@ class TechDrawExport DrawUtil {
|
||||
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::Vector2d& v2) { return Base::Vector3d(v2.x,v2.y,0.0); }
|
||||
static Base::Vector2d vector32(const Base::Vector3d& v3) { return Base::Vector2d(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
|
||||
@@ -96,6 +95,11 @@ class TechDrawExport DrawUtil {
|
||||
Base::Vector3d p2, Base::Vector3d 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 std::string shapeToString(TopoDS_Shape s);
|
||||
static TopoDS_Shape shapeFromString(std::string s);
|
||||
static Base::Vector3d invertY(Base::Vector3d v);
|
||||
static std::vector<std::string> split(std::string csvLine);
|
||||
static std::vector<std::string> tokenize(std::string csvLine, std::string delimiter = ",$$$,");
|
||||
|
||||
//debugging routines
|
||||
static void dumpVertexes(const char* text, const TopoDS_Shape& s);
|
||||
|
||||
@@ -54,7 +54,6 @@
|
||||
#include "DrawView.h"
|
||||
|
||||
using namespace TechDraw;
|
||||
using namespace TechDrawGeometry;
|
||||
|
||||
//===========================================================================
|
||||
// DrawView
|
||||
|
||||
@@ -221,7 +221,7 @@ App::DocumentObjectExecReturn *DrawViewDetail::execute(void)
|
||||
BRepBuilderAPI_Copy BuilderCopy(shape);
|
||||
TopoDS_Shape myShape = BuilderCopy.Shape();
|
||||
|
||||
gp_Pnt gpCenter = TechDrawGeometry::findCentroid(myShape,
|
||||
gp_Pnt gpCenter = TechDraw::findCentroid(myShape,
|
||||
dirDetail);
|
||||
Base::Vector3d shapeCenter = Base::Vector3d(gpCenter.X(),gpCenter.Y(),gpCenter.Z());
|
||||
|
||||
@@ -233,9 +233,9 @@ App::DocumentObjectExecReturn *DrawViewDetail::execute(void)
|
||||
viewAxis = dvp->getViewAxis(shapeCenter, dirDetail,false);
|
||||
}
|
||||
|
||||
myShape = TechDrawGeometry::moveShape(myShape, //centre on origin
|
||||
myShape = TechDraw::moveShape(myShape, //centre on origin
|
||||
-shapeCenter);
|
||||
gpCenter = TechDrawGeometry::findCentroid(myShape, //sb origin!
|
||||
gpCenter = TechDraw::findCentroid(myShape, //sb origin!
|
||||
dirDetail);
|
||||
shapeCenter = Base::Vector3d(gpCenter.X(),gpCenter.Y(),gpCenter.Z());
|
||||
|
||||
@@ -293,7 +293,7 @@ App::DocumentObjectExecReturn *DrawViewDetail::execute(void)
|
||||
BRepBndLib::Add(detail, testBox);
|
||||
if (testBox.IsVoid()) {
|
||||
// Base::Console().Warning("DrawViewDetail - detail area contains no geometry\n");
|
||||
TechDrawGeometry::GeometryObject* go = getGeometryObject();
|
||||
TechDraw::GeometryObject* go = getGeometryObject();
|
||||
if (go != nullptr) {
|
||||
go->clear();
|
||||
}
|
||||
@@ -311,9 +311,9 @@ App::DocumentObjectExecReturn *DrawViewDetail::execute(void)
|
||||
|
||||
gp_Pnt inputCenter;
|
||||
try {
|
||||
inputCenter = TechDrawGeometry::findCentroid(tool,
|
||||
inputCenter = TechDraw::findCentroid(tool,
|
||||
dirDetail);
|
||||
TopoDS_Shape mirroredShape = TechDrawGeometry::mirrorShape(detail,
|
||||
TopoDS_Shape mirroredShape = TechDraw::mirrorShape(detail,
|
||||
inputCenter,
|
||||
scale);
|
||||
|
||||
@@ -322,11 +322,11 @@ App::DocumentObjectExecReturn *DrawViewDetail::execute(void)
|
||||
double shapeRotate = dvp->Rotation.getValue(); //degrees CW?
|
||||
|
||||
if (!DrawUtil::fpCompare(shapeRotate,0.0)) {
|
||||
mirroredShape = TechDrawGeometry::rotateShape(mirroredShape,
|
||||
mirroredShape = TechDraw::rotateShape(mirroredShape,
|
||||
viewAxis,
|
||||
shapeRotate);
|
||||
}
|
||||
inputCenter = TechDrawGeometry::findCentroid(mirroredShape,
|
||||
inputCenter = TechDraw::findCentroid(mirroredShape,
|
||||
dirDetail);
|
||||
|
||||
geometryObject = buildGeometryObject(mirroredShape,viewAxis);
|
||||
@@ -352,16 +352,16 @@ App::DocumentObjectExecReturn *DrawViewDetail::execute(void)
|
||||
}
|
||||
|
||||
//add back the cosmetic vertices
|
||||
for (auto& v: cosmoVertex) {
|
||||
int idx = geometryObject->addRandomVertex(v->pageLocation * getScale());
|
||||
for (auto& v: vertexCosmetic) {
|
||||
int idx = geometryObject->addCosmeticVertex(v->point() * 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;
|
||||
for (auto& e: edgeCosmetic) {
|
||||
TechDraw::BaseGeom* scaledGeom = e->scaledGeometry(getScale());
|
||||
int idx = geometryObject->addCosmeticEdge(scaledGeom);
|
||||
e->m_linkGeom = idx;
|
||||
}
|
||||
|
||||
requestPaint();
|
||||
|
||||
@@ -38,7 +38,7 @@ class gp_Pln;
|
||||
class gp_Ax2;
|
||||
class TopoDS_Face;
|
||||
|
||||
namespace TechDrawGeometry
|
||||
namespace TechDraw
|
||||
{
|
||||
class Face;
|
||||
}
|
||||
|
||||
@@ -261,18 +261,18 @@ App::DocumentObjectExecReturn *DrawViewDimension::execute(void)
|
||||
m_hasGeometry = true;
|
||||
} else if(Type.isValue("Radius")){
|
||||
int idx = DrawUtil::getIndexFromName(subElements[0]);
|
||||
TechDrawGeometry::BaseGeom* base = getViewPart()->getProjEdgeByIndex(idx);
|
||||
TechDrawGeometry::Circle* circle;
|
||||
TechDraw::BaseGeom* base = getViewPart()->getProjEdgeByIndex(idx);
|
||||
TechDraw::Circle* circle;
|
||||
arcPoints pts;
|
||||
pts.center = Base::Vector3d(0.0,0.0,0.0);
|
||||
pts.radius = 0.0;
|
||||
if( (base && base->geomType == TechDrawGeometry::GeomType::CIRCLE) ||
|
||||
(base && base->geomType == TechDrawGeometry::GeomType::ARCOFCIRCLE)) {
|
||||
circle = static_cast<TechDrawGeometry::Circle*> (base);
|
||||
if( (base && base->geomType == TechDraw::GeomType::CIRCLE) ||
|
||||
(base && base->geomType == TechDraw::GeomType::ARCOFCIRCLE)) {
|
||||
circle = static_cast<TechDraw::Circle*> (base);
|
||||
pts.center = Base::Vector3d(circle->center.x,circle->center.y,0.0);
|
||||
pts.radius = circle->radius;
|
||||
if (base->geomType == TechDrawGeometry::GeomType::ARCOFCIRCLE) {
|
||||
TechDrawGeometry::AOC* aoc = static_cast<TechDrawGeometry::AOC*> (circle);
|
||||
if (base->geomType == TechDraw::GeomType::ARCOFCIRCLE) {
|
||||
TechDraw::AOC* aoc = static_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);
|
||||
@@ -284,9 +284,9 @@ App::DocumentObjectExecReturn *DrawViewDimension::execute(void)
|
||||
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 == TechDrawGeometry::GeomType::ELLIPSE) ||
|
||||
(base && base->geomType == TechDrawGeometry::GeomType::ARCOFELLIPSE)) {
|
||||
TechDrawGeometry::Ellipse* ellipse = static_cast<TechDrawGeometry::Ellipse*> (base);
|
||||
} else if ((base && base->geomType == TechDraw::GeomType::ELLIPSE) ||
|
||||
(base && base->geomType == TechDraw::GeomType::ARCOFELLIPSE)) {
|
||||
TechDraw::Ellipse* ellipse = static_cast<TechDraw::Ellipse*> (base);
|
||||
if (ellipse->closed()) {
|
||||
double r1 = ellipse->minor;
|
||||
double r2 = ellipse->major;
|
||||
@@ -299,7 +299,7 @@ App::DocumentObjectExecReturn *DrawViewDimension::execute(void)
|
||||
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 {
|
||||
TechDrawGeometry::AOE* aoe = static_cast<TechDrawGeometry::AOE*> (base);
|
||||
TechDraw::AOE* aoe = static_cast<TechDraw::AOE*> (base);
|
||||
double r1 = aoe->minor;
|
||||
double r2 = aoe->major;
|
||||
double rAvg = (r1 + r2) / 2.0;
|
||||
@@ -315,8 +315,8 @@ App::DocumentObjectExecReturn *DrawViewDimension::execute(void)
|
||||
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 == TechDrawGeometry::GeomType::BSPLINE) {
|
||||
TechDrawGeometry::BSpline* spline = static_cast<TechDrawGeometry::BSpline*> (base);
|
||||
} else if (base && base->geomType == TechDraw::GeomType::BSPLINE) {
|
||||
TechDraw::BSpline* spline = static_cast<TechDraw::BSpline*> (base);
|
||||
if (spline->isCircle()) {
|
||||
bool circ,arc;
|
||||
double rad;
|
||||
@@ -348,18 +348,18 @@ App::DocumentObjectExecReturn *DrawViewDimension::execute(void)
|
||||
m_hasGeometry = true;
|
||||
} else if(Type.isValue("Diameter")){
|
||||
int idx = DrawUtil::getIndexFromName(subElements[0]);
|
||||
TechDrawGeometry::BaseGeom* base = getViewPart()->getProjEdgeByIndex(idx);
|
||||
TechDrawGeometry::Circle* circle;
|
||||
TechDraw::BaseGeom* base = getViewPart()->getProjEdgeByIndex(idx);
|
||||
TechDraw::Circle* circle;
|
||||
arcPoints pts;
|
||||
pts.center = Base::Vector3d(0.0,0.0,0.0);
|
||||
pts.radius = 0.0;
|
||||
if ((base && base->geomType == TechDrawGeometry::GeomType::CIRCLE) ||
|
||||
(base && base->geomType == TechDrawGeometry::GeomType::ARCOFCIRCLE)) {
|
||||
circle = static_cast<TechDrawGeometry::Circle*> (base);
|
||||
if ((base && base->geomType == TechDraw::GeomType::CIRCLE) ||
|
||||
(base && base->geomType == TechDraw::GeomType::ARCOFCIRCLE)) {
|
||||
circle = static_cast<TechDraw::Circle*> (base);
|
||||
pts.center = Base::Vector3d(circle->center.x,circle->center.y,0.0);
|
||||
pts.radius = circle->radius;
|
||||
if (base->geomType == TechDrawGeometry::GeomType::ARCOFCIRCLE) {
|
||||
TechDrawGeometry::AOC* aoc = static_cast<TechDrawGeometry::AOC*> (circle);
|
||||
if (base->geomType == TechDraw::GeomType::ARCOFCIRCLE) {
|
||||
TechDraw::AOC* aoc = static_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);
|
||||
@@ -371,9 +371,9 @@ App::DocumentObjectExecReturn *DrawViewDimension::execute(void)
|
||||
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 == TechDrawGeometry::GeomType::ELLIPSE) ||
|
||||
(base && base->geomType == TechDrawGeometry::GeomType::ARCOFELLIPSE) ) {
|
||||
TechDrawGeometry::Ellipse* ellipse = static_cast<TechDrawGeometry::Ellipse*> (base);
|
||||
} else if ( (base && base->geomType == TechDraw::GeomType::ELLIPSE) ||
|
||||
(base && base->geomType == TechDraw::GeomType::ARCOFELLIPSE) ) {
|
||||
TechDraw::Ellipse* ellipse = static_cast<TechDraw::Ellipse*> (base);
|
||||
if (ellipse->closed()) {
|
||||
double r1 = ellipse->minor;
|
||||
double r2 = ellipse->major;
|
||||
@@ -386,7 +386,7 @@ App::DocumentObjectExecReturn *DrawViewDimension::execute(void)
|
||||
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 {
|
||||
TechDrawGeometry::AOE* aoe = static_cast<TechDrawGeometry::AOE*> (base);
|
||||
TechDraw::AOE* aoe = static_cast<TechDraw::AOE*> (base);
|
||||
double r1 = aoe->minor;
|
||||
double r2 = aoe->major;
|
||||
double rAvg = (r1 + r2) / 2.0;
|
||||
@@ -402,8 +402,8 @@ App::DocumentObjectExecReturn *DrawViewDimension::execute(void)
|
||||
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 == TechDrawGeometry::GeomType::BSPLINE) {
|
||||
TechDrawGeometry::BSpline* spline = static_cast<TechDrawGeometry::BSpline*> (base);
|
||||
} else if (base && base->geomType == TechDraw::GeomType::BSPLINE) {
|
||||
TechDraw::BSpline* spline = static_cast<TechDraw::BSpline*> (base);
|
||||
if (spline->isCircle()) {
|
||||
bool circ,arc;
|
||||
double rad;
|
||||
@@ -440,37 +440,37 @@ App::DocumentObjectExecReturn *DrawViewDimension::execute(void)
|
||||
}
|
||||
int idx0 = DrawUtil::getIndexFromName(subElements[0]);
|
||||
int idx1 = DrawUtil::getIndexFromName(subElements[1]);
|
||||
TechDrawGeometry::BaseGeom* edge0 = getViewPart()->getProjEdgeByIndex(idx0);
|
||||
TechDrawGeometry::BaseGeom* edge1 = getViewPart()->getProjEdgeByIndex(idx1);
|
||||
TechDrawGeometry::Generic *gen0;
|
||||
TechDrawGeometry::Generic *gen1;
|
||||
if (edge0 && edge0->geomType == TechDrawGeometry::GeomType::GENERIC) {
|
||||
gen0 = static_cast<TechDrawGeometry::Generic*>(edge0);
|
||||
TechDraw::BaseGeom* edge0 = getViewPart()->getProjEdgeByIndex(idx0);
|
||||
TechDraw::BaseGeom* edge1 = getViewPart()->getProjEdgeByIndex(idx1);
|
||||
TechDraw::Generic *gen0;
|
||||
TechDraw::Generic *gen1;
|
||||
if (edge0 && edge0->geomType == TechDraw::GeomType::GENERIC) {
|
||||
gen0 = static_cast<TechDraw::Generic*>(edge0);
|
||||
} else {
|
||||
Base::Console().Log("Error: DVD - %s - 2D references are corrupt\n",getNameInDocument());
|
||||
return App::DocumentObject::StdReturn;
|
||||
}
|
||||
if (edge1 && edge1->geomType == TechDrawGeometry::GeomType::GENERIC) {
|
||||
gen1 = static_cast<TechDrawGeometry::Generic*>(edge1);
|
||||
if (edge1 && edge1->geomType == TechDraw::GeomType::GENERIC) {
|
||||
gen1 = static_cast<TechDraw::Generic*>(edge1);
|
||||
} else {
|
||||
Base::Console().Log("Error: DVD - %s - 2D references are corrupt\n",getNameInDocument());
|
||||
return App::DocumentObject::StdReturn;
|
||||
}
|
||||
|
||||
anglePoints pts;
|
||||
Base::Vector3d apex = DrawUtil::vector23(gen0->apparentInter(gen1));
|
||||
Base::Vector3d apex = gen0->apparentInter(gen1);
|
||||
Base::Vector3d extPoint0,extPoint1;
|
||||
if ((DrawUtil::vector23(gen0->getStartPoint()) - apex).Length() >
|
||||
(DrawUtil::vector23(gen0->getEndPoint()) - apex).Length()) {
|
||||
extPoint0 = DrawUtil::vector23(gen0->getStartPoint());
|
||||
if ((gen0->getStartPoint() - apex).Length() >
|
||||
(gen0->getEndPoint() - apex).Length()) {
|
||||
extPoint0 = gen0->getStartPoint();
|
||||
} else {
|
||||
extPoint0 = DrawUtil::vector23(gen0->getEndPoint());
|
||||
extPoint0 = gen0->getEndPoint();
|
||||
}
|
||||
if ((DrawUtil::vector23(gen1->getStartPoint()) - apex).Length() >
|
||||
(DrawUtil::vector23(gen1->getEndPoint()) - apex).Length()) {
|
||||
extPoint1 = DrawUtil::vector23(gen1->getStartPoint());
|
||||
if ((gen1->getStartPoint() - apex).Length() >
|
||||
(gen1->getEndPoint() - apex).Length()) {
|
||||
extPoint1 = gen1->getStartPoint();
|
||||
} else {
|
||||
extPoint1 = DrawUtil::vector23(gen1->getEndPoint());
|
||||
extPoint1 = gen1->getEndPoint();
|
||||
}
|
||||
pts.ends.first = extPoint0;
|
||||
pts.ends.second = extPoint1;
|
||||
@@ -486,18 +486,18 @@ App::DocumentObjectExecReturn *DrawViewDimension::execute(void)
|
||||
int idx1 = DrawUtil::getIndexFromName(subElements[1]);
|
||||
int idx2 = DrawUtil::getIndexFromName(subElements[2]);
|
||||
|
||||
TechDrawGeometry::Vertex* vert0 = getViewPart()->getProjVertexByIndex(idx0);
|
||||
TechDrawGeometry::Vertex* vert1 = getViewPart()->getProjVertexByIndex(idx1);
|
||||
TechDrawGeometry::Vertex* vert2 = getViewPart()->getProjVertexByIndex(idx2);
|
||||
TechDraw::Vertex* vert0 = getViewPart()->getProjVertexByIndex(idx0);
|
||||
TechDraw::Vertex* vert1 = getViewPart()->getProjVertexByIndex(idx1);
|
||||
TechDraw::Vertex* vert2 = getViewPart()->getProjVertexByIndex(idx2);
|
||||
if (!vert0 || !vert1 || !vert2) {
|
||||
Base::Console().Log("Error: DVD - %s - 2D references are corrupt\n",getNameInDocument());
|
||||
return App::DocumentObject::StdReturn;
|
||||
}
|
||||
|
||||
anglePoints pts;
|
||||
Base::Vector3d apex = vert1->getAs3D();
|
||||
Base::Vector3d extPoint0 = vert0->getAs3D();
|
||||
Base::Vector3d extPoint2 = vert2->getAs3D();
|
||||
Base::Vector3d apex = vert1->point();
|
||||
Base::Vector3d extPoint0 = vert0->point();
|
||||
Base::Vector3d extPoint2 = vert2->point();
|
||||
pts.ends.first = extPoint0;
|
||||
pts.ends.second = extPoint2;
|
||||
pts.vertex = apex;
|
||||
@@ -723,16 +723,16 @@ pointPair DrawViewDimension::getPointsOneEdge()
|
||||
|
||||
//TODO: Check for straight line Edge?
|
||||
int idx = DrawUtil::getIndexFromName(subElements[0]);
|
||||
TechDrawGeometry::BaseGeom* geom = getViewPart()->getProjEdgeByIndex(idx);
|
||||
TechDrawGeometry::Generic* gen;
|
||||
if (geom && geom->geomType == TechDrawGeometry::GeomType::GENERIC) {
|
||||
gen = static_cast<TechDrawGeometry::Generic*>(geom);
|
||||
TechDraw::BaseGeom* geom = getViewPart()->getProjEdgeByIndex(idx);
|
||||
TechDraw::Generic* gen;
|
||||
if (geom && geom->geomType == TechDraw::GeomType::GENERIC) {
|
||||
gen = static_cast<TechDraw::Generic*>(geom);
|
||||
} else {
|
||||
Base::Console().Error("Error: DVD - %s - 2D references are corrupt\n",getNameInDocument());
|
||||
return result;
|
||||
}
|
||||
result.first = DrawUtil::vector23(gen->points[0]);
|
||||
result.second = DrawUtil::vector23(gen->points[1]);
|
||||
result.first = gen->points[0];
|
||||
result.second = gen->points[1];
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -744,8 +744,8 @@ pointPair DrawViewDimension::getPointsTwoEdges()
|
||||
|
||||
int idx0 = DrawUtil::getIndexFromName(subElements[0]);
|
||||
int idx1 = DrawUtil::getIndexFromName(subElements[1]);
|
||||
TechDrawGeometry::BaseGeom* geom0 = getViewPart()->getProjEdgeByIndex(idx0);
|
||||
TechDrawGeometry::BaseGeom* geom1 = getViewPart()->getProjEdgeByIndex(idx1);
|
||||
TechDraw::BaseGeom* geom0 = getViewPart()->getProjEdgeByIndex(idx0);
|
||||
TechDraw::BaseGeom* geom1 = getViewPart()->getProjEdgeByIndex(idx1);
|
||||
if ((geom0 == nullptr) ||
|
||||
(geom1 == nullptr) ) {
|
||||
Base::Console().Error("Error: DVD - %s - 2D references are corrupt\n",getNameInDocument());
|
||||
@@ -763,15 +763,15 @@ pointPair DrawViewDimension::getPointsTwoVerts()
|
||||
|
||||
int idx0 = DrawUtil::getIndexFromName(subElements[0]);
|
||||
int idx1 = DrawUtil::getIndexFromName(subElements[1]);
|
||||
TechDrawGeometry::Vertex* v0 = getViewPart()->getProjVertexByIndex(idx0);
|
||||
TechDrawGeometry::Vertex* v1 = getViewPart()->getProjVertexByIndex(idx1);
|
||||
TechDraw::Vertex* v0 = getViewPart()->getProjVertexByIndex(idx0);
|
||||
TechDraw::Vertex* v1 = getViewPart()->getProjVertexByIndex(idx1);
|
||||
if ((v0 == nullptr) ||
|
||||
(v1 == nullptr) ) {
|
||||
Base::Console().Error("Error: DVD - %s - 2D references are corrupt\n",getNameInDocument());
|
||||
return result;
|
||||
}
|
||||
result.first = DrawUtil::vector23(v0->pnt);
|
||||
result.second = DrawUtil::vector23(v1->pnt);
|
||||
result.first = v0->pnt;
|
||||
result.second = v1->pnt;
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -783,8 +783,8 @@ pointPair DrawViewDimension::getPointsEdgeVert()
|
||||
|
||||
int idx0 = DrawUtil::getIndexFromName(subElements[0]);
|
||||
int idx1 = DrawUtil::getIndexFromName(subElements[1]);
|
||||
TechDrawGeometry::BaseGeom* e;
|
||||
TechDrawGeometry::Vertex* v;
|
||||
TechDraw::BaseGeom* e;
|
||||
TechDraw::Vertex* v;
|
||||
if (DrawUtil::getGeomTypeFromName(subElements[0]) == "Edge") {
|
||||
e = getViewPart()->getProjEdgeByIndex(idx0);
|
||||
v = getViewPart()->getProjVertexByIndex(idx1);
|
||||
@@ -882,13 +882,13 @@ bool DrawViewDimension::checkReferences2D() const
|
||||
if (!s.empty()) {
|
||||
int idx = DrawUtil::getIndexFromName(s);
|
||||
if (DrawUtil::getGeomTypeFromName(s) == "Edge") {
|
||||
TechDrawGeometry::BaseGeom* geom = getViewPart()->getProjEdgeByIndex(idx);
|
||||
TechDraw::BaseGeom* geom = getViewPart()->getProjEdgeByIndex(idx);
|
||||
if (geom == nullptr) {
|
||||
result = false;
|
||||
break;
|
||||
}
|
||||
} else if (DrawUtil::getGeomTypeFromName(s) == "Vertex") {
|
||||
TechDrawGeometry::Vertex* v = getViewPart()->getProjVertexByIndex(idx);
|
||||
TechDraw::Vertex* v = getViewPart()->getProjVertexByIndex(idx);
|
||||
if (v == nullptr) {
|
||||
result = false;
|
||||
break;
|
||||
@@ -961,10 +961,10 @@ void DrawViewDimension::dumpRefs2D(char* text) const
|
||||
}
|
||||
}
|
||||
|
||||
double DrawViewDimension::dist2Segs(Base::Vector2d s1,
|
||||
Base::Vector2d e1,
|
||||
Base::Vector2d s2,
|
||||
Base::Vector2d e2) const
|
||||
double DrawViewDimension::dist2Segs(Base::Vector3d s1,
|
||||
Base::Vector3d e1,
|
||||
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);
|
||||
@@ -997,14 +997,14 @@ bool DrawViewDimension::leaderIntersectsArc(Base::Vector3d s, Base::Vector3d poi
|
||||
bool result = false;
|
||||
const std::vector<std::string> &subElements = References2D.getSubValues();
|
||||
int idx = DrawUtil::getIndexFromName(subElements[0]);
|
||||
TechDrawGeometry::BaseGeom* base = getViewPart()->getProjEdgeByIndex(idx);
|
||||
if( base && base->geomType == TechDrawGeometry::GeomType::ARCOFCIRCLE ) {
|
||||
TechDrawGeometry::AOC* aoc = static_cast<TechDrawGeometry::AOC*> (base);
|
||||
TechDraw::BaseGeom* base = getViewPart()->getProjEdgeByIndex(idx);
|
||||
if( base && base->geomType == TechDraw::GeomType::ARCOFCIRCLE ) {
|
||||
TechDraw::AOC* aoc = static_cast<TechDraw::AOC*> (base);
|
||||
if (aoc->intersectsArc(s,pointOnCircle)) {
|
||||
result = true;
|
||||
}
|
||||
} else if( base && base->geomType == TechDrawGeometry::GeomType::BSPLINE ) {
|
||||
TechDrawGeometry::BSpline* spline = static_cast<TechDrawGeometry::BSpline*> (base);
|
||||
} else if( base && base->geomType == TechDraw::GeomType::BSPLINE ) {
|
||||
TechDraw::BSpline* spline = static_cast<TechDraw::BSpline*> (base);
|
||||
if (spline->isCircle()) {
|
||||
if (spline->intersectsArc(s,pointOnCircle)) {
|
||||
result = true;
|
||||
|
||||
@@ -152,10 +152,10 @@ protected:
|
||||
|
||||
protected:
|
||||
Measure::Measurement *measurement;
|
||||
double dist2Segs(Base::Vector2d s1,
|
||||
Base::Vector2d e1,
|
||||
Base::Vector2d s2,
|
||||
Base::Vector2d e2) const;
|
||||
double dist2Segs(Base::Vector3d s1,
|
||||
Base::Vector3d e1,
|
||||
Base::Vector3d s2,
|
||||
Base::Vector3d e2) const;
|
||||
pointPair closestPoints(TopoDS_Shape s1,
|
||||
TopoDS_Shape s2) const;
|
||||
|
||||
|
||||
@@ -139,15 +139,15 @@ App::DocumentObjectExecReturn *DrawViewMulti::execute(void)
|
||||
|
||||
gp_Pnt inputCenter;
|
||||
try {
|
||||
inputCenter = TechDrawGeometry::findCentroid(comp,
|
||||
inputCenter = TechDraw::findCentroid(comp,
|
||||
Direction.getValue());
|
||||
shapeCentroid = Base::Vector3d(inputCenter.X(),inputCenter.Y(),inputCenter.Z());
|
||||
TopoDS_Shape mirroredShape = TechDrawGeometry::mirrorShape(comp,
|
||||
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)) {
|
||||
mirroredShape = TechDrawGeometry::rotateShape(mirroredShape,
|
||||
mirroredShape = TechDraw::rotateShape(mirroredShape,
|
||||
viewAxis,
|
||||
Rotation.getValue());
|
||||
}
|
||||
|
||||
@@ -37,7 +37,7 @@
|
||||
class gp_Pln;
|
||||
class TopoDS_Face;
|
||||
|
||||
namespace TechDrawGeometry
|
||||
namespace TechDraw
|
||||
{
|
||||
//class Face;
|
||||
}
|
||||
|
||||
@@ -154,12 +154,6 @@ DrawViewPart::DrawViewPart(void) :
|
||||
|
||||
geometryObject = nullptr;
|
||||
getRunControl();
|
||||
|
||||
// Base::Vector3d org(0.0,0.0,0.0); //App side coords
|
||||
// addRandomVertex(org);
|
||||
// Base::Vector3d pt(11.0,11.0,0.0);
|
||||
// addRandomVertex(pt);
|
||||
|
||||
}
|
||||
|
||||
DrawViewPart::~DrawViewPart()
|
||||
@@ -291,8 +285,8 @@ App::DocumentObjectExecReturn *DrawViewPart::execute(void)
|
||||
}
|
||||
|
||||
rebuildCosmoVertex();
|
||||
rebuildCosmoEdge();
|
||||
|
||||
// rebuildCosmoEdge();
|
||||
|
||||
App::Document* doc = getDocument();
|
||||
bool isRestoring = doc->testStatus(App::Document::Status::Restoring);
|
||||
const std::vector<App::DocumentObject*>& links = Source.getValues();
|
||||
@@ -322,18 +316,18 @@ App::DocumentObjectExecReturn *DrawViewPart::execute(void)
|
||||
gp_Pnt inputCenter;
|
||||
Base::Vector3d stdOrg(0.0,0.0,0.0);
|
||||
|
||||
inputCenter = TechDrawGeometry::findCentroid(shape,
|
||||
inputCenter = TechDraw::findCentroid(shape,
|
||||
getViewAxis(stdOrg,Direction.getValue()));
|
||||
|
||||
shapeCentroid = Base::Vector3d(inputCenter.X(),inputCenter.Y(),inputCenter.Z());
|
||||
TopoDS_Shape mirroredShape;
|
||||
mirroredShape = TechDrawGeometry::mirrorShape(shape,
|
||||
mirroredShape = TechDraw::mirrorShape(shape,
|
||||
inputCenter,
|
||||
getScale());
|
||||
|
||||
gp_Ax2 viewAxis = getViewAxis(shapeCentroid,Direction.getValue());
|
||||
if (!DrawUtil::fpCompare(Rotation.getValue(),0.0)) {
|
||||
mirroredShape = TechDrawGeometry::rotateShape(mirroredShape,
|
||||
mirroredShape = TechDraw::rotateShape(mirroredShape,
|
||||
viewAxis,
|
||||
Rotation.getValue());
|
||||
}
|
||||
@@ -352,16 +346,16 @@ App::DocumentObjectExecReturn *DrawViewPart::execute(void)
|
||||
}
|
||||
|
||||
//add back the cosmetic vertices
|
||||
for (auto& v: cosmoVertex) {
|
||||
int idx = geometryObject->addRandomVertex(v->pageLocation * getScale());
|
||||
for (auto& v: vertexCosmetic) {
|
||||
int idx = geometryObject->addCosmeticVertex(v->point() * 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;
|
||||
for (auto& e: edgeCosmetic) {
|
||||
TechDraw::BaseGeom* scaledGeom = e->scaledGeometry(getScale());
|
||||
int idx = geometryObject->addCosmeticEdge(scaledGeom);
|
||||
e->m_linkGeom = idx;
|
||||
}
|
||||
|
||||
auto end = chrono::high_resolution_clock::now();
|
||||
@@ -373,7 +367,6 @@ App::DocumentObjectExecReturn *DrawViewPart::execute(void)
|
||||
#endif //#if MOD_TECHDRAW_HANDLE_FACES
|
||||
|
||||
requestPaint();
|
||||
// Base::Console().Message("DVP::execute - %s - exits\n",getNameInDocument());
|
||||
return App::DocumentObject::StdReturn;
|
||||
}
|
||||
|
||||
@@ -412,10 +405,10 @@ void DrawViewPart::onChanged(const App::Property* prop)
|
||||
}
|
||||
|
||||
//note: slightly different than routine with same name in DrawProjectSplit
|
||||
TechDrawGeometry::GeometryObject* DrawViewPart::buildGeometryObject(TopoDS_Shape shape, gp_Ax2 viewAxis)
|
||||
TechDraw::GeometryObject* DrawViewPart::buildGeometryObject(TopoDS_Shape shape, gp_Ax2 viewAxis)
|
||||
{
|
||||
// Base::Console().Message("DVP::buildGO() - %s\n", getNameInDocument());
|
||||
TechDrawGeometry::GeometryObject* go = new TechDrawGeometry::GeometryObject(getNameInDocument(), this);
|
||||
TechDraw::GeometryObject* go = new TechDraw::GeometryObject(getNameInDocument(), this);
|
||||
go->setIsoCount(IsoCount.getValue());
|
||||
go->isPerspective(Perspective.getValue());
|
||||
go->setFocus(Focus.getValue());
|
||||
@@ -435,38 +428,38 @@ TechDrawGeometry::GeometryObject* DrawViewPart::buildGeometryObject(TopoDS_Shape
|
||||
|
||||
auto start = chrono::high_resolution_clock::now();
|
||||
|
||||
go->extractGeometry(TechDrawGeometry::ecHARD, //always show the hard&outline visible lines
|
||||
go->extractGeometry(TechDraw::ecHARD, //always show the hard&outline visible lines
|
||||
true);
|
||||
go->extractGeometry(TechDrawGeometry::ecOUTLINE,
|
||||
go->extractGeometry(TechDraw::ecOUTLINE,
|
||||
true);
|
||||
if (SmoothVisible.getValue()) {
|
||||
go->extractGeometry(TechDrawGeometry::ecSMOOTH,
|
||||
go->extractGeometry(TechDraw::ecSMOOTH,
|
||||
true);
|
||||
}
|
||||
if (SeamVisible.getValue()) {
|
||||
go->extractGeometry(TechDrawGeometry::ecSEAM,
|
||||
go->extractGeometry(TechDraw::ecSEAM,
|
||||
true);
|
||||
}
|
||||
if ((IsoVisible.getValue()) && (IsoCount.getValue() > 0)) {
|
||||
go->extractGeometry(TechDrawGeometry::ecUVISO,
|
||||
go->extractGeometry(TechDraw::ecUVISO,
|
||||
true);
|
||||
}
|
||||
if (HardHidden.getValue()) {
|
||||
go->extractGeometry(TechDrawGeometry::ecHARD,
|
||||
go->extractGeometry(TechDraw::ecHARD,
|
||||
false);
|
||||
go->extractGeometry(TechDrawGeometry::ecOUTLINE,
|
||||
go->extractGeometry(TechDraw::ecOUTLINE,
|
||||
false);
|
||||
}
|
||||
if (SmoothHidden.getValue()) {
|
||||
go->extractGeometry(TechDrawGeometry::ecSMOOTH,
|
||||
go->extractGeometry(TechDraw::ecSMOOTH,
|
||||
false);
|
||||
}
|
||||
if (SeamHidden.getValue()) {
|
||||
go->extractGeometry(TechDrawGeometry::ecSEAM,
|
||||
go->extractGeometry(TechDraw::ecSEAM,
|
||||
false);
|
||||
}
|
||||
if (IsoHidden.getValue() && (IsoCount.getValue() > 0)) {
|
||||
go->extractGeometry(TechDrawGeometry::ecUVISO,
|
||||
go->extractGeometry(TechDraw::ecUVISO,
|
||||
false);
|
||||
}
|
||||
auto end = chrono::high_resolution_clock::now();
|
||||
@@ -474,7 +467,7 @@ TechDrawGeometry::GeometryObject* DrawViewPart::buildGeometryObject(TopoDS_Shape
|
||||
double diffOut = chrono::duration <double, milli> (diff).count();
|
||||
Base::Console().Log("TIMING - %s DVP spent: %.3f millisecs in GO::extractGeometry\n",getNameInDocument(),diffOut);
|
||||
|
||||
const std::vector<TechDrawGeometry::BaseGeom *> & edges = go->getEdgeGeometry();
|
||||
const std::vector<TechDraw::BaseGeom *> & edges = go->getEdgeGeometry();
|
||||
if (edges.empty()) {
|
||||
Base::Console().Log("DVP::buildGO - NO extracted edges!\n");
|
||||
}
|
||||
@@ -486,9 +479,9 @@ TechDrawGeometry::GeometryObject* DrawViewPart::buildGeometryObject(TopoDS_Shape
|
||||
void DrawViewPart::extractFaces()
|
||||
{
|
||||
geometryObject->clearFaceGeom();
|
||||
const std::vector<TechDrawGeometry::BaseGeom*>& goEdges =
|
||||
const std::vector<TechDraw::BaseGeom*>& goEdges =
|
||||
geometryObject->getVisibleFaceEdges(SmoothVisible.getValue(),SeamVisible.getValue());
|
||||
std::vector<TechDrawGeometry::BaseGeom*>::const_iterator itEdge = goEdges.begin();
|
||||
std::vector<TechDraw::BaseGeom*>::const_iterator itEdge = goEdges.begin();
|
||||
std::vector<TopoDS_Edge> origEdges;
|
||||
for (;itEdge != goEdges.end(); itEdge++) {
|
||||
origEdges.push_back((*itEdge)->occEdge);
|
||||
@@ -594,9 +587,9 @@ void DrawViewPart::extractFaces()
|
||||
std::vector<TopoDS_Wire>::iterator itWire = sortedWires.begin();
|
||||
for (; itWire != sortedWires.end(); itWire++) {
|
||||
//version 1: 1 wire/face - no voids in face
|
||||
TechDrawGeometry::Face* f = new TechDrawGeometry::Face();
|
||||
TechDraw::Face* f = new TechDraw::Face();
|
||||
const TopoDS_Wire& wire = (*itWire);
|
||||
TechDrawGeometry::Wire* w = new TechDrawGeometry::Wire(wire);
|
||||
TechDraw::Wire* w = new TechDraw::Wire(wire);
|
||||
f->wires.push_back(w);
|
||||
geometryObject->addFaceGeom(f);
|
||||
}
|
||||
@@ -659,25 +652,25 @@ std::vector<TechDraw::DrawViewBalloon*> DrawViewPart::getBalloons() const
|
||||
return result;
|
||||
}
|
||||
|
||||
const std::vector<TechDrawGeometry::Vertex *> & DrawViewPart::getVertexGeometry() const
|
||||
const std::vector<TechDraw::Vertex *> & DrawViewPart::getVertexGeometry() const
|
||||
{
|
||||
return geometryObject->getVertexGeometry();
|
||||
}
|
||||
|
||||
const std::vector<TechDrawGeometry::Face *> & DrawViewPart::getFaceGeometry() const
|
||||
const std::vector<TechDraw::Face *> & DrawViewPart::getFaceGeometry() const
|
||||
{
|
||||
return geometryObject->getFaceGeometry();
|
||||
}
|
||||
|
||||
const std::vector<TechDrawGeometry::BaseGeom *> & DrawViewPart::getEdgeGeometry() const
|
||||
const std::vector<TechDraw::BaseGeom *> & DrawViewPart::getEdgeGeometry() const
|
||||
{
|
||||
return geometryObject->getEdgeGeometry();
|
||||
}
|
||||
|
||||
//! returns existing BaseGeom of 2D Edge(idx)
|
||||
TechDrawGeometry::BaseGeom* DrawViewPart::getProjEdgeByIndex(int idx) const
|
||||
TechDraw::BaseGeom* DrawViewPart::getProjEdgeByIndex(int idx) const
|
||||
{
|
||||
const std::vector<TechDrawGeometry::BaseGeom *> &geoms = getEdgeGeometry();
|
||||
const std::vector<TechDraw::BaseGeom *> &geoms = getEdgeGeometry();
|
||||
if (geoms.empty()) {
|
||||
Base::Console().Log("INFO - getProjEdgeByIndex(%d) - no Edge Geometry. Probably restoring?\n",idx);
|
||||
return NULL;
|
||||
@@ -690,9 +683,9 @@ TechDrawGeometry::BaseGeom* DrawViewPart::getProjEdgeByIndex(int idx) const
|
||||
}
|
||||
|
||||
//! returns existing geometry of 2D Vertex(idx)
|
||||
TechDrawGeometry::Vertex* DrawViewPart::getProjVertexByIndex(int idx) const
|
||||
TechDraw::Vertex* DrawViewPart::getProjVertexByIndex(int idx) const
|
||||
{
|
||||
const std::vector<TechDrawGeometry::Vertex *> &geoms = getVertexGeometry();
|
||||
const std::vector<TechDraw::Vertex *> &geoms = getVertexGeometry();
|
||||
if (geoms.empty()) {
|
||||
Base::Console().Log("INFO - getProjVertexByIndex(%d) - no Vertex Geometry. Probably restoring?\n",idx);
|
||||
return NULL;
|
||||
@@ -705,12 +698,12 @@ TechDrawGeometry::Vertex* DrawViewPart::getProjVertexByIndex(int idx) const
|
||||
}
|
||||
|
||||
//! returns existing geometry of 2D Face(idx)
|
||||
std::vector<TechDrawGeometry::BaseGeom*> DrawViewPart::getFaceEdgesByIndex(int idx) const
|
||||
std::vector<TechDraw::BaseGeom*> DrawViewPart::getFaceEdgesByIndex(int idx) const
|
||||
{
|
||||
std::vector<TechDrawGeometry::BaseGeom*> result;
|
||||
const std::vector<TechDrawGeometry::Face *>& faces = getFaceGeometry();
|
||||
std::vector<TechDraw::BaseGeom*> result;
|
||||
const std::vector<TechDraw::Face *>& faces = getFaceGeometry();
|
||||
if (idx < (int) faces.size()) {
|
||||
TechDrawGeometry::Face* projFace = faces.at(idx);
|
||||
TechDraw::Face* projFace = faces.at(idx);
|
||||
for (auto& w: projFace->wires) {
|
||||
for (auto& g:w->geoms) {
|
||||
if (g->cosmetic) {
|
||||
@@ -727,8 +720,8 @@ std::vector<TopoDS_Wire> DrawViewPart::getWireForFace(int idx) const
|
||||
{
|
||||
std::vector<TopoDS_Wire> result;
|
||||
std::vector<TopoDS_Edge> edges;
|
||||
const std::vector<TechDrawGeometry::Face *>& faces = getFaceGeometry();
|
||||
TechDrawGeometry::Face * ourFace = faces.at(idx);
|
||||
const std::vector<TechDraw::Face *>& faces = getFaceGeometry();
|
||||
TechDraw::Face * ourFace = faces.at(idx);
|
||||
for (auto& w:ourFace->wires) {
|
||||
edges.clear();
|
||||
int i = 0;
|
||||
@@ -800,8 +793,8 @@ bool DrawViewPart::hasGeometry(void) const
|
||||
if (geometryObject == nullptr) {
|
||||
return result;
|
||||
}
|
||||
const std::vector<TechDrawGeometry::Vertex*> &verts = getVertexGeometry();
|
||||
const std::vector<TechDrawGeometry::BaseGeom*> &edges = getEdgeGeometry();
|
||||
const std::vector<TechDraw::Vertex*> &verts = getVertexGeometry();
|
||||
const std::vector<TechDraw::BaseGeom*> &edges = getEdgeGeometry();
|
||||
if (verts.empty() &&
|
||||
edges.empty() ) {
|
||||
result = false;
|
||||
@@ -816,7 +809,7 @@ gp_Ax2 DrawViewPart::getViewAxis(const Base::Vector3d& pt,
|
||||
const Base::Vector3d& axis,
|
||||
const bool flip) const
|
||||
{
|
||||
gp_Ax2 viewAxis = TechDrawGeometry::getViewAxis(pt,axis,flip);
|
||||
gp_Ax2 viewAxis = TechDraw::getViewAxis(pt,axis,flip);
|
||||
|
||||
return viewAxis;
|
||||
}
|
||||
@@ -860,7 +853,7 @@ std::vector<DrawViewDetail*> DrawViewPart::getDetailRefs(void) const
|
||||
return result;
|
||||
}
|
||||
|
||||
const std::vector<TechDrawGeometry::BaseGeom *> DrawViewPart::getVisibleFaceEdges() const
|
||||
const std::vector<TechDraw::BaseGeom *> DrawViewPart::getVisibleFaceEdges() const
|
||||
{
|
||||
return geometryObject->getVisibleFaceEdges(SmoothVisible.getValue(),SeamVisible.getValue());
|
||||
}
|
||||
@@ -894,44 +887,6 @@ bool DrawViewPart::showSectionEdges(void)
|
||||
return m_sectionEdges;
|
||||
}
|
||||
|
||||
//build cosmoVertex from CosmeticVertexList
|
||||
void DrawViewPart::rebuildCosmoVertex(void)
|
||||
{
|
||||
// Base::Console().Message("DVP::rebuildCosmoVertx()\n");
|
||||
cosmoVertex.clear();
|
||||
std::vector<std::string> restoreVerts = CosmeticVertexList.getValues();
|
||||
for (auto& rv: restoreVerts) {
|
||||
if (!rv.empty()) {
|
||||
CosmeticVertex* cv = new CosmeticVertex();
|
||||
bool rc = cv->fromCSV(rv);
|
||||
if (rc) {
|
||||
cosmoVertex.push_back(cv);
|
||||
} else {
|
||||
delete cv;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//build cosmoEdge from CosmeticEdgeList
|
||||
void DrawViewPart::rebuildCosmoEdge(void)
|
||||
{
|
||||
// Base::Console().Message("DVP::rebuildCosmoEdge()\n");
|
||||
cosmoEdge.clear();
|
||||
std::vector<std::string> restoreEdges = CosmeticEdgeList.getValues();
|
||||
for (auto& re: restoreEdges) {
|
||||
if (!re.empty()) {
|
||||
CosmeticEdge* ce = new CosmeticEdge();
|
||||
bool rc = ce->fromCSV(re);
|
||||
if (rc) {
|
||||
cosmoEdge.push_back(ce);
|
||||
} else {
|
||||
delete ce;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//! remove features that are useless without this DVP
|
||||
//! hatches, geomhatches, dimensions,...
|
||||
void DrawViewPart::unsetupObject()
|
||||
@@ -1008,13 +963,51 @@ bool DrawViewPart::isIso(void) const
|
||||
//* Cosmetics
|
||||
//********
|
||||
|
||||
// adds a cosmetic vertex to cosmoVertex and CosmeticVertexList
|
||||
int DrawViewPart::addRandomVertex(Base::Vector3d pos)
|
||||
//build vertexCosmetic from CosmeticVertexList
|
||||
void DrawViewPart::rebuildCosmoVertex(void)
|
||||
{
|
||||
// Base::Console().Message("DVP::addRandomVertex(%s)\n", DrawUtil::formatVector(pos).c_str());
|
||||
int newIdx = -1;
|
||||
// Base::Console().Message("DVP::rebuildCosmoVertex()\n");
|
||||
vertexCosmetic.clear();
|
||||
std::vector<std::string> restoreVerts = CosmeticVertexList.getValues();
|
||||
for (auto& rv: restoreVerts) {
|
||||
if (!rv.empty()) {
|
||||
CosmeticVertex* cv = new CosmeticVertex();
|
||||
bool rc = cv->fromCSV(rv);
|
||||
if (rc) {
|
||||
vertexCosmetic.push_back(cv);
|
||||
} else {
|
||||
delete cv;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//build edgeCosmetic from CosmeticEdgeList
|
||||
void DrawViewPart::rebuildCosmoEdge(void)
|
||||
{
|
||||
// Base::Console().Message("DVP::rebuildCosmoEdge()\n");
|
||||
edgeCosmetic.clear();
|
||||
std::vector<std::string> restoreEdges = CosmeticEdgeList.getValues();
|
||||
for (auto& re: restoreEdges) {
|
||||
if (!re.empty()) {
|
||||
CosmeticEdge* ce = new CosmeticEdge();
|
||||
bool rc = ce->fromCSV(re);
|
||||
if (rc) {
|
||||
edgeCosmetic.push_back(ce);
|
||||
} else {
|
||||
delete ce;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// adds a cosmetic vertex to vertexCosmetic and CosmeticVertexList
|
||||
int DrawViewPart::addCosmeticVertex(Base::Vector3d pos)
|
||||
{
|
||||
// Base::Console().Message("DVP::addCosmeticVertex(%s)\n", DrawUtil::formatVector(pos).c_str());
|
||||
TechDraw::CosmeticVertex* rVert = new TechDraw::CosmeticVertex(pos);
|
||||
cosmoVertex.push_back(rVert);
|
||||
vertexCosmetic.push_back(rVert);
|
||||
int newIdx = (int) (vertexCosmetic.size() - 1);
|
||||
stuffCosmeticVertexList();
|
||||
return newIdx;
|
||||
}
|
||||
@@ -1031,12 +1024,12 @@ void DrawViewPart::stuffCosmeticVertexList(void)
|
||||
CosmeticVertexList.setValues(saveVerts);
|
||||
}
|
||||
|
||||
void DrawViewPart::removeRandomVertex(TechDraw::CosmeticVertex* cv)
|
||||
void DrawViewPart::removeCosmeticVertex(TechDraw::CosmeticVertex* cv)
|
||||
{
|
||||
// Base::Console().Message("DVP::removeRandomVertex(cv) - cvs in: %d\n", cosmoVertex.size());
|
||||
// Base::Console().Message("DVP::removeCosmeticVertex(cv) - cvs in: %d\n", vertexCosmetic.size());
|
||||
bool found = false;
|
||||
std::vector<TechDraw::CosmeticVertex*> newCosmoVertex;
|
||||
for (auto& v: cosmoVertex) {
|
||||
for (auto& v: vertexCosmetic) {
|
||||
if (cv == v) {
|
||||
found = true;
|
||||
continue;
|
||||
@@ -1049,16 +1042,16 @@ void DrawViewPart::removeRandomVertex(TechDraw::CosmeticVertex* cv)
|
||||
delete cv;
|
||||
}
|
||||
|
||||
cosmoVertex = newCosmoVertex;
|
||||
vertexCosmetic = newCosmoVertex;
|
||||
stuffCosmeticVertexList();
|
||||
recomputeFeature();
|
||||
}
|
||||
|
||||
void DrawViewPart::removeRandomVertex(int idx)
|
||||
void DrawViewPart::removeCosmeticVertex(int idx)
|
||||
{
|
||||
if (idx < (int) cosmoVertex.size()) {
|
||||
TechDraw::CosmeticVertex* cvSave = cosmoVertex.at(idx);
|
||||
cosmoVertex.erase(cosmoVertex.begin() + idx);
|
||||
if (idx < (int) vertexCosmetic.size()) {
|
||||
TechDraw::CosmeticVertex* cvSave = vertexCosmetic.at(idx);
|
||||
vertexCosmetic.erase(vertexCosmetic.begin() + idx);
|
||||
delete cvSave;
|
||||
}
|
||||
|
||||
@@ -1092,51 +1085,63 @@ TechDraw::CosmeticVertex* DrawViewPart::getCosmeticVertexByLink(int idx) const
|
||||
return result;
|
||||
}
|
||||
|
||||
void DrawViewPart::clearCV(void)
|
||||
void DrawViewPart::clearCosmeticVertices(void)
|
||||
{
|
||||
// Base::Console().Message("DVP::clearCV()\n");
|
||||
cosmoVertex.clear();
|
||||
// Base::Console().Message("DVP::clearCosmeticVertices()\n");
|
||||
vertexCosmetic.clear();
|
||||
std::vector<std::string> noVerts;
|
||||
CosmeticVertexList.setValues(noVerts);
|
||||
}
|
||||
|
||||
// adds a cosmetic edge to cosmoEdge and CosmeticEdgeList
|
||||
int DrawViewPart::addRandomEdge(Base::Vector3d p1, Base::Vector3d p2)
|
||||
void DrawViewPart::clearCosmeticEdges(void)
|
||||
{
|
||||
// Base::Console().Message("DVP::addRandomEdge(%s, %s)\n",
|
||||
// Base::Console().Message("DVP::clearCosmeticEdges()\n");
|
||||
edgeCosmetic.clear();
|
||||
std::vector<std::string> noEdges;
|
||||
CosmeticEdgeList.setValues(noEdges);
|
||||
}
|
||||
|
||||
// adds a cosmetic edge to edgeCosmetic and CosmeticEdgeList
|
||||
int DrawViewPart::addCosmeticEdge(Base::Vector3d p1, Base::Vector3d p2)
|
||||
{
|
||||
// Base::Console().Message("DVP::addCosmeticEdge(%s, %s)\n",
|
||||
// DrawUtil::formatVector(p1).c_str(),
|
||||
// DrawUtil::formatVector(p2).c_str());
|
||||
int newIdx = -1;
|
||||
TechDraw::CosmeticEdge* rEdge = new TechDraw::CosmeticEdge(p1, p2);
|
||||
cosmoEdge.push_back(rEdge);
|
||||
|
||||
//stuff stringList
|
||||
std::vector<std::string> saveEdges;
|
||||
const std::vector<TechDraw::CosmeticEdge*> cosEdges = getCosmeticEdge();
|
||||
for (auto& ce: cosEdges) {
|
||||
std::string csv = ce->toCSV();
|
||||
saveEdges.push_back(csv);
|
||||
}
|
||||
stuffCosmeticEdgeList();
|
||||
TechDraw::CosmeticEdge* ce = new TechDraw::CosmeticEdge(p1, p2);
|
||||
edgeCosmetic.push_back(ce);
|
||||
int newIdx = (int) (edgeCosmetic.size() - 1);
|
||||
// stuffCosmeticEdgeList();
|
||||
std::string csv = ce->toCSV();
|
||||
std::vector<std::string> edgeList = CosmeticEdgeList.getValues();
|
||||
edgeList.push_back(csv);
|
||||
CosmeticEdgeList.setValues(edgeList);
|
||||
return newIdx;
|
||||
}
|
||||
|
||||
int DrawViewPart::addRandomEdge(TopoDS_Edge e)
|
||||
int DrawViewPart::addCosmeticEdge(TopoDS_Edge e)
|
||||
{
|
||||
// Base::Console().Message("DVP::addRandomEdge(TopoDS_Edge)\n");
|
||||
int newIdx = -1;
|
||||
TechDraw::CosmeticEdge* rEdge = new TechDraw::CosmeticEdge(e);
|
||||
cosmoEdge.push_back(rEdge);
|
||||
stuffCosmeticEdgeList();
|
||||
// Base::Console().Message("DVP::addCosmeticEdge(TopoDS_Edge)\n");
|
||||
TechDraw::CosmeticEdge* ce = new TechDraw::CosmeticEdge(e);
|
||||
edgeCosmetic.push_back(ce);
|
||||
int newIdx = (int) (edgeCosmetic.size() - 1);
|
||||
// stuffCosmeticEdgeList();
|
||||
std::string csv = ce->toCSV();
|
||||
std::vector<std::string> edgeList = CosmeticEdgeList.getValues();
|
||||
edgeList.push_back(csv);
|
||||
CosmeticEdgeList.setValues(edgeList);
|
||||
return newIdx;
|
||||
}
|
||||
|
||||
int DrawViewPart::addRandomEdge(CosmeticEdge* ce)
|
||||
int DrawViewPart::addCosmeticEdge(CosmeticEdge* ce)
|
||||
{
|
||||
// Base::Console().Message("DVP::addRandomEdge(CosmeticEdge)\n");
|
||||
int newIdx = -1;
|
||||
cosmoEdge.push_back(ce);
|
||||
stuffCosmeticEdgeList();
|
||||
// Base::Console().Message("DVP::addCosmeticEdge(CosmeticEdge)\n");
|
||||
edgeCosmetic.push_back(ce);
|
||||
int newIdx = (int) (edgeCosmetic.size() - 1);
|
||||
// stuffCosmeticEdgeList();
|
||||
std::string csv = ce->toCSV();
|
||||
std::vector<std::string> edgeList = CosmeticEdgeList.getValues();
|
||||
edgeList.push_back(csv);
|
||||
CosmeticEdgeList.setValues(edgeList);
|
||||
return newIdx;
|
||||
}
|
||||
|
||||
@@ -1152,12 +1157,12 @@ void DrawViewPart::stuffCosmeticEdgeList(void)
|
||||
CosmeticEdgeList.setValues(saveEdges);
|
||||
}
|
||||
|
||||
void DrawViewPart::removeRandomEdge(TechDraw::CosmeticEdge* ce)
|
||||
void DrawViewPart::removeCosmeticEdge(TechDraw::CosmeticEdge* ce)
|
||||
{
|
||||
// Base::Console().Message("DVP::removeRandomEdge(ce) - ces in: %d\n", cosmoEdge.size());
|
||||
// Base::Console().Message("DVP::removeCosmeticEdge(ce) - ces in: %d\n", edgeCosmetic.size());
|
||||
bool found = false;
|
||||
std::vector<TechDraw::CosmeticEdge*> newCosmoEdge;
|
||||
for (auto& e: cosmoEdge) {
|
||||
for (auto& e: edgeCosmetic) {
|
||||
if (ce == e) {
|
||||
found = true;
|
||||
continue;
|
||||
@@ -1169,17 +1174,17 @@ void DrawViewPart::removeRandomEdge(TechDraw::CosmeticEdge* ce)
|
||||
(found) ) {
|
||||
delete ce;
|
||||
}
|
||||
cosmoEdge = newCosmoEdge;
|
||||
edgeCosmetic = newCosmoEdge;
|
||||
stuffCosmeticEdgeList();
|
||||
recomputeFeature();
|
||||
}
|
||||
|
||||
void DrawViewPart::removeRandomEdge(int idx)
|
||||
void DrawViewPart::removeCosmeticEdge(int idx)
|
||||
{
|
||||
// Base::Console().Message("DVP::removeRandomEdge(%d) - ces in: %d\n", idx, cosmoEdge.size());
|
||||
if (idx < (int) cosmoEdge.size()) {
|
||||
TechDraw::CosmeticEdge* ceSave = cosmoEdge.at(idx);
|
||||
cosmoEdge.erase(cosmoEdge.begin() + idx);
|
||||
// Base::Console().Message("DVP::removeCosmeticEdge(%d) - ces in: %d\n", idx, edgeCosmetic.size());
|
||||
if (idx < (int) edgeCosmetic.size()) {
|
||||
TechDraw::CosmeticEdge* ceSave = edgeCosmetic.at(idx);
|
||||
edgeCosmetic.erase(edgeCosmetic.begin() + idx);
|
||||
delete ceSave;
|
||||
}
|
||||
stuffCosmeticEdgeList();
|
||||
@@ -1204,7 +1209,7 @@ TechDraw::CosmeticEdge* DrawViewPart::getCosmeticEdgeByLink(int idx) const
|
||||
CosmeticEdge* result = nullptr;
|
||||
const std::vector<TechDraw::CosmeticEdge*> edges = getCosmeticEdge();
|
||||
for (auto& ce: edges) {
|
||||
if (ce->linkGeom == idx) {
|
||||
if (ce->m_linkGeom == idx) {
|
||||
result = ce;
|
||||
break;
|
||||
}
|
||||
@@ -1212,14 +1217,6 @@ TechDraw::CosmeticEdge* DrawViewPart::getCosmeticEdgeByLink(int idx) const
|
||||
return result;
|
||||
}
|
||||
|
||||
void DrawViewPart::clearCE(void)
|
||||
{
|
||||
// Base::Console().Message("DVP::clearCE()\n");
|
||||
cosmoEdge.clear();
|
||||
std::vector<std::string> noEdges;
|
||||
CosmeticEdgeList.setValues(noEdges);
|
||||
}
|
||||
|
||||
PyObject *DrawViewPart::getPyObject(void)
|
||||
{
|
||||
if (PythonObject.is(Py::_None())) {
|
||||
|
||||
@@ -52,7 +52,7 @@ namespace App
|
||||
class Part;
|
||||
}
|
||||
|
||||
namespace TechDrawGeometry
|
||||
namespace TechDraw
|
||||
{
|
||||
class GeometryObject;
|
||||
class Vertex;
|
||||
@@ -111,19 +111,19 @@ public:
|
||||
std::vector<TechDraw::DrawViewDimension*> getDimensions() const;
|
||||
std::vector<TechDraw::DrawViewBalloon*> getBalloons() const;
|
||||
|
||||
//TODO: are there use-cases for Python access to TechDrawGeometry???
|
||||
//TODO: are there use-cases for Python access to TechDraw???
|
||||
|
||||
const std::vector<TechDrawGeometry::Vertex *> & getVertexGeometry() const;
|
||||
const std::vector<TechDrawGeometry::BaseGeom *> & getEdgeGeometry() const;
|
||||
const std::vector<TechDrawGeometry::BaseGeom *> getVisibleFaceEdges() const;
|
||||
const std::vector<TechDrawGeometry::Face *> & getFaceGeometry() const;
|
||||
const std::vector<TechDraw::Vertex *> & getVertexGeometry() const;
|
||||
const std::vector<TechDraw::BaseGeom *> & getEdgeGeometry() const;
|
||||
const std::vector<TechDraw::BaseGeom *> getVisibleFaceEdges() const;
|
||||
const std::vector<TechDraw::Face *> & getFaceGeometry() const;
|
||||
|
||||
bool hasGeometry(void) const;
|
||||
TechDrawGeometry::GeometryObject* getGeometryObject(void) const { return geometryObject; }
|
||||
TechDraw::GeometryObject* getGeometryObject(void) const { return geometryObject; }
|
||||
|
||||
TechDrawGeometry::BaseGeom* getProjEdgeByIndex(int idx) const; //get existing geom for edge idx in projection
|
||||
TechDrawGeometry::Vertex* getProjVertexByIndex(int idx) const; //get existing geom for vertex idx in projection
|
||||
std::vector<TechDrawGeometry::BaseGeom*> getFaceEdgesByIndex(int idx) const; //get edges for face idx in projection
|
||||
TechDraw::BaseGeom* getProjEdgeByIndex(int idx) const; //get existing geom for edge idx in projection
|
||||
TechDraw::Vertex* getProjVertexByIndex(int idx) const; //get existing geom for vertex idx in projection
|
||||
std::vector<TechDraw::BaseGeom*> getFaceEdgesByIndex(int idx) const; //get edges for face idx in projection
|
||||
|
||||
virtual Base::BoundBox3d getBoundingBox() const;
|
||||
double getBoxX(void) const;
|
||||
@@ -167,32 +167,34 @@ public:
|
||||
virtual TopoDS_Shape getSourceShapeFused(void) const;
|
||||
bool isIso(void) const;
|
||||
|
||||
virtual int addRandomVertex(Base::Vector3d pos);
|
||||
virtual void removeRandomVertex(TechDraw::CosmeticVertex* cv);
|
||||
virtual void removeRandomVertex(int idx);
|
||||
const std::vector<TechDraw::CosmeticVertex*> & getCosmeticVertex(void) const { return cosmoVertex; }
|
||||
virtual int addCosmeticVertex(Base::Vector3d pos);
|
||||
virtual void stuffCosmeticVertexList(void);
|
||||
virtual void removeCosmeticVertex(TechDraw::CosmeticVertex* cv);
|
||||
virtual void removeCosmeticVertex(int idx);
|
||||
const std::vector<TechDraw::CosmeticVertex*> & getCosmeticVertex(void) const { return vertexCosmetic; }
|
||||
TechDraw::CosmeticVertex* getCosmeticVertexByIndex(int idx) const;
|
||||
TechDraw::CosmeticVertex* getCosmeticVertexByLink(int idx) const;
|
||||
void clearCV(void);
|
||||
void clearCosmeticVertices(void);
|
||||
|
||||
virtual int addRandomEdge(Base::Vector3d start, Base::Vector3d end);
|
||||
virtual int addRandomEdge(TopoDS_Edge e);
|
||||
virtual int addRandomEdge(TechDraw::CosmeticEdge*);
|
||||
virtual void removeRandomEdge(TechDraw::CosmeticEdge* ce);
|
||||
virtual void removeRandomEdge(int idx);
|
||||
const std::vector<TechDraw::CosmeticEdge*> & getCosmeticEdge(void) const { return cosmoEdge; }
|
||||
virtual int addCosmeticEdge(Base::Vector3d start, Base::Vector3d end);
|
||||
virtual int addCosmeticEdge(TopoDS_Edge e);
|
||||
virtual int addCosmeticEdge(TechDraw::CosmeticEdge*);
|
||||
virtual void stuffCosmeticEdgeList(void);
|
||||
virtual void removeCosmeticEdge(TechDraw::CosmeticEdge* ce);
|
||||
virtual void removeCosmeticEdge(int idx);
|
||||
const std::vector<TechDraw::CosmeticEdge*> & getCosmeticEdge(void) const { return edgeCosmetic; }
|
||||
TechDraw::CosmeticEdge* getCosmeticEdgeByIndex(int idx) const;
|
||||
TechDraw::CosmeticEdge* getCosmeticEdgeByLink(int idx) const;
|
||||
void clearCE(void);
|
||||
void clearCosmeticEdges(void);
|
||||
|
||||
protected:
|
||||
TechDrawGeometry::GeometryObject *geometryObject;
|
||||
TechDraw::GeometryObject *geometryObject;
|
||||
Base::BoundBox3d bbox;
|
||||
|
||||
void onChanged(const App::Property* prop);
|
||||
virtual void unsetupObject();
|
||||
|
||||
virtual TechDrawGeometry::GeometryObject* buildGeometryObject(TopoDS_Shape shape, gp_Ax2 viewAxis);
|
||||
virtual TechDraw::GeometryObject* buildGeometryObject(TopoDS_Shape shape, gp_Ax2 viewAxis);
|
||||
void extractFaces();
|
||||
|
||||
//Projection parameter space
|
||||
@@ -207,14 +209,11 @@ protected:
|
||||
bool m_handleFaces;
|
||||
|
||||
//Cosmetics
|
||||
std::vector<TechDraw::CosmeticVertex*> cosmoVertex;
|
||||
std::vector<TechDraw::CosmeticVertex*> vertexCosmetic;
|
||||
void rebuildCosmoVertex(void);
|
||||
void stuffCosmeticVertexList(void);
|
||||
|
||||
std::vector<TechDraw::CosmeticEdge*> cosmoEdge;
|
||||
std::vector<TechDraw::CosmeticEdge*> edgeCosmetic;
|
||||
void rebuildCosmoEdge(void);
|
||||
void stuffCosmeticEdgeList(void);
|
||||
|
||||
|
||||
private:
|
||||
bool nowUnsetting;
|
||||
|
||||
@@ -13,9 +13,54 @@
|
||||
<Author Licence="LGPL" Name="WandererFan" EMail="wandererfan@gmail.com" />
|
||||
<UserDocu>Feature for creating and manipulating Technical Drawing Part Views</UserDocu>
|
||||
</Documentation>
|
||||
<Methode Name="clearCV">
|
||||
<Methode Name="makeCosmeticVertex">
|
||||
<Documentation>
|
||||
<UserDocu>clearCV() - remove all CosmeticVertices from the View. Returns nothing.</UserDocu>
|
||||
<UserDocu>makeCosmeticVertex(p1) - add a CosmeticVertex at p1 (View coordinates). Returns index of created vertex.</UserDocu>
|
||||
</Documentation>
|
||||
</Methode>
|
||||
<Methode Name="getCosmeticVertexByIndex">
|
||||
<Documentation>
|
||||
<UserDocu>getCosmeticVertexByIndex(idx) - returns CosmeticVertx[idx].</UserDocu>
|
||||
</Documentation>
|
||||
</Methode>
|
||||
<Methode Name="removeCosmeticVertex">
|
||||
<Documentation>
|
||||
<UserDocu>removeCosmeticVertex(idx) - remove CosmeticVertex[idx] from View. Returns None.</UserDocu>
|
||||
</Documentation>
|
||||
</Methode>
|
||||
<Methode Name="clearCosmeticVertices">
|
||||
<Documentation>
|
||||
<UserDocu>clearCosmeticVertices() - remove all CosmeticVertices from the View. Returns nothing.</UserDocu>
|
||||
</Documentation>
|
||||
</Methode>
|
||||
<Methode Name="makeCosmeticLine">
|
||||
<Documentation>
|
||||
<UserDocu>makeCosmeticLine(p1, p2) - add a CosmeticEdge from p1 to p2(View coordinates). Returns index of created edge.</UserDocu>
|
||||
</Documentation>
|
||||
</Methode>
|
||||
<Methode Name="makeCosmeticCircle">
|
||||
<Documentation>
|
||||
<UserDocu>makeCosmeticCircle(center, radius) - add a CosmeticEdge at center with radius radius(View coordinates). Returns index of created edge.</UserDocu>
|
||||
</Documentation>
|
||||
</Methode>
|
||||
<Methode Name="makeCosmeticCircleArc">
|
||||
<Documentation>
|
||||
<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">
|
||||
<Documentation>
|
||||
<UserDocu>getCosmeticEdgeByIndex(idx) - returns CosmeticEdge[idx].</UserDocu>
|
||||
</Documentation>
|
||||
</Methode>
|
||||
<Methode Name="removeCosmeticEdge">
|
||||
<Documentation>
|
||||
<UserDocu>removeCosmeticEdge(idx) - remove CosmeticEdge[idx] from View. Returns None.</UserDocu>
|
||||
</Documentation>
|
||||
</Methode>
|
||||
<Methode Name="clearCosmeticEdges">
|
||||
<Documentation>
|
||||
<UserDocu>clearCosmeticEdges() - remove all CosmeticLines from the View. Returns nothing.</UserDocu>
|
||||
</Documentation>
|
||||
</Methode>
|
||||
<CustomAttributes />
|
||||
|
||||
@@ -1,7 +1,52 @@
|
||||
/***************************************************************************
|
||||
* Copyright (c) 2019 WandererFan (wandererfan@gmail.com) *
|
||||
* *
|
||||
* 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"
|
||||
|
||||
#include <gp_Pnt.hxx>
|
||||
#include <gp_Dir.hxx>
|
||||
#include <gp_Ax1.hxx>
|
||||
#include <gp_Ax2.hxx>
|
||||
#include <gp_Circ.hxx>
|
||||
#include <Geom_Circle.hxx>
|
||||
#include <BRepBuilderAPI_MakeEdge.hxx>
|
||||
#include <TopoDS.hxx>
|
||||
#include <TopoDS_Edge.hxx>
|
||||
#include <TopoDS_Shape.hxx>
|
||||
#include <TopExp.hxx>
|
||||
#include <TopExp_Explorer.hxx>
|
||||
|
||||
#include <Base/Console.h>
|
||||
#include <Base/Exception.h>
|
||||
#include <Base/GeometryPyCXX.h>
|
||||
#include <Base/PyObjectBase.h>
|
||||
#include <Base/Vector3D.h>
|
||||
#include <Base/VectorPy.h>
|
||||
|
||||
#include "DrawViewPart.h"
|
||||
#include "GeometryObject.h"
|
||||
#include "Cosmetic.h"
|
||||
#include "DrawUtil.h"
|
||||
#include "GeometryObject.h"
|
||||
|
||||
// inclusion of the generated files (generated out of DrawViewPartPy.xml)
|
||||
#include <Mod/TechDraw/App/DrawViewPartPy.h>
|
||||
@@ -9,17 +54,231 @@
|
||||
|
||||
using namespace TechDraw;
|
||||
|
||||
App::Color pyTupleToColor(PyObject* pColor);
|
||||
|
||||
// returns a string which represents the object e.g. when printed in python
|
||||
std::string DrawViewPartPy::representation(void) const
|
||||
{
|
||||
return std::string("<DrawViewPart object>");
|
||||
}
|
||||
|
||||
PyObject* DrawViewPartPy::clearCV(PyObject *args)
|
||||
PyObject* DrawViewPartPy::clearCosmeticVertices(PyObject *args)
|
||||
{
|
||||
(void) args;
|
||||
DrawViewPart* item = getDrawViewPartPtr();
|
||||
item->clearCV();
|
||||
item->clearCosmeticVertices();
|
||||
Py_INCREF(Py_None);
|
||||
return Py_None;
|
||||
}
|
||||
|
||||
PyObject* DrawViewPartPy::clearCosmeticEdges(PyObject *args)
|
||||
{
|
||||
(void) args;
|
||||
DrawViewPart* item = getDrawViewPartPtr();
|
||||
item->clearCosmeticEdges();
|
||||
Py_INCREF(Py_None);
|
||||
return Py_None;
|
||||
}
|
||||
|
||||
PyObject* DrawViewPartPy::makeCosmeticVertex(PyObject *args)
|
||||
{
|
||||
// Base::Console().Message("DVPPI::makeCosmeticVertex()\n");
|
||||
PyObject* pPnt1 = nullptr;
|
||||
if (!PyArg_ParseTuple(args, "O!", &(Base::VectorPy::Type), &pPnt1)) {
|
||||
throw Py::TypeError("expected (vector)");
|
||||
}
|
||||
|
||||
DrawViewPart* item = getDrawViewPartPtr();
|
||||
Base::Vector3d pnt1 = DrawUtil::invertY(static_cast<Base::VectorPy*>(pPnt1)->value());
|
||||
int idx = item->addCosmeticVertex(pnt1);
|
||||
return PyLong_FromLong(idx);
|
||||
}
|
||||
|
||||
PyObject* DrawViewPartPy::makeCosmeticLine(PyObject *args)
|
||||
{
|
||||
// Base::Console().Message("DVPPI::makeCosmeticLine()\n");
|
||||
PyObject* pPnt1 = nullptr;
|
||||
PyObject* pPnt2 = nullptr;
|
||||
int style = LineFormat::getDefEdgeStyle();
|
||||
double weight = LineFormat::getDefEdgeWidth();
|
||||
// App::Color defCol = LineFormat::getDefEdgeColor();
|
||||
// PyObject* pColor = nullptr;
|
||||
|
||||
if (!PyArg_ParseTuple(args, "O!O!|id", &(Base::VectorPy::Type), &pPnt1,
|
||||
&(Base::VectorPy::Type), &pPnt2,
|
||||
&style, &weight)) {
|
||||
throw Py::TypeError("expected (vector, vector, [style, weight])");
|
||||
}
|
||||
// if (!PyArg_ParseTuple(args, "O!O!|idO", &(Base::VectorPy::Type), &pPnt1,
|
||||
// &(Base::VectorPy::Type), &pPnt2,
|
||||
// &style, &weight,
|
||||
// &pColor)) {
|
||||
// throw Py::TypeError("expected (vector, vector,[style,weight,color])");
|
||||
// }
|
||||
|
||||
DrawViewPart* dvp = getDrawViewPartPtr();
|
||||
//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);
|
||||
ce->m_format.m_style = style;
|
||||
ce->m_format.m_weight = weight;
|
||||
// ce->m_format.m_color = pyTupleToColor(pColor);
|
||||
|
||||
return PyLong_FromLong(idx);
|
||||
}
|
||||
|
||||
PyObject* DrawViewPartPy::makeCosmeticCircle(PyObject *args)
|
||||
{
|
||||
// Base::Console().Message("DVPPI::makeCosmeticCircle()\n");
|
||||
PyObject* pPnt1 = nullptr;
|
||||
double radius = 5.0;
|
||||
double angle1 = 0.0;
|
||||
double angle2 = 360.0;
|
||||
int style = LineFormat::getDefEdgeStyle();
|
||||
double weight = LineFormat::getDefEdgeWidth();
|
||||
// App::Color defCol = LineFormat::getDefEdgeColor();
|
||||
// PyObject* pColor = nullptr;
|
||||
|
||||
if (!PyArg_ParseTuple(args, "O!d|id", &(Base::VectorPy::Type), &pPnt1,
|
||||
&radius,
|
||||
&style, &weight)) {
|
||||
throw Py::TypeError("expected (vector, radius, [style, weight])");
|
||||
}
|
||||
// if (!PyArg_ParseTuple(args, "O!O!|idO", &(Base::VectorPy::Type), &pPnt1,
|
||||
// &(Base::VectorPy::Type), &pPnt2,
|
||||
// &style, &weight,
|
||||
// &pColor)) {
|
||||
// throw Py::TypeError("expected (vector, vector,[style,weight,color])");
|
||||
// }
|
||||
|
||||
DrawViewPart* dvp = getDrawViewPartPtr();
|
||||
Base::Vector3d pnt1 = DrawUtil::invertY(static_cast<Base::VectorPy*>(pPnt1)->value());
|
||||
gp_Pnt loc(pnt1.x, pnt1.y, pnt1.z);
|
||||
gp_Dir dir(0,0,1);
|
||||
gp_Ax1 axis(loc, dir);
|
||||
gp_Circ circle;
|
||||
circle.SetAxis(axis);
|
||||
circle.SetRadius(radius);
|
||||
|
||||
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);
|
||||
ce->m_format.m_style = style;
|
||||
ce->m_format.m_weight = weight;
|
||||
// ce->m_format.m_color = pyTupleToColor(pColor);
|
||||
return PyLong_FromLong(idx);
|
||||
}
|
||||
|
||||
PyObject* DrawViewPartPy::makeCosmeticCircleArc(PyObject *args)
|
||||
{
|
||||
// Base::Console().Message("DVPPI::makeCosmeticCircleArc()\n");
|
||||
PyObject* pPnt1 = nullptr;
|
||||
double radius = 5.0;
|
||||
double angle1 = 0.0;
|
||||
double angle2 = 360.0;
|
||||
int style = LineFormat::getDefEdgeStyle();
|
||||
double weight = LineFormat::getDefEdgeWidth();
|
||||
// App::Color defCol = LineFormat::getDefEdgeColor();
|
||||
// PyObject* pColor = nullptr;
|
||||
|
||||
if (!PyArg_ParseTuple(args, "O!ddd|id", &(Base::VectorPy::Type), &pPnt1,
|
||||
&radius, &angle1, &angle2,
|
||||
&style, &weight)) {
|
||||
throw Py::TypeError("expected (vector, radius, start, end,[style, weight])");
|
||||
}
|
||||
// if (!PyArg_ParseTuple(args, "O!O!|idO", &(Base::VectorPy::Type), &pPnt1,
|
||||
// &(Base::VectorPy::Type), &pPnt2,
|
||||
// &style, &weight,
|
||||
// &pColor)) {
|
||||
// throw Py::TypeError("expected (vector, vector,[style,weight,color])");
|
||||
// }
|
||||
|
||||
//from here on is duplicate of makeCosmeticCircle
|
||||
DrawViewPart* dvp = getDrawViewPartPtr();
|
||||
Base::Vector3d pnt1 = DrawUtil::invertY(static_cast<Base::VectorPy*>(pPnt1)->value());
|
||||
gp_Pnt loc(pnt1.x, pnt1.y, pnt1.z);
|
||||
gp_Dir dir(0,0,1);
|
||||
gp_Ax1 axis(loc, dir);
|
||||
gp_Circ circle;
|
||||
circle.SetAxis(axis);
|
||||
circle.SetRadius(radius); //full circle @ right loc
|
||||
Handle(Geom_Circle) hCircle = new Geom_Circle (circle);
|
||||
BRepBuilderAPI_MakeEdge aMakeEdge(hCircle, -angle2*(M_PI/180), -angle1*(M_PI/180)); //hack!
|
||||
// right result, but ugly:
|
||||
// Qt angles are cw, OCC angles are CCW
|
||||
// Qt -y is up, OCC -y is down
|
||||
|
||||
TopoDS_Edge edge = aMakeEdge.Edge();
|
||||
int idx = dvp->addCosmeticEdge(edge);
|
||||
TechDraw::CosmeticEdge* ce = dvp->getCosmeticEdgeByIndex(idx);
|
||||
ce->m_format.m_style = style;
|
||||
ce->m_format.m_weight = weight;
|
||||
// ce->m_format.m_color = pyTupleToColor(pColor);
|
||||
return PyLong_FromLong(idx);
|
||||
}
|
||||
|
||||
PyObject* DrawViewPartPy::getCosmeticVertexByIndex(PyObject *args)
|
||||
{
|
||||
// Base::Console().Message("DVPPI::getCosVertByIndex()\n");
|
||||
PyObject* result = nullptr;
|
||||
int idx = 0;
|
||||
if (!PyArg_ParseTuple(args, "i", &idx)) {
|
||||
throw Py::TypeError("expected (index)");
|
||||
}
|
||||
DrawViewPart* dvp = getDrawViewPartPtr();
|
||||
TechDraw::CosmeticVertex* cv = dvp->getCosmeticVertexByIndex(idx);
|
||||
if (cv != nullptr) {
|
||||
Base::Console().Message("DVPPI::getCosVertbyIdx - found a CV\n");
|
||||
//make a py object
|
||||
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
PyObject* DrawViewPartPy::removeCosmeticVertex(PyObject *args)
|
||||
{
|
||||
// Base::Console().Message("DVPPI::removeCosVert()\n");
|
||||
int idx = 0;
|
||||
if (!PyArg_ParseTuple(args, "i", &idx)) {
|
||||
throw Py::TypeError("expected (index)");
|
||||
}
|
||||
DrawViewPart* dvp = getDrawViewPartPtr();
|
||||
dvp->removeCosmeticVertex(idx);
|
||||
Py_INCREF(Py_None);
|
||||
return Py_None;
|
||||
}
|
||||
|
||||
PyObject* DrawViewPartPy::getCosmeticEdgeByIndex(PyObject *args)
|
||||
{
|
||||
// Base::Console().Message("DVPPI::getCosEdgeByIndex()\n");
|
||||
int idx = 0;
|
||||
PyObject* result = nullptr;
|
||||
if (!PyArg_ParseTuple(args, "i", &idx)) {
|
||||
throw Py::TypeError("expected (index)");
|
||||
}
|
||||
DrawViewPart* dvp = getDrawViewPartPtr();
|
||||
TechDraw::CosmeticEdge* ce = dvp->getCosmeticEdgeByIndex(idx);
|
||||
if (ce != nullptr) {
|
||||
Base::Console().Message("DVPPI::getCosEdgebyIdx - found a CE\n");
|
||||
//make a py object
|
||||
}
|
||||
|
||||
return 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)");
|
||||
}
|
||||
DrawViewPart* dvp = getDrawViewPartPtr();
|
||||
dvp->removeCosmeticEdge(idx);
|
||||
Py_INCREF(Py_None);
|
||||
return Py_None;
|
||||
}
|
||||
@@ -33,3 +292,27 @@ int DrawViewPartPy::setCustomAttributes(const char* /*attr*/, PyObject* /*obj*/)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
App::Color pyTupleToColor(PyObject* pColor)
|
||||
{
|
||||
double red = 0.0, green = 0.0, blue = 0.0, alpha = 0.0;
|
||||
App::Color c(red, blue, green, alpha);
|
||||
if (PyTuple_Check(pColor)) {
|
||||
int tSize = (int) PyTuple_Size(pColor);
|
||||
if (tSize > 2) {
|
||||
PyObject* pRed = PyTuple_GetItem(pColor,0);
|
||||
red = PyFloat_AsDouble(pRed);
|
||||
PyObject* pGreen = PyTuple_GetItem(pColor,1);
|
||||
green = PyFloat_AsDouble(pGreen);
|
||||
PyObject* pBlue = PyTuple_GetItem(pColor,2);
|
||||
blue = PyFloat_AsDouble(pBlue);
|
||||
}
|
||||
if (tSize > 3) {
|
||||
PyObject* pAlpha = PyTuple_GetItem(pColor,3);
|
||||
alpha = PyFloat_AsDouble(pAlpha);
|
||||
}
|
||||
c = App::Color(red, blue, green, alpha);
|
||||
}
|
||||
return c;
|
||||
}
|
||||
|
||||
|
||||
@@ -271,14 +271,14 @@ App::DocumentObjectExecReturn *DrawViewSection::execute(void)
|
||||
m_cutShape = rawShape;
|
||||
gp_Pnt inputCenter;
|
||||
try {
|
||||
inputCenter = TechDrawGeometry::findCentroid(rawShape,
|
||||
inputCenter = TechDraw::findCentroid(rawShape,
|
||||
Direction.getValue());
|
||||
TopoDS_Shape mirroredShape = TechDrawGeometry::mirrorShape(rawShape,
|
||||
TopoDS_Shape mirroredShape = TechDraw::mirrorShape(rawShape,
|
||||
inputCenter,
|
||||
getScale());
|
||||
gp_Ax2 viewAxis = getViewAxis(Base::Vector3d(inputCenter.X(),inputCenter.Y(),inputCenter.Z()),Direction.getValue());
|
||||
if (!DrawUtil::fpCompare(Rotation.getValue(),0.0)) {
|
||||
mirroredShape = TechDrawGeometry::rotateShape(mirroredShape,
|
||||
mirroredShape = TechDraw::rotateShape(mirroredShape,
|
||||
viewAxis,
|
||||
Rotation.getValue());
|
||||
}
|
||||
@@ -295,12 +295,12 @@ App::DocumentObjectExecReturn *DrawViewSection::execute(void)
|
||||
|
||||
try {
|
||||
TopoDS_Compound sectionCompound = findSectionPlaneIntersections(rawShape);
|
||||
TopoDS_Shape mirroredSection = TechDrawGeometry::mirrorShape(sectionCompound,
|
||||
TopoDS_Shape mirroredSection = TechDraw::mirrorShape(sectionCompound,
|
||||
inputCenter,
|
||||
getScale());
|
||||
gp_Ax2 viewAxis = getViewAxis(Base::Vector3d(inputCenter.X(),inputCenter.Y(),inputCenter.Z()),Direction.getValue());
|
||||
if (!DrawUtil::fpCompare(Rotation.getValue(),0.0)) {
|
||||
mirroredSection = TechDrawGeometry::rotateShape(mirroredSection,
|
||||
mirroredSection = TechDraw::rotateShape(mirroredSection,
|
||||
viewAxis,
|
||||
Rotation.getValue());
|
||||
}
|
||||
@@ -329,16 +329,16 @@ App::DocumentObjectExecReturn *DrawViewSection::execute(void)
|
||||
return new App::DocumentObjectExecReturn(e2.GetMessageString());
|
||||
}
|
||||
//add back the cosmetic vertices
|
||||
for (auto& v: cosmoVertex) {
|
||||
int idx = geometryObject->addRandomVertex(v->pageLocation * getScale());
|
||||
for (auto& v: vertexCosmetic) {
|
||||
int idx = geometryObject->addCosmeticVertex(v->point() * 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;
|
||||
for (auto& e: edgeCosmetic) {
|
||||
TechDraw::BaseGeom* scaledGeom = e->scaledGeometry(getScale());
|
||||
int idx = geometryObject->addCosmeticEdge(scaledGeom);
|
||||
e->m_linkGeom = idx;
|
||||
}
|
||||
|
||||
requestPaint();
|
||||
@@ -389,23 +389,23 @@ TopoDS_Compound DrawViewSection::findSectionPlaneIntersections(const TopoDS_Shap
|
||||
}
|
||||
|
||||
//! get display geometry for Section faces
|
||||
std::vector<TechDrawGeometry::Face*> DrawViewSection::getFaceGeometry()
|
||||
std::vector<TechDraw::Face*> DrawViewSection::getFaceGeometry()
|
||||
{
|
||||
std::vector<TechDrawGeometry::Face*> result;
|
||||
std::vector<TechDraw::Face*> result;
|
||||
TopoDS_Compound c = sectionFaces;
|
||||
TopExp_Explorer faces(c, TopAbs_FACE);
|
||||
for (; faces.More(); faces.Next()) {
|
||||
TechDrawGeometry::Face* f = new TechDrawGeometry::Face();
|
||||
TechDraw::Face* f = new TechDraw::Face();
|
||||
const TopoDS_Face& face = TopoDS::Face(faces.Current());
|
||||
TopExp_Explorer wires(face, TopAbs_WIRE);
|
||||
for (; wires.More(); wires.Next()) {
|
||||
TechDrawGeometry::Wire* w = new TechDrawGeometry::Wire();
|
||||
TechDraw::Wire* w = new TechDraw::Wire();
|
||||
const TopoDS_Wire& wire = TopoDS::Wire(wires.Current());
|
||||
TopExp_Explorer edges(wire, TopAbs_EDGE);
|
||||
for (; edges.More(); edges.Next()) {
|
||||
const TopoDS_Edge& edge = TopoDS::Edge(edges.Current());
|
||||
//dumpEdge("edge",edgeCount,edge);
|
||||
TechDrawGeometry::BaseGeom* base = TechDrawGeometry::BaseGeom::baseFactory(edge);
|
||||
TechDraw::BaseGeom* base = TechDraw::BaseGeom::baseFactory(edge);
|
||||
w->geoms.push_back(base);
|
||||
}
|
||||
f->wires.push_back(w);
|
||||
|
||||
@@ -40,7 +40,7 @@ class gp_Pln;
|
||||
class gp_Pnt;
|
||||
class TopoDS_Face;
|
||||
|
||||
namespace TechDrawGeometry
|
||||
namespace TechDraw
|
||||
{
|
||||
class Face;
|
||||
}
|
||||
@@ -83,7 +83,7 @@ public:
|
||||
}
|
||||
|
||||
public:
|
||||
std::vector<TechDrawGeometry::Face*> getFaceGeometry();
|
||||
std::vector<TechDraw::Face*> getFaceGeometry();
|
||||
Base::Vector3d getSectionVector (const std::string sectionName);
|
||||
TechDraw::DrawViewPart* getBaseDVP();
|
||||
TechDraw::DrawProjGroupItem* getBaseDPGI();
|
||||
|
||||
@@ -77,7 +77,6 @@
|
||||
|
||||
#include "Geometry.h"
|
||||
|
||||
using namespace TechDrawGeometry;
|
||||
using namespace TechDraw;
|
||||
|
||||
// Collection of Geometric Features
|
||||
@@ -121,37 +120,73 @@ BaseGeom::BaseGeom() :
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
std::vector<Base::Vector2d> BaseGeom::findEndPoints()
|
||||
std::string BaseGeom::toCSV(void) const
|
||||
{
|
||||
std::vector<Base::Vector2d> result;
|
||||
// Base::Console().Message("Geo::BaseGeom::toCSV()\n");
|
||||
std::stringstream ss;
|
||||
ss << geomType << "," <<
|
||||
extractType << "," <<
|
||||
classOfEdge << "," <<
|
||||
visible << "," <<
|
||||
reversed << "," <<
|
||||
ref3D << "," <<
|
||||
cosmetic;
|
||||
return ss.str();
|
||||
}
|
||||
|
||||
bool BaseGeom::fromCSV(std::string lineSpec)
|
||||
{
|
||||
unsigned int maxCells = 7;
|
||||
if (lineSpec.length() == 0) {
|
||||
Base::Console().Message( "BG::fromCSV - lineSpec empty\n");
|
||||
return false;
|
||||
}
|
||||
std::vector<std::string> values = DrawUtil::split(lineSpec);
|
||||
if (values.size() < maxCells) {
|
||||
Base::Console().Message( "BG::fromCSV(%s) invalid CSV entry\n",lineSpec.c_str() );
|
||||
return false;
|
||||
}
|
||||
|
||||
geomType = (TechDraw::GeomType) atoi(values[0].c_str());
|
||||
extractType = (TechDraw::ExtractionType) atoi(values[1].c_str());
|
||||
classOfEdge = (TechDraw::edgeClass) atoi(values[2].c_str());
|
||||
visible = (bool) atoi(values[3].c_str());
|
||||
reversed = (bool) atoi(values[4].c_str());
|
||||
ref3D = atoi(values[5].c_str());
|
||||
cosmetic = (bool) atoi(values[6].c_str());
|
||||
return true;
|
||||
}
|
||||
|
||||
std::vector<Base::Vector3d> BaseGeom::findEndPoints()
|
||||
{
|
||||
std::vector<Base::Vector3d> result;
|
||||
|
||||
gp_Pnt p = BRep_Tool::Pnt(TopExp::FirstVertex(occEdge));
|
||||
result.push_back(Base::Vector2d(p.X(),p.Y()));
|
||||
result.push_back(Base::Vector3d(p.X(),p.Y(), p.Z()));
|
||||
p = BRep_Tool::Pnt(TopExp::LastVertex(occEdge));
|
||||
result.push_back(Base::Vector2d(p.X(),p.Y()));
|
||||
result.push_back(Base::Vector3d(p.X(),p.Y(), p.Z()));
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
Base::Vector2d BaseGeom::getStartPoint()
|
||||
Base::Vector3d BaseGeom::getStartPoint()
|
||||
{
|
||||
std::vector<Base::Vector2d> verts = findEndPoints();
|
||||
std::vector<Base::Vector3d> verts = findEndPoints();
|
||||
return verts[0];
|
||||
}
|
||||
|
||||
|
||||
Base::Vector2d BaseGeom::getEndPoint()
|
||||
Base::Vector3d BaseGeom::getEndPoint()
|
||||
{
|
||||
std::vector<Base::Vector2d> verts = findEndPoints();
|
||||
std::vector<Base::Vector3d> verts = findEndPoints();
|
||||
return verts[1];
|
||||
}
|
||||
|
||||
Base::Vector2d BaseGeom::getMidPoint()
|
||||
Base::Vector3d BaseGeom::getMidPoint()
|
||||
{
|
||||
// Base::Console().Message("BG::getMidPoint()\n");
|
||||
Base::Vector2d result;
|
||||
Base::Vector3d result;
|
||||
BRepAdaptor_Curve adapt(occEdge);
|
||||
double u = adapt.FirstParameter();
|
||||
double v = adapt.LastParameter();
|
||||
@@ -159,16 +194,16 @@ Base::Vector2d BaseGeom::getMidPoint()
|
||||
double midParm = u + (range / 2.0);
|
||||
BRepLProp_CLProps prop(adapt,midParm,0,Precision::Confusion());
|
||||
const gp_Pnt& pt = prop.Value();
|
||||
result = Base::Vector2d(pt.X(),pt.Y());
|
||||
result = Base::Vector3d(pt.X(),pt.Y(), pt.Z());
|
||||
// Base::Console().Message("BG::getMidPoint - returns: %s\n",
|
||||
// TechDraw::DrawUtil::formatVector(result).c_str());
|
||||
return result;
|
||||
}
|
||||
|
||||
std::vector<Base::Vector2d> BaseGeom::getQuads()
|
||||
std::vector<Base::Vector3d> BaseGeom::getQuads()
|
||||
{
|
||||
// Base::Console().Message("BG::getQuads()\n");
|
||||
std::vector<Base::Vector2d> result;
|
||||
std::vector<Base::Vector3d> result;
|
||||
BRepAdaptor_Curve adapt(occEdge);
|
||||
double u = adapt.FirstParameter();
|
||||
double v = adapt.LastParameter();
|
||||
@@ -178,18 +213,18 @@ std::vector<Base::Vector2d> BaseGeom::getQuads()
|
||||
double q3 = u + (3.0 * range / 4.0);
|
||||
BRepLProp_CLProps prop(adapt,q1,0,Precision::Confusion());
|
||||
const gp_Pnt& p1 = prop.Value();
|
||||
result.push_back(Base::Vector2d(p1.X(),p1.Y()));
|
||||
result.push_back(Base::Vector3d(p1.X(),p1.Y(), 0.0));
|
||||
prop.SetParameter(q2);
|
||||
const gp_Pnt& p2 = prop.Value();
|
||||
result.push_back(Base::Vector2d(p2.X(),p2.Y()));
|
||||
result.push_back(Base::Vector3d(p2.X(),p2.Y(), 0.0));
|
||||
prop.SetParameter(q3);
|
||||
const gp_Pnt& p3 = prop.Value();
|
||||
result.push_back(Base::Vector2d(p3.X(),p3.Y()));
|
||||
result.push_back(Base::Vector3d(p3.X(),p3.Y(), 0.0));
|
||||
// Base::Console().Message("BG::getQuads - returns pts: %d\n", result.size());
|
||||
return result;
|
||||
}
|
||||
|
||||
double BaseGeom::minDist(Base::Vector2d p)
|
||||
double BaseGeom::minDist(Base::Vector3d p)
|
||||
{
|
||||
double minDist = -1.0;
|
||||
gp_Pnt pnt(p.x,p.y,0.0);
|
||||
@@ -199,9 +234,9 @@ double BaseGeom::minDist(Base::Vector2d p)
|
||||
}
|
||||
|
||||
//!find point on me nearest to p
|
||||
Base::Vector2d BaseGeom::nearPoint(const BaseGeom* p)
|
||||
Base::Vector3d BaseGeom::nearPoint(const BaseGeom* p)
|
||||
{
|
||||
Base::Vector2d result(0.0,0.0);
|
||||
Base::Vector3d result(0.0, 0.0, 0.0);
|
||||
TopoDS_Edge pEdge = p->occEdge;
|
||||
BRepExtrema_DistShapeShape extss(occEdge, pEdge);
|
||||
if (extss.IsDone()) {
|
||||
@@ -209,16 +244,16 @@ Base::Vector2d BaseGeom::nearPoint(const BaseGeom* p)
|
||||
if (count != 0) {
|
||||
gp_Pnt p1;
|
||||
p1 = extss.PointOnShape1(1);
|
||||
result = Base::Vector2d(p1.X(),p1.Y());
|
||||
result = Base::Vector3d(p1.X(), p1.Y(), 0.0);
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
Base::Vector2d BaseGeom::nearPoint(Base::Vector2d p)
|
||||
Base::Vector3d BaseGeom::nearPoint(Base::Vector3d p)
|
||||
{
|
||||
gp_Pnt pnt(p.x,p.y,0.0);
|
||||
Base::Vector2d result(0.0,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()) {
|
||||
@@ -226,7 +261,7 @@ Base::Vector2d BaseGeom::nearPoint(Base::Vector2d p)
|
||||
if (count != 0) {
|
||||
gp_Pnt p1;
|
||||
p1 = extss.PointOnShape1(1);
|
||||
result = Base::Vector2d(p1.X(),p1.Y());
|
||||
result = Base::Vector3d(p1.X(),p1.Y(), 0.0);
|
||||
}
|
||||
}
|
||||
return result;
|
||||
@@ -234,8 +269,8 @@ Base::Vector2d BaseGeom::nearPoint(Base::Vector2d p)
|
||||
|
||||
std::string BaseGeom::dump()
|
||||
{
|
||||
Base::Vector2d start = getStartPoint();
|
||||
Base::Vector2d end = getEndPoint();
|
||||
Base::Vector3d start = getStartPoint();
|
||||
Base::Vector3d end = getEndPoint();
|
||||
std::stringstream ss;
|
||||
ss << "BaseGeom: s:(" << start.x << "," << start.y << ") e:(" << end.x << "," << end.y << ") ";
|
||||
ss << "type: " << geomType << " class: " << classOfEdge << " viz: " << visible << " rev: " << reversed;
|
||||
@@ -263,6 +298,9 @@ bool BaseGeom::closed(void)
|
||||
BaseGeom* BaseGeom::baseFactory(TopoDS_Edge edge)
|
||||
{
|
||||
BaseGeom* result = NULL;
|
||||
if (edge.IsNull()) {
|
||||
Base::Console().Message("BG::baseFactory - input edge is NULL \n");
|
||||
}
|
||||
BRepAdaptor_Curve adapt(edge);
|
||||
switch(adapt.GetType()) {
|
||||
case GeomAbs_Circle: {
|
||||
@@ -360,7 +398,7 @@ Ellipse::Ellipse(const TopoDS_Edge &e)
|
||||
gp_Elips ellp = c.Ellipse();
|
||||
const gp_Pnt &p = ellp.Location();
|
||||
|
||||
center = Base::Vector2d(p.X(), p.Y());
|
||||
center = Base::Vector3d(p.X(), p.Y(), 0.0);
|
||||
|
||||
major = ellp.MajorRadius();
|
||||
minor = ellp.MinorRadius();
|
||||
@@ -391,12 +429,19 @@ AOE::AOE(const TopoDS_Edge &e) : Ellipse(e)
|
||||
cw = (a < 0) ? true: false;
|
||||
largeArc = (l-f > M_PI) ? true : false;
|
||||
|
||||
startPnt = Base::Vector2d(s.X(), s.Y());
|
||||
endPnt = Base::Vector2d(ePt.X(), ePt.Y());
|
||||
midPnt = Base::Vector2d(m.X(), m.Y());
|
||||
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());
|
||||
}
|
||||
|
||||
|
||||
Circle::Circle(void)
|
||||
{
|
||||
geomType = CIRCLE;
|
||||
radius = 0.0;
|
||||
center = Base::Vector3d(0.0, 0.0, 0.0);
|
||||
}
|
||||
|
||||
Circle::Circle(const TopoDS_Edge &e)
|
||||
{
|
||||
geomType = CIRCLE; //center, radius
|
||||
@@ -407,7 +452,45 @@ Circle::Circle(const TopoDS_Edge &e)
|
||||
const gp_Pnt& p = circ.Location();
|
||||
|
||||
radius = circ.Radius();
|
||||
center = Base::Vector2d(p.X(), p.Y());
|
||||
center = Base::Vector3d(p.X(), p.Y(), p.Z());
|
||||
}
|
||||
std::string Circle::toCSV(void) const
|
||||
{
|
||||
// Base::Console().Message("Geo::Circle::toCSV()\n");
|
||||
std::string baseCSV = BaseGeom::toCSV();
|
||||
std::stringstream ss;
|
||||
ss << center.x << "," <<
|
||||
center.y << "," <<
|
||||
center.z << "," <<
|
||||
radius;
|
||||
return baseCSV + ",$$$," + ss.str();
|
||||
}
|
||||
|
||||
bool Circle::fromCSV(std::string lineSpec)
|
||||
{
|
||||
std::vector<std::string> tokens = DrawUtil::tokenize(lineSpec);
|
||||
//"baseCSV,$$$,circleCSV"
|
||||
if (tokens.size() != 2) {
|
||||
Base::Console().Message("CosmeticEdge::fromCSV - tokenize failed - size: %d\n",tokens.size());
|
||||
}
|
||||
|
||||
BaseGeom::fromCSV(tokens[0]);
|
||||
unsigned int maxCells = 4;
|
||||
if (lineSpec.length() == 0) {
|
||||
Base::Console().Message( "Circle::fromCSV - lineSpec empty\n");
|
||||
return false;
|
||||
}
|
||||
std::vector<std::string> values = DrawUtil::split(tokens[1]);
|
||||
if (values.size() < maxCells) {
|
||||
Base::Console().Message( "Circle::fromCSV(%s) invalid CSV entry\n",lineSpec.c_str() );
|
||||
return false;
|
||||
}
|
||||
double x = atof(values[0].c_str());
|
||||
double y = atof(values[1].c_str());
|
||||
double z = atof(values[2].c_str());
|
||||
center = Base::Vector3d(x,y,z);
|
||||
radius = atof(values[3].c_str());
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@@ -421,20 +504,33 @@ 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);
|
||||
|
||||
gp_Vec v1(m,s);
|
||||
gp_Vec v2(m,ePt);
|
||||
gp_Vec v3(0,0,1);
|
||||
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);
|
||||
|
||||
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;
|
||||
largeArc = (fabs(l-f) > M_PI) ? true : false;
|
||||
|
||||
startPnt = Base::Vector3d(s.X(), s.Y(), s.Z());
|
||||
endPnt = Base::Vector3d(ePt.X(), ePt.Y(), s.Z());
|
||||
midPnt = Base::Vector3d(m.X(), m.Y(), s.Z());
|
||||
}
|
||||
|
||||
AOC::AOC(void) : Circle()
|
||||
{
|
||||
geomType = ARCOFCIRCLE;
|
||||
|
||||
startPnt = Base::Vector3d(0.0, 0.0, 0.0);
|
||||
endPnt = Base::Vector3d(0.0, 0.0, 0.0);
|
||||
midPnt = Base::Vector3d(0.0, 0.0, 0.0);
|
||||
startAngle = 0.0;
|
||||
endAngle = 2.0 * M_PI;
|
||||
cw = false;
|
||||
largeArc = false;
|
||||
|
||||
startPnt = Base::Vector2d(s.X(), s.Y());
|
||||
endPnt = Base::Vector2d(ePt.X(), ePt.Y());
|
||||
midPnt = Base::Vector2d(m.X(), m.Y());
|
||||
}
|
||||
|
||||
bool AOC::isOnArc(Base::Vector3d p)
|
||||
@@ -458,13 +554,13 @@ bool AOC::isOnArc(Base::Vector3d p)
|
||||
|
||||
double AOC::distToArc(Base::Vector3d p)
|
||||
{
|
||||
Base::Vector2d p2(p.x,p.y);
|
||||
Base::Vector3d p2(p.x, p.y, p.z);
|
||||
double result = minDist(p2);
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
bool AOC::intersectsArc(Base::Vector3d p1,Base::Vector3d p2)
|
||||
bool AOC::intersectsArc(Base::Vector3d p1, Base::Vector3d p2)
|
||||
{
|
||||
bool result = false;
|
||||
double minDist = -1.0;
|
||||
@@ -487,6 +583,70 @@ bool AOC::intersectsArc(Base::Vector3d p1,Base::Vector3d p2)
|
||||
return result;
|
||||
}
|
||||
|
||||
std::string AOC::toCSV(void) const
|
||||
{
|
||||
std::string circleCSV = Circle::toCSV();
|
||||
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 << "," <<
|
||||
largeArc;
|
||||
|
||||
std::string result = circleCSV + ",$$$," + ss.str();
|
||||
return result;
|
||||
}
|
||||
|
||||
bool AOC::fromCSV(std::string lineSpec)
|
||||
{
|
||||
// Base::Console().Message( "AOC::fromCSV(%s)\n", lineSpec.c_str());
|
||||
if (lineSpec.length() == 0) {
|
||||
Base::Console().Message( "AOC::fromCSV - lineSpec empty\n");
|
||||
return false;
|
||||
}
|
||||
std::vector<std::string> tokens = DrawUtil::tokenize(lineSpec);
|
||||
//"(baseCSV,$$$,circleCSV),$$$,AOCCSV"
|
||||
// [0] [1] [2]
|
||||
if (tokens.size() != 3) {
|
||||
Base::Console().Message("CosmeticEdge::fromCSV - tokenize failed - size: %d\n",tokens.size());
|
||||
}
|
||||
|
||||
Circle::fromCSV(tokens[0] + ",$$$," + tokens[1]); //extra work here.
|
||||
unsigned int maxCells = 13;
|
||||
std::vector<std::string> values = DrawUtil::split(tokens[2]); // we are only interested in last token
|
||||
if (values.size() < maxCells) {
|
||||
Base::Console().Message( "AOC::fromCSV(%s) invalid CSV entry\n",lineSpec.c_str() );
|
||||
return false;
|
||||
}
|
||||
double x = atof(values[0].c_str());
|
||||
double y = atof(values[1].c_str());
|
||||
double z = atof(values[2].c_str());
|
||||
startPnt = Base::Vector3d(x,y,z);
|
||||
x = atof(values[3].c_str());
|
||||
y = atof(values[4].c_str());
|
||||
z = atof(values[5].c_str());
|
||||
endPnt = Base::Vector3d(x,y,z);
|
||||
x = atof(values[6].c_str());
|
||||
y = atof(values[7].c_str());
|
||||
z = atof(values[8].c_str());
|
||||
midPnt = Base::Vector3d(x,y,z);
|
||||
startAngle = atof(values[9].c_str());
|
||||
endAngle = atof(values[10].c_str());
|
||||
cw = atoi(values[11].c_str());
|
||||
largeArc = atoi(values[12].c_str());
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
|
||||
//! Generic is a multiline
|
||||
Generic::Generic(const TopoDS_Edge &e)
|
||||
@@ -501,14 +661,14 @@ Generic::Generic(const TopoDS_Edge &e)
|
||||
if (!polygon.IsNull()) {
|
||||
const TColgp_Array1OfPnt &nodes = polygon->Nodes();
|
||||
for (int i = nodes.Lower(); i <= nodes.Upper(); i++){
|
||||
points.push_back(Base::Vector2d(nodes(i).X(), nodes(i).Y()));
|
||||
points.push_back(Base::Vector3d(nodes(i).X(), nodes(i).Y(), nodes(i).Z()));
|
||||
}
|
||||
} else {
|
||||
//no polygon representation? approximate with line
|
||||
gp_Pnt p = BRep_Tool::Pnt(TopExp::FirstVertex(occEdge));
|
||||
points.push_back(Base::Vector2d(p.X(), p.Y()));
|
||||
points.push_back(Base::Vector3d(p.X(), p.Y(), p.Z()));
|
||||
p = BRep_Tool::Pnt(TopExp::LastVertex(occEdge));
|
||||
points.push_back(Base::Vector2d(p.X(), p.Y()));
|
||||
points.push_back(Base::Vector3d(p.X(), p.Y(), p.Z()));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -518,16 +678,63 @@ Generic::Generic()
|
||||
geomType = GENERIC;
|
||||
}
|
||||
|
||||
Base::Vector2d Generic::asVector(void)
|
||||
std::string Generic::toCSV(void) const
|
||||
{
|
||||
Base::Vector2d result = getEndPoint() - getStartPoint();
|
||||
// Base::Console().Message("Geo::Generic::toCSV()\n");
|
||||
std::string baseCSV = BaseGeom::toCSV();
|
||||
std::stringstream ss;
|
||||
ss << points.size() << ",";
|
||||
for (auto& p: points) {
|
||||
ss << p.x << "," <<
|
||||
p.y << "," <<
|
||||
p.z << ",";
|
||||
}
|
||||
std::string genericCSV = ss.str();
|
||||
genericCSV.pop_back();
|
||||
return baseCSV + ",$$$," + genericCSV;
|
||||
}
|
||||
|
||||
bool Generic::fromCSV(std::string lineSpec)
|
||||
{
|
||||
|
||||
std::vector<std::string> tokens = DrawUtil::tokenize(lineSpec);
|
||||
//"baseCSV,$$$,genericCSV"
|
||||
if (tokens.size() != 2) {
|
||||
Base::Console().Message("Generic::fromCSV - tokenize failed - size: %d\n",tokens.size());
|
||||
}
|
||||
|
||||
BaseGeom::fromCSV(tokens[0]);
|
||||
if (lineSpec.length() == 0) {
|
||||
Base::Console().Message( "Generic::fromCSV - lineSpec empty\n");
|
||||
return false;
|
||||
}
|
||||
std::vector<std::string> values = DrawUtil::split(tokens[1]);
|
||||
if (!values.empty()) {
|
||||
double count = atoi(values[0].c_str());
|
||||
points.clear();
|
||||
int i = 0;
|
||||
for ( ; i < count; i++) {
|
||||
int idx = i * 3;
|
||||
double x = atof(values[idx+1].c_str());
|
||||
double y = atof(values[idx+2].c_str());
|
||||
double z = atof(values[idx+3].c_str());
|
||||
points.push_back(Base::Vector3d(x, y, z));
|
||||
}
|
||||
}
|
||||
// occEdge = GeometryUtils::edgeFromGeneric(this);
|
||||
return true;
|
||||
}
|
||||
|
||||
Base::Vector3d Generic::asVector(void)
|
||||
{
|
||||
Base::Vector3d result = getEndPoint() - getStartPoint();
|
||||
return result;
|
||||
}
|
||||
|
||||
double Generic::slope(void)
|
||||
{
|
||||
double slope;
|
||||
Base::Vector2d v = asVector();
|
||||
Base::Vector3d v = asVector();
|
||||
if (v.x == 0.0) {
|
||||
slope = DOUBLE_MAX;
|
||||
} else {
|
||||
@@ -536,10 +743,10 @@ double Generic::slope(void)
|
||||
return slope;
|
||||
}
|
||||
|
||||
Base::Vector2d Generic::apparentInter(Generic* g)
|
||||
Base::Vector3d Generic::apparentInter(Generic* g)
|
||||
{
|
||||
Base::Vector3d dir0 = DrawUtil::vector23(asVector());
|
||||
Base::Vector3d dir1 = DrawUtil::vector23(g->asVector());
|
||||
Base::Vector3d dir0 = asVector();
|
||||
Base::Vector3d dir1 = g->asVector();
|
||||
|
||||
// Line Intersetion (taken from ViewProviderSketch.cpp)
|
||||
double det = dir0.x*dir1.y - dir0.y*dir1.x;
|
||||
@@ -552,7 +759,7 @@ Base::Vector2d Generic::apparentInter(Generic* g)
|
||||
double y = (dir0.y*c1 - dir1.y*c0)/det;
|
||||
|
||||
// Apparent Intersection point
|
||||
Base::Vector2d result = Base::Vector2d(x,y);
|
||||
Base::Vector3d result = Base::Vector3d(x, y, 0.0);
|
||||
return result;
|
||||
|
||||
}
|
||||
@@ -572,9 +779,9 @@ BSpline::BSpline(const TopoDS_Edge &e)
|
||||
gp_Pnt s = c.Value(f);
|
||||
gp_Pnt m = c.Value((l+f)/2.0);
|
||||
gp_Pnt ePt = c.Value(l);
|
||||
startPnt = Base::Vector2d(s.X(), s.Y());
|
||||
endPnt = Base::Vector2d(ePt.X(), ePt.Y());
|
||||
midPnt = Base::Vector2d(m.X(), m.Y());
|
||||
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);
|
||||
@@ -631,7 +838,7 @@ BSpline::BSpline(const TopoDS_Edge &e)
|
||||
tempSegment.degree = bezier->Degree();
|
||||
for (int pole = 1; pole <= tempSegment.poles; ++pole) {
|
||||
controlPoint = bezier->Pole(pole);
|
||||
tempSegment.pnts.push_back(Base::Vector2d(controlPoint.X(), controlPoint.Y()));
|
||||
tempSegment.pnts.push_back(Base::Vector3d(controlPoint.X(), controlPoint.Y(), controlPoint.Z()));
|
||||
}
|
||||
segments.push_back(tempSegment);
|
||||
}
|
||||
@@ -676,7 +883,7 @@ bool BSpline::isLine()
|
||||
return result;
|
||||
}
|
||||
|
||||
//obs? used by DVDim for approximate dims
|
||||
//used by DVDim for approximate dims
|
||||
bool BSpline::isCircle()
|
||||
{
|
||||
bool result = false;
|
||||
@@ -690,7 +897,7 @@ bool BSpline::isCircle()
|
||||
return result;
|
||||
}
|
||||
|
||||
//obs? used by DVDim for approximate dims
|
||||
//used by DVDim for approximate dims
|
||||
void BSpline::getCircleParms(bool& isCircle, double& radius, Base::Vector3d& center, bool& isArc)
|
||||
{
|
||||
// bool result = false;
|
||||
@@ -906,15 +1113,26 @@ BezierSegment::BezierSegment(const TopoDS_Edge &e)
|
||||
}
|
||||
for (int i = 1; i <= poles; ++i) {
|
||||
gp_Pnt controlPoint = bez->Pole(i);
|
||||
pnts.push_back(Base::Vector2d(controlPoint.X(), controlPoint.Y()));
|
||||
pnts.push_back(Base::Vector3d(controlPoint.X(), controlPoint.Y(), controlPoint.Z()));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//**** Vertex
|
||||
Vertex::Vertex()
|
||||
{
|
||||
pnt = Base::Vector3d(0.0, 0.0, 0.0);
|
||||
extractType = ExtractionType::Plain; //obs?
|
||||
visible = false;
|
||||
ref3D = -1; //obs. never used.
|
||||
isCenter = false;
|
||||
BRepBuilderAPI_MakeVertex mkVert(gp_Pnt(0.0, 0.0, 0.0));
|
||||
occVertex = mkVert.Vertex();
|
||||
}
|
||||
|
||||
Vertex::Vertex(double x, double y)
|
||||
{
|
||||
pnt = Base::Vector2d(x, y);
|
||||
pnt = Base::Vector3d(x, y, 0.0);
|
||||
extractType = ExtractionType::Plain; //obs?
|
||||
visible = false;
|
||||
ref3D = -1; //obs. never used.
|
||||
@@ -950,7 +1168,7 @@ BaseGeomPtrVector GeometryUtils::chainGeoms(BaseGeomPtrVector geoms)
|
||||
} else {
|
||||
//start with first edge
|
||||
result.push_back(geoms[0]);
|
||||
Base::Vector2d atPoint = (geoms[0])->getEndPoint();
|
||||
Base::Vector3d atPoint = (geoms[0])->getEndPoint();
|
||||
used[0] = true;
|
||||
for (unsigned int i = 1; i < geoms.size(); i++) { //do size-1 more edges
|
||||
auto next( nextGeom(atPoint, geoms, used, Precision::Confusion()) );
|
||||
@@ -975,7 +1193,7 @@ BaseGeomPtrVector GeometryUtils::chainGeoms(BaseGeomPtrVector geoms)
|
||||
|
||||
|
||||
/*static*/ GeometryUtils::ReturnType GeometryUtils::nextGeom(
|
||||
Base::Vector2d atPoint,
|
||||
Base::Vector3d atPoint,
|
||||
BaseGeomPtrVector geoms,
|
||||
std::vector<bool> used,
|
||||
double tolerance )
|
||||
@@ -1001,4 +1219,52 @@ BaseGeomPtrVector GeometryUtils::chainGeoms(BaseGeomPtrVector geoms)
|
||||
return result;
|
||||
}
|
||||
|
||||
TopoDS_Edge GeometryUtils::edgeFromGeneric(TechDraw::Generic* g)
|
||||
{
|
||||
// Base::Console().Message("GU::edgeFromGeneric()\n");
|
||||
//note that this isn't quite right as g can be a polyline!
|
||||
//sb points.first, points.last
|
||||
Base::Vector3d first = g->points.front();
|
||||
Base::Vector3d last = g->points.back();
|
||||
gp_Pnt gp1(first.x, first.y, first.z);
|
||||
gp_Pnt gp2(last.x, last.y, last.z);
|
||||
TopoDS_Edge e = BRepBuilderAPI_MakeEdge(gp1, gp2);
|
||||
return e;
|
||||
}
|
||||
|
||||
TopoDS_Edge GeometryUtils::edgeFromCircle(TechDraw::Circle* c)
|
||||
{
|
||||
// Base::Console().Message("GU::edgeFromCircle()\n");
|
||||
gp_Pnt loc(c->center.x, c->center.y, c->center.z);
|
||||
gp_Dir dir(0,0,1);
|
||||
gp_Ax1 axis(loc, dir);
|
||||
gp_Circ circle;
|
||||
circle.SetAxis(axis);
|
||||
circle.SetRadius(c->radius);
|
||||
Handle(Geom_Circle) hCircle = new Geom_Circle (circle);
|
||||
BRepBuilderAPI_MakeEdge aMakeEdge(hCircle, 0.0, 2.0 * M_PI);
|
||||
TopoDS_Edge e = aMakeEdge.Edge();
|
||||
return e;
|
||||
}
|
||||
|
||||
TopoDS_Edge GeometryUtils::edgeFromCircleArc(TechDraw::AOC* c)
|
||||
{
|
||||
Base::Console().Message("GU::edgeFromCircleArc()\n");
|
||||
gp_Pnt loc(c->center.x, c->center.y, c->center.z);
|
||||
gp_Dir dir(0,0,1);
|
||||
gp_Ax1 axis(loc, dir);
|
||||
gp_Circ circle;
|
||||
circle.SetAxis(axis);
|
||||
circle.SetRadius(c->radius);
|
||||
Handle(Geom_Circle) hCircle = new Geom_Circle (circle);
|
||||
Base::Console().Message("GU::edgeFromCircleArc - startAngle: %.3f endAngle: %.3f\n",c->startAngle,c->endAngle);
|
||||
// double startAngle = c->startAngle * M_PI / 180.0; //to radians
|
||||
// double endAngle = c->endAngle * M_PI / 180.0;
|
||||
double startAngle = c->startAngle;
|
||||
double endAngle = c->endAngle;
|
||||
BRepBuilderAPI_MakeEdge aMakeEdge(hCircle, startAngle, endAngle);
|
||||
TopoDS_Edge e = aMakeEdge.Edge();
|
||||
return e;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -31,7 +31,7 @@
|
||||
#include <TopoDS_Edge.hxx>
|
||||
#include <TopoDS_Wire.hxx>
|
||||
|
||||
namespace TechDrawGeometry {
|
||||
namespace TechDraw {
|
||||
|
||||
enum ExtractionType { //obs
|
||||
Plain,
|
||||
@@ -75,29 +75,35 @@ class TechDrawExport BaseGeom
|
||||
TopoDS_Edge occEdge; //projected Edge
|
||||
bool cosmetic;
|
||||
|
||||
std::vector<Base::Vector2d> findEndPoints();
|
||||
Base::Vector2d getStartPoint();
|
||||
Base::Vector2d getEndPoint();
|
||||
Base::Vector2d getMidPoint();
|
||||
std::vector<Base::Vector2d> getQuads();
|
||||
double minDist(Base::Vector2d p);
|
||||
Base::Vector2d nearPoint(Base::Vector2d p);
|
||||
Base::Vector2d nearPoint(const BaseGeom* p);
|
||||
virtual std::string toCSV(void) const;
|
||||
virtual bool fromCSV(std::string s);
|
||||
std::vector<Base::Vector3d> findEndPoints();
|
||||
Base::Vector3d getStartPoint();
|
||||
Base::Vector3d getEndPoint();
|
||||
Base::Vector3d getMidPoint();
|
||||
std::vector<Base::Vector3d> getQuads();
|
||||
double minDist(Base::Vector3d p);
|
||||
Base::Vector3d nearPoint(Base::Vector3d p);
|
||||
Base::Vector3d nearPoint(const BaseGeom* p);
|
||||
static BaseGeom* baseFactory(TopoDS_Edge edge);
|
||||
bool closed(void);
|
||||
std::string dump();
|
||||
};
|
||||
|
||||
typedef std::vector<BaseGeom *> BaseGeomPtrVector;
|
||||
typedef std::vector<BaseGeom *> BaseGeomPtrVector; //obs?
|
||||
|
||||
class TechDrawExport Circle: public BaseGeom
|
||||
{
|
||||
public:
|
||||
Circle(const TopoDS_Edge &e);
|
||||
Circle(void);
|
||||
~Circle() = default;
|
||||
|
||||
public:
|
||||
Base::Vector2d center;
|
||||
virtual std::string toCSV(void) const override;
|
||||
virtual bool fromCSV(std::string s) override;
|
||||
|
||||
Base::Vector3d center;
|
||||
double radius;
|
||||
};
|
||||
|
||||
@@ -108,7 +114,7 @@ class TechDrawExport Ellipse: public BaseGeom
|
||||
~Ellipse() = default;
|
||||
|
||||
public:
|
||||
Base::Vector2d center;
|
||||
Base::Vector3d center;
|
||||
double minor;
|
||||
double major;
|
||||
|
||||
@@ -123,9 +129,9 @@ class TechDrawExport AOE: public Ellipse
|
||||
~AOE() = default;
|
||||
|
||||
public:
|
||||
Base::Vector2d startPnt; //TODO: The points are used for drawing, the angles for bounding box calcs - seems redundant
|
||||
Base::Vector2d endPnt;
|
||||
Base::Vector2d midPnt;
|
||||
Base::Vector3d startPnt; //TODO: The points are used for drawing, the angles for bounding box calcs - seems redundant
|
||||
Base::Vector3d endPnt;
|
||||
Base::Vector3d midPnt;
|
||||
|
||||
/// Angle in radian
|
||||
double startAngle;
|
||||
@@ -142,12 +148,16 @@ class TechDrawExport AOC: public Circle
|
||||
{
|
||||
public:
|
||||
AOC(const TopoDS_Edge &e);
|
||||
AOC(void);
|
||||
~AOC() = default;
|
||||
|
||||
public:
|
||||
Base::Vector2d startPnt;
|
||||
Base::Vector2d endPnt;
|
||||
Base::Vector2d midPnt;
|
||||
virtual std::string toCSV(void) const override;
|
||||
virtual bool fromCSV(std::string s) override;
|
||||
|
||||
Base::Vector3d startPnt;
|
||||
Base::Vector3d endPnt;
|
||||
Base::Vector3d midPnt;
|
||||
|
||||
/// Angle in radian ??angle with horizontal?
|
||||
double startAngle;
|
||||
@@ -174,8 +184,8 @@ public:
|
||||
int poles;
|
||||
int degree;
|
||||
|
||||
//Base::Vector2d pnts[4];
|
||||
std::vector<Base::Vector2d> pnts;
|
||||
//Base::Vector3d pnts[4];
|
||||
std::vector<Base::Vector3d> pnts;
|
||||
};
|
||||
|
||||
class TechDrawExport BSpline: public BaseGeom
|
||||
@@ -185,9 +195,9 @@ class TechDrawExport BSpline: public BaseGeom
|
||||
~BSpline() = default;
|
||||
|
||||
public:
|
||||
Base::Vector2d startPnt;
|
||||
Base::Vector2d endPnt;
|
||||
Base::Vector2d midPnt;
|
||||
Base::Vector3d startPnt;
|
||||
Base::Vector3d endPnt;
|
||||
Base::Vector3d midPnt;
|
||||
double startAngle;
|
||||
double endAngle;
|
||||
/// Arc is drawn clockwise from startAngle to endAngle if true, counterclockwise if false
|
||||
@@ -209,10 +219,12 @@ class TechDrawExport Generic: public BaseGeom
|
||||
Generic();
|
||||
~Generic() = default;
|
||||
|
||||
Base::Vector2d asVector(void);
|
||||
virtual std::string toCSV(void) const override;
|
||||
virtual bool fromCSV(std::string s) override;
|
||||
Base::Vector3d asVector(void);
|
||||
double slope(void);
|
||||
Base::Vector2d apparentInter(Generic* g);
|
||||
std::vector<Base::Vector2d> points;
|
||||
Base::Vector3d apparentInter(Generic* g);
|
||||
std::vector<Base::Vector3d> points;
|
||||
};
|
||||
|
||||
|
||||
@@ -241,18 +253,21 @@ class TechDrawExport Face
|
||||
class TechDrawExport Vertex
|
||||
{
|
||||
public:
|
||||
Vertex();
|
||||
Vertex(double x, double y);
|
||||
Vertex(Base::Vector2d v) : Vertex(v.x,v.y) {}
|
||||
Vertex(Base::Vector3d v) : Vertex(v.x,v.y) {}
|
||||
~Vertex() = default;
|
||||
|
||||
Base::Vector2d pnt;
|
||||
Base::Vector3d pnt;
|
||||
ExtractionType extractType; //obs?
|
||||
bool visible;
|
||||
int ref3D; //obs. never used.
|
||||
bool isCenter;
|
||||
TopoDS_Vertex occVertex;
|
||||
bool isEqual(Vertex* v, double tol);
|
||||
Base::Vector3d getAs3D(void) {return Base::Vector3d(pnt.x,pnt.y,0.0);}
|
||||
Base::Vector3d point(void) const { return Base::Vector3d(pnt.x,pnt.y,0.0); }
|
||||
void point(Base::Vector3d v){ pnt = Base::Vector3d(v.x, v.y); }
|
||||
|
||||
double x() {return pnt.x;}
|
||||
double y() {return pnt.y;}
|
||||
};
|
||||
@@ -275,15 +290,18 @@ class TechDrawExport GeometryUtils
|
||||
/*!
|
||||
* returns index[1:geoms.size()),reversed [true,false]
|
||||
*/
|
||||
static ReturnType nextGeom( Base::Vector2d atPoint,
|
||||
std::vector<TechDrawGeometry::BaseGeom*> geoms,
|
||||
static ReturnType nextGeom( Base::Vector3d atPoint,
|
||||
std::vector<TechDraw::BaseGeom*> geoms,
|
||||
std::vector<bool> used,
|
||||
double tolerance );
|
||||
|
||||
//! return a vector of BaseGeom*'s in tail to nose order
|
||||
static std::vector<BaseGeom*> chainGeoms(std::vector<BaseGeom*> geoms);
|
||||
static TopoDS_Edge edgeFromGeneric(TechDraw::Generic* g);
|
||||
static TopoDS_Edge edgeFromCircle(TechDraw::Circle* c);
|
||||
static TopoDS_Edge edgeFromCircleArc(TechDraw::AOC* c);
|
||||
};
|
||||
|
||||
} //end namespace TechDrawGeometry
|
||||
} //end namespace TechDraw
|
||||
|
||||
#endif //TECHDRAW_GEOMETRY_H
|
||||
|
||||
@@ -78,7 +78,6 @@
|
||||
#include "DrawViewPart.h"
|
||||
#include "DrawViewDetail.h"
|
||||
|
||||
using namespace TechDrawGeometry;
|
||||
using namespace TechDraw;
|
||||
using namespace std;
|
||||
|
||||
@@ -333,10 +332,10 @@ void GeometryObject::projectShapeWithPolygonAlgo(const TopoDS_Shape& input,
|
||||
Base::Console().Log("TIMING - %s GO spent: %.3f millisecs in HLRBRep_PolyAlgo & co\n", m_parentName.c_str(), diffOut);
|
||||
}
|
||||
|
||||
|
||||
//!add edges meeting filter criteria for category, visibility
|
||||
void GeometryObject::extractGeometry(edgeClass category, bool visible)
|
||||
{
|
||||
// Base::Console().Message("GO::extractGeometry(%d, %d)\n",category, visible);
|
||||
TopoDS_Shape filtEdges;
|
||||
if (visible) {
|
||||
switch (category) {
|
||||
@@ -422,12 +421,12 @@ void GeometryObject::addGeomFromCompound(TopoDS_Shape edgeCompound, edgeClass ca
|
||||
BaseGeom* lastAdded = edgeGeom.back();
|
||||
bool v1Add = true, v2Add = true;
|
||||
bool c1Add = true;
|
||||
TechDrawGeometry::Vertex* v1 = new TechDrawGeometry::Vertex(lastAdded->getStartPoint());
|
||||
TechDrawGeometry::Vertex* v2 = new TechDrawGeometry::Vertex(lastAdded->getEndPoint());
|
||||
TechDrawGeometry::Circle* circle = dynamic_cast<TechDrawGeometry::Circle*>(lastAdded);
|
||||
TechDrawGeometry::Vertex* c1 = nullptr;
|
||||
TechDraw::Vertex* v1 = new TechDraw::Vertex(lastAdded->getStartPoint());
|
||||
TechDraw::Vertex* v2 = new TechDraw::Vertex(lastAdded->getEndPoint());
|
||||
TechDraw::Circle* circle = dynamic_cast<TechDraw::Circle*>(lastAdded);
|
||||
TechDraw::Vertex* c1 = nullptr;
|
||||
if (circle) {
|
||||
c1 = new TechDrawGeometry::Vertex(circle->center);
|
||||
c1 = new TechDraw::Vertex(circle->center);
|
||||
c1->isCenter = true;
|
||||
c1->visible = true;
|
||||
}
|
||||
@@ -472,49 +471,25 @@ void GeometryObject::addGeomFromCompound(TopoDS_Shape edgeCompound, edgeClass ca
|
||||
} //end TopExp
|
||||
}
|
||||
|
||||
int GeometryObject::addRandomVertex(Base::Vector3d pos)
|
||||
int GeometryObject::addCosmeticVertex(Base::Vector3d pos)
|
||||
{
|
||||
// Base::Console().Message("GO::addRandomVertex(%s)\n",DrawUtil::formatVector(pos).c_str());
|
||||
TechDrawGeometry::Vertex* v = new TechDrawGeometry::Vertex(pos.x, - pos.y);
|
||||
// Base::Console().Message("GO::addCosmeticVertex(%s)\n",DrawUtil::formatVector(pos).c_str());
|
||||
TechDraw::Vertex* v = new TechDraw::Vertex(pos.x, pos.y);
|
||||
vertexGeom.push_back(v);
|
||||
int idx = vertexGeom.size() - 1;
|
||||
return idx;
|
||||
}
|
||||
|
||||
//void GeometryObject::removeRandomVertex(TechDraw::CosmeticVertex* cv)
|
||||
//{
|
||||
// Base::Console().Message("GO::removeRandomVertex(cv)\n");
|
||||
|
||||
//}
|
||||
|
||||
//void GeometryObject::removeRandomVertex(int idx)
|
||||
//{
|
||||
// Base::Console().Message("GO::removeRandomVertex(%d)\n", idx);
|
||||
|
||||
//}
|
||||
|
||||
int GeometryObject::addRandomEdge(TechDrawGeometry::BaseGeom* base)
|
||||
int GeometryObject::addCosmeticEdge(TechDraw::BaseGeom* base)
|
||||
{
|
||||
// Base::Console().Message("GO::addRandomEdge() - cosmetic: %d\n", base->cosmetic);
|
||||
// Base::Console().Message("GO::addCosmeticEdge() - cosmetic: %d\n", base->cosmetic);
|
||||
base->cosmetic = true;
|
||||
edgeGeom.push_back(base);
|
||||
|
||||
int idx = edgeGeom.size() - 1;
|
||||
return idx;
|
||||
}
|
||||
|
||||
//void GeometryObject::removeRandomEdge(TechDraw::CosmeticEdge* ce)
|
||||
//{
|
||||
// Base::Console().Message("GO::removeRandomEdge(ce)\n");
|
||||
|
||||
//}
|
||||
|
||||
//void GeometryObject::removeRandomEdge(int idx)
|
||||
//{
|
||||
// Base::Console().Message("GO::removeRandomEdge(%d)\n",idx);
|
||||
|
||||
//}
|
||||
|
||||
//! empty Face geometry
|
||||
void GeometryObject::clearFaceGeom()
|
||||
{
|
||||
@@ -605,7 +580,7 @@ void GeometryObject::pruneVertexGeom(Base::Vector3d center, double radius)
|
||||
const std::vector<Vertex *>& oldVerts = getVertexGeometry();
|
||||
std::vector<Vertex *> newVerts;
|
||||
for (auto& v: oldVerts) {
|
||||
Base::Vector3d v3 = v->getAs3D();
|
||||
Base::Vector3d v3 = v->point();
|
||||
double length = (v3 - center).Length();
|
||||
if (length < Precision::Confusion()) {
|
||||
continue;
|
||||
@@ -619,7 +594,7 @@ void GeometryObject::pruneVertexGeom(Base::Vector3d center, double radius)
|
||||
|
||||
|
||||
//! does this GeometryObject already have this vertex
|
||||
bool GeometryObject::findVertex(Base::Vector2d v)
|
||||
bool GeometryObject::findVertex(Base::Vector3d v)
|
||||
{
|
||||
bool found = false;
|
||||
std::vector<Vertex*>::iterator it = vertexGeom.begin();
|
||||
@@ -638,7 +613,7 @@ bool GeometryObject::findVertex(Base::Vector2d v)
|
||||
//! used for individual views, but not secondary views in projection groups
|
||||
//! flip determines Y mirror or not.
|
||||
// getViewAxis 1
|
||||
gp_Ax2 TechDrawGeometry::getViewAxis(const Base::Vector3d origin,
|
||||
gp_Ax2 TechDraw::getViewAxis(const Base::Vector3d origin,
|
||||
const Base::Vector3d& direction,
|
||||
const bool flip)
|
||||
{
|
||||
@@ -674,7 +649,7 @@ gp_Ax2 TechDrawGeometry::getViewAxis(const Base::Vector3d origin,
|
||||
|
||||
//! gets a coordinate system specified by Z and X directions
|
||||
//getViewAxis 2
|
||||
gp_Ax2 TechDrawGeometry::getViewAxis(const Base::Vector3d origin,
|
||||
gp_Ax2 TechDraw::getViewAxis(const Base::Vector3d origin,
|
||||
const Base::Vector3d& direction,
|
||||
const Base::Vector3d& xAxis,
|
||||
const bool flip)
|
||||
@@ -693,7 +668,7 @@ gp_Ax2 TechDrawGeometry::getViewAxis(const Base::Vector3d origin,
|
||||
}
|
||||
|
||||
//! Returns the centroid of shape, as viewed according to direction
|
||||
gp_Pnt TechDrawGeometry::findCentroid(const TopoDS_Shape &shape,
|
||||
gp_Pnt TechDraw::findCentroid(const TopoDS_Shape &shape,
|
||||
const Base::Vector3d &direction)
|
||||
{
|
||||
Base::Vector3d origin(0.0,0.0,0.0);
|
||||
@@ -702,7 +677,7 @@ gp_Pnt TechDrawGeometry::findCentroid(const TopoDS_Shape &shape,
|
||||
}
|
||||
|
||||
//! Returns the centroid of shape, as viewed according to direction
|
||||
gp_Pnt TechDrawGeometry::findCentroid(const TopoDS_Shape &shape,
|
||||
gp_Pnt TechDraw::findCentroid(const TopoDS_Shape &shape,
|
||||
const gp_Ax2 viewAxis)
|
||||
{
|
||||
// Base::Vector3d origin(0.0,0.0,0.0);
|
||||
@@ -729,17 +704,16 @@ gp_Pnt TechDrawGeometry::findCentroid(const TopoDS_Shape &shape,
|
||||
return gp_Pnt(x, y, z);
|
||||
}
|
||||
|
||||
Base::Vector3d TechDrawGeometry::findCentroidVec(const TopoDS_Shape &shape,
|
||||
Base::Vector3d TechDraw::findCentroidVec(const TopoDS_Shape &shape,
|
||||
const Base::Vector3d &direction)
|
||||
{
|
||||
gp_Pnt p = TechDrawGeometry::findCentroid(shape,direction);
|
||||
gp_Pnt p = TechDraw::findCentroid(shape,direction);
|
||||
Base::Vector3d result(p.X(),p.Y(),p.Z());
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
//!scales & mirrors a shape about a center
|
||||
TopoDS_Shape TechDrawGeometry::mirrorShape(const TopoDS_Shape &input,
|
||||
TopoDS_Shape TechDraw::mirrorShape(const TopoDS_Shape &input,
|
||||
const gp_Pnt& inputCenter,
|
||||
double scale)
|
||||
{
|
||||
@@ -773,7 +747,7 @@ TopoDS_Shape TechDrawGeometry::mirrorShape(const TopoDS_Shape &input,
|
||||
}
|
||||
|
||||
//!rotates a shape about a viewAxis
|
||||
TopoDS_Shape TechDrawGeometry::rotateShape(const TopoDS_Shape &input,
|
||||
TopoDS_Shape TechDraw::rotateShape(const TopoDS_Shape &input,
|
||||
gp_Ax2& viewAxis,
|
||||
double rotAngle)
|
||||
{
|
||||
@@ -799,7 +773,7 @@ TopoDS_Shape TechDrawGeometry::rotateShape(const TopoDS_Shape &input,
|
||||
}
|
||||
|
||||
//!scales a shape about a origin
|
||||
TopoDS_Shape TechDrawGeometry::scaleShape(const TopoDS_Shape &input,
|
||||
TopoDS_Shape TechDraw::scaleShape(const TopoDS_Shape &input,
|
||||
double scale)
|
||||
{
|
||||
TopoDS_Shape transShape;
|
||||
@@ -818,7 +792,7 @@ TopoDS_Shape TechDrawGeometry::scaleShape(const TopoDS_Shape &input,
|
||||
}
|
||||
|
||||
//!moves a shape
|
||||
TopoDS_Shape TechDrawGeometry::moveShape(const TopoDS_Shape &input,
|
||||
TopoDS_Shape TechDraw::moveShape(const TopoDS_Shape &input,
|
||||
const Base::Vector3d& motion)
|
||||
{
|
||||
TopoDS_Shape transShape;
|
||||
|
||||
@@ -45,7 +45,7 @@ class CosmeticVertex;
|
||||
class CosmeticEdge;
|
||||
}
|
||||
|
||||
namespace TechDrawGeometry
|
||||
namespace TechDraw
|
||||
{
|
||||
class BaseGeom;
|
||||
class Vector;
|
||||
@@ -53,9 +53,15 @@ class Face;
|
||||
class Vertex;
|
||||
|
||||
//! scales & mirrors a shape about a center
|
||||
|
||||
TopoDS_Shape TechDrawExport mirrorShapeVec(const TopoDS_Shape &input,
|
||||
const Base::Vector3d& inputCenter = Base::Vector3d(0.0, 0.0, 0.0),
|
||||
double scale = 1.0);
|
||||
|
||||
TopoDS_Shape TechDrawExport mirrorShape(const TopoDS_Shape &input,
|
||||
const gp_Pnt& inputCenter = gp_Pnt(0.0,0.0,0.0),
|
||||
double scale = 1.0);
|
||||
|
||||
TopoDS_Shape TechDrawExport scaleShape(const TopoDS_Shape &input,
|
||||
double scale);
|
||||
TopoDS_Shape TechDrawExport rotateShape(const TopoDS_Shape &input,
|
||||
@@ -102,7 +108,7 @@ public:
|
||||
const gp_Ax2 viewAxis);
|
||||
void projectShapeWithPolygonAlgo(const TopoDS_Shape &input,
|
||||
const gp_Ax2 viewAxis);
|
||||
|
||||
|
||||
void extractGeometry(edgeClass category, bool visible);
|
||||
void addFaceGeom(Face * f);
|
||||
void clearFaceGeom();
|
||||
@@ -128,12 +134,12 @@ public:
|
||||
TopoDS_Shape getHidIso(void) { return hidIso; }
|
||||
|
||||
//Are removeXXXXX functions really needed for GO?
|
||||
int addRandomVertex(Base::Vector3d pos);
|
||||
/* void removeRandomVertex(TechDraw::CosmeticVertex* cv);*/
|
||||
/* void removeRandomVertex(int idx);*/
|
||||
int addRandomEdge(TechDrawGeometry::BaseGeom* bg);
|
||||
/* void removeRandomEdge(TechDraw::CosmeticEdge* ce);*/
|
||||
/* void removeRandomEdge(int idx);*/
|
||||
int addCosmeticVertex(Base::Vector3d pos);
|
||||
/* void removeCosmeticVertex(TechDraw::CosmeticVertex* cv);*/
|
||||
/* void removeCosmeticVertex(int idx);*/
|
||||
int addCosmeticEdge(TechDraw::BaseGeom* bg);
|
||||
/* void removeCosmeticEdge(TechDraw::CosmeticEdge* ce);*/
|
||||
/* void removeCosmeticEdge(int idx);*/
|
||||
|
||||
protected:
|
||||
//HLR output
|
||||
@@ -163,7 +169,7 @@ protected:
|
||||
std::vector<Vertex *> vertexGeom;
|
||||
std::vector<Face *> faceGeom;
|
||||
|
||||
bool findVertex(Base::Vector2d v);
|
||||
bool findVertex(Base::Vector3d v);
|
||||
|
||||
std::string m_parentName;
|
||||
TechDraw::DrawView* m_parent;
|
||||
@@ -173,6 +179,6 @@ protected:
|
||||
bool m_usePolygonHLR;
|
||||
};
|
||||
|
||||
} //namespace TechDrawGeometry
|
||||
} //namespace TechDraw
|
||||
|
||||
#endif
|
||||
|
||||
@@ -80,7 +80,7 @@ bool LineSet::isDashed(void)
|
||||
}
|
||||
|
||||
//! calculates the apparent start point (ie start of overlay line) for dashed lines
|
||||
Base::Vector3d LineSet::calcApparentStart(TechDrawGeometry::BaseGeom* g)
|
||||
Base::Vector3d LineSet::calcApparentStart(TechDraw::BaseGeom* g)
|
||||
{
|
||||
Base::Vector3d result;
|
||||
Base::Vector3d start(g->getStartPoint().x,g->getStartPoint().y,0.0);
|
||||
@@ -151,7 +151,7 @@ Base::Vector3d LineSet::findAtomStart(void)
|
||||
return result;
|
||||
}
|
||||
|
||||
Base::Vector3d LineSet::getPatternStartPoint(TechDrawGeometry::BaseGeom* g, double &offset, double scale)
|
||||
Base::Vector3d LineSet::getPatternStartPoint(TechDraw::BaseGeom* g, double &offset, double scale)
|
||||
{
|
||||
Base::Vector3d result = getOrigin();
|
||||
Base::Vector3d atomStart = findAtomStart();
|
||||
|
||||
@@ -38,7 +38,7 @@
|
||||
//class TopoDS_Edge;
|
||||
//class Bnd_Box;
|
||||
|
||||
namespace TechDrawGeometry
|
||||
namespace TechDraw
|
||||
{
|
||||
class BaseGeom;
|
||||
}
|
||||
@@ -117,12 +117,12 @@ public:
|
||||
|
||||
void setPATLineSpec(PATLineSpec s) { m_hatchLine = s; }
|
||||
void setEdges(std::vector<TopoDS_Edge> e) {m_edges = e;}
|
||||
void setGeoms(std::vector<TechDrawGeometry::BaseGeom*> g) {m_geoms = g;}
|
||||
void setGeoms(std::vector<TechDraw::BaseGeom*> g) {m_geoms = g;}
|
||||
void setBBox(Bnd_Box bb) {m_box = bb;}
|
||||
|
||||
std::vector<TopoDS_Edge> getEdges(void) { return m_edges; }
|
||||
TopoDS_Edge getEdge(int i) {return m_edges.at(i);}
|
||||
std::vector<TechDrawGeometry::BaseGeom*> getGeoms(void) { return m_geoms; }
|
||||
std::vector<TechDraw::BaseGeom*> getGeoms(void) { return m_geoms; }
|
||||
|
||||
PATLineSpec getPATLineSpec(void) { return m_hatchLine; }
|
||||
double getOffset(void) { return m_hatchLine.getOffset(); } //delta X offset
|
||||
@@ -136,10 +136,10 @@ public:
|
||||
Base::Vector3d getUnitDir(void);
|
||||
Base::Vector3d getUnitOrtho(void);
|
||||
DashSpec getDashSpec(void) { return m_hatchLine.getDashParms();}
|
||||
Base::Vector3d calcApparentStart(TechDrawGeometry::BaseGeom* g);
|
||||
Base::Vector3d calcApparentStart(TechDraw::BaseGeom* g);
|
||||
Base::Vector3d findAtomStart(void);
|
||||
Base::Vector3d getLineOrigin(void); //point corresponding to pattern origin for this line (O + n*intervalX)
|
||||
Base::Vector3d getPatternStartPoint(TechDrawGeometry::BaseGeom* g, double &offset, double scale = 1.0);
|
||||
Base::Vector3d getPatternStartPoint(TechDraw::BaseGeom* g, double &offset, double scale = 1.0);
|
||||
|
||||
Bnd_Box getBBox(void) {return m_box;}
|
||||
double getMinX(void);
|
||||
@@ -151,7 +151,7 @@ public:
|
||||
|
||||
private:
|
||||
std::vector<TopoDS_Edge> m_edges;
|
||||
std::vector<TechDrawGeometry::BaseGeom*> m_geoms;
|
||||
std::vector<TechDraw::BaseGeom*> m_geoms;
|
||||
PATLineSpec m_hatchLine;
|
||||
Bnd_Box m_box;
|
||||
};
|
||||
|
||||
@@ -62,6 +62,7 @@
|
||||
#include "ViewProviderPage.h"
|
||||
|
||||
using namespace TechDrawGui;
|
||||
using namespace TechDraw;
|
||||
using namespace std;
|
||||
|
||||
|
||||
@@ -346,14 +347,14 @@ void execMidpoints(Gui::Command* cmd)
|
||||
}
|
||||
|
||||
//combine 2 loops?
|
||||
const std::vector<TechDrawGeometry::BaseGeom*> edges = objFeat->getEdgeGeometry();
|
||||
const std::vector<TechDraw::BaseGeom*> edges = objFeat->getEdgeGeometry();
|
||||
double scale = objFeat->getScale();
|
||||
for (auto& s: SubNames) {
|
||||
int GeoId(TechDraw::DrawUtil::getIndexFromName(s));
|
||||
TechDrawGeometry::BaseGeom* geom = edges.at(GeoId);
|
||||
Base::Vector2d mid = geom->getMidPoint();
|
||||
Base::Vector3d mid3(mid.x / scale, - mid.y / scale, 0.0);
|
||||
objFeat->addRandomVertex(mid3);
|
||||
TechDraw::BaseGeom* geom = edges.at(GeoId);
|
||||
Base::Vector3d mid = geom->getMidPoint();
|
||||
// Base::Vector3d mid3(mid.x / scale, - mid.y / scale, 0.0);
|
||||
objFeat->addCosmeticVertex(mid / scale);
|
||||
}
|
||||
cmd->updateActive();
|
||||
// Base::Console().Message("execMidpoints - exits\n");
|
||||
@@ -387,18 +388,18 @@ void execQuadrant(Gui::Command* cmd)
|
||||
}
|
||||
|
||||
//combine 2 loops?
|
||||
const std::vector<TechDrawGeometry::BaseGeom*> edges = objFeat->getEdgeGeometry();
|
||||
const std::vector<TechDraw::BaseGeom*> edges = objFeat->getEdgeGeometry();
|
||||
double scale = objFeat->getScale();
|
||||
bool nonCircles = false;
|
||||
for (auto& s: SubNames) {
|
||||
int GeoId(TechDraw::DrawUtil::getIndexFromName(s));
|
||||
TechDrawGeometry::BaseGeom* geom = edges.at(GeoId);
|
||||
TechDraw::BaseGeom* geom = edges.at(GeoId);
|
||||
//TODO: should this be restricted to circles??
|
||||
// if (geom->geomType == TechDrawGeometry::CIRCLE) {
|
||||
std::vector<Base::Vector2d> quads = geom->getQuads();
|
||||
// if (geom->geomType == TechDraw::CIRCLE) {
|
||||
std::vector<Base::Vector3d> quads = geom->getQuads();
|
||||
for (auto& q: quads) {
|
||||
Base::Vector3d q3(q.x / scale, - q.y / scale, 0.0);
|
||||
objFeat->addRandomVertex(q3);
|
||||
// Base::Vector3d q3(q.x / scale, - q.y / scale, 0.0);
|
||||
objFeat->addCosmeticVertex(q / scale);
|
||||
}
|
||||
// } else {
|
||||
// nonCircles = true;
|
||||
@@ -641,7 +642,15 @@ void CmdTechDrawFaceCenterLine::activated(int iMsg)
|
||||
SubNames = (*itSel).getSubNames();
|
||||
}
|
||||
}
|
||||
if (SubNames.empty()) {
|
||||
std::vector<std::string> faceNames;
|
||||
for (auto& s: SubNames) {
|
||||
std::string geomType = DrawUtil::getGeomTypeFromName(s);
|
||||
if (geomType == "Face") {
|
||||
faceNames.push_back(s);
|
||||
}
|
||||
}
|
||||
|
||||
if (faceNames.empty()) {
|
||||
QMessageBox::warning(Gui::getMainWindow(), QObject::tr("Selection Error"),
|
||||
QObject::tr("You must select a Face(s) for the center line."));
|
||||
return;
|
||||
@@ -649,7 +658,7 @@ void CmdTechDrawFaceCenterLine::activated(int iMsg)
|
||||
|
||||
Gui::Control().showDialog(new TaskDlgCenterLine(baseFeat,
|
||||
page,
|
||||
SubNames));
|
||||
faceNames));
|
||||
}
|
||||
|
||||
bool CmdTechDrawFaceCenterLine::isActive(void)
|
||||
@@ -728,12 +737,12 @@ void CmdTechDrawCosmeticEraser::activated(int iMsg)
|
||||
if (geomType == "Edge") {
|
||||
TechDraw::CosmeticEdge* ce = objFeat->getCosmeticEdgeByLink(idx);
|
||||
if (ce != nullptr) {
|
||||
objFeat->removeRandomEdge(ce);
|
||||
objFeat->removeCosmeticEdge(ce);
|
||||
}
|
||||
} else if (geomType == "Vertex") {
|
||||
TechDraw::CosmeticVertex* cv = objFeat->getCosmeticVertexByLink(idx);
|
||||
if (cv != nullptr) {
|
||||
objFeat->removeRandomVertex(cv);
|
||||
objFeat->removeCosmeticVertex(cv);
|
||||
}
|
||||
} else {
|
||||
QMessageBox::warning(Gui::getMainWindow(), QObject::tr("Wrong selection"),
|
||||
|
||||
@@ -1158,18 +1158,18 @@ int _isValidSingleEdge(Gui::Command* cmd) {
|
||||
if (SubNames.size() == 1) { //only 1 subshape selected
|
||||
if (TechDraw::DrawUtil::getGeomTypeFromName(SubNames[0]) == "Edge") { //the Name starts with "Edge"
|
||||
int GeoId( TechDraw::DrawUtil::getIndexFromName(SubNames[0]) );
|
||||
TechDrawGeometry::BaseGeom* geom = objFeat->getProjEdgeByIndex(GeoId);
|
||||
TechDraw::BaseGeom* geom = objFeat->getProjEdgeByIndex(GeoId);
|
||||
if (!geom) {
|
||||
Base::Console().Error("Logic Error: no geometry for GeoId: %d\n",GeoId);
|
||||
return isInvalid;
|
||||
}
|
||||
|
||||
if(geom->geomType == TechDrawGeometry::GENERIC) {
|
||||
TechDrawGeometry::Generic* gen1 = static_cast<TechDrawGeometry::Generic *>(geom);
|
||||
if(geom->geomType == TechDraw::GENERIC) {
|
||||
TechDraw::Generic* gen1 = static_cast<TechDraw::Generic *>(geom);
|
||||
if(gen1->points.size() > 2) { //the edge is a polyline
|
||||
return isInvalid;
|
||||
}
|
||||
Base::Vector2d line = gen1->points.at(1) - gen1->points.at(0);
|
||||
Base::Vector3d line = gen1->points.at(1) - gen1->points.at(0);
|
||||
if(fabs(line.y) < FLT_EPSILON ) {
|
||||
edgeType = isHorizontal;
|
||||
} else if(fabs(line.x) < FLT_EPSILON) {
|
||||
@@ -1177,14 +1177,14 @@ int _isValidSingleEdge(Gui::Command* cmd) {
|
||||
} else {
|
||||
edgeType = isDiagonal;
|
||||
}
|
||||
} else if (geom->geomType == TechDrawGeometry::CIRCLE ||
|
||||
geom->geomType == TechDrawGeometry::ARCOFCIRCLE ) {
|
||||
} else if (geom->geomType == TechDraw::CIRCLE ||
|
||||
geom->geomType == TechDraw::ARCOFCIRCLE ) {
|
||||
edgeType = isCircle;
|
||||
} else if (geom->geomType == TechDrawGeometry::ELLIPSE ||
|
||||
geom->geomType == TechDrawGeometry::ARCOFELLIPSE) {
|
||||
} else if (geom->geomType == TechDraw::ELLIPSE ||
|
||||
geom->geomType == TechDraw::ARCOFELLIPSE) {
|
||||
edgeType = isEllipse;
|
||||
} else if (geom->geomType == TechDrawGeometry::BSPLINE) {
|
||||
TechDrawGeometry::BSpline* spline = static_cast<TechDrawGeometry::BSpline*>(geom);
|
||||
} else if (geom->geomType == TechDraw::BSPLINE) {
|
||||
TechDraw::BSpline* spline = static_cast<TechDraw::BSpline*>(geom);
|
||||
if (spline->isCircle()) {
|
||||
edgeType = isBSplineCircle;
|
||||
} else {
|
||||
@@ -1235,23 +1235,23 @@ int _isValidEdgeToEdge(Gui::Command* cmd) {
|
||||
TechDraw::DrawUtil::getGeomTypeFromName(SubNames[1]) == "Edge") {
|
||||
int GeoId0( TechDraw::DrawUtil::getIndexFromName(SubNames[0]) );
|
||||
int GeoId1( TechDraw::DrawUtil::getIndexFromName(SubNames[1]) );
|
||||
TechDrawGeometry::BaseGeom* geom0 = objFeat0->getProjEdgeByIndex(GeoId0);
|
||||
TechDrawGeometry::BaseGeom* geom1 = objFeat0->getProjEdgeByIndex(GeoId1);
|
||||
TechDraw::BaseGeom* geom0 = objFeat0->getProjEdgeByIndex(GeoId0);
|
||||
TechDraw::BaseGeom* geom1 = objFeat0->getProjEdgeByIndex(GeoId1);
|
||||
if ((!geom0) || (!geom1)) {
|
||||
Base::Console().Error("Logic Error: no geometry for GeoId: %d or GeoId: %d\n",GeoId0,GeoId1);
|
||||
return isInvalid;
|
||||
}
|
||||
|
||||
if(geom0->geomType == TechDrawGeometry::GENERIC &&
|
||||
geom1->geomType == TechDrawGeometry::GENERIC) {
|
||||
TechDrawGeometry::Generic *gen0 = static_cast<TechDrawGeometry::Generic *>(geom0);
|
||||
TechDrawGeometry::Generic *gen1 = static_cast<TechDrawGeometry::Generic *>(geom1);
|
||||
if(geom0->geomType == TechDraw::GENERIC &&
|
||||
geom1->geomType == TechDraw::GENERIC) {
|
||||
TechDraw::Generic *gen0 = static_cast<TechDraw::Generic *>(geom0);
|
||||
TechDraw::Generic *gen1 = static_cast<TechDraw::Generic *>(geom1);
|
||||
if(gen0->points.size() > 2 ||
|
||||
gen1->points.size() > 2) { //the edge is a polyline
|
||||
return isInvalid;
|
||||
}
|
||||
Base::Vector2d line0 = gen0->points.at(1) - gen0->points.at(0);
|
||||
Base::Vector2d line1 = gen1->points.at(1) - gen1->points.at(0);
|
||||
Base::Vector3d line0 = gen0->points.at(1) - gen0->points.at(0);
|
||||
Base::Vector3d line1 = gen1->points.at(1) - gen1->points.at(0);
|
||||
double xprod = fabs(line0.x * line1.y - line0.y * line1.x);
|
||||
if(xprod > FLT_EPSILON) { //edges are not parallel
|
||||
return isAngle;
|
||||
@@ -1280,8 +1280,8 @@ bool _isValidVertexToEdge(Gui::Command* cmd) {
|
||||
const std::vector<std::string> SubNames = selection[0].getSubNames();
|
||||
if(SubNames.size() == 2) { //there are 2
|
||||
int eId,vId;
|
||||
TechDrawGeometry::BaseGeom* e;
|
||||
TechDrawGeometry::Vertex* v;
|
||||
TechDraw::BaseGeom* e;
|
||||
TechDraw::Vertex* v;
|
||||
if (TechDraw::DrawUtil::getGeomTypeFromName(SubNames[0]) == "Edge" &&
|
||||
TechDraw::DrawUtil::getGeomTypeFromName(SubNames[1]) == "Vertex") {
|
||||
eId = TechDraw::DrawUtil::getIndexFromName(SubNames[0]);
|
||||
@@ -1299,7 +1299,7 @@ bool _isValidVertexToEdge(Gui::Command* cmd) {
|
||||
Base::Console().Error("Logic Error: no geometry for GeoId: %d or GeoId: %d\n",eId,vId);
|
||||
return false;
|
||||
}
|
||||
if (e->geomType != TechDrawGeometry::GENERIC) { //only vertex-line for now.
|
||||
if (e->geomType != TechDraw::GENERIC) { //only vertex-line for now.
|
||||
return false;
|
||||
}
|
||||
result = true;
|
||||
|
||||
@@ -96,9 +96,9 @@ void QGIDrawingTemplate::draw()
|
||||
// Clear the previous geometry stored
|
||||
|
||||
// Get a list of geometry and iterate
|
||||
const std::vector<TechDrawGeometry::BaseGeom *> &geoms = tmplte->getGeometry();
|
||||
const std::vector<TechDraw::BaseGeom *> &geoms = tmplte->getGeometry();
|
||||
|
||||
std::vector<TechDrawGeometry::BaseGeom *>::const_iterator it = geoms.begin();
|
||||
std::vector<TechDraw::BaseGeom *>::const_iterator it = geoms.begin();
|
||||
|
||||
QPainterPath path;
|
||||
|
||||
@@ -106,12 +106,12 @@ void QGIDrawingTemplate::draw()
|
||||
// iterate through all the geometries
|
||||
for(; it != geoms.end(); ++it) {
|
||||
switch((*it)->geomType) {
|
||||
case TechDrawGeometry::GENERIC: {
|
||||
case TechDraw::GENERIC: {
|
||||
|
||||
TechDrawGeometry::Generic *geom = static_cast<TechDrawGeometry::Generic *>(*it);
|
||||
TechDraw::Generic *geom = static_cast<TechDraw::Generic *>(*it);
|
||||
|
||||
path.moveTo(geom->points[0].x, geom->points[0].y);
|
||||
std::vector<Base::Vector2d>::const_iterator it = geom->points.begin();
|
||||
std::vector<Base::Vector3d>::const_iterator it = geom->points.begin();
|
||||
|
||||
for(++it; it != geom->points.end(); ++it) {
|
||||
path.lineTo((*it).x, (*it).y);
|
||||
|
||||
@@ -50,8 +50,10 @@ QGIEdge::QGIEdge(int index) :
|
||||
setCosmetic(isCosmetic);
|
||||
}
|
||||
|
||||
//NOTE this refers to Qt cosmetic lines
|
||||
void QGIEdge::setCosmetic(bool state)
|
||||
{
|
||||
// Base::Console().Message("QGIE::setCosmetic(%d)\n", state);
|
||||
isCosmetic = state;
|
||||
if (state) {
|
||||
setWidth(0.0);
|
||||
|
||||
@@ -285,7 +285,7 @@ QGraphicsPathItem* QGIFace::lineFromPoints(Base::Vector3d start, Base::Vector3d
|
||||
return fillItem;
|
||||
}
|
||||
|
||||
QGraphicsPathItem* QGIFace::geomToLine(TechDrawGeometry::BaseGeom* base, LineSet& ls)
|
||||
QGraphicsPathItem* QGIFace::geomToLine(TechDraw::BaseGeom* base, LineSet& ls)
|
||||
{
|
||||
QGraphicsPathItem* fillItem = new QGraphicsPathItem(this);
|
||||
Base::Vector3d start(base->getStartPoint().x,
|
||||
@@ -302,7 +302,7 @@ QGraphicsPathItem* QGIFace::geomToLine(TechDrawGeometry::BaseGeom* base, LineSe
|
||||
|
||||
|
||||
//! make a fragment (length = remain) of a dashed line, with pattern starting at +offset
|
||||
QGraphicsPathItem* QGIFace::geomToStubbyLine(TechDrawGeometry::BaseGeom* base, double remain, LineSet& ls)
|
||||
QGraphicsPathItem* QGIFace::geomToStubbyLine(TechDraw::BaseGeom* base, double remain, LineSet& ls)
|
||||
{
|
||||
QGraphicsPathItem* fillItem = new QGraphicsPathItem(this);
|
||||
Base::Vector3d start(base->getStartPoint().x,
|
||||
|
||||
@@ -110,9 +110,9 @@ public:
|
||||
void clearFillItems(void);
|
||||
|
||||
void lineSetToFillItems(LineSet& ls);
|
||||
QGraphicsPathItem* geomToLine(TechDrawGeometry::BaseGeom* base,LineSet& ls);
|
||||
// QGraphicsPathItem* geomToOffsetLine(TechDrawGeometry::BaseGeom* base, double offset, const LineSet& ls);
|
||||
QGraphicsPathItem* geomToStubbyLine(TechDrawGeometry::BaseGeom* base, double offset, LineSet& ls);
|
||||
QGraphicsPathItem* geomToLine(TechDraw::BaseGeom* base,LineSet& ls);
|
||||
// QGraphicsPathItem* geomToOffsetLine(TechDraw::BaseGeom* base, double offset, const LineSet& ls);
|
||||
QGraphicsPathItem* geomToStubbyLine(TechDraw::BaseGeom* base, double offset, LineSet& ls);
|
||||
QGraphicsPathItem* lineFromPoints(Base::Vector3d start, Base::Vector3d end, DashSpec ds);
|
||||
|
||||
//bitmap texture fill parms method
|
||||
@@ -127,7 +127,7 @@ protected:
|
||||
std::vector<double> offsetDash(const std::vector<double> dv, const double offset);
|
||||
QPainterPath dashedPPath(const std::vector<double> dv, const Base::Vector3d start, const Base::Vector3d end);
|
||||
double dashRemain(const std::vector<double> dv, const double offset);
|
||||
double calcOffset(TechDrawGeometry::BaseGeom* g,LineSet ls);
|
||||
double calcOffset(TechDraw::BaseGeom* g,LineSet ls);
|
||||
int projIndex; //index of face in Projection. -1 for SectionFace.
|
||||
QGCustomRect *m_rect;
|
||||
|
||||
|
||||
@@ -204,17 +204,20 @@ QColor QGIPrimPath::getSelectColor()
|
||||
|
||||
void QGIPrimPath::setWidth(double w)
|
||||
{
|
||||
// Base::Console().Message("QGIPP::setWidth(%.3f)\n", w);
|
||||
m_width = w;
|
||||
m_pen.setWidthF(m_width);
|
||||
}
|
||||
|
||||
void QGIPrimPath::setStyle(Qt::PenStyle s)
|
||||
{
|
||||
// Base::Console().Message("QGIPP::setStyle(QTPS: %d)\n", s);
|
||||
m_styleCurrent = s;
|
||||
}
|
||||
|
||||
void QGIPrimPath::setStyle(int s)
|
||||
{
|
||||
// Base::Console().Message("QGIPP::setStyle(int: %d)\n", s);
|
||||
m_styleCurrent = (Qt::PenStyle) s;
|
||||
}
|
||||
|
||||
|
||||
@@ -41,7 +41,7 @@ namespace TechDraw {
|
||||
class DrawViewBalloon;
|
||||
}
|
||||
|
||||
namespace TechDrawGeometry {
|
||||
namespace TechDraw {
|
||||
class BaseGeom;
|
||||
class AOC;
|
||||
}
|
||||
|
||||
@@ -38,7 +38,7 @@ namespace TechDraw {
|
||||
class DrawViewDimension;
|
||||
}
|
||||
|
||||
namespace TechDrawGeometry {
|
||||
namespace TechDraw {
|
||||
class BaseGeom;
|
||||
class AOC;
|
||||
}
|
||||
|
||||
@@ -82,7 +82,6 @@
|
||||
|
||||
using namespace TechDraw;
|
||||
using namespace TechDrawGui;
|
||||
using namespace TechDrawGeometry;
|
||||
|
||||
const float lineScaleFactor = Rez::guiX(1.); // temp fiddle for devel
|
||||
|
||||
@@ -132,21 +131,21 @@ void QGIViewPart::setViewPartFeature(TechDraw::DrawViewPart *obj)
|
||||
setViewFeature(static_cast<TechDraw::DrawView *>(obj));
|
||||
}
|
||||
|
||||
QPainterPath QGIViewPart::drawPainterPath(TechDrawGeometry::BaseGeom *baseGeom) const
|
||||
QPainterPath QGIViewPart::drawPainterPath(TechDraw::BaseGeom *baseGeom) const
|
||||
{
|
||||
double rot = getViewObject()->Rotation.getValue();
|
||||
return geomToPainterPath(baseGeom,rot);
|
||||
}
|
||||
|
||||
|
||||
QPainterPath QGIViewPart::geomToPainterPath(TechDrawGeometry::BaseGeom *baseGeom, double rot)
|
||||
QPainterPath QGIViewPart::geomToPainterPath(TechDraw::BaseGeom *baseGeom, double rot)
|
||||
{
|
||||
Q_UNUSED(rot);
|
||||
QPainterPath path;
|
||||
|
||||
switch(baseGeom->geomType) {
|
||||
case TechDrawGeometry::CIRCLE: {
|
||||
TechDrawGeometry::Circle *geom = static_cast<TechDrawGeometry::Circle *>(baseGeom);
|
||||
case TechDraw::CIRCLE: {
|
||||
TechDraw::Circle *geom = static_cast<TechDraw::Circle *>(baseGeom);
|
||||
|
||||
double x = geom->center.x - geom->radius;
|
||||
double y = geom->center.y - geom->radius;
|
||||
@@ -156,8 +155,8 @@ QPainterPath QGIViewPart::geomToPainterPath(TechDrawGeometry::BaseGeom *baseGeom
|
||||
Rez::guiX(geom->radius * 2),
|
||||
Rez::guiX(geom->radius * 2)); //topleft@(x,y) radx,rady
|
||||
} break;
|
||||
case TechDrawGeometry::ARCOFCIRCLE: {
|
||||
TechDrawGeometry::AOC *geom = static_cast<TechDrawGeometry::AOC *>(baseGeom);
|
||||
case TechDraw::ARCOFCIRCLE: {
|
||||
TechDraw::AOC *geom = static_cast<TechDraw::AOC *>(baseGeom);
|
||||
|
||||
pathArc(path,
|
||||
Rez::guiX(geom->radius),
|
||||
@@ -170,8 +169,8 @@ QPainterPath QGIViewPart::geomToPainterPath(TechDrawGeometry::BaseGeom *baseGeom
|
||||
Rez::guiX(geom->startPnt.x),
|
||||
Rez::guiX(geom->startPnt.y));
|
||||
} break;
|
||||
case TechDrawGeometry::ELLIPSE: {
|
||||
TechDrawGeometry::Ellipse *geom = static_cast<TechDrawGeometry::Ellipse *>(baseGeom);
|
||||
case TechDraw::ELLIPSE: {
|
||||
TechDraw::Ellipse *geom = static_cast<TechDraw::Ellipse *>(baseGeom);
|
||||
|
||||
// Calculate start and end points as ellipse with theta = 0 and pi
|
||||
double startX = geom->center.x + geom->major * cos(geom->angle),
|
||||
@@ -202,8 +201,8 @@ QPainterPath QGIViewPart::geomToPainterPath(TechDrawGeometry::BaseGeom *baseGeom
|
||||
Rez::guiX(endY));
|
||||
|
||||
} break;
|
||||
case TechDrawGeometry::ARCOFELLIPSE: {
|
||||
TechDrawGeometry::AOE *geom = static_cast<TechDrawGeometry::AOE *>(baseGeom);
|
||||
case TechDraw::ARCOFELLIPSE: {
|
||||
TechDraw::AOE *geom = static_cast<TechDraw::AOE *>(baseGeom);
|
||||
|
||||
pathArc(path,
|
||||
Rez::guiX(geom->major),
|
||||
@@ -217,8 +216,8 @@ QPainterPath QGIViewPart::geomToPainterPath(TechDrawGeometry::BaseGeom *baseGeom
|
||||
Rez::guiX(geom->startPnt.y));
|
||||
|
||||
} break;
|
||||
case TechDrawGeometry::BEZIER: {
|
||||
TechDrawGeometry::BezierSegment *geom = static_cast<TechDrawGeometry::BezierSegment *>(baseGeom);
|
||||
case TechDraw::BEZIER: {
|
||||
TechDraw::BezierSegment *geom = static_cast<TechDraw::BezierSegment *>(baseGeom);
|
||||
|
||||
// Move painter to the beginning
|
||||
path.moveTo(Rez::guiX(geom->pnts[0].x), Rez::guiX(geom->pnts[0].y));
|
||||
@@ -243,10 +242,10 @@ QPainterPath QGIViewPart::geomToPainterPath(TechDrawGeometry::BaseGeom *baseGeom
|
||||
}
|
||||
}
|
||||
} break;
|
||||
case TechDrawGeometry::BSPLINE: {
|
||||
TechDrawGeometry::BSpline *geom = static_cast<TechDrawGeometry::BSpline *>(baseGeom);
|
||||
case TechDraw::BSPLINE: {
|
||||
TechDraw::BSpline *geom = static_cast<TechDraw::BSpline *>(baseGeom);
|
||||
|
||||
std::vector<TechDrawGeometry::BezierSegment>::const_iterator it = geom->segments.begin();
|
||||
std::vector<TechDraw::BezierSegment>::const_iterator it = geom->segments.begin();
|
||||
|
||||
// Move painter to the beginning of our first segment
|
||||
path.moveTo(Rez::guiX(it->pnts[0].x), Rez::guiX(it->pnts[0].y));
|
||||
@@ -272,11 +271,11 @@ QPainterPath QGIViewPart::geomToPainterPath(TechDrawGeometry::BaseGeom *baseGeom
|
||||
}
|
||||
}
|
||||
} break;
|
||||
case TechDrawGeometry::GENERIC: {
|
||||
TechDrawGeometry::Generic *geom = static_cast<TechDrawGeometry::Generic *>(baseGeom);
|
||||
case TechDraw::GENERIC: {
|
||||
TechDraw::Generic *geom = static_cast<TechDraw::Generic *>(baseGeom);
|
||||
|
||||
path.moveTo(Rez::guiX(geom->points[0].x), Rez::guiX(geom->points[0].y));
|
||||
std::vector<Base::Vector2d>::const_iterator it = geom->points.begin();
|
||||
std::vector<Base::Vector3d>::const_iterator it = geom->points.begin();
|
||||
for(++it; it != geom->points.end(); ++it) {
|
||||
path.lineTo(Rez::guiX((*it).x), Rez::guiX((*it).y));
|
||||
}
|
||||
@@ -334,6 +333,7 @@ void QGIViewPart::draw() {
|
||||
|
||||
void QGIViewPart::drawViewPart()
|
||||
{
|
||||
// Base::Console().Message("QGIVP::dvp()\n");
|
||||
auto viewPart( dynamic_cast<TechDraw::DrawViewPart *>(getViewObject()) );
|
||||
if ( viewPart == nullptr ) {
|
||||
return;
|
||||
@@ -364,8 +364,8 @@ void QGIViewPart::drawViewPart()
|
||||
// Draw Faces
|
||||
std::vector<TechDraw::DrawHatch*> hatchObjs = viewPart->getHatches();
|
||||
std::vector<TechDraw::DrawGeomHatch*> geomObjs = viewPart->getGeomHatches();
|
||||
const std::vector<TechDrawGeometry::Face *> &faceGeoms = viewPart->getFaceGeometry();
|
||||
std::vector<TechDrawGeometry::Face *>::const_iterator fit = faceGeoms.begin();
|
||||
const std::vector<TechDraw::Face *> &faceGeoms = viewPart->getFaceGeometry();
|
||||
std::vector<TechDraw::Face *>::const_iterator fit = faceGeoms.begin();
|
||||
for(int i = 0 ; fit != faceGeoms.end(); fit++, i++) {
|
||||
QGIFace* newFace = drawFace(*fit,i);
|
||||
newFace->isHatched(false);
|
||||
@@ -417,8 +417,8 @@ void QGIViewPart::drawViewPart()
|
||||
#endif //#if MOD_TECHDRAW_HANDLE_FACES
|
||||
|
||||
// Draw Edges
|
||||
const std::vector<TechDrawGeometry::BaseGeom *> &geoms = viewPart->getEdgeGeometry();
|
||||
std::vector<TechDrawGeometry::BaseGeom *>::const_iterator itEdge = geoms.begin();
|
||||
const std::vector<TechDraw::BaseGeom *> &geoms = viewPart->getEdgeGeometry();
|
||||
std::vector<TechDraw::BaseGeom *>::const_iterator itEdge = geoms.begin();
|
||||
QGIEdge* item;
|
||||
for(int i = 0 ; itEdge != geoms.end(); itEdge++, i++) {
|
||||
bool showEdge = false;
|
||||
@@ -445,15 +445,14 @@ void QGIViewPart::drawViewPart()
|
||||
if ((*itEdge)->cosmetic == true) {
|
||||
TechDraw::CosmeticEdge* ce = viewPart->getCosmeticEdgeByLink(i);
|
||||
if (ce != nullptr) {
|
||||
item->setNormalColor(ce->color.asValue<QColor>());
|
||||
item->setWidth(ce->width * lineScaleFactor);
|
||||
item->setStyle(ce->style);
|
||||
item->setNormalColor(ce->m_format.m_color.asValue<QColor>());
|
||||
item->setWidth(ce->m_format.m_weight * lineScaleFactor);
|
||||
item->setStyle(ce->m_format.m_style);
|
||||
}
|
||||
}
|
||||
addToGroup(item); //item is at scene(0,0), not group(0,0)
|
||||
item->setPos(0.0,0.0); //now at group(0,0)
|
||||
item->setPath(drawPainterPath(*itEdge));
|
||||
// item->setWidth(lineWidth);
|
||||
item->setZValue(ZVALUE::EDGE);
|
||||
if(!(*itEdge)->visible) {
|
||||
item->setWidth(lineWidthHid);
|
||||
@@ -502,8 +501,8 @@ void QGIViewPart::drawViewPart()
|
||||
}
|
||||
}
|
||||
|
||||
const std::vector<TechDrawGeometry::Vertex *> &verts = viewPart->getVertexGeometry();
|
||||
std::vector<TechDrawGeometry::Vertex *>::const_iterator vert = verts.begin();
|
||||
const std::vector<TechDraw::Vertex *> &verts = viewPart->getVertexGeometry();
|
||||
std::vector<TechDraw::Vertex *>::const_iterator vert = verts.begin();
|
||||
double cAdjust = vp->CenterScale.getValue();
|
||||
|
||||
for(int i = 0 ; vert != verts.end(); ++vert, i++) {
|
||||
@@ -529,7 +528,7 @@ void QGIViewPart::drawViewPart()
|
||||
item->setRadius(lineWidth * vertexScaleFactor);
|
||||
}
|
||||
addToGroup(item);
|
||||
item->setPos(Rez::guiX((*vert)->pnt.x), Rez::guiX((*vert)->pnt.y));
|
||||
item->setPos(Rez::guiX((*vert)->point.x), Rez::guiX((*vert)->point.y));
|
||||
item->setPrettyNormal();
|
||||
item->setZValue(ZVALUE::VERTEX);
|
||||
}
|
||||
@@ -543,13 +542,13 @@ void QGIViewPart::drawViewPart()
|
||||
}
|
||||
}
|
||||
|
||||
QGIFace* QGIViewPart::drawFace(TechDrawGeometry::Face* f, int idx)
|
||||
QGIFace* QGIViewPart::drawFace(TechDraw::Face* f, int idx)
|
||||
{
|
||||
std::vector<TechDrawGeometry::Wire *> fWires = f->wires;
|
||||
std::vector<TechDraw::Wire *> fWires = f->wires;
|
||||
QPainterPath facePath;
|
||||
for(std::vector<TechDrawGeometry::Wire *>::iterator wire = fWires.begin(); wire != fWires.end(); ++wire) {
|
||||
for(std::vector<TechDraw::Wire *>::iterator wire = fWires.begin(); wire != fWires.end(); ++wire) {
|
||||
QPainterPath wirePath;
|
||||
for(std::vector<TechDrawGeometry::BaseGeom *>::iterator edge = (*wire)->geoms.begin(); edge != (*wire)->geoms.end(); ++edge) {
|
||||
for(std::vector<TechDraw::BaseGeom *>::iterator edge = (*wire)->geoms.begin(); edge != (*wire)->geoms.end(); ++edge) {
|
||||
//Save the start Position
|
||||
QPainterPath edgePath = drawPainterPath(*edge);
|
||||
// If the current end point matches the shape end point the new edge path needs reversing
|
||||
@@ -993,6 +992,7 @@ void QGIViewPart::toggleCosmeticLines(bool state)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
TechDraw::DrawHatch* QGIViewPart::faceIsHatched(int i,std::vector<TechDraw::DrawHatch*> hatchObjs) const
|
||||
{
|
||||
TechDraw::DrawHatch* result = nullptr;
|
||||
|
||||
@@ -73,7 +73,7 @@ public:
|
||||
virtual void rotateView(void) override;
|
||||
|
||||
|
||||
static QPainterPath geomToPainterPath(TechDrawGeometry::BaseGeom *baseGeom, double rotation = 0.0);
|
||||
static QPainterPath geomToPainterPath(TechDraw::BaseGeom *baseGeom, double rotation = 0.0);
|
||||
/// Helper for pathArc()
|
||||
/*!
|
||||
* x_axis_rotation is in radian
|
||||
@@ -91,9 +91,9 @@ public:
|
||||
double curx, double cury);
|
||||
|
||||
protected:
|
||||
QPainterPath drawPainterPath(TechDrawGeometry::BaseGeom *baseGeom) const;
|
||||
QPainterPath drawPainterPath(TechDraw::BaseGeom *baseGeom) const;
|
||||
void drawViewPart();
|
||||
QGIFace* drawFace(TechDrawGeometry::Face* f, int idx);
|
||||
QGIFace* drawFace(TechDraw::Face* f, int idx);
|
||||
|
||||
virtual QVariant itemChange(GraphicsItemChange change, const QVariant &value) override;
|
||||
|
||||
|
||||
@@ -89,7 +89,7 @@ void QGIViewSection::drawSectionFace()
|
||||
return;
|
||||
}
|
||||
|
||||
std::vector<TechDrawGeometry::Face *>::iterator fit = sectionFaces.begin();
|
||||
std::vector<TechDraw::Face *>::iterator fit = sectionFaces.begin();
|
||||
QColor faceColor = (sectionVp->CutSurfaceColor.getValue()).asValue<QColor>();
|
||||
int i = 0;
|
||||
for(; fit != sectionFaces.end(); fit++, i++) {
|
||||
|
||||
@@ -55,12 +55,6 @@ double Rez::guiX(double x)
|
||||
return getRezFactor() * x;
|
||||
}
|
||||
|
||||
Base::Vector2d Rez::guiX(Base::Vector2d v)
|
||||
{
|
||||
Base::Vector2d result(guiX(v.y),guiX(v.y));
|
||||
return result;
|
||||
}
|
||||
|
||||
Base::Vector3d Rez::guiX(Base::Vector3d v)
|
||||
{
|
||||
Base::Vector3d result(guiX(v.x),guiX(v.y),guiX(v.z));
|
||||
@@ -73,12 +67,6 @@ double Rez::appX(double x)
|
||||
return x / getRezFactor();
|
||||
}
|
||||
|
||||
Base::Vector2d Rez::appX(Base::Vector2d v)
|
||||
{
|
||||
Base::Vector2d result(appX(v.y),appX(v.y));
|
||||
return result;
|
||||
}
|
||||
|
||||
Base::Vector3d Rez::appX(Base::Vector3d v)
|
||||
{
|
||||
Base::Vector3d result(appX(v.x),appX(v.y),appX(v.z));
|
||||
|
||||
@@ -41,11 +41,9 @@ public:
|
||||
static void setRezFactor(double f);
|
||||
//turn App side value to Gui side value
|
||||
static double guiX(double x);
|
||||
static Base::Vector2d guiX(Base::Vector2d v);
|
||||
static Base::Vector3d guiX(Base::Vector3d v);
|
||||
//turn Gui side value to App side value
|
||||
static double appX(double x);
|
||||
static Base::Vector2d appX(Base::Vector2d v);
|
||||
static Base::Vector3d appX(Base::Vector3d v);
|
||||
static QPointF appX(QPointF p);
|
||||
|
||||
|
||||
@@ -229,7 +229,7 @@ void TaskCenterLine::createCenterLine(void)
|
||||
}
|
||||
m_extendBy = ui->qsbExtend->rawValue();
|
||||
TechDraw::CosmeticEdge* ce = calcEndPoints(m_subNames,vertical,m_extendBy);
|
||||
m_partFeat->addRandomEdge(ce);
|
||||
m_partFeat->addCosmeticEdge(ce);
|
||||
m_partFeat->requestPaint();
|
||||
Gui::Command::updateActive();
|
||||
Gui::Command::commitCommand();
|
||||
@@ -302,7 +302,7 @@ TechDraw::CosmeticEdge* TaskCenterLine::calcEndPoints(std::vector<std::string> f
|
||||
continue;
|
||||
}
|
||||
int idx = TechDraw::DrawUtil::getIndexFromName(fn);
|
||||
std::vector<TechDrawGeometry::BaseGeom*> faceEdges =
|
||||
std::vector<TechDraw::BaseGeom*> faceEdges =
|
||||
m_partFeat->getFaceEdgesByIndex(idx);
|
||||
for (auto& fe: faceEdges) {
|
||||
if (!fe->cosmetic) {
|
||||
@@ -339,13 +339,13 @@ TechDraw::CosmeticEdge* TaskCenterLine::calcEndPoints(std::vector<std::string> f
|
||||
p2 = right;
|
||||
}
|
||||
|
||||
result = new TechDraw::CosmeticEdge(p1, p2, scale); //p1 & p2 are as found in GO.
|
||||
result = new TechDraw::CosmeticEdge(p1 / scale, p2 / scale); //p1 & p2 are as found in GO.
|
||||
App::Color ac;
|
||||
ac.setValue<QColor>(ui->cpLineColor->color());
|
||||
result->color = ac;
|
||||
result->width = ui->dsbWeight->value();
|
||||
result->style = ui->cboxStyle->currentIndex();
|
||||
result->visible = true;
|
||||
result->m_format.m_color = ac;
|
||||
result->m_format.m_weight = ui->dsbWeight->value();
|
||||
result->m_format.m_style = ui->cboxStyle->currentIndex();
|
||||
result->m_format.m_visible = true;
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
@@ -53,7 +53,7 @@ class DrawView;
|
||||
class DrawViewPart;
|
||||
}
|
||||
|
||||
namespace TechDrawGeometry
|
||||
namespace TechDraw
|
||||
{
|
||||
class Face;
|
||||
}
|
||||
|
||||
@@ -154,9 +154,9 @@ void TaskCosVertex::updateUi(void)
|
||||
void TaskCosVertex::addCosVertex(QPointF qPos)
|
||||
{
|
||||
// Base::Console().Message("TCV::addCosVertex(%s)\n", TechDraw::DrawUtil::formatVector(qPos).c_str());
|
||||
Base::Vector3d pos(qPos.x(), -qPos.y());
|
||||
Base::Vector3d pos(qPos.x(), qPos.y());
|
||||
// int idx =
|
||||
(void) m_baseFeat->addRandomVertex(pos);
|
||||
(void) m_baseFeat->addCosmeticVertex(pos);
|
||||
m_baseFeat->requestPaint();
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user