Skip to content

Commit

Permalink
[TD]Add CenterLine edit function
Browse files Browse the repository at this point in the history
  • Loading branch information
WandererFan committed Jul 15, 2019
1 parent 39e556f commit 11d8aae
Show file tree
Hide file tree
Showing 20 changed files with 977 additions and 570 deletions.
307 changes: 260 additions & 47 deletions src/Mod/TechDraw/App/Cosmetic.cpp

Large diffs are not rendered by default.

54 changes: 42 additions & 12 deletions src/Mod/TechDraw/App/Cosmetic.h
Expand Up @@ -30,11 +30,8 @@

class TopoDS_Edge;

/*namespace TechDraw {*/
/*class BaseGeom;*/
/*}*/

namespace TechDraw {
class DrawViewPart;

class TechDrawExport LineFormat
{
Expand Down Expand Up @@ -78,35 +75,68 @@ class TechDrawExport CosmeticVertex: public TechDraw::Vertex
bool visible;

protected:
/* std::vector<std::string> split(std::string csvLine);*/

};

//class TechDrawExport CosmeticEdge: publix TechDraw::BaseGeom
class TechDrawExport CosmeticEdge
{
public:
CosmeticEdge();
CosmeticEdge(Base::Vector3d p1, Base::Vector3d p2);
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

Expand Down
2 changes: 1 addition & 1 deletion src/Mod/TechDraw/App/DrawView.h
Expand Up @@ -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
*/
Expand Down
15 changes: 4 additions & 11 deletions src/Mod/TechDraw/App/DrawViewDetail.cpp
Expand Up @@ -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());
Expand All @@ -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);
Expand Down Expand Up @@ -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!
Expand Down
22 changes: 11 additions & 11 deletions src/Mod/TechDraw/App/DrawViewDimension.cpp
Expand Up @@ -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);
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -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);
Expand All @@ -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());
Expand Down Expand Up @@ -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) ||
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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)) {
Expand Down

0 comments on commit 11d8aae

Please sign in to comment.