Fix bug in switching active Part/Assembly object when document with active one was closed

This commit is contained in:
jriegel 2012-08-23 17:14:56 +02:00 committed by Stefan Tröger
parent b08b2f6140
commit 2403af2e6c
4 changed files with 41 additions and 34 deletions

View File

@ -102,9 +102,6 @@ TaskWatcherCommands::TaskWatcherCommands(const char* Filter,const char* commands
Content.push_back(tb);
}
TaskWatcherCommands::~TaskWatcherCommands()
{
}
//==== implementer ===========================================================================
@ -128,9 +125,7 @@ TaskWatcherCommandsEmptyDoc::TaskWatcherCommandsEmptyDoc(const char* commands[],
{
}
TaskWatcherCommandsEmptyDoc::~TaskWatcherCommandsEmptyDoc()
{
}
//==== implementer ===========================================================================

View File

@ -48,7 +48,7 @@ class GuiExport TaskWatcher : public QObject, public Gui::SelectionFilter
public:
TaskWatcher(const char* Filter);
~TaskWatcher();
virtual ~TaskWatcher();
std::vector<QWidget*> &getWatcherContent(void);
@ -71,7 +71,6 @@ class GuiExport TaskWatcherCommands : public TaskWatcher
public:
TaskWatcherCommands(const char* Filter,const char* commands[], const char* name, const char* pixmap);
~TaskWatcherCommands();
public:
/// is called wenn the document or the Selection changes.
@ -88,7 +87,6 @@ class GuiExport TaskWatcherCommandsEmptyDoc : public TaskWatcherCommands
public:
TaskWatcherCommandsEmptyDoc(const char* commands[], const char* name, const char* pixmap);
~TaskWatcherCommandsEmptyDoc();
public:
/// is called wenn the document or the Selection changes.

View File

@ -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;

View File

@ -39,13 +39,29 @@
// pointer to the active assembly object
Assembly::Item *ActiveAsmObject =0;
Gui::Document *ActiveGuiDoc =0;
App::Document *ActiveAppDoc =0;
Gui::ViewProviderDocumentObject *ActiveVp =0;
/* module functions */
static PyObject * setActiveAssembly(PyObject *self, PyObject *args)
{
{
if(ActiveAsmObject){
// 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::Blue,false);
break;
}
ActiveAsmObject = 0;
ActiveGuiDoc =0;
ActiveAppDoc =0;
ActiveVp =0;
}
PyObject *object=0;
if (PyArg_ParseTuple(args,"|O!",&(Assembly::ItemPy::Type), &object)&& object) {
Assembly::Item* Item = static_cast<Assembly::ItemPy*>(object)->getItemPtr();
@ -53,20 +69,11 @@ static PyObject * setActiveAssembly(PyObject *self, PyObject *args)
assert(Item);
// get the gui document of the Assembly Item
if(ActiveAsmObject){
ActiveGuiDoc->signalHighlightObject(*ActiveVp,Gui::Blue,false);
ActiveAsmObject = 0;
}
ActiveAsmObject = 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::Blue,true);
}else{
ActiveGuiDoc->signalHighlightObject(*ActiveVp,Gui::Blue,false);
ActiveAsmObject = 0;
}
Py_Return;