Merge pull request #19411 from benj5378/enums2
TechDraw: hard type enums, part 2
This commit is contained in:
@@ -34,14 +34,16 @@ namespace TechDraw
|
||||
{
|
||||
|
||||
//common definitions for line ends / arrows
|
||||
enum ArrowType { FILLED_ARROW = 0,
|
||||
OPEN_ARROW,
|
||||
TICK,
|
||||
DOT,
|
||||
OPEN_CIRCLE,
|
||||
FORK,
|
||||
FILLED_TRIANGLE,
|
||||
NONE};
|
||||
enum class ArrowType : int {
|
||||
FILLED_ARROW = 0,
|
||||
OPEN_ARROW,
|
||||
TICK,
|
||||
DOT,
|
||||
OPEN_CIRCLE,
|
||||
FORK,
|
||||
FILLED_TRIANGLE,
|
||||
NONE
|
||||
};
|
||||
|
||||
class TechDrawExport ArrowPropEnum {
|
||||
Q_DECLARE_TR_FUNCTIONS(TechDraw::ArrowPropEnum)
|
||||
|
||||
@@ -33,14 +33,16 @@
|
||||
namespace TechDraw
|
||||
{
|
||||
|
||||
enum BalloonType { Circular = 0,
|
||||
None,
|
||||
Triangle,
|
||||
Inspection,
|
||||
Hexagon,
|
||||
Square,
|
||||
Rectangle,
|
||||
Line};
|
||||
enum class BalloonType {
|
||||
Circular = 0,
|
||||
None,
|
||||
Triangle,
|
||||
Inspection,
|
||||
Hexagon,
|
||||
Square,
|
||||
Rectangle,
|
||||
Line
|
||||
};
|
||||
|
||||
class TechDrawExport BalloonPropEnum {
|
||||
Q_DECLARE_TR_FUNCTIONS(TechDraw::BalloonPropEnum)
|
||||
|
||||
@@ -561,12 +561,11 @@ int DrawProjGroup::purgeProjections()
|
||||
|
||||
std::pair<Base::Vector3d, Base::Vector3d> DrawProjGroup::getDirsFromFront(DrawProjGroupItem* view)
|
||||
{
|
||||
std::pair<Base::Vector3d, Base::Vector3d> result;
|
||||
std::string viewType = view->Type.getValueAsString();
|
||||
ProjDirection viewType = static_cast<ProjDirection>(view->Type.getValue());
|
||||
return getDirsFromFront(viewType);
|
||||
}
|
||||
|
||||
std::pair<Base::Vector3d, Base::Vector3d> DrawProjGroup::getDirsFromFront(std::string viewType)
|
||||
std::pair<Base::Vector3d, Base::Vector3d> DrawProjGroup::getDirsFromFront(ProjDirection viewType)
|
||||
{
|
||||
// Base::Console().Message("DPG::getDirsFromFront(%s)\n", viewType.c_str());
|
||||
std::pair<Base::Vector3d, Base::Vector3d> result;
|
||||
@@ -1106,77 +1105,26 @@ void DrawProjGroup::updateSecondaryDirs()
|
||||
Base::Vector3d anchDir = anchor->Direction.getValue();
|
||||
Base::Vector3d anchRot = anchor->getXDirection();
|
||||
|
||||
std::map<std::string, std::pair<Base::Vector3d, Base::Vector3d>> saveVals;
|
||||
std::string key;
|
||||
std::map<ProjDirection, std::pair<Base::Vector3d, Base::Vector3d>> saveVals;
|
||||
std::pair<Base::Vector3d, Base::Vector3d> data;
|
||||
for (auto& docObj : Views.getValues()) {
|
||||
std::pair<Base::Vector3d, Base::Vector3d> newDirs;
|
||||
std::string pic;
|
||||
DrawProjGroupItem* v = static_cast<DrawProjGroupItem*>(docObj);
|
||||
ProjItemType t = static_cast<ProjItemType>(v->Type.getValue());
|
||||
switch (t) {
|
||||
case Front:
|
||||
data.first = anchDir;
|
||||
data.second = anchRot;
|
||||
key = "Front";
|
||||
saveVals[key] = data;
|
||||
break;
|
||||
case Rear:
|
||||
key = "Rear";
|
||||
newDirs = getDirsFromFront(key);
|
||||
saveVals[key] = newDirs;
|
||||
break;
|
||||
case Left:
|
||||
key = "Left";
|
||||
newDirs = getDirsFromFront(key);
|
||||
saveVals[key] = newDirs;
|
||||
break;
|
||||
case Right:
|
||||
key = "Right";
|
||||
newDirs = getDirsFromFront(key);
|
||||
saveVals[key] = newDirs;
|
||||
break;
|
||||
case Top:
|
||||
key = "Top";
|
||||
newDirs = getDirsFromFront(key);
|
||||
saveVals[key] = newDirs;
|
||||
break;
|
||||
case Bottom:
|
||||
key = "Bottom";
|
||||
newDirs = getDirsFromFront(key);
|
||||
saveVals[key] = newDirs;
|
||||
break;
|
||||
case FrontTopLeft:
|
||||
key = "FrontTopLeft";
|
||||
newDirs = getDirsFromFront(key);
|
||||
saveVals[key] = newDirs;
|
||||
break;
|
||||
case FrontTopRight:
|
||||
key = "FrontTopRight";
|
||||
newDirs = getDirsFromFront(key);
|
||||
saveVals[key] = newDirs;
|
||||
break;
|
||||
case FrontBottomLeft:
|
||||
key = "FrontBottomLeft";
|
||||
newDirs = getDirsFromFront(key);
|
||||
saveVals[key] = newDirs;
|
||||
break;
|
||||
case FrontBottomRight:
|
||||
key = "FrontBottomRight";
|
||||
newDirs = getDirsFromFront(key);
|
||||
saveVals[key] = newDirs;
|
||||
break;
|
||||
default: {
|
||||
//TARFU invalid secondary type
|
||||
Base::Console().Message(
|
||||
"ERROR - DPG::updateSecondaryDirs - invalid projection type\n");
|
||||
}
|
||||
ProjDirection t = static_cast<ProjDirection>(v->Type.getValue());
|
||||
|
||||
if (t == ProjDirection::Front) {
|
||||
data.first = anchDir;
|
||||
data.second = anchRot;
|
||||
saveVals[ProjDirection::Front] = data;
|
||||
}
|
||||
else {
|
||||
std::pair<Base::Vector3d, Base::Vector3d> newDirs = getDirsFromFront(t);
|
||||
saveVals[t] = newDirs;
|
||||
}
|
||||
}
|
||||
|
||||
for (auto& docObj : Views.getValues()) {
|
||||
DrawProjGroupItem* v = static_cast<DrawProjGroupItem*>(docObj);
|
||||
std::string type = v->Type.getValueAsString();
|
||||
ProjDirection type = static_cast<ProjDirection>(v->Type.getValue());
|
||||
data = saveVals[type];
|
||||
v->Direction.setValue(data.first);
|
||||
v->Direction.purgeTouched();
|
||||
@@ -1186,31 +1134,20 @@ void DrawProjGroup::updateSecondaryDirs()
|
||||
recomputeChildren();
|
||||
}
|
||||
|
||||
void DrawProjGroup::rotate(const std::string& rotationdirection)
|
||||
void DrawProjGroup::rotate(const RotationMotion& motion)
|
||||
{
|
||||
std::pair<Base::Vector3d, Base::Vector3d> newDirs;
|
||||
if (rotationdirection == "Right")
|
||||
newDirs = getDirsFromFront("Left");// Front -> Right -> Rear -> Left -> Front
|
||||
else if (rotationdirection == "Left")
|
||||
newDirs = getDirsFromFront("Right");// Front -> Left -> Rear -> Right -> Front
|
||||
else if (rotationdirection == "Up")
|
||||
newDirs = getDirsFromFront("Bottom");// Front -> Top -> Rear -> Bottom -> Front
|
||||
else if (rotationdirection == "Down")
|
||||
newDirs = getDirsFromFront("Top");// Front -> Bottom -> Rear -> Top -> Front
|
||||
|
||||
DrawProjGroupItem* anchor = getAnchor();
|
||||
anchor->Direction.setValue(newDirs.first);
|
||||
anchor->XDirection.setValue(newDirs.second);
|
||||
|
||||
getAnchor()->rotate(motion);
|
||||
updateSecondaryDirs();
|
||||
}
|
||||
|
||||
void DrawProjGroup::spin(const std::string& spindirection)
|
||||
// TODO: should these functions identical to those
|
||||
// in DrawViewPart be moved to DrawView?
|
||||
void DrawProjGroup::spin(const SpinDirection& spindirection)
|
||||
{
|
||||
double angle;
|
||||
if (spindirection == "CW")
|
||||
if (spindirection == SpinDirection::CW)
|
||||
angle = M_PI / 2.0;// Top -> Right -> Bottom -> Left -> Top
|
||||
if (spindirection == "CCW")
|
||||
if (spindirection == SpinDirection::CCW)
|
||||
angle = -M_PI / 2.0;// Top -> Left -> Bottom -> Right -> Top
|
||||
|
||||
spin(angle);
|
||||
|
||||
@@ -43,6 +43,9 @@ namespace TechDraw
|
||||
const int MAXPROJECTIONCOUNT = 10;
|
||||
|
||||
class DrawProjGroupItem;
|
||||
enum class ProjDirection : int;
|
||||
enum class SpinDirection : int;
|
||||
enum class RotationMotion : int;
|
||||
|
||||
/**
|
||||
* Class super-container for managing a collection of DrawProjGroupItem
|
||||
@@ -123,12 +126,12 @@ public:
|
||||
Base::Vector3d getAnchorDirection();
|
||||
TechDraw::DrawProjGroupItem* getAnchor();
|
||||
std::pair<Base::Vector3d, Base::Vector3d> getDirsFromFront(DrawProjGroupItem* view);
|
||||
std::pair<Base::Vector3d, Base::Vector3d> getDirsFromFront(std::string viewType);
|
||||
std::pair<Base::Vector3d, Base::Vector3d> getDirsFromFront(TechDraw::ProjDirection viewType);
|
||||
|
||||
void updateSecondaryDirs();
|
||||
|
||||
void rotate(const std::string &rotationdirection);
|
||||
void spin(const std::string &spindirection);
|
||||
void rotate(const TechDraw::RotationMotion& motion);
|
||||
void spin(const TechDraw::SpinDirection& spindirection);
|
||||
void spin(double angle);
|
||||
|
||||
void dumpISO(const char * title);
|
||||
|
||||
@@ -35,17 +35,6 @@
|
||||
namespace TechDraw
|
||||
{
|
||||
|
||||
enum ProjItemType{ Front,
|
||||
Left,
|
||||
Right,
|
||||
Rear,
|
||||
Top,
|
||||
Bottom,
|
||||
FrontTopLeft,
|
||||
FrontTopRight,
|
||||
FrontBottomLeft,
|
||||
FrontBottomRight };
|
||||
|
||||
class DrawProjGroup;
|
||||
|
||||
class TechDrawExport DrawProjGroupItem : public TechDraw::DrawViewPart
|
||||
|
||||
@@ -70,7 +70,7 @@ DrawViewBalloon::DrawViewBalloon()
|
||||
ADD_PROPERTY_TYPE(OriginY, (0), "", (App::PropertyType)(App::Prop_None), "Balloon origin y");
|
||||
|
||||
EndType.setEnums(ArrowPropEnum::ArrowTypeEnums);
|
||||
ADD_PROPERTY_TYPE(EndType, (Preferences::balloonArrow()), "", (App::PropertyType)(App::Prop_None),
|
||||
ADD_PROPERTY_TYPE(EndType, (static_cast<int>(Preferences::balloonArrow())), "", (App::PropertyType)(App::Prop_None),
|
||||
"End symbol for the balloon line");
|
||||
|
||||
ADD_PROPERTY_TYPE(EndTypeScale, (1.0), "", (App::PropertyType)(App::Prop_None),
|
||||
|
||||
@@ -51,7 +51,7 @@ public:
|
||||
|
||||
App::DocumentObjectExecReturn *execute() override;
|
||||
|
||||
int getRefType() const override { return extent; }
|
||||
RefType getRefType() const override { return RefType::extent; }
|
||||
|
||||
PyObject *getPyObject() override;
|
||||
|
||||
|
||||
@@ -82,6 +82,7 @@
|
||||
using namespace TechDraw;
|
||||
using namespace Part;
|
||||
using DU = DrawUtil;
|
||||
using RefType = DrawViewDimension::RefType;
|
||||
|
||||
//===========================================================================
|
||||
// DrawViewDimension
|
||||
@@ -490,16 +491,16 @@ App::DocumentObjectExecReturn* DrawViewDimension::execute()
|
||||
ReferenceVector references = getEffectiveReferences();
|
||||
|
||||
if (Type.isValue("Distance") || Type.isValue("DistanceX") || Type.isValue("DistanceY")) {
|
||||
if (getRefType() == oneEdge) {
|
||||
if (getRefType() == RefType::oneEdge) {
|
||||
m_linearPoints = getPointsOneEdge(references);
|
||||
}
|
||||
else if (getRefType() == twoEdge) {
|
||||
else if (getRefType() == RefType::twoEdge) {
|
||||
m_linearPoints = getPointsTwoEdges(references);
|
||||
}
|
||||
else if (getRefType() == twoVertex) {
|
||||
else if (getRefType() == RefType::twoVertex) {
|
||||
m_linearPoints = getPointsTwoVerts(references);
|
||||
}
|
||||
else if (getRefType() == vertexEdge) {
|
||||
else if (getRefType() == RefType::vertexEdge) {
|
||||
m_linearPoints = getPointsEdgeVert(references);
|
||||
}
|
||||
m_hasGeometry = true;
|
||||
@@ -510,21 +511,21 @@ App::DocumentObjectExecReturn* DrawViewDimension::execute()
|
||||
m_hasGeometry = true;
|
||||
}
|
||||
else if (Type.isValue("Angle")) {
|
||||
if (getRefType() != twoEdge) {
|
||||
if (getRefType() != RefType::twoEdge) {
|
||||
throw Base::RuntimeError("Angle dimension has non-edge references");
|
||||
}
|
||||
m_anglePoints = getAnglePointsTwoEdges(references);
|
||||
m_hasGeometry = true;
|
||||
}
|
||||
else if (Type.isValue("Angle3Pt")) {
|
||||
if (getRefType() != threeVertex) {
|
||||
if (getRefType() != RefType::threeVertex) {
|
||||
throw Base::RuntimeError("3 point angle dimension has non-vertex references");
|
||||
}
|
||||
m_anglePoints = getAnglePointsThreeVerts(references);
|
||||
m_hasGeometry = true;
|
||||
}
|
||||
else if (Type.isValue("Area")) {
|
||||
if (getRefType() != oneFace) {
|
||||
if (getRefType() != RefType::oneFace) {
|
||||
throw Base::RuntimeError("area dimension has non-face references");
|
||||
}
|
||||
m_areaPoint = getAreaParameters(references);
|
||||
@@ -1512,7 +1513,7 @@ ReferenceVector DrawViewDimension::getEffectiveReferences() const
|
||||
|
||||
|
||||
// what configuration of references do we have - Vertex-Vertex, Edge-Vertex, Edge, ...
|
||||
int DrawViewDimension::getRefType() const
|
||||
RefType DrawViewDimension::getRefType() const
|
||||
{
|
||||
if (isExtentDim()) {
|
||||
return RefType::extent;
|
||||
@@ -1534,7 +1535,7 @@ int DrawViewDimension::getRefType() const
|
||||
// something went wrong, there were no subNames.
|
||||
Base::Console().Message("DVD::getRefType - %s - there are no subNames.\n",
|
||||
getNameInDocument());
|
||||
return 0;
|
||||
return RefType::invalidRef;
|
||||
}
|
||||
|
||||
return getRefTypeSubElements(subNames);
|
||||
@@ -1542,9 +1543,9 @@ int DrawViewDimension::getRefType() const
|
||||
|
||||
// TODO: Gui/DimensionValidators.cpp has almost the same code
|
||||
// decide what the reference configuration is by examining the names of the sub elements
|
||||
int DrawViewDimension::getRefTypeSubElements(const std::vector<std::string>& subElements)
|
||||
RefType DrawViewDimension::getRefTypeSubElements(const std::vector<std::string>& subElements)
|
||||
{
|
||||
int refType{invalidRef};
|
||||
RefType refType{RefType::invalidRef};
|
||||
int refEdges{0};
|
||||
int refVertices{0};
|
||||
int refFaces{0};
|
||||
@@ -1562,22 +1563,22 @@ int DrawViewDimension::getRefTypeSubElements(const std::vector<std::string>& sub
|
||||
}
|
||||
|
||||
if (refEdges == 0 && refVertices == 2 && refFaces == 0) {
|
||||
refType = twoVertex;
|
||||
refType = RefType::twoVertex;
|
||||
}
|
||||
if (refEdges == 0 && refVertices == 3 && refFaces == 0) {
|
||||
refType = threeVertex;
|
||||
refType = RefType::threeVertex;
|
||||
}
|
||||
if (refEdges == 1 && refVertices == 0 && refFaces == 0) {
|
||||
refType = oneEdge;
|
||||
refType = RefType::oneEdge;
|
||||
}
|
||||
if (refEdges == 1 && refVertices == 1 && refFaces == 0) {
|
||||
refType = vertexEdge;
|
||||
refType = RefType::vertexEdge;
|
||||
}
|
||||
if (refEdges == 2 && refVertices == 0 && refFaces == 0) {
|
||||
refType = twoEdge;
|
||||
refType = RefType::twoEdge;
|
||||
}
|
||||
if (refEdges == 0 && refVertices == 0 && refFaces == 1) {
|
||||
refType = oneFace;
|
||||
refType = RefType::oneFace;
|
||||
}
|
||||
|
||||
return refType;
|
||||
@@ -1830,14 +1831,14 @@ bool DrawViewDimension::validateReferenceForm() const
|
||||
}
|
||||
|
||||
if (Type.isValue("Distance") || Type.isValue("DistanceX") || Type.isValue("DistanceY")) {
|
||||
if (getRefType() == oneEdge) {
|
||||
if (getRefType() == RefType::oneEdge) {
|
||||
if (references.size() != 1) {
|
||||
return false;
|
||||
}
|
||||
std::string subGeom = DrawUtil::getGeomTypeFromName(references.front().getSubName());
|
||||
return subGeom == "Edge";
|
||||
}
|
||||
if (getRefType() == twoEdge) {
|
||||
if (getRefType() == RefType::twoEdge) {
|
||||
if (references.size() != 2) {
|
||||
return false;
|
||||
}
|
||||
@@ -1846,7 +1847,7 @@ bool DrawViewDimension::validateReferenceForm() const
|
||||
return (subGeom0 == "Edge" && subGeom1 == "Edge");
|
||||
}
|
||||
|
||||
if (getRefType() == twoVertex) {
|
||||
if (getRefType() == RefType::twoVertex) {
|
||||
if (references.size() != 2) {
|
||||
return false;
|
||||
}
|
||||
@@ -1855,7 +1856,7 @@ bool DrawViewDimension::validateReferenceForm() const
|
||||
return (subGeom0 == "Vertex" && subGeom1 == "Vertex");
|
||||
}
|
||||
|
||||
if (getRefType() == vertexEdge) {
|
||||
if (getRefType() == RefType::vertexEdge) {
|
||||
if (references.size() != 2) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -99,7 +99,7 @@ public:
|
||||
|
||||
App::PropertyBool ShowUnits;
|
||||
|
||||
enum RefType
|
||||
enum class RefType
|
||||
{
|
||||
invalidRef,
|
||||
oneEdge,
|
||||
@@ -145,8 +145,8 @@ public:
|
||||
{
|
||||
return {0, 0, 1, 1};
|
||||
} // pretend dimensions always fit!
|
||||
virtual int getRefType() const; // Vertex-Vertex, Edge, Edge-Edge
|
||||
static int
|
||||
virtual RefType getRefType() const; // Vertex-Vertex, Edge, Edge-Edge
|
||||
static RefType
|
||||
getRefTypeSubElements(const std::vector<std::string>&); // Vertex-Vertex, Edge, Edge-Edge
|
||||
|
||||
void setReferences2d(const ReferenceVector& refs);
|
||||
|
||||
@@ -1276,29 +1276,29 @@ Base::Vector3d DrawViewPart::getXDirection() const
|
||||
}
|
||||
|
||||
|
||||
void DrawViewPart::rotate(const std::string& rotationdirection)
|
||||
void DrawViewPart::rotate(const RotationMotion& motion)
|
||||
{
|
||||
std::pair<Base::Vector3d, Base::Vector3d> newDirs;
|
||||
if (rotationdirection == "Right")
|
||||
newDirs = getDirsFromFront("Left");// Front -> Right -> Rear -> Left -> Front
|
||||
else if (rotationdirection == "Left")
|
||||
newDirs = getDirsFromFront("Right");// Front -> Left -> Rear -> Right -> Front
|
||||
else if (rotationdirection == "Up")
|
||||
newDirs = getDirsFromFront("Bottom");// Front -> Top -> Rear -> Bottom -> Front
|
||||
else if (rotationdirection == "Down")
|
||||
newDirs = getDirsFromFront("Top");// Front -> Bottom -> Rear -> Top -> Front
|
||||
if (motion == RotationMotion::Right)
|
||||
newDirs = getDirsFromFront(ProjDirection::Left);// Front -> Right -> Rear -> Left -> Front
|
||||
else if (motion == RotationMotion::Left)
|
||||
newDirs = getDirsFromFront(ProjDirection::Right);// Front -> Left -> Rear -> Right -> Front
|
||||
else if (motion == RotationMotion::Up)
|
||||
newDirs = getDirsFromFront(ProjDirection::Bottom);// Front -> Top -> Rear -> Bottom -> Front
|
||||
else if (motion == RotationMotion::Down)
|
||||
newDirs = getDirsFromFront(ProjDirection::Top);// Front -> Bottom -> Rear -> Top -> Front
|
||||
|
||||
Direction.setValue(newDirs.first);
|
||||
XDirection.setValue(newDirs.second);
|
||||
recompute();
|
||||
}
|
||||
|
||||
void DrawViewPart::spin(const std::string& spindirection)
|
||||
void DrawViewPart::spin(const SpinDirection& spindirection)
|
||||
{
|
||||
double angle;
|
||||
if (spindirection == "CW")
|
||||
if (spindirection == SpinDirection::CW)
|
||||
angle = M_PI / 2.0;// Top -> Right -> Bottom -> Left -> Top
|
||||
if (spindirection == "CCW")
|
||||
if (spindirection == SpinDirection::CCW)
|
||||
angle = -M_PI / 2.0;// Top -> Left -> Bottom -> Right -> Top
|
||||
|
||||
spin(angle);
|
||||
@@ -1315,7 +1315,7 @@ void DrawViewPart::spin(double angle)
|
||||
recompute();
|
||||
}
|
||||
|
||||
std::pair<Base::Vector3d, Base::Vector3d> DrawViewPart::getDirsFromFront(std::string viewType)
|
||||
std::pair<Base::Vector3d, Base::Vector3d> DrawViewPart::getDirsFromFront(ProjDirection viewType)
|
||||
{
|
||||
// Base::Console().Message("DVP::getDirsFromFront(%s)\n", viewType.c_str());
|
||||
std::pair<Base::Vector3d, Base::Vector3d> result;
|
||||
@@ -1335,60 +1335,52 @@ std::pair<Base::Vector3d, Base::Vector3d> DrawViewPart::getDirsFromFront(std::st
|
||||
|
||||
double angle = M_PI / 2.0;//90*
|
||||
|
||||
if (viewType == "Right") {
|
||||
if (viewType == ProjDirection::Right) {
|
||||
newCS = anchorCS.Rotated(gUpAxis, angle);
|
||||
projDir = dir2vec(newCS.Direction());
|
||||
rotVec = dir2vec(newCS.XDirection());
|
||||
}
|
||||
else if (viewType == "Left") {
|
||||
else if (viewType == ProjDirection::Left) {
|
||||
newCS = anchorCS.Rotated(gUpAxis, -angle);
|
||||
projDir = dir2vec(newCS.Direction());
|
||||
rotVec = dir2vec(newCS.XDirection());
|
||||
}
|
||||
else if (viewType == "Top") {
|
||||
else if (viewType == ProjDirection::Top) {
|
||||
projDir = dir2vec(gYDir);
|
||||
rotVec = dir2vec(gXDir);
|
||||
}
|
||||
else if (viewType == "Bottom") {
|
||||
else if (viewType == ProjDirection::Bottom) {
|
||||
projDir = dir2vec(gYDir.Reversed());
|
||||
rotVec = dir2vec(gXDir);
|
||||
}
|
||||
else if (viewType == "Rear") {
|
||||
else if (viewType == ProjDirection::Rear) {
|
||||
projDir = dir2vec(gDir.Reversed());
|
||||
rotVec = dir2vec(gXDir.Reversed());
|
||||
}
|
||||
else if (viewType == "FrontTopLeft") {
|
||||
else if (viewType == ProjDirection::FrontTopLeft) {
|
||||
gp_Dir newDir = gp_Dir(gp_Vec(gDir) - gp_Vec(gXDir) + gp_Vec(gYDir));
|
||||
projDir = dir2vec(newDir);
|
||||
gp_Dir newXDir = gp_Dir(gp_Vec(gXDir) + gp_Vec(gDir));
|
||||
rotVec = dir2vec(newXDir);
|
||||
}
|
||||
else if (viewType == "FrontTopRight") {
|
||||
else if (viewType == ProjDirection::FrontTopRight) {
|
||||
gp_Dir newDir = gp_Dir(gp_Vec(gDir) + gp_Vec(gXDir) + gp_Vec(gYDir));
|
||||
projDir = dir2vec(newDir);
|
||||
gp_Dir newXDir = gp_Dir(gp_Vec(gXDir) - gp_Vec(gDir));
|
||||
rotVec = dir2vec(newXDir);
|
||||
}
|
||||
else if (viewType == "FrontBottomLeft") {
|
||||
else if (viewType == ProjDirection::FrontBottomLeft) {
|
||||
gp_Dir newDir = gp_Dir(gp_Vec(gDir) - gp_Vec(gXDir) - gp_Vec(gYDir));
|
||||
projDir = dir2vec(newDir);
|
||||
gp_Dir newXDir = gp_Dir(gp_Vec(gXDir) + gp_Vec(gDir));
|
||||
rotVec = dir2vec(newXDir);
|
||||
}
|
||||
else if (viewType == "FrontBottomRight") {
|
||||
else if (viewType == ProjDirection::FrontBottomRight) {
|
||||
gp_Dir newDir = gp_Dir(gp_Vec(gDir) + gp_Vec(gXDir) - gp_Vec(gYDir));
|
||||
projDir = dir2vec(newDir);
|
||||
gp_Dir newXDir = gp_Dir(gp_Vec(gXDir) - gp_Vec(gDir));
|
||||
rotVec = dir2vec(newXDir);
|
||||
}
|
||||
else {
|
||||
// not one of the standard view directions, so complain and use the values for "Front"
|
||||
Base::Console().Error("DrawViewPart - %s unknown projection: %s\n", getNameInDocument(),
|
||||
viewType.c_str());
|
||||
Base::Vector3d dirAnch = Direction.getValue();
|
||||
Base::Vector3d rotAnch = getXDirection();
|
||||
return std::make_pair(dirAnch, rotAnch);
|
||||
}
|
||||
|
||||
return std::make_pair(projDir, rotVec);
|
||||
}
|
||||
|
||||
@@ -77,9 +77,34 @@ class GeomFormat;
|
||||
|
||||
namespace TechDraw
|
||||
{
|
||||
|
||||
class DrawViewSection;
|
||||
|
||||
|
||||
enum class ProjDirection {
|
||||
Front,
|
||||
Left,
|
||||
Right,
|
||||
Rear,
|
||||
Top,
|
||||
Bottom,
|
||||
FrontTopLeft,
|
||||
FrontTopRight,
|
||||
FrontBottomLeft,
|
||||
FrontBottomRight
|
||||
};
|
||||
|
||||
enum class RotationMotion {
|
||||
Left,
|
||||
Right,
|
||||
Up,
|
||||
Down
|
||||
};
|
||||
|
||||
enum class SpinDirection {
|
||||
CW,
|
||||
CCW
|
||||
};
|
||||
|
||||
class TechDrawExport DrawViewPart: public DrawView, public CosmeticExtension
|
||||
{
|
||||
PROPERTY_HEADER_WITH_EXTENSIONS(TechDraw::DrawViewPart);
|
||||
@@ -172,10 +197,10 @@ public:
|
||||
virtual Base::Vector3d getLegacyX(const Base::Vector3d& pt, const Base::Vector3d& axis,
|
||||
const bool flip = true) const;
|
||||
|
||||
void rotate(const std::string& rotationdirection);
|
||||
void spin(const std::string& spindirection);
|
||||
void rotate(const RotationMotion& motion);
|
||||
void spin(const SpinDirection& spindirection);
|
||||
void spin(double val);
|
||||
std::pair<Base::Vector3d, Base::Vector3d> getDirsFromFront(std::string viewType);
|
||||
std::pair<Base::Vector3d, Base::Vector3d> getDirsFromFront(ProjDirection viewType);
|
||||
Base::Vector3d dir2vec(gp_Dir d);
|
||||
|
||||
gp_Ax2 localVectorToCS(const Base::Vector3d localUnit) const;
|
||||
|
||||
@@ -155,7 +155,7 @@ Base::Vector3d LandmarkDimension::projectPoint(const Base::Vector3d& pt, DrawVie
|
||||
return DrawUtil::invertY(result);
|
||||
}
|
||||
|
||||
int LandmarkDimension::getRefType() const
|
||||
DrawViewDimension::RefType LandmarkDimension::getRefType() const
|
||||
{
|
||||
//TODO: need changes here when other reference dim types added
|
||||
return DrawViewDimension::RefType::twoVertex;
|
||||
|
||||
@@ -57,7 +57,7 @@ public:
|
||||
return "TechDrawGui::ViewProviderDimension"; }
|
||||
|
||||
DrawViewPart* getViewPart() const override;
|
||||
int getRefType() const override;
|
||||
RefType getRefType() const override;
|
||||
|
||||
gp_Ax2 getProjAxis() const;
|
||||
|
||||
|
||||
@@ -176,9 +176,10 @@ int Preferences::lineGroup()
|
||||
return getPreferenceGroup("Decorations")->GetInt("LineGroup", 3); // FC 0.70mm
|
||||
}
|
||||
|
||||
int Preferences::balloonArrow()
|
||||
ArrowType Preferences::balloonArrow()
|
||||
{
|
||||
return getPreferenceGroup("Decorations")->GetInt("BalloonArrow", 0);
|
||||
int temp = getPreferenceGroup("Decorations")->GetInt("BalloonArrow", 0);
|
||||
return static_cast<ArrowType>(temp);
|
||||
}
|
||||
|
||||
double Preferences::balloonKinkLength()
|
||||
|
||||
@@ -41,6 +41,7 @@ class Color;
|
||||
|
||||
namespace TechDraw
|
||||
{
|
||||
enum class ArrowType : int;
|
||||
|
||||
//getters for parameters used in multiple places.
|
||||
class TechDrawExport Preferences
|
||||
@@ -70,7 +71,7 @@ public:
|
||||
static double groupSpaceX();
|
||||
static double groupSpaceY();
|
||||
|
||||
static int balloonArrow();
|
||||
static ArrowType balloonArrow();
|
||||
static double balloonKinkLength();
|
||||
static int balloonShape();
|
||||
|
||||
|
||||
@@ -79,6 +79,7 @@ using namespace TechDrawGui;
|
||||
using namespace TechDraw;
|
||||
using namespace std;
|
||||
using DimensionType = TechDraw::DrawViewDimension::DimensionType;
|
||||
using DimensionGeometry = TechDraw::DimensionGeometry;
|
||||
|
||||
//===========================================================================
|
||||
// utility routines
|
||||
@@ -104,7 +105,7 @@ void execAngle3Pt(Gui::Command* cmd);
|
||||
void execRadius(Gui::Command* cmd);
|
||||
void execDiameter(Gui::Command* cmd);
|
||||
void execArea(Gui::Command* cmd);
|
||||
void execDim(Gui::Command* cmd, std::string type, StringVector acceptableGeometry, std::vector<int> minimumCounts, std::vector<DimensionGeometryType> acceptableDimensionGeometrys);
|
||||
void execDim(Gui::Command* cmd, std::string type, StringVector acceptableGeometry, std::vector<int> minimumCounts, std::vector<DimensionGeometry> acceptableDimensionGeometrys);
|
||||
|
||||
void execExtent(Gui::Command* cmd, const std::string& dimType);
|
||||
|
||||
@@ -1100,7 +1101,7 @@ protected:
|
||||
}
|
||||
|
||||
void createAngleDimension(ReferenceEntry ref1, ReferenceEntry ref2) {
|
||||
if (TechDraw::isValidMultiEdge({ ref1, ref2 }) != isAngle) {
|
||||
if (TechDraw::isValidMultiEdge({ ref1, ref2 }) != DimensionGeometry::isAngle) {
|
||||
//isValidMultiEdge check if lines are parallel.
|
||||
restartCommand(QT_TRANSLATE_NOOP("Command", "Add Distance dimension"));
|
||||
createDistanceDimension("Distance", { ref1, ref2 });
|
||||
@@ -1354,10 +1355,10 @@ protected:
|
||||
|
||||
bool isVerticalDistance(ReferenceVector refs)
|
||||
{
|
||||
DimensionGeometryType geometryRefs2d = validateDimSelection(
|
||||
refs, { "Edge", "Vertex" }, { 1, 2 }, { isDiagonal });
|
||||
DimensionGeometry geometryRefs2d = validateDimSelection(
|
||||
refs, { "Edge", "Vertex" }, { 1, 2 }, { DimensionGeometry::isDiagonal });
|
||||
|
||||
return geometryRefs2d == TechDraw::isDiagonal;
|
||||
return geometryRefs2d == DimensionGeometry::isDiagonal;
|
||||
}
|
||||
|
||||
QPixmap icon(std::string name)
|
||||
@@ -1531,8 +1532,8 @@ void execRadius(Gui::Command* cmd)
|
||||
//Define the geometric configuration required for a radius dimension
|
||||
StringVector acceptableGeometry({"Edge"});
|
||||
std::vector<int> minimumCounts({1});
|
||||
std::vector<DimensionGeometryType> acceptableDimensionGeometrys(
|
||||
{isCircle, isEllipse, isBSplineCircle, isBSpline});
|
||||
std::vector<DimensionGeometry> acceptableDimensionGeometrys(
|
||||
{DimensionGeometry::isCircle, DimensionGeometry::isEllipse, DimensionGeometry::isBSplineCircle, DimensionGeometry::isBSpline});
|
||||
|
||||
execDim(cmd, "Radius", acceptableGeometry, minimumCounts, acceptableDimensionGeometrys);
|
||||
}
|
||||
@@ -1579,8 +1580,8 @@ void execDiameter(Gui::Command* cmd)
|
||||
//Define the geometric configuration required for a diameter dimension
|
||||
StringVector acceptableGeometry({"Edge"});
|
||||
std::vector<int> minimumCounts({1});
|
||||
std::vector<DimensionGeometryType> acceptableDimensionGeometrys(
|
||||
{isCircle, isEllipse, isBSplineCircle, isBSpline});
|
||||
std::vector<DimensionGeometry> acceptableDimensionGeometrys(
|
||||
{DimensionGeometry::isCircle, DimensionGeometry::isEllipse, DimensionGeometry::isBSplineCircle, DimensionGeometry::isBSpline});
|
||||
|
||||
execDim(cmd, "Diameter", acceptableGeometry, minimumCounts, acceptableDimensionGeometrys);
|
||||
}
|
||||
@@ -1626,8 +1627,8 @@ void execDistance(Gui::Command* cmd)
|
||||
{
|
||||
StringVector acceptableGeometry({"Edge", "Vertex"});
|
||||
std::vector<int> minimumCounts({1, 2});
|
||||
std::vector<DimensionGeometryType> acceptableDimensionGeometrys(
|
||||
{isVertical, isHorizontal, isDiagonal, isHybrid});
|
||||
std::vector<DimensionGeometry> acceptableDimensionGeometrys(
|
||||
{DimensionGeometry::isVertical, DimensionGeometry::isHorizontal, DimensionGeometry::isDiagonal, DimensionGeometry::isHybrid});
|
||||
|
||||
execDim(cmd, "Distance", acceptableGeometry, minimumCounts, acceptableDimensionGeometrys);
|
||||
}
|
||||
@@ -1675,7 +1676,7 @@ void execDistanceX(Gui::Command* cmd)
|
||||
//Define the geometric configuration required for a length dimension
|
||||
StringVector acceptableGeometry({"Edge", "Vertex"});
|
||||
std::vector<int> minimumCounts({1, 2});
|
||||
std::vector<DimensionGeometryType> acceptableDimensionGeometrys({isHorizontal, isDiagonal, isHybrid});
|
||||
std::vector<DimensionGeometry> acceptableDimensionGeometrys({DimensionGeometry::isHorizontal, DimensionGeometry::isDiagonal, DimensionGeometry::isHybrid});
|
||||
|
||||
execDim(cmd, "DistanceX", acceptableGeometry, minimumCounts, acceptableDimensionGeometrys);
|
||||
}
|
||||
@@ -1723,7 +1724,7 @@ void execDistanceY(Gui::Command* cmd)
|
||||
//Define the geometric configuration required for a length dimension
|
||||
StringVector acceptableGeometry({"Edge", "Vertex"});
|
||||
std::vector<int> minimumCounts({1, 2});
|
||||
std::vector<DimensionGeometryType> acceptableDimensionGeometrys({isVertical, isDiagonal, isHybrid});
|
||||
std::vector<DimensionGeometry> acceptableDimensionGeometrys({DimensionGeometry::isVertical, DimensionGeometry::isDiagonal, DimensionGeometry::isHybrid});
|
||||
|
||||
execDim(cmd, "DistanceY", acceptableGeometry, minimumCounts, acceptableDimensionGeometrys);
|
||||
}
|
||||
@@ -1770,7 +1771,7 @@ void execAngle(Gui::Command* cmd)
|
||||
//Define the geometric configuration required for a length dimension
|
||||
StringVector acceptableGeometry({"Edge"});
|
||||
std::vector<int> minimumCounts({2});
|
||||
std::vector<DimensionGeometryType> acceptableDimensionGeometrys({isAngle});
|
||||
std::vector<DimensionGeometry> acceptableDimensionGeometrys({DimensionGeometry::isAngle});
|
||||
|
||||
execDim(cmd, "Angle", acceptableGeometry, minimumCounts, acceptableDimensionGeometrys);
|
||||
}
|
||||
@@ -1817,7 +1818,7 @@ void execAngle3Pt(Gui::Command* cmd)
|
||||
//Define the geometric configuration required for a length dimension
|
||||
StringVector acceptableGeometry({"Vertex"});
|
||||
std::vector<int> minimumCounts({3});
|
||||
std::vector<DimensionGeometryType> acceptableDimensionGeometrys({isAngle3Pt});
|
||||
std::vector<DimensionGeometry> acceptableDimensionGeometrys({DimensionGeometry::isAngle3Pt});
|
||||
|
||||
execDim(cmd, "Angle3Pt", acceptableGeometry, minimumCounts, acceptableDimensionGeometrys);
|
||||
}
|
||||
@@ -1864,7 +1865,7 @@ void execArea(Gui::Command* cmd)
|
||||
//Define the geometric configuration required for a area dimension
|
||||
StringVector acceptableGeometry({"Face"});
|
||||
std::vector<int> minimumCounts({1});
|
||||
std::vector<DimensionGeometryType> acceptableDimensionGeometrys({isFace});
|
||||
std::vector<DimensionGeometry> acceptableDimensionGeometrys({DimensionGeometry::isFace});
|
||||
|
||||
execDim(cmd, "Area", acceptableGeometry, minimumCounts, acceptableDimensionGeometrys);
|
||||
}
|
||||
@@ -2116,20 +2117,20 @@ void execExtent(Gui::Command* cmd, const std::string& dimType)
|
||||
//Define the geometric configuration required for a extent dimension
|
||||
StringVector acceptableGeometry({"Edge"});
|
||||
std::vector<int> minimumCounts({1});
|
||||
std::vector<DimensionGeometryType> acceptableDimensionGeometrys({isMultiEdge,
|
||||
isHorizontal,
|
||||
isVertical,
|
||||
isDiagonal,
|
||||
isCircle,
|
||||
isEllipse,
|
||||
isBSplineCircle,
|
||||
isBSpline,
|
||||
isZLimited});
|
||||
std::vector<DimensionGeometry> acceptableDimensionGeometrys({DimensionGeometry::isMultiEdge,
|
||||
DimensionGeometry::isHorizontal,
|
||||
DimensionGeometry::isVertical,
|
||||
DimensionGeometry::isDiagonal,
|
||||
DimensionGeometry::isCircle,
|
||||
DimensionGeometry::isEllipse,
|
||||
DimensionGeometry::isBSplineCircle,
|
||||
DimensionGeometry::isBSpline,
|
||||
DimensionGeometry::isZLimited});
|
||||
|
||||
//what 2d geometry configuration did we receive?
|
||||
DimensionGeometryType geometryRefs2d = validateDimSelection(
|
||||
DimensionGeometry geometryRefs2d = validateDimSelection(
|
||||
references2d, acceptableGeometry, minimumCounts, acceptableDimensionGeometrys);
|
||||
if (geometryRefs2d == TechDraw::isInvalid) {
|
||||
if (geometryRefs2d == DimensionGeometry::isInvalid) {
|
||||
QMessageBox::warning(Gui::getMainWindow(),
|
||||
QObject::tr("Incorrect Selection"),
|
||||
QObject::tr("Can not make 2D extent dimension from selection"));
|
||||
@@ -2137,14 +2138,14 @@ void execExtent(Gui::Command* cmd, const std::string& dimType)
|
||||
}
|
||||
|
||||
//what 3d geometry configuration did we receive?
|
||||
DimensionGeometryType geometryRefs3d;
|
||||
if (geometryRefs2d == TechDraw::isViewReference && !references3d.empty()) {
|
||||
DimensionGeometry geometryRefs3d;
|
||||
if (geometryRefs2d == DimensionGeometry::isViewReference && !references3d.empty()) {
|
||||
geometryRefs3d = validateDimSelection3d(partFeat,
|
||||
references3d,
|
||||
acceptableGeometry,
|
||||
minimumCounts,
|
||||
acceptableDimensionGeometrys);
|
||||
if (geometryRefs3d == isInvalid) {
|
||||
if (geometryRefs3d == DimensionGeometry::isInvalid) {
|
||||
QMessageBox::warning(Gui::getMainWindow(),
|
||||
QObject::tr("Incorrect Selection"),
|
||||
QObject::tr("Can not make 3D extent dimension from selection"));
|
||||
@@ -2380,7 +2381,7 @@ void CreateTechDrawCommandsDims()
|
||||
|
||||
//Common code to build a dimension feature
|
||||
|
||||
void execDim(Gui::Command* cmd, std::string type, StringVector acceptableGeometry, std::vector<int> minimumCounts, std::vector<DimensionGeometryType> acceptableDimensionGeometrys)
|
||||
void execDim(Gui::Command* cmd, std::string type, StringVector acceptableGeometry, std::vector<int> minimumCounts, std::vector<DimensionGeometry> acceptableDimensionGeometrys)
|
||||
{
|
||||
bool result = _checkDrawViewPart(cmd);
|
||||
if (!result) {
|
||||
@@ -2396,9 +2397,9 @@ void execDim(Gui::Command* cmd, std::string type, StringVector acceptableGeometr
|
||||
TechDraw::getReferencesFromSelection(references2d, references3d);
|
||||
|
||||
//what 2d geometry configuration did we receive?
|
||||
DimensionGeometryType geometryRefs2d = validateDimSelection(
|
||||
DimensionGeometry geometryRefs2d = validateDimSelection(
|
||||
references2d, acceptableGeometry, minimumCounts, acceptableDimensionGeometrys);
|
||||
if (geometryRefs2d == TechDraw::isInvalid) {
|
||||
if (geometryRefs2d == DimensionGeometry::isInvalid) {
|
||||
QMessageBox::warning(Gui::getMainWindow(),
|
||||
QObject::tr("Incorrect Selection"),
|
||||
QObject::tr("Can not make 2D dimension from selection"));
|
||||
@@ -2406,15 +2407,15 @@ void execDim(Gui::Command* cmd, std::string type, StringVector acceptableGeometr
|
||||
}
|
||||
|
||||
//what 3d geometry configuration did we receive?
|
||||
DimensionGeometryType geometryRefs3d{TechDraw::isInvalid};
|
||||
if (geometryRefs2d == TechDraw::isViewReference && !references3d.empty()) {
|
||||
DimensionGeometry geometryRefs3d{DimensionGeometry::isInvalid};
|
||||
if (geometryRefs2d == DimensionGeometry::isViewReference && !references3d.empty()) {
|
||||
geometryRefs3d = validateDimSelection3d(partFeat,
|
||||
references3d,
|
||||
acceptableGeometry,
|
||||
minimumCounts,
|
||||
acceptableDimensionGeometrys);
|
||||
|
||||
if (geometryRefs3d == TechDraw::isInvalid) {
|
||||
if (geometryRefs3d == DimensionGeometry::isInvalid) {
|
||||
QMessageBox::warning(Gui::getMainWindow(),
|
||||
QObject::tr("Incorrect Selection"),
|
||||
QObject::tr("Can not make 3D dimension from selection"));
|
||||
@@ -2427,7 +2428,7 @@ void execDim(Gui::Command* cmd, std::string type, StringVector acceptableGeometr
|
||||
|
||||
//errors and warnings
|
||||
if (type == "Radius" || type == "Diameter") {
|
||||
if (geometryRefs2d == isEllipse || geometryRefs3d == isEllipse) {
|
||||
if (geometryRefs2d == DimensionGeometry::isEllipse || geometryRefs3d == DimensionGeometry::isEllipse) {
|
||||
QMessageBox::StandardButton result = QMessageBox::warning(
|
||||
Gui::getMainWindow(),
|
||||
QObject::tr("Ellipse Curve Warning"),
|
||||
@@ -2438,7 +2439,7 @@ void execDim(Gui::Command* cmd, std::string type, StringVector acceptableGeometr
|
||||
return;
|
||||
}
|
||||
}
|
||||
if (geometryRefs2d == isBSplineCircle || geometryRefs3d == isBSplineCircle) {
|
||||
if (geometryRefs2d == DimensionGeometry::isBSplineCircle || geometryRefs3d == DimensionGeometry::isBSplineCircle) {
|
||||
QMessageBox::StandardButton result = QMessageBox::warning(
|
||||
Gui::getMainWindow(),
|
||||
QObject::tr("B-spline Curve Warning"),
|
||||
@@ -2449,7 +2450,7 @@ void execDim(Gui::Command* cmd, std::string type, StringVector acceptableGeometr
|
||||
return;
|
||||
}
|
||||
}
|
||||
if (geometryRefs2d == isBSpline || geometryRefs3d == isBSpline) {
|
||||
if (geometryRefs2d == DimensionGeometry::isBSpline || geometryRefs3d == DimensionGeometry::isBSpline) {
|
||||
QMessageBox::critical(
|
||||
Gui::getMainWindow(),
|
||||
QObject::tr("B-spline Curve Error"),
|
||||
|
||||
@@ -40,6 +40,7 @@
|
||||
using namespace TechDraw;
|
||||
using namespace Measure;
|
||||
using DU = DrawUtil;
|
||||
using DimensionGeometry = TechDraw::DimensionGeometry;
|
||||
|
||||
TechDraw::DrawViewPart* TechDraw::getReferencesFromSelection(ReferenceVector& references2d,
|
||||
ReferenceVector& references3d)
|
||||
@@ -95,11 +96,11 @@ TechDraw::DrawViewPart* TechDraw::getReferencesFromSelection(ReferenceVector& re
|
||||
}
|
||||
|
||||
//! verify that the proposed references contains valid geometries from a 2d DrawViewPart.
|
||||
DimensionGeometryType TechDraw::validateDimSelection(
|
||||
DimensionGeometry TechDraw::validateDimSelection(
|
||||
const ReferenceVector& references, //[(dvp*, std::string),...,(dvp*, std::string)]
|
||||
const StringVector& acceptableGeometry,//"Edge", "Vertex", etc
|
||||
const std::vector<int>& minimumCounts, //how many of each geometry are needed for a good dimension
|
||||
const std::vector<DimensionGeometryType>& acceptableDimensionGeometrys)//isVertical, isHorizontal, ...
|
||||
const std::vector<DimensionGeometry>& acceptableDimensionGeometrys)//isVertical, isHorizontal, ...
|
||||
{
|
||||
StringVector subNames;
|
||||
TechDraw::DrawViewPart* dvpSave(nullptr);
|
||||
@@ -114,18 +115,18 @@ DimensionGeometryType TechDraw::validateDimSelection(
|
||||
}
|
||||
if (!dvpSave) {
|
||||
//must have 1 DVP in selection
|
||||
return isInvalid;
|
||||
return DimensionGeometry::isInvalid;
|
||||
}
|
||||
|
||||
if (subNames.empty()) {
|
||||
//no geometry referenced. can not make a dim from this mess. We are being called to validate
|
||||
//a selection for a 3d reference
|
||||
return isViewReference;
|
||||
return DimensionGeometry::isViewReference;
|
||||
}
|
||||
|
||||
if (subNames.front().empty()) {
|
||||
//can this still happen?
|
||||
return isViewReference;
|
||||
return DimensionGeometry::isViewReference;
|
||||
}
|
||||
|
||||
//check for invalid geometry descriptors in the subNames
|
||||
@@ -133,7 +134,7 @@ DimensionGeometryType TechDraw::validateDimSelection(
|
||||
acceptableGeometry.end());
|
||||
if (!TechDraw::validateSubnameList(subNames, acceptableGeometrySet)) {
|
||||
//can not make a dimension from this
|
||||
return isInvalid;
|
||||
return DimensionGeometry::isInvalid;
|
||||
}
|
||||
|
||||
//check for wrong number of geometry
|
||||
@@ -141,7 +142,7 @@ DimensionGeometryType TechDraw::validateDimSelection(
|
||||
GeomCountMap minimumCountMap = loadRequiredCounts(acceptableGeometry, minimumCounts);
|
||||
if (!checkGeometryOccurrences(subNames, minimumCountMap)) {
|
||||
//too many or too few geometry descriptors.
|
||||
return isInvalid;
|
||||
return DimensionGeometry::isInvalid;
|
||||
}
|
||||
|
||||
//we have a (potentially valid collection of 2d geometry
|
||||
@@ -151,7 +152,7 @@ DimensionGeometryType TechDraw::validateDimSelection(
|
||||
valid2dReferences.push_back(validEntry);
|
||||
}
|
||||
|
||||
DimensionGeometryType foundGeometry = getGeometryConfiguration(valid2dReferences);
|
||||
DimensionGeometry foundGeometry = getGeometryConfiguration(valid2dReferences);
|
||||
if (acceptableDimensionGeometrys.empty()) {
|
||||
//if the list is empty, we are accepting anything
|
||||
return foundGeometry;
|
||||
@@ -162,16 +163,16 @@ DimensionGeometryType TechDraw::validateDimSelection(
|
||||
}
|
||||
}
|
||||
|
||||
return isInvalid;
|
||||
return DimensionGeometry::isInvalid;
|
||||
}
|
||||
|
||||
//! verify that the proposed references contains valid geometries from non-TechDraw objects.
|
||||
DimensionGeometryType TechDraw::validateDimSelection3d(
|
||||
DimensionGeometry TechDraw::validateDimSelection3d(
|
||||
TechDraw::DrawViewPart* dvp,
|
||||
const ReferenceVector& references, //[(dvp*, std::string),...,(dvp*, std::string)]
|
||||
const StringVector& acceptableGeometry,//"Edge", "Vertex", etc
|
||||
const std::vector<int>& minimumCounts, //how many of each geometry are needed for a good dimension
|
||||
const std::vector<DimensionGeometryType>& acceptableDimensionGeometrys)//isVertical, isHorizontal, ...
|
||||
const std::vector<DimensionGeometry>& acceptableDimensionGeometrys)//isVertical, isHorizontal, ...
|
||||
{
|
||||
StringVector subNames;
|
||||
for (auto& ref : references) {
|
||||
@@ -185,18 +186,18 @@ DimensionGeometryType TechDraw::validateDimSelection3d(
|
||||
acceptableGeometry.end());
|
||||
if (!TechDraw::validateSubnameList(subNames, acceptableGeometrySet)) {
|
||||
//can not make a dimension from this
|
||||
return isInvalid;
|
||||
return DimensionGeometry::isInvalid;
|
||||
}
|
||||
|
||||
//check for wrong number of geometry
|
||||
GeomCountMap minimumCountMap = loadRequiredCounts(acceptableGeometry, minimumCounts);
|
||||
if (!checkGeometryOccurrences(subNames, minimumCountMap)) {
|
||||
//too many or too few geometry descriptors.
|
||||
return isInvalid;
|
||||
return DimensionGeometry::isInvalid;
|
||||
}
|
||||
|
||||
//we have a (potentially valid collection of 3d geometry
|
||||
DimensionGeometryType foundGeometry = getGeometryConfiguration3d(dvp, references);
|
||||
DimensionGeometry foundGeometry = getGeometryConfiguration3d(dvp, references);
|
||||
if (acceptableDimensionGeometrys.empty()) {
|
||||
//if the list is empty, we are accepting anything
|
||||
return foundGeometry;
|
||||
@@ -207,7 +208,7 @@ DimensionGeometryType TechDraw::validateDimSelection3d(
|
||||
}
|
||||
}
|
||||
|
||||
return isInvalid;
|
||||
return DimensionGeometry::isInvalid;
|
||||
}
|
||||
bool TechDraw::validateSubnameList(StringVector subNames, GeometrySet acceptableGeometrySet)
|
||||
{
|
||||
@@ -263,36 +264,36 @@ bool TechDraw::checkGeometryOccurrences(StringVector subNames, GeomCountMap keye
|
||||
}
|
||||
|
||||
//return the first valid configuration contained in the already validated references
|
||||
DimensionGeometryType TechDraw::getGeometryConfiguration(ReferenceVector valid2dReferences)
|
||||
DimensionGeometry TechDraw::getGeometryConfiguration(ReferenceVector valid2dReferences)
|
||||
{
|
||||
DimensionGeometryType config = isValidHybrid(valid2dReferences);
|
||||
if (config > isInvalid) {
|
||||
DimensionGeometry config = isValidHybrid(valid2dReferences);
|
||||
if (config > DimensionGeometry::isInvalid) {
|
||||
return config;
|
||||
}
|
||||
|
||||
config = isValidMultiEdge(valid2dReferences);
|
||||
if (config > isInvalid) {
|
||||
if (config > DimensionGeometry::isInvalid) {
|
||||
return config;
|
||||
}
|
||||
config = isValidVertexes(valid2dReferences);
|
||||
if (config > isInvalid) {
|
||||
if (config > DimensionGeometry::isInvalid) {
|
||||
return config;
|
||||
}
|
||||
config = isValidSingleEdge(valid2dReferences.front());
|
||||
if (config > isInvalid) {
|
||||
if (config > DimensionGeometry::isInvalid) {
|
||||
return config;
|
||||
}
|
||||
config = isValidSingleFace(valid2dReferences.front());
|
||||
if (config > isInvalid) {
|
||||
if (config > DimensionGeometry::isInvalid) {
|
||||
return config;
|
||||
}
|
||||
|
||||
// no valid configuration found
|
||||
return isInvalid;
|
||||
return DimensionGeometry::isInvalid;
|
||||
}
|
||||
|
||||
//return the first valid configuration contained in the already validated references
|
||||
DimensionGeometryType TechDraw::getGeometryConfiguration3d(DrawViewPart* dvp,
|
||||
DimensionGeometry TechDraw::getGeometryConfiguration3d(DrawViewPart* dvp,
|
||||
ReferenceVector valid3dReferences)
|
||||
{
|
||||
//first we check for whole object references
|
||||
@@ -307,37 +308,37 @@ DimensionGeometryType TechDraw::getGeometryConfiguration3d(DrawViewPart* dvp,
|
||||
}
|
||||
if (subElementRefs.empty()) {
|
||||
//only whole object references
|
||||
return isMultiEdge;
|
||||
return DimensionGeometry::isMultiEdge;
|
||||
}
|
||||
if (!wholeObjectRefs.empty()) {
|
||||
//mix of whole object and subelement refs
|
||||
return isMultiEdge;//??? correct ???
|
||||
return DimensionGeometry::isMultiEdge;//??? correct ???
|
||||
}
|
||||
|
||||
//only have subelement refs
|
||||
DimensionGeometryType config = isValidMultiEdge3d(dvp, valid3dReferences);
|
||||
if (config > isInvalid) {
|
||||
DimensionGeometry config = isValidMultiEdge3d(dvp, valid3dReferences);
|
||||
if (config > DimensionGeometry::isInvalid) {
|
||||
return config;
|
||||
}
|
||||
config = isValidVertexes3d(dvp, valid3dReferences);
|
||||
if (config > isInvalid) {
|
||||
if (config > DimensionGeometry::isInvalid) {
|
||||
return config;
|
||||
}
|
||||
config = isValidSingleEdge3d(dvp, valid3dReferences.front());
|
||||
if (config > isInvalid) {
|
||||
if (config > DimensionGeometry::isInvalid) {
|
||||
return config;
|
||||
}
|
||||
config = isValidSingleFace3d(dvp, valid3dReferences.front());
|
||||
if (config > isInvalid) {
|
||||
if (config > DimensionGeometry::isInvalid) {
|
||||
return config;
|
||||
}
|
||||
config = isValidHybrid3d(dvp, valid3dReferences);
|
||||
if (config > isInvalid) {
|
||||
if (config > DimensionGeometry::isInvalid) {
|
||||
return config;
|
||||
}
|
||||
|
||||
// no valid configuration found
|
||||
return isInvalid;
|
||||
return DimensionGeometry::isInvalid;
|
||||
}
|
||||
|
||||
//fill the GeomCountMap with pairs made from corresponding items in acceptableGeometry
|
||||
@@ -359,62 +360,62 @@ GeomCountMap TechDraw::loadRequiredCounts(const StringVector& acceptableGeometry
|
||||
}
|
||||
|
||||
//! verify that Selection contains a valid Geometry for a single Edge Dimension
|
||||
DimensionGeometryType TechDraw::isValidSingleEdge(ReferenceEntry ref)
|
||||
DimensionGeometry TechDraw::isValidSingleEdge(ReferenceEntry ref)
|
||||
{
|
||||
auto objFeat(dynamic_cast<TechDraw::DrawViewPart*>(ref.getObject()));
|
||||
if (!objFeat) {
|
||||
return isInvalid;
|
||||
return DimensionGeometry::isInvalid;
|
||||
}
|
||||
|
||||
//the Name starts with "Edge"
|
||||
std::string geomName = DrawUtil::getGeomTypeFromName(ref.getSubName());
|
||||
if (geomName != "Edge") {
|
||||
return isInvalid;
|
||||
return DimensionGeometry::isInvalid;
|
||||
}
|
||||
|
||||
//the geometry exists (redundant?)
|
||||
int GeoId(TechDraw::DrawUtil::getIndexFromName(ref.getSubName()));
|
||||
TechDraw::BaseGeomPtr geom = objFeat->getGeomByIndex(GeoId);
|
||||
if (!geom) {
|
||||
return isInvalid;
|
||||
return DimensionGeometry::isInvalid;
|
||||
}
|
||||
|
||||
if (geom->getGeomType() == GeomType::GENERIC) {
|
||||
TechDraw::GenericPtr gen1 = std::static_pointer_cast<TechDraw::Generic>(geom);
|
||||
if (gen1->points.size() < 2) {
|
||||
return isInvalid;
|
||||
return DimensionGeometry::isInvalid;
|
||||
}
|
||||
Base::Vector3d line = gen1->points.at(1) - gen1->points.at(0);
|
||||
if (fabs(line.y) < FLT_EPSILON) {
|
||||
return TechDraw::isHorizontal;
|
||||
return DimensionGeometry::isHorizontal;
|
||||
} else if (fabs(line.x) < FLT_EPSILON) {
|
||||
return TechDraw::isVertical;
|
||||
return DimensionGeometry::isHorizontal;
|
||||
} else {
|
||||
return TechDraw::isDiagonal;
|
||||
return DimensionGeometry::isDiagonal;
|
||||
}
|
||||
} else if (geom->getGeomType() == GeomType::CIRCLE || geom->getGeomType() == GeomType::ARCOFCIRCLE) {
|
||||
return isCircle;
|
||||
return DimensionGeometry::isCircle;
|
||||
} else if (geom->getGeomType() == GeomType::ELLIPSE || geom->getGeomType() == GeomType::ARCOFELLIPSE) {
|
||||
return isEllipse;
|
||||
return DimensionGeometry::isEllipse;
|
||||
} else if (geom->getGeomType() == GeomType::BSPLINE) {
|
||||
TechDraw::BSplinePtr spline = std::static_pointer_cast<TechDraw::BSpline>(geom);
|
||||
if (spline->isCircle()) {
|
||||
return isBSplineCircle;
|
||||
return DimensionGeometry::isBSplineCircle;
|
||||
} else {
|
||||
return isBSpline;
|
||||
return DimensionGeometry::isBSpline;
|
||||
}
|
||||
}
|
||||
return isInvalid;
|
||||
return DimensionGeometry::isInvalid;
|
||||
}
|
||||
|
||||
//! verify that Selection contains a valid Geometry for a single Edge Dimension
|
||||
DimensionGeometryType TechDraw::isValidSingleEdge3d(DrawViewPart* dvp, ReferenceEntry ref)
|
||||
DimensionGeometry TechDraw::isValidSingleEdge3d(DrawViewPart* dvp, ReferenceEntry ref)
|
||||
{
|
||||
(void)dvp;
|
||||
//the Name starts with "Edge"
|
||||
std::string geomName = DrawUtil::getGeomTypeFromName(ref.getSubName());
|
||||
if (geomName != "Edge") {
|
||||
return isInvalid;
|
||||
return DimensionGeometry::isInvalid;
|
||||
}
|
||||
|
||||
TopoDS_Shape refShape = ref.getGeometry();
|
||||
@@ -431,85 +432,85 @@ DimensionGeometryType TechDraw::isValidSingleEdge3d(DrawViewPart* dvp, Reference
|
||||
point1 = dvp->projectPoint(point1);
|
||||
Base::Vector3d line = point1 - point0;
|
||||
if (fabs(line.y) < FLT_EPSILON) {
|
||||
return TechDraw::isHorizontal;
|
||||
return DimensionGeometry::isHorizontal;
|
||||
} else if (fabs(line.x) < FLT_EPSILON) {
|
||||
return TechDraw::isVertical;
|
||||
return DimensionGeometry::isHorizontal;
|
||||
}
|
||||
// else if (fabs(line.z) < FLT_EPSILON) {
|
||||
// return TechDraw::isZLimited;
|
||||
// }
|
||||
else {
|
||||
return TechDraw::isDiagonal;
|
||||
return DimensionGeometry::isDiagonal;
|
||||
}
|
||||
} else if (adapt.GetType() == GeomAbs_Circle) {
|
||||
return isCircle;
|
||||
return DimensionGeometry::isCircle;
|
||||
} else if (adapt.GetType() == GeomAbs_Ellipse) {
|
||||
return isEllipse;
|
||||
return DimensionGeometry::isEllipse;
|
||||
} else if (adapt.GetType() == GeomAbs_BSplineCurve) {
|
||||
if (GeometryUtils::isCircle(occEdge)) {
|
||||
return isBSplineCircle;
|
||||
return DimensionGeometry::isBSplineCircle;
|
||||
} else {
|
||||
return isBSpline;
|
||||
return DimensionGeometry::isBSpline;
|
||||
}
|
||||
}
|
||||
|
||||
return isInvalid;
|
||||
return DimensionGeometry::isInvalid;
|
||||
}
|
||||
|
||||
//! verify that Selection contains a valid Geometry for a single Edge Dimension
|
||||
DimensionGeometryType TechDraw::isValidSingleFace(ReferenceEntry ref)
|
||||
DimensionGeometry TechDraw::isValidSingleFace(ReferenceEntry ref)
|
||||
{
|
||||
auto objFeat(dynamic_cast<TechDraw::DrawViewPart*>(ref.getObject()));
|
||||
if (!objFeat) {
|
||||
return isInvalid;
|
||||
return DimensionGeometry::isInvalid;
|
||||
}
|
||||
|
||||
//the Name starts with "Edge"
|
||||
std::string geomName = DrawUtil::getGeomTypeFromName(ref.getSubName());
|
||||
if (geomName != "Face") {
|
||||
return isInvalid;
|
||||
return DimensionGeometry::isInvalid;
|
||||
}
|
||||
|
||||
auto geom = objFeat->getFace(ref.getSubName());
|
||||
if (!geom) {
|
||||
return isInvalid;
|
||||
return DimensionGeometry::isInvalid;
|
||||
}
|
||||
|
||||
return isFace;
|
||||
return DimensionGeometry::isFace;
|
||||
}
|
||||
|
||||
//! verify that Selection contains a valid Geometry for a single Edge Dimension
|
||||
DimensionGeometryType TechDraw::isValidSingleFace3d(DrawViewPart* dvp, ReferenceEntry ref)
|
||||
DimensionGeometry TechDraw::isValidSingleFace3d(DrawViewPart* dvp, ReferenceEntry ref)
|
||||
{
|
||||
(void)dvp;
|
||||
//the Name starts with "Edge"
|
||||
std::string geomName = DrawUtil::getGeomTypeFromName(ref.getSubName());
|
||||
if (geomName != "Face") {
|
||||
return isInvalid;
|
||||
return DimensionGeometry::isInvalid;
|
||||
}
|
||||
|
||||
TopoDS_Shape refShape = ref.getGeometry();
|
||||
if (refShape.IsNull() || refShape.ShapeType() != TopAbs_FACE) {
|
||||
Base::Console().Warning("Geometry for reference is not a face.\n");
|
||||
return isInvalid;
|
||||
return DimensionGeometry::isInvalid;
|
||||
}
|
||||
|
||||
return isFace;
|
||||
return DimensionGeometry::isFace;
|
||||
}
|
||||
|
||||
//! verify that the edge references can make a dimension. Currently only extent
|
||||
//! dimensions support more than 2 edges
|
||||
DimensionGeometryType TechDraw::isValidMultiEdge(ReferenceVector refs)
|
||||
DimensionGeometry TechDraw::isValidMultiEdge(ReferenceVector refs)
|
||||
{
|
||||
//there has to be at least 2
|
||||
if (refs.size() < 2) {
|
||||
return isInvalid;
|
||||
return DimensionGeometry::isInvalid;
|
||||
}
|
||||
|
||||
//they all must start with "Edge"
|
||||
const std::string matchToken{"Edge"};
|
||||
if (!refsMatchToken(refs, matchToken)) {
|
||||
return isInvalid;
|
||||
return DimensionGeometry::isInvalid;
|
||||
}
|
||||
|
||||
auto objFeat0(dynamic_cast<TechDraw::DrawViewPart*>(refs.at(0).getObject()));
|
||||
@@ -520,7 +521,7 @@ DimensionGeometryType TechDraw::isValidMultiEdge(ReferenceVector refs)
|
||||
|
||||
if (refs.size() > 2) {
|
||||
//many edges, must be an extent?
|
||||
return isMultiEdge;
|
||||
return DimensionGeometry::isMultiEdge;
|
||||
}
|
||||
|
||||
//exactly 2 edges. could be angle, could be distance
|
||||
@@ -533,7 +534,7 @@ DimensionGeometryType TechDraw::isValidMultiEdge(ReferenceVector refs)
|
||||
TechDraw::GenericPtr gen0 = std::static_pointer_cast<TechDraw::Generic>(geom0);
|
||||
TechDraw::GenericPtr gen1 = std::static_pointer_cast<TechDraw::Generic>(geom1);
|
||||
if (gen0->points.size() > 2 || gen1->points.size() > 2) {//the edge is a polyline
|
||||
return isInvalid; //not supported yet
|
||||
return DimensionGeometry::isInvalid; //not supported yet
|
||||
}
|
||||
Base::Vector3d line0 = gen0->points.at(1) - gen0->points.at(0);
|
||||
line0.Normalize();
|
||||
@@ -541,27 +542,27 @@ DimensionGeometryType TechDraw::isValidMultiEdge(ReferenceVector refs)
|
||||
line1.Normalize();
|
||||
double dot = fabs(line0.Dot(line1));
|
||||
if (DU::fpCompare(dot, 1.0, EWTOLERANCE)) {
|
||||
return isDiagonal; //distance || line
|
||||
return DimensionGeometry::isDiagonal; //distance || line
|
||||
}
|
||||
return isAngle; //angle or distance
|
||||
return DimensionGeometry::isAngle; //angle or distance
|
||||
}
|
||||
return isDiagonal; //two edges, not both straight lines
|
||||
return DimensionGeometry::isDiagonal; //two edges, not both straight lines
|
||||
}
|
||||
|
||||
//! verify that the edge references can make a dimension. Currently only extent
|
||||
//! dimensions support more than 2 edges
|
||||
DimensionGeometryType TechDraw::isValidMultiEdge3d(DrawViewPart* dvp, ReferenceVector refs)
|
||||
DimensionGeometry TechDraw::isValidMultiEdge3d(DrawViewPart* dvp, ReferenceVector refs)
|
||||
{
|
||||
(void)dvp;
|
||||
//there has to be at least 2
|
||||
if (refs.size() < 2) {
|
||||
return isInvalid;
|
||||
return DimensionGeometry::isInvalid;
|
||||
}
|
||||
|
||||
//they all must start with "Edge"
|
||||
const std::string matchToken{"Edge"};
|
||||
if (!refsMatchToken(refs, matchToken)) {
|
||||
return isInvalid;
|
||||
return DimensionGeometry::isInvalid;
|
||||
}
|
||||
|
||||
std::vector<TopoDS_Edge> edges;
|
||||
@@ -569,7 +570,7 @@ DimensionGeometryType TechDraw::isValidMultiEdge3d(DrawViewPart* dvp, ReferenceV
|
||||
std::vector<TopoDS_Shape> shapesAll = ShapeExtractor::getShapesFromObject(ref.getObject());
|
||||
if (shapesAll.empty()) {
|
||||
//reference has no geometry
|
||||
return isInvalid;
|
||||
return DimensionGeometry::isInvalid;
|
||||
}
|
||||
}
|
||||
std::vector<TopoDS_Edge> edgesAll;
|
||||
@@ -577,19 +578,19 @@ DimensionGeometryType TechDraw::isValidMultiEdge3d(DrawViewPart* dvp, ReferenceV
|
||||
for (auto& ref : refs) {
|
||||
TopoDS_Shape geometry = ref.getGeometry();
|
||||
if (geometry.ShapeType() != TopAbs_EDGE) {
|
||||
return isInvalid;
|
||||
return DimensionGeometry::isInvalid;
|
||||
}
|
||||
TopoDS_Edge edge = TopoDS::Edge(geometry);
|
||||
BRepAdaptor_Curve adapt(edge);
|
||||
if (adapt.GetType() != GeomAbs_Line) {
|
||||
//not a line, so this must be an extent dim?
|
||||
return isMultiEdge;
|
||||
return DimensionGeometry::isMultiEdge;
|
||||
}
|
||||
edgesAll.push_back(edge);
|
||||
}
|
||||
if (edgesAll.size() > 2) {
|
||||
//must be an extent dimension of lines?
|
||||
return isMultiEdge;
|
||||
return DimensionGeometry::isMultiEdge;
|
||||
}
|
||||
|
||||
if (edgesAll.size() == 2) {
|
||||
@@ -604,17 +605,17 @@ DimensionGeometryType TechDraw::isValidMultiEdge3d(DrawViewPart* dvp, ReferenceV
|
||||
auto dot = fabs(line0.Dot(line1));
|
||||
if (DU::fpCompare(dot, 1.0, EWTOLERANCE)) {
|
||||
//lines are parallel, must be distance dim
|
||||
return isDiagonal;
|
||||
return DimensionGeometry::isDiagonal;
|
||||
}
|
||||
//lines are skew, could be angle, could be distance?
|
||||
return isAngle;
|
||||
return DimensionGeometry::isAngle;
|
||||
}
|
||||
|
||||
return isInvalid;
|
||||
return DimensionGeometry::isInvalid;
|
||||
}
|
||||
|
||||
//! verify that the vertex references can make a dimension
|
||||
DimensionGeometryType TechDraw::isValidVertexes(ReferenceVector refs)
|
||||
DimensionGeometry TechDraw::isValidVertexes(ReferenceVector refs)
|
||||
{
|
||||
TechDraw::DrawViewPart* dvp(dynamic_cast<TechDraw::DrawViewPart*>(refs.front().getObject()));
|
||||
if (!dvp) {
|
||||
@@ -624,7 +625,7 @@ DimensionGeometryType TechDraw::isValidVertexes(ReferenceVector refs)
|
||||
|
||||
const std::string matchToken{"Vertex"};
|
||||
if (!refsMatchToken(refs, matchToken)) {
|
||||
return isInvalid;
|
||||
return DimensionGeometry::isInvalid;
|
||||
}
|
||||
|
||||
if (refs.size() == 2) {
|
||||
@@ -633,28 +634,28 @@ DimensionGeometryType TechDraw::isValidVertexes(ReferenceVector refs)
|
||||
TechDraw::VertexPtr v1 = dvp->getVertex(refs.at(1).getSubName());
|
||||
Base::Vector3d line = v1->point() - v0->point();
|
||||
if (fabs(line.y) < FLT_EPSILON) {
|
||||
return isHorizontal;
|
||||
return DimensionGeometry::isHorizontal;
|
||||
} else if (fabs(line.x) < FLT_EPSILON) {
|
||||
return isVertical;
|
||||
return DimensionGeometry::isHorizontal;
|
||||
} else {
|
||||
return isDiagonal;
|
||||
return DimensionGeometry::isDiagonal;
|
||||
}
|
||||
} else if (refs.size() == 3) {
|
||||
//three vertices make an angle dimension
|
||||
return isAngle3Pt;
|
||||
return DimensionGeometry::isAngle3Pt;
|
||||
}
|
||||
|
||||
// did not find a valid configuration
|
||||
return isInvalid;
|
||||
return DimensionGeometry::isInvalid;
|
||||
}
|
||||
|
||||
//! verify that the vertex references can make a dimension
|
||||
DimensionGeometryType TechDraw::isValidVertexes3d(DrawViewPart* dvp, ReferenceVector refs)
|
||||
DimensionGeometry TechDraw::isValidVertexes3d(DrawViewPart* dvp, ReferenceVector refs)
|
||||
{
|
||||
(void)dvp;
|
||||
const std::string matchToken{"Vertex"};
|
||||
if (!refsMatchToken(refs, matchToken)) {
|
||||
return isInvalid;
|
||||
return DimensionGeometry::isInvalid;
|
||||
}
|
||||
|
||||
if (refs.size() == 2) {
|
||||
@@ -663,7 +664,7 @@ DimensionGeometryType TechDraw::isValidVertexes3d(DrawViewPart* dvp, ReferenceVe
|
||||
TopoDS_Shape geometry1 = refs.at(1).getGeometry();
|
||||
if (geometry0.IsNull() || geometry1.IsNull() || geometry0.ShapeType() != TopAbs_VERTEX
|
||||
|| geometry1.ShapeType() != TopAbs_VERTEX) {
|
||||
return isInvalid;
|
||||
return DimensionGeometry::isInvalid;
|
||||
}
|
||||
Base::Vector3d point0 = DU::toVector3d(BRep_Tool::Pnt(TopoDS::Vertex(geometry0)));
|
||||
point0 = dvp->projectPoint(point0);
|
||||
@@ -671,29 +672,29 @@ DimensionGeometryType TechDraw::isValidVertexes3d(DrawViewPart* dvp, ReferenceVe
|
||||
point1 = dvp->projectPoint(point1);
|
||||
Base::Vector3d line = point1 - point0;
|
||||
if (fabs(line.y) < FLT_EPSILON) {
|
||||
return isHorizontal;
|
||||
return DimensionGeometry::isHorizontal;
|
||||
} else if (fabs(line.x) < FLT_EPSILON) {
|
||||
return isVertical;
|
||||
return DimensionGeometry::isHorizontal;
|
||||
// } else if(fabs(line.z) < FLT_EPSILON) {
|
||||
// return isZLimited;
|
||||
} else {
|
||||
return isDiagonal;
|
||||
return DimensionGeometry::isDiagonal;
|
||||
}
|
||||
} else if (refs.size() == 3) {
|
||||
//three vertices make an angle dimension
|
||||
//we could check here that all the geometries are Vertex
|
||||
return isAngle3Pt;
|
||||
return DimensionGeometry::isAngle3Pt;
|
||||
}
|
||||
|
||||
// did not find a valid configuration
|
||||
return isInvalid;
|
||||
return DimensionGeometry::isInvalid;
|
||||
}
|
||||
|
||||
//! verify that the mixed bag (ex Vertex-Edge) of references can make a dimension
|
||||
DimensionGeometryType TechDraw::isValidHybrid(ReferenceVector refs)
|
||||
DimensionGeometry TechDraw::isValidHybrid(ReferenceVector refs)
|
||||
{
|
||||
if (refs.empty()) {
|
||||
return isInvalid;
|
||||
return DimensionGeometry::isInvalid;
|
||||
}
|
||||
|
||||
int vertexCount(0);
|
||||
@@ -707,15 +708,15 @@ DimensionGeometryType TechDraw::isValidHybrid(ReferenceVector refs)
|
||||
}
|
||||
}
|
||||
if (vertexCount > 0 && edgeCount > 0) {
|
||||
//must be a diagonal dim? could it be isHorizontal or isVertical?
|
||||
return isHybrid;
|
||||
//must be a diagonal dim? could it be DimensionGeometry::isHorizontal or isVertical?
|
||||
return DimensionGeometry::isHybrid;
|
||||
}
|
||||
|
||||
return isInvalid;
|
||||
return DimensionGeometry::isInvalid;
|
||||
}
|
||||
|
||||
//! verify that the mixed bag (ex Vertex-Edge) of references can make a dimension
|
||||
DimensionGeometryType TechDraw::isValidHybrid3d(DrawViewPart* dvp, ReferenceVector refs)
|
||||
DimensionGeometry TechDraw::isValidHybrid3d(DrawViewPart* dvp, ReferenceVector refs)
|
||||
{
|
||||
(void)dvp;
|
||||
//we can reuse the 2d check here.
|
||||
@@ -723,38 +724,38 @@ DimensionGeometryType TechDraw::isValidHybrid3d(DrawViewPart* dvp, ReferenceVect
|
||||
}
|
||||
|
||||
//handle situations where revised geometry type is valid but not suitable for existing dimType
|
||||
long int TechDraw::mapGeometryTypeToDimType(long int dimType, DimensionGeometryType geometry2d,
|
||||
DimensionGeometryType geometry3d)
|
||||
long int TechDraw::mapGeometryTypeToDimType(long int dimType, DimensionGeometry geometry2d,
|
||||
DimensionGeometry geometry3d)
|
||||
{
|
||||
if (geometry2d == isInvalid && geometry3d == isInvalid) {
|
||||
if (geometry2d == DimensionGeometry::isInvalid && geometry3d == DimensionGeometry::isInvalid) {
|
||||
//probably an error, but we can't do anything with this
|
||||
return dimType;
|
||||
}
|
||||
|
||||
if (geometry2d == isViewReference && geometry3d != isInvalid) {
|
||||
if (geometry2d == DimensionGeometry::isViewReference && geometry3d != DimensionGeometry::isInvalid) {
|
||||
switch (geometry3d) {
|
||||
case isDiagonal:
|
||||
case DimensionGeometry::isDiagonal:
|
||||
return DrawViewDimension::Distance;
|
||||
case isHorizontal:
|
||||
case DimensionGeometry::isHorizontal:
|
||||
return DrawViewDimension::DistanceX;
|
||||
case isVertical:
|
||||
case DimensionGeometry::isVertical:
|
||||
return DrawViewDimension::DistanceY;
|
||||
case isAngle:
|
||||
case DimensionGeometry::isAngle:
|
||||
return DrawViewDimension::Angle;
|
||||
case isAngle3Pt:
|
||||
case DimensionGeometry::isAngle3Pt:
|
||||
return DrawViewDimension::Angle3Pt;
|
||||
}
|
||||
} else if (geometry2d != isViewReference) {
|
||||
} else if (geometry2d != DimensionGeometry::isViewReference) {
|
||||
switch (geometry2d) {
|
||||
case isDiagonal:
|
||||
case DimensionGeometry::isDiagonal:
|
||||
return DrawViewDimension::Distance;
|
||||
case isHorizontal:
|
||||
case DimensionGeometry::isHorizontal:
|
||||
return DrawViewDimension::DistanceX;
|
||||
case isVertical:
|
||||
case DimensionGeometry::isVertical:
|
||||
return DrawViewDimension::DistanceY;
|
||||
case isAngle:
|
||||
case DimensionGeometry::isAngle:
|
||||
return DrawViewDimension::Angle;
|
||||
case isAngle3Pt:
|
||||
case DimensionGeometry::isAngle3Pt:
|
||||
return DrawViewDimension::Angle3Pt;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -39,67 +39,65 @@ using GeomCountVector = std::vector<GeomCount>;
|
||||
using GeomCountMap = std::map<std::string, int>;
|
||||
using GeometrySet = std::unordered_set<std::string>; //queryable unique set of geometrty descriptors
|
||||
|
||||
using DimensionGeometryType = int;
|
||||
|
||||
namespace TechDraw
|
||||
{
|
||||
|
||||
class DrawViewPart;
|
||||
|
||||
enum DimensionGeometryEnum {
|
||||
isInvalid,
|
||||
isHorizontal,
|
||||
isVertical,
|
||||
isDiagonal,
|
||||
isCircle,
|
||||
isEllipse,
|
||||
isBSplineCircle,
|
||||
isBSpline,
|
||||
isAngle,
|
||||
isAngle3Pt,
|
||||
isMultiEdge,
|
||||
isZLimited,
|
||||
isHybrid,
|
||||
isFace,
|
||||
isViewReference //never needs to be specified in the acceptable list
|
||||
};
|
||||
enum class DimensionGeometry {
|
||||
isInvalid,
|
||||
isHorizontal,
|
||||
isVertical,
|
||||
isDiagonal,
|
||||
isCircle,
|
||||
isEllipse,
|
||||
isBSplineCircle,
|
||||
isBSpline,
|
||||
isAngle,
|
||||
isAngle3Pt,
|
||||
isMultiEdge,
|
||||
isZLimited,
|
||||
isHybrid,
|
||||
isFace,
|
||||
isViewReference //never needs to be specified in the acceptable list
|
||||
};
|
||||
|
||||
DrawViewPart* getReferencesFromSelection(ReferenceVector& references2d,
|
||||
ReferenceVector& references3d);
|
||||
DimensionGeometryType validateDimSelection(const ReferenceVector& references,
|
||||
DimensionGeometry validateDimSelection(const ReferenceVector& references,
|
||||
const StringVector& acceptableGeometry,//"Edge", "Vertex", etc
|
||||
const std::vector<int>& minimumCounts, //how many of each geometry are needed for a good dimension
|
||||
const std::vector<DimensionGeometryType>& acceptableDimensionGeometrys);//isVertical, isHorizontal, ...
|
||||
DimensionGeometryType validateDimSelection3d(DrawViewPart* dvp,
|
||||
const std::vector<DimensionGeometry>& acceptableDimensionGeometrys);//isVertical, isHorizontal, ...
|
||||
DimensionGeometry validateDimSelection3d(DrawViewPart* dvp,
|
||||
const ReferenceVector& references,
|
||||
const StringVector& acceptableGeometry, //"Edge", "Vertex", etc
|
||||
const std::vector<int>& minimumCounts, //how many of each geometry are needed for a good dimension
|
||||
const std::vector<DimensionGeometryType>& acceptableDimensionGeometrys);//isVertical, isHorizontal, ...
|
||||
const std::vector<DimensionGeometry>& acceptableDimensionGeometrys);//isVertical, isHorizontal, ...
|
||||
|
||||
bool validateSubnameList(StringVector subNames, GeometrySet acceptableGeometrySet);
|
||||
|
||||
DimensionGeometryType getGeometryConfiguration(ReferenceVector valid2dReferences);
|
||||
DimensionGeometryType getGeometryConfiguration3d(DrawViewPart* dvp,
|
||||
DimensionGeometry getGeometryConfiguration(ReferenceVector valid2dReferences);
|
||||
DimensionGeometry getGeometryConfiguration3d(DrawViewPart* dvp,
|
||||
ReferenceVector valid3dReferences);
|
||||
|
||||
GeomCountMap loadRequiredCounts(const StringVector& acceptableGeometry,
|
||||
const std::vector<int>& minimumCouts);
|
||||
bool checkGeometryOccurrences(StringVector subNames, GeomCountMap keyedMinimumCounts);
|
||||
|
||||
DimensionGeometryType isValidVertexes(ReferenceVector refs);
|
||||
DimensionGeometryType isValidMultiEdge(ReferenceVector refs);
|
||||
DimensionGeometryType isValidSingleEdge(ReferenceEntry ref);
|
||||
DimensionGeometryType isValidSingleFace(ReferenceEntry ref);
|
||||
DimensionGeometryType isValidHybrid(ReferenceVector refs);
|
||||
DimensionGeometry isValidVertexes(ReferenceVector refs);
|
||||
DimensionGeometry isValidMultiEdge(ReferenceVector refs);
|
||||
DimensionGeometry isValidSingleEdge(ReferenceEntry ref);
|
||||
DimensionGeometry isValidSingleFace(ReferenceEntry ref);
|
||||
DimensionGeometry isValidHybrid(ReferenceVector refs);
|
||||
|
||||
DimensionGeometryType isValidVertexes3d(DrawViewPart* dvp, ReferenceVector refs);
|
||||
DimensionGeometryType isValidMultiEdge3d(DrawViewPart* dvp, ReferenceVector refs);
|
||||
DimensionGeometryType isValidSingleEdge3d(DrawViewPart* dvp, ReferenceEntry ref);
|
||||
DimensionGeometryType isValidSingleFace3d(DrawViewPart* dvp, ReferenceEntry ref);
|
||||
DimensionGeometryType isValidHybrid3d(DrawViewPart* dvp, ReferenceVector refs);
|
||||
DimensionGeometry isValidVertexes3d(DrawViewPart* dvp, ReferenceVector refs);
|
||||
DimensionGeometry isValidMultiEdge3d(DrawViewPart* dvp, ReferenceVector refs);
|
||||
DimensionGeometry isValidSingleEdge3d(DrawViewPart* dvp, ReferenceEntry ref);
|
||||
DimensionGeometry isValidSingleFace3d(DrawViewPart* dvp, ReferenceEntry ref);
|
||||
DimensionGeometry isValidHybrid3d(DrawViewPart* dvp, ReferenceVector refs);
|
||||
|
||||
long int mapGeometryTypeToDimType(long int dimType, DimensionGeometryType geometry2d,
|
||||
DimensionGeometryType geometry3d);
|
||||
long int mapGeometryTypeToDimType(long int dimType, DimensionGeometry geometry2d,
|
||||
DimensionGeometry geometry3d);
|
||||
|
||||
bool refsMatchToken(const ReferenceVector& refs, const std::string& matchToken);
|
||||
|
||||
|
||||
@@ -166,7 +166,7 @@ void DlgPrefsTechDrawAnnotationImp::loadSettings()
|
||||
|
||||
ui->pcbBalloonArrow->onRestore();
|
||||
DrawGuiUtil::loadArrowBox(ui->pcbBalloonArrow);
|
||||
ui->pcbBalloonArrow->setCurrentIndex(prefBalloonArrow());
|
||||
ui->pcbBalloonArrow->setCurrentIndex(static_cast<int>(prefBalloonArrow()));
|
||||
|
||||
ui->cbEndCap->onRestore();
|
||||
|
||||
@@ -207,7 +207,7 @@ void DlgPrefsTechDrawAnnotationImp::changeEvent(QEvent *e)
|
||||
}
|
||||
}
|
||||
|
||||
int DlgPrefsTechDrawAnnotationImp::prefBalloonArrow() const
|
||||
TechDraw::ArrowType DlgPrefsTechDrawAnnotationImp::prefBalloonArrow() const
|
||||
{
|
||||
return Preferences::balloonArrow();
|
||||
}
|
||||
|
||||
@@ -31,6 +31,7 @@
|
||||
|
||||
namespace TechDraw {
|
||||
class LineGenerator;
|
||||
enum class ArrowType : int;
|
||||
}
|
||||
|
||||
namespace TechDrawGui {
|
||||
@@ -53,7 +54,7 @@ protected:
|
||||
void loadSettings() override;
|
||||
void changeEvent(QEvent *e) override;
|
||||
|
||||
int prefBalloonArrow() const;
|
||||
TechDraw::ArrowType prefBalloonArrow() const;
|
||||
int prefBalloonShape() const;
|
||||
int prefMattingStyle() const;
|
||||
void loadLineStyleBoxes();
|
||||
|
||||
@@ -147,7 +147,7 @@ void DlgPrefsTechDrawDimensionsImp::loadSettings()
|
||||
ui->plsb_ArrowSize->onRestore();
|
||||
|
||||
DrawGuiUtil::loadArrowBox(ui->pcbArrow);
|
||||
ui->pcbArrow->setCurrentIndex(prefArrowStyle());
|
||||
ui->pcbArrow->setCurrentIndex(static_cast<int>(prefArrowStyle()));
|
||||
|
||||
ui->leFormatSpec->setText(QString::fromStdString(Preferences::formatSpec()));
|
||||
ui->leFormatSpec->onRestore();
|
||||
@@ -225,7 +225,7 @@ void DlgPrefsTechDrawDimensionsImp::resetSettingsToDefaults()
|
||||
PreferencePage::resetSettingsToDefaults();
|
||||
}
|
||||
|
||||
int DlgPrefsTechDrawDimensionsImp::prefArrowStyle() const
|
||||
TechDraw::ArrowType DlgPrefsTechDrawDimensionsImp::prefArrowStyle() const
|
||||
{
|
||||
return PreferencesGui::dimArrowStyle();
|
||||
}
|
||||
|
||||
@@ -30,6 +30,10 @@
|
||||
#include <Mod/TechDraw/TechDrawGlobal.h>
|
||||
|
||||
|
||||
namespace TechDraw {
|
||||
enum class ArrowType : int;
|
||||
}
|
||||
|
||||
namespace TechDrawGui {
|
||||
class Ui_DlgPrefsTechDrawDimensionsImp;
|
||||
|
||||
@@ -48,7 +52,7 @@ protected:
|
||||
void changeEvent(QEvent *e) override;
|
||||
void dimensioningModeChanged(int index);
|
||||
|
||||
int prefArrowStyle() const;
|
||||
TechDraw::ArrowType prefArrowStyle() const;
|
||||
|
||||
private:
|
||||
std::unique_ptr<Ui_DlgPrefsTechDrawDimensionsImp> ui;
|
||||
|
||||
@@ -34,6 +34,7 @@
|
||||
#include <Base/Console.h>
|
||||
#include <Base/Parameter.h>
|
||||
#include <Gui/Selection/Selection.h>
|
||||
#include <Mod/TechDraw/App/ArrowPropEnum.h>
|
||||
#include <Mod/TechDraw/App/Preferences.h>
|
||||
#include <Mod/TechDraw/App/LineGenerator.h>
|
||||
|
||||
@@ -156,9 +157,10 @@ QColor PreferencesGui::leaderQColor()
|
||||
return fcColor.asValue<QColor>();
|
||||
}
|
||||
|
||||
int PreferencesGui::dimArrowStyle()
|
||||
ArrowType PreferencesGui::dimArrowStyle()
|
||||
{
|
||||
return Preferences::getPreferenceGroup("Dimensions")->GetInt("ArrowStyle", 0);
|
||||
int temp = Preferences::getPreferenceGroup("Dimensions")->GetInt("ArrowStyle", 0);
|
||||
return static_cast<ArrowType>(temp);
|
||||
}
|
||||
|
||||
double PreferencesGui::dimArrowSize()
|
||||
|
||||
@@ -40,6 +40,10 @@ class QString;
|
||||
|
||||
#include <Mod/TechDraw/App/Preferences.h>
|
||||
|
||||
namespace TechDraw{
|
||||
enum class ArrowType : int;
|
||||
}
|
||||
|
||||
namespace TechDrawGui
|
||||
{
|
||||
|
||||
@@ -68,7 +72,7 @@ static QColor pageQColor();
|
||||
static Base::Color breaklineColor();
|
||||
static QColor breaklineQColor();
|
||||
|
||||
static int dimArrowStyle();
|
||||
static TechDraw::ArrowType dimArrowStyle();
|
||||
static double dimArrowSize();
|
||||
|
||||
static double edgeFuzz();
|
||||
|
||||
@@ -39,7 +39,7 @@ using namespace TechDraw;
|
||||
QGIArrow::QGIArrow() :
|
||||
m_fill(Qt::SolidPattern),
|
||||
m_size(getPrefArrowSize()),
|
||||
m_style(0),
|
||||
m_style(ArrowType::FILLED_ARROW),
|
||||
m_dirMode(false),
|
||||
m_dir(Base::Vector3d(1.0, 0.0, 0.0))
|
||||
{
|
||||
@@ -300,7 +300,7 @@ QPainterPath QGIArrow::makePyramid(Base::Vector3d dir, double length)
|
||||
return path;
|
||||
}
|
||||
|
||||
int QGIArrow::getPrefArrowStyle()
|
||||
ArrowType QGIArrow::getPrefArrowStyle()
|
||||
{
|
||||
return PreferencesGui::dimArrowStyle();
|
||||
}
|
||||
@@ -310,7 +310,7 @@ double QGIArrow::getPrefArrowSize()
|
||||
return PreferencesGui::dimArrowSize();
|
||||
}
|
||||
|
||||
double QGIArrow::getOverlapAdjust(int style, double size)
|
||||
double QGIArrow::getOverlapAdjust(ArrowType style, double size)
|
||||
{
|
||||
// adjustment required depends on arrow size and type! :(
|
||||
// ex for fork and tick, adjustment sb zero. 0.25 is good for filled triangle, 0.1 for open arrow.
|
||||
@@ -318,22 +318,22 @@ double QGIArrow::getOverlapAdjust(int style, double size)
|
||||
// NOTE: this may need to be adjusted to account for line thickness too.
|
||||
// Base::Console().Message("QGIA::getOverlapAdjust(%d, %.3f) \n", style, size);
|
||||
switch(style) {
|
||||
case FILLED_ARROW:
|
||||
case ArrowType::FILLED_ARROW:
|
||||
return 0.50 * size;
|
||||
case OPEN_ARROW:
|
||||
case ArrowType::OPEN_ARROW:
|
||||
return 0.10 * size;
|
||||
case TICK:
|
||||
case ArrowType::TICK:
|
||||
return 0.0;
|
||||
case DOT:
|
||||
case ArrowType::DOT:
|
||||
return 0.0;
|
||||
case OPEN_CIRCLE:
|
||||
case ArrowType::OPEN_CIRCLE:
|
||||
//diameter is size/2 so radius is size/4
|
||||
return 0.25 * size;
|
||||
case FORK:
|
||||
case ArrowType::FORK:
|
||||
return 0.0;
|
||||
case FILLED_TRIANGLE:
|
||||
case ArrowType::FILLED_TRIANGLE:
|
||||
return size;
|
||||
case NONE:
|
||||
case ArrowType::NONE:
|
||||
return 0.0;
|
||||
}
|
||||
return 1.0; // Unknown
|
||||
|
||||
@@ -24,6 +24,7 @@
|
||||
#define DRAWINGGUI_QGRAPHICSITEMARROW_H
|
||||
|
||||
#include <Mod/TechDraw/TechDrawGlobal.h>
|
||||
#include <Mod/TechDraw/App/ArrowPropEnum.h>
|
||||
|
||||
#include <Base/Vector3D.h>
|
||||
|
||||
@@ -37,17 +38,6 @@ QT_END_NAMESPACE
|
||||
namespace TechDrawGui
|
||||
{
|
||||
|
||||
/*enum ArrowType {*/
|
||||
/* FILLED_TRIANGLE = 0, */
|
||||
/* OPEN_ARROW, */
|
||||
/* HASH_MARK, */
|
||||
/* DOT, */
|
||||
/* OPEN_CIRCLE, */
|
||||
/* FORK, */
|
||||
/* PYRAMID, */
|
||||
/* NONE*/
|
||||
/*};*/
|
||||
|
||||
class TechDrawGuiExport QGIArrow : public QGIPrimPath
|
||||
{
|
||||
public:
|
||||
@@ -64,16 +54,16 @@ public:
|
||||
void flip() { m_flipped = !m_flipped; }
|
||||
double getSize() { return m_size; }
|
||||
void setSize(double s);
|
||||
int getStyle() { return m_style; }
|
||||
void setStyle(int s) { m_style = s; }
|
||||
TechDraw::ArrowType getStyle() { return m_style; }
|
||||
void setStyle(TechDraw::ArrowType s) { m_style = s; }
|
||||
bool getDirMode() { return m_dirMode; }
|
||||
void setDirMode(bool b) { m_dirMode = b; }
|
||||
Base::Vector3d getDirection(void) { return m_flipped ? -m_dir : m_dir; }
|
||||
void setDirection(Base::Vector3d v) { m_dir = v; }
|
||||
void setDirection(double angle) { m_dir = Base::Vector3d(cos(angle), sin(angle), 0.0); }
|
||||
static int getPrefArrowStyle();
|
||||
static TechDraw::ArrowType getPrefArrowStyle();
|
||||
static double getPrefArrowSize();
|
||||
static double getOverlapAdjust(int style, double size);
|
||||
static double getOverlapAdjust(TechDraw::ArrowType style, double size);
|
||||
|
||||
protected:
|
||||
QPainterPath makeFilledTriangle(double length, double width, bool flipped);
|
||||
@@ -93,7 +83,7 @@ private:
|
||||
QBrush m_brush;
|
||||
Qt::BrushStyle m_fill;
|
||||
double m_size;
|
||||
int m_style;
|
||||
TechDraw::ArrowType m_style;
|
||||
bool m_flipped;
|
||||
bool m_dirMode;
|
||||
Base::Vector3d m_dir;
|
||||
|
||||
@@ -426,12 +426,14 @@ QPainterPath QGILeaderLine::makeLeaderPath(std::vector<QPointF> qPoints)
|
||||
double endAdjLength(0.0);
|
||||
if (qPoints.size() > 1) {
|
||||
//make path adjustment to hide leaderline ends behind arrowheads
|
||||
if (featLeader->StartSymbol.getValue() != ArrowType::NONE) {
|
||||
startAdjLength = QGIArrow::getOverlapAdjust(featLeader->StartSymbol.getValue(),
|
||||
ArrowType choice = static_cast<ArrowType>(featLeader->StartSymbol.getValue());
|
||||
if (choice != ArrowType::NONE) {
|
||||
startAdjLength = QGIArrow::getOverlapAdjust(choice,
|
||||
QGIArrow::getPrefArrowSize());
|
||||
}
|
||||
if (featLeader->EndSymbol.getValue() != ArrowType::NONE) {
|
||||
endAdjLength = QGIArrow::getOverlapAdjust(featLeader->EndSymbol.getValue(),
|
||||
choice = static_cast<ArrowType>(featLeader->EndSymbol.getValue());
|
||||
if (choice != ArrowType::NONE) {
|
||||
endAdjLength = QGIArrow::getOverlapAdjust(choice,
|
||||
QGIArrow::getPrefArrowSize());
|
||||
}
|
||||
|
||||
@@ -515,8 +517,9 @@ void QGILeaderLine::setArrows(std::vector<QPointF> pathPoints)
|
||||
|
||||
QPointF lastOffset = (pathPoints.back() - pathPoints.front());
|
||||
|
||||
if (featLeader->StartSymbol.getValue() != ArrowType::NONE) {
|
||||
m_arrow1->setStyle(featLeader->StartSymbol.getValue());
|
||||
ArrowType choice = static_cast<ArrowType>(featLeader->StartSymbol.getValue());
|
||||
if (choice != ArrowType::NONE) {
|
||||
m_arrow1->setStyle(choice);
|
||||
m_arrow1->setWidth(getLineWidth());
|
||||
m_arrow1->setSize(QGIArrow::getPrefArrowSize());
|
||||
m_arrow1->setDirMode(true);
|
||||
@@ -537,8 +540,9 @@ void QGILeaderLine::setArrows(std::vector<QPointF> pathPoints)
|
||||
m_arrow1->hide();
|
||||
}
|
||||
|
||||
if (featLeader->EndSymbol.getValue() != ArrowType::NONE) {
|
||||
m_arrow2->setStyle(featLeader->EndSymbol.getValue());
|
||||
choice = static_cast<ArrowType>(featLeader->EndSymbol.getValue());
|
||||
if (choice != ArrowType::NONE) {
|
||||
m_arrow2->setStyle(choice);
|
||||
m_arrow2->setWidth(getLineWidth());
|
||||
m_arrow2->setSize(QGIArrow::getPrefArrowSize());
|
||||
m_arrow2->setDirMode(true);
|
||||
|
||||
@@ -141,10 +141,10 @@ void QGISectionLine::makeArrows()
|
||||
//make Euro (ISO) Arrows
|
||||
void QGISectionLine::makeArrowsISO()
|
||||
{
|
||||
m_arrow1->setStyle(0);
|
||||
m_arrow1->setStyle(ArrowType::FILLED_ARROW);
|
||||
m_arrow1->setSize(QGIArrow::getPrefArrowSize());
|
||||
m_arrow1->setPos(m_start);
|
||||
m_arrow2->setStyle(0);
|
||||
m_arrow2->setStyle(ArrowType::FILLED_ARROW);
|
||||
m_arrow2->setSize(QGIArrow::getPrefArrowSize());
|
||||
m_arrow2->setPos(m_end);
|
||||
|
||||
@@ -165,9 +165,9 @@ void QGISectionLine::makeArrowsISO()
|
||||
//make traditional (ASME) section arrows
|
||||
void QGISectionLine::makeArrowsTrad()
|
||||
{
|
||||
m_arrow1->setStyle(0);
|
||||
m_arrow1->setStyle(ArrowType::FILLED_ARROW);
|
||||
m_arrow1->setSize(QGIArrow::getPrefArrowSize());
|
||||
m_arrow2->setStyle(0);
|
||||
m_arrow2->setStyle(ArrowType::FILLED_ARROW);
|
||||
m_arrow2->setSize(QGIArrow::getPrefArrowSize());
|
||||
|
||||
if (m_arrowMode == SINGLEDIRECTIONMODE) {
|
||||
|
||||
@@ -785,7 +785,7 @@ void QGIViewBalloon::drawBalloon(bool originDrag)
|
||||
|
||||
double xAdj = 0.0;
|
||||
double yAdj = 0.0;
|
||||
int endType = balloon->EndType.getValue();
|
||||
ArrowType endType = static_cast<ArrowType>(balloon->EndType.getValue());
|
||||
double arrowAdj = QGIArrow::getOverlapAdjust(
|
||||
endType, balloon->EndTypeScale.getValue() * QGIArrow::getPrefArrowSize());
|
||||
|
||||
@@ -955,8 +955,9 @@ QColor QGIViewBalloon::prefNormalColor()
|
||||
return getNormalColor();
|
||||
}
|
||||
|
||||
int QGIViewBalloon::prefDefaultArrow() const { return Preferences::balloonArrow(); }
|
||||
|
||||
ArrowType QGIViewBalloon::prefDefaultArrow() const {
|
||||
return Preferences::balloonArrow();
|
||||
}
|
||||
|
||||
//should this be an object property or global preference?
|
||||
//when would you want a crooked pyramid?
|
||||
|
||||
@@ -42,6 +42,7 @@ namespace TechDraw
|
||||
{
|
||||
class DrawViewBalloon;
|
||||
class DrawView;
|
||||
enum class ArrowType : int;
|
||||
}// namespace TechDraw
|
||||
|
||||
namespace TechDraw
|
||||
@@ -203,7 +204,7 @@ public:
|
||||
|
||||
void setNormalColorAll();
|
||||
QColor prefNormalColor();
|
||||
int prefDefaultArrow() const;
|
||||
TechDraw::ArrowType prefDefaultArrow() const;
|
||||
bool prefOrthoPyramid() const;
|
||||
|
||||
TechDraw::DrawViewBalloon* getBalloonFeat()
|
||||
|
||||
@@ -927,7 +927,7 @@ void QGIViewDimension::drawArrows(int count, const Base::Vector2d positions[], d
|
||||
arrow->setSize(arrowSize);
|
||||
arrow->setFlipped(flipped);
|
||||
|
||||
if (vp->ArrowStyle.getValue() != ArrowType::NONE) {
|
||||
if (vp->ArrowStyle.getValue() != static_cast<int>(ArrowType::NONE)) {
|
||||
arrow->draw();
|
||||
arrow->show();
|
||||
}
|
||||
|
||||
@@ -128,21 +128,21 @@ void TaskDimRepair::slotUseSelection()
|
||||
|
||||
StringVector acceptableGeometry({ "Edge", "Vertex", "Face" });
|
||||
std::vector<int> minimumCounts({1, 1, 1});
|
||||
std::vector<DimensionGeometryType> acceptableDimensionGeometrys;//accept anything
|
||||
DimensionGeometryType geometryRefs2d = validateDimSelection(
|
||||
std::vector<DimensionGeometry> acceptableDimensionGeometrys;//accept anything
|
||||
DimensionGeometry geometryRefs2d = validateDimSelection(
|
||||
references2d, acceptableGeometry, minimumCounts, acceptableDimensionGeometrys);
|
||||
if (geometryRefs2d == isInvalid) {
|
||||
if (geometryRefs2d == DimensionGeometry::isInvalid) {
|
||||
QMessageBox::warning(Gui::getMainWindow(),
|
||||
QObject::tr("Incorrect Selection"),
|
||||
QObject::tr("Can not make dimension from selection"));
|
||||
return;
|
||||
}
|
||||
//what 3d geometry configuration did we receive?
|
||||
DimensionGeometryType geometryRefs3d(isInvalid);
|
||||
if (geometryRefs2d == TechDraw::isViewReference && !references3d.empty()) {
|
||||
DimensionGeometry geometryRefs3d(DimensionGeometry::isInvalid);
|
||||
if (geometryRefs2d == DimensionGeometry::isViewReference && !references3d.empty()) {
|
||||
geometryRefs3d = validateDimSelection3d(
|
||||
dvp, references3d, acceptableGeometry, minimumCounts, acceptableDimensionGeometrys);
|
||||
if (geometryRefs3d == isInvalid) {
|
||||
if (geometryRefs3d == DimensionGeometry::isInvalid) {
|
||||
QMessageBox::warning(Gui::getMainWindow(),
|
||||
QObject::tr("Incorrect Selection"),
|
||||
QObject::tr("Can not make dimension from selection"));
|
||||
|
||||
@@ -233,11 +233,11 @@ void TaskLeaderLine::setUiPrimary()
|
||||
}
|
||||
|
||||
DrawGuiUtil::loadArrowBox(ui->cboxStartSym);
|
||||
int aStyle = PreferencesGui::dimArrowStyle();
|
||||
ui->cboxStartSym->setCurrentIndex(aStyle);
|
||||
ArrowType aStyle = PreferencesGui::dimArrowStyle();
|
||||
ui->cboxStartSym->setCurrentIndex(static_cast<int>(aStyle));
|
||||
|
||||
DrawGuiUtil::loadArrowBox(ui->cboxEndSym);
|
||||
ui->cboxEndSym->setCurrentIndex(TechDraw::ArrowType::NONE);
|
||||
ui->cboxEndSym->setCurrentIndex(static_cast<int>(TechDraw::ArrowType::NONE));
|
||||
|
||||
ui->dsbWeight->setUnit(Base::Unit::Length);
|
||||
ui->dsbWeight->setMinimum(0);
|
||||
|
||||
@@ -90,12 +90,12 @@ void TaskLinkDim::loadAvailDims()
|
||||
return;
|
||||
|
||||
std::string result;
|
||||
int selRefType = TechDraw::DrawViewDimension::getRefTypeSubElements(m_subs);
|
||||
TechDraw::DrawViewDimension::RefType selRefType = TechDraw::DrawViewDimension::getRefTypeSubElements(m_subs);
|
||||
//int found = 0;
|
||||
for (auto* view : m_page->getViews()) {
|
||||
if (view->isDerivedFrom<TechDraw::DrawViewDimension>()) {
|
||||
auto* dim = static_cast<TechDraw::DrawViewDimension*>(view);
|
||||
int dimRefType = dim->getRefType();
|
||||
TechDraw::DrawViewDimension::RefType dimRefType = dim->getRefType();
|
||||
if (dimRefType == selRefType) { //potential matches
|
||||
// found++;
|
||||
if (dim->has3DReferences()) {
|
||||
|
||||
@@ -444,12 +444,12 @@ void TaskProjGroup::rotateButtonClicked()
|
||||
|
||||
if (multiView) {
|
||||
//change Front View Dir by 90
|
||||
if (clicked == ui->butTopRotate) multiView->rotate("Up");
|
||||
else if (clicked == ui->butDownRotate) multiView->rotate("Down");
|
||||
else if (clicked == ui->butRightRotate) multiView->rotate("Right");
|
||||
else if (clicked == ui->butLeftRotate) multiView->rotate("Left");
|
||||
else if (clicked == ui->butCWRotate) multiView->spin("CW");
|
||||
else if (clicked == ui->butCCWRotate) multiView->spin("CCW");
|
||||
if (clicked == ui->butTopRotate) multiView->rotate(RotationMotion::Up);
|
||||
else if (clicked == ui->butDownRotate) multiView->rotate(RotationMotion::Down);
|
||||
else if (clicked == ui->butRightRotate) multiView->rotate(RotationMotion::Right);
|
||||
else if (clicked == ui->butLeftRotate) multiView->rotate(RotationMotion::Left);
|
||||
else if (clicked == ui->butCWRotate) multiView->spin(SpinDirection::CW);
|
||||
else if (clicked == ui->butCCWRotate) multiView->spin(SpinDirection::CCW);
|
||||
else if (clicked == ui->butFront) {
|
||||
multiView->getAnchor()->Direction.setValue(Base::Vector3d(0.0, -1.0, 0.0));
|
||||
multiView->getAnchor()->RotationVector.setValue(Base::Vector3d(1.0, 0.0, 0.0));
|
||||
@@ -466,12 +466,12 @@ void TaskProjGroup::rotateButtonClicked()
|
||||
}
|
||||
else {
|
||||
auto* viewPart = static_cast<TechDraw::DrawViewPart*>(view);
|
||||
if (clicked == ui->butTopRotate) viewPart->rotate("Up");
|
||||
else if (clicked == ui->butDownRotate) viewPart->rotate("Down");
|
||||
else if (clicked == ui->butRightRotate) viewPart->rotate("Right");
|
||||
else if (clicked == ui->butLeftRotate) viewPart->rotate("Left");
|
||||
else if (clicked == ui->butCWRotate) viewPart->spin("CW");
|
||||
else if (clicked == ui->butCCWRotate) viewPart->spin("CCW");
|
||||
if (clicked == ui->butTopRotate) viewPart->rotate(RotationMotion::Up);
|
||||
else if (clicked == ui->butDownRotate) viewPart->rotate(RotationMotion::Down);
|
||||
else if (clicked == ui->butRightRotate) viewPart->rotate(RotationMotion::Right);
|
||||
else if (clicked == ui->butLeftRotate) viewPart->rotate(RotationMotion::Left);
|
||||
else if (clicked == ui->butCWRotate) viewPart->spin(SpinDirection::CW);
|
||||
else if (clicked == ui->butCCWRotate) viewPart->spin(SpinDirection::CCW);
|
||||
else if (clicked == ui->butFront) {
|
||||
viewPart->Direction.setValue(Base::Vector3d(0.0,-1.0,0.0));
|
||||
viewPart->XDirection.setValue(Base::Vector3d(1.0, 0.0, 0.0));
|
||||
|
||||
@@ -85,7 +85,7 @@ ViewProviderDimension::ViewProviderDimension()
|
||||
"Arrow size in units");
|
||||
|
||||
ArrowStyle.setEnums(ArrowPropEnum::ArrowTypeEnums); // NOLINT
|
||||
ADD_PROPERTY_TYPE(ArrowStyle, (PreferencesGui::dimArrowStyle()),
|
||||
ADD_PROPERTY_TYPE(ArrowStyle, (static_cast<int>(PreferencesGui::dimArrowStyle())),
|
||||
group, (App::PropertyType)(App::Prop_None),
|
||||
"Arrow end symbol - point, filled arrow, etc");
|
||||
|
||||
|
||||
Reference in New Issue
Block a user