Ignore:
Timestamp:
12/18/02 17:48:44 (22 years ago)
Author:
tbretz
Message:
*** empty log message ***
Location:
trunk/MagicSoft/Cosy/gui
Files:
9 edited

Legend:

Unmodified
Added
Removed
  • trunk/MagicSoft/Cosy/gui/MGCosy.cc

    r1531 r1690  
    3030#include "SlaStars.h"
    3131
     32#undef DEBUG
     33
    3234ClassImp(MGCosy);
    3335
    34 #define IDM_EXIT 1
    35 #define IDM_TEXT 2
     36#define IDM_EXIT   1
     37#define IDM_TEXT   2
     38#define IDM_ASPECT 3
    3639
    3740enum
     
    6063    //
    6164    TGPopupMenu *fFileMenu = new TGPopupMenu(gClient->GetRoot());
     65    fFileMenu->AddEntry("Set Aspect", IDM_ASPECT);
    6266    fFileMenu->AddEntry("Exit", IDM_EXIT);
    6367    fFileMenu->Associate(this);
     
    477481    fList = new MGList;
    478482
     483#ifdef DEBUG
    479484    cout << "MGCosy: Creating Menu" << endl;
     485#endif
    480486    CreateMenu();
    481487
     488#ifdef DEBUG
    482489    cout << "MGCosy: Creating TGCompositeFrame" << endl;
    483     TGCompositeFrame *f = new TGCompositeFrame(this, 0, 0);
    484     f->SetLayoutManager(new TGMatrixLayout(f, 3, 2, 10));
    485     fList->Add(f);
    486 
     490#endif
     491    TGHorizontalFrame *f1 = new TGHorizontalFrame(this, 0, 0);
     492    TGHorizontalFrame *f2 = new TGHorizontalFrame(this, 0, 0);
     493    fList->Add(f1);
     494    fList->Add(f2);
     495
     496#ifdef DEBUG
    487497    cout << "MGCosy: Creating TGTab" << endl;
    488     fTab = new TGTab(f, 300, 300);
     498#endif
     499    fTab = new TGTab(f1, 300, 300);
    489500    fList->Add(fTab);
    490501
     502#ifdef DEBUG
    491503    cout << "MGCosy: Creating MGSkyPosition" << endl;
    492     fSkyPosition = new MGSkyPosition(f, 300);
     504#endif
     505    fSkyPosition = new MGSkyPosition(f1, 300);
     506#ifdef DEBUG
    493507    cout << "MGCosy: Creating MGAccuracy" << endl;
    494     fAccuracy    = new MGAccuracy   (f, 300);
     508#endif
     509    fAccuracy    = new MGAccuracy   (f1, 300);
     510#ifdef DEBUG
    495511    cout << "MGCosy: Creating MGVelocity" << endl;
    496     fVelocity    = new MGVelocity   (f, "Velocity [\"/min]", 300);
     512#endif
     513    fVelocity    = new MGVelocity   (f2, "Velocity [\"/min]", 300);
    497514//    fOffset      = new MGVelocity   (f, "Offset se-re [']", 300);
    498515
     
    502519//    fList->Add(fOffset);
    503520
     521#ifdef DEBUG
    504522    cout << "MGCosy: Creating TGGroupFrame" << endl;
    505     TGGroupFrame *frame = new TGGroupFrame(f, "Status");
     523#endif
     524    TGGroupFrame *frame = new TGGroupFrame(f2, "Status");
    506525    frame->Resize(300, 300);
    507526    fList->Add(frame);
    508527
     528#ifdef DEBUG
    509529    cout << "MGCosy: Creating TGListBox" << endl;
    510     fLog = new TGListBox(f, -1, kSunkenFrame);  //kSunkenFrame|kDoubleBorder,
     530#endif
     531    fLog = new TGListBox(f2, -1, kSunkenFrame);  //kSunkenFrame|kDoubleBorder,
    511532    fLog->Resize(300, 300);
    512533    fLog->ChangeBackground(TGFrame::GetBlackPixel());
    513534    fList->Add(fLog);
    514535
    515     //
    516     // Layout the window, tile by tile...
    517     //
    518     f->AddFrame(fTab);
    519     f->AddFrame(fSkyPosition);
    520     f->AddFrame(fAccuracy);
    521     f->AddFrame(frame);
    522     f->AddFrame(fVelocity);
    523     f->AddFrame(fLog);
    524 
    525     AddFrame(f, new TGLayoutHints(kLHintsNormal | kLHintsExpandX, 0, 0, 1, 0));
     536    TGLayoutHints *hints1  = new TGLayoutHints(kLHintsNormal  | kLHintsExpandX|kLHintsExpandY, 6, 6, 6, 3);
     537    TGLayoutHints *hints2  = new TGLayoutHints(kLHintsNormal  | kLHintsExpandX|kLHintsExpandY, 6, 6, 3, 6);
     538    TGLayoutHints *hints1a = new TGLayoutHints(kLHintsLeft    | kLHintsTop   |kLHintsExpandX|kLHintsExpandY);
     539    TGLayoutHints *hints2a = new TGLayoutHints(kLHintsCenterY | kLHintsTop   |kLHintsExpandX|kLHintsExpandY, 6, 6);
     540    TGLayoutHints *hints3a = new TGLayoutHints(kLHintsRight   | kLHintsTop   |kLHintsExpandX|kLHintsExpandY);
     541    TGLayoutHints *hints1b = new TGLayoutHints(kLHintsLeft    | kLHintsBottom|kLHintsExpandX|kLHintsExpandY);
     542    TGLayoutHints *hints2b = new TGLayoutHints(kLHintsCenterY | kLHintsBottom|kLHintsExpandX|kLHintsExpandY, 6, 6);
     543    TGLayoutHints *hints3b = new TGLayoutHints(kLHintsRight   | kLHintsBottom|kLHintsExpandX|kLHintsExpandY);
     544
     545    fList->Add(hints1);
     546    fList->Add(hints2);
     547    fList->Add(hints1a);
     548    fList->Add(hints2a);
     549    fList->Add(hints3a);
     550    fList->Add(hints1b);
     551    fList->Add(hints2b);
     552    fList->Add(hints3b);
     553
     554    // Layout upper frame
     555    f1->AddFrame(fTab,         hints1a);
     556    f1->AddFrame(fSkyPosition, hints2a);
     557    f1->AddFrame(fAccuracy,    hints3a);
     558
     559    // Layout upper frame
     560    f2->AddFrame(frame,        hints1b);
     561    f2->AddFrame(fVelocity,    hints2b);
     562    f2->AddFrame(fLog,         hints3b);
     563
     564    // Layout window
     565    AddFrame(f1, hints1);
     566    AddFrame(f2, hints2);
    526567
    527568    //
    528569    // FIXME!
    529570    //
     571#ifdef DEBUG
    530572    cout << "MGCosy: Creating Tabs" << endl;
     573#endif
    531574    CreateTabs(fTab);
     575#ifdef DEBUG
    532576    cout << "MGCosy: Creating Label" << endl;
     577#endif
    533578    CreateLabel(frame);
    534579
     
    536581    //   Map the window, set up the layout, etc.
    537582    //
     583#ifdef DEBUG
    538584    cout << "MGCosy: Setting Size" << endl;
     585#endif
    539586    const Int_t w = 940;
    540587    const Int_t h = 660;
    541     SetWMSizeHints(w, h, w, h, 10, 10);  // set the smallest and biggest size of the Main frame
     588    SetWMSizeHints(w, h, 1280, 900, 10, 10);  // set the smallest and biggest size of the Main frame
    542589
    543590    SetWindowName("Cosy Main Window");
    544591    SetIconName("Cosy");
    545592
     593#ifdef DEBUG
    546594    cout << "MGCosy: Map Window" << endl;
     595#endif
    547596    MapSubwindows();
    548     Resize(GetDefaultSize());
     597    Resize(w, h); //GetDefaultSize());
    549598    MapWindow();
    550599}
     
    930979                //CloseWindow();
    931980                return kTRUE;
     981            case IDM_ASPECT:
     982                Int_t w = GetWidth();
     983                Int_t h = GetHeight();
     984                if (w>940*h/660)
     985                    w = 940*h/660;
     986                else
     987                    h = 660*w/940;
     988                Resize(w, h);
     989                return kTRUE;
    932990            }
    933991            return kTRUE;
  • trunk/MagicSoft/Cosy/gui/MGEmbeddedCanvas.cc

    r1275 r1690  
    1212#include <TCanvas.h>
    1313
     14#undef DEBUG
     15
    1416ClassImp(MGEmbeddedCanvas);
    1517
     
    1921      fModified(kFALSE), fWidth(width), fRange(range), fPix(2.*range/width)
    2022{
     23#ifdef DEBUG
    2124    cout << "MGEmbeddedCanvas: Initializing." << endl;
     25#endif
     26
    2227    fCanvas = GetCanvas();
    2328
     29#ifdef DEBUG
    2430    cout << "MGEmbeddedCanvas: fCanvas = 0x" << fCanvas << endl;
    2531
    2632    cout << "MGEmbeddedCanvas: SetFillColor." << endl;
     33#endif
    2734    fCanvas->SetFillColor(39); // s. TAttFill
     35#ifdef DEBUG
    2836    cout << "MGEmbeddedCanvas: fRange=" << fRange << endl;
     37#endif
    2938    if (fRange>0)
    3039        fCanvas->Range(-fRange, -fRange, fRange, fRange);
     
    3342    fList->SetOwner();
    3443
     44#ifdef DEBUG
    3545    cout << "MGEmbeddedCanvas: Initializing done." << endl;
     46#endif
    3647}
    3748
  • trunk/MagicSoft/Cosy/gui/MGImage.cc

    r1343 r1690  
    1111#include <iostream.h>
    1212#include <pthread.h>
     13
     14#include <TTimer.h>
     15#include <TSystem.h>
     16#include <TVirtualX.h>
     17#include <TGX11.h>
    1318
    1419ClassImp(MGImage);
     
    97102
    98103    //
    99     // get frame id
    100     //
    101     fId = GetId();
    102 
    103     //
    104104    // Create Default Graphic Context (XCreateGC)
    105105    //
    106     fDefGC = gVirtualX->CreateGC(fId, 0); // GetBckgndGC(); //
     106    fDefGC = gVirtualX->CreateGC(fId, 0); // GetBckgndGC().GetGC(); //
    107107
    108108    //
     
    120120
    121121    Resize(w, h);
     122
     123    //fTimer=new TTimer(Form("gClient->ProcessEventsFor((TGWindow*)0x%p);", this), 250, kTRUE);
     124//    fTimer=new TTimer("printf(\"Timer!\\n\"); gSystem->ProcessEvents();", 250, kTRUE);
     125    //fTimer->Start();
    122126}
    123127
    124128void MGImage::Resize(UInt_t w, UInt_t h)
    125129{
    126     TGFrame::Resize(w+2*GetBorderWidth(), h+2*GetBorderWidth());
     130//    TGFrame::Resize(w+2*GetBorderWidth(), h+2*GetBorderWidth());
    127131    // FIXME: RESIZE THE PIXMAP
    128132}
     
    130134void MGImage::Resize(TGDimension size)
    131135{
    132     TGFrame::Resize(size.fWidth+2*GetBorderWidth(), size.fHeight+2*GetBorderWidth());
     136//    TGFrame::Resize(size.fWidth+2*GetBorderWidth(), size.fHeight+2*GetBorderWidth());
    133137    // FIXME: RESIZE THE PIXMAP
    134138}
     
    136140void MGImage::MoveResize(Int_t x, Int_t y, UInt_t w, UInt_t h)
    137141{
    138    TGFrame::MoveResize(x, y, w+2*GetBorderWidth(), h+2*GetBorderWidth());
     142//   TGFrame::MoveResize(x, y, w+2*GetBorderWidth(), h+2*GetBorderWidth());
    139143   // FIXME: RESIZE THE PIXMAP
    140144}
     
    142146MGImage::~MGImage()
    143147{
     148    //fTimer->Stop();
     149    //delete fTimer;
     150
    144151    pthread_mutex_lock((pthread_mutex_t*)fMuxPixmap);
    145152
     
    154161
    155162    if (fPixmap!=kNone) // @@@
     163    {
     164        cout << "Delete Pixmap" << endl;
    156165        gVirtualX->DeletePixmap(fPixmap);  // XFreePixmap(fDisplay, (Pixmap) pmap);
     166    }
    157167
    158168    cout << "Deleting GC..." << endl;
    159169
     170
    160171    gVirtualX->DeleteGC(fDefGC);       // XFreeGC(fDisplay, (GC) gc);
    161172
     
    165176}
    166177
     178#include <X11/Xlib.h>
    167179/*
    168 #include <X11/Xlib.h>
    169180#include <X11/Xutil.h>
    170181#include <X11/Intrinsic.h>
     
    174185void MGImage::DoRedraw()
    175186{
    176     // Pixmap_t pm = gVirtualX->CreatePixmap(this->GetId(), buffer,
    177     //                                       768, 576, 0, 0xff, 8);
    178     TGFrame::DrawBorder();
     187//    TGFrame::DrawBorder();
    179188    pthread_mutex_lock((pthread_mutex_t*)fMuxPixmap);
     189
     190    //===========================
     191    if (TestBit(kNeedRecreate))
     192    {
     193        Pixmap_t mask = kNone;
     194        PictureAttributes_t attr;
     195        attr.fMask = kNone;
     196
     197        if (fPixmap!=kNone)
     198            gVirtualX->DeletePixmap(fPixmap);
     199
     200        fPixmap=kNone;
     201
     202        if (!gVirtualX->CreatePictureFromData(fId, fBuffer, fPixmap,
     203                                              mask, attr))
     204        {
     205            cout << "Warning: Error in CreatePictureFromData" << endl;
     206            fPixmap=kNone;
     207        }
     208        ResetBit(kNeedRecreate);
     209    }
     210
     211    //===========================
    180212
    181213    // Copy a drawable (i.e. pixmap) to another drawable (pixmap, window).
     
    185217    //           dest_x, dest_y);
    186218    if (fPixmap!=kNone) //@@@
    187     gVirtualX->CopyArea(fPixmap, fId, fDefGC,
    188                         0, 0, fWidth, fHeight,
    189                         GetBorderWidth(), GetBorderWidth());
     219    {
     220//        gVirtualX->DrawString(fId, fDefGC, 20, 20, "HELLO WORLD!", 12);
     221//        gVirtualX->FillRectangle(fId, fDefGC, 10, 10, 50, 50);
     222
     223        //        cout << gVirtualX->IsA()->GetName() << endl;
     224        gVirtualX->CopyArea(fPixmap, fId, fDefGC,
     225                            0, 0, fWidth, fHeight,
     226                            GetBorderWidth(), GetBorderWidth());
     227
     228        /*
     229        XCopyArea((Display*)gVirtualX->GetDisplay(), pm, fId,
     230                  (GC)fDefGC, 0, 0, fWidth, fHeight,
     231                  GetBorderWidth(), GetBorderWidth());
     232                  */
     233    }
    190234/*
    191235     if (fPix)
     
    271315    cout << "Done " << (void*)fPix << endl;
    272316    */
     317
     318/*
    273319    Pixmap_t mask = kNone;
    274320    PictureAttributes_t attr;
    275321    attr.fMask = kNone;
    276322    if (fPixmap!=kNone) // @@@
    277     gVirtualX->DeletePixmap(fPixmap); // XFreePixmap(fDisplay, (Pixmap) pmap);
     323        gVirtualX->DeletePixmap(fPixmap); // XFreePixmap(fDisplay, (Pixmap) pmap);
    278324
    279325    // Create a pixture pixmap from data. The picture attributes
     
    310356        fPixmap=kNone;
    311357    }
    312 
     358*/
     359    SetBit(kNeedRecreate);
    313360    pthread_mutex_unlock((pthread_mutex_t*)fMuxPixmap);
    314     DoRedraw();
     361    //gClient->NeedRedraw(this);
     362    //fTimer->Start(10, kTRUE);
     363    //gVirtualX->UpdateWindow(1);
     364    //    ((TGX11*)gVirtualX)->Sync(1);
     365    //new TTimer(Form("gClient->ProcessEventsFor((TGWindow*)0x%p);", this), 1, kFALSE);
     366    //    DoRedraw();
    315367}
    316368
     
    339391        }
    340392    }
    341 
     393/*
    342394    Pixmap_t mask = kNone;
    343395    PictureAttributes_t attr;
     
    346398    if (fPixmap!=kNone)
    347399        gVirtualX->DeletePixmap(fPixmap);
     400
    348401    fPixmap=kNone;
    349402
     
    354407        fPixmap=kNone;
    355408    }
    356 
     409    */
     410    SetBit(kNeedRecreate);
    357411    pthread_mutex_unlock((pthread_mutex_t*)fMuxPixmap);
    358     DoRedraw();
    359 }
    360 
     412    //gClient->NeedRedraw(this);
     413    //fTimer->Start(10, kTRUE);
     414    //gVirtualX->UpdateWindow(1);
     415    //    ((TGX11*)gVirtualX)->Sync(1);
     416    //new TTimer(Form("gClient->ProcessEventsFor((TGWindow*)0x%p);", this), 1, kFALSE);
     417    //    DoRedraw();
     418}
     419
  • trunk/MagicSoft/Cosy/gui/MGImage.h

    r1111 r1690  
    1010#include <TGFrame.h>
    1111
     12class TTimer;
     13
    1214typedef unsigned char byte;
    1315
     
    2022
    2123    GContext_t fDefGC;
    22     Drawable_t fId;
    2324    Pixmap_t   fPixmap;
    2425
     
    2829    void *fMuxPixmap; //! test
    2930
    30 public:
     31    TTimer *fTimer;
     32
     33    enum { kNeedRecreate = BIT(17) };
    3134
    3235public:
  • trunk/MagicSoft/Cosy/gui/MGSkyPosition.cc

    r1275 r1690  
    172172    : MGEmbeddedCanvas("SkyPosition", p, w, 110)
    173173{
    174     cout << "MGSkyPosition: Initilizing." << endl;
    175174    DrawCoordinateSystem();
    176175    InitPlanets();
     
    178177    InitText();
    179178    InitCanvas();
    180     cout << "MGSkyPosition: Initilizing done." << endl;
    181179}
    182180
     
    278276    static int Y = ~0;
    279277
    280     int xd = (int)floor(x);
    281     int yd = (int)floor(y);
     278    int xd = (int)/*floor*/(x);
     279    int yd = (int)/*floor*/(y);
    282280    x *= 60.;
    283281    y *= 60.;
    284282
    285     int fx = (int)floor(x*10.);
    286     int fy = (int)floor(y*10.);
     283    int fx = (int)/*floor*/(x*10.);
     284    int fy = (int)/*floor*/(y*10.);
    287285
    288286    if (X==fx && Y==fy)
     
    296294
    297295    char txt[100];
    298     sprintf(txt, "Zd=%d\xb0%02.1f'\nAz=%d\xb0%02.1f'",
    299             xd, xm, yd, ym);
     296    sprintf(txt, "Zd=%s%d\xb0%02.1f'\nAz=%s%d\xb0%02.1f'",
     297            x<0?"-":"", abs(xd), xm, y<0?"-":"", abs(yd), ym);
    300298
    301299    fText->SetText(fText->GetX(), fText->GetY(), txt);
     
    305303
    306304
    307 void MGSkyPosition::Update(ZdAz &pos)
     305void MGSkyPosition::Update(ZdAz &pos, double mjd)
    308306{
    309307    //
    310308    // calculate actual time for planet positions
    311309    //
    312     fSlaPlanet->SetMjd2Now();
    313     fSlaStar->SetMjd2Now();
     310    fSlaPlanet->SetMjd(mjd);
     311    fSlaStar->SetMjd(mjd);
    314312
    315313    UpdatePlanet(kESun,     fSun);
  • trunk/MagicSoft/Cosy/gui/MGSkyPosition.h

    r1273 r1690  
    6666    ~MGSkyPosition();
    6767
    68     void Update(ZdAz &pos);
     68    void Update(ZdAz &pos, double mjd);
    6969
    7070    ClassDef(MGSkyPosition, 0)
  • trunk/MagicSoft/Cosy/gui/MGStarguider.cc

    r1531 r1690  
    33#include <fstream.h>    // ifstream
    44#include <iostream.h>   // cout
    5 #
     5
     6#include <TTimer.h>
     7
    68#include <TGMenu.h>
    79#include <TSystem.h>
     
    6163};
    6264
     65Bool_t MGStarguider::HandleTimer(TTimer *t)
     66{
     67    fImage->DoRedraw();
     68    fZoomImage->DoRedraw();
     69    return kTRUE;
     70}
     71
    6372#define kZOOM 96
    6473
     
    199208    // Create Image Display
    200209    //
     210    fZoomImage = new MGImage(this, kZOOM, kZOOM);
     211    fZoomImage->Move(768-kZOOM-2, 700-kZOOM-2);
     212    AddFrame(fZoomImage);
     213    fList->Add(fZoomImage);
     214
    201215    fImage = new MGImage(this, 768, 576);
    202216    fImage->Move(0, fMenu->GetDefaultHeight());
     
    204218    fList->Add(fImage);
    205219
    206     fZoomImage = new MGImage(this, kZOOM, kZOOM);
    207     fZoomImage->Move(768-kZOOM-2, 700-kZOOM-2);
    208     AddFrame(fZoomImage);
    209     fList->Add(fZoomImage);
    210 
    211220    //
    212221    // Make everything visible
     
    217226    MapSubwindows();
    218227    MapWindow();
     228
     229    fTimer=new TTimer(this, 100); // 100ms
     230    fTimer->TurnOn();
    219231}
    220232
    221233MGStarguider::~MGStarguider()
    222234{
     235    fTimer->TurnOff();
     236    delete fTimer;
     237
    223238    delete fSao;
    224239    delete fRaDec;
  • trunk/MagicSoft/Cosy/gui/MGStarguider.h

    r1531 r1690  
    1414class AltAz;
    1515class RaDec;
     16
     17class TTimer;
    1618
    1719class TGMenuBar;
     
    5254    RaDec *fRaDec;
    5355
     56    TTimer *fTimer;
     57
    5458    Int_t fDx;
    5559    Int_t fDy;
     
    6266    void GetCoordinates();
    6367    void CalcTrackingError(MStarList &, MStarList &);
     68
     69    Bool_t HandleTimer(TTimer *t);
    6470
    6571public:
  • trunk/MagicSoft/Cosy/gui/MGVelocity.cc

    r1111 r1690  
    279279    vy /= 60.;  //['/min]
    280280
    281     int fx = (int)floor(vx*10.);
    282     int fy = (int)floor(vy*10.);
     281    int fx = (int)/*floor*/(vx*10.);
     282    int fy = (int)/*floor*/(vy*10.);
    283283
    284284    if (X==fx && Y==fy)
     
    290290    char txt[100];
    291291    sprintf(txt, "Zd=%.1f'\nAz=%.1f'",
    292             vx, vy);
     292            vy, vx);
    293293
    294294    fTextVel->SetText(fTextVel->GetX(), fTextVel->GetY(), txt);
Note: See TracChangeset for help on using the changeset viewer.