[TD]Add CenterLine edit function
This commit is contained in:
@@ -22,6 +22,7 @@
|
||||
|
||||
#include "PreCompiled.h"
|
||||
#ifndef _PreComp_
|
||||
#include <cmath>
|
||||
#include <gp_Pnt.hxx>
|
||||
#include <gp_Dir.hxx>
|
||||
#include <gp_Ax1.hxx>
|
||||
@@ -31,12 +32,13 @@
|
||||
#include <TopoDS.hxx>
|
||||
#include <TopoDS_Shape.hxx>
|
||||
#include <TopoDS_Edge.hxx>
|
||||
#include <BRepBndLib.hxx>
|
||||
#include <Bnd_Box.hxx>
|
||||
#endif // #ifndef _PreComp_
|
||||
|
||||
#include <Base/Console.h>
|
||||
#include <Base/Exception.h>
|
||||
#include <Base/Parameter.h>
|
||||
#include <Base/Tools2D.h>
|
||||
#include <Base/Vector3D.h>
|
||||
|
||||
#include <App/Application.h>
|
||||
@@ -45,6 +47,7 @@
|
||||
#include "DrawUtil.h"
|
||||
#include "GeometryObject.h"
|
||||
#include "Geometry.h"
|
||||
#include "DrawViewPart.h"
|
||||
|
||||
#include "Cosmetic.h"
|
||||
|
||||
@@ -151,7 +154,6 @@ CosmeticVertex::CosmeticVertex() : TechDraw::Vertex()
|
||||
visible = true;
|
||||
}
|
||||
|
||||
//CosmeticVertex::CosmeticVertex(Base::Vector3d loc) : TechDraw::Vertex(DrawUtil::invertY(loc))
|
||||
CosmeticVertex::CosmeticVertex(Base::Vector3d loc) : TechDraw::Vertex(loc)
|
||||
{
|
||||
Base::Reference<ParameterGrp> hGrp = App::GetApplication().GetUserParameter().GetGroup("BaseApp")->
|
||||
@@ -178,8 +180,7 @@ std::string CosmeticVertex::toCSV(void) const
|
||||
color.asHexString() << "," <<
|
||||
size << "," <<
|
||||
style << "," <<
|
||||
visible <<
|
||||
std::endl;
|
||||
visible;
|
||||
return ss.str();
|
||||
}
|
||||
|
||||
@@ -219,67 +220,46 @@ void CosmeticVertex::dump(char* title)
|
||||
CosmeticEdge::CosmeticEdge()
|
||||
{
|
||||
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();
|
||||
init();
|
||||
}
|
||||
|
||||
//CosmeticEdge::CosmeticEdge(Base::Vector3d pt1, Base::Vector3d pt2)
|
||||
CosmeticEdge::CosmeticEdge(Base::Vector3d pt1, Base::Vector3d pt2)
|
||||
{
|
||||
// Base:: Console().Message("CE::CE(%s, %s) \n",
|
||||
// DrawUtil::formatVector(p1).c_str(),
|
||||
// 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);
|
||||
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();
|
||||
init();
|
||||
}
|
||||
|
||||
//CosmeticEdge::CosmeticEdge(TopoDS_Edge e, Base::Vector3d mirrorPoint)
|
||||
CosmeticEdge::CosmeticEdge(TopoDS_Edge e)
|
||||
{
|
||||
// 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;
|
||||
|
||||
m_linkGeom = -1;
|
||||
m_format = LineFormat();
|
||||
init();
|
||||
}
|
||||
|
||||
CosmeticEdge::CosmeticEdge(TechDraw::BaseGeom* g)
|
||||
{
|
||||
// Base:: Console().Message("CE::CE(Base::Geom) \n");
|
||||
m_geometry = g;
|
||||
init();
|
||||
}
|
||||
|
||||
CosmeticEdge::~CosmeticEdge(void)
|
||||
{
|
||||
delete m_geometry;
|
||||
}
|
||||
|
||||
void CosmeticEdge::init(void)
|
||||
{
|
||||
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);
|
||||
TechDraw::BaseGeom* newGeom = nullptr;
|
||||
TopoDS_Edge e = m_geometry->occEdge;
|
||||
TopoDS_Shape s = TechDraw::scaleShape(e, scale);
|
||||
@@ -293,23 +273,19 @@ TechDraw::BaseGeom* CosmeticEdge::scaledGeometry(double scale)
|
||||
|
||||
std::string CosmeticEdge::toCSV(void) const
|
||||
{
|
||||
// Base::Console().Message( "CosmeticEdge::toCSV()\n");
|
||||
std::stringstream ss;
|
||||
if (m_geometry != nullptr) {
|
||||
ss << m_geometry->geomType << "," <<
|
||||
m_linkGeom <<
|
||||
ss << m_geometry->geomType <<
|
||||
",$$$," <<
|
||||
m_geometry->toCSV() <<
|
||||
",$$$," <<
|
||||
m_format.toCSV() <<
|
||||
std::endl;
|
||||
m_format.toCSV();
|
||||
}
|
||||
return ss.str();
|
||||
}
|
||||
|
||||
bool CosmeticEdge::fromCSV(std::string& lineSpec)
|
||||
{
|
||||
// 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");
|
||||
@@ -322,13 +298,12 @@ bool CosmeticEdge::fromCSV(std::string& lineSpec)
|
||||
}
|
||||
|
||||
std::vector<std::string> values = DrawUtil::split(tokens[0]);
|
||||
unsigned int maxCells = 2;
|
||||
unsigned int maxCells = 1;
|
||||
if (values.size() < maxCells) {
|
||||
Base::Console().Message( "CosmeticEdge::fromCSV(%s) invalid CSV entry\n",lineSpec.c_str() );
|
||||
return false;
|
||||
}
|
||||
int geomType = atoi(values[0].c_str());
|
||||
m_linkGeom = atoi(values[1].c_str());
|
||||
|
||||
int lastToken = 0;
|
||||
if (geomType == TechDraw::GeomType::GENERIC) {
|
||||
@@ -374,11 +349,249 @@ bool CosmeticEdge::fromCSV(std::string& lineSpec)
|
||||
return true;
|
||||
}
|
||||
|
||||
//duplicate of CV routine. make static? or base class?
|
||||
void CosmeticEdge::replaceGeometry(TechDraw::BaseGeom* g)
|
||||
{
|
||||
delete m_geometry;
|
||||
m_geometry = g;
|
||||
}
|
||||
|
||||
void CosmeticEdge::dump(char* title)
|
||||
{
|
||||
Base::Console().Message("CE::dump - %s \n",title);
|
||||
Base::Console().Message("CE::dump - %s \n",toCSV().c_str());
|
||||
}
|
||||
|
||||
//*********************************************************
|
||||
CenterLine::CenterLine(void)
|
||||
{
|
||||
start = Base::Vector3d(0.0, 0.0, 0.0);
|
||||
end = Base::Vector3d(0.0, 0.0, 0.0);
|
||||
mode = 0;
|
||||
hShift = 0.0;
|
||||
vShift = 0.0;
|
||||
rotate = 0.0;
|
||||
extendBy = 0.0;
|
||||
}
|
||||
|
||||
CenterLine::CenterLine(Base::Vector3d p1, Base::Vector3d p2)
|
||||
{
|
||||
start = p1;
|
||||
end = p2;
|
||||
mode = 0;
|
||||
hShift = 0.0;
|
||||
vShift = 0.0;
|
||||
rotate = 0.0;
|
||||
extendBy = 0.0;
|
||||
}
|
||||
|
||||
CenterLine::CenterLine(Base::Vector3d p1, Base::Vector3d p2,
|
||||
int m,
|
||||
double h,
|
||||
double v,
|
||||
double r,
|
||||
double x)
|
||||
{
|
||||
start = p1;
|
||||
end = p2;
|
||||
mode = m;
|
||||
hShift = h;
|
||||
vShift = v;
|
||||
rotate = r;
|
||||
extendBy = x;
|
||||
}
|
||||
|
||||
CenterLine::~CenterLine()
|
||||
{
|
||||
}
|
||||
|
||||
TechDraw::BaseGeom* CenterLine::scaledGeometry(TechDraw::DrawViewPart* partFeat)
|
||||
{
|
||||
double scale = partFeat->getScale();
|
||||
if (m_faces.empty() ) {
|
||||
Base::Console().Message("CL::scaledGeometry - no Faces!\n");
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
std::pair<Base::Vector3d, Base::Vector3d> ends =
|
||||
calcEndPoints(partFeat,
|
||||
m_faces,
|
||||
mode, extendBy,
|
||||
hShift,vShift, rotate);
|
||||
TechDraw::BaseGeom* newGeom = nullptr;
|
||||
Base::Vector3d p1 = DrawUtil::invertY(ends.first);
|
||||
Base::Vector3d p2 = DrawUtil::invertY(ends.second);
|
||||
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);
|
||||
TopoDS_Shape s = TechDraw::scaleShape(e, scale);
|
||||
TopoDS_Edge newEdge = TopoDS::Edge(s);
|
||||
newGeom = TechDraw::BaseGeom::baseFactory(newEdge);
|
||||
newGeom->classOfEdge = ecHARD;
|
||||
newGeom->visible = true;
|
||||
newGeom->cosmetic = true;
|
||||
return newGeom;
|
||||
}
|
||||
|
||||
std::string CenterLine::toCSV(void) const
|
||||
{
|
||||
std::stringstream ss;
|
||||
ss << start.x << "," << //0
|
||||
start.y << "," << //1
|
||||
start.z << "," << //2
|
||||
end.x << "," << //3
|
||||
end.y << "," << //4
|
||||
end.z << "," << //5
|
||||
mode << "," << //6
|
||||
hShift << "," << //7
|
||||
vShift << "," << //8
|
||||
rotate << "," << //9
|
||||
extendBy << "," << //10
|
||||
m_faces.size(); //11
|
||||
if (!m_faces.empty()) {
|
||||
for (auto& f: m_faces) {
|
||||
if (!f.empty()) {
|
||||
ss << "," << f ;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
std::string clCSV = ss.str();
|
||||
std::string fmtCSV = fmt.toCSV();
|
||||
return clCSV + ",$$$," + fmtCSV;
|
||||
}
|
||||
|
||||
bool CenterLine::fromCSV(std::string& lineSpec)
|
||||
{
|
||||
if (lineSpec.length() == 0) {
|
||||
Base::Console().Message( "CenterLine::fromCSV - lineSpec empty\n");
|
||||
return false;
|
||||
}
|
||||
|
||||
std::vector<std::string> tokens = DrawUtil::tokenize(lineSpec);
|
||||
if (tokens.size() != 2) {
|
||||
Base::Console().Message("CenterLine::fromCSV - tokenize failed - size: %d\n",tokens.size());
|
||||
}
|
||||
|
||||
if (tokens[0].length() == 0) {
|
||||
Base::Console().Message( "CenterLine::fromCSV - token0 empty\n");
|
||||
return false;
|
||||
}
|
||||
|
||||
std::vector<std::string> values = DrawUtil::split(tokens[0]);
|
||||
|
||||
// variable length record, can't determine maxCells in advance.
|
||||
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);
|
||||
mode = atoi(values[6].c_str());
|
||||
hShift = atof(values[7].c_str());
|
||||
vShift = atof(values[8].c_str());
|
||||
rotate = atof(values[9].c_str());
|
||||
extendBy = atof(values[10].c_str());
|
||||
int faceCount = atoi(values[11].c_str());
|
||||
int i = 0;
|
||||
for ( ; i < faceCount; i++ ) {
|
||||
m_faces.push_back(values[12 + i]);
|
||||
}
|
||||
fmt.fromCSV(tokens[1]);
|
||||
return true;
|
||||
}
|
||||
|
||||
void CenterLine::dump(char* title)
|
||||
{
|
||||
Base::Console().Message("CL::dump - %s \n",title);
|
||||
Base::Console().Message("CL::dump - %s \n",toCSV().c_str());
|
||||
}
|
||||
|
||||
std::pair<Base::Vector3d, Base::Vector3d> CenterLine::calcEndPoints(DrawViewPart* partFeat,
|
||||
std::vector<std::string> faceNames,
|
||||
int vert, double ext,
|
||||
double hShift, double vShift,
|
||||
double rotate)
|
||||
{
|
||||
std::pair<Base::Vector3d, Base::Vector3d> result;
|
||||
if (faceNames.empty()) {
|
||||
Base::Console().Message("CL::calcEndPoints - no faces!\n");
|
||||
return result;
|
||||
}
|
||||
|
||||
Bnd_Box faceBox;
|
||||
faceBox.SetGap(0.0);
|
||||
|
||||
double scale = partFeat->getScale();
|
||||
double hss = hShift * scale;
|
||||
double vss = vShift * scale;
|
||||
|
||||
for (auto& fn: faceNames) {
|
||||
if (TechDraw::DrawUtil::getGeomTypeFromName(fn) != "Face") {
|
||||
continue;
|
||||
}
|
||||
int idx = TechDraw::DrawUtil::getIndexFromName(fn);
|
||||
std::vector<TechDraw::BaseGeom*> faceEdges =
|
||||
partFeat->getFaceEdgesByIndex(idx);
|
||||
for (auto& fe: faceEdges) {
|
||||
if (!fe->cosmetic) {
|
||||
BRepBndLib::Add(fe->occEdge, faceBox);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
double Xmin,Ymin,Zmin,Xmax,Ymax,Zmax;
|
||||
faceBox.Get(Xmin,Ymin,Zmin,Xmax,Ymax,Zmax);
|
||||
|
||||
double Xspan = fabs(Xmax - Xmin);
|
||||
// Xspan = (Xspan / 2.0) + (ext * scale); //this should be right? edges in GO are scaled!
|
||||
// Xspan = (Xspan / 2.0) + ext;
|
||||
Xspan = (Xspan / 2.0);
|
||||
double Xmid = Xmin + fabs(Xmax - Xmin) / 2.0;
|
||||
|
||||
double Yspan = fabs(Ymax - Ymin);
|
||||
// Yspan = (Yspan / 2.0) + (ext * scale);
|
||||
// Yspan = (Yspan / 2.0) + ext;
|
||||
Yspan = (Yspan / 2.0);
|
||||
double Ymid = Ymin + fabs(Ymax - Ymin) / 2.0;
|
||||
|
||||
Base::Vector3d p1, p2;
|
||||
if (vert == 0) { //vertical
|
||||
Base::Vector3d top(Xmid + hss, (Ymid - Yspan - ext) + vss, 0.0);
|
||||
Base::Vector3d bottom(Xmid + hss, (Ymid + Yspan + ext) + vss, 0.0);
|
||||
p1 = top;
|
||||
p2 = bottom;
|
||||
} else if (vert == 1) { //horizontal
|
||||
Base::Vector3d left((Xmid - Xspan - ext) + hss, Ymid + vss, 0.0);
|
||||
Base::Vector3d right((Xmid + Xspan + ext) + hss, Ymid + vss, 0.0);
|
||||
p1 = left;
|
||||
p2 = right;
|
||||
} else { //vert == 2 //aligned
|
||||
Base::Console().Message("CL::calcEndPoints - aligned is not implemented yet\n");
|
||||
Base::Vector3d top(Xmid + hss, (Ymid - Yspan - ext) + vss, 0.0);
|
||||
Base::Vector3d bottom(Xmid + hss, (Ymid + Yspan + ext) + vss, 0.0);
|
||||
p1 = top;
|
||||
p2 = bottom;
|
||||
}
|
||||
|
||||
Base::Vector3d bbxCenter(Xmid, Ymid, 0.0);
|
||||
if (!DrawUtil::fpCompare(rotate, 0.0)) {
|
||||
//rotate p1, p2 about bbxCenter
|
||||
double cosTheta = cos(rotate * M_PI / 180.0);
|
||||
double sinTheta = sin(rotate * M_PI / 180.0);
|
||||
Base::Vector3d toOrg = p1 - bbxCenter;
|
||||
double xRot = toOrg.x * cosTheta - toOrg.y * sinTheta;
|
||||
double yRot = toOrg.y * cosTheta + toOrg.x * sinTheta;
|
||||
p1 = Base::Vector3d(xRot, yRot, 0.0) + bbxCenter;
|
||||
toOrg = p2 - bbxCenter;
|
||||
xRot = toOrg.x * cosTheta - toOrg.y * sinTheta;
|
||||
yRot = toOrg.y * cosTheta + toOrg.x * sinTheta;
|
||||
p2 = Base::Vector3d(xRot, yRot, 0.0) + bbxCenter;
|
||||
}
|
||||
|
||||
result.first = p1 / scale;
|
||||
result.second = p2 / scale;
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
@@ -30,11 +30,8 @@
|
||||
|
||||
class TopoDS_Edge;
|
||||
|
||||
/*namespace TechDraw {*/
|
||||
/*class BaseGeom;*/
|
||||
/*}*/
|
||||
|
||||
namespace TechDraw {
|
||||
class DrawViewPart;
|
||||
|
||||
class TechDrawExport LineFormat
|
||||
{
|
||||
@@ -78,11 +75,9 @@ public:
|
||||
bool visible;
|
||||
|
||||
protected:
|
||||
/* std::vector<std::string> split(std::string csvLine);*/
|
||||
|
||||
};
|
||||
|
||||
//class TechDrawExport CosmeticEdge: publix TechDraw::BaseGeom
|
||||
class TechDrawExport CosmeticEdge
|
||||
{
|
||||
public:
|
||||
@@ -90,23 +85,58 @@ public:
|
||||
CosmeticEdge(Base::Vector3d p1, Base::Vector3d p2);
|
||||
CosmeticEdge(TopoDS_Edge e);
|
||||
CosmeticEdge(TechDraw::BaseGeom* g);
|
||||
virtual ~CosmeticEdge() = default;
|
||||
virtual ~CosmeticEdge();
|
||||
|
||||
void init(void);
|
||||
TechDraw::BaseGeom* scaledGeometry(double scale);
|
||||
|
||||
std::string toCSV(void) const;
|
||||
bool fromCSV(std::string& lineSpec);
|
||||
virtual std::string toCSV(void) const;
|
||||
virtual bool fromCSV(std::string& lineSpec);
|
||||
void replaceGeometry(TechDraw::BaseGeom* newGeom);
|
||||
void dump(char* title);
|
||||
|
||||
TechDraw::BaseGeom* m_geometry;
|
||||
TechDraw::BaseGeom* m_geometry;
|
||||
LineFormat m_format;
|
||||
int m_linkGeom;
|
||||
|
||||
protected:
|
||||
/* std::vector<std::string> split(std::string csvLine);*/
|
||||
|
||||
};
|
||||
|
||||
class TechDrawExport CenterLine
|
||||
{
|
||||
public:
|
||||
CenterLine();
|
||||
CenterLine(Base::Vector3d p1, Base::Vector3d p2);
|
||||
CenterLine(Base::Vector3d p1, Base::Vector3d p2,
|
||||
int m,
|
||||
double h,
|
||||
double v,
|
||||
double r,
|
||||
double x);
|
||||
~CenterLine();
|
||||
|
||||
std::string toCSV(void) const;
|
||||
bool fromCSV(std::string& lineSpec);
|
||||
CosmeticEdge* toCosmeticEdge(TechDraw::DrawViewPart* partFeat); //??
|
||||
TechDraw::BaseGeom* scaledGeometry(TechDraw::DrawViewPart* partFeat);
|
||||
static std::pair<Base::Vector3d, Base::Vector3d> calcEndPoints(
|
||||
TechDraw::DrawViewPart* partFeat,
|
||||
std::vector<std::string> faceNames,
|
||||
int vert, double ext,
|
||||
double hShift, double vShift,
|
||||
double rotate);
|
||||
void dump(char* title);
|
||||
|
||||
Base::Vector3d start;
|
||||
Base::Vector3d end;
|
||||
std::vector<std::string> m_faces;
|
||||
int mode; // vert/horiz/aligned
|
||||
double hShift;
|
||||
double vShift;
|
||||
double rotate;
|
||||
double extendBy;
|
||||
LineFormat fmt;
|
||||
};
|
||||
|
||||
} //end namespace TechDraw
|
||||
|
||||
|
||||
@@ -38,7 +38,7 @@ namespace TechDraw
|
||||
class DrawPage;
|
||||
class DrawViewClip;
|
||||
class DrawLeaderLine;
|
||||
class CosmeticVertex;
|
||||
/*class CosmeticVertex;*/
|
||||
|
||||
/** Base class of all View Features in the drawing module
|
||||
*/
|
||||
|
||||
@@ -136,7 +136,6 @@ short DrawViewDetail::mustExecute() const
|
||||
void DrawViewDetail::onChanged(const App::Property* prop)
|
||||
{
|
||||
if (!isRestoring()) {
|
||||
//Base::Console().Message("TRACE - DVD::onChanged(%s) - %s\n",prop->getName(),Label.getValue());
|
||||
if (prop == &Reference) {
|
||||
std::string lblText = "Detail " +
|
||||
std::string(Reference.getValue());
|
||||
@@ -158,9 +157,6 @@ App::DocumentObjectExecReturn *DrawViewDetail::execute(void)
|
||||
return App::DocumentObject::StdReturn;
|
||||
}
|
||||
|
||||
rebuildCosmoVertex();
|
||||
rebuildCosmoEdge();
|
||||
|
||||
App::DocumentObject* baseObj = BaseView.getValue();
|
||||
if (!baseObj) {
|
||||
bool isRestoring = getDocument()->testStatus(App::Document::Status::Restoring);
|
||||
@@ -352,17 +348,14 @@ App::DocumentObjectExecReturn *DrawViewDetail::execute(void)
|
||||
}
|
||||
|
||||
//add back the cosmetic vertices
|
||||
for (auto& v: vertexCosmetic) {
|
||||
for (auto& v: CVertexTable) {
|
||||
int idx = geometryObject->addCosmeticVertex(v->point() * getScale());
|
||||
v->linkGeom = idx;
|
||||
}
|
||||
|
||||
//add the cosmetic Edges to geometry Edges list
|
||||
for (auto& e: edgeCosmetic) {
|
||||
TechDraw::BaseGeom* scaledGeom = e->scaledGeometry(getScale());
|
||||
int idx = geometryObject->addCosmeticEdge(scaledGeom);
|
||||
e->m_linkGeom = idx;
|
||||
}
|
||||
addCosmeticEdgesToGeom();
|
||||
//add centerlines to geometry edges list
|
||||
addCenterLinesToGeom();
|
||||
|
||||
requestPaint();
|
||||
dvp->requestPaint(); //to refresh detail highlight!
|
||||
|
||||
@@ -261,7 +261,7 @@ App::DocumentObjectExecReturn *DrawViewDimension::execute(void)
|
||||
m_hasGeometry = true;
|
||||
} else if(Type.isValue("Radius")){
|
||||
int idx = DrawUtil::getIndexFromName(subElements[0]);
|
||||
TechDraw::BaseGeom* base = getViewPart()->getProjEdgeByIndex(idx);
|
||||
TechDraw::BaseGeom* base = getViewPart()->getGeomByIndex(idx);
|
||||
TechDraw::Circle* circle;
|
||||
arcPoints pts;
|
||||
pts.center = Base::Vector3d(0.0,0.0,0.0);
|
||||
@@ -348,7 +348,7 @@ App::DocumentObjectExecReturn *DrawViewDimension::execute(void)
|
||||
m_hasGeometry = true;
|
||||
} else if(Type.isValue("Diameter")){
|
||||
int idx = DrawUtil::getIndexFromName(subElements[0]);
|
||||
TechDraw::BaseGeom* base = getViewPart()->getProjEdgeByIndex(idx);
|
||||
TechDraw::BaseGeom* base = getViewPart()->getGeomByIndex(idx);
|
||||
TechDraw::Circle* circle;
|
||||
arcPoints pts;
|
||||
pts.center = Base::Vector3d(0.0,0.0,0.0);
|
||||
@@ -440,8 +440,8 @@ App::DocumentObjectExecReturn *DrawViewDimension::execute(void)
|
||||
}
|
||||
int idx0 = DrawUtil::getIndexFromName(subElements[0]);
|
||||
int idx1 = DrawUtil::getIndexFromName(subElements[1]);
|
||||
TechDraw::BaseGeom* edge0 = getViewPart()->getProjEdgeByIndex(idx0);
|
||||
TechDraw::BaseGeom* edge1 = getViewPart()->getProjEdgeByIndex(idx1);
|
||||
TechDraw::BaseGeom* edge0 = getViewPart()->getGeomByIndex(idx0);
|
||||
TechDraw::BaseGeom* edge1 = getViewPart()->getGeomByIndex(idx1);
|
||||
TechDraw::Generic *gen0;
|
||||
TechDraw::Generic *gen1;
|
||||
if (edge0 && edge0->geomType == TechDraw::GeomType::GENERIC) {
|
||||
@@ -723,7 +723,7 @@ pointPair DrawViewDimension::getPointsOneEdge()
|
||||
|
||||
//TODO: Check for straight line Edge?
|
||||
int idx = DrawUtil::getIndexFromName(subElements[0]);
|
||||
TechDraw::BaseGeom* geom = getViewPart()->getProjEdgeByIndex(idx);
|
||||
TechDraw::BaseGeom* geom = getViewPart()->getGeomByIndex(idx);
|
||||
TechDraw::Generic* gen;
|
||||
if (geom && geom->geomType == TechDraw::GeomType::GENERIC) {
|
||||
gen = static_cast<TechDraw::Generic*>(geom);
|
||||
@@ -744,8 +744,8 @@ pointPair DrawViewDimension::getPointsTwoEdges()
|
||||
|
||||
int idx0 = DrawUtil::getIndexFromName(subElements[0]);
|
||||
int idx1 = DrawUtil::getIndexFromName(subElements[1]);
|
||||
TechDraw::BaseGeom* geom0 = getViewPart()->getProjEdgeByIndex(idx0);
|
||||
TechDraw::BaseGeom* geom1 = getViewPart()->getProjEdgeByIndex(idx1);
|
||||
TechDraw::BaseGeom* geom0 = getViewPart()->getGeomByIndex(idx0);
|
||||
TechDraw::BaseGeom* geom1 = getViewPart()->getGeomByIndex(idx1);
|
||||
if ((geom0 == nullptr) ||
|
||||
(geom1 == nullptr) ) {
|
||||
Base::Console().Error("Error: DVD - %s - 2D references are corrupt\n",getNameInDocument());
|
||||
@@ -786,10 +786,10 @@ pointPair DrawViewDimension::getPointsEdgeVert()
|
||||
TechDraw::BaseGeom* e;
|
||||
TechDraw::Vertex* v;
|
||||
if (DrawUtil::getGeomTypeFromName(subElements[0]) == "Edge") {
|
||||
e = getViewPart()->getProjEdgeByIndex(idx0);
|
||||
e = getViewPart()->getGeomByIndex(idx0);
|
||||
v = getViewPart()->getProjVertexByIndex(idx1);
|
||||
} else {
|
||||
e = getViewPart()->getProjEdgeByIndex(idx1);
|
||||
e = getViewPart()->getGeomByIndex(idx1);
|
||||
v = getViewPart()->getProjVertexByIndex(idx0);
|
||||
}
|
||||
if ((v == nullptr) ||
|
||||
@@ -882,7 +882,7 @@ bool DrawViewDimension::checkReferences2D() const
|
||||
if (!s.empty()) {
|
||||
int idx = DrawUtil::getIndexFromName(s);
|
||||
if (DrawUtil::getGeomTypeFromName(s) == "Edge") {
|
||||
TechDraw::BaseGeom* geom = getViewPart()->getProjEdgeByIndex(idx);
|
||||
TechDraw::BaseGeom* geom = getViewPart()->getGeomByIndex(idx);
|
||||
if (geom == nullptr) {
|
||||
result = false;
|
||||
break;
|
||||
@@ -997,7 +997,7 @@ 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]);
|
||||
TechDraw::BaseGeom* base = getViewPart()->getProjEdgeByIndex(idx);
|
||||
TechDraw::BaseGeom* base = getViewPart()->getGeomByIndex(idx);
|
||||
if( base && base->geomType == TechDraw::GeomType::ARCOFCIRCLE ) {
|
||||
TechDraw::AOC* aoc = static_cast<TechDraw::AOC*> (base);
|
||||
if (aoc->intersectsArc(s,pointOnCircle)) {
|
||||
|
||||
@@ -139,7 +139,7 @@ DrawViewPart::DrawViewPart(void) :
|
||||
//properties that control HLR algoaffect Appearance
|
||||
bool coarseView = hGrp->GetBool("CoarseView", false);
|
||||
ADD_PROPERTY_TYPE(CoarseView, (coarseView), sgroup, App::Prop_None, "Coarse View on/off");
|
||||
//visible outline
|
||||
//add property for visible outline?
|
||||
ADD_PROPERTY_TYPE(SmoothVisible ,(false),sgroup,App::Prop_None,"Visible Smooth lines on/off");
|
||||
ADD_PROPERTY_TYPE(SeamVisible ,(false),sgroup,App::Prop_None,"Visible Seam lines on/off");
|
||||
ADD_PROPERTY_TYPE(IsoVisible ,(false),sgroup,App::Prop_None,"Visible Iso u,v lines on/off");
|
||||
@@ -151,6 +151,12 @@ DrawViewPart::DrawViewPart(void) :
|
||||
|
||||
ADD_PROPERTY_TYPE(CosmeticVertexList ,(""),sgroup,App::Prop_None,"CosmeticVertex Save/Restore");
|
||||
ADD_PROPERTY_TYPE(CosmeticEdgeList ,(""),sgroup,App::Prop_None,"CosmeticEdge Save/Restore");
|
||||
ADD_PROPERTY_TYPE(CenterLineList ,(""),sgroup,App::Prop_None,"CenterLine Save/Restore");
|
||||
|
||||
std::vector<std::string> emptyList;
|
||||
CosmeticVertexList.setValues(emptyList);
|
||||
CosmeticEdgeList.setValues(emptyList);
|
||||
CenterLineList.setValues(emptyList);
|
||||
|
||||
geometryObject = nullptr;
|
||||
getRunControl();
|
||||
@@ -163,7 +169,6 @@ DrawViewPart::~DrawViewPart()
|
||||
|
||||
TopoDS_Shape DrawViewPart::getSourceShape(void) const
|
||||
{
|
||||
// Base::Console().Message("DVP::getSourceShape() - %s\n", getNameInDocument());
|
||||
TopoDS_Shape result;
|
||||
const std::vector<App::DocumentObject*>& links = Source.getValues();
|
||||
if (links.empty()) {
|
||||
@@ -208,7 +213,6 @@ TopoDS_Shape DrawViewPart::getSourceShape(void) const
|
||||
|
||||
std::vector<TopoDS_Shape> DrawViewPart::getShapesFromObject(App::DocumentObject* docObj) const
|
||||
{
|
||||
// Base::Console().Message("DVP::getShapesFromObject() - %s\n", getNameInDocument());
|
||||
std::vector<TopoDS_Shape> result;
|
||||
App::GroupExtension* gex = dynamic_cast<App::GroupExtension*>(docObj);
|
||||
App::Property* gProp = docObj->getPropertyByName("Group");
|
||||
@@ -256,7 +260,6 @@ std::vector<TopoDS_Shape> DrawViewPart::getShapesFromObject(App::DocumentObject*
|
||||
|
||||
TopoDS_Shape DrawViewPart::getSourceShapeFused(void) const
|
||||
{
|
||||
// Base::Console().Message("DVP::getSourceShapeFused() - %s\n", getNameInDocument());
|
||||
TopoDS_Shape baseShape = getSourceShape();
|
||||
if (!baseShape.IsNull()) {
|
||||
TopoDS_Iterator it(baseShape);
|
||||
@@ -267,7 +270,7 @@ TopoDS_Shape DrawViewPart::getSourceShapeFused(void) const
|
||||
BRepAlgoAPI_Fuse mkFuse(fusedShape, aChild);
|
||||
// Let's check if the fusion has been successful
|
||||
if (!mkFuse.IsDone()) {
|
||||
Base::Console().Error("DVp - Fusion failed - %s\n",getNameInDocument());
|
||||
Base::Console().Error("DVP - Fusion failed - %s\n",getNameInDocument());
|
||||
return baseShape;
|
||||
}
|
||||
fusedShape = mkFuse.Shape();
|
||||
@@ -279,14 +282,10 @@ TopoDS_Shape DrawViewPart::getSourceShapeFused(void) const
|
||||
|
||||
App::DocumentObjectExecReturn *DrawViewPart::execute(void)
|
||||
{
|
||||
// Base::Console().Message("DVP::execute() - %s\n",getNameInDocument());
|
||||
if (!keepUpdated()) {
|
||||
return App::DocumentObject::StdReturn;
|
||||
}
|
||||
|
||||
// rebuildCosmoVertex();
|
||||
// rebuildCosmoEdge();
|
||||
|
||||
App::Document* doc = getDocument();
|
||||
bool isRestoring = doc->testStatus(App::Document::Status::Restoring);
|
||||
const std::vector<App::DocumentObject*>& links = Source.getValues();
|
||||
@@ -346,18 +345,14 @@ App::DocumentObjectExecReturn *DrawViewPart::execute(void)
|
||||
}
|
||||
|
||||
//add back the cosmetic vertices
|
||||
for (auto& v: vertexCosmetic) {
|
||||
for (auto& v: CVertexTable) {
|
||||
int idx = geometryObject->addCosmeticVertex(v->point() * getScale());
|
||||
v->linkGeom = idx;
|
||||
}
|
||||
|
||||
//add the cosmetic Edges to geometry Edges list
|
||||
for (auto& e: edgeCosmetic) {
|
||||
TechDraw::BaseGeom* scaledGeom = e->scaledGeometry(getScale());
|
||||
int idx = geometryObject->addCosmeticEdge(scaledGeom);
|
||||
e->m_linkGeom = idx;
|
||||
}
|
||||
|
||||
addCosmeticEdgesToGeom();
|
||||
//add centerlines to geometry edges list
|
||||
addCenterLinesToGeom();
|
||||
auto end = chrono::high_resolution_clock::now();
|
||||
auto diff = end - start;
|
||||
double diffOut = chrono::duration <double, milli> (diff).count();
|
||||
@@ -407,7 +402,6 @@ void DrawViewPart::onChanged(const App::Property* prop)
|
||||
//note: slightly different than routine with same name in DrawProjectSplit
|
||||
TechDraw::GeometryObject* DrawViewPart::buildGeometryObject(TopoDS_Shape shape, gp_Ax2 viewAxis)
|
||||
{
|
||||
// Base::Console().Message("DVP::buildGO() - %s\n", getNameInDocument());
|
||||
TechDraw::GeometryObject* go = new TechDraw::GeometryObject(getNameInDocument(), this);
|
||||
go->setIsoCount(IsoCount.getValue());
|
||||
go->isPerspective(Perspective.getValue());
|
||||
@@ -668,15 +662,15 @@ const std::vector<TechDraw::BaseGeom *> & DrawViewPart::getEdgeGeometry() const
|
||||
}
|
||||
|
||||
//! returns existing BaseGeom of 2D Edge(idx)
|
||||
TechDraw::BaseGeom* DrawViewPart::getProjEdgeByIndex(int idx) const
|
||||
TechDraw::BaseGeom* DrawViewPart::getGeomByIndex(int idx) const
|
||||
{
|
||||
const std::vector<TechDraw::BaseGeom *> &geoms = getEdgeGeometry();
|
||||
if (geoms.empty()) {
|
||||
Base::Console().Log("INFO - getProjEdgeByIndex(%d) - no Edge Geometry. Probably restoring?\n",idx);
|
||||
Base::Console().Log("INFO - getGeomByIndex(%d) - no Edge Geometry. Probably restoring?\n",idx);
|
||||
return NULL;
|
||||
}
|
||||
if ((unsigned)idx >= geoms.size()) {
|
||||
Base::Console().Log("INFO - getProjEdgeByIndex(%d) - invalid index\n",idx);
|
||||
Base::Console().Log("INFO - getGeomByIndex(%d) - invalid index\n",idx);
|
||||
return NULL;
|
||||
}
|
||||
return geoms.at(idx);
|
||||
@@ -707,9 +701,11 @@ std::vector<TechDraw::BaseGeom*> DrawViewPart::getFaceEdgesByIndex(int idx) cons
|
||||
for (auto& w: projFace->wires) {
|
||||
for (auto& g:w->geoms) {
|
||||
if (g->cosmetic) {
|
||||
Base::Console().Message("DVP::getFaceEdgesByIndex - found cosmetic edge\n");
|
||||
//if g is cosmetic, we should skip it
|
||||
Base::Console().Message("DVP::getFaceEdgesByIndex - found cosmetic edge\n");
|
||||
} else {
|
||||
result.push_back(g);
|
||||
}
|
||||
result.push_back(g);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -727,11 +723,9 @@ std::vector<TopoDS_Wire> DrawViewPart::getWireForFace(int idx) const
|
||||
int i = 0;
|
||||
for (auto& g:w->geoms) {
|
||||
edges.push_back(g->occEdge);
|
||||
// DrawUtil::dumpEdge("DVP Face edge",i,g->occEdge);
|
||||
i++;
|
||||
}
|
||||
TopoDS_Wire occwire = EdgeWalker::makeCleanWire(edges);
|
||||
// BRepLib::BuildCurves3d(occwire); //probably don't need this
|
||||
result.push_back(occwire);
|
||||
}
|
||||
|
||||
@@ -858,7 +852,6 @@ const std::vector<TechDraw::BaseGeom *> DrawViewPart::getVisibleFaceEdges() con
|
||||
return geometryObject->getVisibleFaceEdges(SmoothVisible.getValue(),SeamVisible.getValue());
|
||||
}
|
||||
|
||||
//is this really the projection plane??
|
||||
gp_Pln DrawViewPart::getProjPlane() const
|
||||
{
|
||||
Base::Vector3d plnPnt(0.0,0.0,0.0);
|
||||
@@ -891,7 +884,6 @@ bool DrawViewPart::showSectionEdges(void)
|
||||
//! hatches, geomhatches, dimensions,...
|
||||
void DrawViewPart::unsetupObject()
|
||||
{
|
||||
// Base::Console().Message("DVP::unsetupObject()\n");
|
||||
nowUnsetting = true;
|
||||
App::Document* doc = getDocument();
|
||||
std::string docName = doc->getName();
|
||||
@@ -963,18 +955,20 @@ bool DrawViewPart::isIso(void) const
|
||||
//* Cosmetics
|
||||
//********
|
||||
|
||||
//build vertexCosmetic from CosmeticVertexList
|
||||
void DrawViewPart::rebuildCosmoVertex(void)
|
||||
//build CVertexTable from CosmeticVertexList
|
||||
void DrawViewPart::readCVertexProp(void)
|
||||
{
|
||||
// Base::Console().Message("DVP::rebuildCosmoVertex()\n");
|
||||
vertexCosmetic.clear();
|
||||
CVertexTable.clear();
|
||||
std::vector<std::string> restoreVerts = CosmeticVertexList.getValues();
|
||||
if (restoreVerts.empty()) {
|
||||
return;
|
||||
}
|
||||
for (auto& rv: restoreVerts) {
|
||||
if (!rv.empty()) {
|
||||
CosmeticVertex* cv = new CosmeticVertex();
|
||||
bool rc = cv->fromCSV(rv);
|
||||
if (rc) {
|
||||
vertexCosmetic.push_back(cv);
|
||||
CVertexTable.push_back(cv);
|
||||
} else {
|
||||
delete cv;
|
||||
}
|
||||
@@ -982,18 +976,20 @@ void DrawViewPart::rebuildCosmoVertex(void)
|
||||
}
|
||||
}
|
||||
|
||||
//build edgeCosmetic from CosmeticEdgeList
|
||||
void DrawViewPart::rebuildCosmoEdge(void)
|
||||
//build CEdgeTable from CosmeticEdgeList
|
||||
void DrawViewPart::readCEdgeProp(void)
|
||||
{
|
||||
// Base::Console().Message("DVP::rebuildCosmoEdge()\n");
|
||||
edgeCosmetic.clear();
|
||||
CEdgeTable.clear();
|
||||
std::vector<std::string> restoreEdges = CosmeticEdgeList.getValues();
|
||||
if (restoreEdges.empty()) {
|
||||
return;
|
||||
}
|
||||
for (auto& re: restoreEdges) {
|
||||
if (!re.empty()) {
|
||||
CosmeticEdge* ce = new CosmeticEdge();
|
||||
bool rc = ce->fromCSV(re);
|
||||
if (rc) {
|
||||
edgeCosmetic.push_back(ce);
|
||||
CEdgeTable.push_back(ce);
|
||||
} else {
|
||||
delete ce;
|
||||
}
|
||||
@@ -1001,13 +997,33 @@ void DrawViewPart::rebuildCosmoEdge(void)
|
||||
}
|
||||
}
|
||||
|
||||
// adds a cosmetic vertex to vertexCosmetic and CosmeticVertexList
|
||||
//build CLineTable from CenterLineList
|
||||
void DrawViewPart::readCLineProp(void)
|
||||
{
|
||||
CLineTable.clear();
|
||||
std::vector<std::string> restoreLines = CenterLineList.getValues();
|
||||
if (restoreLines.empty()) {
|
||||
return;
|
||||
}
|
||||
for (auto& rl: restoreLines) {
|
||||
if (!rl.empty()) {
|
||||
CenterLine* cl = new CenterLine();
|
||||
bool rc = cl->fromCSV(rl);
|
||||
if (rc) {
|
||||
CLineTable.push_back(cl);
|
||||
} else {
|
||||
delete cl;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// adds a cosmetic vertex to CVertexTable and CosmeticVertexList
|
||||
int DrawViewPart::addCosmeticVertex(Base::Vector3d pos)
|
||||
{
|
||||
// Base::Console().Message("DVP::addCosmeticVertex(%s)\n", DrawUtil::formatVector(pos).c_str());
|
||||
TechDraw::CosmeticVertex* cv = new TechDraw::CosmeticVertex(pos);
|
||||
vertexCosmetic.push_back(cv);
|
||||
int newIdx = (int) (vertexCosmetic.size() - 1);
|
||||
int newIdx = (int) (CVertexTable.size());
|
||||
CVertexTable.push_back(cv);
|
||||
std::string csv = cv->toCSV();
|
||||
std::vector<std::string> vertexList = CosmeticVertexList.getValues();
|
||||
vertexList.push_back(csv);
|
||||
@@ -1016,9 +1032,8 @@ int DrawViewPart::addCosmeticVertex(Base::Vector3d pos)
|
||||
return newIdx;
|
||||
}
|
||||
|
||||
void DrawViewPart::stuffCosmeticVertexList(void)
|
||||
void DrawViewPart::writeCVertProp(void)
|
||||
{
|
||||
// Base::Console().Message("DVP::stuffCosmeticVertexList()\n");
|
||||
std::vector<std::string> saveVerts;
|
||||
const std::vector<TechDraw::CosmeticVertex*> cosVerts = getCosmeticVertex();
|
||||
for (auto& cv: cosVerts) {
|
||||
@@ -1030,10 +1045,9 @@ void DrawViewPart::stuffCosmeticVertexList(void)
|
||||
|
||||
void DrawViewPart::removeCosmeticVertex(TechDraw::CosmeticVertex* cv)
|
||||
{
|
||||
// Base::Console().Message("DVP::removeCosmeticVertex(cv) - cvs in: %d\n", vertexCosmetic.size());
|
||||
bool found = false;
|
||||
std::vector<TechDraw::CosmeticVertex*> newCosmoVertex;
|
||||
for (auto& v: vertexCosmetic) {
|
||||
for (auto& v: CVertexTable) {
|
||||
if (cv == v) {
|
||||
found = true;
|
||||
continue;
|
||||
@@ -1046,26 +1060,25 @@ void DrawViewPart::removeCosmeticVertex(TechDraw::CosmeticVertex* cv)
|
||||
delete cv;
|
||||
}
|
||||
|
||||
vertexCosmetic = newCosmoVertex;
|
||||
stuffCosmeticVertexList();
|
||||
CVertexTable = newCosmoVertex;
|
||||
writeCVertProp();
|
||||
recomputeFeature();
|
||||
}
|
||||
|
||||
void DrawViewPart::removeCosmeticVertex(int idx)
|
||||
{
|
||||
if (idx < (int) vertexCosmetic.size()) {
|
||||
TechDraw::CosmeticVertex* cvSave = vertexCosmetic.at(idx);
|
||||
vertexCosmetic.erase(vertexCosmetic.begin() + idx);
|
||||
if (idx < (int) CVertexTable.size()) {
|
||||
TechDraw::CosmeticVertex* cvSave = CVertexTable.at(idx);
|
||||
CVertexTable.erase(CVertexTable.begin() + idx);
|
||||
delete cvSave;
|
||||
}
|
||||
|
||||
stuffCosmeticVertexList();
|
||||
writeCVertProp();
|
||||
recomputeFeature();
|
||||
}
|
||||
|
||||
TechDraw::CosmeticVertex* DrawViewPart::getCosmeticVertexByIndex(int idx) const
|
||||
{
|
||||
// Base::Console().Message("DVP::getCosmeticVertexByIndex(%d)\n", idx);
|
||||
CosmeticVertex* result = nullptr;
|
||||
const std::vector<TechDraw::CosmeticVertex*> verts = getCosmeticVertex();
|
||||
if ((unsigned) idx < verts.size()) {
|
||||
@@ -1075,9 +1088,8 @@ TechDraw::CosmeticVertex* DrawViewPart::getCosmeticVertexByIndex(int idx) const
|
||||
}
|
||||
|
||||
//find the cosmetic vertex corresponding to geometry vertex idx
|
||||
TechDraw::CosmeticVertex* DrawViewPart::getCosmeticVertexByLink(int idx) const
|
||||
TechDraw::CosmeticVertex* DrawViewPart::getCosmeticVertexByGeom(int idx) const
|
||||
{
|
||||
// Base::Console().Message("DVP::getVosmeticVertexByLinkIndex(%d)\n", idx);
|
||||
CosmeticVertex* result = nullptr;
|
||||
const std::vector<TechDraw::CosmeticVertex*> verts = getCosmeticVertex();
|
||||
for (auto& cv: verts) {
|
||||
@@ -1091,69 +1103,64 @@ TechDraw::CosmeticVertex* DrawViewPart::getCosmeticVertexByLink(int idx) const
|
||||
|
||||
void DrawViewPart::clearCosmeticVertices(void)
|
||||
{
|
||||
// Base::Console().Message("DVP::clearCosmeticVertices()\n");
|
||||
vertexCosmetic.clear();
|
||||
CVertexTable.clear();
|
||||
std::vector<std::string> noVerts;
|
||||
CosmeticVertexList.setValues(noVerts);
|
||||
}
|
||||
|
||||
void DrawViewPart::clearCosmeticEdges(void)
|
||||
{
|
||||
// Base::Console().Message("DVP::clearCosmeticEdges()\n");
|
||||
edgeCosmetic.clear();
|
||||
CEdgeTable.clear();
|
||||
std::vector<std::string> noEdges;
|
||||
CosmeticEdgeList.setValues(noEdges);
|
||||
}
|
||||
|
||||
// adds a cosmetic edge to edgeCosmetic and CosmeticEdgeList
|
||||
// adds a cosmetic edge to CEdgeTable 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());
|
||||
TechDraw::CosmeticEdge* ce = new TechDraw::CosmeticEdge(p1, p2);
|
||||
edgeCosmetic.push_back(ce);
|
||||
int newIdx = (int) (edgeCosmetic.size() - 1);
|
||||
// stuffCosmeticEdgeList();
|
||||
int newIdx = (int) (CEdgeTable.size());
|
||||
CEdgeTable.push_back(ce);
|
||||
std::string csv = ce->toCSV();
|
||||
|
||||
std::vector<std::string> edgeList = CosmeticEdgeList.getValues();
|
||||
edgeList.push_back(csv);
|
||||
CosmeticEdgeList.setValues(edgeList);
|
||||
|
||||
return newIdx;
|
||||
}
|
||||
|
||||
int DrawViewPart::addCosmeticEdge(TopoDS_Edge e)
|
||||
{
|
||||
// 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();
|
||||
int newIdx = (int) (CEdgeTable.size());
|
||||
CEdgeTable.push_back(ce);
|
||||
std::string csv = ce->toCSV();
|
||||
|
||||
std::vector<std::string> edgeList = CosmeticEdgeList.getValues();
|
||||
edgeList.push_back(csv);
|
||||
CosmeticEdgeList.setValues(edgeList);
|
||||
|
||||
return newIdx;
|
||||
}
|
||||
|
||||
int DrawViewPart::addCosmeticEdge(CosmeticEdge* ce)
|
||||
{
|
||||
// Base::Console().Message("DVP::addCosmeticEdge(CosmeticEdge)\n");
|
||||
edgeCosmetic.push_back(ce);
|
||||
int newIdx = (int) (edgeCosmetic.size() - 1);
|
||||
// stuffCosmeticEdgeList();
|
||||
int newIdx = (int) (CEdgeTable.size());
|
||||
CEdgeTable.push_back(ce);
|
||||
std::string csv = ce->toCSV();
|
||||
|
||||
std::vector<std::string> edgeList = CosmeticEdgeList.getValues();
|
||||
edgeList.push_back(csv);
|
||||
CosmeticEdgeList.setValues(edgeList);
|
||||
|
||||
return newIdx;
|
||||
}
|
||||
|
||||
void DrawViewPart::stuffCosmeticEdgeList(void)
|
||||
void DrawViewPart::writeCEdgeProp(void)
|
||||
{
|
||||
// Base::Console().Message("DVP::stuffCosmeticEdgeList()\n");
|
||||
std::vector<std::string> saveEdges;
|
||||
const std::vector<TechDraw::CosmeticEdge*> cosEdges = getCosmeticEdge();
|
||||
const std::vector<TechDraw::CosmeticEdge*> cosEdges = getCosmeticEdges();
|
||||
for (auto& ce: cosEdges) {
|
||||
std::string csv = ce->toCSV();
|
||||
saveEdges.push_back(csv);
|
||||
@@ -1161,12 +1168,12 @@ void DrawViewPart::stuffCosmeticEdgeList(void)
|
||||
CosmeticEdgeList.setValues(saveEdges);
|
||||
}
|
||||
|
||||
|
||||
void DrawViewPart::removeCosmeticEdge(TechDraw::CosmeticEdge* ce)
|
||||
{
|
||||
// Base::Console().Message("DVP::removeCosmeticEdge(ce) - ces in: %d\n", edgeCosmetic.size());
|
||||
bool found = false;
|
||||
std::vector<TechDraw::CosmeticEdge*> newCosmoEdge;
|
||||
for (auto& e: edgeCosmetic) {
|
||||
for (auto& e: CEdgeTable) {
|
||||
if (ce == e) {
|
||||
found = true;
|
||||
continue;
|
||||
@@ -1178,28 +1185,44 @@ void DrawViewPart::removeCosmeticEdge(TechDraw::CosmeticEdge* ce)
|
||||
(found) ) {
|
||||
delete ce;
|
||||
}
|
||||
edgeCosmetic = newCosmoEdge;
|
||||
stuffCosmeticEdgeList();
|
||||
CEdgeTable = newCosmoEdge;
|
||||
writeCEdgeProp();
|
||||
recomputeFeature();
|
||||
}
|
||||
|
||||
void DrawViewPart::removeCosmeticEdge(int 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);
|
||||
if (idx < (int) CEdgeTable.size()) {
|
||||
TechDraw::CosmeticEdge* ceSave = CEdgeTable.at(idx);
|
||||
CEdgeTable.erase(CEdgeTable.begin() + idx);
|
||||
delete ceSave;
|
||||
writeCEdgeProp();
|
||||
recomputeFeature();
|
||||
}
|
||||
stuffCosmeticEdgeList();
|
||||
recomputeFeature();
|
||||
}
|
||||
|
||||
void DrawViewPart::replaceCosmeticEdge(int idx, TechDraw::CosmeticEdge* ce)
|
||||
{
|
||||
std::vector<TechDraw::CosmeticEdge*> edges = getCosmeticEdges();
|
||||
if (idx < (int) edges.size()) {
|
||||
edges.at(idx) = ce;
|
||||
//TODO: GC old ce
|
||||
writeCEdgeProp();
|
||||
recomputeFeature();
|
||||
}
|
||||
}
|
||||
|
||||
void DrawViewPart::replaceCosmeticEdgeByGeom(int geomIndex, TechDraw::CosmeticEdge* ce)
|
||||
{
|
||||
const std::vector<TechDraw::BaseGeom*> &geoms = getEdgeGeometry();
|
||||
int sourceIndex = geoms.at(geomIndex)->sourceIndex();
|
||||
replaceCosmeticEdge(sourceIndex, ce);
|
||||
}
|
||||
|
||||
TechDraw::CosmeticEdge* DrawViewPart::getCosmeticEdgeByIndex(int idx) const
|
||||
{
|
||||
// Base::Console().Message("DVP::getCosmeticEdgeByIndex(%d)\n", idx);
|
||||
CosmeticEdge* result = nullptr;
|
||||
const std::vector<TechDraw::CosmeticEdge*> edges = getCosmeticEdge();
|
||||
const std::vector<TechDraw::CosmeticEdge*> edges = getCosmeticEdges();
|
||||
if (idx < (int) edges.size()) {
|
||||
result = edges.at(idx);
|
||||
}
|
||||
@@ -1207,31 +1230,167 @@ TechDraw::CosmeticEdge* DrawViewPart::getCosmeticEdgeByIndex(int idx) const
|
||||
}
|
||||
|
||||
//find the cosmetic edge corresponding to geometry edge idx
|
||||
TechDraw::CosmeticEdge* DrawViewPart::getCosmeticEdgeByLink(int idx) const
|
||||
TechDraw::CosmeticEdge* DrawViewPart::getCosmeticEdgeByGeom(int idx) const
|
||||
{
|
||||
// Base::Console().Message("DVP::getCosmeticEdgeByLinkIndex(%d)\n", idx);
|
||||
CosmeticEdge* result = nullptr;
|
||||
const std::vector<TechDraw::CosmeticEdge*> edges = getCosmeticEdge();
|
||||
for (auto& ce: edges) {
|
||||
if (ce->m_linkGeom == idx) {
|
||||
result = ce;
|
||||
const std::vector<TechDraw::BaseGeom*> &geoms = getEdgeGeometry();
|
||||
int sourceIndex = geoms.at(idx)->sourceIndex();
|
||||
result = CEdgeTable.at(sourceIndex);
|
||||
return result;
|
||||
}
|
||||
|
||||
//find the index of a cosmetic edge
|
||||
int DrawViewPart::getCosmeticEdgeIndex(TechDraw::CosmeticEdge* ce) const
|
||||
{
|
||||
int result = -1;
|
||||
const std::vector<TechDraw::CosmeticEdge*> edges = getCosmeticEdges();
|
||||
int i = 0;
|
||||
int stop = (int) edges.size();
|
||||
for (; i < stop; i++) {
|
||||
if (edges.at(i) == ce) {
|
||||
result = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
void DrawViewPart::clearCenterLines(void)
|
||||
{
|
||||
CLineTable.clear();
|
||||
std::vector<std::string> noLines;
|
||||
CenterLineList.setValues(noLines);
|
||||
}
|
||||
|
||||
// adds a centerLine edge to CLineTable and CenterLineList
|
||||
int DrawViewPart::addCenterLine(CenterLine* cl)
|
||||
{
|
||||
int newIdx = (int) (CLineTable.size());
|
||||
CLineTable.push_back(cl);
|
||||
std::string csv = cl->toCSV();
|
||||
std::vector<std::string> lineList = CenterLineList.getValues();
|
||||
lineList.push_back(csv);
|
||||
CenterLineList.setValues(lineList);
|
||||
return newIdx;
|
||||
}
|
||||
|
||||
void DrawViewPart::writeCListProp(void)
|
||||
{
|
||||
std::vector<std::string> saveLines;
|
||||
const std::vector<TechDraw::CenterLine*> cLines = getCenterLines();
|
||||
for (auto& cl: cLines) {
|
||||
std::string csv = cl->toCSV();
|
||||
saveLines.push_back(csv);
|
||||
}
|
||||
CenterLineList.setValues(saveLines);
|
||||
}
|
||||
|
||||
void DrawViewPart::removeCenterLine(TechDraw::CenterLine* cl)
|
||||
{
|
||||
bool found = false;
|
||||
int i = 0;
|
||||
int stop = CLineTable.size();
|
||||
for ( ; i < stop; i++) {
|
||||
TechDraw::CenterLine* l = CLineTable.at(i);
|
||||
if (cl == l) {
|
||||
found = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if ( (cl != nullptr) &&
|
||||
(found) ) {
|
||||
removeCenterLine(i);
|
||||
}
|
||||
}
|
||||
|
||||
void DrawViewPart::removeCenterLine(int idx)
|
||||
{
|
||||
if (idx < (int) CLineTable.size()) {
|
||||
CLineTable.erase(CLineTable.begin() + idx);
|
||||
writeCListProp();
|
||||
recomputeFeature();
|
||||
}
|
||||
}
|
||||
|
||||
void DrawViewPart::replaceCenterLine(int idx, TechDraw::CenterLine* cl)
|
||||
{
|
||||
std::vector<TechDraw::CenterLine*> lines = getCenterLines();
|
||||
if (idx < (int) lines.size()) {
|
||||
lines.at(idx) = cl;
|
||||
writeCListProp();
|
||||
recomputeFeature();
|
||||
}
|
||||
}
|
||||
|
||||
void DrawViewPart::replaceCenterLineByGeom(int geomIndex, TechDraw::CenterLine* cl)
|
||||
{
|
||||
const std::vector<TechDraw::BaseGeom*> &geoms = getEdgeGeometry();
|
||||
int sourceIndex = geoms.at(geomIndex)->sourceIndex();
|
||||
replaceCenterLine(sourceIndex, cl);
|
||||
}
|
||||
|
||||
TechDraw::CenterLine* DrawViewPart::getCenterLineByIndex(int idx) const
|
||||
{
|
||||
CenterLine* result = nullptr;
|
||||
const std::vector<TechDraw::CenterLine*> lines = getCenterLines();
|
||||
if (idx < (int) lines.size()) {
|
||||
result = lines.at(idx);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
//find the cosmetic edge corresponding to geometry edge idx
|
||||
TechDraw::CenterLine* DrawViewPart::getCenterLineByGeom(int idx) const
|
||||
{
|
||||
const std::vector<TechDraw::BaseGeom*> &geoms = getEdgeGeometry();
|
||||
int sourceIndex = geoms.at(idx)->sourceIndex();
|
||||
CenterLine* result = nullptr;
|
||||
const std::vector<TechDraw::CenterLine*> lines = getCenterLines();
|
||||
result = lines.at(sourceIndex);
|
||||
return result;
|
||||
}
|
||||
|
||||
//add the cosmetic Edges to geometry Edges list
|
||||
void DrawViewPart::addCosmeticEdgesToGeom(void)
|
||||
{
|
||||
int i = 0;
|
||||
for ( ; i < (int) CEdgeTable.size(); i++) {
|
||||
TechDraw::BaseGeom* scaledGeom = CEdgeTable.at(i)->scaledGeometry(getScale());
|
||||
if (scaledGeom == nullptr) {
|
||||
Base::Console().Message("DVP::addCosmeticEdgesToGeom - scaledGeometry is null\n");
|
||||
continue;
|
||||
}
|
||||
// int idx =
|
||||
(void) geometryObject->addCosmeticEdge(scaledGeom, 1, i);
|
||||
}
|
||||
}
|
||||
|
||||
//add the center lines to geometry Edges list
|
||||
void DrawViewPart::addCenterLinesToGeom(void)
|
||||
{
|
||||
int i = 0;
|
||||
for ( ; i < (int) CLineTable.size(); i++) {
|
||||
TechDraw::BaseGeom* scaledGeom = CLineTable.at(i)->scaledGeometry(this);
|
||||
if (scaledGeom == nullptr) {
|
||||
Base::Console().Message("DVP::addCenterLinesToGeom - scaledGeometry is null\n");
|
||||
continue;
|
||||
}
|
||||
// int idx =
|
||||
(void) geometryObject->addCenterLine(scaledGeom, 2, i);
|
||||
}
|
||||
}
|
||||
|
||||
void DrawViewPart::onDocumentRestored()
|
||||
{
|
||||
rebuildCosmoVertex();
|
||||
rebuildCosmoEdge();
|
||||
readCVertexProp();
|
||||
readCEdgeProp();
|
||||
readCLineProp();
|
||||
// requestPaint();
|
||||
//if execute has not run yet, there will be no GO, and paint will not do anything.
|
||||
execute();
|
||||
DrawView::onDocumentRestored();
|
||||
}
|
||||
|
||||
|
||||
PyObject *DrawViewPart::getPyObject(void)
|
||||
{
|
||||
if (PythonObject.is(Py::_None())) {
|
||||
|
||||
@@ -70,6 +70,7 @@ class DrawViewDetail;
|
||||
class DrawViewBalloon;
|
||||
class CosmeticVertex;
|
||||
class CosmeticEdge;
|
||||
class CenterLine;
|
||||
}
|
||||
|
||||
namespace TechDraw
|
||||
@@ -105,6 +106,7 @@ public:
|
||||
|
||||
App::PropertyStringList CosmeticVertexList;
|
||||
App::PropertyStringList CosmeticEdgeList;
|
||||
App::PropertyStringList CenterLineList;
|
||||
|
||||
virtual short mustExecute() const;
|
||||
virtual void onDocumentRestored() override;
|
||||
@@ -129,7 +131,7 @@ public:
|
||||
bool hasGeometry(void) const;
|
||||
TechDraw::GeometryObject* getGeometryObject(void) const { return geometryObject; }
|
||||
|
||||
TechDraw::BaseGeom* getProjEdgeByIndex(int idx) const; //get existing geom for edge idx in projection
|
||||
TechDraw::BaseGeom* getGeomByIndex(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
|
||||
|
||||
@@ -161,25 +163,43 @@ public:
|
||||
bool isIso(void) const;
|
||||
|
||||
virtual int addCosmeticVertex(Base::Vector3d pos);
|
||||
virtual void stuffCosmeticVertexList(void);
|
||||
virtual void writeCVertProp(void);
|
||||
virtual void removeCosmeticVertex(TechDraw::CosmeticVertex* cv);
|
||||
virtual void removeCosmeticVertex(int idx);
|
||||
const std::vector<TechDraw::CosmeticVertex*> & getCosmeticVertex(void) const { return vertexCosmetic; }
|
||||
const std::vector<TechDraw::CosmeticVertex*> & getCosmeticVertex(void) const { return CVertexTable; }
|
||||
TechDraw::CosmeticVertex* getCosmeticVertexByIndex(int idx) const;
|
||||
TechDraw::CosmeticVertex* getCosmeticVertexByLink(int idx) const;
|
||||
TechDraw::CosmeticVertex* getCosmeticVertexByGeom(int idx) const;
|
||||
void clearCosmeticVertices(void);
|
||||
|
||||
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 writeCEdgeProp(void);
|
||||
virtual void removeCosmeticEdge(TechDraw::CosmeticEdge* ce);
|
||||
virtual void removeCosmeticEdge(int idx);
|
||||
const std::vector<TechDraw::CosmeticEdge*> & getCosmeticEdge(void) const { return edgeCosmetic; }
|
||||
const std::vector<TechDraw::CosmeticEdge*> & getCosmeticEdges(void) const { return CEdgeTable; }
|
||||
TechDraw::CosmeticEdge* getCosmeticEdgeByIndex(int idx) const;
|
||||
TechDraw::CosmeticEdge* getCosmeticEdgeByLink(int idx) const;
|
||||
TechDraw::CosmeticEdge* getCosmeticEdgeByGeom(int idx) const;
|
||||
int getCosmeticEdgeIndex(TechDraw::CosmeticEdge* ce) const;
|
||||
void replaceCosmeticEdge(int idx, TechDraw::CosmeticEdge* ce);
|
||||
void replaceCosmeticEdgeByGeom(int geomIndex, TechDraw::CosmeticEdge* ce);
|
||||
void clearCosmeticEdges(void);
|
||||
|
||||
virtual int addCenterLine(TechDraw::CenterLine*);
|
||||
virtual void writeCListProp(void);
|
||||
virtual void removeCenterLine(TechDraw::CenterLine* cl);
|
||||
virtual void removeCenterLine(int idx);
|
||||
const std::vector<TechDraw::CenterLine*> & getCenterLines(void) const { return CLineTable; }
|
||||
TechDraw::CenterLine* getCenterLineByIndex(int idx) const;
|
||||
TechDraw::CenterLine* getCenterLineByGeom(int idx) const;
|
||||
void replaceCenterLine(int idx, TechDraw::CenterLine* cl);
|
||||
void replaceCenterLineByGeom(int geomIndex, TechDraw::CenterLine* cl);
|
||||
void clearCenterLines(void);
|
||||
|
||||
void addCosmeticEdgesToGeom(void);
|
||||
void addCenterLinesToGeom(void);
|
||||
|
||||
|
||||
protected:
|
||||
TechDraw::GeometryObject *geometryObject;
|
||||
Base::BoundBox3d bbox;
|
||||
@@ -202,11 +222,14 @@ protected:
|
||||
bool m_handleFaces;
|
||||
|
||||
//Cosmetics
|
||||
std::vector<TechDraw::CosmeticVertex*> vertexCosmetic;
|
||||
void rebuildCosmoVertex(void);
|
||||
std::vector<TechDraw::CosmeticVertex*> CVertexTable;
|
||||
void readCVertexProp(void);
|
||||
|
||||
std::vector<TechDraw::CosmeticEdge*> edgeCosmetic;
|
||||
void rebuildCosmoEdge(void);
|
||||
std::vector<TechDraw::CosmeticEdge*> CEdgeTable;
|
||||
void readCEdgeProp(void);
|
||||
|
||||
std::vector<TechDraw::CenterLine*> CLineTable;
|
||||
void readCLineProp(void);
|
||||
|
||||
private:
|
||||
bool nowUnsetting;
|
||||
|
||||
@@ -82,7 +82,6 @@ PyObject* DrawViewPartPy::clearCosmeticEdges(PyObject *args)
|
||||
|
||||
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)");
|
||||
@@ -96,25 +95,19 @@ PyObject* DrawViewPartPy::makeCosmeticVertex(PyObject *args)
|
||||
|
||||
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;
|
||||
App::Color defCol = LineFormat::getDefEdgeColor();
|
||||
PyObject* pColor = nullptr;
|
||||
|
||||
if (!PyArg_ParseTuple(args, "O!O!|id", &(Base::VectorPy::Type), &pPnt1,
|
||||
if (!PyArg_ParseTuple(args, "O!O!|idO", &(Base::VectorPy::Type), &pPnt1,
|
||||
&(Base::VectorPy::Type), &pPnt2,
|
||||
&style, &weight)) {
|
||||
throw Py::TypeError("expected (vector, vector, [style, weight])");
|
||||
&style, &weight,
|
||||
&pColor)) {
|
||||
throw Py::TypeError("expected (vector, vector,[style,weight,color])");
|
||||
}
|
||||
// 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)
|
||||
@@ -124,34 +117,32 @@ PyObject* DrawViewPartPy::makeCosmeticLine(PyObject *args)
|
||||
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);
|
||||
|
||||
if (pColor == nullptr) {
|
||||
ce->m_format.m_color = defCol;
|
||||
} else {
|
||||
ce->m_format.m_color = pyTupleToColor(pColor);
|
||||
}
|
||||
dvp->writeCEdgeProp();
|
||||
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;
|
||||
App::Color defCol = LineFormat::getDefEdgeColor();
|
||||
PyObject* pColor = nullptr;
|
||||
|
||||
if (!PyArg_ParseTuple(args, "O!d|id", &(Base::VectorPy::Type), &pPnt1,
|
||||
if (!PyArg_ParseTuple(args, "O!d|idO", &(Base::VectorPy::Type), &pPnt1,
|
||||
&radius,
|
||||
&style, &weight)) {
|
||||
throw Py::TypeError("expected (vector, radius, [style, weight])");
|
||||
&style, &weight,
|
||||
&pColor)) {
|
||||
throw Py::TypeError("expected (vector, vector,[style,weight,color])");
|
||||
}
|
||||
// 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());
|
||||
@@ -169,35 +160,33 @@ PyObject* DrawViewPartPy::makeCosmeticCircle(PyObject *args)
|
||||
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);
|
||||
if (pColor == nullptr) {
|
||||
ce->m_format.m_color = defCol;
|
||||
} else {
|
||||
ce->m_format.m_color = pyTupleToColor(pColor);
|
||||
}
|
||||
dvp->writeCEdgeProp();
|
||||
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;
|
||||
App::Color defCol = LineFormat::getDefEdgeColor();
|
||||
PyObject* pColor = nullptr;
|
||||
|
||||
if (!PyArg_ParseTuple(args, "O!ddd|id", &(Base::VectorPy::Type), &pPnt1,
|
||||
if (!PyArg_ParseTuple(args, "O!ddd|idO", &(Base::VectorPy::Type), &pPnt1,
|
||||
&radius, &angle1, &angle2,
|
||||
&style, &weight)) {
|
||||
throw Py::TypeError("expected (vector, radius, start, end,[style, weight])");
|
||||
&style, &weight, &pColor)) {
|
||||
throw Py::TypeError("expected (vector, radius, start, end,[style, weight, color])");
|
||||
}
|
||||
// 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
|
||||
//from here on is almost 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);
|
||||
@@ -217,13 +206,17 @@ PyObject* DrawViewPartPy::makeCosmeticCircleArc(PyObject *args)
|
||||
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);
|
||||
if (pColor == nullptr) {
|
||||
ce->m_format.m_color = defCol;
|
||||
} else {
|
||||
ce->m_format.m_color = pyTupleToColor(pColor);
|
||||
}
|
||||
dvp->writeCEdgeProp();
|
||||
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)) {
|
||||
@@ -232,7 +225,7 @@ PyObject* DrawViewPartPy::getCosmeticVertexByIndex(PyObject *args)
|
||||
DrawViewPart* dvp = getDrawViewPartPtr();
|
||||
TechDraw::CosmeticVertex* cv = dvp->getCosmeticVertexByIndex(idx);
|
||||
if (cv != nullptr) {
|
||||
Base::Console().Message("DVPPI::getCosVertbyIdx - found a CV\n");
|
||||
Base::Console().Message("DVPPI::getCosVertbyIdx - CosmeticVertexPy not implemented yet\n");
|
||||
//make a py object
|
||||
|
||||
}
|
||||
@@ -241,7 +234,6 @@ PyObject* DrawViewPartPy::getCosmeticVertexByIndex(PyObject *args)
|
||||
|
||||
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)");
|
||||
@@ -254,7 +246,6 @@ PyObject* DrawViewPartPy::removeCosmeticVertex(PyObject *args)
|
||||
|
||||
PyObject* DrawViewPartPy::getCosmeticEdgeByIndex(PyObject *args)
|
||||
{
|
||||
// Base::Console().Message("DVPPI::getCosEdgeByIndex()\n");
|
||||
int idx = 0;
|
||||
PyObject* result = nullptr;
|
||||
if (!PyArg_ParseTuple(args, "i", &idx)) {
|
||||
@@ -263,8 +254,8 @@ PyObject* DrawViewPartPy::getCosmeticEdgeByIndex(PyObject *args)
|
||||
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
|
||||
Base::Console().Message("DVPPI::getCosEdgebyIdx - CosmeticEdgePy not implemented yet\n");
|
||||
//make a py object?
|
||||
}
|
||||
|
||||
return result;
|
||||
@@ -295,6 +286,7 @@ int DrawViewPartPy::setCustomAttributes(const char* /*attr*/, PyObject* /*obj*/)
|
||||
|
||||
App::Color pyTupleToColor(PyObject* pColor)
|
||||
{
|
||||
// Base::Console().Message("DVPPI::pyTupleToColor()\n");
|
||||
double red = 0.0, green = 0.0, blue = 0.0, alpha = 0.0;
|
||||
App::Color c(red, blue, green, alpha);
|
||||
if (PyTuple_Check(pColor)) {
|
||||
|
||||
@@ -193,9 +193,6 @@ App::DocumentObjectExecReturn *DrawViewSection::execute(void)
|
||||
return App::DocumentObject::StdReturn;
|
||||
}
|
||||
|
||||
rebuildCosmoVertex();
|
||||
rebuildCosmoEdge();
|
||||
|
||||
App::DocumentObject* base = BaseView.getValue();
|
||||
if (!base->getTypeId().isDerivedFrom(TechDraw::DrawViewPart::getClassTypeId()))
|
||||
return new App::DocumentObjectExecReturn("BaseView object is not a DrawViewPart object");
|
||||
@@ -328,18 +325,16 @@ App::DocumentObjectExecReturn *DrawViewSection::execute(void)
|
||||
Base::Console().Log("LOG - DVS::execute - failed building section faces for %s - %s **\n",getNameInDocument(),e2.GetMessageString());
|
||||
return new App::DocumentObjectExecReturn(e2.GetMessageString());
|
||||
}
|
||||
|
||||
//add back the cosmetic vertices
|
||||
for (auto& v: vertexCosmetic) {
|
||||
for (auto& v: CVertexTable) {
|
||||
int idx = geometryObject->addCosmeticVertex(v->point() * getScale());
|
||||
v->linkGeom = idx;
|
||||
}
|
||||
|
||||
//add the cosmetic Edges to geometry Edges list
|
||||
for (auto& e: edgeCosmetic) {
|
||||
TechDraw::BaseGeom* scaledGeom = e->scaledGeometry(getScale());
|
||||
int idx = geometryObject->addCosmeticEdge(scaledGeom);
|
||||
e->m_linkGeom = idx;
|
||||
}
|
||||
addCosmeticEdgesToGeom();
|
||||
//add centerlines to geometry edges list
|
||||
addCenterLinesToGeom();
|
||||
|
||||
requestPaint();
|
||||
return App::DocumentObject::StdReturn;
|
||||
|
||||
@@ -116,13 +116,15 @@ BaseGeom::BaseGeom() :
|
||||
visible(true),
|
||||
reversed(false),
|
||||
ref3D(-1), //obs?
|
||||
cosmetic(false)
|
||||
cosmetic(false),
|
||||
m_source(0),
|
||||
m_sourceIndex(-1)
|
||||
|
||||
{
|
||||
}
|
||||
|
||||
std::string BaseGeom::toCSV(void) const
|
||||
{
|
||||
// Base::Console().Message("Geo::BaseGeom::toCSV()\n");
|
||||
std::stringstream ss;
|
||||
ss << geomType << "," <<
|
||||
extractType << "," <<
|
||||
@@ -130,13 +132,15 @@ std::string BaseGeom::toCSV(void) const
|
||||
visible << "," <<
|
||||
reversed << "," <<
|
||||
ref3D << "," <<
|
||||
cosmetic;
|
||||
cosmetic << "," <<
|
||||
m_source << "," <<
|
||||
m_sourceIndex;
|
||||
return ss.str();
|
||||
}
|
||||
|
||||
bool BaseGeom::fromCSV(std::string lineSpec)
|
||||
{
|
||||
unsigned int maxCells = 7;
|
||||
unsigned int maxCells = 9;
|
||||
if (lineSpec.length() == 0) {
|
||||
Base::Console().Message( "BG::fromCSV - lineSpec empty\n");
|
||||
return false;
|
||||
@@ -154,6 +158,8 @@ bool BaseGeom::fromCSV(std::string lineSpec)
|
||||
reversed = (bool) atoi(values[4].c_str());
|
||||
ref3D = atoi(values[5].c_str());
|
||||
cosmetic = (bool) atoi(values[6].c_str());
|
||||
m_source = atoi(values[7].c_str());
|
||||
m_sourceIndex = atoi(values[8].c_str());
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -185,7 +191,6 @@ Base::Vector3d BaseGeom::getEndPoint()
|
||||
|
||||
Base::Vector3d BaseGeom::getMidPoint()
|
||||
{
|
||||
// Base::Console().Message("BG::getMidPoint()\n");
|
||||
Base::Vector3d result;
|
||||
BRepAdaptor_Curve adapt(occEdge);
|
||||
double u = adapt.FirstParameter();
|
||||
@@ -195,14 +200,11 @@ Base::Vector3d BaseGeom::getMidPoint()
|
||||
BRepLProp_CLProps prop(adapt,midParm,0,Precision::Confusion());
|
||||
const gp_Pnt& pt = prop.Value();
|
||||
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::Vector3d> BaseGeom::getQuads()
|
||||
{
|
||||
// Base::Console().Message("BG::getQuads()\n");
|
||||
std::vector<Base::Vector3d> result;
|
||||
BRepAdaptor_Curve adapt(occEdge);
|
||||
double u = adapt.FirstParameter();
|
||||
@@ -220,7 +222,6 @@ std::vector<Base::Vector3d> BaseGeom::getQuads()
|
||||
prop.SetParameter(q3);
|
||||
const gp_Pnt& p3 = prop.Value();
|
||||
result.push_back(Base::Vector3d(p3.X(),p3.Y(), 0.0));
|
||||
// Base::Console().Message("BG::getQuads - returns pts: %d\n", result.size());
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -279,7 +280,6 @@ std::string BaseGeom::dump()
|
||||
|
||||
bool BaseGeom::closed(void)
|
||||
{
|
||||
//return occEdge.Closed(); //based on a flag in occ. may not be correct!
|
||||
bool result = false;
|
||||
Base::Vector3d start(getStartPoint().x,
|
||||
getStartPoint().y,
|
||||
@@ -456,7 +456,6 @@ Circle::Circle(const TopoDS_Edge &e)
|
||||
}
|
||||
std::string Circle::toCSV(void) const
|
||||
{
|
||||
// Base::Console().Message("Geo::Circle::toCSV()\n");
|
||||
std::string baseCSV = BaseGeom::toCSV();
|
||||
std::stringstream ss;
|
||||
ss << center.x << "," <<
|
||||
@@ -468,6 +467,11 @@ std::string Circle::toCSV(void) const
|
||||
|
||||
bool Circle::fromCSV(std::string lineSpec)
|
||||
{
|
||||
if (lineSpec.length() == 0) {
|
||||
Base::Console().Message( "Circle::fromCSV - lineSpec empty\n");
|
||||
return false;
|
||||
}
|
||||
|
||||
std::vector<std::string> tokens = DrawUtil::tokenize(lineSpec);
|
||||
//"baseCSV,$$$,circleCSV"
|
||||
if (tokens.size() != 2) {
|
||||
@@ -476,10 +480,6 @@ bool Circle::fromCSV(std::string lineSpec)
|
||||
|
||||
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() );
|
||||
@@ -646,8 +646,6 @@ bool AOC::fromCSV(std::string lineSpec)
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
|
||||
//! Generic is a multiline
|
||||
Generic::Generic(const TopoDS_Edge &e)
|
||||
{
|
||||
@@ -680,7 +678,6 @@ Generic::Generic()
|
||||
|
||||
std::string Generic::toCSV(void) const
|
||||
{
|
||||
// Base::Console().Message("Geo::Generic::toCSV()\n");
|
||||
std::string baseCSV = BaseGeom::toCSV();
|
||||
std::stringstream ss;
|
||||
ss << points.size() << ",";
|
||||
@@ -721,7 +718,6 @@ bool Generic::fromCSV(std::string lineSpec)
|
||||
points.push_back(Base::Vector3d(x, y, z));
|
||||
}
|
||||
}
|
||||
// occEdge = GeometryUtils::edgeFromGeneric(this);
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -832,8 +828,6 @@ BSpline::BSpline(const TopoDS_Edge &e)
|
||||
if (bezier->Degree() > 3) {
|
||||
Base::Console().Log("Geometry::BSpline - converted curve degree > 3\n");
|
||||
}
|
||||
// Base::Console().Message("TRACE - Geo::BSpline - bezier degree: %d bezier poles: %d\n",
|
||||
// bezier->Degree(),bezier->NbPoles());
|
||||
tempSegment.poles = bezier->NbPoles();
|
||||
tempSegment.degree = bezier->Degree();
|
||||
for (int pole = 1; pole <= tempSegment.poles; ++pole) {
|
||||
@@ -891,16 +885,12 @@ bool BSpline::isCircle()
|
||||
Base::Vector3d center;
|
||||
bool isArc = false;
|
||||
getCircleParms(result,radius,center,isArc);
|
||||
// Base::Console().Message("TRACE - GEO::BS::isCircle - result: %d radius: %.3f center: %s isArc %d\n",
|
||||
// result,radius,DrawUtil::formatVector(center).c_str(),isArc);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
//used by DVDim for approximate dims
|
||||
void BSpline::getCircleParms(bool& isCircle, double& radius, Base::Vector3d& center, bool& isArc)
|
||||
{
|
||||
// bool result = false;
|
||||
double curveLimit = 0.0001;
|
||||
BRepAdaptor_Curve c(occEdge);
|
||||
Handle(Geom_BSplineCurve) spline = c.BSpline();
|
||||
@@ -942,7 +932,6 @@ void BSpline::getCircleParms(bool& isCircle, double& radius, Base::Vector3d& cen
|
||||
Base::Console().Log("TechDraw - GEO::BSpline::getCircleParms - CLProps failed\n");
|
||||
isCircle = false;
|
||||
return;
|
||||
// throw Base::RuntimeError(e.GetMessageString());
|
||||
}
|
||||
Base::Vector3d avgCenter = sumCenter/testCount;
|
||||
double errorCenter = 0;
|
||||
@@ -1235,7 +1224,6 @@ TopoDS_Edge GeometryUtils::edgeFromGeneric(TechDraw::Generic* g)
|
||||
|
||||
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);
|
||||
@@ -1250,7 +1238,6 @@ TopoDS_Edge GeometryUtils::edgeFromCircle(TechDraw::Circle* c)
|
||||
|
||||
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);
|
||||
|
||||
@@ -59,6 +59,12 @@ enum GeomType {
|
||||
GENERIC
|
||||
};
|
||||
|
||||
enum SourceType {
|
||||
GEOM,
|
||||
COSEDGE,
|
||||
CENTERLINE
|
||||
};
|
||||
|
||||
class TechDrawExport BaseGeom
|
||||
{
|
||||
public:
|
||||
@@ -74,6 +80,10 @@ class TechDrawExport BaseGeom
|
||||
int ref3D; //obs?
|
||||
TopoDS_Edge occEdge; //projected Edge
|
||||
bool cosmetic;
|
||||
int source(void) { return m_source; }
|
||||
void source(int s) { m_source = s; }
|
||||
int sourceIndex(void) { return m_sourceIndex; }
|
||||
void sourceIndex(int si) { m_sourceIndex = si; }
|
||||
|
||||
virtual std::string toCSV(void) const;
|
||||
virtual bool fromCSV(std::string s);
|
||||
@@ -88,6 +98,11 @@ class TechDrawExport BaseGeom
|
||||
static BaseGeom* baseFactory(TopoDS_Edge edge);
|
||||
bool closed(void);
|
||||
std::string dump();
|
||||
|
||||
protected:
|
||||
int m_source;
|
||||
int m_sourceIndex;
|
||||
|
||||
};
|
||||
|
||||
typedef std::vector<BaseGeom *> BaseGeomPtrVector; //obs?
|
||||
|
||||
@@ -412,6 +412,8 @@ void GeometryObject::addGeomFromCompound(TopoDS_Shape edgeCompound, edgeClass ca
|
||||
Base::Console().Log("Error - GO::addGeomFromCompound - baseFactory failed for edge: %d\n",i);
|
||||
throw Base::ValueError("GeometryObject::addGeomFromCompound - baseFactory failed");
|
||||
}
|
||||
base->source(0); //object geometry
|
||||
base->sourceIndex(i-1);
|
||||
base->classOfEdge = category;
|
||||
base->visible = visible;
|
||||
edgeGeom.push_back(base);
|
||||
@@ -473,23 +475,37 @@ void GeometryObject::addGeomFromCompound(TopoDS_Shape edgeCompound, edgeClass ca
|
||||
|
||||
int GeometryObject::addCosmeticVertex(Base::Vector3d pos)
|
||||
{
|
||||
// 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;
|
||||
}
|
||||
|
||||
|
||||
int GeometryObject::addCosmeticEdge(TechDraw::BaseGeom* base)
|
||||
int GeometryObject::addCosmeticEdge(TechDraw::BaseGeom* base,
|
||||
int s, int si)
|
||||
{
|
||||
// Base::Console().Message("GO::addCosmeticEdge() - cosmetic: %d\n", base->cosmetic);
|
||||
base->cosmetic = true;
|
||||
base->source(s); //1-CosmeticEdge, 2-CenterLine
|
||||
base->sourceIndex(si); //index into source;
|
||||
|
||||
edgeGeom.push_back(base);
|
||||
int idx = edgeGeom.size() - 1;
|
||||
return idx;
|
||||
}
|
||||
|
||||
int GeometryObject::addCenterLine(TechDraw::BaseGeom* base,
|
||||
int s, int si)
|
||||
{
|
||||
base->cosmetic = true;
|
||||
base->source(s); //1-CosmeticEdge, 2-CenterLine
|
||||
base->sourceIndex(si); //index into source;
|
||||
|
||||
edgeGeom.push_back(base);
|
||||
int idx = edgeGeom.size() - 1;
|
||||
return idx;
|
||||
}
|
||||
|
||||
|
||||
//! empty Face geometry
|
||||
void GeometryObject::clearFaceGeom()
|
||||
{
|
||||
|
||||
@@ -137,7 +137,8 @@ public:
|
||||
int addCosmeticVertex(Base::Vector3d pos);
|
||||
/* void removeCosmeticVertex(TechDraw::CosmeticVertex* cv);*/
|
||||
/* void removeCosmeticVertex(int idx);*/
|
||||
int addCosmeticEdge(TechDraw::BaseGeom* bg);
|
||||
int addCosmeticEdge(TechDraw::BaseGeom* bg, int s = 0, int si = -1);
|
||||
int addCenterLine(TechDraw::BaseGeom* bg, int s = 0, int si = -1);
|
||||
/* void removeCosmeticEdge(TechDraw::CosmeticEdge* ce);*/
|
||||
/* void removeCosmeticEdge(int idx);*/
|
||||
|
||||
|
||||
@@ -51,7 +51,7 @@
|
||||
#include <Mod/TechDraw/App/DrawPage.h>
|
||||
#include <Mod/TechDraw/App/DrawUtil.h>
|
||||
#include <Mod/TechDraw/App/Geometry.h>
|
||||
#include <Mod/TechDraw/Gui/QGVPage.h>
|
||||
#include <Mod/TechDraw/App/Cosmetic.h>
|
||||
|
||||
#include "DrawGuiUtil.h"
|
||||
#include "MDIViewPage.h"
|
||||
@@ -60,6 +60,7 @@
|
||||
#include "TaskCosVertex.h"
|
||||
#include "TaskCenterLine.h"
|
||||
#include "ViewProviderPage.h"
|
||||
#include "QGVPage.h"
|
||||
|
||||
using namespace TechDrawGui;
|
||||
using namespace TechDraw;
|
||||
@@ -643,22 +644,47 @@ void CmdTechDrawFaceCenterLine::activated(int iMsg)
|
||||
}
|
||||
}
|
||||
std::vector<std::string> faceNames;
|
||||
std::vector<std::string> edgeNames;
|
||||
for (auto& s: SubNames) {
|
||||
std::string geomType = DrawUtil::getGeomTypeFromName(s);
|
||||
if (geomType == "Face") {
|
||||
faceNames.push_back(s);
|
||||
} else if (geomType == "Edge") {
|
||||
edgeNames.push_back(s);
|
||||
}
|
||||
}
|
||||
|
||||
if (faceNames.empty()) {
|
||||
|
||||
if ( (faceNames.empty()) &&
|
||||
(edgeNames.empty()) ) {
|
||||
QMessageBox::warning(Gui::getMainWindow(), QObject::tr("Selection Error"),
|
||||
QObject::tr("You must select a Face(s) for the center line."));
|
||||
QObject::tr("You must select a Face(s) or an existing CenterLine."));
|
||||
return;
|
||||
}
|
||||
if (!faceNames.empty()) {
|
||||
Gui::Control().showDialog(new TaskDlgCenterLine(baseFeat,
|
||||
page,
|
||||
faceNames));
|
||||
} else if (edgeNames.empty()) {
|
||||
QMessageBox::warning(Gui::getMainWindow(), QObject::tr("Selection Error"),
|
||||
QObject::tr("No CenterLine in selection."));
|
||||
return;
|
||||
} else {
|
||||
std::string edgeName = edgeNames.front();
|
||||
int geomIdx = DrawUtil::getIndexFromName(edgeName);
|
||||
const std::vector<TechDraw::BaseGeom *> &geoms = baseFeat->getEdgeGeometry();
|
||||
BaseGeom* bg = geoms.at(geomIdx);
|
||||
int clIdx = bg->sourceIndex();
|
||||
TechDraw::CenterLine* cl = baseFeat->getCenterLineByIndex(clIdx);
|
||||
if (cl == nullptr) {
|
||||
QMessageBox::warning(Gui::getMainWindow(), QObject::tr("Selection Error"),
|
||||
QObject::tr("No CenterLine in selection."));
|
||||
return;
|
||||
}
|
||||
|
||||
Gui::Control().showDialog(new TaskDlgCenterLine(baseFeat,
|
||||
page,
|
||||
faceNames));
|
||||
Gui::Control().showDialog(new TaskDlgCenterLine(baseFeat,
|
||||
page,
|
||||
edgeNames.front()));
|
||||
}
|
||||
}
|
||||
|
||||
bool CmdTechDrawFaceCenterLine::isActive(void)
|
||||
@@ -735,12 +761,22 @@ void CmdTechDrawCosmeticEraser::activated(int iMsg)
|
||||
int idx = TechDraw::DrawUtil::getIndexFromName(s);
|
||||
std::string geomType = TechDraw::DrawUtil::getGeomTypeFromName(s);
|
||||
if (geomType == "Edge") {
|
||||
TechDraw::CosmeticEdge* ce = objFeat->getCosmeticEdgeByLink(idx);
|
||||
if (ce != nullptr) {
|
||||
objFeat->removeCosmeticEdge(ce);
|
||||
TechDraw::BaseGeom* bg = objFeat->getGeomByIndex(idx);
|
||||
if ((bg != nullptr) &&
|
||||
(bg->cosmetic) ) {
|
||||
int source = bg->source();
|
||||
int sourceIndex = bg->sourceIndex();
|
||||
if (source == 1) { //this is a "CosmeticEdge"
|
||||
objFeat->removeCosmeticEdge(sourceIndex);
|
||||
} else if (source == 2) { //this is a "CenterLine"
|
||||
objFeat->removeCenterLine(sourceIndex);
|
||||
} else {
|
||||
Base::Console().Message(
|
||||
"CMD::CosmeticEraserP - edge: %d is confused - source: %d\n",idx,source);
|
||||
}
|
||||
}
|
||||
} else if (geomType == "Vertex") {
|
||||
TechDraw::CosmeticVertex* cv = objFeat->getCosmeticVertexByLink(idx);
|
||||
TechDraw::CosmeticVertex* cv = objFeat->getCosmeticVertexByGeom(idx);
|
||||
if (cv != nullptr) {
|
||||
objFeat->removeCosmeticVertex(cv);
|
||||
}
|
||||
|
||||
@@ -1158,7 +1158,7 @@ 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]) );
|
||||
TechDraw::BaseGeom* geom = objFeat->getProjEdgeByIndex(GeoId);
|
||||
TechDraw::BaseGeom* geom = objFeat->getGeomByIndex(GeoId);
|
||||
if (!geom) {
|
||||
Base::Console().Error("Logic Error: no geometry for GeoId: %d\n",GeoId);
|
||||
return isInvalid;
|
||||
@@ -1235,8 +1235,8 @@ 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]) );
|
||||
TechDraw::BaseGeom* geom0 = objFeat0->getProjEdgeByIndex(GeoId0);
|
||||
TechDraw::BaseGeom* geom1 = objFeat0->getProjEdgeByIndex(GeoId1);
|
||||
TechDraw::BaseGeom* geom0 = objFeat0->getGeomByIndex(GeoId0);
|
||||
TechDraw::BaseGeom* geom1 = objFeat0->getGeomByIndex(GeoId1);
|
||||
if ((!geom0) || (!geom1)) {
|
||||
Base::Console().Error("Logic Error: no geometry for GeoId: %d or GeoId: %d\n",GeoId0,GeoId1);
|
||||
return isInvalid;
|
||||
@@ -1293,7 +1293,7 @@ bool _isValidVertexToEdge(Gui::Command* cmd) {
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
e = objFeat0->getProjEdgeByIndex(eId);
|
||||
e = objFeat0->getGeomByIndex(eId);
|
||||
v = objFeat0->getProjVertexByIndex(vId);
|
||||
if ((!e) || (!v)) {
|
||||
Base::Console().Error("Logic Error: no geometry for GeoId: %d or GeoId: %d\n",eId,vId);
|
||||
|
||||
@@ -327,6 +327,7 @@ void QGIViewPart::draw() {
|
||||
drawViewPart();
|
||||
drawMatting();
|
||||
QGIView::draw();
|
||||
//this is old C/L
|
||||
drawCenterLines(true); //have to draw centerlines after border to get size correct.
|
||||
drawAllSectionLines(); //same for section lines
|
||||
}
|
||||
@@ -418,59 +419,64 @@ void QGIViewPart::drawViewPart()
|
||||
|
||||
// Draw Edges
|
||||
const std::vector<TechDraw::BaseGeom *> &geoms = viewPart->getEdgeGeometry();
|
||||
std::vector<TechDraw::BaseGeom *>::const_iterator itEdge = geoms.begin();
|
||||
std::vector<TechDraw::BaseGeom *>::const_iterator itGeom = geoms.begin();
|
||||
QGIEdge* item;
|
||||
for(int i = 0 ; itEdge != geoms.end(); itEdge++, i++) {
|
||||
for(int i = 0 ; itGeom != geoms.end(); itGeom++, i++) {
|
||||
bool showEdge = false;
|
||||
if ((*itEdge)->visible) {
|
||||
if (((*itEdge)->classOfEdge == ecHARD) ||
|
||||
((*itEdge)->classOfEdge == ecOUTLINE) ||
|
||||
(((*itEdge)->classOfEdge == ecSMOOTH) && viewPart->SmoothVisible.getValue()) ||
|
||||
(((*itEdge)->classOfEdge == ecSEAM) && viewPart->SeamVisible.getValue()) ||
|
||||
(((*itEdge)->classOfEdge == ecUVISO) && viewPart->IsoVisible.getValue())) {
|
||||
if ((*itGeom)->visible) {
|
||||
if (((*itGeom)->classOfEdge == ecHARD) ||
|
||||
((*itGeom)->classOfEdge == ecOUTLINE) ||
|
||||
(((*itGeom)->classOfEdge == ecSMOOTH) && viewPart->SmoothVisible.getValue()) ||
|
||||
(((*itGeom)->classOfEdge == ecSEAM) && viewPart->SeamVisible.getValue()) ||
|
||||
(((*itGeom)->classOfEdge == ecUVISO) && viewPart->IsoVisible.getValue())) {
|
||||
showEdge = true;
|
||||
}
|
||||
} else {
|
||||
if ( (((*itEdge)->classOfEdge == ecHARD) && (viewPart->HardHidden.getValue())) ||
|
||||
(((*itEdge)->classOfEdge == ecOUTLINE) && (viewPart->HardHidden.getValue())) ||
|
||||
(((*itEdge)->classOfEdge == ecSMOOTH) && (viewPart->SmoothHidden.getValue())) ||
|
||||
(((*itEdge)->classOfEdge == ecSEAM) && (viewPart->SeamHidden.getValue())) ||
|
||||
(((*itEdge)->classOfEdge == ecUVISO) && (viewPart->IsoHidden.getValue())) ) {
|
||||
if ( (((*itGeom)->classOfEdge == ecHARD) && (viewPart->HardHidden.getValue())) ||
|
||||
(((*itGeom)->classOfEdge == ecOUTLINE) && (viewPart->HardHidden.getValue())) ||
|
||||
(((*itGeom)->classOfEdge == ecSMOOTH) && (viewPart->SmoothHidden.getValue())) ||
|
||||
(((*itGeom)->classOfEdge == ecSEAM) && (viewPart->SeamHidden.getValue())) ||
|
||||
(((*itGeom)->classOfEdge == ecUVISO) && (viewPart->IsoHidden.getValue())) ) {
|
||||
showEdge = true;
|
||||
}
|
||||
}
|
||||
if (showEdge) {
|
||||
item = new QGIEdge(i);
|
||||
item->setWidth(lineWidth);
|
||||
if ((*itEdge)->cosmetic == true) {
|
||||
TechDraw::CosmeticEdge* ce = viewPart->getCosmeticEdgeByLink(i);
|
||||
if (ce != nullptr) {
|
||||
item->setNormalColor(ce->m_format.m_color.asValue<QColor>());
|
||||
item->setWidth(ce->m_format.m_weight * lineScaleFactor);
|
||||
item->setStyle(ce->m_format.m_style);
|
||||
}
|
||||
//TODO: implement formats for geom lines.
|
||||
if ((*itGeom)->cosmetic == true) {
|
||||
int source = (*itGeom)->source();
|
||||
int sourceIndex = (*itGeom)->sourceIndex();
|
||||
if (source == 1) { //this is a "CosmeticEdge"
|
||||
formatGeomFromCosmetic(sourceIndex, item);
|
||||
} else if (source == 2) { //this is a "CenterLine"
|
||||
formatGeomFromCenterLine(sourceIndex, item);
|
||||
} else {
|
||||
Base::Console().Message("QGIVP::drawVP - edge: %d is confused - source: %d\n",i,source);
|
||||
}
|
||||
}
|
||||
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));
|
||||
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(*itGeom));
|
||||
item->setZValue(ZVALUE::EDGE);
|
||||
if(!(*itEdge)->visible) {
|
||||
if(!(*itGeom)->visible) {
|
||||
item->setWidth(lineWidthHid);
|
||||
item->setHiddenEdge(true);
|
||||
item->setZValue(ZVALUE::HIDEDGE);
|
||||
}
|
||||
if ((*itEdge)->classOfEdge == ecUVISO) {
|
||||
if ((*itGeom)->classOfEdge == ecUVISO) {
|
||||
item->setWidth(lineWidthIso);
|
||||
}
|
||||
item->setPrettyNormal();
|
||||
//debug a path
|
||||
// QPainterPath edgePath=drawPainterPath(*itEdge);
|
||||
// QPainterPath edgePath=drawPainterPath(*itGeom);
|
||||
// std::stringstream edgeId;
|
||||
// edgeId << "QGIVP.edgePath" << i;
|
||||
// dumpPath(edgeId.str().c_str(),edgePath);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Draw Vertexs:
|
||||
Base::Reference<ParameterGrp> hGrp = App::GetApplication().GetUserParameter().GetGroup("BaseApp")->
|
||||
GetGroup("Preferences")->GetGroup("Mod/TechDraw/General");
|
||||
@@ -519,7 +525,7 @@ void QGIViewPart::drawViewPart()
|
||||
} else { //regular Vertex
|
||||
if (showVertices) {
|
||||
QGIVertex *item = new QGIVertex(i);
|
||||
TechDraw::CosmeticVertex* cv = viewPart->getCosmeticVertexByLink(i);
|
||||
TechDraw::CosmeticVertex* cv = viewPart->getCosmeticVertexByGeom(i);
|
||||
if (cv != nullptr) {
|
||||
item->setNormalColor(cv->color.asValue<QColor>());
|
||||
item->setRadius(cv->size);
|
||||
@@ -542,6 +548,30 @@ void QGIViewPart::drawViewPart()
|
||||
}
|
||||
}
|
||||
|
||||
void QGIViewPart::formatGeomFromCosmetic(int sourceIndex, QGIEdge* item)
|
||||
{
|
||||
// Base::Console().Message("QGIVP::formatGeomFromCosmetic(%d)\n",sourceIndex);
|
||||
auto partFeat( dynamic_cast<TechDraw::DrawViewPart *>(getViewObject()) );
|
||||
TechDraw::CosmeticEdge* ce = partFeat->getCosmeticEdgeByIndex(sourceIndex);
|
||||
if (ce != nullptr) {
|
||||
item->setNormalColor(ce->m_format.m_color.asValue<QColor>());
|
||||
item->setWidth(ce->m_format.m_weight * lineScaleFactor);
|
||||
item->setStyle(ce->m_format.m_style);
|
||||
}
|
||||
}
|
||||
|
||||
void QGIViewPart::formatGeomFromCenterLine(int sourceIndex, QGIEdge* item)
|
||||
{
|
||||
// Base::Console().Message("QGIVP::formatGeomFromCenterLine(%d)\n",sourceIndex);
|
||||
auto partFeat( dynamic_cast<TechDraw::DrawViewPart *>(getViewObject()) );
|
||||
TechDraw::CenterLine* cl = partFeat->getCenterLineByIndex(sourceIndex);
|
||||
if (cl != nullptr) {
|
||||
item->setNormalColor(cl->fmt.m_color.asValue<QColor>());
|
||||
item->setWidth(cl->fmt.m_weight * lineScaleFactor);
|
||||
item->setStyle(cl->fmt.m_style);
|
||||
}
|
||||
}
|
||||
|
||||
QGIFace* QGIViewPart::drawFace(TechDraw::Face* f, int idx)
|
||||
{
|
||||
std::vector<TechDraw::Wire *> fWires = f->wires;
|
||||
|
||||
@@ -41,6 +41,7 @@ class DrawView;
|
||||
namespace TechDrawGui
|
||||
{
|
||||
class QGIFace;
|
||||
class QGIEdge;
|
||||
|
||||
class TechDrawGuiExport QGIViewPart : public QGIView
|
||||
{
|
||||
@@ -106,6 +107,10 @@ protected:
|
||||
bool prefPrintCenters(void);
|
||||
|
||||
|
||||
void formatGeomFromCosmetic(int sourceIndex, QGIEdge* item);
|
||||
void formatGeomFromCenterLine(int sourceIndex, QGIEdge* item);
|
||||
|
||||
|
||||
private:
|
||||
QList<QGraphicsItem*> deleteItems;
|
||||
};
|
||||
|
||||
@@ -71,60 +71,41 @@ using namespace TechDraw;
|
||||
using namespace TechDrawGui;
|
||||
|
||||
//ctor for edit
|
||||
//TaskCenterLine::TaskCenterLine(TechDrawGui::ViewProviderViewPart* partVP) :
|
||||
// ui(new Ui_TaskCenterLine),
|
||||
// m_partVP(partVp),
|
||||
// m_partFeat(nullptr),
|
||||
// m_basePage(nullptr),
|
||||
// m_createMode(false),
|
||||
// m_inProgressLock(false)
|
||||
//{
|
||||
// if (m_partVP == nullptr) {
|
||||
// //should be caught in CMD caller
|
||||
// Base::Console().Error("TaskCenterLine - bad parameters. Can not proceed.\n");
|
||||
// return;
|
||||
// }
|
||||
// ui->setupUi(this);
|
||||
//
|
||||
// m_partFeat = m_partVP->getFeature();
|
||||
// m_basePage = m_partFeat->findParentPage();
|
||||
TaskCenterLine::TaskCenterLine(TechDraw::DrawViewPart* partFeat,
|
||||
TechDraw::DrawPage* page,
|
||||
std::string edgeName) :
|
||||
ui(new Ui_TaskCenterLine),
|
||||
m_partFeat(partFeat),
|
||||
m_basePage(page),
|
||||
m_createMode(false),
|
||||
m_edgeName(edgeName)
|
||||
{
|
||||
// Base::Console().Message("TCL::TCL() - edit mode\n");
|
||||
ui->setupUi(this);
|
||||
|
||||
// //TODO: when/if leaders are allowed to be parented to Page, check for m_partFeat will be removed
|
||||
// if ( (m_partFeat == nullptr) ||
|
||||
// (m_basePage == nullptr) ) {
|
||||
// Base::Console().Error("TaskCenterLine - bad parameters (2). Can not proceed.\n");
|
||||
// return;
|
||||
// }
|
||||
m_geomIndex = DrawUtil::getIndexFromName(m_edgeName);
|
||||
const std::vector<TechDraw::BaseGeom *> &geoms = partFeat->getEdgeGeometry();
|
||||
BaseGeom* bg = geoms.at(m_geomIndex);
|
||||
m_clIdx = bg->sourceIndex();
|
||||
m_cl = partFeat->getCenterLineByIndex(m_clIdx);
|
||||
if (m_cl == nullptr) { //checked by CommandAnnotate. Should never happen.
|
||||
Base::Console().Message("TCL::TCL() - no centerline found\n");
|
||||
}
|
||||
|
||||
// //m_subNames = m_partFeat->get?????();
|
||||
|
||||
// setUiEdit();
|
||||
|
||||
//// m_mdi = m_partVP->getMDIViewPage();
|
||||
//// m_scene = m_mdi->m_scene;
|
||||
//// m_view = m_mdi->getQGVPage();
|
||||
|
||||
//// connect(ui->pbTracker, SIGNAL(clicked(bool)),
|
||||
//// this, SLOT(onTrackerClicked(bool)));
|
||||
//// connect(ui->pbCancelEdit, SIGNAL(clicked(bool)),
|
||||
//// this, SLOT(onCancelEditClicked(bool)));
|
||||
//// ui->pbCancelEdit->setEnabled(false);
|
||||
|
||||
// saveState();
|
||||
|
||||
//}
|
||||
setUiEdit();
|
||||
}
|
||||
|
||||
//ctor for creation
|
||||
TaskCenterLine::TaskCenterLine(TechDraw::DrawViewPart* partFeat,
|
||||
TechDraw::DrawPage* page,
|
||||
std::vector<std::string> subNames) :
|
||||
ui(new Ui_TaskCenterLine),
|
||||
m_partVP(nullptr),
|
||||
m_partFeat(partFeat),
|
||||
m_basePage(page),
|
||||
m_createMode(true),
|
||||
m_subNames(subNames)
|
||||
{
|
||||
// Base::Console().Message("TCL::TCL() - create mode\n");
|
||||
if ( (m_basePage == nullptr) ||
|
||||
(m_partFeat == nullptr) ) {
|
||||
//should be caught in CMD caller
|
||||
@@ -134,19 +115,7 @@ TaskCenterLine::TaskCenterLine(TechDraw::DrawViewPart* partFeat,
|
||||
|
||||
ui->setupUi(this);
|
||||
|
||||
Gui::Document* activeGui = Gui::Application::Instance->getDocument(m_basePage->getDocument());
|
||||
Gui::ViewProvider* vp = activeGui->getViewProvider(m_basePage);
|
||||
ViewProviderPage* vpp = static_cast<ViewProviderPage*>(vp);
|
||||
m_mdi = vpp->getMDIViewPage();
|
||||
m_scene = m_mdi->m_scene;
|
||||
m_view = m_mdi->getQGVPage();
|
||||
|
||||
setUiPrimary();
|
||||
|
||||
// connect(ui->pbTracker, SIGNAL(clicked(bool)),
|
||||
// this, SLOT(onTrackerClicked(bool)));
|
||||
// connect(ui->pbCancelEdit, SIGNAL(clicked(bool)),
|
||||
// this, SLOT(onCancelEditClicked(bool)));
|
||||
}
|
||||
|
||||
TaskCenterLine::~TaskCenterLine()
|
||||
@@ -154,18 +123,6 @@ TaskCenterLine::~TaskCenterLine()
|
||||
delete ui;
|
||||
}
|
||||
|
||||
void TaskCenterLine::saveState()
|
||||
{
|
||||
if (m_partFeat != nullptr) {
|
||||
}
|
||||
}
|
||||
|
||||
void TaskCenterLine::restoreState()
|
||||
{
|
||||
if (m_partFeat != nullptr) {
|
||||
}
|
||||
}
|
||||
|
||||
void TaskCenterLine::updateTask()
|
||||
{
|
||||
// blockUpdate = true;
|
||||
@@ -183,8 +140,7 @@ void TaskCenterLine::changeEvent(QEvent *e)
|
||||
void TaskCenterLine::setUiPrimary()
|
||||
{
|
||||
// Base::Console().Message("TCL::setUiPrimary()\n");
|
||||
// enableVPUi(false);
|
||||
setWindowTitle(QObject::tr("New Center Line"));
|
||||
setWindowTitle(QObject::tr("Create Center Line"));
|
||||
|
||||
if (m_partFeat != nullptr) {
|
||||
std::string baseName = m_partFeat->getNameInDocument();
|
||||
@@ -194,37 +150,61 @@ void TaskCenterLine::setUiPrimary()
|
||||
ui->lstSubList->addItem(listItem);
|
||||
}
|
||||
}
|
||||
|
||||
ui->cpLineColor->setColor(getCenterColor());
|
||||
ui->dsbWeight->setValue(getCenterWidth());
|
||||
ui->cboxStyle->setCurrentIndex(getCenterStyle());
|
||||
ui->qsbExtend->setValue(getExtendBy());
|
||||
Base::Quantity qVal;
|
||||
qVal.setUnit(Base::Unit::Length);
|
||||
qVal.setValue(getExtendBy());
|
||||
ui->qsbExtend->setValue(qVal);
|
||||
int precision = Base::UnitsApi::getDecimals();
|
||||
ui->dsbRotate->setDecimals(precision);
|
||||
}
|
||||
|
||||
//void TaskCenterLine::enableVPUi(bool b)
|
||||
|
||||
//{
|
||||
//}
|
||||
|
||||
//void TaskCenterLine::setUiEdit()
|
||||
//{
|
||||
//// Base::Console().Message("TCL::setUiEdit()\n");
|
||||
// enableVPUi(true);
|
||||
// setWindowTitle(QObject::tr("Edit Center Line"));
|
||||
//}
|
||||
|
||||
void TaskCenterLine::addCenterLine(void)
|
||||
void TaskCenterLine::setUiEdit()
|
||||
{
|
||||
// TechDraw::CosmeticEdge* ce = new TechDrawCosmeticEdge();
|
||||
}
|
||||
// Base::Console().Message("TCL::setUiEdit()\n");
|
||||
setWindowTitle(QObject::tr("Edit Center Line"));
|
||||
if (m_partFeat != nullptr) {
|
||||
std::string baseName = m_partFeat->getNameInDocument();
|
||||
ui->leBaseView->setText(Base::Tools::fromStdString(baseName));
|
||||
QString listItem = Base::Tools::fromStdString(m_edgeName);
|
||||
ui->lstSubList->addItem(listItem);
|
||||
}
|
||||
|
||||
ui->cpLineColor->setColor(m_cl->fmt.m_color.asValue<QColor>());
|
||||
ui->dsbWeight->setValue(m_cl->fmt.m_weight);
|
||||
ui->cboxStyle->setCurrentIndex(m_cl->fmt.m_style);
|
||||
|
||||
int precision = Base::UnitsApi::getDecimals();
|
||||
ui->dsbRotate->setDecimals(precision);
|
||||
|
||||
ui->rbVertical->setChecked(false);
|
||||
ui->rbHorizontal->setChecked(false);
|
||||
ui->rbAligned->setChecked(false);
|
||||
if (m_cl->mode == 0) {
|
||||
ui->rbVertical->setChecked(true);
|
||||
} else if (m_cl->mode == 1) {
|
||||
ui->rbHorizontal->setChecked(true);
|
||||
} else if (m_cl->mode ==2) {
|
||||
ui->rbAligned->setChecked(true);
|
||||
}
|
||||
ui->dsbRotate->setValue(m_cl->rotate);
|
||||
Base::Quantity qVal;
|
||||
qVal.setUnit(Base::Unit::Length);
|
||||
qVal.setValue(m_cl->vShift);
|
||||
ui->qsbVertShift->setValue(qVal);
|
||||
qVal.setValue(m_cl->hShift);
|
||||
ui->qsbHorizShift->setValue(qVal);
|
||||
qVal.setValue(m_cl->extendBy);
|
||||
ui->qsbExtend->setValue(qVal);
|
||||
}
|
||||
|
||||
//******************************************************************************
|
||||
void TaskCenterLine::createCenterLine(void)
|
||||
{
|
||||
// Base::Console().Message("TCL::createCenterLine()\n");
|
||||
|
||||
Gui::Command::openCommand("Create CenterLine");
|
||||
bool vertical = false;
|
||||
if (ui->rbVertical->isChecked()) {
|
||||
@@ -233,12 +213,41 @@ void TaskCenterLine::createCenterLine(void)
|
||||
double hShift = ui->qsbHorizShift->rawValue();
|
||||
double vShift = ui->qsbVertShift->rawValue();
|
||||
double rotate = ui->dsbRotate->value();
|
||||
m_extendBy = ui->qsbExtend->rawValue();
|
||||
TechDraw::CosmeticEdge* ce = calcEndPoints(m_subNames,vertical,
|
||||
m_extendBy,
|
||||
hShift, vShift, rotate);
|
||||
m_partFeat->addCosmeticEdge(ce);
|
||||
m_partFeat->requestPaint();
|
||||
double extendBy = ui->qsbExtend->rawValue();
|
||||
std::pair<Base::Vector3d, Base::Vector3d> ends;
|
||||
ends = TechDraw::CenterLine::calcEndPoints(m_partFeat,
|
||||
m_subNames,
|
||||
vertical,
|
||||
extendBy,
|
||||
hShift, vShift, rotate);
|
||||
TechDraw::CenterLine* cl = new TechDraw::CenterLine(ends.first, ends.second);
|
||||
cl->start = ends.first;
|
||||
cl->end = ends.second;
|
||||
|
||||
App::Color ac;
|
||||
ac.setValue<QColor>(ui->cpLineColor->color());
|
||||
cl->fmt.m_color = ac;
|
||||
cl->fmt.m_weight = ui->dsbWeight->value();
|
||||
cl->fmt.m_style = ui->cboxStyle->currentIndex();
|
||||
cl->fmt.m_visible = true;
|
||||
|
||||
if (ui->rbVertical->isChecked()) {
|
||||
cl->mode = 0;
|
||||
} else if (ui->rbHorizontal->isChecked()) {
|
||||
cl->mode = 1;
|
||||
} else if (ui->rbAligned->isChecked()) {
|
||||
cl->mode = 2;
|
||||
}
|
||||
cl->m_faces = m_subNames;
|
||||
cl->rotate = rotate;
|
||||
cl->vShift = vShift;
|
||||
cl->hShift = hShift;
|
||||
cl->extendBy = extendBy;
|
||||
|
||||
m_partFeat->addCenterLine(cl);
|
||||
|
||||
// m_partFeat->requestPaint(); //if execute has not run, then CL will not be in Geoms.
|
||||
m_partFeat->recomputeFeature();
|
||||
Gui::Command::updateActive();
|
||||
Gui::Command::commitCommand();
|
||||
}
|
||||
@@ -247,41 +256,30 @@ void TaskCenterLine::updateCenterLine(void)
|
||||
{
|
||||
// Base::Console().Message("TCL::updateCenterLine()\n");
|
||||
Gui::Command::openCommand("Edit CenterLine");
|
||||
m_cl->fmt.m_color.setValue<QColor>(ui->cpLineColor->color() );
|
||||
m_cl->fmt.m_weight = ui->dsbWeight->value();
|
||||
m_cl->fmt.m_style = ui->cboxStyle->currentIndex();
|
||||
m_cl->fmt.m_visible = true;
|
||||
|
||||
if (ui->rbVertical->isChecked()) {
|
||||
m_cl->mode = 0;
|
||||
} else if (ui->rbHorizontal->isChecked()) {
|
||||
m_cl->mode = 1;
|
||||
} else if (ui->rbAligned->isChecked()) {
|
||||
m_cl->mode = 2;
|
||||
}
|
||||
m_cl->rotate = ui->dsbRotate->value();
|
||||
m_cl->vShift = ui->qsbVertShift->rawValue();
|
||||
m_cl->hShift = ui->qsbHorizShift->rawValue();
|
||||
m_cl->extendBy = ui->qsbExtend->rawValue();
|
||||
m_partFeat->replaceCenterLine(m_clIdx, m_cl);
|
||||
m_partFeat->requestPaint(); //is requestPaint enough here?
|
||||
// m_partFeat->recomputeFeature();
|
||||
|
||||
Gui::Command::updateActive();
|
||||
Gui::Command::commitCommand();
|
||||
}
|
||||
|
||||
void TaskCenterLine::removeCenterLine(void)
|
||||
{
|
||||
// Base::Console().Message("TCL::removeCenterLine()\n");
|
||||
if (m_partFeat != nullptr) {
|
||||
if (m_createMode) {
|
||||
//don't know!
|
||||
} else {
|
||||
if (Gui::Command::hasPendingCommand()) {
|
||||
std::vector<std::string> undos = Gui::Application::Instance->activeDocument()->getUndoVector();
|
||||
Gui::Application::Instance->activeDocument()->undo(1);
|
||||
} else {
|
||||
Base::Console().Log("TaskCenterLine: Edit mode - NO command is active\n");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
QGIView* TaskCenterLine::findParentQGIV()
|
||||
{
|
||||
QGIView* result = nullptr;
|
||||
if (m_partFeat != nullptr) {
|
||||
Gui::ViewProvider* gvp = QGIView::getViewProvider(m_partFeat);
|
||||
ViewProviderDrawingView* vpdv = dynamic_cast<ViewProviderDrawingView*>(gvp);
|
||||
if (vpdv != nullptr) {
|
||||
result = vpdv->getQView();
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
void TaskCenterLine::saveButtons(QPushButton* btnOK,
|
||||
QPushButton* btnCancel)
|
||||
{
|
||||
@@ -295,86 +293,6 @@ void TaskCenterLine::enableTaskButtons(bool b)
|
||||
m_btnCancel->setEnabled(b);
|
||||
}
|
||||
|
||||
TechDraw::CosmeticEdge* TaskCenterLine::calcEndPoints(std::vector<std::string> faceNames,
|
||||
bool vert, double ext,
|
||||
double hShift, double vShift,
|
||||
double rotate)
|
||||
{
|
||||
// Base::Console().Message("TCL::calcEndPoints(%d, %d) \n",faceNames.size(), vert);
|
||||
TechDraw::CosmeticEdge* result = nullptr;
|
||||
|
||||
Bnd_Box faceBox;
|
||||
faceBox.SetGap(0.0);
|
||||
|
||||
double scale = m_partFeat->getScale();
|
||||
double hss = hShift * scale;
|
||||
double vss = vShift * scale;
|
||||
|
||||
|
||||
for (auto& fn: faceNames) {
|
||||
if (TechDraw::DrawUtil::getGeomTypeFromName(fn) != "Face") {
|
||||
continue;
|
||||
}
|
||||
int idx = TechDraw::DrawUtil::getIndexFromName(fn);
|
||||
std::vector<TechDraw::BaseGeom*> faceEdges =
|
||||
m_partFeat->getFaceEdgesByIndex(idx);
|
||||
for (auto& fe: faceEdges) {
|
||||
if (!fe->cosmetic) {
|
||||
BRepBndLib::Add(fe->occEdge, faceBox);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
double Xmin,Ymin,Zmin,Xmax,Ymax,Zmax;
|
||||
faceBox.Get(Xmin,Ymin,Zmin,Xmax,Ymax,Zmax);
|
||||
|
||||
double Xspan = fabs(Xmax - Xmin);
|
||||
// Xspan = (Xspan / 2.0) + (ext * scale); //this should be right? edges in GO are scaled!
|
||||
Xspan = (Xspan / 2.0) + ext;
|
||||
double Xmid = Xmin + fabs(Xmax - Xmin) / 2.0;
|
||||
|
||||
double Yspan = fabs(Ymax - Ymin);
|
||||
// Yspan = (Yspan / 2.0) + (ext * scale);
|
||||
Yspan = (Yspan / 2.0) + ext;
|
||||
double Ymid = Ymin + fabs(Ymax - Ymin) / 2.0;
|
||||
|
||||
Base::Vector3d p1, p2;
|
||||
if (vert) {
|
||||
Base::Vector3d top(Xmid + hss, (Ymid - Yspan) + vss, 0.0);
|
||||
Base::Vector3d bottom(Xmid + hss, (Ymid + Yspan) + vss, 0.0);
|
||||
p1 = top;
|
||||
p2 = bottom;
|
||||
} else {
|
||||
Base::Vector3d left((Xmid - Xspan) + hss, Ymid + vss, 0.0);
|
||||
Base::Vector3d right((Xmid + Xspan) + hss, Ymid + vss, 0.0);
|
||||
p1 = left;
|
||||
p2 = right;
|
||||
}
|
||||
|
||||
Base::Vector3d bbxCenter(Xmid, Ymid, 0.0);
|
||||
if (!DrawUtil::fpCompare(rotate, 0.0)) {
|
||||
double cosTheta = cos(rotate * M_PI / 180.0);
|
||||
double sinTheta = sin(rotate * M_PI / 180.0);
|
||||
Base::Vector3d toOrg = p1 - bbxCenter;
|
||||
double xRot = toOrg.x * cosTheta - toOrg.y * sinTheta;
|
||||
double yRot = toOrg.y * cosTheta + toOrg.x * sinTheta;
|
||||
p1 = Base::Vector3d(xRot, yRot, 0.0) + bbxCenter;
|
||||
toOrg = p2 - bbxCenter;
|
||||
xRot = toOrg.x * cosTheta - toOrg.y * sinTheta;
|
||||
yRot = toOrg.y * cosTheta + toOrg.x * sinTheta;
|
||||
p2 = Base::Vector3d(xRot, yRot, 0.0) + bbxCenter;
|
||||
}
|
||||
|
||||
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->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;
|
||||
}
|
||||
|
||||
double TaskCenterLine::getCenterWidth()
|
||||
{
|
||||
Base::Reference<ParameterGrp> hGrp = App::GetApplication().GetUserParameter().GetGroup("BaseApp")->
|
||||
@@ -416,16 +334,14 @@ double TaskCenterLine::getExtendBy(void)
|
||||
bool TaskCenterLine::accept()
|
||||
{
|
||||
// Base::Console().Message("TCL::accept()\n");
|
||||
|
||||
Gui::Document* doc = Gui::Application::Instance->getDocument(m_basePage->getDocument());
|
||||
if (!doc) return false;
|
||||
|
||||
if (!getCreateMode()) {
|
||||
//
|
||||
updateCenterLine();
|
||||
} else {
|
||||
createCenterLine();
|
||||
}
|
||||
// m_mdi->setContextMenuPolicy(m_saveContextPolicy);
|
||||
Gui::Command::doCommand(Gui::Command::Gui,"Gui.ActiveDocument.resetEdit()");
|
||||
|
||||
return true;
|
||||
@@ -433,25 +349,19 @@ bool TaskCenterLine::accept()
|
||||
|
||||
bool TaskCenterLine::reject()
|
||||
{
|
||||
if (m_inProgressLock) {
|
||||
// Base::Console().Message("TCL::reject - edit in progress!!\n");
|
||||
return false;
|
||||
}
|
||||
|
||||
Gui::Document* doc = Gui::Application::Instance->getDocument(m_basePage->getDocument());
|
||||
if (!doc) return false;
|
||||
|
||||
if (m_mdi != nullptr) {
|
||||
// m_mdi->setContextMenuPolicy(m_saveContextPolicy);
|
||||
}
|
||||
if (getCreateMode() &&
|
||||
(m_partFeat != nullptr) ) {
|
||||
//
|
||||
// Base::Console().Message("TCL::reject - credit Mode!!\n");
|
||||
//nothing to remove.
|
||||
}
|
||||
|
||||
if (!getCreateMode() &&
|
||||
(m_partFeat != nullptr) ) {
|
||||
//
|
||||
// Base::Console().Message("TCL::reject - edit Mode!!\n");
|
||||
//nothing to un-update
|
||||
}
|
||||
|
||||
//make sure any dangling objects are cleaned up
|
||||
@@ -475,15 +385,17 @@ TaskDlgCenterLine::TaskDlgCenterLine(TechDraw::DrawViewPart* partFeat,
|
||||
Content.push_back(taskbox);
|
||||
}
|
||||
|
||||
//TaskDlgCenterLine::TaskDlgCenterLine(TechDrawGui::ViewProviderViewPart* partVP)
|
||||
// : TaskDialog()
|
||||
//{
|
||||
// widget = new TaskCenterLine(partVP);
|
||||
// taskbox = new Gui::TaskView::TaskBox(Gui::BitmapFactory().pixmap("actions/techdraw-facecenterline"),
|
||||
// widget->windowTitle(), true, 0);
|
||||
// taskbox->groupLayout()->addWidget(widget);
|
||||
// Content.push_back(taskbox);
|
||||
//}
|
||||
TaskDlgCenterLine::TaskDlgCenterLine(TechDraw::DrawViewPart* partFeat,
|
||||
TechDraw::DrawPage* page,
|
||||
std::string edgeName)
|
||||
: TaskDialog()
|
||||
{
|
||||
widget = new TaskCenterLine(partFeat,page, edgeName);
|
||||
taskbox = new Gui::TaskView::TaskBox(Gui::BitmapFactory().pixmap("actions/techdraw-facecenterline"),
|
||||
widget->windowTitle(), true, 0);
|
||||
taskbox->groupLayout()->addWidget(widget);
|
||||
Content.push_back(taskbox);
|
||||
}
|
||||
|
||||
TaskDlgCenterLine::~TaskDlgCenterLine()
|
||||
{
|
||||
|
||||
@@ -51,6 +51,8 @@ namespace TechDraw
|
||||
class DrawPage;
|
||||
class DrawView;
|
||||
class DrawViewPart;
|
||||
class CosmeticEdge;
|
||||
class LineFormat;
|
||||
}
|
||||
|
||||
namespace TechDraw
|
||||
@@ -74,7 +76,9 @@ public:
|
||||
TaskCenterLine(TechDraw::DrawViewPart* baseFeat,
|
||||
TechDraw::DrawPage* page,
|
||||
std::vector<std::string> subNames);
|
||||
/* TaskCenterLine(TechDrawGui::ViewProviderViewPart* partVP);*/
|
||||
TaskCenterLine(TechDraw::DrawViewPart* baseFeat,
|
||||
TechDraw::DrawPage* page,
|
||||
std::string edgeName);
|
||||
~TaskCenterLine();
|
||||
|
||||
public Q_SLOTS:
|
||||
@@ -97,24 +101,10 @@ protected:
|
||||
|
||||
void blockButtons(bool b);
|
||||
void setUiPrimary(void);
|
||||
/* void setUiEdit(void);*/
|
||||
/* void enableVPUi(bool b);*/
|
||||
/* void setEditCursor(QCursor c);*/
|
||||
void setUiEdit(void);
|
||||
|
||||
void addCenterLine(void);
|
||||
void createCenterLine(void);
|
||||
|
||||
|
||||
QGIView* findParentQGIV();
|
||||
void updateCenterLine(void);
|
||||
void removeCenterLine(void);
|
||||
TechDraw::CosmeticEdge* calcEndPoints(std::vector<std::string> faceNames,
|
||||
bool vert, double ext,
|
||||
double hShift, double vShift,
|
||||
double rotate);
|
||||
|
||||
void saveState(void);
|
||||
void restoreState(void);
|
||||
|
||||
double getCenterWidth();
|
||||
QColor getCenterColor();
|
||||
@@ -124,24 +114,20 @@ protected:
|
||||
|
||||
private:
|
||||
Ui_TaskCenterLine * ui;
|
||||
bool blockUpdate;
|
||||
|
||||
MDIViewPage* m_mdi;
|
||||
QGraphicsScene* m_scene;
|
||||
QGVPage* m_view;
|
||||
ViewProviderViewPart* m_partVP;
|
||||
TechDraw::DrawViewPart* m_partFeat;
|
||||
TechDraw::DrawPage* m_basePage;
|
||||
bool m_createMode;
|
||||
|
||||
Qt::ContextMenuPolicy m_saveContextPolicy;
|
||||
bool m_inProgressLock;
|
||||
|
||||
QPushButton* m_btnOK;
|
||||
QPushButton* m_btnCancel;
|
||||
|
||||
std::vector<std::string> m_subNames;
|
||||
std::string m_edgeName;
|
||||
double m_extendBy;
|
||||
int m_geomIndex;
|
||||
TechDraw::CenterLine* m_cl;
|
||||
int m_clIdx;
|
||||
};
|
||||
|
||||
class TaskDlgCenterLine : public Gui::TaskView::TaskDialog
|
||||
@@ -152,7 +138,9 @@ public:
|
||||
TaskDlgCenterLine(TechDraw::DrawViewPart* baseFeat,
|
||||
TechDraw::DrawPage* page,
|
||||
std::vector<std::string> subNames);
|
||||
/* TaskDlgCenterLine(TechDrawGui::ViewProviderLeader* partVP);*/
|
||||
TaskDlgCenterLine(TechDraw::DrawViewPart* baseFeat,
|
||||
TechDraw::DrawPage* page,
|
||||
std::string edgeName);
|
||||
~TaskDlgCenterLine();
|
||||
|
||||
public:
|
||||
|
||||
@@ -98,6 +98,9 @@
|
||||
<layout class="QGridLayout" name="gridLayout_2">
|
||||
<item row="0" column="0">
|
||||
<widget class="QRadioButton" name="rbVertical">
|
||||
<property name="toolTip">
|
||||
<string>Top to Bottom line</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Vertical</string>
|
||||
</property>
|
||||
@@ -111,6 +114,9 @@
|
||||
<property name="enabled">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string>Left to Right line</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Horizontal</string>
|
||||
</property>
|
||||
@@ -118,6 +124,12 @@
|
||||
</item>
|
||||
<item row="0" column="2">
|
||||
<widget class="QRadioButton" name="rbAligned">
|
||||
<property name="enabled">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string>Option not implemented yet</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Aligned</string>
|
||||
</property>
|
||||
|
||||
Reference in New Issue
Block a user