diff --git a/src/Mod/PartDesign/App/FeatureLinearPattern.h b/src/Mod/PartDesign/App/FeatureLinearPattern.h index 1e9878478..e1a0cff78 100644 --- a/src/Mod/PartDesign/App/FeatureLinearPattern.h +++ b/src/Mod/PartDesign/App/FeatureLinearPattern.h @@ -25,9 +25,9 @@ #define PARTDESIGN_FeatureLinearPattern_H #include +#include #include "FeatureTransformed.h" - namespace PartDesign { @@ -40,7 +40,7 @@ public: App::PropertyLinkSub Direction; App::PropertyBool Reversed; - App::PropertyFloat Length; + App::PropertyLength Length; App::PropertyInteger Occurrences; /** @name methods override feature */ diff --git a/src/Mod/PartDesign/App/FeaturePolarPattern.h b/src/Mod/PartDesign/App/FeaturePolarPattern.h index 191618483..09d195c34 100644 --- a/src/Mod/PartDesign/App/FeaturePolarPattern.h +++ b/src/Mod/PartDesign/App/FeaturePolarPattern.h @@ -25,6 +25,7 @@ #define PARTDESIGN_FeaturePolarPattern_H #include +#include #include "FeatureTransformed.h" @@ -40,7 +41,7 @@ public: App::PropertyLinkSub Axis; App::PropertyBool Reversed; - App::PropertyFloat Angle; + App::PropertyAngle Angle; App::PropertyInteger Occurrences; /** @name methods override feature */ diff --git a/src/Mod/PartDesign/Gui/TaskChamferParameters.cpp b/src/Mod/PartDesign/Gui/TaskChamferParameters.cpp index 71c7eb108..8e1c52207 100644 --- a/src/Mod/PartDesign/Gui/TaskChamferParameters.cpp +++ b/src/Mod/PartDesign/Gui/TaskChamferParameters.cpp @@ -69,6 +69,7 @@ TaskChamferParameters::TaskChamferParameters(ViewProviderChamfer *ChamferView,QW ui->chamferDistance->setValue(r); ui->chamferDistance->setMinimum(0); ui->chamferDistance->selectNumber(); + ui->chamferDistance->bind(pcChamfer->Size); QMetaObject::invokeMethod(ui->chamferDistance, "setFocus", Qt::QueuedConnection); } @@ -97,6 +98,17 @@ void TaskChamferParameters::changeEvent(QEvent *e) } } +void TaskChamferParameters::apply() +{ + std::string name = ChamferView->getObject()->getNameInDocument(); + + //Gui::Command::openCommand("Chamfer changed"); + ui->chamferDistance->apply(); + Gui::Command::doCommand(Gui::Command::Doc,"App.ActiveDocument.recompute()"); + Gui::Command::doCommand(Gui::Command::Gui,"Gui.activeDocument().resetEdit()"); + Gui::Command::commitCommand(); +} + //************************************************************************** //************************************************************************** // TaskDialog @@ -135,13 +147,7 @@ void TaskDlgChamferParameters::clicked(int) bool TaskDlgChamferParameters::accept() { - std::string name = ChamferView->getObject()->getNameInDocument(); - - //Gui::Command::openCommand("Chamfer changed"); - Gui::Command::doCommand(Gui::Command::Doc,"App.ActiveDocument.%s.Size = %f",name.c_str(),parameter->getLength()); - Gui::Command::doCommand(Gui::Command::Doc,"App.ActiveDocument.recompute()"); - Gui::Command::doCommand(Gui::Command::Gui,"Gui.activeDocument().resetEdit()"); - Gui::Command::commitCommand(); + parameter->apply(); return true; } diff --git a/src/Mod/PartDesign/Gui/TaskChamferParameters.h b/src/Mod/PartDesign/Gui/TaskChamferParameters.h index 69c476747..9c0c99ec7 100644 --- a/src/Mod/PartDesign/Gui/TaskChamferParameters.h +++ b/src/Mod/PartDesign/Gui/TaskChamferParameters.h @@ -51,13 +51,14 @@ public: TaskChamferParameters(ViewProviderChamfer *ChamferView, QWidget *parent=0); ~TaskChamferParameters(); - double getLength(void) const; + void apply(); private Q_SLOTS: void onLengthChanged(double); protected: void changeEvent(QEvent *e); + double getLength(void) const; private: diff --git a/src/Mod/PartDesign/Gui/TaskFilletParameters.cpp b/src/Mod/PartDesign/Gui/TaskFilletParameters.cpp index eeed99d27..a86637ac3 100644 --- a/src/Mod/PartDesign/Gui/TaskFilletParameters.cpp +++ b/src/Mod/PartDesign/Gui/TaskFilletParameters.cpp @@ -69,6 +69,7 @@ TaskFilletParameters::TaskFilletParameters(ViewProviderFillet *FilletView,QWidge ui->filletRadius->setValue(r); ui->filletRadius->setMinimum(0); ui->filletRadius->selectNumber(); + ui->filletRadius->bind(pcFillet->Radius); QMetaObject::invokeMethod(ui->filletRadius, "setFocus", Qt::QueuedConnection); } @@ -97,6 +98,17 @@ void TaskFilletParameters::changeEvent(QEvent *e) } } +void TaskFilletParameters::apply() +{ + std::string name = FilletView->getObject()->getNameInDocument(); + + //Gui::Command::openCommand("Fillet changed"); + ui->filletRadius->apply(); + Gui::Command::doCommand(Gui::Command::Doc,"App.ActiveDocument.recompute()"); + Gui::Command::doCommand(Gui::Command::Gui,"Gui.activeDocument().resetEdit()"); + Gui::Command::commitCommand(); +} + //************************************************************************** //************************************************************************** // TaskDialog @@ -135,13 +147,7 @@ void TaskDlgFilletParameters::clicked(int) bool TaskDlgFilletParameters::accept() { - std::string name = FilletView->getObject()->getNameInDocument(); - - //Gui::Command::openCommand("Fillet changed"); - Gui::Command::doCommand(Gui::Command::Doc,"App.ActiveDocument.%s.Radius = %f",name.c_str(),parameter->getLength()); - Gui::Command::doCommand(Gui::Command::Doc,"App.ActiveDocument.recompute()"); - Gui::Command::doCommand(Gui::Command::Gui,"Gui.activeDocument().resetEdit()"); - Gui::Command::commitCommand(); + parameter->apply(); return true; } diff --git a/src/Mod/PartDesign/Gui/TaskFilletParameters.h b/src/Mod/PartDesign/Gui/TaskFilletParameters.h index 1a9d1bbd0..06b735114 100644 --- a/src/Mod/PartDesign/Gui/TaskFilletParameters.h +++ b/src/Mod/PartDesign/Gui/TaskFilletParameters.h @@ -51,12 +51,13 @@ public: TaskFilletParameters(ViewProviderFillet *FilletView, QWidget *parent=0); ~TaskFilletParameters(); - double getLength(void) const; + void apply(); private Q_SLOTS: void onLengthChanged(double); protected: + double getLength(void) const; void changeEvent(QEvent *e); private: diff --git a/src/Mod/PartDesign/Gui/TaskGrooveParameters.cpp b/src/Mod/PartDesign/Gui/TaskGrooveParameters.cpp index f6e0bbad6..2ce7fbcbc 100644 --- a/src/Mod/PartDesign/Gui/TaskGrooveParameters.cpp +++ b/src/Mod/PartDesign/Gui/TaskGrooveParameters.cpp @@ -82,6 +82,7 @@ TaskGrooveParameters::TaskGrooveParameters(ViewProviderGroove *GrooveView,QWidge bool reversed = pcGroove->Reversed.getValue(); ui->grooveAngle->setValue(l); + ui->grooveAngle->bind(pcGroove->Angle); int count=pcGroove->getSketchAxisCount(); @@ -250,6 +251,38 @@ void TaskGrooveParameters::changeEvent(QEvent *e) } } +void TaskGrooveParameters::apply() +{ + App::DocumentObject* groove = GrooveView->getObject(); + std::string name = groove->getNameInDocument(); + + // retrieve sketch and its support object + App::DocumentObject* sketch = 0; + App::DocumentObject* support = 0; + if (groove->getTypeId().isDerivedFrom(PartDesign::Groove::getClassTypeId())) { + sketch = static_cast(groove)->Sketch.getValue(); + if (sketch) { + support = static_cast(sketch)->Support.getValue(); + } + } + + //Gui::Command::openCommand("Groove changed"); + ui->grooveAngle->apply(); + std::string axis = getReferenceAxis().toStdString(); + Gui::Command::doCommand(Gui::Command::Doc,"App.ActiveDocument.%s.ReferenceAxis = %s",name.c_str(),axis.c_str()); + Gui::Command::doCommand(Gui::Command::Doc,"App.ActiveDocument.%s.Midplane = %i",name.c_str(), getMidplane() ? 1 : 0); + Gui::Command::doCommand(Gui::Command::Doc,"App.ActiveDocument.%s.Reversed = %i",name.c_str(), getReversed() ? 1 : 0); + Gui::Command::doCommand(Gui::Command::Doc,"App.ActiveDocument.recompute()"); + if (groove->isValid()) { + if (sketch) + Gui::Command::doCommand(Gui::Command::Gui,"Gui.activeDocument().hide(\"%s\")",sketch->getNameInDocument()); + if (support) + Gui::Command::doCommand(Gui::Command::Gui,"Gui.activeDocument().hide(\"%s\")",support->getNameInDocument()); + } + Gui::Command::doCommand(Gui::Command::Gui,"Gui.activeDocument().resetEdit()"); + Gui::Command::commitCommand(); + } + //************************************************************************** //************************************************************************** // TaskDialog @@ -288,35 +321,7 @@ void TaskDlgGrooveParameters::clicked(int) bool TaskDlgGrooveParameters::accept() { - App::DocumentObject* groove = GrooveView->getObject(); - std::string name = groove->getNameInDocument(); - - // retrieve sketch and its support object - App::DocumentObject* sketch = 0; - App::DocumentObject* support = 0; - if (groove->getTypeId().isDerivedFrom(PartDesign::Groove::getClassTypeId())) { - sketch = static_cast(groove)->Sketch.getValue(); - if (sketch) { - support = static_cast(sketch)->Support.getValue(); - } - } - - //Gui::Command::openCommand("Groove changed"); - Gui::Command::doCommand(Gui::Command::Doc,"App.ActiveDocument.%s.Angle = %f",name.c_str(),parameter->getAngle()); - std::string axis = parameter->getReferenceAxis().toStdString(); - Gui::Command::doCommand(Gui::Command::Doc,"App.ActiveDocument.%s.ReferenceAxis = %s",name.c_str(),axis.c_str()); - Gui::Command::doCommand(Gui::Command::Doc,"App.ActiveDocument.%s.Midplane = %i",name.c_str(),parameter->getMidplane()?1:0); - Gui::Command::doCommand(Gui::Command::Doc,"App.ActiveDocument.%s.Reversed = %i",name.c_str(),parameter->getReversed()?1:0); - Gui::Command::doCommand(Gui::Command::Doc,"App.ActiveDocument.recompute()"); - if (groove->isValid()) { - if (sketch) - Gui::Command::doCommand(Gui::Command::Gui,"Gui.activeDocument().hide(\"%s\")",sketch->getNameInDocument()); - if (support) - Gui::Command::doCommand(Gui::Command::Gui,"Gui.activeDocument().hide(\"%s\")",support->getNameInDocument()); - } - Gui::Command::doCommand(Gui::Command::Gui,"Gui.activeDocument().resetEdit()"); - Gui::Command::commitCommand(); - + parameter->apply(); return true; } diff --git a/src/Mod/PartDesign/Gui/TaskGrooveParameters.h b/src/Mod/PartDesign/Gui/TaskGrooveParameters.h index 7afaaf1f7..3587aba33 100644 --- a/src/Mod/PartDesign/Gui/TaskGrooveParameters.h +++ b/src/Mod/PartDesign/Gui/TaskGrooveParameters.h @@ -52,11 +52,7 @@ public: TaskGrooveParameters(ViewProviderGroove *GrooveView,QWidget *parent = 0); ~TaskGrooveParameters(); - QString getReferenceAxis(void) const; - double getAngle(void) const; - bool getMidplane(void) const; - bool getReversed(void) const; - const bool updateView() const; + void apply(); private Q_SLOTS: void onAngleChanged(double); @@ -67,6 +63,11 @@ private Q_SLOTS: protected: void changeEvent(QEvent *e); + QString getReferenceAxis(void) const; + double getAngle(void) const; + bool getMidplane(void) const; + bool getReversed(void) const; + const bool updateView() const; private: diff --git a/src/Mod/PartDesign/Gui/TaskLinearPatternParameters.cpp b/src/Mod/PartDesign/Gui/TaskLinearPatternParameters.cpp index f9e801bf3..d9a839fee 100644 --- a/src/Mod/PartDesign/Gui/TaskLinearPatternParameters.cpp +++ b/src/Mod/PartDesign/Gui/TaskLinearPatternParameters.cpp @@ -107,8 +107,8 @@ void TaskLinearPatternParameters::setupUI() this, SLOT(onCheckReverse(bool))); connect(ui->spinLength, SIGNAL(valueChanged(double)), this, SLOT(onLength(double))); - connect(ui->spinOccurrences, SIGNAL(valueChanged(int)), - this, SLOT(onOccurrences(int))); + connect(ui->spinOccurrences, SIGNAL(valueChanged(double)), + this, SLOT(onOccurrences(double))); connect(ui->checkBoxUpdateView, SIGNAL(toggled(bool)), this, SLOT(onUpdateView(bool))); @@ -127,6 +127,9 @@ void TaskLinearPatternParameters::setupUI() } // --------------------- + ui->spinLength->bind(pcLinearPattern->Length); + ui->spinOccurrences->bind(pcLinearPattern->Occurrences); + ui->comboDirection->setEnabled(true); ui->checkReverse->setEnabled(true); ui->spinLength->blockSignals(true); @@ -271,11 +274,11 @@ void TaskLinearPatternParameters::onLength(const double l) { kickUpdateViewTimer(); } -void TaskLinearPatternParameters::onOccurrences(const int n) { +void TaskLinearPatternParameters::onOccurrences(const double n) { if (blockUpdate) return; PartDesign::LinearPattern* pcLinearPattern = static_cast(getObject()); - pcLinearPattern->Occurrences.setValue(n); + pcLinearPattern->Occurrences.setValue(round(n)); exitSelectionMode(); kickUpdateViewTimer(); @@ -375,9 +378,9 @@ const double TaskLinearPatternParameters::getLength(void) const return ui->spinLength->value().getValue(); } -const unsigned TaskLinearPatternParameters::getOccurrences(void) const +const unsigned TaskLinearPatternParameters::getOccurrences(void) const { - return ui->spinOccurrences->value(); + return round(ui->spinOccurrences->value().getValue()); } @@ -396,6 +399,39 @@ void TaskLinearPatternParameters::changeEvent(QEvent *e) } } +void TaskLinearPatternParameters::apply() +{ + std::string name = TransformedView->getObject()->getNameInDocument(); + std::string direction = getDirection(); + + if (!direction.empty()) { + App::DocumentObject* sketch = 0; + if (direction == "H_Axis" || direction == "V_Axis" || + (direction.size() > 4 && direction.substr(0,4) == "Axis")) + sketch = getSketchObject(); + else + sketch = getSupportObject(); + + if (sketch) { + QString buf = QString::fromLatin1("(App.ActiveDocument.%1,[\"%2\"])"); + buf = buf.arg(QString::fromLatin1(sketch->getNameInDocument())); + 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 + Gui::Command::doCommand(Gui::Command::Doc,"App.ActiveDocument.%s.Direction = None", name.c_str()); + Gui::Command::doCommand(Gui::Command::Doc,"App.ActiveDocument.%s.Reversed = %u",name.c_str(),getReverse()); + + ui->spinLength->apply(); + ui->spinOccurrences->apply(); + + Gui::Command::doCommand(Gui::Command::Doc,"App.ActiveDocument.recompute()"); + if (!TransformedView->getObject()->isValid()) + throw Base::Exception(TransformedView->getObject()->getStatusString()); + Gui::Command::doCommand(Gui::Command::Gui,"Gui.activeDocument().resetEdit()"); + Gui::Command::commitCommand(); +} + //************************************************************************** //************************************************************************** // TaskDialog @@ -413,40 +449,13 @@ TaskDlgLinearPatternParameters::TaskDlgLinearPatternParameters(ViewProviderLinea bool TaskDlgLinearPatternParameters::accept() { - std::string name = TransformedView->getObject()->getNameInDocument(); - try { //Gui::Command::openCommand("LinearPattern changed"); // Handle Originals if (!TaskDlgTransformedParameters::accept()) return false; - TaskLinearPatternParameters* linearpatternParameter = static_cast(parameter); - std::string direction = linearpatternParameter->getDirection(); - if (!direction.empty()) { - App::DocumentObject* sketch = 0; - if (direction == "H_Axis" || direction == "V_Axis" || - (direction.size() > 4 && direction.substr(0,4) == "Axis")) - sketch = linearpatternParameter->getSketchObject(); - else - sketch = linearpatternParameter->getSupportObject(); - - if (sketch) { - QString buf = QString::fromLatin1("(App.ActiveDocument.%1,[\"%2\"])"); - buf = buf.arg(QString::fromLatin1(sketch->getNameInDocument())); - 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 - Gui::Command::doCommand(Gui::Command::Doc,"App.ActiveDocument.%s.Direction = None", name.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.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.recompute()"); - if (!TransformedView->getObject()->isValid()) - throw Base::Exception(TransformedView->getObject()->getStatusString()); - Gui::Command::doCommand(Gui::Command::Gui,"Gui.activeDocument().resetEdit()"); - Gui::Command::commitCommand(); + parameter->apply(); } catch (const Base::Exception& e) { QMessageBox::warning(parameter, tr("Input error"), QString::fromAscii(e.what())); diff --git a/src/Mod/PartDesign/Gui/TaskLinearPatternParameters.h b/src/Mod/PartDesign/Gui/TaskLinearPatternParameters.h index ae964d12f..e90bffea8 100644 --- a/src/Mod/PartDesign/Gui/TaskLinearPatternParameters.h +++ b/src/Mod/PartDesign/Gui/TaskLinearPatternParameters.h @@ -57,22 +57,23 @@ public: TaskLinearPatternParameters(TaskMultiTransformParameters *parentTask, QLayout *layout); virtual ~TaskLinearPatternParameters(); - const std::string getDirection(void) const; - const bool getReverse(void) const; - const double getLength(void) const; - const unsigned getOccurrences(void) const; + virtual void apply(); private Q_SLOTS: void onUpdateViewTimer(); void onDirectionChanged(int num); void onCheckReverse(const bool on); void onLength(const double l); - void onOccurrences(const int n); + void onOccurrences(const double n); virtual void onUpdateView(bool); protected: virtual void changeEvent(QEvent *e); virtual void onSelectionChanged(const Gui::SelectionChanges& msg); + const std::string getDirection(void) const; + const bool getReverse(void) const; + const double getLength(void) const; + const unsigned getOccurrences(void) const; private: void setupUI(); diff --git a/src/Mod/PartDesign/Gui/TaskLinearPatternParameters.ui b/src/Mod/PartDesign/Gui/TaskLinearPatternParameters.ui index b4b4ddca9..156a1f61e 100644 --- a/src/Mod/PartDesign/Gui/TaskLinearPatternParameters.ui +++ b/src/Mod/PartDesign/Gui/TaskLinearPatternParameters.ui @@ -75,11 +75,11 @@ - + mm - + 100.000000000000000 @@ -96,14 +96,7 @@ - - - 2 - - - 99999 - - + diff --git a/src/Mod/PartDesign/Gui/TaskMirroredParameters.cpp b/src/Mod/PartDesign/Gui/TaskMirroredParameters.cpp index 75907c15b..3ac4c5523 100644 --- a/src/Mod/PartDesign/Gui/TaskMirroredParameters.cpp +++ b/src/Mod/PartDesign/Gui/TaskMirroredParameters.cpp @@ -291,6 +291,10 @@ const std::string TaskMirroredParameters::getMirrorPlane(void) const return std::string(""); } +void TaskMirroredParameters::apply() +{ +} + TaskMirroredParameters::~TaskMirroredParameters() { delete ui; diff --git a/src/Mod/PartDesign/Gui/TaskMirroredParameters.h b/src/Mod/PartDesign/Gui/TaskMirroredParameters.h index 916c0c8f8..3312662fa 100644 --- a/src/Mod/PartDesign/Gui/TaskMirroredParameters.h +++ b/src/Mod/PartDesign/Gui/TaskMirroredParameters.h @@ -59,6 +59,8 @@ public: const std::string getMirrorPlane(void) const; + virtual void apply(); + private Q_SLOTS: void onPlaneChanged(int num); virtual void onUpdateView(bool); diff --git a/src/Mod/PartDesign/Gui/TaskMultiTransformParameters.cpp b/src/Mod/PartDesign/Gui/TaskMultiTransformParameters.cpp index fcad5116c..53eaafebb 100644 --- a/src/Mod/PartDesign/Gui/TaskMultiTransformParameters.cpp +++ b/src/Mod/PartDesign/Gui/TaskMultiTransformParameters.cpp @@ -382,6 +382,10 @@ const std::vector TaskMultiTransformParameters::getTransfo return pcMultiTransform->Transformations.getValues(); } +void TaskMultiTransformParameters::apply() +{ +} + TaskMultiTransformParameters::~TaskMultiTransformParameters() { closeSubTask(); diff --git a/src/Mod/PartDesign/Gui/TaskMultiTransformParameters.h b/src/Mod/PartDesign/Gui/TaskMultiTransformParameters.h index d83102717..4b1317658 100644 --- a/src/Mod/PartDesign/Gui/TaskMultiTransformParameters.h +++ b/src/Mod/PartDesign/Gui/TaskMultiTransformParameters.h @@ -63,6 +63,8 @@ public: /// Return the currently active subFeature PartDesign::Transformed* getSubFeature(void) { return subFeature; } + virtual void apply(); + private Q_SLOTS: void onTransformDelete(); void onTransformEdit(); diff --git a/src/Mod/PartDesign/Gui/TaskPadParameters.cpp b/src/Mod/PartDesign/Gui/TaskPadParameters.cpp index 50eda391a..620ff420c 100644 --- a/src/Mod/PartDesign/Gui/TaskPadParameters.cpp +++ b/src/Mod/PartDesign/Gui/TaskPadParameters.cpp @@ -117,6 +117,9 @@ TaskPadParameters::TaskPadParameters(ViewProviderPad *PadView,bool newObj, QWidg ui->lengthEdit2->setMaximum(INT_MAX); ui->lengthEdit2->setValue(l2); + // Bind input fields to properties + ui->lengthEdit->bind(pcPad->Length); + ui->lengthEdit2->bind(pcPad->Length2); ui->checkBoxMidplane->setChecked(midplane); // According to bug #0000521 the reversed option @@ -290,7 +293,7 @@ void TaskPadParameters::onModeChanged(int index) case 0: pcPad->Type.setValue("Length"); // Avoid error message - if (ui->lengthEdit->value().getValue() < Precision::Confusion()) + if (ui->lengthEdit->value() < Precision::Confusion()) ui->lengthEdit->setValue(5.0); break; case 1: pcPad->Type.setValue("UpToLast"); break; @@ -457,6 +460,37 @@ void TaskPadParameters::saveHistory(void) ui->lengthEdit2->pushToHistory(); } +void TaskPadParameters::apply() +{ + std::string name = PadView->getObject()->getNameInDocument(); + const char * cname = name.c_str(); + + ui->lengthEdit->apply(); + + Gui::Command::doCommand(Gui::Command::Doc,"App.ActiveDocument.%s.Reversed = %i",cname,getReversed()?1:0); + Gui::Command::doCommand(Gui::Command::Doc,"App.ActiveDocument.%s.Midplane = %i",cname,getMidplane()?1:0); + + ui->lengthEdit2->apply(); + + Gui::Command::doCommand(Gui::Command::Doc,"App.ActiveDocument.%s.Type = %u",cname,getMode()); + std::string facename = getFaceName().data(); + PartDesign::Pad* pcPad = static_cast(PadView->getObject()); + Part::Feature* support = pcPad->getSupport(); + + if (support != NULL && !facename.empty()) { + QString buf = QString::fromUtf8("(App.ActiveDocument.%1,[\"%2\"])"); + buf = buf.arg(QString::fromUtf8(support->getNameInDocument())); + buf = buf.arg(QString::fromStdString(facename)); + Gui::Command::doCommand(Gui::Command::Doc,"App.ActiveDocument.%s.UpToFace = %s", cname, buf.toStdString().c_str()); + } else + Gui::Command::doCommand(Gui::Command::Doc,"App.ActiveDocument.%s.UpToFace = None", cname); + Gui::Command::doCommand(Gui::Command::Doc,"App.ActiveDocument.recompute()"); + if (!PadView->getObject()->isValid()) + throw Base::Exception(PadView->getObject()->getStatusString()); + Gui::Command::doCommand(Gui::Command::Gui,"Gui.activeDocument().resetEdit()"); + Gui::Command::commitCommand(); +} + //************************************************************************** //************************************************************************** // TaskDialog @@ -494,34 +528,13 @@ void TaskDlgPadParameters::clicked(int) bool TaskDlgPadParameters::accept() { - std::string name = PadView->getObject()->getNameInDocument(); // save the history parameter->saveHistory(); try { //Gui::Command::openCommand("Pad changed"); - Gui::Command::doCommand(Gui::Command::Doc,"App.ActiveDocument.%s.Length = %f",name.c_str(),parameter->getLength()); - Gui::Command::doCommand(Gui::Command::Doc,"App.ActiveDocument.%s.Reversed = %i",name.c_str(),parameter->getReversed()?1:0); - Gui::Command::doCommand(Gui::Command::Doc,"App.ActiveDocument.%s.Midplane = %i",name.c_str(),parameter->getMidplane()?1:0); - Gui::Command::doCommand(Gui::Command::Doc,"App.ActiveDocument.%s.Length2 = %f",name.c_str(),parameter->getLength2()); - Gui::Command::doCommand(Gui::Command::Doc,"App.ActiveDocument.%s.Type = %u",name.c_str(),parameter->getMode()); - std::string facename = parameter->getFaceName().data(); - PartDesign::Pad* pcPad = static_cast(PadView->getObject()); - Part::Feature* support = pcPad->getSupport(); - - if (support != NULL && !facename.empty()) { - QString buf = QString::fromUtf8("(App.ActiveDocument.%1,[\"%2\"])"); - buf = buf.arg(QString::fromUtf8(support->getNameInDocument())); - buf = buf.arg(QString::fromStdString(facename)); - Gui::Command::doCommand(Gui::Command::Doc,"App.ActiveDocument.%s.UpToFace = %s", name.c_str(), buf.toStdString().c_str()); - } else - Gui::Command::doCommand(Gui::Command::Doc,"App.ActiveDocument.%s.UpToFace = None", name.c_str()); - Gui::Command::doCommand(Gui::Command::Doc,"App.ActiveDocument.recompute()"); - if (!PadView->getObject()->isValid()) - throw Base::Exception(PadView->getObject()->getStatusString()); - Gui::Command::doCommand(Gui::Command::Gui,"Gui.activeDocument().resetEdit()"); - Gui::Command::commitCommand(); + parameter->apply(); } catch (const Base::Exception& e) { QMessageBox::warning(parameter, tr("Input error"), QString::fromAscii(e.what())); diff --git a/src/Mod/PartDesign/Gui/TaskPadParameters.h b/src/Mod/PartDesign/Gui/TaskPadParameters.h index e94e7842b..c78aa4183 100644 --- a/src/Mod/PartDesign/Gui/TaskPadParameters.h +++ b/src/Mod/PartDesign/Gui/TaskPadParameters.h @@ -52,14 +52,9 @@ public: TaskPadParameters(ViewProviderPad *PadView,bool newObj=false,QWidget *parent = 0); ~TaskPadParameters(); - int getMode(void) const; - double getLength(void) const; - double getLength2(void) const; - bool getReversed(void) const; - bool getMidplane(void) const; - QByteArray getFaceName(void) const; const bool updateView() const; void saveHistory(void); + void apply(); private Q_SLOTS: void onLengthChanged(double); @@ -75,6 +70,12 @@ protected: void changeEvent(QEvent *e); private: + int getMode(void) const; + double getLength(void) const; + double getLength2(void) const; + bool getReversed(void) const; + bool getMidplane(void) const; + QByteArray getFaceName(void) const; void onSelectionChanged(const Gui::SelectionChanges& msg); void updateUI(int index); diff --git a/src/Mod/PartDesign/Gui/TaskPocketParameters.cpp b/src/Mod/PartDesign/Gui/TaskPocketParameters.cpp index 849aadb23..2108ac7fa 100644 --- a/src/Mod/PartDesign/Gui/TaskPocketParameters.cpp +++ b/src/Mod/PartDesign/Gui/TaskPocketParameters.cpp @@ -120,6 +120,9 @@ TaskPocketParameters::TaskPocketParameters(ViewProviderPocket *PocketView,QWidge ui->changeMode->setCurrentIndex(index); ui->checkBoxMidplane->setChecked(midplane); + // Bind input fields to properties + ui->pocketLength->bind(pcPocket->Length); + ui->pocketLength->blockSignals(false); ui->checkBoxMidplane->blockSignals(false); ui->checkBoxReversed->blockSignals(false); @@ -412,6 +415,30 @@ void TaskPocketParameters::changeEvent(QEvent *e) } } +void TaskPocketParameters::apply() +{ + std::string name = PocketView->getObject()->getNameInDocument(); + + //Gui::Command::openCommand("Pocket changed"); + ui->pocketLength->apply(); + Gui::Command::doCommand(Gui::Command::Doc,"App.ActiveDocument.%s.Type = %u",name.c_str(),getMode()); + std::string facename = getFaceName().data(); + PartDesign::Pocket* pcPocket = static_cast(PocketView->getObject()); + Part::Feature* support = pcPocket->getSupport(); + if (support != NULL && !facename.empty()) { + QString buf = QString::fromUtf8("(App.ActiveDocument.%1,[\"%2\"])"); + buf = buf.arg(QString::fromUtf8(support->getNameInDocument())); + buf = buf.arg(QString::fromStdString(facename)); + Gui::Command::doCommand(Gui::Command::Doc,"App.ActiveDocument.%s.UpToFace = %s", name.c_str(), buf.toStdString().c_str()); + } else + Gui::Command::doCommand(Gui::Command::Doc,"App.ActiveDocument.%s.UpToFace = None", name.c_str()); + Gui::Command::doCommand(Gui::Command::Doc,"App.ActiveDocument.recompute()"); + if (!PocketView->getObject()->isValid()) + throw Base::Exception(PocketView->getObject()->getStatusString()); + Gui::Command::doCommand(Gui::Command::Gui,"Gui.activeDocument().resetEdit()"); + Gui::Command::commitCommand(); +} + //************************************************************************** //************************************************************************** // TaskDialog @@ -450,27 +477,8 @@ void TaskDlgPocketParameters::clicked(int) bool TaskDlgPocketParameters::accept() { - std::string name = PocketView->getObject()->getNameInDocument(); - try { - //Gui::Command::openCommand("Pocket changed"); - Gui::Command::doCommand(Gui::Command::Doc,"App.ActiveDocument.%s.Length = %f",name.c_str(),parameter->getLength()); - Gui::Command::doCommand(Gui::Command::Doc,"App.ActiveDocument.%s.Type = %u",name.c_str(),parameter->getMode()); - std::string facename = parameter->getFaceName().data(); - PartDesign::Pocket* pcPocket = static_cast(PocketView->getObject()); - Part::Feature* support = pcPocket->getSupport(); - if (support != NULL && !facename.empty()) { - QString buf = QString::fromUtf8("(App.ActiveDocument.%1,[\"%2\"])"); - buf = buf.arg(QString::fromUtf8(support->getNameInDocument())); - buf = buf.arg(QString::fromStdString(facename)); - Gui::Command::doCommand(Gui::Command::Doc,"App.ActiveDocument.%s.UpToFace = %s", name.c_str(), buf.toStdString().c_str()); - } else - Gui::Command::doCommand(Gui::Command::Doc,"App.ActiveDocument.%s.UpToFace = None", name.c_str()); - Gui::Command::doCommand(Gui::Command::Doc,"App.ActiveDocument.recompute()"); - if (!PocketView->getObject()->isValid()) - throw Base::Exception(PocketView->getObject()->getStatusString()); - Gui::Command::doCommand(Gui::Command::Gui,"Gui.activeDocument().resetEdit()"); - Gui::Command::commitCommand(); + parameter->apply(); } catch (const Base::Exception& e) { QMessageBox::warning(parameter, tr("Input error"), QString::fromAscii(e.what())); diff --git a/src/Mod/PartDesign/Gui/TaskPocketParameters.h b/src/Mod/PartDesign/Gui/TaskPocketParameters.h index 899d5602b..2d209b051 100644 --- a/src/Mod/PartDesign/Gui/TaskPocketParameters.h +++ b/src/Mod/PartDesign/Gui/TaskPocketParameters.h @@ -52,11 +52,9 @@ public: TaskPocketParameters(ViewProviderPocket *PocketView,QWidget *parent = 0); ~TaskPocketParameters(); - double getLength(void) const; - bool getMidplane(void) const; - int getMode(void) const; QByteArray getFaceName(void) const; const bool updateView() const; + void apply(); private Q_SLOTS: void onLengthChanged(double); @@ -71,6 +69,9 @@ protected: void changeEvent(QEvent *e); private: + double getLength(void) const; + bool getMidplane(void) const; + int getMode(void) const; void onSelectionChanged(const Gui::SelectionChanges& msg); void updateUI(int index); diff --git a/src/Mod/PartDesign/Gui/TaskPolarPatternParameters.cpp b/src/Mod/PartDesign/Gui/TaskPolarPatternParameters.cpp index e0430e669..66ed8e1d3 100644 --- a/src/Mod/PartDesign/Gui/TaskPolarPatternParameters.cpp +++ b/src/Mod/PartDesign/Gui/TaskPolarPatternParameters.cpp @@ -107,8 +107,8 @@ void TaskPolarPatternParameters::setupUI() this, SLOT(onCheckReverse(bool))); connect(ui->polarAngle, SIGNAL(valueChanged(double)), this, SLOT(onAngle(double))); - connect(ui->spinOccurrences, SIGNAL(valueChanged(int)), - this, SLOT(onOccurrences(int))); + connect(ui->spinOccurrences, SIGNAL(valueChanged(double)), + this, SLOT(onOccurrences(double))); connect(ui->checkBoxUpdateView, SIGNAL(toggled(bool)), this, SLOT(onUpdateView(bool))); @@ -127,6 +127,9 @@ void TaskPolarPatternParameters::setupUI() } // --------------------- + ui->polarAngle->bind(pcPolarPattern->Angle); + ui->spinOccurrences->bind(pcPolarPattern->Occurrences); + ui->comboAxis->setEnabled(true); ui->checkReverse->setEnabled(true); ui->polarAngle->setEnabled(true); @@ -244,12 +247,12 @@ void TaskPolarPatternParameters::onAngle(const double a) { kickUpdateViewTimer(); } -void TaskPolarPatternParameters::onOccurrences(const int n) { +void TaskPolarPatternParameters::onOccurrences(const double n) { if (blockUpdate) return; PartDesign::PolarPattern* pcPolarPattern = static_cast(getObject()); - pcPolarPattern->Occurrences.setValue(n); - + pcPolarPattern->Occurrences.setValue(round(n)); + exitSelectionMode(); kickUpdateViewTimer(); } @@ -323,7 +326,7 @@ const double TaskPolarPatternParameters::getAngle(void) const const unsigned TaskPolarPatternParameters::getOccurrences(void) const { - return ui->spinOccurrences->value(); + return round(ui->spinOccurrences->value().getValue()); } @@ -342,6 +345,36 @@ void TaskPolarPatternParameters::changeEvent(QEvent *e) } } +void TaskPolarPatternParameters::apply() +{ + std::string name = TransformedView->getObject()->getNameInDocument(); + std::string axis = getAxis(); + + if (!axis.empty()) { + App::DocumentObject* sketch = 0; + if (axis == "N_Axis") + sketch = getSketchObject(); + else + sketch = 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(),getReverse()); + ui->polarAngle->apply(); + ui->spinOccurrences->apply(); + Gui::Command::doCommand(Gui::Command::Doc,"App.ActiveDocument.recompute()"); + if (!TransformedView->getObject()->isValid()) + throw Base::Exception(TransformedView->getObject()->getStatusString()); + Gui::Command::doCommand(Gui::Command::Gui,"Gui.activeDocument().resetEdit()"); + Gui::Command::commitCommand(); +} + //************************************************************************** //************************************************************************** // TaskDialog @@ -358,39 +391,13 @@ TaskDlgPolarPatternParameters::TaskDlgPolarPatternParameters(ViewProviderPolarPa bool TaskDlgPolarPatternParameters::accept() { - std::string name = TransformedView->getObject()->getNameInDocument(); - try { //Gui::Command::openCommand("PolarPattern changed"); // Handle Originals if (!TaskDlgTransformedParameters::accept()) return false; - TaskPolarPatternParameters* polarpatternParameter = static_cast(parameter); - std::string axis = polarpatternParameter->getAxis(); - if (!axis.empty()) { - App::DocumentObject* sketch = 0; - if (axis == "N_Axis") - sketch = polarpatternParameter->getSketchObject(); - else - 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()); - 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.recompute()"); - if (!TransformedView->getObject()->isValid()) - throw Base::Exception(TransformedView->getObject()->getStatusString()); - Gui::Command::doCommand(Gui::Command::Gui,"Gui.activeDocument().resetEdit()"); - Gui::Command::commitCommand(); + parameter->apply(); } catch (const Base::Exception& e) { QMessageBox::warning(parameter, tr("Input error"), QString::fromAscii(e.what())); diff --git a/src/Mod/PartDesign/Gui/TaskPolarPatternParameters.h b/src/Mod/PartDesign/Gui/TaskPolarPatternParameters.h index 1fb90e03a..f484ed47e 100644 --- a/src/Mod/PartDesign/Gui/TaskPolarPatternParameters.h +++ b/src/Mod/PartDesign/Gui/TaskPolarPatternParameters.h @@ -57,23 +57,23 @@ public: TaskPolarPatternParameters(TaskMultiTransformParameters *parentTask, QLayout *layout); virtual ~TaskPolarPatternParameters(); - const std::string getStdAxis(void) const; - const std::string getAxis(void) const; - const bool getReverse(void) const; - const double getAngle(void) const; - const unsigned getOccurrences(void) const; - + void apply(); private Q_SLOTS: void onUpdateViewTimer(); void onAxisChanged(int num); void onCheckReverse(const bool on); void onAngle(const double a); - void onOccurrences(const int n); + void onOccurrences(const double n); virtual void onUpdateView(bool); protected: virtual void changeEvent(QEvent *e); virtual void onSelectionChanged(const Gui::SelectionChanges& msg); + const std::string getStdAxis(void) const; + const std::string getAxis(void) const; + const bool getReverse(void) const; + const double getAngle(void) const; + const unsigned getOccurrences(void) const; private: void setupUI(); diff --git a/src/Mod/PartDesign/Gui/TaskPolarPatternParameters.ui b/src/Mod/PartDesign/Gui/TaskPolarPatternParameters.ui index c9279dc91..21de2ea98 100644 --- a/src/Mod/PartDesign/Gui/TaskPolarPatternParameters.ui +++ b/src/Mod/PartDesign/Gui/TaskPolarPatternParameters.ui @@ -70,17 +70,17 @@ - + deg - + 0.000000000000000 - + 360.000000000000000 - + 360.000000000000000 @@ -97,14 +97,7 @@ - - - 2 - - - 99999 - - + diff --git a/src/Mod/PartDesign/Gui/TaskRevolutionParameters.cpp b/src/Mod/PartDesign/Gui/TaskRevolutionParameters.cpp index 3d88170a0..bfdeae0b0 100644 --- a/src/Mod/PartDesign/Gui/TaskRevolutionParameters.cpp +++ b/src/Mod/PartDesign/Gui/TaskRevolutionParameters.cpp @@ -113,6 +113,7 @@ TaskRevolutionParameters::TaskRevolutionParameters(ViewProviderRevolution *Revol ui->checkBoxMidplane->setChecked(mirrored); ui->checkBoxReversed->setChecked(reversed); + ui->revolveAngle->bind(pcRevolution->Angle); ui->revolveAngle->blockSignals(false); ui->axis->blockSignals(false); @@ -250,6 +251,38 @@ void TaskRevolutionParameters::changeEvent(QEvent *e) } } +void TaskRevolutionParameters::apply() +{ + App::DocumentObject* revolve = RevolutionView->getObject(); + std::string name = revolve->getNameInDocument(); + + // retrieve sketch and its support object + App::DocumentObject* sketch = 0; + App::DocumentObject* support = 0; + if (revolve->getTypeId().isDerivedFrom(PartDesign::Revolution::getClassTypeId())) { + sketch = static_cast(revolve)->Sketch.getValue(); + if (sketch) { + support = static_cast(sketch)->Support.getValue(); + } + } + + //Gui::Command::openCommand("Revolution changed"); + ui->revolveAngle->apply(); + std::string axis = getReferenceAxis().toStdString(); + Gui::Command::doCommand(Gui::Command::Doc,"App.ActiveDocument.%s.ReferenceAxis = %s",name.c_str(),axis.c_str()); + Gui::Command::doCommand(Gui::Command::Doc,"App.ActiveDocument.%s.Midplane = %i",name.c_str(), getMidplane() ? 1 : 0); + Gui::Command::doCommand(Gui::Command::Doc,"App.ActiveDocument.%s.Reversed = %i",name.c_str(), getReversed() ? 1 : 0); + Gui::Command::doCommand(Gui::Command::Doc,"App.ActiveDocument.recompute()"); + if (revolve->isValid()) { + if (sketch) + Gui::Command::doCommand(Gui::Command::Gui,"Gui.activeDocument().hide(\"%s\")",sketch->getNameInDocument()); + if (support) + Gui::Command::doCommand(Gui::Command::Gui,"Gui.activeDocument().hide(\"%s\")",support->getNameInDocument()); + } + Gui::Command::doCommand(Gui::Command::Gui,"Gui.activeDocument().resetEdit()"); + Gui::Command::commitCommand(); +} + //************************************************************************** //************************************************************************** // TaskDialog @@ -288,35 +321,7 @@ void TaskDlgRevolutionParameters::clicked(int) bool TaskDlgRevolutionParameters::accept() { - App::DocumentObject* revolve = RevolutionView->getObject(); - std::string name = revolve->getNameInDocument(); - - // retrieve sketch and its support object - App::DocumentObject* sketch = 0; - App::DocumentObject* support = 0; - if (revolve->getTypeId().isDerivedFrom(PartDesign::Revolution::getClassTypeId())) { - sketch = static_cast(revolve)->Sketch.getValue(); - if (sketch) { - support = static_cast(sketch)->Support.getValue(); - } - } - - //Gui::Command::openCommand("Revolution changed"); - Gui::Command::doCommand(Gui::Command::Doc,"App.ActiveDocument.%s.Angle = %f",name.c_str(),parameter->getAngle()); - std::string axis = parameter->getReferenceAxis().toStdString(); - Gui::Command::doCommand(Gui::Command::Doc,"App.ActiveDocument.%s.ReferenceAxis = %s",name.c_str(),axis.c_str()); - Gui::Command::doCommand(Gui::Command::Doc,"App.ActiveDocument.%s.Midplane = %i",name.c_str(),parameter->getMidplane()?1:0); - Gui::Command::doCommand(Gui::Command::Doc,"App.ActiveDocument.%s.Reversed = %i",name.c_str(),parameter->getReversed()?1:0); - Gui::Command::doCommand(Gui::Command::Doc,"App.ActiveDocument.recompute()"); - if (revolve->isValid()) { - if (sketch) - Gui::Command::doCommand(Gui::Command::Gui,"Gui.activeDocument().hide(\"%s\")",sketch->getNameInDocument()); - if (support) - Gui::Command::doCommand(Gui::Command::Gui,"Gui.activeDocument().hide(\"%s\")",support->getNameInDocument()); - } - Gui::Command::doCommand(Gui::Command::Gui,"Gui.activeDocument().resetEdit()"); - Gui::Command::commitCommand(); - + parameter->apply(); return true; } diff --git a/src/Mod/PartDesign/Gui/TaskRevolutionParameters.h b/src/Mod/PartDesign/Gui/TaskRevolutionParameters.h index 6b0d9eec7..1240a422f 100644 --- a/src/Mod/PartDesign/Gui/TaskRevolutionParameters.h +++ b/src/Mod/PartDesign/Gui/TaskRevolutionParameters.h @@ -52,11 +52,7 @@ public: TaskRevolutionParameters(ViewProviderRevolution *RevolutionView,QWidget *parent = 0); ~TaskRevolutionParameters(); - QString getReferenceAxis(void) const; - double getAngle(void) const; - bool getMidplane(void) const; - bool getReversed(void) const; - const bool updateView() const; + void apply(); private Q_SLOTS: void onAngleChanged(double); @@ -67,6 +63,11 @@ private Q_SLOTS: protected: void changeEvent(QEvent *e); + const bool updateView() const; + QString getReferenceAxis(void) const; + double getAngle(void) const; + bool getMidplane(void) const; + bool getReversed(void) const; private: diff --git a/src/Mod/PartDesign/Gui/TaskScaledParameters.cpp b/src/Mod/PartDesign/Gui/TaskScaledParameters.cpp index 0966ff2ba..4ad3f6dcd 100644 --- a/src/Mod/PartDesign/Gui/TaskScaledParameters.cpp +++ b/src/Mod/PartDesign/Gui/TaskScaledParameters.cpp @@ -92,8 +92,8 @@ void TaskScaledParameters::setupUI() { connect(ui->spinFactor, SIGNAL(valueChanged(double)), this, SLOT(onFactor(double))); - connect(ui->spinOccurrences, SIGNAL(valueChanged(int)), - this, SLOT(onOccurrences(int))); + connect(ui->spinOccurrences, SIGNAL(valueChanged(double)), + this, SLOT(onOccurrences(double))); connect(ui->checkBoxUpdateView, SIGNAL(toggled(bool)), this, SLOT(onUpdateView(bool))); @@ -112,9 +112,11 @@ void TaskScaledParameters::setupUI() } // --------------------- + ui->spinFactor->bind(pcScaled->Factor); + ui->spinOccurrences->bind(pcScaled->Occurrences); ui->spinFactor->setEnabled(true); ui->spinOccurrences->setEnabled(true); - ui->spinFactor->setDecimals(Base::UnitsApi::getDecimals()); + //ui->spinFactor->setDecimals(Base::UnitsApi::getDecimals()); updateUI(); } @@ -144,7 +146,8 @@ void TaskScaledParameters::onSelectionChanged(const Gui::SelectionChanges& msg) } } -void TaskScaledParameters::onFactor(const double f) { +void TaskScaledParameters::onFactor(const double f) +{ if (blockUpdate) return; PartDesign::Scaled* pcScaled = static_cast(getObject()); @@ -152,11 +155,12 @@ void TaskScaledParameters::onFactor(const double f) { recomputeFeature(); } -void TaskScaledParameters::onOccurrences(const int n) { +void TaskScaledParameters::onOccurrences(const double n) +{ if (blockUpdate) return; PartDesign::Scaled* pcScaled = static_cast(getObject()); - pcScaled->Occurrences.setValue(n); + pcScaled->Occurrences.setValue(round(n)); recomputeFeature(); } @@ -174,15 +178,14 @@ void TaskScaledParameters::onUpdateView(bool on) const double TaskScaledParameters::getFactor(void) const { - return ui->spinFactor->value(); + return ui->spinFactor->value().getValue(); } const unsigned TaskScaledParameters::getOccurrences(void) const { - return ui->spinOccurrences->value(); + return round(ui->spinOccurrences->value().getValue()); } - TaskScaledParameters::~TaskScaledParameters() { delete ui; @@ -198,6 +201,19 @@ void TaskScaledParameters::changeEvent(QEvent *e) } } +void TaskScaledParameters::apply() +{ + std::string name = TransformedView->getObject()->getNameInDocument(); + + Gui::Command::doCommand(Gui::Command::Doc,"App.ActiveDocument.%s.Factor = %f",name.c_str(), getFactor()); + Gui::Command::doCommand(Gui::Command::Doc,"App.ActiveDocument.%s.Occurrences = %u",name.c_str(), getOccurrences()); + Gui::Command::doCommand(Gui::Command::Doc,"App.ActiveDocument.recompute()"); + if (!TransformedView->getObject()->isValid()) + throw Base::Exception(TransformedView->getObject()->getStatusString()); + Gui::Command::doCommand(Gui::Command::Gui,"Gui.activeDocument().resetEdit()"); + Gui::Command::commitCommand(); +} + //************************************************************************** //************************************************************************** // TaskDialog @@ -214,22 +230,13 @@ TaskDlgScaledParameters::TaskDlgScaledParameters(ViewProviderScaled *ScaledView) bool TaskDlgScaledParameters::accept() { - std::string name = TransformedView->getObject()->getNameInDocument(); - try { //Gui::Command::openCommand("Scaled changed"); // Handle Originals if (!TaskDlgTransformedParameters::accept()) return false; - TaskScaledParameters* scaledParameter = static_cast(parameter); - Gui::Command::doCommand(Gui::Command::Doc,"App.ActiveDocument.%s.Factor = %f",name.c_str(),scaledParameter->getFactor()); - Gui::Command::doCommand(Gui::Command::Doc,"App.ActiveDocument.%s.Occurrences = %u",name.c_str(),scaledParameter->getOccurrences()); - Gui::Command::doCommand(Gui::Command::Doc,"App.ActiveDocument.recompute()"); - if (!TransformedView->getObject()->isValid()) - throw Base::Exception(TransformedView->getObject()->getStatusString()); - Gui::Command::doCommand(Gui::Command::Gui,"Gui.activeDocument().resetEdit()"); - Gui::Command::commitCommand(); + parameter->apply(); } catch (const Base::Exception& e) { QMessageBox::warning(parameter, tr("Input error"), QString::fromAscii(e.what())); diff --git a/src/Mod/PartDesign/Gui/TaskScaledParameters.h b/src/Mod/PartDesign/Gui/TaskScaledParameters.h index 80ab2958d..432534ce4 100644 --- a/src/Mod/PartDesign/Gui/TaskScaledParameters.h +++ b/src/Mod/PartDesign/Gui/TaskScaledParameters.h @@ -56,17 +56,18 @@ public: TaskScaledParameters(TaskMultiTransformParameters *parentTask, QLayout *layout); virtual ~TaskScaledParameters(); - const double getFactor(void) const; - const unsigned getOccurrences(void) const; + virtual void apply(); private Q_SLOTS: void onFactor(const double f); - void onOccurrences(const int n); + void onOccurrences(const double n); virtual void onUpdateView(bool); protected: virtual void changeEvent(QEvent *e); virtual void onSelectionChanged(const Gui::SelectionChanges& msg); + const double getFactor(void) const; + const unsigned getOccurrences(void) const; private: void setupUI(); diff --git a/src/Mod/PartDesign/Gui/TaskScaledParameters.ui b/src/Mod/PartDesign/Gui/TaskScaledParameters.ui index 562d47607..7b0ead986 100644 --- a/src/Mod/PartDesign/Gui/TaskScaledParameters.ui +++ b/src/Mod/PartDesign/Gui/TaskScaledParameters.ui @@ -38,20 +38,7 @@ - - - 3 - - - 999999.000000000000000 - - - 0.500000000000000 - - - 2.000000000000000 - - + @@ -65,14 +52,7 @@ - - - 2 - - - 99999 - - + @@ -112,6 +92,13 @@ + + + Gui::QuantitySpinBox + QWidget +
Gui/QuantitySpinBox.h
+
+
diff --git a/src/Mod/PartDesign/Gui/TaskTransformedParameters.h b/src/Mod/PartDesign/Gui/TaskTransformedParameters.h index b6c01ba8c..06de7ae15 100644 --- a/src/Mod/PartDesign/Gui/TaskTransformedParameters.h +++ b/src/Mod/PartDesign/Gui/TaskTransformedParameters.h @@ -66,6 +66,8 @@ public: void exitSelectionMode(); + virtual void apply() = 0; + protected Q_SLOTS: /// Connect the subTask OK button to the MultiTransform task virtual void onSubTaskButtonOK() {}