Changeset 4083 in Sophya
- Timestamp:
- Oct 4, 2012, 2:26:28 PM (12 years ago)
- Location:
- trunk/SophyaPI/PI
- Files:
-
- 57 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/SophyaPI/PI/Makefile
r4077 r4083 1 include ../ BuildMgr/sophyamake.inc1 include ../sophyamake.inc 2 2 3 3 all: $(SOPHYALIBP)libPI.a -
trunk/SophyaPI/PI/Quartz/pigraphquartz.cpp
r4081 r4083 331 331 void PIGraphicQuartz::DrawMarker(PIGrCoord x0, PIGrCoord y0) 332 332 { 333 printf("PIGraphicQuartz::DrawMarker NOT IMPLEMENTED\n"); 333 334 334 335 /* … … 407 408 void PIGraphicQuartz::DrawMarkers(PIGrCoord *x, PIGrCoord *y, int n) 408 409 { 410 printf("PIGraphicQuartz::DrawMarkers NOT IMPLEMENTED\n"); 409 411 /* 410 412 int i; … … 431 433 432 434 435 void PIGraphicQuartz::DrawPixmap(PIGrCoord, PIGrCoord, PIPixColIdx&, PIColorMap*) { 436 printf("PIGraphicQuartz::DrawPixmap1 NOT IMPLEMENTED\n"); 437 } 438 433 439 /* --Methode-- */ 434 440 void PIGraphicQuartz::DrawPixmap(PIGrCoord x, PIGrCoord y, unsigned char *pix, … … 470 476 XFree(ximg); 471 477 */ 478 printf("PIGraphicQuartz::DrawPixmap2 NOT IMPLEMENTED\n"); 472 479 return; 473 480 } … … 517 524 void PIGraphicQuartz::DrawVerticalString(int x, int y, const char* s, unsigned long pos, bool imgs) 518 525 { 526 printf("PIGraphicQuartz::DrawVerticalString NOT IMPLEMENTED\n"); 519 527 /* 520 528 int fh, fasc, fdes; … … 693 701 void PIGraphicQuartz::SelLine(PILineAtt const& att) 694 702 { 703 printf("PIGraphicQuartz::SelLine NOT IMPLEMENTED\n"); 695 704 696 705 if (att == mLAtt) return; -
trunk/SophyaPI/PI/Quartz/pigraphquartz.h
r4077 r4083 52 52 virtual void DrawPixmap(PIGrCoord x, PIGrCoord y, unsigned char *pix, 53 53 int sx, int sy, PIColorMap* cmap); 54 virtual void DrawPixmap(PIGrCoord, PIGrCoord, PIPixColIdx&, PIColorMap*); 54 55 55 56 // Modifications attributs graphiques -
trunk/SophyaPI/PI/Tests/xp1.cc
r4077 r4083 10 10 #include PISTDWDG_H 11 11 #include PIWIN_H 12 #include "PIButtonQuartz.h" 12 #ifdef __PIWQUARTZ__ 13 #include <pistdwdgquartz.h> 14 #else 15 #include <pistdwdgx.h> 16 #endif 13 17 14 18 // ----- Declaration de la classe ArgsWind : Fenetre de dialogue ------- … … 48 52 { 49 53 int bsx, bsy; 50 54 printf("ArgsWind::ArgsWind\n"); 55 51 56 // On definit la taille a partir de la taille par defaut des composantes 52 57 PIApplicationPrefCompSize(bsx, bsy); 53 58 // On redefinit la taille de la fenetre 54 59 SetSize(bsx*4, bsy*4); 55 60 printf("bsx:%d bsy:%d\n",bsx,bsy); 61 56 62 // Creation de champs "labels" 57 63 mLab[0] = new PILabel(this, "Arg-1:", bsx, bsy, bsx/3, bsy/4); … … 96 102 void ArgsWind::Process(PIMessage msg, PIMsgHandler* /*sender*/, void* /*data*/) 97 103 { 104 printf("ArgsWind::Process\n"); 98 105 99 106 switch (UserMsg(msg)) -
trunk/SophyaPI/PI/lut.cc
r4077 r4083 12 12 #include "lut.h" 13 13 14 14 //++ 15 // Class LUT 16 // Lib PI 17 // include lut.h 18 // 19 // Classe Look-Up table : transformation de valeurs (intensite/RGB) en index de couleur 20 //-- 21 //++ 22 // Links Voir aussi 23 // PIColorMap 24 // PIPixmap 25 // PIImage 26 //-- 15 27 /* --Methode-- */ 16 28 17 LUT::LUT(double min, double max, unsigned short ncol, int typ , int ntable)29 LUT::LUT(double min, double max, unsigned short ncol, int typ) 18 30 { 19 int nlev; 20 21 bornes=NULL; 22 nlev = ncol-2; 31 int nlev = ncol-2; 23 32 if (nlev < 1) nlev = 1; 24 33 bornes = new double[nlev+1]; … … 26 35 if (bornes == NULL) return; 27 36 type = typ; nLevel = nlev; 37 int qqq = 1; 38 quantum = 1; 39 for(quantum=2; quantum<=42; quantum++) { 40 qqq = quantum*quantum*quantum; 41 if (qqq > NCol()) break; 42 } 43 quantum--; 44 28 45 table = NULL; 29 46 tablenbin = 0; … … 39 56 delete[] table; 40 57 } 58 /* --Methode-- */ 59 void LUT::SetNCol(unsigned short ncol) 60 { 61 if (ncol == NCol()) return; 62 double min = Min(); 63 double max = Max(); 64 if (bornes) delete[] bornes; 65 int nlev = ncol-2; 66 if (nlev < 1) nlev = 1; 67 bornes = new double[nlev+1]; 68 nLevel = nlev; 69 int qqq = 1; 70 quantum = 1; 71 for(quantum=2; quantum<=42; quantum++) { 72 qqq = quantum*quantum*quantum; 73 if (qqq > NCol()) break; 74 } 75 quantum--; 76 // printf("*DBG*LUT* quantum= %d \n", (int)quantum); 77 SetLut(min, max, Type()); 78 } 41 79 42 80 /* --Methode-- */ 43 void LUT::SetLut(double min, double max, int typ , int ntable)81 void LUT::SetLut(double min, double max, int typ) 44 82 { 45 83 46 84 if( (typ != kLutType_Lin) && (typ != kLutType_Log) 47 && (typ != kLutType_Sqrt) && (typ != kLutType_Square) 48 ) typ = kLutType_Lin;85 && (typ != kLutType_Sqrt) && (typ != kLutType_Square) 86 && (typ != kLutType_RGB) ) typ = kLutType_Lin; 49 87 type = typ; 50 88 if (max <= min) max = min+1.; 89 mMin = min; mMax = max; 90 mMinI = (int)(min+0.1); mMaxI = (int)(max+0.1); 51 91 if (nLevel > 0) 52 92 { 53 93 int i; 54 double dx; 55 double dlx; 94 double dx, dlx, fmx; 56 95 switch (typ) 57 96 { 58 97 case kLutType_Lin : 98 case kLutType_RGB : 59 99 dx = (max-min)/(double)nLevel; 60 100 for(i=0; i<nLevel; i++) … … 62 102 break; 63 103 case kLutType_Log : 64 dlx = log(max-min) / (double)nLevel; 104 fmx = (max-min)/(exp(1.)-1.); 105 dlx = 1./(double)nLevel; 65 106 for(i=0; i<nLevel; i++) 66 bornes[i] = min+(double)exp((double)i*dlx); 107 bornes[i] = min+((double)exp((double)i*dlx)-1.)*fmx; 108 break; 109 case kLutType_Exp : 110 dlx = (exp(1.)-1.)/(double)nLevel; 111 for(i=0; i<nLevel; i++) 112 bornes[i] = min+(double)log(1.+(double)i*dlx)*(max-min); 67 113 break; 68 114 case kLutType_Sqrt : … … 84 130 } 85 131 else bornes[0] = 0.5*(min+max); 86 ComputeTable((ntable > nLevel) ? ntable : tablenbin); 132 // ComputeTable((ntable > nLevel) ? ntable : tablenbin); 133 if (type != kLutType_RGB) ComputeTable(0); 87 134 return; 88 135 } … … 101 148 102 149 /* --Methode-- */ 103 unsigned short LUT::Apply (double x)150 unsigned short LUT::ApplyI(double x) 104 151 { 105 152 int i; … … 110 157 111 158 /* --Methode-- */ 159 unsigned short LUT::ApplyRGB(double x) 160 { 161 long lv = x+0.3; 162 int r = (lv%256); 163 lv /= 256; 164 int g = (lv%256); 165 lv /= 256; 166 int b = (lv%256); 167 return (unsigned short)((Contraste(b)*quantum+Contraste(g))*quantum+Contraste(r)); 168 } 169 170 /* --Methode-- */ 112 171 void LUT::ComputeTable(int nt) 113 172 { 114 if (nt <= 0) nt = 16*(nLevel+2); 173 if (nt <= 0) { 174 int fm = 16; 175 if ((nLevel+2)>4096) fm = 1; 176 else if ((nLevel+2)>2048) fm = 2; 177 else if ((nLevel+2)>1024) fm = 4; 178 else if ((nLevel+2)>512) fm = 8; 179 nt = fm*(nLevel+2); 180 } 115 181 else if (nt < (nLevel+2)) nt = (nLevel+2); 116 182 tablenbin = nt; 183 if (table) delete[] table; 117 184 table = new unsigned short [nt-2]; 118 185 tablebinwidth = (Max()-Min())/(nt-2); 119 186 double x = Min()+0.5*tablebinwidth; 120 for(int i=0; i<nt-2; i++) { table[i] = Apply (x); x += tablebinwidth; }187 for(int i=0; i<nt-2; i++) { table[i] = ApplyI(x); x += tablebinwidth; } 121 188 } -
trunk/SophyaPI/PI/lut.h
r4077 r4083 13 13 14 14 // Type de lut possibles 15 enum {kLutType_Lin=1, kLutType_Log=2, kLutType_ Sqrt=3, kLutType_Square=4};15 enum {kLutType_Lin=1, kLutType_Log=2, kLutType_Exp=3, kLutType_Sqrt=4, kLutType_Square=5, kLutType_RGB=11 }; 16 16 17 17 class LUT … … 19 19 public: 20 20 21 LUT(double min, double max, unsigned short ncol=16, int typ=kLutType_Lin , int ntable=0);21 LUT(double min, double max, unsigned short ncol=16, int typ=kLutType_Lin); 22 22 ~LUT(); 23 void SetLut(double min, double max, int typ=kLutType_Lin, int ntable=0); 23 void SetNCol(unsigned short ncol); 24 void SetLut(double min, double max, int typ=kLutType_Lin); 24 25 void Print(); 25 unsigned short Apply(double x); 26 27 inline unsigned short Apply(double x) 28 { 29 if (type == kLutType_RGB) return ApplyRGB(x); 30 else return ApplyI(x); 31 } 32 26 33 inline unsigned short ApplyFast(double x) 27 34 { 35 if (type == kLutType_RGB) return ApplyRGB(x); 36 else return AppFast(x); 37 } 38 39 40 inline double Min() { return(bornes[0]); }; 41 inline double Max() { return(bornes[nLevel]); }; 42 inline double Borne(int k) { return(bornes[k]); }; 43 inline int Type() { return(type); }; 44 inline int NCol() { return(nLevel+2); }; 45 46 47 protected: 48 void ComputeTable(int nt); 49 unsigned short ApplyI(double x); 50 unsigned short ApplyRGB(double x); 51 inline unsigned short AppFast(double x) 52 { 28 53 if (x < Min()) return(0); 29 54 if (x >= Max() ) return(nLevel+1); … … 31 56 return(table[k]); 32 57 } 33 34 inline double Min() { return(bornes[0]); }; 35 inline double Max() { return(bornes[nLevel]); }; 36 inline int Type() { return(type); }; 37 inline int NCol() { return(nLevel+2); }; 38 39 protected: 40 void ComputeTable(int nt); 41 58 inline int Contraste(int ii) /* for ApplyRGB */ 59 { 60 if (ii >= mMaxI) return quantum-1; 61 if (ii <= mMinI) return 0; 62 else return ((ii-mMinI)*(quantum-1)/mMaxI); 63 } 42 64 int type; 43 65 int nLevel; 66 int quantum; 44 67 double * bornes; 68 double mMin, mMax; 69 int mMinI, mMaxI; 45 70 int tablenbin; 46 71 unsigned short * table; -
trunk/SophyaPI/PI/parradapter.cc
r4077 r4083 174 174 175 175 /* --Methode-- */ 176 double P2DArrayAdapter::MeanVal(int ix1, int ix2, int jy1, int jy2) 177 { 178 int ec; 179 if (ix1>ix2) { ec=ix1; ix1=ix2; ix2=ec; } 180 if (jy1>jy2) { ec=jy1; jy1=jy2; jy2=ec; } 181 // On calcule la somme des pixels dans la zone 182 double ss = 0.; 183 for(int j=jy1; j<=jy2; j++) 184 for(int i=ix1; i<=ix2; i++) ss += Value(i,j); 185 186 ss /= (double)((jy2-jy1+1)*(ix2-ix1+1)); 187 return ss; 188 } 189 190 /* --Methode-- */ 176 191 void P2DArrayAdapter::XYfromxy(int ix, int iy, double& x, double& y) 177 192 { … … 187 202 double x,y; 188 203 this->Coord(ix, iy, x, y); 189 c har * isr = "";204 const char * isr = ""; 190 205 if (ISFunc != NULL) isr = ISFunc(this, ix, iy); 191 206 sprintf(ibuff,"X= %g Y= %g Pix= %g %s ", … … 433 448 434 449 /* --Methode-- */ 435 unsigned char *P2DArrayAdapter::ComputePixmap(LUT* lut, int ofx, int ofy, int zm,436 int xwsz, int ywsz, unsigned char * opix, int * oxsp, int * oysp)450 void P2DArrayAdapter::ComputePixmap(LUT* lut, int ofx, int ofy, int zm, 451 int xwsz, int ywsz, PIPixColIdx & pixc) 437 452 { 438 453 // TIMEF ; 439 unsigned char *pix, *pp, ucp;440 454 int zmm=1; 441 int npx, npy, nppx, nppy , nszp, oszp;455 int npx, npy, nppx, nppy; 442 456 int i,j,k,l; 443 double vpx;444 457 445 458 /* … … 448 461 */ 449 462 450 if ( (XSize() <= 0) || (YSize() <= 0) || (lut == NULL) || (ofx < 0) || (ofy < 0) ) 451 { *oxsp = *oysp = 0; return(NULL); } 463 if ( (XSize() <= 0) || (YSize() <= 0) || (lut == NULL) || (ofx < 0) || (ofy < 0) ) { 464 pixc.DeAlloc(); return; 465 } 452 466 453 467 npx = XSize()-ofx; … … 471 485 } 472 486 473 oszp = (*oxsp)*(*oysp); 474 nszp = nppx*nppy; 475 if ( oszp != nszp ) 476 { 477 if (opix) delete[] opix; 478 pix = new unsigned char[nppx*nppy]; 479 if (pix == NULL) { *oxsp = *oysp = 0; ; return(NULL); } 480 } 481 else pix = opix; 482 *oxsp = nppx; *oysp = nppy; 483 487 488 /* printf("Debug_ComputePixmap %d %d %d (%d-%d %d-%d)\n", 489 ofx, ofy, zm, npx,nppx, npy,nppy); */ 490 if (lut->NCol() <= 256) { // On fait un pixmap de type Byte/pixel 484 491 /* 485 printf("Debug_ComputePixmap %d %d %d (%d-%d %d-%d)\n", 486 ofx, ofy, zm, npx,nppx, npy,nppy); 487 */ 488 489 pp = pix; 492 printf("Debug_ComputePixmap- pixc.AllocateByte() type=%d - %d %d %d - %d %d %d - %d %d %d \n", 493 lut->Type(), 494 lut->ApplyFast(0.), lut->ApplyFast(1.), lut->ApplyFast(2.), 495 lut->ApplyRGB(0.), lut->ApplyRGB(1.), lut->ApplyRGB(2.), 496 lut->Apply(0.), lut->Apply(1.), lut->Apply(2.)); 497 */ 498 unsigned char *pp, ucp; 499 pixc.AllocateByte(nppx, nppy); 500 pp = pixc.BytePointer(); 490 501 if (eXY) { // Echange Axe X,Y 491 502 if (zm == 1) { // Pas de zoom … … 497 508 } 498 509 else if (zm < -1) { // Compression 499 double fv = (double)(zmm*zmm);500 510 for(j=ofy; j<ofy+npy; j+=zmm) 501 for(i=ofx; i<ofx+npx; i+=zmm) { 502 vpx = 0; 503 for(l=0; l<zmm; l++) 504 for(k=0; k<zmm; k++) 505 vpx += this->Value( (j+l)*sgnX+offX, (i+k)*sgnY+offY); 506 *pp = (unsigned char) lut->ApplyFast(vpx/fv); 511 for(i=ofx; i<ofx+npx; i+=zmm) { 512 *pp = lut->ApplyFast( MeanVal(j*sgnX+offX, (j+zmm-1)*sgnX+offX, 513 i*sgnY+offY, (i+zmm-1)*sgnY+offY) ); 507 514 pp++; 508 515 } 509 516 } 510 517 else { // Agrandissement … … 513 520 ucp = (unsigned char) lut->ApplyFast(this->Value(j*sgnX+offX, i*sgnY+offY)); 514 521 for(l=0; l<zm; l++) { 515 pp = pix +((j-ofy)*zm+l)*nppx+((i-ofx)*zm);522 pp = pixc.BytePointer()+((j-ofy)*zm+l)*nppx+((i-ofx)*zm); 516 523 for(k=0; k<zm; k++) { *pp = ucp; pp++; } 517 524 } … … 528 535 } 529 536 else if (zm < -1) { // Compression 530 double fv = (double)(zmm*zmm);531 537 for(j=ofy; j<ofy+npy; j+=zmm) 532 538 for(i=ofx; i<ofx+npx; i+=zmm) { 533 vpx = 0; 534 for(l=0; l<zmm; l++) 535 for(k=0; k<zmm; k++) 536 vpx += this->Value( (i+k)*sgnX+offX, (j+l)*sgnY+offY); 537 *pp = (unsigned char) lut->ApplyFast(vpx/fv); 539 *pp = lut->ApplyFast( MeanVal(i*sgnX+offX, (i+zmm-1)*sgnX+offX, 540 j*sgnY+offY, (j+zmm-1)*sgnY+offY) ); 538 541 pp++; 539 542 } 540 543 } 541 544 else { // Agrandissement … … 544 547 ucp = (unsigned char) lut->ApplyFast(this->Value(i*sgnX+offX, j*sgnY+offY)); 545 548 for(l=0; l<zm; l++) { 546 pp = pix +((j-ofy)*zm+l)*nppx+((i-ofx)*zm);549 pp = pixc.BytePointer()+((j-ofy)*zm+l)*nppx+((i-ofx)*zm); 547 550 for(k=0; k<zm; k++) { *pp = ucp; pp++; } 548 551 } … … 550 553 } 551 554 } 552 return(pix); 555 } // ---- Fin pixmap de type Byte 556 else { // On fait un pixmap de type short/pixel 557 // printf("Debug_ComputePixmap- pixc.AllocateShort() \n"); 558 unsigned short *pp, ucp; 559 pixc.AllocateShort(nppx, nppy); 560 pp = pixc.ShortPointer(); 561 if (eXY) { // Echange Axe X,Y 562 if (zm == 1) { // Pas de zoom 563 for(j=ofy; j<ofy+npy; j++) 564 for(i=ofx; i<ofx+npx; i++) { 565 *pp = lut->ApplyFast(this->Value(j*sgnX+offX, i*sgnY+offY)); pp++; 566 } 567 } 568 else if (zm < -1) { // Compression 569 for(j=ofy; j<ofy+npy; j+=zmm) 570 for(i=ofx; i<ofx+npx; i+=zmm) { 571 *pp = lut->ApplyFast( MeanVal(j*sgnX+offX, (j+zmm-1)*sgnX+offX, 572 i*sgnY+offY, (i+zmm-1)*sgnY+offY) ); 573 pp++; 574 } 575 } 576 else { // Agrandissement 577 for(j=ofy; j<ofy+npy; j++) 578 for(i=ofx; i<ofx+npx; i++) { 579 ucp = lut->ApplyFast(this->Value(j*sgnX+offX, i*sgnY+offY)); 580 for(l=0; l<zm; l++) { 581 pp = pixc.ShortPointer()+((j-ofy)*zm+l)*nppx+((i-ofx)*zm); 582 for(k=0; k<zm; k++) { *pp = ucp; pp++; } 583 } 584 } 585 } 586 } // Fin du cas avec echange d'axe X/Y 587 else { 588 if (zm == 1) { // Pas de zoom 589 for(j=ofy; j<ofy+npy; j++) 590 for(i=ofx; i<ofx+npx; i++) { 591 *pp = lut->ApplyFast(this->Value(i*sgnX+offX, j*sgnY+offY)); pp++; 592 } 593 } 594 else if (zm < -1) { // Compression 595 for(j=ofy; j<ofy+npy; j+=zmm) 596 for(i=ofx; i<ofx+npx; i+=zmm) { 597 *pp = lut->ApplyFast( MeanVal(i*sgnX+offX, (i+zmm-1)*sgnX+offX, 598 j*sgnY+offY, (j+zmm-1)*sgnY+offY) ); 599 pp++; 600 } 601 } 602 else { // Agrandissement 603 for(j=ofy; j<ofy+npy; j++) 604 for(i=ofx; i<ofx+npx; i++) { 605 ucp = lut->ApplyFast(this->Value(i*sgnX+offX, j*sgnY+offY)); 606 for(l=0; l<zm; l++) { 607 pp = pixc.ShortPointer()+((j-ofy)*zm+l)*nppx+((i-ofx)*zm); 608 for(k=0; k<zm; k++) { *pp = ucp; pp++; } 609 } 610 } 611 } 612 } 613 } // ---- Fin pixmap de type Byte 614 615 return; 553 616 } 554 617 -
trunk/SophyaPI/PI/parradapter.h
r4077 r4083 9 9 #include "machdefs.h" 10 10 #include "lut.h" 11 #include "pipixutils.h" 11 12 12 13 #include <string> … … 54 55 virtual void DefineXYCoordinates(double x0, double y0, double dx, double dy); 55 56 // Doit etre defini par les classes derivees 56 virtual double Value(int ix, int iy) = 0; 57 virtual double Value(int ix, int iy) = 0; 58 // Peut etre redefini pour les classes derivees, pour une optimisation par exemple 59 virtual double MeanVal(int ix1, int ix2, int jy1, int jy2); 57 60 58 61 virtual void XYfromxy(int ix, int iy, double& x, double& y); … … 89 92 90 93 // Calcul pixmap avec un LUT 91 virtual unsigned char * ComputePixmap(LUT* lut, int ofx, int ofy, int zm, 92 int xwsz, int ywsz, unsigned char * opix, 93 int * oxsp, int * oysp); 94 virtual void ComputePixmap(LUT* lut, int ofx, int ofy, int zm, 95 int xwsz, int ywsz, PIPixColIdx & pixc); 94 96 95 97 // Methode de decodage des options - Implementation par defaut ne fait rien … … 109 111 }; 110 112 113 // Adaptateur de tableau 1D pour pointeur de type T * 114 111 115 template <class T> 112 116 class P1DAdapter : public P1DArrayAdapter { … … 126 130 127 131 132 // Adaptateur de tableau 2D pour pointeur de type T * 128 133 template <class T> 129 134 class P2DAdapter : public P2DArrayAdapter { … … 134 139 135 140 virtual ~P2DAdapter() { if ( (aDel) && (mData) ) delete[] mData; } 136 virtual double 141 virtual double Value(int ix, int iy) 137 142 { if ( (ix < 0) || (iy < 0) || (ix >= sX) || (iy >= sY) ) return(0.); 138 143 return(mData[ix+iy*sX]); } 144 virtual double MeanVal(int ix1, int ix2, int jy1, int jy2) 145 { 146 int ec; 147 if (ix1>ix2) { ec=ix1; ix1=ix2; ix2=ec; } 148 if (jy1>jy2) { ec=jy1; jy1=jy2; jy2=ec; } 149 double ss = 0.; 150 for(int j=jy1; j<=jy2; j++) 151 for(int i=ix1; i<=ix2; i++) ss += (double)(mData[i+j*sX]); 152 ss /= (double)((jy2-jy1+1)*(ix2-ix1+1)); 153 return ss; 154 } 155 139 156 protected : 140 157 bool aDel; … … 142 159 }; 143 160 161 // Adaptateur de tableau 2D pour tableau RGB 162 163 class P2DPixRGBAdapter : public P2DArrayAdapter { 164 public : 165 P2DPixRGBAdapter(PIPixRGBArray * rgbp, bool ad=false) : 166 P2DArrayAdapter(rgbp->XSize(), rgbp->YSize() ) 167 { aDel = ad; mPix = rgbp; } 168 virtual ~P2DPixRGBAdapter() { if ( (aDel) && (mPix) ) delete mPix; } 169 170 virtual double Value(int ix, int iy) 171 { 172 if ( (ix < 0) || (iy < 0) || (ix >= sX) || (iy >= sY) ) return(0.); 173 PIPixRGB rgb = (*mPix)(ix, iy); 174 return ( ((double)rgb.blue*256.+(double)rgb.green)*256.+(double)rgb.red ); 175 } 176 virtual double MeanVal(int ix1, int ix2, int jy1, int jy2) 177 { 178 int ec; 179 if (ix1>ix2) { ec=ix1; ix1=ix2; ix2=ec; } 180 if (jy1>jy2) { ec=jy1; jy1=jy2; jy2=ec; } 181 int r = 0; 182 int g = 0; 183 int b = 0; 184 for(int j=jy1; j<=jy2; j++) 185 for(int i=ix1; i<=ix2; i++) { 186 PIPixRGB rgb = (*mPix)(i, j); 187 r += rgb.red; g += rgb.green; b += rgb.blue; 188 } 189 int n = (jy2-jy1+1)*(ix2-ix1+1); 190 r /= n; g /= n; b /= n; 191 return ( ((double)b*256.+(double)g)*256.+(double)r ); 192 } 193 194 protected : 195 bool aDel; 196 PIPixRGBArray* mPix; 197 }; 198 144 199 145 200 -
trunk/SophyaPI/PI/pi3dwdg.cc
r4077 r4083 224 224 double ymin = mBDrw->ScaleY( mBDrw->YMin3() ); 225 225 double ymax = mBDrw->ScaleY( mBDrw->YMax3() ); 226 double zmin = mBDrw->Scale Y( mBDrw->ZMin3() );227 double zmax = mBDrw->Scale Y( mBDrw->ZMax3() );226 double zmin = mBDrw->ScaleZ( mBDrw->ZMin3() ); 227 double zmax = mBDrw->ScaleZ( mBDrw->ZMax3() ); 228 228 bool asxy = mBDrw->isAutoScaleXY(); 229 229 bool asz = mBDrw->isAutoScaleZ(); -
trunk/SophyaPI/PI/piapplgen.cc
r4077 r4083 54 54 #include "sopnamsp.h" 55 55 #include "piapplgen.h" 56 #include <stdlib.h> 57 #include <iostream> 58 #include "pidrawer.h" 56 59 57 60 // Variable qui contient le pointeur de l'application courante … … 62 65 :topcont(NULL), menubar(NULL), mState(0) 63 66 { 64 curapp = this; 67 curapp = this; 68 // Si la variable d'environnement PIDEFAFSZFRAC est definie, on modifie 69 // la taille par defaut de AutoFontSizeFrac 70 char *envafsz = getenv("PIDEFAFSZFRAC"); 71 if (envafsz) { 72 double fsfr = atof(envafsz); 73 if ((fsfr>0.)&&(fsfr<1.)) { 74 PIDrawer::SetGlDefAutoFontSizeFrac(fsfr); 75 cout << " PIApplicationGen()/Info: getenv(PIDEFAFSZFRAC)=" << envafsz << endl; 76 cout << " ... Set Global Default PIDrawer AutoFontSizeFrac to " 77 << PIDrawer::GetGlDefAutoFontSizeFrac() << endl; 78 } 79 } 65 80 } 66 81 -
trunk/SophyaPI/PI/piapplx.cc
r4077 r4083 43 43 class PITopContAppX : public PIContainer { 44 44 public : 45 PITopContAppX(PIContainer *par, c har *nom, PIWdg* topw,45 PITopContAppX(PIContainer *par, const char *nom, PIWdg* topw, 46 46 int sx=10, int sy=10, int px=0, int py=0); 47 47 virtual ~PITopContAppX(); … … 55 55 56 56 /* --Methode-- */ 57 PITopContAppX::PITopContAppX(PIContainer *par, c har *nom, PIWdg* topw, int sx, int sy, int px, int py)57 PITopContAppX::PITopContAppX(PIContainer *par, const char *nom, PIWdg* topw, int sx, int sy, int px, int py) 58 58 : PIContainer(par, nom, (sx>10)?sx:10, (sy>10)?sy:10, px, py) 59 59 { … … 144 144 if (sx < sxt) sx = sxt; 145 145 if (sy < 10) sy = 10; 146 topcont = new PITopContAppX(MBCont(), "TopLevelCont", topwdg, 147 sx, sy, 0, msy); 146 topcont = new PITopContAppX(MBCont(), "TopLevelCont", topwdg,sx, sy, 0, msy); 148 147 MBCont()->Show(); 149 148 //DBG printf("PIApplicationX-DBG2:: MBContSize=%d %d \n", MBCont()->XSize(), MBCont()->YSize()); … … 289 288 { 290 289 int szf; 290 printf("XtAppContext* PIXtAppCtx :szx=%d szy=%d szf=%d\n",szx,szy,szf); 291 291 PIXtAppCtx(szx, szy, szf); 292 printf("XtAppContext* PIXtAppCtx :szx=%d szy=%d szf=%d\n",szx,szy,szf); 292 293 return; 293 294 } -
trunk/SophyaPI/PI/piaxes.cc
r4077 r4083 11 11 #include <math.h> 12 12 #include "piaxes.h" 13 #include "pidrawer.h" 13 14 14 15 //++ … … 41 42 { 42 43 ConfigureTicks(); 43 ConfigureAutoFontSize( );44 ConfigureAutoFontSize(true, PIDrawer::GetGlDefAutoFontSizeFrac()); 44 45 ConfigureAxesCenter(); 45 46 setupDone = false; … … 53 54 //++ 54 55 // void DrawXYAxes(PIGraphicUC* g, PIGraphicAtt& gratt, \ 55 // unsigned int flags =kAxesDflt, bool afsz=true)56 // unsigned int flags, bool afsz, double fszf) 56 57 // Trace les axes en utilisant les limites de l'objet PIGraphicUC. 57 58 // "flags" spécifie les attributs d'axes. Constantes prédéfinies: … … 64 65 //| kBoxAxes | kTicks | | kIntTicks | kLabels 65 66 //| kGridOn, kAxesNone 66 // Si "afsz == true", la taille de fonte est choisie automatiquement. 67 // Si "afsz == true", la taille de fonte est choisie automatiquement avec "fszf" 68 // representant la taille de fonte en fraction de (ymax-ymin) 69 // 70 // void DrawXYAxes(PIGraphicUC* g, PIGraphicAtt& gratt, unsigned int flags=kAxesDflt) 71 // Appel de DrawXYAxes avec les parametres "axesAFSz. fontSz" de l'objet. 67 72 // 68 73 // void DrawXYAxes(PIGraphicUC* g, PIGraphicAtt& gratt, \ 69 74 // double xmin, double xmax, double ymin, double ymax, \ 70 // unsigned int flags =kAxesDflt, bool afsz=true)75 // unsigned int flags, bool afsz, double ) 71 76 // Tracé d'axes avec spécification des limites d'axes. 77 // 78 // void DrawXYAxes(PIGraphicUC* g, PIGraphicAtt& gratt, \ 79 // double xmin, double xmax, double ymin, double ymax, unsigned int flags=kAxesDflt) 80 // Appel de DrawXYAxes avec les parametres "axesAFSz. fontSz" de l'objet. 72 81 // 73 82 // void DrawXCaption(PIGraphicUC* g, string const& xLabel, PIGraphicAtt const& att) … … 79 88 /* --Methode-- */ 80 89 void PIAxes::DrawXYAxes(PIGraphicUC* g, PIGraphicAtt& gratt, 81 unsigned int flags, bool afsz )90 unsigned int flags, bool afsz, double fszf) 82 91 { 83 92 PIGrCoord xmin, xmax, ymin, ymax; 84 93 g->GetGrSpace(xmin, xmax, ymin, ymax); 85 94 DrawXYAxes(g, gratt, (double)xmin, (double)xmax, 86 (double)ymin, (double)ymax, flags, afsz );95 (double)ymin, (double)ymax, flags, afsz, fszf); 87 96 } 88 97 … … 90 99 void PIAxes::DrawXYAxes(PIGraphicUC* g, PIGraphicAtt& gratt, 91 100 double xmin, double xmax, double ymin, double ymax, 92 unsigned int flags, bool afsz )101 unsigned int flags, bool afsz, double fszf) 93 102 94 103 { … … 107 116 108 117 if(afsz) { 109 double fsz = (yMax-yMin)*f ontSz;118 double fsz = (yMax-yMin)*fszf; 110 119 g->SelFontSz(fsz); 111 120 } … … 314 323 // (X/Y max-min). Les paramètres ne sont pas changés si des valeurs 315 324 // négatives ou nulles sont spécifiées. 316 // void ConfigureAutoFontSize( double fszf=0.0125)317 // Configuration de la taille de fonte, en mode AutoFontSize .325 // void ConfigureAutoFontSize(bool afsz=true, double fszf=0.04) 326 // Configuration de la taille de fonte, en mode AutoFontSize ou FixedFontSize. 318 327 // La taille est exprimée en fraction de la taille totale YMax-Min 319 328 // void ConfigureAxesCenter(bool fset,double x0,double y0) … … 332 341 333 342 /* --Methode-- */ 334 void PIAxes::ConfigureAutoFontSize(double fszf) 335 { 343 void PIAxes::ConfigureAutoFontSize(bool afsz, double fszf) 344 { 345 axesAFSz = afsz; 336 346 if (fszf > 1.e-19) fontSz = fszf; 337 347 } … … 420 430 //Attention erreur d'arrondi x->0 (on code 5.1698e-26 au lieu de 0) 421 431 double xx = (fabs(xticks[i]/xstep)<1.e-5) ? 0.: xticks[i]; 422 sprintf(label,format.c_str(),xx/fac); Arrange_Label(label); 432 double dog = fabs(xx/fac); 433 if ((dog<=1.e-5)||(dog>=1.e5)) 434 sprintf(label,"%le",xx/fac); 435 else 436 sprintf(label,format.c_str(),xx/fac); 437 Arrange_Label(label); 423 438 double largeur = g->CalcStringWidth(label); 424 439 g->DUC2GrC(largeur,0.,largpix,dum); … … 463 478 if(yticks[i]>yMax) break; 464 479 double yy = (fabs(yticks[i]/ystep)<1.e-5) ? 0.: yticks[i]; 465 sprintf(label,format.c_str(),yy/fac); Arrange_Label(label); 480 double dog = fabs(yy/fac); 481 if ((dog<=1.e-5)||(dog>=1.e5)) 482 sprintf(label,"%le",yy/fac); 483 else 484 sprintf(label,format.c_str(),yy/fac); 485 Arrange_Label(label); 466 486 g->UC2GrC(x,yticks[i],dum,ypixdeb); ypixdeb -= hautpix/2.; 467 487 // -- Attention: ypix=0 est en haut de l'ecran … … 478 498 if(npuiss!=0) { 479 499 if(aYdir) hauteur = -hauteur; 480 double ym = (aYdir)? yMin: yMax; ym = g->DeltaUCY(ym,0. 5*hauteur);500 double ym = (aYdir)? yMin: yMax; ym = g->DeltaUCY(ym,0.25*hauteur); 481 501 sprintf(label,"%d",npuiss); 482 502 g->DrawCompString(x,ym,"x 10",label,NULL,PI_VerticalBottom|just); -
trunk/SophyaPI/PI/piaxes.h
r4077 r4083 40 40 41 41 virtual void DrawXYAxes(PIGraphicUC* g, PIGraphicAtt& gratt, 42 unsigned int flags=kAxesDflt, bool afsz=true); 42 unsigned int flags, bool afsz, double fszf); 43 inline void DrawXYAxes(PIGraphicUC* g, PIGraphicAtt& gratt, unsigned int flags=kAxesDflt) 44 { DrawXYAxes(g, gratt, flags, axesAFSz, fontSz); } 43 45 44 46 virtual void DrawXYAxes(PIGraphicUC* g, PIGraphicAtt& gratt, 45 47 double xmin, double xmax, 46 48 double ymin, double ymax, 47 unsigned int flags=kAxesDflt, bool afsz=true); 48 49 unsigned int flags, bool afsz, double fszf); 50 inline void DrawXYAxes(PIGraphicUC* g, PIGraphicAtt& gratt, 51 double xmin, double xmax, double ymin, double ymax, unsigned int flags=kAxesDflt) 52 { DrawXYAxes(g, gratt, xmin, xmax, ymin, ymax, flags, axesAFSz, fontSz); } 49 53 50 54 virtual void DrawXCaption(PIGraphicUC* g, PIGraphicAtt& att, unsigned int flags, … … 56 60 void ConfigureTicks(int ntickx=10, int nticky=12, 57 61 double majtl=0.016, double mintl=0.01); 58 void ConfigureAutoFontSize(double fszf=0.04); 62 // Choix de taille automatique de fontes 63 void ConfigureAutoFontSize(bool afsz=true, double fszf=0.04); 59 64 void ConfigureAxesCenter(bool fset=false,double x0=0.,double y0=0.); 60 65 … … 91 96 bool aXdir, aYdir; // Sens des axes horiz, vertical 92 97 bool aXlog, aYlog; // Echelle log pour les axes horiz, vertical 93 bool axesAFSz; 98 bool axesAFSz; // true -> AutoFontSize 94 99 95 100 int xNTicks, yNTicks; // Nb de ticks en X, Y -
trunk/SophyaPI/PI/piaxestools.cc
r4077 r4083 237 237 mCkb[3]->SetState(scd->isLogScaleX()); 238 238 mCkb[4]->SetState(scd->isLogScaleY()); 239 mCkb[7]->SetState(scd->BaseDrawer()-> isAxesAutoFontSize());239 mCkb[7]->SetState(scd->BaseDrawer()->GetAutoFontSizeState()); 240 240 } 241 241 else { … … 312 312 313 313 scd->SetLogScale(mCkb[3]->GetState(), mCkb[4]->GetState() ); 314 scd->BaseDrawer()-> SetAxesAutoFontSize(mCkb[7]->GetState());314 scd->BaseDrawer()->ConfigureAutoFontSize(mCkb[7]->GetState(), -1); 315 315 if (refr) scd->Refresh(); 316 316 return; -
trunk/SophyaPI/PI/pibwdgx.cc
r4077 r4083 39 39 CreateXtWdg(nom, piXtBaseWidgetClass, NULL, sx, sy, px, py); 40 40 41 XtSetArg(wargs[0], PIXNobject,this);41 XtSetArg(wargs[0],const_cast<char*>(PIXNobject),this); 42 42 XtSetArg(wargs[1],XtNbackground, colpixwhite); 43 43 XtSetArg(wargs[2],XtNborderWidth, (Dimension)0); … … 72 72 #endif 73 73 Arg wargs[2]; 74 XtSetArg(wargs[0],PIXNobject,NULL);74 XtSetArg(wargs[0],const_cast<char*>(PIXNobject),NULL); 75 75 XtSetValues(XtWdg(), wargs, 1); 76 76 } -
trunk/SophyaPI/PI/picmap.cc
r4077 r4083 6 6 #include "picmap.h" 7 7 #include <iostream> 8 8 9 9 10 //++ … … 24 25 //-- 25 26 26 #define MXMAPIDS 3 027 #define MXMAPIDS 34 27 28 static int MapNCols[MXMAPIDS] = { 28 29 256, 256, 256, 256, 256, 256, 256, 256, 256, 256, 29 30 256, 256, 256, 256, 256, 256, 256, 256, 256, 256, 30 256, 256, 256, 256, 256, 256, 256, 256, 256, 256 }; 31 256, 256, 256, 256, 256, 256, 256, 256, 256, 256, 32 216, 512, 4096, 32768 }; 31 33 32 34 // Tables de couleurs : … … 37 39 // 1 Standard PI 64 couleurs differentes 38 40 // 1 Standard PI 16 couleurs 41 // 1 Standard PI , 216 couleurs RGB (6x6x6) 42 // 1 Standard PI , 512 couleurs RGB (8x8x8) 43 // 1 Standard PI , 4096 couleurs RGB (16x16x16) 44 // 1 Standard PI , 32768 couleurs RGB (32x32x32) 39 45 40 46 static const char* MapNoms[MXMAPIDS] = { … … 47 53 "MIDAS_Stairs9","MIDAS_StairCase","MIDAS_Color", 48 54 "MIDAS_ManyCol","MIDAS_Idl14","MIDAS_Idl15", 49 "MultiCol16","MultiCol64"}; 55 "MultiCol16","MultiCol64", 56 "RGB216CM","RGB512CM","RGB4096CM","RGB32768CM"}; 50 57 51 58 static CMapId MapIds[MXMAPIDS] = { … … 58 65 CMAP_MIDAS_Stairs9, CMAP_MIDAS_StairCase, CMAP_MIDAS_Color, 59 66 CMAP_MIDAS_ManyCol, CMAP_MIDAS_Idl14, CMAP_MIDAS_Idl15, 60 CMAP_COL16, CMAP_COL64 } ; 67 CMAP_COL16, CMAP_COL64, 68 CMAP_RGB216, CMAP_RGB512, CMAP_RGB4096, CMAP_RGB32768} ; 61 69 62 70 static int mColTNums[8192]; // Max 8192 tables differentes pour le moment … … 70 78 NULL, NULL, NULL, NULL, NULL, 71 79 NULL, NULL, NULL, NULL, NULL, 72 NULL, NULL, NULL, NULL, NULL }; 80 NULL, NULL, NULL, NULL, NULL, 81 NULL, NULL, NULL, NULL }; 73 82 74 83 int PIColorMap::NumberStandardColorMaps() … … 122 131 //| CMAP_COL64 : 64 Couleurs arcenciel 123 132 //| CMAP_OTHER : Table non standard 133 //| CMAP_RGB216 : 216 couleurs, 6x6x6 couleurs en composantes RGB 134 //| CMAP_RGB512 : 512 couleurs, 8x8x8 couleurs en composantes RGB 135 //| CMAP_RGB4096 : 4096 couleurs, 16x16x16 couleurs en composantes RGB 136 //| CMAP_RGB4096 : 32768 couleurs, 32x32x32 couleurs en composantes RGB 137 124 138 // Toutes les tables de couleurs standard possèdent 256 cellules de couleurs, 125 // contenant 16 ou 32 ou 128 couleurs distinctes. 139 // contenant 16 ou 32 ou 128 (ou 216) couleurs distinctes, 140 // sauf CMAP_RGB512 , CMAP_RGB4096 et CMAP_RGB32768. 126 141 // 127 142 // PIColorMap(string const& nom, int nCol) … … 144 159 145 160 if (NMaxTableAuto == 0) { // Il faut allouer les tables de depart 146 if ( TotNbColors() > 4096 ) NMaxTableAuto = MXMAPIDS-1; 161 if ( TotNbColors() >= 4096 ) NMaxTableAuto = MXMAPIDS-2; 162 if ( TotNbColors() >= 65536 ) NMaxTableAuto = MXMAPIDS-1; 147 163 else NMaxTableAuto = 3; 148 164 // for(k=0; k<NMaxTableAuto; k++) { … … 158 174 for(kdx=0; kdx<MXMAPIDS; kdx++) if (id == MapIds[kdx]) break; 159 175 if (kdx == MXMAPIDS) { id = MapIds[0]; kdx = 0; } 160 for(k=0; k< NMaxTableAuto; k++) {176 for(k=0; k<=NMaxTableAuto; k++) { 161 177 if ((MapIds[k] == id) && (mMaps[k] == NULL)) { // Table pas encore alloue 162 178 mnom = MapNoms[k]; … … 176 192 if ( mMaps[k] ) { 177 193 mColTNums[mMaps[k]->mCTId] = 1; // Je force a liberer les couleurs 178 delete mMaps[k] ; 194 delete mMaps[k] ; mMaps[k] = NULL; 195 mnom = MapNoms[k]; 196 cout << " PIColorMap::PIColorMap(CMapId id) Freeing colors for ColorMap " 197 << mnom << " ... " << endl; 179 198 } 180 199 mnom = MapNoms[kdx]; 200 cout << " PIColorMap::PIColorMap(CMapId id) Allocating ColorMap " 201 << mnom << " ... " << endl; 181 202 mMaps[k] = new PIColorMap(MapIds[kdx], MapNCols[kdx], mnom); 182 203 } … … 563 584 } 564 585 break; 586 587 case CMAP_RGB216 : 588 i = 0; 589 for(int kb=0; kb<6; kb++) { 590 mycol.blue = (unsigned short)(kb*65535/5); 591 for(int jg=0; jg<6; jg++) { 592 mycol.green = (unsigned short)(jg*65535/5); 593 for(int ir=0; ir<6; ir++) { 594 mycol.red = (unsigned short)(ir*65535/5); 595 AllocColor(mycol, i); i++; 596 } 597 } 598 } 599 mycol.blue = mycol.green = mycol.red = 65535; 600 for(i=216; i<256; i++) 601 AllocColor(mycol, i); 602 break; 603 604 case CMAP_RGB512 : 605 case CMAP_RGB4096 : 606 case CMAP_RGB32768 : 607 { 608 int nlev = 8; 609 if (mType == CMAP_RGB4096) nlev = 16; 610 else if (mType == CMAP_RGB32768) nlev = 32; 611 int drgb = 65535/(nlev-1); 612 i = 0; 613 for(int kb=0; kb<nlev; kb++) { 614 mycol.blue = (unsigned short)(kb*drgb); 615 for(int jg=0; jg<nlev; jg++) { 616 mycol.green = (unsigned short)(jg*drgb); 617 for(int ir=0; ir<nlev; ir++) { 618 mycol.red = (unsigned short)(ir*drgb); 619 AllocColor(mycol, i); i++; 620 } 621 } 622 } 623 } 624 break; 625 565 626 //---------------------------------------------------------- 566 627 //---------------------------------------------------------- -
trunk/SophyaPI/PI/picmap.h
r4077 r4083 47 47 48 48 // Table simple a 16/64 couleurs 49 CMAP_COL16 = 998, // 16 Couleurs arcenciel 50 CMAP_COL64 = 999 // 64 Couleurs differentes 49 CMAP_COL16 = 991, // 16 Couleurs arcenciel 50 CMAP_COL64 = 992, // 64 Couleurs differentes 51 // Table de couleurs RGB 6x6x6=216 couleurs 52 CMAP_RGB216 = 993, // 216 couleurs avec toutes les nuances RGB 53 CMAP_RGB512 = 994, // 512 couleurs avec toutes les nuances RGB 54 CMAP_RGB4096 = 995, // 4096 couleurs avec toutes les nuances RGB 55 CMAP_RGB32768 = 996 // 32768 couleurs avec toutes les nuances RGB 51 56 }; 52 57 -
trunk/SophyaPI/PI/picmapview.cc
r4077 r4083 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 //++ … … 79 81 if ( cmap && (cmp->Type() == cmap->Type()) && (cmp->Type() != CMAP_OTHER) 80 82 && (cmp->IsColorIndexReversed() == cmap->IsColorIndexReversed()) 81 && (fabs(vmin-min) < 1.e-69) && (fabs(vmax-max) > -1.e-69) ) return; 83 && (fabs(vmin-min) < 1.e-69) && (fabs(vmax-max) > -1.e-69) ) { 84 if (refr) Refresh(); 85 return; 86 } 82 87 if (cmap) delete cmap; 83 88 cmap = new PIColorMap(*cmp); … … 93 98 (cmap->IsColorIndexReversed() == revidx) && 94 99 ((vmin-min) < 1.e-69) && ((vmin-min) > -1.e-69) && 95 ((vmax-max) < 1.e-69) && ((vmax-max) > -1.e-69) ) return; 100 ((vmax-max) < 1.e-69) && ((vmax-max) > -1.e-69) ) { 101 if (refr) Refresh(); 102 return; 103 } 96 104 if (cmap) delete cmap; 97 105 cmap = new PIColorMap(cmapid); … … 117 125 118 126 int k; 127 // On limite le nombre de carres de couleurs traces, si trop de couleur ... 128 int dk = cmap->NCol()/128; 129 if (dk<1) dk=1; 119 130 if (sx > sy) { // horizontal 120 131 int xc, dx; 121 132 xc = 0; 122 for(k=0; k<cmap->NCol(); k+ +) {123 dx = (sx-xc)/(cmap->NCol()-k);133 for(k=0; k<cmap->NCol(); k+=dk) { 134 dx = dk*(sx-xc)/(cmap->NCol()-k); 124 135 g->SelForeground((*cmap), k); 125 136 g->DrawFBox(xc, 0, dx+1, sy); … … 130 141 int yc, dy; 131 142 yc = sy; 132 for(k=0; k<cmap->NCol(); k+ +) {133 dy = yc/(cmap->NCol()-k);143 for(k=0; k<cmap->NCol(); k+=dk) { 144 dy = dk*yc/(cmap->NCol()-k); 134 145 yc -= dy; 135 146 g->SelForeground((*cmap), k); … … 177 188 } 178 189 179 180 181 182 183 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
r4077 r4083 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/picmapx.cc
r4077 r4083 187 187 mColRGB = new PIColor[mNCol]; 188 188 mNewCol = new bool[mNCol]; 189 /* Remplace par memcpy pour performances, Reza, Nov 2008 189 190 for (int i=0; i<mNCol; i++) 190 191 { mColors[i] = ((PIColorMapX *)x)->mColors[i]; … … 192 193 // C'est la table de couleur originale qui est responsable de liberer les couleurs - Reza 8/2/98 193 194 mNewCol[i] = false; } 194 } 195 -> memcpy (Nov08) */ 196 memcpy(mColors, ((PIColorMapX *)x)->mColors, sizeof(PIXColor)*mNCol); 197 memcpy(mColRGB, ((PIColorMapX *)x)->mColRGB, sizeof(PIColor)*mNCol); 198 // C'est la table de couleur originale qui est responsable de liberer les couleurs - Reza 8/2/98 199 for (int i=0; i<mNCol; i++) mNewCol[i] = false; 200 } -
trunk/SophyaPI/PI/picontainergen.h
r4077 r4083 51 51 inline PILayoutMgr* GetLayoutMgr() { return(layout); } 52 52 53 54 53 virtual void PSPrint(PSFile *psf, int ofx=0, int ofy=0, 54 double scale_x=1., double scale_y=1.); 55 55 56 56 virtual void Show(); -
trunk/SophyaPI/PI/pidrawer.cc
r4077 r4083 52 52 //-- 53 53 54 // Valeur par defaut global pour TailleFonteAuto 55 double PIDrawer::glDefAFSzFrac = 0.04; 56 void PIDrawer::SetGlDefAutoFontSizeFrac(double fszf) 57 { 58 if (fszf>1.e-6) glDefAFSzFrac = fszf; 59 } 60 double PIDrawer::GetGlDefAutoFontSizeFrac() 61 { 62 return glDefAFSzFrac; 63 } 64 54 65 PIDrawer::PIDrawer() 55 66 { … … 65 76 limitsFixed = false; 66 77 SetAxesFlags(kAxesNone); // Pas de trace d'axes par defaut 67 SetAxesAutoFontSize();78 ConfigureAutoFontSize(true, glDefAFSzFrac); 68 79 69 80 mDndfg = false; // Pour controle de l'appel de Detach() si delete … … 107 118 108 119 //++ 109 // Titre Gestion des axes et des limites120 // Titre Gestion des axes, des limites et coordonnees fenetre 110 121 // Le tracé des axes 2D est pris en charge par la classe PIAxes. 111 122 //-- 112 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 // 113 132 // void SetLimits(double xmin, double xmax, double ymin, double ymax, - 114 133 // int axrl=kAxeDirSame, int ayud=kAxeDirSame) 115 // Définit les limites du système de coordonnées .134 // Définit les limites du système de coordonnées du Drawer. 116 135 //| kAxeDirSame , kAxeDirAuto 117 136 //| kAxeDirLtoR , kAxeDirRtoL (Axe X) … … 143 162 //| kMajTicks , kMinTicks , kLabels , kGridOn 144 163 //| kAxesDflt , kAxesNone 145 // void SetAxesAutoFontSize(bool fg=true)146 // Si "fg==true", la taille de la fonte p our les labels d'axes (chiffres)est164 // void ConfigureAutoFontSize(bool afsz=true, double fszf=0.05) 165 // Si "fg==true", la taille de la fonte par le drawer, est 147 166 // choisie automatiquement, en s'adaptant à la taille de la zone de tracé - 148 // sinon, taille de la fonte de l'objet PIDrawer. 167 // sinon, taille de la fonte de l'objet PIDrawer. Cette taille est donnée par 168 // FontSize=(YMax()-YMin())*(mFontSzF=fszf). "mFontSzF=fszf" n'est mis à jour 169 // que si fszf>0. Le décodage des attributs graphiques par DecodeOptionString() 170 // ("autofontsize=fszf" et "fixedfontsize") permet de modifier ces attributs de 171 // choix automtique de fonte. Utilisé en particulier par PIElDrawer pour 172 // le tracé les labels d'axes (chiffres). 149 173 // unsigned int GetAxesFlags() 150 174 // Renvoie les attributs de tracé d'axes 151 // bool isAxesAutoFontSize() 152 // Renvoie la valeur du flag de choix automatique de taille de fonte pour axes. 175 // bool GetAutoFontSizeState() 176 // Renvoie la valeur du flag de choix automatique de taille de fonte. 177 // double GetAutoFontSizeFraction() 178 // Renvoie la valeur de la fraction de taille ("mFontSzF) pour lee 179 // choix automatique de taille de fonte. 153 180 // void DrawAxes(PIGraphicUC* g) 154 181 // Méthode de tracé des axes (le tracé est pris en charge par la classe *PIAxes*) … … 395 422 PIDrawer::DecodeOptionString(vector<string> & opt, bool rmdecop) 396 423 { 397 if (opt.size() < 1) return(0); 424 int nopt0 = opt.size(); 425 if (nopt0 < 1) return(0); 398 426 PIGraphicAtt gratt; 399 int ndec = gratt.DecodeAttStrings(opt, rmdecop);427 int ndec1 = gratt.DecodeAttStrings(opt, rmdecop); 400 428 UpdateGraphicAtt(gratt); 401 return(ndec); 429 if ((nopt0 - ndec1) < 1) return(ndec1); // si tout a ete decode 430 vector<string> udopt; 431 unsigned int k = 0; 432 int ndec = opt.size(); 433 string opts; 434 for( k=0; k<opt.size(); k++ ) { 435 opts = opt[k]; 436 if (opts.substr(0,13) == "autofontsize=") { 437 double fszf = atof(opts.substr(13).c_str()); 438 ConfigureAutoFontSize(true, fszf); 439 } 440 else if (opts == "fixedfontsize") 441 ConfigureAutoFontSize(false, -1.); 442 else { 443 ndec--; 444 if (rmdecop) udopt.push_back(opts); 445 } 446 } 447 448 if (rmdecop) opt = udopt; 449 return(ndec+ndec1); 402 450 } 403 451 … … 424 472 info += " FontAtt: roman, bold, italic, bolditalic \n"; 425 473 info += " FontSize: 6,8,10,12... (pts) - integer \n"; 474 info += ">>> Automatic font size selection : \n"; 475 info += " autofontsize=FontSizeFrac fixedfontsize \n"; 476 info += ">>> ColorTables: defcmap grey32 invgrey32 colrj32 colbr32 \n"; 426 477 info += ">>> marker=MarkerType,MarkerSize (MarkerSize: integer 3,5,7... \n"; 427 478 info += " MarkerType: dot, plus, cross, circle, fcircle, box, fbox \n"; … … 505 556 PIAxes axes; 506 557 axes.DrawXYAxes(g, mGrAtt, XMin(), XMax(), YMin(), YMax(), 507 axesFlags, axesAFSz);558 axesFlags, mAFSz, mFontSzF); 508 559 g->Clip(); 509 560 } -
trunk/SophyaPI/PI/pidrawer.h
r4077 r4083 30 30 31 31 virtual void SetAxesFlags(unsigned int flags=kAxesNone); 32 inline void SetAxesAutoFontSize(bool fg=true) { axesAFSz = fg; } 32 33 //---- Choix automatique ou pas de taille de fonte 34 inline void ConfigureAutoFontSize(bool afsz=true, double fszf=0.04) 35 { mAFSz = afsz; if (fszf>1e-5) mFontSzF = fszf; } 36 // Valeur par defaut global pour le AutoFontSizeFrac, utilise dans les constructeurs de PIDrawer 37 static void SetGlDefAutoFontSizeFrac(double fszf=0.04); 38 // Retourne la valeur globale par defaut de AutoFontSizeFrac 39 static double GetGlDefAutoFontSizeFrac(); 33 40 34 41 virtual void DrawAxes(PIGraphicUC* g); … … 53 60 virtual void HighLight(bool fgh); 54 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 55 69 inline double XMin() const {return xMin;} 56 70 inline double XMax() const {return xMax;} … … 63 77 64 78 inline unsigned int GetAxesFlags() { return(axesFlags); } 65 inline bool isAxesAutoFontSize() { return axesAFSz; } 79 80 inline bool GetAutoFontSizeState() { return mAFSz; } 81 inline double GetAutoFontSizeFraction() { return mFontSzF; } 66 82 67 83 inline PIGraphicUC* GetGraphicUC() { return(mGrUC); } … … 127 143 bool limitsFixed; 128 144 unsigned int axesFlags; 129 bool axesAFSz; 145 146 bool mAFSz; // true -> Choix automatique de taille de font en fraction (ymax-ymin) 147 double mFontSzF; // TailleFonteAuto = mFontSzF*(ymax-ymin) 148 static double glDefAFSzFrac; // Valeur globale par defaut pour mFontSzF, utilise ds le constructeur 149 130 150 PIBaseWdgGen* mBWdg; 131 151 PIGraphicUC* mGrUC; -
trunk/SophyaPI/PI/pieldrw.cc
r4077 r4083 575 575 SetAxesFlags(GetAxesFlags() & ~kMinTicks); 576 576 else if (opts == "extticks") 577 SetAxesFlags( GetAxesFlags() & ~kIntTicks| kExtTicks);577 SetAxesFlags((GetAxesFlags() & ~kIntTicks) | kExtTicks); 578 578 else if (opts == "intticks") 579 SetAxesFlags( GetAxesFlags() & ~kExtTicks| kIntTicks);579 SetAxesFlags((GetAxesFlags() & ~kExtTicks) | kIntTicks); 580 580 else if (opts == "extintticks") 581 581 SetAxesFlags(GetAxesFlags() | kIntTicks | kExtTicks); … … 593 593 } 594 594 } 595 596 else if (opts.substr(0,13) == "autofontsize=") { 597 double fszf = atof(opts.substr(13).c_str()); 598 ConfigureAxeAutoFontSize(fszf); 599 SetAxesAutoFontSize(true); 600 } 601 else if (opts == "fixedfontsize") 602 SetAxesAutoFontSize(false); 603 595 604 596 else if (opts == "title" || opts == "tit") ShowTitles(true); 605 597 else if (opts == "notitle" || opts == "notit") ShowTitles(false); … … 639 631 info += " ticks/noticks minorticks/nominorticks \n"; 640 632 info += " extticks/intticks/extintticks nbticks=X_NbTicks,Y_NbTicks \n"; 641 info += " tickslen=MajorTickLenFrac,MinorTickLenFraC \n"; 642 info += " >> Axe label font size: \n";633 info += " tickslen=MajorTickLenFrac,MinorTickLenFraC \n"; 634 info += " >> Axe labels font size: \n"; 643 635 info += " autofontsize=FontSizeFrac fixedfontsize \n"; 644 636 info += " >> Up/Down title: title tit notitle notit \n"; … … 655 647 // g->NoClip(); 656 648 axeDr.DrawXYAxes(g, mGrAtt, XMin(), XMax(), YMin(), YMax(), 657 axesFlags, axesAFSz);649 axesFlags, mAFSz, mFontSzF); 658 650 if (showAxesLabels) { 659 651 axeDr.DrawXCaption(g, labelAtt, axesFlags, xLabel); -
trunk/SophyaPI/PI/pieldrw.h
r4077 r4083 246 246 double majtl=0., double mintl=0.) 247 247 { axeDr.ConfigureTicks(ntickx, nticky, majtl, mintl); } 248 inline void ConfigureAxeAutoFontSize(double fszf=0.)249 { axeDr.ConfigureAutoFontSize(fszf); }250 248 251 249 inline PIElDrwMgr& ElDrwMgr() { return eltsMgr; } -
trunk/SophyaPI/PI/pifilechox.cc
r4077 r4083 120 120 { 121 121 XmString xmstr; 122 xmstr = XmStringLtoRCreate( (char *)path.c_str(), XmSTRING_DEFAULT_CHARSET);122 xmstr = XmStringLtoRCreate(const_cast<char*>(path.c_str()), const_cast<char*>(XmSTRING_DEFAULT_CHARSET)); 123 123 Arg warg[2]; 124 124 XtSetArg(warg[0], XmNdirectory, xmstr); … … 132 132 { 133 133 XmString xmstr; 134 xmstr = XmStringLtoRCreate( (char *)fname.c_str(), XmSTRING_DEFAULT_CHARSET);134 xmstr = XmStringLtoRCreate(const_cast<char*>(fname.c_str()), const_cast<char*>(XmSTRING_DEFAULT_CHARSET)); 135 135 Arg warg[2]; 136 136 XtSetArg(warg[0], XmNtextString, xmstr); -
trunk/SophyaPI/PI/pifontx.cc
r4077 r4083 263 263 264 264 static XtResource resources[] = { 265 { "fontFamilyName", "FontFamilyName", XtRString, sizeof(String), 265 { const_cast<char *>("fontFamilyName"), const_cast<char *>("FontFamilyName"), 266 XtRString, sizeof(String), 266 267 /*XtOffset(apd, fntFam[0])*/ 0, XtRString, const_cast<char *>("*-courier") } , 267 { "courierfontFamilyName", "CourierfontFamilyName", XtRString, sizeof(String), 268 { const_cast<char *>("courierfontFamilyName"), const_cast<char *>("CourierfontFamilyName"), 269 XtRString, sizeof(String), 268 270 sizeof(String) , XtRString, const_cast<char *>("*-courier") } , 269 { "helveticafontFamilyName", "HelveticafontFamilyName", XtRString, sizeof(String), 271 { const_cast<char *>("helveticafontFamilyName"), const_cast<char *>("HelveticafontFamilyName"), 272 XtRString, sizeof(String), 270 273 2*sizeof(String) , XtRString, const_cast<char *>("*-helvetica") } , 271 { "timesfontFamilyName", "TimesfontFamilyName", XtRString, sizeof(String), 274 { const_cast<char *>("timesfontFamilyName"), const_cast<char *>("TimesfontFamilyName"), 275 XtRString, sizeof(String), 272 276 3*sizeof(String) , XtRString, const_cast<char *>("*-times") } , 273 { "symbolfontFamilyName", "SymbolfontFamilyName", XtRString, sizeof(String), 277 { const_cast<char *>("symbolfontFamilyName"), const_cast<char *>("SymbolfontFamilyName"), 278 XtRString, sizeof(String), 274 279 4*sizeof(String) , XtRString, const_cast<char *>("*-symbol") } 275 280 }; 276 281 277 static c har * fnbi_b[4] = { "medium-r-normal", "bold-r-normal",282 static const char * fnbi_b[4] = { "medium-r-normal", "bold-r-normal", 278 283 "medium-o-normal", "bold-o-normal" }; 279 static c har * fnbo_b[4] = { NULL, NULL,284 static const char * fnbo_b[4] = { NULL, NULL, 280 285 "medium-i-normal", "bold-i-normal" }; 281 286 … … 289 294 int count,k; 290 295 Display * mdsp = PIXDisplay(); 291 char **list ;296 char **list = NULL; 292 297 293 298 for (k=0; k<5; k++) { // Recherche de la fonte pour tailles croissantes 294 299 sprintf(buff,"-%s-%s-*-%d-*-*-*-*-*-*-*", apd.fntFam[kfn], fnbi_b[jat], fntsz[isz]+k); 295 300 list = XListFonts(mdsp, buff, 10, &count); 296 XFreeFontNames(list);297 301 if ((count <= 0) && (fnbo_b[jat] != NULL)) { 302 if (list) XFreeFontNames(list); 298 303 sprintf(buff,"-%s-%s-*-%d-*-*-*-*-*-*-*", apd.fntFam[kfn], fnbo_b[jat], fntsz[isz]+k); 299 304 list = XListFonts(mdsp, buff, 10, &count); 300 XFreeFontNames(list);301 305 } 302 306 if (count > 0) break; 303 307 } 304 308 // certaines fontes n'ont pas de version bold ou italique 305 309 if ( (count == 0) && (jat > 0) ) { 306 310 for (k=0; k<5; k++) { // Recherche de la fonte pour tailles croissantes 311 if (list) XFreeFontNames(list); 307 312 sprintf(buff,"-%s-%s-*-%d-*-*-*-*-*-*-*", apd.fntFam[kfn], fnbi_b[0], fntsz[isz]+k); 308 313 list = XListFonts(mdsp, buff, 10, &count); 309 XFreeFontNames(list);310 314 if (count > 0) break; 311 }312 315 } 313 if (count > 0) 314 fntst[isz][jat][kfn] = XLoadQueryFont(mdsp, buff); 315 else 316 { printf("PIFontX::LoadFontSt/ Pb font %s - Using default \n", buff); 317 fntst[isz][jat][kfn] = defnt; } 316 } 317 if (count > 0) { 318 for (int kkk=0; kkk<count; kkk++) { 319 /* pour debug 320 printf("PIFontX::LoadFontSt/DBG - Call to XLoadFont(%s) \n", list[kkk]); 321 Font lfid=XLoadFont(mdsp,list[kkk]); 322 printf("PIFontX::LoadFontSt/DBG - Call to XQueryFont(FID=%ld) \n", (unsigned long)lfid); 323 fntst[isz][jat][kfn] = XQueryFont(mdsp, lfid); 324 printf("PIFontX::LoadFontSt/DBG - Call to XLoadQueryFont(%s) \n", list[kkk]); 325 */ 326 fntst[isz][jat][kfn] = XLoadQueryFont(mdsp, list[kkk]); 327 if (fntst[isz][jat][kfn] != NULL) break; 328 } 329 if (list) XFreeFontNames(list); 330 } 331 else { 332 if (list) XFreeFontNames(list); 333 printf("PIFontX::LoadFontSt/ Pb font %s - Using default \n", buff); 334 fntst[isz][jat][kfn] = defnt; 335 } 318 336 } 319 337 … … 342 360 XtGetApplicationResources(PIXtTopWdg(), &apd, resources, 343 361 XtNumber(resources), NULL, 0); 362 // printf("PIFontX::GlInit()-DBG- FontFamily = %s \n",apd.fntFam[0]); 363 344 364 sprintf(buff,"-%s-*-*-*-*-*-*-*-*-*-*-*-*", apd.fntFam[0]); 365 list = NULL; 345 366 list = XListFonts(mdsp, buff, 15, &count); 346 XFreeFontNames(list);347 367 if (count < 5) 348 368 { 349 369 printf("PIFontX::Init %d fonts found for %s , switching to courier\n", 350 370 count, apd.fntFam[0]); 351 apd.fntFam[0] = "*-courier"; 371 apd.fntFam[0] = const_cast<char *>("*-courier"); 372 if (list) XFreeFontNames(list); 352 373 } 353 374 sprintf(buff,"-%s-%s-*-*-*-*-12-*-*-*-*", apd.fntFam[0], fnbi_b[0]); 354 375 list = XListFonts(mdsp, buff, 10, &count); 355 XFreeFontNames(list);356 376 if (count < 1) { 377 if (list) XFreeFontNames(list); 357 378 sprintf(buff,"-*-fixed-*-*-*-*-12-*-*-*-*-*-*-*"); 358 379 list = XListFonts(mdsp, buff, 10, &count); 359 XFreeFontNames(list);360 380 if (count < 1) { 381 if (list) XFreeFontNames(list); 361 382 sprintf(buff,"fixed"); 362 383 list = XListFonts(mdsp, buff, 10, &count); 363 XFreeFontNames(list);364 384 } 365 385 if (count < 1) { 386 if (list) XFreeFontNames(list); 366 387 strcpy(buff,""); 367 388 list = XListFonts(mdsp, buff, 10, &count); 368 XFreeFontNames(list);369 389 } 370 390 } 371 391 if (count < 1) { 392 if (list) XFreeFontNames(list); 372 393 printf("PIFontX::Init/ Erreur, no font found ... \n"); 373 394 defnt = NULL; 374 } 375 else defnt = XLoadQueryFont(mdsp, buff); 376 395 //Reza+Bruno, 17 Juin 2008 - Il faut lancer une exception 396 } 397 else { 398 defnt = NULL; 399 for (int kkk=0; kkk<count; kkk++) { 400 defnt = XLoadQueryFont(mdsp, list[kkk]); 401 if (defnt != NULL) break; 402 } 403 if (list) XFreeFontNames(list); 404 } 377 405 for (i=0; i<NMAXFONTSZ; i++) 378 406 for (j=0; j<NMAXFONTATT; j++) … … 399 427 // HugeFontIndex = NMAXFONTSZ-1; 400 428 401 // printf("PIFontX:: Init()-DBG- FontIndex= %d %d %d (SzF=%d) \n",402 // SmallFontIndex, NormalFontIndex, BigFontIndex, szf);429 // printf("PIFontX::GlInit()-DBG- FontIndex= %d %d %d (SzF=%d) \n", 430 // SmallFontIndex, NormalFontIndex, HugeFontIndex, szf); 403 431 404 432 return; -
trunk/SophyaPI/PI/pigraphgen.h
r4077 r4083 17 17 18 18 #include "pilineatt.h" // Class PILineAtt 19 #include "pipixutils.h" // classes utilitaires pour pixels/RGB ... 19 20 20 21 … … 118 119 bool fgline=true); 119 120 120 virtual void DrawPixmap(PIGrCoord x, PIGrCoord y, unsigned char *pix,121 int sx, int sy, PIColorMap* cmap)= 0;121 virtual void DrawPixmap(PIGrCoord x, PIGrCoord y, PIPixColIdx & pix, 122 PIColorMap* cmap) = 0; 122 123 123 124 // Modifications attributs graphiques -
trunk/SophyaPI/PI/pigraphps.cc
r4077 r4083 324 324 325 325 /* --Methode-- */ 326 void PIGraphicPS::DrawPixmap(PIGrCoord x, PIGrCoord y, unsigned char *pix, 327 int sx, int sy, PIColorMap* cmap) 328 { 326 void PIGraphicPS::DrawPixmap(PIGrCoord x, PIGrCoord y, PIPixColIdx & pixc, PIColorMap* cmap) 327 { 328 int sx = pixc.XSize(); 329 int sy = pixc.YSize(); 329 330 if ( (sx < 1) || (sy < 1) ) return; 330 if ((pix == NULL) || (cmap == NULL)) return; 331 if(mPSOut) 332 mPSOut->Image((double)x, (double)y, (double)sx, (double)sy, sx, sy, pix, cmap); 331 if (cmap == NULL) return; 332 if(mPSOut) { 333 if (pixc.BytePointer()) 334 mPSOut->Image((double)x, (double)y, (double)sx, (double)sy, sx, sy, pixc.BytePointer(), cmap); 335 else if (pixc.ShortPointer()) 336 mPSOut->Image((double)x, (double)y, (double)sx, (double)sy, sx, sy, pixc.ShortPointer(), cmap); 337 } 333 338 return; 334 339 } -
trunk/SophyaPI/PI/pigraphps.h
r4077 r4083 38 38 virtual void DrawMarker(PIGrCoord x0, PIGrCoord y0); 39 39 virtual void DrawMarkers(PIGrCoord *x, PIGrCoord *y, int n); 40 virtual void DrawPixmap(PIGrCoord x, PIGrCoord y, unsigned char *pix, 41 int sx, int sy, PIColorMap* cmap); 40 virtual void DrawPixmap(PIGrCoord x, PIGrCoord y, PIPixColIdx & pix, PIColorMap* cmap); 42 41 43 42 // Modifications attributs graphiques -
trunk/SophyaPI/PI/pigraphuc.cc
r4077 r4083 729 729 730 730 /* --Methode-- */ 731 void PIGraphicUC::DrawPixmap(PIGrCoord x, PIGrCoord y, unsigned char *pix, 732 int sx, int sy, PIColorMap* cmap) 733 { 734 if (!mGrC) return; 735 if ( (sx < 1) || (sy < 1) ) return; 736 if ((pix == NULL) || (cmap == NULL)) return; 731 void PIGraphicUC::DrawPixmap(PIGrCoord x, PIGrCoord y, PIPixColIdx & pix, PIColorMap* cmap) 732 { 733 if (!mGrC) return; 734 if ( (pix.XSize() < 1) || (pix.YSize() < 1) ) return; 735 if (cmap == NULL) return; 737 736 double xf,yf; 738 737 UC2GrC(x, y, xf, yf); 739 mGrC->DrawPixmap(xf, yf, pix, sx, sy,cmap);738 mGrC->DrawPixmap(xf, yf, pix, cmap); 740 739 } 741 740 -
trunk/SophyaPI/PI/pigraphuc.h
r4077 r4083 78 78 bool fgline=true); 79 79 80 virtual void DrawPixmap(PIGrCoord x, PIGrCoord y, unsigned char *pix, 81 int sx, int sy, PIColorMap* cmap); 80 virtual void DrawPixmap(PIGrCoord x, PIGrCoord y, PIPixColIdx & pix, PIColorMap* cmap); 82 81 83 82 // Modifications attributs graphiques -
trunk/SophyaPI/PI/pigraphx.cc
r4077 r4083 384 384 385 385 /* --Methode-- */ 386 void PIGraphicX::DrawPixmap(PIGrCoord x, PIGrCoord y, unsigned char *pix, 387 int sx, int sy, PIColorMap* cmap) 386 void PIGraphicX::DrawPixmap(PIGrCoord x, PIGrCoord y, PIPixColIdx & pixc, PIColorMap* cmap) 388 387 { 389 388 Window xw; … … 395 394 XImage * ximg; 396 395 397 if ( (sx < 1) || (sy < 1) ) return; 398 if ((pix == NULL) || (cmap == NULL)) return; 396 int sx = pixc.XSize(); 397 int sy = pixc.YSize(); 398 if ((sx==0) || (sx==0) || (cmap == NULL)) return; 399 399 400 400 … … 406 406 pad = (depth > 8) ? 32 : 8; 407 407 ximg = XCreateImage (mdsp,DefaultVisual(mdsp,scr), 408 depth,ZPixmap,0,NULL, sx, 408 depth,ZPixmap,0,NULL, sx,sy, pad,0); 409 409 if (ximg == NULL) return; 410 410 ximg->data = new char [sy*ximg->bytes_per_line]; … … 412 412 { XFree(ximg); return; } 413 413 414 for(j=0; j<sy; j++) 415 for(i=0; i<sx; i++) 416 { XPutPixel(ximg, i, j, cmap->Color(*pix) ); pix++; } 414 if (pixc.BytePointer()) { 415 unsigned char * pix = pixc.BytePointer(); 416 for(j=0; j<sy; j++) 417 for(i=0; i<sx; i++) 418 { XPutPixel(ximg, i, j, cmap->Color(*pix) ); pix++; } 419 } 420 else if (pixc.ShortPointer()) { 421 unsigned short * pix = pixc.ShortPointer(); 422 for(j=0; j<sy; j++) 423 for(i=0; i<sx; i++) 424 { XPutPixel(ximg, i, j, cmap->Color(*pix) ); pix++; } 425 } 426 else { 427 for(j=0; j<sy; j++) 428 for(i=0; i<sx; i++) XPutPixel(ximg, i, j, 0 ); 429 } 417 430 418 431 XPutImage(mdsp, xw, DefGC(), ximg, 0, 0, (int)x, (int)y, sx, sy); -
trunk/SophyaPI/PI/pigraphx.h
r4077 r4083 38 38 virtual void DrawMarker(PIGrCoord x0, PIGrCoord y0); 39 39 virtual void DrawMarkers(PIGrCoord *x, PIGrCoord *y, int n); 40 virtual void DrawPixmap(PIGrCoord x, PIGrCoord y, unsigned char *pix, 41 int sx, int sy, PIColorMap* cmap); 40 virtual void DrawPixmap(PIGrCoord x, PIGrCoord y, PIPixColIdx & pix, PIColorMap* cmap); 42 41 43 42 // Modifications attributs graphiques -
trunk/SophyaPI/PI/piimage.cc
r4077 r4083 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; … … 128 130 cutscw = NULL; 129 131 130 gpixm = zpixm = pixm = NULL;131 xsgpxm = xszpxm = xspxm = 0;132 ysgpxm = yszpxm = yspxm = 0;133 132 lut = NULL; 134 133 offx = offy = 0; … … 145 144 146 145 mdrw = new PIElDrawer(false); 147 146 mdrw->SetAxesFlags(kAxesNone); 148 147 gvdrw = new PIElDrawer(); 149 148 AddDrawer(mdrw, true, false, false, false); … … 174 173 PIImage::~PIImage() 175 174 { 176 if (pixm) delete pixm;177 if (zpixm) delete zpixm;178 175 if (zow) 179 176 { 180 zow->SetPixmap(NULL ,0,0);177 zow->SetPixmap(NULL); 181 178 zow->EraseWindow(); 182 179 } 183 if (gpixm) delete gpixm;184 180 if (gvw) 185 181 { 186 gvw->SetPixmap(NULL ,0,0);182 gvw->SetPixmap(NULL); 187 183 gvw->EraseWindow(); 188 184 gvw->SetMsg(0); gvw->SetMsgParent(NULL); … … 256 252 xszpav = yszpav = 1; 257 253 img = pim; 258 if (gpixm) delete gpixm; 259 gpixm = NULL; 260 xsgpxm = ysgpxm = 0; 254 gpixm.DeAlloc(); 261 255 zmgv = 1; 262 256 … … 607 601 // Position du centre d'image 608 602 if (opts.substr(0,12) == "imagecenter=") { 609 int xc = XPave();610 int yc = YPave();603 /* Si on ecrit "imagecenter=34.5,55.5" ca ne marche pas CMV 29/01/2011 604 int xc = XPave(), yc = YPave(); 611 605 sscanf(opts.substr(12).c_str(),"%d,%d",&xc, &yc); 606 SetPave(xc, yc, false, true); 607 */ 608 int xc = XPave(), yc = YPave(); 609 double ddxc = xc, ddyc = yc; 610 sscanf(opts.substr(12).c_str(),"%lf,%lf",&ddxc, &ddyc); 611 xc = int(ddxc+0.00001); yc = int(ddyc+0.00001); 612 612 SetPave(xc, yc, false, true); 613 613 continue; … … 633 633 double min = Lut()->Min(); 634 634 double max = Lut()->Max(); 635 int typlut=kLutType_Lin; ; 636 if (opts.substr(4,3) == "lin") typlut=kLutType_Lin; 637 else if (opts.substr(4,3) == "log") typlut=kLutType_Log; 638 else if (opts.substr(4,3) == "exp") typlut=kLutType_Exp; 639 else if (opts.substr(4,4) == "sqrt") typlut=kLutType_Sqrt; 640 else if (opts.substr(4,6) == "square") typlut=kLutType_Square; 641 else if (opts.substr(4,3) == "rgb") { 642 typlut=kLutType_RGB; 643 min = 0; max = 255; 644 } 635 645 size_t q = opts.find(','); 636 646 if (q < opts.length()-1) 637 647 sscanf(opts.substr(q+1).c_str(),"%lg,%lg",&min, &max); 638 int typlut=kLutType_Lin; ; 639 if (opts.substr(4,3) == "lin") typlut=kLutType_Lin; 640 else if (opts.substr(4,3) == "log") typlut=kLutType_Log; 641 else if (opts.substr(4,4) == "sqrt") typlut=kLutType_Sqrt; 642 else if (opts.substr(4,6) == "square") typlut=kLutType_Square; 648 643 649 SetLut(AutoLut_No, min, max, typlut, 0, false); 644 650 continue; … … 668 674 continue; 669 675 } 676 if (opts == "showcmap") UpdateCMapDrawer(1); 677 else if (opts == "noshowcmap") UpdateCMapDrawer(0); 678 else if (opts.substr(0,9) == "showcmap=") { 679 if (opts.substr(9,2) == "no") UpdateCMapDrawer(0); 680 else if (opts.substr(9,3) == "top") UpdateCMapDrawer(1); 681 else if (opts.substr(9,5) == "right") UpdateCMapDrawer(2); 682 else if (opts.substr(9,6) == "bottom") UpdateCMapDrawer(3); 683 else if (opts.substr(9,4) == "left") UpdateCMapDrawer(4); 684 else if (opts.substr(9,5) == "horiz") UpdateCMapDrawer(1); 685 else if (opts.substr(9,4) == "vert") UpdateCMapDrawer(2); 686 else UpdateCMapDrawer(0); 687 } 688 670 689 ndec--; 671 690 udopt.push_back(opts); 672 691 } 673 692 // Set color map if requested 674 if(fgcmapid || revcmapid) SetColMapId(cmapid,revcmapid,false); 693 if(fgcmapid || revcmapid) 694 SetColMapId(cmapid,revcmapid,false); 695 675 696 // Configure axes if requested 676 697 if (confaxes) ChangeAxesConfiguration(invx, invy, exchxy, false); … … 691 712 SetLut(t_al, min_al, max_al, Lut()->Type(), ns_al, false); 692 713 } 714 693 715 return(ndec+ndec2); 694 716 } … … 724 746 { 725 747 if (!cmp) return; 748 int ncolold = 0; 749 if (cmap) ncolold = cmap->NCol(); 750 bool fgapp = false; 751 if (refr && cmp->NCol() != ncolold) { 752 fgapp = true; refr = false; 753 } 726 754 int cmapid = cmp->Type(); 727 755 if ( (cmapid == CMAP_GREY32) || (cmapid == CMAP_GREYINV32) || 728 756 (cmapid == CMAP_GREY128) || (cmapid == CMAP_GREYINV128)) mdrw->GetGraphicAtt().SetColAtt(PI_Red); 729 757 else mdrw->GetGraphicAtt().SetColAtt(PI_Turquoise); 758 if (lut) lut->SetNCol(cmp->NCol()); 730 759 PIPixmap::SetColMap(cmp, refr); 731 760 if (refr) { xcurs = ycurs = -1; } 732 761 if (zow) zow->SetColMap(cmp, refr); 733 if (gvw) gvw->SetColMap(cmp, refr); 762 if (gvw) { 763 if (cmap->NCol() != ncolold) { 764 ComputeGloVPixmap(); 765 SetGloVPixmap(); 766 } 767 else gvw->SetColMap(cmp, refr); 768 } 734 769 if (cmvw) cmvw->SetColMap(cmap, Lut()->Min(), Lut()->Max(), refr); 770 if (fgapp) Apply(); 735 771 return; 736 772 } … … 739 775 void PIImage::SetColMapId(CMapId cmapid, bool revidx, bool refr) 740 776 { 777 int ncolold = 0; 778 if (cmap) ncolold = cmap->NCol(); 741 779 if ( (cmapid == CMAP_GREY32) || (cmapid == CMAP_GREYINV32) || 742 780 (cmapid == CMAP_GREY128) || (cmapid == CMAP_GREYINV128)) mdrw->GetGraphicAtt().SetColAtt(PI_Red); 743 781 else mdrw->GetGraphicAtt().SetColAtt(PI_Turquoise); 744 PIPixmap::SetColMapId(cmapid, revidx, refr); 782 PIPixmap::SetColMapId(cmapid, revidx, false); 783 if (refr) { xcurs = ycurs = -1; } 784 bool fgapp = false; 785 if (refr && cmap->NCol() != ncolold) { 786 fgapp = true; refr = false; 787 } 788 if (lut) lut->SetNCol(GetColMap()->NCol()); 789 if (refr) Refresh(); 745 790 if (zow) zow->SetColMapId(cmapid, revidx, refr); 746 if (gvw) gvw->SetColMapId(cmapid, revidx, refr); 791 if (gvw) { 792 if (cmap->NCol() != ncolold) { 793 ComputeGloVPixmap(); 794 SetGloVPixmap(); 795 } 796 else gvw->SetColMapId(cmapid, revidx, refr); 797 } 747 798 if (cmvw) cmvw->SetColMapId(cmapid, revidx, Lut()->Min(), Lut()->Max(), refr); 799 if (fgapp) Apply(); 748 800 return; 749 801 } … … 754 806 { 755 807 if (img == NULL) return; 808 if (fgshowcmap>0) { 809 cmpd.SetColMap(GetColMap()); 810 cmpd.SetBornes(*Lut()); 811 } 756 812 if (mw) { 757 813 ComputePixmap(); … … 1111 1167 ywsz = YSize(); 1112 1168 1113 pixm = img->ComputePixmap(lut, offx, offy, zoom, xwsz, ywsz, pixm, &xspxm, &yspxm);1169 img->ComputePixmap(lut, offx, offy, zoom, xwsz, ywsz, pixm); 1114 1170 int xw1, yw1, xw2, yw2; 1115 xw1 = (xwsz- xspxm)/2;1171 xw1 = (xwsz-pixm.XSize())/2; 1116 1172 if (xw1 < 0) xw1 = 0; 1117 yw1 = (ywsz- yspxm)/2;1173 yw1 = (ywsz-pixm.YSize())/2; 1118 1174 if (yw1 < 0) yw1 = 0; 1119 xw2 = xspxm+xw1;1120 yw2 = yspxm+yw1;1175 xw2 = pixm.XSize()+xw1; 1176 yw2 = pixm.YSize()+yw1; 1121 1177 SetDefaultDrawRectangle(xw1, yw1, xw2, yw2, false); 1122 // printf("--DBG-- ComputePixmap() %d %d $ %d %d :: %d %d , %d %d \n", xwsz, ywsz, xspxm, yspxm, xw1, yw1, xw2, yw2);1178 // printf("--DBG-- ComputePixmap() %d %d $ %d %d :: %d %d , %d %d \n", xwsz, ywsz, pixm.XSize(), pixm.YSize(), xw1, yw1, xw2, yw2); 1123 1179 int x1,y1, x2,y2; 1124 1180 ofx = xw1; ofy = yw1; … … 1131 1187 // printf("--DBG2-- ComputePixmap() %g %g %g %g \n", fx1, fx2, fy1, fy2); 1132 1188 xcurs = ycurs = -1; 1133 SetPixmap( pixm, xspxm, yspxm, true, xw1, yw1);1189 SetPixmap(&pixm, true, xw1, yw1); 1134 1190 // Refresh(); 1135 1191 return; … … 1174 1230 if (lofy < 0) lofy = 0; 1175 1231 1176 zpixm = img->ComputePixmap(lut, lofx, lofy, zm, xwsz, ywsz, zpixm, &xszpxm, &yszpxm);1232 img->ComputePixmap(lut, lofx, lofy, zm, xwsz, ywsz, zpixm); 1177 1233 zow->SetColMap(cmap, false); 1178 zow->SetPixmap( zpixm, xszpxm, yszpxm);1234 zow->SetPixmap(&zpixm); 1179 1235 zow->SetUserData((void *)this, 0); 1180 1236 // zow->Refresh(); … … 1203 1259 zmgv = zmx; 1204 1260 if (zmx > 1) zmx = -zmx; 1205 gpixm = img->ComputePixmap(lut, 0, 0, zmx, xwsz, ywsz, gpixm, &xsgpxm, &ysgpxm);1206 // printf("DEBUG-ComputeGloVPixmap() %d-%d , (%d,%d) , %d-%d \n", xwsz, ywsz, zmx, zmy, xsgpxm, ysgpxm);1261 img->ComputePixmap(lut, 0, 0, zmx, xwsz, ywsz, gpixm); 1262 // printf("DEBUG-ComputeGloVPixmap() %d-%d , (%d,%d) , %d-%d \n", xwsz, ywsz, zmx, zmy, gpixm.XSize(), gpixm.YSize()); 1207 1263 return; 1208 1264 } … … 1215 1271 1216 1272 int xw1, yw1, xw2, yw2; 1217 xw1 = (gvw->XSize()- xsgpxm)/2;1273 xw1 = (gvw->XSize()-gpixm.XSize())/2; 1218 1274 if (xw1 < 0) xw1 = 0; 1219 yw1 = (gvw->YSize()- ysgpxm)/2;1275 yw1 = (gvw->YSize()-gpixm.YSize())/2; 1220 1276 if (yw1 < 0) yw1 = 0; 1221 xw2 = xsgpxm+xw1;1222 yw2 = ysgpxm+yw1;1277 xw2 = gpixm.XSize()+xw1; 1278 yw2 = gpixm.YSize()+yw1; 1223 1279 1224 1280 if (zoom > 0) zm = zmgv*zoom; … … 1242 1298 gvw->AddDrawer(gvdrw, xw1, yw1, xw2, yw2, false); 1243 1299 gvw->SetColMap(cmap, false); 1244 gvw->SetPixmap( gpixm, xsgpxm, ysgpxm, true, xw1, yw1);1300 gvw->SetPixmap(&gpixm, true, xw1, yw1); 1245 1301 gvw->SetUserData((void *)this, 0); 1246 1302 gvw->SetMsg(Msg()+626); … … 1348 1404 //printf("UpdateCuts()-DBG X: %d -> %g , Y: %d -> %g \n", cutarrx->Size(), cutarrx->Value(0), 1349 1405 // cutarry->Size(), cutarry->Value(0)); 1406 } 1407 1408 /* --Methode-- */ 1409 void PIImage::UpdateCMapDrawer(int fgshow) 1410 { 1411 if ((fgshow<0)||(fgshow>4)) fgshow=0; 1412 if (fgshow==fgshowcmap) return; 1413 fgshowcmap=fgshow; 1414 switch (fgshowcmap ) { 1415 case 0 : 1416 RemoveDrawer(cmdid); 1417 break; 1418 case 1 : 1419 cmpd.SetHorizontal(); 1420 cmdid=AddDrawer(&cmpd, 0.10, 0.02, 0.90, 0.10, true, false); 1421 break; 1422 case 2 : 1423 cmpd.SetVertical(); 1424 cmdid=AddDrawer(&cmpd, 0.90, 0.1, 0.98, 0.9, true, false); 1425 break; 1426 case 3 : 1427 cmpd.SetHorizontal(); 1428 cmdid=AddDrawer(&cmpd, 0.10, 0.90, 0.90, 0.98, true, false); 1429 break; 1430 case 4 : 1431 cmpd.SetVertical(); 1432 cmdid=AddDrawer(&cmpd, 0.02, 0.1, 0.10, 0.9, true, false); 1433 break; 1434 } 1435 if (fgshowcmap>0) cmpd.GetGraphicAtt().SetColAtt(PI_Turquoise); 1350 1436 } 1351 1437 -
trunk/SophyaPI/PI/piimage.h
r4077 r4083 135 135 void SetGloVPixmap(); 136 136 void UpdateCuts(); 137 void UpdateCMapDrawer(int fgshow); 137 138 138 139 void DrawCursor(PIGraphic* g); … … 154 155 bool winovis; // $CHECK$ Reza A enlever si possible 17/6/96 155 156 // Tableau des pixels principal 156 unsigned char * pixm; 157 int xspxm, yspxm; 157 PIPixColIdx pixm; 158 158 LUT * lut; 159 159 AutoLutType t_al; // Si AutoLut et le type lors du dernier appel a SetLut() … … 164 164 int zoom; 165 165 PIPixmap * zow; 166 unsigned char * zpixm; 167 int xszpxm, yszpxm; 168 // Fenetre pour l'image entiere 166 PIPixColIdx zpixm; 167 // Fenetre pour vue globale de l'image 169 168 int zmgv; 170 169 PIPixmap * gvw; 171 unsigned char * gpixm; 172 int xsgpxm, ysgpxm; 170 PIPixColIdx gpixm; 173 171 PIElDrawer* gvdrw; 174 172 // Fenetre d'affichage du ColMap 175 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; 176 177 // Fenetre/champ de texte 177 178 PILabel * trtlb; -
trunk/SophyaPI/PI/piimgtools.cc
r4077 r4083 99 99 mOpt[0] = new PIOptMenu(this, "imglut-opt-1", 1.5*bsx, bsy, cpx, cpy); 100 100 mOpt[0]->AppendItem("Linear", 1100); 101 mOpt[0]->AppendItem("Log.", 1101); 102 mOpt[0]->AppendItem("Sqrt", 1102); 103 mOpt[0]->AppendItem("Square", 1103); 101 mOpt[0]->AppendItem("Log", 1101); 102 mOpt[0]->AppendItem("Exp", 1102); 103 mOpt[0]->AppendItem("Sqrt", 1103); 104 mOpt[0]->AppendItem("Square", 1104); 105 mOpt[0]->AppendItem("RGB", 1105); 104 106 mOpt[0]->SetValue(1100); 105 107 mOpt[0]->SetBinding(PIBK_elastic,PIBK_elastic, PIBK_elastic,PIBK_elastic); … … 174 176 mCasc[1] = new PIMenu(mOptzc[0]->Menu(), "PIUniCol32"); 175 177 mCasc[2] = new PIMenu(mOptzc[0]->Menu(), "MIDAS-CMap"); 176 177 int nsct1,nsct2,nsct3,nsct4; 178 mCasc[3] = new PIMenu(mOptzc[0]->Menu(), "RGB-CMap"); 179 180 int nsct1,nsct2,nsct3,nsct4,nsct5; 178 181 // D'abord les tables standard de PI 32 couleurs 179 182 nsct1 = 5; // Les 5 premieres tables … … 190 193 mOptzc[0]->AppendPDMenu(mCasc[1]); 191 194 // Apres les tables importees de MIDAS 192 nsct4 = PIColorMap::NumberStandardColorMaps()- 2; // Les reste jusqu'a l'avant derniere195 nsct4 = PIColorMap::NumberStandardColorMaps()-6; // Les reste jusqu'a l'avant derniere 193 196 for(kcc=nsct3; kcc<nsct4; kcc++) 194 197 mCasc[2]->AppendItem(PIColorMap::GetStandardColorMapName(kcc).c_str(), 201+kcc); 195 198 mOptzc[0]->AppendPDMenu(mCasc[2]); 196 // Les tables qui restent ( Col16 , ... ) 197 for(kcc=nsct4; kcc<PIColorMap::NumberStandardColorMaps(); kcc++) 198 mOptzc[0]->AppendItem(PIColorMap::GetStandardColorMapName(kcc).c_str(), 201+kcc); 199 // On ajoute un CheckItem pour inverser les index de table de couleur 199 nsct5 = PIColorMap::NumberStandardColorMaps()-4; // Les reste jusqu'aux tables RGB 200 for(kcc=nsct4; kcc<nsct5; kcc++) 201 mOptzc[0]->AppendItem(PIColorMap::GetStandardColorMapName(kcc).c_str(), 201+kcc); 202 // Les tables de couleur RGB ( RGB216, RGB512 , ... ) 203 for(kcc=nsct5; kcc<PIColorMap::NumberStandardColorMaps(); kcc++) 204 mCasc[3]->AppendItem(PIColorMap::GetStandardColorMapName(kcc).c_str(), 201+kcc); 205 mOptzc[0]->AppendPDMenu(mCasc[3]); 206 // On ajoute un CheckItem pour inverser les index de table de couleur 200 207 mOptzc[0]->Menu()->AppendSeparator(); 201 208 mOptzc[0]->Menu()->AppendCheckItem("Reverse CMap", 299); … … 310 317 for(i=0; i<3; i++) delete mBut[i]; 311 318 delete mButR; 312 for(i=0; i< 2; i++) delete mCasc[i];319 for(i=0; i<4; i++) delete mCasc[i]; 313 320 for(i=0; i<5; i++) delete mButsz[i]; 314 321 for(i=0; i<3; i++) delete mButcax[i]; … … 371 378 if ( (mpii->Lut())->Type() == kLutType_Lin ) mOpt[0]->SetValue(1100); 372 379 else if( (mpii->Lut())->Type() == kLutType_Log ) mOpt[0]->SetValue(1101); 373 else if( (mpii->Lut())->Type() == kLutType_Sqrt ) mOpt[0]->SetValue(1102); 374 else if( (mpii->Lut())->Type() == kLutType_Square ) mOpt[0]->SetValue(1103); 380 else if( (mpii->Lut())->Type() == kLutType_Exp ) mOpt[0]->SetValue(1102); 381 else if( (mpii->Lut())->Type() == kLutType_Sqrt ) mOpt[0]->SetValue(1103); 382 else if( (mpii->Lut())->Type() == kLutType_Square ) mOpt[0]->SetValue(1104); 383 else if( (mpii->Lut())->Type() == kLutType_RGB ) mOpt[0]->SetValue(1105); 375 384 else mOpt[0]->SetValue(1100); 376 385 } … … 388 397 double min, max, del; 389 398 int lauto, typ; 390 int typlut[ 4] = {kLutType_Lin, kLutType_Log, kLutType_Sqrt, kLutType_Square} ;399 int typlut[6] = {kLutType_Lin, kLutType_Log, kLutType_Exp, kLutType_Sqrt, kLutType_Square, kLutType_RGB } ; 391 400 AutoLutType alts[13] = { AutoLut_No, 392 401 AutoLut_MeanSigma, AutoLut_MeanSigma, AutoLut_MeanSigma, … … 446 455 if ((lauto < 0) || (lauto > 12)) lauto = 12; 447 456 typ = mOpt[0]->GetValue() - 1100; 448 if ( (typ < 0) || (typ > 3) ) typ = 0;457 if ( (typ < 0) || (typ > 5) ) typ = 0; 449 458 (PIImage::CurrentPIImage())->SetLut(alts[lauto], min, max, typlut[typ], nsas[lauto]); 450 459 if (msg == 2500) { -
trunk/SophyaPI/PI/pilistx.cc
r4077 r4083 116 116 mNItem++; 117 117 118 #if defined(__DECCXX) || defined(__KCC__) || defined(__aCC__) 119 XmString xms = XmStringCreate(const_cast<char *>(item), XmSTRING_DEFAULT_CHARSET); 120 #else 121 XmString xms = XmStringCreate((char *)(item), XmSTRING_DEFAULT_CHARSET); 122 #endif 118 XmString xms = XmStringCreate(const_cast<char*>(item), const_cast<char*>(XmSTRING_DEFAULT_CHARSET)); 123 119 XmListAddItem(mlist, xms, 0); 124 120 XmStringFree(xms); -
trunk/SophyaPI/PI/pimenux.cc
r4077 r4083 386 386 n=0; 387 387 sprintf(acc,"Ctrl/%c", sc[0]); 388 xmstr = XmStringLtoRCreate(acc, XmSTRING_DEFAULT_CHARSET);388 xmstr = XmStringLtoRCreate(acc, const_cast<char*>(XmSTRING_DEFAULT_CHARSET)); 389 389 XtSetArg(warg[n], XmNacceleratorText, xmstr); n++; 390 390 sprintf(acc,"Ctrl<Key>%c", sc[0]); -
trunk/SophyaPI/PI/pipixmapgen.cc
r4077 r4083 8 8 #include "sopnamsp.h" 9 9 #include "pipixmapgen.h" 10 10 11 11 12 // --------- Methodes de la classe PIPixMap ---------- … … 43 44 // long kind() 44 45 // Retourne le type ("=PIPixmap::ClassId") 45 // void SetPixmap(unsigned char *pix, int sx, int sy, bool refr=true, int ox=0, int oy=0) 46 // Associe un tableau d'index "pix" de taille "sx * sy". 47 // (ox,oy)" définissent l'offset d'affichage. 46 // void SetPixmap(PIPixColIdx *pixidx, int sx, int sy, bool refr=true, int ox=0, int oy=0) 47 // Associe un tableau d'index de couleur "pixidx". (ox,oy)" définissent l'offset d'affichage. 48 48 // Si "refr=true", la méthode "Refresh()" est appelée. 49 49 //-- … … 87 87 { 88 88 pixmap = NULL; 89 nx = ny = 0;89 fgownpmap = false; 90 90 ofx = ofy = 0; 91 91 mPpos[0] = mPpos[0] = 0; … … 99 99 { 100 100 delete cmap; 101 if (fgownpmap && pixmap) delete pixmap; 101 102 } 102 103 103 104 /* --Methode-- */ 104 void PIPixmapGen::SetPixmap( unsigned char *pix, int sx, int sy, bool refr, int ox, int oy)105 void PIPixmapGen::SetPixmap(PIPixColIdx *pixidx, bool refr, int ox, int oy) 105 106 { 106 pixmap = pix; 107 if (pixmap) 108 { 109 if (sx < 0) sx = 0; 110 if (sy < 0) sy = 0; 111 if (ox < 0) ox = 0; 112 if (oy < 0) oy = 0; 113 nx = sx; ny = sy; 114 ofx = ox; ofy = oy; 107 if (fgownpmap && pixmap) delete pixmap; 108 fgownpmap = false; 109 pixmap = pixidx; 110 if (ox < 0) ox = 0; 111 if (oy < 0) oy = 0; 112 ofx = ox; ofy = oy; 113 if (refr) Refresh(); 114 } 115 116 /* --Methode-- */ 117 void PIPixmapGen::SetRGBArray(PIPixRGBArray *rgba, CMapId cmapid, bool refr, int ox, int oy) 118 { 119 if (rgba == NULL) return; 120 int quantum = 8; 121 if (cmapid == CMAP_RGB216) quantum = 6; 122 else if (cmapid == CMAP_RGB4096) quantum = 16; 123 else cmapid = CMAP_RGB512; 124 SetColMapId(cmapid, false); 125 PIPixColIdx * pixc = new PIPixColIdx; 126 pixc->AllocateByte(rgba->XSize(), rgba->YSize()); 127 for(int j=0; j<rgba->YSize(); j++) 128 for(int i=0; i<rgba->XSize(); i++) { 129 PIPixRGB vv = (*rgba)(i,j); 130 int r = (int)vv.red*quantum/256; 131 int g = (int)vv.green*quantum/256; 132 int b = (int)vv.blue*quantum/256; 133 pixc->GetShort(i,j) = (unsigned short)((b*quantum+g)*quantum+r); 115 134 } 116 else { ofx = ofy = nx = ny = 0; } 117 if (refr) Refresh(); 135 SetPixmap(pixc, refr, ox, oy); 136 fgownpmap = true; 137 return; 118 138 } 119 139 -
trunk/SophyaPI/PI/pipixmapgen.h
r4077 r4083 9 9 #include PICMAP_H 10 10 11 #include "pipixutils.h" 12 11 13 #include <list> 14 12 15 13 16 class PIPixmapGen : public PIBaseWdg … … 22 25 virtual long kind() {return ClassId; } 23 26 24 virtual void SetPixmap(unsigned char *pix, int sx, int sy, 25 bool refr=true, int ox=0, int oy=0); 27 virtual void SetPixmap(PIPixColIdx *pixidx, bool refr=true, int ox=0, int oy=0); 28 virtual void SetRGBArray(PIPixRGBArray *rgba, CMapId cmapid=CMAP_RGB512, 29 bool refr=true, int ox=0, int oy=0); 26 30 27 31 virtual void SetColMap(PIColorMap* cmp, bool refr=true); … … 39 43 40 44 protected: 41 unsigned char *pixmap;42 int nx, ny;43 int ofx, ofy; 45 PIPixColIdx *pixmap; // Pointeur d'objet PIPixCoIdx, tableau d'index de couleurs, peut etre NULL 46 bool fgownpmap; // si true -> possede le pixmap et doit le deleter si besoin 47 int ofx, ofy; // Offset d'affichage 44 48 PIColorMap* cmap; 45 49 -
trunk/SophyaPI/PI/pipixmapx.cc
r4077 r4083 7 7 #include "sopnamsp.h" 8 8 #include "pipixmapx.h" 9 #include <iostream> 10 11 using namespace std; 9 12 10 13 static GC mygc; … … 31 34 { 32 35 int i,j; 33 unsigned char *pp; 34 35 if (pixmap) 36 { 37 for(j=0; j<ny; j++) 38 { 39 pp = pixmap+j*nx; 40 for(i=0; i<nx; i++) 41 { XPutPixel(myximg, i, j, cmap->Color(*pp) ); pp++; } 36 int nx = 0; 37 int ny = 0; 38 if (pixmap!=NULL) { 39 nx = pixmap->XSize(); 40 if (nx > XSize()) nx = XSize(); 41 ny = pixmap->YSize(); 42 if (ny > YSize()) ny = YSize(); 43 if (pixmap->BytePointer()!=NULL) { 44 unsigned char *pp = pixmap->BytePointer(); 45 for(j=0; j<ny; j++) { 46 pp = pixmap->BytePointer()+j*pixmap->XSize(); 47 for(i=0; i<nx; i++) 48 { XPutPixel(myximg, i, j, cmap->Color(*pp) ); pp++; } 49 } 50 } 51 else if (pixmap->ShortPointer()!=NULL) { 52 unsigned short *pp = pixmap->ShortPointer(); 53 for(j=0; j<ny; j++) { 54 pp = pixmap->ShortPointer()+j*pixmap->XSize(); 55 for(i=0; i<nx; i++) 56 { XPutPixel(myximg, i, j, cmap->Color(*pp) ); pp++; } 42 57 } 43 58 } 44 59 } 60 /* ----- On peut laisser le reste - ce n'est pas utilise dans le Draw 61 // On remplit le restant 62 for(j=0; j<YSize(); j++) 63 for(i=nx; i<XSize(); i++) 64 XPutPixel(myximg, i, j, 0 ); 45 65 for(j=ny; j<YSize(); j++) 46 for(i= nx; i<XSize(); i++)66 for(i=0; i<XSize(); i++) 47 67 XPutPixel(myximg, i, j, 0 ); 48 68 ------- */ 49 69 PIBaseWdgX::Refresh(); 50 70 } … … 66 86 if (!g) return; 67 87 if (g->kind() == PI_PSFileGraphics ) { 68 g->DrawPixmap(ofx, ofy, pixmap, nx, ny,cmap);88 g->DrawPixmap(ofx, ofy, pixmap, cmap); 69 89 // Il faut faire quelque chose Sinon ??! 70 90 } … … 78 98 79 99 if (!g) return; 80 if ((myximg == NULL) || (cmap == NULL)) return;81 100 82 101 if (g->kind() == PI_PSFileGraphics ) { 83 if (pixmap) g->DrawPixmap(ofx, ofy, pixmap, nx, ny, cmap);102 g->DrawPixmap(ofx, ofy, (*pixmap), cmap); 84 103 return; 85 104 } 105 86 106 87 107 Window xw = XtWindow(XtWdg()); 88 108 Display * mdsp = PIXDisplay(); 89 109 110 if ((myximg == NULL) || (cmap == NULL) || (pixmap == NULL) || 111 (pixmap->XSize()<=0) || (pixmap->YSize()<=0) ) { 112 XClearArea(mdsp, xw, x0, y0, dx, dy, False); return; 113 } 114 90 115 int mx, my, ox, oy; 91 116 92 117 if (x0 < 0) x0 = 0; 93 118 if (y0 < 0) y0 = 0; 94 mx = nx+ofx; my = ny+ofy; 119 120 mx = pixmap->XSize()+ofx; my = pixmap->YSize()+ofy; 121 95 122 if (dx > (XSize()-x0)) dx = XSize()-x0; 96 123 if (dy > (YSize()-y0)) dy = YSize()-y0; … … 101 128 102 129 ox = oy = 0; 103 104 130 if (ofx > x0) 105 131 { XClearArea(mdsp, xw, x0, y0, ofx-x0, dy, False); … … 115 141 if (my < (y0+dy)) 116 142 { XClearArea(mdsp, xw, x0, my, dx, y0+dy-my, False); dy = my-y0; } 143 144 /* 145 if (ofx > x0) 146 XClearArea(mdsp, xw, x0, y0, ofx-x0, dy, False); 147 if (ofy > y0) 148 XClearArea(mdsp, xw, x0, y0, dx, ofy-y0, False); 117 149 150 if (mx < (x0+dx)) 151 XClearArea(mdsp, xw, mx, y0, x0+dx-mx, dy, False); 152 if (my < (y0+dy)) 153 XClearArea(mdsp, xw, x0, my, dx, y0+dy-my, False); 154 155 if (ofx > x0) 156 { dx -= (ofx-x0); x0 = ofx; ox = 0; } 157 else ox = x0-ofx; 158 if (ofy > y0) 159 { dy -= (ofy-y0); y0 = ofy; oy = 0; } 160 else oy = y0-ofy; 161 if (mx < (x0+dx)) dx = mx-x0; 162 if (my < (y0+dy)) dy = my-y0; 163 */ 164 118 165 XPutImage(mdsp, xw, mygc, myximg, ox, oy, x0, y0, dx, dy); 119 166 XFlush(mdsp); -
trunk/SophyaPI/PI/piscdrawwdg.cc
r4077 r4083 248 248 bool fglogy = isLogScaleY(); 249 249 250 // Flag declenchant SetLimits 251 bool fgsaxel = false; 252 // Limites et sens d'axe 253 double xmin = XMin(); 254 double ymin = YMin(); 255 double xmax = XMax(); 256 double ymax = YMax(); 257 int axrl = kAxeDirLtoR; 258 int ayud = kAxeDirDownUp; 259 int xac, yac; 260 GetAxesConfig(xac, yac); 261 if (xac & kAxeDirRtoL) axrl = kAxeDirRtoL; 262 if (yac & kAxeDirUpDown) ayud = kAxeDirUpDown; 263 250 264 for( k=0; k<opt.size(); k++ ) { 251 265 string opts = opt[k]; … … 259 273 // Limites en x,y 260 274 if (opts.substr(0,9) == "xylimits=") { 261 double xmin = XMin();262 double ymin = YMin();263 double xmax = XMax();264 double ymax = YMax();265 275 sscanf(opts.substr(9).c_str(),"%lg,%lg,%lg,%lg",&xmin, &xmax,&ymin,&ymax); 266 SetLimits(xmin, xmax, ymin, ymax);276 fgsaxel = true; 267 277 continue; 268 278 } … … 292 302 continue; 293 303 } 294 295 // Les attributs d'axes (stdaxes boxaxesgrid ...) sont decodes par PIElDrawer 304 if ((opts == "revax") || (opts == "axerl") ) { 305 fgsaxel = true; axrl = kAxeDirRtoL; 306 continue; 307 } 308 if ((opts == "revay") || (opts == "axeud") ) { 309 fgsaxel = true; ayud = kAxeDirUpDown; 310 continue; 311 } 312 if (opts == "axelr") { 313 fgsaxel = true; axrl = kAxeDirLtoR; 314 continue; 315 } 316 if (opts == "axedu") { 317 fgsaxel = true; ayud = kAxeDirDownUp; 318 continue; 319 } 320 321 // Les autres attributs d'axes (stdaxes boxaxesgrid ...) sont decodes par PIElDrawer 296 322 297 323 ndec--; … … 299 325 } 300 326 327 if (fgsaxel) SetLimits(xmin, xmax, ymin, ymax, axrl, ayud); 301 328 if (fglinlog) SetLogScale(fglogx, fglogy); 302 329 -
trunk/SophyaPI/PI/pistdwdgx.cc
r4077 r4083 51 51 { 52 52 XmString xmstr; 53 xmstr = XmStringLtoRCreate( (char *)lab.c_str(), XmSTRING_DEFAULT_CHARSET);53 xmstr = XmStringLtoRCreate(const_cast<char*>(lab.c_str()), const_cast<char*>(XmSTRING_DEFAULT_CHARSET)); 54 54 int n=0; 55 55 Arg warg[2]; … … 149 149 { 150 150 XmString xmstr; 151 xmstr = XmStringLtoRCreate( (char *)lab.c_str(), XmSTRING_DEFAULT_CHARSET);151 xmstr = XmStringLtoRCreate(const_cast<char*>(lab.c_str()), const_cast<char*>(XmSTRING_DEFAULT_CHARSET)); 152 152 int n=0; 153 153 Arg warg[2]; -
trunk/SophyaPI/PI/pitherm.cc
r4077 r4083 24 24 //-- 25 25 //++ 26 // PIThermometer(PIContainerGen *par, c har *nom, int sx=256, int sy=10, int px=0, int py=0)26 // PIThermometer(PIContainerGen *par, const char *nom, int sx=256, int sy=10, int px=0, int py=0) 27 27 // Constructeur - Le choix d'affichage (vertical ou horizontal) dépend 28 28 // du rapport des tailles "sx", "sy" … … 31 31 32 32 /* --Methode-- */ 33 PIThermometer::PIThermometer(PIContainerGen *par, c har *nom,33 PIThermometer::PIThermometer(PIContainerGen *par, const char *nom, 34 34 int sx, int sy, int px, int py) 35 35 : PIBaseWdg(par, nom, sx, sy, px, py) … … 139 139 void PIThermometer::Draw(PIGraphicGen* g, int /*x0*/, int /*y0*/, int /*dx*/, int /*dy*/) 140 140 { 141 if (!IsVisible()) return; 141 142 double delta = (max_-min_); 142 143 if (delta < 1.e-39) delta = 1.e-39; -
trunk/SophyaPI/PI/pitherm.h
r4077 r4083 16 16 enum {ClassId = 5220}; 17 17 18 PIThermometer(PIContainerGen *par, c har *nom,18 PIThermometer(PIContainerGen *par, const char *nom, 19 19 int sx=256, int sy=10, int px=0, int py=0); 20 20 virtual ~PIThermometer(); -
trunk/SophyaPI/PI/piversion.h
r4077 r4083 2 2 #define PIVERSION_H_SEEN 3 3 4 #define PI_VERSIONNUMBER 4. 114 #define PI_VERSIONNUMBER 4.20 5 5 6 6 #endif -
trunk/SophyaPI/PI/piwdggen.cc
r4077 r4083 57 57 //-- 58 58 //++ 59 // void PSPrint(PSFile *psf, int ofx=0, int ofy=0)60 // Méthode virtuelle qui doit être redéfinie pour chacune des classes filles.61 // produit une représentation graphique de l'objet en Postscript.62 59 // SetSize(int sx, int sy) 63 60 // Modifie la taille de l'objet. … … 181 178 // int UserFlag() 182 179 // Renvoie la valeur "int" user de l'objet. 180 //-- 181 182 //++ 183 // Titre Export postscript et format RGB 184 //-- 185 //++ 186 // void PSPrint(PSFile *psf, int ofx=0, int ofy=0) 187 // Méthode virtuelle qui doit être redéfinie pour chacune des classes filles. 188 // produit une représentation graphique de l'objet en Postscript. 189 // void ExportToRGB(PIPixRGBArray & rgba) 190 // Méthode virtuelle qui doit être redéfinie pour chaque architecture. 191 // Remplit un tableau PIPixRGBArray le contenu pixels du widget en couleurs RGB. 183 192 //-- 184 193 … … 309 318 } 310 319 320 /* --Methode-- */ 321 void PIWdgGen::ExportToRGB(PIPixRGBArray & rgba) 322 { 323 return; 324 } 325 311 326 //++ 312 327 // Titre Gestion des Draw/Event Handler -
trunk/SophyaPI/PI/piwdggen.h
r4077 r4083 10 10 #include "pimsghandler.h" 11 11 #include "picolist.h" 12 #include "pipixutils.h" 12 13 13 14 #include <string> … … 107 108 virtual bool IfSensitive()=0; 108 109 110 // Pour exporter le contenu d'un widget (dessin vectoriel) en postscript 109 111 virtual void PSPrint(PSFile *psf, int ofx=0, int ofy=0, 110 112 double scale_x=1., double scale_y=1.); 113 // Pour exporter le tableau des pixels du widget en classe PIPixRGBArray 114 // L'implementation par defaut ne fait rien 115 virtual void ExportToRGB(PIPixRGBArray & rgba); 111 116 112 117 // Gestion de copier-coller -
trunk/SophyaPI/PI/piwdgx.cc
r4077 r4083 20 20 #include "pigraphx.h" 21 21 22 #ifdef SANS_EVOLPLANCK23 #include "perrors.h"24 #else25 22 #include "pexceptions.h" 26 #endif27 23 28 24 … … 50 46 szx = appSzX; szy = appSzY; 51 47 szf = appSzFont; 48 printf("XtAppContext* PIXtAppCtx :szx=%d szy=%d szf=%d",szx,szy,szf); 52 49 return(&appctx); 53 50 } … … 627 624 // Ressources X si non definis 628 625 static const String fallback_res[26] = { 629 "PeidaInt*default*background: LightGrey",630 "PeidaInt*background: LightGrey",631 "PeidaInt*Foreground: Black",632 "PeidaInt*default*Foreground: Black",633 "PeidaInt*default*bottomShadowColor: Black",634 "PeidaInt*bottomShadowColor: Black",635 "PeidaInt*default*topShadowColor: White",636 "PeidaInt*topShadowColor: White",637 "PeidaInt*borderColor: Black",638 "PeidaInt*XmLabel.borderWidth: 0",639 "PeidaInt*XmDrawingArea*background: Black",640 "PeidaInt*XmPushButton*borderWidth: 0",641 "PeidaInt*XmText*shadowThickness: 2",642 "PeidaInt*XmText*highlightThickness: 0",643 "PeidaInt*XmText*marginHeigt: 0",644 "PeidaInt*XmText*marginWidth: 2",645 // "PeidaInt*DefMenubar*XtNwidth: 250",646 // "PeidaInt*DefMenubar*XtNheight: 30",647 "PeidaInt*fontList: -*-courier-bold-r-normal-*-12-*-*-*-*-*-ISO8859-1",648 "PeidaInt*default*fontList: -*-courier-bold-r-normal-*-12-*-*-*-*-*-ISO8859-1",649 "PeidaInt*fontFamilyName: *-courier", // Pas de blanc apres le nom de font650 "PeidaInt*courierfontFamilyName: *-courier", // " "651 "PeidaInt*helveticafontFamilyName: *-helvetica", // " "652 "PeidaInt*timesfontFamilyName: *-times", // " "653 "PeidaInt*symbolfontFamilyName: *-symbol", // " "654 "PeidaInt*XmToggleButton*selectColor: Red",626 const_cast<char*>("PeidaInt*default*background: LightGrey") , 627 const_cast<char*>("PeidaInt*background: LightGrey") , 628 const_cast<char*>("PeidaInt*Foreground: Black"), 629 const_cast<char*>("PeidaInt*default*Foreground: Black"), 630 const_cast<char*>("PeidaInt*default*bottomShadowColor: Black"), 631 const_cast<char*>("PeidaInt*bottomShadowColor: Black"), 632 const_cast<char*>("PeidaInt*default*topShadowColor: White"), 633 const_cast<char*>("PeidaInt*topShadowColor: White"), 634 const_cast<char*>("PeidaInt*borderColor: Black"), 635 const_cast<char*>("PeidaInt*XmLabel.borderWidth: 0"), 636 const_cast<char*>("PeidaInt*XmDrawingArea*background: Black"), 637 const_cast<char*>("PeidaInt*XmPushButton*borderWidth: 0"), 638 const_cast<char*>("PeidaInt*XmText*shadowThickness: 2"), 639 const_cast<char*>("PeidaInt*XmText*highlightThickness: 0"), 640 const_cast<char*>("PeidaInt*XmText*marginHeigt: 0"), 641 const_cast<char*>("PeidaInt*XmText*marginWidth: 2"), 642 // const_cast<char*>("PeidaInt*DefMenubar*XtNwidth: 250"), 643 // const_cast<char*>("PeidaInt*DefMenubar*XtNheight: 30"), 644 const_cast<char*>("PeidaInt*fontList: -*-courier-bold-r-normal-*-12-*-*-*-*-*-ISO8859-1"), 645 const_cast<char*>("PeidaInt*default*fontList: -*-courier-bold-r-normal-*-12-*-*-*-*-*-ISO8859-1"), 646 const_cast<char*>("PeidaInt*fontFamilyName: *-courier"), // Pas de blanc apres le nom de font 647 const_cast<char*>("PeidaInt*courierfontFamilyName: *-courier"), // " " 648 const_cast<char*>("PeidaInt*helveticafontFamilyName: *-helvetica"), // " " 649 const_cast<char*>("PeidaInt*timesfontFamilyName: *-times"), // " " 650 const_cast<char*>("PeidaInt*symbolfontFamilyName: *-symbol"), // " " 651 const_cast<char*>("PeidaInt*XmToggleButton*selectColor: Red"), 655 652 NULL 656 653 }; … … 681 678 if (top == NULL) { 682 679 fprintf(stderr, "PIWdgX::InitXt()/ Error XtVaAppInitialize()\n"); 683 #ifdef SANS_EVOLPLANCK 684 throw notFoundErr; 685 #else 686 throw NotFoundExc("PIWdgX::InitXt()/ Error XtVaAppInitialize()"); 687 #endif 680 throw PError("PIWdgX::InitXt()/ Error XtVaAppInitialize()"); 688 681 } 689 682 dpy = XtDisplay(top); 690 683 if (dpy == NULL) { 691 684 fprintf(stderr, "PIWdgX::InitXt()/ Error XtVaAppInitialize()/DisplayConnection\n"); 692 #ifdef SANS_EVOLPLANCK 693 throw notFoundErr; 694 #else 695 throw NotFoundExc("PIWdgX::InitXt()/ Error XtVaAppInitialize()/DisplayConnection"); 696 #endif 685 throw PError("PIWdgX::InitXt()/ Error XtVaAppInitialize()/DisplayConnection"); 697 686 } 698 687 … … 734 723 } 735 724 stdfnt = XLoadQueryFont(dpy, buff); 736 c har * myfntname = "???";725 const char * myfntname = "???"; 737 726 // Recherche du champ taille en pixel de la fonte : apres le 7eme tiret 738 727 int mySzFont = 12; … … 831 820 } 832 821 822 823 // Pour exporter le tableau des pixels du widget en classe PIPixRGBArray 824 inline void _col2_fcol_(unsigned long & col, unsigned long & fcol) 825 { 826 if (col > 0x00FFFFFF) fcol = 0x01000000; 827 else if (col > 0x0000FFFF) fcol = 0x000010000; 828 else if (col > 0x000000FF) fcol = 0x00000100; 829 else fcol = 1; 830 } 831 /* --Methode-- */ 832 void PIWdgX::ExportToRGB(PIPixRGBArray & rgba) 833 { 834 Display* mdsp = PIXDisplay(); 835 int scr = XDefaultScreen(mdsp); 836 int depth = DefaultDepth(mdsp,scr); 837 Window xw = XtWindow(XtWdg()); 838 unsigned long plane_mask = ~0; // tous les bits a 1 839 XImage * ximg = XGetImage(mdsp, xw, 0, 0, XSize(), YSize(), plane_mask, ZPixmap); 840 //DBG cout << " Resultat XGetImage -> " << hex << ximg << dec << endl; 841 if (ximg == NULL) return; 842 843 unsigned long red,green,blue; 844 unsigned long fred,fgreen,fblue; 845 XColor col; 846 Colormap cmap = XDefaultColormap (mdsp, scr); 847 red = 0x000000FF; 848 green = 0x0000FF00; 849 blue = 0x00FF0000; 850 unsigned short maxrgb = ~0; 851 col.red = maxrgb; col.green = col.blue = 0; 852 if (XAllocColor(mdsp, cmap, &col)) red = col.pixel; 853 col.green = maxrgb; col.red = col.blue = 0; 854 if (XAllocColor(mdsp, cmap, &col)) green = col.pixel; 855 col.blue = maxrgb; col.red = col.green = 0; 856 if (XAllocColor(mdsp, cmap, &col)) blue = col.pixel; 857 _col2_fcol_(red, fred); 858 _col2_fcol_(green, fgreen); 859 _col2_fcol_(blue, fblue); 860 rgba.SetSize(XSize(), YSize()); 861 unsigned long pixel; 862 PIPixRGB rgb; 863 for(int j=0; j<YSize(); j++) 864 for(int i=0; i<XSize(); i++) { 865 pixel = XGetPixel(ximg, i, j); 866 rgb.red = (pixel&red)/fred; 867 rgb.green = (pixel&green)/fgreen; 868 rgb.blue = (pixel&blue)/fblue; 869 rgba(i,j) = rgb; 870 } 871 XDestroyImage(ximg); 872 return; 873 } 833 874 834 875 -
trunk/SophyaPI/PI/piwdgx.h
r4077 r4083 63 63 virtual void SetUnSensitive(); 64 64 virtual bool IfSensitive(); 65 66 // Pour exporter le tableau des pixels du widget en classe PIPixRGBArray 67 virtual void ExportToRGB(PIPixRGBArray & rgba); 65 68 66 69 // Gestion de copier-coller -
trunk/SophyaPI/PI/piwindowgen.h
r4077 r4083 22 22 virtual long kind() {return ClassId; } 23 23 24 25 24 virtual void PSPrint(PSFile *psf, int ofx=0, int ofy=0, 25 double scale_x=1., double scale_y=1.); 26 26 27 27 inline void AutoHideOnClose(bool ahc=true) { mAHC = ahc; } -
trunk/SophyaPI/PI/piwindowx.cc
r4077 r4083 152 152 //if (mWtyp == PIWK_transient) 153 153 XRaiseWindow(mdsp, XtWindow(pwm->XtWdg())); 154 // cmv+rz Fevrier 2009 (retour Moriond) - Suppression de XFlush() / usleep 155 // Probleme regle par gestion VisibilityChange event ds pixtbase.cc 154 156 // cmv+rz 09/08/2007 Ajout XFlush() + usleep 155 157 // pour regler le probleme de perte d'evenement expose a la creation 156 XFlush(mdsp); usleep(5000);158 // XFlush(mdsp); usleep(5000); 157 159 return; 158 160 } -
trunk/SophyaPI/PI/pixtbase.cc
r4077 r4083 46 46 47 47 static XtResource resources[] ={ 48 { PIXNobject ,(char *)"Object", XtRPointer, sizeof(XtRPointer),48 {const_cast<char*>(PIXNobject) ,const_cast<char*>("Object"), XtRPointer, sizeof(XtRPointer), 49 49 XtOffset(PIXtBaseWidget, pixtbase.objet), XtRImmediate, (XtPointer)0}, 50 50 }; … … 143 143 } 144 144 145 // Pour traiter les etats de changements de visibilite de la fenetre 146 /* Nouvelle-Fonction */ 147 void visibchange_handler_pixtbase (Widget wdgp, XtPointer /*closure*/, 148 XEvent* evt, Boolean* cont) 149 { 150 #ifdef DEBUG_PIXTB 151 printf("Debug_visibchange_handler_pixtbase: Wdg= %lx Object= %lx fgvis_expose= %d (EvtType=%d VisSt=%d)\n", 152 (long)wdgp, (long)(((PIXtBaseWidget)wdgp)->pixtbase.objet), 153 ((PIXtBaseWidget)wdgp)->pixtbase.vis_expose_fg, (int)evt->type,(int)evt->xvisibility.state); 154 #endif 155 PIXtBaseWidget bwdg = (PIXtBaseWidget)wdgp; 156 if (bwdg->pixtbase.vis_expose_fg != 1) return; 157 if (evt->xvisibility.state == VisibilityFullyObscured) return; 158 int x0, y0, dx, dy; 159 x0 = y0 = 0; 160 dx = wdgp->core.width; dy = wdgp->core.height; 161 (bwdg->pixtbase.objet)->eXposeProcess(x0, y0, dx, dy); 162 bwdg->pixtbase.vis_expose_fg = 0; 163 } 164 145 165 /* Nouvelle-Fonction */ 146 166 static void init_pixtbase (Widget request, Widget wdg, … … 154 174 // get_GCs (wdgp); 155 175 #ifdef DEBUG_PIXTB 156 printf("Debug_init_pixtbase: Wdg=%lx Object= %lx narg=%d \n", 157 (long)wdgp, (long)(wdgp->pixtbase.objet), (int)(*narg)); 158 #endif 159 return; 160 } 161 162 /* Nouvelle-Fonction */ 163 static void destroy_pixtbase (Widget /*wdgp*/) 176 printf("Debug_init_pixtbase: Wdg=%lx Object= %lx \n", 177 (long)wdgp, (long)(wdgp->pixtbase.objet)); 178 #endif 179 180 // Pour gerer les exposes event avec fenetre non visible ... 181 wdgp->pixtbase.vis_expose_fg = 0; 182 XtAddEventHandler(wdg, VisibilityChangeMask, FALSE, visibchange_handler_pixtbase, NULL); 183 return; 184 } 185 186 /* Nouvelle-Fonction */ 187 static void destroy_pixtbase (Widget wdgp) 164 188 { 165 189 #ifdef DEBUG_PIXTB … … 194 218 (long)(((PIXtBaseWidget)wdgp)->pixtbase.objet) ); 195 219 #endif 196 if (!(wdgp->core.visible)) return; 197 if ( ((PIXtBaseWidget)wdgp)->pixtbase.objet ) 198 { 220 if (!(wdgp->core.visible)) { 221 ((PIXtBaseWidget)wdgp)->pixtbase.vis_expose_fg = 1; 222 return; 223 } 224 if ( ((PIXtBaseWidget)wdgp)->pixtbase.objet ) { 199 225 XRectangle xrec; 200 226 int x0, y0, dx, dy; 201 XClipBox(region, &xrec); 202 x0 = xrec.x; y0 = xrec.y; 203 dx = xrec.width; dy = xrec.height; 227 if (region) { 228 XClipBox(region, &xrec); 229 x0 = xrec.x; y0 = xrec.y; 230 dx = xrec.width; dy = xrec.height; 231 } 232 else { 233 x0 = y0 = 0; 234 dx = wdgp->core.width; dy = wdgp->core.height; 235 } 204 236 (((PIXtBaseWidget)wdgp)->pixtbase.objet)->eXposeProcess(x0, y0, dx, dy); 205 } 237 ((PIXtBaseWidget)wdgp)->pixtbase.vis_expose_fg = 0; 238 } 206 239 return; 207 240 } -
trunk/SophyaPI/PI/pixtbaseP.h
r4077 r4083 24 24 PIBaseWdgX * objet; 25 25 unsigned long myeventmask; 26 unsigned int vis_expose_fg; // Gestion des expose_event avec fenetre non visible 26 27 } PIXtBasePart; 27 28 -
trunk/SophyaPI/PI/psfile.cc
r4077 r4083 682 682 } 683 683 /* Portrait ou Landscape ? */ 684 if(orientation == PI_Auto) 684 if(orientation == PI_Auto) { 685 685 if( ((tw < th) && (Dx < 1.2*Dy)) || 686 686 ((tw > th) && (Dx > Dy) )) … … 688 688 else 689 689 currentPage->orientation = PI_Landscape ; 690 690 } 691 691 if(currentPage->orientation == PI_Portrait) { 692 692 // if( (tw/Dx) < (th/Dy) ) … … 1367 1367 for(i = 0; i < Ny; i++) { 1368 1368 for(j = 0; j<Nx-1; j++ ) 1369 fprintf(mPSFile, "%02X", Pict[i*Nx+j]); 1370 fprintf(mPSFile, "%02X\n", Pict[i*Nx+j]); 1369 fprintf(mPSFile, "%02X", (int)Pict[i*Nx+j]); 1370 fprintf(mPSFile, "%02X\n", (int)Pict[i*Nx+j]); 1371 } 1372 /* Un petit grestore ...*/ 1373 fprintf(mPSFile, "gr\n"); 1374 } 1375 1376 void PSFile::Image(double x0, double y0, double Tx, double Ty, 1377 int Nx, int Ny, 1378 unsigned short *Pict, 1379 PIColorMap *mMap) { 1380 1381 int i, j; 1382 1383 /* Buffers PostScript */ 1384 fprintf(mPSFile, "/Taille %d def\n", Nx); 1385 fprintf(mPSFile, "/ImStr Taille string def\n"); 1386 fprintf(mPSFile, "/RGBStr Taille 3 mul string def\n"); 1387 1388 /* Ecriture ColorMap */ 1389 fprintf(mPSFile, "/ColorMap %05d array def\n", mMap->NCol() ); 1390 for(i = 0; i < mMap->NCol(); i++) { 1391 fprintf(mPSFile, "ColorMap %d [16#%02X 16#%02X 16#%02X] put\n", 1392 i, 1393 (int)(mMap->GetColor(i).red/256), 1394 (int)(mMap->GetColor(i).green/256), 1395 (int)(mMap->GetColor(i).blue/256)); 1396 } 1397 /* Emplacement de l'image */ 1398 fprintf(mPSFile, "gs %.2f Ux %.2f Uy tr %.2f Ux %.2f Uy sc\n", x0, y0, Tx, Ty); 1399 /* Nbr pix-X, Nbr pix-Y bits/pixels */ 1400 fprintf(mPSFile, "%d %d 16\n", Nx, Ny); 1401 /* Matrice de passage */ 1402 fprintf(mPSFile, "[%d 0 0 %d 0 0]", Nx, Ny); 1403 /* Fonction colorimage */ 1404 fprintf(mPSFile, "{currentfile ImStr readhexstring pop GetRGB}\ 1405 false 3 colorimage\n\n"); 1406 /* Data */ 1407 for(i = 0; i < Ny; i++) { 1408 for(j = 0; j<Nx-1; j++ ) 1409 fprintf(mPSFile, "%04X", (int)Pict[i*Nx+j]); 1410 fprintf(mPSFile, "%04X\n", (int)Pict[i*Nx+j]); 1371 1411 } 1372 1412 /* Un petit grestore ...*/ -
trunk/SophyaPI/PI/psfile.h
r4077 r4083 165 165 unsigned char *pict, 166 166 PIColorMap *mColorMap); 167 virtual void Image(double x0, double y0, double Tx, double Ty, 168 int Nx, int Ny, 169 unsigned short *pict, 170 PIColorMap *mColorMap); 167 171 168 172 // Declarations en public - sinon certains compilateurs cxx , aCC, xlC ont des problemes
Note: See TracChangeset
for help on using the changeset viewer.