Changeset 52 in Sophya


Ignore:
Timestamp:
Aug 8, 1997, 8:57:53 PM (28 years ago)
Author:
ansari
Message:

Nouvelles fonctionalites pour le PIBaseWdg (non implemente mac)
Classe PIDrawer, traceur en coordonnes user, pouvant etre attaches a
tout PIBaseWdg. Optimisation trace (Backing-store en X, Trace de
zones a rafraichir pour les ScDrawer, ...)
Nouveau classe de trace de points a partir de NTuples
Reza 08/08/97

Location:
trunk/SophyaPI/PI
Files:
4 added
28 edited

Legend:

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

    r23 r52  
    6464Display *mdsp;
    6565mdsp = XtDisplay (topwdg->XtWdg());
    66 topwdg->Unmanage();
     66topwdg->UnManage();
    6767delete menubar;
    6868if (topcont != MBCont())  delete topcont;
  • trunk/SophyaPI/PI/pibwdggen.cc

    r32 r52  
    22
    33#include "pibwdggen.h"
     4#include "pidrawer.h"
    45#include "psfile.h"
    56
     
    1213{
    1314mPSOut=NULL;
     15mDrwId=0;   // Compteur des numeros sequentiel des PIDrawer
     16mAdfg=false;    // Pour controle d'appel de RemoveDrawer()
    1417}
    1518
     
    1821PIBaseWdgGen::~PIBaseWdgGen()
    1922{
    20 }
    21 
     23DeleteDrawers();
     24}
    2225 
    2326
     27/* --Methode-- */
     28void PIBaseWdgGen::SaveGraphicAtt()
     29{
     30  sFCol = GetForeground();
     31  sBCol = GetBackground();
     32  sGOm = GetGOMode();
     33  sFAtt = GetFontAtt();   
     34  sFSize = GetFontSize();
     35  sLAtt = GetLineAtt();
     36  sMrk = GetMarker();   
     37  sMrkSz = GetMarkerSize();
     38  return;
     39}
     40
     41/* --Methode-- */
     42void PIBaseWdgGen::RestoreGraphicAtt()
     43{
     44  SelForeground(sFCol);
     45  SelBackground(sBCol);
     46  SelGOMode(sGOm);
     47  SelFontSzPt(sFSize, sFAtt);
     48  SelLine(sLAtt);
     49  SelMarker(sMrkSz, sMrk);
     50  return;
     51}
    2452
    2553/* --Methode-- */
     
    131159}
    132160
     161
     162/* --Methode-- */
     163int PIBaseWdgGen::AddDrawer(PIDrawer* drw, int x0, int y0, int dx, int dy, bool ad)
     164{
     165if (drw == NULL)   return(0);
     166mDrwId++;
     167BWDrwId did;
     168did.x0 = x0;  did.y0 = y0;
     169did.dx = dx;  did.dy = dy;
     170did.id = mDrwId;  did.ad = ad;
     171did.drw = drw;
     172mDrwList.push_back(did);
     173drw->Attach((PIBaseWdg*)this, mDrwId);
     174return(mDrwId);
     175}
     176
     177/* --Methode-- */
     178void PIBaseWdgGen::RemoveDrawer(int id)
     179{
     180if (mAdfg)  return;
     181list<BWDrwId>::iterator it;
     182for(it = mDrwList.begin(); it != mDrwList.end(); it++)
     183  if ((*it).id == id)
     184    { (*it).drw->Detach((PIBaseWdg*)this, id); mDrwList.erase(it); break; }
     185return;
     186}
     187
     188/* --Methode-- */
     189void PIBaseWdgGen::DeleteDrawers()
     190{
     191mAdfg = true;
     192list<BWDrwId>::iterator it;
     193for(it = mDrwList.begin(); it != mDrwList.end(); it++) 
     194  if ((*it).ad)  delete (*it).drw;
     195mDrwList.erase(mDrwList.begin(), mDrwList.end() );
     196mAdfg = false;
     197return;
     198}
     199
     200
     201/* --Methode-- */
     202void PIBaseWdgGen::CallDrawers(int x0, int y0, int dx, int dy)
     203{
     204double xmin,ymin, xmax, ymax;
     205
     206bool sxy = false;
     207if ((dx > 0) && (dy > 0))  sxy = true;
     208
     209list<BWDrwId>::iterator it;
     210bool fgc=false;
     211for(it = mDrwList.begin(); it != mDrwList.end(); it++) {
     212  SaveGraphicAtt();
     213  (*it).drw->SetDrwWdg(this, (*it).x0, (*it).y0, (*it).dx, (*it).dy);
     214  SetClipRectangle((*it).x0, (*it).y0, (*it).dx , (*it).dy);
     215  fgc = true;
     216  if (sxy) {
     217    (*it).drw->Local2Sc(x0, y0, xmin, ymin);
     218    (*it).drw->Local2Sc(x0+dx, y0+dy, xmax, ymax);
     219    if (xmin > xmax)  swap(xmin,xmax);
     220    if (ymin > ymax)  swap(ymin,ymax);
     221    (*it).drw->Draw(xmin, ymin, xmax, ymax);
     222  }
     223  else (*it).drw->Draw();
     224  RestoreGraphicAtt();
     225  }
     226if (fgc)  ClearClipRectangle();
     227
     228}
  • trunk/SophyaPI/PI/pibwdggen.h

    r44 r52  
    22#define PIBWDGGEN_H_SEEN
    33
     4
    45#include "pisysdep.h"
    56#include PIWDG_H
     7#include PICMAP_H
    68
    7 #include "pibwdggen.h"
     9// Mettre dans cet ordre, sinon g++ a des problemes   
     10#include <list>   
    811
    912
    1013enum PIKeyModifier { PIKM_Blank = 0, PIKM_Shift = 1, PIKM_Alt = 2, PIKM_Cntl = 4 } ;
    1114
    12 enum PIColors  { PI_NotDefColor = -1,
     15enum PIColors  { PI_NotDefColor = -1, 
    1316                 PI_Black = 0, PI_White = 1,  PI_Grey = 2,
    1417                 PI_Red = 3, PI_Blue = 4, PI_Green = 5, 
    15                  PI_Yellow = 6, PI_Magenta =7 };
     18                 PI_Yellow = 6, PI_Magenta = 7 };
    1619
    1720enum PIFontSize { PI_NotDefFontSize = -1,
     
    6164
    6265//  Trace graphiques
    63   virtual void       EraseWindow()             = 0;
    64   virtual void       DrawString(int x, int y, char* s, int pos = 0)  = 0;
     66  virtual void       EraseWindow(int x0=0, int y0=0, int dx=0, int dy=0)   = 0;
     67  virtual void       DrawString(int x, int y, char* s, int pos = 0)        = 0;
    6568  virtual void       DrawLine(int x1, int y1, int x2, int y2)              = 0;
    6669  virtual void       DrawBox(int x0, int y0, int dx, int dy)               = 0;
     
    7275  virtual void       DrawMarker(int x0, int y0)                            = 0;
    7376  virtual void       DrawMarkers(int *x, int *y, int n)                    = 0;
    74 
    75 
     77  virtual void       DrawPixmap(int x, int y, unsigned char *pix,
     78                                int sx, int sy, PIColorMap* cmap)          = 0;
    7679
    7780  virtual int        CalcStringWidth(char const* s)                        = 0;
     
    8891  virtual void       SelMarker(int msz=3, PIMarker mrk=PI_DotMarker)       = 0;
    8992
     93// Selection de zone de trace (clip)
     94  virtual void       SetClipRectangle(int x0, int y0, int dx, int dy)      = 0;
     95  virtual void       ClearClipRectangle() = 0;
     96
    9097// Acces aux attributs graphiques
    9198  virtual PIColors   GetForeground()    = 0;
     
    98105  virtual PIMarker   GetMarker()        = 0;
    99106  virtual int        GetMarkerSize()    = 0;
     107  virtual int        GetFontHeight(int& asc, int& desc) = 0;
     108
     109// Sauvegarde des attributs graphiques
     110  virtual void       SaveGraphicAtt();
     111  virtual void       RestoreGraphicAtt();
    100112
    101113
     
    122134
    123135// PostScript output
    124   virtual void       PSPrint(PSFile * psf, int ofx = 0, int ofy = 0); 
     136  virtual void       PSPrint(PSFile * psf, int ofx = 0, int ofy = 0);
    125137
     138// Gestion des Drawers
     139  friend class PIDrawer;
     140          int        AddDrawer(PIDrawer* drw, int x0, int y0, int dx, int dy,
     141                               bool ad=false);
     142          void       RemoveDrawer(int id);       // Ote un drawer de la liste
     143          void       DeleteDrawers();            // Ote et detruit tous les drawers
     144
     145// Devrait etre protected - mis ici a cause de cxx  11/07/97  Reza
     146  struct BWDrwId { int x0, y0; int dx, dy; int id; bool ad; PIDrawer* drw; };
     147         
    126148protected:
     149  virtual void       CallDrawers(int x0, int y0, int dx, int dy); // Appel le trace des drawers
     150
    127151  PSFile * mPSOut;  /* Fichier PostScript eventuel */
     152
     153  bool mAdfg;
     154  int mDrwId;
     155  list<BWDrwId> mDrwList;
     156// Pour Save/Restore des attributs graphiques
     157  PIColors  sFCol, sBCol;
     158  PIGOMode sGOm;
     159  PIFontAtt sFAtt;
     160  PILineAtt sLAtt;
     161  int sFSize;
     162  PIMarker sMrk;
     163  int sMrkSz;
     164
    128165};
    129166
  • trunk/SophyaPI/PI/pibwdgmac.cc

    r15 r52  
    4949
    5050/* --Methode-- */
    51 void PIBaseWdgMac::EraseWindow()
     51void PIBaseWdgMac::EraseWindow(int x0, int y0, int dx, int dy)
    5252{
    5353  if (mPane->FocusDraw()) {
  • trunk/SophyaPI/PI/pibwdgmac.h

    r15 r52  
    2525
    2626//  Trace graphiques
    27   virtual void       EraseWindow();
     27  virtual void       EraseWindow(int x0=0, int y0=0, int dx=0, int dy=0);
    2828  virtual void       DrawString(int x, int y, char* s, int pos = 0);
    2929  virtual void       DrawLine(int x1, int y1, int x2, int y2);
  • trunk/SophyaPI/PI/pibwdgx.cc

    r44 r52  
    88#include <X11/CoreP.h>
    99
    10 #include "pibwdgx.h"
    11 
    1210#include "pixtbaseP.h"
    1311#include "pixtbase.h"
    1412
     13#include "pibwdgx.h"
     14#include "pidrawer.h"
    1515#include "psfile.h"
    1616
     
    2626static Cursor curs[NMAXCURS];
    2727
     28/*  GC pour DrawPixmap   */
     29static GC dpxgc;
    2830
    2931// #define DEBUG_PIBWDGX     Flag pour impression de debug etc ...
     
    6062SelPointerShape();
    6163SelMarker(1, PI_DotMarker);
     64
    6265Manage();
    6366}
     
    6770PIBaseWdgX::~PIBaseWdgX()
    6871{
    69 }
    70 
    71  
     72
     73}
     74
     75/* --Methode-- */
     76void PIBaseWdgX::FinishCreate()
     77{
     78// appele par la fenetre mere, apres XtRealize()
     79// J'active le backing store pour la fenetre X
     80XSetWindowAttributes xswa;
     81Window mwi;
     82mwi = XtWindow(XtWdg());
     83xswa.backing_store = WhenMapped;
     84xswa.backing_planes = ~0;
     85XChangeWindowAttributes(PIXDisplay(), XtWindow(XtWdg()), CWBackingPlanes|CWBackingStore, &xswa);
     86}
    7287
    7388/* --Methode-- */
     
    131146}
    132147
    133 /* --Methode-- */
    134 void PIBaseWdgX::EraseWindow()
     148
     149/* --Methode-- */
     150void PIBaseWdgX::EraseWindow(int x0, int y0, int dx, int dy)
    135151{
    136152if(mPSOut) return;
    137 XClearWindow   (XtDisplay(XtWdg()),XtWindow(XtWdg()) );
    138 return;
    139 }
    140 
    141 /* --Methode-- */
    142 void PIBaseWdgX::DrawString(int x, int y, char* s, int pos)
     153XClearArea (XtDisplay(XtWdg()),XtWindow(XtWdg()), x0, y0, dx, dy, False );
     154return;
     155}
     156
     157/* --Methode-- */
     158void PIBaseWdgX::DrawString(int x, int y, char* s, int /*pos*/)
    143159{
    144160if(mPSOut){
    145 mPSOut->DrawString((float)x,(float)y,s,mFCol,mFAtt,mFSize); /* PIFontSize ?? */
     161mPSOut->DrawString((float)x,(float)y,s,mFCol,mFAtt,mFSize); /* $CHECK$ PIFontSize ?? */
    146162}
    147163else
     
    183199{
    184200if(mPSOut)
    185 mPSOut->DrawFBox((float)x0,(float)y0,(float)dx,(float)dy);
     201mPSOut->DrawFBox((float)x0,(float)y0,(float)dx,(float)dy, mFCol, mFCol, mLAtt);
    186202else{
    187203if (dx < 0)  { x0 += dx;  dx = -dx; }
     
    229245if(mPSOut)
    230246{
    231 xtmp = (float*)malloc(n*sizeof(float));
    232 ytmp = (float*)malloc(n*sizeof(float));
     247xtmp = new float[n];
     248ytmp = new float[n];
    233249for(i=0;i<n;i++){
    234250  xtmp[i] = (float)x[i];
     
    236252}
    237253mPSOut->DrawPolygon(xtmp,ytmp,n,mFCol,mLAtt);
    238 free(xtmp);
    239 free(ytmp);
     254delete[] xtmp;
     255delete[] ytmp;
    240256}
    241257else {
     
    262278if(mPSOut)
    263279{
    264 xtmp = (float*)malloc(n*sizeof(float));
    265 ytmp = (float*)malloc(n*sizeof(float));
     280xtmp = new float[n];
     281ytmp = new float[n];
    266282for(i=0;i<n;i++){
    267283  xtmp[i] = (float)x[i];
     
    269285}
    270286mPSOut->DrawFPolygon(xtmp,ytmp,n,mFCol,mFCol,mLAtt);
    271 free(xtmp);
    272 free(ytmp);
     287delete[] xtmp;
     288delete[] ytmp;
    273289}
    274290else
     
    354370if(mPSOut)
    355371{
    356 xtmp = (float*)malloc(n*sizeof(float));
    357 ytmp = (float*)malloc(n*sizeof(float));
     372xtmp = new float[n];
     373ytmp = new float[n];
    358374for(i=0;i<n;i++){
    359375  xtmp[i] = (float)x[i];
     
    361377}
    362378mPSOut->DrawMarkers(xtmp,ytmp,n,mMrk,mFCol, mMrkSz);
    363 free(xtmp);
    364 free(ytmp);
     379delete[] xtmp;
     380delete[] ytmp;
    365381}
    366382else
     
    380396}
    381397}
     398
     399
     400/* --Methode-- */
     401void PIBaseWdgX::DrawPixmap(int x, int y, unsigned char *pix,
     402                            int sx, int sy, PIColorMap* cmap)
     403{
     404Window xw;
     405Display * mdsp;
     406int scr;
     407int depth;
     408int pad;
     409int i,j;
     410XImage * ximg;
     411
     412if ( (sx < 1) || (sy < 1) )  return;
     413if ((pix == NULL) || (cmap == NULL)) return;
     414
     415if(mPSOut) {
     416  mPSOut->Image((float)x, (float)y, (float)sx, (float)sy, sx, sy, pix, cmap);
     417  return;
     418  }
     419 
     420xw = XtWindow(XtWdg());
     421mdsp = PIXDisplay();
     422scr = PIXScreen();
     423
     424depth = DefaultDepth(mdsp,scr);
     425pad = (depth > 8) ? 32 : 8;
     426ximg = XCreateImage (mdsp,DefaultVisual(mdsp,scr),
     427                     depth,ZPixmap,0,NULL, sx, sy, pad,0);
     428if (ximg == NULL)  return;
     429ximg->data = new char [sy*ximg->bytes_per_line];
     430if (ximg->data == NULL) 
     431  { XFree(ximg); return; }
     432
     433for(j=0; j<sy; j++)
     434  for(i=0; i<sx; i++)
     435    { XPutPixel(ximg, i, j, cmap->Color(*pix) );  pix++; }
     436
     437XPutImage(mdsp, xw, dpxgc, ximg, 0, 0, x, y, sx, sy);
     438
     439delete[] ximg->data;
     440XFree(ximg);
     441return;
     442}
     443
    382444
    383445/* --Methode-- */
     
    527589}
    528590
     591
     592/* --Methode-- */
     593void PIBaseWdgX::SetClipRectangle(int x0, int y0, int dx, int dy)
     594{
     595XRectangle xr;
     596xr.x = x0;  xr.y = y0;
     597xr.width = dx;  xr.height = dy;
     598XSetClipRectangles(XtDisplay(XtWdg()), DefGC(), 0, 0, &xr, 1, Unsorted);
     599XSetClipRectangles(XtDisplay(XtWdg()), dpxgc, 0, 0, &xr, 1, Unsorted);
     600return;
     601}
     602
     603/* --Methode-- */
     604void PIBaseWdgX::ClearClipRectangle()
     605{
     606XSetClipMask(XtDisplay(XtWdg()), DefGC(), None);
     607XSetClipMask(XtDisplay(XtWdg()), dpxgc, None);
     608return;
     609}
     610
    529611/* --Methode-- */
    530612PIColors  PIBaseWdgX::GetForeground()
     
    582664}
    583665
    584 
     666/* --Methode-- */
     667int        PIBaseWdgX::GetFontHeight(int& asc, int& desc)   
     668{
     669char a[2];
     670XCharStruct  ovr;
     671int hd, fa, fd;
     672XTextExtents(mFSt, a, 0, &hd, &fa, &fd, &ovr);
     673asc = fa; desc = fd;
     674return(fa+fd);
     675}
     676
     677
     678/* --Methode-- */
     679void PIBaseWdgX::SaveGraphicAtt()
     680
     681// Pour optimier l'implementation de PIBaseWdgGen
     682sFCol = mFCol;    sBCol = mBCol;
     683sGOm = mGOm;
     684sFAtt = mFAtt;   sFSize = mFSize;
     685sMrk = mMrk;   sMrkSz = mMrkSz;
     686return;
     687}
    585688
    586689/* --Methode-- */
     
    620723this->DrawFBox(10,10, XSize()*2/3, YSize()*2/3);
    621724#endif
     725CallDrawers(0,0,0,0);
    622726return;
    623727}
     
    644748
    645749/* --Methode-- */
    646 void PIBaseWdgX::But1Press(int x, int y)
     750void PIBaseWdgX::But1Press(int, int)
    647751{
    648752#ifdef DEBUG_PIBWDGX
     
    653757
    654758/* --Methode-- */
    655 void PIBaseWdgX::But1Release(int x, int y)
     759void PIBaseWdgX::But1Release(int, int)
    656760{
    657761Send(Msg(), PIMsg_Active);
     
    688792
    689793/* --Methode-- */
    690 void PIBaseWdgX::Ptr1Move(int  x, int  y )
     794void PIBaseWdgX::Ptr1Move(int , int )
    691795{
    692796#ifdef DEBUG_PIBWDGX
     
    710814
    711815/* --Methode-- */
    712 void PIBaseWdgX::Keyboard(int key, PIKeyModifier kmod)
     816void PIBaseWdgX::Keyboard(int /*key*/, PIKeyModifier /*kmod*/)
    713817{
    714818
     
    844948curs[PI_TDLRArrowPointer] =  XCreateFontCursor(mdsp, XC_fleur);
    845949
     950/*  le GC pour DrawPixmap  */
     951XGCValues  xgv;
     952xgv.function = GXcopy;
     953xgv.plane_mask = ~0;
     954dpxgc = XCreateGC(mdsp, DefaultRootWindow(mdsp), GCFunction | GCPlaneMask, &xgv);
     955
    846956return;
    847957}
     
    879989return;
    880990}
     991
     992
  • trunk/SophyaPI/PI/pibwdgx.h

    r11 r52  
    1616  virtual         ~PIBaseWdgX();
    1717
     18  virtual void    FinishCreate(); // appele par la fenetre mere, apres XtRealize()
    1819
    1920//  Activation des evenements   
     
    2425
    2526//  Trace graphiques
    26   virtual void   EraseWindow();
     27  virtual void   EraseWindow(int x0=0, int y0=0, int dx=0, int dy=0);
    2728  virtual void   DrawString(int x, int y, char* s, int pos = 0);
    2829  virtual void   DrawLine(int x1, int y1, int x2, int y2);
     
    3536  virtual void   DrawMarker(int x0, int y0);
    3637  virtual void   DrawMarkers(int *x, int *y, int n);
     38  virtual void   DrawPixmap(int x, int y, unsigned char *pix,
     39                            int sx, int sy, PIColorMap* cmap);
    3740
    3841  virtual int    CalcStringWidth(char const* s);
     
    4952  virtual void   SelMarker(int msz, PIMarker mrk=PI_DotMarker);
    5053 
     54// Selection de zone de trace (clip)
     55  virtual void       SetClipRectangle(int x0, int y0, int dx, int dy);
     56  virtual void       ClearClipRectangle();
    5157
    5258// Acces aux attributs graphiques
     
    6066  virtual PIMarker   GetMarker();
    6167  virtual int        GetMarkerSize();
     68  virtual int        GetFontHeight(int& asc, int& desc);
     69
     70// Sauvegarde des attributs graphiques
     71  virtual void       SaveGraphicAtt();
    6272
    6373//  Fonction qui doit etre appelee pour rafraichir (retracer) tout
     
    8595
    8696protected:
     97
    8798  void           Init();
    8899  void           SelectFont(int isz, int jat);
  • trunk/SophyaPI/PI/picontainergen.cc

    r32 r52  
    1010{
    1111mNCh = 0;
    12 mACSup = mPaSup = false;
     12mACSup = false;   // Pas de suppression auto des widgets fils au delete
     13mPaSup = false;
    1314mChilds = new (PIWdgGen * [NCHALGRP]);
    1415mMxCh = NCHALGRP;
     
    3940{
    4041stvis = 1;
     42Manage();
    4143return;
    4244}
     
    4648{
    4749stvis = 0;
     50UnManage();
    4851return;
    4952}
  • trunk/SophyaPI/PI/picontainerx.cc

    r2 r52  
    2626{}
    2727
    28 /* --Methode-- */
     28/* --Methode--
    2929void PIContainerX::Show()
    3030{
     
    3333}
    3434
    35 /* --Methode-- */
    3635void PIContainerX::Hide()
    3736{
    3837PIContainerGen::Hide();
    39 Unmanage();
     38UnManage();
    4039}
    4140
     41*/
  • trunk/SophyaPI/PI/picontainerx.h

    r2 r52  
    1818  virtual     ~PIContainerX();
    1919
    20   virtual void           Show();
    21   virtual void           Hide();
    22 
    2320};
    2421
  • trunk/SophyaPI/PI/pidrawwin.cc

    r23 r52  
    1616
    1717void
    18 PIDrawWindow::AddDrawer(PIScDrawer* d)
     18PIDrawWindow::AddScDrawer(PIScDrawer* d, bool ad)
    1919{
    20   mDrawWdg->AddDrawer(d);
     20  mDrawWdg->AddScDrawer(d, ad);
    2121}
    2222
  • trunk/SophyaPI/PI/pidrawwin.h

    r18 r52  
    1515                ~PIDrawWindow();
    1616               
    17  virtual void    AddDrawer(PIScDrawer*);               
     17 virtual void    AddScDrawer(PIScDrawer*, bool ad=false);               
    1818 virtual void    SetAxesFlags(int flags=-1);
    1919 inline PIScDrawWdg * DrawWdg() { return mDrawWdg; }
  • trunk/SophyaPI/PI/pifilechox.cc

    r41 r52  
    2525pif = (PIFileChooserX *) usd ;
    2626pif->mSt = 1;
    27 pif->MWin()->Unmanage();
     27pif->MWin()->UnManage();
    2828//pif->Send(pif->Msg(), (void *) (pif->GetFileName().c_str()));
    2929CStrFrXmStr(calld->value, pif->mFName, 512);
     
    3939pif->mSt = 0;
    4040pif->mFName[0] = '\0';
    41 pif->MWin()->Unmanage();
     41pif->MWin()->UnManage();
    4242pif->Send(pif->Msg(), PIMsg_Cancel, NULL);
    4343return;
  • trunk/SophyaPI/PI/pihisto.cc

    r37 r52  
    22#include "pihisto.h"
    33
    4 PIHisto::PIHisto(Histo* histo)
     4PIHisto::PIHisto(Histo* histo, bool ad)
    55: PIScDrawer(), mHisto(histo)
    66{
    7   ahisup = false;     // Flag pour suppression automatique de mHisto
     7  mAdDO = ad;     // Flag pour suppression automatique de mHisto
    88}
    99
    1010PIHisto::~PIHisto()
    1111{
    12   if (ahisup)
     12  if (mAdDO)
    1313    delete mHisto;
    1414}
    1515
    16 
    17 void
    18 PIHisto::AttachTo(PIScDrawWdg* wdg)
    19 {
    20   PIScDrawer::AttachTo(wdg);
    21   UpdateSize();
    22 }
    2316
    2417
     
    2619PIHisto::UpdateSize()
    2720{
    28   if (!mDrawWdg) return;
    29   if (mDrawWdg->LimitsFixed()) return;
     21  if (!mDrawer) return;
     22  if (mDrawer->LimitsFixed()) return;
    3023  // Commencer par trouver nos limites
    3124 
     
    3629  double ymin = mHisto->VMin();
    3730 
    38   mDrawWdg->SetLimits(xmin, xmax, ymin, ymax);
    39   mDrawWdg->SetAxesFlags(kBoxAxes | kExtTicks | kLabels);
     31  if (mDrawWdg)
     32    mDrawWdg->SetLimits(xmin, xmax, ymin, ymax);
     33  else
     34    mDrawer->SetLimits(xmin, xmax, ymin, ymax);
     35
     36  mDrawer->SetAxesFlags(kBoxAxes | kExtTicks | kLabels);
    4037}
    4138
    4239
    4340void
    44 PIHisto::Draw()
     41PIHisto::Draw(double /*xmin*/, double /*ymin*/, double /*xmax*/, double /*ymax*/)
    4542{
    46   if (!mDrawWdg) return;
     43  if (!mDrawer) return;
    4744  for (int i=0; i<mHisto->NBins(); i++) {
    4845                double left   = mHisto->BinLowEdge(i);
     
    5047                double bottom = 0;
    5148                double height = (*mHisto)(i);
    52                 mDrawWdg->ScDrawFBox(left,bottom,width,height);
    53                 mDrawWdg->ScDrawLine(left, bottom, left, bottom + height); // Au moins une ligne...
     49                mDrawer->DrawFBox(left,bottom,width,height);
     50                mDrawer->DrawLine(left, bottom, left, bottom + height); // Au moins une ligne...
    5451        }
    5552  DrawStats();
     
    6057{
    6158  // Une boite dans le coin superieur droit
    62   if (!mDrawWdg) return;
     59  if (!mDrawer) return;
    6360  double cellHeight = (mDrawWdg->YMax() - mDrawWdg->YMin()) * 0.05;
    6461  double cellWidth  = (mDrawWdg->XMax() - mDrawWdg->XMin()) * 0.23;
    65   mDrawWdg->ScDrawLine(mDrawWdg->XMax() - cellWidth, mDrawWdg->YMax(),
     62  mDrawer->DrawLine(mDrawWdg->XMax() - cellWidth, mDrawWdg->YMax(),
    6663                       mDrawWdg->XMax() - cellWidth, mDrawWdg->YMax() - cellHeight);
    67   mDrawWdg->ScDrawLine(mDrawWdg->XMax() - cellWidth, mDrawWdg->YMax() - cellHeight,
     64  mDrawer->DrawLine(mDrawWdg->XMax() - cellWidth, mDrawWdg->YMax() - cellHeight,
    6865                       mDrawWdg->XMax()            , mDrawWdg->YMax() - cellHeight);
    6966  char label[50];
    7067  sprintf(label, "N = %.6g", mHisto->NData());
    71   mDrawWdg->ScSelFontSz((mDrawWdg->YMax() - mDrawWdg->YMin())/30);
    72   mDrawWdg->ScDrawString(mDrawWdg->XMax() - cellWidth*0.9, mDrawWdg->YMax() - cellHeight*0.8, label);
     68  mDrawer->SelFontSz((mDrawWdg->YMax() - mDrawWdg->YMin())/30);
     69  mDrawer->DrawString(mDrawWdg->XMax() - cellWidth*0.9, mDrawWdg->YMax() - cellHeight*0.8, label);
    7370                       
    7471}
    75 
    76 void
    77 PIHisto::Refresh()
    78 {
    79   if (!mDrawWdg) return;
    80   mDrawWdg->FreeLimits();
    81   UpdateSize();
    82   mDrawWdg->Refresh();
    83 }
  • trunk/SophyaPI/PI/pihisto.h

    r37 r52  
    22#define PIHISTO_H
    33
    4 
     4#include "histos.h"
    55#include "piscdrawwdg.h"
    6 #include "histos.h"
    76
    87class PIHisto : public PIScDrawer {
    98public:
    10                      PIHisto(Histo* histo);
     9                     PIHisto(Histo* histo, bool ad=false);
    1110  virtual           ~PIHisto();
    12   virtual void       Draw();
     11  virtual void       Draw(double xmin, double ymin, double xmax, double ymax);
     12  virtual void       UpdateSize();
    1313  virtual void       DrawStats();
    14   virtual void       Refresh();  // Recalcule les limites, et reaffiche
    15   inline  void       SetAutoDelHisto(bool ad=false) {  ahisup = ad; }
    1614  inline  Histo*     Histogram() { return(mHisto); }
    1715
    1816protected:
    1917  Histo* mHisto;
    20   bool   ahisup;
    21 
    22   virtual void       AttachTo(PIScDrawWdg*);
    23   virtual void       UpdateSize();
    2418};
    2519
  • trunk/SophyaPI/PI/pimenux.cc

    r41 r52  
    1818
    1919/* Nouvelle-Fonction */
    20 void  menub_action(Widget w, XtPointer *usd, XtPointer *calld)
     20void  menub_action(Widget /*w*/, XtPointer *usd, XtPointer* /*calld*/)
    2121{
    2222PIMenuX *pim;
     
    131131
    132132/* --Methode-- */
    133 void PIMenuX::CheckItemNum(int n, bool st)
     133void PIMenuX::CheckItemNum(int n, bool /*st*/)
    134134{
    135135printf("PIMenuX::CheckItemNum(%d,bool) Error/ Not yet implemented \n", n);
     
    144144
    145145/* --Methode-- */
    146 void PIMenuX::Show(PIWdg *w, int px, int py)
     146void PIMenuX::Show(PIWdg* /*w*/, int /*px*/, int /*py*/)
    147147{
    148148Manage();
     
    153153void PIMenuX::Hide()
    154154{
    155 // Unmanage();
     155// UnManage();
    156156}
    157157
  • trunk/SophyaPI/PI/pimsghandler.h

    r37 r52  
    1313        PIMsg_Resize        = 3,
    1414
    15         PIMsg_OK            = 11,
    16         PIMsg_Cancel        = 12,
    17         PIMsg_Help          = 13,
    18 
    19         PIMsg_DataChanged   = 21,
    20         PIMsg_Click         = 22,
    21         PIMsg_Press         = 23,
     15        PIMsg_Click         = 21,
     16        PIMsg_Press         = 22,
     17        PIMsg_Release       = 23,
    2218        PIMsg_Drag          = 24,
    2319        PIMsg_Drop          = 25,
     20        PIMsg_Copy          = 26,
     21        PIMsg_Paste         = 27,
     22        PIMsg_Cut           = 28,
    2423
    25         PIMsg_Select        = 31,
    26         PIMsg_ClearSel      = 32
     24        PIMsg_OK            = 21,
     25        PIMsg_Cancel        = 22,
     26        PIMsg_Help          = 23,
     27
     28        PIMsg_DataChanged   = 31,
     29        PIMsg_Select        = 32,
     30        PIMsg_ClearSel      = 33
    2731
    2832};
  • trunk/SophyaPI/PI/pipixmapx.cc

    r37 r52  
    169169myximg->data = new char [YSize()*myximg->bytes_per_line];
    170170if (myximg->data == NULL) 
    171   { XFree(myximg); myximg = NULL; }
     171  { XFree(myximg); myximg = NULL;  return; }
    172172
    173173for(j=0; j<YSize(); j++)
  • trunk/SophyaPI/PI/piscdrawwdg.cc

    r48 r52  
     1#include "generalfit.h"
    12#include "piscdrawwdg.h"
    2 #include "generalfit.h"
    3 #include <algorithm>
    4 
    53
    64PIScDrawWdg::PIScDrawWdg(PIContainerGen *par, char *nom,
     
    86:PIBaseWdg(par, nom, sx, sy, px, py)
    97{
    10   SetLimits(-1, 1, -1, 1);
    11   limitsFixed = 0;
     8  mBDrw = new PIDrawer;
     9  SetSpan();
     10  SetLimits(-1.,1.,-1.,1.);
     11  FreeLimits();
    1212  xEndDrag = yEndDrag = xBegDrag = yBegDrag = 0;
    13   SetAxesFlags(kAxesDflt);
    14   clip = true;
     13
     14  Clip();
     15
    1516  padsup = false;
    1617  mTrlb = mTxw = NULL;
    1718  mTrW = NULL;
    1819  SetTextWin(NULL);
     20
    1921  ActivateButton(1);    // Pour pouvoir activer la fenetre et coordonnees
    2022  ActivateMove(1);      //    "         "         "        "
     
    2628PIScDrawWdg::~PIScDrawWdg()
    2729{
    28   DeleteDrawers();
     30  DeleteScDrawers();
     31  delete mBDrw;
    2932  if (mTrW)  delete mTrW;
    3033}
     
    3336void
    3437PIScDrawWdg::SetLimits(double xmin, double xmax, double ymin, double ymax,
    35                        bool axrl, bool ayud, bool tmp)
     38                       int axrl, int ayud, bool tmp)
    3639{
    3740  if (xmax <= xmin || ymax <= ymin)
    3841    return; // $CHECK$ exception ?
    39   aXdir = axrl;      // Vrai si Axe X de Droite vers Gauche
    40   aYdir = ayud;      // Vrai si Axe Y de Haut vers Bas
    41   xMin = xmin;
    42   xMax = xmax;
    43   yMin = ymin;
    44   yMax = ymax;
    45   mPPos[0] = 0.5*(xMin+xMax);
    46   mPPos[1] = 0.5*(yMin+yMax);
     42  mBDrw->SetLimits(xmin, xmax, ymin, ymax, axrl, ayud);
     43  mPPos[0] = 0.5*(XMin()+XMax());
     44  mPPos[1] = 0.5*(YMin()+YMax());
    4745  if (!tmp) {
    4846    xMinS = xmin;
     
    5149    yMaxS = ymax;
    5250  }
    53   CalcScale();
    54   CalcTicks();
    55   limitsFixed = 1;
    5651}
    5752
     
    5954PIScDrawWdg::Resize()
    6055{
    61   CalcScale();
    62   CalcTicks();
     56  SetSpan();
    6357  Refresh();
    6458}
    6559
    6660void
    67 PIScDrawWdg::CalcScale()
    68 {
    69   double margeH = (xMax-xMin)*0.15;
    70   double margeV = (yMax-yMin)*0.15;
    71   xScale = XSize() / (xMax-xMin + 2*margeH);
    72   if (aXdir)  {
    73     xScale = -xScale;
    74     xOrg   = (-xMax - margeH) * xScale;// + XPos();
    75   }
    76   else xOrg   = (-xMin + margeH) * xScale;// + XPos();
    77   yScale = YSize() / (yMax-yMin + 2*margeV);
    78   if (!aYdir) {
    79     yScale = -yScale;
    80     yOrg   = (-yMax - margeV) * yScale;// + YPos();
    81   }
    82   else yOrg   = (-yMin + margeV) * yScale;// + YPos();
    83 return;
    84 }
    85 
    86 void
    87 PIScDrawWdg::CalcTicks()
    88 {
    89         double xExt = xMax-xMin;
    90         int lx = (int) ceil(log10(xExt)-0.1);
    91         xExt = pow(10.0,lx);
    92         xMajTickStep = xExt/10;
    93         xMinTickStep = xMajTickStep/10;
    94     xFirstMajTick = int(xMin / xMajTickStep) * xMajTickStep;
    95     if (xFirstMajTick < xMin) xFirstMajTick += xMajTickStep;
    96     xFirstMinTick = int(xMin / xMinTickStep) * xMinTickStep;
    97     if (xFirstMinTick < xMin) xFirstMinTick += xMinTickStep;
    98    
    99    
    100         double yExt = yMax-yMin;
    101         int ly = (int) ceil(log10(yExt)-0.1);
    102         yExt = pow(10.0,ly);
    103         yMajTickStep = yExt/10;
    104         yMinTickStep = yMajTickStep/10;
    105     yFirstMajTick = int(yMin / yMajTickStep) * yMajTickStep;
    106     if (yFirstMajTick < yMin) yFirstMajTick += yMajTickStep;
    107     yFirstMinTick = int(yMin / yMinTickStep) * yMinTickStep;
    108     if (yFirstMinTick < yMin) yFirstMinTick += yMinTickStep;
    109    
    110 //    xMajTickLen = -2/yScale;
    111 //    xMinTickLen = -1/yScale;
    112 //    yMajTickLen = 2/xScale;
    113 //    yMinTickLen = 1/xScale;
    114 
    115     yMajTickLen = (xMax-xMin)/100;
    116     yMinTickLen = (xMax-xMin)/250;
    117     xMajTickLen = (yMax-yMin)/100;
    118     xMinTickLen = (yMax-yMin)/250;
    119 
    120 }
    121 
    122 void
    123 PIScDrawWdg::Sc2Local(double x, double y, int& xpix, int& ypix)
    124 {
    125   xpix = int(xOrg + x*xScale + .5);
    126   ypix = int(yOrg + y*yScale + .5);
    127 }
    128 
    129 void
    130 PIScDrawWdg::Local2Sc(int xpix, int ypix, double& x, double& y)
    131 {
    132   x = (xpix-xOrg)/xScale;
    133   y = (ypix-yOrg)/yScale;
    134 }
    135 
    136 
    137 void
    138 PIScDrawWdg::DSc2Local(double dx, double dy, int& dxpix, int& dypix)
    139 {
    140   dxpix = int(dx*xScale + .5);
    141   dypix = int(dy*yScale + .5);
    142 }
    143 
    144 double
    145 PIScDrawWdg::ScStringWidth(char const* s)
    146 {
    147   return CalcStringWidth(s) / xScale;
    148 }
    149 
    150 void
    151 PIScDrawWdg::ScSelFontSz(double size, PIFontAtt att)
    152 {
    153   int npt = int(fabs(size * yScale)+.5);
    154   if (npt < 8) npt = 8;
    155   if (npt > 127) npt = 127;
    156   SelFontSzPt(npt, att);
    157 }
    158 
    159 void
    160 PIScDrawWdg::ScSelMarker(double size, PIMarker mrk)
    161 {
    162   int isz = int(fabs(size * xScale)+.5);
    163   SelMarker( isz, mrk);
    164 }
    165 
    166 void
    167 PIScDrawWdg::ScDrawString(double x, double y, char* s, int pos)
    168 {
    169   int xPix, yPix;
    170   Sc2Local(x, y, xPix, yPix);
    171   DrawString(xPix, yPix, s, pos);
    172 }
    173 
    174 void
    175 PIScDrawWdg::ScDrawLine(double x1, double y1, double x2, double y2)
    176 {
     61PIScDrawWdg::SetSpan()
     62{
     63  int x0, y0, dx, dy;
     64  x0 = (int)(XSize()*0.12);
     65  y0 = (int)(YSize()*0.12);
     66  dx = (int)(XSize()*0.76+0.5);
     67  dy = (int)(YSize()*0.76+0.5);
     68  mBDrw->SetDrwWdg(this, x0, y0, dx, dy);
     69  return;
     70}
     71
     72void
     73PIScDrawWdg::DrawAxes(int flags)
     74{
     75  mBDrw->DrawAxes(flags);
     76}
     77
     78
     79void
     80PIScDrawWdg::SetAxesFlags(int flags)
     81{
     82  mBDrw->SetAxesFlags(flags);
     83}
    17784 
    178   if (clip) {
    179     if (x2 < xMin && x1 < xMin) return;
    180     if (x2 > xMax && x1 > xMax) return;
    181     if (y1 < yMin && y2 < yMin) return;
    182     if (y1 > yMax && y2 > yMax) return;
    183     if (x2 < x1) {
    184       swap(x1,x2);
    185       swap(y1,y2);
    186     }
    187     if (x2>xMax) {
    188       y2 = y1 + (y2-y1)/(x2-x1)*(xMax-x1);
    189       x2 = xMax;
    190     }
    191     if (x1<xMin) {
    192       y1 = y2 + (y1-y2)/(x1-x2)*(xMin-x2);
    193       x1 = xMin;
    194     }
    195     if (y2 < y1) {
    196       swap(x1,x2);
    197       swap(y1,y2);
    198     }
    199     if (y2>yMax) {
    200       x2 = x1 + (x2-x1)/(y2-y1)*(yMax-y1);
    201       y2 = yMax;
    202     }
    203     if (y1<yMin) {
    204       x1 = x2 + (x1-x2)/(y1-y2)*(yMin-y2);
    205       y1 = yMin;
    206     }
    207   }
    208   int x1Pix, y1Pix, x2Pix, y2Pix;
    209   Sc2Local(x1, y1, x1Pix, y1Pix);
    210   Sc2Local(x2, y2, x2Pix, y2Pix);
    211   DrawLine(x1Pix, y1Pix, x2Pix, y2Pix);
    212 
    213 
    214 
    215 void
    216 PIScDrawWdg::ScDrawBox(double x, double y, double dx, double dy)
    217 {
    218   if (clip) {
    219     if (dx < 0) {
    220       x = x+dx;
    221       dx = -dx;
    222     }
    223     if (dy < 0) {
    224       y = y+dy;
    225       dy = -dy;
    226     }
    227     if (x > xMax || x+dx < xMin || y > yMax || y+dy < yMin) return;
    228     if (x < xMin) {
    229       dx -= (xMin-x);
    230       x = xMin;
    231     }
    232     if (y < yMin) {
    233       dy -= (yMin-y);
    234       y = yMin;
    235     }
    236     if (x+dx > xMax)
    237       dx = (xMax-x);
    238     if (y+dy > yMax)
    239       dy = (yMax-y);
    240   }
    241   int xPix, yPix, x2Pix, y2Pix;
    242   Sc2Local(x, y, xPix, yPix);
    243   Sc2Local(x+dx, y+dy, x2Pix, y2Pix);
    244   DrawBox(xPix, yPix, x2Pix-xPix, y2Pix-yPix);
    245 
    246 
    247 void
    248 PIScDrawWdg::ScDrawFBox(double x, double y, double dx, double dy)
    249 {
    250   if (clip) {
    251     if (dx < 0) {
    252       x = x+dx;
    253       dx = -dx;
    254     }
    255     if (dy < 0) {
    256       y = y+dy;
    257       dy = -dy;
    258     }
    259     if (x > xMax || x+dx < xMin || y > yMax || y+dy < yMin) return;
    260     if (x < xMin) {
    261       dx -= (xMin-x);
    262       x = xMin;
    263     }
    264     if (y < yMin) {
    265       dy -= (yMin-y);
    266       y = yMin;
    267     }
    268     if (x+dx > xMax)
    269       dx = (xMax-x);
    270     if (y+dy > yMax)
    271       dy = (yMax-y);
    272   }
    273   int xPix, yPix, x2Pix, y2Pix;
    274   Sc2Local(x, y, xPix, yPix);
    275   Sc2Local(x+dx, y+dy, x2Pix, y2Pix);
    276   DrawFBox(xPix, yPix, x2Pix-xPix, y2Pix-yPix);
    277 
    278 
    279 void
    280 PIScDrawWdg::ScDrawCircle(double x, double y, double r)
    281 {
    282   int xPix, yPix, rPix;
    283   Sc2Local(x, y, xPix, yPix);
    284   rPix = r * xScale;
    285   DrawCircle(xPix, yPix, rPix);
    286 
    287 
    288 void
    289 PIScDrawWdg::ScDrawFCircle(double x, double y, double r)
    290 {
    291   int xPix, yPix, rPix;
    292   Sc2Local(x, y, xPix, yPix);
    293   rPix = r * xScale;
    294   DrawFCircle(xPix, yPix, rPix);
    295 }
    296 
    297 #define NMXMULTP  30   // Pour multipoint sans new
    298 
    299 void 
    300 PIScDrawWdg::ScDrawPolygon(double *x, double *y, int n)
    301 {
    302 int ix[NMXMULTP], iy[NMXMULTP];
    303 int *pxi, *pyi;
    304 int i;
    305  
    306 if (n <= 0)  return;
    307 if (n > NMXMULTP) { pxi = new int[n];  pyi = new int[n]; }
    308 else { pxi = ix;  pyi = iy; }
    309 for(i=0; i<n; i++) 
    310   Sc2Local(x[i], y[i], pxi[i], pyi[i]);
    311 DrawPolygon(pxi, pyi, n);
    312 if (n > NMXMULTP) { delete[] pxi;  delete[] pyi; }
    313 return;
    314 }
    315  
    316 void 
    317 PIScDrawWdg::ScDrawFPolygon(double *x, double *y, int n)
    318 {
    319 int xi[NMXMULTP], yi[NMXMULTP];
    320 int *pxi, *pyi;
    321 int i;
    322  
    323 if (n <= 0)  return;
    324 if (n > NMXMULTP) { pxi = new int[n];  pyi = new int[n]; }
    325 else { pxi = xi;  pyi = yi; }
    326 for(i=0; i<n; i++) 
    327   Sc2Local(x[i], y[i], pxi[i], pyi[i]);
    328 DrawFPolygon(pxi, pyi, n);
    329 if (n > NMXMULTP) { delete[] pxi;  delete[] pyi; }
    330 return;
    331 }
    332 
    333 void 
    334 PIScDrawWdg::ScDrawMarker(double x0, double y0)
    335 {
    336   int xPix, yPix;
    337   Sc2Local(x0, y0, xPix, yPix);
    338   DrawMarker(xPix, yPix);
    339   return;
    340 }
    341 void 
    342 PIScDrawWdg::ScDrawMarkers(double *x, double *y, int n)
    343 {
    344 int xi[NMXMULTP], yi[NMXMULTP];
    345 int *pxi, *pyi;
    346 int i;
    347  
    348 if (n <= 0)  return;
    349 if (n > NMXMULTP) { pxi = new int[n];  pyi = new int[n]; }
    350 else { pxi = xi;  pyi = yi; }
    351 for(i=0; i<n; i++) 
    352   Sc2Local(x[i], y[i], pxi[i], pyi[i]);
    353 DrawMarkers(pxi, pyi, n);
    354 if (n > NMXMULTP) { delete[] pxi;  delete[] pyi; }
    355 return;
    356 }
    357 
    358 void
    359 PIScDrawWdg::DrawHTicks(double y, double tickUp, double tickDown, double xBeg, double xStep)
    360 {
    361   for (double x=xBeg; x<=xMax; x += xStep)
    362     ScDrawLine(x, y-tickDown, x, y+tickUp);
    363 }
    364 
    365 void
    366 PIScDrawWdg::DrawVTicks(double x, double tickLeft, double tickRight, double yBeg, double yStep)
    367 {
    368   for (double y=yBeg; y<=yMax; y += yStep)
    369     ScDrawLine(x-tickLeft, y, x+tickRight, y);
    370 }
    371 
    372 void
    373 PIScDrawWdg::DrawHLabels(double y, double xBeg, double xStep, int just)
    374 {
    375   double xOffset = 0;
    376   int kk;
    377   ScSelFontSz(xMajTickLen*4);
    378   for (double x=xBeg; x<=xMax; x += xStep) {
    379       char label[20]; sprintf(label, "%-6g", x);
    380       for(kk=0; kk<20; kk++)
    381         if (label[kk] == ' ')   { label[kk] = '\0' ; break; }
    382       double largeur = ScStringWidth(label);
    383       if (just == 1)
    384         xOffset = -largeur;
    385       else if (just == 0)
    386         xOffset = -largeur/2;
    387       else
    388         xOffset = 0;
    389       if (aXdir)  xOffset = -xOffset;
    390       ScDrawString(x+xOffset, y, label);
    391   }
    392 }
    393 
    394 void
    395 PIScDrawWdg::DrawVLabels(double x, double yBeg, double yStep, int just)
    396 {
    397   double xOffset = 0;
    398   ScSelFontSz(xMajTickLen*4);
    399   for (double y=yBeg; y<=yMax; y += yStep) {
    400       char label[20]; sprintf(label, "%-6g", y);
    401       double largeur = ScStringWidth(label);
    402       if (just == 1)
    403         xOffset = -largeur;
    404       else if (just == 0)
    405         xOffset = -largeur/2;
    406       else
    407         xOffset = 0;
    408       if (aXdir)  xOffset = -xOffset;
    409       ScDrawString(x+xOffset, y, label);
    410   }
    411 }
    412 
    413 
    414 void
    415 PIScDrawWdg::DrawAxes(int flags)
    416 {
    417   NoClip();
    418   if (flags == -1)
    419     flags = axesFlags;
    420    
    421  
    422   if (flags & kStdAxes) {
    423  
    424     // Les axes
    425    
    426     ScDrawLine(xMin, 0, xMax, 0);
    427     ScDrawLine(0, yMin, 0, yMax);
    428  
    429     // Les ticks majeurs
    430  
    431     if (flags & kMajTicks) {
    432         DrawHTicks(0, xMajTickLen, xMajTickLen, xFirstMajTick, xMajTickStep);
    433         DrawVTicks(0, yMajTickLen, yMajTickLen, yFirstMajTick, yMajTickStep);
    434     }
    435    
    436     // Les ticks mineurs
    437  
    438     if (flags & kMinTicks) {
    439         DrawHTicks(0, xMinTickLen, xMinTickLen, xFirstMinTick, xMinTickStep);
    440         DrawVTicks(0, yMinTickLen, yMinTickLen, yFirstMinTick, yMinTickStep);
    441     }
    442    
    443     // Les labels
    444    
    445     if (flags & kLabels) {
    446       if (!aYdir)
    447         DrawHLabels(-xMajTickLen*8, xFirstMajTick, xMajTickStep,0);
    448       else
    449         DrawHLabels(xMajTickLen*8, xFirstMajTick, xMajTickStep,0);
    450       if (!aXdir)
    451         DrawVLabels(-yMajTickLen*2, yFirstMajTick, yMajTickStep,1);
    452       else
    453         DrawVLabels(yMajTickLen*2, yFirstMajTick, yMajTickStep,1);
    454     }
    455    
    456   }
    457  
    458   if (flags & kBoxAxes) {
    459  
    460     // La boite
    461    
    462     ScDrawLine(xMin, yMin, xMax, yMin);
    463     ScDrawLine(xMax, yMin, xMax, yMax);
    464     ScDrawLine(xMax, yMax, xMin, yMax);
    465     ScDrawLine(xMin, yMax, xMin, yMin);
    466 
    467     // Longueur des ticks
    468    
    469     double extXMajTickLen = flags&kExtTicks ? xMajTickLen : 0;
    470     double intXMajTickLen = flags&kIntTicks ? xMajTickLen : 0;
    471     double extXMinTickLen = flags&kExtTicks ? xMinTickLen : 0;
    472     double intXMinTickLen = flags&kIntTicks ? xMinTickLen : 0;
    473     double extYMajTickLen = flags&kExtTicks ? yMajTickLen : 0;
    474     double intYMajTickLen = flags&kIntTicks ? yMajTickLen : 0;
    475     double extYMinTickLen = flags&kExtTicks ? yMinTickLen : 0;
    476     double intYMinTickLen = flags&kIntTicks ? yMinTickLen : 0;
    477 
    478     // Les ticks majeurs
    479  
    480     if (flags & kMajTicks) {
    481         DrawHTicks(yMin, intXMajTickLen, extXMajTickLen, xFirstMajTick, xMajTickStep);
    482         DrawHTicks(yMax, extXMajTickLen, intXMajTickLen, xFirstMajTick, xMajTickStep);
    483         DrawVTicks(xMin, extYMajTickLen, intYMajTickLen, yFirstMajTick, yMajTickStep);
    484         DrawVTicks(xMax, intYMajTickLen, extYMajTickLen, yFirstMajTick, yMajTickStep);
    485     }
    486    
    487     // Les ticks mineurs
    488  
    489     if (flags & kMinTicks) {
    490         DrawHTicks(yMin, intXMinTickLen, extXMinTickLen, xFirstMinTick, xMinTickStep);
    491         DrawHTicks(yMax, extXMinTickLen, intXMinTickLen, xFirstMinTick, xMinTickStep);
    492         DrawVTicks(xMin, extYMinTickLen, intYMinTickLen, yFirstMinTick, yMinTickStep);
    493         DrawVTicks(xMax, intYMinTickLen, extYMinTickLen, yFirstMinTick, yMinTickStep);
    494     }
    495 
    496 
    497     // Les labels
    498    
    499     if (flags & kLabels) {
    500       if (!aYdir) {
    501         DrawHLabels(yMin-xMajTickLen*8, xFirstMajTick, xMajTickStep,0);
    502         DrawHLabels(yMax+xMajTickLen*2, xFirstMajTick, xMajTickStep,0);
    503       }
    504       else {
    505         DrawHLabels(yMin-xMajTickLen*2, xFirstMajTick, xMajTickStep,0);
    506         DrawHLabels(yMax+xMajTickLen*8, xFirstMajTick, xMajTickStep,0);
    507       }
    508       if (!aXdir) {
    509         DrawVLabels(xMin-yMajTickLen*2, yFirstMajTick, yMajTickStep,1);
    510         DrawVLabels(xMax+yMajTickLen*2, yFirstMajTick, yMajTickStep,-1);
    511       }
    512       else {
    513         DrawVLabels(xMin-yMajTickLen*2, yFirstMajTick, yMajTickStep,-1);
    514         DrawVLabels(xMax+yMajTickLen*2, yFirstMajTick, yMajTickStep,1);
    515       }
    516     }
    517   }
    518   Clip();
    519 }
    520 
    521  
    522 
    523 void
    524 PIScDrawWdg::AddDrawer(PIScDrawer* d)
    525 {
    526   mDrawers.push_back(d);
    527   d->AttachTo(this);
    528 }
    529 
    530 void
    531 PIScDrawWdg::RemoveDrawer(PIScDrawer* d)
     85
     86void
     87PIScDrawWdg::AddScDrawer(PIScDrawer* d, bool ad)
     88{
     89  bool pd=false;
     90  if (mScDrawers.size() == 0)  pd = true;
     91  mScDrawers.push_back(d);
     92  d->AttachTo(this, ad, pd);
     93}
     94
     95void
     96PIScDrawWdg::RemoveScDrawer(PIScDrawer* d)
    53297{
    53398  if (padsup)  return;
    534   mDrawers.remove(d);
    535   d->mDrawWdg = NULL;
    536 }
    537 
    538 void
    539 PIScDrawWdg::DeleteDrawers()
     99  vector<PIScDrawer*>::iterator drw;
     100  for(drw = mScDrawers.begin(); drw != mScDrawers.end(); drw++)
     101    if (d == (*drw)) { mScDrawers.erase(drw);  break; }
     102  d->mDrawWdg = NULL;  d->mDrawer = NULL;
     103}
     104
     105int
     106PIScDrawWdg::NbScDrawers()
     107{
     108  return(mScDrawers.size());
     109}
     110
     111PIScDrawer*
     112PIScDrawWdg::ScDrawer(int i)
     113{
     114 if ( (i<0) || (i>mScDrawers.size()) )  return(NULL);
     115 return(mScDrawers[i]);
     116}
     117
     118
     119void
     120PIScDrawWdg::DeleteScDrawers()
    540121{
    541122  padsup = true;
    542   for(list<PIScDrawer*>::iterator i = mDrawers.begin(); i != mDrawers.end(); i++)
    543     delete *i;
    544   mDrawers.erase(mDrawers.begin(),mDrawers.end());
     123  vector<PIScDrawer*>::iterator i;
     124  for(i = mScDrawers.begin(); i != mScDrawers.end(); i++) {
     125    if ( (*i)->ADelByDrwWdg() )  delete *i;
     126  }
     127  mScDrawers.erase(mScDrawers.begin(),mScDrawers.end());
    545128  padsup = false;
    546129}
    547130
    548131void
    549 PIScDrawWdg::CallDrawer(PIScDrawer* d)
    550 {
    551   d->Draw();
    552 }
    553 
    554 void
    555 PIScDrawWdg::CallDrawers()
    556 {
    557   for_each(mDrawers.begin(), mDrawers.end(), CallDrawer);
    558 }
    559 
    560 void
    561 PIScDrawWdg::SetAxesFlags(int flags)
    562 {
    563   axesFlags = flags;
    564   if (axesFlags & (kIntTicks | kExtTicks | kMajTicks | kMinTicks))
    565     axesFlags |= kTicks;
    566   if ((axesFlags & (kTicks | kIntTicks | kExtTicks)) == kTicks)
    567     axesFlags |= kIntTicks | kExtTicks;
    568   if ((axesFlags & (kTicks | kMajTicks | kMinTicks)) == kTicks)
    569     axesFlags |= kMajTicks;
    570 }
     132PIScDrawWdg::CallScDrawers(double xmin, double ymin, double xmax, double ymax)
     133{
     134  vector<PIScDrawer*>::iterator drw;
     135  for(drw = mScDrawers.begin(); drw != mScDrawers.end(); drw++) {
     136    (*drw)->SelGraAtt();
     137    (*drw)->Draw(xmin, ymin, xmax, ymax);
     138  }
     139}
     140
    571141void
    572142PIScDrawWdg::SetTextWin(PILabel * tw, bool trw, int tx, int ty)
     
    580150    mTrW = new PIWindow(this, "Point", PIWK_transient, tx, ty, 0, 0);
    581151    mTrW->SetAutoDelChilds(true);
    582     mTrlb = new PILabel(mTrW, "PixVal", tx, ty, 0, 0);
     152    mTrlb = new PILabel(mTrW, "PointCoord", tx, ty, 0, 0);
    583153    mTrlb->SetBinding(PIBK_fixed,PIBK_fixed, PIBK_fixed,PIBK_fixed);
    584154    }
     
    595165  EraseWindow();
    596166  DrawAxes();
    597   CallDrawers();
    598   DrawSelf();
    599 }
    600 
     167  DrawSelf(-9.e19, -9.e19, 9.e19, 9.e19);
     168  CallScDrawers(-9.e19, -9.e19, 9.e19, 9.e19);
     169  CallDrawers(0,0,0,0);
     170}
     171
     172void
     173PIScDrawWdg::Draw(int x0, int y0, int dx, int dy)
     174{
     175  double xmin,xmax,ymin,ymax;
     176  mBDrw->Local2Sc(x0, y0, xmin, ymin);
     177  mBDrw->Local2Sc(x0+dx, y0+dy, xmax, ymax);
     178  if (xmin > xmax) swap(xmin,xmax);
     179  if (ymin > ymax) swap(ymin,ymax);
     180  DrawAxes();
     181  DrawSelf(xmin, ymin, xmax, ymax);
     182  CallScDrawers(xmin, ymin, xmax, ymax); 
     183  CallDrawers(x0, y0, dx, dy);
     184}
     185
     186void
     187PIScDrawWdg::DrawSelf()
     188{
     189return;
     190}
     191
     192void
     193PIScDrawWdg::DrawSelf(double /*xmin*/, double /*ymin*/, double /*xmax*/, double /*ymax*/)
     194{
     195return;
     196}
    601197
    602198
     
    641237
    642238  double dx, dy;
    643   Local2Sc(xp, yp, dx, dy);
     239  mBDrw->Local2Sc(xp, yp, dx, dy);
    644240  mPPos[0] = dx;  mPPos[1] = dy;
    645241  if ((mTxw == NULL) && (mTrlb == NULL)) return(false);
     
    684280 
    685281  if (xBegDrag == xEndDrag || yBegDrag == yEndDrag)
    686     SetLimits(xMinS, xMaxS, yMinS, yMaxS, aXdir, aYdir );
     282    SetLimits(xMinS, xMaxS, yMinS, yMaxS, kAxeDirSame, kAxeDirSame );
    687283  else {
    688284    double xl,yl,xh,yh;
    689     Local2Sc(xBegDrag, yBegDrag, xl, yl);
    690     Local2Sc(xEndDrag, yEndDrag, xh, yh);
     285    mBDrw->Local2Sc(xBegDrag, yBegDrag, xl, yl);
     286    mBDrw->Local2Sc(xEndDrag, yEndDrag, xh, yh);
    691287    if (xl > xh) swap(xl, xh);
    692288    if (yl > yh) swap(yl, yh);
    693     SetLimits(xl,xh,yl,yh, aXdir, aYdir, true);
     289    SetLimits(xl,xh,yl,yh, kAxeDirSame, kAxeDirSame, true);
    694290  }
    695291 
     
    710306//================================================================
    711307
     308
     309
    712310PIScDrawer::PIScDrawer()
    713 : mDrawWdg(NULL)
    714 {}
     311: mDrawWdg(NULL), mDrawer(NULL)
     312{
     313  mADbW = mAdDO = mPrDw = false;
     314  mFCol = mBCol = PI_NotDefColor;
     315  mLAtt = PI_NotDefLineAtt;
     316  mFSz = PI_NotDefFontSize;
     317  mFAtt = PI_NotDefFontAtt;
     318  mMSz = -1;
     319  mMrk = PI_NotDefMarker;
     320}
    715321
    716322PIScDrawer::~PIScDrawer()
    717323{
    718324  if (mDrawWdg)
    719     mDrawWdg->RemoveDrawer(this);
    720 }
    721 
    722 void
    723 PIScDrawer::AttachTo(PIScDrawWdg* wdg)
     325    mDrawWdg->RemoveScDrawer(this);
     326}
     327
     328void
     329PIScDrawer::UpdateSize()
     330{
     331// Ne fait rien !
     332  return;
     333}
     334
     335void
     336PIScDrawer::Refresh()
     337{
     338// Recalcule les limites, et reaffiche
     339  if (!mDrawer) return;
     340  mDrawWdg->FreeLimits();
     341  UpdateSize();
     342  if (mDrawWdg) mDrawWdg->Refresh();
     343}
     344
     345void
     346PIScDrawer::AttachTo(PIScDrawWdg* wdg, bool ad, bool prd)
    724347{
    725348  if (mDrawWdg)
    726     mDrawWdg->RemoveDrawer(this);
    727   mDrawWdg = wdg;
    728 }
    729 
    730 
     349    mDrawWdg->RemoveScDrawer(this);
     350  mDrawWdg = wdg; 
     351  mDrawer = wdg->BaseDrawer();
     352  UpdateSize();
     353  mADbW = ad;
     354  mPrDw = prd;
     355}
     356
     357// Classe PIDrawer special pour enrober un PIScDrawer en PIDrawer
     358class PIScContDrw : public PIDrawer {
     359public :
     360                     PIScContDrw(PIScDrawer* d, bool ad=false);
     361  virtual            ~PIScContDrw();
     362  virtual  void      Draw();
     363  virtual  void      Draw(double xmin, double ymin, double xmax, double ymax);
     364private:
     365  PIScDrawer* mScDrw;
     366  bool mAD;
     367};
     368
     369PIScContDrw::PIScContDrw(PIScDrawer* d, bool ad) 
     370{
     371  mScDrw = d;
     372  mAD=ad;
     373}
     374
     375PIScContDrw::~PIScContDrw()
     376{
     377  if (mAD)  delete mScDrw;
     378}
     379
     380void PIScContDrw::Draw()
     381{
     382  mScDrw->SelGraAtt();
     383  mScDrw->Draw(-9.e19, -9.e19, 9.e19, 9.e19);
     384}
     385
     386void PIScContDrw::Draw(double xmin, double ymin, double xmax, double ymax)
     387{
     388  mScDrw->SelGraAtt();
     389  mScDrw->Draw(xmin, ymin, xmax, ymax);
     390}
     391
     392PIDrawer*
     393PIScDrawer::Convert()
     394{
     395  PIScContDrw* rd;
     396  if (mDrawWdg) mDrawWdg->RemoveScDrawer(this);
     397  mDrawWdg = NULL;
     398  rd = new PIScContDrw(this);
     399  mDrawer = rd;
     400  UpdateSize();
     401  return((PIDrawer*)rd);
     402}
     403
     404void
     405PIScDrawer::SetColAtt(PIColors fg, PIColors bg)
     406{
     407  if (fg != PI_NotDefColor) mFCol = fg;
     408  if (bg != PI_NotDefColor) mBCol = bg;
     409}
     410
     411void
     412PIScDrawer::SetLineAtt(PILineAtt lat)
     413{
     414  if (lat != PI_NotDefLineAtt) mLAtt = lat;
     415}
     416
     417void
     418PIScDrawer::SetFontAtt(PIFontSize fsz, PIFontAtt fat)
     419{
     420  if (fsz != PI_NotDefFontSize) mFSz = fsz;
     421  if (fat != PI_NotDefFontAtt) mFAtt = fat;
     422}
     423
     424void
     425PIScDrawer::SetMarkerAtt(int sz, PIMarker mrk)
     426{
     427  if (sz >= 0)  mMSz = sz;
     428  if (mrk != PI_NotDefMarker) mMrk = mrk;
     429}
     430
     431void
     432PIScDrawer::SelGraAtt()
     433{
     434  if (mDrawer == NULL)   return;
     435  if (mFCol != PI_NotDefColor)    mDrawer->SelForeground(mFCol);
     436  if (mBCol != PI_NotDefColor)    mDrawer->SelBackground(mBCol);
     437  if (mLAtt != PI_NotDefLineAtt)  mDrawer->SelLine(mLAtt);
     438  if ( (mFSz != PI_NotDefFontSize) || (mFAtt != PI_NotDefFontAtt) )
     439                                  mDrawer->SelFont(mFSz, mFAtt);
     440  if ( (mMrk != PI_NotDefMarker) || (mMSz >= 0) )
     441                                  mDrawer->SelMarker(mMSz, mMrk);
     442}
    731443
    732444//================================================================
     
    743455
    744456void
    745 PIScFuncDrawer::Draw()
    746 {
    747   if (!mDrawWdg) return;
    748   double xMax = mDrawWdg->XMax();
    749   double xMin = mDrawWdg->XMin();
    750   double yMax = mDrawWdg->YMax();
    751   double yMin = mDrawWdg->YMin();
     457PIScFuncDrawer::Draw(double /*xmin*/, double/*ymin*/, double/*xmax*/, double/*ymax*/)
     458{
     459  if (!mDrawer) return;
     460  double xMax = mDrawer->XMax();
     461  double xMin = mDrawer->XMin();
     462  double yMax = mDrawer->YMax();
     463  double yMin = mDrawer->YMin();
    752464  double xStep = (xMax - xMin)/100;
    753465  double xOld = xMin;
     
    757469    if (y>yMin && yOld>yMin &&
    758470        y<yMax && yOld<yMax)
    759            mDrawWdg->ScDrawLine(xOld, yOld, x, y);
     471           mDrawer->DrawLine(xOld, yOld, x, y);
    760472    xOld = x;
    761473    yOld = y;
     
    787499
    788500void
    789 PIScGFFDrawer::Draw()
    790 {
    791   if (!mDrawWdg) return;
    792   double xMax = mDrawWdg->XMax();
    793   double xMin = mDrawWdg->XMin();
    794   double yMax = mDrawWdg->YMax();
    795   double yMin = mDrawWdg->YMin();
     501PIScGFFDrawer::Draw(double /*xmin*/, double/*ymin*/, double/*xmax*/, double/*ymax*/)
     502{
     503  if (!mDrawer) return;
     504  double xMax = mDrawer->XMax();
     505  double xMin = mDrawer->XMin();
     506  double yMax = mDrawer->YMax();
     507  double yMin = mDrawer->YMin();
    796508  double xStep = (xMax - xMin)/100;
    797509  double xOld = xMin;
     
    803515    if (y>yMin && yOld>yMin &&
    804516        y<yMax && yOld<yMax)
    805            mDrawWdg->ScDrawLine(xOld, yOld, x, y);
     517           mDrawer->DrawLine(xOld, yOld, x, y);
    806518    xOld = x;
    807519    yOld = y;
  • trunk/SophyaPI/PI/piscdrawwdg.h

    r48 r52  
    22#define PISCDRAWWDG_H
    33
     4#include <vector>
    45
    56#include "pisysdep.h"
     
    78#include PISTDWDG_H
    89#include PIWIN_H
     10#include "pidrawer.h"
    911
    10 #include <list>
    1112
    12   enum {
    13     kStdAxes     = 0x0001,
    14     kBoxAxes     = 0x0002,
    15     kTicks       = 0x0004,
    16     kIntTicks    = 0x0010,
    17     kExtTicks    = 0x0020,
    18     kMajTicks    = 0x0040,
    19     kMinTicks    = 0x0080,
    20     kLabels      = 0x1000,
    21     kAxesDflt    = kStdAxes | kTicks | kLabels
    22   };
    2313
     14class PIScDrawer;
    2415
    2516class PIScDrawWdg : public PIBaseWdg {
     
    2920  virtual           ~PIScDrawWdg();
    3021
    31   virtual void       SetLimits(double xmin, double xmax, double ymin, double ymax,
    32                                bool axrl=false, bool ayud=false, bool tmp=false);
    33  
    34   virtual void       ScDrawString(double x, double y, char* s, int pos = 0);
    35   virtual void       ScDrawLine(double x1, double y1, double x2, double y2);
    36   virtual void       ScDrawBox(double x0, double y0, double dx, double dy);
    37   virtual void       ScDrawFBox(double x0, double y0, double dx, double dy);
    38   virtual void       ScDrawCircle(double x0, double y0, double r);
    39   virtual void       ScDrawFCircle(double x0, double y0, double r);
    40   virtual void       ScDrawPolygon(double *x, double *y, int n); 
    41   virtual void       ScDrawFPolygon(double *x, double *y, int n);
    42   virtual void       ScDrawMarker(double x0, double y0);
    43   virtual void       ScDrawMarkers(double *x0, double *y0, int n);
    44 
    45   virtual double     ScStringWidth(char const*);
    46 
    47   virtual void       ScSelFontSz(double size, PIFontAtt att=PI_RomanFont);
    48   virtual void       ScSelMarker(double size=0, PIMarker mrk=PI_DotMarker);
    49 
    50   virtual void       DrawAxes(int flags = -1);
    51   virtual void       DrawSelf() {}
    52  
    5322  virtual void       Resize();
    5423 
    55   virtual void       CalcTicks();
    56   virtual void       CalcScale();
     24  virtual void       Draw();
     25  virtual void       Draw(int x0, int y0, int dx, int dy);
     26  virtual void       DrawSelf();
     27  virtual void       DrawSelf(double xmin, double ymin, double xmax, double ymax);
    5728 
    58   virtual void       Sc2Local(double x, double y, int& xpix, int& ypix);
    59   virtual void       Local2Sc(int xpix, int ypix, double& x, double& y);
    60   virtual void       DSc2Local(double dx, double dy, int& dxpix, int& dypix);
    61  
    62   virtual void       Draw();
    63  
    64   friend class PIScDrawer;
    65   virtual void       AddDrawer(PIScDrawer*);   // Ajoute un drawer
    66   virtual void       RemoveDrawer(PIScDrawer*);  // Ote un drawer sans le detruire
    67   virtual void       DeleteDrawers();            // Ote et detruit tous les drawers
    68   static  void       CallDrawer(PIScDrawer*);
    69   virtual void       CallDrawers();
    70   virtual void       SetAxesFlags(int flags=kAxesDflt);
    71  
    72   void               SetTextWin(PILabel * tw, bool trw=true, int tx=200, int ty=30);
     29  void               SetLimits(double xmin, double xmax, double ymin, double ymax,
     30                               int axrl=kAxeDirSame, int ayud=kAxeDirSame, bool tmp=false);
    7331
    74   double XMin() const {return xMin;}
    75   double XMax() const {return xMax;}
    76   double YMin() const {return yMin;}
    77   double YMax() const {return yMax;}
     32  void               SetAxesFlags(int flags=kAxesDflt);
     33  void               DrawAxes(int flags = -1);
     34
     35  void               AddScDrawer(PIScDrawer*, bool ad=false);   // Ajoute un ScDrawer
     36  void               RemoveScDrawer(PIScDrawer*);  // Ote un ScDrawer sans le detruire
     37  int                NbScDrawers();
     38  PIScDrawer*        ScDrawer(int i);         
     39
     40  PIDrawer*          BaseDrawer() { return mBDrw; };
     41
     42  double XMin() const {return mBDrw->XMin();}
     43  double XMax() const {return mBDrw->XMax();}
     44  double YMin() const {return mBDrw->YMin();}
     45  double YMax() const {return mBDrw->YMax();}
    7846  double XPPos() const { return mPPos[0]; }
    7947  double YPPos() const { return mPPos[1]; }
    80   int    LimitsFixed() const {return limitsFixed;}
    81   void   FreeLimits() {limitsFixed = 0;}
    82   void   NoClip() {clip = false;}
    83   void   Clip() {clip = true;}
     48  int    LimitsFixed() const {return mBDrw->LimitsFixed();}
     49  void   FreeLimits() { mBDrw->FreeLimits(); }
     50  void   NoClip() { mBDrw->NoClip(); }
     51  void   Clip() { mBDrw->NoClip(); }
    8452   
     53
     54  void               SetTextWin(PILabel * tw, bool trw=true, int tx=200, int ty=30);
    8555
    8656  virtual void       But1Press(int x, int y);
     
    9363 
    9464protected:
    95   double xMin, xMax, yMin, yMax; // Valeurs en unites user
     65          void       DeleteScDrawers();    // Ote et detruit tous les ScDrawers
     66          void       CallScDrawers(double xmin, double ymin, double xmax, double ymax);
     67          void       SetSpan();
     68
    9669  double xMinS, xMaxS, yMinS, yMaxS; // Sauvegarde pour zoom
    97   double xOrg, yOrg;             // Position en pixels de (0.0, 0.0)
    98   double xScale, yScale;         // Pixels par unites graphiques
    99   bool   aXdir, aYdir;           // Sens des axes horiz, vertical
    10070  double mPPos[2];               // Position click souris X,Y
    101   double xFirstMajTick, xFirstMinTick;
    102   double yFirstMajTick, yFirstMinTick;
    103   double xMajTickStep, xMinTickStep;
    104   double yMajTickStep, yMinTickStep;
    105   double xMajTickLen,  xMinTickLen;
    106   double yMajTickLen,  yMinTickLen;
    107  
    108   int limitsFixed;
    109   int axesFlags;
    110   list<PIScDrawer*>   mDrawers;
     71
     72  PIDrawer* mBDrw;
     73  vector<PIScDrawer*>   mScDrawers;
     74  bool padsup;
    11175 
    11276  int xBegDrag, yBegDrag;
     
    11983  PILabel * mTrlb;
    12084  PIWindow * mTrW;
    121   bool clip;
    122   bool padsup;
    12385
    12486
    12587private:
    126   void DrawHTicks(double y, double tickUp, double tickDown, double xBeg, double xStep);
    127   void DrawVTicks(double x, double tickLeft, double tickRight, double yBeg, double yStep);
    128   void DrawHLabels(double y, double xBeg, double xStep, int just=0);
    129   void DrawVLabels(double x, double yBeg, double yStep, int just=0);
    130  
    13188  bool  UpdateText(int xp, int yp);
    13289};
     90
    13391
    13492class PIScDrawer {
     
    13795  virtual           ~PIScDrawer();
    13896
    139   virtual void       Draw() = 0;
     97  virtual void       Draw(double xmin, double ymin, double xmax, double ymax) = 0;
     98  virtual void       UpdateSize();   // Calcule et change les limites si non fixees
     99  virtual void       Refresh();      // Recalcule les limites et reaffiche
     100
     101  PIDrawer*          Convert();
     102
     103  void               SetColAtt(PIColors fg=PI_NotDefColor,
     104                                PIColors bg=PI_NotDefColor);
     105  void               SetLineAtt(PILineAtt lat=PI_NotDefLineAtt);
     106  void               SetFontAtt(PIFontSize fsz=PI_NotDefFontSize,
     107                                PIFontAtt fat=PI_NotDefFontAtt);
     108  void               SetMarkerAtt(int sz=-1, PIMarker mrk=PI_NotDefMarker);
     109
     110  void               SelGraAtt();
     111
     112  inline void        SetAutoDelDataObj(bool ad=false) { mAdDO = ad; }
     113  inline bool        ADelByDrwWdg() { return mADbW; }
     114  inline bool        MainScDrawer() { return mPrDw; }
     115
    140116protected:
    141117  friend class       PIScDrawWdg;
    142   virtual void       AttachTo(PIScDrawWdg*);
     118  virtual void       AttachTo(PIScDrawWdg*, bool, bool);
     119
    143120  PIScDrawWdg*       mDrawWdg;
     121  PIDrawer*          mDrawer;
     122  bool               mADbW, mAdDO, mPrDw;
     123  PIColors           mFCol, mBCol;
     124  PILineAtt          mLAtt;
     125  PIFontSize         mFSz;
     126  PIFontAtt          mFAtt;
     127  int                mMSz;
     128  PIMarker           mMrk;     
    144129};
    145130
     
    150135  virtual           ~PIScFuncDrawer();
    151136 
    152   virtual void       Draw();
     137  virtual void       Draw(double xmin, double ymin, double xmax, double ymax);
    153138protected:
    154139  FUNC               mFunc;
     
    161146  virtual           ~PIScGFFDrawer();
    162147 
    163   virtual void       Draw();
     148  virtual void       Draw(double xmin, double ymin, double xmax, double ymax);
    164149  virtual void       SetParms(double const*);
    165150protected:
  • trunk/SophyaPI/PI/pistlist.cc

    r37 r52  
    44 
    55/* --Methode-- */
    6 PIStarList::PIStarList(StarList* stl, bool ayud)
     6PIStarList::PIStarList(StarList* stl, bool ad, int ayud)
    77: PIScDrawer(), mStL(stl)
    88{
    9   mAdelStl = false;   
     9  mAdDO = ad;   
    1010  mAYdir = ayud; 
    1111  if (stl == NULL) return;
     
    1616PIStarList::~PIStarList()
    1717{
    18   if (mAdelStl && mStL)
    19     delete mStL;
     18  if (mAdDO && mStL)  delete mStL;
    2019}
    2120
     
    5756
    5857
    59 /* --Methode-- */
    60 void  PIStarList::AttachTo(PIScDrawWdg* wdg)
    61 {
    62   PIScDrawer::AttachTo(wdg);
    63   UpdateSize();
    64 }
    65 
    6658
    6759/* --Methode-- */
     
    6961{
    7062  if (!mStL) return;
    71   if (!mDrawWdg) return;
    72   if (mDrawWdg->LimitsFixed()) return;
     63  if (!mDrawer) return;
     64  if (mDrawer->LimitsFixed()) return;
    7365
    7466  // Commencer par trouver nos limites
     
    7870  dy = 0.02*(mYMax-mYMin);
    7971 
    80   mDrawWdg->SetLimits(mXMin-dx, mXMax+dx, mYMin-dy, mYMax+dy, false, mAYdir);
    81   mDrawWdg->SetAxesFlags(kBoxAxes | kExtTicks | kLabels);
     72  if (mDrawWdg)
     73    mDrawWdg->SetLimits(mXMin-dx, mXMax+dx, mYMin-dy, mYMax+dy, kAxeDirLtoR, mAYdir);
     74  else
     75    mDrawer->SetLimits(mXMin-dx, mXMax+dx, mYMin-dy, mYMax+dy, false, mAYdir);
     76
     77  mDrawer->SetAxesFlags(kBoxAxes | kExtTicks | kLabels);
    8278}
    8379
    8480
    8581/* --Methode-- */
    86 void PIStarList::Draw()
     82void PIStarList::Draw(double xmin, double ymin, double xmax, double ymax)
    8783{
    8884BStar *sti;
     
    9389
    9490if (!mStL) return;
    95 if (!mDrawWdg) return;
     91if (!mDrawer) return;
    9692
    97 mDrawWdg->SelFont();
     93mDrawer->SelFont();
    9894nok = 0;  nl2 = mNLev*2-1;
    9995for (int i=0; i<mStL->NbStars(); i++) {
     
    104100  xp = sti->PosX();   yp = sti->PosY();
    105101  if ( (xp < mXMin) || (xp > mXMax) || (yp < mYMin) || (yp > mYMax) )  continue;
     102  if ( (xp < xmin) || (xp > xmax) || (yp < ymin) || (yp > ymax) )  continue;
    106103  nok++;
    107104  sz = (int)((log10((double)flx/mF0))/mDLgF*(double)nl2-0.01) + mMSz0;
    108   if (sz < 2)  mDrawWdg->SelMarker(sz, PI_DotMarker);
    109   else mDrawWdg->SelMarker(sz, PI_FCircleMarker);
    110   mDrawWdg->ScDrawMarker((double)xp,(double)yp );
     105  if (sz < 2)  mDrawer->SelMarker(sz, PI_DotMarker);
     106  else mDrawer->SelMarker(sz, PI_FCircleMarker);
     107  mDrawer->DrawMarker((double)xp,(double)yp );
    111108  if (mDspFV) { 
    112109    sprintf(buff," F=%g", flx);
    113     mDrawWdg->Sc2Local(xp, yp, ixp, iyp);
    114     mDrawWdg->DrawString( ixp+sz/2+1, iyp-4, buff);
     110    mDrawer->Sc2Local(xp, yp, ixp, iyp);
     111    mDrawer->DrawString( ixp+sz/2+1, iyp-4, buff);
    115112    }
    116113  }
     114
     115if (!MainScDrawer()) return;
     116if (!mDrawWdg)  return;
    117117
    118118sprintf(buff, "StarList:  NbStars= %d  NDisp= %d", (int)mStL->NbStars(), nok);
     
    123123}
    124124
    125 
    126 /* --Methode-- */
    127 void PIStarList::Refresh()
    128 {
    129   if (!mDrawWdg) return;
    130   mDrawWdg->FreeLimits();
    131   UpdateSize();
    132   mDrawWdg->Refresh();
    133 }
  • trunk/SophyaPI/PI/pistlist.h

    r37 r52  
    22#define PISTLIST_H
    33
    4 
     4#include "stlist.h"
    55#include "piscdrawwdg.h"
    6 #include "stlist.h"
    76
    87class PIStarList : public PIScDrawer {
    98public:
    10                      PIStarList(StarList* stl, bool ayud=true);
     9                     PIStarList(StarList* stl, bool ad, int ayud=kAxeDirUpDown);
    1110  virtual           ~PIStarList();
    1211 
    13   virtual void       Draw();
    14   virtual void       Refresh();  // Recalcule les limites, et reaffiche
     12  virtual void       Draw(double xmin, double ymin, double xmax, double ymax);
     13  virtual void       UpdateSize();
    1514 
    16   inline  void       SetAutoDelStList(bool ad=false)   { mAdelStl = ad; }
    1715  void               SetFluxLimits(float min=1., float max=-1., int nl=5,
    1816                                   int msz0=0, bool refr=false);
     
    3028protected:
    3129  StarList* mStL;
    32   bool   mAdelStl;
    3330  float mFmin, mFmax;
    3431  int mNLev, mMSz0;
     
    3734  float mYMin, mYMax;
    3835  bool mDspFV;
    39   bool mAYdir;
     36  int mAYdir;
    4037
    41   virtual void       AttachTo(PIScDrawWdg*);
    42   virtual void       UpdateSize();
    4338};
    4439
  • trunk/SophyaPI/PI/piwdggen.h

    r48 r52  
    6060  virtual void           GetScreenPos(int & spx, int & spy);
    6161
     62  virtual void           Manage()=0;
     63  virtual void           UnManage()=0;
     64  virtual int            IfManaged()=0;
     65
    6266  virtual void           PSPrint(PSFile *psf, int ofx=0, int ofy=0);
    6367
  • trunk/SophyaPI/PI/piwdgx.cc

    r41 r52  
    1111#include <Xm/Xm.h>       // A cause des container XmForm
    1212#include <Xm/Form.h>     // Idem
    13 
    1413
    1514#include "piwdgx.h"
     
    188187
    189188/* --Methode-- */
    190 void PIWdgX::Unmanage()
    191 {
    192 #ifdef DEBUG_PIWdgX
    193 printf("Debug_PIWdgX::Unmanage  this=%lx sdw=%lx \n", (long)this, (long)sdw);
     189void PIWdgX::UnManage()
     190{
     191#ifdef DEBUG_PIWdgX
     192printf("Debug_PIWdgX::UnManage  this=%lx sdw=%lx \n", (long)this, (long)sdw);
    194193#endif
    195194if (!sdw)  return;
  • trunk/SophyaPI/PI/piwdgx.h

    r37 r52  
    55#define PIWDG_X_SEEN
    66
    7 #include <string>
    8 
    97#include <X11/Xlib.h>
    108#include <X11/Intrinsic.h>
    119
    12 #include "piwdggen.h"
    1310#include "piwdggen.h"
    1411
     
    5350  virtual void   GetScreenPos(int & spx, int & spy);
    5451
    55   void Manage();
    56   void Unmanage();
    57   int  IfManaged();
     52  virtual void  Manage();
     53  virtual void   UnManage();
     54  virtual int    IfManaged();
    5855
    5956  inline SysDWdg XtWdg() const {return(sdw); };
     
    7774Display * PIXDisplay();
    7875#define  PIXScreen()  DefaultScreen(PIXDisplay())
     76Time PIXGetLastEventTime();
     77unsigned long PIXGetLastEventSerial();
    7978
    8079#endif/* PIWDGX_SEEN */
  • trunk/SophyaPI/PI/piwindowx.cc

    r41 r52  
    130130
    131131PIContainerGen::Show();
    132 Manage();
     132// Manage();  $CHECK$ Ca ne doit plus etre necessaire Reza 9/7/97
    133133if (!XtIsRealized(pwm->XtWdg()))  fgr = 1;
    134134pwm->Manage();
     
    143143  else
    144144    XSetTransientForHint(mdsp, XtWindow(PIXtTopWdg()), XtWindow(pwm->XtWdg()));
     145  //  Pour faire les actions sur les fenetres X, sinon fenetre pas cree
     146  int k;
     147  for(k=0; k<mNCh; k++)  mChilds[k]->FinishCreate();
    145148  }
    146149
     
    156159{
    157160PIWindowGen::Hide();
    158 Unmanage();
    159 pwm->Unmanage();
     161// UnManage();  $CHECK$ Ca ne doit plus etre necessaire Reza 9/7/97
     162pwm->UnManage();
    160163}
    161164
  • trunk/SophyaPI/PI/pixtbase.cc

    r41 r52  
    110110
    111111
     112static Time last_time_xevt = 0;
     113static unsigned long last_serial_xevt = 0;
     114
     115Time PIXGetLastEventTime() { return(last_time_xevt); }
     116unsigned long PIXGetLastEventSerial() { return(last_serial_xevt); }
     117
    112118/* Nouvelle-Fonction */
    113119static void init_class_pixtbase()
     
    174180
    175181/* Nouvelle-Fonction */
    176 static void enter_pixtbase (Widget wdgp, XEvent* /*evt*/,
     182static void enter_pixtbase (Widget wdgp, XEvent* evt,
    177183                            String* /*args*/, Cardinal* /*narg*/)
    178184{
     185last_time_xevt = evt->xcrossing.time;
     186last_serial_xevt = evt->xcrossing.serial;
    179187if (((PIXtBaseWidget)wdgp)->pixtbase.objet)
    180188   (((PIXtBaseWidget)wdgp)->pixtbase.objet)->Enter();
     
    183191
    184192/* Nouvelle-Fonction */
    185 static void leave_pixtbase (Widget wdgp, XEvent* /*evt*/,
     193static void leave_pixtbase (Widget wdgp, XEvent* evt,
    186194                            String* /*args*/, Cardinal* /*narg*/)
    187195{
     196last_time_xevt = evt->xcrossing.time;
     197last_serial_xevt = evt->xcrossing.serial;
    188198if (((PIXtBaseWidget)wdgp)->pixtbase.objet)
    189199   (((PIXtBaseWidget)wdgp)->pixtbase.objet)->Leave();
     
    196206
    197207{
     208last_time_xevt = evt->xbutton.time;
     209last_serial_xevt = evt->xbutton.serial;
    198210if (((PIXtBaseWidget)wdgp)->pixtbase.objet)
    199211  {
     
    211223
    212224{
     225last_time_xevt = evt->xbutton.time;
     226last_serial_xevt = evt->xbutton.serial;
    213227if (((PIXtBaseWidget)wdgp)->pixtbase.objet)
    214228  {
     
    225239
    226240{
     241last_time_xevt = evt->xbutton.time;
     242last_serial_xevt = evt->xbutton.serial;
    227243if (((PIXtBaseWidget)wdgp)->pixtbase.objet)
    228244  {
     
    239255                           String* /*args*/, Cardinal* /*narg*/)
    240256{
     257last_time_xevt = evt->xbutton.time;
     258last_serial_xevt = evt->xbutton.serial;
    241259if (((PIXtBaseWidget)wdgp)->pixtbase.objet)
    242260  {
     
    255273
    256274{
     275last_time_xevt = evt->xbutton.time;
     276last_serial_xevt = evt->xbutton.serial;
    257277if (((PIXtBaseWidget)wdgp)->pixtbase.objet)
    258278  {
     
    270290
    271291{
     292last_time_xevt = evt->xbutton.time;
     293last_serial_xevt = evt->xbutton.serial;
    272294if (((PIXtBaseWidget)wdgp)->pixtbase.objet)
    273295  {
     
    284306                           String* /*args*/, Cardinal* /*narg*/)
    285307{
     308last_time_xevt = evt->xbutton.time;
     309last_serial_xevt = evt->xbutton.serial;
    286310if (((PIXtBaseWidget)wdgp)->pixtbase.objet) 
    287311  {
     
    298322                           String* /*args*/, Cardinal* /*narg*/)
    299323{
     324last_time_xevt = evt->xbutton.time;
     325last_serial_xevt = evt->xbutton.serial;
    300326if (((PIXtBaseWidget)wdgp)->pixtbase.objet) 
    301327  {
     
    312338                           String* /*args*/, Cardinal* /*narg*/)
    313339{
     340last_time_xevt = evt->xbutton.time;
     341last_serial_xevt = evt->xbutton.serial;
    314342if (((PIXtBaseWidget)wdgp)->pixtbase.objet) 
    315343  {
     
    326354                           String* /*args*/, Cardinal* /*narg*/)
    327355{
     356last_time_xevt = evt->xkey.time;
     357last_serial_xevt = evt->xkey.serial;
    328358if (((PIXtBaseWidget)wdgp)->pixtbase.objet) 
    329359  {
  • trunk/SophyaPI/PI/sc_sample.cc

    r15 r52  
    2929int i;
    3030SelForeground(PI_Green);
    31 ScSelMarker(0.3, PI_BoxMarker);
    32 ScDrawMarkers(x, y, 5);
     31BaseDrawer()->SelMarker(0.3, PI_BoxMarker);
     32BaseDrawer()->DrawMarkers(x, y, 5);
    3333SelForeground(PI_Magenta);
    34 ScSelMarker(0.3, PI_FCircleMarker);
     34BaseDrawer()->SelMarker(0.3, PI_FCircleMarker);
    3535for(i=0; i<5; i++)
    3636   y[i]+=1.;
    37 ScDrawMarkers(x, y, 5);
     37BaseDrawer()->DrawMarkers(x, y, 5);
    3838SelForeground(PI_Black);
    3939
    40 ScDrawLine(-4, -4, 4, 4);
    41 ScDrawLine(-2, -5, 5, 2);
    42 ScDrawLine(-5, -4, -2, -2);
    43 ScDrawLine(1, -10, 1, 10);
     40BaseDrawer()->DrawLine(-4, -4, 4, 4);
     41BaseDrawer()->DrawLine(-2, -5, 5, 2);
     42BaseDrawer()->DrawLine(-5, -4, -2, -2);
     43BaseDrawer()->DrawLine(1, -10, 1, 10);
    4444return; 
    4545}
Note: See TracChangeset for help on using the changeset viewer.