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)