PartDesign/Gui: make DressUp view providers use the common code.
This commit is contained in:
parent
55f3f52f54
commit
1876c76f3c
|
@ -50,8 +50,8 @@ using namespace Gui;
|
|||
|
||||
TaskDressUpParameters::TaskDressUpParameters(ViewProviderDressUp *DressUpView, bool selectEdges, bool selectFaces, QWidget *parent)
|
||||
: allowFaces(selectFaces), allowEdges(selectEdges),
|
||||
TaskBox(Gui::BitmapFactory().pixmap((std::string("PartDesign_") + DressUpView->featureName).c_str()),
|
||||
QString::fromAscii((DressUpView->featureName + " parameters").c_str()),
|
||||
TaskBox(Gui::BitmapFactory().pixmap((std::string("PartDesign_") + DressUpView->featureName()).c_str()),
|
||||
QString::fromAscii((DressUpView->featureName() + " parameters").c_str()),
|
||||
true,
|
||||
parent),
|
||||
DressUpView(DressUpView)
|
||||
|
|
|
@ -24,46 +24,22 @@
|
|||
#include "PreCompiled.h"
|
||||
|
||||
#ifndef _PreComp_
|
||||
# include <QAction>
|
||||
# include <QMenu>
|
||||
# include <QMessageBox>
|
||||
#endif
|
||||
|
||||
#include "ViewProviderChamfer.h"
|
||||
#include "TaskChamferParameters.h"
|
||||
#include <Gui/Control.h>
|
||||
#include <Gui/Command.h>
|
||||
#include <Gui/Application.h>
|
||||
|
||||
#include "ViewProviderChamfer.h"
|
||||
|
||||
using namespace PartDesignGui;
|
||||
|
||||
PROPERTY_SOURCE(PartDesignGui::ViewProviderChamfer,PartDesignGui::ViewProviderDressUp)
|
||||
|
||||
bool ViewProviderChamfer::setEdit(int ModNum)
|
||||
{
|
||||
if (ModNum == ViewProvider::Default ) {
|
||||
TaskDlgDressUpParameters *dressUpDlg = NULL;
|
||||
|
||||
if (checkDlgOpen(dressUpDlg)) {
|
||||
// always change to PartDesign WB, remember where we come from
|
||||
oldWb = Gui::Command::assureWorkbench("PartDesignWorkbench");
|
||||
|
||||
// start the edit dialog
|
||||
if (dressUpDlg)
|
||||
Gui::Control().showDialog(dressUpDlg);
|
||||
else
|
||||
Gui::Control().showDialog(new TaskDlgChamferParameters(this));
|
||||
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
else {
|
||||
return ViewProviderDressUp::setEdit(ModNum);
|
||||
}
|
||||
const std::string & ViewProviderChamfer::featureName() const {
|
||||
static const std::string name = "Chamfer";
|
||||
return name;
|
||||
}
|
||||
|
||||
|
||||
|
||||
TaskDlgFeatureParameters *ViewProviderChamfer::getEditDialog() {
|
||||
return new TaskDlgChamferParameters (this);
|
||||
}
|
||||
|
|
|
@ -36,12 +36,14 @@ class PartDesignGuiExport ViewProviderChamfer : public ViewProviderDressUp
|
|||
public:
|
||||
/// constructor
|
||||
ViewProviderChamfer()
|
||||
{ featureName = std::string("Chamfer");
|
||||
sPixmap = "PartDesign_Chamfer.svg"; }
|
||||
{ sPixmap = "PartDesign_Chamfer.svg"; }
|
||||
|
||||
/// return "Chamfer"
|
||||
virtual const std::string & featureName() const;
|
||||
|
||||
protected:
|
||||
virtual bool setEdit(int ModNum);
|
||||
|
||||
/// Returns a newly create dialog for the part to be placed in the task view
|
||||
virtual TaskDlgFeatureParameters *getEditDialog();
|
||||
};
|
||||
|
||||
|
||||
|
|
|
@ -24,49 +24,22 @@
|
|||
#include "PreCompiled.h"
|
||||
|
||||
#ifndef _PreComp_
|
||||
# include <QAction>
|
||||
# include <QMenu>
|
||||
# include <QMessageBox>
|
||||
# include <TopTools_IndexedMapOfShape.hxx>
|
||||
# include <TopExp.hxx>
|
||||
#endif
|
||||
|
||||
#include "ViewProviderDraft.h"
|
||||
#include "TaskDraftParameters.h"
|
||||
#include <Mod/PartDesign/App/FeatureDraft.h>
|
||||
#include <Mod/Sketcher/App/SketchObject.h>
|
||||
#include <Gui/Control.h>
|
||||
#include <Gui/Command.h>
|
||||
#include <Gui/Application.h>
|
||||
|
||||
#include "ViewProviderDraft.h"
|
||||
|
||||
using namespace PartDesignGui;
|
||||
|
||||
PROPERTY_SOURCE(PartDesignGui::ViewProviderDraft,PartDesignGui::ViewProviderDressUp)
|
||||
|
||||
bool ViewProviderDraft::setEdit(int ModNum)
|
||||
{
|
||||
if (ModNum == ViewProvider::Default ) {
|
||||
TaskDlgDressUpParameters *dressUpDlg = NULL;
|
||||
|
||||
if (checkDlgOpen(dressUpDlg)) {
|
||||
// always change to PartDesign WB, remember where we come from
|
||||
oldWb = Gui::Command::assureWorkbench("PartDesignWorkbench");
|
||||
|
||||
// start the edit dialog
|
||||
if (dressUpDlg)
|
||||
Gui::Control().showDialog(dressUpDlg);
|
||||
else
|
||||
Gui::Control().showDialog(new TaskDlgDraftParameters(this));
|
||||
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
else {
|
||||
return ViewProviderDressUp::setEdit(ModNum);
|
||||
}
|
||||
const std::string & ViewProviderDraft::featureName() const {
|
||||
static const std::string name = "Draft";
|
||||
return name;
|
||||
}
|
||||
|
||||
|
||||
TaskDlgFeatureParameters *ViewProviderDraft::getEditDialog() {
|
||||
return new TaskDlgDraftParameters (this);
|
||||
}
|
||||
|
|
|
@ -36,11 +36,14 @@ class PartDesignGuiExport ViewProviderDraft : public ViewProviderDressUp
|
|||
public:
|
||||
/// constructor
|
||||
ViewProviderDraft()
|
||||
{ featureName = std::string("Draft");
|
||||
sPixmap = "PartDesign_Draft.svg"; }
|
||||
{ sPixmap = "PartDesign_Draft.svg"; }
|
||||
|
||||
/// return "Draft"
|
||||
virtual const std::string & featureName() const;
|
||||
|
||||
protected:
|
||||
virtual bool setEdit(int ModNum);
|
||||
/// Returns a newly create dialog for the part to be placed in the task view
|
||||
virtual TaskDlgFeatureParameters *getEditDialog();
|
||||
};
|
||||
|
||||
} // namespace PartDesignGui
|
||||
|
|
|
@ -45,53 +45,27 @@ using namespace PartDesignGui;
|
|||
|
||||
PROPERTY_SOURCE(PartDesignGui::ViewProviderDressUp,PartDesignGui::ViewProvider)
|
||||
|
||||
|
||||
void ViewProviderDressUp::setupContextMenu(QMenu* menu, QObject* receiver, const char* member)
|
||||
{
|
||||
QAction* act;
|
||||
act = menu->addAction(QObject::tr((std::string("Edit ") + featureName + " feature").c_str()), receiver, member);
|
||||
// TODO check if this gets a sane translation (2015-07-26, Fat-Zer)
|
||||
act = menu->addAction(QObject::tr((std::string("Edit ") + featureName() + " feature").c_str()), receiver, member);
|
||||
act->setData(QVariant((int)ViewProvider::Default));
|
||||
PartGui::ViewProviderPart::setupContextMenu(menu, receiver, member);
|
||||
}
|
||||
|
||||
const bool ViewProviderDressUp::checkDlgOpen(TaskDlgDressUpParameters* dressUpDlg) {
|
||||
// When double-clicking on the item for this feature the
|
||||
// object unsets and sets its edit mode without closing
|
||||
// the task panel
|
||||
Gui::TaskView::TaskDialog *dlg = Gui::Control().activeDialog();
|
||||
dressUpDlg = qobject_cast<TaskDlgDressUpParameters *>(dlg);
|
||||
|
||||
if ((dressUpDlg != NULL) && (dressUpDlg->getDressUpView() != this))
|
||||
dressUpDlg = NULL; // another transformed feature left open its task panel
|
||||
|
||||
if ((dlg != NULL) && (dressUpDlg == NULL)) {
|
||||
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();
|
||||
|
||||
// Continue (usually in virtual method setEdit())
|
||||
return true;
|
||||
const std::string & ViewProviderDressUp::featureName() const {
|
||||
static const std::string name = "Undefined";
|
||||
return name;
|
||||
}
|
||||
|
||||
bool ViewProviderDressUp::onDelete(const std::vector<std::string> &s)
|
||||
{
|
||||
return ViewProvider::onDelete(s);
|
||||
}
|
||||
|
||||
void ViewProviderDressUp::highlightReferences(const bool on)
|
||||
{
|
||||
PartDesign::DressUp* pcDressUp = static_cast<PartDesign::DressUp*>(getObject());
|
||||
Part::Feature* base = static_cast<Part::Feature*>(pcDressUp->Base.getValue());
|
||||
Part::Feature* base = pcDressUp->getBaseObject (/*silent =*/ true);
|
||||
if (base == NULL) return;
|
||||
PartGui::ViewProviderPart* vp = dynamic_cast<PartGui::ViewProviderPart*>(
|
||||
Gui::Application::Instance->getViewProvider(base));
|
||||
|
|
|
@ -38,7 +38,7 @@ class PartDesignGuiExport ViewProviderDressUp : public ViewProvider
|
|||
public:
|
||||
/// constructor
|
||||
ViewProviderDressUp()
|
||||
: featureName("undefined") {}
|
||||
{}
|
||||
/// destructor
|
||||
virtual ~ViewProviderDressUp()
|
||||
{}
|
||||
|
@ -46,16 +46,14 @@ public:
|
|||
/// grouping handling
|
||||
void setupContextMenu(QMenu*, QObject*, const char*);
|
||||
|
||||
virtual bool onDelete(const std::vector<std::string> &);
|
||||
|
||||
/// Highlight the references that have been selected
|
||||
void highlightReferences(const bool on);
|
||||
|
||||
// The feature name of the subclass
|
||||
std::string featureName;
|
||||
|
||||
protected:
|
||||
const bool checkDlgOpen(TaskDlgDressUpParameters* dressUpDlg);
|
||||
|
||||
/**
|
||||
* Returns the feature Name associated with the view provider.
|
||||
* Should be reimplemented in the successor.
|
||||
*/
|
||||
virtual const std::string & featureName() const;
|
||||
|
||||
private:
|
||||
std::vector<App::Color> originalFaceColors;
|
||||
|
|
|
@ -24,45 +24,22 @@
|
|||
#include "PreCompiled.h"
|
||||
|
||||
#ifndef _PreComp_
|
||||
# include <QAction>
|
||||
# include <QMenu>
|
||||
# include <QMessageBox>
|
||||
#endif
|
||||
|
||||
#include "ViewProviderFillet.h"
|
||||
#include "TaskFilletParameters.h"
|
||||
#include <Gui/Control.h>
|
||||
#include <Gui/Command.h>
|
||||
#include <Gui/Application.h>
|
||||
|
||||
#include "ViewProviderFillet.h"
|
||||
|
||||
using namespace PartDesignGui;
|
||||
|
||||
PROPERTY_SOURCE(PartDesignGui::ViewProviderFillet,PartDesignGui::ViewProviderDressUp)
|
||||
|
||||
bool ViewProviderFillet::setEdit(int ModNum)
|
||||
{
|
||||
if (ModNum == ViewProvider::Default ) {
|
||||
TaskDlgDressUpParameters *dressUpDlg = NULL;
|
||||
|
||||
if (checkDlgOpen(dressUpDlg)) {
|
||||
// always change to PartDesign WB, remember where we come from
|
||||
oldWb = Gui::Command::assureWorkbench("PartDesignWorkbench");
|
||||
|
||||
// start the edit dialog
|
||||
if (dressUpDlg)
|
||||
Gui::Control().showDialog(dressUpDlg);
|
||||
else
|
||||
Gui::Control().showDialog(new TaskDlgFilletParameters(this));
|
||||
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
else {
|
||||
return ViewProviderDressUp::setEdit(ModNum);
|
||||
}
|
||||
const std::string & ViewProviderFillet::featureName() const {
|
||||
static const std::string name = "Fillet";
|
||||
return name;
|
||||
}
|
||||
|
||||
|
||||
TaskDlgFeatureParameters *ViewProviderFillet::getEditDialog() {
|
||||
return new TaskDlgFilletParameters (this);
|
||||
}
|
||||
|
|
|
@ -36,11 +36,14 @@ class PartDesignGuiExport ViewProviderFillet : public ViewProviderDressUp
|
|||
public:
|
||||
/// constructor
|
||||
ViewProviderFillet()
|
||||
{ featureName = std::string("Fillet");
|
||||
sPixmap = "PartDesign_Fillet.svg"; }
|
||||
{ sPixmap = "PartDesign_Fillet.svg"; }
|
||||
|
||||
/// return "Fillet"
|
||||
virtual const std::string & featureName() const;
|
||||
|
||||
protected:
|
||||
virtual bool setEdit(int ModNum);
|
||||
/// Returns a newly create dialog for the part to be placed in the task view
|
||||
virtual TaskDlgFeatureParameters *getEditDialog();
|
||||
};
|
||||
|
||||
} // namespace PartDesignGui
|
||||
|
|
|
@ -24,46 +24,22 @@
|
|||
#include "PreCompiled.h"
|
||||
|
||||
#ifndef _PreComp_
|
||||
# include <TopTools_IndexedMapOfShape.hxx>
|
||||
# include <TopExp.hxx>
|
||||
#endif
|
||||
|
||||
#include "ViewProviderThickness.h"
|
||||
#include "TaskThicknessParameters.h"
|
||||
#include <Mod/PartDesign/App/FeatureThickness.h>
|
||||
#include <Mod/Sketcher/App/SketchObject.h>
|
||||
#include <Gui/Control.h>
|
||||
#include <Gui/Command.h>
|
||||
#include <Gui/Application.h>
|
||||
|
||||
#include "ViewProviderThickness.h"
|
||||
|
||||
using namespace PartDesignGui;
|
||||
|
||||
PROPERTY_SOURCE(PartDesignGui::ViewProviderThickness,PartDesignGui::ViewProviderDressUp)
|
||||
|
||||
bool ViewProviderThickness::setEdit(int ModNum)
|
||||
{
|
||||
if (ModNum == ViewProvider::Default ) {
|
||||
TaskDlgDressUpParameters *dressUpDlg = NULL;
|
||||
|
||||
if (checkDlgOpen(dressUpDlg)) {
|
||||
// always change to PartDesign WB, remember where we come from
|
||||
oldWb = Gui::Command::assureWorkbench("PartDesignWorkbench");
|
||||
|
||||
// start the edit dialog
|
||||
if (dressUpDlg)
|
||||
Gui::Control().showDialog(dressUpDlg);
|
||||
else
|
||||
Gui::Control().showDialog(new TaskDlgThicknessParameters(this));
|
||||
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
else {
|
||||
return ViewProviderDressUp::setEdit(ModNum);
|
||||
}
|
||||
const std::string & ViewProviderThickness::featureName() const {
|
||||
static const std::string name = "Thickness";
|
||||
return name;
|
||||
}
|
||||
|
||||
|
||||
TaskDlgFeatureParameters *ViewProviderThickness::getEditDialog() {
|
||||
return new TaskDlgThicknessParameters (this);
|
||||
}
|
||||
|
|
|
@ -36,11 +36,14 @@ class PartDesignGuiExport ViewProviderThickness : public ViewProviderDressUp
|
|||
public:
|
||||
/// constructor
|
||||
ViewProviderThickness()
|
||||
{ featureName = std::string("Thickness");
|
||||
sPixmap = "PartDesign_Thickness.svg"; }
|
||||
{ sPixmap = "PartDesign_Thickness.svg"; }
|
||||
|
||||
/// return "Thickness"
|
||||
virtual const std::string & featureName() const;
|
||||
|
||||
protected:
|
||||
virtual bool setEdit(int ModNum);
|
||||
/// Returns a newly create dialog for the part to be placed in the task view
|
||||
virtual TaskDlgFeatureParameters *getEditDialog();
|
||||
};
|
||||
|
||||
} // namespace PartDesignGui
|
||||
|
|
Loading…
Reference in New Issue
Block a user