diff --git a/src/Mod/Assembly/Gui/ViewProviderAssembly.cpp b/src/Mod/Assembly/Gui/ViewProviderAssembly.cpp index ca1d578d3..8cdb3fe57 100644 --- a/src/Mod/Assembly/Gui/ViewProviderAssembly.cpp +++ b/src/Mod/Assembly/Gui/ViewProviderAssembly.cpp @@ -52,7 +52,7 @@ bool ViewProviderItemAssembly::doubleClicked(void) return true; } -void ViewProviderItemAssembly::attach(App::DocumentObject *pcFeat) +void ViewProviderItemAssembly::attach(App::DocumentObject* pcFeat) { // call parent attach method ViewProviderGeometryObject::attach(pcFeat); @@ -64,10 +64,10 @@ void ViewProviderItemAssembly::attach(App::DocumentObject *pcFeat) void ViewProviderItemAssembly::setDisplayMode(const char* ModeName) { - if ( strcmp("Main",ModeName)==0 ) + if(strcmp("Main",ModeName)==0) setDisplayMaskMode("Main"); - ViewProviderGeometryObject::setDisplayMode( ModeName ); + ViewProviderGeometryObject::setDisplayMode(ModeName); } std::vector ViewProviderItemAssembly::getDisplayModes(void) const @@ -98,3 +98,31 @@ std::vector ViewProviderItemAssembly::claimChildren3D(void return static_cast(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(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(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 +} diff --git a/src/Mod/Assembly/Gui/ViewProviderAssembly.h b/src/Mod/Assembly/Gui/ViewProviderAssembly.h index 1e3fe40cc..1e30ef327 100644 --- a/src/Mod/Assembly/Gui/ViewProviderAssembly.h +++ b/src/Mod/Assembly/Gui/ViewProviderAssembly.h @@ -25,6 +25,8 @@ #define ASSEMBLYGUI_ViewProviderAssembly_H #include "ViewProvider.h" +#include +#include namespace AssemblyGui { @@ -48,6 +50,9 @@ public: virtual std::vector claimChildren(void)const; virtual std::vector claimChildren3D(void)const; + + virtual void setupContextMenu(QMenu* menu, QObject* receiver, const char* member); + virtual bool setEdit(int ModNum); }; diff --git a/src/Mod/Assembly/Gui/ViewProviderConstraint.cpp b/src/Mod/Assembly/Gui/ViewProviderConstraint.cpp index b93bda783..4ea41bb4a 100644 --- a/src/Mod/Assembly/Gui/ViewProviderConstraint.cpp +++ b/src/Mod/Assembly/Gui/ViewProviderConstraint.cpp @@ -170,9 +170,17 @@ void ViewProviderConstraint::attach(App::DocumentObject* pcFeat) 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) { draw(); diff --git a/src/Mod/Assembly/Gui/ViewProviderConstraint.h b/src/Mod/Assembly/Gui/ViewProviderConstraint.h index cedcfcfef..9371a3f1c 100644 --- a/src/Mod/Assembly/Gui/ViewProviderConstraint.h +++ b/src/Mod/Assembly/Gui/ViewProviderConstraint.h @@ -70,6 +70,8 @@ public: //annotation nodes 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 virtual void updateData(const App::Property*); //needs to be overridden as this viewprovider dos not represent a Part::Feature