From 8f11dc549278c55511d85db14f4c731a521f530d Mon Sep 17 00:00:00 2001 From: jriegel Date: Sat, 19 May 2012 19:39:38 +0200 Subject: [PATCH] start Constraints --- src/Mod/Assembly/App/ItemAssembly.h | 1 + src/Mod/Assembly/Gui/CMakeLists.txt | 2 + src/Mod/Assembly/Gui/ViewProviderAssembly.cpp | 7 +- .../Gui/ViewProviderConstraintGroup.cpp | 95 +++++++++++++++++++ .../Gui/ViewProviderConstraintGroup.h | 59 ++++++++++++ 5 files changed, 162 insertions(+), 2 deletions(-) create mode 100644 src/Mod/Assembly/Gui/ViewProviderConstraintGroup.cpp create mode 100644 src/Mod/Assembly/Gui/ViewProviderConstraintGroup.h diff --git a/src/Mod/Assembly/App/ItemAssembly.h b/src/Mod/Assembly/App/ItemAssembly.h index 5d7a882c8..156f1f6d8 100644 --- a/src/Mod/Assembly/App/ItemAssembly.h +++ b/src/Mod/Assembly/App/ItemAssembly.h @@ -39,6 +39,7 @@ public: ItemAssembly(); App::PropertyLinkList Items; + App::PropertyLinkList Annotations; /** @name methods override feature */ //@{ diff --git a/src/Mod/Assembly/Gui/CMakeLists.txt b/src/Mod/Assembly/Gui/CMakeLists.txt index 21be6e185..b28a58e02 100644 --- a/src/Mod/Assembly/Gui/CMakeLists.txt +++ b/src/Mod/Assembly/Gui/CMakeLists.txt @@ -35,6 +35,8 @@ SET(AssemblyGuiViewProvider_SRCS ViewProviderPart.h ViewProviderAssembly.cpp ViewProviderAssembly.h + ViewProviderConstraintGroup.cpp + ViewProviderConstraintGroup.h ) SOURCE_GROUP("ViewProvider" FILES ${AssemblyGuiViewProvider_SRCS}) diff --git a/src/Mod/Assembly/Gui/ViewProviderAssembly.cpp b/src/Mod/Assembly/Gui/ViewProviderAssembly.cpp index 49fe6fa71..ca1d578d3 100644 --- a/src/Mod/Assembly/Gui/ViewProviderAssembly.cpp +++ b/src/Mod/Assembly/Gui/ViewProviderAssembly.cpp @@ -84,9 +84,12 @@ std::vector ViewProviderItemAssembly::getDisplayModes(void) const std::vector ViewProviderItemAssembly::claimChildren(void)const { + std::vector temp(static_cast(getObject())->Items.getValues()); + temp.insert(temp.end(), + static_cast(getObject())->Annotations.getValues().begin(), + static_cast(getObject())->Annotations.getValues().end()); - return static_cast(getObject())->Items.getValues(); - + return temp; } std::vector ViewProviderItemAssembly::claimChildren3D(void)const diff --git a/src/Mod/Assembly/Gui/ViewProviderConstraintGroup.cpp b/src/Mod/Assembly/Gui/ViewProviderConstraintGroup.cpp new file mode 100644 index 000000000..02bab39c4 --- /dev/null +++ b/src/Mod/Assembly/Gui/ViewProviderConstraintGroup.cpp @@ -0,0 +1,95 @@ +/*************************************************************************** + * Copyright (c) 2012 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_ +# include +#endif + +#include "ViewProviderConstraintGroup.h" +#include +#include + +#include + +using namespace AssemblyGui; + +PROPERTY_SOURCE(AssemblyGui::ViewProviderConstraintGroup,Gui::ViewProviderDocumentObject) + +ViewProviderConstraintGroup::ViewProviderConstraintGroup() +{ +} + +ViewProviderConstraintGroup::~ViewProviderConstraintGroup() +{ +} + +bool ViewProviderConstraintGroup::doubleClicked(void) +{ + return false; +} + +void ViewProviderConstraintGroup::attach(App::DocumentObject *pcFeat) +{ + // call parent attach method + ViewProviderDocumentObject::attach(pcFeat); + + + // putting all together with the switch + addDisplayMaskMode(getChildRoot(), "Main"); +} + +void ViewProviderConstraintGroup::setDisplayMode(const char* ModeName) +{ + if ( strcmp("Main",ModeName)==0 ) + setDisplayMaskMode("Main"); + + ViewProviderDocumentObject::setDisplayMode( ModeName ); +} + +std::vector ViewProviderConstraintGroup::getDisplayModes(void) const +{ + // get the modes of the father + std::vector StrList = ViewProviderDocumentObject::getDisplayModes(); + + // add your own modes + StrList.push_back("Main"); + + return StrList; +} + + +std::vector ViewProviderConstraintGroup::claimChildren(void)const +{ + std::vector temp(static_cast(getObject())->Constraints.getValues()); + + return temp; +} + +std::vector ViewProviderConstraintGroup::claimChildren3D(void)const +{ + + //return static_cast(getObject())->Constraints.getValues(); + return std::vector (); +} diff --git a/src/Mod/Assembly/Gui/ViewProviderConstraintGroup.h b/src/Mod/Assembly/Gui/ViewProviderConstraintGroup.h new file mode 100644 index 000000000..dabcb2af9 --- /dev/null +++ b/src/Mod/Assembly/Gui/ViewProviderConstraintGroup.h @@ -0,0 +1,59 @@ +/*************************************************************************** + * Copyright (c) 2012 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 ASSEMBLYGUI_ViewProviderConstraintGroup_H +#define ASSEMBLYGUI_ViewProviderConstraintGroup_H + +#include + + +namespace AssemblyGui { + +class AssemblyGuiExport ViewProviderConstraintGroup : public Gui::ViewProviderDocumentObject +{ + PROPERTY_HEADER(PartGui::ViewProviderConstraintGroup); + +public: + /// constructor + ViewProviderConstraintGroup(); + /// destructor + virtual ~ViewProviderConstraintGroup(); + + virtual bool doubleClicked(void); + virtual void attach(App::DocumentObject *); + virtual void setDisplayMode(const char* ModeName); + /// returns a list of all possible modes + virtual std::vector getDisplayModes(void) const; + + virtual std::vector claimChildren(void)const; + + virtual std::vector claimChildren3D(void)const; + +}; + + + +} // namespace AssemblyGui + + +#endif // ASSEMBLYGUI_ViewProviderAssembly_H