Changeset 52 in Sophya
- Timestamp:
- Aug 8, 1997, 8:57:53 PM (28 years ago)
- Location:
- trunk/SophyaPI/PI
- Files:
-
- 4 added
- 28 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/SophyaPI/PI/piapplx.cc
r23 r52 64 64 Display *mdsp; 65 65 mdsp = XtDisplay (topwdg->XtWdg()); 66 topwdg->Un manage();66 topwdg->UnManage(); 67 67 delete menubar; 68 68 if (topcont != MBCont()) delete topcont; -
trunk/SophyaPI/PI/pibwdggen.cc
r32 r52 2 2 3 3 #include "pibwdggen.h" 4 #include "pidrawer.h" 4 5 #include "psfile.h" 5 6 … … 12 13 { 13 14 mPSOut=NULL; 15 mDrwId=0; // Compteur des numeros sequentiel des PIDrawer 16 mAdfg=false; // Pour controle d'appel de RemoveDrawer() 14 17 } 15 18 … … 18 21 PIBaseWdgGen::~PIBaseWdgGen() 19 22 { 20 } 21 23 DeleteDrawers(); 24 } 22 25 23 26 27 /* --Methode-- */ 28 void PIBaseWdgGen::SaveGraphicAtt() 29 { 30 sFCol = GetForeground(); 31 sBCol = GetBackground(); 32 sGOm = GetGOMode(); 33 sFAtt = GetFontAtt(); 34 sFSize = GetFontSize(); 35 sLAtt = GetLineAtt(); 36 sMrk = GetMarker(); 37 sMrkSz = GetMarkerSize(); 38 return; 39 } 40 41 /* --Methode-- */ 42 void PIBaseWdgGen::RestoreGraphicAtt() 43 { 44 SelForeground(sFCol); 45 SelBackground(sBCol); 46 SelGOMode(sGOm); 47 SelFontSzPt(sFSize, sFAtt); 48 SelLine(sLAtt); 49 SelMarker(sMrkSz, sMrk); 50 return; 51 } 24 52 25 53 /* --Methode-- */ … … 131 159 } 132 160 161 162 /* --Methode-- */ 163 int PIBaseWdgGen::AddDrawer(PIDrawer* drw, int x0, int y0, int dx, int dy, bool ad) 164 { 165 if (drw == NULL) return(0); 166 mDrwId++; 167 BWDrwId did; 168 did.x0 = x0; did.y0 = y0; 169 did.dx = dx; did.dy = dy; 170 did.id = mDrwId; did.ad = ad; 171 did.drw = drw; 172 mDrwList.push_back(did); 173 drw->Attach((PIBaseWdg*)this, mDrwId); 174 return(mDrwId); 175 } 176 177 /* --Methode-- */ 178 void PIBaseWdgGen::RemoveDrawer(int id) 179 { 180 if (mAdfg) return; 181 list<BWDrwId>::iterator it; 182 for(it = mDrwList.begin(); it != mDrwList.end(); it++) 183 if ((*it).id == id) 184 { (*it).drw->Detach((PIBaseWdg*)this, id); mDrwList.erase(it); break; } 185 return; 186 } 187 188 /* --Methode-- */ 189 void PIBaseWdgGen::DeleteDrawers() 190 { 191 mAdfg = true; 192 list<BWDrwId>::iterator it; 193 for(it = mDrwList.begin(); it != mDrwList.end(); it++) 194 if ((*it).ad) delete (*it).drw; 195 mDrwList.erase(mDrwList.begin(), mDrwList.end() ); 196 mAdfg = false; 197 return; 198 } 199 200 201 /* --Methode-- */ 202 void PIBaseWdgGen::CallDrawers(int x0, int y0, int dx, int dy) 203 { 204 double xmin,ymin, xmax, ymax; 205 206 bool sxy = false; 207 if ((dx > 0) && (dy > 0)) sxy = true; 208 209 list<BWDrwId>::iterator it; 210 bool fgc=false; 211 for(it = mDrwList.begin(); it != mDrwList.end(); it++) { 212 SaveGraphicAtt(); 213 (*it).drw->SetDrwWdg(this, (*it).x0, (*it).y0, (*it).dx, (*it).dy); 214 SetClipRectangle((*it).x0, (*it).y0, (*it).dx , (*it).dy); 215 fgc = true; 216 if (sxy) { 217 (*it).drw->Local2Sc(x0, y0, xmin, ymin); 218 (*it).drw->Local2Sc(x0+dx, y0+dy, xmax, ymax); 219 if (xmin > xmax) swap(xmin,xmax); 220 if (ymin > ymax) swap(ymin,ymax); 221 (*it).drw->Draw(xmin, ymin, xmax, ymax); 222 } 223 else (*it).drw->Draw(); 224 RestoreGraphicAtt(); 225 } 226 if (fgc) ClearClipRectangle(); 227 228 } -
trunk/SophyaPI/PI/pibwdggen.h
r44 r52 2 2 #define PIBWDGGEN_H_SEEN 3 3 4 4 5 #include "pisysdep.h" 5 6 #include PIWDG_H 7 #include PICMAP_H 6 8 7 #include "pibwdggen.h" 9 // Mettre dans cet ordre, sinon g++ a des problemes 10 #include <list> 8 11 9 12 10 13 enum PIKeyModifier { PIKM_Blank = 0, PIKM_Shift = 1, PIKM_Alt = 2, PIKM_Cntl = 4 } ; 11 14 12 enum PIColors { PI_NotDefColor = -1, 15 enum PIColors { PI_NotDefColor = -1, 13 16 PI_Black = 0, PI_White = 1, PI_Grey = 2, 14 17 PI_Red = 3, PI_Blue = 4, PI_Green = 5, 15 PI_Yellow = 6, PI_Magenta = 7 };18 PI_Yellow = 6, PI_Magenta = 7 }; 16 19 17 20 enum PIFontSize { PI_NotDefFontSize = -1, … … 61 64 62 65 // Trace graphiques 63 virtual void EraseWindow( )= 0;64 virtual void DrawString(int x, int y, char* s, int pos = 0) = 0;66 virtual void EraseWindow(int x0=0, int y0=0, int dx=0, int dy=0) = 0; 67 virtual void DrawString(int x, int y, char* s, int pos = 0) = 0; 65 68 virtual void DrawLine(int x1, int y1, int x2, int y2) = 0; 66 69 virtual void DrawBox(int x0, int y0, int dx, int dy) = 0; … … 72 75 virtual void DrawMarker(int x0, int y0) = 0; 73 76 virtual void DrawMarkers(int *x, int *y, int n) = 0; 74 75 77 virtual void DrawPixmap(int x, int y, unsigned char *pix, 78 int sx, int sy, PIColorMap* cmap) = 0; 76 79 77 80 virtual int CalcStringWidth(char const* s) = 0; … … 88 91 virtual void SelMarker(int msz=3, PIMarker mrk=PI_DotMarker) = 0; 89 92 93 // Selection de zone de trace (clip) 94 virtual void SetClipRectangle(int x0, int y0, int dx, int dy) = 0; 95 virtual void ClearClipRectangle() = 0; 96 90 97 // Acces aux attributs graphiques 91 98 virtual PIColors GetForeground() = 0; … … 98 105 virtual PIMarker GetMarker() = 0; 99 106 virtual int GetMarkerSize() = 0; 107 virtual int GetFontHeight(int& asc, int& desc) = 0; 108 109 // Sauvegarde des attributs graphiques 110 virtual void SaveGraphicAtt(); 111 virtual void RestoreGraphicAtt(); 100 112 101 113 … … 122 134 123 135 // PostScript output 124 virtual void PSPrint(PSFile * psf, int ofx = 0, int ofy = 0); 136 virtual void PSPrint(PSFile * psf, int ofx = 0, int ofy = 0); 125 137 138 // Gestion des Drawers 139 friend class PIDrawer; 140 int AddDrawer(PIDrawer* drw, int x0, int y0, int dx, int dy, 141 bool ad=false); 142 void RemoveDrawer(int id); // Ote un drawer de la liste 143 void DeleteDrawers(); // Ote et detruit tous les drawers 144 145 // Devrait etre protected - mis ici a cause de cxx 11/07/97 Reza 146 struct BWDrwId { int x0, y0; int dx, dy; int id; bool ad; PIDrawer* drw; }; 147 126 148 protected: 149 virtual void CallDrawers(int x0, int y0, int dx, int dy); // Appel le trace des drawers 150 127 151 PSFile * mPSOut; /* Fichier PostScript eventuel */ 152 153 bool mAdfg; 154 int mDrwId; 155 list<BWDrwId> mDrwList; 156 // Pour Save/Restore des attributs graphiques 157 PIColors sFCol, sBCol; 158 PIGOMode sGOm; 159 PIFontAtt sFAtt; 160 PILineAtt sLAtt; 161 int sFSize; 162 PIMarker sMrk; 163 int sMrkSz; 164 128 165 }; 129 166 -
trunk/SophyaPI/PI/pibwdgmac.cc
r15 r52 49 49 50 50 /* --Methode-- */ 51 void PIBaseWdgMac::EraseWindow( )51 void PIBaseWdgMac::EraseWindow(int x0, int y0, int dx, int dy) 52 52 { 53 53 if (mPane->FocusDraw()) { -
trunk/SophyaPI/PI/pibwdgmac.h
r15 r52 25 25 26 26 // Trace graphiques 27 virtual void EraseWindow( );27 virtual void EraseWindow(int x0=0, int y0=0, int dx=0, int dy=0); 28 28 virtual void DrawString(int x, int y, char* s, int pos = 0); 29 29 virtual void DrawLine(int x1, int y1, int x2, int y2); -
trunk/SophyaPI/PI/pibwdgx.cc
r44 r52 8 8 #include <X11/CoreP.h> 9 9 10 #include "pibwdgx.h"11 12 10 #include "pixtbaseP.h" 13 11 #include "pixtbase.h" 14 12 13 #include "pibwdgx.h" 14 #include "pidrawer.h" 15 15 #include "psfile.h" 16 16 … … 26 26 static Cursor curs[NMAXCURS]; 27 27 28 /* GC pour DrawPixmap */ 29 static GC dpxgc; 28 30 29 31 // #define DEBUG_PIBWDGX Flag pour impression de debug etc ... … … 60 62 SelPointerShape(); 61 63 SelMarker(1, PI_DotMarker); 64 62 65 Manage(); 63 66 } … … 67 70 PIBaseWdgX::~PIBaseWdgX() 68 71 { 69 } 70 71 72 73 } 74 75 /* --Methode-- */ 76 void PIBaseWdgX::FinishCreate() 77 { 78 // appele par la fenetre mere, apres XtRealize() 79 // J'active le backing store pour la fenetre X 80 XSetWindowAttributes xswa; 81 Window mwi; 82 mwi = XtWindow(XtWdg()); 83 xswa.backing_store = WhenMapped; 84 xswa.backing_planes = ~0; 85 XChangeWindowAttributes(PIXDisplay(), XtWindow(XtWdg()), CWBackingPlanes|CWBackingStore, &xswa); 86 } 72 87 73 88 /* --Methode-- */ … … 131 146 } 132 147 133 /* --Methode-- */ 134 void PIBaseWdgX::EraseWindow() 148 149 /* --Methode-- */ 150 void PIBaseWdgX::EraseWindow(int x0, int y0, int dx, int dy) 135 151 { 136 152 if(mPSOut) return; 137 XClear Window (XtDisplay(XtWdg()),XtWindow(XtWdg()));138 return; 139 } 140 141 /* --Methode-- */ 142 void PIBaseWdgX::DrawString(int x, int y, char* s, int pos)153 XClearArea (XtDisplay(XtWdg()),XtWindow(XtWdg()), x0, y0, dx, dy, False ); 154 return; 155 } 156 157 /* --Methode-- */ 158 void PIBaseWdgX::DrawString(int x, int y, char* s, int /*pos*/) 143 159 { 144 160 if(mPSOut){ 145 mPSOut->DrawString((float)x,(float)y,s,mFCol,mFAtt,mFSize); /* PIFontSize ?? */161 mPSOut->DrawString((float)x,(float)y,s,mFCol,mFAtt,mFSize); /* $CHECK$ PIFontSize ?? */ 146 162 } 147 163 else … … 183 199 { 184 200 if(mPSOut) 185 mPSOut->DrawFBox((float)x0,(float)y0,(float)dx,(float)dy );201 mPSOut->DrawFBox((float)x0,(float)y0,(float)dx,(float)dy, mFCol, mFCol, mLAtt); 186 202 else{ 187 203 if (dx < 0) { x0 += dx; dx = -dx; } … … 229 245 if(mPSOut) 230 246 { 231 xtmp = (float*)malloc(n*sizeof(float));232 ytmp = (float*)malloc(n*sizeof(float));247 xtmp = new float[n]; 248 ytmp = new float[n]; 233 249 for(i=0;i<n;i++){ 234 250 xtmp[i] = (float)x[i]; … … 236 252 } 237 253 mPSOut->DrawPolygon(xtmp,ytmp,n,mFCol,mLAtt); 238 free(xtmp);239 free(ytmp);254 delete[] xtmp; 255 delete[] ytmp; 240 256 } 241 257 else { … … 262 278 if(mPSOut) 263 279 { 264 xtmp = (float*)malloc(n*sizeof(float));265 ytmp = (float*)malloc(n*sizeof(float));280 xtmp = new float[n]; 281 ytmp = new float[n]; 266 282 for(i=0;i<n;i++){ 267 283 xtmp[i] = (float)x[i]; … … 269 285 } 270 286 mPSOut->DrawFPolygon(xtmp,ytmp,n,mFCol,mFCol,mLAtt); 271 free(xtmp);272 free(ytmp);287 delete[] xtmp; 288 delete[] ytmp; 273 289 } 274 290 else … … 354 370 if(mPSOut) 355 371 { 356 xtmp = (float*)malloc(n*sizeof(float));357 ytmp = (float*)malloc(n*sizeof(float));372 xtmp = new float[n]; 373 ytmp = new float[n]; 358 374 for(i=0;i<n;i++){ 359 375 xtmp[i] = (float)x[i]; … … 361 377 } 362 378 mPSOut->DrawMarkers(xtmp,ytmp,n,mMrk,mFCol, mMrkSz); 363 free(xtmp);364 free(ytmp);379 delete[] xtmp; 380 delete[] ytmp; 365 381 } 366 382 else … … 380 396 } 381 397 } 398 399 400 /* --Methode-- */ 401 void PIBaseWdgX::DrawPixmap(int x, int y, unsigned char *pix, 402 int sx, int sy, PIColorMap* cmap) 403 { 404 Window xw; 405 Display * mdsp; 406 int scr; 407 int depth; 408 int pad; 409 int i,j; 410 XImage * ximg; 411 412 if ( (sx < 1) || (sy < 1) ) return; 413 if ((pix == NULL) || (cmap == NULL)) return; 414 415 if(mPSOut) { 416 mPSOut->Image((float)x, (float)y, (float)sx, (float)sy, sx, sy, pix, cmap); 417 return; 418 } 419 420 xw = XtWindow(XtWdg()); 421 mdsp = PIXDisplay(); 422 scr = PIXScreen(); 423 424 depth = DefaultDepth(mdsp,scr); 425 pad = (depth > 8) ? 32 : 8; 426 ximg = XCreateImage (mdsp,DefaultVisual(mdsp,scr), 427 depth,ZPixmap,0,NULL, sx, sy, pad,0); 428 if (ximg == NULL) return; 429 ximg->data = new char [sy*ximg->bytes_per_line]; 430 if (ximg->data == NULL) 431 { XFree(ximg); return; } 432 433 for(j=0; j<sy; j++) 434 for(i=0; i<sx; i++) 435 { XPutPixel(ximg, i, j, cmap->Color(*pix) ); pix++; } 436 437 XPutImage(mdsp, xw, dpxgc, ximg, 0, 0, x, y, sx, sy); 438 439 delete[] ximg->data; 440 XFree(ximg); 441 return; 442 } 443 382 444 383 445 /* --Methode-- */ … … 527 589 } 528 590 591 592 /* --Methode-- */ 593 void PIBaseWdgX::SetClipRectangle(int x0, int y0, int dx, int dy) 594 { 595 XRectangle xr; 596 xr.x = x0; xr.y = y0; 597 xr.width = dx; xr.height = dy; 598 XSetClipRectangles(XtDisplay(XtWdg()), DefGC(), 0, 0, &xr, 1, Unsorted); 599 XSetClipRectangles(XtDisplay(XtWdg()), dpxgc, 0, 0, &xr, 1, Unsorted); 600 return; 601 } 602 603 /* --Methode-- */ 604 void PIBaseWdgX::ClearClipRectangle() 605 { 606 XSetClipMask(XtDisplay(XtWdg()), DefGC(), None); 607 XSetClipMask(XtDisplay(XtWdg()), dpxgc, None); 608 return; 609 } 610 529 611 /* --Methode-- */ 530 612 PIColors PIBaseWdgX::GetForeground() … … 582 664 } 583 665 584 666 /* --Methode-- */ 667 int PIBaseWdgX::GetFontHeight(int& asc, int& desc) 668 { 669 char a[2]; 670 XCharStruct ovr; 671 int hd, fa, fd; 672 XTextExtents(mFSt, a, 0, &hd, &fa, &fd, &ovr); 673 asc = fa; desc = fd; 674 return(fa+fd); 675 } 676 677 678 /* --Methode-- */ 679 void PIBaseWdgX::SaveGraphicAtt() 680 { 681 // Pour optimier l'implementation de PIBaseWdgGen 682 sFCol = mFCol; sBCol = mBCol; 683 sGOm = mGOm; 684 sFAtt = mFAtt; sFSize = mFSize; 685 sMrk = mMrk; sMrkSz = mMrkSz; 686 return; 687 } 585 688 586 689 /* --Methode-- */ … … 620 723 this->DrawFBox(10,10, XSize()*2/3, YSize()*2/3); 621 724 #endif 725 CallDrawers(0,0,0,0); 622 726 return; 623 727 } … … 644 748 645 749 /* --Methode-- */ 646 void PIBaseWdgX::But1Press(int x, int y)750 void PIBaseWdgX::But1Press(int, int) 647 751 { 648 752 #ifdef DEBUG_PIBWDGX … … 653 757 654 758 /* --Methode-- */ 655 void PIBaseWdgX::But1Release(int x, int y)759 void PIBaseWdgX::But1Release(int, int) 656 760 { 657 761 Send(Msg(), PIMsg_Active); … … 688 792 689 793 /* --Methode-- */ 690 void PIBaseWdgX::Ptr1Move(int x, int y)794 void PIBaseWdgX::Ptr1Move(int , int ) 691 795 { 692 796 #ifdef DEBUG_PIBWDGX … … 710 814 711 815 /* --Methode-- */ 712 void PIBaseWdgX::Keyboard(int key, PIKeyModifier kmod)816 void PIBaseWdgX::Keyboard(int /*key*/, PIKeyModifier /*kmod*/) 713 817 { 714 818 … … 844 948 curs[PI_TDLRArrowPointer] = XCreateFontCursor(mdsp, XC_fleur); 845 949 950 /* le GC pour DrawPixmap */ 951 XGCValues xgv; 952 xgv.function = GXcopy; 953 xgv.plane_mask = ~0; 954 dpxgc = XCreateGC(mdsp, DefaultRootWindow(mdsp), GCFunction | GCPlaneMask, &xgv); 955 846 956 return; 847 957 } … … 879 989 return; 880 990 } 991 992 -
trunk/SophyaPI/PI/pibwdgx.h
r11 r52 16 16 virtual ~PIBaseWdgX(); 17 17 18 virtual void FinishCreate(); // appele par la fenetre mere, apres XtRealize() 18 19 19 20 // Activation des evenements … … 24 25 25 26 // Trace graphiques 26 virtual void EraseWindow( );27 virtual void EraseWindow(int x0=0, int y0=0, int dx=0, int dy=0); 27 28 virtual void DrawString(int x, int y, char* s, int pos = 0); 28 29 virtual void DrawLine(int x1, int y1, int x2, int y2); … … 35 36 virtual void DrawMarker(int x0, int y0); 36 37 virtual void DrawMarkers(int *x, int *y, int n); 38 virtual void DrawPixmap(int x, int y, unsigned char *pix, 39 int sx, int sy, PIColorMap* cmap); 37 40 38 41 virtual int CalcStringWidth(char const* s); … … 49 52 virtual void SelMarker(int msz, PIMarker mrk=PI_DotMarker); 50 53 54 // Selection de zone de trace (clip) 55 virtual void SetClipRectangle(int x0, int y0, int dx, int dy); 56 virtual void ClearClipRectangle(); 51 57 52 58 // Acces aux attributs graphiques … … 60 66 virtual PIMarker GetMarker(); 61 67 virtual int GetMarkerSize(); 68 virtual int GetFontHeight(int& asc, int& desc); 69 70 // Sauvegarde des attributs graphiques 71 virtual void SaveGraphicAtt(); 62 72 63 73 // Fonction qui doit etre appelee pour rafraichir (retracer) tout … … 85 95 86 96 protected: 97 87 98 void Init(); 88 99 void SelectFont(int isz, int jat); -
trunk/SophyaPI/PI/picontainergen.cc
r32 r52 10 10 { 11 11 mNCh = 0; 12 mACSup = mPaSup = false; 12 mACSup = false; // Pas de suppression auto des widgets fils au delete 13 mPaSup = false; 13 14 mChilds = new (PIWdgGen * [NCHALGRP]); 14 15 mMxCh = NCHALGRP; … … 39 40 { 40 41 stvis = 1; 42 Manage(); 41 43 return; 42 44 } … … 46 48 { 47 49 stvis = 0; 50 UnManage(); 48 51 return; 49 52 } -
trunk/SophyaPI/PI/picontainerx.cc
r2 r52 26 26 {} 27 27 28 /* --Methode-- */28 /* --Methode-- 29 29 void PIContainerX::Show() 30 30 { … … 33 33 } 34 34 35 /* --Methode-- */36 35 void PIContainerX::Hide() 37 36 { 38 37 PIContainerGen::Hide(); 39 Un manage();38 UnManage(); 40 39 } 41 40 41 */ -
trunk/SophyaPI/PI/picontainerx.h
r2 r52 18 18 virtual ~PIContainerX(); 19 19 20 virtual void Show();21 virtual void Hide();22 23 20 }; 24 21 -
trunk/SophyaPI/PI/pidrawwin.cc
r23 r52 16 16 17 17 void 18 PIDrawWindow::Add Drawer(PIScDrawer*d)18 PIDrawWindow::AddScDrawer(PIScDrawer* d, bool ad) 19 19 { 20 mDrawWdg->Add Drawer(d);20 mDrawWdg->AddScDrawer(d, ad); 21 21 } 22 22 -
trunk/SophyaPI/PI/pidrawwin.h
r18 r52 15 15 ~PIDrawWindow(); 16 16 17 virtual void Add Drawer(PIScDrawer*);17 virtual void AddScDrawer(PIScDrawer*, bool ad=false); 18 18 virtual void SetAxesFlags(int flags=-1); 19 19 inline PIScDrawWdg * DrawWdg() { return mDrawWdg; } -
trunk/SophyaPI/PI/pifilechox.cc
r41 r52 25 25 pif = (PIFileChooserX *) usd ; 26 26 pif->mSt = 1; 27 pif->MWin()->Un manage();27 pif->MWin()->UnManage(); 28 28 //pif->Send(pif->Msg(), (void *) (pif->GetFileName().c_str())); 29 29 CStrFrXmStr(calld->value, pif->mFName, 512); … … 39 39 pif->mSt = 0; 40 40 pif->mFName[0] = '\0'; 41 pif->MWin()->Un manage();41 pif->MWin()->UnManage(); 42 42 pif->Send(pif->Msg(), PIMsg_Cancel, NULL); 43 43 return; -
trunk/SophyaPI/PI/pihisto.cc
r37 r52 2 2 #include "pihisto.h" 3 3 4 PIHisto::PIHisto(Histo* histo )4 PIHisto::PIHisto(Histo* histo, bool ad) 5 5 : PIScDrawer(), mHisto(histo) 6 6 { 7 ahisup = false; // Flag pour suppression automatique de mHisto7 mAdDO = ad; // Flag pour suppression automatique de mHisto 8 8 } 9 9 10 10 PIHisto::~PIHisto() 11 11 { 12 if ( ahisup)12 if (mAdDO) 13 13 delete mHisto; 14 14 } 15 15 16 17 void18 PIHisto::AttachTo(PIScDrawWdg* wdg)19 {20 PIScDrawer::AttachTo(wdg);21 UpdateSize();22 }23 16 24 17 … … 26 19 PIHisto::UpdateSize() 27 20 { 28 if (!mDraw Wdg) return;29 if (mDraw Wdg->LimitsFixed()) return;21 if (!mDrawer) return; 22 if (mDrawer->LimitsFixed()) return; 30 23 // Commencer par trouver nos limites 31 24 … … 36 29 double ymin = mHisto->VMin(); 37 30 38 mDrawWdg->SetLimits(xmin, xmax, ymin, ymax); 39 mDrawWdg->SetAxesFlags(kBoxAxes | kExtTicks | kLabels); 31 if (mDrawWdg) 32 mDrawWdg->SetLimits(xmin, xmax, ymin, ymax); 33 else 34 mDrawer->SetLimits(xmin, xmax, ymin, ymax); 35 36 mDrawer->SetAxesFlags(kBoxAxes | kExtTicks | kLabels); 40 37 } 41 38 42 39 43 40 void 44 PIHisto::Draw( )41 PIHisto::Draw(double /*xmin*/, double /*ymin*/, double /*xmax*/, double /*ymax*/) 45 42 { 46 if (!mDraw Wdg) return;43 if (!mDrawer) return; 47 44 for (int i=0; i<mHisto->NBins(); i++) { 48 45 double left = mHisto->BinLowEdge(i); … … 50 47 double bottom = 0; 51 48 double height = (*mHisto)(i); 52 mDraw Wdg->ScDrawFBox(left,bottom,width,height);53 mDraw Wdg->ScDrawLine(left, bottom, left, bottom + height); // Au moins une ligne...49 mDrawer->DrawFBox(left,bottom,width,height); 50 mDrawer->DrawLine(left, bottom, left, bottom + height); // Au moins une ligne... 54 51 } 55 52 DrawStats(); … … 60 57 { 61 58 // Une boite dans le coin superieur droit 62 if (!mDraw Wdg) return;59 if (!mDrawer) return; 63 60 double cellHeight = (mDrawWdg->YMax() - mDrawWdg->YMin()) * 0.05; 64 61 double cellWidth = (mDrawWdg->XMax() - mDrawWdg->XMin()) * 0.23; 65 mDraw Wdg->ScDrawLine(mDrawWdg->XMax() - cellWidth, mDrawWdg->YMax(),62 mDrawer->DrawLine(mDrawWdg->XMax() - cellWidth, mDrawWdg->YMax(), 66 63 mDrawWdg->XMax() - cellWidth, mDrawWdg->YMax() - cellHeight); 67 mDraw Wdg->ScDrawLine(mDrawWdg->XMax() - cellWidth, mDrawWdg->YMax() - cellHeight,64 mDrawer->DrawLine(mDrawWdg->XMax() - cellWidth, mDrawWdg->YMax() - cellHeight, 68 65 mDrawWdg->XMax() , mDrawWdg->YMax() - cellHeight); 69 66 char label[50]; 70 67 sprintf(label, "N = %.6g", mHisto->NData()); 71 mDraw Wdg->ScSelFontSz((mDrawWdg->YMax() - mDrawWdg->YMin())/30);72 mDraw Wdg->ScDrawString(mDrawWdg->XMax() - cellWidth*0.9, mDrawWdg->YMax() - cellHeight*0.8, label);68 mDrawer->SelFontSz((mDrawWdg->YMax() - mDrawWdg->YMin())/30); 69 mDrawer->DrawString(mDrawWdg->XMax() - cellWidth*0.9, mDrawWdg->YMax() - cellHeight*0.8, label); 73 70 74 71 } 75 76 void77 PIHisto::Refresh()78 {79 if (!mDrawWdg) return;80 mDrawWdg->FreeLimits();81 UpdateSize();82 mDrawWdg->Refresh();83 } -
trunk/SophyaPI/PI/pihisto.h
r37 r52 2 2 #define PIHISTO_H 3 3 4 4 #include "histos.h" 5 5 #include "piscdrawwdg.h" 6 #include "histos.h"7 6 8 7 class PIHisto : public PIScDrawer { 9 8 public: 10 PIHisto(Histo* histo );9 PIHisto(Histo* histo, bool ad=false); 11 10 virtual ~PIHisto(); 12 virtual void Draw(); 11 virtual void Draw(double xmin, double ymin, double xmax, double ymax); 12 virtual void UpdateSize(); 13 13 virtual void DrawStats(); 14 virtual void Refresh(); // Recalcule les limites, et reaffiche15 inline void SetAutoDelHisto(bool ad=false) { ahisup = ad; }16 14 inline Histo* Histogram() { return(mHisto); } 17 15 18 16 protected: 19 17 Histo* mHisto; 20 bool ahisup;21 22 virtual void AttachTo(PIScDrawWdg*);23 virtual void UpdateSize();24 18 }; 25 19 -
trunk/SophyaPI/PI/pimenux.cc
r41 r52 18 18 19 19 /* Nouvelle-Fonction */ 20 void menub_action(Widget w, XtPointer *usd, XtPointer *calld)20 void menub_action(Widget /*w*/, XtPointer *usd, XtPointer* /*calld*/) 21 21 { 22 22 PIMenuX *pim; … … 131 131 132 132 /* --Methode-- */ 133 void PIMenuX::CheckItemNum(int n, bool st)133 void PIMenuX::CheckItemNum(int n, bool /*st*/) 134 134 { 135 135 printf("PIMenuX::CheckItemNum(%d,bool) Error/ Not yet implemented \n", n); … … 144 144 145 145 /* --Methode-- */ 146 void PIMenuX::Show(PIWdg *w, int px, int py)146 void PIMenuX::Show(PIWdg* /*w*/, int /*px*/, int /*py*/) 147 147 { 148 148 Manage(); … … 153 153 void PIMenuX::Hide() 154 154 { 155 // Un manage();155 // UnManage(); 156 156 } 157 157 -
trunk/SophyaPI/PI/pimsghandler.h
r37 r52 13 13 PIMsg_Resize = 3, 14 14 15 PIMsg_OK = 11, 16 PIMsg_Cancel = 12, 17 PIMsg_Help = 13, 18 19 PIMsg_DataChanged = 21, 20 PIMsg_Click = 22, 21 PIMsg_Press = 23, 15 PIMsg_Click = 21, 16 PIMsg_Press = 22, 17 PIMsg_Release = 23, 22 18 PIMsg_Drag = 24, 23 19 PIMsg_Drop = 25, 20 PIMsg_Copy = 26, 21 PIMsg_Paste = 27, 22 PIMsg_Cut = 28, 24 23 25 PIMsg_Select = 31, 26 PIMsg_ClearSel = 32 24 PIMsg_OK = 21, 25 PIMsg_Cancel = 22, 26 PIMsg_Help = 23, 27 28 PIMsg_DataChanged = 31, 29 PIMsg_Select = 32, 30 PIMsg_ClearSel = 33 27 31 28 32 }; -
trunk/SophyaPI/PI/pipixmapx.cc
r37 r52 169 169 myximg->data = new char [YSize()*myximg->bytes_per_line]; 170 170 if (myximg->data == NULL) 171 { XFree(myximg); myximg = NULL; }171 { XFree(myximg); myximg = NULL; return; } 172 172 173 173 for(j=0; j<YSize(); j++) -
trunk/SophyaPI/PI/piscdrawwdg.cc
r48 r52 1 #include "generalfit.h" 1 2 #include "piscdrawwdg.h" 2 #include "generalfit.h"3 #include <algorithm>4 5 3 6 4 PIScDrawWdg::PIScDrawWdg(PIContainerGen *par, char *nom, … … 8 6 :PIBaseWdg(par, nom, sx, sy, px, py) 9 7 { 10 SetLimits(-1, 1, -1, 1); 11 limitsFixed = 0; 8 mBDrw = new PIDrawer; 9 SetSpan(); 10 SetLimits(-1.,1.,-1.,1.); 11 FreeLimits(); 12 12 xEndDrag = yEndDrag = xBegDrag = yBegDrag = 0; 13 SetAxesFlags(kAxesDflt); 14 clip = true; 13 14 Clip(); 15 15 16 padsup = false; 16 17 mTrlb = mTxw = NULL; 17 18 mTrW = NULL; 18 19 SetTextWin(NULL); 20 19 21 ActivateButton(1); // Pour pouvoir activer la fenetre et coordonnees 20 22 ActivateMove(1); // " " " " … … 26 28 PIScDrawWdg::~PIScDrawWdg() 27 29 { 28 DeleteDrawers(); 30 DeleteScDrawers(); 31 delete mBDrw; 29 32 if (mTrW) delete mTrW; 30 33 } … … 33 36 void 34 37 PIScDrawWdg::SetLimits(double xmin, double xmax, double ymin, double ymax, 35 bool axrl, boolayud, bool tmp)38 int axrl, int ayud, bool tmp) 36 39 { 37 40 if (xmax <= xmin || ymax <= ymin) 38 41 return; // $CHECK$ exception ? 39 aXdir = axrl; // Vrai si Axe X de Droite vers Gauche 40 aYdir = ayud; // Vrai si Axe Y de Haut vers Bas 41 xMin = xmin; 42 xMax = xmax; 43 yMin = ymin; 44 yMax = ymax; 45 mPPos[0] = 0.5*(xMin+xMax); 46 mPPos[1] = 0.5*(yMin+yMax); 42 mBDrw->SetLimits(xmin, xmax, ymin, ymax, axrl, ayud); 43 mPPos[0] = 0.5*(XMin()+XMax()); 44 mPPos[1] = 0.5*(YMin()+YMax()); 47 45 if (!tmp) { 48 46 xMinS = xmin; … … 51 49 yMaxS = ymax; 52 50 } 53 CalcScale();54 CalcTicks();55 limitsFixed = 1;56 51 } 57 52 … … 59 54 PIScDrawWdg::Resize() 60 55 { 61 CalcScale(); 62 CalcTicks(); 56 SetSpan(); 63 57 Refresh(); 64 58 } 65 59 66 60 void 67 PIScDrawWdg::CalcScale() 68 { 69 double margeH = (xMax-xMin)*0.15; 70 double margeV = (yMax-yMin)*0.15; 71 xScale = XSize() / (xMax-xMin + 2*margeH); 72 if (aXdir) { 73 xScale = -xScale; 74 xOrg = (-xMax - margeH) * xScale;// + XPos(); 75 } 76 else xOrg = (-xMin + margeH) * xScale;// + XPos(); 77 yScale = YSize() / (yMax-yMin + 2*margeV); 78 if (!aYdir) { 79 yScale = -yScale; 80 yOrg = (-yMax - margeV) * yScale;// + YPos(); 81 } 82 else yOrg = (-yMin + margeV) * yScale;// + YPos(); 83 return; 84 } 85 86 void 87 PIScDrawWdg::CalcTicks() 88 { 89 double xExt = xMax-xMin; 90 int lx = (int) ceil(log10(xExt)-0.1); 91 xExt = pow(10.0,lx); 92 xMajTickStep = xExt/10; 93 xMinTickStep = xMajTickStep/10; 94 xFirstMajTick = int(xMin / xMajTickStep) * xMajTickStep; 95 if (xFirstMajTick < xMin) xFirstMajTick += xMajTickStep; 96 xFirstMinTick = int(xMin / xMinTickStep) * xMinTickStep; 97 if (xFirstMinTick < xMin) xFirstMinTick += xMinTickStep; 98 99 100 double yExt = yMax-yMin; 101 int ly = (int) ceil(log10(yExt)-0.1); 102 yExt = pow(10.0,ly); 103 yMajTickStep = yExt/10; 104 yMinTickStep = yMajTickStep/10; 105 yFirstMajTick = int(yMin / yMajTickStep) * yMajTickStep; 106 if (yFirstMajTick < yMin) yFirstMajTick += yMajTickStep; 107 yFirstMinTick = int(yMin / yMinTickStep) * yMinTickStep; 108 if (yFirstMinTick < yMin) yFirstMinTick += yMinTickStep; 109 110 // xMajTickLen = -2/yScale; 111 // xMinTickLen = -1/yScale; 112 // yMajTickLen = 2/xScale; 113 // yMinTickLen = 1/xScale; 114 115 yMajTickLen = (xMax-xMin)/100; 116 yMinTickLen = (xMax-xMin)/250; 117 xMajTickLen = (yMax-yMin)/100; 118 xMinTickLen = (yMax-yMin)/250; 119 120 } 121 122 void 123 PIScDrawWdg::Sc2Local(double x, double y, int& xpix, int& ypix) 124 { 125 xpix = int(xOrg + x*xScale + .5); 126 ypix = int(yOrg + y*yScale + .5); 127 } 128 129 void 130 PIScDrawWdg::Local2Sc(int xpix, int ypix, double& x, double& y) 131 { 132 x = (xpix-xOrg)/xScale; 133 y = (ypix-yOrg)/yScale; 134 } 135 136 137 void 138 PIScDrawWdg::DSc2Local(double dx, double dy, int& dxpix, int& dypix) 139 { 140 dxpix = int(dx*xScale + .5); 141 dypix = int(dy*yScale + .5); 142 } 143 144 double 145 PIScDrawWdg::ScStringWidth(char const* s) 146 { 147 return CalcStringWidth(s) / xScale; 148 } 149 150 void 151 PIScDrawWdg::ScSelFontSz(double size, PIFontAtt att) 152 { 153 int npt = int(fabs(size * yScale)+.5); 154 if (npt < 8) npt = 8; 155 if (npt > 127) npt = 127; 156 SelFontSzPt(npt, att); 157 } 158 159 void 160 PIScDrawWdg::ScSelMarker(double size, PIMarker mrk) 161 { 162 int isz = int(fabs(size * xScale)+.5); 163 SelMarker( isz, mrk); 164 } 165 166 void 167 PIScDrawWdg::ScDrawString(double x, double y, char* s, int pos) 168 { 169 int xPix, yPix; 170 Sc2Local(x, y, xPix, yPix); 171 DrawString(xPix, yPix, s, pos); 172 } 173 174 void 175 PIScDrawWdg::ScDrawLine(double x1, double y1, double x2, double y2) 176 { 61 PIScDrawWdg::SetSpan() 62 { 63 int x0, y0, dx, dy; 64 x0 = (int)(XSize()*0.12); 65 y0 = (int)(YSize()*0.12); 66 dx = (int)(XSize()*0.76+0.5); 67 dy = (int)(YSize()*0.76+0.5); 68 mBDrw->SetDrwWdg(this, x0, y0, dx, dy); 69 return; 70 } 71 72 void 73 PIScDrawWdg::DrawAxes(int flags) 74 { 75 mBDrw->DrawAxes(flags); 76 } 77 78 79 void 80 PIScDrawWdg::SetAxesFlags(int flags) 81 { 82 mBDrw->SetAxesFlags(flags); 83 } 177 84 178 if (clip) { 179 if (x2 < xMin && x1 < xMin) return; 180 if (x2 > xMax && x1 > xMax) return; 181 if (y1 < yMin && y2 < yMin) return; 182 if (y1 > yMax && y2 > yMax) return; 183 if (x2 < x1) { 184 swap(x1,x2); 185 swap(y1,y2); 186 } 187 if (x2>xMax) { 188 y2 = y1 + (y2-y1)/(x2-x1)*(xMax-x1); 189 x2 = xMax; 190 } 191 if (x1<xMin) { 192 y1 = y2 + (y1-y2)/(x1-x2)*(xMin-x2); 193 x1 = xMin; 194 } 195 if (y2 < y1) { 196 swap(x1,x2); 197 swap(y1,y2); 198 } 199 if (y2>yMax) { 200 x2 = x1 + (x2-x1)/(y2-y1)*(yMax-y1); 201 y2 = yMax; 202 } 203 if (y1<yMin) { 204 x1 = x2 + (x1-x2)/(y1-y2)*(yMin-y2); 205 y1 = yMin; 206 } 207 } 208 int x1Pix, y1Pix, x2Pix, y2Pix; 209 Sc2Local(x1, y1, x1Pix, y1Pix); 210 Sc2Local(x2, y2, x2Pix, y2Pix); 211 DrawLine(x1Pix, y1Pix, x2Pix, y2Pix); 212 } 213 214 215 void 216 PIScDrawWdg::ScDrawBox(double x, double y, double dx, double dy) 217 { 218 if (clip) { 219 if (dx < 0) { 220 x = x+dx; 221 dx = -dx; 222 } 223 if (dy < 0) { 224 y = y+dy; 225 dy = -dy; 226 } 227 if (x > xMax || x+dx < xMin || y > yMax || y+dy < yMin) return; 228 if (x < xMin) { 229 dx -= (xMin-x); 230 x = xMin; 231 } 232 if (y < yMin) { 233 dy -= (yMin-y); 234 y = yMin; 235 } 236 if (x+dx > xMax) 237 dx = (xMax-x); 238 if (y+dy > yMax) 239 dy = (yMax-y); 240 } 241 int xPix, yPix, x2Pix, y2Pix; 242 Sc2Local(x, y, xPix, yPix); 243 Sc2Local(x+dx, y+dy, x2Pix, y2Pix); 244 DrawBox(xPix, yPix, x2Pix-xPix, y2Pix-yPix); 245 } 246 247 void 248 PIScDrawWdg::ScDrawFBox(double x, double y, double dx, double dy) 249 { 250 if (clip) { 251 if (dx < 0) { 252 x = x+dx; 253 dx = -dx; 254 } 255 if (dy < 0) { 256 y = y+dy; 257 dy = -dy; 258 } 259 if (x > xMax || x+dx < xMin || y > yMax || y+dy < yMin) return; 260 if (x < xMin) { 261 dx -= (xMin-x); 262 x = xMin; 263 } 264 if (y < yMin) { 265 dy -= (yMin-y); 266 y = yMin; 267 } 268 if (x+dx > xMax) 269 dx = (xMax-x); 270 if (y+dy > yMax) 271 dy = (yMax-y); 272 } 273 int xPix, yPix, x2Pix, y2Pix; 274 Sc2Local(x, y, xPix, yPix); 275 Sc2Local(x+dx, y+dy, x2Pix, y2Pix); 276 DrawFBox(xPix, yPix, x2Pix-xPix, y2Pix-yPix); 277 } 278 279 void 280 PIScDrawWdg::ScDrawCircle(double x, double y, double r) 281 { 282 int xPix, yPix, rPix; 283 Sc2Local(x, y, xPix, yPix); 284 rPix = r * xScale; 285 DrawCircle(xPix, yPix, rPix); 286 } 287 288 void 289 PIScDrawWdg::ScDrawFCircle(double x, double y, double r) 290 { 291 int xPix, yPix, rPix; 292 Sc2Local(x, y, xPix, yPix); 293 rPix = r * xScale; 294 DrawFCircle(xPix, yPix, rPix); 295 } 296 297 #define NMXMULTP 30 // Pour multipoint sans new 298 299 void 300 PIScDrawWdg::ScDrawPolygon(double *x, double *y, int n) 301 { 302 int ix[NMXMULTP], iy[NMXMULTP]; 303 int *pxi, *pyi; 304 int i; 305 306 if (n <= 0) return; 307 if (n > NMXMULTP) { pxi = new int[n]; pyi = new int[n]; } 308 else { pxi = ix; pyi = iy; } 309 for(i=0; i<n; i++) 310 Sc2Local(x[i], y[i], pxi[i], pyi[i]); 311 DrawPolygon(pxi, pyi, n); 312 if (n > NMXMULTP) { delete[] pxi; delete[] pyi; } 313 return; 314 } 315 316 void 317 PIScDrawWdg::ScDrawFPolygon(double *x, double *y, int n) 318 { 319 int xi[NMXMULTP], yi[NMXMULTP]; 320 int *pxi, *pyi; 321 int i; 322 323 if (n <= 0) return; 324 if (n > NMXMULTP) { pxi = new int[n]; pyi = new int[n]; } 325 else { pxi = xi; pyi = yi; } 326 for(i=0; i<n; i++) 327 Sc2Local(x[i], y[i], pxi[i], pyi[i]); 328 DrawFPolygon(pxi, pyi, n); 329 if (n > NMXMULTP) { delete[] pxi; delete[] pyi; } 330 return; 331 } 332 333 void 334 PIScDrawWdg::ScDrawMarker(double x0, double y0) 335 { 336 int xPix, yPix; 337 Sc2Local(x0, y0, xPix, yPix); 338 DrawMarker(xPix, yPix); 339 return; 340 } 341 void 342 PIScDrawWdg::ScDrawMarkers(double *x, double *y, int n) 343 { 344 int xi[NMXMULTP], yi[NMXMULTP]; 345 int *pxi, *pyi; 346 int i; 347 348 if (n <= 0) return; 349 if (n > NMXMULTP) { pxi = new int[n]; pyi = new int[n]; } 350 else { pxi = xi; pyi = yi; } 351 for(i=0; i<n; i++) 352 Sc2Local(x[i], y[i], pxi[i], pyi[i]); 353 DrawMarkers(pxi, pyi, n); 354 if (n > NMXMULTP) { delete[] pxi; delete[] pyi; } 355 return; 356 } 357 358 void 359 PIScDrawWdg::DrawHTicks(double y, double tickUp, double tickDown, double xBeg, double xStep) 360 { 361 for (double x=xBeg; x<=xMax; x += xStep) 362 ScDrawLine(x, y-tickDown, x, y+tickUp); 363 } 364 365 void 366 PIScDrawWdg::DrawVTicks(double x, double tickLeft, double tickRight, double yBeg, double yStep) 367 { 368 for (double y=yBeg; y<=yMax; y += yStep) 369 ScDrawLine(x-tickLeft, y, x+tickRight, y); 370 } 371 372 void 373 PIScDrawWdg::DrawHLabels(double y, double xBeg, double xStep, int just) 374 { 375 double xOffset = 0; 376 int kk; 377 ScSelFontSz(xMajTickLen*4); 378 for (double x=xBeg; x<=xMax; x += xStep) { 379 char label[20]; sprintf(label, "%-6g", x); 380 for(kk=0; kk<20; kk++) 381 if (label[kk] == ' ') { label[kk] = '\0' ; break; } 382 double largeur = ScStringWidth(label); 383 if (just == 1) 384 xOffset = -largeur; 385 else if (just == 0) 386 xOffset = -largeur/2; 387 else 388 xOffset = 0; 389 if (aXdir) xOffset = -xOffset; 390 ScDrawString(x+xOffset, y, label); 391 } 392 } 393 394 void 395 PIScDrawWdg::DrawVLabels(double x, double yBeg, double yStep, int just) 396 { 397 double xOffset = 0; 398 ScSelFontSz(xMajTickLen*4); 399 for (double y=yBeg; y<=yMax; y += yStep) { 400 char label[20]; sprintf(label, "%-6g", y); 401 double largeur = ScStringWidth(label); 402 if (just == 1) 403 xOffset = -largeur; 404 else if (just == 0) 405 xOffset = -largeur/2; 406 else 407 xOffset = 0; 408 if (aXdir) xOffset = -xOffset; 409 ScDrawString(x+xOffset, y, label); 410 } 411 } 412 413 414 void 415 PIScDrawWdg::DrawAxes(int flags) 416 { 417 NoClip(); 418 if (flags == -1) 419 flags = axesFlags; 420 421 422 if (flags & kStdAxes) { 423 424 // Les axes 425 426 ScDrawLine(xMin, 0, xMax, 0); 427 ScDrawLine(0, yMin, 0, yMax); 428 429 // Les ticks majeurs 430 431 if (flags & kMajTicks) { 432 DrawHTicks(0, xMajTickLen, xMajTickLen, xFirstMajTick, xMajTickStep); 433 DrawVTicks(0, yMajTickLen, yMajTickLen, yFirstMajTick, yMajTickStep); 434 } 435 436 // Les ticks mineurs 437 438 if (flags & kMinTicks) { 439 DrawHTicks(0, xMinTickLen, xMinTickLen, xFirstMinTick, xMinTickStep); 440 DrawVTicks(0, yMinTickLen, yMinTickLen, yFirstMinTick, yMinTickStep); 441 } 442 443 // Les labels 444 445 if (flags & kLabels) { 446 if (!aYdir) 447 DrawHLabels(-xMajTickLen*8, xFirstMajTick, xMajTickStep,0); 448 else 449 DrawHLabels(xMajTickLen*8, xFirstMajTick, xMajTickStep,0); 450 if (!aXdir) 451 DrawVLabels(-yMajTickLen*2, yFirstMajTick, yMajTickStep,1); 452 else 453 DrawVLabels(yMajTickLen*2, yFirstMajTick, yMajTickStep,1); 454 } 455 456 } 457 458 if (flags & kBoxAxes) { 459 460 // La boite 461 462 ScDrawLine(xMin, yMin, xMax, yMin); 463 ScDrawLine(xMax, yMin, xMax, yMax); 464 ScDrawLine(xMax, yMax, xMin, yMax); 465 ScDrawLine(xMin, yMax, xMin, yMin); 466 467 // Longueur des ticks 468 469 double extXMajTickLen = flags&kExtTicks ? xMajTickLen : 0; 470 double intXMajTickLen = flags&kIntTicks ? xMajTickLen : 0; 471 double extXMinTickLen = flags&kExtTicks ? xMinTickLen : 0; 472 double intXMinTickLen = flags&kIntTicks ? xMinTickLen : 0; 473 double extYMajTickLen = flags&kExtTicks ? yMajTickLen : 0; 474 double intYMajTickLen = flags&kIntTicks ? yMajTickLen : 0; 475 double extYMinTickLen = flags&kExtTicks ? yMinTickLen : 0; 476 double intYMinTickLen = flags&kIntTicks ? yMinTickLen : 0; 477 478 // Les ticks majeurs 479 480 if (flags & kMajTicks) { 481 DrawHTicks(yMin, intXMajTickLen, extXMajTickLen, xFirstMajTick, xMajTickStep); 482 DrawHTicks(yMax, extXMajTickLen, intXMajTickLen, xFirstMajTick, xMajTickStep); 483 DrawVTicks(xMin, extYMajTickLen, intYMajTickLen, yFirstMajTick, yMajTickStep); 484 DrawVTicks(xMax, intYMajTickLen, extYMajTickLen, yFirstMajTick, yMajTickStep); 485 } 486 487 // Les ticks mineurs 488 489 if (flags & kMinTicks) { 490 DrawHTicks(yMin, intXMinTickLen, extXMinTickLen, xFirstMinTick, xMinTickStep); 491 DrawHTicks(yMax, extXMinTickLen, intXMinTickLen, xFirstMinTick, xMinTickStep); 492 DrawVTicks(xMin, extYMinTickLen, intYMinTickLen, yFirstMinTick, yMinTickStep); 493 DrawVTicks(xMax, intYMinTickLen, extYMinTickLen, yFirstMinTick, yMinTickStep); 494 } 495 496 497 // Les labels 498 499 if (flags & kLabels) { 500 if (!aYdir) { 501 DrawHLabels(yMin-xMajTickLen*8, xFirstMajTick, xMajTickStep,0); 502 DrawHLabels(yMax+xMajTickLen*2, xFirstMajTick, xMajTickStep,0); 503 } 504 else { 505 DrawHLabels(yMin-xMajTickLen*2, xFirstMajTick, xMajTickStep,0); 506 DrawHLabels(yMax+xMajTickLen*8, xFirstMajTick, xMajTickStep,0); 507 } 508 if (!aXdir) { 509 DrawVLabels(xMin-yMajTickLen*2, yFirstMajTick, yMajTickStep,1); 510 DrawVLabels(xMax+yMajTickLen*2, yFirstMajTick, yMajTickStep,-1); 511 } 512 else { 513 DrawVLabels(xMin-yMajTickLen*2, yFirstMajTick, yMajTickStep,-1); 514 DrawVLabels(xMax+yMajTickLen*2, yFirstMajTick, yMajTickStep,1); 515 } 516 } 517 } 518 Clip(); 519 } 520 521 522 523 void 524 PIScDrawWdg::AddDrawer(PIScDrawer* d) 525 { 526 mDrawers.push_back(d); 527 d->AttachTo(this); 528 } 529 530 void 531 PIScDrawWdg::RemoveDrawer(PIScDrawer* d) 85 86 void 87 PIScDrawWdg::AddScDrawer(PIScDrawer* d, bool ad) 88 { 89 bool pd=false; 90 if (mScDrawers.size() == 0) pd = true; 91 mScDrawers.push_back(d); 92 d->AttachTo(this, ad, pd); 93 } 94 95 void 96 PIScDrawWdg::RemoveScDrawer(PIScDrawer* d) 532 97 { 533 98 if (padsup) return; 534 mDrawers.remove(d); 535 d->mDrawWdg = NULL; 536 } 537 538 void 539 PIScDrawWdg::DeleteDrawers() 99 vector<PIScDrawer*>::iterator drw; 100 for(drw = mScDrawers.begin(); drw != mScDrawers.end(); drw++) 101 if (d == (*drw)) { mScDrawers.erase(drw); break; } 102 d->mDrawWdg = NULL; d->mDrawer = NULL; 103 } 104 105 int 106 PIScDrawWdg::NbScDrawers() 107 { 108 return(mScDrawers.size()); 109 } 110 111 PIScDrawer* 112 PIScDrawWdg::ScDrawer(int i) 113 { 114 if ( (i<0) || (i>mScDrawers.size()) ) return(NULL); 115 return(mScDrawers[i]); 116 } 117 118 119 void 120 PIScDrawWdg::DeleteScDrawers() 540 121 { 541 122 padsup = true; 542 for(list<PIScDrawer*>::iterator i = mDrawers.begin(); i != mDrawers.end(); i++) 543 delete *i; 544 mDrawers.erase(mDrawers.begin(),mDrawers.end()); 123 vector<PIScDrawer*>::iterator i; 124 for(i = mScDrawers.begin(); i != mScDrawers.end(); i++) { 125 if ( (*i)->ADelByDrwWdg() ) delete *i; 126 } 127 mScDrawers.erase(mScDrawers.begin(),mScDrawers.end()); 545 128 padsup = false; 546 129 } 547 130 548 131 void 549 PIScDrawWdg::CallDrawer(PIScDrawer* d) 550 { 551 d->Draw(); 552 } 553 554 void 555 PIScDrawWdg::CallDrawers() 556 { 557 for_each(mDrawers.begin(), mDrawers.end(), CallDrawer); 558 } 559 560 void 561 PIScDrawWdg::SetAxesFlags(int flags) 562 { 563 axesFlags = flags; 564 if (axesFlags & (kIntTicks | kExtTicks | kMajTicks | kMinTicks)) 565 axesFlags |= kTicks; 566 if ((axesFlags & (kTicks | kIntTicks | kExtTicks)) == kTicks) 567 axesFlags |= kIntTicks | kExtTicks; 568 if ((axesFlags & (kTicks | kMajTicks | kMinTicks)) == kTicks) 569 axesFlags |= kMajTicks; 570 } 132 PIScDrawWdg::CallScDrawers(double xmin, double ymin, double xmax, double ymax) 133 { 134 vector<PIScDrawer*>::iterator drw; 135 for(drw = mScDrawers.begin(); drw != mScDrawers.end(); drw++) { 136 (*drw)->SelGraAtt(); 137 (*drw)->Draw(xmin, ymin, xmax, ymax); 138 } 139 } 140 571 141 void 572 142 PIScDrawWdg::SetTextWin(PILabel * tw, bool trw, int tx, int ty) … … 580 150 mTrW = new PIWindow(this, "Point", PIWK_transient, tx, ty, 0, 0); 581 151 mTrW->SetAutoDelChilds(true); 582 mTrlb = new PILabel(mTrW, "P ixVal", tx, ty, 0, 0);152 mTrlb = new PILabel(mTrW, "PointCoord", tx, ty, 0, 0); 583 153 mTrlb->SetBinding(PIBK_fixed,PIBK_fixed, PIBK_fixed,PIBK_fixed); 584 154 } … … 595 165 EraseWindow(); 596 166 DrawAxes(); 597 CallDrawers(); 598 DrawSelf(); 599 } 600 167 DrawSelf(-9.e19, -9.e19, 9.e19, 9.e19); 168 CallScDrawers(-9.e19, -9.e19, 9.e19, 9.e19); 169 CallDrawers(0,0,0,0); 170 } 171 172 void 173 PIScDrawWdg::Draw(int x0, int y0, int dx, int dy) 174 { 175 double xmin,xmax,ymin,ymax; 176 mBDrw->Local2Sc(x0, y0, xmin, ymin); 177 mBDrw->Local2Sc(x0+dx, y0+dy, xmax, ymax); 178 if (xmin > xmax) swap(xmin,xmax); 179 if (ymin > ymax) swap(ymin,ymax); 180 DrawAxes(); 181 DrawSelf(xmin, ymin, xmax, ymax); 182 CallScDrawers(xmin, ymin, xmax, ymax); 183 CallDrawers(x0, y0, dx, dy); 184 } 185 186 void 187 PIScDrawWdg::DrawSelf() 188 { 189 return; 190 } 191 192 void 193 PIScDrawWdg::DrawSelf(double /*xmin*/, double /*ymin*/, double /*xmax*/, double /*ymax*/) 194 { 195 return; 196 } 601 197 602 198 … … 641 237 642 238 double dx, dy; 643 Local2Sc(xp, yp, dx, dy);239 mBDrw->Local2Sc(xp, yp, dx, dy); 644 240 mPPos[0] = dx; mPPos[1] = dy; 645 241 if ((mTxw == NULL) && (mTrlb == NULL)) return(false); … … 684 280 685 281 if (xBegDrag == xEndDrag || yBegDrag == yEndDrag) 686 SetLimits(xMinS, xMaxS, yMinS, yMaxS, aXdir, aYdir);282 SetLimits(xMinS, xMaxS, yMinS, yMaxS, kAxeDirSame, kAxeDirSame ); 687 283 else { 688 284 double xl,yl,xh,yh; 689 Local2Sc(xBegDrag, yBegDrag, xl, yl);690 Local2Sc(xEndDrag, yEndDrag, xh, yh);285 mBDrw->Local2Sc(xBegDrag, yBegDrag, xl, yl); 286 mBDrw->Local2Sc(xEndDrag, yEndDrag, xh, yh); 691 287 if (xl > xh) swap(xl, xh); 692 288 if (yl > yh) swap(yl, yh); 693 SetLimits(xl,xh,yl,yh, aXdir, aYdir, true);289 SetLimits(xl,xh,yl,yh, kAxeDirSame, kAxeDirSame, true); 694 290 } 695 291 … … 710 306 //================================================================ 711 307 308 309 712 310 PIScDrawer::PIScDrawer() 713 : mDrawWdg(NULL) 714 {} 311 : mDrawWdg(NULL), mDrawer(NULL) 312 { 313 mADbW = mAdDO = mPrDw = false; 314 mFCol = mBCol = PI_NotDefColor; 315 mLAtt = PI_NotDefLineAtt; 316 mFSz = PI_NotDefFontSize; 317 mFAtt = PI_NotDefFontAtt; 318 mMSz = -1; 319 mMrk = PI_NotDefMarker; 320 } 715 321 716 322 PIScDrawer::~PIScDrawer() 717 323 { 718 324 if (mDrawWdg) 719 mDrawWdg->RemoveDrawer(this); 720 } 721 722 void 723 PIScDrawer::AttachTo(PIScDrawWdg* wdg) 325 mDrawWdg->RemoveScDrawer(this); 326 } 327 328 void 329 PIScDrawer::UpdateSize() 330 { 331 // Ne fait rien ! 332 return; 333 } 334 335 void 336 PIScDrawer::Refresh() 337 { 338 // Recalcule les limites, et reaffiche 339 if (!mDrawer) return; 340 mDrawWdg->FreeLimits(); 341 UpdateSize(); 342 if (mDrawWdg) mDrawWdg->Refresh(); 343 } 344 345 void 346 PIScDrawer::AttachTo(PIScDrawWdg* wdg, bool ad, bool prd) 724 347 { 725 348 if (mDrawWdg) 726 mDrawWdg->RemoveDrawer(this); 727 mDrawWdg = wdg; 728 } 729 730 349 mDrawWdg->RemoveScDrawer(this); 350 mDrawWdg = wdg; 351 mDrawer = wdg->BaseDrawer(); 352 UpdateSize(); 353 mADbW = ad; 354 mPrDw = prd; 355 } 356 357 // Classe PIDrawer special pour enrober un PIScDrawer en PIDrawer 358 class PIScContDrw : public PIDrawer { 359 public : 360 PIScContDrw(PIScDrawer* d, bool ad=false); 361 virtual ~PIScContDrw(); 362 virtual void Draw(); 363 virtual void Draw(double xmin, double ymin, double xmax, double ymax); 364 private: 365 PIScDrawer* mScDrw; 366 bool mAD; 367 }; 368 369 PIScContDrw::PIScContDrw(PIScDrawer* d, bool ad) 370 { 371 mScDrw = d; 372 mAD=ad; 373 } 374 375 PIScContDrw::~PIScContDrw() 376 { 377 if (mAD) delete mScDrw; 378 } 379 380 void PIScContDrw::Draw() 381 { 382 mScDrw->SelGraAtt(); 383 mScDrw->Draw(-9.e19, -9.e19, 9.e19, 9.e19); 384 } 385 386 void PIScContDrw::Draw(double xmin, double ymin, double xmax, double ymax) 387 { 388 mScDrw->SelGraAtt(); 389 mScDrw->Draw(xmin, ymin, xmax, ymax); 390 } 391 392 PIDrawer* 393 PIScDrawer::Convert() 394 { 395 PIScContDrw* rd; 396 if (mDrawWdg) mDrawWdg->RemoveScDrawer(this); 397 mDrawWdg = NULL; 398 rd = new PIScContDrw(this); 399 mDrawer = rd; 400 UpdateSize(); 401 return((PIDrawer*)rd); 402 } 403 404 void 405 PIScDrawer::SetColAtt(PIColors fg, PIColors bg) 406 { 407 if (fg != PI_NotDefColor) mFCol = fg; 408 if (bg != PI_NotDefColor) mBCol = bg; 409 } 410 411 void 412 PIScDrawer::SetLineAtt(PILineAtt lat) 413 { 414 if (lat != PI_NotDefLineAtt) mLAtt = lat; 415 } 416 417 void 418 PIScDrawer::SetFontAtt(PIFontSize fsz, PIFontAtt fat) 419 { 420 if (fsz != PI_NotDefFontSize) mFSz = fsz; 421 if (fat != PI_NotDefFontAtt) mFAtt = fat; 422 } 423 424 void 425 PIScDrawer::SetMarkerAtt(int sz, PIMarker mrk) 426 { 427 if (sz >= 0) mMSz = sz; 428 if (mrk != PI_NotDefMarker) mMrk = mrk; 429 } 430 431 void 432 PIScDrawer::SelGraAtt() 433 { 434 if (mDrawer == NULL) return; 435 if (mFCol != PI_NotDefColor) mDrawer->SelForeground(mFCol); 436 if (mBCol != PI_NotDefColor) mDrawer->SelBackground(mBCol); 437 if (mLAtt != PI_NotDefLineAtt) mDrawer->SelLine(mLAtt); 438 if ( (mFSz != PI_NotDefFontSize) || (mFAtt != PI_NotDefFontAtt) ) 439 mDrawer->SelFont(mFSz, mFAtt); 440 if ( (mMrk != PI_NotDefMarker) || (mMSz >= 0) ) 441 mDrawer->SelMarker(mMSz, mMrk); 442 } 731 443 732 444 //================================================================ … … 743 455 744 456 void 745 PIScFuncDrawer::Draw( )746 { 747 if (!mDraw Wdg) return;748 double xMax = mDraw Wdg->XMax();749 double xMin = mDraw Wdg->XMin();750 double yMax = mDraw Wdg->YMax();751 double yMin = mDraw Wdg->YMin();457 PIScFuncDrawer::Draw(double /*xmin*/, double/*ymin*/, double/*xmax*/, double/*ymax*/) 458 { 459 if (!mDrawer) return; 460 double xMax = mDrawer->XMax(); 461 double xMin = mDrawer->XMin(); 462 double yMax = mDrawer->YMax(); 463 double yMin = mDrawer->YMin(); 752 464 double xStep = (xMax - xMin)/100; 753 465 double xOld = xMin; … … 757 469 if (y>yMin && yOld>yMin && 758 470 y<yMax && yOld<yMax) 759 mDraw Wdg->ScDrawLine(xOld, yOld, x, y);471 mDrawer->DrawLine(xOld, yOld, x, y); 760 472 xOld = x; 761 473 yOld = y; … … 787 499 788 500 void 789 PIScGFFDrawer::Draw( )790 { 791 if (!mDraw Wdg) return;792 double xMax = mDraw Wdg->XMax();793 double xMin = mDraw Wdg->XMin();794 double yMax = mDraw Wdg->YMax();795 double yMin = mDraw Wdg->YMin();501 PIScGFFDrawer::Draw(double /*xmin*/, double/*ymin*/, double/*xmax*/, double/*ymax*/) 502 { 503 if (!mDrawer) return; 504 double xMax = mDrawer->XMax(); 505 double xMin = mDrawer->XMin(); 506 double yMax = mDrawer->YMax(); 507 double yMin = mDrawer->YMin(); 796 508 double xStep = (xMax - xMin)/100; 797 509 double xOld = xMin; … … 803 515 if (y>yMin && yOld>yMin && 804 516 y<yMax && yOld<yMax) 805 mDraw Wdg->ScDrawLine(xOld, yOld, x, y);517 mDrawer->DrawLine(xOld, yOld, x, y); 806 518 xOld = x; 807 519 yOld = y; -
trunk/SophyaPI/PI/piscdrawwdg.h
r48 r52 2 2 #define PISCDRAWWDG_H 3 3 4 #include <vector> 4 5 5 6 #include "pisysdep.h" … … 7 8 #include PISTDWDG_H 8 9 #include PIWIN_H 10 #include "pidrawer.h" 9 11 10 #include <list>11 12 12 enum {13 kStdAxes = 0x0001,14 kBoxAxes = 0x0002,15 kTicks = 0x0004,16 kIntTicks = 0x0010,17 kExtTicks = 0x0020,18 kMajTicks = 0x0040,19 kMinTicks = 0x0080,20 kLabels = 0x1000,21 kAxesDflt = kStdAxes | kTicks | kLabels22 };23 13 14 class PIScDrawer; 24 15 25 16 class PIScDrawWdg : public PIBaseWdg { … … 29 20 virtual ~PIScDrawWdg(); 30 21 31 virtual void SetLimits(double xmin, double xmax, double ymin, double ymax,32 bool axrl=false, bool ayud=false, bool tmp=false);33 34 virtual void ScDrawString(double x, double y, char* s, int pos = 0);35 virtual void ScDrawLine(double x1, double y1, double x2, double y2);36 virtual void ScDrawBox(double x0, double y0, double dx, double dy);37 virtual void ScDrawFBox(double x0, double y0, double dx, double dy);38 virtual void ScDrawCircle(double x0, double y0, double r);39 virtual void ScDrawFCircle(double x0, double y0, double r);40 virtual void ScDrawPolygon(double *x, double *y, int n);41 virtual void ScDrawFPolygon(double *x, double *y, int n);42 virtual void ScDrawMarker(double x0, double y0);43 virtual void ScDrawMarkers(double *x0, double *y0, int n);44 45 virtual double ScStringWidth(char const*);46 47 virtual void ScSelFontSz(double size, PIFontAtt att=PI_RomanFont);48 virtual void ScSelMarker(double size=0, PIMarker mrk=PI_DotMarker);49 50 virtual void DrawAxes(int flags = -1);51 virtual void DrawSelf() {}52 53 22 virtual void Resize(); 54 23 55 virtual void CalcTicks(); 56 virtual void CalcScale(); 24 virtual void Draw(); 25 virtual void Draw(int x0, int y0, int dx, int dy); 26 virtual void DrawSelf(); 27 virtual void DrawSelf(double xmin, double ymin, double xmax, double ymax); 57 28 58 virtual void Sc2Local(double x, double y, int& xpix, int& ypix); 59 virtual void Local2Sc(int xpix, int ypix, double& x, double& y); 60 virtual void DSc2Local(double dx, double dy, int& dxpix, int& dypix); 61 62 virtual void Draw(); 63 64 friend class PIScDrawer; 65 virtual void AddDrawer(PIScDrawer*); // Ajoute un drawer 66 virtual void RemoveDrawer(PIScDrawer*); // Ote un drawer sans le detruire 67 virtual void DeleteDrawers(); // Ote et detruit tous les drawers 68 static void CallDrawer(PIScDrawer*); 69 virtual void CallDrawers(); 70 virtual void SetAxesFlags(int flags=kAxesDflt); 71 72 void SetTextWin(PILabel * tw, bool trw=true, int tx=200, int ty=30); 29 void SetLimits(double xmin, double xmax, double ymin, double ymax, 30 int axrl=kAxeDirSame, int ayud=kAxeDirSame, bool tmp=false); 73 31 74 double XMin() const {return xMin;} 75 double XMax() const {return xMax;} 76 double YMin() const {return yMin;} 77 double YMax() const {return yMax;} 32 void SetAxesFlags(int flags=kAxesDflt); 33 void DrawAxes(int flags = -1); 34 35 void AddScDrawer(PIScDrawer*, bool ad=false); // Ajoute un ScDrawer 36 void RemoveScDrawer(PIScDrawer*); // Ote un ScDrawer sans le detruire 37 int NbScDrawers(); 38 PIScDrawer* ScDrawer(int i); 39 40 PIDrawer* BaseDrawer() { return mBDrw; }; 41 42 double XMin() const {return mBDrw->XMin();} 43 double XMax() const {return mBDrw->XMax();} 44 double YMin() const {return mBDrw->YMin();} 45 double YMax() const {return mBDrw->YMax();} 78 46 double XPPos() const { return mPPos[0]; } 79 47 double YPPos() const { return mPPos[1]; } 80 int LimitsFixed() const {return limitsFixed;}81 void FreeLimits() { limitsFixed = 0;}82 void NoClip() { clip = false;}83 void Clip() { clip = true;}48 int LimitsFixed() const {return mBDrw->LimitsFixed();} 49 void FreeLimits() { mBDrw->FreeLimits(); } 50 void NoClip() { mBDrw->NoClip(); } 51 void Clip() { mBDrw->NoClip(); } 84 52 53 54 void SetTextWin(PILabel * tw, bool trw=true, int tx=200, int ty=30); 85 55 86 56 virtual void But1Press(int x, int y); … … 93 63 94 64 protected: 95 double xMin, xMax, yMin, yMax; // Valeurs en unites user 65 void DeleteScDrawers(); // Ote et detruit tous les ScDrawers 66 void CallScDrawers(double xmin, double ymin, double xmax, double ymax); 67 void SetSpan(); 68 96 69 double xMinS, xMaxS, yMinS, yMaxS; // Sauvegarde pour zoom 97 double xOrg, yOrg; // Position en pixels de (0.0, 0.0)98 double xScale, yScale; // Pixels par unites graphiques99 bool aXdir, aYdir; // Sens des axes horiz, vertical100 70 double mPPos[2]; // Position click souris X,Y 101 double xFirstMajTick, xFirstMinTick; 102 double yFirstMajTick, yFirstMinTick; 103 double xMajTickStep, xMinTickStep; 104 double yMajTickStep, yMinTickStep; 105 double xMajTickLen, xMinTickLen; 106 double yMajTickLen, yMinTickLen; 107 108 int limitsFixed; 109 int axesFlags; 110 list<PIScDrawer*> mDrawers; 71 72 PIDrawer* mBDrw; 73 vector<PIScDrawer*> mScDrawers; 74 bool padsup; 111 75 112 76 int xBegDrag, yBegDrag; … … 119 83 PILabel * mTrlb; 120 84 PIWindow * mTrW; 121 bool clip;122 bool padsup;123 85 124 86 125 87 private: 126 void DrawHTicks(double y, double tickUp, double tickDown, double xBeg, double xStep);127 void DrawVTicks(double x, double tickLeft, double tickRight, double yBeg, double yStep);128 void DrawHLabels(double y, double xBeg, double xStep, int just=0);129 void DrawVLabels(double x, double yBeg, double yStep, int just=0);130 131 88 bool UpdateText(int xp, int yp); 132 89 }; 90 133 91 134 92 class PIScDrawer { … … 137 95 virtual ~PIScDrawer(); 138 96 139 virtual void Draw() = 0; 97 virtual void Draw(double xmin, double ymin, double xmax, double ymax) = 0; 98 virtual void UpdateSize(); // Calcule et change les limites si non fixees 99 virtual void Refresh(); // Recalcule les limites et reaffiche 100 101 PIDrawer* Convert(); 102 103 void SetColAtt(PIColors fg=PI_NotDefColor, 104 PIColors bg=PI_NotDefColor); 105 void SetLineAtt(PILineAtt lat=PI_NotDefLineAtt); 106 void SetFontAtt(PIFontSize fsz=PI_NotDefFontSize, 107 PIFontAtt fat=PI_NotDefFontAtt); 108 void SetMarkerAtt(int sz=-1, PIMarker mrk=PI_NotDefMarker); 109 110 void SelGraAtt(); 111 112 inline void SetAutoDelDataObj(bool ad=false) { mAdDO = ad; } 113 inline bool ADelByDrwWdg() { return mADbW; } 114 inline bool MainScDrawer() { return mPrDw; } 115 140 116 protected: 141 117 friend class PIScDrawWdg; 142 virtual void AttachTo(PIScDrawWdg*); 118 virtual void AttachTo(PIScDrawWdg*, bool, bool); 119 143 120 PIScDrawWdg* mDrawWdg; 121 PIDrawer* mDrawer; 122 bool mADbW, mAdDO, mPrDw; 123 PIColors mFCol, mBCol; 124 PILineAtt mLAtt; 125 PIFontSize mFSz; 126 PIFontAtt mFAtt; 127 int mMSz; 128 PIMarker mMrk; 144 129 }; 145 130 … … 150 135 virtual ~PIScFuncDrawer(); 151 136 152 virtual void Draw( );137 virtual void Draw(double xmin, double ymin, double xmax, double ymax); 153 138 protected: 154 139 FUNC mFunc; … … 161 146 virtual ~PIScGFFDrawer(); 162 147 163 virtual void Draw( );148 virtual void Draw(double xmin, double ymin, double xmax, double ymax); 164 149 virtual void SetParms(double const*); 165 150 protected: -
trunk/SophyaPI/PI/pistlist.cc
r37 r52 4 4 5 5 /* --Methode-- */ 6 PIStarList::PIStarList(StarList* stl, bool a yud)6 PIStarList::PIStarList(StarList* stl, bool ad, int ayud) 7 7 : PIScDrawer(), mStL(stl) 8 8 { 9 mAd elStl = false;9 mAdDO = ad; 10 10 mAYdir = ayud; 11 11 if (stl == NULL) return; … … 16 16 PIStarList::~PIStarList() 17 17 { 18 if (mAdelStl && mStL) 19 delete mStL; 18 if (mAdDO && mStL) delete mStL; 20 19 } 21 20 … … 57 56 } 58 57 59 /* --Methode-- */60 void PIStarList::AttachTo(PIScDrawWdg* wdg)61 {62 PIScDrawer::AttachTo(wdg);63 UpdateSize();64 }65 66 58 67 59 /* --Methode-- */ … … 69 61 { 70 62 if (!mStL) return; 71 if (!mDraw Wdg) return;72 if (mDraw Wdg->LimitsFixed()) return;63 if (!mDrawer) return; 64 if (mDrawer->LimitsFixed()) return; 73 65 74 66 // Commencer par trouver nos limites … … 78 70 dy = 0.02*(mYMax-mYMin); 79 71 80 mDrawWdg->SetLimits(mXMin-dx, mXMax+dx, mYMin-dy, mYMax+dy, false, mAYdir); 81 mDrawWdg->SetAxesFlags(kBoxAxes | kExtTicks | kLabels); 72 if (mDrawWdg) 73 mDrawWdg->SetLimits(mXMin-dx, mXMax+dx, mYMin-dy, mYMax+dy, kAxeDirLtoR, mAYdir); 74 else 75 mDrawer->SetLimits(mXMin-dx, mXMax+dx, mYMin-dy, mYMax+dy, false, mAYdir); 76 77 mDrawer->SetAxesFlags(kBoxAxes | kExtTicks | kLabels); 82 78 } 83 79 84 80 85 81 /* --Methode-- */ 86 void PIStarList::Draw( )82 void PIStarList::Draw(double xmin, double ymin, double xmax, double ymax) 87 83 { 88 84 BStar *sti; … … 93 89 94 90 if (!mStL) return; 95 if (!mDraw Wdg) return;91 if (!mDrawer) return; 96 92 97 mDraw Wdg->SelFont();93 mDrawer->SelFont(); 98 94 nok = 0; nl2 = mNLev*2-1; 99 95 for (int i=0; i<mStL->NbStars(); i++) { … … 104 100 xp = sti->PosX(); yp = sti->PosY(); 105 101 if ( (xp < mXMin) || (xp > mXMax) || (yp < mYMin) || (yp > mYMax) ) continue; 102 if ( (xp < xmin) || (xp > xmax) || (yp < ymin) || (yp > ymax) ) continue; 106 103 nok++; 107 104 sz = (int)((log10((double)flx/mF0))/mDLgF*(double)nl2-0.01) + mMSz0; 108 if (sz < 2) mDraw Wdg->SelMarker(sz, PI_DotMarker);109 else mDraw Wdg->SelMarker(sz, PI_FCircleMarker);110 mDraw Wdg->ScDrawMarker((double)xp,(double)yp );105 if (sz < 2) mDrawer->SelMarker(sz, PI_DotMarker); 106 else mDrawer->SelMarker(sz, PI_FCircleMarker); 107 mDrawer->DrawMarker((double)xp,(double)yp ); 111 108 if (mDspFV) { 112 109 sprintf(buff," F=%g", flx); 113 mDraw Wdg->Sc2Local(xp, yp, ixp, iyp);114 mDraw Wdg->DrawString( ixp+sz/2+1, iyp-4, buff);110 mDrawer->Sc2Local(xp, yp, ixp, iyp); 111 mDrawer->DrawString( ixp+sz/2+1, iyp-4, buff); 115 112 } 116 113 } 114 115 if (!MainScDrawer()) return; 116 if (!mDrawWdg) return; 117 117 118 118 sprintf(buff, "StarList: NbStars= %d NDisp= %d", (int)mStL->NbStars(), nok); … … 123 123 } 124 124 125 126 /* --Methode-- */127 void PIStarList::Refresh()128 {129 if (!mDrawWdg) return;130 mDrawWdg->FreeLimits();131 UpdateSize();132 mDrawWdg->Refresh();133 } -
trunk/SophyaPI/PI/pistlist.h
r37 r52 2 2 #define PISTLIST_H 3 3 4 4 #include "stlist.h" 5 5 #include "piscdrawwdg.h" 6 #include "stlist.h"7 6 8 7 class PIStarList : public PIScDrawer { 9 8 public: 10 PIStarList(StarList* stl, bool a yud=true);9 PIStarList(StarList* stl, bool ad, int ayud=kAxeDirUpDown); 11 10 virtual ~PIStarList(); 12 11 13 virtual void Draw( );14 virtual void Refresh(); // Recalcule les limites, et reaffiche12 virtual void Draw(double xmin, double ymin, double xmax, double ymax); 13 virtual void UpdateSize(); 15 14 16 inline void SetAutoDelStList(bool ad=false) { mAdelStl = ad; }17 15 void SetFluxLimits(float min=1., float max=-1., int nl=5, 18 16 int msz0=0, bool refr=false); … … 30 28 protected: 31 29 StarList* mStL; 32 bool mAdelStl;33 30 float mFmin, mFmax; 34 31 int mNLev, mMSz0; … … 37 34 float mYMin, mYMax; 38 35 bool mDspFV; 39 boolmAYdir;36 int mAYdir; 40 37 41 virtual void AttachTo(PIScDrawWdg*);42 virtual void UpdateSize();43 38 }; 44 39 -
trunk/SophyaPI/PI/piwdggen.h
r48 r52 60 60 virtual void GetScreenPos(int & spx, int & spy); 61 61 62 virtual void Manage()=0; 63 virtual void UnManage()=0; 64 virtual int IfManaged()=0; 65 62 66 virtual void PSPrint(PSFile *psf, int ofx=0, int ofy=0); 63 67 -
trunk/SophyaPI/PI/piwdgx.cc
r41 r52 11 11 #include <Xm/Xm.h> // A cause des container XmForm 12 12 #include <Xm/Form.h> // Idem 13 14 13 15 14 #include "piwdgx.h" … … 188 187 189 188 /* --Methode-- */ 190 void PIWdgX::Un manage()191 { 192 #ifdef DEBUG_PIWdgX 193 printf("Debug_PIWdgX::Un manage this=%lx sdw=%lx \n", (long)this, (long)sdw);189 void PIWdgX::UnManage() 190 { 191 #ifdef DEBUG_PIWdgX 192 printf("Debug_PIWdgX::UnManage this=%lx sdw=%lx \n", (long)this, (long)sdw); 194 193 #endif 195 194 if (!sdw) return; -
trunk/SophyaPI/PI/piwdgx.h
r37 r52 5 5 #define PIWDG_X_SEEN 6 6 7 #include <string>8 9 7 #include <X11/Xlib.h> 10 8 #include <X11/Intrinsic.h> 11 9 12 #include "piwdggen.h"13 10 #include "piwdggen.h" 14 11 … … 53 50 virtual void GetScreenPos(int & spx, int & spy); 54 51 55 v oidManage();56 v oid Unmanage();57 intIfManaged();52 virtual void Manage(); 53 virtual void UnManage(); 54 virtual int IfManaged(); 58 55 59 56 inline SysDWdg XtWdg() const {return(sdw); }; … … 77 74 Display * PIXDisplay(); 78 75 #define PIXScreen() DefaultScreen(PIXDisplay()) 76 Time PIXGetLastEventTime(); 77 unsigned long PIXGetLastEventSerial(); 79 78 80 79 #endif/* PIWDGX_SEEN */ -
trunk/SophyaPI/PI/piwindowx.cc
r41 r52 130 130 131 131 PIContainerGen::Show(); 132 Manage(); 132 // Manage(); $CHECK$ Ca ne doit plus etre necessaire Reza 9/7/97 133 133 if (!XtIsRealized(pwm->XtWdg())) fgr = 1; 134 134 pwm->Manage(); … … 143 143 else 144 144 XSetTransientForHint(mdsp, XtWindow(PIXtTopWdg()), XtWindow(pwm->XtWdg())); 145 // Pour faire les actions sur les fenetres X, sinon fenetre pas cree 146 int k; 147 for(k=0; k<mNCh; k++) mChilds[k]->FinishCreate(); 145 148 } 146 149 … … 156 159 { 157 160 PIWindowGen::Hide(); 158 Unmanage(); 159 pwm->Un manage();161 // UnManage(); $CHECK$ Ca ne doit plus etre necessaire Reza 9/7/97 162 pwm->UnManage(); 160 163 } 161 164 -
trunk/SophyaPI/PI/pixtbase.cc
r41 r52 110 110 111 111 112 static Time last_time_xevt = 0; 113 static unsigned long last_serial_xevt = 0; 114 115 Time PIXGetLastEventTime() { return(last_time_xevt); } 116 unsigned long PIXGetLastEventSerial() { return(last_serial_xevt); } 117 112 118 /* Nouvelle-Fonction */ 113 119 static void init_class_pixtbase() … … 174 180 175 181 /* Nouvelle-Fonction */ 176 static void enter_pixtbase (Widget wdgp, XEvent* /*evt*/,182 static void enter_pixtbase (Widget wdgp, XEvent* evt, 177 183 String* /*args*/, Cardinal* /*narg*/) 178 184 { 185 last_time_xevt = evt->xcrossing.time; 186 last_serial_xevt = evt->xcrossing.serial; 179 187 if (((PIXtBaseWidget)wdgp)->pixtbase.objet) 180 188 (((PIXtBaseWidget)wdgp)->pixtbase.objet)->Enter(); … … 183 191 184 192 /* Nouvelle-Fonction */ 185 static void leave_pixtbase (Widget wdgp, XEvent* /*evt*/,193 static void leave_pixtbase (Widget wdgp, XEvent* evt, 186 194 String* /*args*/, Cardinal* /*narg*/) 187 195 { 196 last_time_xevt = evt->xcrossing.time; 197 last_serial_xevt = evt->xcrossing.serial; 188 198 if (((PIXtBaseWidget)wdgp)->pixtbase.objet) 189 199 (((PIXtBaseWidget)wdgp)->pixtbase.objet)->Leave(); … … 196 206 197 207 { 208 last_time_xevt = evt->xbutton.time; 209 last_serial_xevt = evt->xbutton.serial; 198 210 if (((PIXtBaseWidget)wdgp)->pixtbase.objet) 199 211 { … … 211 223 212 224 { 225 last_time_xevt = evt->xbutton.time; 226 last_serial_xevt = evt->xbutton.serial; 213 227 if (((PIXtBaseWidget)wdgp)->pixtbase.objet) 214 228 { … … 225 239 226 240 { 241 last_time_xevt = evt->xbutton.time; 242 last_serial_xevt = evt->xbutton.serial; 227 243 if (((PIXtBaseWidget)wdgp)->pixtbase.objet) 228 244 { … … 239 255 String* /*args*/, Cardinal* /*narg*/) 240 256 { 257 last_time_xevt = evt->xbutton.time; 258 last_serial_xevt = evt->xbutton.serial; 241 259 if (((PIXtBaseWidget)wdgp)->pixtbase.objet) 242 260 { … … 255 273 256 274 { 275 last_time_xevt = evt->xbutton.time; 276 last_serial_xevt = evt->xbutton.serial; 257 277 if (((PIXtBaseWidget)wdgp)->pixtbase.objet) 258 278 { … … 270 290 271 291 { 292 last_time_xevt = evt->xbutton.time; 293 last_serial_xevt = evt->xbutton.serial; 272 294 if (((PIXtBaseWidget)wdgp)->pixtbase.objet) 273 295 { … … 284 306 String* /*args*/, Cardinal* /*narg*/) 285 307 { 308 last_time_xevt = evt->xbutton.time; 309 last_serial_xevt = evt->xbutton.serial; 286 310 if (((PIXtBaseWidget)wdgp)->pixtbase.objet) 287 311 { … … 298 322 String* /*args*/, Cardinal* /*narg*/) 299 323 { 324 last_time_xevt = evt->xbutton.time; 325 last_serial_xevt = evt->xbutton.serial; 300 326 if (((PIXtBaseWidget)wdgp)->pixtbase.objet) 301 327 { … … 312 338 String* /*args*/, Cardinal* /*narg*/) 313 339 { 340 last_time_xevt = evt->xbutton.time; 341 last_serial_xevt = evt->xbutton.serial; 314 342 if (((PIXtBaseWidget)wdgp)->pixtbase.objet) 315 343 { … … 326 354 String* /*args*/, Cardinal* /*narg*/) 327 355 { 356 last_time_xevt = evt->xkey.time; 357 last_serial_xevt = evt->xkey.serial; 328 358 if (((PIXtBaseWidget)wdgp)->pixtbase.objet) 329 359 { -
trunk/SophyaPI/PI/sc_sample.cc
r15 r52 29 29 int i; 30 30 SelForeground(PI_Green); 31 ScSelMarker(0.3, PI_BoxMarker);32 ScDrawMarkers(x, y, 5);31 BaseDrawer()->SelMarker(0.3, PI_BoxMarker); 32 BaseDrawer()->DrawMarkers(x, y, 5); 33 33 SelForeground(PI_Magenta); 34 ScSelMarker(0.3, PI_FCircleMarker);34 BaseDrawer()->SelMarker(0.3, PI_FCircleMarker); 35 35 for(i=0; i<5; i++) 36 36 y[i]+=1.; 37 ScDrawMarkers(x, y, 5);37 BaseDrawer()->DrawMarkers(x, y, 5); 38 38 SelForeground(PI_Black); 39 39 40 ScDrawLine(-4, -4, 4, 4);41 ScDrawLine(-2, -5, 5, 2);42 ScDrawLine(-5, -4, -2, -2);43 ScDrawLine(1, -10, 1, 10);40 BaseDrawer()->DrawLine(-4, -4, 4, 4); 41 BaseDrawer()->DrawLine(-2, -5, 5, 2); 42 BaseDrawer()->DrawLine(-5, -4, -2, -2); 43 BaseDrawer()->DrawLine(1, -10, 1, 10); 44 44 return; 45 45 }
Note:
See TracChangeset
for help on using the changeset viewer.