36 #ifdef G4VIS_BUILD_OPENGLQT_DRIVER
65 #include <qpushbutton.h>
67 #include <qdesktopwidget.h>
70 #include <qimagewriter.h>
72 #include <qtextedit.h>
73 #include <qtreewidget.h>
74 #include <qapplication.h>
75 #include <qmessagebox.h>
76 #include <qfiledialog.h>
78 #include <qdatetime.h>
82 #include <qcolordialog.h>
85 #include <qgroupbox.h>
86 #include <qcombobox.h>
87 #include <qlineedit.h>
88 #include <qsignalmapper.h>
89 #include <qmainwindow.h>
90 #include <qtablewidget.h>
91 #include <qheaderview.h>
92 #include <qscrollarea.h>
93 #include <qsplitter.h>
94 #include <qcheckbox.h>
105 #ifdef G4MULTITHREADED
112 void G4OpenGLQtViewer::CreateMainWindow (
120 if(fGLWidget)
return;
122 fGLWidget = glWidget ;
125 G4Qt* interactorManager = G4Qt::getInstance ();
127 ResizeWindow(fVP.GetWindowSizeHintX(),fVP.GetWindowSizeHintY());
139 if (UI == NULL)
return;
141 if (! static_cast<G4UIQt*> (UI->GetG4UIWindow())) {
146 fUiQt =
static_cast<G4UIQt*
> (UI->GetG4UIWindow());
148 bool isTabbedView =
false;
151 if (!interactorManager->IsExternalApp()) {
153 fWinSize_x = fVP.GetWindowSizeHintX();
154 fWinSize_y = fVP.GetWindowSizeHintY();
156 isTabbedView = fUiQt->AddTabWidget((QWidget*)fGLWidget,name);
157 QObject::connect(fUiQt->GetViewerTabWidget(),
158 SIGNAL(currentChanged(
int)),
160 SLOT(currentTabActivated(
int)));
164 createSceneTreeWidget();
171 QWidget *glDialogWidget = getParentWidget();
172 if (glDialogWidget == NULL) {
175 glWidget->setParent(glDialogWidget);
176 QHBoxLayout *mainLayout =
new QHBoxLayout();
178 mainLayout->setMargin(0);
179 mainLayout->setSpacing(0);
180 mainLayout->addWidget(fGLWidget);
181 if (fGLWidget->inherits(
"QMainWindow")) {
182 fGLWidget->setWindowTitle( name);
184 glDialogWidget->setLayout(mainLayout);
188 int offset = QApplication::desktop()->height()
189 - QApplication::desktop()->availableGeometry().height();
191 G4int YPos= fVP.GetWindowAbsoluteLocationHintY(QApplication::desktop()->height());
192 if (fVP.GetWindowAbsoluteLocationHintY(QApplication::desktop()->height())< offset) {
195 glDialogWidget->resize(getWinWidth(), getWinHeight());
196 glDialogWidget->move(fVP.GetWindowAbsoluteLocationHintX(QApplication::desktop()->width()),YPos);
197 glDialogWidget->show();
200 if(!fGLWidget)
return;
209 G4OpenGLQtViewer::G4OpenGLQtViewer (
210 G4OpenGLSceneHandler& scene
213 ,G4OpenGLViewer (scene)
215 ,fRecordFrameNumber(0)
216 ,fMouseOnSceneTree(false)
218 ,fLastPickPoint(-1,-1)
221 ,fHoldKeyEvent(false)
222 ,fHoldMoveEvent(false)
223 ,fHoldRotateEvent(false)
227 ,fMovieTempFolderPath(
"")
229 ,fParameterFileName(
"ppmtompeg_encode_parameter_file.par")
230 ,fMovieParametersDialog(NULL)
231 ,fRecordingStep(WAIT)
233 ,fNbMaxFramesPerSec(100)
234 ,fNbMaxAnglePerSec(360)
235 ,fLaunchSpinDelay(100)
236 ,fUISceneTreeWidget(NULL)
237 ,fUIViewerPropertiesWidget(NULL)
238 ,fUIPickInfosWidget(NULL)
241 ,fControlKeyPress(false)
242 ,fShiftKeyPress(false)
244 ,fCheckSceneTreeComponentSignalLock(false)
245 ,fViewerPropertiesTableWidgetIsInit(false)
246 ,fSceneTreeComponentTreeWidget(NULL)
247 ,fSceneTreeWidget(NULL)
248 ,fPVRootNodeCreate(false)
252 ,fTouchableVolumes(
"Touchables")
253 ,fShortcutsDialog(NULL)
254 ,fViewerPropertiesTableWidget(NULL)
255 ,fPickInfosWidget(NULL)
256 ,fPickInfosScrollArea(NULL)
257 ,fTreeWidgetInfosIgnoredCommands(0)
258 ,fSceneTreeDepthSlider(NULL)
260 ,fModelShortNameItem(NULL)
261 ,fMaxPOindexInserted(-1)
263 ,fSignalMapperMouse(NULL)
264 ,fSignalMapperSurface(NULL)
265 ,fSignalMapperPicking(NULL)
267 ,fTreeIconClosed(NULL)
268 ,fLastExportSliderValue(80)
269 ,fLastHighlightColor(
G4Color(0,0,0,0))
270 ,fLastHighlightName(0)
273 lWaitForVisSubThreadQtOpenGLContextInitialized
274 =
new G4AutoLock(mWaitForVisSubThreadQtOpenGLContextInitialized,
276 lWaitForVisSubThreadQtOpenGLContextMoved
277 =
new G4AutoLock(mWaitForVisSubThreadQtOpenGLContextMoved,
284 G4Qt::getInstance ();
286 fLastPos3 = QPoint(-1,-1);
287 fLastPos2 = QPoint(-1,-1);
288 fLastPos1 = QPoint(-1,-1);
290 initMovieParameters();
292 fLastEventTime =
new QTime();
293 fSignalMapperMouse =
new QSignalMapper(
this);
294 fSignalMapperSurface =
new QSignalMapper(
this);
297 fFileSavePath = QDir::currentPath();
300 QList<QByteArray> formats = QImageWriter::supportedImageFormats ();
301 for (
int i = 0; i < formats.size(); ++i) {
302 addExportImageFormat(formats.at(i).data());
305 const char *
const icon1[]={
363 const char *
const icon2[]={
456 const char *
const search[] = {
468 "OOOOOOOOOOOOOOOOOOO",
469 "OOOOOOOOOOOOOOOOOOO",
470 "OOOOOOOo. .oOOOOOO",
473 "OOOOO. XOOOOX .OOOO",
476 "OOOOO. XOOOOo .OOOO",
480 "OOOOOOOOOOOOO. XOO",
481 "OOOOOOOOOOOOOO. XOO",
482 "OOOOOOOOOOOOOOOoOOO",
483 "OOOOOOOOOOOOOOOOOOO",
484 "OOOOOOOOOOOOOOOOOOO",
485 "OOOOOOOOOOOOOOOOOOO",
486 "OOOOOOOOOOOOOOOOOOO"
489 fSearchIcon =
new QPixmap(search);
490 fTreeIconOpen =
new QPixmap(icon1);
491 fTreeIconClosed =
new QPixmap(icon2);
496 G4OpenGLQtViewer::~G4OpenGLQtViewer (
506 if (fSceneTreeWidget != NULL) {
507 if (fSceneTreeWidget->layout() != NULL) {
508 while ((wItem = fSceneTreeWidget->layout()->takeAt(0)) != 0) {
509 delete wItem->widget();
516 delete fTreeIconOpen;
517 delete fTreeIconClosed;
519 G4cout <<removeTempFolder().toStdString().c_str() <<
G4endl;
521 delete lWaitForVisSubThreadQtOpenGLContextInitialized;
522 delete lWaitForVisSubThreadQtOpenGLContextMoved;
530 void G4OpenGLQtViewer::createPopupMenu() {
532 fContextMenu =
new QMenu(
"All");
534 QMenu *mMouseAction = fContextMenu->addMenu(
"&Mouse actions");
536 fMouseRotateAction = mMouseAction->addAction(
"Rotate", fSignalMapperMouse, SLOT(map()));
537 fMouseMoveAction = mMouseAction->addAction(
"Move", fSignalMapperMouse, SLOT(map()));
538 fMousePickAction = mMouseAction->addAction(
"Pick", fSignalMapperMouse, SLOT(map()));
539 fMouseZoomOutAction = mMouseAction->addAction(
"Zoom out", fSignalMapperMouse, SLOT(map()));
540 fMouseZoomInAction = mMouseAction->addAction(
"Zoom in", fSignalMapperMouse, SLOT(map()));
541 QAction *shortcutsAction = mMouseAction->addAction(
"Show shortcuts");
543 fMouseRotateAction->setCheckable(
true);
544 fMouseMoveAction->setCheckable(
true);
545 fMousePickAction->setCheckable(
true);
546 fMouseZoomOutAction->setCheckable(
true);
547 fMouseZoomInAction->setCheckable(
true);
548 shortcutsAction->setCheckable(
false);
550 connect(fSignalMapperMouse, SIGNAL(mapped(
int)),
this, SLOT(toggleMouseAction(
int)));
551 fSignalMapperMouse->setMapping(fMouseRotateAction,1);
552 fSignalMapperMouse->setMapping(fMouseMoveAction,2);
553 fSignalMapperMouse->setMapping(fMousePickAction,3);
554 fSignalMapperMouse->setMapping(fMouseZoomOutAction,4);
555 fSignalMapperMouse->setMapping(fMouseZoomInAction,5);
557 QObject::connect(shortcutsAction,
558 SIGNAL(triggered(
bool)),
560 SLOT(showShortcuts()));
563 QMenu *mStyle = fContextMenu->addMenu(
"&Style");
565 QMenu *mProjection = mStyle->addMenu(
"&Projection");
567 fProjectionOrtho = mProjection->addAction(
"Orthographic", fSignalMapperSurface, SLOT(map()));
568 fProjectionPerspective = mProjection->addAction(
"Persepective", fSignalMapperSurface, SLOT(map()));
571 if (fVP.GetFieldHalfAngle() == 0) {
572 createRadioAction(fProjectionOrtho, fProjectionPerspective,SLOT(toggleProjection(
bool)),1);
574 createRadioAction(fProjectionOrtho, fProjectionPerspective,SLOT(toggleProjection(
bool)),2);
578 QMenu *mDrawing = mStyle->addMenu(
"&Drawing");
580 fDrawingWireframe = mDrawing->addAction(
"Wireframe", fSignalMapperSurface, SLOT(map()));
582 fDrawingLineRemoval = mDrawing->addAction(
"Hidden line removal", fSignalMapperSurface, SLOT(map()));
584 fDrawingSurfaceRemoval = mDrawing->addAction(
"Hidden Surface removal", fSignalMapperSurface, SLOT(map()));
586 fDrawingLineSurfaceRemoval = mDrawing->addAction(
"Hidden line and surface removal", fSignalMapperSurface, SLOT(map()));
588 fDrawingWireframe->setCheckable(
true);
589 fDrawingLineRemoval->setCheckable(
true);
590 fDrawingSurfaceRemoval->setCheckable(
true);
591 fDrawingLineSurfaceRemoval->setCheckable(
true);
593 connect(fSignalMapperSurface, SIGNAL(mapped(
int)),
this, SLOT(toggleSurfaceAction(
int)));
594 fSignalMapperSurface->setMapping(fDrawingWireframe,1);
595 fSignalMapperSurface->setMapping(fDrawingLineRemoval,2);
596 fSignalMapperSurface->setMapping(fDrawingSurfaceRemoval,3);
597 fSignalMapperSurface->setMapping(fDrawingLineSurfaceRemoval,4);
602 QAction *backgroundColorChooser ;
604 backgroundColorChooser = mStyle->addAction(
"Background color");
605 QObject ::connect(backgroundColorChooser,
608 SLOT(actionChangeBackgroundColor()));
612 QAction *textColorChooser ;
614 textColorChooser = mStyle->addAction(
"Text color");
615 QObject ::connect(textColorChooser,
618 SLOT(actionChangeTextColor()));
622 QAction *defaultColorChooser ;
624 defaultColorChooser = mStyle->addAction(
"Default color");
625 QObject ::connect(defaultColorChooser,
628 SLOT(actionChangeDefaultColor()));
632 QMenu *mActions = fContextMenu->addMenu(
"&Actions");
633 QAction *createEPS = mActions->addAction(
"Save as ...");
634 QObject ::connect(createEPS,
637 SLOT(actionSaveImage()));
640 QAction *movieParameters = mActions->addAction(
"Save as movie...");
641 QObject ::connect(movieParameters,
644 SLOT(actionMovieParameters()));
650 QMenu *mSpecial = fContextMenu->addMenu(
"S&pecial");
651 QMenu *mTransparency = mSpecial->addMenu(
"Transparency");
652 QAction *transparencyOn = mTransparency->addAction(
"On");
653 QAction *transparencyOff = mTransparency->addAction(
"Off");
655 if (transparency_enabled ==
false) {
656 createRadioAction(transparencyOn,transparencyOff,SLOT(toggleTransparency(
bool)),2);
657 }
else if (transparency_enabled ==
true) {
658 createRadioAction(transparencyOn,transparencyOff,SLOT(toggleTransparency(
bool)),1);
664 QMenu *mAntialiasing = mSpecial->addMenu(
"Antialiasing");
665 QAction *antialiasingOn = mAntialiasing->addAction(
"On");
666 QAction *antialiasingOff = mAntialiasing->addAction(
"Off");
668 if (antialiasing_enabled ==
false) {
669 createRadioAction(antialiasingOn,antialiasingOff,SLOT(toggleAntialiasing(
bool)),2);
670 }
else if (antialiasing_enabled ==
true) {
671 createRadioAction(antialiasingOn,antialiasingOff,SLOT(toggleAntialiasing(
bool)),1);
673 mAntialiasing->clear();
676 QMenu *mHaloing = mSpecial->addMenu(
"Haloing");
677 QAction *haloingOn = mHaloing->addAction(
"On");
678 QAction *haloingOff = mHaloing->addAction(
"Off");
679 if (haloing_enabled ==
false) {
680 createRadioAction(haloingOn,haloingOff,SLOT(toggleHaloing(
bool)),2);
681 }
else if (haloing_enabled ==
true) {
682 createRadioAction(haloingOn,haloingOff,SLOT(toggleHaloing(
bool)),1);
687 QMenu *mAux = mSpecial->addMenu(
"Auxiliary edges");
688 QAction *auxOn = mAux->addAction(
"On");
689 QAction *auxOff = mAux->addAction(
"Off");
690 if (!fVP.IsAuxEdgeVisible()) {
691 createRadioAction(auxOn,auxOff,SLOT(toggleAux(
bool)),2);
693 createRadioAction(auxOn,auxOff,SLOT(toggleAux(
bool)),1);
697 QMenu *mHiddenMarkers = mSpecial->addMenu(
"Hidden markers");
698 QAction *hiddenMarkersOn = mHiddenMarkers->addAction(
"On");
699 QAction *hiddenMarkersOff = mHiddenMarkers->addAction(
"Off");
700 if (fVP.IsMarkerNotHidden()) {
701 createRadioAction(hiddenMarkersOn,hiddenMarkersOff,SLOT(toggleHiddenMarkers(
bool)),2);
703 createRadioAction(hiddenMarkersOn,hiddenMarkersOff,SLOT(toggleHiddenMarkers(
bool)),1);
708 QMenu *mFullScreen = mSpecial->addMenu(
"&Full screen");
709 fFullScreenOn = mFullScreen->addAction(
"On");
710 fFullScreenOff = mFullScreen->addAction(
"Off");
711 createRadioAction(fFullScreenOn,fFullScreenOff,SLOT(toggleFullScreen(
bool)),2);
714 updateToolbarAndMouseContextMenu();
717 void G4OpenGLQtViewer::G4manageContextMenuEvent(QContextMenuEvent *
e)
720 G4cerr <<
"Visualization window not defined, please choose one before" <<
G4endl;
727 if ( fContextMenu ) {
728 fContextMenu->exec( e->globalPos() );
744 void G4OpenGLQtViewer::createRadioAction(QAction *action1,QAction *action2,
const std::string& method,
unsigned int nCheck) {
746 action1->setCheckable(
true);
747 action2->setCheckable(
true);
750 action1->setChecked (
true);
752 action2->setChecked (
true);
754 QObject ::connect(action1, SIGNAL(triggered(
bool)),action2, SLOT(toggle()));
755 QObject ::connect(action2, SIGNAL(triggered(
bool)),action1, SLOT(toggle()));
757 QObject ::connect(action1, SIGNAL(toggled(
bool)),
this, method.c_str());
766 void G4OpenGLQtViewer::showShortcuts() {
769 text =
"========= Mouse Shortcuts =========\n";
771 if (fUiQt->IsIconRotateSelected()) {
772 text +=
"Click and move mouse to rotate volume \n";
773 text +=
"ALT + Click and move mouse to rotate volume (Toggle View/Theta-Phi Direction) \n";
774 text +=
"CTRL + Click and move mouse to zoom in/out \n";
775 text +=
"SHIFT + Click and move mouse to change camera point of view \n";
776 }
else if (fUiQt->IsIconMoveSelected()) {
777 text +=
"Move camera point of view with mouse \n";
778 }
else if (fUiQt->IsIconPickSelected()) {
779 text +=
"Click and pick \n";
782 text +=
"Click and move mouse to rotate volume \n";
783 text +=
"ALT + Click and move mouse to rotate volume (Toggle View/Theta-Phi Direction) \n";
784 text +=
"CTRL + Click and zoom mouse to zoom in/out \n";
785 text +=
"SHIFT + Click and zoommove camera point of view \n";
787 text +=
"========= Move Shortcuts ========= \n";
788 text +=
"Press left/right arrows to move volume left/right \n";
789 text +=
"Press up/down arrows to move volume up/down \n";
790 text +=
"Press '+'/'-' to move volume toward/forward \n";
792 text +=
"========= Rotation (Theta/Phi) Shortcuts ========= \n";
793 text +=
"Press SHIFT + left/right arrows to rotate volume left/right \n";
794 text +=
"Press SHIFT + up/down arrows to rotate volume up/down \n";
796 text +=
"========= Rotation (View Direction) Shortcuts ========= \n";
797 text +=
"Press ALT + left/right to rotate volume around vertical direction \n";
798 text +=
"Press ALT + up/down to rotate volume around horizontal direction \n";
800 text +=
"========= Zoom View ========= \n";
801 text +=
"Press CTRL + '+'/'-' to zoom into volume \n";
803 text +=
"========= Misc ========= \n";
804 text +=
"Press ALT +/- to slow/speed rotation/move \n";
805 text +=
"Press H to reset view \n";
806 text +=
"Press Esc to exit FullScreen \n";
808 text +=
"========= Video ========= \n";
809 text +=
"In video mode : \n";
810 text +=
" Press SPACE to Start/Pause video recording \n";
811 text +=
" Press RETURN to Stop video recording \n";
816 if ( fShortcutsDialog == NULL) {
817 fShortcutsDialog =
new QDialog();
818 fShortcutsDialogInfos =
new QTextEdit() ;
819 QVBoxLayout *mainLayout =
new QVBoxLayout;
820 mainLayout->addWidget(fShortcutsDialogInfos);
821 fShortcutsDialog->setLayout(mainLayout);
822 fShortcutsDialog->setWindowTitle(tr(
"Shortcuts"));
825 fShortcutsDialogInfos->setPlainText(text.data());
826 fShortcutsDialog->show();
837 void G4OpenGLQtViewer::toggleMouseAction(
int aAction) {
840 fUiQt->SetIconRotateSelected();
841 }
else if (aAction == 2) {
842 fUiQt->SetIconMoveSelected();
843 }
else if (aAction == 3) {
845 }
else if (aAction == 4) {
846 fUiQt->SetIconZoomOutSelected();
847 }
else if (aAction == 5) {
848 fUiQt->SetIconZoomInSelected();
852 updateToolbarAndMouseContextMenu();
866 void G4OpenGLQtViewer::toggleSurfaceAction(
int aAction) {
873 }
else if (aAction ==2) {
876 }
else if (aAction ==3) {
879 }
else if (aAction ==4) {
882 fVP.SetDrawingStyle(d_style);
884 updateToolbarAndMouseContextMenu();
899 void G4OpenGLQtViewer::toggleProjection(
bool check) {
902 fVP.SetOrthogonalProjection ();
904 fVP.SetPerspectiveProjection();
906 updateToolbarAndMouseContextMenu();
915 void G4OpenGLQtViewer::toggleTransparency(
bool check) {
918 transparency_enabled =
true;
920 transparency_enabled =
false;
922 SetNeedKernelVisit (
true);
923 updateToolbarAndMouseContextMenu();
931 void G4OpenGLQtViewer::toggleAntialiasing(
bool check) {
934 antialiasing_enabled =
false;
935 glDisable (GL_LINE_SMOOTH);
936 glDisable (GL_POLYGON_SMOOTH);
938 antialiasing_enabled =
true;
939 glEnable (GL_LINE_SMOOTH);
940 glHint (GL_LINE_SMOOTH_HINT, GL_NICEST);
941 glEnable (GL_POLYGON_SMOOTH);
942 glHint (GL_POLYGON_SMOOTH_HINT, GL_NICEST);
945 updateToolbarAndMouseContextMenu();
954 void G4OpenGLQtViewer::toggleHaloing(
bool check) {
956 haloing_enabled =
false;
958 haloing_enabled =
true;
961 updateToolbarAndMouseContextMenu();
970 void G4OpenGLQtViewer::toggleAux(
bool check) {
972 fVP.SetAuxEdgeVisible(
true);
974 fVP.SetAuxEdgeVisible(
false);
976 SetNeedKernelVisit (
true);
977 updateToolbarAndMouseContextMenu();
982 void G4OpenGLQtViewer::togglePicking() {
985 if (!fVP.IsPicking()) {
986 fUiQt->SetIconPickSelected();
988 fUiQt->SetIconRotateSelected();
994 if (!fVP.IsPicking()) {
995 UI->
ApplyCommand(std::string(
"/vis/viewer/set/picking true"));
997 UI->
ApplyCommand(std::string(
"/vis/viewer/set/picking false"));
1008 void G4OpenGLQtViewer::toggleHiddenMarkers(
bool check) {
1010 fVP.SetMarkerHidden();
1012 fVP.SetMarkerNotHidden();
1015 updateToolbarAndMouseContextMenu();
1022 void G4OpenGLQtViewer::toggleFullScreen(
bool check) {
1023 if (check != fGLWidget->isFullScreen()) {
1024 fGLWidget->setWindowState(fGLWidget->windowState() ^ Qt::WindowFullScreen);
1029 void G4OpenGLQtViewer::savePPMToTemp() {
1030 if (fMovieTempFolderPath ==
"") {
1033 QGLWidget* qGLW =
dynamic_cast<QGLWidget*
> (fGLWidget) ;
1037 QString fileName =
"Test"+QString::number(fRecordFrameNumber)+
".ppm";
1038 QString filePath =fMovieTempFolderPath+fileName;
1041 image = qGLW->grabFrameBuffer();
1044 res = image.save(filePath,0);
1047 setRecordingInfos(
"Can't save tmp file "+filePath);
1051 setRecordingInfos(
"File "+fileName+
" saved");
1052 fRecordFrameNumber++;
1057 void G4OpenGLQtViewer::actionSaveImage() {
1059 for (
unsigned int i = 0; i < fExportImageFormatVector.size(); ++i) {
1060 filters += QString(
"*.") + fExportImageFormatVector.at(i).c_str() +
";;";
1063 QString* selectedFormat =
new QString(fDefaultExportImageFormat.c_str());
1065 qFilename = QFileDialog::getSaveFileName ( fGLWidget,
1072 std::string name = qFilename.toStdString().c_str();
1079 fFileSavePath = QFileInfo(qFilename).path();
1081 std::string format = selectedFormat->toLower().toStdString().c_str();
1084 fExportImageFormat = format.substr(format.find_last_of(
".") + 1);
1086 std::string filename =
name;
1087 std::string extension =
"";
1088 if (name.find_last_of(
".") != std::string::npos) {
1089 filename = name.substr(0,name.find_last_of(
".") + 1);
1090 extension = name.substr(name.find_last_of(
".") + 1);
1092 extension = fExportImageFormat;
1095 filename+=
"."+ extension;
1097 if (!setExportFilename(filename.c_str(),0)) {
1101 G4OpenGLQtExportDialog* exportDialog=
new G4OpenGLQtExportDialog(fGLWidget,format.c_str(),fGLWidget->height(),fGLWidget->width());
1102 if( exportDialog->exec()) {
1104 if ((exportDialog->getWidth() !=fGLWidget->width()) ||
1105 (exportDialog->getHeight() !=fGLWidget->height())) {
1106 setExportSize(exportDialog->getWidth(),exportDialog->getHeight());
1109 if (fExportImageFormat ==
"eps") {
1110 fVectoredPs = exportDialog->getVectorEPS();
1111 }
else if (fExportImageFormat ==
"ps") {
1114 fLastExportSliderValue = exportDialog->getSliderValue();
1116 if (exportImage(filename)) {
1118 fDefaultExportImageFormat = format;
1127 void G4OpenGLQtViewer::actionChangeBackgroundColor() {
1135 #if QT_VERSION < 0x040500
1137 const QColor color = QColor(QColorDialog::getRgba (QColor(Qt::black).rgba(),&a,fGLWidget));
1139 const QColor color =
1140 QColorDialog::getColor(Qt::black,
1142 " Get background color and transparency",
1143 QColorDialog::ShowAlphaChannel);
1145 if (color.isValid()) {
1150 fVP.SetBackgroundColour(colour);
1152 updateToolbarAndMouseContextMenu();
1157 void G4OpenGLQtViewer::actionChangeTextColor() {
1159 #if QT_VERSION < 0x040500
1161 const QColor color = QColor(QColorDialog::getRgba (QColor(
Qt::yellow).rgba(),&a,fGLWidget));
1163 const QColor& color =
1166 " Get text color and transparency",
1167 QColorDialog::ShowAlphaChannel);
1169 if (color.isValid()) {
1175 fVP.SetDefaultTextColour(colour);
1177 updateToolbarAndMouseContextMenu();
1182 void G4OpenGLQtViewer::actionChangeDefaultColor() {
1184 #if QT_VERSION < 0x040500
1186 const QColor color = QColor(QColorDialog::getRgba (QColor(Qt::white).rgba(),&a,fGLWidget));
1188 const QColor& color =
1189 QColorDialog::getColor(Qt::white,
1191 " Get default color and transparency",
1192 QColorDialog::ShowAlphaChannel);
1194 if (color.isValid()) {
1200 fVP.SetDefaultColour(colour);
1202 updateToolbarAndMouseContextMenu();
1208 void G4OpenGLQtViewer::actionMovieParameters() {
1209 showMovieParametersDialog();
1213 void G4OpenGLQtViewer::showMovieParametersDialog() {
1214 if (!fMovieParametersDialog) {
1215 fMovieParametersDialog=
new G4OpenGLQtMovieDialog(
this,fGLWidget);
1216 displayRecordingStatus();
1217 fMovieParametersDialog->checkEncoderSwParameters();
1218 fMovieParametersDialog->checkSaveFileNameParameters();
1219 fMovieParametersDialog->checkTempFolderParameters();
1220 if (getEncoderPath() ==
"") {
1221 setRecordingInfos(
"ppmtompeg is needed to encode in video format. It is available here: http://netpbm.sourceforge.net ");
1224 fMovieParametersDialog->show();
1229 void G4OpenGLQtViewer::FinishView()
1245 void G4OpenGLQtViewer::G4MousePressEvent(QMouseEvent *evnt)
1247 if (evnt->button() == Qt::RightButton) {
1250 if ((evnt->button() & Qt::LeftButton) && (! (evnt->modifiers() & Qt::ControlModifier ))){
1251 fGLWidget->setMouseTracking(
true);
1253 fLastPos1 = evnt->pos();
1254 fLastPos2 = fLastPos1;
1255 fLastPos3 = fLastPos2;
1256 fLastEventTime->start();
1257 if (fUiQt != NULL) {
1259 if (fUiQt->IsIconZoomInSelected()) {
1262 float deltaX = ((float)getWinWidth()/2-evnt->pos().x());
1263 float deltaY = ((float)getWinHeight()/2-evnt->pos().y());
1267 if (getWinHeight() <getWinWidth()) {
1270 fVP.IncrementPan(-deltaX*coefTrans,deltaY*coefTrans,0);
1271 fVP.SetZoomFactor(1.5 * fVP.GetZoomFactor());
1275 }
else if (fUiQt->IsIconZoomOutSelected()) {
1277 moveScene(((
float)getWinWidth()/2-evnt->pos().x()),((
float)getWinHeight()/2-evnt->
pos().
y()),0,true);
1279 fVP.SetZoomFactor(0.75 * fVP.GetZoomFactor());
1282 }
else if (fUiQt->IsIconRotateSelected() ) {
1284 if (fShiftKeyPress) {
1285 fGLWidget->setCursor(QCursor(Qt::SizeAllCursor));
1288 fGLWidget->setCursor(QCursor(Qt::ClosedHandCursor));
1290 }
else if (fUiQt->IsIconMoveSelected()) {
1291 fGLWidget->setCursor(QCursor(Qt::SizeAllCursor));
1292 }
else if (fUiQt->IsIconPickSelected()) {
1293 fGLWidget->setCursor(QCursor(Qt::PointingHandCursor));
1301 void G4OpenGLQtViewer::G4MouseReleaseEvent(QMouseEvent *evnt)
1304 glGetIntegerv(GL_VIEWPORT, viewport);
1307 double factorX = ((double)viewport[2]/fGLWidget->width());
1308 double factorY = ((double)viewport[3]/fGLWidget->height());
1309 fSpinningDelay = fLastEventTime->elapsed();
1310 QPoint delta = (fLastPos3-fLastPos1)*factorX;
1313 fGLWidget->setCursor(QCursor(Qt::ArrowCursor));
1315 if (fVP.IsPicking()){
1316 if ((delta.x() != 0) || (delta.y() != 0)) {
1319 updatePickInfosWidget(evnt->pos().x()*factorX,evnt->pos().y()*factorY);
1321 }
else if (fSpinningDelay < fLaunchSpinDelay ) {
1322 if ((delta.x() == 0) && (delta.y() == 0)) {
1328 lastMoveTime.start();
1330 float correctionFactor = 5;
1332 if ( lastMoveTime.elapsed() >= (
int)(1000/fNbMaxFramesPerSec)) {
1333 float lTime = 1000/lastMoveTime.elapsed();
1334 if (((((
float)delta.x())/correctionFactor)*lTime > fNbMaxAnglePerSec) ||
1335 ((((
float)delta.x())/correctionFactor)*lTime < -fNbMaxAnglePerSec) ) {
1336 correctionFactor = (float)delta.x()*(lTime/fNbMaxAnglePerSec);
1337 if (delta.x() <0 ) {
1338 correctionFactor = -correctionFactor;
1341 if (((((
float)delta.y())/correctionFactor)*lTime > fNbMaxAnglePerSec) ||
1342 ((((
float)delta.y())/correctionFactor)*lTime < -fNbMaxAnglePerSec) ) {
1343 correctionFactor = (float)delta.y()*(lTime/fNbMaxAnglePerSec);
1344 if (delta.y() <0 ) {
1345 correctionFactor = -correctionFactor;
1356 lastMoveTime.start();
1358 bool rotate =
false;
1361 if (fUiQt != NULL) {
1362 if (fUiQt->IsIconRotateSelected()) {
1364 }
else if (fUiQt->IsIconMoveSelected()) {
1377 rotateQtScene(((
float)delta.x())/correctionFactor,((
float)delta.y())/correctionFactor);
1378 }
else if (fAltKeyPress) {
1379 rotateQtSceneToggle(((
float)delta.x())/correctionFactor,((
float)delta.y())/correctionFactor);
1383 moveScene(-((
float)delta.x())/correctionFactor,-((
float)delta.y())/correctionFactor,0,true);
1386 ((QApplication*)G4Qt::getInstance ())->processEvents();
1389 fGLWidget->setMouseTracking(false);
1394 void G4OpenGLQtViewer::G4MouseDoubleClickEvent()
1396 fGLWidget->setMouseTracking(
true);
1407 void G4OpenGLQtViewer::G4MouseMoveEvent(QMouseEvent *evnt)
1410 Qt::MouseButtons mButtons = evnt->buttons();
1412 updateKeyModifierState(evnt->modifiers());
1418 fLastPos3 = fLastPos2;
1419 fLastPos2 = fLastPos1;
1420 fLastPos1 = QPoint(evnt->x(), evnt->y());
1422 int deltaX = fLastPos2.x()-fLastPos1.x();
1423 int deltaY = fLastPos2.y()-fLastPos1.y();
1426 if (fUiQt != NULL) {
1427 if (fUiQt->IsIconMoveSelected()) {
1432 if (mButtons & Qt::LeftButton) {
1434 rotateQtScene(((
float)deltaX),((
float)deltaY));
1435 }
else if (fAltKeyPress) {
1436 rotateQtSceneToggle(((
float)deltaX),((
float)deltaY));
1437 }
else if (fShiftKeyPress) {
1438 unsigned int sizeWin;
1439 sizeWin = getWinWidth();
1440 if (getWinHeight() < getWinWidth()) {
1441 sizeWin = getWinHeight();
1445 float factor = ((float)100/(
float)sizeWin) ;
1446 moveScene(-(
float)deltaX*factor,-(
float)deltaY*factor,0,
false);
1447 }
else if (fControlKeyPress) {
1448 fVP.SetZoomFactor(fVP.GetZoomFactor()*(1+((float)deltaY)));
1452 if (mButtons & Qt::LeftButton) {
1453 moveScene(-(
float)deltaX,-(
float)deltaY,0,
true);
1457 fLastEventTime->start();
1468 void G4OpenGLQtViewer::moveScene(
float dx,
float dy,
float dz,
bool mouseMove)
1472 fHoldMoveEvent =
true;
1475 GLdouble coefDepth = 0;
1478 if (getWinHeight() <getWinWidth()) {
1482 coefTrans = getSceneNearWidth()*fPan_sens;
1483 coefDepth = getSceneDepth()*fDeltaDepth;
1485 fVP.IncrementPan(-dx*coefTrans,dy*coefTrans,dz*coefDepth);
1489 ((QApplication*)G4Qt::getInstance ())->processEvents();
1491 fHoldMoveEvent =
false;
1500 void G4OpenGLQtViewer::rotateQtScene(
float dx,
float dy)
1502 if (fHoldRotateEvent)
1504 fHoldRotateEvent =
true;
1510 fHoldRotateEvent =
false;
1518 void G4OpenGLQtViewer::rotateQtSceneToggle(
float dx,
float dy)
1520 if (fHoldRotateEvent)
1522 fHoldRotateEvent =
true;
1524 rotateSceneToggle(dx,dy);
1528 fHoldRotateEvent =
false;
1539 void G4OpenGLQtViewer::rescaleImage(
1559 void G4OpenGLQtViewer::G4wheelEvent (QWheelEvent * evnt)
1561 fVP.SetZoomFactor(fVP.GetZoomFactor()+(fVP.GetZoomFactor()*(evnt->delta())/1200));
1566 void G4OpenGLQtViewer::G4keyPressEvent (QKeyEvent * evnt)
1571 fHoldKeyEvent =
true;
1575 updateKeyModifierState(evnt->modifiers());
1576 if ((fNoKeyPress) || (evnt->modifiers() == Qt::KeypadModifier )) {
1577 if (evnt->key() == Qt::Key_Down) {
1578 moveScene(0,1,0,
false);
1580 else if (evnt->key() == Qt::Key_Up) {
1581 moveScene(0,-1,0,
false);
1583 if (evnt->key() == Qt::Key_Left) {
1584 moveScene(-1,0,0,
false);
1586 else if (evnt->key() == Qt::Key_Right) {
1587 moveScene(1,0,0,
false);
1589 if (evnt->key() == Qt::Key_Minus) {
1590 moveScene(0,0,1,
false);
1592 else if (evnt->key() == Qt::Key_Plus) {
1593 moveScene(0,0,-1,
false);
1596 if (evnt->key() == Qt::Key_Escape) {
1597 toggleFullScreen(
false);
1606 if ((evnt->key() == Qt::Key_Return) || (evnt->key() == Qt::Key_Enter)){
1609 if (evnt->key() == Qt::Key_Space){
1614 if (evnt->key() == Qt::Key_H){
1621 if (fShiftKeyPress) {
1622 fGLWidget->setCursor(QCursor(Qt::SizeAllCursor));
1624 if (evnt->key() == Qt::Key_Down) {
1625 rotateQtScene(0,-fRot_sens);
1627 else if (evnt->key() == Qt::Key_Up) {
1628 rotateQtScene(0,fRot_sens);
1630 if (evnt->key() == Qt::Key_Left) {
1631 rotateQtScene(fRot_sens,0);
1633 else if (evnt->key() == Qt::Key_Right) {
1634 rotateQtScene(-fRot_sens,0);
1636 if (evnt->key() == Qt::Key_Plus) {
1638 moveScene(0,0,-1,
false);
1643 if ((fAltKeyPress)) {
1644 fGLWidget->setCursor(QCursor(Qt::ClosedHandCursor));
1646 if (evnt->key() == Qt::Key_Down) {
1647 rotateQtSceneToggle(0,-fRot_sens);
1649 else if (evnt->key() == Qt::Key_Up) {
1650 rotateQtSceneToggle(0,fRot_sens);
1652 if (evnt->key() == Qt::Key_Left) {
1653 rotateQtSceneToggle(fRot_sens,0);
1655 else if (evnt->key() == Qt::Key_Right) {
1656 rotateQtSceneToggle(-fRot_sens,0);
1660 if (evnt->key() == Qt::Key_Plus) {
1661 fRot_sens = fRot_sens/0.7;
1662 G4cout <<
"Auto-rotation set to : " << fRot_sens <<
G4endl;
1664 else if (evnt->key() == Qt::Key_Minus) {
1665 fRot_sens = fRot_sens*0.7;
1666 G4cout <<
"Auto-rotation set to : " << fRot_sens <<
G4endl;
1671 if ((fControlKeyPress)) {
1672 if (evnt->key() == Qt::Key_Plus) {
1673 fVP.SetZoomFactor(fVP.GetZoomFactor()*(1+fDeltaZoom));
1676 else if (evnt->key() == Qt::Key_Minus) {
1677 fVP.SetZoomFactor(fVP.GetZoomFactor()*(1-fDeltaZoom));
1682 fHoldKeyEvent =
false;
1686 void G4OpenGLQtViewer::G4keyReleaseEvent (QKeyEvent *)
1688 fGLWidget->setCursor(QCursor(Qt::ArrowCursor));
1692 void G4OpenGLQtViewer::updateKeyModifierState(
const Qt::KeyboardModifiers& modifier) {
1696 fAltKeyPress =
false;
1697 fShiftKeyPress =
false;
1698 fControlKeyPress =
false;
1700 if (modifier & Qt::AltModifier ) {
1701 fAltKeyPress =
true;
1702 fNoKeyPress =
false;
1704 if (modifier & Qt::ShiftModifier ) {
1705 fShiftKeyPress =
true;
1706 fNoKeyPress =
false;
1708 if (modifier & Qt::ControlModifier ) {
1709 fControlKeyPress =
true;
1710 fNoKeyPress =
false;
1717 void G4OpenGLQtViewer::stopVideo() {
1720 if (!fMovieParametersDialog) {
1721 showMovieParametersDialog();
1723 setRecordingStatus(STOP);
1725 if (fRecordFrameNumber >0) {
1727 if (!(fMovieParametersDialog->checkEncoderSwParameters())) {
1728 setRecordingStatus(BAD_ENCODER);
1729 }
else if (!(fMovieParametersDialog->checkSaveFileNameParameters())) {
1730 setRecordingStatus(BAD_OUTPUT);
1734 setRecordingInfos(
"No frame to encode.");
1740 void G4OpenGLQtViewer::saveVideo() {
1743 if (!fMovieParametersDialog) {
1744 showMovieParametersDialog();
1747 fMovieParametersDialog->checkEncoderSwParameters();
1748 fMovieParametersDialog->checkSaveFileNameParameters();
1750 if (fRecordingStep == STOP) {
1751 setRecordingStatus(SAVE);
1752 generateMpegEncoderParameters();
1760 void G4OpenGLQtViewer::startPauseVideo() {
1764 if ( fRecordingStep == WAIT) {
1765 if ( fRecordFrameNumber == 0) {
1766 if (getTempFolderPath() ==
"") {
1767 showMovieParametersDialog();
1768 setRecordingInfos(
"You should specified the temp folder in order to make movie");
1772 QString
tmp = removeTempFolder();
1774 setRecordingInfos(tmp);
1777 tmp = createTempFolder();
1779 setRecordingInfos(
"Can't create temp folder."+tmp);
1785 if (fRecordingStep == WAIT) {
1786 setRecordingStatus(
START);
1787 }
else if (fRecordingStep ==
START) {
1788 setRecordingStatus(PAUSE);
1789 }
else if (fRecordingStep == PAUSE) {
1790 setRecordingStatus(CONTINUE);
1791 }
else if (fRecordingStep == CONTINUE) {
1792 setRecordingStatus(PAUSE);
1796 void G4OpenGLQtViewer::setRecordingStatus(RECORDING_STEP step) {
1798 fRecordingStep = step;
1799 displayRecordingStatus();
1803 void G4OpenGLQtViewer::displayRecordingStatus() {
1805 QString txtStatus =
"";
1806 if (fRecordingStep == WAIT) {
1807 txtStatus =
"Waiting to start...";
1808 fRecordFrameNumber = 0;
1809 }
else if (fRecordingStep ==
START) {
1810 txtStatus =
"Start Recording...";
1811 }
else if (fRecordingStep == PAUSE) {
1812 txtStatus =
"Pause Recording...";
1813 }
else if (fRecordingStep == CONTINUE) {
1814 txtStatus =
"Continue Recording...";
1815 }
else if (fRecordingStep == STOP) {
1816 txtStatus =
"Stop Recording...";
1817 }
else if (fRecordingStep == READY_TO_ENCODE) {
1818 txtStatus =
"Ready to Encode...";
1819 }
else if (fRecordingStep ==
ENCODING) {
1820 txtStatus =
"Encoding...";
1821 }
else if (fRecordingStep == FAILED) {
1822 txtStatus =
"Failed to encode...";
1823 }
else if ((fRecordingStep == BAD_ENCODER)
1824 || (fRecordingStep == BAD_OUTPUT)
1825 || (fRecordingStep == BAD_TMP)) {
1826 txtStatus =
"Correct above errors first";
1827 }
else if (fRecordingStep == SUCCESS) {
1828 txtStatus =
"File encoded successfully";
1832 if (fMovieParametersDialog) {
1833 fMovieParametersDialog->setRecordingStatus(txtStatus);
1837 setRecordingInfos(
"");
1841 void G4OpenGLQtViewer::setRecordingInfos(
const QString& txt) {
1842 if (fMovieParametersDialog) {
1843 fMovieParametersDialog->setRecordingInfos(txt);
1851 void G4OpenGLQtViewer::initMovieParameters() {
1855 fProcess =
new QProcess();
1857 QObject ::connect(fProcess,SIGNAL(finished (
int)),
1858 this,SLOT(processLookForFinished()));
1859 fProcess->setReadChannelMode(QProcess::MergedChannels);
1860 fProcess->start (
"which ppmtompeg");
1866 QString G4OpenGLQtViewer::getEncoderPath() {
1867 return fEncoderPath;
1875 QString G4OpenGLQtViewer::setEncoderPath(QString path) {
1877 return "ppmtompeg is needed to encode in video format. It is available here: http://netpbm.sourceforge.net ";
1880 path = QDir::cleanPath(path);
1881 QFileInfo *
f =
new QFileInfo(path);
1883 return "File does not exist";
1884 }
else if (f->isDir()) {
1885 return "This is a directory";
1886 }
else if (!f->isExecutable()) {
1887 return "File exist but is not executable";
1888 }
else if (!f->isFile()) {
1889 return "This is not a file";
1891 fEncoderPath = path;
1893 if (fRecordingStep == BAD_ENCODER) {
1894 setRecordingStatus(STOP);
1900 bool G4OpenGLQtViewer::isRecording(){
1901 if ((fRecordingStep ==
START) || (fRecordingStep == CONTINUE)) {
1907 bool G4OpenGLQtViewer::isPaused(){
1908 if (fRecordingStep == PAUSE) {
1914 bool G4OpenGLQtViewer::isEncoding(){
1921 bool G4OpenGLQtViewer::isWaiting(){
1922 if (fRecordingStep == WAIT) {
1928 bool G4OpenGLQtViewer::isStopped(){
1929 if (fRecordingStep == STOP) {
1935 bool G4OpenGLQtViewer::isFailed(){
1936 if (fRecordingStep == FAILED) {
1942 bool G4OpenGLQtViewer::isSuccess(){
1943 if (fRecordingStep == SUCCESS) {
1949 bool G4OpenGLQtViewer::isBadEncoder(){
1950 if (fRecordingStep == BAD_ENCODER) {
1955 bool G4OpenGLQtViewer::isBadTmp(){
1956 if (fRecordingStep == BAD_TMP) {
1961 bool G4OpenGLQtViewer::isBadOutput(){
1962 if (fRecordingStep == BAD_OUTPUT) {
1968 void G4OpenGLQtViewer::setBadEncoder(){
1969 fRecordingStep = BAD_ENCODER;
1970 displayRecordingStatus();
1972 void G4OpenGLQtViewer::setBadTmp(){
1973 fRecordingStep = BAD_TMP;
1974 displayRecordingStatus();
1976 void G4OpenGLQtViewer::setBadOutput(){
1977 fRecordingStep = BAD_OUTPUT;
1978 displayRecordingStatus();
1981 void G4OpenGLQtViewer::setWaiting(){
1982 fRecordingStep = WAIT;
1983 displayRecordingStatus();
1987 bool G4OpenGLQtViewer::isReadyToEncode(){
1988 if (fRecordingStep == READY_TO_ENCODE) {
1994 void G4OpenGLQtViewer::resetRecording() {
1995 setRecordingStatus(WAIT);
2002 QString G4OpenGLQtViewer::setTempFolderPath(QString path) {
2005 return "Path does not exist";
2007 path = QDir::cleanPath(path);
2008 QFileInfo *
d =
new QFileInfo(path);
2010 return "Path does not exist";
2011 }
else if (!d->isDir()) {
2012 return "This is not a directory";
2013 }
else if (!d->isReadable()) {
2014 return path +
" is read protected";
2015 }
else if (!d->isWritable()) {
2016 return path +
" is write protected";
2019 if (fRecordingStep == BAD_TMP) {
2020 setRecordingStatus(WAIT);
2022 fTempFolderPath = path;
2028 QString G4OpenGLQtViewer::getTempFolderPath() {
2029 return fTempFolderPath;
2036 QString G4OpenGLQtViewer::setSaveFileName(QString path) {
2039 return "Path does not exist";
2042 QFileInfo *
file =
new QFileInfo(path);
2043 QDir
dir = file->dir();
2044 path = QDir::cleanPath(path);
2045 if (file->exists()) {
2046 return "File already exist, please choose a new one";
2047 }
else if (!dir.exists()) {
2048 return "Dir does not exist";
2049 }
else if (!dir.isReadable()) {
2050 return path +
" is read protected";
2053 if (fRecordingStep == BAD_OUTPUT) {
2054 setRecordingStatus(STOP);
2056 fSaveFileName = path;
2062 QString G4OpenGLQtViewer::getSaveFileName() {
2063 return fSaveFileName ;
2070 QString G4OpenGLQtViewer::createTempFolder() {
2071 fMovieTempFolderPath =
"";
2073 QString
tmp = setTempFolderPath(fTempFolderPath);
2077 QString sep = QString(QDir::separator());
2078 QString path = sep+
"QtMovie_"+QDateTime::currentDateTime ().toString(
"dd-MM-yyyy_hh-mm-ss")+sep;
2079 QDir *d =
new QDir(QDir::cleanPath(fTempFolderPath));
2081 if (d->exists(path)) {
2082 return "Folder "+path+
" already exists.Please remove it first";
2084 if (d->mkdir(fTempFolderPath+path)) {
2085 fMovieTempFolderPath = fTempFolderPath+path;
2088 return "Can't create "+fTempFolderPath+path;
2093 QString G4OpenGLQtViewer::removeTempFolder() {
2095 if (fMovieTempFolderPath ==
"") {
2098 QDir *d =
new QDir(QDir::cleanPath(fMovieTempFolderPath));
2103 d->setFilter( QDir::Files );
2104 QStringList subDirList = d->entryList();
2107 for (QStringList::ConstIterator it = subDirList.begin() ;(it != subDirList.end()) ; it++) {
2108 const QString currentFile = *it;
2109 if (!d->remove(currentFile)) {
2111 QString file = fMovieTempFolderPath+currentFile;
2112 error +=
"Removing file failed : "+
file;
2117 if (d->rmdir(fMovieTempFolderPath)) {
2118 fMovieTempFolderPath =
"";
2121 return "Dir "+fMovieTempFolderPath+
" should be empty, but could not remove it";
2125 return "Could not remove "+fMovieTempFolderPath+
" because of the following errors :"+
error;
2135 bool G4OpenGLQtViewer::exportImage(std::string name,
int width,
int height) {
2137 QGLWidget* qGLW =
dynamic_cast<QGLWidget*
> (fGLWidget) ;
2142 bool increaseFileNumber =
true;
2144 if (name.size() != name.substr(name.find_last_of(
".") + 1).size()) {
2145 increaseFileNumber =
false;
2147 if (! setExportFilename(name,increaseFileNumber)) {
2150 if ((width !=-1) && (height != -1)) {
2151 setExportSize(width, height);
2154 if (G4OpenGLViewer::exportImage(name, width, height)) {
2160 image = qGLW->grabFrameBuffer();
2162 bool res = image.save(QString(getRealPrintFilename().c_str()),0,fLastExportSliderValue);
2165 G4cerr <<
"Error saving file... " << getRealPrintFilename().c_str() <<
G4endl;
2168 G4cout <<
"File " << getRealPrintFilename().c_str() <<
" size: " << fGLWidget->width() <<
"x" << fGLWidget->height() <<
" has been saved " <<
G4endl;
2169 fExportFilenameIndex++;
2177 bool G4OpenGLQtViewer::hasPendingEvents () {
2178 return ((QApplication*)G4Qt::getInstance ())->hasPendingEvents ();
2181 bool G4OpenGLQtViewer::generateMpegEncoderParameters () {
2185 fp = fopen (QString(fMovieTempFolderPath+fParameterFileName).toStdString().c_str(),
"w");
2188 setRecordingInfos(
"Generation of parameter file failed");
2192 fprintf (fp,
"# Pattern affects speed, quality and compression. See the User's Guide\n");
2193 fprintf (fp,
"# for more info.\n");
2195 fprintf (fp,
"PATTERN I\n");
2196 fprintf (fp,
"OUTPUT %s\n",getSaveFileName().toStdString().c_str());
2198 fprintf (fp,
"# You must specify the type of the input files. The choices are:\n");
2199 fprintf (fp,
"# YUV, PPM, JMOVIE, Y, JPEG, PNM\n");
2200 fprintf (fp,
"# (must be upper case)\n");
2202 fprintf (fp,
"BASE_FILE_FORMAT PPM\n");
2205 fprintf (fp,
"# If you are using YUV, there are different supported file formats.\n");
2206 fprintf (fp,
"# EYUV or UCB are the same as previous versions of this encoder.\n");
2207 fprintf (fp,
"# (All the Y's, then U's then V's, in 4:2:0 subsampling.)\n");
2208 fprintf (fp,
"# Other formats, such as Abekas, Phillips, or a general format are\n");
2209 fprintf (fp,
"# permissible, the general format is a string of Y's, U's, and V's\n");
2210 fprintf (fp,
"# to specify the file order.\n");
2212 fprintf (fp,
"INPUT_FORMAT UCB\n");
2214 fprintf (fp,
"# the conversion statement\n");
2216 fprintf (fp,
"# Each occurrence of '*' will be replaced by the input file\n");
2218 fprintf (fp,
"# e.g., if you have a bunch of GIF files, then this might be:\n");
2219 fprintf (fp,
"# INPUT_CONVERT giftoppm *\n");
2221 fprintf (fp,
"# e.g., if you have a bunch of files like a.Y a.U a.V, etc., then:\n");
2222 fprintf (fp,
"# INPUT_CONVERT cat *.Y *.U *.V\n");
2224 fprintf (fp,
"# e.g., if you are grabbing from laser disc you might have something like\n");
2225 fprintf (fp,
"# INPUT_CONVERT goto frame *; grabppm\n");
2226 fprintf (fp,
"# 'INPUT_CONVERT *' means the files are already in the base file format\n");
2228 fprintf (fp,
"INPUT_CONVERT * \n");
2230 fprintf (fp,
"# number of frames in a GOP.\n");
2232 fprintf (fp,
"# since each GOP must have at least one I-frame, the encoder will find the\n");
2233 fprintf (fp,
"# the first I-frame after GOP_SIZE frames to start the next GOP\n");
2235 fprintf (fp,
"# later, will add more flexible GOP signalling\n");
2237 fprintf (fp,
"GOP_SIZE 1\n");
2239 fprintf (fp,
"# number of slices in a frame\n");
2241 fprintf (fp,
"# 1 is a good number. another possibility is the number of macroblock rows\n");
2242 fprintf (fp,
"# (which is the height divided by 16)\n");
2244 fprintf (fp,
"SLICES_PER_FRAME 1\n");
2245 fprintf (fp,
"PIXEL HALF");
2247 fprintf (fp,
"# directory to get all input files from (makes this file easier to read)\n");
2248 fprintf (fp,
"INPUT_DIR %s\n",fMovieTempFolderPath.toStdString().c_str());
2250 fprintf (fp,
"# There are a bunch of ways to specify the input files.\n");
2251 fprintf (fp,
"# from a simple one-per-line listing, to the following \n");
2252 fprintf (fp,
"# way of numbering them. See the manual for more information.\n");
2253 fprintf (fp,
"INPUT\n");
2254 fprintf (fp,
"# '*' is replaced by the numbers 01, 02, 03, 04\n");
2255 fprintf (fp,
"# if I instead do [01-11], it would be 01, 02, ..., 09, 10, 11\n");
2256 fprintf (fp,
"# if I instead do [1-11], it would be 1, 2, 3, ..., 9, 10, 11\n");
2257 fprintf (fp,
"# if I instead do [1-11+3], it would be 1, 4, 7, 10\n");
2258 fprintf (fp,
"# the program assumes none of your input files has a name ending in ']'\n");
2259 fprintf (fp,
"# if you do, too bad!!!\n");
2262 fprintf (fp,
"Test*.ppm [0-%d]\n",fRecordFrameNumber-1);
2263 fprintf (fp,
"# can have more files here if you want...there is no limit on the number\n");
2264 fprintf (fp,
"# of files\n");
2265 fprintf (fp,
"END_INPUT\n");
2269 fprintf (fp,
"# Many of the remaining options have to do with the motion search and qscale\n");
2271 fprintf (fp,
"# FULL or HALF -- must be upper case\n");
2272 fprintf (fp,
"# Should be FULL for computer generated images\n");
2273 fprintf (fp,
"PIXEL FULL\n");
2275 fprintf (fp,
"# means +/- this many pixels for both P and B frame searches\n");
2276 fprintf (fp,
"# specify two numbers if you wish to serc different ranges in the two.\n");
2277 fprintf (fp,
"RANGE 10\n");
2279 fprintf (fp,
"# The two search algorithm parameters below mostly affect speed,\n");
2280 fprintf (fp,
"# with some affect on compression and almost none on quality.\n");
2282 fprintf (fp,
"# this must be one of {EXHAUSTIVE, SUBSAMPLE, LOGARITHMIC}\n");
2283 fprintf (fp,
"PSEARCH_ALG LOGARITHMIC\n");
2285 fprintf (fp,
"# this must be one of {SIMPLE, CROSS2, EXHAUSTIVE}\n");
2287 fprintf (fp,
"# note that EXHAUSTIVE is really, really, really slow\n");
2289 fprintf (fp,
"BSEARCH_ALG SIMPLE\n");
2292 fprintf (fp,
"# these specify the q-scale for I, P, and B frames\n");
2293 fprintf (fp,
"# (values must be between 1 and 31)\n");
2294 fprintf (fp,
"# These are the Qscale values for the entire frame in variable bit-rate\n");
2295 fprintf (fp,
"# mode, and starting points (but not important) for constant bit rate\n");
2298 fprintf (fp,
"# Qscale (Quantization scale) affects quality and compression,\n");
2299 fprintf (fp,
"# but has very little effect on speed.\n");
2301 fprintf (fp,
"IQSCALE 4\n");
2302 fprintf (fp,
"PQSCALE 5\n");
2303 fprintf (fp,
"BQSCALE 12\n");
2305 fprintf (fp,
"# this must be ORIGINAL or DECODED\n");
2306 fprintf (fp,
"REFERENCE_FRAME ORIGINAL\n");
2308 fprintf (fp,
"# for parallel parameters see parallel.param in the exmaples subdirectory\n");
2310 fprintf (fp,
"# if you want constant bit-rate mode, specify it as follows (number is bits/sec):\n");
2311 fprintf (fp,
"#BIT_RATE 1000000\n");
2313 fprintf (fp,
"# To specify the buffer size (327680 is default, measused in bits, for 16bit words)\n");
2314 fprintf (fp,
"BUFFER_SIZE 327680\n");
2316 fprintf (fp,
"# The frame rate is the number of frames/second (legal values:\n");
2317 fprintf (fp,
"# 23.976, 24, 25, 29.97, 30, 50 ,59.94, 60\n");
2318 fprintf (fp,
"FRAME_RATE 30\n");
2320 fprintf (fp,
"# There are many more options, see the users manual for examples....\n");
2321 fprintf (fp,
"# ASPECT_RATIO, USER_DATA, GAMMA, IQTABLE, etc.\n");
2326 setRecordingInfos(
"Parameter file "+fParameterFileName+
" generated in "+fMovieTempFolderPath);
2327 setRecordingStatus(READY_TO_ENCODE);
2331 void G4OpenGLQtViewer::encodeVideo()
2333 if ((getEncoderPath() !=
"") && (getSaveFileName() !=
"")) {
2336 fProcess =
new QProcess();
2337 #if QT_VERSION > 0x040100
2338 QObject ::connect(fProcess,SIGNAL(finished (
int,QProcess::ExitStatus)),
2339 this,SLOT(processEncodeFinished()));
2340 QObject ::connect(fProcess,SIGNAL(readyReadStandardOutput ()),
2341 this,SLOT(processEncodeStdout()));
2343 QObject ::connect(fProcess,SIGNAL(finished (
int)),
2344 this,SLOT(processEncodeFinished()));
2345 QObject ::connect(fProcess,SIGNAL(readyReadStandardOutput ()),
2346 this,SLOT(processEncodeStdout()));
2348 fProcess->setReadChannelMode(QProcess::MergedChannels);
2349 fProcess->start (fEncoderPath, QStringList(fMovieTempFolderPath+fParameterFileName));
2355 void G4OpenGLQtViewer::processEncodeStdout()
2357 QString tmp = fProcess->readAllStandardOutput ().data();
2358 int start = tmp.lastIndexOf(
"ESTIMATED TIME");
2359 tmp = tmp.mid(start,tmp.indexOf(
"\n",start)-start);
2360 setRecordingInfos(tmp);
2364 void G4OpenGLQtViewer::processEncodeFinished()
2368 txt = getProcessErrorMsg();
2370 setRecordingStatus(SUCCESS);
2372 setRecordingStatus(FAILED);
2378 void G4OpenGLQtViewer::processLookForFinished()
2381 QString txt = getProcessErrorMsg();
2385 fEncoderPath = QString(fProcess->readAllStandardOutput ().data()).trimmed();
2387 if (fEncoderPath.contains(
" ")) {
2389 }
else if (!fEncoderPath.contains(
"ppmtompeg")) {
2392 setEncoderPath(fEncoderPath);
2395 setTempFolderPath(QDir::temp ().absolutePath ());
2399 QString G4OpenGLQtViewer::getProcessErrorMsg()
2402 if (fProcess->exitCode() != 0) {
2403 switch (fProcess->error()) {
2404 case QProcess::FailedToStart:
2405 txt =
"The process failed to start. Either the invoked program is missing, or you may have insufficient permissions to invoke the program.\n";
2407 case QProcess::Crashed:
2408 txt =
"The process crashed some time after starting successfully.\n";
2410 case QProcess::Timedout:
2411 txt =
"The last waitFor...() function timed out. The state of QProcess is unchanged, and you can try calling waitFor...() again.\n";
2413 case QProcess::WriteError:
2414 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";
2416 case QProcess::ReadError:
2417 txt =
"An error occurred when attempting to read from the process. For example, the process may not be running.\n";
2419 case QProcess::UnknownError:
2420 txt =
"An unknown error occurred. This is the default return value of error().\n";
2430 QWidget *G4OpenGLQtViewer::getParentWidget()
2433 G4Qt* interactorManager = G4Qt::getInstance ();
2438 QDialog* dialog = NULL;
2440 if (((QApplication*)interactorManager->GetMainInteractor())) {
2442 QWidgetList wl = QApplication::allWidgets();
2443 QWidget *widget = NULL;
2444 for (
int i=0; i < wl.size(); i++) {
2446 if ((found==
false) && (widget->inherits(
"QMainWindow"))) {
2447 dialog =
new QDialog(widget,Qt::WindowTitleHint | Qt::WindowSystemMenuHint | Qt::WindowMinMaxButtonsHint);
2453 dialog =
new QDialog();
2456 dialog=
new QDialog();
2466 void G4OpenGLQtViewer::createSceneTreeWidget() {
2467 fUISceneTreeWidget = fUiQt->GetSceneTreeWidget();
2469 if (!fUISceneTreeWidget) {
2474 QLayoutItem * wItem;
2476 if (fUISceneTreeWidget->layout()->count() ) {
2477 for(
int idx = 0; idx < fUISceneTreeWidget->layout()->count(); idx++){
2478 wItem = fUISceneTreeWidget->layout()->itemAt(idx);
2479 if (fSceneTreeWidget) {
2480 if(dynamic_cast<QWidget *>(wItem->widget())) {
2481 if (wItem->widget()->windowTitle() == fSceneTreeWidget->windowTitle()) {
2482 wItem->widget()->show();
2485 wItem->widget()->hide();
2489 wItem->widget()->hide();
2496 fSceneTreeWidget =
new QWidget();
2497 QVBoxLayout* layoutSceneTree =
new QVBoxLayout();
2498 fSceneTreeWidget->setStyleSheet (
"padding: 0px ");
2500 fSceneTreeWidget->setLayout(layoutSceneTree);
2501 fSceneTreeWidget->layout()->setContentsMargins(5,5,5,5);
2502 fSceneTreeWidget->setWindowTitle(QString(GetName().
data()));
2504 if (fUISceneTreeWidget != NULL) {
2505 fUISceneTreeWidget->layout()->addWidget(fSceneTreeWidget);
2509 if (dynamic_cast<G4OpenGLStoredQtViewer*> (
this)) {
2510 createSceneTreeComponent();
2516 void G4OpenGLQtViewer::createSceneTreeComponent(){
2518 QLayout* vLayout = fSceneTreeWidget->layout();
2521 QWidget* coutButtonWidget =
new QWidget();
2522 QHBoxLayout* layoutCoutTBButtons =
new QHBoxLayout();
2524 fFilterOutput =
new QLineEdit();
2525 fFilterOutput->setToolTip(
"Filter output by...");
2526 fFilterOutput->setStyleSheet (
"padding: 0px ");
2528 QPixmap* searchIcon = fUiQt->getSearchIcon();
2529 #if QT_VERSION > 0x050100
2530 fFilterOutput->addAction(*searchIcon,QLineEdit::TrailingPosition);
2531 fFilterOutput->setStyleSheet (
"border-radius:7px;");
2533 QPushButton *coutTBFilterButton =
new QPushButton();
2534 coutTBFilterButton->setIcon(*searchIcon);
2535 coutTBFilterButton->setStyleSheet (
"padding-left: 0px; border:0px;");
2536 fFilterOutput->setStyleSheet (
"padding-right: 0px;");
2538 layoutCoutTBButtons->addWidget(fFilterOutput);
2540 #if QT_VERSION <= 0x050100
2541 layoutCoutTBButtons->addWidget(coutTBFilterButton);
2544 coutButtonWidget->setLayout(layoutCoutTBButtons);
2545 vLayout->addWidget(coutButtonWidget);
2548 vLayout->setContentsMargins(0,0,0,0);
2551 fSceneTreeComponentTreeWidget =
new QTreeWidget();
2552 fSceneTreeComponentTreeWidget->setSelectionMode(QAbstractItemView::SingleSelection);
2553 fSceneTreeComponentTreeWidget->setHeaderLabel (
"Scene tree : "+QString(GetName().
data()));
2554 fSceneTreeComponentTreeWidget->setColumnHidden (1,
true);
2555 fSceneTreeComponentTreeWidget->setColumnHidden (2,
true);
2556 fSceneTreeComponentTreeWidget->setColumnHidden (3,
true);
2561 vLayout->addWidget(fSceneTreeComponentTreeWidget);
2563 connect(fSceneTreeComponentTreeWidget,SIGNAL(itemChanged(QTreeWidgetItem*,
int)),SLOT(sceneTreeComponentItemChanged(QTreeWidgetItem*,
int)));
2564 connect(fSceneTreeComponentTreeWidget,SIGNAL(itemSelectionChanged ()),SLOT(sceneTreeComponentSelected()));
2565 connect(fSceneTreeComponentTreeWidget,SIGNAL(itemDoubleClicked ( QTreeWidgetItem*,
int)),SLOT(changeColorAndTransparency( QTreeWidgetItem*,
int)));
2569 QWidget *helpWidget =
new QWidget();
2570 QHBoxLayout *helpLayout =
new QHBoxLayout();
2572 QWidget* depthWidget =
new QWidget();
2573 QWidget *showBox =
new QWidget(depthWidget);
2574 QHBoxLayout *showBoxLayout =
new QHBoxLayout();
2577 showBoxLayout->setContentsMargins(5,5,5,5);
2579 QLabel *zero =
new QLabel();
2580 zero->setText(
"Show all");
2581 QLabel *one =
new QLabel();
2582 one->setText(
"Hide all");
2583 fSceneTreeDepthSlider =
new QSlider ( Qt::Horizontal);
2584 fSceneTreeDepthSlider->setMaximum (1000);
2585 fSceneTreeDepthSlider->setMinimum (0);
2586 fSceneTreeDepthSlider->setTickPosition(QSlider::TicksAbove);
2588 fSceneTreeDepthSlider->setMinimumWidth (40);
2590 showBoxLayout->addWidget(zero);
2591 showBoxLayout->addWidget(fSceneTreeDepthSlider);
2592 showBoxLayout->addWidget(one);
2594 showBox->setLayout(showBoxLayout);
2596 helpLayout->addWidget(showBox);
2597 helpWidget->setLayout(helpLayout);
2598 helpLayout->setContentsMargins(0,0,0,0);
2600 vLayout->addWidget(helpWidget);
2602 connect( fSceneTreeDepthSlider, SIGNAL( valueChanged(
int) ),
this, SLOT( changeDepthInSceneTree(
int) ) );
2603 connect( fFilterOutput, SIGNAL( textEdited (
const QString &) ),
this, SLOT(changeSearchSelection()));
2604 fTreeItemModels.clear();
2606 fPVRootNodeCreate =
false;
2608 fMaxPOindexInserted = -1;
2614 void G4OpenGLQtViewer::createViewerPropertiesWidget() {
2617 fUIViewerPropertiesWidget = fUiQt->GetViewerPropertiesWidget();
2619 if (!fUIViewerPropertiesWidget) {
2624 QLayoutItem * wItem;
2625 if (fUIViewerPropertiesWidget->layout()->count()) {
2626 while ((wItem = fUIViewerPropertiesWidget->layout()->takeAt(0)) != 0) {
2627 delete wItem->widget();
2633 QGroupBox *groupBox =
new QGroupBox();
2634 groupBox->setTitle(GetName().
data());
2635 QVBoxLayout *vbox =
new QVBoxLayout;
2638 fViewerPropertiesTableWidget =
new QTableWidget();
2640 QSizePolicy vPolicy = fViewerPropertiesTableWidget->sizePolicy();
2641 vPolicy.setVerticalStretch(4);
2643 vbox->addWidget(fViewerPropertiesTableWidget);
2644 groupBox->setLayout(vbox);
2645 fUIViewerPropertiesWidget->layout()->addWidget(groupBox);
2647 connect(fViewerPropertiesTableWidget, SIGNAL(itemChanged(QTableWidgetItem*)),
this, SLOT(tableWidgetViewerSetItemChanged(QTableWidgetItem *)));
2649 updateViewerPropertiesTableWidget();
2651 QDialog* dial =
static_cast<QDialog*
> (fUIViewerPropertiesWidget->parent());
2654 dial->setWindowTitle(QString(
"Viewer properties - ")+GetName());
2659 void G4OpenGLQtViewer::createPickInfosWidget(){
2662 fUIPickInfosWidget = fUiQt->GetPickInfosWidget();
2664 if (!fUIPickInfosWidget) {
2669 QLayoutItem * wItem;
2670 if (fUIPickInfosWidget->layout()->count()) {
2671 while ((wItem = fUIPickInfosWidget->layout()->takeAt(0)) != 0) {
2672 delete wItem->widget();
2677 QGroupBox *groupBox =
new QGroupBox(
"");
2678 QVBoxLayout *vbox =
new QVBoxLayout;
2681 QWidget *pickingInfoWidget =
new QWidget();
2682 QHBoxLayout *pickingInfoLayout =
new QHBoxLayout();
2684 pickingInfoWidget->setStyleSheet (
"padding-left: 0px; border:0px;");
2685 pickingInfoWidget->setLayout(pickingInfoLayout);
2687 vbox->addWidget(pickingInfoWidget);
2690 fPickInfosScrollArea =
new QScrollArea();
2691 fPickInfosScrollArea->setWidgetResizable(
true);
2694 fPickInfosWidget =
new QWidget();
2695 fPickInfosWidget->setStyleSheet (
"padding: 0px ");
2697 QVBoxLayout* vLayout =
new QVBoxLayout();
2698 fPickInfosWidget->setLayout (vLayout);
2699 fPickInfosScrollArea->setWidget(fPickInfosWidget);
2701 QSizePolicy vPolicy = fPickInfosWidget->sizePolicy();
2702 vPolicy.setVerticalStretch(4);
2703 vbox->addWidget(fPickInfosScrollArea);
2704 pickingInfoLayout->setContentsMargins(0,0,0,0);
2705 vLayout->setContentsMargins(0,0,0,0);
2706 vbox->setContentsMargins(1,1,1,1);
2708 groupBox->setLayout(vbox);
2709 fUIPickInfosWidget->layout()->addWidget(groupBox);
2711 updatePickInfosWidget(fLastPickPoint.x(),fLastPickPoint.y());
2717 void G4OpenGLQtViewer::setCheckComponent(QTreeWidgetItem* item,
bool check)
2721 const PVPath& fullPath = fTreeItemModels[item->data(0,Qt::UserRole).toInt()];
2723 if (fullPath.size() > 0) {
2724 SetTouchable(fullPath);
2725 TouchableSetVisibility(fullPath, check);
2726 fMouseOnSceneTree =
true;
2732 item->setCheckState(0,Qt::Checked);
2734 item->setCheckState(0,Qt::Unchecked);
2736 updatePositivePoIndexSceneTreeWidgetQuickMap(item->data(0,Qt::UserRole).toInt(),item);
2737 int nChildCount = item->childCount();
2738 for (
int i = 0; i < nChildCount; i++) {
2739 setCheckComponent(item->child(i),check);
2745 void G4OpenGLQtViewer::DrawText(
const G4Text& g4text)
2747 QGLWidget* qGLW =
dynamic_cast<QGLWidget*
> (fGLWidget) ;
2751 if (isGl2psWriting()) {
2753 G4OpenGLViewer::DrawText(g4text);
2757 if (!fGLWidget)
return;
2759 #ifdef G4MULTITHREADED
2764 G4double size = fSceneHandler.GetMarkerSize(g4text,sizeType);
2766 QFont font = QFont();
2767 font.setPointSizeF(size);
2769 const G4Colour& c = fSceneHandler.GetTextColour(g4text);
2775 const char* textCString = textString.c_str();
2777 glRasterPos3d(position.x(),position.y(),position.z());
2780 QFontMetrics* f =
new QFontMetrics (font);
2781 G4double span = f->width(textCString);
2794 ((position.x()+(2*xmove)/getWinWidth()),
2795 (position.y()+(2*ymove)/getWinHeight()),
2804 void G4OpenGLQtViewer::ResetView () {
2805 G4OpenGLViewer::ResetView();
2815 const QString& modelShortName = getModelShortName(model);
2817 if (modelShortName ==
"") {
2821 if (fSceneTreeComponentTreeWidget == NULL) {
2822 createSceneTreeComponent();
2826 if (fSceneTreeComponentTreeWidget == NULL) {
2830 fSceneTreeComponentTreeWidget->blockSignals(
true);
2834 if (!fPVRootNodeCreate) {
2837 fModelShortNameItem = createTreeWidgetItem(pPVModel->
GetFullPVPath(),
2845 fPVRootNodeCreate =
true;
2848 bool added = parseAndInsertInSceneTree(fModelShortNameItem,pPVModel,0,modelShortName,0,currentPOIndex);
2852 fSceneTreeComponentTreeWidget->blockSignals(
false);
2861 QTreeWidgetItem* G4OpenGLQtViewer::createTreeWidgetItem(
2863 ,
const QString& name
2866 ,
const QString& logicalName
2867 ,Qt::CheckState state
2868 ,QTreeWidgetItem * parentTreeNode
2873 if (fullPath.size() > fSceneTreeDepth) {
2874 fSceneTreeDepth = fullPath.size();
2876 if (fSceneTreeDepthSlider) {
2877 fSceneTreeDepthSlider->setTickInterval(1000/(fSceneTreeDepth+1));
2880 QTreeWidgetItem * newItem = NULL;
2881 if (parentTreeNode == NULL) {
2882 newItem =
new QTreeWidgetItem();
2883 fSceneTreeComponentTreeWidget->addTopLevelItem(newItem);
2885 newItem =
new QTreeWidgetItem(parentTreeNode);
2886 fSceneTreeComponentTreeWidget->addTopLevelItem(parentTreeNode);
2890 newItem->setText(0,name);
2891 newItem->setData(1,Qt::UserRole,copyNb);
2892 newItem->setText(2,QString::number(POIndex));
2893 newItem->setData(0, Qt::UserRole, POIndex);
2894 newItem->setText(3,logicalName);
2895 newItem->setFlags(newItem->flags()|Qt::ItemIsUserCheckable);
2896 newItem->setCheckState(0,state);
2897 newItem->setExpanded(
true);
2898 updatePositivePoIndexSceneTreeWidgetQuickMap(POIndex,newItem);
2900 changeQColorForTreeWidgetItem(newItem,QColor((
int)(color.
GetRed()*255),
2906 if ((state == Qt::Unchecked) && (POIndex == -1)) {
2907 newItem->setForeground (0, QBrush(
Qt::gray) );
2910 newItem->setToolTip (0,QString(
2911 "This node exists in the geometry but has not been\n")+
2912 "drawn, perhaps because it has been set invisible. It \n"+
2913 "cannot be made visible with a click on the button.\n"+
2914 "To see it, change the visibility, for example, with \n"+
2915 "/vis/geometry/set/visibility " + logicalName +
" 0 true\n"+
2916 "and rebuild the view with /vis/viewer/rebuild.\n"+
2917 "Click here will only show/hide all child components");
2920 newItem->setToolTip (0,QString(
"double-click to change the color"));
2926 state = Qt::Unchecked;
2927 newItem->setCheckState(0,state);
2928 updatePositivePoIndexSceneTreeWidgetQuickMap(POIndex,newItem);
2931 fTreeItemModels.insert(std::pair <int, PVPath > (POIndex,fullPath) );
2935 changeOpenCloseVisibleHiddenSelectedColorSceneTreeElement(newItem);
2952 bool G4OpenGLQtViewer::parseAndInsertInSceneTree(
2953 QTreeWidgetItem * parentItem
2955 ,
unsigned int fullPathIndex
2956 ,
const QString& parentRoot
2957 ,
unsigned int currentIndexInTreeSceneHandler
2958 ,
int currentPVPOIndex
2961 if (parentItem == NULL) {
2967 std::ostringstream oss;
2968 oss << fullPath.at(fullPathIndex).GetCopyNo();
2969 std::string currentPVName =
G4String(fullPath.at(fullPathIndex).GetPhysicalVolume()->GetName()+
" ["+oss.str()+
"]").
data();
2971 int currentPVCopyNb = fullPath.at(fullPathIndex).GetCopyNo();
2981 QTreeWidgetItem* subItem = NULL;
2982 QList<QTreeWidgetItem *> parentItemList;
2990 if ((currentIndexInTreeSceneHandler == (fullPath.size()-1)) && ((color.
GetAlpha() == 1.))) {
2992 QString lookForString = QString(currentPVName.c_str());
2993 for (
int i = 0;i < parentItem->childCount(); i++ ) {
2994 if (parentItem->child(i)->text(0) == lookForString) {
2995 parentItemList.push_back(parentItem->child(i));
3000 for (
int i = 0; i < parentItemList.size(); ++i) {
3001 const std::string& parentItemName = parentItemList.at(i)->text(0).toStdString();
3002 int parentItemCopyNb = parentItemList.at(i)->data(1,Qt::UserRole).toInt();
3003 int parentItemPOIndex = parentItemList.at(i)->data(0,Qt::UserRole).toInt();
3011 if (((parentRoot == fTouchableVolumes) && (currentPVCopyNb == parentItemCopyNb)
3012 && (currentPVName == parentItemName)) ||
3014 ((parentRoot != fTouchableVolumes) && (currentPVCopyNb == parentItemCopyNb)
3016 && (currentPVName == parentItemName) && (currentPVPOIndex == parentItemPOIndex) )) {
3019 bool sameTransform =
true;
3020 if (parentItemPOIndex >= 0) {
3021 const PVPath& fullPathTmp = fTreeItemModels[parentItemPOIndex];
3022 if (fullPathTmp.size() > 0) {
3023 if (fullPathTmp.at(fullPathTmp.size()-1).GetTransform () == pPVModel->
GetTransformation ()) {
3024 sameTransform =
true;
3026 sameTransform =
false;
3032 if (sameTransform ==
true) {
3039 if (currentIndexInTreeSceneHandler == (fullPath.size()-1)) {
3041 parentItemList.at(i)->setText(2,QString::number(currentPVPOIndex));
3042 parentItemList.at(i)->setData(0, Qt::UserRole,currentPVPOIndex);
3044 fTreeItemModels.insert(std::pair <int, PVPath >(currentPVPOIndex,fullPath) );
3048 parentItemList.at(i)->setFont (0,f);
3051 parentItemList.at(i)->setForeground (0,QBrush());
3054 parentItemList.at(i)->setToolTip (0,
"");
3056 changeQColorForTreeWidgetItem(parentItemList.at(i),QColor((
int)(color.
GetRed()*255),
3063 parentItemList.at(i)->setCheckState(0,Qt::Checked);
3064 updatePositivePoIndexSceneTreeWidgetQuickMap(currentPVPOIndex,parentItemList.at(i));
3068 subItem = parentItemList.at(i);
3072 }
else if (currentIndexInTreeSceneHandler < (fullPath.size()-1)) {
3073 subItem = parentItemList.at(i);
3080 if (currentIndexInTreeSceneHandler == (fullPath.size()-1)) {
3081 createTreeWidgetItem(fullPath,
3082 QString(currentPVName.c_str()),
3085 QString(fullPath.at(fullPathIndex).GetPhysicalVolume()->GetLogicalVolume()->GetName().data()),
3090 if (currentPVPOIndex > fMaxPOindexInserted) {
3091 fMaxPOindexInserted = currentPVPOIndex;
3097 if (subItem == NULL) {
3099 if (currentIndexInTreeSceneHandler < (fullPath.size()-1)) {
3100 subItem = createTreeWidgetItem(fullPath,
3101 QString(currentPVName.c_str()),
3104 QString(fullPath.at(fullPathIndex).GetPhysicalVolume()->GetLogicalVolume()->GetName().data()),
3111 return parseAndInsertInSceneTree(subItem,pPVModel,fullPathIndex+1,parentRoot,currentIndexInTreeSceneHandler+1,currentPVPOIndex);
3117 void G4OpenGLQtViewer::changeOpenCloseVisibleHiddenSelectedColorSceneTreeElement(
3118 QTreeWidgetItem* subItem
3122 QTreeWidgetItem* oldItem = NULL;
3124 QTreeWidgetItem* foundItem = getOldTreeWidgetItem(subItem->data(0,Qt::UserRole).toInt());
3126 if (foundItem != NULL) {
3127 if (isSameSceneTreeElement(foundItem,subItem)) {
3128 oldItem = foundItem;
3131 if (foundItem == NULL) {
3134 std::map <int, QTreeWidgetItem*>::const_iterator i;
3135 i = fOldPositivePoIndexSceneTreeWidgetQuickMap.begin();
3136 while (i != fOldPositivePoIndexSceneTreeWidgetQuickMap.end()) {
3137 if (isSameSceneTreeElement(i->second,subItem)) {
3138 oldItem = i->second;
3139 i = fOldPositivePoIndexSceneTreeWidgetQuickMap.end();
3145 if (oldItem == NULL) {
3147 while (a < fOldNullPoIndexSceneTreeWidgetQuickVector.size()) {
3148 if (isSameSceneTreeElement(fOldNullPoIndexSceneTreeWidgetQuickVector[a],subItem)) {
3149 oldItem = fOldNullPoIndexSceneTreeWidgetQuickVector[
a];
3150 a = fOldNullPoIndexSceneTreeWidgetQuickVector.size();
3159 if (oldItem != NULL) {
3160 subItem->setFlags(oldItem->flags());
3161 subItem->setCheckState(0,oldItem->checkState(0));
3162 subItem->setSelected(oldItem->isSelected());
3163 subItem->setExpanded(oldItem->isExpanded ());
3168 std::map <int, QTreeWidgetItem* >::iterator it;
3171 int oldPOIndex = oldItem->data(0,Qt::UserRole).toInt();
3172 it = fOldPositivePoIndexSceneTreeWidgetQuickMap.find(oldPOIndex);
3176 std::map <int, QColor >::iterator itVis;
3177 itVis = fOldVisAttrColorMap.find(oldPOIndex);
3179 QColor oldVisAttrColor;
3180 const QColor& newVisAttrColor = subItem->data(2,Qt::UserRole).value<QColor>();
3182 bool visAttrChange =
false;
3184 if (itVis != fOldVisAttrColorMap.end()) {
3185 oldVisAttrColor = itVis->second;
3186 if (oldVisAttrColor != newVisAttrColor) {
3187 visAttrChange =
true;
3190 visAttrChange =
true;
3193 if (visAttrChange) {
3194 fOldVisAttrColorMap.insert(std::pair <int, QColor > (subItem->data(0,Qt::UserRole).toInt(),newVisAttrColor) );
3198 if (it != fOldPositivePoIndexSceneTreeWidgetQuickMap.end()) {
3199 color = (it->second)->
data(2,Qt::UserRole).value<QColor>();
3201 color = oldItem->data(2,Qt::UserRole).value<QColor>();
3203 changeQColorForTreeWidgetItem(subItem,color);
3215 bool G4OpenGLQtViewer::isSameSceneTreeElement(
3216 QTreeWidgetItem* parentOldItem
3217 ,QTreeWidgetItem* parentNewItem
3223 int newCpNumber = -1;
3224 int oldCpNumber = -1;
3226 bool firstWhile =
true;
3228 while ((parentOldItem != NULL) && (parentNewItem != NULL)) {
3232 oldPO = parentOldItem->data(0,Qt::UserRole).toInt();
3233 newPO = parentNewItem->data(0,Qt::UserRole).toInt();
3239 const PVPath& oldFullPath = fOldTreeItemModels[oldPO];
3240 const PVPath& newFullPath = fTreeItemModels[newPO];
3241 if ((oldFullPath.size() > 0) &&
3242 (newFullPath.size() > 0)) {
3243 if (oldFullPath.size() != newFullPath.size()) {
3246 if (oldFullPath.at(oldFullPath.size()-1).GetTransform () == newFullPath.at(newFullPath.size()-1).GetTransform ()) {
3247 newCpNumber = newFullPath.at(newFullPath.size()-1).GetCopyNo();
3248 oldCpNumber = oldFullPath.at(oldFullPath.size()-1).GetCopyNo();
3257 if (oldCpNumber == -1) {
3258 oldCpNumber = parentOldItem->data(1,Qt::UserRole).toInt();
3260 if (newCpNumber == -1) {
3261 newCpNumber = parentNewItem->data(1,Qt::UserRole).toInt();
3263 if ((oldCpNumber != newCpNumber) ||
3265 (parentOldItem->text(0) != parentNewItem->text(0)) ) {
3268 }
else if ((parentOldItem->text(0) != parentNewItem->text(0)) ||
3269 (parentOldItem->text(3) != parentNewItem->text(3))) {
3272 parentOldItem = parentOldItem->parent();
3273 parentNewItem = parentNewItem->parent();
3281 void G4OpenGLQtViewer::addNonPVSceneTreeElement(
3284 ,
const std::string& modelDescription
3288 QString modelShortName = getModelShortName(model);
3293 const G4Text& g4Text =
dynamic_cast<const G4Text&
>(visible);
3294 color = fSceneHandler.GetTextColour(g4Text);
3296 catch (
const std::bad_cast&) {
3299 if (modelShortName ==
"") {
3303 if (fSceneTreeComponentTreeWidget == NULL) {
3304 createSceneTreeComponent();
3308 if (fSceneTreeComponentTreeWidget == NULL) {
3312 fSceneTreeComponentTreeWidget->blockSignals(
true);
3316 QList<QTreeWidgetItem *> resItem;
3317 resItem = fSceneTreeComponentTreeWidget->findItems (modelShortName, Qt::MatchExactly, 0 );
3318 QTreeWidgetItem * currentItem = NULL;
3319 const PVPath tmpFullPath;
3321 if (resItem.empty()) {
3322 currentItem = createTreeWidgetItem(tmpFullPath,
3331 currentItem = resItem.first();
3335 const QList<QTreeWidgetItem *>&
3336 resItems = fSceneTreeComponentTreeWidget->findItems (QString(modelDescription.c_str()), Qt::MatchFixedString| Qt::MatchCaseSensitive|Qt::MatchRecursive, 0 );
3338 bool alreadyPresent =
false;
3339 for (
int i = 0; i < resItems.size(); ++i) {
3340 if (currentPOIndex == resItems.at(i)->data(0,Qt::UserRole).toInt()) {
3341 alreadyPresent =
true;
3344 if (!alreadyPresent) {
3345 createTreeWidgetItem(tmpFullPath,
3346 QString(modelDescription.c_str()),
3354 fSceneTreeComponentTreeWidget->blockSignals(
false);
3362 QString G4OpenGLQtViewer::getModelShortName(
const G4String& model) {
3364 QString modelShortName = model.
data();
3365 if (modelShortName.mid(0,modelShortName.indexOf(
" ")) ==
"G4PhysicalVolumeModel") {
3366 modelShortName = fTouchableVolumes;
3368 if (modelShortName.mid(0,2) ==
"G4") {
3369 modelShortName = modelShortName.mid(2);
3371 if (modelShortName.indexOf(
"Model") != -1) {
3372 modelShortName = modelShortName.mid(0,modelShortName.indexOf(
"Model"));
3375 return modelShortName;
3380 bool G4OpenGLQtViewer::isTouchableVisible(
int POindex){
3383 if (fSceneTreeComponentTreeWidget == NULL) {
3389 if (fLastSceneTreeWidgetAskForIterator != fLastSceneTreeWidgetAskForIteratorEnd) {
3390 fLastSceneTreeWidgetAskForIterator++;
3392 QTreeWidgetItem* item = getTreeWidgetItem(POindex);
3395 if ( item->checkState(0) == Qt::Checked) {
3403 bool G4OpenGLQtViewer::parseAndCheckVisibility(QTreeWidgetItem * treeNode,
int POindex){
3404 bool isFound =
false;
3405 for (
int i = 0; i < treeNode->childCount() ; ++i) {
3407 if (treeNode->child(i)->data(0,Qt::UserRole).toInt() == POindex) {
3408 if (treeNode->child(i)->checkState(0) == Qt::Checked) {
3412 isFound = parseAndCheckVisibility(treeNode->child(i),POindex);
3421 std::string G4OpenGLQtViewer::parseSceneTreeAndSaveState(){
3422 std::string commandLine =
"";
3423 for (
int b=0;b<fSceneTreeComponentTreeWidget->topLevelItemCount();b++) {
3424 commandLine += parseSceneTreeElementAndSaveState(fSceneTreeComponentTreeWidget->topLevelItem(b),1)+
"\n";
3426 if (commandLine !=
"") {
3427 commandLine = std::string(
"# Disable auto refresh and quieten vis messages whilst scene and\n") +
3428 "# trajectories are established:\n" +
3429 "/vis/viewer/set/autoRefresh false\n" +
3430 "/vis/verbose errors" +
3432 "# Re-establish auto refreshing and verbosity:\n" +
3433 "/vis/viewer/set/autoRefresh true\n" +
3434 "/vis/verbose confirmations\n";
3440 std::string G4OpenGLQtViewer::parseSceneTreeElementAndSaveState(QTreeWidgetItem* item,
unsigned int level){
3442 std::string str( level,
' ' );
3443 std::string commandLine =
"\n#"+ str +
"PV Name: " + item->text(0).toStdString();
3445 if (item->text(3) !=
"") {
3446 commandLine +=
" LV Name: "+item->text(3).toStdString()+
"\n";
3448 commandLine +=
"/vis/geometry/set/visibility " + item->text(3).toStdString() +
" ! ";
3449 if (item->checkState(0) == Qt::Checked) {
3452 if (item->checkState(0) == Qt::Unchecked) {
3458 const QColor& c = item->data(2,Qt::UserRole).value<QColor>();
3459 std::stringstream
red;
3460 red << ((double)c.red())/255;
3461 std::stringstream green;
3462 green << (double)c.green()/255;
3463 std::stringstream
blue;
3464 blue << ((double)c.blue())/255;
3465 std::stringstream
alpha;
3466 alpha << ((double)c.alpha())/255;
3468 commandLine +=
"/vis/geometry/set/colour " + item->text(3).toStdString() +
" ! " + red.str() +
" " + green.str() +
" " + blue.str() +
" " + alpha.str()+
"\n";
3471 commandLine +=
"\n";
3475 for (
int b=0;b< item->childCount();b++) {
3476 commandLine += parseSceneTreeElementAndSaveState(item->child(b),level+1);
3483 void G4OpenGLQtViewer::sceneTreeComponentItemChanged(QTreeWidgetItem* item,
int) {
3485 if (fCheckSceneTreeComponentSignalLock ==
false) {
3486 fCheckSceneTreeComponentSignalLock =
true;
3488 if (item->checkState(0) == Qt::Checked) {
3491 setCheckComponent(item,checked);
3494 fCheckSceneTreeComponentSignalLock =
false;
3499 void G4OpenGLQtViewer::sceneTreeComponentSelected() {
3502 void G4OpenGLQtViewer::changeDepthInSceneTree (
int val){
3505 if (fSceneTreeComponentTreeWidget == NULL) {
3516 double depth = 1 + ((double)val)/1000 * ((double)fSceneTreeDepth+1);
3519 fCheckSceneTreeComponentSignalLock =
true;
3522 G4bool currentAutoRefresh = fVP.IsAutoRefresh();
3523 fVP.SetAutoRefresh(
false);
3525 for (
int b=0;b<fSceneTreeComponentTreeWidget->topLevelItemCount();b++) {
3526 changeDepthOnSceneTreeItem(depth,1.,fSceneTreeComponentTreeWidget->topLevelItem(b));
3530 fVP.SetAutoRefresh(currentAutoRefresh);
3534 fCheckSceneTreeComponentSignalLock =
false;
3539 void G4OpenGLQtViewer::changeColorAndTransparency(QTreeWidgetItem* item,
int) {
3544 const QColor& old = QColor(item->data(2,Qt::UserRole).value<QColor>());
3546 #if QT_VERSION < 0x040500
3548 const QColor& color = QColor(QColorDialog::getRgba (old.rgba(),&
a,fSceneTreeComponentTreeWidget));
3550 const QColor& color = QColorDialog::getColor(old,
3551 fSceneTreeComponentTreeWidget,
3552 " Get color and transparency",
3553 QColorDialog::ShowAlphaChannel);
3556 if (color.isValid()) {
3558 changeColorAndTransparency(item->data(0,Qt::UserRole).toInt(),
3565 changeQColorForTreeWidgetItem(item,color);
3570 void G4OpenGLQtViewer::changeColorAndTransparency(GLuint index,
G4Color color) {
3574 if (iPO >= 0 && fTreeItemModels.find(iPO) != fTreeItemModels.end()) {
3575 const PVPath& fullPath = fTreeItemModels[iPO];
3577 if (fullPath.size()) {
3578 SetTouchable(fullPath);
3579 TouchableSetColour(fullPath, color);
3580 fMouseOnSceneTree =
true;
3586 G4Colour G4OpenGLQtViewer::getColorForPoIndex(
int poIndex) {
3588 QTreeWidgetItem* item = getTreeWidgetItem(poIndex);
3592 const QColor& color = item->data(2,Qt::UserRole).value<QColor>();
3605 G4OpenGLQtViewer::GetPrivateVisAttributesModifiers()
const
3607 static std::vector<G4ModelingParameters::VisAttributesModifier>
3608 privateVisAttributesModifiers;
3610 privateVisAttributesModifiers.clear();
3663 return &privateVisAttributesModifiers;
3667 void G4OpenGLQtViewer::changeSearchSelection()
3669 const QString& searchText = fFilterOutput->text();
3670 if (fSceneTreeComponentTreeWidget == NULL) {
3675 for (
int a=0; a<fSceneTreeComponentTreeWidget->topLevelItemCount(); a++) {
3676 fSceneTreeComponentTreeWidget->topLevelItem(a)->setExpanded(
false);
3677 fSceneTreeComponentTreeWidget->topLevelItem(a)->setSelected(
false);
3678 clearSceneTreeSelection(fSceneTreeComponentTreeWidget->topLevelItem(a));
3681 QList<QTreeWidgetItem *> itemList = fSceneTreeComponentTreeWidget->findItems (searchText,Qt::MatchContains | Qt::MatchRecursive,0);
3683 for (
int i = 0; i < itemList.size(); ++i) {
3684 QTreeWidgetItem* expandParentItem = itemList.at(i);
3685 while (expandParentItem->parent() != NULL) {
3686 expandParentItem->parent()->setExpanded(
true);
3687 expandParentItem = expandParentItem->parent();
3689 itemList.at(i)->setSelected(
true);
3695 void G4OpenGLQtViewer::clearSceneTreeSelection(QTreeWidgetItem* item) {
3696 for (
int a=0; a<item->childCount(); a++) {
3697 item->child(a)->setSelected(
false);
3698 item->child(a)->setExpanded(
false);
3699 clearSceneTreeSelection(item->child(a));
3705 bool G4OpenGLQtViewer::isPVVolume(QTreeWidgetItem* item) {
3706 QTreeWidgetItem* sParent = item;
3707 while (sParent->parent() != NULL) {
3708 sParent = sParent->parent();
3710 if (sParent->text(0) != fTouchableVolumes) {
3714 if (item->text(0) == fTouchableVolumes) {
3721 void G4OpenGLQtViewer::changeDepthOnSceneTreeItem(
3723 ,
double currentDepth
3724 ,QTreeWidgetItem* item
3726 double transparencyLevel = 0.;
3731 if (isPVVolume(item)) {
3732 if ((lookForDepth-currentDepth) < 0) {
3733 item->setCheckState(0,Qt::Checked);
3734 updatePositivePoIndexSceneTreeWidgetQuickMap(item->data(0,Qt::UserRole).toInt(),item);
3735 transparencyLevel = 1;
3736 }
else if ((lookForDepth-currentDepth) > 1 ){
3737 item->setCheckState(0,Qt::Unchecked);
3738 updatePositivePoIndexSceneTreeWidgetQuickMap(item->data(0,Qt::UserRole).toInt(),item);
3739 transparencyLevel = 0;
3741 item->setCheckState(0,Qt::Checked);
3742 updatePositivePoIndexSceneTreeWidgetQuickMap(item->data(0,Qt::UserRole).toInt(),item);
3743 transparencyLevel = 1-(lookForDepth-currentDepth);
3747 if (item->data(0,Qt::UserRole).toInt() >= 0) {
3748 const G4Colour& color = getColorForPoIndex(item->data(0,Qt::UserRole).toInt());
3760 if (((color.
GetAlpha()-transparencyLevel) > 0.000001) ||
3761 ((color.
GetAlpha()-transparencyLevel) < -0.000001)) {
3762 if ((item->text(3) !=
"")) {
3768 changeQColorForTreeWidgetItem(item,QColor((
int)(color.
GetRed()*255),
3771 (
int)(transparencyLevel*255)));
3776 for (
int b=0;b< item->childCount();b++) {
3777 changeDepthOnSceneTreeItem(lookForDepth,currentDepth+1,item->child(b));
3782 void G4OpenGLQtViewer::clearTreeWidget(){
3785 if (fSceneTreeComponentTreeWidget) {
3787 if (fSceneTreeComponentTreeWidget->topLevelItemCount () > 0) {
3789 fPVRootNodeCreate =
false;
3792 fOldPositivePoIndexSceneTreeWidgetQuickMap.clear();
3793 fOldNullPoIndexSceneTreeWidgetQuickVector.clear();
3794 fOldTreeItemModels.clear();
3797 for (
int b =0; b <fSceneTreeComponentTreeWidget->topLevelItemCount();b++) {
3806 int poIndex = fSceneTreeComponentTreeWidget->topLevelItem(b)->data(0,Qt::UserRole).toInt();
3807 if (poIndex != -1) {
3808 fOldPositivePoIndexSceneTreeWidgetQuickMap.insert(std::pair <int, QTreeWidgetItem*> (poIndex,cloneWidgetItem(fSceneTreeComponentTreeWidget->topLevelItem(b))));
3810 fOldNullPoIndexSceneTreeWidgetQuickVector.push_back(cloneWidgetItem(fSceneTreeComponentTreeWidget->topLevelItem(b)));
3814 cloneSceneTree(fSceneTreeComponentTreeWidget->topLevelItem(b));
3818 fOldTreeItemModels.insert(fTreeItemModels.begin(), fTreeItemModels.end());
3821 int tmp2 = fSceneTreeComponentTreeWidget->topLevelItemCount();
3823 delete fSceneTreeComponentTreeWidget->takeTopLevelItem (0);
3824 tmp2 = fSceneTreeComponentTreeWidget->topLevelItemCount();
3826 fPositivePoIndexSceneTreeWidgetQuickMap.clear();
3829 fOldLastSceneTreeWidgetAskForIterator = fOldPositivePoIndexSceneTreeWidgetQuickMap.begin();
3830 fOldLastSceneTreeWidgetAskForIteratorEnd = fOldPositivePoIndexSceneTreeWidgetQuickMap.end();
3831 fSceneTreeDepth = 1;
3832 fModelShortNameItem = NULL;
3833 fMaxPOindexInserted = -1;
3846 QTreeWidgetItem * G4OpenGLQtViewer::cloneWidgetItem(QTreeWidgetItem* item) {
3848 QTreeWidgetItem* cloneItem =
new QTreeWidgetItem();
3852 cloneItem->setText(0,item->text(0));
3853 cloneItem->setData(1,Qt::UserRole,item->data(1,Qt::UserRole).toInt());
3854 cloneItem->setText(2,item->text(2));
3855 cloneItem->setData(0, Qt::UserRole,item->data(0,Qt::UserRole).toInt());
3856 cloneItem->setText(3,item->text(3));
3857 cloneItem->setFlags(item->flags());
3858 cloneItem->setToolTip(0,item->toolTip(0));
3859 cloneItem->setCheckState(0,item->checkState(0));
3860 cloneItem->setSelected(item->isSelected());
3861 cloneItem->setExpanded(item->isExpanded ());
3863 cloneItem->setData(2,Qt::UserRole,item->data(2,Qt::UserRole).value<QColor>());
3872 void G4OpenGLQtViewer::cloneSceneTree(
3873 QTreeWidgetItem* rootItem
3876 for (
int b=0;b< rootItem->childCount();b++) {
3878 QTreeWidgetItem *child = rootItem->child(b);
3881 int poIndex = child->data(0,Qt::UserRole).toInt();
3882 if (poIndex != -1) {
3883 fOldPositivePoIndexSceneTreeWidgetQuickMap.insert(std::pair <int, QTreeWidgetItem*> (poIndex,cloneWidgetItem(child)));
3885 fOldNullPoIndexSceneTreeWidgetQuickVector.push_back(cloneWidgetItem(child));
3887 cloneSceneTree(child);
3895 void G4OpenGLQtViewer::updatePositivePoIndexSceneTreeWidgetQuickMap(
int POindex,QTreeWidgetItem* item) {
3898 std::map <int, QTreeWidgetItem*>::iterator i;
3899 i = fPositivePoIndexSceneTreeWidgetQuickMap.find(POindex);
3901 if (i == fPositivePoIndexSceneTreeWidgetQuickMap.end()) {
3902 fPositivePoIndexSceneTreeWidgetQuickMap.insert(std::pair <int, QTreeWidgetItem*> (POindex,item) );
3903 fLastSceneTreeWidgetAskForIterator = fPositivePoIndexSceneTreeWidgetQuickMap.end();
3904 fLastSceneTreeWidgetAskForIteratorEnd = fPositivePoIndexSceneTreeWidgetQuickMap.end();
3912 void G4OpenGLQtViewer::changeQColorForTreeWidgetItem(QTreeWidgetItem* item,
const QColor& qc) {
3914 int POIndex = item->data(0,Qt::UserRole).toInt();
3915 updatePositivePoIndexSceneTreeWidgetQuickMap(POIndex,item );
3917 QPixmap pixmap = QPixmap(QSize(16, 16));
3918 if (item->data(0,Qt::UserRole).toInt() != -1) {
3921 pixmap.fill (QColor(255,255,255,255));
3923 QPainter painter(&pixmap);
3924 painter.setPen(Qt::black);
3925 painter.drawRect(0,0,15,15);
3927 item->setIcon(0,pixmap);
3928 item->setData(2,Qt::UserRole,qc);
3937 QTreeWidgetItem* G4OpenGLQtViewer::getTreeWidgetItem(
int POindex){
3940 if (POindex == -1) {
3944 if (fPositivePoIndexSceneTreeWidgetQuickMap.size() == 0){
3948 if (fLastSceneTreeWidgetAskForIterator != fLastSceneTreeWidgetAskForIteratorEnd) {
3949 if (POindex == fLastSceneTreeWidgetAskForIterator->first) {
3950 if (fLastSceneTreeWidgetAskForIterator->second != NULL) {
3951 return fLastSceneTreeWidgetAskForIterator->second;
3957 fLastSceneTreeWidgetAskForIterator = fPositivePoIndexSceneTreeWidgetQuickMap.find(POindex);
3958 fLastSceneTreeWidgetAskForIteratorEnd = fPositivePoIndexSceneTreeWidgetQuickMap.end();
3960 if (fLastSceneTreeWidgetAskForIterator != fPositivePoIndexSceneTreeWidgetQuickMap.end()) {
3961 return fLastSceneTreeWidgetAskForIterator->second;
3970 QTreeWidgetItem* G4OpenGLQtViewer::getOldTreeWidgetItem(
int POindex){
3974 if (POindex == -1) {
3978 if (fOldPositivePoIndexSceneTreeWidgetQuickMap.size() == 0){
3984 if (fOldLastSceneTreeWidgetAskForIterator != fOldLastSceneTreeWidgetAskForIteratorEnd) {
3985 fOldLastSceneTreeWidgetAskForIterator++;
3988 if (fOldLastSceneTreeWidgetAskForIterator != fOldPositivePoIndexSceneTreeWidgetQuickMap.end()) {
3989 if (POindex == fOldLastSceneTreeWidgetAskForIterator->first) {
3990 if (fOldLastSceneTreeWidgetAskForIterator->second != NULL) {
3991 return fOldLastSceneTreeWidgetAskForIterator->second;
3997 fOldLastSceneTreeWidgetAskForIterator = fOldPositivePoIndexSceneTreeWidgetQuickMap.find(POindex);
3998 fOldLastSceneTreeWidgetAskForIteratorEnd = fOldPositivePoIndexSceneTreeWidgetQuickMap.end();
4000 if (fOldLastSceneTreeWidgetAskForIterator != fOldPositivePoIndexSceneTreeWidgetQuickMap.end()) {
4001 return fOldLastSceneTreeWidgetAskForIterator->second;
4012 void G4OpenGLQtViewer::displaySceneTreeComponent() {
4014 if (fUISceneTreeWidget == NULL) {
4017 if (fSceneTreeComponentTreeWidget == NULL) {
4022 fSceneTreeComponentTreeWidget->sortItems (0, Qt::AscendingOrder );
4034 void G4OpenGLQtViewer::updateToolbarAndMouseContextMenu(){
4040 d_style = fVP.GetDrawingStyle();
4044 if (fUiQt) fUiQt->SetIconWireframeSelected();
4046 fDrawingWireframe->setChecked(
true);
4047 fDrawingLineRemoval->setChecked(
false);
4048 fDrawingSurfaceRemoval->setChecked(
false);
4049 fDrawingLineSurfaceRemoval->setChecked(
false);
4052 if (fUiQt) fUiQt->SetIconHLRSelected();
4054 fDrawingLineRemoval->setChecked(
true);
4055 fDrawingWireframe->setChecked(
false);
4056 fDrawingSurfaceRemoval->setChecked(
false);
4057 fDrawingLineSurfaceRemoval->setChecked(
false);
4060 if (fUiQt) fUiQt->SetIconSolidSelected();
4062 fDrawingSurfaceRemoval->setChecked(
true);
4063 fDrawingWireframe->setChecked(
false);
4064 fDrawingLineRemoval->setChecked(
false);
4065 fDrawingLineSurfaceRemoval->setChecked(
false);
4068 if (fUiQt) fUiQt->SetIconHLHSRSelected();
4070 fDrawingLineSurfaceRemoval->setChecked(
true);
4071 fDrawingWireframe->setChecked(
false);
4072 fDrawingLineRemoval->setChecked(
false);
4073 fDrawingSurfaceRemoval->setChecked(
false);
4074 fDrawingLineSurfaceRemoval->setChecked(
false);
4080 G4double d_proj = fVP.GetFieldHalfAngle () ;
4082 if (fUiQt) fUiQt->SetIconOrthoSelected();
4084 fProjectionOrtho->setChecked(
true);
4085 fProjectionPerspective->setChecked(
false);
4088 if (fUiQt) fUiQt->SetIconPerspectiveSelected();
4090 fProjectionPerspective->setChecked(
true);
4091 fProjectionOrtho->setChecked(
false);
4097 if (fUiQt && fContextMenu) {
4098 if (fUiQt->IsIconPickSelected()) {
4099 fMousePickAction->setChecked(
true);
4100 fMouseZoomOutAction->setChecked(
false);
4101 fMouseZoomInAction->setChecked(
false);
4102 fMouseRotateAction->setChecked(
false);
4103 fMouseMoveAction->setChecked(
false);
4104 }
else if (fUiQt->IsIconZoomOutSelected()) {
4105 fMouseZoomOutAction->setChecked(
true);
4106 fMousePickAction->setChecked(
false);
4107 fMouseZoomInAction->setChecked(
false);
4108 fMouseRotateAction->setChecked(
false);
4109 fMouseMoveAction->setChecked(
false);
4110 }
else if (fUiQt->IsIconZoomInSelected()) {
4111 fMouseZoomInAction->setChecked(
true);
4112 fMousePickAction->setChecked(
false);
4113 fMouseZoomOutAction->setChecked(
false);
4114 fMouseRotateAction->setChecked(
false);
4115 fMouseMoveAction->setChecked(
false);
4116 }
else if (fUiQt->IsIconRotateSelected()) {
4117 fMouseRotateAction->setChecked(
true);
4118 fMousePickAction->setChecked(
false);
4119 fMouseZoomOutAction->setChecked(
false);
4120 fMouseZoomInAction->setChecked(
false);
4121 fMouseMoveAction->setChecked(
false);
4122 }
else if (fUiQt->IsIconMoveSelected()) {
4123 fMouseMoveAction->setChecked(
true);
4124 fMousePickAction->setChecked(
false);
4125 fMouseZoomOutAction->setChecked(
false);
4126 fMouseZoomInAction->setChecked(
false);
4127 fMouseRotateAction->setChecked(
false);
4135 void G4OpenGLQtViewer::updateSceneTreeWidget() {
4137 if (!fSceneTreeWidget) {
4138 createSceneTreeWidget();
4147 void G4OpenGLQtViewer::updateViewerPropertiesTableWidget() {
4149 if (!isCurrentWidget()) {
4154 if (!fViewerPropertiesTableWidget) {
4155 createViewerPropertiesWidget();
4157 int treeWidgetInfosIgnoredCommands = 0;
4167 if ((path->
GetCommandEntry()-fTreeWidgetInfosIgnoredCommands) != fViewerPropertiesTableWidget->rowCount()) {
4168 fViewerPropertiesTableWidget->clear();
4171 fViewerPropertiesTableWidget->blockSignals(
true);
4174 fViewerPropertiesTableWidget->setColumnCount (2);
4175 fViewerPropertiesTableWidget->setRowCount (path->
GetCommandEntry()-fTreeWidgetInfosIgnoredCommands);
4176 fViewerPropertiesTableWidget->setHorizontalHeaderLabels(QStringList() << tr(
"Property")
4178 fViewerPropertiesTableWidget->verticalHeader()->setVisible(
false);
4179 fViewerPropertiesTableWidget->setAlternatingRowColors (
true);
4187 QString params =
"";
4190 if (fVP.IsAutoRefresh()) {
4196 if (fVP.IsAuxEdgeVisible()) {
4202 params = QString().number(fVP.GetBackgroundColour().GetRed()) +
" "+
4203 QString().number(fVP.GetBackgroundColour().GetGreen()) +
" "+
4204 QString().number(fVP.GetBackgroundColour().GetBlue()) +
" "+
4205 QString().number(fVP.GetBackgroundColour().GetAlpha());
4208 params = QString().number(fVP. IsCulling ());
4213 params =
"intersection";
4217 params = QString().number(fVP.GetDefaultVisAttributes()->GetColor().GetRed()) +
" "+
4218 QString().number(fVP.GetDefaultVisAttributes()->GetColor().GetGreen()) +
" "+
4219 QString().number(fVP.GetDefaultVisAttributes()->GetColor().GetBlue()) +
" "+
4220 QString().number(fVP.GetDefaultVisAttributes()->GetColor().GetAlpha());
4223 params = QString().number(fVP.GetDefaultTextVisAttributes()->GetColor().GetRed()) +
" "+
4224 QString().number(fVP.GetDefaultTextVisAttributes()->GetColor().GetGreen()) +
" "+
4225 QString().number(fVP.GetDefaultTextVisAttributes()->GetColor().GetBlue()) +
" "+
4226 QString().number(fVP.GetDefaultTextVisAttributes()->GetColor().GetAlpha());
4236 params = QString().number(fVP.GetExplodeFactor()) +
" " + QString(
G4String(
G4BestUnit(fVP.GetExplodeFactor(),
"Length")).
data());
4238 }
else if(commandTmp->
GetCommandName() ==
"globalLineWidthScale") {
4239 params = QString().number(fVP.GetGlobalLineWidthScale());
4242 params = QString().number(fVP.GetGlobalMarkerScale());
4254 if (fVP.IsMarkerNotHidden()) {
4261 if (fVP.GetLightsMoveWithCamera()) {
4267 G4Vector3D direction = fVP.GetLightpointDirection();
4276 params = QString().number(fVP.GetLightpointDirection().x()) +
" "+
4277 QString().number(fVP.GetLightpointDirection().y()) +
" "+
4278 QString().number(fVP.GetLightpointDirection().z());
4280 }
else if(commandTmp->
GetCommandName() ==
"lineSegmentsPerCircle") {
4281 params = QString().number(fVP.GetNoOfSides());
4284 if (fVP.IsPicking()) {
4291 if (fVP.GetFieldHalfAngle() == 0.) {
4292 params =
"orthogonal";
4294 params = QString(
"perspective ") + QString().number(fVP.GetFieldHalfAngle()/
CLHEP::degree) +
" deg";
4299 params =
"constrainUpDirection";
4301 params =
"freeRotation";
4305 if (fVP.IsSection()) {
4306 params = QString(
"on ") +
4308 QString().number(fVP.GetSectionPlane().normal().x())
4309 +
" " + QString().number(fVP.GetSectionPlane().normal().y())
4310 +
" " + QString().number(fVP.GetSectionPlane().normal().z());
4317 params =
"wireframe";
4324 G4Point3D point = fVP.GetCurrentTargetPoint();
4325 if (fSceneHandler.GetScene()) {
4326 G4String b =
G4BestUnit(fSceneHandler.GetScene()->GetStandardTargetPoint() + fVP.GetCurrentTargetPoint(),
"Length");
4340 params = QString().number(up.
x())+
" "+ QString().number(up.
y())+
" "+QString().number(up.
z())+
" ";
4343 G4Vector3D direction = fVP.GetViewpointDirection();
4352 G4Vector3D direction = fVP.GetViewpointDirection();
4353 params = QString().number(direction.
x())+
" "+ QString().number(direction.
y())+
" "+QString().number(direction.
z());
4383 QTableWidgetItem *nameItem;
4384 QTableWidgetItem *paramItem;
4387 QList<QTableWidgetItem *> list = fViewerPropertiesTableWidget->findItems (commandTmp->
GetCommandName().
data(),Qt::MatchExactly);
4388 if (list.size() == 1) {
4389 nameItem = list.first();
4390 paramItem = fViewerPropertiesTableWidget->item(nameItem->row(),1);
4393 nameItem =
new QTableWidgetItem();
4394 paramItem =
new QTableWidgetItem();
4395 fViewerPropertiesTableWidget->setItem(a-treeWidgetInfosIgnoredCommands, 0, nameItem);
4396 fViewerPropertiesTableWidget->setItem(a-treeWidgetInfosIgnoredCommands, 1, paramItem);
4401 for(
G4int i_thGuidance=0; i_thGuidance < n_guidanceEntry; i_thGuidance++ ) {
4405 nameItem->setToolTip(guidance);
4406 paramItem->setToolTip(GetCommandParameterList(commandTmp));
4408 fViewerPropertiesTableWidget->setRowHeight(a-treeWidgetInfosIgnoredCommands,15);
4413 paramItem->setText(params);
4415 nameItem->setFlags(Qt::NoItemFlags);
4416 nameItem->setForeground(QBrush());
4419 treeWidgetInfosIgnoredCommands++;
4423 for (
int i=0; i<treeWidgetInfosIgnoredCommands; i++) {
4424 fViewerPropertiesTableWidget->removeRow (fViewerPropertiesTableWidget->rowCount() - 1);
4428 if (!fViewerPropertiesTableWidgetIsInit) {
4429 fViewerPropertiesTableWidgetIsInit =
true;
4431 fViewerPropertiesTableWidget->resizeColumnsToContents();
4433 int x = fViewerPropertiesTableWidget->horizontalHeader()->length();
4434 int y = fViewerPropertiesTableWidget->verticalHeader()->length()+ fViewerPropertiesTableWidget->horizontalHeader()->sizeHint().height() + 2;
4440 QDialog* dial =
static_cast<QDialog*
> (fUIViewerPropertiesWidget->parent());
4442 dial->resize(x+56,y+46);
4445 fViewerPropertiesTableWidget->blockSignals(
false);
4447 fTreeWidgetInfosIgnoredCommands = treeWidgetInfosIgnoredCommands;
4454 void G4OpenGLQtViewer::updatePickInfosWidget(
int aX,
int aY) {
4455 fLastPickPoint = QPoint(aX,aY);
4457 if (!isCurrentWidget()) {
4461 if (!fPickInfosWidget) {
4462 createPickInfosWidget();
4465 const std::vector < G4OpenGLViewerPickMap* > & pickMapVector = GetPickDetails(aX,aY);
4468 if (fPickInfosWidget) {
4469 QLayoutItem * wItem;
4470 if (fPickInfosWidget->layout()->count()) {
4471 while ((wItem = fPickInfosWidget->layout()->takeAt(0)) != 0) {
4472 delete wItem->widget();
4478 if (!fPickInfosWidget) {
4479 createPickInfosWidget();
4484 delete fSignalMapperPicking;
4485 fSignalMapperPicking =
new QSignalMapper(
this);
4488 G4int nPickedObjectsWithAttributes = 0;
4489 for (
unsigned int a=0; a< pickMapVector.size(); a++) {
4490 const auto& pickMap = pickMapVector[
a];
4492 std::ostringstream label;
4493 std::ostringstream content;
4494 std::string txt = pickMap->getAttributes()[0].data();
4495 if (pickMapVector[a]->getAttributes().size()) {
4496 ++nPickedObjectsWithAttributes;
4498 std::size_t pos1 = txt.find(
':');
4499 std::string storeKey = txt.substr(0,pos1);
4501 if (storeKey ==
"G4PhysicalVolumeModel") {
4504 std::size_t pos2 = txt.find(
':',pos1+1);
4505 std::size_t pos3 = txt.find(
'\n',pos2+1);
4506 label << txt.substr(pos2+1,pos3-pos2-1);
4508 }
else if (storeKey ==
"G4TrajectoriesModel") {
4510 label <<
"Trajectory:";
4511 std::size_t pos2 = txt.find(
':',pos1+1);
4512 std::size_t pos3 = txt.find(
'\n',pos2+1);
4513 label <<
" Run:" << txt.substr(pos2+1,pos3-pos2-1);
4514 std::size_t pos4 = txt.find(
':',pos3+1);
4515 std::size_t pos5 = txt.find(
'\n',pos4+1);
4516 label <<
", Event:" << txt.substr(pos4+1,pos5-pos4-1);
4520 label <<
"Hit number:" << a <<
", PickName: " << pickMap->getPickName();
4525 content << pickMap->print().data();
4526 G4int thisPickName = pickMap->getPickName();
4527 while (++a < pickMapVector.size()) {
4528 const auto& a_pickMap = pickMapVector[
a];
4529 if (a_pickMap->getPickName() == thisPickName) {
4530 content << a_pickMap->print().data();
4537 QPushButton* pickCoutButton =
new QPushButton(label.str().c_str());
4538 pickCoutButton->setStyleSheet (
"text-align: left; padding: 1px; border: 0px;");
4539 pickCoutButton->setIcon(*fTreeIconClosed);
4540 fPickInfosWidget->layout()->addWidget(pickCoutButton);
4545 newStr = QStringList(QString(content.str().c_str()).trimmed());
4547 QTextEdit* ed =
new QTextEdit();
4548 ed->setFontFamily(
"Courier");
4549 ed->setFontPointSize(12);
4550 ed->setReadOnly(
true);
4551 fPickInfosWidget->layout()->addWidget(ed);
4552 ed->setVisible((
false));
4553 ed->append(newStr.join(
""));
4555 connect(pickCoutButton, SIGNAL(clicked()), fSignalMapperPicking, SLOT(map()));
4556 fSignalMapperPicking->setMapping(pickCoutButton,fPickInfosWidget->layout()->count()-1);
4560 connect(fSignalMapperPicking, SIGNAL(mapped(
int)),
this, SLOT(toggleSceneTreeComponentPickingCout(
int)));
4563 QLabel * pushUp =
new QLabel(
"");
4564 QSizePolicy vPolicy = QSizePolicy(QSizePolicy::Minimum,QSizePolicy::Minimum);
4565 vPolicy.setVerticalStretch(10);
4566 pushUp->setSizePolicy(vPolicy);
4567 fPickInfosWidget->layout()->addWidget(pushUp);
4572 changeColorAndTransparency(fLastHighlightName,fLastHighlightColor);
4574 if (pickMapVector.size() > 0 ) {
4576 fLastHighlightName = pickMapVector[0]->getPickName();
4577 fLastHighlightColor = getColorForPoIndex(fLastHighlightName);
4579 changeColorAndTransparency(fLastHighlightName,
G4Color(1,1,1,1));
4583 QDialog* dial =
static_cast<QDialog*
> (fUIPickInfosWidget->parent());
4586 std::ostringstream oss;
4587 if (nPickedObjectsWithAttributes == 0) {
4589 }
else if (nPickedObjectsWithAttributes == 1) {
4592 oss << nPickedObjectsWithAttributes <<
" objects";
4594 oss <<
" selected - " << GetName();
4595 dial->setWindowTitle(oss.str().c_str());
4598 fPickInfosScrollArea->setVisible(
true);
4602 void G4OpenGLQtViewer::toggleSceneTreeComponentPickingCout(
int pickItem) {
4607 for (
int a=0; a<fPickInfosWidget->layout()->count(); a++) {
4608 w = fPickInfosWidget->layout()->itemAt(a)->widget();
4609 QTextEdit* ed =
dynamic_cast<QTextEdit*
>(
w);
4610 QPushButton* button;
4612 if (a == pickItem) {
4613 w->setVisible(!w->isVisible());
4615 w->setVisible(
false);
4618 button =
dynamic_cast<QPushButton*
>(fPickInfosWidget->layout()->itemAt(a-1)->widget());
4620 if (button->isVisible()) {
4621 button->setIcon(*fTreeIconOpen);
4623 button->setIcon(*fTreeIconClosed);
4632 void G4OpenGLQtViewer::currentTabActivated(
int currentTab) {
4633 if (fUiQt->GetViewerTabWidget()->tabText(currentTab) == GetName()) {
4634 createViewerPropertiesWidget();
4635 createPickInfosWidget();
4636 createSceneTreeWidget();
4641 void G4OpenGLQtViewer::tableWidgetViewerSetItemChanged(QTableWidgetItem * item) {
4644 QTableWidgetItem* previous = fViewerPropertiesTableWidget->item(fViewerPropertiesTableWidget->row(item),0);
4646 fViewerPropertiesTableWidget->blockSignals(
true);
4648 + previous->text().toStdString()
4650 + item->text().toStdString()).c_str());
4651 fViewerPropertiesTableWidget->blockSignals(
false);
4656 bool G4OpenGLQtViewer::isCurrentWidget(){
4657 G4Qt* interactorManager = G4Qt::getInstance ();
4658 if (!interactorManager->IsExternalApp()) {
4661 if ( GetName() != fUiQt->GetViewerTabWidget()->tabText(fUiQt->GetViewerTabWidget()->currentIndex()).toStdString().c_str()) {
4675 QString G4OpenGLQtViewer::GetCommandParameterList (
4682 if( n_parameterEntry > 0 ) {
4687 for(
G4int i_thParameter=0; i_thParameter<n_parameterEntry; i_thParameter++ ) {
4692 txt +=
" Parameter type : " + QString(QChar(param->
GetParameterType())) +
"\n";
4694 txt +=
" Omittable : True\n";
4696 txt +=
" Omittable : False\n";
4699 txt +=
" Default value : taken from the current value\n";
4714 #ifdef G4MULTITHREADED
4716 void G4OpenGLQtViewer::DoneWithMasterThread()
4722 if(!lWaitForVisSubThreadQtOpenGLContextInitialized->owns_lock())
4723 lWaitForVisSubThreadQtOpenGLContextInitialized->lock();
4726 void G4OpenGLQtViewer::SwitchToVisSubThread()
4730 QGLWidget* qGLW =
dynamic_cast<QGLWidget*
> (fGLWidget) ;
4736 SetQGLContextVisSubThread(QThread::currentThread());
4742 if(!lWaitForVisSubThreadQtOpenGLContextMoved->owns_lock())
4743 lWaitForVisSubThreadQtOpenGLContextMoved->lock();
4747 lWaitForVisSubThreadQtOpenGLContextMoved);
4750 qGLW->makeCurrent();
4753 void G4OpenGLQtViewer::DoneWithVisSubThread()
4756 QGLWidget* qGLW =
dynamic_cast<QGLWidget*
> (fGLWidget) ;
4762 qGLW->doneCurrent();
4764 #if QT_VERSION > 0x050000
4766 qGLW->context()->moveToThread(fQGLContextMainThread);
4770 void G4OpenGLQtViewer::SwitchToMasterThread()
4774 QGLWidget* qGLW =
dynamic_cast<QGLWidget*
> (fGLWidget) ;
4781 if(lWaitForVisSubThreadQtOpenGLContextInitialized->owns_lock())
4782 lWaitForVisSubThreadQtOpenGLContextInitialized->unlock();
4784 qGLW->makeCurrent();
4788 void G4OpenGLQtViewer::MovingToVisSubThread(){
4791 QGLWidget* qGLW =
dynamic_cast<QGLWidget*
> (fGLWidget) ;
4798 if(!lWaitForVisSubThreadQtOpenGLContextInitialized->owns_lock())
4799 lWaitForVisSubThreadQtOpenGLContextInitialized->lock();
4803 lWaitForVisSubThreadQtOpenGLContextInitialized);
4806 SetQGLContextMainThread(QThread::currentThread());
4809 qGLW->doneCurrent();
4810 #if QT_VERSION > 0x050000
4811 qGLW->context()->moveToThread(fQGLContextVisSubThread);
G4UIcommandTree * GetTree() const
G4TemplateAutoLock< G4Mutex > G4AutoLock
std::vector< ExP01TrackerHit * > a
G4UIcommandTree * FindCommandTree(const char *commandPath)
static const G4double pos
#define G4CONDITIONBROADCAST(cond)
G4int ApplyCommand(const char *aCommand)
#define G4CONDITIONWAIT(cond, mutex)
const G4String & GetGuidanceLine(G4int i) const
char GetParameterType() const
G4String GetDefaultValue() const
G4UIparameter * GetParameter(G4int i) const
static constexpr double gray
G4String GetParameterCandidates() const
G4int GetGuidanceEntries() const
G4String GetParameterRange() const
const std::vector< G4PhysicalVolumeNodeID > & GetFullPVPath() const
static G4UImanager * GetUIpointer()
const G4String & GetCommandName() const
G4double GetXOffset() const
const XML_Char const XML_Char * data
G4UIcommand * GetCommand(G4int i)
#define G4MUTEX_INITIALIZER
std::vector< G4PolyconeSideRZ > g4c
std::vector< PVNodeID > PVPath
const G4String GetParameterGuidance() const
static const G4double alpha
const char * data() const
typedef int(XMLCALL *XML_NotStandaloneHandler)(void *userData)
const G4ThreeVector const G4double const
G4GLOB_DLL std::ostream G4cerr
#define G4BestUnit(a, b)
#define G4_USE_G4BESTUNIT_FOR_VERBOSE 1
static MCTruthManager * instance
G4int GetCommandEntry() const
#define G4CONDITION_INITIALIZER
G4bool GetCurrentAsDefault() const
G4double GetAlpha() const
G4bool IsOmittable() const
G4int GetParameterEntries() const
G4GLOB_DLL std::ostream G4cout
G4double GetYOffset() const
static PROLOG_HANDLER error
G4Point3D GetPosition() const
G4double GetGreen() const
const XML_Char XML_Content * model
G4String GetParameterName() const
static constexpr double degree
const G4Transform3D & GetTransformation() const
static G4bool GetColour(const G4String &key, G4Colour &result)