[TD]improve selection filtering for ArchSection
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user