KWWidgets
|
00001 /*========================================================================= 00002 00003 Module: $RCSfile: vtkKWMatrixWidget.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 vtkKWMatrixWidget - matrix widget 00015 // .SECTION Description 00016 // vtkKWMatrixWidget is a widget containing entries that help view and 00017 // edit a matrix. 00018 // .SECTION Thanks 00019 // This work is part of the National Alliance for Medical Image 00020 // Computing (NAMIC), funded by the National Institutes of Health 00021 // through the NIH Roadmap for Medical Research, Grant U54 EB005149. 00022 // Information on the National Centers for Biomedical Computing 00023 // can be obtained from http://nihroadmap.nih.gov/bioinformatics. 00024 00025 #ifndef __vtkKWMatrixWidget_h 00026 #define __vtkKWMatrixWidget_h 00027 00028 #include "vtkKWCompositeWidget.h" 00029 00030 class vtkKWEntrySet; 00031 00032 class KWWidgets_EXPORT vtkKWMatrixWidget : public vtkKWCompositeWidget 00033 { 00034 public: 00035 static vtkKWMatrixWidget* New(); 00036 vtkTypeRevisionMacro(vtkKWMatrixWidget,vtkKWCompositeWidget); 00037 void PrintSelf(ostream& os, vtkIndent indent); 00038 00039 // Description: 00040 // Set/Get the matrix size. Default to 1x1. 00041 virtual void SetNumberOfColumns(int col); 00042 vtkGetMacro(NumberOfColumns, int); 00043 virtual void SetNumberOfRows(int col); 00044 vtkGetMacro(NumberOfRows, int); 00045 00046 // Description: 00047 // Set/Get the value of a given element. 00048 virtual void SetElementValue(int row, int col, const char *val); 00049 virtual const char* GetElementValue(int row, int col); 00050 virtual void SetElementValueAsInt(int row, int col, int val); 00051 virtual int GetElementValueAsInt(int row, int col); 00052 virtual void SetElementValueAsDouble(int row, int col, double val); 00053 virtual double GetElementValueAsDouble(int row, int col); 00054 00055 // Description: 00056 // The width is the number of charaters each element can fit. 00057 virtual void SetElementWidth(int width); 00058 vtkGetMacro(ElementWidth, int); 00059 00060 // Description: 00061 // Set/Get readonly flag. This flags makes each element read only. 00062 virtual void SetReadOnly(int); 00063 vtkBooleanMacro(ReadOnly, int); 00064 vtkGetMacro(ReadOnly, int); 00065 00066 // Description: 00067 // Restrict the value of an element to a given type 00068 // (integer, double, or no restriction). 00069 //BTX 00070 enum 00071 { 00072 RestrictNone = 0, 00073 RestrictInteger, 00074 RestrictDouble 00075 }; 00076 //ETX 00077 vtkGetMacro(RestrictElementValue, int); 00078 virtual void SetRestrictElementValue(int); 00079 virtual void SetRestrictElementValueToInteger(); 00080 virtual void SetRestrictElementValueToDouble(); 00081 virtual void SetRestrictElementValueToNone(); 00082 00083 // Description: 00084 // Specifies a command to be invoked when the value of an element in the 00085 // matrix has changed. 00086 // The 'object' argument is the object that will have the method called on 00087 // it. The 'method' argument is the name of the method to be called and any 00088 // arguments in string form. If the object is NULL, the method is still 00089 // evaluated as a simple command. 00090 // The following parameters are also passed to the command: 00091 // - the element location, i.e. its row and column indices: int, int 00092 // - the element's new value: const char* 00093 virtual void SetElementChangedCommand(vtkObject *object, const char *method); 00094 00095 // Description: 00096 // Events. The ElementChangedEvent is triggered when the value of an 00097 // element in the matrix has changed. 00098 // The following parameters are also passed as client data: 00099 // - the element location, i.e. its row and column indices: int, int 00100 // - the element's new value: const char* 00101 // Note that given the heterogeneous nature of types passed as client data, 00102 // you should treat it as an array of void*[3], each one a pointer to 00103 // the parameter (i.e., &int, &int, &const char*). 00104 //BTX 00105 enum 00106 { 00107 ElementChangedEvent = 10000 00108 }; 00109 //ETX 00110 00111 // Description: 00112 // Specify when ElementChangedCommand should be invoked. Default to losing 00113 // focus and return key in the entry. 00114 //BTX 00115 enum 00116 { 00117 TriggerOnFocusOut = 1, 00118 TriggerOnReturnKey = 2, 00119 TriggerOnAnyChange = 4 00120 }; 00121 //ETX 00122 vtkGetMacro(ElementChangedCommandTrigger, int); 00123 virtual void SetElementChangedCommandTrigger(int); 00124 virtual void SetElementChangedCommandTriggerToReturnKeyAndFocusOut(); 00125 virtual void SetElementChangedCommandTriggerToAnyChange(); 00126 00127 // Description: 00128 // Update the "enable" state of the object and its internal parts. 00129 // Depending on different Ivars (this->Enabled, the application's 00130 // Limited Edition Mode, etc.), the "enable" state of the object is updated 00131 // and propagated to its internal parts/subwidgets. This will, for example, 00132 // enable/disable parts of the widget UI, enable/disable the visibility 00133 // of 3D widgets, etc. 00134 virtual void UpdateEnableState(); 00135 00136 // Description: 00137 // Callbacks. 00138 virtual void ElementChangedCallback(int id, const char *value); 00139 00140 protected: 00141 vtkKWMatrixWidget(); 00142 virtual ~vtkKWMatrixWidget(); 00143 00144 int NumberOfColumns; 00145 int NumberOfRows; 00146 00147 int ElementWidth; 00148 int ReadOnly; 00149 int RestrictElementValue; 00150 int ElementChangedCommandTrigger; 00151 00152 // Description: 00153 // Create the widget. 00154 virtual void CreateWidget(); 00155 virtual void UpdateWidget(); 00156 00157 vtkKWEntrySet *EntrySet; 00158 00159 char *ElementChangedCommand; 00160 void InvokeElementChangedCommand(int row, int col, const char *value); 00161 00162 private: 00163 vtkKWMatrixWidget(const vtkKWMatrixWidget&); // Not implemented 00164 void operator=(const vtkKWMatrixWidget&); // Not implemented 00165 }; 00166 00167 #endif 00168