dataStructure.docu 4.5 KB
 Jan Möbius committed Apr 19, 2011 1 2 3 4 5 6 7 8 9 10 11 12 13 /** \page dataStructure Data Structures \section Overview \image html ObjectTree.png All Objects in OpeFlipper have to be derived from the BaseObject. For the predefined objects this is already the case. In BaseObject a tree structure is implemented. You can use the functions in BaseObject to search for items and access them. A root Object is created by OpenFlipper which is the root of the object tree. You can get it via PluginFunctions::objectRoot(). There is also a GroupObject which holds no data and is used for grouping different objects like in the figure above. All objects in OpenFlipper are handled by the core. To create and delete objects use  Jan Möbius committed Feb 15, 2012 14 15 the functions provided by the \ref loadSaveInterfacePage. Additionally there is a small example on how to add empty objects to the scene which can be filled by the programmer: \ref adding_empty_objects  Jan Möbius committed Apr 19, 2011 16   Jan Möbius committed Apr 19, 2011 17 \subsection DataAccess Access to data from within the Plugins  Jan Möbius committed Feb 15, 2012 18 19 From each plugin you have to get access to the data. Functions to get the right data are provided by the build-in ObjectIterators(\ref OpenFlipperIterators ). If you need consistent data access during the plugin  Jan Möbius committed Apr 19, 2011 20 lifetime (e.g. you have to track one mesh during the plugin lifetime) you should use the identifiers made  Jan Möbius committed Feb 15, 2012 21 available by the objects which never change( \ref identifying_objects).\n  Jan Möbius committed Apr 19, 2011 22 23 24 25 It is possible that the vector containing the objects changes during the plugin lifetime (added or deleted objects). Only the identifiers will stay constant. If one of these changes occurs, the main application will call BaseInterface::updatedObject() of all Plugins containing the id of a changed object or -1 if an object has been deleted. LoadSaveInterface::objectDeleted() will tell you if an object is deleted.  Jan Möbius committed Feb 15, 2012 26 27 If you have to keep track of these changes, implement these functions. More information about the update notifiation system is described in the BaseInterface documentation (\ref baseInterfacegeneralObjectUpdates )  Jan Möbius committed Apr 19, 2011 28   Jan Möbius committed Apr 19, 2011 29 30 31 32 \section identifying_objects Identifying Objects Objects in OpenFlipper get a unique id when they are created. This id will not change during runtime. It is possible, that pointers change so you should only use the id to reference objects in your plugins. To get this id, just call the BaseObject::id() function. To get an object with a specific id, you can use the  Jan Möbius committed Feb 15, 2012 33 PluginFunctions provided by the data type (e.g. PluginFunctions::triMeshObject(int) ). This way, you will always  Jan Möbius committed Apr 19, 2011 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 be sure to get the right object. \section basicObjectTypes Basic object types \subsection baseObjectDescription BaseObject All objects are derived from BaseObject. This object implements the basic object functions. It creates a tree structure of all available objects, includes object selection, name and type information. It does not contain any code to visualize objects. Each object derived from BaseObject has a datatype function BaseObject::dataType. Additionally you can add data to each object by using the perObjectData class. See PerObjectData \subsection baseObjectDataDescription BaseObjectData This class is derived from BaseObject and includes basic visualization functions. It creates the basic scenegraph nodes for the object ( TODO : See per Object Scenegraph structure ). For every object, the top scenegraph node is the ObjectData::SeparatorNode*. All other nodes ( including per object custom nodes ) have to be added below this node. Additionally an ManipulatorNode is added below the separator node. This manipulator is used to move or transform the object. Normally this node is managed by the move plugin. If you use per object nodes which should be transformed along with the object you can attach them below this node ( BaseObjectData::manipulatorNode() ). Additionally per object scenegraph nodes can be managed automatically by BaseObjectData. \subsection MeshObjectDescription MeshObject MeshObject is the class representing triangle or poly meshes. It uses OpenMesh as its data structure. It is based on BaseObjectData and adds additional scenegraph nodes. First it creates a materialNode used to set the meshes rendering material properties, followed by a texture node ( MeshObject::textureNode() ). A shader node ( MeshObject::shaderNode() ) is than added to manage the systems and user defined shaders. Below the shader node is the mesh node ( MeshObject::meshNode() )which actually renders the mesh. Additionally some nodes to render selection, features or modeling areas are added by the MeshObject See MeshObject for the detailed function documentation. \section creatingCustomObjectTypes Creating custom object types */  Mike Kremer committed Apr 22, 2009 76