CustusX  18.04
An IGT application
cxFilterPresetWidget.cpp
Go to the documentation of this file.
1 /*=========================================================================
2 This file is part of CustusX, an Image Guided Therapy Application.
3 
4 Copyright (c) SINTEF Department of Medical Technology.
5 All rights reserved.
6 
7 CustusX is released under a BSD 3-Clause license.
8 
9 See Lisence.txt (https://github.com/SINTEFMedtek/CustusX/blob/master/License.txt) for details.
10 =========================================================================*/
11 
12 #include "cxFilterPresetWidget.h"
13 
14 #include <QMessageBox>
15 #include "cxLogger.h"
16 #include "cxFilter.h"
17 
18 namespace cx {
19 
21  PresetWidget(parent)
22 {}
23 
25 {
26  if(!filter->hasPresets()){
27  reportError("Cannot use filter "+filter->getName()+" in the FilterPresetWidget because it does not have any presets.");
28  return;
29  }
30 
31  mFilter = filter;
32  this->setPresets(mFilter->getPresets());
33 }
34 
36 {
37  if(!mFilter)
38  return;
39 
40  QString text = PresetWidget::getNewPresetName(true);
41  QDomElement element = mFilter->generatePresetFromCurrentlySetOptions(text);
42  mPresets->addCustomPreset(element);
43 
46 }
47 
49 {
50  if (mPresets->isDefaultPreset(PresetWidget::getCurrentPreset())) {
51  reportWarning("It is not possible to delete one of the default presets");
52  return;
53  }
54 
55  if (QMessageBox::question(this, "Delete current preset", "Do you really want to delete the current preset?", QMessageBox::Cancel | QMessageBox::Ok) != QMessageBox::Ok)
56  return;
57  mPresets->deleteCustomPreset(PresetWidget::getCurrentPreset());
58 
60  //TODO
61 // PresetWidget::requestSetCurrentPreset(text);
62 }
63 
64 } /* namespace cx */
void reportError(QString msg)
Definition: cxLogger.cpp:71
QString getCurrentPreset()
returns the name of the currently selected preset
virtual void setPresets(PresetsPtr presets)
virtual void saveSlot()
QString getNewPresetName(bool withoutSpaces)
Base class for preset handling. Takes care of making a uniform preset system. Contains a preset selec...
boost::shared_ptr< class Filter > FilterPtr
void reportWarning(QString msg)
Definition: cxLogger.cpp:70
virtual void saveSlot()
called when user tries to save a filter preset
virtual void deleteSlot()
void setFilter(FilterPtr filter)
sets which filter to operate on
bool requestSetCurrentPreset(QString name)
tries to set the preset to the requested name
virtual void deleteSlot()
called when user tries to delete a filter preset
PresetsPtr mPresets
FilterPresetWidget(QWidget *parent)
Namespace for all CustusX production code.