Geant4 11.2.2
Toolkit for the simulation of the passage of particles through matter
Loading...
Searching...
No Matches
G4OpenGLQtViewer Class Referenceabstract

#include <G4OpenGLQtViewer.hh>

+ Inheritance diagram for G4OpenGLQtViewer:

Public Slots

void startPauseVideo ()
 

Public Member Functions

 G4OpenGLQtViewer (G4OpenGLSceneHandler &scene)
 
virtual ~G4OpenGLQtViewer ()
 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!//
 
virtual void updateQWidget ()=0
 
void updateSceneTreeWidget ()
 
void updateViewerPropertiesTableWidget ()
 
void updatePickInfosWidget (int, int)
 
QString setEncoderPath (QString path)
 
QString getEncoderPath ()
 
QString setTempFolderPath (QString path)
 
QString getTempFolderPath ()
 
QString setSaveFileName (QString path)
 
QString getSaveFileName ()
 
bool isRecording ()
 
bool isStopped ()
 
bool isPaused ()
 
bool isEncoding ()
 
bool isWaiting ()
 
bool isFailed ()
 
void setWaiting ()
 
bool isBadEncoder ()
 
bool isBadOutput ()
 
bool isBadTmp ()
 
bool isSuccess ()
 
void setBadTmp ()
 
void setBadOutput ()
 
void setBadEncoder ()
 
bool isReadyToEncode ()
 
void resetRecording ()
 
void encodeVideo ()
 
void stopVideo ()
 
void saveVideo ()
 
bool generateMpegEncoderParameters ()
 
void displayRecordingStatus ()
 
void DrawText (const G4Text &)
 
void ResetView ()
 
void addPVSceneTreeElement (const G4String &model, G4PhysicalVolumeModel *pPVModel, int currentPVPOIndex)
 
void addNonPVSceneTreeElement (const G4String &model, int currentPVPOIndex, const std::string &modelDescription, const G4Visible &visible)
 
bool isTouchableVisible (int POindex)
 
void clearTreeWidget ()
 
bool exportImage (std::string name="", int width=-1, int height=-1)
 
void G4MousePressEvent (QMouseEvent *event)
 
void G4wheelEvent (QWheelEvent *event)
 
void G4keyPressEvent (QKeyEvent *event)
 
void G4keyReleaseEvent (QKeyEvent *event)
 
void G4MouseDoubleClickEvent ()
 
void G4MouseReleaseEvent (QMouseEvent *evnt)
 
void G4MouseMoveEvent (QMouseEvent *event)
 
- Public Member Functions inherited from G4OpenGLViewer
void ClearView ()
 
void ClearViewWithoutFlush ()
 
bool setExportImageFormat (std::string format, bool quiet=false)
 
- Public Member Functions inherited from G4VViewer
 G4VViewer (G4VSceneHandler &, G4int id, const G4String &name="")
 
virtual ~G4VViewer ()
 
virtual void Initialise ()
 
virtual void DrawView ()=0
 
void RefreshView ()
 
virtual void ShowView ()
 
std::vector< G4ThreeVectorComputeFlyThrough (G4Vector3D *)
 
SceneTreeSceneAccessSceneTreeScene ()
 
G4SceneTreeItemAccessSceneTree ()
 
void UpdateGUISceneTree ()
 
const G4StringGetName () const
 
const G4StringGetShortName () const
 
void SetName (const G4String &)
 
G4int GetViewId () const
 
G4VSceneHandlerGetSceneHandler () const
 
const G4ViewParametersGetViewParameters () const
 
const G4ViewParametersGetDefaultViewParameters () const
 
G4double GetKernelVisitElapsedTimeSeconds () const
 
void SetViewParameters (const G4ViewParameters &vp)
 
void SetDefaultViewParameters (const G4ViewParameters &vp)
 
const G4VisAttributesGetApplicableVisAttributes (const G4VisAttributes *) const
 
void SetNeedKernelVisit (G4bool need)
 
void NeedKernelVisit ()
 
void ProcessView ()
 

Protected Slots

void updateToolbarAndMouseContextMenu ()
 

Protected Member Functions

void CreateGLQtContext ()
 
virtual void CreateMainWindow (G4QGLWidgetType *, const QString &)
 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!//
 
void G4manageContextMenuEvent (QContextMenuEvent *e)
 
void rotateQtScene (float, float)
 
void rotateQtSceneToggle (float, float)
 
void moveScene (float, float, float, bool)
 
void FinishView ()
 
void updateKeyModifierState (const Qt::KeyboardModifiers &)
 
void displaySceneTreeComponent ()
 
G4Colour getColorForPoIndex (int poIndex)
 
const std::vector< G4ModelingParameters::VisAttributesModifier > * GetPrivateVisAttributesModifiers () const
 
bool isCurrentWidget ()
 
void savePPMToTemp ()
 
- Protected Member Functions inherited from G4OpenGLViewer
 G4OpenGLViewer (G4OpenGLSceneHandler &scene)
 
virtual ~G4OpenGLViewer ()
 
void SetView ()
 
void ResetView ()
 
void ChangePointSize (G4double size)
 
void ChangeLineWidth (G4double width)
 
void HaloingFirstPass ()
 
void HaloingSecondPass ()
 
void HLRFirstPass ()
 
void HLRSecondPass ()
 
void HLRThirdPass ()
 
void InitializeGLView ()
 
void ResizeGLView ()
 
void ResizeWindow (unsigned int, unsigned int)
 
virtual G4String Pick (GLdouble x, GLdouble y)
 
const std::vector< G4OpenGLViewerPickMap * > & GetPickDetails (GLdouble x, GLdouble y)
 
virtual void CreateFontLists ()
 
void rotateScene (G4double dx, G4double dy)
 
void rotateSceneToggle (G4double dx, G4double dy)
 
void setExportSize (G4int, G4int)
 
bool setExportFilename (G4String name, G4bool inc=true)
 
std::string getRealPrintFilename ()
 
unsigned int getWinWidth () const
 
unsigned int getWinHeight () const
 
G4bool sizeHasChanged ()
 
GLdouble getSceneNearWidth ()
 
GLdouble getSceneFarWidth ()
 
GLdouble getSceneDepth ()
 
void addExportImageFormat (std::string format)
 
G4bool isGl2psWriting ()
 
G4bool isFramebufferReady ()
 
void g4GluPickMatrix (GLdouble x, GLdouble y, GLdouble width, GLdouble height, GLint viewport[4])
 
void g4GluLookAt (GLdouble eyex, GLdouble eyey, GLdouble eyez, GLdouble centerx, GLdouble centery, GLdouble centerz, GLdouble upx, GLdouble upy, GLdouble upz)
 
void g4GlOrtho (GLdouble left, GLdouble right, GLdouble bottom, GLdouble top, GLdouble near, GLdouble far)
 
void g4GlFrustum (GLdouble left, GLdouble right, GLdouble bottom, GLdouble top, GLdouble near, GLdouble far)
 
- Protected Member Functions inherited from G4VViewer
void SetTouchable (const std::vector< G4PhysicalVolumeModel::G4PhysicalVolumeNodeID > &fullPath)
 
void TouchableSetVisibility (const std::vector< G4PhysicalVolumeModel::G4PhysicalVolumeNodeID > &fullPath, G4bool visibility)
 
void TouchableSetColour (const std::vector< G4PhysicalVolumeModel::G4PhysicalVolumeNodeID > &fullPath, const G4Colour &)
 

Protected Attributes

G4UIQtfUiQt
 
QWidget * fGLWidget
 
int fRecordFrameNumber
 
bool fHasToRepaint
 
bool fUpdateGLLock
 
bool fQGLWidgetInitialiseCompleted
 
bool fPaintEventLock
 
bool fMouseOnSceneTree
 
- Protected Attributes inherited from G4OpenGLViewer
G4bool fPrintColour
 
G4bool fVectoredPs
 
G4OpenGLSceneHandlerfOpenGLSceneHandler
 
G4Colour background
 
G4bool transparency_enabled
 
G4bool antialiasing_enabled
 
G4bool haloing_enabled
 
G4gl2psfGL2PSAction
 
G4double fRot_sens
 
G4double fPan_sens
 
unsigned int fWinSize_x
 
unsigned int fWinSize_y
 
std::vector< std::string > fExportImageFormatVector
 
std::string fDefaultExportImageFormat
 
std::string fExportImageFormat
 
int fExportFilenameIndex
 
G4int fPrintSizeX
 
G4int fPrintSizeY
 
- Protected Attributes inherited from G4VViewer
G4VSceneHandlerfSceneHandler
 
G4int fViewId
 
G4String fName
 
G4String fShortName
 
G4ViewParameters fVP
 
G4ViewParameters fDefaultVP
 
G4double fKernelVisitElapsedTimeSeconds = 999.
 
SceneTreeScene fSceneTreeScene
 
G4SceneTreeItem fSceneTree
 
G4bool fNeedKernelVisit
 

Detailed Description

Definition at line 89 of file G4OpenGLQtViewer.hh.

Constructor & Destructor Documentation

◆ G4OpenGLQtViewer()

G4OpenGLQtViewer::G4OpenGLQtViewer ( G4OpenGLSceneHandler & scene)

Definition at line 217 of file G4OpenGLQtViewer.cc.

220 :G4VViewer (scene, -1)
221 ,G4OpenGLViewer (scene)
222 ,fUiQt(NULL)
223 ,fGLWidget(NULL)
225 ,fMouseOnSceneTree(false)
226 ,fContextMenu(0)
227 ,fLastPickPoint(-1,-1)
228 ,fDeltaDepth(0.01)
229 ,fDeltaZoom(0.05)
230 ,fHoldKeyEvent(false)
231 ,fHoldMoveEvent(false)
232 ,fHoldRotateEvent(false)
233 ,fAutoMove(false)
234 ,fEncoderPath("")
235 ,fTempFolderPath("")
236 ,fMovieTempFolderPath("")
237 ,fSaveFileName("")
238 ,fParameterFileName("ppmtompeg_encode_parameter_file.par")
239 ,fMovieParametersDialog(NULL)
240 ,fRecordingStep(WAIT)
241 ,fProcess(NULL)
242 ,fNbMaxFramesPerSec(100)
243 ,fNbMaxAnglePerSec(360)
244 ,fLaunchSpinDelay(100)
245 ,fUISceneTreeWidget(NULL)
246 ,fUIViewerPropertiesWidget(NULL)
247 ,fUIPickInfosWidget(NULL)
248 ,fNoKeyPress(true)
249 ,fAltKeyPress(false)
250 ,fControlKeyPress(false)
251 ,fShiftKeyPress(false)
252 ,fBatchMode(false)
253 ,fCheckSceneTreeComponentSignalLock(false)
254 ,fViewerPropertiesTableWidgetIsInit(false)
255 ,fSceneTreeComponentTreeWidget(NULL)
256 ,fSceneTreeWidget(NULL)
257 ,fPVRootNodeCreate(false)
258 ,fFilterOutput(NULL)
259 ,fNbRotation(0)
260 ,fTimeRotation(0)
261 ,fTouchableVolumes("Touchables")
262 ,fShortcutsDialog(NULL)
263 ,fViewerPropertiesTableWidget(NULL)
264 ,fPickInfosWidget(NULL)
265 ,fPickInfosScrollArea(NULL)
266 ,fTreeWidgetInfosIgnoredCommands(0)
267 ,fSceneTreeDepthSlider(NULL)
268 ,fSceneTreeDepth(1)
269 ,fModelShortNameItem(NULL)
270 ,fMaxPOindexInserted(-1)
271 ,fTreeIconOpen(NULL)
272 ,fTreeIconClosed(NULL)
273 ,fLastExportSliderValue(80)
274 ,fLastHighlightColor(G4Color(0,0,0,0))
275 ,fLastHighlightName(0)
276 ,fIsDeleting(false)
277{
278 lWaitForVisSubThreadQtOpenGLContextInitialized
279 = new G4AutoLock(mWaitForVisSubThreadQtOpenGLContextInitialized,
280 std::defer_lock);
281 lWaitForVisSubThreadQtOpenGLContextMoved
282 = new G4AutoLock(mWaitForVisSubThreadQtOpenGLContextMoved,
283 std::defer_lock);
284
285 // launch Qt if not
286 if (QCoreApplication::instance () == NULL) {
287 fBatchMode = true;
288 }
290
291 fLastPos3 = QPoint(-1,-1);
292 fLastPos2 = QPoint(-1,-1);
293 fLastPos1 = QPoint(-1,-1);
294
295 initMovieParameters();
296
297#if (QT_VERSION < QT_VERSION_CHECK(5, 14, 0))
298 fLastEventTime = new QTime();
299#else
300 fLastEventTime = new QElapsedTimer();
301#endif
302 // Set default path and format
303 fFileSavePath = QDir::currentPath();
304
305 // add available export format
306 QList<QByteArray> formats = QImageWriter::supportedImageFormats ();
307 for (int i = 0; i < formats.size(); ++i) {
308 addExportImageFormat(formats.at(i).data());
309 }
310
311 const char * const icon1[]={
312 /* columns rows colors chars-per-pixel */
313 "20 20 34 1",
314 " c None",
315 ". c #7C7C7C7C7C7C",
316 "X c #7D7D7D7D7D7D",
317 "o c #828282828282",
318 "O c #838383838383",
319 "+ c #848484848484",
320 "@ c #858585858585",
321 "# c #878787878787",
322 "$ c #888888888888",
323 "% c #8B8B8B8B8B8B",
324 "& c #8C8C8C8C8C8C",
325 "* c #8F8F8F8F8F8F",
326 "= c #909090909090",
327 "- c #919191919191",
328 "; c #999999999999",
329 ": c #9D9D9D9D9D9D",
330 "> c #A2A2A2A2A2A2",
331 ", c #A3A3A3A3A3A3",
332 "< c #A5A5A5A5A5A5",
333 "1 c #A6A6A6A6A6A6",
334 "2 c #B3B3B3B3B3B3",
335 "3 c #B6B6B6B6B6B6",
336 "4 c #C2C2C2C2C2C2",
337 "5 c #C6C6C6C6C6C6",
338 "6 c #CACACACACACA",
339 "7 c #CFCFCFCFCFCF",
340 "8 c #D0D0D0D0D0D0",
341 "9 c #D4D4D4D4D4D4",
342 "0 c #D7D7D7D7D7D7",
343 "q c #DEDEDEDEDEDE",
344 "w c #E0E0E0E0E0E0",
345 "e c #E7E7E7E7E7E7",
346 "r c #F4F4F4F4F4F4",
347 "t c #F7F7F7F7F7F7",
348 " ",
349 " ",
350 " ",
351 " ",
352 " ",
353 " ",
354 " =========> ",
355 " 7&X+++Oo<e ",
356 " 2o+@@+-8 ",
357 " w;.#@+3 ",
358 " 4$o@:q ",
359 " r1X%5 ",
360 " 9*,t ",
361 " 60 ",
362 " ",
363 " ",
364 " ",
365 " ",
366 " ",
367 " "
368 };
369 const char * const icon2[]={
370 "20 20 68 1",
371 " c None",
372 ". c #5F5F10102323",
373 "X c #40405F5F1010",
374 "o c #696963632E2E",
375 "O c #101019194C4C",
376 "+ c #101023237070",
377 "@ c #70702D2D6363",
378 "# c #73732D2D6464",
379 "$ c #79792E2E6767",
380 "% c #19194C4C5353",
381 "& c #2D2D63636161",
382 "* c #2E2E61617070",
383 "= c #6F6F6E6E4343",
384 "- c #707065655F5F",
385 "; c #727279795454",
386 ": c #535341417070",
387 "> c #797954547979",
388 ", c #434361617474",
389 "< c #414170707070",
390 "1 c #686869696363",
391 "2 c #6C6C69696363",
392 "3 c #656567676F6F",
393 "4 c #69696F6F6E6E",
394 "5 c #747465656767",
395 "6 c #757562626C6C",
396 "7 c #70706C6C6969",
397 "8 c #616174746565",
398 "9 c #656573736969",
399 "0 c #616174746969",
400 "q c #707075756262",
401 "w c #797970706565",
402 "e c #636361617474",
403 "r c #67676F6F7272",
404 "t c #727261617070",
405 "y c #616170707070",
406 "u c #6F6F72727979",
407 "i c #67676E6ED1D1",
408 "p c #808080808080",
409 "a c #828282828282",
410 "s c #838383838383",
411 "d c #848484848484",
412 "f c #858585858585",
413 "g c #868686868686",
414 "h c #888888888888",
415 "j c #8A8A8A8A8A8A",
416 "k c #8D8D8D8D8D8D",
417 "l c #8F8F8F8F8F8F",
418 "z c #909090909090",
419 "x c #949494949494",
420 "c c #9C9C9C9C9C9C",
421 "v c #9F9F9F9F9F9F",
422 "b c #A2A2A2A2A2A2",
423 "n c #AEAEAEAEAEAE",
424 "m c #B7B7B7B7B7B7",
425 "M c #C7C7C7C7C7C7",
426 "N c #C9C9C9C9C9C9",
427 "B c #D1D1D1D1D1D1",
428 "V c #D4D4D4D4D4D4",
429 "C c #D9D9D9D9D9D9",
430 "Z c #E0E0E0E0E0E0",
431 "A c #E2E2E2E2E2E2",
432 "S c #EEEEEEEEEEEE",
433 "D c #F0F0F0F0F0F0",
434 "F c #F5F5F5F5F5F5",
435 "G c #F6F6F6F6F6F6",
436 "H c #F9F9F9F9F9F9",
437 "J c #FCFCFCFCFCFC",
438 "K c #FDFDFDFDFDFD",
439 " ",
440 " ",
441 " ",
442 " ",
443 " ",
444 " bC ",
445 " zjnD ",
446 " ldjjMK ",
447 " zdhdjcA ",
448 " zddhdddVK ",
449 " zghdalBH ",
450 " zghamSK ",
451 " lubZH ",
452 " xMF ",
453 " G ",
454 " ",
455 " ",
456 " ",
457 " ",
458 " ",
459
460 };
461
462 const char * const search[] = {
463 /* columns rows colors chars-per-pixel */
464 "19 19 8 1",
465 " c #5C5C5C",
466 ". c #7D7D7D",
467 "X c #9B9B9B",
468 "o c #C3C3C3",
469 "O c None",
470 "+ c #000000",
471 "@ c #000000",
472 "# c None",
473 /* pixels */
474 "OOOOOOOOOOOOOOOOOOO",
475 "OOOOOOOOOOOOOOOOOOO",
476 "OOOOOOOo. .oOOOOOO",
477 "OOOOOOX XOOOOO",
478 "OOOOOo XOOX oOOOO",
479 "OOOOO. XOOOOX .OOOO",
480 "OOOOO OOOOOO OOOO",
481 "OOOOO OOOOOO OOOO",
482 "OOOOO. XOOOOo .OOOO",
483 "OOOOOo oOOo oOOOO",
484 "OOOOOOX XOOOO",
485 "OOOOOOOo. . XOOO",
486 "OOOOOOOOOOOOO. XOO",
487 "OOOOOOOOOOOOOO. XOO",
488 "OOOOOOOOOOOOOOOoOOO",
489 "OOOOOOOOOOOOOOOOOOO",
490 "OOOOOOOOOOOOOOOOOOO",
491 "OOOOOOOOOOOOOOOOOOO",
492 "OOOOOOOOOOOOOOOOOOO"
493 };
494
495 fSearchIcon = new QPixmap(search);
496 fTreeIconOpen = new QPixmap(icon1);
497 fTreeIconClosed = new QPixmap(icon2);
498
499}
G4TemplateAutoLock< G4Mutex > G4AutoLock
G4Colour G4Color
Definition G4Color.hh:41
G4OpenGLViewer(G4OpenGLSceneHandler &scene)
void addExportImageFormat(std::string format)
static G4Qt * getInstance()
Definition G4Qt.cc:51
G4VViewer(G4VSceneHandler &, G4int id, const G4String &name="")
Definition G4VViewer.cc:49

◆ ~G4OpenGLQtViewer()

G4OpenGLQtViewer::~G4OpenGLQtViewer ( )
virtual

!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!//

Definition at line 502 of file G4OpenGLQtViewer.cc.

506{
507 fIsDeleting = true;
508
509 // remove scene tree from layout
510 // Delete all the existing buttons in the layout
511 QLayoutItem *wItem;
512 if (fSceneTreeWidget != NULL) {
513 if (fSceneTreeWidget->layout() != NULL) {
514 while ((wItem = fSceneTreeWidget->layout()->takeAt(0)) != 0) {
515 delete wItem->widget();
516 delete wItem;
517 }
518 }
519 }
520
521 // Delete the open/close icons
522 delete fTreeIconOpen;
523 delete fTreeIconClosed;
524
525 G4cout <<removeTempFolder().toStdString().c_str() <<G4endl;
526
527 delete lWaitForVisSubThreadQtOpenGLContextInitialized;
528 delete lWaitForVisSubThreadQtOpenGLContextMoved;
529
530}
#define G4endl
Definition G4ios.hh:67
G4GLOB_DLL std::ostream G4cout

Member Function Documentation

◆ addNonPVSceneTreeElement()

void G4OpenGLQtViewer::addNonPVSceneTreeElement ( const G4String & model,
int currentPVPOIndex,
const std::string & modelDescription,
const G4Visible & visible )

Definition at line 3263 of file G4OpenGLQtViewer.cc.

3268 {
3269
3270 QString modelShortName = getModelShortName(model);
3271 G4Colour color;
3272
3273 // Special case for text
3274 try {
3275 const G4Text& g4Text = dynamic_cast<const G4Text&>(visible);
3276 color = fSceneHandler.GetTextColour(g4Text);
3277 }
3278 catch (const std::bad_cast&) {
3279 color = fSceneHandler.GetColour();
3280 }
3281
3282 // Special case for marker
3283 try {
3284 const G4VMarker& g4Marker = dynamic_cast<const G4VMarker&>(visible);
3285 if (g4Marker.GetInfo() != "") {
3286 modelShortName = g4Marker.GetInfo();
3287 }
3288 }
3289 catch (const std::bad_cast&) {}
3290
3291 if (modelShortName == "") {
3292 return ;
3293 }
3294 // try to init it
3295 if (fSceneTreeComponentTreeWidget == NULL) {
3296 createSceneTreeComponent();
3297 }
3298
3299 // if no UI
3300 if (fSceneTreeComponentTreeWidget == NULL) {
3301 return;
3302 }
3303
3304 fSceneTreeComponentTreeWidget->blockSignals(true);
3305
3306 // Create the "Model" node if not
3307
3308 QList<QTreeWidgetItem *> resItem;
3309 resItem = fSceneTreeComponentTreeWidget->findItems (modelShortName, Qt::MatchExactly, 0 );
3310 QTreeWidgetItem * currentItem = NULL;
3311 const PVPath tmpFullPath;
3312
3313 if (resItem.empty()) {
3314 currentItem = createTreeWidgetItem(tmpFullPath,
3315 modelShortName,
3316 0, // currentPVCopyNb
3317 -1, // currentPVPOIndex
3318 "",
3319 Qt::Checked,
3320 NULL,
3321 color);
3322 } else {
3323 currentItem = resItem.first();
3324 }
3325
3326 // Is this volume already in the tree AND PO is not the same?
3327 const QList<QTreeWidgetItem *>&
3328 resItems = fSceneTreeComponentTreeWidget->findItems (QString(modelDescription.c_str()), Qt::MatchFixedString| Qt::MatchCaseSensitive|Qt::MatchRecursive, 0 );
3329
3330 bool alreadyPresent = false;
3331 for (int i = 0; i < resItems.size(); ++i) {
3332 if (currentPOIndex == resItems.at(i)->data(0,Qt::UserRole).toInt()) {
3333 alreadyPresent = true;
3334 }
3335 }
3336 if (!alreadyPresent) {
3337 createTreeWidgetItem(tmpFullPath,
3338 modelShortName,
3339 0, // currentPVCopyNb
3340 currentPOIndex,
3341 "",
3342 Qt::Checked,
3343 currentItem,
3344 color);
3345 }
3346 fSceneTreeComponentTreeWidget->blockSignals(false);
3347
3348}
const G4Colour & GetTextColour(const G4Text &)
const G4Colour & GetColour()
G4VSceneHandler & fSceneHandler
Definition G4VViewer.hh:253
virtual const G4String & GetInfo() const

Referenced by G4OpenGLStoredQtSceneHandler::ExtraPOProcessing().

◆ addPVSceneTreeElement()

void G4OpenGLQtViewer::addPVSceneTreeElement ( const G4String & model,
G4PhysicalVolumeModel * pPVModel,
int currentPVPOIndex )

Definition at line 2795 of file G4OpenGLQtViewer.cc.

2795 {
2796
2797 const QString& modelShortName = getModelShortName(model);
2798
2799 if (modelShortName == "") {
2800 return ;
2801 }
2802 // try to init it
2803 if (fSceneTreeComponentTreeWidget == NULL) {
2804 createSceneTreeComponent();
2805 }
2806
2807 // if no UI
2808 if (fSceneTreeComponentTreeWidget == NULL) {
2809 return;
2810 }
2811
2812 fSceneTreeComponentTreeWidget->blockSignals(true);
2813
2814 // Create the "volume" node if not
2815 // if (fSceneTreeComponentTreeWidget->topLevelItemCount () == 0) {
2816 if (!fPVRootNodeCreate) {
2817 const G4Colour& color = fSceneHandler.GetColour();
2818
2819 fModelShortNameItem = createTreeWidgetItem(pPVModel->GetFullPVPath(),
2820 modelShortName,
2821 0, // currentPVCopyNb
2822 -1, // currentPVPOIndex
2823 "",
2824 Qt::Checked,
2825 NULL,
2826 color);
2827 fPVRootNodeCreate = true;
2828 }
2829
2830 bool added = parseAndInsertInSceneTree(fModelShortNameItem,pPVModel,0,modelShortName,0,currentPOIndex);
2831 if (!added) {
2832 }
2833
2834 fSceneTreeComponentTreeWidget->blockSignals(false);
2835
2836}
const std::vector< G4PhysicalVolumeNodeID > & GetFullPVPath() const

Referenced by G4OpenGLStoredQtSceneHandler::ExtraPOProcessing().

◆ clearTreeWidget()

void G4OpenGLQtViewer::clearTreeWidget ( )

Definition at line 3769 of file G4OpenGLQtViewer.cc.

3769 {
3770 // be careful about calling this twice
3771
3772 if (fSceneTreeComponentTreeWidget) {
3773
3774 if (fSceneTreeComponentTreeWidget->topLevelItemCount () > 0) {
3775
3776 fPVRootNodeCreate = false;
3777
3778 // reset all old
3779 fOldPositivePoIndexSceneTreeWidgetQuickMap.clear();
3780 fOldNullPoIndexSceneTreeWidgetQuickVector.clear();
3781 fOldTreeItemModels.clear();
3782
3783 // Clone everything
3784 for (int b =0; b <fSceneTreeComponentTreeWidget->topLevelItemCount();b++) {
3785 // All tree widgets are in :
3786 // then we could get the old POindex and get
3787 // .visible/Hidden
3788 // .Check/Uncheck
3789 // .selected
3790 // .colour status from std::map
3791
3792 // clone top level items
3793 int poIndex = fSceneTreeComponentTreeWidget->topLevelItem(b)->data(0,Qt::UserRole).toInt();
3794 if (poIndex != -1) {
3795 fOldPositivePoIndexSceneTreeWidgetQuickMap.insert(std::pair <int, QTreeWidgetItem*> (poIndex,cloneWidgetItem(fSceneTreeComponentTreeWidget->topLevelItem(b))));
3796 } else {
3797 fOldNullPoIndexSceneTreeWidgetQuickVector.push_back(cloneWidgetItem(fSceneTreeComponentTreeWidget->topLevelItem(b)));
3798 }
3799
3800 // clone leaves
3801 cloneSceneTree(fSceneTreeComponentTreeWidget->topLevelItem(b));
3802 }
3803 // delete all elements
3804
3805 fOldTreeItemModels.insert(fTreeItemModels.begin(), fTreeItemModels.end());
3806
3807 // all is copy, then clear scene tree
3808 int tmp2 = fSceneTreeComponentTreeWidget->topLevelItemCount();
3809 while (tmp2 > 0) {
3810 delete fSceneTreeComponentTreeWidget->takeTopLevelItem (0);
3811 tmp2 = fSceneTreeComponentTreeWidget->topLevelItemCount();
3812 }
3813 fPositivePoIndexSceneTreeWidgetQuickMap.clear();
3814
3815 // put correct value in paramaters
3816 fOldLastSceneTreeWidgetAskForIterator = fOldPositivePoIndexSceneTreeWidgetQuickMap.begin();
3817 fOldLastSceneTreeWidgetAskForIteratorEnd = fOldPositivePoIndexSceneTreeWidgetQuickMap.end();
3818 fSceneTreeDepth = 1;
3819 fModelShortNameItem = NULL;
3820 fMaxPOindexInserted = -1;
3821
3822 }
3823 }
3824}

Referenced by G4OpenGLStoredQtSceneHandler::ClearStore(), and G4OpenGLStoredQtSceneHandler::SetScene().

◆ CreateGLQtContext()

void G4OpenGLQtViewer::CreateGLQtContext ( )
protected

◆ CreateMainWindow()

void G4OpenGLQtViewer::CreateMainWindow ( G4QGLWidgetType * glWidget,
const QString & name )
protectedvirtual

!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!//

Definition at line 115 of file G4OpenGLQtViewer.cc.

121{
122
123 if(fGLWidget) return; //Done.
124
125 fGLWidget = glWidget ;
126 // fGLWidget->makeCurrent();
127
128 G4Qt* interactorManager = G4Qt::getInstance ();
129
131
132 // FIXME L.Garnier 9/11/09 Has to be check !!!
133 // Qt UI with Qt Vis
134 // Qt UI with X Vis
135 // X UI with Qt Vis
136 // X UI with X Vis
137 // Ne marche pas avec un UIBatch !! (ecran blanc)
138
139 // return false if G4UIQt was not launch
140
142 if (UI == NULL) return;
143
144 if (! static_cast<G4UIQt*> (UI->GetG4UIWindow())) {
145 // NO UI, should be batch mode
146 fBatchMode = true;
147 return;
148 }
149 fUiQt = static_cast<G4UIQt*> (UI->GetG4UIWindow());
150
151 bool isTabbedView = false;
152 if ( fUiQt) {
153 if (!fBatchMode) {
154 if (!interactorManager->IsExternalApp()) {
155 // INIT size
158
159 isTabbedView = fUiQt->AddTabWidget((QWidget*)fGLWidget,name);
160 QObject::connect(fUiQt->GetViewerTabWidget(),
161 SIGNAL(currentChanged(int)),
162 this,
163 SLOT(currentTabActivated(int)));
164
165
166 }
167 createSceneTreeWidget();
168 // activate them
169 }
170 }
171
172 if (!isTabbedView) { // we have to do a dialog
173
174 QWidget *glDialogWidget = getParentWidget();
175 if (glDialogWidget == NULL) {
176 return;
177 }
178 glWidget->setParent(glDialogWidget);
179 QHBoxLayout *mainLayout = new QHBoxLayout();
180
181 mainLayout->setContentsMargins(0,0,0,0);
182 mainLayout->setSpacing(0);
183 mainLayout->addWidget(fGLWidget);
184 if (fGLWidget->inherits("QMainWindow")) {
185 fGLWidget->setWindowTitle( name);
186 }
187 glDialogWidget->setLayout(mainLayout);
188
189
190 //useful for MACOSX, we have to compt the menuBar height
191#if (QT_VERSION >= QT_VERSION_CHECK(5, 10, 0))
192 G4int offset = QGuiApplication::primaryScreen()->availableGeometry().height()
193 - QGuiApplication::screenAt(QPoint(20,20))->availableGeometry().height();
194#else
195 G4int offset = QApplication::desktop()->height()
196 - QApplication::desktop()->availableGeometry().height();
197#endif
198
199 G4int YPos= fVP.GetWindowAbsoluteLocationHintY(QGuiApplication::primaryScreen()->availableGeometry().height());
200 if (fVP.GetWindowAbsoluteLocationHintY(QGuiApplication::primaryScreen()->availableGeometry().height())< offset) {
201 YPos = offset;
202 }
203 glDialogWidget->resize(getWinWidth(), getWinHeight());
204 glDialogWidget->move(fVP.GetWindowAbsoluteLocationHintX(QGuiApplication::primaryScreen()->availableGeometry().width()),YPos);
205 glDialogWidget->show();
206 }
207
208 if(!fGLWidget) return;
209
210 if (!fContextMenu)
211 createPopupMenu();
212
213}
int G4int
Definition G4Types.hh:85
unsigned int fWinSize_y
unsigned int getWinHeight() const
void ResizeWindow(unsigned int, unsigned int)
unsigned int getWinWidth() const
unsigned int fWinSize_x
Definition G4Qt.hh:50
bool IsExternalApp()
Definition G4Qt.cc:183
G4bool AddTabWidget(QWidget *, QString)
Definition G4UIQt.cc:2283
QTabWidget * GetViewerTabWidget()
Definition G4UIQt.hh:171
G4UIsession * GetG4UIWindow() const
static G4UImanager * GetUIpointer()
G4ViewParameters fVP
Definition G4VViewer.hh:257
G4int GetWindowAbsoluteLocationHintY(G4int) const
unsigned int GetWindowSizeHintX() const
G4int GetWindowAbsoluteLocationHintX(G4int) const
unsigned int GetWindowSizeHintY() const

Referenced by G4OpenGLImmediateQtViewer::Initialise(), and G4OpenGLStoredQtViewer::Initialise().

◆ displayRecordingStatus()

void G4OpenGLQtViewer::displayRecordingStatus ( )

Definition at line 1782 of file G4OpenGLQtViewer.cc.

1782 {
1783
1784 QString txtStatus = "";
1785 if (fRecordingStep == WAIT) {
1786 txtStatus = "Waiting to start...";
1787 fRecordFrameNumber = 0; // reset the frame number
1788 } else if (fRecordingStep == START) {
1789 txtStatus = "Start Recording...";
1790 } else if (fRecordingStep == PAUSE) {
1791 txtStatus = "Pause Recording...";
1792 } else if (fRecordingStep == CONTINUE) {
1793 txtStatus = "Continue Recording...";
1794 } else if (fRecordingStep == STOP) {
1795 txtStatus = "Stop Recording...";
1796 } else if (fRecordingStep == READY_TO_ENCODE) {
1797 txtStatus = "Ready to Encode...";
1798 } else if (fRecordingStep == ENCODING) {
1799 txtStatus = "Encoding...";
1800 } else if (fRecordingStep == FAILED) {
1801 txtStatus = "Failed to encode...";
1802 } else if ((fRecordingStep == BAD_ENCODER)
1803 || (fRecordingStep == BAD_OUTPUT)
1804 || (fRecordingStep == BAD_TMP)) {
1805 txtStatus = "Correct above errors first";
1806 } else if (fRecordingStep == SUCCESS) {
1807 txtStatus = "File encoded successfully";
1808 } else {
1809 }
1810
1811 if (fMovieParametersDialog) {
1812 fMovieParametersDialog->setRecordingStatus(txtStatus);
1813 } else {
1814 G4cout << txtStatus.toStdString().c_str() << G4endl;
1815 }
1816 setRecordingInfos("");
1817}

Referenced by setBadEncoder(), setBadOutput(), setBadTmp(), and setWaiting().

◆ displaySceneTreeComponent()

void G4OpenGLQtViewer::displaySceneTreeComponent ( )
protected

Should replace actual tree by the one in this class and update tree

Definition at line 3999 of file G4OpenGLQtViewer.cc.

3999 {
4000 // no UI
4001 if (fUISceneTreeWidget == NULL) {
4002 return;
4003 }
4004 if (fSceneTreeComponentTreeWidget == NULL) {
4005 return;
4006 }
4007
4008 // sort tree items
4009 fSceneTreeComponentTreeWidget->sortItems (0, Qt::AscendingOrder );
4010
4011 return;
4012}

◆ DrawText()

void G4OpenGLQtViewer::DrawText ( const G4Text & g4text)
virtual

Reimplemented from G4OpenGLViewer.

Definition at line 2711 of file G4OpenGLQtViewer.cc.

2712{
2713 auto* qGLW = dynamic_cast<G4QGLWidgetType*> (fGLWidget) ;
2714 if (! qGLW) {
2715 return;
2716 }
2717 if (isGl2psWriting()) {
2718
2720
2721 } else {
2722
2723 if (!fGLWidget) return;
2724
2725#ifdef G4MULTITHREADED
2727#endif
2728
2730 G4double size = fSceneHandler.GetMarkerSize(g4text,sizeType);
2731
2732 QFont font = QFont();
2733 font.setPointSizeF(size);
2734
2735 const G4Colour& c = fSceneHandler.GetTextColour(g4text);
2736 glColor4d(c.GetRed(),c.GetGreen(),c.GetBlue(),c.GetAlpha());
2737
2738 G4Point3D position = g4text.GetPosition();
2739
2740 const G4String& textString = g4text.GetText();
2741 const char* textCString = textString.c_str();
2742
2743 glRasterPos3d(position.x(),position.y(),position.z());
2744
2745 // Calculate move for centre and right adjustment
2746 QFontMetrics* f = new QFontMetrics (font);
2747 G4double span = f->boundingRect(textCString).width();
2748 // Marked as such due to current un-use when building with Qt6
2749 // See use of renderText at end of function.
2750 [[maybe_unused]] G4double xmove = 0.;
2751 [[maybe_unused]] G4double ymove = 0.;
2752
2753 switch (g4text.GetLayout()) {
2754 case G4Text::left: break;
2755 case G4Text::centre: xmove -= span / 2.; break;
2756 case G4Text::right: xmove -= span;
2757 }
2758
2759 //Add offsets
2760 xmove += g4text.GetXOffset();
2761 ymove += g4text.GetYOffset();
2762
2763 // xmove, ymove in pixels - or are they?
2764#ifdef __APPLE__
2765 const G4double fudgeFactor = 2.;
2766#else
2767 const G4double fudgeFactor = 1.;
2768#endif
2769 xmove *= fudgeFactor;
2770 ymove *= fudgeFactor;
2771
2772#if (QT_VERSION < QT_VERSION_CHECK(6, 0, 0))
2773 qGLW->renderText
2774 ((position.x()+(2*xmove)/getWinWidth()),
2775 (position.y()+(2*ymove)/getWinHeight()),
2776 position.z(),
2777 textCString,
2778 font);
2779#else
2780 // Not yet obvious how to do this in Qt6....
2781#endif
2782 }
2783}
QOpenGLWidget G4QGLWidgetType
double G4double
Definition G4Types.hh:83
G4double GetBlue() const
Definition G4Colour.hh:154
G4double GetAlpha() const
Definition G4Colour.hh:155
G4double GetRed() const
Definition G4Colour.hh:152
G4double GetGreen() const
Definition G4Colour.hh:153
virtual void DrawText(const G4Text &)
G4bool isGl2psWriting()
Layout GetLayout() const
G4double GetYOffset() const
G4double GetXOffset() const
G4String GetText() const
@ centre
Definition G4Text.hh:76
@ right
Definition G4Text.hh:76
@ left
Definition G4Text.hh:76
G4Point3D GetPosition() const
G4double GetMarkerSize(const G4VMarker &, MarkerSizeType &)
G4int G4GetThreadId()

◆ encodeVideo()

void G4OpenGLQtViewer::encodeVideo ( )

Definition at line 2311 of file G4OpenGLQtViewer.cc.

2312{
2313 if ((getEncoderPath() != "") && (getSaveFileName() != "")) {
2314 setRecordingStatus(ENCODING);
2315
2316 fProcess = new QProcess();
2317 QObject ::connect(fProcess,SIGNAL(finished ( int,QProcess::ExitStatus)),
2318 this,SLOT(processEncodeFinished()));
2319 QObject ::connect(fProcess,SIGNAL(readyReadStandardOutput ()),
2320 this,SLOT(processEncodeStdout()));
2321#if (QT_VERSION < QT_VERSION_CHECK(5, 10, 0))
2322 fProcess->setReadChannelMode(QProcess::MergedChannels);
2323#else
2324 fProcess->setProcessChannelMode(QProcess::MergedChannels);
2325#endif
2326 fProcess->start (fEncoderPath, QStringList(fMovieTempFolderPath+fParameterFileName));
2327 }
2328}

Referenced by saveVideo().

◆ exportImage()

bool G4OpenGLQtViewer::exportImage ( std::string name = "",
int width = -1,
int height = -1 )
virtual

Export image. Try to get the format according to the file extention. If not present, the last one choosen by /vis/ogl/set/exportFormat If not, will take the default format : eps Best format actually available is pdf (vectored and allow transparency) If name is not set, it will take the default name value given by /vis/ogl/set/printFilename

Reimplemented from G4OpenGLViewer.

Definition at line 2117 of file G4OpenGLQtViewer.cc.

2117 {
2118
2119 auto* qGLW = dynamic_cast<G4QGLWidgetType*> (fGLWidget) ;
2120 if (! qGLW) {
2121 return false;
2122 }
2123 // If there is already an extention
2124 bool increaseFileNumber = true;
2125 // if
2126 if (name.size() != name.substr(name.find_last_of(".") + 1).size()) {
2127 increaseFileNumber = false;
2128 }
2129 if (! setExportFilename(name,increaseFileNumber)) {
2130 return false;
2131 }
2132 if ((width !=-1) && (height != -1)) {
2133 setExportSize(width, height);
2134 }
2135 // first, try to do it with generic function
2136 if (G4OpenGLViewer::exportImage(name, width, height)) {
2137 return true;
2138
2139 // Then try Qt saving functions
2140 } else {
2141 QImage image;
2142#if (QT_VERSION < QT_VERSION_CHECK(6, 0, 0))
2143 image = qGLW->grabFrameBuffer();
2144#else
2145 image = qGLW->grabFramebuffer();
2146#endif
2147
2148 bool res = image.save(QString(getRealPrintFilename().c_str()),0,fLastExportSliderValue);
2149
2150 if (!res) {
2151 G4cerr << "Error saving file... " << getRealPrintFilename().c_str() << G4endl;
2152 return false;
2153 } else {
2154 G4cout << "File " << getRealPrintFilename().c_str() << " size: " << fGLWidget->width() << "x" << fGLWidget->height() << " has been saved " << G4endl;
2156 }
2157 }
2158 return true;
2159}
G4GLOB_DLL std::ostream G4cerr
bool setExportFilename(G4String name, G4bool inc=true)
void setExportSize(G4int, G4int)
virtual bool exportImage(std::string name="", int width=-1, int height=-1)
std::string getRealPrintFilename()
const char * name(G4int ptype)

◆ FinishView()

void G4OpenGLQtViewer::FinishView ( void )
protectedvirtual

Reimplemented from G4VViewer.

Definition at line 1195 of file G4OpenGLQtViewer.cc.

1196{
1197 /* From Apple doc:
1198 CGLFlushDrawable : Copies the back buffer of a double-buffered context to the front buffer.
1199 If the backing store attribute is set to false, the buffers can be exchanged rather than copied
1200 */
1201 glFlush ();
1202
1203 // L. Garnier 10/2009 : Not necessary and cause problems on mac OS X 10.6
1204 // fGLWidget->swapBuffers ();
1205}

◆ G4keyPressEvent()

void G4OpenGLQtViewer::G4keyPressEvent ( QKeyEvent * event)

Definition at line 1545 of file G4OpenGLQtViewer.cc.

1546{
1547 if (fHoldKeyEvent)
1548 return;
1549
1550 fHoldKeyEvent = true;
1551
1552
1553 // with no modifiers
1554 updateKeyModifierState(evnt->modifiers());
1555 if ((fNoKeyPress) || (evnt->modifiers() == Qt::KeypadModifier )) {
1556 if (evnt->key() == Qt::Key_Down) { // go down
1557 moveScene(0,1,0,false);
1558 }
1559 else if (evnt->key() == Qt::Key_Up) { // go up
1560 moveScene(0,-1,0,false);
1561 }
1562 if (evnt->key() == Qt::Key_Left) { // go left
1563 moveScene(-1,0,0,false);
1564 }
1565 else if (evnt->key() == Qt::Key_Right) { // go right
1566 moveScene(1,0,0,false);
1567 }
1568 if (evnt->key() == Qt::Key_Minus) { // go backward
1569 moveScene(0,0,1,false);
1570 }
1571 else if (evnt->key() == Qt::Key_Plus) { // go forward
1572 moveScene(0,0,-1,false);
1573 }
1574 // escaped from full screen
1575 if (evnt->key() == Qt::Key_Escape) {
1576 toggleFullScreen(false);
1577 }
1578 }
1579 // several case here : If return is pressed, in every case -> display the movie parameters dialog
1580 // If one parameter is wrong -> put it in red (only save filenam could be wrong..)
1581 // If encoder not found-> does nothing.Only display a message in status box
1582 // If all ok-> generate parameter file
1583 // If ok -> put encoder button enabled
1584
1585 if ((evnt->key() == Qt::Key_Return) || (evnt->key() == Qt::Key_Enter)){ // end of video
1586 stopVideo();
1587 }
1588 if (evnt->key() == Qt::Key_Space){ // start/pause of video
1590 }
1591
1592 // H : Return Home view
1593 if (evnt->key() == Qt::Key_H){ // go Home
1594 ResetView();
1595
1596 updateQWidget();
1597 }
1598
1599 // Shift Modifier
1600 if (fShiftKeyPress) {
1601 fGLWidget->setCursor(QCursor(Qt::SizeAllCursor));
1602
1603 if (evnt->key() == Qt::Key_Down) { // rotate phi
1605 }
1606 else if (evnt->key() == Qt::Key_Up) { // rotate phi
1608 }
1609 if (evnt->key() == Qt::Key_Left) { // rotate theta
1611 }
1612 else if (evnt->key() == Qt::Key_Right) { // rotate theta
1614 }
1615 if (evnt->key() == Qt::Key_Plus) { // go forward ("Plus" imply
1616 // "Shift" on Mac French keyboard
1617 moveScene(0,0,-1,false);
1618 }
1619
1620 // Alt Modifier
1621 }
1622 if ((fAltKeyPress)) {
1623 fGLWidget->setCursor(QCursor(Qt::ClosedHandCursor));
1624
1625 if (evnt->key() == Qt::Key_Down) { // rotate phi
1627 }
1628 else if (evnt->key() == Qt::Key_Up) { // rotate phi
1630 }
1631 if (evnt->key() == Qt::Key_Left) { // rotate theta
1633 }
1634 else if (evnt->key() == Qt::Key_Right) { // rotate theta
1636 }
1637
1638 // Rotatio +/-
1639 if (evnt->key() == Qt::Key_Plus) {
1640 fRot_sens = fRot_sens/0.7;
1641 G4cout << "Auto-rotation set to : " << fRot_sens << G4endl;
1642 }
1643 else if (evnt->key() == Qt::Key_Minus) {
1644 fRot_sens = fRot_sens*0.7;
1645 G4cout << "Auto-rotation set to : " << fRot_sens << G4endl;
1646 }
1647
1648 // Control Modifier OR Command on MAC
1649 }
1650 if ((fControlKeyPress)) {
1651 if (evnt->key() == Qt::Key_Plus) {
1652 fVP.SetZoomFactor(fVP.GetZoomFactor()*(1+fDeltaZoom));
1653 updateQWidget();
1654 }
1655 else if (evnt->key() == Qt::Key_Minus) {
1656 fVP.SetZoomFactor(fVP.GetZoomFactor()*(1-fDeltaZoom));
1657 updateQWidget();
1658 }
1659 }
1660
1661 fHoldKeyEvent = false;
1662}
void rotateQtSceneToggle(float, float)
void moveScene(float, float, float, bool)
void rotateQtScene(float, float)
void updateKeyModifierState(const Qt::KeyboardModifiers &)
virtual void updateQWidget()=0
G4double GetZoomFactor() const
void SetZoomFactor(G4double zoomFactor)

Referenced by G4OpenGLImmediateQtViewer::keyPressEvent(), and G4OpenGLStoredQtViewer::keyPressEvent().

◆ G4keyReleaseEvent()

void G4OpenGLQtViewer::G4keyReleaseEvent ( QKeyEvent * event)

Definition at line 1665 of file G4OpenGLQtViewer.cc.

1666{
1667 fGLWidget->setCursor(QCursor(Qt::ArrowCursor));
1668}

Referenced by G4OpenGLImmediateQtViewer::keyReleaseEvent(), and G4OpenGLStoredQtViewer::keyReleaseEvent().

◆ G4manageContextMenuEvent()

void G4OpenGLQtViewer::G4manageContextMenuEvent ( QContextMenuEvent * e)
protected

Definition at line 697 of file G4OpenGLQtViewer.cc.

698{
699 if (!fGLWidget) {
700 G4cerr << "Visualization window not defined, please choose one before" << G4endl;
701 } else {
702
703 if (!fContextMenu)
704 createPopupMenu();
705
706 // launch menu
707 if ( fContextMenu ) {
708 fContextMenu->exec( e->globalPos() );
709 // delete fContextMenu;
710 }
711 }
712 e->accept();
713}

Referenced by G4OpenGLImmediateQtViewer::contextMenuEvent(), and G4OpenGLStoredQtViewer::contextMenuEvent().

◆ G4MouseDoubleClickEvent()

void G4OpenGLQtViewer::G4MouseDoubleClickEvent ( )

Definition at line 1364 of file G4OpenGLQtViewer.cc.

1365{
1366 fGLWidget->setMouseTracking(true);
1367}

Referenced by G4OpenGLImmediateQtViewer::mouseDoubleClickEvent(), and G4OpenGLStoredQtViewer::mouseDoubleClickEvent().

◆ G4MouseMoveEvent()

void G4OpenGLQtViewer::G4MouseMoveEvent ( QMouseEvent * evnt)
Parameters
pos_xmouse x position
pos_ymouse y position
mButtonsmouse button active
mAutoMovetrue: apply this move till another evnt came, false :one time move

Definition at line 1377 of file G4OpenGLQtViewer.cc.

1378{
1379
1380 Qt::MouseButtons mButtons = evnt->buttons();
1381
1382 updateKeyModifierState(evnt->modifiers());
1383
1384 if (fAutoMove) {
1385 return;
1386 }
1387
1388 fLastPos3 = fLastPos2;
1389 fLastPos2 = fLastPos1;
1390
1391#if (QT_VERSION < QT_VERSION_CHECK(6, 0, 0))
1392 fLastPos1 = QPoint(evnt->x(), evnt->y());
1393#else
1394 fLastPos1 = QPoint(evnt->position().x(), evnt->position().y());
1395#endif
1396
1397 int deltaX = fLastPos2.x()-fLastPos1.x();
1398 int deltaY = fLastPos2.y()-fLastPos1.y();
1399
1400 bool move = false;
1401 if (fUiQt != NULL) {
1402 if (fUiQt->IsIconMoveSelected()) { // move
1403 move = true;
1404 }
1405 }
1406 if (!move) { // rotate, pick, zoom...
1407 if (mButtons & Qt::LeftButton) {
1408 if (fNoKeyPress) {
1409 rotateQtScene(((float)deltaX),((float)deltaY));
1410 } else if (fAltKeyPress) {
1411 rotateQtSceneToggle(((float)deltaX),((float)deltaY));
1412 } else if (fShiftKeyPress) {
1413 unsigned int sizeWin;
1414 sizeWin = getWinWidth();
1415 if (getWinHeight() < getWinWidth()) {
1416 sizeWin = getWinHeight();
1417 }
1418
1419 // L.Garnier : 08/2010 100 is the good value, but don't ask me why !
1420 float factor = ((float)100/(float)sizeWin) ;
1421 moveScene(-(float)deltaX*factor,-(float)deltaY*factor,0,false);
1422 } else if (fControlKeyPress) {
1423 fVP.SetZoomFactor(fVP.GetZoomFactor()*(1+((float)deltaY)));
1424 }
1425 }
1426 } else if (move) { // move
1427 if (mButtons & Qt::LeftButton) {
1428 moveScene(-(float)deltaX,-(float)deltaY,0,true);
1429 }
1430 }
1431
1432 fLastEventTime->start();
1433}
G4bool IsIconMoveSelected()
Definition G4UIQt.hh:184

Referenced by G4OpenGLImmediateQtViewer::mouseMoveEvent(), and G4OpenGLStoredQtViewer::mouseMoveEvent().

◆ G4MousePressEvent()

void G4OpenGLQtViewer::G4MousePressEvent ( QMouseEvent * evnt)

Save the current mouse press point

Parameters
pmouse click point

Definition at line 1211 of file G4OpenGLQtViewer.cc.

1212{
1213 if (evnt->button() == Qt::RightButton) {
1214 return;
1215 }
1216 if ((evnt->button() & Qt::LeftButton) && (! (evnt->modifiers() & Qt::ControlModifier ))){
1217 fGLWidget->setMouseTracking(true);
1218 fAutoMove = false; // stop automove
1219 fLastPos1 = evnt->pos();
1220 fLastPos2 = fLastPos1;
1221 fLastPos3 = fLastPos2;
1222 fLastEventTime->start();
1223 if (fUiQt != NULL) {
1224
1225 if (fUiQt->IsIconZoomInSelected()) { // zoomIn
1226 // Move click point to center of OGL
1227
1228 float deltaX = ((float)getWinWidth()/2-evnt->pos().x());
1229 float deltaY = ((float)getWinHeight()/2-evnt->pos().y());
1230
1231 G4double coefTrans = 0;
1232 coefTrans = ((G4double)getSceneNearWidth())/((G4double)getWinWidth());
1233 if (getWinHeight() <getWinWidth()) {
1234 coefTrans = ((G4double)getSceneNearWidth())/((G4double)getWinHeight());
1235 }
1236 fVP.IncrementPan(-deltaX*coefTrans,deltaY*coefTrans,0);
1238
1239 updateQWidget();
1240
1241 } else if (fUiQt->IsIconZoomOutSelected()) { // zoomOut
1242 // Move click point to center of OGL
1243 moveScene(((float)getWinWidth()/2-evnt->pos().x()),((float)getWinHeight()/2-evnt->pos().y()),0,true);
1244
1246 updateQWidget();
1247
1248 } else if (fUiQt->IsIconRotateSelected() ) {
1249
1250 if (fShiftKeyPress) { // move
1251 fGLWidget->setCursor(QCursor(Qt::SizeAllCursor));
1252
1253 } else { // rotate
1254 fGLWidget->setCursor(QCursor(Qt::ClosedHandCursor));
1255 }
1256 } else if (fUiQt->IsIconMoveSelected()) {
1257 fGLWidget->setCursor(QCursor(Qt::SizeAllCursor));
1258 } else if (fUiQt->IsIconPickSelected()) {
1259 fGLWidget->setCursor(QCursor(Qt::PointingHandCursor));
1260 }
1261 }
1262 }
1263}
GLdouble getSceneNearWidth()
G4bool IsIconRotateSelected()
Definition G4UIQt.hh:185
G4bool IsIconZoomInSelected()
Definition G4UIQt.hh:187
G4bool IsIconZoomOutSelected()
Definition G4UIQt.hh:188
G4bool IsIconPickSelected()
Definition G4UIQt.hh:186
void IncrementPan(G4double right, G4double up)

Referenced by G4OpenGLImmediateQtViewer::mousePressEvent(), and G4OpenGLStoredQtViewer::mousePressEvent().

◆ G4MouseReleaseEvent()

void G4OpenGLQtViewer::G4MouseReleaseEvent ( QMouseEvent * evnt)

Definition at line 1267 of file G4OpenGLQtViewer.cc.

1268{
1269 GLint viewport[4];
1270 glGetIntegerv(GL_VIEWPORT, viewport);
1271
1272 // factorX == factorY
1273 double factorX = ((double)viewport[2]/fGLWidget->width());
1274 double factorY = ((double)viewport[3]/fGLWidget->height());
1275 fSpinningDelay = (int)fLastEventTime->elapsed();
1276 QPoint delta = (fLastPos3-fLastPos1)*factorX;
1277
1278 // reset cursor state
1279 fGLWidget->setCursor(QCursor(Qt::ArrowCursor));
1280
1281 if (fVP.IsPicking()){ // pick
1282 if ((delta.x() != 0) || (delta.y() != 0)) {
1283 return;
1284 }
1285 updatePickInfosWidget(evnt->pos().x()*factorX,evnt->pos().y()*factorY);
1286
1287 } else if (fSpinningDelay < fLaunchSpinDelay ) {
1288 if ((delta.x() == 0) && (delta.y() == 0)) {
1289 return;
1290 }
1291
1292 fAutoMove = true;
1293#if (QT_VERSION < QT_VERSION_CHECK(5, 14, 0))
1294 QTime lastMoveTime;
1295#else
1296 QElapsedTimer lastMoveTime;
1297#endif
1298 lastMoveTime.start();
1299 // try to addapt speed move/rotate looking to drawing speed
1300 float correctionFactor = 5;
1301 while (fAutoMove) {
1302 if ( lastMoveTime.elapsed() >= (int)(1000/fNbMaxFramesPerSec)) {
1303 float lTime = 1000.0f/lastMoveTime.elapsed();
1304 if (((((float)delta.x())/correctionFactor)*lTime > fNbMaxAnglePerSec) ||
1305 ((((float)delta.x())/correctionFactor)*lTime < -fNbMaxAnglePerSec) ) {
1306 correctionFactor = (float)delta.x()*(lTime/fNbMaxAnglePerSec);
1307 if (delta.x() <0 ) {
1308 correctionFactor = -correctionFactor;
1309 }
1310 }
1311 if (((((float)delta.y())/correctionFactor)*lTime > fNbMaxAnglePerSec) ||
1312 ((((float)delta.y())/correctionFactor)*lTime < -fNbMaxAnglePerSec) ) {
1313 correctionFactor = (float)delta.y()*(lTime/fNbMaxAnglePerSec);
1314 if (delta.y() <0 ) {
1315 correctionFactor = -correctionFactor;
1316 }
1317 }
1318
1319 // Check Qt Versions for META Keys
1320
1321 // Click and move mouse to rotate volume
1322 // ALT + Click and move mouse to rotate volume (View Direction)
1323 // SHIFT + Click and move camera point of view
1324 // CTRL + Click and zoom mouse to zoom in/out
1325
1326 lastMoveTime.start();
1327
1328 bool rotate = false;
1329 bool move = false;
1330
1331 if (fUiQt != NULL) {
1332 if (fUiQt->IsIconRotateSelected()) { // rotate
1333 rotate = true;
1334 } else if (fUiQt->IsIconMoveSelected()) { // move
1335 move = true;
1336 }
1337 } else {
1338 rotate = true;
1339 }
1340 // prevent from closing widget when rotating (cause a crash)
1341 if (fIsDeleting) {
1342 return;
1343 }
1344
1345 if (rotate) { // rotate
1346 if (fNoKeyPress) {
1347 rotateQtScene(((float)delta.x())/correctionFactor,((float)delta.y())/correctionFactor);
1348 } else if (fAltKeyPress) {
1349 rotateQtSceneToggle(((float)delta.x())/correctionFactor,((float)delta.y())/correctionFactor);
1350 }
1351
1352 } else if (move) { // move
1353 moveScene(-((float)delta.x())/correctionFactor,-((float)delta.y())/correctionFactor,0,true);
1354 }
1355 }
1356 ((QApplication*)G4Qt::getInstance ())->processEvents();
1357 }
1358 }
1359 fGLWidget->setMouseTracking(false);
1360
1361}
void updatePickInfosWidget(int, int)
G4bool IsPicking() const

Referenced by G4OpenGLImmediateQtViewer::mouseReleaseEvent(), and G4OpenGLStoredQtViewer::mouseReleaseEvent().

◆ G4wheelEvent()

void G4OpenGLQtViewer::G4wheelEvent ( QWheelEvent * event)

Definition at line 1534 of file G4OpenGLQtViewer.cc.

1535{
1536#if (QT_VERSION < QT_VERSION_CHECK(5, 15, 0))
1537 fVP.SetZoomFactor(fVP.GetZoomFactor()+(fVP.GetZoomFactor()*(evnt->delta())/1200));
1538#else
1539 fVP.SetZoomFactor(fVP.GetZoomFactor()+(fVP.GetZoomFactor()*(evnt->angleDelta().y())/1200));
1540#endif
1541 updateQWidget();
1542}

Referenced by G4OpenGLImmediateQtViewer::wheelEvent(), and G4OpenGLStoredQtViewer::wheelEvent().

◆ generateMpegEncoderParameters()

bool G4OpenGLQtViewer::generateMpegEncoderParameters ( )

Definition at line 2161 of file G4OpenGLQtViewer.cc.

2161 {
2162
2163 // save the parameter file
2164 FILE* fp;
2165 fp = fopen (QString(fMovieTempFolderPath+fParameterFileName).toStdString().c_str(), "w");
2166
2167 if (fp == NULL) {
2168 setRecordingInfos("Generation of parameter file failed");
2169 return false;
2170 }
2171
2172 fprintf (fp,"# Pattern affects speed, quality and compression. See the User's Guide\n");
2173 fprintf (fp,"# for more info.\n");
2174 fprintf (fp,"\n");
2175 fprintf (fp,"PATTERN I\n");
2176 fprintf (fp,"OUTPUT %s\n",getSaveFileName().toStdString().c_str());
2177 fprintf (fp,"\n");
2178 fprintf (fp,"# You must specify the type of the input files. The choices are:\n");
2179 fprintf (fp,"# YUV, PPM, JMOVIE, Y, JPEG, PNM\n");
2180 fprintf (fp,"# (must be upper case)\n");
2181 fprintf (fp,"#\n");
2182 fprintf (fp,"BASE_FILE_FORMAT PPM\n");
2183 fprintf (fp,"\n");
2184 fprintf (fp,"\n");
2185 fprintf (fp,"# If you are using YUV, there are different supported file formats.\n");
2186 fprintf (fp,"# EYUV or UCB are the same as previous versions of this encoder.\n");
2187 fprintf (fp,"# (All the Y's, then U's then V's, in 4:2:0 subsampling.)\n");
2188 fprintf (fp,"# Other formats, such as Abekas, Phillips, or a general format are\n");
2189 fprintf (fp,"# permissible, the general format is a string of Y's, U's, and V's\n");
2190 fprintf (fp,"# to specify the file order.\n");
2191 fprintf (fp,"\n");
2192 fprintf (fp,"INPUT_FORMAT UCB\n");
2193 fprintf (fp,"\n");
2194 fprintf (fp,"# the conversion statement\n");
2195 fprintf (fp,"#\n");
2196 fprintf (fp,"# Each occurrence of '*' will be replaced by the input file\n");
2197 fprintf (fp,"#\n");
2198 fprintf (fp,"# e.g., if you have a bunch of GIF files, then this might be:\n");
2199 fprintf (fp,"# INPUT_CONVERT giftoppm *\n");
2200 fprintf (fp,"#\n");
2201 fprintf (fp,"# e.g., if you have a bunch of files like a.Y a.U a.V, etc., then:\n");
2202 fprintf (fp,"# INPUT_CONVERT cat *.Y *.U *.V\n");
2203 fprintf (fp,"#\n");
2204 fprintf (fp,"# e.g., if you are grabbing from laser disc you might have something like\n");
2205 fprintf (fp,"# INPUT_CONVERT goto frame *; grabppm\n");
2206 fprintf (fp,"# 'INPUT_CONVERT *' means the files are already in the base file format\n");
2207 fprintf (fp,"#\n");
2208 fprintf (fp,"INPUT_CONVERT * \n");
2209 fprintf (fp,"\n");
2210 fprintf (fp,"# number of frames in a GOP.\n");
2211 fprintf (fp,"#\n");
2212 fprintf (fp,"# since each GOP must have at least one I-frame, the encoder will find the\n");
2213 fprintf (fp,"# the first I-frame after GOP_SIZE frames to start the next GOP\n");
2214 fprintf (fp,"#\n");
2215 fprintf (fp,"# later, will add more flexible GOP signalling\n");
2216 fprintf (fp,"#\n");
2217 fprintf (fp,"GOP_SIZE 1\n");
2218 fprintf (fp,"\n");
2219 fprintf (fp,"# number of slices in a frame\n");
2220 fprintf (fp,"#\n");
2221 fprintf (fp,"# 1 is a good number. another possibility is the number of macroblock rows\n");
2222 fprintf (fp,"# (which is the height divided by 16)\n");
2223 fprintf (fp,"#\n");
2224 fprintf (fp,"SLICES_PER_FRAME 1\n");
2225 fprintf (fp,"PIXEL HALF");
2226 fprintf (fp,"\n");
2227 fprintf (fp,"# directory to get all input files from (makes this file easier to read)\n");
2228 fprintf (fp,"INPUT_DIR %s\n",fMovieTempFolderPath.toStdString().c_str());
2229 fprintf (fp,"\n");
2230 fprintf (fp,"# There are a bunch of ways to specify the input files.\n");
2231 fprintf (fp,"# from a simple one-per-line listing, to the following \n");
2232 fprintf (fp,"# way of numbering them. See the manual for more information.\n");
2233 fprintf (fp,"INPUT\n");
2234 fprintf (fp,"# '*' is replaced by the numbers 01, 02, 03, 04\n");
2235 fprintf (fp,"# if I instead do [01-11], it would be 01, 02, ..., 09, 10, 11\n");
2236 fprintf (fp,"# if I instead do [1-11], it would be 1, 2, 3, ..., 9, 10, 11\n");
2237 fprintf (fp,"# if I instead do [1-11+3], it would be 1, 4, 7, 10\n");
2238 fprintf (fp,"# the program assumes none of your input files has a name ending in ']'\n");
2239 fprintf (fp,"# if you do, too bad!!!\n");
2240 fprintf (fp,"#\n");
2241 fprintf (fp,"#\n");
2242 fprintf (fp,"Test*.ppm [0-%d]\n",fRecordFrameNumber-1);
2243 fprintf (fp,"# can have more files here if you want...there is no limit on the number\n");
2244 fprintf (fp,"# of files\n");
2245 fprintf (fp,"END_INPUT\n");
2246 fprintf (fp,"\n");
2247 fprintf (fp,"\n");
2248 fprintf (fp,"\n");
2249 fprintf (fp,"# Many of the remaining options have to do with the motion search and qscale\n");
2250 fprintf (fp,"\n");
2251 fprintf (fp,"# FULL or HALF -- must be upper case\n");
2252 fprintf (fp,"# Should be FULL for computer generated images\n");
2253 fprintf (fp,"PIXEL FULL\n");
2254 fprintf (fp,"\n");
2255 fprintf (fp,"# means +/- this many pixels for both P and B frame searches\n");
2256 fprintf (fp,"# specify two numbers if you wish to serc different ranges in the two.\n");
2257 fprintf (fp,"RANGE 10\n");
2258 fprintf (fp,"\n");
2259 fprintf (fp,"# The two search algorithm parameters below mostly affect speed,\n");
2260 fprintf (fp,"# with some affect on compression and almost none on quality.\n");
2261 fprintf (fp,"\n");
2262 fprintf (fp,"# this must be one of {EXHAUSTIVE, SUBSAMPLE, LOGARITHMIC}\n");
2263 fprintf (fp,"PSEARCH_ALG LOGARITHMIC\n");
2264 fprintf (fp,"\n");
2265 fprintf (fp,"# this must be one of {SIMPLE, CROSS2, EXHAUSTIVE}\n");
2266 fprintf (fp,"#\n");
2267 fprintf (fp,"# note that EXHAUSTIVE is really, really, really slow\n");
2268 fprintf (fp,"#\n");
2269 fprintf (fp,"BSEARCH_ALG SIMPLE\n");
2270 fprintf (fp,"\n");
2271 fprintf (fp,"#\n");
2272 fprintf (fp,"# these specify the q-scale for I, P, and B frames\n");
2273 fprintf (fp,"# (values must be between 1 and 31)\n");
2274 fprintf (fp,"# These are the Qscale values for the entire frame in variable bit-rate\n");
2275 fprintf (fp,"# mode, and starting points (but not important) for constant bit rate\n");
2276 fprintf (fp,"#\n");
2277 fprintf (fp,"\n");
2278 fprintf (fp,"# Qscale (Quantization scale) affects quality and compression,\n");
2279 fprintf (fp,"# but has very little effect on speed.\n");
2280 fprintf (fp,"\n");
2281 fprintf (fp,"IQSCALE 4\n");
2282 fprintf (fp,"PQSCALE 5\n");
2283 fprintf (fp,"BQSCALE 12\n");
2284 fprintf (fp,"\n");
2285 fprintf (fp,"# this must be ORIGINAL or DECODED\n");
2286 fprintf (fp,"REFERENCE_FRAME ORIGINAL\n");
2287 fprintf (fp,"\n");
2288 fprintf (fp,"# for parallel parameters see parallel.param in the examples subdirectory\n");
2289 fprintf (fp,"\n");
2290 fprintf (fp,"# if you want constant bit-rate mode, specify it as follows (number is bits/sec):\n");
2291 fprintf (fp,"#BIT_RATE 1000000\n");
2292 fprintf (fp,"\n");
2293 fprintf (fp,"# To specify the buffer size (327680 is default, measused in bits, for 16bit words)\n");
2294 fprintf (fp,"BUFFER_SIZE 327680\n");
2295 fprintf (fp,"\n");
2296 fprintf (fp,"# The frame rate is the number of frames/second (legal values:\n");
2297 fprintf (fp,"# 23.976, 24, 25, 29.97, 30, 50 ,59.94, 60\n");
2298 fprintf (fp,"FRAME_RATE 30\n");
2299 fprintf (fp,"\n");
2300 fprintf (fp,"# There are many more options, see the users manual for examples....\n");
2301 fprintf (fp,"# ASPECT_RATIO, USER_DATA, GAMMA, IQTABLE, etc.\n");
2302 fprintf (fp,"\n");
2303 fprintf (fp,"\n");
2304 fclose (fp);
2305
2306 setRecordingInfos("Parameter file "+fParameterFileName+" generated in "+fMovieTempFolderPath);
2307 setRecordingStatus(READY_TO_ENCODE);
2308 return true;
2309}

Referenced by saveVideo().

◆ getColorForPoIndex()

G4Colour G4OpenGLQtViewer::getColorForPoIndex ( int poIndex)
protected

Definition at line 3573 of file G4OpenGLQtViewer.cc.

3573 {
3574 // FIXME 09/2014 : Could be optimize by searching in a tab instead of item->data
3575 QTreeWidgetItem* item = getTreeWidgetItem(poIndex);
3576
3577 if (item != NULL) {
3578
3579 const QColor& color = item->data(2,Qt::UserRole).value<QColor>();
3580 G4Colour g4c(((G4double)color.red())/255,
3581 ((G4double)color.green())/255,
3582 ((G4double)color.blue())/255,
3583 ((G4double)color.alpha())/255);
3584
3585 return g4c;
3586 }
3587 return G4Colour();
3588}

Referenced by G4OpenGLStoredQtViewer::DisplayTimePOColourModification(), and updatePickInfosWidget().

◆ getEncoderPath()

QString G4OpenGLQtViewer::getEncoderPath ( )
Returns
encoder path or "" if it does not exist

Definition at line 1848 of file G4OpenGLQtViewer.cc.

1848 {
1849 return fEncoderPath;
1850}

Referenced by G4OpenGLQtMovieDialog::checkEncoderSwParameters(), encodeVideo(), and G4OpenGLQtMovieDialog::G4OpenGLQtMovieDialog().

◆ GetPrivateVisAttributesModifiers()

const std::vector< G4ModelingParameters::VisAttributesModifier > * G4OpenGLQtViewer::GetPrivateVisAttributesModifiers ( ) const
protectedvirtual

Reimplemented from G4VViewer.

Definition at line 3592 of file G4OpenGLQtViewer.cc.

3593{
3594 static std::vector<G4ModelingParameters::VisAttributesModifier>
3595 privateVisAttributesModifiers;
3596
3597 privateVisAttributesModifiers.clear();
3598
3599// I don't think we need this. (JA Sep 2016).
3600// // For each modified touchable...
3601// std::map<int,PVPath>::const_iterator i;
3602// for (i = fTreeItemModels.begin();
3603// i != fTreeItemModels.end();
3604// ++i) {
3605//
3606// // How do I know if it's been modified or not?
3607//
3608// int iPO = i->first;
3609// const PVPath& fullPath = i->second;
3610//
3611// // If a physical volume
3612// if (fullPath.size()) {
3613//
3614// // const G4bool& visibilityChanged = ???
3615// // const G4bool& visibility = ???
3616// // const G4bool& colourChanged = ???
3617// // const QColor& colour = ???
3618// // G4Colour g4colour(((G4double)colour.red())/255,
3619// // ((G4double)colour.green())/255,
3620// // ((G4double)colour.blue())/255,
3621// // ((G4double)colour.alpha())/255);
3622// // Next 4 lines are for testing, to be replaced by the above...
3623// G4bool visibilityChanged = true;
3624// G4bool visibility = true;
3625// G4bool colourChanged = true;
3626// G4Colour g4colour(G4Colour::Red());
3627//
3628// // Instantiate a working copy of a G4VisAttributes object...
3629// G4VisAttributes workingVisAtts;
3630// // ...and use it to create vis attribute modifiers...
3631// if (visibilityChanged) {
3632// workingVisAtts.SetVisibility(visibility);
3633// privateVisAttributesModifiers.push_back
3634// (G4ModelingParameters::VisAttributesModifier
3635// (workingVisAtts,
3636// G4ModelingParameters::VASVisibility,
3637// fullPath));
3638// }
3639// if (colourChanged) {
3640// workingVisAtts.SetColour(g4colour);
3641// privateVisAttributesModifiers.push_back
3642// (G4ModelingParameters::VisAttributesModifier
3643// (workingVisAtts,
3644// G4ModelingParameters::VASColour,
3645// fullPath));
3646// }
3647// }
3648// }
3649
3650 return &privateVisAttributesModifiers;
3651}

◆ getSaveFileName()

QString G4OpenGLQtViewer::getSaveFileName ( )
Returns
the save file path

Definition at line 2044 of file G4OpenGLQtViewer.cc.

2044 {
2045 return fSaveFileName ;
2046}

Referenced by G4OpenGLQtMovieDialog::checkSaveFileNameParameters(), encodeVideo(), and generateMpegEncoderParameters().

◆ getTempFolderPath()

QString G4OpenGLQtViewer::getTempFolderPath ( )
Returns
the temp folder path or "" if it does not exist

Definition at line 2010 of file G4OpenGLQtViewer.cc.

2010 {
2011 return fTempFolderPath;
2012}

Referenced by G4OpenGLQtMovieDialog::checkTempFolderParameters(), G4OpenGLQtMovieDialog::G4OpenGLQtMovieDialog(), and startPauseVideo().

◆ isBadEncoder()

bool G4OpenGLQtViewer::isBadEncoder ( )

Definition at line 1931 of file G4OpenGLQtViewer.cc.

1931 {
1932 if (fRecordingStep == BAD_ENCODER) {
1933 return true;
1934 }
1935 return false;
1936}

Referenced by G4OpenGLQtMovieDialog::setRecordingStatus().

◆ isBadOutput()

bool G4OpenGLQtViewer::isBadOutput ( )

Definition at line 1943 of file G4OpenGLQtViewer.cc.

1943 {
1944 if (fRecordingStep == BAD_OUTPUT) {
1945 return true;
1946 }
1947 return false;
1948}

Referenced by G4OpenGLQtMovieDialog::setRecordingStatus().

◆ isBadTmp()

bool G4OpenGLQtViewer::isBadTmp ( )

Definition at line 1937 of file G4OpenGLQtViewer.cc.

1937 {
1938 if (fRecordingStep == BAD_TMP) {
1939 return true;
1940 }
1941 return false;
1942}

Referenced by G4OpenGLQtMovieDialog::setRecordingStatus().

◆ isCurrentWidget()

bool G4OpenGLQtViewer::isCurrentWidget ( )
protected

Definition at line 4637 of file G4OpenGLQtViewer.cc.

4637 {
4638 G4Qt* interactorManager = G4Qt::getInstance ();
4639 if (!interactorManager->IsExternalApp()) {
4640
4641 // Prevent from repainting a hidden tab (the current tab name has to be the one of th GL viewer)
4642 if ( GetName() != fUiQt->GetViewerTabWidget()->tabText(fUiQt->GetViewerTabWidget()->currentIndex()).toStdString().c_str()) {
4643 return false;
4644 }
4645 }
4646 return true;
4647}
const G4String & GetName() const

Referenced by updatePickInfosWidget(), G4OpenGLImmediateQtViewer::updateQWidget(), G4OpenGLStoredQtViewer::updateQWidget(), and updateViewerPropertiesTableWidget().

◆ isEncoding()

bool G4OpenGLQtViewer::isEncoding ( )

Definition at line 1896 of file G4OpenGLQtViewer.cc.

1896 {
1897 if (fRecordingStep == ENCODING) {
1898 return true;
1899 }
1900 return false;
1901}

◆ isFailed()

bool G4OpenGLQtViewer::isFailed ( )

Definition at line 1917 of file G4OpenGLQtViewer.cc.

1917 {
1918 if (fRecordingStep == FAILED) {
1919 return true;
1920 }
1921 return false;
1922}

Referenced by G4OpenGLQtMovieDialog::setRecordingStatus().

◆ isPaused()

bool G4OpenGLQtViewer::isPaused ( )

Definition at line 1889 of file G4OpenGLQtViewer.cc.

1889 {
1890 if (fRecordingStep == PAUSE) {
1891 return true;
1892 }
1893 return false;
1894}

Referenced by G4OpenGLQtMovieDialog::save(), and G4OpenGLQtMovieDialog::setRecordingStatus().

◆ isReadyToEncode()

bool G4OpenGLQtViewer::isReadyToEncode ( )

Definition at line 1969 of file G4OpenGLQtViewer.cc.

1969 {
1970 if (fRecordingStep == READY_TO_ENCODE) {
1971 return true;
1972 }
1973 return false;
1974}

Referenced by G4OpenGLQtMovieDialog::checkEncoderSwParameters().

◆ isRecording()

bool G4OpenGLQtViewer::isRecording ( )

Definition at line 1882 of file G4OpenGLQtViewer.cc.

1882 {
1883 if ((fRecordingStep == START) || (fRecordingStep == CONTINUE)) {
1884 return true;
1885 }
1886 return false;
1887}

Referenced by G4OpenGLQtMovieDialog::save(), and G4OpenGLQtMovieDialog::setRecordingStatus().

◆ isStopped()

bool G4OpenGLQtViewer::isStopped ( )

Definition at line 1910 of file G4OpenGLQtViewer.cc.

1910 {
1911 if (fRecordingStep == STOP) {
1912 return true;
1913 }
1914 return false;
1915}

Referenced by G4OpenGLQtMovieDialog::save(), and G4OpenGLQtMovieDialog::setRecordingStatus().

◆ isSuccess()

bool G4OpenGLQtViewer::isSuccess ( )

Definition at line 1924 of file G4OpenGLQtViewer.cc.

1924 {
1925 if (fRecordingStep == SUCCESS) {
1926 return true;
1927 }
1928 return false;
1929}

Referenced by G4OpenGLQtMovieDialog::setRecordingStatus().

◆ isTouchableVisible()

bool G4OpenGLQtViewer::isTouchableVisible ( int POindex)

Definition at line 3372 of file G4OpenGLQtViewer.cc.

3372 {
3373
3374 // If no scene tree (Immediate viewer)
3375 if (fSceneTreeComponentTreeWidget == NULL) {
3376 return false;
3377 }
3378
3379 // should be the next one
3380 // Prevent to get out the std::map
3381 if (fLastSceneTreeWidgetAskForIterator != fLastSceneTreeWidgetAskForIteratorEnd) {
3382 fLastSceneTreeWidgetAskForIterator++;
3383 }
3384 QTreeWidgetItem* item = getTreeWidgetItem(POindex);
3385
3386 if (item != NULL) {
3387 if ( item->checkState(0) == Qt::Checked) {
3388 return true;
3389 }
3390 }
3391 return false;
3392}

Referenced by G4OpenGLStoredQtViewer::POSelected().

◆ isWaiting()

bool G4OpenGLQtViewer::isWaiting ( )

Definition at line 1903 of file G4OpenGLQtViewer.cc.

1903 {
1904 if (fRecordingStep == WAIT) {
1905 return true;
1906 }
1907 return false;
1908}

Referenced by G4OpenGLQtMovieDialog::setRecordingStatus().

◆ moveScene()

void G4OpenGLQtViewer::moveScene ( float dx,
float dy,
float dz,
bool mouseMove )
protected

Move the scene of dx, dy, dz values.

Parameters
dxdelta mouse x position
dydelta mouse y position
mouseMove: true if event comes from a mouse move, false if event comes from key action

Definition at line 1443 of file G4OpenGLQtViewer.cc.

1444{
1445 if (fHoldMoveEvent)
1446 return;
1447 fHoldMoveEvent = true;
1448
1449 G4double coefTrans = 0;
1450 GLdouble coefDepth = 0;
1451 if(mouseMove) {
1452 coefTrans = ((G4double)getSceneNearWidth())/((G4double)getWinWidth());
1453 if (getWinHeight() <getWinWidth()) {
1454 coefTrans = ((G4double)getSceneNearWidth())/((G4double)getWinHeight());
1455 }
1456 } else {
1457 coefTrans = getSceneNearWidth()*fPan_sens;
1458 coefDepth = getSceneDepth()*fDeltaDepth;
1459 }
1460 fVP.IncrementPan(-dx*coefTrans,dy*coefTrans,dz*coefDepth);
1461
1462 updateQWidget();
1463 if (fAutoMove)
1464 ((QApplication*)G4Qt::getInstance ())->processEvents();
1465
1466 fHoldMoveEvent = false;
1467}
GLdouble getSceneDepth()

Referenced by G4keyPressEvent(), G4MouseMoveEvent(), G4MousePressEvent(), and G4MouseReleaseEvent().

◆ resetRecording()

void G4OpenGLQtViewer::resetRecording ( )

Definition at line 1976 of file G4OpenGLQtViewer.cc.

1976 {
1977 setRecordingStatus(WAIT);
1978}

Referenced by savePPMToTemp(), and stopVideo().

◆ ResetView()

void G4OpenGLQtViewer::ResetView ( )
virtual

Reimplemented from G4VViewer.

Definition at line 2786 of file G4OpenGLQtViewer.cc.

2786 {
2788 fDeltaDepth = 0.01;
2789 fDeltaZoom = 0.05;
2790}

Referenced by G4keyPressEvent().

◆ rotateQtScene()

void G4OpenGLQtViewer::rotateQtScene ( float dx,
float dy )
protected
Parameters
dxdelta mouse x position
dydelta mouse y position

Definition at line 1475 of file G4OpenGLQtViewer.cc.

1476{
1477 if (fHoldRotateEvent)
1478 return;
1479 fHoldRotateEvent = true;
1480
1481 rotateScene(dx,dy);
1482
1483 updateQWidget();
1484
1485 fHoldRotateEvent = false;
1486}
void rotateScene(G4double dx, G4double dy)

Referenced by G4keyPressEvent(), G4MouseMoveEvent(), and G4MouseReleaseEvent().

◆ rotateQtSceneToggle()

void G4OpenGLQtViewer::rotateQtSceneToggle ( float dx,
float dy )
protected
Parameters
dxdelta mouse x position
dydelta mouse y position

Definition at line 1493 of file G4OpenGLQtViewer.cc.

1494{
1495 if (fHoldRotateEvent)
1496 return;
1497 fHoldRotateEvent = true;
1498
1499 rotateSceneToggle(dx,dy);
1500
1501 updateQWidget();
1502
1503 fHoldRotateEvent = false;
1504}
void rotateSceneToggle(G4double dx, G4double dy)

Referenced by G4keyPressEvent(), G4MouseMoveEvent(), and G4MouseReleaseEvent().

◆ savePPMToTemp()

void G4OpenGLQtViewer::savePPMToTemp ( )
protected

Definition at line 1009 of file G4OpenGLQtViewer.cc.

1009 {
1010 if (fMovieTempFolderPath == "") {
1011 return;
1012 }
1013 auto qGLW = dynamic_cast<G4QGLWidgetType*> (fGLWidget) ;
1014 if (! qGLW) {
1015 return;
1016 }
1017 QString fileName ="Test"+QString::number(fRecordFrameNumber)+".ppm";
1018 QString filePath =fMovieTempFolderPath+fileName;
1019
1020 QImage image;
1021#if (QT_VERSION < QT_VERSION_CHECK(6, 0, 0))
1022 image = qGLW->grabFrameBuffer();
1023#else
1024 image = qGLW->grabFramebuffer();
1025#endif
1026 bool res = false;
1027
1028 res = image.save(filePath,0);
1029 if (res == false) {
1031 setRecordingInfos("Can't save tmp file "+filePath);
1032 return;
1033 }
1034
1035 setRecordingInfos("File "+fileName+" saved");
1037}

◆ saveVideo()

void G4OpenGLQtViewer::saveVideo ( )

Stop the video. Check all parameters and enable encoder button if all is ok.

Definition at line 1719 of file G4OpenGLQtViewer.cc.

1719 {
1720
1721 // if encoder parameter is wrong, display parameters dialog and return
1722 if (!fMovieParametersDialog) {
1723 showMovieParametersDialog();
1724 }
1725
1726 fMovieParametersDialog->checkEncoderSwParameters();
1727 fMovieParametersDialog->checkSaveFileNameParameters();
1728
1729 if (fRecordingStep == STOP) {
1730 setRecordingStatus(SAVE);
1732 encodeVideo();
1733 }
1734}

Referenced by G4OpenGLQtMovieDialog::save().

◆ setBadEncoder()

void G4OpenGLQtViewer::setBadEncoder ( )

Definition at line 1950 of file G4OpenGLQtViewer.cc.

1950 {
1951 fRecordingStep = BAD_ENCODER;
1953}

◆ setBadOutput()

void G4OpenGLQtViewer::setBadOutput ( )

Definition at line 1958 of file G4OpenGLQtViewer.cc.

1958 {
1959 fRecordingStep = BAD_OUTPUT;
1961}

◆ setBadTmp()

void G4OpenGLQtViewer::setBadTmp ( )

Definition at line 1954 of file G4OpenGLQtViewer.cc.

1954 {
1955 fRecordingStep = BAD_TMP;
1957}

◆ setEncoderPath()

QString G4OpenGLQtViewer::setEncoderPath ( QString path)

set the new encoder path

Returns
"" if correct. The error otherwise

Definition at line 1857 of file G4OpenGLQtViewer.cc.

1857 {
1858 if (path == "") {
1859 return "ppmtompeg is needed to encode in video format. It is available here: http://netpbm.sourceforge.net ";
1860 }
1861
1862 path = QDir::cleanPath(path);
1863 QFileInfo *f = new QFileInfo(path);
1864 if (!f->exists()) {
1865 return "File does not exist";
1866 } else if (f->isDir()) {
1867 return "This is a directory";
1868 } else if (!f->isExecutable()) {
1869 return "File exist but is not executable";
1870 } else if (!f->isFile()) {
1871 return "This is not a file";
1872 }
1873 fEncoderPath = path;
1874
1875 if (fRecordingStep == BAD_ENCODER) {
1876 setRecordingStatus(STOP);
1877 }
1878 return "";
1879}

Referenced by G4OpenGLQtMovieDialog::checkEncoderSwParameters().

◆ setSaveFileName()

QString G4OpenGLQtViewer::setSaveFileName ( QString path)

set the save file name path

Returns
"" if correct. The error otherwise

Definition at line 2018 of file G4OpenGLQtViewer.cc.

2018 {
2019
2020 if (path == "") {
2021 return "Path does not exist";
2022 }
2023
2024 QFileInfo *file = new QFileInfo(path);
2025 QDir dir = file->dir();
2026 path = QDir::cleanPath(path);
2027 if (file->exists()) {
2028 return "File already exist, please choose a new one";
2029 } else if (!dir.exists()) {
2030 return "Dir does not exist";
2031 } else if (!dir.isReadable()) {
2032 return path +" is read protected";
2033 }
2034
2035 if (fRecordingStep == BAD_OUTPUT) {
2036 setRecordingStatus(STOP);
2037 }
2038 fSaveFileName = path;
2039 return "";
2040}

Referenced by G4OpenGLQtMovieDialog::checkSaveFileNameParameters().

◆ setTempFolderPath()

QString G4OpenGLQtViewer::setTempFolderPath ( QString path)

set the temp folder path

Returns
"" if correct. The error otherwise

Definition at line 1984 of file G4OpenGLQtViewer.cc.

1984 {
1985
1986 if (path == "") {
1987 return "Path does not exist";
1988 }
1989 path = QDir::cleanPath(path);
1990 QFileInfo *d = new QFileInfo(path);
1991 if (!d->exists()) {
1992 return "Path does not exist";
1993 } else if (!d->isDir()) {
1994 return "This is not a directory";
1995 } else if (!d->isReadable()) {
1996 return path +" is read protected";
1997 } else if (!d->isWritable()) {
1998 return path +" is write protected";
1999 }
2000
2001 if (fRecordingStep == BAD_TMP) {
2002 setRecordingStatus(WAIT);
2003 }
2004 fTempFolderPath = path;
2005 return "";
2006}

Referenced by G4OpenGLQtMovieDialog::checkTempFolderParameters().

◆ setWaiting()

void G4OpenGLQtViewer::setWaiting ( )

Definition at line 1963 of file G4OpenGLQtViewer.cc.

1963 {
1964 fRecordingStep = WAIT;
1966}

◆ startPauseVideo

void G4OpenGLQtViewer::startPauseVideo ( )
slot

Start/Pause the video..

Definition at line 1739 of file G4OpenGLQtViewer.cc.

1739 {
1740
1741 // first time, if temp parameter is wrong, display parameters dialog and return
1742
1743 if ( fRecordingStep == WAIT) {
1744 if ( fRecordFrameNumber == 0) {
1745 if (getTempFolderPath() == "") { // BAD_OUTPUT
1746 showMovieParametersDialog();
1747 setRecordingInfos("You should specified the temp folder in order to make movie");
1748 return;
1749 } else {
1750 // remove temp folder if it was create
1751 QString tmp = removeTempFolder();
1752 if (tmp !="") {
1753 setRecordingInfos(tmp);
1754 return;
1755 }
1756 tmp = createTempFolder();
1757 if (tmp != "") {
1758 setRecordingInfos("Can't create temp folder."+tmp);
1759 return;
1760 }
1761 }
1762 }
1763 }
1764 if (fRecordingStep == WAIT) {
1765 setRecordingStatus(START);
1766 } else if (fRecordingStep == START) {
1767 setRecordingStatus(PAUSE);
1768 } else if (fRecordingStep == PAUSE) {
1769 setRecordingStatus(CONTINUE);
1770 } else if (fRecordingStep == CONTINUE) {
1771 setRecordingStatus(PAUSE);
1772 }
1773}

Referenced by G4keyPressEvent().

◆ stopVideo()

void G4OpenGLQtViewer::stopVideo ( )

Stop the video. Check all parameters and enable encoder button if all is ok.

Definition at line 1696 of file G4OpenGLQtViewer.cc.

1696 {
1697
1698 // if encoder parameter is wrong, display parameters dialog and return
1699 if (!fMovieParametersDialog) {
1700 showMovieParametersDialog();
1701 }
1702 setRecordingStatus(STOP);
1703
1704 if (fRecordFrameNumber >0) {
1705 // check parameters if they were modified (Re APPLY them...)
1706 if (!(fMovieParametersDialog->checkEncoderSwParameters())) {
1707 setRecordingStatus(BAD_ENCODER);
1708 } else if (!(fMovieParametersDialog->checkSaveFileNameParameters())) {
1709 setRecordingStatus(BAD_OUTPUT);
1710 }
1711 } else {
1713 setRecordingInfos("No frame to encode.");
1714 }
1715}

Referenced by G4keyPressEvent(), and G4OpenGLQtMovieDialog::stopFinishClose().

◆ updateKeyModifierState()

void G4OpenGLQtViewer::updateKeyModifierState ( const Qt::KeyboardModifiers & modifier)
protected

Definition at line 1671 of file G4OpenGLQtViewer.cc.

1671 {
1672 // Check Qt Versions for META Keys
1673
1674 fNoKeyPress = true;
1675 fAltKeyPress = false;
1676 fShiftKeyPress = false;
1677 fControlKeyPress = false;
1678
1679 if (modifier & Qt::AltModifier ) {
1680 fAltKeyPress = true;
1681 fNoKeyPress = false;
1682 }
1683 if (modifier & Qt::ShiftModifier ) {
1684 fShiftKeyPress = true;
1685 fNoKeyPress = false;
1686 }
1687 if (modifier & Qt::ControlModifier ) {
1688 fControlKeyPress = true;
1689 fNoKeyPress = false;
1690 }
1691}

Referenced by G4keyPressEvent(), and G4MouseMoveEvent().

◆ updatePickInfosWidget()

void G4OpenGLQtViewer::updatePickInfosWidget ( int aX,
int aY )

Update the pick infos component widget

Definition at line 4442 of file G4OpenGLQtViewer.cc.

4442 {
4443 fLastPickPoint = QPoint(aX,aY);
4444
4445 if (!isCurrentWidget()) {
4446 return;
4447 }
4448 // Ensure case where closing a UI tab close the widget
4449 if (!fPickInfosWidget) {
4450 createPickInfosWidget();
4451 }
4452
4453 const std::vector < G4OpenGLViewerPickMap* > & pickMapVector = GetPickDetails(aX,aY);
4454
4455 // remove all previous widgets
4456 if (fPickInfosWidget) {
4457 QLayoutItem * wItem;
4458 if (fPickInfosWidget->layout()->count()) {
4459 while ((wItem = fPickInfosWidget->layout()->takeAt(0)) != 0) {
4460 delete wItem->widget();
4461 delete wItem;
4462 }
4463 }
4464 } else {
4465 // Ensure case where closing a UI tab close the widget
4466 if (!fPickInfosWidget) {
4467 createPickInfosWidget();
4468 }
4469 }
4470
4471 // parse all pick results
4472 G4int nPickedObjectsWithAttributes = 0;
4473 for (unsigned int a=0; a< pickMapVector.size(); a++) {
4474 const auto& pickMap = pickMapVector[a];
4475 // Add a box inside the pick viewer box
4476 std::ostringstream label;
4477 std::ostringstream content;
4478 std::string txt = pickMap->getAttributes()[0].data();
4479 if (pickMapVector[a]->getAttributes().size()) {
4480 ++nPickedObjectsWithAttributes;
4481
4482 std::size_t pos1 = txt.find(':');
4483 std::string storeKey = txt.substr(0,pos1);
4484
4485 if (storeKey == "G4PhysicalVolumeModel") {
4486
4487 label << "Volume:";
4488 std::size_t pos2 = txt.find(':',pos1+1);
4489 std::size_t pos3 = txt.find('\n',pos2+1);
4490 label << txt.substr(pos2+1,pos3-pos2-1);
4491
4492 } else if (storeKey == "G4TrajectoriesModel") {
4493
4494 label << "Trajectory:";
4495 std::size_t pos2 = txt.find(':',pos1+1);
4496 std::size_t pos3 = txt.find('\n',pos2+1);
4497 label << " Run:" << txt.substr(pos2+1,pos3-pos2-1);
4498 std::size_t pos4 = txt.find(':',pos3+1);
4499 std::size_t pos5 = txt.find('\n',pos4+1);
4500 label << ", Event:" << txt.substr(pos4+1,pos5-pos4-1);
4501
4502 } else {
4503
4504 label << "Hit number:" << a << ", PickName: " << pickMap->getPickName();
4505
4506 }
4507
4508 // Accumulate all content with the same pickname
4509 content << pickMap->print().data();
4510 G4int thisPickName = pickMap->getPickName();
4511 while (++a < pickMapVector.size()) {
4512 const auto& a_pickMap = pickMapVector[a];
4513 if (a_pickMap->getPickName() == thisPickName) {
4514 content << a_pickMap->print().data();
4515 } else {
4516 a--;
4517 break;
4518 }
4519 }
4520
4521 QPushButton* pickCoutButton = new QPushButton(label.str().c_str());
4522 pickCoutButton->setStyleSheet ("text-align: left; padding: 1px; border: 0px;");
4523 pickCoutButton->setIcon(*fTreeIconClosed);
4524 fPickInfosWidget->layout()->addWidget(pickCoutButton);
4525
4526 QStringList newStr;
4527
4528 // Add to stringList
4529 newStr = QStringList(QString(content.str().c_str()).trimmed());
4530
4531 QTextEdit* ed = new QTextEdit();
4532 ed->setReadOnly(true);
4533 fPickInfosWidget->layout()->addWidget(ed);
4534 ed->setVisible((false));
4535 ed->append(newStr.join(""));
4536
4537 std::cout << pickCoutButton->text().toStdString() << " "<< fPickInfosWidget->layout()->count()-1<< std::endl;
4538 int tmp = fPickInfosWidget->layout()->count()-1;
4539 connect(pickCoutButton, &QPushButton::clicked , [this, tmp](){ this->toggleSceneTreeComponentPickingCout(tmp);});
4540 }
4541 }
4542
4543 // add a label to push everything up!
4544 QLabel * pushUp = new QLabel("");
4545 QSizePolicy vPolicy = QSizePolicy(QSizePolicy::Minimum,QSizePolicy::Minimum);
4546 vPolicy.setVerticalStretch(10);
4547 pushUp->setSizePolicy(vPolicy);
4548 fPickInfosWidget->layout()->addWidget(pushUp);
4549
4550 // highlight the first one :
4551
4552 // first un-highlight the last selected
4553 changeColorAndTransparency(fLastHighlightName,fLastHighlightColor);
4554
4555 if (pickMapVector.size() > 0 ) {
4556 // get the new one
4557 fLastHighlightName = pickMapVector[0]->getPickName();
4558 fLastHighlightColor = getColorForPoIndex(fLastHighlightName);
4559 // set the new one
4560 changeColorAndTransparency(fLastHighlightName,G4Color(1,1,1,1));
4561
4562 updateQWidget();
4563 }
4564 QDialog* dial = static_cast<QDialog*> (fUIPickInfosWidget->parent());
4565 if (dial) {
4566 // change name
4567 std::ostringstream oss;
4568 if (nPickedObjectsWithAttributes == 0) {
4569 oss << "No object";
4570 } else if (nPickedObjectsWithAttributes == 1) {
4571 oss << "1 object";
4572 } else {
4573 oss << nPickedObjectsWithAttributes << " objects";
4574 }
4575 oss << " selected - " << GetName();
4576 dial->setWindowTitle(oss.str().c_str());
4577 }
4578 // set picking cout visible
4579 fPickInfosScrollArea->setVisible(true);
4580}
G4Colour getColorForPoIndex(int poIndex)
const std::vector< G4OpenGLViewerPickMap * > & GetPickDetails(GLdouble x, GLdouble y)

Referenced by G4MouseReleaseEvent().

◆ updateQWidget()

virtual void G4OpenGLQtViewer::updateQWidget ( )
pure virtual

◆ updateSceneTreeWidget()

void G4OpenGLQtViewer::updateSceneTreeWidget ( )

Update the scene tree widget

Definition at line 4123 of file G4OpenGLQtViewer.cc.

4123 {
4124 // Ensure case where closing a UI tab close the widget
4125 if (!fSceneTreeWidget) {
4126 createSceneTreeWidget();
4127 }
4128}

Referenced by G4OpenGLImmediateQtViewer::updateQWidget(), and G4OpenGLStoredQtViewer::updateQWidget().

◆ updateToolbarAndMouseContextMenu

void G4OpenGLQtViewer::updateToolbarAndMouseContextMenu ( )
protectedslot

Update the toolbar Icons/Mouse context menu

  • Change ortho/perspective
  • Change surface style
  • Change cursor style

Definition at line 4021 of file G4OpenGLQtViewer.cc.

4021 {
4022 if (fBatchMode) {
4023 return;
4024 }
4025
4027 d_style = fVP.GetDrawingStyle();
4028
4029 // Surface style
4030 if (d_style == G4ViewParameters::wireframe) {
4032 if (fContextMenu) {
4033 fDrawingWireframe->setChecked(true);
4034 fDrawingLineRemoval->setChecked(false);
4035 fDrawingSurfaceRemoval->setChecked(false);
4036 fDrawingLineSurfaceRemoval->setChecked(false);
4037 }
4038 } else if (d_style == G4ViewParameters::hlr) {
4040 if (fContextMenu) {
4041 fDrawingLineRemoval->setChecked(true);
4042 fDrawingWireframe->setChecked(false);
4043 fDrawingSurfaceRemoval->setChecked(false);
4044 fDrawingLineSurfaceRemoval->setChecked(false);
4045 }
4046 } else if (d_style == G4ViewParameters::hsr) {
4048 if (fContextMenu) {
4049 fDrawingSurfaceRemoval->setChecked(true);
4050 fDrawingWireframe->setChecked(false);
4051 fDrawingLineRemoval->setChecked(false);
4052 fDrawingLineSurfaceRemoval->setChecked(false);
4053 }
4054 } else if (d_style == G4ViewParameters::hlhsr) {
4056 if (fContextMenu) {
4057 fDrawingLineSurfaceRemoval->setChecked(true);
4058 fDrawingWireframe->setChecked(false);
4059 fDrawingLineRemoval->setChecked(false);
4060 fDrawingSurfaceRemoval->setChecked(false);
4061 fDrawingLineSurfaceRemoval->setChecked(false);
4062 }
4063 }
4064
4065
4066 // projection style
4067 G4double d_proj = fVP.GetFieldHalfAngle () ;
4068 if (d_proj == 0.) { // ortho
4070 if (fContextMenu) {
4071 fProjectionOrtho->setChecked(true);
4072 fProjectionPerspective->setChecked(false);
4073 }
4074 } else {
4076 if (fContextMenu) {
4077 fProjectionPerspective->setChecked(true);
4078 fProjectionOrtho->setChecked(false);
4079 }
4080 }
4081
4082
4083 // mouse style : They are controlled by UI !
4084 if (fUiQt && fContextMenu) {
4085 if (fUiQt->IsIconPickSelected()) {
4086 fMousePickAction->setChecked(true);
4087 fMouseZoomOutAction->setChecked(false);
4088 fMouseZoomInAction->setChecked(false);
4089 fMouseRotateAction->setChecked(false);
4090 fMouseMoveAction->setChecked(false);
4091 } else if (fUiQt->IsIconZoomOutSelected()) {
4092 fMouseZoomOutAction->setChecked(true);
4093 fMousePickAction->setChecked(false);
4094 fMouseZoomInAction->setChecked(false);
4095 fMouseRotateAction->setChecked(false);
4096 fMouseMoveAction->setChecked(false);
4097 } else if (fUiQt->IsIconZoomInSelected()) {
4098 fMouseZoomInAction->setChecked(true);
4099 fMousePickAction->setChecked(false);
4100 fMouseZoomOutAction->setChecked(false);
4101 fMouseRotateAction->setChecked(false);
4102 fMouseMoveAction->setChecked(false);
4103 } else if (fUiQt->IsIconRotateSelected()) {
4104 fMouseRotateAction->setChecked(true);
4105 fMousePickAction->setChecked(false);
4106 fMouseZoomOutAction->setChecked(false);
4107 fMouseZoomInAction->setChecked(false);
4108 fMouseMoveAction->setChecked(false);
4109 } else if (fUiQt->IsIconMoveSelected()) {
4110 fMouseMoveAction->setChecked(true);
4111 fMousePickAction->setChecked(false);
4112 fMouseZoomOutAction->setChecked(false);
4113 fMouseZoomInAction->setChecked(false);
4114 fMouseRotateAction->setChecked(false);
4115 }
4116 }
4117}
void SetIconOrthoSelected()
Definition G4UIQt.cc:5384
void SetIconHLRSelected()
Definition G4UIQt.cc:5308
void SetIconPerspectiveSelected()
Definition G4UIQt.cc:5363
void SetIconSolidSelected()
Definition G4UIQt.cc:5254
void SetIconWireframeSelected()
Definition G4UIQt.cc:5281
void SetIconHLHSRSelected()
Definition G4UIQt.cc:5335
G4double GetFieldHalfAngle() const
DrawingStyle GetDrawingStyle() const

Referenced by G4OpenGLImmediateQtViewer::paintGL(), and G4OpenGLStoredQtViewer::paintGL().

◆ updateViewerPropertiesTableWidget()

void G4OpenGLQtViewer::updateViewerPropertiesTableWidget ( )

Update the viewer properties component widget Clear it only if the number of command is less than the previous table widget row count

Definition at line 4135 of file G4OpenGLQtViewer.cc.

4135 {
4136
4137 if (!isCurrentWidget()) {
4138 return;
4139 }
4140
4141 // Ensure case where closing a UI tab close the widget
4142 if (!fViewerPropertiesTableWidget) {
4143 createViewerPropertiesWidget();
4144 }
4145 int treeWidgetInfosIgnoredCommands = 0;
4147 G4UIcommandTree * commandTreeTop = UI->GetTree();
4148 G4UIcommandTree* path = commandTreeTop->FindCommandTree("/vis/viewer/set/");
4149
4150 if (!path) {
4151 return;
4152 }
4153
4154 // clear old table
4155 if ((path->GetCommandEntry()-fTreeWidgetInfosIgnoredCommands) != fViewerPropertiesTableWidget->rowCount()) {
4156 fViewerPropertiesTableWidget->clear();
4157 }
4158
4159 fViewerPropertiesTableWidget->blockSignals(true);
4160 // TODO : Could be optimized by comparing current command to old commands. That should not change so much
4161
4162 fViewerPropertiesTableWidget->setColumnCount (2);
4163 fViewerPropertiesTableWidget->setRowCount (path->GetCommandEntry()-fTreeWidgetInfosIgnoredCommands);
4164 fViewerPropertiesTableWidget->setHorizontalHeaderLabels(QStringList() << tr("Property")
4165 << tr("Value"));
4166 fViewerPropertiesTableWidget->verticalHeader()->setVisible(false);
4167 fViewerPropertiesTableWidget->setAlternatingRowColors (true);
4168
4169 // For the moment, we do only command that have a "set" command in UI
4170
4171 for (int a=0;a<path->GetCommandEntry();a++) {
4172 G4UIcommand* commandTmp = path->GetCommand(a+1);
4173
4174 // get current parameters
4175 QString params = "";
4176
4177 if(commandTmp->GetCommandName() == "autoRefresh") {
4178 if (fVP.IsAutoRefresh()) {
4179 params = "True";
4180 } else {
4181 params = "False";
4182 }
4183 } else if(commandTmp->GetCommandName() == "auxiliaryEdge") {
4184 if (fVP.IsAuxEdgeVisible()) {
4185 params = "True";
4186 } else {
4187 params = "False";
4188 }
4189 } else if(commandTmp->GetCommandName() == "background") {
4190 params = QString().number(fVP.GetBackgroundColour().GetRed()) + " "+
4191 QString().number(fVP.GetBackgroundColour().GetGreen()) + " "+
4192 QString().number(fVP.GetBackgroundColour().GetBlue()) + " "+
4193 QString().number(fVP.GetBackgroundColour().GetAlpha());
4194
4195 } else if(commandTmp->GetCommandName() == "culling") {
4196 params = QString().number(fVP. IsCulling ());
4197 } else if(commandTmp->GetCommandName() == "cutawayMode") {
4199 params = "union";
4200 } else {
4201 params = "intersection";
4202 }
4203
4204 } else if(commandTmp->GetCommandName() == "defaultColour") {
4205 params = QString().number(fVP.GetDefaultVisAttributes()->GetColor().GetRed()) + " "+
4206 QString().number(fVP.GetDefaultVisAttributes()->GetColor().GetGreen()) + " "+
4207 QString().number(fVP.GetDefaultVisAttributes()->GetColor().GetBlue()) + " "+
4208 QString().number(fVP.GetDefaultVisAttributes()->GetColor().GetAlpha());
4209
4210 } else if(commandTmp->GetCommandName() == "defaultTextColour") {
4211 params = QString().number(fVP.GetDefaultTextVisAttributes()->GetColor().GetRed()) + " "+
4212 QString().number(fVP.GetDefaultTextVisAttributes()->GetColor().GetGreen()) + " "+
4213 QString().number(fVP.GetDefaultTextVisAttributes()->GetColor().GetBlue()) + " "+
4214 QString().number(fVP.GetDefaultTextVisAttributes()->GetColor().GetAlpha());
4215
4216 } else if(commandTmp->GetCommandName() == "edge") {
4218 params = "False";
4219 if (existingStyle == G4ViewParameters::hsr) {
4220 params = "True";
4221 }
4222
4223 } else if(commandTmp->GetCommandName() == "explodeFactor") {
4224 params = QString().number(fVP.GetExplodeFactor()) + " " + QString(G4String(G4BestUnit(fVP.GetExplodeFactor(),"Length")).data());
4225
4226 } else if(commandTmp->GetCommandName() == "globalLineWidthScale") {
4227 params = QString().number(fVP.GetGlobalLineWidthScale());
4228
4229 } else if(commandTmp->GetCommandName() == "globalMarkerScale") {
4230 params = QString().number(fVP.GetGlobalMarkerScale());
4231
4232 } else if(commandTmp->GetCommandName() == "hiddenEdge") {
4234 if ((style == G4ViewParameters::hlr) ||
4235 (style == G4ViewParameters::hlhsr)) {
4236 params = "True";
4237 } else {
4238 params = "False";
4239 }
4240
4241 } else if(commandTmp->GetCommandName() == "hiddenMarker") {
4242 if (fVP.IsMarkerNotHidden()) {
4243 params = "False";
4244 } else {
4245 params = "True";
4246 }
4247
4248 } else if(commandTmp->GetCommandName() == "lightsMove") {
4250 params = "camera";
4251 } else {
4252 params = "object";
4253 }
4254 } else if(commandTmp->GetCommandName() == "lightsThetaPhi") {
4256 // degree
4257 params = QString().number(direction.theta()/CLHEP::degree)+ " "+ QString().number(direction.phi()/CLHEP::degree)+" deg";
4258 if (commandTmp->GetParameterEntries() == 3) {
4259 if (commandTmp->GetParameter(2)->GetDefaultValue() != "deg") {
4260 params = QString().number(direction.theta())+ " "+ QString().number(direction.phi())+" "+commandTmp->GetParameter(2)->GetDefaultValue().data();
4261 }
4262 }
4263 } else if(commandTmp->GetCommandName() == "lightsVector") {
4264 params = QString().number(fVP.GetLightpointDirection().x()) + " "+
4265 QString().number(fVP.GetLightpointDirection().y()) + " "+
4266 QString().number(fVP.GetLightpointDirection().z());
4267
4268 } else if(commandTmp->GetCommandName() == "lineSegmentsPerCircle") {
4269 params = QString().number(fVP.GetNoOfSides());
4270
4271 } else if(commandTmp->GetCommandName() == "picking") {
4272 if (fVP.IsPicking()) {
4273 params = "True";
4274 } else {
4275 params = "False";
4276 }
4277
4278 } else if(commandTmp->GetCommandName() == "projection") {
4279 if (fVP.GetFieldHalfAngle() == 0.) {
4280 params = "orthogonal";
4281 } else {
4282 params = QString("perspective ") + QString().number(fVP.GetFieldHalfAngle()/CLHEP::degree) + " deg";
4283 }
4284
4285 } else if(commandTmp->GetCommandName() == "rotationStyle") {
4287 params = "constrainUpDirection";
4288 } else {
4289 params = "freeRotation";
4290 }
4291
4292 } else if(commandTmp->GetCommandName() == "sectionPlane") {
4293 if (fVP.IsSection()) {
4294 params = QString("on ") +
4295 G4String(G4BestUnit(fVP.GetSectionPlane().point(),"Length")).data()+
4296 QString().number(fVP.GetSectionPlane().normal().x())
4297 + " " + QString().number(fVP.GetSectionPlane().normal().y())
4298 + " " + QString().number(fVP.GetSectionPlane().normal().z());
4299 } else {
4300 params = "off";
4301 }
4302
4303 } else if(commandTmp->GetCommandName() == "style") {
4305 params = "wireframe";
4306 } else {
4307 params = "surface";
4308 }
4309
4310
4311 } else if(commandTmp->GetCommandName() == "targetPoint") {
4313 if (fSceneHandler.GetScene()) {
4315 params = b.data();
4316 }
4317 } else if(commandTmp->GetCommandName() == "upThetaPhi") {
4318 G4Vector3D up = fVP.GetUpVector();
4319 // degree
4320 params = QString().number(up.theta()/CLHEP::degree)+ " "+ QString().number(up.phi()/CLHEP::degree)+" deg";
4321 if (commandTmp->GetParameterEntries() == 3) {
4322 if (commandTmp->GetParameter(2)->GetDefaultValue() != "deg") {
4323 params = QString().number(up.theta())+ " "+ QString().number(up.phi())+" "+commandTmp->GetParameter(2)->GetDefaultValue().data();
4324 }
4325 }
4326 } else if(commandTmp->GetCommandName() == "upVector") {
4327 G4Vector3D up = fVP.GetUpVector();
4328 params = QString().number(up.x())+ " "+ QString().number(up.y())+" "+QString().number(up.z())+ " ";
4329
4330 } else if(commandTmp->GetCommandName() == "viewpointThetaPhi") {
4331 G4Vector3D direction = fVP.GetViewpointDirection();
4332 // degree
4333 params = QString().number(direction.theta()/CLHEP::degree)+ " "+ QString().number(direction.phi()/CLHEP::degree)+" deg";
4334 if (commandTmp->GetParameterEntries() == 3) {
4335 if (commandTmp->GetParameter(2)->GetDefaultValue() != "deg") {
4336 params = QString().number(direction.theta())+ " "+ QString().number(direction.phi())+" "+commandTmp->GetParameter(2)->GetDefaultValue().data();
4337 }
4338 }
4339 } else if(commandTmp->GetCommandName() == "viewpointVector") {
4340 G4Vector3D direction = fVP.GetViewpointDirection();
4341 params = QString().number(direction.x())+ " "+ QString().number(direction.y())+" "+QString().number(direction.z());
4342 } else {
4343 // No help
4344 }
4345
4346 /* DO NOT DISPLAY COMMANDS WITHOUT ANY PARAMETERS SET
4347 if (params == "") {
4348 // TODO : display default parameters // should not be editable ?
4349
4350 for( G4int i_thParameter=0; i_thParameter<commandTmp->GetParameterEntries(); i_thParameter++ ) {
4351 commandParam = commandTmp->GetParameter(i_thParameter);
4352
4353 if (QString(QChar(commandParam->GetParameterType())) == "b") {
4354 if (commandParam->GetDefaultValue().data()) {
4355 params += "True";
4356 } else {
4357 params += "False";
4358 }
4359 } else {
4360 params += QString((char*)(commandParam->GetDefaultValue()).data());
4361 }
4362 if (i_thParameter<commandTmp->GetParameterEntries()-1) {
4363 params += " ";
4364 }
4365 }
4366 }
4367 */
4368
4369 if (params != "") {
4370
4371 QTableWidgetItem *nameItem;
4372 QTableWidgetItem *paramItem;
4373
4374 // already present ?
4375 QList<QTableWidgetItem *> list = fViewerPropertiesTableWidget->findItems (commandTmp->GetCommandName().data(),Qt::MatchExactly);
4376 if (list.size() == 1) {
4377 nameItem = list.first();
4378 paramItem = fViewerPropertiesTableWidget->item(nameItem->row(),1);
4379
4380 } else {
4381 nameItem = new QTableWidgetItem();
4382 paramItem = new QTableWidgetItem();
4383 fViewerPropertiesTableWidget->setItem(a-treeWidgetInfosIgnoredCommands, 0, nameItem);
4384 fViewerPropertiesTableWidget->setItem(a-treeWidgetInfosIgnoredCommands, 1, paramItem);
4385
4386 // Set Guidance
4387 QString guidance;
4388 G4int n_guidanceEntry = (G4int)commandTmp->GetGuidanceEntries();
4389 for( G4int i_thGuidance=0; i_thGuidance < n_guidanceEntry; i_thGuidance++ ) {
4390 guidance += QString((char*)(commandTmp->GetGuidanceLine(i_thGuidance)).data()) + "\n";
4391 }
4392
4393 nameItem->setToolTip(guidance);
4394 paramItem->setToolTip(GetCommandParameterList(commandTmp));
4395
4396 fViewerPropertiesTableWidget->setRowHeight(a-treeWidgetInfosIgnoredCommands,15);
4397 }
4398
4399 // set current name and parameters
4400 nameItem->setText(commandTmp->GetCommandName().data());
4401 paramItem->setText(params);
4402
4403 nameItem->setFlags(Qt::NoItemFlags);
4404 nameItem->setForeground(QBrush());
4405
4406 } else {
4407 treeWidgetInfosIgnoredCommands++;
4408 }
4409 }
4410 // remove empty content row
4411 for (int i=0; i<treeWidgetInfosIgnoredCommands; i++) {
4412 fViewerPropertiesTableWidget->removeRow (fViewerPropertiesTableWidget->rowCount() - 1);
4413 }
4414
4415 // The resize should done only at creation
4416 if (!fViewerPropertiesTableWidgetIsInit) {
4417 fViewerPropertiesTableWidgetIsInit = true;
4418
4419 fViewerPropertiesTableWidget->resizeColumnsToContents();
4420
4421 int x = fViewerPropertiesTableWidget->horizontalHeader()->length();
4422 int y = fViewerPropertiesTableWidget->verticalHeader()->length()+ fViewerPropertiesTableWidget->horizontalHeader()->sizeHint().height() + 2;
4423
4424 // fViewerPropertiesTableWidget->verticalHeader()->setResizeMode(QHeaderView::ResizeToContents);
4425 // fViewerPropertiesTableWidget->horizontalHeader()->setResizeMode(QHeaderView::ResizeToContents);
4426
4427 // resize to fit content
4428 QDialog* dial = static_cast<QDialog*> (fUIViewerPropertiesWidget->parent());
4429 if (dial) {
4430 dial->resize(x+56,y+46); // more or less (margins) ...
4431 }
4432 }
4433 fViewerPropertiesTableWidget->blockSignals(false);
4434
4435 fTreeWidgetInfosIgnoredCommands = treeWidgetInfosIgnoredCommands;
4436}
#define G4BestUnit(a, b)
const G4Point3D & GetStandardTargetPoint() const
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
const G4String & GetDefaultValue() const
G4Scene * GetScene() const
G4int GetNoOfSides() const
CutawayMode GetCutawayMode() const
G4double GetExplodeFactor() const
G4bool IsMarkerNotHidden() const
G4double GetGlobalLineWidthScale() const
const G4Colour & GetBackgroundColour() const
const G4Vector3D & GetLightpointDirection() const
const G4Vector3D & GetViewpointDirection() const
G4bool IsSection() const
const G4Point3D & GetCurrentTargetPoint() const
const G4VisAttributes * GetDefaultTextVisAttributes() const
const G4Vector3D & GetUpVector() const
G4double GetGlobalMarkerScale() const
const G4VisAttributes * GetDefaultVisAttributes() const
RotationStyle GetRotationStyle() const
G4bool IsAutoRefresh() const
G4bool GetLightsMoveWithCamera() const
const G4Plane3D & GetSectionPlane() const
G4bool IsAuxEdgeVisible() const
const G4Color & GetColor() const
Point3D< T > point(const Point3D< T > &p) const
Definition Plane3D.h:115
Normal3D< T > normal() const
Definition Plane3D.h:97

Referenced by G4OpenGLImmediateQtViewer::updateQWidget(), and G4OpenGLStoredQtViewer::updateQWidget().

Member Data Documentation

◆ fGLWidget

◆ fHasToRepaint

◆ fMouseOnSceneTree

bool G4OpenGLQtViewer::fMouseOnSceneTree
protected

Definition at line 206 of file G4OpenGLQtViewer.hh.

Referenced by G4OpenGLStoredQtViewer::CompareForKernelVisit().

◆ fPaintEventLock

◆ fQGLWidgetInitialiseCompleted

◆ fRecordFrameNumber

int G4OpenGLQtViewer::fRecordFrameNumber
protected

◆ fUiQt

◆ fUpdateGLLock


The documentation for this class was generated from the following files: