Changeset 6938 for trunk/MagicSoft/Mars/mbase
- Timestamp:
- 04/13/05 17:30:51 (20 years ago)
- Location:
- trunk/MagicSoft/Mars/mbase
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/MagicSoft/Mars/mbase/MStatusDisplay.cc
r6932 r6938 31 31 // (see Read and Write) or printed as a postscript file (see SaveAsPS). 32 32 // 33 // To write gif files of C-Macros use SaveAsGif() or SaveAsC().33 // To write gif files of C-Macros use SaveAsGif()/SaveAsPNG() or SaveAsC(). 34 34 // Direct printing to the default printer (via lpr) can be done by 35 35 // PrintToLpr(). … … 193 193 filemenu->AddSeparator(); 194 194 filemenu->AddEntry("Save status.&ps", kFileSaveAsPS); 195 filemenu->AddEntry("Save status.&png", kFileSaveAsPNG); 195 196 filemenu->AddEntry("Save status.&gif", kFileSaveAsGIF); 197 filemenu->AddEntry("Save status.&jpg", kFileSaveAsJPG); 198 filemenu->AddEntry("Save status.&xpm", kFileSaveAsXPM); 196 199 filemenu->AddEntry("Save status.&C", kFileSaveAsC); 197 200 filemenu->AddEntry("Save status.&root", kFileSaveAsRoot); … … 217 220 tabmenu->AddSeparator(); 218 221 tabmenu->AddEntry("Save tab-i.&ps", kTabSaveAsPS); 222 tabmenu->AddEntry("Save tab-i.&png", kTabSaveAsPNG); 219 223 tabmenu->AddEntry("Save tab-i.&gif", kTabSaveAsGIF); 224 tabmenu->AddEntry("Save tab-i.&jpg", kTabSaveAsJPG); 225 tabmenu->AddEntry("Save tab-i.&xpm", kTabSaveAsXPM); 220 226 tabmenu->AddEntry("Save tab-i.&C", kTabSaveAsC); 221 227 tabmenu->AddEntry("Save tab-i.&root", kTabSaveAsRoot); … … 1198 1204 return kTRUE; 1199 1205 1206 case kFileSaveAsPNG: 1207 SaveAsPNG(); 1208 return kTRUE; 1209 1200 1210 case kFileSaveAsGIF: 1201 1211 SaveAsGIF(); 1202 1212 return kTRUE; 1203 1213 1214 case kFileSaveAsXPM: 1215 SaveAsXPM(); 1216 return kTRUE; 1217 1218 case kFileSaveAsJPG: 1219 SaveAsJPG(); 1220 return kTRUE; 1221 1204 1222 case kFileSaveAsC: 1205 1223 SaveAsC(); … … 1222 1240 return kTRUE; 1223 1241 1242 case kTabSaveAsPNG: 1243 SaveAsPNG(fTab->GetCurrent()); 1244 return kTRUE; 1245 1224 1246 case kTabSaveAsGIF: 1225 1247 SaveAsGIF(fTab->GetCurrent()); 1248 return kTRUE; 1249 1250 case kTabSaveAsXPM: 1251 SaveAsXPM(fTab->GetCurrent()); 1252 return kTRUE; 1253 1254 case kTabSaveAsJPG: 1255 SaveAsJPG(fTab->GetCurrent()); 1226 1256 return kTRUE; 1227 1257 … … 1869 1899 } 1870 1900 1871 void MStatusDisplay::AddExtension(TString &name, const TString &ext, Int_t num) const 1901 // -------------------------------------------------------------------------- 1902 // 1903 // If the filename name doesn't end with ext, ext is added to the end. 1904 // If name.IsNull() "status" is assumed and the a number (>0) is added 1905 // as "status-6". 1906 // The extension is returned. 1907 // 1908 const TString &MStatusDisplay::AddExtension(TString &name, const TString &ext, Int_t num) const 1872 1909 { 1873 1910 if (name.IsNull()) … … 1882 1919 1883 1920 if (name.EndsWith("."+ext)) 1884 return ;1921 return ext; 1885 1922 1886 1923 name += "."; 1887 1924 name += ext; 1925 1926 return ext; 1888 1927 } 1889 1928 … … 2170 2209 } 2171 2210 2172 Bool_t MStatusDisplay::SaveAs GIF(Int_t num, TString name)2211 Bool_t MStatusDisplay::SaveAsImage(Int_t num, TString name, TImage::EImageFileTypes type) 2173 2212 { 2174 2213 if (gROOT->IsBatch()) 2175 2214 { 2176 *fLog << warn << "Sorry, writing gif-files is not available in batch mode." << endl; 2215 *fLog << warn << "Sorry, writing image-files is not available in batch mode." << endl; 2216 //*fLog << warn << "Sorry, writing gif-files is not available in batch mode." << endl; 2177 2217 return 0; 2178 2218 } 2179 SetStatusLine1("Writing GIF file..."); 2219 //SetStatusLine1("Writing GIF file..."); 2220 SetStatusLine1("Writing image file... <please be patient>"); 2180 2221 SetStatusLine2(""); 2181 2222 … … 2186 2227 } 2187 2228 2188 AddExtension(name, "gif", num); 2229 TString ext; 2230 switch (type) 2231 { 2232 case TImage::kXpm: 2233 case TImage::kZCompressedXpm: 2234 ext = AddExtension(name, "xpm", num); 2235 break; 2236 // case TImage::kGZCompressedXpm: 2237 // ext = AddExtension(name, "xpm.gz", num); 2238 // break; 2239 case TImage::kPng: 2240 ext = AddExtension(name, "png", num); 2241 break; 2242 case TImage::kJpeg: 2243 ext = AddExtension(name, "jpg", num); 2244 break; 2245 // case TImage::kXcf: 2246 // ext = AddExtension(name, "xcf", num); 2247 // break; 2248 // case TImage::kPpm: 2249 // ext = AddExtension(name, "ppm", num); 2250 // break; 2251 // case TImage::kPnm: 2252 // ext = AddExtension(name, "pnm", num); 2253 // break; 2254 // case TImage::kBmp: 2255 // ext = AddExtension(name, "bmp", num); 2256 // break; 2257 // case TImage::kIco: 2258 // ext = AddExtension(name, "ico", num); 2259 // break; 2260 // case TImage::kCur: 2261 // ext = AddExtension(name, "cur", num); 2262 // break; 2263 case TImage::kGif: 2264 ext = AddExtension(name, "gif", num); 2265 break; 2266 // case TImage::kTiff: 2267 // ext = AddExtension(name, "tif", num); 2268 // break; 2269 // case TImage::kXbm: 2270 // ext = AddExtension(name, "xbm", num); 2271 // break; 2272 // case TImage::kFits: 2273 // ext = AddExtension(name, "fits", num); 2274 // break; 2275 // case TImage::kTga: 2276 // ext = AddExtension(name, "tga", num); 2277 // break; 2278 // case TImage::kXml: 2279 // ext = AddExtension(name, "xml", num); 2280 // break; 2281 default: 2282 *fLog << warn << "Sorry, unknown or unsupported file type..." << endl; 2283 return 0; 2284 } 2189 2285 2190 2286 if (num<0) 2191 *fLog << inf << "Writing gif-Files..." << endl;2287 *fLog << inf << "Writing " << ext << "-Files..." << endl; 2192 2288 2193 2289 TPad *padsav = (TPad*)gPad; … … 2239 2335 2240 2336 c->Draw(); 2241 c->SaveAs(writename); 2242 /* 2243 n->Draw(); 2244 n->SaveAs(writename); 2245 delete n; 2246 */ 2337 if (type==TImage::kGif) 2338 c->SaveAs(writename); // FIXME: Seems not to work well in TImage! (root 3.10/02) 2339 else 2340 { 2341 TImage *img = TImage::Create(); 2342 img->FromPad(c); 2343 img->WriteImage(writename, type); 2344 delete img; 2345 } 2247 2346 2248 2347 if (num<0) -
trunk/MagicSoft/Mars/mbase/MStatusDisplay.h
r6932 r6938 12 12 #ifndef ROOT_TTimer 13 13 #include <TTimer.h> 14 #endif 15 16 #ifndef ROOT_TImage 17 #include <TImage.h> 14 18 #endif 15 19 … … 38 42 // kFile 39 43 kFileBrowser, kFileCanvas, kFileOpen, kFileSave, kFileSaveAs, kFileSaveAsPS, 40 kFileSaveAsRoot, kFileSaveAsGIF, kFileSaveAsC, kFilePrint, 41 kFilePrinterName, kFileClose, kFileExit, kFileReset, 44 kFileSaveAsRoot, kFileSaveAsPNG, kFileSaveAsGIF, kFileSaveAsJPG, 45 kFileSaveAsXPM, kFileSaveAsC, kFilePrint, kFilePrinterName, 46 kFileClose, kFileExit, kFileReset, 42 47 // kLoop 43 48 kLoopNone, kLoopStop, 44 49 // kTab 45 kTabSave, kTabSaveAs, kTabSaveAsPS, kTabSaveAsRoot, kTabSaveAsGIF, 46 kTabSaveAsC, kTabPrint, kTabNext, kTabPrevious, kTabRemove, 50 kTabSave, kTabSaveAs, kTabSaveAsPS, kTabSaveAsRoot, kTabSaveAsPNG, 51 kTabSaveAsGIF, kTabSaveAsJPG, kTabSaveAsXPM, kTabSaveAsC, 52 kTabPrint, kTabNext, kTabPrevious, kTabRemove, 47 53 // kSize 48 54 kSize640, kSize768, kSize800, kSize960, kSize1024, kSize1152, … … 124 130 Bool_t Display(const TObjArray &list, const char *tab=0); 125 131 126 voidAddExtension(TString &name, const TString &ext, Int_t num) const;132 const TString &AddExtension(TString &name, const TString &ext, Int_t num) const; 127 133 128 134 void UpdatePSHeader(const TString &name) const; … … 132 138 133 139 TRootEmbeddedCanvas *GetEmbeddedCanvas(TGCompositeFrame *cf) const; 140 141 Bool_t SaveAsImage(Int_t num, TString name, TImage::EImageFileTypes type); 134 142 135 143 public: … … 187 195 188 196 Int_t SaveAsPS(TString name="", const TString addon="") { return SaveAsPS(-1, name, addon); } 197 Bool_t SaveAsPNG(TString name="") { return SaveAsPNG(-1, name); } 189 198 Bool_t SaveAsGIF(TString name="") { return SaveAsGIF(-1, name); } 199 Bool_t SaveAsXPM(TString name="") { return SaveAsXPM(-1, name); } 200 Bool_t SaveAsJPG(TString name="") { return SaveAsJPG(-1, name); } 190 201 Bool_t SaveAsC(TString name="") { return SaveAsC(-1, name); } 191 202 Int_t SaveAsRoot(TString name="") { return SaveAsRoot(-1, name); } … … 193 204 194 205 Int_t SaveAsPS(Int_t num, TString name="", const TString addon=""); 195 Bool_t SaveAsGIF(Int_t num, TString name=""); 206 Bool_t SaveAsPNG(Int_t num, TString name="") { return SaveAsImage(num, name, TImage::kPng); } 207 Bool_t SaveAsGIF(Int_t num, TString name="") { return SaveAsImage(num, name, TImage::kGif); } 208 Bool_t SaveAsXPM(Int_t num, TString name="") { return SaveAsImage(num, name, TImage::kXpm); } 209 Bool_t SaveAsJPG(Int_t num, TString name="") { return SaveAsImage(num, name, TImage::kJpeg); } 196 210 Bool_t SaveAsC(Int_t num, TString name=""); 197 211 Int_t SaveAsRoot(Int_t num, TString name="");
Note:
See TracChangeset
for help on using the changeset viewer.