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)  

Double2MonthFilter.h
Go to the documentation of this file.
1 
12 
30 #ifndef DOUBLE2MONTH_FILTER_H
31 #define DOUBLE2MONTH_FILTER_H
32 
33 #include "../AbstractSimpleFilter.h"
34 #include <QDateTime>
35 #include <math.h>
36 #include "lib/XmlStreamReader.h"
37 #include <QXmlStreamWriter>
38 
41 {
42  Q_OBJECT
43  public:
44  virtual QDate dateAt(int row) const {
45  return dateTimeAt(row).date();
46  }
47  virtual QTime timeAt(int row) const {
48  return dateTimeAt(row).time();
49  }
50  virtual QDateTime dateTimeAt(int row) const {
51  if (!d_inputs.value(0)) return QDateTime();
52  double input_value = d_inputs.value(0)->valueAt(row);
53  // Don't use Julian days here since support for years < 1 is bad
54  // Use 1900-01-01 instead
55  QDate result_date = QDate(1900,1,1).addMonths(qRound(input_value - 1.0));
56  QTime result_time = QTime(0,0,0,0);
57  return QDateTime(result_date, result_time);
58  }
59 
62 
63  protected:
64  virtual bool inputAcceptable(int, const AbstractColumn *source) {
65  return source->dataType() == SciDAVis::TypeDouble;
66  }
67 };
68 
69 #endif // ifndef DOUBLE2MONTH_FILTER_H
70 
SciDAVis::ColumnDataType
ColumnDataType
Column data type.
Definition: globals.h:77
Double2MonthFilter::timeAt
virtual QTime timeAt(int row) const
Return the time part of row 'row'.
Definition: Double2MonthFilter.h:47
Double2MonthFilter::dataType
virtual SciDAVis::ColumnDataType dataType() const
Return the data type of the column.
Definition: Double2MonthFilter.h:61
AbstractColumn::dataType
virtual SciDAVis::ColumnDataType dataType() const =0
Return the data type of the column.
Double2MonthFilter::inputAcceptable
virtual bool inputAcceptable(int, const AbstractColumn *source)
Give implementations a chance to reject connections to their input ports.
Definition: Double2MonthFilter.h:64
Double2MonthFilter
Conversion filter double -> QDateTime, interpreting the input numbers as months of the year.
Definition: Double2MonthFilter.h:41
XmlStreamReader.h
SciDAVis::TypeDouble
@ TypeDouble
Definition: globals.h:78
Double2MonthFilter::dateTimeAt
virtual QDateTime dateTimeAt(int row) const
Set the content of row 'row'.
Definition: Double2MonthFilter.h:50
AbstractSimpleFilter
Simplified filter interface for filters with only one output port.
Definition: AbstractSimpleFilter.h:129
SciDAVis::TypeQDateTime
@ TypeQDateTime
Definition: globals.h:80
AbstractFilter::d_inputs
QVector< const AbstractColumn * > d_inputs
The data sources connected to my input ports.
Definition: AbstractFilter.h:275
Double2MonthFilter::dateAt
virtual QDate dateAt(int row) const
Return the date part of row 'row'.
Definition: Double2MonthFilter.h:44
AbstractColumn
Interface definition for data with column logic.
Definition: AbstractColumn.h:82