1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379
|
/*=========================================================================
Copyright (c) Kitware, Inc.
All rights reserved.
See Copyright.txt or http://www.kitware.com/VolViewCopyright.htm for details.
This software is distributed WITHOUT ANY WARRANTY; without even
the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE. See the above copyright notice for more information.
=========================================================================*/
// .NAME vtkVVDataItemVolume - a class that encapsulates a single volume
// .SECTION Description
// This is a single volume.
#ifndef __vtkVVDataItemVolume_h
#define __vtkVVDataItemVolume_h
#include "vtkVVDataItem.h"
#include "XML/vtkXMLIOBaseMacros.h" // Needed for XML reader/writer macros
class vtkImageData;
class vtkKWCroppingRegionsWidget;
class vtkKWCursorWidget;
class vtkKWHistogram;
class vtkKWHistogramSet;
class vtkKWImageWidget;
class vtkKWInteractorStyle2DView;
class vtkKWLightboxWidget;
class vtkKWOpenFileProperties;
class vtkKWOpenWizard;
class vtkKWProbeImageWidget;
class vtkKWRenderWidget;
class vtkKWRenderWidgetPro;
class vtkKWVolumeWidget;
class vtkMedicalImageProperties;
class vtkVVDataItemVolumeInternals;
class vtkVVLODDataItemVolumeHelper;
class vtkVVSelectionFrame;
class vtkVVDataItemVolumeContourCollection;
class vtkVolumeProperty;
class VTK_EXPORT vtkVVDataItemVolume : public vtkVVDataItem
{
public:
static vtkVVDataItemVolume* New();
vtkTypeRevisionMacro(vtkVVDataItemVolume,vtkVVDataItem);
virtual void PrintSelf(ostream& os, vtkIndent indent);
//BTX
vtkKWGetXMLReaderWriterObjectsMacro();
//ETX
// Description:
// Set/Get the image data (i.e. the main data/volume).
// It is ref counted.
virtual void SetImageData(vtkImageData *data);
vtkGetObjectMacro(ImageData, vtkImageData);
// Description:
// Set/Get the scalar units for this dataset (e.g. density, T1, T2, etc)
// There are up to four values depending on how many components the
// dataset has
virtual const char *GetScalarUnits(int c);
virtual void SetScalarUnits(int c, const char *units);
// Description:
// Set/Get the volume property.
// It is ref counted.
virtual void SetVolumeProperty(vtkVolumeProperty *prop);
virtual vtkVolumeProperty* GetVolumeProperty();
// Description:
// Set/Get the medical image properties.
// It is ref counted.
virtual void SetMedicalImageProperties(vtkMedicalImageProperties *prop);
vtkGetObjectMacro(MedicalImageProperties, vtkMedicalImageProperties);
// Description:
// Specify which mode are allowed (by default everything is turned on):
// - Volume
// - LightBox
// - Axial
// - Coronal
// - Sagittal
// E.g. If you would like only Axial & Coronal, specify:
// SetDisplayMode(vtkVVDataItemVolume::ModeAxial |
// vtkVVDataItemVolume::ModeCoronal)
//BTX
typedef enum
{
ModeVolume = 1,
ModeLightBox = 2,
ModeAxial = 4,
ModeCoronal = 8,
ModeSagittal = 16
} DisplayModes;
//ETX
vtkGetMacro(DisplayMode, int);
vtkSetMacro(DisplayMode, int);
// Description:
// Check if there is enough memory to load a volume which structure is
// described by a vtkImageData or vtkKWOpenFileProperties.
// The application parameter is required to prompt the user for input.
static int CheckForMemory(
vtkImageData *input, vtkKWApplication *app);
static int CheckForMemory(
vtkKWOpenFileProperties *open_prop, vtkKWApplication *app);
// Description:
// Get the scalar range across the whole volume for a given component.
// Return 1 of success, 0 otherwise
virtual int GetScalarRange(int c, double range[2]);
// Description:
// Get the histogram for the whole volume at a given component.
virtual vtkKWHistogram* GetHistogram(int component);
vtkGetObjectMacro(HistogramSet, vtkKWHistogramSet);
// Description:
// Get the collection of contours on this volume
vtkGetObjectMacro(Contours, vtkVVDataItemVolumeContourCollection);
// Description:
// Load from open wizard
// Return 1 of success, 0 otherwise
virtual int LoadFromOpenWizard(vtkKWOpenWizard *, int output_port);
// Description:
// Set/Get the descriptive name of the data item.
// The descriptive name is used to provide a reasonable but short clue to
// the user about the data. If not set, it default to the name of the
// data item. Since the name is usually the filename to the data, subclasses
// are suggested to set the descriptive name to something more meaningful,
// say the name of the patient if the data item is a medical data.
// Override the parent method to use the internal medical properties
virtual const char *GetDescriptiveName();
// Description:
// Get the bounds of the data
virtual void GetBounds(double bounds[6]);
// Description:
// Release data. This comply with the superclass API, and will set
// ImageData to NULL.
virtual void ReleaseData();
// Description:
// Update the annotations of all the render widgets associated to this
// data.
virtual void UpdateRenderWidgetsAnnotations();
// -----------------------------------------------------------------------
// Undo/Redo for plugins
// Description:
// Set/Get the Undo or Redo image data. Once plugins operate on the dataset,
// this stores the previous volume, to aid quick undo or redo plugin
// operations.
// It is ref counted.
virtual int SetUndoRedoImageData(vtkImageData *data);
vtkGetObjectMacro(UndoRedoImageData, vtkImageData);
// Description:
// Set/Get the plugin name that produced the UndoRedoImageData. See
// UndoRedoPluginName below
vtkGetStringMacro(UndoRedoPluginName);
vtkSetStringMacro(UndoRedoPluginName);
// Description:
// The type of plugin operation that must be allowed by a plugin. This must
// be an iVar of the DataItemVolume, since it is the responsiblity of each
// DataItemVolume to maintain its Undo/Redo data and know which plugin
// should be allowed to invoke this Undo/Redo and whether this operation
// should be an Undo or a Redo.
//BTX
enum
{
Undo=0,
Redo,
Nothing
};
//ETX
// Description:
// Set/Get the type of operation here. Note: Setting it to none, destroys the
// UndoRedo dataset.
virtual void SetUndoRedoImageDataType(unsigned int);
vtkGetMacro( UndoRedoImageDataType, unsigned int );
virtual void SetUndoRedoImageDataTypeToUndo()
{ this->SetUndoRedoImageDataType(vtkVVDataItemVolume::Undo); };
virtual void SetUndoRedoImageDataTypeToRedo()
{ this->SetUndoRedoImageDataType(vtkVVDataItemVolume::Redo); };
virtual void SetUndoRedoImageDataTypeToNothing()
{ this->SetUndoRedoImageDataType(vtkVVDataItemVolume::Nothing); };
// -----------------------------------------------------------------------
// The following methods are per-window, i.e. one can add/retrieve/configure
// the default render widgets to several windows...
// Description:
// Add/Remove default widgets to a widget layout manager.
// For image/volume data, this will create the default 3D view, 2D views,
// lightbox, etc.
virtual void AddDefaultRenderWidgets(vtkVVWindowBase *win);
virtual void RemoveDefaultRenderWidgets(vtkVVWindowBase *win);
// Description:
// Get some of the unique widgets (if valid) for a given window
virtual vtkKWLightboxWidget *GetLightboxWidget(vtkVVWindowBase *win);
virtual vtkKWVolumeWidget *GetVolumeWidget(vtkVVWindowBase *win);
virtual vtkKWProbeImageWidget *GetObliqueProbeWidget(vtkVVWindowBase *win);
virtual vtkKWRenderWidget *GetNthRenderWidget(vtkVVWindowBase *win, int idx);
// Description:
// Query if the data item has a representation (say a 2D or 3D view) in
// a given window.
virtual int HasRenderWidgetInWindow(vtkVVWindowBase *win);
// Description:
// Enable/Disable the oblique probe in a given window
virtual void SetObliqueProbeVisibility(vtkVVWindowBase *win, int state);
virtual int GetObliqueProbeVisibility(vtkVVWindowBase *win);
// Description:
// Enable/Disable cropping for all the render widgets associated to this
// data, also set cropping planes, etc.
virtual void SetCroppingMode(vtkVVWindowBase *win, int state);
virtual int GetCroppingMode(vtkVVWindowBase *win);
virtual void SetCroppingPlanes(
vtkVVWindowBase *win,
double p0, double p1, double p2, double p3, double p4, double p5);
virtual void ResetCroppingPlanes(vtkVVWindowBase *win);
// Description:
// Enable/Disable 3D cursors for all the render widgets associated to this
// data, also set cursor position, etc.
virtual void SetCursorVisibility(vtkVVWindowBase *win, int state);
virtual int GetCursorVisibility(vtkVVWindowBase *win);
virtual void SetCursorPosition(
vtkVVWindowBase *win, double x, double y, double z);
// Description:
// Get number of renderwidgets (including all windows) amd a specific widget
virtual int GetNumberOfRenderWidgets();
virtual vtkKWRenderWidget *GetNthRenderWidget(int idx);
// Description:
// Get some of the unique widgets (if valid) for a given internal class
virtual vtkKWImageWidget *GetImageWidgetUsingCroppingRegionsWidget(
vtkKWCroppingRegionsWidget *cropping_w);
virtual vtkKWImageWidget *GetImageWidgetUsingCursorWidget(
vtkKWCursorWidget *cursor_w);
virtual vtkKWProbeImageWidget *GetObliqueProbeWidgetUsingInteractorStyle(
vtkKWInteractorStyle2DView *style);
// Description:
// Reset all renderwidgets' inputs. This can be useful if the ImageData
// has been updated/reloaded.
virtual void ResetRenderWidgetsInput();
// Description:
// The volume can manage datasets at multiple resolutions. (Limited to low and
// high for now). This will be created only when this method is invoked by
// the user for the first time.
virtual vtkVVLODDataItemVolumeHelper *GetLODHelper();
// Description:
// Enable garbage collection. There are ref counting cycles with
// vtkVVDataItemVolumeContourCollection
virtual void Register(vtkObjectBase* o);
virtual void UnRegister(vtkObjectBase* o);
protected:
vtkVVDataItemVolume();
~vtkVVDataItemVolume();
// Description:
// Histograms
vtkKWHistogramSet *HistogramSet;
// Contours (surfaces):
vtkVVDataItemVolumeContourCollection * Contours;
// Description:
// PIMPL Encapsulation for STL containers
//BTX
vtkVVDataItemVolumeInternals *Internals;
//ETX
// Description:
// The image data itself
vtkImageData *ImageData;
// Description:
// Once plugins operate on the dataset, this stores the Undo or the
// Redo data.
vtkImageData *UndoRedoImageData;
// Description:
// Plugin that gave the UndoRedoImageData. An UndoRedoImageData is
// associated to a volume and the plugin that produced it. This string is
// set by the appropriate plugin using
// vtkVVPluginSelector::GetPrettyPluginName()
char *UndoRedoPluginName;
// Description:
// Type of plugin operation
unsigned int UndoRedoImageDataType;
// Description:
// The common volume property
vtkVolumeProperty *VolumeProperty;
// Description:
// Scalar units
char *ScalarUnits[VTK_MAX_VRCOMP];
// Description:
// Some medical image properties
vtkMedicalImageProperties *MedicalImageProperties;
// Description:
// Create and configure a renderwidget for a specific window, and
// add it to the window's layout manager inside a new instance
// of vtkKWSelectionFrame (or subclass).
// Note that the widget's RenderState is set to Off and the RenderMode to
// Disabled, so that several widgets can be created in a row without
// extra Render's. It is therefore up to the caller to set the RenderState
// back to On and the RenderMode back to Still, then call Render().
virtual int CreateRenderWidget(
vtkVVWindowBase *win, vtkKWRenderWidgetPro *rwp);
// Description:
// Update a renderwidget's annotations
virtual void UpdateRenderWidgetAnnotations(vtkKWRenderWidgetPro *rwp);
// Description:
// Processes the events that are passed through CallbackCommand (or others).
// Subclasses can override this method to process their own events, but
// should call the superclass too.
virtual void ProcessCallbackCommandEvents(
vtkObject *caller, unsigned long event, void *calldata);
// Description:
// Add Auto Window Level Presets
// Return the number of presets that were added
virtual int AddAutoWindowLevelPresets();
// Description:
// Store the mode that will be displayed:
int DisplayMode;
// Description:
// See documentation of GetLODDataItemVolumeHelper()
vtkVVLODDataItemVolumeHelper *LODHelper;
// Report reference count loops. The contours refcount us
virtual void ReportReferences(vtkGarbageCollector* collector);
// Invoke the memory dialog. In quiet mode, we will assume that the user's
// answer is Yes to dialogs posed and try to load the dataset automatically
// without bringing up dialogs. If the dataset does not fit in memory at
// all, the load will silently fail. When quiet mode is off, the behaviour is
// the same as before. The return value indicates whether to proceed with the
// load or not (1 to proceed, 0 to halt).
static int InvokeMemoryDialog( vtkKWApplication *app,
const char *message, int icon, int messageBoxStyle );
private:
vtkVVDataItemVolume(const vtkVVDataItemVolume&); // Not implemented
void operator=(const vtkVVDataItemVolume&); // Not implemented
};
#endif
|