PartDesign: fix bug in checkbox "Update View" of pattern features and do some code refactoring
This commit is contained in:
parent
e1727b6c16
commit
f0917eff39
|
@ -29,6 +29,7 @@
|
||||||
|
|
||||||
#include "ui_TaskLinearPatternParameters.h"
|
#include "ui_TaskLinearPatternParameters.h"
|
||||||
#include "TaskLinearPatternParameters.h"
|
#include "TaskLinearPatternParameters.h"
|
||||||
|
#include "TaskMultiTransformParameters.h"
|
||||||
#include <App/Application.h>
|
#include <App/Application.h>
|
||||||
#include <App/Document.h>
|
#include <App/Document.h>
|
||||||
#include <Gui/Application.h>
|
#include <Gui/Application.h>
|
||||||
|
@ -41,7 +42,6 @@
|
||||||
#include <Gui/Command.h>
|
#include <Gui/Command.h>
|
||||||
#include <Mod/PartDesign/App/FeatureLinearPattern.h>
|
#include <Mod/PartDesign/App/FeatureLinearPattern.h>
|
||||||
#include <Mod/Sketcher/App/SketchObject.h>
|
#include <Mod/Sketcher/App/SketchObject.h>
|
||||||
#include "TaskMultiTransformParameters.h"
|
|
||||||
|
|
||||||
using namespace PartDesignGui;
|
using namespace PartDesignGui;
|
||||||
using namespace Gui;
|
using namespace Gui;
|
||||||
|
@ -64,7 +64,7 @@ TaskLinearPatternParameters::TaskLinearPatternParameters(ViewProviderTransformed
|
||||||
|
|
||||||
referenceSelectionMode = false;
|
referenceSelectionMode = false;
|
||||||
|
|
||||||
updateUIinProgress = false; // Hack, sometimes it is NOT false although set to false in Transformed::Transformed()!!
|
blockUpdate = false; // Hack, sometimes it is NOT false although set to false in Transformed::Transformed()!!
|
||||||
setupUI();
|
setupUI();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -87,7 +87,7 @@ TaskLinearPatternParameters::TaskLinearPatternParameters(TaskMultiTransformParam
|
||||||
|
|
||||||
referenceSelectionMode = false;
|
referenceSelectionMode = false;
|
||||||
|
|
||||||
updateUIinProgress = false; // Hack, sometimes it is NOT false although set to false in Transformed::Transformed()!!
|
blockUpdate = false; // Hack, sometimes it is NOT false although set to false in Transformed::Transformed()!!
|
||||||
setupUI();
|
setupUI();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -138,9 +138,9 @@ void TaskLinearPatternParameters::setupUI()
|
||||||
|
|
||||||
void TaskLinearPatternParameters::updateUI()
|
void TaskLinearPatternParameters::updateUI()
|
||||||
{
|
{
|
||||||
if (updateUIinProgress)
|
if (blockUpdate)
|
||||||
return;
|
return;
|
||||||
updateUIinProgress = true;
|
blockUpdate = true;
|
||||||
|
|
||||||
PartDesign::LinearPattern* pcLinearPattern = static_cast<PartDesign::LinearPattern*>(getObject());
|
PartDesign::LinearPattern* pcLinearPattern = static_cast<PartDesign::LinearPattern*>(getObject());
|
||||||
|
|
||||||
|
@ -177,39 +177,45 @@ void TaskLinearPatternParameters::updateUI()
|
||||||
ui->lineReference->setText(tr("Select an edge or a face"));
|
ui->lineReference->setText(tr("Select an edge or a face"));
|
||||||
|
|
||||||
// Note: These three lines would trigger onLength(), on Occurrences() and another updateUI() if we
|
// Note: These three lines would trigger onLength(), on Occurrences() and another updateUI() if we
|
||||||
// didn't check for updateUIinProgress
|
// didn't check for blockUpdate
|
||||||
ui->checkReverse->setChecked(reverse);
|
ui->checkReverse->setChecked(reverse);
|
||||||
ui->spinLength->setValue(length);
|
ui->spinLength->setValue(length);
|
||||||
ui->spinOccurrences->setValue(occurrences);
|
ui->spinOccurrences->setValue(occurrences);
|
||||||
|
|
||||||
updateUIinProgress = false;
|
blockUpdate = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void TaskLinearPatternParameters::onSelectionChanged(const Gui::SelectionChanges& msg)
|
void TaskLinearPatternParameters::onSelectionChanged(const Gui::SelectionChanges& msg)
|
||||||
{
|
{
|
||||||
if (msg.Type == Gui::SelectionChanges::AddSelection) {
|
if (msg.Type == Gui::SelectionChanges::AddSelection) {
|
||||||
|
|
||||||
|
if (strcmp(msg.pDocName, getObject()->getDocument()->getName()) != 0)
|
||||||
|
return;
|
||||||
|
|
||||||
std::string subName(msg.pSubName);
|
std::string subName(msg.pSubName);
|
||||||
PartDesign::LinearPattern* pcLinearPattern = static_cast<PartDesign::LinearPattern*>(getObject());
|
if (originalSelected(msg)) {
|
||||||
if (originalSelectionMode) {
|
ui->lineOriginal->setText(QString::fromAscii(msg.pObjectName));
|
||||||
App::DocumentObject* selectedObject = pcLinearPattern->getDocument()->getActiveObject();
|
|
||||||
if ((selectedObject == NULL) || !selectedObject->isDerivedFrom(Part::Feature::getClassTypeId()))
|
|
||||||
return;
|
|
||||||
if (originalSelected(msg))
|
|
||||||
ui->lineOriginal->setText(QString::fromAscii(selectedObject->getNameInDocument()));
|
|
||||||
} else if (referenceSelectionMode &&
|
} else if (referenceSelectionMode &&
|
||||||
((subName.size() > 4 && subName.substr(0,4) == "Edge") ||
|
((subName.size() > 4 && subName.substr(0,4) == "Edge") ||
|
||||||
(subName.size() > 4 && subName.substr(0,4) == "Face"))) {
|
(subName.size() > 4 && subName.substr(0,4) == "Face"))) {
|
||||||
|
|
||||||
std::vector<std::string> directions;
|
if (strcmp(msg.pObjectName, getSupportObject()->getNameInDocument()) != 0)
|
||||||
directions.push_back(subName.c_str());
|
return;
|
||||||
pcLinearPattern->Direction.setValue(getOriginalObject(), directions);
|
|
||||||
pcLinearPattern->StdDirection.setValue("");
|
|
||||||
|
|
||||||
if (updateView())
|
|
||||||
recomputeFeature();
|
|
||||||
|
|
||||||
exitSelectionMode();
|
exitSelectionMode();
|
||||||
updateUI();
|
if (!blockUpdate) {
|
||||||
|
PartDesign::LinearPattern* pcLinearPattern = static_cast<PartDesign::LinearPattern*>(getObject());
|
||||||
|
std::vector<std::string> directions(1,subName);
|
||||||
|
pcLinearPattern->Direction.setValue(getSupportObject(), directions);
|
||||||
|
pcLinearPattern->StdDirection.setValue("");
|
||||||
|
|
||||||
|
recomputeFeature();
|
||||||
|
updateUI();
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
ui->buttonReference->setChecked(referenceSelectionMode);
|
||||||
|
ui->lineReference->setText(QString::fromAscii(subName.c_str()));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -227,43 +233,40 @@ void TaskLinearPatternParameters::onButtonZ() {
|
||||||
}
|
}
|
||||||
|
|
||||||
void TaskLinearPatternParameters::onCheckReverse(const bool on) {
|
void TaskLinearPatternParameters::onCheckReverse(const bool on) {
|
||||||
if (updateUIinProgress)
|
if (blockUpdate)
|
||||||
return;
|
return;
|
||||||
PartDesign::LinearPattern* pcLinearPattern = static_cast<PartDesign::LinearPattern*>(getObject());
|
PartDesign::LinearPattern* pcLinearPattern = static_cast<PartDesign::LinearPattern*>(getObject());
|
||||||
pcLinearPattern->Reversed.setValue(on);
|
pcLinearPattern->Reversed.setValue(on);
|
||||||
|
|
||||||
exitSelectionMode();
|
exitSelectionMode();
|
||||||
updateUI();
|
updateUI();
|
||||||
if (updateView())
|
recomputeFeature();
|
||||||
recomputeFeature();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void TaskLinearPatternParameters::onLength(const double l) {
|
void TaskLinearPatternParameters::onLength(const double l) {
|
||||||
if (updateUIinProgress)
|
if (blockUpdate)
|
||||||
return;
|
return;
|
||||||
PartDesign::LinearPattern* pcLinearPattern = static_cast<PartDesign::LinearPattern*>(getObject());
|
PartDesign::LinearPattern* pcLinearPattern = static_cast<PartDesign::LinearPattern*>(getObject());
|
||||||
pcLinearPattern->Length.setValue(l);
|
pcLinearPattern->Length.setValue(l);
|
||||||
|
|
||||||
exitSelectionMode();
|
exitSelectionMode();
|
||||||
updateUI();
|
updateUI();
|
||||||
if (updateView())
|
recomputeFeature();
|
||||||
recomputeFeature();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void TaskLinearPatternParameters::onOccurrences(const int n) {
|
void TaskLinearPatternParameters::onOccurrences(const int n) {
|
||||||
if (updateUIinProgress)
|
if (blockUpdate)
|
||||||
return;
|
return;
|
||||||
PartDesign::LinearPattern* pcLinearPattern = static_cast<PartDesign::LinearPattern*>(getObject());
|
PartDesign::LinearPattern* pcLinearPattern = static_cast<PartDesign::LinearPattern*>(getObject());
|
||||||
pcLinearPattern->Occurrences.setValue(n);
|
pcLinearPattern->Occurrences.setValue(n);
|
||||||
|
|
||||||
exitSelectionMode();
|
exitSelectionMode();
|
||||||
updateUI();
|
updateUI();
|
||||||
if (updateView())
|
recomputeFeature();
|
||||||
recomputeFeature();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void TaskLinearPatternParameters::onStdDirection(const std::string& dir) {
|
void TaskLinearPatternParameters::onStdDirection(const std::string& dir) {
|
||||||
if (updateUIinProgress)
|
if (blockUpdate)
|
||||||
return;
|
return;
|
||||||
PartDesign::LinearPattern* pcLinearPattern = static_cast<PartDesign::LinearPattern*>(getObject());
|
PartDesign::LinearPattern* pcLinearPattern = static_cast<PartDesign::LinearPattern*>(getObject());
|
||||||
pcLinearPattern->StdDirection.setValue(dir.c_str());
|
pcLinearPattern->StdDirection.setValue(dir.c_str());
|
||||||
|
@ -271,14 +274,11 @@ void TaskLinearPatternParameters::onStdDirection(const std::string& dir) {
|
||||||
|
|
||||||
exitSelectionMode();
|
exitSelectionMode();
|
||||||
updateUI();
|
updateUI();
|
||||||
if (updateView())
|
recomputeFeature();
|
||||||
recomputeFeature();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void TaskLinearPatternParameters::onButtonReference(bool checked)
|
void TaskLinearPatternParameters::onButtonReference(bool checked)
|
||||||
{
|
{
|
||||||
if (updateUIinProgress)
|
|
||||||
return;
|
|
||||||
if (checked ) {
|
if (checked ) {
|
||||||
hideObject();
|
hideObject();
|
||||||
showOriginals();
|
showOriginals();
|
||||||
|
@ -292,49 +292,46 @@ void TaskLinearPatternParameters::onButtonReference(bool checked)
|
||||||
|
|
||||||
void TaskLinearPatternParameters::onUpdateView(bool on)
|
void TaskLinearPatternParameters::onUpdateView(bool on)
|
||||||
{
|
{
|
||||||
ui->buttonX->blockSignals(!on);
|
blockUpdate = !on;
|
||||||
ui->buttonY->blockSignals(!on);
|
if (on) {
|
||||||
ui->buttonZ->blockSignals(!on);
|
// Do the same like in TaskDlgLinearPatternParameters::accept() but without doCommand
|
||||||
ui->checkReverse->blockSignals(!on);
|
PartDesign::LinearPattern* pcLinearPattern = static_cast<PartDesign::LinearPattern*>(getObject());
|
||||||
ui->spinLength->blockSignals(!on);
|
|
||||||
ui->spinOccurrences->blockSignals(!on);
|
std::string direction = getDirection();
|
||||||
|
if (!direction.empty()) {
|
||||||
|
std::vector<std::string> directions(1,direction);
|
||||||
|
pcLinearPattern->Direction.setValue(getSupportObject(), directions);
|
||||||
|
} else
|
||||||
|
pcLinearPattern->Direction.setValue(NULL);
|
||||||
|
|
||||||
|
std::string stdDirection = getStdDirection();
|
||||||
|
if (!stdDirection.empty())
|
||||||
|
pcLinearPattern->StdDirection.setValue(stdDirection.c_str());
|
||||||
|
else
|
||||||
|
pcLinearPattern->StdDirection.setValue(NULL);
|
||||||
|
|
||||||
|
pcLinearPattern->Reversed.setValue(getReverse());
|
||||||
|
pcLinearPattern->Length.setValue(getLength());
|
||||||
|
pcLinearPattern->Occurrences.setValue(getOccurrences());
|
||||||
|
|
||||||
|
recomputeFeature();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const std::string TaskLinearPatternParameters::getStdDirection(void) const
|
const std::string TaskLinearPatternParameters::getStdDirection(void) const
|
||||||
{
|
{
|
||||||
std::string stdDirection;
|
|
||||||
|
|
||||||
if (ui->buttonX->isChecked())
|
if (ui->buttonX->isChecked())
|
||||||
stdDirection = "X";
|
return std::string("X");
|
||||||
else if (ui->buttonY->isChecked())
|
else if (ui->buttonY->isChecked())
|
||||||
stdDirection = "Y";
|
return std::string("Y");
|
||||||
else if (ui->buttonZ->isChecked())
|
else if (ui->buttonZ->isChecked())
|
||||||
stdDirection = "Z";
|
return std::string("Z");
|
||||||
|
return std::string("");
|
||||||
if (!stdDirection.empty())
|
|
||||||
return std::string("\"") + stdDirection + "\"";
|
|
||||||
else
|
|
||||||
return std::string("");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const QString TaskLinearPatternParameters::getDirection(void) const
|
const std::string TaskLinearPatternParameters::getDirection(void) const
|
||||||
{
|
{
|
||||||
PartDesign::LinearPattern* pcLinearPattern = static_cast<PartDesign::LinearPattern*>(getObject());
|
return ui->lineReference->text().toStdString();
|
||||||
App::DocumentObject* feature = pcLinearPattern->Direction.getValue();
|
|
||||||
if (feature == NULL)
|
|
||||||
return QString::fromUtf8("");
|
|
||||||
std::vector<std::string> directions = pcLinearPattern->Direction.getSubValues();
|
|
||||||
QString buf;
|
|
||||||
|
|
||||||
if ((feature != NULL) && !directions.empty()) {
|
|
||||||
buf = QString::fromUtf8("(App.ActiveDocument.%1,[\"%2\"])");
|
|
||||||
buf = buf.arg(QString::fromUtf8(feature->getNameInDocument()));
|
|
||||||
buf = buf.arg(QString::fromUtf8(directions.front().c_str()));
|
|
||||||
}
|
|
||||||
else
|
|
||||||
buf = QString::fromUtf8("");
|
|
||||||
|
|
||||||
return buf;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const bool TaskLinearPatternParameters::getReverse(void) const
|
const bool TaskLinearPatternParameters::getReverse(void) const
|
||||||
|
@ -352,14 +349,6 @@ const unsigned TaskLinearPatternParameters::getOccurrences(void) const
|
||||||
return ui->spinOccurrences->value();
|
return ui->spinOccurrences->value();
|
||||||
}
|
}
|
||||||
|
|
||||||
const bool TaskLinearPatternParameters::updateView() const
|
|
||||||
{
|
|
||||||
if (insideMultiTransform)
|
|
||||||
return parentTask->updateView();
|
|
||||||
else
|
|
||||||
return ui->checkBoxUpdateView->isChecked();
|
|
||||||
}
|
|
||||||
|
|
||||||
void TaskLinearPatternParameters::exitSelectionMode()
|
void TaskLinearPatternParameters::exitSelectionMode()
|
||||||
{
|
{
|
||||||
originalSelectionMode = false;
|
originalSelectionMode = false;
|
||||||
|
@ -409,12 +398,16 @@ bool TaskDlgLinearPatternParameters::accept()
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
TaskLinearPatternParameters* linearpatternParameter = static_cast<TaskLinearPatternParameters*>(parameter);
|
TaskLinearPatternParameters* linearpatternParameter = static_cast<TaskLinearPatternParameters*>(parameter);
|
||||||
std::string direction = linearpatternParameter->getDirection().toStdString();
|
std::string direction = linearpatternParameter->getDirection();
|
||||||
if (!direction.empty())
|
if (!direction.empty()) {
|
||||||
Gui::Command::doCommand(Gui::Command::Doc,"App.ActiveDocument.%s.Direction = %s", name.c_str(), direction.c_str());
|
QString buf = QString::fromUtf8("(App.ActiveDocument.%1,[\"%2\"])");
|
||||||
|
buf = buf.arg(QString::fromUtf8(linearpatternParameter->getSupportObject()->getNameInDocument()));
|
||||||
|
buf = buf.arg(QString::fromUtf8(direction.c_str()));
|
||||||
|
Gui::Command::doCommand(Gui::Command::Doc,"App.ActiveDocument.%s.Direction = %s", name.c_str(), buf.toStdString().c_str());
|
||||||
|
} else
|
||||||
|
Gui::Command::doCommand(Gui::Command::Doc,"App.ActiveDocument.%s.Direction = None", name.c_str());
|
||||||
std::string stdDirection = linearpatternParameter->getStdDirection();
|
std::string stdDirection = linearpatternParameter->getStdDirection();
|
||||||
if (!stdDirection.empty())
|
Gui::Command::doCommand(Gui::Command::Doc,"App.ActiveDocument.%s.StdDirection = \"%s\"",name.c_str(),stdDirection.c_str());
|
||||||
Gui::Command::doCommand(Gui::Command::Doc,"App.ActiveDocument.%s.StdDirection = %s",name.c_str(),stdDirection.c_str());
|
|
||||||
Gui::Command::doCommand(Gui::Command::Doc,"App.ActiveDocument.%s.Reversed = %u",name.c_str(),linearpatternParameter->getReverse());
|
Gui::Command::doCommand(Gui::Command::Doc,"App.ActiveDocument.%s.Reversed = %u",name.c_str(),linearpatternParameter->getReverse());
|
||||||
Gui::Command::doCommand(Gui::Command::Doc,"App.ActiveDocument.%s.Length = %f",name.c_str(),linearpatternParameter->getLength());
|
Gui::Command::doCommand(Gui::Command::Doc,"App.ActiveDocument.%s.Length = %f",name.c_str(),linearpatternParameter->getLength());
|
||||||
Gui::Command::doCommand(Gui::Command::Doc,"App.ActiveDocument.%s.Occurrences = %u",name.c_str(),linearpatternParameter->getOccurrences());
|
Gui::Command::doCommand(Gui::Command::Doc,"App.ActiveDocument.%s.Occurrences = %u",name.c_str(),linearpatternParameter->getOccurrences());
|
||||||
|
|
|
@ -56,12 +56,11 @@ public:
|
||||||
TaskLinearPatternParameters(TaskMultiTransformParameters *parentTask, QLayout *layout);
|
TaskLinearPatternParameters(TaskMultiTransformParameters *parentTask, QLayout *layout);
|
||||||
virtual ~TaskLinearPatternParameters();
|
virtual ~TaskLinearPatternParameters();
|
||||||
|
|
||||||
const QString getDirection(void) const;
|
|
||||||
const std::string getStdDirection(void) const;
|
const std::string getStdDirection(void) const;
|
||||||
|
const std::string getDirection(void) const;
|
||||||
const bool getReverse(void) const;
|
const bool getReverse(void) const;
|
||||||
const double getLength(void) const;
|
const double getLength(void) const;
|
||||||
const unsigned getOccurrences(void) const;
|
const unsigned getOccurrences(void) const;
|
||||||
const bool updateView() const;
|
|
||||||
|
|
||||||
private Q_SLOTS:
|
private Q_SLOTS:
|
||||||
void onStdDirection(const std::string& dir);
|
void onStdDirection(const std::string& dir);
|
||||||
|
|
|
@ -43,7 +43,6 @@
|
||||||
#include <Mod/PartDesign/App/FeatureMirrored.h>
|
#include <Mod/PartDesign/App/FeatureMirrored.h>
|
||||||
#include <Mod/Sketcher/App/SketchObject.h>
|
#include <Mod/Sketcher/App/SketchObject.h>
|
||||||
|
|
||||||
|
|
||||||
using namespace PartDesignGui;
|
using namespace PartDesignGui;
|
||||||
using namespace Gui;
|
using namespace Gui;
|
||||||
|
|
||||||
|
@ -65,7 +64,7 @@ TaskMirroredParameters::TaskMirroredParameters(ViewProviderTransformed *Transfor
|
||||||
|
|
||||||
referenceSelectionMode = false;
|
referenceSelectionMode = false;
|
||||||
|
|
||||||
updateUIinProgress = false; // Hack, sometimes it is NOT false although set to false in Transformed::Transformed()!!
|
blockUpdate = false; // Hack, sometimes it is NOT false although set to false in Transformed::Transformed()!!
|
||||||
setupUI();
|
setupUI();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -88,7 +87,7 @@ TaskMirroredParameters::TaskMirroredParameters(TaskMultiTransformParameters *par
|
||||||
|
|
||||||
referenceSelectionMode = false;
|
referenceSelectionMode = false;
|
||||||
|
|
||||||
updateUIinProgress = false; // Hack, sometimes it is NOT false although set to false in Transformed::Transformed()!!
|
blockUpdate = false; // Hack, sometimes it is NOT false although set to false in Transformed::Transformed()!!
|
||||||
setupUI();
|
setupUI();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -130,9 +129,9 @@ void TaskMirroredParameters::setupUI()
|
||||||
|
|
||||||
void TaskMirroredParameters::updateUI()
|
void TaskMirroredParameters::updateUI()
|
||||||
{
|
{
|
||||||
if (updateUIinProgress)
|
if (blockUpdate)
|
||||||
return;
|
return;
|
||||||
updateUIinProgress = true;
|
blockUpdate = true;
|
||||||
PartDesign::Mirrored* pcMirrored = static_cast<PartDesign::Mirrored*>(getObject());
|
PartDesign::Mirrored* pcMirrored = static_cast<PartDesign::Mirrored*>(getObject());
|
||||||
App::DocumentObject* mirrorPlaneFeature = pcMirrored->MirrorPlane.getValue();
|
App::DocumentObject* mirrorPlaneFeature = pcMirrored->MirrorPlane.getValue();
|
||||||
std::vector<std::string> mirrorPlanes = pcMirrored->MirrorPlane.getSubValues();
|
std::vector<std::string> mirrorPlanes = pcMirrored->MirrorPlane.getSubValues();
|
||||||
|
@ -163,39 +162,45 @@ void TaskMirroredParameters::updateUI()
|
||||||
if (referenceSelectionMode)
|
if (referenceSelectionMode)
|
||||||
ui->lineReference->setText(tr("Select a plane"));
|
ui->lineReference->setText(tr("Select a plane"));
|
||||||
|
|
||||||
updateUIinProgress = false;
|
blockUpdate = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void TaskMirroredParameters::onSelectionChanged(const Gui::SelectionChanges& msg)
|
void TaskMirroredParameters::onSelectionChanged(const Gui::SelectionChanges& msg)
|
||||||
{
|
{
|
||||||
if (msg.Type == Gui::SelectionChanges::AddSelection) {
|
if (msg.Type == Gui::SelectionChanges::AddSelection) {
|
||||||
|
|
||||||
|
if (strcmp(msg.pDocName, getObject()->getDocument()->getName()) != 0)
|
||||||
|
return;
|
||||||
|
|
||||||
std::string subName(msg.pSubName);
|
std::string subName(msg.pSubName);
|
||||||
PartDesign::Mirrored* pcMirrored = static_cast<PartDesign::Mirrored*>(getObject());
|
if (originalSelected(msg)) {
|
||||||
if (originalSelectionMode) {
|
ui->lineOriginal->setText(QString::fromAscii(msg.pObjectName));
|
||||||
App::DocumentObject* selectedObject = pcMirrored->getDocument()->getActiveObject();
|
|
||||||
if ((selectedObject == NULL) || !selectedObject->isDerivedFrom(Part::Feature::getClassTypeId()))
|
|
||||||
return;
|
|
||||||
if (originalSelected(msg))
|
|
||||||
ui->lineOriginal->setText(QString::fromAscii(selectedObject->getNameInDocument()));
|
|
||||||
} else if (referenceSelectionMode &&
|
} else if (referenceSelectionMode &&
|
||||||
(subName.size() > 4 && subName.substr(0,4) == "Face")) {
|
(subName.size() > 4 && subName.substr(0,4) == "Face")) {
|
||||||
|
|
||||||
std::vector<std::string> mirrorPlanes;
|
if (strcmp(msg.pObjectName, getSupportObject()->getNameInDocument()) != 0)
|
||||||
mirrorPlanes.push_back(subName.c_str());
|
return;
|
||||||
pcMirrored->MirrorPlane.setValue(getOriginalObject(), mirrorPlanes);
|
|
||||||
pcMirrored->StdMirrorPlane.setValue("");
|
|
||||||
|
|
||||||
if (updateView())
|
|
||||||
recomputeFeature();
|
|
||||||
|
|
||||||
exitSelectionMode();
|
exitSelectionMode();
|
||||||
updateUI();
|
if (!blockUpdate) {
|
||||||
|
PartDesign::Mirrored* pcMirrored = static_cast<PartDesign::Mirrored*>(getObject());
|
||||||
|
std::vector<std::string> mirrorPlanes(1,subName);
|
||||||
|
pcMirrored->MirrorPlane.setValue(getSupportObject(), mirrorPlanes);
|
||||||
|
pcMirrored->StdMirrorPlane.setValue("");
|
||||||
|
|
||||||
|
recomputeFeature();
|
||||||
|
updateUI();
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
ui->buttonReference->setChecked(referenceSelectionMode);
|
||||||
|
ui->lineReference->setText(QString::fromAscii(subName.c_str()));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void TaskMirroredParameters::onStdMirrorPlane(const std::string &plane) {
|
void TaskMirroredParameters::onStdMirrorPlane(const std::string &plane) {
|
||||||
if (updateUIinProgress)
|
if (blockUpdate)
|
||||||
return;
|
return;
|
||||||
PartDesign::Mirrored* pcMirrored = static_cast<PartDesign::Mirrored*>(getObject());
|
PartDesign::Mirrored* pcMirrored = static_cast<PartDesign::Mirrored*>(getObject());
|
||||||
pcMirrored->StdMirrorPlane.setValue(plane.c_str());
|
pcMirrored->StdMirrorPlane.setValue(plane.c_str());
|
||||||
|
@ -203,8 +208,7 @@ void TaskMirroredParameters::onStdMirrorPlane(const std::string &plane) {
|
||||||
|
|
||||||
exitSelectionMode();
|
exitSelectionMode();
|
||||||
updateUI();
|
updateUI();
|
||||||
if (updateView())
|
recomputeFeature();
|
||||||
recomputeFeature();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void TaskMirroredParameters::onButtonXY() {
|
void TaskMirroredParameters::onButtonXY() {
|
||||||
|
@ -221,8 +225,6 @@ void TaskMirroredParameters::onButtonYZ() {
|
||||||
|
|
||||||
void TaskMirroredParameters::onButtonReference(bool checked)
|
void TaskMirroredParameters::onButtonReference(bool checked)
|
||||||
{
|
{
|
||||||
if (updateUIinProgress)
|
|
||||||
return;
|
|
||||||
if (checked ) {
|
if (checked ) {
|
||||||
hideObject();
|
hideObject();
|
||||||
showOriginals();
|
showOriginals();
|
||||||
|
@ -236,54 +238,42 @@ void TaskMirroredParameters::onButtonReference(bool checked)
|
||||||
|
|
||||||
void TaskMirroredParameters::onUpdateView(bool on)
|
void TaskMirroredParameters::onUpdateView(bool on)
|
||||||
{
|
{
|
||||||
ui->buttonXY->blockSignals(!on);
|
blockUpdate = !on;
|
||||||
ui->buttonYZ->blockSignals(!on);
|
if (on) {
|
||||||
ui->buttonXZ->blockSignals(!on);
|
// Do the same like in TaskDlgMirroredParameters::accept() but without doCommand
|
||||||
|
PartDesign::Mirrored* pcMirrored = static_cast<PartDesign::Mirrored*>(getObject());
|
||||||
|
|
||||||
|
std::string mirrorPlane = getMirrorPlane();
|
||||||
|
if (!mirrorPlane.empty()) {
|
||||||
|
std::vector<std::string> planes(1,mirrorPlane);
|
||||||
|
pcMirrored->MirrorPlane.setValue(getSupportObject(),planes);
|
||||||
|
} else
|
||||||
|
pcMirrored->MirrorPlane.setValue(NULL);
|
||||||
|
|
||||||
|
std::string stdMirrorPlane = getStdMirrorPlane();
|
||||||
|
if (!stdMirrorPlane.empty())
|
||||||
|
pcMirrored->StdMirrorPlane.setValue(stdMirrorPlane.c_str());
|
||||||
|
else
|
||||||
|
pcMirrored->StdMirrorPlane.setValue(NULL);
|
||||||
|
|
||||||
|
recomputeFeature();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const std::string TaskMirroredParameters::getStdMirrorPlane(void) const
|
const std::string TaskMirroredParameters::getStdMirrorPlane(void) const
|
||||||
{
|
{
|
||||||
std::string stdMirrorPlane;
|
|
||||||
|
|
||||||
if (ui->buttonXY->isChecked())
|
if (ui->buttonXY->isChecked())
|
||||||
stdMirrorPlane = "XY";
|
return std::string("XY");
|
||||||
else if (ui->buttonYZ->isChecked())
|
else if (ui->buttonYZ->isChecked())
|
||||||
stdMirrorPlane = "YZ";
|
return std::string("YZ");
|
||||||
else if (ui->buttonXZ->isChecked())
|
else if (ui->buttonXZ->isChecked())
|
||||||
stdMirrorPlane = "XZ";
|
return std::string("XZ");
|
||||||
|
return std::string("");
|
||||||
if (!stdMirrorPlane.empty())
|
|
||||||
return std::string("\"") + stdMirrorPlane + "\"";
|
|
||||||
else
|
|
||||||
return std::string("");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const QString TaskMirroredParameters::getMirrorPlane(void) const
|
const std::string TaskMirroredParameters::getMirrorPlane(void) const
|
||||||
{
|
{
|
||||||
PartDesign::Mirrored* pcMirrored = static_cast<PartDesign::Mirrored*>(getObject());
|
return ui->lineReference->text().toStdString();
|
||||||
App::DocumentObject* feature = pcMirrored->MirrorPlane.getValue();
|
|
||||||
if (feature == NULL)
|
|
||||||
return QString::fromUtf8("");
|
|
||||||
std::vector<std::string> mirrorPlanes = pcMirrored->MirrorPlane.getSubValues();
|
|
||||||
QString buf;
|
|
||||||
|
|
||||||
if ((feature != NULL) && !mirrorPlanes.empty()) {
|
|
||||||
buf = QString::fromUtf8("(App.ActiveDocument.%1,[\"%2\"])");
|
|
||||||
buf = buf.arg(QString::fromUtf8(feature->getNameInDocument()));
|
|
||||||
buf = buf.arg(QString::fromUtf8(mirrorPlanes.front().c_str()));
|
|
||||||
}
|
|
||||||
else
|
|
||||||
buf = QString::fromUtf8("");
|
|
||||||
|
|
||||||
return buf;
|
|
||||||
}
|
|
||||||
|
|
||||||
const bool TaskMirroredParameters::updateView() const
|
|
||||||
{
|
|
||||||
if (insideMultiTransform)
|
|
||||||
return parentTask->updateView();
|
|
||||||
else
|
|
||||||
return ui->checkBoxUpdateView->isChecked();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void TaskMirroredParameters::exitSelectionMode()
|
void TaskMirroredParameters::exitSelectionMode()
|
||||||
|
@ -335,12 +325,16 @@ bool TaskDlgMirroredParameters::accept()
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
TaskMirroredParameters* mirrorParameter = static_cast<TaskMirroredParameters*>(parameter);
|
TaskMirroredParameters* mirrorParameter = static_cast<TaskMirroredParameters*>(parameter);
|
||||||
std::string mirrorPlane = mirrorParameter->getMirrorPlane().toStdString();
|
std::string mirrorPlane = mirrorParameter->getMirrorPlane();
|
||||||
if (!mirrorPlane.empty())
|
if (!mirrorPlane.empty()) {
|
||||||
Gui::Command::doCommand(Gui::Command::Doc,"App.ActiveDocument.%s.MirrorPlane = %s", name.c_str(), mirrorPlane.c_str());
|
QString buf = QString::fromUtf8("(App.ActiveDocument.%1,[\"%2\"])");
|
||||||
|
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());
|
||||||
|
} else
|
||||||
|
Gui::Command::doCommand(Gui::Command::Doc,"App.ActiveDocument.%s.MirrorPlane = None", name.c_str());
|
||||||
std::string stdMirrorPlane = mirrorParameter->getStdMirrorPlane();
|
std::string stdMirrorPlane = mirrorParameter->getStdMirrorPlane();
|
||||||
if (!stdMirrorPlane.empty())
|
Gui::Command::doCommand(Gui::Command::Doc,"App.ActiveDocument.%s.StdMirrorPlane = \"%s\"",name.c_str(),stdMirrorPlane.c_str());
|
||||||
Gui::Command::doCommand(Gui::Command::Doc,"App.ActiveDocument.%s.StdMirrorPlane = %s",name.c_str(),stdMirrorPlane.c_str());
|
|
||||||
Gui::Command::doCommand(Gui::Command::Doc,"App.ActiveDocument.recompute()");
|
Gui::Command::doCommand(Gui::Command::Doc,"App.ActiveDocument.recompute()");
|
||||||
if (!TransformedView->getObject()->isValid())
|
if (!TransformedView->getObject()->isValid())
|
||||||
throw Base::Exception(TransformedView->getObject()->getStatusString());
|
throw Base::Exception(TransformedView->getObject()->getStatusString());
|
||||||
|
|
|
@ -57,9 +57,8 @@ public:
|
||||||
|
|
||||||
virtual ~TaskMirroredParameters();
|
virtual ~TaskMirroredParameters();
|
||||||
|
|
||||||
const QString getMirrorPlane(void) const;
|
|
||||||
const std::string getStdMirrorPlane(void) const;
|
const std::string getStdMirrorPlane(void) const;
|
||||||
const bool updateView() const;
|
const std::string getMirrorPlane(void) const;
|
||||||
|
|
||||||
private Q_SLOTS:
|
private Q_SLOTS:
|
||||||
void onButtonXY();
|
void onButtonXY();
|
||||||
|
|
|
@ -101,8 +101,6 @@ TaskMultiTransformParameters::TaskMultiTransformParameters(ViewProviderTransform
|
||||||
this, SLOT(onMoveDown()));
|
this, SLOT(onMoveDown()));
|
||||||
ui->listTransformFeatures->addAction(action);
|
ui->listTransformFeatures->addAction(action);
|
||||||
ui->listTransformFeatures->setContextMenuPolicy(Qt::ActionsContextMenu);
|
ui->listTransformFeatures->setContextMenuPolicy(Qt::ActionsContextMenu);
|
||||||
connect(ui->checkBoxUpdateView, SIGNAL(toggled(bool)),
|
|
||||||
this, SLOT(onUpdateView(bool)));
|
|
||||||
|
|
||||||
connect(ui->listTransformFeatures, SIGNAL(activated(QModelIndex)),
|
connect(ui->listTransformFeatures, SIGNAL(activated(QModelIndex)),
|
||||||
this, SLOT(onTransformActivated(QModelIndex)));
|
this, SLOT(onTransformActivated(QModelIndex)));
|
||||||
|
@ -144,20 +142,16 @@ TaskMultiTransformParameters::TaskMultiTransformParameters(ViewProviderTransform
|
||||||
|
|
||||||
void TaskMultiTransformParameters::onSelectionChanged(const Gui::SelectionChanges& msg)
|
void TaskMultiTransformParameters::onSelectionChanged(const Gui::SelectionChanges& msg)
|
||||||
{
|
{
|
||||||
PartDesign::MultiTransform* pcMultiTransform = static_cast<PartDesign::MultiTransform*>(TransformedView->getObject());
|
if (originalSelected(msg)) {
|
||||||
App::DocumentObject* selectedObject = pcMultiTransform->getDocument()->getActiveObject();
|
App::DocumentObject* selectedObject = TransformedView->getObject()->getDocument()->getActiveObject();
|
||||||
if ((selectedObject == NULL) || !selectedObject->isDerivedFrom(Part::Feature::getClassTypeId()))
|
ui->lineOriginal->setText(QString::fromAscii(selectedObject->getNameInDocument()));
|
||||||
return;
|
|
||||||
|
|
||||||
if (originalSelectionMode) {
|
|
||||||
if (originalSelected(msg))
|
|
||||||
ui->lineOriginal->setText(QString::fromAscii(selectedObject->getNameInDocument()));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void TaskMultiTransformParameters::closeSubTask()
|
void TaskMultiTransformParameters::closeSubTask()
|
||||||
{
|
{
|
||||||
if (subTask) {
|
if (subTask) {
|
||||||
|
disconnect(ui->checkBoxUpdateView, 0, subTask, 0);
|
||||||
delete subTask;
|
delete subTask;
|
||||||
subTask = NULL;
|
subTask = NULL;
|
||||||
}
|
}
|
||||||
|
@ -175,9 +169,10 @@ void TaskMultiTransformParameters::onTransformDelete()
|
||||||
closeSubTask();
|
closeSubTask();
|
||||||
|
|
||||||
transformFeatures.erase(transformFeatures.begin() + row);
|
transformFeatures.erase(transformFeatures.begin() + row);
|
||||||
pcMultiTransform->Transformations.setValues(transformFeatures);
|
pcMultiTransform->Transformations.setValues(transformFeatures);
|
||||||
if (ui->checkBoxUpdateView->isChecked())
|
// Note: When the last transformation is deleted, recomputeFeature does nothing, because Transformed::execute()
|
||||||
pcMultiTransform->getDocument()->recomputeFeature(pcMultiTransform);
|
// says: "No transformations defined, exit silently"
|
||||||
|
recomputeFeature();
|
||||||
|
|
||||||
ui->listTransformFeatures->model()->removeRow(row);
|
ui->listTransformFeatures->model()->removeRow(row);
|
||||||
ui->listTransformFeatures->setCurrentRow(0, QItemSelectionModel::ClearAndSelect);
|
ui->listTransformFeatures->setCurrentRow(0, QItemSelectionModel::ClearAndSelect);
|
||||||
|
@ -203,6 +198,9 @@ void TaskMultiTransformParameters::onTransformEdit()
|
||||||
subTask = new TaskScaledParameters(this, ui->verticalLayout);
|
subTask = new TaskScaledParameters(this, ui->verticalLayout);
|
||||||
else
|
else
|
||||||
return; // TODO: Show an error?
|
return; // TODO: Show an error?
|
||||||
|
|
||||||
|
connect(ui->checkBoxUpdateView, SIGNAL(toggled(bool)),
|
||||||
|
subTask, SLOT(onUpdateView(bool)));
|
||||||
}
|
}
|
||||||
|
|
||||||
void TaskMultiTransformParameters::onTransformActivated(const QModelIndex& index) {
|
void TaskMultiTransformParameters::onTransformActivated(const QModelIndex& index) {
|
||||||
|
@ -300,8 +298,7 @@ void TaskMultiTransformParameters::finishAdd(std::string &newFeatName)
|
||||||
}
|
}
|
||||||
pcMultiTransform->Transformations.setValues(transformFeatures);
|
pcMultiTransform->Transformations.setValues(transformFeatures);
|
||||||
|
|
||||||
if (ui->checkBoxUpdateView->isChecked())
|
recomputeFeature();
|
||||||
pcMultiTransform->getDocument()->recomputeFeature(pcMultiTransform);
|
|
||||||
|
|
||||||
// Set state to hidden - only the MultiTransform should be visible
|
// Set state to hidden - only the MultiTransform should be visible
|
||||||
Gui::Command::doCommand(
|
Gui::Command::doCommand(
|
||||||
|
@ -341,8 +338,7 @@ void TaskMultiTransformParameters::moveTransformFeature(const int increment)
|
||||||
}
|
}
|
||||||
|
|
||||||
pcMultiTransform->Transformations.setValues(transformFeatures);
|
pcMultiTransform->Transformations.setValues(transformFeatures);
|
||||||
if (ui->checkBoxUpdateView->isChecked())
|
recomputeFeature();
|
||||||
pcMultiTransform->getDocument()->recomputeFeature(pcMultiTransform);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void TaskMultiTransformParameters::onMoveUp()
|
void TaskMultiTransformParameters::onMoveUp()
|
||||||
|
@ -359,10 +355,6 @@ void TaskMultiTransformParameters::onSubTaskButtonOK() {
|
||||||
closeSubTask();
|
closeSubTask();
|
||||||
}
|
}
|
||||||
|
|
||||||
void TaskMultiTransformParameters::onUpdateView(bool on)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
const std::vector<App::DocumentObject*> TaskMultiTransformParameters::getTransformFeatures(void) const
|
const std::vector<App::DocumentObject*> TaskMultiTransformParameters::getTransformFeatures(void) const
|
||||||
{
|
{
|
||||||
PartDesign::MultiTransform* pcMultiTransform = static_cast<PartDesign::MultiTransform*>(TransformedView->getObject());
|
PartDesign::MultiTransform* pcMultiTransform = static_cast<PartDesign::MultiTransform*>(TransformedView->getObject());
|
||||||
|
@ -385,16 +377,6 @@ void TaskMultiTransformParameters::changeEvent(QEvent *e)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void TaskMultiTransformParameters::recomputeFeature() {
|
|
||||||
PartDesign::MultiTransform* pcMultiTransform = static_cast<PartDesign::MultiTransform*>(TransformedView->getObject());
|
|
||||||
pcMultiTransform->getDocument()->recomputeFeature(pcMultiTransform);
|
|
||||||
}
|
|
||||||
|
|
||||||
const bool TaskMultiTransformParameters::updateView() const
|
|
||||||
{
|
|
||||||
return ui->checkBoxUpdateView->isChecked();
|
|
||||||
}
|
|
||||||
|
|
||||||
//**************************************************************************
|
//**************************************************************************
|
||||||
//**************************************************************************
|
//**************************************************************************
|
||||||
// TaskDialog
|
// TaskDialog
|
||||||
|
|
|
@ -62,11 +62,6 @@ public:
|
||||||
/// Return the currently active subFeature
|
/// Return the currently active subFeature
|
||||||
PartDesign::Transformed* getSubFeature(void) { return subFeature; }
|
PartDesign::Transformed* getSubFeature(void) { return subFeature; }
|
||||||
|
|
||||||
/// Recompute the feature associated with this task
|
|
||||||
void recomputeFeature();
|
|
||||||
/// Tell the subtask whether the view should be updated
|
|
||||||
const bool updateView() const;
|
|
||||||
|
|
||||||
private Q_SLOTS:
|
private Q_SLOTS:
|
||||||
void onTransformDelete();
|
void onTransformDelete();
|
||||||
void onTransformEdit();
|
void onTransformEdit();
|
||||||
|
@ -77,7 +72,6 @@ private Q_SLOTS:
|
||||||
void onTransformAddScaled();
|
void onTransformAddScaled();
|
||||||
void onMoveUp();
|
void onMoveUp();
|
||||||
void onMoveDown();
|
void onMoveDown();
|
||||||
virtual void onUpdateView(bool);
|
|
||||||
/// User finished editing a subFeature
|
/// User finished editing a subFeature
|
||||||
virtual void onSubTaskButtonOK();
|
virtual void onSubTaskButtonOK();
|
||||||
// Note: There is no Cancel button because I couldn't work out how to save the state of
|
// Note: There is no Cancel button because I couldn't work out how to save the state of
|
||||||
|
|
|
@ -29,6 +29,7 @@
|
||||||
|
|
||||||
#include "ui_TaskPolarPatternParameters.h"
|
#include "ui_TaskPolarPatternParameters.h"
|
||||||
#include "TaskPolarPatternParameters.h"
|
#include "TaskPolarPatternParameters.h"
|
||||||
|
#include "TaskMultiTransformParameters.h"
|
||||||
#include <App/Application.h>
|
#include <App/Application.h>
|
||||||
#include <App/Document.h>
|
#include <App/Document.h>
|
||||||
#include <Gui/Application.h>
|
#include <Gui/Application.h>
|
||||||
|
@ -41,7 +42,6 @@
|
||||||
#include <Gui/Command.h>
|
#include <Gui/Command.h>
|
||||||
#include <Mod/PartDesign/App/FeaturePolarPattern.h>
|
#include <Mod/PartDesign/App/FeaturePolarPattern.h>
|
||||||
#include <Mod/Sketcher/App/SketchObject.h>
|
#include <Mod/Sketcher/App/SketchObject.h>
|
||||||
#include "TaskMultiTransformParameters.h"
|
|
||||||
|
|
||||||
using namespace PartDesignGui;
|
using namespace PartDesignGui;
|
||||||
using namespace Gui;
|
using namespace Gui;
|
||||||
|
@ -64,7 +64,7 @@ TaskPolarPatternParameters::TaskPolarPatternParameters(ViewProviderTransformed *
|
||||||
|
|
||||||
referenceSelectionMode = false;
|
referenceSelectionMode = false;
|
||||||
|
|
||||||
updateUIinProgress = false; // Hack, sometimes it is NOT false although set to false in Transformed::Transformed()!!
|
blockUpdate = false; // Hack, sometimes it is NOT false although set to false in Transformed::Transformed()!!
|
||||||
setupUI();
|
setupUI();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -87,7 +87,7 @@ TaskPolarPatternParameters::TaskPolarPatternParameters(TaskMultiTransformParamet
|
||||||
|
|
||||||
referenceSelectionMode = false;
|
referenceSelectionMode = false;
|
||||||
|
|
||||||
updateUIinProgress = false; // Hack, sometimes it is NOT false although set to false in Transformed::Transformed()!!
|
blockUpdate = false; // Hack, sometimes it is NOT false although set to false in Transformed::Transformed()!!
|
||||||
setupUI();
|
setupUI();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -138,9 +138,9 @@ void TaskPolarPatternParameters::setupUI()
|
||||||
|
|
||||||
void TaskPolarPatternParameters::updateUI()
|
void TaskPolarPatternParameters::updateUI()
|
||||||
{
|
{
|
||||||
if (updateUIinProgress)
|
if (blockUpdate)
|
||||||
return;
|
return;
|
||||||
updateUIinProgress = true;
|
blockUpdate = true;
|
||||||
|
|
||||||
PartDesign::PolarPattern* pcPolarPattern = static_cast<PartDesign::PolarPattern*>(getObject());
|
PartDesign::PolarPattern* pcPolarPattern = static_cast<PartDesign::PolarPattern*>(getObject());
|
||||||
|
|
||||||
|
@ -180,33 +180,39 @@ void TaskPolarPatternParameters::updateUI()
|
||||||
ui->spinAngle->setValue(angle);
|
ui->spinAngle->setValue(angle);
|
||||||
ui->spinOccurrences->setValue(occurrences);
|
ui->spinOccurrences->setValue(occurrences);
|
||||||
|
|
||||||
updateUIinProgress = false;
|
blockUpdate = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void TaskPolarPatternParameters::onSelectionChanged(const Gui::SelectionChanges& msg)
|
void TaskPolarPatternParameters::onSelectionChanged(const Gui::SelectionChanges& msg)
|
||||||
{
|
{
|
||||||
if (msg.Type == Gui::SelectionChanges::AddSelection) {
|
if (msg.Type == Gui::SelectionChanges::AddSelection) {
|
||||||
|
|
||||||
|
if (strcmp(msg.pDocName, getObject()->getDocument()->getName()) != 0)
|
||||||
|
return;
|
||||||
|
|
||||||
std::string subName(msg.pSubName);
|
std::string subName(msg.pSubName);
|
||||||
PartDesign::PolarPattern* pcPolarPattern = static_cast<PartDesign::PolarPattern*>(getObject());
|
if (originalSelected(msg)) {
|
||||||
if (originalSelectionMode) {
|
ui->lineOriginal->setText(QString::fromAscii(msg.pObjectName));
|
||||||
App::DocumentObject* selectedObject = pcPolarPattern->getDocument()->getActiveObject();
|
|
||||||
if ((selectedObject == NULL) || !selectedObject->isDerivedFrom(Part::Feature::getClassTypeId()))
|
|
||||||
return;
|
|
||||||
if (originalSelected(msg))
|
|
||||||
ui->lineOriginal->setText(QString::fromAscii(selectedObject->getNameInDocument()));
|
|
||||||
} else if (referenceSelectionMode &&
|
} else if (referenceSelectionMode &&
|
||||||
(subName.size() > 4 && subName.substr(0,4) == "Edge")) {
|
(subName.size() > 4 && subName.substr(0,4) == "Edge")) {
|
||||||
|
|
||||||
std::vector<std::string> axes;
|
if (strcmp(msg.pObjectName, getSupportObject()->getNameInDocument()) != 0)
|
||||||
axes.push_back(subName.c_str());
|
return;
|
||||||
pcPolarPattern->Axis.setValue(getOriginalObject(), axes);
|
|
||||||
pcPolarPattern->StdAxis.setValue("");
|
|
||||||
|
|
||||||
if (updateView())
|
|
||||||
recomputeFeature();
|
|
||||||
|
|
||||||
exitSelectionMode();
|
exitSelectionMode();
|
||||||
updateUI();
|
if (!blockUpdate) {
|
||||||
|
PartDesign::PolarPattern* pcPolarPattern = static_cast<PartDesign::PolarPattern*>(getObject());
|
||||||
|
std::vector<std::string> axes(1,subName);
|
||||||
|
pcPolarPattern->Axis.setValue(getSupportObject(), axes);
|
||||||
|
pcPolarPattern->StdAxis.setValue("");
|
||||||
|
|
||||||
|
recomputeFeature();
|
||||||
|
updateUI();
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
ui->buttonReference->setChecked(referenceSelectionMode);
|
||||||
|
ui->lineReference->setText(QString::fromAscii(subName.c_str()));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -224,43 +230,40 @@ void TaskPolarPatternParameters::onButtonZ() {
|
||||||
}
|
}
|
||||||
|
|
||||||
void TaskPolarPatternParameters::onCheckReverse(const bool on) {
|
void TaskPolarPatternParameters::onCheckReverse(const bool on) {
|
||||||
if (updateUIinProgress)
|
if (blockUpdate)
|
||||||
return;
|
return;
|
||||||
PartDesign::PolarPattern* pcPolarPattern = static_cast<PartDesign::PolarPattern*>(getObject());
|
PartDesign::PolarPattern* pcPolarPattern = static_cast<PartDesign::PolarPattern*>(getObject());
|
||||||
pcPolarPattern->Reversed.setValue(on);
|
pcPolarPattern->Reversed.setValue(on);
|
||||||
|
|
||||||
exitSelectionMode();
|
exitSelectionMode();
|
||||||
updateUI();
|
updateUI();
|
||||||
if (updateView())
|
recomputeFeature();
|
||||||
recomputeFeature();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void TaskPolarPatternParameters::onAngle(const double a) {
|
void TaskPolarPatternParameters::onAngle(const double a) {
|
||||||
if (updateUIinProgress)
|
if (blockUpdate)
|
||||||
return;
|
return;
|
||||||
PartDesign::PolarPattern* pcPolarPattern = static_cast<PartDesign::PolarPattern*>(getObject());
|
PartDesign::PolarPattern* pcPolarPattern = static_cast<PartDesign::PolarPattern*>(getObject());
|
||||||
pcPolarPattern->Angle.setValue(a);
|
pcPolarPattern->Angle.setValue(a);
|
||||||
|
|
||||||
exitSelectionMode();
|
exitSelectionMode();
|
||||||
updateUI();
|
updateUI();
|
||||||
if (updateView())
|
recomputeFeature();
|
||||||
recomputeFeature();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void TaskPolarPatternParameters::onOccurrences(const int n) {
|
void TaskPolarPatternParameters::onOccurrences(const int n) {
|
||||||
if (updateUIinProgress)
|
if (blockUpdate)
|
||||||
return;
|
return;
|
||||||
PartDesign::PolarPattern* pcPolarPattern = static_cast<PartDesign::PolarPattern*>(getObject());
|
PartDesign::PolarPattern* pcPolarPattern = static_cast<PartDesign::PolarPattern*>(getObject());
|
||||||
pcPolarPattern->Occurrences.setValue(n);
|
pcPolarPattern->Occurrences.setValue(n);
|
||||||
|
|
||||||
exitSelectionMode();
|
exitSelectionMode();
|
||||||
updateUI();
|
updateUI();
|
||||||
if (updateView())
|
recomputeFeature();
|
||||||
recomputeFeature();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void TaskPolarPatternParameters::onStdAxis(const std::string& axis) {
|
void TaskPolarPatternParameters::onStdAxis(const std::string& axis) {
|
||||||
if (updateUIinProgress)
|
if (blockUpdate)
|
||||||
return;
|
return;
|
||||||
PartDesign::PolarPattern* pcPolarPattern = static_cast<PartDesign::PolarPattern*>(getObject());
|
PartDesign::PolarPattern* pcPolarPattern = static_cast<PartDesign::PolarPattern*>(getObject());
|
||||||
pcPolarPattern->StdAxis.setValue(axis.c_str());
|
pcPolarPattern->StdAxis.setValue(axis.c_str());
|
||||||
|
@ -268,14 +271,11 @@ void TaskPolarPatternParameters::onStdAxis(const std::string& axis) {
|
||||||
|
|
||||||
exitSelectionMode();
|
exitSelectionMode();
|
||||||
updateUI();
|
updateUI();
|
||||||
if (updateView())
|
recomputeFeature();
|
||||||
recomputeFeature();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void TaskPolarPatternParameters::onButtonReference(bool checked)
|
void TaskPolarPatternParameters::onButtonReference(bool checked)
|
||||||
{
|
{
|
||||||
if (updateUIinProgress)
|
|
||||||
return;
|
|
||||||
if (checked ) {
|
if (checked ) {
|
||||||
hideObject();
|
hideObject();
|
||||||
showOriginals();
|
showOriginals();
|
||||||
|
@ -289,51 +289,48 @@ void TaskPolarPatternParameters::onButtonReference(bool checked)
|
||||||
|
|
||||||
void TaskPolarPatternParameters::onUpdateView(bool on)
|
void TaskPolarPatternParameters::onUpdateView(bool on)
|
||||||
{
|
{
|
||||||
ui->buttonX->blockSignals(!on);
|
blockUpdate = !on;
|
||||||
ui->buttonY->blockSignals(!on);
|
if (on) {
|
||||||
ui->buttonZ->blockSignals(!on);
|
// Do the same like in TaskDlgPolarPatternParameters::accept() but without doCommand
|
||||||
ui->checkReverse->blockSignals(!on);
|
PartDesign::PolarPattern* pcPolarPattern = static_cast<PartDesign::PolarPattern*>(getObject());
|
||||||
ui->spinAngle->blockSignals(!on);
|
|
||||||
ui->spinOccurrences->blockSignals(!on);
|
std::string axis = getAxis();
|
||||||
|
if (!axis.empty()) {
|
||||||
|
std::vector<std::string> axes(1,axis);
|
||||||
|
pcPolarPattern->Axis.setValue(getSupportObject(),axes);
|
||||||
|
} else
|
||||||
|
pcPolarPattern->Axis.setValue(NULL);
|
||||||
|
|
||||||
|
std::string stdAxis = getStdAxis();
|
||||||
|
if (!stdAxis.empty())
|
||||||
|
pcPolarPattern->StdAxis.setValue(stdAxis.c_str());
|
||||||
|
else
|
||||||
|
pcPolarPattern->StdAxis.setValue(NULL);
|
||||||
|
|
||||||
|
pcPolarPattern->Reversed.setValue(getReverse());
|
||||||
|
pcPolarPattern->Angle.setValue(getAngle());
|
||||||
|
pcPolarPattern->Occurrences.setValue(getOccurrences());
|
||||||
|
|
||||||
|
recomputeFeature();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const std::string TaskPolarPatternParameters::getStdAxis(void) const
|
const std::string TaskPolarPatternParameters::getStdAxis(void) const
|
||||||
{
|
{
|
||||||
std::string stdAxis;
|
|
||||||
|
|
||||||
if (ui->buttonX->isChecked())
|
if (ui->buttonX->isChecked())
|
||||||
stdAxis = "X";
|
return std::string("X");
|
||||||
else if (ui->buttonY->isChecked())
|
else if (ui->buttonY->isChecked())
|
||||||
stdAxis = "Y";
|
return std::string("Y");
|
||||||
else if (ui->buttonZ->isChecked())
|
else if (ui->buttonZ->isChecked())
|
||||||
stdAxis = "Z";
|
return std::string("Z");
|
||||||
|
return std::string("");
|
||||||
if (!stdAxis.empty())
|
|
||||||
return std::string("\"") + stdAxis + "\"";
|
|
||||||
else
|
|
||||||
return std::string("");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const QString TaskPolarPatternParameters::getAxis(void) const
|
const std::string TaskPolarPatternParameters::getAxis(void) const
|
||||||
{
|
{
|
||||||
PartDesign::PolarPattern* pcPolarPattern = static_cast<PartDesign::PolarPattern*>(getObject());
|
return ui->lineReference->text().toStdString();
|
||||||
App::DocumentObject* feature = pcPolarPattern->Axis.getValue();
|
|
||||||
if (feature == NULL)
|
|
||||||
return QString::fromUtf8("");
|
|
||||||
std::vector<std::string> axes = pcPolarPattern->Axis.getSubValues();
|
|
||||||
QString buf;
|
|
||||||
|
|
||||||
if ((feature != NULL) && !axes.empty()) {
|
|
||||||
buf = QString::fromUtf8("(App.ActiveDocument.%1,[\"%2\"])");
|
|
||||||
buf = buf.arg(QString::fromUtf8(feature->getNameInDocument()));
|
|
||||||
buf = buf.arg(QString::fromUtf8(axes.front().c_str()));
|
|
||||||
}
|
|
||||||
else
|
|
||||||
buf = QString::fromUtf8("");
|
|
||||||
|
|
||||||
return buf;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const bool TaskPolarPatternParameters::getReverse(void) const
|
const bool TaskPolarPatternParameters::getReverse(void) const
|
||||||
{
|
{
|
||||||
return ui->checkReverse->isChecked();
|
return ui->checkReverse->isChecked();
|
||||||
|
@ -349,14 +346,6 @@ const unsigned TaskPolarPatternParameters::getOccurrences(void) const
|
||||||
return ui->spinOccurrences->value();
|
return ui->spinOccurrences->value();
|
||||||
}
|
}
|
||||||
|
|
||||||
const bool TaskPolarPatternParameters::updateView() const
|
|
||||||
{
|
|
||||||
if (insideMultiTransform)
|
|
||||||
return parentTask->updateView();
|
|
||||||
else
|
|
||||||
return ui->checkBoxUpdateView->isChecked();
|
|
||||||
}
|
|
||||||
|
|
||||||
void TaskPolarPatternParameters::exitSelectionMode()
|
void TaskPolarPatternParameters::exitSelectionMode()
|
||||||
{
|
{
|
||||||
originalSelectionMode = false;
|
originalSelectionMode = false;
|
||||||
|
@ -406,12 +395,16 @@ bool TaskDlgPolarPatternParameters::accept()
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
TaskPolarPatternParameters* polarpatternParameter = static_cast<TaskPolarPatternParameters*>(parameter);
|
TaskPolarPatternParameters* polarpatternParameter = static_cast<TaskPolarPatternParameters*>(parameter);
|
||||||
std::string axis = polarpatternParameter->getAxis().toStdString();
|
std::string axis = polarpatternParameter->getAxis();
|
||||||
if (!axis.empty())
|
if (!axis.empty()) {
|
||||||
Gui::Command::doCommand(Gui::Command::Doc,"App.ActiveDocument.%s.Axis = %s", name.c_str(), axis.c_str());
|
QString buf = QString::fromUtf8("(App.ActiveDocument.%1,[\"%2\"])");
|
||||||
|
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());
|
||||||
|
} else
|
||||||
|
Gui::Command::doCommand(Gui::Command::Doc,"App.ActiveDocument.%s.Axis = None", name.c_str());
|
||||||
std::string stdAxis = polarpatternParameter->getStdAxis();
|
std::string stdAxis = polarpatternParameter->getStdAxis();
|
||||||
if (!stdAxis.empty())
|
Gui::Command::doCommand(Gui::Command::Doc,"App.ActiveDocument.%s.StdAxis = \"%s\"",name.c_str(),stdAxis.c_str());
|
||||||
Gui::Command::doCommand(Gui::Command::Doc,"App.ActiveDocument.%s.StdAxis = %s",name.c_str(),stdAxis.c_str());
|
|
||||||
Gui::Command::doCommand(Gui::Command::Doc,"App.ActiveDocument.%s.Reversed = %u",name.c_str(),polarpatternParameter->getReverse());
|
Gui::Command::doCommand(Gui::Command::Doc,"App.ActiveDocument.%s.Reversed = %u",name.c_str(),polarpatternParameter->getReverse());
|
||||||
Gui::Command::doCommand(Gui::Command::Doc,"App.ActiveDocument.%s.Angle = %f",name.c_str(),polarpatternParameter->getAngle());
|
Gui::Command::doCommand(Gui::Command::Doc,"App.ActiveDocument.%s.Angle = %f",name.c_str(),polarpatternParameter->getAngle());
|
||||||
Gui::Command::doCommand(Gui::Command::Doc,"App.ActiveDocument.%s.Occurrences = %u",name.c_str(),polarpatternParameter->getOccurrences());
|
Gui::Command::doCommand(Gui::Command::Doc,"App.ActiveDocument.%s.Occurrences = %u",name.c_str(),polarpatternParameter->getOccurrences());
|
||||||
|
|
|
@ -56,12 +56,11 @@ public:
|
||||||
TaskPolarPatternParameters(TaskMultiTransformParameters *parentTask, QLayout *layout);
|
TaskPolarPatternParameters(TaskMultiTransformParameters *parentTask, QLayout *layout);
|
||||||
virtual ~TaskPolarPatternParameters();
|
virtual ~TaskPolarPatternParameters();
|
||||||
|
|
||||||
const QString getAxis(void) const;
|
|
||||||
const std::string getStdAxis(void) const;
|
const std::string getStdAxis(void) const;
|
||||||
|
const std::string getAxis(void) const;
|
||||||
const bool getReverse(void) const;
|
const bool getReverse(void) const;
|
||||||
const double getAngle(void) const;
|
const double getAngle(void) const;
|
||||||
const unsigned getOccurrences(void) const;
|
const unsigned getOccurrences(void) const;
|
||||||
const bool updateView() const;
|
|
||||||
|
|
||||||
private Q_SLOTS:
|
private Q_SLOTS:
|
||||||
void onStdAxis(const std::string& axis);
|
void onStdAxis(const std::string& axis);
|
||||||
|
|
|
@ -29,6 +29,7 @@
|
||||||
|
|
||||||
#include "ui_TaskScaledParameters.h"
|
#include "ui_TaskScaledParameters.h"
|
||||||
#include "TaskScaledParameters.h"
|
#include "TaskScaledParameters.h"
|
||||||
|
#include "TaskMultiTransformParameters.h"
|
||||||
#include <App/Application.h>
|
#include <App/Application.h>
|
||||||
#include <App/Document.h>
|
#include <App/Document.h>
|
||||||
#include <Gui/Application.h>
|
#include <Gui/Application.h>
|
||||||
|
@ -41,7 +42,6 @@
|
||||||
#include <Gui/Command.h>
|
#include <Gui/Command.h>
|
||||||
#include <Mod/PartDesign/App/FeatureScaled.h>
|
#include <Mod/PartDesign/App/FeatureScaled.h>
|
||||||
#include <Mod/Sketcher/App/SketchObject.h>
|
#include <Mod/Sketcher/App/SketchObject.h>
|
||||||
#include "TaskMultiTransformParameters.h"
|
|
||||||
|
|
||||||
using namespace PartDesignGui;
|
using namespace PartDesignGui;
|
||||||
using namespace Gui;
|
using namespace Gui;
|
||||||
|
@ -62,7 +62,7 @@ TaskScaledParameters::TaskScaledParameters(ViewProviderTransformed *TransformedV
|
||||||
ui->buttonOK->hide();
|
ui->buttonOK->hide();
|
||||||
ui->checkBoxUpdateView->setEnabled(true);
|
ui->checkBoxUpdateView->setEnabled(true);
|
||||||
|
|
||||||
updateUIinProgress = false; // Hack, sometimes it is NOT false although set to false in Transformed::Transformed()!!
|
blockUpdate = false; // Hack, sometimes it is NOT false although set to false in Transformed::Transformed()!!
|
||||||
setupUI();
|
setupUI();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -83,7 +83,7 @@ TaskScaledParameters::TaskScaledParameters(TaskMultiTransformParameters *parentT
|
||||||
ui->lineOriginal->hide();
|
ui->lineOriginal->hide();
|
||||||
ui->checkBoxUpdateView->hide();
|
ui->checkBoxUpdateView->hide();
|
||||||
|
|
||||||
updateUIinProgress = false; // Hack, sometimes it is NOT false although set to false in Transformed::Transformed()!!
|
blockUpdate = false; // Hack, sometimes it is NOT false although set to false in Transformed::Transformed()!!
|
||||||
setupUI();
|
setupUI();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -119,8 +119,9 @@ void TaskScaledParameters::setupUI()
|
||||||
|
|
||||||
void TaskScaledParameters::updateUI()
|
void TaskScaledParameters::updateUI()
|
||||||
{
|
{
|
||||||
if (updateUIinProgress) return;
|
if (blockUpdate)
|
||||||
updateUIinProgress = true;
|
return;
|
||||||
|
blockUpdate = true;
|
||||||
|
|
||||||
PartDesign::Scaled* pcScaled = static_cast<PartDesign::Scaled*>(getObject());
|
PartDesign::Scaled* pcScaled = static_cast<PartDesign::Scaled*>(getObject());
|
||||||
|
|
||||||
|
@ -130,44 +131,45 @@ void TaskScaledParameters::updateUI()
|
||||||
ui->spinFactor->setValue(factor);
|
ui->spinFactor->setValue(factor);
|
||||||
ui->spinOccurrences->setValue(occurrences);
|
ui->spinOccurrences->setValue(occurrences);
|
||||||
|
|
||||||
updateUIinProgress = false;
|
blockUpdate = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void TaskScaledParameters::onSelectionChanged(const Gui::SelectionChanges& msg)
|
void TaskScaledParameters::onSelectionChanged(const Gui::SelectionChanges& msg)
|
||||||
{
|
{
|
||||||
PartDesign::Scaled* pcScaled = static_cast<PartDesign::Scaled*>(getObject());
|
if (originalSelected(msg)) {
|
||||||
App::DocumentObject* selectedObject = pcScaled->getDocument()->getActiveObject();
|
App::DocumentObject* selectedObject = TransformedView->getObject()->getDocument()->getActiveObject();
|
||||||
if ((selectedObject == NULL) || !selectedObject->isDerivedFrom(Part::Feature::getClassTypeId()))
|
ui->lineOriginal->setText(QString::fromAscii(selectedObject->getNameInDocument()));
|
||||||
return;
|
|
||||||
|
|
||||||
if (originalSelectionMode) {
|
|
||||||
if (originalSelected(msg))
|
|
||||||
ui->lineOriginal->setText(QString::fromAscii(selectedObject->getNameInDocument()));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void TaskScaledParameters::onFactor(const double f) {
|
void TaskScaledParameters::onFactor(const double f) {
|
||||||
if (updateUIinProgress) return;
|
if (blockUpdate)
|
||||||
|
return;
|
||||||
PartDesign::Scaled* pcScaled = static_cast<PartDesign::Scaled*>(getObject());
|
PartDesign::Scaled* pcScaled = static_cast<PartDesign::Scaled*>(getObject());
|
||||||
pcScaled->Factor.setValue(f);
|
pcScaled->Factor.setValue(f);
|
||||||
updateUI();
|
updateUI();
|
||||||
if (updateView())
|
recomputeFeature();
|
||||||
recomputeFeature();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void TaskScaledParameters::onOccurrences(const int n) {
|
void TaskScaledParameters::onOccurrences(const int n) {
|
||||||
if (updateUIinProgress) return;
|
if (blockUpdate)
|
||||||
|
return;
|
||||||
PartDesign::Scaled* pcScaled = static_cast<PartDesign::Scaled*>(getObject());
|
PartDesign::Scaled* pcScaled = static_cast<PartDesign::Scaled*>(getObject());
|
||||||
pcScaled->Occurrences.setValue(n);
|
pcScaled->Occurrences.setValue(n);
|
||||||
updateUI();
|
updateUI();
|
||||||
if (updateView())
|
recomputeFeature();
|
||||||
recomputeFeature();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void TaskScaledParameters::onUpdateView(bool on)
|
void TaskScaledParameters::onUpdateView(bool on)
|
||||||
{
|
{
|
||||||
ui->spinFactor->blockSignals(!on);
|
blockUpdate = !on;
|
||||||
ui->spinOccurrences->blockSignals(!on);
|
if (on) {
|
||||||
|
// Do the same like in TaskDlgScaledParameters::accept() but without doCommand
|
||||||
|
PartDesign::Scaled* pcScaled = static_cast<PartDesign::Scaled*>(getObject());
|
||||||
|
pcScaled->Factor.setValue(getFactor());
|
||||||
|
pcScaled->Occurrences.setValue(getOccurrences());
|
||||||
|
recomputeFeature();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const double TaskScaledParameters::getFactor(void) const
|
const double TaskScaledParameters::getFactor(void) const
|
||||||
|
@ -180,13 +182,6 @@ const unsigned TaskScaledParameters::getOccurrences(void) const
|
||||||
return ui->spinOccurrences->value();
|
return ui->spinOccurrences->value();
|
||||||
}
|
}
|
||||||
|
|
||||||
const bool TaskScaledParameters::updateView() const
|
|
||||||
{
|
|
||||||
if (insideMultiTransform)
|
|
||||||
return parentTask->updateView();
|
|
||||||
else
|
|
||||||
return ui->checkBoxUpdateView->isChecked();
|
|
||||||
}
|
|
||||||
|
|
||||||
TaskScaledParameters::~TaskScaledParameters()
|
TaskScaledParameters::~TaskScaledParameters()
|
||||||
{
|
{
|
||||||
|
|
|
@ -58,7 +58,6 @@ public:
|
||||||
|
|
||||||
const double getFactor(void) const;
|
const double getFactor(void) const;
|
||||||
const unsigned getOccurrences(void) const;
|
const unsigned getOccurrences(void) const;
|
||||||
const bool updateView() const;
|
|
||||||
|
|
||||||
private Q_SLOTS:
|
private Q_SLOTS:
|
||||||
void onFactor(const double f);
|
void onFactor(const double f);
|
||||||
|
|
|
@ -55,7 +55,7 @@ TaskTransformedParameters::TaskTransformedParameters(ViewProviderTransformed *Tr
|
||||||
TransformedView(TransformedView),
|
TransformedView(TransformedView),
|
||||||
parentTask(NULL),
|
parentTask(NULL),
|
||||||
insideMultiTransform(false),
|
insideMultiTransform(false),
|
||||||
updateUIinProgress(false)
|
blockUpdate(false)
|
||||||
{
|
{
|
||||||
originalSelectionMode = false;
|
originalSelectionMode = false;
|
||||||
}
|
}
|
||||||
|
@ -65,7 +65,7 @@ TaskTransformedParameters::TaskTransformedParameters(TaskMultiTransformParameter
|
||||||
TransformedView(NULL),
|
TransformedView(NULL),
|
||||||
parentTask(parentTask),
|
parentTask(parentTask),
|
||||||
insideMultiTransform(true),
|
insideMultiTransform(true),
|
||||||
updateUIinProgress(false)
|
blockUpdate(false)
|
||||||
{
|
{
|
||||||
// Original feature selection makes no sense inside a MultiTransform
|
// Original feature selection makes no sense inside a MultiTransform
|
||||||
originalSelectionMode = false;
|
originalSelectionMode = false;
|
||||||
|
@ -73,22 +73,21 @@ TaskTransformedParameters::TaskTransformedParameters(TaskMultiTransformParameter
|
||||||
|
|
||||||
const bool TaskTransformedParameters::originalSelected(const Gui::SelectionChanges& msg)
|
const bool TaskTransformedParameters::originalSelected(const Gui::SelectionChanges& msg)
|
||||||
{
|
{
|
||||||
if (originalSelectionMode && (msg.Type == Gui::SelectionChanges::AddSelection)) {
|
if (msg.Type == Gui::SelectionChanges::AddSelection && originalSelectionMode) {
|
||||||
PartDesign::Transformed* pcTransformed = static_cast<PartDesign::Transformed*>(TransformedView->getObject());
|
|
||||||
App::DocumentObject* selectedObject = pcTransformed->getDocument()->getActiveObject();
|
if (strcmp(msg.pDocName, getObject()->getDocument()->getName()) != 0)
|
||||||
if (!selectedObject->isDerivedFrom(PartDesign::Additive::getClassTypeId()) &&
|
|
||||||
!selectedObject->isDerivedFrom(PartDesign::Subtractive::getClassTypeId()))
|
|
||||||
return false;
|
|
||||||
if (TransformedView->getObject() == pcTransformed)
|
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
std::vector<App::DocumentObject*> originals = pcTransformed->Originals.getValues();
|
PartDesign::Transformed* pcTransformed = getObject();
|
||||||
|
App::DocumentObject* selectedObject = pcTransformed->getDocument()->getObject(msg.pObjectName);
|
||||||
|
if (selectedObject->isDerivedFrom(PartDesign::Additive::getClassTypeId()) ||
|
||||||
|
selectedObject->isDerivedFrom(PartDesign::Subtractive::getClassTypeId())) {
|
||||||
|
|
||||||
|
// Do the same like in TaskDlgTransformedParameters::accept() but without doCommand
|
||||||
|
std::vector<App::DocumentObject*> originals(1,selectedObject);
|
||||||
|
pcTransformed->Originals.setValues(originals);
|
||||||
|
recomputeFeature();
|
||||||
|
|
||||||
if (std::find(originals.begin(), originals.end(), selectedObject) == originals.end()) {
|
|
||||||
Gui::Command::doCommand(Gui::Command::Gui,"App.activeDocument().%s.Originals = [App.activeDocument().%s]",
|
|
||||||
getObject()->getNameInDocument(),
|
|
||||||
selectedObject->getNameInDocument() );
|
|
||||||
Gui::Command::doCommand(Gui::Command::Doc,"App.ActiveDocument.recompute()");
|
|
||||||
originalSelectionMode = false;
|
originalSelectionMode = false;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -109,8 +108,9 @@ PartDesign::Transformed *TaskTransformedParameters::getObject() const
|
||||||
void TaskTransformedParameters::recomputeFeature()
|
void TaskTransformedParameters::recomputeFeature()
|
||||||
{
|
{
|
||||||
if (insideMultiTransform) {
|
if (insideMultiTransform) {
|
||||||
|
// redirect recompute and let the parent decide if recompute has to be blocked
|
||||||
parentTask->recomputeFeature();
|
parentTask->recomputeFeature();
|
||||||
} else {
|
} else if (!blockRecompute) {
|
||||||
PartDesign::Transformed* pcTransformed = static_cast<PartDesign::Transformed*>(TransformedView->getObject());
|
PartDesign::Transformed* pcTransformed = static_cast<PartDesign::Transformed*>(TransformedView->getObject());
|
||||||
pcTransformed->getDocument()->recomputeFeature(pcTransformed);
|
pcTransformed->getDocument()->recomputeFeature(pcTransformed);
|
||||||
}
|
}
|
||||||
|
@ -128,10 +128,10 @@ const std::vector<App::DocumentObject*> TaskTransformedParameters::getOriginals(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
App::DocumentObject* TaskTransformedParameters::getOriginalObject() const
|
App::DocumentObject* TaskTransformedParameters::getSupportObject() const
|
||||||
{
|
{
|
||||||
if (insideMultiTransform) {
|
if (insideMultiTransform) {
|
||||||
return parentTask->getOriginalObject();
|
return parentTask->getSupportObject();
|
||||||
} else {
|
} else {
|
||||||
PartDesign::Transformed* pcTransformed = static_cast<PartDesign::Transformed*>(TransformedView->getObject());
|
PartDesign::Transformed* pcTransformed = static_cast<PartDesign::Transformed*>(TransformedView->getObject());
|
||||||
return pcTransformed->getOriginalObject();
|
return pcTransformed->getOriginalObject();
|
||||||
|
|
|
@ -59,6 +59,8 @@ public:
|
||||||
{}
|
{}
|
||||||
|
|
||||||
const std::vector<App::DocumentObject*> getOriginals(void) const;
|
const std::vector<App::DocumentObject*> getOriginals(void) const;
|
||||||
|
/// Get the support object either of the object associated with this feature or with the parent feature (MultiTransform mode)
|
||||||
|
App::DocumentObject* getSupportObject() const;
|
||||||
|
|
||||||
|
|
||||||
protected Q_SLOTS:
|
protected Q_SLOTS:
|
||||||
|
@ -71,8 +73,6 @@ protected:
|
||||||
/// Get the TransformedFeature object associated with this task
|
/// Get the TransformedFeature object associated with this task
|
||||||
// Either through the ViewProvider or the currently active subFeature of the parentTask
|
// Either through the ViewProvider or the currently active subFeature of the parentTask
|
||||||
PartDesign::Transformed *getObject() const;
|
PartDesign::Transformed *getObject() const;
|
||||||
/// Get the original object either of the object associated with this feature or with the parent feature (MultiTransform mode)
|
|
||||||
App::DocumentObject* getOriginalObject() const;
|
|
||||||
/// Recompute either this feature or the parent feature (MultiTransform mode)
|
/// Recompute either this feature or the parent feature (MultiTransform mode)
|
||||||
void recomputeFeature();
|
void recomputeFeature();
|
||||||
|
|
||||||
|
@ -94,8 +94,10 @@ protected:
|
||||||
TaskMultiTransformParameters* parentTask;
|
TaskMultiTransformParameters* parentTask;
|
||||||
/// Flag indicating whether this object is a container for MultiTransform
|
/// Flag indicating whether this object is a container for MultiTransform
|
||||||
bool insideMultiTransform;
|
bool insideMultiTransform;
|
||||||
/// Lock updateUI() so that no unnecessary recomputeFeatures() are triggered
|
/// Lock updateUI() and applying changes to the underlying feature
|
||||||
bool updateUIinProgress;
|
bool blockUpdate;
|
||||||
|
/// Lock recomputeFeature()
|
||||||
|
bool blockRecompute;
|
||||||
};
|
};
|
||||||
|
|
||||||
/// simulation dialog for the TaskView
|
/// simulation dialog for the TaskView
|
||||||
|
|
Loading…
Reference in New Issue
Block a user