SoFCColorBar.h

Go to the documentation of this file.
00001 /***************************************************************************
00002  *   Copyright (c) 2005 Werner Mayer <wmayer[at]users.sourceforge.net>     *
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 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 } // namespace Gui
00200 
00201 
00202 #endif // GUI_SOFCCOLORBAR_H
00203 

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