Logo ROOT  
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
132class TMutex;
133class TTree;
134class TFile;
135class TGPictureButton;
136class TGCheckButton;
137class TGLabel;
138class 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
152class TRecEvent : public TObject
153{
154private:
155 TTime fEventTime; // Time of original event execution
156
157public:
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
195{
196private:
197 TString fText; // Text of stored command
198
199public:
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)
217 }
218
219 virtual void ReplayEvent(Bool_t) {
220 // Stored command is executed again
221 std::cout << GetText() << std::endl;
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//////////////////////////////////////////////////////////////////////////
237{
238private:
239 TString fText; // Text of stored command
240
241public:
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)
259 }
260
261 virtual void ReplayEvent(Bool_t) {
262 // Stored event is executed again
263
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
280{
281protected:
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
308public:
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.
319 kROOT_MESSAGE = 10002
320 };
321
322 virtual ERecEventType GetType() const {
323 // Returns what kind of event it stores (GUI event)
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
347class TRecWinPair : public TObject
348{
349protected:
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
355public:
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//////////////////////////////////////////////////////////////////////////
422class TRecorder : public TObject
423{
424private:
425 TRecorderState *fRecorderState; //! Current state of recorder
426
427 TRecorder(const TRecorder&); // Not implemented.
428 TRecorder &operator=(const TRecorder&); // Not implemented.
429
430protected:
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
442public:
443 //---- Modes of replaying. Only kRealtime implemented so far
446 };
447 //---- States of recorder. In every moment, recorder is in right
448 // one of these states.
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{
518protected:
519 friend class TRecorder;
520 void ChangeState(TRecorder *r, TRecorderState *s, Bool_t deletePreviousState) { r->ChangeState(s, deletePreviousState); }
521
522public:
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
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{
554private:
555 virtual ~TRecorderReplaying();
559
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
615protected:
616 friend class TRecorderInactive;
617 friend class TRecorderPaused;
618
619 TRecorderReplaying(const char *filename);
621
622public:
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{
646private:
647 virtual ~TRecorderRecording();
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
682protected:
683 friend class TRecorderInactive;
684 TRecorderRecording(TRecorder *r, const char *filename, Option_t *option, Window_t *w, Int_t winCount);
685
687
688public:
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
722private:
724
725public:
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{
759private:
760 virtual ~TRecorderPaused() {}
761
762 TRecorderReplaying *fReplayingState; // Replaying that is paused
763
764protected:
765 friend class TRecorderReplaying;
767
768public:
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//////////////////////////////////////////////////////////////////////////
786{
787private:
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
805public:
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
EGEventType
Definition: GuiTypes.h:58
ULong_t Handle_t
Definition: GuiTypes.h:25
ULong_t Time_t
Definition: GuiTypes.h:41
Handle_t Window_t
Definition: GuiTypes.h:28
ROOT::R::TRInterface & r
Definition: Object.C:4
#define h(i)
Definition: RSha256.hxx:106
#define e(i)
Definition: RSha256.hxx:103
int Int_t
Definition: RtypesCore.h:41
unsigned int UInt_t
Definition: RtypesCore.h:42
const Bool_t kFALSE
Definition: RtypesCore.h:88
long Long_t
Definition: RtypesCore.h:50
bool Bool_t
Definition: RtypesCore.h:59
long long Long64_t
Definition: RtypesCore.h:69
unsigned long long ULong64_t
Definition: RtypesCore.h:70
const Bool_t kTRUE
Definition: RtypesCore.h:87
const char Option_t
Definition: RtypesCore.h:62
#define ClassDef(name, id)
Definition: Rtypes.h:326
R__EXTERN TApplication * gApplication
Definition: TApplication.h:166
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 "....
Using a TBrowser one can browse all ROOT objects.
Definition: TBrowser.h:37
The Canvas class.
Definition: TCanvas.h:31
A ROOT file is a suite of consecutive data records (TKey instances) with a well defined format.
Definition: TFile.h:48
Window_t fFilteredIds[fgWidgetsCount]
Definition: TRecorder.h:801
time_t fStart
Definition: TRecorder.h:798
TGPictureButton * fStartStop
Definition: TRecorder.h:790
virtual ~TGRecorder()
Destructor. Cleanup the GUI.
Definition: TRecorder.cxx:2070
TGLabel * fTimeDisplay
Definition: TRecorder.h:794
TGCheckButton * fCursorCheckBox
Definition: TRecorder.h:795
TTimer * fTimer
Definition: TRecorder.h:797
void StartStop()
Handles push of the fStartStop button according to the current recorder state.
Definition: TRecorder.cxx:1961
TGPictureButton * fReplay
Definition: TRecorder.h:791
TRecorder * fRecorder
Definition: TRecorder.h:788
TGRecorder(const TGWindow *p=0, UInt_t w=230, UInt_t h=150)
The GUI for the recorder.
Definition: TRecorder.cxx:1777
void Update()
Called when fTimer timeouts (every 0.025 second) Updates GUI of recorder.
Definition: TRecorder.cxx:1899
static const Int_t fgWidgetsCount
Definition: TRecorder.h:800
TGLabel * fStatus
Definition: TRecorder.h:793
time_t fElapsed
Definition: TRecorder.h:798
void SetDefault()
Sets GUI to the default inactive state.
Definition: TRecorder.cxx:1881
void Replay()
Handles push of fReplay button according to the current recorder state.
Definition: TRecorder.cxx:2025
A doubly linked list.
Definition: TList.h:44
Definition: TMutex.h:30
Mother of all ROOT objects.
Definition: TObject.h:37
virtual ERecEventType GetType() const
Definition: TRecorder.h:214
const char * GetText() const
Definition: TRecorder.h:209
TString fText
Definition: TRecorder.h:197
virtual void ReplayEvent(Bool_t)
Definition: TRecorder.h:219
void SetText(const char *text)
Definition: TRecorder.h:204
@ kExtraEvent
Definition: TRecorder.h:162
TTime fEventTime
Definition: TRecorder.h:155
virtual void ReplayEvent(Bool_t showMouseCursor=kTRUE)=0
virtual void SetTime(TTime t)
Definition: TRecorder.h:176
virtual TTime GetTime() const
Definition: TRecorder.h:171
virtual ERecEventType GetType() const =0
void SetText(TString text)
Definition: TRecorder.h:246
TString GetText() const
Definition: TRecorder.h:251
TString fText
Definition: TRecorder.h:239
virtual void ReplayEvent(Bool_t)
Definition: TRecorder.h:261
virtual ERecEventType GetType() const
Definition: TRecorder.h:256
EGEventType fType
Definition: TRecorder.h:287
UInt_t fCode
Definition: TRecorder.h:294
virtual void ReplayEvent(Bool_t showMouseCursor=kTRUE)
Replays stored GUI event.
Definition: TRecorder.cxx:2086
Int_t fFormat
Definition: TRecorder.h:301
Long_t fUser[5]
Definition: TRecorder.h:302
static Event_t * CreateEvent(TRecGuiEvent *ge)
Converts TRecGuiEvent type to Event_t type.
Definition: TRecorder.cxx:2196
Window_t fMasked
Definition: TRecorder.h:306
Handle_t fHandle
Definition: TRecorder.h:300
UInt_t fHeight
Definition: TRecorder.h:297
virtual ERecEventType GetType() const
Definition: TRecorder.h:322
Int_t fCount
Definition: TRecorder.h:298
@ kWM_DELETE_WINDOW
Definition: TRecorder.h:318
UInt_t fWidth
Definition: TRecorder.h:296
Int_t fXRoot
Definition: TRecorder.h:292
Bool_t fSendEvent
Definition: TRecorder.h:299
Int_t fYRoot
Definition: TRecorder.h:293
UInt_t fState
Definition: TRecorder.h:295
Window_t fWindow
Definition: TRecorder.h:288
Time_t fTime
Definition: TRecorder.h:289
Window_t fValue
Definition: TRecorder.h:353
Window_t fKey
Definition: TRecorder.h:352
TRecWinPair(Window_t key, Window_t value)
Definition: TRecorder.h:357
virtual ~TRecorderInactive()
Definition: TRecorder.h:726
virtual void ListCmd(const char *filename)
Prints out commandline events recorded in given file.
Definition: TRecorder.cxx:1028
virtual void Start(TRecorder *r, const char *filename, Option_t *option, Window_t *w=0, Int_t winCount=0)
Switches from INACTIVE state to RECORDING and starts recording.
Definition: TRecorder.cxx:981
void PrevCanvases(const char *filename, Option_t *option)
Save previous canvases in a .root file.
Definition: TRecorder.cxx:1147
virtual TRecorder::ERecorderState GetState() const
Definition: TRecorder.h:735
TSeqCollection * fCollect
Definition: TRecorder.h:723
virtual Bool_t Replay(TRecorder *r, const char *filename, Bool_t showMouseCursor, TRecorder::EReplayModes mode)
Switches from INACTIVE state of recorder to REPLAYING Return kTRUE if replaying has started or kFALSE...
Definition: TRecorder.cxx:1004
static void DumpRootEvent(TRecGuiEvent *e, Int_t n)
Prints out attributes of one GUI event TRecGuiEvent *e Int_n n is number of event if called in cycle.
Definition: TRecorder.cxx:1112
static long DisplayValid(Long_t n)
Definition: TRecorder.h:738
virtual void ListGui(const char *filename)
Prints out GUI events recorded in given file.
Definition: TRecorder.cxx:1070
virtual TRecorder::ERecorderState GetState() const
Definition: TRecorder.h:769
TRecorderReplaying * fReplayingState
Definition: TRecorder.h:762
virtual void Resume(TRecorder *r)
Continues replaying.
Definition: TRecorder.cxx:1174
virtual ~TRecorderPaused()
Definition: TRecorder.h:760
TRecorderPaused(TRecorderReplaying *state)
Rememeber the recorder state that is paused.
Definition: TRecorder.cxx:1166
virtual void ReplayStop(TRecorder *r)
Replaying is cancelled.
Definition: TRecorder.cxx:1186
TRecExtraEvent * fExtraEvent
Definition: TRecorder.h:668
TRecCmdEvent * fCmdEvent
Definition: TRecorder.h:667
void FilterEventPave()
Change the state of the flag to kTRUE when you are recording a pavelabel.
Definition: TRecorder.cxx:1636
ULong64_t fWin
Definition: TRecorder.h:665
TRecorder * fRecorder
Definition: TRecorder.h:652
void RecordMousePosition()
Try to record all mouse moves...
Definition: TRecorder.cxx:1496
TRecGuiEvent * fGuiEvent
Definition: TRecorder.h:666
virtual TRecorder::ERecorderState GetState() const
Definition: TRecorder.h:689
Long64_t fBeginPave
Definition: TRecorder.h:658
TRecorderRecording(TRecorder *r, const char *filename, Option_t *option, Window_t *w, Int_t winCount)
Initializes TRecorderRecording for recording What is allocated here is deleted in destructor.
Definition: TRecorder.cxx:1204
void RegisterWindow(Window_t w)
This method is called when RegisteredWindow(Window_t) is emitted from TGClient.
Definition: TRecorder.cxx:1403
virtual void Stop(TRecorder *r, Bool_t guiCommand)
Disconnects all slots and stopps recording.
Definition: TRecorder.cxx:1363
Bool_t StartRecording()
Connects appropriate signals and slots in order to gain all registered windows and processed events i...
Definition: TRecorder.cxx:1269
Bool_t fFilterEventPave
Definition: TRecorder.h:680
void StartEditing()
Memorize the starting time of editinga TLatex or a TPaveLabel.
Definition: TRecorder.cxx:1644
void RecordGuiBldEvent(Event_t *e)
Special case for the gui builder, having a timer handling some of the events.
Definition: TRecorder.cxx:1478
TTree * fExtraTree
Definition: TRecorder.h:663
void RecordPave(const TObject *obj)
Records TPaveLabel object created in TCreatePrimitives::Pave()
Definition: TRecorder.cxx:1550
virtual ~TRecorderRecording()
Freeing of allocated memory.
Definition: TRecorder.cxx:1252
Bool_t IsFiltered(Window_t id)
Returns kTRUE if passed id belongs to window IDs of recorder GUI itself.
Definition: TRecorder.cxx:1707
Window_t * fFilteredIds
Definition: TRecorder.h:678
TTimer * fMouseTimer
Definition: TRecorder.h:657
void SetTypeOfConfigureNotify(Event_t *e)
Sets type of kConfigureNotify event to one of EConfigureNotify.
Definition: TRecorder.cxx:1725
void RecordGuiCNEvent(Event_t *e)
Records GUI Event_t *e of type kConfigureNotify.
Definition: TRecorder.cxx:1527
void RecordExtraEvent(TString line, TTime extTime)
Records TLatex or TPaveLabel object created in TCreatePrimitives, ExtTime is needed for the correct r...
Definition: TRecorder.cxx:1653
Bool_t fCmdEventPending
Definition: TRecorder.h:670
void RecordGuiEvent(Event_t *e, Window_t wid)
Records GUI Event_t *e different from kConfigureNotify (they are recorded in TRecorderRecording::Reco...
Definition: TRecorder.cxx:1444
Int_t fFilteredIdsCount
Definition: TRecorder.h:677
void RecordText(const TObject *obj)
Records TLatex object created in TCreatePrimitives::Text()
Definition: TRecorder.cxx:1594
void CopyEvent(Event_t *e, Window_t wid)
Copies all items of given event to fGuiEvent.
Definition: TRecorder.cxx:1663
void RecordCmdEvent(const char *line)
Records commandline event (text and time) ans saves the previous commandline event This 1 event delay...
Definition: TRecorder.cxx:1416
TTree * fExtraTree
Definition: TRecorder.h:576
Bool_t FilterEvent(TRecGuiEvent *e)
Definition: TRecorder.cxx:667
Bool_t fEventReplayed
Definition: TRecorder.h:605
TCanvas * fCanv
Definition: TRecorder.h:568
TRecEvent * fNextEvent
Definition: TRecorder.h:594
TRecGuiEvent * fGuiEvent
Definition: TRecorder.h:579
virtual void ReplayStop(TRecorder *r)
Cancels replaying.
Definition: TRecorder.cxx:958
virtual ~TRecorderReplaying()
Closes all signal-slot connections Frees all memory allocated in contructor.
Definition: TRecorder.cxx:402
virtual TRecorder::ERecorderState GetState() const
Definition: TRecorder.h:623
TTime fPreviousEventTime
Definition: TRecorder.h:596
TList * fWindowList
Definition: TRecorder.h:592
TRecCmdEvent * fCmdEvent
Definition: TRecorder.h:580
Bool_t RemapWindowReferences()
All references to the old windows (IDs) in fNextEvent are replaced by new ones according to the mappi...
Definition: TRecorder.cxx:607
Bool_t fFilterStatusBar
Definition: TRecorder.h:613
Bool_t fWaitingForWindow
Definition: TRecorder.h:599
TRecExtraEvent * fExtraEvent
Definition: TRecorder.h:581
virtual void Continue()
Continues previously paused replaying.
Definition: TRecorder.cxx:967
Bool_t CanOverlap()
ButtonPress and ButtonRelease must be sometimes replayed more times Example: pressing of a button ope...
Definition: TRecorder.cxx:827
Int_t fExtraTreeCounter
Definition: TRecorder.h:586
virtual void Pause(TRecorder *r)
Pauses replaying.
Definition: TRecorder.cxx:948
Bool_t fShowMouseCursor
Definition: TRecorder.h:611
TRecorderReplaying(const char *filename)
Allocates all necessary data structures used for replaying What is allocated here is deleted in destr...
Definition: TRecorder.cxx:368
Bool_t PrepareNextEvent()
Finds the next event in log file to replay and sets it to fNextEvent.
Definition: TRecorder.cxx:722
TRecorder * fRecorder
Definition: TRecorder.h:562
Bool_t Initialize(TRecorder *r, Bool_t showMouseCursor, TRecorder::EReplayModes mode)
Initialization of data structures for replaying.
Definition: TRecorder.cxx:434
ULong64_t fWin
Definition: TRecorder.h:578
void RegisterWindow(Window_t w)
Creates mapping for the newly registered window w and adds this mapping to fWindowList.
Definition: TRecorder.cxx:539
void ReplayRealtime()
Replays the next event.
Definition: TRecorder.cxx:871
virtual void PrevCanvases(const char *, Option_t *)
Definition: TRecorder.h:534
virtual void Resume(TRecorder *)
Definition: TRecorder.h:528
virtual ~TRecorderState()
Definition: TRecorder.h:523
virtual void Start(TRecorder *, const char *, Option_t *, Window_t *, Int_t)
Definition: TRecorder.h:524
virtual void ListCmd(const char *)
Definition: TRecorder.h:531
virtual void ReplayStop(TRecorder *)
Definition: TRecorder.h:529
void ChangeState(TRecorder *r, TRecorderState *s, Bool_t deletePreviousState)
Definition: TRecorder.h:520
virtual void Pause(TRecorder *)
Definition: TRecorder.h:527
virtual void ListGui(const char *)
Definition: TRecorder.h:532
virtual TRecorder::ERecorderState GetState() const =0
virtual Bool_t Replay(TRecorder *, const char *, Bool_t, TRecorder::EReplayModes)
Definition: TRecorder.h:526
virtual void Stop(TRecorder *, Bool_t)
Definition: TRecorder.h:525
void Replay()
Definition: TRecorder.h:475
void Stop(Bool_t guiCommand=kFALSE)
Stopps recording events.
Definition: TRecorder.cxx:276
void ReplayStop()
Cancells replaying.
Definition: TRecorder.cxx:309
void Resume()
Resumes replaying.
Definition: TRecorder.cxx:301
TRecorderState * fRecorderState
Definition: TRecorder.h:425
virtual TRecorder::ERecorderState GetState() const
Get current state of recorder.
Definition: TRecorder.cxx:345
TString fFilename
Definition: TRecorder.h:437
void Start(const char *filename, Option_t *option="RECREATE", Window_t *w=0, Int_t winCount=0)
Starts recording events.
Definition: TRecorder.cxx:267
void ListGui(const char *filename)
Prints out recorded GUI events.
Definition: TRecorder.cxx:325
void Pause()
Pauses replaying.
Definition: TRecorder.cxx:293
TRecorder & operator=(const TRecorder &)
@ kRecording
Definition: TRecorder.h:451
@ kReplaying
Definition: TRecorder.h:453
void Browse(TBrowser *)
Browse the recorder from a ROOT file.
Definition: TRecorder.cxx:259
TRecorder(const TRecorder &)
Current state of recorder.
void ListCmd(const char *filename)
Prints out recorded commandline events.
Definition: TRecorder.cxx:317
virtual ~TRecorder()
Destructor.
Definition: TRecorder.cxx:250
TRecorder()
Creates initial INACTIVE state for the recorder.
Definition: TRecorder.cxx:225
void PrevCanvases(const char *filename, Option_t *option)
Save previous canvases in a .root file.
Definition: TRecorder.cxx:354
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
Sequenceable collection abstract base class.
Basic string class.
Definition: TString.h:131
const char * Data() const
Definition: TString.h:364
Basic time type with millisecond precision.
Definition: TTime.h:27
Handles synchronous and a-synchronous timer events.
Definition: TTimer.h:51
A TTree represents a columnar dataset.
Definition: TTree.h:72
TText * text
TLine * line
const Int_t n
Definition: legend1.C:16
static constexpr double s