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