QtiPlot  0.9.8.2
MatrixCommand.h
Go to the documentation of this file.
1 /***************************************************************************
2  File : MatrixCommand.h
3  Project : QtiPlot
4  --------------------------------------------------------------------
5  Copyright : (C) 2008 by Ion Vasilief,
6  Email (use @ for *) : ion_vasilief*yahoo.fr
7  Description : Matrix undo/redo commands
8 
9  ***************************************************************************/
10 
11 /***************************************************************************
12  * *
13  * This program is free software; you can redistribute it and/or modify *
14  * it under the terms of the GNU General Public License as published by *
15  * the Free Software Foundation; either version 2 of the License, or *
16  * (at your option) any later version. *
17  * *
18  * This program is distributed in the hope that it will be useful, *
19  * but WITHOUT ANY WARRANTY; without even the implied warranty of *
20  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
21  * GNU General Public License for more details. *
22  * *
23  * You should have received a copy of the GNU General Public License *
24  * along with this program; if not, write to the Free Software *
25  * Foundation, Inc., 51 Franklin Street, Fifth Floor, *
26  * Boston, MA 02110-1301 USA *
27  * *
28  ***************************************************************************/
29 #ifndef MATRIX_COMMAND_H
30 #define MATRIX_COMMAND_H
31 
32 #include "Matrix.h"
33 #include "MatrixModel.h"
34 #include <QUndoCommand>
35 
37 class MatrixEditCellCommand: public QUndoCommand
38 {
39 public:
40  MatrixEditCellCommand(MatrixModel *model, const QModelIndex & index, double valBefore,
41  double valAfter, const QString & text);
42  virtual void redo();
43  virtual void undo();
44 
45 private:
47  QModelIndex d_index;
48  double d_val_before;
49  double d_val_after;
50 };
51 
52 class MatrixSetFormulaCommand: public QUndoCommand
53 {
54 public:
55  MatrixSetFormulaCommand(Matrix *m, const QString& oldFormula, const QString& newFormula, const QString & text);
56  virtual void redo();
57  virtual void undo();
58 
59 private:
61  QString d_old_formula;
62  QString d_new_formula;
63 };
64 
65 class MatrixSetViewCommand: public QUndoCommand
66 {
67 public:
68  MatrixSetViewCommand(Matrix *m, Matrix::ViewType oldView, Matrix::ViewType newView, const QString & text);
69  virtual void redo();
70  virtual void undo();
71 
72 private:
76 };
77 
78 class MatrixSetHeaderViewCommand: public QUndoCommand
79 {
80 public:
82  Matrix::HeaderViewType newView, const QString & text);
83  virtual void redo();
84  virtual void undo();
85 
86 private:
90 };
91 
92 class MatrixSetColWidthCommand: public QUndoCommand
93 {
94 public:
95  MatrixSetColWidthCommand(Matrix *m, int oldWidth, int newWidth, const QString & text);
96  virtual void redo();
97  virtual void undo();
98 
99 private:
103 };
104 
105 class MatrixSetPrecisionCommand: public QUndoCommand
106 {
107 public:
108  MatrixSetPrecisionCommand(Matrix *m, const QChar& oldFormat, const QChar& newFormat,
109  int oldPrec, int newPrec, const QString & text);
110  virtual void redo();
111  virtual void undo();
112 
113 private:
119 };
120 
121 class MatrixSetCoordinatesCommand: public QUndoCommand
122 {
123 public:
124  MatrixSetCoordinatesCommand(Matrix *, double, double, double, double,
125  double, double, double, double, const QString &);
126  virtual void redo();
127  virtual void undo();
128 
129 private:
133 };
134 
135 class MatrixSetColorMapCommand: public QUndoCommand
136 {
137 public:
140  const LinearColorMap& d_map_after, const QString& text);
141  virtual void redo();
142  virtual void undo();
143 
144 private:
148 };
149 
150 class MatrixDeleteRowsCommand: public QUndoCommand
151 {
152 public:
153  MatrixDeleteRowsCommand(MatrixModel *model, int startRow, int count, double* data, const QString& text);
155  virtual void redo();
156  virtual void undo();
157 
158 private:
161  double* d_data;
162 };
163 
164 class MatrixInsertRowCommand: public QUndoCommand
165 {
166 public:
167  MatrixInsertRowCommand(MatrixModel *model, int startRow, const QString& text);
168  virtual void redo();
169  virtual void undo();
170 
171 private:
174 };
175 
176 class MatrixDeleteColsCommand: public QUndoCommand
177 {
178 public:
179  MatrixDeleteColsCommand(MatrixModel *model, int startCol, int count, double* data, const QString& text);
181  virtual void redo();
182  virtual void undo();
183 
184 private:
187  double* d_data;
188 };
189 
190 class MatrixInsertColCommand: public QUndoCommand
191 {
192 public:
193  MatrixInsertColCommand(MatrixModel *model, int startCol, const QString& text);
194  virtual void redo();
195  virtual void undo();
196 
197 private:
200 };
201 
202 class MatrixSetSizeCommand: public QUndoCommand
203 {
204 public:
205  MatrixSetSizeCommand(MatrixModel *model, const QSize& oldSize, const QSize& newSize, double *data, const QString& text);
207  virtual void redo();
208  virtual void undo();
209 
210 protected:
213  double *d_backup;
214 };
215 
216 class MatrixSmoothCommand: public QUndoCommand
217 {
218 public:
219  MatrixSmoothCommand(MatrixModel *model, double *data, const QString& text);
221  virtual void redo();
222  virtual void undo();
223 
224 protected:
226  double *d_backup;
227 };
228 
230 {
231 public:
232  MatrixResampleCommand(MatrixModel *model, const QSize& oldSize, const QSize& newSize, int method, double *data, const QString& text);
233  virtual void redo();
234 
235 private:
236  int d_method;
237 };
238 
239 class MatrixUndoCommand: public QUndoCommand
240 {
241 public:
242  MatrixUndoCommand(MatrixModel *model, Matrix::Operation op, int startRow, int endRow, int startCol, int endCol,
243  double *data, const QString& text);
245  virtual void redo();
246  virtual void undo();
247 
248 protected:
252  double* d_data;
253 };
254 
256 {
257 public:
258  MatrixFftCommand(bool inverse, MatrixModel *model, int startRow, int endRow,
259  int startCol, int endCol, double *data, const QString& text);
260  virtual void redo();
261 
262 private:
263  bool d_inverse;
264 };
265 
267 {
268 public:
269  MatrixSetImageCommand(MatrixModel *model, const QImage& image, Matrix::ViewType oldView,
270  int startRow, int endRow, int startCol, int endCol, double *data, const QString& text);
271  virtual void redo();
272  virtual void undo();
273 
274 private:
275  QImage d_image;
277 };
278 
280 {
281 public:
282  MatrixImportAsciiCommand(const QString &fname, const QString &sep,
283  int ignoredLines, bool stripSpaces, bool simplifySpaces,
284  const QString& commentString, Matrix::ImportMode importAs, const QLocale& locale,
285  int endLineChar, int maxRows, MatrixModel *model, int startRow, int endRow,
286  int startCol, int endCol, double *data, const QString& text);
287  virtual void redo();
288 
289 private:
290  QString d_path, d_sep, d_comment;
294  QLocale d_locale;
295 };
296 
297 class MatrixSymmetryOperation: public QUndoCommand
298 {
299 public:
300  MatrixSymmetryOperation(MatrixModel *model, Matrix::Operation op, const QString& text);
301  virtual void redo();
302  virtual void undo();
303 
304 private:
307 };
308 
309 class MatrixPasteCommand: public QUndoCommand
310 {
311 public:
312  MatrixPasteCommand(MatrixModel *model, int startRow, int endRow, int startCol, int endCol,
313  double *clipboardData, int rows, int cols, double *backupData,
314  int oldRows, int oldCols, const QString& text);
316  virtual void redo();
317  virtual void undo();
318 
319 private:
323 };
324 #endif