23 QGroupBox *anglesGroup =
new QGroupBox(tr(
"Camera Control"));
24 anglesGroup->setMinimumWidth(450);
27 QLabel *moveLabel =
new QLabel(tr(
"Move:"));
28 moveCombo =
new QComboBox;
29 moveCombo->addItem(tr(
"Light"));
30 moveCombo->addItem(tr(
"Detector"));
34 QLabel *projLabel =
new QLabel(tr(
"Projection:"));
35 projCombo =
new QComboBox;
36 projCombo->addItem(tr(
"Orthogonal"));
37 projCombo->addItem(tr(
"Perspective 30"));
38 projCombo->addItem(tr(
"Perspective 45"));
39 projCombo->addItem(tr(
"Perspective 60"));
40 connect ( projCombo , SIGNAL( currentIndexChanged (
int) ),
this, SLOT( set_perspective(
int) ) );
42 QHBoxLayout *mpLayout =
new QHBoxLayout;
43 mpLayout->addWidget(moveLabel);
44 mpLayout->addWidget(moveCombo);
45 mpLayout->addSpacing(100);
46 mpLayout->addWidget(projLabel);
47 mpLayout->addWidget(projCombo);
49 theta_hall = phi_hall = 0;
52 QLabel *thetaLabel =
new QLabel(tr(
"theta"));
53 theta_slider =
new QSlider(Qt::Horizontal);
54 theta_slider->setTickInterval(1);
55 theta_slider->setRange(0, 180);
57 QLCDNumber *Theta_LCD =
new QLCDNumber(
this);
58 Theta_LCD->setFont(QFont(
"Helvetica", 32, QFont::Bold));
59 Theta_LCD->setMaximumSize(45, 45);
60 Theta_LCD->setSegmentStyle(QLCDNumber::Flat);
61 for(
int t=0; t<=180; t+=30)
64 sprintf(tmp,
"%d", t);
65 ThetaSet.push_back(tmp);
68 QComboBox *ThetaCombo =
new QComboBox;
69 for(
unsigned int i=0; i<ThetaSet.size(); i++) ThetaCombo->addItem(tr(ThetaSet[i].c_str()));
70 ThetaCombo->setMaximumSize(60, 45);
71 QHBoxLayout *thetaLayout =
new QHBoxLayout;
72 thetaLayout->addWidget(thetaLabel);
73 thetaLayout->addWidget(theta_slider);
74 thetaLayout->addWidget(Theta_LCD);
75 thetaLayout->addWidget(ThetaCombo);
77 connect ( theta_slider , SIGNAL( valueChanged (
int) ),
this, SLOT( change_theta(
int) ) );
78 connect ( theta_slider , SIGNAL( valueChanged (
int) ), Theta_LCD, SLOT( display(
int) ) );
79 connect ( ThetaCombo , SIGNAL( currentIndexChanged (
int) ),
this, SLOT( set_theta(
int) ) );
80 connect ( ThetaCombo , SIGNAL( currentIndexChanged (
int) ),
this, SLOT( change_theta_s(
int) ) );
83 QLabel *phiLabel =
new QLabel(tr(
"phi"));
84 phi_slider =
new QSlider(Qt::Horizontal);
85 phi_slider->setTickInterval(1);
86 phi_slider->setRange(0, 360);
87 QLCDNumber *Phi_LCD =
new QLCDNumber(
this);
88 Phi_LCD->setFont(QFont(
"Helvetica", 32, QFont::Bold));
89 Phi_LCD->setMaximumSize(45, 45);
90 Phi_LCD->setSegmentStyle(QLCDNumber::Flat);
91 for(
int t=0; t<=360; t+=30)
94 sprintf(tmp,
"%d", t);
95 PhiSet.push_back(tmp);
97 QComboBox *PhiCombo =
new QComboBox;
98 for(
unsigned int i=0; i<PhiSet.size(); i++) PhiCombo->addItem(tr(PhiSet[i].c_str()));
99 PhiCombo->setMaximumSize(60, 45);
100 QHBoxLayout *phiLayout =
new QHBoxLayout;
101 phiLayout->addWidget(phiLabel);
102 phiLayout->addWidget(phi_slider);
103 phiLayout->addWidget(Phi_LCD);
104 phiLayout->addWidget(PhiCombo);
106 connect ( phi_slider , SIGNAL( valueChanged (
int) ),
this, SLOT( change_phi(
int) ) );
107 connect ( phi_slider , SIGNAL( valueChanged (
int) ), Phi_LCD, SLOT( display(
int) ) );
108 connect ( PhiCombo , SIGNAL( currentIndexChanged (
int) ),
this, SLOT( set_phi(
int) ) );
109 connect ( PhiCombo , SIGNAL( currentIndexChanged (
int) ),
this, SLOT( change_phi_s(
int) ) );
111 QVBoxLayout *anglesLayout =
new QVBoxLayout;
112 anglesLayout->addLayout(mpLayout);
113 anglesLayout->addSpacing(12);
114 anglesLayout->addLayout(thetaLayout);
115 anglesLayout->addSpacing(2);
116 anglesLayout->addLayout(phiLayout);
117 anglesGroup->setLayout(anglesLayout);
124 sliceXEdit =
new QLineEdit(tr(
"0"));
125 sliceXEdit->setMaximumWidth(100);
127 sliceXActi =
new QCheckBox(tr(
"&Active: "));
128 sliceXActi->setChecked(
false);
130 sliceXInve =
new QCheckBox(tr(
"&Invert: "));
131 sliceXInve->setChecked(
false);
133 QHBoxLayout *sliceXLayout =
new QHBoxLayout;
134 sliceXLayout->addWidget(
new QLabel(tr(
"X: ")));
135 sliceXLayout->addWidget(sliceXEdit);
136 sliceXLayout->addStretch(1);
137 sliceXLayout->addWidget(sliceXActi);
138 sliceXLayout->addWidget(sliceXInve);
139 sliceXLayout->addStretch(1);
143 sliceYEdit =
new QLineEdit(tr(
"0"));
144 sliceYEdit->setMaximumWidth(100);
146 sliceYActi =
new QCheckBox(tr(
"&Active: "));
147 sliceYActi->setChecked(
false);
149 sliceYInve =
new QCheckBox(tr(
"&Invert: "));
150 sliceYInve->setChecked(
false);
152 QHBoxLayout *sliceYLayout =
new QHBoxLayout;
153 sliceYLayout->addWidget(
new QLabel(tr(
"Y: ")));
154 sliceYLayout->addWidget(sliceYEdit);
155 sliceYLayout->addStretch(1);
156 sliceYLayout->addWidget(sliceYActi);
157 sliceYLayout->addWidget(sliceYInve);
158 sliceYLayout->addStretch(1);
163 sliceZEdit =
new QLineEdit(tr(
"0"));
164 sliceZEdit->setMaximumWidth(100);
166 sliceZActi =
new QCheckBox(tr(
"&Active: "));
167 sliceZActi->setChecked(
false);
169 sliceZInve =
new QCheckBox(tr(
"&Invert: "));
170 sliceZInve->setChecked(
false);
172 QHBoxLayout *sliceZLayout =
new QHBoxLayout;
173 sliceZLayout->addWidget(
new QLabel(tr(
"Z: ")));
174 sliceZLayout->addWidget(sliceZEdit);
175 sliceZLayout->addStretch(1);
176 sliceZLayout->addWidget(sliceZActi);
177 sliceZLayout->addWidget(sliceZInve);
178 sliceZLayout->addStretch(1);
181 connect ( sliceXEdit , SIGNAL( textChanged(
const QString &) ),
this, SLOT( slice() ) );
182 connect ( sliceYEdit , SIGNAL( textChanged(
const QString &) ),
this, SLOT( slice() ) );
183 connect ( sliceZEdit , SIGNAL( textChanged(
const QString &) ),
this, SLOT( slice() ) );
185 connect ( sliceXActi , SIGNAL( stateChanged(
int) ),
this, SLOT( slice() ) );
186 connect ( sliceYActi , SIGNAL( stateChanged(
int) ),
this, SLOT( slice() ) );
187 connect ( sliceZActi , SIGNAL( stateChanged(
int) ),
this, SLOT( slice() ) );
190 QPushButton *clearSliceButton =
new QPushButton(tr(
"Clear Slices"));
191 clearSliceButton->setToolTip(
"Clear Slice Planes");
192 clearSliceButton->setIcon(style()->standardIcon(QStyle::SP_DialogResetButton));
193 connect ( clearSliceButton , SIGNAL(clicked()),
this, SLOT( clearSlice() ) );
197 QVBoxLayout *sliceLayout =
new QVBoxLayout;
198 sliceLayout->addLayout(sliceXLayout);
199 sliceLayout->addLayout(sliceYLayout);
200 sliceLayout->addLayout(sliceZLayout);
201 sliceLayout->addWidget(clearSliceButton);
204 QGroupBox *sliceGroup =
new QGroupBox(tr(
"Slices [mm]"));
205 sliceGroup->setLayout(sliceLayout);
209 QLabel *antialiasingLabel =
new QLabel(tr(
"Anti-Aliasing"));
210 aliasing =
new QComboBox;
211 aliasing->addItem(tr(
"OFF"));
212 aliasing->addItem(tr(
"ON"));
213 QHBoxLayout *aliasingLayout =
new QHBoxLayout;
214 aliasingLayout->addWidget(antialiasingLabel);
215 aliasingLayout->addWidget(aliasing);
216 connect ( aliasing , SIGNAL( currentIndexChanged (
int) ),
this, SLOT( switch_antialiasing(
int) ) );
218 QLabel *sides_per_circlesLabel =
new QLabel(tr(
"Sides per circle"));
219 sides_per_circle =
new QComboBox;
220 sides_per_circle->addItem(tr(
"25"));
221 sides_per_circle->addItem(tr(
"50"));
222 sides_per_circle->addItem(tr(
"100"));
223 sides_per_circle->addItem(tr(
"200"));
224 sides_per_circle->setCurrentIndex(0);
225 QHBoxLayout *sides_per_circleLayout =
new QHBoxLayout;
226 sides_per_circleLayout->addWidget(sides_per_circlesLabel);
227 sides_per_circleLayout->addWidget(sides_per_circle);
228 connect ( sides_per_circle , SIGNAL( currentIndexChanged (
int) ),
this, SLOT( switch_sides_per_circle(
int) ) );
230 QLabel *auxiliaryEdgesLabel =
new QLabel(tr(
"Auxiliary Edges"));
231 auxiliary =
new QComboBox;
232 auxiliary->addItem(tr(
"OFF"));
233 auxiliary->addItem(tr(
"ON"));
234 QHBoxLayout *auxedgesLayout =
new QHBoxLayout;
235 auxedgesLayout->addWidget(auxiliaryEdgesLabel);
236 auxedgesLayout->addWidget(auxiliary);
237 connect ( auxiliary , SIGNAL( currentIndexChanged (
int) ),
this, SLOT( switch_auxiliary_edges(
int) ) );
239 QVBoxLayout *voptionsLayout =
new QVBoxLayout;
240 voptionsLayout->addLayout(aliasingLayout);
241 voptionsLayout->addLayout(sides_per_circleLayout);
242 voptionsLayout->addLayout(auxedgesLayout);
245 QGroupBox *vOptionsGroup =
new QGroupBox(tr(
"Visualization Options"));
246 vOptionsGroup->setLayout(voptionsLayout);
249 QHBoxLayout *sliceOptionsLayout =
new QHBoxLayout;
250 sliceOptionsLayout->addWidget(sliceGroup);
251 sliceOptionsLayout->addWidget(vOptionsGroup);
256 explodeSlider =
new QSlider(Qt::Horizontal);
257 explodeSlider->setTickInterval(1);
258 explodeSlider->setRange(0, 30);
259 connect ( explodeSlider , SIGNAL( valueChanged(
int) ),
this, SLOT( explode(
int) ) );
261 QPushButton *screenShotPNG =
new QPushButton(tr(
"PNG"));
262 screenShotPNG->setToolTip(
"Print a screenshot to a PNG file");
263 screenShotPNG->setIcon(style()->standardIcon(QStyle::SP_DialogSaveButton));
264 connect ( screenShotPNG , SIGNAL(clicked()),
this, SLOT( printPNG() ));
266 QPushButton *screenShotEPS =
new QPushButton(tr(
"EPS"));
267 screenShotEPS->setToolTip(
"Print a screenshot to a encapsulated poscript file");
268 screenShotEPS->setIcon(style()->standardIcon(QStyle::SP_DialogSaveButton));
269 connect ( screenShotEPS , SIGNAL(clicked()),
this, SLOT( printEPS() ));
271 QPushButton *screenShotPDF =
new QPushButton(tr(
"PDF"));
272 screenShotPDF->setToolTip(
"Print a screenshot to PDF");
273 screenShotPDF->setIcon(style()->standardIcon(QStyle::SP_DialogSaveButton));
274 connect ( screenShotPDF , SIGNAL(clicked()),
this, SLOT( printPDF() ));
277 QHBoxLayout *explodeLayout =
new QHBoxLayout;
278 explodeLayout->addWidget(explodeSlider);
279 explodeLayout->addWidget(screenShotPNG);
280 explodeLayout->addWidget(screenShotPDF);
281 explodeLayout->addWidget(screenShotEPS);
283 QGroupBox *explodeGroup =
new QGroupBox(tr(
"Explode"));
284 explodeGroup->setLayout(explodeLayout);
289 QVBoxLayout *mainLayout =
new QVBoxLayout;
290 mainLayout->addWidget(anglesGroup);
291 mainLayout->addLayout(sliceOptionsLayout);
292 mainLayout->addSpacing(6);
293 mainLayout->addWidget(explodeGroup);
294 mainLayout->addStretch(1);
295 setLayout(mainLayout);
302 void camera_control::printPNG()
305 sprintf(command,
"/vis/ogl/export gemc.png");
310 void camera_control::printEPS()
313 sprintf(command,
"/vis/ogl/set/printMode vectored");
315 sprintf(command,
"/vis/ogl/printEPS");
319 void camera_control::printPDF()
322 sprintf(command,
"/vis/ogl/export gemc.pdf");
328 void camera_control::slice()
332 UImanager->ApplyCommand(
"/vis/geometry/set/forceSolid all -1 1");
335 UImanager->ApplyCommand(
"/vis/viewer/clearCutawayPlanes");
337 UImanager->ApplyCommand(
"/vis/viewer/set/cutawayMode intersection");
339 char command[200] =
"";
341 if(sliceXActi->isChecked() )
343 sprintf(command,
"/vis/viewer/addCutawayPlane %d 0 0 mm %d 0 0 ", (
int)
qs_toDouble(sliceXEdit->text()), sliceXInve->isChecked() ? -1 : 1 );
346 if(sliceYActi->isChecked() )
348 sprintf(command,
"/vis/viewer/addCutawayPlane 0 %d 0 mm 0 %d 0 ", (
int)
qs_toDouble(sliceYEdit->text()), sliceYInve->isChecked() ? -1 : 1);
351 if(sliceZActi->isChecked() )
353 sprintf(command,
"/vis/viewer/addCutawayPlane 0 0 %d mm 0 0 %d ", (
int)
qs_toDouble(sliceZEdit->text()), sliceZInve->isChecked() ? -1 : 1);
364 void camera_control::clearSlice()
366 UImanager->ApplyCommand(
"/vis/viewer/clearCutawayPlanes");
368 sliceXActi->setChecked(
false);
369 sliceYActi->setChecked(
false);
370 sliceZActi->setChecked(
false);
376 void camera_control::change_theta(
int theta)
379 theta_hall = theta - 1;
381 if(
qs_tostring(moveCombo->currentText()) ==
"Detector")
382 sprintf(command,
"/vis/viewer/set/viewpointThetaPhi %d %d.", theta_hall, phi_hall);
384 if(
qs_tostring(moveCombo->currentText()) ==
"Light")
385 sprintf(command,
"/vis/viewer/set/lightsThetaPhi %d %d.", theta_hall, phi_hall);
390 void camera_control::set_theta(
int index)
393 theta_hall = atoi(ThetaSet[index].c_str());
394 sprintf(command,
"/vis/viewer/set/viewpointThetaPhi %d %d.", theta_hall, phi_hall);
398 void camera_control::change_theta_s(
int theta)
400 theta_slider->setSliderPosition(atoi(ThetaSet[theta].c_str()));
403 void camera_control::change_phi(
int phi)
409 if(
qs_tostring(moveCombo->currentText()) ==
"Detector")
410 sprintf(command,
"/vis/viewer/set/viewpointThetaPhi %d %d", theta_hall, phi_hall);
412 if(
qs_tostring(moveCombo->currentText()) ==
"Light")
413 sprintf(command,
"/vis/viewer/set/lightsThetaPhi %d %d.", theta_hall, phi_hall);
418 void camera_control::change_phi_s(
int phi)
420 phi_slider->setSliderPosition(atoi(PhiSet[phi].c_str()));
423 void camera_control::set_phi(
int index)
426 phi_hall = atoi(PhiSet[index].c_str());
427 sprintf(command,
"/vis/viewer/set/viewpointThetaPhi %d %d.", theta_hall, phi_hall);
432 void camera_control::explode(
int boom)
436 double xf = 1 + ((double) boom)/15.0;
438 sprintf(command,
"/vis/viewer/set/explodeFactor %3.2f", xf);
443 void camera_control::set_perspective(
int index)
446 double angles[4] = { 0, 30, 45, 60};
447 string which[4] = {
"o",
"p",
"p",
"p"};
449 sprintf(command,
"/vis/viewer/set/projection %s %4.2f ",which[index].c_str(), angles[index]);
453 void camera_control::switch_antialiasing(
int index)
457 glDisable (GL_LINE_SMOOTH);
458 glDisable (GL_POLYGON_SMOOTH);
462 glEnable (GL_LINE_SMOOTH);
463 glHint (GL_LINE_SMOOTH_HINT, GL_NICEST);
464 glEnable (GL_POLYGON_SMOOTH);
465 glHint (GL_POLYGON_SMOOTH_HINT, GL_NICEST);
467 UImanager->ApplyCommand(
"/vis/viewer/flush");
470 void camera_control::switch_auxiliary_edges(
int index)
474 UImanager->ApplyCommand(
"/vis/viewer/set/auxiliaryEdge 0");
475 UImanager->ApplyCommand(
"/vis/viewer/set/hiddenEdge 0");
479 UImanager->ApplyCommand(
"/vis/viewer/set/auxiliaryEdge 1");
480 UImanager->ApplyCommand(
"/vis/viewer/set/hiddenEdge 1");
482 UImanager->ApplyCommand(
"/vis/viewer/flush");
485 void camera_control::switch_sides_per_circle(
int index)
488 int sides[4] = { 25, 50, 100, 200};
490 sprintf(command,
"/vis/viewer/set/lineSegmentsPerCircle %d ", sides[index]);
492 UImanager->ApplyCommand(
"/vis/viewer/flush");
496 void camera_control::update_angles()
511 cout << hd_msg <<
" Camera Control Widget Deleted." << endl;
double qs_toDouble(QString input)
map< string, aopt > optMap
Options map.
string qs_tostring(QString input)
camera_control(QWidget *parent, goptions *)