Logo ROOT   6.08/07
Reference Guide
TRecorder.h
Go to the documentation of this file.
1 // @(#)root/gui:$Id$
2 // Author: Katerina Opocenska 11/09/2008
3 
4 /*************************************************************************
5 * Copyright (C) 1995-2008, Rene Brun and Fons Rademakers. *
6 * All rights reserved. *
7 * *
8 * For the licensing terms see $ROOTSYS/LICENSE. *
9 * For the list of contributors see $ROOTSYS/README/CREDITS. *
10 *************************************************************************/
11 
12 #ifndef ROOT_TRecorder
13 #define ROOT_TRecorder
14 
15 //////////////////////////////////////////////////////////////////////////
16 // //
17 // ROOT EVENT RECORDING SYSTEM //
18 // ================================================================== //
19 // //
20 // TRecorder class provides interface for recording and replaying //
21 // events in ROOT. //
22 // Recorded events are: //
23 // - Commands typed by user in commandline ('new TCanvas') //
24 // - GUI events (mouse movement, button clicks, ...) //
25 // //
26 // All the recorded events from one session are stored in one TFile //
27 // and can be replayed again anytime. //
28 // //
29 // Recording //
30 // ================================================================== //
31 // //
32 // 1] To start recording //
33 // //
34 // TRecorder r(const char *filename, "NEW") //
35 // TRecorder r(const char *filename, "RECREATE") //
36 // //
37 // or: //
38 // //
39 // TRecorder *recorder = new TRecorder; //
40 // recorder->Start(const char *filename, ...) //
41 // //
42 // -filename Name of ROOT file in which to save //
43 // recorded events. //
44 // //
45 // 2] To stop recording //
46 // //
47 // recorder->Stop() //
48 // //
49 // //
50 // IMPORTANT: //
51 // State capturing is part of recording. It means that if you want to //
52 // record events for some object (window), creation of this object //
53 // must be also recorded. //
54 // //
55 // Example: //
56 // -------- //
57 // t = new TRecorder(); // Create a new recorder //
58 // t->Start("logfile.root"); // ! Start recording first //
59 // //
60 // c = new TCanvas(); // ! Then, create an object //
61 // c->Dump(); // Work with that object //
62 // //
63 // t->Stop(); // Stop recording //
64 // //
65 // It is strongly recommended to start recording with empty ROOT //
66 // environment, at least with no previously created ROOT GUI. //
67 // This ensures that only events for well known windows are stored. //
68 // Events for windows, which were not created during recording, //
69 // cannot be replayed. //
70 // //
71 // Replaying //
72 // =================================================================== //
73 // //
74 // 1] To start replaying //
75 // //
76 // TRecorder r(const char *filename) //
77 // TRecorder r(const char *filename, "READ") //
78 // //
79 // or: //
80 // //
81 // TRecorder *recorder = new TRecorder; //
82 // recorder->Replay(const char *filename, //
83 // Bool_t showMouseCursor = kTRUE); //
84 // //
85 // -filename A name of file with recorded events //
86 // previously created with TRecorder::Start //
87 // //
88 // -showMouseCursor If kTRUE, mouse cursor is replayed as well. //
89 // In that case it is not recommended to use mouse //
90 // during replaying. //
91 // //
92 // In general, it is not recommended to use mouse to change positions //
93 // and states of ROOT windows during replaying. //
94 // //
95 // IMPORTANT: //
96 // The state of ROOT environment before replaying of some events //
97 // must be exactly the same as before recording them. //
98 // Therefore it is strongly recommended to start both recording //
99 // and replaying with empty ROOT environment. //
100 // //
101 // 2] To pause replaying //
102 // //
103 // recorder->Pause() //
104 // //
105 // Replaying is stopped until recorder->Resume() is called. //
106 // //
107 // //
108 // 3] To resume paused replaying //
109 // //
110 // recorder->Resume() //
111 // //
112 // Resumes previously stopped replaying. //
113 // //
114 // //
115 // 4] To stop replaying before its end //
116 // //
117 // recorder->Stop() //
118 // //
119 //////////////////////////////////////////////////////////////////////////
120 
121 #ifndef ROOT_Riostream
122 #include "Riostream.h"
123 #endif
124 #ifndef ROOT_TApplication
125 #include "TApplication.h"
126 #endif
127 #ifndef ROOT_TError
128 #include "TError.h"
129 #endif
130 #ifndef ROOT_TTimer
131 #include "TTimer.h"
132 #endif
133 #ifndef ROOT_TGClient
134 #include "TGClient.h"
135 #endif
136 #ifndef ROOT_TGFrame
137 #include "TGFrame.h"
138 #endif
139 #ifndef ROOT_TCanvas
140 #include "TCanvas.h"
141 #endif
142 #ifndef ROOT_THashList
143 #include "THashList.h"
144 #endif
145 
146 #include <time.h>
147 
148 class TMutex;
149 class TTree;
150 class TFile;
151 class TGPictureButton;
152 class TGCheckButton;
153 class TGLabel;
154 class TRecorderState;
155 
156 //////////////////////////////////////////////////////////////////////////
157 // //
158 // TRecEvent //
159 // //
160 // Abstract class that defines interface for a class storing //
161 // information about 1 ROOT event. //
162 // Time of event is stored and this event can be replayed. //
163 // Classes TRecCmdEvent and TRecGuiEvent implements this interface //
164 // for command line and GUI events respectively. //
165 // //
166 //////////////////////////////////////////////////////////////////////////
167 
168 class TRecEvent : public TObject
169 {
170 private:
171  TTime fEventTime; // Time of original event execution
172 
173 public:
174  //---- Types of events recorded in ROOT.
176  kCmdEvent, // Commandline event
177  kGuiEvent, // GUI event
179  };
180 
181  // Replays (executes) the stored event again
182  virtual void ReplayEvent(Bool_t showMouseCursor = kTRUE) = 0;
183 
184  // Returns what kind of event it stores
185  virtual ERecEventType GetType() const = 0;
186 
187  virtual TTime GetTime() const {
188  // Returns time of original execution of stored event
189  return fEventTime;
190  }
191 
192  virtual void SetTime(TTime t) {
193  // Sets time of event execution
194  fEventTime = t;
195  }
196 
197  ClassDef(TRecEvent,1) // Abstract class. Defines basic interface for storing information about ROOT events
198 };
199 
200 //////////////////////////////////////////////////////////////////////////
201 // //
202 // TRecCmdEvent //
203 // //
204 // Class used for storing information about 1 commandline event. //
205 // It means 1 command typed in by user in the commandline, //
206 // e.g 'new TCanvas'. //
207 // //
208 //////////////////////////////////////////////////////////////////////////
209 
210 class TRecCmdEvent : public TRecEvent
211 {
212 private:
213  TString fText; // Text of stored command
214 
215 public:
217  // Creates new empty TRecCmdEvent
218  }
219 
220  void SetText(const char *text) {
221  // Saves text of a command
222  fText = text;
223  }
224 
225  const char *GetText() const {
226  // Returns stored text of the command
227  return fText.Data();
228  }
229 
230  virtual ERecEventType GetType() const {
231  // Returns what kind of event it stores (commandline event)
232  return TRecEvent::kCmdEvent;
233  }
234 
235  virtual void ReplayEvent(Bool_t) {
236  // Stored command is executed again
237  std::cout << GetText() << std::endl;
238  gApplication->ProcessLine(GetText());
239  }
240 
241  ClassDef(TRecCmdEvent,1) // Class stores information about 1 commandline event (= 1 command typed by user in commandline)
242 };
243 
244 //////////////////////////////////////////////////////////////////////////
245 // //
246 // TRecExtraEvent //
247 // //
248 // Class used for storing information about 1 extra event. //
249 // It means 1 TPaveLabel or 1 TLatex event produced in the Canvas //
250 // //
251 //////////////////////////////////////////////////////////////////////////
252 class TRecExtraEvent : public TRecEvent
253 {
254 private:
255  TString fText; // Text of stored command
256 
257 public:
259  // Creates new empty TRecExtraEvent
260  }
261 
263  // Saves text of a command (PaveLabel or Text)
264  fText = text;
265  }
266 
267  TString GetText() const {
268  // Returns stored text of the command
269  return fText;
270  }
271 
272  virtual ERecEventType GetType() const {
273  // Returns what kind of event it stores (Especial event)
274  return TRecEvent::kExtraEvent;
275  }
276 
277  virtual void ReplayEvent(Bool_t) {
278  // Stored event is executed again
279 
280  gApplication->ProcessLine(GetText());
281  }
282 
283  ClassDef(TRecExtraEvent,1) // Class stores information about extra events
284 };
285 
286 //////////////////////////////////////////////////////////////////////////
287 // //
288 // TRecGuiEvent //
289 // //
290 // Class used for storing information about 1 GUI event in ROOT. //
291 // For list of possible GUI events see EGEventType. //
292 // //
293 //////////////////////////////////////////////////////////////////////////
294 
295 class TRecGuiEvent : public TRecEvent
296 {
297 protected:
298  friend class TRecorderInactive;
299  friend class TRecorderPaused;
300  friend class TRecorderRecording;
301  friend class TRecorderReplaying;
302 
303  EGEventType fType; // Type of event (see EGEventType)
304  Window_t fWindow; // Window ID which reported event is relative to
305  Time_t fTime; // Time event occured in ms
306  Int_t fX; // Pointer x coordinate in event window
307  Int_t fY; // Pointer y coordinate in event window
308  Int_t fXRoot; // x coordinate relative to root
309  Int_t fYRoot; // y coordinate relative to root
310  UInt_t fCode; // Key or button code
311  UInt_t fState; // Key or button mask
312  UInt_t fWidth; // Width of exposed area
313  UInt_t fHeight; // Height of exposed area
314  Int_t fCount; // If non-zero, at least this many more exposes
315  Bool_t fSendEvent; // True if event came from SendEvent
316  Handle_t fHandle; // General resource handle (used for atoms or windows)
317  Int_t fFormat; // Next fields only used by kClientMessageEvent
318  Long_t fUser[5]; // 5 longs can be used by client message events
319  // NOTE: only [0], [1] and [2] may be used.
320  // [1] and [2] may contain > 32 bit quantities
321  // (i.e. pointers on 64 bit machines)
322  Window_t fMasked; // If non-zero, event recorded in HandleMaskEvent()
323 
324 public:
325  //---- Types of kConfigureNotify GUI event
327  kCNMove = 0, // Movement of a window (Linux)
328  kCNResize = 1, // Resize of a window (Linux)
329  kCNMoveResize = 2, // Movement, resize or both (Windows)
330  kCNFilter = 3 // Not replaybale (filtered event).
331  };
332  //---- Aliases for non cross-platform atoms.
333  enum ERootAtoms {
334  kWM_DELETE_WINDOW = 10001,
335  kROOT_MESSAGE = 10002
336  };
337 
338  virtual ERecEventType GetType() const {
339  // Returns what kind of event it stores (GUI event)
340  return TRecEvent::kGuiEvent;
341  }
342 
343  virtual void ReplayEvent(Bool_t showMouseCursor = kTRUE);
344  static Event_t *CreateEvent(TRecGuiEvent *ge);
345 
346  ClassDef(TRecGuiEvent,1) // Class stores information about 1 GUI event in ROOT
347 };
348 
349 //////////////////////////////////////////////////////////////////////////
350 // //
351 // TRecWinPair //
352 // //
353 // Class used for storing of window IDs mapping. //
354 // Remapping of window IDs is needed for replaying events. //
355 // - ID of original window is stored in fKey. //
356 // - ID of a new window is stored in fValue. //
357 // //
358 // Whenever an event is replayed, its referenced window ID is changed //
359 // from original to a new one according to the appropriate mapping. //
360 // //
361 //////////////////////////////////////////////////////////////////////////
362 
363 class TRecWinPair : public TObject
364 {
365 protected:
366  friend class TRecorderReplaying;
367 
368  Window_t fKey; // ID of original window (for which an event was originally recorded)
369  Window_t fValue; // ID of a new window (for which an event is being replayed)
370 
371 public:
372  // Creates a new key-value mapping of window IDs
373  TRecWinPair(Window_t key, Window_t value): fKey(key), fValue(value) {}
374 
375  ClassDef(TRecWinPair,1) // Class used for storing of window IDs mapping. Needed for replaying events.
376 };
377 
378 //////////////////////////////////////////////////////////////////////////
379 // //
380 // TRecorder //
381 // //
382 // Class provides direct recorder/replayer interface for a user. //
383 // See 'ROOT EVENT RECORDING SYSTEM' for more information about usage. //
384 // //
385 // Implementation uses C++ design pattern State. Functionality of //
386 // recorder is divided into 4 classes according to the current //
387 // state of recorder. //
388 // //
389 // Internally, there is a pointer to TRecorderState object. //
390 // This object changes whenever state of recorder is changed. //
391 // States of recorder are the following: //
392 // //
393 // - INACTIVE Implemented in TRecorderInactive class. //
394 // Default state after TRecorder object is created. //
395 // //
396 // - RECORDING Implemented in TRecorderRecording class. //
397 // //
398 // - REPLAYING Implemented in TRecorderReplaying class. //
399 // //
400 // - PAUSED Implemented in TRecorderPause class. //
401 // Pause of replaying. //
402 // //
403 // Every command for TRecorder is just passed //
404 // to TRecordeState object. //
405 // Depending on the current state of recorder, this command is passed //
406 // to some of the above mentioned classes and if valid, handled there. //
407 // //
408 // [TRecorder.JPG] //
409 // //
410 // Switching between states is not possible from outside. States are //
411 // switched directly by state objects via: //
412 // //
413 // ChangeState(TRecorderState* newstate, Bool_t deletePreviousState); //
414 // //
415 // When recorder is switched to a new state, the old state object is //
416 // typically deleted. The only exception is switching from REPLAYING //
417 // state to PAUSED state. The previous state (REPLAYING) is not //
418 // deleted in order to be used again after TRecorder::Resume call. //
419 // //
420 // STATE TRANSITIONS: //
421 // ------------------ //
422 // //
423 // INACTIVE -> RECORDING via TRecorder::Start (Starts recording) //
424 // RECORDING -> INACTIVE via TRecorder::Stop (Stops recording) //
425 // //
426 // INACTIVE -> REPLAYING via TRecorder::Replay (Starts replaying) //
427 // REPLAYING -> INACTIVE via TRecorder::ReplayStop (Stops replaying) //
428 // //
429 // REPLAYING -> PAUSED via TRecorder::Pause (Pause replaying) //
430 // PAUSED -> REPLAYING via TRecorder::Resume (Resumes replaying) //
431 // //
432 // PAUSED -> INACTIVE via TRecorder::ReplayStop (Stops paused //
433 // replaying) //
434 // //
435 // [TRecorderStates.JPG] //
436 // //
437 //////////////////////////////////////////////////////////////////////////
438 class TRecorder : public TObject
439 {
440 private:
441  TRecorderState *fRecorderState; //! Current state of recorder
442 
443  TRecorder(const TRecorder&); // Not implemented.
444  TRecorder &operator=(const TRecorder&); // Not implemented.
445 
446 protected:
447  friend class TRecorderState;
448  friend class TRecorderInactive;
449  friend class TRecorderPaused;
450  friend class TRecorderRecording;
451  friend class TRecorderReplaying;
452 
453  TString fFilename; // Events file name
454  // Changes state to the new one.
455  // See class documentation for information about state changing.
456  void ChangeState(TRecorderState *newstate, Bool_t deletePreviousState = kTRUE);
457 
458 public:
459  //---- Modes of replaying. Only kRealtime implemented so far
461  kRealtime
462  };
463  //---- States of recorder. In every moment, recorder is in right
464  // one of these states.
469  kReplaying
470  };
471 
472  // Creates recorder and sets its state as INACTIVE
473  TRecorder();
474  TRecorder(const char *filename, Option_t *option = "READ");
475 
476  // Deletes recorder together with its current state
477  virtual ~TRecorder();
478 
479  void Browse(TBrowser *);
480 
481  // Starts recording of events to the given file
482  void Start(const char *filename, Option_t *option = "RECREATE", Window_t *w = 0, Int_t winCount = 0);
483 
484  // Stops recording of events
485  void Stop(Bool_t guiCommand = kFALSE);
486 
487  // Replays recorded events from given file
488  Bool_t Replay(const char *filename, Bool_t showMouseCursor = kTRUE, TRecorder::EReplayModes mode = kRealtime);
489 
490  // Replays recorded events from current file
491  void Replay() { Replay(fFilename); } // *MENU*
492 
493  // Pauses replaying
494  void Pause();
495 
496  // Resumes paused replaying
497  void Resume();
498 
499  // Stops (cancels) replaying
500  void ReplayStop();
501 
502  // Prints out the list of recorded commandline events
503  void ListCmd(const char *filename);
504 
505  // Prints out the list of recorded GUI events
506  void ListGui(const char *filename);
507 
508  // Gets current state of recorder
509  virtual TRecorder::ERecorderState GetState() const;
510 
511  // Saves all the canvases previous to the TRecorder
512  void PrevCanvases(const char *filename, Option_t *option);
513 
514  ClassDef(TRecorder,2) // Class provides direct recorder/replayer interface for a user.
515 };
516 
517 //////////////////////////////////////////////////////////////////////////
518 // //
519 // TRecorderState //
520 // //
521 // Abstract class that defines interface for a state of recorder. //
522 // Inherited classes are: //
523 // - TRecorderInactive //
524 // - TRecorderRecording //
525 // - TRecorderReplaying //
526 // - TRecorderPaused //
527 // //
528 // See TRecorder for more information about creating, using, //
529 // changing and deleting states. //
530 // //
531 //////////////////////////////////////////////////////////////////////////
533 {
534 protected:
535  friend class TRecorder;
536  void ChangeState(TRecorder *r, TRecorderState *s, Bool_t deletePreviousState) { r->ChangeState(s, deletePreviousState); }
537 
538 public:
539  virtual ~TRecorderState() {}
540  virtual void Start(TRecorder *, const char *, Option_t *, Window_t *, Int_t) {}
541  virtual void Stop(TRecorder *, Bool_t ) {}
542  virtual Bool_t Replay(TRecorder *, const char *, Bool_t, TRecorder::EReplayModes) { return false; }
543  virtual void Pause(TRecorder *) {}
544  virtual void Resume(TRecorder *) {}
545  virtual void ReplayStop(TRecorder *) {}
546 
547  virtual void ListCmd(const char *) {}
548  virtual void ListGui(const char *) {}
549 
550  virtual void PrevCanvases(const char *, Option_t *) {}
551 
552  virtual TRecorder::ERecorderState GetState() const = 0;
553 
554  ClassDef(TRecorderState, 0) // Abstract class that defines interface for a state of recorder
555 };
556 
557 //////////////////////////////////////////////////////////////////////////
558 // //
559 // TRecorderReplaying //
560 // //
561 // Represents state of TRecorder when replaying previously recorded //
562 // events. //
563 // //
564 // Not intended to be used by a user directly. //
565 // [Replaying.JPG] //
566 // //
567 //////////////////////////////////////////////////////////////////////////
569 {
570 private:
571  virtual ~TRecorderReplaying();
572  Bool_t PrepareNextEvent();
573  Bool_t RemapWindowReferences();
574  Bool_t CanOverlap();
575 
576  Bool_t FilterEvent(TRecGuiEvent *e);
577 
578  TRecorder *fRecorder; // Reference to recorder (owner of this state) is kept in order to switch
579  // recorder to INACTIVE state after replaying is finished
580 
581  TFile *fFile; // ROOT file which the recorded events are being read from
582 
583 
584  TCanvas *fCanv; // Used to record the previous canvases
585 
586 
587  TTimer *fTimer; // Timer used for replaying
588 
589  TTree *fWinTree; // TTree with recorded windows (=registered during recording)
590  TTree *fGuiTree; // TTree with recorded GUI events
591  TTree *fCmdTree; // TTree with recorded commandline events
592  TTree *fExtraTree; // TTree with recorded extra events (PaveLabels and Texts)
593 
594  ULong64_t fWin; // Window ID being currenty mapped
595  TRecGuiEvent *fGuiEvent; // GUI event being currently replayed
596  TRecCmdEvent *fCmdEvent; // Commandline event being currently replayed
597  TRecExtraEvent *fExtraEvent; // Extra event being currently replayed
598 
599  Int_t fRegWinCounter; // Counter of registered windows when replaying
600  Int_t fGuiTreeCounter; // Counter of GUI events that have been replayed
601  Int_t fCmdTreeCounter; // Counter of commandline events that have been replayed
602  Int_t fExtraTreeCounter; // Counter of extra events that have been replayed
603 
604  Int_t fWinTreeEntries; // Number of registered windows during _recording_
605 
607 
608  TList *fWindowList; // List of TRecWinPair objects. Mapping of window IDs is stored here.
609 
610  TRecEvent *fNextEvent; // The next event that is going to be replayed (GUI event or commandline)
611 
612  TTime fPreviousEventTime; // Execution time of the previously replayed event.
613  // It is used for computing time difference between two events.
614 
615  Bool_t fWaitingForWindow; // Signalizes that we wait for a window to be registered in order
616  // to replay the next event fNextEvent.
617  // Registraion of windows can last different time when recording and replaying.
618  // If there is an event ready to be replayed but the corresponding windows has not been yet
619  // registered, we wait (postopone fNextEvent) until it is registered.
620 
621  Bool_t fEventReplayed; // Signalizes that the last event sent to the replaying has been already replayed.
622  // Sometimes an execution of an event can take more time than during recording.
623  // This ensures that the next event is sent to replaying AFTER
624  // the replaying of the previous one finishes and not earlier.
625  // Exceptions: ButtonPress and ButtonRelease events (See TRecorderReplaying::CanBeOverlapped)
626 
627  Bool_t fShowMouseCursor; // Specifies if mouse cursor should be also replayed
628 
629  Bool_t fFilterStatusBar; // Special flag to filter status bar element
630 
631 protected:
632  friend class TRecorderInactive;
633  friend class TRecorderPaused;
634 
635  TRecorderReplaying(const char *filename);
636  Bool_t Initialize(TRecorder *r, Bool_t showMouseCursor, TRecorder::EReplayModes mode);
637 
638 public:
640 
641  virtual void Pause(TRecorder *r);
642  virtual void Continue();
643  virtual void ReplayStop(TRecorder *r);
644 
645  void RegisterWindow(Window_t w); //SLOT
646  void ReplayRealtime(); //SLOT
647 
648  ClassDef(TRecorderReplaying, 0) // Represents state of TRecorder when replaying
649 };
650 
651 //////////////////////////////////////////////////////////////////////////
652 // //
653 // TRecorderRecording //
654 // //
655 // Represents state of TRecorder when recording events. //
656 // //
657 // Not intended to be used by a user directly. //
658 // //
659 //////////////////////////////////////////////////////////////////////////
661 {
662 private:
663  virtual ~TRecorderRecording();
664  Bool_t IsFiltered(Window_t id);
665  void SetTypeOfConfigureNotify(Event_t *e);
666  void CopyEvent(Event_t *e, Window_t wid);
667 
668  TRecorder *fRecorder; // Reference to recorder (owner of this state) is kept in order to switch
669  // recorder back to INACTIVE state after recording is finished
670 
671  TFile *fFile; // ROOT file to store recorded events in
672  TTimer *fTimer; // Timer used for recording
673  TTimer *fMouseTimer; // Timer used for recording mouse position
674  Long64_t fBeginPave; // TLatex/TPaveLabel edition starting time
675 
676  TTree *fWinTree; // TTree with registered windows
677  TTree *fGuiTree; // TTree with recorded GUI events
678  TTree *fCmdTree; // TTree with recorded commandline events
679  TTree *fExtraTree; // TTree with recorded extra events (PaveLabels and Texts)
680 
681  ULong64_t fWin; // The newest registered window to be stored in TTree
682  TRecGuiEvent *fGuiEvent; // The newest GUI event to be stored in TTree
683  TRecCmdEvent *fCmdEvent; // The newest commandline event to be stored in TTree
684  TRecExtraEvent *fExtraEvent; // The newest extra event to be stored in TTree
685 
686  Bool_t fCmdEventPending; // Indication if there is a still pending commandline event that should be stored.
687  // Commandline events are stored with 1 event delay to ensure skipping
688  // the last event 'TRecorder::Stop' that is not supposed to be recorded
689 
690  Int_t fRegWinCounter; // Counter of registered ROOT windows.
691  // It is increased every time when a new window is registered
692 
693  Int_t fFilteredIdsCount; // Only when GUI for recorder is used: Count of windows in GUI recorder
694  Window_t *fFilteredIds; // Only when GUI for recorer is used: IDs of windows that creates that GUI.
695  // Events for GUI recorder are not recorded.
696  Bool_t fFilterEventPave; // Special flag to filter events during the pave recording
697 
698 protected:
699  friend class TRecorderInactive;
700  TRecorderRecording(TRecorder *r, const char *filename, Option_t *option, Window_t *w, Int_t winCount);
701 
702  Bool_t StartRecording();
703 
704 public:
706 
707  virtual void Stop(TRecorder *r, Bool_t guiCommand);
708 
709  void RegisterWindow(Window_t w); //SLOT
710  void RecordCmdEvent(const char *line); //SLOT
711  void RecordGuiEvent(Event_t *e, Window_t wid); //SLOT
712  void RecordGuiBldEvent(Event_t *e); //SLOT
713  void RecordGuiCNEvent(Event_t *e); //SLOT
714  void RecordMousePosition();
715  void RecordPave(const TObject *obj); //SLOT
716  void RecordText(const TObject *obj); //SLOT
717  void FilterEventPave(); //SLOT
718  void StartEditing(); //SLOT
719 
720  void RecordExtraEvent(TString line, TTime extTime);
721 
722  ClassDef(TRecorderRecording, 0) // Represents state of TRecorder when recording events
723 };
724 
725 //////////////////////////////////////////////////////////////////////////
726 // //
727 // TRecorderInactive //
728 // //
729 // Represents state of TRecorder just after its creation. //
730 // Nor recording neither replaying is being executed in this state. //
731 // //
732 // Not intended to be used by a user directly. //
733 // //
734 //////////////////////////////////////////////////////////////////////////
736 {
737 
738 private:
740 
741 public:
742  virtual ~TRecorderInactive() {}
743  TRecorderInactive() : fCollect(0) {}
744 
745  virtual void ListCmd(const char *filename);
746  virtual void ListGui(const char *filename);
747 
748  virtual void Start(TRecorder *r, const char *filename, Option_t *option, Window_t *w = 0, Int_t winCount = 0);
749  virtual Bool_t Replay(TRecorder *r, const char *filename, Bool_t showMouseCursor, TRecorder::EReplayModes mode);
750 
752 
753  static void DumpRootEvent(TRecGuiEvent *e, Int_t n);
754  static long DisplayValid(Long_t n) { return ( n < 0 ? -1 : n); }
755 
756  void PrevCanvases(const char *filename, Option_t *option);
757 
758  ClassDef(TRecorderInactive, 0) // Represents state of TRecorder after its creation
759 };
760 
761 //////////////////////////////////////////////////////////////////////////
762 // //
763 // TRecorderPaused //
764 // //
765 // Represents state of TRecorder when replaying was paused //
766 // by a user. //
767 // The paused replaying is remembered and after Resume call can //
768 // be continued again. //
769 // //
770 // Not intended to be used by a user directly. //
771 // //
772 //////////////////////////////////////////////////////////////////////////
774 {
775 private:
776  virtual ~TRecorderPaused() {}
777 
778  TRecorderReplaying *fReplayingState; // Replaying that is paused
779 
780 protected:
781  friend class TRecorderReplaying;
783 
784 public:
786 
787  virtual void Resume(TRecorder *r);
788  virtual void ReplayStop(TRecorder *r);
789 
790  ClassDef(TRecorderPaused, 0) // Represents state of TRecorder when paused
791 };
792 
793 
794 //////////////////////////////////////////////////////////////////////////
795 // //
796 // TGRecorder //
797 // //
798 // Provides GUI for TRecorder class. //
799 // //
800 //////////////////////////////////////////////////////////////////////////
801 class TGRecorder : public TGMainFrame
802 {
803 private:
804  TRecorder *fRecorder; // Recorder
805 
806  TGPictureButton *fStartStop; // Button for start and stop of recording
807  TGPictureButton *fReplay; // Button for start of replaying
808 
809  TGLabel *fStatus; // Label with actual status
810  TGLabel *fTimeDisplay; // Label with time counter
811  TGCheckButton *fCursorCheckBox; // Check box "Show mouse cursor" for replaying
812 
813  TTimer *fTimer; // Timer for handling GUI of recorder
814  time_t fStart, fElapsed; // playing/recording time
815 
816  static const Int_t fgWidgetsCount = 12; // Number of windows in GUI recorder
817  Window_t fFilteredIds[fgWidgetsCount]; // IDs of these windows in GUI recorder
818 
819  void SetDefault();
820 
821 public:
822  TGRecorder(const TGWindow *p = 0, UInt_t w = 230, UInt_t h = 150);
823  virtual ~TGRecorder();
824 
825  void StartStop();
826  void Update();
827  void Replay();
828 
829  ClassDef(TGRecorder,0) // GUI class of the event recorder.
830 };
831 
832 #endif // ROOT_TRecorder
Time_t fTime
Definition: TRecorder.h:305
TGPictureButton * fReplay
Definition: TRecorder.h:807
Bool_t fSendEvent
Definition: TRecorder.h:315
TRecExtraEvent * fExtraEvent
Definition: TRecorder.h:597
Definition: TMutex.h:34
virtual Long_t ProcessLine(const char *line, Bool_t sync=kFALSE, Int_t *error=0)
Process a single command line, either a C++ statement or an interpreter command starting with a "...
Window_t fValue
Definition: TRecorder.h:369
virtual TRecorder::ERecorderState GetState() const
Definition: TRecorder.h:639
TCanvas * fCanv
Definition: TRecorder.h:584
long long Long64_t
Definition: RtypesCore.h:69
ULong64_t fWin
Definition: TRecorder.h:681
Bool_t fWaitingForWindow
Definition: TRecorder.h:615
static long DisplayValid(Long_t n)
Definition: TRecorder.h:754
TLine * line
const char Option_t
Definition: RtypesCore.h:62
TTree * fExtraTree
Definition: TRecorder.h:592
ULong_t Time_t
Definition: GuiTypes.h:43
TH1 * h
Definition: legend2.C:5
virtual void ListCmd(const char *)
Definition: TRecorder.h:547
EGEventType
Definition: GuiTypes.h:60
A ROOT file is a suite of consecutive data records (TKey instances) with a well defined format...
Definition: TFile.h:50
virtual TRecorder::ERecorderState GetState() const
Definition: TRecorder.h:705
TGCheckButton * fCursorCheckBox
Definition: TRecorder.h:811
void ChangeState(TRecorder *r, TRecorderState *s, Bool_t deletePreviousState)
Definition: TRecorder.h:536
Int_t fCount
Definition: TRecorder.h:314
virtual void Pause(TRecorder *)
Definition: TRecorder.h:543
Int_t fExtraTreeCounter
Definition: TRecorder.h:602
void SetText(TString text)
Definition: TRecorder.h:262
virtual void Browse(TBrowser *b)
Browse object. May be overridden for another default action.
Definition: TObject.cxx:179
Basic string class.
Definition: TString.h:137
int Int_t
Definition: RtypesCore.h:41
TSeqCollection * fCollect
Definition: TRecorder.h:739
bool Bool_t
Definition: RtypesCore.h:59
const Bool_t kFALSE
Definition: Rtypes.h:92
virtual Bool_t Replay(TRecorder *, const char *, Bool_t, TRecorder::EReplayModes)
Definition: TRecorder.h:542
virtual void SetTime(TTime t)
Definition: TRecorder.h:192
R__EXTERN TApplication * gApplication
Definition: TApplication.h:171
Basic time type with millisecond precision.
Definition: TTime.h:29
TTime fPreviousEventTime
Definition: TRecorder.h:612
TRecWinPair(Window_t key, Window_t value)
Definition: TRecorder.h:373
virtual void ReplayStop(TRecorder *)
Definition: TRecorder.h:545
Int_t fYRoot
Definition: TRecorder.h:309
TString fText
Definition: TRecorder.h:213
friend class TRecorderPaused
Definition: TRecorder.h:633
virtual void ReplayStop(TRecorder *r)
Replaying is cancelled.
Definition: TRecorder.cxx:1186
TRecorderReplaying * fReplayingState
Definition: TRecorder.h:778
UInt_t fHeight
Definition: TRecorder.h:313
virtual void Start(TRecorder *, const char *, Option_t *, Window_t *, Int_t)
Definition: TRecorder.h:540
Sequenceable collection abstract base class.
TList * fWindowList
Definition: TRecorder.h:608
Window_t fMasked
Definition: TRecorder.h:322
#define ClassDef(name, id)
Definition: Rtypes.h:254
Bool_t fCmdEventPending
Definition: TRecorder.h:686
virtual void Stop(TRecorder *, Bool_t)
Definition: TRecorder.h:541
TRecCmdEvent * fCmdEvent
Definition: TRecorder.h:596
TGLabel * fTimeDisplay
Definition: TRecorder.h:810
TRecGuiEvent * fGuiEvent
Definition: TRecorder.h:682
TRecGuiEvent * fGuiEvent
Definition: TRecorder.h:595
Handle_t fHandle
Definition: TRecorder.h:316
TRecCmdEvent * fCmdEvent
Definition: TRecorder.h:683
TObject & operator=(const TObject &rhs)
TObject assignment operator.
Definition: TObject.cxx:103
TTimer * fTimer
Definition: TRecorder.h:813
TRecorder * fRecorder
Definition: TRecorder.h:578
Int_t fXRoot
Definition: TRecorder.h:308
time_t fStart
Definition: TRecorder.h:814
TString fFilename
Definition: TRecorder.h:453
TRecExtraEvent * fExtraEvent
Definition: TRecorder.h:684
A doubly linked list.
Definition: TList.h:47
void SetText(const char *text)
Definition: TRecorder.h:220
TString GetText() const
Definition: TRecorder.h:267
Using a TBrowser one can browse all ROOT objects.
Definition: TBrowser.h:41
virtual ERecEventType GetType() const
Definition: TRecorder.h:230
TGLabel * fStatus
Definition: TRecorder.h:809
TRandom2 r(17)
void Initialize(Bool_t useTMVAStyle=kTRUE)
Definition: tmvaglob.cxx:176
void ChangeState(TRecorderState *newstate, Bool_t deletePreviousState=kTRUE)
Changes state from the current to the passed one (newstate) Deletes the old state if delPreviousState...
Definition: TRecorder.cxx:334
virtual ERecEventType GetType() const
Definition: TRecorder.h:272
TTime fEventTime
Definition: TRecorder.h:171
friend class TRecorder
Definition: TRecorder.h:535
Window_t fKey
Definition: TRecorder.h:368
unsigned int UInt_t
Definition: RtypesCore.h:42
UInt_t fState
Definition: TRecorder.h:311
virtual ~TRecorderState()
Definition: TRecorder.h:539
UInt_t fWidth
Definition: TRecorder.h:312
Handles synchronous and a-synchronous timer events.
Definition: TTimer.h:57
virtual ~TRecorderInactive()
Definition: TRecorder.h:742
Long64_t fBeginPave
Definition: TRecorder.h:674
TTimer * fMouseTimer
Definition: TRecorder.h:673
virtual ~TRecorderPaused()
Definition: TRecorder.h:776
virtual ERecEventType GetType() const =0
long Long_t
Definition: RtypesCore.h:50
The Canvas class.
Definition: TCanvas.h:41
void Replay()
Definition: TRecorder.h:491
virtual void ReplayEvent(Bool_t showMouseCursor=kTRUE)=0
TRecorderState * fRecorderState
Definition: TRecorder.h:441
virtual TRecorder::ERecorderState GetState() const
Definition: TRecorder.h:751
TText * text
virtual ERecEventType GetType() const
Definition: TRecorder.h:338
unsigned long long ULong64_t
Definition: RtypesCore.h:70
UInt_t fCode
Definition: TRecorder.h:310
Int_t fFormat
Definition: TRecorder.h:317
you should not use this method at all Int_t Int_t Double_t Double_t Double_t e
Definition: TRolke.cxx:630
Bool_t fFilterStatusBar
Definition: TRecorder.h:629
Bool_t fFilterEventPave
Definition: TRecorder.h:696
Bool_t fShowMouseCursor
Definition: TRecorder.h:627
virtual TRecorder::ERecorderState GetState() const
Get current state of recorder.
Definition: TRecorder.cxx:345
Mother of all ROOT objects.
Definition: TObject.h:37
TRecorder * fRecorder
Definition: TRecorder.h:668
Window_t * fFilteredIds
Definition: TRecorder.h:694
virtual void ReplayEvent(Bool_t)
Definition: TRecorder.h:235
Handle_t Window_t
Definition: GuiTypes.h:30
virtual void PrevCanvases(const char *, Option_t *)
Definition: TRecorder.h:550
virtual void ReplayStop(TRecorder *r)
Cancels replaying.
Definition: TRecorder.cxx:958
virtual void Resume(TRecorder *)
Definition: TRecorder.h:544
EGEventType fType
Definition: TRecorder.h:303
const char * GetText() const
Definition: TRecorder.h:225
A TTree object has a header with a name and a title.
Definition: TTree.h:98
TRecEvent * fNextEvent
Definition: TRecorder.h:610
virtual void ListGui(const char *)
Definition: TRecorder.h:548
Bool_t fEventReplayed
Definition: TRecorder.h:621
virtual void Pause(TRecorder *r)
Pauses replaying.
Definition: TRecorder.cxx:948
Int_t fFilteredIdsCount
Definition: TRecorder.h:693
const Bool_t kTRUE
Definition: Rtypes.h:91
virtual TTime GetTime() const
Definition: TRecorder.h:187
TString fText
Definition: TRecorder.h:255
const Int_t n
Definition: legend1.C:16
TGPictureButton * fStartStop
Definition: TRecorder.h:806
TRecorder * fRecorder
Definition: TRecorder.h:804
TTree * fExtraTree
Definition: TRecorder.h:679
virtual void ReplayEvent(Bool_t)
Definition: TRecorder.h:277
Window_t fWindow
Definition: TRecorder.h:304
ULong64_t fWin
Definition: TRecorder.h:594
const char * Data() const
Definition: TString.h:349
virtual TRecorder::ERecorderState GetState() const
Definition: TRecorder.h:785
friend class TRecorderReplaying
Definition: TRecorder.h:781
ULong_t Handle_t
Definition: GuiTypes.h:27