Main Page | Class Hierarchy | Class List | Directories | File List | Class Members | File Members

ring.h

Go to the documentation of this file.
00001 /***************************************************************************
00002  *    Copyright (C) 2005 by Loïc Duviquet & Nicolas Rémond                 *
00003  *        duviquet@isia.cma.fr    remond@isia.cma.fr                       *
00004  *                                                                         *
00005  * This software is governed by the CeCILL  license under French law and   *
00006  * abiding by the rules of distribution of free software.  You can  use,   *
00007  * modify and/ or redistribute the software under the terms of the CeCILL  *
00008  * license as circulated by CEA, CNRS and INRIA at the following URL       *
00009  * "http://www.cecill.info".                                               *
00010  *                                                                         *
00011  * As a counterpart to the access to the source code and  rights to copy,  *
00012  * modify and redistribute granted by the license, users are provided only *
00013  * with a limited warranty  and the software's author,  the holder of the  *
00014  * economic rights,  and the successive licensors  have only  limited      *
00015  * liability.                                                              *
00016  *                                                                         *
00017  * In this respect, the user's attention is drawn to the risks associated  *
00018  * with loading,  using,  modifying and/or developing or reproducing the   *
00019  * software by the user in light of its specific status of free software,  *
00020  * that may mean  that it is complicated to manipulate,  and  that  also   *
00021  * therefore means  that it is reserved for developers  and  experienced   *
00022  * professionals having in-depth computer knowledge. Users are therefore   *
00023  * encouraged to load and test the software's suitability as regards their *
00024  * requirements in conditions enabling the security of their systems and/or*
00025  * data to be ensured and,  more generally, to use and operate it in the   *
00026  * same conditions as regards security.                                    *
00027  *                                                                         *
00028  * The fact that you are presently reading this means that you have had    *
00029  * knowledge of the CeCILL license and that you accept its terms.          *
00030  *                                                                         *
00031  ***************************************************************************/ 
00032 
00033 #ifndef RING_H
00034 #define RING_H
00035 
00036 // Define the standard dimensions of the ring
00037 #define RING_BOUNDARY_WIDTH 0.2
00038 #define RING_RADIUS 1
00039 #define RING_HEIGHT_DEFAULT 2
00040 #define FIXED_RING_HEIGHT_DEFAULT RING_BOUNDARY_WIDTH*2
00041 
00042 // STL
00043 #include <list>
00044 #include <string>
00045 #include <iterator>
00046 
00047 // Coin-2
00048 #include <Inventor/nodes/SoSeparator.h>
00049 #include <Inventor/nodes/SoTransform.h>
00050 #include <Inventor/nodes/SoCylinder.h>
00051 #include <Inventor/nodes/SoMaterial.h>
00052 #include <Inventor/sensors/SoNodeSensor.h>
00053 #include <Inventor/draggers/SoTranslate1Dragger.h>
00054 
00055 
00069 class Ring{
00070 
00071 public:
00072     // Enable to make more tests
00073     friend class ringTest;
00074 
00076     enum Collision {
00077       NONE,  
00078       LEFT,  
00079       RIGHT, 
00080       BOTH   
00081       };
00082       
00084     enum Transformation {
00085       TRANSLATION, 
00086       ROTATION,    
00087       TOOL_ANGLE,  
00088       NO_TRANSFORM 
00089       };
00090    
00091 private:
00095     typedef std::list<Ring*>::const_iterator const_iterator;
00096     
00100     typedef std::list<Ring*>::iterator iterator;
00101 
00102 public:
00103     static float highlight(const float &color, const float &factor);
00104     static Ring* getRing(SoPath* path);
00105     
00106     static void collisionerCB(void* data, void* unused);
00107     static void leftHandleCB(void* data, void* unused);
00108     static void rightHandleCB(void* data, void* unused);
00109     
00110     Ring(float position, std::string name, bool fixed = false);
00111     ~Ring();
00112    
00113     float getPosition() const;
00114     void setPosition(const float f);
00115     
00116     float getWidth() const;
00117     void setWidth(const float h);
00118         
00119     float getRight() const;
00120     void setRight(const float r);
00121     
00122     float getLeft() const;
00123     void setLeft(const float l);
00124     
00125     void setColor(float r, float g, float b);
00126    
00127     bool isFixed() {return fixed;}
00128     int getTransformType() {return transform_type;}
00129     
00130     SoSeparator* getNode(){ return root; }
00131    
00132     Ring* next();
00133     Ring* prev();
00134     
00135   
00136 public: /* PAKI strikes again ! */
00137     bool solid;
00138     
00139 // Static attributes  
00140 private:
00141     static std::list<Ring*> rings;     
00143 // Private methods
00144 private:   
00145     int insert();
00146     void erase();
00147     
00148 // Private attributes
00149 protected:
00150     std::string name;                  
00151     bool fixed;                   
00152     int transform_type;           
00154     SoSeparator*         root;         
00156     SoSeparator*         separator;    
00157     SoCylinder*          cylinder;     
00158     SoTransform*         transform;    
00160     SoTranslate1Dragger* dragger;      
00161     SoTranslate1Dragger* leftDragger;  
00162     SoTranslate1Dragger* rightDragger; 
00164     SoMaterial* normalMaterial;        
00165     SoMaterial* activeMaterial;        
00167     SoSeparator* normalCylinder;       
00168     SoSeparator* activeCylinder;       
00170     SoSeparator* leftNormalCylinder;   
00171     SoSeparator* leftActiveCylinder;   
00173     SoSeparator* rightNormalCylinder;  
00174     SoSeparator* rightActiveCylinder;  
00177 };
00178 
00179 
00186 class RingError
00187 {
00188 public:
00193     int error;  
00194     
00195     RingError(int c) : error(c) {}
00196     
00197     // Copy constructor.
00198     RingError(const RingError &source) : error(source.error) {}
00199 };
00200 
00201 
00208 class RingTranslation : public Ring
00209 {
00210 public:
00211     RingTranslation(float position, std::string name, bool fixed = false);
00212 };
00213 
00220 class RingRotation: public Ring
00221 {
00222 public:
00223     RingRotation(float position, std::string name, bool fixed = false);
00224 };
00225 
00232 class RingToolAngle : public Ring
00233 {
00234 public:
00235     RingToolAngle(float position, std::string name, bool fixed = false);
00236 };
00237 
00238 #endif

Generated on Tue Jul 12 16:40:18 2005 for CosmeProject by  doxygen 1.4.3