Index: trunk/geant4/visualization/OpenGL/src/G4OpenGLQtViewer.cc
===================================================================
--- trunk/geant4/visualization/OpenGL/src/G4OpenGLQtViewer.cc	(revision 701)
+++ trunk/geant4/visualization/OpenGL/src/G4OpenGLQtViewer.cc	(revision 702)
@@ -50,6 +50,6 @@
 
 #include "G4Qt.hh"
-#include "G4UIsession.hh"
 #include "G4UImanager.hh"
+#include "G4UIcommandTree.hh"
 #include <qapplication.h>
 #include <qlayout.h>
@@ -288,4 +288,5 @@
   ,fDeltaSceneTranslation(1/100)
   ,fDeltaZoom(2)
+  ,holdKeyEvent(false)
 {
 #ifdef GEANT4_QT_DEBUG
@@ -415,16 +416,29 @@
   QPopupMenu *mRepresentation = new QPopupMenu(fContextMenu);
 
+  QPopupMenu *mProjection = new QPopupMenu(fProjection);
+
 #if QT_VERSION < 0x030200
   QAction *polyhedron = new QAction("&Polyhedron","&Polyhedron",CTRL+Key_P,mRepresentation);
   QAction *nurbs = new QAction("&NURBS","&NURBS",CTRL+Key_N,mRepresentation);
+
+  QAction *ortho = new QAction("&Orthographic","&Orthographic",CTRL+Key_O,mProjection);
+  QAction *perspective = new QAction("&Perspective","&Perspective",CTRL+Key_P,mProjection);
 #else
   QAction *polyhedron = new QAction("&Polyhedron",CTRL+Key_P,mRepresentation);
   QAction *nurbs = new QAction("&NURBS",CTRL+Key_N,mRepresentation);
+
+  QAction *ortho = new QAction("&Orthographic",CTRL+Key_O,mProjection);
+  QAction *perspective = new QAction("&Perspective",CTRL+Key_P,mProjection);
 #endif
   polyhedron->addTo(mRepresentation);
   nurbs->addTo(mRepresentation);
 
+  ortho->addTo(mProjection);
+  perspective->addTo(mProjection);
+
   mStyle->insertItem("&Representation",mRepresentation);
+  mStyle->insertItem("&Projection",mProjection);
   fContextMenu->insertItem("&Style",mStyle);
+
 
 #else
@@ -435,6 +449,10 @@
   QAction *polyhedron = mRepresentation->addAction("Polyhedron");
   QAction *nurbs = mRepresentation->addAction("NURBS");
-#endif
-  // INIT mStyle
+
+  QAction *ortho = mRepresentation->addAction("Orthographic");
+  QAction *perspective = mRepresentation->addAction("Persepective");
+#endif
+
+  // INIT mRepresentation
   G4ViewParameters::RepStyle style;
   style = fVP.GetRepStyle();
@@ -447,4 +465,10 @@
   }
 
+  // INIT mProjection
+  if (fVP.GetFieldHalfAngle() == 0) {
+    createRadioAction(ortho, perspective,SLOT(toggleProjection(bool)),1);
+  } else {
+    createRadioAction(ortho, perspective,SLOT(toggleProjection(bool)),2);
+  }
 
 #if QT_VERSION < 0x040000
@@ -887,6 +911,6 @@
     G4cout << "Clic and move mouse to rotate Volume \n" << G4endl;
     G4cout << "Press left/right arrows to move camera left/right\n" << G4endl;
-    G4cout << "Press up/down arrows to move camera toward/forward\n" << G4endl;
-    G4cout << "Press SHIFT+up/down arrows to move camera up/down\n" << G4endl;
+    G4cout << "Press up/down arrows to move camera up/down\n" << G4endl;
+    G4cout << "Press SHIFT+up/down arrows to move camera toward/forward\n" << G4endl;
     G4cout << "Press +/- to zoom into volume\n" << G4endl;
 #if QT_VERSION < 0x040000
@@ -1061,4 +1085,56 @@
 #endif
 }
+
+/**
+   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.SetFieldHalfAngle (0);
+  } else {
+    // look for the default parameter hidden in G4UIcommand parameters
+    G4UImanager* UI = G4UImanager::GetUIpointer();
+    if(UI==NULL)
+      return;
+    G4UIcommandTree * treeTop = UI->GetTree();
+
+    // find command
+    G4UIcommand* command = treeTop->FindPath("/vis/viewer/set/projection");
+    if (!command)
+      return;
+
+    // find param
+    G4UIparameter * param = NULL;
+
+    for(G4int i=0;  i<command->GetParameterEntries(); i++)
+    {
+      if( command->GetParameter(i)->GetParameterName() == "field-half-angle" ) {
+        param = command->GetParameter(i);
+      }
+    }
+    if (!param)
+      return;
+    G4double defaultValue = command->ConvertToDouble(param->GetDefaultValue()); 
+    G4cout << "Perspective view has been set to default value. Field half angle="<<defaultValue <<" \n" << G4endl;
+    fVP.SetFieldHalfAngle (defaultValue);
+  }
+  
+#ifdef GEANT4_QT_DEBUG
+  printf("G4OpenGLQtViewer::toggleRepresentation 3%d\n",check);
+#endif
+  updateQWidget();
+#ifdef GEANT4_QT_DEBUG
+  printf("G4OpenGLQtViewer::toggleRepresentation 4%d\n",check);
+#endif
+}
+
 
 /**
@@ -1744,4 +1820,9 @@
 void G4OpenGLQtViewer::G4keyPressEvent (QKeyEvent * event) 
 {
+  if (holdKeyEvent)
+    return;
+
+  holdKeyEvent = true;
+
 #ifdef GEANT4_QT_DEBUG
   printf("G4OpenGLQtViewer::keyPressEvent count:%d autoRepeat:%d key:%d\n",event->count(),event->isAutoRepeat(),event->key());
@@ -1752,19 +1833,19 @@
     }
 
-  if ((event->key() == Qt::Key_Down) && (event->modifiers() & Qt::ShiftModifier)) // go up
+  if ((event->key() == Qt::Key_Down) && (event->modifiers() & Qt::ShiftModifier)) // go backward
+    {
+      G4MouseMoveEvent(0,0,1);
+    }
+  else if ((event->key() == Qt::Key_Up) && (event->modifiers() & Qt::ShiftModifier))  // go forward
+    {
+      G4MouseMoveEvent(0,0,-1);
+    }
+ else if (event->key() == Qt::Key_Down) // go down
     {
       G4MouseMoveEvent(0,1,0);
     }
-  else if ((event->key() == Qt::Key_Up) && (event->modifiers() & Qt::ShiftModifier))  // go down
+  else if (event->key() == Qt::Key_Up)  // go up
     {
       G4MouseMoveEvent(0,-1,0);
-    }
- else if (event->key() == Qt::Key_Down) // go backward
-    {
-      G4MouseMoveEvent(0,0,-1);
-    }
-  else if (event->key() == Qt::Key_Up)  // go forward
-    {
-      G4MouseMoveEvent(0,0,1);
     }
   else if (event->key() == Qt::Key_Left) // go left
@@ -1786,4 +1867,8 @@
       updateQWidget();
     }
+#ifdef GEANT4_QT_DEBUG
+  printf("G4OpenGLQtViewer::keyPressEvent END\n");
+#endif
+  holdKeyEvent = false;
 }
 
@@ -1811,2 +1896,3 @@
 }
 */
+
