- Timestamp:
- Jan 29, 2010, 7:15:04 PM (16 years ago)
- Location:
- trunk/SophyaPI/PI
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/SophyaPI/PI/lut.h
r3545 r3734 40 40 inline double Min() { return(bornes[0]); }; 41 41 inline double Max() { return(bornes[nLevel]); }; 42 inline double Borne(int k) { return(bornes[k]); }; 42 43 inline int Type() { return(type); }; 43 44 inline int NCol() { return(nLevel+2); }; -
trunk/SophyaPI/PI/picmapview.cc
r3545 r3734 5 5 #include "sopnamsp.h" 6 6 #include "picmapview.h" 7 #include "strutil.h" 7 8 #include <math.h> 9 #include <iostream> 8 10 9 11 //++ … … 186 188 } 187 189 188 189 190 191 192 190 //++ 191 // Class PICMapDrawer 192 // Lib PI 193 // include picmapview.h 194 // 195 // Classe de traceur de colormap 196 //-- 197 //++ 198 // Links Parents 199 // PIDrawer 200 //-- 201 //++ 202 203 204 /* --Methode-- */ 205 PICMapDrawer::PICMapDrawer(bool fgvert) 206 : fgvert_(fgvert), fgtext_(false), cmapp(NULL), bornes_(5) 207 { 208 SetLimits(0.,1.,0.,1., kAxeDirLtoR, kAxeDirDownUp); 209 SetColMapId(CMAP_GREY32); 210 } 211 212 /* --Methode-- */ 213 PICMapDrawer::~PICMapDrawer() 214 { 215 } 216 217 /* --Methode-- */ 218 void PICMapDrawer::SetBornes(LUT& lut) 219 { 220 fgtext_=true; 221 bornes_[0]=lut.Min(); bornes_[4]=lut.Max(); 222 bornes_[1]=lut.Borne((lut.NCol()-2)/4); 223 bornes_[2]=lut.Borne((lut.NCol()-2)/2); 224 bornes_[3]=lut.Borne(3*(lut.NCol()-2)/4); 225 return; 226 } 227 228 /* --Methode-- */ 229 void PICMapDrawer::SetBornes(double min, double max) 230 { 231 fgtext_=true; 232 bornes_[0]=min; bornes_[4]=max; 233 bornes_[1]=min+(max-min)*0.25; 234 bornes_[2]=min+(max-min)*0.5; 235 bornes_[3]=min+(max-min)*0.75; 236 return; 237 } 238 239 /* --Methode-- */ 240 void PICMapDrawer::Draw(PIGraphicUC* g, double /*xmin*/, double /*ymin*/, 241 double /*xmax*/, double /*ymax*/) 242 { 243 PIColorMap* cmp=cmapp; 244 PIColorMap cmapi(cmapid_); 245 if (cmp==NULL) cmp=&cmapi; 246 PIColorMap& cmap=(*cmp); 247 248 // cout << " *DBG*PICMapDrawer::Draw() Sz:" << BWdgXSize() << "," << BWdgYSize() 249 // << " Pos:" << BWdgXPos() << "," << BWdgYPos() << endl; 250 // On limite le nombre de carres de couleurs traces, si trop de couleur ... 251 PIPixColIdx pixc; 252 if (fgvert_) { // vertical 253 pixc.AllocateByte(0.25*BWdgXSize(), BWdgYSize()); 254 for(int j=0; j<pixc.YSize(); j++) { 255 int ci = j*cmap.NCol()/pixc.YSize(); 256 int jrev=pixc.YSize()-j-1; 257 for(int i=0; i<pixc.XSize(); i++) pixc.GetByte(i,jrev)=(unsigned char)ci; 258 } 259 g->DrawPixmap(0.,1.,pixc, cmp); 260 } 261 else { // horizontal 262 pixc.AllocateByte(BWdgXSize(), 0.25*BWdgYSize()); 263 for(int i=0; i<pixc.XSize(); i++) { 264 int ci = i*cmap.NCol()/pixc.XSize(); 265 for(int j=0; j<pixc.YSize(); j++) pixc.GetByte(i,j)=(unsigned char)ci; 266 } 267 g->DrawPixmap(0.,0.25,pixc, cmp); 268 } 269 270 271 if (!fgtext_) return; 272 char buff[32]; 273 double ps[5]={0.025,0.25,0.5,0.75,0.975}; 274 // g->SelForeground(PI_White); 275 for(int k=0; k<5; k++) { 276 sprintf(buff,"%6.2lg",bornes_[k]); 277 strip(buff,'B',' '); 278 if (fgvert_) { // vertical 279 g->DrawLine(0.25,ps[k],0.35,ps[k]); 280 g->DrawString(0.7, ps[k], buff, PI_TextDirectionVerticalUp|PI_HorizontalCenter|PI_VerticalCenter); 281 } 282 else { // horizontal 283 g->DrawLine(ps[k],0.25,ps[k],0.35); 284 g->DrawString(ps[k], 0.7, buff, PI_VerticalCenter|PI_HorizontalCenter); 285 } 286 } 287 return; 288 } 289 290 -
trunk/SophyaPI/PI/picmapview.h
r2652 r3734 11 11 #include PIBWDG_H 12 12 #include PICMAP_H 13 14 #include "pidrawer.h" 15 #include "lut.h" 16 #include <vector> 17 13 18 14 19 class PICMapView : public PIBaseWdg … … 38 43 }; 39 44 45 class PICMapDrawer : public PIDrawer 46 { 47 public: 48 PICMapDrawer(bool fgvert=false); 49 ~PICMapDrawer(); 50 51 virtual void Draw(PIGraphicUC* g, double xmin, double ymin, double xmax, double ymax); 52 inline void SetHorizontal() { fgvert_=false; } 53 inline void SetVertical() { fgvert_=true; } 54 55 inline void SetColMapId(CMapId cmapid, bool revcidx=false) 56 { cmapid_=cmapid; revcidx_=revcidx; cmapp=NULL; return; } 57 58 inline void SetColMap(PIColorMap* cmp) 59 { cmapp=cmp; return; } 60 61 void SetBornes(LUT& lut); 62 void SetBornes(double min, double max); 63 64 protected: 65 66 bool fgvert_; // true -> vertical 67 bool fgtext_; // true -> ecriture des valeurs des bornes 68 PIColorMap* cmapp; 69 CMapId cmapid_; 70 bool revcidx_; // true -> reverse color map index 71 vector<double> bornes_; 72 }; 73 40 74 41 75 #endif -
trunk/SophyaPI/PI/pidrawer.cc
r3562 r3734 118 118 119 119 //++ 120 // Titre Gestion des axes et des limites120 // Titre Gestion des axes, des limites et coordonnees fenetre 121 121 // Le tracé des axes 2D est pris en charge par la classe PIAxes. 122 122 //-- 123 123 //++ 124 // double BWdgXPos() BWdgYPos() 125 // Renvoient les positions (X,Y) du drawer dans l'objet PIBaseWdg. Ces positions ne sont 126 // valables qu'apres appel a SetDrwWdg() - Ne peut donc etre utilise en pratique que dans 127 // la methode Draw. 128 // double BWdgXSize() BWdgYSize() 129 // Renvoient les tailles (X,Y) du drawer dans l'objet PIBaseWdg. Meme remarque que pour 130 // BWdgXPos() BWdgYPos(). 131 // 124 132 // void SetLimits(double xmin, double xmax, double ymin, double ymax, - 125 133 // int axrl=kAxeDirSame, int ayud=kAxeDirSame) 126 // Définit les limites du système de coordonnées .134 // Définit les limites du système de coordonnées du Drawer. 127 135 //| kAxeDirSame , kAxeDirAuto 128 136 //| kAxeDirLtoR , kAxeDirRtoL (Axe X) -
trunk/SophyaPI/PI/pidrawer.h
r3562 r3734 60 60 virtual void HighLight(bool fgh); 61 61 62 // Zone de trace/accrochage dans le BaseWidget 63 inline int BWdgXPos() const { return xW0; } 64 inline int BWdgYPos() const { return yW0; } 65 inline int BWdgXSize() const { return xWd; } 66 inline int BWdgYSize() const { return yWd; } 67 68 // Limites et informations sur les coordonnees dans le systeme du Drawer 62 69 inline double XMin() const {return xMin;} 63 70 inline double XMax() const {return xMax;} -
trunk/SophyaPI/PI/piimage.cc
r3545 r3734 111 111 gvw = NULL; // widget vue globale 112 112 cmvw = NULL; // widget ColorMapView 113 fgshowcmap = 0; // 0: Pas de vue ColMap, 1: top, 2:right, 3:bottom, 4:left 114 cmdid = -1; 113 115 // Fenetre transient et Label pour affichage de l'info (texte PixVal) 114 116 int tx, ty; … … 142 144 143 145 mdrw = new PIElDrawer(false); 144 146 mdrw->SetAxesFlags(kAxesNone); 145 147 gvdrw = new PIElDrawer(); 146 148 AddDrawer(mdrw, true, false, false, false); … … 666 668 continue; 667 669 } 670 if (opts == "showcmap") UpdateCMapDrawer(1); 671 else if (opts == "noshowcmap") UpdateCMapDrawer(0); 672 else if (opts.substr(0,9) == "showcmap=") { 673 if (opts.substr(9,2) == "no") UpdateCMapDrawer(0); 674 else if (opts.substr(9,3) == "top") UpdateCMapDrawer(1); 675 else if (opts.substr(9,5) == "right") UpdateCMapDrawer(2); 676 else if (opts.substr(9,6) == "bottom") UpdateCMapDrawer(3); 677 else if (opts.substr(9,4) == "left") UpdateCMapDrawer(4); 678 else if (opts.substr(9,5) == "horiz") UpdateCMapDrawer(1); 679 else if (opts.substr(9,4) == "vert") UpdateCMapDrawer(2); 680 else UpdateCMapDrawer(0); 681 } 682 668 683 ndec--; 669 684 udopt.push_back(opts); … … 785 800 { 786 801 if (img == NULL) return; 802 if (fgshowcmap>0) { 803 cmpd.SetColMap(GetColMap()); 804 cmpd.SetBornes(*Lut()); 805 } 787 806 if (mw) { 788 807 ComputePixmap(); … … 1379 1398 //printf("UpdateCuts()-DBG X: %d -> %g , Y: %d -> %g \n", cutarrx->Size(), cutarrx->Value(0), 1380 1399 // cutarry->Size(), cutarry->Value(0)); 1400 } 1401 1402 /* --Methode-- */ 1403 void PIImage::UpdateCMapDrawer(int fgshow) 1404 { 1405 if ((fgshow<0)||(fgshow>4)) fgshow=0; 1406 if (fgshow==fgshowcmap) return; 1407 fgshowcmap=fgshow; 1408 switch (fgshowcmap ) { 1409 case 0 : 1410 RemoveDrawer(cmdid); 1411 break; 1412 case 1 : 1413 cmpd.SetHorizontal(); 1414 cmdid=AddDrawer(&cmpd, 0.10, 0.02, 0.90, 0.10, true, false); 1415 break; 1416 case 2 : 1417 cmpd.SetVertical(); 1418 cmdid=AddDrawer(&cmpd, 0.90, 0.1, 0.98, 0.9, true, false); 1419 break; 1420 case 3 : 1421 cmpd.SetHorizontal(); 1422 cmdid=AddDrawer(&cmpd, 0.10, 0.90, 0.90, 0.98, true, false); 1423 break; 1424 case 4 : 1425 cmpd.SetVertical(); 1426 cmdid=AddDrawer(&cmpd, 0.02, 0.1, 0.10, 0.9, true, false); 1427 break; 1428 } 1429 if (fgshowcmap>0) cmpd.GetGraphicAtt().SetColAtt(PI_Turquoise); 1381 1430 } 1382 1431 -
trunk/SophyaPI/PI/piimage.h
r3519 r3734 135 135 void SetGloVPixmap(); 136 136 void UpdateCuts(); 137 void UpdateCMapDrawer(int fgshow); 137 138 138 139 void DrawCursor(PIGraphic* g); … … 171 172 // Fenetre d'affichage du ColMap 172 173 PICMapView* cmvw; 174 int fgshowcmap; // 0: Pas de vue ColMap, 1: top, 2:right, 3:bottom, 4:left 175 PICMapDrawer cmpd; 176 int cmdid; 173 177 // Fenetre/champ de texte 174 178 PILabel * trtlb;
Note:
See TracChangeset
for help on using the changeset viewer.