[TD]Landmark Dims initial impl

This commit is contained in:
wandererfan
2020-02-16 13:37:43 -05:00
committed by WandererFan
parent 4eacc3f28a
commit cb2a3d529c
24 changed files with 1177 additions and 90 deletions

View File

@@ -28,6 +28,7 @@
#include "DrawViewAnnotation.h"
#include "DrawViewDimension.h"
#include "DrawViewDimExtent.h"
#include "LandmarkDimension.h"
#include "DrawProjGroupItem.h"
#include "DrawProjGroup.h"
#include "DrawViewSymbol.h"
@@ -85,6 +86,7 @@ PyMOD_INIT_FUNC(TechDraw)
TechDraw::DrawViewMulti ::init();
TechDraw::DrawViewDimension ::init();
TechDraw::DrawViewDimExtent ::init();
TechDraw::LandmarkDimension ::init();
TechDraw::DrawProjGroup ::init();
TechDraw::DrawProjGroupItem ::init();
TechDraw::DrawViewDetail ::init();

View File

@@ -100,6 +100,8 @@ SET(Draw_SRCS
DrawViewDimension.h
DrawViewDimExtent.cpp
DrawViewDimExtent.h
LandmarkDimension.cpp
LandmarkDimension.h
DrawViewBalloon.cpp
DrawViewBalloon.h
DrawViewSection.cpp

View File

@@ -191,6 +191,16 @@ CosmeticVertex::CosmeticVertex(Base::Vector3d loc) : TechDraw::Vertex(loc)
}
void CosmeticVertex::move(Base::Vector3d newPos)
{
permaPoint = newPos;
}
void CosmeticVertex::moveRelative(Base::Vector3d movement)
{
permaPoint += movement;
}
std::string CosmeticVertex::toString(void) const
{
std::stringstream ss;

View File

@@ -77,6 +77,9 @@ public:
CosmeticVertex(Base::Vector3d loc);
virtual ~CosmeticVertex() = default;
void move(Base::Vector3d newPos);
void moveRelative(Base::Vector3d movement);
std::string toString(void) const;
void dump(const char* title);
Base::Vector3d scaled(double factor);

View File

@@ -434,6 +434,7 @@ void DrawView::handleChangedPropertyType(
bool DrawView::keepUpdated(void)
{
// Base::Console().Message("DV::keepUpdated() - %s\n", getNameInDocument());
bool result = false;
bool pageUpdate = false;
@@ -455,7 +456,6 @@ bool DrawView::keepUpdated(void)
if (force) { //when do we turn this off??
result = true;
}
return result;
}

View File

@@ -25,6 +25,7 @@
#include <boost/signals2.hpp>
#include <QCoreApplication>
#include <QRectF>
#include <App/DocumentObject.h>
@@ -45,6 +46,7 @@ class DrawLeaderLine;
*/
class TechDrawExport DrawView : public App::DocumentObject
{
Q_DECLARE_TR_FUNCTIONS(TechDraw::DrawView);
PROPERTY_HEADER_WITH_OVERRIDE(TechDraw::DrawView);
public:
@@ -88,7 +90,7 @@ public:
virtual bool checkFit(void) const;
virtual bool checkFit(DrawPage*) const;
virtual void setPosition(double x, double y, bool force = false);
bool keepUpdated(void);
virtual bool keepUpdated(void);
boost::signals2::signal<void (const DrawView*)> signalGuiPaint;
virtual double getScale(void) const;
void checkScale(void);

View File

@@ -82,15 +82,6 @@ const char* DrawViewDimension::MeasureTypeEnums[]= {"True",
"Projected",
NULL};
enum RefType{
invalidRef,
oneEdge,
twoEdge,
twoVertex,
vertexEdge,
threeVertex
};
DrawViewDimension::DrawViewDimension(void)
{
ADD_PROPERTY_TYPE(References2D,(0,0),"",(App::Prop_None),"Projected Geometry References");
@@ -98,7 +89,7 @@ DrawViewDimension::DrawViewDimension(void)
ADD_PROPERTY_TYPE(References3D,(0,0),"",(App::Prop_None),"3D Geometry References");
References3D.setScope(App::LinkScope::Global);
ADD_PROPERTY_TYPE(FormatSpec,("") , "Format", App::Prop_Output,"Dimension Format");
ADD_PROPERTY_TYPE(FormatSpec,(getDefaultFormatSpec()) , "Format", App::Prop_Output,"Dimension Format");
ADD_PROPERTY_TYPE(Arbitrary,(false) ,"Format", App::Prop_Output,"Value overridden by user");
Type.setEnums(TypeEnums); //dimension type: length, radius etc
@@ -112,7 +103,7 @@ DrawViewDimension::DrawViewDimension(void)
//hide the properties the user can't edit in the property editor
// References2D.setStatus(App::Property::Hidden,true);
References3D.setStatus(App::Property::Hidden,true);
// References3D.setStatus(App::Property::Hidden,true);
//hide the DrawView properties that don't apply to Dimensions
ScaleType.setStatus(App::Property::ReadOnly,true);
@@ -161,6 +152,7 @@ void DrawViewDimension::onChanged(const App::Property* prop)
MeasureType.setValue("Projected");
}
} else if (prop == &References3D) { //have to rebuild the Measurement object
// Base::Console().Message("DVD::onChanged - References3D\n");
clear3DMeasurements(); //Measurement object
if (!(References3D.getValues()).empty()) {
setAll3DMeasurement();
@@ -219,14 +211,12 @@ App::DocumentObjectExecReturn *DrawViewDimension::execute(void)
// Base::Console().Message("DVD::execute() - %s\n", getNameInDocument());
if (!keepUpdated()) {
return App::DocumentObject::StdReturn;
}
DrawViewPart* dvp = getViewPart();
if (dvp == nullptr) {
Base::Console().Message("DVD::execute - no DVP!\n");
return App::DocumentObject::StdReturn;
}
DrawViewPart* dvp = getViewPart();
if (dvp == nullptr) {
return App::DocumentObject::StdReturn;
}
//any empty Reference2D??
if (!has2DReferences()) { //too soon?
if (isRestoring() ||
getDocument()->testStatus(App::Document::Status::Restoring)) {
@@ -243,7 +233,6 @@ App::DocumentObjectExecReturn *DrawViewDimension::execute(void)
getDocument()->testStatus(App::Document::Status::Restoring)) {
return App::DocumentObject::StdReturn;
} else {
Base::Console().Warning("%s - target has no geometry\n", getNameInDocument());
return App::DocumentObject::StdReturn;
}
}
@@ -259,7 +248,6 @@ App::DocumentObjectExecReturn *DrawViewDimension::execute(void)
if ( Type.isValue("Distance") ||
Type.isValue("DistanceX") ||
Type.isValue("DistanceY") ) {
if (getRefType() == oneEdge) {
m_linearPoints = getPointsOneEdge();
}else if (getRefType() == twoEdge) {
@@ -721,9 +709,9 @@ double DrawViewDimension::getDimValue()
}
return result;
}
if (getViewPart() == nullptr) {
return result;
}
if (getViewPart() == nullptr) {
return result;
}
if (!getViewPart()->hasGeometry() ) { //happens when loading saved document
return result;
@@ -802,7 +790,6 @@ double DrawViewDimension::getDimValue()
result = -result;
}
}
return result;
}
@@ -1226,27 +1213,27 @@ std::string DrawViewDimension::getDefaultFormatSpec() const
return Base::Tools::toStdString(formatSpec);
}
//! is refName a target of this Dim (2D references)
bool DrawViewDimension::references(std::string refName) const
{
Base::Console().Message("DVD::references(%s) - %s\n",refName.c_str(),getNameInDocument());
bool result = false;
const std::vector<App::DocumentObject*> &objects = References2D.getValues();
if (!objects.empty()) {
const std::vector<std::string> &subElements = References2D.getSubValues();
if (!subElements.empty()) {
for (auto& s: subElements) {
if (!s.empty()) {
if (s == refName) {
result = true;
break;
}
}
}
}
}
return result;
}
////! is refName a target of this Dim (2D references)
//bool DrawViewDimension::references(std::string refName) const
//{
// Base::Console().Message("DVD::references(%s) - %s\n",refName.c_str(),getNameInDocument());
// bool result = false;
// const std::vector<App::DocumentObject*> &objects = References2D.getValues();
// if (!objects.empty()) {
// const std::vector<std::string> &subElements = References2D.getSubValues();
// if (!subElements.empty()) {
// for (auto& s: subElements) {
// if (!s.empty()) {
// if (s == refName) {
// result = true;
// break;
// }
// }
// }
// }
// }
// return result;
//}
PyObject *DrawViewDimension::getPyObject(void)
{

View File

@@ -105,9 +105,19 @@ public:
App::PropertyFloat OverTolerance;
App::PropertyFloat UnderTolerance;
enum RefType{
invalidRef,
oneEdge,
twoEdge,
twoVertex,
vertexEdge,
threeVertex
};
short mustExecute() const override;
bool has2DReferences(void) const;
bool has3DReferences(void) const;
virtual bool has2DReferences(void) const;
virtual bool has3DReferences(void) const;
bool hasTolerance(void) const;
/** @name methods override Feature */
@@ -125,14 +135,14 @@ public:
virtual std::string getFormatedValue(int partial = 0);
virtual double getDimValue();
DrawViewPart* getViewPart() const;
virtual DrawViewPart* getViewPart() const;
virtual QRectF getRect() const override { return QRectF(0,0,1,1);} //pretend dimensions always fit!
static int getRefType1(const std::string s);
static int getRefType2(const std::string s1, const std::string s2);
static int getRefType3(const std::string g1,
const std::string g2,
const std::string g3);
int getRefType() const; //Vertex-Vertex, Edge, Edge-Edge
virtual int getRefType() const; //Vertex-Vertex, Edge, Edge-Edge
void setAll3DMeasurement();
void clear3DMeasurements(void);
virtual bool checkReferences2D(void) const;
@@ -140,7 +150,7 @@ public:
arcPoints getArcPoints(void) {return m_arcPoints; }
anglePoints getAnglePoints(void) {return m_anglePoints; }
bool leaderIntersectsArc(Base::Vector3d s, Base::Vector3d pointOnCircle);
bool references(std::string geomName) const;
/* bool references(std::string geomName) const;*/
bool isMultiValueSchema(void) const;
@@ -164,13 +174,14 @@ protected:
Base::Vector3d e2) const;
pointPair closestPoints(TopoDS_Shape s1,
TopoDS_Shape s2) const;
pointPair m_linearPoints;
private:
static const char* TypeEnums[];
static const char* MeasureTypeEnums[];
void dumpRefs2D(const char* text) const;
//Dimension "geometry"
pointPair m_linearPoints;
/* pointPair m_linearPoints;*/
arcPoints m_arcPoints;
anglePoints m_anglePoints;
bool m_hasGeometry;

View File

@@ -64,10 +64,12 @@
#include <TopExp.hxx>
#include <TopoDS_Edge.hxx>
#include <TopoDS_Face.hxx>
#include <TopoDS_Vertex.hxx>
#include <TopoDS.hxx>
#include <TopoDS_Shape.hxx>
#include <TopoDS_Vertex.hxx>
#include <TopoDS_Wire.hxx>
#include <BRepAlgo_NormalProjection.hxx>
#include <TopTools_IndexedMapOfShape.hxx>
@@ -99,6 +101,7 @@
#include "DrawViewBalloon.h"
#include "DrawViewDetail.h"
#include "DrawViewDimension.h"
#include "LandmarkDimension.h"
#include "DrawViewPart.h"
#include "DrawViewSection.h"
#include "EdgeWalker.h"
@@ -160,11 +163,6 @@ DrawViewPart::DrawViewPart(void) :
ADD_PROPERTY_TYPE(IsoHidden ,(prefIsoHid()),sgroup,App::Prop_None,"Show Hidden Iso u,v lines");
ADD_PROPERTY_TYPE(IsoCount ,(prefIsoCount()),sgroup,App::Prop_None,"Number of iso parameters lines");
// ADD_PROPERTY_TYPE(CosmeticVertexes ,(0),sgroup,App::Prop_Output,"CosmeticVertex Save/Restore");
// ADD_PROPERTY_TYPE(CosmeticEdges ,(0),sgroup,App::Prop_Output,"CosmeticEdge Save/Restore");
// ADD_PROPERTY_TYPE(CenterLines ,(0),sgroup,App::Prop_Output,"Geometry format Save/Restore");
// ADD_PROPERTY_TYPE(GeomFormats ,(0),sgroup,App::Prop_Output,"Geometry format Save/Restore");
geometryObject = nullptr;
getRunControl();
//initialize bbox to non-garbage
@@ -176,6 +174,16 @@ DrawViewPart::~DrawViewPart()
delete geometryObject;
}
std::vector<TopoDS_Shape> DrawViewPart::getSourceShape2d(void) const
{
// Base::Console().Message("DVP::getSourceShape2d()\n");
std::vector<TopoDS_Shape> result;
const std::vector<App::DocumentObject*>& links = Source.getValues();
result = ShapeExtractor::getShapes2d(links);
return result;
}
TopoDS_Shape DrawViewPart::getSourceShape(void) const
{
TopoDS_Shape result;
@@ -248,6 +256,7 @@ App::DocumentObjectExecReturn *DrawViewPart::execute(void)
return App::DocumentObject::StdReturn;
}
bool haveX = checkXDirection();
if (!haveX) {
//block touch/onChanged stuff
@@ -260,6 +269,7 @@ App::DocumentObjectExecReturn *DrawViewPart::execute(void)
m_saveShape = shape;
partExec(shape);
addShapes2d();
//second pass if required
if (ScaleType.isValue("Automatic")) {
@@ -270,8 +280,9 @@ App::DocumentObjectExecReturn *DrawViewPart::execute(void)
if (geometryObject != nullptr) {
delete geometryObject;
geometryObject = nullptr;
partExec(shape);
// partExec(shape);
}
partExec(shape);
}
}
@@ -335,15 +346,46 @@ void DrawViewPart::partExec(TopoDS_Shape shape)
}
}
#endif //#if MOD_TECHDRAW_HANDLE_FACES
std::vector<TechDraw::Vertex*> verts = getVertexGeometry();
addCosmeticVertexesToGeom();
addCosmeticEdgesToGeom();
addCenterLinesToGeom();
addReferencesToGeom();
}
void DrawViewPart::addShapes2d(void)
{
std::vector<TopoDS_Shape> shapes = getSourceShape2d();
for (auto& s: shapes) {
//just vertices for now
if (s.ShapeType() == TopAbs_VERTEX) {
gp_Pnt gp = BRep_Tool::Pnt(TopoDS::Vertex(s));
Base::Vector3d vp(gp.X(), gp.Y(), gp.Z());
vp = vp - m_saveCentroid;
//need to offset the point to match the big projection
Base::Vector3d projected = projectPoint(vp * getScale());
TechDraw::Vertex* v1 = new TechDraw::Vertex(projected);
geometryObject->addVertex(v1);
} else if (s.ShapeType() == TopAbs_EDGE) {
//not supporting edges yet.
// Base::Console().Message("DVP::add2dShapes - found loose edge - isNull: %d\n", s.IsNull());
// TopoDS_Shape sTrans = TechDraw::moveShape(s,
// m_saveCentroid * -1.0);
// TopoDS_Shape sScale = TechDraw::scaleShape(sTrans,
// getScale());
// TopoDS_Shape sMirror = TechDraw::mirrorShape(sScale);
// TopoDS_Edge edge = TopoDS::Edge(sMirror);
// BaseGeom* bg = projectEdge(edge);
// geometryObject->addEdge(bg);
//save connection between source feat and this edge
}
}
}
GeometryObject* DrawViewPart::makeGeometryForShape(TopoDS_Shape shape)
{
// Base::Console().Message("DVP::makeGeometryforShape() - %s\n", Label.getValue());
gp_Pnt inputCenter;
Base::Vector3d stdOrg(0.0,0.0,0.0);
@@ -758,6 +800,7 @@ QRectF DrawViewPart::getRect() const
//used to project a pt (ex SectionOrigin) onto paper plane
Base::Vector3d DrawViewPart::projectPoint(const Base::Vector3d& pt) const
{
// Base::Console().Message("DVP::projectPoint()\n");
Base::Vector3d stdOrg(0.0,0.0,0.0);
gp_Ax2 viewAxis = getProjectionCS(stdOrg);
gp_Pnt gPt(pt.x,pt.y,pt.z);
@@ -770,6 +813,25 @@ Base::Vector3d DrawViewPart::projectPoint(const Base::Vector3d& pt) const
return result;
}
//project a loose edge onto the paper plane
//TODO:: loose edges not supported yet
BaseGeom* DrawViewPart::projectEdge(const TopoDS_Edge& e) const
{
Base::Vector3d stdOrg(0.0,0.0,0.0);
gp_Ax2 viewAxis = getProjectionCS(stdOrg);
gp_Pln plane(viewAxis);
TopoDS_Face paper = BRepBuilderAPI_MakeFace(plane);
BRepAlgo_NormalProjection projector(paper);
projector.Add(e);
projector.Build();
TopoDS_Shape s = projector.Projection();
// Base::Console().Message("DVP::projectEdge - s.IsNull: %d\n", s.IsNull());
// BaseGeom* result = BaseGeom::baseFactory(pe);
BaseGeom* result = nullptr;
return result;
}
bool DrawViewPart::hasGeometry(void) const
{
bool result = false;
@@ -1004,6 +1066,71 @@ Base::Vector3d DrawViewPart::getLegacyX(const Base::Vector3d& pt,
return result;
}
void DrawViewPart::updateReferenceVert(std::string tag, Base::Vector3d loc2d)
{
for (auto& v: m_referenceVerts) {
if (v->getTagAsString() == tag) {
v->pnt = loc2d;
break;
}
}
}
void DrawViewPart::addReferencesToGeom(void)
{
// Base::Console().Message("DVP::addReferences()\n");
std::vector<TechDraw::Vertex *> gVerts = getVertexGeometry();
gVerts.insert(gVerts.end(), m_referenceVerts.begin(), m_referenceVerts.end());
getGeometryObject()->setVertexGeometry(gVerts);
}
//add a vertex that is not part of the geometry, but is used by
//ex. LandmarkDimension as a reference
std::string DrawViewPart::addReferenceVertex(Base::Vector3d v)
{
// Base::Console().Message("DVP::addReferenceVertex(%s)\n", DrawUtil::formatVector(v).c_str());
std::string refTag;
Base::Vector3d scaledV = v * getScale();
TechDraw::Vertex* ref = new TechDraw::Vertex(scaledV);
ref->reference = true;
refTag = ref->getTagAsString();
m_referenceVerts.push_back(ref);
return refTag;
}
void DrawViewPart::removeReferenceVertex(std::string tag)
{
std::vector<TechDraw::Vertex*> newRefVerts;
for (auto& v: m_referenceVerts) {
if (v->getTagAsString() != tag) {
newRefVerts.push_back(v);
} else {
// delete v; //??? who deletes v?
}
}
resetReferenceVerts();
}
void DrawViewPart::removeAllReferencesFromGeom()
{
std::vector<TechDraw::Vertex *> gVerts = getVertexGeometry();
std::vector<TechDraw::Vertex *> newVerts;
for (auto& gv: gVerts) {
if (!gv->reference) {
newVerts.push_back(gv);
}
}
getGeometryObject()->setVertexGeometry(newVerts);
}
void DrawViewPart::resetReferenceVerts()
{
// Base::Console().Message("DVP::resetReferenceVerts()\n");
removeAllReferencesFromGeom();
addReferencesToGeom();
}
//********
//* Cosmetics
//********
@@ -1054,6 +1181,45 @@ void DrawViewPart::refreshCVGeoms(void)
addCosmeticVertexesToGeom();
}
//what is the CV's position in the big geometry q
int DrawViewPart::getCVIndex(std::string tag)
{
// Base::Console().Message("DVP::getCVIndex(%s)\n", tag.c_str());
int result = -1;
std::vector<TechDraw::Vertex *> gVerts = getVertexGeometry();
Base::Console().Message("DVP::getCVIndex - gVerts: %d\n", gVerts.size());
std::vector<TechDraw::CosmeticVertex*> cVerts = CosmeticVertexes.getValues();
Base::Console().Message("DVP::getCVIndex - cVerts: %d\n", cVerts.size());
int i = 0;
bool found = false;
for (auto& gv :gVerts) {
Base::Console().Message("DVP::getCVIndex - gv cosmetic: %d ctag: %s\n",
gv->cosmetic, gv->cosmeticTag.c_str());
if (gv->cosmeticTag == tag) {
result = i;
found = true;
break;
}
i++;
}
if (!found) { //not in vertexGeoms
int base = gVerts.size();
int i = 0;
for (auto& cv: cVerts) {
// Base::Console().Message("DVP::getCVIndex - cv tag: %s\n",
// cv->getTagAsString().c_str());
if (cv->getTagAsString() == tag) {
result = base + i;
break;
}
i++;
}
}
// Base::Console().Message("DVP::getCVIndex - returns: %d\n", result);
return result;
}
//CosmeticEdges -------------------------------------------------------------------

View File

@@ -146,6 +146,8 @@ public:
virtual Base::Vector3d projectPoint(const Base::Vector3d& pt) const;
virtual BaseGeom* projectEdge(const TopoDS_Edge& e) const;
virtual gp_Ax2 getViewAxis(const Base::Vector3d& pt,
const Base::Vector3d& direction,
const bool flip=true) const;
@@ -166,6 +168,8 @@ public:
virtual TopoDS_Shape getSourceShape(void) const;
virtual TopoDS_Shape getSourceShapeFused(void) const;
virtual std::vector<TopoDS_Shape> getSourceShape2d(void) const;
bool isIso(void) const;
@@ -173,6 +177,7 @@ public:
void refreshCVGeoms(void);
void addCosmeticVertexesToGeom(void);
int add1CVToGV(std::string tag);
int getCVIndex(std::string tag);
void clearCosmeticEdges(void);
void refreshCEGeoms(void);
@@ -190,6 +195,13 @@ public:
void dumpCosVerts(const std::string text);
void dumpCosEdges(const std::string text);
std::string addReferenceVertex(Base::Vector3d v);
void addReferencesToGeom(void);
void removeReferenceVertex(std::string tag);
void updateReferenceVert(std::string tag, Base::Vector3d loc2d);
void removeAllReferencesFromGeom();
void resetReferenceVerts();
protected:
bool checkXDirection(void) const;
@@ -202,6 +214,7 @@ protected:
virtual TechDraw::GeometryObject* buildGeometryObject(TopoDS_Shape shape, gp_Ax2 viewAxis); //const??
virtual TechDraw::GeometryObject* makeGeometryForShape(TopoDS_Shape shape); //const??
void partExec(TopoDS_Shape shape);
virtual void addShapes2d(void);
void extractFaces();
@@ -226,6 +239,7 @@ protected:
bool prefIsoHid(void);
int prefIsoCount(void);
std::vector<TechDraw::Vertex*> m_referenceVerts;
private:
bool nowUnsetting;

View File

@@ -1293,6 +1293,7 @@ Vertex::Vertex()
cosmetic = false;
cosmeticLink = -1;
cosmeticTag = std::string();
reference = false;
createNewTag();
}
@@ -1307,6 +1308,7 @@ Vertex::Vertex(const Vertex* v)
cosmetic = v->cosmetic;
cosmeticLink = v->cosmeticLink;
cosmeticTag = v->cosmeticTag;
reference = false;
createNewTag();
}
@@ -1322,6 +1324,7 @@ Vertex::Vertex(double x, double y)
cosmetic = false;
cosmeticLink = -1;
cosmeticTag = std::string();
reference = false;
createNewTag();
}
@@ -1360,6 +1363,11 @@ void Vertex::Save(Base::Writer &writer) const
writer.Stream() << writer.ind() << "<Cosmetic value=\"" << c2 << "\"/>" << endl;
writer.Stream() << writer.ind() << "<CosmeticLink value=\"" << cosmeticLink << "\"/>" << endl;
writer.Stream() << writer.ind() << "<CosmeticTag value=\"" << cosmeticTag << "\"/>" << endl;
//do we need to save this? always recreated by program.
// const char r = reference?'1':'0';
// writer.Stream() << writer.ind() << "<Reference value=\"" << r << "\"/>" << endl;
writer.Stream() << writer.ind() << "<VertexTag value=\"" << getTagAsString() << "\"/>" << endl;
}
@@ -1384,6 +1392,11 @@ void Vertex::Restore(Base::XMLReader &reader)
cosmeticLink = reader.getAttributeAsInteger("value");
reader.readElement("CosmeticTag");
cosmeticTag = reader.getAttribute("value");
//will restore read to eof looking for "Reference" in old docs?? YES!!
// reader.readElement("Reference");
// reference = (bool)reader.getAttributeAsInteger("value")==0?false:true;
reader.readElement("VertexTag");
std::string temp = reader.getAttribute("value");
boost::uuids::string_generator gen;

View File

@@ -317,6 +317,7 @@ class TechDrawExport Vertex
bool cosmetic;
int cosmeticLink; //deprec. use cosmeticTag
std::string cosmeticTag;
bool reference; //reference vertex (ex robust dimension)
double x() {return pnt.x;}
double y() {return pnt.y;}

View File

@@ -573,6 +573,16 @@ void GeometryObject::addGeomFromCompound(TopoDS_Shape edgeCompound, edgeClass ca
} //end TopExp
}
void GeometryObject::addVertex(TechDraw::Vertex* v)
{
vertexGeom.push_back(v);
}
void GeometryObject::addEdge(TechDraw::BaseGeom* bg)
{
edgeGeom.push_back(bg);
}
//********** Cosmetic Vertex ***************************************************
//adds a new GeomVert surrogate for CV

View File

@@ -144,6 +144,10 @@ public:
TopoDS_Shape getHidSeam(void) { return hidSeam; }
TopoDS_Shape getHidIso(void) { return hidIso; }
void addVertex(TechDraw::Vertex* v);
void addEdge(TechDraw::BaseGeom* bg);
int addCosmeticVertex(CosmeticVertex* cv);
int addCosmeticVertex(Base::Vector3d pos);
int addCosmeticVertex(Base::Vector3d pos,

View File

@@ -0,0 +1,258 @@
/***************************************************************************
* Copyright (c) 2020 WandererFan <wandererfan@gmail.com *
* *
* This file is part of the FreeCAD CAx development system. *
* *
* This library is free software; you can redistribute it and/or *
* modify it under the terms of the GNU Library General Public *
* License as published by the Free Software Foundation; either *
* version 2 of the License, or (at your option) any later version. *
* *
* This library is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU Library General Public License for more details. *
* *
* You should have received a copy of the GNU Library General Public *
* License along with this library; see the file COPYING.LIB. If not, *
* write to the Free Software Foundation, Inc., 59 Temple Place, *
* Suite 330, Boston, MA 02111-1307, USA *
* *
***************************************************************************/
//*
//* Notes:
//* LandmarkDimension doesn't need References2D as points are always calculated from
//* Reference3D features and DVP Vertices are always accessed by tag.
//* References2D is only used to store the parent DVP
#include "PreCompiled.h"
#ifndef _PreComp_
#endif
#include <HLRAlgo_Projector.hxx>
#include <gp_Ax2.hxx>
#include <gp_Pnt.hxx>
#include <gp_Pnt2d.hxx>
#include <App/Application.h>
#include <App/Document.h>
#include <Base/Console.h>
#include <Base/Exception.h>
#include <Base/Parameter.h>
#include <Base/Quantity.h>
#include <Base/Tools.h>
#include <Base/UnitsApi.h>
#include <Mod/Measure/App/Measurement.h>
#include "Geometry.h"
#include "GeometryObject.h"
#include "DrawViewPart.h"
#include "DrawUtil.h"
#include "LineGroup.h"
#include "Cosmetic.h"
#include "ShapeExtractor.h"
#include "LandmarkDimension.h"
//#include <Mod/TechDraw/App/LandmarkDimensionPy.h> // generated from LandmarkDimensionPy.xml
using namespace TechDraw;
//===========================================================================
// LandmarkDimension
//===========================================================================
PROPERTY_SOURCE(TechDraw::LandmarkDimension, TechDraw::DrawViewDimension)
LandmarkDimension::LandmarkDimension(void)
{
static const char *group = "Landmark";
//this leaves a blank entry in position 1.
ADD_PROPERTY_TYPE(ReferenceTags,("") , group, App::Prop_Output,"Tags of Dimension Endpoints");
std::vector<std::string> noTags;
ReferenceTags.setValues(noTags);
}
LandmarkDimension::~LandmarkDimension()
{
}
void LandmarkDimension::onChanged(const App::Property* prop)
{
if (!isRestoring()) {
//this is only good for new RD creation, not restore from disk?
if (prop == &References3D) {
//handled in base class
} else if (prop == &ReferenceTags) {
//???
}
}
DrawViewDimension::onChanged(prop);
}
short LandmarkDimension::mustExecute() const
{
return DrawViewDimension::mustExecute();
}
App::DocumentObjectExecReturn *LandmarkDimension::execute(void)
{
// Base::Console().Message("LD::execute() - %s\n", getNameInDocument());
if (!keepUpdated()) {
return App::DocumentObject::StdReturn;
}
DrawViewPart* dvp = getViewPart();
if (dvp == nullptr) {
return App::DocumentObject::StdReturn;
}
References2D.setValue(dvp);
std::vector<DocumentObject*> features = References3D.getValues();
//if distance, required size = 2
//if angle, required size = 3;
unsigned int requiredSize = 2;
if (features.size() < requiredSize) {
return App::DocumentObject::StdReturn;
}
std::vector<Base::Vector3d> points;
std::vector<std::string> reprs = ReferenceTags.getValues();
if (reprs.empty()) {
//add verts to dvp & vert tags to RD
for (auto& f: features) {
Base::Vector3d loc3d = ShapeExtractor::getLocation3dFromFeat(f);
Base::Vector3d loc2d = projectPoint(loc3d, dvp) * dvp->getScale();
points.push_back(loc2d);
std::string tag = dvp->addReferenceVertex(loc2d);
reprs.push_back(tag);
}
ReferenceTags.setValues(reprs);
} else {
//update dvp referenceverts locations
int index = 0;
for (auto& f: features) {
Base::Vector3d loc3d = ShapeExtractor::getLocation3dFromFeat(f);
Base::Vector3d loc2d = projectPoint(loc3d, dvp) * dvp->getScale();
points.push_back(loc2d);
dvp->updateReferenceVert(reprs.at(index), loc2d);
index++;
}
}
m_linearPoints.first = points.front();
m_linearPoints.second = points.back();
App::DocumentObjectExecReturn* dvdResult = DrawViewDimension::execute();
dvp->resetReferenceVerts();
dvp->requestPaint();
return dvdResult;
}
Base::Vector3d LandmarkDimension::projectPoint(const Base::Vector3d& pt, DrawViewPart* dvp) const
{
Base::Vector3d stdOrg(0.0,0.0,0.0);
gp_Ax2 viewAxis = dvp->getProjectionCS(stdOrg);
Base::Vector3d alignedPt = pt - dvp->getOriginalCentroid();
gp_Pnt gPt(alignedPt.x, alignedPt.y, alignedPt.z);
HLRAlgo_Projector projector( viewAxis );
gp_Pnt2d prjPnt;
projector.Project(gPt, prjPnt);
Base::Vector3d result(prjPnt.X(),prjPnt.Y(), 0.0);
result = DrawUtil::invertY(result);
return result;
}
std::vector<Base::Vector3d> LandmarkDimension::get2DPoints(void) const
{
// Base::Console().Message("LD::get2DPoints()\n");
std::vector<Base::Vector3d> result;
std::vector<App::DocumentObject*> refs3 = References3D.getValues();
TechDraw::DrawViewPart* dvp = getViewPart();
for (auto& r: refs3) {
Base::Vector3d loc3d = ShapeExtractor::getLocation3dFromFeat(r);
Base::Vector3d loc2d = projectPoint(loc3d, dvp);
result.push_back(loc2d);
}
return result;
}
//! References2D are only used to store ParentView
bool LandmarkDimension::has2DReferences(void) const
{
bool result = false;
const std::vector<App::DocumentObject*> &objects = References2D.getValues();
if (!objects.empty()) {
result = true;
}
return result;
}
//! References2D are only used to store ParentView
bool LandmarkDimension::checkReferences2D() const
{
return true;
}
pointPair LandmarkDimension::getPointsTwoVerts()
{
// Base::Console().Message("LD::getPointsTwoVerts() - %s\n",getNameInDocument());
pointPair result;
TechDraw::DrawViewPart* dvp = getViewPart();
if (dvp != nullptr) {
std::vector<Base::Vector3d> points = get2DPoints();
result.first = points.at(0) * dvp->getScale();
result.second = points.at(1) * dvp->getScale();
}
return result;
}
int LandmarkDimension::getRefType() const
{
//TODO: need changes here when other reference dim types added
return DrawViewDimension::RefType::twoVertex;
}
DrawViewPart* LandmarkDimension::getViewPart() const
{
DrawViewPart* result = nullptr;
std::vector<App::DocumentObject*> refs2d = References2D.getValues();
App::DocumentObject* obj = refs2d.front();
DrawViewPart* dvp = dynamic_cast<DrawViewPart*>(obj);
if (dvp != nullptr) {
result = dvp;
}
return result;
}
//clean up at deletion time
void LandmarkDimension::unsetupObject()
{
// Base::Console().Message("LD::unsetupObject()\n");
DrawViewPart* dvp = getViewPart();
if (dvp != nullptr) {
std::vector<std::string> tags = ReferenceTags.getValues();
for (auto& t: tags) {
dvp->removeReferenceVertex(t);
}
}
DrawViewDimension::unsetupObject();
}
//??? why does getPyObject work sometimes and no others???
//PyObject *LandmarkDimension::getPyObject(void)
//{
// if (PythonObject.is(Py::_None())) {
// // ref counter is set to 1
// PythonObject = Py::Object(new LandmarkDimensionPy(this),true);
// }
// return Py::new_reference_to(PythonObject);
//}

View File

@@ -0,0 +1,78 @@
/***************************************************************************
* Copyright (c) 2020 WandererFan <wandererfan@gmail.com *
* *
* This file is part of the FreeCAD CAx development system. *
* *
* This library is free software; you can redistribute it and/or *
* modify it under the terms of the GNU Library General Public *
* License as published by the Free Software Foundation; either *
* version 2 of the License, or (at your option) any later version. *
* *
* This library is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU Library General Public License for more details. *
* *
* You should have received a copy of the GNU Library General Public *
* License along with this library; see the file COPYING.LIB. If not, *
* write to the Free Software Foundation, Inc., 59 Temple Place, *
* Suite 330, Boston, MA 02111-1307, USA *
* *
***************************************************************************/
#ifndef _TechDraw_LandmarkDimension_h_
#define _TechDraw_LandmarkDimension_h_
# include <App/DocumentObject.h>
# include <App/FeaturePython.h>
# include <App/PropertyLinks.h>
#include "DrawViewDimension.h"
class TopoDS_Shape;
class gp_Ax2;
namespace Measure {
class Measurement;
}
namespace TechDraw
{
class DrawViewPart;
class TechDrawExport LandmarkDimension : public TechDraw::DrawViewDimension
{
PROPERTY_HEADER_WITH_OVERRIDE(TechDraw::LandmarkDimension);
public:
/// Constructor
LandmarkDimension();
virtual ~LandmarkDimension();
App::PropertyStringList ReferenceTags; //tags of 2d vertices in DVP
virtual App::DocumentObjectExecReturn *execute(void) override;
short mustExecute() const override;
virtual const char* getViewProviderName(void) const override {
return "TechDrawGui::ViewProviderDimension"; }
/* virtual PyObject *getPyObject(void) override;*/
virtual bool checkReferences2D() const override;
virtual bool has2DReferences(void) const override;
virtual pointPair getPointsTwoVerts() override;
std::vector<Base::Vector3d> get2DPoints(void) const;
virtual DrawViewPart* getViewPart() const override;
virtual int getRefType() const override;
gp_Ax2 getProjAxis(void) const;
protected:
virtual void onChanged(const App::Property* prop) override;
virtual void unsetupObject() override;
Base::Vector3d projectPoint(const Base::Vector3d& pt, DrawViewPart* dvp) const;
private:
};
} //namespace TechDraw
#endif

View File

@@ -29,7 +29,11 @@
#include <BRepAlgoAPI_Fuse.hxx>
#include <BRepTools.hxx>
#include <BRepBuilderAPI_Copy.hxx>
#include <TopExp.hxx>
#include <TopExp_Explorer.hxx>
#include <TopoDS_Vertex.hxx>
#include <TopoDS.hxx>
#include <TopoDS_Edge.hxx>
#include <App/Application.h>
#include <App/Document.h>
@@ -43,20 +47,53 @@
#include <Base/Parameter.h>
#include <Mod/Part/App/PartFeature.h>
#include <Mod/Part/App/PrimitiveFeature.h>
#include <Mod/Part/App/FeaturePartCircle.h>
#include <Mod/Part/App/TopoShape.h>
#include <Mod/Part/App/PropertyTopoShape.h>
#include "ShapeExtractor.h"
#include "DrawUtil.h"
using namespace TechDraw;
std::vector<TopoDS_Shape> ShapeExtractor::getShapes2d(const std::vector<App::DocumentObject*> links)
{
// Base::Console().Message("SE::getShapes2d()\n");
std::vector<TopoDS_Shape> shapes2d;
for (auto& l:links) {
const App::GroupExtension* gex = dynamic_cast<const App::GroupExtension*>(l);
// App::Property* gProp = l->getPropertyByName("Group");
if (gex != nullptr) {
std::vector<App::DocumentObject*> objs = gex->Group.getValues();
for (auto& d: objs) {
if (is2dObject(d)) {
auto shape = Part::Feature::getShape(d);
if(!shape.IsNull()) {
shapes2d.push_back(shape);
}
}
}
} else {
if (is2dObject(l)) {
auto shape = Part::Feature::getShape(l);
if(!shape.IsNull()) {
shapes2d.push_back(shape);
}
}
}
}
return shapes2d;
}
TopoDS_Shape ShapeExtractor::getShapes(const std::vector<App::DocumentObject*> links)
{
TopoDS_Shape result;
std::vector<TopoDS_Shape> sourceShapes;
for (auto& l:links) {
auto shape = Part::Feature::getShape(l); //finds shape within DocObj??
auto shape = Part::Feature::getShape(l);
if(!shape.IsNull()) {
// BRepTools::Write(shape, "DVPgetShape.brep"); //debug
if (shape.ShapeType() > TopAbs_COMPSOLID) { //simple shape
@@ -201,7 +238,8 @@ std::vector<TopoDS_Shape> ShapeExtractor::extractDrawableShapes(const TopoDS_Sha
extShapes.push_back(s);
}
}
//get edges not part of a solid
//vs using 2d geom as construction geom?
//get edges not part of a solid
//???? should this look for Faces(Wires?) before Edges?
TopExp_Explorer expEdge(shapeIn, TopAbs_EDGE, TopAbs_SOLID);
for (int i = 1; expEdge.More(); expEdge.Next(), i++) {
@@ -222,3 +260,84 @@ std::vector<TopoDS_Shape> ShapeExtractor::extractDrawableShapes(const TopoDS_Sha
return result;
}
bool ShapeExtractor::is2dObject(App::DocumentObject* obj)
{
bool result = false;
if (isEdgeType(obj) || isPointType(obj)) {
result = true;
}
return result;
}
//skip edges for now.
bool ShapeExtractor::isEdgeType(App::DocumentObject* obj)
{
(void) obj;
bool result = false;
// Base::Type t = obj->getTypeId();
// if (t.isDerivedFrom(Part::Line::getClassTypeId()) ) {
// result = true;
// } else if (t.isDerivedFrom(Part::Circle::getClassTypeId())) {
// result = true;
// } else if (t.isDerivedFrom(Part::Ellipse::getClassTypeId())) {
// result = true;
// } else if (t.isDerivedFrom(Part::RegularPolygon::getClassTypeId())) {
// result = true;
// }
return result;
}
bool ShapeExtractor::isPointType(App::DocumentObject* obj)
{
bool result = false;
Base::Type t = obj->getTypeId();
if (t.isDerivedFrom(Part::Vertex::getClassTypeId())) {
result = true;
} else if (isDraftPoint(obj)) {
result = true;
}
return result;
}
bool ShapeExtractor::isDraftPoint(App::DocumentObject* obj)
{
// Base::Console().Message("SE::isDraftPoint()\n");
bool result = false;
//if the docObj doesn't have a Proxy property, it definitely isn't a Draft point
App::Property* proxy = obj->getPropertyByName("Proxy");
if (proxy != nullptr) {
App::PropertyPythonObject* proxyPy = dynamic_cast<App::PropertyPythonObject*>(proxy);
std::string pp = proxyPy->toString();
// Base::Console().Message("SE::isDraftPoint - pp: %s\n", pp.c_str());
if (pp.find("Point") != std::string::npos) {
result = true;
}
}
return result;
}
Base::Vector3d ShapeExtractor::getLocation3dFromFeat(App::DocumentObject* obj)
{
// Base::Console().Message("SE::getLocation3dFromFeat()\n");
Base::Vector3d result(0.0, 0.0, 0.0);
if (!isPointType(obj)) {
return result;
}
// if (isDraftPoint(obj) {
// //Draft Points are not necc. Part::PartFeature??
// //if Draft option "use part primitives" is not set are Draft points still PartFeature?
// Base::Vector3d featPos = features[i]->(Placement.getValue()).Position();
Part::Feature* pf = dynamic_cast<Part::Feature*>(obj);
if (pf != nullptr) {
TopoDS_Shape ts = pf->Shape.getValue();
if (ts.ShapeType() == TopAbs_VERTEX) {
TopoDS_Vertex v = TopoDS::Vertex(ts);
result = DrawUtil::vertex2Vector(v);
}
}
// Base::Console().Message("SE::getLocation3dFromFeat - returns: %s\n",
// DrawUtil::formatVector(result).c_str());
return result;
}

View File

@@ -25,8 +25,6 @@
#include <TopoDS.hxx>
#include <TopoDS_Shape.hxx>
#include <TopExp.hxx>
#include <TopExp_Explorer.hxx>
#include <App/Application.h>
#include <App/Document.h>
@@ -37,6 +35,9 @@
#include <App/PropertyLinks.h>
#include <App/PropertyStandard.h>
#include <Base/Type.h>
#include <Base/Vector3D.h>
namespace TechDraw
{
@@ -44,10 +45,18 @@ class TechDrawExport ShapeExtractor
{
public:
static TopoDS_Shape getShapes(const std::vector<App::DocumentObject*> links);
static std::vector<TopoDS_Shape> getShapes2d(const std::vector<App::DocumentObject*> links);
static std::vector<TopoDS_Shape> getShapesFromObject(const App::DocumentObject* docObj);
static TopoDS_Shape getShapesFused(const std::vector<App::DocumentObject*> links);
static std::vector<TopoDS_Shape> extractDrawableShapes(const TopoDS_Shape shapeIn);
static bool is2dObject(App::DocumentObject* obj);
static bool isEdgeType(App::DocumentObject* obj);
static bool isPointType(App::DocumentObject* obj);
static bool isDraftPoint(App::DocumentObject* obj);
static Base::Vector3d getLocation3dFromFeat(App::DocumentObject* obj);
protected:
private:

View File

@@ -54,6 +54,7 @@
# include <Mod/TechDraw/App/DrawProjGroup.h>
# include <Mod/TechDraw/App/DrawViewDimension.h>
# include <Mod/TechDraw/App/DrawDimHelper.h>
# include <Mod/TechDraw/App/LandmarkDimension.h>
# include <Mod/TechDraw/App/DrawPage.h>
# include <Mod/TechDraw/App/DrawUtil.h>
# include <Mod/TechDraw/App/Geometry.h>
@@ -1338,6 +1339,101 @@ void execVExtent(Gui::Command* cmd)
1);
}
//===========================================================================
// TechDraw_LandmarkDimension
//===========================================================================
DEF_STD_CMD_A(CmdTechDrawLandmarkDimension)
CmdTechDrawLandmarkDimension::CmdTechDrawLandmarkDimension()
: Command("TechDraw_LandmarkDimension")
{
sAppModule = "TechDraw";
sGroup = QT_TR_NOOP("TechDraw");
sMenuText = QT_TR_NOOP("Insert Landmark Dimension");
sToolTipText = sMenuText;
sWhatsThis = "TechDraw_LandmarkDimension";
sStatusTip = sToolTipText;
sPixmap = "techdraw-landmarkdistance";
}
void CmdTechDrawLandmarkDimension::activated(int iMsg)
{
Q_UNUSED(iMsg);
bool result = _checkSelection(this,3); //redundant??
if (!result)
return;
const std::vector<App::DocumentObject*> objects = getSelection().
getObjectsOfType(Part::Feature::getClassTypeId()); //??
if ( (objects.size() != 2) &&
(objects.size() != 3) ) {
QMessageBox::warning(Gui::getMainWindow(), QObject::tr("Wrong selection"),
QObject::tr("Select 2 or 3 point objects and 1 View. (1)"));
return;
}
const std::vector<App::DocumentObject*> views = getSelection().
getObjectsOfType(TechDraw::DrawViewPart::getClassTypeId());
if (views.size() != 1) {
QMessageBox::warning(Gui::getMainWindow(), QObject::tr("Wrong selection"),
QObject::tr("Select 2 or 3 two point objects and 1 View. (2)"));
return;
}
TechDraw::DrawViewPart* dvp = dynamic_cast<TechDraw::DrawViewPart*>(views.front());
std::vector<App::DocumentObject*> refs2d;
std::vector<std::string> subs;
subs.push_back("Vertex1");
subs.push_back("Vertex1");
TechDraw::DrawPage* page = dvp->findParentPage();
std::string parentName = dvp->getNameInDocument();
std::string PageName = page->getNameInDocument();
TechDraw::LandmarkDimension *dim = 0;
std::string FeatName = getUniqueObjectName("LandmarkDim");
openCommand("Create Dimension");
doCommand(Doc,"App.activeDocument().addObject('TechDraw::LandmarkDimension','%s')",FeatName.c_str());
doCommand(Doc,"App.activeDocument().%s.addView(App.activeDocument().%s)",PageName.c_str(),FeatName.c_str());
if (objects.size() == 2) {
//what about distanceX and distanceY??
doCommand(Doc,"App.activeDocument().%s.Type = '%s'",FeatName.c_str(), "Distance");
refs2d.push_back(dvp);
refs2d.push_back(dvp);
} else if (objects.size() == 3) {
doCommand(Doc,"App.activeDocument().%s.Type = '%s'",FeatName.c_str(), "Angle3Pt");
refs2d.push_back(dvp);
refs2d.push_back(dvp);
refs2d.push_back(dvp);
subs.push_back("Vertex1");
}
dim = dynamic_cast<TechDraw::LandmarkDimension *>(getDocument()->getObject(FeatName.c_str()));
if (!dim) {
throw Base::TypeError("CmdTechDrawLandmarkDimension - dim not found\n");
}
dim->References2D.setValues(refs2d, subs);
dim->References3D.setValues(objects, subs);
commitCommand();
dim->recomputeFeature();
//Horrible hack to force Tree update
double x = dvp->X.getValue();
dvp->X.setValue(x);
}
bool CmdTechDrawLandmarkDimension::isActive(void)
{
bool havePage = DrawGuiUtil::needPage(this);
bool haveView = DrawGuiUtil::needView(this);
return (havePage && haveView);
}
//------------------------------------------------------------------------------
void CreateTechDrawCommandsDims(void)
{
@@ -1355,6 +1451,7 @@ void CreateTechDrawCommandsDims(void)
rcCmdMgr.addCommand(new CmdTechDrawVerticalExtentDimension());
rcCmdMgr.addCommand(new CmdTechDrawHorizontalExtentDimension());
rcCmdMgr.addCommand(new CmdTechDrawLinkDimension());
rcCmdMgr.addCommand(new CmdTechDrawLandmarkDimension());
}
//===========================================================================

View File

@@ -66,6 +66,7 @@
#include <Mod/TechDraw/App/DrawViewCollection.h>
#include <Mod/TechDraw/App/DrawViewBalloon.h>
#include <Mod/TechDraw/App/DrawViewDimension.h>
//#include <Mod/TechDraw/App/LandmarkDimension.h>
#include <Mod/TechDraw/App/DrawProjGroup.h>
#include <Mod/TechDraw/App/DrawViewPart.h>
#include <Mod/TechDraw/App/DrawViewAnnotation.h>
@@ -490,6 +491,7 @@ QGIView * QGVPage::addViewDimension(TechDraw::DrawViewDimension *dim)
void QGVPage::addDimToParent(QGIViewDimension* dim, QGIView* parent)
{
// Base::Console().Message("QGVP::addDimToParent()\n");
assert(dim);
assert(parent); //blow up if we don't have Dimension or Parent
QPointF posRef(0.,0.);
@@ -617,10 +619,21 @@ QGIView * QGVPage::findParent(QGIView *view) const
const std::vector<QGIView *> qviews = getViews();
TechDraw::DrawView *myFeat = view->getViewObject();
//LandmarkDimension shouldn't require special handling
// TechDraw::LandmarkDimension *robust = nullptr;
// robust = dynamic_cast<TechDraw::LandmarkDimension*>(myFeat);
// if (robust != nullptr) {
// App::DocumentObject* robustParent = robust->ParentView.getValue();
// for (auto& qv: qviews) {
// if(strcmp(qv->getViewName(), robustParent->getNameInDocument()) == 0) {
// return qv;
// }
// }
// }
//If type is dimension we check references first
TechDraw::DrawViewDimension *dim = 0;
dim = dynamic_cast<TechDraw::DrawViewDimension *>(myFeat);
if(dim) {
std::vector<App::DocumentObject *> objs = dim->References2D.getValues();

View File

@@ -34,6 +34,7 @@
<file>icons/TechDraw_Dimension_Link.svg</file>
<file>icons/TechDraw_HorizontalExtentDimension.svg</file>
<file>icons/TechDraw_VerticalExtentDimension.svg</file>
<file>icons/techdraw-landmarkdistance.svg</file>
<file>icons/preferences-techdraw.svg</file>
<file>icons/arrowdot.svg</file>
<file>icons/arrowopendot.svg</file>

File diff suppressed because one or more lines are too long

After

Width:  |  Height:  |  Size: 12 KiB

View File

@@ -40,6 +40,7 @@
#include <App/Material.h>
#include <Mod/TechDraw/App/LineGroup.h>
#include <Mod/TechDraw/App/LandmarkDimension.h>
#include "QGIViewDimension.h"
#include "ViewProviderDimension.h"
@@ -88,6 +89,11 @@ void ViewProviderDimension::attach(App::DocumentObject *pcFeat)
{
// call parent attach method
ViewProviderDrawingView::attach(pcFeat);
sPixmap = "TechDraw_Dimension";
if (getViewObject()->isDerivedFrom(TechDraw::LandmarkDimension::getClassTypeId())) {
sPixmap = "techdraw-landmarkdistance";
}
}
void ViewProviderDimension::setDisplayMode(const char* ModeName)

View File

@@ -50,32 +50,34 @@ Gui::MenuItem* Workbench::setupMenuBar() const
Gui::MenuItem* draw = new Gui::MenuItem;
root->insertItem(item, draw);
// dimensions
Gui::MenuItem* dimensions = new Gui::MenuItem;
dimensions->setCommand("Dimensions");
*dimensions << "TechDraw_LengthDimension" << "TechDraw_HorizontalDimension" << "TechDraw_VerticalDimension"
<< "TechDraw_RadiusDimension" << "TechDraw_DiameterDimension" << "TechDraw_AngleDimension"
<< "TechDraw_HorizontalExtentDimension" << "TechDraw_VerticalExtentDimension" << "TechDraw_LinkDimension";
// dimensions
Gui::MenuItem* dimensions = new Gui::MenuItem;
dimensions->setCommand("Dimensions");
*dimensions << "TechDraw_LengthDimension" << "TechDraw_HorizontalDimension" << "TechDraw_VerticalDimension"
<< "TechDraw_RadiusDimension" << "TechDraw_DiameterDimension" << "TechDraw_AngleDimension"
<< "TechDraw_HorizontalExtentDimension" << "TechDraw_VerticalExtentDimension" << "TechDraw_LinkDimension"
<< "TechDraw_LandmarkDimension"
;
// annotations
Gui::MenuItem* annotations = new Gui::MenuItem;
annotations->setCommand("Annotations");
*annotations << "TechDraw_Annotation" << "TechDraw_RichTextAnnotation" << "TechDraw_Balloon";
// annotations
Gui::MenuItem* annotations = new Gui::MenuItem;
annotations->setCommand("Annotations");
*annotations << "TechDraw_Annotation" << "TechDraw_RichTextAnnotation" << "TechDraw_Balloon";
// lines
Gui::MenuItem* lines = new Gui::MenuItem;
lines->setCommand("Add Lines");
*lines << "TechDraw_LeaderLine" << "TechDraw_FaceCenterLine"
<< "TechDraw_2LineCenterLine" << "TechDraw_2PointCenterLine";
// lines
Gui::MenuItem* lines = new Gui::MenuItem;
lines->setCommand("Add Lines");
*lines << "TechDraw_LeaderLine" << "TechDraw_FaceCenterLine"
<< "TechDraw_2LineCenterLine" << "TechDraw_2PointCenterLine";
// vertices
Gui::MenuItem* vertices = new Gui::MenuItem;
vertices->setCommand("Add Vertices");
*vertices << "TechDraw_CosmeticVertex" << "TechDraw_Midpoints"
<< "TechDraw_Quadrants";
// vertices
Gui::MenuItem* vertices = new Gui::MenuItem;
vertices->setCommand("Add Vertices");
*vertices << "TechDraw_CosmeticVertex" << "TechDraw_Midpoints"
<< "TechDraw_Quadrants";
// main menu
draw->setCommand("TechDraw");
// main menu
draw->setCommand("TechDraw");
*draw << "TechDraw_PageDefault";
*draw << "TechDraw_PageTemplate";
*draw << "TechDraw_RedrawPage";
@@ -94,7 +96,7 @@ Gui::MenuItem* Workbench::setupMenuBar() const
*draw << "TechDraw_ClipGroupAdd";
*draw << "TechDraw_ClipGroupRemove";
*draw << "Separator";
*draw << dimensions;
*draw << dimensions;
*draw << "Separator";
*draw << "TechDraw_ExportPageSVG";
*draw << "TechDraw_ExportPageDXF";
@@ -106,7 +108,7 @@ Gui::MenuItem* Workbench::setupMenuBar() const
*draw << "TechDraw_ToggleFrame";
*draw << "Separator";
*draw << annotations;
*draw << lines;
*draw << lines;
*draw << vertices;
*draw << "TechDraw_CosmeticEraser";
*draw << "TechDraw_DecorateLine";
@@ -155,6 +157,7 @@ Gui::ToolBarItem* Workbench::setupToolBars() const
// *dims << "TechDraw_VerticalExtentDimension";
*dims << "TechDraw_LinkDimension";
*dims << "TechDraw_Balloon";
*dims << "TechDraw_LandmarkDimension";
// *dims << "TechDraw_Dimension"
Gui::ToolBarItem *file = new Gui::ToolBarItem(root);
@@ -227,6 +230,7 @@ Gui::ToolBarItem* Workbench::setupCommandBars() const
// *dims << "TechDraw_VerticalExtentDimension";
*dims << "TechDraw_LinkDimension";
*dims << "TechDraw_Balloon";
*dims << "TechDraw_LandmarkDimension";
// *dims << "TechDraw_Dimension";
Gui::ToolBarItem *file = new Gui::ToolBarItem(root);