Changeset 7827 for trunk/MagicSoft
- Timestamp:
- 07/31/06 12:48:48 (18 years ago)
- Location:
- trunk/MagicSoft/Mars
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/MagicSoft/Mars/Changelog
r7826 r7827 18 18 19 19 -*-*- END OF LINE -*-*- 20 2006/07/31 Thomas Bretz 21 22 * showplot.cc: 23 - added new options to write bmp and xml files 24 - added new options for the display size 25 26 * mbase/MStatusDisplay.[h,cc]: 27 - changed the constructor to allow starting with a different size 28 - added new member functions to change the display or canvas size 29 - fixed setting of sizes 30 31 32 20 33 2006/07/30 Thomas Bretz 21 34 -
trunk/MagicSoft/Mars/NEWS
r7818 r7827 8 8 - general: Fixed some warnings thrown if more warnings are switched 9 9 on in the compiler 10 11 - showplot: 12 + batch mode creating of image files now works with root 5.12/00 13 + added support for writing bmp (though it never produces 14 bmp which can be read by programs like xv or gimp) 15 + added support for xml 10 16 11 17 - merpp: didn't recognize files with the extension .raw.gz - fixed. -
trunk/MagicSoft/Mars/mbase/MStatusDisplay.cc
r7826 r7827 339 339 sizemenu->AddEntry("Fit to 1400x1050", kSize1400); 340 340 sizemenu->AddEntry("Fit to 1600x1200", kSize1600); 341 sizemenu->AddEntry("Fit to &Desktop", kSizeOptimum); 341 342 sizemenu->Associate(this); 342 343 … … 672 673 // always by deleting the corresponding object. 673 674 // 675 // You can give either width or height. (Set the value not given to -1) 676 // The other value is calculated accordingly. If width and height are 677 // given height is ignored. If width=height=0 an optimum size from 678 // the desktop size is calculated. 679 // 674 680 // Update time default: 10s 675 681 // 676 MStatusDisplay::MStatusDisplay( Long_t t)682 MStatusDisplay::MStatusDisplay(Int_t w, Int_t h, Long_t t) 677 683 : TGMainFrame(NULL, 1, 1), fName("MStatusDisplay"), fLog(&gLog), fTab(NULL), fTimer(this, t, kTRUE), fStatus(kLoopNone), fLogIdx(-1), fLogTimer(this, 250, kTRUE), fLogBox(NULL), fIsLocked(0) 678 684 { … … 714 720 // In newer root versions gClient!=NULL in batch mode! 715 721 if (!gClient || !gClient->GetRoot() || gROOT->IsBatch()) // BATCH MODE 722 { 723 Resize(644, 484); 716 724 return; 725 } 717 726 718 727 AddMenuBar(); … … 725 734 // set the smallest and biggest size of the Main frame 726 735 // and move it to its appearance position 727 SetWMSizeHints(572, 480, 2048, 1536, 1, 1); 728 MoveResize(rand()%100+572, rand()%100+480, 572, 480); 736 SetWMSizeHints(566, 476, 2048, 1536, 1, 1); 737 MoveResize(rand()%100+566, rand()%100+476, 566, 476); 738 if (h>0) 739 SetDisplayHeight(h); 740 if (w>0) 741 SetDisplayWidth(w); 742 if (w==0 && h==0) 743 SetOptimumSize(); 729 744 730 745 // … … 997 1012 if (gROOT->IsBatch()) 998 1013 { 999 TCanvas *c = new TCanvas(name, name); 1014 // 4 = 2*default border width of a canvas 1015 const UInt_t cw = GetWidth(); 1016 const UInt_t ch = 2*cw/3 + 25; // 25: Menu, etc 1017 1018 TCanvas *c = new TCanvas(name, name, -cw, ch); 1000 1019 fBatch->Add(c); 1001 1020 return *c; … … 1617 1636 return kTRUE; 1618 1637 1619 case kSize640: 1620 Resize(572, 480);1638 case kSize640: 1639 SetDisplaySize(640, 480); 1621 1640 return kTRUE; 1622 1641 case kSize768: 1623 Resize(714, 576);1642 SetDisplaySize(768, 576); 1624 1643 return kTRUE; 1625 1644 case kSize800: 1626 Resize(750, 600);1645 SetDisplaySize(800, 600); 1627 1646 return kTRUE; 1628 1647 case kSize960: 1629 Resize(900, 700);1648 SetDisplaySize(960, 720); 1630 1649 return kTRUE; 1631 1650 case kSize1024: 1632 Resize(1000, 768);1651 SetDisplaySize(1024, 768); 1633 1652 return kTRUE; 1634 1653 case kSize1152: 1635 Resize(1147, 864);1654 SetDisplaySize(1152, 864); 1636 1655 return kTRUE; 1637 1656 case kSize1280: 1638 Resize(1321, 980);1657 SetDisplaySize(1280, 1024); 1639 1658 return kTRUE; 1640 1659 case kSize1400: 1641 Resize(1426, 1050);1660 SetDisplaySize(1400, 1050); 1642 1661 return kTRUE; 1643 1662 case kSize1600: 1644 Resize(1550, 1400); 1663 SetDisplaySize(1600, 1200); 1664 return kTRUE; 1665 case kSizeOptimum: 1666 SetOptimumSize(); 1645 1667 return kTRUE; 1646 1668 … … 2940 2962 } 2941 2963 2964 // -------------------------------------------------------------------------- 2965 // 2966 // Change width of display. The height is calculated accordingly. 2967 // 2968 void MStatusDisplay::SetDisplayWidth(UInt_t dw) 2969 { 2970 if (gROOT->IsBatch()) 2971 { 2972 SetCanvasWidth(dw); 2973 return; 2974 } 2975 2976 // 4 == 2*default border with of canvas 2977 dw -= 4; 2978 2979 // Difference between canvas size and display size 2980 const UInt_t cw = GetWidth() -fTab->GetWidth(); 2981 const UInt_t ch = GetHeight()-fTab->GetHeight()+fTab->GetTabHeight(); 2982 2983 const UInt_t dh = TMath::Nint((dw - cw)/1.5 + ch); 2984 2985 Resize(dw, dh); // Set display size 2986 } 2987 2988 // -------------------------------------------------------------------------- 2989 // 2990 // Change height of display. The width is calculated accordingly. 2991 // 2992 void MStatusDisplay::SetDisplayHeight(UInt_t dh) 2993 { 2994 if (gROOT->IsBatch()) 2995 { 2996 SetCanvasHeight(dh); 2997 return; 2998 } 2999 3000 // 4 == 2*default border with of canvas 3001 dh -= 4; 3002 3003 // Difference between canvas size and display size 3004 const UInt_t cw = GetWidth() -fTab->GetWidth(); 3005 const UInt_t ch = GetHeight()-fTab->GetHeight()+fTab->GetTabHeight(); 3006 3007 const UInt_t dw = TMath::Nint((dh - ch)*1.5 + cw); 3008 3009 Resize(dw, dh); // Set display size 3010 } 3011 3012 // -------------------------------------------------------------------------- 3013 // 3014 // Change width of canvas. The height is calculated accordingly. 3015 // 3016 void MStatusDisplay::SetCanvasWidth(UInt_t w) 3017 { 3018 // 4 == 2*default border with of canvas 3019 w += 4; 3020 3021 if (gROOT->IsBatch()) 3022 { 3023 Resize(w, 3*w/2); 3024 return; 3025 } 3026 3027 // Difference between canvas size and display size 3028 const UInt_t cw = GetWidth() -fTab->GetWidth(); 3029 const UInt_t ch = GetHeight()-fTab->GetHeight()+fTab->GetTabHeight(); 3030 3031 const UInt_t h = TMath::Nint(w/1.5 + ch); 3032 3033 Resize(w + cw, h); // Set display size 3034 } 3035 3036 // -------------------------------------------------------------------------- 3037 // 3038 // Change height of canvas. The width is calculated accordingly. 3039 // 3040 void MStatusDisplay::SetCanvasHeight(UInt_t h) 3041 { 3042 // 4 == 2*default border with of canvas 3043 h += 4; 3044 3045 if (gROOT->IsBatch()) 3046 { 3047 Resize(2*h/3, h); 3048 return; 3049 } 3050 3051 // Difference between canvas size and display size 3052 const UInt_t cw = GetWidth() -fTab->GetWidth(); 3053 const UInt_t ch = GetHeight()-fTab->GetHeight()+fTab->GetTabHeight(); 3054 3055 // 4 == 2*default border with of canvas 3056 const UInt_t dw = TMath::Nint((h+4)*1.5 + cw); 3057 3058 Resize(dw, h + ch); // Set display size 3059 } 3060 3061 // -------------------------------------------------------------------------- 3062 // 3063 // Calculate width and height of the display such that it fits into the 3064 // defined box. 3065 // 3066 void MStatusDisplay::SetDisplaySize(UInt_t w, UInt_t h) 3067 { 3068 if (gROOT->IsBatch()) 3069 return; 3070 3071 SetDisplayHeight(h); 3072 3073 if (GetWidth()>w) 3074 SetDisplayWidth(w); 3075 } 3076 3077 // -------------------------------------------------------------------------- 3078 // 3079 // Calculate an optimum size for the display from the desktop size 3080 // 3081 void MStatusDisplay::SetOptimumSize() 3082 { 3083 if (gROOT->IsBatch()) 3084 return; 3085 3086 const UInt_t w = TMath::Nint(0.95*gClient->GetDisplayWidth()); 3087 const UInt_t h = TMath::Nint(0.95*gClient->GetDisplayHeight()); 3088 3089 SetDisplaySize(w, h); 3090 } 3091 3092 2942 3093 Bool_t MStatusDisplay::HandleConfigureNotify(Event_t *evt) 2943 3094 { … … 2951 3102 UInt_t h = evt->fHeight; 2952 3103 2953 const Bool_t wchanged = w!=GetWidth() ;2954 const Bool_t hchanged = h!=GetHeight() ;3104 const Bool_t wchanged = w!=GetWidth()-fTab->GetWidth(); 3105 const Bool_t hchanged = h!=GetHeight()-fTab->GetHeight(); 2955 3106 2956 3107 if (!wchanged && !hchanged) -
trunk/MagicSoft/Mars/mbase/MStatusDisplay.h
r7825 r7827 59 59 // kSize 60 60 kSize640, kSize768, kSize800, kSize960, kSize1024, kSize1152, 61 kSize1280, kSize1400, kSize1600, 61 kSize1280, kSize1400, kSize1600, kSizeOptimum, 62 62 // kLog 63 63 kLogCopy, kLogClear, kLogSelect, kLogFind, kLogSave, kLogAppend, … … 157 157 158 158 public: 159 MStatusDisplay( Long_t t=1000);159 MStatusDisplay(Int_t w=-1, Int_t h=-1, Long_t t=1000); 160 160 virtual ~MStatusDisplay(); 161 161 … … 246 246 Bool_t SaveLogAsPS(const char *name) const; 247 247 248 // Size options 249 void SetCanvasWidth(UInt_t w); 250 void SetCanvasHeight(UInt_t h); 251 252 void SetDisplayWidth(UInt_t w); 253 void SetDisplayHeight(UInt_t h); 254 255 void SetOptimumSize(); 256 void SetDisplaySize(UInt_t w, UInt_t h); 257 248 258 Int_t SaveAs(Int_t num=-1); 249 259 Int_t Open(TString fname, const char *name="MStatusDisplay"); -
trunk/MagicSoft/Mars/showplot.cc
r7573 r7827 56 56 gLog << " --save-as-xpm[=filename] Save plots as xpm files" << endl; 57 57 gLog << " --save-as-png[=filename] Save plots as png files" << endl; 58 gLog << " --save-as-bmp[=filename] Save plots as bmp files" << endl; 59 gLog << " --save-as-xml[=filename] Save plots as xml files" << endl << endl; 60 gLog << " Size options:" << endl; 61 gLog << " --display-width=w Set width of display window to w" << endl; 62 gLog << " --display-height=h Set height of display window to h" << endl; 63 gLog << " --canvas-width=w Set width of canvas' contained by display to w" << endl; 64 gLog << " --canvas-height=h Set height of canvas' contained by display to h" << endl; 65 gLog << " --auto-size Determin optimum size (not available in batch mode)" << endl; 58 66 gLog << endl; 59 67 gLog << " --version, -V Show startup message with version number" << endl; … … 64 72 gLog << " MStatusArrays are typically written by programs showing data" << endl; 65 73 gLog << " check plots, like callisto." << endl << endl; 74 gLog << " Only the last size option given is taken into account." << endl; 75 gLog << " Width or height is set according to height or width." << endl << endl; 76 gLog << " In batch mode display width and height and auto-size is ignored." << endl; 66 77 gLog << "Printing:" << endl; 67 78 gLog << " For more details see MStatusDisplay::PrintPS" << endl << endl; … … 110 121 const Bool_t kSaveAsXpm = arg.HasOnlyAndRemove("--save-as-xpm") || arg.Has("--save-as-xpm="); 111 122 const Bool_t kSaveAsPng = arg.HasOnlyAndRemove("--save-as-png") || arg.Has("--save-as-png="); 123 const Bool_t kSaveAsBmp = arg.HasOnlyAndRemove("--save-as-bmp") || arg.Has("--save-as-bmp="); 124 const Bool_t kSaveAsXml = arg.HasOnlyAndRemove("--save-as-xml") || arg.Has("--save-as-xml="); 112 125 const Bool_t kSaveAsRoot = arg.HasOnlyAndRemove("--save-as-root") || arg.Has("--save-as-root="); 113 126 const Bool_t kSaveAsC = arg.HasOnlyAndRemove("--save-as-C") || arg.Has("--save-as-C="); 127 128 const Int_t kCanvasWidth = arg.GetIntAndRemove("--canvas-width=", -1); 129 const Int_t kCanvasHeight = arg.GetIntAndRemove("--canvas-height=", -1); 130 131 const Bool_t kAutoSize = arg.HasOnlyAndRemove("--auto-size"); 132 Int_t kDisplayWidth = arg.GetIntAndRemove("--display-width=", -1); 133 Int_t kDisplayHeight = arg.GetIntAndRemove("--display-height=", -1); 134 if (kAutoSize) 135 { 136 kDisplayWidth=0; 137 kDisplayHeight=0; 138 } 114 139 115 140 TString kNamePrint = arg.GetStringAndRemove("--print="); … … 123 148 TString kNameXpm = arg.GetStringAndRemove("--save-as-xpm="); 124 149 TString kNamePng = arg.GetStringAndRemove("--save-as-png="); 150 TString kNameBmp = arg.GetStringAndRemove("--save-as-bmp="); 151 TString kNameXml = arg.GetStringAndRemove("--save-as-xml="); 125 152 TString kNameRoot = arg.GetStringAndRemove("--save-as-root="); 126 153 TString kNameC = arg.GetStringAndRemove("--save-as-C="); … … 203 230 if (kNamePng.IsNull() && kSaveAsPng) 204 231 kNamePng = kInput; 232 if (kNameBmp.IsNull() && kSaveAsBmp) 233 kNameBmp = kInput; 234 if (kNameXml.IsNull() && kSaveAsXml) 235 kNameXml = kInput; 205 236 if (kNameRoot.IsNull() && kSaveAsRoot) 206 237 kNameRoot = kInput; … … 211 242 // Update frequency by default = 1Hz 212 243 // 213 MStatusDisplay *d = new MStatusDisplay ;244 MStatusDisplay *d = new MStatusDisplay(kDisplayWidth, kDisplayHeight); 214 245 215 246 // From now on each 'Exit' means: Terminate the application 216 247 d->SetTitle(kInput); 217 248 d->SetWindowName(kInput); 249 250 if (kCanvasHeight>0) 251 d->SetCanvasHeight(kCanvasHeight); 252 if (kCanvasWidth>0) 253 d->SetCanvasWidth(kCanvasWidth); 218 254 219 255 d->Open(kInput); … … 235 271 if (kSaveAsPng) 236 272 d->SaveAsPNG(kTab, kNamePng); 273 if (kSaveAsBmp) 274 d->SaveAsBMP(kTab, kNameBmp); 275 if (kSaveAsXml) 276 d->SaveAsXML(kTab, kNameXml); 237 277 if (kSaveAsRoot) 238 278 d->SaveAsRoot(kTab, kNameRoot);
Note:
See TracChangeset
for help on using the changeset viewer.