Changeset 158 in Sophya for trunk/SophyaPI/PI/pigraph3d.cc


Ignore:
Timestamp:
Nov 16, 1998, 6:35:42 PM (27 years ago)
Author:
ercodmgr
Message:

1/ Mise en place des LayoutMgr pour les PIContainer avec ZoneLayout/ StackLayout
2/ Nouvelles methodes pour PIGraphic (DrawOval() DrawArc ...)
3/ Modifs ds PIGraphicX (preparation pour les GraphicBufferX)
4/ Petites modifs pour PIGraphic (HugeFontSize, etc...)
5/ Support pour titre de trace ds PIElDrawer -> PIScDrawer et PI3dDrawWdg
6/ Documentation(AutoDoc) PIGraphic PIBaseWdg ... Reza 16/11/98

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/SophyaPI/PI/pigraph3d.cc

    r155 r158  
    66#include <math.h>
    77#include "pigraph3d.h"
     8
     9//++
     10// Class        PIGraphic3D
     11// Lib          PI
     12// include      pigraph3d.h
     13//
     14//      Classe fournissant les services de tracé graphique
     15//      en coordonnées utilisateur, et quelques primitives de tracé 3D
     16//--
     17//++
     18// Links        Parent
     19// PIGraphicUC
     20//--
     21
     22//++
     23// Titre        Constructeurs, méthodes
     24//--
     25//++
     26// PIGraphic3D(PIGraphicGen* g, PIGrCoord x0, PIGrCoord y0, PIGrCoord dx, PIGrCoord dy)
     27//      Constructeur d'un objet "PIGraph3D" à partir d'un "PIGraphic* g". L'espace
     28//      de travail du nouvel objet "PIGraphic" correspond au rectangle défini par
     29//      "(x0,y0)" , "dx,dy" du "PIGraphic" de départ.
     30//
     31// int  kind()
     32//      Renvoie le type ("= PI_3DGraphics")
     33//--
    834
    935/* --Methode-- */
     
    3359  return PI_3DGraphics;
    3460}
     61
     62//++
     63// Titre        Système de coordonnées 3D et projection
     64//      Le système de coordonnées 3D est défini par la position de l'observateur (caméra),
     65//      la direction de visée ou la position du centre du champ,
     66//      l'ouverture angulaire de la caméra selon les deux
     67//      axes de la projection (X,Y), eventuellement un angle correspondant à la rotation
     68//      du plan image ("psi"). Les angles d'Euler ("teta", "phi", "psi" ) sont utilisés
     69//      dans la définition du système de coordonnées et la projection est de type
     70//      perspective.
     71//
     72//      Les coordonnées utilisateur définissant le plan image ("PIGraphicUC") vont de
     73//      X: "-dax , +dax"   Y : "-day , +day". 
     74//--
     75
     76//++
     77// void  Set3DCS_Obs(float xo, float yo, float zo, float teta, float phi, float psi, -
     78//                  float dax, float day, float co, float dco=0.2)
     79//      Définition du système de projection 3D à l'aide de la position de l'observateur
     80//      et de la direction de visée.
     81//|     xo,yo,zo : Position de l'observateur (camera)
     82//|     teta,phi : Direction de visee
     83//|     psi : rotation du plan image
     84//|     dax , day : Ouverture du plan image selon les deux axes = Xmax,Ymax / Z
     85//|     co : distance au centre du champ
     86//|     dco : profondeur de champ
     87//
     88// void  Set3DCS(float xc, float yc, float zc, float xo, float yo, float zo, -
     89//               float dax, float day, float dco=0.2, float psi=0.)
     90//      Définition du système de projection 3D à partir de la position de l'observateur et
     91//      du centre du champ.
     92//|     xc,yc,zc : Position du centre du champ
     93//|     xo,yo,zo : Position de l'observateur (camera)
     94//|     dax , day : Ouverture du plan image selon les deux axes = Xmax,Ymax / Z
     95//|     dco : profondeur de champ
     96//|     psi : rotation du plan image
     97//--
    3598
    3699static float deuxpi = 2*M_PI;
     
    128191}
    129192
     193//++
     194// bool Get3DCS(float& xc, float& yc, float& zc, float& xo, float& yo, float& zo, -
     195//             float& teta, float& phi, float& psi, float& dax, float& day, float& co, float& dco);
     196//      Renvoie les paramètres de définition du système de projection 3D.
     197//      "Rc= true" si défini par  "Set3DCS_Obs()"
     198//     
     199// void  RotateObserver(float teta, float phi, float psi=0., bool rel=true)
     200//      Positionne l'observateur (la caméra) en maintenant la position 
     201//      du centre de champ fixe. Si "rel=false" : "teta, phi" determine la nouvelle
     202//      direction de visée. Si "rel=false" : la direction de visée est tournée
     203//      de l'angle "teta,phi".
     204// void  RotateObject(float teta, float phi, bool rel=true)
     205//      Repostionne le centre du champ en maintenant la position de l'observateur fixe.
     206//      Si "rel=false" : "teta, phi" determine la nouvelle direction de visée.
     207//      Si "rel=false" : la direction de visée est tournée de l'angle "teta,phi".
     208//
     209// void  ZoomInOut(float fco, float fdax, float fday, bool rel=true)
     210//      Eloigne ou approche l'observateur et modifie l'ouverture du plan image.
     211//      si "real=true" : "fco, fdax, fday" sont des facteurs multiplicatifs
     212//      par rapport aux valeurs actuelles, sinon des valeurs absolues.
     213//|     fco : distance observateur - centre du champ
     214//|     fdax, fday : ouverture du plan image
     215//--
    130216
    131217/* --Methode-- */
     
    141227}
    142228
     229
     230/* --Methode-- */
     231void PIGraphic3D::RotateObserver(float teta, float phi, float psi, bool rel)
     232// Positionne l'observateur (la camera) de maniere a ce que la direction de
     233// visee soit tO=teta, pO=phi (rel=false) / tO+=teta pO+=phi (rel=true)
     234// en conservant le centre de champ fixe 
     235{
     236  if (rel) {
     237    teta += tO;
     238    phi += fO;
     239    psi += pO;
     240    }
     241  while (teta < 0.)  teta += deuxpi;
     242  while (teta > deuxpi)  teta -= deuxpi;
     243  if (teta > M_PI)  { teta = M_PI-teta;  phi = phi+M_PI; }
     244  float xo,yo,zo;
     245  zo = -cos((double)teta)*lCO+zC;
     246  xo = -sin((double)teta)*cos((double)phi)*lCO+xC;
     247  yo = -sin((double)teta)*sin((double)phi)*lCO+yC;
     248  Set3DCS(xC,yC,zC, xo,yo,zo, daxO, dayO, dlCO, psi);
     249}
     250
     251/* --Methode-- */
     252void PIGraphic3D::RotateObject(float teta, float phi, bool rel)
     253// Positionne l'objet (centre du champ) de maniere a ce que la direction de
     254// visee soit tO=teta, pO=phi (rel=false) / tO+=teta pO+=phi (rel=true)
     255// en conservant la position de l'observateur fixe. 
     256{
     257  if (rel) {
     258    teta += tO;
     259    phi += fO;
     260    }
     261  while (teta < 0.)  teta += deuxpi;
     262  while (teta > deuxpi)  teta -= deuxpi;
     263  if (teta > M_PI)  { teta = M_PI-teta;  phi = phi+M_PI; }
     264  float xc,yc,zc;
     265  zc = cos((double)teta)*lCO+zO;
     266  xc = sin((double)teta)*cos((double)phi)*lCO+xO;
     267  yc = sin((double)teta)*sin((double)phi)*lCO+yO;
     268  Set3DCS(xc,yc,zc, xO,yO,zO, daxO, dayO, dlCO, pO);
     269}
     270
     271/* --Methode-- */
     272void PIGraphic3D::ZoomInOut(float fco, float fdax, float fday, bool rel)
     273{
     274  if (fco < 0.001) fco = 1.;
     275  if (fdax < 0.001) fdax = 1.;
     276  if (fday < 0.001) fday = 1.;
     277  double dl;
     278  if (rel) {
     279    dl = fco*lCO; 
     280    fdax *= daxO;
     281    fday *= dayO;
     282  }
     283  else dl = fco;
     284  float xo,yo,zo;
     285  if (dl < 1.e-5) dl = 1.e-5;
     286  zo = zC-cos((double)tO)*dl;
     287  xo = xC-sin((double)tO)*cos((double)fO)*dl;
     288  yo = yC-sin((double)tO)*sin((double)fO)*dl;
     289  Set3DCS(xC,yC,zC, xo,yo,zo, fdax, fday, dlCO, pO);
     290//  Set3DCS_Obs(xo, yo, zo, tO, fO, pO, daxO*fda, dayO*fda, dl, dlCO);
     291}
     292
     293/* --Methode-- */
     294void PIGraphic3D::C3DC2ObsCS(float x, float y, float z, float& xp, float& yp, float& zp)
     295{
     296  double xc, yc, zc;
     297  xc = x-xO;   yc = y-yO;    zc = z-zO;
     298  xp = RE[0][0]*xc+RE[0][1]*yc+RE[0][2]*zc;
     299  yp = -RE[1][0]*xc+RE[1][1]*yc+RE[1][2]*zc; 
     300  zp = RE[2][0]*xc+RE[2][1]*yc+RE[2][2]*zc;
     301}
     302
     303/* --Methode-- */
     304void PIGraphic3D::Proj3DC2GrC(float x, float y, float z, float& xpix, float& ypix)
     305{
     306  double xc, yc, zc;
     307  float xp, yp, zp;
     308  xc = x-xO;   yc = y-yO;    zc = z-zO;
     309  xp = RE[0][0]*xc+RE[0][1]*yc+RE[0][2]*zc;   
     310  yp = RE[1][0]*xc+RE[1][1]*yc+RE[1][2]*zc;
     311  zp = RE[2][0]*xc+RE[2][1]*yc+RE[2][2]*zc;
     312  if ((zp>-1.e-6) && (zp < 1.e-6))   // Protection Divide/0
     313    { xpix = ypix = 0.;   return; }
     314  xpix = (float)(xOrg + (xp/zp)*xScale);
     315  ypix = (float)(yOrg + (yp/zp)*yScale);
     316//  printf("-DBG-Proj3DC2GrC() %g %g %g -> %g %g %g -> %g %g %g -> (%g %g)\n", x,y,z,xc,yc,zc,xp,yp,zp,xp/zp,yp/zp);
     317//  printf("-DBG- ... (%g %g %g - %g %g) %g %g - %g %g -> %g %g \n", xO,yO,zO, tO,fO, xOrg, yOrg,xScale,yScale ,xpix,ypix);
     318}
     319
     320//++
     321// Titre        Primitives de tracé 3D
     322//--
     323//++
     324// void  DrawString3D(PIGrCoord x0, PIGrCoord y0, PIGrCoord z0, char* s)
     325//      Tracé de chaîne de caractères à la position "(x0,y0,z0)"
     326// void  DrawOpaqueString3D(PIGrCoord x0, PIGrCoord y0, PIGrCoord z0, char* s)
     327//      Tracé de chaîne opaque à la position "(x0,y0,z0)"
     328// void  DrawLine3D(PIGrCoord x1, PIGrCoord y1, PIGrCoord z1, -
     329//                  PIGrCoord x2, PIGrCoord y2, PIGrCoord z2)
     330//      Tracé d'une ligne entre les deux points "(x1,y1,z1)" et "(x2,y2,z2)"
     331// void  DrawPolygon3D(PIGrCoord *x, PIGrCoord *y, PIGrCoord *z, int n)
     332//      Tracé de contour de polygone - sommets définis par le tableau
     333//      "(x[i],y[i],z[i])" , "i=0..n-1"
     334// void  DrawFPolygon3D(PIGrCoord *x, PIGrCoord *y, PIGrCoord *z, int n)
     335//      Tracé de polygone - "(x[i],y[i],z[i])" , "i=0..n-1"
     336// void  DrawMarker3D(PIGrCoord x0, PIGrCoord y0, PIGrCoord z0)
     337//      Tracé d'un signe (marker) au point "(x0,y0,z0)"
     338// void  DrawMarkers3D(PIGrCoord *x, PIGrCoord *y, PIGrCoord *z, int n)
     339//      Tracé de signes (marker) aux points "(x[i],y[i],z[i])" , "i=0..n-1"
     340//--
     341
     342/* --Methode-- */
     343void PIGraphic3D::DrawString3D(PIGrCoord x0, PIGrCoord y0, PIGrCoord z0, const char* s)
     344{
     345  if (!mGrC) return;
     346  float xf, yf;
     347  Proj3DC2GrC(x0, y0, z0, xf, yf);
     348  mGrC->DrawString(xf, yf, s);
     349  return;
     350}
     351
     352/* --Methode-- */
     353void PIGraphic3D::DrawOpaqueString3D(PIGrCoord x0, PIGrCoord y0, PIGrCoord z0, const char* s)
     354{
     355  if (!mGrC) return;
     356  float xf, yf;
     357  Proj3DC2GrC(x0, y0, z0, xf, yf);
     358  mGrC->DrawOpaqueString(xf, yf, s);
     359  return;
     360}
     361
     362/* --Methode-- */
     363void PIGraphic3D::DrawLine3D(PIGrCoord x1, PIGrCoord y1, PIGrCoord z1,
     364                             PIGrCoord x2, PIGrCoord y2, PIGrCoord z2)
     365{
     366  if (!mGrC) return;
     367  float xf1, yf1, xf2, yf2;
     368  Proj3DC2GrC(x1, y1, z1, xf1, yf1);
     369  Proj3DC2GrC(x2, y2, z2, xf2, yf2);
     370//  printf("-DBG-DrawLine3D() : %g %g %g -> %g %g | %g %g %g -> %g %g\n",
     371//         (float)x1, (float)y1, (float)z1, xf1, yf1,
     372//         (float)x2, (float)y2, (float)z2, xf2, yf2 );
     373  mGrC->DrawLine(xf1, yf1, xf2, yf2);
     374}
     375
     376#define NMXMULTP  30   // Pour multipoint sans new
     377
     378/* --Methode-- */
     379void PIGraphic3D::DrawPolygon3D(PIGrCoord *x, PIGrCoord *y, PIGrCoord *z, int n)
     380{
     381  PIGrCoord xc[NMXMULTP], yc[NMXMULTP];
     382  PIGrCoord *pxc, *pyc;
     383  int i;
     384  float xf, yf;
     385 
     386  if (!mGrC) return;
     387  if (n <= 0)  return;
     388
     389  if (n > NMXMULTP) { pxc = new PIGrCoord[n];  pyc = new PIGrCoord[n];  }
     390  else { pxc = xc;  pyc = yc; }
     391  for(i=0; i<n; i++) {
     392    Proj3DC2GrC(x[i], y[i], z[i], xf, yf);
     393    pxc[i] = xf;  pyc[i] = yf;
     394  }
     395  mGrC->DrawPolygon(pxc, pyc, n, false);
     396  if (n > NMXMULTP) { delete[] pxc;  delete[] pyc; }
     397  return;
     398}
     399
     400
     401/* --Methode-- */
     402void PIGraphic3D::DrawFPolygon3D(PIGrCoord *x, PIGrCoord *y, PIGrCoord *z, int n)
     403{
     404  PIGrCoord xc[NMXMULTP], yc[NMXMULTP];
     405  PIGrCoord *pxc, *pyc;
     406  int i;
     407  float xf, yf;
     408 
     409  if (!mGrC) return;
     410  if (n <= 0)  return;
     411
     412  if (n > NMXMULTP) { pxc = new PIGrCoord[n];  pyc = new PIGrCoord[n];  }
     413  else { pxc = xc;  pyc = yc; }
     414  for(i=0; i<n; i++) {
     415    Proj3DC2GrC(x[i], y[i], z[i], xf, yf);
     416    pxc[i] = xf;  pyc[i] = yf;
     417  }
     418  mGrC->DrawFPolygon(pxc, pyc, n, false);
     419  if (n > NMXMULTP) { delete[] pxc;  delete[] pyc; }
     420  return;
     421}
     422
     423/* --Methode-- */
     424void PIGraphic3D::DrawMarker3D(PIGrCoord x0, PIGrCoord y0, PIGrCoord z0)
     425{
     426  if (!mGrC) return;
     427  float xf, yf;
     428  Proj3DC2GrC(x0, y0, z0, xf, yf);
     429  mGrC->DrawMarker(xf, yf);
     430  return;
     431}
     432
     433/* --Methode-- */
     434void PIGraphic3D::DrawMarkers3D(PIGrCoord *x, PIGrCoord *y, PIGrCoord *z, int n)
     435{
     436  PIGrCoord xc[NMXMULTP], yc[NMXMULTP];
     437  PIGrCoord *pxc, *pyc;
     438  int i;
     439  float xf, yf;
     440 
     441  if (!mGrC) return;
     442  if (n <= 0)  return;
     443
     444  if (n > NMXMULTP) { pxc = new PIGrCoord[n];  pyc = new PIGrCoord[n]; }
     445  else { pxc = xc;  pyc = yc; }
     446  for(i=0; i<n; i++) {
     447    Proj3DC2GrC(x[i], y[i], z[i], xf, yf);
     448    pxc[i] = xf;  pyc[i] = yf;
     449  }
     450  mGrC->DrawMarkers(pxc, pyc, n);
     451  if (n > NMXMULTP) { delete[] pxc;  delete[] pyc; }
     452  return;
     453}
     454
     455
     456//  Methode pour debugger
    143457/* --Methode-- */
    144458void PIGraphic3D::PrintCS()
     
    164478printf("C+(0,1,1) -> %g %g %g -> %g %g \n", xp, yp, zp, xpix, ypix);
    165479}
    166 
    167 /* --Methode-- */
    168 void PIGraphic3D::RotateObserver(float teta, float phi, float psi, bool rel)
    169 // Positionne l'observateur (la camera) de maniere a ce que la direction de
    170 // visee soit tO=teta, pO=phi (rel=false) / tO+=teta pO+=phi (rel=true)
    171 // en conservant le centre de champ fixe 
    172 {
    173   if (rel) {
    174     teta += tO;
    175     phi += fO;
    176     psi += pO;
    177     }
    178   while (teta < 0.)  teta += deuxpi;
    179   while (teta > deuxpi)  teta -= deuxpi;
    180   if (teta > M_PI)  { teta = M_PI-teta;  phi = phi+M_PI; }
    181   float xo,yo,zo;
    182   zo = -cos((double)teta)*lCO+zC;
    183   xo = -sin((double)teta)*cos((double)phi)*lCO+xC;
    184   yo = -sin((double)teta)*sin((double)phi)*lCO+yC;
    185   Set3DCS(xC,yC,zC, xo,yo,zo, daxO, dayO, dlCO, psi);
    186 }
    187 
    188 /* --Methode-- */
    189 void PIGraphic3D::RotateObject(float teta, float phi, bool rel)
    190 // Positionne l'objet (centre du champ) de maniere a ce que la direction de
    191 // visee soit tO=teta, pO=phi (rel=false) / tO+=teta pO+=phi (rel=true)
    192 // en conservant la position de l'observateur fixe. 
    193 {
    194   if (rel) {
    195     teta += tO;
    196     phi += fO;
    197     }
    198   while (teta < 0.)  teta += deuxpi;
    199   while (teta > deuxpi)  teta -= deuxpi;
    200   if (teta > M_PI)  { teta = M_PI-teta;  phi = phi+M_PI; }
    201   float xc,yc,zc;
    202   zc = cos((double)teta)*lCO+zO;
    203   xc = sin((double)teta)*cos((double)phi)*lCO+xO;
    204   yc = sin((double)teta)*sin((double)phi)*lCO+yO;
    205   Set3DCS(xc,yc,zc, xO,yO,zO, daxO, dayO, dlCO, pO);
    206 }
    207 
    208 /* --Methode-- */
    209 void PIGraphic3D::ZoomInOut(float fco, float fdax, float fday, bool rel)
    210 {
    211   if (fco < 0.001) fco = 1.;
    212   if (fdax < 0.001) fdax = 1.;
    213   if (fday < 0.001) fday = 1.;
    214   double dl;
    215   if (rel) {
    216     dl = fco*lCO; 
    217     fdax *= daxO;
    218     fday *= dayO;
    219   }
    220   else dl = fco;
    221   float xo,yo,zo;
    222   if (dl < 1.e-5) dl = 1.e-5;
    223   zo = zC-cos((double)tO)*dl;
    224   xo = xC-sin((double)tO)*cos((double)fO)*dl;
    225   yo = yC-sin((double)tO)*sin((double)fO)*dl;
    226   Set3DCS(xC,yC,zC, xo,yo,zo, fdax, fday, dl, pO);
    227 //  Set3DCS_Obs(xo, yo, zo, tO, fO, pO, daxO*fda, dayO*fda, dl, dlCO);
    228 }
    229 
    230 /* --Methode-- */
    231 void PIGraphic3D::C3DC2ObsCS(float x, float y, float z, float& xp, float& yp, float& zp)
    232 {
    233   double xc, yc, zc;
    234   xc = x-xO;   yc = y-yO;    zc = z-zO;
    235   xp = RE[0][0]*xc+RE[0][1]*yc+RE[0][2]*zc;
    236   yp = -RE[1][0]*xc+RE[1][1]*yc+RE[1][2]*zc; 
    237   zp = RE[2][0]*xc+RE[2][1]*yc+RE[2][2]*zc;
    238 }
    239 
    240 /* --Methode-- */
    241 void PIGraphic3D::Proj3DC2GrC(float x, float y, float z, float& xpix, float& ypix)
    242 {
    243   double xc, yc, zc;
    244   float xp, yp, zp;
    245   xc = x-xO;   yc = y-yO;    zc = z-zO;
    246   xp = RE[0][0]*xc+RE[0][1]*yc+RE[0][2]*zc;   
    247   yp = RE[1][0]*xc+RE[1][1]*yc+RE[1][2]*zc;
    248   zp = RE[2][0]*xc+RE[2][1]*yc+RE[2][2]*zc;
    249   if ((zp>-1.e-6) && (zp < 1.e-6))   // Protection Divide/0
    250     { xpix = ypix = 0.;   return; }
    251   xpix = (float)(xOrg + (xp/zp)*xScale);
    252   ypix = (float)(yOrg + (yp/zp)*yScale);
    253 //  printf("-DBG-Proj3DC2GrC() %g %g %g -> %g %g %g -> %g %g %g -> (%g %g)\n", x,y,z,xc,yc,zc,xp,yp,zp,xp/zp,yp/zp);
    254 //  printf("-DBG- ... (%g %g %g - %g %g) %g %g - %g %g -> %g %g \n", xO,yO,zO, tO,fO, xOrg, yOrg,xScale,yScale ,xpix,ypix);
    255 }
    256 
    257 /* --Methode-- */
    258 void PIGraphic3D::DrawString3D(PIGrCoord x0, PIGrCoord y0, PIGrCoord z0, char* s)
    259 {
    260   if (!mGrC) return;
    261   float xf, yf;
    262   Proj3DC2GrC(x0, y0, z0, xf, yf);
    263   mGrC->DrawString(xf, yf, s);
    264   return;
    265 }
    266 
    267 /* --Methode-- */
    268 void PIGraphic3D::DrawOpaqueString3D(PIGrCoord x0, PIGrCoord y0, PIGrCoord z0, char* s)
    269 {
    270   if (!mGrC) return;
    271   float xf, yf;
    272   Proj3DC2GrC(x0, y0, z0, xf, yf);
    273   mGrC->DrawOpaqueString(xf, yf, s);
    274   return;
    275 }
    276 
    277 /* --Methode-- */
    278 void PIGraphic3D::DrawLine3D(PIGrCoord x1, PIGrCoord y1, PIGrCoord z1,
    279                              PIGrCoord x2, PIGrCoord y2, PIGrCoord z2)
    280 {
    281   if (!mGrC) return;
    282   float xf1, yf1, xf2, yf2;
    283   Proj3DC2GrC(x1, y1, z1, xf1, yf1);
    284   Proj3DC2GrC(x2, y2, z2, xf2, yf2);
    285 //  printf("-DBG-DrawLine3D() : %g %g %g -> %g %g | %g %g %g -> %g %g\n",
    286 //         (float)x1, (float)y1, (float)z1, xf1, yf1,
    287 //         (float)x2, (float)y2, (float)z2, xf2, yf2 );
    288   mGrC->DrawLine(xf1, yf1, xf2, yf2);
    289 }
    290 
    291 #define NMXMULTP  30   // Pour multipoint sans new
    292 
    293 /* --Methode-- */
    294 void PIGraphic3D::DrawPolygon3D(PIGrCoord *x, PIGrCoord *y, PIGrCoord *z, int n)
    295 {
    296   PIGrCoord xc[NMXMULTP], yc[NMXMULTP];
    297   PIGrCoord *pxc, *pyc;
    298   int i;
    299   float xf, yf;
    300  
    301   if (!mGrC) return;
    302   if (n <= 0)  return;
    303 
    304   if (n > NMXMULTP) { pxc = new PIGrCoord[n];  pyc = new PIGrCoord[n];  }
    305   else { pxc = xc;  pyc = yc; }
    306   for(i=0; i<n; i++) {
    307     Proj3DC2GrC(x[i], y[i], z[i], xf, yf);
    308     pxc[i] = xf;  pyc[i] = yf;
    309   }
    310   mGrC->DrawPolygon(pxc, pyc, n, false);
    311   if (n > NMXMULTP) { delete[] pxc;  delete[] pyc; }
    312   return;
    313 }
    314 
    315 
    316 /* --Methode-- */
    317 void PIGraphic3D::DrawFPolygon3D(PIGrCoord *x, PIGrCoord *y, PIGrCoord *z, int n)
    318 {
    319   PIGrCoord xc[NMXMULTP], yc[NMXMULTP];
    320   PIGrCoord *pxc, *pyc;
    321   int i;
    322   float xf, yf;
    323  
    324   if (!mGrC) return;
    325   if (n <= 0)  return;
    326 
    327   if (n > NMXMULTP) { pxc = new PIGrCoord[n];  pyc = new PIGrCoord[n];  }
    328   else { pxc = xc;  pyc = yc; }
    329   for(i=0; i<n; i++) {
    330     Proj3DC2GrC(x[i], y[i], z[i], xf, yf);
    331     pxc[i] = xf;  pyc[i] = yf;
    332   }
    333   mGrC->DrawFPolygon(pxc, pyc, n, false);
    334   if (n > NMXMULTP) { delete[] pxc;  delete[] pyc; }
    335   return;
    336 }
    337 
    338 /* --Methode-- */
    339 void PIGraphic3D::DrawMarker3D(PIGrCoord x0, PIGrCoord y0, PIGrCoord z0)
    340 {
    341   if (!mGrC) return;
    342   float xf, yf;
    343   Proj3DC2GrC(x0, y0, z0, xf, yf);
    344   mGrC->DrawMarker(xf, yf);
    345   return;
    346 }
    347 
    348 /* --Methode-- */
    349 void PIGraphic3D::DrawMarkers3D(PIGrCoord *x, PIGrCoord *y, PIGrCoord *z, int n)
    350 {
    351   PIGrCoord xc[NMXMULTP], yc[NMXMULTP];
    352   PIGrCoord *pxc, *pyc;
    353   int i;
    354   float xf, yf;
    355  
    356   if (!mGrC) return;
    357   if (n <= 0)  return;
    358 
    359   if (n > NMXMULTP) { pxc = new PIGrCoord[n];  pyc = new PIGrCoord[n]; }
    360   else { pxc = xc;  pyc = yc; }
    361   for(i=0; i<n; i++) {
    362     Proj3DC2GrC(x[i], y[i], z[i], xf, yf);
    363     pxc[i] = xf;  pyc[i] = yf;
    364   }
    365   mGrC->DrawMarkers(pxc, pyc, n);
    366   if (n > NMXMULTP) { delete[] pxc;  delete[] pyc; }
    367   return;
    368 }
Note: See TracChangeset for help on using the changeset viewer.