allow to set rigid property via context menu

This commit is contained in:
Stefan Tröger 2013-08-13 17:03:59 +00:00
parent e9e1b45280
commit f61ae2e90c
4 changed files with 48 additions and 5 deletions

View File

@ -98,3 +98,31 @@ std::vector<App::DocumentObject*> ViewProviderItemAssembly::claimChildren3D(void
return static_cast<Assembly::ItemAssembly*>(getObject())->Items.getValues(); return static_cast<Assembly::ItemAssembly*>(getObject())->Items.getValues();
} }
void ViewProviderItemAssembly::setupContextMenu(QMenu* menu, QObject* receiver, const char* member)
{
ViewProviderItem::setupContextMenu(menu, receiver, member); // call the base class
QAction* toggle = menu->addAction(QObject::tr("Rigid subassembly"), receiver, member);
toggle->setData(QVariant(1000)); // identifier
toggle->setCheckable(true);
toggle->setToolTip(QObject::tr("Set if the subassembly shall be solved as on part (rigid) or if all parts of this assembly are solved for themselfe."));
toggle->setStatusTip(QObject::tr("Set if the subassembly shall be solved as on part (rigid) or if all parts of this assembly are solved for themself."));
bool prop = static_cast<Assembly::ItemAssembly*>(getObject())->Rigid.getValue();
toggle->setChecked(prop);
}
bool ViewProviderItemAssembly::setEdit(int ModNum)
{
if(ModNum == 1000) { // identifier
Gui::Command::openCommand("Change subassembly solving behaviour");
if(!static_cast<Assembly::ItemAssembly*>(getObject())->Rigid.getValue())
Gui::Command::doCommand(Gui::Command::Doc,"FreeCAD.getDocument(\"%s\").getObject(\"%s\").Rigid = True",getObject()->getDocument()->getName(), getObject()->getNameInDocument());
else
Gui::Command::doCommand(Gui::Command::Doc,"FreeCAD.getDocument(\"%s\").getObject(\"%s\").Rigid = False",getObject()->getDocument()->getName(), getObject()->getNameInDocument());
Gui::Command::commitCommand();
return false;
}
return ViewProviderItem::setEdit(ModNum); // call the base class
}

View File

@ -25,6 +25,8 @@
#define ASSEMBLYGUI_ViewProviderAssembly_H #define ASSEMBLYGUI_ViewProviderAssembly_H
#include "ViewProvider.h" #include "ViewProvider.h"
#include <QMenu>
#include <QObject>
namespace AssemblyGui { namespace AssemblyGui {
@ -49,6 +51,9 @@ public:
virtual std::vector<App::DocumentObject*> claimChildren3D(void)const; virtual std::vector<App::DocumentObject*> claimChildren3D(void)const;
virtual void setupContextMenu(QMenu* menu, QObject* receiver, const char* member);
virtual bool setEdit(int ModNum);
}; };

View File

@ -170,9 +170,17 @@ void ViewProviderConstraint::attach(App::DocumentObject* pcFeat)
internal_vp.setDisplayMM("Flat Lines"); internal_vp.setDisplayMM("Flat Lines");
} }
void ViewProviderConstraint::update(const App::Property* prop) {
void ViewProviderConstraint::updateData(const App::Property* prop) if(Visibility.getValue() && m_selected) {
{
draw();
}
ViewProviderPart::update(prop);
}
void ViewProviderConstraint::updateData(const App::Property* prop) {
if(Visibility.getValue() && m_selected) { if(Visibility.getValue() && m_selected) {
draw(); draw();

View File

@ -70,6 +70,8 @@ public:
//annotation nodes //annotation nodes
virtual void attach(App::DocumentObject* pcObj); virtual void attach(App::DocumentObject* pcObj);
//update is for visual only
virtual void update(const App::Property*);
//needs to be overridden as this viewprovider dos not represent a Part::Feature //needs to be overridden as this viewprovider dos not represent a Part::Feature
virtual void updateData(const App::Property*); virtual void updateData(const App::Property*);
//needs to be overridden as this viewprovider dos not represent a Part::Feature //needs to be overridden as this viewprovider dos not represent a Part::Feature