Isis 3 Programmer Reference
FilterWidget.h
1 #ifndef FilterWidget_H
2 #define FilterWidget_H
3 
4 
5 // parent
6 #include <QWidget>
7 
8 // these are included because it is needed inside a templated method
9 #include "FilterGroup.h"
10 
11 
12 class QLabel;
13 template< class T > class QList;
14 template< typename U, typename V > struct QPair;
15 class QPushButton;
16 class QString;
17 class QTextEdit;
18 class QVBoxLayout;
19 
20 
21 namespace Isis {
22  class ControlNet;
23  class ControlMeasure;
24  class ControlPoint;
25  class FilterGroup;
26 
51  class FilterWidget : public QWidget {
52  Q_OBJECT
53 
54  public:
55  explicit FilterWidget(QString);
56  FilterWidget(const FilterWidget &);
57  virtual ~FilterWidget();
58 
59  template< typename T >
60  bool evaluate(const T *t, bool (AbstractFilter::*meth)() const) const {
61  // if andFiltersTogether is true then we break out of the loop as
62  // soon as any selectors evaluate to false. If andFiltersTogether
63  // is false then we are ORing them so we break out as soon as any
64  // selector evaluates to true. Whether we are looking for
65  // successes or failures depends on whether we are ANDing or ORing
66  // the filters (selectors) together!!!
67  bool looking = true;
68  for (int i = 0; looking && i < m_filterGroups->size(); i++) {
69  if (m_filterGroups->at(i)->hasFilter(meth))
70  looking = !(m_filterGroups->at(i)->evaluate(t, meth) ^
71  m_andGroupsTogether);
72  }
73 
74  // It is good that we are still looking for failures if we were
75  // ANDing filters together, but it is bad if we were ORing them
76  // since in this case we were looking for success (unless of
77  // course there were no filters to look through).
78  return !(looking ^ m_andGroupsTogether) || !hasFilter(meth);
79  }
80 
81  bool evaluate(const QPair<QString, ControlNet *> *) const;
82  bool evaluate(const ControlPoint *point) const;
83  bool evaluate(const ControlMeasure *measure) const;
84 
85  bool hasFilter(bool (AbstractFilter:: *)() const) const;
86 
87  FilterWidget &operator=(FilterWidget other);
88 
89 
90  signals:
91  void filterChanged();
92  void scrollToBottom();
93 
94 
95  private:
96  void nullify();
97  void init();
98  QList< FilterGroup * > groupsWithCondition(
99  bool (FilterGroup:: *)() const) const;
100 
101  void updateDescription(QLabel *label,
102  bool (AbstractFilter:: *)() const,
103  QString(AbstractFilter:: *)() const,
104  QString);
105 
106  void addGroup(FilterGroup *newGroup);
107 
108 
109  private slots:
110  void addGroup();
111  void deleteGroup(FilterGroup *);
112  void changeGroupCombinationLogic(int);
113  void updateDescription();
114  void maybeScroll(FilterGroup *);
115 
116 
117  private:
118  QPushButton *m_addGroupButton;
119  QButtonGroup *m_buttonGroup;
120  QLabel *m_imageDescription;
121  QLabel *m_imageDummy;
122  QLabel *m_pointDescription;
123  QLabel *m_pointDummy;
124  QLabel *m_measureDescription;
125  QLabel *m_measureDummy;
126  QVBoxLayout *m_mainLayout;
127  QWidget *m_logicWidget;
128 
129  bool m_andGroupsTogether;
130 
131  QList< FilterGroup * > * m_filterGroups;
132  QString *m_filterType;
133  };
134 }
135 
136 #endif
A single control point.
Definition: ControlPoint.h:369
This class provides an interface for a group of filters.
Definition: FilterGroup.h:33
Namespace for ISIS/Bullet specific routines.
Definition: Apollo.h:31
a control measurement
Base class for control net filters.
This widget contains filtering capabilities for a single filter type.
Definition: FilterWidget.h:51