Add vertex-edge dimension
This commit is contained in:
parent
af7d257b91
commit
4fe4c31966
|
@ -79,7 +79,8 @@ enum RefType{
|
|||
invalidRef,
|
||||
oneEdge,
|
||||
twoEdge,
|
||||
twoVertex
|
||||
twoVertex,
|
||||
vertexEdge
|
||||
};
|
||||
|
||||
DrawViewDimension::DrawViewDimension(void)
|
||||
|
@ -92,7 +93,6 @@ DrawViewDimension::DrawViewDimension(void)
|
|||
ADD_PROPERTY_TYPE(References3D,(0,0),"",(App::PropertyType)(App::Prop_None),"3D Geometry References");
|
||||
ADD_PROPERTY_TYPE(Font ,(fontName.c_str()),"Format",App::Prop_None, "The name of the font to use");
|
||||
ADD_PROPERTY_TYPE(Fontsize,(4) ,"Format",(App::PropertyType)(App::Prop_None),"Dimension text size in mm");
|
||||
ADD_PROPERTY_TYPE(CentreLines,(0) ,"Format",(App::PropertyType)(App::Prop_None),"Arc Dimension Center Mark");
|
||||
ADD_PROPERTY_TYPE(FormatSpec,("%value%") ,"Format",(App::PropertyType)(App::Prop_None),"Dimension Format");
|
||||
ADD_PROPERTY_TYPE(LineWidth,(0.5) ,"Format",(App::PropertyType)(App::Prop_None),"Dimension line weight");
|
||||
|
||||
|
@ -129,7 +129,6 @@ void DrawViewDimension::onChanged(const App::Property* prop)
|
|||
if (prop == &References2D ||
|
||||
prop == &Font ||
|
||||
prop == &Fontsize ||
|
||||
prop == &CentreLines ||
|
||||
prop == &FormatSpec ||
|
||||
prop == &LineWidth) {
|
||||
try {
|
||||
|
@ -270,71 +269,77 @@ double DrawViewDimension::getDimValue() const
|
|||
// Projected Values
|
||||
const std::vector<App::DocumentObject*> &objects = References2D.getValues();
|
||||
const std::vector<std::string> &subElements = References2D.getSubValues();
|
||||
if (Type.isValue("Distance") && getRefType() == oneEdge) {
|
||||
//TODO: Check for straight line Edge?
|
||||
int idx = DrawUtil::getIndexFromName(subElements[0]);
|
||||
TechDrawGeometry::BaseGeom* geom = getViewPart()->getProjEdgeByIndex(idx);
|
||||
TechDrawGeometry::Generic* gen = static_cast<TechDrawGeometry::Generic*>(geom);
|
||||
Base::Vector2D start = gen->points[0];
|
||||
Base::Vector2D end = gen->points[1];
|
||||
Base::Vector2D line = end - start;
|
||||
result = line.Length() / getViewPart()->Scale.getValue();
|
||||
} else if (Type.isValue("Distance") && getRefType() == twoEdge) {
|
||||
//only works for straight line edges
|
||||
int idx0 = DrawUtil::getIndexFromName(subElements[0]);
|
||||
int idx1 = DrawUtil::getIndexFromName(subElements[1]);
|
||||
TechDrawGeometry::BaseGeom* geom0 = getViewPart()->getProjEdgeByIndex(idx0);
|
||||
TechDrawGeometry::BaseGeom* geom1 = getViewPart()->getProjEdgeByIndex(idx1);
|
||||
TechDrawGeometry::Generic* gen0 = static_cast<TechDrawGeometry::Generic*>(geom0);
|
||||
TechDrawGeometry::Generic* gen1 = static_cast<TechDrawGeometry::Generic*>(geom1);
|
||||
Base::Vector2D s0 = gen0->points[0];
|
||||
Base::Vector2D e0 = gen0->points[1];
|
||||
Base::Vector2D s1 = gen1->points[0];
|
||||
Base::Vector2D e1 = gen1->points[1];
|
||||
result = dist2Segs(s0,e0,s1,e1) / getViewPart()->Scale.getValue();
|
||||
} else if (Type.isValue("Distance") && getRefType() == twoVertex) {
|
||||
int idx0 = DrawUtil::getIndexFromName(subElements[0]);
|
||||
int idx1 = DrawUtil::getIndexFromName(subElements[1]);
|
||||
TechDrawGeometry::Vertex* v0 = getViewPart()->getProjVertexByIndex(idx0);
|
||||
TechDrawGeometry::Vertex* v1 = getViewPart()->getProjVertexByIndex(idx1);
|
||||
Base::Vector2D start = v0->pnt;
|
||||
Base::Vector2D end = v1->pnt;
|
||||
Base::Vector2D line = end - start;
|
||||
result = line.Length() / getViewPart()->Scale.getValue();
|
||||
} else if (Type.isValue("DistanceX") && getRefType() == oneEdge) {
|
||||
int idx = DrawUtil::getIndexFromName(subElements[0]);
|
||||
TechDrawGeometry::BaseGeom* geom = getViewPart()->getProjEdgeByIndex(idx);
|
||||
TechDrawGeometry::Generic* gen = static_cast<TechDrawGeometry::Generic*>(geom);
|
||||
Base::Vector2D start = gen->points[0];
|
||||
Base::Vector2D end = gen->points[1];
|
||||
Base::Vector2D line = end - start;
|
||||
return fabs(line.fX) / getViewPart()->Scale.getValue();
|
||||
} else if (Type.isValue("DistanceY") && getRefType() == oneEdge) {
|
||||
int idx = DrawUtil::getIndexFromName(subElements[0]);
|
||||
TechDrawGeometry::BaseGeom* geom = getViewPart()->getProjEdgeByIndex(idx);
|
||||
TechDrawGeometry::Generic* gen = static_cast<TechDrawGeometry::Generic*>(geom);
|
||||
Base::Vector2D start = gen->points[0];
|
||||
Base::Vector2D end = gen->points[1];
|
||||
Base::Vector2D line = end - start;
|
||||
result = fabs(line.fY) / getViewPart()->Scale.getValue();
|
||||
} else if (Type.isValue("DistanceX") && getRefType() == twoVertex) {
|
||||
int idx0 = DrawUtil::getIndexFromName(subElements[0]);
|
||||
int idx1 = DrawUtil::getIndexFromName(subElements[1]);
|
||||
TechDrawGeometry::Vertex* v0 = getViewPart()->getProjVertexByIndex(idx0);
|
||||
TechDrawGeometry::Vertex* v1 = getViewPart()->getProjVertexByIndex(idx1);
|
||||
Base::Vector2D start = v0->pnt;
|
||||
Base::Vector2D end = v1->pnt;
|
||||
Base::Vector2D line = end - start;
|
||||
result = fabs(line.fX) / getViewPart()->Scale.getValue();
|
||||
} else if (Type.isValue("DistanceY") && getRefType() == twoVertex) {
|
||||
int idx0 = DrawUtil::getIndexFromName(subElements[0]);
|
||||
int idx1 = DrawUtil::getIndexFromName(subElements[1]);
|
||||
TechDrawGeometry::Vertex* v0 = getViewPart()->getProjVertexByIndex(idx0);
|
||||
TechDrawGeometry::Vertex* v1 = getViewPart()->getProjVertexByIndex(idx1);
|
||||
Base::Vector2D start = v0->pnt;
|
||||
Base::Vector2D end = v1->pnt;
|
||||
Base::Vector2D line = end - start;
|
||||
result = fabs(line.fY) / getViewPart()->Scale.getValue();
|
||||
if ( Type.isValue("Distance") ||
|
||||
Type.isValue("DistanceX") ||
|
||||
Type.isValue("DistanceY") ) {
|
||||
if (getRefType() == oneEdge) {
|
||||
//TODO: Check for straight line Edge?
|
||||
int idx = DrawUtil::getIndexFromName(subElements[0]);
|
||||
TechDrawGeometry::BaseGeom* geom = getViewPart()->getProjEdgeByIndex(idx);
|
||||
TechDrawGeometry::Generic* gen = static_cast<TechDrawGeometry::Generic*>(geom);
|
||||
Base::Vector2D start = gen->points[0];
|
||||
Base::Vector2D end = gen->points[1];
|
||||
Base::Vector2D line = end - start;
|
||||
if (Type.isValue("Distance")) {
|
||||
result = line.Length() / getViewPart()->Scale.getValue();
|
||||
} else if (Type.isValue("DistanceX")) {
|
||||
return fabs(line.fX) / getViewPart()->Scale.getValue();
|
||||
} else {
|
||||
result = fabs(line.fY) / getViewPart()->Scale.getValue();
|
||||
}
|
||||
}else if (getRefType() == twoEdge) {
|
||||
//only works for straight line edges
|
||||
int idx0 = DrawUtil::getIndexFromName(subElements[0]);
|
||||
int idx1 = DrawUtil::getIndexFromName(subElements[1]);
|
||||
TechDrawGeometry::BaseGeom* geom0 = getViewPart()->getProjEdgeByIndex(idx0);
|
||||
TechDrawGeometry::BaseGeom* geom1 = getViewPart()->getProjEdgeByIndex(idx1);
|
||||
TechDrawGeometry::Generic* gen0 = static_cast<TechDrawGeometry::Generic*>(geom0);
|
||||
TechDrawGeometry::Generic* gen1 = static_cast<TechDrawGeometry::Generic*>(geom1);
|
||||
Base::Vector2D s0 = gen0->points[0];
|
||||
Base::Vector2D e0 = gen0->points[1];
|
||||
Base::Vector2D s1 = gen1->points[0];
|
||||
Base::Vector2D e1 = gen1->points[1];
|
||||
if (Type.isValue("Distance")) {
|
||||
//we don't do horiz/vertical edge to edge
|
||||
result = dist2Segs(s0,e0,s1,e1) / getViewPart()->Scale.getValue();
|
||||
}
|
||||
} else if (getRefType() == twoVertex) {
|
||||
int idx0 = DrawUtil::getIndexFromName(subElements[0]);
|
||||
int idx1 = DrawUtil::getIndexFromName(subElements[1]);
|
||||
TechDrawGeometry::Vertex* v0 = getViewPart()->getProjVertexByIndex(idx0);
|
||||
TechDrawGeometry::Vertex* v1 = getViewPart()->getProjVertexByIndex(idx1);
|
||||
Base::Vector2D start = v0->pnt;
|
||||
Base::Vector2D end = v1->pnt;
|
||||
Base::Vector2D line = end - start;
|
||||
if (Type.isValue("Distance")) {
|
||||
result = line.Length() / getViewPart()->Scale.getValue();
|
||||
} else if (Type.isValue("DistanceX")) {
|
||||
result = fabs(line.fX) / getViewPart()->Scale.getValue();
|
||||
} else {
|
||||
result = fabs(line.fY) / getViewPart()->Scale.getValue();
|
||||
}
|
||||
} else if (getRefType() == vertexEdge) {
|
||||
int idx0 = DrawUtil::getIndexFromName(subElements[0]);
|
||||
int idx1 = DrawUtil::getIndexFromName(subElements[1]);
|
||||
TechDrawGeometry::BaseGeom* e;
|
||||
TechDrawGeometry::Vertex* v;
|
||||
if (DrawUtil::getGeomTypeFromName(subElements[0]) == "Edge") {
|
||||
e = getViewPart()->getProjEdgeByIndex(idx0);
|
||||
v = getViewPart()->getProjVertexByIndex(idx1);
|
||||
} else {
|
||||
e = getViewPart()->getProjEdgeByIndex(idx1);
|
||||
v = getViewPart()->getProjVertexByIndex(idx0);
|
||||
}
|
||||
Base::Vector2D nearPoint = e->nearPoint(v->pnt);
|
||||
Base::Vector2D line = nearPoint - v->pnt;
|
||||
if (Type.isValue("Distance")) {
|
||||
result = e->minDist(v->pnt) / getViewPart()->Scale.getValue();
|
||||
} else if (Type.isValue("DistanceX")) {
|
||||
result = fabs(line.fX) / getViewPart()->Scale.getValue();
|
||||
} else {
|
||||
result = fabs(line.fY) / getViewPart()->Scale.getValue();
|
||||
}
|
||||
} //else tarfu
|
||||
} else if(Type.isValue("Radius")){
|
||||
//only 1 reference for a Radius
|
||||
int idx = DrawUtil::getIndexFromName(subElements[0]);
|
||||
|
@ -432,8 +437,13 @@ int DrawViewDimension::getRefType() const
|
|||
} else if ((DrawUtil::getGeomTypeFromName(subElements[0]) == "Vertex") &&
|
||||
(DrawUtil::getGeomTypeFromName(subElements[1]) == "Vertex")) {
|
||||
refType = twoVertex;
|
||||
} else if (((DrawUtil::getGeomTypeFromName(subElements[0]) == "Vertex") &&
|
||||
(DrawUtil::getGeomTypeFromName(subElements[1]) == "Edge")) ||
|
||||
((DrawUtil::getGeomTypeFromName(subElements[0]) == "Edge") &&
|
||||
(DrawUtil::getGeomTypeFromName(subElements[1]) == "Vertex")) ) {
|
||||
refType = vertexEdge;
|
||||
}
|
||||
//} else add different types here - Vertex-Edge, Vertex-Face, ...
|
||||
//} else add different types here - Vertex-Face, ...
|
||||
}
|
||||
return refType;
|
||||
}
|
||||
|
|
|
@ -54,7 +54,6 @@ public:
|
|||
/// Properties for Visualisation
|
||||
App::PropertyString Font;
|
||||
App::PropertyFloat Fontsize;
|
||||
App::PropertyBool CentreLines;
|
||||
App::PropertyString FormatSpec;
|
||||
App::PropertyFloat LineWidth;
|
||||
|
||||
|
|
|
@ -132,6 +132,39 @@ Base::Vector2D BaseGeom::getEndPoint()
|
|||
}
|
||||
|
||||
|
||||
double BaseGeom::minDist(Base::Vector2D p)
|
||||
{
|
||||
double minDist = -1.0;
|
||||
gp_Pnt pnt(p.fX,p.fY,0.0);
|
||||
TopoDS_Vertex v = BRepBuilderAPI_MakeVertex(pnt);
|
||||
BRepExtrema_DistShapeShape extss(occEdge, v);
|
||||
if (extss.IsDone()) {
|
||||
int count = extss.NbSolution();
|
||||
if (count != 0) {
|
||||
minDist = extss.Value();
|
||||
}
|
||||
}
|
||||
return minDist;
|
||||
}
|
||||
|
||||
//!find point on me nearest to p
|
||||
Base::Vector2D BaseGeom::nearPoint(Base::Vector2D p)
|
||||
{
|
||||
gp_Pnt pnt(p.fX,p.fY,0.0);
|
||||
Base::Vector2D result(0.0,0.0);
|
||||
TopoDS_Vertex v = BRepBuilderAPI_MakeVertex(pnt);
|
||||
BRepExtrema_DistShapeShape extss(occEdge, v);
|
||||
if (extss.IsDone()) {
|
||||
int count = extss.NbSolution();
|
||||
if (count != 0) {
|
||||
gp_Pnt p1;
|
||||
p1 = extss.PointOnShape1(1);
|
||||
result = Base::Vector2D(p1.X(),p1.Y());
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
//! Convert 1 OCC edge into 1 BaseGeom (static factory method)
|
||||
BaseGeom* BaseGeom::baseFactory(TopoDS_Edge edge)
|
||||
{
|
||||
|
@ -256,8 +289,8 @@ Circle::Circle(const TopoDS_Edge &e)
|
|||
|
||||
gp_Circ circ = c.Circle();
|
||||
const gp_Pnt& p = circ.Location();
|
||||
const gp_Ax2& p1 = circ.Position();
|
||||
const gp_Pnt& l = p1.Location();
|
||||
//const gp_Ax2& p1 = circ.Position();
|
||||
//const gp_Pnt& l = p1.Location();
|
||||
|
||||
radius = circ.Radius();
|
||||
center = Base::Vector2D(p.X(), p.Y());
|
||||
|
@ -311,17 +344,20 @@ bool AOC::isOnArc(Base::Vector3d p)
|
|||
|
||||
double AOC::distToArc(Base::Vector3d p)
|
||||
{
|
||||
double minDist = -1.0;
|
||||
gp_Pnt pnt(p.x,p.y,p.z);
|
||||
TopoDS_Vertex v = BRepBuilderAPI_MakeVertex(pnt);
|
||||
BRepExtrema_DistShapeShape extss(occEdge, v);
|
||||
if (extss.IsDone()) {
|
||||
int count = extss.NbSolution();
|
||||
if (count != 0) {
|
||||
minDist = extss.Value();
|
||||
}
|
||||
}
|
||||
return minDist;
|
||||
Base::Vector2D p2(p.x,p.y);
|
||||
double result = minDist(p2);
|
||||
return result;
|
||||
// double minDist = -1.0;
|
||||
// gp_Pnt pnt(p.x,p.y,p.z);
|
||||
// TopoDS_Vertex v = BRepBuilderAPI_MakeVertex(pnt);
|
||||
// BRepExtrema_DistShapeShape extss(occEdge, v);
|
||||
// if (extss.IsDone()) {
|
||||
// int count = extss.NbSolution();
|
||||
// if (count != 0) {
|
||||
// minDist = extss.Value();
|
||||
// }
|
||||
// }
|
||||
// return minDist;
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -76,6 +76,8 @@ class TechDrawExport BaseGeom
|
|||
std::vector<Base::Vector2D> findEndPoints();
|
||||
Base::Vector2D getStartPoint();
|
||||
Base::Vector2D getEndPoint();
|
||||
double minDist(Base::Vector2D p);
|
||||
Base::Vector2D nearPoint(Base::Vector2D p);
|
||||
static BaseGeom* baseFactory(TopoDS_Edge edge);
|
||||
};
|
||||
|
||||
|
|
|
@ -114,6 +114,7 @@ bool _checkPartFeature(Gui::Command* cmd);
|
|||
int _isValidSingleEdge(Gui::Command* cmd);
|
||||
bool _isValidVertexes(Gui::Command* cmd);
|
||||
int _isValidEdgeToEdge(Gui::Command* cmd);
|
||||
bool _isValidVertexToEdge(Gui::Command* cmd);
|
||||
|
||||
enum EdgeType{
|
||||
isInvalid,
|
||||
|
@ -218,6 +219,12 @@ void CmdTechDrawNewDimension::activated(int iMsg)
|
|||
default:
|
||||
break;
|
||||
}
|
||||
} else if (_isValidVertexToEdge(this)) {
|
||||
dimType = "Distance";
|
||||
objs.push_back(objFeat);
|
||||
objs.push_back(objFeat);
|
||||
subs.push_back(SubNames[0]);
|
||||
subs.push_back(SubNames[1]);
|
||||
} else {
|
||||
QMessageBox::warning(Gui::getMainWindow(), QObject::tr("Incorrect Selection"),
|
||||
QObject::tr("Can't make a Dimension from this selection"));
|
||||
|
@ -512,6 +519,11 @@ void CmdTechDrawNewLengthDimension::activated(int iMsg)
|
|||
objs.push_back(objFeat);
|
||||
subs.push_back(SubNames[0]);
|
||||
subs.push_back(SubNames[1]);
|
||||
} else if (_isValidVertexToEdge(this)) {
|
||||
objs.push_back(objFeat);
|
||||
objs.push_back(objFeat);
|
||||
subs.push_back(SubNames[0]);
|
||||
subs.push_back(SubNames[1]);
|
||||
} else {
|
||||
std::stringstream edgeMsg;
|
||||
edgeMsg << "Can't make a length Dimension from this selection (edge type: " << edgeType << ")";
|
||||
|
@ -608,6 +620,11 @@ void CmdTechDrawNewDistanceXDimension::activated(int iMsg)
|
|||
objs.push_back(objFeat);
|
||||
subs.push_back(SubNames[0]);
|
||||
subs.push_back(SubNames[1]);
|
||||
} else if (_isValidVertexToEdge(this)) {
|
||||
objs.push_back(objFeat);
|
||||
objs.push_back(objFeat);
|
||||
subs.push_back(SubNames[0]);
|
||||
subs.push_back(SubNames[1]);
|
||||
} else {
|
||||
std::stringstream edgeMsg;
|
||||
edgeMsg << "Can't make a horizontal Dimension from this selection (edge type: " << edgeType << ")";
|
||||
|
@ -705,6 +722,11 @@ void CmdTechDrawNewDistanceYDimension::activated(int iMsg)
|
|||
objs.push_back(objFeat);
|
||||
subs.push_back(SubNames[0]);
|
||||
subs.push_back(SubNames[1]);
|
||||
} else if (_isValidVertexToEdge(this)) {
|
||||
objs.push_back(objFeat);
|
||||
objs.push_back(objFeat);
|
||||
subs.push_back(SubNames[0]);
|
||||
subs.push_back(SubNames[1]);
|
||||
} else {
|
||||
std::stringstream edgeMsg;
|
||||
edgeMsg << "Can't make a vertical Dimension from this selection (edge type: " << edgeType << ")";
|
||||
|
@ -1063,3 +1085,39 @@ int _isValidEdgeToEdge(Gui::Command* cmd) {
|
|||
}
|
||||
return edgeType;
|
||||
}
|
||||
|
||||
//! verify that the Selection contains valid geometries for a Vertex to Edge Dimension
|
||||
bool _isValidVertexToEdge(Gui::Command* cmd) {
|
||||
bool result = false;
|
||||
std::vector<Gui::SelectionObject> selection = cmd->getSelection().getSelectionEx();
|
||||
TechDraw::DrawViewPart* objFeat0 = dynamic_cast<TechDraw::DrawViewPart *>(selection[0].getObject());
|
||||
//TechDraw::DrawViewPart* objFeat1 = dynamic_cast<TechDraw::DrawViewPart *>(selection[1].getObject());
|
||||
const std::vector<std::string> SubNames = selection[0].getSubNames();
|
||||
if(SubNames.size() == 2) { //there are 2
|
||||
int eId,vId;
|
||||
TechDrawGeometry::BaseGeom* e;
|
||||
TechDrawGeometry::Vertex* v;
|
||||
if (TechDraw::DrawUtil::getGeomTypeFromName(SubNames[0]) == "Edge" &&
|
||||
TechDraw::DrawUtil::getGeomTypeFromName(SubNames[1]) == "Vertex") {
|
||||
eId = TechDraw::DrawUtil::getIndexFromName(SubNames[0]);
|
||||
vId = TechDraw::DrawUtil::getIndexFromName(SubNames[1]);
|
||||
} else if (TechDraw::DrawUtil::getGeomTypeFromName(SubNames[1]) == "Edge" &&
|
||||
TechDraw::DrawUtil::getGeomTypeFromName(SubNames[0]) == "Vertex") {
|
||||
eId = TechDraw::DrawUtil::getIndexFromName(SubNames[1]);
|
||||
vId = TechDraw::DrawUtil::getIndexFromName(SubNames[0]);
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
e = objFeat0->getProjEdgeByIndex(eId);
|
||||
v = objFeat0->getProjVertexByIndex(vId);
|
||||
if ((!e) || (!v)) {
|
||||
Base::Console().Error("Logic Error: no geometry for GeoId: %d or GeoId: %d\n",eId,vId);
|
||||
return false;
|
||||
}
|
||||
if (e->geomType != TechDrawGeometry::GENERIC) { //only vertex-line for now.
|
||||
return false;
|
||||
}
|
||||
result = true;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
|
|
@ -147,8 +147,6 @@ QGIViewDimension::QGIViewDimension() :
|
|||
addToGroup(datumLabel);
|
||||
dimLines = new QGraphicsPathItem();
|
||||
addToGroup(dimLines);
|
||||
centerMark = new QGraphicsPathItem();
|
||||
addToGroup(centerMark);
|
||||
aHead1 = new QGIArrow();
|
||||
addToGroup(aHead1);
|
||||
aHead2 = new QGIArrow();
|
||||
|
@ -172,7 +170,6 @@ QGIViewDimension::QGIViewDimension() :
|
|||
this , SLOT (hover(bool)));
|
||||
|
||||
m_pen.setStyle(Qt::SolidLine);
|
||||
m_clPen.setColor(QColor(128,128,128)); // TODO: centre line colour preference?
|
||||
|
||||
toggleBorder(false);
|
||||
}
|
||||
|
@ -290,7 +287,6 @@ void QGIViewDimension::draw()
|
|||
}
|
||||
|
||||
m_pen.setWidthF(dim->LineWidth.getValue());
|
||||
m_clPen.setWidthF(m_pen.widthF() * 0.80); //magic number!!!!
|
||||
|
||||
// Crude method of determining state [TODO] improve
|
||||
if(isSelected()) {
|
||||
|
@ -394,6 +390,41 @@ void QGIViewDimension::draw()
|
|||
//TODO: Exception here seems drastic. Can we fail more gracefully?
|
||||
throw Base::Exception("FVD::draw -Invalid reference for dimension type (1)");
|
||||
}
|
||||
} else if(dim->References2D.getValues().size() == 2) {
|
||||
int vx,ex;
|
||||
TechDrawGeometry::BaseGeom* e;
|
||||
TechDrawGeometry::Vertex* v;
|
||||
if ((TechDraw::DrawUtil::getGeomTypeFromName(SubNames[0]) == "Edge") &&
|
||||
(TechDraw::DrawUtil::getGeomTypeFromName(SubNames[1]) == "Vertex")) {
|
||||
ex = TechDraw::DrawUtil::getIndexFromName(SubNames[0]);
|
||||
vx = TechDraw::DrawUtil::getIndexFromName(SubNames[1]);
|
||||
} else if ((TechDraw::DrawUtil::getGeomTypeFromName(SubNames[0]) == "Vertex") &&
|
||||
(TechDraw::DrawUtil::getGeomTypeFromName(SubNames[1]) == "Edge")) {
|
||||
ex = TechDraw::DrawUtil::getIndexFromName(SubNames[1]);
|
||||
vx = TechDraw::DrawUtil::getIndexFromName(SubNames[0]);
|
||||
} else {
|
||||
Base::Console().Log("INFO - qgivd::draw - vertexEdge dim is not vertexEdge!\n");
|
||||
return;
|
||||
}
|
||||
e = refObj->getProjEdgeByIndex(ex);
|
||||
v = refObj->getProjVertexByIndex(vx);
|
||||
if (!e || !v) {
|
||||
Base::Console().Log("INFO - qgivd::draw - no geom for projected edge: %d or %d of %d\n",
|
||||
ex,vx,refObj->getEdgeGeometry().size());
|
||||
return;
|
||||
}
|
||||
Base::Vector3d pnt(v->pnt.fX,v->pnt.fY, 0.0);
|
||||
Base::Vector3d edgeStart(e->getStartPoint().fX,e->getStartPoint().fY,0.0);
|
||||
Base::Vector3d edgeEnd(e->getEndPoint().fX,e->getEndPoint().fY,0.0);
|
||||
Base::Vector3d displace;
|
||||
displace.ProjectToLine(pnt - edgeStart, edgeEnd - edgeStart);
|
||||
Base::Vector3d ptOnLine = pnt + displace;
|
||||
|
||||
distStart = pnt;
|
||||
distEnd = ptOnLine;
|
||||
//need to figure out Distance? from slope of distEnd-distStart?
|
||||
} else {
|
||||
Base::Console().Message("TARFU - invalid references for Dimension!!");
|
||||
}
|
||||
|
||||
Base::Vector3d dir, norm; //direction/normal vectors of dimLine
|
||||
|
@ -709,28 +740,6 @@ void QGIViewDimension::draw()
|
|||
|
||||
dimLines->setPath(path);
|
||||
|
||||
// Add or remove centre lines
|
||||
QPainterPath clpath;
|
||||
|
||||
if(dim->CentreLines.getValue()) {
|
||||
// Add centre lines to the circle
|
||||
|
||||
double clDist = margin; // Centre Line Size
|
||||
if( margin / radius > 0.2) {
|
||||
// Tolerance if centre line is greater than 0.3x radius then set to limit
|
||||
clDist = radius * 0.2;
|
||||
}
|
||||
// Vertical Line
|
||||
clpath.moveTo(centre.x, centre.y + clDist);
|
||||
clpath.lineTo(centre.x, centre.y - clDist);
|
||||
|
||||
// Vertical Line
|
||||
clpath.moveTo(centre.x - clDist, centre.y);
|
||||
clpath.lineTo(centre.x + clDist, centre.y);
|
||||
}
|
||||
|
||||
centerMark->setPath(clpath);
|
||||
|
||||
aHead1->draw();
|
||||
aHead2->flip(true);
|
||||
aHead2->draw();
|
||||
|
@ -886,24 +895,6 @@ void QGIViewDimension::draw()
|
|||
|
||||
dimLines->setPath(dLinePath);
|
||||
|
||||
// Add or remove centre lines (wf - this is centermark, not centerlines)
|
||||
QPainterPath clpath;
|
||||
if(dim->CentreLines.getValue()) {
|
||||
// Add centre lines to the circle
|
||||
double clDist = margin; // Centre Line Size
|
||||
if( margin / radius > 0.2) {
|
||||
// Tolerance if centre line is greater than 0.3x radius then set to limit
|
||||
clDist = radius * 0.2;
|
||||
}
|
||||
// Vertical Line
|
||||
clpath.moveTo(curveCenter.x, curveCenter.y + clDist);
|
||||
clpath.lineTo(curveCenter.x, curveCenter.y - clDist);
|
||||
// Horizontal Line
|
||||
clpath.moveTo(curveCenter.x - clDist, curveCenter.y);
|
||||
clpath.lineTo(curveCenter.x + clDist, curveCenter.y);
|
||||
}
|
||||
centerMark->setPath(clpath);
|
||||
|
||||
aHead1->draw();
|
||||
|
||||
Base::Vector3d ar1Pos = pointOnCurve;
|
||||
|
@ -1181,7 +1172,6 @@ void QGIViewDimension::paint ( QPainter * painter, const QStyleOptionGraphicsIte
|
|||
QPaintDevice* hw = painter->device();
|
||||
QSvgGenerator* svg = dynamic_cast<QSvgGenerator*>(hw);
|
||||
double saveWidth = m_pen.widthF();
|
||||
double saveClWidth = m_clPen.widthF();
|
||||
if (svg) {
|
||||
setSvgPens();
|
||||
} else {
|
||||
|
@ -1189,7 +1179,6 @@ void QGIViewDimension::paint ( QPainter * painter, const QStyleOptionGraphicsIte
|
|||
}
|
||||
QGIView::paint (painter, &myOption, widget);
|
||||
m_pen.setWidthF(saveWidth);
|
||||
m_clPen.setWidthF(saveClWidth);
|
||||
}
|
||||
|
||||
void QGIViewDimension::setSvgPens(void)
|
||||
|
@ -1199,8 +1188,6 @@ void QGIViewDimension::setSvgPens(void)
|
|||
dimLines->setPen(m_pen);
|
||||
aHead1->setPen(m_pen);
|
||||
aHead2->setPen(m_pen);
|
||||
m_clPen.setWidthF(m_clPen.widthF()/svgLineFactor);
|
||||
centerMark->setPen(m_clPen);
|
||||
}
|
||||
|
||||
void QGIViewDimension::setPens(void)
|
||||
|
@ -1208,7 +1195,6 @@ void QGIViewDimension::setPens(void)
|
|||
dimLines->setPen(m_pen);
|
||||
aHead1->setPen(m_pen);
|
||||
aHead2->setPen(m_pen);
|
||||
centerMark->setPen(m_clPen);
|
||||
}
|
||||
|
||||
#include <Mod/TechDraw/Gui/moc_QGIViewDimension.cpp>
|
||||
|
|
|
@ -114,11 +114,8 @@ protected:
|
|||
bool hasHover;
|
||||
QGIDatumLabel* datumLabel; //dimension text
|
||||
QGraphicsPathItem* dimLines; //dimension lines + extension lines
|
||||
QGraphicsPathItem* centerMark;
|
||||
QGIArrow* aHead1;
|
||||
QGIArrow* aHead2;
|
||||
//QPen m_pen;
|
||||
QPen m_clPen;
|
||||
};
|
||||
|
||||
} // namespace MDIViewPageGui
|
||||
|
|
Loading…
Reference in New Issue
Block a user