From 321e9215d492e55a83ccd56c152d7bcf2095e693 Mon Sep 17 00:00:00 2001 From: Abdullah Tahiri Date: Sun, 16 Jun 2019 12:12:14 +0200 Subject: [PATCH] PartDesign: Extend Datums ViewProvider to overlay attachment status --- src/Mod/PartDesign/Gui/ViewProviderDatum.cpp | 51 ++++++++++++++++++-- src/Mod/PartDesign/Gui/ViewProviderDatum.h | 8 +-- 2 files changed, 53 insertions(+), 6 deletions(-) diff --git a/src/Mod/PartDesign/Gui/ViewProviderDatum.cpp b/src/Mod/PartDesign/Gui/ViewProviderDatum.cpp index 747e5b64e5..be294dc156 100644 --- a/src/Mod/PartDesign/Gui/ViewProviderDatum.cpp +++ b/src/Mod/PartDesign/Gui/ViewProviderDatum.cpp @@ -24,6 +24,7 @@ #include "PreCompiled.h" #ifndef _PreComp_ +# include # include # include # include @@ -61,6 +62,7 @@ #include #include #include +#include #include #include @@ -282,11 +284,11 @@ bool ViewProviderDatum::doubleClicked(void) std::string Msg("Edit "); Msg += this->pcObject->Label.getValue(); Gui::Command::openCommand(Msg.c_str()); - + Part::Datum* pcDatum = static_cast(getObject()); PartDesign::Body* activeBody = getActiveView()->getActiveObject(PDBODYKEY); auto datumBody = PartDesignGui::getBodyFor(pcDatum, false); - + if (datumBody != NULL) { if (datumBody != activeBody) { Gui::Command::doCommand(Gui::Command::Gui, @@ -339,7 +341,7 @@ SbBox3f ViewProviderDatum::getRelevantBoundBox () const { if(group) { auto* ext = group->getExtensionByType(); - if(ext) + if(ext) objs = ext->getObjects (); } else { // Fallback to whole document @@ -409,3 +411,46 @@ void ViewProviderDatum::setPickable(bool val) { else pPickStyle->style = SoPickStyle::UNPICKABLE; } + +QIcon ViewProviderDatum::mergeOverlayIcons (const QIcon & orig) const +{ + QIcon mergedicon = orig; + + if (getObject()->hasExtension(Part::AttachExtension::getExtensionClassTypeId())) { + + bool attached = false; + + try{ + attached = getObject()->getExtensionByType()->positionBySupport(); + } + catch (...) { // We are just trying to get an icon, if no placement can be calculated, set unattached. + // set unattached + } + + if(!attached) { + QPixmap px; + + static const char * const feature_detached_xpm[]={ + "9 9 3 1", + ". c None", + "# c #cc00cc", + "a c #ffffff", + "...###...", + ".##aaa##.", + "##aaaaa##", + "##aaaaa##", + ".##aaa##.", + "...###...", + "...###...", + "....#....", + "....#....", + "....#...."}; + + px = QPixmap(feature_detached_xpm); + + mergedicon = mergePixmap(mergedicon, px, Gui::BitmapFactoryInst::BottomLeft); + } + } + + return mergedicon; +} diff --git a/src/Mod/PartDesign/Gui/ViewProviderDatum.h b/src/Mod/PartDesign/Gui/ViewProviderDatum.h index 98854b940b..c0d811f17e 100644 --- a/src/Mod/PartDesign/Gui/ViewProviderDatum.h +++ b/src/Mod/PartDesign/Gui/ViewProviderDatum.h @@ -60,14 +60,14 @@ public: virtual std::string getElement(const SoDetail *) const; virtual SoDetail* getDetail(const char*) const; - /** + /** * Enable/Disable the selectability of the datum - * This differs from the normal ViewProvider selectability in that, that with this enabled one + * This differs from the normal ViewProvider selectability in that, that with this enabled one * can pick through the datum and select stuff behind it. */ bool isPickable(); void setPickable(bool val); - + /** * Update the visual size to match the given extents * @note should be reimplemented in the offspings @@ -124,6 +124,8 @@ protected: // Get the separator to fill with datum content SoSeparator *getShapeRoot () { return pShapeSep; } + virtual QIcon mergeOverlayIcons (const QIcon & orig) const override; + private: SoSeparator* pShapeSep; SoPickStyle* pPickStyle;