Changeset 2373 in Sophya for trunk/SophyaPI/PIext


Ignore:
Timestamp:
Apr 25, 2003, 3:36:47 PM (22 years ago)
Author:
ansari
Message:

Ajout possibilite de trace de marker suivant table de couleur/poids ds PINTuple/PINTuple3D - Reza 25/04/03

Location:
trunk/SophyaPI/PIext
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/SophyaPI/PIext/piaversion.h

    r2350 r2373  
    22#define PIAPPVERSION_H_SEEN
    33
    4 #define PIAPP_VERSIONNUMBER  3.93
     4#define PIAPP_VERSIONNUMBER  3.95
    55
    66#endif
  • trunk/SophyaPI/PIext/pintup3d.cc

    r2350 r2373  
    4848  mNT = nt;
    4949  mAdDO = ad;
     50  UseSizeScale(true, 5);
     51  UseColorScale(true);
    5052  SelectXYZ(NULL, NULL, NULL);
    51   SelectWt(NULL, 1);
     53  SelectWt(NULL);
    5254  SelectErrBar();
    5355  SelectLabel(NULL);
     
    9193
    9294/* --Methode-- */
    93 void  PINTuple3D::SelectWt(const char* pw, int nbins)
    94 {
    95 nWbins = (nbins > 0) ? nbins : 10;
     95void  PINTuple3D::SelectWt(const char* pw)
     96{
    9697if (pw == NULL) wK = -1; 
    9798else { string name = pw;   wK = mNT->ColumnIndex(name);  }
     
    189190//  Pour tracer des markers avec taille fonction de Wt (poids)
    190191double dw = (wMax-wMin)/nWbins;
    191 if (dw < 1.e-19) dw = 1.e19;
     192if (dw < 1.e-19) dw = 1.e-19;
     193//  Pour tracer des markers avec couleur en fonction de Wt (poids)
     194PIColorMap * cmap = NULL;
     195double dwc = 1.;
     196double nwc = 1.;
     197bool revcmap;
     198CMapId mcmapid = GetGraphicAtt().GetColMapId(revcmap);
     199if( colorScale && (wK >= 0) && (mcmapid != CMAP_OTHER) ) {
     200  cmap = new PIColorMap(mcmapid);
     201  cmap->ReverseColorIndex(revcmap);
     202  nwc = cmap->NCol();
     203  dwc = (wMax-wMin)/nwc;
     204}
     205
    192206int msz,sz;
    193207
     
    207221  yp = mNT->GetCell(i, yK);
    208222  zp = mNT->GetCell(i, zK);
     223
     224// Taille - couleur de marker en fonction du poids
     225  if (wK >= 0) wp = mNT->GetCell(i, wK);
     226  if (mrkSzScale && (wK >= 0)) {   // Changement de taille
     227    sz = (int)((wp-wMin)/dw);
     228    if (sz < 0) sz = 0;
     229    if (sz > nWbins)  sz = nWbins;
     230    sz += msz;
     231    if (sz < 2)  g->SelMarker(sz, PI_DotMarker);
     232    else g->SelMarker(sz, mrk);
     233  }
     234// Couleur du marker en fonction du poids
     235  if( colorScale && (wK >= 0) && cmap ) {
     236    int cid = (int)((wp-wMin)/dwc);
     237    if (cid < 0) cid = 0;
     238    if (cid >= nwc)  cid = nwc-1;
     239    g->SelForeground(*cmap, cid);
     240  }
     241
    209242  if ( (i > 0) && connectPts ) // On relie les points ...
    210243    g3->DrawLine3D(xl, yl, zl, xp, yp, zp);
     
    221254    zer = mNT->GetCell(i, zebK);
    222255    g3->DrawLine3D(xp, yp, zp-zer, xp, yp, zp+zer);
    223   }
    224   if (wK >= 0) { // Taille de marker en fonction du poids
    225     wp = mNT->GetCell(i, wK);
    226     sz = (int)((wp-wMin)/dw);
    227     if (sz < 0) sz = 0;
    228     if (sz > nWbins)  sz = nWbins;
    229     sz += msz;
    230     if (sz < 2)  g->SelMarker(sz, PI_DotMarker);
    231     else g->SelMarker(sz, mrk);
    232256  }
    233257  // Trace du marker
     
    271295    if (opts == "connectpoints") ConnectPoints(true);
    272296    else if (opts == "noconnectpoints") ConnectPoints(false);
     297    else if (opts == "colorscale") UseColorScale(true);
     298    else if (opts == "nocolorscale") UseColorScale(false);
     299    else if (opts == "sizescale") UseSizeScale(true);
     300    else if (opts == "nosizescale") UseSizeScale(false);
     301    else if (opts.substr(0,10) == "sizescale=") {
     302      int nbn = atoi(opts.substr(10).c_str());
     303      UseSizeScale(true, nbn);
     304    }
    273305    else {
    274306      // Si option non decode
     
    298330info += "  connectpoints: The points are connected by a line \n";
    299331info += "  noconnectpoints (this is the default) \n";
     332info += "  colorscale/nocolorscale (Use color scale for weight) \n";
     333info += "  sizescale/sizescale=nbins/nosizescale (Use marker size for weight) \n";
    300334info += "  and usual color/line/marker/... attribute decoding  \n";
    301335return;
  • trunk/SophyaPI/PIext/pintup3d.h

    r2350 r2373  
    1414 
    1515  virtual void       SelectXYZ(const char* px, const char* py, const char* pz);
    16   virtual void       SelectWt(const char* pw=NULL, int nbins=10);
     16  virtual void       SelectWt(const char* pw=NULL);
    1717  virtual void       SelectErrBar(const char* erbx=NULL, const char* erby=NULL, const char* erbz=NULL);
    1818  virtual void       SelectLabel(const char* plabel);
    1919
    2020  inline  void       ConnectPoints(bool fg=false) { connectPts = fg; }
     21
     22  // Gestion de la representation de poids
     23  inline  void       UseSizeScale(bool fg=true, int nbins=5)
     24    { mrkSzScale = fg; if (nbins>0) nWbins = nbins; }
     25  inline  void       UseColorScale(bool fg=true) { colorScale = fg; }
     26
     27  inline  bool       GetSizeScale(int& nbins)
     28    { nbins = nWbins; return mrkSzScale; }
     29  inline  bool       GetColScale() { return colorScale; }
    2130
    2231//   Methode de decodage des options
     
    3342  int lK;                   // Index du nom de variable label (affiche en texte)
    3443  double wMin, wMax;        // Valeurs de poids min/max
    35   int nWbins;               // Nombre de bins pour le poids (Wt)
     44  bool mrkSzScale;     // true -> Taille de markers variable suivant poids
     45  int nWbins;          // Nombre de bins taille de marker variable
     46  bool colorScale;     // true -> Couleur de marker variable suivant poids
    3647
    3748  bool connectPts;          // true -> les points sont relies par une ligne
  • trunk/SophyaPI/PIext/pintuple.cc

    r2350 r2373  
    1515//      Les objets "PINTuple" peuvent tracer des signes (markers)
    1616//      éventuellement avec des barres d'erreur et une étiquette
    17 //      pour chaque point. Si un attribut de ligne, autre que
    18 //      "PI_NotDefLineAtt" est spécifié, les points sont connectés
    19 //      par une ligne.
     17//      pour chaque point. Si un nom de colonne poids est spécifié,
     18//      la taille et/ou la couleur des signes (markers) sera fonction
     19//      de la valeur de poids.
    2020//--
    2121//++
     
    3636//      Constructeur. Si "ad == true", l'objet "nt" est détruit par
    3737//      le destructeur de l'objet "PINTuple"
    38 //      Note : "nt" doit être créé par new
     38//      Note : "nt" doit être créé par new dans ce cas.
    3939//--
    4040 
     
    4747  SetStats(true);
    4848  ConnectPoints(false);
     49  UseSizeScale(true, 5);
     50  UseColorScale(true);
    4951  SelectXY(NULL, NULL);
    50   SelectWt(NULL, 1);
     52  SelectWt(NULL);
    5153  SelectErrBar();
    5254  SelectLabel(NULL);
     
    8890
    8991/* --Methode-- */
    90 void  PINTuple::SelectWt(const char* pw, int nbins)
    91 {
    92 nWbins = (nbins > 0) ? nbins : 10;
     92void  PINTuple::SelectWt(const char* pw)
     93{
    9394if (pw == NULL) wK = -1; 
    9495else { string name = pw;   wK = mNT->ColumnIndex(name);  }
     
    151152//  Pour tracer des markers avec taille fonction de Wt (poids)
    152153double dw = (wMax-wMin)/nWbins;
    153 if (dw < 1.e-19) dw = 1.e19;
     154if (dw < 1.e-19) dw = 1.e-19;
     155
     156//  Pour tracer des markers avec couleur en fonction de Wt (poids)
     157PIColorMap * cmap = NULL;
     158double dwc = 1.;
     159double nwc = 1.;
     160bool revcmap;
     161CMapId mcmapid = GetGraphicAtt().GetColMapId(revcmap);
     162if( colorScale && (wK >= 0) && (mcmapid != CMAP_OTHER) ) {
     163  cmap = new PIColorMap(mcmapid);
     164  cmap->ReverseColorIndex(revcmap);
     165  nwc = cmap->NCol();
     166  dwc = (wMax-wMin)/nwc;
     167}
     168
    154169int msz,sz;
    155170
     
    158173if (wK >= 0)  mrk = (mmrk != PI_NotDefMarker) ? mmrk : PI_CircleMarker;
    159174else   mrk = (mmrk != PI_NotDefMarker) ? mmrk : PI_DotMarker;
    160  msz = GetGraphicAtt().GetMarkerSz();
     175msz = GetGraphicAtt().GetMarkerSz();
    161176if (msz < 1) msz = 1;
    162177g->SelMarker(msz, mrk);
     
    178193  nok++;
    179194  if ( (xp < xmin) || (xp > xmax) || (yp < ymin) || (yp > ymax) )  continue;
    180   if ( (i > 0) && connectPts )   
    181     g->DrawLine(xl, yl, xp, yp);  // On relie les points ...
    182   if ( xebK >= 0 ) {
    183     xer = mNT->GetCell(i, xebK);
    184     if(xer>0.) g->DrawLine(xp-xer, yp, xp+xer, yp);
    185   }
    186   if ( yebK >= 0 ) {
    187     yer = mNT->GetCell(i, yebK);
    188     if(yer>0.) g->DrawLine(xp, yp-yer, xp, yp+yer);
    189   }
    190   if (wK >= 0) { // Taille de marker en fonction du poids
    191     wp = mNT->GetCell(i, wK);
     195
     196// Taille - couleur de marker en fonction du poids
     197  if (wK >= 0) wp = mNT->GetCell(i, wK);
     198  if (mrkSzScale && (wK >= 0)) {  // Changement de taille
    192199    sz = (int)((wp-wMin)/dw);
    193200    if (sz < 0) sz = 0;
     
    196203    if (sz < 2)  g->SelMarker(sz, PI_DotMarker);
    197204    else g->SelMarker(sz, mrk);
     205  }
     206// Couleur du marker en fonction du poids
     207  if( colorScale && (wK >= 0) && cmap ) {
     208    int cid = (int)((wp-wMin)/dwc);
     209    if (cid < 0) cid = 0;
     210    if (cid >= nwc)  cid = nwc-1;
     211    g->SelForeground(*cmap, cid);
     212  }
     213
     214  if ( (i > 0) && connectPts )   
     215    g->DrawLine(xl, yl, xp, yp);  // On relie les points ...
     216  if ( xebK >= 0 ) {
     217    xer = mNT->GetCell(i, xebK);
     218    if(xer>0.) g->DrawLine(xp-xer, yp, xp+xer, yp);
     219  }
     220  if ( yebK >= 0 ) {
     221    yer = mNT->GetCell(i, yebK);
     222    if(yer>0.) g->DrawLine(xp, yp-yer, xp, yp+yer);
    198223  }
    199224  // Trace du marker
     
    228253}
    229254
     255if (cmap) delete cmap;
    230256return;
    231257}
     
    289315    else if (opts == "connectpoints") ConnectPoints(true);
    290316    else if (opts == "noconnectpoints") ConnectPoints(false);
     317    else if (opts == "colorscale") UseColorScale(true);
     318    else if (opts == "nocolorscale") UseColorScale(false);
     319    else if (opts == "sizescale") UseSizeScale(true);
     320    else if (opts == "nosizescale") UseSizeScale(false);
     321    else if (opts.substr(0,10) == "sizescale=") {
     322      int nbn = atoi(opts.substr(10).c_str());
     323      UseSizeScale(true, nbn);
     324    }
    291325    else {
    292326      // Si option non decode
     
    318352info += "  connectpoints: The points are connected by a line \n";
    319353info += "  noconnectpoints (this is the default) \n";
     354info += "  colorscale/nocolorscale (Use color scale for weight) \n";
     355info += "  sizescale/sizescale=nbins/nosizescale (Use marker size for weight) \n";
    320356info += "  and usual color/line/marker/... attribute decoding  \n";
    321357return;
    322358}
     359
     360
     361
  • trunk/SophyaPI/PIext/pintuple.h

    r2350 r2373  
    1919 
    2020  virtual void       SelectXY(const char* px, const char* py);
    21   virtual void       SelectWt(const char* pw=NULL, int nbins=10);
     21  virtual void       SelectWt(const char* pw=NULL);
    2222  virtual void       SelectErrBar(const char* erbx=NULL, const char* erby=NULL);
    2323  virtual void       SelectLabel(const char* plabel=NULL);
    2424
     25  inline  void       ConnectPoints(bool fg=false) { connectPts = fg; }
     26
     27  // Gestion de la representation de poids
     28  inline  void       UseSizeScale(bool fg=true, int nbins=5)
     29    { mrkSzScale = fg; if (nbins>0) nWbins = nbins; }
     30  inline  void       UseColorScale(bool fg=true) { colorScale = fg; }
     31
     32  inline  bool       GetSizeScale(int& nbins)
     33    { nbins = nWbins; return mrkSzScale; }
     34  inline  bool       GetColScale() { return colorScale; }
     35
    2536  inline  void       SetStats(bool fg=true) { stats = fg; }
    26   inline  void       ConnectPoints(bool fg=false) { connectPts = fg; }
    2737
    2838  virtual void       AppendTextInfo(string& info, double xmin, double ymin, double xmax, double ymax);
     
    4050  int wK;              // Index du nom de variable poids
    4151  int lK;              // Index du nom de variable label (affiche en texte)
    42   double wMin, wMax;        // Valeurs de poids min/max
    43   int nWbins;               // Nombre de bins pour le poids (Wt)
     52  double wMin, wMax;   // Valeurs de poids min/max
     53  bool mrkSzScale;     // true -> Taille de markers variable suivant poids
     54  int nWbins;          // Nombre de bins taille de marker variable
     55  bool colorScale;     // true -> Couleur de marker variable suivant poids
    4456  bool stats;               // true -> indication du nb de points
    4557  bool connectPts;          // true -> les points sont relies par une ligne
Note: See TracChangeset for help on using the changeset viewer.