00001 /*========================================================================= 00002 00003 Module: $RCSfile: vtkKWVolumePropertyPresetSelector.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 vtkKWVolumePropertyPresetSelector - a volume property preset selector. 00015 // .SECTION Description 00016 // This class is a widget that can be used to store and apply volume property 00017 // presets. 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 __vtkKWVolumePropertyPresetSelector_h 00026 #define __vtkKWVolumePropertyPresetSelector_h 00027 00028 #include "vtkKWPresetSelector.h" 00029 00030 class vtkVolumeProperty; 00031 class vtkKWVolumePropertyPresetSelectorInternals; 00032 00033 class KWWidgets_EXPORT vtkKWVolumePropertyPresetSelector : public vtkKWPresetSelector 00034 { 00035 public: 00036 static vtkKWVolumePropertyPresetSelector* New(); 00037 vtkTypeRevisionMacro(vtkKWVolumePropertyPresetSelector, vtkKWPresetSelector); 00038 void PrintSelf(ostream& os, vtkIndent indent); 00039 00040 // Description: 00041 // Set/Get the volume property associated to the preset in the pool. 00042 // Note that the volume property object passed as parameter is neither 00043 // stored nor Register()'ed, only a copy is stored (and updated each 00044 // time this method is called later on). 00045 // Return 1 on success, 0 on error 00046 virtual int SetPresetVolumeProperty(int id, vtkVolumeProperty *prop); 00047 virtual vtkVolumeProperty* GetPresetVolumeProperty(int id); 00048 00049 // Description: 00050 // Set/Get the type for a given preset. 00051 // The type column can be used, for example, to put the medical modality 00052 // a specific presets applies to (say, CT, MR) 00053 // The type field is not displayed as a column by default, but this 00054 // can be changed using the SetTypeColumnVisibility() method. 00055 // This column can not be edited. 00056 // Return 1 on success, 0 otherwise 00057 virtual int SetPresetType(int id, const char *type); 00058 virtual const char* GetPresetType(int id); 00059 00060 // Description: 00061 // Set/Get if the volume property is designed with independent components 00062 // in mind. 00063 // IMPORTANT: this slot is a convenience slot that reflect the value 00064 // of the vtkVolumeProperty's own IndependentComponents ivar. Each time 00065 // the volume property preset is set (see SetPresetVolumeProperty), this 00066 // slot is updated automatically, and vice-versa. 00067 // It is provided for filtering purposes (i.e. so that you can use 00068 // this slot in a preset filter constraint, and only show the presets 00069 // that are relevant to your data, if it has independent components or not). 00070 // Return 1 on success, 0 otherwise 00071 virtual int GetPresetIndependentComponents(int id); 00072 virtual int SetPresetIndependentComponents(int id, int flag); 00073 00074 // Description: 00075 // Set/Get if the volume property is designed with a specific blend mode 00076 // in mind. Valid constants are the ones found in vtkVolumeMapper, i.e. 00077 // vtkVolumeMapper::COMPOSITE_BLEND, 00078 // vtkVolumeMapper::MAXIMUM_INTENSITY_BLEND, 00079 // vtkVolumeMapper::MINIMUM_INTENSITY_BLEND. 00080 // Return 1 on success, 0 otherwise 00081 virtual int GetPresetBlendMode(int id); 00082 virtual int SetPresetBlendMode(int id, int flag); 00083 virtual int HasPresetBlendMode(int id); 00084 00085 // Description: 00086 // Set/Get if the normalized scalar values in the volume property are to 00087 // be interpreted relative to an histogram of the scalars. 00088 // Return 1 on success, 0 otherwise 00089 virtual int GetPresetHistogramFlag(int id); 00090 virtual int SetPresetHistogramFlag(int id, int flag); 00091 00092 // Description: 00093 // Query if the preset range falls inside a given range 00094 // (the preset range is computed by checking the largest scalar range among 00095 // the volume property transfer functions for component 0). 00096 // Return 1 on success (or HistogramFlag is On), 0 on error 00097 virtual int IsPresetRangeInsideRange(int id, double range[2]); 00098 00099 // Description: 00100 // Set/Get the visibility of the type column. Hidden by default. 00101 // No effect if called before Create(). 00102 virtual void SetTypeColumnVisibility(int); 00103 virtual int GetTypeColumnVisibility(); 00104 vtkBooleanMacro(TypeColumnVisibility, int); 00105 00106 // Description: 00107 // Add default normalized presets. 00108 // The type parameter will be used to call SetPresetType on each new preset. 00109 virtual void AddDefaultNormalizedPresets(const char *type); 00110 00111 // Description: 00112 // Add a preset filter constraint on the preset group field. 00113 virtual void SetPresetFilterRangeConstraint(double range[2]); 00114 virtual double* GetPresetFilterRangeConstraint(); 00115 virtual void DeletePresetFilterRangeConstraint(); 00116 00117 // Description: 00118 // Query if a given preset matches the current preset filter constraints. 00119 // Return 1 if match or if no filter was defined, 0 otherwise 00120 // Override (augment) the superclass to handle range constraint (see 00121 // SetPresetFilterRangeConstraint). 00122 virtual int IsPresetFiltered(int id); 00123 00124 // Description: 00125 // Most (if not all) of the information associated to a preset (say group, 00126 // comment, filename, creation time, thumbnail and screenshot) is stored 00127 // under the hood as user slots using the corresponding API (i.e. 00128 // Set/GetPresetUserSlotAs...()). Since each slot requires a unique name, 00129 // the following methods are provided to retrieve the slot name for 00130 // the preset fields. This can be useful to avoid collision between 00131 // the default slots and your own user slots. Note that the default slot 00132 // names can be changed too, but doing so will not transfer the value 00133 // stored at the old slot name to the new slot name (it is up to you to do 00134 // so, if needed). 00135 virtual void SetPresetTypeSlotName(const char *); 00136 virtual const char* GetPresetTypeSlotName(); 00137 virtual void SetPresetIndependentComponentsSlotName(const char *); 00138 virtual const char* GetPresetIndependentComponentsSlotName(); 00139 virtual void SetPresetHistogramFlagSlotName(const char *); 00140 virtual const char* GetPresetHistogramFlagSlotName(); 00141 virtual void SetPresetBlendModeSlotName(const char *); 00142 virtual const char* GetPresetBlendModeSlotName(); 00143 00144 // Description: 00145 // Some constants 00146 //BTX 00147 static const char *TypeColumnName; 00148 //ETX 00149 00150 protected: 00151 vtkKWVolumePropertyPresetSelector(); 00152 ~vtkKWVolumePropertyPresetSelector(); 00153 00154 // Description: 00155 // Create the columns. 00156 // Subclasses should override this method to add their own columns and 00157 // display their own preset fields (do not forget to call the superclass 00158 // first). 00159 virtual void CreateColumns(); 00160 00161 // Description: 00162 // Update the preset row, i.e. add a row for that preset if it is not 00163 // displayed already, hide it if it does not match GroupFilter, and 00164 // update the table columns with the corresponding preset fields. 00165 // Subclass should override this method to display their own fields. 00166 // Return 1 on success, 0 if the row was not (or can not be) updated. 00167 // Subclasses should call the parent's UpdatePresetRow, and abort 00168 // if the result is not 1. 00169 virtual int UpdatePresetRow(int id); 00170 00171 // Description: 00172 // Get the index of a given column. 00173 virtual int GetTypeColumnIndex(); 00174 00175 // Description: 00176 // Update the toolbar preset buttons state/visibility. 00177 virtual void UpdateToolbarPresetButtons(vtkKWToolbar*); 00178 00179 // Description: 00180 // Populate the pop-up context menu that is displayed when right-clicking 00181 // on a give preset. It should replicate the commands available through the 00182 // preset buttons. 00183 virtual void PopulatePresetContextMenu(vtkKWMenu *menu, int id); 00184 00185 // PIMPL Encapsulation for STL containers 00186 //BTX 00187 vtkKWVolumePropertyPresetSelectorInternals *Internals; 00188 //ETX 00189 00190 private: 00191 00192 vtkKWVolumePropertyPresetSelector(const vtkKWVolumePropertyPresetSelector&); // Not implemented 00193 void operator=(const vtkKWVolumePropertyPresetSelector&); // Not implemented 00194 }; 00195 00196 #endif