KWWidgets
|
00001 /*========================================================================= 00002 00003 Copyright (c) 1998-2003 Kitware Inc. 469 Clifton Corporate Parkway, 00004 Clifton Park, NY, 12065, USA. 00005 00006 All rights reserved. No part of this software may be reproduced, distributed, 00007 or modified, in any form or by any means, without permission in writing from 00008 Kitware Inc. 00009 00010 IN NO EVENT SHALL THE AUTHORS OR DISTRIBUTORS BE LIABLE TO ANY PARTY FOR 00011 DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING OUT 00012 OF THE USE OF THIS SOFTWARE, ITS DOCUMENTATION, OR ANY DERIVATIVES THEREOF, 00013 EVEN IF THE AUTHORS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 00014 00015 THE AUTHORS AND DISTRIBUTORS SPECIFICALLY DISCLAIM ANY WARRANTIES, INCLUDING, 00016 BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A 00017 PARTICULAR PURPOSE, AND NON-INFRINGEMENT. THIS SOFTWARE IS PROVIDED ON AN 00018 "AS IS" BASIS, AND THE AUTHORS AND DISTRIBUTORS HAVE NO OBLIGATION TO PROVIDE 00019 MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS. 00020 00021 =========================================================================*/ 00022 // .NAME vtkKWWindowLevelPresetSelector - a window level preset selector. 00023 // .SECTION Description 00024 // This class is a widget that can be used to store and apply window/level 00025 // presets. 00026 // .SECTION Thanks 00027 // This work is part of the National Alliance for Medical Image 00028 // Computing (NAMIC), funded by the National Institutes of Health 00029 // through the NIH Roadmap for Medical Research, Grant U54 EB005149. 00030 // Information on the National Centers for Biomedical Computing 00031 // can be obtained from http://nihroadmap.nih.gov/bioinformatics. 00032 // .SECTION See Also 00033 // vtkKWPresetSelector 00034 00035 #ifndef __vtkKWWindowLevelPresetSelector_h 00036 #define __vtkKWWindowLevelPresetSelector_h 00037 00038 #include "vtkKWPresetSelector.h" 00039 00040 class vtkKWWindowLevelPresetSelectorInternals; 00041 00042 class KWWidgets_EXPORT vtkKWWindowLevelPresetSelector : public vtkKWPresetSelector 00043 { 00044 public: 00045 static vtkKWWindowLevelPresetSelector* New(); 00046 vtkTypeRevisionMacro(vtkKWWindowLevelPresetSelector, vtkKWPresetSelector); 00047 void PrintSelf(ostream& os, vtkIndent indent); 00048 00049 // Description: 00050 // Set/Get the window/level values for a given preset. 00051 // Return 1 on success, 0 otherwise 00052 virtual double GetPresetWindow(int id); 00053 virtual int SetPresetWindow(int id, double window); 00054 virtual double GetPresetLevel(int id); 00055 virtual int SetPresetLevel(int id, double level); 00056 00057 // Description: 00058 // Set/Get the type for a given preset. 00059 // The type column can be used, for example, to put the medical modality 00060 // a specific presets applies to (say, CT, MR) 00061 // The type field is not displayed as a column by default, but this 00062 // can be changed using the SetTypeColumnVisibility() method. 00063 // This column can not be edited. 00064 // Return 1 on success, 0 otherwise 00065 virtual int SetPresetType(int id, const char *type); 00066 virtual const char* GetPresetType(int id); 00067 00068 // Description: 00069 // Set/Get the visibility of the type column. Hidden by default. 00070 // No effect if called before Create(). 00071 virtual void SetTypeColumnVisibility(int); 00072 virtual int GetTypeColumnVisibility(); 00073 vtkBooleanMacro(TypeColumnVisibility, int); 00074 00075 // Description: 00076 // Query if the pool has a given window/level preset in a group 00077 virtual int HasPresetWithGroupWithWindowLevel( 00078 const char *group, double window, double level); 00079 00080 // Description: 00081 // Most (if not all) of the information associated to a preset (say group, 00082 // comment, filename, creation time, thumbnail and screenshot) is stored 00083 // under the hood as user slots using the corresponding API (i.e. 00084 // Set/GetPresetUserSlotAs...()). Since each slot requires a unique name, 00085 // the following methods are provided to retrieve the slot name for 00086 // the preset fields. This can be useful to avoid collision between 00087 // the default slots and your own user slots. Note that the default slot 00088 // names can be changed too, but doing so will not transfer the value 00089 // stored at the old slot name to the new slot name (it is up to you to do 00090 // so, if needed). 00091 virtual void SetPresetTypeSlotName(const char *); 00092 virtual const char* GetPresetTypeSlotName(); 00093 00094 // Description: 00095 // Some constants 00096 //BTX 00097 static const char *WindowColumnName; 00098 static const char *LevelColumnName; 00099 static const char *TypeColumnName; 00100 //ETX 00101 00102 // Description: 00103 // Callback invoked when the user ends editing a specific preset field 00104 // located at cell ('row', 'col'). 00105 // The main purpose of this method is to perform a final validation of 00106 // the edit window's contents 'text'. 00107 // This method returns the value that is to become the new contents 00108 // for that cell. 00109 // The next step (updating) is handled by PresetCellUpdateCallback 00110 virtual const char* PresetCellEditEndCallback( 00111 int row, int col, const char *text); 00112 00113 // Description: 00114 // Callback invoked when the user successfully updated the preset field 00115 // located at ('row', 'col') with the new contents 'text', as a result 00116 // of editing the corresponding cell interactively. 00117 virtual void PresetCellUpdatedCallback(int row, int col, const char *text); 00118 00119 protected: 00120 vtkKWWindowLevelPresetSelector(); 00121 ~vtkKWWindowLevelPresetSelector(); 00122 00123 // Description: 00124 // Create the columns. 00125 // Subclasses should override this method to add their own columns and 00126 // display their own preset fields (do not forget to call the superclass 00127 // first). 00128 virtual void CreateColumns(); 00129 00130 // Description: 00131 // Update the preset row, i.e. add a row for that preset if it is not 00132 // displayed already, hide it if it does not match GroupFilter, and 00133 // update the table columns with the corresponding preset fields. 00134 // Subclass should override this method to display their own fields. 00135 // Return 1 on success, 0 if the row was not (or can not be) updated. 00136 // Subclasses should call the parent's UpdatePresetRow, and abort 00137 // if the result is not 1. 00138 virtual int UpdatePresetRow(int id); 00139 00140 // Description: 00141 // Get the index of a given column 00142 virtual int GetWindowColumnIndex(); 00143 virtual int GetLevelColumnIndex(); 00144 virtual int GetTypeColumnIndex(); 00145 00146 // PIMPL Encapsulation for STL containers 00147 //BTX 00148 vtkKWWindowLevelPresetSelectorInternals *Internals; 00149 //ETX 00150 00151 private: 00152 00153 vtkKWWindowLevelPresetSelector(const vtkKWWindowLevelPresetSelector&); // Not implemented 00154 void operator=(const vtkKWWindowLevelPresetSelector&); // Not implemented 00155 }; 00156 00157 #endif