Fix 2889 Toggle Frames for DrawViewSymbol

This commit is contained in:
WandererFan 2017-02-05 20:26:22 -05:00 committed by Yorik van Havre
parent 18cd5b5166
commit 2c31b01ffe
3 changed files with 15 additions and 7 deletions

View File

@ -291,7 +291,7 @@ void CmdTechDrawToggleFrame::activated(int iMsg)
bool CmdTechDrawToggleFrame::isActive(void) bool CmdTechDrawToggleFrame::isActive(void)
{ {
bool havePage = DrawGuiUtil::needPage(this); bool havePage = DrawGuiUtil::needPage(this);
bool haveView = DrawGuiUtil::needView(this); bool haveView = DrawGuiUtil::needView(this,false);
return (havePage && haveView); return (havePage && haveView);
} }

View File

@ -121,15 +121,23 @@ bool DrawGuiUtil::needPage(Gui::Command* cmd)
return active; return active;
} }
bool DrawGuiUtil::needView(Gui::Command* cmd) bool DrawGuiUtil::needView(Gui::Command* cmd, bool partOnly)
{ {
bool haveView = false; bool haveView = false;
if (cmd->hasActiveDocument()) { if (cmd->hasActiveDocument()) {
if (partOnly) {
auto drawPartType (TechDraw::DrawViewPart::getClassTypeId()); auto drawPartType (TechDraw::DrawViewPart::getClassTypeId());
auto selParts = cmd->getDocument()->getObjectsOfType(drawPartType); auto selParts = cmd->getDocument()->getObjectsOfType(drawPartType);
if (!selParts.empty()) { if (!selParts.empty()) {
haveView = true; haveView = true;
} }
} else {
auto drawViewType (TechDraw::DrawView::getClassTypeId());
auto selParts = cmd->getDocument()->getObjectsOfType(drawViewType);
if (!selParts.empty()) {
haveView = true;
}
}
} }
return haveView; return haveView;
} }

View File

@ -33,7 +33,7 @@ class TechDrawGuiExport DrawGuiUtil {
public: public:
static TechDraw::DrawPage* findPage(Gui::Command* cmd); static TechDraw::DrawPage* findPage(Gui::Command* cmd);
static bool needPage(Gui::Command* cmd); static bool needPage(Gui::Command* cmd);
static bool needView(Gui::Command* cmd); static bool needView(Gui::Command* cmd, bool partOnly = true);
}; };
} //end namespace TechDrawGui } //end namespace TechDrawGui