Developer documentation | Axl-2.5.1

axlInspectorView.cpp
Go to the documentation of this file.
1 /* axlInspectorView.cpp ---
2  *
3  * Author: Julien Wintz
4  * Copyright (C) 2008 - Julien Wintz, Inria.
5  * Created: Wed Mar 30 09:26:03 2011 (+0200)
6  * Version: $Id$
7  * Last-Updated: Tue Apr 3 14:21:33 2012 (+0200)
8  * By: Julien Wintz
9  * Update #: 78
10  */
11 
12 /* Commentary:
13  *
14  */
15 
16 /* Change log:
17  *
18  */
19 
20 #include "axlInspectorView.h"
21 #include "axlInspectorUtils.h"
22 #include "axlInspector.h"
23 
25 
26 #include <axlGui/axlColorDialog.h>
29 
30 #include <dtkConfig.h>
31 
32 #include <dtkCoreSupport/dtkGlobal.h>
33 
34 #include <dtkGuiSupport/dtkColorButton.h>
35 
36 #ifdef DTK_BUILD_VR
37 #include <dtkVr/dtkVrHeadRecognizer.h>
38 #include <dtkVr/dtkVrFlystickRecognizer.h>
39 #include <dtkVr/dtkVrGestureRecognizer.h>
40 #endif
41 
42 class axlInspectorViewPrivate
43 {
44 
45 #ifdef DTK_BUILD_VR
46 public:
47  dtkVrHeadRecognizer *head_recognizer;
48  dtkVrFlystickRecognizer *flystick_recognizer;
49  dtkVrGestureRecognizer *gesture_recognizer;
50 #endif
51 
52 public:
53  axlAbstractView *view;
54 
55 public:
56  dtkColorButton *colorButton;
57  axlInspectorLight *lightDialog;
58  axlInspectorCamera *inpectorCamera;
59 
60  QFrame *box_head;
61  QFrame *box_flystick;
62  QFrame *box_finger;
63  QFrame *box_background;
64 
65  QCheckBox *switch_head;
66  QCheckBox *switch_flystick;
67  QCheckBox *switch_finger;
68  QCheckBox *checkBoxGradientBackground;
69 
70  QLineEdit *head_address;
71  QLineEdit *flystick_address;
72  QLineEdit *finger_address;
73 
74  QString head_address_url;
75  QString flystick_address_url;
76  QString finger_address_url;
77 };
78 
79 axlInspectorView::axlInspectorView(QWidget *parent) : QFrame(parent), d(new axlInspectorViewPrivate)
80 {
81 #ifdef DTK_BUILD_VR
82  d->head_recognizer = new dtkVrHeadRecognizer;
83  d->flystick_recognizer = new dtkVrFlystickRecognizer;
84  d->gesture_recognizer = new dtkVrGestureRecognizer;
85 #endif
86 
87  d->head_address_url = "DTrackCW@is-sound";
88  d->flystick_address_url = "DTrackCW@is-sound";
89  d->finger_address_url = "DTrackCW@is-sound";
90 
91  d->view = NULL;
92 
93  d->box_head = new QFrame(this);
94  d->head_address = new QLineEdit("DTrackCW@is-sound", d->box_head);
95  d->switch_head = new QCheckBox(this);
96 
97  d->colorButton = new dtkColorButton(this);
98 
99  d->lightDialog = new axlInspectorLight;
100 
101  d->inpectorCamera = new axlInspectorCamera;
102 
103 
104  QVBoxLayout *box_head_layout = new QVBoxLayout(d->box_head);
105 
106  QHBoxLayout *box_head_layout_top = new QHBoxLayout;
107  box_head_layout_top->addWidget(new QLabel("Head tracking", d->box_head));
108  box_head_layout_top->addWidget(d->switch_head);
109 
110  box_head_layout->addLayout(box_head_layout_top);
111  box_head_layout->addWidget(d->head_address);
112 
113  d->box_flystick = new QFrame(this);
114  d->flystick_address = new QLineEdit("DTrackCW@is-sound", d->box_flystick);
115  d->switch_flystick = new QCheckBox(this);
116 
117  QVBoxLayout *box_flystick_layout = new QVBoxLayout(d->box_flystick);
118 
119  QHBoxLayout *box_flystick_layout_top = new QHBoxLayout;
120  box_flystick_layout_top->addWidget(new QLabel("Flystick tracking", d->box_flystick));
121  box_flystick_layout_top->addWidget(d->switch_flystick);
122 
123  box_flystick_layout->addLayout(box_flystick_layout_top);
124  box_flystick_layout->addWidget(d->flystick_address);
125 
126  d->box_finger = new QFrame(this);
127  d->finger_address = new QLineEdit("DTrackCW@is-sound", d->box_finger);
128  d->switch_finger = new QCheckBox(this);
129 
130  QVBoxLayout *box_finger_layout = new QVBoxLayout(d->box_finger);
131 
132  QHBoxLayout *box_finger_layout_top = new QHBoxLayout;
133  box_finger_layout_top->addWidget(new QLabel("Finger tracking", d->box_finger));
134  box_finger_layout_top->addWidget(d->switch_finger);
135 
136  box_finger_layout->addLayout(box_finger_layout_top);
137  box_finger_layout->addWidget(d->finger_address);
138 
139  d->box_background = new QFrame(this);
140  QVBoxLayout *box_background_layout = new QVBoxLayout(d->box_background);
141 
142  QHBoxLayout *layoutColorButton = new QHBoxLayout;
143 // layoutColorButton->setContentsMargins(20, 20, 20, 20);
144  layoutColorButton->addWidget(new QLabel("Color",d->box_background));
145  layoutColorButton->addWidget(d->colorButton);
146 
147  QHBoxLayout *layoutGradientCheckBox = new QHBoxLayout;
148  d->checkBoxGradientBackground = new QCheckBox(this);
149  d->checkBoxGradientBackground->setChecked(true);
150  QLabel *labelGradientBackground = new QLabel("Gradient :", d->box_background);
151  layoutGradientCheckBox->addWidget(labelGradientBackground);
152  layoutGradientCheckBox->addWidget(d->checkBoxGradientBackground);
153  labelGradientBackground->setToolTip("Turn on/off the gradient background.");
154 
155  box_background_layout->addWidget(new QLabel("Background", this));
156  box_background_layout->addLayout(layoutColorButton);
157  box_background_layout->addLayout(layoutGradientCheckBox);
158 
159  QVBoxLayout *layout = new QVBoxLayout(this);
160  layout->setAlignment(Qt::AlignTop);
161  layout->setContentsMargins(0, 0, 0, 0);
162  layout->setSpacing(0);
163  layout->addWidget(d->box_head);
164  layout->addWidget(new axlInspectorSeparator(this));
165  layout->addWidget(d->box_flystick);
166  layout->addWidget(new axlInspectorSeparator(this));
167  layout->addWidget(d->box_finger);
168  layout->addWidget(new axlInspectorSeparator(this));
169 // layout->addLayout(layoutColorButton);
170  layout->addWidget(d->box_background);
171  layout->addWidget(new axlInspectorSeparator(this));
172  layout->addWidget(d->lightDialog);
173  layout->addWidget(new axlInspectorSeparator(this));
174  layout->addWidget(d->inpectorCamera);
175  layout->addWidget(new axlInspectorSeparator(this));
176 
177  connect(d->head_address, SIGNAL(textChanged(const QString&)), this, SLOT(onHeadAddressChanged(const QString&)));
178  connect(d->flystick_address, SIGNAL(textChanged(const QString&)), this, SLOT(onFlystickAddressChanged(const QString&)));
179  connect(d->finger_address, SIGNAL(textChanged(const QString&)), this, SLOT(onFingerAddressChanged(const QString&)));
180 
181  connect(d->switch_head, SIGNAL(toggled(bool)), this, SLOT(onHeadToggled(bool)));
182  connect(d->switch_flystick, SIGNAL(toggled(bool)), this, SLOT(onFlystickToggled(bool)));
183  connect(d->switch_finger, SIGNAL(toggled(bool)), this, SLOT(onFingerToggled(bool)));
184 
185 }
186 
188 {
189 #ifdef DTK_BUILD_VR
190  delete d->head_recognizer;
191  delete d->flystick_recognizer;
192  delete d->gesture_recognizer;
193 #endif
194  delete d->lightDialog;
195  delete d->inpectorCamera;
196  delete d;
197 
198  d = NULL;
199 }
200 
202 {
203  if(view){
204  d->view = view;
205  d->lightDialog->setView(view);
206  d->inpectorCamera->setView(view);
207  QColor c;
208  c.setRgbF(d->view->getBackgroundColor()[0],d->view->getBackgroundColor()[1],d->view->getBackgroundColor()[2]);
209  d->colorButton->setColor(c);
210  connect(d->view, SIGNAL(lightPositionChanged(double,double,double)), d->lightDialog, SLOT(onPositionChanged(double,double,double)));
211  connect(d->colorButton, SIGNAL(colorChanged(QColor)), this, SLOT(onBackGroundColorChanged(QColor)));
212  connect(d->checkBoxGradientBackground, SIGNAL(clicked(bool)), d->view, SLOT(onBackgroundGradientChange(bool)));
213  }
214 
215 }
216 
218  QColor c;
219  c.setRgbF(d->view->getBackgroundColor()[0],d->view->getBackgroundColor()[1],d->view->getBackgroundColor()[2]);
220  d->colorButton->setColor(c);
221  d->checkBoxGradientBackground->setChecked(d->view->getBackgroundGradient());
222 
223  d->inpectorCamera->updateView();
224 }
225 
227 {
228  d->view->setBackgroundColor(color.redF(), color.greenF(), color.blueF());
229 }
230 
231 void axlInspectorView::onHeadAddressChanged(const QString& address)
232 {
233  d->head_address_url = address;
234 }
235 
236 void axlInspectorView::onFlystickAddressChanged(const QString& address)
237 {
238  d->flystick_address_url = address;
239 }
240 
241 void axlInspectorView::onFingerAddressChanged(const QString& address)
242 {
243  d->finger_address_url = address;
244 }
245 
247 {
248  qDebug() << DTK_PRETTY_FUNCTION << toggled << QUrl(d->head_address_url);
249 #ifdef DTK_BUILD_VR
250  if(toggled)
251  d->head_recognizer->startConnection(QUrl(d->head_address_url));
252  else
253  d->head_recognizer->stopConnection();
254 
255  d->head_recognizer->setView(d->view);
256 #endif
257 }
258 
260 {
261  qDebug() << DTK_PRETTY_FUNCTION << toggled << QUrl(d->flystick_address_url);
262 #ifdef DTK_BUILD_VR
263  if(toggled)
264  d->flystick_recognizer->startConnection(QUrl(d->flystick_address_url));
265  else
266  d->flystick_recognizer->stopConnection();
267 #endif
268 }
269 
271 {
272 #ifdef DTK_BUILD_VR
273  if(toggled)
274  d->gesture_recognizer->startConnection(QUrl(d->finger_address_url));
275  else
276  d->gesture_recognizer->stopConnection();
277 #endif
278 }
void onFingerToggled(bool)
void setView(axlAbstractView *view)
void onFingerAddressChanged(const QString &)
void onHeadAddressChanged(const QString &)
axlInspectorView(QWidget *parent=0)
void onFlystickAddressChanged(const QString &)
void onFlystickToggled(bool)
void onBackGroundColorChanged(QColor color)