14 #include <QInputDialog> 15 #include <QMessageBox> 27 mActiveData(patientModelService->getActiveData())
29 this->setToolTip(
"Select a predefined transfer function");
30 this->setObjectName(
"transfer_function_preset_widget");
31 this->
setPresets(patientModelService->getPresetTransferFunctions3D());
32 QString toggleText =
"Toggle between apply presets,\neither on %1\nor both 2D and 3D\ntransfer functions.";
34 toggleText = toggleText.arg(
"3D");
36 toggleText = toggleText.arg(
"2D");
39 QIcon(
":/icons/preset_2D_and_3D.png"), toggleText,
"",
43 mApplyToAll =
settings()->
value(
"applyTransferFunctionPresetsToAll").toBool();
44 this->updateToggles();
54 mApplyToAll = !mApplyToAll;
57 this->updateToggles();
61 void TransferFunctionPresetWidget::updateToggles()
64 mToggleAction->setIcon(QIcon(
":/icons/preset_2D_and_3D.png"));
68 mToggleAction->setIcon(QIcon(
":/icons/preset_3D.png"));
70 mToggleAction->setIcon(QIcon(
":/icons/preset_2D.png"));
76 if (mActiveData->getActive<
Image>())
88 preset->
load(presetName, activeImage, this->use2D(), this->use3D());
104 if (!preset->getPresetList(
"").contains(newName))
105 newName =
"custom preset";
106 if (preset->isDefaultPreset(newName))
110 QString text = QInputDialog::getText(
this,
"Save Preset",
111 "Custom Preset Name", QLineEdit::Normal, newName, &ok);
112 if (!ok || text.isEmpty())
116 preset->
save(text, activeImage, this->use2D(), this->use3D());
122 bool TransferFunctionPresetWidget::use2D()
const 125 return !mIs3D || mApplyToAll;
128 bool TransferFunctionPresetWidget::use3D()
const 130 return mIs3D || mApplyToAll;
136 reportWarning(
"It is not possible to delete one of the default presets");
141 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.
Namespace for all CustusX production code.