diff --git a/ObjectTypes/Coordsys/CoordinateSystemNode.cc b/ObjectTypes/Coordsys/CoordinateSystemNode.cc new file mode 100644 index 0000000000000000000000000000000000000000..fad55a5e719d37e25794523a46e21c5420f722e1 --- /dev/null +++ b/ObjectTypes/Coordsys/CoordinateSystemNode.cc @@ -0,0 +1,299 @@ +/*===========================================================================*\ + * * + * OpenFlipper * + * Copyright (C) 2001-2011 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: 10926 $ * + * $Author: moebius $ * + * $Date: 2011-02-21 13:34:38 +0100 (Mo, 21 Feb 2011) $ * + * * +\*===========================================================================*/ + + + + +//============================================================================= +// +// CLASS CoordsysNode - IMPLEMENTATION +// +//============================================================================= + +//== INCLUDES ================================================================= + +#include +#include +#include + + +//== NAMESPACES =============================================================== + +namespace ACG { +namespace SceneGraph { + + +//== IMPLEMENTATION ========================================================== + + +void +CoordinateSystemNode:: +boundingBox(Vec3d& _bbMin, Vec3d& _bbMax) +{ + //TODO!! + Vec3d topLeft = position_ + coordsysSize_ * ACG::Vec3d(1.0,1.0,1.0); + + _bbMin.minimize( topLeft ); + _bbMin.minimize( position_ ); + + _bbMax.maximize( topLeft ); + _bbMax.maximize( position_ ); + +} + + +//---------------------------------------------------------------------------- + + +DrawModes::DrawMode +CoordinateSystemNode:: +availableDrawModes() const +{ + return ( DrawModes::POINTS | + DrawModes::POINTS_SHADED | + DrawModes::POINTS_COLORED ); +} + + +//---------------------------------------------------------------------------- + +void +CoordinateSystemNode:: +drawCoordsys( GLState& _state) { + + double topRadius = 0.1 * coordsysSize_; + double arrowLength = 0.4 * coordsysSize_; + double bodyRadius = 0.04 * coordsysSize_; + double bodyLength = 0.6 * coordsysSize_; + int slices = 10; + int stacks = 10; + int loops = 10; + double sphereRadius = 0.1 * coordsysSize_; + + GLUquadricObj *quadric = gluNewQuadric(); + + // Origin + glColor3f(0.5, 0.5, 0.5); + gluSphere( quadric, sphereRadius, slices, stacks ); + + // X-Axis + glColor3f(1.0, 0.0, 0.0); + _state.push_modelview_matrix (); + _state.rotate (-90, 0, 1, 0); + _state.translate ( 0, 0, -bodyLength ); + gluCylinder( quadric, bodyRadius, bodyRadius, bodyLength, slices, stacks ); + gluDisk( quadric, 0, topRadius, slices, loops ); + _state.translate ( 0, 0, -arrowLength ); + gluCylinder( quadric, 0, topRadius, arrowLength, slices, stacks ); + _state.pop_modelview_matrix (); + + // Y-Axis + glColor3f(0.0, 1.0, 0.0); + _state.push_modelview_matrix (); + _state.rotate (90, 1, 0, 0); + _state.translate ( 0, 0, -bodyLength ); + gluCylinder( quadric, bodyRadius, bodyRadius, bodyLength, slices, stacks ); + gluDisk( quadric, 0, topRadius, slices, loops ); + _state.translate ( 0, 0, -arrowLength ); + gluCylinder( quadric, 0, topRadius, arrowLength, slices, stacks ); + _state.pop_modelview_matrix (); + + // Z-Axis + glColor3f(0.0, 0.0, 1.0); + _state.push_modelview_matrix (); + _state.rotate (180, 0, 1, 0); + _state.translate ( 0, 0, -bodyLength ); + gluCylinder( quadric, bodyRadius, bodyRadius, bodyLength, slices, stacks ); + gluDisk( quadric, 0, topRadius, slices, loops ); + _state.translate ( 0, 0, -arrowLength ); + gluCylinder( quadric, 0, topRadius, arrowLength, slices, stacks ); + _state.pop_modelview_matrix (); + + gluDeleteQuadric(quadric); +} + +//============================================================================ + + +void +CoordinateSystemNode::drawCoordsysPick( GLState& _state) { + + double topRadius = 0.1 * coordsysSize_; + double arrowLength = 0.4 * coordsysSize_; + double bodyRadius = 0.04 * coordsysSize_; + double bodyLength = 0.6 * coordsysSize_; + int slices = 10; + int stacks = 10; + int loops = 10; + double sphereRadius = 0.1 * coordsysSize_; + + GLUquadricObj *quadric = gluNewQuadric(); + + // Origin + _state.pick_set_name (1); + gluSphere( quadric, sphereRadius, slices, stacks ); + + // X-Axis + _state.pick_set_name (2); + _state.push_modelview_matrix (); + _state.rotate (-90, 0, 1, 0); + _state.translate ( 0, 0, -bodyLength ); + gluCylinder( quadric, bodyRadius, bodyRadius, bodyLength, slices, stacks ); + gluDisk( quadric, 0, topRadius, slices, loops ); + _state.translate ( 0, 0, -arrowLength ); + gluCylinder( quadric, 0, topRadius, arrowLength, slices, stacks ); + _state.pop_modelview_matrix (); + + // Y-Axis + _state.pick_set_name (3); + _state.push_modelview_matrix (); + _state.rotate (90, 1, 0, 0); + _state.translate ( 0, 0, -bodyLength ); + gluCylinder( quadric, bodyRadius, bodyRadius, bodyLength, slices, stacks ); + gluDisk( quadric, 0, topRadius, slices, loops ); + _state.translate ( 0, 0, -arrowLength ); + gluCylinder( quadric, 0, topRadius, arrowLength, slices, stacks ); + _state.pop_modelview_matrix (); + + // Z-Axis + _state.pick_set_name (4); + _state.push_modelview_matrix (); + _state.rotate (180, 0, 1, 0); + _state.translate ( 0, 0, -bodyLength ); + gluCylinder( quadric, bodyRadius, bodyRadius, bodyLength, slices, stacks ); + gluDisk( quadric, 0, topRadius, slices, loops ); + _state.translate ( 0, 0, -arrowLength ); + gluCylinder( quadric, 0, topRadius, arrowLength, slices, stacks ); + _state.pop_modelview_matrix (); + + + gluDeleteQuadric(quadric); + +} + + +//============================================================================ + + +void +CoordinateSystemNode:: +draw(GLState& _state , const DrawModes::DrawMode& /*_drawMode*/) +{ + + // Push Modelview-Matrix + _state.push_modelview_matrix(); + + Vec4f lastBaseColor = _state.base_color(); + + glColorMaterial ( GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE ) ; + glEnable(GL_COLOR_MATERIAL); + glShadeModel(GL_SMOOTH); + + _state.translate(position_); + + // Koordinatensystem zeichnen + drawCoordsys(_state); + + glColor4fv(lastBaseColor.data()); + + // Reload old configuration + _state.pop_modelview_matrix(); +} + + +void +CoordinateSystemNode:: +position(const Vec3d& _pos) +{ + position_ = _pos; +} + + +Vec3d +CoordinateSystemNode:: +position() { + return position_; +} + +void +CoordinateSystemNode:: +size(const double _size) { + coordsysSize_ = _size; +} + +double +CoordinateSystemNode:: +size() { + return coordsysSize_; +} + + +void +CoordinateSystemNode::pick(GLState& _state, PickTarget _target) +{ + + + if (_target == PICK_ANYTHING) { + + _state.pick_set_maximum(5); + _state.pick_set_name(0); + + // Push Modelview-Matrix + _state.push_modelview_matrix(); + + // Translate to current position of the coordsys + _state.translate(position_); + + // Koordinatensystem zeichnen + drawCoordsysPick(_state); + + // Reload old configuration + _state.pop_modelview_matrix(); + + } +} + + +//============================================================================= +} // namespace SceneGraph +} // namespace ACG +//============================================================================= diff --git a/ObjectTypes/Coordsys/CoordinateSystemNode.hh b/ObjectTypes/Coordsys/CoordinateSystemNode.hh new file mode 100644 index 0000000000000000000000000000000000000000..1f6c134b32e7b3fbc5610623efa34c7ca5a7baa5 --- /dev/null +++ b/ObjectTypes/Coordsys/CoordinateSystemNode.hh @@ -0,0 +1,141 @@ +/*===========================================================================*\ + * * + * OpenFlipper * + * Copyright (C) 2001-2011 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: 10926 $ * + * $Author: moebius $ * + * $Date: 2011-02-21 13:34:38 +0100 (Mo, 21 Feb 2011) $ * + * * +\*===========================================================================*/ + + + + +//============================================================================= +// +// CLASS PointNode +// +//============================================================================= + + +#ifndef ACG_COORDSYSNODE_HH +#define ACG_COORDSYSNODE_HH + + +//== INCLUDES ================================================================= + +#include +#include +#include + +//== NAMESPACES =============================================================== + +namespace ACG { +namespace SceneGraph { + +//== CLASS DEFINITION ========================================================= + + +/** \class Node for displaying coordinate systems + + CoordinateSystemNode renders A coordinate system. + +**/ + +class ACGDLLEXPORT CoordinateSystemNode : public BaseNode +{ + +public: + + /** default constructor + * @param _parent Define the parent Node this node gets attached to + * @param _name Name of this Node + */ + CoordinateSystemNode( BaseNode* _parent=0, + std::string _name="") + : BaseNode(_parent, _name), + coordsysSize_(1.0) + {}; + + /// destructor + ~CoordinateSystemNode() {}; + + /// static name of this class + ACG_CLASSNAME(CoordinateSystemNode); + + /// return available draw modes + ACG::SceneGraph::DrawModes::DrawMode availableDrawModes() const; + + /// update bounding box + void boundingBox(Vec3d& _bbMin, Vec3d& _bbMax); + + /// draw Coordsys + void draw(GLState& _state, const DrawModes::DrawMode& _drawMode); + + /// draw Coordsys for object picking + void pick(GLState& _state, PickTarget _target); + + /// set position of the coordsys + void position(const Vec3d& _pos); + + /// Get current position + Vec3d position(); + + /// set size of the coordsys ( Size is length of one of the axis ) + void size(const double _size); + + /// Get current size + double size(); + + private: + + void drawCoordsys(GLState& _state); + void drawCoordsysPick(GLState& _state); + + /// 3d position of the coordsys origin + Vec3d position_; + + /// Size of the coordsys + double coordsysSize_; + +}; + + +//============================================================================= +} // namespace SceneGraph +} // namespace ACG +//============================================================================= +#endif // ACG_COORDSYSNODE_HH defined +//============================================================================= diff --git a/ObjectTypes/Coordsys/Coordsys.hh b/ObjectTypes/Coordsys/Coordsys.hh new file mode 100644 index 0000000000000000000000000000000000000000..f1e4bb0d6739db04153ba526c604c80a2ce3b3ed --- /dev/null +++ b/ObjectTypes/Coordsys/Coordsys.hh @@ -0,0 +1,67 @@ +/*===========================================================================*\ +* * +* OpenFlipper * +* Copyright (C) 2001-2011 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: 10745 $ * +* $LastChangedBy: moebius $ * +* $Date: 2011-01-26 10:23:50 +0100 (Mi, 26. Jan 2011) $ * +* * +\*===========================================================================*/ + + +/** + * \file Coordsys.hh + * This File contains all required includes for using Coordinate systems +*/ + +#ifndef COORDSYS_INCLUDE_HH +#define COORDSYS_INCLUDE_HH + +//== INCLUDES ================================================================= + +#define DATA_COORDSYS typeId("Coordsys") + +#include + +#include + +#include + +#include + +//============================================================================= +#endif // COORDSYS_INCLUDE_HH defined +//============================================================================= + diff --git a/ObjectTypes/Coordsys/CoordsysObject.cc b/ObjectTypes/Coordsys/CoordsysObject.cc new file mode 100644 index 0000000000000000000000000000000000000000..4269c47f5bafffd5e0e78a8debcd546644e0c03b --- /dev/null +++ b/ObjectTypes/Coordsys/CoordsysObject.cc @@ -0,0 +1,222 @@ +/*===========================================================================*\ +* * +* OpenFlipper * +* Copyright (C) 2001-2011 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: 10929 $ * +* $LastChangedBy: moebius $ * +* $Date: 2011-02-21 15:00:32 +0100 (Mo, 21 Feb 2011) $ * +* * +\*===========================================================================*/ + +//============================================================================= +// +// Plane Object +// +//============================================================================= + +#define PLANEOBJECT_C + +//== INCLUDES ================================================================= + +#include +#include "Coordsys.hh" + +//== DEFINES ================================================================== + +//== TYPEDEFS ================================================================= + +//== CLASS DEFINITION ========================================================= + +/** Constructor for Coordinate system Objects. This object class gets a Separator Node giving +* the root node to which it should be connected. The Coordinate system is generated internally +* and all nodes for visualization will be added below the scenegraph node.\n +* You don't need to create an object of this type manually. Use +* the functions from LoadSaveInterface ( addEmpty() ) +*/ +CoordsysObject::CoordsysObject( ) : + BaseObjectData( ), + coordsysNode_(NULL) +{ + setDataType(DATA_COORDSYS); + init(); +} + +//============================================================================= + + +/** + * Copy Constructor - generates a copy of the given object + */ +CoordsysObject::CoordsysObject(const CoordsysObject & _object) : + BaseObjectData(_object) +{ + + init(_object.coordsysNode_); + + setName( name() ); +} + +/** Destructor for Coordsys Objects. The destructor deletes the Line and all +* Scenegraph nodes associated with the Coordinate System or the object. +*/ +CoordsysObject::~CoordsysObject() +{ + // Delete the data attached to this object ( this will remove all perObject data) + // Not the best way to do it but it will work. + // This is only necessary if people use references to the coordsys below and + // they do something with the coordsys in the destructor of their + // perObjectData. + deleteData(); + + // No need to delete the scenegraph Nodes as this will be managed by baseplugin + coordsysNode_ = NULL; +} + +/** Cleanup Function for Coordsys Objects. Deletes the contents of the whole object and +* calls CoordsysObject::init afterwards. +*/ +void CoordsysObject::cleanup() { + + BaseObjectData::cleanup(); + + coordsysNode_ = NULL; + + setDataType(DATA_COORDSYS); + setTypeIcon(DATA_COORDSYS,"CoordsysType.png"); + + init(); + +} + +/** + * Generate a copy + */ +BaseObject* CoordsysObject::copy() { + CoordsysObject* object = new CoordsysObject(*this); + return dynamic_cast< BaseObject* >(object); +} + +/** This function initalizes the coordsys object. It creates the scenegraph nodes. +*/ +void CoordsysObject::init(CoordsysNode* _coordsys) { + + if ( materialNode() == NULL) + std::cerr << "Error when creating Coordsys Object! materialNode is NULL!" << std::endl; + + coordsysNode_ = new CoordsysNode( materialNode() , "NEW CoordsysNode"); + + if (_coordsys){ + coordsysNode_->position( _coordsys->position() ); + coordsysNode_->size( _coordsys->size() ); + } else { + coordsysNode_->position( ACG::Vec3d(0.0, 0.0, 0.0) ); + coordsysNode_->size( 1.0 ); + } +} + +// =============================================================================== +// Name/Path Handling +// =============================================================================== + +/** Set the name of an object. All Scenegraph nodes are renamed too. It also calls +* BaseObjectData::setName. +*/ +void CoordsysObject::setName( QString _name ) { + BaseObjectData::setName(_name); + + std::string nodename = std::string("CoordsysNode for Coordinate system " + _name.toUtf8() ); + coordsysNode_->name( nodename ); +} + +// =============================================================================== +// Visualization +// =============================================================================== + +CoordsysNode* CoordsysObject::coordsysNode() { + return coordsysNode_; +} + +// =============================================================================== +// Object information +// =============================================================================== + +/** Returns a string containing all information about the current object. This also +* includes the information provided by BaseObjectData::getObjectinfo +* +* @return String containing the object information +*/ +QString CoordsysObject::getObjectinfo() { + QString output; + + output += "========================================================================\n"; + output += BaseObjectData::getObjectinfo(); + + if ( dataType( DATA_COORDSYS ) ) + output += "Object Contains a coordinate system : "; + + ACG::Vec3d pos = coordsysNode_->position(); + double size = coordsysNode_->size(); + + output += " Position ( " + QString::number(pos[0]) + ", " + QString::number(pos[1]) + ", " + QString::number(pos[2]) + ")"; + output += " Size ( "+ QString::number(size) + ")"; + + output += "========================================================================\n"; + return output; +} + +// =============================================================================== +// Picking +// =============================================================================== + +/** Given an node index from PluginFunctions::scenegraphPick this function can be used to +* check if the coordsysNode of the object has been picked. +* +* @param _node_idx Index of the picked coordsys node +* @return bool if the coordsys node of this object is the picking target. +*/ +bool CoordsysObject::picked( uint _node_idx ) { + return ( _node_idx == coordsysNode_->id() ); +} + +void CoordsysObject::enablePicking( bool _enable ) { + coordsysNode_->enablePicking( _enable ); +} + +bool CoordsysObject::pickingEnabled() { + return coordsysNode_->pickingEnabled(); +} + +//============================================================================= + diff --git a/ObjectTypes/Coordsys/CoordsysObject.hh b/ObjectTypes/Coordsys/CoordsysObject.hh new file mode 100644 index 0000000000000000000000000000000000000000..cbdc2fc87247e1d14a49ccb32a74e3150e7c3b03 --- /dev/null +++ b/ObjectTypes/Coordsys/CoordsysObject.hh @@ -0,0 +1,154 @@ +/*===========================================================================*\ +* * +* OpenFlipper * +* Copyright (C) 2001-2011 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: 10745 $ * +* $LastChangedBy: moebius $ * +* $Date: 2011-01-26 10:23:50 +0100 (Mi, 26. Jan 2011) $ * +* * +\*===========================================================================*/ + +//============================================================================= +// +// Types +// +//============================================================================= + +/** + * \file CoordsysObject.hh + * This File contains the Coordsys Object + */ + + +#ifndef COORDSYSOBJECT_HH +#define COORDSYSOBJECT_HH + + + +//== INCLUDES ================================================================= + +#include + +#include + +#include "CoordsysTypes.hh" + +//== TYPEDEFS ================================================================= + +// //== CLASS DEFINITION ========================================================= + +class DLLEXPORT CoordsysObject : public BaseObjectData { + + public: + /// constructor + CoordsysObject(); + + /** \brief copy constructor + * + * Create a copy of this object + */ + CoordsysObject(const CoordsysObject& _object); + + /// destructor + virtual ~CoordsysObject(); + + /// Reset current object, including all related nodes. + virtual void cleanup(); + + /** return a full copy of this object ( All scenegraph nodes will be created ) + * but the object will not be a part of the object tree. + */ + BaseObject* copy(); + + + protected: + /// Initialize current object, including all related nodes. + virtual void init(CoordsysNode* _coordsys = 0); + + //=========================================================================== + /** @name Name and Path handling + * @{ */ + //=========================================================================== + public: + + /// Set the name of the Object + void setName( QString _name ); + + //=========================================================================== + /** @name Visualization + * @{ */ + //=========================================================================== + + public: + /// Get the scenegraph Node + CoordsysNode* coordsysNode(); + + private: + CoordsysNode* coordsysNode_; + + /** @} */ + + //=========================================================================== + /** @name Object Information + * @{ */ + //=========================================================================== + public: + /// Get all Info for the Object as a string + QString getObjectinfo(); + + /** @} */ + + + //=========================================================================== + /** @name Picking + * @{ */ + //=========================================================================== + public: + /// detect if the node has been picked + bool picked( uint _node_idx ); + + /// Enable or disable picking for this Object + void enablePicking( bool _enable ); + + /// Check if picking is enabled for this Object + bool pickingEnabled(); + + /** @} */ + +}; + +//============================================================================= +#endif // COORDSYSOBJECT_HH defined +//============================================================================= diff --git a/ObjectTypes/Coordsys/CoordsysTypes.hh b/ObjectTypes/Coordsys/CoordsysTypes.hh new file mode 100644 index 0000000000000000000000000000000000000000..79a8993214e6e08e77f5610b32711ada0ae15c7e --- /dev/null +++ b/ObjectTypes/Coordsys/CoordsysTypes.hh @@ -0,0 +1,69 @@ +/*===========================================================================*\ +* * +* OpenFlipper * +* Copyright (C) 2001-2011 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: 10745 $ * +* $LastChangedBy: moebius $ * +* $Date: 2011-01-26 10:23:50 +0100 (Mi, 26. Jan 2011) $ * +* * +\*===========================================================================*/ + +//============================================================================= +// +// CoordsysTypes +// +//============================================================================= + +/** + * \file CoordsysTypes.hh + * This File contains the required types and typedefs for using Coordinate systems + */ + +#ifndef COORDSYS_TYPES_HH +#define COORDSYS_TYPES_HH + + +//== INCLUDES ================================================================= + +#include + +//== TYPEDEFS FOR SCENEGRAPH =============================================== + +/// Simple Name for CoordsysNode +typedef ACG::SceneGraph::CoordinateSystemNode CoordsysNode; + +//============================================================================= +#endif // COORDSYS_TYPES_HH defined +//============================================================================= diff --git a/ObjectTypes/Coordsys/PluginFunctionsCoordsys.cc b/ObjectTypes/Coordsys/PluginFunctionsCoordsys.cc new file mode 100644 index 0000000000000000000000000000000000000000..023a7dd15076cdd17164ae6e0b3ad53ef816a638 --- /dev/null +++ b/ObjectTypes/Coordsys/PluginFunctionsCoordsys.cc @@ -0,0 +1,105 @@ +/*===========================================================================*\ +* * +* OpenFlipper * +* Copyright (C) 2001-2011 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: 10745 $ * +* $LastChangedBy: moebius $ * +* $Date: 2011-01-26 10:23:50 +0100 (Mi, 26. Jan 2011) $ * +* * +\*===========================================================================*/ + + +//============================================================================= +// +// Plugin Functions for Coordsys +// +//============================================================================= + +#include +#include "Coordsys.hh" + +#include "PluginFunctionsCoordsys.hh" +#include + +namespace PluginFunctions { + +// =============================================================================== +// Get objects +// =============================================================================== + +bool getObject( int _identifier , CoordsysObject*& _object ) { + + if ( _identifier == -1 ) { + _object = 0; + return false; + } + + BaseObject* object = objectRoot()->childExists( _identifier ); + _object = dynamic_cast< CoordsysObject* >(object); + return ( _object != 0 ); +} + + +// =============================================================================== +// Getting data from objects and casting between them +// =============================================================================== + +CoordsysNode* coordsysNode( BaseObjectData* _object ) { + + if ( _object->dataType(DATA_COORDSYS) ) { + CoordsysObject* object = dynamic_cast< CoordsysObject* >(_object); + return object->coordsysNode(); + } else + return 0; +} + + +CoordsysObject* coordsysObject( BaseObjectData* _object ) { + if ( ! _object->dataType(DATA_COORDSYS) ) + return 0; + return dynamic_cast< CoordsysObject* >( _object ); +} + +CoordsysObject* coordsysObject( int _objectId ) { + if ( _objectId == -1 ) { + return 0; + } + + BaseObject* object = objectRoot()->childExists( _objectId ); + + return dynamic_cast< CoordsysObject* >(object); +} + +} diff --git a/ObjectTypes/Coordsys/PluginFunctionsCoordsys.hh b/ObjectTypes/Coordsys/PluginFunctionsCoordsys.hh new file mode 100644 index 0000000000000000000000000000000000000000..688b33f69a99e0d03f8e36766561c56b64dffcfe --- /dev/null +++ b/ObjectTypes/Coordsys/PluginFunctionsCoordsys.hh @@ -0,0 +1,96 @@ +/*===========================================================================*\ +* * +* OpenFlipper * +* Copyright (C) 2001-2011 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: 10745 $ * +* $LastChangedBy: moebius $ * +* $Date: 2011-01-26 10:23:50 +0100 (Mi, 26. Jan 2011) $ * +* * +\*===========================================================================*/ + + +//============================================================================= +// +// Standard Functions +// +//============================================================================= + +/** + * \file PluginFunctionsCoordsys.hh + * This file contains functions which can be used by plugins to access Coordsyss in the framework. + */ + +// +#ifndef PLUGINFUNCTIONSCOORDSYS_HH +#define PLUGINFUNCTIONSCOORDSYS_HH + +#include + +/** The Namespace PluginFunctions contains functions for all plugins. */ +namespace PluginFunctions { + +/** This functions returns the object with the given id if it is a CoordsysObject. + * See get_object( int _identifier , BaseObject*& _object ) for more details. + */ +DLLEXPORT +bool getObject( int _identifier , CoordsysObject*& _object ); + +/** \brief Get a CoordsysNode from an object. + * + * @param _object The object should be of type BaseDataObject. If the content is a coordsys, a + * CoordsysNode will be returned. Otherwise a NULL pointer is returned. + */ +DLLEXPORT +CoordsysNode* coordsysNode( BaseObjectData* _object ); + +/** \brief Cast an BaseObject to a CoordsysObject if possible + * + * @param _object The object should be of type BaseDataObject. If the content is a coordsys, a + * a CoordsysObject is returned. Otherwise a NULL pointer is returned. + */ +DLLEXPORT +CoordsysObject* coordsysObject( BaseObjectData* _object ); + +/** \brief Get a CoordsysObject with its identifier + * + * @param _objectId The object should be of type CoordsysObject. If the id belongs to a coordsys, a + * a CoordsysObject is returned. Otherwise a NULL pointer is returned. + */ +CoordsysObject* coordsysObject( int _objectId ); + + +} + +#endif // PLUGINFUNCTIONSCOORDSYS_HH diff --git a/ObjectTypes/Coordsys/doc/coordsys.docu b/ObjectTypes/Coordsys/doc/coordsys.docu new file mode 100644 index 0000000000000000000000000000000000000000..b206146c1d0b3eb6b6efad97b404142c37eca31b --- /dev/null +++ b/ObjectTypes/Coordsys/doc/coordsys.docu @@ -0,0 +1,4 @@ +/** \page coordsysType Coordinate System +\image html type_coordsys_thumb.png +*/ + diff --git a/OpenFlipper/Documentation/DeveloperHelpSources/dataTypes.docu b/OpenFlipper/Documentation/DeveloperHelpSources/dataTypes.docu index 0a49fe69c77e187ab432baed0d28cdd03b927410..5011eb04e0744f1910fed43bb84d30c9fbd9d4d8 100644 --- a/OpenFlipper/Documentation/DeveloperHelpSources/dataTypes.docu +++ b/OpenFlipper/Documentation/DeveloperHelpSources/dataTypes.docu @@ -19,5 +19,6 @@ The following datatypes are available in OpenFlipper: \image html type_SplineCurve_thumb.png - \subpage BSplineSurfaceType "BSplineSurfaces" \image html type_SplineSurface_thumb.png - +- \subpage coordsysType "Coordinate Systems" + \image html type_coordsys_thumb.png */ diff --git a/OpenFlipper/Documentation/DeveloperHelpSources/pics/type_coordsys_thumb.png b/OpenFlipper/Documentation/DeveloperHelpSources/pics/type_coordsys_thumb.png new file mode 100644 index 0000000000000000000000000000000000000000..3e40e9f77ac4de0b2c75bf7813d462955cbf3848 Binary files /dev/null and b/OpenFlipper/Documentation/DeveloperHelpSources/pics/type_coordsys_thumb.png differ diff --git a/Plugin-TypeCoordsys/CMakeLists.txt b/Plugin-TypeCoordsys/CMakeLists.txt new file mode 100644 index 0000000000000000000000000000000000000000..e5e0fb254bc3315e16377c4106a8dd1130321d55 --- /dev/null +++ b/Plugin-TypeCoordsys/CMakeLists.txt @@ -0,0 +1,3 @@ +include (plugin) +openflipper_plugin ( INSTALLDATA Icons + ) diff --git a/Plugin-TypeCoordsys/Icons/CoordsysType.png b/Plugin-TypeCoordsys/Icons/CoordsysType.png new file mode 100644 index 0000000000000000000000000000000000000000..3e40e9f77ac4de0b2c75bf7813d462955cbf3848 Binary files /dev/null and b/Plugin-TypeCoordsys/Icons/CoordsysType.png differ diff --git a/Plugin-TypeCoordsys/TypeCoordsys.cc b/Plugin-TypeCoordsys/TypeCoordsys.cc new file mode 100644 index 0000000000000000000000000000000000000000..082d188c077bf227c2d9297a207b112f4f38de19 --- /dev/null +++ b/Plugin-TypeCoordsys/TypeCoordsys.cc @@ -0,0 +1,110 @@ +/*===========================================================================*\ +* * +* OpenFlipper * +* Copyright (C) 2001-2011 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: 10745 $ * +* $LastChangedBy: moebius $ * +* $Date: 2011-01-26 10:23:50 +0100 (Mi, 26. Jan 2011) $ * +* * +\*===========================================================================*/ + +#include "TypeCoordsys.hh" +#include "OpenFlipper/BasePlugin/PluginFunctions.hh" + +TypeCoordsysPlugin::TypeCoordsysPlugin() { + +} + +bool TypeCoordsysPlugin::registerType() { + addDataType("Coordsys",tr("Coordsys")); + setTypeIcon( "Coordsys", "CoordsysType.png"); + return true; +} + +int TypeCoordsysPlugin::addEmpty(){ + + // new object data struct + CoordsysObject * object = new CoordsysObject(); + + if ( PluginFunctions::objectCount() == 1 ) + object->target(true); + + if (PluginFunctions::targetCount() == 0 ) + object->target(true); + + QString name = get_unique_name(object); + + // call the local function to update names + QFileInfo f(name); + object->setName( f.fileName() ); + + object->update(); + + object->show(); + + emit emptyObjectAdded (object->id() ); + + return object->id(); +} + +QString TypeCoordsysPlugin::get_unique_name(CoordsysObject* _object) +{ + bool name_unique = false; + + int cur_idx = _object->id(); + + while(!name_unique) + { + name_unique = true; + + QString cur_name = QString(tr("Coordsys %1.cos").arg( cur_idx )); + + PluginFunctions::ObjectIterator o_it(PluginFunctions::ALL_OBJECTS, DATA_COORDSYS ); + for(; o_it != PluginFunctions::objectsEnd(); ++o_it) + { + if( o_it->name() == cur_name) + { + name_unique = false; + cur_idx += 10; + break; + } + } + } + + return QString(tr("Coordsys %1.cos").arg( cur_idx )); +} + +Q_EXPORT_PLUGIN2( typecoordsysplugin , TypeCoordsysPlugin ); + diff --git a/Plugin-TypeCoordsys/TypeCoordsys.hh b/Plugin-TypeCoordsys/TypeCoordsys.hh new file mode 100644 index 0000000000000000000000000000000000000000..6ee80c89ed7885bef9f6062a3d69e6c5402ea65b --- /dev/null +++ b/Plugin-TypeCoordsys/TypeCoordsys.hh @@ -0,0 +1,104 @@ +/*===========================================================================*\ +* * +* OpenFlipper * +* Copyright (C) 2001-2011 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: 10745 $ * +* $LastChangedBy: moebius $ * +* $Date: 2011-01-26 10:23:50 +0100 (Mi, 26. Jan 2011) $ * +* * +\*===========================================================================*/ + + + + +#ifndef TYPECOORDSYSPLUGIN_HH +#define TYPECOORDSYSPLUGIN_HH + +#include + +#include +#include +#include +#include +#include + +class TypeCoordsysPlugin : public QObject, BaseInterface, LoggingInterface, TypeInterface +{ + Q_OBJECT + Q_INTERFACES(BaseInterface) + Q_INTERFACES(LoggingInterface) + Q_INTERFACES(TypeInterface) + + + signals: + // Logging interface + void log(Logtype _type, QString _message); + void log(QString _message); + + // Type Interface + void emptyObjectAdded( int _id ); + + private slots: + + void noguiSupported( ) {} ; + + public : + + ~TypeCoordsysPlugin() {}; + TypeCoordsysPlugin(); + + QString name() { return (QString("TypeCoordsys")); }; + QString description( ) { return (QString(tr("Register Coordsys type"))); }; + + bool registerType(); + + public slots: + + // Base Interface + QString version() { return QString("1.0"); }; + + // Type Interface + int addEmpty(); + + DataType supportedType() { return DATA_COORDSYS; }; + + private: + + /// Return unique name for object + QString get_unique_name(CoordsysObject* _object); + +}; + +#endif //TYPECOORDSYSPLUGIN_HH