Skip to content

Commit

Permalink
ViewProviderAttachExtension: check for attach extension
Browse files Browse the repository at this point in the history
  • Loading branch information
abdullahtahiriyo authored and wwmayer committed Jun 22, 2019
1 parent 62975d2 commit e72b48e
Showing 1 changed file with 51 additions and 46 deletions.
97 changes: 51 additions & 46 deletions src/Mod/Part/Gui/ViewProviderAttachExtension.cpp
Expand Up @@ -45,41 +45,44 @@ QIcon ViewProviderAttachExtension::extensionMergeOverlayIcons(const QIcon & orig
{
QIcon mergedicon = orig;

auto* attach = getExtendedViewProvider()->getObject()->getExtensionByType<Part::AttachExtension>();

if (attach) {

bool attached = false;

try{
attached = attach->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##.",
".##aaa##.",
"...###..."};

px = QPixmap(feature_detached_xpm);

mergedicon = Gui::BitmapFactoryInst::mergePixmap(mergedicon, px, Gui::BitmapFactoryInst::BottomLeft);
if (getExtendedViewProvider()->getObject()->hasExtension(Part::AttachExtension::getExtensionClassTypeId())) {

auto* attach = getExtendedViewProvider()->getObject()->getExtensionByType<Part::AttachExtension>();

if (attach) {

bool attached = false;

try{
attached = attach->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##.",
".##aaa##.",
"...###..."};

px = QPixmap(feature_detached_xpm);

mergedicon = Gui::BitmapFactoryInst::mergePixmap(mergedicon, px, Gui::BitmapFactoryInst::BottomLeft);
}
}
}

Expand All @@ -88,17 +91,19 @@ QIcon ViewProviderAttachExtension::extensionMergeOverlayIcons(const QIcon & orig

void ViewProviderAttachExtension::extensionUpdateData(const App::Property* prop)
{
auto* attach = getExtendedViewProvider()->getObject()->getExtensionByType<Part::AttachExtension>();

if(attach) {
if( prop == &(attach->Support) ||
prop == &(attach->MapMode) ||
prop == &(attach->MapPathParameter) ||
prop == &(attach->MapReversed) ||
prop == &(attach->AttachmentOffset) ||
prop == &(attach->AttacherType) ) {

getExtendedViewProvider()->signalChangeIcon(); // signal icon change
if (getExtendedViewProvider()->getObject()->hasExtension(Part::AttachExtension::getExtensionClassTypeId())) {
auto* attach = getExtendedViewProvider()->getObject()->getExtensionByType<Part::AttachExtension>();

if(attach) {
if( prop == &(attach->Support) ||
prop == &(attach->MapMode) ||
prop == &(attach->MapPathParameter) ||
prop == &(attach->MapReversed) ||
prop == &(attach->AttachmentOffset) ||
prop == &(attach->AttacherType) ) {

getExtendedViewProvider()->signalChangeIcon(); // signal icon change
}
}
}

Expand Down

0 comments on commit e72b48e

Please sign in to comment.