Offset function

This commit is contained in:
wmayer 2012-11-24 22:46:16 +01:00
parent 96afbb2756
commit 89e5215d3b
6 changed files with 359 additions and 1 deletions

View File

@ -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

View File

@ -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());
}

View File

@ -0,0 +1,133 @@
/***************************************************************************
* Copyright (c) 2012 Werner Mayer <wmayer[at]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 <QMessageBox>
# include <QTextStream>
#endif
#include "ui_TaskOffset.h"
#include "TaskOffset.h"
#include <Gui/Application.h>
#include <Gui/BitmapFactory.h>
#include <Gui/Document.h>
#include <Gui/Selection.h>
#include <Gui/SelectionFilter.h>
#include <Gui/ViewProvider.h>
#include <Base/Console.h>
#include <Base/Interpreter.h>
#include <App/Application.h>
#include <App/Document.h>
#include <App/DocumentObject.h>
#include <Mod/Part/App/PartFeature.h>
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"

View File

@ -0,0 +1,75 @@
/***************************************************************************
* Copyright (c) 2012 Werner Mayer <wmayer[at]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 PARTGUI_TASKOFFSET_H
#define PARTGUI_TASKOFFSET_H
#include <Gui/TaskView/TaskView.h>
#include <Gui/TaskView/TaskDialog.h>
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

View File

@ -0,0 +1,115 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>PartGui::TaskOffset</class>
<widget class="QWidget" name="PartGui::TaskOffset">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>256</width>
<height>217</height>
</rect>
</property>
<property name="windowTitle">
<string>Offset</string>
</property>
<layout class="QGridLayout" name="gridLayout">
<item row="0" column="0">
<widget class="QLabel" name="labelOffset">
<property name="text">
<string>Offset</string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QDoubleSpinBox" name="spinOffset"/>
</item>
<item row="1" column="0">
<widget class="QLabel" name="label">
<property name="text">
<string>Tolerance</string>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QDoubleSpinBox" name="spinTolerance"/>
</item>
<item row="2" column="0">
<widget class="QLabel" name="label_2">
<property name="text">
<string>Mode</string>
</property>
</widget>
</item>
<item row="2" column="1">
<widget class="QComboBox" name="comboBox">
<item>
<property name="text">
<string>Skin</string>
</property>
</item>
<item>
<property name="text">
<string>Pipe</string>
</property>
</item>
<item>
<property name="text">
<string>RectoVerso</string>
</property>
</item>
</widget>
</item>
<item row="3" column="0">
<widget class="QLabel" name="label_3">
<property name="text">
<string>Join type</string>
</property>
</widget>
</item>
<item row="3" column="1">
<widget class="QComboBox" name="comboBox_2">
<item>
<property name="text">
<string>Arc</string>
</property>
</item>
<item>
<property name="text">
<string>Tangent</string>
</property>
</item>
<item>
<property name="text">
<string>Intersection</string>
</property>
</item>
</widget>
</item>
<item row="4" column="0" colspan="2">
<widget class="QCheckBox" name="checkBox">
<property name="text">
<string>Intersection</string>
</property>
</widget>
</item>
<item row="5" column="0" colspan="2">
<widget class="QCheckBox" name="checkBox_2">
<property name="text">
<string>Self-intersection</string>
</property>
</widget>
</item>
</layout>
</widget>
<tabstops>
<tabstop>spinOffset</tabstop>
<tabstop>spinTolerance</tabstop>
<tabstop>comboBox</tabstop>
<tabstop>comboBox_2</tabstop>
<tabstop>checkBox</tabstop>
<tabstop>checkBox_2</tabstop>
</tabstops>
<resources/>
<connections/>
</ui>

View File

@ -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;
}