Changeset 703 for trunk


Ignore:
Timestamp:
Jan 29, 2008, 6:15:49 PM (16 years ago)
Author:
garnier
Message:

Bounton perspective Ok. Inversion des commandes rotation

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/geant4/visualization/OpenGL/src/G4OpenGLQtViewer.cc

    r702 r703  
    4848#include "G4Scene.hh"
    4949#include "G4OpenGLQtExportDialog.hh"
    50 
     50#include "G4UnitsTable.hh"
    5151#include "G4Qt.hh"
    5252#include "G4UImanager.hh"
     
    416416  QPopupMenu *mRepresentation = new QPopupMenu(fContextMenu);
    417417
    418   QPopupMenu *mProjection = new QPopupMenu(fProjection);
     418  QPopupMenu *mProjection = new QPopupMenu(fContextMenu);
    419419
    420420#if QT_VERSION < 0x030200
     
    447447
    448448  QMenu *mRepresentation = mStyle->addMenu("&Representation");
     449  QMenu *mProjection = mStyle->addMenu("&Projection");
    449450  QAction *polyhedron = mRepresentation->addAction("Polyhedron");
    450451  QAction *nurbs = mRepresentation->addAction("NURBS");
    451452
    452   QAction *ortho = mRepresentation->addAction("Orthographic");
    453   QAction *perspective = mRepresentation->addAction("Persepective");
     453  QAction *ortho = mProjection->addAction("Orthographic");
     454  QAction *perspective = mProjection->addAction("Persepective");
    454455#endif
    455456
     
    10771078  fVP.SetRepStyle (style);
    10781079
    1079 #ifdef GEANT4_QT_DEBUG
    1080   printf("G4OpenGLQtViewer::toggleRepresentation 3%d\n",check);
    1081 #endif
    10821080  updateQWidget();
    1083 #ifdef GEANT4_QT_DEBUG
    1084   printf("G4OpenGLQtViewer::toggleRepresentation 4%d\n",check);
    1085 #endif
    10861081}
    10871082
     
    11011096    fVP.SetFieldHalfAngle (0);
    11021097  } else {
     1098
    11031099    // look for the default parameter hidden in G4UIcommand parameters
    11041100    G4UImanager* UI = G4UImanager::GetUIpointer();
     
    11131109
    11141110    // find param
    1115     G4UIparameter * param = NULL;
    1116 
     1111    G4UIparameter * angleParam = NULL;
    11171112    for(G4int i=0;  i<command->GetParameterEntries(); i++)
    11181113    {
    11191114      if( command->GetParameter(i)->GetParameterName() == "field-half-angle" ) {
    1120         param = command->GetParameter(i);
     1115        angleParam = command->GetParameter(i);
    11211116      }
    11221117    }
    1123     if (!param)
     1118    if (!angleParam)
    11241119      return;
    1125     G4double defaultValue = command->ConvertToDouble(param->GetDefaultValue());
    1126     G4cout << "Perspective view has been set to default value. Field half angle="<<defaultValue <<" \n" << G4endl;
    1127     fVP.SetFieldHalfAngle (defaultValue);
    1128   }
    1129  
    1130 #ifdef GEANT4_QT_DEBUG
    1131   printf("G4OpenGLQtViewer::toggleRepresentation 3%d\n",check);
    1132 #endif
     1120
     1121    // find unit
     1122    G4UIparameter * unitParam = NULL;
     1123    for(G4int i=0;  i<command->GetParameterEntries(); i++)
     1124    {
     1125      if( command->GetParameter(i)->GetParameterName() == "unit" ) {
     1126        unitParam = command->GetParameter(i);
     1127      }
     1128    }
     1129    if (!unitParam)
     1130      return;
     1131
     1132    G4double defaultValue = command->ConvertToDouble(angleParam->GetDefaultValue())
     1133                            * G4UnitDefinition::GetValueOf(unitParam->GetDefaultValue());
     1134    if (defaultValue > 89.5 || defaultValue <= 0.0) {
     1135      G4cerr << "Field half angle should be 0 < angle <= 89.5 degrees. Check your default Field half angle parameter\n";
     1136    } else {
     1137      G4cout << "Perspective view has been set to default value. Field half angle="<<angleParam->GetDefaultValue() <<" \n" << G4endl;
     1138      fVP.SetFieldHalfAngle (defaultValue);
     1139      SetView ();
     1140    }
     1141  } 
    11331142  updateQWidget();
    1134 #ifdef GEANT4_QT_DEBUG
    1135   printf("G4OpenGLQtViewer::toggleRepresentation 4%d\n",check);
    1136 #endif
    11371143}
    11381144
     
    11931199
    11941200  updateQWidget();
    1195 #ifdef GEANT4_QT_DEBUG
    1196   printf("G4OpenGLQtViewer::toggleRepresentation %d\n",check);
    1197 #endif
    11981201}
    11991202
     
    12121215  updateQWidget();
    12131216
    1214 #ifdef GEANT4_QT_DEBUG
    1215   printf("G4OpenGLQtViewer::toggleRepresentation %d\n",check);
    1216 #endif
    12171217}
    12181218
     
    12301230  updateQWidget();
    12311231
    1232 #ifdef GEANT4_QT_DEBUG
    1233   printf("G4OpenGLQtViewer::toggleRepresentation %d\n",check);
    1234 #endif
    12351232}
    12361233
     
    12441241#else
    12451242  G4cerr << "This version of G4UI Could not generate the selected format\n" << G4endl;
    1246 #endif
    1247 #ifdef GEANT4_QT_DEBUG
    1248   printf("G4OpenGLQtViewer::toggleRepresentation %d\n",check);
    12491243#endif
    12501244}
     
    14171411#endif
    14181412{
    1419   int dx = pos_x - fLastPos.x();
    1420   int dy = pos_y - fLastPos.y();
     1413  int dx = fLastPos.x() - pos_x;
     1414  int dy = fLastPos.y() - pos_y;
    14211415  if (fMouseAction == STYLE1) {  // rotate
    14221416    if (mButtons & Qt::LeftButton) {
     
    18251819  holdKeyEvent = true;
    18261820
    1827 #ifdef GEANT4_QT_DEBUG
    1828   printf("G4OpenGLQtViewer::keyPressEvent count:%d autoRepeat:%d key:%d\n",event->count(),event->isAutoRepeat(),event->key());
    1829 #endif
    1830 if (event->modifiers() & Qt::ShiftModifier)
    1831     {
    1832       printf("-------------------------\n");
    1833     }
    1834 
    18351821  if ((event->key() == Qt::Key_Down) && (event->modifiers() & Qt::ShiftModifier)) // go backward
    18361822    {
     
    18671853      updateQWidget();
    18681854    }
    1869 #ifdef GEANT4_QT_DEBUG
    1870   printf("G4OpenGLQtViewer::keyPressEvent END\n");
    1871 #endif
    18721855  holdKeyEvent = false;
    18731856}
Note: See TracChangeset for help on using the changeset viewer.