35 #include <QInputDialog>
36 #include <QMessageBox>
47 mPatientModelService(patientModelService)
49 this->setToolTip(
"Select a predefined transfer function");
50 this->setObjectName(
"TransferFunctionPresetWidget");
51 this->
setPresets(patientModelService->getPresetTransferFunctions3D());
52 QString toggleText =
"Toggle between apply presets,\neither on %1\nor both 2D and 3D\ntransfer functions.";
54 toggleText = toggleText.arg(
"3D");
56 toggleText = toggleText.arg(
"2D");
59 QIcon(
":/icons/preset_2D_and_3D.png"), toggleText,
"",
63 mApplyToAll =
settings()->
value(
"applyTransferFunctionPresetsToAll").toBool();
64 this->updateToggles();
74 mApplyToAll = !mApplyToAll;
77 this->updateToggles();
80 void TransferFunctionPresetWidget::updateToggles()
83 mToggleAction->setIcon(QIcon(
":/icons/preset_2D_and_3D.png"));
87 mToggleAction->setIcon(QIcon(
":/icons/preset_3D.png"));
89 mToggleAction->setIcon(QIcon(
":/icons/preset_2D.png"));
95 if (mPatientModelService->getActiveImage())
104 ImagePtr activeImage = mPatientModelService->getActiveImage();
107 preset->
load(presetName, activeImage, this->use2D(), this->use3D());
114 ImagePtr activeImage = mPatientModelService->getActiveImage();
115 activeImage->resetTransferFunctions(this->use2D(), this->use3D());
123 if (!preset->getPresetList(
"").contains(newName))
124 newName =
"custom preset";
125 if (preset->isDefaultPreset(newName))
129 QString text = QInputDialog::getText(
this,
"Save Preset",
130 "Custom Preset Name", QLineEdit::Normal, newName, &ok);
131 if (!ok || text.isEmpty())
134 ImagePtr activeImage = mPatientModelService->getActiveImage();
135 preset->save(text, activeImage, this->use2D(), this->use3D());
141 bool TransferFunctionPresetWidget::use2D()
const
144 return !mIs3D || mApplyToAll;
147 bool TransferFunctionPresetWidget::use3D()
const
149 return mIs3D || mApplyToAll;
155 reportWarning(
"It is not possible to delete one of the default presets");
160 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)
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.
void reportWarning(QString msg)
boost::shared_ptr< class PatientModelService > PatientModelServicePtr
Settings * settings()
Shortcut for accessing the settings instance.
static ActiveImageProxyPtr New(PatientModelServicePtr patientModelService)
boost::shared_ptr< class TransferFunctions3DPresets > TransferFunctions3DPresetsPtr
void activeImageChanged(const QString &uid)
The original image changed signal from DataManager.
Handles transfer function presets.