Changeset 1503 in Sophya


Ignore:
Timestamp:
May 21, 2001, 3:09:26 PM (24 years ago)
Author:
ansari
Message:

Implementation de la possibilite d'inverser l'indexage des ColorMap - Reza 21/5/2001

Location:
trunk/SophyaPI/PI
Files:
17 edited

Legend:

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

    r1129 r1503  
    2525if (bornes == NULL)  return;
    2626type = typ;  nLevel = nlev;
     27table = NULL; 
     28tablenbin = 0;
    2729SetLut(min, max, typ);
    28 table = NULL; 
    29 ComputeTable(ntable);
    3030return;
    3131}
     
    4040
    4141/* --Methode-- */
    42 void LUT::SetLut(double min, double max, int typ)
     42void LUT::SetLut(double min, double max, int typ, int ntable)
    4343{
    4444
     
    8383  }
    8484else  bornes[0] = 0.5*(min+max);
     85ComputeTable((ntable > nLevel) ? ntable : tablenbin);
    8586return;
    8687}
     
    110111void LUT::ComputeTable(int nt)
    111112{
    112 if (nt < 0) nt = 16*(nLevel+2);
     113if (nt <= 0) nt = 16*(nLevel+2);
    113114else if (nt < (nLevel+2))  nt = (nLevel+2);
     115tablenbin = nt;
    114116table = new unsigned short [nt-2];
    115117tablebinwidth = (Max()-Min())/(nt-2);
  • trunk/SophyaPI/PI/lut.h

    r1129 r1503  
    1919public:
    2020 
    21   LUT(double min, double max, unsigned short ncol=16, int typ=kLutType_Lin, int ntable=-1);
     21  LUT(double min, double max, unsigned short ncol=16, int typ=kLutType_Lin, int ntable=0);
    2222  ~LUT();
    23   void SetLut(double min, double max, int typ=0);
     23  void SetLut(double min, double max, int typ=kLutType_Lin, int ntable=0);
    2424  void Print();
    2525  unsigned short Apply(double x);
     
    4343  int nLevel;
    4444  double * bornes;
     45  int tablenbin;
    4546  unsigned short * table;
    4647  double tablebinwidth;
  • trunk/SophyaPI/PI/picmap.cc

    r1132 r1503  
    7676  if ( (num < 0) || (num >= MXMAPIDS) )  num = 0;
    7777  return (MapNoms[num]) ;
     78}
     79
     80int PIColorMap::ColorMapId2Num(PIColorMap const & cmap)
     81{
     82  for(int k=0; k<MXMAPIDS; k++)
     83    if (cmap.Type() == MapIds[k])  return(k);
     84  return(-1);
    7885}
    7986
     
    182189
    183190PIColorMap::PIColorMap(PIColorMap& cm)
     191: PIColorMapNative()
    184192{
     193  ReverseColorIndex(cm.IsColorIndexReversed());
    185194  CopyFrom(&cm);
    186195  mCTId = cm.mCTId;
  • trunk/SophyaPI/PI/picmap.h

    r1129 r1503  
    5353  static CMapId GetStandardColorMapId(int num);
    5454  static string GetStandardColorMapName(int num);
     55  static int    ColorMapId2Num(PIColorMap const & cmap);
    5556
    5657protected:
  • trunk/SophyaPI/PI/picmapgen.cc

    r440 r1503  
    1313  mNCol = 0;
    1414  mType = -1;
     15  ReverseColorIndex(false);
    1516}
    1617PIColorMapGen::PIColorMapGen(int id, int nc, string const& nom)
     
    1920  mNCol = nc;
    2021  mType = id;
     22  ReverseColorIndex(false); 
    2123}
    2224
  • trunk/SophyaPI/PI/picmapgen.h

    r440 r1503  
    2424
    2525  virtual PIColor GetColor(int n)=0;
     26  inline void  ReverseColorIndex(bool fg=false)
     27               { mFlagReversedIndex = fg; }
     28  inline bool  IsColorIndexReversed() const
     29               { return(mFlagReversedIndex); }
    2630  virtual bool AllocColor(PIColor const& col, int index)=0;
    2731  virtual void FreeColors()=0;     // Desalloue les couleurs
    2832
    29   virtual long   TotNbColors()=0;   // Donne le nombre total de couleurs disponibles
     33  virtual long  TotNbColors()=0;    // Donne le nombre total de couleurs disponibles
    3034  virtual int   NbAllocColors()=0;  // Nb de couleurs deja allouees
    3135protected:
     
    3741  int    mType;
    3842  string mNom;
    39  
     43  bool   mFlagReversedIndex;
    4044};
    4145
  • trunk/SophyaPI/PI/picmapview.cc

    r1125 r1503  
    7676    return;
    7777    }
    78   if ( cmap && (cmp->Type() == cmap->Type()) && (cmp->Type() != CMAP_OTHER) 
    79        && ((vmin-min) < 1.e-69) &&  ((vmin-min) > -1.e-69) &&
    80        ((vmax-max) < 1.e-69) &&  ((vmax-max) > -1.e-69) )  return;
     78  if ( cmap && (cmp->Type() == cmap->Type()) && (cmp->Type() != CMAP_OTHER)
     79       && (cmp->IsColorIndexReversed() == cmap->IsColorIndexReversed())
     80       && (fabs(vmin-min) < 1.e-69)  && (fabs(vmax-max) > -1.e-69) )  return;
    8181  if (cmap) delete cmap;
    8282  cmap = new PIColorMap(*cmp);
     
    8787
    8888/* --Methode-- */
    89 void PICMapView::SetColMapId(CMapId cmapid, double min, double max, bool refr)
     89void PICMapView::SetColMapId(CMapId cmapid, bool revidx, double min, double max, bool refr)
    9090{
    91   if ( cmap && (cmapid == cmap->Type()) && (cmapid != CMAP_OTHER)
    92        && ((vmin-min) < 1.e-69) &&  ((vmin-min) > -1.e-69) &&
     91  if ( cmap && (cmapid == cmap->Type()) && (cmapid != CMAP_OTHER) &&
     92       (cmap->IsColorIndexReversed() == revidx) &&
     93       ((vmin-min) < 1.e-69) &&  ((vmin-min) > -1.e-69) &&
    9394       ((vmax-max) < 1.e-69) &&  ((vmax-max) > -1.e-69) )  return;
    9495  if (cmap) delete cmap;
    9596  cmap = new PIColorMap(cmapid);
     97  cmap->ReverseColorIndex(revidx);
    9698  vmin = min;  vmax = max;
    9799  if (refr)  Refresh(); 
  • trunk/SophyaPI/PI/picmapview.h

    r557 r1503  
    2424
    2525  void            SetColMap(PIColorMap* cmp=NULL, double min=1., double max=-1., bool refr=true);
    26   void            SetColMapId(CMapId cmapid, double min=1., double max=-1., bool refr=true);
     26  void            SetColMapId(CMapId cmapid, bool revidx, double min, double max, bool refr);
     27  inline void     SetColMapId(CMapId cmapid, double min=1., double max=-1., bool refr=true)
     28                  { SetColMapId(cmapid, false, min, max, refr); }
    2729
    2830// Traitement des evenements   
  • trunk/SophyaPI/PI/picmapx.cc

    r194 r1503  
    5353  return(picr);
    5454  }
    55 return(mColRGB[n]);
     55if (mFlagReversedIndex) return(mColRGB[NCol()-n-1]);
     56else return(mColRGB[n]);
    5657}
    5758
  • trunk/SophyaPI/PI/picmapx.h

    r112 r1503  
    1313  virtual ~PIColorMapX();
    1414
     15  // Fonction Color() est definie afin de permettre l'optimisation - affichage d'image, etc...
    1516  inline PIXColor  Color(int index)
    16     { return ((index < mNCol) ? mColors[index] : 0); } ;
     17    { return (((index < mNCol)&&(index>=0)) ?
     18              mColors[(mFlagReversedIndex)?mNCol-index-1:index] : 0); } ;
    1719
    1820  virtual PIColor GetColor(int n);
  • trunk/SophyaPI/PI/piimage.cc

    r1125 r1503  
    484484
    485485/* --Methode-- */
    486 float PIImage::GetZoomF()
     486float PIImage::GetZoomF() const
    487487{
    488488if (zoom >= 1)  return((float)zoom);
     
    548548
    549549/* --Methode-- */
    550 void PIImage::SetColMapId(CMapId cmapid, bool refr)
     550void PIImage::SetColMapId(CMapId cmapid, bool revidx, bool refr)
    551551{
    552552if ( (cmapid == CMAP_GREY32) || (cmapid == CMAP_GREYINV32) ||
    553553     (cmapid == CMAP_GREY128) || (cmapid == CMAP_GREYINV128))  mdrw->SetColAtt(PI_Red);
    554554else mdrw->SetColAtt(PI_Turquoise);
    555 PIPixmap::SetColMapId(cmapid, refr);
    556 if (zow)  zow->SetColMapId(cmapid, refr);
    557 if (gvw)  gvw->SetColMapId(cmapid, refr);
    558 if (cmvw) cmvw->SetColMapId(cmapid, Lut()->Min(), Lut()->Max(), refr);
     555PIPixmap::SetColMapId(cmapid, revidx, refr);
     556if (zow)  zow->SetColMapId(cmapid, revidx, refr);
     557if (gvw)  gvw->SetColMapId(cmapid, revidx, refr);
     558if (cmvw) cmvw->SetColMapId(cmapid, revidx, Lut()->Min(), Lut()->Max(), refr);
    559559return;
    560560}
  • trunk/SophyaPI/PI/piimage.h

    r389 r1503  
    5858  void SetZoom(int zm, bool refr=true);
    5959  void SetZoomF(float fzm, bool refr=true);
    60   float GetZoomF();
     60  float GetZoomF() const ;
     61  inline int GetZoom() const { return (zoom); }
    6162
    6263// Changement de table de couleur
    6364  virtual void SetColMap(PIColorMap* cmp, bool refr=true);
    64   virtual void SetColMapId(CMapId cmapid, bool refr=true);
     65  virtual void SetColMapId(CMapId cmapid, bool revidx, bool refr);
     66  inline  void SetColMapId(CMapId cmapid, bool refr=true)
     67               { SetColMapId(cmapid, false, refr); }
    6568
    6669// Positionnement image - pave
  • trunk/SophyaPI/PI/piimgtools.cc

    r1317 r1503  
    174174for(kcc=nsct3; kcc<PIColorMap::NumberStandardColorMaps(); kcc++)
    175175mOptzc[0]->AppendItem(PIColorMap::GetStandardColorMapName(kcc).c_str(), 201+kcc);
    176 
    177 mOptzc[0]->SetValue(203);
     176// On ajoute un CheckItem pour inverser les index de table de couleur
     177mOptzc[0]->Menu()->AppendCheckItem("Reverse CMap", 299);
     178
     179mOptzc[0]->SetValue(203);  mLastCol = 203;
    178180mOptzc[0]->SetBinding(PIBK_elastic,PIBK_elastic, PIBK_elastic,PIBK_elastic);
    179181
     
    297299PIWindow::Show();
    298300mpii = PIImage::CurrentPIImage();
    299 if (mpii == NULL)  return;
     301if (mpii == NULL) {
     302  mOptzc[0]->Menu()->SetStateMsg(299, false);
     303  mOptzc[0]->SetValue(203);  mLastCol = 203;
     304  mOptzc[1]->SetValue(101);
     305  mOptCut->SetValue(303);
     306  return;
     307}
    300308min_lut = mpii->Lut()->Min();
    301309max_lut = mpii->Lut()->Max();
     
    313321mSc[0]->SetValue(0);
    314322mSc[1]->SetValue(0);
    315 mOptzc[0]->SetValue(203);
    316 mOptzc[1]->SetValue(101);
     323
     324// Pour mettre a jour le menu de la table de couleur
     325mOptzc[0]->Menu()->SetStateMsg(299, mpii->GetColMap()->IsColorIndexReversed());
     326int cmnum = PIColorMap::ColorMapId2Num(mpii->GetColMapId());
     327mLastCol =  (cmnum < 0) ? 203 : 201+cmnum;
     328mOptzc[0]->SetValue(mLastCol);
     329
     330// Pour le facteur de zoom
     331mOptzc[1]->SetValue(mpii->GetZoom()+100);
     332
    317333mOptCut->SetValue(303);
    318334return;
     
    453469if ((msg <= 110) && (msg >= 90))  // Zoom
    454470  PIImage::CurrentPIImage()->SetZoom((int)(msg-100), true);
    455 else if ((msg > 200) && (msg < 299)) // Changement de couleur
    456   PIImage::CurrentPIImage()->SetColMapId(PIColorMap::GetStandardColorMapId(msg-201), true);
     471else if (msg == 299) { // Revert CMap index
     472  mOptzc[0]->SetValue(mLastCol);
     473}
     474else if ((msg > 200) && (msg < 299)) { // Changement de couleur
     475  //  bool irev = PIImage::CurrentPIImage()->GetColMap()->IsColorIndexReversed();
     476  bool revidx = mOptzc[0]->Menu()->GetStateMsg(299);
     477  //  cout << " DBG PIImgTools::Process() revidx= " ;
     478  //  if (revidx) cout << " TRUE " ;
     479  //  else cout << " FALSE " ;
     480  //  if (irev) cout << " Img::RevIdx= TRUE " << endl;
     481  //  else cout << " Img::RevIdx= FALSE " << endl;
     482  PIImage::CurrentPIImage()->SetColMapId(PIColorMap::GetStandardColorMapId(msg-201), revidx, true);
     483  mLastCol = msg;
     484}
    457485
    458486// Cuts
  • trunk/SophyaPI/PI/piimgtools.h

    r1124 r1503  
    3939  PIOptMenu* mOptzc[2];
    4040  PIMenu* mCasc[5];
     41  PIMessage mLastCol;
     42
    4143// Pour expand et compress
    4244  PIButton* mButsz[5];
  • trunk/SophyaPI/PI/pipixmapgen.cc

    r329 r1503  
    121121{
    122122if (!cmp)  return;
    123 if ( (cmp->Type() == cmap->Type()) && (cmp->Type() != CMAP_OTHER) ) return;
     123if ( (cmp->Type() == cmap->Type()) && (cmp->Type() != CMAP_OTHER)
     124     && (cmp->IsColorIndexReversed() == cmap->IsColorIndexReversed()) ) return;
    124125if (cmap) delete cmap;
    125126cmap = new PIColorMap(*cmp);
     
    128129
    129130/* --Methode-- */
    130 void PIPixmapGen::SetColMapId(CMapId cmapid, bool refr)
     131void PIPixmapGen::SetColMapId(CMapId cmapid, bool revidx, bool refr)
    131132{
    132 if (!cmap || (cmap->Type() != cmapid) || (cmapid == CMAP_OTHER) ) { 
     133if (!cmap || (cmap->Type() != cmapid) || (cmapid == CMAP_OTHER)
     134    || (cmap->IsColorIndexReversed() != revidx) ) { 
    133135  if (cmap) delete cmap;
    134136  cmap = new PIColorMap(cmapid);
     137  cmap->ReverseColorIndex(revidx);
    135138  }
    136139if (refr)  Refresh(); 
  • trunk/SophyaPI/PI/pipixmapgen.h

    r440 r1503  
    2626
    2727  virtual void  SetColMap(PIColorMap* cmp, bool refr=true);
    28   virtual void  SetColMapId(CMapId cmapid, bool refr=true);
     28  virtual void  SetColMapId(CMapId cmapid, bool revidx, bool refr);
     29  inline  void  SetColMapId(CMapId cmapid, bool refr=true)
     30                { SetColMapId(cmapid, false, refr); }
    2931
    3032  inline PIColorMap* GetColMap() { return cmap; }
  • trunk/SophyaPI/PI/piversion.h

    r1421 r1503  
    22#define PIVERSION_H_SEEN
    33
    4 #define PI_VERSIONNUMBER  2.80
     4#define PI_VERSIONNUMBER  2.85
    55
    66#endif
Note: See TracChangeset for help on using the changeset viewer.