Changeset 127 in Sophya for trunk/SophyaPI/PI/picmapview.cc


Ignore:
Timestamp:
Jul 31, 1998, 5:22:21 PM (27 years ago)
Author:
ercodmgr
Message:

Modifs depuis le PC - (PICMapView , coller depuis PIImage, ... Reza 31/07/98

File:
1 edited

Legend:

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

    r113 r127  
    1 #include <stdio.h>
    2 #include <string.h>
     1// Module PI : Peida Interactive     PICMapView
     2// Visualisation de table de couleur     R. Ansari  07/98
     3// LAL (Orsay) / IN2P3-CNRS  DAPNIA/SPP (Saclay) / CEA
    34
    45#include "picmapview.h"
     
    1213
    1314{
    14 
     15  cmap = NULL;
    1516}
    1617
     
    1920PICMapView::~PICMapView()
    2021{
     22  if (cmap) delete cmap;
    2123}
    2224
    2325 
    24 
     26/* --Methode-- */
     27void PICMapView::SetColMap(PIColorMap* cmp, bool refr)
     28{
     29  if (cmap) delete cmap;
     30  if (cmp == NULL)   cmap = NULL;
     31  else cmap = new PIColorMap(*cmp);
     32  if (refr)  Refresh(); 
     33  return;
     34}
    2535
    2636/* --Methode-- */
    27 void PICMapView::Resize()
     37void PICMapView::SetColMapId(CMapId cmapid, bool refr)
    2838{
    29 
     39  if (cmap && (cmap->Type() == cmapid) && (cmapid != CMAP_OTHER) )  return;
     40  if (cmap) delete cmap;
     41  cmap = new PIColorMap(cmapid);
     42  if (refr)  Refresh(); 
     43  return;
    3044}
    3145
    3246
    3347/* --Methode-- */
    34 void PICMapView::Draw(PIGraphicGen* g)
     48void PICMapView::Draw(PIGraphicGen* g, int /*x0*/, int /*y0*/, int /*dx*/, int /*dy*/)
    3549{
    36 EraseWindow();
    37 g->SelLine(PI_NormalLine);
    38 g->DrawBox(10,10, XSize()-20, YSize()-20);
     50  if (!cmap) {
     51    EraseWindow(0, 0, XSize(), YSize());
     52    return;
     53    }
     54  // On presente la table de couleur verticalement si SizeY > SizeX
     55  // ou horizontale  si SizeX > SizeY
    3956
    40 g->SelLine(PI_ThinLine);
    41 g->DrawFBox(20, 20, 20, 20);
    42 g->DrawCircle(30, 30, 15);
     57  int sx = XSize();
     58  int sy = YSize();
    4359
    44 g->SelForeground(PI_Red);
    45 g->DrawFCircle(70, 30, 15);
    46 
    47 g->SelForeground(PI_Yellow);
    48 g->DrawFBox(10, 60, 100, 15);
    49 
    50 g->SelForeground(PI_Black);
    51 
    52 g->SelLine(PI_ThinLine);
    53 g->DrawLine(10, 120, 40, 120);
    54 g->SelLine(PI_NormalLine);
    55 g->DrawLine(40, 120, 70, 120);
    56 g->SelLine(PI_ThickLine);
    57 g->DrawLine(70, 120, 100, 120);
    58 
    59 g->SelForeground(PI_Magenta);
    60 g->DrawFCircle(120, 30, 15);
    61 g->SelForeground(PI_Grey);
    62 g->DrawFCircle(120, 60, 15);
    63 
    64 PIGrCoord x[5] = { 20, 35, 50, 65, 80 };
    65 PIGrCoord y[5] = { 130, 130, 130, 130, 130 };
    66 
    67 g->SelForeground(PI_Black);
    68 g->DrawMarkers(x, y, 5);
    69 return;
     60  int k;
     61  if (sx > sy) {    // horizontal
     62    int xc, dx;
     63    xc = 0;
     64    for(k=0; k<cmap->NCol(); k++) {
     65      dx = (sx-xc)/(cmap->NCol()-k);
     66      g->SelForeground((*cmap), k);
     67      g->DrawFBox(xc, 0, dx, sy);
     68      xc += dx;
     69    }
     70  }
     71  else  {    // vertical
     72    int yc, dy;
     73    yc = sy;
     74    for(k=0; k<cmap->NCol(); k++) {
     75      dy = yc/(cmap->NCol()-k);
     76      yc -= dy;
     77      g->SelForeground((*cmap), k);
     78      g->DrawFBox(0, yc, sx, dy);
     79    }
     80  }
     81 
     82  return;
    7083}
    7184
Note: See TracChangeset for help on using the changeset viewer.