PartDesign: Extend Datums ViewProvider to overlay attachment status

This commit is contained in:
Abdullah Tahiri
2019-06-16 12:12:14 +02:00
committed by wmayer
parent b0fdf138b8
commit 321e9215d4
2 changed files with 53 additions and 6 deletions

View File

@@ -24,6 +24,7 @@
#include "PreCompiled.h"
#ifndef _PreComp_
# include <QApplication>
# include <QMessageBox>
# include <QAction>
# include <QMenu>
@@ -61,6 +62,7 @@
#include <Gui/ViewProviderOrigin.h>
#include <Gui/View3DInventor.h>
#include <Gui/View3DInventorViewer.h>
#include <Gui/BitmapFactory.h>
#include <Mod/PartDesign/App/DatumPoint.h>
#include <Mod/PartDesign/App/DatumLine.h>
@@ -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<Part::Datum*>(getObject());
PartDesign::Body* activeBody = getActiveView()->getActiveObject<PartDesign::Body*>(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<App::GroupExtension>();
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<Part::AttachExtension>()->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;
}

View File

@@ -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;