diff --git a/src/Mod/Assembly/App/Item.cpp b/src/Mod/Assembly/App/Item.cpp index 0ca9126d8..b43225ac9 100644 --- a/src/Mod/Assembly/App/Item.cpp +++ b/src/Mod/Assembly/App/Item.cpp @@ -40,6 +40,7 @@ PROPERTY_SOURCE(Assembly::Item, Part::Feature) Item::Item() { ADD_PROPERTY(Id,(0)); + ADD_PROPERTY(Uid,(0)); ADD_PROPERTY(Name,(0)); ADD_PROPERTY(Description,(0)); } diff --git a/src/Mod/Assembly/App/Item.h b/src/Mod/Assembly/App/Item.h index 0dd7f9fe1..a57252630 100644 --- a/src/Mod/Assembly/App/Item.h +++ b/src/Mod/Assembly/App/Item.h @@ -38,9 +38,17 @@ class AssemblyExport Item : public Part::Feature public: Item(); + /** @name base properties of all Assembly Items */ + //@{ + /// Id e.g. Part number App::PropertyString Id; + /// unique identifier of the Item + App::PropertyUUID Uid; + /// Name of the Item (human readable) App::PropertyString Name ; + /// long description of the Item App::PropertyString Description ; + //@} /** @name methods override feature */ //@{ @@ -48,9 +56,9 @@ public: App::DocumentObjectExecReturn *execute(void); short mustExecute() const; /// returns the type name of the view provider - //const char* getViewProviderName(void) const { - // return "PartDesignGui::ViewProviderItem"; - //} + const char* getViewProviderName(void) const { + return "PartDesignGui::ViewProviderItem"; + } //@} }; diff --git a/src/Mod/Assembly/App/ItemAssembly.cpp b/src/Mod/Assembly/App/ItemAssembly.cpp index ce43002ec..e6210ca3b 100644 --- a/src/Mod/Assembly/App/ItemAssembly.cpp +++ b/src/Mod/Assembly/App/ItemAssembly.cpp @@ -23,9 +23,11 @@ #include "PreCompiled.h" #ifndef _PreComp_ +# include #endif #include +#include #include "ItemAssembly.h" @@ -52,8 +54,34 @@ short ItemAssembly::mustExecute() const App::DocumentObjectExecReturn *ItemAssembly::execute(void) { - + std::vector s; + std::vector obj = Items.getValues(); + + std::vector::iterator it; + for (it = obj.begin(); it != obj.end(); ++it) { + if ((*it)->getTypeId().isDerivedFrom(Assembly::Item::getClassTypeId())) { + s.push_back(static_cast(*it)->Shape.getValue()); + } + } + + if (s.size() > 0) { + TopoDS_Compound aRes = TopoDS_Compound(); + BRep_Builder aBuilder = BRep_Builder(); + aBuilder.MakeCompound(aRes); + + for (std::vector::iterator it = s.begin(); it != s.end(); ++it) { + + aBuilder.Add(aRes, *it); + } + if (aRes.IsNull()) + throw Base::Exception("Resulting shape is invalid"); + this->Shape.setValue(aRes); + } + else { + // set empty shape + this->Shape.setValue(TopoDS_Shape()); + } return App::DocumentObject::StdReturn; } -} \ No newline at end of file +} diff --git a/src/Mod/Assembly/App/ItemAssembly.h b/src/Mod/Assembly/App/ItemAssembly.h index 86b3ef242..35e822390 100644 --- a/src/Mod/Assembly/App/ItemAssembly.h +++ b/src/Mod/Assembly/App/ItemAssembly.h @@ -46,9 +46,9 @@ public: App::DocumentObjectExecReturn *execute(void); short mustExecute() const; /// returns the type name of the view provider - //const char* getViewProviderName(void) const { - // return "PartDesignGui::ViewProviderItemAssembly"; - //} + const char* getViewProviderName(void) const { + return "PartDesignGui::ViewProviderItemAssembly"; + } //@} }; diff --git a/src/Mod/Assembly/App/ItemPart.cpp b/src/Mod/Assembly/App/ItemPart.cpp index 85e1db9e1..3e909a295 100644 --- a/src/Mod/Assembly/App/ItemPart.cpp +++ b/src/Mod/Assembly/App/ItemPart.cpp @@ -52,7 +52,12 @@ short ItemPart::mustExecute() const App::DocumentObjectExecReturn *ItemPart::execute(void) { - + App::DocumentObject* obj = Model.getValue(); + + if (obj->getTypeId().isDerivedFrom(Part::Feature::getClassTypeId())) { + this->Shape.setValue(static_cast(obj)->Shape.getValue()); + } + return App::DocumentObject::StdReturn; } diff --git a/src/Mod/Assembly/Gui/CMakeLists.txt b/src/Mod/Assembly/Gui/CMakeLists.txt index 04734001b..6487b35f0 100644 --- a/src/Mod/Assembly/Gui/CMakeLists.txt +++ b/src/Mod/Assembly/Gui/CMakeLists.txt @@ -10,8 +10,10 @@ include_directories( ${Boost_INCLUDE_DIRS} ${COIN_INCLUDE_DIR} ${ZLIB_INCLUDE_DIR} + ${OCC_INCLUDE_DIR} ${QT_INCLUDE_DIR} ${PYTHON_INCLUDE_DIRS} + ${COIN3D_INCLUDE_DIRS} ${XercesC_INCLUDE_DIRS} #${ODE_INCLUDE_DIRS} ) @@ -19,22 +21,38 @@ include_directories( set(AssemblyGui_LIBS #${ODE_LIBRARIES} Assembly + PartGui FreeCADGui ) qt4_add_resources(AssemblyGui_SRCS Resources/Assembly.qrc) -SET(AssemblyGui_SRCS - ${AssemblyGui_SRCS} + +SET(AssemblyGuiViewProvider_SRCS + ViewProvider.cpp + ViewProvider.h +) +SOURCE_GROUP("ViewProvider" FILES ${AssemblyGuiViewProvider_SRCS}) + +SET(AssemblyGuiModule_SRCS AppAssemblyGui.cpp AppAssemblyGuiPy.cpp Command.cpp Resources/Assembly.qrc + qrc_Assembly.cxx PreCompiled.cpp PreCompiled.h Workbench.cpp Workbench.h ) +SOURCE_GROUP("Module" FILES ${AssemblyGuiModule_SRCS}) + + +SET(AssemblyGui_SRCS + ${AssemblyGui_SRCS} + ${AssemblyGuiViewProvider_SRCS} + ${AssemblyGuiModule_SRCS} +) add_library(AssemblyGui SHARED ${AssemblyGui_SRCS}) target_link_libraries(AssemblyGui ${AssemblyGui_LIBS}) diff --git a/src/Mod/Assembly/Gui/PreCompiled.h b/src/Mod/Assembly/Gui/PreCompiled.h index 402f58d47..3fe37f681 100644 --- a/src/Mod/Assembly/Gui/PreCompiled.h +++ b/src/Mod/Assembly/Gui/PreCompiled.h @@ -29,9 +29,11 @@ // Importing of App classes #ifdef FC_OS_WIN32 # define AssemblyAppExport __declspec(dllimport) +# define PartGuiExport __declspec(dllimport) # define AssemblyGuiExport __declspec(dllexport) #else // for Linux # define AssemblyAppExport +# define PartGuiExport # define AssemblyGuiExport #endif diff --git a/src/Mod/Assembly/Gui/ViewProvider.cpp b/src/Mod/Assembly/Gui/ViewProvider.cpp new file mode 100644 index 000000000..8193335ab --- /dev/null +++ b/src/Mod/Assembly/Gui/ViewProvider.cpp @@ -0,0 +1,50 @@ +/*************************************************************************** + * Copyright (c) 2011 Juergen Riegel * + * * + * 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 "ViewProvider.h" +#include +//#include + +using namespace AssemblyGui; + +PROPERTY_SOURCE(AssemblyGui::ViewProvider,PartGui::ViewProviderPart) + +ViewProvider::ViewProvider() +{ +} + +ViewProvider::~ViewProvider() +{ +} + +bool ViewProvider::doubleClicked(void) +{ + return true; +} + + diff --git a/src/Mod/Assembly/Gui/ViewProvider.h b/src/Mod/Assembly/Gui/ViewProvider.h new file mode 100644 index 000000000..8f75eb8a4 --- /dev/null +++ b/src/Mod/Assembly/Gui/ViewProvider.h @@ -0,0 +1,51 @@ +/*************************************************************************** + * Copyright (c) 2011 Juergen Riegel * + * * + * 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 PARTGUI_ViewProvider_H +#define PARTGUI_ViewProvider_H + +#include + + +namespace AssemblyGui { + +class AssemblyGuiExport ViewProvider : public PartGui::ViewProviderPart +{ + PROPERTY_HEADER(PartGui::ViewProvider); + +public: + /// constructor + ViewProvider(); + /// destructor + virtual ~ViewProvider(); + + virtual bool doubleClicked(void); + +}; + + + +} // namespace AssemblyGui + + +#endif // PARTGUI_ViewProviderHole_H