Dimension fixes
Prevent _M_range_check on wrong selection Allow unlinking of linked Dimension Allow Horiz/Vert projected Dims Improve error msg for invalid selction
This commit is contained in:
committed by
Yorik van Havre
parent
a662cad5be
commit
6abce56595
@@ -68,6 +68,18 @@
|
||||
using namespace TechDrawGui;
|
||||
using namespace std;
|
||||
|
||||
|
||||
enum EdgeType{
|
||||
isInvalid,
|
||||
isHorizontal,
|
||||
isVertical,
|
||||
isDiagonal,
|
||||
isCircle,
|
||||
isCurve,
|
||||
isAngle
|
||||
};
|
||||
|
||||
|
||||
//===========================================================================
|
||||
// utility routines
|
||||
//===========================================================================
|
||||
@@ -81,18 +93,9 @@ int _isValidSingleEdge(Gui::Command* cmd);
|
||||
bool _isValidVertexes(Gui::Command* cmd);
|
||||
int _isValidEdgeToEdge(Gui::Command* cmd);
|
||||
bool _isValidVertexToEdge(Gui::Command* cmd);
|
||||
char* _edgeTypeToText(int e);
|
||||
//bool _checkActive(Gui::Command* cmd, Base::Type classType, bool needSubs);
|
||||
|
||||
enum EdgeType{
|
||||
isInvalid,
|
||||
isHorizontal,
|
||||
isVertical,
|
||||
isDiagonal,
|
||||
isCircle,
|
||||
isCurve,
|
||||
isAngle
|
||||
};
|
||||
|
||||
|
||||
//===========================================================================
|
||||
// TechDraw_NewDimension
|
||||
@@ -168,13 +171,10 @@ void CmdTechDrawNewDimension::activated(int iMsg)
|
||||
subs.push_back(SubNames[0]);
|
||||
subs.push_back(SubNames[1]);
|
||||
switch (edgeCase) {
|
||||
//TODO: This didn't have the breaks in it before 17 May, but didn't
|
||||
// seem to crash either, so should check whether execution can even
|
||||
// get here -Ian-
|
||||
case isHorizontal:
|
||||
case isHorizontal:
|
||||
dimType = "DistanceX";
|
||||
break;
|
||||
case isVertical:
|
||||
case isVertical:
|
||||
dimType = "DistanceY";
|
||||
break;
|
||||
case isDiagonal:
|
||||
@@ -285,7 +285,7 @@ void CmdTechDrawNewRadiusDimension::activated(int iMsg)
|
||||
subs.push_back(SubNames[0]);
|
||||
} else {
|
||||
std::stringstream edgeMsg;
|
||||
edgeMsg << "Can't make a radius Dimension from this selection (edge type: " << edgeType << ")";
|
||||
edgeMsg << "Can't make a radius Dimension from this selection (edge type: " << _edgeTypeToText(edgeType) << ")";
|
||||
QMessageBox::warning(Gui::getMainWindow(), QObject::tr("Incorrect Selection"),
|
||||
QObject::tr(edgeMsg.str().c_str()));
|
||||
return;
|
||||
@@ -374,7 +374,7 @@ void CmdTechDrawNewDiameterDimension::activated(int iMsg)
|
||||
subs.push_back(SubNames[0]);
|
||||
} else {
|
||||
std::stringstream edgeMsg;
|
||||
edgeMsg << "Can't make a diameter Dimension from this selection (edge type: " << edgeType << ")";
|
||||
edgeMsg << "Can't make a diameter Dimension from this selection (edge type: " << _edgeTypeToText(edgeType) << ")";
|
||||
QMessageBox::warning(Gui::getMainWindow(), QObject::tr("Incorrect Selection"),
|
||||
QObject::tr(edgeMsg.str().c_str()));
|
||||
return;
|
||||
@@ -473,7 +473,9 @@ void CmdTechDrawNewLengthDimension::activated(int iMsg)
|
||||
subs.push_back(SubNames[1]);
|
||||
} else if ((_isValidEdgeToEdge(this) == isHorizontal) ||
|
||||
(_isValidEdgeToEdge(this) == isVertical) ||
|
||||
(_isValidEdgeToEdge(this) == isVertical)) {
|
||||
(_isValidEdgeToEdge(this) == isDiagonal) ||
|
||||
(_isValidEdgeToEdge(this) == isAngle)) {
|
||||
edgeType = _isValidEdgeToEdge(this);
|
||||
objs.push_back(objFeat);
|
||||
objs.push_back(objFeat);
|
||||
subs.push_back(SubNames[0]);
|
||||
@@ -485,7 +487,7 @@ void CmdTechDrawNewLengthDimension::activated(int iMsg)
|
||||
subs.push_back(SubNames[1]);
|
||||
} else {
|
||||
std::stringstream edgeMsg;
|
||||
edgeMsg << "Can't make a length Dimension from this selection (edge type: " << edgeType << ")";
|
||||
edgeMsg << "Can't make a length Dimension from this selection (edge type: " << _edgeTypeToText(edgeType) << ")";
|
||||
QMessageBox::warning(Gui::getMainWindow(), QObject::tr("Incorrect Selection"),
|
||||
QObject::tr(edgeMsg.str().c_str()));
|
||||
return;
|
||||
@@ -579,7 +581,11 @@ void CmdTechDrawNewDistanceXDimension::activated(int iMsg)
|
||||
objs.push_back(objFeat);
|
||||
subs.push_back(SubNames[0]);
|
||||
subs.push_back(SubNames[1]);
|
||||
} else if (_isValidEdgeToEdge(this) == isHorizontal) {
|
||||
} else if ((_isValidEdgeToEdge(this) == isHorizontal) ||
|
||||
(_isValidEdgeToEdge(this) == isVertical) ||
|
||||
(_isValidEdgeToEdge(this) == isDiagonal) ||
|
||||
(_isValidEdgeToEdge(this) == isAngle)) {
|
||||
edgeType = _isValidEdgeToEdge(this);
|
||||
objs.push_back(objFeat);
|
||||
objs.push_back(objFeat);
|
||||
subs.push_back(SubNames[0]);
|
||||
@@ -591,7 +597,7 @@ void CmdTechDrawNewDistanceXDimension::activated(int iMsg)
|
||||
subs.push_back(SubNames[1]);
|
||||
} else {
|
||||
std::stringstream edgeMsg;
|
||||
edgeMsg << "Can't make a horizontal Dimension from this selection (edge type: " << edgeType << ")";
|
||||
edgeMsg << "Can't make a horizontal Dimension from this selection (edge type: " << _edgeTypeToText(edgeType) << ")";
|
||||
QMessageBox::warning(Gui::getMainWindow(), QObject::tr("Incorrect Selection"),
|
||||
QObject::tr(edgeMsg.str().c_str()));
|
||||
return;
|
||||
@@ -686,7 +692,11 @@ void CmdTechDrawNewDistanceYDimension::activated(int iMsg)
|
||||
objs.push_back(objFeat);
|
||||
subs.push_back(SubNames[0]);
|
||||
subs.push_back(SubNames[1]);
|
||||
} else if (_isValidEdgeToEdge(this) == isVertical) {
|
||||
} else if ((_isValidEdgeToEdge(this) == isVertical) ||
|
||||
(_isValidEdgeToEdge(this) == isHorizontal) ||
|
||||
(_isValidEdgeToEdge(this) == isDiagonal) ||
|
||||
(_isValidEdgeToEdge(this) == isAngle)) {
|
||||
edgeType = _isValidEdgeToEdge(this);
|
||||
objs.push_back(objFeat);
|
||||
objs.push_back(objFeat);
|
||||
subs.push_back(SubNames[0]);
|
||||
@@ -698,7 +708,7 @@ void CmdTechDrawNewDistanceYDimension::activated(int iMsg)
|
||||
subs.push_back(SubNames[1]);
|
||||
} else {
|
||||
std::stringstream edgeMsg;
|
||||
edgeMsg << "Can't make a vertical Dimension from this selection (edge type: " << edgeType << ")";
|
||||
edgeMsg << "Can't make a vertical Dimension from this selection (edge type: " << _edgeTypeToText(edgeType) << ")";
|
||||
QMessageBox::warning(Gui::getMainWindow(), QObject::tr("Incorrect Selection"),
|
||||
QObject::tr(edgeMsg.str().c_str()));
|
||||
return;
|
||||
@@ -868,11 +878,16 @@ void CmdTechDrawLinkDimension::activated(int iMsg)
|
||||
|
||||
if (!obj3D) {
|
||||
QMessageBox::warning(Gui::getMainWindow(), QObject::tr("Incorrect Selection"),
|
||||
QObject::tr("Can't link a dimension to this selection"));
|
||||
QObject::tr("There is no 3D object in your selection"));
|
||||
return;
|
||||
}
|
||||
|
||||
if (subs.empty()) {
|
||||
QMessageBox::warning(Gui::getMainWindow(), QObject::tr("Incorrect Selection"),
|
||||
QObject::tr("There are no 3D Edges or Vertices in your selection"));
|
||||
return;
|
||||
}
|
||||
|
||||
//TODO: if (subs.empty()) { "no geometry found in selection" }
|
||||
|
||||
// dialog to select the Dimension to link
|
||||
Gui::Control().showDialog(new TaskDlgLinkDim(obj3D,subs,page));
|
||||
@@ -1064,9 +1079,9 @@ int _isValidEdgeToEdge(Gui::Command* cmd) {
|
||||
if(xprod > FLT_EPSILON) { //edges are not parallel
|
||||
return isAngle;
|
||||
}
|
||||
if(fabs(line0.fX) < FLT_EPSILON && fabs(line1.fX) < FLT_EPSILON) {
|
||||
if(fabs(line0.fX) < FLT_EPSILON && fabs(line1.fX) < FLT_EPSILON) { //both horizontal
|
||||
edgeType = isHorizontal;
|
||||
} else if(fabs(line0.fY) < FLT_EPSILON && fabs(line1.fY) < FLT_EPSILON) {
|
||||
} else if(fabs(line0.fY) < FLT_EPSILON && fabs(line1.fY) < FLT_EPSILON) { //both vertical
|
||||
edgeType = isVertical;
|
||||
} else {
|
||||
edgeType = isDiagonal;
|
||||
@@ -1114,6 +1129,38 @@ bool _isValidVertexToEdge(Gui::Command* cmd) {
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
char* _edgeTypeToText(int e)
|
||||
{
|
||||
char* result;
|
||||
switch(e) {
|
||||
case isInvalid:
|
||||
result = "invalid";
|
||||
break;
|
||||
case isHorizontal:
|
||||
result = "horizontal";
|
||||
break;
|
||||
case isVertical:
|
||||
result = "vertical";
|
||||
break;
|
||||
case isDiagonal:
|
||||
result = "diagonal";
|
||||
break;
|
||||
case isCircle:
|
||||
result = "circle";
|
||||
break;
|
||||
case isCurve:
|
||||
result = "curve";
|
||||
break;
|
||||
case isAngle:
|
||||
result = "angle";
|
||||
break;
|
||||
default:
|
||||
result = "unknown";
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
//bool _checkActive(Gui::Command* cmd, Base::Type classType, bool needSubs)
|
||||
//{
|
||||
// //need a page, a selected classType and [a subelement]
|
||||
|
||||
Reference in New Issue
Block a user