Changeset 2373 in Sophya for trunk/SophyaPI/PIext/pintuple.cc


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

File:
1 edited

Legend:

Unmodified
Added
Removed
  • 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
Note: See TracChangeset for help on using the changeset viewer.