Changeset 1965 for trunk/MagicSoft/Mars/mbase
- Timestamp:
- 04/19/03 18:39:05 (22 years ago)
- Location:
- trunk/MagicSoft/Mars/mbase
- Files:
-
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/MagicSoft/Mars/mbase/MEvtLoop.cc
r1902 r1965 46 46 // Afterwards the PostProcess functions are executed. // 47 47 // // 48 // // 49 // Maybe we can add a TProgressMeter sometimes later to be able to show // 50 // the progress graphically... // 51 // // 48 // If you want to display the progress in a gui you can use SetProgressBar // 49 // and a TGProgressBar or a MProgressBar. If you set a MStatusDisplay // 50 // using SetDisplay, the Progress bar from this display is used. // 52 51 // // 53 52 // You can create a macro from a completely setup eventloop by: // … … 74 73 #include <iostream.h> 75 74 75 #include <TTime.h> // TTime 76 76 #include <TFile.h> // gFile 77 77 #include <TSystem.h> // gSystem … … 87 87 #include "MRead.h" // for setting progress bar 88 88 #include "MProgressBar.h" // MProgressBar::GetBar 89 #include "MStatusDisplay.h" // MStatusDisplay::GetBar 89 90 #endif 90 91 … … 101 102 // -------------------------------------------------------------------------- 102 103 // 103 // default constructor - emty104 // default constructor 104 105 // 105 106 MEvtLoop::MEvtLoop(const char *name) : fParList(NULL), fProgress(NULL) … … 112 113 // -------------------------------------------------------------------------- 113 114 // 114 // de fault destructor - emty115 // destructor 115 116 // 116 117 MEvtLoop::~MEvtLoop() … … 171 172 if (fLog != &gLog) 172 173 fParList->SetLogStream(fLog); 174 175 #ifdef __MARS__ 176 // 177 // Check whether display is still existing 178 // 179 if (fDisplay && !gROOT->GetListOfSpecials()->FindObject(fDisplay)) 180 fDisplay = NULL; 181 if (fDisplay) 182 { 183 // Lock display to prevent user from deleting it 184 fDisplay->Lock(); 185 // Get pointer to update Progress bar 186 fProgress = fDisplay->GetBar(); 187 // Don't display context menus 188 fDisplay->SetNoContextMenu(); 189 // Set window and icon name 190 fDisplay->SetWindowName(TString("Status Display: ")+fName); 191 fDisplay->SetIconName(fName); 192 // Set status lines 193 fDisplay->SetStatusLine1("PreProcessing..."); 194 fDisplay->SetStatusLine2(""); 195 // Start automatic update 196 fDisplay->StartUpdate(); 197 // Cascade display through childs 198 fParList->SetDisplay(fDisplay); 199 } 200 #endif 173 201 174 202 // … … 188 216 } 189 217 218 Bool_t MEvtLoop::ProcessGuiEvents(Int_t num) 219 { 220 if (!fProgress) 221 return kTRUE; 222 223 // 224 // Check status of display 225 // 226 Bool_t rc = kTRUE; 227 228 if (fDisplay) 229 switch (fDisplay->CheckStatus()) 230 { 231 case MStatusDisplay::kLoopNone: 232 break; 233 case MStatusDisplay::kLoopStop: 234 rc = kFALSE; 235 fDisplay->ClearStatus(); 236 break; 237 case MStatusDisplay::kFileExit: 238 fParList->SetDisplay(NULL); 239 delete fDisplay; 240 SetDisplay(NULL); 241 fProgress = NULL; 242 gSystem->ProcessEvents(); 243 return kTRUE; 244 default: 245 fDisplay->ClearStatus(); 246 *fLog << warn << "Display shows unknown status... cleared." << endl; 247 break; 248 } 249 250 // 251 // Check System time (don't loose too much time by updates) 252 // 253 static TTime t0 = gSystem->Now(); 254 255 const TTime t1 = gSystem->Now(); 256 if (t1-t0 < (TTime)20) 257 return rc; 258 259 t0 = t1; 260 261 // 262 // Set new progress bar position 263 // 264 fProgress->SetPosition(num); 265 266 // 267 // Handle GUI events (display changes) 268 // 269 #if ROOT_VERSION_CODE < ROOT_VERSION(3,02,06) 270 gSystem->ProcessEvents(); 271 #else 272 if (fDisplay) 273 gSystem->ProcessEvents(); 274 else 275 gClient->ProcessEventsFor(fProgress); 276 #endif 277 278 return rc; 279 } 280 190 281 // -------------------------------------------------------------------------- 191 282 // … … 193 284 // for developers or use in special jobs only! 194 285 // 195 Bool_t MEvtLoop::Process(Int_t maxcnt) const286 Bool_t MEvtLoop::Process(Int_t maxcnt) 196 287 { 197 288 // … … 208 299 *fLog << " events)..." << flush; 209 300 301 Int_t entries = INT_MAX; 302 210 303 if (fProgress) 211 304 { 212 305 fProgress->Reset(); 213 214 Int_t entries = INT_MAX;215 216 306 #ifdef __MARS__ 217 307 // limits.h … … 228 318 } 229 319 320 if (fDisplay) 321 { 322 fDisplay->SetStatusLine1("Processing..."); 323 fDisplay->SetStatusLine2(""); 324 } 325 230 326 Int_t dummy = maxcnt<0 ? 0 : maxcnt; 231 327 … … 246 342 if (maxcnt<0) 247 343 // process first and increment if sucessfull 248 if (fProgress) 249 while ((rc=fTaskList->Process())==kTRUE) 250 { 251 fProgress->SetPosition(++dummy); 252 #if ROOT_VERSION_CODE < ROOT_VERSION(3,02,06) 253 gSystem->ProcessEvents(); 254 #else 255 gClient->ProcessEventsFor(fProgress); 256 #endif 257 numcnts++; 258 } 259 else 260 while ((rc=fTaskList->Process())==kTRUE) numcnts++; 344 while ((rc=fTaskList->Process())==kTRUE) 345 { 346 numcnts++; 347 if (!ProcessGuiEvents(++dummy)) 348 break; 349 } 261 350 else 262 351 // check for number and break if unsuccessfull 263 if (fProgress) 264 while (dummy-- && (rc=fTaskList->Process())==kTRUE) 265 { 266 fProgress->SetPosition(maxcnt - dummy); 352 while (dummy-- && (rc=fTaskList->Process())==kTRUE) 353 { 354 numcnts++; 355 if (!ProcessGuiEvents(maxcnt - dummy)) 356 break; 357 } 358 359 // 360 // stop stop-watch, print results 361 // 362 clock.Stop(); 363 364 if (fProgress) 365 { 366 fProgress->SetPosition(maxcnt>0 ? TMath::Min(maxcnt, entries) : entries); 267 367 #if ROOT_VERSION_CODE < ROOT_VERSION(3,02,06) 268 368 gSystem->ProcessEvents(); 269 369 #else 270 gClient->ProcessEventsFor(fProgress);370 gClient->ProcessEventsFor(fDisplay ? fDisplay : fProgress); 271 371 #endif 272 numcnts++; 273 } 274 else 275 while (dummy-- && (rc=fTaskList->Process())==kTRUE) numcnts++; 276 277 // 278 // stop stop-watch, print results 279 // 280 clock.Stop(); 372 } 281 373 282 374 *fLog << all << "Ready!" << endl << endl; … … 306 398 // execute the post process of all tasks 307 399 // 400 if (fDisplay) 401 { 402 // Set status lines 403 fDisplay->SetStatusLine1("PostProcessing..."); 404 fDisplay->SetStatusLine2(""); 405 } 308 406 return fTaskList->PostProcess(); 309 407 } … … 329 427 if (!PostProcess()) 330 428 return kFALSE; 429 430 if (!fDisplay) 431 return rc; 432 433 // Set status lines 434 fDisplay->SetStatusLine1(fName); 435 fDisplay->SetStatusLine2(rc ? "Done." : "ERROR"); 436 // Stop automatic update 437 fDisplay->StopUpdate(); 438 // Reallow context menus 439 fDisplay->SetNoContextMenu(kFALSE); 440 // Reallow user to exit window by File menu 441 fDisplay->UnLock(); 331 442 332 443 // -
trunk/MagicSoft/Mars/mbase/MEvtLoop.h
r1880 r1965 27 27 MTaskList *fTaskList; //! 28 28 29 TGProgressBar *fProgress; //!29 TGProgressBar *fProgress; //! 30 30 31 31 enum { kIsOwner = BIT(14) }; … … 35 35 36 36 void StreamPrimitive(ofstream &out) const; 37 38 Bool_t ProcessGuiEvents(Int_t num); 37 39 38 40 public: … … 44 46 MTaskList *GetTaskList() const { return fTaskList; } 45 47 48 MStatusDisplay *GetDisplay() { return fDisplay; } 49 46 50 void SetOwner(Bool_t enable=kTRUE); 47 51 … … 52 56 53 57 Bool_t PreProcess(const char *tlist="MTaskList"); 54 Bool_t Process(Int_t maxcnt) const;58 Bool_t Process(Int_t maxcnt); 55 59 Bool_t PostProcess() const; 56 60 -
trunk/MagicSoft/Mars/mbase/MParContainer.cc
r1902 r1965 37 37 #include "MParContainer.h" 38 38 39 #include <ctype.h> // isdigit40 #include <fstream.h> // ofstream, AsciiWrite41 42 #include <TEnv.h> // Env::Lookup43 #include <TClass.h> // IsA44 #include <TObjArray.h> // TObjArray45 #include <TBaseClass.h> // GetClassPointer46 #include <TMethodCall.h> // TMethodCall, AsciiWrite47 #include <TDataMember.h> // TDataMember, AsciiWrite48 #include <TVirtualPad.h> // gPad39 #include <ctype.h> // isdigit 40 #include <fstream.h> // ofstream, AsciiWrite 41 42 #include <TEnv.h> // Env::Lookup 43 #include <TClass.h> // IsA 44 #include <TObjArray.h> // TObjArray 45 #include <TBaseClass.h> // GetClassPointer 46 #include <TMethodCall.h> // TMethodCall, AsciiWrite 47 #include <TDataMember.h> // TDataMember, AsciiWrite 48 #include <TVirtualPad.h> // gPad 49 49 50 50 #include "MLog.h" … … 52 52 53 53 #ifndef __COSY__ 54 #include "MEvtLoop.h" // gListOfPrimitives54 #include "MEvtLoop.h" // gListOfPrimitives 55 55 #else 56 56 TList *gListOfPrimitives; // forard declaration in MParContainer.h … … 71 71 72 72 fReadyToSave = named.fReadyToSave; 73 74 fDisplay = named.fDisplay; 73 75 } 74 76 -
trunk/MagicSoft/Mars/mbase/MParContainer.h
r1902 r1965 26 26 class TDataMember; 27 27 class TMethodCall; 28 class MStatusDisplay; 28 29 29 30 class MParContainer : public TObject … … 34 35 35 36 MLog *fLog; // The general log facility for this object, initialized with the global object 37 38 MStatusDisplay *fDisplay; 36 39 37 40 private: … … 49 52 }; 50 53 51 MParContainer(const char *name="", const char *title="") : fName(name), fTitle(title), fLog(&gLog), f ReadyToSave(kFALSE) { }52 MParContainer(const TString &name, const TString &title) : fName(name), fTitle(title), fLog(&gLog), f ReadyToSave(kFALSE) { }54 MParContainer(const char *name="", const char *title="") : fName(name), fTitle(title), fLog(&gLog), fDisplay(NULL), fReadyToSave(kFALSE) { } 55 MParContainer(const TString &name, const TString &title) : fName(name), fTitle(title), fLog(&gLog), fDisplay(NULL), fReadyToSave(kFALSE) { } 53 56 MParContainer(const MParContainer &named); 54 57 MParContainer& operator=(const MParContainer& rhs); … … 64 67 virtual void FillBuffer(char *&buffer); 65 68 66 virtual const char *GetDescriptor() const { return Form("%s [%s]", fName.Data(), ClassName()); }69 virtual const char *GetDescriptor() const { return fName==ClassName() ? ClassName() : Form("%s [%s]", fName.Data(), ClassName()); } 67 70 virtual const TString GetUniqueName() const; 68 71 virtual const char *GetName() const { return fName.Data(); } … … 87 90 virtual void EnableGraphicalOutput(Bool_t flag=kTRUE) { flag ? SetBit(kEnableGraphicalOutput) : ResetBit(kEnableGraphicalOutput);} 88 91 virtual Bool_t IsGraphicalOutputEnabled() const { return TestBit(kEnableGraphicalOutput); } 92 93 virtual void SetDisplay(MStatusDisplay *d) { fDisplay = d; } 89 94 90 95 TMethodCall *GetterMethod(const char *name) const; -
trunk/MagicSoft/Mars/mbase/MParList.cc
r1902 r1965 138 138 } 139 139 140 void MParList::SetDisplay(MStatusDisplay *d) 141 { 142 fContainer->ForEach(MParContainer, SetDisplay)(d); 143 MParContainer::SetDisplay(d); 144 } 145 140 146 // -------------------------------------------------------------------------- 141 147 // … … 149 155 // check if the object (you want to add) exists 150 156 // 151 152 157 if (!cont) 153 158 return kFALSE; -
trunk/MagicSoft/Mars/mbase/MParList.h
r1880 r1965 50 50 51 51 void SetLogStream(MLog *log); 52 void SetDisplay(MStatusDisplay *d); 52 53 53 54 TObject *FindObject(const char *name) const; -
trunk/MagicSoft/Mars/mbase/MTaskList.cc
r1935 r1965 57 57 #include "MTaskList.h" 58 58 59 #include <fstream.h> // ofstream, SavePrimitive59 #include <fstream.h> // ofstream, SavePrimitive 60 60 61 61 #include <TClass.h> … … 70 70 #include "MInputStreamID.h" 71 71 72 #include "MStatusDisplay.h" 73 72 74 ClassImp(MTaskList); 73 75 … … 133 135 fTasks->ForEach(MTask, SetLogStream)(log); 134 136 MParContainer::SetLogStream(log); 137 } 138 139 void MTaskList::SetDisplay(MStatusDisplay *d) 140 { 141 fTasks->ForEach(MTask, SetDisplay)(d); 142 MParContainer::SetDisplay(d); 135 143 } 136 144 … … 350 358 // 351 359 Bool_t MTaskList::PreProcess(MParList *pList) 352 { 360 { 353 361 *fLog << all << "Preprocessing... " << flush; 354 362 … … 370 378 { 371 379 *fLog << all << task->GetName() << "... " << flush; 380 if (fDisplay) 381 fDisplay->SetStatusLine2(*task); 372 382 373 383 // … … 539 549 { 540 550 *fLog << all << task->GetName() << "... " << flush; 551 if (fDisplay) 552 fDisplay->SetStatusLine2(*task); 541 553 542 554 if (!task->CallPostProcess()) -
trunk/MagicSoft/Mars/mbase/MTaskList.h
r1935 r1965 44 44 45 45 void SetLogStream(MLog *log); 46 void SetDisplay(MStatusDisplay *d); 46 47 47 48 Bool_t AddToListBefore(MTask *task, const MTask *where, const char *tType="All");
Note:
See TracChangeset
for help on using the changeset viewer.