Changeset 173 in Sophya


Ignore:
Timestamp:
Dec 22, 1998, 5:19:22 PM (27 years ago)
Author:
ercodmgr
Message:

Ajout classe PIGraphicBuffer Reza 22/12/98

Location:
trunk/SophyaPI/PI
Files:
8 edited

Legend:

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

    r158 r173  
    3636//      Constructeur pour les *PIGraphicWin*. Objet "PIGraphic" capable
    3737//      de tracer dans un "PIWdg".
     38// PIGraphic(PIGraphicBuffer* grb)
     39//      Constructeur pour objet "PIGraphic" capable de tracer dans un
     40//      buffer graphique.
    3841//--
    3942//++
     
    4346// int  kind()
    4447//      Renvoie le type de l'objet "PIGraphic" .
     48//      * PI_UnknownGraphics : Objet PIGraphic de type inconnue.
     49//      * PI_GrBufferGraphics : Objet PIGraphic associé à un "GraphicBuffer"
    4550//      * PI_ScrWindowGraphics : Objet PIGraphic associé à une fenêtre sur l'écran (PIWdg)
    4651//      * PI_PSFileGraphics : Objet PIGraphic à un fichier PostScript (pour impression papier)
     
    6065{
    6166myWdg = NULL;
     67myGrb = NULL;
    6268}
    6369
     
    6672{
    6773myWdg = wdg;
     74myGrb = NULL;
     75}
     76
     77/* --Methode-- */
     78PIGraphicGen::PIGraphicGen(PIGraphicBuffer* grb)
     79{
     80myWdg = NULL;
     81myGrb = grb;
    6882}
    6983
     
    7589int PIGraphicGen::kind()
    7690{
    77 return PI_ScrWindowGraphics;
     91return PI_UnknownGraphics ;
    7892}
    7993
  • trunk/SophyaPI/PI/pigraphgen.h

    r158 r173  
     1// This may look like C code, but it is really -*- C++ -*-
    12// Module PI : Peida Interactive     PIGraphic
    23// Primitives de trace graphiques    R. Ansari  97
     
    6061};
    6162
    62 enum PIGraphicsType { PI_ScrWindowGraphics = 0, PI_PSFileGraphics = 1,
    63                       PI_UCGraphics = 2, PI_3DGraphics = 3 };
     63enum PIGraphicsType { PI_UnknownGraphics = 0,
     64                      PI_ScrWindowGraphics = 2, PI_GrBufferGraphics = 3,
     65                      PI_PSFileGraphics = 8,
     66                      PI_UCGraphics = 32, PI_3DGraphics = 36 };
    6467
    6568// Classe generique de trace graphique de base :
     
    7073                     PIGraphicGen();
    7174                     PIGraphicGen(PIWdg* wdg);
     75                     PIGraphicGen(PIGraphicBuffer* grb);
    7276  virtual           ~PIGraphicGen();
    7377
     
    135139// Pour Save/Restore des attributs graphiques
    136140  PIWdg* myWdg;
     141  PIGraphicBuffer* myGrb;
    137142
    138143  PIColors  sFCol, sBCol;
  • trunk/SophyaPI/PI/pigraphx.cc

    r158 r173  
    3333{
    3434
    35 Init();
     35GlInit();
    3636
    3737if (MyWdg()) {
     
    4141else mDisp = PIXDisplay();       // Structure Display X associe
    4242
    43 mDefGC = XCreateGC (PIXDisplay(), XtWindow(PIXtTopWdg()), 0, NULL);
    44 
     43XGCValues  xgv;
     44xgv.function = GXcopy;
     45xgv.plane_mask = ~0;
     46mDefGC = XCreateGC (PIXDisplay(), XtWindow(PIXtTopWdg()), GCFunction | GCPlaneMask, &xgv);
     47
     48Init();
     49}
     50
     51/* --Methode-- */
     52PIGraphicX::PIGraphicX(PIGraphicBuffer* grb)
     53: PIGraphicGen(grb)
     54{
     55GlInit();
     56
     57mDisp = PIXDisplay();       // Structure Display X associe
     58mWId = grb->XGrBuffer();
     59
     60XGCValues  xgv;
     61xgv.function = GXcopy;
     62xgv.plane_mask = ~0;
     63mDefGC = XCreateGC (mDisp, mWId, GCFunction | GCPlaneMask, &xgv);
     64Init();
     65}
     66
     67
     68/* --Methode-- */
     69void PIGraphicX::Init()
     70{
    4571mGOm = PI_GOCopy;
    46 
    4772mFCol = mBCol = PI_Grey;
    4873SelForeground(PI_Black);
     
    5984PIGraphicX::~PIGraphicX()
    6085{
     86XFreeGC(mDisp, mDefGC);
     87}
     88
     89/* --Methode-- */
     90int PIGraphicX::kind()
     91{
     92if (myWdg != NULL) return (PI_ScrWindowGraphics);
     93else if (myGrb != NULL) return (PI_GrBufferGraphics);
     94else return(PI_UnknownGraphics);
    6195}
    6296
     
    647681
    648682/* --Methode-- */
    649 void PIGraphicX::Init()
     683void PIGraphicX::GlInit()
    650684{
    651685char buff[256];
  • trunk/SophyaPI/PI/pigraphx.h

    r158 r173  
    1414public:
    1515                     PIGraphicX(PIWdg* wdg);
     16                     PIGraphicX(PIGraphicBuffer* grb);
    1617  virtual           ~PIGraphicX();
     18
     19  virtual int        kind();
    1720
    1821//  Trace graphiques
     
    7780
    7881protected:
     82  static void    GlInit();
    7983  void           Init();
    8084  void           SelectFont(int isz, int jat);
  • trunk/SophyaPI/PI/piwdggen.cc

    r170 r173  
    227227//++
    228228// Titre        Gestion des Draw/Event Handler
    229 //      Des Draw ou des Event Handler peuvent etre ajoute a un Widget
     229//      Les objets de la classe "PIWdg" peuvent gérer des objets "PIEventHandler"
     230//      qui peuvent prendre en charge une partie du traitement des événements
     231//      clavier-souris-écran.
    230232//--
    231233
    232234//++
    233235// void AddDrawHandler(PIEventHandler* drwh, bool ad=false)
    234 //      Ajout de
     236//      Ajout d'un objet gestionnaire d'événements, responsable du tracé du contenu de la fenêtre.
     237//      La méthode "Draw(PIGraphic* g, ...)" sera appelé pour rafraîchir le contenu de la fenêtre.
    235238// void RemoveDrawHandler(PIEventHandler* drwh)
    236 //      Suppression de
     239//      Suppression d'un objet gestionnaire de tracé.
    237240// void AddEventHandler(PIEventHandler* evh, unsigned long evtmask, bool ad=false)
    238 //      Ajout de
     241//      Ajout d'un objet gestionnaire d'événements. La variable "evtmask" détermine pour
     242//      quels types d'événements, la méthode "Process()" du gestionnaire est appelée.
     243//|     PIEvent_Resize   (Non implementé en version X11 , 12/98)
     244//|     PIEvent_Enter , PIEvent_Leave
     245//|     PIEvent_ButxPress, PIEvent_ButxRelease (x=1,2,3)
     246//|     PIEvent_PtrMove , PIEvent_PtrxMove (x=1,2,3)
     247//|     PIEvent_Keyboard
     248//
    239249// void RemoveEventHandler(PIEventHandler* evh)
    240 //      Suppression de
     250//      Suppression d'un gestionnaire d'événements.
    241251//--
    242252
  • trunk/SophyaPI/PI/piwdggen.h

    r170 r173  
    3535class PIEventHandler;
    3636
     37//  -------------------- Classe PIWdgGen -----------------------
    3738class PIWdgGen : public PIMsgHandler
    3839{
     
    9697  virtual void           PasteSelection(unsigned int typ, void *pdata, unsigned int l)    = 0;
    9798
     99//  Copie depuis un PIWdgGen
     100  virtual void           CopyFrom(PIWdgGen* wdg, int ox, int oy, int dx, int dy, int x, int y) = 0;
     101
    98102//  Gestion des EventHandler
    99103  virtual void           AddDrawHandler(PIEventHandler* drwh, bool ad=false);
     
    114118};
    115119
    116 
     120// ---- La classe PIGraphicBuffer doit se conformer a l'interface suivante
     121// class PIGraphicBuffer {
     122// public :
     123//                      PIGraphicBuffer(int sx, int sy);
     124//  virtual             ~PIGraphicBuffer();
     125//  virtual int         XSize();
     126//  virtual int         YSize();
     127//  virtual  void       CopyFromWdg(PIWdg* wdg, int ox, int oy, int dx, int dy, int x, int y);
     128//  virtual  void       CopyToWdg(PIWdg* wdg, int ox, int oy, int dx, int dy, int x, int y);
     129//  virtual  void       CopyFrom(PIGraphicBuffer* grb, int ox, int oy, int dx, int dy, int x, int y);
     130// };
    117131 
    118132
  • trunk/SophyaPI/PI/piwdgx.cc

    r170 r173  
    2525static SysDWdg  top = NULL;
    2626static Display * dpy = NULL;
     27static GC defgc;
    2728// static char appname[64];
    2829static char appclass[64];
     
    560561top = XtVaAppInitialize(&appctx, appclass, NULL, 0, &n, ppc, (String*)(fallback_res), NULL);
    561562#endif
     563if (top == NULL) {
     564  fprintf(stderr, "PIWdgX::InitXt()/ Error XtVaAppInitialize() -> Exit \n");
     565  exit(9);
     566  }
    562567dpy = XtDisplay(top);
     568if (dpy == NULL)  {
     569  fprintf(stderr, "PIWdgX::InitXt()/ Error XtVaAppInitialize()/DisplayConnection -> Exit \n");
     570  exit(9);
     571  }
     572
     573/*  le GC pour les XCopyArea */
     574XGCValues  xgv;
     575xgv.function = GXcopy;
     576xgv.plane_mask = ~0;
     577defgc = XCreateGC (dpy, DefaultRootWindow(dpy), GCFunction | GCPlaneMask, &xgv);
    563578
    564579// On va recuperer la fonte par defaut des composantes Motif
     
    736751#endif
    737752return;
     753}
     754
     755//  Copie depuis un PIWdgGen
     756void PIWdgX::CopyFrom(PIWdgGen* wdg, int ox, int oy, int dx, int dy, int x, int y)
     757{
     758PIWdgX* wx = (PIWdgX*)wdg;
     759XCopyArea(XtDisplay(XtWdg()), XtWindow(wx->XtWdg()), XtWindow(XtWdg()), defgc, ox, oy,
     760          (unsigned int)dx, (unsigned int)dy, x, y);
    738761}
    739762
     
    974997return;
    975998}
     999
     1000
     1001// -------- La classe PIGraphicBuffer ----------
     1002/* --Methode-- */
     1003PIGraphicBuffer::PIGraphicBuffer(int sx, int sy)
     1004{
     1005if (sx < 1) sx = 1;
     1006if (sy < 1) sy = 1;
     1007mSx = sx;  mSy = sy;
     1008Display * dsx = PIXDisplay();
     1009Window rw = DefaultRootWindow(dsx);
     1010xGrbuff = XCreatePixmap(dsx, rw, sx, sy, DefaultDepth(dsx, DefaultScreen(dsx)) );
     1011}
     1012/* --Methode-- */
     1013PIGraphicBuffer::~PIGraphicBuffer()
     1014{
     1015XFreePixmap(PIXDisplay(),xGrbuff);
     1016}
     1017
     1018/* --Methode-- */
     1019int PIGraphicBuffer::XSize()
     1020{
     1021return(mSx);
     1022}
     1023
     1024/* --Methode-- */
     1025int PIGraphicBuffer::YSize()
     1026{
     1027return(mSx);
     1028}
     1029
     1030/* --Methode-- */
     1031void PIGraphicBuffer::CopyFromWdg(PIWdg* wdg, int ox, int oy, int dx, int dy, int x, int y)
     1032{
     1033XCopyArea(XtDisplay(wdg->XtWdg()), XtWindow(wdg->XtWdg()), XGrBuffer(), defgc, ox, oy,
     1034          (unsigned int)dx, (unsigned int)dy, x, y);
     1035}
     1036
     1037/* --Methode-- */
     1038void PIGraphicBuffer::CopyToWdg(PIWdg* wdg, int ox, int oy, int dx, int dy, int x, int y)
     1039{
     1040XCopyArea(XtDisplay(wdg->XtWdg()), XGrBuffer(), XtWindow(wdg->XtWdg()), defgc, ox, oy,
     1041          (unsigned int)dx, (unsigned int)dy, x, y);
     1042}
     1043
     1044/* --Methode-- */
     1045void PIGraphicBuffer::CopyFrom(PIGraphicBuffer* grb, int ox, int oy, int dx, int dy, int x, int y)
     1046{
     1047
     1048XCopyArea(PIXDisplay(), grb->XGrBuffer(), XGrBuffer(), defgc, ox, oy,
     1049          (unsigned int)dx, (unsigned int)dy, x, y);
     1050}
  • trunk/SophyaPI/PI/piwdgx.h

    r170 r173  
    2525public:
    2626// Les methodes ...
    27   PIWdgX(int narg=0, char *arg[]=NULL);
    28   PIWdgX(PIContainerGen *par, char *nom,
    29          int sx=10, int sy=10, int px=0, int py=0);
     27                  PIWdgX(int narg=0, char *arg[]=NULL);
     28                  PIWdgX(PIContainerGen *par, char *nom,
     29                         int sx=10, int sy=10, int px=0, int py=0);
    3030
    31   virtual ~PIWdgX();
     31  virtual        ~PIWdgX();
    3232
    3333  virtual void   FinishCreate(); // apres avoir installe les sous-vues
     
    6464  virtual void           PasteSelection(unsigned int typ, void *, unsigned int l);
    6565
     66//  Copie depuis un PIWdgGen
     67  virtual void           CopyFrom(PIWdgGen* wdg, int ox, int oy, int dx, int dy, int x, int y);
     68
    6669//  Gestion des EventHandler
    6770  virtual void           AddDrawHandler(PIEventHandler* drwh, bool ad=false);
     
    9497typedef PIWdgX PIWdg;
    9598
     99// -------- La classe PIGraphicBuffer ----------
     100class PIGraphicBuffer {
     101public :
     102                        PIGraphicBuffer(int sx, int sy);
     103  virtual               ~PIGraphicBuffer();
     104
     105  virtual int           XSize();
     106  virtual int           YSize();
     107  virtual  void         CopyFromWdg(PIWdg* wdg, int ox, int oy, int dx, int dy, int x, int y);
     108  virtual  void         CopyToWdg(PIWdg* wdg, int ox, int oy, int dx, int dy, int x, int y);
     109  virtual  void         CopyFrom(PIGraphicBuffer* grb, int ox, int oy, int dx, int dy, int x, int y);
     110
     111//  Acces au Drawable X
     112  inline Pixmap         XGrBuffer() { return(xGrbuff); }
     113protected :
     114  Pixmap xGrbuff;
     115  int mSx, mSy;
     116};
     117
    96118
    97119// Utile pour avoir acces au Display et Screen X ...
Note: See TracChangeset for help on using the changeset viewer.