vrecko
virtual reality framework
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
ColorPicker.h
Go to the documentation of this file.
1 #pragma once
2 
3 #include "GUI_item.h"
4 
5 # ifdef GUI_LIBRARY
6 # define GUI_EXPORT __declspec(dllexport)
7 # else
8 # define GUI_EXPORT __declspec(dllimport)
9 #endif
10 
11 
12 
13 namespace APGUI
14 {
15 
17 
26 {
27  public:
28  ColorPicker();
29  ~ColorPicker();
30 
31  bool initialize(XERCES_CPP_NAMESPACE_QUALIFIER DOMNode *parametersNode);
32 
34  bool createVisuals();
35 
36  void pointed(bool pointed) { }
37 
39 
43  bool processAction( const int sensorNumber, const GUI_ACTION action, const bool pressed);
44 
45  void setState(GUI_ITEM_STATE newState);
46 
47  void update(void);
48 
49 
50 
51 
52  protected:
53 
55  bool _isActive;
56 
59 
60  //visuals
61  float _pickerHeight, _pickerRadius, spheresRadius;
62  osg::Geode* osgGeode;
63 
64  //handSphere
66  osg::ShapeDrawable* handShapeDraw;
67  osg::Sphere* handShapeSphere;
68 
70 
72 
73 
74  void createColorSphere(osg::Vec3* pos, float radius, osg::Vec4* colour);
75 
77  void evoke();
78  void RGBtoHSL(osg::Vec4* p_source, osg::Vec3* target);
79  void HSLtoPos(osg::Vec3* p_hsl, osg::Vec3* p_pos);
80  void PostoHSL(osg::Vec3* p_pos, osg::Vec3* p_hsl);
81  void HSLtoRGB(osg::Vec3* source, osg::Vec4* target);
82 
83 
84  osg::Vec3 limitPosition( osg::Vec3 handPosition);
85  bool linesIntersection(osg::Vec3* p_point1, osg::Vec3* p_orientation1, osg::Vec3* p_point2, osg::Vec3* p_orientation2, osg::Vec3* result);
86 
88  void revoke();
89 
90 
91  //for direct evocation of color picker - by key, for example
92  DECLARE_INPUT(Evoke, MessageBool);
93 
94  //evoke command from GUI (Icon, e.g.)
95  DECLARE_INPUT(GUIItemClicked, MessageString);
96 
97  //direct selection of color - not used at all?
98  DECLARE_INPUT(Select, MessageBool);
99 
100  // color picker activated by icon - when color is picked, color picker should set icon to default state
101  DECLARE_INPUT(ExternalDeactivation, MessageObjectID);
102 
103  //request for color picker evocation - picked color will be send to given receiver
104  DECLARE_REQUEST_INPUT(EvokeHSLColorPicker, MessageString, MessageBool);
105 
106  //selected colour
107  DECLARE_OUTPUT(Colour, MessageVec4);
108 
109  //request for hand position - called repeatedly during update()
110  DECLARE_REQUEST_OUTPUT(SensorPosition, MessageInt, MessageVec3);
111 
112 
113 
114 };
115 
116 }