0000286: Feature request for better Fillet/Chamfer

This commit is contained in:
unknown
2012-02-29 01:56:07 +01:00
parent 11b8b60af4
commit 0171a22a98
13 changed files with 231 additions and 44 deletions

View File

@@ -145,9 +145,10 @@ void PartExport initPart()
Part::Fuse ::init();
Part::MultiFuse ::init();
Part::Section ::init();
Part::FilletBase ::init();
Part::Fillet ::init();
Part::Chamfer ::init();
Part::Extrusion ::init();
Part::Fillet ::init();
Part::Revolution ::init();
Part::Mirroring ::init();
Part::ImportStep ::init();

View File

@@ -40,20 +40,10 @@
using namespace Part;
PROPERTY_SOURCE(Part::Chamfer, Part::Feature)
PROPERTY_SOURCE(Part::Chamfer, Part::FilletBase)
Chamfer::Chamfer()
{
ADD_PROPERTY(Base,(0));
ADD_PROPERTY(Edges,(0,0,0));
Edges.setSize(0);
}
short Chamfer::mustExecute() const
{
if (Base.isTouched() || Edges.isTouched())
return 1;
return 0;
}
App::DocumentObjectExecReturn *Chamfer::execute(void)

View File

@@ -30,21 +30,17 @@
namespace Part
{
class Chamfer : public Part::Feature
class Chamfer : public Part::FilletBase
{
PROPERTY_HEADER(Part::Chamfer);
public:
Chamfer();
App::PropertyLink Base;
PropertyFilletEdges Edges;
/** @name methods override feature */
//@{
/// recalculate the feature
App::DocumentObjectExecReturn *execute(void);
short mustExecute() const;
/// returns the type name of the view provider
const char* getViewProviderName(void) const {
return "PartGui::ViewProviderChamfer";

View File

@@ -39,20 +39,10 @@
using namespace Part;
PROPERTY_SOURCE(Part::Fillet, Part::Feature)
PROPERTY_SOURCE(Part::Fillet, Part::FilletBase)
Fillet::Fillet()
{
ADD_PROPERTY(Base,(0));
ADD_PROPERTY(Edges,(0,0,0));
Edges.setSize(0);
}
short Fillet::mustExecute() const
{
if (Base.isTouched() || Edges.isTouched())
return 1;
return 0;
}
App::DocumentObjectExecReturn *Fillet::execute(void)

View File

@@ -30,21 +30,17 @@
namespace Part
{
class Fillet : public Part::Feature
class Fillet : public Part::FilletBase
{
PROPERTY_HEADER(Part::Fillet);
public:
Fillet();
App::PropertyLink Base;
PropertyFilletEdges Edges;
/** @name methods override feature */
//@{
/// recalculate the feature
App::DocumentObjectExecReturn *execute(void);
short mustExecute() const;
/// returns the type name of the view provider
const char* getViewProviderName(void) const {
return "PartGui::ViewProviderFillet";

View File

@@ -132,6 +132,24 @@ const char* Feature::getViewProviderName(void) const {
// ---------------------------------------------------------
PROPERTY_SOURCE(Part::FilletBase, Part::Feature)
FilletBase::FilletBase()
{
ADD_PROPERTY(Base,(0));
ADD_PROPERTY(Edges,(0,0,0));
Edges.setSize(0);
}
short FilletBase::mustExecute() const
{
if (Base.isTouched() || Edges.isTouched())
return 1;
return 0;
}
// ---------------------------------------------------------
PROPERTY_SOURCE(Part::FeatureExt, Part::Feature)

View File

@@ -68,6 +68,19 @@ protected:
TopLoc_Location getLocation() const;
};
class FilletBase : public Part::Feature
{
PROPERTY_HEADER(Part::FilletBase);
public:
FilletBase();
App::PropertyLink Base;
PropertyFilletEdges Edges;
short mustExecute() const;
};
typedef App::FeaturePythonT<Feature> FeaturePython;

View File

@@ -817,6 +817,33 @@ bool CmdPartFillet::isActive(void)
return (hasActiveDocument() && !Gui::Control().activeDialog());
}
//===========================================================================
// Part_Chamfer
//===========================================================================
DEF_STD_CMD_A(CmdPartChamfer);
CmdPartChamfer::CmdPartChamfer()
:Command("Part_Chamfer")
{
sAppModule = "Part";
sGroup = QT_TR_NOOP("Part");
sMenuText = QT_TR_NOOP("Chamfer...");
sToolTipText = QT_TR_NOOP("Chamfer the selected edges of a shape");
sWhatsThis = sToolTipText;
sStatusTip = sToolTipText;
sPixmap = "Part_Chamfer";
}
void CmdPartChamfer::activated(int iMsg)
{
Gui::Control().showDialog(new PartGui::TaskChamferEdges(0));
}
bool CmdPartChamfer::isActive(void)
{
return (hasActiveDocument() && !Gui::Control().activeDialog());
}
//===========================================================================
// Part_Mirror
//===========================================================================
@@ -1152,6 +1179,7 @@ void CreatePartCommands(void)
rcCmdMgr.addCommand(new CmdPartRevolve());
rcCmdMgr.addCommand(new CmdPartCrossSections());
rcCmdMgr.addCommand(new CmdPartFillet());
rcCmdMgr.addCommand(new CmdPartChamfer());
rcCmdMgr.addCommand(new CmdPartCommon());
rcCmdMgr.addCommand(new CmdPartCut());
rcCmdMgr.addCommand(new CmdPartFuse());

View File

@@ -49,6 +49,7 @@
#include "../App/PartFeature.h"
#include "../App/FeatureFillet.h"
#include "../App/FeatureChamfer.h"
#include <App/Application.h>
#include <App/Document.h>
#include <App/DocumentObject.h>
@@ -155,7 +156,7 @@ namespace PartGui {
public:
App::DocumentObject* object;
EdgeSelection* selection;
Part::Fillet* fillet;
Part::FilletBase* fillet;
typedef boost::signals::connection Connection;
Connection connectApplicationDeletedObject;
Connection connectApplicationDeletedDocument;
@@ -164,7 +165,7 @@ namespace PartGui {
/* TRANSLATOR PartGui::DlgFilletEdges */
DlgFilletEdges::DlgFilletEdges(Part::Fillet* fillet, QWidget* parent, Qt::WFlags fl)
DlgFilletEdges::DlgFilletEdges(Part::FilletBase* fillet, QWidget* parent, Qt::WFlags fl)
: QWidget(parent, fl), ui(new Ui_DlgFilletEdges()), d(new DlgFilletEdgesP())
{
ui->setupUi(this);
@@ -544,6 +545,11 @@ void DlgFilletEdges::on_filletEndRadius_valueChanged(double radius)
}
}
const char* DlgFilletEdges::getFilletType() const
{
return "Fillet";
}
bool DlgFilletEdges::accept()
{
if (!d->object) {
@@ -558,16 +564,17 @@ bool DlgFilletEdges::accept()
bool todo = false;
QString shape, type, name;
std::string fillet = getFilletType();
int index = ui->shapeObject->currentIndex();
shape = ui->shapeObject->itemData(index).toString();
type = QString::fromAscii("Part::Fillet");
type = QString::fromAscii("Part::%1").arg(QString::fromAscii(fillet.c_str()));
if (d->fillet)
name = QString::fromAscii(d->fillet->getNameInDocument());
else
name = QString::fromAscii(activeDoc->getUniqueObjectName("Fillet").c_str());
name = QString::fromAscii(activeDoc->getUniqueObjectName(fillet.c_str()).c_str());
activeDoc->openTransaction("Fillet");
activeDoc->openTransaction(fillet.c_str());
QString code;
if (!d->fillet) {
code = QString::fromAscii(
@@ -627,7 +634,7 @@ bool DlgFilletEdges::accept()
// ---------------------------------------
FilletEdgesDialog::FilletEdgesDialog(Part::Fillet* fillet, QWidget* parent, Qt::WFlags fl)
FilletEdgesDialog::FilletEdgesDialog(Part::FilletBase* fillet, QWidget* parent, Qt::WFlags fl)
: QDialog(parent, fl)
{
widget = new DlgFilletEdges(fillet, this);
@@ -693,4 +700,63 @@ bool TaskFilletEdges::reject()
return true;
}
// --------------------------------------------------------------
/* TRANSLATOR PartGui::DlgChamferEdges */
DlgChamferEdges::DlgChamferEdges(Part::FilletBase* chamfer, QWidget* parent, Qt::WFlags fl)
: DlgFilletEdges(chamfer, parent, fl)
{
this->setWindowTitle(tr("Chamfer Edges"));
}
/*
* Destroys the object and frees any allocated resources
*/
DlgChamferEdges::~DlgChamferEdges()
{
}
const char* DlgChamferEdges::getFilletType() const
{
return "Chamfer";
}
TaskChamferEdges::TaskChamferEdges(Part::Chamfer* chamfer)
{
widget = new DlgChamferEdges(chamfer);
taskbox = new Gui::TaskView::TaskBox(
Gui::BitmapFactory().pixmap("Part_Chamfer"),
widget->windowTitle(), true, 0);
taskbox->groupLayout()->addWidget(widget);
Content.push_back(taskbox);
}
TaskChamferEdges::~TaskChamferEdges()
{
// automatically deleted in the sub-class
}
void TaskChamferEdges::open()
{
}
void TaskChamferEdges::clicked(int)
{
}
bool TaskChamferEdges::accept()
{
bool ok = widget->accept();
if (ok)
Gui::Command::doCommand(Gui::Command::Gui,"Gui.activeDocument().resetEdit()");
return ok;
}
bool TaskChamferEdges::reject()
{
Gui::Command::doCommand(Gui::Command::Gui,"Gui.activeDocument().resetEdit()");
return true;
}
#include "moc_DlgFilletEdges.cpp"

View File

@@ -29,7 +29,11 @@
#include <QStandardItemModel>
#include <QItemDelegate>
namespace Part { class Fillet; }
namespace Part {
class FilletBase;
class Fillet;
class Chamfer;
}
namespace PartGui {
@@ -72,7 +76,7 @@ class DlgFilletEdges : public QWidget, public Gui::SelectionObserver
Q_OBJECT
public:
DlgFilletEdges(Part::Fillet*, QWidget* parent = 0, Qt::WFlags fl = 0);
DlgFilletEdges(Part::FilletBase*, QWidget* parent = 0, Qt::WFlags fl = 0);
~DlgFilletEdges();
bool accept();
@@ -80,6 +84,7 @@ protected:
void findShapes();
void setupFillet(const std::vector<App::DocumentObject*>&);
void changeEvent(QEvent *e);
virtual const char* getFilletType() const;
private:
void onSelectionChanged(const Gui::SelectionChanges& msg);
@@ -105,7 +110,7 @@ class FilletEdgesDialog : public QDialog
Q_OBJECT
public:
FilletEdgesDialog(Part::Fillet* fillet, QWidget* parent = 0, Qt::WFlags fl = 0);
FilletEdgesDialog(Part::FilletBase* fillet, QWidget* parent = 0, Qt::WFlags fl = 0);
~FilletEdgesDialog();
void accept();
@@ -113,6 +118,18 @@ private:
DlgFilletEdges* widget;
};
class DlgChamferEdges : public DlgFilletEdges
{
Q_OBJECT
public:
DlgChamferEdges(Part::FilletBase*, QWidget* parent = 0, Qt::WFlags fl = 0);
~DlgChamferEdges();
protected:
virtual const char* getFilletType() const;
};
class TaskFilletEdges : public Gui::TaskView::TaskDialog
{
Q_OBJECT
@@ -135,6 +152,28 @@ private:
Gui::TaskView::TaskBox* taskbox;
};
class TaskChamferEdges : public Gui::TaskView::TaskDialog
{
Q_OBJECT
public:
TaskChamferEdges(Part::Chamfer*);
~TaskChamferEdges();
public:
virtual void open();
virtual void clicked(int);
virtual bool accept();
virtual bool reject();
virtual QDialogButtonBox::StandardButtons getStandardButtons() const
{ return QDialogButtonBox::Ok|QDialogButtonBox::Cancel; }
private:
DlgChamferEdges* widget;
Gui::TaskView::TaskBox* taskbox;
};
} // namespace PartGui
#endif // PARTGUI_DLGFILLETEDGES_H

View File

@@ -38,6 +38,7 @@
#include <Mod/Part/App/FeatureMirroring.h>
#include <Mod/Part/App/FeatureFillet.h>
#include <Mod/Part/App/FeatureChamfer.h>
#include <Gui/Application.h>
#include <Gui/Control.h>
#include <Gui/Document.h>
@@ -253,3 +254,43 @@ ViewProviderChamfer::ViewProviderChamfer()
ViewProviderChamfer::~ViewProviderChamfer()
{
}
void ViewProviderChamfer::setupContextMenu(QMenu* menu, QObject* receiver, const char* member)
{
QAction* act;
act = menu->addAction(QObject::tr("Edit chamfer edges"), receiver, member);
act->setData(QVariant((int)ViewProvider::Default));
PartGui::ViewProviderPart::setupContextMenu(menu, receiver, member);
}
bool ViewProviderChamfer::setEdit(int ModNum)
{
if (ModNum == ViewProvider::Default ) {
if (Gui::Control().activeDialog())
return false;
Part::Chamfer* chamfer = static_cast<Part::Chamfer*>(getObject());
Gui::Control().showDialog(new PartGui::TaskChamferEdges(chamfer));
return true;
}
else {
ViewProviderPart::setEdit(ModNum);
return true;
}
}
void ViewProviderChamfer::unsetEdit(int ModNum)
{
if (ModNum == ViewProvider::Default) {
Gui::Control().closeDialog();
}
else {
ViewProviderPart::unsetEdit(ModNum);
}
}
std::vector<App::DocumentObject*> ViewProviderChamfer::claimChildren() const
{
std::vector<App::DocumentObject*> temp;
temp.push_back(static_cast<Part::Chamfer*>(getObject())->Base.getValue());
return temp;
}

View File

@@ -80,6 +80,15 @@ public:
ViewProviderChamfer();
/// destructor
virtual ~ViewProviderChamfer();
/** @name Edit methods */
//@{
void setupContextMenu(QMenu*, QObject*, const char*);
std::vector<App::DocumentObject*> claimChildren() const;
protected:
bool setEdit(int ModNum);
void unsetEdit(int ModNum);
//@}
};
} // namespace PartGui

View File

@@ -66,7 +66,7 @@ Gui::MenuItem* Workbench::setupMenuBar() const
<< "Part_MakeSolid" << "Part_ReverseShape" << "Part_SimpleCopy"
<< "Part_RefineShape" << "Separator"
<< "Part_Boolean" << "Part_CrossSections" << "Part_Extrude"
<< "Part_Revolve" << "Part_Mirror" << "Part_Fillet"
<< "Part_Revolve" << "Part_Mirror" << "Part_Fillet" << "Part_Chamfer"
<< "Part_RuledSurface" << "Part_Loft"
<< "Part_Builder";
@@ -94,7 +94,7 @@ Gui::ToolBarItem* Workbench::setupToolBars() const
Gui::ToolBarItem* tool = new Gui::ToolBarItem(root);
tool->setCommand("Part tools");
*tool << "Part_Extrude" << "Part_Revolve" << "Part_Mirror" << "Part_Fillet" << "Part_RuledSurface";
*tool << "Part_Extrude" << "Part_Revolve" << "Part_Mirror" << "Part_Fillet" << "Part_Chamfer" << "Part_RuledSurface";
Gui::ToolBarItem* boolop = new Gui::ToolBarItem(root);
boolop->setCommand("Boolean");