Developer documentation | Axl-2.5.1

axlInspectorCamera.cpp
Go to the documentation of this file.
1 /* axlInspectorCamera.cpp ---
2  *
3  * Author: Meriadeg Perrinel
4  * Copyright (C) 2008 - Meriadeg Perrinel, Inria.
5  * Created: Wed Mar 16 17:19:51 2011 (+0100)
6  * Version: $Id$
7  * Last-Updated: Wed Mar 16 17:38:31 2011 (+0100)
8  * By: Meriadeg Perrinel
9  * Update #: 31
10  */
11 
12 /* Commentary:
13  *
14  */
15 
16 /* Change log:
17  *
18  */
19 
20 #include "axlInspectorCamera.h"
21 #include "axlInspectorSeparator.h"
22 
23 #include <axlCore/axlPoint.h>
25 #include <dtkCoreSupport/dtkAbstractProcessFactory.h>
26 #include <dtkCoreSupport/dtkAbstractProcess.h>
27 
28 #include <QtGui>
29 
30 class axlInspectorCameraPrivate
31 {
32 public:
33  axlAbstractView *view;
34 
35  QRadioButton *radioButtonLastCamera;
36 
37  QRadioButton *radioButtonCameraX;
38  QRadioButton *radioButtonCameraY;
39  QRadioButton *radioButtonCameraZ;
40 
41  QRadioButton *radioButtonCameraInverseX;
42  QRadioButton *radioButtonCameraInverseY;
43  QRadioButton *radioButtonCameraInverseZ;
44 
45  QRadioButton *radioButtonCameraPerpective;
46  QRadioButton *radioButtonCameraParallel;
47 
48  QCheckBox *checkBoxGridX;
49  QCheckBox *checkBoxGridY;
50  QCheckBox *checkBoxGridZ;
51 
52  QCheckBox *checkBoxShowAxes;
53 
54  QSlider *sliderResolution;
55 
56 };
57 
58 axlInspectorCamera::axlInspectorCamera(QWidget *parent) : QDialog(parent), d(new axlInspectorCameraPrivate)
59 {
60  d->view = NULL;
61 
62  QVBoxLayout *layout = new QVBoxLayout(this);
63 
64  QGridLayout *layoutCamera = new QGridLayout();
65  QButtonGroup *buttonGroupCamera = new QButtonGroup(this);
66  QButtonGroup *buttonGroupCameraProjection = new QButtonGroup(this);
67 
68  // last Camera
69  d->radioButtonLastCamera = new QRadioButton("Free", this);
70  d->radioButtonLastCamera->setToolTip("switch to free camera");
71  d->radioButtonLastCamera->setChecked(true);
72  d->radioButtonLastCamera->setFocusPolicy(Qt::NoFocus);
73  layoutCamera->addWidget(d->radioButtonLastCamera, 0, 0);
74 
75 
76  //Positive Camera
77  d->radioButtonCameraX = new QRadioButton(" X", this);
78  d->radioButtonCameraX->setFocusPolicy(Qt::NoFocus);
79 
80  d->radioButtonCameraY = new QRadioButton(" Y", this);
81  d->radioButtonCameraY->setFocusPolicy(Qt::NoFocus);
82 
83  d->radioButtonCameraZ = new QRadioButton(" Z", this);
84  d->radioButtonCameraZ->setFocusPolicy(Qt::NoFocus);
85 
86  layoutCamera->addWidget(d->radioButtonCameraX, 1, 0);
87  layoutCamera->addWidget(d->radioButtonCameraY, 1, 1);
88  layoutCamera->addWidget(d->radioButtonCameraZ, 1, 2);
89 
90  //Negative CameraV
91  d->radioButtonCameraInverseX = new QRadioButton("-X", this);
92  d->radioButtonCameraInverseX->setFocusPolicy(Qt::NoFocus);
93 
94  d->radioButtonCameraInverseY = new QRadioButton("-Y", this);
95  d->radioButtonCameraInverseY->setFocusPolicy(Qt::NoFocus);
96 
97  d->radioButtonCameraInverseZ = new QRadioButton("-Z", this);
98  d->radioButtonCameraInverseZ->setFocusPolicy(Qt::NoFocus);
99 
100  layoutCamera->addWidget(d->radioButtonCameraInverseX, 2, 0);
101  layoutCamera->addWidget(d->radioButtonCameraInverseY, 2, 1);
102  layoutCamera->addWidget(d->radioButtonCameraInverseZ, 2, 2);
103 
104  buttonGroupCamera->addButton(d->radioButtonLastCamera);
105  buttonGroupCamera->addButton(d->radioButtonCameraX);
106  buttonGroupCamera->addButton(d->radioButtonCameraY);
107  buttonGroupCamera->addButton(d->radioButtonCameraZ);
108  buttonGroupCamera->addButton(d->radioButtonCameraInverseX);
109  buttonGroupCamera->addButton(d->radioButtonCameraInverseY);
110  buttonGroupCamera->addButton(d->radioButtonCameraInverseZ);
111 
112  QHBoxLayout *layoutCameraProjection = new QHBoxLayout();
113 
114  d->radioButtonCameraPerpective = new QRadioButton(" Perspective", this);
115  d->radioButtonCameraPerpective->setFocusPolicy(Qt::NoFocus);
116  d->radioButtonCameraPerpective->setChecked(true);
117 
118  d->radioButtonCameraParallel = new QRadioButton(" Parallel", this);
119  d->radioButtonCameraParallel->setFocusPolicy(Qt::NoFocus);
120  layoutCameraProjection->addWidget(d->radioButtonCameraPerpective);
121  layoutCameraProjection->addWidget(d->radioButtonCameraParallel);
122 
123  buttonGroupCameraProjection->addButton(d->radioButtonCameraPerpective);
124  buttonGroupCameraProjection->addButton(d->radioButtonCameraParallel);
125  QGridLayout *layoutGrid = new QGridLayout();
126 
127  d->checkBoxGridX = new QCheckBox(" X", this);
128  d->checkBoxGridX->setFocusPolicy(Qt::NoFocus);
129 
130  d->checkBoxGridY = new QCheckBox(" Y", this);
131  d->checkBoxGridY->setFocusPolicy(Qt::NoFocus);
132 
133  d->checkBoxGridZ = new QCheckBox(" Z", this);
134  d->checkBoxGridZ->setFocusPolicy(Qt::NoFocus);
135 
136  d->sliderResolution = new QSlider(Qt::Horizontal, this);
137  d->sliderResolution->setMinimum(1);
138  d->sliderResolution->setMaximum(100);
139  d->sliderResolution->setToolTip("Set the grid resolution between 1 and 100");
140 
141 
142  layoutGrid->addWidget(d->checkBoxGridX, 0, 0);
143  layoutGrid->addWidget(d->checkBoxGridY, 0, 1);
144  layoutGrid->addWidget(d->checkBoxGridZ, 0, 2);
145  layoutGrid->addWidget(d->sliderResolution, 1, 0, 1, 3);
146 
147  d->checkBoxShowAxes = new QCheckBox(" Show axes", this);
148  d->checkBoxShowAxes->setChecked(true);
149  //d->checkBoxShowAxes->setFocusPolicy(Qt::NoFocus);
150 
151  // QAction *actionShowAxes = new QAction("Show axes", this);
152 
153  layout->addWidget(new QLabel("Projection :", this));
154  layout->addLayout(layoutCameraProjection);
155  layout->addWidget(new axlInspectorSeparator(this));
156  layout->addWidget(new QLabel("View", this));
157  layout->addLayout(layoutCamera);
158  layout->addWidget(new axlInspectorSeparator(this));
159  layout->addWidget(new QLabel("Grid :", this));
160  layout->addLayout(layoutGrid);
161  layout->addWidget(new axlInspectorSeparator(this));
162  layout->addWidget(new QLabel("Axes :", this));
163  layout->addWidget(d->checkBoxShowAxes);
164 
165  connect(d->radioButtonLastCamera, SIGNAL(clicked()), this, SLOT(onCameraViewChanged()));
166  connect(d->radioButtonCameraX, SIGNAL(clicked()), this, SLOT(onCameraViewChanged()));
167  connect(d->radioButtonCameraY, SIGNAL(clicked()), this, SLOT(onCameraViewChanged()));
168  connect(d->radioButtonCameraZ, SIGNAL(clicked()), this, SLOT(onCameraViewChanged()));
169  connect(d->radioButtonCameraInverseX, SIGNAL(clicked()), this, SLOT(onCameraViewChanged()));
170  connect(d->radioButtonCameraInverseY, SIGNAL(clicked()), this, SLOT(onCameraViewChanged()));
171  connect(d->radioButtonCameraInverseZ, SIGNAL(clicked()), this, SLOT(onCameraViewChanged()));
172  connect(d->radioButtonCameraPerpective, SIGNAL(clicked()), this, SLOT(onCameraProjectionChanged()));
173  connect(d->radioButtonCameraParallel, SIGNAL(clicked()), this, SLOT(onCameraProjectionChanged()));
174  connect(d->checkBoxGridX, SIGNAL(clicked()), this, SLOT(onGridChanged()));
175  connect(d->checkBoxGridY, SIGNAL(clicked()), this, SLOT(onGridChanged()));
176  connect(d->checkBoxGridZ, SIGNAL(clicked()), this, SLOT(onGridChanged()));
177 }
178 
180 {
181  delete d;
182 
183  d = NULL;
184 }
185 
187 {
188  d->view = view;
189  connect(d->sliderResolution, SIGNAL(valueChanged(int)), d->view, SLOT(onGridResolutionChanged(int)));
190 
191  connect(d->checkBoxShowAxes, SIGNAL(clicked(bool)), d->view, SLOT(onShowAxis(bool)));
192 
193 }
194 
196 {
197  d->checkBoxShowAxes->setChecked(d->view->getAxesVisibility());
198 
199  if (d->view->getParallelProjection())
200  d->radioButtonCameraParallel->setChecked(true);
201  else
202  d->radioButtonCameraPerpective->setChecked(true);
203 }
204 
206 {
207  if(d->radioButtonCameraParallel->isChecked())
208  d->view->setParallelCamera(true);
209 
210  if(d->radioButtonCameraPerpective->isChecked())
211  d->view->setParallelCamera(false);
212 
213 }
214 
216 {
217  if(d->radioButtonLastCamera->isChecked())
218  d->view->setCameraViewDefaut();
219 
220  if(d->radioButtonCameraX->isChecked())
221  d->view->setCameraViewPositiveX();
222 
223  if(d->radioButtonCameraY->isChecked())
224  d->view->setCameraViewPositiveY();
225 
226  if(d->radioButtonCameraZ->isChecked())
227  d->view->setCameraViewPositiveZ();
228 
229  if(d->radioButtonCameraInverseX->isChecked())
230  d->view->setCameraViewNegativeX();
231 
232  if(d->radioButtonCameraInverseY->isChecked())
233  d->view->setCameraViewNegativeY();
234 
235  if(d->radioButtonCameraInverseZ->isChecked())
236  d->view->setCameraViewNegativeZ();
237 }
238 
240 {
241  d->view->setGrid(d->checkBoxGridX->isChecked(), d->checkBoxGridY->isChecked(), d->checkBoxGridZ->isChecked());
242 }
axlInspectorCamera(QWidget *parent=0)
void onCameraProjectionChanged(void)
void setView(axlAbstractView *view)