[TD]improve selection filtering for ArchSection

This commit is contained in:
wandererfan
2020-03-18 13:20:41 -04:00
committed by WandererFan
parent 55da881bc9
commit 197c0f799c
3 changed files with 95 additions and 48 deletions

View File

@@ -96,7 +96,6 @@ void DrawGuiUtil::loadArrowBox(QComboBox* qcb)
}
}
//===========================================================================
// validate helper routines
//===========================================================================
@@ -182,6 +181,72 @@ bool DrawGuiUtil::isDraftObject(App::DocumentObject* obj)
return result;
}
bool DrawGuiUtil::isArchObject(App::DocumentObject* obj)
{
bool result = false;
App::Property* proxy = obj->getPropertyByName("Proxy");
if (proxy != nullptr) {
//if no proxy, can not be Arch obj
//if has proxy, might be Arch obj
App::PropertyPythonObject* proxyPy = dynamic_cast<App::PropertyPythonObject*>(proxy);
Py::Object proxyObj = proxyPy->getValue();
std::stringstream ss;
if (proxyPy != nullptr) {
Base::PyGILStateLocker lock;
try {
if (proxyObj.hasAttr("__module__")) {
Py::String mod(proxyObj.getAttr("__module__"));
ss << (std::string)mod;
//does this have to be an ArchSection, or can it be any Arch object?
if (ss.str().find("Arch") != std::string::npos) {
result = true;
}
}
}
catch (Py::Exception&) {
Base::PyException e; // extract the Python error text
e.ReportException();
result = false;
}
}
}
return result;
}
bool DrawGuiUtil::isArchSection(App::DocumentObject* obj)
{
bool result = false;
App::Property* proxy = obj->getPropertyByName("Proxy");
if (proxy != nullptr) {
//if no proxy, can not be Arch obj
//if has proxy, might be Arch obj
App::PropertyPythonObject* proxyPy = dynamic_cast<App::PropertyPythonObject*>(proxy);
Py::Object proxyObj = proxyPy->getValue();
std::stringstream ss;
if (proxyPy != nullptr) {
Base::PyGILStateLocker lock;
try {
if (proxyObj.hasAttr("__module__")) {
Py::String mod(proxyObj.getAttr("__module__"));
ss << (std::string)mod;
//does this have to be an ArchSection, or can it be other Arch objects?
if (ss.str().find("ArchSectionPlane") != std::string::npos) {
result = true;
}
}
}
catch (Py::Exception&) {
Base::PyException e; // extract the Python error text
e.ReportException();
result = false;
}
}
}
return result;
}
bool DrawGuiUtil::needPage(Gui::Command* cmd)
{
//need a Document and a Page