+ fix possible crashes in mirror and polar pattern feature
This commit is contained in:
parent
aaeba38e78
commit
e47b85994c
|
@ -41,6 +41,7 @@
|
|||
#include "FeatureSubtractive.h"
|
||||
#include "FeatureMirrored.h"
|
||||
#include "FeatureLinearPattern.h"
|
||||
#include "FeaturePolarPattern.h"
|
||||
|
||||
#include <Base/Console.h>
|
||||
#include <Base/Exception.h>
|
||||
|
@ -87,6 +88,16 @@ App::DocumentObject* Transformed::getSketchObject() const
|
|||
const LinearPattern* pattern = static_cast<const LinearPattern*>(this);
|
||||
return pattern->Direction.getValue();
|
||||
}
|
||||
else if (this->getTypeId().isDerivedFrom(PolarPattern::getClassTypeId())) {
|
||||
// if Originals is empty then try the polar pattern's Axis property
|
||||
const PolarPattern* pattern = static_cast<const PolarPattern*>(this);
|
||||
return pattern->Axis.getValue();
|
||||
}
|
||||
else if (this->getTypeId().isDerivedFrom(Mirrored::getClassTypeId())) {
|
||||
// if Originals is empty then try the mirror pattern's MirrorPlane property
|
||||
const Mirrored* pattern = static_cast<const Mirrored*>(this);
|
||||
return pattern->MirrorPlane.getValue();
|
||||
}
|
||||
else {
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -429,10 +429,10 @@ bool TaskDlgLinearPatternParameters::accept()
|
|||
else
|
||||
sketch = linearpatternParameter->getSupportObject();
|
||||
|
||||
QString buf = QString::fromUtf8("(App.ActiveDocument.%1,[\"%2\"])");
|
||||
if (sketch) {
|
||||
QString buf = QString::fromLatin1("(App.ActiveDocument.%1,[\"%2\"])");
|
||||
buf = buf.arg(QString::fromLatin1(sketch->getNameInDocument()));
|
||||
buf = buf.arg(QString::fromUtf8(direction.c_str()));
|
||||
buf = buf.arg(QString::fromLatin1(direction.c_str()));
|
||||
Gui::Command::doCommand(Gui::Command::Doc,"App.ActiveDocument.%s.Direction = %s", name.c_str(), buf.toStdString().c_str());
|
||||
}
|
||||
} else
|
||||
|
|
|
@ -333,14 +333,19 @@ bool TaskDlgMirroredParameters::accept()
|
|||
TaskMirroredParameters* mirrorParameter = static_cast<TaskMirroredParameters*>(parameter);
|
||||
std::string mirrorPlane = mirrorParameter->getMirrorPlane();
|
||||
if (!mirrorPlane.empty()) {
|
||||
QString buf = QString::fromUtf8("(App.ActiveDocument.%1,[\"%2\"])");
|
||||
App::DocumentObject* sketch = 0;
|
||||
if (mirrorPlane == "H_Axis" || mirrorPlane == "V_Axis" ||
|
||||
(mirrorPlane.size() > 4 && mirrorPlane.substr(0,4) == "Axis"))
|
||||
buf = buf.arg(QString::fromUtf8(mirrorParameter->getSketchObject()->getNameInDocument()));
|
||||
sketch = mirrorParameter->getSketchObject();
|
||||
else
|
||||
buf = buf.arg(QString::fromUtf8(mirrorParameter->getSupportObject()->getNameInDocument()));
|
||||
buf = buf.arg(QString::fromUtf8(mirrorPlane.c_str()));
|
||||
Gui::Command::doCommand(Gui::Command::Doc,"App.ActiveDocument.%s.MirrorPlane = %s", name.c_str(), buf.toStdString().c_str());
|
||||
sketch = mirrorParameter->getSupportObject();
|
||||
|
||||
if (sketch) {
|
||||
QString buf = QString::fromLatin1("(App.ActiveDocument.%1,[\"%2\"])");
|
||||
buf = buf.arg(QString::fromLatin1(sketch->getNameInDocument()));
|
||||
buf = buf.arg(QString::fromLatin1(mirrorPlane.c_str()));
|
||||
Gui::Command::doCommand(Gui::Command::Doc,"App.ActiveDocument.%s.MirrorPlane = %s", name.c_str(), buf.toStdString().c_str());
|
||||
}
|
||||
} else
|
||||
Gui::Command::doCommand(Gui::Command::Doc,"App.ActiveDocument.%s.MirrorPlane = None", name.c_str());
|
||||
Gui::Command::doCommand(Gui::Command::Doc,"App.ActiveDocument.recompute()");
|
||||
|
|
|
@ -370,13 +370,18 @@ bool TaskDlgPolarPatternParameters::accept()
|
|||
TaskPolarPatternParameters* polarpatternParameter = static_cast<TaskPolarPatternParameters*>(parameter);
|
||||
std::string axis = polarpatternParameter->getAxis();
|
||||
if (!axis.empty()) {
|
||||
QString buf = QString::fromUtf8("(App.ActiveDocument.%1,[\"%2\"])");
|
||||
App::DocumentObject* sketch = 0;
|
||||
if (axis == "N_Axis")
|
||||
buf = buf.arg(QString::fromUtf8(polarpatternParameter->getSketchObject()->getNameInDocument()));
|
||||
sketch = polarpatternParameter->getSketchObject();
|
||||
else
|
||||
buf = buf.arg(QString::fromUtf8(polarpatternParameter->getSupportObject()->getNameInDocument()));
|
||||
buf = buf.arg(QString::fromUtf8(axis.c_str()));
|
||||
Gui::Command::doCommand(Gui::Command::Doc,"App.ActiveDocument.%s.Axis = %s", name.c_str(), buf.toStdString().c_str());
|
||||
sketch = polarpatternParameter->getSupportObject();
|
||||
|
||||
if (sketch) {
|
||||
QString buf = QString::fromLatin1("(App.ActiveDocument.%1,[\"%2\"])");
|
||||
buf = buf.arg(QString::fromLatin1(sketch->getNameInDocument()));
|
||||
buf = buf.arg(QString::fromLatin1(axis.c_str()));
|
||||
Gui::Command::doCommand(Gui::Command::Doc,"App.ActiveDocument.%s.Axis = %s", name.c_str(), buf.toStdString().c_str());
|
||||
}
|
||||
} else
|
||||
Gui::Command::doCommand(Gui::Command::Doc,"App.ActiveDocument.%s.Axis = None", name.c_str());
|
||||
Gui::Command::doCommand(Gui::Command::Doc,"App.ActiveDocument.%s.Reversed = %u",name.c_str(),polarpatternParameter->getReverse());
|
||||
|
|
Loading…
Reference in New Issue
Block a user