From 4e5b328500d754a287a25bc737d12c93afb20b8a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20M=C3=B6bius?= Date: Tue, 8 Dec 2009 09:00:30 +0000 Subject: [PATCH] Resturucture some includes to make BaseObjects QObjects git-svn-id: http://www.openflipper.org/svnrepo/OpenFlipper/branches/Free@7782 383ad7c9-94d9-4d36-a494-682f7c89f535 --- Core/Core.cc | 3 +- common/BaseObject.cc | 6 +- common/BaseObject.hh | 7 +- common/BaseObjectCore.hh | 65 ++++++++++++ common/BaseObjectData.cc | 1 + common/BaseObjectData.hh | 5 +- common/DataTypes.hh | 212 +++++++++++++++++++++++++++++++++++++++ common/GroupObject.hh | 1 + common/Types.cc | 2 +- common/Types.hh | 144 +------------------------- common/TypesInternal.hh | 147 +++++++++++++-------------- 11 files changed, 374 insertions(+), 219 deletions(-) create mode 100644 common/BaseObjectCore.hh create mode 100644 common/DataTypes.hh diff --git a/Core/Core.cc b/Core/Core.cc index 431d13b1..5d91b616 100644 --- a/Core/Core.cc +++ b/Core/Core.cc @@ -100,7 +100,8 @@ #include -#include "OpenFlipper/common/TypesInternal.hh" +#include +#include #define WIDGET_HEIGHT 800 #define WIDGET_WIDTH 800 diff --git a/common/BaseObject.cc b/common/BaseObject.cc index 2a489d84..d06896b0 100644 --- a/common/BaseObject.cc +++ b/common/BaseObject.cc @@ -54,6 +54,7 @@ //== INCLUDES ================================================================= +#include "BaseObjectCore.hh" #include "Types.hh" #include @@ -67,7 +68,9 @@ */ static int idGenerator = 1; -BaseObject::BaseObject(const BaseObject& _object) { +BaseObject::BaseObject(const BaseObject& _object) : + QObject() +{ id_ = idGenerator; ++idGenerator; persistentId_ = _object.persistentId_; @@ -90,6 +93,7 @@ BaseObject::BaseObject(const BaseObject& _object) { } BaseObject::BaseObject(BaseObject* _parent) : + QObject() , id_(-1), persistentId_(-1), objectType_(DATA_UNKNOWN), diff --git a/common/BaseObject.hh b/common/BaseObject.hh index b0c3e804..8ddb8c33 100644 --- a/common/BaseObject.hh +++ b/common/BaseObject.hh @@ -61,6 +61,8 @@ //== INCLUDES ================================================================= #include +#include +#include #include #include #include @@ -77,7 +79,10 @@ * This is the basic Data class providing the functions common to all objects. * If the Datacontrol Plugin is available, a Tree structure will be generated allowing groups of objects. */ -class DLLEXPORTONLY BaseObject { +class DLLEXPORTONLY BaseObject : public QObject { + + Q_OBJECT + friend class BaseObjectData; public : diff --git a/common/BaseObjectCore.hh b/common/BaseObjectCore.hh new file mode 100644 index 00000000..58fb8db7 --- /dev/null +++ b/common/BaseObjectCore.hh @@ -0,0 +1,65 @@ +/*===========================================================================*\ + * * + * OpenFlipper * + * Copyright (C) 2001-2009 by Computer Graphics Group, RWTH Aachen * + * www.openflipper.org * + * * + *---------------------------------------------------------------------------* + * This file is part of OpenFlipper. * + * * + * OpenFlipper is free software: you can redistribute it and/or modify * + * it under the terms of the GNU Lesser General Public License as * + * published by the Free Software Foundation, either version 3 of * + * the License, or (at your option) any later version with the * + * following exceptions: * + * * + * If other files instantiate templates or use macros * + * or inline functions from this file, or you compile this file and * + * link it with other files to produce an executable, this file does * + * not by itself cause the resulting executable to be covered by the * + * GNU Lesser General Public License. This exception does not however * + * invalidate any other reasons why the executable file might be * + * covered by the GNU Lesser General Public License. * + * * + * OpenFlipper 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 Lesser General Public License for more details. * + * * + * You should have received a copy of the GNU LesserGeneral Public * + * License along with OpenFlipper. If not, * + * see . * + * * +\*===========================================================================*/ + +/*===========================================================================*\ + * * + * $Revision: 6727 $ * + * $Author: moebius $ * + * $Date: 2009-08-05 08:03:50 +0200 (Mi, 05. Aug 2009) $ * + * * +\*===========================================================================*/ + + + + +//============================================================================= +// +// Types +// +//============================================================================= + +/** + * \file BaseObjectCore.hh + * This File contains the Basic object handling only used by the Core + */ + + +#ifndef BASEOBJECTCORE_HH +#define BASEOBJECTCORE_HH + +#include + +//============================================================================= +#endif // BASEOBJECTCORE_HH defined +//============================================================================= diff --git a/common/BaseObjectData.cc b/common/BaseObjectData.cc index bb65c357..36bba4df 100644 --- a/common/BaseObjectData.cc +++ b/common/BaseObjectData.cc @@ -54,6 +54,7 @@ #include "Types.hh" #include #include +#include //== TYPEDEFS ================================================================= diff --git a/common/BaseObjectData.hh b/common/BaseObjectData.hh index 5d7d2a91..f2542a7a 100644 --- a/common/BaseObjectData.hh +++ b/common/BaseObjectData.hh @@ -63,7 +63,8 @@ //== INCLUDES ================================================================= #include -#include "BaseObject.hh" +#include +#include #include #include #include @@ -96,6 +97,8 @@ typedef ACG::SceneGraph::StencilRefNode StencilRefNode; */ class DLLEXPORT BaseObjectData : public BaseObject { + Q_OBJECT + public: /** \brief copy constructor diff --git a/common/DataTypes.hh b/common/DataTypes.hh new file mode 100644 index 00000000..cd835a7d --- /dev/null +++ b/common/DataTypes.hh @@ -0,0 +1,212 @@ +/*===========================================================================*\ + * * + * OpenFlipper * + * Copyright (C) 2001-2009 by Computer Graphics Group, RWTH Aachen * + * www.openflipper.org * + * * + *---------------------------------------------------------------------------* + * This file is part of OpenFlipper. * + * * + * OpenFlipper is free software: you can redistribute it and/or modify * + * it under the terms of the GNU Lesser General Public License as * + * published by the Free Software Foundation, either version 3 of * + * the License, or (at your option) any later version with the * + * following exceptions: * + * * + * If other files instantiate templates or use macros * + * or inline functions from this file, or you compile this file and * + * link it with other files to produce an executable, this file does * + * not by itself cause the resulting executable to be covered by the * + * GNU Lesser General Public License. This exception does not however * + * invalidate any other reasons why the executable file might be * + * covered by the GNU Lesser General Public License. * + * * + * OpenFlipper 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 Lesser General Public License for more details. * + * * + * You should have received a copy of the GNU LesserGeneral Public * + * License along with OpenFlipper. If not, * + * see . * + * * +\*===========================================================================*/ + +/*===========================================================================*\ + * * + * $Revision: 7697 $ * + * $Author: moebius $ * + * $Date: 2009-11-30 17:40:00 +0100 (Mo, 30. Nov 2009) $ * + * * +\*===========================================================================*/ + + + + +//============================================================================= +// +// Types +// +//============================================================================= + +/** + * \file DataTypes.hh + * This File contains the basic type informations + */ + + +#ifndef DATATYPES_HH +#define DATATYPES_HH + +//== includes ================================================================= + + +#include + +#include +#include +#include +#include +#include + +//== Global Typedefs ================================================================= + +/** \brief Predefined datatypes +* +* Here are several datatypes which have predefined ids. This might be changed to runtime added +* datatypes in the future. +*/ + +/// None of the other Objects +#define DATA_UNKNOWN 0 + +/// Items used for Grouping +#define DATA_GROUP 1 + +/// Triangle Mesh objects +#define DATA_TRIANGLE_MESH typeId("TriangleMesh") +#define DATA_TRIANGLE_MESH_CONST_ID 2 + +/// Poly Mesh Objects +#define DATA_POLY_MESH typeId("PolyMesh") +#define DATA_POLY_MESH_CONST_ID 4 + +/// Identifier for all available objects +const unsigned int DATA_ALL = UINT_MAX; + +typedef unsigned int DataType; + + +//== TYPEDEFS ================================================================= + +/// Standard Type for 3d Vector used for scripting +typedef ACG::Vec3d Vector; +/// Standard Type for id Lists used for scripting +typedef std::vector< int > idList; +/// Standard Type for a 4x4 Matrix used for scripting +typedef ACG::Matrix4x4d Matrix4x4; + +Q_DECLARE_METATYPE(idList); +Q_DECLARE_METATYPE(QVector< int >); +Q_DECLARE_METATYPE(Vector); +Q_DECLARE_METATYPE(Matrix4x4); + +//================================================================================================ +/** @name Functions for adding dataTypes +* @{ */ +//================================================================================================ + +/** Adds a datatype and returns the id for the new type +* +* @param _name Internal name for the new DataType +* @param _readableName Human readable Name for this type ( Use tr to make it translatable ) +*/ +DLLEXPORT +DataType addDataType(QString _name, QString _readableName); + +/// Given a dataType Identifier string this function will return the id of the datatype +DLLEXPORT +DataType typeId(QString _name); + +/** \brief Get the name of a type with given id +* +* The ids are organized in a bitfield. So use either the macro for getting the type id or +* use the id directly (they have to be power of 2! ... Bitfield) +*/ +DLLEXPORT +QString typeName(DataType _id); + +/** \brief Get the number of registered types +* +* This function will return the number of types registered to the core. You can use it to +* iterate over all types. +* +* \Note Remember that the types are organized in a bitfield! +*/ +DLLEXPORT +uint typeCount(); + +/** @} */ + +//================================================================================================ +/** @name Datatype Name handling +* @{ */ +//================================================================================================ + +/// Get DataType Human readable name ( this name might change. Use the typeName insted! ) +DLLEXPORT +QString dataTypeName( DataType _id ); + +/// Get DataType Human readable name ( this name might change. Use the typeName insted! ) +DLLEXPORT +QString dataTypeName( QString _typeName); + +/// Set DataType Human readable name +DLLEXPORT +void setDataTypeName( DataType _id, QString _name ); + +/// Set DataType Human readable name +DLLEXPORT +void setDataTypeName( QString _typeName, QString _name ); + + +/** @} */ + +//================================================================================================ +/** @name Datatype Icons +* @{ */ +//================================================================================================ + +/// Get a string with the filename of the icon for the DataType name +DLLEXPORT +QString typeIconName(QString _name); + +/// Get a string with the filename of the icon for the DataType +DLLEXPORT +QString typeIconName(DataType _id); + +/** \brief Get an QIcon associated with the given datatype +* +* The icons are loaded once when set and then the reference is returned here. +* This reduces the time when frequently requesting the icons (e.g. DataControl) +*/ +DLLEXPORT +QIcon& typeIcon(DataType _id); + +/// Set an Icon for a given DataType +DLLEXPORT +void setTypeIcon( DataType _id , QString _icon); + +/// Set an Icon for a given DataType +DLLEXPORT +void setTypeIcon( QString _name , QString _icon ); + +/** @} */ + + + + + +//============================================================================= +#endif // DATATYPES_HH defined +//============================================================================= diff --git a/common/GroupObject.hh b/common/GroupObject.hh index 32903ea2..f7b2544c 100644 --- a/common/GroupObject.hh +++ b/common/GroupObject.hh @@ -62,6 +62,7 @@ //== INCLUDES ================================================================= #include +#include #include //== TYPEDEFS ================================================================= diff --git a/common/Types.cc b/common/Types.cc index 421b0468..fac2c488 100644 --- a/common/Types.cc +++ b/common/Types.cc @@ -57,8 +57,8 @@ //== INCLUDES ================================================================= -#include "Types.hh" #include "TypesInternal.hh" +#include "DataTypes.hh" #include #include #include diff --git a/common/Types.hh b/common/Types.hh index e65e2bc2..792e05cb 100644 --- a/common/Types.hh +++ b/common/Types.hh @@ -58,155 +58,17 @@ #ifndef TYPES_HH #define TYPES_HH -#include -#include -#include -//== Global Typedefs ================================================================= - -/** \brief Predefined datatypes - * - * Here are several datatypes which have predefined ids. This might be changed to runtime added - * datatypes in the future. - */ - -/// None of the other Objects -#define DATA_UNKNOWN 0 - -/// Items used for Grouping -#define DATA_GROUP 1 - -/// Triangle Mesh objects -#define DATA_TRIANGLE_MESH typeId("TriangleMesh") -#define DATA_TRIANGLE_MESH_CONST_ID 2 - -/// Poly Mesh Objects -#define DATA_POLY_MESH typeId("PolyMesh") -#define DATA_POLY_MESH_CONST_ID 4 - -/// Identifier for all available objects -const unsigned int DATA_ALL = UINT_MAX; - -typedef unsigned int DataType; - -// TODO: Make types runtime addable - //== INCLUDES ================================================================= +// This include defines all required datatype handling functions +#include + #include "BaseObject.hh" #include "GroupObject.hh" #include "BaseObjectData.hh" -//== TYPEDEFS ================================================================= - -/// Standard Type for 3d Vector used for scripting -typedef ACG::Vec3d Vector; -/// Standard Type for id Lists used for scripting -typedef std::vector< int > idList; -/// Standard Type for a 4x4 Matrix used for scripting -typedef ACG::Matrix4x4d Matrix4x4; - -Q_DECLARE_METATYPE(idList); -Q_DECLARE_METATYPE(QVector< int >); -Q_DECLARE_METATYPE(Vector); -Q_DECLARE_METATYPE(Matrix4x4); - -/// Vector Type containing the Data Objects -typedef std::vector DataContainer; - -//================================================================================================ -/** @name Functions for adding dataTypes -* @{ */ -//================================================================================================ - -/** Adds a datatype and returns the id for the new type -* -* @param _name Internal name for the new DataType -* @param _readableName Human readable Name for this type ( Use tr to make it translatable ) -*/ -DLLEXPORT -DataType addDataType(QString _name, QString _readableName); - -/// Given a dataType Identifier string this function will return the id of the datatype -DLLEXPORT -DataType typeId(QString _name); - -/** \brief Get the name of a type with given id -* -* The ids are organized in a bitfield. So use either the macro for getting the type id or -* use the id directly (they have to be power of 2! ... Bitfield) -*/ -DLLEXPORT -QString typeName(DataType _id); - -/** \brief Get the number of registered types -* -* This function will return the number of types registered to the core. You can use it to -* iterate over all types. -* -* \Note Remember that the types are organized in a bitfield! -*/ -DLLEXPORT -uint typeCount(); - -/** @} */ - -//================================================================================================ -/** @name Datatype Name handling -* @{ */ -//================================================================================================ - -/// Get DataType Human readable name ( this name might change. Use the typeName insted! ) -DLLEXPORT -QString dataTypeName( DataType _id ); - -/// Get DataType Human readable name ( this name might change. Use the typeName insted! ) -DLLEXPORT -QString dataTypeName( QString _typeName); - -/// Set DataType Human readable name -DLLEXPORT -void setDataTypeName( DataType _id, QString _name ); - -/// Set DataType Human readable name -DLLEXPORT -void setDataTypeName( QString _typeName, QString _name ); - - -/** @} */ - -//================================================================================================ -/** @name Datatype Icons -* @{ */ -//================================================================================================ - -/// Get a string with the filename of the icon for the DataType name -DLLEXPORT -QString typeIconName(QString _name); - -/// Get a string with the filename of the icon for the DataType -DLLEXPORT -QString typeIconName(DataType _id); - -/** \brief Get an QIcon associated with the given datatype -* -* The icons are loaded once when set and then the reference is returned here. -* This reduces the time when frequently requesting the icons (e.g. DataControl) -*/ -DLLEXPORT -QIcon& typeIcon(DataType _id); - -/// Set an Icon for a given DataType -DLLEXPORT -void setTypeIcon( DataType _id , QString _icon); - -/// Set an Icon for a given DataType -DLLEXPORT -void setTypeIcon( QString _name , QString _icon ); - -/** @} */ - //============================================================================= #endif // TYPES_HH defined diff --git a/common/TypesInternal.hh b/common/TypesInternal.hh index 27f9df59..270b9b66 100644 --- a/common/TypesInternal.hh +++ b/common/TypesInternal.hh @@ -1,73 +1,74 @@ -/*===========================================================================*\ - * * - * OpenFlipper * - * Copyright (C) 2001-2009 by Computer Graphics Group, RWTH Aachen * - * www.openflipper.org * - * * - *---------------------------------------------------------------------------* - * This file is part of OpenFlipper. * - * * - * OpenFlipper is free software: you can redistribute it and/or modify * - * it under the terms of the GNU Lesser General Public License as * - * published by the Free Software Foundation, either version 3 of * - * the License, or (at your option) any later version with the * - * following exceptions: * - * * - * If other files instantiate templates or use macros * - * or inline functions from this file, or you compile this file and * - * link it with other files to produce an executable, this file does * - * not by itself cause the resulting executable to be covered by the * - * GNU Lesser General Public License. This exception does not however * - * invalidate any other reasons why the executable file might be * - * covered by the GNU Lesser General Public License. * - * * - * OpenFlipper 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 Lesser General Public License for more details. * - * * - * You should have received a copy of the GNU LesserGeneral Public * - * License along with OpenFlipper. If not, * - * see . * - * * -\*===========================================================================*/ - -/*===========================================================================*\ - * * - * $Revision: 7673 $ * - * $Author: moebius $ * - * $Date: 2009-11-30 12:45:38 +0100 (Mo, 30. Nov 2009) $ * - * * -\*===========================================================================*/ - - - - -//============================================================================= -// -// Types -// -//============================================================================= - -/** - * \file TypesInternal.hh - * This File contains the functions for internal communication between types and - * the core. Do not use in Plugins!!! - */ - - -#ifndef TYPESINTERNAL_HH -#define TYPESINTERNAL_HH - - - -//== INCLUDES ================================================================= -#include -#include - -DLLEXPORT -void initializeTypes(); - -//============================================================================= -#endif // TYPESINTERNAL_HH defined -//============================================================================= +/*===========================================================================*\ + * * + * OpenFlipper * + * Copyright (C) 2001-2009 by Computer Graphics Group, RWTH Aachen * + * www.openflipper.org * + * * + *---------------------------------------------------------------------------* + * This file is part of OpenFlipper. * + * * + * OpenFlipper is free software: you can redistribute it and/or modify * + * it under the terms of the GNU Lesser General Public License as * + * published by the Free Software Foundation, either version 3 of * + * the License, or (at your option) any later version with the * + * following exceptions: * + * * + * If other files instantiate templates or use macros * + * or inline functions from this file, or you compile this file and * + * link it with other files to produce an executable, this file does * + * not by itself cause the resulting executable to be covered by the * + * GNU Lesser General Public License. This exception does not however * + * invalidate any other reasons why the executable file might be * + * covered by the GNU Lesser General Public License. * + * * + * OpenFlipper 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 Lesser General Public License for more details. * + * * + * You should have received a copy of the GNU LesserGeneral Public * + * License along with OpenFlipper. If not, * + * see . * + * * +\*===========================================================================*/ + +/*===========================================================================*\ + * * + * $Revision: 7673 $ * + * $Author: moebius $ * + * $Date: 2009-11-30 12:45:38 +0100 (Mo, 30. Nov 2009) $ * + * * +\*===========================================================================*/ + + + + +//============================================================================= +// +// Types +// +//============================================================================= + +/** + * \file TypesInternal.hh + * This File contains the functions for internal communication between types and + * the core. Do not use in Plugins!!! + */ + + +#ifndef TYPESINTERNAL_HH +#define TYPESINTERNAL_HH + + +//== INCLUDES ================================================================= + +#include + +/// Vector Type containing the Data Objects +typedef std::vector DataContainer; + +void initializeTypes(); + +//============================================================================= +#endif // TYPESINTERNAL_HH defined +//============================================================================= -- GitLab