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:
parent
96486cc4ed
commit
d43525370c
|
@ -27,6 +27,7 @@
|
||||||
|
|
||||||
#include <Gui/Application.h>
|
#include <Gui/Application.h>
|
||||||
#include <Gui/Command.h>
|
#include <Gui/Command.h>
|
||||||
|
#include <Gui/BitmapFactory.h>
|
||||||
#include <Mod/PartDesign/App/Feature.h>
|
#include <Mod/PartDesign/App/Feature.h>
|
||||||
#include <Mod/PartDesign/App/Body.h>
|
#include <Mod/PartDesign/App/Body.h>
|
||||||
|
|
||||||
|
@ -35,6 +36,31 @@
|
||||||
using namespace PartDesignGui;
|
using namespace PartDesignGui;
|
||||||
using namespace Gui;
|
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 *
|
* Task Dialog *
|
||||||
*********************************************************************/
|
*********************************************************************/
|
||||||
|
@ -53,6 +79,12 @@ bool TaskDlgFeatureParameters::accept() {
|
||||||
App::DocumentObject* feature = vp->getObject();
|
App::DocumentObject* feature = vp->getObject();
|
||||||
|
|
||||||
try {
|
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
|
// Make sure the feature is what we are expecting
|
||||||
// Should be fine but you never know...
|
// Should be fine but you never know...
|
||||||
if ( !feature->getTypeId().isDerivedFrom(PartDesign::Feature::getClassTypeId()) ) {
|
if ( !feature->getTypeId().isDerivedFrom(PartDesign::Feature::getClassTypeId()) ) {
|
||||||
|
|
|
@ -24,12 +24,40 @@
|
||||||
#define TASKFEATUREPARAMETERS_H_NAHKE2YZ
|
#define TASKFEATUREPARAMETERS_H_NAHKE2YZ
|
||||||
|
|
||||||
|
|
||||||
|
#include <Gui/TaskView/TaskView.h>
|
||||||
#include <Gui/TaskView/TaskDialog.h>
|
#include <Gui/TaskView/TaskDialog.h>
|
||||||
|
|
||||||
#include "ViewProvider.h"
|
#include "ViewProvider.h"
|
||||||
|
|
||||||
namespace PartDesignGui {
|
namespace PartDesignGui {
|
||||||
|
|
||||||
|
/// Convenience class to collect common methods for all SketchBased features
|
||||||
|
class TaskFeatureParameters : public Gui::TaskView::TaskBox
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
|
||||||
|
public:
|
||||||
|
TaskFeatureParameters(PartDesignGui::ViewProvider* vp, QWidget *parent,
|
||||||
|
const std::string& pixmapname, const QString& parname);
|
||||||
|
virtual ~TaskFeatureParameters() {};
|
||||||
|
|
||||||
|
/// save field history
|
||||||
|
virtual void saveHistory(void) {};
|
||||||
|
/// apply changes made in the parameters input to the model via commands
|
||||||
|
virtual void apply() {};
|
||||||
|
|
||||||
|
void recomputeFeature();
|
||||||
|
|
||||||
|
protected Q_SLOTS:
|
||||||
|
// TODO Add update view to all dialogs (2015-12-05, Fat-Zer)
|
||||||
|
void onUpdateView(bool on);
|
||||||
|
|
||||||
|
protected:
|
||||||
|
PartDesignGui::ViewProvider *vp;
|
||||||
|
/// Lock updateUI(), applying changes to the underlying feature and calling recomputeFeature()
|
||||||
|
bool blockUpdate;
|
||||||
|
};
|
||||||
|
|
||||||
/// A common base for sketch based, dressup and other solid parameters dialogs
|
/// A common base for sketch based, dressup and other solid parameters dialogs
|
||||||
class TaskDlgFeatureParameters : public Gui::TaskView::TaskDialog
|
class TaskDlgFeatureParameters : public Gui::TaskView::TaskDialog
|
||||||
{
|
{
|
||||||
|
@ -37,7 +65,7 @@ class TaskDlgFeatureParameters : public Gui::TaskView::TaskDialog
|
||||||
|
|
||||||
public:
|
public:
|
||||||
TaskDlgFeatureParameters(PartDesignGui::ViewProvider *vp);
|
TaskDlgFeatureParameters(PartDesignGui::ViewProvider *vp);
|
||||||
~TaskDlgFeatureParameters();
|
virtual ~TaskDlgFeatureParameters();
|
||||||
|
|
||||||
public:
|
public:
|
||||||
/// is called by the framework if the dialog is accepted (Ok)
|
/// is called by the framework if the dialog is accepted (Ok)
|
||||||
|
@ -47,6 +75,7 @@ public:
|
||||||
|
|
||||||
/// Returns the view provider dialog is runed for
|
/// Returns the view provider dialog is runed for
|
||||||
PartDesignGui::ViewProvider *viewProvider() const { return vp; }
|
PartDesignGui::ViewProvider *viewProvider() const { return vp; }
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
PartDesignGui::ViewProvider *vp;
|
PartDesignGui::ViewProvider *vp;
|
||||||
};
|
};
|
||||||
|
|
|
@ -406,6 +406,7 @@ void TaskPadParameters::apply()
|
||||||
Gui::Command::doCommand(Gui::Command::Doc,"App.ActiveDocument.%s.Type = %u", cname, getMode());
|
Gui::Command::doCommand(Gui::Command::Doc,"App.ActiveDocument.%s.Type = %u", cname, getMode());
|
||||||
QString facename = getFaceName();
|
QString facename = getFaceName();
|
||||||
|
|
||||||
|
// TODO get rid of this if (2015-12-05, Fat-Zer)
|
||||||
if (!facename.isEmpty()) {
|
if (!facename.isEmpty()) {
|
||||||
Gui::Command::doCommand(Gui::Command::Doc,"App.ActiveDocument.%s.UpToFace = %s",
|
Gui::Command::doCommand(Gui::Command::Doc,"App.ActiveDocument.%s.UpToFace = %s",
|
||||||
cname, facename.toLatin1().data());
|
cname, facename.toLatin1().data());
|
||||||
|
@ -426,26 +427,9 @@ TaskDlgPadParameters::TaskDlgPadParameters(ViewProviderPad *PadView,bool newObj)
|
||||||
: TaskDlgSketchBasedParameters(PadView)
|
: TaskDlgSketchBasedParameters(PadView)
|
||||||
{
|
{
|
||||||
assert(vp);
|
assert(vp);
|
||||||
parameter = new TaskPadParameters(static_cast<ViewProviderPad*>(vp));
|
Content.push_back ( new TaskPadParameters(PadView ) );
|
||||||
|
|
||||||
Content.push_back(parameter);
|
|
||||||
}
|
|
||||||
|
|
||||||
TaskDlgPadParameters::~TaskDlgPadParameters()
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//==== calls from the TaskView ===============================================================
|
//==== calls from the TaskView ===============================================================
|
||||||
|
|
||||||
bool TaskDlgPadParameters::accept()
|
|
||||||
{
|
|
||||||
// save the history
|
|
||||||
parameter->saveHistory();
|
|
||||||
parameter->apply();
|
|
||||||
|
|
||||||
return TaskDlgSketchBasedParameters::accept();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
#include "moc_TaskPadParameters.cpp"
|
#include "moc_TaskPadParameters.cpp"
|
||||||
|
|
|
@ -52,9 +52,8 @@ public:
|
||||||
TaskPadParameters(ViewProviderPad *PadView, QWidget *parent = 0, bool newObj=false);
|
TaskPadParameters(ViewProviderPad *PadView, QWidget *parent = 0, bool newObj=false);
|
||||||
~TaskPadParameters();
|
~TaskPadParameters();
|
||||||
|
|
||||||
|
virtual void saveHistory() override;
|
||||||
void saveHistory(void);
|
virtual void apply() override;
|
||||||
void apply();
|
|
||||||
|
|
||||||
private Q_SLOTS:
|
private Q_SLOTS:
|
||||||
void onLengthChanged(double);
|
void onLengthChanged(double);
|
||||||
|
@ -92,18 +91,9 @@ class TaskDlgPadParameters : public TaskDlgSketchBasedParameters
|
||||||
|
|
||||||
public:
|
public:
|
||||||
TaskDlgPadParameters(ViewProviderPad *PadView, bool newObj=false);
|
TaskDlgPadParameters(ViewProviderPad *PadView, bool newObj=false);
|
||||||
~TaskDlgPadParameters();
|
|
||||||
|
|
||||||
ViewProviderPad* getPadView() const
|
ViewProviderPad* getPadView() const
|
||||||
{ return static_cast<ViewProviderPad*>(vp); }
|
{ return static_cast<ViewProviderPad*>(vp); }
|
||||||
|
|
||||||
|
|
||||||
public:
|
|
||||||
/// is called by the framework if the dialog is accepted (Ok)
|
|
||||||
virtual bool accept();
|
|
||||||
|
|
||||||
protected:
|
|
||||||
TaskPadParameters *parameter;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
} //namespace PartDesignGui
|
} //namespace PartDesignGui
|
||||||
|
|
|
@ -414,27 +414,7 @@ TaskDlgPocketParameters::TaskDlgPocketParameters(ViewProviderPocket *PocketView)
|
||||||
: TaskDlgSketchBasedParameters(PocketView)
|
: TaskDlgSketchBasedParameters(PocketView)
|
||||||
{
|
{
|
||||||
assert(vp);
|
assert(vp);
|
||||||
parameter = new TaskPocketParameters(static_cast<ViewProviderPocket*>(vp));
|
Content.push_back ( new TaskPocketParameters(PocketView ) );
|
||||||
|
|
||||||
Content.push_back(parameter);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
TaskDlgPocketParameters::~TaskDlgPocketParameters()
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
//==== calls from the TaskView ===============================================================
|
|
||||||
|
|
||||||
bool TaskDlgPocketParameters::accept()
|
|
||||||
{
|
|
||||||
parameter->apply();
|
|
||||||
|
|
||||||
// save the history
|
|
||||||
parameter->saveHistory();
|
|
||||||
|
|
||||||
return TaskDlgSketchBasedParameters::accept();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
#include "moc_TaskPocketParameters.cpp"
|
#include "moc_TaskPocketParameters.cpp"
|
||||||
|
|
|
@ -52,9 +52,8 @@ public:
|
||||||
TaskPocketParameters(ViewProviderPocket *PocketView, QWidget *parent = 0, bool newObj=false);
|
TaskPocketParameters(ViewProviderPocket *PocketView, QWidget *parent = 0, bool newObj=false);
|
||||||
~TaskPocketParameters();
|
~TaskPocketParameters();
|
||||||
|
|
||||||
void apply();
|
virtual void saveHistory() override;
|
||||||
|
virtual void apply() override;
|
||||||
void saveHistory(void);
|
|
||||||
|
|
||||||
private Q_SLOTS:
|
private Q_SLOTS:
|
||||||
void onLengthChanged(double);
|
void onLengthChanged(double);
|
||||||
|
@ -92,18 +91,9 @@ class TaskDlgPocketParameters : public TaskDlgSketchBasedParameters
|
||||||
|
|
||||||
public:
|
public:
|
||||||
TaskDlgPocketParameters(ViewProviderPocket *PocketView);
|
TaskDlgPocketParameters(ViewProviderPocket *PocketView);
|
||||||
~TaskDlgPocketParameters();
|
|
||||||
|
|
||||||
ViewProviderPocket* getPocketView() const
|
ViewProviderPocket* getPocketView() const
|
||||||
{ return static_cast<ViewProviderPocket*>(vp); }
|
{ return static_cast<ViewProviderPocket*>(vp); }
|
||||||
|
|
||||||
|
|
||||||
public:
|
|
||||||
/// is called by the framework if the dialog is accepted (Ok)
|
|
||||||
virtual bool accept();
|
|
||||||
|
|
||||||
protected:
|
|
||||||
TaskPocketParameters *parameter;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
} //namespace PartDesignGui
|
} //namespace PartDesignGui
|
||||||
|
|
|
@ -409,24 +409,6 @@ TaskDlgRevolutionParameters::TaskDlgRevolutionParameters(PartDesignGui::ViewProv
|
||||||
: TaskDlgSketchBasedParameters(RevolutionView)
|
: TaskDlgSketchBasedParameters(RevolutionView)
|
||||||
{
|
{
|
||||||
assert(RevolutionView);
|
assert(RevolutionView);
|
||||||
parameter = new TaskRevolutionParameters(RevolutionView);
|
Content.push_back(new TaskRevolutionParameters(RevolutionView));
|
||||||
|
|
||||||
Content.push_back(parameter);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
TaskDlgRevolutionParameters::~TaskDlgRevolutionParameters()
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
//==== calls from the TaskView ===============================================================
|
|
||||||
|
|
||||||
bool TaskDlgRevolutionParameters::accept()
|
|
||||||
{
|
|
||||||
parameter->apply();
|
|
||||||
|
|
||||||
return TaskDlgSketchBasedParameters::accept();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
#include "moc_TaskRevolutionParameters.cpp"
|
#include "moc_TaskRevolutionParameters.cpp"
|
||||||
|
|
|
@ -53,7 +53,7 @@ public:
|
||||||
TaskRevolutionParameters(ViewProvider* RevolutionView,QWidget *parent = 0);
|
TaskRevolutionParameters(ViewProvider* RevolutionView,QWidget *parent = 0);
|
||||||
~TaskRevolutionParameters();
|
~TaskRevolutionParameters();
|
||||||
|
|
||||||
void apply();
|
virtual void apply() override;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief fillAxisCombo fills the combo and selects the item according to
|
* @brief fillAxisCombo fills the combo and selects the item according to
|
||||||
|
@ -111,17 +111,9 @@ class TaskDlgRevolutionParameters : public TaskDlgSketchBasedParameters
|
||||||
|
|
||||||
public:
|
public:
|
||||||
TaskDlgRevolutionParameters(PartDesignGui::ViewProvider *RevolutionView);
|
TaskDlgRevolutionParameters(PartDesignGui::ViewProvider *RevolutionView);
|
||||||
~TaskDlgRevolutionParameters();
|
|
||||||
|
|
||||||
ViewProvider* getRevolutionView() const
|
ViewProvider* getRevolutionView() const
|
||||||
{ return vp; }
|
{ return vp; }
|
||||||
|
|
||||||
public:
|
|
||||||
/// is called by the framework if the dialog is accepted (Ok)
|
|
||||||
virtual bool accept();
|
|
||||||
|
|
||||||
protected:
|
|
||||||
TaskRevolutionParameters *parameter;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
} //namespace PartDesignGui
|
} //namespace PartDesignGui
|
||||||
|
|
|
@ -60,8 +60,7 @@ using namespace Gui;
|
||||||
|
|
||||||
TaskSketchBasedParameters::TaskSketchBasedParameters(PartDesignGui::ViewProvider *vp, QWidget *parent,
|
TaskSketchBasedParameters::TaskSketchBasedParameters(PartDesignGui::ViewProvider *vp, QWidget *parent,
|
||||||
const std::string& pixmapname, const QString& parname)
|
const std::string& pixmapname, const QString& parname)
|
||||||
: TaskBox(Gui::BitmapFactory().pixmap(pixmapname.c_str()),parname,true, parent),
|
: TaskFeatureParameters(vp, parent, pixmapname, parname)
|
||||||
vp(vp), blockUpdate(false)
|
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -172,7 +171,7 @@ const QByteArray TaskSketchBasedParameters::onFaceName(const QString& text)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
QString TaskSketchBasedParameters::getFaceReference(const QString& obj, const QString& sub) const
|
QString TaskSketchBasedParameters::getFaceReference(const QString& obj, const QString& sub)
|
||||||
{
|
{
|
||||||
QString o = obj.left(obj.indexOf(QString::fromAscii(":")));
|
QString o = obj.left(obj.indexOf(QString::fromAscii(":")));
|
||||||
|
|
||||||
|
@ -183,20 +182,6 @@ QString TaskSketchBasedParameters::getFaceReference(const QString& obj, const QS
|
||||||
QString::fromAscii(", [\"") + sub + QString::fromAscii("\"])");
|
QString::fromAscii(", [\"") + sub + QString::fromAscii("\"])");
|
||||||
}
|
}
|
||||||
|
|
||||||
void TaskSketchBasedParameters::onUpdateView(bool on)
|
|
||||||
{
|
|
||||||
blockUpdate = !on;
|
|
||||||
recomputeFeature();
|
|
||||||
}
|
|
||||||
|
|
||||||
void TaskSketchBasedParameters::recomputeFeature()
|
|
||||||
{
|
|
||||||
if (!blockUpdate) {
|
|
||||||
PartDesign::SketchBased* pcSketchBased = static_cast<PartDesign::SketchBased*>(vp->getObject());
|
|
||||||
pcSketchBased->getDocument()->recomputeFeature(pcSketchBased);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
TaskSketchBasedParameters::~TaskSketchBasedParameters()
|
TaskSketchBasedParameters::~TaskSketchBasedParameters()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
@ -259,5 +244,4 @@ bool TaskDlgSketchBasedParameters::reject()
|
||||||
return rv;
|
return rv;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
#include "moc_TaskSketchBasedParameters.cpp"
|
#include "moc_TaskSketchBasedParameters.cpp"
|
||||||
|
|
|
@ -24,7 +24,6 @@
|
||||||
#ifndef GUI_TASKVIEW_TaskSketchBasedParameters_H
|
#ifndef GUI_TASKVIEW_TaskSketchBasedParameters_H
|
||||||
#define GUI_TASKVIEW_TaskSketchBasedParameters_H
|
#define GUI_TASKVIEW_TaskSketchBasedParameters_H
|
||||||
|
|
||||||
#include <Gui/TaskView/TaskView.h>
|
|
||||||
#include <Gui/Selection.h>
|
#include <Gui/Selection.h>
|
||||||
#include "ViewProvider.h"
|
#include "ViewProvider.h"
|
||||||
|
|
||||||
|
@ -38,7 +37,7 @@ namespace PartDesignGui {
|
||||||
|
|
||||||
|
|
||||||
/// Convenience class to collect common methods for all SketchBased features
|
/// Convenience class to collect common methods for all SketchBased features
|
||||||
class TaskSketchBasedParameters : public Gui::TaskView::TaskBox, public Gui::SelectionObserver
|
class TaskSketchBasedParameters : public PartDesignGui::TaskFeatureParameters, public Gui::SelectionObserver
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
|
@ -53,16 +52,8 @@ protected:
|
||||||
void onSelectReference(const bool pressed, const bool edge, const bool face, const bool planar);
|
void onSelectReference(const bool pressed, const bool edge, const bool face, const bool planar);
|
||||||
void exitSelectionMode();
|
void exitSelectionMode();
|
||||||
const QByteArray onFaceName(const QString& text);
|
const QByteArray onFaceName(const QString& text);
|
||||||
QString getFaceReference(const QString& obj, const QString& sub) const;
|
|
||||||
void recomputeFeature();
|
|
||||||
|
|
||||||
protected Q_SLOTS:
|
static QString getFaceReference(const QString& obj, const QString& sub);
|
||||||
void onUpdateView(bool on);
|
|
||||||
|
|
||||||
protected:
|
|
||||||
PartDesignGui::ViewProvider *vp;
|
|
||||||
/// Lock updateUI(), applying changes to the underlying feature and calling recomputeFeature()
|
|
||||||
bool blockUpdate;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
class TaskDlgSketchBasedParameters : public PartDesignGui::TaskDlgFeatureParameters
|
class TaskDlgSketchBasedParameters : public PartDesignGui::TaskDlgFeatureParameters
|
||||||
|
|
Loading…
Reference in New Issue
Block a user