Refactored code of SketchBased features to have common code in an abstract superclass
This commit is contained in:
parent
0bcdb0511f
commit
b815656649
|
@ -42,7 +42,6 @@ public:
|
|||
App::PropertyEnumeration Type;
|
||||
App::PropertyLength Length;
|
||||
App::PropertyLength Length2;
|
||||
App::PropertyLinkSub UpToFace;
|
||||
|
||||
/** @name methods override feature */
|
||||
//@{
|
||||
|
|
|
@ -39,7 +39,6 @@ public:
|
|||
|
||||
App::PropertyEnumeration Type;
|
||||
App::PropertyLength Length;
|
||||
App::PropertyLinkSub UpToFace;
|
||||
|
||||
/** @name methods override feature */
|
||||
//@{
|
||||
|
|
|
@ -93,12 +93,18 @@ App::DocumentObjectExecReturn *Revolution::execute(void)
|
|||
return new App::DocumentObjectExecReturn(e.what());
|
||||
}
|
||||
|
||||
TopoDS_Shape support;
|
||||
// if the Base property has a valid shape, fuse the AddShape into it
|
||||
TopoDS_Shape base;
|
||||
try {
|
||||
support = getSupportShape();
|
||||
base = getBaseShape();
|
||||
} catch (const Base::Exception&) {
|
||||
// ignore, because support isn't mandatory
|
||||
support = TopoDS_Shape();
|
||||
// fall back to support (for legacy features)
|
||||
try {
|
||||
base = getSupportShape();
|
||||
} catch (const Base::Exception&) {
|
||||
// ignore, because support isn't mandatory
|
||||
base = TopoDS_Shape();
|
||||
}
|
||||
}
|
||||
|
||||
// update Axis from ReferenceAxis
|
||||
|
@ -127,7 +133,7 @@ App::DocumentObjectExecReturn *Revolution::execute(void)
|
|||
TopLoc_Location invObjLoc = this->getLocation().Inverted();
|
||||
pnt.Transform(invObjLoc.Transformation());
|
||||
dir.Transform(invObjLoc.Transformation());
|
||||
support.Move(invObjLoc);
|
||||
base.Move(invObjLoc);
|
||||
sketchshape.Move(invObjLoc);
|
||||
|
||||
// Check distance between sketchshape and axis - to avoid failures and crashes
|
||||
|
@ -141,17 +147,7 @@ App::DocumentObjectExecReturn *Revolution::execute(void)
|
|||
TopoDS_Shape result = RevolMaker.Shape();
|
||||
result = refineShapeIfActive(result);
|
||||
// set the additive shape property for later usage in e.g. pattern
|
||||
this->AddShape.setValue(result);
|
||||
|
||||
// if the Base property has a valid shape, fuse the AddShape into it
|
||||
TopoDS_Shape base;
|
||||
try {
|
||||
base = getBaseShape();
|
||||
base.Move(invObjLoc);
|
||||
} catch (const Base::Exception&) {
|
||||
// fall back to support (for legacy features)
|
||||
base = support;
|
||||
}
|
||||
this->AddShape.setValue(result);
|
||||
|
||||
if (!base.IsNull()) {
|
||||
// Let's call algorithm computing a fuse operation:
|
||||
|
|
|
@ -101,13 +101,15 @@ SketchBased::SketchBased()
|
|||
ADD_PROPERTY_TYPE(Sketch,(0),"SketchBased", App::Prop_None, "Reference to sketch");
|
||||
ADD_PROPERTY_TYPE(Midplane,(0),"SketchBased", App::Prop_None, "Extrude symmetric to sketch face");
|
||||
ADD_PROPERTY_TYPE(Reversed, (0),"SketchBased", App::Prop_None, "Reverse extrusion direction");
|
||||
ADD_PROPERTY_TYPE(UpToFace,(0),"SketchBased",(App::PropertyType)(App::Prop_None),"Face where feature will end");
|
||||
}
|
||||
|
||||
short SketchBased::mustExecute() const
|
||||
{
|
||||
if (Sketch.isTouched() ||
|
||||
Midplane.isTouched() ||
|
||||
Reversed.isTouched())
|
||||
Reversed.isTouched() ||
|
||||
UpToFace.isTouched())
|
||||
return 1;
|
||||
return PartDesign::Feature::mustExecute();
|
||||
}
|
||||
|
|
|
@ -50,7 +50,9 @@ public:
|
|||
/// Reverse extrusion direction
|
||||
App::PropertyBool Reversed;
|
||||
/// Make extrusion symmetric to sketch plane
|
||||
App::PropertyBool Midplane;
|
||||
App::PropertyBool Midplane;
|
||||
/// Face to extrude up to
|
||||
App::PropertyLinkSub UpToFace;
|
||||
|
||||
short mustExecute() const;
|
||||
|
||||
|
|
|
@ -29,6 +29,7 @@ set(PartDesignGui_LIBS
|
|||
|
||||
set(PartDesignGui_MOC_HDRS
|
||||
FeaturePickDialog.h
|
||||
TaskSketchBasedParameters.h
|
||||
TaskPadParameters.h
|
||||
TaskPocketParameters.h
|
||||
TaskChamferParameters.h
|
||||
|
@ -121,6 +122,8 @@ SET(PartDesignGuiTaskDlgs_SRCS
|
|||
FeaturePickDialog.h
|
||||
ReferenceSelection.cpp
|
||||
ReferenceSelection.h
|
||||
TaskSketchBasedParameters.cpp
|
||||
TaskSketchBasedParameters.h
|
||||
TaskPadParameters.ui
|
||||
TaskPadParameters.cpp
|
||||
TaskPadParameters.h
|
||||
|
|
|
@ -50,7 +50,7 @@ using namespace Gui;
|
|||
/* TRANSLATOR PartDesignGui::TaskGrooveParameters */
|
||||
|
||||
TaskGrooveParameters::TaskGrooveParameters(ViewProviderGroove *GrooveView,QWidget *parent)
|
||||
: TaskBox(Gui::BitmapFactory().pixmap("PartDesign_Groove"),tr("Groove parameters"),true, parent),GrooveView(GrooveView)
|
||||
: TaskSketchBasedParameters(GrooveView, parent, "PartDesign_Groove",tr("Groove parameters"))
|
||||
{
|
||||
// we need a separate container widget to add all controls to
|
||||
proxy = new QWidget(this);
|
||||
|
@ -77,7 +77,7 @@ TaskGrooveParameters::TaskGrooveParameters(ViewProviderGroove *GrooveView,QWidge
|
|||
ui->checkBoxMidplane->blockSignals(true);
|
||||
ui->checkBoxReversed->blockSignals(true);
|
||||
|
||||
PartDesign::Groove* pcGroove = static_cast<PartDesign::Groove*>(GrooveView->getObject());
|
||||
PartDesign::Groove* pcGroove = static_cast<PartDesign::Groove*>(vp->getObject());
|
||||
double l = pcGroove->Angle.getValue();
|
||||
bool mirrored = pcGroove->Midplane.getValue();
|
||||
bool reversed = pcGroove->Reversed.getValue();
|
||||
|
@ -126,7 +126,7 @@ TaskGrooveParameters::TaskGrooveParameters(ViewProviderGroove *GrooveView,QWidge
|
|||
|
||||
void TaskGrooveParameters::onAngleChanged(double len)
|
||||
{
|
||||
PartDesign::Groove* pcGroove = static_cast<PartDesign::Groove*>(GrooveView->getObject());
|
||||
PartDesign::Groove* pcGroove = static_cast<PartDesign::Groove*>(vp->getObject());
|
||||
pcGroove->Angle.setValue(len);
|
||||
if (updateView())
|
||||
pcGroove->getDocument()->recomputeFeature(pcGroove);
|
||||
|
@ -134,7 +134,7 @@ void TaskGrooveParameters::onAngleChanged(double len)
|
|||
|
||||
void TaskGrooveParameters::onAxisChanged(int num)
|
||||
{
|
||||
PartDesign::Groove* pcGroove = static_cast<PartDesign::Groove*>(GrooveView->getObject());
|
||||
PartDesign::Groove* pcGroove = static_cast<PartDesign::Groove*>(vp->getObject());
|
||||
Sketcher::SketchObject *pcSketch = static_cast<Sketcher::SketchObject*>(pcGroove->Sketch.getValue());
|
||||
if (pcSketch) {
|
||||
App::DocumentObject *oldRefAxis = pcGroove->ReferenceAxis.getValue();
|
||||
|
@ -172,7 +172,7 @@ void TaskGrooveParameters::onAxisChanged(int num)
|
|||
|
||||
void TaskGrooveParameters::onMidplane(bool on)
|
||||
{
|
||||
PartDesign::Groove* pcGroove = static_cast<PartDesign::Groove*>(GrooveView->getObject());
|
||||
PartDesign::Groove* pcGroove = static_cast<PartDesign::Groove*>(vp->getObject());
|
||||
pcGroove->Midplane.setValue(on);
|
||||
if (updateView())
|
||||
pcGroove->getDocument()->recomputeFeature(pcGroove);
|
||||
|
@ -180,20 +180,12 @@ void TaskGrooveParameters::onMidplane(bool on)
|
|||
|
||||
void TaskGrooveParameters::onReversed(bool on)
|
||||
{
|
||||
PartDesign::Groove* pcGroove = static_cast<PartDesign::Groove*>(GrooveView->getObject());
|
||||
PartDesign::Groove* pcGroove = static_cast<PartDesign::Groove*>(vp->getObject());
|
||||
pcGroove->Reversed.setValue(on);
|
||||
if (updateView())
|
||||
pcGroove->getDocument()->recomputeFeature(pcGroove);
|
||||
}
|
||||
|
||||
void TaskGrooveParameters::onUpdateView(bool on)
|
||||
{
|
||||
if (on) {
|
||||
PartDesign::Groove* pcGroove = static_cast<PartDesign::Groove*>(GrooveView->getObject());
|
||||
pcGroove->getDocument()->recomputeFeature(pcGroove);
|
||||
}
|
||||
}
|
||||
|
||||
double TaskGrooveParameters::getAngle(void) const
|
||||
{
|
||||
return ui->grooveAngle->value().getValue();
|
||||
|
@ -202,7 +194,7 @@ double TaskGrooveParameters::getAngle(void) const
|
|||
QString TaskGrooveParameters::getReferenceAxis(void) const
|
||||
{
|
||||
// get the support and Sketch
|
||||
PartDesign::Groove* pcGroove = static_cast<PartDesign::Groove*>(GrooveView->getObject());
|
||||
PartDesign::Groove* pcGroove = static_cast<PartDesign::Groove*>(vp->getObject());
|
||||
Sketcher::SketchObject *pcSketch = static_cast<Sketcher::SketchObject*>(pcGroove->Sketch.getValue());
|
||||
|
||||
QString buf;
|
||||
|
@ -254,7 +246,7 @@ void TaskGrooveParameters::changeEvent(QEvent *e)
|
|||
|
||||
void TaskGrooveParameters::apply()
|
||||
{
|
||||
App::DocumentObject* groove = GrooveView->getObject();
|
||||
App::DocumentObject* groove = vp->getObject();
|
||||
std::string name = groove->getNameInDocument();
|
||||
|
||||
// retrieve sketch and its support object
|
||||
|
@ -290,10 +282,10 @@ void TaskGrooveParameters::apply()
|
|||
//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
|
||||
|
||||
TaskDlgGrooveParameters::TaskDlgGrooveParameters(ViewProviderGroove *GrooveView)
|
||||
: TaskDialog(),GrooveView(GrooveView)
|
||||
: TaskDlgSketchBasedParameters(GrooveView)
|
||||
{
|
||||
assert(GrooveView);
|
||||
parameter = new TaskGrooveParameters(GrooveView);
|
||||
assert(vp);
|
||||
parameter = new TaskGrooveParameters(static_cast<ViewProviderGroove*>(vp));
|
||||
|
||||
Content.push_back(parameter);
|
||||
}
|
||||
|
@ -329,7 +321,7 @@ bool TaskDlgGrooveParameters::accept()
|
|||
bool TaskDlgGrooveParameters::reject()
|
||||
{
|
||||
// get the support and Sketch
|
||||
PartDesign::Groove* pcGroove = static_cast<PartDesign::Groove*>(GrooveView->getObject());
|
||||
PartDesign::Groove* pcGroove = static_cast<PartDesign::Groove*>(vp->getObject());
|
||||
Sketcher::SketchObject *pcSketch = 0;
|
||||
if (pcGroove->Sketch.getValue()) {
|
||||
pcSketch = static_cast<Sketcher::SketchObject*>(pcGroove->Sketch.getValue());
|
||||
|
|
|
@ -29,6 +29,7 @@
|
|||
#include <Gui/TaskView/TaskDialog.h>
|
||||
|
||||
#include "ViewProviderGroove.h"
|
||||
#include "TaskSketchBasedParameters.h"
|
||||
|
||||
class Ui_TaskGrooveParameters;
|
||||
|
||||
|
@ -44,7 +45,7 @@ namespace PartDesignGui {
|
|||
|
||||
|
||||
|
||||
class TaskGrooveParameters : public Gui::TaskView::TaskBox
|
||||
class TaskGrooveParameters : public TaskSketchBasedParameters
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
|
@ -59,9 +60,9 @@ private Q_SLOTS:
|
|||
void onAxisChanged(int);
|
||||
void onMidplane(bool);
|
||||
void onReversed(bool);
|
||||
void onUpdateView(bool);
|
||||
|
||||
protected:
|
||||
void onSelectionChanged(const Gui::SelectionChanges& msg) {}
|
||||
void changeEvent(QEvent *e);
|
||||
QString getReferenceAxis(void) const;
|
||||
double getAngle(void) const;
|
||||
|
@ -74,11 +75,10 @@ private:
|
|||
private:
|
||||
QWidget* proxy;
|
||||
Ui_TaskGrooveParameters* ui;
|
||||
ViewProviderGroove *GrooveView;
|
||||
};
|
||||
|
||||
/// simulation dialog for the TaskView
|
||||
class TaskDlgGrooveParameters : public Gui::TaskView::TaskDialog
|
||||
class TaskDlgGrooveParameters : public TaskDlgSketchBasedParameters
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
|
@ -87,28 +87,19 @@ public:
|
|||
~TaskDlgGrooveParameters();
|
||||
|
||||
ViewProviderGroove* getGrooveView() const
|
||||
{ return GrooveView; }
|
||||
|
||||
{ return static_cast<ViewProviderGroove*>(vp); }
|
||||
|
||||
public:
|
||||
/// is called the TaskView when the dialog is opened
|
||||
virtual void open();
|
||||
/// is called by the framework if an button is clicked which has no accept or reject role
|
||||
/// is called by the framework if an button is clicked which has no accept or reject role^M
|
||||
virtual void clicked(int);
|
||||
/// is called by the framework if the dialog is accepted (Ok)
|
||||
virtual bool accept();
|
||||
/// is called by the framework if the dialog is rejected (Cancel)
|
||||
virtual bool reject();
|
||||
virtual bool isAllowedAlterDocument(void) const
|
||||
{ return false; }
|
||||
|
||||
/// returns for Close and Help button
|
||||
virtual QDialogButtonBox::StandardButtons getStandardButtons(void) const
|
||||
{ return QDialogButtonBox::Ok|QDialogButtonBox::Cancel; }
|
||||
|
||||
protected:
|
||||
ViewProviderGroove *GrooveView;
|
||||
|
||||
TaskGrooveParameters *parameter;
|
||||
};
|
||||
|
||||
|
|
117
src/Mod/PartDesign/Gui/TaskGrooveParameters.h.orig
Normal file
117
src/Mod/PartDesign/Gui/TaskGrooveParameters.h.orig
Normal file
|
@ -0,0 +1,117 @@
|
|||
/******************************************************************************
|
||||
* Copyright (c)2012 Jan Rheinlaender <jrheinlaender@users.sourceforge.net> *
|
||||
* *
|
||||
* This file is part of the FreeCAD CAx development system. *
|
||||
* *
|
||||
* This library is free software; you can redistribute it and/or *
|
||||
* modify it under the terms of the GNU Library General Public *
|
||||
* License as published by the Free Software Foundation; either *
|
||||
* version 2 of the License, or (at your option) any later version. *
|
||||
* *
|
||||
* This library is distributed in the hope that it will be useful, *
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
||||
* GNU Library General Public License for more details. *
|
||||
* *
|
||||
* You should have received a copy of the GNU Library General Public *
|
||||
* License along with this library; see the file COPYING.LIB. If not, *
|
||||
* write to the Free Software Foundation, Inc., 59 Temple Place, *
|
||||
* Suite 330, Boston, MA 02111-1307, USA *
|
||||
* *
|
||||
******************************************************************************/
|
||||
|
||||
|
||||
#ifndef GUI_TASKVIEW_TaskGrooveParameters_H
|
||||
#define GUI_TASKVIEW_TaskGrooveParameters_H
|
||||
|
||||
#include <Gui/TaskView/TaskView.h>
|
||||
#include <Gui/Selection.h>
|
||||
#include <Gui/TaskView/TaskDialog.h>
|
||||
|
||||
#include "ViewProviderGroove.h"
|
||||
#include "TaskSketchBasedParameters.h"
|
||||
|
||||
class Ui_TaskGrooveParameters;
|
||||
|
||||
namespace App {
|
||||
class Property;
|
||||
}
|
||||
|
||||
namespace Gui {
|
||||
class ViewProvider;
|
||||
}
|
||||
|
||||
namespace PartDesignGui {
|
||||
|
||||
|
||||
|
||||
class TaskGrooveParameters : public TaskSketchBasedParameters
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
TaskGrooveParameters(ViewProviderGroove *GrooveView,QWidget *parent = 0);
|
||||
~TaskGrooveParameters();
|
||||
|
||||
void apply();
|
||||
|
||||
private Q_SLOTS:
|
||||
void onAngleChanged(double);
|
||||
void onAxisChanged(int);
|
||||
void onMidplane(bool);
|
||||
void onReversed(bool);
|
||||
|
||||
protected:
|
||||
void onSelectionChanged(const Gui::SelectionChanges& msg) {}
|
||||
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:
|
||||
|
||||
private:
|
||||
QWidget* proxy;
|
||||
Ui_TaskGrooveParameters* ui;
|
||||
};
|
||||
|
||||
/// simulation dialog for the TaskView
|
||||
class TaskDlgGrooveParameters : public TaskDlgSketchBasedParameters
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
TaskDlgGrooveParameters(ViewProviderGroove *GrooveView);
|
||||
~TaskDlgGrooveParameters();
|
||||
|
||||
ViewProviderGroove* getGrooveView() const
|
||||
{ return static_cast<ViewProviderGroove*>(vp); }
|
||||
|
||||
public:
|
||||
/// is called the TaskView when the dialog is opened
|
||||
virtual void open();
|
||||
/// is called by the framework if an button is clicked which has no accept or reject role^M
|
||||
virtual void clicked(int);
|
||||
/// is called by the framework if the dialog is accepted (Ok)
|
||||
virtual bool accept();
|
||||
/// is called by the framework if the dialog is rejected (Cancel)
|
||||
virtual bool reject();
|
||||
<<<<<<< 0973b40e8e489ddbf6455e9a2e80b0520f143b58
|
||||
virtual bool isAllowedAlterDocument(void) const
|
||||
{ return false; }
|
||||
|
||||
/// returns for Close and Help button
|
||||
virtual QDialogButtonBox::StandardButtons getStandardButtons(void) const
|
||||
{ return QDialogButtonBox::Ok|QDialogButtonBox::Cancel; }
|
||||
=======
|
||||
>>>>>>> Refactored code of SketchBased features to have common code in an abstract superclass
|
||||
|
||||
protected:
|
||||
TaskGrooveParameters *parameter;
|
||||
};
|
||||
|
||||
} //namespace PartDesignGui
|
||||
|
||||
#endif // GUI_TASKVIEW_TASKAPPERANCE_H
|
|
@ -46,6 +46,7 @@
|
|||
#include <Mod/PartDesign/App/FeaturePad.h>
|
||||
#include <Mod/Sketcher/App/SketchObject.h>
|
||||
#include <Mod/PartDesign/App/Body.h>
|
||||
#include "TaskSketchBasedParameters.h"
|
||||
#include "ReferenceSelection.h"
|
||||
#include "Workbench.h"
|
||||
|
||||
|
@ -55,7 +56,7 @@ using namespace Gui;
|
|||
/* TRANSLATOR PartDesignGui::TaskPadParameters */
|
||||
|
||||
TaskPadParameters::TaskPadParameters(ViewProviderPad *PadView,bool newObj, QWidget *parent)
|
||||
: TaskBox(Gui::BitmapFactory().pixmap("PartDesign_Pad"),tr("Pad parameters"),true, parent),PadView(PadView)
|
||||
: TaskSketchBasedParameters(PadView, parent, "PartDesign_Pad",tr("Pad parameters"))
|
||||
{
|
||||
// we need a separate container widget to add all controls to
|
||||
proxy = new QWidget(this);
|
||||
|
@ -96,7 +97,7 @@ TaskPadParameters::TaskPadParameters(ViewProviderPad *PadView,bool newObj, QWidg
|
|||
ui->lengthEdit2->setParamGrpPath(QByteArray("User parameter:BaseApp/History/PadLength2"));
|
||||
|
||||
// Get the feature data
|
||||
PartDesign::Pad* pcPad = static_cast<PartDesign::Pad*>(PadView->getObject());
|
||||
PartDesign::Pad* pcPad = static_cast<PartDesign::Pad*>(vp->getObject());
|
||||
Base::Quantity l = pcPad->Length.getQuantityValue();
|
||||
bool midplane = pcPad->Midplane.getValue();
|
||||
bool reversed = pcPad->Reversed.getValue();
|
||||
|
@ -212,40 +213,22 @@ void TaskPadParameters::updateUI(int index)
|
|||
void TaskPadParameters::onSelectionChanged(const Gui::SelectionChanges& msg)
|
||||
{
|
||||
if (msg.Type == Gui::SelectionChanges::AddSelection) {
|
||||
// Don't allow selection in other document
|
||||
if (strcmp(msg.pDocName, PadView->getObject()->getDocument()->getName()) != 0)
|
||||
return;
|
||||
|
||||
if (!msg.pSubName || msg.pSubName[0] == '\0')
|
||||
return;
|
||||
std::string subName(msg.pSubName);
|
||||
if (subName.substr(0,4) != "Face")
|
||||
return;
|
||||
int faceId = std::atoi(&subName[4]);
|
||||
|
||||
// Don't allow selection outside support
|
||||
PartDesign::Pad* pcPad = static_cast<PartDesign::Pad*>(PadView->getObject());
|
||||
Part::Feature* support = pcPad->getSupport();
|
||||
if (support == NULL) {
|
||||
// There is no support, so we can't select from it...
|
||||
QString refText = onAddSelection(msg);
|
||||
if (refText.length() != 0) {
|
||||
ui->lineFaceName->blockSignals(true);
|
||||
ui->lineFaceName->setText(refText);
|
||||
ui->lineFaceName->setProperty("FaceName", QByteArray(msg.pSubName));
|
||||
ui->lineFaceName->blockSignals(false);
|
||||
// Turn off reference selection mode
|
||||
onButtonFace(false);
|
||||
return;
|
||||
} else {
|
||||
ui->lineFaceName->blockSignals(true);
|
||||
ui->lineFaceName->setText(tr("No face selected"));
|
||||
ui->lineFaceName->setProperty("FaceName", QByteArray());
|
||||
ui->lineFaceName->blockSignals(false);
|
||||
}
|
||||
if (strcmp(msg.pObjectName, support->getNameInDocument()) != 0)
|
||||
return;
|
||||
|
||||
std::vector<std::string> upToFaces(1,subName);
|
||||
pcPad->UpToFace.setValue(support, upToFaces);
|
||||
if (updateView())
|
||||
pcPad->getDocument()->recomputeFeature(pcPad);
|
||||
ui->lineFaceName->blockSignals(true);
|
||||
ui->lineFaceName->setText(tr("Face") + QString::number(faceId));
|
||||
ui->lineFaceName->setProperty("FaceName", QByteArray(subName.c_str()));
|
||||
ui->lineFaceName->blockSignals(false);
|
||||
// Turn off reference selection mode
|
||||
onButtonFace(false);
|
||||
}
|
||||
|
||||
else if (msg.Type == Gui::SelectionChanges::ClrSelection) {
|
||||
ui->lineFaceName->blockSignals(true);
|
||||
ui->lineFaceName->setText(tr(""));
|
||||
|
@ -256,7 +239,7 @@ void TaskPadParameters::onSelectionChanged(const Gui::SelectionChanges& msg)
|
|||
|
||||
void TaskPadParameters::onLengthChanged(double len)
|
||||
{
|
||||
PartDesign::Pad* pcPad = static_cast<PartDesign::Pad*>(PadView->getObject());
|
||||
PartDesign::Pad* pcPad = static_cast<PartDesign::Pad*>(vp->getObject());
|
||||
pcPad->Length.setValue(len);
|
||||
if (updateView())
|
||||
pcPad->getDocument()->recomputeFeature(pcPad);
|
||||
|
@ -264,7 +247,7 @@ void TaskPadParameters::onLengthChanged(double len)
|
|||
|
||||
void TaskPadParameters::onMidplane(bool on)
|
||||
{
|
||||
PartDesign::Pad* pcPad = static_cast<PartDesign::Pad*>(PadView->getObject());
|
||||
PartDesign::Pad* pcPad = static_cast<PartDesign::Pad*>(vp->getObject());
|
||||
pcPad->Midplane.setValue(on);
|
||||
ui->checkBoxReversed->setEnabled(!on);
|
||||
if (updateView())
|
||||
|
@ -273,7 +256,7 @@ void TaskPadParameters::onMidplane(bool on)
|
|||
|
||||
void TaskPadParameters::onReversed(bool on)
|
||||
{
|
||||
PartDesign::Pad* pcPad = static_cast<PartDesign::Pad*>(PadView->getObject());
|
||||
PartDesign::Pad* pcPad = static_cast<PartDesign::Pad*>(vp->getObject());
|
||||
pcPad->Reversed.setValue(on);
|
||||
if (updateView())
|
||||
pcPad->getDocument()->recomputeFeature(pcPad);
|
||||
|
@ -281,7 +264,7 @@ void TaskPadParameters::onReversed(bool on)
|
|||
|
||||
void TaskPadParameters::onLength2Changed(double len)
|
||||
{
|
||||
PartDesign::Pad* pcPad = static_cast<PartDesign::Pad*>(PadView->getObject());
|
||||
PartDesign::Pad* pcPad = static_cast<PartDesign::Pad*>(vp->getObject());
|
||||
pcPad->Length2.setValue(len);
|
||||
if (updateView())
|
||||
pcPad->getDocument()->recomputeFeature(pcPad);
|
||||
|
@ -289,7 +272,7 @@ void TaskPadParameters::onLength2Changed(double len)
|
|||
|
||||
void TaskPadParameters::onModeChanged(int index)
|
||||
{
|
||||
PartDesign::Pad* pcPad = static_cast<PartDesign::Pad*>(PadView->getObject());
|
||||
PartDesign::Pad* pcPad = static_cast<PartDesign::Pad*>(vp->getObject());
|
||||
|
||||
switch (index) {
|
||||
case 0:
|
||||
|
@ -312,30 +295,6 @@ void TaskPadParameters::onModeChanged(int index)
|
|||
|
||||
void TaskPadParameters::onButtonFace(const bool pressed)
|
||||
{
|
||||
PartDesign::Pad* pcPad = static_cast<PartDesign::Pad*>(PadView->getObject());
|
||||
Part::Feature* support = pcPad->getSupport();
|
||||
if (support == NULL) {
|
||||
// There is no support, so we can't select from it...
|
||||
return;
|
||||
}
|
||||
|
||||
if (pressed) {
|
||||
Gui::Document* doc = Gui::Application::Instance->activeDocument();
|
||||
if (doc) {
|
||||
doc->setHide(PadView->getObject()->getNameInDocument());
|
||||
doc->setShow(support->getNameInDocument());
|
||||
}
|
||||
Gui::Selection().clearSelection();
|
||||
Gui::Selection().addSelectionGate
|
||||
(new ReferenceSelection(support, false, true, false));
|
||||
} else {
|
||||
Gui::Selection().rmvSelectionGate();
|
||||
Gui::Document* doc = Gui::Application::Instance->activeDocument();
|
||||
if (doc) {
|
||||
doc->setShow(PadView->getObject()->getNameInDocument());
|
||||
doc->setHide(support->getNameInDocument());
|
||||
}
|
||||
}
|
||||
|
||||
// Update button if onButtonFace() is called explicitly
|
||||
ui->buttonFace->setChecked(pressed);
|
||||
|
@ -343,39 +302,7 @@ void TaskPadParameters::onButtonFace(const bool pressed)
|
|||
|
||||
void TaskPadParameters::onFaceName(const QString& text)
|
||||
{
|
||||
// We must expect that "text" is the translation of "Face" followed by an ID.
|
||||
QString name;
|
||||
QTextStream str(&name);
|
||||
str << "^" << tr("Face") << "(\\d+)$";
|
||||
QRegExp rx(name);
|
||||
if (text.indexOf(rx) < 0) {
|
||||
ui->lineFaceName->setProperty("FaceName", QByteArray());
|
||||
return;
|
||||
}
|
||||
|
||||
int faceId = rx.cap(1).toInt();
|
||||
std::stringstream ss;
|
||||
ss << "Face" << faceId;
|
||||
ui->lineFaceName->setProperty("FaceName", QByteArray(ss.str().c_str()));
|
||||
|
||||
PartDesign::Pad* pcPad = static_cast<PartDesign::Pad*>(PadView->getObject());
|
||||
Part::Feature* support = pcPad->getSupport();
|
||||
if (support == NULL) {
|
||||
// There is no support, so we can't select from it...
|
||||
return;
|
||||
}
|
||||
std::vector<std::string> upToFaces(1,ss.str());
|
||||
pcPad->UpToFace.setValue(support, upToFaces);
|
||||
if (updateView())
|
||||
pcPad->getDocument()->recomputeFeature(pcPad);
|
||||
}
|
||||
|
||||
void TaskPadParameters::onUpdateView(bool on)
|
||||
{
|
||||
if (on) {
|
||||
PartDesign::Pad* pcPad = static_cast<PartDesign::Pad*>(PadView->getObject());
|
||||
pcPad->getDocument()->recomputeFeature(pcPad);
|
||||
}
|
||||
ui->lineFaceName->setProperty("FaceName", TaskSketchBasedParameters::onFaceName(text));
|
||||
}
|
||||
|
||||
double TaskPadParameters::getLength(void) const
|
||||
|
@ -464,7 +391,7 @@ void TaskPadParameters::saveHistory(void)
|
|||
|
||||
void TaskPadParameters::apply()
|
||||
{
|
||||
std::string name = PadView->getObject()->getNameInDocument();
|
||||
std::string name = vp->getObject()->getNameInDocument();
|
||||
const char * cname = name.c_str();
|
||||
|
||||
ui->lengthEdit->apply();
|
||||
|
@ -476,7 +403,7 @@ void TaskPadParameters::apply()
|
|||
|
||||
Gui::Command::doCommand(Gui::Command::Doc,"App.ActiveDocument.%s.Type = %u",cname,getMode());
|
||||
std::string facename = getFaceName().data();
|
||||
PartDesign::Pad* pcPad = static_cast<PartDesign::Pad*>(PadView->getObject());
|
||||
PartDesign::Pad* pcPad = static_cast<PartDesign::Pad*>(vp->getObject());
|
||||
Part::Feature* support = pcPad->getSupport();
|
||||
|
||||
if (support != NULL && !facename.empty()) {
|
||||
|
@ -487,8 +414,8 @@ void TaskPadParameters::apply()
|
|||
} 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());
|
||||
if (!vp->getObject()->isValid())
|
||||
throw Base::Exception(vp->getObject()->getStatusString());
|
||||
Gui::Command::doCommand(Gui::Command::Gui,"Gui.activeDocument().resetEdit()");
|
||||
Gui::Command::commitCommand();
|
||||
}
|
||||
|
@ -499,10 +426,10 @@ void TaskPadParameters::apply()
|
|||
//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
|
||||
|
||||
TaskDlgPadParameters::TaskDlgPadParameters(ViewProviderPad *PadView,bool newObj)
|
||||
: TaskDialog(),PadView(PadView)
|
||||
: TaskDlgSketchBasedParameters(PadView)
|
||||
{
|
||||
assert(PadView);
|
||||
parameter = new TaskPadParameters(PadView,newObj);
|
||||
parameter = new TaskPadParameters(static_cast<ViewProviderPad*>(PadView));
|
||||
|
||||
Content.push_back(parameter);
|
||||
}
|
||||
|
@ -514,20 +441,6 @@ TaskDlgPadParameters::~TaskDlgPadParameters()
|
|||
|
||||
//==== calls from the TaskView ===============================================================
|
||||
|
||||
|
||||
void TaskDlgPadParameters::open()
|
||||
{
|
||||
// a transaction is already open at creation time of the pad
|
||||
if (!Gui::Command::hasPendingCommand()) {
|
||||
QString msg = QObject::tr("Edit pad");
|
||||
Gui::Command::openCommand((const char*)msg.toUtf8());
|
||||
}
|
||||
}
|
||||
|
||||
void TaskDlgPadParameters::clicked(int)
|
||||
{
|
||||
}
|
||||
|
||||
bool TaskDlgPadParameters::accept()
|
||||
{
|
||||
|
||||
|
@ -546,40 +459,5 @@ bool TaskDlgPadParameters::accept()
|
|||
return true;
|
||||
}
|
||||
|
||||
bool TaskDlgPadParameters::reject()
|
||||
{
|
||||
// get the support and Sketch
|
||||
PartDesign::Pad* pcPad = static_cast<PartDesign::Pad*>(PadView->getObject());
|
||||
Sketcher::SketchObject *pcSketch = 0;
|
||||
if (pcPad->Sketch.getValue()) {
|
||||
pcSketch = static_cast<Sketcher::SketchObject*>(pcPad->Sketch.getValue());
|
||||
}
|
||||
|
||||
// roll back the done things
|
||||
Gui::Command::abortCommand();
|
||||
Gui::Command::doCommand(Gui::Command::Gui,"Gui.activeDocument().resetEdit()");
|
||||
|
||||
// if abort command deleted the object the sketch is visible again
|
||||
if (!Gui::Application::Instance->getViewProvider(pcPad)) {
|
||||
if (pcSketch && Gui::Application::Instance->getViewProvider(pcSketch))
|
||||
Gui::Application::Instance->getViewProvider(pcSketch)->show();
|
||||
}
|
||||
|
||||
// Body housekeeping
|
||||
if (ActivePartObject != NULL) {
|
||||
// Make the new Tip and the previous solid feature visible again
|
||||
App::DocumentObject* tip = ActivePartObject->Tip.getValue();
|
||||
App::DocumentObject* prev = ActivePartObject->getPrevSolidFeature();
|
||||
if (tip != NULL) {
|
||||
Gui::Application::Instance->getViewProvider(tip)->show();
|
||||
if ((tip != prev) && (prev != NULL))
|
||||
Gui::Application::Instance->getViewProvider(prev)->show();
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
|
||||
#include "moc_TaskPadParameters.cpp"
|
||||
|
|
|
@ -28,6 +28,7 @@
|
|||
#include <Gui/Selection.h>
|
||||
#include <Gui/TaskView/TaskDialog.h>
|
||||
|
||||
#include "TaskSketchBasedParameters.h"
|
||||
#include "ViewProviderPad.h"
|
||||
|
||||
class Ui_TaskPadParameters;
|
||||
|
@ -44,7 +45,7 @@ namespace PartDesignGui {
|
|||
|
||||
|
||||
|
||||
class TaskPadParameters : public Gui::TaskView::TaskBox, public Gui::SelectionObserver
|
||||
class TaskPadParameters : public TaskSketchBasedParameters
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
|
@ -64,7 +65,6 @@ private Q_SLOTS:
|
|||
void onModeChanged(int);
|
||||
void onButtonFace(const bool pressed = true);
|
||||
void onFaceName(const QString& text);
|
||||
void onUpdateView(bool);
|
||||
|
||||
protected:
|
||||
void changeEvent(QEvent *e);
|
||||
|
@ -82,11 +82,10 @@ private:
|
|||
private:
|
||||
QWidget* proxy;
|
||||
Ui_TaskPadParameters* ui;
|
||||
ViewProviderPad *PadView;
|
||||
};
|
||||
|
||||
/// simulation dialog for the TaskView
|
||||
class TaskDlgPadParameters : public Gui::TaskView::TaskDialog
|
||||
class TaskDlgPadParameters : public TaskDlgSketchBasedParameters
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
|
@ -95,28 +94,15 @@ public:
|
|||
~TaskDlgPadParameters();
|
||||
|
||||
ViewProviderPad* getPadView() const
|
||||
{ return PadView; }
|
||||
{ return static_cast<ViewProviderPad*>(vp); }
|
||||
|
||||
|
||||
public:
|
||||
/// is called the TaskView when the dialog is opened
|
||||
virtual void open();
|
||||
/// is called by the framework if an button is clicked which has no accept or reject role
|
||||
virtual void clicked(int);
|
||||
/// is called by the framework if the dialog is accepted (Ok)
|
||||
virtual bool accept();
|
||||
/// is called by the framework if the dialog is rejected (Cancel)
|
||||
virtual bool reject();
|
||||
virtual bool isAllowedAlterDocument(void) const
|
||||
{ return false; }
|
||||
|
||||
/// returns for Close and Help button
|
||||
virtual QDialogButtonBox::StandardButtons getStandardButtons(void) const
|
||||
{ return QDialogButtonBox::Ok|QDialogButtonBox::Cancel; }
|
||||
|
||||
protected:
|
||||
ViewProviderPad *PadView;
|
||||
|
||||
TaskPadParameters *parameter;
|
||||
};
|
||||
|
||||
|
|
121
src/Mod/PartDesign/Gui/TaskPadParameters.h.orig
Normal file
121
src/Mod/PartDesign/Gui/TaskPadParameters.h.orig
Normal file
|
@ -0,0 +1,121 @@
|
|||
/***************************************************************************
|
||||
* Copyright (c) 2011 Juergen Riegel <FreeCAD@juergen-riegel.net> *
|
||||
* *
|
||||
* This file is part of the FreeCAD CAx development system. *
|
||||
* *
|
||||
* This library is free software; you can redistribute it and/or *
|
||||
* modify it under the terms of the GNU Library General Public *
|
||||
* License as published by the Free Software Foundation; either *
|
||||
* version 2 of the License, or (at your option) any later version. *
|
||||
* *
|
||||
* This library is distributed in the hope that it will be useful, *
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
||||
* GNU Library General Public License for more details. *
|
||||
* *
|
||||
* You should have received a copy of the GNU Library General Public *
|
||||
* License along with this library; see the file COPYING.LIB. If not, *
|
||||
* write to the Free Software Foundation, Inc., 59 Temple Place, *
|
||||
* Suite 330, Boston, MA 02111-1307, USA *
|
||||
* *
|
||||
***************************************************************************/
|
||||
|
||||
|
||||
#ifndef GUI_TASKVIEW_TaskPadParameters_H
|
||||
#define GUI_TASKVIEW_TaskPadParameters_H
|
||||
|
||||
#include <Gui/TaskView/TaskView.h>
|
||||
#include <Gui/Selection.h>
|
||||
#include <Gui/TaskView/TaskDialog.h>
|
||||
|
||||
#include "TaskSketchBasedParameters.h"
|
||||
#include "ViewProviderPad.h"
|
||||
|
||||
class Ui_TaskPadParameters;
|
||||
|
||||
namespace App {
|
||||
class Property;
|
||||
}
|
||||
|
||||
namespace Gui {
|
||||
class ViewProvider;
|
||||
}
|
||||
|
||||
namespace PartDesignGui {
|
||||
|
||||
|
||||
|
||||
class TaskPadParameters : public TaskSketchBasedParameters
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
TaskPadParameters(ViewProviderPad *PadView,bool newObj=false,QWidget *parent = 0);
|
||||
~TaskPadParameters();
|
||||
|
||||
const bool updateView() const;
|
||||
void saveHistory(void);
|
||||
void apply();
|
||||
|
||||
private Q_SLOTS:
|
||||
void onLengthChanged(double);
|
||||
void onMidplane(bool);
|
||||
void onReversed(bool);
|
||||
void onLength2Changed(double);
|
||||
void onModeChanged(int);
|
||||
void onButtonFace(const bool pressed = true);
|
||||
void onFaceName(const QString& text);
|
||||
|
||||
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);
|
||||
|
||||
private:
|
||||
QWidget* proxy;
|
||||
Ui_TaskPadParameters* ui;
|
||||
};
|
||||
|
||||
/// simulation dialog for the TaskView
|
||||
class TaskDlgPadParameters : public TaskDlgSketchBasedParameters
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
TaskDlgPadParameters(ViewProviderPad *PadView,bool newObj=false);
|
||||
~TaskDlgPadParameters();
|
||||
|
||||
ViewProviderPad* getPadView() const
|
||||
{ return static_cast<ViewProviderPad*>(vp); }
|
||||
|
||||
|
||||
public:
|
||||
/// is called by the framework if the dialog is accepted (Ok)
|
||||
virtual bool accept();
|
||||
/// is called by the framework if the dialog is rejected (Cancel)
|
||||
<<<<<<< 0973b40e8e489ddbf6455e9a2e80b0520f143b58
|
||||
virtual bool reject();
|
||||
virtual bool isAllowedAlterDocument(void) const
|
||||
{ return false; }
|
||||
|
||||
/// returns for Close and Help button
|
||||
virtual QDialogButtonBox::StandardButtons getStandardButtons(void) const
|
||||
{ return QDialogButtonBox::Ok|QDialogButtonBox::Cancel; }
|
||||
=======
|
||||
>>>>>>> Refactored code of SketchBased features to have common code in an abstract superclass
|
||||
|
||||
protected:
|
||||
TaskPadParameters *parameter;
|
||||
};
|
||||
|
||||
} //namespace PartDesignGui
|
||||
|
||||
#endif // GUI_TASKVIEW_TASKAPPERANCE_H
|
|
@ -47,6 +47,7 @@
|
|||
#include <Mod/PartDesign/App/FeaturePocket.h>
|
||||
#include <Mod/Sketcher/App/SketchObject.h>
|
||||
#include <Mod/PartDesign/App/Body.h>
|
||||
#include "TaskSketchBasedParameters.h"
|
||||
#include "ReferenceSelection.h"
|
||||
#include "Workbench.h"
|
||||
|
||||
|
@ -56,7 +57,7 @@ using namespace Gui;
|
|||
/* TRANSLATOR PartDesignGui::TaskPocketParameters */
|
||||
|
||||
TaskPocketParameters::TaskPocketParameters(ViewProviderPocket *PocketView,QWidget *parent)
|
||||
: TaskBox(Gui::BitmapFactory().pixmap("PartDesign_Pocket"),tr("Pocket parameters"),true, parent),PocketView(PocketView)
|
||||
: TaskSketchBasedParameters(PocketView, parent, "PartDesign_Pocket",tr("Pocket parameters"))
|
||||
{
|
||||
// we need a separate container widget to add all controls to
|
||||
proxy = new QWidget(this);
|
||||
|
@ -90,7 +91,7 @@ TaskPocketParameters::TaskPocketParameters(ViewProviderPocket *PocketView,QWidge
|
|||
ui->changeMode->blockSignals(true);
|
||||
|
||||
// Get the feature data
|
||||
PartDesign::Pocket* pcPocket = static_cast<PartDesign::Pocket*>(PocketView->getObject());
|
||||
PartDesign::Pocket* pcPocket = static_cast<PartDesign::Pocket*>(vp->getObject());
|
||||
double l = pcPocket->Length.getValue();
|
||||
bool midplane = pcPocket->Midplane.getValue();
|
||||
bool reversed = pcPocket->Reversed.getValue();
|
||||
|
@ -192,39 +193,20 @@ void TaskPocketParameters::updateUI(int index)
|
|||
void TaskPocketParameters::onSelectionChanged(const Gui::SelectionChanges& msg)
|
||||
{
|
||||
if (msg.Type == Gui::SelectionChanges::AddSelection) {
|
||||
// Don't allow selection in other document
|
||||
if (strcmp(msg.pDocName, PocketView->getObject()->getDocument()->getName()) != 0)
|
||||
return;
|
||||
|
||||
if (!msg.pSubName || msg.pSubName[0] == '\0')
|
||||
return;
|
||||
std::string subName(msg.pSubName);
|
||||
if (subName.substr(0,4) != "Face")
|
||||
return;
|
||||
int faceId = std::atoi(&subName[4]);
|
||||
|
||||
// Don't allow selection outside of support
|
||||
PartDesign::Pocket* pcPocket = static_cast<PartDesign::Pocket*>(PocketView->getObject());
|
||||
Part::Feature* support = pcPocket->getSupport();
|
||||
if (support == NULL) {
|
||||
// There is no support, so we can't select from it...
|
||||
QString refText = onAddSelection(msg);
|
||||
if (refText.length() > 0) {
|
||||
ui->lineFaceName->blockSignals(true);
|
||||
ui->lineFaceName->setText(refText);
|
||||
ui->lineFaceName->setProperty("FaceName", QByteArray(msg.pSubName));
|
||||
ui->lineFaceName->blockSignals(false);
|
||||
// Turn off reference selection mode
|
||||
onButtonFace(false);
|
||||
return;
|
||||
} else {
|
||||
ui->lineFaceName->blockSignals(true);
|
||||
ui->lineFaceName->setText(tr("No face selected"));
|
||||
ui->lineFaceName->setProperty("FaceName", QByteArray());
|
||||
ui->lineFaceName->blockSignals(false);
|
||||
}
|
||||
if (strcmp(msg.pObjectName, support->getNameInDocument()) != 0)
|
||||
return;
|
||||
|
||||
std::vector<std::string> upToFaces(1,subName);
|
||||
pcPocket->UpToFace.setValue(support, upToFaces);
|
||||
if (updateView())
|
||||
pcPocket->getDocument()->recomputeFeature(pcPocket);
|
||||
ui->lineFaceName->blockSignals(true);
|
||||
ui->lineFaceName->setText(tr("Face") + QString::number(faceId));
|
||||
ui->lineFaceName->setProperty("FaceName", QByteArray(subName.c_str()));
|
||||
ui->lineFaceName->blockSignals(false);
|
||||
// Turn off reference selection mode
|
||||
onButtonFace(false);
|
||||
}
|
||||
else if (msg.Type == Gui::SelectionChanges::ClrSelection) {
|
||||
ui->lineFaceName->blockSignals(true);
|
||||
|
@ -236,7 +218,7 @@ void TaskPocketParameters::onSelectionChanged(const Gui::SelectionChanges& msg)
|
|||
|
||||
void TaskPocketParameters::onLengthChanged(double len)
|
||||
{
|
||||
PartDesign::Pocket* pcPocket = static_cast<PartDesign::Pocket*>(PocketView->getObject());
|
||||
PartDesign::Pocket* pcPocket = static_cast<PartDesign::Pocket*>(vp->getObject());
|
||||
pcPocket->Length.setValue(len);
|
||||
if (updateView())
|
||||
pcPocket->getDocument()->recomputeFeature(pcPocket);
|
||||
|
@ -244,7 +226,7 @@ void TaskPocketParameters::onLengthChanged(double len)
|
|||
|
||||
void TaskPocketParameters::onMidplaneChanged(bool on)
|
||||
{
|
||||
PartDesign::Pocket* pcPocket = static_cast<PartDesign::Pocket*>(PocketView->getObject());
|
||||
PartDesign::Pocket* pcPocket = static_cast<PartDesign::Pocket*>(vp->getObject());
|
||||
pcPocket->Midplane.setValue(on);
|
||||
ui->checkBoxReversed->setEnabled(!on);
|
||||
if (updateView())
|
||||
|
@ -253,7 +235,7 @@ void TaskPocketParameters::onMidplaneChanged(bool on)
|
|||
|
||||
void TaskPocketParameters::onReversedChanged(bool on)
|
||||
{
|
||||
PartDesign::Pocket* pcPocket = static_cast<PartDesign::Pocket*>(PocketView->getObject());
|
||||
PartDesign::Pocket* pcPocket = static_cast<PartDesign::Pocket*>(vp->getObject());
|
||||
pcPocket->Reversed.setValue(on);
|
||||
if (updateView())
|
||||
pcPocket->getDocument()->recomputeFeature(pcPocket);
|
||||
|
@ -261,7 +243,7 @@ void TaskPocketParameters::onReversedChanged(bool on)
|
|||
|
||||
void TaskPocketParameters::onModeChanged(int index)
|
||||
{
|
||||
PartDesign::Pocket* pcPocket = static_cast<PartDesign::Pocket*>(PocketView->getObject());
|
||||
PartDesign::Pocket* pcPocket = static_cast<PartDesign::Pocket*>(vp->getObject());
|
||||
|
||||
switch (index) {
|
||||
case 0:
|
||||
|
@ -299,30 +281,7 @@ void TaskPocketParameters::onModeChanged(int index)
|
|||
}
|
||||
|
||||
void TaskPocketParameters::onButtonFace(const bool pressed) {
|
||||
PartDesign::Pocket* pcPocket = static_cast<PartDesign::Pocket*>(PocketView->getObject());
|
||||
Part::Feature* support = pcPocket->getSupport();
|
||||
if (support == NULL) {
|
||||
// There is no support, so we can't select from it...
|
||||
return;
|
||||
}
|
||||
|
||||
if (pressed) {
|
||||
Gui::Document* doc = Gui::Application::Instance->activeDocument();
|
||||
if (doc) {
|
||||
doc->setHide(PocketView->getObject()->getNameInDocument());
|
||||
doc->setShow(support->getNameInDocument());
|
||||
}
|
||||
Gui::Selection().clearSelection();
|
||||
Gui::Selection().addSelectionGate
|
||||
(new ReferenceSelection(support, false, true, false));
|
||||
} else {
|
||||
Gui::Selection().rmvSelectionGate();
|
||||
Gui::Document* doc = Gui::Application::Instance->activeDocument();
|
||||
if (doc) {
|
||||
doc->setShow(PocketView->getObject()->getNameInDocument());
|
||||
doc->setHide(support->getNameInDocument());
|
||||
}
|
||||
}
|
||||
TaskSketchBasedParameters::onButtonFace(pressed);
|
||||
|
||||
// Update button if onButtonFace() is called explicitly
|
||||
ui->buttonFace->setChecked(pressed);
|
||||
|
@ -330,39 +289,7 @@ void TaskPocketParameters::onButtonFace(const bool pressed) {
|
|||
|
||||
void TaskPocketParameters::onFaceName(const QString& text)
|
||||
{
|
||||
// We must expect that "text" is the translation of "Face" followed by an ID.
|
||||
QString name;
|
||||
QTextStream str(&name);
|
||||
str << "^" << tr("Face") << "(\\d+)$";
|
||||
QRegExp rx(name);
|
||||
if (text.indexOf(rx) < 0) {
|
||||
ui->lineFaceName->setProperty("FaceName", QByteArray());
|
||||
return;
|
||||
}
|
||||
|
||||
int faceId = rx.cap(1).toInt();
|
||||
std::stringstream ss;
|
||||
ss << "Face" << faceId;
|
||||
ui->lineFaceName->setProperty("FaceName", QByteArray(ss.str().c_str()));
|
||||
|
||||
PartDesign::Pocket* pcPocket = static_cast<PartDesign::Pocket*>(PocketView->getObject());
|
||||
Part::Feature* support = pcPocket->getSupport();
|
||||
if (support == NULL) {
|
||||
// There is no support, so we can't select from it...
|
||||
return;
|
||||
}
|
||||
std::vector<std::string> upToFaces(1,ss.str());
|
||||
pcPocket->UpToFace.setValue(support, upToFaces);
|
||||
if (updateView())
|
||||
pcPocket->getDocument()->recomputeFeature(pcPocket);
|
||||
}
|
||||
|
||||
void TaskPocketParameters::onUpdateView(bool on)
|
||||
{
|
||||
if (on) {
|
||||
PartDesign::Pocket* pcPocket = static_cast<PartDesign::Pocket*>(PocketView->getObject());
|
||||
pcPocket->getDocument()->recomputeFeature(pcPocket);
|
||||
}
|
||||
ui->lineFaceName->setProperty("FaceName", TaskSketchBasedParameters::onFaceName(text));
|
||||
}
|
||||
|
||||
double TaskPocketParameters::getLength(void) const
|
||||
|
@ -428,13 +355,13 @@ void TaskPocketParameters::changeEvent(QEvent *e)
|
|||
|
||||
void TaskPocketParameters::apply()
|
||||
{
|
||||
std::string name = PocketView->getObject()->getNameInDocument();
|
||||
std::string name = vp->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<PartDesign::Pocket*>(PocketView->getObject());
|
||||
PartDesign::Pocket* pcPocket = static_cast<PartDesign::Pocket*>(vp->getObject());
|
||||
Part::Feature* support = pcPocket->getSupport();
|
||||
if (support != NULL && !facename.empty()) {
|
||||
QString buf = QString::fromUtf8("(App.ActiveDocument.%1,[\"%2\"])");
|
||||
|
@ -443,10 +370,10 @@ void TaskPocketParameters::apply()
|
|||
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.%s.Reversed = %i",name.c_str(),getReversed()?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 (!PocketView->getObject()->isValid())
|
||||
throw Base::Exception(PocketView->getObject()->getStatusString());
|
||||
if (!vp->getObject()->isValid())
|
||||
throw Base::Exception(vp->getObject()->getStatusString());
|
||||
Gui::Command::doCommand(Gui::Command::Gui,"Gui.activeDocument().resetEdit()");
|
||||
Gui::Command::commitCommand();
|
||||
}
|
||||
|
@ -457,10 +384,10 @@ void TaskPocketParameters::apply()
|
|||
//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
|
||||
|
||||
TaskDlgPocketParameters::TaskDlgPocketParameters(ViewProviderPocket *PocketView)
|
||||
: TaskDialog(),PocketView(PocketView)
|
||||
: TaskDlgSketchBasedParameters(PocketView)
|
||||
{
|
||||
assert(PocketView);
|
||||
parameter = new TaskPocketParameters(PocketView);
|
||||
assert(vp);
|
||||
parameter = new TaskPocketParameters(static_cast<ViewProviderPocket*>(vp));
|
||||
|
||||
Content.push_back(parameter);
|
||||
}
|
||||
|
@ -472,21 +399,6 @@ TaskDlgPocketParameters::~TaskDlgPocketParameters()
|
|||
|
||||
//==== calls from the TaskView ===============================================================
|
||||
|
||||
|
||||
void TaskDlgPocketParameters::open()
|
||||
{
|
||||
// a transaction is already open at creation time of the pocket
|
||||
if (!Gui::Command::hasPendingCommand()) {
|
||||
QString msg = tr("Edit pocket");
|
||||
Gui::Command::openCommand((const char*)msg.toUtf8());
|
||||
}
|
||||
}
|
||||
|
||||
void TaskDlgPocketParameters::clicked(int)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
bool TaskDlgPocketParameters::accept()
|
||||
{
|
||||
try {
|
||||
|
@ -500,40 +412,5 @@ bool TaskDlgPocketParameters::accept()
|
|||
return true;
|
||||
}
|
||||
|
||||
bool TaskDlgPocketParameters::reject()
|
||||
{
|
||||
// get the support and Sketch
|
||||
PartDesign::Pocket* pcPocket = static_cast<PartDesign::Pocket*>(PocketView->getObject());
|
||||
Sketcher::SketchObject *pcSketch = 0;
|
||||
if (pcPocket->Sketch.getValue()) {
|
||||
pcSketch = static_cast<Sketcher::SketchObject*>(pcPocket->Sketch.getValue());
|
||||
}
|
||||
|
||||
// roll back the done things
|
||||
Gui::Command::abortCommand();
|
||||
Gui::Command::doCommand(Gui::Command::Gui,"Gui.activeDocument().resetEdit()");
|
||||
|
||||
// if abort command deleted the object the sketch is visible again
|
||||
if (!Gui::Application::Instance->getViewProvider(pcPocket)) {
|
||||
if (pcSketch && Gui::Application::Instance->getViewProvider(pcSketch))
|
||||
Gui::Application::Instance->getViewProvider(pcSketch)->show();
|
||||
}
|
||||
|
||||
// Body housekeeping
|
||||
if (ActivePartObject != NULL) {
|
||||
// Make the new Tip and the previous solid feature visible again
|
||||
App::DocumentObject* tip = ActivePartObject->Tip.getValue();
|
||||
App::DocumentObject* prev = ActivePartObject->getPrevSolidFeature();
|
||||
if (tip != NULL) {
|
||||
Gui::Application::Instance->getViewProvider(tip)->show();
|
||||
if ((tip != prev) && (prev != NULL))
|
||||
Gui::Application::Instance->getViewProvider(prev)->show();
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
|
||||
#include "moc_TaskPocketParameters.cpp"
|
||||
|
|
|
@ -28,6 +28,7 @@
|
|||
#include <Gui/Selection.h>
|
||||
#include <Gui/TaskView/TaskDialog.h>
|
||||
|
||||
#include "TaskSketchBasedParameters.h"
|
||||
#include "ViewProviderPocket.h"
|
||||
|
||||
class Ui_TaskPocketParameters;
|
||||
|
@ -44,7 +45,7 @@ namespace PartDesignGui {
|
|||
|
||||
|
||||
|
||||
class TaskPocketParameters : public Gui::TaskView::TaskBox, public Gui::SelectionObserver
|
||||
class TaskPocketParameters : public TaskSketchBasedParameters
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
|
@ -64,7 +65,6 @@ private Q_SLOTS:
|
|||
void onModeChanged(int);
|
||||
void onButtonFace(const bool pressed = true);
|
||||
void onFaceName(const QString& text);
|
||||
void onUpdateView(bool);
|
||||
|
||||
protected:
|
||||
void changeEvent(QEvent *e);
|
||||
|
@ -79,12 +79,11 @@ private:
|
|||
private:
|
||||
QWidget* proxy;
|
||||
Ui_TaskPocketParameters* ui;
|
||||
ViewProviderPocket *PocketView;
|
||||
double oldLength;
|
||||
};
|
||||
|
||||
/// simulation dialog for the TaskView
|
||||
class TaskDlgPocketParameters : public Gui::TaskView::TaskDialog
|
||||
class TaskDlgPocketParameters : public TaskDlgSketchBasedParameters
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
|
@ -93,28 +92,14 @@ public:
|
|||
~TaskDlgPocketParameters();
|
||||
|
||||
ViewProviderPocket* getPocketView() const
|
||||
{ return PocketView; }
|
||||
{ return static_cast<ViewProviderPocket*>(vp); }
|
||||
|
||||
|
||||
public:
|
||||
/// is called the TaskView when the dialog is opened
|
||||
virtual void open();
|
||||
/// is called by the framework if an button is clicked which has no accept or reject role
|
||||
virtual void clicked(int);
|
||||
/// is called by the framework if the dialog is accepted (Ok)
|
||||
virtual bool accept();
|
||||
/// is called by the framework if the dialog is rejected (Cancel)
|
||||
virtual bool reject();
|
||||
virtual bool isAllowedAlterDocument(void) const
|
||||
{ return false; }
|
||||
|
||||
/// returns for Close and Help button
|
||||
virtual QDialogButtonBox::StandardButtons getStandardButtons(void) const
|
||||
{ return QDialogButtonBox::Ok|QDialogButtonBox::Cancel; }
|
||||
|
||||
protected:
|
||||
ViewProviderPocket *PocketView;
|
||||
|
||||
TaskPocketParameters *parameter;
|
||||
};
|
||||
|
||||
|
|
119
src/Mod/PartDesign/Gui/TaskPocketParameters.h.orig
Normal file
119
src/Mod/PartDesign/Gui/TaskPocketParameters.h.orig
Normal file
|
@ -0,0 +1,119 @@
|
|||
/***************************************************************************
|
||||
* Copyright (c) 2011 Juergen Riegel <FreeCAD@juergen-riegel.net> *
|
||||
* *
|
||||
* This file is part of the FreeCAD CAx development system. *
|
||||
* *
|
||||
* This library is free software; you can redistribute it and/or *
|
||||
* modify it under the terms of the GNU Library General Public *
|
||||
* License as published by the Free Software Foundation; either *
|
||||
* version 2 of the License, or (at your option) any later version. *
|
||||
* *
|
||||
* This library is distributed in the hope that it will be useful, *
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
||||
* GNU Library General Public License for more details. *
|
||||
* *
|
||||
* You should have received a copy of the GNU Library General Public *
|
||||
* License along with this library; see the file COPYING.LIB. If not, *
|
||||
* write to the Free Software Foundation, Inc., 59 Temple Place, *
|
||||
* Suite 330, Boston, MA 02111-1307, USA *
|
||||
* *
|
||||
***************************************************************************/
|
||||
|
||||
|
||||
#ifndef GUI_TASKVIEW_TaskPocketParameters_H
|
||||
#define GUI_TASKVIEW_TaskPocketParameters_H
|
||||
|
||||
#include <Gui/TaskView/TaskView.h>
|
||||
#include <Gui/Selection.h>
|
||||
#include <Gui/TaskView/TaskDialog.h>
|
||||
|
||||
#include "TaskSketchBasedParameters.h"
|
||||
#include "ViewProviderPocket.h"
|
||||
|
||||
class Ui_TaskPocketParameters;
|
||||
|
||||
namespace App {
|
||||
class Property;
|
||||
}
|
||||
|
||||
namespace Gui {
|
||||
class ViewProvider;
|
||||
}
|
||||
|
||||
namespace PartDesignGui {
|
||||
|
||||
|
||||
|
||||
class TaskPocketParameters : public TaskSketchBasedParameters
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
TaskPocketParameters(ViewProviderPocket *PocketView,QWidget *parent = 0);
|
||||
~TaskPocketParameters();
|
||||
|
||||
bool getReversed(void) const;
|
||||
QByteArray getFaceName(void) const;
|
||||
const bool updateView() const;
|
||||
void apply();
|
||||
|
||||
private Q_SLOTS:
|
||||
void onLengthChanged(double);
|
||||
void onMidplaneChanged(bool);
|
||||
void onReversedChanged(bool);
|
||||
void onModeChanged(int);
|
||||
void onButtonFace(const bool pressed = true);
|
||||
void onFaceName(const QString& text);
|
||||
|
||||
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);
|
||||
|
||||
private:
|
||||
QWidget* proxy;
|
||||
Ui_TaskPocketParameters* ui;
|
||||
double oldLength;
|
||||
};
|
||||
|
||||
/// simulation dialog for the TaskView
|
||||
class TaskDlgPocketParameters : public TaskDlgSketchBasedParameters
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
TaskDlgPocketParameters(ViewProviderPocket *PocketView);
|
||||
~TaskDlgPocketParameters();
|
||||
|
||||
ViewProviderPocket* getPocketView() const
|
||||
{ return static_cast<ViewProviderPocket*>(vp); }
|
||||
|
||||
|
||||
public:
|
||||
/// is called by the framework if the dialog is accepted (Ok)
|
||||
virtual bool accept();
|
||||
<<<<<<< 0973b40e8e489ddbf6455e9a2e80b0520f143b58
|
||||
/// is called by the framework if the dialog is rejected (Cancel)
|
||||
virtual bool reject();
|
||||
virtual bool isAllowedAlterDocument(void) const
|
||||
{ return false; }
|
||||
|
||||
/// returns for Close and Help button
|
||||
virtual QDialogButtonBox::StandardButtons getStandardButtons(void) const
|
||||
{ return QDialogButtonBox::Ok|QDialogButtonBox::Cancel; }
|
||||
=======
|
||||
>>>>>>> Refactored code of SketchBased features to have common code in an abstract superclass
|
||||
|
||||
protected:
|
||||
TaskPocketParameters *parameter;
|
||||
};
|
||||
|
||||
} //namespace PartDesignGui
|
||||
|
||||
#endif // GUI_TASKVIEW_TASKAPPERANCE_H
|
|
@ -51,7 +51,7 @@ using namespace Gui;
|
|||
/* TRANSLATOR PartDesignGui::TaskRevolutionParameters */
|
||||
|
||||
TaskRevolutionParameters::TaskRevolutionParameters(ViewProviderRevolution *RevolutionView,QWidget *parent)
|
||||
: TaskBox(Gui::BitmapFactory().pixmap("PartDesign_Revolution"),tr("Revolution parameters"),true, parent),RevolutionView(RevolutionView)
|
||||
: TaskSketchBasedParameters(RevolutionView, parent, "PartDesign_Revolution",tr("Revolution parameters"))
|
||||
{
|
||||
// we need a separate container widget to add all controls to
|
||||
proxy = new QWidget(this);
|
||||
|
@ -78,7 +78,7 @@ TaskRevolutionParameters::TaskRevolutionParameters(ViewProviderRevolution *Revol
|
|||
ui->checkBoxMidplane->blockSignals(true);
|
||||
ui->checkBoxReversed->blockSignals(true);
|
||||
|
||||
PartDesign::Revolution* pcRevolution = static_cast<PartDesign::Revolution*>(RevolutionView->getObject());
|
||||
PartDesign::Revolution* pcRevolution = static_cast<PartDesign::Revolution*>(vp->getObject());
|
||||
double l = pcRevolution->Angle.getValue();
|
||||
bool mirrored = pcRevolution->Midplane.getValue();
|
||||
bool reversed = pcRevolution->Reversed.getValue();
|
||||
|
@ -127,7 +127,7 @@ TaskRevolutionParameters::TaskRevolutionParameters(ViewProviderRevolution *Revol
|
|||
|
||||
void TaskRevolutionParameters::onAngleChanged(double len)
|
||||
{
|
||||
PartDesign::Revolution* pcRevolution = static_cast<PartDesign::Revolution*>(RevolutionView->getObject());
|
||||
PartDesign::Revolution* pcRevolution = static_cast<PartDesign::Revolution*>(vp->getObject());
|
||||
pcRevolution->Angle.setValue(len);
|
||||
if (updateView())
|
||||
pcRevolution->getDocument()->recomputeFeature(pcRevolution);
|
||||
|
@ -135,7 +135,7 @@ void TaskRevolutionParameters::onAngleChanged(double len)
|
|||
|
||||
void TaskRevolutionParameters::onAxisChanged(int num)
|
||||
{
|
||||
PartDesign::Revolution* pcRevolution = static_cast<PartDesign::Revolution*>(RevolutionView->getObject());
|
||||
PartDesign::Revolution* pcRevolution = static_cast<PartDesign::Revolution*>(vp->getObject());
|
||||
Sketcher::SketchObject *pcSketch = static_cast<Sketcher::SketchObject*>(pcRevolution->Sketch.getValue());
|
||||
if (pcSketch) {
|
||||
App::DocumentObject *oldRefAxis = pcRevolution->ReferenceAxis.getValue();
|
||||
|
@ -173,7 +173,7 @@ void TaskRevolutionParameters::onAxisChanged(int num)
|
|||
|
||||
void TaskRevolutionParameters::onMidplane(bool on)
|
||||
{
|
||||
PartDesign::Revolution* pcRevolution = static_cast<PartDesign::Revolution*>(RevolutionView->getObject());
|
||||
PartDesign::Revolution* pcRevolution = static_cast<PartDesign::Revolution*>(vp->getObject());
|
||||
pcRevolution->Midplane.setValue(on);
|
||||
if (updateView())
|
||||
pcRevolution->getDocument()->recomputeFeature(pcRevolution);
|
||||
|
@ -181,20 +181,12 @@ void TaskRevolutionParameters::onMidplane(bool on)
|
|||
|
||||
void TaskRevolutionParameters::onReversed(bool on)
|
||||
{
|
||||
PartDesign::Revolution* pcRevolution = static_cast<PartDesign::Revolution*>(RevolutionView->getObject());
|
||||
PartDesign::Revolution* pcRevolution = static_cast<PartDesign::Revolution*>(vp->getObject());
|
||||
pcRevolution->Reversed.setValue(on);
|
||||
if (updateView())
|
||||
pcRevolution->getDocument()->recomputeFeature(pcRevolution);
|
||||
}
|
||||
|
||||
void TaskRevolutionParameters::onUpdateView(bool on)
|
||||
{
|
||||
if (on) {
|
||||
PartDesign::Revolution* pcRevolution = static_cast<PartDesign::Revolution*>(RevolutionView->getObject());
|
||||
pcRevolution->getDocument()->recomputeFeature(pcRevolution);
|
||||
}
|
||||
}
|
||||
|
||||
double TaskRevolutionParameters::getAngle(void) const
|
||||
{
|
||||
return ui->revolveAngle->value().getValue();
|
||||
|
@ -203,7 +195,7 @@ double TaskRevolutionParameters::getAngle(void) const
|
|||
QString TaskRevolutionParameters::getReferenceAxis(void) const
|
||||
{
|
||||
// get the support and Sketch
|
||||
PartDesign::Revolution* pcRevolution = static_cast<PartDesign::Revolution*>(RevolutionView->getObject());
|
||||
PartDesign::Revolution* pcRevolution = static_cast<PartDesign::Revolution*>(vp->getObject());
|
||||
Sketcher::SketchObject *pcSketch = static_cast<Sketcher::SketchObject*>(pcRevolution->Sketch.getValue());
|
||||
|
||||
QString buf;
|
||||
|
@ -255,7 +247,7 @@ void TaskRevolutionParameters::changeEvent(QEvent *e)
|
|||
|
||||
void TaskRevolutionParameters::apply()
|
||||
{
|
||||
App::DocumentObject* revolve = RevolutionView->getObject();
|
||||
App::DocumentObject* revolve = vp->getObject();
|
||||
std::string name = revolve->getNameInDocument();
|
||||
|
||||
// retrieve sketch and its support object
|
||||
|
@ -291,7 +283,7 @@ void TaskRevolutionParameters::apply()
|
|||
//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
|
||||
|
||||
TaskDlgRevolutionParameters::TaskDlgRevolutionParameters(ViewProviderRevolution *RevolutionView)
|
||||
: TaskDialog(),RevolutionView(RevolutionView)
|
||||
: TaskDlgSketchBasedParameters(RevolutionView)
|
||||
{
|
||||
assert(RevolutionView);
|
||||
parameter = new TaskRevolutionParameters(RevolutionView);
|
||||
|
@ -306,61 +298,11 @@ TaskDlgRevolutionParameters::~TaskDlgRevolutionParameters()
|
|||
|
||||
//==== calls from the TaskView ===============================================================
|
||||
|
||||
|
||||
void TaskDlgRevolutionParameters::open()
|
||||
{
|
||||
// a transaction is already open at creation time of the revolve
|
||||
if (!Gui::Command::hasPendingCommand()) {
|
||||
QString msg = QObject::tr("Edit revolve");
|
||||
Gui::Command::openCommand((const char*)msg.toUtf8());
|
||||
}
|
||||
}
|
||||
|
||||
void TaskDlgRevolutionParameters::clicked(int)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
bool TaskDlgRevolutionParameters::accept()
|
||||
{
|
||||
parameter->apply();
|
||||
return true;
|
||||
}
|
||||
|
||||
bool TaskDlgRevolutionParameters::reject()
|
||||
{
|
||||
// get the support and Sketch
|
||||
PartDesign::Revolution* pcRevolution = static_cast<PartDesign::Revolution*>(RevolutionView->getObject());
|
||||
Sketcher::SketchObject *pcSketch = 0;
|
||||
if (pcRevolution->Sketch.getValue()) {
|
||||
pcSketch = static_cast<Sketcher::SketchObject*>(pcRevolution->Sketch.getValue());
|
||||
}
|
||||
|
||||
// role back the done things
|
||||
Gui::Command::abortCommand();
|
||||
Gui::Command::doCommand(Gui::Command::Gui,"Gui.activeDocument().resetEdit()");
|
||||
|
||||
// if abort command deleted the object the support is visible again
|
||||
if (!Gui::Application::Instance->getViewProvider(pcRevolution)) {
|
||||
if (pcSketch && Gui::Application::Instance->getViewProvider(pcSketch))
|
||||
Gui::Application::Instance->getViewProvider(pcSketch)->show();
|
||||
}
|
||||
|
||||
// Body housekeeping
|
||||
if (ActivePartObject != NULL) {
|
||||
// Make the new Tip and the previous solid feature visible again
|
||||
App::DocumentObject* tip = ActivePartObject->Tip.getValue();
|
||||
App::DocumentObject* prev = ActivePartObject->getPrevSolidFeature();
|
||||
if (tip != NULL) {
|
||||
Gui::Application::Instance->getViewProvider(tip)->show();
|
||||
if ((tip != prev) && (prev != NULL))
|
||||
Gui::Application::Instance->getViewProvider(prev)->show();
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
|
||||
#include "moc_TaskRevolutionParameters.cpp"
|
||||
|
|
|
@ -28,6 +28,7 @@
|
|||
#include <Gui/Selection.h>
|
||||
#include <Gui/TaskView/TaskDialog.h>
|
||||
|
||||
#include "TaskSketchBasedParameters.h"
|
||||
#include "ViewProviderRevolution.h"
|
||||
|
||||
class Ui_TaskRevolutionParameters;
|
||||
|
@ -44,7 +45,7 @@ namespace PartDesignGui {
|
|||
|
||||
|
||||
|
||||
class TaskRevolutionParameters : public Gui::TaskView::TaskBox
|
||||
class TaskRevolutionParameters : public TaskSketchBasedParameters
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
|
@ -59,9 +60,9 @@ private Q_SLOTS:
|
|||
void onAxisChanged(int);
|
||||
void onMidplane(bool);
|
||||
void onReversed(bool);
|
||||
void onUpdateView(bool);
|
||||
|
||||
protected:
|
||||
void onSelectionChanged(const Gui::SelectionChanges& msg) {}
|
||||
void changeEvent(QEvent *e);
|
||||
const bool updateView() const;
|
||||
QString getReferenceAxis(void) const;
|
||||
|
@ -69,16 +70,13 @@ protected:
|
|||
bool getMidplane(void) const;
|
||||
bool getReversed(void) const;
|
||||
|
||||
private:
|
||||
|
||||
private:
|
||||
QWidget* proxy;
|
||||
Ui_TaskRevolutionParameters* ui;
|
||||
ViewProviderRevolution *RevolutionView;
|
||||
};
|
||||
|
||||
/// simulation dialog for the TaskView
|
||||
class TaskDlgRevolutionParameters : public Gui::TaskView::TaskDialog
|
||||
class TaskDlgRevolutionParameters : public TaskDlgSketchBasedParameters
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
|
@ -87,28 +85,13 @@ public:
|
|||
~TaskDlgRevolutionParameters();
|
||||
|
||||
ViewProviderRevolution* getRevolutionView() const
|
||||
{ return RevolutionView; }
|
||||
{ return static_cast<ViewProviderRevolution*>(vp); }
|
||||
|
||||
|
||||
public:
|
||||
/// is called the TaskView when the dialog is opened
|
||||
virtual void open();
|
||||
/// is called by the framework if an button is clicked which has no accept or reject role
|
||||
virtual void clicked(int);
|
||||
public:
|
||||
/// is called by the framework if the dialog is accepted (Ok)
|
||||
virtual bool accept();
|
||||
/// is called by the framework if the dialog is rejected (Cancel)
|
||||
virtual bool reject();
|
||||
virtual bool isAllowedAlterDocument(void) const
|
||||
{ return false; }
|
||||
|
||||
/// returns for Close and Help button
|
||||
virtual QDialogButtonBox::StandardButtons getStandardButtons(void) const
|
||||
{ return QDialogButtonBox::Ok|QDialogButtonBox::Cancel; }
|
||||
|
||||
protected:
|
||||
ViewProviderRevolution *RevolutionView;
|
||||
|
||||
TaskRevolutionParameters *parameter;
|
||||
};
|
||||
|
||||
|
|
111
src/Mod/PartDesign/Gui/TaskRevolutionParameters.h.orig
Normal file
111
src/Mod/PartDesign/Gui/TaskRevolutionParameters.h.orig
Normal file
|
@ -0,0 +1,111 @@
|
|||
/***************************************************************************
|
||||
* Copyright (c) 2011 Juergen Riegel <FreeCAD@juergen-riegel.net> *
|
||||
* *
|
||||
* This file is part of the FreeCAD CAx development system. *
|
||||
* *
|
||||
* This library is free software; you can redistribute it and/or *
|
||||
* modify it under the terms of the GNU Library General Public *
|
||||
* License as published by the Free Software Foundation; either *
|
||||
* version 2 of the License, or (at your option) any later version. *
|
||||
* *
|
||||
* This library is distributed in the hope that it will be useful, *
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
||||
* GNU Library General Public License for more details. *
|
||||
* *
|
||||
* You should have received a copy of the GNU Library General Public *
|
||||
* License along with this library; see the file COPYING.LIB. If not, *
|
||||
* write to the Free Software Foundation, Inc., 59 Temple Place, *
|
||||
* Suite 330, Boston, MA 02111-1307, USA *
|
||||
* *
|
||||
***************************************************************************/
|
||||
|
||||
|
||||
#ifndef GUI_TASKVIEW_TaskRevolutionParameters_H
|
||||
#define GUI_TASKVIEW_TaskRevolutionParameters_H
|
||||
|
||||
#include <Gui/TaskView/TaskView.h>
|
||||
#include <Gui/Selection.h>
|
||||
#include <Gui/TaskView/TaskDialog.h>
|
||||
|
||||
#include "TaskSketchBasedParameters.h"
|
||||
#include "ViewProviderRevolution.h"
|
||||
|
||||
class Ui_TaskRevolutionParameters;
|
||||
|
||||
namespace App {
|
||||
class Property;
|
||||
}
|
||||
|
||||
namespace Gui {
|
||||
class ViewProvider;
|
||||
}
|
||||
|
||||
namespace PartDesignGui {
|
||||
|
||||
|
||||
|
||||
class TaskRevolutionParameters : public TaskSketchBasedParameters
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
TaskRevolutionParameters(ViewProviderRevolution *RevolutionView,QWidget *parent = 0);
|
||||
~TaskRevolutionParameters();
|
||||
|
||||
void apply();
|
||||
|
||||
private Q_SLOTS:
|
||||
void onAngleChanged(double);
|
||||
void onAxisChanged(int);
|
||||
void onMidplane(bool);
|
||||
void onReversed(bool);
|
||||
|
||||
protected:
|
||||
void onSelectionChanged(const Gui::SelectionChanges& msg) {}
|
||||
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:
|
||||
QWidget* proxy;
|
||||
Ui_TaskRevolutionParameters* ui;
|
||||
};
|
||||
|
||||
/// simulation dialog for the TaskView
|
||||
class TaskDlgRevolutionParameters : public TaskDlgSketchBasedParameters
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
TaskDlgRevolutionParameters(ViewProviderRevolution *RevolutionView);
|
||||
~TaskDlgRevolutionParameters();
|
||||
|
||||
ViewProviderRevolution* getRevolutionView() const
|
||||
{ return static_cast<ViewProviderRevolution*>(vp); }
|
||||
|
||||
public:
|
||||
/// is called by the framework if the dialog is accepted (Ok)
|
||||
virtual bool accept();
|
||||
<<<<<<< 0973b40e8e489ddbf6455e9a2e80b0520f143b58
|
||||
/// is called by the framework if the dialog is rejected (Cancel)
|
||||
virtual bool reject();
|
||||
virtual bool isAllowedAlterDocument(void) const
|
||||
{ return false; }
|
||||
|
||||
/// returns for Close and Help button
|
||||
virtual QDialogButtonBox::StandardButtons getStandardButtons(void) const
|
||||
{ return QDialogButtonBox::Ok|QDialogButtonBox::Cancel; }
|
||||
=======
|
||||
>>>>>>> Refactored code of SketchBased features to have common code in an abstract superclass
|
||||
|
||||
protected:
|
||||
TaskRevolutionParameters *parameter;
|
||||
};
|
||||
|
||||
} //namespace PartDesignGui
|
||||
|
||||
#endif // GUI_TASKVIEW_TASKAPPERANCE_H
|
266
src/Mod/PartDesign/Gui/TaskSketchBasedParameters.cpp
Normal file
266
src/Mod/PartDesign/Gui/TaskSketchBasedParameters.cpp
Normal file
|
@ -0,0 +1,266 @@
|
|||
/***************************************************************************
|
||||
* Copyright (c) 2013 Jan Rheinländer <jrheinlaender@users.sourceforge.net>*
|
||||
* *
|
||||
* This file is part of the FreeCAD CAx development system. *
|
||||
* *
|
||||
* This library is free software; you can redistribute it and/or *
|
||||
* modify it under the terms of the GNU Library General Public *
|
||||
* License as published by the Free Software Foundation; either *
|
||||
* version 2 of the License, or (at your option) any later version. *
|
||||
* *
|
||||
* This library is distributed in the hope that it will be useful, *
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
||||
* GNU Library General Public License for more details. *
|
||||
* *
|
||||
* You should have received a copy of the GNU Library General Public *
|
||||
* License along with this library; see the file COPYING.LIB. If not, *
|
||||
* write to the Free Software Foundation, Inc., 59 Temple Place, *
|
||||
* Suite 330, Boston, MA 02111-1307, USA *
|
||||
* *
|
||||
***************************************************************************/
|
||||
|
||||
|
||||
#include "PreCompiled.h"
|
||||
|
||||
#ifndef _PreComp_
|
||||
# include <sstream>
|
||||
# include <QRegExp>
|
||||
# include <QTextStream>
|
||||
# include <QMessageBox>
|
||||
# include <Precision.hxx>
|
||||
#endif
|
||||
|
||||
#include "TaskSketchBasedParameters.h"
|
||||
#include <App/Application.h>
|
||||
#include <App/Document.h>
|
||||
#include <App/Plane.h>
|
||||
#include <Gui/Application.h>
|
||||
#include <Gui/Document.h>
|
||||
#include <Gui/BitmapFactory.h>
|
||||
#include <Gui/ViewProvider.h>
|
||||
#include <Gui/WaitCursor.h>
|
||||
#include <Base/Console.h>
|
||||
#include <Gui/Selection.h>
|
||||
#include <Gui/Command.h>
|
||||
#include <Mod/Part/App/DatumFeature.h>
|
||||
#include <Mod/PartDesign/App/FeatureSketchBased.h>
|
||||
#include <Mod/Sketcher/App/SketchObject.h>
|
||||
#include <Mod/PartDesign/App/Body.h>
|
||||
#include "ReferenceSelection.h"
|
||||
#include "Workbench.h"
|
||||
|
||||
using namespace PartDesignGui;
|
||||
using namespace Gui;
|
||||
|
||||
/* TRANSLATOR PartDesignGui::TaskSketchBasedParameters */
|
||||
|
||||
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)
|
||||
{
|
||||
|
||||
}
|
||||
/*
|
||||
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)
|
||||
{
|
||||
// Note: The validity checking has already been done in ReferenceSelection.cpp
|
||||
PartDesign::SketchBased* pcSketchBased = static_cast<PartDesign::SketchBased*>(vp->getObject());
|
||||
App::DocumentObject* selObj = pcSketchBased->getDocument()->getObject(msg.pObjectName);
|
||||
if (selObj == pcSketchBased)
|
||||
return QString::fromAscii("");
|
||||
std::string subname = msg.pSubName;
|
||||
QString refStr;
|
||||
|
||||
// Remove subname for planes and datum features
|
||||
if (selObj->getTypeId().isDerivedFrom(App::Plane::getClassTypeId()) ||
|
||||
selObj->getTypeId().isDerivedFrom(Part::Datum::getClassTypeId())) {
|
||||
subname = "";
|
||||
refStr = QString::fromAscii(selObj->getNameInDocument());
|
||||
} else {
|
||||
int faceId = std::atoi(&subname[4]);
|
||||
refStr = QString::fromAscii(selObj->getNameInDocument()) + QObject::tr(":Face") + QString::number(faceId);
|
||||
}
|
||||
|
||||
std::vector<std::string> upToFaces(1,subname);
|
||||
pcSketchBased->UpToFace.setValue(selObj, upToFaces);
|
||||
if (updateView())
|
||||
pcSketchBased->getDocument()->recomputeFeature(pcSketchBased);
|
||||
|
||||
return refStr;
|
||||
}
|
||||
|
||||
void TaskSketchBasedParameters::onButtonFace(const bool pressed) {
|
||||
// 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());
|
||||
|
||||
if (pressed) {
|
||||
Gui::Document* doc = Gui::Application::Instance->activeDocument();
|
||||
if (doc && solid) {
|
||||
doc->setHide(pcSketchBased->getNameInDocument());
|
||||
doc->setShow(solid->getNameInDocument());
|
||||
}
|
||||
Gui::Selection().clearSelection();
|
||||
Gui::Selection().addSelectionGate
|
||||
(new ReferenceSelection(solid, false, true, false));
|
||||
} else {
|
||||
Gui::Selection().rmvSelectionGate();
|
||||
Gui::Document* doc = Gui::Application::Instance->activeDocument();
|
||||
if (doc && solid) {
|
||||
doc->setShow(pcSketchBased->getNameInDocument());
|
||||
doc->setHide(solid->getNameInDocument());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
const QByteArray TaskSketchBasedParameters::onFaceName(const QString& text)
|
||||
{
|
||||
if (text.length() == 0)
|
||||
return QByteArray();
|
||||
|
||||
QStringList parts = text.split(QChar::fromAscii(':'));
|
||||
if (parts.length() < 2)
|
||||
parts.push_back(QString::fromAscii(""));
|
||||
// Check whether this is the name of an App::Plane or Part::Datum feature
|
||||
App::DocumentObject* obj = vp->getObject()->getDocument()->getObject(parts[0].toAscii());
|
||||
if (obj == NULL)
|
||||
return QByteArray();
|
||||
|
||||
if (obj->getTypeId().isDerivedFrom(App::Plane::getClassTypeId())) {
|
||||
// everything is OK (we assume a Part can only have exactly 3 App::Plane objects located at the base of the feature tree)
|
||||
return QByteArray();
|
||||
} else if (obj->getTypeId().isDerivedFrom(Part::Datum::getClassTypeId())) {
|
||||
if (!PartDesignGui::ActivePartObject->hasFeature(obj))
|
||||
return QByteArray();
|
||||
return QByteArray();
|
||||
} else {
|
||||
// We must expect that "text" is the translation of "Face" followed by an ID.
|
||||
QString name;
|
||||
QTextStream str(&name);
|
||||
str << "^" << tr("Face") << "(\\d+)$";
|
||||
QRegExp rx(name);
|
||||
if (text.indexOf(rx) < 0) {
|
||||
return QByteArray();
|
||||
}
|
||||
|
||||
int faceId = rx.cap(1).toInt();
|
||||
std::stringstream ss;
|
||||
ss << "Face" << faceId;
|
||||
|
||||
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);
|
||||
|
||||
return QByteArray(ss.str().c_str());
|
||||
}
|
||||
}
|
||||
|
||||
QString TaskSketchBasedParameters::getFaceReference(const QString& obj, const QString& sub) const
|
||||
{
|
||||
QString o = obj.left(obj.indexOf(QString::fromAscii(":")));
|
||||
|
||||
if (o == tr("No face selected"))
|
||||
return QString::fromAscii("");
|
||||
else
|
||||
return QString::fromAscii("(App.activeDocument().") + o +
|
||||
QString::fromAscii(", [\"") + sub + QString::fromAscii("\"])");
|
||||
}
|
||||
|
||||
void TaskSketchBasedParameters::onUpdateView(bool on)
|
||||
{
|
||||
if (on) {
|
||||
PartDesign::SketchBased* pcSketchBased = static_cast<PartDesign::SketchBased*>(vp->getObject());
|
||||
pcSketchBased->getDocument()->recomputeFeature(pcSketchBased);
|
||||
}
|
||||
}
|
||||
|
||||
TaskSketchBasedParameters::~TaskSketchBasedParameters()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
//**************************************************************************
|
||||
//**************************************************************************
|
||||
// TaskDialog
|
||||
//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
|
||||
|
||||
TaskDlgSketchBasedParameters::TaskDlgSketchBasedParameters(ViewProvider *vp)
|
||||
: TaskDialog(),vp(vp)
|
||||
{
|
||||
}
|
||||
|
||||
TaskDlgSketchBasedParameters::~TaskDlgSketchBasedParameters()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
//==== calls from the TaskView ===============================================================
|
||||
|
||||
|
||||
void TaskDlgSketchBasedParameters::open()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void TaskDlgSketchBasedParameters::clicked(int)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
bool TaskDlgSketchBasedParameters::reject()
|
||||
{
|
||||
// get the support and Sketch
|
||||
PartDesign::SketchBased* pcSketchBased = static_cast<PartDesign::SketchBased*>(vp->getObject());
|
||||
Sketcher::SketchObject *pcSketch;
|
||||
if (pcSketchBased->Sketch.getValue()) {
|
||||
pcSketch = static_cast<Sketcher::SketchObject*>(pcSketchBased->Sketch.getValue());
|
||||
}
|
||||
|
||||
// roll back the done things
|
||||
Gui::Command::abortCommand();
|
||||
Gui::Command::doCommand(Gui::Command::Gui,"Gui.activeDocument().resetEdit()");
|
||||
|
||||
// if abort command deleted the object the sketch is visible again
|
||||
if (!Gui::Application::Instance->getViewProvider(pcSketchBased)) {
|
||||
if (pcSketch && Gui::Application::Instance->getViewProvider(pcSketch))
|
||||
Gui::Application::Instance->getViewProvider(pcSketch)->show();
|
||||
}
|
||||
|
||||
// Body housekeeping
|
||||
if (ActivePartObject != NULL) {
|
||||
// Make the new Tip and the previous solid feature visible again
|
||||
App::DocumentObject* tip = ActivePartObject->Tip.getValue();
|
||||
App::DocumentObject* prev = ActivePartObject->getPrevSolidFeature();
|
||||
if (tip != NULL) {
|
||||
Gui::Application::Instance->getViewProvider(tip)->show();
|
||||
if ((tip != prev) && (prev != NULL))
|
||||
Gui::Application::Instance->getViewProvider(prev)->show();
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
#include "moc_TaskSketchBasedParameters.cpp"
|
97
src/Mod/PartDesign/Gui/TaskSketchBasedParameters.h
Normal file
97
src/Mod/PartDesign/Gui/TaskSketchBasedParameters.h
Normal file
|
@ -0,0 +1,97 @@
|
|||
/***************************************************************************
|
||||
* Copyright (c) 2013 Jan Rheinländer <jrheinlaender@users.sourceforge.net>*
|
||||
* *
|
||||
* This file is part of the FreeCAD CAx development system. *
|
||||
* *
|
||||
* This library is free software; you can redistribute it and/or *
|
||||
* modify it under the terms of the GNU Library General Public *
|
||||
* License as published by the Free Software Foundation; either *
|
||||
* version 2 of the License, or (at your option) any later version. *
|
||||
* *
|
||||
* This library is distributed in the hope that it will be useful, *
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
||||
* GNU Library General Public License for more details. *
|
||||
* *
|
||||
* You should have received a copy of the GNU Library General Public *
|
||||
* License along with this library; see the file COPYING.LIB. If not, *
|
||||
* write to the Free Software Foundation, Inc., 59 Temple Place, *
|
||||
* Suite 330, Boston, MA 02111-1307, USA *
|
||||
* *
|
||||
***************************************************************************/
|
||||
|
||||
|
||||
#ifndef GUI_TASKVIEW_TaskSketchBasedParameters_H
|
||||
#define GUI_TASKVIEW_TaskSketchBasedParameters_H
|
||||
|
||||
#include <Gui/TaskView/TaskView.h>
|
||||
#include <Gui/Selection.h>
|
||||
#include <Gui/TaskView/TaskDialog.h>
|
||||
#include "ViewProvider.h"
|
||||
|
||||
namespace App {
|
||||
class Property;
|
||||
}
|
||||
|
||||
namespace PartDesignGui {
|
||||
|
||||
|
||||
/// Convenience class to collect common methods for all SketchBased features
|
||||
class TaskSketchBasedParameters : public Gui::TaskView::TaskBox, public Gui::SelectionObserver
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
TaskSketchBasedParameters(ViewProvider* vp, QWidget *parent,
|
||||
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);
|
||||
const QByteArray onFaceName(const QString& text);
|
||||
QString getFaceReference(const QString& obj, const QString& sub) const;
|
||||
virtual const bool updateView() const=0;
|
||||
|
||||
protected Q_SLOTS:
|
||||
void onUpdateView(bool on);
|
||||
|
||||
protected:
|
||||
ViewProvider *vp;
|
||||
};
|
||||
|
||||
class TaskDlgSketchBasedParameters : public Gui::TaskView::TaskDialog
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
TaskDlgSketchBasedParameters(ViewProvider *vp);
|
||||
~TaskDlgSketchBasedParameters();
|
||||
|
||||
public:
|
||||
/// is called the TaskView when the dialog is opened
|
||||
virtual void open();
|
||||
/// is called by the framework if an button is clicked which has no accept or reject role
|
||||
virtual void clicked(int);
|
||||
/// is called by the framework if the dialog is accepted (Ok)
|
||||
virtual bool accept()=0;
|
||||
/// is called by the framework if the dialog is rejected (Cancel)
|
||||
virtual bool reject();
|
||||
/// is called by the framework if the user presses the help button
|
||||
virtual bool isAllowedAlterDocument(void) const
|
||||
{ return false; }
|
||||
|
||||
/// returns for Close and Help button
|
||||
virtual QDialogButtonBox::StandardButtons getStandardButtons(void) const
|
||||
{ return QDialogButtonBox::Ok|QDialogButtonBox::Cancel; }
|
||||
|
||||
protected:
|
||||
ViewProvider *vp;
|
||||
};
|
||||
|
||||
} //namespace PartDesignGui
|
||||
|
||||
#endif // GUI_TASKVIEW_TaskSketchBasedParameters_H
|
Loading…
Reference in New Issue
Block a user