1#ifndef SOANY_THUMBWHEEL_H
2#define SOANY_THUMBWHEEL_H
3
4// @configure_input@
5
6/**************************************************************************\
7 * Copyright (c) Kongsberg Oil & Gas Technologies AS
8 * All rights reserved.
9 *
10 * Redistribution and use in source and binary forms, with or without
11 * modification, are permitted provided that the following conditions are
12 * met:
13 *
14 * Redistributions of source code must retain the above copyright notice,
15 * this list of conditions and the following disclaimer.
16 *
17 * Redistributions in binary form must reproduce the above copyright
18 * notice, this list of conditions and the following disclaimer in the
19 * documentation and/or other materials provided with the distribution.
20 *
21 * Neither the name of the copyright holder nor the names of its
22 * contributors may be used to endorse or promote products derived from
23 * this software without specific prior written permission.
24 *
25 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
26 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
27 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
28 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
29 * HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
30 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
31 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
32 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
33 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
34 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
35 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
36\**************************************************************************/
37
38class SoAnyThumbWheel {
39public:
40  enum State              { DISABLED, ENABLED };
41  enum Alignment          { VERTICAL, HORIZONTAL };
42  enum BoundaryHandling   { MODULATE, ACCUMULATE, CLAMP };
43  enum Movement           { UNIFORM, AUTHENTIC };
44  enum GraphicsByteOrder  { ABGR, RGBA, ARGB, BGRA };
45
46  SoAnyThumbWheel(void);
47  ~SoAnyThumbWheel(void);
48
49  void setSize(const int diameter, const int width);
50  void getSize(int & diameter, int & width) const;
51
52  void setColor(const float red, const float green, const float blue);
53  void getColor(float & red, float & green, float & blue) const;
54  void setColorFactors(const float light, const float front, const float normal, const float shade);
55  void getColorFactors(float & light, float & front, float & normal, float & shade) const;
56
57  int getNumBitmaps(void) const;
58  void drawBitmap(const int number, void * bitmap, Alignment alignment) const;
59  float calculateValue(const float origValue, const int origPosition, const int deltaPosition) const;
60  int getBitmapForValue(const float value, const State state) const;
61
62  void setGraphicsByteOrder(const GraphicsByteOrder byteorder);
63  GraphicsByteOrder getGraphicsByteOrder(void) const;
64
65  void setMovement(const Movement movement);
66  Movement getMovement(void) const;
67
68  void setBoundaryHandling(const BoundaryHandling handling);
69  BoundaryHandling getBoundaryHandling(void) const;
70
71private:
72  unsigned int swapWord(unsigned int) const;
73
74  int diameter, width;
75  // float disabledred, disabledgreen, disabledblue; // not implemented
76  float red, green, blue;
77  float light, front, normal, shade;
78
79  GraphicsByteOrder  byteorder;
80  BoundaryHandling   boundaryhandling;
81  Movement           movement;
82
83  enum Tables { SIN, COS, RAD, NUMTABLES };
84
85  mutable float * tables [ NUMTABLES ];
86  mutable int dirtyTables;
87  mutable int dirtyVariables;
88  mutable float squarelength, squarespacing, shadelength, unistep, numsquares;
89
90  void drawDisabledWheel(const int number, void * bitmap, Alignment alignment) const;
91  void drawEnabledWheel(const int number, void * bitmap, Alignment alignment) const;
92
93  void validate(void) const;
94
95}; // class SoAnyThumbWheel
96
97// ************************************************************************
98
99#endif // ! SOANY_THUMBWHEEL_H
100