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