36 #ifdef G4VIS_BUILD_OPENGLQT_DRIVER
64 #include <qpushbutton.h>
66 #include <qdesktopwidget.h>
69 #include <qimagewriter.h>
71 #include <qtextedit.h>
72 #include <qtreewidget.h>
73 #include <qapplication.h>
74 #include <qmessagebox.h>
75 #include <qfiledialog.h>
77 #include <qdatetime.h>
81 #include <qcolordialog.h>
84 #include <qgroupbox.h>
85 #include <qcombobox.h>
86 #include <qlineedit.h>
87 #include <qsignalmapper.h>
88 #include <qmainwindow.h>
89 #include <qtablewidget.h>
90 #include <qheaderview.h>
91 #include <qscrollarea.h>
92 #include <qsplitter.h>
93 #include <qcheckbox.h>
97 #ifdef G4MULTITHREADED
103 #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)
278 G4Qt::getInstance ();
280 fLastPos3 = QPoint(-1,-1);
281 fLastPos2 = QPoint(-1,-1);
282 fLastPos1 = QPoint(-1,-1);
284 initMovieParameters();
286 fLastEventTime =
new QTime();
287 fSignalMapperMouse =
new QSignalMapper(
this);
288 fSignalMapperSurface =
new QSignalMapper(
this);
291 fFileSavePath = QDir::currentPath();
294 QList<QByteArray> formats = QImageWriter::supportedImageFormats ();
295 for (
int i = 0; i < formats.size(); ++i) {
296 addExportImageFormat(formats.at(i).data());
299 const char *
const icon1[]={
357 const char *
const icon2[]={
450 const char *
const search[] = {
462 "OOOOOOOOOOOOOOOOOOO",
463 "OOOOOOOOOOOOOOOOOOO",
464 "OOOOOOOo. .oOOOOOO",
467 "OOOOO. XOOOOX .OOOO",
470 "OOOOO. XOOOOo .OOOO",
474 "OOOOOOOOOOOOO. XOO",
475 "OOOOOOOOOOOOOO. XOO",
476 "OOOOOOOOOOOOOOOoOOO",
477 "OOOOOOOOOOOOOOOOOOO",
478 "OOOOOOOOOOOOOOOOOOO",
479 "OOOOOOOOOOOOOOOOOOO",
480 "OOOOOOOOOOOOOOOOOOO"
483 fSearchIcon =
new QPixmap(search);
484 fTreeIconOpen =
new QPixmap(icon1);
485 fTreeIconClosed =
new QPixmap(icon2);
490 G4OpenGLQtViewer::~G4OpenGLQtViewer (
500 if (fSceneTreeWidget != NULL) {
501 if (fSceneTreeWidget->layout() != NULL) {
502 while ((wItem = fSceneTreeWidget->layout()->takeAt(0)) != 0) {
503 delete wItem->widget();
510 delete fTreeIconOpen;
511 delete fTreeIconClosed;
513 G4cout <<removeTempFolder().toStdString().c_str() <<
G4endl;
520 void G4OpenGLQtViewer::createPopupMenu() {
522 fContextMenu =
new QMenu(
"All");
524 QMenu *mMouseAction = fContextMenu->addMenu(
"&Mouse actions");
526 fMouseRotateAction = mMouseAction->addAction(
"Rotate", fSignalMapperMouse, SLOT(map()));
527 fMouseMoveAction = mMouseAction->addAction(
"Move", fSignalMapperMouse, SLOT(map()));
528 fMousePickAction = mMouseAction->addAction(
"Pick", fSignalMapperMouse, SLOT(map()));
529 fMouseZoomOutAction = mMouseAction->addAction(
"Zoom out", fSignalMapperMouse, SLOT(map()));
530 fMouseZoomInAction = mMouseAction->addAction(
"Zoom in", fSignalMapperMouse, SLOT(map()));
531 QAction *shortcutsAction = mMouseAction->addAction(
"Show shortcuts");
533 fMouseRotateAction->setCheckable(
true);
534 fMouseMoveAction->setCheckable(
true);
535 fMousePickAction->setCheckable(
true);
536 fMouseZoomOutAction->setCheckable(
true);
537 fMouseZoomInAction->setCheckable(
true);
538 shortcutsAction->setCheckable(
false);
540 connect(fSignalMapperMouse, SIGNAL(mapped(
int)),
this, SLOT(toggleMouseAction(
int)));
541 fSignalMapperMouse->setMapping(fMouseRotateAction,1);
542 fSignalMapperMouse->setMapping(fMouseMoveAction,2);
543 fSignalMapperMouse->setMapping(fMousePickAction,3);
544 fSignalMapperMouse->setMapping(fMouseZoomOutAction,4);
545 fSignalMapperMouse->setMapping(fMouseZoomInAction,5);
547 QObject::connect(shortcutsAction,
548 SIGNAL(triggered(
bool)),
550 SLOT(showShortcuts()));
553 QMenu *mStyle = fContextMenu->addMenu(
"&Style");
555 QMenu *mProjection = mStyle->addMenu(
"&Projection");
557 fProjectionOrtho = mProjection->addAction(
"Orthographic", fSignalMapperSurface, SLOT(map()));
558 fProjectionPerspective = mProjection->addAction(
"Persepective", fSignalMapperSurface, SLOT(map()));
561 if (fVP.GetFieldHalfAngle() == 0) {
562 createRadioAction(fProjectionOrtho, fProjectionPerspective,SLOT(toggleProjection(
bool)),1);
564 createRadioAction(fProjectionOrtho, fProjectionPerspective,SLOT(toggleProjection(
bool)),2);
568 QMenu *mDrawing = mStyle->addMenu(
"&Drawing");
570 fDrawingWireframe = mDrawing->addAction(
"Wireframe", fSignalMapperSurface, SLOT(map()));
572 fDrawingLineRemoval = mDrawing->addAction(
"Hidden line removal", fSignalMapperSurface, SLOT(map()));
574 fDrawingSurfaceRemoval = mDrawing->addAction(
"Hidden Surface removal", fSignalMapperSurface, SLOT(map()));
576 fDrawingLineSurfaceRemoval = mDrawing->addAction(
"Hidden line and surface removal", fSignalMapperSurface, SLOT(map()));
578 fDrawingWireframe->setCheckable(
true);
579 fDrawingLineRemoval->setCheckable(
true);
580 fDrawingSurfaceRemoval->setCheckable(
true);
581 fDrawingLineSurfaceRemoval->setCheckable(
true);
583 connect(fSignalMapperSurface, SIGNAL(mapped(
int)),
this, SLOT(toggleSurfaceAction(
int)));
584 fSignalMapperSurface->setMapping(fDrawingWireframe,1);
585 fSignalMapperSurface->setMapping(fDrawingLineRemoval,2);
586 fSignalMapperSurface->setMapping(fDrawingSurfaceRemoval,3);
587 fSignalMapperSurface->setMapping(fDrawingLineSurfaceRemoval,4);
592 QAction *backgroundColorChooser ;
594 backgroundColorChooser = mStyle->addAction(
"Background color");
595 QObject ::connect(backgroundColorChooser,
598 SLOT(actionChangeBackgroundColor()));
602 QAction *textColorChooser ;
604 textColorChooser = mStyle->addAction(
"Text color");
605 QObject ::connect(textColorChooser,
608 SLOT(actionChangeTextColor()));
612 QAction *defaultColorChooser ;
614 defaultColorChooser = mStyle->addAction(
"Default color");
615 QObject ::connect(defaultColorChooser,
618 SLOT(actionChangeDefaultColor()));
622 QMenu *mActions = fContextMenu->addMenu(
"&Actions");
623 QAction *createEPS = mActions->addAction(
"Save as ...");
624 QObject ::connect(createEPS,
627 SLOT(actionSaveImage()));
630 QAction *movieParameters = mActions->addAction(
"Save as movie...");
631 QObject ::connect(movieParameters,
634 SLOT(actionMovieParameters()));
640 QMenu *mSpecial = fContextMenu->addMenu(
"S&pecial");
641 QMenu *mTransparency = mSpecial->addMenu(
"Transparency");
642 QAction *transparencyOn = mTransparency->addAction(
"On");
643 QAction *transparencyOff = mTransparency->addAction(
"Off");
645 if (transparency_enabled ==
false) {
646 createRadioAction(transparencyOn,transparencyOff,SLOT(toggleTransparency(
bool)),2);
647 }
else if (transparency_enabled ==
true) {
648 createRadioAction(transparencyOn,transparencyOff,SLOT(toggleTransparency(
bool)),1);
654 QMenu *mAntialiasing = mSpecial->addMenu(
"Antialiasing");
655 QAction *antialiasingOn = mAntialiasing->addAction(
"On");
656 QAction *antialiasingOff = mAntialiasing->addAction(
"Off");
658 if (antialiasing_enabled ==
false) {
659 createRadioAction(antialiasingOn,antialiasingOff,SLOT(toggleAntialiasing(
bool)),2);
660 }
else if (antialiasing_enabled ==
true) {
661 createRadioAction(antialiasingOn,antialiasingOff,SLOT(toggleAntialiasing(
bool)),1);
663 mAntialiasing->clear();
666 QMenu *mHaloing = mSpecial->addMenu(
"Haloing");
667 QAction *haloingOn = mHaloing->addAction(
"On");
668 QAction *haloingOff = mHaloing->addAction(
"Off");
669 if (haloing_enabled ==
false) {
670 createRadioAction(haloingOn,haloingOff,SLOT(toggleHaloing(
bool)),2);
671 }
else if (haloing_enabled ==
true) {
672 createRadioAction(haloingOn,haloingOff,SLOT(toggleHaloing(
bool)),1);
677 QMenu *mAux = mSpecial->addMenu(
"Auxiliary edges");
678 QAction *auxOn = mAux->addAction(
"On");
679 QAction *auxOff = mAux->addAction(
"Off");
680 if (!fVP.IsAuxEdgeVisible()) {
681 createRadioAction(auxOn,auxOff,SLOT(toggleAux(
bool)),2);
683 createRadioAction(auxOn,auxOff,SLOT(toggleAux(
bool)),1);
687 QMenu *mHiddenMarkers = mSpecial->addMenu(
"Hidden markers");
688 QAction *hiddenMarkersOn = mHiddenMarkers->addAction(
"On");
689 QAction *hiddenMarkersOff = mHiddenMarkers->addAction(
"Off");
690 if (fVP.IsMarkerNotHidden()) {
691 createRadioAction(hiddenMarkersOn,hiddenMarkersOff,SLOT(toggleHiddenMarkers(
bool)),2);
693 createRadioAction(hiddenMarkersOn,hiddenMarkersOff,SLOT(toggleHiddenMarkers(
bool)),1);
698 QMenu *mFullScreen = mSpecial->addMenu(
"&Full screen");
699 fFullScreenOn = mFullScreen->addAction(
"On");
700 fFullScreenOff = mFullScreen->addAction(
"Off");
701 createRadioAction(fFullScreenOn,fFullScreenOff,SLOT(toggleFullScreen(
bool)),2);
704 updateToolbarAndMouseContextMenu();
707 void G4OpenGLQtViewer::G4manageContextMenuEvent(QContextMenuEvent *e)
710 G4cerr <<
"Visualization window not defined, please choose one before" <<
G4endl;
717 if ( fContextMenu ) {
718 fContextMenu->exec( e->globalPos() );
734 void G4OpenGLQtViewer::createRadioAction(QAction *action1,QAction *action2,
const std::string& method,
unsigned int nCheck) {
736 action1->setCheckable(
true);
737 action2->setCheckable(
true);
740 action1->setChecked (
true);
742 action2->setChecked (
true);
744 QObject ::connect(action1, SIGNAL(triggered(
bool)),action2, SLOT(toggle()));
745 QObject ::connect(action2, SIGNAL(triggered(
bool)),action1, SLOT(toggle()));
747 QObject ::connect(action1, SIGNAL(toggled(
bool)),
this, method.c_str());
756 void G4OpenGLQtViewer::showShortcuts() {
759 text =
"========= Mouse Shortcuts =========\n";
761 if (fUiQt->IsIconRotateSelected()) {
762 text +=
"Click and move mouse to rotate volume \n";
763 text +=
"ALT + Click and move mouse to rotate volume (Toggle View/Theta-Phi Direction) \n";
764 text +=
"CTRL + Click and move mouse to zoom in/out \n";
765 text +=
"SHIFT + Click and move mouse to change camera point of view \n";
766 }
else if (fUiQt->IsIconMoveSelected()) {
767 text +=
"Move camera point of view with mouse \n";
768 }
else if (fUiQt->IsIconPickSelected()) {
769 text +=
"Click and pick \n";
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 zoom mouse to zoom in/out \n";
775 text +=
"SHIFT + Click and zoommove camera point of view \n";
777 text +=
"========= Move Shortcuts ========= \n";
778 text +=
"Press left/right arrows to move volume left/right \n";
779 text +=
"Press up/down arrows to move volume up/down \n";
780 text +=
"Press '+'/'-' to move volume toward/forward \n";
782 text +=
"========= Rotation (Theta/Phi) Shortcuts ========= \n";
783 text +=
"Press SHIFT + left/right arrows to rotate volume left/right \n";
784 text +=
"Press SHIFT + up/down arrows to rotate volume up/down \n";
786 text +=
"========= Rotation (View Direction) Shortcuts ========= \n";
787 text +=
"Press ALT + left/right to rotate volume around vertical direction \n";
788 text +=
"Press ALT + up/down to rotate volume around horizontal direction \n";
790 text +=
"========= Zoom View ========= \n";
791 text +=
"Press CTRL + '+'/'-' to zoom into volume \n";
793 text +=
"========= Misc ========= \n";
794 text +=
"Press ALT +/- to slow/speed rotation/move \n";
795 text +=
"Press H to reset view \n";
796 text +=
"Press Esc to exit FullScreen \n";
798 text +=
"========= Video ========= \n";
799 text +=
"In video mode : \n";
800 text +=
" Press SPACE to Start/Pause video recording \n";
801 text +=
" Press RETURN to Stop video recording \n";
806 if ( fShortcutsDialog == NULL) {
807 fShortcutsDialog =
new QDialog();
808 fShortcutsDialogInfos =
new QTextEdit() ;
809 QVBoxLayout *mainLayout =
new QVBoxLayout;
810 mainLayout->addWidget(fShortcutsDialogInfos);
811 fShortcutsDialog->setLayout(mainLayout);
812 fShortcutsDialog->setWindowTitle(tr(
"Shortcuts"));
815 fShortcutsDialogInfos->setPlainText(text.data());
816 fShortcutsDialog->show();
827 void G4OpenGLQtViewer::toggleMouseAction(
int aAction) {
830 fUiQt->SetIconRotateSelected();
831 }
else if (aAction == 2) {
832 fUiQt->SetIconMoveSelected();
833 }
else if (aAction == 3) {
835 }
else if (aAction == 4) {
836 fUiQt->SetIconZoomOutSelected();
837 }
else if (aAction == 5) {
838 fUiQt->SetIconZoomInSelected();
842 updateToolbarAndMouseContextMenu();
856 void G4OpenGLQtViewer::toggleSurfaceAction(
int aAction) {
863 }
else if (aAction ==2) {
866 }
else if (aAction ==3) {
869 }
else if (aAction ==4) {
872 fVP.SetDrawingStyle(d_style);
874 updateToolbarAndMouseContextMenu();
889 void G4OpenGLQtViewer::toggleProjection(
bool check) {
892 fVP.SetOrthogonalProjection ();
894 fVP.SetPerspectiveProjection();
896 updateToolbarAndMouseContextMenu();
905 void G4OpenGLQtViewer::toggleTransparency(
bool check) {
908 transparency_enabled =
true;
910 transparency_enabled =
false;
912 SetNeedKernelVisit (
true);
913 updateToolbarAndMouseContextMenu();
921 void G4OpenGLQtViewer::toggleAntialiasing(
bool check) {
924 antialiasing_enabled =
false;
925 glDisable (GL_LINE_SMOOTH);
926 glDisable (GL_POLYGON_SMOOTH);
928 antialiasing_enabled =
true;
929 glEnable (GL_LINE_SMOOTH);
930 glHint (GL_LINE_SMOOTH_HINT, GL_NICEST);
931 glEnable (GL_POLYGON_SMOOTH);
932 glHint (GL_POLYGON_SMOOTH_HINT, GL_NICEST);
935 updateToolbarAndMouseContextMenu();
944 void G4OpenGLQtViewer::toggleHaloing(
bool check) {
946 haloing_enabled =
false;
948 haloing_enabled =
true;
951 updateToolbarAndMouseContextMenu();
960 void G4OpenGLQtViewer::toggleAux(
bool check) {
962 fVP.SetAuxEdgeVisible(
true);
964 fVP.SetAuxEdgeVisible(
false);
966 SetNeedKernelVisit (
true);
967 updateToolbarAndMouseContextMenu();
972 void G4OpenGLQtViewer::togglePicking() {
975 if (!fVP.IsPicking()) {
976 fUiQt->SetIconPickSelected();
978 fUiQt->SetIconRotateSelected();
984 if (!fVP.IsPicking()) {
985 UI->
ApplyCommand(std::string(
"/vis/viewer/set/picking true"));
987 UI->
ApplyCommand(std::string(
"/vis/viewer/set/picking false"));
998 void G4OpenGLQtViewer::toggleHiddenMarkers(
bool check) {
1000 fVP.SetMarkerHidden();
1002 fVP.SetMarkerNotHidden();
1005 updateToolbarAndMouseContextMenu();
1012 void G4OpenGLQtViewer::toggleFullScreen(
bool check) {
1013 if (check != fGLWidget->isFullScreen()) {
1014 fGLWidget->setWindowState(fGLWidget->windowState() ^ Qt::WindowFullScreen);
1019 void G4OpenGLQtViewer::savePPMToTemp() {
1020 if (fMovieTempFolderPath ==
"") {
1023 QGLWidget* qGLW =
dynamic_cast<QGLWidget*
> (fGLWidget) ;
1027 QString fileName =
"Test"+QString::number(fRecordFrameNumber)+
".ppm";
1028 QString filePath =fMovieTempFolderPath+fileName;
1031 image = qGLW->grabFrameBuffer();
1034 res = image.save(filePath,0);
1037 setRecordingInfos(
"Can't save tmp file "+filePath);
1041 setRecordingInfos(
"File "+fileName+
" saved");
1042 fRecordFrameNumber++;
1047 void G4OpenGLQtViewer::actionSaveImage() {
1049 for (
unsigned int i = 0; i < fExportImageFormatVector.size(); ++i) {
1050 filters += QString(
"*.") + fExportImageFormatVector.at(i).c_str() +
";;";
1053 QString* selectedFormat =
new QString(fDefaultExportImageFormat.c_str());
1055 qFilename = QFileDialog::getSaveFileName ( fGLWidget,
1062 std::string name = qFilename.toStdString().c_str();
1069 fFileSavePath = QFileInfo(qFilename).path();
1071 std::string format = selectedFormat->toLower().toStdString().c_str();
1074 fExportImageFormat = format.substr(format.find_last_of(
".") + 1);
1076 std::string filename =
name;
1077 std::string extension =
"";
1078 if (name.find_last_of(
".") != std::string::npos) {
1079 filename = name.substr(0,name.find_last_of(
".") + 1);
1080 extension = name.substr(name.find_last_of(
".") + 1);
1082 extension = fExportImageFormat;
1085 filename+=
"."+ extension;
1087 if (!setExportFilename(filename.c_str(),0)) {
1091 G4OpenGLQtExportDialog* exportDialog=
new G4OpenGLQtExportDialog(fGLWidget,format.c_str(),fGLWidget->height(),fGLWidget->width());
1092 if( exportDialog->exec()) {
1094 if ((exportDialog->getWidth() !=fGLWidget->width()) ||
1095 (exportDialog->getHeight() !=fGLWidget->height())) {
1096 setExportSize(exportDialog->getWidth(),exportDialog->getHeight());
1099 if (fExportImageFormat ==
"eps") {
1100 fVectoredPs = exportDialog->getVectorEPS();
1101 }
else if (fExportImageFormat ==
"ps") {
1104 fLastExportSliderValue = exportDialog->getSliderValue();
1106 if (exportImage(filename)) {
1108 fDefaultExportImageFormat = format;
1117 void G4OpenGLQtViewer::actionChangeBackgroundColor() {
1125 #if QT_VERSION < 0x040500
1127 const QColor color = QColor(QColorDialog::getRgba (QColor(Qt::black).rgba(),&a,fGLWidget));
1129 const QColor color =
1130 QColorDialog::getColor(Qt::black,
1132 " Get background color and transparency",
1133 QColorDialog::ShowAlphaChannel);
1135 if (color.isValid()) {
1140 fVP.SetBackgroundColour(colour);
1142 updateToolbarAndMouseContextMenu();
1147 void G4OpenGLQtViewer::actionChangeTextColor() {
1149 #if QT_VERSION < 0x040500
1151 const QColor color = QColor(QColorDialog::getRgba (QColor(
Qt::yellow).rgba(),&a,fGLWidget));
1153 const QColor& color =
1156 " Get text color and transparency",
1157 QColorDialog::ShowAlphaChannel);
1159 if (color.isValid()) {
1165 fVP.SetDefaultTextColour(colour);
1167 updateToolbarAndMouseContextMenu();
1172 void G4OpenGLQtViewer::actionChangeDefaultColor() {
1174 #if QT_VERSION < 0x040500
1176 const QColor color = QColor(QColorDialog::getRgba (QColor(Qt::white).rgba(),&a,fGLWidget));
1178 const QColor& color =
1179 QColorDialog::getColor(Qt::white,
1181 " Get default color and transparency",
1182 QColorDialog::ShowAlphaChannel);
1184 if (color.isValid()) {
1190 fVP.SetDefaultColour(colour);
1192 updateToolbarAndMouseContextMenu();
1198 void G4OpenGLQtViewer::actionMovieParameters() {
1199 showMovieParametersDialog();
1203 void G4OpenGLQtViewer::showMovieParametersDialog() {
1204 if (!fMovieParametersDialog) {
1205 fMovieParametersDialog=
new G4OpenGLQtMovieDialog(
this,fGLWidget);
1206 displayRecordingStatus();
1207 fMovieParametersDialog->checkEncoderSwParameters();
1208 fMovieParametersDialog->checkSaveFileNameParameters();
1209 fMovieParametersDialog->checkTempFolderParameters();
1210 if (getEncoderPath() ==
"") {
1211 setRecordingInfos(
"ppmtompeg is needed to encode in video format. It is available here: http://netpbm.sourceforge.net ");
1214 fMovieParametersDialog->show();
1219 void G4OpenGLQtViewer::FinishView()
1235 void G4OpenGLQtViewer::G4MousePressEvent(QMouseEvent *evnt)
1237 if (evnt->button() == Qt::RightButton) {
1240 if ((evnt->button() & Qt::LeftButton) && (! (evnt->modifiers() & Qt::ControlModifier ))){
1241 fGLWidget->setMouseTracking(
true);
1243 fLastPos1 = evnt->pos();
1244 fLastPos2 = fLastPos1;
1245 fLastPos3 = fLastPos2;
1246 fLastEventTime->start();
1247 if (fUiQt != NULL) {
1249 if (fUiQt->IsIconZoomInSelected()) {
1252 float deltaX = ((float)getWinWidth()/2-evnt->pos().x());
1253 float deltaY = ((float)getWinHeight()/2-evnt->pos().y());
1257 if (getWinHeight() <getWinWidth()) {
1260 fVP.IncrementPan(-deltaX*coefTrans,deltaY*coefTrans,0);
1261 fVP.SetZoomFactor(1.5 * fVP.GetZoomFactor());
1265 }
else if (fUiQt->IsIconZoomOutSelected()) {
1267 moveScene(((
float)getWinWidth()/2-evnt->pos().x()),((
float)getWinHeight()/2-evnt->
pos().y()),0,true);
1269 fVP.SetZoomFactor(0.75 * fVP.GetZoomFactor());
1272 }
else if (fUiQt->IsIconRotateSelected() ) {
1274 if (fShiftKeyPress) {
1275 fGLWidget->setCursor(QCursor(Qt::SizeAllCursor));
1278 fGLWidget->setCursor(QCursor(Qt::ClosedHandCursor));
1280 }
else if (fUiQt->IsIconMoveSelected()) {
1281 fGLWidget->setCursor(QCursor(Qt::SizeAllCursor));
1282 }
else if (fUiQt->IsIconPickSelected()) {
1283 fGLWidget->setCursor(QCursor(Qt::PointingHandCursor));
1291 void G4OpenGLQtViewer::G4MouseReleaseEvent(QMouseEvent *evnt)
1293 fSpinningDelay = fLastEventTime->elapsed();
1294 QPoint delta = (fLastPos3-fLastPos1);
1297 fGLWidget->setCursor(QCursor(Qt::ArrowCursor));
1299 if (fVP.IsPicking()){
1300 if ((delta.x() != 0) || (delta.y() != 0)) {
1303 updatePickInfosWidget(evnt->pos().x(),evnt->pos().y());
1305 }
else if (fSpinningDelay < fLaunchSpinDelay ) {
1306 if ((delta.x() == 0) && (delta.y() == 0)) {
1312 lastMoveTime.start();
1314 float correctionFactor = 5;
1316 if ( lastMoveTime.elapsed() >= (
int)(1000/fNbMaxFramesPerSec)) {
1317 float lTime = 1000/lastMoveTime.elapsed();
1318 if (((((
float)delta.x())/correctionFactor)*lTime > fNbMaxAnglePerSec) ||
1319 ((((
float)delta.x())/correctionFactor)*lTime < -fNbMaxAnglePerSec) ) {
1320 correctionFactor = (float)delta.x()*(lTime/fNbMaxAnglePerSec);
1321 if (delta.x() <0 ) {
1322 correctionFactor = -correctionFactor;
1325 if (((((
float)delta.y())/correctionFactor)*lTime > fNbMaxAnglePerSec) ||
1326 ((((
float)delta.y())/correctionFactor)*lTime < -fNbMaxAnglePerSec) ) {
1327 correctionFactor = (float)delta.y()*(lTime/fNbMaxAnglePerSec);
1328 if (delta.y() <0 ) {
1329 correctionFactor = -correctionFactor;
1340 lastMoveTime.start();
1342 bool rotate =
false;
1345 if (fUiQt != NULL) {
1346 if (fUiQt->IsIconRotateSelected()) {
1348 }
else if (fUiQt->IsIconMoveSelected()) {
1361 rotateQtScene(((
float)delta.x())/correctionFactor,((
float)delta.y())/correctionFactor);
1362 }
else if (fAltKeyPress) {
1363 rotateQtSceneToggle(((
float)delta.x())/correctionFactor,((
float)delta.y())/correctionFactor);
1367 moveScene(-((
float)delta.x())/correctionFactor,-((
float)delta.y())/correctionFactor,0,true);
1370 ((QApplication*)G4Qt::getInstance ())->processEvents();
1373 fGLWidget->setMouseTracking(false);
1378 void G4OpenGLQtViewer::G4MouseDoubleClickEvent()
1380 fGLWidget->setMouseTracking(
true);
1391 void G4OpenGLQtViewer::G4MouseMoveEvent(QMouseEvent *evnt)
1394 Qt::MouseButtons mButtons = evnt->buttons();
1396 updateKeyModifierState(evnt->modifiers());
1402 fLastPos3 = fLastPos2;
1403 fLastPos2 = fLastPos1;
1404 fLastPos1 = QPoint(evnt->x(), evnt->y());
1406 int deltaX = fLastPos2.x()-fLastPos1.x();
1407 int deltaY = fLastPos2.y()-fLastPos1.y();
1410 if (fUiQt != NULL) {
1411 if (fUiQt->IsIconMoveSelected()) {
1416 if (mButtons & Qt::LeftButton) {
1418 rotateQtScene(((
float)deltaX),((
float)deltaY));
1419 }
else if (fAltKeyPress) {
1420 rotateQtSceneToggle(((
float)deltaX),((
float)deltaY));
1421 }
else if (fShiftKeyPress) {
1422 unsigned int sizeWin;
1423 sizeWin = getWinWidth();
1424 if (getWinHeight() < getWinWidth()) {
1425 sizeWin = getWinHeight();
1429 float factor = ((float)100/(
float)sizeWin) ;
1430 moveScene(-(
float)deltaX*factor,-(
float)deltaY*factor,0,
false);
1431 }
else if (fControlKeyPress) {
1432 fVP.SetZoomFactor(fVP.GetZoomFactor()*(1+((float)deltaY)));
1436 if (mButtons & Qt::LeftButton) {
1437 moveScene(-(
float)deltaX,-(
float)deltaY,0,
true);
1441 fLastEventTime->start();
1452 void G4OpenGLQtViewer::moveScene(
float dx,
float dy,
float dz,
bool mouseMove)
1456 fHoldMoveEvent =
true;
1459 GLdouble coefDepth = 0;
1462 if (getWinHeight() <getWinWidth()) {
1466 coefTrans = getSceneNearWidth()*fPan_sens;
1467 coefDepth = getSceneDepth()*fDeltaDepth;
1469 fVP.IncrementPan(-dx*coefTrans,dy*coefTrans,dz*coefDepth);
1473 ((QApplication*)G4Qt::getInstance ())->processEvents();
1475 fHoldMoveEvent =
false;
1484 void G4OpenGLQtViewer::rotateQtScene(
float dx,
float dy)
1486 if (fHoldRotateEvent)
1488 fHoldRotateEvent =
true;
1494 fHoldRotateEvent =
false;
1502 void G4OpenGLQtViewer::rotateQtSceneToggle(
float dx,
float dy)
1504 if (fHoldRotateEvent)
1506 fHoldRotateEvent =
true;
1508 rotateSceneToggle(dx,dy);
1512 fHoldRotateEvent =
false;
1523 void G4OpenGLQtViewer::rescaleImage(
1543 void G4OpenGLQtViewer::G4wheelEvent (QWheelEvent * evnt)
1545 fVP.SetZoomFactor(fVP.GetZoomFactor()+(fVP.GetZoomFactor()*(evnt->delta())/1200));
1550 void G4OpenGLQtViewer::G4keyPressEvent (QKeyEvent * evnt)
1555 fHoldKeyEvent =
true;
1559 updateKeyModifierState(evnt->modifiers());
1560 if ((fNoKeyPress) || (evnt->modifiers() == Qt::KeypadModifier )) {
1561 if (evnt->key() == Qt::Key_Down) {
1562 moveScene(0,1,0,
false);
1564 else if (evnt->key() == Qt::Key_Up) {
1565 moveScene(0,-1,0,
false);
1567 if (evnt->key() == Qt::Key_Left) {
1568 moveScene(-1,0,0,
false);
1570 else if (evnt->key() == Qt::Key_Right) {
1571 moveScene(1,0,0,
false);
1573 if (evnt->key() == Qt::Key_Minus) {
1574 moveScene(0,0,1,
false);
1576 else if (evnt->key() == Qt::Key_Plus) {
1577 moveScene(0,0,-1,
false);
1580 if (evnt->key() == Qt::Key_Escape) {
1581 toggleFullScreen(
false);
1590 if ((evnt->key() == Qt::Key_Return) || (evnt->key() == Qt::Key_Enter)){
1593 if (evnt->key() == Qt::Key_Space){
1598 if (evnt->key() == Qt::Key_H){
1605 if (fShiftKeyPress) {
1606 fGLWidget->setCursor(QCursor(Qt::SizeAllCursor));
1608 if (evnt->key() == Qt::Key_Down) {
1609 rotateQtScene(0,-fRot_sens);
1611 else if (evnt->key() == Qt::Key_Up) {
1612 rotateQtScene(0,fRot_sens);
1614 if (evnt->key() == Qt::Key_Left) {
1615 rotateQtScene(fRot_sens,0);
1617 else if (evnt->key() == Qt::Key_Right) {
1618 rotateQtScene(-fRot_sens,0);
1620 if (evnt->key() == Qt::Key_Plus) {
1622 moveScene(0,0,-1,
false);
1627 if ((fAltKeyPress)) {
1628 fGLWidget->setCursor(QCursor(Qt::ClosedHandCursor));
1630 if (evnt->key() == Qt::Key_Down) {
1631 rotateQtSceneToggle(0,-fRot_sens);
1633 else if (evnt->key() == Qt::Key_Up) {
1634 rotateQtSceneToggle(0,fRot_sens);
1636 if (evnt->key() == Qt::Key_Left) {
1637 rotateQtSceneToggle(fRot_sens,0);
1639 else if (evnt->key() == Qt::Key_Right) {
1640 rotateQtSceneToggle(-fRot_sens,0);
1644 if (evnt->key() == Qt::Key_Plus) {
1645 fRot_sens = fRot_sens/0.7;
1646 G4cout <<
"Auto-rotation set to : " << fRot_sens <<
G4endl;
1648 else if (evnt->key() == Qt::Key_Minus) {
1649 fRot_sens = fRot_sens*0.7;
1650 G4cout <<
"Auto-rotation set to : " << fRot_sens <<
G4endl;
1655 if ((fControlKeyPress)) {
1656 if (evnt->key() == Qt::Key_Plus) {
1657 fVP.SetZoomFactor(fVP.GetZoomFactor()*(1+fDeltaZoom));
1660 else if (evnt->key() == Qt::Key_Minus) {
1661 fVP.SetZoomFactor(fVP.GetZoomFactor()*(1-fDeltaZoom));
1666 fHoldKeyEvent =
false;
1670 void G4OpenGLQtViewer::G4keyReleaseEvent (QKeyEvent *)
1672 fGLWidget->setCursor(QCursor(Qt::ArrowCursor));
1676 void G4OpenGLQtViewer::updateKeyModifierState(
const Qt::KeyboardModifiers& modifier) {
1680 fAltKeyPress =
false;
1681 fShiftKeyPress =
false;
1682 fControlKeyPress =
false;
1684 if (modifier & Qt::AltModifier ) {
1685 fAltKeyPress =
true;
1686 fNoKeyPress =
false;
1688 if (modifier & Qt::ShiftModifier ) {
1689 fShiftKeyPress =
true;
1690 fNoKeyPress =
false;
1692 if (modifier & Qt::ControlModifier ) {
1693 fControlKeyPress =
true;
1694 fNoKeyPress =
false;
1701 void G4OpenGLQtViewer::stopVideo() {
1704 if (!fMovieParametersDialog) {
1705 showMovieParametersDialog();
1707 setRecordingStatus(STOP);
1709 if (fRecordFrameNumber >0) {
1711 if (!(fMovieParametersDialog->checkEncoderSwParameters())) {
1712 setRecordingStatus(BAD_ENCODER);
1713 }
else if (!(fMovieParametersDialog->checkSaveFileNameParameters())) {
1714 setRecordingStatus(BAD_OUTPUT);
1718 setRecordingInfos(
"No frame to encode.");
1724 void G4OpenGLQtViewer::saveVideo() {
1727 if (!fMovieParametersDialog) {
1728 showMovieParametersDialog();
1731 fMovieParametersDialog->checkEncoderSwParameters();
1732 fMovieParametersDialog->checkSaveFileNameParameters();
1734 if (fRecordingStep == STOP) {
1735 setRecordingStatus(SAVE);
1736 generateMpegEncoderParameters();
1744 void G4OpenGLQtViewer::startPauseVideo() {
1748 if ( fRecordingStep == WAIT) {
1749 if ( fRecordFrameNumber == 0) {
1750 if (getTempFolderPath() ==
"") {
1751 showMovieParametersDialog();
1752 setRecordingInfos(
"You should specified the temp folder in order to make movie");
1756 QString tmp = removeTempFolder();
1758 setRecordingInfos(tmp);
1761 tmp = createTempFolder();
1763 setRecordingInfos(
"Can't create temp folder."+tmp);
1769 if (fRecordingStep == WAIT) {
1770 setRecordingStatus(
START);
1771 }
else if (fRecordingStep ==
START) {
1772 setRecordingStatus(PAUSE);
1773 }
else if (fRecordingStep == PAUSE) {
1774 setRecordingStatus(CONTINUE);
1775 }
else if (fRecordingStep == CONTINUE) {
1776 setRecordingStatus(PAUSE);
1780 void G4OpenGLQtViewer::setRecordingStatus(RECORDING_STEP step) {
1782 fRecordingStep = step;
1783 displayRecordingStatus();
1787 void G4OpenGLQtViewer::displayRecordingStatus() {
1789 QString txtStatus =
"";
1790 if (fRecordingStep == WAIT) {
1791 txtStatus =
"Waiting to start...";
1792 fRecordFrameNumber = 0;
1793 }
else if (fRecordingStep ==
START) {
1794 txtStatus =
"Start Recording...";
1795 }
else if (fRecordingStep == PAUSE) {
1796 txtStatus =
"Pause Recording...";
1797 }
else if (fRecordingStep == CONTINUE) {
1798 txtStatus =
"Continue Recording...";
1799 }
else if (fRecordingStep == STOP) {
1800 txtStatus =
"Stop Recording...";
1801 }
else if (fRecordingStep == READY_TO_ENCODE) {
1802 txtStatus =
"Ready to Encode...";
1803 }
else if (fRecordingStep ==
ENCODING) {
1804 txtStatus =
"Encoding...";
1805 }
else if (fRecordingStep == FAILED) {
1806 txtStatus =
"Failed to encode...";
1807 }
else if ((fRecordingStep == BAD_ENCODER)
1808 || (fRecordingStep == BAD_OUTPUT)
1809 || (fRecordingStep == BAD_TMP)) {
1810 txtStatus =
"Correct above errors first";
1811 }
else if (fRecordingStep == SUCCESS) {
1812 txtStatus =
"File encoded successfully";
1816 if (fMovieParametersDialog) {
1817 fMovieParametersDialog->setRecordingStatus(txtStatus);
1821 setRecordingInfos(
"");
1825 void G4OpenGLQtViewer::setRecordingInfos(
const QString& txt) {
1826 if (fMovieParametersDialog) {
1827 fMovieParametersDialog->setRecordingInfos(txt);
1835 void G4OpenGLQtViewer::initMovieParameters() {
1839 fProcess =
new QProcess();
1841 QObject ::connect(fProcess,SIGNAL(finished (
int)),
1842 this,SLOT(processLookForFinished()));
1843 fProcess->setReadChannelMode(QProcess::MergedChannels);
1844 fProcess->start (
"which ppmtompeg");
1850 QString G4OpenGLQtViewer::getEncoderPath() {
1851 return fEncoderPath;
1859 QString G4OpenGLQtViewer::setEncoderPath(QString path) {
1861 return "ppmtompeg is needed to encode in video format. It is available here: http://netpbm.sourceforge.net ";
1864 path = QDir::cleanPath(path);
1865 QFileInfo *f =
new QFileInfo(path);
1867 return "File does not exist";
1868 }
else if (f->isDir()) {
1869 return "This is a directory";
1870 }
else if (!f->isExecutable()) {
1871 return "File exist but is not executable";
1872 }
else if (!f->isFile()) {
1873 return "This is not a file";
1875 fEncoderPath = path;
1877 if (fRecordingStep == BAD_ENCODER) {
1878 setRecordingStatus(STOP);
1884 bool G4OpenGLQtViewer::isRecording(){
1885 if ((fRecordingStep ==
START) || (fRecordingStep == CONTINUE)) {
1891 bool G4OpenGLQtViewer::isPaused(){
1892 if (fRecordingStep == PAUSE) {
1898 bool G4OpenGLQtViewer::isEncoding(){
1905 bool G4OpenGLQtViewer::isWaiting(){
1906 if (fRecordingStep == WAIT) {
1912 bool G4OpenGLQtViewer::isStopped(){
1913 if (fRecordingStep == STOP) {
1919 bool G4OpenGLQtViewer::isFailed(){
1920 if (fRecordingStep == FAILED) {
1926 bool G4OpenGLQtViewer::isSuccess(){
1927 if (fRecordingStep == SUCCESS) {
1933 bool G4OpenGLQtViewer::isBadEncoder(){
1934 if (fRecordingStep == BAD_ENCODER) {
1939 bool G4OpenGLQtViewer::isBadTmp(){
1940 if (fRecordingStep == BAD_TMP) {
1945 bool G4OpenGLQtViewer::isBadOutput(){
1946 if (fRecordingStep == BAD_OUTPUT) {
1952 void G4OpenGLQtViewer::setBadEncoder(){
1953 fRecordingStep = BAD_ENCODER;
1954 displayRecordingStatus();
1956 void G4OpenGLQtViewer::setBadTmp(){
1957 fRecordingStep = BAD_TMP;
1958 displayRecordingStatus();
1960 void G4OpenGLQtViewer::setBadOutput(){
1961 fRecordingStep = BAD_OUTPUT;
1962 displayRecordingStatus();
1965 void G4OpenGLQtViewer::setWaiting(){
1966 fRecordingStep = WAIT;
1967 displayRecordingStatus();
1971 bool G4OpenGLQtViewer::isReadyToEncode(){
1972 if (fRecordingStep == READY_TO_ENCODE) {
1978 void G4OpenGLQtViewer::resetRecording() {
1979 setRecordingStatus(WAIT);
1986 QString G4OpenGLQtViewer::setTempFolderPath(QString path) {
1989 return "Path does not exist";
1991 path = QDir::cleanPath(path);
1992 QFileInfo *d =
new QFileInfo(path);
1994 return "Path does not exist";
1995 }
else if (!d->isDir()) {
1996 return "This is not a directory";
1997 }
else if (!d->isReadable()) {
1998 return path +
" is read protected";
1999 }
else if (!d->isWritable()) {
2000 return path +
" is write protected";
2003 if (fRecordingStep == BAD_TMP) {
2004 setRecordingStatus(WAIT);
2006 fTempFolderPath = path;
2012 QString G4OpenGLQtViewer::getTempFolderPath() {
2013 return fTempFolderPath;
2020 QString G4OpenGLQtViewer::setSaveFileName(QString path) {
2023 return "Path does not exist";
2026 QFileInfo *file =
new QFileInfo(path);
2027 QDir dir = file->dir();
2028 path = QDir::cleanPath(path);
2029 if (file->exists()) {
2030 return "File already exist, please choose a new one";
2031 }
else if (!dir.exists()) {
2032 return "Dir does not exist";
2033 }
else if (!dir.isReadable()) {
2034 return path +
" is read protected";
2037 if (fRecordingStep == BAD_OUTPUT) {
2038 setRecordingStatus(STOP);
2040 fSaveFileName = path;
2046 QString G4OpenGLQtViewer::getSaveFileName() {
2047 return fSaveFileName ;
2054 QString G4OpenGLQtViewer::createTempFolder() {
2055 fMovieTempFolderPath =
"";
2057 QString tmp = setTempFolderPath(fTempFolderPath);
2061 QString sep = QString(QDir::separator());
2062 QString path = sep+
"QtMovie_"+QDateTime::currentDateTime ().toString(
"dd-MM-yyyy_hh-mm-ss")+sep;
2063 QDir *d =
new QDir(QDir::cleanPath(fTempFolderPath));
2065 if (d->exists(path)) {
2066 return "Folder "+path+
" already exists.Please remove it first";
2068 if (d->mkdir(fTempFolderPath+path)) {
2069 fMovieTempFolderPath = fTempFolderPath+path;
2072 return "Can't create "+fTempFolderPath+path;
2077 QString G4OpenGLQtViewer::removeTempFolder() {
2079 if (fMovieTempFolderPath ==
"") {
2082 QDir *d =
new QDir(QDir::cleanPath(fMovieTempFolderPath));
2087 d->setFilter( QDir::Files );
2088 QStringList subDirList = d->entryList();
2091 for (QStringList::ConstIterator it = subDirList.begin() ;(it != subDirList.end()) ; it++) {
2092 const QString currentFile = *it;
2093 if (!d->remove(currentFile)) {
2095 QString file = fMovieTempFolderPath+currentFile;
2096 error +=
"Removing file failed : "+file;
2101 if (d->rmdir(fMovieTempFolderPath)) {
2102 fMovieTempFolderPath =
"";
2105 return "Dir "+fMovieTempFolderPath+
" should be empty, but could not remove it";
2109 return "Could not remove "+fMovieTempFolderPath+
" because of the following errors :"+
error;
2119 bool G4OpenGLQtViewer::exportImage(std::string name,
int width,
int height) {
2121 QGLWidget* qGLW =
dynamic_cast<QGLWidget*
> (fGLWidget) ;
2126 bool increaseFileNumber =
true;
2128 if (name.size() != name.substr(name.find_last_of(
".") + 1).size()) {
2129 increaseFileNumber =
false;
2131 if (! setExportFilename(name,increaseFileNumber)) {
2134 if ((width !=-1) && (height != -1)) {
2135 setExportSize(width, height);
2138 if (G4OpenGLViewer::exportImage()) {
2144 image = qGLW->grabFrameBuffer();
2146 bool res = image.save(QString(getRealPrintFilename().c_str()),0,fLastExportSliderValue);
2149 G4cerr <<
"Error saving file... " << getRealPrintFilename().c_str() <<
G4endl;
2152 G4cout <<
"File " << getRealPrintFilename().c_str() <<
" size: " << fGLWidget->width() <<
"x" << fGLWidget->height() <<
" has been saved " <<
G4endl;
2153 fExportFilenameIndex++;
2161 bool G4OpenGLQtViewer::hasPendingEvents () {
2162 return ((QApplication*)G4Qt::getInstance ())->hasPendingEvents ();
2165 bool G4OpenGLQtViewer::generateMpegEncoderParameters () {
2169 fp = fopen (QString(fMovieTempFolderPath+fParameterFileName).toStdString().c_str(),
"w");
2172 setRecordingInfos(
"Generation of parameter file failed");
2176 fprintf (fp,
"# Pattern affects speed, quality and compression. See the User's Guide\n");
2177 fprintf (fp,
"# for more info.\n");
2179 fprintf (fp,
"PATTERN I\n");
2180 fprintf (fp,
"OUTPUT %s\n",getSaveFileName().toStdString().c_str());
2182 fprintf (fp,
"# You must specify the type of the input files. The choices are:\n");
2183 fprintf (fp,
"# YUV, PPM, JMOVIE, Y, JPEG, PNM\n");
2184 fprintf (fp,
"# (must be upper case)\n");
2186 fprintf (fp,
"BASE_FILE_FORMAT PPM\n");
2189 fprintf (fp,
"# If you are using YUV, there are different supported file formats.\n");
2190 fprintf (fp,
"# EYUV or UCB are the same as previous versions of this encoder.\n");
2191 fprintf (fp,
"# (All the Y's, then U's then V's, in 4:2:0 subsampling.)\n");
2192 fprintf (fp,
"# Other formats, such as Abekas, Phillips, or a general format are\n");
2193 fprintf (fp,
"# permissible, the general format is a string of Y's, U's, and V's\n");
2194 fprintf (fp,
"# to specify the file order.\n");
2196 fprintf (fp,
"INPUT_FORMAT UCB\n");
2198 fprintf (fp,
"# the conversion statement\n");
2200 fprintf (fp,
"# Each occurrence of '*' will be replaced by the input file\n");
2202 fprintf (fp,
"# e.g., if you have a bunch of GIF files, then this might be:\n");
2203 fprintf (fp,
"# INPUT_CONVERT giftoppm *\n");
2205 fprintf (fp,
"# e.g., if you have a bunch of files like a.Y a.U a.V, etc., then:\n");
2206 fprintf (fp,
"# INPUT_CONVERT cat *.Y *.U *.V\n");
2208 fprintf (fp,
"# e.g., if you are grabbing from laser disc you might have something like\n");
2209 fprintf (fp,
"# INPUT_CONVERT goto frame *; grabppm\n");
2210 fprintf (fp,
"# 'INPUT_CONVERT *' means the files are already in the base file format\n");
2212 fprintf (fp,
"INPUT_CONVERT * \n");
2214 fprintf (fp,
"# number of frames in a GOP.\n");
2216 fprintf (fp,
"# since each GOP must have at least one I-frame, the encoder will find the\n");
2217 fprintf (fp,
"# the first I-frame after GOP_SIZE frames to start the next GOP\n");
2219 fprintf (fp,
"# later, will add more flexible GOP signalling\n");
2221 fprintf (fp,
"GOP_SIZE 1\n");
2223 fprintf (fp,
"# number of slices in a frame\n");
2225 fprintf (fp,
"# 1 is a good number. another possibility is the number of macroblock rows\n");
2226 fprintf (fp,
"# (which is the height divided by 16)\n");
2228 fprintf (fp,
"SLICES_PER_FRAME 1\n");
2229 fprintf (fp,
"PIXEL HALF");
2231 fprintf (fp,
"# directory to get all input files from (makes this file easier to read)\n");
2232 fprintf (fp,
"INPUT_DIR %s\n",fMovieTempFolderPath.toStdString().c_str());
2234 fprintf (fp,
"# There are a bunch of ways to specify the input files.\n");
2235 fprintf (fp,
"# from a simple one-per-line listing, to the following \n");
2236 fprintf (fp,
"# way of numbering them. See the manual for more information.\n");
2237 fprintf (fp,
"INPUT\n");
2238 fprintf (fp,
"# '*' is replaced by the numbers 01, 02, 03, 04\n");
2239 fprintf (fp,
"# if I instead do [01-11], it would be 01, 02, ..., 09, 10, 11\n");
2240 fprintf (fp,
"# if I instead do [1-11], it would be 1, 2, 3, ..., 9, 10, 11\n");
2241 fprintf (fp,
"# if I instead do [1-11+3], it would be 1, 4, 7, 10\n");
2242 fprintf (fp,
"# the program assumes none of your input files has a name ending in ']'\n");
2243 fprintf (fp,
"# if you do, too bad!!!\n");
2246 fprintf (fp,
"Test*.ppm [0-%d]\n",fRecordFrameNumber-1);
2247 fprintf (fp,
"# can have more files here if you want...there is no limit on the number\n");
2248 fprintf (fp,
"# of files\n");
2249 fprintf (fp,
"END_INPUT\n");
2253 fprintf (fp,
"# Many of the remaining options have to do with the motion search and qscale\n");
2255 fprintf (fp,
"# FULL or HALF -- must be upper case\n");
2256 fprintf (fp,
"# Should be FULL for computer generated images\n");
2257 fprintf (fp,
"PIXEL FULL\n");
2259 fprintf (fp,
"# means +/- this many pixels for both P and B frame searches\n");
2260 fprintf (fp,
"# specify two numbers if you wish to serc different ranges in the two.\n");
2261 fprintf (fp,
"RANGE 10\n");
2263 fprintf (fp,
"# The two search algorithm parameters below mostly affect speed,\n");
2264 fprintf (fp,
"# with some affect on compression and almost none on quality.\n");
2266 fprintf (fp,
"# this must be one of {EXHAUSTIVE, SUBSAMPLE, LOGARITHMIC}\n");
2267 fprintf (fp,
"PSEARCH_ALG LOGARITHMIC\n");
2269 fprintf (fp,
"# this must be one of {SIMPLE, CROSS2, EXHAUSTIVE}\n");
2271 fprintf (fp,
"# note that EXHAUSTIVE is really, really, really slow\n");
2273 fprintf (fp,
"BSEARCH_ALG SIMPLE\n");
2276 fprintf (fp,
"# these specify the q-scale for I, P, and B frames\n");
2277 fprintf (fp,
"# (values must be between 1 and 31)\n");
2278 fprintf (fp,
"# These are the Qscale values for the entire frame in variable bit-rate\n");
2279 fprintf (fp,
"# mode, and starting points (but not important) for constant bit rate\n");
2282 fprintf (fp,
"# Qscale (Quantization scale) affects quality and compression,\n");
2283 fprintf (fp,
"# but has very little effect on speed.\n");
2285 fprintf (fp,
"IQSCALE 4\n");
2286 fprintf (fp,
"PQSCALE 5\n");
2287 fprintf (fp,
"BQSCALE 12\n");
2289 fprintf (fp,
"# this must be ORIGINAL or DECODED\n");
2290 fprintf (fp,
"REFERENCE_FRAME ORIGINAL\n");
2292 fprintf (fp,
"# for parallel parameters see parallel.param in the exmaples subdirectory\n");
2294 fprintf (fp,
"# if you want constant bit-rate mode, specify it as follows (number is bits/sec):\n");
2295 fprintf (fp,
"#BIT_RATE 1000000\n");
2297 fprintf (fp,
"# To specify the buffer size (327680 is default, measused in bits, for 16bit words)\n");
2298 fprintf (fp,
"BUFFER_SIZE 327680\n");
2300 fprintf (fp,
"# The frame rate is the number of frames/second (legal values:\n");
2301 fprintf (fp,
"# 23.976, 24, 25, 29.97, 30, 50 ,59.94, 60\n");
2302 fprintf (fp,
"FRAME_RATE 30\n");
2304 fprintf (fp,
"# There are many more options, see the users manual for examples....\n");
2305 fprintf (fp,
"# ASPECT_RATIO, USER_DATA, GAMMA, IQTABLE, etc.\n");
2310 setRecordingInfos(
"Parameter file "+fParameterFileName+
" generated in "+fMovieTempFolderPath);
2311 setRecordingStatus(READY_TO_ENCODE);
2315 void G4OpenGLQtViewer::encodeVideo()
2317 if ((getEncoderPath() !=
"") && (getSaveFileName() !=
"")) {
2320 fProcess =
new QProcess();
2321 #if QT_VERSION > 0x040100
2322 QObject ::connect(fProcess,SIGNAL(finished (
int,QProcess::ExitStatus)),
2323 this,SLOT(processEncodeFinished()));
2324 QObject ::connect(fProcess,SIGNAL(readyReadStandardOutput ()),
2325 this,SLOT(processEncodeStdout()));
2327 QObject ::connect(fProcess,SIGNAL(finished (
int)),
2328 this,SLOT(processEncodeFinished()));
2329 QObject ::connect(fProcess,SIGNAL(readyReadStandardOutput ()),
2330 this,SLOT(processEncodeStdout()));
2332 fProcess->setReadChannelMode(QProcess::MergedChannels);
2333 fProcess->start (fEncoderPath, QStringList(fMovieTempFolderPath+fParameterFileName));
2339 void G4OpenGLQtViewer::processEncodeStdout()
2341 QString tmp = fProcess->readAllStandardOutput ().data();
2342 int start = tmp.lastIndexOf(
"ESTIMATED TIME");
2343 tmp = tmp.mid(start,tmp.indexOf(
"\n",start)-start);
2344 setRecordingInfos(tmp);
2348 void G4OpenGLQtViewer::processEncodeFinished()
2352 txt = getProcessErrorMsg();
2354 setRecordingStatus(SUCCESS);
2356 setRecordingStatus(FAILED);
2362 void G4OpenGLQtViewer::processLookForFinished()
2365 QString txt = getProcessErrorMsg();
2369 fEncoderPath = QString(fProcess->readAllStandardOutput ().data()).trimmed();
2371 if (fEncoderPath.contains(
" ")) {
2373 }
else if (!fEncoderPath.contains(
"ppmtompeg")) {
2376 setEncoderPath(fEncoderPath);
2379 setTempFolderPath(QDir::temp ().absolutePath ());
2383 QString G4OpenGLQtViewer::getProcessErrorMsg()
2386 if (fProcess->exitCode() != 0) {
2387 switch (fProcess->error()) {
2388 case QProcess::FailedToStart:
2389 txt =
"The process failed to start. Either the invoked program is missing, or you may have insufficient permissions to invoke the program.\n";
2391 case QProcess::Crashed:
2392 txt =
"The process crashed some time after starting successfully.\n";
2394 case QProcess::Timedout:
2395 txt =
"The last waitFor...() function timed out. The state of QProcess is unchanged, and you can try calling waitFor...() again.\n";
2397 case QProcess::WriteError:
2398 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";
2400 case QProcess::ReadError:
2401 txt =
"An error occurred when attempting to read from the process. For example, the process may not be running.\n";
2403 case QProcess::UnknownError:
2404 txt =
"An unknown error occurred. This is the default return value of error().\n";
2414 QWidget *G4OpenGLQtViewer::getParentWidget()
2417 G4Qt* interactorManager = G4Qt::getInstance ();
2422 QDialog* dialog = NULL;
2424 if (((QApplication*)interactorManager->GetMainInteractor())) {
2426 QWidgetList wl = QApplication::allWidgets();
2427 QWidget *widget = NULL;
2428 for (
int i=0; i < wl.size(); i++) {
2430 if ((found==
false) && (widget->inherits(
"QMainWindow"))) {
2431 dialog =
new QDialog(widget,Qt::WindowTitleHint | Qt::WindowSystemMenuHint | Qt::WindowMinMaxButtonsHint);
2437 dialog =
new QDialog();
2440 dialog=
new QDialog();
2450 void G4OpenGLQtViewer::createSceneTreeWidget() {
2451 fUISceneTreeWidget = fUiQt->GetSceneTreeWidget();
2453 if (!fUISceneTreeWidget) {
2458 QLayoutItem * wItem;
2460 if (fUISceneTreeWidget->layout()->count() ) {
2461 for(
int idx = 0; idx < fUISceneTreeWidget->layout()->count(); idx++){
2462 wItem = fUISceneTreeWidget->layout()->itemAt(idx);
2463 if (fSceneTreeWidget) {
2464 if(dynamic_cast<QWidget *>(wItem->widget())) {
2465 if (wItem->widget()->windowTitle() == fSceneTreeWidget->windowTitle()) {
2466 wItem->widget()->show();
2469 wItem->widget()->hide();
2473 wItem->widget()->hide();
2480 fSceneTreeWidget =
new QWidget();
2481 QVBoxLayout* layoutSceneTree =
new QVBoxLayout();
2482 fSceneTreeWidget->setStyleSheet (
"padding: 0px ");
2484 fSceneTreeWidget->setLayout(layoutSceneTree);
2485 fSceneTreeWidget->layout()->setContentsMargins(5,5,5,5);
2486 fSceneTreeWidget->setWindowTitle(QString(GetName().
data()));
2488 if (fUISceneTreeWidget != NULL) {
2489 fUISceneTreeWidget->layout()->addWidget(fSceneTreeWidget);
2493 if (dynamic_cast<G4OpenGLStoredQtViewer*> (
this)) {
2494 createSceneTreeComponent();
2500 void G4OpenGLQtViewer::createSceneTreeComponent(){
2502 QLayout* vLayout = fSceneTreeWidget->layout();
2505 QWidget* coutButtonWidget =
new QWidget();
2506 QHBoxLayout* layoutCoutTBButtons =
new QHBoxLayout();
2508 fFilterOutput =
new QLineEdit();
2509 fFilterOutput->setToolTip(
"Filter output by...");
2510 fFilterOutput->setStyleSheet (
"padding: 0px ");
2512 QPixmap* searchIcon = fUiQt->getSearchIcon();
2513 #if QT_VERSION > 0x050100
2514 fFilterOutput->addAction(*searchIcon,QLineEdit::TrailingPosition);
2515 fFilterOutput->setStyleSheet (
"border-radius:7px;");
2517 QPushButton *coutTBFilterButton =
new QPushButton();
2518 coutTBFilterButton->setIcon(*searchIcon);
2519 coutTBFilterButton->setStyleSheet (
"padding-left: 0px; border:0px;");
2520 fFilterOutput->setStyleSheet (
"padding-right: 0px;");
2522 layoutCoutTBButtons->addWidget(fFilterOutput);
2524 #if QT_VERSION <= 0x050100
2525 layoutCoutTBButtons->addWidget(coutTBFilterButton);
2528 coutButtonWidget->setLayout(layoutCoutTBButtons);
2529 vLayout->addWidget(coutButtonWidget);
2532 vLayout->setContentsMargins(0,0,0,0);
2535 fSceneTreeComponentTreeWidget =
new QTreeWidget();
2536 fSceneTreeComponentTreeWidget->setSelectionMode(QAbstractItemView::SingleSelection);
2537 fSceneTreeComponentTreeWidget->setHeaderLabel (
"Scene tree : "+QString(GetName().
data()));
2538 fSceneTreeComponentTreeWidget->setColumnHidden (1,
true);
2539 fSceneTreeComponentTreeWidget->setColumnHidden (2,
true);
2540 fSceneTreeComponentTreeWidget->setColumnHidden (3,
true);
2545 vLayout->addWidget(fSceneTreeComponentTreeWidget);
2547 connect(fSceneTreeComponentTreeWidget,SIGNAL(itemChanged(QTreeWidgetItem*,
int)),SLOT(sceneTreeComponentItemChanged(QTreeWidgetItem*,
int)));
2548 connect(fSceneTreeComponentTreeWidget,SIGNAL(itemSelectionChanged ()),SLOT(sceneTreeComponentSelected()));
2549 connect(fSceneTreeComponentTreeWidget,SIGNAL(itemDoubleClicked ( QTreeWidgetItem*,
int)),SLOT(changeColorAndTransparency( QTreeWidgetItem*,
int)));
2553 QWidget *helpWidget =
new QWidget();
2554 QHBoxLayout *helpLayout =
new QHBoxLayout();
2556 QWidget* depthWidget =
new QWidget();
2557 QWidget *showBox =
new QWidget(depthWidget);
2558 QHBoxLayout *showBoxLayout =
new QHBoxLayout();
2561 showBoxLayout->setContentsMargins(5,5,5,5);
2563 QLabel *zero =
new QLabel();
2564 zero->setText(
"Show all");
2565 QLabel *one =
new QLabel();
2566 one->setText(
"Hide all");
2567 fSceneTreeDepthSlider =
new QSlider ( Qt::Horizontal);
2568 fSceneTreeDepthSlider->setMaximum (1000);
2569 fSceneTreeDepthSlider->setMinimum (0);
2570 fSceneTreeDepthSlider->setTickPosition(QSlider::TicksAbove);
2572 fSceneTreeDepthSlider->setMinimumWidth (40);
2574 showBoxLayout->addWidget(zero);
2575 showBoxLayout->addWidget(fSceneTreeDepthSlider);
2576 showBoxLayout->addWidget(one);
2578 showBox->setLayout(showBoxLayout);
2580 helpLayout->addWidget(showBox);
2581 helpWidget->setLayout(helpLayout);
2582 helpLayout->setContentsMargins(0,0,0,0);
2584 vLayout->addWidget(helpWidget);
2586 connect( fSceneTreeDepthSlider, SIGNAL( valueChanged(
int) ),
this, SLOT( changeDepthInSceneTree(
int) ) );
2587 connect( fFilterOutput, SIGNAL( textEdited (
const QString &) ),
this, SLOT(changeSearchSelection()));
2588 fTreeItemModels.clear();
2590 fPVRootNodeCreate =
false;
2592 fMaxPOindexInserted = -1;
2598 void G4OpenGLQtViewer::createViewerPropertiesWidget() {
2601 fUIViewerPropertiesWidget = fUiQt->GetViewerPropertiesWidget();
2603 if (!fUIViewerPropertiesWidget) {
2608 QLayoutItem * wItem;
2609 if (fUIViewerPropertiesWidget->layout()->count()) {
2610 while ((wItem = fUIViewerPropertiesWidget->layout()->takeAt(0)) != 0) {
2611 delete wItem->widget();
2617 QGroupBox *groupBox =
new QGroupBox();
2618 groupBox->setTitle(GetName().
data());
2619 QVBoxLayout *vbox =
new QVBoxLayout;
2622 fViewerPropertiesTableWidget =
new QTableWidget();
2624 QSizePolicy vPolicy = fViewerPropertiesTableWidget->sizePolicy();
2625 vPolicy.setVerticalStretch(4);
2627 vbox->addWidget(fViewerPropertiesTableWidget);
2628 groupBox->setLayout(vbox);
2629 fUIViewerPropertiesWidget->layout()->addWidget(groupBox);
2631 connect(fViewerPropertiesTableWidget, SIGNAL(itemChanged(QTableWidgetItem*)),
this, SLOT(tableWidgetViewerSetItemChanged(QTableWidgetItem *)));
2633 updateViewerPropertiesTableWidget();
2635 QDialog* dial =
static_cast<QDialog*
> (fUIViewerPropertiesWidget->parent());
2638 dial->setWindowTitle(QString(
"Viewer properties - ")+GetName());
2643 void G4OpenGLQtViewer::createPickInfosWidget(){
2646 fUIPickInfosWidget = fUiQt->GetPickInfosWidget();
2648 if (!fUIPickInfosWidget) {
2653 QLayoutItem * wItem;
2654 if (fUIPickInfosWidget->layout()->count()) {
2655 while ((wItem = fUIPickInfosWidget->layout()->takeAt(0)) != 0) {
2656 delete wItem->widget();
2661 QGroupBox *groupBox =
new QGroupBox(
"");
2662 QVBoxLayout *vbox =
new QVBoxLayout;
2665 QWidget *pickingInfoWidget =
new QWidget();
2666 QHBoxLayout *pickingInfoLayout =
new QHBoxLayout();
2668 pickingInfoWidget->setStyleSheet (
"padding-left: 0px; border:0px;");
2669 pickingInfoWidget->setLayout(pickingInfoLayout);
2671 vbox->addWidget(pickingInfoWidget);
2674 fPickInfosScrollArea =
new QScrollArea();
2675 fPickInfosScrollArea->setWidgetResizable(
true);
2678 fPickInfosWidget =
new QWidget();
2679 fPickInfosWidget->setStyleSheet (
"padding: 0px ");
2681 QVBoxLayout* vLayout =
new QVBoxLayout();
2682 fPickInfosWidget->setLayout (vLayout);
2683 fPickInfosScrollArea->setWidget(fPickInfosWidget);
2685 QSizePolicy vPolicy = fPickInfosWidget->sizePolicy();
2686 vPolicy.setVerticalStretch(4);
2687 vbox->addWidget(fPickInfosScrollArea);
2688 pickingInfoLayout->setContentsMargins(0,0,0,0);
2689 vLayout->setContentsMargins(0,0,0,0);
2690 vbox->setContentsMargins(1,1,1,1);
2692 groupBox->setLayout(vbox);
2693 fUIPickInfosWidget->layout()->addWidget(groupBox);
2695 updatePickInfosWidget(fLastPickPoint.x(),fLastPickPoint.y());
2701 void G4OpenGLQtViewer::setCheckComponent(QTreeWidgetItem* item,
bool check)
2705 const PVPath& fullPath = fTreeItemModels[item->data(0,Qt::UserRole).toInt()];
2707 if (fullPath.size() > 0) {
2708 SetTouchable(fullPath);
2709 TouchableSetVisibility(fullPath, check);
2710 fMouseOnSceneTree =
true;
2716 item->setCheckState(0,Qt::Checked);
2718 item->setCheckState(0,Qt::Unchecked);
2720 updatePositivePoIndexSceneTreeWidgetQuickMap(item->data(0,Qt::UserRole).toInt(),item);
2721 int nChildCount = item->childCount();
2722 for (
int i = 0; i < nChildCount; i++) {
2723 setCheckComponent(item->child(i),check);
2729 void G4OpenGLQtViewer::DrawText(
const G4Text& g4text)
2731 QGLWidget* qGLW =
dynamic_cast<QGLWidget*
> (fGLWidget) ;
2735 if (isGl2psWriting()) {
2737 G4OpenGLViewer::DrawText(g4text);
2741 if (!fGLWidget)
return;
2743 #ifdef G4MULTITHREADED
2748 G4double size = fSceneHandler.GetMarkerSize(g4text,sizeType);
2750 QFont font = QFont();
2751 font.setPointSizeF(size);
2753 const G4Colour&
c = fSceneHandler.GetTextColour(g4text);
2759 const char* textCString = textString.c_str();
2761 glRasterPos3d(position.x(),position.y(),position.z());
2764 QFontMetrics* f =
new QFontMetrics (font);
2765 G4double span = f->width(textCString);
2778 ((position.x()+(2*xmove)/getWinWidth()),
2779 (position.y()+(2*ymove)/getWinHeight()),
2788 void G4OpenGLQtViewer::ResetView () {
2789 G4OpenGLViewer::ResetView();
2799 const QString& modelShortName = getModelShortName(model);
2801 if (modelShortName ==
"") {
2805 if (fSceneTreeComponentTreeWidget == NULL) {
2806 createSceneTreeComponent();
2810 if (fSceneTreeComponentTreeWidget == NULL) {
2814 fSceneTreeComponentTreeWidget->blockSignals(
true);
2818 if (!fPVRootNodeCreate) {
2821 fModelShortNameItem = createTreeWidgetItem(pPVModel->
GetFullPVPath(),
2829 fPVRootNodeCreate =
true;
2832 bool added = parseAndInsertInSceneTree(fModelShortNameItem,pPVModel,0,modelShortName,0,currentPOIndex);
2836 fSceneTreeComponentTreeWidget->blockSignals(
false);
2845 QTreeWidgetItem* G4OpenGLQtViewer::createTreeWidgetItem(
2847 ,
const QString& name
2850 ,
const QString& logicalName
2851 ,Qt::CheckState state
2852 ,QTreeWidgetItem * parentTreeNode
2857 if (fullPath.size() > fSceneTreeDepth) {
2858 fSceneTreeDepth = fullPath.size();
2860 if (fSceneTreeDepthSlider) {
2861 fSceneTreeDepthSlider->setTickInterval(1000/(fSceneTreeDepth+1));
2864 QTreeWidgetItem * newItem = NULL;
2865 if (parentTreeNode == NULL) {
2866 newItem =
new QTreeWidgetItem();
2867 fSceneTreeComponentTreeWidget->addTopLevelItem(newItem);
2869 newItem =
new QTreeWidgetItem(parentTreeNode);
2870 fSceneTreeComponentTreeWidget->addTopLevelItem(parentTreeNode);
2874 newItem->setText(0,name);
2875 newItem->setData(1,Qt::UserRole,copyNb);
2876 newItem->setText(2,QString::number(POIndex));
2877 newItem->setData(0, Qt::UserRole, POIndex);
2878 newItem->setText(3,logicalName);
2879 newItem->setFlags(newItem->flags()|Qt::ItemIsUserCheckable);
2880 newItem->setCheckState(0,state);
2881 newItem->setExpanded(
true);
2882 updatePositivePoIndexSceneTreeWidgetQuickMap(POIndex,newItem);
2884 changeQColorForTreeWidgetItem(newItem,QColor((
int)(color.
GetRed()*255),
2890 if ((state == Qt::Unchecked) && (POIndex == -1)) {
2891 newItem->setForeground (0, QBrush(
Qt::gray) );
2894 newItem->setToolTip (0,QString(
2895 "This node exists in the geometry but has not been\n")+
2896 "drawn, perhaps because it has been set invisible. It \n"+
2897 "cannot be made visible with a click on the button.\n"+
2898 "To see it, change the visibility, for example, with \n"+
2899 "/vis/geometry/set/visibility " + logicalName +
" 0 true\n"+
2900 "and rebuild the view with /vis/viewer/rebuild.\n"+
2901 "Click here will only show/hide all child components");
2904 newItem->setToolTip (0,QString(
"double-click to change the color"));
2910 state = Qt::Unchecked;
2911 newItem->setCheckState(0,state);
2912 updatePositivePoIndexSceneTreeWidgetQuickMap(POIndex,newItem);
2915 fTreeItemModels.insert(std::pair <int, PVPath > (POIndex,fullPath) );
2919 changeOpenCloseVisibleHiddenSelectedColorSceneTreeElement(newItem);
2936 bool G4OpenGLQtViewer::parseAndInsertInSceneTree(
2937 QTreeWidgetItem * parentItem
2939 ,
unsigned int fullPathIndex
2940 ,
const QString& parentRoot
2941 ,
unsigned int currentIndexInTreeSceneHandler
2942 ,
int currentPVPOIndex
2945 if (parentItem == NULL) {
2951 std::ostringstream oss;
2952 oss << fullPath.at(fullPathIndex).GetCopyNo();
2953 std::string currentPVName =
G4String(fullPath.at(fullPathIndex).GetPhysicalVolume()->GetName()+
" ["+oss.str()+
"]").
data();
2955 int currentPVCopyNb = fullPath.at(fullPathIndex).GetCopyNo();
2965 QTreeWidgetItem* subItem = NULL;
2966 QList<QTreeWidgetItem *> parentItemList;
2974 if ((currentIndexInTreeSceneHandler == (fullPath.size()-1)) && ((color.
GetAlpha() == 1.))) {
2976 QString lookForString = QString(currentPVName.c_str());
2977 for (
int i = 0;i < parentItem->childCount(); i++ ) {
2978 if (parentItem->child(i)->text(0) == lookForString) {
2979 parentItemList.push_back(parentItem->child(i));
2984 for (
int i = 0; i < parentItemList.size(); ++i) {
2985 const std::string& parentItemName = parentItemList.at(i)->text(0).toStdString();
2986 int parentItemCopyNb = parentItemList.at(i)->data(1,Qt::UserRole).toInt();
2987 int parentItemPOIndex = parentItemList.at(i)->data(0,Qt::UserRole).toInt();
2995 if (((parentRoot == fTouchableVolumes) && (currentPVCopyNb == parentItemCopyNb)
2996 && (currentPVName == parentItemName)) ||
2998 ((parentRoot != fTouchableVolumes) && (currentPVCopyNb == parentItemCopyNb)
3000 && (currentPVName == parentItemName) && (currentPVPOIndex == parentItemPOIndex) )) {
3003 bool sameTransform =
true;
3004 if (parentItemPOIndex >= 0) {
3005 const PVPath& fullPathTmp = fTreeItemModels[parentItemPOIndex];
3006 if (fullPathTmp.size() > 0) {
3007 if (fullPathTmp.at(fullPathTmp.size()-1).GetTransform () == pPVModel->
GetTransformation ()) {
3008 sameTransform =
true;
3010 sameTransform =
false;
3016 if (sameTransform ==
true) {
3023 if (currentIndexInTreeSceneHandler == (fullPath.size()-1)) {
3025 parentItemList.at(i)->setText(2,QString::number(currentPVPOIndex));
3026 parentItemList.at(i)->setData(0, Qt::UserRole,currentPVPOIndex);
3028 fTreeItemModels.insert(std::pair <int, PVPath >(currentPVPOIndex,fullPath) );
3032 parentItemList.at(i)->setFont (0,f);
3035 parentItemList.at(i)->setForeground (0,QBrush());
3038 parentItemList.at(i)->setToolTip (0,
"");
3040 changeQColorForTreeWidgetItem(parentItemList.at(i),QColor((
int)(color.
GetRed()*255),
3047 parentItemList.at(i)->setCheckState(0,Qt::Checked);
3048 updatePositivePoIndexSceneTreeWidgetQuickMap(currentPVPOIndex,parentItemList.at(i));
3052 subItem = parentItemList.at(i);
3056 }
else if (currentIndexInTreeSceneHandler < (fullPath.size()-1)) {
3057 subItem = parentItemList.at(i);
3064 if (currentIndexInTreeSceneHandler == (fullPath.size()-1)) {
3065 createTreeWidgetItem(fullPath,
3066 QString(currentPVName.c_str()),
3069 QString(fullPath.at(fullPathIndex).GetPhysicalVolume()->GetLogicalVolume()->GetName().data()),
3074 if (currentPVPOIndex > fMaxPOindexInserted) {
3075 fMaxPOindexInserted = currentPVPOIndex;
3081 if (subItem == NULL) {
3083 if (currentIndexInTreeSceneHandler < (fullPath.size()-1)) {
3084 subItem = createTreeWidgetItem(fullPath,
3085 QString(currentPVName.c_str()),
3088 QString(fullPath.at(fullPathIndex).GetPhysicalVolume()->GetLogicalVolume()->GetName().data()),
3095 return parseAndInsertInSceneTree(subItem,pPVModel,fullPathIndex+1,parentRoot,currentIndexInTreeSceneHandler+1,currentPVPOIndex);
3101 void G4OpenGLQtViewer::changeOpenCloseVisibleHiddenSelectedColorSceneTreeElement(
3102 QTreeWidgetItem* subItem
3106 QTreeWidgetItem* oldItem = NULL;
3108 QTreeWidgetItem* foundItem = getOldTreeWidgetItem(subItem->data(0,Qt::UserRole).toInt());
3110 if (foundItem != NULL) {
3111 if (isSameSceneTreeElement(foundItem,subItem)) {
3112 oldItem = foundItem;
3115 if (foundItem == NULL) {
3118 std::map <int, QTreeWidgetItem*>::const_iterator i;
3119 i = fOldPositivePoIndexSceneTreeWidgetQuickMap.begin();
3120 while (i != fOldPositivePoIndexSceneTreeWidgetQuickMap.end()) {
3121 if (isSameSceneTreeElement(i->second,subItem)) {
3122 oldItem = i->second;
3123 i = fOldPositivePoIndexSceneTreeWidgetQuickMap.end();
3129 if (oldItem == NULL) {
3131 while (a < fOldNullPoIndexSceneTreeWidgetQuickVector.size()) {
3132 if (isSameSceneTreeElement(fOldNullPoIndexSceneTreeWidgetQuickVector[a],subItem)) {
3133 oldItem = fOldNullPoIndexSceneTreeWidgetQuickVector[
a];
3134 a = fOldNullPoIndexSceneTreeWidgetQuickVector.size();
3143 if (oldItem != NULL) {
3144 subItem->setFlags(oldItem->flags());
3145 subItem->setCheckState(0,oldItem->checkState(0));
3146 subItem->setSelected(oldItem->isSelected());
3147 subItem->setExpanded(oldItem->isExpanded ());
3152 std::map <int, QTreeWidgetItem* >::iterator it;
3155 int oldPOIndex = oldItem->data(0,Qt::UserRole).toInt();
3156 it = fOldPositivePoIndexSceneTreeWidgetQuickMap.find(oldPOIndex);
3160 std::map <int, QColor >::iterator itVis;
3161 itVis = fOldVisAttrColorMap.find(oldPOIndex);
3163 QColor oldVisAttrColor;
3164 const QColor& newVisAttrColor = subItem->data(2,Qt::UserRole).value<QColor>();
3166 bool visAttrChange =
false;
3168 if (itVis != fOldVisAttrColorMap.end()) {
3169 oldVisAttrColor = itVis->second;
3170 if (oldVisAttrColor != newVisAttrColor) {
3171 visAttrChange =
true;
3174 visAttrChange =
true;
3177 if (visAttrChange) {
3178 fOldVisAttrColorMap.insert(std::pair <int, QColor > (subItem->data(0,Qt::UserRole).toInt(),newVisAttrColor) );
3182 if (it != fOldPositivePoIndexSceneTreeWidgetQuickMap.end()) {
3183 color = (it->second)->
data(2,Qt::UserRole).value<QColor>();
3185 color = oldItem->data(2,Qt::UserRole).value<QColor>();
3187 changeQColorForTreeWidgetItem(subItem,color);
3199 bool G4OpenGLQtViewer::isSameSceneTreeElement(
3200 QTreeWidgetItem* parentOldItem
3201 ,QTreeWidgetItem* parentNewItem
3207 int newCpNumber = -1;
3208 int oldCpNumber = -1;
3210 bool firstWhile =
true;
3212 while ((parentOldItem != NULL) && (parentNewItem != NULL)) {
3216 oldPO = parentOldItem->data(0,Qt::UserRole).toInt();
3217 newPO = parentNewItem->data(0,Qt::UserRole).toInt();
3223 const PVPath& oldFullPath = fOldTreeItemModels[oldPO];
3224 const PVPath& newFullPath = fTreeItemModels[newPO];
3225 if ((oldFullPath.size() > 0) &&
3226 (newFullPath.size() > 0)) {
3227 if (oldFullPath.size() != newFullPath.size()) {
3230 if (oldFullPath.at(oldFullPath.size()-1).GetTransform () == newFullPath.at(newFullPath.size()-1).GetTransform ()) {
3231 newCpNumber = newFullPath.at(newFullPath.size()-1).GetCopyNo();
3232 oldCpNumber = oldFullPath.at(oldFullPath.size()-1).GetCopyNo();
3241 if (oldCpNumber == -1) {
3242 oldCpNumber = parentOldItem->data(1,Qt::UserRole).toInt();
3244 if (newCpNumber == -1) {
3245 newCpNumber = parentNewItem->data(1,Qt::UserRole).toInt();
3247 if ((oldCpNumber != newCpNumber) ||
3249 (parentOldItem->text(0) != parentNewItem->text(0)) ) {
3252 }
else if ((parentOldItem->text(0) != parentNewItem->text(0)) ||
3253 (parentOldItem->text(3) != parentNewItem->text(3))) {
3256 parentOldItem = parentOldItem->parent();
3257 parentNewItem = parentNewItem->parent();
3265 void G4OpenGLQtViewer::addNonPVSceneTreeElement(
3268 ,
const std::string& modelDescription
3272 QString modelShortName = getModelShortName(model);
3277 const G4Text& g4Text =
dynamic_cast<const G4Text&
>(visible);
3278 color = fSceneHandler.GetTextColour(g4Text);
3280 catch (std::bad_cast) {
3283 if (modelShortName ==
"") {
3287 if (fSceneTreeComponentTreeWidget == NULL) {
3288 createSceneTreeComponent();
3292 if (fSceneTreeComponentTreeWidget == NULL) {
3296 fSceneTreeComponentTreeWidget->blockSignals(
true);
3300 QList<QTreeWidgetItem *> resItem;
3301 resItem = fSceneTreeComponentTreeWidget->findItems (modelShortName, Qt::MatchExactly, 0 );
3302 QTreeWidgetItem * currentItem = NULL;
3303 const PVPath tmpFullPath;
3305 if (resItem.empty()) {
3306 currentItem = createTreeWidgetItem(tmpFullPath,
3315 currentItem = resItem.first();
3319 const QList<QTreeWidgetItem *>&
3320 resItems = fSceneTreeComponentTreeWidget->findItems (QString(modelDescription.c_str()), Qt::MatchFixedString| Qt::MatchCaseSensitive|Qt::MatchRecursive, 0 );
3322 bool alreadyPresent =
false;
3323 for (
int i = 0; i < resItems.size(); ++i) {
3324 if (currentPOIndex == resItems.at(i)->data(0,Qt::UserRole).toInt()) {
3325 alreadyPresent =
true;
3328 if (!alreadyPresent) {
3329 createTreeWidgetItem(tmpFullPath,
3330 QString(modelDescription.c_str()),
3338 fSceneTreeComponentTreeWidget->blockSignals(
false);
3346 QString G4OpenGLQtViewer::getModelShortName(
const G4String& model) {
3348 QString modelShortName = model.
data();
3349 if (modelShortName.mid(0,modelShortName.indexOf(
" ")) ==
"G4PhysicalVolumeModel") {
3350 modelShortName = fTouchableVolumes;
3352 if (modelShortName.mid(0,2) ==
"G4") {
3353 modelShortName = modelShortName.mid(2);
3355 if (modelShortName.indexOf(
"Model") != -1) {
3356 modelShortName = modelShortName.mid(0,modelShortName.indexOf(
"Model"));
3359 return modelShortName;
3364 bool G4OpenGLQtViewer::isTouchableVisible(
int POindex){
3367 if (fSceneTreeComponentTreeWidget == NULL) {
3373 if (fLastSceneTreeWidgetAskForIterator != fLastSceneTreeWidgetAskForIteratorEnd) {
3374 fLastSceneTreeWidgetAskForIterator++;
3376 QTreeWidgetItem* item = getTreeWidgetItem(POindex);
3379 if ( item->checkState(0) == Qt::Checked) {
3387 bool G4OpenGLQtViewer::parseAndCheckVisibility(QTreeWidgetItem * treeNode,
int POindex){
3388 bool isFound =
false;
3389 for (
int i = 0; i < treeNode->childCount() ; ++i) {
3391 if (treeNode->child(i)->data(0,Qt::UserRole).toInt() == POindex) {
3392 if (treeNode->child(i)->checkState(0) == Qt::Checked) {
3396 isFound = parseAndCheckVisibility(treeNode->child(i),POindex);
3405 std::string G4OpenGLQtViewer::parseSceneTreeAndSaveState(){
3406 std::string commandLine =
"";
3407 for (
int b=0;
b<fSceneTreeComponentTreeWidget->topLevelItemCount();
b++) {
3408 commandLine += parseSceneTreeElementAndSaveState(fSceneTreeComponentTreeWidget->topLevelItem(
b),1)+
"\n";
3410 if (commandLine !=
"") {
3411 commandLine = std::string(
"# Disable auto refresh and quieten vis messages whilst scene and\n") +
3412 "# trajectories are established:\n" +
3413 "/vis/viewer/set/autoRefresh false\n" +
3414 "/vis/verbose errors" +
3416 "# Re-establish auto refreshing and verbosity:\n" +
3417 "/vis/viewer/set/autoRefresh true\n" +
3418 "/vis/verbose confirmations\n";
3424 std::string G4OpenGLQtViewer::parseSceneTreeElementAndSaveState(QTreeWidgetItem* item,
unsigned int level){
3426 std::string str( level,
' ' );
3427 std::string commandLine =
"\n#"+ str +
"PV Name: " + item->text(0).toStdString();
3429 if (item->text(3) !=
"") {
3430 commandLine +=
" LV Name: "+item->text(3).toStdString()+
"\n";
3432 commandLine +=
"/vis/geometry/set/visibility " + item->text(3).toStdString() +
" ! ";
3433 if (item->checkState(0) == Qt::Checked) {
3436 if (item->checkState(0) == Qt::Unchecked) {
3442 const QColor& c = item->data(2,Qt::UserRole).value<QColor>();
3443 std::stringstream
red;
3444 red << ((double)c.red())/255;
3445 std::stringstream green;
3446 green << (double)c.green()/255;
3447 std::stringstream
blue;
3448 blue << ((double)c.blue())/255;
3449 std::stringstream
alpha;
3450 alpha << ((double)c.alpha())/255;
3452 commandLine +=
"/vis/geometry/set/colour " + item->text(3).toStdString() +
" ! " + red.str() +
" " + green.str() +
" " + blue.str() +
" " + alpha.str()+
"\n";
3455 commandLine +=
"\n";
3459 for (
int b=0;
b< item->childCount();
b++) {
3460 commandLine += parseSceneTreeElementAndSaveState(item->child(
b),level+1);
3467 void G4OpenGLQtViewer::sceneTreeComponentItemChanged(QTreeWidgetItem* item,
int) {
3469 if (fCheckSceneTreeComponentSignalLock ==
false) {
3470 fCheckSceneTreeComponentSignalLock =
true;
3472 if (item->checkState(0) == Qt::Checked) {
3475 setCheckComponent(item,checked);
3478 fCheckSceneTreeComponentSignalLock =
false;
3483 void G4OpenGLQtViewer::sceneTreeComponentSelected() {
3486 void G4OpenGLQtViewer::changeDepthInSceneTree (
int val){
3489 if (fSceneTreeComponentTreeWidget == NULL) {
3500 double depth = 1 + ((double)val)/1000 * ((double)fSceneTreeDepth+1);
3503 fCheckSceneTreeComponentSignalLock =
true;
3506 G4bool currentAutoRefresh = fVP.IsAutoRefresh();
3507 fVP.SetAutoRefresh(
false);
3509 for (
int b=0;
b<fSceneTreeComponentTreeWidget->topLevelItemCount();
b++) {
3510 changeDepthOnSceneTreeItem(depth,1.,fSceneTreeComponentTreeWidget->topLevelItem(
b));
3514 fVP.SetAutoRefresh(currentAutoRefresh);
3518 fCheckSceneTreeComponentSignalLock =
false;
3523 void G4OpenGLQtViewer::changeColorAndTransparency(QTreeWidgetItem* item,
int) {
3528 const QColor& old = QColor(item->data(2,Qt::UserRole).value<QColor>());
3530 #if QT_VERSION < 0x040500
3532 const QColor& color = QColor(QColorDialog::getRgba (old.rgba(),&
a,fSceneTreeComponentTreeWidget));
3534 const QColor& color = QColorDialog::getColor(old,
3535 fSceneTreeComponentTreeWidget,
3536 " Get color and transparency",
3537 QColorDialog::ShowAlphaChannel);
3540 if (color.isValid()) {
3542 changeColorAndTransparency(item->data(0,Qt::UserRole).toInt(),
3549 changeQColorForTreeWidgetItem(item,color);
3554 void G4OpenGLQtViewer::changeColorAndTransparency(GLuint index,
G4Color color) {
3558 if (iPO >= 0 && fTreeItemModels.find(iPO) != fTreeItemModels.end()) {
3559 const PVPath& fullPath = fTreeItemModels[iPO];
3561 if (fullPath.size()) {
3562 SetTouchable(fullPath);
3563 TouchableSetColour(fullPath, color);
3564 fMouseOnSceneTree =
true;
3570 G4Colour G4OpenGLQtViewer::getColorForPoIndex(
int poIndex) {
3572 QTreeWidgetItem* item = getTreeWidgetItem(poIndex);
3576 const QColor& color = item->data(2,Qt::UserRole).value<QColor>();
3589 G4OpenGLQtViewer::GetPrivateVisAttributesModifiers()
const
3591 static std::vector<G4ModelingParameters::VisAttributesModifier>
3592 privateVisAttributesModifiers;
3594 privateVisAttributesModifiers.clear();
3647 return &privateVisAttributesModifiers;
3651 void G4OpenGLQtViewer::changeSearchSelection()
3653 const QString& searchText = fFilterOutput->text();
3654 if (fSceneTreeComponentTreeWidget == NULL) {
3659 for (
int a=0; a<fSceneTreeComponentTreeWidget->topLevelItemCount(); a++) {
3660 fSceneTreeComponentTreeWidget->topLevelItem(a)->setExpanded(
false);
3661 fSceneTreeComponentTreeWidget->topLevelItem(a)->setSelected(
false);
3662 clearSceneTreeSelection(fSceneTreeComponentTreeWidget->topLevelItem(a));
3665 QList<QTreeWidgetItem *> itemList = fSceneTreeComponentTreeWidget->findItems (searchText,Qt::MatchContains | Qt::MatchRecursive,0);
3667 for (
int i = 0; i < itemList.size(); ++i) {
3668 QTreeWidgetItem* expandParentItem = itemList.at(i);
3669 while (expandParentItem->parent() != NULL) {
3670 expandParentItem->parent()->setExpanded(
true);
3671 expandParentItem = expandParentItem->parent();
3673 itemList.at(i)->setSelected(
true);
3679 void G4OpenGLQtViewer::clearSceneTreeSelection(QTreeWidgetItem* item) {
3680 for (
int a=0; a<item->childCount(); a++) {
3681 item->child(a)->setSelected(
false);
3682 item->child(a)->setExpanded(
false);
3683 clearSceneTreeSelection(item->child(a));
3689 bool G4OpenGLQtViewer::isPVVolume(QTreeWidgetItem* item) {
3690 QTreeWidgetItem* sParent = item;
3691 while (sParent->parent() != NULL) {
3692 sParent = sParent->parent();
3694 if (sParent->text(0) != fTouchableVolumes) {
3698 if (item->text(0) == fTouchableVolumes) {
3705 void G4OpenGLQtViewer::changeDepthOnSceneTreeItem(
3707 ,
double currentDepth
3708 ,QTreeWidgetItem* item
3710 double transparencyLevel = 0.;
3715 if (isPVVolume(item)) {
3716 if ((lookForDepth-currentDepth) < 0) {
3717 item->setCheckState(0,Qt::Checked);
3718 updatePositivePoIndexSceneTreeWidgetQuickMap(item->data(0,Qt::UserRole).toInt(),item);
3719 transparencyLevel = 1;
3720 }
else if ((lookForDepth-currentDepth) > 1 ){
3721 item->setCheckState(0,Qt::Unchecked);
3722 updatePositivePoIndexSceneTreeWidgetQuickMap(item->data(0,Qt::UserRole).toInt(),item);
3723 transparencyLevel = 0;
3725 item->setCheckState(0,Qt::Checked);
3726 updatePositivePoIndexSceneTreeWidgetQuickMap(item->data(0,Qt::UserRole).toInt(),item);
3727 transparencyLevel = 1-(lookForDepth-currentDepth);
3731 if (item->data(0,Qt::UserRole).toInt() >= 0) {
3732 const G4Colour& color = getColorForPoIndex(item->data(0,Qt::UserRole).toInt());
3744 if (((color.
GetAlpha()-transparencyLevel) > 0.000001) ||
3745 ((color.
GetAlpha()-transparencyLevel) < -0.000001)) {
3746 if ((item->text(3) !=
"")) {
3752 changeQColorForTreeWidgetItem(item,QColor((
int)(color.
GetRed()*255),
3755 (
int)(transparencyLevel*255)));
3760 for (
int b=0;
b< item->childCount();
b++) {
3761 changeDepthOnSceneTreeItem(lookForDepth,currentDepth+1,item->child(
b));
3766 void G4OpenGLQtViewer::clearTreeWidget(){
3769 if (fSceneTreeComponentTreeWidget) {
3771 if (fSceneTreeComponentTreeWidget->topLevelItemCount () > 0) {
3773 fPVRootNodeCreate =
false;
3776 fOldPositivePoIndexSceneTreeWidgetQuickMap.clear();
3777 fOldNullPoIndexSceneTreeWidgetQuickVector.clear();
3778 fOldTreeItemModels.clear();
3781 for (
int b =0;
b <fSceneTreeComponentTreeWidget->topLevelItemCount();
b++) {
3790 int poIndex = fSceneTreeComponentTreeWidget->topLevelItem(
b)->data(0,Qt::UserRole).toInt();
3791 if (poIndex != -1) {
3792 fOldPositivePoIndexSceneTreeWidgetQuickMap.insert(std::pair <int, QTreeWidgetItem*> (poIndex,cloneWidgetItem(fSceneTreeComponentTreeWidget->topLevelItem(
b))));
3794 fOldNullPoIndexSceneTreeWidgetQuickVector.push_back(cloneWidgetItem(fSceneTreeComponentTreeWidget->topLevelItem(
b)));
3798 cloneSceneTree(fSceneTreeComponentTreeWidget->topLevelItem(
b));
3802 fOldTreeItemModels.insert(fTreeItemModels.begin(), fTreeItemModels.end());
3805 int tmp2 = fSceneTreeComponentTreeWidget->topLevelItemCount();
3807 delete fSceneTreeComponentTreeWidget->takeTopLevelItem (0);
3808 tmp2 = fSceneTreeComponentTreeWidget->topLevelItemCount();
3810 fPositivePoIndexSceneTreeWidgetQuickMap.clear();
3813 fOldLastSceneTreeWidgetAskForIterator = fOldPositivePoIndexSceneTreeWidgetQuickMap.begin();
3814 fOldLastSceneTreeWidgetAskForIteratorEnd = fOldPositivePoIndexSceneTreeWidgetQuickMap.end();
3815 fSceneTreeDepth = 1;
3816 fModelShortNameItem = NULL;
3817 fMaxPOindexInserted = -1;
3830 QTreeWidgetItem * G4OpenGLQtViewer::cloneWidgetItem(QTreeWidgetItem* item) {
3832 QTreeWidgetItem* cloneItem =
new QTreeWidgetItem();
3836 cloneItem->setText(0,item->text(0));
3837 cloneItem->setData(1,Qt::UserRole,item->data(1,Qt::UserRole).toInt());
3838 cloneItem->setText(2,item->text(2));
3839 cloneItem->setData(0, Qt::UserRole,item->data(0,Qt::UserRole).toInt());
3840 cloneItem->setText(3,item->text(3));
3841 cloneItem->setFlags(item->flags());
3842 cloneItem->setToolTip(0,item->toolTip(0));
3843 cloneItem->setCheckState(0,item->checkState(0));
3844 cloneItem->setSelected(item->isSelected());
3845 cloneItem->setExpanded(item->isExpanded ());
3847 cloneItem->setData(2,Qt::UserRole,item->data(2,Qt::UserRole).value<QColor>());
3856 void G4OpenGLQtViewer::cloneSceneTree(
3857 QTreeWidgetItem* rootItem
3860 for (
int b=0;
b< rootItem->childCount();
b++) {
3862 QTreeWidgetItem *child = rootItem->child(
b);
3865 int poIndex = child->data(0,Qt::UserRole).toInt();
3866 if (poIndex != -1) {
3867 fOldPositivePoIndexSceneTreeWidgetQuickMap.insert(std::pair <int, QTreeWidgetItem*> (poIndex,cloneWidgetItem(child)));
3869 fOldNullPoIndexSceneTreeWidgetQuickVector.push_back(cloneWidgetItem(child));
3871 cloneSceneTree(child);
3879 void G4OpenGLQtViewer::updatePositivePoIndexSceneTreeWidgetQuickMap(
int POindex,QTreeWidgetItem* item) {
3882 std::map <int, QTreeWidgetItem*>::iterator i;
3883 i = fPositivePoIndexSceneTreeWidgetQuickMap.find(POindex);
3885 if (i == fPositivePoIndexSceneTreeWidgetQuickMap.end()) {
3886 fPositivePoIndexSceneTreeWidgetQuickMap.insert(std::pair <int, QTreeWidgetItem*> (POindex,item) );
3887 fLastSceneTreeWidgetAskForIterator = fPositivePoIndexSceneTreeWidgetQuickMap.end();
3888 fLastSceneTreeWidgetAskForIteratorEnd = fPositivePoIndexSceneTreeWidgetQuickMap.end();
3896 void G4OpenGLQtViewer::changeQColorForTreeWidgetItem(QTreeWidgetItem* item,
const QColor& qc) {
3898 int POIndex = item->data(0,Qt::UserRole).toInt();
3899 updatePositivePoIndexSceneTreeWidgetQuickMap(POIndex,item );
3901 QPixmap pixmap = QPixmap(QSize(16, 16));
3902 if (item->data(0,Qt::UserRole).toInt() != -1) {
3905 pixmap.fill (QColor(255,255,255,255));
3907 QPainter painter(&pixmap);
3908 painter.setPen(Qt::black);
3909 painter.drawRect(0,0,15,15);
3911 item->setIcon(0,pixmap);
3912 item->setData(2,Qt::UserRole,qc);
3921 QTreeWidgetItem* G4OpenGLQtViewer::getTreeWidgetItem(
int POindex){
3924 if (POindex == -1) {
3928 if (fPositivePoIndexSceneTreeWidgetQuickMap.size() == 0){
3932 if (fLastSceneTreeWidgetAskForIterator != fLastSceneTreeWidgetAskForIteratorEnd) {
3933 if (POindex == fLastSceneTreeWidgetAskForIterator->first) {
3934 if (fLastSceneTreeWidgetAskForIterator->second != NULL) {
3935 return fLastSceneTreeWidgetAskForIterator->second;
3941 fLastSceneTreeWidgetAskForIterator = fPositivePoIndexSceneTreeWidgetQuickMap.find(POindex);
3942 fLastSceneTreeWidgetAskForIteratorEnd = fPositivePoIndexSceneTreeWidgetQuickMap.end();
3944 if (fLastSceneTreeWidgetAskForIterator != fPositivePoIndexSceneTreeWidgetQuickMap.end()) {
3945 return fLastSceneTreeWidgetAskForIterator->second;
3954 QTreeWidgetItem* G4OpenGLQtViewer::getOldTreeWidgetItem(
int POindex){
3958 if (POindex == -1) {
3962 if (fOldPositivePoIndexSceneTreeWidgetQuickMap.size() == 0){
3968 if (fOldLastSceneTreeWidgetAskForIterator != fOldLastSceneTreeWidgetAskForIteratorEnd) {
3969 fOldLastSceneTreeWidgetAskForIterator++;
3972 if (fOldLastSceneTreeWidgetAskForIterator != fOldPositivePoIndexSceneTreeWidgetQuickMap.end()) {
3973 if (POindex == fOldLastSceneTreeWidgetAskForIterator->first) {
3974 if (fOldLastSceneTreeWidgetAskForIterator->second != NULL) {
3975 return fOldLastSceneTreeWidgetAskForIterator->second;
3981 fOldLastSceneTreeWidgetAskForIterator = fOldPositivePoIndexSceneTreeWidgetQuickMap.find(POindex);
3982 fOldLastSceneTreeWidgetAskForIteratorEnd = fOldPositivePoIndexSceneTreeWidgetQuickMap.end();
3984 if (fOldLastSceneTreeWidgetAskForIterator != fOldPositivePoIndexSceneTreeWidgetQuickMap.end()) {
3985 return fOldLastSceneTreeWidgetAskForIterator->second;
3996 void G4OpenGLQtViewer::displaySceneTreeComponent() {
3998 if (fUISceneTreeWidget == NULL) {
4001 if (fSceneTreeComponentTreeWidget == NULL) {
4006 fSceneTreeComponentTreeWidget->sortItems (0, Qt::AscendingOrder );
4018 void G4OpenGLQtViewer::updateToolbarAndMouseContextMenu(){
4024 d_style = fVP.GetDrawingStyle();
4028 if (fUiQt) fUiQt->SetIconWireframeSelected();
4030 fDrawingWireframe->setChecked(
true);
4031 fDrawingLineRemoval->setChecked(
false);
4032 fDrawingSurfaceRemoval->setChecked(
false);
4033 fDrawingLineSurfaceRemoval->setChecked(
false);
4036 if (fUiQt) fUiQt->SetIconHLRSelected();
4038 fDrawingLineRemoval->setChecked(
true);
4039 fDrawingWireframe->setChecked(
false);
4040 fDrawingSurfaceRemoval->setChecked(
false);
4041 fDrawingLineSurfaceRemoval->setChecked(
false);
4044 if (fUiQt) fUiQt->SetIconSolidSelected();
4046 fDrawingSurfaceRemoval->setChecked(
true);
4047 fDrawingWireframe->setChecked(
false);
4048 fDrawingLineRemoval->setChecked(
false);
4049 fDrawingLineSurfaceRemoval->setChecked(
false);
4052 if (fUiQt) fUiQt->SetIconHLHSRSelected();
4054 fDrawingLineSurfaceRemoval->setChecked(
true);
4055 fDrawingWireframe->setChecked(
false);
4056 fDrawingLineRemoval->setChecked(
false);
4057 fDrawingSurfaceRemoval->setChecked(
false);
4058 fDrawingLineSurfaceRemoval->setChecked(
false);
4064 G4double d_proj = fVP.GetFieldHalfAngle () ;
4066 if (fUiQt) fUiQt->SetIconOrthoSelected();
4068 fProjectionOrtho->setChecked(
true);
4069 fProjectionPerspective->setChecked(
false);
4072 if (fUiQt) fUiQt->SetIconPerspectiveSelected();
4074 fProjectionPerspective->setChecked(
true);
4075 fProjectionOrtho->setChecked(
false);
4081 if (fUiQt && fContextMenu) {
4082 if (fUiQt->IsIconPickSelected()) {
4083 fMousePickAction->setChecked(
true);
4084 fMouseZoomOutAction->setChecked(
false);
4085 fMouseZoomInAction->setChecked(
false);
4086 fMouseRotateAction->setChecked(
false);
4087 fMouseMoveAction->setChecked(
false);
4088 }
else if (fUiQt->IsIconZoomOutSelected()) {
4089 fMouseZoomOutAction->setChecked(
true);
4090 fMousePickAction->setChecked(
false);
4091 fMouseZoomInAction->setChecked(
false);
4092 fMouseRotateAction->setChecked(
false);
4093 fMouseMoveAction->setChecked(
false);
4094 }
else if (fUiQt->IsIconZoomInSelected()) {
4095 fMouseZoomInAction->setChecked(
true);
4096 fMousePickAction->setChecked(
false);
4097 fMouseZoomOutAction->setChecked(
false);
4098 fMouseRotateAction->setChecked(
false);
4099 fMouseMoveAction->setChecked(
false);
4100 }
else if (fUiQt->IsIconRotateSelected()) {
4101 fMouseRotateAction->setChecked(
true);
4102 fMousePickAction->setChecked(
false);
4103 fMouseZoomOutAction->setChecked(
false);
4104 fMouseZoomInAction->setChecked(
false);
4105 fMouseMoveAction->setChecked(
false);
4106 }
else if (fUiQt->IsIconMoveSelected()) {
4107 fMouseMoveAction->setChecked(
true);
4108 fMousePickAction->setChecked(
false);
4109 fMouseZoomOutAction->setChecked(
false);
4110 fMouseZoomInAction->setChecked(
false);
4111 fMouseRotateAction->setChecked(
false);
4119 void G4OpenGLQtViewer::updateSceneTreeWidget() {
4121 if (!fSceneTreeWidget) {
4122 createSceneTreeWidget();
4131 void G4OpenGLQtViewer::updateViewerPropertiesTableWidget() {
4133 if (!isCurrentWidget()) {
4138 if (!fViewerPropertiesTableWidget) {
4139 createViewerPropertiesWidget();
4141 int treeWidgetInfosIgnoredCommands = 0;
4151 if ((path->
GetCommandEntry()-fTreeWidgetInfosIgnoredCommands) != fViewerPropertiesTableWidget->rowCount()) {
4152 fViewerPropertiesTableWidget->clear();
4155 fViewerPropertiesTableWidget->blockSignals(
true);
4158 fViewerPropertiesTableWidget->setColumnCount (2);
4159 fViewerPropertiesTableWidget->setRowCount (path->
GetCommandEntry()-fTreeWidgetInfosIgnoredCommands);
4160 fViewerPropertiesTableWidget->setHorizontalHeaderLabels(QStringList() << tr(
"Property")
4162 fViewerPropertiesTableWidget->verticalHeader()->setVisible(
false);
4163 fViewerPropertiesTableWidget->setAlternatingRowColors (
true);
4171 QString params =
"";
4174 if (fVP.IsAutoRefresh()) {
4180 if (fVP.IsAuxEdgeVisible()) {
4186 params = QString().number(fVP.GetBackgroundColour().GetRed()) +
" "+
4187 QString().number(fVP.GetBackgroundColour().GetGreen()) +
" "+
4188 QString().number(fVP.GetBackgroundColour().GetBlue()) +
" "+
4189 QString().number(fVP.GetBackgroundColour().GetAlpha());
4192 params = QString().number(fVP. IsCulling ());
4197 params =
"intersection";
4201 params = QString().number(fVP.GetDefaultVisAttributes()->GetColor().GetRed()) +
" "+
4202 QString().number(fVP.GetDefaultVisAttributes()->GetColor().GetGreen()) +
" "+
4203 QString().number(fVP.GetDefaultVisAttributes()->GetColor().GetBlue()) +
" "+
4204 QString().number(fVP.GetDefaultVisAttributes()->GetColor().GetAlpha());
4207 params = QString().number(fVP.GetDefaultTextVisAttributes()->GetColor().GetRed()) +
" "+
4208 QString().number(fVP.GetDefaultTextVisAttributes()->GetColor().GetGreen()) +
" "+
4209 QString().number(fVP.GetDefaultTextVisAttributes()->GetColor().GetBlue()) +
" "+
4210 QString().number(fVP.GetDefaultTextVisAttributes()->GetColor().GetAlpha());
4220 params = QString().number(fVP.GetExplodeFactor()) +
" " + QString(
G4String(
G4BestUnit(fVP.GetExplodeFactor(),
"Length")).
data());
4222 }
else if(commandTmp->
GetCommandName() ==
"globalLineWidthScale") {
4223 params = QString().number(fVP.GetGlobalLineWidthScale());
4226 params = QString().number(fVP.GetGlobalMarkerScale());
4238 if (fVP.IsMarkerNotHidden()) {
4245 if (fVP.GetLightsMoveWithCamera()) {
4251 G4Vector3D direction = fVP.GetLightpointDirection();
4260 params = QString().number(fVP.GetLightpointDirection().x()) +
" "+
4261 QString().number(fVP.GetLightpointDirection().y()) +
" "+
4262 QString().number(fVP.GetLightpointDirection().z());
4264 }
else if(commandTmp->
GetCommandName() ==
"lineSegmentsPerCircle") {
4265 params = QString().number(fVP.GetNoOfSides());
4268 if (fVP.IsPicking()) {
4275 if (fVP.GetFieldHalfAngle() == 0.) {
4276 params =
"orthogonal";
4278 params = QString(
"perspective ") + QString().number(fVP.GetFieldHalfAngle()/
CLHEP::degree) +
" deg";
4283 params =
"constrainUpDirection";
4285 params =
"freeRotation";
4289 if (fVP.IsSection()) {
4290 params = QString(
"on ") +
4292 QString().number(fVP.GetSectionPlane().normal().x())
4293 +
" " + QString().number(fVP.GetSectionPlane().normal().y())
4294 +
" " + QString().number(fVP.GetSectionPlane().normal().z());
4301 params =
"wireframe";
4308 G4Point3D point = fVP.GetCurrentTargetPoint();
4309 if (fSceneHandler.GetScene()) {
4310 G4String b =
G4BestUnit(fSceneHandler.GetScene()->GetStandardTargetPoint() + fVP.GetCurrentTargetPoint(),
"Length");
4324 params = QString().number(up.
x())+
" "+ QString().number(up.
y())+
" "+QString().number(up.
z())+
" ";
4327 G4Vector3D direction = fVP.GetViewpointDirection();
4336 G4Vector3D direction = fVP.GetViewpointDirection();
4337 params = QString().number(direction.
x())+
" "+ QString().number(direction.
y())+
" "+QString().number(direction.
z());
4367 QTableWidgetItem *nameItem;
4368 QTableWidgetItem *paramItem;
4371 QList<QTableWidgetItem *> list = fViewerPropertiesTableWidget->findItems (commandTmp->
GetCommandName().
data(),Qt::MatchExactly);
4372 if (list.size() == 1) {
4373 nameItem = list.first();
4374 paramItem = fViewerPropertiesTableWidget->item(nameItem->row(),1);
4377 nameItem =
new QTableWidgetItem();
4378 paramItem =
new QTableWidgetItem();
4379 fViewerPropertiesTableWidget->setItem(a-treeWidgetInfosIgnoredCommands, 0, nameItem);
4380 fViewerPropertiesTableWidget->setItem(a-treeWidgetInfosIgnoredCommands, 1, paramItem);
4385 for(
G4int i_thGuidance=0; i_thGuidance < n_guidanceEntry; i_thGuidance++ ) {
4389 nameItem->setToolTip(guidance);
4390 paramItem->setToolTip(GetCommandParameterList(commandTmp));
4392 fViewerPropertiesTableWidget->setRowHeight(a-treeWidgetInfosIgnoredCommands,15);
4397 paramItem->setText(params);
4399 nameItem->setFlags(Qt::NoItemFlags);
4400 nameItem->setForeground(QBrush());
4403 treeWidgetInfosIgnoredCommands++;
4407 for (
int i=0; i<treeWidgetInfosIgnoredCommands; i++) {
4408 fViewerPropertiesTableWidget->removeRow (fViewerPropertiesTableWidget->rowCount() - 1);
4412 if (!fViewerPropertiesTableWidgetIsInit) {
4413 fViewerPropertiesTableWidgetIsInit =
true;
4415 fViewerPropertiesTableWidget->resizeColumnsToContents();
4417 int x = fViewerPropertiesTableWidget->horizontalHeader()->length();
4418 int y = fViewerPropertiesTableWidget->verticalHeader()->length()+ fViewerPropertiesTableWidget->horizontalHeader()->sizeHint().height() + 2;
4424 QDialog* dial =
static_cast<QDialog*
> (fUIViewerPropertiesWidget->parent());
4426 dial->resize(x+56,y+46);
4429 fViewerPropertiesTableWidget->blockSignals(
false);
4431 fTreeWidgetInfosIgnoredCommands = treeWidgetInfosIgnoredCommands;
4438 void G4OpenGLQtViewer::updatePickInfosWidget(
int aX,
int aY) {
4439 fLastPickPoint = QPoint(aX,aY);
4441 if (!isCurrentWidget()) {
4445 if (!fPickInfosWidget) {
4446 createPickInfosWidget();
4449 std::vector < G4OpenGLViewerPickMap* > pickMap = GetPickDetails(aX,aY);
4452 if (fPickInfosWidget) {
4453 QLayoutItem * wItem;
4454 if (fPickInfosWidget->layout()->count()) {
4455 while ((wItem = fPickInfosWidget->layout()->takeAt(0)) != 0) {
4456 delete wItem->widget();
4462 if (!fPickInfosWidget) {
4463 createPickInfosWidget();
4468 delete fSignalMapperPicking;
4469 fSignalMapperPicking =
new QSignalMapper(
this);
4472 for (
unsigned int a=0; a< pickMap.size(); a++) {
4474 std::ostringstream label;
4475 label <<
"Hit number:" << a <<
", PickName: " << pickMap[
a]->getPickName();
4477 QPushButton* pickCoutButton =
new QPushButton(label.str().c_str());
4478 pickCoutButton->setStyleSheet (
"text-align: left; padding: 1px; border: 0px;");
4479 pickCoutButton->setIcon(*fTreeIconClosed);
4480 fPickInfosWidget->layout()->addWidget(pickCoutButton);
4485 newStr = QStringList(QString(pickMap[a]->
print().
data()).trimmed());
4487 QTextEdit* ed =
new QTextEdit();
4488 ed->setFontFamily(
"Courier");
4489 ed->setFontPointSize(12);
4490 ed->setReadOnly(
true);
4491 fPickInfosWidget->layout()->addWidget(ed);
4492 ed->setVisible((
false));
4493 ed->append(newStr.join(
""));
4495 connect(pickCoutButton, SIGNAL(clicked()), fSignalMapperPicking, SLOT(map()));
4496 fSignalMapperPicking->setMapping(pickCoutButton,fPickInfosWidget->layout()->count()-1);
4499 connect(fSignalMapperPicking, SIGNAL(mapped(
int)),
this, SLOT(toggleSceneTreeComponentPickingCout(
int)));
4502 QLabel * pushUp =
new QLabel(
"");
4503 QSizePolicy vPolicy = QSizePolicy(QSizePolicy::Minimum,QSizePolicy::Minimum);
4504 vPolicy.setVerticalStretch(10);
4505 pushUp->setSizePolicy(vPolicy);
4506 fPickInfosWidget->layout()->addWidget(pushUp);
4511 changeColorAndTransparency(fLastHighlightName,fLastHighlightColor);
4513 if (pickMap.size() > 0 ) {
4515 fLastHighlightName = pickMap[0]->getPickName();
4516 fLastHighlightColor = getColorForPoIndex(fLastHighlightName);
4518 changeColorAndTransparency(fLastHighlightName,
G4Color(1,1,1,1));
4522 QDialog* dial =
static_cast<QDialog*
> (fUIPickInfosWidget->parent());
4525 if (pickMap.size() == 0) {
4526 dial->setWindowTitle(QString(
"No object selected - ")+GetName());
4527 }
else if (pickMap.size() == 1) {
4528 dial->setWindowTitle(QString(
"1 object selected - ")+GetName());
4530 dial->setWindowTitle(QString::number(pickMap.size())+
" objects selected - "+GetName());
4534 fPickInfosScrollArea->setVisible(
true);
4538 void G4OpenGLQtViewer::toggleSceneTreeComponentPickingCout(
int pickItem) {
4543 for (
int a=0; a<fPickInfosWidget->layout()->count(); a++) {
4544 w = fPickInfosWidget->layout()->itemAt(a)->widget();
4545 QTextEdit* ed =
dynamic_cast<QTextEdit*
>(w);
4546 QPushButton* button;
4548 if (a == pickItem) {
4549 w->setVisible(!w->isVisible());
4551 w->setVisible(
false);
4554 button =
dynamic_cast<QPushButton*
>(fPickInfosWidget->layout()->itemAt(a-1)->widget());
4556 if (button->isVisible()) {
4557 button->setIcon(*fTreeIconOpen);
4559 button->setIcon(*fTreeIconClosed);
4568 void G4OpenGLQtViewer::currentTabActivated(
int currentTab) {
4569 if (fUiQt->GetViewerTabWidget()->tabText(currentTab) == GetName()) {
4570 createViewerPropertiesWidget();
4571 createPickInfosWidget();
4572 createSceneTreeWidget();
4577 void G4OpenGLQtViewer::tableWidgetViewerSetItemChanged(QTableWidgetItem * item) {
4580 QTableWidgetItem* previous = fViewerPropertiesTableWidget->item(fViewerPropertiesTableWidget->row(item),0);
4582 fViewerPropertiesTableWidget->blockSignals(
true);
4584 + previous->text().toStdString()
4586 + item->text().toStdString()).c_str());
4587 fViewerPropertiesTableWidget->blockSignals(
false);
4592 bool G4OpenGLQtViewer::isCurrentWidget(){
4593 G4Qt* interactorManager = G4Qt::getInstance ();
4594 if (!interactorManager->IsExternalApp()) {
4597 if ( GetName() != fUiQt->GetViewerTabWidget()->tabText(fUiQt->GetViewerTabWidget()->currentIndex()).toStdString().c_str()) {
4611 QString G4OpenGLQtViewer::GetCommandParameterList (
4618 if( n_parameterEntry > 0 ) {
4623 for(
G4int i_thParameter=0; i_thParameter<n_parameterEntry; i_thParameter++ ) {
4628 txt +=
" Parameter type : " + QString(QChar(param->
GetParameterType())) +
"\n";
4630 txt +=
" Omittable : True\n";
4632 txt +=
" Omittable : False\n";
4635 txt +=
" Default value : taken from the current value\n";
4650 #ifdef G4MULTITHREADED
4652 void G4OpenGLQtViewer::DoneWithMasterThread()
4657 G4MUTEXLOCK(&mWaitForVisSubThreadQtOpenGLContextInitialized);
4660 void G4OpenGLQtViewer::SwitchToVisSubThread()
4664 QGLWidget* qGLW =
dynamic_cast<QGLWidget*
> (fGLWidget) ;
4670 SetQGLContextVisSubThread(QThread::currentThread());
4676 G4CONDITIONWAIT(&c2_VisSubThreadQtOpenGLContextMoved, &mWaitForVisSubThreadQtOpenGLContextMoved);
4679 qGLW->makeCurrent();
4682 void G4OpenGLQtViewer::DoneWithVisSubThread()
4685 QGLWidget* qGLW =
dynamic_cast<QGLWidget*
> (fGLWidget) ;
4691 qGLW->doneCurrent();
4693 #if QT_VERSION > 0x050000
4695 qGLW->context()->moveToThread(fQGLContextMainThread);
4699 void G4OpenGLQtViewer::SwitchToMasterThread()
4703 QGLWidget* qGLW =
dynamic_cast<QGLWidget*
> (fGLWidget) ;
4709 G4MUTEXUNLOCK(&mWaitForVisSubThreadQtOpenGLContextInitialized);
4710 qGLW->makeCurrent();
4714 void G4OpenGLQtViewer::MovingToVisSubThread(){
4717 QGLWidget* qGLW =
dynamic_cast<QGLWidget*
> (fGLWidget) ;
4723 G4CONDITIONWAIT( &c1_VisSubThreadQtOpenGLContextInitialized, &mWaitForVisSubThreadQtOpenGLContextInitialized);
4727 SetQGLContextMainThread(QThread::currentThread());
4730 qGLW->doneCurrent();
4731 #if QT_VERSION > 0x050000
4732 qGLW->context()->moveToThread(fQGLContextVisSubThread);
G4UIcommandTree * FindCommandTree(const char *commandPath)
G4String GetParameterCandidates() const
G4double GetAlpha() const
std::vector< ExP01TrackerHit * > a
G4int GetCommandEntry() const
G4String GetParameterName() const
G4UIcommand * GetCommand(G4int i)
const G4Transform3D & GetTransformation() const
static G4bool GetColour(const G4String &key, G4Colour &result)
static constexpr double degree
#define G4BestUnit(a, b)
#define G4_USE_G4BESTUNIT_FOR_VERBOSE 1
G4Point3D GetPosition() const
const G4ThreeVector const G4double const
#define G4CONDITIONWAIT(cond, mutex)
const G4String & GetGuidanceLine(G4int i) const
#define G4MUTEX_INITIALIZER
const XML_Char const XML_Char * data
static G4UImanager * GetUIpointer()
G4bool IsOmittable() const
G4double GetYOffset() const
G4GLOB_DLL std::ostream G4cout
G4double GetGreen() const
static constexpr double gray
G4UIparameter * GetParameter(G4int i) const
typedef int(XMLCALL *XML_NotStandaloneHandler)(void *userData)
std::vector< PVNodeID > PVPath
void print(G4double elem)
const std::vector< G4PhysicalVolumeNodeID > & GetFullPVPath() const
const G4String & GetCommandName() const
const char * data() const
G4double GetXOffset() const
G4UIcommandTree * GetTree() const
G4String GetDefaultValue() const
char GetParameterType() const
static MCTruthManager * instance
static PROLOG_HANDLER error
const G4String GetParameterGuidance() const
G4String GetParameterRange() const
static const G4double alpha
G4int GetGuidanceEntries() const
const XML_Char XML_Content * model
G4int GetParameterEntries() const
G4bool GetCurrentAsDefault() const
static const G4double pos
G4int ApplyCommand(const char *aCommand)
std::vector< G4PolyconeSideRZ > g4c
G4GLOB_DLL std::ostream G4cerr
#define G4CONDITIONBROADCAST(cond)
#define G4CONDITION_INITIALIZER