Changeset 7827 for trunk/MagicSoft


Ignore:
Timestamp:
07/31/06 12:48:48 (18 years ago)
Author:
tbretz
Message:
*** empty log message ***
Location:
trunk/MagicSoft/Mars
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/MagicSoft/Mars/Changelog

    r7826 r7827  
    1818
    1919                                                 -*-*- 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
    2033 2006/07/30 Thomas Bretz
    2134
  • trunk/MagicSoft/Mars/NEWS

    r7818 r7827  
    88   - general: Fixed some warnings thrown if more warnings are switched
    99     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
    1016
    1117   - merpp: didn't recognize files with the extension .raw.gz - fixed.
  • trunk/MagicSoft/Mars/mbase/MStatusDisplay.cc

    r7826 r7827  
    339339    sizemenu->AddEntry("Fit to 1400x1050",  kSize1400);
    340340    sizemenu->AddEntry("Fit to 1600x1200",  kSize1600);
     341    sizemenu->AddEntry("Fit to &Desktop",   kSizeOptimum);
    341342    sizemenu->Associate(this);
    342343
     
    672673//   always by deleting the corresponding object.
    673674//
     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//
    674680// Update time default: 10s
    675681//
    676 MStatusDisplay::MStatusDisplay(Long_t t)
     682MStatusDisplay::MStatusDisplay(Int_t w, Int_t h, Long_t t)
    677683: 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)
    678684{
     
    714720    // In newer root versions gClient!=NULL in batch mode!
    715721    if (!gClient || !gClient->GetRoot() || gROOT->IsBatch()) // BATCH MODE
     722    {
     723        Resize(644, 484);
    716724        return;
     725    }
    717726
    718727    AddMenuBar();
     
    725734    // set the smallest and biggest size of the Main frame
    726735    // 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();
    729744
    730745    //
     
    9971012    if (gROOT->IsBatch())
    9981013    {
    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);
    10001019        fBatch->Add(c);
    10011020        return *c;
     
    16171636        return kTRUE;
    16181637
    1619     case kSize640: 
    1620         Resize(572, 480);
     1638    case kSize640:
     1639        SetDisplaySize(640, 480);
    16211640        return kTRUE;
    16221641    case kSize768: 
    1623         Resize(714, 576);
     1642        SetDisplaySize(768, 576);
    16241643        return kTRUE;
    16251644    case kSize800: 
    1626         Resize(750, 600);
     1645        SetDisplaySize(800, 600);
    16271646        return kTRUE;
    16281647    case kSize960: 
    1629         Resize(900, 700);
     1648        SetDisplaySize(960, 720);
    16301649        return kTRUE;
    16311650    case kSize1024:
    1632         Resize(1000, 768);
     1651        SetDisplaySize(1024, 768);
    16331652        return kTRUE;
    16341653    case kSize1152:
    1635         Resize(1147, 864);
     1654        SetDisplaySize(1152, 864);
    16361655        return kTRUE;
    16371656    case kSize1280:
    1638         Resize(1321, 980);
     1657        SetDisplaySize(1280, 1024);
    16391658        return kTRUE;
    16401659    case kSize1400:
    1641         Resize(1426, 1050);
     1660        SetDisplaySize(1400, 1050);
    16421661        return kTRUE;
    16431662    case kSize1600:
    1644         Resize(1550, 1400);
     1663        SetDisplaySize(1600, 1200);
     1664        return kTRUE;
     1665    case kSizeOptimum:
     1666        SetOptimumSize();
    16451667        return kTRUE;
    16461668
     
    29402962}
    29412963
     2964// --------------------------------------------------------------------------
     2965//
     2966//  Change width of display. The height is calculated accordingly.
     2967//
     2968void 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//
     2992void 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//
     3016void 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//
     3040void 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//
     3066void 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//
     3081void 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
    29423093Bool_t MStatusDisplay::HandleConfigureNotify(Event_t *evt)
    29433094{
     
    29513102    UInt_t h = evt->fHeight;
    29523103
    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();
    29553106
    29563107    if (!wchanged && !hchanged)
  • trunk/MagicSoft/Mars/mbase/MStatusDisplay.h

    r7825 r7827  
    5959        // kSize
    6060        kSize640, kSize768, kSize800, kSize960, kSize1024, kSize1152,
    61         kSize1280, kSize1400, kSize1600,
     61        kSize1280, kSize1400, kSize1600, kSizeOptimum,
    6262        // kLog
    6363        kLogCopy, kLogClear, kLogSelect, kLogFind, kLogSave, kLogAppend,
     
    157157
    158158public:
    159      MStatusDisplay(Long_t t=1000);
     159     MStatusDisplay(Int_t w=-1, Int_t h=-1, Long_t t=1000);
    160160     virtual ~MStatusDisplay();
    161161
     
    246246     Bool_t SaveLogAsPS(const char *name) const;
    247247
     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
    248258     Int_t  SaveAs(Int_t num=-1);
    249259     Int_t  Open(TString fname, const char *name="MStatusDisplay");
  • trunk/MagicSoft/Mars/showplot.cc

    r7573 r7827  
    5656    gLog << "   --save-as-xpm[=filename]  Save plots as xpm files" << endl;
    5757    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;
    5866    gLog << endl;
    5967    gLog << "   --version, -V             Show startup message with version number" << endl;
     
    6472    gLog << " MStatusArrays are typically written by programs showing data" << endl;
    6573    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;
    6677    gLog << "Printing:" << endl;
    6778    gLog << " For more details see MStatusDisplay::PrintPS" << endl << endl;
     
    110121    const Bool_t kSaveAsXpm  = arg.HasOnlyAndRemove("--save-as-xpm")  || arg.Has("--save-as-xpm=");
    111122    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=");
    112125    const Bool_t kSaveAsRoot = arg.HasOnlyAndRemove("--save-as-root") || arg.Has("--save-as-root=");
    113126    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    }
    114139
    115140    TString kNamePrint = arg.GetStringAndRemove("--print=");
     
    123148    TString kNameXpm   = arg.GetStringAndRemove("--save-as-xpm=");
    124149    TString kNamePng   = arg.GetStringAndRemove("--save-as-png=");
     150    TString kNameBmp   = arg.GetStringAndRemove("--save-as-bmp=");
     151    TString kNameXml   = arg.GetStringAndRemove("--save-as-xml=");
    125152    TString kNameRoot  = arg.GetStringAndRemove("--save-as-root=");
    126153    TString kNameC     = arg.GetStringAndRemove("--save-as-C=");
     
    203230    if (kNamePng.IsNull()  && kSaveAsPng)
    204231        kNamePng = kInput;
     232    if (kNameBmp.IsNull()  && kSaveAsBmp)
     233        kNameBmp = kInput;
     234    if (kNameXml.IsNull()  && kSaveAsXml)
     235        kNameXml = kInput;
    205236    if (kNameRoot.IsNull() && kSaveAsRoot)
    206237        kNameRoot = kInput;
     
    211242    // Update frequency by default = 1Hz
    212243    //
    213     MStatusDisplay *d = new MStatusDisplay;
     244    MStatusDisplay *d = new MStatusDisplay(kDisplayWidth, kDisplayHeight);
    214245
    215246    // From now on each 'Exit' means: Terminate the application
    216247    d->SetTitle(kInput);
    217248    d->SetWindowName(kInput);
     249
     250    if (kCanvasHeight>0)
     251        d->SetCanvasHeight(kCanvasHeight);
     252    if (kCanvasWidth>0)
     253        d->SetCanvasWidth(kCanvasWidth);
    218254
    219255    d->Open(kInput);
     
    235271    if (kSaveAsPng)
    236272        d->SaveAsPNG(kTab,  kNamePng);
     273    if (kSaveAsBmp)
     274        d->SaveAsBMP(kTab,  kNameBmp);
     275    if (kSaveAsXml)
     276        d->SaveAsXML(kTab,  kNameXml);
    237277    if (kSaveAsRoot)
    238278        d->SaveAsRoot(kTab, kNameRoot);
Note: See TracChangeset for help on using the changeset viewer.