00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029 #ifndef MATRIX_COMMAND_H
00030 #define MATRIX_COMMAND_H
00031
00032 #include "Matrix.h"
00033 #include "MatrixModel.h"
00034 #include <QUndoCommand>
00035
00037 class MatrixEditCellCommand: public QUndoCommand
00038 {
00039 public:
00040 MatrixEditCellCommand(MatrixModel *model, const QModelIndex & index, double valBefore,
00041 double valAfter, const QString & text);
00042 virtual void redo();
00043 virtual void undo();
00044
00045 private:
00046 MatrixModel *d_model;
00047 QModelIndex d_index;
00048 double d_val_before;
00049 double d_val_after;
00050 };
00051
00052 class MatrixSetFormulaCommand: public QUndoCommand
00053 {
00054 public:
00055 MatrixSetFormulaCommand(Matrix *m, const QString& oldFormula, const QString& newFormula, const QString & text);
00056 virtual void redo();
00057 virtual void undo();
00058
00059 private:
00060 Matrix *d_matrix;
00061 QString d_old_formula;
00062 QString d_new_formula;
00063 };
00064
00065 class MatrixSetViewCommand: public QUndoCommand
00066 {
00067 public:
00068 MatrixSetViewCommand(Matrix *m, Matrix::ViewType oldView, Matrix::ViewType newView, const QString & text);
00069 virtual void redo();
00070 virtual void undo();
00071
00072 private:
00073 Matrix *d_matrix;
00074 Matrix::ViewType d_old_view;
00075 Matrix::ViewType d_new_view;
00076 };
00077
00078 class MatrixSetHeaderViewCommand: public QUndoCommand
00079 {
00080 public:
00081 MatrixSetHeaderViewCommand(Matrix *m, Matrix::HeaderViewType oldView,
00082 Matrix::HeaderViewType newView, const QString & text);
00083 virtual void redo();
00084 virtual void undo();
00085
00086 private:
00087 Matrix *d_matrix;
00088 Matrix::HeaderViewType d_old_view;
00089 Matrix::HeaderViewType d_new_view;
00090 };
00091
00092 class MatrixSetColWidthCommand: public QUndoCommand
00093 {
00094 public:
00095 MatrixSetColWidthCommand(Matrix *m, int oldWidth, int newWidth, const QString & text);
00096 virtual void redo();
00097 virtual void undo();
00098
00099 private:
00100 Matrix *d_matrix;
00101 int d_old_width;
00102 int d_new_width;
00103 };
00104
00105 class MatrixSetPrecisionCommand: public QUndoCommand
00106 {
00107 public:
00108 MatrixSetPrecisionCommand(Matrix *m, const QChar& oldFormat, const QChar& newFormat,
00109 int oldPrec, int newPrec, const QString & text);
00110 virtual void redo();
00111 virtual void undo();
00112
00113 private:
00114 Matrix *d_matrix;
00115 QChar d_old_format;
00116 QChar d_new_format;
00117 int d_old_prec;
00118 int d_new_prec;
00119 };
00120
00121 class MatrixSetCoordinatesCommand: public QUndoCommand
00122 {
00123 public:
00124 MatrixSetCoordinatesCommand(Matrix *, double, double, double, double,
00125 double, double, double, double, const QString &);
00126 virtual void redo();
00127 virtual void undo();
00128
00129 private:
00130 Matrix *d_matrix;
00131 double d_old_xs, d_old_xe, d_old_ys, d_old_ye;
00132 double d_new_xs, d_new_xe, d_new_ys, d_new_ye;
00133 };
00134
00135 class MatrixSetColorMapCommand: public QUndoCommand
00136 {
00137 public:
00138 MatrixSetColorMapCommand(Matrix *m, Matrix::ColorMapType d_map_type_before,
00139 const QwtLinearColorMap& d_map_before, Matrix::ColorMapType d_map_type_after,
00140 const QwtLinearColorMap& d_map_after, const QString& text);
00141 virtual void redo();
00142 virtual void undo();
00143
00144 private:
00145 Matrix *d_matrix;
00146 Matrix::ColorMapType d_map_type_before, d_map_type_after;
00147 QwtLinearColorMap d_map_before, d_map_after;
00148 };
00149
00150 class MatrixDeleteRowsCommand: public QUndoCommand
00151 {
00152 public:
00153 MatrixDeleteRowsCommand(MatrixModel *model, int startRow, int count, double* data, const QString& text);
00154 ~MatrixDeleteRowsCommand(){free(d_data);};
00155 virtual void redo();
00156 virtual void undo();
00157
00158 private:
00159 MatrixModel *d_model;
00160 int d_start_row, d_count;
00161 double* d_data;
00162 };
00163
00164 class MatrixInsertRowCommand: public QUndoCommand
00165 {
00166 public:
00167 MatrixInsertRowCommand(MatrixModel *model, int startRow, const QString& text);
00168 virtual void redo();
00169 virtual void undo();
00170
00171 private:
00172 MatrixModel *d_model;
00173 int d_start_row;
00174 };
00175
00176 class MatrixDeleteColsCommand: public QUndoCommand
00177 {
00178 public:
00179 MatrixDeleteColsCommand(MatrixModel *model, int startCol, int count, double* data, const QString& text);
00180 ~MatrixDeleteColsCommand(){free(d_data);};
00181 virtual void redo();
00182 virtual void undo();
00183
00184 private:
00185 MatrixModel *d_model;
00186 int d_start_col, d_count;
00187 double* d_data;
00188 };
00189
00190 class MatrixInsertColCommand: public QUndoCommand
00191 {
00192 public:
00193 MatrixInsertColCommand(MatrixModel *model, int startCol, const QString& text);
00194 virtual void redo();
00195 virtual void undo();
00196
00197 private:
00198 MatrixModel *d_model;
00199 int d_start_col;
00200 };
00201
00202 class MatrixSetSizeCommand: public QUndoCommand
00203 {
00204 public:
00205 MatrixSetSizeCommand(MatrixModel *model, const QSize& oldSize, const QSize& newSize, double *data, const QString& text);
00206 ~MatrixSetSizeCommand(){free(d_backup);};
00207 virtual void redo();
00208 virtual void undo();
00209
00210 private:
00211 MatrixModel *d_model;
00212 QSize d_old_size, d_new_size;
00213 double *d_backup;
00214 };
00215
00216 class MatrixUndoCommand: public QUndoCommand
00217 {
00218 public:
00219 MatrixUndoCommand(MatrixModel *model, Matrix::Operation op, int startRow, int endRow, int startCol, int endCol,
00220 double *data, const QString& text);
00221 ~MatrixUndoCommand(){free(d_data);};
00222 virtual void redo();
00223 virtual void undo();
00224
00225 protected:
00226 MatrixModel *d_model;
00227 Matrix::Operation d_operation;
00228 int d_start_row, d_end_row, d_start_col, d_end_col;
00229 double* d_data;
00230 };
00231
00232 class MatrixFftCommand: public MatrixUndoCommand
00233 {
00234 public:
00235 MatrixFftCommand(bool inverse, MatrixModel *model, int startRow, int endRow,
00236 int startCol, int endCol, double *data, const QString& text);
00237 virtual void redo();
00238
00239 private:
00240 bool d_inverse;
00241 };
00242
00243 class MatrixSetImageCommand: public MatrixUndoCommand
00244 {
00245 public:
00246 MatrixSetImageCommand(MatrixModel *model, const QImage& image, Matrix::ViewType oldView,
00247 int startRow, int endRow, int startCol, int endCol, double *data, const QString& text);
00248 virtual void redo();
00249 virtual void undo();
00250
00251 private:
00252 QImage d_image;
00253 Matrix::ViewType d_old_view;
00254 };
00255
00256 class MatrixImportAsciiCommand: public MatrixUndoCommand
00257 {
00258 public:
00259 MatrixImportAsciiCommand(const QString &fname, const QString &sep,
00260 int ignoredLines, bool stripSpaces, bool simplifySpaces,
00261 const QString& commentString, Matrix::ImportMode importAs, const QLocale& locale,
00262 int endLineChar, int maxRows, MatrixModel *model, int startRow, int endRow,
00263 int startCol, int endCol, double *data, const QString& text);
00264 virtual void redo();
00265
00266 private:
00267 QString d_path, d_sep, d_comment;
00268 int d_ignore_lines, d_end_line, d_max_rows;
00269 bool d_strip_spaces, d_simplify_spaces;
00270 Matrix::ImportMode d_mode;
00271 QLocale d_locale;
00272 };
00273
00274 class MatrixSymmetryOperation: public QUndoCommand
00275 {
00276 public:
00277 MatrixSymmetryOperation(MatrixModel *model, Matrix::Operation op, const QString& text);
00278 virtual void redo();
00279 virtual void undo();
00280
00281 private:
00282 MatrixModel *d_model;
00283 Matrix::Operation d_operation;
00284 };
00285
00286 class MatrixPasteCommand: public QUndoCommand
00287 {
00288 public:
00289 MatrixPasteCommand(MatrixModel *model, int startRow, int endRow, int startCol, int endCol,
00290 double *clipboardData, int rows, int cols, double *backupData,
00291 int oldRows, int oldCols, const QString& text);
00292 ~MatrixPasteCommand(){free(d_clipboard_data); free(d_backup_data);};
00293 virtual void redo();
00294 virtual void undo();
00295
00296 private:
00297 MatrixModel *d_model;
00298 int d_start_row, d_end_row, d_start_col, d_end_col, d_rows, d_cols, d_old_rows, d_old_cols;
00299 double *d_clipboard_data, *d_backup_data;
00300 };
00301 #endif