58#include <qpushbutton.h>
60#include <qdesktopwidget.h>
63#include <qimagewriter.h>
66#include <qtreewidget.h>
67#include <qapplication.h>
68#include <qmessagebox.h>
69#include <qfiledialog.h>
72#if QT_VERSION >= 0x050e00
73 #include <qelapsedtimer.h>
78#include <qcolordialog.h>
84#if QT_VERSION < 0x050600
85#include <qsignalmapper.h>
89#include <qmainwindow.h>
90#include <qtablewidget.h>
91#include <qheaderview.h>
92#include <qscrollarea.h>
99#include "moc_G4OpenGLQtViewer.cpp"
107#ifdef G4MULTITHREADED
141 if (UI == NULL)
return;
150 bool isTabbedView =
false;
160 SIGNAL(currentChanged(
int)),
174 if (glDialogWidget == NULL) {
177 glWidget->setParent(glDialogWidget);
178 QHBoxLayout *mainLayout =
new QHBoxLayout();
180 mainLayout->setMargin(0);
181 mainLayout->setSpacing(0);
183 if (
fGLWidget->inherits(
"QMainWindow")) {
186 glDialogWidget->setLayout(mainLayout);
190#if QT_VERSION >= 0x050a00
191 G4int offset = QApplication::desktop()->height()
192 - QGuiApplication::screenAt(QPoint(20,20))->availableGeometry().height();
194 G4int offset = QApplication::desktop()->height()
195 - QApplication::desktop()->availableGeometry().height();
204 glDialogWidget->show();
222 ,fRecordFrameNumber(0)
223 ,fMouseOnSceneTree(false)
225 ,fLastPickPoint(-1,-1)
228 ,fHoldKeyEvent(false)
229 ,fHoldMoveEvent(false)
230 ,fHoldRotateEvent(false)
234 ,fMovieTempFolderPath(
"")
236 ,fParameterFileName(
"ppmtompeg_encode_parameter_file.par")
237 ,fMovieParametersDialog(NULL)
238 ,fRecordingStep(WAIT)
240 ,fNbMaxFramesPerSec(100)
241 ,fNbMaxAnglePerSec(360)
242 ,fLaunchSpinDelay(100)
243 ,fUISceneTreeWidget(NULL)
244 ,fUIViewerPropertiesWidget(NULL)
245 ,fUIPickInfosWidget(NULL)
248 ,fControlKeyPress(false)
249 ,fShiftKeyPress(false)
251 ,fCheckSceneTreeComponentSignalLock(false)
252 ,fViewerPropertiesTableWidgetIsInit(false)
253 ,fSceneTreeComponentTreeWidget(NULL)
254 ,fSceneTreeWidget(NULL)
255 ,fPVRootNodeCreate(false)
259 ,fTouchableVolumes(
"Touchables")
260 ,fShortcutsDialog(NULL)
261 ,fViewerPropertiesTableWidget(NULL)
262 ,fPickInfosWidget(NULL)
263 ,fPickInfosScrollArea(NULL)
264 ,fTreeWidgetInfosIgnoredCommands(0)
265 ,fSceneTreeDepthSlider(NULL)
267 ,fModelShortNameItem(NULL)
268 ,fMaxPOindexInserted(-1)
270#if QT_VERSION < 0x050600
271 ,fSignalMapperMouse(NULL)
272 ,fSignalMapperSurface(NULL)
273 ,fSignalMapperPicking(NULL)
276 ,fTreeIconClosed(NULL)
277 ,fLastExportSliderValue(80)
278 ,fLastHighlightColor(
G4Color(0,0,0,0))
279 ,fLastHighlightName(0)
290 if (QCoreApplication::instance () == NULL) {
301#if QT_VERSION < 0x050e00
306#if QT_VERSION < 0x050600
314 QList<QByteArray> formats = QImageWriter::supportedImageFormats ();
315 for (
int i = 0; i < formats.size(); ++i) {
319 const char *
const icon1[]={
377 const char *
const icon2[]={
470 const char *
const search[] = {
482 "OOOOOOOOOOOOOOOOOOO",
483 "OOOOOOOOOOOOOOOOOOO",
484 "OOOOOOOo. .oOOOOOO",
487 "OOOOO. XOOOOX .OOOO",
490 "OOOOO. XOOOOo .OOOO",
494 "OOOOOOOOOOOOO. XOO",
495 "OOOOOOOOOOOOOO. XOO",
496 "OOOOOOOOOOOOOOOoOOO",
497 "OOOOOOOOOOOOOOOOOOO",
498 "OOOOOOOOOOOOOOOOOOO",
499 "OOOOOOOOOOOOOOOOOOO",
500 "OOOOOOOOOOOOOOOOOOO"
523 delete wItem->widget();
548 QMenu *mMouseAction =
fContextMenu->addMenu(
"&Mouse actions");
550#if QT_VERSION < 0x050600
563 QAction *shortcutsAction = mMouseAction->addAction(
"Show shortcuts");
570 shortcutsAction->setCheckable(
false);
572#if QT_VERSION < 0x050600
582 SIGNAL(triggered(
bool)),
589 QMenu *mProjection = mStyle->addMenu(
"&Projection");
591#if QT_VERSION < 0x050600
607 QMenu *mDrawing = mStyle->addMenu(
"&Drawing");
609#if QT_VERSION < 0x050600
619#if QT_VERSION < 0x050600
639 QAction *backgroundColorChooser ;
641 backgroundColorChooser = mStyle->addAction(
"Background color");
649 QAction *textColorChooser ;
651 textColorChooser = mStyle->addAction(
"Text color");
659 QAction *defaultColorChooser ;
661 defaultColorChooser = mStyle->addAction(
"Default color");
670 QAction *createEPS = mActions->addAction(
"Save as ...");
677 QAction *movieParameters = mActions->addAction(
"Save as movie...");
688 QMenu *mTransparency = mSpecial->addMenu(
"Transparency");
689 QAction *transparencyOn = mTransparency->addAction(
"On");
690 QAction *transparencyOff = mTransparency->addAction(
"Off");
701 QMenu *mAntialiasing = mSpecial->addMenu(
"Antialiasing");
702 QAction *antialiasingOn = mAntialiasing->addAction(
"On");
703 QAction *antialiasingOff = mAntialiasing->addAction(
"Off");
710 mAntialiasing->clear();
713 QMenu *mHaloing = mSpecial->addMenu(
"Haloing");
714 QAction *haloingOn = mHaloing->addAction(
"On");
715 QAction *haloingOff = mHaloing->addAction(
"Off");
724 QMenu *mAux = mSpecial->addMenu(
"Auxiliary edges");
725 QAction *auxOn = mAux->addAction(
"On");
726 QAction *auxOff = mAux->addAction(
"Off");
734 QMenu *mHiddenMarkers = mSpecial->addMenu(
"Hidden markers");
735 QAction *hiddenMarkersOn = mHiddenMarkers->addAction(
"On");
736 QAction *hiddenMarkersOff = mHiddenMarkers->addAction(
"Off");
745 QMenu *mFullScreen = mSpecial->addMenu(
"&Full screen");
757 G4cerr <<
"Visualization window not defined, please choose one before" <<
G4endl;
783 action1->setCheckable(
true);
784 action2->setCheckable(
true);
787 action1->setChecked (
true);
789 action2->setChecked (
true);
806 text =
"========= Mouse Shortcuts =========\n";
809 text +=
"Click and move mouse to rotate volume \n";
810 text +=
"ALT + Click and move mouse to rotate volume (Toggle View/Theta-Phi Direction) \n";
811 text +=
"CTRL + Click and move mouse to zoom in/out \n";
812 text +=
"SHIFT + Click and move mouse to change camera point of view \n";
814 text +=
"Move camera point of view with mouse \n";
816 text +=
"Click and pick \n";
819 text +=
"Click and move mouse to rotate volume \n";
820 text +=
"ALT + Click and move mouse to rotate volume (Toggle View/Theta-Phi Direction) \n";
821 text +=
"CTRL + Click and zoom mouse to zoom in/out \n";
822 text +=
"SHIFT + Click and zoommove camera point of view \n";
824 text +=
"========= Move Shortcuts ========= \n";
825 text +=
"Press left/right arrows to move volume left/right \n";
826 text +=
"Press up/down arrows to move volume up/down \n";
827 text +=
"Press '+'/'-' to move volume toward/forward \n";
829 text +=
"========= Rotation (Theta/Phi) Shortcuts ========= \n";
830 text +=
"Press SHIFT + left/right arrows to rotate volume left/right \n";
831 text +=
"Press SHIFT + up/down arrows to rotate volume up/down \n";
833 text +=
"========= Rotation (View Direction) Shortcuts ========= \n";
834 text +=
"Press ALT + left/right to rotate volume around vertical direction \n";
835 text +=
"Press ALT + up/down to rotate volume around horizontal direction \n";
837 text +=
"========= Zoom View ========= \n";
838 text +=
"Press CTRL + '+'/'-' to zoom into volume \n";
840 text +=
"========= Misc ========= \n";
841 text +=
"Press ALT +/- to slow/speed rotation/move \n";
842 text +=
"Press H to reset view \n";
843 text +=
"Press Esc to exit FullScreen \n";
845 text +=
"========= Video ========= \n";
846 text +=
"In video mode : \n";
847 text +=
" Press SPACE to Start/Pause video recording \n";
848 text +=
" Press RETURN to Stop video recording \n";
856 QVBoxLayout *mainLayout =
new QVBoxLayout;
878 }
else if (aAction == 2) {
880 }
else if (aAction == 3) {
882 }
else if (aAction == 4) {
884 }
else if (aAction == 5) {
910 }
else if (aAction ==2) {
913 }
else if (aAction ==3) {
916 }
else if (aAction ==4) {
972 glDisable (GL_LINE_SMOOTH);
973 glDisable (GL_POLYGON_SMOOTH);
976 glEnable (GL_LINE_SMOOTH);
977 glHint (GL_LINE_SMOOTH_HINT, GL_NICEST);
978 glEnable (GL_POLYGON_SMOOTH);
979 glHint (GL_POLYGON_SMOOTH_HINT, GL_NICEST);
1032 UI->
ApplyCommand(std::string(
"/vis/viewer/set/picking true"));
1034 UI->
ApplyCommand(std::string(
"/vis/viewer/set/picking false"));
1060 if (check !=
fGLWidget->isFullScreen()) {
1070 QGLWidget* qGLW =
dynamic_cast<QGLWidget*
> (
fGLWidget) ;
1078 image = qGLW->grabFrameBuffer();
1081 res = image.save(filePath,0);
1102 qFilename = QFileDialog::getSaveFileName (
fGLWidget,
1109 std::string
name = qFilename.toStdString().c_str();
1118 std::string format = selectedFormat->toLower().toStdString().c_str();
1123 std::string filename =
name;
1124 std::string extension =
"";
1125 if (
name.find_last_of(
".") != std::string::npos) {
1126 filename =
name.substr(0,
name.find_last_of(
".") + 1);
1127 extension =
name.substr(
name.find_last_of(
".") + 1);
1132 filename+=
"."+ extension;
1139 if( exportDialog->exec()) {
1172#if QT_VERSION < 0x040500
1174 const QColor color = QColor(QColorDialog::getRgba (QColor(Qt::black).rgba(),&a,
fGLWidget));
1176 const QColor color =
1177 QColorDialog::getColor(Qt::black,
1179 " Get background color and transparency",
1180 QColorDialog::ShowAlphaChannel);
1182 if (color.isValid()) {
1196#if QT_VERSION < 0x040500
1198 const QColor color = QColor(QColorDialog::getRgba (QColor(Qt::yellow).rgba(),&a,
fGLWidget));
1200 const QColor& color =
1201 QColorDialog::getColor(Qt::yellow,
1203 " Get text color and transparency",
1204 QColorDialog::ShowAlphaChannel);
1206 if (color.isValid()) {
1221#if QT_VERSION < 0x040500
1223 const QColor color = QColor(QColorDialog::getRgba (QColor(Qt::white).rgba(),&a,
fGLWidget));
1225 const QColor& color =
1226 QColorDialog::getColor(Qt::white,
1228 " Get default color and transparency",
1229 QColorDialog::ShowAlphaChannel);
1231 if (color.isValid()) {
1258 setRecordingInfos(
"ppmtompeg is needed to encode in video format. It is available here: http://netpbm.sourceforge.net ");
1284 if (evnt->button() == Qt::RightButton) {
1287 if ((evnt->button() & Qt::LeftButton) && (! (evnt->modifiers() & Qt::ControlModifier ))){
1294 if (
fUiQt != NULL) {
1299 float deltaX = ((float)
getWinWidth()/2-evnt->pos().x());
1300 float deltaY = ((float)
getWinHeight()/2-evnt->pos().y());
1322 fGLWidget->setCursor(QCursor(Qt::SizeAllCursor));
1325 fGLWidget->setCursor(QCursor(Qt::ClosedHandCursor));
1328 fGLWidget->setCursor(QCursor(Qt::SizeAllCursor));
1330 fGLWidget->setCursor(QCursor(Qt::PointingHandCursor));
1341 glGetIntegerv(GL_VIEWPORT, viewport);
1344 double factorX = ((double)viewport[2]/
fGLWidget->width());
1345 double factorY = ((double)viewport[3]/
fGLWidget->height());
1350 fGLWidget->setCursor(QCursor(Qt::ArrowCursor));
1353 if ((delta.x() != 0) || (delta.y() != 0)) {
1359 if ((delta.x() == 0) && (delta.y() == 0)) {
1364#if QT_VERSION < 0x050e00
1367 QElapsedTimer lastMoveTime;
1369 lastMoveTime.start();
1371 float correctionFactor = 5;
1374 float lTime = 1000/lastMoveTime.elapsed();
1378 if (delta.x() <0 ) {
1379 correctionFactor = -correctionFactor;
1385 if (delta.y() <0 ) {
1386 correctionFactor = -correctionFactor;
1397 lastMoveTime.start();
1399 bool rotate =
false;
1402 if (
fUiQt != NULL) {
1418 rotateQtScene(((
float)delta.x())/correctionFactor,((
float)delta.y())/correctionFactor);
1420 rotateQtSceneToggle(((
float)delta.x())/correctionFactor,((
float)delta.y())/correctionFactor);
1424 moveScene(-((
float)delta.x())/correctionFactor,-((
float)delta.y())/correctionFactor,0,
true);
1451 Qt::MouseButtons mButtons = evnt->buttons();
1461 fLastPos1 = QPoint(evnt->x(), evnt->y());
1467 if (
fUiQt != NULL) {
1473 if (mButtons & Qt::LeftButton) {
1479 unsigned int sizeWin;
1486 float factor = ((float)100/(
float)sizeWin) ;
1487 moveScene(-(
float)deltaX*factor,-(
float)deltaY*factor,0,
false);
1493 if (mButtons & Qt::LeftButton) {
1494 moveScene(-(
float)deltaX,-(
float)deltaY,0,
true);
1516 GLdouble coefDepth = 0;
1602#if QT_VERSION < 0x050F00
1623 if ((
fNoKeyPress) || (evnt->modifiers() == Qt::KeypadModifier )) {
1624 if (evnt->key() == Qt::Key_Down) {
1627 else if (evnt->key() == Qt::Key_Up) {
1630 if (evnt->key() == Qt::Key_Left) {
1633 else if (evnt->key() == Qt::Key_Right) {
1636 if (evnt->key() == Qt::Key_Minus) {
1639 else if (evnt->key() == Qt::Key_Plus) {
1643 if (evnt->key() == Qt::Key_Escape) {
1653 if ((evnt->key() == Qt::Key_Return) || (evnt->key() == Qt::Key_Enter)){
1656 if (evnt->key() == Qt::Key_Space){
1661 if (evnt->key() == Qt::Key_H){
1669 fGLWidget->setCursor(QCursor(Qt::SizeAllCursor));
1671 if (evnt->key() == Qt::Key_Down) {
1674 else if (evnt->key() == Qt::Key_Up) {
1677 if (evnt->key() == Qt::Key_Left) {
1680 else if (evnt->key() == Qt::Key_Right) {
1683 if (evnt->key() == Qt::Key_Plus) {
1691 fGLWidget->setCursor(QCursor(Qt::ClosedHandCursor));
1693 if (evnt->key() == Qt::Key_Down) {
1696 else if (evnt->key() == Qt::Key_Up) {
1699 if (evnt->key() == Qt::Key_Left) {
1702 else if (evnt->key() == Qt::Key_Right) {
1707 if (evnt->key() == Qt::Key_Plus) {
1711 else if (evnt->key() == Qt::Key_Minus) {
1719 if (evnt->key() == Qt::Key_Plus) {
1723 else if (evnt->key() == Qt::Key_Minus) {
1735 fGLWidget->setCursor(QCursor(Qt::ArrowCursor));
1747 if (modifier & Qt::AltModifier ) {
1751 if (modifier & Qt::ShiftModifier ) {
1755 if (modifier & Qt::ControlModifier ) {
1815 setRecordingInfos(
"You should specified the temp folder in order to make movie");
1852 QString txtStatus =
"";
1854 txtStatus =
"Waiting to start...";
1857 txtStatus =
"Start Recording...";
1859 txtStatus =
"Pause Recording...";
1861 txtStatus =
"Continue Recording...";
1863 txtStatus =
"Stop Recording...";
1865 txtStatus =
"Ready to Encode...";
1867 txtStatus =
"Encoding...";
1869 txtStatus =
"Failed to encode...";
1873 txtStatus =
"Correct above errors first";
1875 txtStatus =
"File encoded successfully";
1906 fProcess->setProcessChannelMode(QProcess::MergedChannels);
1907#if QT_VERSION < 0x050F00
1909 fProcess->start (
"which ppmtompeg");
1912 fProcess->start (
"which ppmtompeg", QStringList());
1929 return "ppmtompeg is needed to encode in video format. It is available here: http://netpbm.sourceforge.net ";
1932 path = QDir::cleanPath(path);
1933 QFileInfo *f =
new QFileInfo(path);
1935 return "File does not exist";
1936 }
else if (f->isDir()) {
1937 return "This is a directory";
1938 }
else if (!f->isExecutable()) {
1939 return "File exist but is not executable";
1940 }
else if (!f->isFile()) {
1941 return "This is not a file";
2057 return "Path does not exist";
2059 path = QDir::cleanPath(path);
2060 QFileInfo *d =
new QFileInfo(path);
2062 return "Path does not exist";
2063 }
else if (!d->isDir()) {
2064 return "This is not a directory";
2065 }
else if (!d->isReadable()) {
2066 return path +
" is read protected";
2067 }
else if (!d->isWritable()) {
2068 return path +
" is write protected";
2091 return "Path does not exist";
2094 QFileInfo *
file =
new QFileInfo(path);
2095 QDir dir =
file->dir();
2096 path = QDir::cleanPath(path);
2097 if (
file->exists()) {
2098 return "File already exist, please choose a new one";
2099 }
else if (!dir.exists()) {
2100 return "Dir does not exist";
2101 }
else if (!dir.isReadable()) {
2102 return path +
" is read protected";
2129 QString sep = QString(QDir::separator());
2130 QString path = sep+
"QtMovie_"+QDateTime::currentDateTime ().toString(
"dd-MM-yyyy_hh-mm-ss")+sep;
2133 if (d->exists(path)) {
2134 return "Folder "+path+
" already exists.Please remove it first";
2155 d->setFilter( QDir::Files );
2156 QStringList subDirList = d->entryList();
2159 for (QStringList::ConstIterator it = subDirList.begin() ;(it != subDirList.end()) ; it++) {
2160 const QString currentFile = *it;
2161 if (!d->remove(currentFile)) {
2189 QGLWidget* qGLW =
dynamic_cast<QGLWidget*
> (
fGLWidget) ;
2194 bool increaseFileNumber =
true;
2196 if (
name.size() !=
name.substr(
name.find_last_of(
".") + 1).size()) {
2197 increaseFileNumber =
false;
2202 if ((width !=-1) && (height != -1)) {
2212 image = qGLW->grabFrameBuffer();
2238 fprintf (fp,
"# Pattern affects speed, quality and compression. See the User's Guide\n");
2239 fprintf (fp,
"# for more info.\n");
2241 fprintf (fp,
"PATTERN I\n");
2244 fprintf (fp,
"# You must specify the type of the input files. The choices are:\n");
2245 fprintf (fp,
"# YUV, PPM, JMOVIE, Y, JPEG, PNM\n");
2246 fprintf (fp,
"# (must be upper case)\n");
2248 fprintf (fp,
"BASE_FILE_FORMAT PPM\n");
2251 fprintf (fp,
"# If you are using YUV, there are different supported file formats.\n");
2252 fprintf (fp,
"# EYUV or UCB are the same as previous versions of this encoder.\n");
2253 fprintf (fp,
"# (All the Y's, then U's then V's, in 4:2:0 subsampling.)\n");
2254 fprintf (fp,
"# Other formats, such as Abekas, Phillips, or a general format are\n");
2255 fprintf (fp,
"# permissible, the general format is a string of Y's, U's, and V's\n");
2256 fprintf (fp,
"# to specify the file order.\n");
2258 fprintf (fp,
"INPUT_FORMAT UCB\n");
2260 fprintf (fp,
"# the conversion statement\n");
2262 fprintf (fp,
"# Each occurrence of '*' will be replaced by the input file\n");
2264 fprintf (fp,
"# e.g., if you have a bunch of GIF files, then this might be:\n");
2265 fprintf (fp,
"# INPUT_CONVERT giftoppm *\n");
2267 fprintf (fp,
"# e.g., if you have a bunch of files like a.Y a.U a.V, etc., then:\n");
2268 fprintf (fp,
"# INPUT_CONVERT cat *.Y *.U *.V\n");
2270 fprintf (fp,
"# e.g., if you are grabbing from laser disc you might have something like\n");
2271 fprintf (fp,
"# INPUT_CONVERT goto frame *; grabppm\n");
2272 fprintf (fp,
"# 'INPUT_CONVERT *' means the files are already in the base file format\n");
2274 fprintf (fp,
"INPUT_CONVERT * \n");
2276 fprintf (fp,
"# number of frames in a GOP.\n");
2278 fprintf (fp,
"# since each GOP must have at least one I-frame, the encoder will find the\n");
2279 fprintf (fp,
"# the first I-frame after GOP_SIZE frames to start the next GOP\n");
2281 fprintf (fp,
"# later, will add more flexible GOP signalling\n");
2283 fprintf (fp,
"GOP_SIZE 1\n");
2285 fprintf (fp,
"# number of slices in a frame\n");
2287 fprintf (fp,
"# 1 is a good number. another possibility is the number of macroblock rows\n");
2288 fprintf (fp,
"# (which is the height divided by 16)\n");
2290 fprintf (fp,
"SLICES_PER_FRAME 1\n");
2291 fprintf (fp,
"PIXEL HALF");
2293 fprintf (fp,
"# directory to get all input files from (makes this file easier to read)\n");
2296 fprintf (fp,
"# There are a bunch of ways to specify the input files.\n");
2297 fprintf (fp,
"# from a simple one-per-line listing, to the following \n");
2298 fprintf (fp,
"# way of numbering them. See the manual for more information.\n");
2299 fprintf (fp,
"INPUT\n");
2300 fprintf (fp,
"# '*' is replaced by the numbers 01, 02, 03, 04\n");
2301 fprintf (fp,
"# if I instead do [01-11], it would be 01, 02, ..., 09, 10, 11\n");
2302 fprintf (fp,
"# if I instead do [1-11], it would be 1, 2, 3, ..., 9, 10, 11\n");
2303 fprintf (fp,
"# if I instead do [1-11+3], it would be 1, 4, 7, 10\n");
2304 fprintf (fp,
"# the program assumes none of your input files has a name ending in ']'\n");
2305 fprintf (fp,
"# if you do, too bad!!!\n");
2309 fprintf (fp,
"# can have more files here if you want...there is no limit on the number\n");
2310 fprintf (fp,
"# of files\n");
2311 fprintf (fp,
"END_INPUT\n");
2315 fprintf (fp,
"# Many of the remaining options have to do with the motion search and qscale\n");
2317 fprintf (fp,
"# FULL or HALF -- must be upper case\n");
2318 fprintf (fp,
"# Should be FULL for computer generated images\n");
2319 fprintf (fp,
"PIXEL FULL\n");
2321 fprintf (fp,
"# means +/- this many pixels for both P and B frame searches\n");
2322 fprintf (fp,
"# specify two numbers if you wish to serc different ranges in the two.\n");
2323 fprintf (fp,
"RANGE 10\n");
2325 fprintf (fp,
"# The two search algorithm parameters below mostly affect speed,\n");
2326 fprintf (fp,
"# with some affect on compression and almost none on quality.\n");
2328 fprintf (fp,
"# this must be one of {EXHAUSTIVE, SUBSAMPLE, LOGARITHMIC}\n");
2329 fprintf (fp,
"PSEARCH_ALG LOGARITHMIC\n");
2331 fprintf (fp,
"# this must be one of {SIMPLE, CROSS2, EXHAUSTIVE}\n");
2333 fprintf (fp,
"# note that EXHAUSTIVE is really, really, really slow\n");
2335 fprintf (fp,
"BSEARCH_ALG SIMPLE\n");
2338 fprintf (fp,
"# these specify the q-scale for I, P, and B frames\n");
2339 fprintf (fp,
"# (values must be between 1 and 31)\n");
2340 fprintf (fp,
"# These are the Qscale values for the entire frame in variable bit-rate\n");
2341 fprintf (fp,
"# mode, and starting points (but not important) for constant bit rate\n");
2344 fprintf (fp,
"# Qscale (Quantization scale) affects quality and compression,\n");
2345 fprintf (fp,
"# but has very little effect on speed.\n");
2347 fprintf (fp,
"IQSCALE 4\n");
2348 fprintf (fp,
"PQSCALE 5\n");
2349 fprintf (fp,
"BQSCALE 12\n");
2351 fprintf (fp,
"# this must be ORIGINAL or DECODED\n");
2352 fprintf (fp,
"REFERENCE_FRAME ORIGINAL\n");
2354 fprintf (fp,
"# for parallel parameters see parallel.param in the examples subdirectory\n");
2356 fprintf (fp,
"# if you want constant bit-rate mode, specify it as follows (number is bits/sec):\n");
2357 fprintf (fp,
"#BIT_RATE 1000000\n");
2359 fprintf (fp,
"# To specify the buffer size (327680 is default, measused in bits, for 16bit words)\n");
2360 fprintf (fp,
"BUFFER_SIZE 327680\n");
2362 fprintf (fp,
"# The frame rate is the number of frames/second (legal values:\n");
2363 fprintf (fp,
"# 23.976, 24, 25, 29.97, 30, 50 ,59.94, 60\n");
2364 fprintf (fp,
"FRAME_RATE 30\n");
2366 fprintf (fp,
"# There are many more options, see the users manual for examples....\n");
2367 fprintf (fp,
"# ASPECT_RATIO, USER_DATA, GAMMA, IQTABLE, etc.\n");
2383#if QT_VERSION > 0x040100
2394#if QT_VERSION < 0x050a00
2395 fProcess->setReadChannelMode(QProcess::MergedChannels);
2397 fProcess->setProcessChannelMode(QProcess::MergedChannels);
2407 QString tmp =
fProcess->readAllStandardOutput ().data();
2408 int start = tmp.lastIndexOf(
"ESTIMATED TIME");
2409 tmp = tmp.mid(start,tmp.indexOf(
"\n",start)-start);
2454 case QProcess::FailedToStart:
2455 txt =
"The process failed to start. Either the invoked program is missing, or you may have insufficient permissions to invoke the program.\n";
2457 case QProcess::Crashed:
2458 txt =
"The process crashed some time after starting successfully.\n";
2460 case QProcess::Timedout:
2461 txt =
"The last waitFor...() function timed out. The state of QProcess is unchanged, and you can try calling waitFor...() again.\n";
2463 case QProcess::WriteError:
2464 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";
2466 case QProcess::ReadError:
2467 txt =
"An error occurred when attempting to read from the process. For example, the process may not be running.\n";
2469 case QProcess::UnknownError:
2470 txt =
"An unknown error occurred. This is the default return value of error().\n";
2488 QDialog* dialog = NULL;
2492 QWidgetList wl = QApplication::allWidgets();
2493 QWidget *widget = NULL;
2494 for (
int i=0; i < wl.size(); i++) {
2496 if ((found==
false) && (widget->inherits(
"QMainWindow"))) {
2497 dialog =
new QDialog(widget,Qt::WindowTitleHint | Qt::WindowSystemMenuHint | Qt::WindowMinMaxButtonsHint);
2503 dialog =
new QDialog();
2506 dialog=
new QDialog();
2524 QLayoutItem * wItem;
2530 if(
dynamic_cast<QWidget *
>(wItem->widget())) {
2532 wItem->widget()->show();
2535 wItem->widget()->hide();
2539 wItem->widget()->hide();
2547 QVBoxLayout* layoutSceneTree =
new QVBoxLayout();
2571 QWidget* coutButtonWidget =
new QWidget();
2572 QHBoxLayout* layoutCoutTBButtons =
new QHBoxLayout();
2579#if QT_VERSION > 0x050100
2580 fFilterOutput->addAction(*searchIcon,QLineEdit::TrailingPosition);
2583 QPushButton *coutTBFilterButton =
new QPushButton();
2584 coutTBFilterButton->setIcon(*searchIcon);
2585 coutTBFilterButton->setStyleSheet (
"padding-left: 0px; border:0px;");
2590#if QT_VERSION <= 0x050100
2591 layoutCoutTBButtons->addWidget(coutTBFilterButton);
2594 coutButtonWidget->setLayout(layoutCoutTBButtons);
2595 vLayout->addWidget(coutButtonWidget);
2598 vLayout->setContentsMargins(0,0,0,0);
2619 QWidget *helpWidget =
new QWidget();
2620 QHBoxLayout *helpLayout =
new QHBoxLayout();
2622 QWidget* depthWidget =
new QWidget();
2623 QWidget *showBox =
new QWidget(depthWidget);
2624 QHBoxLayout *showBoxLayout =
new QHBoxLayout();
2627 showBoxLayout->setContentsMargins(5,5,5,5);
2629 QLabel *
zero =
new QLabel();
2630 zero->setText(
"Show all");
2631 QLabel *one =
new QLabel();
2632 one->setText(
"Hide all");
2640 showBoxLayout->addWidget(
zero);
2642 showBoxLayout->addWidget(one);
2644 showBox->setLayout(showBoxLayout);
2646 helpLayout->addWidget(showBox);
2647 helpWidget->setLayout(helpLayout);
2648 helpLayout->setContentsMargins(0,0,0,0);
2650 vLayout->addWidget(helpWidget);
2674 QLayoutItem * wItem;
2677 delete wItem->widget();
2683 QGroupBox *groupBox =
new QGroupBox();
2684 groupBox->setTitle(
GetName().data());
2685 QVBoxLayout *vbox =
new QVBoxLayout;
2691 vPolicy.setVerticalStretch(4);
2694 groupBox->setLayout(vbox);
2704 dial->setWindowTitle(QString(
"Viewer properties - ")+
GetName());
2719 QLayoutItem * wItem;
2722 delete wItem->widget();
2727 QGroupBox *groupBox =
new QGroupBox(
"");
2728 QVBoxLayout *vbox =
new QVBoxLayout;
2731 QWidget *pickingInfoWidget =
new QWidget();
2732 QHBoxLayout *pickingInfoLayout =
new QHBoxLayout();
2734 pickingInfoWidget->setStyleSheet (
"padding-left: 0px; border:0px;");
2735 pickingInfoWidget->setLayout(pickingInfoLayout);
2737 vbox->addWidget(pickingInfoWidget);
2747 QVBoxLayout* vLayout =
new QVBoxLayout();
2752 vPolicy.setVerticalStretch(4);
2754 pickingInfoLayout->setContentsMargins(0,0,0,0);
2755 vLayout->setContentsMargins(0,0,0,0);
2756 vbox->setContentsMargins(1,1,1,1);
2758 groupBox->setLayout(vbox);
2773 if (fullPath.size() > 0) {
2782 item->setCheckState(0,Qt::Checked);
2784 item->setCheckState(0,Qt::Unchecked);
2787 int nChildCount = item->childCount();
2788 for (
int i = 0; i < nChildCount; i++) {
2797 QGLWidget* qGLW =
dynamic_cast<QGLWidget*
> (
fGLWidget) ;
2809#ifdef G4MULTITHREADED
2816 QFont font = QFont();
2817 font.setPointSizeF(size);
2825 const char* textCString = textString.c_str();
2830 QFontMetrics* f =
new QFontMetrics (font);
2831#if QT_VERSION > 0x050110
2832 G4double span = f->boundingRect(textCString).width();
2834 G4double span = f->width(textCString);
2853 xmove *= fudgeFactor;
2854 ymove *= fudgeFactor;
2880 if (modelShortName ==
"") {
2926 ,
const QString&
name
2929 ,
const QString& logicalName
2930 ,Qt::CheckState state
2931 ,QTreeWidgetItem * parentTreeNode
2943 QTreeWidgetItem * newItem = NULL;
2944 if (parentTreeNode == NULL) {
2945 newItem =
new QTreeWidgetItem();
2948 newItem =
new QTreeWidgetItem(parentTreeNode);
2953 newItem->setText(0,
name);
2954 newItem->setData(1,Qt::UserRole,copyNb);
2955 newItem->setText(2,QString::number(POIndex));
2956 newItem->setData(0, Qt::UserRole, POIndex);
2957 newItem->setText(3,logicalName);
2958 newItem->setFlags(newItem->flags()|Qt::ItemIsUserCheckable);
2959 newItem->setCheckState(0,state);
2960 newItem->setExpanded(
true);
2969 if ((state == Qt::Unchecked) && (POIndex == -1)) {
2970 newItem->setForeground (0, QBrush(
Qt::gray) );
2973 newItem->setToolTip (0,QString(
2974 "This node exists in the geometry but has not been\n")+
2975 "drawn, perhaps because it has been set invisible. It \n"+
2976 "cannot be made visible with a click on the button.\n"+
2977 "To see it, change the visibility, for example, with \n"+
2978 "/vis/geometry/set/visibility " + logicalName +
" 0 true\n"+
2979 "and rebuild the view with /vis/viewer/rebuild.\n"+
2980 "Click here will only show/hide all child components");
2983 newItem->setToolTip (0,QString(
"double-click to change the color"));
2989 state = Qt::Unchecked;
2990 newItem->setCheckState(0,state);
3016 QTreeWidgetItem * parentItem
3018 ,
unsigned int fullPathIndex
3019 ,
const QString& parentRoot
3020 ,
unsigned int currentIndexInTreeSceneHandler
3021 ,
int currentPVPOIndex
3024 if (parentItem == NULL) {
3030 std::ostringstream oss;
3031 oss << fullPath.at(fullPathIndex).GetCopyNo();
3032 std::string currentPVName =
G4String(fullPath.at(fullPathIndex).GetPhysicalVolume()->GetName()+
" ["+oss.str()+
"]").data();
3034 int currentPVCopyNb = fullPath.at(fullPathIndex).GetCopyNo();
3044 QTreeWidgetItem* subItem = NULL;
3045 QList<QTreeWidgetItem *> parentItemList;
3053 if ((currentIndexInTreeSceneHandler == (fullPath.size()-1)) && ((color.
GetAlpha() == 1.))) {
3055 QString lookForString = QString(currentPVName.c_str());
3056 for (
int i = 0;i < parentItem->childCount(); i++ ) {
3057 if (parentItem->child(i)->text(0) == lookForString) {
3058 parentItemList.push_back(parentItem->child(i));
3063 for (
int i = 0; i < parentItemList.size(); ++i) {
3064 const std::string& parentItemName = parentItemList.at(i)->text(0).toStdString();
3065 int parentItemCopyNb = parentItemList.at(i)->data(1,Qt::UserRole).toInt();
3066 int parentItemPOIndex = parentItemList.at(i)->data(0,Qt::UserRole).toInt();
3075 && (currentPVName == parentItemName)) ||
3079 && (currentPVName == parentItemName) && (currentPVPOIndex == parentItemPOIndex) )) {
3082 bool sameTransform =
true;
3083 if (parentItemPOIndex >= 0) {
3085 if (fullPathTmp.size() > 0) {
3086 if (fullPathTmp.at(fullPathTmp.size()-1).GetTransform () == pPVModel->
GetTransformation ()) {
3087 sameTransform =
true;
3089 sameTransform =
false;
3095 if (sameTransform ==
true) {
3102 if (currentIndexInTreeSceneHandler == (fullPath.size()-1)) {
3104 parentItemList.at(i)->setText(2,QString::number(currentPVPOIndex));
3105 parentItemList.at(i)->setData(0, Qt::UserRole,currentPVPOIndex);
3107 fTreeItemModels.insert(std::pair <int, PVPath >(currentPVPOIndex,fullPath) );
3111 parentItemList.at(i)->setFont (0,f);
3114 parentItemList.at(i)->setForeground (0,QBrush());
3117 parentItemList.at(i)->setToolTip (0,
"");
3126 parentItemList.at(i)->setCheckState(0,Qt::Checked);
3131 subItem = parentItemList.at(i);
3135 }
else if (currentIndexInTreeSceneHandler < (fullPath.size()-1)) {
3136 subItem = parentItemList.at(i);
3143 if (currentIndexInTreeSceneHandler == (fullPath.size()-1)) {
3145 QString(currentPVName.c_str()),
3148 QString(fullPath.at(fullPathIndex).GetPhysicalVolume()->GetLogicalVolume()->GetName().data()),
3160 if (subItem == NULL) {
3162 if (currentIndexInTreeSceneHandler < (fullPath.size()-1)) {
3164 QString(currentPVName.c_str()),
3167 QString(fullPath.at(fullPathIndex).GetPhysicalVolume()->GetLogicalVolume()->GetName().data()),
3174 return parseAndInsertInSceneTree(subItem,pPVModel,fullPathIndex+1,parentRoot,currentIndexInTreeSceneHandler+1,currentPVPOIndex);
3181 QTreeWidgetItem* subItem
3185 QTreeWidgetItem* oldItem = NULL;
3189 if (foundItem != NULL) {
3191 oldItem = foundItem;
3194 if (foundItem == NULL) {
3197 std::map <int, QTreeWidgetItem*>::const_iterator i;
3201 oldItem = i->second;
3208 if (oldItem == NULL) {
3222 if (oldItem != NULL) {
3223 subItem->setFlags(oldItem->flags());
3224 subItem->setCheckState(0,oldItem->checkState(0));
3225 subItem->setSelected(oldItem->isSelected());
3226 subItem->setExpanded(oldItem->isExpanded ());
3231 std::map <int, QTreeWidgetItem* >::iterator it;
3234 int oldPOIndex = oldItem->data(0,Qt::UserRole).toInt();
3239 std::map <int, QColor >::iterator itVis;
3242 QColor oldVisAttrColor;
3243 const QColor& newVisAttrColor = subItem->data(2,Qt::UserRole).value<QColor>();
3245 bool visAttrChange =
false;
3248 oldVisAttrColor = itVis->second;
3249 if (oldVisAttrColor != newVisAttrColor) {
3250 visAttrChange =
true;
3253 visAttrChange =
true;
3256 if (visAttrChange) {
3257 fOldVisAttrColorMap.insert(std::pair <int, QColor > (subItem->data(0,Qt::UserRole).toInt(),newVisAttrColor) );
3262 color = (it->second)->data(2,Qt::UserRole).value<QColor>();
3264 color = oldItem->data(2,Qt::UserRole).value<QColor>();
3279 QTreeWidgetItem* parentOldItem
3280 ,QTreeWidgetItem* parentNewItem
3286 int newCpNumber = -1;
3287 int oldCpNumber = -1;
3289 bool firstWhile =
true;
3291 while ((parentOldItem != NULL) && (parentNewItem != NULL)) {
3295 oldPO = parentOldItem->data(0,Qt::UserRole).toInt();
3296 newPO = parentNewItem->data(0,Qt::UserRole).toInt();
3304 if ((oldFullPath.size() > 0) &&
3305 (newFullPath.size() > 0)) {
3306 if (oldFullPath.size() != newFullPath.size()) {
3309 if (oldFullPath.at(oldFullPath.size()-1).GetTransform () == newFullPath.at(newFullPath.size()-1).GetTransform ()) {
3310 newCpNumber = newFullPath.at(newFullPath.size()-1).GetCopyNo();
3311 oldCpNumber = oldFullPath.at(oldFullPath.size()-1).GetCopyNo();
3320 if (oldCpNumber == -1) {
3321 oldCpNumber = parentOldItem->data(1,Qt::UserRole).toInt();
3323 if (newCpNumber == -1) {
3324 newCpNumber = parentNewItem->data(1,Qt::UserRole).toInt();
3326 if ((oldCpNumber != newCpNumber) ||
3328 (parentOldItem->text(0) != parentNewItem->text(0)) ) {
3331 }
else if ((parentOldItem->text(0) != parentNewItem->text(0)) ||
3332 (parentOldItem->text(3) != parentNewItem->text(3))) {
3335 parentOldItem = parentOldItem->parent();
3336 parentNewItem = parentNewItem->parent();
3347 ,
const std::string& modelDescription
3356 const G4Text& g4Text =
dynamic_cast<const G4Text&
>(visible);
3359 catch (
const std::bad_cast&) {
3366 if (g4Marker.
GetInfo() !=
"") {
3367 modelShortName = g4Marker.
GetInfo();
3370 catch (
const std::bad_cast&) {}
3372 if (modelShortName ==
"") {
3389 QList<QTreeWidgetItem *> resItem;
3391 QTreeWidgetItem * currentItem = NULL;
3392 const PVPath tmpFullPath;
3394 if (resItem.empty()) {
3404 currentItem = resItem.first();
3408 const QList<QTreeWidgetItem *>&
3409 resItems =
fSceneTreeComponentTreeWidget->findItems (QString(modelDescription.c_str()), Qt::MatchFixedString| Qt::MatchCaseSensitive|Qt::MatchRecursive, 0 );
3411 bool alreadyPresent =
false;
3412 for (
int i = 0; i < resItems.size(); ++i) {
3413 if (currentPOIndex == resItems.at(i)->data(0,Qt::UserRole).toInt()) {
3414 alreadyPresent =
true;
3417 if (!alreadyPresent) {
3437 QString modelShortName = model.data();
3438 if (modelShortName.mid(0,modelShortName.indexOf(
" ")) ==
"G4PhysicalVolumeModel") {
3441 if (modelShortName.mid(0,2) ==
"G4") {
3442 modelShortName = modelShortName.mid(2);
3444 if (modelShortName.indexOf(
"Model") != -1) {
3445 modelShortName = modelShortName.mid(0,modelShortName.indexOf(
"Model"));
3448 return modelShortName;
3468 if ( item->checkState(0) == Qt::Checked) {
3477 bool isFound =
false;
3478 for (
int i = 0; i < treeNode->childCount() ; ++i) {
3480 if (treeNode->child(i)->data(0,Qt::UserRole).toInt() == POindex) {
3481 if (treeNode->child(i)->checkState(0) == Qt::Checked) {
3495 std::string commandLine =
"";
3499 if (commandLine !=
"") {
3500 commandLine = std::string(
"# Disable auto refresh and quieten vis messages whilst scene and\n") +
3501 "# trajectories are established:\n" +
3502 "/vis/viewer/set/autoRefresh false\n" +
3503 "/vis/verbose errors" +
3505 "# Re-establish auto refreshing and verbosity:\n" +
3506 "/vis/viewer/set/autoRefresh true\n" +
3507 "/vis/verbose confirmations\n";
3515 std::string str( level,
' ' );
3516 std::string commandLine =
"\n#"+ str +
"PV Name: " + item->text(0).toStdString();
3518 if (item->text(3) !=
"") {
3519 commandLine +=
" LV Name: "+item->text(3).toStdString()+
"\n";
3521 commandLine +=
"/vis/geometry/set/visibility " + item->text(3).toStdString() +
" ! ";
3522 if (item->checkState(0) == Qt::Checked) {
3525 if (item->checkState(0) == Qt::Unchecked) {
3531 const QColor& c = item->data(2,Qt::UserRole).value<QColor>();
3532 std::stringstream red;
3533 red << ((double)c.red())/255;
3534 std::stringstream green;
3535 green << (double)c.green()/255;
3536 std::stringstream blue;
3537 blue << ((double)c.blue())/255;
3538 std::stringstream
alpha;
3539 alpha << ((double)c.alpha())/255;
3541 commandLine +=
"/vis/geometry/set/colour " + item->text(3).toStdString() +
" ! " + red.str() +
" " + green.str() +
" " + blue.str() +
" " +
alpha.str()+
"\n";
3544 commandLine +=
"\n";
3548 for (
int b=0;b< item->childCount();b++) {
3561 if (item->checkState(0) == Qt::Checked) {
3617 const QColor& old = QColor(item->data(2,Qt::UserRole).value<QColor>());
3619#if QT_VERSION < 0x040500
3623 const QColor& color = QColorDialog::getColor(old,
3625 " Get color and transparency",
3626 QColorDialog::ShowAlphaChannel);
3629 if (color.isValid()) {
3650 if (fullPath.size()) {
3665 const QColor& color = item->data(2,Qt::UserRole).value<QColor>();
3677const std::vector<G4ModelingParameters::VisAttributesModifier>*
3680 static std::vector<G4ModelingParameters::VisAttributesModifier>
3681 privateVisAttributesModifiers;
3683 privateVisAttributesModifiers.clear();
3736 return &privateVisAttributesModifiers;
3756 for (
int i = 0; i < itemList.size(); ++i) {
3757 QTreeWidgetItem* expandParentItem = itemList.at(i);
3758 while (expandParentItem->parent() != NULL) {
3759 expandParentItem->parent()->setExpanded(
true);
3760 expandParentItem = expandParentItem->parent();
3762 itemList.at(i)->setSelected(
true);
3769 for (
int a=0; a<item->childCount(); a++) {
3770 item->child(a)->setSelected(
false);
3771 item->child(a)->setExpanded(
false);
3779 QTreeWidgetItem* sParent = item;
3780 while (sParent->parent() != NULL) {
3781 sParent = sParent->parent();
3796 ,
double currentDepth
3797 ,QTreeWidgetItem* item
3799 double transparencyLevel = 0.;
3805 if ((lookForDepth-currentDepth) < 0) {
3806 item->setCheckState(0,Qt::Checked);
3808 transparencyLevel = 1;
3809 }
else if ((lookForDepth-currentDepth) > 1 ){
3810 item->setCheckState(0,Qt::Unchecked);
3812 transparencyLevel = 0;
3814 item->setCheckState(0,Qt::Checked);
3816 transparencyLevel = 1-(lookForDepth-currentDepth);
3820 if (item->data(0,Qt::UserRole).toInt() >= 0) {
3833 if (((color.
GetAlpha()-transparencyLevel) > 0.000001) ||
3834 ((color.
GetAlpha()-transparencyLevel) < -0.000001)) {
3835 if ((item->text(3) !=
"")) {
3844 (
int)(transparencyLevel*255)));
3849 for (
int b=0;b< item->childCount();b++) {
3880 if (poIndex != -1) {
3921 QTreeWidgetItem* cloneItem =
new QTreeWidgetItem();
3925 cloneItem->setText(0,item->text(0));
3926 cloneItem->setData(1,Qt::UserRole,item->data(1,Qt::UserRole).toInt());
3927 cloneItem->setText(2,item->text(2));
3928 cloneItem->setData(0, Qt::UserRole,item->data(0,Qt::UserRole).toInt());
3929 cloneItem->setText(3,item->text(3));
3930 cloneItem->setFlags(item->flags());
3931 cloneItem->setToolTip(0,item->toolTip(0));
3932 cloneItem->setCheckState(0,item->checkState(0));
3933 cloneItem->setSelected(item->isSelected());
3934 cloneItem->setExpanded(item->isExpanded ());
3936 cloneItem->setData(2,Qt::UserRole,item->data(2,Qt::UserRole).value<QColor>());
3946 QTreeWidgetItem* rootItem
3949 for (
int b=0;b< rootItem->childCount();b++) {
3951 QTreeWidgetItem *child = rootItem->child(b);
3954 int poIndex = child->data(0,Qt::UserRole).toInt();
3955 if (poIndex != -1) {
3971 std::map <int, QTreeWidgetItem*>::iterator i;
3987 int POIndex = item->data(0,Qt::UserRole).toInt();
3990 QPixmap pixmap = QPixmap(QSize(16, 16));
3991 if (item->data(0,Qt::UserRole).toInt() != -1) {
3994 pixmap.fill (QColor(255,255,255,255));
3996 QPainter painter(&pixmap);
3997 painter.setPen(Qt::black);
3998 painter.drawRect(0,0,15,15);
4000 item->setIcon(0,pixmap);
4001 item->setData(2,Qt::UserRole,qc);
4013 if (POindex == -1) {
4047 if (POindex == -1) {
4230 int treeWidgetInfosIgnoredCommands = 0;
4260 QString params =
"";
4281 params = QString().number(
fVP. IsCulling ());
4286 params =
"intersection";
4311 }
else if(commandTmp->
GetCommandName() ==
"globalLineWidthScale") {
4353 }
else if(commandTmp->
GetCommandName() ==
"lineSegmentsPerCircle") {
4365 params =
"orthogonal";
4372 params =
"constrainUpDirection";
4374 params =
"freeRotation";
4379 params = QString(
"on ") +
4390 params =
"wireframe";
4413 params = QString().number(up.
x())+
" "+ QString().number(up.
y())+
" "+QString().number(up.
z())+
" ";
4426 params = QString().number(direction.
x())+
" "+ QString().number(direction.
y())+
" "+QString().number(direction.
z());
4456 QTableWidgetItem *nameItem;
4457 QTableWidgetItem *paramItem;
4461 if (list.size() == 1) {
4462 nameItem = list.first();
4466 nameItem =
new QTableWidgetItem();
4467 paramItem =
new QTableWidgetItem();
4474 for(
G4int i_thGuidance=0; i_thGuidance < n_guidanceEntry; i_thGuidance++ ) {
4475 guidance += QString((
char*)(commandTmp->
GetGuidanceLine(i_thGuidance)).data()) +
"\n";
4478 nameItem->setToolTip(guidance);
4486 paramItem->setText(params);
4488 nameItem->setFlags(Qt::NoItemFlags);
4489 nameItem->setForeground(QBrush());
4492 treeWidgetInfosIgnoredCommands++;
4496 for (
int i=0; i<treeWidgetInfosIgnoredCommands; i++) {
4515 dial->resize(x+56,y+46);
4538 const std::vector < G4OpenGLViewerPickMap* > & pickMapVector =
GetPickDetails(aX,aY);
4542 QLayoutItem * wItem;
4545 delete wItem->widget();
4557#if QT_VERSION < 0x050600
4563 G4int nPickedObjectsWithAttributes = 0;
4564 for (
unsigned int a=0; a< pickMapVector.size(); a++) {
4565 const auto& pickMap = pickMapVector[a];
4567 std::ostringstream label;
4568 std::ostringstream content;
4569 std::string txt = pickMap->getAttributes()[0].data();
4570 if (pickMapVector[a]->getAttributes().size()) {
4571 ++nPickedObjectsWithAttributes;
4573 std::size_t pos1 = txt.find(
':');
4574 std::string storeKey = txt.substr(0,pos1);
4576 if (storeKey ==
"G4PhysicalVolumeModel") {
4579 std::size_t pos2 = txt.find(
':',pos1+1);
4580 std::size_t pos3 = txt.find(
'\n',pos2+1);
4581 label << txt.substr(pos2+1,pos3-pos2-1);
4583 }
else if (storeKey ==
"G4TrajectoriesModel") {
4585 label <<
"Trajectory:";
4586 std::size_t pos2 = txt.find(
':',pos1+1);
4587 std::size_t pos3 = txt.find(
'\n',pos2+1);
4588 label <<
" Run:" << txt.substr(pos2+1,pos3-pos2-1);
4589 std::size_t pos4 = txt.find(
':',pos3+1);
4590 std::size_t pos5 = txt.find(
'\n',pos4+1);
4591 label <<
", Event:" << txt.substr(pos4+1,pos5-pos4-1);
4595 label <<
"Hit number:" << a <<
", PickName: " << pickMap->getPickName();
4600 content << pickMap->print().data();
4601 G4int thisPickName = pickMap->getPickName();
4602 while (++a < pickMapVector.size()) {
4603 const auto& a_pickMap = pickMapVector[a];
4604 if (a_pickMap->getPickName() == thisPickName) {
4605 content << a_pickMap->print().data();
4612 QPushButton* pickCoutButton =
new QPushButton(label.str().c_str());
4613 pickCoutButton->setStyleSheet (
"text-align: left; padding: 1px; border: 0px;");
4620 newStr = QStringList(QString(content.str().c_str()).trimmed());
4622 QTextEdit* ed =
new QTextEdit();
4623 ed->setReadOnly(
true);
4625 ed->setVisible((
false));
4626 ed->append(newStr.join(
""));
4628#if QT_VERSION < 0x050600
4632 std::cout << pickCoutButton->text().toStdString() <<
" "<<
fPickInfosWidget->layout()->count()-1<< std::endl;
4638#if QT_VERSION < 0x050600
4643 QLabel * pushUp =
new QLabel(
"");
4644 QSizePolicy vPolicy = QSizePolicy(QSizePolicy::Minimum,QSizePolicy::Minimum);
4645 vPolicy.setVerticalStretch(10);
4646 pushUp->setSizePolicy(vPolicy);
4654 if (pickMapVector.size() > 0 ) {
4666 std::ostringstream oss;
4667 if (nPickedObjectsWithAttributes == 0) {
4669 }
else if (nPickedObjectsWithAttributes == 1) {
4672 oss << nPickedObjectsWithAttributes <<
" objects";
4674 oss <<
" selected - " <<
GetName();
4675 dial->setWindowTitle(oss.str().c_str());
4689 QTextEdit* ed =
dynamic_cast<QTextEdit*
>(w);
4690 QPushButton* button;
4692 if (a == pickItem) {
4693 w->setVisible(!w->isVisible());
4695 w->setVisible(
false);
4698 button =
dynamic_cast<QPushButton*
>(
fPickInfosWidget->layout()->itemAt(a-1)->widget());
4700 if (button->isVisible()) {
4728 + previous->text().toStdString()
4730 + item->text().toStdString()).c_str());
4762 if( n_parameterEntry > 0 ) {
4767 for(
G4int i_thParameter=0; i_thParameter<n_parameterEntry; i_thParameter++ ) {
4769 txt +=
"\nParameter : " + QString((
char*)(param->
GetParameterName()).data()) +
"\n";
4772 txt +=
" Parameter type : " + QString(QChar(param->
GetParameterType())) +
"\n";
4774 txt +=
" Omittable : True\n";
4776 txt +=
" Omittable : False\n";
4779 txt +=
" Default value : taken from the current value\n";
4781 txt +=
" Default value : " + QString((
char*)(param->
GetDefaultValue()).data())+
"\n";
4784 txt +=
" Parameter range : " + QString((
char*)(param->
GetParameterRange()).data())+
"\n";
4794#ifdef G4MULTITHREADED
4796void G4OpenGLQtViewer::DoneWithMasterThread()
4806void G4OpenGLQtViewer::SwitchToVisSubThread()
4810 QGLWidget* qGLW =
dynamic_cast<QGLWidget*
> (
fGLWidget) ;
4816 SetQGLContextVisSubThread(QThread::currentThread());
4830 qGLW->makeCurrent();
4833void G4OpenGLQtViewer::DoneWithVisSubThread()
4836 QGLWidget* qGLW =
dynamic_cast<QGLWidget*
> (
fGLWidget) ;
4842 qGLW->doneCurrent();
4844#if QT_VERSION > 0x050000
4846 qGLW->context()->moveToThread(fQGLContextMainThread);
4850void G4OpenGLQtViewer::SwitchToMasterThread()
4854 QGLWidget* qGLW =
dynamic_cast<QGLWidget*
> (
fGLWidget) ;
4864 qGLW->makeCurrent();
4868void G4OpenGLQtViewer::MovingToVisSubThread(){
4871 QGLWidget* qGLW =
dynamic_cast<QGLWidget*
> (
fGLWidget) ;
4886 SetQGLContextMainThread(QThread::currentThread());
4889 qGLW->doneCurrent();
4890#if QT_VERSION > 0x050000
4891 qGLW->context()->moveToThread(fQGLContextVisSubThread);
G4TemplateAutoLock< G4Mutex > G4AutoLock
static const G4double alpha
static constexpr double gray
#define G4CONDITION_INITIALIZER
#define G4MUTEX_INITIALIZER
#define G4CONDITIONWAIT(cond, mutex)
#define G4CONDITIONBROADCAST(cond)
G4GLOB_DLL std::ostream G4cerr
G4GLOB_DLL std::ostream G4cout
G4double GetAlpha() const
G4double GetGreen() const
bool checkSaveFileNameParameters()
void setRecordingInfos(QString)
void setRecordingStatus(QString)
bool checkTempFolderParameters()
bool checkEncoderSwParameters()
void toggleFullScreen(bool)
void toggleSurfaceAction(int)
QTreeWidgetItem * getOldTreeWidgetItem(int POindex)
void G4MouseReleaseEvent(QMouseEvent *evnt)
std::map< int, QTreeWidgetItem * >::const_iterator fOldLastSceneTreeWidgetAskForIteratorEnd
void showMovieParametersDialog()
QWidget * fUISceneTreeWidget
QTreeWidget * fSceneTreeComponentTreeWidget
void initMovieParameters()
void createSceneTreeWidget()
bool parseAndCheckVisibility(QTreeWidgetItem *treeNode, int POindex)
QString getProcessErrorMsg()
void changeSearchSelection()
std::map< int, QColor > fOldVisAttrColorMap
void changeColorAndTransparency(GLuint index, G4Color color)
QLineEdit * fFilterOutput
RECORDING_STEP fRecordingStep
bool isPVVolume(QTreeWidgetItem *item)
QPixmap * fTreeIconClosed
std::map< int, PVPath > fOldTreeItemModels
QTreeWidgetItem * createTreeWidgetItem(const PVPath &fullPath, const QString &name, int copyNb, int POIndex, const QString &logicalName, Qt::CheckState state, QTreeWidgetItem *treeNode, const G4Colour &color)
void rotateQtSceneToggle(float, float)
QAction * fMouseRotateAction
void G4MouseMoveEvent(QMouseEvent *event)
std::map< int, QTreeWidgetItem * >::const_iterator fLastSceneTreeWidgetAskForIteratorEnd
QScrollArea * fPickInfosScrollArea
void setCheckComponent(QTreeWidgetItem *item, bool check)
void tableWidgetViewerSetItemChanged(QTableWidgetItem *)
void G4keyPressEvent(QKeyEvent *event)
void updateViewerPropertiesTableWidget()
void addNonPVSceneTreeElement(const G4String &model, int currentPVPOIndex, const std::string &modelDescription, const G4Visible &visible)
void displayRecordingStatus()
G4AutoLock * lWaitForVisSubThreadQtOpenGLContextMoved
QAction * fDrawingLineSurfaceRemoval
QSignalMapper * fSignalMapperPicking
QString getSaveFileName()
void actionMovieParameters()
void changeDepthInSceneTree(int)
void G4MousePressEvent(QMouseEvent *event)
void G4wheelEvent(QWheelEvent *event)
QString GetCommandParameterList(const G4UIcommand *aCommand)
void cloneSceneTree(QTreeWidgetItem *rootItem)
std::map< int, PVPath > fTreeItemModels
QAction * fMouseZoomOutAction
void G4MouseDoubleClickEvent()
QWidget * fSceneTreeWidget
QAction * fProjectionPerspective
bool fCheckSceneTreeComponentSignalLock
void updateSceneTreeWidget()
QString removeTempFolder()
QString getModelShortName(const G4String &modelShortName)
G4OpenGLQtViewer(G4OpenGLSceneHandler &scene)
void toggleSceneTreeComponentPickingCout(int)
QAction * fDrawingLineRemoval
bool isTouchableVisible(int POindex)
void moveScene(float, float, float, bool)
QWidget * fUIPickInfosWidget
void actionChangeDefaultColor()
unsigned int fSceneTreeDepth
void processLookForFinished()
QSignalMapper * fSignalMapperMouse
QTreeWidgetItem * cloneWidgetItem(QTreeWidgetItem *item)
void rescaleImage(int, int)
void G4manageContextMenuEvent(QContextMenuEvent *e)
QTreeWidgetItem * fModelShortNameItem
QTextEdit * fShortcutsDialogInfos
void processEncodeFinished()
QString fMovieTempFolderPath
G4Color fLastHighlightColor
std::map< int, QTreeWidgetItem * >::const_iterator fLastSceneTreeWidgetAskForIterator
QAction * fDrawingSurfaceRemoval
std::string parseSceneTreeElementAndSaveState(QTreeWidgetItem *item, unsigned int level)
std::vector< QTreeWidgetItem * > fOldNullPoIndexSceneTreeWidgetQuickVector
GLuint fLastHighlightName
QString getTempFolderPath()
QAction * fMousePickAction
void toggleMouseAction(int)
void changeOpenCloseVisibleHiddenSelectedColorSceneTreeElement(QTreeWidgetItem *subItem)
int fTreeWidgetInfosIgnoredCommands
void actionChangeTextColor()
QTableWidget * fViewerPropertiesTableWidget
void actionChangeBackgroundColor()
void rotateQtScene(float, float)
bool exportImage(std::string name="", int width=-1, int height=-1)
std::vector< PVNodeID > PVPath
void toggleProjection(bool)
void currentTabActivated(int)
QWidget * fPickInfosWidget
void updateToolbarAndMouseContextMenu()
std::map< int, QTreeWidgetItem * > fOldPositivePoIndexSceneTreeWidgetQuickMap
QDialog * fShortcutsDialog
void updateKeyModifierState(const Qt::KeyboardModifiers &)
void G4keyReleaseEvent(QKeyEvent *event)
void clearSceneTreeSelection(QTreeWidgetItem *)
void sceneTreeComponentSelected()
G4Colour getColorForPoIndex(int poIndex)
void toggleHiddenMarkers(bool)
void setRecordingStatus(RECORDING_STEP)
void createRadioAction(QAction *, QAction *, const std::string &, unsigned int a=1)
void updatePositivePoIndexSceneTreeWidgetQuickMap(int POindex, QTreeWidgetItem *item)
void updatePickInfosWidget(int, int)
QAction * fMouseMoveAction
virtual ~G4OpenGLQtViewer()
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!//
void toggleAntialiasing(bool)
void DrawText(const G4Text &)
QWidget * fUIViewerPropertiesWidget
void createViewerPropertiesWidget()
QTreeWidgetItem * getTreeWidgetItem(int POindex)
QString setEncoderPath(QString path)
QString fTouchableVolumes
virtual void CreateMainWindow(QGLWidget *, const QString &)
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!//
void toggleTransparency(bool)
QAction * fProjectionOrtho
bool fViewerPropertiesTableWidgetIsInit
void sceneTreeComponentItemChanged(QTreeWidgetItem *item, int id)
QSlider * fSceneTreeDepthSlider
QSignalMapper * fSignalMapperSurface
QAction * fDrawingWireframe
G4OpenGLQtMovieDialog * fMovieParametersDialog
bool generateMpegEncoderParameters()
void processEncodeStdout()
QString createTempFolder()
QWidget * getParentWidget()
int fLastExportSliderValue
void setRecordingInfos(const QString &)
virtual void updateQWidget()=0
QString setSaveFileName(QString path)
void changeDepthOnSceneTreeItem(double lookForDepth, double currentDepth, QTreeWidgetItem *item)
QAction * fMouseZoomInAction
void addPVSceneTreeElement(const G4String &model, G4PhysicalVolumeModel *pPVModel, int currentPVPOIndex)
void changeQColorForTreeWidgetItem(QTreeWidgetItem *item, const QColor &)
void createSceneTreeComponent()
std::map< int, QTreeWidgetItem * > fPositivePoIndexSceneTreeWidgetQuickMap
const std::vector< G4ModelingParameters::VisAttributesModifier > * GetPrivateVisAttributesModifiers() const
std::string parseSceneTreeAndSaveState()
bool parseAndInsertInSceneTree(QTreeWidgetItem *, G4PhysicalVolumeModel *pPVModel, unsigned int fullPathIndex, const QString &parentRoot, unsigned int currentIndex, int currentPVPOIndex)
QString fParameterFileName
std::map< int, QTreeWidgetItem * >::const_iterator fOldLastSceneTreeWidgetAskForIterator
G4AutoLock * lWaitForVisSubThreadQtOpenGLContextInitialized
void createPickInfosWidget()
QString setTempFolderPath(QString path)
bool isSameSceneTreeElement(QTreeWidgetItem *parentOldItem, QTreeWidgetItem *parentNewItem)
void displaySceneTreeComponent()
std::vector< std::string > fExportImageFormatVector
void rotateSceneToggle(G4double dx, G4double dy)
unsigned int getWinHeight() const
std::string fExportImageFormat
void ResizeWindow(unsigned int, unsigned int)
unsigned int getWinWidth() const
std::string fDefaultExportImageFormat
bool setExportFilename(G4String name, G4bool inc=true)
void addExportImageFormat(std::string format)
G4bool antialiasing_enabled
virtual void DrawText(const G4Text &)
void setExportSize(G4int, G4int)
void rotateScene(G4double dx, G4double dy)
G4bool transparency_enabled
virtual bool exportImage(std::string name="", int width=-1, int height=-1)
std::string getRealPrintFilename()
GLdouble getSceneNearWidth()
const std::vector< G4OpenGLViewerPickMap * > & GetPickDetails(GLdouble x, GLdouble y)
const G4Transform3D & GetTransformation() const
const std::vector< G4PhysicalVolumeNodeID > & GetFullPVPath() const
static G4Qt * getInstance()
const G4Point3D & GetStandardTargetPoint() const
bool owns_lock() const noexcept
G4double GetYOffset() const
G4double GetXOffset() const
void SetIconPickSelected()
QWidget * GetViewerPropertiesWidget()
void SetIconOrthoSelected()
bool IsIconRotateSelected()
void SetIconZoomInSelected()
QPixmap * getSearchIcon()
QWidget * GetSceneTreeWidget()
bool IsIconZoomOutSelected()
void SetIconZoomOutSelected()
void SetIconHLRSelected()
bool IsIconZoomInSelected()
void SetIconPerspectiveSelected()
QTabWidget * GetViewerTabWidget()
QWidget * GetPickInfosWidget()
void SetIconSolidSelected()
void SetIconRotateSelected()
bool IsIconPickSelected()
bool IsIconMoveSelected()
void SetIconWireframeSelected()
bool AddTabWidget(QWidget *, QString)
void SetIconMoveSelected()
void SetIconHLHSRSelected()
G4int GetCommandEntry() const
G4UIcommand * GetCommand(G4int i)
G4UIcommandTree * FindCommandTree(const char *commandPath)
std::size_t GetParameterEntries() const
const G4String & GetGuidanceLine(G4int i) const
G4UIparameter * GetParameter(G4int i) const
std::size_t GetGuidanceEntries() const
const G4String & GetCommandName() const
G4UIcommandTree * GetTree() const
G4int ApplyCommand(const char *aCommand)
G4UIsession * GetG4UIWindow() const
static G4UImanager * GetUIpointer()
const G4String & GetParameterCandidates() const
const G4String & GetParameterGuidance() const
G4bool IsOmittable() const
const G4String & GetParameterRange() const
G4bool GetCurrentAsDefault() const
char GetParameterType() const
const G4String & GetParameterName() const
const G4String & GetDefaultValue() const
G4Interactor GetMainInteractor()
G4Point3D GetPosition() const
virtual const G4String & GetInfo() const
const G4Colour & GetTextColour(const G4Text &)
const G4Colour & GetColour()
G4Scene * GetScene() const
G4double GetMarkerSize(const G4VMarker &, MarkerSizeType &)
void SetTouchable(const std::vector< G4PhysicalVolumeModel::G4PhysicalVolumeNodeID > &fullPath)
const G4String & GetName() const
G4VSceneHandler & fSceneHandler
void SetNeedKernelVisit(G4bool need)
void TouchableSetVisibility(const std::vector< G4PhysicalVolumeModel::G4PhysicalVolumeNodeID > &fullPath, G4bool visibility)
void TouchableSetColour(const std::vector< G4PhysicalVolumeModel::G4PhysicalVolumeNodeID > &fullPath, const G4Colour &)
void SetAutoRefresh(G4bool)
void SetBackgroundColour(const G4Colour &)
G4int GetNoOfSides() const
G4int GetWindowAbsoluteLocationHintY(G4int) const
CutawayMode GetCutawayMode() const
G4double GetExplodeFactor() const
G4bool IsMarkerNotHidden() const
unsigned int GetWindowSizeHintX() const
G4double GetGlobalLineWidthScale() const
void SetPerspectiveProjection(G4double fieldHalfAngle=30. *CLHEP::deg)
void SetDefaultColour(const G4Colour &)
void SetDrawingStyle(G4ViewParameters::DrawingStyle style)
const G4Colour & GetBackgroundColour() const
const G4Vector3D & GetLightpointDirection() const
void SetDefaultTextColour(const G4Colour &)
const G4Vector3D & GetViewpointDirection() const
const G4Point3D & GetCurrentTargetPoint() const
G4double GetFieldHalfAngle() const
const G4VisAttributes * GetDefaultTextVisAttributes() const
G4double GetZoomFactor() const
void SetOrthogonalProjection()
G4int GetWindowAbsoluteLocationHintX(G4int) const
void IncrementPan(G4double right, G4double up)
const G4Vector3D & GetUpVector() const
void SetMarkerNotHidden()
G4double GetGlobalMarkerScale() const
void SetZoomFactor(G4double zoomFactor)
const G4VisAttributes * GetDefaultVisAttributes() const
RotationStyle GetRotationStyle() const
G4bool IsAutoRefresh() const
unsigned int GetWindowSizeHintY() const
G4bool GetLightsMoveWithCamera() const
void SetAuxEdgeVisible(G4bool)
const G4Plane3D & GetSectionPlane() const
DrawingStyle GetDrawingStyle() const
G4bool IsAuxEdgeVisible() const
const G4Color & GetColor() const
Point3D< T > point(const Point3D< T > &p) const
Normal3D< T > normal() const
static constexpr double degree
const char * name(G4int ptype)
static const G4LorentzVector zero(0., 0., 0., 0.)
G4Mutex mWaitForVisSubThreadQtOpenGLContextMoved
G4Mutex mWaitForVisSubThreadQtOpenGLContextInitialized
def connect(endpoint="tcp://127.0.0.1:5555")
static PROLOG_HANDLER error