From 89e5215d3b7379354642f8b75838ade09325ced1 Mon Sep 17 00:00:00 2001 From: wmayer Date: Sat, 24 Nov 2012 22:46:16 +0100 Subject: [PATCH] Offset function --- src/Mod/Part/Gui/CMakeLists.txt | 5 ++ src/Mod/Part/Gui/Command.cpp | 30 +++++++ src/Mod/Part/Gui/TaskOffset.cpp | 133 ++++++++++++++++++++++++++++++++ src/Mod/Part/Gui/TaskOffset.h | 75 ++++++++++++++++++ src/Mod/Part/Gui/TaskOffset.ui | 115 +++++++++++++++++++++++++++ src/Mod/Part/Gui/Workbench.cpp | 2 +- 6 files changed, 359 insertions(+), 1 deletion(-) create mode 100644 src/Mod/Part/Gui/TaskOffset.cpp create mode 100644 src/Mod/Part/Gui/TaskOffset.h create mode 100644 src/Mod/Part/Gui/TaskOffset.ui diff --git a/src/Mod/Part/Gui/CMakeLists.txt b/src/Mod/Part/Gui/CMakeLists.txt index f6a41f935..e138c13ec 100644 --- a/src/Mod/Part/Gui/CMakeLists.txt +++ b/src/Mod/Part/Gui/CMakeLists.txt @@ -41,6 +41,7 @@ set(PartGui_MOC_HDRS TaskFaceColors.h TaskShapeBuilder.h TaskLoft.h + TaskOffset.h TaskSweep.h TaskCheckGeometry.h ) @@ -67,6 +68,7 @@ set(PartGui_UIC_SRCS TaskFaceColors.ui TaskShapeBuilder.ui TaskLoft.ui + TaskOffset.ui TaskSweep.ui ) qt4_wrap_ui(PartGui_UIC_HDRS ${PartGui_UIC_SRCS}) @@ -158,6 +160,9 @@ SET(PartGui_SRCS TaskLoft.cpp TaskLoft.h TaskLoft.ui + TaskOffset.cpp + TaskOffset.h + TaskOffset.ui TaskSweep.cpp TaskSweep.h TaskSweep.ui diff --git a/src/Mod/Part/Gui/Command.cpp b/src/Mod/Part/Gui/Command.cpp index 51f84675c..d796c31c7 100644 --- a/src/Mod/Part/Gui/Command.cpp +++ b/src/Mod/Part/Gui/Command.cpp @@ -62,6 +62,7 @@ #include "TaskShapeBuilder.h" #include "TaskLoft.h" #include "TaskSweep.h" +#include "TaskOffset.h" #include "TaskCheckGeometry.h" @@ -990,6 +991,34 @@ bool CmdPartSweep::isActive(void) //-------------------------------------------------------------------------------------- +DEF_STD_CMD_A(CmdPartOffset); + +CmdPartOffset::CmdPartOffset() + : Command("Part_Offset") +{ + sAppModule = "Part"; + sGroup = QT_TR_NOOP("Part"); + sMenuText = QT_TR_NOOP("Offset..."); + sToolTipText = QT_TR_NOOP("Utility to offset"); + sWhatsThis = sToolTipText; + sStatusTip = sToolTipText; + sPixmap = "Part_Offset"; +} + +void CmdPartOffset::activated(int iMsg) +{ + Gui::Control().showDialog(new PartGui::TaskOffset()); +} + +bool CmdPartOffset::isActive(void) +{ + Base::Type partid = Base::Type::fromName("Part::Feature"); + bool objectsSelected = Gui::Selection().countObjectsOfType(partid) == 1; + return (objectsSelected && !Gui::Control().activeDialog()); +} + +//-------------------------------------------------------------------------------------- + DEF_STD_CMD_A(CmdShapeInfo); CmdShapeInfo::CmdShapeInfo() @@ -1260,5 +1289,6 @@ void CreatePartCommands(void) rcCmdMgr.addCommand(new CmdPartBuilder()); rcCmdMgr.addCommand(new CmdPartLoft()); rcCmdMgr.addCommand(new CmdPartSweep()); + rcCmdMgr.addCommand(new CmdPartOffset()); rcCmdMgr.addCommand(new CmdCheckGeometry()); } diff --git a/src/Mod/Part/Gui/TaskOffset.cpp b/src/Mod/Part/Gui/TaskOffset.cpp new file mode 100644 index 000000000..5324e17ea --- /dev/null +++ b/src/Mod/Part/Gui/TaskOffset.cpp @@ -0,0 +1,133 @@ +/*************************************************************************** + * Copyright (c) 2012 Werner Mayer * + * * + * 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 +#endif + +#include "ui_TaskOffset.h" +#include "TaskOffset.h" + +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include + + +using namespace PartGui; + +class OffsetWidget::Private +{ +public: + Ui_TaskOffset ui; + std::string document; + Private() + { + } + ~Private() + { + } +}; + +/* TRANSLATOR PartGui::OffsetWidget */ + +OffsetWidget::OffsetWidget(QWidget* parent) + : d(new Private()) +{ + Gui::Application::Instance->runPythonCode("from FreeCAD import Base"); + Gui::Application::Instance->runPythonCode("import Part"); + + d->ui.setupUi(this); +} + +OffsetWidget::~OffsetWidget() +{ + delete d; +} + +bool OffsetWidget::accept() +{ + return true; +} + +bool OffsetWidget::reject() +{ + return true; +} + +void OffsetWidget::changeEvent(QEvent *e) +{ + QWidget::changeEvent(e); + if (e->type() == QEvent::LanguageChange) { + d->ui.retranslateUi(this); + } +} + + +/* TRANSLATOR PartGui::TaskOffset */ + +TaskOffset::TaskOffset() +{ + widget = new OffsetWidget(); + taskbox = new Gui::TaskView::TaskBox( + Gui::BitmapFactory().pixmap("Part_Offset"), + widget->windowTitle(), true, 0); + taskbox->groupLayout()->addWidget(widget); + Content.push_back(taskbox); +} + +TaskOffset::~TaskOffset() +{ +} + +void TaskOffset::open() +{ +} + +void TaskOffset::clicked(int) +{ +} + +bool TaskOffset::accept() +{ + return widget->accept(); +} + +bool TaskOffset::reject() +{ + return widget->reject(); +} + +#include "moc_TaskOffset.cpp" diff --git a/src/Mod/Part/Gui/TaskOffset.h b/src/Mod/Part/Gui/TaskOffset.h new file mode 100644 index 000000000..d1dc8d47b --- /dev/null +++ b/src/Mod/Part/Gui/TaskOffset.h @@ -0,0 +1,75 @@ +/*************************************************************************** + * Copyright (c) 2012 Werner Mayer * + * * + * 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_TASKOFFSET_H +#define PARTGUI_TASKOFFSET_H + +#include +#include + +namespace PartGui { + +class OffsetWidget : public QWidget +{ + Q_OBJECT + +public: + OffsetWidget(QWidget* parent = 0); + ~OffsetWidget(); + + bool accept(); + bool reject(); + +private: + void changeEvent(QEvent *e); + +private: + class Private; + Private* d; +}; + +class TaskOffset : public Gui::TaskView::TaskDialog +{ + Q_OBJECT + +public: + TaskOffset(); + ~TaskOffset(); + +public: + void open(); + bool accept(); + bool reject(); + void clicked(int); + + QDialogButtonBox::StandardButtons getStandardButtons() const + { return QDialogButtonBox::Ok|QDialogButtonBox::Cancel; } + +private: + OffsetWidget* widget; + Gui::TaskView::TaskBox* taskbox; +}; + +} //namespace PartGui + +#endif // PARTGUI_TASKOFFSET_H diff --git a/src/Mod/Part/Gui/TaskOffset.ui b/src/Mod/Part/Gui/TaskOffset.ui new file mode 100644 index 000000000..a2a0300c6 --- /dev/null +++ b/src/Mod/Part/Gui/TaskOffset.ui @@ -0,0 +1,115 @@ + + + PartGui::TaskOffset + + + + 0 + 0 + 256 + 217 + + + + Offset + + + + + + Offset + + + + + + + + + + Tolerance + + + + + + + + + + Mode + + + + + + + + Skin + + + + + Pipe + + + + + RectoVerso + + + + + + + + Join type + + + + + + + + Arc + + + + + Tangent + + + + + Intersection + + + + + + + + Intersection + + + + + + + Self-intersection + + + + + + + spinOffset + spinTolerance + comboBox + comboBox_2 + checkBox + checkBox_2 + + + + diff --git a/src/Mod/Part/Gui/Workbench.cpp b/src/Mod/Part/Gui/Workbench.cpp index ddd441b7d..079815731 100644 --- a/src/Mod/Part/Gui/Workbench.cpp +++ b/src/Mod/Part/Gui/Workbench.cpp @@ -72,7 +72,7 @@ Gui::MenuItem* Workbench::setupMenuBar() const << "Part_SimpleCopy" << "Part_RefineShape" << "Part_CheckGeometry" << "Separator" << "Part_Boolean" << "Part_CrossSections" << "Part_Extrude" << "Part_Revolve" << "Part_Mirror" << "Part_Fillet" << "Part_Chamfer" - << "Part_RuledSurface" << "Part_Loft" << "Part_Sweep"; + << "Part_RuledSurface" << "Part_Loft" << "Part_Sweep" << "Part_Offset"; return root; }