SciDAVis
1.D4
Main Page
Related Pages
Namespaces
Classes
Files
File List
File Members
scidavis
src
future
core
datatypes
DateTime2DoubleFilter.h
Go to the documentation of this file.
1
/***************************************************************************
2
File : DateTime2DoubleFilter.h
3
Project : SciDAVis
4
--------------------------------------------------------------------
5
Copyright : (C) 2007 by Tilman Benkert,
6
Knut Franke
7
Email (use @ for *) : thzs*gmx.net, knut.franke*gmx.de
8
Description : Conversion filter QDateTime -> double (using Julian day).
9
10
***************************************************************************/
11
12
/***************************************************************************
13
* *
14
* This program is free software; you can redistribute it and/or modify *
15
* it under the terms of the GNU General Public License as published by *
16
* the Free Software Foundation; either version 2 of the License, or *
17
* (at your option) any later version. *
18
* *
19
* This program is distributed in the hope that it will be useful, *
20
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
21
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
22
* GNU General Public License for more details. *
23
* *
24
* You should have received a copy of the GNU General Public License *
25
* along with this program; if not, write to the Free Software *
26
* Foundation, Inc., 51 Franklin Street, Fifth Floor, *
27
* Boston, MA 02110-1301 USA *
28
* *
29
***************************************************************************/
30
#ifndef DATE_TIME2DOUBLE_FILTER_H
31
#define DATE_TIME2DOUBLE_FILTER_H
32
33
#include "../AbstractSimpleFilter.h"
34
#include <QDateTime>
35
#include <QDate>
36
#include <QTime>
37
#include "
lib/XmlStreamReader.h
"
38
#include <QXmlStreamWriter>
39
41
class
DateTime2DoubleFilter
:
public
AbstractSimpleFilter
42
{
43
Q_OBJECT
44
45
public
:
46
virtual
double
valueAt
(
int
row)
const
{
47
if
(!
d_inputs
.value(0))
return
0;
48
QDateTime input_value =
d_inputs
.value(0)->dateTimeAt(row);
49
return
double(input_value.date().toJulianDay()) +
50
double
( -input_value.time().msecsTo(QTime(12,0,0,0)) ) / 86400000.0;
51
}
52
54
virtual
SciDAVis::ColumnDataType
dataType
()
const
{
return
SciDAVis::TypeDouble
; }
55
56
protected
:
58
virtual
bool
inputAcceptable
(
int
,
const
AbstractColumn
*source) {
59
return
source->
dataType
() ==
SciDAVis::TypeQDateTime
;
60
}
61
};
62
63
#endif // ifndef DATE_TIME2DOUBLE_FILTER_H
64
Generated by
1.8.1