19 #include <QFileDialog>
20 #include <QFontMetrics>
29 #include <vtkUnstructuredGrid.h>
32 : QWidget(parent, f), deltaScale(1.0), deltaMax(1024), deltaMin(1)
40 connect(m_CrossLevelWindow, SIGNAL(SignalDeltaMove(
int,
int)),
this, SLOT(
OnDeltaLevelWindow(
int,
int)));
45 connect(m_CrossThreshold, SIGNAL(SignalDeltaMove(
int,
int)),
this, SLOT(
OnDeltaThreshold(
int,
int)));
51 m_TransferFunctionComboBox->setVisible(
false);
54 connect(m_TransferFunctionComboBox, SIGNAL(activated(
int)),
this, SLOT(
OnPreset(
int)));
56 connect(m_SavePreset, SIGNAL(clicked()),
this, SLOT(
OnSavePreset()));
58 connect(m_LoadPreset, SIGNAL(clicked()),
this, SLOT(
OnLoadPreset()));
66 m_TransferFunctionComboBox->setVisible(
true);
68 m_TransferFunctionComboBox->addItem(presetName);
69 return m_TransferFunctionComboBox->count() - 1;
74 m_PresetTab->setEnabled(enable);
79 m_ThresholdTab->setEnabled(enable);
84 m_BellTab->setEnabled(enable);
95 this,
"Choose a filename to save the transfer function",
presetFileName,
"Transferfunction (*.xml)");
104 QFontMetrics metrics(m_InfoPreset->font());
105 QString text = metrics.elidedText(
presetFileName, Qt::ElideMiddle, m_InfoPreset->width());
106 m_InfoPreset->setText(QString(
"saved ") + text);
110 m_InfoPreset->setText(QString(
"saving failed"));
120 this,
"Choose a file to open the transfer function from",
presetFileName,
"Transferfunction (*.xml)");
131 QFontMetrics metrics(m_InfoPreset->font());
132 QString text = metrics.elidedText(
presetFileName, Qt::ElideMiddle, m_InfoPreset->width());
133 m_InfoPreset->setText(QString(
"loaded ") + text);
146 m_InfoPreset->setText(QString(
"selected ") + m_TransferFunctionComboBox->currentText());
149 m_TransferFunctionComboBox->setCurrentIndex(0);
156 double a = 2 - 2 * z;
158 double b = 2 * z - 1;
167 x = 1 - (2 * x - 1.0);
168 x = x * (3 * x - 2 * x * x);
200 std::stringstream ss;
202 ss <<
"Click on the cross and move the mouse"
205 <<
"center at " <<
thPos <<
"\n"
208 m_InfoLevelWindow->setText(QString(ss.str().c_str()));
214 vtkPiecewiseFunction *f = tf->GetScalarOpacityFunction();
215 f->RemoveAllPoints();
217 for (
int r = 0; r <= 6; r++)
219 double relPos = (r / 6.0) * 0.5 + 0.5;
229 vtkPiecewiseFunction *f = tf->GetGradientOpacityFunction();
230 f->RemoveAllPoints();
245 x = x * (3 * x - 2 * x * x);
272 std::stringstream ss;
274 ss <<
"Click on the cross and move the mouse"
277 <<
"threshold at " <<
thPos <<
"\n"
280 m_InfoThreshold->setText(QString(ss.str().c_str()));
286 vtkPiecewiseFunction *f = tf->GetScalarOpacityFunction();
287 f->RemoveAllPoints();
289 for (
int r = 1; r <= 4; r++)
291 double relPos = r / 4.0;
300 vtkPiecewiseFunction *f = tf->GetGradientOpacityFunction();
301 f->RemoveAllPoints();
336 double *range = grid->GetVtkUnstructuredGrid()->GetScalarRange();
346 MITK_WARN <<
"QmitkTransferFunctonGeneratorWidget does not support " << node->
GetData()->GetNameOfClass()
355 m_InfoPreset->setText(QString(
""));
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)
BaseData * GetData() const
Get the data object (instance of BaseData, e.g., an Image) managed by this DataNode.
mitk::BaseProperty * GetProperty(const char *propertyKey, const mitk::BaseRenderer *renderer=nullptr) const
Get the property (instance of BaseProperty) with key propertyKey from the PropertyList of the rendere...
virtual ScalarType GetScalarValueMin(int t=0, unsigned int component=0)
Get the minimum for scalar images. Recomputation performed only when necessary.
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.
Class holding the statistics informations about a single mitk::Image.
Class for storing unstructured grids (vtkUnstructuredGrid)
void SetProperty(const char *propertyKey, BaseProperty *property, const mitk::BaseRenderer *renderer=nullptr)
Set the property (instance of BaseProperty) with key propertyKey in the PropertyList of the renderer ...
void RequestUpdateAll(RequestType type=REQUEST_UPDATE_ALL)
Class for nodes of the DataTree.