getActivePart() python function as complement to setActivePart()
This commit is contained in:
parent
f7874306b9
commit
5c18e947e6
|
@ -78,10 +78,22 @@ static PyObject * setActivePart(PyObject *self, PyObject *args)
|
|||
|
||||
Py_Return;
|
||||
}
|
||||
static PyObject * getActivePart(PyObject *, PyObject *)
|
||||
{
|
||||
if (PartDesignGui::ActivePartObject == NULL) {
|
||||
return Py::_None();
|
||||
}
|
||||
|
||||
return PartDesignGui::ActivePartObject->getPyObject();
|
||||
}
|
||||
|
||||
/* registration table */
|
||||
struct PyMethodDef Assembly_methods[] = {
|
||||
{"setActivePart" ,setActivePart ,METH_VARARGS,
|
||||
"setActivePart(BodyObject) -- Set the PartBody object in work."},
|
||||
|
||||
{"getActivePart" ,getActivePart ,METH_NOARGS,
|
||||
"getActivePart() -- Get the PartBody object in work."},
|
||||
|
||||
{NULL, NULL} /* end of table marker */
|
||||
};
|
||||
|
|
|
@ -22,31 +22,33 @@
|
|||
|
||||
|
||||
#include "PreCompiled.h"
|
||||
#ifndef _PreComp_
|
||||
# include <Python.h>
|
||||
#ifndef _PreComp_
|
||||
# include <Python.h>
|
||||
#endif
|
||||
|
||||
<<<<<<< 8ef3abc971814e64ef79a85812dd1a5827ba955f:src/Mod/Assembly/App/AppAssemblyPy.cpp
|
||||
/* registration table */
|
||||
struct PyMethodDef Assembly_methods[] = {
|
||||
{NULL, NULL} /* end of table marker */
|
||||
=======
|
||||
#include <Base/PyObjectBase.h>
|
||||
#include <Base/Console.h>
|
||||
|
||||
#include <Gui/Application.h>
|
||||
#include <Gui/Document.h>
|
||||
#include <Gui/Tree.h>
|
||||
#include <Gui/ViewProviderDocumentObject.h>
|
||||
|
||||
#include <Mod/PartDesign/App/BodyPy.h>
|
||||
|
||||
#include "ViewProviderBody.h"
|
||||
|
||||
namespace PartDesignGui {
|
||||
|
||||
// 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;
|
||||
|
||||
// The names of the base planes. Note: The user-visible label is different from this
|
||||
const char* BaseplaneNames[3] = {"BaseplaneXY", "BaseplaneXZ", "BaseplaneYZ"};
|
||||
|
||||
}
|
||||
|
||||
static PyObject * setActivePart(PyObject *self, PyObject *args)
|
||||
{
|
||||
|
@ -56,31 +58,50 @@ static PyObject * setActivePart(PyObject *self, PyObject *args)
|
|||
// 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());
|
||||
ActiveVp = dynamic_cast<Gui::ViewProviderDocumentObject*> (ActiveGuiDoc->getViewProvider(Item)) ;
|
||||
ActiveGuiDoc->signalHighlightObject(*ActiveVp,Gui::Blue,true);
|
||||
|
||||
}else{
|
||||
ActiveGuiDoc->signalHighlightObject(*ActiveVp,Gui::Blue,false);
|
||||
ActivePartObject = 0;
|
||||
// Set old body inactive if we are activating another body in the same document
|
||||
if ((PartDesignGui::ActivePartObject != NULL) &&
|
||||
(PartDesignGui::ActivePartObject->getDocument() == Item->getDocument()))
|
||||
PartDesignGui::ActivePartObject->IsActive.setValue(false);
|
||||
PartDesignGui::ActivePartObject = Item;
|
||||
PartDesignGui::ActiveAppDoc = Item->getDocument();
|
||||
PartDesignGui::ActiveGuiDoc = Gui::Application::Instance->getDocument(PartDesignGui::ActiveAppDoc);
|
||||
PartDesignGui::ActiveVp = dynamic_cast<Gui::ViewProviderDocumentObject*> (PartDesignGui::ActiveGuiDoc->getViewProvider(Item));
|
||||
PartDesignGui::ActiveVp->show();
|
||||
Item->IsActive.setValue(true);
|
||||
} else {
|
||||
// This handles the case of deactivating the workbench
|
||||
PartDesignGui::ActivePartObject=0;
|
||||
PartDesignGui::ActiveGuiDoc =0;
|
||||
PartDesignGui::ActiveAppDoc =0;
|
||||
PartDesignGui::ActiveVp =0;
|
||||
}
|
||||
|
||||
Py_Return;
|
||||
}
|
||||
<<<<<<< 35072e8d22a22eaf711a74958d47b351d55292ae:src/Mod/Assembly/App/AppAssemblyPy.cpp
|
||||
=======
|
||||
|
||||
static PyObject * getActivePart(PyObject *, PyObject *)
|
||||
{
|
||||
if (PartDesignGui::ActivePartObject == NULL) {
|
||||
return Py::_None();
|
||||
}
|
||||
|
||||
return PartDesignGui::ActivePartObject->getPyObject();
|
||||
}
|
||||
|
||||
>>>>>>> getActivePart() python function as complement to setActivePart():src/Mod/PartDesign/Gui/AppPartDesignGuiPy.cpp
|
||||
/* registration table */
|
||||
struct PyMethodDef PartDesignGui_Import_methods[] = {
|
||||
struct PyMethodDef Assembly_methods[] = {
|
||||
{"setActivePart" ,setActivePart ,METH_VARARGS,
|
||||
"setActivePart(BodyObject) -- Set the PartBody object in work."},
|
||||
|
||||
<<<<<<< 35072e8d22a22eaf711a74958d47b351d55292ae:src/Mod/Assembly/App/AppAssemblyPy.cpp
|
||||
{NULL, NULL} /* end of table marker */
|
||||
=======
|
||||
{"getActivePart" ,getActivePart ,METH_NOARGS,
|
||||
"getActivePart() -- Get the PartBody object in work."},
|
||||
|
||||
{NULL, NULL} /* end of table marker */
|
||||
>>>>>>> implement active body in PartDesign:src/Mod/PartDesign/Gui/AppPartDesignGuiPy.cpp
|
||||
>>>>>>> getActivePart() python function as complement to setActivePart():src/Mod/PartDesign/Gui/AppPartDesignGuiPy.cpp
|
||||
};
|
||||
|
|
Loading…
Reference in New Issue
Block a user