fixes in highlight code

This commit is contained in:
jriegel 2012-03-06 00:12:54 +01:00 committed by Stefan Tröger
parent 26afb6ee77
commit 72b49dbc6b
5 changed files with 28 additions and 11 deletions

View File

@ -1052,7 +1052,6 @@ void DocumentItem::slotHighlightObject (const Gui::ViewProviderDocumentObject& o
default: default:
break; break;
} }
jt->second->setFont(0,f); jt->second->setFont(0,f);
} }

View File

@ -28,6 +28,7 @@
#include <Base/Placement.h> #include <Base/Placement.h>
#include "Item.h" #include "Item.h"
#include "ItemPy.h"
using namespace Assembly; using namespace Assembly;
@ -62,4 +63,13 @@ App::DocumentObjectExecReturn *Item::execute(void)
return App::DocumentObject::StdReturn; return App::DocumentObject::StdReturn;
} }
PyObject *Item::getPyObject(void)
{
if (PythonObject.is(Py::_None())){
// ref counter is set to 1
PythonObject = Py::Object(new ItemPy(this),true);
}
return Py::new_reference_to(PythonObject);
}
} }

View File

@ -71,9 +71,11 @@ public:
return "AssemblyGui::ViewProviderItem"; return "AssemblyGui::ViewProviderItem";
} }
//@} //@}
PyObject *getPyObject(void);
}; };
} //namespace PartDesign } //namespace Assembly
#endif // PART_Item_H #endif // ASSEMBLY_Item_H

View File

@ -27,6 +27,7 @@
#endif #endif
#include <Base/Console.h> #include <Base/Console.h>
#include <Base/Interpreter.h>
#include <Gui/Application.h> #include <Gui/Application.h>
#include <Gui/Language/Translator.h> #include <Gui/Language/Translator.h>
#include "Workbench.h" #include "Workbench.h"
@ -67,6 +68,9 @@ void AssemblyGuiExport initAssemblyGui()
(void) Py_InitModule("AssemblyGui", AssemblyGui_Import_methods); /* mod name, table ptr */ (void) Py_InitModule("AssemblyGui", AssemblyGui_Import_methods); /* mod name, table ptr */
Base::Console().Log("Loading GUI of Assembly module... done\n"); Base::Console().Log("Loading GUI of Assembly module... done\n");
// directly load the module for usage in commands
Base::Interpreter().runString("import AssemblyGui");
// instanciating the commands // instanciating the commands
CreateAssemblyCommands(); CreateAssemblyCommands();
CreateAssemblyConstraintCommands(); CreateAssemblyConstraintCommands();

View File

@ -47,27 +47,29 @@ Gui::ViewProviderDocumentObject *ActiveVp =0;
static PyObject * setActiveAssembly(PyObject *self, PyObject *args) static PyObject * setActiveAssembly(PyObject *self, PyObject *args)
{ {
PyObject *object=0; PyObject *object=0;
if (PyArg_ParseTuple(args,"|O",&(Assembly::ItemPy::Type), &object)) { if (PyArg_ParseTuple(args,"|O!",&(Assembly::ItemPy::Type), &object)&& object) {
Assembly::Item* Item = static_cast<Assembly::ItemPy*>(object)->getItemPtr(); Assembly::Item* Item = static_cast<Assembly::ItemPy*>(object)->getItemPtr();
// Should be set! // Should be set!
assert(Item); assert(Item);
// get the gui document of the Assembly Item // get the gui document of the Assembly Item
Gui::Document* GuiDoc = Gui::Application::Instance->getDocument(Item->getDocument());
Gui::ViewProviderDocumentObject* vp = dynamic_cast<Gui::ViewProviderDocumentObject*> (GuiDoc->getViewProvider(Item)) ;
if(ActiveAsmObject){ if(ActiveAsmObject){
GuiDoc->signalHighlightObject(*vp,Gui::HiglightMode::None); ActiveGuiDoc->signalHighlightObject(*ActiveVp,Gui::None);
ActiveAsmObject = 0; ActiveAsmObject = 0;
} }
ActiveAsmObject = Item; ActiveAsmObject = Item;
//Gui::ViewProvider* vp = Gui::Application::Instance -> getViewProvider(ActiveAsmObject); ActiveGuiDoc = Gui::Application::Instance->getDocument(Item->getDocument());
//PyErr_SetString(PyExc_Exception, "empty shape"); ActiveVp = dynamic_cast<Gui::ViewProviderDocumentObject*> (ActiveGuiDoc->getViewProvider(Item)) ;
ActiveGuiDoc->signalHighlightObject(*ActiveVp,Gui::Blue);
}else{
ActiveGuiDoc->signalHighlightObject(*ActiveVp,Gui::None);
ActiveAsmObject = 0;
} }
return 0; Py_Return;
} }