diff --git a/src/Gui/InputField.cpp b/src/Gui/InputField.cpp index 50df3f4f2..b0ab87c31 100644 --- a/src/Gui/InputField.cpp +++ b/src/Gui/InputField.cpp @@ -201,6 +201,14 @@ std::vector InputField::getHistory(void) return res; } +void InputField::setToLastUsedValue(void) +{ + std::vector hist = getHistory(); + if(hist.size()>0) + this->setText(hist[0]); +} + + void InputField::pushToSavedValues(const QString &valueq) { std::string value; diff --git a/src/Gui/InputField.h b/src/Gui/InputField.h index 9eec33195..3c31be05f 100644 --- a/src/Gui/InputField.h +++ b/src/Gui/InputField.h @@ -70,6 +70,8 @@ public: */ void setUnit(const Base::Unit&); + /// set the input field to the last used value (works only if the setParamGrpPath() was called) + void setToLastUsedValue(void); /// get the value of the singleStep property double singleStep(void)const; /// set the value of the singleStep property diff --git a/src/Mod/PartDesign/App/FeaturePad.cpp b/src/Mod/PartDesign/App/FeaturePad.cpp index 6168d9a9d..8fce92d35 100644 --- a/src/Mod/PartDesign/App/FeaturePad.cpp +++ b/src/Mod/PartDesign/App/FeaturePad.cpp @@ -58,7 +58,9 @@ Pad::Pad() ADD_PROPERTY(Type,((long)0)); Type.setEnums(TypeEnums); ADD_PROPERTY(Length,(100.0)); + Length.setUnit(Base::Unit::Length); ADD_PROPERTY(Length2,(100.0)); + Length2.setUnit(Base::Unit::Length); ADD_PROPERTY_TYPE(UpToFace,(0),"Pad",(App::PropertyType)(App::Prop_None),"Face where feature will end"); } diff --git a/src/Mod/PartDesign/App/FeaturePad.h b/src/Mod/PartDesign/App/FeaturePad.h index 6bfb9e609..bf8bbd43f 100644 --- a/src/Mod/PartDesign/App/FeaturePad.h +++ b/src/Mod/PartDesign/App/FeaturePad.h @@ -26,6 +26,7 @@ #include #include +#include #include "FeatureAdditive.h" namespace PartDesign @@ -39,8 +40,8 @@ public: Pad(); App::PropertyEnumeration Type; - App::PropertyLength Length; - App::PropertyLength Length2; + App::PropertyQuantity Length; + App::PropertyQuantity Length2; App::PropertyLinkSub UpToFace; /** @name methods override feature */ diff --git a/src/Mod/PartDesign/Gui/Command.cpp b/src/Mod/PartDesign/Gui/Command.cpp index 68ecf7b5c..2a21b7f88 100644 --- a/src/Mod/PartDesign/Gui/Command.cpp +++ b/src/Mod/PartDesign/Gui/Command.cpp @@ -211,7 +211,7 @@ void CmdPartDesignPad::activated(int iMsg) if (support) doCommand(Gui,"Gui.activeDocument().hide(\"%s\")",support->getNameInDocument()); } - doCommand(Gui,"Gui.activeDocument().setEdit('%s')",FeatName.c_str()); + doCommand(Gui,"Gui.activeDocument().setEdit('%s',1)",FeatName.c_str()); //commitCommand(); adjustCameraPosition(); diff --git a/src/Mod/PartDesign/Gui/TaskPadParameters.cpp b/src/Mod/PartDesign/Gui/TaskPadParameters.cpp index d30b88720..ef1ee4a28 100644 --- a/src/Mod/PartDesign/Gui/TaskPadParameters.cpp +++ b/src/Mod/PartDesign/Gui/TaskPadParameters.cpp @@ -52,7 +52,7 @@ using namespace Gui; /* TRANSLATOR PartDesignGui::TaskPadParameters */ -TaskPadParameters::TaskPadParameters(ViewProviderPad *PadView,QWidget *parent) +TaskPadParameters::TaskPadParameters(ViewProviderPad *PadView,bool newObj, QWidget *parent) : TaskBox(Gui::BitmapFactory().pixmap("PartDesign_Pad"),tr("Pad parameters"),true, parent),PadView(PadView) { // we need a separate container widget to add all controls to @@ -89,12 +89,16 @@ TaskPadParameters::TaskPadParameters(ViewProviderPad *PadView,QWidget *parent) ui->lineFaceName->blockSignals(true); ui->changeMode->blockSignals(true); + // set the history path + ui->lengthEdit->setParamGrpPath(QByteArray("User parameter:BaseApp/History/PadLength")); + ui->lengthEdit2->setParamGrpPath(QByteArray("User parameter:BaseApp/History/PadLength2")); + // Get the feature data PartDesign::Pad* pcPad = static_cast(PadView->getObject()); - double l = pcPad->Length.getValue(); + Base::Quantity l = pcPad->Length.getQuantityValue(); bool midplane = pcPad->Midplane.getValue(); bool reversed = pcPad->Reversed.getValue(); - double l2 = pcPad->Length2.getValue(); + Base::Quantity l2 = pcPad->Length2.getQuantityValue(); int index = pcPad->Type.getValue(); // must extract value here, clear() kills it! std::vector subStrings = pcPad->UpToFace.getSubValues(); std::string upToFace; @@ -112,6 +116,13 @@ TaskPadParameters::TaskPadParameters(ViewProviderPad *PadView,QWidget *parent) ui->lengthEdit2->setMinimum(0); ui->lengthEdit2->setMaximum(INT_MAX); ui->lengthEdit2->setValue(l2); + + // if it is a newly created object use the last value of the history + if(newObj){ + ui->lengthEdit->setToLastUsedValue(); + ui->lengthEdit2->setToLastUsedValue(); + } + ui->checkBoxMidplane->setChecked(midplane); // According to bug #0000521 the reversed option // shouldn't be de-activated if the pad has a support face @@ -143,7 +154,7 @@ void TaskPadParameters::updateUI(int index) { if (index == 0) { // dimension ui->lengthEdit->setEnabled(true); - ui->lengthEdit->selectAll(); + ui->lengthEdit->selectNumber(); // Make sure that the spin box has the focus to get key events // Calling setFocus() directly doesn't work because the spin box is not // yet visible. @@ -429,16 +440,23 @@ void TaskPadParameters::changeEvent(QEvent *e) } } +void TaskPadParameters::saveHistory(void) +{ + // save the user values to history + ui->lengthEdit->pushToHistory(); + ui->lengthEdit2->pushToHistory(); +} + //************************************************************************** //************************************************************************** // TaskDialog //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -TaskDlgPadParameters::TaskDlgPadParameters(ViewProviderPad *PadView) +TaskDlgPadParameters::TaskDlgPadParameters(ViewProviderPad *PadView,bool newObj) : TaskDialog(),PadView(PadView) { assert(PadView); - parameter = new TaskPadParameters(PadView); + parameter = new TaskPadParameters(PadView,newObj); Content.push_back(parameter); } @@ -465,6 +483,9 @@ 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()); diff --git a/src/Mod/PartDesign/Gui/TaskPadParameters.h b/src/Mod/PartDesign/Gui/TaskPadParameters.h index e17a30527..e94e7842b 100644 --- a/src/Mod/PartDesign/Gui/TaskPadParameters.h +++ b/src/Mod/PartDesign/Gui/TaskPadParameters.h @@ -49,7 +49,7 @@ class TaskPadParameters : public Gui::TaskView::TaskBox, public Gui::SelectionOb Q_OBJECT public: - TaskPadParameters(ViewProviderPad *PadView,QWidget *parent = 0); + TaskPadParameters(ViewProviderPad *PadView,bool newObj=false,QWidget *parent = 0); ~TaskPadParameters(); int getMode(void) const; @@ -59,6 +59,7 @@ public: bool getMidplane(void) const; QByteArray getFaceName(void) const; const bool updateView() const; + void saveHistory(void); private Q_SLOTS: void onLengthChanged(double); @@ -89,7 +90,7 @@ class TaskDlgPadParameters : public Gui::TaskView::TaskDialog Q_OBJECT public: - TaskDlgPadParameters(ViewProviderPad *PadView); + TaskDlgPadParameters(ViewProviderPad *PadView,bool newObj=false); ~TaskDlgPadParameters(); ViewProviderPad* getPadView() const diff --git a/src/Mod/PartDesign/Gui/ViewProviderPad.cpp b/src/Mod/PartDesign/Gui/ViewProviderPad.cpp index 927d70392..e9a22cae1 100644 --- a/src/Mod/PartDesign/Gui/ViewProviderPad.cpp +++ b/src/Mod/PartDesign/Gui/ViewProviderPad.cpp @@ -65,7 +65,7 @@ void ViewProviderPad::setupContextMenu(QMenu* menu, QObject* receiver, const cha bool ViewProviderPad::setEdit(int ModNum) { - if (ModNum == ViewProvider::Default ) { + if (ModNum == ViewProvider::Default || ModNum == 1 ) { // When double-clicking on the item for this pad the // object unsets and sets its edit mode without closing // the task panel @@ -95,7 +95,7 @@ bool ViewProviderPad::setEdit(int ModNum) if (padDlg) Gui::Control().showDialog(padDlg); else - Gui::Control().showDialog(new TaskDlgPadParameters(this)); + Gui::Control().showDialog(new TaskDlgPadParameters(this,ModNum == 1)); return true; }