Changeset 1023 for trunk/MagicSoft/Mars/meventdisp
- Timestamp:
- 11/01/01 10:19:46 (23 years ago)
- Location:
- trunk/MagicSoft/Mars/meventdisp
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/MagicSoft/Mars/meventdisp/MGEvtDisplay.cc
r991 r1023 28 28 29 29 #include <TGTab.h> // TGTab 30 #include <TGMenu.h> // TGPopupMenu 31 #include <TCanvas.h> // TCanvas::Print 30 32 #include <TGLabel.h> // TGLabel 31 33 #include <TGButton.h> // TGPictureButton 32 34 #include <TGMsgBox.h> // TGMsgBox 33 35 #include <TGTextEntry.h> // TGTextEntry 36 #include <TGFileDialog.h> // TGFileDialog 34 37 #include <TRootEmbeddedCanvas.h> // TRootEmbeddedCanvas 35 38 … … 46 49 enum MGCamDisplayCommand 47 50 { 48 M_PREVEVT, 49 M_NEXTEVT, 50 M_EVTNUMBER, 51 52 M_PRINT, 53 M_CLOSE 51 kEvtPrev, 52 kEvtNext, 53 kEvtNumber, 54 55 kFileSaveAs, 56 kFileSaveAsRoot, 57 kFileSaveAsC, 58 kFileSaveAsPS, 59 kFileSaveAsEPS, 60 kFileSaveAsGIF, 61 kFilePrint, 62 kClose 54 63 }; 55 64 … … 155 164 // Create the gui elements 156 165 // 157 TGTextButton *prevevt = new TGTextButton(top2, "<< Previous Event", M_PREVEVT);166 TGTextButton *prevevt = new TGTextButton(top2, "<< Previous Event", kEvtPrev); 158 167 prevevt->Associate(this); 159 168 160 169 TGLabel *evtnr = new TGLabel(top2, new TGString("Event: ")); 161 170 162 fTxtEvtNr = new TGTextEntry(top2, new TGTextBuffer(100), M_EVTNUMBER);171 fTxtEvtNr = new TGTextEntry(top2, new TGTextBuffer(100), kEvtNumber); 163 172 fTxtEvtNr->Resize(60, fTxtEvtNr->GetDefaultHeight()); 164 173 fTxtEvtNr->Associate(this); … … 166 175 fNumOfEvts = new TGLabel(top2, "out of Events."); 167 176 168 TGTextButton *nextevt = new TGTextButton (top2, "Next Event >>", M_NEXTEVT);177 TGTextButton *nextevt = new TGTextButton (top2, "Next Event >>", kEvtNext); 169 178 nextevt->Associate(this); 170 179 … … 252 261 void MGEvtDisplay::AddLowFrame(TGHorizontalFrame *frame) 253 262 { 254 TGTextButton *but1 = new TGTextButton(frame, "Print", M_PRINT); 255 TGTextButton *but2 = new TGTextButton(frame, "Close", M_CLOSE); 256 257 but1->Associate(this); 258 but2->Associate(this); 259 260 fList->Add(but1); 261 fList->Add(but2); 263 TGTextButton *but = new TGTextButton(frame, "Close", kClose); 264 265 but->Associate(this); 266 267 fList->Add(but); 262 268 263 269 TGLayoutHints *laybut = new TGLayoutHints(kLHintsLeft, 10, 10, 10, 10); 264 270 fList->Add(laybut); 265 271 266 frame->AddFrame(but1, laybut); 267 frame->AddFrame(but2, laybut); 272 frame->AddFrame(but, laybut); 268 273 } 269 274 … … 330 335 // Constructor 331 336 // 337 void MGEvtDisplay::AddMenuBar() 338 { 339 // 340 // Add all GUI elements and update the event counter 341 // 342 TGLayoutHints *laymenubar = new TGLayoutHints(kLHintsTop|kLHintsLeft|kLHintsExpandX, 2, 2, 2, 2); 343 TGLayoutHints *laymenuitem = new TGLayoutHints(kLHintsTop|kLHintsLeft, 0, 4, 0, 0); 344 TGLayoutHints *laylinesep = new TGLayoutHints(kLHintsTop|kLHintsExpandX); 345 346 fList->Add(laymenubar); 347 fList->Add(laymenuitem); 348 fList->Add(laylinesep); 349 350 TGPopupMenu *filemenu = new TGPopupMenu(gClient->GetRoot()); 351 filemenu->AddEntry("Save &As...", kFileSaveAs); 352 filemenu->AddEntry("Save As display.&ps", kFileSaveAsPS); 353 filemenu->AddEntry("Save As display.&eps", kFileSaveAsEPS); 354 filemenu->AddEntry("Save As display.&gif", kFileSaveAsGIF); 355 filemenu->AddEntry("Save As display.&C", kFileSaveAsC); 356 filemenu->AddEntry("Save As display.&root", kFileSaveAsRoot); 357 filemenu->AddSeparator(); 358 filemenu->AddEntry("&Print...", kFilePrint); 359 filemenu->AddSeparator(); 360 filemenu->AddEntry("E&xit", kClose); 361 filemenu->Associate(this); 362 363 TGMenuBar *menubar = new TGMenuBar(this, 1, 1, kHorizontalFrame); 364 menubar->AddPopup("File", filemenu, laymenuitem); 365 AddFrame(menubar, laymenubar); 366 367 TGHorizontal3DLine *linesep = new TGHorizontal3DLine(this); 368 AddFrame(linesep, laylinesep); 369 370 fList->Add(filemenu); 371 fList->Add(menubar); 372 fList->Add(linesep); 373 } 374 332 375 MGEvtDisplay::MGEvtDisplay(const char *fname, const char *tname, 333 376 const TGWindow *p, const TGWindow *main, … … 346 389 // (via SetOwner()) 347 390 // 348 349 391 MTaskList *tlist = new MTaskList; 350 392 tlist->SetOwner(); … … 353 395 tlist->AddToList(read); 354 396 355 MParList *plist = new MParList ();397 MParList *plist = new MParList; 356 398 plist->SetOwner(); 357 399 plist->AddToList(tlist); … … 361 403 fEvtLoop->SetParList(plist); 362 404 363 // 364 // Add all GUI elements and update the event counter 365 // 405 AddMenuBar(); 366 406 AddFrames(fname, tname); 367 407 UpdateEventCounter(); 368 408 } 369 409 370 371 410 // -------------------------------------------------------------------------- 372 411 // … … 375 414 MGEvtDisplay::~MGEvtDisplay() 376 415 { 377 delete fList;378 379 416 fEvtLoop->PostProcess(); 380 417 delete fEvtLoop; 418 419 delete fList; 381 420 } 382 421 … … 404 443 Int_t retval = 0; 405 444 445 // 406 446 // first check if the new event is in the range of possible events 407 447 // 408 448 if (iEvt >= GetReader()->GetEntries()) 409 449 { 410 new TGMsgBox(gClient->GetRoot(), this, 411 "WARNING!", 450 new TGMsgBox(gClient->GetRoot(), this, "WARNING!", 412 451 "The event number is out of range!!!", 413 452 kMBIconExclamation, buttons, &retval); … … 435 474 436 475 fTxtEvtNr->SetText(txt); 476 } 477 478 // -------------------------------------------------------------------------- 479 // 480 // Opens a save as dialog, and tries to store the canvas 481 // in the given output format 482 // 483 void MGEvtDisplay::SaveAsDialog() const 484 { 485 static const char *gSaveAsTypes[] = 486 { 487 "PostScript", "*.ps", 488 "Encapsulated PostScript", "*.eps", 489 "Gif files", "*.gif", 490 "Macro files", "*.C", 491 "ROOT files", "*.root", 492 "All files", "*", 493 NULL, NULL 494 }; 495 496 static TString dir("."); 497 498 TGFileInfo fi; 499 500 fi.fFileTypes = gSaveAsTypes; 501 fi.fIniDir = StrDup(dir); 502 503 new TGFileDialog(fClient->GetRoot(), this, kFDSave, &fi); 504 505 if (!fi.fFilename) 506 return; 507 508 dir = fi.fIniDir; 509 510 if (strstr(fi.fFilename, ".root") || 511 strstr(fi.fFilename, ".ps") || 512 strstr(fi.fFilename, ".eps") || 513 strstr(fi.fFilename, ".gif")) 514 { 515 fCanvas->SaveAs(fi.fFilename); 516 return; 517 } 518 if (strstr(fi.fFilename, ".C")) 519 { 520 fCanvas->SaveSource(fi.fFilename); 521 return; 522 } 523 Warning("SaveAsDialog", "Unknown Extension: %s", fi.fFilename); 437 524 } 438 525 … … 456 543 switch (parm1) 457 544 { 458 case M_PREVEVT:545 case kEvtPrev: 459 546 // 460 547 // '-2' is because MReadTree::Process increases the … … 465 552 return kTRUE; 466 553 467 case M_NEXTEVT:554 case kEvtNext: 468 555 // 469 556 // '+0' is because MReadTree::Process increases the … … 474 561 return kTRUE; 475 562 476 case M_CLOSE: 563 case kClose: 564 CloseWindow(); 565 return kTRUE; 566 } 567 return kTRUE; 568 569 case kCM_MENU: 570 switch (parm1) 571 { 572 case kFileSaveAs: 573 SaveAsDialog(); 574 return kTRUE; 575 case kFileSaveAsRoot: 576 fCanvas->SaveAs("display.root"); 577 return kTRUE; 578 case kFileSaveAsC: 579 fCanvas->SaveSource("display.C"); 580 return kTRUE; 581 case kFileSaveAsPS: 582 fCanvas->SaveAs("display.ps"); 583 return kTRUE; 584 case kFileSaveAsEPS: 585 fCanvas->SaveAs("display.eps"); 586 return kTRUE; 587 case kFileSaveAsGIF: 588 fCanvas->SaveAs("display.gif"); 589 return kTRUE; 590 case kFilePrint: 591 fCanvas->Print(); 592 return kTRUE; 593 case kClose: 477 594 CloseWindow(); 478 595 return kTRUE; -
trunk/MagicSoft/Mars/meventdisp/MGEvtDisplay.h
r1015 r1023 29 29 TGTextEntry *fTxtEvtNr; 30 30 31 void AddMenuBar(); 31 32 void AddTopFramePart1(TGVerticalFrame *frame, 32 33 const char *filename, … … 37 38 38 39 void AddFrames(const char *filename, const char *treename); 40 41 void SaveAsDialog() const; 39 42 40 43 void ReadinEvent(UInt_t iEvt);
Note:
See TracChangeset
for help on using the changeset viewer.