- Timestamp:
- 05/02/03 08:56:31 (22 years ago)
- Location:
- trunk/MagicSoft/Mars
- Files:
-
- 15 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/MagicSoft/Mars/Changelog
r2049 r2052 1 1 -*-*- END OF LINE -*-*- 2 3 2003/05/02: Thomas Bretz 4 5 * manalysis/MCerPhotEvt.[h,cc: 6 - added RemoveUnusedPixels 7 8 * manalysis/MSigmabar.cc: 9 - small simplification for compiler optimization 10 11 * mbase/MEvtLoop.cc: 12 - changed output to fDisplay 13 - changed behaviour in case of a failed PostProcess 14 15 * mbase/MLog.[h,cc]: 16 - added flushing and tab conversion to GUI 17 18 * mbase/MParList.cc: 19 - replaced some *Iter by MIter 20 21 * mbase/MTask.cc, mbase/MTaskList.cc: 22 - added output to fDisplay 23 - replaced some *Iter by MIter 24 25 * mhist/MH.cc: 26 - don't add clones to directory 27 28 * mimage/MImgCleanStd.[h,cc]: 29 - replaced divisiond by multiplications 30 - fixed StreamePrimitive 31 - do not allow 0 rings 32 33 * mmain/MStatusDisplay.[h,cc]: 34 - added writing gif 35 - added writing C 36 - changes SaveAs to non-const (added output to status lines) 37 2 38 3 39 -
trunk/MagicSoft/Mars/manalysis/MCerPhotEvt.cc
r1965 r2052 351 351 } 352 352 353 /*354 // --------------------------------------------------------------------------355 //356 // Use this function to sum photons in events together.357 //358 Bool_t MCerPhotEvt::AddEvent(const MCerPhotEvt &evt)359 {360 if (evt.fNumPixels<=0)361 {362 *fLog << "Warning - Event to be added has no pixels." << endl;363 return kFALSE;364 }365 if (fNumPixels<=0)366 {367 *fLog << "Warning - Event to add pixels to has no pixels." << endl;368 return kFALSE;369 }370 371 for (UInt_t i=0; i<evt.fNumPixels; i++)372 {373 const UInt_t id = evt[i].GetPixId();374 375 MCerPhotPix *pix2 = GetPixById(id);376 if (!pix2)377 {378 *fLog << "Error - Pixel#" << dec << id << " does not exist in this event!" << endl;379 return kFALSE;380 }381 382 pix2->AddNumPhotons(evt[i].GetNumPhotons());383 }384 return kTRUE;385 }386 */387 388 353 void MCerPhotEvt::Scale(Double_t f) 389 354 { 390 355 fPixels->ForEach(MCerPhotPix, Scale)(f); 391 356 } 357 358 void MCerPhotEvt::RemoveUnusedPixels() 359 { 360 TIter Next(fPixels); 361 MCerPhotPix *pix = NULL; 362 363 while ((pix=(MCerPhotPix*)Next())) 364 if (!pix->IsPixelUsed()) 365 fPixels->Remove(pix); 366 367 fPixels->Compress(); 368 fNumPixels=fPixels->GetEntriesFast(); 369 } -
trunk/MagicSoft/Mars/manalysis/MCerPhotEvt.h
r1965 r2052 49 49 50 50 void Scale(Double_t f); 51 void RemoveUnusedPixels(); 51 52 52 53 MCerPhotPix *GetPixById(int id) const; -
trunk/MagicSoft/Mars/manalysis/MSigmabar.cc
r1961 r2052 172 172 fSigmabarInner = 0; 173 173 fSigmabarOuter = 0; 174 for (UInt_t i=0; i<6; i++) { 174 for (UInt_t i=0; i<6; i++) 175 { 175 176 fSigmabarInner += innerSquaredSum[i]; 176 177 fInnerPixels += innerPixels[i]; … … 187 188 if (fOuterPixels > 0) fSigmabarOuter /= fOuterPixels; 188 189 189 // 190 // this is the sqrt of the average sigma^2 191 // for the inner and outer pixels respectively 192 // 193 fSigmabarInner = sqrt( fSigmabarInner ); 194 fSigmabarOuter = sqrt( fSigmabarOuter ); 195 196 for (UInt_t i=0; i<6; i++) { 197 fSigmabarSector[i] = innerPixels[i]+outerPixels[i]<=0?0:sqrt((innerSquaredSum[i]+outerSquaredSum[i])/(innerPixels[i]+outerPixels[i])); 198 199 const Double_t is = innerPixels[i]<=0?0:innerSquaredSum[i]/innerPixels[i]; 200 const Double_t os = outerPixels[i]<=0?0:outerSquaredSum[i]/outerPixels[i]; 201 202 fSigmabarInnerSector[i] = sqrt( is ); 203 fSigmabarOuterSector[i] = sqrt( os ); 204 } 205 190 // 191 // this is the sqrt of the average sigma^2 192 // for the inner and outer pixels respectively 193 // 194 fSigmabarInner = sqrt( fSigmabarInner ); 195 fSigmabarOuter = sqrt( fSigmabarOuter ); 196 197 for (UInt_t i=0; i<6; i++) 198 { 199 const Double_t ip = innerPixels[i]; 200 const Double_t op = outerPixels[i]; 201 const Double_t iss = innerSquaredSum[i]; 202 const Double_t oss = outerSquaredSum[i]; 203 204 const Double_t sum = ip + op; 205 206 fSigmabarSector[i] = sum<=0 ? 0 : sqrt((iss+oss)/sum); 207 fSigmabarInnerSector[i] = ip <=0 ? 0 : sqrt(iss/ip); 208 fSigmabarOuterSector[i] = op <=0 ? 0 : sqrt(oss/op); 209 } 210 206 211 return fSigmabar; 207 212 } … … 237 242 238 243 } 239 240 241 242 243 244 -
trunk/MagicSoft/Mars/mbase/MEvtLoop.cc
r2042 r2052 190 190 fDisplay->SetWindowName(TString("Status Display: ")+fName); 191 191 fDisplay->SetIconName(fName); 192 // Set status lines193 fDisplay->SetStatusLine1("PreProcessing...");194 fDisplay->SetStatusLine2("");195 192 // Start automatic update 196 193 fDisplay->StartUpdate(); … … 207 204 if (!fTaskList->PreProcess(fParList)) 208 205 { 209 *fLog << err << "Error detected while PreProcessing " << endl;206 *fLog << err << "Error detected while PreProcessing." << endl; 210 207 return kFALSE; 211 208 } … … 422 419 // execute the post process of all tasks 423 420 // 424 if (fDisplay)425 {426 // Set status lines427 fDisplay->SetStatusLine1("PostProcessing...");428 fDisplay->SetStatusLine2("");429 }430 421 return fTaskList->PostProcess(); 431 422 } … … 433 424 // -------------------------------------------------------------------------- 434 425 // 435 // See class description above. 426 // See class description above. Returns kTRUE if PreProcessing, 427 // Processing and PostProcessing was successfull, otherwise kFALSE. 436 428 // 437 429 Bool_t MEvtLoop::Eventloop(Int_t maxcnt, const char *tlist) … … 446 438 447 439 // 448 // Now postprocess all tasks. Only successfully preprocessed tasks are 449 // postprocessed. If the Postprocessing of one task fail return an error. 440 // Now postprocess all tasks. Only successfully preprocessed tasks 441 // are postprocessed. If the Postprocessing of one task fails 442 // return an error. 450 443 // 451 444 if (!PostProcess()) 452 return kFALSE; 445 { 446 *fLog << err << "Error detected while PostProcessing." << endl; 447 rc = kFALSE; 448 } 453 449 454 450 if (!fDisplay) … … 457 453 // Set status lines 458 454 fDisplay->SetStatusLine1(fName); 459 fDisplay->SetStatusLine2(rc ? "Done." : "E RROR");455 fDisplay->SetStatusLine2(rc ? "Done." : "Error!"); 460 456 // Stop automatic update 461 457 fDisplay->StopUpdate(); -
trunk/MagicSoft/Mars/mbase/MLog.cc
r1895 r2052 175 175 MLog::MLog(MLog &log) 176 176 { 177 fOutputLevel 178 fDebugLevel 179 fDevice 177 fOutputLevel = log.fOutputLevel; 178 fDebugLevel = log.fDebugLevel; 179 fDevice = log.fDevice; 180 180 } 181 181 … … 208 208 if (fDevice&eGui && fgui) 209 209 { 210 char **newstr = new char*[fNumLines+1]; 211 212 for (int i=0; i<fNumLines; i++) 213 newstr[i] = fGuiLines[i]; 214 215 if (fNumLines>0) 216 delete fGuiLines; 217 218 char *dummy = new char[len]; 219 memcpy(dummy, fBase, len-1); 220 dummy[len-1]='\0'; 221 222 newstr[fNumLines++] = dummy; 223 224 fGuiLines = newstr; 210 // check whether the current text was flushed or endl'ed 211 const Bool_t flushed = fBase[len-1]!='\n'; 212 213 // for the gui remove trailing characters ('\n' or '\0') 214 fBase[len-1]='\0'; 215 216 // add new text to line storage 217 fGuiLine += fBase; 218 219 if (!flushed) 220 { 221 // add a new TString* to the array of gui lines 222 TString **newstr = new TString*[fNumLines+1]; 223 memcpy(newstr, fGuiLines, fNumLines*sizeof(TString*)); 224 if (fNumLines>0) 225 delete fGuiLines; 226 fGuiLines = newstr; 227 228 // add Gui line as last line of array 229 fGuiLines[fNumLines++] = new TString(fGuiLine); 230 fGuiLine = ""; 231 } 225 232 } 226 233 } … … 231 238 return; 232 239 240 // lock mutex 233 241 Lock(); 234 242 243 // copy lines to TGListBox 235 244 for (int i=0; i<fNumLines; i++) 236 245 { 237 fgui->AddEntry(fGuiLines[i], fGuiLineId++); 246 // Replace all tabs by 7 white spaces 247 fGuiLines[i]->ReplaceAll("\t", " "); 248 fgui->AddEntry(*fGuiLines[i], fGuiLineId++); 238 249 delete fGuiLines[i]; 239 250 } 240 241 251 delete fGuiLines; 242 252 243 253 fNumLines=0; 244 254 255 // cut list box top 1000 lines 245 256 fgui->RemoveEntries(0, fGuiLineId-1000); 257 // show last entry 246 258 fgui->SetTopEntry(fGuiLineId-1); 259 // tell a main loop, that list box contents have changed 247 260 fgui->SetBit(kHasChanged); 248 261 262 // release mutex 249 263 UnLock(); 250 264 } -
trunk/MagicSoft/Mars/mbase/MLog.h
r1895 r2052 4 4 #ifndef ROOT_TObject 5 5 #include <TObject.h> 6 #endif 7 #ifndef ROOT_TString 8 #include <TString.h> 6 9 #endif 7 10 … … 23 26 24 27 private: 25 char fBuffer; //!26 char fBase[bsz ];//! Buffer to store the data in27 char *fPPtr; //! Pointer to present position in buffer28 const char *fEPtr; //! Pointer to end of buffer28 char fBuffer; //! 29 char fBase[bsz+1]; //! Buffer to store the data in 30 char *fPPtr; //! Pointer to present position in buffer 31 const char *fEPtr; //! Pointer to end of buffer 29 32 30 UInt_t fOutputLevel; //! Present output level of the stream31 UInt_t fDebugLevel; //! Present global debug level32 UInt_t fDevice; //! Flag to indicate the present streams33 UInt_t fOutputLevel; //! Present output level of the stream 34 UInt_t fDebugLevel; //! Present global debug level 35 UInt_t fDevice; //! Flag to indicate the present streams 33 36 34 Bool_t fIsNull; //! Switch output completely off37 Bool_t fIsNull; //! Switch output completely off 35 38 36 Int_t fGuiLineId; 39 Int_t fGuiLineId; //! 37 40 38 41 ofstream *fout; //! possible file output stream … … 40 43 TGListBox *fgui; //! Listbox output 41 44 42 Bool_t fIsDirectGui; //! Pipe text directly to the GUI (for single threaded environments) 43 char **fGuiLines; //! Lines to pipe to gui 44 Int_t fNumLines; 45 Bool_t fIsDirectGui; //! Pipe text directly to the GUI (for single threaded environments) 46 TString **fGuiLines; //! Lines to pipe to gui 47 Int_t fNumLines; //! 48 // Bool_t fGuiLineFlushed; 49 TString fGuiLine; //! 45 50 46 51 #ifdef _REENTRANT -
trunk/MagicSoft/Mars/mbase/MParList.cc
r1965 r2052 222 222 return; 223 223 224 TObjArrayIter Next(list);224 MIter Next(list); 225 225 226 226 MParContainer *cont = NULL; 227 while ((cont= (MParContainer*)Next()))227 while ((cont=Next())) 228 228 AddToList(cont); 229 229 } … … 505 505 *fLog << all << " " << GetDescriptor() << endl; 506 506 *fLog << setfill('-') << setw(strlen(GetDescriptor())+2) << "" << endl; 507 507 508 MParContainer *obj = NULL; 508 TIter Next(fContainer);509 while ((obj= (MParContainer*)Next()))509 MIter Next(fContainer); 510 while ((obj=Next())) 510 511 { 511 512 *fLog << " " << obj->GetDescriptor(); … … 802 803 MParContainer *cont = NULL; 803 804 804 TIter Next(fContainer);805 while ((cont= (MParContainer*)Next()))805 MIter Next(fContainer); 806 while ((cont=Next())) 806 807 { 807 808 if (cont->InheritsFrom("MTaskList")) … … 878 879 MParContainer *cont = NULL; 879 880 880 TIter Next(fContainer);881 while ((cont= (MParContainer*)Next()))881 MIter Next(fContainer); 882 while ((cont=Next())) 882 883 if (!cont->WriteEnv(env, prefix, print)) 883 884 return kFALSE; -
trunk/MagicSoft/Mars/mbase/MTask.cc
r2015 r2052 16 16 ! 17 17 ! 18 ! Author(s): Thomas Bretz <mailto:tbretz@uni-sw.gwdg.de>, 12/200019 ! 20 ! Copyright: MAGIC Software Development, 2000-200 118 ! Author(s): Thomas Bretz, 12/2000 <mailto:tbretz@astro.uni-wuerzburg.de> 19 ! 20 ! Copyright: MAGIC Software Development, 2000-2003 21 21 ! 22 22 ! … … 76 76 #include "MFilter.h" 77 77 #include "MGGroupFrame.h" 78 #include "MStatusDisplay.h" 78 79 79 80 ClassImp(MTask); … … 166 167 fNumExecutions = 0; 167 168 169 *fLog << all << fName << "... " << flush; 170 if (fDisplay) 171 fDisplay->SetStatusLine2(*this); 172 168 173 switch (PreProcess(plist)) 169 174 { … … 220 225 221 226 fIsPreprocessed = kFALSE; 227 228 *fLog << all << fName << "... " << flush; 229 if (fDisplay) 230 fDisplay->SetStatusLine2(*this); 222 231 223 232 return PostProcess(); -
trunk/MagicSoft/Mars/mbase/MTaskList.cc
r2015 r2052 65 65 #include "MLogManip.h" 66 66 67 #include "MIter.h" 67 68 #include "MFilter.h" 68 69 #include "MParList.h" … … 288 289 MTask *task=NULL; 289 290 // 290 // loop over all tasks for preproccesing291 // loop over all tasks for reinitialization 291 292 // 292 293 while ((task=(MTask*)Next())) … … 330 331 { 331 332 *fLog << all << "Preprocessing... " << flush; 333 if (fDisplay) 334 { 335 // Set status lines 336 fDisplay->SetStatusLine1("PreProcessing..."); 337 fDisplay->SetStatusLine2(""); 338 } 332 339 333 340 fParList = pList; … … 347 354 while ((task=(MTask*)Next())) 348 355 { 349 *fLog << all << task->GetName() << "... " << flush;350 if (fDisplay)351 fDisplay->SetStatusLine2(*task);352 353 356 // 354 357 // PreProcess the task and check for it's return value. … … 494 497 { 495 498 *fLog << all << "Postprocessing... " << flush; 499 if (fDisplay) 500 { 501 // Set status lines 502 fDisplay->SetStatusLine1("PostProcessing..."); 503 fDisplay->SetStatusLine2(""); 504 } 496 505 497 506 // … … 518 527 while ( (task=(MTask*)Next()) ) 519 528 { 520 *fLog << all << task->GetName() << "... " << flush;521 if (fDisplay)522 fDisplay->SetStatusLine2(*task);523 524 529 if (!task->CallPostProcess()) 525 530 return kFALSE; … … 602 607 out << ";" << endl << endl; 603 608 604 TIter Next(fTasks);609 MIter Next(fTasks); 605 610 606 611 MParContainer *cont = NULL; 607 while ((cont= (MParContainer*)Next()))612 while ((cont=Next())) 608 613 { 609 614 cont->SavePrimitive(out, ""); … … 654 659 MParContainer *cont = NULL; 655 660 656 TIter Next(fTasks);657 while ((cont= (MParContainer*)Next()))661 MIter Next(fTasks); 662 while ((cont=Next())) 658 663 { 659 664 if (cont->InheritsFrom("MTaskList")) … … 730 735 MParContainer *cont = NULL; 731 736 732 TIter Next(fTasks);733 while ((cont= (MParContainer*)Next()))737 MIter Next(fTasks); 738 while ((cont=Next())) 734 739 if (!cont->WriteEnv(env, prefix, print)) 735 740 return kFALSE; -
trunk/MagicSoft/Mars/mhist/MH.cc
r2043 r2052 763 763 gROOT->SetSelectedPad(NULL); 764 764 765 Bool_t store = TH1::AddDirectoryStatus(); 766 TH1::AddDirectory(kFALSE); 767 765 768 TObject *o = MParContainer::DrawClone(opt); 766 769 o->SetBit(kCanDelete); 770 771 TH1::AddDirectory(store); 772 767 773 return o; 768 774 } … … 787 793 // 788 794 if (cls->GetMethodAny("Draw")) 789 {790 *fLog << all << "FOUND: " << cls->GetName() << " " << (cls->GetName()=="MH") << endl;791 795 return kTRUE; 792 }793 796 794 797 // -
trunk/MagicSoft/Mars/mimage/MImgCleanStd.cc
r2040 r2052 285 285 // 286 286 MImgCleanStd::MImgCleanStd(const Float_t lvl1, const Float_t lvl2, 287 const char *name, const char *title)287 const char *name, const char *title) 288 288 : fSgb(NULL), fCleaningMethod(kStandard), fCleanLvl1(lvl1), 289 289 fCleanLvl2(lvl2), fCleanRings(1) … … 324 324 MCerPhotPix &pix = (*fEvt)[i]; 325 325 326 const Float_t entry = pix.GetNumPhotons();327 const Float_t noise = pix.GetErrorPhot();328 329 326 const Int_t id = pix.GetPixId(); 327 328 const Float_t entry = pix.GetNumPhotons(); 329 const Float_t noise = pix.GetErrorPhot(); 330 330 const Double_t ratio = TMath::Sqrt(fCam->GetPixRatio(id)); 331 331 332 332 // COBB: '<=' to skip entry=noise=0 333 if (entry <= fCleanLvl1 * noise / ratio)333 if (entry * ratio <= fCleanLvl1 * noise) 334 334 pix.SetPixelUnused(); 335 335 … … 366 366 MCerPhotPix &pix = (*fEvt)[i]; 367 367 368 const Float_t entry = pix.GetNumPhotons();369 370 368 const Int_t id = pix.GetPixId(); 371 369 370 const Float_t entry = pix.GetNumPhotons(); 372 371 const Double_t ratio = fCam->GetPixRatio(id); 373 372 374 373 // COBB: '<=' to skip entry=noise=0 375 if (entry <= fCleanLvl1 * fInnerNoise / ratio)374 if (entry * ratio <= fCleanLvl1 * fInnerNoise) 376 375 pix.SetPixelUnused(); 377 376 … … 451 450 const Int_t id2 = gpix.GetNeighbor(j); 452 451 453 // when you find an used 452 // when you find an used neighbor, break the loop 454 453 if (ispixused[id2] == 1) 455 454 { 456 hasNeighbor = kTRUE 455 hasNeighbor = kTRUE; 457 456 break; 458 457 } … … 460 459 461 460 if (hasNeighbor == kFALSE) 462 461 pix.SetPixelUnused(); 463 462 } 464 463 … … 493 492 // check the num of photons against the noise level 494 493 // 495 const Float_t entry = pix.GetNumPhotons(); 496 const Float_t noise = pix.GetErrorPhot(); 497 494 const Float_t entry = pix.GetNumPhotons(); 495 const Float_t noise = pix.GetErrorPhot(); 498 496 const Double_t ratio = TMath::Sqrt(fCam->GetPixRatio(id)); 499 497 500 return (entry <= fCleanLvl2 * noise / ratio);498 return (entry * ratio <= fCleanLvl2 * noise); 501 499 } 502 500 … … 517 515 // check the num of photons against the noise level 518 516 // 519 const Float_t entry = pix.GetNumPhotons(); 520 517 const Float_t entry = pix.GetNumPhotons(); 521 518 const Double_t ratio = fCam->GetPixRatio(id); 522 519 523 return (entry <= fCleanLvl2 * fInnerNoise / ratio);520 return (entry * ratio <= fCleanLvl2 * fInnerNoise); 524 521 } 525 522 … … 583 580 584 581 pix.SetRing(r); 585 582 break; 586 583 } 587 584 } … … 819 816 } 820 817 out << ");" << endl; 821 } 818 819 if (fCleaningMethod!=kDemocratic) 820 return; 821 822 out << " " << GetUniqueName() << ".SetMethod(MImgCleanStd::kDemocratic);" << endl; 823 824 if (fCleanRings==1) 825 return; 826 827 out << " " << GetUniqueName() << ".SetCleanRings(" << fCleanRings << ");" << endl; 828 } -
trunk/MagicSoft/Mars/mimage/MImgCleanStd.h
r2038 r2052 62 62 UShort_t GetCleanRings() const { return fCleanRings;} 63 63 64 void SetCleanRings(UShort_t r) { fCleanRings=r; }64 void SetCleanRings(UShort_t r) { if(r==0) r=1; fCleanRings=r; } 65 65 void SetMethod(CleaningMethod_t m) { fCleaningMethod = m; } 66 66 -
trunk/MagicSoft/Mars/mmain/MStatusDisplay.cc
r2022 r2052 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(). 34 // Direct printing to the default printer (via lpr) can be done by 35 // PrintToLpr(). 36 // 33 37 // It has also to half status lines which can be used to display the status 34 38 // or something going on. Together with the status lines it has a progress … … 101 105 // filemenu->AddEntry("S&ave [F2]", kFileSave); 102 106 // filemenu->AddEntry("Save &As... [Shift-F2]", kFileSaveAs); 103 filemenu->AddEntry("Save As status.&ps", kFileSaveAsPS);104 // filemenu->AddEntry("Save As status.&gif",kFileSaveAsGIF);105 // filemenu->AddEntry("Save As status.&C",kFileSaveAsC);107 filemenu->AddEntry("Save As status.&ps", kFileSaveAsPS); 108 filemenu->AddEntry("Save As status.&gif", kFileSaveAsGIF); 109 filemenu->AddEntry("Save As status.&C", kFileSaveAsC); 106 110 filemenu->AddEntry("Save As status.&root", kFileSaveAsRoot); 107 111 filemenu->AddSeparator(); 108 filemenu->AddEntry("Print with &lpr", kFilePrint);109 filemenu->AddEntry("Set printer &name", kFilePrinterName);112 filemenu->AddEntry("Print with &lpr", kFilePrint); 113 filemenu->AddEntry("Set printer &name", kFilePrinterName); 110 114 filemenu->AddSeparator(); 111 115 filemenu->AddEntry("E&xit", kFileExit); … … 118 122 // tabmenu->AddEntry("S&ave [F2]", kFileSave); 119 123 // tabmenu->AddEntry("Save &As... [Shift-F2]", kFileSaveAs); 120 tabmenu->AddEntry("Save As tab-i.&ps", kTabSaveAsPS);121 // tabmenu->AddEntry("Save As tab-i.&gif",kTabSaveAsGIF);122 // tabmenu->AddEntry("Save As tab-i.&C",kTabSaveAsC);124 tabmenu->AddEntry("Save As tab-i.&ps", kTabSaveAsPS); 125 tabmenu->AddEntry("Save As tab-i.&gif", kTabSaveAsGIF); 126 tabmenu->AddEntry("Save As tab-i.&C", kTabSaveAsC); 123 127 tabmenu->AddEntry("Save As tab-i.&root", kTabSaveAsRoot); 124 128 tabmenu->AddSeparator(); 125 tabmenu->AddEntry("Print with &lpr", kFilePrint);129 tabmenu->AddEntry("Print with &lpr", kFilePrint); 126 130 tabmenu->AddSeparator(); 127 tabmenu->AddEntry("Next [&+]", kTabNext);128 tabmenu->AddEntry("Previous [&-]", kTabPrevious);131 tabmenu->AddEntry("Next [&+]", kTabNext); 132 tabmenu->AddEntry("Previous [&-]", kTabPrevious); 129 133 tabmenu->Associate(this); 130 134 … … 135 139 loopmenu->AddEntry("&Stop", kLoopStop); 136 140 loopmenu->Associate(this); 141 142 // 143 // Loop Menu 144 // 145 MGPopupMenu *sizemenu = new MGPopupMenu(gClient->GetRoot()); 146 sizemenu->AddEntry("Fit to 640x&480", kSize640); 147 sizemenu->AddEntry("Fit to 800x&600", kSize800); 148 sizemenu->AddEntry("Fit to 960x7&20", kSize960); 149 sizemenu->AddEntry("Fit to 1024x&768", kSize1024); 150 sizemenu->AddEntry("Fit to 1280x&1024", kSize1280); 151 sizemenu->Associate(this); 137 152 138 153 // … … 143 158 menubar->AddPopup("&Tab", tabmenu, NULL); 144 159 menubar->AddPopup("&Loop", loopmenu, NULL); 160 menubar->AddPopup("&Size", sizemenu, NULL); 145 161 menubar->BindKeys(this); 146 162 AddFrame(menubar); … … 160 176 fList->Add(filemenu); 161 177 fList->Add(loopmenu); 178 fList->Add(sizemenu); 162 179 fList->Add(menubar); 163 180 fList->Add(tabmenu); … … 175 192 176 193 // Add MARS version 177 TString txt = "Official Release: V"; 178 TGLabel *l = new TGLabel(f, txt+MARSVER); 194 TGLabel *l = new TGLabel(f, Form("Official Release: V%s", MARSVER)); 179 195 fList->Add(l); 180 196 … … 184 200 185 201 // Add root version 186 txt = "Using ROOT v"; 187 l = new TGLabel(f, txt+ROOTVER); 202 l = new TGLabel(f, Form("Using ROOT v%s", ROOTVER)); 188 203 fList->Add(l); 189 204 … … 238 253 TGCompositeFrame *f = fTab->AddTab("-Logbook-"); 239 254 240 // Create TGListBox for logging contents241 fLogBox = new TGListBox(f, 1, 1);242 fLogBox->ChangeBackground(TGFrame::GetBlackPixel());255 // Create TGListBox(p, id=-1, opt, back) for logging contents 256 fLogBox = new TGListBox(f, -1, kSunkenFrame); 257 //fLogBox->Associate(this); 243 258 244 259 // Add List box to the tab 245 TGLayoutHints *lay = new TGLayoutHints(kLHintsNormal|kLHintsExpandX|kLHintsExpandY );//, 5, 6, 5);260 TGLayoutHints *lay = new TGLayoutHints(kLHintsNormal|kLHintsExpandX|kLHintsExpandY,2,2,2,2); 246 261 f->AddFrame(fLogBox, lay); 247 262 … … 373 388 void MStatusDisplay::SetStatusLine2(const MParContainer &cont) 374 389 { 375 TString txt = cont.GetDescriptor(); 376 txt += ": "; 377 txt += cont.GetTitle(); 378 379 SetStatusLine2(txt); 390 SetStatusLine2(Form("%s: %s", cont.GetDescriptor(), cont.GetTitle())); 380 391 } 381 392 … … 406 417 // set the smallest and biggest size of the Main frame 407 418 // and move it to its appearance position 408 SetWMSizeHints( 640, 548, 1280, 1024, 10, 10);419 SetWMSizeHints(570, 480, 1280, 980, 1, 1); 409 420 Move(rand()%100+50, rand()%100+50); 421 //Resize(740, 600); 422 Resize(570, 480); 410 423 411 424 // … … 603 616 // via SetPrinter 'lpr -Pname' is used. 604 617 // 605 Int_t MStatusDisplay::PrintToLpr(Int_t num) const618 Int_t MStatusDisplay::PrintToLpr(Int_t num) 606 619 { 607 620 TString name = "mars"; … … 613 626 614 627 const Int_t pages = SaveAsPS(num, name); 628 629 SetStatusLine1("Printing..."); 630 SetStatusLine2(""); 631 615 632 if (!pages) 616 633 { 617 634 *fLog << warn << "MStatusDisplay::PrintToLpr: Sorry, couldn't save file as temporary postscript!" << endl; 635 SetStatusLine2("Failed!"); 618 636 return 0; 619 637 } … … 630 648 gSystem->Exec(cmd); 631 649 gSystem->Unlink(name); 650 651 SetStatusLine2(Form("Done (%dpages)", pages)); 632 652 633 653 return pages; … … 658 678 */ 659 679 case kFileSaveAsPS: 660 //cout << "FileSaveAsPS..." << endl;661 680 SaveAsPS(); 662 681 return kTRUE; 663 /* 682 664 683 case kFileSaveAsGIF: 665 cout << "FileSaveAsGIF..." << endl;666 684 SaveAsGIF(); 667 685 return kTRUE; 668 686 669 687 case kFileSaveAsC: 670 cout << "FileSaveAsC..." << endl;671 688 SaveAsC(); 672 689 return kTRUE; 673 */ 690 674 691 case kFileSaveAsRoot: 675 692 SaveAsRoot(); … … 683 700 SaveAsPS(fTab->GetCurrent()); 684 701 return kTRUE; 685 /* 702 686 703 case kTabSaveAsGIF: 687 cout << "TabSaveAsGIF... " << fTab->GetCurrent() << endl;688 704 SaveAsGIF(fTab->GetCurrent()); 689 705 return kTRUE; 690 706 691 707 case kTabSaveAsC: 692 cout << "TabSaveAsC... " << fTab->GetCurrent() << endl;693 708 SaveAsC(fTab->GetCurrent()); 694 709 return kTRUE; 695 */ 710 696 711 case kTabSaveAsRoot: 697 712 SaveAsRoot(fTab->GetCurrent()); … … 710 725 return kTRUE; 711 726 727 case kSize640: 728 Resize(570, 480); 729 return kTRUE; 730 case kSize800: 731 Resize(740, 600); 732 return kTRUE; 733 case kSize960: 734 Resize(880, 700); 735 return kTRUE; 736 case kSize1024: 737 Resize(980, 768); 738 return kTRUE; 739 case kSize1280: 740 Resize(1280, 980); 741 return kTRUE; 742 712 743 default: 713 cout << "Command-Menu : Id=" << id << endl;744 cout << "Command-Menu #" << id << endl; 714 745 } 715 746 return kTRUE; … … 726 757 { 727 758 case kCM_MENU: 728 return ProcessMessageCommandMenu(mp1); 759 return ProcessMessageCommandMenu(mp1); // mp2=userdata 729 760 730 761 case kCM_MENUSELECT: 731 cout << "Menuselect #" << mp1 << endl; 762 cout << "Command-Menuselect #" << mp1 << " (UserData=" << (void*)mp2 << ")" << endl; 763 return kTRUE; 764 765 case kCM_BUTTON: 766 cout << "Command-Button." << endl; 767 return kTRUE; 768 769 case kCM_CHECKBUTTON: 770 cout << "Command-CheckButton." << endl; 771 return kTRUE; 772 773 case kCM_RADIOBUTTON: 774 cout << "Command-RadioButton." << endl; 775 return kTRUE; 776 777 case kCM_LISTBOX: 778 cout << "Command-Listbox #" << mp1 << " (LineId #" << mp2 << ")" << endl; 779 return kTRUE; 780 781 case kCM_COMBOBOX: 782 cout << "Command-ComboBox." << endl; 732 783 return kTRUE; 733 784 … … 764 815 Bool_t MStatusDisplay::ProcessMessage(Long_t msg, Long_t mp1, Long_t mp2) 765 816 { 817 // Can be found in WidgetMessageTypes.h 766 818 switch (GET_MSG(msg)) 767 819 { … … 1005 1057 TObject *obj; 1006 1058 1059 // See also TPad::UseCurrentStyle 1007 1060 TIter Next(p.GetListOfPrimitives()); 1008 1061 while ((obj=Next())) … … 1036 1089 } 1037 1090 1091 Bool_t MStatusDisplay::CheckTabForCanvas(int num) const 1092 { 1093 if (num>=fTab->GetNumberOfTabs()) 1094 { 1095 *fLog << warn << "Tab #" << num << " doesn't exist..." << endl; 1096 return kFALSE; 1097 } 1098 if (num==0) 1099 { 1100 *fLog << warn << "Tab #" << num << " doesn't contain an embedded canvas..." << endl; 1101 return kFALSE; 1102 } 1103 if (fTab->GetNumberOfTabs()<2 || !gPad) 1104 { 1105 *fLog << warn << "Sorry, you must have at least one existing canvas (gPad!=NULL)" << endl; 1106 return kFALSE; 1107 } 1108 return kTRUE; 1109 } 1110 1038 1111 // -------------------------------------------------------------------------- 1039 1112 // … … 1046 1119 // To write all tabs you can also use SaveAsPS(name) 1047 1120 // 1048 Int_t MStatusDisplay::SaveAsPS(Int_t num, TString name) const 1049 { 1050 if (num>=fTab->GetNumberOfTabs()) 1051 { 1052 *fLog << warn << "Tab #" << num << " doesn't exist..." << endl; 1053 return 0; 1054 } 1055 if (num==0) 1056 { 1057 *fLog << warn << "Tab #" << num << " doesn't contain an embedded canvas..." << endl; 1058 return 0; 1059 } 1060 if (fTab->GetNumberOfTabs()<2 || !gPad) 1061 { 1062 *fLog << warn << "Sorry, you must have at least one existing canvas (gPad!=NULL)" << endl; 1121 Int_t MStatusDisplay::SaveAsPS(Int_t num, TString name) 1122 { 1123 SetStatusLine1("Writing Postscript file..."); 1124 SetStatusLine2(""); 1125 1126 if (!CheckTabForCanvas(num)) 1127 { 1128 SetStatusLine2("Failed!"); 1063 1129 return 0; 1064 1130 } … … 1107 1173 continue; 1108 1174 } 1175 1176 SetStatusLine2(Form("Tab #%d", i)); 1109 1177 1110 1178 // … … 1186 1254 *fLog << inf << "done." << endl; 1187 1255 1256 SetStatusLine2(Form("Done (%dpages)", page-1)); 1257 1188 1258 return page-1; 1189 1259 } 1190 1260 1191 /* 1192 void MStatusDisplay::SaveAsGIF(Int_t num, TString name) const 1193 { 1261 Bool_t MStatusDisplay::SaveAsGIF(Int_t num, TString name) 1262 { 1263 SetStatusLine1("Writing GIF file..."); 1264 SetStatusLine2(""); 1265 1266 if (!CheckTabForCanvas(num)) 1267 { 1268 SetStatusLine2("Failed!"); 1269 return 0; 1270 } 1271 1194 1272 AddExtension(name, "gif", num); 1195 1273 1196 cout << "Open gif-File: " << name << endl; 1197 cout << " SORRY, not implemented." << endl; 1198 } 1199 1200 void MStatusDisplay::SaveAsC(Int_t num, TString name) const 1201 { 1274 if (num<0) 1275 *fLog << inf << "Writing gif-Files..." << endl; 1276 1277 TPad *padsav = (TPad*)gPad; 1278 1279 int page = 1; 1280 1281 // 1282 // Maintain tab numbers 1283 // 1284 const Int_t from = num<0 ? 1 : num; 1285 const Int_t to = num<0 ? fTab->GetNumberOfTabs() : num+1; 1286 1287 for (int i=from; i<to; i++) 1288 { 1289 TCanvas *c; 1290 if (!(c = GetCanvas(i))) 1291 { 1292 if (num<0) 1293 *fLog << inf << " - "; 1294 *fLog << "Tab #" << i << " doesn't contain an embedded Canvas... skipped." << endl; 1295 continue; 1296 } 1297 1298 SetStatusLine2(Form("Tab #%d", i)); 1299 1300 // 1301 // Clone canvas and change background color and schedule for 1302 // deletion 1303 // 1304 //TCanvas *n = (TCanvas*)c->Clone(); 1305 //CanvasSetFillColor(*n, kWhite); 1306 1307 // 1308 // Paint canvas into root file 1309 // 1310 TString writename = name; 1311 if (num<0) 1312 { 1313 TString numname = "-"; 1314 numname += i; 1315 writename.Insert(name.Last('.'), numname); 1316 } 1317 if (num<0) 1318 *fLog << inf << " - "; 1319 *fLog << inf << "Writing Tab #" << i << " to " << writename << ": " << c->GetName() << " (" << c << ") "; 1320 if (num>0) 1321 *fLog << "to " << name; 1322 *fLog << "..." << flush; 1323 1324 c->Draw(); 1325 c->SaveAs(writename); 1326 /* 1327 n->Draw(); 1328 n->SaveAs(writename); 1329 delete n; 1330 */ 1331 1332 if (num<0) 1333 *fLog << "done." << endl; 1334 } 1335 1336 padsav->cd(); 1337 1338 *fLog << inf << "done." << endl; 1339 1340 SetStatusLine2("Done."); 1341 1342 return page-1; 1343 } 1344 1345 Bool_t MStatusDisplay::SaveAsC(Int_t num, TString name) 1346 { 1347 SetStatusLine1("Writing C++ file..."); 1348 SetStatusLine2(""); 1349 1350 if (!CheckTabForCanvas(num)) 1351 { 1352 SetStatusLine2("Failed!"); 1353 return 0; 1354 } 1355 1202 1356 AddExtension(name, "C", num); 1203 1357 1204 cout << "Open C-File: " << name << endl; 1205 cout << " SORRY, not implemented." << endl; 1206 } 1207 */ 1358 if (num<0) 1359 *fLog << inf << "Writing C-Files..." << endl; 1360 1361 TPad *padsav = (TPad*)gPad; 1362 1363 int page = 1; 1364 1365 // 1366 // Maintain tab numbers 1367 // 1368 const Int_t from = num<0 ? 1 : num; 1369 const Int_t to = num<0 ? fTab->GetNumberOfTabs() : num+1; 1370 1371 for (int i=from; i<to; i++) 1372 { 1373 TCanvas *c; 1374 if (!(c = GetCanvas(i))) 1375 { 1376 if (num<0) 1377 *fLog << inf << " - "; 1378 *fLog << "Tab #" << i << " doesn't contain an embedded Canvas... skipped." << endl; 1379 continue; 1380 } 1381 1382 SetStatusLine2(Form("Tab #%d", i)); 1383 1384 // 1385 // Clone canvas and change background color and schedule for 1386 // deletion 1387 // 1388 TCanvas *n = (TCanvas*)c->Clone(); 1389 CanvasSetFillColor(*n, kWhite); 1390 1391 // 1392 // Paint canvas into root file 1393 // 1394 TString writename = name; 1395 if (num<0) 1396 { 1397 TString numname = "-"; 1398 numname += i; 1399 writename.Insert(name.Last('.'), numname); 1400 } 1401 if (num<0) 1402 *fLog << inf << " - "; 1403 *fLog << inf << "Writing Tab #" << i << " to " << writename << ": " << c->GetName() << " (" << n << ") "; 1404 if (num>0) 1405 *fLog << "to " << name; 1406 *fLog << "..." << flush; 1407 1408 n->SaveSource(writename, ""); 1409 delete n; 1410 1411 if (num<0) 1412 *fLog << "done." << endl; 1413 } 1414 1415 padsav->cd(); 1416 1417 *fLog << inf << "done." << endl; 1418 1419 SetStatusLine2("Done."); 1420 1421 return page-1; 1422 } 1208 1423 1209 1424 // -------------------------------------------------------------------------- … … 1219 1434 Int_t MStatusDisplay::SaveAsRoot(Int_t num, TString name) 1220 1435 { 1221 if (num>=fTab->GetNumberOfTabs()) 1222 { 1223 *fLog << warn << "Tab #" << num << " doesn't exist..." << endl; 1224 return 0; 1225 } 1226 if (num==0) 1227 { 1228 *fLog << warn << "Tab #" << num << " doesn't contain an embedded canvas..." << endl; 1229 return 0; 1230 } 1231 if (fTab->GetNumberOfTabs()<2 || !gPad) 1232 { 1233 *fLog << warn << "Sorry, you must have at least one existing canvas." << endl; 1436 SetStatusLine1("Writing root file..."); 1437 SetStatusLine2(""); 1438 1439 if (!CheckTabForCanvas(num)) 1440 { 1441 SetStatusLine2("Failed!"); 1234 1442 return 0; 1235 1443 } … … 1242 1450 gFile = fsave; 1243 1451 1452 SetStatusLine2("Done."); 1453 1244 1454 return keys; 1245 1455 } 1456 1457 Bool_t MStatusDisplay::HandleConfigureNotify(Event_t *evt) 1458 { 1459 //cout << "----- Start -----" << endl; 1460 1461 UInt_t w = evt->fWidth; 1462 UInt_t h = evt->fHeight; 1463 1464 //cout << "Old: " << GetWidth() << " " << GetHeight() << " " << GetBorderWidth() << endl; 1465 //cout << "New: " << w << " " << h << endl; 1466 1467 Bool_t wchanged = w!=GetWidth(); 1468 Bool_t hchanged = h!=GetHeight(); 1469 1470 if (!wchanged && !hchanged) 1471 { 1472 Layout(); 1473 return kTRUE; 1474 } 1475 1476 if (GetWidth()==1 && GetHeight()==1) 1477 return kTRUE; 1478 1479 // calculate the constant part of the window 1480 const UInt_t cw = GetWidth() -fTab->GetWidth(); 1481 const UInt_t ch = GetHeight()-fTab->GetHeight(); 1482 1483 // canculate new size of frame (canvas @ 1:sqrt(2)) 1484 if (hchanged) 1485 w = (UInt_t)((h-ch)*sqrt(2)+.5)+cw; 1486 else 1487 h = (UInt_t)((w-cw)/sqrt(2)+.5)+ch; 1488 1489 //cout << "Res: " << w << " " << h << " " << evt->fX << " " << evt->fY << endl; 1490 1491 // resize frame 1492 Resize(w, h); 1493 1494 return kTRUE; 1495 } 1496 1497 Bool_t MStatusDisplay::HandleEvent(Event_t *event) 1498 { 1499 /* 1500 if (event->fType!=9) 1501 { 1502 cout << "Event: " << event->fType << " "; 1503 cout << event->fX << " " << event->fY << endl; 1504 } 1505 */ 1506 /* 1507 switch (event->fType) { 1508 case kConfigureNotify: 1509 //while (gVirtualX->CheckEvent(fId, kConfigureNotify, *event)) 1510 // ; 1511 HandleConfigureNotify(event); 1512 return kTRUE; 1513 } 1514 */ 1515 // if (event->fType==kConfigureNotify && event->fX!=0 && event->fY!=0) 1516 // return kTRUE; 1517 1518 return TGMainFrame::HandleEvent(event); 1519 } -
trunk/MagicSoft/Mars/mmain/MStatusDisplay.h
r2015 r2052 51 51 kTabNext, 52 52 kTabPrevious, 53 kSize640, 54 kSize800, 55 kSize960, 56 kSize1024, 57 kSize1280, 53 58 kFileExit, 54 59 kPicMagic, … … 89 94 Bool_t ProcessMessage(Long_t msg, Long_t mp1, Long_t mp2); 90 95 void CloseWindow(); 96 Bool_t HandleConfigureNotify(Event_t *); 97 Bool_t HandleEvent(Event_t *event); 91 98 92 99 Bool_t HandleTimer(TTimer *timer=NULL); … … 135 142 void SetNoContextMenu(Bool_t flag=kTRUE); 136 143 137 Int_t SaveAsPS(TString name="") const{ return SaveAsPS(-1, name); }138 //Bool_t SaveAsGIF(TString name="") const{ return SaveAsGIF(-1, name); }139 //Bool_t SaveAsC(TString name="") const{ return SaveAsC(-1, name); }140 Int_t SaveAsRoot(TString name="") { return SaveAsRoot(-1, name); }141 Int_t PrintToLpr() const{ return PrintToLpr(-1); }144 Int_t SaveAsPS(TString name="") { return SaveAsPS(-1, name); } 145 Bool_t SaveAsGIF(TString name="") { return SaveAsGIF(-1, name); } 146 Bool_t SaveAsC(TString name="") { return SaveAsC(-1, name); } 147 Int_t SaveAsRoot(TString name="") { return SaveAsRoot(-1, name); } 148 Int_t PrintToLpr() { return PrintToLpr(-1); } 142 149 143 Int_t SaveAsPS(Int_t num, TString name="") const;144 //Bool_t SaveAsGIF(Int_t num, TString name="") const;145 //Bool_t SaveAsC(Int_t num, TString name="") const;146 Int_t SaveAsRoot(Int_t num, TString name="");147 Int_t PrintToLpr(Int_t num) const;150 Int_t SaveAsPS(Int_t num, TString name=""); 151 Bool_t SaveAsGIF(Int_t num, TString name=""); 152 Bool_t SaveAsC(Int_t num, TString name=""); 153 Int_t SaveAsRoot(Int_t num, TString name=""); 154 Int_t PrintToLpr(Int_t num); 148 155 149 156 Status_t CheckStatus() const { return fStatus; } … … 153 160 void UnLock() { ResetBit(kIsLocked); } 154 161 162 Bool_t CheckTabForCanvas(int num) const; 163 155 164 ClassDef(MStatusDisplay, 0) // Window for a status display 156 165 };
Note:
See TracChangeset
for help on using the changeset viewer.