Changeset 107 in Sophya for trunk/SophyaPI


Ignore:
Timestamp:
May 22, 1998, 6:04:01 PM (27 years ago)
Author:
ansari
Message:

Suppression des PIScDrawer / remplacement par des PIDrawer Reza 22/05/98

Location:
trunk/SophyaPI/PI
Files:
20 edited

Legend:

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

    r88 r107  
    1616mWGrC = NULL;   // PIGraphic (Contexte graphique) associe a la fenetre}
    1717                // Doit etre cree par PIBaseWdgX/Mac/...
     18SetDefaultDrawRectangle(0., 0., 1., 1., true);
     19SetDefaultDrawerLimits(0., 1., 0., 1., kAxeDirLtoR, kAxeDirUpDown);
    1820}
    1921
     
    3638}
    3739
     40// On met une variable pour eviter des boucles infinies entre les deux methodes
     41// Draw(PIGraphic* g, int, int, int, int) et Draw(PIGraphic* g)
     42static int fgdrawloop = 0;
     43
    3844/* --Methode-- */
    3945void PIBaseWdgGen::Draw(PIGraphic* g, int /*x0*/, int /*y0*/, int /*dx*/, int /*dy*/)
    4046{
    41 this->Draw(g);
     47if (fgdrawloop == 0)
     48  { fgdrawloop=1;  Draw(g); }
     49fgdrawloop = 0;
    4250return;
    4351}
     
    4957puts("Debug_PIBaseWdgGen::Draw() Efface la fenetre par defaut ! ");
    5058#endif
    51 this->EraseWindow();
     59if (fgdrawloop == 0)
     60  { fgdrawloop=2;  Draw(g, 0, 0, XSize(), YSize()); }
     61fgdrawloop = 0;
    5262return;
    5363}
     
    169179}
    170180
    171 
    172 /* --Methode-- */
    173 int PIBaseWdgGen::AddDrawer(PIDrawer* drw, int x0, int y0, int dx, int dy, bool ad)
     181/* --Methode-- */
     182void PIBaseWdgGen::SetDefaultDrawRectangle(PIGrCoord x1, PIGrCoord y1, PIGrCoord x2, PIGrCoord y2, bool psz)
     183{
     184mDrX1 = x1;  mDrY1 = y1;
     185mDrX2 = x2;  mDrY2 = y2;   mDrElastic = psz;
     186}
     187
     188/* --Methode-- */
     189void PIBaseWdgGen::SetDefaultDrawerLimits(float xmin, float xmax, float ymin, float ymax,
     190                                          int axrl, int ayud)
     191{
     192mDrXmin = xmin;   mDrXmax = xmax;
     193mDrYmin = ymin;   mDrYmax = ymax;
     194mDXdir = axrl;    mDYdir = ayud;
     195}
     196
     197
     198/* --Methode-- */
     199int PIBaseWdgGen::AddDrawer(PIDrawer* drw, PIGrCoord x1, PIGrCoord y1, 
     200                            PIGrCoord x2, PIGrCoord y2, bool psz, bool ad)
    174201{
    175202if (drw == NULL)   return(0);
    176203mDrwId++;
    177204BWDrwId did;
    178 did.x0 = x0;  did.y0 = y0;
    179 did.dx = dx;  did.dy = dy;
     205did.x1 = x1;  did.y1 = y1;
     206did.x2 = x2;  did.y2 = y2;
     207did.autoszp = did.autolim = false;   did.elastic = psz;
    180208did.id = mDrwId;  did.ad = ad;
    181209did.drw = drw;
     
    186214
    187215/* --Methode-- */
    188 void PIBaseWdgGen::MoveResizeDrawer(int id, int x0, int y0, int dx, int dy)
    189 {
    190 list<BWDrwId>::iterator it;
     216int PIBaseWdgGen::AddDrawer(PIDrawer* drw, bool autolim, bool ad)
     217{
     218if (drw == NULL)   return(0);
     219mDrwId++;
     220BWDrwId did;
     221did.x1 = 0.;  did.y1 = 0.;
     222did.x2 = 1.;  did.y2 = 1.;
     223did.autoszp = true;   did.autolim = autolim;   did.elastic = false;
     224did.id = mDrwId;  did.ad = ad;
     225did.drw = drw;
     226mDrwList.push_back(did);
     227drw->Attach(this, mDrwId);
     228return(mDrwId);
     229}
     230
     231
     232/* --Methode-- */
     233void PIBaseWdgGen::MoveResizeDrawer(int id,  PIGrCoord x1, PIGrCoord y1,  PIGrCoord x2, PIGrCoord y2, bool psz)
     234{
     235vector<BWDrwId>::iterator it;
    191236for(it = mDrwList.begin(); it != mDrwList.end(); it++) 
    192237  if ((*it).id == id) {
    193     (*it).x0 = x0;  (*it).y0 = y0;
    194     (*it).dx = dx;  (*it).dy = dy;
     238    (*it).x1 = x1;  (*it).y1 = y1;
     239    (*it).x2 = x2;  (*it).y2 = y2;
     240    (*it).elastic = psz;
    195241    break;
    196242  }
     
    202248{
    203249if (mAdfg)  return;
    204 list<BWDrwId>::iterator it;
     250vector<BWDrwId>::iterator it;
    205251for(it = mDrwList.begin(); it != mDrwList.end(); it++)
    206252  if ((*it).id == id)
     
    213259{
    214260mAdfg = true;
    215 list<BWDrwId>::iterator it;
     261vector<BWDrwId>::iterator it;
    216262for(it = mDrwList.begin(); it != mDrwList.end(); it++) 
    217263  if ((*it).ad)  delete (*it).drw;
     
    221267}
    222268
     269/* --Methode-- */
     270int PIBaseWdgGen::NbDrawers()
     271{
     272return(mDrwList.size());
     273}
     274
     275
     276/* --Methode-- */
     277PIDrawer* PIBaseWdgGen::GetDrawer(int n)
     278{
     279if ( (n < 0) || (n >= mDrwList.size()) ) return(NULL);
     280return(mDrwList[n].drw);
     281}
     282
     283/* --Methode-- */
     284PIDrawer* PIBaseWdgGen::GetDrawerId(int id)
     285{
     286vector<BWDrwId>::iterator it;
     287for(it = mDrwList.begin(); it != mDrwList.end(); it++) 
     288  if ((*it).id == id)  return((*it).drw);
     289return(NULL);
     290}
     291
    223292
    224293/* --Methode-- */
     
    227296float xmin,ymin, xmax, ymax;
    228297PIGraphicUC* guc;
     298int drx0, dry0, drdx, drdy;
     299int ddrx0, ddry0, ddrdx, ddrdy;
     300
     301if (mDrElastic) {
     302  ddrx0 = (int)((float) mDrX1 * (float)XSize());
     303  ddry0 = (int)((float) mDrY1 * (float)YSize());
     304  ddrdx = (int)((float) mDrX2 * (float)XSize()) - ddrx0 ;
     305  ddrdy = (int)((float) mDrY2 * (float)YSize()) - ddry0 ;
     306  }
     307else {
     308  ddrx0 = (int)mDrX1;   ddry0 = (int)mDrY1; 
     309  ddrdx = (int)mDrX2-ddrx0;   ddrdy = (int)mDrY2-ddry0; 
     310  }
    229311
    230312bool sxy = false;
    231313if ((dx > 0) && (dy > 0))  sxy = true;
    232314
    233 list<BWDrwId>::iterator it;
     315vector<BWDrwId>::iterator it;
    234316bool fgc=false;
    235317for(it = mDrwList.begin(); it != mDrwList.end(); it++) {
    236318  g->SaveGraphicAtt();
    237   guc = (*it).drw->SetDrwWdg(this, (*it).x0, (*it).y0, (*it).dx, (*it).dy, g);
    238   g->SetClipRectangle((*it).x0, (*it).y0, (*it).dx , (*it).dy);
     319  if ( (*it).autoszp )   // Taille/position  par defaut impose par PIBaseWdg
     320    { drx0 = ddrx0;  dry0 = ddry0;   drdx = ddrdx;  drdy = ddrdy; }
     321  else {
     322    if ( (*it).elastic  ) {   // Taille/position defin en fraction de la taille du PIBaseWdg
     323      drx0 = (int)((float)(*it).x1 * (float)XSize());
     324      dry0 = (int)((float)(*it).y1 * (float)YSize());
     325      drdx = (int)((float)(*it).x2 * (float)XSize()) - drx0 ;
     326      drdy = (int)((float)(*it).y2 * (float)YSize()) - dry0 ;
     327      }
     328    else {
     329      drx0 = (int)(*it).x1 ;  dry0 = (int)(*it).y1 ;
     330      drdx = (int)(*it).x2-drx0 ;  drdy = (int)(*it).y2-dry0 ;
     331      }
     332    }
     333// L'ordre des operations ici est importante
     334  if ( (*it).autolim ) 
     335     (*it).drw->SetLimits(mDrXmin, mDrXmax, mDrYmin, mDrYmax, mDXdir, mDYdir);
     336  guc = (*it).drw->SetDrwWdg(this, drx0, dry0, drdx, drdy, g);
     337  g->SetClipRectangle(drx0, dry0, drdx , drdy);
     338  (*it).drw->SelGraAtt(guc);
    239339  fgc = true;
    240340  if (sxy) {
    241341    guc->GrC2UC(x0, y0, xmin, ymin);
    242342    guc->GrC2UC(x0+dx, y0+dy, xmax, ymax);
     343    }
     344  else {
     345    guc->GrC2UC(0, 0, xmin, ymin);
     346    guc->GrC2UC(XSize(), YSize(), xmax, ymax);   
     347    }
     348  if (xmin > xmax)  swap(xmin,xmax);
     349  if (ymin > ymax)  swap(ymin,ymax);
     350  (*it).drw->Draw(guc, xmin, ymin, xmax, ymax);
     351  g->RestoreGraphicAtt();
     352  }
     353if (fgc)  g->ClearClipRectangle();
     354
     355return;
     356}
     357
     358/* --Methode-- */
     359void PIBaseWdgGen::CallDrawer(int id)
     360{
     361float xmin,ymin, xmax, ymax;
     362PIGraphicUC* guc;
     363int drx0, dry0, drdx, drdy;
     364int ddrx0, ddry0, ddrdx, ddrdy;
     365
     366PIGraphic* g = WindowGraphic();
     367
     368if (mDrElastic) {
     369  ddrx0 = (int)((float) mDrX1 * (float)XSize());
     370  ddry0 = (int)((float) mDrY1 * (float)YSize());
     371  ddrdx = (int)((float) mDrX2 * (float)XSize()) - ddrx0 ;
     372  ddrdy = (int)((float) mDrY2 * (float)YSize()) - ddry0 ;
     373  }
     374else {
     375  ddrx0 = (int)mDrX1;   ddry0 = (int)mDrY1; 
     376  ddrdx = (int)mDrX2-ddrx0;   ddrdy = (int)mDrY2-ddry0; 
     377  }
     378vector<BWDrwId>::iterator it;
     379for(it = mDrwList.begin(); it != mDrwList.end(); it++)
     380  if ((*it).id == id) {
     381    g->SaveGraphicAtt();
     382    if ( (*it).autoszp )   // Taille/position  par defaut impose par PIBaseWdg
     383      { drx0 = ddrx0;  dry0 = ddry0;   drdx = ddrdx;  drdy = ddrdy; }
     384    else {
     385      if ( (*it).elastic  ) {   // Taille/position defin en fraction de la taille du PIBaseWdg
     386        drx0 = (int)((float)(*it).x1 * (float)XSize());
     387        dry0 = (int)((float)(*it).y1 * (float)YSize());
     388        drdx = (int)((float)(*it).x2 * (float)XSize()) - drx0 ;
     389        drdy = (int)((float)(*it).y2 * (float)YSize()) - dry0 ;
     390        }
     391      else {
     392        drx0 = (int)(*it).x1 ;  dry0 = (int)(*it).y1 ;
     393        drdx = (int)(*it).x2-drx0 ;  drdy = (int)(*it).y2-dry0 ;
     394        }
     395      }
     396// L'ordre des operations ici est importante
     397    if ( (*it).autolim ) 
     398       (*it).drw->SetLimits(mDrXmin, mDrXmax, mDrYmin, mDrYmax, mDXdir, mDYdir);
     399    guc = (*it).drw->SetDrwWdg(this, drx0, dry0, drdx, drdy, g);
     400    g->SetClipRectangle(drx0, dry0, drdx , drdy);
     401    (*it).drw->SelGraAtt(guc);
     402    guc->GrC2UC(0, 0, xmin, ymin);
     403    guc->GrC2UC(XSize(), YSize(), xmax, ymax);     
    243404    if (xmin > xmax)  swap(xmin,xmax);
    244405    if (ymin > ymax)  swap(ymin,ymax);
    245406    (*it).drw->Draw(guc, xmin, ymin, xmax, ymax);
    246   }
    247   else (*it).drw->Draw(guc);
    248   g->RestoreGraphicAtt();
    249   }
    250 if (fgc)  g->ClearClipRectangle();
    251 
    252 return;
    253 }
    254 
    255 /* --Methode-- */
    256 void PIBaseWdgGen::CallDrawer(PIGraphicGen* g, int id)
    257 {
    258 PIGraphicUC* guc;
    259 list<BWDrwId>::iterator it;
    260 for(it = mDrwList.begin(); it != mDrwList.end(); it++)
    261   if ((*it).id == id) {
    262     g->SaveGraphicAtt();
    263     guc = (*it).drw->SetDrwWdg(this, (*it).x0, (*it).y0, (*it).dx, (*it).dy, g);
    264     g->SetClipRectangle((*it).x0, (*it).y0, (*it).dx , (*it).dy);
    265     (*it).drw->Draw(guc);
    266407    g->RestoreGraphicAtt();   
    267408    g->ClearClipRectangle();
  • trunk/SophyaPI/PI/pibwdggen.h

    r90 r107  
    77#include PICMAP_H
    88#include PIGRAPHIC_H
     9#include "pigraphuc.h"
    910#include "psfile.h"
    1011
    1112// Mettre dans cet ordre, sinon g++ a des problemes   
    12 #include <list>   
     13#include <vector>   
    1314
    1415enum PIKeyModifier { PIKM_Blank = 0, PIKM_Shift = 1, PIKM_Alt = 2, PIKM_Cntl = 4 } ;
     
    7879  virtual void       PSPrint(PSFile* psf, int ofx = 0, int ofy = 0);
    7980
    80 // Gestion des Drawers
     81// ------ Gestion des Drawers  ------
    8182  friend class PIDrawer;
    82           int        AddDrawer(PIDrawer* drw, int x0, int y0, int dx, int dy,
    83                                bool ad=false);
    84           void       MoveResizeDrawer(int id, int x0, int y0, int dx, int dy);
     83          void       SetDefaultDrawRectangle(PIGrCoord x1, PIGrCoord y1,
     84                                             PIGrCoord x2, PIGrCoord y2, bool psz=true);
     85          void       SetDefaultDrawerLimits(float xmin, float xmax, float ymin, float ymax,
     86                                            int axrl=kAxeDirSame, int ayud=kAxeDirSame);
     87          int        AddDrawer(PIDrawer* drw, PIGrCoord x1, PIGrCoord y1,
     88                               PIGrCoord x2, PIGrCoord y2,
     89                               bool psz=true, bool ad=false);
     90          int        AddDrawer(PIDrawer* drw, bool autolim=false, bool ad=false);
     91          void       MoveResizeDrawer(int id, PIGrCoord x1, PIGrCoord y1,
     92                                      PIGrCoord x2, PIGrCoord y2, bool psz=true);
    8593          void       RemoveDrawer(int id);       // Ote un drawer de la liste
    8694          void       DeleteDrawers();            // Ote et detruit tous les drawers
     95// Acces aux drawers
     96          int        NbDrawers();
     97          PIDrawer*  GetDrawerId(int id);   
     98          PIDrawer*  GetDrawer(int n);   
    8799
    88100//  Trace des Drawers ...         
    89101  virtual void       CallDrawers(PIGraphicGen* g, int x0=0, int y0=0, int dx=0, int dy=0);
    90   virtual void       CallDrawer(PIGraphicGen* g, int id);
     102  virtual void       CallDrawer(int id);
    91103
    92104// Devrait etre protected - mis ici a cause de cxx  11/07/97  Reza
    93   struct BWDrwId { int x0, y0; int dx, dy; int id; bool ad; PIDrawer* drw; };
     105  struct BWDrwId { int id; PIGrCoord x1, y1, x2, y2; bool autoszp, autolim, elastic, ad; PIDrawer* drw; };
    94106
    95107  virtual PIGraphic*  WindowGraphic();
    96108
     109// -------------- Variables membre protegees -------------------
    97110protected:
    98111  PIGraphicWin* mWGrC;  // PIGraphic (Contexte graphique) associe a la fenetre
    99   bool mAdfg;
    100   int mDrwId;
    101   list<BWDrwId> mDrwList;
     112  bool mAdfg;           // Pour la gestion de DeleteDrawers() quand appele par delete de PIBaseWdg
     113  int mDrwId;           // Compteur pour DrawerId
     114  vector<BWDrwId> mDrwList;
     115//  Definition de la zone de trace et limites UC des drawers par defaut 
     116  PIGrCoord mDrX1, mDrY1,  mDrX2,  mDrY2; 
     117  bool mDrElastic;   // true --> Coord en fraction de la taille
     118  float mDrXmin, mDrXmax, mDrYmin, mDrYmax;   // Limites par defaut - UC
     119  int  mDXdir, mDYdir;                        // Sens des axes par defaut
    102120
    103121};
  • trunk/SophyaPI/PI/pidrawer.cc

    r72 r107  
    1313  SetAxesFlags(kAxesDflt);
    1414  mDndfg = false;  // Pour controle de l'appel de Detach() si delete
     15
     16  mFCol = mBCol = PI_NotDefColor;
     17  mLAtt = PI_NotDefLineAtt;
     18  mFSz = PI_NotDefFontSize;
     19  mFAtt = PI_NotDefFontAtt;
     20  mMSz = -1;
     21  mMrk = PI_NotDefMarker;
    1522}
    1623
     
    4451}
    4552
     53
     54void
     55PIDrawer::UpdateSize()
     56{
     57// Ne fait rien !
     58  return;
     59}
     60
     61void
     62PIDrawer::Refresh()
     63{
     64  list<DrwBWId>::iterator it;
     65  for(it = mBWdgList.begin(); it != mBWdgList.end(); it++)
     66         (*it).wdg->CallDrawer((*it).id);
     67
     68}
     69
     70void
     71PIDrawer::SetColAtt(PIColors fg, PIColors bg)
     72{
     73  if (fg != PI_NotDefColor) mFCol = fg;
     74  if (bg != PI_NotDefColor) mBCol = bg;
     75}
     76
     77void
     78PIDrawer::SetLineAtt(PILineAtt lat)
     79{
     80  if (lat != PI_NotDefLineAtt) mLAtt = lat;
     81}
     82
     83void
     84PIDrawer::SetFontAtt(PIFontSize fsz, PIFontAtt fat)
     85{
     86  if (fsz != PI_NotDefFontSize) mFSz = fsz;
     87  if (fat != PI_NotDefFontAtt) mFAtt = fat;
     88}
     89
     90void
     91PIDrawer::SetMarkerAtt(int sz, PIMarker mrk)
     92{
     93  if (sz >= 0)  mMSz = sz;
     94  if (mrk != PI_NotDefMarker) mMrk = mrk;
     95}
     96
     97void
     98PIDrawer::SelGraAtt(PIGraphicUC* g)
     99{
     100  if (mFCol != PI_NotDefColor)    g->SelForeground(mFCol);
     101  if (mBCol != PI_NotDefColor)    g->SelBackground(mBCol);
     102  if (mLAtt != PI_NotDefLineAtt)  g->SelLine(mLAtt);
     103  if ( (mFSz != PI_NotDefFontSize) || (mFAtt != PI_NotDefFontAtt) )
     104                                  g->SelFont(mFSz, mFAtt);
     105  if ( (mMrk != PI_NotDefMarker) || (mMSz >= 0) )
     106                                  g->SelMarker(mMSz, mMrk);
     107}
    46108
    47109void
     
    234296
    235297 
    236 void
    237 PIDrawer::Draw(PIGraphicUC*)
    238 {
    239 }
    240298
    241299void
    242300PIDrawer::Draw(PIGraphicUC* g, float /*xmin*/, float /*ymin*/, float /*xmax*/, float /*ymax*/)
    243301{
    244 Draw(g);
    245302}
    246303
  • trunk/SophyaPI/PI/pidrawer.h

    r71 r107  
    3030  virtual void       SetAxesFlags(int flags=kAxesDflt);
    3131   
    32   virtual void       Draw(PIGraphicUC* g);
    33   virtual void       Draw(PIGraphicUC* g, float xmin, float ymin, float xmax, float ymax);   
     32  virtual void       Draw(PIGraphicUC* g, float xmin, float ymin, float xmax, float ymax);
     33   
     34  virtual void       Refresh();      // Recalcule les limites et reaffiche
     35  virtual void       UpdateSize();   // Calcule et change les limites si non fixees
    3436
    3537  float XMin() const {return xMin;}
     
    4244  int    LimitsFixed() const {return limitsFixed;}
    4345  void   FreeLimits() {limitsFixed = 0;}
     46
     47  void               SetColAtt(PIColors fg=PI_NotDefColor,
     48                               PIColors bg=PI_NotDefColor);
     49  void               SetLineAtt(PILineAtt lat=PI_NotDefLineAtt);
     50  void               SetFontAtt(PIFontSize fsz=PI_NotDefFontSize,
     51                                PIFontAtt fat=PI_NotDefFontAtt);
     52  void               SetMarkerAtt(int sz=-1, PIMarker mrk=PI_NotDefMarker);
     53
     54  void               SelGraAtt(PIGraphicUC* g);
    4455
    4556//  Les objets/methodes suivants devraient etre protected     
     
    8394  list<DrwBWId>  mBWdgList;
    8495  bool mDndfg;
     96
     97//  Gestion d attributs graphiques associes a chaque drawer
     98  PIColors           mFCol, mBCol;
     99  PILineAtt          mLAtt;
     100  PIFontSize         mFSz;
     101  PIFontAtt          mFAtt;
     102  int                mMSz;
     103  PIMarker           mMrk;     
    85104 
    86105};
  • trunk/SophyaPI/PI/pidrawwin.cc

    r52 r107  
    1616
    1717void
    18 PIDrawWindow::AddScDrawer(PIScDrawer* d, bool ad)
     18PIDrawWindow::AddScDrawer(PIDrawer* d, bool ad)
    1919{
    2020  mDrawWdg->AddScDrawer(d, ad);
  • trunk/SophyaPI/PI/pidrawwin.h

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

    r71 r107  
    33
    44PIHisto::PIHisto(Histo* histo, bool ad)
    5 : PIScDrawer(), mHisto(histo)
     5: PIDrawer(), mHisto(histo)
    66{
    77  mAdDO = ad;     // Flag pour suppression automatique de mHisto
     
    1919PIHisto::UpdateSize()
    2020{
    21   if (!mDrawer) return;
    22   if (mDrawer->LimitsFixed()) return;
    23   // Commencer par trouver nos limites
    24  
    25   float xmin = mHisto->XMin();
    26   float xmax = (mHisto->XMax());
    27 
    28   float ymax = mHisto->VMax()*1.2;
    29   float ymin = mHisto->VMin();
    30  
    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);
     21  if (!mHisto)  return; 
     22  SetLimits(mHisto->XMin(), mHisto->XMax(), mHisto->VMin(), mHisto->VMax()*1.2);
     23  SetAxesFlags(kBoxAxes | kExtTicks | kLabels);
    3724}
    3825
     
    4128PIHisto::Draw(PIGraphicUC* g, float /*xmin*/, float /*ymin*/, float /*xmax*/, float /*ymax*/)
    4229{
     30  if (!mHisto)  return; 
    4331  for (int i=0; i<mHisto->NBins(); i++) {
    4432                float left   = mHisto->BinLowEdge(i);
     
    5543PIHisto::DrawStats(PIGraphicUC* g)
    5644{
    57   if (!mDrawWdg) return;
    58   // Une boite dans le coin superieur droit
    59   float cellHeight = (mDrawWdg->YMax() - mDrawWdg->YMin()) * 0.05;
    60   float cellWidth  = (mDrawWdg->XMax() - mDrawWdg->XMin()) * 0.23;
    61   g->DrawLine(mDrawWdg->XMax() - cellWidth, mDrawWdg->YMax(),
    62                        mDrawWdg->XMax() - cellWidth, mDrawWdg->YMax() - cellHeight);
    63   g->DrawLine(mDrawWdg->XMax() - cellWidth, mDrawWdg->YMax() - cellHeight,
    64                        mDrawWdg->XMax()            , mDrawWdg->YMax() - cellHeight);
     45  if (!mHisto) return;
     46  float cellHeight = (YMax() - YMin()) * 0.05;
     47  float cellWidth  = (XMax() - XMin()) * 0.23;
     48  g->DrawLine(XMax() - cellWidth, YMax(),
     49                       XMax() - cellWidth, YMax() - cellHeight);
     50  g->DrawLine(XMax() - cellWidth, YMax() - cellHeight,
     51                       XMax()            , YMax() - cellHeight);
    6552  char label[50];
    6653  sprintf(label, "N = %.6g", mHisto->NData());
    67   g->SelFontSz((mDrawWdg->YMax() - mDrawWdg->YMin())/30);
    68   g->DrawString(mDrawWdg->XMax() - cellWidth*0.9, mDrawWdg->YMax() - cellHeight*0.8, label);
     54  g->SelFontSz((YMax() - YMin())/30);
     55  g->DrawString(XMax() - cellWidth*0.9, YMax() - cellHeight*0.8, label);
    6956                       
    7057}
  • trunk/SophyaPI/PI/pihisto.h

    r71 r107  
    33
    44#include "histos.h"
    5 #include "piscdrawwdg.h"
     5#include "pidrawer.h"
    66
    7 class PIHisto : public PIScDrawer {
     7class PIHisto : public PIDrawer {
    88public:
    99                     PIHisto(Histo* histo, bool ad=false);
     
    1616protected:
    1717  Histo* mHisto;
     18  bool mAdDO;
    1819};
    1920
  • trunk/SophyaPI/PI/pihisto2d.cc

    r87 r107  
    2222//      Createur d'une classe de dessin pour l'histogramme 2D histo.
    2323//--
    24 : PIScDrawer(), mHisto(histo)
     24: PIDrawer(), mHisto(histo)
    2525{
    2626mAdDO = ad;     // Flag pour suppression automatique de mHisto 
     
    150150//--
    151151{
    152   if (!mDrawer) return;
    153   if (mDrawer->LimitsFixed()) return;
    154152  if(!mHisto) return;
    155   // Commencer par trouver nos limites
    156  
    157   float xmin = mHisto->XMin();
    158   float xmax = mHisto->XMax();
    159 
    160   float ymax = mHisto->YMax();
    161   float ymin = mHisto->YMin();
    162  
    163   if (mDrawWdg)
    164     mDrawWdg->SetLimits(xmin, xmax, ymin, ymax);
    165   else
    166     mDrawer->SetLimits(xmin, xmax, ymin, ymax);
    167 
    168   mDrawer->SetAxesFlags(kBoxAxes | kExtTicks | kLabels);
     153  SetLimits(mHisto->XMin(), mHisto->XMax(), mHisto->YMin() , mHisto->YMax());
     154  SetAxesFlags(kBoxAxes | kExtTicks | kLabels);
    169155}
    170156
     
    291277//--
    292278{
    293   if (!mDrawWdg) return;
    294279  // Une boite dans le coin superieur droit
    295   float cellHeight = (mDrawWdg->YMax() - mDrawWdg->YMin()) * 0.05;
    296   float cellWidth  = (mDrawWdg->XMax() - mDrawWdg->XMin()) * 0.23;
    297   g->DrawLine(mDrawWdg->XMax() - cellWidth, mDrawWdg->YMax(),
    298                        mDrawWdg->XMax() - cellWidth, mDrawWdg->YMax() - cellHeight);
    299   g->DrawLine(mDrawWdg->XMax() - cellWidth, mDrawWdg->YMax() - cellHeight,
    300                        mDrawWdg->XMax()            , mDrawWdg->YMax() - cellHeight);
     280  float cellHeight = (YMax() - YMin()) * 0.05;
     281  float cellWidth  = (XMax() - XMin()) * 0.23;
     282  g->DrawLine(XMax() - cellWidth, YMax(),
     283                       XMax() - cellWidth, YMax() - cellHeight);
     284  g->DrawLine(XMax() - cellWidth, YMax() - cellHeight,
     285                       XMax()            , YMax() - cellHeight);
    301286  char label[50];
    302287  sprintf(label, "N = %.6g", mHisto->NData());
    303   g->SelFontSz((mDrawWdg->YMax() - mDrawWdg->YMin())/30);
    304   g->DrawString(mDrawWdg->XMax() - cellWidth*0.9, mDrawWdg->YMax() - cellHeight*0.8, label);
     288  g->SelFontSz((YMax() - YMin())/30);
     289  g->DrawString(XMax() - cellWidth*0.9, YMax() - cellHeight*0.8, label);
    305290  printf("H[%d,%d] Dynamique: [%g,%g] Frac [%g,%g]\n"
    306291        ,mHisto->NBinX(),mHisto->NBinY(),HMin(),HMax(),FMin(),FMax());
     
    679664  mpih->UseDyn(mHMin,mHMax);
    680665  mpih->UseFrac(mFracMin,mFracMax);
    681   mpih->Refresh();  // On rafraichit le dessin
     666  mH2Wdg->Refresh();  // On rafraichit le dessin (tout le PIScDrawWdg)
    682667}
    683668else if (opt==6002) {
  • trunk/SophyaPI/PI/pihisto2d.h

    r82 r107  
    1111
    1212////////////////////////////////////////////////////////////////////
    13 class PIHisto2D : public PIScDrawer {
     13class PIHisto2D : public PIDrawer {
    1414public:
    1515                     PIHisto2D(Histo2D* histo, bool ad=false);
     
    4242
    4343  Histo2D* mHisto;
     44  bool mAdDO;
    4445  bool mFgCol;
    4546  CMapId mCmap;
  • trunk/SophyaPI/PI/piimage.cc

    r106 r107  
    2525winovis = true;     // $CHECK$ Reza A enlever si possible 17/6/96
    2626
    27 admrk = true;
    28 xpmrk = ypmrk = NULL;   nbmrk = 0;
    29 mrkt = PI_PlusMarker;   mrkbsz = 3;
    3027
    3128zow = NULL;
     
    8279if (lut) delete lut;
    8380if (aisup)  delete img;   // Suppression automatique d'image
    84 if (admrk)
    85   {
    86   if (xpmrk)  delete xpmrk;
    87   if (ypmrk)  delete ypmrk;
    88   }
    8981if (trtw)  delete trtw;
    9082}
     
    10597
    10698/* --Methode-- */
    107 void PIImage::SetImage(P2DArrayAdapter *pim, bool refr)
     99void PIImage::SetImage(P2DArrayAdapter *pim, bool ad, bool refr)
    108100{
    109101
     
    117109zmgv = 1;
    118110
    119 if (img)
    120   {
     111if (img)  {
    121112//  SetSize(img->XSize(), img->YSize());
    122113  CenterPave();
     
    125116  img->CheckDyn(min, max, moy, sig, nbnul, nbsat);
    126117  SetLut(min, max, kLutType_Lin, 1, refr);
    127   }
    128 return;
    129 }
    130 
    131 /* --Methode-- */
    132 void PIImage::AddMarks(int nm, float* px, float* py, bool refr, bool ad, PIMarker mrk, int msz)
    133 {
    134 if ( (nbmrk > 0) && admrk ) {
    135   if (xpmrk)  delete xpmrk;
    136   if (ypmrk)  delete ypmrk;
    137 }
    138 if (nm <= 0) { nbmrk = 0; xpmrk = ypmrk = NULL; }
    139 else { nbmrk = nm;  xpmrk = px, ypmrk = py; }
    140 admrk = ad;  mrkt = mrk;  mrkbsz = msz;
    141 if (refr)  DrawMarks(mWGrC, 0, XSize(), 0, YSize());
    142 return;
    143 }
    144 
    145 /* --Methode-- */
    146 void PIImage::RemoveMarks(bool refr)
    147 {
    148 if (nbmrk < 1)  return;
    149 if (admrk ) {
    150   if (xpmrk)  delete xpmrk;
    151   if (ypmrk)  delete ypmrk;
    152 }
    153 nbmrk = 0; xpmrk = ypmrk = NULL;
    154 if (refr)  Refresh();
    155 }
     118  aisup = ad;
     119  }
     120else aisup = false;
     121return;
     122}
     123
    156124
    157125/* --Methode-- */
     
    173141return;
    174142}
    175 
    176143
    177144
     
    197164}
    198165
    199 
    200 /* --Methode-- */
    201 void PIImage::SetAutoDelImage(bool ad)
    202 {
    203 aisup = ad;
    204 return;
    205 }
    206 
    207166/* --Methode-- */
    208167void PIImage::ShowCursor(bool sc)
     
    380339  }
    381340
    382 DrawMarks(g, x0, x0+dx, y0, y0+dy);
    383341return;
    384342}
     
    689647}
    690648
    691 /* --Methode-- */
    692 void PIImage::DrawMarks(PIGraphicGen* g, int x1, int x2, int y1, int y2)
    693 {
    694 float fz;
    695 float tofx, tofy;
    696 int i,x,y;
    697 
    698 if ( (winovis || (nbmrk < 1) ) ) return;
    699 tofx = tofy = 0;
    700 if ( img ) { tofx = tofy = 0; }  /* img->XOrg(); tofy = img->YOrg(); $CHECK$  REZA 5/04/98 */ 
    701 tofx += offx;  tofy += offy;
    702 fz = GetZoomF();
    703 g->SelGOMode(PI_GOCopy);
    704 g->SelMarker((int)(fz*mrkbsz), mrkt);
    705 if ( (GetColMapId() == CMAP_GREY32) || (GetColMapId() == CMAP_GREYINV32) )
    706   g->SelForeground(PI_Red);
    707 else g->SelForeground(PI_White);
    708 for(i=0; i<nbmrk; i++)
    709   {
    710   x = (int) ((xpmrk[i]-tofx)*fz);
    711   y = (int) ((ypmrk[i]-tofy)*fz);
    712   if ((x < x1) || (x > x2) || (y < y1) || (y > y2))  continue;
    713   g->DrawMarker(x,y);
    714   }
    715 return;
    716 }
    717649
    718650/* --Methode-- */
  • trunk/SophyaPI/PI/piimage.h

    r104 r107  
    2929  virtual void    Process(PIMessage msg, PIMsgHandler* sender, void* data=NULL);
    3030
    31   void SetImage(P2DArrayAdapter* pim, bool refr=true);
    32   void SetAutoDelImage(bool ad = false);
    33 
    34   void AddMarks(int nm, float* px, float* py, bool refr=true,
    35                 bool ad=true, PIMarker mrk=PI_PlusMarker, int msz=3);
    36   void RemoveMarks(bool refr=true);               
     31  void SetImage(P2DArrayAdapter* pim, bool ad = true, bool refr=true);
    3732
    3833  void SetZoomWin(PIPixmap * zw, bool refr=true);
     
    8681  void DrawCursor(PIGraphicGen* g);
    8782  void DrawCursor(PIGraphicGen* g, int xc, int yc);
    88   void DrawMarks(PIGraphicGen* g, int x1, int x2, int y1, int y2);
    8983
    9084  void ShowTrTxW();
     
    9791
    9892// Les donnees
    99 
    10093  P2DArrayAdapter * img;
    101   bool aisup;
     94  bool aisup;     // Flag de suppression automatique de img
    10295  bool curshow;
    10396  bool winovis;   // $CHECK$ Reza A enlever si possible 17/6/96
    104 
    105 // Pour gerer les marques ajoutees
    106   bool admrk;
    107   int nbmrk, mrkbsz;
    108   float * xpmrk, * ypmrk;
    109   PIMarker mrkt;
    11097// Tableau des pixels principal 
    11198  unsigned char * pixm;
  • trunk/SophyaPI/PI/pintuple.cc

    r72 r107  
    55/* --Methode-- */
    66PINTuple::PINTuple(NTuple* nt, bool ad)
    7 : PIScDrawer()
     7: PIDrawer()
    88{
    99  mNT = nt;
     
    4545  if (mNT->NEntry() <= 0)  return;
    4646  if ( (xK < 0) || (yK < 0) )   return;
    47   if (!mDrawer) return;
    48   if (mDrawer->LimitsFixed()) return;
    4947
    5048  // Commencer par trouver nos limites
     
    5957  dy = 0.02*(ymax-ymin);
    6058 
    61   if (mDrawWdg)
    62     mDrawWdg->SetLimits(xmin-dx, xmax+dx, ymin-dy, ymax+dy,
    63                         kAxeDirLtoR, kAxeDirDownUp);
    64   else
    65     mDrawer->SetLimits(xmin-dx, xmax+dx, ymin-dy, ymax+dy,
    66                         kAxeDirLtoR, kAxeDirDownUp);
    67  
    68   mDrawer->SetAxesFlags(kBoxAxes | kExtTicks | kLabels);
     59  SetLimits(xmin-dx, xmax+dx, ymin-dy, ymax+dy);
     60  SetAxesFlags(kBoxAxes | kExtTicks | kLabels);
    6961}
    7062
     
    7870
    7971if (!mNT) return;
    80 if (!mDrawer) return;
    8172if ( (xK < 0) || (yK < 0) )  return;
    8273
     
    9889}
    9990
    100 if (!mDrawWdg)  return;
    101 if (!MainScDrawer())  return;
     91/*
    10292sprintf(buff, "NTuple:  NEntry= %d  NDisp= %d", (int)mNT->NEntry(), nok);
    10393g->BaseGraphic()->DrawString(15,15,buff);
     94*/
    10495return;
    10596}
  • trunk/SophyaPI/PI/pintuple.h

    r71 r107  
    55#include "piscdrawwdg.h"
    66
    7 class PINTuple : public PIScDrawer {
     7class PINTuple : public PIDrawer {
    88public:
    99                     PINTuple(NTuple* nt, bool ad);
     
    1919protected:
    2020  NTuple* mNT;
     21  bool mAdDO;
    2122  int xK, yK;          // Index du nom de variable en X/Y ds le ntuple
    2223  int xebK, yebK;      // Index du nom de variable en ErrBarX/Y ds le ntuple
  • trunk/SophyaPI/PI/piscdrawwdg.cc

    r88 r107  
    77{
    88  mBDrw = new PIDrawer;
    9   SetLimits(-1.,1.,-1.,1.);
     9  SetLimits(-1.,1.,-1.,1.,kAxeDirLtoR,kAxeDirDownUp);
     10  SetAxesFlags(kBoxAxes | kExtTicks | kLabels); 
    1011  FreeLimits();
    1112  xEndDrag = yEndDrag = xBegDrag = yBegDrag = 0;
    12 
    13   padsup = false;
     13  SetDefaultDrawRectangle(0.12, 0.12, 0.88, 0.88, true);
     14
    1415  mTrlb = mTxw = NULL;
    1516  mTrW = NULL;
     
    2425PIScDrawWdg::~PIScDrawWdg()
    2526{
    26   DeleteScDrawers();
    2727  delete mBDrw;
    2828  if (mTrW)  delete mTrW;
     
    3737    return; // $CHECK$ exception ?
    3838  mBDrw->SetLimits(xmin, xmax, ymin, ymax, axrl, ayud);
     39  SetDefaultDrawerLimits(xmin, xmax, ymin, ymax, axrl, ayud);
    3940  mPPos[0] = 0.5*(XMin()+XMax());
    4041  mPPos[1] = 0.5*(YMin()+YMax());
     
    7980 
    8081
    81 void
    82 PIScDrawWdg::AddScDrawer(PIScDrawer* d, bool ad)
    83 {
    84   bool pd=false;
    85   if (mScDrawers.size() == 0)  pd = true;
    86   mScDrawers.push_back(d);
    87   d->AttachTo(this, ad, pd);
    88 }
    89 
    90 void
    91 PIScDrawWdg::RemoveScDrawer(PIScDrawer* d)
    92 {
    93   if (padsup)  return;
    94   vector<PIScDrawer*>::iterator drw;
    95   for(drw = mScDrawers.begin(); drw != mScDrawers.end(); drw++)
    96     if (d == (*drw)) { mScDrawers.erase(drw);  break; }
    97   d->mDrawWdg = NULL;  d->mDrawer = NULL;
    98 }
    99 
    10082int
    101 PIScDrawWdg::NbScDrawers()
    102 {
    103   return(mScDrawers.size());
    104 }
    105 
    106 PIScDrawer*
    107 PIScDrawWdg::ScDrawer(int i)
    108 {
    109  if ( (i<0) || (i>mScDrawers.size()) )  return(NULL);
    110  return(mScDrawers[i]);
    111 }
    112 
    113 
    114 void
    115 PIScDrawWdg::DeleteScDrawers()
    116 {
    117   padsup = true;
    118   vector<PIScDrawer*>::iterator i;
    119   for(i = mScDrawers.begin(); i != mScDrawers.end(); i++) {
    120     if ( (*i)->ADelByDrwWdg() )  delete *i;
    121   }
    122   mScDrawers.erase(mScDrawers.begin(),mScDrawers.end());
    123   padsup = false;
    124 }
    125 
    126 void
    127 PIScDrawWdg::CallScDrawers(PIGraphicUC* g, float xmin, float ymin, float xmax, float ymax)
    128 {
    129   vector<PIScDrawer*>::iterator drw;
    130   for(drw = mScDrawers.begin(); drw != mScDrawers.end(); drw++) {
    131     g->SaveGraphicAtt();
    132     (*drw)->SelGraAtt(g);
    133     (*drw)->Draw(g, xmin, ymin, xmax, ymax);
    134     g->RestoreGraphicAtt();
    135   }
    136 }
     83PIScDrawWdg::AddScDrawer(PIDrawer* d, bool ad)
     84{
     85  return(AddDrawer(d, true, ad));
     86}
     87
    13788
    13889void
     
    161112{
    162113  EraseWindow();
     114  if (! LimitsFixed() ) {  //  On met a jour les limites a partir du premier Drawer
     115    PIDrawer* drw = GetDrawer(0);
     116    if (drw != NULL)   {   
     117      drw->UpdateSize();
     118      SetLimits(drw->XMin(), drw->XMax(), drw->YMin(), drw->YMax());
     119      }
     120    else SetLimits(0., 1., 0., 1.);
     121    }
    163122  PIGraphicUC* guc = SetSpan(g);
    164123  DrawAxes(guc);
    165124  DrawSelf(guc, -9.e19, -9.e19, 9.e19, 9.e19);
    166   CallScDrawers(guc, -9.e19, -9.e19, 9.e19, 9.e19);
    167125}
    168126
     
    170128PIScDrawWdg::Draw(PIGraphic* g, int x0, int y0, int dx, int dy)
    171129{
     130  EraseWindow();
     131  if (! LimitsFixed() ) {  //  On met a jour les limites a partir du premier Drawer
     132    PIDrawer* drw = GetDrawer(0);
     133    if (drw != NULL)   {   
     134      drw->UpdateSize();
     135      SetLimits(drw->XMin(), drw->XMax(), drw->YMin(), drw->YMax());
     136      }
     137    else SetLimits(0., 1., 0., 1.);
     138    }
    172139  float xmin,xmax,ymin,ymax;
    173140  PIGraphicUC* guc = SetSpan(g);
     
    178145  DrawAxes(guc);
    179146  DrawSelf(guc, xmin, ymin, xmax, ymax);
    180   CallScDrawers(guc, xmin, ymin, xmax, ymax); 
    181147}
    182148
     
    304270}
    305271
     272
    306273//================================================================
    307 // PIScDrawer
     274// PIFuncDrawer
    308275//================================================================
    309276
    310 
    311 
    312 PIScDrawer::PIScDrawer()
    313 : mDrawWdg(NULL), mDrawer(NULL)
    314 {
    315   mADbW = mAdDO = mPrDw = false;
    316   mFCol = mBCol = PI_NotDefColor;
    317   mLAtt = PI_NotDefLineAtt;
    318   mFSz = PI_NotDefFontSize;
    319   mFAtt = PI_NotDefFontAtt;
    320   mMSz = -1;
    321   mMrk = PI_NotDefMarker;
    322 }
    323 
    324 PIScDrawer::~PIScDrawer()
    325 {
    326   if (mDrawWdg)
    327     mDrawWdg->RemoveScDrawer(this);
    328 }
    329 
    330 void
    331 PIScDrawer::UpdateSize()
    332 {
    333 // Ne fait rien !
    334   return;
    335 }
    336 
    337 void
    338 PIScDrawer::Refresh()
    339 {
    340 // Recalcule les limites, et reaffiche
    341   if (!mDrawWdg) return;
    342   mDrawWdg->FreeLimits();
    343   UpdateSize();
    344   if (mDrawWdg) mDrawWdg->Refresh();
    345 }
    346 
    347 void
    348 PIScDrawer::AttachTo(PIScDrawWdg* wdg, bool ad, bool prd)
    349 {
    350   if (mDrawWdg)
    351     mDrawWdg->RemoveScDrawer(this);
    352   mDrawWdg = wdg;  mDrawer = wdg->BaseDrawer();
    353   UpdateSize();
    354   mADbW = ad;
    355   mPrDw = prd;
    356 }
    357 
    358 // Classe PIDrawer special pour enrober un PIScDrawer en PIDrawer
    359 class PIScContDrw : public PIDrawer {
    360 public :
    361                      PIScContDrw(PIScDrawer* d, bool ad=false);
    362   virtual            ~PIScContDrw();
    363   virtual  void      Draw(PIGraphicUC* g);
    364   virtual  void      Draw(PIGraphicUC* g, float xmin, float ymin, float xmax, float ymax);
    365 private:
    366   PIScDrawer* mScDrw;
    367   bool mAD;
    368 };
    369 
    370 PIScContDrw::PIScContDrw(PIScDrawer* d, bool ad) 
    371 {
    372   mScDrw = d;
    373   mAD=ad;
    374 }
    375 
    376 PIScContDrw::~PIScContDrw()
    377 {
    378   if (mAD)  delete mScDrw;
    379 }
    380 
    381 void PIScContDrw::Draw(PIGraphicUC* g)
    382 {
    383   mScDrw->SelGraAtt(g);
    384   mScDrw->Draw(g, -9.e19, -9.e19, 9.e19, 9.e19);
    385 }
    386 
    387 void PIScContDrw::Draw(PIGraphicUC* g, float xmin, float ymin, float xmax, float ymax)
    388 {
    389   mScDrw->SelGraAtt(g);
    390   mScDrw->Draw(g, xmin, ymin, xmax, ymax);
    391 }
    392 
    393 PIDrawer*
    394 PIScDrawer::Convert()
    395 {
    396   PIScContDrw* rd;
    397   if (mDrawWdg) mDrawWdg->RemoveScDrawer(this);
    398   rd = new PIScContDrw(this);
    399   mDrawWdg = NULL;    mDrawer = rd;
    400   UpdateSize();
    401   return((PIDrawer*)rd);
    402 }
    403 
    404 void
    405 PIScDrawer::SetColAtt(PIColors fg, PIColors bg)
    406 {
    407   if (fg != PI_NotDefColor) mFCol = fg;
    408   if (bg != PI_NotDefColor) mBCol = bg;
    409 }
    410 
    411 void
    412 PIScDrawer::SetLineAtt(PILineAtt lat)
    413 {
    414   if (lat != PI_NotDefLineAtt) mLAtt = lat;
    415 }
    416 
    417 void
    418 PIScDrawer::SetFontAtt(PIFontSize fsz, PIFontAtt fat)
    419 {
    420   if (fsz != PI_NotDefFontSize) mFSz = fsz;
    421   if (fat != PI_NotDefFontAtt) mFAtt = fat;
    422 }
    423 
    424 void
    425 PIScDrawer::SetMarkerAtt(int sz, PIMarker mrk)
    426 {
    427   if (sz >= 0)  mMSz = sz;
    428   if (mrk != PI_NotDefMarker) mMrk = mrk;
    429 }
    430 
    431 void
    432 PIScDrawer::SelGraAtt(PIGraphicUC* g)
    433 {
    434   if (mFCol != PI_NotDefColor)    g->SelForeground(mFCol);
    435   if (mBCol != PI_NotDefColor)    g->SelBackground(mBCol);
    436   if (mLAtt != PI_NotDefLineAtt)  g->SelLine(mLAtt);
    437   if ( (mFSz != PI_NotDefFontSize) || (mFAtt != PI_NotDefFontAtt) )
    438                                   g->SelFont(mFSz, mFAtt);
    439   if ( (mMrk != PI_NotDefMarker) || (mMSz >= 0) )
    440                                   g->SelMarker(mMSz, mMrk);
    441 }
    442 
    443 //================================================================
    444 // PIScFuncDrawer
    445 //================================================================
    446 
    447 PIScFuncDrawer::PIScFuncDrawer(PIScFuncDrawer::FUNC f)
     277PIFuncDrawer::PIFuncDrawer(PIFuncDrawer::FUNC f)
    448278: mFunc(f)
    449279{}
    450280
    451 PIScFuncDrawer::~PIScFuncDrawer()
    452 {
    453 }
    454 
    455 void
    456 PIScFuncDrawer::Draw(PIGraphicUC* g, float /*xmin*/, float/*ymin*/, float/*xmax*/, float/*ymax*/)
     281PIFuncDrawer::~PIFuncDrawer()
     282{
     283}
     284
     285void
     286PIFuncDrawer::Draw(PIGraphicUC* g, float /*xmin*/, float/*ymin*/, float/*xmax*/, float/*ymax*/)
    457287{
    458288  PIGrCoord x1, x2, y1, y2;
     
    476306
    477307//================================================================
    478 // PIScGFFDrawer
     308// PIGFFDrawer
    479309//================================================================
    480310
    481 PIScGFFDrawer::PIScGFFDrawer(GeneralFunction* f)
     311PIGFFDrawer::PIGFFDrawer(GeneralFunction* f)
    482312: mFunc(f), mNParms(f->NPar()), mParms(new double[mNParms])
    483313{
     
    485315}
    486316
    487 PIScGFFDrawer::~PIScGFFDrawer()
     317PIGFFDrawer::~PIGFFDrawer()
    488318{
    489319  delete[] mParms;
     
    491321
    492322void
    493 PIScGFFDrawer::SetParms(double const* p)
     323PIGFFDrawer::SetParms(double const* p)
    494324{
    495325  for (int i=0; i<mNParms; i++)
     
    499329
    500330void
    501 PIScGFFDrawer::Draw(PIGraphicUC* g, float /*xmin*/, float/*ymin*/, float/*xmax*/, float/*ymax*/)
     331PIGFFDrawer::Draw(PIGraphicUC* g, float /*xmin*/, float/*ymin*/, float/*xmax*/, float/*ymax*/)
    502332{
    503333  PIGrCoord x1, x2, y1, y2;
  • trunk/SophyaPI/PI/piscdrawwdg.h

    r88 r107  
    1212
    1313
    14 class PIScDrawer;
    1514
    1615class PIScDrawWdg : public PIBaseWdg {
     
    3635  void               DrawAxes(PIGraphicUC* g, int flags = -1);
    3736
    38   void               AddScDrawer(PIScDrawer*, bool ad=false);   // Ajoute un ScDrawer
    39   void               RemoveScDrawer(PIScDrawer*);  // Ote un ScDrawer sans le detruire
    40   int                NbScDrawers();
    41   PIScDrawer*        ScDrawer(int i);         
     37  int                AddScDrawer(PIDrawer*, bool ad=false);   // Ajoute un Drawer en auto
    4238
    4339  PIDrawer*          BaseDrawer() { return mBDrw; };
     
    6662 
    6763protected:
    68           void       DeleteScDrawers();    // Ote et detruit tous les ScDrawers
    69           void       CallScDrawers(PIGraphicUC* g, float xmin, float ymin, float xmax, float ymax);
    7064       PIGraphicUC*  SetSpan(PIGraphicGen* g);
    7165
     
    7468
    7569  PIDrawer* mBDrw;
    76   vector<PIScDrawer*>   mScDrawers;
    77   bool padsup;
    7870 
    7971  int xBegDrag, yBegDrag;
     
    9385
    9486
    95 class PIScDrawer {
    96 public:
    97                      PIScDrawer();
    98   virtual           ~PIScDrawer();
    9987
    100   virtual void       Draw(PIGraphicUC* g, float xmin, float ymin, float xmax, float ymax) = 0;
    101   virtual void       UpdateSize();   // Calcule et change les limites si non fixees
    102   virtual void       Refresh();      // Recalcule les limites et reaffiche
    103 
    104   PIDrawer*          Convert();
    105 
    106   void               SetColAtt(PIColors fg=PI_NotDefColor,
    107                                 PIColors bg=PI_NotDefColor);
    108   void               SetLineAtt(PILineAtt lat=PI_NotDefLineAtt);
    109   void               SetFontAtt(PIFontSize fsz=PI_NotDefFontSize,
    110                                 PIFontAtt fat=PI_NotDefFontAtt);
    111   void               SetMarkerAtt(int sz=-1, PIMarker mrk=PI_NotDefMarker);
    112 
    113   void               SelGraAtt(PIGraphicUC* g);
    114 
    115   inline void        SetAutoDelDataObj(bool ad=false) { mAdDO = ad; }
    116   inline bool        ADelByDrwWdg() { return mADbW; }
    117   inline bool        MainScDrawer() { return mPrDw; }
    118 
    119 protected:
    120   friend class       PIScDrawWdg;
    121   virtual void       AttachTo(PIScDrawWdg*, bool, bool);
    122 
    123   PIScDrawWdg*       mDrawWdg;
    124   PIDrawer*          mDrawer;
    125   bool               mADbW, mAdDO, mPrDw;
    126   PIColors           mFCol, mBCol;
    127   PILineAtt          mLAtt;
    128   PIFontSize         mFSz;
    129   PIFontAtt          mFAtt;
    130   int                mMSz;
    131   PIMarker           mMrk;     
    132 };
    133 
    134 class PIScFuncDrawer : public PIScDrawer {
     88class PIFuncDrawer : public PIDrawer {
    13589public:
    13690  typedef double(*FUNC)(double);
    137                      PIScFuncDrawer(FUNC);
    138   virtual           ~PIScFuncDrawer();
     91                     PIFuncDrawer(FUNC);
     92  virtual           ~PIFuncDrawer();
    13993 
    14094  virtual void       Draw(PIGraphicUC* g, float xmin, float ymin, float xmax, float ymax);
     
    14498
    14599class GeneralFunction;
    146 class PIScGFFDrawer : public PIScDrawer {
     100class PIGFFDrawer : public PIDrawer {
    147101public:
    148                      PIScGFFDrawer(GeneralFunction*);
    149   virtual           ~PIScGFFDrawer();
     102                     PIGFFDrawer(GeneralFunction*);
     103  virtual           ~PIGFFDrawer();
    150104 
    151105  virtual void       Draw(PIGraphicUC* g, float xmin, float ymin, float xmax, float ymax);
  • trunk/SophyaPI/PI/pistlist.cc

    r71 r107  
    55/* --Methode-- */
    66PIStarList::PIStarList(StarList* stl, bool ad, int ayud)
    7 : PIScDrawer(), mStL(stl)
     7: PIDrawer(), mStL(stl)
    88{
    99  mAdDO = ad;   
     
    6161{
    6262  if (!mStL) return;
    63   if (!mDrawer) return;
    64   if (mDrawer->LimitsFixed()) return;
    6563
    6664  // Commencer par trouver nos limites
     
    7068  dy = 0.02*(mYMax-mYMin);
    7169 
    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);
     70  SetLimits(mXMin-dx, mXMax+dx, mYMin-dy, mYMax+dy, kAxeDirLtoR, mAYdir);
     71  SetAxesFlags(kBoxAxes | kExtTicks | kLabels);
    7872}
    7973
     
    8983
    9084if (!mStL) return;
    91 if (!mDrawer) return;
    9285
    9386g->SelFont();
     
    114107  }
    115108
    116 if (!mDrawWdg)  return;
    117 if (!MainScDrawer()) return;
    118 
     109/*
    119110sprintf(buff, "StarList:  NbStars= %d  NDisp= %d", (int)mStL->NbStars(), nok);
    120111g->BaseGraphic()->DrawString(15,15,buff);
    121112sprintf(buff, "FMin= %g  FMax= %g Nl= %d Sz0= %d", mFmin, mFmax, mNLev, mMSz0);
    122113g->BaseGraphic()->DrawString(15,30,buff);
     114*/
    123115
    124116}
  • trunk/SophyaPI/PI/pistlist.h

    r71 r107  
    33
    44#include "stlist.h"
    5 #include "piscdrawwdg.h"
     5#include "pidrawer.h"
    66
    7 class PIStarList : public PIScDrawer {
     7class PIStarList : public PIDrawer {
    88public:
    99                     PIStarList(StarList* stl, bool ad, int ayud=kAxeDirUpDown);
     
    2828protected:
    2929  StarList* mStL;
     30  bool mAdDO;
    3031  float mFmin, mFmax;
    3132  int mNLev, mMSz0;
  • trunk/SophyaPI/PI/sc_sample.cc

    r72 r107  
    1 #include <stdlib.h>
    2 #include <stdio.h>
    3 #include <string>
    4 
    51#include "sc_sample.h"
    62
     
    128
    139{
    14 PIScFuncDrawer * mfd;
    15 mfd = new PIScFuncDrawer(f);
     10PIFuncDrawer * mfd;
     11mfd = new PIFuncDrawer(f);
    1612  SetLimits(-3,3,-4,4);
    1713AddScDrawer(mfd);
     
    2622
    2723void
    28 ScSample::DrawSelf(PIGraphicUC* g, float, float, float, float)
     24ScSample::DrawSelf(PIGraphicUC* g)
    2925{
    3026PIGrCoord x[5] = {-2, -1., 1., 1.7, 2.2};
     
    3632g->DrawMarkers(x, y, 5);
    3733g->SelForeground(PI_Magenta);
    38 printf(" +DBG+ ScSample::DrawSelf - Marker(%g) \n", 0.3);
    3934g->SelMarkerSz(0.3, PI_FCircleMarker);
    4035for(i=0; i<5; i++)
  • trunk/SophyaPI/PI/sc_sample.h

    r72 r107  
    1 // #include "pisysdep.h"
     1#include "pisysdep.h"
    22
    33#include "piscdrawwdg.h"
     
    1010
    1111 
    12   virtual void DrawSelf(PIGraphicUC* g, float, float, float, float);
     12  virtual void DrawSelf(PIGraphicUC* g);
    1313
    1414};
Note: See TracChangeset for help on using the changeset viewer.