Changeset 1910 in Sophya for trunk/SophyaPI
- Timestamp:
- Feb 21, 2002, 12:41:53 AM (24 years ago)
- Location:
- trunk/SophyaPI/PI
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/SophyaPI/PI/piaxestools.cc
r1592 r1910 75 75 PIAxesTools::PIAxesTools(PIApplication* par) 76 76 : PIWindow((PIMsgHandler*)par, "PIAxesTools", PIWK_normal, 240, 240, 150, 150) 77 , mTypAction(0), mSclAction(0.) 77 78 { 78 79 int bsx, bsy, spx, spy; … … 80 81 // On definit la taille a partir de la taille par defaut des composantes 81 82 // PIApplicationPrefCompSize(bsx, bsy); 82 par->PrefCompSize(bsx, bsy); 83 par->PrefCompSize(bsx, bsy); // environ 6 lettres 83 84 spx = bsx/10; 84 85 spy = bsy/4; 85 86 86 int wszx = 5*spx+3.5*bsx;87 int wszy = 6*bsy+8*spy;87 int wszx = 6*spx+4.*bsx; 88 int wszy = 7*bsy+9*spy; 88 89 SetSize(wszx, wszy); 89 90 … … 109 110 110 111 cpx = spx+0.25*bsx; 111 cpy += spy+bsy; 112 cpy += spy+bsy; 112 113 mCkb[0] = new PICheckBox(this,"X-RtoL", 2000, bsx, bsy, cpx, cpy); 113 114 cpx += spx+bsx; … … 142 143 mBut[3]->SetBinding(PIBK_elastic,PIBK_elastic, PIBK_elastic,PIBK_elastic); 143 144 144 /* 145 int offy = cpy+bsy+spy*2; 146 147 // Option-Menu Marker, Line, couleur, etc... 148 cpx = 2*spx; 149 cpy += 3*spy+bsy; 150 151 int bsyo = bsy; 152 int spyo = spy; 153 bsy = 0.85*bsy; spy = 0.85*spy; 154 155 mOpt[0] = new PIOptMenu(this, "bwt-opt-0", bsx*1.75, bsy, cpx, cpy); 156 mOpt[0]->AppendItem("Def.Col", 100); 157 mOpt[0]->AppendItem("Black", 101); 158 mOpt[0]->AppendItem("White", 102); 159 mOpt[0]->SetValue(100); 160 mOpt[0]->SetBinding(PIBK_elastic, PIBK_elastic, PIBK_elastic, PIBK_elastic); 161 162 cpx += spx+1.75*bsx; 163 mOpt[1] = new PIOptMenu(this, "bwt-opt-1", bsx*1.75, bsy, cpx, cpy); 164 mOpt[1]->AppendItem("No.CMap", 200); 165 */ 166 145 cpy += spy+bsy; 146 cpx = spx; 147 mBut[4] = new PIButton(this,"<<",2801,0.5*bsx,bsy,cpx,cpy); 148 mBut[4]->SetBinding(PIBK_elastic,PIBK_elastic, PIBK_elastic,PIBK_elastic); 149 cpx += spx+0.5*bsx; 150 mBut[5] = new PIButton(this,"<",2802,0.5*bsx,bsy,cpx,cpy); 151 mBut[5]->SetBinding(PIBK_elastic,PIBK_elastic, PIBK_elastic,PIBK_elastic); 152 cpx += spx+0.5*bsx; 153 mOpt = new PIOptMenu(this,"choix-action",2.*bsx,bsy,cpx,cpy); 154 mOpt->AppendItem("Transl X",2850); // mTypAction=0 155 mOpt->AppendItem("Transl Y",2851); // mTypAction=1 156 mOpt->AppendItem("Zoom X",2852); // mTypAction=2 157 mOpt->AppendItem("Zoom Y",2853); // mTypAction=3 158 mOpt->AppendItem("Zoom X-Y",2854); // mTypAction=4 159 mOpt->SetBinding(PIBK_elastic,PIBK_elastic, PIBK_elastic,PIBK_elastic); 160 string sdum="Transl X"; mOpt->SetValueStr(sdum); mTypAction=0; 161 cpx += spx+2.*bsx; 162 mBut[6] = new PIButton(this,">",2803,0.5*bsx,bsy,cpx,cpy); 163 mBut[6]->SetBinding(PIBK_elastic,PIBK_elastic, PIBK_elastic,PIBK_elastic); 164 cpx += spx+0.5*bsx; 165 mBut[7] = new PIButton(this,">>",2804,0.5*bsx,bsy,cpx,cpy); 166 mBut[7]->SetBinding(PIBK_elastic,PIBK_elastic, PIBK_elastic,PIBK_elastic); 167 167 168 168 cwaxet = this; … … 174 174 if (cwaxet == this) cwaxet = NULL; 175 175 int i; 176 for(i=0; i<2; i++) { 177 delete mLab[i]; 178 delete mBut[i]; 179 delete mText[i]; 180 } 181 for(i=0; i<4; i++) delete mBut[i]; 182 for(i=0; i<5; i++) delete mCkb[i]; 183 184 } 185 176 for(i=0;i<2;i++) delete mLab[i]; 177 for(i=0;i<2;i++) delete mText[i]; 178 for(i=0;i<8;i++) delete mBut[i]; 179 for(i=0;i<5;i++) delete mCkb[i]; 180 delete mOpt; 181 } 186 182 187 183 /* --Methode-- */ … … 226 222 void PIAxesTools::SetAxes(bool refr) 227 223 { 224 PIScDrawWdg* scd = curscdwdg; 225 if ( scd == NULL ) return; 226 228 227 double xmin, xmax, ymin, ymax; 228 if(mText[0]->GetText().length()>1 && mSclAction==0.) { 229 xmin = -1.; xmax = 1.; 230 sscanf(mText[0]->GetText().c_str(), "%lg %lg" , &xmin, &xmax); 231 } else { 232 xmin = scd->XMin(); 233 xmax = scd->XMax(); 234 } 235 if(mText[1]->GetText().length()>1 && mSclAction==0.) { 236 ymin = -1.; ymax = 1.; 237 sscanf(mText[1]->GetText().c_str(), "%lg %lg" , &ymin, &ymax); 238 } else { 239 ymin = scd->YMin(); 240 ymax = scd->YMax(); 241 } 242 243 if(mSclAction!=0.) { 244 double d; 245 if(mTypAction==0) { // Translation X 246 d = mSclAction*(xmax-xmin); xmin += d; xmax += d; 247 } else if(mTypAction==1) { // Translation Y 248 d = mSclAction*(ymax-ymin); ymin += d; ymax += d; 249 } else { // Zoom X, Y ou X-Y 250 double c, s=(mSclAction>0.)? 1./(1.+mSclAction): (1.-mSclAction); 251 if((mTypAction==2 || mTypAction==4) && xmax-xmin>0.) { 252 c = (xmin+xmax)/2.; d = s*(xmax-xmin)/2.; 253 xmin = c - d; xmax = c + d; 254 } 255 if((mTypAction==3 || mTypAction==4) && ymax-ymin>0.) { 256 c = (ymin+ymax)/2.; d = s*(ymax-ymin)/2.; 257 ymin = c - d; ymax = c + d; 258 } 259 } 260 } 261 229 262 int axrl = kAxeDirLtoR; 230 263 int ayud = kAxeDirDownUp; 231 PIScDrawWdg* scd = curscdwdg;232 if ( scd == NULL ) return;233 if (mText[0]->GetText().length() > 1) {234 xmin = -1.; xmax = 1.;235 sscanf(mText[0]->GetText().c_str(), "%lg %lg" , &xmin, &xmax);236 }237 else {238 xmin = scd->XMin();239 xmax = scd->XMax();240 }241 if (mText[1]->GetText().length() > 1) {242 ymin = -1.; ymax = 1.;243 sscanf(mText[1]->GetText().c_str(), "%lg %lg" , &ymin, &ymax);244 }245 else {246 ymin = scd->YMin();247 ymax = scd->YMax();248 }249 264 if (mCkb[0]->GetState()) axrl = kAxeDirRtoL ; 250 265 if (mCkb[1]->GetState()) ayud = kAxeDirUpDown; … … 262 277 void PIAxesTools::Process(PIMessage msg, PIMsgHandler* /*sender*/, void* /*data*/) 263 278 { 279 // Petit deplacement (zoom) ">" ou "<" de 20% 280 // Grand deplacement (zoom) ">>" ou "<<" de 50% 281 // *** ATTENTION: Valeurs OBLIGATOIREMENT ]0,1[ bornes exclues *** 282 double smallstep=0.2, bigstep=0.5; 264 283 265 284 msg = UserMsg(msg); 266 285 mSclAction = 0.; 267 286 268 287 switch (msg) { 288 269 289 case 2100 : 270 290 UpdateAxesInfoFromScWdg(); 271 291 break; 272 273 292 case 2200 : 274 293 if ( curscdwdg != NULL ) { … … 276 295 UpdateAxesInfoFromScWdg(); 277 296 } 278 /* 279 PIDraw3DWdg* dr3 = dynamic_cast<PIDraw3DWdg *>(curscdwdg); 280 if (dr3 != NULL) dr3->Update3DView(); 281 */ 282 break; 283 297 break; 284 298 case 2500 : 285 299 SetAxes(true); … … 290 304 break; 291 305 306 case 2801 : // < 307 mSclAction = -bigstep; 308 SetAxes(true); 309 break; 310 case 2802 : // << 311 mSclAction = -smallstep; 312 SetAxes(true); 313 break; 314 case 2803 : // > 315 mSclAction = smallstep; 316 SetAxes(true); 317 break; 318 case 2804 : // >> 319 mSclAction = bigstep; 320 SetAxes(true); 321 break; 322 323 case 2850 : 324 case 2851 : 325 case 2852 : 326 case 2853 : 327 case 2854 : 328 mTypAction = msg - 2850; 329 break; 330 292 331 default : 293 332 break; -
trunk/SophyaPI/PI/piaxestools.h
r1589 r1910 38 38 // Pour changer les axes 39 39 PILabel* mLab[2]; 40 PIButton* mBut[ 4];40 PIButton* mBut[8]; 41 41 PIText* mText[2]; 42 42 PICheckBox* mCkb[5]; 43 // 43 PIOptMenu * mOpt; 44 unsigned short mTypAction; 45 double mSclAction; 46 44 47 static PIScDrawWdg* curscdwdg; 45 48 static PIAxesTools* cwaxet;
Note:
See TracChangeset
for help on using the changeset viewer.