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
17
18
19template< class T > class QList;
20class QPushButton;
21class QVBoxLayout;
22
23
24namespace 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
75 FilterGroup &operator=(FilterGroup other);
76
77
78 signals:
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
Base class for control net filters.
Definition AbstractFilter.h:46
Base class for filter selectors.
Definition AbstractFilterSelector.h:46
This class provides an interface for a group of filters.
Definition FilterGroup.h:40
bool hasFilter(bool(AbstractFilter::*)() const =NULL) const
Definition FilterGroup.cpp:96
virtual ~FilterGroup()
Definition FilterGroup.cpp:78
bool evaluate(const T *t, bool(AbstractFilter::*meth)() const) const
Definition FilterGroup.h:49
void sizeChanged(FilterGroup *)
FilterGroup(QString type)
Definition FilterGroup.cpp:35
void close(FilterGroup *)
This is free and unencumbered software released into the public domain.
Definition BoxcarCachingAlgorithm.h:13
This is free and unencumbered software released into the public domain.
Definition Apollo.h:16