From 52c8a19d4dd0c198b3e8bfbeaf3b9f2b7ea5796a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stefan=20Tr=C3=B6ger?= Date: Sun, 10 May 2015 20:14:10 +0200 Subject: [PATCH] basic infrastructure for part design primitives --- src/Mod/PartDesign/App/AppPartDesign.cpp | 5 + src/Mod/PartDesign/App/CMakeLists.txt | 2 + src/Mod/PartDesign/App/FeaturePrimitive.cpp | 159 +++++++++++++ src/Mod/PartDesign/App/FeaturePrimitive.h | 105 +++++++++ src/Mod/PartDesign/Gui/AppPartDesignGui.cpp | 4 + src/Mod/PartDesign/Gui/CMakeLists.txt | 5 +- src/Mod/PartDesign/Gui/CommandPrimitive.cpp | 209 ++++++++++++++++++ .../PartDesign/Gui/ViewProviderPrimitive.cpp | 93 ++++++++ .../PartDesign/Gui/ViewProviderPrimitive.h | 49 ++++ src/Mod/PartDesign/Gui/Workbench.cpp | 2 + 10 files changed, 632 insertions(+), 1 deletion(-) create mode 100644 src/Mod/PartDesign/App/FeaturePrimitive.cpp create mode 100644 src/Mod/PartDesign/App/FeaturePrimitive.h create mode 100644 src/Mod/PartDesign/Gui/CommandPrimitive.cpp create mode 100644 src/Mod/PartDesign/Gui/ViewProviderPrimitive.cpp create mode 100644 src/Mod/PartDesign/Gui/ViewProviderPrimitive.h diff --git a/src/Mod/PartDesign/App/AppPartDesign.cpp b/src/Mod/PartDesign/App/AppPartDesign.cpp index 61125def2..cad48c424 100644 --- a/src/Mod/PartDesign/App/AppPartDesign.cpp +++ b/src/Mod/PartDesign/App/AppPartDesign.cpp @@ -51,6 +51,7 @@ #include "DatumLine.h" #include "DatumPoint.h" #include "FeatureBoolean.h" +#include "FeaturePrimitive.h" namespace PartDesign { extern PyObject* initModule(); @@ -101,6 +102,10 @@ PyMODINIT_FUNC init_PartDesign() PartDesign::Line ::init(); PartDesign::Point ::init(); PartDesign::Boolean ::init(); + PartDesign::FeaturePrimitive ::init(); + PartDesign::Box ::init(); + PartDesign::AdditiveBox ::init(); + PartDesign::SubtractiveBox ::init(); PartDesign::Point::initHints(); PartDesign::Line ::initHints(); diff --git a/src/Mod/PartDesign/App/CMakeLists.txt b/src/Mod/PartDesign/App/CMakeLists.txt index 7d17cd534..07b995e5c 100644 --- a/src/Mod/PartDesign/App/CMakeLists.txt +++ b/src/Mod/PartDesign/App/CMakeLists.txt @@ -94,6 +94,8 @@ SET(FeaturesSketchBased_SRCS FeatureHole.cpp FeatureBoolean.h FeatureBoolean.cpp + FeaturePrimitive.h + FeaturePrimitive.cpp ) SOURCE_GROUP("SketchBasedFeatures" FILES ${FeaturesSketchBased_SRCS}) diff --git a/src/Mod/PartDesign/App/FeaturePrimitive.cpp b/src/Mod/PartDesign/App/FeaturePrimitive.cpp new file mode 100644 index 000000000..1e3e31a10 --- /dev/null +++ b/src/Mod/PartDesign/App/FeaturePrimitive.cpp @@ -0,0 +1,159 @@ +/*************************************************************************** + * Copyright (c) 2015 Stefan Tröger * + * * + * 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_ +#endif + + +#include "FeaturePrimitive.h" +#include +#include +#include +#include + +namespace PartDesign { + + +PROPERTY_SOURCE(PartDesign::FeaturePrimitive, PartDesign::FeatureAddSub) + +FeaturePrimitive::FeaturePrimitive() +{ + ADD_PROPERTY_TYPE(References, (0,0), "Primitive", (App::PropertyType)(App::Prop_None), "References to build the location of the primitive"); +} + +App::DocumentObjectExecReturn* FeaturePrimitive::execute(const TopoDS_Shape& primitiveShape) +{ + try { + //transform the primitive in the correct coordinance + BRepBuilderAPI_GTransform mkTrf(primitiveShape, getLocation().Transformation()); + const TopoDS_Shape primitiveShape = mkTrf.Shape(); + + //if we have no base we just add the standart primitive shape + const TopoDS_Shape base = getBaseShape(); + if(base.IsNull()) { + if(getAddSubType() == FeatureAddSub::Additive) + Shape.setValue(primitiveShape); + else + return new App::DocumentObjectExecReturn("Cannot subtract primitive feature without base feature"); + + AddSubShape.setValue(base); + return App::DocumentObject::StdReturn; + } + + if(getAddSubType() == FeatureAddSub::Additive) { + BRepAlgoAPI_Fuse mkFuse(base, primitiveShape); + if (!mkFuse.IsDone()) + return new App::DocumentObjectExecReturn("Adding the primitive failed"); + // we have to get the solids (fuse sometimes creates compounds) + TopoDS_Shape boolOp = this->getSolid(mkFuse.Shape()); + // lets check if the result is a solid + if (boolOp.IsNull()) + return new App::DocumentObjectExecReturn("Resulting shape is not a solid"); + + Shape.setValue(boolOp); + AddSubShape.setValue(primitiveShape); + } + else if(getAddSubType() == FeatureAddSub::Subtractive) { + + BRepAlgoAPI_Cut mkCut(base, primitiveShape); + if (!mkCut.IsDone()) + return new App::DocumentObjectExecReturn("Subtracting the primitive failed"); + // we have to get the solids (fuse sometimes creates compounds) + TopoDS_Shape boolOp = this->getSolid(mkCut.Shape()); + // lets check if the result is a solid + if (boolOp.IsNull()) + return new App::DocumentObjectExecReturn("Resulting shape is not a solid"); + + Shape.setValue(boolOp); + AddSubShape.setValue(primitiveShape); + } + + + } + catch (Standard_Failure) { + Handle_Standard_Failure e = Standard_Failure::Caught(); + return new App::DocumentObjectExecReturn(e->GetMessageString()); + } + + return App::DocumentObject::StdReturn; +} + +TopLoc_Location FeaturePrimitive::calculateLocation() +{ + return TopLoc_Location(); +} + + + +PROPERTY_SOURCE(PartDesign::Box, PartDesign::FeaturePrimitive) + +Box::Box() +{ + ADD_PROPERTY_TYPE(Length,(10.0f),"Box",App::Prop_None,"The length of the box"); + ADD_PROPERTY_TYPE(Width ,(10.0f),"Box",App::Prop_None,"The width of the box"); + ADD_PROPERTY_TYPE(Height,(10.0f),"Box",App::Prop_None,"The height of the box"); + + primitiveType = FeaturePrimitive::Box; +} + +App::DocumentObjectExecReturn* Box::execute(void) +{ + double L = Length.getValue(); + double W = Width.getValue(); + double H = Height.getValue(); + + if (L < Precision::Confusion()) + return new App::DocumentObjectExecReturn("Length of box too small"); + + if (W < Precision::Confusion()) + return new App::DocumentObjectExecReturn("Width of box too small"); + + if (H < Precision::Confusion()) + return new App::DocumentObjectExecReturn("Height of box too small"); + + try { + // Build a box using the dimension attributes + BRepPrimAPI_MakeBox mkBox(L, W, H); + return FeaturePrimitive::execute(mkBox.Shape()); + } + catch (Standard_Failure) { + Handle_Standard_Failure e = Standard_Failure::Caught(); + return new App::DocumentObjectExecReturn(e->GetMessageString()); + } +} + +short int Box::mustExecute() const +{ + if ( Length.isTouched() || + Height.isTouched() || + Width.isTouched() ) + return 1; + + return FeaturePrimitive::mustExecute(); +} + +PROPERTY_SOURCE(PartDesign::AdditiveBox, PartDesign::Box) +PROPERTY_SOURCE(PartDesign::SubtractiveBox, PartDesign::Box) + +} diff --git a/src/Mod/PartDesign/App/FeaturePrimitive.h b/src/Mod/PartDesign/App/FeaturePrimitive.h new file mode 100644 index 000000000..a4b7716f2 --- /dev/null +++ b/src/Mod/PartDesign/App/FeaturePrimitive.h @@ -0,0 +1,105 @@ +/*************************************************************************** + * Copyright (c) 2015 Stefan Tröger * + * * + * 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 PARTDESIGN_FeaturePrimitive_H +#define PARTDESIGN_FeaturePrimitive_H + +#include +#include + +#include "FeatureAddSub.h" + +namespace PartDesign +{ + +class PartDesignExport FeaturePrimitive : public PartDesign::FeatureAddSub +{ + PROPERTY_HEADER(PartDesign::FeaturePrimitive); + +public: + enum Type { + Box=0, + Cylinder, + Sphere + }; + + FeaturePrimitive(); + + virtual const char* getViewProviderName(void) const { + return "getViewProviderPrimitive"; + } + Type getPrimitiveType() {return primitiveType;}; + + /// The references defining the primtive base + App::PropertyLinkSubList References; + +protected: + //make the boolean ops with the primitives provided by the derived features + App::DocumentObjectExecReturn* execute(const TopoDS_Shape& primitiveShape); + + //calculate the position of the primitive from the support and the exis + TopLoc_Location calculateLocation(); + + Type primitiveType = Box; +}; + +class PartDesignExport Box : public PartDesign::FeaturePrimitive { + + PROPERTY_HEADER(Part::Box); + +public: + + Box(); + + App::PropertyLength Length,Height,Width; + + /** @name methods override feature */ + //@{ + /// recalculate the Feature + App::DocumentObjectExecReturn *execute(void); + short mustExecute() const; + +protected: + +}; + +class PartDesignExport AdditiveBox : public Box { + PROPERTY_HEADER(PartDesign::AdditiveBox); + + AdditiveBox() { + addSubType = FeatureAddSub::Additive; + } +}; + +class PartDesignExport SubtractiveBox : public Box { + PROPERTY_HEADER(PartDesign::SubtractiveBox); + + SubtractiveBox() { + addSubType = FeatureAddSub::Subtractive; + } +}; + +} //namespace PartDesign + + +#endif // PARTDESIGN_FeaturePrimitive_H diff --git a/src/Mod/PartDesign/Gui/AppPartDesignGui.cpp b/src/Mod/PartDesign/Gui/AppPartDesignGui.cpp index 58e146b83..15ffd3d8d 100644 --- a/src/Mod/PartDesign/Gui/AppPartDesignGui.cpp +++ b/src/Mod/PartDesign/Gui/AppPartDesignGui.cpp @@ -54,9 +54,11 @@ #include "ViewProviderDatumLine.h" #include "ViewProviderDatumPlane.h" #include "ViewProviderBoolean.h" +#include "ViewProviderPrimitive.h" // use a different name to CreateCommand() void CreatePartDesignCommands(void); +void CreatePartDesignPrimitiveCommands(void); void loadPartDesignResource() { @@ -109,6 +111,7 @@ PyMODINIT_FUNC initPartDesignGui() // instantiating the commands CreatePartDesignCommands(); + CreatePartDesignPrimitiveCommands(); PartDesignGui::Workbench ::init(); PartDesignGui::ViewProvider ::init(); @@ -132,6 +135,7 @@ PyMODINIT_FUNC initPartDesignGui() PartDesignGui::ViewProviderDatumLine ::init(); PartDesignGui::ViewProviderDatumPlane ::init(); PartDesignGui::ViewProviderBoolean ::init(); + PartDesignGui::ViewProviderPrimitive ::init(); // add resources and reloads the translators loadPartDesignResource(); diff --git a/src/Mod/PartDesign/Gui/CMakeLists.txt b/src/Mod/PartDesign/Gui/CMakeLists.txt index e72aab283..2b3c7b7c9 100644 --- a/src/Mod/PartDesign/Gui/CMakeLists.txt +++ b/src/Mod/PartDesign/Gui/CMakeLists.txt @@ -75,7 +75,7 @@ set(PartDesignGui_UIC_SRCS ) qt4_wrap_ui(PartDesignGui_UIC_HDRS ${PartDesignGui_UIC_SRCS}) -SET(PartDesignGuiViewProvider_SRCS +SET(PartDesignGuiViewProvider_SRCS CommandPrimitive.cpp ViewProvider.cpp ViewProvider.h ViewProviderBody.cpp @@ -120,6 +120,8 @@ SET(PartDesignGuiViewProvider_SRCS ViewProviderDatumPlane.h ViewProviderBoolean.cpp ViewProviderBoolean.h + ViewProviderPrimitive.h + ViewProviderPrimitive.cpp ) SOURCE_GROUP("ViewProvider" FILES ${PartDesignGuiViewProvider_SRCS}) @@ -189,6 +191,7 @@ SOURCE_GROUP("TaskDialogs" FILES ${PartDesignGuiTaskDlgs_SRCS}) SET(PartDesignGuiModule_SRCS AppPartDesignGui.cpp Command.cpp + CommandPrimitive.cpp Resources/PartDesign.qrc PreCompiled.cpp PreCompiled.h diff --git a/src/Mod/PartDesign/Gui/CommandPrimitive.cpp b/src/Mod/PartDesign/Gui/CommandPrimitive.cpp new file mode 100644 index 000000000..4c37bdcfe --- /dev/null +++ b/src/Mod/PartDesign/Gui/CommandPrimitive.cpp @@ -0,0 +1,209 @@ +/*************************************************************************** + * Copyright (c) 2015 Stefan Tröger (stefantroeger@gmx.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" +#include "Workbench.h" +#include +#ifndef _PreComp_ +# include +# include +#endif + +#include +#include +#include +#include +#include +#include + +using namespace std; + +DEF_STD_CMD_ACL(CmdPrimtiveCompAdditive); + +CmdPrimtiveCompAdditive::CmdPrimtiveCompAdditive() + : Command("PartDesign_CompPrimitiveAdditive") +{ + sAppModule = "PartDesign"; + sGroup = QT_TR_NOOP("PartDesign"); + sMenuText = QT_TR_NOOP("Create an additive primitive"); + sToolTipText = QT_TR_NOOP("Create an additive primitive"); + sWhatsThis = "Sketcher_CompPrimitiveAdditive"; + sStatusTip = sToolTipText; + eType = ForEdit; +} + +void CmdPrimtiveCompAdditive::activated(int iMsg) +{ + Base::Console().Message("activated msg %i\n", iMsg); + + PartDesign::Body *pcActiveBody = PartDesignGui::getBody(); + if (!pcActiveBody) return; + + if(iMsg == 0) { + + std::string FeatName = getUniqueObjectName("Box"); + + Gui::Command::openCommand("Make additive box"); + Gui::Command::doCommand(Gui::Command::Doc,"App.activeDocument().addObject(\'PartDesign::AdditiveBox\',\'%s\')", + FeatName.c_str()); + Gui::Command::doCommand(Doc,"App.activeDocument().%s.addObject(App.activeDocument().%s)" + ,pcActiveBody->getNameInDocument(), FeatName.c_str()); + Gui::Command::doCommand(Gui::Command::Gui, "Gui.activeDocument().setEdit(\'%s\')", FeatName.c_str()); + } +} + +Gui::Action * CmdPrimtiveCompAdditive::createAction(void) +{ + Gui::ActionGroup* pcAction = new Gui::ActionGroup(this, Gui::getMainWindow()); + pcAction->setDropDownMenu(true); + applyCommandData(this->className(), pcAction); + + QAction* p1 = pcAction->addAction(QString()); + p1->setIcon(Gui::BitmapFactory().pixmap("Part_Box")); + QAction* p2 = pcAction->addAction(QString()); + p2->setIcon(Gui::BitmapFactory().pixmap("Part_Cylinder")); + + _pcAction = pcAction; + languageChange(); + + pcAction->setIcon(p1->icon()); + int defaultId = 0; + pcAction->setProperty("defaultAction", QVariant(defaultId)); + + return pcAction; +} + +void CmdPrimtiveCompAdditive::languageChange() +{ + Command::languageChange(); + + if (!_pcAction) + return; + Gui::ActionGroup* pcAction = qobject_cast(_pcAction); + QList a = pcAction->actions(); + + QAction* arc1 = a[0]; + arc1->setText(QApplication::translate("CmdSketcherCompCreateArc","Center and end points")); + arc1->setToolTip(QApplication::translate("Sketcher_CreateArc","Create an arc by its center and by its end points")); + arc1->setStatusTip(QApplication::translate("Sketcher_CreateArc","Create an arc by its center and by its end points")); + QAction* arc2 = a[1]; + arc2->setText(QApplication::translate("CmdSketcherCompCreateArc","End points and rim point")); + arc2->setToolTip(QApplication::translate("Sketcher_Create3PointArc","Create an arc by its end points and a point along the arc")); + arc2->setStatusTip(QApplication::translate("Sketcher_Create3PointArc","Create an arc by its end points and a point along the arc")); +} + +bool CmdPrimtiveCompAdditive::isActive(void) +{ + if (getActiveGuiDocument()) + return true; + else + return false; +} + +DEF_STD_CMD_ACL(CmdPrimtiveCompSubtractive); + +CmdPrimtiveCompSubtractive::CmdPrimtiveCompSubtractive() + : Command("PartDesign_CompPrimitiveSubtractive") +{ + sAppModule = "PartDesign"; + sGroup = QT_TR_NOOP("PartDesign"); + sMenuText = QT_TR_NOOP("Create an subtractive primitive"); + sToolTipText = QT_TR_NOOP("Create an subtractive primitive"); + sWhatsThis = "PartDesign_CompPrimitiveSubtractive"; + sStatusTip = sToolTipText; + eType = ForEdit; +} + +void CmdPrimtiveCompSubtractive::activated(int iMsg) +{ + Base::Console().Message("activated msg %i\n", iMsg); + return; + + // Since the default icon is reset when enabing/disabling the command we have + // to explicitly set the icon of the used command. + Gui::ActionGroup* pcAction = qobject_cast(_pcAction); + QList a = pcAction->actions(); + + assert(iMsg < a.size()); + pcAction->setIcon(a[iMsg]->icon()); +} + +Gui::Action * CmdPrimtiveCompSubtractive::createAction(void) +{ + Gui::ActionGroup* pcAction = new Gui::ActionGroup(this, Gui::getMainWindow()); + pcAction->setDropDownMenu(true); + applyCommandData(this->className(), pcAction); + + QAction* p1 = pcAction->addAction(QString()); + p1->setIcon(Gui::BitmapFactory().pixmap("Part_Box")); + QAction* p2 = pcAction->addAction(QString()); + p2->setIcon(Gui::BitmapFactory().pixmap("Part_Cylinder")); + + _pcAction = pcAction; + languageChange(); + + pcAction->setIcon(p1->icon()); + int defaultId = 0; + pcAction->setProperty("defaultAction", QVariant(defaultId)); + + return pcAction; +} + +void CmdPrimtiveCompSubtractive::languageChange() +{ + Command::languageChange(); + + if (!_pcAction) + return; + Gui::ActionGroup* pcAction = qobject_cast(_pcAction); + QList a = pcAction->actions(); + + QAction* arc1 = a[0]; + arc1->setText(QApplication::translate("CmdSketcherCompCreateArc","Center and end points")); + arc1->setToolTip(QApplication::translate("Sketcher_CreateArc","Create an arc by its center and by its end points")); + arc1->setStatusTip(QApplication::translate("Sketcher_CreateArc","Create an arc by its center and by its end points")); + QAction* arc2 = a[1]; + arc2->setText(QApplication::translate("CmdSketcherCompCreateArc","End points and rim point")); + arc2->setToolTip(QApplication::translate("Sketcher_Create3PointArc","Create an arc by its end points and a point along the arc")); + arc2->setStatusTip(QApplication::translate("Sketcher_Create3PointArc","Create an arc by its end points and a point along the arc")); +} + +bool CmdPrimtiveCompSubtractive::isActive(void) +{ + if (getActiveGuiDocument()) + return true; + else + return false; +} + +//=========================================================================== +// Initialization +//=========================================================================== + +void CreatePartDesignPrimitiveCommands(void) +{ + Gui::CommandManager &rcCmdMgr = Gui::Application::Instance->commandManager(); + + rcCmdMgr.addCommand(new CmdPrimtiveCompAdditive); + rcCmdMgr.addCommand(new CmdPrimtiveCompSubtractive); + } \ No newline at end of file diff --git a/src/Mod/PartDesign/Gui/ViewProviderPrimitive.cpp b/src/Mod/PartDesign/Gui/ViewProviderPrimitive.cpp new file mode 100644 index 000000000..813118190 --- /dev/null +++ b/src/Mod/PartDesign/Gui/ViewProviderPrimitive.cpp @@ -0,0 +1,93 @@ +/*************************************************************************** + * Copyright (c) 2013 Jan Rheinländer * + * * + * 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 +#endif + +#include "ViewProviderPrimitive.h" +#include +#include +#include +#include +#include + + +using namespace PartDesignGui; + +PROPERTY_SOURCE(PartDesignGui::ViewProviderPrimitive,PartDesignGui::ViewProvider) + +ViewProviderPrimitive::ViewProviderPrimitive() +{ + sPixmap = "Part_Box.svg"; +} + +ViewProviderPrimitive::~ViewProviderPrimitive() +{ +} + +bool ViewProviderPrimitive::setEdit(int ModNum) +{/* + if (ModNum == ViewProvider::Default ) { + // When double-clicking on the item for this fillet the + // object unsets and sets its edit mode without closing + // the task panel + Gui::TaskView::TaskDialog *dlg = Gui::Control().activeDialog(); + TaskDlgBooleanParameters *booleanDlg = qobject_cast(dlg); + if (booleanDlg && booleanDlg->getBooleanView() != this) + booleanDlg = 0; // another pad left open its task panel + if (dlg && !booleanDlg) { + QMessageBox msgBox; + msgBox.setText(QObject::tr("A dialog is already open in the task panel")); + msgBox.setInformativeText(QObject::tr("Do you want to close this dialog?")); + msgBox.setStandardButtons(QMessageBox::Yes | QMessageBox::No); + msgBox.setDefaultButton(QMessageBox::Yes); + int ret = msgBox.exec(); + if (ret == QMessageBox::Yes) + Gui::Control().closeDialog(); + else + return false; + } + + // clear the selection (convenience) + Gui::Selection().clearSelection(); + + // always change to PartDesign WB, remember where we come from + oldWb = Gui::Command::assureWorkbench("PartDesignWorkbench"); + + // start the edit dialog + if (booleanDlg) + Gui::Control().showDialog(booleanDlg); + else + Gui::Control().showDialog(new TaskDlgBooleanParameters(this)); + + return true; + } + else { + return PartGui::ViewProviderPart::setEdit(ModNum); + }*/ +} + + diff --git a/src/Mod/PartDesign/Gui/ViewProviderPrimitive.h b/src/Mod/PartDesign/Gui/ViewProviderPrimitive.h new file mode 100644 index 000000000..dbe54c821 --- /dev/null +++ b/src/Mod/PartDesign/Gui/ViewProviderPrimitive.h @@ -0,0 +1,49 @@ +/*************************************************************************** + * Copyright (c) 2015 Stefan Tröger * + * * + * 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 PARTGUI_ViewProviderPrimitive_H +#define PARTGUI_ViewProviderPrimitive_H + +#include "ViewProvider.h" + + +namespace PartDesignGui { + +class PartDesignGuiExport ViewProviderPrimitive : public ViewProvider +{ + PROPERTY_HEADER(PartDesignGui::ViewProviderPrimitive); + +public: + /// constructor + ViewProviderPrimitive(); + /// destructor + virtual ~ViewProviderPrimitive(); + +protected: + virtual bool setEdit(int ModNum); +}; + +} // namespace PartDesignGui + + +#endif // PARTGUI_ViewProviderBoolean_H diff --git a/src/Mod/PartDesign/Gui/Workbench.cpp b/src/Mod/PartDesign/Gui/Workbench.cpp index 5c059a4a7..0fb9b3750 100644 --- a/src/Mod/PartDesign/Gui/Workbench.cpp +++ b/src/Mod/PartDesign/Gui/Workbench.cpp @@ -746,6 +746,8 @@ Gui::ToolBarItem* Workbench::setupToolBars() const << "PartDesign_Pocket" << "PartDesign_Revolution" << "PartDesign_Groove" + << "PartDesign_CompPrimitiveAdditive" + << "PartDesign_CompPrimitiveSubtractive" << "PartDesign_Fillet" << "PartDesign_Chamfer" << "PartDesign_Draft"