SoFCColorBar.h
Go to the documentation of this file.00001 
00002 
00003 
00004 
00005 
00006 
00007 
00008 
00009 
00010 
00011 
00012 
00013 
00014 
00015 
00016 
00017 
00018 
00019 
00020 
00021 
00022 
00023 
00024 #ifndef GUI_SOFCCOLORBAR_H
00025 #define GUI_SOFCCOLORBAR_H
00026 
00027 #include <Inventor/SbVec2s.h>
00028 #include <Inventor/nodes/SoSeparator.h>
00029 #include <QTime>
00030 #include <Base/Observer.h>
00031 #include <App/ColorModel.h>
00032 #include <vector>
00033 
00034 class SoSwitch;
00035 class SoEventCallback;
00036 class SbVec2s;
00037 class SoHandleEventAction;
00038 class SoGLRenderAction;
00039 
00040 namespace Gui {
00041 class SoFCColorGradient;
00042 
00047 class GuiExport SoFCColorBarBase : public SoSeparator, public App::ValueFloatToRGB {
00048   typedef SoSeparator inherited;
00049 
00050   SO_NODE_ABSTRACT_HEADER(Gui::SoFCColorBarBase);
00051 
00052 public:
00053   static void initClass(void);
00054   static void finish(void);
00055 
00056   virtual void GLRenderBelowPath ( SoGLRenderAction *action );
00057 
00064   virtual void setRange( float fMin, float fMax, int prec=3 ) = 0;
00070   virtual App::Color getColor(float fVal) const = 0;
00078   virtual bool isVisible (float fVal) const = 0;
00084   virtual void setOutsideGrayed (bool bVal) = 0;
00089   virtual float getMinValue (void) const = 0;
00094   virtual float getMaxValue (void) const = 0;
00101   virtual bool customize() = 0;
00106   virtual const char* getColorBarName() const = 0;
00107 
00108 protected:
00114   virtual void setViewportSize( const SbVec2s& size ) = 0;
00115 
00116   SoFCColorBarBase (void);
00117   virtual ~SoFCColorBarBase ();
00118 
00119 private:
00120   SbVec2s _windowSize;
00121 };
00122 
00123 
00124 
00129 class GuiExport SoFCColorBar : public SoFCColorBarBase, public Base::Subject<int> {
00130   typedef SoFCColorBarBase inherited;
00131 
00132   SO_NODE_HEADER(Gui::SoFCColorBar);
00133 
00134 public:
00135   static void initClass(void);
00136   static void finish(void);
00137   SoFCColorBar(void);
00138 
00142   SoFCColorBarBase* getActiveBar() const;
00146   void handleEvent (SoHandleEventAction *action);
00151   void setRange( float fMin, float fMax, int prec=3 );
00155   App::Color getColor(float fVal) const;
00159   void setOutsideGrayed (bool bVal);
00163   bool isVisible (float fVal) const;
00167   float getMinValue (void) const;
00171   float getMaxValue (void) const;
00175   bool customize();
00178   const char* getColorBarName() const { return "Color Bar"; }
00179 
00180 protected:
00184   void setViewportSize( const SbVec2s& size );
00185 
00186   virtual ~SoFCColorBar();
00187 
00188 private:
00189   static void eventCallback(void * userdata, SoEventCallback * node);
00190 
00191 private:
00192   float _fMaxX, _fMinX, _fMaxY, _fMinY;
00193   QTime _timer;
00194 
00195   SoSwitch* pColorMode; 
00196   std::vector<SoFCColorBarBase*> _colorBars;
00197 };
00198 
00199 } 
00200 
00201 
00202 #endif // GUI_SOFCCOLORBAR_H
00203