SoNavigationDragger.h

Go to the documentation of this file.
00001 /***************************************************************************
00002  *   Copyright (c) 2005 Jürgen Riegel <juergen.riegel@web.de>              *
00003  *                                                                         *
00004  *   This file is part of the FreeCAD CAx development system.              *
00005  *                                                                         *
00006  *   This library is free software; you can redistribute it and/or         *
00007  *   modify it under the terms of the GNU Library General Public           *
00008  *   License as published by the Free Software Foundation; either          *
00009  *   version 2 of the License, or (at your option) any later version.      *
00010  *                                                                         *
00011  *   This library  is distributed in the hope that it will be useful,      *
00012  *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
00013  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
00014  *   GNU Library General Public License for more details.                  *
00015  *                                                                         *
00016  *   You should have received a copy of the GNU Library General Public     *
00017  *   License along with this library; see the file COPYING.LIB. If not,    *
00018  *   write to the Free Software Foundation, Inc., 59 Temple Place,         *
00019  *   Suite 330, Boston, MA  02111-1307, USA                                *
00020  *                                                                         *
00021  ***************************************************************************/
00022 
00023 
00024 #ifndef SONAVIGATIONDRAGGER_H
00025 #define SONAVIGATIONDRAGGER_H
00026 
00027 //  Geometry resources and part names for this dragger:
00028 
00029 //  Resource Names:                     Part Names:
00030 // rotTransTranslatorTranslator      translator.translator
00031 // rotTransTranslatorTranslatorActive
00032 //                                   translator.translatorActive
00033 // rotTransTranslatorFeedback        translator.feedback
00034 // rotTransTranslatorFeedbackActive  translator.feedbackActive
00035 
00036 // rotTransRotatorRotator             XRotator.rotator
00037 // rotTransRotatorRotatorActive       XRotator.rotatorActive
00038 // rotTransRotatorFeedback            XRotator.feedback
00039 // rotTransRotatorFeedbackActive      XRotator.feedbackActive
00040 // (and similarly for parts of the YRotator and ZRotator)
00041 
00042 #include <Inventor/sensors/SoFieldSensor.h>
00043 #include <Inventor/draggers/SoDragger.h>
00044 #include <Inventor/fields/SoSFVec3f.h>
00045 #include <Inventor/fields/SoSFRotation.h>
00046 
00047 //class TranslateRadialDragger;
00048 class SoRotateCylindricalDragger;
00049 
00050 class RotTransDragger : public SoDragger
00051 {
00052    SO_KIT_HEADER(RotTransDragger);
00053 
00054    // Makes the dragger surround other objects
00055    SO_KIT_CATALOG_ENTRY_HEADER(surroundScale);
00056 // Keeps the dragger evenly sized in all 3 dimensions
00057    SO_KIT_CATALOG_ENTRY_HEADER(antiSquish);
00058 
00059    // The translating dragger...
00060    SO_KIT_CATALOG_ENTRY_HEADER(translator);
00061 
00062    // The X and Z rotators need to be turned so as to orient 
00063    // correctly. So create a separator part and put an 
00064    // SoRotation node and the dragger underneath.
00065    SO_KIT_CATALOG_ENTRY_HEADER(XRotatorSep);
00066    SO_KIT_CATALOG_ENTRY_HEADER(XRotatorRot);
00067    SO_KIT_CATALOG_ENTRY_HEADER(XRotator);
00068 
00069    SO_KIT_CATALOG_ENTRY_HEADER(YRotator);
00070 
00071    SO_KIT_CATALOG_ENTRY_HEADER(ZRotatorSep);
00072    SO_KIT_CATALOG_ENTRY_HEADER(ZRotatorRot);
00073    SO_KIT_CATALOG_ENTRY_HEADER(ZRotator);
00074 
00075   public:
00076   
00077    // Constructor
00078    RotTransDragger();
00079 
00080    // These fields reflect state of the dragger at all times.
00081    SoSFRotation rotation;
00082    SoSFVec3f   translation;
00083 
00084    // This should be called once after SoInteraction::init().
00085    static void initClass();
00086 
00087   protected:
00088 
00089    // These sensors ensure that the motionMatrix is updated 
00090    // when the fields are changed from outside.
00091    SoFieldSensor *rotFieldSensor;
00092    SoFieldSensor *translFieldSensor;
00093    static void fieldSensorCB(void *, SoSensor *);
00094 
00095    // This function is invoked by the child draggers when they 
00096    // change their value.
00097    static void valueChangedCB(void *, SoDragger *);
00098 
00099    // Called at the beginning and end of each dragging motion.
00100    // Tells the "surroundScale" part to recalculate.
00101    static void invalidateSurroundScaleCB(void *, SoDragger *);
00102 
00103    // This will detach/attach the fieldSensor.
00104    // It is called at the end of the constructor (to attach).
00105    // and at the start/end of SoBaseKit::readInstance()
00106    // and on the new copy at the start/end of SoBaseKit::copy()
00107    // Returns the state of the node when this was called.
00108    virtual SbBool setUpConnections( SbBool onOff, 
00109                         SbBool doItAlways = FALSE);
00110 
00111    // This allows us to specify that certain parts do not
00112    // write out. We'll use this on the antiSquish and
00113    // surroundScale parts.
00114    virtual void setDefaultOnNonWritingFields();
00115 
00116   private:
00117 
00118    static const char NavigationDraggerLayout[];
00119 
00120    // Destructor.
00121    ~RotTransDragger();
00122 };
00123 
00124 #endif //SONAVIGATIONDRAGGER_H
00125 

Generated on Wed Nov 23 19:00:40 2011 for FreeCAD by  doxygen 1.6.1