Geant4 11.4.0
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 G4bool ReadyToDraw ()
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)
G4bool GetWindowSize (unsigned int &a_w, unsigned int &a_h)
G4bool GetRenderAreaSize (unsigned int &a_w, unsigned int &a_h)
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
virtual 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 *)
virtual void DoneWithMasterThread ()
virtual void MovingToVisSubThread ()
virtual void SwitchToVisSubThread ()
virtual void DoneWithVisSubThread ()
virtual void MovingToMasterThread ()
virtual void SwitchToMasterThread ()
void InsertModelInSceneTree (G4VModel *)
const G4SceneTreeItemGetSceneTree ()
G4SceneTreeItemAccessSceneTree ()
void UpdateGUISceneTree ()
void UpdateGUIControlWidgets ()
void UpdateGUIDrawingStyle ()
void UpdateGUIProjectionStyle ()
void UpdateGUITransparencySlider ()
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 ()
void ProcessTransients ()
void ZoomFromMouseWheel (G4double delta, G4bool shift=false, G4double xPos=0, G4double yPos=0)

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 ()
virtual void SetView ()
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 ()
G4double 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)
bool IsGettingPickInfos () const
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.
G4SceneTreeItem fSceneTree
G4bool fNeedKernelVisit
G4bool fTransientsNeedRedrawing

Additional Inherited Members

Public Attributes inherited from G4VViewer
const G4int fMaxAllTouchables = 10000
G4bool fCurtailDescent = false

Detailed Description

Definition at line 89 of file G4OpenGLQtViewer.hh.

Constructor & Destructor Documentation

◆ G4OpenGLQtViewer()

G4OpenGLQtViewer::G4OpenGLQtViewer ( G4OpenGLSceneHandler & scene)

Definition at line 213 of file G4OpenGLQtViewer.cc.

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

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

◆ ~G4OpenGLQtViewer()

G4OpenGLQtViewer::~G4OpenGLQtViewer ( )
virtual

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

Definition at line 491 of file G4OpenGLQtViewer.cc.

495{
496 fIsDeleting = true;
497
498 // remove scene tree from layout
499 // Delete all the existing buttons in the layout
500 QLayoutItem *wItem;
501 if (fSceneTreeWidget != NULL) {
502 if (fSceneTreeWidget->layout() != NULL) {
503 while ((wItem = fSceneTreeWidget->layout()->takeAt(0)) != 0) {
504 delete wItem->widget();
505 delete wItem;
506 }
507 }
508 }
509
510 // Delete the open/close icons
511 delete fTreeIconOpen;
512 delete fTreeIconClosed;
513
514#if QT_VERSION < 0x060000
515 G4cout <<removeTempFolder().toStdString().c_str() <<G4endl; //G.Barrand: with Qt6, it crashes at exit if the viewer is in a detached dialog window.
516#endif
517
518}
#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 3366 of file G4OpenGLQtViewer.cc.

3371 {
3372
3373 QString modelShortName = getModelShortName(model);
3374 G4Colour color;
3375
3376 // Special case for text
3377 try {
3378 const G4Text& g4Text = dynamic_cast<const G4Text&>(visible);
3379 color = fSceneHandler.GetTextColour(g4Text);
3380 }
3381 catch (const std::bad_cast&) {
3382 color = fSceneHandler.GetColour();
3383 }
3384
3385 // Special case for marker
3386 try {
3387 const G4VMarker& g4Marker = dynamic_cast<const G4VMarker&>(visible);
3388 if (g4Marker.GetInfo() != "") {
3389 modelShortName = g4Marker.GetInfo();
3390 }
3391 }
3392 catch (const std::bad_cast&) {}
3393
3394 if (modelShortName == "") {
3395 return ;
3396 }
3397 // try to init it
3398 if (fSceneTreeComponentTreeWidget == NULL) {
3399 createSceneTreeComponent();
3400 }
3401
3402 // if no UI
3403 if (fSceneTreeComponentTreeWidget == NULL) {
3404 return;
3405 }
3406
3407 fSceneTreeComponentTreeWidget->blockSignals(true);
3408
3409 // Create the "Model" node if not
3410
3411 QList<QTreeWidgetItem *> resItem;
3412 resItem = fSceneTreeComponentTreeWidget->findItems (modelShortName, Qt::MatchExactly, 0 );
3413 QTreeWidgetItem * currentItem = NULL;
3414 const PVPath tmpFullPath;
3415
3416 if (resItem.empty()) {
3417 currentItem = createTreeWidgetItem(tmpFullPath,
3418 modelShortName,
3419 0, // currentPVCopyNb
3420 -1, // currentPVPOIndex
3421 "",
3422 Qt::Checked,
3423 NULL,
3424 color);
3425 } else {
3426 currentItem = resItem.first();
3427 }
3428
3429 // Is this volume already in the tree AND PO is not the same?
3430 const QList<QTreeWidgetItem *>&
3431 resItems = fSceneTreeComponentTreeWidget->findItems (QString(modelDescription.c_str()), Qt::MatchFixedString| Qt::MatchCaseSensitive|Qt::MatchRecursive, 0 );
3432
3433 bool alreadyPresent = false;
3434 for (int i = 0; i < resItems.size(); ++i) {
3435 if (currentPOIndex == resItems.at(i)->data(0,Qt::UserRole).toInt()) {
3436 alreadyPresent = true;
3437 }
3438 }
3439 if (!alreadyPresent) {
3440 createTreeWidgetItem(tmpFullPath,
3441 modelShortName,
3442 0, // currentPVCopyNb
3443 currentPOIndex,
3444 "",
3445 Qt::Checked,
3446 currentItem,
3447 color);
3448 }
3449 fSceneTreeComponentTreeWidget->blockSignals(false);
3450
3451}
G4VSceneHandler & fSceneHandler
Definition G4VViewer.hh:268
virtual const G4String & GetInfo() const

Referenced by G4OpenGLStoredQtSceneHandler::ExtraPOProcessing().

◆ addPVSceneTreeElement()

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

Definition at line 2898 of file G4OpenGLQtViewer.cc.

2898 {
2899
2900 const QString& modelShortName = getModelShortName(model);
2901
2902 if (modelShortName == "") {
2903 return ;
2904 }
2905 // try to init it
2906 if (fSceneTreeComponentTreeWidget == NULL) {
2907 createSceneTreeComponent();
2908 }
2909
2910 // if no UI
2911 if (fSceneTreeComponentTreeWidget == NULL) {
2912 return;
2913 }
2914
2915 fSceneTreeComponentTreeWidget->blockSignals(true);
2916
2917 // Create the "volume" node if not
2918 // if (fSceneTreeComponentTreeWidget->topLevelItemCount () == 0) {
2919 if (!fPVRootNodeCreate) {
2920 const G4Colour& color = fSceneHandler.GetColour();
2921
2922 fModelShortNameItem = createTreeWidgetItem(pPVModel->GetFullPVPath(),
2923 modelShortName,
2924 0, // currentPVCopyNb
2925 -1, // currentPVPOIndex
2926 "",
2927 Qt::Checked,
2928 NULL,
2929 color);
2930 fPVRootNodeCreate = true;
2931 }
2932
2933 bool added = parseAndInsertInSceneTree(fModelShortNameItem,pPVModel,0,modelShortName,0,currentPOIndex);
2934 if (!added) {
2935 }
2936
2937 fSceneTreeComponentTreeWidget->blockSignals(false);
2938
2939}
const std::vector< G4PhysicalVolumeNodeID > & GetFullPVPath() const

Referenced by G4OpenGLStoredQtSceneHandler::ExtraPOProcessing().

◆ clearTreeWidget()

void G4OpenGLQtViewer::clearTreeWidget ( )

Definition at line 3870 of file G4OpenGLQtViewer.cc.

3870 {
3871 // be careful about calling this twice
3872
3873 if (fSceneTreeComponentTreeWidget) {
3874
3875 if (fSceneTreeComponentTreeWidget->topLevelItemCount () > 0) {
3876
3877 fPVRootNodeCreate = false;
3878
3879 // reset all old
3880 fOldPositivePoIndexSceneTreeWidgetQuickMap.clear();
3881 fOldNullPoIndexSceneTreeWidgetQuickVector.clear();
3882 fOldTreeItemModels.clear();
3883
3884 // Clone everything
3885 for (int b =0; b <fSceneTreeComponentTreeWidget->topLevelItemCount();b++) {
3886 // All tree widgets are in :
3887 // then we could get the old POindex and get
3888 // .visible/Hidden
3889 // .Check/Uncheck
3890 // .selected
3891 // .colour status from std::map
3892
3893 // clone top level items
3894 int poIndex = fSceneTreeComponentTreeWidget->topLevelItem(b)->data(0,Qt::UserRole).toInt();
3895 if (poIndex != -1) {
3896 fOldPositivePoIndexSceneTreeWidgetQuickMap.insert(std::pair <int, QTreeWidgetItem*> (poIndex,cloneWidgetItem(fSceneTreeComponentTreeWidget->topLevelItem(b))));
3897 } else {
3898 fOldNullPoIndexSceneTreeWidgetQuickVector.push_back(cloneWidgetItem(fSceneTreeComponentTreeWidget->topLevelItem(b)));
3899 }
3900
3901 // clone leaves
3902 cloneSceneTree(fSceneTreeComponentTreeWidget->topLevelItem(b));
3903 }
3904 // delete all elements
3905
3906 fOldTreeItemModels.insert(fTreeItemModels.begin(), fTreeItemModels.end());
3907
3908 // all is copy, then clear scene tree
3909 int tmp2 = fSceneTreeComponentTreeWidget->topLevelItemCount();
3910 while (tmp2 > 0) {
3911 delete fSceneTreeComponentTreeWidget->takeTopLevelItem (0);
3912 tmp2 = fSceneTreeComponentTreeWidget->topLevelItemCount();
3913 }
3914 fPositivePoIndexSceneTreeWidgetQuickMap.clear();
3915
3916 // put correct value in paramaters
3917 fOldLastSceneTreeWidgetAskForIterator = fOldPositivePoIndexSceneTreeWidgetQuickMap.begin();
3918 fOldLastSceneTreeWidgetAskForIteratorEnd = fOldPositivePoIndexSceneTreeWidgetQuickMap.end();
3919 fSceneTreeDepth = 1;
3920 fModelShortNameItem = NULL;
3921 fMaxPOindexInserted = -1;
3922
3923 }
3924 }
3925}

Referenced by G4OpenGLStoredQtSceneHandler::SetScene().

◆ CreateGLQtContext()

void G4OpenGLQtViewer::CreateGLQtContext ( )
protected

◆ CreateMainWindow()

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

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

Definition at line 105 of file G4OpenGLQtViewer.cc.

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

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

◆ displayRecordingStatus()

void G4OpenGLQtViewer::displayRecordingStatus ( )

Definition at line 1802 of file G4OpenGLQtViewer.cc.

1802 {
1803
1804 QString txtStatus = "";
1805 if (fRecordingStep == WAIT) {
1806 txtStatus = "Waiting to start...";
1807 fRecordFrameNumber = 0; // reset the frame number
1808 } else if (fRecordingStep == START) {
1809 txtStatus = "Start Recording...";
1810 } else if (fRecordingStep == PAUSE) {
1811 txtStatus = "Pause Recording...";
1812 } else if (fRecordingStep == CONTINUE) {
1813 txtStatus = "Continue Recording...";
1814 } else if (fRecordingStep == STOP) {
1815 txtStatus = "Stop Recording...";
1816 } else if (fRecordingStep == READY_TO_ENCODE) {
1817 txtStatus = "Ready to Encode...";
1818 } else if (fRecordingStep == ENCODING) {
1819 txtStatus = "Encoding...";
1820 } else if (fRecordingStep == FAILED) {
1821 txtStatus = "Failed to encode...";
1822 } else if ((fRecordingStep == BAD_ENCODER)
1823 || (fRecordingStep == BAD_OUTPUT)
1824 || (fRecordingStep == BAD_TMP)) {
1825 txtStatus = "Correct above errors first";
1826 } else if (fRecordingStep == SUCCESS) {
1827 txtStatus = "File encoded successfully";
1828 } else {
1829 }
1830
1831 if (fMovieParametersDialog) {
1832 fMovieParametersDialog->setRecordingStatus(txtStatus);
1833 } else {
1834 G4cout << txtStatus.toStdString().c_str() << G4endl;
1835 }
1836 setRecordingInfos("");
1837}

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 4100 of file G4OpenGLQtViewer.cc.

4100 {
4101 // no UI
4102 if (fUISceneTreeWidget == NULL) {
4103 return;
4104 }
4105 if (fSceneTreeComponentTreeWidget == NULL) {
4106 return;
4107 }
4108
4109 // sort tree items
4110 fSceneTreeComponentTreeWidget->sortItems (0, Qt::AscendingOrder );
4111
4112 return;
4113}

◆ DrawText()

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

Reimplemented from G4OpenGLViewer.

Definition at line 2812 of file G4OpenGLQtViewer.cc.

2813{
2814 auto* qGLW = dynamic_cast<G4QGLWidgetType*> (fGLWidget) ;
2815 if (! qGLW) {
2816 return;
2817 }
2818 if (isGl2psWriting()) {
2819
2821
2822 } else {
2823
2824 if (!fGLWidget) return;
2825
2826 if (!G4Threading::IsMasterThread()) return;
2827
2829 G4double size = fSceneHandler.GetMarkerSize(g4text,sizeType);
2830
2831 QFont font = QFont();
2832 font.setPointSizeF(size);
2833
2834 const G4Colour& c = fSceneHandler.GetTextColour(g4text);
2835
2836 G4Point3D position = g4text.GetPosition();
2837
2838 const G4String& textString = g4text.GetText();
2839 const char* textCString = textString.c_str();
2840
2841 // Calculate move for centre and right adjustment
2842 QFontMetrics f(font);
2843 G4double span = f.boundingRect(textCString).width();
2844
2845 G4double xmove = 0.;
2846 G4double ymove = 0.;
2847
2848 switch (g4text.GetLayout()) {
2849 case G4Text::left: break;
2850 case G4Text::centre: xmove -= span / 2.; break;
2851 case G4Text::right: xmove -= span;
2852 }
2853
2854 //Add offsets
2855 xmove += g4text.GetXOffset();
2856 ymove += g4text.GetYOffset();
2857
2858#if QT_VERSION < 0x060000
2859 glColor4d(c.GetRed(),c.GetGreen(),c.GetBlue(),c.GetAlpha());
2860 glRasterPos3d(position.x(),position.y(),position.z());
2861 // xmove, ymove in pixels - or are they?
2862#ifdef __APPLE__
2863 const G4double fudgeFactor = 2.;
2864#else
2865 const G4double fudgeFactor = 1.;
2866#endif
2867 xmove *= fudgeFactor;
2868 ymove *= fudgeFactor;
2869 qGLW->renderText
2870 ((position.x()+(2*xmove)/getWinWidth()),
2871 (position.y()+(2*ymove)/getWinHeight()),
2872 position.z(),
2873 textCString,
2874 font);
2875#else
2876 QColor color((int)(c.GetRed()*255),
2877 (int)(c.GetGreen()*255),
2878 (int)(c.GetBlue()*255),
2879 (int)(c.GetAlpha()*255));
2880 render_text(*qGLW,
2881 position.x(),position.y(),position.z(),
2882 xmove,ymove,
2883 font,color,textCString);
2884#endif
2885 }
2886}
QOpenGLWidget G4QGLWidgetType
HepGeom::Point3D< G4double > G4Point3D
Definition G4Point3D.hh:34
double G4double
Definition G4Types.hh:83
G4double GetBlue() const
Definition G4Colour.hh:172
G4double GetAlpha() const
Definition G4Colour.hh:173
G4double GetRed() const
Definition G4Colour.hh:170
G4double GetGreen() const
Definition G4Colour.hh:171
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
G4bool IsMasterThread()

◆ encodeVideo()

void G4OpenGLQtViewer::encodeVideo ( )

Definition at line 2331 of file G4OpenGLQtViewer.cc.

2332{
2333 if ((getEncoderPath() != "") && (getSaveFileName() != "")) {
2334 setRecordingStatus(ENCODING);
2335
2336 fProcess = new QProcess();
2337 QObject ::connect(fProcess,SIGNAL(finished ( int,QProcess::ExitStatus)),
2338 this,SLOT(processEncodeFinished()));
2339 QObject ::connect(fProcess,SIGNAL(readyReadStandardOutput ()),
2340 this,SLOT(processEncodeStdout()));
2341#if (QT_VERSION < QT_VERSION_CHECK(5, 10, 0))
2342 fProcess->setReadChannelMode(QProcess::MergedChannels);
2343#else
2344 fProcess->setProcessChannelMode(QProcess::MergedChannels);
2345#endif
2346 fProcess->start (fEncoderPath, QStringList(fMovieTempFolderPath+fParameterFileName));
2347 }
2348}

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 2137 of file G4OpenGLQtViewer.cc.

2137 {
2138
2139 auto* qGLW = dynamic_cast<G4QGLWidgetType*> (fGLWidget) ;
2140 if (! qGLW) {
2141 return false;
2142 }
2143 // If there is already an extention
2144 bool increaseFileNumber = true;
2145 // if
2146 if (name.size() != name.substr(name.find_last_of(".") + 1).size()) {
2147 increaseFileNumber = false;
2148 }
2149 if (! setExportFilename(name,increaseFileNumber)) {
2150 return false;
2151 }
2152 if ((width !=-1) && (height != -1)) {
2153 setExportSize(width, height);
2154 }
2155 // first, try to do it with generic function
2156 if (G4OpenGLViewer::exportImage(name, width, height)) {
2157 return true;
2158
2159 // Then try Qt saving functions
2160 } else {
2161 QImage image;
2162#if (QT_VERSION < QT_VERSION_CHECK(6, 0, 0))
2163 image = qGLW->grabFrameBuffer();
2164#else
2165 image = qGLW->grabFramebuffer();
2166#endif
2167
2168 bool res = image.save(QString(getRealPrintFilename().c_str()),0,fLastExportSliderValue);
2169
2170 if (!res) {
2171 G4cerr << "Error saving file... " << getRealPrintFilename().c_str() << G4endl;
2172 return false;
2173 } else {
2174 G4cout << "File " << getRealPrintFilename().c_str() << " size: " << fGLWidget->width() << "x" << fGLWidget->height() << " has been saved " << G4endl;
2176 }
2177 }
2178 return true;
2179}
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 1190 of file G4OpenGLQtViewer.cc.

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

◆ G4keyPressEvent()

void G4OpenGLQtViewer::G4keyPressEvent ( QKeyEvent * event)

Definition at line 1565 of file G4OpenGLQtViewer.cc.

1566{
1567 if (fHoldKeyEvent)
1568 return;
1569
1570 fHoldKeyEvent = true;
1571
1572
1573 // with no modifiers
1574 updateKeyModifierState(evnt->modifiers());
1575 if ((fNoKeyPress) || (evnt->modifiers() == Qt::KeypadModifier )) {
1576 if (evnt->key() == Qt::Key_Down) { // go down
1577 moveScene(0,1,0,false);
1578 }
1579 else if (evnt->key() == Qt::Key_Up) { // go up
1580 moveScene(0,-1,0,false);
1581 }
1582 if (evnt->key() == Qt::Key_Left) { // go left
1583 moveScene(-1,0,0,false);
1584 }
1585 else if (evnt->key() == Qt::Key_Right) { // go right
1586 moveScene(1,0,0,false);
1587 }
1588 if (evnt->key() == Qt::Key_Minus) { // go backward
1589 moveScene(0,0,1,false);
1590 }
1591 else if (evnt->key() == Qt::Key_Plus) { // go forward
1592 moveScene(0,0,-1,false);
1593 }
1594 // escaped from full screen
1595 if (evnt->key() == Qt::Key_Escape) {
1596 toggleFullScreen(false);
1597 }
1598 }
1599 // several case here : If return is pressed, in every case -> display the movie parameters dialog
1600 // If one parameter is wrong -> put it in red (only save filenam could be wrong..)
1601 // If encoder not found-> does nothing.Only display a message in status box
1602 // If all ok-> generate parameter file
1603 // If ok -> put encoder button enabled
1604
1605 if ((evnt->key() == Qt::Key_Return) || (evnt->key() == Qt::Key_Enter)){ // end of video
1606 stopVideo();
1607 }
1608 if (evnt->key() == Qt::Key_Space){ // start/pause of video
1610 }
1611
1612 // H : Return Home view
1613 if (evnt->key() == Qt::Key_H){ // go Home
1614 ResetView();
1615
1616 updateQWidget();
1617 }
1618
1619 // Shift Modifier
1620 if (fShiftKeyPress) {
1621 fGLWidget->setCursor(QCursor(Qt::SizeAllCursor));
1622
1623 if (evnt->key() == Qt::Key_Down) { // rotate phi
1625 }
1626 else if (evnt->key() == Qt::Key_Up) { // rotate phi
1628 }
1629 if (evnt->key() == Qt::Key_Left) { // rotate theta
1631 }
1632 else if (evnt->key() == Qt::Key_Right) { // rotate theta
1634 }
1635 if (evnt->key() == Qt::Key_Plus) { // go forward ("Plus" imply
1636 // "Shift" on Mac French keyboard
1637 moveScene(0,0,-1,false);
1638 }
1639
1640 // Alt Modifier
1641 }
1642 if ((fAltKeyPress)) {
1643 fGLWidget->setCursor(QCursor(Qt::ClosedHandCursor));
1644
1645 if (evnt->key() == Qt::Key_Down) { // rotate phi
1647 }
1648 else if (evnt->key() == Qt::Key_Up) { // rotate phi
1650 }
1651 if (evnt->key() == Qt::Key_Left) { // rotate theta
1653 }
1654 else if (evnt->key() == Qt::Key_Right) { // rotate theta
1656 }
1657
1658 // Rotatio +/-
1659 if (evnt->key() == Qt::Key_Plus) {
1660 fRot_sens = fRot_sens/0.7;
1661 G4cout << "Auto-rotation set to : " << fRot_sens << G4endl;
1662 }
1663 else if (evnt->key() == Qt::Key_Minus) {
1664 fRot_sens = fRot_sens*0.7;
1665 G4cout << "Auto-rotation set to : " << fRot_sens << G4endl;
1666 }
1667
1668 // Control Modifier OR Command on MAC
1669 }
1670 if ((fControlKeyPress)) {
1671 if (evnt->key() == Qt::Key_Plus) {
1672 fVP.SetZoomFactor(fVP.GetZoomFactor()*(1+fDeltaZoom));
1673 updateQWidget();
1674 }
1675 else if (evnt->key() == Qt::Key_Minus) {
1676 fVP.SetZoomFactor(fVP.GetZoomFactor()*(1-fDeltaZoom));
1677 updateQWidget();
1678 }
1679 }
1680
1681 fHoldKeyEvent = false;
1682}
void rotateQtSceneToggle(float, float)
void moveScene(float, float, float, bool)
void rotateQtScene(float, float)
void updateKeyModifierState(const Qt::KeyboardModifiers &)
virtual void updateQWidget()=0

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

◆ G4keyReleaseEvent()

void G4OpenGLQtViewer::G4keyReleaseEvent ( QKeyEvent * event)

Definition at line 1685 of file G4OpenGLQtViewer.cc.

1686{
1687 fGLWidget->setCursor(QCursor(Qt::ArrowCursor));
1688}

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

◆ G4manageContextMenuEvent()

void G4OpenGLQtViewer::G4manageContextMenuEvent ( QContextMenuEvent * e)
protected

Definition at line 695 of file G4OpenGLQtViewer.cc.

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

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

◆ G4MouseDoubleClickEvent()

void G4OpenGLQtViewer::G4MouseDoubleClickEvent ( )

Definition at line 1365 of file G4OpenGLQtViewer.cc.

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

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 1378 of file G4OpenGLQtViewer.cc.

1379{
1380
1381 Qt::MouseButtons mButtons = evnt->buttons();
1382
1383 updateKeyModifierState(evnt->modifiers());
1384
1385 if (fAutoMove) {
1386 return;
1387 }
1388
1389 fLastPos3 = fLastPos2;
1390 fLastPos2 = fLastPos1;
1391
1392#if (QT_VERSION < QT_VERSION_CHECK(6, 0, 0))
1393 fLastPos1 = QPoint(evnt->x(), evnt->y());
1394#else
1395 fLastPos1 = QPoint(evnt->position().x(), evnt->position().y());
1396#endif
1397
1398 int deltaX = fLastPos2.x()-fLastPos1.x();
1399 int deltaY = fLastPos2.y()-fLastPos1.y();
1400
1401 bool move = false;
1402 if (fUiQt != NULL) {
1403 if (fUiQt->IsIconMoveSelected()) { // move
1404 move = true;
1405 }
1406 }
1407 if (!move) { // rotate, pick, zoom...
1408 if (mButtons & Qt::LeftButton) {
1409 if (fNoKeyPress) {
1410 rotateQtScene(((float)deltaX),((float)deltaY));
1411 } else if (fAltKeyPress) {
1412 rotateQtSceneToggle(((float)deltaX),((float)deltaY));
1413 } else if (fShiftKeyPress) {
1414 moveScene(-(float)deltaX, -(float)deltaY, 0, true);
1415 } else if (fControlKeyPress) {
1416 fVP.SetZoomFactor(fVP.GetZoomFactor()*(1+((float)deltaY)));
1417 }
1418 }
1419 } else if (move) { // move
1420 if (mButtons & Qt::LeftButton) {
1421 moveScene(-(float)deltaX,-(float)deltaY,0,true);
1422 }
1423 }
1424
1425 fLastEventTime->start();
1426}

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 1206 of file G4OpenGLQtViewer.cc.

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

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

◆ G4MouseReleaseEvent()

void G4OpenGLQtViewer::G4MouseReleaseEvent ( QMouseEvent * evnt)

Definition at line 1262 of file G4OpenGLQtViewer.cc.

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

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

◆ G4wheelEvent()

void G4OpenGLQtViewer::G4wheelEvent ( QWheelEvent * event)

Definition at line 1551 of file G4OpenGLQtViewer.cc.

1552{
1553#if (QT_VERSION < QT_VERSION_CHECK(5, 15, 0))
1554 double delta = evnt->delta();
1555#else
1556 double delta = evnt->angleDelta().y();
1557#endif
1558
1559 ZoomFromMouseWheel(delta, evnt->modifiers() & Qt::ShiftModifier, evnt->position().x(), evnt->position().y());
1560
1561 updateQWidget();
1562}
void ZoomFromMouseWheel(G4double delta, G4bool shift=false, G4double xPos=0, G4double yPos=0)
Definition G4VViewer.cc:144

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

◆ generateMpegEncoderParameters()

bool G4OpenGLQtViewer::generateMpegEncoderParameters ( )

Definition at line 2181 of file G4OpenGLQtViewer.cc.

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

Referenced by saveVideo().

◆ getColorForPoIndex()

G4Colour G4OpenGLQtViewer::getColorForPoIndex ( int poIndex)
protected

Definition at line 3674 of file G4OpenGLQtViewer.cc.

3674 {
3675 // FIXME 09/2014 : Could be optimize by searching in a tab instead of item->data
3676 QTreeWidgetItem* item = getTreeWidgetItem(poIndex);
3677
3678 if (item != NULL) {
3679
3680 const QColor& color = item->data(2,Qt::UserRole).value<QColor>();
3681 G4Colour g4c(((G4double)color.red())/255,
3682 ((G4double)color.green())/255,
3683 ((G4double)color.blue())/255,
3684 ((G4double)color.alpha())/255);
3685
3686 return g4c;
3687 }
3688 return G4Colour();
3689}

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

◆ getEncoderPath()

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

Definition at line 1868 of file G4OpenGLQtViewer.cc.

1868 {
1869 return fEncoderPath;
1870}

Referenced by encodeVideo().

◆ GetPrivateVisAttributesModifiers()

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

Reimplemented from G4VViewer.

Definition at line 3693 of file G4OpenGLQtViewer.cc.

3694{
3695 static std::vector<G4ModelingParameters::VisAttributesModifier>
3696 privateVisAttributesModifiers;
3697
3698 privateVisAttributesModifiers.clear();
3699
3700// I don't think we need this. (JA Sep 2016).
3701// // For each modified touchable...
3702// std::map<int,PVPath>::const_iterator i;
3703// for (i = fTreeItemModels.begin();
3704// i != fTreeItemModels.end();
3705// ++i) {
3706//
3707// // How do I know if it's been modified or not?
3708//
3709// int iPO = i->first;
3710// const PVPath& fullPath = i->second;
3711//
3712// // If a physical volume
3713// if (fullPath.size()) {
3714//
3715// // const G4bool& visibilityChanged = ???
3716// // const G4bool& visibility = ???
3717// // const G4bool& colourChanged = ???
3718// // const QColor& colour = ???
3719// // G4Colour g4colour(((G4double)colour.red())/255,
3720// // ((G4double)colour.green())/255,
3721// // ((G4double)colour.blue())/255,
3722// // ((G4double)colour.alpha())/255);
3723// // Next 4 lines are for testing, to be replaced by the above...
3724// G4bool visibilityChanged = true;
3725// G4bool visibility = true;
3726// G4bool colourChanged = true;
3727// G4Colour g4colour(G4Colour::Red());
3728//
3729// // Instantiate a working copy of a G4VisAttributes object...
3730// G4VisAttributes workingVisAtts;
3731// // ...and use it to create vis attribute modifiers...
3732// if (visibilityChanged) {
3733// workingVisAtts.SetVisibility(visibility);
3734// privateVisAttributesModifiers.push_back
3735// (G4ModelingParameters::VisAttributesModifier
3736// (workingVisAtts,
3737// G4ModelingParameters::VASVisibility,
3738// fullPath));
3739// }
3740// if (colourChanged) {
3741// workingVisAtts.SetColour(g4colour);
3742// privateVisAttributesModifiers.push_back
3743// (G4ModelingParameters::VisAttributesModifier
3744// (workingVisAtts,
3745// G4ModelingParameters::VASColour,
3746// fullPath));
3747// }
3748// }
3749// }
3750
3751 return &privateVisAttributesModifiers;
3752}

◆ GetRenderAreaSize()

G4bool G4OpenGLQtViewer::GetRenderAreaSize ( unsigned int & a_w,
unsigned int & a_h )

Definition at line 1519 of file G4OpenGLQtViewer.cc.

1520{
1521 a_w = fWinSize_x;
1522 a_h = fWinSize_y;
1523 return true;
1524}

◆ getSaveFileName()

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

Definition at line 2064 of file G4OpenGLQtViewer.cc.

2064 {
2065 return fSaveFileName ;
2066}

Referenced by encodeVideo(), and generateMpegEncoderParameters().

◆ getTempFolderPath()

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

Definition at line 2030 of file G4OpenGLQtViewer.cc.

2030 {
2031 return fTempFolderPath;
2032}

Referenced by startPauseVideo().

◆ GetWindowSize()

G4bool G4OpenGLQtViewer::GetWindowSize ( unsigned int & a_w,
unsigned int & a_h )
virtual

Reimplemented from G4VViewer.

Definition at line 1512 of file G4OpenGLQtViewer.cc.

1513{
1514 a_w = fWinSize_x / fGLWidget->devicePixelRatio();
1515 a_h = fWinSize_y / fGLWidget->devicePixelRatio();
1516 return true;
1517}

◆ isBadEncoder()

bool G4OpenGLQtViewer::isBadEncoder ( )

Definition at line 1951 of file G4OpenGLQtViewer.cc.

1951 {
1952 if (fRecordingStep == BAD_ENCODER) {
1953 return true;
1954 }
1955 return false;
1956}

◆ isBadOutput()

bool G4OpenGLQtViewer::isBadOutput ( )

Definition at line 1963 of file G4OpenGLQtViewer.cc.

1963 {
1964 if (fRecordingStep == BAD_OUTPUT) {
1965 return true;
1966 }
1967 return false;
1968}

◆ isBadTmp()

bool G4OpenGLQtViewer::isBadTmp ( )

Definition at line 1957 of file G4OpenGLQtViewer.cc.

1957 {
1958 if (fRecordingStep == BAD_TMP) {
1959 return true;
1960 }
1961 return false;
1962}

◆ isCurrentWidget()

bool G4OpenGLQtViewer::isCurrentWidget ( )
protected

Definition at line 4738 of file G4OpenGLQtViewer.cc.

4738 {
4739 G4Qt* interactorManager = G4Qt::getInstance ();
4740 if (!interactorManager->IsExternalApp()) {
4741
4742 // Prevent from repainting a hidden tab (the current tab name has to be the one of th GL viewer)
4743 if ( GetName() != fUiQt->GetViewerTabWidget()->tabText(fUiQt->GetViewerTabWidget()->currentIndex()).toStdString().c_str()) {
4744 return false;
4745 }
4746 }
4747 return true;
4748}
const G4String & GetName() const

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

◆ isEncoding()

bool G4OpenGLQtViewer::isEncoding ( )

Definition at line 1916 of file G4OpenGLQtViewer.cc.

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

◆ isFailed()

bool G4OpenGLQtViewer::isFailed ( )

Definition at line 1937 of file G4OpenGLQtViewer.cc.

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

◆ isPaused()

bool G4OpenGLQtViewer::isPaused ( )

Definition at line 1909 of file G4OpenGLQtViewer.cc.

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

◆ isReadyToEncode()

bool G4OpenGLQtViewer::isReadyToEncode ( )

Definition at line 1989 of file G4OpenGLQtViewer.cc.

1989 {
1990 if (fRecordingStep == READY_TO_ENCODE) {
1991 return true;
1992 }
1993 return false;
1994}

◆ isRecording()

bool G4OpenGLQtViewer::isRecording ( )

Definition at line 1902 of file G4OpenGLQtViewer.cc.

1902 {
1903 if ((fRecordingStep == START) || (fRecordingStep == CONTINUE)) {
1904 return true;
1905 }
1906 return false;
1907}

◆ isStopped()

bool G4OpenGLQtViewer::isStopped ( )

Definition at line 1930 of file G4OpenGLQtViewer.cc.

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

◆ isSuccess()

bool G4OpenGLQtViewer::isSuccess ( )

Definition at line 1944 of file G4OpenGLQtViewer.cc.

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

◆ isTouchableVisible()

bool G4OpenGLQtViewer::isTouchableVisible ( int POindex)

Definition at line 3475 of file G4OpenGLQtViewer.cc.

3475 {
3476
3477 // If no scene tree (Immediate viewer)
3478 if (fSceneTreeComponentTreeWidget == NULL) {
3479 return false;
3480 }
3481
3482 // should be the next one
3483 // Prevent to get out the std::map
3484 if (fLastSceneTreeWidgetAskForIterator != fLastSceneTreeWidgetAskForIteratorEnd) {
3485 fLastSceneTreeWidgetAskForIterator++;
3486 }
3487 QTreeWidgetItem* item = getTreeWidgetItem(POindex);
3488
3489 if (item != NULL) {
3490 if ( item->checkState(0) == Qt::Checked) {
3491 return true;
3492 }
3493 }
3494 return false;
3495}

Referenced by G4OpenGLStoredQtViewer::POSelected().

◆ isWaiting()

bool G4OpenGLQtViewer::isWaiting ( )

Definition at line 1923 of file G4OpenGLQtViewer.cc.

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

◆ 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 1436 of file G4OpenGLQtViewer.cc.

1437{
1438 if (fHoldMoveEvent)
1439 return;
1440 fHoldMoveEvent = true;
1441
1442 G4double coefTrans = 0;
1443 GLdouble coefDepth = 0;
1444 if(mouseMove) {
1445 if (fVP.GetFieldHalfAngle() == 0.0) {
1446 // Orthographic projection
1447 coefTrans = ((G4double)GetSceneNearWidth()) / ((G4double)getWinWidth());
1448 if (getWinHeight() < getWinWidth()) {
1449 coefTrans = ((G4double)GetSceneNearWidth()) / ((G4double)getWinHeight());
1450 }
1451 } else {
1452 // Perspective projection
1453 G4double radius = fSceneHandler.GetScene()->GetExtent().GetExtentRadius();
1454 if (radius <= 0.) radius = 1.;
1455 const G4double cameraDistance = fVP.GetCameraDistance(radius);
1456 coefTrans = cameraDistance * std::tan(fVP.GetFieldHalfAngle()) / ((G4double)getWinWidth());
1457 if (getWinHeight() < getWinWidth()) {
1458 coefTrans = cameraDistance * std::tan(fVP.GetFieldHalfAngle()) / ((G4double)getWinHeight());
1459 }
1460 }
1461 } else {
1462 coefTrans = GetSceneNearWidth()*fPan_sens;
1463 coefDepth = getSceneDepth()*fDeltaDepth;
1464 }
1465 fVP.IncrementPan(-dx*coefTrans,dy*coefTrans,dz*coefDepth);
1466
1467 updateQWidget();
1468 if (fAutoMove)
1469 ((QApplication*)G4Qt::getInstance ())->processEvents();
1470
1471 fHoldMoveEvent = false;
1472}
GLdouble getSceneDepth()

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

◆ ReadyToDraw()

G4bool G4OpenGLQtViewer::ReadyToDraw ( )
virtual

Reimplemented from G4VViewer.

Definition at line 520 of file G4OpenGLQtViewer.cc.

520 {
521#if QT_VERSION < 0x060000
522 return true;
523#else
524 if(!fGLWidget) return false;
525 auto* qGLW = dynamic_cast<G4QGLWidgetType*>(fGLWidget);
526 if (!qGLW) return false;
527 return qGLW->isValid();
528#endif
529}

◆ resetRecording()

void G4OpenGLQtViewer::resetRecording ( )

Definition at line 1996 of file G4OpenGLQtViewer.cc.

1996 {
1997 setRecordingStatus(WAIT);
1998}

Referenced by savePPMToTemp(), and stopVideo().

◆ ResetView()

void G4OpenGLQtViewer::ResetView ( )
virtual

Reimplemented from G4OpenGLViewer.

Definition at line 2889 of file G4OpenGLQtViewer.cc.

2889 {
2891 fDeltaDepth = 0.01;
2892 fDeltaZoom = 0.05;
2893}
virtual void ResetView()

Referenced by G4keyPressEvent().

◆ rotateQtScene()

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

Definition at line 1480 of file G4OpenGLQtViewer.cc.

1481{
1482 if (fHoldRotateEvent)
1483 return;
1484 fHoldRotateEvent = true;
1485
1486 rotateScene(dx,dy);
1487
1488 updateQWidget();
1489
1490 fHoldRotateEvent = false;
1491}
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 1498 of file G4OpenGLQtViewer.cc.

1499{
1500 if (fHoldRotateEvent)
1501 return;
1502 fHoldRotateEvent = true;
1503
1504 rotateSceneToggle(dx,dy);
1505
1506 updateQWidget();
1507
1508 fHoldRotateEvent = false;
1509}
void rotateSceneToggle(G4double dx, G4double dy)

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

◆ savePPMToTemp()

void G4OpenGLQtViewer::savePPMToTemp ( )
protected

Definition at line 1004 of file G4OpenGLQtViewer.cc.

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

◆ saveVideo()

void G4OpenGLQtViewer::saveVideo ( )

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

Definition at line 1739 of file G4OpenGLQtViewer.cc.

1739 {
1740
1741 // if encoder parameter is wrong, display parameters dialog and return
1742 if (!fMovieParametersDialog) {
1743 showMovieParametersDialog();
1744 }
1745
1746 fMovieParametersDialog->checkEncoderSwParameters();
1747 fMovieParametersDialog->checkSaveFileNameParameters();
1748
1749 if (fRecordingStep == STOP) {
1750 setRecordingStatus(SAVE);
1752 encodeVideo();
1753 }
1754}

◆ setBadEncoder()

void G4OpenGLQtViewer::setBadEncoder ( )

Definition at line 1970 of file G4OpenGLQtViewer.cc.

1970 {
1971 fRecordingStep = BAD_ENCODER;
1973}

◆ setBadOutput()

void G4OpenGLQtViewer::setBadOutput ( )

Definition at line 1978 of file G4OpenGLQtViewer.cc.

1978 {
1979 fRecordingStep = BAD_OUTPUT;
1981}

◆ setBadTmp()

void G4OpenGLQtViewer::setBadTmp ( )

Definition at line 1974 of file G4OpenGLQtViewer.cc.

1974 {
1975 fRecordingStep = BAD_TMP;
1977}

◆ setEncoderPath()

QString G4OpenGLQtViewer::setEncoderPath ( QString path)

set the new encoder path

Returns
"" if correct. The error otherwise

Definition at line 1877 of file G4OpenGLQtViewer.cc.

1877 {
1878 if (path == "") {
1879 return "ppmtompeg is needed to encode in video format. It is available here: http://netpbm.sourceforge.net ";
1880 }
1881
1882 path = QDir::cleanPath(path);
1883 QFileInfo *f = new QFileInfo(path);
1884 if (!f->exists()) {
1885 return "File does not exist";
1886 } else if (f->isDir()) {
1887 return "This is a directory";
1888 } else if (!f->isExecutable()) {
1889 return "File exist but is not executable";
1890 } else if (!f->isFile()) {
1891 return "This is not a file";
1892 }
1893 fEncoderPath = path;
1894
1895 if (fRecordingStep == BAD_ENCODER) {
1896 setRecordingStatus(STOP);
1897 }
1898 return "";
1899}

◆ setSaveFileName()

QString G4OpenGLQtViewer::setSaveFileName ( QString path)

set the save file name path

Returns
"" if correct. The error otherwise

Definition at line 2038 of file G4OpenGLQtViewer.cc.

2038 {
2039
2040 if (path == "") {
2041 return "Path does not exist";
2042 }
2043
2044 QFileInfo *file = new QFileInfo(path);
2045 QDir dir = file->dir();
2046 path = QDir::cleanPath(path);
2047 if (file->exists()) {
2048 return "File already exist, please choose a new one";
2049 } else if (!dir.exists()) {
2050 return "Dir does not exist";
2051 } else if (!dir.isReadable()) {
2052 return path +" is read protected";
2053 }
2054
2055 if (fRecordingStep == BAD_OUTPUT) {
2056 setRecordingStatus(STOP);
2057 }
2058 fSaveFileName = path;
2059 return "";
2060}

◆ setTempFolderPath()

QString G4OpenGLQtViewer::setTempFolderPath ( QString path)

set the temp folder path

Returns
"" if correct. The error otherwise

Definition at line 2004 of file G4OpenGLQtViewer.cc.

2004 {
2005
2006 if (path == "") {
2007 return "Path does not exist";
2008 }
2009 path = QDir::cleanPath(path);
2010 QFileInfo *d = new QFileInfo(path);
2011 if (!d->exists()) {
2012 return "Path does not exist";
2013 } else if (!d->isDir()) {
2014 return "This is not a directory";
2015 } else if (!d->isReadable()) {
2016 return path +" is read protected";
2017 } else if (!d->isWritable()) {
2018 return path +" is write protected";
2019 }
2020
2021 if (fRecordingStep == BAD_TMP) {
2022 setRecordingStatus(WAIT);
2023 }
2024 fTempFolderPath = path;
2025 return "";
2026}

◆ setWaiting()

void G4OpenGLQtViewer::setWaiting ( )

Definition at line 1983 of file G4OpenGLQtViewer.cc.

1983 {
1984 fRecordingStep = WAIT;
1986}

◆ startPauseVideo

void G4OpenGLQtViewer::startPauseVideo ( )
slot

Start/Pause the video..

Definition at line 1759 of file G4OpenGLQtViewer.cc.

1759 {
1760
1761 // first time, if temp parameter is wrong, display parameters dialog and return
1762
1763 if ( fRecordingStep == WAIT) {
1764 if ( fRecordFrameNumber == 0) {
1765 if (getTempFolderPath() == "") { // BAD_OUTPUT
1766 showMovieParametersDialog();
1767 setRecordingInfos("You should specified the temp folder in order to make movie");
1768 return;
1769 } else {
1770 // remove temp folder if it was create
1771 QString tmp = removeTempFolder();
1772 if (tmp !="") {
1773 setRecordingInfos(tmp);
1774 return;
1775 }
1776 tmp = createTempFolder();
1777 if (tmp != "") {
1778 setRecordingInfos("Can't create temp folder."+tmp);
1779 return;
1780 }
1781 }
1782 }
1783 }
1784 if (fRecordingStep == WAIT) {
1785 setRecordingStatus(START);
1786 } else if (fRecordingStep == START) {
1787 setRecordingStatus(PAUSE);
1788 } else if (fRecordingStep == PAUSE) {
1789 setRecordingStatus(CONTINUE);
1790 } else if (fRecordingStep == CONTINUE) {
1791 setRecordingStatus(PAUSE);
1792 }
1793}

Referenced by G4keyPressEvent().

◆ stopVideo()

void G4OpenGLQtViewer::stopVideo ( )

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

Definition at line 1716 of file G4OpenGLQtViewer.cc.

1716 {
1717
1718 // if encoder parameter is wrong, display parameters dialog and return
1719 if (!fMovieParametersDialog) {
1720 showMovieParametersDialog();
1721 }
1722 setRecordingStatus(STOP);
1723
1724 if (fRecordFrameNumber >0) {
1725 // check parameters if they were modified (Re APPLY them...)
1726 if (!(fMovieParametersDialog->checkEncoderSwParameters())) {
1727 setRecordingStatus(BAD_ENCODER);
1728 } else if (!(fMovieParametersDialog->checkSaveFileNameParameters())) {
1729 setRecordingStatus(BAD_OUTPUT);
1730 }
1731 } else {
1733 setRecordingInfos("No frame to encode.");
1734 }
1735}

Referenced by G4keyPressEvent().

◆ updateKeyModifierState()

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

Definition at line 1691 of file G4OpenGLQtViewer.cc.

1691 {
1692 // Check Qt Versions for META Keys
1693
1694 fNoKeyPress = true;
1695 fAltKeyPress = false;
1696 fShiftKeyPress = false;
1697 fControlKeyPress = false;
1698
1699 if (modifier & Qt::AltModifier ) {
1700 fAltKeyPress = true;
1701 fNoKeyPress = false;
1702 }
1703 if (modifier & Qt::ShiftModifier ) {
1704 fShiftKeyPress = true;
1705 fNoKeyPress = false;
1706 }
1707 if (modifier & Qt::ControlModifier ) {
1708 fControlKeyPress = true;
1709 fNoKeyPress = false;
1710 }
1711}

Referenced by G4keyPressEvent(), and G4MouseMoveEvent().

◆ updatePickInfosWidget()

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

Update the pick infos component widget

Definition at line 4538 of file G4OpenGLQtViewer.cc.

4538 {
4539 fLastPickPoint = QPoint(aX,aY);
4540
4541 if (!isCurrentWidget()) {
4542 return;
4543 }
4544 // Ensure case where closing a UI tab close the widget
4545 if (!fPickInfosWidget) {
4546 createPickInfosWidget();
4547 }
4548
4549#if QT_VERSION < 0x060000
4550#else
4551 {auto* qGLW = dynamic_cast<G4QGLWidgetType*> (fGLWidget) ;
4552 if (qGLW) qGLW->makeCurrent();}
4553 ResizeGLView();
4554#endif
4555 const std::vector < G4OpenGLViewerPickMap* > & pickMapVector = GetPickDetails(aX,aY);
4556
4557 // remove all previous widgets
4558 if (fPickInfosWidget) {
4559 QLayoutItem * wItem;
4560 if (fPickInfosWidget->layout()->count()) {
4561 while ((wItem = fPickInfosWidget->layout()->takeAt(0)) != 0) {
4562 delete wItem->widget();
4563 delete wItem;
4564 }
4565 }
4566 } else {
4567 // Ensure case where closing a UI tab close the widget
4568 if (!fPickInfosWidget) {
4569 createPickInfosWidget();
4570 }
4571 }
4572
4573 // parse all pick results
4574 G4int nPickedObjectsWithAttributes = 0;
4575 for (unsigned int a=0; a< pickMapVector.size(); a++) {
4576 const auto& pickMap = pickMapVector[a];
4577 // Add a box inside the pick viewer box
4578 std::ostringstream label;
4579 std::ostringstream content;
4580 std::string txt = pickMap->getAttributes()[0].data();
4581 if (pickMapVector[a]->getAttributes().size()) {
4582 ++nPickedObjectsWithAttributes;
4583
4584 std::size_t pos1 = txt.find(':');
4585 std::string storeKey = txt.substr(0,pos1);
4586
4587 if (storeKey == "G4PhysicalVolumeModel") {
4588
4589 label << "Volume:";
4590 std::size_t pos2 = txt.find(':',pos1+1);
4591 std::size_t pos3 = txt.find('\n',pos2+1);
4592 label << txt.substr(pos2+1,pos3-pos2-1);
4593
4594 } else if (storeKey == "G4TrajectoriesModel") {
4595
4596 label << "Trajectory:";
4597 std::size_t pos2 = txt.find(':',pos1+1);
4598 std::size_t pos3 = txt.find('\n',pos2+1);
4599 label << " Run:" << txt.substr(pos2+1,pos3-pos2-1);
4600 std::size_t pos4 = txt.find(':',pos3+1);
4601 std::size_t pos5 = txt.find('\n',pos4+1);
4602 label << ", Event:" << txt.substr(pos4+1,pos5-pos4-1);
4603
4604 } else {
4605
4606 label << "Hit number:" << a << ", PickName: " << pickMap->getPickName();
4607
4608 }
4609
4610 // Accumulate all content with the same pickname
4611 content << pickMap->print().data();
4612 G4int thisPickName = pickMap->getPickName();
4613 while (++a < pickMapVector.size()) {
4614 const auto& a_pickMap = pickMapVector[a];
4615 if (a_pickMap->getPickName() == thisPickName) {
4616 content << a_pickMap->print().data();
4617 } else {
4618 a--;
4619 break;
4620 }
4621 }
4622
4623 QPushButton* pickCoutButton = new QPushButton(label.str().c_str());
4624 pickCoutButton->setStyleSheet ("text-align: left; padding: 1px; border: 0px;");
4625 pickCoutButton->setIcon(*fTreeIconClosed);
4626 fPickInfosWidget->layout()->addWidget(pickCoutButton);
4627
4628 QStringList newStr;
4629
4630 // Add to stringList
4631 newStr = QStringList(QString(content.str().c_str()).trimmed());
4632
4633 QTextEdit* ed = new QTextEdit();
4634 ed->setReadOnly(true);
4635 fPickInfosWidget->layout()->addWidget(ed);
4636 ed->setVisible((false));
4637 ed->append(newStr.join(""));
4638
4639 int tmp = fPickInfosWidget->layout()->count()-1;
4640 connect(pickCoutButton, &QPushButton::clicked , [this, tmp](){ this->toggleSceneTreeComponentPickingCout(tmp);});
4641
4642 }
4643 }
4644
4645 // add a label to push everything up!
4646 QLabel * pushUp = new QLabel("");
4647 QSizePolicy vPolicy = QSizePolicy(QSizePolicy::Minimum,QSizePolicy::Minimum);
4648 vPolicy.setVerticalStretch(10);
4649 pushUp->setSizePolicy(vPolicy);
4650 fPickInfosWidget->layout()->addWidget(pushUp);
4651
4652 // highlight the first one :
4653
4654 // first un-highlight the last selected
4655 changeColorAndTransparency(fLastHighlightName,fLastHighlightColor);
4656
4657 if (pickMapVector.size() > 0 ) {
4658 // get the new one
4659 fLastHighlightName = pickMapVector[0]->getPickName();
4660 fLastHighlightColor = getColorForPoIndex(fLastHighlightName);
4661 // set the new one
4662 changeColorAndTransparency(fLastHighlightName,G4Color(1,1,1,1));
4663
4664 updateQWidget();
4665 }
4666 QDialog* dial = static_cast<QDialog*> (fUIPickInfosWidget->parent());
4667 if (dial) {
4668 // change name
4669 std::ostringstream oss;
4670 if (nPickedObjectsWithAttributes == 0) {
4671 oss << "No object";
4672 } else if (nPickedObjectsWithAttributes == 1) {
4673 oss << "1 object";
4674 } else {
4675 oss << nPickedObjectsWithAttributes << " objects";
4676 }
4677 oss << " selected - " << GetName();
4678 dial->setWindowTitle(oss.str().c_str());
4679 }
4680 // set picking cout visible
4681 fPickInfosScrollArea->setVisible(true);
4682 dial->show();
4683}
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 4219 of file G4OpenGLQtViewer.cc.

4219 {
4220 // Ensure case where closing a UI tab close the widget
4221 if (!fSceneTreeWidget) {
4222 createSceneTreeWidget();
4223 }
4224}

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 4122 of file G4OpenGLQtViewer.cc.

4122 {
4123 if (fBatchMode) {
4124 return;
4125 }
4126
4128 d_style = fVP.GetDrawingStyle();
4129
4130 // Surface style
4131 if (d_style == G4ViewParameters::wireframe) {
4132 if (fUiQt) fUiQt->SetIconWireframeSelected();
4133 if (fContextMenu) {
4134 fDrawingWireframe->setChecked(true);
4135 fDrawingLineRemoval->setChecked(false);
4136 fDrawingSurfaceRemoval->setChecked(false);
4137 fDrawingLineSurfaceRemoval->setChecked(false);
4138 }
4139 } else if (d_style == G4ViewParameters::hlr) {
4140 if (fUiQt) fUiQt->SetIconHLRSelected();
4141 if (fContextMenu) {
4142 fDrawingLineRemoval->setChecked(true);
4143 fDrawingWireframe->setChecked(false);
4144 fDrawingSurfaceRemoval->setChecked(false);
4145 fDrawingLineSurfaceRemoval->setChecked(false);
4146 }
4147 } else if (d_style == G4ViewParameters::hsr) {
4148 if (fUiQt) fUiQt->SetIconSolidSelected();
4149 if (fContextMenu) {
4150 fDrawingSurfaceRemoval->setChecked(true);
4151 fDrawingWireframe->setChecked(false);
4152 fDrawingLineRemoval->setChecked(false);
4153 fDrawingLineSurfaceRemoval->setChecked(false);
4154 }
4155 } else if (d_style == G4ViewParameters::hlhsr) {
4156 if (fUiQt) fUiQt->SetIconHLHSRSelected();
4157 if (fContextMenu) {
4158 fDrawingLineSurfaceRemoval->setChecked(true);
4159 fDrawingWireframe->setChecked(false);
4160 fDrawingLineRemoval->setChecked(false);
4161 fDrawingSurfaceRemoval->setChecked(false);
4162 fDrawingLineSurfaceRemoval->setChecked(false);
4163 }
4164 }
4165
4166
4167 // projection style
4168 G4double d_proj = fVP.GetFieldHalfAngle () ;
4169 if (d_proj == 0.) { // ortho
4170 if (fUiQt) fUiQt->SetIconOrthoSelected();
4171 if (fContextMenu) {
4172 fProjectionOrtho->setChecked(true);
4173 fProjectionPerspective->setChecked(false);
4174 }
4175 } else {
4176 if (fUiQt) fUiQt->SetIconPerspectiveSelected();
4177 if (fContextMenu) {
4178 fProjectionPerspective->setChecked(true);
4179 fProjectionOrtho->setChecked(false);
4180 }
4181 }
4182
4183
4184 // mouse style : They are controlled by UI !
4185 if (fUiQt && fContextMenu) {
4186 if (fUiQt->IsIconPickSelected()) {
4187 fMousePickAction->setChecked(true);
4188 } else {
4189 fMousePickAction->setChecked(false);
4190 }
4191 if (fUiQt->IsIconZoomOutSelected()) {
4192 fMouseZoomOutAction->setChecked(true);
4193 fMouseZoomInAction->setChecked(false);
4194 fMouseRotateAction->setChecked(false);
4195 fMouseMoveAction->setChecked(false);
4196 } else if (fUiQt->IsIconZoomInSelected()) {
4197 fMouseZoomInAction->setChecked(true);
4198 fMouseZoomOutAction->setChecked(false);
4199 fMouseRotateAction->setChecked(false);
4200 fMouseMoveAction->setChecked(false);
4201 } else if (fUiQt->IsIconRotateSelected()) {
4202 fMouseRotateAction->setChecked(true);
4203 fMouseZoomOutAction->setChecked(false);
4204 fMouseZoomInAction->setChecked(false);
4205 fMouseMoveAction->setChecked(false);
4206 } else if (fUiQt->IsIconMoveSelected()) {
4207 fMouseMoveAction->setChecked(true);
4208 fMouseZoomOutAction->setChecked(false);
4209 fMouseZoomInAction->setChecked(false);
4210 fMouseRotateAction->setChecked(false);
4211 }
4212 }
4213}

Referenced by G4manageContextMenuEvent(), 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 4231 of file G4OpenGLQtViewer.cc.

4231 {
4232
4233 if (!isCurrentWidget()) {
4234 return;
4235 }
4236
4237 // Ensure case where closing a UI tab close the widget
4238 if (!fViewerPropertiesTableWidget) {
4239 createViewerPropertiesWidget();
4240 }
4241 int treeWidgetInfosIgnoredCommands = 0;
4242 G4UImanager* UI = G4UImanager::GetUIpointer();
4243 G4UIcommandTree * commandTreeTop = UI->GetTree();
4244 G4UIcommandTree* path = commandTreeTop->FindCommandTree("/vis/viewer/set/");
4245
4246 if (!path) {
4247 return;
4248 }
4249
4250 // clear old table
4251 if ((path->GetCommandEntry()-fTreeWidgetInfosIgnoredCommands) != fViewerPropertiesTableWidget->rowCount()) {
4252 fViewerPropertiesTableWidget->clear();
4253 }
4254
4255 fViewerPropertiesTableWidget->blockSignals(true);
4256 // TODO : Could be optimized by comparing current command to old commands. That should not change so much
4257
4258 fViewerPropertiesTableWidget->setColumnCount (2);
4259 fViewerPropertiesTableWidget->setRowCount (path->GetCommandEntry()-fTreeWidgetInfosIgnoredCommands);
4260 fViewerPropertiesTableWidget->setHorizontalHeaderLabels(QStringList() << tr("Property")
4261 << tr("Value"));
4262 fViewerPropertiesTableWidget->verticalHeader()->setVisible(false);
4263 fViewerPropertiesTableWidget->setAlternatingRowColors (true);
4264
4265 // For the moment, we do only command that have a "set" command in UI
4266
4267 for (int a=0;a<path->GetCommandEntry();a++) {
4268 G4UIcommand* commandTmp = path->GetCommand(a+1);
4269
4270 // get current parameters
4271 QString params = "";
4272
4273 if(commandTmp->GetCommandName() == "autoRefresh") {
4274 if (fVP.IsAutoRefresh()) {
4275 params = "True";
4276 } else {
4277 params = "False";
4278 }
4279 } else if(commandTmp->GetCommandName() == "auxiliaryEdge") {
4280 if (fVP.IsAuxEdgeVisible()) {
4281 params = "True";
4282 } else {
4283 params = "False";
4284 }
4285 } else if(commandTmp->GetCommandName() == "background") {
4286 params = QString().number(fVP.GetBackgroundColour().GetRed()) + " "+
4287 QString().number(fVP.GetBackgroundColour().GetGreen()) + " "+
4288 QString().number(fVP.GetBackgroundColour().GetBlue()) + " "+
4289 QString().number(fVP.GetBackgroundColour().GetAlpha());
4290
4291 } else if(commandTmp->GetCommandName() == "culling") {
4292 params = QString().number(fVP. IsCulling ());
4293 } else if(commandTmp->GetCommandName() == "cutawayMode") {
4294 if (fVP.GetCutawayMode() == G4ViewParameters::cutawayUnion) {
4295 params = "union";
4296 } else {
4297 params = "intersection";
4298 }
4299
4300 } else if(commandTmp->GetCommandName() == "defaultColour") {
4301 params = QString().number(fVP.GetDefaultVisAttributes()->GetColor().GetRed()) + " "+
4302 QString().number(fVP.GetDefaultVisAttributes()->GetColor().GetGreen()) + " "+
4303 QString().number(fVP.GetDefaultVisAttributes()->GetColor().GetBlue()) + " "+
4304 QString().number(fVP.GetDefaultVisAttributes()->GetColor().GetAlpha());
4305
4306 } else if(commandTmp->GetCommandName() == "defaultTextColour") {
4307 params = QString().number(fVP.GetDefaultTextVisAttributes()->GetColor().GetRed()) + " "+
4308 QString().number(fVP.GetDefaultTextVisAttributes()->GetColor().GetGreen()) + " "+
4309 QString().number(fVP.GetDefaultTextVisAttributes()->GetColor().GetBlue()) + " "+
4310 QString().number(fVP.GetDefaultTextVisAttributes()->GetColor().GetAlpha());
4311
4312 } else if(commandTmp->GetCommandName() == "edge") {
4313 G4ViewParameters::DrawingStyle existingStyle = fVP.GetDrawingStyle();
4314 params = "False";
4315 if (existingStyle == G4ViewParameters::hsr) {
4316 params = "True";
4317 }
4318
4319 } else if(commandTmp->GetCommandName() == "explodeFactor") {
4320 params = QString().number(fVP.GetExplodeFactor()) + " " + QString(G4String(G4BestUnit(fVP.GetExplodeFactor(),"Length")).data());
4321
4322 } else if(commandTmp->GetCommandName() == "globalLineWidthScale") {
4323 params = QString().number(fVP.GetGlobalLineWidthScale());
4324
4325 } else if(commandTmp->GetCommandName() == "globalMarkerScale") {
4326 params = QString().number(fVP.GetGlobalMarkerScale());
4327
4328 } else if(commandTmp->GetCommandName() == "hiddenEdge") {
4329 G4ViewParameters::DrawingStyle style = fVP.GetDrawingStyle();
4330 if ((style == G4ViewParameters::hlr) ||
4331 (style == G4ViewParameters::hlhsr)) {
4332 params = "True";
4333 } else {
4334 params = "False";
4335 }
4336
4337 } else if(commandTmp->GetCommandName() == "hiddenMarker") {
4338 if (fVP.IsMarkerNotHidden()) {
4339 params = "False";
4340 } else {
4341 params = "True";
4342 }
4343
4344 } else if(commandTmp->GetCommandName() == "lightsMove") {
4345 if (fVP.GetLightsMoveWithCamera()) {
4346 params = "camera";
4347 } else {
4348 params = "object";
4349 }
4350 } else if(commandTmp->GetCommandName() == "lightsThetaPhi") {
4351 G4Vector3D direction = fVP.GetLightpointDirection();
4352 // degree
4353 params = QString().number(direction.theta()/CLHEP::degree)+ " "+ QString().number(direction.phi()/CLHEP::degree)+" deg";
4354 if (commandTmp->GetParameterEntries() == 3) {
4355 if (commandTmp->GetParameter(2)->GetDefaultValue() != "deg") {
4356 params = QString().number(direction.theta())+ " "+ QString().number(direction.phi())+" "+commandTmp->GetParameter(2)->GetDefaultValue().data();
4357 }
4358 }
4359 } else if(commandTmp->GetCommandName() == "lightsVector") {
4360 params = QString().number(fVP.GetLightpointDirection().x()) + " "+
4361 QString().number(fVP.GetLightpointDirection().y()) + " "+
4362 QString().number(fVP.GetLightpointDirection().z());
4363
4364 } else if(commandTmp->GetCommandName() == "lineSegmentsPerCircle") {
4365 params = QString().number(fVP.GetNoOfSides());
4366
4367 } else if(commandTmp->GetCommandName() == "picking") {
4368 if (fVP.IsPicking()) {
4369 params = "True";
4370 } else {
4371 params = "False";
4372 }
4373
4374 } else if(commandTmp->GetCommandName() == "projection") {
4375 if (fVP.GetFieldHalfAngle() == 0.) {
4376 params = "orthogonal";
4377 } else {
4378 params = QString("perspective ") + QString().number(fVP.GetFieldHalfAngle()/CLHEP::degree) + " deg";
4379 }
4380
4381 } else if(commandTmp->GetCommandName() == "rotationStyle") {
4382 if (fVP.GetRotationStyle() == G4ViewParameters::constrainUpDirection) {
4383 params = "constrainUpDirection";
4384 } else {
4385 params = "freeRotation";
4386 }
4387
4388 } else if(commandTmp->GetCommandName() == "sectionPlane") {
4389 if (fVP.IsSection()) {
4390 params = QString("on ") +
4391 G4String(G4BestUnit(fVP.GetSectionPlane().point(),"Length")).data()+
4392 QString().number(fVP.GetSectionPlane().normal().x())
4393 + " " + QString().number(fVP.GetSectionPlane().normal().y())
4394 + " " + QString().number(fVP.GetSectionPlane().normal().z());
4395 } else {
4396 params = "off";
4397 }
4398
4399 } else if(commandTmp->GetCommandName() == "style") {
4400 if (fVP.GetDrawingStyle() == G4ViewParameters::wireframe || fVP.GetDrawingStyle() == G4ViewParameters::hlr) {
4401 params = "wireframe";
4402 } else {
4403 params = "surface";
4404 }
4405
4406
4407 } else if(commandTmp->GetCommandName() == "targetPoint") {
4408 G4Point3D point = fVP.GetCurrentTargetPoint();
4409 if (fSceneHandler.GetScene()) {
4410 G4String b = G4BestUnit(fSceneHandler.GetScene()->GetStandardTargetPoint() + fVP.GetCurrentTargetPoint(),"Length");
4411 params = b.data();
4412 }
4413 } else if(commandTmp->GetCommandName() == "upThetaPhi") {
4414 G4Vector3D up = fVP.GetUpVector();
4415 // degree
4416 params = QString().number(up.theta()/CLHEP::degree)+ " "+ QString().number(up.phi()/CLHEP::degree)+" deg";
4417 if (commandTmp->GetParameterEntries() == 3) {
4418 if (commandTmp->GetParameter(2)->GetDefaultValue() != "deg") {
4419 params = QString().number(up.theta())+ " "+ QString().number(up.phi())+" "+commandTmp->GetParameter(2)->GetDefaultValue().data();
4420 }
4421 }
4422 } else if(commandTmp->GetCommandName() == "upVector") {
4423 G4Vector3D up = fVP.GetUpVector();
4424 params = QString().number(up.x())+ " "+ QString().number(up.y())+" "+QString().number(up.z())+ " ";
4425
4426 } else if(commandTmp->GetCommandName() == "viewpointThetaPhi") {
4427 G4Vector3D direction = fVP.GetViewpointDirection();
4428 // degree
4429 params = QString().number(direction.theta()/CLHEP::degree)+ " "+ QString().number(direction.phi()/CLHEP::degree)+" deg";
4430 if (commandTmp->GetParameterEntries() == 3) {
4431 if (commandTmp->GetParameter(2)->GetDefaultValue() != "deg") {
4432 params = QString().number(direction.theta())+ " "+ QString().number(direction.phi())+" "+commandTmp->GetParameter(2)->GetDefaultValue().data();
4433 }
4434 }
4435 } else if(commandTmp->GetCommandName() == "viewpointVector") {
4436 G4Vector3D direction = fVP.GetViewpointDirection();
4437 params = QString().number(direction.x())+ " "+ QString().number(direction.y())+" "+QString().number(direction.z());
4438 } else {
4439 // No help
4440 }
4441
4442 /* DO NOT DISPLAY COMMANDS WITHOUT ANY PARAMETERS SET
4443 if (params == "") {
4444 // TODO : display default parameters // should not be editable ?
4445
4446 for( G4int i_thParameter=0; i_thParameter<commandTmp->GetParameterEntries(); i_thParameter++ ) {
4447 commandParam = commandTmp->GetParameter(i_thParameter);
4448
4449 if (QString(QChar(commandParam->GetParameterType())) == "b") {
4450 if (commandParam->GetDefaultValue().data()) {
4451 params += "True";
4452 } else {
4453 params += "False";
4454 }
4455 } else {
4456 params += QString((char*)(commandParam->GetDefaultValue()).data());
4457 }
4458 if (i_thParameter<commandTmp->GetParameterEntries()-1) {
4459 params += " ";
4460 }
4461 }
4462 }
4463 */
4464
4465 if (params != "") {
4466
4467 QTableWidgetItem *nameItem;
4468 QTableWidgetItem *paramItem;
4469
4470 // already present ?
4471 QList<QTableWidgetItem *> list = fViewerPropertiesTableWidget->findItems (commandTmp->GetCommandName().data(),Qt::MatchExactly);
4472 if (list.size() == 1) {
4473 nameItem = list.first();
4474 paramItem = fViewerPropertiesTableWidget->item(nameItem->row(),1);
4475
4476 } else {
4477 nameItem = new QTableWidgetItem();
4478 paramItem = new QTableWidgetItem();
4479 fViewerPropertiesTableWidget->setItem(a-treeWidgetInfosIgnoredCommands, 0, nameItem);
4480 fViewerPropertiesTableWidget->setItem(a-treeWidgetInfosIgnoredCommands, 1, paramItem);
4481
4482 // Set Guidance
4483 QString guidance;
4484 G4int n_guidanceEntry = (G4int)commandTmp->GetGuidanceEntries();
4485 for( G4int i_thGuidance=0; i_thGuidance < n_guidanceEntry; i_thGuidance++ ) {
4486 guidance += QString((char*)(commandTmp->GetGuidanceLine(i_thGuidance)).data()) + "\n";
4487 }
4488
4489 nameItem->setToolTip(guidance);
4490 paramItem->setToolTip(GetCommandParameterList(commandTmp));
4491
4492 fViewerPropertiesTableWidget->setRowHeight(a-treeWidgetInfosIgnoredCommands,15);
4493 }
4494
4495 // set current name and parameters
4496 nameItem->setText(commandTmp->GetCommandName().data());
4497 paramItem->setText(params);
4498
4499 nameItem->setFlags(Qt::NoItemFlags);
4500 nameItem->setForeground(QBrush());
4501
4502 } else {
4503 treeWidgetInfosIgnoredCommands++;
4504 }
4505 }
4506 // remove empty content row
4507 for (int i=0; i<treeWidgetInfosIgnoredCommands; i++) {
4508 fViewerPropertiesTableWidget->removeRow (fViewerPropertiesTableWidget->rowCount() - 1);
4509 }
4510
4511 // The resize should done only at creation
4512 if (!fViewerPropertiesTableWidgetIsInit) {
4513 fViewerPropertiesTableWidgetIsInit = true;
4514
4515 fViewerPropertiesTableWidget->resizeColumnsToContents();
4516
4517 int x = fViewerPropertiesTableWidget->horizontalHeader()->length();
4518 int y = fViewerPropertiesTableWidget->verticalHeader()->length()+ fViewerPropertiesTableWidget->horizontalHeader()->sizeHint().height() + 2;
4519
4520 // fViewerPropertiesTableWidget->verticalHeader()->setResizeMode(QHeaderView::ResizeToContents);
4521 // fViewerPropertiesTableWidget->horizontalHeader()->setResizeMode(QHeaderView::ResizeToContents);
4522
4523 // resize to fit content
4524 QDialog* dial = static_cast<QDialog*> (fUIViewerPropertiesWidget->parent());
4525 if (dial) {
4526 dial->resize(x+56,y+46); // more or less (margins) ...
4527 }
4528 }
4529 fViewerPropertiesTableWidget->blockSignals(false);
4530
4531 fTreeWidgetInfosIgnoredCommands = treeWidgetInfosIgnoredCommands;
4532}
#define G4BestUnit(a, b)
HepGeom::Vector3D< G4double > G4Vector3D
Definition G4Vector3D.hh:34
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

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

Member Data Documentation

◆ fGLWidget

◆ fHasToRepaint

◆ fMouseOnSceneTree

bool G4OpenGLQtViewer::fMouseOnSceneTree
protected

◆ fPaintEventLock

◆ fQGLWidgetInitialiseCompleted

◆ fRecordFrameNumber

int G4OpenGLQtViewer::fRecordFrameNumber
protected

◆ fUiQt

◆ fUpdateGLLock


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