Isis 3 Programmer Reference
FilterGroup.h
1 #ifndef FilterGroup_H
2 #define FilterGroup_H
3 
4 
5 // parent
6 #include <QWidget>
7 
8 // included because it is needed inside a templated method
9 #include "AbstractFilterSelector.h"
10 
11 
12 template< class T > class QList;
13 class QPushButton;
14 class QVBoxLayout;
15 
16 
17 namespace Isis {
18  class AbstractFilterSelector;
19  class ControlPoint;
20 
33  class FilterGroup : public QWidget {
34  Q_OBJECT
35 
36  public:
37  explicit FilterGroup(QString type);
38  FilterGroup(const FilterGroup &other);
39  virtual ~FilterGroup();
40 
41  template< typename T >
42  bool evaluate(const T *t, bool (AbstractFilter::*meth)() const) const {
43  // if andFiltersTogether is true then we break out of the loop as soon
44  // as any selectors evaluate to false. If andFiltersTogether is false
45  // then we are ORing them so we break out as soon as any selector
46  // evaluates to true. Whether we are looking for successes or failures
47  // depends on whether we are ANDing or ORing the filters (selectors)
48  // together!
49  bool looking = true;
50  for (int i = 0; looking && i < m_selectors->size(); i++)
51  if (m_selectors->at(i)->hasFilter(meth))
52  looking = !(m_selectors->at(i)->evaluate(t) ^ m_andFiltersTogether);
53 
54  // It is good that we are still looking for failures if we were ANDing
55  // filters together, but it is bad if we were ORing them since in this
56  // case we were looking for success.
57  return !(looking ^ m_andFiltersTogether) || !hasFilter(meth);
58  }
59 
60  //bool hasFilter() const;
61  bool hasFilter(bool (AbstractFilter:: *)() const = NULL) const;
62 
63  QString getDescription(bool (AbstractFilter:: *)() const,
64  QString(AbstractFilter:: *)() const) const;
65 
66  bool filtersAreAndedTogether() const;
67 
68  FilterGroup &operator=(FilterGroup other);
69 
70 
71  signals:
72  void close(FilterGroup *);
73  void filterChanged();
74  void sizeChanged(FilterGroup *);
75 
76 
77  private:
78  bool hasSelectorWithCondition(
79  bool (AbstractFilterSelector:: *)() const) const;
80  void nullify();
81  void init();
82  void addSelector(AbstractFilterSelector *newSelector);
83 
84 
85  private slots:
86  void addSelector();
87  void deleteSelector(AbstractFilterSelector *);
88  void sendClose();
89  void sendSizeChanged();
90  void changeFilterCombinationLogic(int);
91 
92 
93  private: // widgets
94  QButtonGroup *m_buttonGroup;
95  QPushButton *m_closeButton;
96  QPushButton *m_newSelectorButton;
97  QVBoxLayout *m_groupBoxLayout;
98  QWidget *m_logicWidget;
99 
100 
101  private:
102  QList< AbstractFilterSelector * > * m_selectors;
103  bool m_andFiltersTogether;
104  QString *m_filterType;
105  };
106 }
107 
108 #endif
Base class for filter selectors.
This class provides an interface for a group of filters.
Definition: FilterGroup.h:33
Namespace for ISIS/Bullet specific routines.
Definition: Apollo.h:31
Base class for control net filters.