scidavis  2.3.0
About: SciDAVis is a free application for Scientific Data Analysis and Visualization (a fork off of QtiPlot).
  Fossies Dox: scidavis-2.3.0.tar.gz  ("unofficial" and yet experimental doxygen-generated source code documentation)  

AbstractSimpleFilter.h
Go to the documentation of this file.
1 
12 
30 #ifndef ABSTRACT_SIMPLE_FILTER
31 #define ABSTRACT_SIMPLE_FILTER
32 
33 #include "core/AbstractFilter.h"
34 #include "core/AbstractColumn.h"
35 #include "lib/IntervalAttribute.h"
36 #include "lib/XmlStreamReader.h"
37 #include <QUndoCommand>
38 #include <QXmlStreamWriter>
39 
40 // forward declaration - class follows
41 class SimpleFilterColumn;
42 
129 {
130  Q_OBJECT
131 
132  public:
136  virtual int inputCount() const { return 1; }
138  virtual int outputCount() const { return 1; }
140  virtual AbstractColumn* output(int port);
141  virtual const AbstractColumn * output(int port) const;
144  return d_inputs.value(0) ?
145  d_inputs.at(0)->plotDesignation() :
147  }
150  {
151  // calling this function while d_input is empty is a sign of very bad code
152  // nevertheless it will return some rather meaningless value to
153  // avoid crashes
154  return d_inputs.value(0) ? d_inputs.at(0)->dataType() : SciDAVis::TypeQString;
155  }
157 
163  {
164  // calling this function while d_input is empty is a sign of very bad code
165  // nevertheless it will return some rather meaningless value to
166  // avoid crashes
167  return d_inputs.value(0) ? d_inputs.at(0)->columnMode() : SciDAVis::Text;
168  }
170 
173  virtual QString textAt(int row) const
174  {
175  return d_inputs.value(0) ? d_inputs.at(0)->textAt(row) : QString();
176  }
178 
181  virtual QDate dateAt(int row) const
182  {
183  return d_inputs.value(0) ? d_inputs.at(0)->dateAt(row) : QDate();
184  }
186 
189  virtual QTime timeAt(int row) const
190  {
191  return d_inputs.value(0) ? d_inputs.at(0)->timeAt(row) : QTime();
192  }
194 
197  virtual QDateTime dateTimeAt(int row) const
198  {
199  return d_inputs.value(0) ? d_inputs.at(0)->dateTimeAt(row) : QDateTime();
200  }
202 
205  virtual double valueAt(int row) const
206  {
207  return d_inputs.value(0) ? d_inputs.at(0)->valueAt(row) : 0.0;
208  }
209 
211 
212  virtual int rowCount() const {
213  return d_inputs.value(0) ? d_inputs.at(0)->rowCount() : 0;
214  }
215  virtual QList< Interval<int> > dependentRows(Interval<int> input_range) const { return QList< Interval<int> >() << input_range; }
217 
219 
220  virtual bool isMasked(int row) const { return d_masking.isSet(row); }
223  virtual bool isMasked(Interval<int> i) const { return d_masking.isSet(i); }
225  virtual QList< Interval<int> > maskedIntervals() const { return d_masking.intervals(); }
227  virtual void clearMasks();
229 
233  virtual void setMasked(Interval<int> i, bool mask = true);
235  virtual void setMasked(int row, bool mask = true) { setMasked(Interval<int>(row,row), mask); }
237 
239  virtual bool isInvalid(int row) const { return d_inputs.value(0) ? d_inputs.at(0)->isInvalid(row) : false; }
241  virtual bool isInvalid(Interval<int> i) const { return d_inputs.value(0) ? d_inputs.at(0)->isInvalid(i) : false; }
243  virtual QList< Interval<int> > invalidIntervals() const
244  {
245  return d_inputs.value(0) ? d_inputs.at(0)->invalidIntervals() : QList< Interval<int> >();
246  }
247 
249 
250  virtual void save(QXmlStreamWriter * writer) const;
253  virtual bool load(XmlStreamReader * reader);
255  virtual void writeExtraAttributes(QXmlStreamWriter * writer) const { Q_UNUSED(writer) }
257 
258  protected:
260 
262 
264  virtual void inputPlotDesignationChanged(const AbstractColumn*);
265  virtual void inputModeAboutToChange(const AbstractColumn*);
266  virtual void inputModeChanged(const AbstractColumn*);
267  virtual void inputDataAboutToChange(const AbstractColumn*);
268  virtual void inputDataChanged(const AbstractColumn*);
269 
270  virtual void inputRowsAboutToBeInserted(const AbstractColumn * source, int before, int count);
271  virtual void inputRowsInserted(const AbstractColumn * source, int before, int count);
272  virtual void inputRowsAboutToBeRemoved(const AbstractColumn * source, int first, int count);
273  virtual void inputRowsRemoved(const AbstractColumn * source, int first, int count);
275 
277 };
278 
280 {
281  Q_OBJECT
282 
283  public:
285 
286  virtual SciDAVis::ColumnDataType dataType() const { return d_owner->dataType(); }
287  virtual SciDAVis::ColumnMode columnMode() const { return d_owner->columnMode(); }
288  virtual int rowCount() const { return d_owner->rowCount(); }
290  virtual bool isInvalid(int row) const { return d_owner->isInvalid(row); }
291  virtual bool isInvalid(Interval<int> i) const { return d_owner->isInvalid(i); }
292  virtual QList< Interval<int> > invalidIntervals() const { return d_owner->invalidIntervals(); }
293  virtual bool isMasked(int row) const { return d_owner->isMasked(row); }
294  virtual bool isMasked(Interval<int> i) const { return d_owner->isMasked(i); }
295  virtual QList< Interval<int> > maskedIntervals() const { return d_owner->maskedIntervals(); }
296  virtual void clearMasks() { d_owner->clearMasks(); }
297  virtual QString textAt(int row) const { return d_owner->textAt(row); }
298  virtual QDate dateAt(int row) const { return d_owner->dateAt(row); }
299  virtual QTime timeAt(int row) const { return d_owner->timeAt(row); }
300  virtual QDateTime dateTimeAt(int row) const { return d_owner->dateTimeAt(row); }
301  virtual double valueAt(int row) const { return d_owner->valueAt(row); }
302 
303  private:
305 
306  friend class AbstractSimpleFilter;
307 };
308 
309 #endif // ifndef ABSTRACT_SIMPLE_FILTER
310 
AbstractSimpleFilter::dateAt
virtual QDate dateAt(int row) const
Return the date part of row 'row'.
Definition: AbstractSimpleFilter.h:181
AbstractSimpleFilter::AbstractSimpleFilter
AbstractSimpleFilter()
Ctor.
Definition: AbstractSimpleFilter.cpp:35
AbstractSimpleFilter::dependentRows
virtual QList< Interval< int > > dependentRows(Interval< int > input_range) const
Definition: AbstractSimpleFilter.h:215
AbstractFilter.h
AbstractSimpleFilter::timeAt
virtual QTime timeAt(int row) const
Return the time part of row 'row'.
Definition: AbstractSimpleFilter.h:189
AbstractSimpleFilter::inputModeAboutToChange
virtual void inputModeAboutToChange(const AbstractColumn *)
The display mode and possibly the data type of an input is about to change.
Definition: AbstractSimpleFilter.cpp:65
AbstractSimpleFilter::inputPlotDesignationChanged
virtual void inputPlotDesignationChanged(const AbstractColumn *)
The plot designation of an input changed.
Definition: AbstractSimpleFilter.cpp:60
SciDAVis::TypeQString
@ TypeQString
Definition: globals.h:79
AbstractFilter
Base class for all analysis operations.
Definition: AbstractFilter.h:77
XmlStreamReader
XML stream parser that supports errors as well as warnings.
Definition: XmlStreamReader.h:42
SimpleFilterColumn::maskedIntervals
virtual QList< Interval< int > > maskedIntervals() const
Return all intervals of masked rows.
Definition: AbstractSimpleFilter.h:295
AbstractSimpleFilter::inputModeChanged
virtual void inputModeChanged(const AbstractColumn *)
The display mode and possibly the data type has changed.
Definition: AbstractSimpleFilter.cpp:70
SciDAVis::noDesignation
@ noDesignation
no plot designation
Definition: globals.h:56
SimpleFilterColumn::clearMasks
virtual void clearMasks()
Clear all masking information.
Definition: AbstractSimpleFilter.h:296
SciDAVis::ColumnDataType
ColumnDataType
Column data type.
Definition: globals.h:77
AbstractSimpleFilter::valueAt
virtual double valueAt(int row) const
Return the double value in row 'row'.
Definition: AbstractSimpleFilter.h:205
AbstractSimpleFilter::d_masking
IntervalAttribute< bool > d_masking
Definition: AbstractSimpleFilter.h:259
SimpleFilterColumn::textAt
virtual QString textAt(int row) const
Return the content of row 'row'.
Definition: AbstractSimpleFilter.h:297
SimpleFilterColumn::isInvalid
virtual bool isInvalid(Interval< int > i) const
Return whether a certain interval of rows contains only invalid values
Definition: AbstractSimpleFilter.h:291
IntervalAttribute< bool >
A class representing an interval-based attribute (bool version)
Definition: IntervalAttribute.h:198
SimpleFilterColumn::rowCount
virtual int rowCount() const
Return the data vector size.
Definition: AbstractSimpleFilter.h:288
AbstractSimpleFilter::dateTimeAt
virtual QDateTime dateTimeAt(int row) const
Set the content of row 'row'.
Definition: AbstractSimpleFilter.h:197
SimpleFilterColumn::dataType
virtual SciDAVis::ColumnDataType dataType() const
Return the data type of the column.
Definition: AbstractSimpleFilter.h:286
AbstractSimpleFilter::d_output_column
SimpleFilterColumn * d_output_column
Definition: AbstractSimpleFilter.h:276
SciDAVis::ColumnMode
ColumnMode
The column mode (defines output and input filter for table columns)
Definition: globals.h:66
AbstractSimpleFilter::dataType
virtual SciDAVis::ColumnDataType dataType() const
Return the data type of the input.
Definition: AbstractSimpleFilter.h:149
SimpleFilterColumn::d_owner
AbstractSimpleFilter * d_owner
Definition: AbstractSimpleFilter.h:304
SimpleFilterColumn::timeAt
virtual QTime timeAt(int row) const
Set the content of row 'row'.
Definition: AbstractSimpleFilter.h:299
AbstractSimpleFilter::columnMode
virtual SciDAVis::ColumnMode columnMode() const
Return the column mode.
Definition: AbstractSimpleFilter.h:162
AbstractSimpleFilter::inputRowsRemoved
virtual void inputRowsRemoved(const AbstractColumn *source, int first, int count)
Definition: AbstractSimpleFilter.cpp:108
AbstractSimpleFilter::inputDataAboutToChange
virtual void inputDataAboutToChange(const AbstractColumn *)
The data of an input is about to change.
Definition: AbstractSimpleFilter.cpp:75
AbstractSimpleFilter::save
virtual void save(QXmlStreamWriter *writer) const
Save to XML.
Definition: AbstractSimpleFilter.cpp:125
AbstractSimpleFilter::inputRowsInserted
virtual void inputRowsInserted(const AbstractColumn *source, int before, int count)
Definition: AbstractSimpleFilter.cpp:93
IntervalAttribute.h
AbstractSimpleFilter::inputPlotDesignationAboutToChange
virtual void inputPlotDesignationAboutToChange(const AbstractColumn *)
The plot designation of an input is about to change.
Definition: AbstractSimpleFilter.cpp:55
AbstractSimpleFilter::isInvalid
virtual bool isInvalid(Interval< int > i) const
Return whether a certain interval of rows contains only invalid values
Definition: AbstractSimpleFilter.h:241
AbstractSimpleFilter::rowCount
virtual int rowCount() const
Definition: AbstractSimpleFilter.h:212
AbstractSimpleFilter::output
virtual AbstractColumn * output(int port)
Return a pointer to d_output_column on port 0 (don't override unless you really know what you are doi...
Definition: AbstractSimpleFilter.cpp:115
AbstractSimpleFilter::inputCount
virtual int inputCount() const
Default to one input port.
Definition: AbstractSimpleFilter.h:136
AbstractAspect::name
QString name() const
Definition: AbstractAspect.cpp:229
AbstractSimpleFilter::isInvalid
virtual bool isInvalid(int row) const
Return whether a certain row contains an invalid value
Definition: AbstractSimpleFilter.h:239
AbstractSimpleFilter::maskedIntervals
virtual QList< Interval< int > > maskedIntervals() const
Return all intervals of masked rows.
Definition: AbstractSimpleFilter.h:225
SimpleFilterColumn
Definition: AbstractSimpleFilter.h:280
XmlStreamReader.h
SciDAVis::Text
@ Text
column contains strings
Definition: globals.h:68
AbstractSimpleFilter::clearMasks
virtual void clearMasks()
Clear all masking information.
Definition: AbstractSimpleFilter.cpp:41
AbstractSimpleFilter::setMasked
virtual void setMasked(int row, bool mask=true)
Overloaded function for convenience.
Definition: AbstractSimpleFilter.h:235
AbstractSimpleFilter::writeExtraAttributes
virtual void writeExtraAttributes(QXmlStreamWriter *writer) const
Override this in derived classes if they have other attributes than filter_name.
Definition: AbstractSimpleFilter.h:255
AbstractSimpleFilter::inputDataChanged
virtual void inputDataChanged(const AbstractColumn *)
The data of an input has changed.
Definition: AbstractSimpleFilter.cpp:80
AbstractSimpleFilter::inputRowsAboutToBeRemoved
virtual void inputRowsAboutToBeRemoved(const AbstractColumn *source, int first, int count)
Definition: AbstractSimpleFilter.cpp:101
SimpleFilterColumn::SimpleFilterColumn
SimpleFilterColumn(AbstractSimpleFilter *owner)
Definition: AbstractSimpleFilter.h:284
AbstractSimpleFilter::invalidIntervals
virtual QList< Interval< int > > invalidIntervals() const
Return all intervals of invalid rows.
Definition: AbstractSimpleFilter.h:243
SimpleFilterColumn::columnMode
virtual SciDAVis::ColumnMode columnMode() const
Return the column mode.
Definition: AbstractSimpleFilter.h:287
AbstractSimpleFilter::load
virtual bool load(XmlStreamReader *reader)
Load from XML.
Definition: AbstractSimpleFilter.cpp:135
SimpleFilterColumn::invalidIntervals
virtual QList< Interval< int > > invalidIntervals() const
Return all intervals of invalid rows.
Definition: AbstractSimpleFilter.h:292
SimpleFilterColumn::dateAt
virtual QDate dateAt(int row) const
Return the date part of row 'row'.
Definition: AbstractSimpleFilter.h:298
AbstractSimpleFilter::inputRowsAboutToBeInserted
virtual void inputRowsAboutToBeInserted(const AbstractColumn *source, int before, int count)
Definition: AbstractSimpleFilter.cpp:85
SimpleFilterColumn::isMasked
virtual bool isMasked(int row) const
Return whether a certain row is masked
Definition: AbstractSimpleFilter.h:293
AbstractSimpleFilter::outputCount
virtual int outputCount() const
We manage only one output port (don't override unless you really know what you are doing).
Definition: AbstractSimpleFilter.h:138
AbstractSimpleFilter::setMasked
virtual void setMasked(Interval< int > i, bool mask=true)
Set an interval masked.
Definition: AbstractSimpleFilter.cpp:48
SciDAVis::PlotDesignation
PlotDesignation
Types of plot designations.
Definition: globals.h:55
IntervalAttribute< bool >::intervals
QList< Interval< int > > intervals() const
Definition: IntervalAttribute.h:292
AbstractSimpleFilter::isMasked
virtual bool isMasked(Interval< int > i) const
Return whether a certain interval of rows rows is fully masked.
Definition: AbstractSimpleFilter.h:223
AbstractSimpleFilter::isMasked
virtual bool isMasked(int row) const
Return whether a certain row is masked.
Definition: AbstractSimpleFilter.h:221
AbstractSimpleFilter::plotDesignation
virtual SciDAVis::PlotDesignation plotDesignation() const
Copy plot designation of input port 0.
Definition: AbstractSimpleFilter.h:143
AbstractColumn.h
AbstractSimpleFilter
Simplified filter interface for filters with only one output port.
Definition: AbstractSimpleFilter.h:129
SimpleFilterColumn::plotDesignation
virtual SciDAVis::PlotDesignation plotDesignation() const
Return the column plot designation.
Definition: AbstractSimpleFilter.h:289
SimpleFilterColumn::valueAt
virtual double valueAt(int row) const
Return the double value in row 'row'.
Definition: AbstractSimpleFilter.h:301
IntervalAttribute< bool >::isSet
bool isSet(int row) const
Definition: IntervalAttribute.h:229
Interval< int >
AbstractFilter::d_inputs
QVector< const AbstractColumn * > d_inputs
The data sources connected to my input ports.
Definition: AbstractFilter.h:275
SimpleFilterColumn::isInvalid
virtual bool isInvalid(int row) const
Return whether a certain row contains an invalid value
Definition: AbstractSimpleFilter.h:290
SimpleFilterColumn::isMasked
virtual bool isMasked(Interval< int > i) const
Return whether a certain interval of rows rows is fully masked
Definition: AbstractSimpleFilter.h:294
SimpleFilterColumn::dateTimeAt
virtual QDateTime dateTimeAt(int row) const
Set the content of row 'row'.
Definition: AbstractSimpleFilter.h:300
AbstractColumn
Interface definition for data with column logic.
Definition: AbstractColumn.h:82
AbstractSimpleFilter::textAt
virtual QString textAt(int row) const
Return the content of row 'row'.
Definition: AbstractSimpleFilter.h:173