15 #include <QFileDialog> 16 #include <QFontMetrics> 25 #include <vtkUnstructuredGrid.h> 28 : QWidget(parent, f), deltaScale(1.0), deltaMax(1024), deltaMin(1)
36 connect(m_CrossLevelWindow, SIGNAL(SignalDeltaMove(
int,
int)),
this, SLOT(
OnDeltaLevelWindow(
int,
int)));
41 connect(m_CrossThreshold, SIGNAL(SignalDeltaMove(
int,
int)),
this, SLOT(
OnDeltaThreshold(
int,
int)));
47 m_TransferFunctionComboBox->setVisible(
false);
50 connect(m_TransferFunctionComboBox, SIGNAL(activated(
int)),
this, SLOT(
OnPreset(
int)));
52 connect(m_SavePreset, SIGNAL(clicked()),
this, SLOT(
OnSavePreset()));
54 connect(m_LoadPreset, SIGNAL(clicked()),
this, SLOT(
OnLoadPreset()));
62 m_TransferFunctionComboBox->setVisible(
true);
64 m_TransferFunctionComboBox->addItem(presetName);
65 return m_TransferFunctionComboBox->count() - 1;
70 m_PresetTab->setEnabled(enable);
75 m_ThresholdTab->setEnabled(enable);
80 m_BellTab->setEnabled(enable);
91 this,
"Choose a filename to save the transfer function",
presetFileName,
"Transferfunction (*.xml)");
100 QFontMetrics metrics(m_InfoPreset->font());
101 QString text = metrics.elidedText(
presetFileName, Qt::ElideMiddle, m_InfoPreset->width());
102 m_InfoPreset->setText(QString(
"saved ") + text);
106 m_InfoPreset->setText(QString(
"saving failed"));
116 this,
"Choose a file to open the transfer function from",
presetFileName,
"Transferfunction (*.xml)");
127 QFontMetrics metrics(m_InfoPreset->font());
128 QString text = metrics.elidedText(
presetFileName, Qt::ElideMiddle, m_InfoPreset->width());
129 m_InfoPreset->setText(QString(
"loaded ") + text);
142 m_InfoPreset->setText(QString(
"selected ") + m_TransferFunctionComboBox->currentText());
145 m_TransferFunctionComboBox->setCurrentIndex(0);
152 double a = 2 - 2 * z;
154 double b = 2 * z - 1;
163 x = 1 - (2 * x - 1.0);
164 x = x * (3 * x - 2 * x * x);
196 std::stringstream ss;
198 ss <<
"Click on the cross and move the mouse" 201 <<
"center at " <<
thPos <<
"\n" 204 m_InfoLevelWindow->setText(QString(ss.str().c_str()));
210 vtkPiecewiseFunction *f = tf->GetScalarOpacityFunction();
211 f->RemoveAllPoints();
213 for (
int r = 0; r <= 6; r++)
215 double relPos = (r / 6.0) * 0.5 + 0.5;
225 vtkPiecewiseFunction *f = tf->GetGradientOpacityFunction();
226 f->RemoveAllPoints();
241 x = x * (3 * x - 2 * x * x);
268 std::stringstream ss;
270 ss <<
"Click on the cross and move the mouse" 273 <<
"threshold at " <<
thPos <<
"\n" 276 m_InfoThreshold->setText(QString(ss.str().c_str()));
282 vtkPiecewiseFunction *f = tf->GetScalarOpacityFunction();
283 f->RemoveAllPoints();
285 for (
int r = 1; r <= 4; r++)
287 double relPos = r / 4.0;
296 vtkPiecewiseFunction *f = tf->GetGradientOpacityFunction();
297 f->RemoveAllPoints();
332 double *range = grid->GetVtkUnstructuredGrid()->GetScalarRange();
342 MITK_WARN <<
"QmitkTransferFunctonGeneratorWidget does not support " << node->
GetData()->GetNameOfClass()
351 m_InfoPreset->setText(QString(
""));
mitk::BaseProperty * GetProperty(const char *propertyKey, const mitk::BaseRenderer *renderer=nullptr, bool fallBackOnDataProperties=true) const
Get the property (instance of BaseProperty) with key propertyKey from the PropertyList of the rendere...
The TransferFunctionProperty class Property class for the mitk::TransferFunction. ...
static bool SerializeTransferFunction(const char *filename, TransferFunction::Pointer tf)
static TransferFunction::Pointer DeserializeTransferFunction(const char *filePath)
virtual ScalarType GetScalarValueMin(int t=0, unsigned int component=0)
Get the minimum for scalar images. Recomputation performed only when necessary.
void SetProperty(const std::string &propertyKey, BaseProperty *property, const std::string &contextName="", bool fallBackOnDefaultContext=false) override
Add new or change existent property.
BaseData * GetData() const
Get the data object (instance of BaseData, e.g., an Image) managed by this DataNode.
static RenderingManager * GetInstance()
virtual ScalarType GetScalarValueMax(int t=0, unsigned int component=0)
Get the maximum for scalar images. Recomputation performed only when necessary.
Image class for storing images.
mitk::Image::Pointer image
Class holding the statistics informations about a single mitk::Image.
Class for storing unstructured grids (vtkUnstructuredGrid)
void RequestUpdateAll(RequestType type=REQUEST_UPDATE_ALL)
Class for nodes of the DataTree.