Index: /trunk/SophyaPI/PI/pi3ddrw.cc
===================================================================
--- /trunk/SophyaPI/PI/pi3ddrw.cc	(revision 154)
+++ /trunk/SophyaPI/PI/pi3ddrw.cc	(revision 155)
@@ -239,11 +239,22 @@
 {
   mGr3d->SetBaseGraphic(mWGrC, 0, 0, XSize(), YSize());
-  float xc, yc, zc, xo, yo, zo;
+  float xo, yo, zo;
   float teta, phi, psi;
   float dax, day, co, dco;
-  mGr3d->Get3DCS(xc, yc, zc, xo, yo, zo, teta, phi, psi, dax, day, co, dco);
+  mGr3d->Get3DCS(cXc, cYc, cZc, xo, yo, zo, teta, phi, psi, dax, day, co, dco);
 //   puts("\n PIDraw3DWdg::But2Press() ");
 //   mGr3d->PrintCS();
-  lPx = x;  lPy = y;    
+  lPx = x;  lPy = y;
+
+// Pour savoir si on se trouve ds la zone centrale     
+  int czx = XSize()/10;
+  int czy = YSize()/10;
+  int dmix = x-XSize()/2;
+  int dmiy = y-YSize()/2;
+  if (dmix < 0) dmix = -dmix;
+  if (dmiy < 0) dmiy = -dmiy;
+  if ((dmix < czx) && (dmiy < czy))  rOfg = true;
+  else rOfg = false;
+
   cUlen = 0.5*(dax+day)*co*0.3;    cDax = dax;   cDay = day;  clCO = co; 
   cTeta = teta;   cPhi = phi;
@@ -260,4 +271,6 @@
 */
   DrawXYZAxes();
+  if (rOfg)  { czx /= 2;   czy /= 2;  mWGrC->DrawBox(XSize()/2-czx, YSize()/2-czy, czx*2, czy*2); }
+ 
   Send(Msg(), PIMsg_Active);
   PIDrwTools::SetCurrentBaseWdg(this);
@@ -268,9 +281,16 @@
 {
   DrawXYZAxes();
-  float phi = M_PI+cPhi;
-  float teta = M_PI-cTeta;
-  phi += (M_PI*0.4*(float)(x-lPx)/XSize());
-  teta -= (M_PI*0.4*(float)(y-lPy)/YSize());
-  mGr3d->RotateObserver(teta, phi, 0., false);
+  float teta, phi;
+
+  if (rOfg) { 
+    phi = cPhi + (M_PI*0.25*(float)(x-lPx)/XSize());
+    teta = cTeta - (M_PI*0.25*(float)(y-lPy)/YSize());
+    mGr3d->RotateObject(teta, phi, false);
+    }
+  else {
+    phi = cPhi - (M_PI*0.5*(float)(x-lPx)/XSize());
+    teta = cTeta + (M_PI*0.5*(float)(y-lPy)/YSize());
+    mGr3d->RotateObserver(teta, phi, 0., false);
+    }
 /*  {
   char buff[256];
@@ -287,4 +307,10 @@
 {
   DrawXYZAxes();
+  if (rOfg) {
+    int czx = XSize()/20;
+    int czy = YSize()/20;
+    mWGrC->DrawBox(XSize()/2-czx, YSize()/2-czy, czx*2, czy*2);
+    }
+
 //  puts("\n PIDraw3DWdg::But2Release()");
 //  mGr3d->PrintCS();
@@ -299,8 +325,8 @@
 void PIDraw3DWdg::But3Press(int x, int y)
 {
-  float xc, yc, zc, xo, yo, zo;
+  float xo, yo, zo;
   float teta, phi, psi;
   float dax, day, co, dco;
-  mGr3d->Get3DCS(xc, yc, zc, xo, yo, zo, teta, phi, psi, dax, day, co, dco);
+  mGr3d->Get3DCS(cXc, cYc, cZc, xo, yo, zo, teta, phi, psi, dax, day, co, dco);
   mGr3d->SetBaseGraphic(mWGrC, 0, 0, XSize(), YSize());
   lPx = x;  lPy = y;  
@@ -364,22 +390,21 @@
   mWGrC->SelGOMode(PI_GOXOR);
   PIGrCoord x1,y1,z1,x2,y2,z2;
-  float xc,yc,zc,xo,yo,zo,teta,phi,psi,dax,day,co,dco;
-  mGr3d->Get3DCS(xc,yc,zc,xo,yo,zo,teta,phi,psi,dax,day,co,dco);
-  float len = cUlen;
-  x1 = xc;  y1 = yc;  z1 = zc;
-  x2 = xc+len;   y2 = yc;   z2 = zc; 
+  x1 = cXc;  y1 = cYc;  z1 = cZc;
+  x2 = cXc+cUlen;   y2 = cYc;   z2 = cZc; 
   mGr3d->DrawLine3D(x1, y1, z1, x2, y2, z2);
-  x2 = xc+len*1.1;
+  x2 = cXc+cUlen*1.1;
   mGr3d->DrawString3D(x2, y2, z2, "X");
-  x2 = xc;   y2 = yc+len;   z2 = zc; 
+  x2 = cXc;   y2 = cYc+cUlen;   z2 = cZc; 
   mGr3d->DrawLine3D(x1, y1, z1, x2, y2, z2);
-  y2 = yc+len*1.1;
+  y2 = cYc+cUlen*1.1;
   mGr3d->DrawString3D(x2, y2, z2, "Y");   
-  x2 = xc;   y2 = yc;   z2 = zc+len; 
+  x2 = cXc;   y2 = cYc;   z2 = cZc+cUlen; 
   mGr3d->DrawLine3D(x1, y1, z1, x2, y2, z2);
-  z2 = zc+len*1.1;
+  z2 = cZc+cUlen*1.1;
   mGr3d->DrawString3D(x2, y2, z2, "Z");   
 //   mGr3d->DrawCircle(0., 0., daxO*0.30);
   char buff[256];
+  float xc,yc,zc,xo,yo,zo,teta,phi,psi,dax,day,co,dco;
+  mGr3d->Get3DCS(xc,yc,zc,xo,yo,zo,teta,phi,psi,dax,day,co,dco);
   sprintf(buff, " C: %g %g %g -> O: %g %g %g  (T/P0= %g %g)     ", xc,yc,zc, xo, yo, zo, cTeta, cPhi);
   mWGrC->DrawString(0,20,buff);
Index: /trunk/SophyaPI/PI/pi3ddrw.h
===================================================================
--- /trunk/SophyaPI/PI/pi3ddrw.h	(revision 154)
+++ /trunk/SophyaPI/PI/pi3ddrw.h	(revision 155)
@@ -85,6 +85,8 @@
   int lPx, lPy;         // dernier position pointeur
   PIColors lCol;        // Couleur
-  float cTeta, cPhi, cUlen;    // Pour garder valeurs avant rotation, Unite de longeur 
+  float cTeta, cPhi, cUlen;    // Pour garder valeurs avant rotation, Unite de longeur
+  float cXc, cYc, cZc;         // Pour garder position du centre de champ 
   float clCO, cDax, cDay;      // Pour garder les valeurs avant Zoom In/Out
+  bool  rOfg;                  // Vrai si on fait tourner l'objet et pas la camera
 };
 
Index: /trunk/SophyaPI/PI/pigraph3d.cc
===================================================================
--- /trunk/SophyaPI/PI/pigraph3d.cc	(revision 154)
+++ /trunk/SophyaPI/PI/pigraph3d.cc	(revision 155)
@@ -43,8 +43,9 @@
   sO = true;
   xO = xo;  yO = yo;  zO = zo;
-  if (teta > M_PI)  teta = M_PI;
-  if (teta < 0.) teta = 0.;
-  if (phi < 0.)  phi = 0.;
-  if (phi > deuxpi) phi = deuxpi;
+  while (teta < 0.)  teta += deuxpi;
+  while (teta > deuxpi)  teta -= deuxpi;
+  if (teta > M_PI)  { teta = M_PI-teta;  phi = phi+M_PI; }
+  while (phi < 0.)  phi += deuxpi;
+  while (phi > deuxpi) phi -= deuxpi;
   tO = teta;  fO = phi;  pO = psi;
   if (dax < 0.) dax = -dax;
@@ -52,5 +53,6 @@
   daxO = dax;  dayO = day;
   lCO = co;   dlCO = dco;
-  SetUCS(-dax, dax, -day, day, kAxeDirLtoR, kAxeDirDownUp);
+// Si on ne met  kAxeDirLtoR, le repere semble etre ds le sens inverse -> kAxeDirRtoL  , Reza 16/10/98
+  SetUCS(-dax, dax, -day, day, kAxeDirRtoL, kAxeDirDownUp);
   double ct = cos((double)tO);
   double st = sin((double)tO);
@@ -87,5 +89,6 @@
   if (day < 0.) day = -day;
   daxO = dax;  dayO = day;  
-  SetUCS(-dax, dax, -day, day, kAxeDirLtoR, kAxeDirDownUp);
+// Si on ne met  kAxeDirLtoR, le repere semble etre ds le sens inverse -> kAxeDirRtoL  , Reza 16/10/98
+  SetUCS(-dax, dax, -day, day, kAxeDirRtoL, kAxeDirDownUp);
   lCO = sqrt(dx*dx+dy*dy+dz*dz);
   if (lCO < 1.e-6) {
@@ -164,17 +167,41 @@
 /* --Methode-- */
 void PIGraphic3D::RotateObserver(float teta, float phi, float psi, bool rel)
+// Positionne l'observateur (la camera) de maniere a ce que la direction de 
+// visee soit tO=teta, pO=phi (rel=false) / tO+=teta pO+=phi (rel=true) 
+// en conservant le centre de champ fixe  
 {
   if (rel) {
-    teta = M_PI-tO-teta;
-    phi = M_PI+fO+phi;
-    psi = pO+psi;
+    teta += tO;
+    phi += fO;
+    psi += pO;
     }
-  if (teta < 0.) teta = 0.;
-  if (teta > M_PI)  teta = M_PI;
+  while (teta < 0.)  teta += deuxpi;
+  while (teta > deuxpi)  teta -= deuxpi;
+  if (teta > M_PI)  { teta = M_PI-teta;  phi = phi+M_PI; }
   float xo,yo,zo; 
-  zo = cos((double)teta)*lCO+zC;
-  xo = sin((double)teta)*cos((double)phi)*lCO+xC;
-  yo = sin((double)teta)*sin((double)phi)*lCO+yC;
+  zo = -cos((double)teta)*lCO+zC;
+  xo = -sin((double)teta)*cos((double)phi)*lCO+xC;
+  yo = -sin((double)teta)*sin((double)phi)*lCO+yC;
   Set3DCS(xC,yC,zC, xo,yo,zo, daxO, dayO, dlCO, psi);
+}
+
+/* --Methode-- */
+void PIGraphic3D::RotateObject(float teta, float phi, bool rel)
+// Positionne l'objet (centre du champ) de maniere a ce que la direction de 
+// visee soit tO=teta, pO=phi (rel=false) / tO+=teta pO+=phi (rel=true) 
+// en conservant la position de l'observateur fixe.  
+{
+  if (rel) {
+    teta += tO;
+    phi += fO;
+    }
+  while (teta < 0.)  teta += deuxpi;
+  while (teta > deuxpi)  teta -= deuxpi;
+  if (teta > M_PI)  { teta = M_PI-teta;  phi = phi+M_PI; }
+  float xc,yc,zc; 
+  zc = cos((double)teta)*lCO+zO;
+  xc = sin((double)teta)*cos((double)phi)*lCO+xO;
+  yc = sin((double)teta)*sin((double)phi)*lCO+yO;
+  Set3DCS(xc,yc,zc, xO,yO,zO, daxO, dayO, dlCO, pO);
 }
 
@@ -207,5 +234,5 @@
   xc = x-xO;   yc = y-yO;    zc = z-zO;
   xp = RE[0][0]*xc+RE[0][1]*yc+RE[0][2]*zc;
-  yp = RE[1][0]*xc+RE[1][1]*yc+RE[1][2]*zc;  
+  yp = -RE[1][0]*xc+RE[1][1]*yc+RE[1][2]*zc;  
   zp = RE[2][0]*xc+RE[2][1]*yc+RE[2][2]*zc;
 }
Index: /trunk/SophyaPI/PI/pigraph3d.h
===================================================================
--- /trunk/SophyaPI/PI/pigraph3d.h	(revision 154)
+++ /trunk/SophyaPI/PI/pigraph3d.h	(revision 155)
@@ -28,4 +28,5 @@
   virtual void       PrintCS();  // Pour debugger
   virtual void       RotateObserver(float teta, float phi, float psi=0., bool rel=true);
+  virtual void       RotateObject(float teta, float phi, bool rel=true);
   virtual void       ZoomInOut(float fco, float fdax, float fday, bool rel=true);
 
