Isis Developer Reference
FilterWidget.h
Go to the documentation of this file.
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 
95 
96 
97  signals:
98  void filterChanged();
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
Isis::AbstractFilter::getImageDescription
virtual QString getImageDescription() const
Definition: AbstractFilter.cpp:98
Isis::AbstractFilter::canFilterMeasures
virtual bool canFilterMeasures() const
Definition: AbstractFilter.cpp:93
FileName.h
QWidget
QList
This is free and unencumbered software released into the public domain.
Definition: BoxcarCachingAlgorithm.h:13
Isis::FilterWidget::FilterWidget
FilterWidget(QString)
Definition: FilterWidget.cpp:37
Isis::AbstractFilter
Base class for control net filters.
Definition: AbstractFilter.h:46
Isis::FilterWidget::evaluate
bool evaluate(const T *t, bool(AbstractFilter::*meth)() const) const
Definition: FilterWidget.h:67
IString.h
FilterWidget.h
FilterGroup.h
Isis::ControlPoint
A single control point.
Definition: ControlPoint.h:354
Isis::AbstractFilter::canFilterPoints
virtual bool canFilterPoints() const
Definition: AbstractFilter.cpp:88
_FILEINFO_
#define _FILEINFO_
Macro for the filename and line number.
Definition: IException.h:24
Isis::AbstractFilter::getPointDescription
virtual QString getPointDescription() const
Definition: AbstractFilter.cpp:103
Isis::FilterWidget::operator=
FilterWidget & operator=(FilterWidget other)
Definition: FilterWidget.cpp:108
Isis::FilterWidget::evaluate
bool evaluate(const ControlPoint *point) const
Definition: FilterWidget.cpp:88
Isis::FilterWidget::filterChanged
void filterChanged()
Isis::AbstractFilter::canFilterImages
virtual bool canFilterImages() const
Definition: AbstractFilter.cpp:83
Isis::IException
Isis exception class.
Definition: IException.h:91
ASSERT
#define ASSERT(x)
Definition: IsisDebug.h:134
Isis::FilterWidget::scrollToBottom
void scrollToBottom()
Isis::FilterWidget::~FilterWidget
virtual ~FilterWidget()
Definition: FilterWidget.cpp:65
IException.h
Isis::IException::Programmer
@ Programmer
This error is for when a programmer made an API call that was illegal.
Definition: IException.h:146
QPair
This is free and unencumbered software released into the public domain.
Definition: CubeIoHandler.h:23
Isis::FilterWidget::hasFilter
bool hasFilter(bool(AbstractFilter::*)() const) const
Definition: FilterWidget.cpp:98
Isis::FilterWidget
This widget contains filtering capabilities for a single filter type.
Definition: FilterWidget.h:58
Isis::IString
Adds specific functionality to C++ strings.
Definition: IString.h:165
IsisDebug.h
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
Isis::AbstractFilter::getMeasureDescription
virtual QString getMeasureDescription() const
Definition: AbstractFilter.cpp:108