35 #ifdef G4VIS_BUILD_OPENGLQT_DRIVER
60 #include <qpushbutton.h>
62 #include <qapplication.h>
63 #include <qdesktopwidget.h>
66 #include <qimagewriter.h>
68 #include <qtextedit.h>
69 #include <qtreewidget.h>
70 #include <qapplication.h>
71 #include <qmessagebox.h>
72 #include <qfiledialog.h>
74 #include <qdatetime.h>
78 #include <qcolordialog.h>
81 #include <qgroupbox.h>
82 #include <qcombobox.h>
83 #include <qlineedit.h>
84 #include <qsignalmapper.h>
87 void G4OpenGLQtViewer::CreateMainWindow (
100 G4Qt* interactorManager = G4Qt::getInstance ();
102 ResizeWindow(fVP.GetWindowSizeHintX(),fVP.GetWindowSizeHintY());
114 if (UI == NULL)
return;
116 if (! static_cast<G4UIQt*> (UI->GetG4UIWindow())) {
121 fUiQt =
static_cast<G4UIQt*
> (UI->GetG4UIWindow());
123 bool isTabbedView =
false;
126 if (!interactorManager->IsExternalApp()) {
127 isTabbedView = fUiQt->AddTabWidget((QWidget*)fWindow,name,getWinWidth(),getWinHeight());
128 fUISceneTreeComponentsTBWidget = fUiQt->GetSceneTreeComponentsTBWidget();
133 #ifdef G4DEBUG_VIS_OGL
135 printf(
"G4OpenGLQtViewer::CreateMainWindow :: UIQt NOt found \n");
141 QWidget *myParent = getParentWidget();
142 #ifdef G4DEBUG_VIS_OGL
143 printf(
"G4OpenGLQtViewer::CreateMainWindow :: getParent OK \n");
145 if (myParent != NULL) {
146 glWidget->setParent(myParent);
148 QHBoxLayout *mainLayout =
new QHBoxLayout();
150 mainLayout->setMargin(0);
151 mainLayout->setSpacing(0);
152 mainLayout->addWidget(fWindow);
153 if (fGLWindow->inherits(
"QMainWindow")) {
154 fGLWindow->setWindowTitle( name);
156 fGLWindow->setLayout(mainLayout);
160 int offset = QApplication::desktop()->height()
161 - QApplication::desktop()->availableGeometry().height();
163 G4int YPos= fVP.GetWindowAbsoluteLocationHintY(QApplication::desktop()->height());
164 if (fVP.GetWindowAbsoluteLocationHintY(QApplication::desktop()->height())< offset) {
167 #ifdef G4DEBUG_VIS_OGL
168 printf(
"G4OpenGLQtViewer::CreateMainWindow :: resizing to %d %d \n",getWinWidth(), getWinHeight());
170 fGLWindow->move(fVP.GetWindowAbsoluteLocationHintX(QApplication::desktop()->width()),YPos);
185 G4OpenGLQtViewer::G4OpenGLQtViewer (
186 G4OpenGLSceneHandler& scene
189 ,G4OpenGLViewer (scene)
192 ,fRecordFrameNumber(0)
196 ,fHoldKeyEvent(false)
197 ,fHoldMoveEvent(false)
198 ,fHoldRotateEvent(false)
202 ,fMovieTempFolderPath(
"")
204 ,fParameterFileName(
"ppmtompeg_encode_parameter_file.par")
205 ,fMovieParametersDialog(NULL)
206 ,fRecordingStep(WAIT)
208 ,fNbMaxFramesPerSec(100)
209 ,fNbMaxAnglePerSec(360)
210 ,fLaunchSpinDelay(100)
211 ,fUISceneTreeComponentsTBWidget(NULL)
214 ,fControlKeyPress(false)
215 ,fShiftKeyPress(false)
217 ,fCheckSceneTreeComponentSignalLock(false)
218 ,fSceneTreeComponentTreeWidget(NULL)
219 ,fOldSceneTreeComponentTreeWidget(NULL)
220 ,fSceneTreeWidget(NULL)
221 ,fPVRootNodeCreate(false)
225 ,fTouchableVolumes(
"Touchables")
226 ,fShortcutsDialog(NULL)
227 ,fSceneTreeDepthSlider(NULL)
229 ,fModelShortNameItem(NULL)
230 ,fMaxPOindexInserted(-1)
232 ,signalMapperMouse(NULL)
233 ,signalMapperSurface(NULL)
237 if (QCoreApplication::instance () == NULL) {
240 G4Qt::getInstance ();
242 fLastPos3 = QPoint(-1,-1);
243 fLastPos2 = QPoint(-1,-1);
244 fLastPos1 = QPoint(-1,-1);
246 initMovieParameters();
248 fLastEventTime =
new QTime();
249 signalMapperMouse =
new QSignalMapper(
this);
250 signalMapperSurface =
new QSignalMapper(
this);
253 fFileSavePath = QDir::currentPath();
254 fDefaultSaveFileFormat =
"png";
256 #ifdef G4DEBUG_VIS_OGL
257 printf(
"G4OpenGLQtViewer::G4OpenGLQtViewer END\n");
262 G4OpenGLQtViewer::~G4OpenGLQtViewer (
270 if (fSceneTreeWidget != NULL) {
271 if (fSceneTreeWidget->layout() != NULL) {
272 while ((wItem = fSceneTreeWidget->layout()->takeAt(0)) != 0) {
273 delete wItem->widget();
277 if (fUISceneTreeComponentsTBWidget != NULL) {
278 fUISceneTreeComponentsTBWidget->removeTab(fUISceneTreeComponentsTBWidget->indexOf(fSceneTreeWidget));
281 G4cout <<removeTempFolder().toStdString().c_str() <<
G4endl;
288 void G4OpenGLQtViewer::createPopupMenu() {
290 fContextMenu =
new QMenu(
"All");
292 QMenu *mMouseAction = fContextMenu->addMenu(
"&Mouse actions");
294 fMouseRotateAction = mMouseAction->addAction(
"Rotate", signalMapperMouse, SLOT(map()));
295 fMouseMoveAction = mMouseAction->addAction(
"Move", signalMapperMouse, SLOT(map()));
296 fMousePickAction = mMouseAction->addAction(
"Pick", signalMapperMouse, SLOT(map()));
297 fMouseZoomOutAction = mMouseAction->addAction(
"Zoom out", signalMapperMouse, SLOT(map()));
298 fMouseZoomInAction = mMouseAction->addAction(
"Zoom in", signalMapperMouse, SLOT(map()));
299 QAction *shortcutsAction = mMouseAction->addAction(
"Show shortcuts");
301 fMouseRotateAction->setCheckable(
true);
302 fMouseMoveAction->setCheckable(
true);
303 fMousePickAction->setCheckable(
true);
304 fMouseZoomOutAction->setCheckable(
true);
305 fMouseZoomInAction->setCheckable(
true);
306 shortcutsAction->setCheckable(
false);
308 connect(signalMapperMouse, SIGNAL(mapped(
int)),
this, SLOT(toggleMouseAction(
int)));
309 signalMapperMouse->setMapping(fMouseRotateAction,1);
310 signalMapperMouse->setMapping(fMouseMoveAction,2);
311 signalMapperMouse->setMapping(fMousePickAction,3);
312 signalMapperMouse->setMapping(fMouseZoomOutAction,4);
313 signalMapperMouse->setMapping(fMouseZoomInAction,5);
315 QObject::connect(shortcutsAction,
316 SIGNAL(triggered(
bool)),
318 SLOT(showShortcuts()));
321 QMenu *mStyle = fContextMenu->addMenu(
"&Style");
323 QMenu *mProjection = mStyle->addMenu(
"&Projection");
325 fProjectionOrtho = mProjection->addAction(
"Orthographic", signalMapperSurface, SLOT(map()));
326 fProjectionPerspective = mProjection->addAction(
"Persepective", signalMapperSurface, SLOT(map()));
329 if (fVP.GetFieldHalfAngle() == 0) {
330 createRadioAction(fProjectionOrtho, fProjectionPerspective,SLOT(toggleProjection(
bool)),1);
332 createRadioAction(fProjectionOrtho, fProjectionPerspective,SLOT(toggleProjection(
bool)),2);
336 QMenu *mDrawing = mStyle->addMenu(
"&Drawing");
338 fDrawingWireframe = mDrawing->addAction(
"Wireframe", signalMapperSurface, SLOT(map()));
340 fDrawingLineRemoval = mDrawing->addAction(
"Hidden line removal", signalMapperSurface, SLOT(map()));
342 fDrawingSurfaceRemoval = mDrawing->addAction(
"Hidden Surface removal", signalMapperSurface, SLOT(map()));
344 fDrawingLineSurfaceRemoval = mDrawing->addAction(
"Hidden line and surface removal", signalMapperSurface, SLOT(map()));
346 fDrawingWireframe->setCheckable(
true);
347 fDrawingLineRemoval->setCheckable(
true);
348 fDrawingSurfaceRemoval->setCheckable(
true);
349 fDrawingLineSurfaceRemoval->setCheckable(
true);
351 connect(signalMapperSurface, SIGNAL(mapped(
int)),
this, SLOT(toggleSurfaceAction(
int)));
352 signalMapperSurface->setMapping(fDrawingWireframe,1);
353 signalMapperSurface->setMapping(fDrawingLineRemoval,2);
354 signalMapperSurface->setMapping(fDrawingSurfaceRemoval,3);
355 signalMapperSurface->setMapping(fDrawingLineSurfaceRemoval,4);
360 QAction *backgroundColorChooser ;
362 backgroundColorChooser = mStyle->addAction(
"Background color");
363 QObject ::connect(backgroundColorChooser,
366 SLOT(actionChangeBackgroundColor()));
370 QAction *textColorChooser ;
372 textColorChooser = mStyle->addAction(
"Text color");
373 QObject ::connect(textColorChooser,
376 SLOT(actionChangeTextColor()));
380 QAction *defaultColorChooser ;
382 defaultColorChooser = mStyle->addAction(
"Default color");
383 QObject ::connect(defaultColorChooser,
386 SLOT(actionChangeDefaultColor()));
390 QMenu *mActions = fContextMenu->addMenu(
"&Actions");
391 QAction *createEPS = mActions->addAction(
"Save as ...");
392 QObject ::connect(createEPS,
395 SLOT(actionSaveImage()));
398 QAction *movieParameters = mActions->addAction(
"Movie parameters...");
399 QObject ::connect(movieParameters,
402 SLOT(actionMovieParameters()));
408 QMenu *mSpecial = fContextMenu->addMenu(
"S&pecial");
409 QMenu *mTransparency = mSpecial->addMenu(
"Transparency");
410 QAction *transparencyOn = mTransparency->addAction(
"On");
411 QAction *transparencyOff = mTransparency->addAction(
"Off");
413 if (transparency_enabled ==
false) {
414 createRadioAction(transparencyOn,transparencyOff,SLOT(toggleTransparency(
bool)),2);
415 }
else if (transparency_enabled ==
true) {
416 createRadioAction(transparencyOn,transparencyOff,SLOT(toggleTransparency(
bool)),1);
422 QMenu *mAntialiasing = mSpecial->addMenu(
"Antialiasing");
423 QAction *antialiasingOn = mAntialiasing->addAction(
"On");
424 QAction *antialiasingOff = mAntialiasing->addAction(
"Off");
426 if (antialiasing_enabled ==
false) {
427 createRadioAction(antialiasingOn,antialiasingOff,SLOT(toggleAntialiasing(
bool)),2);
428 }
else if (antialiasing_enabled ==
true) {
429 createRadioAction(antialiasingOn,antialiasingOff,SLOT(toggleAntialiasing(
bool)),1);
431 mAntialiasing->clear();
434 QMenu *mHaloing = mSpecial->addMenu(
"Haloing");
435 QAction *haloingOn = mHaloing->addAction(
"On");
436 QAction *haloingOff = mHaloing->addAction(
"Off");
437 if (haloing_enabled ==
false) {
438 createRadioAction(haloingOn,haloingOff,SLOT(toggleHaloing(
bool)),2);
439 }
else if (haloing_enabled ==
true) {
440 createRadioAction(haloingOn,haloingOff,SLOT(toggleHaloing(
bool)),1);
445 QMenu *mAux = mSpecial->addMenu(
"Auxiliary edges");
446 QAction *auxOn = mAux->addAction(
"On");
447 QAction *auxOff = mAux->addAction(
"Off");
448 if (!fVP.IsAuxEdgeVisible()) {
449 createRadioAction(auxOn,auxOff,SLOT(toggleAux(
bool)),2);
451 createRadioAction(auxOn,auxOff,SLOT(toggleAux(
bool)),1);
455 QMenu *mHiddenMarkers = mSpecial->addMenu(
"Hidden markers");
456 QAction *hiddenMarkersOn = mHiddenMarkers->addAction(
"On");
457 QAction *hiddenMarkersOff = mHiddenMarkers->addAction(
"Off");
458 if (fVP.IsMarkerNotHidden()) {
459 createRadioAction(hiddenMarkersOn,hiddenMarkersOff,SLOT(toggleHiddenMarkers(
bool)),2);
461 createRadioAction(hiddenMarkersOn,hiddenMarkersOff,SLOT(toggleHiddenMarkers(
bool)),1);
466 QMenu *mFullScreen = mSpecial->addMenu(
"&Full screen");
467 fFullScreenOn = mFullScreen->addAction(
"On");
468 fFullScreenOff = mFullScreen->addAction(
"Off");
469 createRadioAction(fFullScreenOn,fFullScreenOff,SLOT(toggleFullScreen(
bool)),2);
472 updateToolbarAndMouseContextMenu();
476 void G4OpenGLQtViewer::G4manageContextMenuEvent(QContextMenuEvent *e)
479 G4cerr <<
"Visualization window not defined, please choose one before" <<
G4endl;
486 if ( fContextMenu ) {
487 fContextMenu->exec( e->globalPos() );
503 void G4OpenGLQtViewer::createRadioAction(QAction *action1,QAction *action2,
const std::string& method,
unsigned int nCheck) {
505 action1->setCheckable(
true);
506 action2->setCheckable(
true);
509 action1->setChecked (
true);
511 action2->setChecked (
true);
513 QObject ::connect(action1, SIGNAL(triggered(
bool)),action2, SLOT(toggle()));
514 QObject ::connect(action2, SIGNAL(triggered(
bool)),action1, SLOT(toggle()));
516 QObject ::connect(action1, SIGNAL(toggled(
bool)),
this, method.c_str());
525 void G4OpenGLQtViewer::showShortcuts() {
528 text =
"========= Mouse Shortcuts =========\n";
530 if (fUiQt->IsIconRotateSelected()) {
531 text +=
"Click and move mouse to rotate volume \n";
532 text +=
"ALT + Click and move mouse to rotate volume (Toggle View/Theta-Phi Direction) \n";
533 text +=
"CTRL + Click and move mouse to zoom in/out \n";
534 text +=
"SHIFT + Click and move mouse to change camera point of view \n";
535 }
else if (fUiQt->IsIconMoveSelected()) {
536 text +=
"Move camera point of view with mouse \n";
537 }
else if (fUiQt->IsIconPickSelected()) {
538 text +=
"Click and pick \n";
541 text +=
"Click and move mouse to rotate volume \n";
542 text +=
"ALT + Click and move mouse to rotate volume (Toggle View/Theta-Phi Direction) \n";
543 text +=
"CTRL + Click and zoom mouse to zoom in/out \n";
544 text +=
"SHIFT + Click and zoommove camera point of view \n";
546 text +=
"========= Move Shortcuts ========= \n";
547 text +=
"Press left/right arrows to move volume left/right \n";
548 text +=
"Press up/down arrows to move volume up/down \n";
549 text +=
"Press '+'/'-' to move volume toward/forward \n";
551 text +=
"========= Rotation (Theta/Phi) Shortcuts ========= \n";
552 text +=
"Press SHIFT + left/right arrows to rotate volume left/right \n";
553 text +=
"Press SHIFT + up/down arrows to rotate volume up/down \n";
555 text +=
"========= Rotation (View Direction) Shortcuts ========= \n";
556 text +=
"Press ALT + left/right to rotate volume around vertical direction \n";
557 text +=
"Press ALT + up/down to rotate volume around horizontal direction \n";
559 text +=
"========= Zoom View ========= \n";
560 text +=
"Press CTRL + '+'/'-' to zoom into volume \n";
562 text +=
"========= Misc ========= \n";
563 text +=
"Press ALT +/- to slow/speed rotation/move \n";
564 text +=
"Press H to reset view \n";
565 text +=
"Press Esc to exit FullScreen \n";
567 text +=
"========= Video ========= \n";
568 text +=
"In video mode : \n";
569 text +=
" Press SPACE to Start/Pause video recording \n";
570 text +=
" Press RETURN to Stop video recording \n";
575 if ( fShortcutsDialog == NULL) {
576 fShortcutsDialog =
new QDialog();
577 fShortcutsDialogInfos =
new QTextEdit() ;
578 QVBoxLayout *mainLayout =
new QVBoxLayout;
579 mainLayout->addWidget(fShortcutsDialogInfos);
580 fShortcutsDialog->setLayout(mainLayout);
581 fShortcutsDialog->setWindowTitle(tr(
"Shortcuts"));
584 fShortcutsDialogInfos->setPlainText(text.data());
585 fShortcutsDialog->show();
596 void G4OpenGLQtViewer::toggleMouseAction(
int aAction) {
599 fUiQt->SetIconRotateSelected();
600 }
else if (aAction == 2) {
601 fUiQt->SetIconMoveSelected();
602 }
else if (aAction == 3) {
603 fUiQt->SetIconPickSelected();
604 }
else if (aAction == 4) {
605 fUiQt->SetIconZoomOutSelected();
606 }
else if (aAction == 5) {
607 fUiQt->SetIconZoomInSelected();
610 updateToolbarAndMouseContextMenu();
624 void G4OpenGLQtViewer::toggleSurfaceAction(
int aAction) {
631 }
else if (aAction ==2) {
634 }
else if (aAction ==3) {
637 }
else if (aAction ==4) {
640 fVP.SetDrawingStyle(d_style);
642 updateToolbarAndMouseContextMenu();
657 void G4OpenGLQtViewer::toggleProjection(
bool check) {
660 fVP.SetOrthogonalProjection ();
662 fVP.SetPerspectiveProjection();
664 updateToolbarAndMouseContextMenu();
673 void G4OpenGLQtViewer::toggleTransparency(
bool check) {
676 transparency_enabled =
true;
678 transparency_enabled =
false;
680 SetNeedKernelVisit (
true);
681 updateToolbarAndMouseContextMenu();
689 void G4OpenGLQtViewer::toggleAntialiasing(
bool check) {
692 antialiasing_enabled =
false;
693 glDisable (GL_LINE_SMOOTH);
694 glDisable (GL_POLYGON_SMOOTH);
696 antialiasing_enabled =
true;
697 glEnable (GL_LINE_SMOOTH);
698 glHint (GL_LINE_SMOOTH_HINT, GL_NICEST);
699 glEnable (GL_POLYGON_SMOOTH);
700 glHint (GL_POLYGON_SMOOTH_HINT, GL_NICEST);
703 updateToolbarAndMouseContextMenu();
712 void G4OpenGLQtViewer::toggleHaloing(
bool check) {
714 haloing_enabled =
false;
716 haloing_enabled =
true;
719 updateToolbarAndMouseContextMenu();
728 void G4OpenGLQtViewer::toggleAux(
bool check) {
730 fVP.SetAuxEdgeVisible(
true);
732 fVP.SetAuxEdgeVisible(
false);
734 SetNeedKernelVisit (
true);
735 updateToolbarAndMouseContextMenu();
743 void G4OpenGLQtViewer::toggleHiddenMarkers(
bool check) {
745 fVP.SetMarkerHidden();
747 fVP.SetMarkerNotHidden();
750 updateToolbarAndMouseContextMenu();
757 void G4OpenGLQtViewer::toggleFullScreen(
bool check) {
758 if (check != fGLWindow->isFullScreen()) {
759 fGLWindow->setWindowState(fGLWindow->windowState() ^ Qt::WindowFullScreen);
764 void G4OpenGLQtViewer::savePPMToTemp() {
765 if (fMovieTempFolderPath ==
"") {
768 QString fileName =
"Test"+QString::number(fRecordFrameNumber)+
".ppm";
769 QString filePath =fMovieTempFolderPath+fileName;
772 image = fWindow->grabFrameBuffer();
775 res = image.save(filePath,0);
778 setRecordingInfos(
"Can't save tmp file "+filePath);
782 setRecordingInfos(
"File "+fileName+
" saved");
783 fRecordFrameNumber++;
788 void G4OpenGLQtViewer::actionSaveImage() {
790 QList<QByteArray> formats = QImageWriter::supportedImageFormats ();
791 for (
int i = 0; i < formats.size(); ++i) {
792 filters +=formats.at(i) +
";;";
798 QString* selectedFormat =
new QString(fDefaultSaveFileFormat);
800 qFilename = QFileDialog::getSaveFileName ( fGLWindow,
807 std::string name = qFilename.toStdString().c_str();
814 fFileSavePath = QFileInfo(qFilename).path();
815 if (! qFilename.endsWith(QString(selectedFormat->toStdString().c_str()),Qt::CaseInsensitive)) {
816 name +=
"." + selectedFormat->toStdString();
819 QString format = selectedFormat->toLower();
822 fDefaultSaveFileFormat = format;
824 setPrintFilename(name.c_str(),0);
825 G4OpenGLQtExportDialog* exportDialog=
new G4OpenGLQtExportDialog(fGLWindow,format,fWindow->height(),fWindow->width());
826 if( exportDialog->exec()) {
830 if ((exportDialog->getWidth() !=fWindow->width()) ||
831 (exportDialog->getHeight() !=fWindow->height())) {
832 setPrintSize(exportDialog->getWidth(),exportDialog->getHeight());
833 if ((format != QString(
"eps")) && (format != QString(
"ps"))) {
834 G4cerr <<
"Export->Change Size : This function is not implemented, to export in another size, please resize your frame to what you need" <<
G4endl;
853 image = fWindow->grabFrameBuffer();
855 if (format == QString(
"eps")) {
856 fVectoredPs = exportDialog->getVectorEPS();
858 }
else if (format ==
"ps") {
861 }
else if (format ==
"pdf") {
863 res = printPDF(name,exportDialog->getNbColor(),image);
865 }
else if ((format ==
"tif") ||
866 (format ==
"tiff") ||
868 (format ==
"jpeg") ||
876 res = image.save(QString(name.c_str()),0,exportDialog->getSliderValue());
878 G4cerr <<
"This version of G4UI Could not generate the selected format" <<
G4endl;
880 if ((format == QString(
"eps")) && (format == QString(
"ps"))) {
882 G4cerr <<
"Error while saving file... "<<name.c_str()<<
G4endl;
884 G4cout <<
"File "<<name.c_str()<<
" has been saved " <<
G4endl;
895 void G4OpenGLQtViewer::actionChangeBackgroundColor() {
903 #if QT_VERSION < 0x040500
905 const QColor color = QColor(QColorDialog::getRgba (QColor(Qt::black).rgba(),&a,fGLWindow));
908 QColorDialog::getColor(Qt::black,
910 " Get background color and transparency",
911 QColorDialog::ShowAlphaChannel);
913 if (color.isValid()) {
918 fVP.SetBackgroundColour(colour);
920 updateToolbarAndMouseContextMenu();
925 void G4OpenGLQtViewer::actionChangeTextColor() {
927 #if QT_VERSION < 0x040500
929 const QColor color = QColor(QColorDialog::getRgba (QColor(
Qt::yellow).rgba(),&a,fGLWindow));
931 const QColor& color =
934 " Get text color and transparency",
935 QColorDialog::ShowAlphaChannel);
937 if (color.isValid()) {
943 fVP.SetDefaultTextColour(colour);
945 updateToolbarAndMouseContextMenu();
950 void G4OpenGLQtViewer::actionChangeDefaultColor() {
952 #if QT_VERSION < 0x040500
954 const QColor color = QColor(QColorDialog::getRgba (QColor(Qt::white).rgba(),&a,fGLWindow));
956 const QColor& color =
957 QColorDialog::getColor(Qt::white,
959 " Get default color and transparency",
960 QColorDialog::ShowAlphaChannel);
962 if (color.isValid()) {
968 fVP.SetDefaultColour(colour);
970 updateToolbarAndMouseContextMenu();
976 void G4OpenGLQtViewer::actionMovieParameters() {
977 showMovieParametersDialog();
981 void G4OpenGLQtViewer::showMovieParametersDialog() {
982 if (!fMovieParametersDialog) {
983 fMovieParametersDialog=
new G4OpenGLQtMovieDialog(
this,fGLWindow);
984 displayRecordingStatus();
985 fMovieParametersDialog->checkEncoderSwParameters();
986 fMovieParametersDialog->checkSaveFileNameParameters();
987 fMovieParametersDialog->checkTempFolderParameters();
988 if (getEncoderPath() ==
"") {
989 setRecordingInfos(
"ppmtompeg is needed to encode in video format. It is available here: http://netpbm.sourceforge.net ");
992 fMovieParametersDialog->show();
1014 void G4OpenGLQtViewer::FinishView()
1026 void G4OpenGLQtViewer::G4MousePressEvent(QMouseEvent *evnt)
1028 if (evnt->button() == Qt::RightButton) {
1031 if ((evnt->button() & Qt::LeftButton) && (! (evnt->modifiers() & Qt::ControlModifier ))){
1032 fWindow->setMouseTracking(
true);
1034 fLastPos1 = evnt->pos();
1035 fLastPos2 = fLastPos1;
1036 fLastPos3 = fLastPos2;
1037 fLastEventTime->start();
1038 if (fUiQt != NULL) {
1040 if (fUiQt->IsIconPickSelected()){
1041 fVP.SetPicking(
true);
1042 Pick(evnt->pos().x(),evnt->pos().y());
1043 fVP.SetPicking(
false);
1045 }
else if (fUiQt->IsIconZoomInSelected()) {
1048 float deltaX = ((float)getWinWidth()/2-evnt->pos().x());
1049 float deltaY = ((float)getWinHeight()/2-evnt->pos().y());
1053 if (getWinHeight() <getWinWidth()) {
1056 fVP.IncrementPan(-deltaX*coefTrans,deltaY*coefTrans,0);
1057 fVP.SetZoomFactor(1.5 * fVP.GetZoomFactor());
1061 }
else if (fUiQt->IsIconZoomOutSelected()) {
1063 moveScene(((
float)getWinWidth()/2-evnt->pos().x()),((
float)getWinHeight()/2-evnt->pos().
y()),0,true);
1065 fVP.SetZoomFactor(0.75 * fVP.GetZoomFactor());
1075 void G4OpenGLQtViewer::G4MouseReleaseEvent()
1077 fSpinningDelay = fLastEventTime->elapsed();
1078 QPoint delta = (fLastPos3-fLastPos1);
1079 if ((delta.x() == 0) && (delta.y() == 0)) {
1082 if (fSpinningDelay < fLaunchSpinDelay ) {
1085 lastMoveTime.start();
1087 float correctionFactor = 5;
1089 if ( lastMoveTime.elapsed() >= (
int)(1000/fNbMaxFramesPerSec)) {
1090 float lTime = 1000/lastMoveTime.elapsed();
1091 if (((((
float)delta.x())/correctionFactor)*lTime > fNbMaxAnglePerSec) ||
1092 ((((
float)delta.x())/correctionFactor)*lTime < -fNbMaxAnglePerSec) ) {
1093 correctionFactor = (float)delta.x()*(lTime/fNbMaxAnglePerSec);
1094 if (delta.x() <0 ) {
1095 correctionFactor = -correctionFactor;
1098 if (((((
float)delta.y())/correctionFactor)*lTime > fNbMaxAnglePerSec) ||
1099 ((((
float)delta.y())/correctionFactor)*lTime < -fNbMaxAnglePerSec) ) {
1100 correctionFactor = (float)delta.y()*(lTime/fNbMaxAnglePerSec);
1101 if (delta.y() <0 ) {
1102 correctionFactor = -correctionFactor;
1113 lastMoveTime.start();
1118 if (fUiQt != NULL) {
1119 if (fUiQt->IsIconRotateSelected()) {
1121 }
else if (fUiQt->IsIconMoveSelected()) {
1129 rotateQtScene(((
float)delta.x())/correctionFactor,((
float)delta.y())/correctionFactor);
1130 }
else if (fAltKeyPress) {
1131 rotateQtSceneToggle(((
float)delta.x())/correctionFactor,((
float)delta.y())/correctionFactor);
1133 #ifdef G4DEBUG_VIS_OGL
1135 fTimeRotation += lastMoveTime.elapsed();
1136 printf(
"G4OpenGLQtViewer %f \n",fTimeRotation/(
float)fNbRotation);
1140 moveScene(-((
float)delta.x())/correctionFactor,-((
float)delta.y())/correctionFactor,0,true);
1143 ((QApplication*)G4Qt::getInstance ())->processEvents();
1146 fWindow->setMouseTracking(false);
1151 void G4OpenGLQtViewer::G4MouseDoubleClickEvent()
1153 fWindow->setMouseTracking(
true);
1164 void G4OpenGLQtViewer::G4MouseMoveEvent(QMouseEvent *evnt)
1167 Qt::MouseButtons mButtons = evnt->buttons();
1169 updateKeyModifierState(evnt->modifiers());
1175 fLastPos3 = fLastPos2;
1176 fLastPos2 = fLastPos1;
1177 fLastPos1 = QPoint(evnt->x(), evnt->y());
1179 int deltaX = fLastPos2.x()-fLastPos1.x();
1180 int deltaY = fLastPos2.y()-fLastPos1.y();
1182 bool rotate =
false;
1184 if (fUiQt != NULL) {
1185 if (fUiQt->IsIconRotateSelected()) {
1187 }
else if (fUiQt->IsIconMoveSelected()) {
1194 if (mButtons & Qt::LeftButton) {
1196 rotateQtScene(((
float)deltaX),((
float)deltaY));
1197 }
else if (fAltKeyPress) {
1198 rotateQtSceneToggle(((
float)deltaX),((
float)deltaY));
1199 }
else if (fShiftKeyPress) {
1200 unsigned int sizeWin;
1201 sizeWin = getWinWidth();
1202 if (getWinHeight() < getWinWidth()) {
1203 sizeWin = getWinHeight();
1207 float factor = ((float)100/(
float)sizeWin) ;
1208 moveScene(-(
float)deltaX*factor,-(
float)deltaY*factor,0,
false);
1209 }
else if (fControlKeyPress) {
1210 fVP.SetZoomFactor(fVP.GetZoomFactor()*(1+((float)deltaY)));
1214 if (mButtons & Qt::LeftButton) {
1215 moveScene(-(
float)deltaX,-(
float)deltaY,0,
true);
1219 fLastEventTime->start();
1230 void G4OpenGLQtViewer::moveScene(
float dx,
float dy,
float dz,
bool mouseMove)
1234 fHoldMoveEvent =
true;
1237 GLdouble coefDepth = 0;
1240 if (getWinHeight() <getWinWidth()) {
1244 coefTrans = getSceneNearWidth()*fPan_sens;
1245 coefDepth = getSceneDepth()*fDeltaDepth;
1247 fVP.IncrementPan(-dx*coefTrans,dy*coefTrans,dz*coefDepth);
1251 ((QApplication*)G4Qt::getInstance ())->processEvents();
1253 fHoldMoveEvent =
false;
1262 void G4OpenGLQtViewer::rotateQtScene(
float dx,
float dy)
1264 if (fHoldRotateEvent)
1266 fHoldRotateEvent =
true;
1272 fHoldRotateEvent =
false;
1280 void G4OpenGLQtViewer::rotateQtSceneToggle(
float dx,
float dy)
1282 if (fHoldRotateEvent)
1284 fHoldRotateEvent =
true;
1286 rotateSceneToggle(dx,dy);
1290 fHoldRotateEvent =
false;
1301 void G4OpenGLQtViewer::rescaleImage(
1326 bool G4OpenGLQtViewer::printPDF (
1327 const std::string aFilename
1339 if ((!aImage.isGrayscale ()) &&(aInColor ==1 )) {
1340 aImage = aImage.convertToFormat ( aImage.format(), Qt::MonoOnly);
1344 if (aFilename.substr(aFilename.size()-3) ==
".ps") {
1345 #if QT_VERSION > 0x040200
1346 #if QT_VERSION < 0x050000
1347 printer.setOutputFormat(QPrinter::PostScriptFormat);
1349 G4cout <<
"Output in postscript not implemented in this Qt version" <<
G4endl;
1352 G4cout <<
"Output in postscript not implemented in this Qt version" <<
G4endl;
1355 #if QT_VERSION > 0x040100
1356 printer.setOutputFormat(QPrinter::PdfFormat);
1359 #if QT_VERSION > 0x040100
1360 printer.setOutputFileName(QString(aFilename.c_str()));
1363 QPainter paint(&printer);
1364 paint.drawImage (0,0,aImage);
1370 void G4OpenGLQtViewer::G4wheelEvent (QWheelEvent * evnt)
1372 fVP.SetZoomFactor(fVP.GetZoomFactor()+(fVP.GetZoomFactor()*(evnt->delta())/1200));
1377 void G4OpenGLQtViewer::G4keyPressEvent (QKeyEvent * evnt)
1382 fHoldKeyEvent =
true;
1386 updateKeyModifierState(evnt->modifiers());
1387 if ((fNoKeyPress) || (evnt->modifiers() == Qt::KeypadModifier )) {
1388 if (evnt->key() == Qt::Key_Down) {
1389 moveScene(0,1,0,
false);
1391 else if (evnt->key() == Qt::Key_Up) {
1392 moveScene(0,-1,0,
false);
1394 if (evnt->key() == Qt::Key_Left) {
1395 moveScene(-1,0,0,
false);
1397 else if (evnt->key() == Qt::Key_Right) {
1398 moveScene(1,0,0,
false);
1400 if (evnt->key() == Qt::Key_Minus) {
1401 moveScene(0,0,1,
false);
1403 else if (evnt->key() == Qt::Key_Plus) {
1404 moveScene(0,0,-1,
false);
1408 if (evnt->key() == Qt::Key_Escape) {
1409 toggleFullScreen(
false);
1418 if ((evnt->key() == Qt::Key_Return) || (evnt->key() == Qt::Key_Enter)){
1421 if (evnt->key() == Qt::Key_Space){
1426 if (evnt->key() == Qt::Key_H){
1433 if (fShiftKeyPress) {
1434 if (evnt->key() == Qt::Key_Down) {
1435 rotateQtScene(0,-fRot_sens);
1437 else if (evnt->key() == Qt::Key_Up) {
1438 rotateQtScene(0,fRot_sens);
1440 if (evnt->key() == Qt::Key_Left) {
1441 rotateQtScene(fRot_sens,0);
1443 else if (evnt->key() == Qt::Key_Right) {
1444 rotateQtScene(-fRot_sens,0);
1446 if (evnt->key() == Qt::Key_Plus) {
1448 moveScene(0,0,-1,
false);
1453 if ((fAltKeyPress)) {
1454 if (evnt->key() == Qt::Key_Down) {
1455 rotateQtSceneToggle(0,-fRot_sens);
1457 else if (evnt->key() == Qt::Key_Up) {
1458 rotateQtSceneToggle(0,fRot_sens);
1460 if (evnt->key() == Qt::Key_Left) {
1461 rotateQtSceneToggle(fRot_sens,0);
1463 else if (evnt->key() == Qt::Key_Right) {
1464 rotateQtSceneToggle(-fRot_sens,0);
1468 if (evnt->key() == Qt::Key_Plus) {
1469 fRot_sens = fRot_sens/0.7;
1470 G4cout <<
"Auto-rotation set to : " << fRot_sens <<
G4endl;
1472 else if (evnt->key() == Qt::Key_Minus) {
1473 fRot_sens = fRot_sens*0.7;
1474 G4cout <<
"Auto-rotation set to : " << fRot_sens <<
G4endl;
1479 if ((fControlKeyPress)) {
1480 if (evnt->key() == Qt::Key_Plus) {
1481 fVP.SetZoomFactor(fVP.GetZoomFactor()*(1+fDeltaZoom));
1484 else if (evnt->key() == Qt::Key_Minus) {
1485 fVP.SetZoomFactor(fVP.GetZoomFactor()*(1-fDeltaZoom));
1490 fHoldKeyEvent =
false;
1494 void G4OpenGLQtViewer::updateKeyModifierState(
const Qt::KeyboardModifiers& modifier) {
1498 fAltKeyPress =
false;
1499 fShiftKeyPress =
false;
1500 fControlKeyPress =
false;
1502 if (modifier & Qt::AltModifier ) {
1503 fAltKeyPress =
true;
1504 fNoKeyPress =
false;
1506 if (modifier & Qt::ShiftModifier ) {
1507 fShiftKeyPress =
true;
1508 fNoKeyPress =
false;
1510 if (modifier & Qt::ControlModifier ) {
1511 fControlKeyPress =
true;
1512 fNoKeyPress =
false;
1519 void G4OpenGLQtViewer::stopVideo() {
1522 if (!fMovieParametersDialog) {
1523 showMovieParametersDialog();
1525 setRecordingStatus(STOP);
1527 if (fRecordFrameNumber >0) {
1529 if (!(fMovieParametersDialog->checkEncoderSwParameters())) {
1530 setRecordingStatus(BAD_ENCODER);
1531 }
else if (!(fMovieParametersDialog->checkSaveFileNameParameters())) {
1532 setRecordingStatus(BAD_OUTPUT);
1536 setRecordingInfos(
"No frame to encode.");
1542 void G4OpenGLQtViewer::saveVideo() {
1545 if (!fMovieParametersDialog) {
1546 showMovieParametersDialog();
1549 fMovieParametersDialog->checkEncoderSwParameters();
1550 fMovieParametersDialog->checkSaveFileNameParameters();
1552 if (fRecordingStep == STOP) {
1553 setRecordingStatus(SAVE);
1554 generateMpegEncoderParameters();
1562 void G4OpenGLQtViewer::startPauseVideo() {
1566 if ( fRecordingStep == WAIT) {
1567 if ( fRecordFrameNumber == 0) {
1568 if (getTempFolderPath() ==
"") {
1569 showMovieParametersDialog();
1570 setRecordingInfos(
"You should specified the temp folder in order to make movie");
1574 QString
tmp = removeTempFolder();
1576 setRecordingInfos(tmp);
1579 tmp = createTempFolder();
1581 setRecordingInfos(
"Can't create temp folder."+tmp);
1587 if (fRecordingStep == WAIT) {
1588 setRecordingStatus(
START);
1589 }
else if (fRecordingStep ==
START) {
1590 setRecordingStatus(PAUSE);
1591 }
else if (fRecordingStep == PAUSE) {
1592 setRecordingStatus(CONTINUE);
1593 }
else if (fRecordingStep == CONTINUE) {
1594 setRecordingStatus(PAUSE);
1598 void G4OpenGLQtViewer::setRecordingStatus(RECORDING_STEP step) {
1600 fRecordingStep = step;
1601 displayRecordingStatus();
1605 void G4OpenGLQtViewer::displayRecordingStatus() {
1607 QString txtStatus =
"";
1608 if (fRecordingStep == WAIT) {
1609 txtStatus =
"Waiting to start...";
1610 fRecordFrameNumber = 0;
1611 }
else if (fRecordingStep ==
START) {
1612 txtStatus =
"Start Recording...";
1613 }
else if (fRecordingStep == PAUSE) {
1614 txtStatus =
"Pause Recording...";
1615 }
else if (fRecordingStep == CONTINUE) {
1616 txtStatus =
"Continue Recording...";
1617 }
else if (fRecordingStep == STOP) {
1618 txtStatus =
"Stop Recording...";
1619 }
else if (fRecordingStep == READY_TO_ENCODE) {
1620 txtStatus =
"Ready to Encode...";
1621 }
else if (fRecordingStep ==
ENCODING) {
1622 txtStatus =
"Encoding...";
1623 }
else if (fRecordingStep == FAILED) {
1624 txtStatus =
"Failed to encode...";
1625 }
else if ((fRecordingStep == BAD_ENCODER)
1626 || (fRecordingStep == BAD_OUTPUT)
1627 || (fRecordingStep == BAD_TMP)) {
1628 txtStatus =
"Correct above errors first";
1629 }
else if (fRecordingStep == SUCCESS) {
1630 txtStatus =
"File encoded successfully";
1634 if (fMovieParametersDialog) {
1635 fMovieParametersDialog->setRecordingStatus(txtStatus);
1639 setRecordingInfos(
"");
1643 void G4OpenGLQtViewer::setRecordingInfos(
const QString& txt) {
1644 if (fMovieParametersDialog) {
1645 fMovieParametersDialog->setRecordingInfos(txt);
1653 void G4OpenGLQtViewer::initMovieParameters() {
1657 fProcess =
new QProcess();
1659 QObject ::connect(fProcess,SIGNAL(finished (
int)),
1660 this,SLOT(processLookForFinished()));
1661 fProcess->setReadChannelMode(QProcess::MergedChannels);
1662 fProcess->start (
"which ppmtompeg");
1668 QString G4OpenGLQtViewer::getEncoderPath() {
1669 return fEncoderPath;
1677 QString G4OpenGLQtViewer::setEncoderPath(QString path) {
1679 return "File does not exist";
1682 path = QDir::cleanPath(path);
1683 QFileInfo *
f =
new QFileInfo(path);
1685 return "File does not exist";
1686 }
else if (f->isDir()) {
1687 return "This is a directory";
1688 }
else if (!f->isExecutable()) {
1689 return "File exist but is not executable";
1690 }
else if (!f->isFile()) {
1691 return "This is not a file";
1693 fEncoderPath = path;
1695 if (fRecordingStep == BAD_ENCODER) {
1696 setRecordingStatus(STOP);
1702 bool G4OpenGLQtViewer::isRecording(){
1703 if ((fRecordingStep ==
START) || (fRecordingStep == CONTINUE)) {
1709 bool G4OpenGLQtViewer::isPaused(){
1710 if (fRecordingStep == PAUSE) {
1716 bool G4OpenGLQtViewer::isEncoding(){
1723 bool G4OpenGLQtViewer::isWaiting(){
1724 if (fRecordingStep == WAIT) {
1730 bool G4OpenGLQtViewer::isStopped(){
1731 if (fRecordingStep == STOP) {
1737 bool G4OpenGLQtViewer::isFailed(){
1738 if (fRecordingStep == FAILED) {
1744 bool G4OpenGLQtViewer::isSuccess(){
1745 if (fRecordingStep == SUCCESS) {
1751 bool G4OpenGLQtViewer::isBadEncoder(){
1752 if (fRecordingStep == BAD_ENCODER) {
1757 bool G4OpenGLQtViewer::isBadTmp(){
1758 if (fRecordingStep == BAD_TMP) {
1763 bool G4OpenGLQtViewer::isBadOutput(){
1764 if (fRecordingStep == BAD_OUTPUT) {
1770 void G4OpenGLQtViewer::setBadEncoder(){
1771 fRecordingStep = BAD_ENCODER;
1772 displayRecordingStatus();
1774 void G4OpenGLQtViewer::setBadTmp(){
1775 fRecordingStep = BAD_TMP;
1776 displayRecordingStatus();
1778 void G4OpenGLQtViewer::setBadOutput(){
1779 fRecordingStep = BAD_OUTPUT;
1780 displayRecordingStatus();
1783 void G4OpenGLQtViewer::setWaiting(){
1784 fRecordingStep = WAIT;
1785 displayRecordingStatus();
1789 bool G4OpenGLQtViewer::isReadyToEncode(){
1790 if (fRecordingStep == READY_TO_ENCODE) {
1796 void G4OpenGLQtViewer::resetRecording() {
1797 setRecordingStatus(WAIT);
1804 QString G4OpenGLQtViewer::setTempFolderPath(QString path) {
1807 return "Path does not exist";
1809 path = QDir::cleanPath(path);
1810 QFileInfo *
d =
new QFileInfo(path);
1812 return "Path does not exist";
1813 }
else if (!d->isDir()) {
1814 return "This is not a directory";
1815 }
else if (!d->isReadable()) {
1816 return path +
" is read protected";
1817 }
else if (!d->isWritable()) {
1818 return path +
" is write protected";
1821 if (fRecordingStep == BAD_TMP) {
1822 setRecordingStatus(WAIT);
1824 fTempFolderPath = path;
1830 QString G4OpenGLQtViewer::getTempFolderPath() {
1831 return fTempFolderPath;
1838 QString G4OpenGLQtViewer::setSaveFileName(QString path) {
1841 return "Path does not exist";
1844 QFileInfo *
file =
new QFileInfo(path);
1845 QDir
dir = file->dir();
1846 path = QDir::cleanPath(path);
1847 if (file->exists()) {
1848 return "File already exist, please choose a new one";
1849 }
else if (!dir.exists()) {
1850 return "Dir does not exist";
1851 }
else if (!dir.isReadable()) {
1852 return path +
" is read protected";
1855 if (fRecordingStep == BAD_OUTPUT) {
1856 setRecordingStatus(STOP);
1858 fSaveFileName = path;
1864 QString G4OpenGLQtViewer::getSaveFileName() {
1865 return fSaveFileName ;
1872 QString G4OpenGLQtViewer::createTempFolder() {
1873 fMovieTempFolderPath =
"";
1875 QString
tmp = setTempFolderPath(fTempFolderPath);
1879 QString sep = QString(QDir::separator());
1880 QString path = sep+
"QtMovie_"+QDateTime::currentDateTime ().toString(
"dd-MM-yyyy_hh-mm-ss")+sep;
1881 QDir *d =
new QDir(QDir::cleanPath(fTempFolderPath));
1883 if (d->exists(path)) {
1884 return "Folder "+path+
" already exists.Please remove it first";
1886 if (d->mkdir(fTempFolderPath+path)) {
1887 fMovieTempFolderPath = fTempFolderPath+path;
1890 return "Can't create "+fTempFolderPath+path;
1895 QString G4OpenGLQtViewer::removeTempFolder() {
1897 if (fMovieTempFolderPath ==
"") {
1900 QDir *d =
new QDir(QDir::cleanPath(fMovieTempFolderPath));
1905 d->setFilter( QDir::Files );
1906 QStringList subDirList = d->entryList();
1909 for (QStringList::ConstIterator it = subDirList.begin() ;(it != subDirList.end()) ; it++) {
1910 const QString currentFile = *it;
1911 if (!d->remove(currentFile)) {
1913 QString file = fMovieTempFolderPath+currentFile;
1914 error +=
"Removing file failed : "+
file;
1919 if (d->rmdir(fMovieTempFolderPath)) {
1920 fMovieTempFolderPath =
"";
1923 return "Dir "+fMovieTempFolderPath+
" should be empty, but could not remove it";
1927 return "Could not remove "+fMovieTempFolderPath+
" because of the following errors :"+error;
1932 bool G4OpenGLQtViewer::hasPendingEvents () {
1933 return ((QApplication*)G4Qt::getInstance ())->hasPendingEvents ();
1936 bool G4OpenGLQtViewer::generateMpegEncoderParameters () {
1940 fp = fopen (QString(fMovieTempFolderPath+fParameterFileName).toStdString().c_str(),
"w");
1943 setRecordingInfos(
"Generation of parameter file failed");
1947 fprintf (fp,
"# Pattern affects speed, quality and compression. See the User's Guide\n");
1948 fprintf (fp,
"# for more info.\n");
1950 fprintf (fp,
"PATTERN IBBPBBPBBPBBPBBP\n");
1951 fprintf (fp,
"OUTPUT %s\n",getSaveFileName().toStdString().c_str());
1953 fprintf (fp,
"# You must specify the type of the input files. The choices are:\n");
1954 fprintf (fp,
"# YUV, PPM, JMOVIE, Y, JPEG, PNM\n");
1955 fprintf (fp,
"# (must be upper case)\n");
1957 fprintf (fp,
"BASE_FILE_FORMAT PPM\n");
1960 fprintf (fp,
"# if YUV format (or using parallel version), must provide width and height\n");
1961 fprintf (fp,
"# YUV_SIZE widthxheight\n");
1962 fprintf (fp,
"# this option is ignored if BASE_FILE_FORMAT is not YUV and you're running\n");
1963 fprintf (fp,
"# on just one machine\n");
1965 fprintf (fp,
"YUV_SIZE 352x240\n");
1967 fprintf (fp,
"# If you are using YUV, there are different supported file formats.\n");
1968 fprintf (fp,
"# EYUV or UCB are the same as previous versions of this encoder.\n");
1969 fprintf (fp,
"# (All the Y's, then U's then V's, in 4:2:0 subsampling.)\n");
1970 fprintf (fp,
"# Other formats, such as Abekas, Phillips, or a general format are\n");
1971 fprintf (fp,
"# permissible, the general format is a string of Y's, U's, and V's\n");
1972 fprintf (fp,
"# to specify the file order.\n");
1974 fprintf (fp,
"INPUT_FORMAT UCB\n");
1976 fprintf (fp,
"# the conversion statement\n");
1978 fprintf (fp,
"# Each occurrence of '*' will be replaced by the input file\n");
1980 fprintf (fp,
"# e.g., if you have a bunch of GIF files, then this might be:\n");
1981 fprintf (fp,
"# INPUT_CONVERT giftoppm *\n");
1983 fprintf (fp,
"# e.g., if you have a bunch of files like a.Y a.U a.V, etc., then:\n");
1984 fprintf (fp,
"# INPUT_CONVERT cat *.Y *.U *.V\n");
1986 fprintf (fp,
"# e.g., if you are grabbing from laser disc you might have something like\n");
1987 fprintf (fp,
"# INPUT_CONVERT goto frame *; grabppm\n");
1988 fprintf (fp,
"# 'INPUT_CONVERT *' means the files are already in the base file format\n");
1990 fprintf (fp,
"INPUT_CONVERT * \n");
1992 fprintf (fp,
"# number of frames in a GOP.\n");
1994 fprintf (fp,
"# since each GOP must have at least one I-frame, the encoder will find the\n");
1995 fprintf (fp,
"# the first I-frame after GOP_SIZE frames to start the next GOP\n");
1997 fprintf (fp,
"# later, will add more flexible GOP signalling\n");
1999 fprintf (fp,
"GOP_SIZE 16\n");
2001 fprintf (fp,
"# number of slices in a frame\n");
2003 fprintf (fp,
"# 1 is a good number. another possibility is the number of macroblock rows\n");
2004 fprintf (fp,
"# (which is the height divided by 16)\n");
2006 fprintf (fp,
"SLICES_PER_FRAME 1\n");
2008 fprintf (fp,
"# directory to get all input files from (makes this file easier to read)\n");
2009 fprintf (fp,
"INPUT_DIR %s\n",fMovieTempFolderPath.toStdString().c_str());
2011 fprintf (fp,
"# There are a bunch of ways to specify the input files.\n");
2012 fprintf (fp,
"# from a simple one-per-line listing, to the following \n");
2013 fprintf (fp,
"# way of numbering them. See the manual for more information.\n");
2014 fprintf (fp,
"INPUT\n");
2015 fprintf (fp,
"# '*' is replaced by the numbers 01, 02, 03, 04\n");
2016 fprintf (fp,
"# if I instead do [01-11], it would be 01, 02, ..., 09, 10, 11\n");
2017 fprintf (fp,
"# if I instead do [1-11], it would be 1, 2, 3, ..., 9, 10, 11\n");
2018 fprintf (fp,
"# if I instead do [1-11+3], it would be 1, 4, 7, 10\n");
2019 fprintf (fp,
"# the program assumes none of your input files has a name ending in ']'\n");
2020 fprintf (fp,
"# if you do, too bad!!!\n");
2023 fprintf (fp,
"Test*.ppm [0-%d]\n",fRecordFrameNumber-1);
2024 fprintf (fp,
"# can have more files here if you want...there is no limit on the number\n");
2025 fprintf (fp,
"# of files\n");
2026 fprintf (fp,
"END_INPUT\n");
2030 fprintf (fp,
"# Many of the remaining options have to do with the motion search and qscale\n");
2032 fprintf (fp,
"# FULL or HALF -- must be upper case\n");
2033 fprintf (fp,
"# Should be FULL for computer generated images\n");
2034 fprintf (fp,
"PIXEL FULL\n");
2036 fprintf (fp,
"# means +/- this many pixels for both P and B frame searches\n");
2037 fprintf (fp,
"# specify two numbers if you wish to serc different ranges in the two.\n");
2038 fprintf (fp,
"RANGE 10\n");
2040 fprintf (fp,
"# The two search algorithm parameters below mostly affect speed,\n");
2041 fprintf (fp,
"# with some affect on compression and almost none on quality.\n");
2043 fprintf (fp,
"# this must be one of {EXHAUSTIVE, SUBSAMPLE, LOGARITHMIC}\n");
2044 fprintf (fp,
"PSEARCH_ALG LOGARITHMIC\n");
2046 fprintf (fp,
"# this must be one of {SIMPLE, CROSS2, EXHAUSTIVE}\n");
2048 fprintf (fp,
"# note that EXHAUSTIVE is really, really, really slow\n");
2050 fprintf (fp,
"BSEARCH_ALG SIMPLE\n");
2053 fprintf (fp,
"# these specify the q-scale for I, P, and B frames\n");
2054 fprintf (fp,
"# (values must be between 1 and 31)\n");
2055 fprintf (fp,
"# These are the Qscale values for the entire frame in variable bit-rate\n");
2056 fprintf (fp,
"# mode, and starting points (but not important) for constant bit rate\n");
2059 fprintf (fp,
"# Qscale (Quantization scale) affects quality and compression,\n");
2060 fprintf (fp,
"# but has very little effect on speed.\n");
2062 fprintf (fp,
"IQSCALE 4\n");
2063 fprintf (fp,
"PQSCALE 5\n");
2064 fprintf (fp,
"BQSCALE 12\n");
2066 fprintf (fp,
"# this must be ORIGINAL or DECODED\n");
2067 fprintf (fp,
"REFERENCE_FRAME ORIGINAL\n");
2069 fprintf (fp,
"# for parallel parameters see parallel.param in the exmaples subdirectory\n");
2071 fprintf (fp,
"# if you want constant bit-rate mode, specify it as follows (number is bits/sec):\n");
2072 fprintf (fp,
"#BIT_RATE 1000000\n");
2074 fprintf (fp,
"# To specify the buffer size (327680 is default, measused in bits, for 16bit words)\n");
2075 fprintf (fp,
"BUFFER_SIZE 327680\n");
2077 fprintf (fp,
"# The frame rate is the number of frames/second (legal values:\n");
2078 fprintf (fp,
"# 23.976, 24, 25, 29.97, 30, 50 ,59.94, 60\n");
2079 fprintf (fp,
"FRAME_RATE 30\n");
2081 fprintf (fp,
"# There are many more options, see the users manual for examples....\n");
2082 fprintf (fp,
"# ASPECT_RATIO, USER_DATA, GAMMA, IQTABLE, etc.\n");
2087 setRecordingInfos(
"Parameter file "+fParameterFileName+
" generated in "+fMovieTempFolderPath);
2088 setRecordingStatus(READY_TO_ENCODE);
2092 void G4OpenGLQtViewer::encodeVideo()
2094 if ((getEncoderPath() !=
"") && (getSaveFileName() !=
"")) {
2097 fProcess =
new QProcess();
2098 #if QT_VERSION > 0x040100
2099 QObject ::connect(fProcess,SIGNAL(finished (
int,QProcess::ExitStatus)),
2100 this,SLOT(processEncodeFinished()));
2101 QObject ::connect(fProcess,SIGNAL(readyReadStandardOutput ()),
2102 this,SLOT(processEncodeStdout()));
2104 QObject ::connect(fProcess,SIGNAL(finished (
int)),
2105 this,SLOT(processEncodeFinished()));
2106 QObject ::connect(fProcess,SIGNAL(readyReadStandardOutput ()),
2107 this,SLOT(processEncodeStdout()));
2109 fProcess->setReadChannelMode(QProcess::MergedChannels);
2110 fProcess->start (fEncoderPath, QStringList(fMovieTempFolderPath+fParameterFileName));
2116 void G4OpenGLQtViewer::processEncodeStdout()
2118 QString tmp = fProcess->readAllStandardOutput ().data();
2119 int start = tmp.lastIndexOf(
"ESTIMATED TIME");
2120 tmp = tmp.mid(start,tmp.indexOf(
"\n",start)-start);
2121 setRecordingInfos(tmp);
2125 void G4OpenGLQtViewer::processEncodeFinished()
2129 txt = getProcessErrorMsg();
2131 setRecordingStatus(SUCCESS);
2133 setRecordingStatus(FAILED);
2139 void G4OpenGLQtViewer::processLookForFinished()
2142 QString txt = getProcessErrorMsg();
2146 fEncoderPath = QString(fProcess->readAllStandardOutput ().data()).trimmed();
2148 if (fEncoderPath.contains(
" ")) {
2150 }
else if (!fEncoderPath.contains(
"ppmtompeg")) {
2153 setEncoderPath(fEncoderPath);
2156 setTempFolderPath(QDir::temp ().absolutePath ());
2160 QString G4OpenGLQtViewer::getProcessErrorMsg()
2163 if (fProcess->exitCode() != 0) {
2164 switch (fProcess->error()) {
2165 case QProcess::FailedToStart:
2166 txt =
"The process failed to start. Either the invoked program is missing, or you may have insufficient permissions to invoke the program.\n";
2168 case QProcess::Crashed:
2169 txt =
"The process crashed some time after starting successfully.\n";
2171 case QProcess::Timedout:
2172 txt =
"The last waitFor...() function timed out. The state of QProcess is unchanged, and you can try calling waitFor...() again.\n";
2174 case QProcess::WriteError:
2175 txt =
"An error occurred when attempting to write to the process. For example, the process may not be running, or it may have closed its input channel.\n";
2177 case QProcess::ReadError:
2178 txt =
"An error occurred when attempting to read from the process. For example, the process may not be running.\n";
2180 case QProcess::UnknownError:
2181 txt =
"An unknown error occurred. This is the default return value of error().\n";
2191 QWidget *G4OpenGLQtViewer::getParentWidget()
2194 G4Qt* interactorManager = G4Qt::getInstance ();
2201 if (((QApplication*)interactorManager->GetMainInteractor())) {
2203 QWidgetList wl = QApplication::allWidgets();
2204 QWidget *widget = NULL;
2205 for (
int i=0; i < wl.size(); i++) {
2207 if ((found==
false) && (widget->inherits(
"QMainWindow"))) {
2208 fGLWindow =
new QDialog(widget,Qt::WindowTitleHint | Qt::WindowSystemMenuHint | Qt::WindowMinMaxButtonsHint);
2214 #ifdef G4DEBUG_VIS_OGL
2215 printf(
"G4OpenGLQtViewer::CreateMainWindow case Qapp exist, but not found\n");
2217 fGLWindow =
new QDialog();
2220 #ifdef G4DEBUG_VIS_OGL
2221 printf(
"G4OpenGLQtViewer::CreateMainWindow case Qapp exist\n");
2223 fGLWindow =
new QDialog();
2224 #ifdef G4DEBUG_VIS_OGL
2225 printf(
"G4OpenGLQtViewer::GetParentWidget fGLWindow\n");
2236 void G4OpenGLQtViewer::initSceneTreeComponent(){
2238 fSceneTreeWidget =
new QWidget();
2239 QVBoxLayout* layoutSceneTreeComponentsTBWidget =
new QVBoxLayout();
2240 fSceneTreeWidget->setLayout (layoutSceneTreeComponentsTBWidget);
2242 if (fUISceneTreeComponentsTBWidget != NULL) {
2243 fUISceneTreeComponentsTBWidget->addTab(fSceneTreeWidget,QString(GetName().
data()));
2248 layoutSceneTreeComponentsTBWidget->setContentsMargins(5,5,5,5);
2251 fSceneTreeComponentTreeWidget =
new QTreeWidget();
2252 fSceneTreeComponentTreeWidget->setSelectionMode(QAbstractItemView::SingleSelection);
2253 fSceneTreeComponentTreeWidget->setHeaderLabel (
"Scene tree : "+QString(GetName().
data()));
2254 fSceneTreeComponentTreeWidget->setColumnHidden (1,
true);
2255 fSceneTreeComponentTreeWidget->setColumnHidden (2,
true);
2256 fSceneTreeComponentTreeWidget->setColumnHidden (3,
true);
2261 layoutSceneTreeComponentsTBWidget->addWidget(fSceneTreeComponentTreeWidget);
2263 connect(fSceneTreeComponentTreeWidget,SIGNAL(itemChanged(QTreeWidgetItem*,
int)),SLOT(sceneTreeComponentItemChanged(QTreeWidgetItem*,
int)));
2264 connect(fSceneTreeComponentTreeWidget,SIGNAL(itemSelectionChanged ()),SLOT(sceneTreeComponentSelected()));
2265 connect(fSceneTreeComponentTreeWidget,SIGNAL(itemDoubleClicked ( QTreeWidgetItem*,
int)),SLOT(changeColorAndTransparency( QTreeWidgetItem*,
int)));
2269 QLabel *depth =
new QLabel();
2270 depth->setText(
"Depth :");
2272 QWidget* depthWidget =
new QWidget();
2273 QGroupBox *groupBox =
new QGroupBox(tr(
"Touchables slider"),depthWidget);
2274 QHBoxLayout *groupBoxLayout =
new QHBoxLayout();
2277 groupBoxLayout->setContentsMargins(5,5,5,5);
2279 QLabel *zero =
new QLabel();
2280 zero->setText(
"Show all");
2281 QLabel *one =
new QLabel();
2282 one->setText(
"Hide all");
2283 fSceneTreeDepthSlider =
new QSlider ( Qt::Horizontal);
2284 fSceneTreeDepthSlider->setMaximum (1000);
2285 fSceneTreeDepthSlider->setMinimum (0);
2286 fSceneTreeDepthSlider->setTickPosition(QSlider::TicksAbove);
2288 fSceneTreeDepthSlider->setMinimumWidth (40);
2290 groupBoxLayout->addWidget(zero);
2291 groupBoxLayout->addWidget(fSceneTreeDepthSlider);
2292 groupBoxLayout->addWidget(one);
2294 groupBox->setLayout(groupBoxLayout);
2295 layoutSceneTreeComponentsTBWidget->addWidget(groupBox);
2297 connect( fSceneTreeDepthSlider, SIGNAL( valueChanged(
int) ),
this, SLOT( changeDepthInSceneTree(
int) ) );
2300 QWidget *helpWidget =
new QWidget();
2301 QHBoxLayout *helpLayout =
new QHBoxLayout();
2302 QPushButton* select =
new QPushButton(
"select item(s)");
2303 fHelpLine =
new QLineEdit();
2304 helpLayout->addWidget(fHelpLine);
2305 helpLayout->addWidget(select);
2306 helpWidget->setLayout(helpLayout);
2307 helpLayout->setContentsMargins(0,0,0,0);
2310 fHelpLine->setMinimumWidth (20);
2312 QSizePolicy policy = fHelpLine->sizePolicy();
2313 policy.setHorizontalStretch(10);
2314 fHelpLine->setSizePolicy(policy);
2316 policy = select->sizePolicy();
2317 policy.setHorizontalStretch(1);
2318 select->setSizePolicy(policy);
2320 layoutSceneTreeComponentsTBWidget->addWidget(helpWidget);
2322 connect( fHelpLine, SIGNAL( returnPressed () ),
this, SLOT(changeSearchSelection()));
2323 connect( select, SIGNAL( clicked () ),
this, SLOT(changeSearchSelection()));
2326 fTreeItemModels.clear();
2328 fPVRootNodeCreate =
false;
2330 fMaxPOindexInserted = -1;
2336 void G4OpenGLQtViewer::setCheckComponent(QTreeWidgetItem* item,
bool check)
2340 item->setCheckState(0,Qt::Checked);
2342 item->setCheckState(0,Qt::Unchecked);
2344 updatePositivePoIndexSceneTreeWidgetQuickMap(item->data(0,Qt::UserRole).toInt(),item);
2345 int nChildCount = item->childCount();
2346 for (
int i = 0; i < nChildCount; i++) {
2347 setCheckComponent(item->child(i),check);
2353 void G4OpenGLQtViewer::DrawText(
const G4Text& g4text)
2355 if (isGl2psWriting()) {
2357 G4OpenGLViewer::DrawText(g4text);
2361 if (!fWindow)
return;
2364 G4double size = fSceneHandler.GetMarkerSize(g4text,sizeType);
2366 QFont font = QFont();
2367 font.setPointSizeF(size);
2372 const char* textCString = textString.c_str();
2374 glRasterPos3d(position.
x(),position.
y(),position.
z());
2377 QFontMetrics* f =
new QFontMetrics (font);
2378 G4double span = f->width(textCString);
2391 ((position.
x()+(2*xmove)/getWinWidth()),
2392 (position.
y()+(2*ymove)/getWinHeight()),
2401 void G4OpenGLQtViewer::ResetView () {
2402 G4OpenGLViewer::ResetView();
2412 const QString& modelShortName = getModelShortName(model);
2414 if (modelShortName ==
"") {
2418 if (fSceneTreeComponentTreeWidget == NULL) {
2419 initSceneTreeComponent();
2423 if (fSceneTreeComponentTreeWidget == NULL) {
2427 fSceneTreeComponentTreeWidget->blockSignals(
true);
2431 if (!fPVRootNodeCreate) {
2432 const G4VisAttributes* visAttr = GetApplicableVisAttributes(pPVModel->
GetFullPVPath().at(0).GetPhysicalVolume()->GetLogicalVolume()->GetVisAttributes());
2435 fModelShortNameItem = createTreeWidgetItem(pPVModel->
GetFullPVPath(),
2443 fPVRootNodeCreate =
true;
2446 bool added = parseAndInsertInSceneTree(fModelShortNameItem,pPVModel,0,modelShortName,0,currentPOIndex);
2450 fSceneTreeComponentTreeWidget->blockSignals(
false);
2459 QTreeWidgetItem* G4OpenGLQtViewer::createTreeWidgetItem(
2461 ,
const QString& name
2464 ,
const QString& logicalName
2465 ,Qt::CheckState state
2466 ,QTreeWidgetItem * parentTreeNode
2471 if (fullPath.size() > fSceneTreeDepth) {
2472 fSceneTreeDepth = fullPath.size();
2474 if (fSceneTreeDepthSlider) {
2475 fSceneTreeDepthSlider->setTickInterval(1000/(fSceneTreeDepth+1));
2478 QTreeWidgetItem * newItem = NULL;
2479 if (parentTreeNode == NULL) {
2480 newItem =
new QTreeWidgetItem();
2481 fSceneTreeComponentTreeWidget->addTopLevelItem(newItem);
2483 newItem =
new QTreeWidgetItem(parentTreeNode);
2484 fSceneTreeComponentTreeWidget->addTopLevelItem(parentTreeNode);
2488 newItem->setText(0,name);
2489 newItem->setData(1,Qt::UserRole,copyNb);
2490 newItem->setText(2,QString::number(POIndex));
2491 newItem->setData(0, Qt::UserRole, POIndex);
2492 newItem->setText(3,logicalName);
2493 newItem->setFlags(newItem->flags()|Qt::ItemIsUserCheckable);
2494 newItem->setCheckState(0,state);
2495 updatePositivePoIndexSceneTreeWidgetQuickMap(POIndex,newItem);
2497 changeQColorForTreeWidgetItem(newItem,QColor((
int)(color.
GetRed()*255),
2503 if ((state == Qt::Unchecked) && (POIndex == -1)) {
2504 newItem->setForeground (0, QBrush(
Qt::gray) );
2507 newItem->setToolTip (0,QString(
2508 "This node exists in the geometry but has not been\n")+
2509 "drawn, perhaps because it has been set invisible. It \n"+
2510 "cannot be made visible with a click on the button.\n"+
2511 "To see it, change the visibility, for example, with \n"+
2512 "/vis/geometry/set/visibility " + logicalName +
" 0 true\n"+
2513 "and rebuild the view with /vis/viewer/rebuild.\n"+
2514 "Click here will only show/hide all child components");
2517 newItem->setToolTip (0,QString(
"double-click to change the color"));
2523 state = Qt::Unchecked;
2524 newItem->setCheckState(0,state);
2525 updatePositivePoIndexSceneTreeWidgetQuickMap(POIndex,newItem);
2528 fTreeItemModels.insert(std::pair <int, PVPath > (POIndex,fullPath) );
2532 changeOpenCloseVisibleHiddenSelectedColorSceneTreeElement(newItem);
2549 bool G4OpenGLQtViewer::parseAndInsertInSceneTree(
2550 QTreeWidgetItem * parentItem
2552 ,
unsigned int fullPathIndex
2553 ,
const QString& parentRoot
2554 ,
unsigned int currentIndexInTreeSceneHandler
2555 ,
int currentPVPOIndex
2558 if (parentItem == NULL) {
2564 std::ostringstream oss;
2565 oss << fullPath.at(fullPathIndex).GetCopyNo();
2566 std::string currentPVName =
G4String(fullPath.at(fullPathIndex).GetPhysicalVolume()->GetName()+
" ["+oss.str()+
"]").
data();
2568 int currentPVCopyNb = fullPath.at(fullPathIndex).GetCopyNo();
2570 const G4VisAttributes* visAttr = GetApplicableVisAttributes(fullPath.at(fullPathIndex).GetPhysicalVolume()->GetLogicalVolume()->GetVisAttributes());
2579 QTreeWidgetItem* subItem = NULL;
2580 QList<QTreeWidgetItem *> parentItemList;
2588 if ((currentIndexInTreeSceneHandler == (fullPath.size()-1)) && ((color.GetAlpha() == 1.))) {
2590 QString lookForString = QString(currentPVName.c_str());
2591 for (
int i = 0;i < parentItem->childCount(); i++ ) {
2592 if (parentItem->child(i)->text(0) == lookForString) {
2593 parentItemList.push_back(parentItem->child(i));
2598 for (
int i = 0; i < parentItemList.size(); ++i) {
2599 const std::string& parentItemName = parentItemList.at(i)->text(0).toStdString();
2600 int parentItemCopyNb = parentItemList.at(i)->data(1,Qt::UserRole).toInt();
2601 int parentItemPOIndex = parentItemList.at(i)->data(0,Qt::UserRole).toInt();
2609 if (((parentRoot == fTouchableVolumes) && (currentPVCopyNb == parentItemCopyNb)
2610 && (currentPVName == parentItemName)) ||
2612 ((parentRoot != fTouchableVolumes) && (currentPVCopyNb == parentItemCopyNb)
2614 && (currentPVName == parentItemName) && (currentPVPOIndex == parentItemPOIndex) )) {
2617 bool sameTransform =
true;
2618 if (parentItemPOIndex >= 0) {
2619 const PVPath& fullPathTmp = fTreeItemModels[parentItemPOIndex];
2620 if (fullPathTmp.size() > 0) {
2621 if (fullPathTmp.at(fullPathTmp.size()-1).GetTransform () == pPVModel->
GetTransformation ()) {
2622 sameTransform =
true;
2624 sameTransform =
false;
2630 if (sameTransform ==
true) {
2637 if (currentIndexInTreeSceneHandler == (fullPath.size()-1)) {
2639 parentItemList.at(i)->setText(2,QString::number(currentPVPOIndex));
2640 parentItemList.at(i)->setData(0, Qt::UserRole,currentPVPOIndex);
2642 fTreeItemModels.insert(std::pair <int, PVPath >(currentPVPOIndex,fullPath) );
2646 parentItemList.at(i)->setFont (0,f);
2649 parentItemList.at(i)->setForeground (0,QBrush());
2652 parentItemList.at(i)->setToolTip (0,
"");
2654 changeQColorForTreeWidgetItem(parentItemList.at(i),QColor((
int)(color.GetRed()*255),
2655 (
int)(color.GetGreen()*255),
2656 (
int)(color.GetBlue()*255),
2657 (
int)(color.GetAlpha()*255)));
2660 if (color.GetAlpha() > 0) {
2661 parentItemList.at(i)->setCheckState(0,Qt::Checked);
2662 updatePositivePoIndexSceneTreeWidgetQuickMap(currentPVPOIndex,parentItemList.at(i));
2666 subItem = parentItemList.at(i);
2670 }
else if (currentIndexInTreeSceneHandler < (fullPath.size()-1)) {
2671 subItem = parentItemList.at(i);
2678 if (currentIndexInTreeSceneHandler == (fullPath.size()-1)) {
2679 createTreeWidgetItem(fullPath,
2680 QString(currentPVName.c_str()),
2683 QString(fullPath.at(fullPathIndex).GetPhysicalVolume()->GetLogicalVolume()->GetName().data()),
2688 if (currentPVPOIndex > fMaxPOindexInserted) {
2689 fMaxPOindexInserted = currentPVPOIndex;
2695 if (subItem == NULL) {
2697 if (currentIndexInTreeSceneHandler < (fullPath.size()-1)) {
2698 subItem = createTreeWidgetItem(fullPath,
2699 QString(currentPVName.c_str()),
2702 QString(fullPath.at(fullPathIndex).GetPhysicalVolume()->GetLogicalVolume()->GetName().data()),
2709 return parseAndInsertInSceneTree(subItem,pPVModel,fullPathIndex+1,parentRoot,currentIndexInTreeSceneHandler+1,currentPVPOIndex);
2715 void G4OpenGLQtViewer::changeOpenCloseVisibleHiddenSelectedColorSceneTreeElement(
2716 QTreeWidgetItem* subItem
2720 QTreeWidgetItem* oldItem = NULL;
2722 QTreeWidgetItem* foundItem = getOldTreeWidgetItem(subItem->data(0,Qt::UserRole).toInt());
2724 if (foundItem != NULL) {
2725 if (isSameSceneTreeElement(foundItem,subItem)) {
2726 oldItem = foundItem;
2729 if (foundItem == NULL) {
2732 std::map <int, QTreeWidgetItem*>::const_iterator i;
2733 i = fOldPositivePoIndexSceneTreeWidgetQuickMap.begin();
2734 while (i != fOldPositivePoIndexSceneTreeWidgetQuickMap.end()) {
2735 if (isSameSceneTreeElement(i->second,subItem)) {
2736 oldItem = i->second;
2737 i = fOldPositivePoIndexSceneTreeWidgetQuickMap.end();
2743 if (oldItem == NULL) {
2745 while (a < fOldNullPoIndexSceneTreeWidgetQuickVector.size()) {
2746 if (isSameSceneTreeElement(fOldNullPoIndexSceneTreeWidgetQuickVector[a],subItem)) {
2747 oldItem = fOldNullPoIndexSceneTreeWidgetQuickVector[
a];
2748 a = fOldNullPoIndexSceneTreeWidgetQuickVector.size();
2757 if (oldItem != NULL) {
2758 subItem->setFlags(oldItem->flags());
2759 subItem->setCheckState(0,oldItem->checkState(0));
2760 subItem->setSelected(oldItem->isSelected());
2761 subItem->setExpanded(oldItem->isExpanded ());
2766 std::map <int, QTreeWidgetItem* >::iterator it;
2769 int oldPOIndex = oldItem->data(0,Qt::UserRole).toInt();
2770 it = fOldPositivePoIndexSceneTreeWidgetQuickMap.find(oldPOIndex);
2774 std::map <int, QColor >::iterator itVis;
2775 itVis = fOldVisAttrColorMap.find(oldPOIndex);
2777 QColor oldVisAttrColor;
2778 const QColor& newVisAttrColor = subItem->data(2,Qt::UserRole).value<QColor>();
2780 bool visAttrChange =
false;
2782 if (itVis != fOldVisAttrColorMap.end()) {
2783 oldVisAttrColor = itVis->second;
2784 if (oldVisAttrColor != newVisAttrColor) {
2785 visAttrChange =
true;
2788 visAttrChange =
true;
2791 if (visAttrChange) {
2792 fOldVisAttrColorMap.insert(std::pair <int, QColor > (subItem->data(0,Qt::UserRole).toInt(),newVisAttrColor) );
2796 if (it != fOldPositivePoIndexSceneTreeWidgetQuickMap.end()) {
2797 color = (it->second)->
data(2,Qt::UserRole).value<QColor>();
2799 color = oldItem->data(2,Qt::UserRole).value<QColor>();
2801 #ifdef G4DEBUG_VIS_OGL
2802 printf(
"====color name:%s\n",color.name().toStdString().c_str());
2804 changeQColorForTreeWidgetItem(subItem,color);
2816 bool G4OpenGLQtViewer::isSameSceneTreeElement(
2817 QTreeWidgetItem* parentOldItem
2818 ,QTreeWidgetItem* parentNewItem
2824 int newCpNumber = -1;
2825 int oldCpNumber = -1;
2827 bool firstWhile =
true;
2829 while ((parentOldItem != NULL) && (parentNewItem != NULL)) {
2833 oldPO = parentOldItem->data(0,Qt::UserRole).toInt();
2834 newPO = parentNewItem->data(0,Qt::UserRole).toInt();
2840 const PVPath& oldFullPath = fOldTreeItemModels[oldPO];
2841 const PVPath& newFullPath = fTreeItemModels[newPO];
2842 if ((oldFullPath.size() > 0) &&
2843 (newFullPath.size() > 0)) {
2844 if (oldFullPath.size() != newFullPath.size()) {
2847 if (oldFullPath.at(oldFullPath.size()-1).GetTransform () == newFullPath.at(newFullPath.size()-1).GetTransform ()) {
2848 newCpNumber = newFullPath.at(newFullPath.size()-1).GetCopyNo();
2849 oldCpNumber = oldFullPath.at(oldFullPath.size()-1).GetCopyNo();
2858 if (oldCpNumber == -1) {
2859 oldCpNumber = parentOldItem->data(1,Qt::UserRole).toInt();
2861 if (newCpNumber == -1) {
2862 newCpNumber = parentNewItem->data(1,Qt::UserRole).toInt();
2864 if ((oldCpNumber != newCpNumber) ||
2866 (parentOldItem->text(0) != parentNewItem->text(0)) ) {
2869 }
else if ((parentOldItem->text(0) != parentNewItem->text(0)) ||
2870 (parentOldItem->text(3) != parentNewItem->text(3))) {
2873 parentOldItem = parentOldItem->parent();
2874 parentNewItem = parentNewItem->parent();
2882 void G4OpenGLQtViewer::addNonPVSceneTreeElement(
2885 ,
const std::string& modelDescription
2889 QString modelShortName = getModelShortName(model);
2894 const G4Text& g4Text =
dynamic_cast<const G4Text&
>(visible);
2895 color = fSceneHandler.GetTextColour(g4Text);
2897 catch (std::bad_cast) {
2898 color = fSceneHandler.
GetColour(visible);
2900 if (modelShortName ==
"") {
2904 if (fSceneTreeComponentTreeWidget == NULL) {
2905 initSceneTreeComponent();
2909 if (fSceneTreeComponentTreeWidget == NULL) {
2913 fSceneTreeComponentTreeWidget->blockSignals(
true);
2917 QList<QTreeWidgetItem *> resItem;
2918 resItem = fSceneTreeComponentTreeWidget->findItems (modelShortName, Qt::MatchExactly, 0 );
2919 QTreeWidgetItem * currentItem = NULL;
2920 const PVPath tmpFullPath;
2922 if (resItem.empty()) {
2923 currentItem = createTreeWidgetItem(tmpFullPath,
2932 currentItem = resItem.first();
2936 const QList<QTreeWidgetItem *>&
2937 resItems = fSceneTreeComponentTreeWidget->findItems (QString(modelDescription.c_str()), Qt::MatchFixedString| Qt::MatchCaseSensitive|Qt::MatchRecursive, 0 );
2939 bool alreadyPresent =
false;
2940 for (
int i = 0; i < resItems.size(); ++i) {
2941 if (currentPOIndex == resItems.at(i)->data(0,Qt::UserRole).toInt()) {
2942 alreadyPresent =
true;
2945 if (!alreadyPresent) {
2946 createTreeWidgetItem(tmpFullPath,
2947 QString(modelDescription.c_str()),
2955 fSceneTreeComponentTreeWidget->blockSignals(
false);
2963 QString G4OpenGLQtViewer::getModelShortName(
const G4String& model) {
2965 QString modelShortName = model.
data();
2966 if (modelShortName.mid(0,modelShortName.indexOf(
" ")) ==
"G4PhysicalVolumeModel") {
2967 modelShortName = fTouchableVolumes;
2969 if (modelShortName.mid(0,2) ==
"G4") {
2970 modelShortName = modelShortName.mid(2);
2972 if (modelShortName.indexOf(
"Model") != -1) {
2973 modelShortName = modelShortName.mid(0,modelShortName.indexOf(
"Model"));
2976 return modelShortName;
2981 bool G4OpenGLQtViewer::isTouchableVisible(
int POindex){
2984 if (fSceneTreeComponentTreeWidget == NULL) {
2990 if (fLastSceneTreeWidgetAskForIterator != fLastSceneTreeWidgetAskForIteratorEnd) {
2991 fLastSceneTreeWidgetAskForIterator++;
2993 QTreeWidgetItem* item = getTreeWidgetItem(POindex);
2996 if ( item->checkState(0) == Qt::Checked) {
3004 bool G4OpenGLQtViewer::parseAndCheckVisibility(QTreeWidgetItem * treeNode,
int POindex){
3005 bool isFound =
false;
3006 for (
int i = 0; i < treeNode->childCount() ; ++i) {
3008 if (treeNode->child(i)->data(0,Qt::UserRole).toInt() == POindex) {
3009 if (treeNode->child(i)->checkState(0) == Qt::Checked) {
3013 isFound = parseAndCheckVisibility(treeNode->child(i),POindex);
3022 std::string G4OpenGLQtViewer::parseSceneTreeAndSaveState(){
3023 std::string commandLine =
"";
3024 for (
int b=0;
b<fSceneTreeComponentTreeWidget->topLevelItemCount();
b++) {
3025 commandLine += parseSceneTreeElementAndSaveState(fSceneTreeComponentTreeWidget->topLevelItem(
b),1)+
"\n";
3027 if (commandLine !=
"") {
3028 commandLine = std::string(
"# Disable auto refresh and quieten vis messages whilst scene and\n") +
3029 "# trajectories are established:\n" +
3030 "/vis/viewer/set/autoRefresh false\n" +
3031 "/vis/verbose errors" +
3033 "# Re-establish auto refreshing and verbosity:\n" +
3034 "/vis/viewer/set/autoRefresh true\n" +
3035 "/vis/verbose confirmations\n";
3041 std::string G4OpenGLQtViewer::parseSceneTreeElementAndSaveState(QTreeWidgetItem* item,
unsigned int level){
3043 std::string str( level,
' ' );
3044 std::string commandLine =
"\n#"+ str +
"PV Name: " + item->text(0).toStdString();
3046 if (item->text(3) !=
"") {
3047 commandLine +=
" LV Name: "+item->text(3).toStdString()+
"\n";
3049 commandLine +=
"/vis/geometry/set/visibility " + item->text(3).toStdString() +
" ! ";
3050 if (item->checkState(0) == Qt::Checked) {
3053 if (item->checkState(0) == Qt::Unchecked) {
3059 const QColor&
c = item->data(2,Qt::UserRole).value<QColor>();
3060 std::stringstream
red;
3061 red << ((double)c.red())/255;
3062 std::stringstream green;
3063 green << (double)c.green()/255;
3064 std::stringstream
blue;
3065 blue << ((double)c.blue())/255;
3066 std::stringstream alpha;
3067 alpha << ((double)c.alpha())/255;
3069 commandLine +=
"/vis/geometry/set/colour " + item->text(3).toStdString() +
" ! " + red.str() +
" " + green.str() +
" " + blue.str() +
" " + alpha.str()+
"\n";
3072 commandLine +=
"\n";
3076 for (
int b=0;
b< item->childCount();
b++) {
3077 commandLine += parseSceneTreeElementAndSaveState(item->child(
b),level+1);
3084 void G4OpenGLQtViewer::sceneTreeComponentItemChanged(QTreeWidgetItem* item,
int) {
3086 if (fCheckSceneTreeComponentSignalLock ==
false) {
3087 fCheckSceneTreeComponentSignalLock =
true;
3089 if (item->checkState(0) == Qt::Checked) {
3092 setCheckComponent(item,checked);
3095 fCheckSceneTreeComponentSignalLock =
false;
3100 void G4OpenGLQtViewer::sceneTreeComponentSelected() {
3118 void G4OpenGLQtViewer::changeDepthInSceneTree (
int val){
3121 if (fSceneTreeComponentTreeWidget == NULL) {
3132 double depth = 1 + ((double)val)/1000 * ((double)fSceneTreeDepth+1);
3135 fCheckSceneTreeComponentSignalLock =
true;
3138 G4bool currentAutoRefresh = fVP.IsAutoRefresh();
3139 fVP.SetAutoRefresh(
false);
3141 for (
int b=0;
b<fSceneTreeComponentTreeWidget->topLevelItemCount();
b++) {
3142 changeDepthOnSceneTreeItem(depth,1.,fSceneTreeComponentTreeWidget->topLevelItem(
b));
3146 fVP.SetAutoRefresh(currentAutoRefresh);
3150 fCheckSceneTreeComponentSignalLock =
false;
3155 void G4OpenGLQtViewer::changeColorAndTransparency(QTreeWidgetItem* item,
int) {
3160 const QColor& old = QColor(item->data(2,Qt::UserRole).value<QColor>());
3162 #if QT_VERSION < 0x040500
3164 const QColor& color = QColor(QColorDialog::getRgba (old.rgba(),&
a,fSceneTreeComponentTreeWidget));
3166 const QColor& color = QColorDialog::getColor(old,
3167 fSceneTreeComponentTreeWidget,
3168 " Get color and transparency",
3169 QColorDialog::ShowAlphaChannel);
3172 if (color.isValid()) {
3175 G4int iPO = item->data(0,Qt::UserRole).toInt();
3176 if (iPO >= 0 && fTreeItemModels.find(iPO) != fTreeItemModels.end()) {
3177 const PVPath& fullPath = fTreeItemModels[iPO];
3179 if (fullPath.size()) {
3188 workingVisAtts.SetColour(
g4c);
3191 fVP.AddVisAttributesModifier
3203 changeQColorForTreeWidgetItem(item,color);
3208 G4Colour G4OpenGLQtViewer::getColorForPoIndex(
int poIndex) {
3210 QTreeWidgetItem* item = getTreeWidgetItem(poIndex);
3214 const QColor& color = item->data(2,Qt::UserRole).value<QColor>();
3227 G4OpenGLQtViewer::GetPrivateVisAttributesModifiers()
const
3229 static std::vector<G4ModelingParameters::VisAttributesModifier>
3230 privateVisAttributesModifiers;
3232 privateVisAttributesModifiers.clear();
3284 return &privateVisAttributesModifiers;
3288 void G4OpenGLQtViewer::changeSearchSelection()
3290 const QString& searchText = fHelpLine->text();
3291 if (fSceneTreeComponentTreeWidget == NULL) {
3296 for (
int a=0; a<fSceneTreeComponentTreeWidget->topLevelItemCount(); a++) {
3297 fSceneTreeComponentTreeWidget->topLevelItem(a)->setExpanded(
false);
3298 fSceneTreeComponentTreeWidget->topLevelItem(a)->setSelected(
false);
3299 clearSceneTreeSelection(fSceneTreeComponentTreeWidget->topLevelItem(a));
3302 QList<QTreeWidgetItem *> itemList = fSceneTreeComponentTreeWidget->findItems (searchText,Qt::MatchContains | Qt::MatchRecursive,0);
3304 for (
int i = 0; i < itemList.size(); ++i) {
3305 QTreeWidgetItem* expandParentItem = itemList.at(i);
3306 while (expandParentItem->parent() != NULL) {
3307 expandParentItem->parent()->setExpanded(
true);
3308 expandParentItem = expandParentItem->parent();
3310 itemList.at(i)->setSelected(
true);
3316 void G4OpenGLQtViewer::clearSceneTreeSelection(QTreeWidgetItem* item) {
3317 for (
int a=0; a<item->childCount(); a++) {
3318 item->child(a)->setSelected(
false);
3319 item->child(a)->setExpanded(
false);
3320 clearSceneTreeSelection(item->child(a));
3326 bool G4OpenGLQtViewer::isPVVolume(QTreeWidgetItem* item) {
3327 QTreeWidgetItem* sParent = item;
3328 while (sParent->parent() != NULL) {
3329 sParent = sParent->parent();
3331 if (sParent->text(0) != fTouchableVolumes) {
3335 if (item->text(0) == fTouchableVolumes) {
3342 void G4OpenGLQtViewer::changeDepthOnSceneTreeItem(
3344 ,
double currentDepth
3345 ,QTreeWidgetItem* item
3347 double transparencyLevel = 0.;
3352 if (isPVVolume(item)) {
3353 if ((lookForDepth-currentDepth) < 0) {
3354 item->setCheckState(0,Qt::Checked);
3355 updatePositivePoIndexSceneTreeWidgetQuickMap(item->data(0,Qt::UserRole).toInt(),item);
3356 transparencyLevel = 1;
3357 }
else if ((lookForDepth-currentDepth) > 1 ){
3358 item->setCheckState(0,Qt::Unchecked);
3359 updatePositivePoIndexSceneTreeWidgetQuickMap(item->data(0,Qt::UserRole).toInt(),item);
3360 transparencyLevel = 0;
3362 item->setCheckState(0,Qt::Checked);
3363 updatePositivePoIndexSceneTreeWidgetQuickMap(item->data(0,Qt::UserRole).toInt(),item);
3364 transparencyLevel = 1-(lookForDepth-currentDepth);
3368 if (item->data(0,Qt::UserRole).toInt() >= 0) {
3369 const G4Colour& color = getColorForPoIndex(item->data(0,Qt::UserRole).toInt());
3381 if (((color.
GetAlpha()-transparencyLevel) > 0.000001) ||
3382 ((color.
GetAlpha()-transparencyLevel) < -0.000001)) {
3383 if ((item->text(3) !=
"")) {
3389 changeQColorForTreeWidgetItem(item,QColor((
int)(color.
GetRed()*255),
3392 (
int)(transparencyLevel*255)));
3397 for (
int b=0;
b< item->childCount();
b++) {
3398 changeDepthOnSceneTreeItem(lookForDepth,currentDepth+1,item->child(
b));
3403 void G4OpenGLQtViewer::clearTreeWidget(){
3406 if (fSceneTreeComponentTreeWidget) {
3408 if (fOldSceneTreeComponentTreeWidget == NULL) {
3409 fOldSceneTreeComponentTreeWidget =
new QTreeWidget();
3412 int tmp = fOldSceneTreeComponentTreeWidget->topLevelItemCount();
3414 delete fOldSceneTreeComponentTreeWidget->takeTopLevelItem (0);
3415 tmp = fOldSceneTreeComponentTreeWidget->topLevelItemCount();
3418 if (fSceneTreeComponentTreeWidget->topLevelItemCount () > 0) {
3420 fPVRootNodeCreate =
false;
3423 fOldPositivePoIndexSceneTreeWidgetQuickMap.clear();
3424 fOldNullPoIndexSceneTreeWidgetQuickVector.clear();
3425 fOldTreeItemModels.clear();
3428 for (
int b =0;
b <fSceneTreeComponentTreeWidget->topLevelItemCount();
b++) {
3437 int poIndex = fSceneTreeComponentTreeWidget->topLevelItem(
b)->data(0,Qt::UserRole).toInt();
3438 if (poIndex != -1) {
3439 fOldPositivePoIndexSceneTreeWidgetQuickMap.insert(std::pair <int, QTreeWidgetItem*> (poIndex,cloneWidgetItem(fSceneTreeComponentTreeWidget->topLevelItem(
b))));
3441 fOldNullPoIndexSceneTreeWidgetQuickVector.push_back(cloneWidgetItem(fSceneTreeComponentTreeWidget->topLevelItem(
b)));
3445 cloneSceneTree(fSceneTreeComponentTreeWidget->topLevelItem(
b));
3449 fOldTreeItemModels.insert(fTreeItemModels.begin(), fTreeItemModels.end());
3452 int tmp2 = fSceneTreeComponentTreeWidget->topLevelItemCount();
3454 delete fSceneTreeComponentTreeWidget->takeTopLevelItem (0);
3455 tmp2 = fSceneTreeComponentTreeWidget->topLevelItemCount();
3457 fPositivePoIndexSceneTreeWidgetQuickMap.clear();
3460 fOldLastSceneTreeWidgetAskForIterator = fOldPositivePoIndexSceneTreeWidgetQuickMap.begin();
3461 fOldLastSceneTreeWidgetAskForIteratorEnd = fOldPositivePoIndexSceneTreeWidgetQuickMap.end();
3462 fSceneTreeDepth = 1;
3463 fModelShortNameItem = NULL;
3464 fMaxPOindexInserted = -1;
3477 QTreeWidgetItem * G4OpenGLQtViewer::cloneWidgetItem(QTreeWidgetItem* item) {
3479 QTreeWidgetItem* cloneItem =
new QTreeWidgetItem();
3483 cloneItem->setText(0,item->text(0));
3484 cloneItem->setData(1,Qt::UserRole,item->data(1,Qt::UserRole).toInt());
3485 cloneItem->setText(2,item->text(2));
3486 cloneItem->setData(0, Qt::UserRole,item->data(0,Qt::UserRole).toInt());
3487 cloneItem->setText(3,item->text(3));
3488 cloneItem->setFlags(item->flags());
3489 cloneItem->setToolTip(0,item->toolTip(0));
3490 cloneItem->setCheckState(0,item->checkState(0));
3491 cloneItem->setSelected(item->isSelected());
3492 cloneItem->setExpanded(item->isExpanded ());
3494 cloneItem->setData(2,Qt::UserRole,item->data(2,Qt::UserRole).value<QColor>());
3503 void G4OpenGLQtViewer::cloneSceneTree(
3504 QTreeWidgetItem* rootItem
3507 for (
int b=0;
b< rootItem->childCount();
b++) {
3509 QTreeWidgetItem *child = rootItem->child(
b);
3512 int poIndex = child->data(0,Qt::UserRole).toInt();
3513 if (poIndex != -1) {
3514 fOldPositivePoIndexSceneTreeWidgetQuickMap.insert(std::pair <int, QTreeWidgetItem*> (poIndex,cloneWidgetItem(child)));
3516 fOldNullPoIndexSceneTreeWidgetQuickVector.push_back(cloneWidgetItem(child));
3518 cloneSceneTree(child);
3526 void G4OpenGLQtViewer::updatePositivePoIndexSceneTreeWidgetQuickMap(
int POindex,QTreeWidgetItem* item) {
3529 std::map <int, QTreeWidgetItem*>::iterator i;
3530 i = fPositivePoIndexSceneTreeWidgetQuickMap.find(POindex);
3532 if (i == fPositivePoIndexSceneTreeWidgetQuickMap.end()) {
3533 fPositivePoIndexSceneTreeWidgetQuickMap.insert(std::pair <int, QTreeWidgetItem*> (POindex,item) );
3534 fLastSceneTreeWidgetAskForIterator = fPositivePoIndexSceneTreeWidgetQuickMap.end();
3535 fLastSceneTreeWidgetAskForIteratorEnd = fPositivePoIndexSceneTreeWidgetQuickMap.end();
3543 void G4OpenGLQtViewer::changeQColorForTreeWidgetItem(QTreeWidgetItem* item,
const QColor& qc) {
3545 int POIndex = item->data(0,Qt::UserRole).toInt();
3546 updatePositivePoIndexSceneTreeWidgetQuickMap(POIndex,item );
3548 QPixmap pixmap = QPixmap(QSize(16, 16));
3549 if (item->data(0,Qt::UserRole).toInt() != -1) {
3552 pixmap.fill (QColor(255,255,255,255));
3554 QPainter painter(&pixmap);
3555 painter.setPen(Qt::black);
3556 painter.drawRect(0,0,15,15);
3558 item->setIcon(0,pixmap);
3559 item->setData(2,Qt::UserRole,qc);
3568 QTreeWidgetItem* G4OpenGLQtViewer::getTreeWidgetItem(
int POindex){
3571 if (POindex == -1) {
3575 if (fPositivePoIndexSceneTreeWidgetQuickMap.size() == 0){
3579 if (fLastSceneTreeWidgetAskForIterator != fLastSceneTreeWidgetAskForIteratorEnd) {
3580 if (POindex == fLastSceneTreeWidgetAskForIterator->first) {
3581 if (fLastSceneTreeWidgetAskForIterator->second != NULL) {
3582 return fLastSceneTreeWidgetAskForIterator->second;
3588 fLastSceneTreeWidgetAskForIterator = fPositivePoIndexSceneTreeWidgetQuickMap.find(POindex);
3589 fLastSceneTreeWidgetAskForIteratorEnd = fPositivePoIndexSceneTreeWidgetQuickMap.end();
3591 if (fLastSceneTreeWidgetAskForIterator != fPositivePoIndexSceneTreeWidgetQuickMap.end()) {
3592 return fLastSceneTreeWidgetAskForIterator->second;
3601 QTreeWidgetItem* G4OpenGLQtViewer::getOldTreeWidgetItem(
int POindex){
3605 if (POindex == -1) {
3609 if (fOldPositivePoIndexSceneTreeWidgetQuickMap.size() == 0){
3615 if (fOldLastSceneTreeWidgetAskForIterator != fOldLastSceneTreeWidgetAskForIteratorEnd) {
3616 fOldLastSceneTreeWidgetAskForIterator++;
3619 if (fOldLastSceneTreeWidgetAskForIterator != fOldPositivePoIndexSceneTreeWidgetQuickMap.end()) {
3620 if (POindex == fOldLastSceneTreeWidgetAskForIterator->first) {
3621 if (fOldLastSceneTreeWidgetAskForIterator->second != NULL) {
3622 return fOldLastSceneTreeWidgetAskForIterator->second;
3628 fOldLastSceneTreeWidgetAskForIterator = fOldPositivePoIndexSceneTreeWidgetQuickMap.find(POindex);
3629 fOldLastSceneTreeWidgetAskForIteratorEnd = fOldPositivePoIndexSceneTreeWidgetQuickMap.end();
3631 if (fOldLastSceneTreeWidgetAskForIterator != fOldPositivePoIndexSceneTreeWidgetQuickMap.end()) {
3632 return fOldLastSceneTreeWidgetAskForIterator->second;
3643 void G4OpenGLQtViewer::displaySceneTreeComponent() {
3645 if (fUISceneTreeComponentsTBWidget == NULL) {
3648 if (fSceneTreeComponentTreeWidget == NULL) {
3653 fSceneTreeComponentTreeWidget->sortItems (0, Qt::AscendingOrder );
3665 void G4OpenGLQtViewer::updateToolbarAndMouseContextMenu(){
3671 d_style = fVP.GetDrawingStyle();
3675 if (fUiQt) fUiQt->SetIconWireframeSelected();
3677 fDrawingWireframe->setChecked(
true);
3678 fDrawingLineRemoval->setChecked(
false);
3679 fDrawingSurfaceRemoval->setChecked(
false);
3680 fDrawingLineSurfaceRemoval->setChecked(
false);
3683 if (fUiQt) fUiQt->SetIconHLRSelected();
3685 fDrawingLineRemoval->setChecked(
true);
3686 fDrawingWireframe->setChecked(
false);
3687 fDrawingSurfaceRemoval->setChecked(
false);
3688 fDrawingLineSurfaceRemoval->setChecked(
false);
3691 if (fUiQt) fUiQt->SetIconSolidSelected();
3693 fDrawingSurfaceRemoval->setChecked(
true);
3694 fDrawingWireframe->setChecked(
false);
3695 fDrawingLineRemoval->setChecked(
false);
3696 fDrawingLineSurfaceRemoval->setChecked(
false);
3699 if (fUiQt) fUiQt->SetIconHLHSRSelected();
3701 fDrawingLineSurfaceRemoval->setChecked(
true);
3702 fDrawingWireframe->setChecked(
false);
3703 fDrawingLineRemoval->setChecked(
false);
3704 fDrawingSurfaceRemoval->setChecked(
false);
3705 fDrawingLineSurfaceRemoval->setChecked(
false);
3711 G4double d_proj = fVP.GetFieldHalfAngle () ;
3713 if (fUiQt) fUiQt->SetIconOrthoSelected();
3715 fProjectionOrtho->setChecked(
true);
3716 fProjectionPerspective->setChecked(
false);
3719 if (fUiQt) fUiQt->SetIconPerspectiveSelected();
3721 fProjectionPerspective->setChecked(
true);
3722 fProjectionOrtho->setChecked(
false);
3728 if (fUiQt && fContextMenu) {
3729 if (fUiQt->IsIconPickSelected()) {
3730 fMousePickAction->setChecked(
true);
3731 fMouseZoomOutAction->setChecked(
false);
3732 fMouseZoomInAction->setChecked(
false);
3733 fMouseRotateAction->setChecked(
false);
3734 fMouseMoveAction->setChecked(
false);
3735 }
else if (fUiQt->IsIconZoomOutSelected()) {
3736 fMouseZoomOutAction->setChecked(
true);
3737 fMousePickAction->setChecked(
false);
3738 fMouseZoomInAction->setChecked(
false);
3739 fMouseRotateAction->setChecked(
false);
3740 fMouseMoveAction->setChecked(
false);
3741 }
else if (fUiQt->IsIconZoomInSelected()) {
3742 fMouseZoomInAction->setChecked(
true);
3743 fMousePickAction->setChecked(
false);
3744 fMouseZoomOutAction->setChecked(
false);
3745 fMouseRotateAction->setChecked(
false);
3746 fMouseMoveAction->setChecked(
false);
3747 }
else if (fUiQt->IsIconRotateSelected()) {
3748 fMouseRotateAction->setChecked(
true);
3749 fMousePickAction->setChecked(
false);
3750 fMouseZoomOutAction->setChecked(
false);
3751 fMouseZoomInAction->setChecked(
false);
3752 fMouseMoveAction->setChecked(
false);
3753 }
else if (fUiQt->IsIconMoveSelected()) {
3754 fMouseMoveAction->setChecked(
true);
3755 fMousePickAction->setChecked(
false);
3756 fMouseZoomOutAction->setChecked(
false);
3757 fMouseZoomInAction->setChecked(
false);
3758 fMouseRotateAction->setChecked(
false);
G4double GetAlpha() const
typedef int(XMLCALL *XML_NotStandaloneHandler)(void *userData)
const G4Transform3D & GetTransformation() const
static G4bool GetColour(const G4String &key, G4Colour &result)
const G4Colour & GetColour() const
G4Point3D GetPosition() const
const G4ThreeVector const G4double const
static G4UImanager * GetUIpointer()
G4double GetYOffset() const
G4GLOB_DLL std::ostream G4cout
G4double GetGreen() const
const XML_Char XML_Content * model
std::vector< PVNodeID > PVPath
const std::vector< G4PhysicalVolumeNodeID > & GetFullPVPath() const
const char * data() const
G4double GetXOffset() const
printf("%d Experimental points found\n", nlines)
const XML_Char const XML_Char * data
std::vector< G4PolyconeSideRZ > g4c
G4GLOB_DLL std::ostream G4cerr