Some code unification for sketchbased features
This commit is contained in:
committed by
Stefan Tröger
parent
c382fb3afb
commit
dfd27740a9
@@ -128,8 +128,7 @@ void TaskGrooveParameters::onAngleChanged(double len)
|
||||
{
|
||||
PartDesign::Groove* pcGroove = static_cast<PartDesign::Groove*>(vp->getObject());
|
||||
pcGroove->Angle.setValue(len);
|
||||
if (updateView())
|
||||
pcGroove->getDocument()->recomputeFeature(pcGroove);
|
||||
recomputeFeature();
|
||||
}
|
||||
|
||||
void TaskGrooveParameters::onAxisChanged(int num)
|
||||
@@ -166,24 +165,21 @@ void TaskGrooveParameters::onAxisChanged(int num)
|
||||
}
|
||||
}
|
||||
}
|
||||
if (updateView())
|
||||
pcGroove->getDocument()->recomputeFeature(pcGroove);
|
||||
recomputeFeature();
|
||||
}
|
||||
|
||||
void TaskGrooveParameters::onMidplane(bool on)
|
||||
{
|
||||
PartDesign::Groove* pcGroove = static_cast<PartDesign::Groove*>(vp->getObject());
|
||||
pcGroove->Midplane.setValue(on);
|
||||
if (updateView())
|
||||
pcGroove->getDocument()->recomputeFeature(pcGroove);
|
||||
recomputeFeature();
|
||||
}
|
||||
|
||||
void TaskGrooveParameters::onReversed(bool on)
|
||||
{
|
||||
PartDesign::Groove* pcGroove = static_cast<PartDesign::Groove*>(vp->getObject());
|
||||
pcGroove->Reversed.setValue(on);
|
||||
if (updateView())
|
||||
pcGroove->getDocument()->recomputeFeature(pcGroove);
|
||||
recomputeFeature();
|
||||
}
|
||||
|
||||
double TaskGrooveParameters::getAngle(void) const
|
||||
@@ -226,11 +222,6 @@ bool TaskGrooveParameters::getReversed(void) const
|
||||
return ui->checkBoxReversed->isChecked();
|
||||
}
|
||||
|
||||
const bool TaskGrooveParameters::updateView() const
|
||||
{
|
||||
return ui->checkBoxUpdateView->isChecked();
|
||||
}
|
||||
|
||||
TaskGrooveParameters::~TaskGrooveParameters()
|
||||
{
|
||||
delete ui;
|
||||
|
||||
@@ -243,8 +243,7 @@ void TaskPadParameters::onLengthChanged(double len)
|
||||
{
|
||||
PartDesign::Pad* pcPad = static_cast<PartDesign::Pad*>(vp->getObject());
|
||||
pcPad->Length.setValue(len);
|
||||
if (updateView())
|
||||
pcPad->getDocument()->recomputeFeature(pcPad);
|
||||
recomputeFeature();
|
||||
}
|
||||
|
||||
void TaskPadParameters::onMidplane(bool on)
|
||||
@@ -252,24 +251,21 @@ void TaskPadParameters::onMidplane(bool on)
|
||||
PartDesign::Pad* pcPad = static_cast<PartDesign::Pad*>(vp->getObject());
|
||||
pcPad->Midplane.setValue(on);
|
||||
ui->checkBoxReversed->setEnabled(!on);
|
||||
if (updateView())
|
||||
pcPad->getDocument()->recomputeFeature(pcPad);
|
||||
recomputeFeature();
|
||||
}
|
||||
|
||||
void TaskPadParameters::onReversed(bool on)
|
||||
{
|
||||
PartDesign::Pad* pcPad = static_cast<PartDesign::Pad*>(vp->getObject());
|
||||
pcPad->Reversed.setValue(on);
|
||||
if (updateView())
|
||||
pcPad->getDocument()->recomputeFeature(pcPad);
|
||||
recomputeFeature();
|
||||
}
|
||||
|
||||
void TaskPadParameters::onLength2Changed(double len)
|
||||
{
|
||||
PartDesign::Pad* pcPad = static_cast<PartDesign::Pad*>(vp->getObject());
|
||||
pcPad->Length2.setValue(len);
|
||||
if (updateView())
|
||||
pcPad->getDocument()->recomputeFeature(pcPad);
|
||||
recomputeFeature();
|
||||
}
|
||||
|
||||
void TaskPadParameters::onModeChanged(int index)
|
||||
@@ -290,13 +286,12 @@ void TaskPadParameters::onModeChanged(int index)
|
||||
}
|
||||
|
||||
updateUI(index);
|
||||
|
||||
if (updateView())
|
||||
pcPad->getDocument()->recomputeFeature(pcPad);
|
||||
recomputeFeature();
|
||||
}
|
||||
|
||||
void TaskPadParameters::onButtonFace(const bool pressed)
|
||||
{
|
||||
TaskSketchBasedParameters::onSelectReference(pressed, false, true, false);
|
||||
|
||||
// Update button if onButtonFace() is called explicitly
|
||||
ui->buttonFace->setChecked(pressed);
|
||||
@@ -340,11 +335,6 @@ QByteArray TaskPadParameters::getFaceName(void) const
|
||||
return "";
|
||||
}
|
||||
|
||||
const bool TaskPadParameters::updateView() const
|
||||
{
|
||||
return ui->checkBoxUpdateView->isChecked();
|
||||
}
|
||||
|
||||
TaskPadParameters::~TaskPadParameters()
|
||||
{
|
||||
delete ui;
|
||||
|
||||
@@ -53,7 +53,6 @@ public:
|
||||
TaskPadParameters(ViewProviderPad *PadView,bool newObj=false,QWidget *parent = 0);
|
||||
~TaskPadParameters();
|
||||
|
||||
const bool updateView() const;
|
||||
void saveHistory(void);
|
||||
void apply();
|
||||
|
||||
|
||||
@@ -225,8 +225,7 @@ void TaskPocketParameters::onLengthChanged(double len)
|
||||
{
|
||||
PartDesign::Pocket* pcPocket = static_cast<PartDesign::Pocket*>(vp->getObject());
|
||||
pcPocket->Length.setValue(len);
|
||||
if (updateView())
|
||||
pcPocket->getDocument()->recomputeFeature(pcPocket);
|
||||
recomputeFeature();
|
||||
}
|
||||
|
||||
void TaskPocketParameters::onMidplaneChanged(bool on)
|
||||
@@ -234,16 +233,14 @@ void TaskPocketParameters::onMidplaneChanged(bool on)
|
||||
PartDesign::Pocket* pcPocket = static_cast<PartDesign::Pocket*>(vp->getObject());
|
||||
pcPocket->Midplane.setValue(on);
|
||||
ui->checkBoxReversed->setEnabled(!on);
|
||||
if (updateView())
|
||||
pcPocket->getDocument()->recomputeFeature(pcPocket);
|
||||
recomputeFeature();
|
||||
}
|
||||
|
||||
void TaskPocketParameters::onReversedChanged(bool on)
|
||||
{
|
||||
PartDesign::Pocket* pcPocket = static_cast<PartDesign::Pocket*>(vp->getObject());
|
||||
pcPocket->Reversed.setValue(on);
|
||||
if (updateView())
|
||||
pcPocket->getDocument()->recomputeFeature(pcPocket);
|
||||
recomputeFeature();
|
||||
}
|
||||
|
||||
void TaskPocketParameters::onModeChanged(int index)
|
||||
@@ -280,13 +277,11 @@ void TaskPocketParameters::onModeChanged(int index)
|
||||
}
|
||||
|
||||
updateUI(index);
|
||||
|
||||
if (updateView())
|
||||
pcPocket->getDocument()->recomputeFeature(pcPocket);
|
||||
recomputeFeature();
|
||||
}
|
||||
|
||||
void TaskPocketParameters::onButtonFace(const bool pressed) {
|
||||
TaskSketchBasedParameters::onButtonFace(pressed);
|
||||
TaskSketchBasedParameters::onSelectReference(pressed, false, true, false);
|
||||
|
||||
// Update button if onButtonFace() is called explicitly
|
||||
ui->buttonFace->setChecked(pressed);
|
||||
@@ -320,11 +315,6 @@ QByteArray TaskPocketParameters::getFaceName(void) const
|
||||
return "";
|
||||
}
|
||||
|
||||
const bool TaskPocketParameters::updateView() const
|
||||
{
|
||||
return ui->checkBoxUpdateView->isChecked();
|
||||
}
|
||||
|
||||
TaskPocketParameters::~TaskPocketParameters()
|
||||
{
|
||||
delete ui;
|
||||
|
||||
@@ -55,7 +55,6 @@ public:
|
||||
|
||||
bool getReversed(void) const;
|
||||
QByteArray getFaceName(void) const;
|
||||
const bool updateView() const;
|
||||
void apply();
|
||||
|
||||
private Q_SLOTS:
|
||||
|
||||
@@ -58,27 +58,10 @@ using namespace Gui;
|
||||
TaskSketchBasedParameters::TaskSketchBasedParameters(ViewProvider *vp, QWidget *parent,
|
||||
const std::string& pixmapname, const QString& parname)
|
||||
: TaskBox(Gui::BitmapFactory().pixmap(pixmapname.c_str()),parname,true, parent),
|
||||
vp(vp)
|
||||
vp(vp), blockUpdate(false)
|
||||
{
|
||||
|
||||
}
|
||||
/*
|
||||
App::DocumentObject* TaskSketchBasedParameters::getBaseFeature()
|
||||
{
|
||||
PartDesign::SketchBased* pcSketchBased = static_cast<PartDesign::SketchBased*>(vp->getObject());
|
||||
App::DocumentObject* baseFeature = pcSketchBased->BaseFeature.getValue();
|
||||
if (baseFeature == NULL) {
|
||||
if (ActivePartObject != NULL) {
|
||||
baseFeature = ActivePartObject->getPrevSolidFeature(pcSketchBased, false);
|
||||
}
|
||||
if (baseFeature == NULL) {
|
||||
// For legacy features
|
||||
baseFeature = pcSketchBased->getSupport();
|
||||
}
|
||||
}
|
||||
|
||||
return baseFeature;
|
||||
}*/
|
||||
|
||||
const QString TaskSketchBasedParameters::onAddSelection(const Gui::SelectionChanges& msg)
|
||||
{
|
||||
@@ -101,13 +84,12 @@ const QString TaskSketchBasedParameters::onAddSelection(const Gui::SelectionChan
|
||||
|
||||
std::vector<std::string> upToFaces(1,subname);
|
||||
pcSketchBased->UpToFace.setValue(selObj, upToFaces);
|
||||
if (updateView())
|
||||
pcSketchBased->getDocument()->recomputeFeature(pcSketchBased);
|
||||
recomputeFeature();
|
||||
|
||||
return refStr;
|
||||
}
|
||||
|
||||
void TaskSketchBasedParameters::onButtonFace(const bool pressed) {
|
||||
void TaskSketchBasedParameters::onSelectReference(const bool pressed, const bool edge, const bool face, const bool planar) {
|
||||
// Note: Even if there is no solid, App::Plane and Part::Datum can still be selected
|
||||
App::DocumentObject* solid = PartDesignGui::ActivePartObject->getPrevSolidFeature(NULL, false);
|
||||
PartDesign::SketchBased* pcSketchBased = static_cast<PartDesign::SketchBased*>(vp->getObject());
|
||||
@@ -120,7 +102,7 @@ void TaskSketchBasedParameters::onButtonFace(const bool pressed) {
|
||||
}
|
||||
Gui::Selection().clearSelection();
|
||||
Gui::Selection().addSelectionGate
|
||||
(new ReferenceSelection(solid, false, true, false));
|
||||
(new ReferenceSelection(solid, edge, face, planar));
|
||||
} else {
|
||||
Gui::Selection().rmvSelectionGate();
|
||||
Gui::Document* doc = Gui::Application::Instance->activeDocument();
|
||||
@@ -168,8 +150,7 @@ const QByteArray TaskSketchBasedParameters::onFaceName(const QString& text)
|
||||
std::vector<std::string> upToFaces(1,ss.str());
|
||||
PartDesign::SketchBased* pcSketchBased = static_cast<PartDesign::SketchBased*>(vp->getObject());
|
||||
pcSketchBased->UpToFace.setValue(obj, upToFaces);
|
||||
if (updateView())
|
||||
pcSketchBased->getDocument()->recomputeFeature(pcSketchBased);
|
||||
recomputeFeature();
|
||||
|
||||
return QByteArray(ss.str().c_str());
|
||||
}
|
||||
@@ -188,7 +169,13 @@ QString TaskSketchBasedParameters::getFaceReference(const QString& obj, const QS
|
||||
|
||||
void TaskSketchBasedParameters::onUpdateView(bool on)
|
||||
{
|
||||
if (on) {
|
||||
blockUpdate = !on;
|
||||
recomputeFeature();
|
||||
}
|
||||
|
||||
void TaskSketchBasedParameters::recomputeFeature()
|
||||
{
|
||||
if (!blockUpdate) {
|
||||
PartDesign::SketchBased* pcSketchBased = static_cast<PartDesign::SketchBased*>(vp->getObject());
|
||||
pcSketchBased->getDocument()->recomputeFeature(pcSketchBased);
|
||||
}
|
||||
|
||||
@@ -46,21 +46,21 @@ public:
|
||||
const std::string& pixmapname, const QString& parname);
|
||||
~TaskSketchBasedParameters();
|
||||
|
||||
//App::DocumentObject* getBaseFeature();
|
||||
|
||||
protected:
|
||||
void onSelectionChanged(const Gui::SelectionChanges& msg)=0;
|
||||
const QString onAddSelection(const Gui::SelectionChanges& msg);
|
||||
void onButtonFace(const bool pressed = true);
|
||||
void onSelectReference(const bool pressed, const bool edge, const bool face, const bool planar);
|
||||
const QByteArray onFaceName(const QString& text);
|
||||
QString getFaceReference(const QString& obj, const QString& sub) const;
|
||||
virtual const bool updateView() const=0;
|
||||
void recomputeFeature();
|
||||
|
||||
protected Q_SLOTS:
|
||||
void onUpdateView(bool on);
|
||||
|
||||
protected:
|
||||
ViewProvider *vp;
|
||||
/// Lock updateUI(), applying changes to the underlying feature and calling recomputeFeature()
|
||||
bool blockUpdate;
|
||||
};
|
||||
|
||||
class TaskDlgSketchBasedParameters : public Gui::TaskView::TaskDialog
|
||||
|
||||
Reference in New Issue
Block a user