[TechDraw] Improve readability of DrawViewDetail.cpp
[TechDraw] Improve readability of DrawViewDimension.cpp [TechDraw] Improve readability of DrawViewDimExtent.cpp [TechDraw] Improve readability of DrawViewDraft.cpp [TechDraw] Improve readability of DrawViewImage.cpp [TechDraw] Improve readability of DrawViewMulti.cpp
This commit is contained in:
committed by
WandererFan
parent
a203b1ae30
commit
6ed38eeb99
@@ -127,15 +127,15 @@ DrawViewDetail::~DrawViewDetail()
|
||||
|
||||
short DrawViewDetail::mustExecute() const
|
||||
{
|
||||
short result = 0;
|
||||
if (!isRestoring()) {
|
||||
result = (AnchorPoint.isTouched() ||
|
||||
Radius.isTouched() ||
|
||||
BaseView.isTouched() ||
|
||||
Reference.isTouched());
|
||||
}
|
||||
if (result) {
|
||||
return result;
|
||||
if (
|
||||
AnchorPoint.isTouched() ||
|
||||
Radius.isTouched() ||
|
||||
BaseView.isTouched() ||
|
||||
Reference.isTouched()
|
||||
) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return TechDraw::DrawView::mustExecute();
|
||||
}
|
||||
@@ -213,9 +213,9 @@ App::DocumentObjectExecReturn *DrawViewDetail::execute(void)
|
||||
DrawViewPart* dvp = nullptr;
|
||||
if (!baseObj->getTypeId().isDerivedFrom(TechDraw::DrawViewPart::getClassTypeId())) {
|
||||
return new App::DocumentObjectExecReturn("BaseView object is not a DrawViewPart object");
|
||||
} else {
|
||||
dvp = static_cast<DrawViewPart*>(baseObj);
|
||||
}
|
||||
|
||||
dvp = static_cast<DrawViewPart*>(baseObj);
|
||||
|
||||
DrawProjGroupItem* dpgi = nullptr;
|
||||
if (dvp->isDerivedFrom(TechDraw::DrawProjGroupItem::getClassTypeId())) {
|
||||
@@ -263,16 +263,14 @@ App::DocumentObjectExecReturn *DrawViewDetail::execute(void)
|
||||
addShapes2d();
|
||||
|
||||
//second pass if required
|
||||
if (ScaleType.isValue("Automatic")) {
|
||||
if (!checkFit()) {
|
||||
double newScale = autoScale();
|
||||
Scale.setValue(newScale);
|
||||
Scale.purgeTouched();
|
||||
if (geometryObject) {
|
||||
delete geometryObject;
|
||||
geometryObject = nullptr;
|
||||
detailExec(shape, dvp, dvs);
|
||||
}
|
||||
if (ScaleType.isValue("Automatic") && !checkFit()) {
|
||||
double newScale = autoScale();
|
||||
Scale.setValue(newScale);
|
||||
Scale.purgeTouched();
|
||||
if (geometryObject != nullptr) {
|
||||
delete geometryObject;
|
||||
geometryObject = nullptr;
|
||||
detailExec(shape, dvp, dvs);
|
||||
}
|
||||
}
|
||||
dvp->requestPaint(); //to refresh detail highlight!
|
||||
@@ -526,8 +524,7 @@ TopoDS_Shape DrawViewDetail::projectEdgesOntoFace(TopoDS_Shape edgeShape, TopoDS
|
||||
//so tell the Gui that there are no details for this view
|
||||
std::vector<DrawViewDetail*> DrawViewDetail::getDetailRefs(void) const
|
||||
{
|
||||
std::vector<DrawViewDetail*> result;
|
||||
return result;
|
||||
return std::vector<DrawViewDetail*>();
|
||||
}
|
||||
|
||||
double DrawViewDetail::getFudgeRadius()
|
||||
@@ -540,8 +537,7 @@ bool DrawViewDetail::debugDetail(void) const
|
||||
Base::Reference<ParameterGrp> hGrp = App::GetApplication().GetUserParameter()
|
||||
.GetGroup("BaseApp")->GetGroup("Preferences")->GetGroup("Mod/TechDraw/debug");
|
||||
|
||||
bool result = hGrp->GetBool("debugDetail",false);
|
||||
return result;
|
||||
return hGrp->GetBool("debugDetail",false);
|
||||
}
|
||||
|
||||
void DrawViewDetail::unsetupObject()
|
||||
|
||||
@@ -126,36 +126,36 @@ App::DocumentObjectExecReturn *DrawViewDimExtent::execute(void)
|
||||
Base::Vector3d refMin = endPoints.first;
|
||||
Base::Vector3d refMax = endPoints.second;
|
||||
|
||||
TechDraw::VertexPtr v0 = nullptr;
|
||||
TechDraw::VertexPtr v1 = nullptr;
|
||||
std::vector<std::string> cTags = CosmeticTags.getValues();
|
||||
if (cTags.size() > 1) {
|
||||
v0 = dvp->getProjVertexByCosTag(cTags[0]);
|
||||
v1 = dvp->getProjVertexByCosTag(cTags[1]);
|
||||
if (v0 && v1) {
|
||||
double length00 = (v0->pnt - refMin).Length();
|
||||
double length11 = (v1->pnt - refMax).Length();
|
||||
double length01 = (v0->pnt - refMax).Length();
|
||||
double length10 = (v1->pnt - refMin).Length();
|
||||
if ( ((length00 < tolerance) &&
|
||||
(length11 < tolerance)) ||
|
||||
((length01 < tolerance) &&
|
||||
(length10 < tolerance)) ) {
|
||||
//nothing changed - nop
|
||||
} else {
|
||||
//update GV
|
||||
v0->pnt = refMin;
|
||||
v1->pnt = refMax;
|
||||
// v0->occVertex = ???
|
||||
// v1->occVertex = ???
|
||||
//update CV
|
||||
double scale = dvp->getScale();
|
||||
CosmeticVertex* cvTemp = dvp->getCosmeticVertex(cTags[0]);
|
||||
cvTemp->permaPoint = refMin / scale;
|
||||
cvTemp = dvp->getCosmeticVertex(cTags[1]);
|
||||
cvTemp->permaPoint = refMax / scale;
|
||||
}
|
||||
}
|
||||
if (cTags.size() <= 1) {
|
||||
return DrawViewDimension::execute();
|
||||
}
|
||||
|
||||
TechDraw::VertexPtr v0 = dvp->getProjVertexByCosTag(cTags[0]);
|
||||
TechDraw::VertexPtr v1 = dvp->getProjVertexByCosTag(cTags[1]);
|
||||
if (v0 == nullptr ||
|
||||
v1 != nullptr) {
|
||||
return DrawViewDimension::execute();
|
||||
}
|
||||
|
||||
double length00 = (v0->pnt - refMin).Length();
|
||||
double length11 = (v1->pnt - refMax).Length();
|
||||
double length01 = (v0->pnt - refMax).Length();
|
||||
double length10 = (v1->pnt - refMin).Length();
|
||||
|
||||
if ((length00 >= tolerance || length11 >= tolerance) &&
|
||||
(length01 >= tolerance || length10 >= tolerance)) { // Something has changed
|
||||
//update GV
|
||||
v0->pnt = refMin;
|
||||
v1->pnt = refMax;
|
||||
// v0->occVertex = ???
|
||||
// v1->occVertex = ???
|
||||
//update CV
|
||||
double scale = dvp->getScale();
|
||||
CosmeticVertex* cvTemp = dvp->getCosmeticVertex(cTags[0]);
|
||||
cvTemp->permaPoint = refMin / scale;
|
||||
cvTemp = dvp->getCosmeticVertex(cTags[1]);
|
||||
cvTemp->permaPoint = refMax / scale;
|
||||
}
|
||||
|
||||
return DrawViewDimension::execute();
|
||||
@@ -164,60 +164,62 @@ App::DocumentObjectExecReturn *DrawViewDimExtent::execute(void)
|
||||
//getSubValues returns a garbage 1st entry if there are no subelements.
|
||||
std::vector<std::string> DrawViewDimExtent::getSubNames(void)
|
||||
{
|
||||
std::vector<std::string> result;
|
||||
std::vector<std::string> edgeNames = Source.getSubValues();
|
||||
if (!edgeNames.empty() &&
|
||||
(edgeNames[0].size() == 0)) {
|
||||
//garbage first entry - nop
|
||||
} else {
|
||||
result = edgeNames;
|
||||
if (edgeNames.empty() ||
|
||||
edgeNames[0].size() != 0) {
|
||||
return std::vector<std::string>(); //garbage first entry - nop
|
||||
}
|
||||
return result;
|
||||
return edgeNames;
|
||||
}
|
||||
|
||||
pointPair DrawViewDimExtent::getPointsTwoVerts()
|
||||
{
|
||||
// Base::Console().Message("DVDE::getPointsTwoVerts() - %s\n",getNameInDocument());
|
||||
pointPair result;
|
||||
result.first = Base::Vector3d(0.0, 0.0, 0.0);
|
||||
result.second = Base::Vector3d(0.0, 0.0, 0.0);
|
||||
TechDraw::VertexPtr v0 = nullptr;
|
||||
TechDraw::VertexPtr v1 = nullptr;
|
||||
pointPair errorValue(
|
||||
Base::Vector3d(0.0, 0.0, 0.0),
|
||||
Base::Vector3d(0.0, 0.0, 0.0)
|
||||
);
|
||||
|
||||
TechDraw::DrawViewPart* dvp = getViewPart();
|
||||
if (!dvp)
|
||||
return result;
|
||||
if (!dvp) {
|
||||
return errorValue;
|
||||
}
|
||||
|
||||
std::vector<std::string> cTags = CosmeticTags.getValues();
|
||||
if (cTags.size() > 1) {
|
||||
v0 = dvp->getProjVertexByCosTag(cTags[0]);
|
||||
v1 = dvp->getProjVertexByCosTag(cTags[1]);
|
||||
if (v0 && v1) {
|
||||
result.first = v0->pnt;
|
||||
result.second = v1->pnt;
|
||||
}
|
||||
if (cTags.size() < 1) {
|
||||
return errorValue;
|
||||
}
|
||||
return result;
|
||||
|
||||
TechDraw::VertexPtr v0 = dvp->getProjVertexByCosTag(cTags[0]);
|
||||
TechDraw::VertexPtr v1 = dvp->getProjVertexByCosTag(cTags[1]);
|
||||
if (v0 == nullptr || v1 == nullptr ) {
|
||||
return errorValue;
|
||||
}
|
||||
|
||||
return pointPair(v0->pnt, v1->pnt);
|
||||
}
|
||||
|
||||
//! validate 2D references - only checks if the target exists
|
||||
bool DrawViewDimExtent::checkReferences2D() const
|
||||
{
|
||||
// Base::Console().Message("DVDE::checkReFerences2d() - %s\n",getNameInDocument());
|
||||
bool result = false;
|
||||
TechDraw::DrawViewPart* dvp = getViewPart();
|
||||
if (!dvp) {
|
||||
return result;
|
||||
return false;
|
||||
}
|
||||
|
||||
std::vector<std::string> cTags = CosmeticTags.getValues();
|
||||
if (cTags.size() > 1) {
|
||||
CosmeticVertex* cv0 = dvp->getCosmeticVertex(cTags[0]);
|
||||
CosmeticVertex* cv1 = dvp->getCosmeticVertex(cTags[1]);
|
||||
if (cv0 && cv1) {
|
||||
result = true;
|
||||
}
|
||||
if (cTags.size() < 1) {
|
||||
return false;
|
||||
}
|
||||
return result;
|
||||
|
||||
CosmeticVertex* cv0 = dvp->getCosmeticVertex(cTags[0]);
|
||||
CosmeticVertex* cv1 = dvp->getCosmeticVertex(cTags[1]);
|
||||
if (cv0 == nullptr || cv1 == nullptr) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void DrawViewDimExtent::unsetupObject()
|
||||
|
||||
@@ -205,10 +205,8 @@ void DrawViewDimension::onChanged(const App::Property* prop)
|
||||
clear3DMeasurements(); //Measurement object
|
||||
if (!(References3D.getValues()).empty()) {
|
||||
setAll3DMeasurement();
|
||||
} else {
|
||||
if (MeasureType.isValue("True")) { //empty 3dRefs, but True
|
||||
MeasureType.touch(); //run MeasureType logic for this case
|
||||
}
|
||||
} else if (MeasureType.isValue("True")) { //empty 3dRefs, but True
|
||||
MeasureType.touch(); //run MeasureType logic for this case
|
||||
}
|
||||
}
|
||||
else if (prop == &Type) { //why??
|
||||
@@ -343,13 +341,13 @@ void DrawViewDimension::handleChangedPropertyType(Base::XMLReader &reader, const
|
||||
}
|
||||
|
||||
// Over/Undertolerance were further changed from App::PropertyQuantity to App::PropertyQuantityConstraint
|
||||
if ((prop == &OverTolerance) && (strcmp(TypeName, "App::PropertyQuantity") == 0)) {
|
||||
if (prop == &OverTolerance && strcmp(TypeName, "App::PropertyQuantity") == 0) {
|
||||
App::PropertyQuantity OverToleranceProperty;
|
||||
// restore the PropertyQuantity to be able to set its value
|
||||
OverToleranceProperty.Restore(reader);
|
||||
OverTolerance.setValue(OverToleranceProperty.getValue());
|
||||
}
|
||||
else if ((prop == &UnderTolerance) && (strcmp(TypeName, "App::PropertyQuantity") == 0)) {
|
||||
else if (prop == &UnderTolerance && strcmp(TypeName, "App::PropertyQuantity") == 0) {
|
||||
App::PropertyQuantity UnderToleranceProperty;
|
||||
// restore the PropertyQuantity to be able to set its value
|
||||
UnderToleranceProperty.Restore(reader);
|
||||
@@ -360,24 +358,24 @@ void DrawViewDimension::handleChangedPropertyType(Base::XMLReader &reader, const
|
||||
|
||||
short DrawViewDimension::mustExecute() const
|
||||
{
|
||||
bool result = 0;
|
||||
if (!isRestoring()) {
|
||||
result = (References2D.isTouched() ||
|
||||
Type.isTouched() ||
|
||||
FormatSpec.isTouched() ||
|
||||
Arbitrary.isTouched() ||
|
||||
FormatSpecOverTolerance.isTouched() ||
|
||||
FormatSpecUnderTolerance.isTouched() ||
|
||||
ArbitraryTolerances.isTouched() ||
|
||||
MeasureType.isTouched() ||
|
||||
TheoreticalExact.isTouched() ||
|
||||
EqualTolerance.isTouched() ||
|
||||
OverTolerance.isTouched() ||
|
||||
UnderTolerance.isTouched() ||
|
||||
Inverted.isTouched() );
|
||||
}
|
||||
if (result) {
|
||||
return result;
|
||||
if (
|
||||
References2D.isTouched() ||
|
||||
Type.isTouched() ||
|
||||
FormatSpec.isTouched() ||
|
||||
Arbitrary.isTouched() ||
|
||||
FormatSpecOverTolerance.isTouched() ||
|
||||
FormatSpecUnderTolerance.isTouched() ||
|
||||
ArbitraryTolerances.isTouched() ||
|
||||
MeasureType.isTouched() ||
|
||||
TheoreticalExact.isTouched() ||
|
||||
EqualTolerance.isTouched() ||
|
||||
OverTolerance.isTouched() ||
|
||||
UnderTolerance.isTouched() ||
|
||||
Inverted.isTouched()
|
||||
) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return DrawView::mustExecute();
|
||||
@@ -744,22 +742,17 @@ App::DocumentObjectExecReturn *DrawViewDimension::execute(void)
|
||||
|
||||
bool DrawViewDimension::isMultiValueSchema(void) const
|
||||
{
|
||||
bool result = false;
|
||||
bool angularMeasure = false;
|
||||
if ( (Type.isValue("Angle")) ||
|
||||
(Type.isValue("Angle3Pt")) ) {
|
||||
angularMeasure = true;
|
||||
}
|
||||
bool angularMeasure = (Type.isValue("Angle") || Type.isValue("Angle3Pt"));
|
||||
|
||||
Base::UnitSystem uniSys = Base::UnitsApi::getSchema();
|
||||
if ((uniSys == Base::UnitSystem::ImperialBuilding) &&
|
||||
if (uniSys == Base::UnitSystem::ImperialBuilding &&
|
||||
!angularMeasure) {
|
||||
result = true;
|
||||
} else if ((uniSys == Base::UnitSystem::ImperialCivil) &&
|
||||
return true;
|
||||
} else if (uniSys == Base::UnitSystem::ImperialCivil &&
|
||||
!angularMeasure) {
|
||||
result = true;
|
||||
return true;
|
||||
}
|
||||
return result;
|
||||
return false;
|
||||
}
|
||||
|
||||
std::string DrawViewDimension::getBaseLengthUnit(Base::UnitSystem system)
|
||||
@@ -793,8 +786,6 @@ std::string DrawViewDimension::formatValue(qreal value,
|
||||
int partial,
|
||||
bool isDim)
|
||||
{
|
||||
std::string result;
|
||||
|
||||
QString qUserStringUnits;
|
||||
QString formattedValue;
|
||||
bool angularMeasure = false;
|
||||
@@ -933,10 +924,11 @@ std::string DrawViewDimension::formatValue(qreal value,
|
||||
}
|
||||
}
|
||||
|
||||
result = formattedValue.toStdString();
|
||||
|
||||
std::string formattedValueString = formattedValue.toStdString();
|
||||
|
||||
if (partial == 0) { //full text for multi-value schemas
|
||||
result = Base::Tools::toStdString(formatPrefix) +
|
||||
return Base::Tools::toStdString(formatPrefix) +
|
||||
Base::Tools::toStdString(qMultiValueStr) +
|
||||
Base::Tools::toStdString(formatSuffix) +
|
||||
Base::Tools::toStdString(qUserStringUnits);
|
||||
@@ -951,26 +943,26 @@ std::string DrawViewDimension::formatValue(qreal value,
|
||||
}
|
||||
if (angularMeasure) {
|
||||
//always insert unit after value
|
||||
result = Base::Tools::toStdString(formatPrefix) +
|
||||
result +
|
||||
return Base::Tools::toStdString(formatPrefix) +
|
||||
formattedValueString +
|
||||
Base::Tools::toStdString(qUserStringUnits) +
|
||||
Base::Tools::toStdString(formatSuffix);
|
||||
} else if (showUnits()){
|
||||
if (isDim && haveTolerance()) {
|
||||
//unit will be included in tolerance so don't repeat it here
|
||||
result = Base::Tools::toStdString(formatPrefix) +
|
||||
result +
|
||||
return Base::Tools::toStdString(formatPrefix) +
|
||||
formattedValueString +
|
||||
Base::Tools::toStdString(formatSuffix);
|
||||
} else {
|
||||
//no tolerance, so we need to include unit
|
||||
result = Base::Tools::toStdString(formatPrefix) +
|
||||
result +
|
||||
return Base::Tools::toStdString(formatPrefix) +
|
||||
formattedValueString +
|
||||
Base::Tools::toStdString(qUserStringUnits) +
|
||||
Base::Tools::toStdString(formatSuffix);
|
||||
}
|
||||
} else {
|
||||
result = Base::Tools::toStdString(formatPrefix) +
|
||||
result +
|
||||
return Base::Tools::toStdString(formatPrefix) +
|
||||
formattedValueString +
|
||||
Base::Tools::toStdString(formatSuffix);
|
||||
}
|
||||
}
|
||||
@@ -981,28 +973,27 @@ std::string DrawViewDimension::formatValue(qreal value,
|
||||
QRegExp space(QString::fromUtf8("\\s"));
|
||||
qUserStringUnits.remove(space);
|
||||
}
|
||||
result = Base::Tools::toStdString(qUserStringUnits);
|
||||
return Base::Tools::toStdString(qUserStringUnits);
|
||||
} else if (showUnits()) {
|
||||
result = Base::Tools::toStdString(qUserStringUnits);
|
||||
return Base::Tools::toStdString(qUserStringUnits);
|
||||
} else {
|
||||
result = "";
|
||||
return "";
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
return formattedValueString;
|
||||
}
|
||||
|
||||
bool DrawViewDimension::haveTolerance(void)
|
||||
{
|
||||
bool result = false;
|
||||
//if a numeric tolerance is specified AND
|
||||
//tolerances are NOT arbitrary
|
||||
if ((!DrawUtil::fpCompare(OverTolerance.getValue(), 0.0) ||
|
||||
!DrawUtil::fpCompare(UnderTolerance.getValue(), 0.0)) &&
|
||||
!ArbitraryTolerances.getValue()){
|
||||
result = true;
|
||||
return true;
|
||||
}
|
||||
return result;
|
||||
return false;
|
||||
}
|
||||
|
||||
std::string DrawViewDimension::getFormattedToleranceValue(int partial)
|
||||
@@ -1097,22 +1088,21 @@ std::string DrawViewDimension::getFormattedDimensionValue(int partial)
|
||||
2,
|
||||
false).c_str()); //just the unit
|
||||
QString tolerance = QString::fromStdString(getFormattedToleranceValue(1).c_str());
|
||||
QString result;
|
||||
|
||||
// tolerance might start with a plus sign that we don't want, so cut it off
|
||||
// note plus sign is not at pos = 0!
|
||||
QRegExp plus(QString::fromUtf8("^\\s*\\+"));
|
||||
tolerance.remove(plus);
|
||||
|
||||
result = labelText +
|
||||
return (labelText +
|
||||
QString::fromUtf8(" \xC2\xB1 ") + // +/- symbol
|
||||
tolerance;
|
||||
tolerance).toStdString();
|
||||
|
||||
if (partial == 2) {
|
||||
result = unitText;
|
||||
return unitText.toStdString();
|
||||
}
|
||||
|
||||
return result.toStdString();
|
||||
return "";
|
||||
}
|
||||
|
||||
//tolerance not specified, so just format dimension value?
|
||||
@@ -1124,17 +1114,14 @@ std::string DrawViewDimension::getFormattedDimensionValue(int partial)
|
||||
QStringList DrawViewDimension::getPrefixSuffixSpec(QString fSpec)
|
||||
{
|
||||
QStringList result;
|
||||
QString formatPrefix;
|
||||
QString formatSuffix;
|
||||
//find the %x.y tag in FormatSpec
|
||||
QRegExp rxFormat(QStringLiteral("%[+-]?[0-9]*\\.*[0-9]*[aefgwAEFGW]")); //printf double format spec
|
||||
QString match;
|
||||
int pos = 0;
|
||||
if ((pos = rxFormat.indexIn(fSpec, 0)) != -1) {
|
||||
match = rxFormat.cap(0); //entire capture of rx
|
||||
formatPrefix = fSpec.left(pos);
|
||||
int pos = rxFormat.indexIn(fSpec, 0);
|
||||
if (pos != -1) {
|
||||
QString match = rxFormat.cap(0); //entire capture of rx
|
||||
QString formatPrefix = fSpec.left(pos);
|
||||
result.append(formatPrefix);
|
||||
formatSuffix = fSpec.right(fSpec.size() - pos - match.size());
|
||||
QString formatSuffix = fSpec.right(fSpec.size() - pos - match.size());
|
||||
result.append(formatSuffix);
|
||||
result.append(match);
|
||||
} else { //printf format not found!
|
||||
@@ -1214,7 +1201,8 @@ double DrawViewDimension::getDimValue()
|
||||
arcPoints pts = m_arcPoints;
|
||||
result = (pts.radius * 2.0) / getViewPart()->getScale(); //Projected BaseGeom is scaled for drawing
|
||||
|
||||
} else if (Type.isValue("Angle")){
|
||||
} else if (Type.isValue("Angle") ||
|
||||
Type.isValue("Angle3Pt")) { //same as case "Angle"?
|
||||
anglePoints pts = m_anglePoints;
|
||||
Base::Vector3d vertex = pts.vertex;
|
||||
Base::Vector3d leg0 = pts.ends.first - vertex;
|
||||
@@ -1222,13 +1210,6 @@ double DrawViewDimension::getDimValue()
|
||||
double legAngle = leg0.GetAngle(leg1) * 180.0 / M_PI;
|
||||
result = legAngle;
|
||||
|
||||
} else if (Type.isValue("Angle3Pt")){ //same as case "Angle"?
|
||||
anglePoints pts = m_anglePoints;
|
||||
Base::Vector3d vertex = pts.vertex;
|
||||
Base::Vector3d leg0 = pts.ends.first - vertex;
|
||||
Base::Vector3d leg1 = pts.ends.second - vertex;
|
||||
double legAngle = leg0.GetAngle(leg1) * 180.0 / M_PI;
|
||||
result = legAngle;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1247,22 +1228,18 @@ double DrawViewDimension::getDimValue()
|
||||
pointPair DrawViewDimension::getPointsOneEdge()
|
||||
{
|
||||
// Base::Console().Message("DVD::getPointsOneEdge() - %s\n",getNameInDocument());
|
||||
pointPair result;
|
||||
const std::vector<std::string> &subElements = References2D.getSubValues();
|
||||
|
||||
//TODO: Check for straight line Edge?
|
||||
int idx = DrawUtil::getIndexFromName(subElements[0]);
|
||||
TechDraw::BaseGeomPtr geom = getViewPart()->getGeomByIndex(idx);
|
||||
TechDraw::GenericPtr gen;
|
||||
if (geom && geom->geomType == TechDraw::GeomType::GENERIC) {
|
||||
gen = std::static_pointer_cast<TechDraw::Generic>(geom);
|
||||
} else {
|
||||
if (!geom || geom->geomType != TechDraw::GeomType::GENERIC) {
|
||||
Base::Console().Error("Error: DVD - %s - 2D references are corrupt (1)\n",getNameInDocument());
|
||||
return result;
|
||||
return pointPair();
|
||||
}
|
||||
result.first = gen->points[0];
|
||||
result.second = gen->points[1];
|
||||
return result;
|
||||
|
||||
TechDraw::GenericPtr gen = std::static_pointer_cast<TechDraw::Generic>(geom);
|
||||
return pointPair(gen->points[0], gen->points[1]);
|
||||
}
|
||||
|
||||
pointPair DrawViewDimension::getPointsTwoEdges()
|
||||
@@ -1363,40 +1340,38 @@ int DrawViewDimension::getRefTypeSubElements(const std::vector<std::string> &sub
|
||||
bool DrawViewDimension::checkReferences2D() const
|
||||
{
|
||||
// Base::Console().Message("DVD::checkReFerences2d() - %s\n",getNameInDocument());
|
||||
bool result = true;
|
||||
const std::vector<App::DocumentObject*> &objects = References2D.getValues();
|
||||
if (!objects.empty()) {
|
||||
const std::vector<std::string> &subElements = References2D.getSubValues();
|
||||
if (!subElements.empty()) {
|
||||
for (auto& s: subElements) {
|
||||
if (!s.empty()) {
|
||||
int idx = DrawUtil::getIndexFromName(s);
|
||||
if (DrawUtil::getGeomTypeFromName(s) == "Edge") {
|
||||
TechDraw::BaseGeomPtr geom = getViewPart()->getGeomByIndex(idx);
|
||||
if (!geom) {
|
||||
result = false;
|
||||
break;
|
||||
}
|
||||
} else if (DrawUtil::getGeomTypeFromName(s) == "Vertex") {
|
||||
TechDraw::VertexPtr v = getViewPart()->getProjVertexByIndex(idx);
|
||||
if (!v) {
|
||||
result = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
result = false;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
Base::Console().Log("DVD::checkRegerences2d() - %s - subelements empty!\n",getNameInDocument());
|
||||
result = false;
|
||||
}
|
||||
} else {
|
||||
Base::Console().Log("DVD::checkRegerences2d() - %s - objects empty!\n",getNameInDocument());
|
||||
result = false;
|
||||
if (objects.empty()) {
|
||||
Base::Console().Log("DVD::checkReferences2d() - %s - objects empty!\n",getNameInDocument());
|
||||
return false;
|
||||
}
|
||||
return result;
|
||||
|
||||
const std::vector<std::string> &subElements = References2D.getSubValues();
|
||||
if (subElements.empty()) {
|
||||
Base::Console().Log("DVD::checkRegerences2d() - %s - subelements empty!\n",getNameInDocument());
|
||||
return false;
|
||||
}
|
||||
|
||||
for (auto& s: subElements) {
|
||||
if (s.empty()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
int idx = DrawUtil::getIndexFromName(s);
|
||||
if (DrawUtil::getGeomTypeFromName(s) == "Edge") {
|
||||
TechDraw::BaseGeomPtr geom = getViewPart()->getGeomByIndex(idx);
|
||||
if (!geom) {
|
||||
return false;
|
||||
}
|
||||
} else if (DrawUtil::getGeomTypeFromName(s) == "Vertex") {
|
||||
TechDraw::VertexPtr v = getViewPart()->getProjVertexByIndex(idx);
|
||||
if (!v) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
pointPair DrawViewDimension::closestPoints(TopoDS_Shape s1,
|
||||
@@ -1527,25 +1502,19 @@ pointPair DrawViewDimension::getArrowPositions(void)
|
||||
bool DrawViewDimension::has2DReferences(void) const
|
||||
{
|
||||
// Base::Console().Message("DVD::has2DReferences() - %s\n",getNameInDocument());
|
||||
bool result = false;
|
||||
|
||||
const std::vector<App::DocumentObject*> &objects = References2D.getValues();
|
||||
const std::vector<std::string> &SubNames = References2D.getSubValues();
|
||||
if (!objects.empty()) {
|
||||
App::DocumentObject* testRef = objects.at(0);
|
||||
if (testRef) {
|
||||
if (!SubNames.empty()) {
|
||||
result = true; //not empty is good
|
||||
for (auto& s: SubNames) { //but check individual entries
|
||||
if (s.empty()) {
|
||||
result = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (objects.empty() || SubNames.empty()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
for (auto& s: SubNames) { // Check individual entries
|
||||
if (s.empty()) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return result;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool DrawViewDimension::has3DReferences(void) const
|
||||
@@ -1556,22 +1525,19 @@ bool DrawViewDimension::has3DReferences(void) const
|
||||
//has arbitrary or nonzero tolerance
|
||||
bool DrawViewDimension::hasOverUnderTolerance(void) const
|
||||
{
|
||||
bool result = false;
|
||||
if (ArbitraryTolerances.getValue() ||
|
||||
!DrawUtil::fpCompare(OverTolerance.getValue(), 0.0) ||
|
||||
!DrawUtil::fpCompare(UnderTolerance.getValue(), 0.0)) {
|
||||
result = true;
|
||||
return true;
|
||||
}
|
||||
return result;
|
||||
return false;
|
||||
}
|
||||
|
||||
bool DrawViewDimension::showUnits() const
|
||||
{
|
||||
bool result = false;
|
||||
Base::Reference<ParameterGrp> hGrp = App::GetApplication().GetUserParameter()
|
||||
.GetGroup("BaseApp")->GetGroup("Preferences")->GetGroup("Mod/TechDraw/Dimensions");
|
||||
result = hGrp->GetBool("ShowUnits", false);
|
||||
return result;
|
||||
return hGrp->GetBool("ShowUnits", false);
|
||||
}
|
||||
|
||||
bool DrawViewDimension::useDecimals() const
|
||||
@@ -1581,26 +1547,15 @@ bool DrawViewDimension::useDecimals() const
|
||||
|
||||
std::string DrawViewDimension::getPrefix() const
|
||||
{
|
||||
std::string result = "";
|
||||
if (Type.isValue("Distance")) {
|
||||
result = "";
|
||||
} else if (Type.isValue("DistanceX")){
|
||||
result = "";
|
||||
} else if (Type.isValue("DistanceY")){
|
||||
result = "";
|
||||
} else if (Type.isValue("DistanceZ")){
|
||||
result = "";
|
||||
} else if (Type.isValue("Radius")){
|
||||
result = "R";
|
||||
if (Type.isValue("Radius")){
|
||||
return "R";
|
||||
} else if (Type.isValue("Diameter")){
|
||||
Base::Reference<ParameterGrp> hGrp = App::GetApplication().GetUserParameter()
|
||||
.GetGroup("BaseApp")->GetGroup("Preferences")->GetGroup("Mod/TechDraw/Dimensions");
|
||||
std::string diamSym = hGrp->GetASCII("DiameterSymbol","\xe2\x8c\x80");
|
||||
result = diamSym;
|
||||
} else if (Type.isValue("Angle")){
|
||||
result = "";
|
||||
return std::string(hGrp->GetASCII("DiameterSymbol","\xe2\x8c\x80")); // Diameter symbol
|
||||
}
|
||||
return result;
|
||||
|
||||
return "";
|
||||
}
|
||||
|
||||
std::string DrawViewDimension::getDefaultFormatSpec(bool isToleranceFormat) const
|
||||
|
||||
@@ -69,19 +69,17 @@ DrawViewDraft::~DrawViewDraft()
|
||||
|
||||
short DrawViewDraft::mustExecute() const
|
||||
{
|
||||
short result = 0;
|
||||
if (!isRestoring()) {
|
||||
result = Source.isTouched() ||
|
||||
LineWidth.isTouched() ||
|
||||
FontSize.isTouched() ||
|
||||
Direction.isTouched() ||
|
||||
Color.isTouched() ||
|
||||
LineStyle.isTouched() ||
|
||||
LineSpacing.isTouched() ||
|
||||
OverrideStyle.isTouched();
|
||||
}
|
||||
if ((bool) result) {
|
||||
return result;
|
||||
if(Source.isTouched() ||
|
||||
LineWidth.isTouched() ||
|
||||
FontSize.isTouched() ||
|
||||
Direction.isTouched() ||
|
||||
Color.isTouched() ||
|
||||
LineStyle.isTouched() ||
|
||||
LineSpacing.isTouched() ||
|
||||
OverrideStyle.isTouched()) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return DrawViewSymbol::mustExecute();
|
||||
}
|
||||
|
||||
@@ -88,15 +88,13 @@ void DrawViewImage::onChanged(const App::Property* prop)
|
||||
|
||||
short DrawViewImage::mustExecute() const
|
||||
{
|
||||
short result = 0;
|
||||
if (!isRestoring()) {
|
||||
result = (Height.isTouched() ||
|
||||
Width.isTouched());
|
||||
if (Height.isTouched() ||
|
||||
Width.isTouched()) {
|
||||
return true;
|
||||
};
|
||||
}
|
||||
|
||||
if (result) {
|
||||
return result;
|
||||
}
|
||||
return App::DocumentObject::mustExecute();
|
||||
}
|
||||
|
||||
@@ -108,8 +106,7 @@ App::DocumentObjectExecReturn *DrawViewImage::execute(void)
|
||||
|
||||
QRectF DrawViewImage::getRect() const
|
||||
{
|
||||
QRectF result(0.0,0.0,Width.getValue(),Height.getValue());
|
||||
return result;
|
||||
return QRectF(0.0,0.0,Width.getValue(), Height.getValue());
|
||||
}
|
||||
|
||||
void DrawViewImage::replaceImageIncluded(std::string newFileName)
|
||||
@@ -138,14 +135,18 @@ void DrawViewImage::setupImageIncluded(void)
|
||||
DrawUtil::copyFile(std::string(), imageName);
|
||||
ImageIncluded.setValue(imageName.c_str());
|
||||
|
||||
if (!ImageFile.isEmpty()) {
|
||||
Base::FileInfo fi(ImageFile.getValue());
|
||||
if (fi.isReadable()) {
|
||||
std::string exchName = ImageIncluded.getExchangeTempFile();
|
||||
DrawUtil::copyFile(ImageFile.getValue(), exchName);
|
||||
ImageIncluded.setValue(exchName.c_str(), special.c_str());
|
||||
}
|
||||
if (ImageFile.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
|
||||
Base::FileInfo fi(ImageFile.getValue());
|
||||
if (!fi.isReadable()) {
|
||||
return;
|
||||
}
|
||||
|
||||
std::string exchName = ImageIncluded.getExchangeTempFile();
|
||||
DrawUtil::copyFile(ImageFile.getValue(), exchName);
|
||||
ImageIncluded.setValue(exchName.c_str(), special.c_str());
|
||||
}
|
||||
|
||||
// Python Drawing feature ---------------------------------------------------------
|
||||
|
||||
@@ -94,13 +94,10 @@ DrawViewMulti::~DrawViewMulti()
|
||||
|
||||
short DrawViewMulti::mustExecute() const
|
||||
{
|
||||
short result = 0;
|
||||
if (!isRestoring()) {
|
||||
result = (Sources.isTouched());
|
||||
}
|
||||
if (result) {
|
||||
return result;
|
||||
if (!isRestoring() && Sources.isTouched()) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return TechDraw::DrawViewPart::mustExecute();
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user