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