PartDesignGui: small rework to sketch-based task parameters

This done mostly for thurther unification them with other task
parameters/dialogs.
This commit is contained in:
Alexander Golubev
2015-12-06 17:01:26 +03:00
committed by Stefan Tröger
parent 7d8fc476bd
commit e8b323ba20
10 changed files with 75 additions and 121 deletions

View File

@@ -27,6 +27,7 @@
#include <Gui/Application.h>
#include <Gui/Command.h>
#include <Gui/BitmapFactory.h>
#include <Mod/PartDesign/App/Feature.h>
#include <Mod/PartDesign/App/Body.h>
@@ -35,6 +36,31 @@
using namespace PartDesignGui;
using namespace Gui;
/*********************************************************************
* Task Feature Parameters *
*********************************************************************/
TaskFeatureParameters::TaskFeatureParameters(PartDesignGui::ViewProvider *vp, QWidget *parent,
const std::string& pixmapname, const QString& parname)
: TaskBox(Gui::BitmapFactory().pixmap(pixmapname.c_str()),parname,true, parent),
vp(vp), blockUpdate(false)
{ }
void TaskFeatureParameters::onUpdateView(bool on)
{
blockUpdate = !on;
recomputeFeature();
}
void TaskFeatureParameters::recomputeFeature()
{
if (!blockUpdate) {
App::DocumentObject* obj = vp->getObject ();
assert (obj);
obj->getDocument()->recomputeFeature ( obj );
}
}
/*********************************************************************
* Task Dialog *
*********************************************************************/
@@ -53,6 +79,12 @@ bool TaskDlgFeatureParameters::accept() {
App::DocumentObject* feature = vp->getObject();
try {
// Iterate over parameter dialogs and apply all parameters from them
for ( QWidget *wgt : Content ) {
TaskFeatureParameters *param = qobject_cast<TaskFeatureParameters *> (wgt);
param->saveHistory ();
param->apply ();
}
// Make sure the feature is what we are expecting
// Should be fine but you never know...
if ( !feature->getTypeId().isDerivedFrom(PartDesign::Feature::getClassTypeId()) ) {