CTL  0.6.1
Computed Tomography Library
Public Types | Public Slots | Public Member Functions | Static Public Member Functions | Protected Member Functions | Private Slots | Private Member Functions | Private Attributes | List of all members
CTL::gui::VolumeViewer Class Reference

The VolumeViewer class provides a tool for visualization of volume data. More...

#include <volumeviewer.h>

Inheritance diagram for CTL::gui::VolumeViewer:
Inheritance graph
[legend]
Collaboration diagram for CTL::gui::VolumeViewer:
Collaboration graph
[legend]

Public Types

enum  WindowPreset {
  Abdomen, Angio, Bone, Brain,
  Chest, Lungs
}
 

Public Slots

void autoResize ()
 
void hideCompositeOverview (bool hide=true)
 
void setAutoMouseWindowScaling ()
 
void showSlice (int slice)
 
void showSubvolume (int subvolume)
 

Public Member Functions

 VolumeViewer (QWidget *parent=nullptr)
 
 VolumeViewer (CompositeVolume volume, QWidget *parent=nullptr)
 
 ~VolumeViewer ()
 
const CompositeVolumedata () const
 
Chunk2DViewdataView () const
 
template<typename T >
void setData (const VoxelVolume< T > &data)
 
void setData (SpectralVolumeData data)
 
void setData (CompositeVolume data)
 
void setWindowPresets (WindowPreset preset1, WindowPreset preset2)
 
void setWindowPresetsInMu (WindowPreset preset1, WindowPreset preset2, float referenceEnergy)
 
void setWindowPresets (QPair< QString, QPair< double, double >> preset1, QPair< QString, QPair< double, double >> preset2)
 

Static Public Member Functions

template<typename T >
static void plot (const VoxelVolume< T > &data)
 
static void plot (CompositeVolume data)
 
static void plot (SpectralVolumeData data)
 

Protected Member Functions

void keyPressEvent (QKeyEvent *event) override
 

Private Slots

void changeSlice (int requestedChange)
 
void selectCentralSlice ()
 
void sliceDirectionChanged ()
 
void updateVolumeOverview ()
 
void updateSliderRange ()
 
void updatePixelInfo (int x, int y, float value)
 
void volumeSelectionChanged ()
 
void windowingUpdate ()
 

Private Member Functions

const SpectralVolumeDataselectedVolume () const
 

Private Attributes

Ui::VolumeViewer * ui
 
CompositeVolume _compData
 

Detailed Description

The VolumeViewer class provides a tool for visualization of volume data.

This class can be used to visualize different volume data objects. It fully supports:

Any subclass of AbstractDynamicVolumeData can be visualized as well, but will be limited to displaying the current state of the volume (ie. as set by AbstractDynamicVolumeData::setTime()).

For convenience, the plot() method can be used to achieve a one-line solution, creating a widget that will be destroyed once it is closed by the user.

A VolumeViewer window visualizing data of a CompositeVolume containing two subvolumes: a water cylinder (currently shown) a ball.

Use the vertical slider to cylce through the slices of the current volume. When visualizing a CompositeVolume, the table widget on the right shows an overview over its different subvolumes. Click on a row to visualize the corresponding subvolume in the viewport. If desired (e.g. to save screen space), the subvolume overview can be hidden with hideCompositeOverview). Subvolumes can then only be selected using showSubvolume().

The following IO operations are supported by this widget:

Within the viewport of the current slice:

Anywhere in the widget:

Contrast line plots are opened in separate windows (see LineSeriesView for details on the corresponding widget).

Visualization of the slice image itself is done using the Chunk2DView class. The viewport can be accessed with dataView(), in order to adjust its settings. For mouse gesture windowing, a convenience method setAutoMouseWindowScaling() exists to directly set a sensitivity suited for the current data.

Example:

// Creating two volumes
auto cylinderVol = SpectralVolumeData::cylinderX(30.0f, 100.0f, 1.0f, 1.0f, attenuationModel(database::Composite::Water));
auto ballVolume = SpectralVolumeData::ball(10.0f, 1.0f, 1.0f, attenuationModel(database::Composite::Blood));
// visualize a single volume (static version)
//create a CompositeVolume and visualize it (property-based version)
CompositeVolume compositeVol(std::move(cylinderVol), std::move(ballVolume));
auto viewer = new gui::VolumeViewer; // needs to be deleted at an appropriate time
viewer->setData(compositeVol);
viewer->autoResize();
viewer->show();

Note that it is absolutely possible to use the static version also to visualize a CompositeVolume. However, he property-based version provides more flexibility as it gives access to the full set of methods to configure the VolumeViewer. In particular, it allows us to configure the viewport showing the individual slices. The following example shows, how we can use this approach to create a visualization that uses a black-red colormap:

// create colormap
QVector<QRgb> blackRedMap(256);
for(int i = 0; i <= 255; ++i)
blackRedMap[i] = qRgb(i,0,0);
auto viewer = new gui::VolumeViewer; // needs to be deleted at an appropriate time
viewer->setData(compositeVol); // see example above for 'compositeVol'
viewer->dataView()->setColorTable(blackRedMap);
viewer->autoResize();
viewer->show();

Constructor & Destructor Documentation

◆ VolumeViewer() [1/2]

CTL::gui::VolumeViewer::VolumeViewer ( QWidget *  parent = nullptr)
explicit

Creates a VolumeViewer object with parent as a parent widget. Note that you need to call show() to display the window.

The static method plot() can be used as a convenience alternative for quick visualization.

◆ VolumeViewer() [2/2]

CTL::gui::VolumeViewer::VolumeViewer ( CompositeVolume  volume,
QWidget *  parent = nullptr 
)

Creates a VolumeViewer with parent widget parent and sets its data to volume. Note that you need to call show() to display the window.

The static method plot() can be used as a convenience alternative for quick visualization.

◆ ~VolumeViewer()

CTL::gui::VolumeViewer::~VolumeViewer ( )

Deletes the object.

Member Function Documentation

◆ autoResize

void CTL::gui::VolumeViewer::autoResize ( )
slot

Requests an automatic resizing of this widget's window size. The window is tried to fit to the size of the shown data, bounded between a minimum size of 700 x 400 pixels (500 x 400 with hidden composite overview) and a maximum size of 1300 x 900 pixels.

◆ data()

const CompositeVolume & CTL::gui::VolumeViewer::data ( ) const

Returns a (constant) reference to the data currently managed by this instance.

◆ dataView()

Chunk2DView * CTL::gui::VolumeViewer::dataView ( ) const

Returns the viewport for displaying the actual slice data. Use this to configure the specific settings of the viewport.

See also
Chunk2DView.

◆ hideCompositeOverview

void CTL::gui::VolumeViewer::hideCompositeOverview ( bool  hide = true)
slot

Hides the composite overview table if hide = true (or makes it visible again if false).

◆ plot() [1/3]

template<typename T >
void CTL::gui::VolumeViewer::plot ( const VoxelVolume< T > &  data)
static

Convenience overload to plot VoxelVolume data of arbitrary template type. The values in data will be converted to float for internal storage and displaying.

◆ plot() [2/3]

void CTL::gui::VolumeViewer::plot ( CompositeVolume  data)
static

Creates a VolumeViewer to visualize data and shows the window.

Sensitivity of windowing using mouse gestures is adapted automatically to data (see setAutoMouseWindowScaling()).

The widget will be deleted automatically if the window is closed.

◆ plot() [3/3]

void CTL::gui::VolumeViewer::plot ( SpectralVolumeData  data)
static

Creates a VolumeViewer to visualize data and shows the window.

Sensitivity of windowing using mouse gestures is adapted automatically to data (see setAutoMouseWindowScaling()).

The widget will be deleted automatically if the window is closed.

◆ setAutoMouseWindowScaling

void CTL::gui::VolumeViewer::setAutoMouseWindowScaling ( )
slot

Convenience method to set automatically determined values for the sensitvity of windowing using mouse gestures.

Same as:

See also
Chunk2DView::setAutoMouseWindowScaling().

◆ setData() [1/3]

template<typename T >
void CTL::gui::VolumeViewer::setData ( const VoxelVolume< T > &  data)

Convenience overload to set VoxelVolume data of arbitrary template type. The values in data will be converted to float for internal storage and displaying.

◆ setData() [2/3]

void CTL::gui::VolumeViewer::setData ( SpectralVolumeData  data)

Sets the visualized data to data. Data is copied, so consider moving if it is no longer required.

Applies a min/max windowing if no specific windowing has been set (ie. the current window is [0,0]).

◆ setData() [3/3]

void CTL::gui::VolumeViewer::setData ( CompositeVolume  data)

Sets the visualized data to data. Data is copied, so consider moving if it is no longer required.

By default, always selects the first subvolume in data for visualization.

Applies a min/max windowing if no specific windowing has been set (ie. the current window is [0,0]).

◆ setWindowPresets()

void CTL::gui::VolumeViewer::setWindowPresets ( WindowPreset  preset1,
WindowPreset  preset2 
)

Sets the presets of the two preset buttons in the windowing GUI block to preset1 and preset2. Presets can be chosen from a set of pre-defined window ranges, specified in Hounsfield units (HU) [from, to]:

  • WindowPreset::Abdomen: [ -140.0, 260.0]
  • WindowPreset::Angio: [ 0.0, 600.0]
  • WindowPreset::Bone: [ -450.0, 1050.0]
  • WindowPreset::Brain: [ 0.0, 80.0]
  • WindowPreset::Chest: [ -160.0, 240.0]
  • WindowPreset::Lungs: [-1150.0, 350.0]

Example:

auto viewer = new VolumeViewer;
// ...
viewer->setWindowPresets(WindowPreset::Abdomen, WindowPreset::Lungs);
viewer->show();

◆ setWindowPresetsInMu()

void CTL::gui::VolumeViewer::setWindowPresetsInMu ( WindowPreset  preset1,
WindowPreset  preset2,
float  referenceEnergy 
)

Sets the presets of the two preset buttons in the windowing GUI block to preset1 and preset2. Presets can be chosen from a set of pre-defined window ranges (see setWindowPresets(WindowPreset, WindowPreset)). Window ranges from the presets (defined in Hounsfield units) will be converted to attenuation coefficients with respect to the reference energy referenceEnergy.

Example:

auto viewer = new VolumeViewer;
// ...
// set Abdomen and Lung presets for attenuation coefficients with reference energy 75 keV
viewer->setWindowPresets(WindowPreset::Abdomen, WindowPreset::Lungs, 75.0f);
viewer->show();

◆ showSlice

void CTL::gui::VolumeViewer::showSlice ( int  slice)
slot

Shows the slice with index slice in the currently selected slice direction.

◆ showSubvolume

void CTL::gui::VolumeViewer::showSubvolume ( int  subvolume)
slot

Shows the subvolume with index subvolume from the currently managed dataset.


The documentation for this class was generated from the following files: