14 #include <QInputDialog> 15 #include <QMessageBox> 28 mActiveData(patientModelService->getActiveData())
30 this->setToolTip(
"Select a predefined transfer function");
31 this->setObjectName(
"transfer_function_preset_widget");
32 this->
setPresets(patientModelService->getPresetTransferFunctions3D());
33 QString toggleText =
"Toggle between apply presets,\neither on %1\nor both 2D and 3D\ntransfer functions.";
35 toggleText = toggleText.arg(
"3D");
37 toggleText = toggleText.arg(
"2D");
40 QIcon(
":/icons/preset_2D_and_3D.png"), toggleText,
"",
44 mApplyToAll =
settings()->
value(
"applyTransferFunctionPresetsToAll").toBool();
45 this->updateToggles();
55 mApplyToAll = !mApplyToAll;
58 this->updateToggles();
62 void TransferFunctionPresetWidget::updateToggles()
65 mToggleAction->setIcon(QIcon(
":/icons/preset_2D_and_3D.png"));
69 mToggleAction->setIcon(QIcon(
":/icons/preset_3D.png"));
71 mToggleAction->setIcon(QIcon(
":/icons/preset_2D.png"));
77 if (mActiveData->getActive<
Image>())
89 preset->
load(presetName, activeImage, this->use2D(), this->use3D());
105 if (!preset->getPresetList(
imUNKNOWN).contains(newName))
106 newName =
"custom preset";
107 if (preset->isDefaultPreset(newName))
111 QString text = QInputDialog::getText(
this,
"Save Preset",
112 "Custom Preset Name", QLineEdit::Normal, newName, &ok);
113 if (!ok || text.isEmpty())
117 preset->
save(text, activeImage, this->use2D(), this->use3D());
123 bool TransferFunctionPresetWidget::use2D()
const 126 return !mIs3D || mApplyToAll;
129 bool TransferFunctionPresetWidget::use3D()
const 131 return mIs3D || mApplyToAll;
137 reportWarning(
"It is not possible to delete one of the default presets");
142 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 IMAGE_MODALITY getModality() const
boost::shared_ptr< class Image > ImagePtr
QVariant value(const QString &key, const QVariant &defaultValue=QVariant()) const
virtual void save(const QString &basePath, FileManagerServicePtr filemanager)
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)
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.