KWWidgets
debian/tmp/usr/include/KWWidgets/vtkKWLogWidget.h
Go to the documentation of this file.
1 /*=========================================================================
2 
3  Module: $RCSfile: vtkKWLogWidget.h,v $
4 
5  Copyright (c) Kitware, Inc.
6  All rights reserved.
7  See Copyright.txt or http://www.kitware.com/Copyright.htm for details.
8 
9  This software is distributed WITHOUT ANY WARRANTY; without even
10  the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
11  PURPOSE. See the above copyright notice for more information.
12 
13 =========================================================================*/
14 // .NAME vtkKWLogWidget - a log widget.
15 // .SECTION Description
16 // This widget can be used to display various types of records/events in the
17 // form of a multicolumn log. Each record is timestamped automatically, and
19 // description.
20 // This widget can be inserted in any widget hierarchy, or used a standalone
21 // dialog through the vtkKWLogDialog class.
22 // .SECTION Thanks
23 // This work is part of the National Alliance for Medical Image
24 // Computing (NAMIC), funded by the National Institutes of Health
25 // through the NIH Roadmap for Medical Research, Grant U54 EB005149.
26 // Information on the National Centers for Biomedical Computing
27 // can be obtained from http://nihroadmap.nih.gov/bioinformatics.
28 // .SECTION See Also
29 // vtkKWLogDialog
30 
31 #ifndef __vtkKWLogWidget_h
32 #define __vtkKWLogWidget_h
33 
34 #include "vtkKWCompositeWidget.h"
35 
37 class vtkKWLogWidgetInternals;
38 class vtkKWToolbar;
40 class vtkKWPushButton;
43 
45 {
46 public:
47  static vtkKWLogWidget* New();
48  vtkTypeRevisionMacro(vtkKWLogWidget,vtkKWCompositeWidget);
49  void PrintSelf(ostream& os, vtkIndent indent);
50 
51  // Description:
52  // Add a record.
53  // Return a unique record ID, which can be used to retrieve later on.
54  virtual int AddErrorRecord(const char *description);
55  virtual int AddWarningRecord(const char *description);
56  virtual int AddInformationRecord(const char *description);
57  virtual int AddDebugRecord(const char *description);
58 
59  // Description:
60  // Get number of records.
61  virtual int GetNumberOfRecords();
62 
63  // Description:
64  // Remove all records.
65  virtual void RemoveAllRecords();
66 
67  // Description:
68  // Set/Get the max number of records that will be stored.
69  virtual void SetMaximumNumberOfRecords(int);
70  vtkGetMacro(MaximumNumberOfRecords, int);
71 
72  // Description:
73  // Write all record to a stream or text file.
74  // Return 1 on success, 0 otherwise
75  virtual int WriteRecordsToStream(ostream& os);
76  virtual int WriteRecordsToFile(const char *filename);
77 
78  // Description:
79  // Email records.
80  virtual int EmailRecords(const char *recipient);
81 
82  // Description:
83  // Callback, do NOT use.
84  // When the time column is displayed, convert
85  // the cell text (time value in seconds) to ctime format.
86  // Returns the formatted string that will be displayed.
87  virtual char *GetFormatTimeStringCallback(const char *celltext);
88 
89  // Description:
90  // Callback, do NOT use.
91  // Write all records to a text file
92  virtual void WriteRecordsToFileCallback();
93 
94  // Description:
95  // Callback, do NOT use.
96  // Remove selected or all records from the table.
97  virtual void RemoveSelectedRecordsCallback();
98  virtual void RemoveAllRecordsCallback();
99  virtual void EmailRecordsCallback();
100 
101  // Description:
102  // Callback, do NOT use.
103  // Invoked when selection is changed in the table.
104  virtual void SelectionChangedCallback();
105 
106  // Description:
107  // Update the "enable" state of the object and its internal parts.
108  // Depending on different Ivars (this->Enabled, the application's
109  // Limited Edition Mode, etc.), the "enable" state of the object
110  // is updated and propagated to its internal parts/subwidgets.
111  // This will, for example, enable/disable parts of the widget UI,
112  // enable/disable the visibility of 3D widgets, etc.
113  virtual void UpdateEnableState();
114  virtual void Update();
115 
116  // Description:
117  // Events.
118  // RecordsClearedEvent is called when all records have been cleared using
119  // the "delete selected" or "delete all" button..
120  //BTX
121  enum
122  {
123  RecordsClearedEvent = 15000
124  };
125  //ETX
126 
127 protected:
128  vtkKWLogWidget();
129  ~vtkKWLogWidget();
130 
131  // Description:
132  // Create the widget.
133  virtual void CreateWidget();
134 
135  // Description:
136  // Define the record types with enumeration
137  //BTX
138  enum
139  {
140  ErrorType = 0,
143  DebugType
144  };
145  //ETX
146 
147  // Description:
148  // Create the log list.
149  virtual void CreateRecordList();
150 
151  // Description:
152  // Get current time in seconds.
153  virtual unsigned int GetCurrentTimeInSeconds();
154 
155  // Description:
156  // Remove the record from internal stored list.
157  virtual void RemoveInternalRecord(int record_id);
158 
159  // Description:
160  // Get the record description.
161  virtual const char* GetRecordDescription(int record_id);
162 
163  // Description:
164  // Add a record to the table and the stored list using the description
165  // and type.
166  // Return a unique record ID.
167  virtual int AddRecord(const char *description, int type);
168 
169  // Description:
170  // Check if the stored internal records number is greater than
171  // MaximumNumberOfRecords. If yes, remove the oldest records
172  // and corresponsing rows.
173  virtual void PruneRecords();
174 
175  // Description:
176  // Remove the corresponding row from the record table given the
177  // record ID.
178  virtual void RemoveRowWithRecordId(int record_id);
179 
180  // Description:
181  // Return the index of the row for the given record ID
182  virtual int GetIndexOfRowWithRecordId(int record_id);
183 
184  // Description:
185  // Member variables
186  vtkKWLogWidgetInternals *Internals;
195 
197 
198 private:
199 
200  static vtkIdType IdCounter;
201 
202  vtkKWLogWidget(const vtkKWLogWidget&); // Not implemented
203  void operator=(const vtkKWLogWidget&); // Not implemented
204 };
205 #endif