1
/***************************************************************************
2
* Copyright (c) 2005 Werner Mayer <werner.wm.mayer@gmx.de> *
4
* This file is part of the FreeCAD CAx development system. *
6
* This library is free software; you can redistribute it and/or *
7
* modify it under the terms of the GNU Library General Public *
8
* License as published by the Free Software Foundation; either *
9
* version 2 of the License, or (at your option) any later version. *
11
* This library is distributed in the hope that it will be useful, *
12
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
13
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
14
* GNU Library General Public License for more details. *
16
* You should have received a copy of the GNU Library General Public *
17
* License along with this library; see the file COPYING.LIB. If not, *
18
* write to the Free Software Foundation, Inc., 59 Temple Place, *
19
* Suite 330, Boston, MA 02111-1307, USA *
21
***************************************************************************/
24
#ifndef GUI_SOFCCOLORBAR_H
25
#define GUI_SOFCCOLORBAR_H
31
#ifndef __InventorAll__
32
# include "InventorAll.h"
35
#include <Base/Observer.h>
36
#include <App/ColorModel.h>
40
class SoEventCallback;
42
class SoHandleEventAction;
43
class SoGLRenderAction;
46
class SoFCColorGradient;
49
* The abstract color bar base class to get most important information on how to convert a scalar to an RGB color.
50
* @author Werner Mayer
52
class GuiExport SoFCColorBarBase : public SoSeparator, public App::ValueFloatToRGB {
53
typedef SoSeparator inherited;
55
SO_NODE_ABSTRACT_HEADER(Gui::SoFCColorBarBase);
58
static void initClass(void);
59
static void finish(void);
61
virtual void GLRenderBelowPath ( SoGLRenderAction *action );
64
* Sets the range of the colorbar from the maximum \a fMax to the minimum \a fMin.
65
* \a prec indicates the post decimal positions, \a prec should be in between 0 and 6.
67
* This method must be implemented in subclasses.
69
virtual void setRange( float fMin, float fMax, int prec=3 ) = 0;
71
* Returns the associated color to the value \a fVal.
73
* This method must be implemented in subclasses.
75
virtual App::Color getColor(float fVal) const = 0;
77
* Returns always true if the color bar is in mode to show colors to arbitrary values of \a fVal,
78
* otherwise true is returned if \a fVal is within the specified parameter range, if not false is
81
* This method must be implemented in subclasses.
83
virtual bool isVisible (float fVal) const = 0;
84
/** Returns the current minimum of the parameter range.
86
* This method must be implemented in subclasses.
88
virtual float getMinValue (void) const = 0;
89
/** Returns the current maximum of the parameter range.
91
* This method must be implemented in subclasses.
93
virtual float getMaxValue (void) const = 0;
95
* Opems a dialog to customie the current settings of the color bar.
96
* Returns true if the settings have been changed, false otherwise.
98
* This method must be implemented in subclasses.
100
virtual bool customize() = 0;
101
/** Returns the name of the color bar.
103
* This method must be implemented in subclasses.
105
virtual const char* getColorBarName() const = 0;
109
* Sets the current viewer size to recalculate the new position.
111
* This method must be implemented in subclasses.
113
virtual void setViewportSize( const SbVec2s& size ) = 0;
115
SoFCColorBarBase (void);
116
virtual ~SoFCColorBarBase ();
122
// --------------------------------------------------------------------------
125
* The color bar class that redirects all calls to its handled color bars.
126
* @author Werner Mayer
128
class GuiExport SoFCColorBar : public SoFCColorBarBase, public Base::Subject<int> {
129
typedef SoFCColorBarBase inherited;
131
SO_NODE_HEADER(Gui::SoFCColorBar);
134
static void initClass(void);
135
static void finish(void);
139
* Returns the currently active color bar object.
141
SoFCColorBarBase* getActiveBar() const;
143
* Handles the mouse button events and checks if the user has clicked on the area of the currently active color bar.
145
void handleEvent (SoHandleEventAction *action);
147
* Sets the range of all color bars from the maximum \a fMax to the minimum \a fMin.
148
* \a prec indicates the post decimal positions, \a prec should be in between 0 and 6.
150
void setRange( float fMin, float fMax, int prec=3 );
152
* Returns the associated color to the value \a fVal of the currently active color bar.
154
App::Color getColor(float fVal) const;
156
* Returns the return value of the currently active color bar.
158
bool isVisible (float fVal) const;
160
* Returns the current minimum of the parameter range of the currently active color bar.
162
float getMinValue (void) const;
164
* Returns the current maximum of the parameter range of the currently active color bar.
166
float getMaxValue (void) const;
168
* Customizes the currently active color bar.
171
/** Returns the name of the color bar.
173
const char* getColorBarName() const { return "Color Bar"; }
177
* Sets the current viewer size to all color bars to recalculate their new position.
179
void setViewportSize( const SbVec2s& size );
181
virtual ~SoFCColorBar();
184
static void eventCallback(void * userdata, SoEventCallback * node);
187
float _fMaxX, _fMinX, _fMaxY, _fMinY;
190
SoSwitch* pColorMode;
191
std::vector<SoFCColorBarBase*> _colorBars;
197
#endif // GUI_SOFCCOLORBAR_H