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)  

IntervalAttribute< T > Class Template Reference

A class representing an interval-based attribute. More...

#include <IntervalAttribute.h>

Public Member Functions

void setValue (Interval< int > i, T value)
 
void setValue (int row, T value)
 
value (int row) const
 
void insertRows (int before, int count)
 
void removeRows (int first, int count)
 
void clear ()
 
QList< Interval< int > > intervals () const
 
QList< T > values () const
 
IntervalAttribute< T > & operator= (const IntervalAttribute< T > &other)
 

Private Attributes

QList< T > d_values
 
QList< Interval< int > > d_intervals
 

Detailed Description

template<class T>
class IntervalAttribute< T >

A class representing an interval-based attribute.

File : IntervalAttribute.h

Project : SciDAVis

Copyright : (C) 2007 by Knut Franke, Tilman Benkert Email (use @ for *) : knut.franke*gmx.de, thzs*gmx.net Description : A class representing an interval-based attribute

  • This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. *
    • This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. *
    • You should have received a copy of the GNU General Public License * along with d_intervals program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, * Boston, MA 02110-1301 USA *

Definition at line 37 of file IntervalAttribute.h.

Member Function Documentation

◆ clear()

template<class T >
void IntervalAttribute< T >::clear ( )
inline

Definition at line 176 of file IntervalAttribute.h.

176 { d_values.clear(); d_intervals.clear(); }

◆ insertRows()

template<class T >
void IntervalAttribute< T >::insertRows ( int  before,
int  count 
)
inline

Definition at line 94 of file IntervalAttribute.h.

95  {
96  QList< Interval<int> > temp_list;
97  // first: split all intervals that contain 'before'
98  for(int c=0; c<d_intervals.size(); c++)
99  {
100  if(d_intervals.at(c).contains(before))
101  {
102  temp_list = Interval<int>::split(d_intervals.at(c), before);
103  d_intervals.replace(c, temp_list.at(0));
104  if(temp_list.size()>1)
105  {
106  d_intervals.insert(c, temp_list.at(1));
107  d_values.insert(c, d_values.at(c));
108  c++;
109  }
110 
111  }
112  }
113  // second: translate all intervals that start at 'before' or later
114  for(int c=0; c<d_intervals.size(); c++)
115  {
116  if(d_intervals.at(c).start() >= before)
117  d_intervals[c].translate(count);
118  }
119 
120  }

◆ intervals()

template<class T >
QList< Interval<int> > IntervalAttribute< T >::intervals ( ) const
inline

Definition at line 178 of file IntervalAttribute.h.

178 { return d_intervals; }

Referenced by Column::Private::formulaIntervals(), and IntervalAttribute< QString >::operator=().

Here is the caller graph for this function:

◆ operator=()

template<class T >
IntervalAttribute<T>& IntervalAttribute< T >::operator= ( const IntervalAttribute< T > &  other)
inline

Definition at line 180 of file IntervalAttribute.h.

181  {
182  d_intervals.clear();
183  d_values.clear();
184  foreach( Interval<int> iv, other.intervals())
185  d_intervals.append(iv);
186  foreach( T value, other.values())
187  d_values.append(value);
188  return *this;
189  }

◆ removeRows()

template<class T >
void IntervalAttribute< T >::removeRows ( int  first,
int  count 
)
inline

Definition at line 122 of file IntervalAttribute.h.

123  {
124  QList< Interval<int> > temp_list;
125  Interval<int> i(first, first+count-1);
126  // first: remove the relevant rows from all intervals
127  for(int c=0; c<d_intervals.size(); c++)
128  {
129  temp_list = Interval<int>::subtract(d_intervals.at(c), i);
130  if(temp_list.isEmpty())
131  {
132  d_intervals.removeAt(c);
133  d_values.removeAt(c--);
134  }
135  else
136  {
137  d_intervals.replace(c, temp_list.at(0));
138  if(temp_list.size()>1)
139  {
140  d_intervals.insert(c, temp_list.at(1));
141  d_values.insert(c, d_values.at(c));
142  c++;
143  }
144  }
145  }
146  // second: translate all intervals that start at 'first+count' or later
147  for(int c=0; c<d_intervals.size(); c++)
148  {
149  if(d_intervals.at(c).start() >= first+count)
150  d_intervals[c].translate(-count);
151  }
152  // third: merge as many intervals as possible
153  QList<T> values_copy = d_values;
154  QList< Interval<int> > intervals_copy = d_intervals;
155  d_values.clear();
156  d_intervals.clear();
157  for(int c=0; c<intervals_copy.size(); c++)
158  {
159  i = intervals_copy.at(c);
160  T value = values_copy.at(c);
161  for(int cc=0; cc<d_intervals.size(); cc++)
162  {
163  if( d_intervals.at(cc).touches(i) &&
164  d_values.at(cc) == value )
165  {
166  d_intervals.replace(cc, Interval<int>::merge(d_intervals.at(cc),i));
167  return;
168  }
169  }
170  // if it could not be merged, just append it
171  d_intervals.append(i);
172  d_values.append(value);
173  }
174  }

◆ setValue() [1/2]

template<class T >
void IntervalAttribute< T >::setValue ( int  row,
value 
)
inline

Definition at line 79 of file IntervalAttribute.h.

80  {
81  setValue(Interval<int>(row, row), value);
82  }

◆ setValue() [2/2]

template<class T >
void IntervalAttribute< T >::setValue ( Interval< int >  i,
value 
)
inline

Definition at line 40 of file IntervalAttribute.h.

41  {
42  // first: subtract the new interval from all others
43  QList< Interval<int> > temp_list;
44  for(int c=0; c<d_intervals.size(); c++)
45  {
46  temp_list = Interval<int>::subtract(d_intervals.at(c), i);
47  if(temp_list.isEmpty())
48  {
49  d_intervals.removeAt(c);
50  d_values.removeAt(c--);
51  }
52  else
53  {
54  d_intervals.replace(c, temp_list.at(0));
55  if(temp_list.size()>1)
56  {
57  d_intervals.insert(c, temp_list.at(1));
58  d_values.insert(c, d_values.at(c));
59  }
60  }
61  }
62 
63  // second: try to merge the new interval with an old one
64  for(int c=0; c<d_intervals.size(); c++)
65  {
66  if( d_intervals.at(c).touches(i) &&
67  d_values.at(c) == value )
68  {
69  d_intervals.replace(c, Interval<int>::merge(d_intervals.at(c), i));
70  return;
71  }
72  }
73  // if it could not be merged, just append it
74  d_intervals.append(i);
75  d_values.append(value);
76  }

Referenced by IntervalAttribute< bool >::setValue(), and IntervalAttribute< QString >::setValue().

Here is the caller graph for this function:

◆ value()

template<class T >
T IntervalAttribute< T >::value ( int  row) const
inline

Definition at line 84 of file IntervalAttribute.h.

85  {
86  for(int c=d_intervals.size()-1; c>=0; c--)
87  {
88  if(d_intervals.at(c).contains(row))
89  return d_values.at(c);
90  }
91  return T();
92  }

Referenced by IntervalAttribute< QString >::operator=(), IntervalAttribute< QString >::removeRows(), IntervalAttribute< bool >::setValue(), and IntervalAttribute< QString >::setValue().

Here is the caller graph for this function:

◆ values()

template<class T >
QList<T> IntervalAttribute< T >::values ( ) const
inline

Definition at line 179 of file IntervalAttribute.h.

179 { return d_values; }

Referenced by IntervalAttribute< QString >::operator=().

Here is the caller graph for this function:

Member Data Documentation

◆ d_intervals

◆ d_values


The documentation for this class was generated from the following file:
IntervalAttribute::setValue
void setValue(Interval< int > i, T value)
Definition: IntervalAttribute.h:40
IntervalAttribute::value
T value(int row) const
Definition: IntervalAttribute.h:84
IntervalAttribute::d_intervals
QList< Interval< int > > d_intervals
Definition: IntervalAttribute.h:193
IntervalAttribute::intervals
QList< Interval< int > > intervals() const
Definition: IntervalAttribute.h:178
IntervalAttribute::d_values
QList< T > d_values
Definition: IntervalAttribute.h:192
Interval
Auxiliary class for interval based data.
Definition: Interval.h:211
IntervalAttribute::values
QList< T > values() const
Definition: IntervalAttribute.h:179