Fix bug in switching active Part/Assembly object when document with active one was closed
This commit is contained in:
@@ -38,34 +38,41 @@
|
||||
|
||||
// pointer to the active assembly object
|
||||
PartDesign::Body *ActivePartObject =0;
|
||||
Gui::Document *ActiveGuiDoc =0;
|
||||
Gui::ViewProviderDocumentObject *ActiveVp =0;
|
||||
Gui::Document *ActiveGuiDoc =0;
|
||||
App::Document *ActiveAppDoc =0;
|
||||
Gui::ViewProviderDocumentObject *ActiveVp =0;
|
||||
|
||||
|
||||
|
||||
static PyObject * setActivePart(PyObject *self, PyObject *args)
|
||||
{
|
||||
if(ActivePartObject){
|
||||
// check if the document not already closed
|
||||
std::vector<App::Document*> docs = App::GetApplication().getDocuments();
|
||||
for(std::vector<App::Document*>::const_iterator it=docs.begin();it!=docs.end();++it)
|
||||
if(*it == ActiveAppDoc){
|
||||
ActiveGuiDoc->signalHighlightObject(*ActiveVp,Gui::Underlined,false);
|
||||
break;
|
||||
}
|
||||
|
||||
ActivePartObject = 0;
|
||||
ActiveGuiDoc =0;
|
||||
ActiveAppDoc =0;
|
||||
ActiveVp =0;
|
||||
}
|
||||
|
||||
PyObject *object=0;
|
||||
if (PyArg_ParseTuple(args,"|O!",&(PartDesign::BodyPy::Type), &object)&& object) {
|
||||
PartDesign::Body* Item = static_cast<PartDesign::BodyPy*>(object)->getBodyPtr();
|
||||
// Should be set!
|
||||
assert(Item);
|
||||
|
||||
// get the gui document of the Assembly Item
|
||||
if(ActivePartObject){
|
||||
|
||||
ActiveGuiDoc->signalHighlightObject(*ActiveVp,Gui::Blue,false);
|
||||
ActivePartObject = 0;
|
||||
|
||||
}
|
||||
ActivePartObject = Item;
|
||||
ActiveGuiDoc = Gui::Application::Instance->getDocument(Item->getDocument());
|
||||
ActiveAppDoc = Item->getDocument();
|
||||
ActiveGuiDoc = Gui::Application::Instance->getDocument(ActiveAppDoc);
|
||||
ActiveVp = dynamic_cast<Gui::ViewProviderDocumentObject*> (ActiveGuiDoc->getViewProvider(Item)) ;
|
||||
ActiveGuiDoc->signalHighlightObject(*ActiveVp,Gui::Underlined,true);
|
||||
|
||||
}else{
|
||||
ActiveGuiDoc->signalHighlightObject(*ActiveVp,Gui::Underlined,false);
|
||||
ActivePartObject = 0;
|
||||
}
|
||||
|
||||
Py_Return;
|
||||
|
||||
Reference in New Issue
Block a user