handle editing of view provider of base feature

This commit is contained in:
wmayer
2017-10-01 19:32:11 +02:00
parent 98c6e0e2b0
commit 397d7b74c0
2 changed files with 61 additions and 1 deletions

View File

@@ -27,6 +27,8 @@
#endif
#include "ViewProviderBase.h"
#include <Mod/PartDesign/App/FeatureBase.h>
#include <Gui/Command.h>
using namespace PartDesignGui;
@@ -43,3 +45,55 @@ ViewProviderBase::~ViewProviderBase()
}
bool ViewProviderBase::doubleClicked(void)
{
// If the Placement is mutable then open the transform panel.
// If the Placement can't be modified then just do nothing on double-click.
PartDesign::FeatureBase* base = static_cast<PartDesign::FeatureBase*>(getObject());
if (!base->Placement.testStatus(App::Property::Immutable) &&
!base->Placement.testStatus(App::Property::ReadOnly) &&
!base->Placement.testStatus(App::Property::Hidden)) {
try {
std::string Msg("Edit ");
Msg += base->Label.getValue();
Gui::Command::openCommand(Msg.c_str());
Gui::Command::doCommand(Gui::Command::Gui,"Gui.activeDocument().setEdit('%s',0)",
base->getNameInDocument());
}
catch (const Base::Exception&) {
Gui::Command::abortCommand();
}
return true;
}
return false;
}
void ViewProviderBase::setupContextMenu(QMenu* menu, QObject* receiver, const char* member)
{
// If the Placement is mutable then show the context-menu of the base class.
PartDesign::FeatureBase* base = static_cast<PartDesign::FeatureBase*>(getObject());
if (!base->Placement.testStatus(App::Property::Immutable) &&
!base->Placement.testStatus(App::Property::ReadOnly) &&
!base->Placement.testStatus(App::Property::Hidden)) {
PartDesignGui::ViewProvider::setupContextMenu(menu, receiver, member);
}
}
bool ViewProviderBase::setEdit(int ModNum)
{
PartDesign::FeatureBase* base = static_cast<PartDesign::FeatureBase*>(getObject());
if (!base->Placement.testStatus(App::Property::Immutable) &&
!base->Placement.testStatus(App::Property::ReadOnly) &&
!base->Placement.testStatus(App::Property::Hidden)) {
return PartGui::ViewProviderPart::setEdit(ModNum);
}
return false;
}
void ViewProviderBase::unsetEdit(int ModNum)
{
PartGui::ViewProviderPart::unsetEdit(ModNum);
}

View File

@@ -37,7 +37,13 @@ public:
ViewProviderBase();
/// destructor
virtual ~ViewProviderBase();
virtual bool doubleClicked(void);
virtual void setupContextMenu(QMenu* menu, QObject* receiver, const char* member);
protected:
virtual bool setEdit(int ModNum);
virtual void unsetEdit(int ModNum);
};
} // namespace PartDesignGui