Logo Search packages:      
Sourcecode: scidavis version File versions  Download package

columncommands.h

/***************************************************************************
    File                 : columncommands.h
    Project              : SciDAVis
    Description          : Commands to be called by Column to modify Column::Private
    --------------------------------------------------------------------
    Copyright            : (C) 2007-2009 Tilman Benkert (thzs*gmx.net)
                           (replace * with @ in the email addresses) 

 ***************************************************************************/

/***************************************************************************
 *                                                                         *
 *  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 this program; if not, write to the Free Software           *
 *   Foundation, Inc., 51 Franklin Street, Fifth Floor,                    *
 *   Boston, MA  02110-1301  USA                                           *
 *                                                                         *
 ***************************************************************************/

#ifndef COLUMNCOMMANDS_H
#define COLUMNCOMMANDS_H

#include <QUndoCommand>
#include <QStringList>
#include "core/column/Column.h"
#include "core/AbstractSimpleFilter.h"
#include "lib/IntervalAttribute.h"

///////////////////////////////////////////////////////////////////////////
// class ColumnSetModeCmd
///////////////////////////////////////////////////////////////////////////
//! Set the column mode 
00043 class ColumnSetModeCmd : public QUndoCommand
{
public:
      //! Ctor
      ColumnSetModeCmd(Column::Private * col, SciDAVis::ColumnMode mode, QUndoCommand * parent = 0 );
      //! Dtor
      ~ColumnSetModeCmd();

      //! Execute the command
      virtual void redo();
      //! Undo the command
      virtual void undo();

private:
      //! The private column data to modify
00058       Column::Private * d_col;
      //! The previous mode
00060       SciDAVis::ColumnMode d_old_mode;    
      //! The new mode
00062       SciDAVis::ColumnMode d_mode;
      //! The old data type
00064       SciDAVis::ColumnDataType d_old_type;
      //! The new data type
00066       SciDAVis::ColumnDataType d_new_type;
      //! Pointer to old data
00068       void * d_old_data;
      //! Pointer to new data
00070       void * d_new_data;
      //! The new input filter
00072       AbstractSimpleFilter* d_new_in_filter;
      //! The new output filter
00074       AbstractSimpleFilter* d_new_out_filter;
      //! The old input filter
00076       AbstractSimpleFilter* d_old_in_filter;
      //! The old output filter
00078       AbstractSimpleFilter* d_old_out_filter;
      //! The old validity information
00080       IntervalAttribute<bool> d_old_validity;
      //! The new validity information
00082       IntervalAttribute<bool> d_new_validity;
      //! A status flag
00084       bool d_undone;
      //! A status flag
00086       bool d_executed;
};
///////////////////////////////////////////////////////////////////////////
// end of class ColumnSetModeCmd
///////////////////////////////////////////////////////////////////////////


///////////////////////////////////////////////////////////////////////////
// class ColumnFullCopyCmd
///////////////////////////////////////////////////////////////////////////
//! Copy a complete column 
00097 class ColumnFullCopyCmd : public QUndoCommand
{
public:
      //! Ctor
      ColumnFullCopyCmd(Column::Private * col, const AbstractColumn * src, QUndoCommand * parent = 0 );
      //! Dtor
      ~ColumnFullCopyCmd();

      //! Execute the command
      virtual void redo();
      //! Undo the command
      virtual void undo();

private:
      //! The private column data to modify
00112       Column::Private * d_col;
      //! The column to copy
00114       const AbstractColumn * d_src;
      //! A backup column
00116       Column::Private * d_backup;
      //! A dummy owner for the backup column
      /**
       * This is needed because a Column::Private must have an owner. We want access
       * to the Column::Private object to access its data pointer for fast data
       * replacement without too much copying.
       */
00123       Column * d_backup_owner;

};
///////////////////////////////////////////////////////////////////////////
// end of class ColumnFullCopyCmd
///////////////////////////////////////////////////////////////////////////

///////////////////////////////////////////////////////////////////////////
// class ColumnPartialCopyCmd
///////////////////////////////////////////////////////////////////////////
//! Copy parts of a column
00134 class ColumnPartialCopyCmd : public QUndoCommand
{
public:
      //! Ctor
      ColumnPartialCopyCmd(Column::Private * col, const AbstractColumn * src, int src_start, int dest_start, int num_rows, QUndoCommand * parent = 0 );
      //! Dtor
      ~ColumnPartialCopyCmd();

      //! Execute the command
      virtual void redo();
      //! Undo the command
      virtual void undo();

private:
      //! The private column data to modify
00149       Column::Private * d_col;
      //! The column to copy
00151       const AbstractColumn * d_src;
      //! A backup of the orig. column
00153       Column::Private * d_col_backup;
      //! A backup of the source column
00155       Column::Private * d_src_backup;
      //! A dummy owner for the backup column
      /**
       * This is needed because a Column::Private must have an owner and
       * we must have a Column::Private object as backup.
       * Using a Column object as backup would lead to an inifinite loop.
       */
00162       Column * d_col_backup_owner;
      //! A dummy owner for the source backup column
      /**
       * This is needed because a Column::Private must have an owner and
       * we must have a Column::Private object as backup.
       * Using a Column object as backup would lead to an inifinite loop.
       */
00169       Column * d_src_backup_owner;
      //! Start index in source column
00171       int d_src_start;
      //! Start index in destination column
00173       int d_dest_start;
      //! Number of rows to copy
00175       int d_num_rows;
      //! Previous number of rows in the destination column
00177       int d_old_row_count;
      //! The old validity information
00179       IntervalAttribute<bool> d_old_validity;
      

};
///////////////////////////////////////////////////////////////////////////
// end of class ColumnPartialCopyCmd
///////////////////////////////////////////////////////////////////////////


///////////////////////////////////////////////////////////////////////////
// class ColumnInsertEmptyRowsCmd
///////////////////////////////////////////////////////////////////////////
//! Insert empty rows 
00192 class ColumnInsertEmptyRowsCmd : public QUndoCommand
{
public:
      //! Ctor
      ColumnInsertEmptyRowsCmd(Column::Private * col, int before, int count, QUndoCommand * parent = 0 );
      //! Dtor
      ~ColumnInsertEmptyRowsCmd();

      //! Execute the command
      virtual void redo();
      //! Undo the command
      virtual void undo();

private:
      //! The private column data to modify
00207       Column::Private * d_col;
      //! Row to insert before
00209       int d_before;
      //! Number of rows
00211       int d_count;

};
///////////////////////////////////////////////////////////////////////////
// end of class ColumnInsertEmptyRowsCmd
///////////////////////////////////////////////////////////////////////////

///////////////////////////////////////////////////////////////////////////
// class ColumnRemoveRowsCmd
///////////////////////////////////////////////////////////////////////////
//!  
class ColumnRemoveRowsCmd : public QUndoCommand 
{
public:
      //! Ctor
      ColumnRemoveRowsCmd(Column::Private * col, int first, int count, QUndoCommand * parent = 0 );
      //! Dtor
      ~ColumnRemoveRowsCmd();

      //! Execute the command
      virtual void redo();
      //! Undo the command
      virtual void undo();

private:
      //! The private column data to modify
      Column::Private * d_col;
      //! The first row
      int d_first;
      //! The number of rows to be removed
      int d_count;
      //! Number of removed rows actually containing data
      int d_data_row_count;
      //! The number of rows before the removal
      int d_old_size;
      //! Column saving the removed rows
      Column::Private * d_backup;
      //! A dummy owner for the backup column
      /**
       * This is needed because a Column::Private must have an owner. We want access
       * to the Column::Private object to access its data pointer for fast data
       * replacement without too much copying.
       */
      Column * d_backup_owner;
      //! Backup of the masking attribute
      IntervalAttribute<bool> d_masking;
      //! Backup of the formula attribute
      IntervalAttribute<QString> d_formulas;
};
///////////////////////////////////////////////////////////////////////////
// end of class ColumnRemoveRowsCmd
///////////////////////////////////////////////////////////////////////////

///////////////////////////////////////////////////////////////////////////
// class ColumnSetPlotDesignationCmd
///////////////////////////////////////////////////////////////////////////
//! Sets a column's plot designation
00268 class ColumnSetPlotDesignationCmd : public QUndoCommand
{
public:
      //! Ctor
      ColumnSetPlotDesignationCmd(Column::Private * col, SciDAVis::PlotDesignation pd, QUndoCommand * parent = 0 );
      //! Dtor
      ~ColumnSetPlotDesignationCmd();

      //! Execute the command
      virtual void redo();
      //! Undo the command
      virtual void undo();

private:
      //! The private column data to modify
00283       Column::Private * d_col;
      //! New plot designation
00285       SciDAVis::PlotDesignation d_new_pd;
      //! Old plot designation
00287       SciDAVis::PlotDesignation d_old_pd;
};
///////////////////////////////////////////////////////////////////////////
// end of class ColumnSetPlotDesignationCmd
///////////////////////////////////////////////////////////////////////////


///////////////////////////////////////////////////////////////////////////
// class ColumnClearCmd
///////////////////////////////////////////////////////////////////////////
//! Clear the column 
00298 class ColumnClearCmd : public QUndoCommand
{
public:
      //! Ctor
      ColumnClearCmd(Column::Private * col, QUndoCommand * parent = 0 );
      //! Dtor
      ~ColumnClearCmd();

      //! Execute the command
      virtual void redo();
      //! Undo the command
      virtual void undo();

private:
      //! The private column data to modify
00313       Column::Private * d_col;
      //! The column's data type
00315       SciDAVis::ColumnDataType d_type;
      //! Pointer to the old data pointer
00317       void * d_data;
      //! Pointer to an empty data vector
00319       void * d_empty_data;
      //! The old validity
00321       IntervalAttribute<bool> d_validity;
      //! Status flag
00323       bool d_undone;

};
///////////////////////////////////////////////////////////////////////////
// end of class ColumnClearCmd
///////////////////////////////////////////////////////////////////////////


///////////////////////////////////////////////////////////////////////////
// class ColumnClearValidityCmd
///////////////////////////////////////////////////////////////////////////
//! Clear validity information 
00335 class ColumnClearValidityCmd : public QUndoCommand
{
public:
      //! Ctor
      ColumnClearValidityCmd(Column::Private * col, QUndoCommand * parent = 0 );
      //! Dtor
      ~ColumnClearValidityCmd();

      //! Execute the command
      virtual void redo();
      //! Undo the command
      virtual void undo();

private:
      //! The private column data to modify
00350       Column::Private * d_col;
      //! The old validity
00352       IntervalAttribute<bool> d_validity;
      //! A status flag
00354       bool d_copied;

};
///////////////////////////////////////////////////////////////////////////
// end of class ColumnClearValidityCmd
///////////////////////////////////////////////////////////////////////////

///////////////////////////////////////////////////////////////////////////
// class ColumnClearMasksCmd
///////////////////////////////////////////////////////////////////////////
//! Clear validity information 
00365 class ColumnClearMasksCmd : public QUndoCommand
{
public:
      //! Ctor
      ColumnClearMasksCmd(Column::Private * col, QUndoCommand * parent = 0 );
      //! Dtor
      ~ColumnClearMasksCmd();

      //! Execute the command
      virtual void redo();
      //! Undo the command
      virtual void undo();

private:
      //! The private column data to modify
00380       Column::Private * d_col;
      //! The old masks
00382       IntervalAttribute<bool> d_masking;
      //! A status flag
00384       bool d_copied;

};
///////////////////////////////////////////////////////////////////////////
// end of class ColumnClearMasksCmd
///////////////////////////////////////////////////////////////////////////

///////////////////////////////////////////////////////////////////////////
// class ColumnSetInvalidCmd
///////////////////////////////////////////////////////////////////////////
//! Mark an interval of rows as invalid 
00395 class ColumnSetInvalidCmd : public QUndoCommand
{
public:
      //! Ctor
      ColumnSetInvalidCmd(Column::Private * col, Interval<int> interval, bool invalid, QUndoCommand * parent = 0 );
      //! Dtor
      ~ColumnSetInvalidCmd();

      //! Execute the command
      virtual void redo();
      //! Undo the command
      virtual void undo();

private:
      //! The private column data to modify
00410       Column::Private * d_col;
      //! The interval
00412       Interval<int> d_interval;
      //! Valid/invalid flag
00414       bool d_invalid;
      //! Interval attribute backup
00416       IntervalAttribute<bool> d_validity;
      //! A status flag
00418       bool d_copied;

};
///////////////////////////////////////////////////////////////////////////
// end of class ColumnSetInvalidCmd
///////////////////////////////////////////////////////////////////////////

///////////////////////////////////////////////////////////////////////////
// class ColumnSetMaskedCmd
///////////////////////////////////////////////////////////////////////////
//! Mark an interval of rows as masked
00429 class ColumnSetMaskedCmd : public QUndoCommand
{
public:
      //! Ctor
      ColumnSetMaskedCmd(Column::Private * col, Interval<int> interval, bool masked, QUndoCommand * parent = 0 );
      //! Dtor
      ~ColumnSetMaskedCmd();

      //! Execute the command
      virtual void redo();
      //! Undo the command
      virtual void undo();

private:
      //! The private column data to modify
00444       Column::Private * d_col;
      //! The interval
00446       Interval<int> d_interval;
      //! Mask/unmask flag
00448       bool d_masked;
      //! Interval attribute backup
00450       IntervalAttribute<bool> d_masking;
      //! A status flag
00452       bool d_copied;

};
///////////////////////////////////////////////////////////////////////////
// end of class ColumnSetMaskedCmd
///////////////////////////////////////////////////////////////////////////

///////////////////////////////////////////////////////////////////////////
// class ColumnSetFormulaCmd
///////////////////////////////////////////////////////////////////////////
//! Set the formula for a given interval
00463 class ColumnSetFormulaCmd : public QUndoCommand
{
public:
      //! Ctor
      ColumnSetFormulaCmd(Column::Private * col, Interval<int> interval, const QString& formula, QUndoCommand * parent = 0 );
      //! Dtor
      ~ColumnSetFormulaCmd();

      //! Execute the command
      virtual void redo();
      //! Undo the command
      virtual void undo();

private:
      //! The private column data to modify
00478       Column::Private * d_col;
      //! The interval
00480       Interval<int> d_interval;
      //! The new formula
00482       QString d_formula;
      //! Interval attribute backup
00484       IntervalAttribute<QString> d_formulas;
      //! A status flag
00486       bool d_copied;

};
///////////////////////////////////////////////////////////////////////////
// end of class ColumnSetFormulaCmd
///////////////////////////////////////////////////////////////////////////

///////////////////////////////////////////////////////////////////////////
// class ColumnClearFormulasCmd
///////////////////////////////////////////////////////////////////////////
//! Clear all associated formulas 
00497 class ColumnClearFormulasCmd : public QUndoCommand
{
public:
      //! Ctor
      ColumnClearFormulasCmd(Column::Private * col, QUndoCommand * parent = 0 );
      //! Dtor
      ~ColumnClearFormulasCmd();

      //! Execute the command
      virtual void redo();
      //! Undo the command
      virtual void undo();

private:
      //! The private column data to modify
00512       Column::Private * d_col;
      //! The old formulas
00514       IntervalAttribute<QString> d_formulas;
      //! A status flag
00516       bool d_copied;

};
///////////////////////////////////////////////////////////////////////////
// end of class ColumnClearFormulasCmd
///////////////////////////////////////////////////////////////////////////

///////////////////////////////////////////////////////////////////////////
// class ColumnSetTextCmd
///////////////////////////////////////////////////////////////////////////
//! Set the text for a string cell 
00527 class ColumnSetTextCmd : public QUndoCommand
{
public:
      //! Ctor
      ColumnSetTextCmd(Column::Private * col, int row, const QString& new_value, QUndoCommand * parent = 0 );
      //! Dtor
      ~ColumnSetTextCmd();

      //! Execute the command
      virtual void redo();
      //! Undo the command
      virtual void undo();

private:
      //! The private column data to modify
00542       Column::Private * d_col;
      //! The row to modify
00544       int d_row;
      //! The new value
00546       QString d_new_value;
      //! The old value
00548       QString d_old_value;
      //! The old number of rows
00550       int d_row_count;
      //! The old validity
00552       IntervalAttribute<bool> d_validity;

};
///////////////////////////////////////////////////////////////////////////
// end of class ColumnSetTextCmd
///////////////////////////////////////////////////////////////////////////

///////////////////////////////////////////////////////////////////////////
// class ColumnSetValueCmd
///////////////////////////////////////////////////////////////////////////
//! Set the value for a double cell 
00563 class ColumnSetValueCmd : public QUndoCommand
{
public:
      //! Ctor
      ColumnSetValueCmd(Column::Private * col, int row, double new_value, QUndoCommand * parent = 0 );
      //! Dtor
      ~ColumnSetValueCmd();

      //! Execute the command
      virtual void redo();
      //! Undo the command
      virtual void undo();

private:
      //! The private column data to modify
00578       Column::Private * d_col;
      //! The row to modify
00580       int d_row;
      //! The new value
00582       double d_new_value;
      //! The old value
00584       double d_old_value;
      //! The old number of rows
00586       int d_row_count;
      //! The old validity
00588       IntervalAttribute<bool> d_validity;

};
///////////////////////////////////////////////////////////////////////////
// end of class ColumnSetValueCmd
///////////////////////////////////////////////////////////////////////////

///////////////////////////////////////////////////////////////////////////
// class ColumnSetDateTimeCmd
///////////////////////////////////////////////////////////////////////////
//! Set the value of a date-time cell 
00599 class ColumnSetDateTimeCmd : public QUndoCommand
{
public:
      //! Ctor
      ColumnSetDateTimeCmd(Column::Private * col, int row, const QDateTime& new_value, QUndoCommand * parent = 0 );
      //! Dtor
      ~ColumnSetDateTimeCmd();

      //! Execute the command
      virtual void redo();
      //! Undo the command
      virtual void undo();

private:
      //! The private column data to modify
00614       Column::Private * d_col;
      //! The row to modify
00616       int d_row;
      //! The new value
00618       QDateTime d_new_value;
      //! The old value
00620       QDateTime d_old_value;
      //! The old number of rows
00622       int d_row_count;
      //! The old validity
00624       IntervalAttribute<bool> d_validity;

};
///////////////////////////////////////////////////////////////////////////
// end of class ColumnSetDateTimeCmd
///////////////////////////////////////////////////////////////////////////

///////////////////////////////////////////////////////////////////////////
// class ColumnReplaceTextsCmd
///////////////////////////////////////////////////////////////////////////
//! Replace a range of strings in a string column 
00635 class ColumnReplaceTextsCmd : public QUndoCommand
{
public:
      //! Ctor
      ColumnReplaceTextsCmd(Column::Private * col, int first, const QStringList& new_values, QUndoCommand * parent = 0 );
      //! Dtor
      ~ColumnReplaceTextsCmd();

      //! Execute the command
      virtual void redo();
      //! Undo the command
      virtual void undo();

private:
      //! The private column data to modify
00650       Column::Private * d_col;
      //! The first row to replace
00652       int d_first;
      //! The new values
00654       QStringList d_new_values;
      //! The old values
00656       QStringList d_old_values;
      //! Status flag
00658       bool d_copied;
      //! The old number of rows
00660       int d_row_count;
      //! The old validity
00662       IntervalAttribute<bool> d_validity;

};
///////////////////////////////////////////////////////////////////////////
// end of class ColumnReplaceTextsCmd
///////////////////////////////////////////////////////////////////////////

///////////////////////////////////////////////////////////////////////////
// class ColumnReplaceValuesCmd
///////////////////////////////////////////////////////////////////////////
//! Replace a range of doubles in a double column 
00673 class ColumnReplaceValuesCmd : public QUndoCommand
{
public:
      //! Ctor
      ColumnReplaceValuesCmd(Column::Private * col, int first, const QVector<double>& new_values, QUndoCommand * parent = 0 );
      //! Dtor
      ~ColumnReplaceValuesCmd();

      //! Execute the command
      virtual void redo();
      //! Undo the command
      virtual void undo();

private:
      //! The private column data to modify
00688       Column::Private * d_col;
      //! The first row to replace
00690       int d_first;
      //! The new values
00692       QVector<double> d_new_values;
      //! The old values
00694       QVector<double> d_old_values;
      //! Status flag
00696       bool d_copied;
      //! The old number of rows
00698       int d_row_count;
      //! The old validity
00700       IntervalAttribute<bool> d_validity;

};
///////////////////////////////////////////////////////////////////////////
// end of class ColumnReplaceValuesCmd
///////////////////////////////////////////////////////////////////////////

///////////////////////////////////////////////////////////////////////////
// class ColumnReplaceDateTimesCmd
///////////////////////////////////////////////////////////////////////////
//! Replace a range of date-times in a date-time column 
00711 class ColumnReplaceDateTimesCmd : public QUndoCommand
{
public:
      //! Ctor
      ColumnReplaceDateTimesCmd(Column::Private * col, int first, const QList<QDateTime>& new_values, QUndoCommand * parent = 0 );
      //! Dtor
      ~ColumnReplaceDateTimesCmd();

      //! Execute the command
      virtual void redo();
      //! Undo the command
      virtual void undo();

private:
      //! The private column data to modify
00726       Column::Private * d_col;
      //! The first row to replace
00728       int d_first;
      //! The new values
00730       QList<QDateTime> d_new_values;
      //! The old values
00732       QList<QDateTime> d_old_values;
      //! Status flag
00734       bool d_copied;
      //! The old number of rows
00736       int d_row_count;
      //! The old validity
00738       IntervalAttribute<bool> d_validity;

};
///////////////////////////////////////////////////////////////////////////
// end of class ColumnReplaceDateTimesCmd
///////////////////////////////////////////////////////////////////////////




#endif

Generated by  Doxygen 1.6.0   Back to index