diff --git a/src/Mod/Surface/App/FeatureBSplineSurf.h b/src/Mod/Surface/App/FeatureBSplineSurf.h
index 5e799a3fa0..f36812b93f 100644
--- a/src/Mod/Surface/App/FeatureBSplineSurf.h
+++ b/src/Mod/Surface/App/FeatureBSplineSurf.h
@@ -37,7 +37,7 @@ public:
BSplineSurf();
// recalculate the feature
- App::DocumentObjectExecReturn *execute(void);
+ virtual App::DocumentObjectExecReturn *execute(void);
};
}//Namespace Surface
#endif
diff --git a/src/Mod/Surface/App/FeatureBSurf.h b/src/Mod/Surface/App/FeatureBSurf.h
index fe3daf5601..cbbdb44fd9 100644
--- a/src/Mod/Surface/App/FeatureBSurf.h
+++ b/src/Mod/Surface/App/FeatureBSurf.h
@@ -44,11 +44,12 @@ public:
App::PropertyInteger filltype; //Fill method (1, 2, or 3 for Stretch, Coons, and Curved)
short mustExecute() const;
+ virtual App::DocumentObjectExecReturn *execute(void) = 0;
/// returns the type name of the view provider
- const char* getViewProviderName(void) const {
- return "SurfaceGui::ViewProviderBSurf";
- }
+ const char* getViewProviderName(void) const {
+ return "SurfaceGui::ViewProviderBSurf";
+ }
protected:
GeomFill_FillingStyle getFillingStyle();
diff --git a/src/Mod/Surface/App/FeatureBezSurf.h b/src/Mod/Surface/App/FeatureBezSurf.h
index f0bbcd8e46..f3f106cd20 100644
--- a/src/Mod/Surface/App/FeatureBezSurf.h
+++ b/src/Mod/Surface/App/FeatureBezSurf.h
@@ -37,7 +37,7 @@ public:
BezSurf();
// recalculate the feature
- App::DocumentObjectExecReturn *execute(void);
+ virtual App::DocumentObjectExecReturn *execute(void);
};
}//Namespace Surface
#endif
diff --git a/src/Mod/Surface/Gui/AppSurfaceGui.cpp b/src/Mod/Surface/Gui/AppSurfaceGui.cpp
index bb1ad80330..2d9ce6b45f 100644
--- a/src/Mod/Surface/Gui/AppSurfaceGui.cpp
+++ b/src/Mod/Surface/Gui/AppSurfaceGui.cpp
@@ -29,6 +29,7 @@
#endif
#include
+#include
#include
#include "Workbench.h"
@@ -54,12 +55,15 @@ void SurfaceGuiExport initSurfaceGui()
return;
}
- SurfaceGui::Workbench::init();
- SurfaceGui::ViewProviderBSurf::init();
-
+// Base::Interpreter().runString("import SurfaceGui"); infinite Python recursion comes
+ Base::Interpreter().runString("import PartGui");
+
// instanciating the commands
CreateSurfaceCommands();
+ SurfaceGui::Workbench::init();
+ SurfaceGui::ViewProviderBSurf::init();
+
// SurfaceGui::ViewProviderCut::init();
(void) Py_InitModule3("SurfaceGui", SurfaceGui_methods, module_SurfaceGui_doc); /* mod name, table ptr */
diff --git a/src/Mod/Surface/Gui/BSurf.cpp b/src/Mod/Surface/Gui/BSurf.cpp
index c4e92583eb..9daeb3cfcf 100644
--- a/src/Mod/Surface/Gui/BSurf.cpp
+++ b/src/Mod/Surface/Gui/BSurf.cpp
@@ -35,6 +35,8 @@
#endif
#include "BSurf.h"
+#include "../App/FeatureBSurf.h"
+#include "../FillType.h"
#include
#include
#include
@@ -54,32 +56,35 @@ bool ViewProviderBSurf::setEdit(int ModNum)
// When double-clicking on the item for this sketch the
// object unsets and sets its edit mode without closing
// the task panel
- Gui::TaskView::TaskDialog* dlg = Gui::Control().activeDialog();
- TaskBSurf* tDlg = qobject_cast(dlg);
+
+ Surface::BSurf* obj = static_cast(this->getObject());
+
+ Gui::TaskView::TaskDialog* dlg = Gui::Control().activeDialog();
+ TaskBSurf* tDlg = qobject_cast(dlg);
// start the edit dialog
if(dlg)
- Gui::Control().showDialog(tDlg);
+ {
+ tDlg->setEditedObject(obj);
+ Gui::Control().showDialog(tDlg);
+ }
else
- Gui::Control().showDialog(new TaskBSurf(this));
-// draw();
+ {
+ Gui::Control().showDialog(new TaskBSurf(this, obj));
+ }
return true;
}
void ViewProviderBSurf::unsetEdit(int ModNum)
{
-/*if(!Gui::Selection().isSelected(pcObject) || !Visibility.getValue()) {
- internal_vp.switch_node(false);
- pcModeSwitch->whichChild = -1;
- m_selected = false;
- } */
+ // nothing to do
}
-BSurf::BSurf(ViewProviderBSurf* vp)
- //: QDialog(parent, fl), bbox(bb)
+BSurf::BSurf(ViewProviderBSurf* vp, Surface::BSurf* obj)
{
ui = new Ui_DlgBSurf();
ui->setupUi(this);
- vp = new ViewProviderBSurf();
+ this->vp = vp;
+ setEditedObject(obj);
}
/*
@@ -89,7 +94,31 @@ BSurf::~BSurf()
{
// no need to delete child widgets, Qt does it all for us
delete ui;
- delete vp;
+}
+
+// stores object pointer, its old fill type and adjusts radio buttons according to it.
+void BSurf::setEditedObject(Surface::BSurf* obj)
+{
+ editedObject = obj;
+ filltype_t ft = (filltype_t)(editedObject->filltype.getValue());
+ switch(ft)
+ {
+ case StretchStyle:
+ oldFillType = ft;
+ ui->fillType_stretch->setChecked(true);
+ break;
+ case CoonsStyle:
+ oldFillType = ft;
+ ui->fillType_coons->setChecked(true);
+ break;
+ case CurvedStyle:
+ oldFillType = ft;
+ ui->fillType_curved->setChecked(true);
+ break;
+ /*default:
+ printf("BSurf::setEditedObject: illegal fill type: %d\n", editedObject->filltype.getValue());
+ Standard_Failure::Raise("BSurf::setEditedObject: illegal fill type.");*/
+ }
}
filltype_t BSurf::getFillType() const
@@ -101,7 +130,6 @@ filltype_t BSurf::getFillType() const
ret = CoonsStyle;
else
ret = CurvedStyle;
- printf("BSurf::getFillType: %d\n", ret);
return ret;
}
@@ -117,43 +145,52 @@ void BSurf::changeEvent(QEvent *e)
void BSurf::accept()
{
- printf("accept ");
+ // applies the changes
apply();
QDialog::accept();
}
+void BSurf::reject()
+{
+ // if the object fill type was changed, reset the old one
+ if(editedObject->filltype.getValue() != oldFillType)
+ {
+ editedObject->filltype.setValue(oldFillType);
+ editedObject->execute();
+ }
+ QDialog::reject();
+}
+
void BSurf::apply()
{
- printf("apply\n");
- // std::vector obj = Gui::Selection().
- // getObjectsOfType(Part::Feature::getClassTypeId());
-////////////////
+ // apply the change only if it is a real change
+ if(editedObject->filltype.getValue() != fillType)
+ {
+ editedObject->filltype.setValue(fillType);
+ editedObject->execute();
+ }
}
void BSurf::on_fillType_stretch_clicked()
{
- printf("stretch\n");
+ fillType = StretchStyle;
}
void BSurf::on_fillType_coons_clicked()
{
- printf("coons\n");
+ fillType = CoonsStyle;
}
void BSurf::on_fillType_curved_clicked()
{
- printf("curved\n");
+ fillType = CurvedStyle;
}
// ---------------------------------------
-TaskBSurf::TaskBSurf(ViewProviderBSurf* vp)
+TaskBSurf::TaskBSurf(ViewProviderBSurf* vp, Surface::BSurf* obj)
{
- widget = new BSurf(vp);
-/* taskbox = new Gui::TaskView::TaskBox(
- NULL,
- widget->windowTitle(), true, 0);
- taskbox->groupLayout()->addWidget(widget);*/
+ widget = new BSurf(vp, obj);
Content.push_back(widget);
}
@@ -162,12 +199,24 @@ TaskBSurf::~TaskBSurf()
// automatically deleted in the sub-class
}
+void TaskBSurf::setEditedObject(Surface::BSurf* obj)
+{
+ widget->setEditedObject(obj);
+}
+
bool TaskBSurf::accept()
{
widget->accept();
return (widget->result() == QDialog::Accepted);
}
+bool TaskBSurf::reject()
+{
+ widget->reject();
+ return (widget->result() == QDialog::Rejected);
+}
+
+// Apply clicked
void TaskBSurf::clicked(int id)
{
if (id == QDialogButtonBox::Apply) {
diff --git a/src/Mod/Surface/Gui/BSurf.h b/src/Mod/Surface/Gui/BSurf.h
index c26137a058..048cb2c394 100644
--- a/src/Mod/Surface/Gui/BSurf.h
+++ b/src/Mod/Surface/Gui/BSurf.h
@@ -35,6 +35,7 @@
#include "../FillType.h"
#include
#include "ui_BSurf.h"
+#include "../App/FeatureBSurf.h"
namespace SurfaceGui
{
@@ -51,13 +52,21 @@ namespace SurfaceGui
{
Q_OBJECT
protected:
- filltype_t fillType;
+ filltype_t fillType, oldFillType;
+ Surface::BSurf* editedObject;
+
+ private:
+ Ui_DlgBSurf* ui;
+ Base::BoundBox3d bbox;
+ ViewProviderBSurf* vp;
public:
- BSurf(ViewProviderBSurf* vp);
+ BSurf(ViewProviderBSurf* vp, Surface::BSurf* obj);
~BSurf();
void accept();
+ void reject();
void apply();
+ void setEditedObject(Surface::BSurf* obj);
protected:
void changeEvent(QEvent *e);
@@ -67,19 +76,6 @@ namespace SurfaceGui
void on_fillType_coons_clicked();
void on_fillType_curved_clicked();
filltype_t getFillType() const;
-
-/* private:
- std::vector getPlanes() const;
- void calcPlane(Plane, double);
- void calcPlanes(Plane);
- void makePlanes(Plane, const std::vector&, double[4]);
- Plane plane() const;*/
-
- private:
- Ui_DlgBSurf* ui;
- Base::BoundBox3d bbox;
- ViewProviderBSurf* vp;
-// QPointer view;
};
class TaskBSurf : public Gui::TaskView::TaskDialog
@@ -87,11 +83,13 @@ namespace SurfaceGui
Q_OBJECT
public:
- TaskBSurf(ViewProviderBSurf* vp);
+ TaskBSurf(ViewProviderBSurf* vp, Surface::BSurf* obj);
~TaskBSurf();
+ void setEditedObject(Surface::BSurf* obj);
public:
bool accept();
+ bool reject();
void clicked(int id);
virtual QDialogButtonBox::StandardButtons getStandardButtons() const
diff --git a/src/Mod/Surface/Gui/Command.cpp b/src/Mod/Surface/Gui/Command.cpp
index e90ab5f29a..bb4ef5967d 100644
--- a/src/Mod/Surface/Gui/Command.cpp
+++ b/src/Mod/Surface/Gui/Command.cpp
@@ -165,12 +165,6 @@ CmdSurfaceBezier::CmdSurfaceBezier()
void CmdSurfaceBezier::activated(int iMsg)
{
- /*if (!isActive()) {
- QMessageBox::warning(Gui::getMainWindow(), QObject::tr("Wrong selection"),
- QObject::tr("Select 2, 3 or 4 curves, please."));
- return;
- }*/
-
// we take the whole selection and require that all of its members are of the required curve
std::vector Selo = getSelection().getSelectionEx(0);
std::string FeatName = getUniqueObjectName("BezierSurface");
@@ -184,6 +178,7 @@ void CmdSurfaceBezier::activated(int iMsg)
openCommand("Create Bezier surface");
doCommand(Doc,"FreeCAD.ActiveDocument.addObject(\"Surface::BezSurf\",\"%s\")", FeatName.c_str());
doCommand(Doc, "FreeCAD.ActiveDocument.ActiveObject.filltype=1"); // TODO ask filltype from user and check it
+ doCommand(Doc, "Gui.ActiveDocument.setEdit('%s',0)", FeatName.c_str());
runCommand(Doc, bezListCmd.str().c_str());
updateActive();
commitCommand();
@@ -241,12 +236,6 @@ CmdSurfaceBSpline::CmdSurfaceBSpline()
void CmdSurfaceBSpline::activated(int iMsg)
{
- /*Gui::TaskView::TaskDialog* dlg = Gui::Control().activeDialog();
- if (!dlg) {
- dlg = new SurfaceGui::TaskBSurf(new SurfaceGui::ViewProviderBSurf());
- }
- Gui::Control().showDialog(dlg);*/
-
// we take the whole selection and require that all of its members are of the required curve
std::vector Selo = getSelection().getSelectionEx(0);
std::string FeatName = getUniqueObjectName("BSplineSurface");