PartPesign: Py: expose some methods of ViewProvider
* setBodyMode(bool) * makeTemporaryVisible(bool)
This commit is contained in:
parent
0160478242
commit
1ee6dcf75e
|
@ -18,6 +18,9 @@ include_directories(
|
|||
)
|
||||
link_directories(${OCC_LIBRARY_DIR})
|
||||
|
||||
generate_from_xml(ViewProviderPy)
|
||||
|
||||
|
||||
set(PartDesignGui_LIBS
|
||||
PartDesign
|
||||
SketcherGui
|
||||
|
@ -252,6 +255,14 @@ SET(PartDesignGuiModule_SRCS
|
|||
)
|
||||
SOURCE_GROUP("Module" FILES ${PartDesignGuiModule_SRCS})
|
||||
|
||||
|
||||
SET(Python_SRCS
|
||||
ViewProviderPy.xml
|
||||
ViewProviderPyImp.cpp
|
||||
)
|
||||
SOURCE_GROUP("Python" FILES ${Python_SRCS})
|
||||
|
||||
|
||||
SET(PartDesignGui_Scripts
|
||||
InitGui.py
|
||||
TestPartDesignGui.py
|
||||
|
@ -263,6 +274,7 @@ SET(PartDesignGui_SRCS
|
|||
${PartDesignGuiModule_SRCS}
|
||||
${PartDesignGuiTaskDlgs_SRCS}
|
||||
${PartDesignGuiViewProvider_SRCS}
|
||||
${Python_SRCS}
|
||||
)
|
||||
|
||||
add_library(PartDesignGui SHARED ${PartDesignGui_SRCS})
|
||||
|
|
|
@ -40,6 +40,7 @@
|
|||
#include "TaskFeatureParameters.h"
|
||||
|
||||
#include "ViewProvider.h"
|
||||
#include "ViewProviderPy.h"
|
||||
|
||||
using namespace PartDesignGui;
|
||||
|
||||
|
@ -252,6 +253,14 @@ void ViewProvider::makeTemporaryVisible(bool onoff)
|
|||
Gui::ViewProvider::hide();
|
||||
}
|
||||
|
||||
PyObject* ViewProvider::getPyObject()
|
||||
{
|
||||
if (!pyViewObject)
|
||||
pyViewObject = new ViewProviderPy(this);
|
||||
pyViewObject->IncRef();
|
||||
return pyViewObject;
|
||||
}
|
||||
|
||||
|
||||
namespace Gui {
|
||||
/// @cond DOXERR
|
||||
|
|
|
@ -60,6 +60,8 @@ public:
|
|||
//document and properties.
|
||||
void makeTemporaryVisible(bool);
|
||||
|
||||
virtual PyObject* getPyObject(void);
|
||||
|
||||
protected:
|
||||
virtual bool setEdit(int ModNum);
|
||||
virtual void unsetEdit(int ModNum);
|
||||
|
|
33
src/Mod/PartDesign/Gui/ViewProviderPy.xml
Normal file
33
src/Mod/PartDesign/Gui/ViewProviderPy.xml
Normal file
|
@ -0,0 +1,33 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<GenerateModel xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="generateMetaModel_Module.xsd">
|
||||
<PythonExport
|
||||
Father="ViewProviderDocumentObjectPy"
|
||||
Name="ViewProviderPy"
|
||||
Twin="ViewProvider"
|
||||
TwinPointer="ViewProvider"
|
||||
Include="Mod/PartDesign/Gui/ViewProvider.h"
|
||||
Namespace="PartDesignGui"
|
||||
FatherInclude="Gui/ViewProviderDocumentObjectPy.h"
|
||||
FatherNamespace="Gui">
|
||||
<Documentation>
|
||||
<Author Licence="LGPL" Name="Juergen Riegel" EMail="FreeCAD@juergen-riegel.net" />
|
||||
<UserDocu>This is the father of all PartDesign ViewProvider classes</UserDocu>
|
||||
</Documentation>
|
||||
<Methode Name="setBodyMode">
|
||||
<Documentation>
|
||||
<UserDocu>setBodyMode(bool): body mode means that the object is part of a body
|
||||
and that the body is used to set the visual properties, not the features. Hence
|
||||
setting body mode to true will hide most viewprovider properties.</UserDocu>
|
||||
</Documentation>
|
||||
</Methode>
|
||||
<Methode Name="makeTemporaryVisible">
|
||||
<Documentation>
|
||||
<UserDocu>makeTemporaryVisible(bool): makes this viewprovider visible in the
|
||||
scene graph without changing any properties, not the visibility one and also not
|
||||
the display mode. This can be used to show the shape of this viewprovider from
|
||||
other viewproviders without doing anything to the document and properties.
|
||||
</UserDocu>
|
||||
</Documentation>
|
||||
</Methode>
|
||||
</PythonExport>
|
||||
</GenerateModel>
|
74
src/Mod/PartDesign/Gui/ViewProviderPyImp.cpp
Normal file
74
src/Mod/PartDesign/Gui/ViewProviderPyImp.cpp
Normal file
|
@ -0,0 +1,74 @@
|
|||
/***************************************************************************
|
||||
* Copyright (c) 2017 Victor Titov (DeepSOIC) <vv.titov@gmail.com> *
|
||||
* *
|
||||
* This file is part of the FreeCAD CAx development system. *
|
||||
* *
|
||||
* This library is free software; you can redistribute it and/or *
|
||||
* modify it under the terms of the GNU Library General Public *
|
||||
* License as published by the Free Software Foundation; either *
|
||||
* version 2 of the License, or (at your option) any later version. *
|
||||
* *
|
||||
* This library is distributed in the hope that it will be useful, *
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
||||
* GNU Library General Public License for more details. *
|
||||
* *
|
||||
* You should have received a copy of the GNU Library General Public *
|
||||
* License along with this library; see the file COPYING.LIB. If not, *
|
||||
* write to the Free Software Foundation, Inc., 59 Temple Place, *
|
||||
* Suite 330, Boston, MA 02111-1307, USA *
|
||||
* *
|
||||
***************************************************************************/
|
||||
|
||||
|
||||
#include "PreCompiled.h"
|
||||
|
||||
#include "ViewProvider.h"
|
||||
|
||||
// inclusion of the generated files (generated out of ViewProviderPy.xml)
|
||||
#include "ViewProviderPy.h"
|
||||
#include "ViewProviderPy.cpp"
|
||||
|
||||
using namespace PartDesignGui;
|
||||
|
||||
// returns a string which represent the object e.g. when printed in python
|
||||
std::string ViewProviderPy::representation(void) const
|
||||
{
|
||||
return std::string("<PartDesign::ViewProvider>");
|
||||
}
|
||||
|
||||
PyObject *ViewProviderPy::getCustomAttributes(const char* ) const
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
int ViewProviderPy::setCustomAttributes(const char* , PyObject *)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
PyObject* ViewProviderPy::setBodyMode(PyObject* args)
|
||||
{
|
||||
PartDesignGui::ViewProvider* base = getViewProviderPtr();
|
||||
|
||||
PyObject* b_mode;
|
||||
if(PyArg_ParseTuple(args, "O!", &PyBool_Type, &b_mode)){
|
||||
base->setBodyMode(PyObject_IsTrue(b_mode));
|
||||
return Py::new_reference_to(Py::None());
|
||||
};
|
||||
|
||||
return nullptr; //error
|
||||
}
|
||||
|
||||
PyObject* ViewProviderPy::makeTemporaryVisible(PyObject* args)
|
||||
{
|
||||
PartDesignGui::ViewProvider* base = getViewProviderPtr();
|
||||
|
||||
PyObject* b_vis;
|
||||
if(PyArg_ParseTuple(args, "O!", &PyBool_Type, &b_vis)){
|
||||
base->makeTemporaryVisible(PyObject_IsTrue(b_vis));
|
||||
return Py::new_reference_to(Py::None());
|
||||
};
|
||||
|
||||
return nullptr; //error
|
||||
}
|
Loading…
Reference in New Issue
Block a user