-
Notifications
You must be signed in to change notification settings - Fork 20
/
PaletteEditor.h
109 lines (93 loc) · 4.07 KB
/
PaletteEditor.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
/***********************************************************************
PaletteEditor - Class to represent a GLMotif popup window to edit
one-dimensional transfer functions with RGB color and opacity.
Copyright (c) 2005-2010 Oliver Kreylos
This file is part of the 3D Data Visualizer (Visualizer).
The 3D Data Visualizer is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License as published
by the Free Software Foundation; either version 2 of the License, or (at
your option) any later version.
The 3D Data Visualizer is distributed in the hope that it will be
useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
You should have received a copy of the GNU General Public License along
with the 3D Data Visualizer; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
***********************************************************************/
#ifndef PALETTEEDITOR_INCLUDED
#define PALETTEEDITOR_INCLUDED
#include <Misc/CallbackList.h>
#include <GLMotif/PopupWindow.h>
#include "ColorMap.h"
/* Forward declarations: */
namespace Misc {
class CallbackData;
}
class GLColorMap;
namespace GLMotif {
class Blind;
class TextField;
class Slider;
}
class PaletteEditor:public GLMotif::PopupWindow
{
/* Embedded classes: */
public:
typedef GLMotif::ColorMap::ValueRange ValueRange;
typedef GLMotif::ColorMap::ColorMapCreationType ColorMapCreationType;
typedef GLMotif::ColorMap::Storage Storage;
class CallbackData:public Misc::CallbackData // Base class for callback data sent by palette editors
{
/* Elements: */
public:
PaletteEditor* paletteEditor; // Pointer to the palette editor that sent the callback
/* Constructors and destructors: */
CallbackData(PaletteEditor* sPaletteEditor)
:paletteEditor(sPaletteEditor)
{
}
};
/* Elements: */
private:
GLMotif::ColorMap* colorMap; // The color map widget
GLMotif::TextField* controlPointValue; // The data value of the currently selected control point
GLMotif::Blind* colorPanel; // The control point color display widget
GLMotif::Slider* colorSliders[4]; // The color selection slider widgets (R, G, B, alpha)
Misc::CallbackList savePaletteCallbacks; // List of callbacks called when the "Save Palette" button is pressed
/* Private methods: */
void selectedControlPointChangedCallback(Misc::CallbackData* cbData);
void colorMapChangedCallback(Misc::CallbackData* cbData);
void controlPointValueChangedCallback(Misc::CallbackData* cbData);
void colorSliderValueChangedCallback(Misc::CallbackData* cbData);
void removeControlPointCallback(Misc::CallbackData* cbData);
void savePaletteCallback(Misc::CallbackData* cbData);
/* Constructors and destructors: */
public:
PaletteEditor(void);
/* Methods: */
const GLMotif::ColorMap* getColorMap(void) const // Returns pointer to the underlying color map widget
{
return colorMap;
}
GLMotif::ColorMap* getColorMap(void) // Ditto
{
return colorMap;
}
Storage* getPalette(void) const; // Returns the current palette
void setPalette(const Storage* newPalette); // Sets a new palette
void createPalette(ColorMapCreationType colorMapType,const ValueRange& newValueRange); // Creates a standard palette
void createPalette(const std::vector<GLMotif::ColorMap::ControlPoint>& controlPoints); // Creates a palette from the given color map control point vector
void loadPalette(const char* paletteFileName,const ValueRange& newValueRange); // Loads a palette from a palette file
void savePalette(const char* paletteFileName) const; // Saves the current palette to a palette file
Misc::CallbackList& getColorMapChangedCallbacks(void) // Returns list of color map change callbacks
{
return colorMap->getColorMapChangedCallbacks();
}
Misc::CallbackList& getSavePaletteCallbacks(void) // Returns list of save palette callbacks
{
return savePaletteCallbacks;
}
void exportColorMap(GLColorMap& glColorMap) const; // Exports color map to GLColorMap object
};
#endif