NorMIT-nav  2023.01.05-dev+develop.0da12
An IGT application
cxImageTF3D.cpp
Go to the documentation of this file.
1 /*=========================================================================
2 This file is part of CustusX, an Image Guided Therapy Application.
3 
4 Copyright (c) SINTEF Department of Medical Technology.
5 All rights reserved.
6 
7 CustusX is released under a BSD 3-Clause license.
8 
9 See Lisence.txt (https://github.com/SINTEFMedtek/CustusX/blob/master/License.txt) for details.
10 =========================================================================*/
11 
12 
13 /*
14  * sscImageTF3D.cpp
15  *
16  * Created on: Jan 9, 2009
17  * Author: christiana
18  */
19 
20 #include "cxImageTF3D.h"
21 
22 #include <vector>
23 #include <vtkImageData.h>
24 #include <vtkWindowLevelLookupTable.h>
25 #include <vtkColorTransferFunction.h>
26 #include <vtkPiecewiseFunction.h>
27 #include <vtkVolumeProperty.h>
28 #include <QColor>
29 #include <QDomDocument>
30 #include <QStringList>
31 #include "cxVector3D.h"
32 
33 #include "vtkForwardDeclarations.h"
34 #include "cxImageTF3D.h"
35 
36 #include "cxTypeConversions.h"
37 
38 namespace cx
39 {
40 
42 {
43 }
44 
45 //void ImageTF3D::setInitialTFFromImage(vtkImageDataPtr base)
46 //{
47 // double smin = base->GetScalarRange()[0];
48 // double smax = base->GetScalarRange()[1];
49 // double srange = smax - smin;
50 
51 // // set a winlevel spanning the entire range
54 // // set llr/alpha with full transmission
57 
62 
64 // mOpacityMap.clear();
65 // this->addAlphaPoint(smin - 1, 0);
66 // this->addAlphaPoint(smin + 0.1 * srange, 255.0 * 0.1);
67 // this->addAlphaPoint(smin + 0.4 * srange, 255.0 * 0.5);
69 // this->addAlphaPoint(smax, 255);
70 
71 // mColorMap.clear();
72 // this->addColorPoint(smin, Qt::black);
73 // this->addColorPoint(smax, Qt::white);
74 //}
75 
77 {
78  this->refreshOpacityTF();
79  this->refreshColorTF();
81 }
82 
84 {
85  ImageTF3DPtr retval(new ImageTF3D());
86  retval->deepCopy(this);
87  return retval;
88 }
89 
91 {
92  if (!mOpacityTF)
93  {
94  mOpacityTF = vtkPiecewiseFunctionPtr::New();
95  this->refreshOpacityTF();
96  }
97  return mOpacityTF;
98 }
99 
101 {
102  if (!mColorTF)
103  {
104  mColorTF = vtkColorTransferFunctionPtr::New();
105  this->refreshColorTF();
106  }
107  return mColorTF;
108 }
109 
113 void ImageTF3D::refreshColorTF()
114 {
115  if (!mColorTF)
116  return;
117  this->fillColorTFFromMap(mColorTF);
118 }
119 
122 void ImageTF3D::refreshOpacityTF()
123 {
124  if (!mOpacityTF)
125  return;
126  this->fillOpacityTFFromMap(mOpacityTF);
127 }
128 
132 void ImageTF3D::buildOpacityMapFromLLRAlpha()
133 {
134  // REMOVED CA 2014-02-07 - TODO
135  double range = this->getWindow();
136  int smooth = (int) (0.1 * range);
137 
138  mOpacityMap.clear();
139 // this->addAlphaPoint(this->getScalarMin(), 0);
140 // if (this->getLLR() > this->getScalarMin())
141  this->addAlphaPoint(this->getLLR() - 1, 0);
142  this->addAlphaPoint(this->getLLR() + 1 * smooth, this->getAlpha() * 255 * 1 / 10);
143  this->addAlphaPoint(this->getLLR() + 4 * smooth, this->getAlpha() * 255 * 5 / 10);
144  this->addAlphaPoint(this->getLLR() + 10 * smooth, this->getAlpha() * 255);
145 // this->addAlphaPoint(this->getScalarMax(), this->getAlpha() * 255);
146 }
147 
148 }
cx::ImageTFData::transferFunctionsChanged
void transferFunctionsChanged()
cx::ImageTFData::fillOpacityTFFromMap
void fillOpacityTFFromMap(vtkPiecewiseFunctionPtr tf) const
Definition: cxImageTFData.cpp:375
cx::ImageTFData::mOpacityMap
IntIntMap mOpacityMap
Definition: cxImageTFData.h:126
cx
Namespace for all CustusX production code.
Definition: cx_dev_group_definitions.h:13
cx::ImageTF3D::ImageTF3D
ImageTF3D()
Definition: cxImageTF3D.cpp:41
cx::ImageTF3D::getOpacityTF
vtkPiecewiseFunctionPtr getOpacityTF()
Definition: cxImageTF3D.cpp:90
cx::ImageTF3DPtr
boost::shared_ptr< class ImageTF3D > ImageTF3DPtr
Definition: cxForwardDeclarations.h:50
cxVector3D.h
cx::ImageTFData::getAlpha
double getAlpha() const
Definition: cxImageTFData.cpp:233
cx::ImageTFData::fillColorTFFromMap
void fillColorTFFromMap(vtkColorTransferFunctionPtr tf) const
Definition: cxImageTFData.cpp:364
cx::ImageTFData::getLLR
double getLLR() const
Definition: cxImageTFData.cpp:192
cx::ImageTF3D::createCopy
ImageTF3DPtr createCopy()
Definition: cxImageTF3D.cpp:83
cx::ImageTFData::getWindow
double getWindow() const
Definition: cxImageTFData.cpp:260
vtkPiecewiseFunctionPtr
vtkSmartPointer< class vtkPiecewiseFunction > vtkPiecewiseFunctionPtr
Definition: vtkForwardDeclarations.h:105
cxTypeConversions.h
vtkForwardDeclarations.h
vtkColorTransferFunctionPtr
vtkSmartPointer< class vtkColorTransferFunction > vtkColorTransferFunctionPtr
Definition: vtkForwardDeclarations.h:44
cx::ImageTF3D::getColorTF
vtkColorTransferFunctionPtr getColorTF()
Definition: cxImageTF3D.cpp:100
cx::ImageTFData::addAlphaPoint
void addAlphaPoint(int alphaPosition, int alphaValue)
Add point to the opacity transfer function.
Definition: cxImageTFData.cpp:302
cxImageTF3D.h
cx::ImageTF3D::internalsHaveChanged
virtual void internalsHaveChanged()
Definition: cxImageTF3D.cpp:76