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

#include <G4OpenGLQtViewer.hh>

+ Inheritance diagram for G4OpenGLQtViewer:

Public Slots

void startPauseVideo ()
 

Public Member Functions

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

Protected Slots

void updateToolbarAndMouseContextMenu ()
 

Protected Member Functions

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

Protected Attributes

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.
 
G4bool fNeedKernelVisit
 

Detailed Description

Definition at line 84 of file G4OpenGLQtViewer.hh.

Constructor & Destructor Documentation

◆ G4OpenGLQtViewer()

G4OpenGLQtViewer::G4OpenGLQtViewer ( G4OpenGLSceneHandler scene)

Definition at line 216 of file G4OpenGLQtViewer.cc.

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

◆ ~G4OpenGLQtViewer()

G4OpenGLQtViewer::~G4OpenGLQtViewer ( )
virtual

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

Definition at line 510 of file G4OpenGLQtViewer.cc.

514{
515 fIsDeleting = true;
516
517 // remove scene tree from layout
518 // Delete all the existing buttons in the layout
519 QLayoutItem *wItem;
520 if (fSceneTreeWidget != NULL) {
521 if (fSceneTreeWidget->layout() != NULL) {
522 while ((wItem = fSceneTreeWidget->layout()->takeAt(0)) != 0) {
523 delete wItem->widget();
524 delete wItem;
525 }
526 }
527 }
528
529 // Delete the open/close icons
530 delete fTreeIconOpen;
531 delete fTreeIconClosed;
532
533 G4cout <<removeTempFolder().toStdString().c_str() <<G4endl;
534
535 delete lWaitForVisSubThreadQtOpenGLContextInitialized;
536 delete lWaitForVisSubThreadQtOpenGLContextMoved;
537
538}
#define G4endl
Definition: G4ios.hh:57
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 3344 of file G4OpenGLQtViewer.cc.

3349 {
3350
3351 QString modelShortName = getModelShortName(model);
3352 G4Colour color;
3353
3354 // Special case for text
3355 try {
3356 const G4Text& g4Text = dynamic_cast<const G4Text&>(visible);
3357 color = fSceneHandler.GetTextColour(g4Text);
3358 }
3359 catch (const std::bad_cast&) {
3360 color = fSceneHandler.GetColour();
3361 }
3362
3363 // Special case for marker
3364 try {
3365 const G4VMarker& g4Marker = dynamic_cast<const G4VMarker&>(visible);
3366 if (g4Marker.GetInfo() != "") {
3367 modelShortName = g4Marker.GetInfo();
3368 }
3369 }
3370 catch (const std::bad_cast&) {}
3371
3372 if (modelShortName == "") {
3373 return ;
3374 }
3375 // try to init it
3376 if (fSceneTreeComponentTreeWidget == NULL) {
3377 createSceneTreeComponent();
3378 }
3379
3380 // if no UI
3381 if (fSceneTreeComponentTreeWidget == NULL) {
3382 return;
3383 }
3384
3385 fSceneTreeComponentTreeWidget->blockSignals(true);
3386
3387 // Create the "Model" node if not
3388
3389 QList<QTreeWidgetItem *> resItem;
3390 resItem = fSceneTreeComponentTreeWidget->findItems (modelShortName, Qt::MatchExactly, 0 );
3391 QTreeWidgetItem * currentItem = NULL;
3392 const PVPath tmpFullPath;
3393
3394 if (resItem.empty()) {
3395 currentItem = createTreeWidgetItem(tmpFullPath,
3396 modelShortName,
3397 0, // currentPVCopyNb
3398 -1, // currentPVPOIndex
3399 "",
3400 Qt::Checked,
3401 NULL,
3402 color);
3403 } else {
3404 currentItem = resItem.first();
3405 }
3406
3407 // Is this volume already in the tree AND PO is not the same?
3408 const QList<QTreeWidgetItem *>&
3409 resItems = fSceneTreeComponentTreeWidget->findItems (QString(modelDescription.c_str()), Qt::MatchFixedString| Qt::MatchCaseSensitive|Qt::MatchRecursive, 0 );
3410
3411 bool alreadyPresent = false;
3412 for (int i = 0; i < resItems.size(); ++i) {
3413 if (currentPOIndex == resItems.at(i)->data(0,Qt::UserRole).toInt()) {
3414 alreadyPresent = true;
3415 }
3416 }
3417 if (!alreadyPresent) {
3418 createTreeWidgetItem(tmpFullPath,
3419 modelShortName,
3420 0, // currentPVCopyNb
3421 currentPOIndex,
3422 "",
3423 Qt::Checked,
3424 currentItem,
3425 color);
3426 }
3427 fSceneTreeComponentTreeWidget->blockSignals(false);
3428
3429}
Definition: G4Text.hh:72
const G4Colour & GetTextColour(const G4Text &)
const G4Colour & GetColour()
G4VSceneHandler & fSceneHandler
Definition: G4VViewer.hh:216
virtual const G4String & GetInfo() const

Referenced by G4OpenGLStoredQtSceneHandler::ExtraPOProcessing().

◆ addPVSceneTreeElement()

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

Definition at line 2876 of file G4OpenGLQtViewer.cc.

2876 {
2877
2878 const QString& modelShortName = getModelShortName(model);
2879
2880 if (modelShortName == "") {
2881 return ;
2882 }
2883 // try to init it
2884 if (fSceneTreeComponentTreeWidget == NULL) {
2885 createSceneTreeComponent();
2886 }
2887
2888 // if no UI
2889 if (fSceneTreeComponentTreeWidget == NULL) {
2890 return;
2891 }
2892
2893 fSceneTreeComponentTreeWidget->blockSignals(true);
2894
2895 // Create the "volume" node if not
2896 // if (fSceneTreeComponentTreeWidget->topLevelItemCount () == 0) {
2897 if (!fPVRootNodeCreate) {
2898 const G4Colour& color = fSceneHandler.GetColour();
2899
2900 fModelShortNameItem = createTreeWidgetItem(pPVModel->GetFullPVPath(),
2901 modelShortName,
2902 0, // currentPVCopyNb
2903 -1, // currentPVPOIndex
2904 "",
2905 Qt::Checked,
2906 NULL,
2907 color);
2908 fPVRootNodeCreate = true;
2909 }
2910
2911 bool added = parseAndInsertInSceneTree(fModelShortNameItem,pPVModel,0,modelShortName,0,currentPOIndex);
2912 if (!added) {
2913 }
2914
2915 fSceneTreeComponentTreeWidget->blockSignals(false);
2916
2917}
const std::vector< G4PhysicalVolumeNodeID > & GetFullPVPath() const

Referenced by G4OpenGLStoredQtSceneHandler::ExtraPOProcessing().

◆ clearTreeWidget()

void G4OpenGLQtViewer::clearTreeWidget ( )

Definition at line 3855 of file G4OpenGLQtViewer.cc.

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

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

◆ CreateGLQtContext()

void G4OpenGLQtViewer::CreateGLQtContext ( )
protected

◆ CreateMainWindow()

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

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

Definition at line 114 of file G4OpenGLQtViewer.cc.

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

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

◆ displayRecordingStatus()

void G4OpenGLQtViewer::displayRecordingStatus ( )

Definition at line 1850 of file G4OpenGLQtViewer.cc.

1850 {
1851
1852 QString txtStatus = "";
1853 if (fRecordingStep == WAIT) {
1854 txtStatus = "Waiting to start...";
1855 fRecordFrameNumber = 0; // reset the frame number
1856 } else if (fRecordingStep == START) {
1857 txtStatus = "Start Recording...";
1858 } else if (fRecordingStep == PAUSE) {
1859 txtStatus = "Pause Recording...";
1860 } else if (fRecordingStep == CONTINUE) {
1861 txtStatus = "Continue Recording...";
1862 } else if (fRecordingStep == STOP) {
1863 txtStatus = "Stop Recording...";
1864 } else if (fRecordingStep == READY_TO_ENCODE) {
1865 txtStatus = "Ready to Encode...";
1866 } else if (fRecordingStep == ENCODING) {
1867 txtStatus = "Encoding...";
1868 } else if (fRecordingStep == FAILED) {
1869 txtStatus = "Failed to encode...";
1870 } else if ((fRecordingStep == BAD_ENCODER)
1871 || (fRecordingStep == BAD_OUTPUT)
1872 || (fRecordingStep == BAD_TMP)) {
1873 txtStatus = "Correct above errors first";
1874 } else if (fRecordingStep == SUCCESS) {
1875 txtStatus = "File encoded successfully";
1876 } else {
1877 }
1878
1879 if (fMovieParametersDialog) {
1880 fMovieParametersDialog->setRecordingStatus(txtStatus);
1881 } else {
1882 G4cout << txtStatus.toStdString().c_str() << G4endl;
1883 }
1884 setRecordingInfos("");
1885}

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

4085 {
4086 // no UI
4087 if (fUISceneTreeWidget == NULL) {
4088 return;
4089 }
4090 if (fSceneTreeComponentTreeWidget == NULL) {
4091 return;
4092 }
4093
4094 // sort tree items
4095 fSceneTreeComponentTreeWidget->sortItems (0, Qt::AscendingOrder );
4096
4097 return;
4098}

◆ DrawText()

void G4OpenGLQtViewer::DrawText ( const G4Text g4text)
virtual

Reimplemented from G4OpenGLViewer.

Definition at line 2795 of file G4OpenGLQtViewer.cc.

2796{
2797 QGLWidget* qGLW = dynamic_cast<QGLWidget*> (fGLWidget) ;
2798 if (! qGLW) {
2799 return;
2800 }
2801 if (isGl2psWriting()) {
2802
2804
2805 } else {
2806
2807 if (!fGLWidget) return;
2808
2809#ifdef G4MULTITHREADED
2811#endif
2812
2814 G4double size = fSceneHandler.GetMarkerSize(g4text,sizeType);
2815
2816 QFont font = QFont();
2817 font.setPointSizeF(size);
2818
2819 const G4Colour& c = fSceneHandler.GetTextColour(g4text);
2820 glColor4d(c.GetRed(),c.GetGreen(),c.GetBlue(),c.GetAlpha());
2821
2822 G4Point3D position = g4text.GetPosition();
2823
2824 const G4String& textString = g4text.GetText();
2825 const char* textCString = textString.c_str();
2826
2827 glRasterPos3d(position.x(),position.y(),position.z());
2828
2829 // Calculate move for centre and right adjustment
2830 QFontMetrics* f = new QFontMetrics (font);
2831#if QT_VERSION > 0x050110
2832 G4double span = f->boundingRect(textCString).width();
2833#else
2834 G4double span = f->width(textCString);
2835#endif
2836 G4double xmove = 0., ymove = 0.;
2837 switch (g4text.GetLayout()) {
2838 case G4Text::left: break;
2839 case G4Text::centre: xmove -= span / 2.; break;
2840 case G4Text::right: xmove -= span;
2841 }
2842
2843 //Add offsets
2844 xmove += g4text.GetXOffset();
2845 ymove += g4text.GetYOffset();
2846
2847 // xmove, ymove in pixels - or are they?
2848#ifdef __APPLE__
2849 const G4double fudgeFactor = 2.;
2850#else
2851 const G4double fudgeFactor = 1.;
2852#endif
2853 xmove *= fudgeFactor;
2854 ymove *= fudgeFactor;
2855
2856 qGLW->renderText
2857 ((position.x()+(2*xmove)/getWinWidth()),
2858 (position.y()+(2*ymove)/getWinHeight()),
2859 position.z(),
2860 textCString,
2861 font);
2862
2863 }
2864}
double G4double
Definition: G4Types.hh:83
G4double GetBlue() const
Definition: G4Colour.hh:154
G4double GetAlpha() const
Definition: G4Colour.hh:155
G4double GetRed() const
Definition: G4Colour.hh:152
G4double GetGreen() const
Definition: G4Colour.hh:153
virtual void DrawText(const G4Text &)
G4bool isGl2psWriting()
Layout GetLayout() const
G4double GetYOffset() const
G4double GetXOffset() const
G4String GetText() const
@ centre
Definition: G4Text.hh:76
@ right
Definition: G4Text.hh:76
@ left
Definition: G4Text.hh:76
G4Point3D GetPosition() const
G4double GetMarkerSize(const G4VMarker &, MarkerSizeType &)
G4int G4GetThreadId()
Definition: G4Threading.cc:122

◆ encodeVideo()

void G4OpenGLQtViewer::encodeVideo ( )

Definition at line 2377 of file G4OpenGLQtViewer.cc.

2378{
2379 if ((getEncoderPath() != "") && (getSaveFileName() != "")) {
2380 setRecordingStatus(ENCODING);
2381
2382 fProcess = new QProcess();
2383#if QT_VERSION > 0x040100
2384 QObject ::connect(fProcess,SIGNAL(finished ( int,QProcess::ExitStatus)),
2385 this,SLOT(processEncodeFinished()));
2386 QObject ::connect(fProcess,SIGNAL(readyReadStandardOutput ()),
2387 this,SLOT(processEncodeStdout()));
2388#else
2389 QObject ::connect(fProcess,SIGNAL(finished ( int)),
2390 this,SLOT(processEncodeFinished()));
2391 QObject ::connect(fProcess,SIGNAL(readyReadStandardOutput ()),
2392 this,SLOT(processEncodeStdout()));
2393#endif
2394#if QT_VERSION < 0x050a00
2395 fProcess->setReadChannelMode(QProcess::MergedChannels);
2396#else
2397 fProcess->setProcessChannelMode(QProcess::MergedChannels);
2398#endif
2399 fProcess->start (fEncoderPath, QStringList(fMovieTempFolderPath+fParameterFileName));
2400 }
2401}

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

2187 {
2188
2189 QGLWidget* qGLW = dynamic_cast<QGLWidget*> (fGLWidget) ;
2190 if (! qGLW) {
2191 return false;
2192 }
2193 // If there is already an extention
2194 bool increaseFileNumber = true;
2195 // if
2196 if (name.size() != name.substr(name.find_last_of(".") + 1).size()) {
2197 increaseFileNumber = false;
2198 }
2199 if (! setExportFilename(name,increaseFileNumber)) {
2200 return false;
2201 }
2202 if ((width !=-1) && (height != -1)) {
2203 setExportSize(width, height);
2204 }
2205 // first, try to do it with generic function
2206 if (G4OpenGLViewer::exportImage(name, width, height)) {
2207 return true;
2208
2209 // Then try Qt saving functions
2210 } else {
2211 QImage image;
2212 image = qGLW->grabFrameBuffer();
2213
2214 bool res = image.save(QString(getRealPrintFilename().c_str()),0,fLastExportSliderValue);
2215
2216 if (!res) {
2217 G4cerr << "Error saving file... " << getRealPrintFilename().c_str() << G4endl;
2218 return false;
2219 } else {
2220 G4cout << "File " << getRealPrintFilename().c_str() << " size: " << fGLWidget->width() << "x" << fGLWidget->height() << " has been saved " << G4endl;
2222 }
2223 }
2224 return true;
2225}
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()

◆ FinishView()

void G4OpenGLQtViewer::FinishView ( void  )
protectedvirtual

Reimplemented from G4VViewer.

Definition at line 1266 of file G4OpenGLQtViewer.cc.

1267{
1268 /* From Apple doc:
1269 CGLFlushDrawable : Copies the back buffer of a double-buffered context to the front buffer.
1270 If the backing store attribute is set to false, the buffers can be exchanged rather than copied
1271 */
1272 glFlush ();
1273
1274 // L. Garnier 10/2009 : Not necessary and cause problems on mac OS X 10.6
1275 // fGLWidget->swapBuffers ();
1276}

◆ G4keyPressEvent()

void G4OpenGLQtViewer::G4keyPressEvent ( QKeyEvent *  event)

Definition at line 1613 of file G4OpenGLQtViewer.cc.

1614{
1615 if (fHoldKeyEvent)
1616 return;
1617
1618 fHoldKeyEvent = true;
1619
1620
1621 // with no modifiers
1622 updateKeyModifierState(evnt->modifiers());
1623 if ((fNoKeyPress) || (evnt->modifiers() == Qt::KeypadModifier )) {
1624 if (evnt->key() == Qt::Key_Down) { // go down
1625 moveScene(0,1,0,false);
1626 }
1627 else if (evnt->key() == Qt::Key_Up) { // go up
1628 moveScene(0,-1,0,false);
1629 }
1630 if (evnt->key() == Qt::Key_Left) { // go left
1631 moveScene(-1,0,0,false);
1632 }
1633 else if (evnt->key() == Qt::Key_Right) { // go right
1634 moveScene(1,0,0,false);
1635 }
1636 if (evnt->key() == Qt::Key_Minus) { // go backward
1637 moveScene(0,0,1,false);
1638 }
1639 else if (evnt->key() == Qt::Key_Plus) { // go forward
1640 moveScene(0,0,-1,false);
1641 }
1642 // escaped from full screen
1643 if (evnt->key() == Qt::Key_Escape) {
1644 toggleFullScreen(false);
1645 }
1646 }
1647 // several case here : If return is pressed, in every case -> display the movie parameters dialog
1648 // If one parameter is wrong -> put it in red (only save filenam could be wrong..)
1649 // If encoder not found-> does nothing.Only display a message in status box
1650 // If all ok-> generate parameter file
1651 // If ok -> put encoder button enabled
1652
1653 if ((evnt->key() == Qt::Key_Return) || (evnt->key() == Qt::Key_Enter)){ // end of video
1654 stopVideo();
1655 }
1656 if (evnt->key() == Qt::Key_Space){ // start/pause of video
1658 }
1659
1660 // H : Return Home view
1661 if (evnt->key() == Qt::Key_H){ // go Home
1662 ResetView();
1663
1664 updateQWidget();
1665 }
1666
1667 // Shift Modifier
1668 if (fShiftKeyPress) {
1669 fGLWidget->setCursor(QCursor(Qt::SizeAllCursor));
1670
1671 if (evnt->key() == Qt::Key_Down) { // rotate phi
1673 }
1674 else if (evnt->key() == Qt::Key_Up) { // rotate phi
1676 }
1677 if (evnt->key() == Qt::Key_Left) { // rotate theta
1679 }
1680 else if (evnt->key() == Qt::Key_Right) { // rotate theta
1682 }
1683 if (evnt->key() == Qt::Key_Plus) { // go forward ("Plus" imply
1684 // "Shift" on Mac French keyboard
1685 moveScene(0,0,-1,false);
1686 }
1687
1688 // Alt Modifier
1689 }
1690 if ((fAltKeyPress)) {
1691 fGLWidget->setCursor(QCursor(Qt::ClosedHandCursor));
1692
1693 if (evnt->key() == Qt::Key_Down) { // rotate phi
1695 }
1696 else if (evnt->key() == Qt::Key_Up) { // rotate phi
1698 }
1699 if (evnt->key() == Qt::Key_Left) { // rotate theta
1701 }
1702 else if (evnt->key() == Qt::Key_Right) { // rotate theta
1704 }
1705
1706 // Rotatio +/-
1707 if (evnt->key() == Qt::Key_Plus) {
1708 fRot_sens = fRot_sens/0.7;
1709 G4cout << "Auto-rotation set to : " << fRot_sens << G4endl;
1710 }
1711 else if (evnt->key() == Qt::Key_Minus) {
1712 fRot_sens = fRot_sens*0.7;
1713 G4cout << "Auto-rotation set to : " << fRot_sens << G4endl;
1714 }
1715
1716 // Control Modifier OR Command on MAC
1717 }
1718 if ((fControlKeyPress)) {
1719 if (evnt->key() == Qt::Key_Plus) {
1720 fVP.SetZoomFactor(fVP.GetZoomFactor()*(1+fDeltaZoom));
1721 updateQWidget();
1722 }
1723 else if (evnt->key() == Qt::Key_Minus) {
1724 fVP.SetZoomFactor(fVP.GetZoomFactor()*(1-fDeltaZoom));
1725 updateQWidget();
1726 }
1727 }
1728
1729 fHoldKeyEvent = false;
1730}
void rotateQtSceneToggle(float, float)
void moveScene(float, float, float, bool)
void rotateQtScene(float, float)
void updateKeyModifierState(const Qt::KeyboardModifiers &)
virtual void updateQWidget()=0
G4double GetZoomFactor() const
void SetZoomFactor(G4double zoomFactor)

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

◆ G4keyReleaseEvent()

void G4OpenGLQtViewer::G4keyReleaseEvent ( QKeyEvent *  event)

Definition at line 1733 of file G4OpenGLQtViewer.cc.

1734{
1735 fGLWidget->setCursor(QCursor(Qt::ArrowCursor));
1736}

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

◆ G4manageContextMenuEvent()

void G4OpenGLQtViewer::G4manageContextMenuEvent ( QContextMenuEvent *  e)
protected

Definition at line 754 of file G4OpenGLQtViewer.cc.

755{
756 if (!fGLWidget) {
757 G4cerr << "Visualization window not defined, please choose one before" << G4endl;
758 } else {
759
760 if (!fContextMenu)
761 createPopupMenu();
762
763 // launch menu
764 if ( fContextMenu ) {
765 fContextMenu->exec( e->globalPos() );
766 // delete fContextMenu;
767 }
768 }
769 e->accept();
770}

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

◆ G4MouseDoubleClickEvent()

void G4OpenGLQtViewer::G4MouseDoubleClickEvent ( )

Definition at line 1435 of file G4OpenGLQtViewer.cc.

1436{
1437 fGLWidget->setMouseTracking(true);
1438}

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

1449{
1450
1451 Qt::MouseButtons mButtons = evnt->buttons();
1452
1453 updateKeyModifierState(evnt->modifiers());
1454
1455 if (fAutoMove) {
1456 return;
1457 }
1458
1459 fLastPos3 = fLastPos2;
1460 fLastPos2 = fLastPos1;
1461 fLastPos1 = QPoint(evnt->x(), evnt->y());
1462
1463 int deltaX = fLastPos2.x()-fLastPos1.x();
1464 int deltaY = fLastPos2.y()-fLastPos1.y();
1465
1466 bool move = false;
1467 if (fUiQt != NULL) {
1468 if (fUiQt->IsIconMoveSelected()) { // move
1469 move = true;
1470 }
1471 }
1472 if (!move) { // rotate, pick, zoom...
1473 if (mButtons & Qt::LeftButton) {
1474 if (fNoKeyPress) {
1475 rotateQtScene(((float)deltaX),((float)deltaY));
1476 } else if (fAltKeyPress) {
1477 rotateQtSceneToggle(((float)deltaX),((float)deltaY));
1478 } else if (fShiftKeyPress) {
1479 unsigned int sizeWin;
1480 sizeWin = getWinWidth();
1481 if (getWinHeight() < getWinWidth()) {
1482 sizeWin = getWinHeight();
1483 }
1484
1485 // L.Garnier : 08/2010 100 is the good value, but don't ask me why !
1486 float factor = ((float)100/(float)sizeWin) ;
1487 moveScene(-(float)deltaX*factor,-(float)deltaY*factor,0,false);
1488 } else if (fControlKeyPress) {
1489 fVP.SetZoomFactor(fVP.GetZoomFactor()*(1+((float)deltaY)));
1490 }
1491 }
1492 } else if (move) { // move
1493 if (mButtons & Qt::LeftButton) {
1494 moveScene(-(float)deltaX,-(float)deltaY,0,true);
1495 }
1496 }
1497
1498 fLastEventTime->start();
1499}
G4bool IsIconMoveSelected()
Definition: G4UIQt.hh:182

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

1283{
1284 if (evnt->button() == Qt::RightButton) {
1285 return;
1286 }
1287 if ((evnt->button() & Qt::LeftButton) && (! (evnt->modifiers() & Qt::ControlModifier ))){
1288 fGLWidget->setMouseTracking(true);
1289 fAutoMove = false; // stop automove
1290 fLastPos1 = evnt->pos();
1291 fLastPos2 = fLastPos1;
1292 fLastPos3 = fLastPos2;
1293 fLastEventTime->start();
1294 if (fUiQt != NULL) {
1295
1296 if (fUiQt->IsIconZoomInSelected()) { // zoomIn
1297 // Move click point to center of OGL
1298
1299 float deltaX = ((float)getWinWidth()/2-evnt->pos().x());
1300 float deltaY = ((float)getWinHeight()/2-evnt->pos().y());
1301
1302 G4double coefTrans = 0;
1303 coefTrans = ((G4double)getSceneNearWidth())/((G4double)getWinWidth());
1304 if (getWinHeight() <getWinWidth()) {
1305 coefTrans = ((G4double)getSceneNearWidth())/((G4double)getWinHeight());
1306 }
1307 fVP.IncrementPan(-deltaX*coefTrans,deltaY*coefTrans,0);
1309
1310 updateQWidget();
1311
1312 } else if (fUiQt->IsIconZoomOutSelected()) { // zoomOut
1313 // Move click point to center of OGL
1314 moveScene(((float)getWinWidth()/2-evnt->pos().x()),((float)getWinHeight()/2-evnt->pos().y()),0,true);
1315
1317 updateQWidget();
1318
1319 } else if (fUiQt->IsIconRotateSelected() ) {
1320
1321 if (fShiftKeyPress) { // move
1322 fGLWidget->setCursor(QCursor(Qt::SizeAllCursor));
1323
1324 } else { // rotate
1325 fGLWidget->setCursor(QCursor(Qt::ClosedHandCursor));
1326 }
1327 } else if (fUiQt->IsIconMoveSelected()) {
1328 fGLWidget->setCursor(QCursor(Qt::SizeAllCursor));
1329 } else if (fUiQt->IsIconPickSelected()) {
1330 fGLWidget->setCursor(QCursor(Qt::PointingHandCursor));
1331 }
1332 }
1333 }
1334}
GLdouble getSceneNearWidth()
G4bool IsIconRotateSelected()
Definition: G4UIQt.hh:185
G4bool IsIconZoomInSelected()
Definition: G4UIQt.hh:191
G4bool IsIconZoomOutSelected()
Definition: G4UIQt.hh:194
G4bool IsIconPickSelected()
Definition: G4UIQt.hh:188
void IncrementPan(G4double right, G4double up)

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

◆ G4MouseReleaseEvent()

void G4OpenGLQtViewer::G4MouseReleaseEvent ( QMouseEvent *  evnt)

Definition at line 1338 of file G4OpenGLQtViewer.cc.

1339{
1340 GLint viewport[4];
1341 glGetIntegerv(GL_VIEWPORT, viewport);
1342
1343 // factorX == factorY
1344 double factorX = ((double)viewport[2]/fGLWidget->width());
1345 double factorY = ((double)viewport[3]/fGLWidget->height());
1346 fSpinningDelay = (int)fLastEventTime->elapsed();
1347 QPoint delta = (fLastPos3-fLastPos1)*factorX;
1348
1349 // reset cursor state
1350 fGLWidget->setCursor(QCursor(Qt::ArrowCursor));
1351
1352 if (fVP.IsPicking()){ // pick
1353 if ((delta.x() != 0) || (delta.y() != 0)) {
1354 return;
1355 }
1356 updatePickInfosWidget(evnt->pos().x()*factorX,evnt->pos().y()*factorY);
1357
1358 } else if (fSpinningDelay < fLaunchSpinDelay ) {
1359 if ((delta.x() == 0) && (delta.y() == 0)) {
1360 return;
1361 }
1362
1363 fAutoMove = true;
1364#if QT_VERSION < 0x050e00
1365 QTime lastMoveTime;
1366#else
1367 QElapsedTimer lastMoveTime;
1368#endif
1369 lastMoveTime.start();
1370 // try to addapt speed move/rotate looking to drawing speed
1371 float correctionFactor = 5;
1372 while (fAutoMove) {
1373 if ( lastMoveTime.elapsed() >= (int)(1000/fNbMaxFramesPerSec)) {
1374 float lTime = 1000/lastMoveTime.elapsed();
1375 if (((((float)delta.x())/correctionFactor)*lTime > fNbMaxAnglePerSec) ||
1376 ((((float)delta.x())/correctionFactor)*lTime < -fNbMaxAnglePerSec) ) {
1377 correctionFactor = (float)delta.x()*(lTime/fNbMaxAnglePerSec);
1378 if (delta.x() <0 ) {
1379 correctionFactor = -correctionFactor;
1380 }
1381 }
1382 if (((((float)delta.y())/correctionFactor)*lTime > fNbMaxAnglePerSec) ||
1383 ((((float)delta.y())/correctionFactor)*lTime < -fNbMaxAnglePerSec) ) {
1384 correctionFactor = (float)delta.y()*(lTime/fNbMaxAnglePerSec);
1385 if (delta.y() <0 ) {
1386 correctionFactor = -correctionFactor;
1387 }
1388 }
1389
1390 // Check Qt Versions for META Keys
1391
1392 // Click and move mouse to rotate volume
1393 // ALT + Click and move mouse to rotate volume (View Direction)
1394 // SHIFT + Click and move camera point of view
1395 // CTRL + Click and zoom mouse to zoom in/out
1396
1397 lastMoveTime.start();
1398
1399 bool rotate = false;
1400 bool move = false;
1401
1402 if (fUiQt != NULL) {
1403 if (fUiQt->IsIconRotateSelected()) { // rotate
1404 rotate = true;
1405 } else if (fUiQt->IsIconMoveSelected()) { // move
1406 move = true;
1407 }
1408 } else {
1409 rotate = true;
1410 }
1411 // prevent from closing widget when rotating (cause a crash)
1412 if (fIsDeleting) {
1413 return;
1414 }
1415
1416 if (rotate) { // rotate
1417 if (fNoKeyPress) {
1418 rotateQtScene(((float)delta.x())/correctionFactor,((float)delta.y())/correctionFactor);
1419 } else if (fAltKeyPress) {
1420 rotateQtSceneToggle(((float)delta.x())/correctionFactor,((float)delta.y())/correctionFactor);
1421 }
1422
1423 } else if (move) { // move
1424 moveScene(-((float)delta.x())/correctionFactor,-((float)delta.y())/correctionFactor,0,true);
1425 }
1426 }
1427 ((QApplication*)G4Qt::getInstance ())->processEvents();
1428 }
1429 }
1430 fGLWidget->setMouseTracking(false);
1431
1432}
void updatePickInfosWidget(int, int)
G4bool IsPicking() const

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

◆ G4wheelEvent()

void G4OpenGLQtViewer::G4wheelEvent ( QWheelEvent *  event)

Definition at line 1600 of file G4OpenGLQtViewer.cc.

1601{
1602#if QT_VERSION < 0x050F00
1603 // Before Qt5.15
1604 fVP.SetZoomFactor(fVP.GetZoomFactor()+(fVP.GetZoomFactor()*(evnt->delta())/1200));
1605#else
1606 // Qt5.15 and beyond
1607 fVP.SetZoomFactor(fVP.GetZoomFactor()+(fVP.GetZoomFactor()*(evnt->angleDelta().y())/1200));
1608#endif
1609 updateQWidget();
1610}

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

◆ generateMpegEncoderParameters()

bool G4OpenGLQtViewer::generateMpegEncoderParameters ( )

Definition at line 2227 of file G4OpenGLQtViewer.cc.

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

Referenced by saveVideo().

◆ getColorForPoIndex()

G4Colour G4OpenGLQtViewer::getColorForPoIndex ( int  poIndex)
protected

Definition at line 3659 of file G4OpenGLQtViewer.cc.

3659 {
3660 // FIXME 09/2014 : Could be optimize by searching in a tab instead of item->data
3661 QTreeWidgetItem* item = getTreeWidgetItem(poIndex);
3662
3663 if (item != NULL) {
3664
3665 const QColor& color = item->data(2,Qt::UserRole).value<QColor>();
3666 G4Colour g4c(((G4double)color.red())/255,
3667 ((G4double)color.green())/255,
3668 ((G4double)color.blue())/255,
3669 ((G4double)color.alpha())/255);
3670
3671 return g4c;
3672 }
3673 return G4Colour();
3674}

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

◆ getEncoderPath()

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

Definition at line 1918 of file G4OpenGLQtViewer.cc.

1918 {
1919 return fEncoderPath;
1920}

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

◆ GetPrivateVisAttributesModifiers()

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

Reimplemented from G4VViewer.

Definition at line 3678 of file G4OpenGLQtViewer.cc.

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

◆ getSaveFileName()

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

Definition at line 2114 of file G4OpenGLQtViewer.cc.

2114 {
2115 return fSaveFileName ;
2116}

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

◆ getTempFolderPath()

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

Definition at line 2080 of file G4OpenGLQtViewer.cc.

2080 {
2081 return fTempFolderPath;
2082}

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

◆ isBadEncoder()

bool G4OpenGLQtViewer::isBadEncoder ( )

Definition at line 2001 of file G4OpenGLQtViewer.cc.

2001 {
2002 if (fRecordingStep == BAD_ENCODER) {
2003 return true;
2004 }
2005 return false;
2006}

Referenced by G4OpenGLQtMovieDialog::setRecordingStatus().

◆ isBadOutput()

bool G4OpenGLQtViewer::isBadOutput ( )

Definition at line 2013 of file G4OpenGLQtViewer.cc.

2013 {
2014 if (fRecordingStep == BAD_OUTPUT) {
2015 return true;
2016 }
2017 return false;
2018}

Referenced by G4OpenGLQtMovieDialog::setRecordingStatus().

◆ isBadTmp()

bool G4OpenGLQtViewer::isBadTmp ( )

Definition at line 2007 of file G4OpenGLQtViewer.cc.

2007 {
2008 if (fRecordingStep == BAD_TMP) {
2009 return true;
2010 }
2011 return false;
2012}

Referenced by G4OpenGLQtMovieDialog::setRecordingStatus().

◆ isCurrentWidget()

bool G4OpenGLQtViewer::isCurrentWidget ( )
protected

Definition at line 4736 of file G4OpenGLQtViewer.cc.

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

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

◆ isEncoding()

bool G4OpenGLQtViewer::isEncoding ( )

Definition at line 1966 of file G4OpenGLQtViewer.cc.

1966 {
1967 if (fRecordingStep == ENCODING) {
1968 return true;
1969 }
1970 return false;
1971}

◆ isFailed()

bool G4OpenGLQtViewer::isFailed ( )

Definition at line 1987 of file G4OpenGLQtViewer.cc.

1987 {
1988 if (fRecordingStep == FAILED) {
1989 return true;
1990 }
1991 return false;
1992}

Referenced by G4OpenGLQtMovieDialog::setRecordingStatus().

◆ isPaused()

bool G4OpenGLQtViewer::isPaused ( )

Definition at line 1959 of file G4OpenGLQtViewer.cc.

1959 {
1960 if (fRecordingStep == PAUSE) {
1961 return true;
1962 }
1963 return false;
1964}

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

◆ isReadyToEncode()

bool G4OpenGLQtViewer::isReadyToEncode ( )

Definition at line 2039 of file G4OpenGLQtViewer.cc.

2039 {
2040 if (fRecordingStep == READY_TO_ENCODE) {
2041 return true;
2042 }
2043 return false;
2044}

Referenced by G4OpenGLQtMovieDialog::checkEncoderSwParameters().

◆ isRecording()

bool G4OpenGLQtViewer::isRecording ( )

Definition at line 1952 of file G4OpenGLQtViewer.cc.

1952 {
1953 if ((fRecordingStep == START) || (fRecordingStep == CONTINUE)) {
1954 return true;
1955 }
1956 return false;
1957}

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

◆ isStopped()

bool G4OpenGLQtViewer::isStopped ( )

Definition at line 1980 of file G4OpenGLQtViewer.cc.

1980 {
1981 if (fRecordingStep == STOP) {
1982 return true;
1983 }
1984 return false;
1985}

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

◆ isSuccess()

bool G4OpenGLQtViewer::isSuccess ( )

Definition at line 1994 of file G4OpenGLQtViewer.cc.

1994 {
1995 if (fRecordingStep == SUCCESS) {
1996 return true;
1997 }
1998 return false;
1999}

Referenced by G4OpenGLQtMovieDialog::setRecordingStatus().

◆ isTouchableVisible()

bool G4OpenGLQtViewer::isTouchableVisible ( int  POindex)

Definition at line 3453 of file G4OpenGLQtViewer.cc.

3453 {
3454
3455 // If no scene tree (Immediate viewer)
3456 if (fSceneTreeComponentTreeWidget == NULL) {
3457 return false;
3458 }
3459
3460 // should be the next one
3461 // Prevent to get out the std::map
3462 if (fLastSceneTreeWidgetAskForIterator != fLastSceneTreeWidgetAskForIteratorEnd) {
3463 fLastSceneTreeWidgetAskForIterator++;
3464 }
3465 QTreeWidgetItem* item = getTreeWidgetItem(POindex);
3466
3467 if (item != NULL) {
3468 if ( item->checkState(0) == Qt::Checked) {
3469 return true;
3470 }
3471 }
3472 return false;
3473}

Referenced by G4OpenGLStoredQtViewer::POSelected().

◆ isWaiting()

bool G4OpenGLQtViewer::isWaiting ( )

Definition at line 1973 of file G4OpenGLQtViewer.cc.

1973 {
1974 if (fRecordingStep == WAIT) {
1975 return true;
1976 }
1977 return false;
1978}

Referenced by G4OpenGLQtMovieDialog::setRecordingStatus().

◆ moveScene()

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

Move the scene of dx, dy, dz values.

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

Definition at line 1509 of file G4OpenGLQtViewer.cc.

1510{
1511 if (fHoldMoveEvent)
1512 return;
1513 fHoldMoveEvent = true;
1514
1515 G4double coefTrans = 0;
1516 GLdouble coefDepth = 0;
1517 if(mouseMove) {
1518 coefTrans = ((G4double)getSceneNearWidth())/((G4double)getWinWidth());
1519 if (getWinHeight() <getWinWidth()) {
1520 coefTrans = ((G4double)getSceneNearWidth())/((G4double)getWinHeight());
1521 }
1522 } else {
1523 coefTrans = getSceneNearWidth()*fPan_sens;
1524 coefDepth = getSceneDepth()*fDeltaDepth;
1525 }
1526 fVP.IncrementPan(-dx*coefTrans,dy*coefTrans,dz*coefDepth);
1527
1528 updateQWidget();
1529 if (fAutoMove)
1530 ((QApplication*)G4Qt::getInstance ())->processEvents();
1531
1532 fHoldMoveEvent = false;
1533}
GLdouble getSceneDepth()

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

◆ resetRecording()

void G4OpenGLQtViewer::resetRecording ( )

Definition at line 2046 of file G4OpenGLQtViewer.cc.

2046 {
2047 setRecordingStatus(WAIT);
2048}

Referenced by savePPMToTemp(), and stopVideo().

◆ ResetView()

void G4OpenGLQtViewer::ResetView ( )
virtual

Reimplemented from G4VViewer.

Definition at line 2867 of file G4OpenGLQtViewer.cc.

2867 {
2869 fDeltaDepth = 0.01;
2870 fDeltaZoom = 0.05;
2871}

Referenced by G4keyPressEvent().

◆ rotateQtScene()

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

Definition at line 1541 of file G4OpenGLQtViewer.cc.

1542{
1543 if (fHoldRotateEvent)
1544 return;
1545 fHoldRotateEvent = true;
1546
1547 rotateScene(dx,dy);
1548
1549 updateQWidget();
1550
1551 fHoldRotateEvent = false;
1552}
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 1559 of file G4OpenGLQtViewer.cc.

1560{
1561 if (fHoldRotateEvent)
1562 return;
1563 fHoldRotateEvent = true;
1564
1565 rotateSceneToggle(dx,dy);
1566
1567 updateQWidget();
1568
1569 fHoldRotateEvent = false;
1570}
void rotateSceneToggle(G4double dx, G4double dy)

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

◆ savePPMToTemp()

void G4OpenGLQtViewer::savePPMToTemp ( )
protected

Definition at line 1066 of file G4OpenGLQtViewer.cc.

1066 {
1067 if (fMovieTempFolderPath == "") {
1068 return;
1069 }
1070 QGLWidget* qGLW = dynamic_cast<QGLWidget*> (fGLWidget) ;
1071 if (! qGLW) {
1072 return;
1073 }
1074 QString fileName ="Test"+QString::number(fRecordFrameNumber)+".ppm";
1075 QString filePath =fMovieTempFolderPath+fileName;
1076
1077 QImage image;
1078 image = qGLW->grabFrameBuffer();
1079 bool res = false;
1080
1081 res = image.save(filePath,0);
1082 if (res == false) {
1084 setRecordingInfos("Can't save tmp file "+filePath);
1085 return;
1086 }
1087
1088 setRecordingInfos("File "+fileName+" saved");
1090}

◆ saveVideo()

void G4OpenGLQtViewer::saveVideo ( )

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

Definition at line 1787 of file G4OpenGLQtViewer.cc.

1787 {
1788
1789 // if encoder parameter is wrong, display parameters dialog and return
1790 if (!fMovieParametersDialog) {
1791 showMovieParametersDialog();
1792 }
1793
1794 fMovieParametersDialog->checkEncoderSwParameters();
1795 fMovieParametersDialog->checkSaveFileNameParameters();
1796
1797 if (fRecordingStep == STOP) {
1798 setRecordingStatus(SAVE);
1800 encodeVideo();
1801 }
1802}
bool generateMpegEncoderParameters()

Referenced by G4OpenGLQtMovieDialog::save().

◆ setBadEncoder()

void G4OpenGLQtViewer::setBadEncoder ( )

Definition at line 2020 of file G4OpenGLQtViewer.cc.

2020 {
2021 fRecordingStep = BAD_ENCODER;
2023}

◆ setBadOutput()

void G4OpenGLQtViewer::setBadOutput ( )

Definition at line 2028 of file G4OpenGLQtViewer.cc.

2028 {
2029 fRecordingStep = BAD_OUTPUT;
2031}

◆ setBadTmp()

void G4OpenGLQtViewer::setBadTmp ( )

Definition at line 2024 of file G4OpenGLQtViewer.cc.

2024 {
2025 fRecordingStep = BAD_TMP;
2027}

◆ setEncoderPath()

QString G4OpenGLQtViewer::setEncoderPath ( QString  path)

set the new encoder path

Returns
"" if correct. The error otherwise

Definition at line 1927 of file G4OpenGLQtViewer.cc.

1927 {
1928 if (path == "") {
1929 return "ppmtompeg is needed to encode in video format. It is available here: http://netpbm.sourceforge.net ";
1930 }
1931
1932 path = QDir::cleanPath(path);
1933 QFileInfo *f = new QFileInfo(path);
1934 if (!f->exists()) {
1935 return "File does not exist";
1936 } else if (f->isDir()) {
1937 return "This is a directory";
1938 } else if (!f->isExecutable()) {
1939 return "File exist but is not executable";
1940 } else if (!f->isFile()) {
1941 return "This is not a file";
1942 }
1943 fEncoderPath = path;
1944
1945 if (fRecordingStep == BAD_ENCODER) {
1946 setRecordingStatus(STOP);
1947 }
1948 return "";
1949}

Referenced by G4OpenGLQtMovieDialog::checkEncoderSwParameters().

◆ setSaveFileName()

QString G4OpenGLQtViewer::setSaveFileName ( QString  path)

set the save file name path

Returns
"" if correct. The error otherwise

Definition at line 2088 of file G4OpenGLQtViewer.cc.

2088 {
2089
2090 if (path == "") {
2091 return "Path does not exist";
2092 }
2093
2094 QFileInfo *file = new QFileInfo(path);
2095 QDir dir = file->dir();
2096 path = QDir::cleanPath(path);
2097 if (file->exists()) {
2098 return "File already exist, please choose a new one";
2099 } else if (!dir.exists()) {
2100 return "Dir does not exist";
2101 } else if (!dir.isReadable()) {
2102 return path +" is read protected";
2103 }
2104
2105 if (fRecordingStep == BAD_OUTPUT) {
2106 setRecordingStatus(STOP);
2107 }
2108 fSaveFileName = path;
2109 return "";
2110}

Referenced by G4OpenGLQtMovieDialog::checkSaveFileNameParameters().

◆ setTempFolderPath()

QString G4OpenGLQtViewer::setTempFolderPath ( QString  path)

set the temp folder path

Returns
"" if correct. The error otherwise

Definition at line 2054 of file G4OpenGLQtViewer.cc.

2054 {
2055
2056 if (path == "") {
2057 return "Path does not exist";
2058 }
2059 path = QDir::cleanPath(path);
2060 QFileInfo *d = new QFileInfo(path);
2061 if (!d->exists()) {
2062 return "Path does not exist";
2063 } else if (!d->isDir()) {
2064 return "This is not a directory";
2065 } else if (!d->isReadable()) {
2066 return path +" is read protected";
2067 } else if (!d->isWritable()) {
2068 return path +" is write protected";
2069 }
2070
2071 if (fRecordingStep == BAD_TMP) {
2072 setRecordingStatus(WAIT);
2073 }
2074 fTempFolderPath = path;
2075 return "";
2076}

Referenced by G4OpenGLQtMovieDialog::checkTempFolderParameters().

◆ setWaiting()

void G4OpenGLQtViewer::setWaiting ( )

Definition at line 2033 of file G4OpenGLQtViewer.cc.

2033 {
2034 fRecordingStep = WAIT;
2036}

◆ startPauseVideo

void G4OpenGLQtViewer::startPauseVideo ( )
slot

Start/Pause the video..

Definition at line 1807 of file G4OpenGLQtViewer.cc.

1807 {
1808
1809 // first time, if temp parameter is wrong, display parameters dialog and return
1810
1811 if ( fRecordingStep == WAIT) {
1812 if ( fRecordFrameNumber == 0) {
1813 if (getTempFolderPath() == "") { // BAD_OUTPUT
1814 showMovieParametersDialog();
1815 setRecordingInfos("You should specified the temp folder in order to make movie");
1816 return;
1817 } else {
1818 // remove temp folder if it was create
1819 QString tmp = removeTempFolder();
1820 if (tmp !="") {
1821 setRecordingInfos(tmp);
1822 return;
1823 }
1824 tmp = createTempFolder();
1825 if (tmp != "") {
1826 setRecordingInfos("Can't create temp folder."+tmp);
1827 return;
1828 }
1829 }
1830 }
1831 }
1832 if (fRecordingStep == WAIT) {
1833 setRecordingStatus(START);
1834 } else if (fRecordingStep == START) {
1835 setRecordingStatus(PAUSE);
1836 } else if (fRecordingStep == PAUSE) {
1837 setRecordingStatus(CONTINUE);
1838 } else if (fRecordingStep == CONTINUE) {
1839 setRecordingStatus(PAUSE);
1840 }
1841}

Referenced by G4keyPressEvent().

◆ stopVideo()

void G4OpenGLQtViewer::stopVideo ( )

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

Definition at line 1764 of file G4OpenGLQtViewer.cc.

1764 {
1765
1766 // if encoder parameter is wrong, display parameters dialog and return
1767 if (!fMovieParametersDialog) {
1768 showMovieParametersDialog();
1769 }
1770 setRecordingStatus(STOP);
1771
1772 if (fRecordFrameNumber >0) {
1773 // check parameters if they were modified (Re APPLY them...)
1774 if (!(fMovieParametersDialog->checkEncoderSwParameters())) {
1775 setRecordingStatus(BAD_ENCODER);
1776 } else if (!(fMovieParametersDialog->checkSaveFileNameParameters())) {
1777 setRecordingStatus(BAD_OUTPUT);
1778 }
1779 } else {
1781 setRecordingInfos("No frame to encode.");
1782 }
1783}

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

◆ updateKeyModifierState()

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

Definition at line 1739 of file G4OpenGLQtViewer.cc.

1739 {
1740 // Check Qt Versions for META Keys
1741
1742 fNoKeyPress = true;
1743 fAltKeyPress = false;
1744 fShiftKeyPress = false;
1745 fControlKeyPress = false;
1746
1747 if (modifier & Qt::AltModifier ) {
1748 fAltKeyPress = true;
1749 fNoKeyPress = false;
1750 }
1751 if (modifier & Qt::ShiftModifier ) {
1752 fShiftKeyPress = true;
1753 fNoKeyPress = false;
1754 }
1755 if (modifier & Qt::ControlModifier ) {
1756 fControlKeyPress = true;
1757 fNoKeyPress = false;
1758 }
1759}

Referenced by G4keyPressEvent(), and G4MouseMoveEvent().

◆ updatePickInfosWidget()

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

Update the pick infos component widget

Definition at line 4527 of file G4OpenGLQtViewer.cc.

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

4208 {
4209 // Ensure case where closing a UI tab close the widget
4210 if (!fSceneTreeWidget) {
4211 createSceneTreeWidget();
4212 }
4213}

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

4107 {
4108 if (fBatchMode) {
4109 return;
4110 }
4111
4113 d_style = fVP.GetDrawingStyle();
4114
4115 // Surface style
4116 if (d_style == G4ViewParameters::wireframe) {
4117 if (fUiQt) fUiQt->SetIconWireframeSelected();
4118 if (fContextMenu) {
4119 fDrawingWireframe->setChecked(true);
4120 fDrawingLineRemoval->setChecked(false);
4121 fDrawingSurfaceRemoval->setChecked(false);
4122 fDrawingLineSurfaceRemoval->setChecked(false);
4123 }
4124 } else if (d_style == G4ViewParameters::hlr) {
4125 if (fUiQt) fUiQt->SetIconHLRSelected();
4126 if (fContextMenu) {
4127 fDrawingLineRemoval->setChecked(true);
4128 fDrawingWireframe->setChecked(false);
4129 fDrawingSurfaceRemoval->setChecked(false);
4130 fDrawingLineSurfaceRemoval->setChecked(false);
4131 }
4132 } else if (d_style == G4ViewParameters::hsr) {
4133 if (fUiQt) fUiQt->SetIconSolidSelected();
4134 if (fContextMenu) {
4135 fDrawingSurfaceRemoval->setChecked(true);
4136 fDrawingWireframe->setChecked(false);
4137 fDrawingLineRemoval->setChecked(false);
4138 fDrawingLineSurfaceRemoval->setChecked(false);
4139 }
4140 } else if (d_style == G4ViewParameters::hlhsr) {
4141 if (fUiQt) fUiQt->SetIconHLHSRSelected();
4142 if (fContextMenu) {
4143 fDrawingLineSurfaceRemoval->setChecked(true);
4144 fDrawingWireframe->setChecked(false);
4145 fDrawingLineRemoval->setChecked(false);
4146 fDrawingSurfaceRemoval->setChecked(false);
4147 fDrawingLineSurfaceRemoval->setChecked(false);
4148 }
4149 }
4150
4151
4152 // projection style
4153 G4double d_proj = fVP.GetFieldHalfAngle () ;
4154 if (d_proj == 0.) { // ortho
4155 if (fUiQt) fUiQt->SetIconOrthoSelected();
4156 if (fContextMenu) {
4157 fProjectionOrtho->setChecked(true);
4158 fProjectionPerspective->setChecked(false);
4159 }
4160 } else {
4161 if (fUiQt) fUiQt->SetIconPerspectiveSelected();
4162 if (fContextMenu) {
4163 fProjectionPerspective->setChecked(true);
4164 fProjectionOrtho->setChecked(false);
4165 }
4166 }
4167
4168
4169 // mouse style : They are controlled by UI !
4170 if (fUiQt && fContextMenu) {
4171 if (fUiQt->IsIconPickSelected()) {
4172 fMousePickAction->setChecked(true);
4173 fMouseZoomOutAction->setChecked(false);
4174 fMouseZoomInAction->setChecked(false);
4175 fMouseRotateAction->setChecked(false);
4176 fMouseMoveAction->setChecked(false);
4177 } else if (fUiQt->IsIconZoomOutSelected()) {
4178 fMouseZoomOutAction->setChecked(true);
4179 fMousePickAction->setChecked(false);
4180 fMouseZoomInAction->setChecked(false);
4181 fMouseRotateAction->setChecked(false);
4182 fMouseMoveAction->setChecked(false);
4183 } else if (fUiQt->IsIconZoomInSelected()) {
4184 fMouseZoomInAction->setChecked(true);
4185 fMousePickAction->setChecked(false);
4186 fMouseZoomOutAction->setChecked(false);
4187 fMouseRotateAction->setChecked(false);
4188 fMouseMoveAction->setChecked(false);
4189 } else if (fUiQt->IsIconRotateSelected()) {
4190 fMouseRotateAction->setChecked(true);
4191 fMousePickAction->setChecked(false);
4192 fMouseZoomOutAction->setChecked(false);
4193 fMouseZoomInAction->setChecked(false);
4194 fMouseMoveAction->setChecked(false);
4195 } else if (fUiQt->IsIconMoveSelected()) {
4196 fMouseMoveAction->setChecked(true);
4197 fMousePickAction->setChecked(false);
4198 fMouseZoomOutAction->setChecked(false);
4199 fMouseZoomInAction->setChecked(false);
4200 fMouseRotateAction->setChecked(false);
4201 }
4202 }
4203}
void SetIconOrthoSelected()
Definition: G4UIQt.cc:5081
void SetIconHLRSelected()
Definition: G4UIQt.cc:5009
void SetIconPerspectiveSelected()
Definition: G4UIQt.cc:5059
void SetIconSolidSelected()
Definition: G4UIQt.cc:4961
void SetIconWireframeSelected()
Definition: G4UIQt.cc:4985
void SetIconHLHSRSelected()
Definition: G4UIQt.cc:5034
G4double GetFieldHalfAngle() const
DrawingStyle GetDrawingStyle() const

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

◆ updateViewerPropertiesTableWidget()

void G4OpenGLQtViewer::updateViewerPropertiesTableWidget ( )

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

Definition at line 4220 of file G4OpenGLQtViewer.cc.

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

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

Member Data Documentation

◆ fGLWidget

◆ fHasToRepaint

◆ fMouseOnSceneTree

bool G4OpenGLQtViewer::fMouseOnSceneTree
protected

Definition at line 200 of file G4OpenGLQtViewer.hh.

Referenced by G4OpenGLStoredQtViewer::CompareForKernelVisit().

◆ fPaintEventLock

◆ fQGLWidgetInitialiseCompleted

◆ fRecordFrameNumber

int G4OpenGLQtViewer::fRecordFrameNumber
protected

◆ fUpdateGLLock


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