diff --git a/src/App/Application.cpp b/src/App/Application.cpp index 655ef445e..d0b7e2c96 100644 --- a/src/App/Application.cpp +++ b/src/App/Application.cpp @@ -93,6 +93,7 @@ #include "MeasureDistance.h" #include "Placement.h" #include "Plane.h" +#include "MaterialObject.h" // If you stumble here, run the target "BuildExtractRevision" on Windows systems // or the Python script "SubWCRev.py" on Linux based systems which builds @@ -1044,6 +1045,7 @@ void Application::initTypes(void) App ::Annotation ::init(); App ::AnnotationLabel ::init(); App ::MeasureDistance ::init(); + App ::MaterialObject ::init(); App ::Placement ::init(); App ::Plane ::init(); } diff --git a/src/App/CMakeLists.txt b/src/App/CMakeLists.txt index c19c09f11..cbf116649 100644 --- a/src/App/CMakeLists.txt +++ b/src/App/CMakeLists.txt @@ -77,6 +77,7 @@ SET(Document_CPP_SRCS Plane.cpp Transactions.cpp VRMLObject.cpp + MaterialObject.cpp ) SET(Document_HPP_SRCS @@ -98,6 +99,7 @@ SET(Document_HPP_SRCS Plane.h Transactions.h VRMLObject.h + MaterialObject.h ) SET(Document_SRCS ${Document_CPP_SRCS} diff --git a/src/App/MaterialObject.cpp b/src/App/MaterialObject.cpp new file mode 100644 index 000000000..5d92a4220 --- /dev/null +++ b/src/App/MaterialObject.cpp @@ -0,0 +1,66 @@ +/*************************************************************************** + * Copyright (c) 2013 Jürgen Riegel (FreeCAD@juergen-riegel.net) * + * * + * 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" + +#ifndef _PreComp_ +#endif + +#include "MaterialObject.h" +#include "DocumentObjectPy.h" + +using namespace App; + +PROPERTY_SOURCE(App::MaterialObject, App::DocumentObject) + + +MaterialObject::MaterialObject() +{ + ADD_PROPERTY_TYPE(Material,(),"Material",Prop_None,"Material key/valu map"); + +} + +MaterialObject::~MaterialObject() +{ +} + +// Python feature --------------------------------------------------------- + +namespace App { +/// @cond DOXERR +PROPERTY_SOURCE_TEMPLATE(App::MaterialObjectPython, App::MaterialObject) +template<> const char* App::MaterialObjectPython::getViewProviderName(void) const { + return "Gui::ViewProviderMaterialObject"; +} +template<> PyObject* App::MaterialObjectPython::getPyObject(void) { + if (PythonObject.is(Py::_None())) { + // ref counter is set to 1 + PythonObject = Py::Object(new App::DocumentObjectPy(this),true); + } + return Py::new_reference_to(PythonObject); +} +/// @endcond + +// explicit template instantiation +template class AppExport FeaturePythonT; +} \ No newline at end of file diff --git a/src/App/MaterialObject.h b/src/App/MaterialObject.h new file mode 100644 index 000000000..23f22da16 --- /dev/null +++ b/src/App/MaterialObject.h @@ -0,0 +1,60 @@ +/*************************************************************************** + * Copyright (c) 2013 Jürgen Riegel (FreeCAD@juergen-riegel.net) * + * * + * 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 * + * * + ***************************************************************************/ + + +#ifndef APP_MaterialObject_H +#define APP_MaterialObject_H + +#include "DocumentObject.h" +#include "PropertyStandard.h" +#include "FeaturePython.h" + + +namespace App +{ + +class AppExport MaterialObject : public DocumentObject +{ + PROPERTY_HEADER(App::MaterialObject); + +public: + /// Constructor + MaterialObject(void); + virtual ~MaterialObject(); + + App::PropertyMap Material; + + + /// returns the type name of the ViewProvider + const char* getViewProviderName(void) const { + return "Gui::ViewProviderMaterialObject"; + } + +}; + +typedef App::FeaturePythonT MaterialObjectPython; + + +} //namespace App + + +#endif // APP_MaterialObject_H diff --git a/src/Gui/CMakeLists.txt b/src/Gui/CMakeLists.txt index 9c3d1641a..0a80f7b61 100644 --- a/src/Gui/CMakeLists.txt +++ b/src/Gui/CMakeLists.txt @@ -622,6 +622,7 @@ SET(Viewprovider_CPP_SRCS ViewProviderBuilder.cpp ViewProviderPlacement.cpp ViewProviderPlane.cpp + ViewProviderMaterialObject.cpp ) SET(Viewprovider_SRCS ${Viewprovider_CPP_SRCS} @@ -639,6 +640,7 @@ SET(Viewprovider_SRCS ViewProviderBuilder.h ViewProviderPlacement.h ViewProviderPlane.h + ViewProviderMaterialObject.h ) SOURCE_GROUP("View3D\\Viewprovider" FILES ${Viewprovider_SRCS}) diff --git a/src/Gui/ViewProviderMaterialObject.cpp b/src/Gui/ViewProviderMaterialObject.cpp new file mode 100644 index 000000000..508e51169 --- /dev/null +++ b/src/Gui/ViewProviderMaterialObject.cpp @@ -0,0 +1,87 @@ +/*************************************************************************** + * Copyright (c) 2006 Werner Mayer * + * * + * 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" + +#ifndef _PreComp_ +# include +# include +#endif + +#include +#include + +/// Here the FreeCAD includes sorted by Base,App,Gui...... +#include "ViewProviderMaterialObject.h" +#include "Application.h" +#include "Command.h" +#include "BitmapFactory.h" +#include "Document.h" +#include "Tree.h" + + +using namespace Gui; + + +PROPERTY_SOURCE(Gui::ViewProviderMaterialObject, Gui::ViewProviderDocumentObject) + + +/** + * Creates the view provider for an object group. + */ +ViewProviderMaterialObject::ViewProviderMaterialObject() +{ + +} + +ViewProviderMaterialObject::~ViewProviderMaterialObject() +{ +} + + + + +/** + * Returns the pixmap for the list item. + */ +QIcon ViewProviderMaterialObject::getIcon() const +{ + QIcon groupIcon; + groupIcon.addPixmap(QApplication::style()->standardPixmap(QStyle::SP_DirClosedIcon), + QIcon::Normal, QIcon::Off); + groupIcon.addPixmap(QApplication::style()->standardPixmap(QStyle::SP_DirOpenIcon), + QIcon::Normal, QIcon::On); + return groupIcon; +} + + +// Python feature ----------------------------------------------------------------------- + +namespace Gui { +/// @cond DOXERR +PROPERTY_SOURCE_TEMPLATE(Gui::ViewProviderMaterialObjectPython, Gui::ViewProviderMaterialObject) +/// @endcond + +// explicit template instantiation +template class GuiExport ViewProviderPythonFeatureT; +} diff --git a/src/Gui/ViewProviderMaterialObject.h b/src/Gui/ViewProviderMaterialObject.h new file mode 100644 index 000000000..50d19c70b --- /dev/null +++ b/src/Gui/ViewProviderMaterialObject.h @@ -0,0 +1,53 @@ +/*************************************************************************** + * Copyright (c) 2006 Werner Mayer * + * * + * 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 * + * * + ***************************************************************************/ + + +#ifndef GUI_VIEWPROVIDER_DOCUMENTOBJECTGROUP_H +#define GUI_VIEWPROVIDER_DOCUMENTOBJECTGROUP_H + + +#include "ViewProviderDocumentObject.h" +#include "ViewProviderPythonFeature.h" + +namespace Gui { + +class GuiExport ViewProviderMaterialObject : public ViewProviderDocumentObject +{ + PROPERTY_HEADER(Gui::ViewProviderMaterialObject); + +public: + /// constructor. + ViewProviderMaterialObject(); + /// destructor. + virtual ~ViewProviderMaterialObject(); + + QIcon getIcon(void) const; + + +}; + +typedef ViewProviderPythonFeatureT ViewProviderMaterialObjectPython; + +} // namespace Gui + +#endif // GUI_VIEWPROVIDER_DOCUMENTOBJECTGROUP_H +