Isis Developer Reference
FilterGroup.h
Go to the documentation of this file.
1 #ifndef FilterGroup_H
2 #define FilterGroup_H
3 
10 /* SPDX-License-Identifier: CC0-1.0 */
11 
12 // parent
13 #include <QWidget>
14 
15 // included because it is needed inside a templated method
16 #include "AbstractFilterSelector.h"
17 
18 
19 template< class T > class QList;
20 class QPushButton;
21 class QVBoxLayout;
22 
23 
24 namespace Isis {
25  class AbstractFilterSelector;
26  class ControlPoint;
27 
40  class FilterGroup : public QWidget {
41  Q_OBJECT
42 
43  public:
44  explicit FilterGroup(QString type);
45  FilterGroup(const FilterGroup &other);
46  virtual ~FilterGroup();
47 
48  template< typename T >
49  bool evaluate(const T *t, bool (AbstractFilter::*meth)() const) const {
50  // if andFiltersTogether is true then we break out of the loop as soon
51  // as any selectors evaluate to false. If andFiltersTogether is false
52  // then we are ORing them so we break out as soon as any selector
53  // evaluates to true. Whether we are looking for successes or failures
54  // depends on whether we are ANDing or ORing the filters (selectors)
55  // together!
56  bool looking = true;
57  for (int i = 0; looking && i < m_selectors->size(); i++)
58  if (m_selectors->at(i)->hasFilter(meth))
59  looking = !(m_selectors->at(i)->evaluate(t) ^ m_andFiltersTogether);
60 
61  // It is good that we are still looking for failures if we were ANDing
62  // filters together, but it is bad if we were ORing them since in this
63  // case we were looking for success.
64  return !(looking ^ m_andFiltersTogether) || !hasFilter(meth);
65  }
66 
67  //bool hasFilter() const;
68  bool hasFilter(bool (AbstractFilter:: *)() const = NULL) const;
69 
70  QString getDescription(bool (AbstractFilter:: *)() const,
71  QString(AbstractFilter:: *)() const) const;
72 
73  bool filtersAreAndedTogether() const;
74 
76 
77 
78  signals:
79  void close(FilterGroup *);
80  void filterChanged();
82 
83 
84  private:
85  bool hasSelectorWithCondition(
86  bool (AbstractFilterSelector:: *)() const) const;
87  void nullify();
88  void init();
89  void addSelector(AbstractFilterSelector *newSelector);
90 
91 
92  private slots:
93  void addSelector();
94  void deleteSelector(AbstractFilterSelector *);
95  void sendClose();
96  void sendSizeChanged();
97  void changeFilterCombinationLogic(int);
98 
99 
100  private: // widgets
101  QButtonGroup *m_buttonGroup;
102  QPushButton *m_closeButton;
103  QPushButton *m_newSelectorButton;
104  QVBoxLayout *m_groupBoxLayout;
105  QWidget *m_logicWidget;
106 
107 
108  private:
109  QList< AbstractFilterSelector * > * m_selectors;
110  bool m_andFiltersTogether;
111  QString *m_filterType;
112  };
113 }
114 
115 #endif
FileName.h
ImagePointFilterSelector.h
QWidget
Isis::ImagePointFilterSelector
Allows users to choose filters for filtering images and points.
Definition: ImagePointFilterSelector.h:29
Isis::ImageImageFilterSelector
Allows users to choose filters for filtering connected images.
Definition: ImageImageFilterSelector.h:29
Isis::FilterGroup::filtersAreAndedTogether
bool filtersAreAndedTogether() const
Definition: FilterGroup.cpp:243
QList
This is free and unencumbered software released into the public domain.
Definition: BoxcarCachingAlgorithm.h:13
Isis::FilterGroup::getDescription
QString getDescription(bool(AbstractFilter::*)() const, QString(AbstractFilter::*)() const) const
Definition: FilterGroup.cpp:310
Isis::AbstractFilter
Base class for control net filters.
Definition: AbstractFilter.h:46
Isis::FilterGroup::~FilterGroup
virtual ~FilterGroup()
Definition: FilterGroup.cpp:80
ImageImageFilterSelector.h
IString.h
FilterGroup.h
PointMeasureFilterSelector.h
_FILEINFO_
#define _FILEINFO_
Macro for the filename and line number.
Definition: IException.h:24
Isis::AbstractFilterSelector
Base class for filter selectors.
Definition: AbstractFilterSelector.h:46
Isis::FilterGroup::close
void close(FilterGroup *)
Isis::PointMeasureFilterSelector
Allows users to choose filters for filtering points and measures.
Definition: PointMeasureFilterSelector.h:29
Isis::FilterGroup::evaluate
bool evaluate(const T *t, bool(AbstractFilter::*meth)() const) const
Definition: FilterGroup.h:49
Isis::IException
Isis exception class.
Definition: IException.h:91
ASSERT
#define ASSERT(x)
Definition: IsisDebug.h:134
Isis::FilterGroup::operator=
FilterGroup & operator=(FilterGroup other)
Definition: FilterGroup.cpp:248
IException.h
Isis::IException::Programmer
@ Programmer
This error is for when a programmer made an API call that was illegal.
Definition: IException.h:146
AbstractFilterSelector.h
Isis::FilterGroup::filterChanged
void filterChanged()
Isis::FilterGroup::sizeChanged
void sizeChanged(FilterGroup *)
Isis::IString
Adds specific functionality to C++ strings.
Definition: IString.h:165
IsisDebug.h
Isis::FilterGroup::FilterGroup
FilterGroup(QString type)
Definition: FilterGroup.cpp:37
Isis
This is free and unencumbered software released into the public domain.
Definition: Apollo.h:16
Isis::FilterGroup::hasFilter
bool hasFilter(bool(AbstractFilter::*)() const =NULL) const
Definition: FilterGroup.cpp:98
Isis::FilterGroup
This class provides an interface for a group of filters.
Definition: FilterGroup.h:40