28 QGroupBox *anglesGroup =
new QGroupBox(tr(
"Camera Control"));
29 anglesGroup->setMinimumWidth(450);
31 QLabel *moveLabel =
new QLabel(tr(
"Move:"));
32 moveCombo =
new QComboBox;
33 moveCombo->addItem(tr(
"Detector"));
34 moveCombo->addItem(tr(
"Light"));
36 QLabel *projLabel =
new QLabel(tr(
"Projection:"));
37 projCombo =
new QComboBox;
38 projCombo->addItem(tr(
"Orthogonal"));
39 projCombo->addItem(tr(
"Perspective 30"));
40 projCombo->addItem(tr(
"Perspective 45"));
41 projCombo->addItem(tr(
"Perspective 60"));
42 connect ( projCombo , SIGNAL( currentIndexChanged (
int) ),
this, SLOT( set_perspective(
int) ) );
44 QHBoxLayout *mpLayout =
new QHBoxLayout;
45 mpLayout->addWidget(moveLabel);
46 mpLayout->addWidget(moveCombo);
47 mpLayout->addSpacing(100);
48 mpLayout->addWidget(projLabel);
49 mpLayout->addWidget(projCombo);
51 theta_hall = phi_hall = 0;
55 QLabel *thetaLabel =
new QLabel(tr(
"theta"));
56 theta_slider =
new QSlider(Qt::Horizontal);
57 theta_slider->setTickInterval(1);
58 theta_slider->setRange(0, 180);
59 QLCDNumber *Theta_LCD =
new QLCDNumber(
this);
60 Theta_LCD->setFont(QFont(
"Helvetica", 32, QFont::Bold));
61 Theta_LCD->setMaximumSize(45, 45);
62 Theta_LCD->setSegmentStyle(QLCDNumber::Flat);
63 for(
int t=0; t<=180; t+=30)
66 sprintf(tmp,
"%d", t);
67 ThetaSet.push_back(tmp);
69 QComboBox *ThetaCombo =
new QComboBox;
70 for(
unsigned int i=0; i<ThetaSet.size(); i++) ThetaCombo->addItem(tr(ThetaSet[i].c_str()));
71 ThetaCombo->setMaximumSize(60, 45);
72 QHBoxLayout *thetaLayout =
new QHBoxLayout;
73 thetaLayout->addWidget(thetaLabel);
74 thetaLayout->addWidget(theta_slider);
75 thetaLayout->addWidget(Theta_LCD);
76 thetaLayout->addWidget(ThetaCombo);
78 connect ( theta_slider , SIGNAL( valueChanged (
int) ),
this, SLOT( change_theta(
int) ) );
79 connect ( theta_slider , SIGNAL( valueChanged (
int) ), Theta_LCD, SLOT( display(
int) ) );
80 connect ( ThetaCombo , SIGNAL( currentIndexChanged (
int) ),
this, SLOT( set_theta(
int) ) );
81 connect ( ThetaCombo , SIGNAL( currentIndexChanged (
int) ),
this, SLOT( change_theta_s(
int) ) );
84 QLabel *phiLabel =
new QLabel(tr(
"phi"));
85 phi_slider =
new QSlider(Qt::Horizontal);
86 phi_slider->setTickInterval(1);
87 phi_slider->setRange(0, 360);
88 QLCDNumber *Phi_LCD =
new QLCDNumber(
this);
89 Phi_LCD->setFont(QFont(
"Helvetica", 32, QFont::Bold));
90 Phi_LCD->setMaximumSize(45, 45);
91 Phi_LCD->setSegmentStyle(QLCDNumber::Flat);
92 for(
int t=0; t<=360; t+=30)
95 sprintf(tmp,
"%d", t);
96 PhiSet.push_back(tmp);
98 QComboBox *PhiCombo =
new QComboBox;
99 for(
unsigned int i=0; i<PhiSet.size(); i++) PhiCombo->addItem(tr(PhiSet[i].c_str()));
100 PhiCombo->setMaximumSize(60, 45);
101 QHBoxLayout *phiLayout =
new QHBoxLayout;
102 phiLayout->addWidget(phiLabel);
103 phiLayout->addWidget(phi_slider);
104 phiLayout->addWidget(Phi_LCD);
105 phiLayout->addWidget(PhiCombo);
107 connect ( phi_slider , SIGNAL( valueChanged (
int) ),
this, SLOT( change_phi(
int) ) );
108 connect ( phi_slider , SIGNAL( valueChanged (
int) ), Phi_LCD, SLOT( display(
int) ) );
109 connect ( PhiCombo , SIGNAL( currentIndexChanged (
int) ),
this, SLOT( set_phi(
int) ) );
110 connect ( PhiCombo , SIGNAL( currentIndexChanged (
int) ),
this, SLOT( change_phi_s(
int) ) );
112 QVBoxLayout *anglesLayout =
new QVBoxLayout;
113 anglesLayout->addLayout(mpLayout);
114 anglesLayout->addSpacing(12);
115 anglesLayout->addLayout(thetaLayout);
116 anglesLayout->addSpacing(2);
117 anglesLayout->addLayout(phiLayout);
118 anglesGroup->setLayout(anglesLayout);
122 QGroupBox *PanGroup =
new QGroupBox(tr(
"Pan"));
124 QToolButton *pan_up =
new QToolButton(
this);
125 pan_up->setArrowType(Qt::UpArrow);
126 pan_up->setAutoRepeat(1);
127 QHBoxLayout *pan_upLayout =
new QHBoxLayout;
128 pan_upLayout->addWidget(pan_up);
130 QLabel *panLabel =
new QLabel(tr(
"Pan Strength"));
131 QToolButton *pan_left =
new QToolButton(
this);
132 pan_left->setAutoRepeat(1);
133 pan_left->setArrowType(Qt::LeftArrow);
135 pan_slider =
new QSlider(Qt::Horizontal);
136 pan_slider->setTickInterval(1);
137 pan_slider->setRange(1, 25);
138 pan_slider->setValue(4);
140 QToolButton *pan_right =
new QToolButton(
this);
141 pan_right->setArrowType(Qt::RightArrow);
142 pan_right->setAutoRepeat(1);
144 QHBoxLayout *pan_lrLayout =
new QHBoxLayout;
145 pan_lrLayout->addWidget(pan_left);
146 pan_lrLayout->addWidget(panLabel);
147 pan_lrLayout->addWidget(pan_slider);
148 pan_lrLayout->addWidget(pan_right);
150 QToolButton *pan_down =
new QToolButton(
this);
151 pan_down->setArrowType(Qt::DownArrow);
152 pan_down->setAutoRepeat(1);
153 QHBoxLayout *pan_downLayout =
new QHBoxLayout;
154 pan_downLayout->addWidget(pan_down);
156 connect(pan_up, SIGNAL(pressed()),
this, SLOT( clickpan_up() ) );
157 connect(pan_left, SIGNAL(pressed()),
this, SLOT( clickpan_left() ) );
158 connect(pan_right,SIGNAL(pressed()),
this, SLOT( clickpan_right() ) );
159 connect(pan_down, SIGNAL(pressed()),
this, SLOT( clickpan_down() ) );
161 QVBoxLayout *pansLayout =
new QVBoxLayout;
162 pansLayout->addLayout(pan_upLayout);
163 pansLayout->addLayout(pan_lrLayout);
164 pansLayout->addLayout(pan_downLayout);
165 PanGroup->setLayout(pansLayout);
169 QGroupBox *vOptionsGroup =
new QGroupBox(tr(
"Visualization Options"));
171 QLabel *antialiasingLabel =
new QLabel(tr(
"Anti-Aliasing"));
172 aliasing =
new QComboBox;
173 aliasing->addItem(tr(
"OFF"));
174 aliasing->addItem(tr(
"ON"));
175 QHBoxLayout *aliasingLayout =
new QHBoxLayout;
176 aliasingLayout->addWidget(antialiasingLabel);
177 aliasingLayout->addWidget(aliasing);
178 connect ( aliasing , SIGNAL( currentIndexChanged (
int) ),
this, SLOT( switch_antialiasing(
int) ) );
180 QLabel *sides_per_circlesLabel =
new QLabel(tr(
"Sides per circle"));
181 sides_per_circle =
new QComboBox;
182 sides_per_circle->addItem(tr(
"50"));
183 sides_per_circle->addItem(tr(
"100"));
184 sides_per_circle->addItem(tr(
"200"));
185 sides_per_circle->addItem(tr(
"500"));
186 sides_per_circle->setCurrentIndex(1);
187 QHBoxLayout *sides_per_circleLayout =
new QHBoxLayout;
188 sides_per_circleLayout->addWidget(sides_per_circlesLabel);
189 sides_per_circleLayout->addWidget(sides_per_circle);
190 connect ( sides_per_circle , SIGNAL( currentIndexChanged (
int) ),
this, SLOT( switch_sides_per_circle(
int) ) );
192 QLabel *auxiliaryEdgesLabel =
new QLabel(tr(
"Auxiliary Edges"));
193 auxiliary =
new QComboBox;
194 auxiliary->addItem(tr(
"OFF"));
195 auxiliary->addItem(tr(
"ON"));
196 QHBoxLayout *auxedgesLayout =
new QHBoxLayout;
197 auxedgesLayout->addWidget(auxiliaryEdgesLabel);
198 auxedgesLayout->addWidget(auxiliary);
199 connect ( auxiliary , SIGNAL( currentIndexChanged (
int) ),
this, SLOT( switch_auxiliary_edges(
int) ) );
201 QVBoxLayout *voptionsLayout =
new QVBoxLayout;
202 voptionsLayout->addLayout(aliasingLayout);
203 voptionsLayout->addLayout(sides_per_circleLayout);
204 voptionsLayout->addLayout(auxedgesLayout);
205 vOptionsGroup->setLayout(voptionsLayout);
208 QHBoxLayout *PanvOptionsLayout =
new QHBoxLayout;
209 PanvOptionsLayout->addWidget(PanGroup);
210 PanvOptionsLayout->addWidget(vOptionsGroup);
214 QGroupBox *ZoomGroup =
new QGroupBox(tr(
"Zoom"));
215 zoom_slider =
new QSlider(Qt::Horizontal);
216 zoom_slider->setTickInterval(1);
217 zoom_slider->setRange(0, 360);
219 QHBoxLayout *zoomLayout =
new QHBoxLayout;
220 zoomLayout->addWidget(zoom_slider);
221 ZoomGroup->setLayout(zoomLayout);
222 connect ( zoom_slider , SIGNAL( valueChanged(
int) ),
this, SLOT( zoom(
int) ) );
226 QGroupBox *OptionsGroup =
new QGroupBox(tr(
""));
227 QPushButton *back_color =
new QPushButton(
"Background Color",
this);
228 QPushButton *screenshot =
new QPushButton(
"Screenshot",
this);
229 connect ( back_color, SIGNAL( pressed() ),
this, SLOT( change_background_color() ) );
230 connect ( screenshot, SIGNAL( pressed() ),
this, SLOT( take_screenshot() ) );
233 QHBoxLayout *optionsLayout =
new QHBoxLayout;
234 optionsLayout->addWidget(back_color);
235 optionsLayout->addWidget(screenshot);
236 OptionsGroup->setLayout(optionsLayout);
240 QVBoxLayout *mainLayout =
new QVBoxLayout;
241 mainLayout->addWidget(anglesGroup);
242 mainLayout->addLayout(PanvOptionsLayout);
243 mainLayout->addSpacing(6);
244 mainLayout->addWidget(ZoomGroup);
245 mainLayout->addSpacing(8);
246 mainLayout->addWidget(OptionsGroup);
247 mainLayout->addStretch(1);
248 setLayout(mainLayout);
257 void camera_control::change_theta(
int theta)
260 theta_hall = theta - 1;
263 sprintf(command,
"/vis/viewer/set/viewpointThetaPhi %d %d.", theta_hall, phi_hall);
266 sprintf(command,
"/vis/viewer/set/lightsThetaPhi %d %d.", theta_hall, phi_hall);
271 void camera_control::set_theta(
int index)
274 theta_hall = atoi(ThetaSet[index].c_str());
275 sprintf(command,
"/vis/viewer/set/viewpointThetaPhi %d %d.", theta_hall, phi_hall);
279 void camera_control::change_theta_s(
int theta)
281 theta_slider->setSliderPosition(atoi(ThetaSet[theta].c_str()));
284 void camera_control::change_phi(
int phi)
291 sprintf(command,
"/vis/viewer/set/viewpointThetaPhi %d %d", theta_hall, phi_hall);
294 sprintf(command,
"/vis/viewer/set/lightsThetaPhi %d %d.", theta_hall, phi_hall);
299 void camera_control::change_phi_s(
int phi)
301 phi_slider->setSliderPosition(atoi(PhiSet[phi].c_str()));
304 void camera_control::set_phi(
int index)
307 phi_hall = atoi(PhiSet[index].c_str());
308 sprintf(command,
"/vis/viewer/set/viewpointThetaPhi %d %d.", theta_hall, phi_hall);
312 void camera_control::clickpan_left()
315 sprintf(command,
"/vis/viewer/pan %3.2f 0 cm", -(pan_slider->value()*pan_slider->value()/4.0) /zoom_value);
319 void camera_control::clickpan_right()
322 sprintf(command,
"/vis/viewer/pan %3.2f 0 cm", (pan_slider->value()*pan_slider->value()/4.0) / zoom_value);
326 void camera_control::clickpan_up()
329 sprintf(command,
"/vis/viewer/pan 0 %3.2f cm", (pan_slider->value()*pan_slider->value()/4.0) / zoom_value);
333 void camera_control::clickpan_down()
336 sprintf(command,
"/vis/viewer/pan 0 %3.2f cm", -(pan_slider->value()*pan_slider->value()/4.0) / zoom_value);
340 void camera_control::zoom(
int zoom)
342 static float current_zoom = 0;
344 float dz = zoom - current_zoom;
346 zoom_value = 1 + dz/18.0;
350 sprintf(command,
"/vis/viewer/zoom %3.2f", zoom_value);
353 current_zoom = zoom_slider->value();
356 void camera_control::set_perspective(
int index)
359 double angles[4] = { 0, 30, 45, 60};
360 string which[4] = {
"o",
"p",
"p",
"p"};
362 sprintf(command,
"/vis/viewer/set/projection %s %4.2f ",which[index].c_str(), angles[index]);
366 void camera_control::switch_antialiasing(
int index)
370 glDisable (GL_LINE_SMOOTH);
371 glDisable (GL_POLYGON_SMOOTH);
375 glEnable (GL_LINE_SMOOTH);
376 glHint (GL_LINE_SMOOTH_HINT, GL_NICEST);
377 glEnable (GL_POLYGON_SMOOTH);
378 glHint (GL_POLYGON_SMOOTH_HINT, GL_NICEST);
380 UImanager->ApplyCommand(
"/vis/viewer/flush");
383 void camera_control::switch_auxiliary_edges(
int index)
387 UImanager->ApplyCommand(
"/vis/viewer/set/auxiliaryEdge 0");
388 UImanager->ApplyCommand(
"/vis/viewer/set/hiddenEdge 0");
392 UImanager->ApplyCommand(
"/vis/viewer/set/auxiliaryEdge 1");
393 UImanager->ApplyCommand(
"/vis/viewer/set/hiddenEdge 1");
395 UImanager->ApplyCommand(
"/vis/viewer/flush");
398 void camera_control::switch_sides_per_circle(
int index)
401 int sides[4] = { 50, 100, 200, 500};
403 sprintf(command,
"/vis/viewer/set/lineSegmentsPerCircle %d ", sides[index]);
405 UImanager->ApplyCommand(
"/vis/viewer/flush");
408 void camera_control::change_background_color()
411 QColor color = QColorDialog::getColor(Qt::green,
this);
412 color.getRgb(&r, &g, &b);
414 sprintf(command,
"/vis/viewer/set/background %3.2f %3.2f %3.2f", r/255.0, g/255.0, b/255.0);
418 void camera_control::take_screenshot()
422 void camera_control::update_angles()
437 cout << hd_msg <<
" Camera Control Widget Deleted." << endl;
camera_control(QWidget *parent, gemc_opts *)
string gemc_tostring(QString input)
map< string, opts > args
Options map.