00001 /*========================================================================= 00002 00003 Module: $RCSfile: vtkKWLogWidget.h,v $ 00004 00005 Copyright (c) Kitware, Inc. 00006 All rights reserved. 00007 See Copyright.txt or http://www.kitware.com/Copyright.htm for details. 00008 00009 This software is distributed WITHOUT ANY WARRANTY; without even 00010 the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR 00011 PURPOSE. See the above copyright notice for more information. 00012 00013 =========================================================================*/ 00014 // .NAME vtkKWLogWidget - a log widget. 00015 // .SECTION Description 00016 // This widget can be used to display various types of records/events in the 00017 // form of a multicolumn log. Each record is timestamped automatically, and 00019 // description. 00020 // This widget can be inserted in any widget hierarchy, or used a standalone 00021 // dialog through the vtkKWLogDialog class. 00022 // .SECTION Thanks 00023 // This work is part of the National Alliance for Medical Image 00024 // Computing (NAMIC), funded by the National Institutes of Health 00025 // through the NIH Roadmap for Medical Research, Grant U54 EB005149. 00026 // Information on the National Centers for Biomedical Computing 00027 // can be obtained from http://nihroadmap.nih.gov/bioinformatics. 00028 // .SECTION See Also 00029 // vtkKWLogDialog 00030 00031 #ifndef __vtkKWLogWidget_h 00032 #define __vtkKWLogWidget_h 00033 00034 #include "vtkKWCompositeWidget.h" 00035 00036 class vtkKWMultiColumnListWithScrollbars; 00037 class vtkKWLogWidgetInternals; 00038 class vtkKWToolbar; 00039 class vtkKWLoadSaveButton; 00040 class vtkKWPushButton; 00041 class vtkKWTextWithScrollbars; 00042 class vtkKWFrameWithLabel; 00043 00044 class KWWidgets_EXPORT vtkKWLogWidget : public vtkKWCompositeWidget 00045 { 00046 public: 00047 static vtkKWLogWidget* New(); 00048 vtkTypeRevisionMacro(vtkKWLogWidget,vtkKWCompositeWidget); 00049 void PrintSelf(ostream& os, vtkIndent indent); 00050 00051 // Description: 00052 // Add a record. 00053 // Return a unique record ID, which can be used to retrieve later on. 00054 virtual int AddErrorRecord(const char *description); 00055 virtual int AddWarningRecord(const char *description); 00056 virtual int AddInformationRecord(const char *description); 00057 virtual int AddDebugRecord(const char *description); 00058 00059 // Description: 00060 // Get number of records. 00061 virtual int GetNumberOfRecords(); 00062 00063 // Description: 00064 // Remove all records. 00065 virtual void RemoveAllRecords(); 00066 00067 // Description: 00068 // Set/Get the max number of records that will be stored. 00069 virtual void SetMaximumNumberOfRecords(int); 00070 vtkGetMacro(MaximumNumberOfRecords, int); 00071 00072 // Description: 00073 // Write all record to a stream or text file. 00074 // Return 1 on success, 0 otherwise 00075 virtual int WriteRecordsToStream(ostream& os); 00076 virtual int WriteRecordsToFile(const char *filename); 00077 00078 // Description: 00079 // Email records. 00080 virtual int EmailRecords(const char *recipient); 00081 00082 // Description: 00083 // Callback, do NOT use. 00084 // When the time column is displayed, convert 00085 // the cell text (time value in seconds) to ctime format. 00086 // Returns the formatted string that will be displayed. 00087 virtual char *GetFormatTimeStringCallback(const char *celltext); 00088 00089 // Description: 00090 // Callback, do NOT use. 00091 // Write all records to a text file 00092 virtual void WriteRecordsToFileCallback(); 00093 00094 // Description: 00095 // Callback, do NOT use. 00096 // Remove selected or all records from the table. 00097 virtual void RemoveSelectedRecordsCallback(); 00098 virtual void RemoveAllRecordsCallback(); 00099 virtual void EmailRecordsCallback(); 00100 00101 // Description: 00102 // Callback, do NOT use. 00103 // Invoked when selection is changed in the table. 00104 virtual void SelectionChangedCallback(); 00105 00106 // Description: 00107 // Update the "enable" state of the object and its internal parts. 00108 // Depending on different Ivars (this->Enabled, the application's 00109 // Limited Edition Mode, etc.), the "enable" state of the object 00110 // is updated and propagated to its internal parts/subwidgets. 00111 // This will, for example, enable/disable parts of the widget UI, 00112 // enable/disable the visibility of 3D widgets, etc. 00113 virtual void UpdateEnableState(); 00114 virtual void Update(); 00115 00116 // Description: 00117 // Events. 00118 // RecordsClearedEvent is called when all records have been cleared using 00119 // the "delete selected" or "delete all" button.. 00120 //BTX 00121 enum 00122 { 00123 RecordsClearedEvent = 15000 00124 }; 00125 //ETX 00126 00127 protected: 00128 vtkKWLogWidget(); 00129 ~vtkKWLogWidget(); 00130 00131 // Description: 00132 // Create the widget. 00133 virtual void CreateWidget(); 00134 00135 // Description: 00136 // Define the record types with enumeration 00137 //BTX 00138 enum 00139 { 00140 ErrorType = 0, 00141 WarningType, 00142 InformationType, 00143 DebugType 00144 }; 00145 //ETX 00146 00147 // Description: 00148 // Create the log list. 00149 virtual void CreateRecordList(); 00150 00151 // Description: 00152 // Get current time in seconds. 00153 virtual unsigned int GetCurrentTimeInSeconds(); 00154 00155 // Description: 00156 // Remove the record from internal stored list. 00157 virtual void RemoveInternalRecord(int record_id); 00158 00159 // Description: 00160 // Get the record description. 00161 virtual const char* GetRecordDescription(int record_id); 00162 00163 // Description: 00164 // Add a record to the table and the stored list using the description 00165 // and type. 00166 // Return a unique record ID. 00167 virtual int AddRecord(const char *description, int type); 00168 00169 // Description: 00170 // Check if the stored internal records number is greater than 00171 // MaximumNumberOfRecords. If yes, remove the oldest records 00172 // and corresponsing rows. 00173 virtual void PruneRecords(); 00174 00175 // Description: 00176 // Remove the corresponding row from the record table given the 00177 // record ID. 00178 virtual void RemoveRowWithRecordId(int record_id); 00179 00180 // Description: 00181 // Return the index of the row for the given record ID 00182 virtual int GetIndexOfRowWithRecordId(int record_id); 00183 00184 // Description: 00185 // Member variables 00186 vtkKWLogWidgetInternals *Internals; 00187 vtkKWMultiColumnListWithScrollbars *RecordList; 00188 vtkKWToolbar *Toolbar; 00189 vtkKWLoadSaveButton *SaveButton; 00190 vtkKWPushButton *RemoveSelectedButton; 00191 vtkKWPushButton *RemoveAllButton; 00192 vtkKWPushButton *EmailButton; 00193 vtkKWFrameWithLabel *DescriptionFrame; 00194 vtkKWTextWithScrollbars *DescriptionText; 00195 00196 int MaximumNumberOfRecords; 00197 00198 private: 00199 00200 static vtkIdType IdCounter; 00201 00202 vtkKWLogWidget(const vtkKWLogWidget&); // Not implemented 00203 void operator=(const vtkKWLogWidget&); // Not implemented 00204 }; 00205 #endif