diff --git a/src/Mod/PartDesign/App/AppPartDesign.cpp b/src/Mod/PartDesign/App/AppPartDesign.cpp index 89e9573aa..4ff77b6f3 100644 --- a/src/Mod/PartDesign/App/AppPartDesign.cpp +++ b/src/Mod/PartDesign/App/AppPartDesign.cpp @@ -54,6 +54,7 @@ #include "FeaturePrimitive.h" #include "DatumCS.h" #include "FeatureThickness.h" +#include "FeaturePipe.h" namespace PartDesign { extern PyObject* initModule(); @@ -101,6 +102,9 @@ PyMODINIT_FUNC init_PartDesign() PartDesign::Chamfer ::init(); PartDesign::Draft ::init(); PartDesign::Thickness ::init(); + PartDesign::Pipe ::init(); + PartDesign::AdditivePipe ::init(); + PartDesign::SubtractivePipe ::init(); PartDesign::Plane ::init(); PartDesign::Line ::init(); PartDesign::Point ::init(); diff --git a/src/Mod/PartDesign/App/CMakeLists.txt b/src/Mod/PartDesign/App/CMakeLists.txt index af9d0efa3..f06ee84d1 100644 --- a/src/Mod/PartDesign/App/CMakeLists.txt +++ b/src/Mod/PartDesign/App/CMakeLists.txt @@ -100,6 +100,8 @@ SET(FeaturesSketchBased_SRCS FeatureBoolean.cpp FeaturePrimitive.h FeaturePrimitive.cpp + FeaturePipe.h + FeaturePipe.cpp ) SOURCE_GROUP("SketchBasedFeatures" FILES ${FeaturesSketchBased_SRCS}) diff --git a/src/Mod/PartDesign/App/FeaturePipe.cpp b/src/Mod/PartDesign/App/FeaturePipe.cpp new file mode 100644 index 000000000..c042a85a2 --- /dev/null +++ b/src/Mod/PartDesign/App/FeaturePipe.cpp @@ -0,0 +1,104 @@ +/*************************************************************************** + * 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_ +# include +# include +# include +# include +# include +# include +# include +# include +# include +# include +# include +# include +# include +# include +# include +# include +# include +# include +#endif + +#include +#include +#include +#include +#include + +//#include "Body.h" +#include "FeaturePipe.h" + + +using namespace PartDesign; + +const char* Pipe::TypeEnums[] = {"FullPath","UpToFace",NULL}; +const char* Pipe::TransitionEnums[] = {"Transformed","Right corner", "Round corner",NULL}; +const char* Pipe::ModeEnums[] = {"Standart", "Fixed", "Binormal", "Frenet", NULL}; + + +PROPERTY_SOURCE(PartDesign::Pipe, PartDesign::SketchBased) + +Pipe::Pipe() +{ + ADD_PROPERTY_TYPE(Sections,(0),"Sweep",App::Prop_None,"List of sections"); + Sections.setSize(0); + ADD_PROPERTY_TYPE(Spine,(0,0),"Sweep",App::Prop_None,"Path to sweep along"); + ADD_PROPERTY_TYPE(Mode,(long(1)),"Sweep",App::Prop_None,"Profile mode"); + ADD_PROPERTY_TYPE(Transition,(long(1)),"Sweep",App::Prop_None,"Transition mode"); + Transition.setEnums(TransitionEnums); +} + +short Pipe::mustExecute() const +{ + if (Sections.isTouched()) + return 1; + if (Spine.isTouched()) + return 1; + if (Mode.isTouched()) + return 1; + if (Transition.isTouched()) + return 1; + return SketchBased::mustExecute(); +} + +App::DocumentObjectExecReturn *Pipe::execute(void) +{ + + return SketchBased::execute(); +} + +PROPERTY_SOURCE(PartDesign::AdditivePipe, PartDesign::Pipe) +AdditivePipe::AdditivePipe() { + addSubType = Additive; +} + +PROPERTY_SOURCE(PartDesign::SubtractivePipe, PartDesign::Pipe) +SubtractivePipe::SubtractivePipe() { + addSubType = Subtractive; +} + + diff --git a/src/Mod/PartDesign/App/FeaturePipe.h b/src/Mod/PartDesign/App/FeaturePipe.h new file mode 100644 index 000000000..78838f79d --- /dev/null +++ b/src/Mod/PartDesign/App/FeaturePipe.h @@ -0,0 +1,76 @@ +/*************************************************************************** + * 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_Pipe_H +#define PARTDESIGN_Pipe_H + +#include +#include "FeatureSketchBased.h" + +namespace PartDesign +{ + +class PartDesignExport Pipe : public SketchBased +{ + PROPERTY_HEADER(PartDesign::Pad); + +public: + Pipe(); + + App::PropertyLinkList Sections; + App::PropertyLinkSubList Spine; + App::PropertyEnumeration Mode; + App::PropertyEnumeration Transition; + + App::DocumentObjectExecReturn *execute(void); + short mustExecute() const; + /// returns the type name of the view provider + const char* getViewProviderName(void) const { + return "PartDesignGui::ViewProviderPipe"; + } + //@} + +private: + static const char* TypeEnums[]; + static const char* TransitionEnums[]; + static const char* ModeEnums[]; +}; + +class PartDesignExport AdditivePipe : public Pipe { + + PROPERTY_HEADER(PartDesign::AdditivePipe); +public: + AdditivePipe(); +}; + +class PartDesignExport SubtractivePipe : public Pipe { + + PROPERTY_HEADER(PartDesign::SubtractivePipe); +public: + SubtractivePipe(); +}; + +} //namespace PartDesign + + +#endif // PART_Pad_H diff --git a/src/Mod/PartDesign/Gui/AppPartDesignGui.cpp b/src/Mod/PartDesign/Gui/AppPartDesignGui.cpp index 29ef11657..ad11d88bf 100644 --- a/src/Mod/PartDesign/Gui/AppPartDesignGui.cpp +++ b/src/Mod/PartDesign/Gui/AppPartDesignGui.cpp @@ -57,6 +57,7 @@ #include "ViewProviderPrimitive.h" #include "ViewProviderDatumCS.h" #include "ViewProviderThickness.h" +#include "ViewProviderPipe.h" // use a different name to CreateCommand() void CreatePartDesignCommands(void); @@ -140,6 +141,7 @@ PyMODINIT_FUNC initPartDesignGui() PartDesignGui::ViewProviderDatumCoordinateSystem::init(); PartDesignGui::ViewProviderBoolean ::init(); PartDesignGui::ViewProviderPrimitive ::init(); + PartDesignGui::ViewProviderPipe ::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 dae533040..f72578060 100644 --- a/src/Mod/PartDesign/Gui/CMakeLists.txt +++ b/src/Mod/PartDesign/Gui/CMakeLists.txt @@ -50,6 +50,7 @@ set(PartDesignGui_MOC_HDRS TaskDatumParameters.h TaskBooleanParameters.h TaskPrimitiveParameters.h + TaskPipeParameters.h ) fc_wrap_cpp(PartDesignGui_MOC_SRCS ${PartDesignGui_MOC_HDRS}) SOURCE_GROUP("Moc" FILES ${PartDesignGui_MOC_SRCS}) @@ -76,6 +77,7 @@ set(PartDesignGui_UIC_SRCS TaskMultiTransformParameters.ui TaskDatumParameters.ui TaskPrimitiveParameters.ui + TaskPipeParameters.ui ) qt4_wrap_ui(PartDesignGui_UIC_HDRS ${PartDesignGui_UIC_SRCS}) @@ -130,6 +132,8 @@ SET(PartDesignGuiViewProvider_SRCS CommandPrimitive.cpp ViewProviderBoolean.h ViewProviderPrimitive.h ViewProviderPrimitive.cpp + ViewProviderPipe.h + ViewProviderPipe.cpp ) SOURCE_GROUP("ViewProvider" FILES ${PartDesignGuiViewProvider_SRCS}) @@ -198,6 +202,9 @@ SET(PartDesignGuiTaskDlgs_SRCS TaskBooleanParameters.h TaskPrimitiveParameters.h TaskPrimitiveParameters.cpp + TaskPipeParameters.ui + TaskPipeParameters.h + TaskPipeParameters.cpp ) SOURCE_GROUP("TaskDialogs" FILES ${PartDesignGuiTaskDlgs_SRCS}) diff --git a/src/Mod/PartDesign/Gui/Command.cpp b/src/Mod/PartDesign/Gui/Command.cpp index d70ab8853..7420c2a58 100644 --- a/src/Mod/PartDesign/Gui/Command.cpp +++ b/src/Mod/PartDesign/Gui/Command.cpp @@ -1284,6 +1284,101 @@ bool CmdPartDesignGroove::isActive(void) return hasActiveDocument(); } +//=========================================================================== +// PartDesign_Additive_Pipe +//=========================================================================== +DEF_STD_CMD_A(CmdPartDesignAdditivePipe); + +CmdPartDesignAdditivePipe::CmdPartDesignAdditivePipe() + : Command("PartDesign_AdditivePipe") +{ + sAppModule = "PartDesign"; + sGroup = QT_TR_NOOP("PartDesign"); + sMenuText = QT_TR_NOOP("Additive pipe"); + sToolTipText = QT_TR_NOOP("Sweep a selected sketch along a path or to other profiles"); + sWhatsThis = "PartDesign_Additive_Pipe"; + sStatusTip = sToolTipText; + sPixmap = "PartDesign_Additive_Pipe"; +} + +void CmdPartDesignAdditivePipe::activated(int iMsg) +{ + Gui::Command* cmd = this; + auto worker = [cmd](Part::Part2DObject* sketch, std::string FeatName) { + + if (FeatName.empty()) return; + + // specific parameters for Pad + //Gui::Command::doCommand(Doc,"App.activeDocument().%s.Length = 10.0",FeatName.c_str()); + App::DocumentObjectGroup* grp = sketch->getGroup(); + if (grp) { + Gui::Command::doCommand(Doc,"App.activeDocument().%s.addObject(App.activeDocument().%s)" + ,grp->getNameInDocument(),FeatName.c_str()); + Gui::Command::doCommand(Doc,"App.activeDocument().%s.removeObject(App.activeDocument().%s)" + ,grp->getNameInDocument(),sketch->getNameInDocument()); + } + Gui::Command::updateActive(); + + finishSketchBased(cmd, sketch, FeatName); + //adjustCameraPosition(); + }; + + prepareSketchBased(this, "AdditivePipe", worker); +} + +bool CmdPartDesignAdditivePipe::isActive(void) +{ + return hasActiveDocument(); +} + + +//=========================================================================== +// PartDesign_Subtractive_Pipe +//=========================================================================== +DEF_STD_CMD_A(CmdPartDesignSubtractivePipe); + +CmdPartDesignSubtractivePipe::CmdPartDesignSubtractivePipe() + : Command("PartDesign_SubtractivePipe") +{ + sAppModule = "PartDesign"; + sGroup = QT_TR_NOOP("PartDesign"); + sMenuText = QT_TR_NOOP("Subtractive pipe"); + sToolTipText = QT_TR_NOOP("Sweep a selected sketch along a path or to other profiles and remove it from the body"); + sWhatsThis = "PartDesign_Subtractive_Pipe"; + sStatusTip = sToolTipText; + sPixmap = "PartDesign_Subtractive_Pipe"; +} + +void CmdPartDesignSubtractivePipe::activated(int iMsg) +{ + Gui::Command* cmd = this; + auto worker = [cmd](Part::Part2DObject* sketch, std::string FeatName) { + + if (FeatName.empty()) return; + + // specific parameters for Pad + //Gui::Command::doCommand(Doc,"App.activeDocument().%s.Length = 10.0",FeatName.c_str()); + App::DocumentObjectGroup* grp = sketch->getGroup(); + if (grp) { + Gui::Command::doCommand(Doc,"App.activeDocument().%s.addObject(App.activeDocument().%s)" + ,grp->getNameInDocument(),FeatName.c_str()); + Gui::Command::doCommand(Doc,"App.activeDocument().%s.removeObject(App.activeDocument().%s)" + ,grp->getNameInDocument(),sketch->getNameInDocument()); + } + Gui::Command::updateActive(); + + finishSketchBased(cmd, sketch, FeatName); + //adjustCameraPosition(); + }; + + prepareSketchBased(this, "SubtractivePipe", worker); +} + +bool CmdPartDesignSubtractivePipe::isActive(void) +{ + return hasActiveDocument(); +} + //=========================================================================== // Common utility functions for Dressup features //=========================================================================== @@ -2091,4 +2186,6 @@ void CreatePartDesignCommands(void) rcCmdMgr.addCommand(new CmdPartDesignMultiTransform()); rcCmdMgr.addCommand(new CmdPartDesignBoolean()); + rcCmdMgr.addCommand(new CmdPartDesignAdditivePipe); + rcCmdMgr.addCommand(new CmdPartDesignSubtractivePipe); } diff --git a/src/Mod/PartDesign/Gui/Resources/PartDesign.qrc b/src/Mod/PartDesign/Gui/Resources/PartDesign.qrc index 31d824b76..8cfa14e2d 100644 --- a/src/Mod/PartDesign/Gui/Resources/PartDesign.qrc +++ b/src/Mod/PartDesign/Gui/Resources/PartDesign.qrc @@ -26,8 +26,9 @@ icons/PartDesign_InternalExternalGear.svg icons/PartDesign_InvoluteGear.svg icons/PartDesignWorkbench.svg - icons/PartDesign_Body_Create_New.svg + icons/PartDesign_Body_Create_New.svg icons/PartDesign_Body_Tree.svg + icons/PartDesign_Additive_Pipe.svg icons/PartDesign_Additive_Box.svg icons/PartDesign_Additive_Cylinder.svg icons/PartDesign_Additive_Sphere.svg diff --git a/src/Mod/PartDesign/Gui/Resources/PartDesign.qrc.orig b/src/Mod/PartDesign/Gui/Resources/PartDesign.qrc.orig index 7711ca2ac..24fa4ae18 100644 --- a/src/Mod/PartDesign/Gui/Resources/PartDesign.qrc.orig +++ b/src/Mod/PartDesign/Gui/Resources/PartDesign.qrc.orig @@ -3,6 +3,7 @@ icons/PartDesign_Chamfer.svg icons/PartDesign_Fillet.svg icons/PartDesign_Draft.svg + icons/PartDesign_Thickness.svg icons/PartDesign_Groove.svg icons/PartDesign_Pad.svg icons/PartDesign_Pocket.svg @@ -18,16 +19,36 @@ icons/PartDesign_Plane.svg icons/PartDesign_Line.svg icons/PartDesign_Point.svg + icons/PartDesign_CoordinateSystem.svg + icons/PartDesign_MoveTip.svg icons/Tree_PartDesign_Pad.svg icons/Tree_PartDesign_Revolution.svg icons/PartDesign_InternalExternalGear.svg icons/PartDesign_InvoluteGear.svg -<<<<<<< bca167ff77a62818ebcd8c2d7030915aa2c9d282 +<<<<<<< a6cae97ea944460d610fe5b54eee2890a927dc00 icons/PartDesignWorkbench.svg -======= icons/PartDesign_Body_Create_New.svg +======= + icons/PartDesign_Body_Create_New.svg +>>>>>>> add basic part design pipe infrastructure icons/PartDesign_Body_Tree.svg ->>>>>>> Add new icons to Assembly work bench + icons/PartDesign_Additive_Pipe.svg + icons/PartDesign_Additive_Box.svg + icons/PartDesign_Additive_Cylinder.svg + icons/PartDesign_Additive_Sphere.svg + icons/PartDesign_Additive_Cone.svg + icons/PartDesign_Additive_Torus.svg + icons/PartDesign_Additive_Ellipsoid.svg + icons/PartDesign_Additive_Prism.svg + icons/PartDesign_Additive_Wedge.svg + icons/PartDesign_Subtractive_Box.svg + icons/PartDesign_Subtractive_Cylinder.svg + icons/PartDesign_Subtractive_Sphere.svg + icons/PartDesign_Subtractive_Cone.svg + icons/PartDesign_Subtractive_Torus.svg + icons/PartDesign_Subtractive_Ellipsoid.svg + icons/PartDesign_Subtractive_Prism.svg + icons/PartDesign_Subtractive_Wedge.svg translations/PartDesign_af.qm translations/PartDesign_de.qm translations/PartDesign_fi.qm diff --git a/src/Mod/PartDesign/Gui/Resources/icons/PartDesign_Additive_Pipe.svg b/src/Mod/PartDesign/Gui/Resources/icons/PartDesign_Additive_Pipe.svg new file mode 100644 index 000000000..c60a71ae9 --- /dev/null +++ b/src/Mod/PartDesign/Gui/Resources/icons/PartDesign_Additive_Pipe.svg @@ -0,0 +1,256 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + image/svg+xml + + + + + + + + + + + + + + diff --git a/src/Mod/PartDesign/Gui/TaskPipeParameters.cpp b/src/Mod/PartDesign/Gui/TaskPipeParameters.cpp new file mode 100644 index 000000000..6125138f3 --- /dev/null +++ b/src/Mod/PartDesign/Gui/TaskPipeParameters.cpp @@ -0,0 +1,391 @@ +/*************************************************************************** + * 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_ +# include +# include +# include +# include +# include +#endif + +#include "ui_TaskPipeParameters.h" +#include "TaskPipeParameters.h" +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include "TaskSketchBasedParameters.h" +#include "ReferenceSelection.h" +#include "Workbench.h" + +using namespace PartDesignGui; +using namespace Gui; + +/* TRANSLATOR PartDesignGui::TaskPipeParameters */ + +TaskPipeParameters::TaskPipeParameters(ViewProviderPipe *PipeView,bool newObj, QWidget *parent) + : TaskSketchBasedParameters(PipeView, parent, "PartDesign_Pipe",tr("Pipe parameters")) +{ + // we need a separate container widget to add all controls to + proxy = new QWidget(this); + ui = new Ui_TaskPipeParameters(); + ui->setupUi(proxy); + QMetaObject::connectSlotsByName(this); +/* + connect(ui->lengthEdit, SIGNAL(valueChanged(double)), + this, SLOT(onLengthChanged(double))); + connect(ui->checkBoxMidplane, SIGNAL(toggled(bool)), + this, SLOT(onMidplane(bool))); + connect(ui->checkBoxReversed, SIGNAL(toggled(bool)), + this, SLOT(onReversed(bool))); + connect(ui->lengthEdit2, SIGNAL(valueChanged(double)), + this, SLOT(onLength2Changed(double))); + connect(ui->spinOffset, SIGNAL(valueChanged(double)), + this, SLOT(onOffsetChanged(double))); + connect(ui->changeMode, SIGNAL(currentIndexChanged(int)), + this, SLOT(onModeChanged(int))); + connect(ui->buttonFace, SIGNAL(clicked()), + this, SLOT(onButtonFace())); + connect(ui->lineFaceName, SIGNAL(textEdited(QString)), + this, SLOT(onFaceName(QString))); + connect(ui->checkBoxUpdateView, SIGNAL(toggled(bool)), + this, SLOT(onUpdateView(bool))); +*/ + this->groupLayout()->addWidget(proxy); +/* + // Temporarily prevent unnecessary feature recomputes + ui->lengthEdit->blockSignals(true); + ui->lengthEdit2->blockSignals(true); + ui->checkBoxMidplane->blockSignals(true); + ui->checkBoxReversed->blockSignals(true); + ui->buttonFace->blockSignals(true); + ui->lineFaceName->blockSignals(true); + ui->changeMode->blockSignals(true); + + // set the history path + ui->lengthEdit->setParamGrpPath(QByteArray("User parameter:BaseApp/History/PipeLength")); + ui->lengthEdit2->setParamGrpPath(QByteArray("User parameter:BaseApp/History/PipeLength2")); + + // Get the feature data + PartDesign::Pipe* pcPipe = static_cast(PipeView->getObject()); + Base::Quantity l = pcPipe->Length.getQuantityValue(); + bool midplane = pcPipe->Midplane.getValue(); + bool reversed = pcPipe->Reversed.getValue(); + Base::Quantity l2 = pcPipe->Length2.getQuantityValue(); + int index = pcPipe->Type.getValue(); // must extract value here, clear() kills it! + App::DocumentObject* obj = pcPipe->UpToFace.getValue(); + std::vector subStrings = pcPipe->UpToFace.getSubValues(); + std::string upToFace; + int faceId = -1; + if ((obj != NULL) && !subStrings.empty()) { + upToFace = subStrings.front(); + if (upToFace.substr(0,4) == "Face") + faceId = std::atoi(&upToFace[4]); + } + + // Fill data into dialog elements + ui->lengthEdit->setMinimum(0); + ui->lengthEdit->setMaximum(INT_MAX); + ui->lengthEdit->setValue(l); + ui->lengthEdit2->setMinimum(0); + ui->lengthEdit2->setMaximum(INT_MAX); + ui->lengthEdit2->setValue(l2); + + + ui->checkBoxMidplane->setChecked(midplane); + // According to bug #0000521 the reversed option + // shouldn't be de-activated if the pad has a support face + ui->checkBoxReversed->setChecked(reversed); + if ((obj != NULL) && PartDesign::Feature::isDatum(obj)) + ui->lineFaceName->setText(QString::fromAscii(obj->getNameInDocument())); + else if (faceId >= 0) + ui->lineFaceName->setText(QString::fromAscii(obj->getNameInDocument()) + QString::fromAscii(":") + tr("Face") + + QString::number(faceId)); + else + ui->lineFaceName->setText(tr("No face selected")); + ui->lineFaceName->setProperty("FaceName", QByteArray(upToFace.c_str())); + ui->changeMode->clear(); + ui->changeMode->insertItem(0, tr("Dimension")); + ui->changeMode->insertItem(1, tr("To last")); + ui->changeMode->insertItem(2, tr("To first")); + ui->changeMode->insertItem(3, tr("Up to face")); + ui->changeMode->insertItem(4, tr("Two dimensions")); + ui->changeMode->setCurrentIndex(index); + + // activate and de-activate dialog elements as appropriate + ui->lengthEdit->blockSignals(false); + ui->lengthEdit2->blockSignals(false); + ui->checkBoxMidplane->blockSignals(false); + ui->checkBoxReversed->blockSignals(false); + ui->buttonFace->blockSignals(false); + ui->lineFaceName->blockSignals(false); + ui->changeMode->blockSignals(false); + updateUI(index); + + // if it is a newly created object use the last value of the history + if(newObj){ + ui->lengthEdit->setToLastUsedValue(); + ui->lengthEdit->selectNumber(); + ui->lengthEdit2->setToLastUsedValue(); + ui->lengthEdit2->selectNumber(); + }*/ +} + +void TaskPipeParameters::updateUI(int index) +{/* + if (index == 0) { // dimension + ui->labelLength->setVisible(true); + ui->spinOffset->setVisible(false); + ui->spinOffset->setEnabled(false); + ui->labelOffset->setVisible(false); + ui->lengthEdit->setEnabled(true); + ui->lengthEdit->selectNumber(); + // Make sure that the spin box has the focus to get key events + // Calling setFocus() directly doesn't work because the spin box is not + // yet visible. + QMetaObject::invokeMethod(ui->lengthEdit, "setFocus", Qt::QueuedConnection); + ui->checkBoxMidplane->setEnabled(true); + // Reverse only makes sense if Midplane is not true + ui->checkBoxReversed->setEnabled(!ui->checkBoxMidplane->isChecked()); + ui->lengthEdit2->setEnabled(false); + ui->buttonFace->setEnabled(false); + ui->lineFaceName->setEnabled(false); + onButtonFace(false); + } else if (index == 1 || index == 2) { // up to first/last + ui->labelLength->setVisible(false); + ui->spinOffset->setVisible(true); + ui->spinOffset->setEnabled(true); + ui->labelOffset->setVisible(true); + ui->lengthEdit->setEnabled(false); + ui->checkBoxMidplane->setEnabled(false); + ui->checkBoxReversed->setEnabled(true); + ui->lengthEdit2->setEnabled(false); + ui->buttonFace->setEnabled(false); + ui->lineFaceName->setEnabled(false); + onButtonFace(false); + } else if (index == 3) { // up to face + ui->labelLength->setVisible(false); + ui->spinOffset->setVisible(true); + ui->spinOffset->setEnabled(true); + ui->labelOffset->setVisible(true); + ui->lengthEdit->setEnabled(false); + ui->checkBoxMidplane->setEnabled(false); + ui->checkBoxReversed->setEnabled(false); + ui->lengthEdit2->setEnabled(false); + ui->buttonFace->setEnabled(true); + ui->lineFaceName->setEnabled(true); + QMetaObject::invokeMethod(ui->lineFaceName, "setFocus", Qt::QueuedConnection); + // Go into reference selection mode if no face has been selected yet + if (ui->lineFaceName->text().isEmpty() || (ui->lineFaceName->text() == tr("No face selected"))) + onButtonFace(true); + } else { // two dimensions + ui->labelLength->setVisible(true); + ui->spinOffset->setVisible(false); + ui->spinOffset->setEnabled(false); + ui->labelOffset->setVisible(false); + ui->lengthEdit->setEnabled(true); + ui->lengthEdit->selectNumber(); + QMetaObject::invokeMethod(ui->lengthEdit, "setFocus", Qt::QueuedConnection); + ui->checkBoxMidplane->setEnabled(false); + ui->checkBoxReversed->setEnabled(false); + ui->lengthEdit2->setEnabled(true); + ui->buttonFace->setEnabled(false); + ui->lineFaceName->setEnabled(false); + onButtonFace(false); + }*/ +} + +void TaskPipeParameters::onSelectionChanged(const Gui::SelectionChanges& msg) +{/* + if (msg.Type == Gui::SelectionChanges::AddSelection) { + 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); + } else { + ui->lineFaceName->blockSignals(true); + ui->lineFaceName->setText(tr("No face selected")); + ui->lineFaceName->setProperty("FaceName", QByteArray()); + ui->lineFaceName->blockSignals(false); + } + } + + else if (msg.Type == Gui::SelectionChanges::ClrSelection) { + ui->lineFaceName->blockSignals(true); + ui->lineFaceName->setText(tr("")); + ui->lineFaceName->setProperty("FaceName", QByteArray()); + ui->lineFaceName->blockSignals(false); + }*/ +} + +TaskPipeParameters::~TaskPipeParameters() +{ + delete ui; +} + +void TaskPipeParameters::changeEvent(QEvent *e) +{/* + TaskBox::changeEvent(e); + if (e->type() == QEvent::LanguageChange) { + ui->spinOffset->blockSignals(true); + ui->lengthEdit->blockSignals(true); + ui->lengthEdit2->blockSignals(true); + ui->lineFaceName->blockSignals(true); + ui->changeMode->blockSignals(true); + int index = ui->changeMode->currentIndex(); + ui->retranslateUi(proxy); + ui->changeMode->clear(); + ui->changeMode->addItem(tr("Dimension")); + ui->changeMode->addItem(tr("To last")); + ui->changeMode->addItem(tr("To first")); + ui->changeMode->addItem(tr("Up to face")); + ui->changeMode->addItem(tr("Two dimensions")); + ui->changeMode->setCurrentIndex(index); + + QStringList parts = ui->lineFaceName->text().split(QChar::fromAscii(':')); + QByteArray upToFace = ui->lineFaceName->property("FaceName").toByteArray(); + int faceId = -1; + bool ok = false; + if (upToFace.indexOf("Face") == 0) { + faceId = upToFace.remove(0,4).toInt(&ok); + } +#if QT_VERSION >= 0x040700 + ui->lineFaceName->setPlaceholderText(tr("No face selected")); +#endif + ui->lineFaceName->setText(ok ? + parts[0] + QString::fromAscii(":") + tr("Face") + QString::number(faceId) : + tr("No face selected")); + ui->spinOffset->blockSignals(false); + ui->lengthEdit->blockSignals(false); + ui->lengthEdit2->blockSignals(false); + ui->lineFaceName->blockSignals(false); + ui->changeMode->blockSignals(false); + }*/ +} + + +//************************************************************************** +//************************************************************************** +// TaskDialog +//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ + +TaskDlgPipeParameters::TaskDlgPipeParameters(ViewProviderPipe *PipeView,bool newObj) + : TaskDlgSketchBasedParameters(PipeView) +{ + assert(PipeView); + parameter = new TaskPipeParameters(PipeView,newObj); + + Content.push_back(parameter); +} + +TaskDlgPipeParameters::~TaskDlgPipeParameters() +{ + +} + +//==== calls from the TaskView =============================================================== + + +bool TaskDlgPipeParameters::accept() +{/* + std::string name = vp->getObject()->getNameInDocument(); + + // save the history + parameter->saveHistory(); + + try { + //Gui::Command::openCommand("Pipe changed"); + Gui::Command::doCommand(Gui::Command::Doc,"App.ActiveDocument.%s.Length = %f",name.c_str(),parameter->getLength()); + Gui::Command::doCommand(Gui::Command::Doc,"App.ActiveDocument.%s.Reversed = %i",name.c_str(),parameter->getReversed()?1:0); + Gui::Command::doCommand(Gui::Command::Doc,"App.ActiveDocument.%s.Midplane = %i",name.c_str(),parameter->getMidplane()?1:0); + Gui::Command::doCommand(Gui::Command::Doc,"App.ActiveDocument.%s.Length2 = %f",name.c_str(),parameter->getLength2()); + Gui::Command::doCommand(Gui::Command::Doc,"App.ActiveDocument.%s.Offset = %f",name.c_str(),parameter->getOffset()); + Gui::Command::doCommand(Gui::Command::Doc,"App.ActiveDocument.%s.Type = %u",name.c_str(),parameter->getMode()); + std::string facename = (const char*)parameter->getFaceName(); + + if (!facename.empty()) { + Gui::Command::doCommand(Gui::Command::Doc,"App.ActiveDocument.%s.UpToFace = %s", name.c_str(), facename.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.recompute()"); + if (!vp->getObject()->isValid()) + throw Base::Exception(vp->getObject()->getStatusString()); + Gui::Command::doCommand(Gui::Command::Gui,"Gui.activeDocument().resetEdit()"); + Gui::Command::commitCommand(); + } + catch (const Base::Exception& e) { + QMessageBox::warning(parameter, tr("Input error"), QString::fromAscii(e.what())); + return false; + } + + return true;*/ +} + +//bool TaskDlgPipeParameters::reject() +//{ +// // get the support and Sketch +// PartDesign::Pipe* pcPipe = static_cast(PipeView->getObject()); +// Sketcher::SketchObject *pcSketch = 0; +// App::DocumentObject *pcSupport = 0; +// if (pcPipe->Sketch.getValue()) { +// pcSketch = static_cast(pcPipe->Sketch.getValue()); +// pcSupport = pcSketch->Support.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 support is visible again +// if (!Gui::Application::Instance->getViewProvider(pcPipe)) { +// if (pcSketch && Gui::Application::Instance->getViewProvider(pcSketch)) +// Gui::Application::Instance->getViewProvider(pcSketch)->show(); +// if (pcSupport && Gui::Application::Instance->getViewProvider(pcSupport)) +// Gui::Application::Instance->getViewProvider(pcSupport)->show(); +// } +// +// //Gui::Command::doCommand(Gui::Command::Doc,"App.ActiveDocument.recompute()"); +// //Gui::Command::commitCommand(); +// +// return true; +//} + + + +#include "moc_TaskPipeParameters.cpp" diff --git a/src/Mod/PartDesign/Gui/TaskPipeParameters.h b/src/Mod/PartDesign/Gui/TaskPipeParameters.h new file mode 100644 index 000000000..dbcb6ee78 --- /dev/null +++ b/src/Mod/PartDesign/Gui/TaskPipeParameters.h @@ -0,0 +1,95 @@ +/*************************************************************************** + * 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 GUI_TASKVIEW_TaskPipeParameters_H +#define GUI_TASKVIEW_TaskPipeParameters_H + +#include +#include +#include + +#include "TaskSketchBasedParameters.h" +#include "ViewProviderPipe.h" + +class Ui_TaskPipeParameters; + +namespace App { +class Property; +} + +namespace Gui { +class ViewProvider; +} + +namespace PartDesignGui { + + + +class TaskPipeParameters : public TaskSketchBasedParameters +{ + Q_OBJECT + +public: + TaskPipeParameters(ViewProviderPipe *PipeView,bool newObj=false,QWidget *parent = 0); + ~TaskPipeParameters(); + + +private Q_SLOTS: + +protected: + void changeEvent(QEvent *e); + +private: + void onSelectionChanged(const Gui::SelectionChanges& msg); + void updateUI(int index); + +private: + QWidget* proxy; + Ui_TaskPipeParameters* ui; +}; + +/// simulation dialog for the TaskView +class TaskDlgPipeParameters : public TaskDlgSketchBasedParameters +{ + Q_OBJECT + +public: + TaskDlgPipeParameters(ViewProviderPipe *PipeView,bool newObj=false); + ~TaskDlgPipeParameters(); + + ViewProviderPipe* getPipeView() const + { return static_cast(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) + +protected: + TaskPipeParameters *parameter; +}; + +} //namespace PartDesignGui + +#endif // GUI_TASKVIEW_TASKAPPERANCE_H diff --git a/src/Mod/PartDesign/Gui/TaskPipeParameters.ui b/src/Mod/PartDesign/Gui/TaskPipeParameters.ui new file mode 100644 index 000000000..bd9095f7b --- /dev/null +++ b/src/Mod/PartDesign/Gui/TaskPipeParameters.ui @@ -0,0 +1,72 @@ + + + PartDesignGui::TaskPipeParameters + + + + 0 + 0 + 257 + 305 + + + + Form + + + + + + + + Add Edge + + + true + + + + + + + Remove Edge + + + true + + + + + + + + + + + + + + Profile orientation + + + + + + + + + + Transition type + + + + + + + + + + + + + diff --git a/src/Mod/PartDesign/Gui/ViewProviderPipe.cpp b/src/Mod/PartDesign/Gui/ViewProviderPipe.cpp new file mode 100644 index 000000000..86726aef7 --- /dev/null +++ b/src/Mod/PartDesign/Gui/ViewProviderPipe.cpp @@ -0,0 +1,135 @@ +/*************************************************************************** + * 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_ +# include +#endif + +#include "ViewProviderPipe.h" +//#include "TaskPipeParameters.h" +#include "Workbench.h" +#include "TaskPipeParameters.h" +#include +#include +#include +#include +#include +#include + +using namespace PartDesignGui; + +PROPERTY_SOURCE(PartDesignGui::ViewProviderPipe,PartDesignGui::ViewProvider) + +ViewProviderPipe::ViewProviderPipe() +{ + sPixmap = "PartDesign_Additive_Pipe.svg"; +} + +ViewProviderPipe::~ViewProviderPipe() +{ +} + +std::vector ViewProviderPipe::claimChildren(void)const +{ + std::vector temp; + App::DocumentObject* sketch = static_cast(getObject())->Sketch.getValue(); + if (sketch != NULL) + temp.push_back(sketch); + + return temp; +} + +void ViewProviderPipe::setupContextMenu(QMenu* menu, QObject* receiver, const char* member) +{/* + QAction* act; + act = menu->addAction(QObject::tr("Edit pad"), receiver, member); + act->setData(QVariant((int)ViewProvider::Default)); + PartGui::ViewProviderPart::setupContextMenu(menu, receiver, member);*/ +} + +bool ViewProviderPipe::doubleClicked(void) +{ + Gui::Command::doCommand(Gui::Command::Gui,"Gui.activeDocument().setEdit('%s',0)",this->pcObject->getNameInDocument()); + return true; +} + +bool ViewProviderPipe::setEdit(int ModNum) +{ + if (ModNum == ViewProvider::Default || ModNum == 1 ) { + // When double-clicking on the item for this pad the + // object unsets and sets its edit mode without closing + // the task panel + Gui::TaskView::TaskDialog *dlg = Gui::Control().activeDialog(); + TaskDlgPipeParameters *padDlg = qobject_cast(dlg); + if (padDlg && padDlg->getPipeView() != this) + padDlg = 0; // another pad left open its task panel + if (dlg && !padDlg) { + 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().reject(); + 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 (padDlg) + Gui::Control().showDialog(padDlg); + else + Gui::Control().showDialog(new TaskDlgPipeParameters(this,ModNum == 1)); + + return true; + } + else { + return ViewProviderPart::setEdit(ModNum); + } +} + +bool ViewProviderPipe::onDelete(const std::vector &s) +{/* + PartDesign::Pipe* pcPipe = static_cast(getObject()); + + // get the Sketch + Sketcher::SketchObject *pcSketch = 0; + if (pcPipe->Sketch.getValue()) + pcSketch = static_cast(pcPipe->Sketch.getValue()); + + // if abort command deleted the object the sketch is visible again + if (pcSketch && Gui::Application::Instance->getViewProvider(pcSketch)) + Gui::Application::Instance->getViewProvider(pcSketch)->show(); + + return ViewProvider::onDelete(s);*/ +} + diff --git a/src/Mod/PartDesign/Gui/ViewProviderPipe.h b/src/Mod/PartDesign/Gui/ViewProviderPipe.h new file mode 100644 index 000000000..b57ff37d1 --- /dev/null +++ b/src/Mod/PartDesign/Gui/ViewProviderPipe.h @@ -0,0 +1,57 @@ +/*************************************************************************** + * 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_ViewProviderPipe_H +#define PARTGUI_ViewProviderPipe_H + +#include "ViewProvider.h" + +namespace PartDesignGui { + +class PartDesignGuiExport ViewProviderPipe : public ViewProvider +{ + PROPERTY_HEADER(PartDesignGui::ViewProviderPipe); + +public: + /// constructor + ViewProviderPipe(); + /// destructor + virtual ~ViewProviderPipe(); + + /// grouping handling + std::vector claimChildren(void)const; + void setupContextMenu(QMenu*, QObject*, const char*); + bool doubleClicked(); + + virtual bool onDelete(const std::vector &); + +protected: + virtual bool setEdit(int ModNum); + +}; + + +} // namespace PartDesignGui + + +#endif // PARTGUI_ViewProviderPipe_H diff --git a/src/Mod/PartDesign/Gui/Workbench.cpp b/src/Mod/PartDesign/Gui/Workbench.cpp index b4e7b2b35..a36bb4ff1 100644 --- a/src/Mod/PartDesign/Gui/Workbench.cpp +++ b/src/Mod/PartDesign/Gui/Workbench.cpp @@ -747,6 +747,8 @@ Gui::MenuItem* Workbench::setupMenuBar() const << "PartDesign_Pocket" << "PartDesign_Revolution" << "PartDesign_Groove" + << "PartDesign_AdditivePipe" + << "PartDesign_SubtractivePipe" << "PartDesign_Fillet" << "PartDesign_Chamfer" << "PartDesign_Draft" @@ -803,6 +805,8 @@ Gui::ToolBarItem* Workbench::setupToolBars() const << "PartDesign_Pocket" << "PartDesign_Revolution" << "PartDesign_Groove" + << "PartDesign_AdditivePipe" + << "PartDesign_SubtractivePipe" << "PartDesign_Fillet" << "PartDesign_Chamfer" << "PartDesign_Draft"