SoFCColorLegend.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_SOFCCOLORLEGEND_H
00025 #define GUI_SOFCCOLORLEGEND_H
00026 
00027 #include <Inventor/nodes/SoSeparator.h>
00028 #include "SoFCColorBar.h"
00029 #include <App/ColorModel.h>
00030 
00031 class SoCoordinate3;
00032 class SoMFString;
00033 class SbVec2s;
00034 
00035 namespace Gui {
00036 
00037 class GuiExport SoFCColorLegend : public SoFCColorBarBase {
00038   typedef SoFCColorBarBase inherited;
00039 
00040   SO_NODE_HEADER(Gui::SoFCColorLegend);
00041 
00042 public:
00043   static void initClass(void);
00044   static void finish(void);
00045   SoFCColorLegend(void);
00046 
00047   void setMarkerLabel( const SoMFString& label );
00048 
00053   void setRange( float fMin, float fMax, int prec=3 );
00058   void setColorModel (App::ColorGradient::TColorModel tModel);
00059 
00060   unsigned short getColorIndex (float fVal) const { return _cColRamp.getColorIndex(fVal);  }
00061   App::Color getColor (float fVal) const { return _cColRamp.getColor(fVal); }
00062   void setOutsideGrayed (bool bVal) { _cColRamp.setOutsideGrayed(bVal); }
00063   bool isVisible (float fVal) const { return false; }
00064   float getMinValue (void) const { return _cColRamp.getMinValue(); }
00065   float getMaxValue (void) const { return _cColRamp.getMaxValue(); }
00066   unsigned long countColors (void) const { return _cColRamp.getCountColors(); }
00067 
00068   bool customize() { return false; }
00069   const char* getColorBarName() const { return "Color Legend"; }
00070 
00071 //  virtual void handleEvent(SoHandleEventAction * action);
00072 //  virtual void GLRenderBelowPath(SoGLRenderAction * action);
00073 //  virtual void GLRenderInPath(SoGLRenderAction * action);
00074 
00075 protected:
00076   void setViewportSize( const SbVec2s& size );
00077   virtual ~SoFCColorLegend();
00078 //  virtual void redrawHighlighted(SoAction * act, SbBool  flag);
00079 
00080   SoCoordinate3* coords;
00081   SoSeparator* labels;
00082 
00083 private:
00084   float _fPosX, _fPosY;
00085   App::ColorGradient _cColRamp;
00086 };
00087 
00088 } // namespace Gui
00089 
00090 
00091 #endif // GUI_SOFCCOLORLEGEND_H
00092 

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