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

U.S. Department of the Interior | U.S. Geological Survey
ISIS | Privacy & Disclaimers | Astrogeology Research Program
To contact us, please post comments and questions on the ISIS Support Center
File Modified: 07/12/2023 23:18:15