Changeset 158 in Sophya


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

Location:
trunk/SophyaPI/PI
Files:
31 edited

Legend:

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

    r155 r158  
    9292PIDraw3DWdg::PIDraw3DWdg(PIContainerGen *par, char *nom, int sx, int sy, int px, int py)
    9393        : PIBaseWdg(par, nom, sx, sy, px, py)
    94 {
     94{ 
    9595  vfixed = false;
     96//  SetDefaultDrawRectangle(0.12, 0.12, 0.88, 0.88, true);
    9697  SetDefaultDrawRectangle(0., 0., 1., 1., true);
     98  mBDrw = new PIElDrawer;
     99  mBDrw->SetLimits(0.12,0.88, 0.12,0.88, kAxeDirLtoR,kAxeDirDownUp);
     100  AddDrawer(mBDrw, 0.12, 0.12, 0.88, 0.88, true, false, false);
     101  mPx = mPy = 0;
    97102
    98103  lPx = lPy = 0;
     
    100105  cTeta = cPhi = 0.;  cUlen = 1.;
    101106
     107  ActivateKeyboard();
    102108  ActivateButton(2);    //  Pour pouvoir tourner la camera
    103109  ActivateMove(2);     
     
    112118PIDraw3DWdg::~PIDraw3DWdg()
    113119{
     120  delete mBDrw;
    114121  delete mGr3d;
    115122}
     
    171178  else Set3DView(xc, yc, zc, xo, yo, zo, dax, day, dco, psi);
    172179  Refresh();
     180  mBDrw->Refresh();  // ? Pour reecrire par-dessus ce qui a ete efface
    173181}
    174182
     
    236244
    237245/* --Methode-- */
     246void PIDraw3DWdg::Keyboard(int key, PIKeyModifier kmod)
     247{
     248if (kmod == PIKM_Alt) {
     249  if (key == 'V' || key == 'v') RequestSelection();  // Pour coller (copier/coller) 
     250  if (key == 'Z' || key == 'z') { mBDrw->ElDelAll();  Refresh(); } // Pour supprimer tous les signes
     251  if (key == 'O' || key == 'o') {
     252    PIDrwTools::SetCurrentBaseWdg(this);
     253    PIDrwTools::ShowPIDrwTools();   // Fentre axes et options de trace
     254    }
     255  }
     256}
     257/* --Methode-- */
     258void PIDraw3DWdg::PasteSelection(unsigned int typ, void *pdata, unsigned int l)
     259{
     260if (typ != PICP_string) return;
     261int ll = (l<256) ? l+1 : 256;
     262char pc[256];
     263strncpy(pc, (char*)pdata, ll-1);  pc[ll-1] = '\0';
     264// printf("PIDraw3DWdg::PasteSelection() / Debug  %s - %d %d -> %g %g \n", pc,
     265//        mPx, mPy, (float)mPx/(float)XSize(), 1.-(float)mPy/(float)YSize());
     266mBDrw->ElAddText((float)mPx/(float)XSize(), 1.-(float)mPy/(float)YSize(), pc );
     267mBDrw->Refresh();
     268}
     269
     270/* --Methode-- */
    238271void PIDraw3DWdg::But2Press(int x, int y)
    239272{
     
    247280  lPx = x;  lPy = y;
    248281
    249 // Pour savoir si on se trouve ds la zone centrale    
     282// Pour savoir si on se trouve ds la zone centrale   
    250283  int czx = XSize()/10;
    251284  int czy = YSize()/10;
    252   int dmix = x-XSize()/2;
    253   int dmiy = y-YSize()/2;
    254   if (dmix < 0) dmix = -dmix;
    255   if (dmiy < 0) dmiy = -dmiy;
    256   if ((dmix < czx) && (dmiy < czy))  rOfg = true;
    257   else rOfg = false;
     285  PIKeyModifier kmod;
     286  unsigned long tm;
     287  GetLastEventInfo(kmod, tm);
     288  rOfg = false;
     289  if (kmod ==  PIKM_Shift)  rOfg = true;
     290  else {
     291    int dmix = x-XSize()/2;
     292    int dmiy = y-YSize()/2;
     293    if (dmix < 0) dmix = -dmix;
     294    if (dmiy < 0) dmiy = -dmiy;
     295    if ((dmix < czx) && (dmiy < czy))  rOfg = true;
     296    }
    258297
    259298  cUlen = 0.5*(dax+day)*co*0.3;    cDax = dax;   cDay = day;  clCO = co;
     
    319358  SetDrawers3DView();
    320359  Refresh();
     360  mBDrw->Refresh();
    321361}
    322362
     
    382422  SetDrawers3DView();
    383423  Refresh();
     424  mBDrw->Refresh();
    384425}
    385426
     
    421462  Send(Msg(), PIMsg_Active);
    422463  PIDrwTools::SetCurrentBaseWdg(this);
     464  mPx = x;  mPy = y;
    423465  if ( (x > 50) || ( y > 50) ) return;
    424466  Update3DView();
  • trunk/SophyaPI/PI/pi3ddrw.h

    r155 r158  
     1// This may look like C code, but it is really -*- C++ -*-
    12// Module PI : Peida Interactive PIDrawer3D PIDraw3DWdg
    23// Drawer et DrawWidget 3D       R. Ansari 06/98
     
    1415#include <list>
    1516
    16 // Traceur (Drawer) 3D
     17// -----------------  Traceur (Drawer) 3D  -------------------
     18
    1719class PIDrawer3D : public PIDrawer
    1820{
     
    4042
    4143
     44//------------------------------ Classe PIDrawer3D --------------------
    4245
    4346class PIDraw3DWdg : public PIBaseWdg {
     
    5053  virtual long          kind() {return ClassId; }
    5154
     55
    5256  virtual void          Set3DView_Obs(float xo, float yo, float zo, float teta, float phi, float psi,
    5357                                      float dax, float day, float co, float dco=0.2);
     
    5862
    5963  virtual void          Update3DView();   // Vue 3-D a partir de Drawer No 1
     64
     65  inline void           SetTitles(const char* tt=NULL, const char* tb=NULL)
     66                                  { mBDrw->SetTitles(tt, tb); }
     67  inline void           SetTitles(string const & tt, string const & tb)
     68                                  { mBDrw->SetTitles(tt, tb); }
    6069
    6170  int                   AddDrawer3D(PIDrawer3D*, bool ad=false);   // Ajoute un Drawer
     
    7584  virtual void          Ptr3Move(int x, int y);
    7685
     86  virtual void          Keyboard(int key, PIKeyModifier kmod);
     87  virtual void          PasteSelection(unsigned int typ, void *pdata, unsigned int l);
     88
    7789
    7890protected :
     
    8092  virtual void          DrawXYZAxes();
    8193
     94  PIElDrawer* mBDrw;   // Objet traceur d'elements de fond
     95  int mPx, mPy;        // Position pointeur - Bouton-1
     96 
    8297  bool vfixed;       // SetView fait ou pas
    8398  list<int> m3DrIl;  // Liste des Id drawers 3D
  • trunk/SophyaPI/PI/pibwdggen.cc

    r127 r158  
     1// Module PI : Peida Interactive     PIBaseWdg
     2// Classe de base pour nouvelles composantes graphiques  96
     3// LAL (Orsay) / IN2P3-CNRS  DAPNIA/SPP (Saclay) / CEA
     4
    15#include <stdio.h>
    26
     
    610#include "pidrwtools.h"
    711
    8 // Les methodes de la classe  PIBWdgGen
     12
     13//++
     14// Class        PIBaseWdg
     15// Lib          PI
     16// include      pibwdggen.h
     17//
     18//      Classe de base pour la création de nouvelles composantes graphiques.
     19//      Le traitement des événements liés à l'écran, clavier, souris se fait
     20//      à travers des méthodes de cette classe : "Resize()", "But1Press()", ...
     21//      La classe "PIBaseWdg" supporte en outre un mécanisme permettant
     22//      d'associer un ou plusieurs objets traceur (*Drawer*) capables
     23//      de se dessiner dans la fenêtre associée à l'objet.
     24//      La classe "PIBaseWdgGen" définit l'interface et ne peut pas être instanciée
     25//      directement (Méthodes virtuelles pures). Les objets instanciés sont de la
     26//      classe "PIBaseWdg" et le fichier entête correspondant est "PIBWDG_H"
     27//      défini dans "pisysdep.h".
     28//--
     29//++
     30// Links        Parents
     31// PIWdg
     32//--
     33//++
     34// Links        Voir aussi
     35// PIGraphic
     36// PIDrawer
     37//--
     38
     39// ---------- Les methodes de la classe  PIBWdgGen ------------
     40
     41//++
     42// Titre        Constructeur
     43//--
     44//++
     45//  PIBaseWdgGen(PIContainerGen *par, char *nom, int sx=10, int sy=10, int px=0, int py=0)
     46//      Création d'un objet contenu dans l'objet *PIContainer* "par", de
     47//      taille "sx,sy", se trouvant à la position "px,py" avec le nom "nom"     
     48//--
     49
     50//++
     51// Titre        Méthodes
     52//--
     53//++
     54// void  SetBackgroundColor(PIColors col=PI_White)
     55//      Choix de la couleur de fond.
     56// void  EraseWindow(int x0=0, int y0=0, int dx=0, int dy=0)
     57//      Efface la zone rectangulaire définie par le coin "(x0,y0)" ,
     58//      de taille "dx,dy" à l'aide de la couleur de fond.
     59// void  SelPointerShape(PIPointer ptr=PI_ArrowPointer)
     60//      Choix de la forme du pointeur (souris) pour la fenêtre
     61//      associée à l'objet.
     62//|     PI_ArrowPointer, PI_CrossPointer, PI_HandPointer, PI_TDLRArrowPointer
     63// PIColors  GetBackgroundColor()
     64//      Renvoie la couleur de fond
     65// PIPointer  GetPointerShape()
     66//      Renvoie la forme du pointeur
     67// void  Refresh()
     68//      L'appel à cette méthode permet de retracer le contenu de la
     69//      fenêtre et des "Drawer" associés.
     70//--
     71
     72//++
     73// Titre        Activation du traitement des événements
     74//--
     75//++
     76// void  ActivatePtrCross()
     77//      Active l'appel aux méthodes "Enter()" et "Leave()" lorsque la souris
     78//      rentre ou sort de la fenêtre correspondante à l'objet
     79// void  ActivateButton(int b)
     80//      Active l'appel aux méthodes "ButbPress()" et "ButxRelease()" pour
     81//      le bouton "b" de la souris ("b=1,2,3")
     82// void  ActivateMove(int b)
     83//      Active l'appel aux méthodes "PtrbMove()" lors des mouvements de
     84//      la souris avec le bouton "b" enfoncé ("b=1,2,3")
     85//      L'appel avec "bid=0" active l'appel à la méthode "PtrMove()"
     86//      Lors des mouvements de souris sans bouton enfoncé.
     87// void  ActivateKeyboard()
     88//      Active l'appel à la méthode "Keyboard()" lors de l'appui sur les
     89//      touches du clavier.
     90//--
     91
    992 
    1093/* --Methode-- */
     
    42125
    43126
     127//++
     128// Titre        Gestion des événements
     129//--
     130//++
     131// void  Draw(PIGraphic* g, int x0, int y0, int dx, int dy)
     132//      Méthode appelée lorsqu'il faut redessiner tout ou partie de
     133//      la fenêtre. La zone a rafraîchir est determinée par
     134//      "(x0,y0)", "dx,dy" et "g" est l'objet "PIGraphic"
     135//      qui doit être utilisé.
     136//      Cette méthode ne doit pas être appelé directement.
     137//      Pour rafraîchir le contenu de la fenêtre, il faut appeler
     138//      la méthode "Refresh()"
     139// void  Resize()
     140//      Méthode appelée lorsque la taille de l'objet est modifiée.
     141//      "XSize()", "YSize()" fournissent la nouvelle taille de l'objet.
     142// void  Enter()
     143//      Méthode appelée lorsque le pointeur rentre dans la fenêtre
     144//      (Si "ActivatePtrCross()" a été appelé )
     145// void  Leave()
     146//      Méthode appelée lorsque le pointeur quitte la fenêtre
     147//      (Si "ActivatePtrCross()" a été appelé )
     148// void  ButbPress(int x, int y)  (b=1,2,3)
     149//      Méthode appelée lorsque le bouton "b=1,2,3" de la souris est enfoncé.
     150//      "x,y" : Position de la souris
     151//      (Si "ActivateButton(b)" a été appelé )
     152// void  ButbRelease(int x, int y)   (b=1,2,3)
     153//      Méthode appelée lorsque le bouton "b=1,2,3" de la souris est relaché.
     154//      "x,y" : Position de la souris
     155//      (Si "ActivateButton(b)" a été appelé )
     156// void  PtrMove(int x, int y)
     157//      Méthode appelée lors des mouvements de la souris. "x,y" : Position de la souris
     158//      (Si "ActivateMove(0)" a été appelé )
     159// void  PtrbMove(int x, int y)     (b=1,2,3)
     160//      Méthode appelée lors des mouvements de la souris, avec le
     161//      bouton "b=1,2,3" appuyé. "x,y" : Position de la souris
     162//      (Si "ActivateMove(b)" a été appelé )
     163// void  Keyboard(int key, PIKeyModifier kmod)
     164//      Méthode appelée en réponse à des actions sur le clavier.
     165//      "key" est le code ASCII de la touche enfoncé - "kmod" indique
     166//      si des touches speciaux étaient enfoncés en même temps.
     167//|     kmod =  PIKM_Blank |  PIKM_Shift | PIKM_Alt | PIKM_Cntl
     168//      Des constantes ont été définis pour certaines touches particulières
     169//|     PIK_Return , PIK_Enter , PIK_BackSpace, PIK_Delete
     170//|     PIK_Tab , PIK_Escape , PIK_Up , PIK_Down,
     171//|     PIK_Right , PIK_Left , PIK_Previous , PIK_Next
     172//--
     173
    44174/* --Methode-- */
    45175void PIBaseWdgGen::Draw(PIGraphic* g, int x0, int y0, int dx, int dy)
     
    124254}
    125255
     256/* --Methode-- */
     257void PIBaseWdgGen::PtrMove(int /*x*/, int /*y*/)
     258{
     259#ifdef DEBUG_RZXB
     260printf ("Debug_PIBaseWdgGen::PtrMove PosX,Y= %d %d \n", x, y);
     261#endif
     262return;
     263}
    126264
    127265/* --Methode-- */
     
    167305}
    168306
     307//++
     308// Titre        Gestion des traceurs (PIDrawer)
     309//      Un même "PIDrawer" peut être attaché simultanement à plusieurs "PIBaseWdg", ainsi
     310//      que plusieurs fois au même "PIBaseWdg", avec des identificateurs différents.
     311//--
     312//++
     313// void  SetDefaultDrawRectangle(PIGrCoord x1, PIGrCoord y1, PIGrCoord x2, PIGrCoord y2, bool psz=true)
     314//      Définition du rectangle d'attachement par défaut. "(x1,y1)" et "(x2,y2)" determinent
     315//      les positions des deux coins opposés.
     316//      si "psz=true", les coordonnées sont supposées être des facteurs multiplicatifs
     317//      des dimensions de l'objet.
     318// void  SetDefaultDrawerLimits(float xmin, float xmax, float ymin, float ymax, -
     319//                              int axrl=kAxeDirSame, int ayud=kAxeDirSame)
     320//      Définition du système de coordonnées par défaut d'un drawer attaché en "autolim=true"
     321//
     322//--
     323
    169324/* --Methode-- */
    170325void PIBaseWdgGen::SetDefaultDrawRectangle(PIGrCoord x1, PIGrCoord y1, PIGrCoord x2, PIGrCoord y2, bool psz)
     
    183338}
    184339
     340
     341//++
     342// int  AddDrawer(PIDrawer* drw, PIGrCoord x1, PIGrCoord y1, PIGrCoord x2, PIGrCoord y2, -
     343//                bool psz=true, bool clip=true, bool ad=false)
     344//      Attachement d'un "PIDrawer" au rectangle défini les coordonnées des deux coins opposés.
     345//      si "psz=true", les coordonnées sont supposées être des facteurs multiplicatifs
     346//      des dimensions de l'objet.
     347//      si "clip=true", "PIDrawer* drw" ne peut dessiner en dehors de son rectangle
     348//      d'attachement.
     349//      si "ad=true", le "PIDrawer* drw" est détruit lors de la destruction de l'objet PIBaseWdg.
     350//      La méthode retourne l'identificateur du drawer attaché.
     351// int  AddDrawer(PIDrawer* drw, bool autolim=false, bool clip=true, bool ad=false)
     352//      Ajout d'un "PIDrawer" au rectangle d'attachement par défaut.
     353//      Si "autolim=true", l'objet "PIBaseWdg" impose l'espace de coordonnées utilisateur
     354//      à l'aide des valeurs définies par "SetDefaultDrawerLimits()".
     355//      Si ""clip=true", "PIDrawer* drw" ne peut dessiner en dehors de son rectangle
     356//      d'attachement.
     357//      si "ad=true", le "PIDrawer* drw" est détruit lors de la destruction de l'objet PIBaseWdg.
     358//      La méthode retourne l'identificateur du drawer attaché.
     359//--
    185360
    186361/* --Methode-- */
     
    220395
    221396
     397//++
     398// void  MoveResizeDrawer(int id, PIGrCoord x1, PIGrCoord y1, PIGrCoord x2, PIGrCoord y2, bool psz=true)
     399//      Modification du rectangle d'attachement du PIDrawer avec l'identificateur "id" , retourné
     400//      par "AddDrawer()"
     401// void  RemoveDrawer(int id)
     402//      Ote le drawer "id" de la liste
     403// void  DeleteDrawers()
     404//      Ote tous les drawers de la liste. Détruit ceux ajoutés avec l'option "ad=true"
     405//--
     406
    222407/* --Methode-- */
    223408void PIBaseWdgGen::MoveResizeDrawer(int id,  PIGrCoord x1, PIGrCoord y1,  PIGrCoord x2, PIGrCoord y2, bool psz)
     
    257442}
    258443
     444//++
     445// int  NbDrawers()
     446//      Retourne le nombre de PIDrawer attachés
     447// PIDrawer*  GetDrawerId(int id)
     448//      Retourne le PIDrawer avec l'identificateur id
     449// PIDrawer*  GetDrawer(int n)
     450//      Retourne le PIDrawer "n=0..NbDrawers()-1" de la liste
     451//--
     452
    259453/* --Methode-- */
    260454int PIBaseWdgGen::NbDrawers()
     
    280474}
    281475
     476
     477//++
     478// void  CallDrawers(PIGraphic* g, int x0=0, int y0=0, int dx=0, int dy=0)
     479//      Appel de la méthode de tracé pour tous les Drawers
     480// void  CallDrawer(int id);
     481//      Appel de la méthode de tracé pour le drawer avec l'identificateur "id"
     482//--
    282483
    283484/* --Methode-- */
  • trunk/SophyaPI/PI/pibwdggen.h

    r127 r158  
    1515enum PIKeyModifier { PIKM_Blank = 0, PIKM_Shift = 1, PIKM_Alt = 2, PIKM_Cntl = 4 } ;
    1616
    17 enum PIKeyValues { PIK_Return = 1+0x2000, PIK_Enter = 2+0x2000 ,
    18                    PIK_BackSpace = 3+0x2000, PIK_Delete = 4+0x2000,
    19                    PIK_Tab = 5+0x2000, PIK_Escape = 6+0x2000,
    20                    PIK_Up = 11+0x2000, PIK_Down = 12+0x2000,
    21                    PIK_Right = 13+0x2000, PIK_Left = 14+0x2000,
    22                    PIK_Previous = 21+0x2000, PIK_Next = 22+0x2000  } ;
     17enum PIKeyValues { PIK_Return = 0xFF0D, PIK_Enter = 0xFF8D ,
     18                   PIK_BackSpace = 0xFF08, PIK_Delete = 0xFFFF,
     19                   PIK_Tab = 0xFF09, PIK_Escape = 0xFF1B,
     20                   PIK_Up = 0xFF52, PIK_Down = 0xFF54,
     21                   PIK_Right = 0xFF53, PIK_Left = 0xFF51,
     22                   PIK_Previous = 0xFF55, PIK_Next = 0xFF56  } ;
    2323
    2424
     
    7070  virtual void       But3Press(int x, int y);
    7171  virtual void       But3Release(int x, int y);
     72  virtual void       PtrMove(int x, int y);
    7273  virtual void       Ptr1Move(int x, int y);
    7374  virtual void       Ptr2Move(int x, int y);
    7475  virtual void       Ptr3Move(int x, int y);
    7576  virtual void       Keyboard(int key, PIKeyModifier kmod);
     77
     78// Acces aux caracteristiques du dernier evenement
     79  virtual void       GetLastEventInfo(PIKeyModifier& kmod, unsigned long& tm) = 0;
    7680
    7781// PostScript output
  • trunk/SophyaPI/PI/pibwdgx.cc

    r154 r158  
     1// This may look like C code, but it is really -*- C++ -*-
     2// Module PI : Peida Interactive      PIBaseWdg
     3//                                    Reza 95-96
     4// LAL (Orsay) / IN2P3-CNRS  DAPNIA/SPP (Saclay) / CEA
     5
    16#include <stdio.h>
    27
     
    2934
    3035Init();
     36mWGrC = NULL; // PIGraphic (Contexte graphique) associe a la fenetre
     37finishDone = false;     // FinishCreate() pas encore appele
    3138
    3239CreateXtWdg(nom, piXtBaseWidgetClass, NULL, sx, sy, px, py);
     
    4249mPtrS = PI_CrossPointer;
    4350SelPointerShape();
    44 
     51// PIGraphic (Contexte graphique) associe a la fenetre
     52// Si pas cree par FinishCreate()
     53if (!mWGrC) mWGrC = new PIGraphicX(this);   
    4554Manage();
    46 mWGrC = new PIGraphicX(this);   // PIGraphic (Contexte graphique) associe a la fenetre
    4755}
    4856
     
    6371void PIBaseWdgX::FinishCreate()
    6472{
     73if (finishDone) {
     74  fprintf(stderr, "BUG/PIBaseWdgX::FinishCreate() multiple call \n");
     75  return;
     76  }
    6577// appele par la fenetre mere, apres XtRealize()
    6678// J'active le backing store pour la fenetre X
     
    8092// XChangeWindowAttributes(PIXDisplay(), XtWindow(XtWdg()), CWBackingPlanes|CWBackingStore, &xswa);
    8193XChangeWindowAttributes(PIXDisplay(), mwi, CWBackingStore, &xswa);
     94
     95// PIGraphic (Contexte graphique) associe a la fenetre
     96if (!mWGrC) mWGrC = new PIGraphicX(this);   
     97mWGrC->TerminateInit();
     98finishDone = true;     // FinishCreate() fait
    8299}
     100
     101/* --Methode-- */
     102bool PIBaseWdgX::IsVisible()
     103{
     104return (finishDone && PIWdg::IsVisible() );
     105}
    83106
    84107/* --Methode-- */
     
    114137unsigned long evtmask ;
    115138
    116 if ( (bid < 1) && (bid > 3) ) return;
    117 if (bid == 1)  evtmask = Button1MotionMask | PointerMotionHintMask ;
     139// bid == 0  -> PointerMove sans bouton
     140if ( (bid < 0) && (bid > 3) ) return;
     141
     142if (bid == 0) evtmask = PointerMotionHintMask ;
     143else if (bid == 1) evtmask = Button1MotionMask | PointerMotionHintMask ;
    118144else if (bid == 2) evtmask = Button2MotionMask | PointerMotionHintMask ;
    119145else if (bid == 3) evtmask = Button3MotionMask | PointerMotionHintMask ;
     
    177203}
    178204
     205/* --Methode-- */
     206void PIBaseWdgX::GetLastEventInfo(PIKeyModifier& kmod, unsigned long& tm)
     207{
     208unsigned int st;
     209Time t;
     210PIXGetLastEventInfo(st, t);
     211tm = t;
     212kmod = PIKM_Blank;
     213if  (st & ShiftMask)   kmod = (PIKeyModifier) (kmod | PIKM_Shift);
     214if  (st & ControlMask) kmod = (PIKeyModifier) (kmod | PIKM_Cntl);
     215if  (st & Mod1Mask)    kmod = (PIKeyModifier) (kmod | PIKM_Alt);
     216return;
     217}
    179218
    180219static bool fgbwdg = false ;
  • trunk/SophyaPI/PI/pibwdgx.h

    r80 r158  
     1// This may look like C code, but it is really -*- C++ -*-
     2// Module PI : Peida Interactive      PIBaseWdg
     3//                                    Reza  95-96
     4// LAL (Orsay) / IN2P3-CNRS  DAPNIA/SPP (Saclay) / CEA
     5
    16#ifndef PIBWDGX_H_SEEN
    27#define PIBWDGX_H_SEEN
     
    611
    712#include "pigraphx.h"
     13           
    814#include "pigraphps.h"
    915
     
    3440  virtual void       AssignKeyboard();
    3541
     42// Acces aux caracteristiques du dernier evenement
     43  virtual void       GetLastEventInfo(PIKeyModifier& kmod, unsigned long& tm);
     44
     45// On redefinit IsVisible() pour tenir compte de l appel a FinsihCreate 
     46  virtual bool       IsVisible();
     47
    3648//  Appel depuis le PIXtBaseWidget uniquement (ExposeEvt de Xt )
    3749  virtual void       eXposeProcess(int x0, int y0, int dx, int dy);
     
    4153  PIPointer mPtrS;
    4254  PIColors mBCol;
     55  bool finishDone;       // Si FinsihCreate appele
    4356};
    4457
  • trunk/SophyaPI/PI/picons.cc

    r138 r158  
    586586int x,y;
    587587
    588 // printf("PIConsole::DisplayLines(%d %d ) \n ", l1, l2);
     588// DBG printf("PIConsole::DisplayLines(%d %d ) -> %d - %lx \n ", l1, l2,
     589//            (int)IsVisible(), (long)XtWindow(XtWdg()));
    589590
    590591if (! IsVisible() )   return;
  • trunk/SophyaPI/PI/picontainergen.cc

    r154 r158  
    44//                  E.Aubourg , R. Ansari  96 - 98
    55// LAL (Orsay) / IN2P3-CNRS  DAPNIA/SPP (Saclay) / CEA
     6
     7#include <stdio.h>
    68
    79#include "picontainergen.h"
     
    1517//      organise la hiérarchie des objets "PIWdg" et donc aussi des "PIMsgHandler",
    1618//      contrôle la géométrie des objets "PIWdg" contenus, ainsi que leur
    17 //      visibilité et activité. La classe "PIContainer" est une des
     19//      visibilité et activité. Le positionnement initial est controle par
     20//      un objet *PILayoutMgr* qui peut eventuellement modifier la postion
     21//      ou la taille de l'objet "PIWdg" ajouté. Les attributs d'attachement
     22//      de l'objet ("PIWdg::SetBinding()") contrôle le repositionnement
     23//      lors du changement de taille du "PIContainer".
     24//      La classe "PIContainer" est une des
    1825//      classes de PI qui ont une implementation dépendante du systeme utilisé
    1926//      (Mac, XWindow, ...). La classe "PIContainerGen" est la classe qui
     
    2633// Links        Parents
    2734// PIWdg
     35//--
     36//++
     37// Links        Voir aussi
     38// PILayoutMgr
    2839//--
    2940//++
     
    4354//--
    4455//++
     56// void SetLayoutMgr(PILayoutMgr* nlay)
     57//      Permet de changer le gestionnaire de positions ("PILayoutMgr") du conteneur,
     58//      et donc la stratégie de positionnement des objets "PIWdg" fils.
     59//      le LayoutMgr par défaut n'applique aucune contrainte sur la position
     60//      ou la taille des objets ajoutés.
     61//      Cette méthode ne peut être appelé que pour un conteneur vide (sans PIWdg fils).
     62//      Il est conseillé de l'appeler juste après la création du "PIContainer"
     63// PILayoutMgr* GetLayoutMgr()
     64//      Retourne le gestionnaire de positions/tailles du conteneur.
    4565// void Show()
    4666//      Rend l'objet visible à l'écran. Tous les objets "PIWdg" contenus et qui sont dans
     
    5070// void  PSPrint(PSFile *psf, int ofx=0, int ofy=0)
    5171//      Appelle la méthode "PSPrint()" pour tous les objets contenus.
    52 // void  SetAutoDelChilds(bool ad = false)
     72// void  SetAutoDelChilds(bool ad = true)
    5373//      Contrôle le comportement de l'objet conteneur vis à vis des objets
    5474//      contenus lors de la destruction. si "ad=true", les objets contenus
    5575//      sont détruits lors de l'appel du destructeur de l'objet conteneur.
    56 //--
    57 
    58 #define NCHALGRP 8
     76// int  NbChilds()
     77//      Retourne le nombre de "PIWdg" contenus.
     78// PIWdg* GetChild(int n)
     79//      Retourne le "PIWdg" numéro "n" (0..NbChilds()-1)
     80//--
     81//++
     82// Titre        Méthodes particulières
     83//      Les méthodes ci-dessous ne doivent pas être appelées directement.
     84//--
     85//++
     86// void ChildAdd(PIWdg* child)
     87//      Méthode qui est appelée lors de l'attachement d'un nouvel objet (création)
     88//      Appelle la méthode correspondante du "PILayoutMgr"
     89// void ChildAdd(PIWdg* child)
     90//      Méthode qui est appelée lors du détachement d'un objet (destruction)
     91//      Appelle la méthode correspondante du "PILayoutMgr"     
     92//--
     93
    5994
    6095/* --Methode-- */
     
    6398: PIWdg(par, nom, sx, sy, px, py) 
    6499{
     100stvis = false;
     101stfcr = false;
     102layout = new PILayoutMgr;
     103layout->SetContainer(this);
     104}
     105
     106
     107/* --Methode-- */
     108PIContainerGen::~PIContainerGen()
     109{
     110delete layout;
     111}
     112
     113/* --Methode-- */
     114void PIContainerGen::SetLayoutMgr(PILayoutMgr* nlay)
     115{
     116if (nlay == NULL) return;
     117if (NbChilds() > 0) {
     118  fprintf(stderr, "PIContainerGen::SetLayoutMgr()/ Error! Container has childs (N = %d) \n", NbChilds());
     119  return;
     120  }
     121delete layout;
     122layout = nlay;
     123layout->SetContainer(this);
     124}
     125
     126/* --Methode-- */
     127void PIContainerGen::PSPrint(PSFile *psf, int ofx, int ofy)
     128{
     129int i;
     130if (!psf)  return;
     131if (!Visible())  return;
     132for(i=0; i<NbChilds(); i++)  GetChild(i)->PSPrint(psf, ofx+XPos(), ofy+YPos());
     133return;
     134}
     135
     136/* --Methode-- */
     137void PIContainerGen::Show()
     138{
     139stvis = true;
     140Manage();
     141return;
     142}
     143
     144/* --Methode-- */
     145void PIContainerGen::Hide()
     146{
     147stvis = false;
     148UnManage();
     149return;
     150}
     151
     152/* --Methode-- */
     153bool PIContainerGen::Visible()
     154{
     155if (Parent())  return(stvis && Parent()->Visible());
     156else return(stvis && IsVisible());
     157}
     158
     159/* --Methode-- */
     160void PIContainerGen::ChildAdd(PIWdg* child)
     161{
     162layout->ChildAdd(child);
     163// Reza 13/10/98 : il faut que child->FinishCreate()
     164// soit appele pour les PIWdg ajoute quand le  container est deja affiche et son FinishCreate() appele
     165if (stfcr)  child->FinishCreate();
     166return;
     167}
     168
     169/* --Methode-- */
     170void PIContainerGen::ChildDel(PIWdg* child)
     171{
     172layout->ChildDel(child);
     173}
     174
     175/* --Methode-- */
     176int PIContainerGen::NbChilds()
     177{
     178return(layout->NbChilds());
     179}
     180
     181/* --Methode-- */
     182PIWdg* PIContainerGen::GetChild(int n)
     183{
     184return(layout->GetChild(n));
     185}
     186
     187/* --Methode-- */
     188void PIContainerGen::SetAutoDelChilds(bool ad)
     189{
     190layout->SetAutoDelChilds(ad) ;
     191}
     192
     193
     194/* --Methode-- */
     195void PIContainerGen::FinishCreate()
     196{
     197if (stfcr)  return;
     198int k;
     199for(k=0; k<NbChilds(); k++)  GetChild(k)->FinishCreate();
     200stfcr = true;
     201}
     202
     203
     204// ------------------------------------------------------------------
     205//  Classe PILayoutMgr (Gestionnaire de positions/tailles PIWdg fils
     206// ------------------------------------------------------------------
     207//++
     208// Class        PILayoutMgr
     209// Lib          PI
     210// include      picontainergen.h
     211//
     212//      Classe de gestionnaire de positions/tailles initiales des "PIWdg"
     213//      fils pour les "PIContainer".
     214//      La classe de base n'impose aucune contrainte sur les positions/tailles.
     215//--
     216//++
     217// Links        Voir
     218// PIContainer
     219//--
     220
     221//++
     222// Titre        Constructeur, méthodes
     223//--
     224//++
     225// PILayoutMgr()
     226//      Constructeur
     227// void ChildAdd(PIWdg* child)
     228//      Méthode appelé lors de l'ajout d'un nouveau "PIWdg" au conteneur.
     229// void ChildDel(PIWdg* child)
     230//      Méthode appelé lors de la suppression d'un "PIWdg"
     231// int  NbChilds()
     232//      Nombre de "PIWdg" gérés.
     233// PIWdg* GetChild(int n)
     234//      Retourne l'objet "PIWdg" numéro "n"
     235//--
     236
     237#define NCHALGRP 8
     238
     239/* --Methode-- */
     240PILayoutMgr::PILayoutMgr()
     241{
    65242mNCh = 0;
    66 mACSup = false;   // Suppression automatique des widgets fils au delete
     243mACSup = true;   // Suppression automatique des widgets fils au delete
    67244mPaSup = false;
    68245mChilds = new (PIWdg* [NCHALGRP]);
    69246mMxCh = NCHALGRP;
    70 stvis = false;
    71 stfcr = false;
    72 }
    73 
    74 
    75 /* --Methode-- */
    76 PIContainerGen::~PIContainerGen()
     247mCont = NULL;
     248}
     249
     250/* --Methode-- */
     251PILayoutMgr::~PILayoutMgr()
    77252{
    78253mPaSup = true;   // Pour prevenir ChildDel()
     
    83258
    84259/* --Methode-- */
    85 void PIContainerGen::PSPrint(PSFile *psf, int ofx, int ofy)
    86 {
    87 int i;
    88 if (!psf)  return;
    89 if (!Visible())  return;
    90 for(i=0; i<mNCh; i++)  mChilds[i]->PSPrint(psf, ofx+XPos(), ofy+YPos());
    91 return;
    92 }
    93 
    94 /* --Methode-- */
    95 void PIContainerGen::Show()
    96 {
    97 stvis = true;
    98 Manage();
    99 return;
    100 }
    101 
    102 /* --Methode-- */
    103 void PIContainerGen::Hide()
    104 {
    105 stvis = false;
    106 UnManage();
    107 return;
    108 }
    109 
    110 /* --Methode-- */
    111 bool PIContainerGen::Visible()
    112 {
    113 if (Parent())  return(stvis && Parent()->Visible());
    114 else return(stvis && IsVisible());
    115 }
    116 
    117 /* --Methode-- */
    118 void PIContainerGen::ChildAdd(PIWdg* child)
     260void PILayoutMgr::ChildAdd(PIWdg* child)
    119261{
    120262if (child == NULL)  return;
     
    128270  } 
    129271mChilds[mNCh] = child;   mNCh++;
    130 // Reza 13/10/98 : il faut que child->FinishCreate()
    131 // soit appele pour les PIWdg ajoute quand le  container est deja affiche et son FinishCreate() appele
    132 if (stfcr)  child->FinishCreate();
    133 return;
    134 }
    135 
    136 /* --Methode-- */
    137 void PIContainerGen::ChildDel(PIWdg* child)
    138 {
    139 if (mPaSup) return;  // Ne rien faire si delete initie par Container-parent
     272return;
     273}
     274
     275/* --Methode-- */
     276void PILayoutMgr::ChildDel(PIWdg* child)
     277{
     278if (mPaSup) return;  // Ne rien faire si delete initie par Container-parent : Le LayoutMgr lui-meme
    140279if ((child == NULL) || (mNCh < 1))  return;
    141280for(int i=0; i<mNCh; i++) 
     
    149288}
    150289
    151 /* --Methode-- */
    152 int PIContainerGen::NbChilds()
    153 {
    154 return(mNCh);
    155 }
    156 
    157 /* --Methode-- */
    158 PIWdg* PIContainerGen::GetChild(int n)
    159 {
    160 if ( (n < 0) || (n >= mNCh))  return(NULL);
    161 return ((PIWdg*)mChilds[n]);
    162 }
    163 
    164 /* --Methode-- */
    165 void PIContainerGen::SetAutoDelChilds(bool ad)
    166 {
    167 mACSup = ad;
    168 return;
    169 }
    170 
    171 /* --Methode-- */
    172 void PIContainerGen::FinishCreate()
    173 {
    174 if (stfcr)  return;
    175 int k;
    176 for(k=0; k<mNCh; k++)  mChilds[k]->FinishCreate();
    177 stfcr = true;
    178 }
    179 
  • trunk/SophyaPI/PI/picontainergen.h

    r154 r158  
     1// This may look like C code, but it is really -*- C++ -*-
     2// Module PI : Peida Interactive    PIContainerGen
     3//                  E.Aubourg , R. Ansari  96 - 98
     4// LAL (Orsay) / IN2P3-CNRS  DAPNIA/SPP (Saclay) / CEA
     5
    16#ifndef PICONTAINERBASE_SEEN
    27#define PICONTAINERBASE_SEEN
     
    611#include PIWDG_H
    712
     13class PIContainerGen;
     14//  Classe gestionnaire du positionnement/tailles des PIWdg d'un PIContainer
     15class PILayoutMgr {
     16public:
     17                        PILayoutMgr();
     18  virtual               ~PILayoutMgr();
    819
     20  inline  void          SetContainer(PIContainerGen* pic) { mCont = pic; }
     21
     22  virtual void          ChildAdd(PIWdg* child);
     23  virtual void          ChildDel(PIWdg* child);
     24
     25  inline  int           NbChilds() { return(mNCh); }
     26  inline  PIWdg*        GetChild(int n)
     27                        { if ( (n < 0) || (n >= mNCh))  return(NULL);
     28                        else return (mChilds[n]); }
     29  inline  void          SetAutoDelChilds(bool ad = true) { mACSup = ad; }
     30
     31protected:
     32  PIWdg                ** mChilds;
     33  int                  mNCh, mMxCh;
     34  bool                 mPaSup, mACSup;
     35  PIContainerGen*      mCont;   // Le PIContainer auquel on est attache
     36};
     37
     38// Classe conteneur pour le regroupement hierarchique (Fenetre/MsgHandler) des PIWdg
    939class PIContainerGen : public PIWdg
    1040{
     
    1848  virtual long         kind() {return ClassId; }
    1949
     50  virtual void         SetLayoutMgr(PILayoutMgr* nlay);
     51  inline  PILayoutMgr* GetLayoutMgr() { return(layout); }
     52
    2053  virtual void         PSPrint(PSFile *psf, int ofx=0, int ofy=0);
    2154
     
    2861  virtual int          NbChilds();
    2962  virtual PIWdg*       GetChild(int n);
     63          void         SetAutoDelChilds(bool ad = true);
    3064
    31           void         SetAutoDelChilds(bool ad = false);
    3265  virtual void         FinishCreate(); // appelle FinishCreate() pour les descendants
    3366
    3467protected:
    3568  bool                 stvis, stfcr;  // Statut visible ou pas, FinishCreate appele ou pas
    36   PIWdg                ** mChilds;
    37   int                  mNCh, mMxCh;
    38   bool                 mPaSup, mACSup;
     69  PILayoutMgr*         layout;        // Gestionnaire de positionnement (/tailles) des PIWdg fils
    3970};
    4071
  • trunk/SophyaPI/PI/pidrawer.cc

    r136 r158  
     1// Module PI : Peida Interactive     PIDrawer
     2// Classe de traceurs pouvat être attachés à une PIBaseWdg
     3//            E. Aubourg , R.Ansari     96-98
     4// LAL (Orsay) / IN2P3-CNRS  DAPNIA/SPP (Saclay) / CEA
     5
    16#include "pidrawer.h"
    27#include "psfile.h"
     8
     9//++
     10// Class        PIDrawer
     11// Lib          PI
     12// include      pidrawer.h
     13//
     14//      Classe pour la création d'objets, capables de se dessiner
     15//      dans une composante graphique ("PIBaseWdg").
     16//--
     17//++
     18// Links        Voir
     19// PIBaseWdg
     20//--
     21
     22//++
     23// Titre        Constructeurs et méthodes
     24//--
     25
     26//++
     27// PIDawer()
     28//      Constructeur.
     29//--
    330
    431PIDrawer::PIDrawer()
     
    3259}
    3360
     61//++
     62// void  SetLimits(float xmin, float xmax, float ymin, float ymax, -
     63//                 int axrl=kAxeDirSame, int ayud=kAxeDirSame)
     64//      Définit les limites du système de coordonnées.
     65// void  SetAxesFlags(unsigned int flags=kAxesNone)
     66//      Attributs de tracé d'axes
     67//|     kStdAxes , kBoxAxes , kTicks , kIntTicks , kExtTicks
     68//|     kMajTicks , kMinTicks , kLabels , kAxesDflt , kAxesNone
     69// void  DrawAxes(PIGraphicUC* g)
     70//      Méthode de tracé des axes
     71//--
    3472
    3573void
     
    62100}
    63101
     102//++
     103//  void  Draw(PIGraphicUC* g, float xmin, float ymin, float xmax, float ymax)
     104//      Méthode qui est appelé lorsquer l'objet PIDrawer doit rafraichir la zone
     105//      définie par "xmin-xmax" , "ymin-ymax" dans le système de coordonnées du
     106//      PIDrawer.
     107//  void  Refresh()
     108//      Rafraîchit le dessin du PIDrawer sur tous les PIBaseWdg auxquel il est attaché.
     109//  void  UpdateLimits()
     110//      Cette méthode doit calculer les limites (X/Y Min-Max) préferées par l'objet
     111//      et doit appeler "SetLimits()". L'implementation par défaut ne fait rien.
     112//--
    64113
    65114void
     
    78127
    79128}
     129
     130//++
     131// Titre        Les attributs graphiques
     132//--
     133//++
     134// void  SetColAtt(PIColors fg=PI_NotDefColor, PIColors bg=PI_NotDefColor)
     135//      Modifie la couleur d'avant-plan et de fond par défaut
     136// void  SetLineAtt(PILineAtt lat=PI_NotDefLineAtt)
     137//      Modifie l'attribut type de ligne
     138// void  SetFontAtt(PIFontSize fsz=PI_NotDefFontSize, PIFontAtt fat=PI_NotDefFontAtt)
     139//      L'attribut Type de fonte
     140// void  SetMarkerAtt(int sz=-1, PIMarker mrk=PI_NotDefMarker)
     141//      L'attribut type et taille de marker
     142// void  SetColMapId(CMapId cid=CMAP_OTHER)
     143//      L'attribut choix de la table de couleurs
     144// void  SelGraAtt(PIGraphicUC* g)
     145//      Modifie les attributs graphiques de "g" à partir des attributs courant
     146//      de l'objet "PIDrawer"
     147//--
    80148
    81149void
     
    384452{
    385453mEn = 0;
     454titleT = titleB = "";
    386455}
    387456
     
    392461
    393462/* --Methode-- */
     463void PIElDrawer::SetTitles(const char* tt, const char* tb)
     464{
     465if (tt != NULL)  titleT = tt;
     466if (tb != NULL)  titleB = tb;
     467}
     468
     469/* --Methode-- */
     470void PIElDrawer::SetTitles(string const & tt, string const & tb)
     471{
     472titleT = tt;  titleB = tb;
     473}
     474
     475/* --Methode-- */
    394476void  PIElDrawer::Draw(PIGraphicUC* g, float /*xmin*/, float /*ymin*/, float /*xmax*/, float /*ymax*/)
    395477{
     
    397479
    398480SelGraAtt(g);   // DrawAxes change certains attributs graphiques
     481if (mFSz == PI_NotDefFontSize) g->SelFont(PI_NormalSizeFont);
     482// Trace des titres
     483if ( (titleT.length() > 0) || (titleB.length() > 0) ) {
     484  aXdir = false;  // Vrai si Axe X de Droite vers Gauche
     485  aYdir = false;  // Vrai si Axe Y de Haut vers Bas
     486  PIGrCoord gas, gds;
     487  float fx, fy, fh;
     488//  fh = g->GetFontHeightUC(gas, gds);
     489  fh = 0.075*(YMax()-YMin());
     490  if ( titleT.length() > 0) {
     491      fx = g->CalcStringWidth(titleT.c_str());
     492      if(aXdir) fx = XMax()-(XMax()-XMin()-fx)/2.;
     493      else fx = XMin()+(XMax()-XMin()-fx)/2.;
     494      if (aYdir) fy = YMin()-fh;
     495      else fy = YMax()+fh;
     496      g->DrawString(fx, fy, titleT.c_str());
     497//      printf(" PIElDrawer::Draw()/DBG (%g , %g) %s  - %g \n", fx, fy, titleT.c_str(), fh);
     498    }
     499  if ( titleB.length() > 0) {
     500      fx = g->CalcStringWidth(titleB.c_str());
     501      if(aXdir) fx = XMax()-(XMax()-XMin()-fx)/2.;
     502      else fx = XMin()+(XMax()-XMin()-fx)/2.;
     503      if (aYdir) fy =  YMax()+fh*1.5;
     504      else fy = YMin()-fh*1.5;
     505      g->DrawString(fx, fy, titleB.c_str());
     506//      printf(" PIElDrawer::Draw()/DBG (%g , %g) %s  - %g \n", fx, fy, titleT.c_str(), fh);
     507    }
     508  }
    399509DrwElList::iterator it;
     510PIColors cc = g->GetForeground();
    400511for (it = mElist.begin(); it != mElist.end(); it++)
    401512  {
     513  if ((*it).col != PI_NotDefColor)  g->SelForeground((*it).col);
    402514  switch ( (*it).etyp )
    403515    {
     
    423535      break;
    424536    }
    425   }
    426 }
    427 
    428 
    429 /* --Methode-- */
    430 int PIElDrawer::ElAdd(int typ, PIGrCoord x, PIGrCoord  y, PIGrCoord dx, PIGrCoord dy, char* s)
     537  g->SelForeground(cc);
     538  }
     539}
     540
     541
     542/* --Methode-- */
     543int PIElDrawer::ElAdd(int typ, PIGrCoord x, PIGrCoord  y, PIGrCoord dx, PIGrCoord dy, const char* s, PIColors c)
    431544{
    432545DrwEl dre;
     
    435548dre.ex = x;   dre.ey = y;
    436549dre.edx = dx;  dre.edy = dy;
     550dre.col = c;
    437551if (s)  dre.es = s;
    438552mElist.push_back(dre);
  • trunk/SophyaPI/PI/pidrawer.h

    r127 r158  
    125125  virtual           ~PIElDrawer();
    126126
     127  virtual void       SetTitles(const char* tt=NULL, const char* tb=NULL);
     128  virtual void       SetTitles(string const & tt, string const & tb);
     129
    127130  virtual void       Draw(PIGraphicUC* g, float xmin, float ymin, float xmax, float ymax);
    128131
    129   inline int         ElAddLine(PIGrCoord x1, PIGrCoord y1, PIGrCoord x2, PIGrCoord y2)
    130     { return( ElAdd(PIDEL_Line, x1, y1, x2, y2, NULL) ); } 
    131   inline int         ElAddText(PIGrCoord x, PIGrCoord y, char* s)
    132     { return( ElAdd(PIDEL_Text, x, y, 0, 0, s) ); } 
    133   inline int         ElAddRect(PIGrCoord x, PIGrCoord y, PIGrCoord dx, PIGrCoord dy)
    134     { return( ElAdd(PIDEL_Rect, x, y, dx, dy, NULL) ); } 
    135   inline int         ElAddFRect(PIGrCoord x, PIGrCoord y, PIGrCoord dx, PIGrCoord dy)
    136     { return( ElAdd(PIDEL_FRect, x, y, dx, dy, NULL) ); } 
    137   inline int         ElAddCirc(PIGrCoord x, PIGrCoord y, PIGrCoord r)
    138     { return( ElAdd(PIDEL_Circ, x, y, r, r, NULL) ); } 
    139   inline int         ElAddFCirc(PIGrCoord x, PIGrCoord y, PIGrCoord r)
    140     { return( ElAdd(PIDEL_FCirc, x, y, r, r, NULL) ); } 
     132  inline int         ElAddLine(PIGrCoord x1, PIGrCoord y1, PIGrCoord x2, PIGrCoord y2,
     133                               PIColors c=PI_NotDefColor)
     134    { return( ElAdd(PIDEL_Line, x1, y1, x2, y2, NULL, c) ); } 
     135  inline int         ElAddText(PIGrCoord x, PIGrCoord y, const char* s, PIColors c=PI_NotDefColor)
     136    { return( ElAdd(PIDEL_Text, x, y, 0, 0, s, c) ); } 
     137  inline int         ElAddRect(PIGrCoord x, PIGrCoord y, PIGrCoord dx, PIGrCoord dy,
     138                               PIColors c=PI_NotDefColor)
     139    { return( ElAdd(PIDEL_Rect, x, y, dx, dy, NULL, c) ); } 
     140  inline int         ElAddFRect(PIGrCoord x, PIGrCoord y, PIGrCoord dx, PIGrCoord dy,
     141                               PIColors c=PI_NotDefColor)
     142    { return( ElAdd(PIDEL_FRect, x, y, dx, dy, NULL, c) ); } 
     143  inline int         ElAddCirc(PIGrCoord x, PIGrCoord y, PIGrCoord r, PIColors c=PI_NotDefColor)
     144    { return( ElAdd(PIDEL_Circ, x, y, r, r, NULL, c) ); } 
     145  inline int         ElAddFCirc(PIGrCoord x, PIGrCoord y, PIGrCoord r, PIColors c=PI_NotDefColor)
     146    { return( ElAdd(PIDEL_FCirc, x, y, r, r, NULL, c) ); } 
    141147
    142148  void               ElDel(int id);
     
    144150
    145151protected:
    146   int                ElAdd(int typ, PIGrCoord x, PIGrCoord y, PIGrCoord dx, PIGrCoord dy, char* s);
     152  int                ElAdd(int typ, PIGrCoord x, PIGrCoord y, PIGrCoord dx, PIGrCoord dy,
     153                           const char* s, PIColors c=PI_NotDefColor);
    147154#ifdef __DECCXX
    148155public:
     
    153160    PIGrCoord edx,edy;
    154161    string es;
     162    PIColors col;
    155163  };
    156164#ifdef __DECCXX
     
    162170  int mEn;
    163171
     172  string titleT, titleB;       // Titre Haut - Bas
     173
    164174};
    165175
  • trunk/SophyaPI/PI/pidrwtools.cc

    r149 r158  
    184184mOpt[4]->AppendItem("Ital", 513);
    185185mOpt[4]->AppendItem("Small-Font", 521);
    186 mOpt[4]->AppendItem("Small-Bold-Font", 522);
    187 mOpt[4]->AppendItem("Small-Ital-Font", 523);
     186mOpt[4]->AppendItem("Small-Bold", 522);
     187mOpt[4]->AppendItem("Small-Ital", 523);
    188188mOpt[4]->AppendItem("Big-Font", 531);
    189189mOpt[4]->AppendItem("Big-Bold", 532);
    190190mOpt[4]->AppendItem("Big-Ital", 533);
     191mOpt[4]->AppendItem("Huge-Font", 541);
     192mOpt[4]->AppendItem("Huge-Bold", 542);
     193mOpt[4]->AppendItem("Huge-Ital", 543);
    191194mOpt[4]->SetValue(500);
    192195mOpt[4]->SetBinding(PIBK_elastic, PIBK_elastic, PIBK_elastic, PIBK_elastic);
     
    305308
    306309PIFontAtt fntatt[4] = { PI_NotDefFontAtt, PI_RomanFont, PI_BoldFont, PI_ItalicFont };
    307 PIFontSize fntsz[4] = { PI_NotDefFontSize, PI_NormalSizeFont, PI_SmallSizeFont, PI_BigSizeFont };
     310PIFontSize fntsz[5] = { PI_NotDefFontSize, PI_NormalSizeFont, PI_SmallSizeFont,
     311                        PI_BigSizeFont, PI_HugeSizeFont };
    308312CMapId cmap[11] = {  CMAP_OTHER, CMAP_GREY32, CMAP_GREYINV32,
    309313                     CMAP_COLRJ32, CMAP_COLBR32, CMAP_COLRV32, 
  • 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 }
  • trunk/SophyaPI/PI/pigraph3d.h

    r155 r158  
     1// This may look like C code, but it is really -*- C++ -*-
    12// Module PI : Peida Interactive     PIGraphic3D
    23// Trace graphiques 3D               R. Ansari  06/98
     
    3435  virtual void       Proj3DC2GrC(float x, float y, float z, float& xpix, float& ypix);
    3536 
    36   virtual void       DrawString3D(PIGrCoord x0, PIGrCoord y0, PIGrCoord z0, char* s);
    37   virtual void       DrawOpaqueString3D(PIGrCoord x0, PIGrCoord y0, PIGrCoord z0, char* s);
     37  virtual void       DrawString3D(PIGrCoord x0, PIGrCoord y0, PIGrCoord z0, const char* s);
     38  virtual void       DrawOpaqueString3D(PIGrCoord x0, PIGrCoord y0, PIGrCoord z0, const char* s);
    3839  virtual void       DrawLine3D(PIGrCoord x1, PIGrCoord y1, PIGrCoord z1,
    3940                                PIGrCoord x2, PIGrCoord y2, PIGrCoord z2);
  • trunk/SophyaPI/PI/pigraphgen.cc

    r147 r158  
    1717//      "PIGraphicWin" ou "PIGraphicUC" ou ...
    1818//      La classe "PIGraphicWin" a une implementation dépendante du système
    19 //      utilisé et sa
    20 //      "
    21 //      Un type particulier *PIGrCoord* permettant de passer les coordonnées
    22 //      graphiques en entier ("int") ou en flottant ("float").
    23 //--
    24 
    25 //
    26 //      "
    27 //      "
    28 //      "
    29 //      "
    30 //      "
    31 //      "
     19//      utilisé (Mac, XWindow, ...).
     20//      Un type particulier *PIGrCoord* est défini pour la spécification
     21//      des coordonnées graphiques.
     22//--
     23//++
     24// Links        Voir aussi
     25// PIGrCoord
     26// PIColorMap
     27//--
     28
     29//++
     30// Titre        Constructeurs
     31//--
     32//++
     33// PIGraphic()
     34//      Constructeur utilisé par les classes dérivées.
     35// PIGraphic(PIWdg* wdg)
     36//      Constructeur pour les *PIGraphicWin*. Objet "PIGraphic" capable
     37//      de tracer dans un "PIWdg".
     38//--
     39//++
     40//--
     41// Titre        Méthodes
     42//++
     43// int  kind()
     44//      Renvoie le type de l'objet "PIGraphic" .
     45//      * PI_ScrWindowGraphics : Objet PIGraphic associé à une fenêtre sur l'écran (PIWdg)
     46//      * PI_PSFileGraphics : Objet PIGraphic à un fichier PostScript (pour impression papier)
     47//      * PI_UCGraphics : Objet PIGraphic travaillant dans un système de coordonnées utilisateur.
     48//      * PI_3DGraphics : Objet PIGraphic fournissant des méthodes de tracé en coordonnées 3-D
     49// void  GetGrSpace(PIGrCoord& xmin, PIGrCoord& xmax, PIGrCoord& ymin, PIGrCoord& ymax)
     50//      Renvoie les limites de l'espace graphique - Coordonnées fenêtre pour un PIGraphicWin,
     51//      Limites définies par l'utilisateur pour un PIGraphicUC
     52// void  Erase(PIGrCoord x0, PIGrCoord y0, PIGrCoord dx, PIGrCoord dy)
     53//      Efface le rectangle défini par le coin "x0,y0", de longeur et de largeur "dx,dy"
     54//      en utilisant la couleur d'arrière plan (Background)
     55//--
     56
    3257
    3358/* --Methode-- */
     
    5277return PI_ScrWindowGraphics;
    5378}
     79
    5480
    5581/* --Methode-- */
     
    6389  }
    6490}
     91
     92//++
     93// Titre        Tracés de texte
     94//--
     95//++
     96// void  DrawString(PIGrCoord x, PIGrCoord y, const char* s, int pos = 0)
     97//      Trace la chaîne de caractères "s" à la position "x,y",
     98//      en utilisant la couleur d'avant-plan (Foreground)
     99// void  DrawOpaqueString(PIGrCoord x, PIGrCoord y, const char* s, int pos = 0)
     100//      Trace la chaîne de caractères "s" à la position "x,y" . La couleur d'
     101//      arrière-plan est utilisée pour remplir la zone rectangulaire occupée par
     102//      le tracé de texte.
     103//--
     104
     105//++
     106// Titre        Tracés de lignes et de figures géometriques
     107//--
     108//++
     109// void  DrawLine(PIGrCoord x1, PIGrCoord y1, PIGrCoord x2, PIGrCoord y2)
     110//      Trace une ligne entre les points de coordonnées "(x1,y1)" et "(x2,y2)",
     111//      en utilisant la couleur d'avant-plan (Foreground)
     112// void  DrawBox(PIGrCoord x0, PIGrCoord y0, PIGrCoord dx, PIGrCoord dy)
     113//      Tracé du contour d'un rectangle défini par la position du coin "(x0,y0)"
     114//      et de taille "dx,dy" avec la couleur d'avant-plan.
     115// void  DrawFBox(PIGrCoord x0, PIGrCoord y0, PIGrCoord dx, PIGrCoord dy)
     116//      Tracé d'un rectangle plein, défini par la position du coin "(x0,y0)"
     117//      et de taille "dx,dy" avec la couleur d'avant-plan.
     118// void  DrawCircle(PIGrCoord x0, PIGrCoord y0, PIGrCoord r) 
     119//      Tracé du contour d'un cercle centré en "(x0,y0)", de rayon "r"
     120// void  DrawFCircle(PIGrCoord x0, PIGrCoord y0, PIGrCoord r) 
     121//      Tracé d'un cercle plein centré en "(x0,y0)", de rayon "r"
     122// void  DrawOval(PIGrCoord x0, PIGrCoord y0, PIGrCoord dx, PIGrCoord dy)
     123//      Tracé d'une ellipse incluse dans le rectangle "(x0,y0)" , "dx,dy"
     124// void  DrawFOval(PIGrCoord x0, PIGrCoord y0, PIGrCoord dx, PIGrCoord dy)
     125//      Tracé d'une ellipse pleine incluse dans le rectangle "(x0,y0)" , "dx,dy"
     126// void  DrawPolygon(PIGrCoord *x, PIGrCoord *y, int n, bool cinc=true)
     127//      Tracé du contour d'un polygone défini par le tableau des "n" points "x,y".
     128//      Si "cinc==true", les coordonnées seront considérées comme relatives
     129//      à la position du point "(x[0], y[0])". Dans le cas contraire, chaque couple
     130//      "(x[i], y[i])" représentera les coordonnées absolues d'un coin du polygone.
     131// void  DrawFPolygon(PIGrCoord *x, PIGrCoord *y, int n, bool cinc=true)
     132//      Tracé d'un polygone plein de la couleur d'avant-plan.
     133// void  DrawArc(PIGrCoord x0, PIGrCoord y0, PIGrCoord dx, PIGrCoord dy, float degdeb, float degfin)
     134//      Tracé d'un arc de cercle ou d'ellipse, inclu dans le "(x0,y0)" , "dx,dy"
     135//      entre les angles (en degré) "degdeb" - "degfin"
     136// void  DrawFArc(PIGrCoord x0, PIGrCoord y0, PIGrCoord dx, PIGrCoord dy, float degdeb, float degfin)
     137//      Tracé d'un arc plein, inclu dans le "(x0,y0)" , "dx,dy"
     138//      entre les angles (en degré) "degdeb" - "degfin"
     139//--
     140
     141//++
     142// Titre        Tracés de signes
     143//--
     144//++
     145// void  DrawMarker(PIGrCoord x0, PIGrCoord y0) 
     146//      Tracé d'un signe au point "(x0,y0)". Le choix du signe tracé s'effectue
     147//      à travers la méthode "SelMarker()"
     148// void  DrawMarkers(PIGrCoord *x, PIGrCoord *y, int n)
     149//      Tracé de "n" signes aux points "(x[i],y[i])"
     150//--
     151
     152//++
     153// Titre        Tracé d'images (pixmap)
     154//--
     155//++
     156// void  DrawPixmap(PIGrCoord x, PIGrCoord y, unsigned char *pix, int sx, int sy, PIColorMap* cmap)
     157//      Tracé d'un pixmap dans un rectangle positionné en "(x,y)". Le tableau des pixels
     158//      "pix", de taille "sx,sy" représente les index dans la table de couleur "cmap".
     159//--
     160
     161//++
     162// Titre        Modifications des attributs graphiques 
     163//--
     164//++
     165// void  SelForeground(PIColors col=PI_Black)
     166//      Choix de la couleur de tracé d'avant-plan
     167//|     PI_Black , PI_White,  PI_Grey , PI_Red , PI_Blue , PI_Green , 
     168//|     PI_Yellow , PI_Magenta , PI_Cyan , PI_Turquoise , PI_NavyBlue ,
     169//|     PI_Orange , PI_SiennaRed , PI_Purple , PI_LimeGreen , PI_Gold
     170// void  SelBackground(PIColors col=PI_White)
     171//      Choix de la couleur d'arrière-plan
     172// void  SelForeground(PIColorMap& cmap, int cid)
     173//      Choix de la couleur de tracé d'avant-plan: Couleur numéro "cid" de la table de couleur "cmap"
     174// void  SelBackground(PIColorMap& cmap, int cid)
     175//      Choix de la couleur d'arrière-plan: Couleur numéro "cid" de la table de couleur "cmap"
     176// void  SelGOMode(PIGOMode mod=PI_GOCopy)
     177//      Choix du mode de tracé graphique: "PI_GOCopy" ou "PI_GOXOR"     
     178// void  SelFont(PIFontSize sz=PI_NormalSizeFont, PIFontAtt att=PI_RomanFont)
     179//      Choix de la fonte pour le tracé de texte
     180//|     PI_SmallSizeFont , PI_NormalSizeFont , PI_BigSizeFont, PI_HugeSizeFont
     181//|     PI_RomanFont , PI_BoldFont , PI_ItalicFont
     182// void  SelFontSzPt(int npt=12, PIFontAtt att=PI_RomanFont)
     183//      Choix de la fonte avec spécification de taille en points (pixels sur l'écran)
     184// void  SelLine(PILineAtt att=PI_NormalLine)
     185//      Choix du type de ligne pour le tracé des lignes et contours
     186//|     PI_NormalLine, PI_ThinLine , PI_ThickLine
     187//|     PI_DashedLine, PI_ThinDashedLine , PI_ThickDashedLine
     188// void  SelMarker(int msz=3, PIMarker mrk=PI_DotMarker)
     189//      Choix de la taille et du type de signe pour "DrawMarker() / DrawMarkers()"
     190//|     PI_DotMarker , PI_PlusMarker , PI_CrossMarker
     191//|     PI_CircleMarker , PI_FCircleMarker , PI_BoxMarker , PI_FBoxMarker
     192//|     PI_TriangleMarker , PI_FTriangleMarker , PI_StarMarker , PI_FStarMarker
     193//      (Les "StarMaker" ne sont pas encore implémentés  11/98)
     194//--
     195
     196//++
     197// Titre        Sélection de la zone de tracé (clip)   
     198//--
     199//++
     200// void  SetClipRectangle(PIGrCoord x0, PIGrCoord y0, PIGrCoord dx, PIGrCoord dy)
     201//      Limite la zone de tracé permise au rectangle "(x0,y0)", "dx,dy"
     202// void  ClearClipRectangle()
     203//      Supprime si nécéssaire la limitation de la zone de tracé.       
     204//--
     205
     206//++
     207// Titre        Accès aux attributs graphiques
     208//--
     209//++
     210// PIColors  GetForeground()
     211//      Renvoie la couleur de tracé d'avant-plan courante.
     212//      ("PI_ColorFromMap" si défini à partir d'une table de couleur
     213// PIColors  GetBackground()
     214//      Renvoie la couleur d'arrière-plan courante.
     215// PIGOMode  GetGOMode()
     216//      Renvoie le mode de tracé graphique courante.
     217// PIFontAtt GetFontAtt()
     218//      Renvoie les attributs de la fonte courante.
     219// int GetFontSize()
     220//      Renvoie la taille de la fonte courante.
     221// PILineAtt GetLineAtt()
     222//      Renvoie le type de ligne courant
     223// PIMarker  GetMarker()
     224//      Renvoie le type de signe (Marker) courant
     225// int GetMarkerSize()
     226//      Renvoie la taille des signes (Marker) pour le marker courant
     227// int GetFontHeight(int& asc, int& desc)
     228//      Renvoie la hauteur des caractères, ainsi que la taille au dessus
     229//      et en-dessous de la ligne de base ("asc , desc") pour la fonte courante
     230// PIGrCoord CalcStringWidth(char const* s)
     231//      Renvoie la largeur occupé par un texte s'il était affiché dans le
     232//      système de coordonnées courant (Fenêtre ou UC).
     233//--
     234
     235//++
     236// Titre        Sauvegarde et rappel des attributs graphiques
     237//--
     238//++
     239// void  SaveGraphicAtt()
     240//      Sauvegarde des attributs graphiques courants
     241// void  RestoreGraphicAtt()
     242//      Utilisation de l'ensemble des attributs graphiques sauvegardés par un appel
     243//      à "SaveGraphicAtt()"
     244//--
     245
    65246
    66247/* --Methode-- */
     
    89270  return;
    90271}
     272
     273
     274
     275
     276//++
     277// Class        PIGrCoord
     278// Lib          PI
     279// include      pigraphgen.h
     280//
     281//      Classe utilisé pour la spécifiaction de coordonnées graphique.
     282//      Des constructeurs et des méthodes de conversion à partir
     283//      et vers des "int", "float" et "double" sont définis.
     284//      L'objet conserve le type effectif de l'argument lors de la
     285//      création ou de la dernière affectation.
     286//
     287//|     PIGrCoord gco;
     288//|     gco = 3.141596 ;
     289//|     int ic = gco;     // ic -> 3
     290//|     float fc = gco;   // fc -> 3.141596
     291//--
     292//++
     293// Links        Voir aussi
     294// PIGraphic
     295//--
     296
     297//++
     298// Titre        Constructeurs
     299//--
     300//++
     301//
     302// PIGrCoord()
     303//      Constructeur par défaut ("intVal=floatVal=0")
     304// PIGrCoord(int a)
     305//      Constructeur à partir de l'entier "a"
     306// PIGrCoord(float a)
     307//      Constructeur à partir de la valeur flottante "a"
     308// PIGrCoord(double a)
     309//      Constructeur à partir de la valeur flottante double précision "a"
     310//--
     311//++
     312// Titre        Opérateurs de conversion
     313//--
     314//++
     315// operator int()
     316//      Conversion en entier "int"
     317// operator short()
     318//      Conversion en entier "short"
     319// operator unsigned int()
     320//      Conversion en entier non signé "unsigned int"
     321// operator unsigned short()
     322//      Conversion en entier non signé "unsigned short"
     323// operator float()
     324//      Conversion en réél "float"
     325//--
     326//++
     327// Titre        Opérateurs d'affectation
     328//--
     329//++
     330// PIGrCoord& operator= (int a)
     331//      Affectation à partir de valeur entière "int"
     332// PIGrCoord& operator= (float a)
     333//      Affectation à partir de valeur réélle "float"
     334// PIGrCoord& operator= (double a)
     335//      Affectation à partir de valeur réélle double précision "double"
     336//--
  • trunk/SophyaPI/PI/pigraphgen.h

    r141 r158  
    2121
    2222enum PIFontSize { PI_NotDefFontSize = -1,
    23                   PI_SmallSizeFont = 1, PI_NormalSizeFont = 2, PI_BigSizeFont = 3 };
     23                  PI_SmallSizeFont = 1, PI_NormalSizeFont = 2,
     24                  PI_BigSizeFont = 3, PI_HugeSizeFont = 4 };
    2425
    2526enum PIFontAtt { PI_NotDefFontAtt = -1,
     
    7879//  Trace graphiques
    7980  virtual void       Erase(PIGrCoord x0, PIGrCoord y0, PIGrCoord dx, PIGrCoord dy)     = 0;
    80   virtual void       DrawString(PIGrCoord x, PIGrCoord y, char* s, int pos = 0)        = 0;
    81   virtual void       DrawOpaqueString(PIGrCoord x, PIGrCoord y, char* s, int pos = 0)  = 0;
     81  virtual void       DrawString(PIGrCoord x, PIGrCoord y, const char* s, int pos = 0)        = 0;
     82  virtual void       DrawOpaqueString(PIGrCoord x, PIGrCoord y, const char* s, int pos = 0)  = 0;
    8283  virtual void       DrawLine(PIGrCoord x1, PIGrCoord y1, PIGrCoord x2, PIGrCoord y2)  = 0;
    8384  virtual void       DrawBox(PIGrCoord x0, PIGrCoord y0, PIGrCoord dx, PIGrCoord dy)   = 0;
     
    8586  virtual void       DrawCircle(PIGrCoord x0, PIGrCoord y0, PIGrCoord r)               = 0;
    8687  virtual void       DrawFCircle(PIGrCoord x0, PIGrCoord y0, PIGrCoord r)              = 0;
     88  virtual void       DrawOval(PIGrCoord x0, PIGrCoord y0, PIGrCoord dx, PIGrCoord dy)  = 0;
     89  virtual void       DrawFOval(PIGrCoord x0, PIGrCoord y0, PIGrCoord dx, PIGrCoord dy) = 0;
    8790  virtual void       DrawPolygon(PIGrCoord *x, PIGrCoord *y, int n, bool cinc=true)    = 0; 
    8891  virtual void       DrawFPolygon(PIGrCoord *x, PIGrCoord *y, int n, bool cinc=true)   = 0; 
     92  virtual void       DrawArc(PIGrCoord x0, PIGrCoord y0, PIGrCoord dx, PIGrCoord dy,
     93                             float degdeb, float degfin)                               = 0;
     94  virtual void       DrawFArc(PIGrCoord x0, PIGrCoord y0, PIGrCoord dx, PIGrCoord dy,
     95                              float degdeb, float degfin)                              = 0;
    8996  virtual void       DrawMarker(PIGrCoord x0, PIGrCoord y0)                            = 0;
    9097  virtual void       DrawMarkers(PIGrCoord *x, PIGrCoord *y, int n)                    = 0;
  • trunk/SophyaPI/PI/pigraphps.cc

    r147 r158  
     1// Module PI : Peida Interactive     PIGraphicPS
     2// Trace graphiques en PostScript    R. Ansari  97
     3// LAL (Orsay) / IN2P3-CNRS  DAPNIA/SPP (Saclay) / CEA
     4
    15#include <stdio.h>
    26
    37#include "pigraphps.h"
    48
     9//++
     10// Class        PIGraphicPS
     11// Lib          PI
     12// include      pigraphps.h
     13//
     14//      Classe les services de tracé graphique avec sortie PostScript
     15//      Toutes les méthodes de tracé de "PIGraphic" sont redéfinies pour
     16//      produire du PostScript
     17//--
     18//++
     19// Links        Parent
     20// PIGraphic
     21//--
     22//++
     23// Links        Voir aussi
     24// PSFile
     25//--
     26
     27//++
     28// Titre        Constructeurs, méthodes
     29//--
     30//++
     31// PIGraphicPS(PSFile * psf, float x0, float y0, float dx, float dy)
     32//      Création d'un objet "PIGraphicPS" à partir d'un objet "PSFIle* psf".
     33//      "(x0, y0)" détermine l'origine du nouveau bloc rectangulaire sur
     34//      la page et "dx, dy" l'extension du bloc.
     35// PIGraphicPS(PSFile * psf, PIWdg* wdg, float ofx, float ofy)
     36//      Création d'un objet "PIGraphicPS" à partir d'un objet "PSFIle* psf"
     37//|     x0 = wdg->XPos()+ofx    y0 = wdg->YPos()+ofy
     38//|     dx = wdg->XSize()       dy = wdg->YSize()
     39//
     40// int kind()
     41//       Renvoie le type ("= PI_PSFileGraphics")
     42//--
    543
    644/* --Methode-- */
     
    70108
    71109/* --Methode-- */
    72 void PIGraphicPS::DrawString(PIGrCoord x, PIGrCoord y, char* s, int /*pos*/)
     110void PIGraphicPS::DrawString(PIGrCoord x, PIGrCoord y, const char* s, int /*pos*/)
    73111{
    74112if(mPSOut)
     
    78116
    79117/* --Methode-- */
    80 void PIGraphicPS::DrawOpaqueString(PIGrCoord x, PIGrCoord y, char* s, int /*pos*/)
     118void PIGraphicPS::DrawOpaqueString(PIGrCoord x, PIGrCoord y, const char* s, int /*pos*/)
    81119{
    82120if(mPSOut)
     
    125163  mPSOut->DrawFCircle((float)x0,(float)y0,(float)r,mFCol,mFCol,mLAtt);
    126164return;
     165}
     166
     167/* --Methode-- */
     168void PIGraphicPS::DrawOval(PIGrCoord x0, PIGrCoord y0, PIGrCoord dx, PIGrCoord dy)
     169{
     170// $CHECK$ Reza/ Nicolas  12 Nov 98 - A faire
     171}
     172
     173/* --Methode-- */
     174void PIGraphicPS::DrawFOval(PIGrCoord x0, PIGrCoord y0, PIGrCoord dx, PIGrCoord dy)
     175{
     176// $CHECK$ Reza/ Nicolas  12 Nov 98 - A faire
    127177}
    128178
     
    182232
    183233return;
     234}
     235
     236/* --Methode-- */
     237void PIGraphicPS::DrawArc(PIGrCoord x0, PIGrCoord y0, PIGrCoord dx, PIGrCoord dy,float degdeb, float degfin)
     238{
     239// $CHECK$ Reza/ Nicolas  12 Nov 98 - A faire
     240}
     241
     242/* --Methode-- */
     243void PIGraphicPS::DrawFArc(PIGrCoord x0, PIGrCoord y0, PIGrCoord dx, PIGrCoord dy,float degdeb, float degfin)
     244{
     245// $CHECK$ Reza/ Nicolas  12 Nov 98 - A faire
    184246}
    185247
  • trunk/SophyaPI/PI/pigraphps.h

    r113 r158  
    2020//  Trace graphiques
    2121  virtual void       Erase(PIGrCoord x0, PIGrCoord y0, PIGrCoord dx, PIGrCoord dy);
    22   virtual void       DrawString(PIGrCoord x, PIGrCoord y, char* s, int pos = 0);
    23   virtual void       DrawOpaqueString(PIGrCoord x, PIGrCoord y, char* s, int pos = 0);
     22  virtual void       DrawString(PIGrCoord x, PIGrCoord y, const char* s, int pos = 0);
     23  virtual void       DrawOpaqueString(PIGrCoord x, PIGrCoord y, const char* s, int pos = 0);
    2424  virtual void       DrawLine(PIGrCoord x1, PIGrCoord y1, PIGrCoord x2, PIGrCoord y2);
    2525  virtual void       DrawBox(PIGrCoord x0, PIGrCoord y0, PIGrCoord dx, PIGrCoord dy);
     
    2727  virtual void       DrawCircle(PIGrCoord x0, PIGrCoord y0, PIGrCoord r);
    2828  virtual void       DrawFCircle(PIGrCoord x0, PIGrCoord y0, PIGrCoord r);
     29  virtual void       DrawOval(PIGrCoord x0, PIGrCoord y0, PIGrCoord dx, PIGrCoord dy);
     30  virtual void       DrawFOval(PIGrCoord x0, PIGrCoord y0, PIGrCoord dx, PIGrCoord dy);
    2931  virtual void       DrawPolygon(PIGrCoord *x, PIGrCoord *y, int n, bool cinc=true); 
    3032  virtual void       DrawFPolygon(PIGrCoord *x, PIGrCoord *y, int n, bool cinc=true); 
     33  virtual void       DrawArc(PIGrCoord x0, PIGrCoord y0, PIGrCoord dx, PIGrCoord dy,
     34                             float degdeb, float degfin);
     35  virtual void       DrawFArc(PIGrCoord x0, PIGrCoord y0, PIGrCoord dx, PIGrCoord dy,
     36                              float degdeb, float degfin);
    3137  virtual void       DrawMarker(PIGrCoord x0, PIGrCoord y0);
    3238  virtual void       DrawMarkers(PIGrCoord *x, PIGrCoord *y, int n);
  • trunk/SophyaPI/PI/pigraphuc.cc

    r139 r158  
    55#include "pigraphuc.h"
    66
     7//++
     8// Class        PIGraphicUC
     9// Lib          PI
     10// include      pigraphuc.h
     11//
     12//      Classe fournissant les services de tracé graphique
     13//      en coordonnées utilisateur.
     14//      Toutes les méthodes de tracé de "PIGraphic" sont redéfinies pour
     15//      accepter les arguments en système de coordonnées utilisateur.
     16//--
     17//++
     18// Links        Parent
     19// PIGraphic
     20//--
    721
    822// Pour echanger deux valeurs PIGrCoord
     
    1024static inline void fl_swap(float& grc1, float& grc2)
    1125{ swpfl = grc1; grc1 = grc2; grc2 = swpfl; }
     26
     27//++
     28// Titre        Constructeurs, méthodes
     29//--
     30//++
     31// PIGraphicUC(PIGraphicGen* g, PIGrCoord x0, PIGrCoord y0, PIGrCoord dx, PIGrCoord dy)
     32//      Constructeur d'un objet "PIGraphUC" à partir d'un "PIGraphicGen* g". L'espace
     33//      de travail du nouvel objet "PIGraphic" correspond au rectangle défini par
     34//      "(x0,y0)" , "dx,dy" du "PIGraphic" de départ.
     35//
     36// int  kind()
     37//      Renvoie le type ("= PI_UCGraphics")
     38// void SetBaseGraphic(PIGraphicGen* g, PIGrCoord x0, PIGrCoord y0, PIGrCoord dx, PIGrCoord dy)
     39//      Permet de modifier l'objet "PIGraphic" de départ et l'espace graphique correspondant.
     40//
     41// void  SelFontSz(PIGrCoord sz, PIFontAtt att=PI_RomanFont)
     42//      Sélection de fonte avec la taille exprimée en coordonnées utilisateur
     43// void  SelMarkerSz(PIGrCoord msz, PIMarker mrk=PI_DotMarker)
     44//      Sélection de marker avec la taille exprimée en coordonnées utilisateur
     45//--
    1246
    1347/* --Methode-- */
     
    3569}
    3670
     71
    3772/* --Methode-- */
    3873void PIGraphicUC::SetBaseGraphic(PIGraphicGen* g, PIGrCoord x0, PIGrCoord y0, PIGrCoord dx, PIGrCoord dy)
     
    5186}
    5287
     88//++
     89// Titre        Système de coordonnées utilisateur
     90//--
     91//++
     92// void       SetUCS(float xmin, float xmax, float ymin, float ymax, -
     93// int axrl=kAxeDirSame, int ayud=kAxeDirSame)
     94//      Définit le système de coordonnées utilisateur. Axe X de "xmin" à "xmax" ,
     95//      Axe Y de "ymin" à "ymax". "axrl", "ayud" définit le sens des axes
     96//      sur la fenêtre :
     97//|     kAxeDirSame : Pas de changement de sens
     98//|     kAxeDirLtoR : Axe X croissant de gauche à droite   
     99//|     kAxeDirRtoL : Axe X croissant de droite à gauche
     100//|     kAxeDirDownUp : Axe Y croissant de Bas vers Haut
     101//|     kAxeDirUpDown : Axe Y croissant de Haut vers Bas
     102//|     kAxeDirAuto : Sens determine a partir de la valeur relative de xmin, xmax, ymin, ymax
     103//|                   xmin < xmax : kAxeDirLtoR   -  xmax < xmin : kAxeDirRtoL
     104//|                   ymin < ymax : kAxeDirDownUp -  ymax < ymin : kAxeDirUpDown
     105//      Par défaut : "xmin=ymin=0." , "ymin=ymax=0." , "kAxeDirLtoR" , "kAxeDirDownUp"
     106//
     107// void  UC2GrC(float x, float y, float& xpix, float& ypix)
     108//      Transformation de coordonnées utilisateur "(x,y)" en coordoonnées
     109//      de l'espace graphic de départ "(xpix, ypix)"
     110// void  GrC2UC(float xpix, float ypix, float& x, float& y)
     111//      Transformation de coordonnées de l'espace graphic de départ. en coordonnées utilisateur.
     112// void  DUC2GrC(float dx, float dy, float& dxpix, float& dypix)
     113//      Transformation de distances selon X,Y en coordonnées utilisateur "dx, dy" en distance
     114//      dans l'espace graphique de départ "dxpix , dypix".
     115// void  DGrC2UC(float dxpix, float dypix, float& dx, float& dy)
     116//      Transformation de distances selon X,Y dans l'espace graphique de départ en distance
     117//      dans l'espace de  coordonnées utilisateur.
     118//--
    53119
    54120/* --Methode-- */
     
    172238
    173239/* --Methode-- */
    174 void PIGraphicUC::DrawString(PIGrCoord x, PIGrCoord y, char* s, int pos)
     240void PIGraphicUC::DrawString(PIGrCoord x, PIGrCoord y, const char* s, int pos)
    175241{
    176242  if (!mGrC) return;
     
    181247
    182248/* --Methode-- */
    183 void PIGraphicUC::DrawOpaqueString(PIGrCoord x, PIGrCoord y, char* s, int pos)
     249void PIGraphicUC::DrawOpaqueString(PIGrCoord x, PIGrCoord y, const char* s, int pos)
    184250{
    185251  if (!mGrC) return;
     
    338404}
    339405
     406/* --Methode-- */
     407void PIGraphicUC::DrawOval(PIGrCoord x0, PIGrCoord y0, PIGrCoord dx, PIGrCoord dy)
     408{
     409  if (!mGrC) return;
     410
     411  float xf, yf, dxf, dyf;
     412  UC2GrC(x0, y0, xf, yf);
     413  DUC2GrC(dx, dy, dxf, dyf);
     414  mGrC->DrawOval(xf, yf, dxf, dyf);
     415}
     416
     417/* --Methode-- */
     418void PIGraphicUC::DrawFOval(PIGrCoord x0, PIGrCoord y0, PIGrCoord dx, PIGrCoord dy)
     419{
     420  if (!mGrC) return;
     421
     422  float xf, yf, dxf, dyf;
     423  UC2GrC(x0, y0, xf, yf);
     424  DUC2GrC(dx, dy, dxf, dyf);
     425  mGrC->DrawFOval(xf, yf, dxf, dyf);
     426}
     427
    340428#define NMXMULTP  30   // Pour multipoint sans new
    341429
     
    384472}
    385473
     474
     475/* --Methode-- */
     476void PIGraphicUC::DrawArc(PIGrCoord x0, PIGrCoord y0, PIGrCoord dx, PIGrCoord dy,
     477                          float degdeb, float degfin)
     478{
     479  if (!mGrC) return;
     480
     481  float xf, yf, dxf, dyf;
     482  UC2GrC(x0, y0, xf, yf);
     483  DUC2GrC(dx, dy, dxf, dyf);
     484  mGrC->DrawArc(xf, yf, dxf, dyf, degdeb, degfin);
     485}
     486/* --Methode-- */
     487void PIGraphicUC::DrawFArc(PIGrCoord x0, PIGrCoord y0, PIGrCoord dx, PIGrCoord dy,
     488                           float degdeb, float degfin)
     489{
     490  if (!mGrC) return;
     491
     492  float xf, yf, dxf, dyf;
     493  UC2GrC(x0, y0, xf, yf);
     494  DUC2GrC(dx, dy, dxf, dyf);
     495  mGrC->DrawFArc(xf, yf, dxf, dyf, degdeb, degfin);
     496}
    386497
    387498/* --Methode-- */
     
    596707  return(mGrC->GetMarkerSize());
    597708}
     709/* --Methode-- */
     710PIGrCoord PIGraphicUC::GetFontHeightUC(PIGrCoord& asc, PIGrCoord& desc)
     711{
     712  asc = desc = 0;
     713  if (!mGrC) return(0);
     714  int h,a,d;
     715  float fh, fa, fd, x;
     716  h = mGrC->GetFontHeight(a, d) ;
     717  DGrC2UC(0., h, x, fh);
     718  DGrC2UC(0., a, x, fa);
     719  DGrC2UC(0., d, x, fd);
     720  asc = a;  desc = d;
     721  return(fh);
     722}
    598723
    599724/* --Methode-- */
  • trunk/SophyaPI/PI/pigraphuc.h

    r113 r158  
    3737//  Trace graphiques
    3838  virtual void       Erase(PIGrCoord x0, PIGrCoord y0, PIGrCoord dx, PIGrCoord dy);
    39   virtual void       DrawString(PIGrCoord x, PIGrCoord y, char* s, int pos = 0);
    40   virtual void       DrawOpaqueString(PIGrCoord x, PIGrCoord y, char* s, int pos = 0);
     39  virtual void       DrawString(PIGrCoord x, PIGrCoord y, const char* s, int pos = 0);
     40  virtual void       DrawOpaqueString(PIGrCoord x, PIGrCoord y, const char* s, int pos = 0);
    4141  virtual void       DrawLine(PIGrCoord x1, PIGrCoord y1, PIGrCoord x2, PIGrCoord y2);
    4242  virtual void       DrawBox(PIGrCoord x0, PIGrCoord y0, PIGrCoord dx, PIGrCoord dy);
     
    4444  virtual void       DrawCircle(PIGrCoord x0, PIGrCoord y0, PIGrCoord r);
    4545  virtual void       DrawFCircle(PIGrCoord x0, PIGrCoord y0, PIGrCoord r);
     46  virtual void       DrawOval(PIGrCoord x0, PIGrCoord y0, PIGrCoord dx, PIGrCoord dy);
     47  virtual void       DrawFOval(PIGrCoord x0, PIGrCoord y0, PIGrCoord dx, PIGrCoord dy);
    4648  virtual void       DrawPolygon(PIGrCoord *x, PIGrCoord *y, int n, bool cinc=true); 
    47   virtual void       DrawFPolygon(PIGrCoord *x, PIGrCoord *y, int n, bool cinc=true); 
     49  virtual void       DrawFPolygon(PIGrCoord *x, PIGrCoord *y, int n, bool cinc=true);
     50  virtual void       DrawArc(PIGrCoord x0, PIGrCoord y0, PIGrCoord dx, PIGrCoord dy,
     51                             float degdeb, float degfin);
     52  virtual void       DrawFArc(PIGrCoord x0, PIGrCoord y0, PIGrCoord dx, PIGrCoord dy,
     53                              float degdeb, float degfin);
     54 
    4855  virtual void       DrawMarker(PIGrCoord x0, PIGrCoord y0);
    4956  virtual void       DrawMarkers(PIGrCoord *x, PIGrCoord *y, int n);
     
    6673  virtual void       SelFontSz(PIGrCoord sz, PIFontAtt att=PI_RomanFont);
    6774  virtual void       SelMarkerSz(PIGrCoord msz, PIMarker mrk=PI_DotMarker);
     75  virtual PIGrCoord  GetFontHeightUC(PIGrCoord& asc, PIGrCoord& desc);
    6876
    6977// Selection de zone de trace (clip)
     
    8189  virtual int        GetMarkerSize();
    8290
    83   virtual int        GetFontHeight(int& asc, int& desc);
     91  virtual int        GetFontHeight(int& asc, int& desc);
    8492  virtual PIGrCoord  CalcStringWidth(char const* s);
    8593
  • trunk/SophyaPI/PI/pigraphx.cc

    r141 r158  
    1414#define NMAXFONTSZ  7
    1515static XFontStruct * fntst[NMAXFONTSZ][3];
    16 static int fntsz[NMAXFONTSZ] = {8,10,12,14,16,20,24};
     16static int fntsz[NMAXFONTSZ] = {8,10,12,14,18,24,36};
    1717static int SmallFontIndex = 1;
    1818static int NormalFontIndex = 3;
    19 static int BigFontIndex = 6;
     19static int BigFontIndex = 5;
     20static int HugeFontIndex = 6;
    2021static  PIFontAtt fntatt[3] = { PI_RomanFont, PI_BoldFont, PI_ItalicFont };
    2122#define NMAXCOL  16
     
    3132: PIGraphicGen(wdg)
    3233{
     34
    3335Init();
    3436
     37if (MyWdg()) {
     38  mDisp = XtDisplay(MyWdg());       // Structure Display X associe
     39  mWId = XtWindow(MyWdg());   // Le drawable X
     40  }
     41else mDisp = PIXDisplay();       // Structure Display X associe
     42
    3543mDefGC = XCreateGC (PIXDisplay(), XtWindow(PIXtTopWdg()), 0, NULL);
     44
    3645mGOm = PI_GOCopy;
    3746
     
    5362
    5463/* --Methode-- */
     64void PIGraphicX::TerminateInit()
     65{
     66if (MyWdg() == NULL)  { fprintf(stderr, "BUG/PIGraphicX::TerminateInit() for NULL Wdg \n"); return; }
     67mDisp = XtDisplay(MyWdg());       // Structure Display X associe
     68mWId = XtWindow(MyWdg());   // Le drawable X
     69}
     70
     71/* --Methode-- */
    5572void PIGraphicX::Erase(PIGrCoord x0, PIGrCoord y0, PIGrCoord dx, PIGrCoord dy)
    5673{
    57 XClearArea (XtDisplay(MyWdg()),XtWindow(MyWdg()), (int)x0, (int)y0, (int)dx, (int)dy, False );
    58 return;
    59 }
    60 
    61 /* --Methode-- */
    62 void PIGraphicX::DrawString(PIGrCoord x, PIGrCoord y, char* s, int /*pos*/)
    63 {
    64 XDrawString (XtDisplay (MyWdg()),XtWindow(MyWdg()),
     74XClearArea (mDisp,mWId, (int)x0, (int)y0, (int)dx, (int)dy, False );
     75return;
     76}
     77
     78/* --Methode-- */
     79void PIGraphicX::DrawString(PIGrCoord x, PIGrCoord y, const char* s, int /*pos*/)
     80{
     81XDrawString (XtDisplay (MyWdg()),mWId,
    6582                  DefGC(), (int)x, (int)y, s, strlen(s));
    6683return;
     
    6885
    6986/* --Methode-- */
    70 void PIGraphicX::DrawOpaqueString(PIGrCoord x, PIGrCoord y, char* s, int /*pos*/)
    71 {
    72 XDrawImageString (XtDisplay (MyWdg()),XtWindow(MyWdg()),
     87void PIGraphicX::DrawOpaqueString(PIGrCoord x, PIGrCoord y, const char* s, int /*pos*/)
     88{
     89XDrawImageString (XtDisplay (MyWdg()),mWId,
    7390                  DefGC(), (int)x, (int)y, s, strlen(s));
    7491return;
     
    7996void PIGraphicX::DrawLine(PIGrCoord x1, PIGrCoord y1, PIGrCoord x2, PIGrCoord y2)
    8097{
    81 XDrawLine(XtDisplay (MyWdg()), XtWindow(MyWdg()), DefGC(), (int)x1, (int)y1, (int)x2, (int)y2);
     98XDrawLine(XtDisplay (MyWdg()), mWId, DefGC(), (int)x1, (int)y1, (int)x2, (int)y2);
    8299return;
    83100}
     
    93110if (idx < 0)  { ix0 += idx;  idx = -idx; }
    94111if (idy < 0)  { iy0 += idy;  idy = -idy; }
    95 XDrawRectangle(XtDisplay (MyWdg()), XtWindow(MyWdg()),
     112XDrawRectangle(XtDisplay (MyWdg()), mWId,
    96113               DefGC(), ix0, iy0, idx, idy);
    97114return;
     
    107124if (idx < 0)  { ix0 += idx;  idx = -idx; }
    108125if (idy < 0)  { iy0 += idy;  idy = -idy; }
    109 XFillRectangle(XtDisplay (MyWdg()), XtWindow(MyWdg()),
     126XFillRectangle(XtDisplay (MyWdg()), mWId,
    110127               DefGC(), ix0, iy0, idx, idy);
    111128return;
     
    115132void PIGraphicX::DrawCircle(PIGrCoord x0, PIGrCoord y0, PIGrCoord r)
    116133{
    117 XDrawArc(XtDisplay (MyWdg()), XtWindow(MyWdg()), DefGC(),
     134XDrawArc(XtDisplay (MyWdg()), mWId, DefGC(),
    118135         (int)x0-(int)r, (int)y0-(int)r, 2*(int)r, 2*(int)r, 0, 360*64);
    119136return;
     
    123140void PIGraphicX::DrawFCircle(PIGrCoord x0, PIGrCoord y0, PIGrCoord r)
    124141{
    125 XFillArc(XtDisplay (MyWdg()), XtWindow(MyWdg()), DefGC(),
     142XFillArc(XtDisplay (MyWdg()), mWId, DefGC(),
    126143         (int)x0-(int)r, (int)y0-(int)r, 2*(int)r, 2*(int)r, 0, 360*64);
     144return;
     145}
     146
     147/* --Methode-- */
     148void PIGraphicX::DrawOval(PIGrCoord x0, PIGrCoord y0, PIGrCoord dx, PIGrCoord dy)
     149{
     150XDrawArc(XtDisplay (MyWdg()), mWId, DefGC(),
     151         (int)x0, (int)y0, (int)dx, (int)dy, 0, 360*64);
     152return;
     153}
     154
     155/* --Methode-- */
     156void PIGraphicX::DrawFOval(PIGrCoord x0, PIGrCoord y0, PIGrCoord dx, PIGrCoord dy)
     157{
     158XFillArc(XtDisplay (MyWdg()), mWId, DefGC(),
     159         (int)x0, (int)y0, (int)dx, (int)dy, 0, 360*64);
    127160return;
    128161}
     
    144177int mode = CoordModeOrigin;
    145178if (cinc) mode =  CoordModePrevious;
    146 XDrawLines(XtDisplay(MyWdg()), XtWindow(MyWdg()), DefGC(), pxp, n, mode);
     179XDrawLines(mDisp, mWId, DefGC(), pxp, n, mode);
    147180if (n > NMXXPOINTS)  delete[] pxp;
    148181
     
    164197int mode = CoordModeOrigin;
    165198if (cinc) mode =  CoordModePrevious;
    166 XFillPolygon(XtDisplay (MyWdg()), XtWindow(MyWdg()), DefGC(), pxp, n,
     199XFillPolygon(XtDisplay (MyWdg()), mWId, DefGC(), pxp, n,
    167200                        Complex, mode);
    168201if (n > NMXXPOINTS)  delete[] pxp;
    169202
     203return;
     204}
     205
     206/* --Methode-- */
     207void PIGraphicX::DrawArc(PIGrCoord x0, PIGrCoord y0, PIGrCoord dx, PIGrCoord dy,
     208                         float degdeb, float degfin)
     209{
     210XDrawArc(XtDisplay (MyWdg()), mWId, DefGC(),
     211         (int)x0, (int)y0, (int)dx, (int)dy, (int)(degdeb*64.), (int)(degfin*64.));
     212return;
     213}
     214
     215/* --Methode-- */
     216void PIGraphicX::DrawFArc(PIGrCoord x0, PIGrCoord y0, PIGrCoord dx, PIGrCoord dy,
     217                         float degdeb, float degfin)
     218{
     219XFillArc(XtDisplay (MyWdg()), mWId, DefGC(),
     220         (int)x0, (int)y0, (int)dx, (int)dy, (int)(degdeb*64.), (int)(degfin*64.));
    170221return;
    171222}
     
    180231
    181232if (mMrk == PI_DotMarker)
    182   XDrawPoint(XtDisplay(MyWdg()), XtWindow(MyWdg()), DefGC(), (int)x0, (int)y0);
     233  XDrawPoint(mDisp, mWId, DefGC(), (int)x0, (int)y0);
    183234
    184235else  {
     
    217268      break;
    218269    default :
    219       XDrawPoint(XtDisplay(MyWdg()), XtWindow(MyWdg()), DefGC(), x0, y0);
     270      XDrawPoint(mDisp, mWId, DefGC(), x0, y0);
    220271      break;
    221272    }
     
    238289  else pxp = multipoint;
    239290  for(i=0; i<n; i++)  { pxp[i].x = x[i];  pxp[i].y = y[i]; }
    240   XDrawPoints(XtDisplay(MyWdg()), XtWindow(MyWdg()), DefGC(), pxp, n, CoordModeOrigin);
     291  XDrawPoints(mDisp, mWId, DefGC(), pxp, n, CoordModeOrigin);
    241292  if (n > NMXXPOINTS)  delete[] pxp; 
    242293  }
     
    263314
    264315 
    265 xw = XtWindow(MyWdg());
     316xw = mWId;
    266317mdsp = PIXDisplay();
    267318scr = PIXScreen();
     
    294345if (col == mFCol)  return;
    295346if ( (col < 0) || (col >= NMAXCOL))  return;
    296 XSetForeground(XtDisplay(MyWdg()), DefGC(), colpix[col]);
     347XSetForeground(mDisp, DefGC(), colpix[col]);
    297348mFCol = col; 
    298349return;
     
    304355if (col == mBCol)  return;
    305356if ( (col < 0) || (col >= NMAXCOL))  return;
    306 XSetBackground(XtDisplay(MyWdg()), DefGC(), colpix[col]);
     357XSetBackground(mDisp, DefGC(), colpix[col]);
    307358mBCol = col; 
    308359return;
     
    328379  {
    329380  case PI_GOCopy :
    330     XSetFunction(XtDisplay(MyWdg()), DefGC(), GXcopy);
     381    XSetFunction(mDisp, DefGC(), GXcopy);
    331382    mGOm = mod;
    332383    break;
    333384  case PI_GOXOR :
    334     XSetFunction(XtDisplay(MyWdg()), DefGC(), GXxor);
     385    XSetFunction(mDisp, DefGC(), GXxor);
    335386    mGOm = mod;
    336387    break;
     
    377428    i = BigFontIndex;
    378429    break;
     430  case PI_HugeSizeFont:
     431    i = HugeFontIndex;
     432    break;
    379433  default:
    380434    i = NormalFontIndex;
     
    432486    break;
    433487  }
    434    
    435 XSetLineAttributes(XtDisplay(MyWdg()), DefGC(), lt, lstyle, CapButt, JoinMiter);
     488if (lstyle != LineSolid) {
     489  char dash[2]= {3,3};   
     490  XSetDashes( mDisp, DefGC(), 0, dash, 2);
     491  }
     492XSetLineAttributes(mDisp, DefGC(), lt, lstyle, CapButt, JoinMiter);
    436493mLAtt = att;
    437494return;
     
    454511xr.x = x0;  xr.y = y0;
    455512xr.width = dx;  xr.height = dy;
    456 XSetClipRectangles(XtDisplay(MyWdg()), DefGC(), 0, 0, &xr, 1, Unsorted);
    457 XSetClipRectangles(XtDisplay(MyWdg()), dpxgc, 0, 0, &xr, 1, Unsorted);
     513XSetClipRectangles(mDisp, DefGC(), 0, 0, &xr, 1, Unsorted);
     514XSetClipRectangles(mDisp, dpxgc, 0, 0, &xr, 1, Unsorted);
    458515return;
    459516}
     
    462519void PIGraphicX::ClearClipRectangle()
    463520{
    464 XSetClipMask(XtDisplay(MyWdg()), DefGC(), None);
    465 XSetClipMask(XtDisplay(MyWdg()), dpxgc, None);
     521XSetClipMask(mDisp, DefGC(), None);
     522XSetClipMask(mDisp, dpxgc, None);
    466523return;
    467524}
     
    673730  if (kkj < kkdsz)  {  kksel = kkk;  kkdsz = kkj; }
    674731  }
     732if (kksel == NMAXFONTSZ-1)  kksel = NMAXFONTSZ-2;
    675733NormalFontIndex = kksel;
    676734SmallFontIndex = (kksel > 1) ? kksel-2 : 0 ;
    677 BigFontIndex = (kksel < NMAXFONTSZ-3) ? kksel+3 : NMAXFONTSZ-1 ;
     735BigFontIndex =  NMAXFONTSZ-2 ;
     736if (BigFontIndex < NormalFontIndex)  BigFontIndex = NormalFontIndex;
     737HugeFontIndex = NMAXFONTSZ-1;
    678738
    679739//printf("PIGraphicX::Init()-DBG- FontIndex= %d %d %d (%d) \n",
     
    754814mFSize = fntsz[isz];
    755815mFSt = fntst[isz][jat];
    756 XSetFont(XtDisplay(MyWdg()), DefGC(), fntst[isz][jat]->fid);
    757 return;
    758 }
    759 
    760 
     816XSetFont(mDisp, DefGC(), fntst[isz][jat]->fid);
     817return;
     818}
     819
     820
  • trunk/SophyaPI/PI/pigraphx.h

    r113 r158  
     1// This may look like C code, but it is really -*- C++ -*-
    12// Module PI : Peida Interactive     PIGraphicX
    23// Trace graphiques- Implementation X11  R. Ansari  97
     
    1718//  Trace graphiques
    1819  virtual void       Erase(PIGrCoord x0, PIGrCoord y0, PIGrCoord dx, PIGrCoord dy);
    19   virtual void       DrawString(PIGrCoord x, PIGrCoord y, char* s, int pos = 0);
    20   virtual void       DrawOpaqueString(PIGrCoord x, PIGrCoord y, char* s, int pos = 0);
     20  virtual void       DrawString(PIGrCoord x, PIGrCoord y, const char* s, int pos = 0);
     21  virtual void       DrawOpaqueString(PIGrCoord x, PIGrCoord y, const char* s, int pos = 0);
    2122  virtual void       DrawLine(PIGrCoord x1, PIGrCoord y1, PIGrCoord x2, PIGrCoord y2);
    2223  virtual void       DrawBox(PIGrCoord x0, PIGrCoord y0, PIGrCoord dx, PIGrCoord dy);
     
    2425  virtual void       DrawCircle(PIGrCoord x0, PIGrCoord y0, PIGrCoord r);
    2526  virtual void       DrawFCircle(PIGrCoord x0, PIGrCoord y0, PIGrCoord r);
     27  virtual void       DrawOval(PIGrCoord x0, PIGrCoord y0, PIGrCoord dx, PIGrCoord dy);
     28  virtual void       DrawFOval(PIGrCoord x0, PIGrCoord y0, PIGrCoord dx, PIGrCoord dy);
    2629  virtual void       DrawPolygon(PIGrCoord *x, PIGrCoord *y, int n, bool cinc=true); 
    2730  virtual void       DrawFPolygon(PIGrCoord *x, PIGrCoord *y, int n, bool cinc=true); 
     31  virtual void       DrawArc(PIGrCoord x0, PIGrCoord y0, PIGrCoord dx, PIGrCoord dy,
     32                             float degdeb, float degfin);
     33  virtual void       DrawFArc(PIGrCoord x0, PIGrCoord y0, PIGrCoord dx, PIGrCoord dy,
     34                              float degdeb, float degfin);
    2835  virtual void       DrawMarker(PIGrCoord x0, PIGrCoord y0);
    2936  virtual void       DrawMarkers(PIGrCoord *x, PIGrCoord *y, int n);
     
    6673//  Pour recuperer le pixcol d une couleur  (pour X)
    6774  PIXColor           GetPixelValueforColor(PIColors col);
     75//  Pour initialiser mWId apres creation de fenetre
     76  virtual void       TerminateInit();
     77
    6878protected:
    6979  void           Init();
     
    7282  inline SysDWdg MyWdg()  {return(myWdg->XtWdg()); }
    7383  inline void    SelectBCol(PIXColor col)
    74     {XSetBackground(XtDisplay(MyWdg()), DefGC(), col);  mBCol = PI_ColorFromMap; mBCfMap = col; }
     84    {XSetBackground(mDisp, DefGC(), col);  mBCol = PI_ColorFromMap; mBCfMap = col; }
    7585  inline void    SelectFCol(PIXColor col)
    76     {XSetForeground(XtDisplay(MyWdg()), DefGC(), col);  mFCol = PI_ColorFromMap; mFCfMap = col; }
     86    {XSetForeground(mDisp, DefGC(), col);  mFCol = PI_ColorFromMap; mFCfMap = col; }
    7787
     88//  Structure et identificateur XWindow  associe
     89  GC mDefGC;
     90  Display* mDisp;  // Display X associe
     91  Drawable mWId;   // Identificateur Window/Drawable X
    7892
    79   GC mDefGC;
    8093  PIColors  mFCol, mBCol;
    8194  PIGOMode mGOm;
  • trunk/SophyaPI/PI/piscdrawwdg.cc

    r147 r158  
    1717  xEndDrag = yEndDrag = xBegDrag = yBegDrag = 0;
    1818  SetDefaultDrawRectangle(0.12, 0.12, 0.88, 0.88, true);
     19//  SetDefaultDrawRectangle(0.12, 0.08, 0.88, 0.92, true);
    1920  AddDrawer(mBDrw, true, false, false);
    2021 
  • trunk/SophyaPI/PI/piscdrawwdg.h

    r130 r158  
    3131
    3232  inline void        SetAxesFlags(unsigned int flags=kAxesDflt) { mBDrw->SetAxesFlags(flags); }
     33
     34  inline void        SetTitles(const char* tt=NULL, const char* tb=NULL)
     35                            { mBDrw->SetTitles(tt, tb); }
     36  inline void        SetTitles(string const & tt, string const & tb)
     37                            { mBDrw->SetTitles(tt, tb); }
    3338
    3439  int                AddScDrawer(PIDrawer*, bool ad=false);   // Ajoute un Drawer en auto
     
    7681  PIWindow * mTrW;
    7782
    78 
    7983private:
    8084  bool  UpdateText(int xp, int yp);
  • trunk/SophyaPI/PI/pistzwin.cc

    r153 r158  
    11// This may look like C code, but it is really -*- C++ -*-
    2 // Module PI : Peida Interactive  PIStackWindow  PIZoneWindow
     2// Module PI : Peida Interactive  - Zone/Stack Layout
     3// PIStackLayout , PIZone Layout , PIStackWindow , PIZoneWindow
    34//                             R. Ansari  08/98
    45
     
    89#include "psfile.h"
    910
    10 // Fonction de l'objet PIPeriodic de PIStackWindow
    11 static void myadperpact(void* a);
    12 
    13 void myadperpact(void* a)
    14 {
    15 ((PIStackWindow*)a)->DispNext();
    16 }
    17 /* --Methode-- */
    18 PIStackWindow::PIStackWindow(PIMsgHandler* par, char* nom, PIWindowKind k,
    19                              int sx, int sy, int px, int py)
    20         : PIWindow(par, nom, k, sx, sy, px, py) , mPerad(1)
     11// -------------- Classe PIStackLayout --------------
     12
     13/* --Methode-- */
     14PIStackLayout::PIStackLayout()
     15        : PILayoutMgr()
    2116{
    2217mCurdisp = -1;
    23 mPerad.SetAction(myadperpact, this);
    24 }
    25 
    26 
    27 /* --Methode-- */
    28 PIStackWindow::~PIStackWindow()
    29 {
    30 mPerad.Stop();
    31 Hide();
    32 }
    33 
    34 /* --Methode-- */
    35 void PIStackWindow::ChildAdd(PIWdg* child)
     18}
     19
     20/* --Methode-- */
     21PIStackLayout::~PIStackLayout()
     22{
     23}
     24
     25/* --Methode-- */
     26void PIStackLayout::ChildAdd(PIWdg* child)
    3627{
    3728int k;
    3829for(k=0; k<NbChilds(); k++) GetChild(k)->UnManage();
    39 PIWindow::ChildAdd(child);
     30PILayoutMgr::ChildAdd(child);
    4031child->Manage();
    4132mCurdisp = NbChilds()-1;
     
    4435
    4536/* --Methode-- */
    46 void PIStackWindow::ChildDel(PIWdg* child)
     37void PIStackLayout::ChildDel(PIWdg* child)
    4738{
    4839int k;
    4940for(k=0; k<NbChilds(); k++) GetChild(k)->UnManage();
    50 PIWindow::ChildDel(child);
     41PILayoutMgr::ChildDel(child);
    5142if (NbChilds() > 0) {
    5243  mCurdisp--;
     
    6051
    6152/* --Methode-- */
     53void PIStackLayout::DispNext()
     54{
     55if (NbChilds() < 1) return;
     56int n = (mCurdisp+1)%NbChilds();
     57DispWdgNum(n);
     58}
     59
     60/* --Methode-- */
     61void PIStackLayout::DispWdgNum(int n)
     62{
     63if ( (n < 0) || (n >= NbChilds()) )  return;
     64for(int k=0; k<NbChilds(); k++) GetChild(k)->UnManage();
     65mCurdisp = n;
     66GetChild(mCurdisp)->Manage();
     67return;
     68}
     69
     70
     71// -------------- Classe PIStackWindow --------------
     72
     73// Fonction de l'objet PIPeriodic de PIStackWindow
     74static void myadperpact(void* a);
     75
     76void myadperpact(void* a)
     77{
     78((PIStackWindow*)a)->DispNext();
     79}
     80
     81/* --Methode-- */
     82PIStackWindow::PIStackWindow(PIMsgHandler* par, char* nom, PIWindowKind k,
     83                             int sx, int sy, int px, int py)
     84        : PIWindow(par, nom, k, sx, sy, px, py) , mPerad(1)
     85{
     86mPerad.SetAction(myadperpact, this);
     87delete layout;
     88layout = new PIStackLayout;
     89layout->SetContainer(this);
     90}
     91
     92
     93/* --Methode-- */
     94PIStackWindow::~PIStackWindow()
     95{
     96mPerad.Stop();
     97Hide();
     98}
     99
     100/* --Methode-- */
     101void PIStackWindow::SetLayoutMgr(PILayoutMgr*)
     102{
     103fprintf(stderr, "PIStackWindow::SetLayoutMgr() - LayoutMgr cannot be changed \n");
     104return;
     105}
     106
     107/* --Methode-- */
    62108void PIStackWindow::PSPrint(PSFile *psf, int ofx, int ofy)
    63109{
     
    70116}
    71117
    72 /* --Methode-- */
    73 PIWdg* PIStackWindow::CurrentWdg()
    74 {
    75 return(GetChild(mCurdisp));
    76 }
    77 
    78 /* --Methode-- */
    79 void PIStackWindow::DispNext()
    80 {
    81 if (NbChilds() < 1) return;
    82 mCurdisp = (mCurdisp+1)%NbChilds();
    83 PIWdg* wc = GetChild(mCurdisp);
    84 wc->Manage();
    85 int k;
    86 for(k=0; k<NbChilds(); k++)
    87   if (k != mCurdisp) GetChild(k)->UnManage();
    88 return;
    89 }
    90118
    91119/* --Methode-- */
     
    101129}
    102130
    103 //-------------------------------------------------------------------------------
    104 
    105 /* --Methode-- */
    106 PIZoneWindow::PIZoneWindow(PIMsgHandler* par, char* nom, PIWindowKind k,
    107                            int nzx, int nzy, int sx, int sy, int px, int py)
    108         : PIWindow(par, nom, k, sx, sy, px, py)
     131//-------------------- Classe PIZoneLayout ------------------------------
     132
     133/* --Methode-- */
     134PIZoneLayout::PIZoneLayout(int nzx, int nzy)
     135        : PILayoutMgr()
    109136{
    110137mZWdg = NULL;
     
    113140
    114141/* --Methode-- */
    115 PIZoneWindow::~PIZoneWindow()
     142PIZoneLayout::~PIZoneLayout()
    116143{
    117144delete[] mZWdg;
    118145}
    119146
    120 /* --Methode-- */
    121 void PIZoneWindow::SetZone(int nzx, int nzy)
     147
     148/* --Methode-- */
     149void PIZoneLayout::SetZone(int nzx, int nzy)
    122150{
    123151int i;
     
    140168
    141169/* --Methode-- */
    142 void PIZoneWindow::ChildAdd(PIWdg * child)
     170void PIZoneLayout::ChildAdd(PIWdg * child)
    143171{
    144172if (!child) return;
    145173int nx = mZc%mZx;
    146174int ny = mZc/mZx;
    147 PIWindow::ChildAdd(child);
     175PILayoutMgr::ChildAdd(child);
    148176child->SetBinding(PIBK_free,PIBK_free,PIBK_free, PIBK_free);
    149 int sx = XSize()/mZx;
    150 int sy = YSize()/mZy;
     177int sx = mCont->XSize()/mZx;
     178int sy = mCont->YSize()/mZy;
    151179child->SetPos(nx*sx, ny*sy);
    152180child->SetSize(sx, sy);
     
    162190
    163191/* --Methode-- */
    164 void PIZoneWindow::ChildDel(PIWdg * child)
     192void PIZoneLayout::ChildDel(PIWdg * child)
    165193{
    166194if (!child)  return;
     
    168196for(k=0; k<mZx*mZy; k++)
    169197  if (mZWdg[k] == child) mZWdg[k] = NULL; 
    170 PIWindow::ChildDel(child);
    171 return;
    172 }
    173 
    174 /* --Methode-- */
    175 void PIZoneWindow::NbZone(int& nzx, int& nzy)
     198PILayoutMgr::ChildDel(child);
     199return;
     200}
     201
     202/* --Methode-- */
     203void PIZoneLayout::NbZone(int& nzx, int& nzy)
    176204{
    177205nzx = mZx;   nzy = mZy;
     
    179207
    180208/* --Methode-- */
    181 PIWdg* PIZoneWindow::NextChildPosSize(int& px, int& py, int& sx, int& sy)
    182 {
    183 sx = XSize()/mZx;
    184 sy = YSize()/mZy;
     209PIWdg* PIZoneLayout::NextChildPosSize(int& px, int& py, int& sx, int& sy)
     210{
     211sx = mCont->XSize()/mZx;
     212sy = mCont->YSize()/mZy;
    185213int nx = mZc%mZx;
    186214int ny = mZc/mZx;
     
    188216return ((PIWdg*)mZWdg[mZc]);
    189217}
     218
     219
     220//-------------------- Classe PIZoneWindow ------------------------------
     221
     222/* --Methode-- */
     223PIZoneWindow::PIZoneWindow(PIMsgHandler* par, char* nom, PIWindowKind k,
     224                           int nzx, int nzy, int sx, int sy, int px, int py)
     225        : PIWindow(par, nom, k, sx, sy, px, py)
     226{
     227delete layout;
     228layout = new PIZoneLayout(nzx, nzy);
     229layout->SetContainer(this);
     230}
     231
     232/* --Methode-- */
     233PIZoneWindow::~PIZoneWindow()
     234{
     235Hide();
     236}
     237
     238/* --Methode-- */
     239void PIZoneWindow::SetLayoutMgr(PILayoutMgr*)
     240{
     241fprintf(stderr, "PIZoneWindow::SetLayoutMgr() - LayoutMgr cannot be changed \n");
     242return;
     243}
     244
  • trunk/SophyaPI/PI/pistzwin.h

    r140 r158  
    1010#include PIPERIODIC_H
    1111
     12// ----------------------- Classe PIStackLayout ----------------------------
     13// Pour Fenetre de type empilement , tout widget occupe la totalite
     14// de la fenetre - Un seul des widget visible (active) a chaque moment
     15
     16class PIStackLayout : public PILayoutMgr {
     17public:
     18                PIStackLayout();
     19  virtual       ~PIStackLayout();
     20
     21  virtual void  ChildAdd(PIWdg* child);
     22  virtual void  ChildDel(PIWdg* child);
     23
     24  inline PIWdg*  CurrentWdg() { return(GetChild(mCurdisp)); }
     25  inline int    NumCurrentWdg() { return(mCurdisp); }
     26  virtual void  DispNext();
     27  virtual void  DispWdgNum(int n);
     28
     29protected:
     30  int mCurdisp;
     31};
     32               
    1233// ----------------------- Classe PIStackWindow ----------------------------
    13 // Fenetre de type empilement , tout widget occupe la totalite de la fenetre,
    14 // Un seul des widget visible (active) a chaque moment
     34//                    Fenetre avec un PIStackLayout
    1535
    1636class PIStackWindow : public PIWindow {
     
    1838                PIStackWindow(PIMsgHandler* par, char* nom, PIWindowKind k=PIWK_normal,
    1939                              int sx=100, int sy=100, int px=0, int py=0);
    20                 ~PIStackWindow();
     40  virtual       ~PIStackWindow();
    2141
    22   virtual void  ChildAdd(PIWdg* child);
    23   virtual void  ChildDel(PIWdg* child);
    24 
     42  virtual void  SetLayoutMgr(PILayoutMgr* nlay);
    2543  virtual void  PSPrint(PSFile *psf, int ofx=0, int ofy=0);
    2644
    27   virtual PIWdg*  CurrentWdg();
    28   virtual void  DispNext();
     45  inline  void  DispNext() { ((PIStackLayout*)layout)->DispNext(); }
     46  inline  PIWdg* CurrentWdg() { return( ((PIStackLayout*)layout)->CurrentWdg() ); }
     47
    2948  virtual void  StartAutoDisp(int dt);
    3049  virtual void  StopAutoDisp();
     
    3251protected:
    3352  PIPeriodic mPerad;
    34   int mCurdisp;
     53};
     54
     55// ----------------------- Classe PIZoneLayout ----------------------------
     56// Pour fenetre avec nzx*nzy zone d affichage - Les nouveaux widgets dans chaque
     57// zone viennent remplacer les anciennes - Ceux-ci sont detruits automatiquement
     58
     59
     60class PIZoneLayout : public PILayoutMgr {
     61public:
     62                PIZoneLayout(int nzx=1, int nzy=1);
     63  virtual       ~PIZoneLayout();
     64
     65  virtual void  ChildAdd(PIWdg* child);
     66  virtual void  ChildDel(PIWdg* child);
     67  virtual void  SetZone(int nzx, int nzy);
     68  virtual void  NbZone(int& nzx, int& nzy);
     69  virtual PIWdg* NextChildPosSize(int& px, int& py, int& sx, int& sy);
     70
     71protected:
     72  int mZx, mZy, mZc;
     73  PIWdg** mZWdg;
    3574};
    3675
    3776// ----------------------- Classe PIZoneWindow ----------------------------
    38 // Fenetre avec nzx*nzy zone d affichage - Les nouveaux widgets dans chaque
    39 // zone viennent remplacer les anciennes - Ceux-ci sont detruits automatiquement
     77//                    Fenetre avec un PIZoneLayout
    4078 
    4179class PIZoneWindow : public PIWindow {
     
    4381                PIZoneWindow(PIMsgHandler* par, char* nom, PIWindowKind k=PIWK_normal,
    4482                             int nzx=1, int nzy=1, int sx=100, int sy=100, int px=0, int py=0);
    45                 ~PIZoneWindow();
     83  virtual       ~PIZoneWindow();
    4684
    47   virtual void  ChildAdd(PIWdg* child);
    48   virtual void  ChildDel(PIWdg* child);
    49   virtual void  SetZone(int nzx, int nzy);
    50   virtual void  NbZone(int& nzx, int& nzy);
    51   virtual PIWdg*  NextChildPosSize(int& px, int& py, int& sx, int& sy);
     85  virtual void  SetLayoutMgr(PILayoutMgr* nlay);
     86
     87  inline  void  SetZone(int nzx, int nzy) { ((PIZoneLayout*)layout)->SetZone(nzx, nzy); }
     88  inline  void  NbZone(int& nzx, int& nzy)  { ((PIZoneLayout*)layout)->NbZone(nzx, nzy); }
     89  inline PIWdg* NextChildPosSize(int& px, int& py, int& sx, int& sy)
     90                { return ( ((PIZoneLayout*)layout)->NextChildPosSize(px, py, sx, sy) ); }
    5291
    5392protected:
    54   int mZx, mZy, mZc;
    55   PIWdg** mZWdg;
    5693};
     94
    5795#endif
  • trunk/SophyaPI/PI/piwdggen.h

    r140 r158  
    11// This may look like C code, but it is really -*- C++ -*-
    2 // Module PI : Peida Interactive      PIWindowGen
     2// Module PI : Peida Interactive      PIWdgGen
    33//                                    Reza 10/95           
     4// LAL (Orsay) / IN2P3-CNRS  DAPNIA/SPP (Saclay) / CEA
    45
    56#ifndef PIWDG_H_SEEN
  • trunk/SophyaPI/PI/piwdgx.h

    r120 r158  
    9090unsigned long PIXGetLastEventSerial();
    9191void PIXSetLastEventTimeSerial(Time t, unsigned long ser);
     92void PIXGetLastEventInfo(unsigned int& st, Time& t);
    9293
    9394
  • trunk/SophyaPI/PI/pixtbase.cc

    r110 r158  
    9797
    9898
    99 /*  Last XEvent Serial Number and Time-Stamp */
     99/*  Last XEvent Serial Number and Time-Stamp , and Key-state */
    100100static Time last_time_xevt = 0;
    101101static unsigned long last_serial_xevt = 0;
     102static unsigned int  last_state_xevt = 0;
     103
    102104
    103105Time PIXGetLastEventTime() { return(last_time_xevt); }
     
    105107void PIXSetLastEventTimeSerial(Time t, unsigned long ser)
    106108{ last_time_xevt = t;  last_serial_xevt = ser; }
     109void PIXGetLastEventInfo(unsigned int& st, Time& t)
     110{ st = last_state_xevt;  t = last_time_xevt; }
    107111
    108112/* Nouvelle-Fonction */
     
    203207    last_time_xevt = evt->xcrossing.time;
    204208    last_serial_xevt = evt->xcrossing.serial;
     209    last_state_xevt = evt->xcrossing.state;
    205210//    if (((PIXtBaseWidget)wdgp)->pixtbase.objet)
    206211    (((PIXtBaseWidget)wdgp)->pixtbase.objet)->Enter();
     
    214219    last_time_xevt = evt->xcrossing.time;
    215220    last_serial_xevt = evt->xcrossing.serial;
     221    last_state_xevt = evt->xcrossing.state;
    216222//    if (((PIXtBaseWidget)wdgp)->pixtbase.objet)
    217223       (((PIXtBaseWidget)wdgp)->pixtbase.objet)->Leave();
     
    221227    last_time_xevt = evt->xbutton.time;
    222228    last_serial_xevt = evt->xbutton.serial;
     229    last_state_xevt = evt->xbutton.state;
    223230    if ( (evt->xbutton.button == 1) && ( ((PIXtBaseWidget)wdgp)->pixtbase.myeventmask & Button1Mask) )
    224231      (((PIXtBaseWidget)wdgp)->pixtbase.objet)->But1Press(evt->xbutton.x, evt->xbutton.y);
     
    232239    last_time_xevt = evt->xbutton.time;
    233240    last_serial_xevt = evt->xbutton.serial;
     241    last_state_xevt = evt->xbutton.state;
    234242    if ( (evt->xbutton.button == 1) && ( ((PIXtBaseWidget)wdgp)->pixtbase.myeventmask & Button1Mask) )
    235243      (((PIXtBaseWidget)wdgp)->pixtbase.objet)->But1Release(evt->xbutton.x, evt->xbutton.y);
     
    250258      }
    251259    else { key_but =  evt->xmotion.state ; xw = evt->xmotion.x;  yw = evt->xmotion.y; }
    252     if  ( !(key_but & ( Button1Mask | Button2Mask | Button3Mask ) ) ) break;
     260//    if  ( !(key_but & ( Button1Mask | Button2Mask | Button3Mask ) ) ) break;
    253261      last_time_xevt = evt->xmotion.time;
    254262      last_serial_xevt = evt->xmotion.serial;
     263      last_state_xevt = evt->xmotion.state;
    255264      if  (key_but & Button1Mask )
    256265        (((PIXtBaseWidget)wdgp)->pixtbase.objet)->Ptr1Move(xw, yw);
     
    259268      else  if (key_but & Button3Mask )
    260269        (((PIXtBaseWidget)wdgp)->pixtbase.objet)->Ptr3Move(xw, yw);
     270      else if ( !(key_but & (Button4Mask|Button5Mask)) )
     271        (((PIXtBaseWidget)wdgp)->pixtbase.objet)->PtrMove(xw, yw);
    261272    }
    262273  break;
  • trunk/SophyaPI/PI/psfile.cc

    r154 r158  
    1414
    1515#include "psfile.h"
     16
     17//++
     18// Class        PSFile
     19// Lib          PI
     20// include      psfile.h
     21//
     22//      Classe encapsulant un fichier PostScript, fournissant des primitives
     23//      graphiques produisant du code PostScript.
     24//--
     25//++
     26// Links        Voir aussi
     27// PIGraphicPS
     28//--
     29
     30
    1631
    1732/* En cm */
     
    259274"
    260275
     276//++
     277// Titre        Constructeurs
     278//--
     279//++
     280// PSFile (const char * FileName, float sc = 1.0)
     281//      Créateur pour fichier Encapsulated Postscript
     282// PSFile (const char * FileName, PIOrientation orientation, -
     283//         PIPaperSize paperSize= PI_A4, -
     284//         float marginX = 5.0, float marginY = 5.0 )
     285//      Créateur pour fichier Postscript
     286//--
    261287
    262288/*
     
    671697
    672698
    673 void  PSFile::DrawString  (float x,  float y, char *s,
     699void  PSFile::DrawString  (float x,  float y, const char *s,
    674700                           PIColors DrawColor,
    675701                           PIFontAtt FontAtt,
  • trunk/SophyaPI/PI/psfile.h

    r147 r158  
    103103
    104104    /* Trace */
    105     virtual void  DrawString  (float x,  float y, char *s,
     105    virtual void  DrawString  (float x,  float y, const char *s,
    106106                               PIColors DrawColor  = PI_NotDefColor,
    107107                               PIFontAtt FontAtt   = PI_NotDefFontAtt,
Note: See TracChangeset for help on using the changeset viewer.