35 #include <QInputDialog>
36 #include <QMessageBox>
48 mActiveData(patientModelService->getActiveData())
50 this->setToolTip(
"Select a predefined transfer function");
51 this->setObjectName(
"TransferFunctionPresetWidget");
52 this->
setPresets(patientModelService->getPresetTransferFunctions3D());
53 QString toggleText =
"Toggle between apply presets,\neither on %1\nor both 2D and 3D\ntransfer functions.";
55 toggleText = toggleText.arg(
"3D");
57 toggleText = toggleText.arg(
"2D");
60 QIcon(
":/icons/preset_2D_and_3D.png"), toggleText,
"",
64 mApplyToAll =
settings()->
value(
"applyTransferFunctionPresetsToAll").toBool();
65 this->updateToggles();
75 mApplyToAll = !mApplyToAll;
78 this->updateToggles();
82 void TransferFunctionPresetWidget::updateToggles()
85 mToggleAction->setIcon(QIcon(
":/icons/preset_2D_and_3D.png"));
89 mToggleAction->setIcon(QIcon(
":/icons/preset_3D.png"));
91 mToggleAction->setIcon(QIcon(
":/icons/preset_2D.png"));
97 if (mActiveData->getActive<
Image>())
109 preset->
load(presetName, activeImage, this->use2D(), this->use3D());
125 if (!preset->getPresetList(
"").contains(newName))
126 newName =
"custom preset";
127 if (preset->isDefaultPreset(newName))
131 QString text = QInputDialog::getText(
this,
"Save Preset",
132 "Custom Preset Name", QLineEdit::Normal, newName, &ok);
133 if (!ok || text.isEmpty())
137 preset->
save(text, activeImage, this->use2D(), this->use3D());
143 bool TransferFunctionPresetWidget::use2D()
const
146 return !mIs3D || mApplyToAll;
149 bool TransferFunctionPresetWidget::use3D()
const
151 return mIs3D || mApplyToAll;
157 reportWarning(
"It is not possible to delete one of the default presets");
162 if (QMessageBox::question(
this,
"Delete current preset",
"Do you really want to delete the current preset?", QMessageBox::Cancel | QMessageBox::Ok) != QMessageBox::Ok)
void load(QString name, ImagePtr image, bool _2D=true, bool _3D=true)
virtual QString getModality() const
boost::shared_ptr< class Image > ImagePtr
QVariant value(const QString &key, const QVariant &defaultValue=QVariant()) const
void setValue(const QString &key, const QVariant &value)
void deletePresetData(QString name, bool _2D=true, bool _3D=true)
Delete the preset data node.
static ActiveImageProxyPtr New(ActiveDataPtr activeData)
void reportWarning(QString msg)
virtual void save(const QString &basePath)
boost::shared_ptr< class PatientModelService > PatientModelServicePtr
Settings * settings()
Shortcut for accessing the settings instance.
boost::shared_ptr< class TransferFunctions3DPresets > TransferFunctions3DPresetsPtr
void activeImageChanged(const QString &uid)
The original image changed signal from DataManager.
Handles transfer function presets.
void resetTransferFunctions(bool _2D=true, bool _3D=true)
Resets the transfer functions and creates new default values.