Changeset 71 in Sophya
- Timestamp:
- Feb 12, 1998, 3:14:22 PM (28 years ago)
- Location:
- trunk/SophyaPI/PI
- Files:
-
- 8 added
- 24 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/SophyaPI/PI/Makefile
r62 r71 3 3 4 4 all: $(LIB)libPI.a 5 $(LIB)libPI.a : $(OBJ)piapplgen.o $(OBJ)piapplx.o $(OBJ)pibwdggen.o $(OBJ)pibwdgx.o $(OBJ)picmap.o $(OBJ)picmapgen.o $(OBJ)picmapx.o $(OBJ)picontainergen.o $(OBJ)picontainerx.o $(OBJ)pidrawer.o $(OBJ)pidrawwin.o $(OBJ)pifilechogen.o $(OBJ)pifilechox.o $(OBJ)pi histo.o $(OBJ)piimage.o $(OBJ)pilistgen.o $(OBJ)pilistx.o $(OBJ)pimenubargen.o $(OBJ)pimenubarx.o $(OBJ)pimenugen.o $(OBJ)pimenux.o $(OBJ)pimsghandler.o $(OBJ)pintuple.o $(OBJ)pioptmenugen.o $(OBJ)pioptmenux.o $(OBJ)piperiodx.o $(OBJ)pipixmapgen.o $(OBJ)pipixmapx.o $(OBJ)piscdrawwdg.o $(OBJ)pistdwdggen.o $(OBJ)pistdwdgx.o $(OBJ)pistlist.o $(OBJ)piup.o $(OBJ)piwdggen.o $(OBJ)piwdgx.o $(OBJ)piwindowgen.o $(OBJ)piwindowx.o $(OBJ)pixtbase.o $(OBJ)psfile.o5 $(LIB)libPI.a : $(OBJ)piapplgen.o $(OBJ)piapplx.o $(OBJ)pibwdggen.o $(OBJ)pibwdgx.o $(OBJ)picmap.o $(OBJ)picmapgen.o $(OBJ)picmapx.o $(OBJ)picontainergen.o $(OBJ)picontainerx.o $(OBJ)pidrawer.o $(OBJ)pidrawwin.o $(OBJ)pifilechogen.o $(OBJ)pifilechox.o $(OBJ)pigraphgen.o $(OBJ)pigraphps.o $(OBJ)pigraphuc.o $(OBJ)pigraphx.o $(OBJ)pihisto.o $(OBJ)piimage.o $(OBJ)pilistgen.o $(OBJ)pilistx.o $(OBJ)pimenubargen.o $(OBJ)pimenubarx.o $(OBJ)pimenugen.o $(OBJ)pimenux.o $(OBJ)pimsghandler.o $(OBJ)pintuple.o $(OBJ)pioptmenugen.o $(OBJ)pioptmenux.o $(OBJ)piperiodx.o $(OBJ)pipixmapgen.o $(OBJ)pipixmapx.o $(OBJ)piscdrawwdg.o $(OBJ)pistdwdggen.o $(OBJ)pistdwdgx.o $(OBJ)pistlist.o $(OBJ)piup.o $(OBJ)piwdggen.o $(OBJ)piwdgx.o $(OBJ)piwindowgen.o $(OBJ)piwindowx.o $(OBJ)pixtbase.o $(OBJ)psfile.o 6 6 $(AR) $(ARFLAGS) $@ $? 7 7 ifeq ($(CXX),cxx) … … 17 17 pimenubargen.h pimenux.h pimenugen.h 18 18 $(OBJ)pibwdggen.o: pibwdggen.cc pibwdggen.h pisysdep.h piwdgx.h piwdggen.h \ 19 pimsghandler.h picmap.h picmapx.h picmapgen.h pidrawer.h psfile.h \ 20 $(INC)defs.h pibwdgx.h 19 pimsghandler.h picmap.h picmapx.h picmapgen.h pigraphx.h pigraphgen.h \ 20 psfile.h $(INC)defs.h pidrawer.h pigraphuc.h \ 21 pigraphps.h 21 22 $(OBJ)pibwdgx.o: pibwdgx.cc pixtbaseP.h pibwdgx.h pisysdep.h pibwdggen.h \ 22 23 piwdgx.h piwdggen.h pimsghandler.h picmap.h picmapx.h picmapgen.h \ 23 pixtbase.h pidrawer.h psfile.h $(INC)defs.h 24 pigraphx.h pigraphgen.h psfile.h $(INC)defs.h \ 25 pigraphps.h pixtbase.h 24 26 $(OBJ)picmap.o: picmap.cc picmap.h pisysdep.h picmapx.h picmapgen.h 25 27 $(OBJ)picmapgen.o: picmapgen.cc picmapgen.h pisysdep.h picmapx.h picmap.h … … 31 33 picontainergen.h piwdgx.h piwdggen.h pimsghandler.h 32 34 $(OBJ)pidrawer.o: pidrawer.cc pidrawer.h pibwdggen.h pisysdep.h piwdgx.h \ 33 piwdggen.h pimsghandler.h picmap.h picmapx.h picmapgen.h psfile.h \ 34 $(INC)defs.h pibwdgx.h 35 piwdggen.h pimsghandler.h picmap.h picmapx.h picmapgen.h pigraphx.h \ 36 pigraphgen.h psfile.h $(INC)defs.h \ 37 pigraphuc.h 35 38 $(OBJ)pidrawwin.o: pidrawwin.cc pidrawwin.h pisysdep.h piwindowx.h \ 36 39 piwindowgen.h picontainerx.h picontainergen.h piwdgx.h piwdggen.h \ 37 40 pimsghandler.h piscdrawwdg.h pibwdgx.h pibwdggen.h picmap.h picmapx.h \ 38 picmapgen.h pistdwdgx.h pistdwdggen.h pidrawer.h 41 picmapgen.h pigraphx.h pigraphgen.h psfile.h \ 42 $(INC)defs.h pigraphps.h pistdwdgx.h \ 43 pistdwdggen.h pidrawer.h pigraphuc.h 39 44 $(OBJ)pifilechogen.o: pifilechogen.cc pifilechogen.h pisysdep.h piwdgx.h \ 40 45 piwdggen.h pimsghandler.h … … 42 47 piwdgx.h piwdggen.h pimsghandler.h piwindowx.h piwindowgen.h \ 43 48 picontainerx.h picontainergen.h 49 $(OBJ)pigraphgen.o: pigraphgen.cc pigraphgen.h pisysdep.h piwdgx.h \ 50 piwdggen.h pimsghandler.h picmap.h picmapx.h picmapgen.h 51 $(OBJ)pigraphps.o: pigraphps.cc pigraphps.h pisysdep.h pigraphgen.h piwdgx.h \ 52 piwdggen.h pimsghandler.h picmap.h picmapx.h picmapgen.h psfile.h \ 53 $(INC)defs.h 54 $(OBJ)pigraphuc.o: pigraphuc.cc pigraphuc.h pisysdep.h pigraphgen.h piwdgx.h \ 55 piwdggen.h pimsghandler.h picmap.h picmapx.h picmapgen.h 56 $(OBJ)pigraphx.o: pigraphx.cc pigraphx.h pisysdep.h pigraphgen.h piwdgx.h \ 57 piwdggen.h pimsghandler.h picmap.h picmapx.h picmapgen.h 44 58 $(OBJ)pihisto.o: pihisto.cc pihisto.h $(INC)histos.h \ 45 59 $(INC)peida.h \ … … 56 70 $(INC)pclassids.h piscdrawwdg.h pisysdep.h \ 57 71 pibwdgx.h pibwdggen.h piwdgx.h piwdggen.h pimsghandler.h picmap.h \ 58 picmapx.h picmapgen.h pistdwdgx.h pistdwdggen.h piwindowx.h \ 59 piwindowgen.h picontainerx.h picontainergen.h pidrawer.h 72 picmapx.h picmapgen.h pigraphx.h pigraphgen.h psfile.h pigraphps.h \ 73 pistdwdgx.h pistdwdggen.h piwindowx.h piwindowgen.h picontainerx.h \ 74 picontainergen.h pidrawer.h pigraphuc.h 60 75 $(OBJ)piimage.o: piimage.cc piimage.h $(INC)cimage.h \ 61 76 $(INC)rzimage.h \ … … 73 88 $(INC)lut.h pisysdep.h pipixmapx.h \ 74 89 pipixmapgen.h pibwdgx.h pibwdggen.h piwdgx.h piwdggen.h \ 75 pimsghandler.h picmap.h picmapx.h picmapgen.h pistdwdgx.h \ 76 pistdwdggen.h piwindowx.h piwindowgen.h picontainerx.h \ 77 picontainergen.h $(INC)imageop.h \ 90 pimsghandler.h picmap.h picmapx.h picmapgen.h pigraphx.h pigraphgen.h \ 91 psfile.h pigraphps.h pistdwdgx.h pistdwdggen.h piwindowx.h \ 92 piwindowgen.h picontainerx.h picontainergen.h \ 93 $(INC)imageop.h \ 78 94 $(INC)fitsimage.h \ 79 95 $(INC)fitsheader.h \ … … 119 135 $(INC)pclassids.h piscdrawwdg.h pisysdep.h \ 120 136 pibwdgx.h pibwdggen.h piwdgx.h piwdggen.h pimsghandler.h picmap.h \ 121 picmapx.h picmapgen.h pistdwdgx.h pistdwdggen.h piwindowx.h \ 122 piwindowgen.h picontainerx.h picontainergen.h pidrawer.h 137 picmapx.h picmapgen.h pigraphx.h pigraphgen.h psfile.h pigraphps.h \ 138 pistdwdgx.h pistdwdggen.h piwindowx.h piwindowgen.h picontainerx.h \ 139 picontainergen.h pidrawer.h pigraphuc.h 123 140 $(OBJ)pioptmenugen.o: pioptmenugen.cc pioptmenugen.h pisysdep.h \ 124 141 picontainerx.h picontainergen.h piwdgx.h piwdggen.h pimsghandler.h \ … … 132 149 $(OBJ)pipixmapgen.o: pipixmapgen.cc pipixmapgen.h pisysdep.h pibwdgx.h \ 133 150 pibwdggen.h piwdgx.h piwdggen.h pimsghandler.h picmap.h picmapx.h \ 134 picmapgen.h 151 picmapgen.h pigraphx.h pigraphgen.h psfile.h \ 152 $(INC)defs.h pigraphps.h 135 153 $(OBJ)pipixmapx.o: pipixmapx.cc pipixmapx.h pipixmapgen.h pisysdep.h \ 136 154 pibwdgx.h pibwdggen.h piwdgx.h piwdggen.h pimsghandler.h picmap.h \ 137 picmapx.h picmapgen.h psfile.h $(INC)defs.h 155 picmapx.h picmapgen.h pigraphx.h pigraphgen.h psfile.h \ 156 $(INC)defs.h pigraphps.h 138 157 $(OBJ)piscdrawwdg.o: piscdrawwdg.cc \ 139 158 $(INC)generalfit.h \ … … 151 170 $(INC)cvector.h piscdrawwdg.h pisysdep.h \ 152 171 pibwdgx.h pibwdggen.h piwdgx.h piwdggen.h pimsghandler.h picmap.h \ 153 picmapx.h picmapgen.h pistdwdgx.h pistdwdggen.h piwindowx.h \ 154 piwindowgen.h picontainerx.h picontainergen.h pidrawer.h 172 picmapx.h picmapgen.h pigraphx.h pigraphgen.h psfile.h pigraphps.h \ 173 pistdwdgx.h pistdwdggen.h piwindowx.h piwindowgen.h picontainerx.h \ 174 picontainergen.h pidrawer.h pigraphuc.h 155 175 $(OBJ)pistdwdggen.o: pistdwdggen.cc pistdwdggen.h pisysdep.h piwdgx.h \ 156 176 piwdggen.h pimsghandler.h … … 190 210 $(INC)zfidu.h piscdrawwdg.h pisysdep.h \ 191 211 pibwdgx.h pibwdggen.h piwdgx.h piwdggen.h pimsghandler.h picmap.h \ 192 picmapx.h picmapgen.h pistdwdgx.h pistdwdggen.h piwindowx.h \ 193 piwindowgen.h picontainerx.h picontainergen.h pidrawer.h 212 picmapx.h picmapgen.h pigraphx.h pigraphgen.h psfile.h pigraphps.h \ 213 pistdwdgx.h pistdwdggen.h piwindowx.h piwindowgen.h picontainerx.h \ 214 picontainergen.h pidrawer.h pigraphuc.h 194 215 $(OBJ)piup.o: piup.cc $(INC)ctimer.h \ 195 216 $(INC)peida.h \ … … 227 248 $(OBJ)piwdggen.o: piwdggen.cc piwdggen.h pimsghandler.h picontainergen.h \ 228 249 pisysdep.h piwdgx.h psfile.h $(INC)defs.h \ 229 pi bwdgx.h pibwdggen.h picmap.h picmapx.h picmapgen.h250 pigraphgen.h picmap.h picmapx.h picmapgen.h 230 251 $(OBJ)piwdgx.o: piwdgx.cc piwdgx.h piwdggen.h pimsghandler.h picontainerx.h \ 231 252 pisysdep.h picontainergen.h 232 253 $(OBJ)piwindowgen.o: piwindowgen.cc piwindowgen.h pisysdep.h picontainerx.h \ 233 254 picontainergen.h piwdgx.h piwdggen.h pimsghandler.h psfile.h \ 234 $(INC)defs.h pi bwdgx.h pibwdggen.h picmap.h \235 picmap x.h picmapgen.h255 $(INC)defs.h pigraphgen.h picmap.h picmapx.h \ 256 picmapgen.h 236 257 $(OBJ)piwindowx.o: piwindowx.cc piwindowx.h piwindowgen.h pisysdep.h \ 237 258 picontainerx.h picontainergen.h piwdgx.h piwdggen.h pimsghandler.h 238 259 $(OBJ)pixtbase.o: pixtbase.cc pixtbaseP.h pibwdgx.h pisysdep.h pibwdggen.h \ 239 260 piwdgx.h piwdggen.h pimsghandler.h picmap.h picmapx.h picmapgen.h \ 240 pixtbase.h 261 pigraphx.h pigraphgen.h psfile.h $(INC)defs.h \ 262 pigraphps.h pixtbase.h 241 263 $(OBJ)psfile.o: psfile.cc psfile.h $(INC)defs.h \ 242 pisysdep.h pi bwdgx.h pibwdggen.h piwdgx.h piwdggen.h pimsghandler.h \243 picmap .h picmapx.h picmapgen.h264 pisysdep.h pigraphgen.h piwdgx.h piwdggen.h pimsghandler.h picmap.h \ 265 picmapx.h picmapgen.h -
trunk/SophyaPI/PI/pibwdggen.cc
r63 r71 3 3 #include "pibwdggen.h" 4 4 #include "pidrawer.h" 5 #include "p sfile.h"5 #include "pigraphps.h" 6 6 7 7 // Les methodes de la classe PIBWdgGen … … 12 12 PIWdg(par, nom, sx, sy, px, py) 13 13 { 14 mPSOut=NULL;15 14 mDrwId=0; // Compteur des numeros sequentiel des PIDrawer 16 15 mAdfg=false; // Pour controle d'appel de RemoveDrawer() 17 } 18 16 mWGrC = NULL; // PIGraphic (Contexte graphique) associe a la fenetre} 17 // Doit etre cree par PIBaseWdgX/Mac/... 18 } 19 19 20 20 /* --Methode-- */ 21 21 PIBaseWdgGen::~PIBaseWdgGen() 22 22 { 23 delete mWGrC; 23 24 DeleteDrawers(); 24 25 } … … 26 27 27 28 /* --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 }52 53 /* --Methode-- */54 29 void PIBaseWdgGen::Refresh() 55 30 { 56 31 if ( IsVisible() ) { 57 Draw( );58 CallDrawers( );59 } 60 return; 61 } 62 63 /* --Methode-- */ 64 void PIBaseWdgGen::Draw( int /*x0*/, int /*y0*/, int /*dx*/, int /*dy*/)65 { 66 this->Draw( );67 return; 68 } 69 70 /* --Methode-- */ 71 void PIBaseWdgGen::Draw( )32 Draw(mWGrC); 33 CallDrawers(mWGrC); 34 } 35 return; 36 } 37 38 /* --Methode-- */ 39 void PIBaseWdgGen::Draw(PIGraphicGen* g, int /*x0*/, int /*y0*/, int /*dx*/, int /*dy*/) 40 { 41 this->Draw(g); 42 return; 43 } 44 45 /* --Methode-- */ 46 void PIBaseWdgGen::Draw(PIGraphicGen* g) 72 47 { 73 48 #ifdef DEBUG_RZXB … … 187 162 void PIBaseWdgGen::PSPrint(PSFile * psf, int ofx, int ofy) 188 163 { 189 if(!psf) return; 190 mPSOut = psf; 191 psf->NewBloc((float)(ofx+XPos()), (float)(ofy+YPos()), 192 (float)XSize(),(float)YSize(), 193 (float)XSize(),(float)YSize()); 194 Draw(); 195 psf->EndBloc(); 196 mPSOut=NULL; 164 if (!psf) return; 165 PIGraphicPS grpsf(psf, (PIWdg *)this, ofx, ofy); 166 Draw(&grpsf); 167 CallDrawers(&grpsf); 168 return; 197 169 } 198 170 … … 209 181 did.drw = drw; 210 182 mDrwList.push_back(did); 211 drw->Attach( (PIBaseWdg*)this, mDrwId);183 drw->Attach(this, mDrwId); 212 184 return(mDrwId); 213 185 } … … 233 205 for(it = mDrwList.begin(); it != mDrwList.end(); it++) 234 206 if ((*it).id == id) 235 { (*it).drw->Detach( (PIBaseWdg*)this, id); mDrwList.erase(it); break; }207 { (*it).drw->Detach(this, id); mDrwList.erase(it); break; } 236 208 return; 237 209 } … … 251 223 252 224 /* --Methode-- */ 253 void PIBaseWdgGen::CallDrawers(int x0, int y0, int dx, int dy) 254 { 255 double xmin,ymin, xmax, ymax; 225 void PIBaseWdgGen::CallDrawers(PIGraphicGen* g, int x0, int y0, int dx, int dy) 226 { 227 float xmin,ymin, xmax, ymax; 228 PIGraphicUC* guc; 256 229 257 230 bool sxy = false; … … 261 234 bool fgc=false; 262 235 for(it = mDrwList.begin(); it != mDrwList.end(); it++) { 263 SaveGraphicAtt();264 (*it).drw->SetDrwWdg(this, (*it).x0, (*it).y0, (*it).dx, (*it).dy);265 SetClipRectangle((*it).x0, (*it).y0, (*it).dx , (*it).dy);236 g->SaveGraphicAtt(); 237 guc = (*it).drw->SetDrwWdg(this, (*it).x0, (*it).y0, (*it).dx, (*it).dy, g); 238 g->SetClipRectangle((*it).x0, (*it).y0, (*it).dx , (*it).dy); 266 239 fgc = true; 267 240 if (sxy) { 268 (*it).drw->Local2Sc(x0, y0, xmin, ymin);269 (*it).drw->Local2Sc(x0+dx, y0+dy, xmax, ymax);241 guc->GrC2UC(x0, y0, xmin, ymin); 242 guc->GrC2UC(x0+dx, y0+dy, xmax, ymax); 270 243 if (xmin > xmax) swap(xmin,xmax); 271 244 if (ymin > ymax) swap(ymin,ymax); 272 (*it).drw->Draw(xmin, ymin, xmax, ymax); 273 } 274 else (*it).drw->Draw(); 275 RestoreGraphicAtt(); 276 } 277 if (fgc) ClearClipRectangle(); 278 279 return; 280 } 281 282 /* --Methode-- */ 283 void PIBaseWdgGen::CallDrawer(int id) 284 { 245 (*it).drw->Draw(guc, xmin, ymin, xmax, ymax); 246 } 247 else (*it).drw->Draw(guc); 248 g->RestoreGraphicAtt(); 249 } 250 if (fgc) g->ClearClipRectangle(); 251 252 return; 253 } 254 255 /* --Methode-- */ 256 void PIBaseWdgGen::CallDrawer(PIGraphicGen* g, int id) 257 { 258 PIGraphicUC* guc; 285 259 list<BWDrwId>::iterator it; 286 260 for(it = mDrwList.begin(); it != mDrwList.end(); it++) 287 261 if ((*it).id == id) { 288 SaveGraphicAtt();289 (*it).drw->SetDrwWdg(this, (*it).x0, (*it).y0, (*it).dx, (*it).dy);290 SetClipRectangle((*it).x0, (*it).y0, (*it).dx , (*it).dy);291 (*it).drw->Draw( );292 RestoreGraphicAtt();293 ClearClipRectangle();262 g->SaveGraphicAtt(); 263 guc = (*it).drw->SetDrwWdg(this, (*it).x0, (*it).y0, (*it).dx, (*it).dy, g); 264 g->SetClipRectangle((*it).x0, (*it).y0, (*it).dx , (*it).dy); 265 (*it).drw->Draw(guc); 266 g->RestoreGraphicAtt(); 267 g->ClearClipRectangle(); 294 268 break; 295 269 } 296 270 return; 297 271 } 272 273 274 /* --Methode-- */ 275 PIGraphic* PIBaseWdgGen::WindowGraphic() 276 { 277 return(mWGrC); 278 } -
trunk/SophyaPI/PI/pibwdggen.h
r63 r71 6 6 #include PIWDG_H 7 7 #include PICMAP_H 8 #include PIGRAPHIC_H 9 #include "psfile.h" 8 10 9 11 // Mettre dans cet ordre, sinon g++ a des problemes … … 19 21 PIK_Previous = 21+0x2000, PIK_Next = 22+0x2000 } ; 20 22 21 enum PIColors { PI_ColorFromMap = -2, PI_NotDefColor = -1,22 PI_Black = 0, PI_White = 1, PI_Grey = 2,23 PI_Red = 3, PI_Blue = 4, PI_Green = 5,24 PI_Yellow = 6, PI_Magenta = 7 };25 26 enum PIFontSize { PI_NotDefFontSize = -1,27 PI_SmallSizeFont = 1, PI_NormalSizeFont = 2, PI_BigSizeFont = 3 };28 29 enum PIFontAtt { PI_NotDefFontAtt = -1,30 PI_RomanFont = 1, PI_BoldFont = 2, PI_ItalicFont = 4 };31 32 enum PIPaperSize { PI_A4 = 1, PI_A3 = 2, PI_A5 = 3, PI_NotDefPaperSize = 0};33 34 enum PIOrientation { PI_Landscape = 0, PI_Portrait = 1, PI_Auto = 2 } ;35 36 37 enum PILineAtt { PI_NotDefLineAtt = -1,38 PI_NormalLine = 0, PI_ThinLine = 1, PI_ThickLine = 2 };39 40 enum PIMarker { PI_NotDefMarker = -1,41 PI_DotMarker = 0, PI_PlusMarker=1, PI_CrossMarker=2,42 PI_CircleMarker=3, PI_FCircleMarker=4,43 PI_BoxMarker=5, PI_FBoxMarker=6,44 PI_TriangleMarker=7, PI_FTriangleMarker=8,45 PI_StarMarker=9, PI_FStarMarker=10 };46 23 47 24 enum PIPointer { PI_ArrowPointer = 1, PI_CrossPointer = 2, 48 25 PI_HandPointer = 3, PI_TDLRArrowPointer = 4 }; 49 26 50 enum PIGOMode { PI_GOCopy = 0, PI_GOXOR = 1 };51 27 52 28 class PIBaseWdgGen : public PIWdg … … 69 45 virtual void ActivateKeyboard() = 0; 70 46 71 // Trace graphiques 72 virtual void EraseWindow(int x0=0, int y0=0, int dx=0, int dy=0) = 0; 73 virtual void DrawString(int x, int y, char* s, int pos = 0) = 0; 74 virtual void DrawOpaqueString(int x, int y, char* s, int pos = 0) = 0; 75 virtual void DrawLine(int x1, int y1, int x2, int y2) = 0; 76 virtual void DrawBox(int x0, int y0, int dx, int dy) = 0; 77 virtual void DrawFBox(int x0, int y0, int dx, int dy) = 0; 78 virtual void DrawCircle(int x0, int y0, int r) = 0; 79 virtual void DrawFCircle(int x0, int y0, int r) = 0; 80 virtual void DrawPolygon(int *x, int *y, int n) = 0; 81 virtual void DrawFPolygon(int *x, int *y, int n) = 0; 82 virtual void DrawMarker(int x0, int y0) = 0; 83 virtual void DrawMarkers(int *x, int *y, int n) = 0; 84 virtual void DrawPixmap(int x, int y, unsigned char *pix, 85 int sx, int sy, PIColorMap* cmap) = 0; 86 87 virtual int CalcStringWidth(char const* s) = 0; 88 89 // Modifications attributs graphiques 90 virtual void SelForeground(PIColors col=PI_Black) = 0; 91 virtual void SelBackground(PIColors col=PI_White) = 0; 92 // virtual void SelForeground(PIColorMap* cmap, int cid) = 0; 93 // virtual void SelBackground(PIColorMap* cmap, int cid) = 0; 94 virtual void SelGOMode(PIGOMode mod=PI_GOCopy) = 0; 95 virtual void SelFont(PIFontSize sz=PI_NormalSizeFont, 96 PIFontAtt att=PI_RomanFont) = 0; 97 virtual void SelFontSzPt(int npt=12, PIFontAtt att=PI_RomanFont) = 0; 98 virtual void SelLine(PILineAtt att=PI_NormalLine) = 0; 99 virtual void SelPointerShape(PIPointer ptr=PI_ArrowPointer) = 0; 100 virtual void SelMarker(int msz=3, PIMarker mrk=PI_DotMarker) = 0; 101 102 // Selection de zone de trace (clip) 103 virtual void SetClipRectangle(int x0, int y0, int dx, int dy) = 0; 104 virtual void ClearClipRectangle() = 0; 105 106 // Acces aux attributs graphiques 107 virtual PIColors GetForeground() = 0; 108 virtual PIColors GetBackground() = 0; 109 virtual PIGOMode GetGOMode() = 0; 110 virtual PIFontAtt GetFontAtt() = 0; 111 virtual int GetFontSize() = 0; 112 virtual PILineAtt GetLineAtt() = 0; 113 virtual PIPointer GetPointerShape() = 0; 114 virtual PIMarker GetMarker() = 0; 115 virtual int GetMarkerSize() = 0; 116 virtual int GetFontHeight(int& asc, int& desc) = 0; 117 118 // Sauvegarde des attributs graphiques 119 virtual void SaveGraphicAtt(); 120 virtual void RestoreGraphicAtt(); 121 47 // Divers : couleur de fond, Effacement fenetre, forme de la souris 48 virtual void SetBackgroundColor(PIColors col=PI_White) = 0; 49 virtual void EraseWindow(int x0=0, int y0=0, int dx=0, int dy=0) = 0; 50 virtual void SelPointerShape(PIPointer ptr=PI_ArrowPointer) = 0; 51 virtual PIColors GetBackgroundColor() = 0; 52 virtual PIPointer GetPointerShape() = 0; 122 53 123 54 // Fonction qui doit etre appelee pour rafraichir la fenetre … … 125 56 126 57 // Fonctions qui doivent contenir le dessin du contenu du widget lui-meme 127 virtual void Draw( );128 virtual void Draw( int x0, int y0, int dx, int dy);58 virtual void Draw(PIGraphicGen* g); 59 virtual void Draw(PIGraphicGen* g, int x0, int y0, int dx, int dy); 129 60 130 61 // Traitement des evenements … … 144 75 145 76 // PostScript output 146 virtual void PSPrint(PSFile 77 virtual void PSPrint(PSFile* psf, int ofx = 0, int ofy = 0); 147 78 148 79 // Gestion des Drawers … … 155 86 156 87 // Trace des Drawers ... 157 virtual void CallDrawers( int x0=0, int y0=0, int dx=0, int dy=0);158 virtual void CallDrawer( int id);88 virtual void CallDrawers(PIGraphicGen* g, int x0=0, int y0=0, int dx=0, int dy=0); 89 virtual void CallDrawer(PIGraphicGen* g, int id); 159 90 160 91 // Devrait etre protected - mis ici a cause de cxx 11/07/97 Reza 161 92 struct BWDrwId { int x0, y0; int dx, dy; int id; bool ad; PIDrawer* drw; }; 162 93 94 virtual PIGraphic* WindowGraphic(); 95 163 96 protected: 164 PSFile * mPSOut; /* Fichier PostScript eventuel */ 165 97 PIGraphic* mWGrC; // PIGraphic (Contexte graphique) associe a la fenetre 166 98 bool mAdfg; 167 99 int mDrwId; 168 100 list<BWDrwId> mDrwList; 169 // Pour Save/Restore des attributs graphiques170 PIColors sFCol, sBCol;171 PIGOMode sGOm;172 PIFontAtt sFAtt;173 PILineAtt sLAtt;174 int sFSize;175 PIMarker sMrk;176 int sMrkSz;177 101 178 102 }; -
trunk/SophyaPI/PI/pibwdgx.cc
r63 r71 12 12 13 13 #include "pibwdgx.h" 14 #include "pidrawer.h" 15 #include "psfile.h" 16 17 18 /* Variables globales pour modifier les GC */ 19 #define NMAXFONTSZ 5 20 static XFontStruct * fntst[NMAXFONTSZ][3]; 21 static int fntsz[NMAXFONTSZ] = {8,10,12,14,16}; 22 static PIFontAtt fntatt[3] = { PI_RomanFont, PI_BoldFont, PI_ItalicFont }; 23 #define NMAXCOL 10 24 static unsigned long colpix[NMAXCOL]; 14 15 16 // #define DEBUG_PIBWDGX Flag pour impression de debug etc ... 17 static unsigned long colpixwhite, colpixblack; 25 18 #define NMAXCURS 5 26 19 static Cursor curs[NMAXCURS]; 27 28 /* GC pour DrawPixmap */29 static GC dpxgc;30 31 // #define DEBUG_PIBWDGX Flag pour impression de debug etc ...32 20 33 21 … … 45 33 46 34 XtSetArg(wargs[0],PIXNobject,this); 47 XtSetArg(wargs[1],XtNbackground, colpix [PI_White]);35 XtSetArg(wargs[1],XtNbackground, colpixwhite); 48 36 XtSetArg(wargs[2],XtNborderWidth, (Dimension)0); 49 37 XtSetValues(XtWdg(), wargs, 3); … … 51 39 XtUninstallTranslations(XtWdg()); 52 40 53 mDefGC = XCreateGC (PIXDisplay(), XtWindow(PIXtTopWdg()), 0, NULL);54 mGOm = PI_GOCopy;55 56 mFCol = mBCol = PI_Grey;57 SelForeground(PI_Black);58 SelBackground(PI_White);59 mLAtt = PI_ThinLine;60 SelLine();61 mFAtt = PI_BoldFont; mFSize = 0;62 SelFont();63 41 mPtrS = PI_CrossPointer; 64 42 SelPointerShape(); 65 SelMarker(1, PI_DotMarker);66 43 67 44 Manage(); 45 mWGrC = new PIGraphic(this); // PIGraphic (Contexte graphique) associe a la fenetre 68 46 } 69 47 … … 154 132 } 155 133 134 /* --Methode-- */ 135 void PIBaseWdgX::SetBackgroundColor(PIColors col) 136 { 137 Arg wargs[2]; 138 XtSetArg(wargs[0],XtNbackground, mWGrC->GetPixelValueforColor(col) ); 139 XtSetValues(XtWdg(), wargs, 1); 140 mBCol = col; 141 return; 142 } 156 143 157 144 /* --Methode-- */ 158 145 void PIBaseWdgX::EraseWindow(int x0, int y0, int dx, int dy) 159 146 { 160 if(mPSOut) return;161 147 XClearArea (XtDisplay(XtWdg()),XtWindow(XtWdg()), x0, y0, dx, dy, False ); 162 148 return; 163 149 } 164 165 /* --Methode-- */166 void PIBaseWdgX::DrawString(int x, int y, char* s, int /*pos*/)167 {168 if(mPSOut){169 mPSOut->DrawString((float)x,(float)y,s,mFCol,mFAtt,mFSize); /* $CHECK$ PIFontSize ?? */170 }171 else172 XDrawString (XtDisplay (XtWdg()),XtWindow(XtWdg()),173 DefGC(), x, y, s, strlen(s));174 return;175 }176 177 /* --Methode-- */178 void PIBaseWdgX::DrawOpaqueString(int x, int y, char* s, int /*pos*/)179 {180 if(mPSOut){181 mPSOut->DrawString((float)x,(float)y,s,mFCol,mFAtt,mFSize); /* $CHECK$ PIFontSize ?? */182 }183 else184 XDrawImageString (XtDisplay (XtWdg()),XtWindow(XtWdg()),185 DefGC(), x, y, s, strlen(s));186 return;187 }188 189 190 /* --Methode-- */191 void PIBaseWdgX::DrawLine(int x1, int y1, int x2, int y2)192 {193 if(mPSOut){194 mPSOut->DrawLine((float)x1,(float)y1,(float)x2,(float)y2,195 mFCol,mLAtt);196 }197 else198 XDrawLine(XtDisplay (XtWdg()), XtWindow(XtWdg()), DefGC(), x1, y1, x2, y2);199 return;200 }201 202 203 /* --Methode-- */204 void PIBaseWdgX::DrawBox(int x0, int y0, int dx, int dy)205 {206 if(mPSOut)207 mPSOut->DrawBox((float)x0,(float)y0,(float)dx,(float)dy,mFCol,mLAtt);208 else{209 if (dx < 0) { x0 += dx; dx = -dx; }210 if (dy < 0) { y0 += dy; dy = -dy; }211 XDrawRectangle(XtDisplay (XtWdg()), XtWindow(XtWdg()),212 DefGC(), x0, y0, dx, dy);213 }214 return;215 }216 217 /* --Methode-- */218 void PIBaseWdgX::DrawFBox(int x0, int y0, int dx, int dy)219 {220 if(mPSOut)221 mPSOut->DrawFBox((float)x0,(float)y0,(float)dx,(float)dy, mFCol, mFCol, mLAtt);222 else{223 if (dx < 0) { x0 += dx; dx = -dx; }224 if (dy < 0) { y0 += dy; dy = -dy; }225 XFillRectangle(XtDisplay (XtWdg()), XtWindow(XtWdg()),226 DefGC(), x0, y0, dx, dy);227 }228 return;229 }230 231 /* --Methode-- */232 void PIBaseWdgX::DrawCircle(int x0, int y0, int r)233 {234 if(mPSOut)235 mPSOut->DrawCircle((float)x0,(float)y0,(float)r,mFCol,mLAtt);236 else237 XDrawArc(XtDisplay (XtWdg()), XtWindow(XtWdg()), DefGC(),238 x0-r, y0-r, 2*r, 2*r, 0, 360*64);239 return;240 }241 242 /* --Methode-- */243 void PIBaseWdgX::DrawFCircle(int x0, int y0, int r)244 {245 if(mPSOut)246 mPSOut->DrawFCircle((float)x0,(float)y0,(float)r,mFCol,mFCol,mLAtt);247 else248 XFillArc(XtDisplay (XtWdg()), XtWindow(XtWdg()), DefGC(),249 x0-r, y0-r, 2*r, 2*r, 0, 360*64);250 return;251 }252 253 // Pour les fonctions de trace avec un plusieurs coordonnees254 #define NMXXPOINTS 30255 256 /* --Methode-- */257 void PIBaseWdgX::DrawPolygon(int *x, int *y, int n)258 {259 XPoint multipoint[NMXXPOINTS];260 XPoint *pxp;261 int i;262 float *xtmp;263 float *ytmp;264 265 if(mPSOut)266 {267 xtmp = new float[n];268 ytmp = new float[n];269 for(i=0;i<n;i++){270 xtmp[i] = (float)x[i];271 ytmp[i] = (float)y[i];272 }273 mPSOut->DrawPolygon(xtmp,ytmp,n,mFCol,mLAtt);274 delete[] xtmp;275 delete[] ytmp;276 }277 else {278 if (n <= 0) return;279 if (n > NMXXPOINTS) pxp = new XPoint[n];280 else pxp = multipoint;281 for(i=0; i<n; i++) { pxp[i].x = x[i]; pxp[i].y = y[i]; }282 XDrawLines(XtDisplay(XtWdg()), XtWindow(XtWdg()), DefGC(), pxp, n, CoordModePrevious);283 if (n > NMXXPOINTS) delete[] pxp;284 }285 return;286 }287 288 289 /* --Methode-- */290 void PIBaseWdgX::DrawFPolygon(int *x, int *y, int n)291 {292 XPoint multipoint[NMXXPOINTS];293 XPoint *pxp;294 int i;295 float *xtmp;296 float *ytmp;297 298 if(mPSOut)299 {300 xtmp = new float[n];301 ytmp = new float[n];302 for(i=0;i<n;i++){303 xtmp[i] = (float)x[i];304 ytmp[i] = (float)y[i];305 }306 mPSOut->DrawFPolygon(xtmp,ytmp,n,mFCol,mFCol,mLAtt);307 delete[] xtmp;308 delete[] ytmp;309 }310 else311 {312 if (n <= 0) return;313 if (n > NMXXPOINTS) pxp = new XPoint[n];314 else pxp = multipoint;315 for(i=0; i<n; i++) { pxp[i].x = x[i]; pxp[i].y = y[i]; }316 XFillPolygon(XtDisplay (XtWdg()), XtWindow(XtWdg()), DefGC(), pxp, n,317 Complex, CoordModePrevious);318 if (n > NMXXPOINTS) delete[] pxp;319 }320 return;321 }322 323 /* --Methode-- */324 void PIBaseWdgX::DrawMarker(int x0, int y0)325 {326 int hmsz = mMrkSz/2;327 int dmsz = mMrkSz-hmsz;328 int x[4],y[4];329 PILineAtt clatt;330 if(mPSOut)331 mPSOut->DrawMarker((float)x0,(float)y0,mMrk,mFCol,mMrkSz);332 else333 {334 if (mMrk == PI_DotMarker)335 XDrawPoint(XtDisplay(XtWdg()), XtWindow(XtWdg()), DefGC(), x0, y0);336 337 else338 {339 clatt = mLAtt;340 SelLine(PI_ThinLine);341 switch (mMrk)342 {343 case PI_PlusMarker :344 DrawLine(x0-hmsz, y0, x0+dmsz, y0);345 DrawLine(x0, y0-hmsz, x0, y0+dmsz);346 break;347 case PI_CrossMarker :348 DrawLine(x0-hmsz, y0-hmsz, x0+dmsz, y0+dmsz);349 DrawLine(x0-hmsz, y0+dmsz, x0+dmsz, y0-hmsz);350 break;351 case PI_CircleMarker :352 DrawCircle(x0, y0, hmsz);353 break;354 case PI_FCircleMarker :355 DrawFCircle(x0, y0, hmsz);356 break;357 case PI_BoxMarker :358 DrawBox(x0-hmsz, y0-hmsz, mMrkSz, mMrkSz);359 break;360 case PI_FBoxMarker :361 DrawFBox(x0-hmsz, y0-hmsz, mMrkSz, mMrkSz);362 break;363 case PI_TriangleMarker :364 x[1] = mMrkSz; y[1] = 0; x[2] = -hmsz; y[2] = -mMrkSz;365 x[3] = -dmsz; y[3] = +mMrkSz; x[0] = x0-hmsz; y[0] = y0+hmsz;366 DrawPolygon(x, y, 4);367 break;368 case PI_FTriangleMarker :369 x[1] = mMrkSz; y[1] = 0; x[2] = -hmsz; y[2] = -mMrkSz;370 x[3] = -dmsz; y[3] = +mMrkSz; x[0] = x0-hmsz; y[0] = y0+hmsz;371 DrawFPolygon(x, y, 4);372 break;373 default :374 XDrawPoint(XtDisplay(XtWdg()), XtWindow(XtWdg()), DefGC(), x0, y0);375 break;376 }377 SelLine(clatt);378 }379 }380 return;381 }382 383 /* --Methode-- */384 void PIBaseWdgX::DrawMarkers(int *x, int *y, int n)385 {386 int i;387 float *xtmp;388 float *ytmp;389 390 if(mPSOut)391 {392 xtmp = new float[n];393 ytmp = new float[n];394 for(i=0;i<n;i++){395 xtmp[i] = (float)x[i];396 ytmp[i] = (float)y[i];397 }398 mPSOut->DrawMarkers(xtmp,ytmp,n,mMrk,mFCol, mMrkSz);399 delete[] xtmp;400 delete[] ytmp;401 }402 else403 {404 if (n <= 0) return;405 if (mMrk == PI_DotMarker)406 {407 XPoint multipoint[NMXXPOINTS];408 XPoint *pxp;409 if (n > NMXXPOINTS) pxp = new XPoint[n];410 else pxp = multipoint;411 for(i=0; i<n; i++) { pxp[i].x = x[i]; pxp[i].y = y[i]; }412 XDrawPoints(XtDisplay(XtWdg()), XtWindow(XtWdg()), DefGC(), pxp, n, CoordModeOrigin);413 if (n > NMXXPOINTS) delete[] pxp;414 }415 else for(i=0; i<n; i++) DrawMarker(x[i], y[i]);416 }417 }418 419 420 /* --Methode-- */421 void PIBaseWdgX::DrawPixmap(int x, int y, unsigned char *pix,422 int sx, int sy, PIColorMap* cmap)423 {424 Window xw;425 Display * mdsp;426 int scr;427 int depth;428 int pad;429 int i,j;430 XImage * ximg;431 432 if ( (sx < 1) || (sy < 1) ) return;433 if ((pix == NULL) || (cmap == NULL)) return;434 435 if(mPSOut) {436 mPSOut->Image((float)x, (float)y, (float)sx, (float)sy, sx, sy, pix, cmap);437 return;438 }439 440 xw = XtWindow(XtWdg());441 mdsp = PIXDisplay();442 scr = PIXScreen();443 444 depth = DefaultDepth(mdsp,scr);445 pad = (depth > 8) ? 32 : 8;446 ximg = XCreateImage (mdsp,DefaultVisual(mdsp,scr),447 depth,ZPixmap,0,NULL, sx, sy, pad,0);448 if (ximg == NULL) return;449 ximg->data = new char [sy*ximg->bytes_per_line];450 if (ximg->data == NULL)451 { XFree(ximg); return; }452 453 for(j=0; j<sy; j++)454 for(i=0; i<sx; i++)455 { XPutPixel(ximg, i, j, cmap->Color(*pix) ); pix++; }456 457 XPutImage(mdsp, xw, dpxgc, ximg, 0, 0, x, y, sx, sy);458 459 delete[] ximg->data;460 XFree(ximg);461 return;462 }463 464 465 /* --Methode-- */466 int PIBaseWdgX::CalcStringWidth(char const* s)467 {468 return(XTextWidth(mFSt, s, strlen(s)));469 }470 471 /* --Methode-- */472 void PIBaseWdgX::SelForeground(PIColors col)473 {474 if (col == mFCol) return;475 if ( (col < 0) || (col >= NMAXCOL)) return;476 XSetForeground(XtDisplay(XtWdg()), DefGC(), colpix[col]);477 mFCol = col;478 return;479 }480 481 /* --Methode-- */482 void PIBaseWdgX::SelBackground(PIColors col)483 {484 if (col == mBCol) return;485 if ( (col < 0) || (col >= NMAXCOL)) return;486 XSetBackground(XtDisplay(XtWdg()), DefGC(), colpix[col]);487 mBCol = col;488 return;489 }490 491 /* --Methode-- */492 void PIBaseWdgX::SelGOMode(PIGOMode mod)493 {494 if (mod == mGOm) return;495 switch (mod)496 {497 case PI_GOCopy :498 XSetFunction(XtDisplay(XtWdg()), DefGC(), GXcopy);499 mGOm = mod;500 break;501 case PI_GOXOR :502 XSetFunction(XtDisplay(XtWdg()), DefGC(), GXxor);503 mGOm = mod;504 break;505 }506 return;507 }508 509 510 /* --Methode-- */511 void PIBaseWdgX::SelFontSzPt(int npt, PIFontAtt att)512 {513 int dsz,i,isel, j;514 515 if ((npt == mFSize) && (att == mFAtt)) return;516 isel = 0;517 dsz = 9999;518 for(i=0; i<NMAXFONTSZ; i++)519 {520 j = npt - fntsz[i]; if (j < 0) j = -j;521 if (j < dsz) { isel = i; dsz = j; }522 }523 524 j = 0;525 if (att & PI_RomanFont) j = 0;526 if (att & PI_BoldFont) j = 1;527 if (att & PI_ItalicFont) j = 2;528 529 SelectFont(isel, j);530 531 }532 533 /* --Methode-- */534 void PIBaseWdgX::SelFont(PIFontSize sz, PIFontAtt att)535 {536 int i,j;537 switch (sz)538 {539 case PI_SmallSizeFont:540 i = 0;541 break;542 case PI_NormalSizeFont:543 i = 2;544 break;545 case PI_BigSizeFont:546 i = 4;547 break;548 default:549 i=2;550 break;551 }552 553 j = 0;554 if (att & PI_RomanFont) j = 0;555 if (att & PI_BoldFont) j = 1;556 if (att & PI_ItalicFont) j = 2;557 558 SelectFont(i, j);559 }560 561 562 563 /* --Methode-- */564 void PIBaseWdgX::SelLine(PILineAtt att)565 {566 unsigned int lt;567 568 if (att == mLAtt) return;569 570 switch (att)571 {572 case PI_NormalLine :573 lt = 2;574 break;575 case PI_ThickLine :576 lt = 4;577 break;578 case PI_ThinLine :579 lt = 0;580 break;581 default:582 lt = 0;583 break;584 }585 586 XSetLineAttributes(XtDisplay(XtWdg()), DefGC(), lt, LineSolid, CapButt, JoinMiter);587 mLAtt = att;588 return;589 }590 591 150 592 151 /* --Methode-- */ … … 602 161 603 162 /* --Methode-- */ 604 void PIBaseWdgX::SelMarker(int msz, PIMarker mrk) 605 { 606 if (msz > 1) { mMrk = mrk; mMrkSz = msz; } 607 else { mMrk = PI_DotMarker; mMrkSz = 1; } 608 return; 609 } 610 611 612 /* --Methode-- */ 613 void PIBaseWdgX::SetClipRectangle(int x0, int y0, int dx, int dy) 614 { 615 XRectangle xr; 616 xr.x = x0; xr.y = y0; 617 xr.width = dx; xr.height = dy; 618 XSetClipRectangles(XtDisplay(XtWdg()), DefGC(), 0, 0, &xr, 1, Unsorted); 619 XSetClipRectangles(XtDisplay(XtWdg()), dpxgc, 0, 0, &xr, 1, Unsorted); 620 return; 621 } 622 623 /* --Methode-- */ 624 void PIBaseWdgX::ClearClipRectangle() 625 { 626 XSetClipMask(XtDisplay(XtWdg()), DefGC(), None); 627 XSetClipMask(XtDisplay(XtWdg()), dpxgc, None); 628 return; 629 } 630 631 /* --Methode-- */ 632 PIColors PIBaseWdgX::GetForeground() 633 { 634 return (mFCol); 635 } 636 637 /* --Methode-- */ 638 PIColors PIBaseWdgX::GetBackground() 639 { 640 return (mBCol); 641 } 642 643 644 /* --Methode-- */ 645 PIGOMode PIBaseWdgX::GetGOMode() 646 { 647 return (mGOm); 648 } 649 650 /* --Methode-- */ 651 PIFontAtt PIBaseWdgX::GetFontAtt() 652 { 653 return (mFAtt); 654 } 655 656 /* --Methode-- */ 657 int PIBaseWdgX::GetFontSize() 658 { 659 return (mFSize); 660 } 661 662 /* --Methode-- */ 663 PILineAtt PIBaseWdgX::GetLineAtt() 664 { 665 return (mLAtt); 163 PIColors PIBaseWdgX::GetBackgroundColor() 164 { 165 return(mBCol); 666 166 } 667 167 … … 672 172 } 673 173 674 /* --Methode-- */675 PIMarker PIBaseWdgX::GetMarker()676 {677 return (mMrk);678 }679 680 /* --Methode-- */681 int PIBaseWdgX::GetMarkerSize()682 {683 return (mMrkSz);684 }685 686 /* --Methode-- */687 int PIBaseWdgX::GetFontHeight(int& asc, int& desc)688 {689 char a[2];690 XCharStruct ovr;691 int hd, fa, fd;692 XTextExtents(mFSt, a, 0, &hd, &fa, &fd, &ovr);693 asc = fa; desc = fd;694 return(fa+fd);695 }696 697 698 /* --Methode-- */699 void PIBaseWdgX::SaveGraphicAtt()700 {701 // Pour optimier l'implementation de PIBaseWdgGen702 sFCol = mFCol; sBCol = mBCol;703 sGOm = mGOm;704 sFAtt = mFAtt; sFSize = mFSize;705 sMrk = mMrk; sMrkSz = mMrkSz;706 return;707 }708 709 710 174 711 175 static bool fgbwdg = false ; 712 176 713 // Le bazar pour recuperer des resources de .Xdefault et autres714 typedef struct715 {716 String fntFam;717 } myAppData;718 static myAppData apd;719 720 static XtResource resources[] = {721 { "fontFamilyName", "FontFamilyName", XtRString, sizeof(String),722 /*XtOffset(apdp, fntFam)*/ 0, XtRString, "*-helvetica" }723 };724 725 static char * fnbi_b[4] = { "medium-r-normal", "bold-r-normal",726 "medium-o-normal", "medium-i-normal" };727 728 static XFontStruct * defnt = NULL;729 static char * fnbi[3];730 731 732 177 /* --Methode-- */ 733 178 void PIBaseWdgX::Init() 734 179 { 735 char buff[256]; 736 int i,j,k, count; 737 char **list; 180 int i; 738 181 739 182 if (fgbwdg) return; 740 183 fgbwdg = true; 741 184 742 Display *mdsp; 743 int scr; 744 XColor exact,mycol; 745 Colormap cmap; 746 747 mdsp = PIXDisplay(); 748 scr = XDefaultScreen(mdsp); 749 750 XtGetApplicationResources(PIXtTopWdg(), &apd, resources, 751 XtNumber(resources), NULL, 0); 752 sprintf(buff,"-%s-*-*-*-*-*-*-*-*-*-*-*-*", apd.fntFam); 753 list = XListFonts(mdsp, buff, 15, &count); 754 XFreeFontNames(list); 755 if (count < 5) 756 { 757 printf("PIBaseWdgX::Init %d fonts found for %s , switching to helvetica\n", 758 count, apd.fntFam); 759 apd.fntFam = "*-helvetica"; 760 } 761 sprintf(buff,"-%s-%s-*-*-*-*-*-*-*-*-*", apd.fntFam, fnbi_b[0]); 762 list = XListFonts(mdsp, buff, 10, &count); 763 XFreeFontNames(list); 764 if (count < 2) fnbi[0] = "*-*-*"; 765 else fnbi[0] = fnbi_b[0]; 766 sprintf(buff,"-%s-%s-*-*-*-*-*-*-*-*-*", apd.fntFam, fnbi_b[1]); 767 list = XListFonts(mdsp, buff, 10, &count); 768 XFreeFontNames(list); 769 if (count < 2) fnbi[1] = "*-*-*"; 770 else fnbi[1] = fnbi_b[1]; 771 sprintf(buff,"-%s-%s-*-*-*-*-*-*-*-*-*", apd.fntFam, fnbi_b[2]); 772 list = XListFonts(mdsp, buff, 10, &count); 773 XFreeFontNames(list); 774 fnbi[2] = fnbi_b[2]; 775 if (count < 2) 776 { 777 sprintf(buff,"-%s-%s-*-*-*-*-*-*-*-*-*", apd.fntFam, fnbi_b[3]); 778 list = XListFonts(mdsp, buff, 10, &count); 779 XFreeFontNames(list); 780 fnbi[2] = fnbi_b[3]; 781 } 782 if (count < 2) fnbi[2] = "*-*-*"; 783 784 sprintf(buff,"-*-fixed-*-*-*-*-14-*-*-*-*-*-*-*"); 785 list = XListFonts(mdsp, buff, 10, &count); 786 XFreeFontNames(list); 787 if (count < 1) 788 { 789 sprintf(buff,"fixed"); 790 list = XListFonts(mdsp, buff, 10, &count); 791 XFreeFontNames(list); 792 } 793 if (count < 1) 794 { 795 strcpy(buff,""); 796 list = XListFonts(mdsp, buff, 10, &count); 797 XFreeFontNames(list); 798 printf("PIBaseWdgX::Init/ Erreur, no font found ... \n"); 799 defnt = NULL; 800 } 801 else defnt = XLoadQueryFont(mdsp, buff); 802 803 for (i=0; i<NMAXFONTSZ; i++) 804 for (j=0; j<3; j++) fntst[i][j] = NULL; 805 806 807 /* Les couleurs */ 808 cmap = XDefaultColormap (mdsp, scr); 809 810 for(i=0; i<NMAXCOL; i++) colpix[i] = XWhitePixel(mdsp, scr); 811 colpix[PI_Black] = XBlackPixel(mdsp, scr); 812 colpix[PI_White] = XWhitePixel(mdsp, scr); 813 if ( XAllocNamedColor (mdsp, cmap, "LightGray", &mycol, &exact) ) 814 colpix[PI_Grey] = mycol.pixel; 815 if ( XAllocNamedColor (mdsp, cmap, "red", &mycol, &exact) ) 816 colpix[PI_Red] = mycol.pixel; 817 if ( XAllocNamedColor (mdsp, cmap, "blue", &mycol, &exact) ) 818 colpix[PI_Blue] = mycol.pixel; 819 if ( XAllocNamedColor (mdsp, cmap, "green", &mycol, &exact) ) 820 colpix[PI_Green] = mycol.pixel; 821 if ( XAllocNamedColor (mdsp, cmap, "yellow", &mycol, &exact) ) 822 colpix[PI_Yellow] = mycol.pixel; 823 if ( XAllocNamedColor (mdsp, cmap, "magenta", &mycol, &exact) ) 824 colpix[PI_Magenta] = mycol.pixel; 185 Display *mdsp = PIXDisplay(); 186 int scr = XDefaultScreen(mdsp); 187 188 colpixwhite = XWhitePixel(mdsp, scr); 189 colpixblack = XBlackPixel(mdsp, scr); 825 190 826 191 curs[0] = XCreateFontCursor(mdsp, XC_X_cursor); … … 832 197 curs[PI_TDLRArrowPointer] = XCreateFontCursor(mdsp, XC_fleur); 833 198 834 /* le GC pour DrawPixmap */ 835 XGCValues xgv; 836 xgv.function = GXcopy; 837 xgv.plane_mask = ~0; 838 dpxgc = XCreateGC(mdsp, DefaultRootWindow(mdsp), GCFunction | GCPlaneMask, &xgv); 839 840 return; 841 } 842 843 844 /* --Methode-- */ 845 void PIBaseWdgX::SelectFont(int isz, int jat) 846 { 847 848 if (!fntst[isz][jat]) // Il faut charger la fonte 849 { 850 char buff[256]; 851 int count,k; 852 Display * mdsp = PIXDisplay(); 853 char **list; 854 855 for (k=0; k<5; k++) // Recherche de la fonte pour tailles croissantes 856 { 857 sprintf(buff,"-%s-%s-*-%d-*-*-*-*-*-*-*", apd.fntFam, fnbi[jat], fntsz[isz]+k); 858 list = XListFonts(mdsp, buff, 10, &count); 859 XFreeFontNames(list); 860 if (count > 0) break; 861 } 862 if (count > 0) 863 fntst[isz][jat] = XLoadQueryFont(mdsp, buff); 864 else 865 { printf("PIBaseWdgX::SelectFont/ Pb font %s - Using default \n", buff); 866 fntst[isz][jat] = defnt; } 867 } 868 869 mFAtt = fntatt[jat]; 870 mFSize = fntsz[isz]; 871 mFSt = fntst[isz][jat]; 872 XSetFont(XtDisplay(XtWdg()), DefGC(), fntst[isz][jat]->fid); 873 return; 874 } 875 876 199 return; 200 } 201 202 /* --Methode-- */ 203 void PIBaseWdgX::eXposeProcess(int x0, int y0, int dx, int dy) 204 { 205 // Appel depuis le PIXtBaseWidget uniquement (ExposeEvt de Xt ) 206 Draw(mWGrC, x0, y0, dx, dy); 207 CallDrawers(mWGrC, x0, y0, dx, dy); 208 return; 209 } -
trunk/SophyaPI/PI/pibwdgx.h
r63 r71 5 5 #include "pibwdggen.h" 6 6 7 #include "pigraphx.h" 8 #include "pigraphps.h" 7 9 8 10 class PIBaseWdgX : public PIBaseWdgGen … … 12 14 // Les methodes ... 13 15 14 PIBaseWdgX(PIContainerGen *par, char *nom,15 int sx=10, int sy=10, int px=0, int py=0);16 virtual ~PIBaseWdgX();16 PIBaseWdgX(PIContainerGen *par, char *nom, 17 int sx=10, int sy=10, int px=0, int py=0); 18 virtual ~PIBaseWdgX(); 17 19 18 virtual void FinishCreate();// appele par la fenetre mere, apres XtRealize()20 virtual void FinishCreate(); // appele par la fenetre mere, apres XtRealize() 19 21 20 22 // Activation des evenements 21 virtual void ActivatePtrCross();22 virtual void ActivateButton(int bid);23 virtual void ActivateMove(int bid);24 virtual void ActivateKeyboard();23 virtual void ActivatePtrCross(); 24 virtual void ActivateButton(int bid); 25 virtual void ActivateMove(int bid); 26 virtual void ActivateKeyboard(); 25 27 26 // Trace graphiques 27 virtual void EraseWindow(int x0=0, int y0=0, int dx=0, int dy=0); 28 virtual void DrawString(int x, int y, char* s, int pos = 0); 29 virtual void DrawOpaqueString(int x, int y, char* s, int pos = 0); 30 virtual void DrawLine(int x1, int y1, int x2, int y2); 31 virtual void DrawBox(int x0, int y0, int dx, int dy); 32 virtual void DrawFBox(int x0, int y0, int dx, int dy); 33 virtual void DrawCircle(int x0, int y0, int r); 34 virtual void DrawFCircle(int x0, int y0, int r); 35 virtual void DrawPolygon(int *x, int *y, int n); 36 virtual void DrawFPolygon(int *x, int *y, int n); 37 virtual void DrawMarker(int x0, int y0); 38 virtual void DrawMarkers(int *x, int *y, int n); 39 virtual void DrawPixmap(int x, int y, unsigned char *pix, 40 int sx, int sy, PIColorMap* cmap); 28 // Divers : couleur de fond, Effacement fenetre, forme de la souris 29 virtual void SetBackgroundColor(PIColors col=PI_White); 30 virtual void EraseWindow(int x0=0, int y0=0, int dx=0, int dy=0); 31 virtual void SelPointerShape(PIPointer ptr=PI_ArrowPointer); 32 virtual PIColors GetBackgroundColor(); 33 virtual PIPointer GetPointerShape(); 41 34 42 virtual int CalcStringWidth(char const* s); 43 44 // Modifications attributs graphiques 45 virtual void SelForeground(PIColors col=PI_Black); 46 virtual void SelBackground(PIColors col=PI_White); 47 virtual void SelGOMode(PIGOMode mod=PI_GOCopy); 48 virtual void SelFont(PIFontSize sz=PI_NormalSizeFont, 49 PIFontAtt att=PI_RomanFont); 50 virtual void SelFontSzPt(int npt=12, PIFontAtt att=PI_RomanFont); 51 virtual void SelLine(PILineAtt att=PI_NormalLine); 52 virtual void SelPointerShape(PIPointer ptr=PI_ArrowPointer); 53 virtual void SelMarker(int msz, PIMarker mrk=PI_DotMarker); 54 55 // Selection de zone de trace (clip) 56 virtual void SetClipRectangle(int x0, int y0, int dx, int dy); 57 virtual void ClearClipRectangle(); 58 59 // Acces aux attributs graphiques 60 virtual PIColors GetForeground(); 61 virtual PIColors GetBackground(); 62 virtual PIGOMode GetGOMode(); 63 virtual PIFontAtt GetFontAtt(); 64 virtual int GetFontSize(); 65 virtual PILineAtt GetLineAtt(); 66 virtual PIPointer GetPointerShape(); 67 virtual PIMarker GetMarker(); 68 virtual int GetMarkerSize(); 69 virtual int GetFontHeight(int& asc, int& desc); 70 71 // Sauvegarde des attributs graphiques 72 virtual void SaveGraphicAtt(); 73 74 35 // Appel depuis le PIXtBaseWidget uniquement (ExposeEvt de Xt ) 36 virtual void eXposeProcess(int x0, int y0, int dx, int dy); 37 75 38 protected: 76 77 void Init(); 78 void SelectFont(int isz, int jat); 79 inline GC DefGC() { return mDefGC; } 80 81 GC mDefGC; 82 PIColors mFCol, mBCol; 83 PIGOMode mGOm; 39 void Init(); 84 40 PIPointer mPtrS; 85 PIFontAtt mFAtt; 86 PILineAtt mLAtt; 87 int mFSize; 88 XFontStruct *mFSt; 89 PIMarker mMrk; 90 int mMrkSz; 41 PIColors mBCol; 91 42 }; 92 43 -
trunk/SophyaPI/PI/pidrawer.cc
r52 r71 5 5 { 6 6 mBWdg = NULL; 7 mGrUC = NULL; 7 8 xW0 = yW0 = 0; xWd = yWd = 100; 8 9 aXdir = false; // Vrai si Axe X de Droite vers Gauche … … 11 12 limitsFixed = 0; 12 13 SetAxesFlags(kAxesDflt); 13 clip = true;14 14 mDndfg = false; // Pour controle de l'appel de Detach() si delete 15 15 } … … 21 21 for(it = mBWdgList.begin(); it != mBWdgList.end(); it++) 22 22 (*it).wdg->RemoveDrawer((*it).id); 23 } 24 25 26 void 27 PIDrawer::SetLimits(double xmin, double xmax, double ymin, double ymax, 23 if (mGrUC) delete mGrUC; 24 } 25 26 27 void 28 PIDrawer::SetLimits(float xmin, float xmax, float ymin, float ymax, 28 29 int axrl, int ayud) 29 30 { … … 38 39 yMin = ymin; 39 40 yMax = ymax; 40 SetDrwWdg(mBWdg, xW0, yW0, xWd, yWd);41 aXFlg = axrl; aYFlg = ayud; 41 42 CalcTicks(); 42 43 limitsFixed = 1; 43 44 } 45 44 46 45 47 void … … 65 67 66 68 67 void 68 PIDrawer::SetDrwWdg(PIBaseWdgGen* drw, int x0, int y0, int dx, int dy )69 PIGraphicUC* 70 PIDrawer::SetDrwWdg(PIBaseWdgGen* drw, int x0, int y0, int dx, int dy, PIGraphicGen* g) 69 71 { 70 72 mBWdg = drw; 71 73 xW0 = x0; yW0 = y0; 72 74 xWd = dx; yWd = dy; 73 xScale = (double)dx/(xMax-xMin); 74 if (aXdir) { 75 xScale = -xScale; 76 xOrg = -xMax * xScale; 77 } 78 else xOrg = -xMin * xScale; 79 xOrg += xW0; 80 81 yScale = (double)dy/(yMax-yMin); 82 if (!aYdir) { 83 yScale = -yScale; 84 yOrg = -yMax * yScale; 85 } 86 else yOrg = -yMin * yScale; 87 yOrg += yW0; 88 return; 75 if (mGrUC) delete mGrUC; 76 mGrUC = new PIGraphicUC(g, x0, y0, dx, dy); 77 mGrUC->SetUCS(xMin, xMax, yMin, yMax, aXFlg, aYFlg); 78 return(mGrUC); 89 79 } 90 80 … … 93 83 PIDrawer::CalcTicks() 94 84 { 95 doublexExt = xMax-xMin;85 float xExt = xMax-xMin; 96 86 int lx = (int) ceil(log10(xExt)-0.1); 97 xExt = pow(10.0,lx);87 xExt = (float)pow(10.0,lx); 98 88 xMajTickStep = xExt/10; 99 89 xMinTickStep = xMajTickStep/10; … … 104 94 105 95 106 doubleyExt = yMax-yMin;96 float yExt = yMax-yMin; 107 97 int ly = (int) ceil(log10(yExt)-0.1); 108 yExt = pow(10.0,ly);98 yExt = (float)pow(10.0,ly); 109 99 yMajTickStep = yExt/10; 110 100 yMinTickStep = yMajTickStep/10; … … 119 109 xMinTickLen = (yMax-yMin)/250; 120 110 121 }122 123 void124 PIDrawer::Sc2Local(double x, double y, int& xpix, int& ypix)125 {126 xpix = int(xOrg + x*xScale + .5);127 ypix = int(yOrg + y*yScale + .5);128 }129 130 void131 PIDrawer::Sc2LocalF(double x, double y, float& xpix, float& ypix)132 {133 xpix = (float)(xOrg + x*xScale + .5);134 ypix = (float)(yOrg + y*yScale + .5);135 }136 137 void138 PIDrawer::Local2Sc(int xpix, int ypix, double& x, double& y)139 {140 x = (xpix-xOrg)/xScale;141 y = (ypix-yOrg)/yScale;142 }143 144 145 void146 PIDrawer::DSc2Local(double dx, double dy, int& dxpix, int& dypix)147 {148 dxpix = int(dx*xScale + .5);149 if (dxpix < 0) dxpix = -dxpix;150 dypix = int(dy*yScale + .5);151 if (dypix < 0) dypix = -dxpix;152 }153 154 155 void156 PIDrawer::Erase()157 {158 if (!mBWdg) return;159 mBWdg->EraseWindow(xW0, yW0, xWd, yWd);160 }161 162 void163 PIDrawer::DrawString(double x, double y, char* s, int pos)164 {165 if (!mBWdg) return;166 if (mBWdg->mPSOut) {167 float xf, yf;168 Sc2LocalF(x, y, xf, yf);169 (mBWdg->mPSOut)->DrawString(xf,yf,s, mBWdg->GetForeground(), /* $CHECK$ PIFontSize ?? */170 mBWdg->GetFontAtt(), mBWdg->GetFontSize());171 }172 else {173 int xPix, yPix;174 Sc2Local(x, y, xPix, yPix);175 mBWdg->DrawString(xPix, yPix, s, pos);176 }177 }178 179 void180 PIDrawer::DrawLine(double x1, double y1, double x2, double y2)181 {182 183 if (!mBWdg) return;184 if (clip) {185 if (x2 < xMin && x1 < xMin) return;186 if (x2 > xMax && x1 > xMax) return;187 if (y1 < yMin && y2 < yMin) return;188 if (y1 > yMax && y2 > yMax) return;189 if (x2 < x1) {190 swap(x1,x2);191 swap(y1,y2);192 }193 if (x2>xMax) {194 y2 = y1 + (y2-y1)/(x2-x1)*(xMax-x1);195 x2 = xMax;196 }197 if (x1<xMin) {198 y1 = y2 + (y1-y2)/(x1-x2)*(xMin-x2);199 x1 = xMin;200 }201 if (y2 < y1) {202 swap(x1,x2);203 swap(y1,y2);204 }205 if (y2>yMax) {206 x2 = x1 + (x2-x1)/(y2-y1)*(yMax-y1);207 y2 = yMax;208 }209 if (y1<yMin) {210 x1 = x2 + (x1-x2)/(y1-y2)*(yMin-y2);211 y1 = yMin;212 }213 }214 215 if (mBWdg->mPSOut) {216 float xf1, yf1, xf2, yf2;217 Sc2LocalF(x1, y1, xf1, yf1);218 Sc2LocalF(x2, y2, xf2, yf2);219 (mBWdg->mPSOut)->DrawLine(xf1, yf1, xf2, yf2, mBWdg->GetForeground(), mBWdg->GetLineAtt());220 221 return;222 }223 224 int x1Pix, y1Pix, x2Pix, y2Pix;225 Sc2Local(x1, y1, x1Pix, y1Pix);226 Sc2Local(x2, y2, x2Pix, y2Pix);227 mBWdg->DrawLine(x1Pix, y1Pix, x2Pix, y2Pix);228 }229 230 231 void232 PIDrawer::DrawBox(double x, double y, double dx, double dy)233 {234 if (!mBWdg) return;235 if (clip) {236 if (dx < 0) {237 x = x+dx;238 dx = -dx;239 }240 if (dy < 0) {241 y = y+dy;242 dy = -dy;243 }244 if (x > xMax || x+dx < xMin || y > yMax || y+dy < yMin) return;245 if (x < xMin) {246 dx -= (xMin-x);247 x = xMin;248 }249 if (y < yMin) {250 dy -= (yMin-y);251 y = yMin;252 }253 if (x+dx > xMax)254 dx = (xMax-x);255 if (y+dy > yMax)256 dy = (yMax-y);257 }258 259 if (mBWdg->mPSOut) {260 float xf, yf, xf2, yf2;261 Sc2LocalF(x, y, xf, yf);262 Sc2LocalF(x+dx, y+dy, xf2, yf2);263 if (xf2 < xf) swap(xf, xf2);264 if (yf2 < yf) swap(yf, yf2);265 (mBWdg->mPSOut)->DrawBox(xf, yf, xf2-xf, yf2-yf, mBWdg->GetForeground(), mBWdg->GetLineAtt() );266 return;267 }268 269 int xPix, yPix, x2Pix, y2Pix;270 Sc2Local(x, y, xPix, yPix);271 Sc2Local(x+dx, y+dy, x2Pix, y2Pix);272 if (x2Pix < xPix) swap(xPix, x2Pix);273 if (y2Pix < yPix) swap(yPix, y2Pix);274 mBWdg->DrawBox(xPix, yPix, x2Pix-xPix, y2Pix-yPix);275 }276 277 void278 PIDrawer::DrawFBox(double x, double y, double dx, double dy)279 {280 281 if (!mBWdg) return;282 if (clip) {283 if (dx < 0) {284 x = x+dx;285 dx = -dx;286 }287 if (dy < 0) {288 y = y+dy;289 dy = -dy;290 }291 if (x > xMax || x+dx < xMin || y > yMax || y+dy < yMin) return;292 if (x < xMin) {293 dx -= (xMin-x);294 x = xMin;295 }296 if (y < yMin) {297 dy -= (yMin-y);298 y = yMin;299 }300 if (x+dx > xMax)301 dx = (xMax-x);302 if (y+dy > yMax)303 dy = (yMax-y);304 }305 306 if (mBWdg->mPSOut) {307 float xf, yf, xf2, yf2;308 Sc2LocalF(x, y, xf, yf);309 Sc2LocalF(x+dx, y+dy, xf2, yf2);310 if (xf2 < xf) swap(xf, xf2);311 if (yf2 < yf) swap(yf, yf2);312 (mBWdg->mPSOut)->DrawFBox(xf, yf, xf2-xf, yf2-yf, mBWdg->GetForeground(),313 mBWdg->GetForeground(), mBWdg->GetLineAtt());314 return;315 }316 317 int xPix, yPix, x2Pix, y2Pix;318 Sc2Local(x, y, xPix, yPix);319 Sc2Local(x+dx, y+dy, x2Pix, y2Pix);320 if (x2Pix < xPix) swap(xPix, x2Pix);321 if (y2Pix < yPix) swap(yPix, y2Pix);322 mBWdg->DrawFBox(xPix, yPix, x2Pix-xPix, y2Pix-yPix);323 }324 325 void326 PIDrawer::DrawCircle(double x, double y, double r)327 {328 if (!mBWdg) return;329 if (mBWdg->mPSOut) {330 float xf, yf, rf;331 Sc2LocalF(x, y, xf, yf);332 rf = r * xScale;333 if (xScale < 0.) rf = -rf;334 (mBWdg->mPSOut)->DrawCircle(xf, yf, rf,mBWdg->GetForeground(), mBWdg->GetLineAtt());335 return;336 }337 338 int xPix, yPix, rPix;339 Sc2Local(x, y, xPix, yPix);340 rPix = (int)(r * xScale);341 if (xScale < 0.) rPix = -rPix;342 mBWdg->DrawCircle(xPix, yPix, rPix);343 }344 345 void346 PIDrawer::DrawFCircle(double x, double y, double r)347 {348 if (!mBWdg) return;349 if (mBWdg->mPSOut) {350 float xf, yf, rf;351 Sc2LocalF(x, y, xf, yf);352 rf = r * xScale;353 if (xScale < 0.) rf = -rf;354 (mBWdg->mPSOut)->DrawFCircle(xf, yf, rf, mBWdg->GetForeground(),355 mBWdg->GetForeground(), mBWdg->GetLineAtt());356 return;357 }358 int xPix, yPix, rPix;359 Sc2Local(x, y, xPix, yPix);360 rPix = (int)(r * xScale);361 if (xScale < 0.) rPix = -rPix;362 mBWdg->DrawFCircle(xPix, yPix, rPix);363 }364 365 #define NMXMULTP 30 // Pour multipoint sans new366 367 void368 PIDrawer::DrawPolygon(double *x, double *y, int n)369 {370 int ix[NMXMULTP], iy[NMXMULTP];371 int *pxi, *pyi;372 int i;373 374 if (!mBWdg) return;375 if (n <= 0) return;376 377 if(mBWdg->mPSOut) {378 float *xf, *yf;379 xf = new float[n];380 yf = new float[n];381 for(i=0;i<n;i++)382 Sc2LocalF(x[i], y[i], xf[i], yf[i]);383 (mBWdg->mPSOut)->DrawPolygon(xf,yf,n, mBWdg->GetForeground(), mBWdg->GetLineAtt());384 delete[] xf;385 delete[] yf;386 return;387 }388 389 if (n > NMXMULTP) { pxi = new int[n]; pyi = new int[n]; }390 else { pxi = ix; pyi = iy; }391 for(i=0; i<n; i++)392 Sc2Local(x[i], y[i], pxi[i], pyi[i]);393 mBWdg->DrawPolygon(pxi, pyi, n);394 if (n > NMXMULTP) { delete[] pxi; delete[] pyi; }395 return;396 }397 398 void399 PIDrawer::DrawFPolygon(double *x, double *y, int n)400 {401 int xi[NMXMULTP], yi[NMXMULTP];402 int *pxi, *pyi;403 int i;404 405 if (!mBWdg) return;406 if (n <= 0) return;407 408 if(mBWdg->mPSOut) {409 float *xf, *yf;410 xf = new float[n];411 yf = new float[n];412 for(i=0;i<n;i++)413 Sc2LocalF(x[i], y[i], xf[i], yf[i]);414 (mBWdg->mPSOut)->DrawFPolygon(xf, yf, n, mBWdg->GetForeground(),415 mBWdg->GetForeground(), mBWdg->GetLineAtt());416 delete[] xf;417 delete[] yf;418 return;419 }420 421 if (n > NMXMULTP) { pxi = new int[n]; pyi = new int[n]; }422 else { pxi = xi; pyi = yi; }423 for(i=0; i<n; i++)424 Sc2Local(x[i], y[i], pxi[i], pyi[i]);425 mBWdg->DrawFPolygon(pxi, pyi, n);426 if (n > NMXMULTP) { delete[] pxi; delete[] pyi; }427 return;428 }429 430 void431 PIDrawer::DrawMarker(double x0, double y0)432 {433 if (!mBWdg) return;434 if(mBWdg->mPSOut) {435 float xf, yf;436 Sc2LocalF(x0, y0, xf, yf);437 (mBWdg->mPSOut)->DrawMarker(xf, yf, mBWdg->GetMarker(),438 mBWdg->GetForeground(), mBWdg->GetMarkerSize() );439 return;440 }441 int xPix, yPix;442 Sc2Local(x0, y0, xPix, yPix);443 mBWdg->DrawMarker(xPix, yPix);444 return;445 }446 447 void448 PIDrawer::DrawMarkers(double *x, double *y, int n)449 {450 int xi[NMXMULTP], yi[NMXMULTP];451 int *pxi, *pyi;452 int i;453 454 if (!mBWdg) return;455 if (n <= 0) return;456 457 if(mBWdg->mPSOut) {458 float *xf, *yf;459 xf = new float[n];460 yf = new float[n];461 for(i=0;i<n;i++)462 Sc2LocalF(x[i], y[i], xf[i], yf[i]);463 464 (mBWdg->mPSOut)->DrawMarkers(xf, yf, n, mBWdg->GetMarker(),465 mBWdg->GetForeground(), mBWdg->GetMarkerSize() );466 delete[] xf;467 delete[] yf;468 return;469 }470 471 if (n > NMXMULTP) { pxi = new int[n]; pyi = new int[n]; }472 else { pxi = xi; pyi = yi; }473 for(i=0; i<n; i++)474 Sc2Local(x[i], y[i], pxi[i], pyi[i]);475 mBWdg->DrawMarkers(pxi, pyi, n);476 if (n > NMXMULTP) { delete[] pxi; delete[] pyi; }477 return;478 }479 480 void481 PIDrawer::DrawPixmap(double x, double y, unsigned char *pix,482 int sx, int sy, PIColorMap* cmap)483 {484 if (!mBWdg) return;485 if ( (sx < 1) || (sy < 1) ) return;486 if ((pix == NULL) || (cmap == NULL)) return;487 488 if(mBWdg->mPSOut) {489 float xf,yf;490 Sc2LocalF(x, y, xf, yf);491 (mBWdg->mPSOut)->Image(xf, yf, (float)sx, (float)sy, sx, sy, pix, cmap);492 return;493 }494 495 int xPix, yPix;496 Sc2Local(x, y, xPix, yPix);497 mBWdg->DrawPixmap(xPix, yPix, pix, sx, sy, cmap);498 }499 500 double501 PIDrawer::StringWidth(char const* s)502 {503 if (!mBWdg) return(0.);504 return mBWdg->CalcStringWidth(s) / xScale;505 }506 507 double508 PIDrawer::FontHeight(double& asc, double& desc)509 {510 if (!mBWdg) return(0.);511 int h,a,d;512 h = mBWdg->GetFontHeight(a,d);513 asc = (double)a / yScale;514 desc = (double)d / yScale;515 return((double)h / yScale);516 }517 518 519 void520 PIDrawer::SelForeground(PIColors col)521 {522 if (!mBWdg) return;523 mBWdg->SelForeground(col);524 return;525 }526 527 528 void529 PIDrawer::SelBackground(PIColors col)530 {531 if (!mBWdg) return;532 mBWdg->SelBackground(col);533 return;534 }535 536 void537 PIDrawer::SelGOMode(PIGOMode mod)538 {539 if (!mBWdg) return;540 mBWdg->SelGOMode(mod);541 return;542 }543 544 void545 PIDrawer::SelFont(PIFontSize sz, PIFontAtt att)546 {547 if (!mBWdg) return;548 mBWdg->SelFont(sz, att);549 return;550 }551 552 void553 PIDrawer::SelLine(PILineAtt att)554 {555 if (!mBWdg) return;556 mBWdg->SelLine(att);557 return;558 }559 560 561 void562 PIDrawer::SelFontSz(double size, PIFontAtt att)563 {564 if (!mBWdg) return;565 int npt = int(fabs(size * yScale)+.5);566 if (npt < 8) npt = 8;567 if (npt > 127) npt = 127;568 mBWdg->SelFontSzPt(npt, att);569 }570 571 void572 PIDrawer::SelMarker(double size, PIMarker mrk)573 {574 if (!mBWdg) return;575 int isz = int(fabs(size * xScale)+.5);576 mBWdg->SelMarker( isz, mrk);577 }578 579 void580 PIDrawer::SelMarker(int msz, PIMarker mrk)581 {582 if (!mBWdg) return;583 mBWdg->SelMarker( msz, mrk);584 111 } 585 112 … … 600 127 601 128 void 602 PIDrawer::DrawAxes( int flags)603 { 604 NoClip();129 PIDrawer::DrawAxes(PIGraphicUC* g, int flags) 130 { 131 g->NoClip(); 605 132 if (flags == -1) 606 133 flags = axesFlags; … … 611 138 // Les axes 612 139 613 DrawLine(xMin, 0, xMax, 0);614 DrawLine(0, yMin, 0, yMax);140 g->DrawLine(xMin, 0, xMax, 0); 141 g->DrawLine(0, yMin, 0, yMax); 615 142 616 143 // Les ticks majeurs 617 144 618 145 if (flags & kMajTicks) { 619 DrawHTicks( 0, xMajTickLen, xMajTickLen, xFirstMajTick, xMajTickStep);620 DrawVTicks( 0, yMajTickLen, yMajTickLen, yFirstMajTick, yMajTickStep);146 DrawHTicks(g, 0, xMajTickLen, xMajTickLen, xFirstMajTick, xMajTickStep); 147 DrawVTicks(g, 0, yMajTickLen, yMajTickLen, yFirstMajTick, yMajTickStep); 621 148 } 622 149 … … 624 151 625 152 if (flags & kMinTicks) { 626 DrawHTicks( 0, xMinTickLen, xMinTickLen, xFirstMinTick, xMinTickStep);627 DrawVTicks( 0, yMinTickLen, yMinTickLen, yFirstMinTick, yMinTickStep);153 DrawHTicks(g, 0, xMinTickLen, xMinTickLen, xFirstMinTick, xMinTickStep); 154 DrawVTicks(g, 0, yMinTickLen, yMinTickLen, yFirstMinTick, yMinTickStep); 628 155 } 629 156 … … 632 159 if (flags & kLabels) { 633 160 if (!aYdir) 634 DrawHLabels( -xMajTickLen*8, xFirstMajTick, xMajTickStep,0);161 DrawHLabels(g, -xMajTickLen*8, xFirstMajTick, xMajTickStep,0); 635 162 else 636 DrawHLabels( xMajTickLen*8, xFirstMajTick, xMajTickStep,0);163 DrawHLabels(g, xMajTickLen*8, xFirstMajTick, xMajTickStep,0); 637 164 if (!aXdir) 638 DrawVLabels( -yMajTickLen*2, yFirstMajTick, yMajTickStep,1);165 DrawVLabels(g, -yMajTickLen*2, yFirstMajTick, yMajTickStep,1); 639 166 else 640 DrawVLabels( yMajTickLen*2, yFirstMajTick, yMajTickStep,1);167 DrawVLabels(g, yMajTickLen*2, yFirstMajTick, yMajTickStep,1); 641 168 } 642 169 … … 647 174 // La boite 648 175 649 DrawLine(xMin, yMin, xMax, yMin);650 DrawLine(xMax, yMin, xMax, yMax);651 DrawLine(xMax, yMax, xMin, yMax);652 DrawLine(xMin, yMax, xMin, yMin);176 g->DrawLine(xMin, yMin, xMax, yMin); 177 g->DrawLine(xMax, yMin, xMax, yMax); 178 g->DrawLine(xMax, yMax, xMin, yMax); 179 g->DrawLine(xMin, yMax, xMin, yMin); 653 180 654 181 // Longueur des ticks 655 182 656 doubleextXMajTickLen = flags&kExtTicks ? xMajTickLen : 0;657 doubleintXMajTickLen = flags&kIntTicks ? xMajTickLen : 0;658 doubleextXMinTickLen = flags&kExtTicks ? xMinTickLen : 0;659 doubleintXMinTickLen = flags&kIntTicks ? xMinTickLen : 0;660 doubleextYMajTickLen = flags&kExtTicks ? yMajTickLen : 0;661 doubleintYMajTickLen = flags&kIntTicks ? yMajTickLen : 0;662 doubleextYMinTickLen = flags&kExtTicks ? yMinTickLen : 0;663 doubleintYMinTickLen = flags&kIntTicks ? yMinTickLen : 0;183 float extXMajTickLen = flags&kExtTicks ? xMajTickLen : 0; 184 float intXMajTickLen = flags&kIntTicks ? xMajTickLen : 0; 185 float extXMinTickLen = flags&kExtTicks ? xMinTickLen : 0; 186 float intXMinTickLen = flags&kIntTicks ? xMinTickLen : 0; 187 float extYMajTickLen = flags&kExtTicks ? yMajTickLen : 0; 188 float intYMajTickLen = flags&kIntTicks ? yMajTickLen : 0; 189 float extYMinTickLen = flags&kExtTicks ? yMinTickLen : 0; 190 float intYMinTickLen = flags&kIntTicks ? yMinTickLen : 0; 664 191 665 192 // Les ticks majeurs 666 193 667 194 if (flags & kMajTicks) { 668 DrawHTicks( yMin, intXMajTickLen, extXMajTickLen, xFirstMajTick, xMajTickStep);669 DrawHTicks( yMax, extXMajTickLen, intXMajTickLen, xFirstMajTick, xMajTickStep);670 DrawVTicks( xMin, extYMajTickLen, intYMajTickLen, yFirstMajTick, yMajTickStep);671 DrawVTicks( xMax, intYMajTickLen, extYMajTickLen, yFirstMajTick, yMajTickStep);195 DrawHTicks(g, yMin, intXMajTickLen, extXMajTickLen, xFirstMajTick, xMajTickStep); 196 DrawHTicks(g, yMax, extXMajTickLen, intXMajTickLen, xFirstMajTick, xMajTickStep); 197 DrawVTicks(g, xMin, extYMajTickLen, intYMajTickLen, yFirstMajTick, yMajTickStep); 198 DrawVTicks(g, xMax, intYMajTickLen, extYMajTickLen, yFirstMajTick, yMajTickStep); 672 199 } 673 200 … … 675 202 676 203 if (flags & kMinTicks) { 677 DrawHTicks( yMin, intXMinTickLen, extXMinTickLen, xFirstMinTick, xMinTickStep);678 DrawHTicks( yMax, extXMinTickLen, intXMinTickLen, xFirstMinTick, xMinTickStep);679 DrawVTicks( xMin, extYMinTickLen, intYMinTickLen, yFirstMinTick, yMinTickStep);680 DrawVTicks( xMax, intYMinTickLen, extYMinTickLen, yFirstMinTick, yMinTickStep);204 DrawHTicks(g, yMin, intXMinTickLen, extXMinTickLen, xFirstMinTick, xMinTickStep); 205 DrawHTicks(g, yMax, extXMinTickLen, intXMinTickLen, xFirstMinTick, xMinTickStep); 206 DrawVTicks(g, xMin, extYMinTickLen, intYMinTickLen, yFirstMinTick, yMinTickStep); 207 DrawVTicks(g, xMax, intYMinTickLen, extYMinTickLen, yFirstMinTick, yMinTickStep); 681 208 } 682 209 … … 686 213 if (flags & kLabels) { 687 214 if (!aYdir) { 688 DrawHLabels( yMin-xMajTickLen*8, xFirstMajTick, xMajTickStep,0);689 DrawHLabels( yMax+xMajTickLen*2, xFirstMajTick, xMajTickStep,0);215 DrawHLabels(g, yMin-xMajTickLen*8, xFirstMajTick, xMajTickStep,0); 216 DrawHLabels(g, yMax+xMajTickLen*2, xFirstMajTick, xMajTickStep,0); 690 217 } 691 218 else { 692 DrawHLabels( yMin-xMajTickLen*2, xFirstMajTick, xMajTickStep,0);693 DrawHLabels( yMax+xMajTickLen*8, xFirstMajTick, xMajTickStep,0);219 DrawHLabels(g, yMin-xMajTickLen*2, xFirstMajTick, xMajTickStep,0); 220 DrawHLabels(g, yMax+xMajTickLen*8, xFirstMajTick, xMajTickStep,0); 694 221 } 695 222 if (!aXdir) { 696 DrawVLabels( xMin-yMajTickLen*2, yFirstMajTick, yMajTickStep,1);697 DrawVLabels( xMax+yMajTickLen*2, yFirstMajTick, yMajTickStep,-1);223 DrawVLabels(g, xMin-yMajTickLen*2, yFirstMajTick, yMajTickStep,1); 224 DrawVLabels(g, xMax+yMajTickLen*2, yFirstMajTick, yMajTickStep,-1); 698 225 } 699 226 else { 700 DrawVLabels( xMin-yMajTickLen*2, yFirstMajTick, yMajTickStep,-1);701 DrawVLabels( xMax+yMajTickLen*2, yFirstMajTick, yMajTickStep,1);227 DrawVLabels(g, xMin-yMajTickLen*2, yFirstMajTick, yMajTickStep,-1); 228 DrawVLabels(g, xMax+yMajTickLen*2, yFirstMajTick, yMajTickStep,1); 702 229 } 703 230 } 704 231 } 705 Clip();706 } 707 708 709 void 710 PIDrawer::Draw( )711 { 712 } 713 714 void 715 PIDrawer::Draw( double /*xmin*/, double /*ymin*/, double /*xmax*/, double/*ymax*/)716 { 717 Draw( );718 } 719 720 721 void 722 PIDrawer::DrawHTicks( double y, double tickUp, double tickDown, double xBeg, doublexStep)723 { 724 for ( doublex=xBeg; x<=xMax; x += xStep)725 DrawLine(x, y-tickDown, x, y+tickUp);726 } 727 728 void 729 PIDrawer::DrawVTicks( double x, double tickLeft, double tickRight, double yBeg, doubleyStep)730 { 731 for ( doubley=yBeg; y<=yMax; y += yStep)732 DrawLine(x-tickLeft, y, x+tickRight, y);733 } 734 735 void 736 PIDrawer::DrawHLabels( double y, double xBeg, doublexStep, int just)737 { 738 doublexOffset = 0;232 g->Clip(); 233 } 234 235 236 void 237 PIDrawer::Draw(PIGraphicUC*) 238 { 239 } 240 241 void 242 PIDrawer::Draw(PIGraphicUC* g, float /*xmin*/, float /*ymin*/, float /*xmax*/, float /*ymax*/) 243 { 244 Draw(g); 245 } 246 247 248 void 249 PIDrawer::DrawHTicks(PIGraphicUC* g, float y, float tickUp, float tickDown, float xBeg, float xStep) 250 { 251 for (float x=xBeg; x<=xMax; x += xStep) 252 g->DrawLine(x, y-tickDown, x, y+tickUp); 253 } 254 255 void 256 PIDrawer::DrawVTicks(PIGraphicUC* g, float x, float tickLeft, float tickRight, float yBeg, float yStep) 257 { 258 for (float y=yBeg; y<=yMax; y += yStep) 259 g->DrawLine(x-tickLeft, y, x+tickRight, y); 260 } 261 262 void 263 PIDrawer::DrawHLabels(PIGraphicUC* g, float y, float xBeg, float xStep, int just) 264 { 265 float xOffset = 0; 739 266 int kk; 740 SelFontSz(xMajTickLen*4.);741 for ( doublex=xBeg; x<=xMax; x += xStep) {267 g->SelFontSz(yMajTickLen*4.); 268 for (float x=xBeg; x<=xMax; x += xStep) { 742 269 char label[20]; sprintf(label, "%-6g", x); 743 270 for(kk=0; kk<20; kk++) 744 271 if (label[kk] == ' ') { label[kk] = '\0' ; break; } 745 double largeur =StringWidth(label);272 float largeur = g->CalcStringWidth(label); 746 273 if (just == 1) 747 274 xOffset = -largeur; … … 751 278 xOffset = 0; 752 279 if (aXdir) xOffset = -xOffset; 753 DrawString(x+xOffset, y, label);280 g->DrawString(x+xOffset, y, label); 754 281 } 755 } 756 757 void 758 PIDrawer::DrawVLabels(double x, double yBeg, double yStep, int just) 759 { 760 double xOffset = 0; 761 SelFontSz(xMajTickLen*4.); 762 for (double y=yBeg; y<=yMax; y += yStep) { 282 printf(" DBGDBG Out of PIDrawer::DrawHLabels \n"); 283 } 284 285 void 286 PIDrawer::DrawVLabels(PIGraphicUC* g, float x, float yBeg, float yStep, int just) 287 { 288 float xOffset = 0; 289 g->SelFontSz(yMajTickLen*4.); 290 for (float y=yBeg; y<=yMax; y += yStep) { 763 291 char label[20]; sprintf(label, "%-6g", y); 764 double largeur =StringWidth(label);292 float largeur = g->CalcStringWidth(label); 765 293 if (just == 1) 766 294 xOffset = -largeur; … … 770 298 xOffset = 0; 771 299 if (aXdir) xOffset = -xOffset; 772 DrawString(x+xOffset, y, label);300 g->DrawString(x+xOffset, y, label); 773 301 } 774 302 } -
trunk/SophyaPI/PI/pidrawer.h
r52 r71 3 3 4 4 #include "pibwdggen.h" 5 #include "pigraphuc.h" 5 6 #include <list> 6 7 … … 17 18 }; 18 19 19 enum {20 kAxeDirSame = 0,21 kAxeDirLtoR = 1,22 kAxeDirRtoL = 2,23 kAxeDirDownUp = 3,24 kAxeDirUpDown = 425 };26 27 20 28 21 class PIDrawer { … … 31 24 virtual ~PIDrawer(); 32 25 33 virtual void SetLimits( double xmin, double xmax, double ymin, doubleymax,26 virtual void SetLimits(float xmin, float xmax, float ymin, float ymax, 34 27 int axrl=kAxeDirSame, int ayud=kAxeDirSame); 35 28 36 37 virtual void Erase(); 38 virtual void DrawString(double x, double y, char* s, int pos = 0); 39 virtual void DrawLine(double x1, double y1, double x2, double y2); 40 virtual void DrawBox(double x0, double y0, double dx, double dy); 41 virtual void DrawFBox(double x0, double y0, double dx, double dy); 42 virtual void DrawCircle(double x0, double y0, double r); 43 virtual void DrawFCircle(double x0, double y0, double r); 44 virtual void DrawPolygon(double *x, double *y, int n); 45 virtual void DrawFPolygon(double *x, double *y, int n); 46 virtual void DrawMarker(double x0, double y0); 47 virtual void DrawMarkers(double *x0, double *y0, int n); 48 virtual void DrawPixmap(double x, double y, unsigned char *pix, 49 int sx, int sy, PIColorMap* cmap); 50 51 virtual double StringWidth(char const*); 52 virtual double FontHeight(double& asc, double& desc); 53 54 virtual void SelForeground(PIColors col=PI_Black); 55 virtual void SelBackground(PIColors col=PI_White); 56 virtual void SelGOMode(PIGOMode mod=PI_GOCopy); 57 virtual void SelFont(PIFontSize sz=PI_NormalSizeFont, 58 PIFontAtt att=PI_RomanFont); 59 virtual void SelLine(PILineAtt att=PI_NormalLine); 60 virtual void SelFontSz(double size, PIFontAtt att=PI_RomanFont); 61 virtual void SelMarker(double size=0, PIMarker mrk=PI_DotMarker); 62 virtual void SelMarker(int msz=3, PIMarker mrk=PI_DotMarker); 63 64 virtual void DrawAxes(int flags = -1); 29 virtual void DrawAxes(PIGraphicUC* g, int flags = -1); 65 30 virtual void SetAxesFlags(int flags=kAxesDflt); 66 31 67 virtual void Draw(); 68 virtual void Draw(double xmin, double ymin, double xmax, double ymax); 32 virtual void Draw(PIGraphicUC* g); 33 virtual void Draw(PIGraphicUC* g, float xmin, float ymin, float xmax, float ymax); 34 35 float XMin() const {return xMin;} 36 float XMax() const {return xMax;} 37 float YMin() const {return yMin;} 38 float YMax() const {return yMax;} 69 39 70 virtual void Sc2Local(double x, double y, int& xpix, int& ypix); 71 virtual void Sc2LocalF(double x, double y, float& xpix, float& ypix); 72 virtual void Local2Sc(int xpix, int ypix, double& x, double& y); 73 virtual void DSc2Local(double dx, double dy, int& dxpix, int& dypix); 74 75 76 77 double XMin() const {return xMin;} 78 double XMax() const {return xMax;} 79 double YMin() const {return yMin;} 80 double YMax() const {return yMax;} 40 inline PIGraphicUC* GetGraphicUC() { return(mGrUC); } 81 41 82 42 int LimitsFixed() const {return limitsFixed;} 83 43 void FreeLimits() {limitsFixed = 0;} 84 void NoClip() {clip = false;}85 void Clip() {clip = true;}86 44 87 45 // Les objets/methodes suivants devraient etre protected 88 46 // Pb avec acces depuis PIBaseWdgGen (Reza 11/07/97) 89 virtual void SetDrwWdg(PIBaseWdgGen* drw, int x0, int y0, int dx, int dy); 47 virtual PIGraphicUC* SetDrwWdg(PIBaseWdgGen* drw, int x0, int y0, int dx, int dy, PIGraphicGen* g); 48 90 49 // Je declare en public a cause de cxx - Reza 11/07/97 91 50 struct DrwBWId { int id; PIBaseWdgGen* wdg; }; … … 98 57 void CalcTicks(); 99 58 100 void DrawHTicks( double y, double tickUp, double tickDown, double xBeg, doublexStep);101 void DrawVTicks( double x, double tickLeft, double tickRight, double yBeg, doubleyStep);102 void DrawHLabels( double y, double xBeg, doublexStep, int just=0);103 void DrawVLabels( double x, double yBeg, doubleyStep, int just=0);59 void DrawHTicks(PIGraphicUC* g, float y, float tickUp, float tickDown, float xBeg, float xStep); 60 void DrawVTicks(PIGraphicUC* g, float x, float tickLeft, float tickRight, float yBeg, float yStep); 61 void DrawHLabels(PIGraphicUC* g, float y, float xBeg, float xStep, int just=0); 62 void DrawVLabels(PIGraphicUC* g, float x, float yBeg, float yStep, int just=0); 104 63 105 64 106 double xMin, xMax, yMin, yMax; // Valeurs en unites user 107 double xOrg, yOrg; // Position en pixels de (0.0, 0.0) 108 double xScale, yScale; // Pixels par unites graphiques 65 float xMin, xMax, yMin, yMax; // Valeurs en unites user 109 66 int xW0, yW0, xWd, yWd; // Origine/largeur ds la fenetre de trace 110 67 bool aXdir, aYdir; // Sens des axes horiz, vertical 68 int aXFlg, aYFlg; 111 69 112 doublexFirstMajTick, xFirstMinTick;113 doubleyFirstMajTick, yFirstMinTick;114 doublexMajTickStep, xMinTickStep;115 doubleyMajTickStep, yMinTickStep;116 doublexMajTickLen, xMinTickLen;117 doubleyMajTickLen, yMinTickLen;70 float xFirstMajTick, xFirstMinTick; 71 float yFirstMajTick, yFirstMinTick; 72 float xMajTickStep, xMinTickStep; 73 float yMajTickStep, yMinTickStep; 74 float xMajTickLen, xMinTickLen; 75 float yMajTickLen, yMinTickLen; 118 76 119 77 int limitsFixed; … … 121 79 122 80 PIBaseWdgGen* mBWdg; 123 bool clip;81 PIGraphicUC* mGrUC; 124 82 125 83 list<DrwBWId> mBWdgList; -
trunk/SophyaPI/PI/pihisto.cc
r52 r71 23 23 // Commencer par trouver nos limites 24 24 25 doublexmin = mHisto->XMin();26 doublexmax = (mHisto->XMax());25 float xmin = mHisto->XMin(); 26 float xmax = (mHisto->XMax()); 27 27 28 doubleymax = mHisto->VMax()*1.2;29 doubleymin = mHisto->VMin();28 float ymax = mHisto->VMax()*1.2; 29 float ymin = mHisto->VMin(); 30 30 31 if (mDrawWdg) 31 if (mDrawWdg) 32 32 mDrawWdg->SetLimits(xmin, xmax, ymin, ymax); 33 33 else … … 39 39 40 40 void 41 PIHisto::Draw( double /*xmin*/, double /*ymin*/, double /*xmax*/, double/*ymax*/)41 PIHisto::Draw(PIGraphicUC* g, float /*xmin*/, float /*ymin*/, float /*xmax*/, float /*ymax*/) 42 42 { 43 if (!mDrawer) return;44 43 for (int i=0; i<mHisto->NBins(); i++) { 45 doubleleft = mHisto->BinLowEdge(i);46 doublewidth = mHisto->BinWidth();47 doublebottom = 0;48 doubleheight = (*mHisto)(i);49 mDrawer->DrawFBox(left,bottom,width,height);50 mDrawer->DrawLine(left, bottom, left, bottom + height); // Au moins une ligne...44 float left = mHisto->BinLowEdge(i); 45 float width = mHisto->BinWidth(); 46 float bottom = 0; 47 float height = (*mHisto)(i); 48 g->DrawFBox(left,bottom,width,height); 49 g->DrawLine(left, bottom, left, bottom + height); // Au moins une ligne... 51 50 } 52 DrawStats( );51 DrawStats(g); 53 52 } 54 53 55 54 void 56 PIHisto::DrawStats( )55 PIHisto::DrawStats(PIGraphicUC* g) 57 56 { 57 if (!mDrawWdg) return; 58 58 // Une boite dans le coin superieur droit 59 if (!mDrawer) return; 60 double cellHeight = (mDrawWdg->YMax() - mDrawWdg->YMin()) * 0.05; 61 double cellWidth = (mDrawWdg->XMax() - mDrawWdg->XMin()) * 0.23; 62 mDrawer->DrawLine(mDrawWdg->XMax() - cellWidth, mDrawWdg->YMax(), 59 float cellHeight = (mDrawWdg->YMax() - mDrawWdg->YMin()) * 0.05; 60 float cellWidth = (mDrawWdg->XMax() - mDrawWdg->XMin()) * 0.23; 61 g->DrawLine(mDrawWdg->XMax() - cellWidth, mDrawWdg->YMax(), 63 62 mDrawWdg->XMax() - cellWidth, mDrawWdg->YMax() - cellHeight); 64 mDrawer->DrawLine(mDrawWdg->XMax() - cellWidth, mDrawWdg->YMax() - cellHeight,63 g->DrawLine(mDrawWdg->XMax() - cellWidth, mDrawWdg->YMax() - cellHeight, 65 64 mDrawWdg->XMax() , mDrawWdg->YMax() - cellHeight); 66 65 char label[50]; 67 66 sprintf(label, "N = %.6g", mHisto->NData()); 68 mDrawer->SelFontSz((mDrawWdg->YMax() - mDrawWdg->YMin())/30);69 mDrawer->DrawString(mDrawWdg->XMax() - cellWidth*0.9, mDrawWdg->YMax() - cellHeight*0.8, label);67 g->SelFontSz((mDrawWdg->YMax() - mDrawWdg->YMin())/30); 68 g->DrawString(mDrawWdg->XMax() - cellWidth*0.9, mDrawWdg->YMax() - cellHeight*0.8, label); 70 69 71 70 } -
trunk/SophyaPI/PI/pihisto.h
r52 r71 9 9 PIHisto(Histo* histo, bool ad=false); 10 10 virtual ~PIHisto(); 11 virtual void Draw( double xmin, double ymin, double xmax, doubleymax);11 virtual void Draw(PIGraphicUC* g, float xmin, float ymin, float xmax, float ymax); 12 12 virtual void UpdateSize(); 13 virtual void DrawStats( );13 virtual void DrawStats(PIGraphicUC* g); 14 14 inline Histo* Histogram() { return(mHisto); } 15 15 -
trunk/SophyaPI/PI/piimage.cc
r61 r71 50 50 SetColMap(CMAP_COLRJ32); 51 51 52 SelForeground(PI_White); 53 SelBackground(PI_Black); 52 SetBackgroundColor(PI_Black); 54 53 55 54 ActivateButton(1); … … 138 137 else { nbmrk = nm; xpmrk = px, ypmrk = py; } 139 138 admrk = ad; mrkt = mrk; mrkbsz = msz; 140 if (refr) DrawMarks( 0, XSize(), 0, YSize());139 if (refr) DrawMarks(mWGrC, 0, XSize(), 0, YSize()); 141 140 return; 142 141 } … … 209 208 if (curshow == sc) return; 210 209 curshow = sc; 211 if (curshow) DrawCursor( );212 else DrawCursor( -1, -1);210 if (curshow) DrawCursor(mWGrC); 211 else DrawCursor(mWGrC, -1, -1); 213 212 return; 214 213 } … … 335 334 if (refr) Apply(true); } 336 335 else if (refr) 337 { Apply(false); if (curshow) DrawCursor( ); }336 { Apply(false); if (curshow) DrawCursor(mWGrC); } 338 337 339 338 return; … … 387 386 388 387 /* --Methode-- */ 389 void PIImage::Draw( int x0, int y0, int dx, int dy)390 { 391 PIPixmap::Draw( x0, y0, dx, dy);388 void PIImage::Draw(PIGraphicGen* g, int x0, int y0, int dx, int dy) 389 { 390 PIPixmap::Draw(g, x0, y0, dx, dy); 392 391 winovis = false; // $CHECK$ Reza A enlever si possible 17/6/96 393 392 if (curshow) … … 396 395 PosImg2W(xpav, ypav, &xc, &yc); 397 396 if ((xc >= x0) && (xc < x0+dx) && 398 (yc >= y0) && (yc < y0+dy) ) DrawCursor( xc, yc);399 } 400 401 DrawMarks( x0, x0+dx, y0, y0+dy);397 (yc >= y0) && (yc < y0+dy) ) DrawCursor(g, xc, yc); 398 } 399 400 DrawMarks(g, x0, x0+dx, y0, y0+dy); 402 401 return; 403 402 } … … 415 414 ShowTrTxW(); 416 415 Apply(false); 417 if (curshow) DrawCursor( -1,-1);416 if (curshow) DrawCursor(mWGrC, -1,-1); 418 417 return; 419 418 } … … 436 435 { 437 436 SelPointerShape(PI_ArrowPointer); 438 if (curshow) DrawCursor( );437 if (curshow) DrawCursor(mWGrC); 439 438 if (trtw) trtw->Hide(); 440 439 return; … … 450 449 if ( PosW2Img(x, y, &xpv0, &ypv0) ) { xmv0 = -1; return; } 451 450 xmv0 = x; ymv0 = y; dxmv = dymv = 0; 452 if (curshow) DrawCursor( -1,-1);453 SelGOMode(PI_GOXOR);451 if (curshow) DrawCursor(mWGrC,-1,-1); 452 mWGrC->SelGOMode(PI_GOXOR); 454 453 if (GetColMapId() == CMAP_COLRJ32) 455 SelForeground(PI_Yellow);456 else SelForeground(PI_Magenta);457 SelLine(PI_NormalLine);454 mWGrC->SelForeground(PI_Yellow); 455 else mWGrC->SelForeground(PI_Magenta); 456 mWGrC->SelLine(PI_NormalLine); 458 457 ShowTrTxW(); 459 458 return; … … 467 466 if (xmv0 < 0) return; 468 467 if ( PosW2Img(x, y, &xp, &yp) ) return; 469 DrawBox(xmv0, ymv0, dxmv, dymv);468 mWGrC->DrawBox(xmv0, ymv0, dxmv, dymv); 470 469 dxmv = x-xmv0; dymv = y-ymv0; 471 DrawBox(xmv0, ymv0, dxmv, dymv);470 mWGrC->DrawBox(xmv0, ymv0, dxmv, dymv); 472 471 if (txw || trtlb) 473 472 { … … 488 487 if (img == NULL) return; 489 488 if (xmv0 < 0) return; 490 DrawBox(xmv0, ymv0, dxmv, dymv);491 SelGOMode(PI_GOCopy);492 SelForeground(PI_White);489 mWGrC->DrawBox(xmv0, ymv0, dxmv, dymv); 490 mWGrC->SelGOMode(PI_GOCopy); 491 mWGrC->SelForeground(PI_White); 493 492 if ( PosW2Img(x, y, &xp2, &yp2) ) 494 493 PosW2Img(xmv0+dxmv, ymv0+dymv, &xp2, &yp2); … … 499 498 500 499 Apply(false); 501 if (curshow) DrawCursor( );500 if (curshow) DrawCursor(mWGrC); 502 501 if (trtw) trtw->Hide(); 503 502 return; … … 513 512 if (img == NULL) return; 514 513 if ( PosW2Img(x, y, &xp, &yp) ) { xmv0 = -1; return; } 515 if (curshow) DrawCursor( -1,-1);514 if (curshow) DrawCursor(mWGrC,-1,-1); 516 515 ShowTrTxW(); 517 516 SelPointerShape(PI_TDLRArrowPointer); … … 743 742 dy = (int) ( (float)YSize()/zm-1. ); 744 743 744 745 745 gvw->ElDelAll(); 746 gvw-> SelForeground(PI_Yellow);747 gvw-> SelLine(PI_NormalLine);746 gvw->WindowGraphic()->SelForeground(PI_Yellow); 747 gvw->WindowGraphic()->SelLine(PI_NormalLine); 748 748 gvw->ElAddRect(x,y,dx,dy); 749 749 gvw->SetColMap(GetColMapId(), false); … … 757 757 758 758 /* --Methode-- */ 759 void PIImage::DrawCursor( )759 void PIImage::DrawCursor(PIGraphicGen* g) 760 760 { 761 761 int xc, yc; 762 if (PosImg2W(xpav, ypav, &xc, &yc)) DrawCursor( -1, -1);763 else DrawCursor( xc, yc);762 if (PosImg2W(xpav, ypav, &xc, &yc)) DrawCursor(g, -1, -1); 763 else DrawCursor(g, xc, yc); 764 764 return; 765 765 } … … 768 768 769 769 /* --Methode-- */ 770 void PIImage::DrawCursor( int xc, int yc)770 void PIImage::DrawCursor(PIGraphicGen* g, int xc, int yc) 771 771 { 772 772 773 773 if ((xcurs>=0) && (ycurs>=0)) 774 PIPixmap::Draw( xcurs-CURSHSIZE, ycurs-CURSHSIZE, CURSHSIZE*2, CURSHSIZE*2);774 PIPixmap::Draw(g, xcurs-CURSHSIZE, ycurs-CURSHSIZE, CURSHSIZE*2, CURSHSIZE*2); 775 775 776 776 if ((xc >= 0) && (yc >= 0)) … … 778 778 xcurs = xc; ycurs = yc; 779 779 if (winovis) return; // $CHECK$ Reza A enlever si possible 17/6/96 780 if (zoom < 3) SelLine(PI_NormalLine);781 else SelLine(PI_ThickLine);780 if (zoom < 3) g->SelLine(PI_NormalLine); 781 else g->SelLine(PI_ThickLine); 782 782 if ( (GetColMapId() == CMAP_GREY32) || (GetColMapId() == CMAP_GREYINV32) ) 783 SelForeground(PI_Red);784 else SelForeground(PI_White);785 SelGOMode(PI_GOCopy);786 DrawLine(xcurs-CURSHSIZE, ycurs, xcurs-4, ycurs);787 DrawLine(xcurs+4, ycurs, xcurs+CURSHSIZE, ycurs);788 DrawLine(xcurs, ycurs-CURSHSIZE, xcurs, ycurs-4);789 DrawLine(xcurs, ycurs+4, xcurs, ycurs+CURSHSIZE);783 g->SelForeground(PI_Red); 784 else g->SelForeground(PI_White); 785 g->SelGOMode(PI_GOCopy); 786 g->DrawLine(xcurs-CURSHSIZE, ycurs, xcurs-4, ycurs); 787 g->DrawLine(xcurs+4, ycurs, xcurs+CURSHSIZE, ycurs); 788 g->DrawLine(xcurs, ycurs-CURSHSIZE, xcurs, ycurs-4); 789 g->DrawLine(xcurs, ycurs+4, xcurs, ycurs+CURSHSIZE); 790 790 } 791 791 else { xcurs = ycurs = -1; } … … 795 795 796 796 /* --Methode-- */ 797 void PIImage::DrawMarks( int x1, int x2, int y1, int y2)797 void PIImage::DrawMarks(PIGraphicGen* g, int x1, int x2, int y1, int y2) 798 798 { 799 799 float fz; … … 806 806 tofx += offx; tofy += offy; 807 807 fz = GetZoomF(); 808 SelGOMode(PI_GOCopy);809 SelMarker((int)(fz*mrkbsz), mrkt);808 g->SelGOMode(PI_GOCopy); 809 g->SelMarker((int)(fz*mrkbsz), mrkt); 810 810 if ( (GetColMapId() == CMAP_GREY32) || (GetColMapId() == CMAP_GREYINV32) ) 811 SelForeground(PI_Red);812 else SelForeground(PI_White);811 g->SelForeground(PI_Red); 812 else g->SelForeground(PI_White); 813 813 for(i=0; i<nbmrk; i++) 814 814 { … … 816 816 y = (int) ((ypmrk[i]-tofy)*fz); 817 817 if ((x < x1) || (x > x2) || (y < y1) || (y > y2)) continue; 818 DrawMarker(x,y);818 g->DrawMarker(x,y); 819 819 } 820 820 return; -
trunk/SophyaPI/PI/piimage.h
r37 r71 66 66 67 67 virtual void Resize(); 68 virtual void Draw( int x0, int y0, int dx, int dy);68 virtual void Draw(PIGraphicGen* g, int x0, int y0, int dx, int dy); 69 69 70 70 virtual void But1Press(int x, int y); … … 88 88 void SetGloVPixmap(); 89 89 90 void DrawCursor( );91 void DrawCursor( int xc, int yc);92 void DrawMarks( int x1, int x2, int y1, int y2);90 void DrawCursor(PIGraphicGen* g); 91 void DrawCursor(PIGraphicGen* g, int xc, int yc); 92 void DrawMarks(PIGraphicGen* g, int x1, int x2, int y1, int y2); 93 93 94 94 void ShowTrTxW(); -
trunk/SophyaPI/PI/pintuple.cc
r53 r71 71 71 72 72 /* --Methode-- */ 73 void PINTuple::Draw( double xmin, double ymin, double xmax, doubleymax)73 void PINTuple::Draw(PIGraphicUC* g, float xmin, float ymin, float xmax, float ymax) 74 74 { 75 doublexp,yp,xer,yer;75 float xp,yp,xer,yer; 76 76 char buff[128]; 77 77 int nok, nl2; … … 87 87 if ( (xp < xmin) || (xp > xmax) || (yp < ymin) || (yp > ymax) ) continue; 88 88 nok++; 89 mDrawer->DrawMarker(xp, yp);89 g->DrawMarker(xp, yp); 90 90 if ( xebK >= 0 ) { 91 91 xer = mNT->GetVal(i, xebK); 92 mDrawer->DrawLine(xp-xer, yp, xp+xer, yp);92 g->DrawLine(xp-xer, yp, xp+xer, yp); 93 93 } 94 94 if ( yebK >= 0 ) { 95 95 yer = mNT->GetVal(i, yebK); 96 mDrawer->DrawLine(xp, yp-yer, xp, yp+yer);96 g->DrawLine(xp, yp-yer, xp, yp+yer); 97 97 } 98 98 } … … 101 101 if (!MainScDrawer()) return; 102 102 sprintf(buff, "NTuple: NEntry= %d NDisp= %d", (int)mNT->NEntry(), nok); 103 mDrawWdg->DrawString(15,15,buff);103 g->BaseGraphic()->DrawString(15,15,buff); 104 104 return; 105 105 } -
trunk/SophyaPI/PI/pintuple.h
r53 r71 10 10 virtual ~PINTuple(); 11 11 12 virtual void Draw( double xmin, double ymin, double xmax, doubleymax);12 virtual void Draw(PIGraphicUC* g, float xmin, float ymin, float xmax, float ymax); 13 13 virtual void UpdateSize(); 14 14 -
trunk/SophyaPI/PI/pipixmapgen.cc
r63 r71 100 100 101 101 /* --Methode-- */ 102 void PIPixmapGen::DrawElements( )102 void PIPixmapGen::DrawElements(PIGraphicGen* g) 103 103 { 104 104 char* txt; … … 109 109 { 110 110 case PIDEL_Line : 111 DrawLine((*it).ex, (*it).ey, (*it).edx, (*it).edy );111 g->DrawLine((*it).ex, (*it).ey, (*it).edx, (*it).edy ); 112 112 break; 113 113 case PIDEL_Text : 114 114 txt = (char*) ((*it).es.c_str()); 115 DrawString((*it).ex, (*it).ey, txt );115 g->DrawString((*it).ex, (*it).ey, txt ); 116 116 break; 117 117 case PIDEL_Rect : 118 DrawBox((*it).ex, (*it).ey, (*it).edx, (*it).edy );118 g->DrawBox((*it).ex, (*it).ey, (*it).edx, (*it).edy ); 119 119 break; 120 120 case PIDEL_FRect : 121 DrawFBox((*it).ex, (*it).ey, (*it).edx, (*it).edy );121 g->DrawFBox((*it).ex, (*it).ey, (*it).edx, (*it).edy ); 122 122 break; 123 123 case PIDEL_Circ : 124 DrawCircle((*it).ex, (*it).ey, (*it).edx );124 g->DrawCircle((*it).ex, (*it).ey, (*it).edx ); 125 125 break; 126 126 case PIDEL_FCirc : 127 DrawFCircle((*it).ex, (*it).ey, (*it).edx );127 g->DrawFCircle((*it).ex, (*it).ey, (*it).edx ); 128 128 break; 129 129 default : -
trunk/SophyaPI/PI/pipixmapgen.h
r63 r71 54 54 protected: 55 55 int ElAdd(int typ, int x, int y, int dx, int dy, char* s); 56 virtual void DrawElements( );56 virtual void DrawElements(PIGraphicGen* g); 57 57 58 58 unsigned char *pixmap; -
trunk/SophyaPI/PI/pipixmapx.cc
r52 r71 61 61 62 62 /* --Methode-- */ 63 void PIPixmapX::Draw( )63 void PIPixmapX::Draw(PIGraphicGen* g) 64 64 { 65 if (mPSOut)66 { 67 if(pixmap) 68 mPSOut->Image(0, 0, (float)XSize(), (float)YSize(), nx, ny, pixmap, cmap);65 if (!pixmap) return; 66 if (!g) return; 67 if (g->kind() == PI_PSFileGraphics ) { 68 g->DrawPixmap(0, 0, pixmap, nx, ny, cmap); 69 69 /* Il faut faire quelque chose Sinon ??! */ 70 DrawElements();70 DrawElements(g); 71 71 } 72 else 73 Draw(0, 0, XSize(), YSize()); 72 else Draw(g, 0, 0, XSize(), YSize()); 74 73 } 75 74 76 75 /* --Methode-- */ 77 void PIPixmapX::Draw( int x0, int y0, int dx, int dy)76 void PIPixmapX::Draw(PIGraphicGen* g, int x0, int y0, int dx, int dy) 78 77 { 79 78 int mx, my, ox, oy; 80 79 Window xw; 81 80 Display * mdsp; 81 if (!g) return; 82 if (g->kind() == PI_PSFileGraphics ) return; 82 83 if ((myximg == NULL) || (cmap == NULL)) return; 83 84 … … 112 113 113 114 XPutImage(mdsp, xw, mygc, myximg, ox, oy, x0, y0, dx, dy); 114 DrawElements( );115 DrawElements(g); 115 116 XFlush(mdsp); 116 117 117 return; 118 118 -
trunk/SophyaPI/PI/pipixmapx.h
r9 r71 13 13 virtual void Refresh(); 14 14 virtual void Resize(); 15 virtual void Draw( );16 virtual void Draw( int x0, int y0, int dx, int dy);15 virtual void Draw(PIGraphicGen* g); 16 virtual void Draw(PIGraphicGen* g, int x0, int y0, int dx, int dy); 17 17 18 18 -
trunk/SophyaPI/PI/piscdrawwdg.cc
r63 r71 7 7 { 8 8 mBDrw = new PIDrawer; 9 SetSpan();10 9 SetLimits(-1.,1.,-1.,1.); 11 10 FreeLimits(); 12 11 xEndDrag = yEndDrag = xBegDrag = yBegDrag = 0; 13 14 Clip();15 12 16 13 padsup = false; … … 34 31 35 32 void 36 PIScDrawWdg::SetLimits( double xmin, double xmax, double ymin, doubleymax,33 PIScDrawWdg::SetLimits(float xmin, float xmax, float ymin, float ymax, 37 34 int axrl, int ayud, bool tmp) 38 35 { … … 53 50 PIScDrawWdg::Resize() 54 51 { 55 SetSpan();56 Refresh();57 } 58 59 void 60 PIScDrawWdg::SetSpan( )52 // SetSpan(); 53 // Refresh(); $CHECK$ Faut-il appeler ? Reza 08/02/98 54 } 55 56 PIGraphicUC* 57 PIScDrawWdg::SetSpan(PIGraphicGen* g) 61 58 { 62 59 int x0, y0, dx, dy; … … 65 62 dx = (int)(XSize()*0.76+0.5); 66 63 dy = (int)(YSize()*0.76+0.5); 67 mBDrw->SetDrwWdg(this, x0, y0, dx, dy); 68 return; 69 } 70 71 void 72 PIScDrawWdg::DrawAxes(int flags) 73 { 74 mBDrw->DrawAxes(flags); 64 return(mBDrw->SetDrwWdg(this, x0, y0, dx, dy, g)); 65 } 66 67 void 68 PIScDrawWdg::DrawAxes(PIGraphicUC* g, int flags) 69 { 70 mBDrw->DrawAxes(g, flags); 75 71 } 76 72 … … 99 95 for(drw = mScDrawers.begin(); drw != mScDrawers.end(); drw++) 100 96 if (d == (*drw)) { mScDrawers.erase(drw); break; } 101 d->mDrawWdg = NULL; d->mDrawer = NULL; 97 d->mDrawWdg = NULL; d->mDrawer = NULL; 102 98 } 103 99 … … 129 125 130 126 void 131 PIScDrawWdg::CallScDrawers( double xmin, double ymin, double xmax, doubleymax)127 PIScDrawWdg::CallScDrawers(PIGraphicUC* g, float xmin, float ymin, float xmax, float ymax) 132 128 { 133 129 vector<PIScDrawer*>::iterator drw; 134 130 for(drw = mScDrawers.begin(); drw != mScDrawers.end(); drw++) { 135 SaveGraphicAtt();136 (*drw)->SelGraAtt( );137 (*drw)->Draw( xmin, ymin, xmax, ymax);138 RestoreGraphicAtt();131 g->SaveGraphicAtt(); 132 (*drw)->SelGraAtt(g); 133 (*drw)->Draw(g, xmin, ymin, xmax, ymax); 134 g->RestoreGraphicAtt(); 139 135 } 140 136 } … … 162 158 163 159 void 164 PIScDrawWdg::Draw( )160 PIScDrawWdg::Draw(PIGraphicGen* g) 165 161 { 166 162 EraseWindow(); 167 DrawAxes(); 168 DrawSelf(-9.e19, -9.e19, 9.e19, 9.e19); 169 CallScDrawers(-9.e19, -9.e19, 9.e19, 9.e19); 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); 163 PIGraphicUC* guc = SetSpan(g); 164 DrawAxes(guc); 165 DrawSelf(guc, -9.e19, -9.e19, 9.e19, 9.e19); 166 CallScDrawers(guc, -9.e19, -9.e19, 9.e19, 9.e19); 167 } 168 169 void 170 PIScDrawWdg::Draw(PIGraphicGen* g, int x0, int y0, int dx, int dy) 171 { 172 float xmin,xmax,ymin,ymax; 173 PIGraphicUC* guc = SetSpan(g); 174 guc->GrC2UC(x0, y0, xmin, ymin); 175 guc->GrC2UC(x0+dx, y0+dy, xmax, ymax); 178 176 if (xmin > xmax) swap(xmin,xmax); 179 177 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() 178 DrawAxes(guc); 179 DrawSelf(guc, xmin, ymin, xmax, ymax); 180 CallScDrawers(guc, xmin, ymin, xmax, ymax); 181 } 182 183 void 184 PIScDrawWdg::DrawSelf(PIGraphicUC*) 188 185 { 189 186 return; … … 191 188 192 189 void 193 PIScDrawWdg::DrawSelf( double /*xmin*/, double /*ymin*/, double /*xmax*/, double/*ymax*/)190 PIScDrawWdg::DrawSelf(PIGraphicUC*, float /*xmin*/, float /*ymin*/, float /*xmax*/, float /*ymax*/) 194 191 { 195 192 return; … … 236 233 { 237 234 238 doubledx, dy;239 mBDrw-> Local2Sc(xp, yp, dx, dy);235 float dx, dy; 236 mBDrw->GetGraphicUC()->GrC2UC(xp, yp, dx, dy); 240 237 mPPos[0] = dx; mPPos[1] = dy; 241 238 if ((mTxw == NULL) && (mTrlb == NULL)) return(false); … … 257 254 xEndDrag = xBegDrag = x; 258 255 yEndDrag = yBegDrag = y; 259 cForCol = GetForeground();260 cGOmod = GetGOMode();256 cForCol = mWGrC->GetForeground(); 257 cGOmod = mWGrC->GetGOMode(); 261 258 cPointer = GetPointerShape(); 262 cLatt = GetLineAtt();259 cLatt = mWGrC->GetLineAtt(); 263 260 SelPointerShape(PI_CrossPointer); 264 SelForeground(PI_Magenta);265 SelGOMode(PI_GOXOR);266 SelLine(PI_ThinLine);261 mWGrC->SelForeground(PI_Magenta); 262 mWGrC->SelGOMode(PI_GOXOR); 263 mWGrC->SelLine(PI_ThinLine); 267 264 Send(Msg(), PIMsg_Active); 268 265 } … … 272 269 { 273 270 274 DrawBox(xBegDrag, yBegDrag, xEndDrag-xBegDrag, yEndDrag-yBegDrag);275 276 SelForeground(cForCol);277 SelGOMode(cGOmod);271 mWGrC->DrawBox(xBegDrag, yBegDrag, xEndDrag-xBegDrag, yEndDrag-yBegDrag); 272 273 mWGrC->SelForeground(cForCol); 274 mWGrC->SelGOMode(cGOmod); 278 275 SelPointerShape(cPointer); 279 SelLine(cLatt);276 mWGrC->SelLine(cLatt); 280 277 281 278 if (xBegDrag == xEndDrag || yBegDrag == yEndDrag) 282 279 SetLimits(xMinS, xMaxS, yMinS, yMaxS, kAxeDirSame, kAxeDirSame ); 283 280 else { 284 doublexl,yl,xh,yh;285 mBDrw-> Local2Sc(xBegDrag, yBegDrag, xl, yl);286 mBDrw-> Local2Sc(xEndDrag, yEndDrag, xh, yh);281 float xl,yl,xh,yh; 282 mBDrw->GetGraphicUC()->GrC2UC(xBegDrag, yBegDrag, xl, yl); 283 mBDrw->GetGraphicUC()->GrC2UC(xEndDrag, yEndDrag, xh, yh); 287 284 if (xl > xh) swap(xl, xh); 288 285 if (yl > yh) swap(yl, yh); … … 296 293 PIScDrawWdg::Ptr2Move(int x, int y) 297 294 { 298 DrawBox(xBegDrag, yBegDrag, xEndDrag-xBegDrag, yEndDrag-yBegDrag);295 mWGrC->DrawBox(xBegDrag, yBegDrag, xEndDrag-xBegDrag, yEndDrag-yBegDrag); 299 296 xEndDrag = x; 300 297 yEndDrag = y; 301 DrawBox(xBegDrag, yBegDrag, xEndDrag-xBegDrag, yEndDrag-yBegDrag);298 mWGrC->DrawBox(xBegDrag, yBegDrag, xEndDrag-xBegDrag, yEndDrag-yBegDrag); 302 299 } 303 300 … … 337 334 { 338 335 // Recalcule les limites, et reaffiche 339 if (!mDraw er) return;336 if (!mDrawWdg) return; 340 337 mDrawWdg->FreeLimits(); 341 338 UpdateSize(); … … 348 345 if (mDrawWdg) 349 346 mDrawWdg->RemoveScDrawer(this); 350 mDrawWdg = wdg; 351 mDrawer = wdg->BaseDrawer(); 347 mDrawWdg = wdg; mDrawer = wdg->BaseDrawer(); 352 348 UpdateSize(); 353 349 mADbW = ad; … … 360 356 PIScContDrw(PIScDrawer* d, bool ad=false); 361 357 virtual ~PIScContDrw(); 362 virtual void Draw( );363 virtual void Draw( double xmin, double ymin, double xmax, doubleymax);358 virtual void Draw(PIGraphicUC* g); 359 virtual void Draw(PIGraphicUC* g, float xmin, float ymin, float xmax, float ymax); 364 360 private: 365 361 PIScDrawer* mScDrw; … … 378 374 } 379 375 380 void PIScContDrw::Draw( )376 void PIScContDrw::Draw(PIGraphicUC* g) 381 377 { 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, doubleymax)378 mScDrw->SelGraAtt(g); 379 mScDrw->Draw(g, -9.e19, -9.e19, 9.e19, 9.e19); 380 } 381 382 void PIScContDrw::Draw(PIGraphicUC* g, float xmin, float ymin, float xmax, float ymax) 387 383 { 388 mScDrw->SelGraAtt( );389 mScDrw->Draw( xmin, ymin, xmax, ymax);384 mScDrw->SelGraAtt(g); 385 mScDrw->Draw(g, xmin, ymin, xmax, ymax); 390 386 } 391 387 … … 395 391 PIScContDrw* rd; 396 392 if (mDrawWdg) mDrawWdg->RemoveScDrawer(this); 397 mDrawWdg = NULL; 393 mDrawWdg = NULL; mDrawer = rd; 398 394 rd = new PIScContDrw(this); 399 mDrawer = rd;400 395 UpdateSize(); 401 396 return((PIDrawer*)rd); … … 430 425 431 426 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); 427 PIScDrawer::SelGraAtt(PIGraphicUC* g) 428 { 429 if (mFCol != PI_NotDefColor) g->SelForeground(mFCol); 430 if (mBCol != PI_NotDefColor) g->SelBackground(mBCol); 431 if (mLAtt != PI_NotDefLineAtt) g->SelLine(mLAtt); 438 432 if ( (mFSz != PI_NotDefFontSize) || (mFAtt != PI_NotDefFontAtt) ) 439 mDrawer->SelFont(mFSz, mFAtt);433 g->SelFont(mFSz, mFAtt); 440 434 if ( (mMrk != PI_NotDefMarker) || (mMSz >= 0) ) 441 mDrawer->SelMarker(mMSz, mMrk);435 g->SelMarker(mMSz, mMrk); 442 436 } 443 437 … … 455 449 456 450 void 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(); 464 double xStep = (xMax - xMin)/100; 465 double xOld = xMin; 466 double yOld = mFunc(xMin); 467 for (double x = xMin+xStep; x<xMax; x+=xStep) { 451 PIScFuncDrawer::Draw(PIGraphicUC* g, float /*xmin*/, float/*ymin*/, float/*xmax*/, float/*ymax*/) 452 { 453 PIGrCoord x1, x2, y1, y2; 454 g->GetGrSpace(x1, x2, y1, y2); 455 float xMax = x2; 456 float xMin = x1; 457 float yMax = y2; 458 float yMin = y1; 459 float xStep = (xMax - xMin)/100; 460 float xOld = xMin; 461 float yOld = mFunc(xMin); 462 for (float x = xMin+xStep; x<xMax; x+=xStep) { 468 463 double y = mFunc(x); 469 464 if (y>yMin && yOld>yMin && 470 465 y<yMax && yOld<yMax) 471 mDrawer->DrawLine(xOld, yOld, x, y);466 g->DrawLine(xOld, yOld, x, y); 472 467 xOld = x; 473 468 yOld = y; … … 499 494 500 495 void 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(); 508 double xStep = (xMax - xMin)/100; 509 double xOld = xMin; 510 double yOld = 0; 511 // double yOld = f->Value(&xMin, mParms); 512 for (double x = xMin+xStep; x<xMax; x+=xStep) { 513 double y = 0; // $CHECK$ 514 // double y = f->Value(&x, mParms); 496 PIScGFFDrawer::Draw(PIGraphicUC* g, float /*xmin*/, float/*ymin*/, float/*xmax*/, float/*ymax*/) 497 { 498 PIGrCoord x1, x2, y1, y2; 499 g->GetGrSpace(x1, x2, y1, y2); 500 float xMax = x2; 501 float xMin = x1; 502 float yMax = y2; 503 float yMin = y1; 504 float xStep = (xMax - xMin)/100; 505 float xOld = xMin; 506 float yOld = 0; 507 // float yOld = f->Value(&xMin, mParms); 508 for (float x = xMin+xStep; x<xMax; x+=xStep) { 509 float y = 0; // $CHECK$ 510 // float y = f->Value(&x, mParms); 515 511 if (y>yMin && yOld>yMin && 516 512 y<yMax && yOld<yMax) 517 mDrawer->DrawLine(xOld, yOld, x, y);513 g->DrawLine(xOld, yOld, x, y); 518 514 xOld = x; 519 515 yOld = y; -
trunk/SophyaPI/PI/piscdrawwdg.h
r54 r71 26 26 virtual void Resize(); 27 27 28 virtual void Draw( );29 virtual void Draw( int x0, int y0, int dx, int dy);30 virtual void DrawSelf( );31 virtual void DrawSelf( double xmin, double ymin, double xmax, doubleymax);28 virtual void Draw(PIGraphicGen* g); 29 virtual void Draw(PIGraphicGen* g, int x0, int y0, int dx, int dy); 30 virtual void DrawSelf(PIGraphicUC* g); 31 virtual void DrawSelf(PIGraphicUC* g, float xmin, float ymin, float xmax, float ymax); 32 32 33 void SetLimits( double xmin, double xmax, double ymin, doubleymax,33 void SetLimits(float xmin, float xmax, float ymin, float ymax, 34 34 int axrl=kAxeDirSame, int ayud=kAxeDirSame, bool tmp=false); 35 35 36 36 void SetAxesFlags(int flags=kAxesDflt); 37 void DrawAxes( int flags = -1);37 void DrawAxes(PIGraphicUC* g, int flags = -1); 38 38 39 39 void AddScDrawer(PIScDrawer*, bool ad=false); // Ajoute un ScDrawer … … 44 44 PIDrawer* BaseDrawer() { return mBDrw; }; 45 45 46 doubleXMin() const {return mBDrw->XMin();}47 doubleXMax() const {return mBDrw->XMax();}48 doubleYMin() const {return mBDrw->YMin();}49 doubleYMax() const {return mBDrw->YMax();}50 doubleXPPos() const { return mPPos[0]; }51 doubleYPPos() const { return mPPos[1]; }46 float XMin() const {return mBDrw->XMin();} 47 float XMax() const {return mBDrw->XMax();} 48 float YMin() const {return mBDrw->YMin();} 49 float YMax() const {return mBDrw->YMax();} 50 float XPPos() const { return mPPos[0]; } 51 float YPPos() const { return mPPos[1]; } 52 52 int LimitsFixed() const {return mBDrw->LimitsFixed();} 53 53 void FreeLimits() { mBDrw->FreeLimits(); } 54 void NoClip() { mBDrw->NoClip(); }55 void Clip() { mBDrw->NoClip(); }56 54 57 55 … … 68 66 protected: 69 67 void DeleteScDrawers(); // Ote et detruit tous les ScDrawers 70 void CallScDrawers( double xmin, double ymin, double xmax, doubleymax);71 void SetSpan();68 void CallScDrawers(PIGraphicUC* g, float xmin, float ymin, float xmax, float ymax); 69 PIGraphicUC* SetSpan(PIGraphicGen* g); 72 70 73 doublexMinS, xMaxS, yMinS, yMaxS; // Sauvegarde pour zoom74 doublemPPos[2]; // Position click souris X,Y71 float xMinS, xMaxS, yMinS, yMaxS; // Sauvegarde pour zoom 72 float mPPos[2]; // Position click souris X,Y 75 73 76 74 PIDrawer* mBDrw; … … 99 97 virtual ~PIScDrawer(); 100 98 101 virtual void Draw( double xmin, double ymin, double xmax, doubleymax) = 0;99 virtual void Draw(PIGraphicUC* g, float xmin, float ymin, float xmax, float ymax) = 0; 102 100 virtual void UpdateSize(); // Calcule et change les limites si non fixees 103 101 virtual void Refresh(); // Recalcule les limites et reaffiche … … 112 110 void SetMarkerAtt(int sz=-1, PIMarker mrk=PI_NotDefMarker); 113 111 114 void SelGraAtt( );112 void SelGraAtt(PIGraphicUC* g); 115 113 116 114 inline void SetAutoDelDataObj(bool ad=false) { mAdDO = ad; } … … 139 137 virtual ~PIScFuncDrawer(); 140 138 141 virtual void Draw( double xmin, double ymin, double xmax, doubleymax);139 virtual void Draw(PIGraphicUC* g, float xmin, float ymin, float xmax, float ymax); 142 140 protected: 143 141 FUNC mFunc; … … 150 148 virtual ~PIScGFFDrawer(); 151 149 152 virtual void Draw( double xmin, double ymin, double xmax, doubleymax);150 virtual void Draw(PIGraphicUC* g, float xmin, float ymin, float xmax, float ymax); 153 151 virtual void SetParms(double const*); 154 152 protected: -
trunk/SophyaPI/PI/pistlist.cc
r52 r71 80 80 81 81 /* --Methode-- */ 82 void PIStarList::Draw( double xmin, double ymin, double xmax, doubleymax)82 void PIStarList::Draw(PIGraphicUC* g, float xmin, float ymin, float xmax, float ymax) 83 83 { 84 84 BStar *sti; 85 85 float xp,yp,flx; 86 int sz ,ixp, iyp;86 int sz; 87 87 char buff[128]; 88 88 int nok, nl2; … … 91 91 if (!mDrawer) return; 92 92 93 mDrawer->SelFont();93 g->SelFont(); 94 94 nok = 0; nl2 = mNLev*2-1; 95 95 for (int i=0; i<mStL->NbStars(); i++) { … … 103 103 nok++; 104 104 sz = (int)((log10((double)flx/mF0))/mDLgF*(double)nl2-0.01) + mMSz0; 105 if (sz < 2) mDrawer->SelMarker(sz, PI_DotMarker);106 else mDrawer->SelMarker(sz, PI_FCircleMarker);107 mDrawer->DrawMarker((double)xp,(double)yp );105 if (sz < 2) g->SelMarker(sz, PI_DotMarker); 106 else g->SelMarker(sz, PI_FCircleMarker); 107 g->DrawMarker((double)xp,(double)yp ); 108 108 if (mDspFV) { 109 109 sprintf(buff," F=%g", flx); 110 mDrawer->Sc2Local(xp, yp, ixp, iyp); 111 mDrawer->DrawString( ixp+sz/2+1, iyp-4, buff); 110 float dx,dy; 111 g->DGrC2UC(sz, 4, dx, dy); 112 g->DrawString(xp+dx, yp-dy, buff); 112 113 } 113 114 } 114 115 116 if (!mDrawWdg) return; 115 117 if (!MainScDrawer()) return; 116 if (!mDrawWdg) return;117 118 118 119 sprintf(buff, "StarList: NbStars= %d NDisp= %d", (int)mStL->NbStars(), nok); 119 mDrawWdg->DrawString(15,15,buff);120 g->BaseGraphic()->DrawString(15,15,buff); 120 121 sprintf(buff, "FMin= %g FMax= %g Nl= %d Sz0= %d", mFmin, mFmax, mNLev, mMSz0); 121 mDrawWdg->DrawString(15,30,buff);122 g->BaseGraphic()->DrawString(15,30,buff); 122 123 123 124 } -
trunk/SophyaPI/PI/pistlist.h
r52 r71 10 10 virtual ~PIStarList(); 11 11 12 virtual void Draw( double xmin, double ymin, double xmax, doubleymax);12 virtual void Draw(PIGraphicUC* g, float xmin, float ymin, float xmax, float ymax); 13 13 virtual void UpdateSize(); 14 14 -
trunk/SophyaPI/PI/pisysdep.h
r30 r71 17 17 18 18 #define PIBWDG_H "pibwdgmac.h" 19 #define PIGRAPHIC_H "pigraphmac.h" 19 20 20 21 #define PICMAPNTV_H "picmapmac.h" … … 37 38 38 39 #define PIBWDG_H "pibwdgx.h" 40 #define PIGRAPHIC_H "pigraphx.h" 39 41 40 42 #define PICMAPNTV_H "picmapx.h" -
trunk/SophyaPI/PI/pixtbase.cc
r63 r71 179 179 (long)(((PIXtBaseWidget)wdgp)->pixtbase.objet) ); 180 180 #endif 181 181 if (!(wdgp->core.visible)) return; 182 182 if ( ((PIXtBaseWidget)wdgp)->pixtbase.objet ) 183 183 { … … 187 187 x0 = xrec.x; y0 = xrec.y; 188 188 dx = xrec.width; dy = xrec.height; 189 (((PIXtBaseWidget)wdgp)->pixtbase.objet)->Draw(x0, y0, dx, dy); 190 (((PIXtBaseWidget)wdgp)->pixtbase.objet)->CallDrawers(x0, y0, dx, dy); 189 (((PIXtBaseWidget)wdgp)->pixtbase.objet)->eXposeProcess(x0, y0, dx, dy); 191 190 } 192 191 return; -
trunk/SophyaPI/PI/psfile.h
r54 r71 25 25 #endif 26 26 #include "pisysdep.h" 27 //#include "piinclude.h" 28 29 #include PIBWDG_H// Types enumeres repris de Peida:PIFontSize...27 28 29 #include "pigraphgen.h" // Types enumeres repris de Peida:PIFontSize... 30 30 #include PICMAP_H 31 31 32 32 #include <list> 33 33 34 enum PIPaperSize { PI_A4 = 1, PI_A3 = 2, PI_A5 = 3, PI_NotDefPaperSize = 0}; 35 36 enum PIOrientation { PI_Landscape = 0, PI_Portrait = 1, PI_Auto = 2 } ; 34 37 35 38
Note:
See TracChangeset
for help on using the changeset viewer.