Problem 2513 - G4OpenGLQtViewer::toggleProjection seems broken on qt 5.6+
Summary: G4OpenGLQtViewer::toggleProjection seems broken on qt 5.6+
Status: RESOLVED FIXED
Alias: None
Product: Geant4
Classification: Unclassified
Component: visualization/OpenGL (show other problems)
Version: 11.0
Hardware: All All
: P4 minor
Assignee: John.Allison
URL:
Depends on:
Blocks:
 
Reported: 2022-10-11 11:49 CEST by shangjiaxuan
Modified: 2022-10-16 16:31 CEST (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this problem.
Description shangjiaxuan 2022-10-11 11:49:56 CEST
Code snippet should be self-explanatory:
```
/**
   SLOT Activate by a click on the projection menu
   Warning : When G4OpenGLStoredQtViewer::DrawView() method call,
   KernelVisitDecision () will be call and will set the fNeedKernelVisit
   to 1. See G4XXXStoredViewer::CompareForKernelVisit for explanations.
   It will cause a redraw of the view
   @param check : 1 orthographic, 2 perspective
   @see G4OpenGLStoredQtViewer::DrawView
   @see G4XXXStoredViewer::CompareForKernelVisit
*/
void G4OpenGLQtViewer::toggleProjection(bool check) {

  if (check == 1) {
    fVP.SetOrthogonalProjection ();
  } else {
    fVP.SetPerspectiveProjection();
  }
  updateToolbarAndMouseContextMenu();
  updateQWidget();
}
```
Used (preprocessor limited to not `QT_VERSION < 0x050600`):
```
  fProjectionOrtho = mProjection->addAction("Orthographic", this, [this](){ this->toggleProjection(1); });
  fProjectionPerspective = mProjection->addAction("Perspective", this, [this](){ this->toggleProjection(2); });
```
Comment 1 John.Allison 2022-10-16 16:31:33 CEST
Ah, I think we have already seen this and fixed it (for the next release). The code now reads

  fProjectionOrtho = mProjection->addAction("Orthographic", this, [this](){ this->toggleProjection(true); });
  fProjectionPerspective = mProjection->addAction("Perspective", this, [this](){ this->toggleProjection(false); });
...
void G4OpenGLQtViewer::toggleProjection(bool check) {
  if (check) {
    fVP.SetOrthogonalProjection ();
  } else {
    fVP.SetPerspectiveProjection();
  }
  updateToolbarAndMouseContextMenu();
  updateQWidget();
}

Is this what you meant?

From the next release we will not support QT_VERSION < 0x051500.