Problem 2513

Summary: G4OpenGLQtViewer::toggleProjection seems broken on qt 5.6+
Product: Geant4 Reporter: shangjiaxuan
Component: visualization/OpenGLAssignee: John.Allison
Status: RESOLVED FIXED    
Severity: minor    
Priority: P4    
Version: 11.0   
Hardware: All   
OS: All   

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.