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)  

ColumnPrivate.cpp
Go to the documentation of this file.
1 
11 
31 #include "core/column/Column.h"
46 #include <QString>
47 #include <QStringList>
48 #include <QSettings>
49 #include <QtDebug>
50 
51 #include <stdexcept>
52 using namespace std;
53 
55  : d_owner(owner)
56 {
57  Q_ASSERT(owner != 0); // a Column::Private without owner is not allowed
58  // because the owner must become the parent aspect of the input and output filters
59  d_column_mode = mode;
60  switch(mode)
61  {
62  case SciDAVis::Numeric:
65 #ifdef LEGACY_CODE_0_2_x // TODO: in a later version this must use the new global setting method
66  {
67 #ifdef Q_OS_MAC // Mac
68  QSettings settings(QSettings::IniFormat,QSettings::UserScope, "SciDAVis", "SciDAVis");
69 #else
70  QSettings settings(QSettings::NativeFormat,QSettings::UserScope, "SciDAVis", "SciDAVis");
71 #endif
72  settings.beginGroup("/General");
73  static_cast<Double2StringFilter *>(d_output_filter)->setNumDigits(settings.value("/DecimalDigits", 14).toInt());
74  static_cast<Double2StringFilter *>(d_output_filter)->setNumericFormat(settings.value("/DefaultNumericFormat", 'f').toChar().toLatin1());
75  }
76 #endif
77  connect(static_cast<Double2StringFilter *>(d_output_filter), SIGNAL(formatChanged()),
78  d_owner, SLOT(notifyDisplayChange()));
80  d_data = new QVector<double>();
81  break;
82  case SciDAVis::Text:
86  d_data = new QStringList();
87  break;
88  case SciDAVis::DateTime:
91  connect(static_cast<DateTime2StringFilter *>(d_output_filter), SIGNAL(formatChanged()),
92  d_owner, SLOT(notifyDisplayChange()));
94  d_data = new QList<QDateTime>();
95  break;
96  case SciDAVis::Month:
99  static_cast<DateTime2StringFilter *>(d_output_filter)->setFormat("MMMM");
100  connect(static_cast<DateTime2StringFilter *>(d_output_filter), SIGNAL(formatChanged()),
101  d_owner, SLOT(notifyDisplayChange()));
103  d_data = new QList<QDateTime>();
104  break;
105  case SciDAVis::Day:
108  static_cast<DateTime2StringFilter *>(d_output_filter)->setFormat("dddd");
109  connect(static_cast<DateTime2StringFilter *>(d_output_filter), SIGNAL(formatChanged()),
110  d_owner, SLOT(notifyDisplayChange()));
112  d_data = new QList<QDateTime>();
113  break;
114  } // switch(mode)
115 
117  d_input_filter->setName("InputFilter");
118  d_output_filter->setName("OutputFilter");
119 }
120 
122  void * data, IntervalAttribute<bool> validity)
123  : d_owner(owner)
124 {
125  d_data_type = type;
126  d_column_mode = mode;
127  d_data = data;
128  d_validity = validity;
129 
130  switch(mode)
131  {
132  case SciDAVis::Numeric:
135 #ifdef LEGACY_CODE_0_2_x // TODO: in a later version this must use the new global setting method
136  {
137 #ifdef Q_OS_MAC // Mac
138  QSettings settings(QSettings::IniFormat,QSettings::UserScope, "SciDAVis", "SciDAVis");
139 #else
140  QSettings settings(QSettings::NativeFormat,QSettings::UserScope, "SciDAVis", "SciDAVis");
141 #endif
142  settings.beginGroup("/General");
143  static_cast<Double2StringFilter *>(d_output_filter)->setNumDigits(settings.value("/DecimalDigits", 14).toInt());
144  static_cast<Double2StringFilter *>(d_output_filter)->setNumericFormat(settings.value("/DefaultNumericFormat", 'f').toChar().toLatin1());
145  }
146 #endif
147  connect(static_cast<Double2StringFilter *>(d_output_filter), SIGNAL(formatChanged()),
148  d_owner, SLOT(notifyDisplayChange()));
149  break;
150  case SciDAVis::Text:
153  break;
154  case SciDAVis::DateTime:
157  connect(static_cast<DateTime2StringFilter *>(d_output_filter), SIGNAL(formatChanged()),
158  d_owner, SLOT(notifyDisplayChange()));
159  break;
160  case SciDAVis::Month:
163  static_cast<DateTime2StringFilter *>(d_output_filter)->setFormat("MMMM");
164  connect(static_cast<DateTime2StringFilter *>(d_output_filter), SIGNAL(formatChanged()),
165  d_owner, SLOT(notifyDisplayChange()));
166  break;
167  case SciDAVis::Day:
170  static_cast<DateTime2StringFilter *>(d_output_filter)->setFormat("dddd");
171  connect(static_cast<DateTime2StringFilter *>(d_output_filter), SIGNAL(formatChanged()),
172  d_owner, SLOT(notifyDisplayChange()));
173  break;
174  } // switch(mode)
175 
177  d_input_filter->setName("InputFilter");
178  d_output_filter->setName("OutputFilter");
179 }
180 
182 {
183  if (!d_data) return;
184 
185  switch(d_data_type)
186  {
188  delete static_cast< QVector<double>* >(d_data);
189  break;
190 
192  delete static_cast< QStringList* >(d_data);
193  break;
194 
196  delete static_cast< QList<QDateTime>* >(d_data);
197  break;
198  } // switch(d_data_type)
199 }
200 
202 {
203  if (mode == d_column_mode) return;
204 
205  void * old_data = d_data;
206  // remark: the deletion of the old data will be done in the dtor of a command
207 
208  AbstractSimpleFilter *new_in_filter, *new_out_filter;
209  bool filter_is_temporary; // it can also become outputFilter(), which we may not delete here
210  Column* temp_col = 0;
211  if (filter)
212  filter_is_temporary = false;
213 
214  emit d_owner->modeAboutToChange(d_owner);
215 
216  // determine the conversion filter and allocate the new data vector
217  switch(d_column_mode)
218  {
219  case SciDAVis::Numeric:
220  disconnect(static_cast<Double2StringFilter *>(d_output_filter), SIGNAL(formatChanged()),
221  d_owner, SLOT(notifyDisplayChange()));
222  switch(mode)
223  {
224  case SciDAVis::Numeric:
225  break;
226  case SciDAVis::Text:
227  if (!filter) {
228  filter = outputFilter(); filter_is_temporary = false;
229  }
230  temp_col = new Column("temp_col", *(static_cast< QVector<qreal>* >(old_data)), d_validity);
231  d_data = new QStringList();
232  d_data_type = SciDAVis::TypeQString;
233  break;
234  case SciDAVis::DateTime:
235  if (!filter) {
236  filter = new Double2DateTimeFilter(); filter_is_temporary = true;
237  }
238  temp_col = new Column("temp_col", *(static_cast< QVector<qreal>* >(old_data)), d_validity);
239  d_data = new QList<QDateTime>();
240  d_data_type = SciDAVis::TypeQDateTime;
241  break;
242  case SciDAVis::Month:
243  if (!filter) {
244  filter = new Double2MonthFilter(); filter_is_temporary = true;
245  }
246  temp_col = new Column("temp_col", *(static_cast< QVector<qreal>* >(old_data)), d_validity);
247  d_data = new QList<QDateTime>();
248  d_data_type = SciDAVis::TypeQDateTime;
249  break;
250  case SciDAVis::Day:
251  if (!filter) {
252  filter = new Double2DayOfWeekFilter(); filter_is_temporary = true;
253  }
254  temp_col = new Column("temp_col", *(static_cast< QVector<qreal>* >(old_data)), d_validity);
255  d_data = new QList<QDateTime>();
256  d_data_type = SciDAVis::TypeQDateTime;
257  break;
258  } // switch(mode)
259  break;
260 
261  case SciDAVis::Text:
262  switch(mode)
263  {
264  case SciDAVis::Text:
265  break;
266  case SciDAVis::Numeric:
267  if (!filter) {
268  filter = new String2DoubleFilter(); filter_is_temporary = true;
269  }
270  temp_col = new Column("temp_col", *(static_cast< QStringList* >(old_data)), d_validity);
271  d_data = new QVector<double>();
272  d_data_type = SciDAVis::TypeDouble;
273  break;
274  case SciDAVis::DateTime:
275  if (!filter) {
276  filter = new String2DateTimeFilter(); filter_is_temporary = true;
277  }
278  temp_col = new Column("temp_col", *(static_cast< QStringList* >(old_data)), d_validity);
279  d_data = new QList<QDateTime>();
280  d_data_type = SciDAVis::TypeQDateTime;
281  break;
282  case SciDAVis::Month:
283  if (!filter) {
284  filter = new String2MonthFilter(); filter_is_temporary = true;
285  }
286  temp_col = new Column("temp_col", *(static_cast< QStringList* >(old_data)), d_validity);
287  d_data = new QList<QDateTime>();
288  d_data_type = SciDAVis::TypeQDateTime;
289  break;
290  case SciDAVis::Day:
291  if (!filter) {
292  filter = new String2DayOfWeekFilter(); filter_is_temporary = true;
293  }
294  temp_col = new Column("temp_col", *(static_cast< QStringList* >(old_data)), d_validity);
295  d_data = new QList<QDateTime>();
296  d_data_type = SciDAVis::TypeQDateTime;
297  break;
298  } // switch(mode)
299  break;
300 
301  case SciDAVis::DateTime:
302  case SciDAVis::Month:
303  case SciDAVis::Day:
304  disconnect(static_cast<DateTime2StringFilter *>(d_output_filter), SIGNAL(formatChanged()),
305  d_owner, SLOT(notifyDisplayChange()));
306  switch(mode)
307  {
308  case SciDAVis::DateTime:
309  break;
310  case SciDAVis::Text:
311  if (!filter) {
312  filter = outputFilter(); filter_is_temporary = false;
313  }
314  temp_col = new Column("temp_col", *(static_cast< QList<QDateTime>* >(old_data)), d_validity);
315  d_data = new QStringList();
316  d_data_type = SciDAVis::TypeQString;
317  break;
318  case SciDAVis::Numeric:
319  if (!filter) {
320  if (d_column_mode == SciDAVis::Month)
321  filter = new Month2DoubleFilter();
322  else if (d_column_mode == SciDAVis::Day)
323  filter = new DayOfWeek2DoubleFilter();
324  else
325  filter = new DateTime2DoubleFilter();
326  filter_is_temporary = true;
327  }
328  temp_col = new Column("temp_col", *(static_cast< QList<QDateTime>* >(old_data)), d_validity);
329  d_data = new QVector<double>();
330  d_data_type = SciDAVis::TypeDouble;
331  break;
332  case SciDAVis::Month:
333  case SciDAVis::Day:
334  break;
335  } // switch(mode)
336  break;
337 
338  }
339 
340  // determine the new input and output filters
341  switch(mode)
342  {
343  case SciDAVis::Numeric:
344  new_in_filter = new String2DoubleFilter();
345  new_out_filter = new Double2StringFilter();
346 #ifdef LEGACY_CODE_0_2_x // TODO: in a later version this must use the new global setting method
347  {
348 #ifdef Q_OS_MAC // Mac
349  QSettings settings(QSettings::IniFormat,QSettings::UserScope, "SciDAVis", "SciDAVis");
350 #else
351  QSettings settings(QSettings::NativeFormat,QSettings::UserScope, "SciDAVis", "SciDAVis");
352 #endif
353  settings.beginGroup("/General");
354  static_cast<Double2StringFilter *>(new_out_filter)->setNumDigits(settings.value("/DecimalDigits", 14).toInt());
355  static_cast<Double2StringFilter *>(new_out_filter)->setNumericFormat(settings.value("/DefaultNumericFormat", 'f').toChar().toLatin1());
356  }
357 #endif
358  connect(static_cast<Double2StringFilter *>(new_out_filter), SIGNAL(formatChanged()),
359  d_owner, SLOT(notifyDisplayChange()));
360  break;
361  case SciDAVis::Text:
362  new_in_filter = new SimpleCopyThroughFilter();
363  new_out_filter = new SimpleCopyThroughFilter();
364  break;
365  case SciDAVis::DateTime:
366  new_in_filter = new String2DateTimeFilter();
367  new_out_filter = new DateTime2StringFilter();
368  connect(static_cast<DateTime2StringFilter *>(new_out_filter), SIGNAL(formatChanged()),
369  d_owner, SLOT(notifyDisplayChange()));
370  break;
371  case SciDAVis::Month:
372  new_in_filter = new String2MonthFilter();
373  new_out_filter = new DateTime2StringFilter();
374  static_cast<DateTime2StringFilter *>(new_out_filter)->setFormat("MMMM");
375  connect(static_cast<DateTime2StringFilter *>(new_out_filter), SIGNAL(formatChanged()),
376  d_owner, SLOT(notifyDisplayChange()));
377  break;
378  case SciDAVis::Day:
379  new_in_filter = new String2DayOfWeekFilter();
380  new_out_filter = new DateTime2StringFilter();
381  static_cast<DateTime2StringFilter *>(new_out_filter)->setFormat("dddd");
382  connect(static_cast<DateTime2StringFilter *>(new_out_filter), SIGNAL(formatChanged()),
383  d_owner, SLOT(notifyDisplayChange()));
384  break;
385  default:
386  throw runtime_error("invalid mode");
387  } // switch(mode)
388 
389  d_column_mode = mode;
390 
391  new_in_filter->setName("InputFilter");
392  new_out_filter->setName("OutputFilter");
393  d_input_filter = new_in_filter;
394  d_output_filter = new_out_filter;
395  d_input_filter->input(0, d_owner->d_string_io);
396  d_output_filter->input(0, d_owner);
397 
398  if (temp_col) // if temp_col == 0, only the input/output filters need to be changed
399  {
400  // copy the filtered, i.e. converted, column
401  filter->input(0, temp_col);
402  copy(filter->output(0));
403  delete temp_col;
404 
405  if (filter_is_temporary) delete filter;
406  }
407 
408  emit d_owner->modeChanged(d_owner);
409 }
410 
412  AbstractSimpleFilter * in_filter, AbstractSimpleFilter * out_filter, IntervalAttribute<bool> validity)
413 {
414  emit d_owner->modeAboutToChange(d_owner);
415  // disconnect formatChanged()
416  switch(d_column_mode)
417  {
418  case SciDAVis::Numeric:
419  disconnect(static_cast<Double2StringFilter *>(d_output_filter), SIGNAL(formatChanged()),
420  d_owner, SLOT(notifyDisplayChange()));
421  break;
422  case SciDAVis::DateTime:
423  case SciDAVis::Month:
424  case SciDAVis::Day:
425  disconnect(static_cast<DateTime2StringFilter *>(d_output_filter), SIGNAL(formatChanged()),
426  d_owner, SLOT(notifyDisplayChange()));
427  break;
428  default:
429  break;
430  }
431 
432  d_column_mode = mode;
433  d_data_type = type;
434  d_data = data;
435 
436  in_filter->setName("InputFilter");
437  out_filter->setName("OutputFilter");
438  d_input_filter = in_filter;
439  d_output_filter = out_filter;
440  d_input_filter->input(0, d_owner->d_string_io);
441  d_output_filter->input(0, d_owner);
442 
443  // connect formatChanged()
444  switch(d_column_mode)
445  {
446  case SciDAVis::Numeric:
447  connect(static_cast<Double2StringFilter *>(d_output_filter), SIGNAL(formatChanged()),
448  d_owner, SLOT(notifyDisplayChange()));
449  break;
450  case SciDAVis::DateTime:
451  case SciDAVis::Month:
452  case SciDAVis::Day:
453  connect(static_cast<DateTime2StringFilter *>(d_output_filter), SIGNAL(formatChanged()),
454  d_owner, SLOT(notifyDisplayChange()));
455  break;
456  default:
457  break;
458  }
459 
460  d_validity = validity;
461  emit d_owner->modeChanged(d_owner);
462 }
463 
465 {
466  emit d_owner->dataAboutToChange(d_owner);
467  d_data = data;
468  d_validity = validity;
469  emit d_owner->dataChanged(d_owner);
470 }
471 
473 {
474  if (other->dataType() != dataType()) return false;
475  int num_rows = other->rowCount();
476 
477  emit d_owner->dataAboutToChange(d_owner);
478  resizeTo(num_rows);
479 
480  // copy the data
481  switch(d_data_type)
482  {
484  {
485  double * ptr = static_cast< QVector<double>* >(d_data)->data();
486  for(int i=0; i<num_rows; i++)
487  ptr[i] = other->valueAt(i);
488  break;
489  }
491  {
492  for(int i=0; i<num_rows; i++)
493  static_cast< QStringList* >(d_data)->replace(i, other->textAt(i));
494  break;
495  }
497  {
498  for(int i=0; i<num_rows; i++)
499  static_cast< QList<QDateTime>* >(d_data)->replace(i, other->dateTimeAt(i));
500  break;
501  }
502  }
503  // copy the validity information
504  d_validity = other->invalidIntervals();
505 
506  emit d_owner->dataChanged(d_owner);
507 
508  return true;
509 }
510 
511 bool Column::Private::copy(const AbstractColumn * source, int source_start, int dest_start, int num_rows)
512 {
513  if (source->dataType() != dataType()) return false;
514  if (num_rows == 0) return true;
515 
516  emit d_owner->dataAboutToChange(d_owner);
517  if (dest_start+1-rowCount() > 1)
518  d_validity.setValue(Interval<int>(rowCount(), dest_start-1), true);
519  if (dest_start + num_rows > rowCount())
520  resizeTo(dest_start + num_rows);
521 
522  // copy the data
523  switch(d_data_type)
524  {
526  {
527  double * ptr = static_cast< QVector<double>* >(d_data)->data();
528  for(int i=0; i<num_rows; i++)
529  ptr[dest_start+i] = source->valueAt(source_start + i);
530  break;
531  }
533  for(int i=0; i<num_rows; i++)
534  static_cast< QStringList* >(d_data)->replace(dest_start+i, source->textAt(source_start + i));
535  break;
537  for(int i=0; i<num_rows; i++)
538  static_cast< QList<QDateTime>* >(d_data)->replace(dest_start+i, source->dateTimeAt(source_start + i));
539  break;
540  }
541  // copy the validity information
542  for(int i=0; i<num_rows; i++)
543  d_validity.setValue(dest_start+i, source->isInvalid(source_start+i));
544 
545  emit d_owner->dataChanged(d_owner);
546 
547  return true;
548 }
549 
550 bool Column::Private::copy(const Private * other)
551 {
552  if (other->dataType() != dataType()) return false;
553  int num_rows = other->rowCount();
554 
555  emit d_owner->dataAboutToChange(d_owner);
556  resizeTo(num_rows);
557 
558  // copy the data
559  switch(d_data_type)
560  {
562  {
563  double * ptr = static_cast< QVector<double>* >(d_data)->data();
564  for(int i=0; i<num_rows; i++)
565  ptr[i] = other->valueAt(i);
566  break;
567  }
569  {
570  for(int i=0; i<num_rows; i++)
571  static_cast< QStringList* >(d_data)->replace(i, other->textAt(i));
572  break;
573  }
575  {
576  for(int i=0; i<num_rows; i++)
577  static_cast< QList<QDateTime>* >(d_data)->replace(i, other->dateTimeAt(i));
578  break;
579  }
580  }
581  // copy the validity information
582  d_validity = other->invalidIntervals();
583 
584  emit d_owner->dataChanged(d_owner);
585 
586  return true;
587 }
588 
589 bool Column::Private::copy(const Private * source, int source_start, int dest_start, int num_rows)
590 {
591  if (source->dataType() != dataType()) return false;
592  if (num_rows == 0) return true;
593 
594  emit d_owner->dataAboutToChange(d_owner);
595  if (dest_start+1-rowCount() > 1)
596  d_validity.setValue(Interval<int>(rowCount(), dest_start-1), true);
597  if (dest_start + num_rows > rowCount())
598  resizeTo(dest_start + num_rows);
599 
600  // copy the data
601  switch(d_data_type)
602  {
604  {
605  double * ptr = static_cast< QVector<double>* >(d_data)->data();
606  for(int i=0; i<num_rows; i++)
607  ptr[dest_start+i] = source->valueAt(source_start + i);
608  break;
609  }
611  for(int i=0; i<num_rows; i++)
612  static_cast< QStringList* >(d_data)->replace(dest_start+i, source->textAt(source_start + i));
613  break;
615  for(int i=0; i<num_rows; i++)
616  static_cast< QList<QDateTime>* >(d_data)->replace(dest_start+i, source->dateTimeAt(source_start + i));
617  break;
618  }
619  // copy the validity information
620  for(int i=0; i<num_rows; i++)
621  d_validity.setValue(dest_start+i, source->isInvalid(source_start+i));
622 
623  emit d_owner->dataChanged(d_owner);
624 
625  return true;
626 }
627 
629 {
630  switch(d_data_type)
631  {
633  return static_cast< QVector<double>* >(d_data)->size();
635  return static_cast< QList<QDateTime>* >(d_data)->size();
637  return static_cast< QStringList* >(d_data)->size();
638  }
639 
640  return 0;
641 }
642 
643 void Column::Private::resizeTo(int new_size)
644 {
645  int old_size = rowCount();
646  if (new_size == old_size) return;
647 
648  switch(d_data_type)
649  {
651  static_cast< QVector<double>* >(d_data)->resize(new_size);
652  break;
654  {
655  int new_rows = new_size - old_size;
656  if (new_rows > 0)
657  {
658  for(int i=0; i<new_rows; i++)
659  static_cast< QList<QDateTime>* >(d_data)->append(QDateTime());
660  }
661  else
662  {
663  for(int i=0; i<-new_rows; i++)
664  static_cast< QList<QDateTime>* >(d_data)->removeLast();
665  }
666  break;
667  }
669  {
670  int new_rows = new_size - old_size;
671  if (new_rows > 0)
672  {
673  for(int i=0; i<new_rows; i++)
674  static_cast< QStringList* >(d_data)->append(QString());
675  }
676  else
677  {
678  for(int i=0; i<-new_rows; i++)
679  static_cast< QStringList* >(d_data)->removeLast();
680  }
681  break;
682  }
683  }
684 }
685 
686 void Column::Private::insertRows(int before, int count)
687 {
688  if (count == 0) return;
689 
690  emit d_owner->rowsAboutToBeInserted(d_owner, before, count);
691  d_validity.insertRows(before, count);
692  d_masking.insertRows(before, count);
693  d_formulas.insertRows(before, count);
694 
695  if (before <= rowCount())
696  {
697  d_validity.setValue(Interval<int>(before, before+count-1), true);
698  switch(d_data_type)
699  {
701  static_cast< QVector<double>* >(d_data)->insert(before, count, 0.0);
702  break;
704  for(int i=0; i<count; i++)
705  static_cast< QList<QDateTime>* >(d_data)->insert(before, QDateTime());
706  break;
708  for(int i=0; i<count; i++)
709  static_cast< QStringList* >(d_data)->insert(before, QString());
710  break;
711  }
712  }
713  emit d_owner->rowsInserted(d_owner, before, count);
714 }
715 
716 void Column::Private::removeRows(int first, int count)
717 {
718  if (count == 0) return;
719 
720  emit d_owner->rowsAboutToBeRemoved(d_owner, first, count);
721  d_validity.removeRows(first, count);
722  d_masking.removeRows(first, count);
723  d_formulas.removeRows(first, count);
724 
725  if (first < rowCount())
726  {
727  int corrected_count = count;
728  if (first + count > rowCount())
729  corrected_count = rowCount() - first;
730 
731  switch(d_data_type)
732  {
734  static_cast< QVector<double>* >(d_data)->remove(first, corrected_count);
735  break;
737  for(int i=0; i<corrected_count; i++)
738  static_cast< QList<QDateTime>* >(d_data)->removeAt(first);
739  break;
741  for(int i=0; i<corrected_count; i++)
742  static_cast< QStringList* >(d_data)->removeAt(first);
743  break;
744  }
745  }
746  emit d_owner->rowsRemoved(d_owner, first, count);
747 }
748 
750 {
751  emit d_owner->plotDesignationAboutToChange(d_owner);
752  d_plot_designation = pd;
753  emit d_owner->plotDesignationChanged(d_owner);
754 }
755 
757 {
758  removeRows(0, rowCount());
759 }
760 
762 {
763  emit d_owner->dataAboutToChange(d_owner);
764  d_validity.clear();
765  emit d_owner->dataChanged(d_owner);
766 }
767 
769 {
770  emit d_owner->maskingAboutToChange(d_owner);
771  d_masking.clear();
772  emit d_owner->maskingChanged(d_owner);
773 }
774 
776 {
777  emit d_owner->dataAboutToChange(d_owner);
778  d_validity.setValue(i, invalid);
779  emit d_owner->dataChanged(d_owner);
780 }
781 
782 void Column::Private::setInvalid(int row, bool invalid)
783 {
784  setInvalid(Interval<int>(row,row), invalid);
785 }
786 
788 {
789  emit d_owner->maskingAboutToChange(d_owner);
790  d_masking.setValue(i, mask);
791  emit d_owner->maskingChanged(d_owner);
792 }
793 
794 void Column::Private::setMasked(int row, bool mask)
795 {
796  setMasked(Interval<int>(row,row), mask);
797 }
798 
800 {
801  d_formulas.setValue(i, formula);
802 }
803 
804 void Column::Private::setFormula(int row, QString formula)
805 {
806  setFormula(Interval<int>(row,row), formula);
807 }
808 
810 {
811  d_formulas.clear();
812 }
813 
814 QString Column::Private::textAt(int row) const
815 {
816  if (d_data_type != SciDAVis::TypeQString) return QString();
817  return static_cast< QStringList* >(d_data)->value(row);
818 }
819 
820 QDate Column::Private::dateAt(int row) const
821 {
822  return dateTimeAt(row).date();
823 }
824 
825 QTime Column::Private::timeAt(int row) const
826 {
827  return dateTimeAt(row).time();
828 }
829 
830 QDateTime Column::Private::dateTimeAt(int row) const
831 {
832  if (d_data_type != SciDAVis::TypeQDateTime) return QDateTime();
833  return static_cast< QList<QDateTime>* >(d_data)->value(row);
834 }
835 
836 double Column::Private::valueAt(int row) const
837 {
838  if (d_data_type != SciDAVis::TypeDouble) return 0.0;
839  return static_cast< QVector<double>* >(d_data)->value(row);
840 }
841 
842 void Column::Private::setTextAt(int row, const QString& new_value)
843 {
844  if (d_data_type != SciDAVis::TypeQString) return;
845 
846  emit d_owner->dataAboutToChange(d_owner);
847  if (row >= rowCount())
848  {
849  if (row+1-rowCount() > 1) // we are adding more than one row in resizeTo()
850  d_validity.setValue(Interval<int>(rowCount(), row-1), true);
851  resizeTo(row+1);
852  }
853 
854  static_cast< QStringList* >(d_data)->replace(row, new_value);
855  d_validity.setValue(Interval<int>(row, row), false);
856  emit d_owner->dataChanged(d_owner);
857 }
858 
859 void Column::Private::replaceTexts(int first, const QStringList& new_values)
860 {
861  if (d_data_type != SciDAVis::TypeQString) return;
862 
863  emit d_owner->dataAboutToChange(d_owner);
864  int num_rows = new_values.size();
865  if (first+1-rowCount() > 1)
866  d_validity.setValue(Interval<int>(rowCount(), first-1), true);
867  if (first + num_rows > rowCount())
868  resizeTo(first + num_rows);
869 
870  for(int i=0; i<num_rows; i++)
871  static_cast< QStringList* >(d_data)->replace(first+i, new_values.at(i));
872  d_validity.setValue(Interval<int>(first, first+num_rows-1), false);
873  emit d_owner->dataChanged(d_owner);
874 }
875 
876 void Column::Private::setDateAt(int row, const QDate& new_value)
877 {
878  if (d_data_type != SciDAVis::TypeQDateTime) return;
879 
880  setDateTimeAt(row, QDateTime(new_value, timeAt(row)));
881 }
882 
883 void Column::Private::setTimeAt(int row, const QTime& new_value)
884 {
885  if (d_data_type != SciDAVis::TypeQDateTime) return;
886 
887  setDateTimeAt(row, QDateTime(dateAt(row), new_value));
888 }
889 
890 void Column::Private::setDateTimeAt(int row, const QDateTime& new_value)
891 {
892  if (d_data_type != SciDAVis::TypeQDateTime) return;
893 
894  emit d_owner->dataAboutToChange(d_owner);
895  if (row >= rowCount())
896  {
897  if (row+1-rowCount() > 1) // we are adding more than one row in resizeTo()
898  d_validity.setValue(Interval<int>(rowCount(), row-1), true);
899  resizeTo(row+1);
900  }
901 
902  static_cast< QList<QDateTime>* >(d_data)->replace(row, new_value);
903  d_validity.setValue(Interval<int>(row, row), !new_value.isValid());
904  emit d_owner->dataChanged(d_owner);
905 }
906 
907 void Column::Private::replaceDateTimes(int first, const QList<QDateTime>& new_values)
908 {
909  if (d_data_type != SciDAVis::TypeQDateTime) return;
910 
911  emit d_owner->dataAboutToChange(d_owner);
912  int num_rows = new_values.size();
913  if (first+1-rowCount() > 1)
914  d_validity.setValue(Interval<int>(rowCount(), first-1), true);
915  if (first + num_rows > rowCount())
916  resizeTo(first + num_rows);
917 
918  for(int i=0; i<num_rows; i++) {
919  static_cast< QList<QDateTime>* >(d_data)->replace(first+i, new_values.at(i));
920  d_validity.setValue(i, !new_values.at(i).isValid());
921  }
922  emit d_owner->dataChanged(d_owner);
923 }
924 
925 void Column::Private::setValueAt(int row, double new_value)
926 {
927  if (d_data_type != SciDAVis::TypeDouble) return;
928 
929  emit d_owner->dataAboutToChange(d_owner);
930  if (row >= rowCount())
931  {
932  if (row+1-rowCount() > 1) // we are adding more than one row in resizeTo()
933  d_validity.setValue(Interval<int>(rowCount(), row-1), true);
934  resizeTo(row+1);
935  }
936 
937  static_cast< QVector<double>* >(d_data)->replace(row, new_value);
938  d_validity.setValue(Interval<int>(row, row), false);
939  emit d_owner->dataChanged(d_owner);
940 }
941 
942 void Column::Private::replaceValues(int first, const QVector<qreal>& new_values)
943 {
944  if (d_data_type != SciDAVis::TypeDouble) return;
945 
946  emit d_owner->dataAboutToChange(d_owner);
947  int num_rows = new_values.size();
948  if (first+1-rowCount() > 1)
949  d_validity.setValue(Interval<int>(rowCount(), first-1), true);
950  if (first + num_rows > rowCount())
951  resizeTo(first + num_rows);
952 
953  double * ptr = static_cast< QVector<double>* >(d_data)->data();
954  for(int i=0; i<num_rows; i++)
955  ptr[first+i] = new_values.at(i);
956  d_validity.setValue(Interval<int>(first, first+num_rows-1), false);
957  emit d_owner->dataChanged(d_owner);
958 }
959 
961 {
962  emit d_owner->maskingAboutToChange(d_owner);
963  d_masking = masking;
964  emit d_owner->maskingChanged(d_owner);
965 }
966 
968 {
969  d_formulas = formulas;
970 }
971 
972 QString Column::Private::name() const
973 {
974  return d_owner->name();
975 }
976 
978 {
979  return d_owner->comment();
980 }
981 
Column::Private::insertRows
void insertRows(int before, int count)
Insert some empty (or initialized with zero) rows.
Definition: ColumnPrivate.cpp:686
AbstractFilter::input
bool input(int port, const AbstractColumn *source)
Connect the provided data source to the specified input port.
Definition: AbstractFilter.cpp:31
Column::Private::name
QString name() const
Return the column name/label.
Definition: ColumnPrivate.cpp:972
Column::dateTimeAt
QDateTime dateTimeAt(int row) const override
Return the QDateTime in row 'row'.
Definition: Column.cpp:255
Column::Private::comment
QString comment() const
Return the column comment.
Definition: ColumnPrivate.cpp:977
Column::Private::setTimeAt
void setTimeAt(int row, const QTime &new_value)
Set the content of row 'row'.
Definition: ColumnPrivate.cpp:883
Double2DateTimeFilter.h
Column::Private::clearMasks
void clearMasks()
Clear all masking information.
Definition: ColumnPrivate.cpp:768
Double2MonthFilter.h
AbstractColumn::textAt
virtual QString textAt(int row) const
Return the content of row 'row'.
Definition: AbstractColumn.h:218
Month2DoubleFilter.h
Column::outputFilter
AbstractSimpleFilter * outputFilter() const
Return the output filter (for data type -> string conversion)
Definition: Column.cpp:593
Column::Private::replaceModeData
void replaceModeData(SciDAVis::ColumnMode mode, SciDAVis::ColumnDataType type, void *data, AbstractSimpleFilter *in_filter, AbstractSimpleFilter *out_filter, IntervalAttribute< bool > validity)
Replace all mode related members.
Definition: ColumnPrivate.cpp:411
String2MonthFilter.h
Column::Private::setDateTimeAt
void setDateTimeAt(int row, const QDateTime &new_value)
Set the content of row 'row'.
Definition: ColumnPrivate.cpp:890
Column.h
SciDAVis::TypeQString
@ TypeQString
Definition: globals.h:79
data
Definition: exp_saturation.c:37
String2MonthFilter
Conversion filter String -> QDateTime, interpreting the input as months of the year (either numeric o...
Definition: String2MonthFilter.h:41
AbstractFilter
Base class for all analysis operations.
Definition: AbstractFilter.h:77
String2DayOfWeekFilter.h
Column::Private::setTextAt
void setTextAt(int row, const QString &new_value)
Set the content of row 'row'.
Definition: ColumnPrivate.cpp:842
SciDAVis::noDesignation
@ noDesignation
no plot designation
Definition: globals.h:56
SciDAVis::ColumnDataType
ColumnDataType
Column data type.
Definition: globals.h:77
AbstractSimpleFilter.h
Month2DoubleFilter
Conversion filter QDateTime -> double, translating dates into months (January -> 1).
Definition: Month2DoubleFilter.h:44
Column
Aspect that manages a column.
Definition: Column.h:59
IntervalAttribute< bool >
A class representing an interval-based attribute (bool version)
Definition: IntervalAttribute.h:198
Double2StringFilter.h
Double2DateTimeFilter
Conversion filter double -> QDateTime.
Definition: Double2DateTimeFilter.h:46
Column::Private::replaceTexts
void replaceTexts(int first, const QStringList &new_values)
Replace a range of values.
Definition: ColumnPrivate.cpp:859
DayOfWeek2DoubleFilter
Conversion filter QDateTime -> double, translating dates into days of the week (Monday -> 1).
Definition: DayOfWeek2DoubleFilter.h:40
DateTime2StringFilter
Conversion filter QDateTime -> QString.
Definition: DateTime2StringFilter.h:41
AbstractColumn::SimpleCopyThroughFilter
friend class SimpleCopyThroughFilter
Definition: AbstractColumn.h:383
Column::Private::dateTimeAt
QDateTime dateTimeAt(int row) const
Return the QDateTime in row 'row'.
Definition: ColumnPrivate.cpp:830
AbstractColumn::dataType
virtual SciDAVis::ColumnDataType dataType() const =0
Return the data type of the column.
Column::Private::setMasked
void setMasked(Interval< int > i, bool mask=true)
Set an interval masked.
Definition: ColumnPrivate.cpp:787
DateTime2StringFilter.h
Column::timeAt
QTime timeAt(int row) const override
Return the time part of row 'row'.
Definition: Column.cpp:250
Column::Private::dateAt
QDate dateAt(int row) const
Return the date part of row 'row'.
Definition: ColumnPrivate.cpp:820
Column::Private::clear
void clear()
Clear the whole column.
Definition: ColumnPrivate.cpp:756
Column::Private::setDateAt
void setDateAt(int row, const QDate &new_value)
Set the content of row 'row'.
Definition: ColumnPrivate.cpp:876
Column::Private::valueAt
double valueAt(int row) const
Return the double value in row 'row'.
Definition: ColumnPrivate.cpp:836
Column::Private::~Private
~Private()
Dtor.
Definition: ColumnPrivate.cpp:181
AbstractColumn::rowCount
virtual int rowCount() const =0
Return the data vector size.
Column::removeRows
void removeRows(int first, int count) override
Remove 'count' rows starting from row 'first'.
Definition: Column.cpp:130
Column::setFormula
void setFormula(Interval< int > i, QString formula)
Set a formula string for an interval of rows.
Definition: Column.cpp:182
DateTime2DoubleFilter
Conversion filter QDateTime -> double (using Julian day).
Definition: DateTime2DoubleFilter.h:42
AbstractColumn::valueAt
virtual double valueAt(int row) const
Return the double value in row 'row'.
Definition: AbstractColumn.h:268
Double2MonthFilter
Conversion filter double -> QDateTime, interpreting the input numbers as months of the year.
Definition: Double2MonthFilter.h:41
Column::Private::isInvalid
bool isInvalid(int row) const
Return whether a certain row contains an invalid value
Definition: ColumnPrivate.h:171
SciDAVis::ColumnMode
ColumnMode
The column mode (defines output and input filter for table columns)
Definition: globals.h:66
Column::rowCount
int rowCount() const override
Return the data vector size.
Definition: Column.cpp:583
ColumnPrivate.h
Column::Private::setColumnMode
void setColumnMode(SciDAVis::ColumnMode mode, AbstractFilter *conversion_filter)
Set the column mode.
Definition: ColumnPrivate.cpp:201
Column::Private::resizeTo
void resizeTo(int new_size)
Resize the vector to the specified number of rows.
Definition: ColumnPrivate.cpp:643
Column::Private::d_plot_designation
SciDAVis::PlotDesignation d_plot_designation
The plot designation.
Definition: ColumnPrivate.h:323
Column::Private::setValueAt
void setValueAt(int row, double new_value)
Set the content of row 'row'.
Definition: ColumnPrivate.cpp:925
Interval::isValid
bool isValid() const
Definition: Interval.h:219
Column::Private::d_input_filter
AbstractSimpleFilter * d_input_filter
The input filter (for string -> data type conversion)
Definition: ColumnPrivate.h:316
Column::Private::d_validity
IntervalAttribute< bool > d_validity
Definition: ColumnPrivate.h:319
Column::Private::clearValidity
void clearValidity()
Clear all validity information.
Definition: ColumnPrivate.cpp:761
Column::Private::setInvalid
void setInvalid(Interval< int > i, bool invalid=true)
Set an interval invalid or valid.
Definition: ColumnPrivate.cpp:775
SciDAVis::Month
@ Month
column contains month names
Definition: globals.h:69
AbstractColumn::modeAboutToChange
void modeAboutToChange(const AbstractColumn *source)
Column mode (possibly also the data type) will be changed.
AbstractColumn::dateTimeAt
virtual QDateTime dateTimeAt(int row) const
Set the content of row 'row'.
Definition: AbstractColumn.h:253
IntervalAttribute< QString >
Column::Private::d_column_mode
SciDAVis::ColumnMode d_column_mode
The column mode.
Definition: ColumnPrivate.h:308
Column::Private::dataType
SciDAVis::ColumnDataType dataType() const
Return the data type of the column.
Definition: ColumnPrivate.h:55
Column::setMasked
void setMasked(Interval< int > i, bool mask=true)
Set an interval masked.
Definition: Column.cpp:172
Column::Private::invalidIntervals
QList< Interval< int > > invalidIntervals() const
Return all intervals of invalid rows.
Definition: ColumnPrivate.h:175
Column::Private::replaceDateTimes
void replaceDateTimes(int first, const QList< QDateTime > &new_values)
Replace a range of values.
Definition: ColumnPrivate.cpp:907
SciDAVis::Text
@ Text
column contains strings
Definition: globals.h:68
Column::Private::Private
Private(Column *owner, SciDAVis::ColumnMode mode)
Ctor.
Definition: ColumnPrivate.cpp:54
Column::dataType
SciDAVis::ColumnDataType dataType() const override
Return the data type of the column.
Definition: Column.cpp:574
String2DateTimeFilter.h
Column::Private::d_data_type
SciDAVis::ColumnDataType d_data_type
Data type string.
Definition: ColumnPrivate.h:302
SciDAVis::DateTime
@ DateTime
column contains dates and/or times
Definition: globals.h:71
Column::formula
QString formula(int row) const override
Return the formula associated with row 'row'
Definition: Column.cpp:628
DayOfWeek2DoubleFilter.h
AbstractColumn::invalidIntervals
virtual QList< Interval< int > > invalidIntervals() const
Return all intervals of invalid rows.
Definition: AbstractColumn.h:158
SciDAVis::TypeDouble
@ TypeDouble
Definition: globals.h:78
Column::Private::textAt
QString textAt(int row) const
Return the content of row 'row'.
Definition: ColumnPrivate.cpp:814
Column::notifyDisplayChange
void notifyDisplayChange()
Definition: Column.cpp:638
String2DoubleFilter.h
Column::Private::timeAt
QTime timeAt(int row) const
Return the time part of row 'row'.
Definition: ColumnPrivate.cpp:825
AbstractAspect::setName
void setName(const QString &value)
Definition: AbstractAspect.cpp:234
Column::Private
Private data class of Column.
Definition: ColumnPrivate.h:44
String2DoubleFilter
Locale-aware conversion filter QString -> double.
Definition: String2DoubleFilter.h:40
Column::Private::replaceMasking
void replaceMasking(IntervalAttribute< bool > masking)
Replace the list of intervals of masked rows.
Definition: ColumnPrivate.cpp:960
String2DayOfWeekFilter
Conversion filter String -> QDateTime, interpreting the input as days of the week (either numeric or ...
Definition: String2DayOfWeekFilter.h:41
Column::Column
Column(const QString &name, SciDAVis::ColumnMode mode)
Ctor.
Definition: Column.cpp:38
Column::Private::replaceFormulas
void replaceFormulas(IntervalAttribute< QString > formulas)
Replace the interval attribute for the formula strings.
Definition: ColumnPrivate.cpp:967
Column::Private::replaceValues
void replaceValues(int first, const QVector< qreal > &new_values)
Replace a range of values.
Definition: ColumnPrivate.cpp:942
SciDAVis::PlotDesignation
PlotDesignation
Types of plot designations.
Definition: globals.h:55
Column::copy
bool copy(const AbstractColumn *other) override
Copy another column of the same type.
Definition: Column.cpp:108
AbstractAspect::remove
virtual void remove()
Remove me from my parent's list of children.
Definition: AbstractAspect.h:250
Column::dateAt
QDate dateAt(int row) const override
Return the date part of row 'row'.
Definition: Column.cpp:245
Column::Private::clearFormulas
void clearFormulas()
Clear all formulas.
Definition: ColumnPrivate.cpp:809
AbstractFilter::output
virtual AbstractColumn * output(int port=0)=0
Get the data source associated with the specified output port.
AbstractSimpleFilter
Simplified filter interface for filters with only one output port.
Definition: AbstractSimpleFilter.h:129
SciDAVis::Day
@ Day
column containts day of week names
Definition: globals.h:70
SciDAVis::TypeQDateTime
@ TypeQDateTime
Definition: globals.h:80
Column::Private::d_data
void * d_data
Pointer to the data vector.
Definition: ColumnPrivate.h:314
SciDAVis::Numeric
@ Numeric
column contains doubles
Definition: globals.h:67
Column::Private::d_output_filter
AbstractSimpleFilter * d_output_filter
The output filter (for data type -> string conversion)
Definition: ColumnPrivate.h:318
String2DateTimeFilter
Conversion filter QString -> QDateTime.
Definition: String2DateTimeFilter.h:48
Column::Private::setFormula
void setFormula(Interval< int > i, QString formula)
Set a formula string for an interval of rows.
Definition: ColumnPrivate.cpp:799
AbstractColumn::isInvalid
virtual bool isInvalid(int row) const
Return whether a certain row contains an invalid value
Definition: AbstractColumn.h:154
Column::Private::d_owner
Column * d_owner
The owner column.
Definition: ColumnPrivate.h:325
Interval< int >
Column::Private::removeRows
void removeRows(int first, int count)
Remove 'count' rows starting from row 'first'.
Definition: ColumnPrivate.cpp:716
Double2StringFilter
Locale-aware conversion filter double -> QString.
Definition: Double2StringFilter.h:39
Double2DayOfWeekFilter
Conversion filter double -> QDateTime, interpreting the input numbers as days of the week (1 = Monday...
Definition: Double2DayOfWeekFilter.h:40
Column::Private::copy
bool copy(const AbstractColumn *other)
Copy another column of the same type.
Definition: ColumnPrivate.cpp:472
SimpleCopyThroughFilter.h
Column::Private::setPlotDesignation
void setPlotDesignation(SciDAVis::PlotDesignation pd)
Set the column plot designation.
Definition: ColumnPrivate.cpp:749
Column::Private::rowCount
int rowCount() const
Return the data vector size.
Definition: ColumnPrivate.cpp:628
DateTime2DoubleFilter.h
Column::setDateTimeAt
void setDateTimeAt(int row, const QDateTime &new_value)
Set the content of row 'row'.
Definition: Column.cpp:218
AbstractColumn
Interface definition for data with column logic.
Definition: AbstractColumn.h:82
Column::Private::replaceData
void replaceData(void *data, IntervalAttribute< bool > validity)
Replace data pointer and validity.
Definition: ColumnPrivate.cpp:464
Column::setInvalid
void setInvalid(Interval< int > i, bool invalid=true)
Set an interval invalid or valid.
Definition: Column.cpp:162
Double2DayOfWeekFilter.h