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:
131  double d_old_xs, d_old_xe, d_old_ys, d_old_ye;
132  double d_new_xs, d_new_xe, d_new_ys, d_new_ye;
133 };
134 
135 class MatrixSetColorMapCommand: public QUndoCommand
136 {
137 public:
139  const LinearColorMap& d_map_before, Matrix::ColorMapType d_map_type_after,
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);
154  ~MatrixDeleteRowsCommand(){free(d_data);};
155  virtual void redo();
156  virtual void undo();
157 
158 private:
160  int d_start_row, d_count;
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);
180  ~MatrixDeleteColsCommand(){free(d_data);};
181  virtual void redo();
182  virtual void undo();
183 
184 private:
186  int d_start_col, d_count;
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);
206  ~MatrixSetSizeCommand(){if (d_backup) free(d_backup);};
207  virtual void redo();
208  virtual void undo();
209 
210 protected:
212  QSize d_old_size, d_new_size;
213  double *d_backup;
214 };
215 
216 class MatrixSmoothCommand: public QUndoCommand
217 {
218 public:
219  MatrixSmoothCommand(MatrixModel *model, double *data, const QString& text);
220  ~MatrixSmoothCommand(){if (d_backup) free(d_backup);};
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);
244  ~MatrixUndoCommand(){free(d_data);};
245  virtual void redo();
246  virtual void undo();
247 
248 protected:
251  int d_start_row, d_end_row, d_start_col, d_end_col;
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;
291  int d_ignore_lines, d_end_line, d_max_rows;
292  bool d_strip_spaces, d_simplify_spaces;
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);
315  ~MatrixPasteCommand(){free(d_clipboard_data); free(d_backup_data);};
316  virtual void redo();
317  virtual void undo();
318 
319 private:
321  int d_start_row, d_end_row, d_start_col, d_end_col, d_rows, d_cols, d_old_rows, d_old_cols;
322  double *d_clipboard_data, *d_backup_data;
323 };
324 #endif
QString d_new_formula
Definition: MatrixCommand.h:62
~MatrixUndoCommand()
Definition: MatrixCommand.h:244
Definition: MatrixCommand.h:176
Matrix::ViewType d_new_view
Definition: MatrixCommand.h:75
double d_old_ys
Definition: MatrixCommand.h:131
~MatrixDeleteRowsCommand()
Definition: MatrixCommand.h:154
~MatrixSmoothCommand()
Definition: MatrixCommand.h:220
double * d_data
Definition: MatrixCommand.h:161
Definition: MatrixCommand.h:266
Definition: MatrixModel.h:43
int d_start_row
Definition: MatrixCommand.h:321
int d_start_row
Definition: MatrixCommand.h:173
MatrixModel * d_model
Definition: MatrixCommand.h:198
Definition: MatrixCommand.h:297
Definition: MatrixCommand.h:150
Definition: MatrixCommand.h:78
MatrixModel * d_model
Definition: MatrixCommand.h:305
int d_old_width
Definition: MatrixCommand.h:101
int d_start_col
Definition: MatrixCommand.h:199
QImage d_image
Definition: MatrixCommand.h:275
HeaderViewType
Definition: Matrix.h:81
double d_val_after
Definition: MatrixCommand.h:49
ViewType
Definition: Matrix.h:82
double * d_backup
Definition: MatrixCommand.h:226
Definition: MatrixCommand.h:309
double * d_backup
Definition: MatrixCommand.h:213
Definition: MatrixCommand.h:65
Matrix::Operation d_operation
Definition: MatrixCommand.h:250
Matrix * d_matrix
Definition: MatrixCommand.h:60
double d_val_before
Definition: MatrixCommand.h:48
double * d_data
Definition: MatrixCommand.h:187
int d_start_col
Definition: MatrixCommand.h:186
Matrix * d_matrix
Definition: MatrixCommand.h:145
MatrixModel * d_model
Definition: MatrixCommand.h:172
~MatrixSetSizeCommand()
Definition: MatrixCommand.h:206
Operation
Definition: Matrix.h:79
double * d_data
Definition: MatrixCommand.h:252
virtual void undo()
Definition: MatrixCommand.cpp:61
int d_old_prec
Definition: MatrixCommand.h:117
Matrix::ImportMode d_mode
Definition: MatrixCommand.h:293
Definition: MatrixCommand.h:135
Matrix::HeaderViewType d_new_view
Definition: MatrixCommand.h:89
MatrixModel * d_model
Definition: MatrixCommand.h:46
MatrixModel * d_model
Definition: MatrixCommand.h:159
A customized QwtLinearColorMap.
Definition: LinearColorMap.h:39
Definition: MatrixCommand.h:105
Matrix::HeaderViewType d_old_view
Definition: MatrixCommand.h:88
Matrix::ViewType d_old_view
Definition: MatrixCommand.h:74
Definition: MatrixCommand.h:202
Matrix * d_matrix
Definition: MatrixCommand.h:130
QLocale d_locale
Definition: MatrixCommand.h:294
QModelIndex d_index
Definition: MatrixCommand.h:47
LinearColorMap d_map_before
Definition: MatrixCommand.h:147
MatrixEditCellCommand(MatrixModel *model, const QModelIndex &index, double valBefore, double valAfter, const QString &text)
Definition: MatrixCommand.cpp:37
bool d_strip_spaces
Definition: MatrixCommand.h:292
Definition: MatrixCommand.h:255
Matrix::Operation d_operation
Definition: MatrixCommand.h:306
double * d_clipboard_data
Definition: MatrixCommand.h:322
QChar d_old_format
Definition: MatrixCommand.h:115
Matrix::ColorMapType d_map_type_before
Definition: MatrixCommand.h:146
MatrixModel * d_model
Definition: MatrixCommand.h:225
Definition: MatrixCommand.h:52
Definition: MatrixCommand.h:279
Matrix worksheet class.
Definition: Matrix.h:57
Matrix::ViewType d_old_view
Definition: MatrixCommand.h:276
double d_new_ys
Definition: MatrixCommand.h:132
QSize d_old_size
Definition: MatrixCommand.h:212
ImportMode
Definition: Matrix.h:84
Matrix * d_matrix
Definition: MatrixCommand.h:114
Matrix * d_matrix
Definition: MatrixCommand.h:100
Definition: MatrixCommand.h:92
int d_new_width
Definition: MatrixCommand.h:102
Definition: MatrixCommand.h:239
Matrix commands used by the undo/redo framework.
Definition: MatrixCommand.h:37
MatrixModel * d_model
Definition: MatrixCommand.h:249
Matrix * d_matrix
Definition: MatrixCommand.h:73
int d_max_rows
Definition: MatrixCommand.h:291
MatrixModel * d_model
Definition: MatrixCommand.h:185
~MatrixDeleteColsCommand()
Definition: MatrixCommand.h:180
Definition: MatrixCommand.h:121
virtual void redo()
Definition: MatrixCommand.cpp:48
Matrix * d_matrix
Definition: MatrixCommand.h:87
Definition: MatrixCommand.h:216
Definition: MatrixCommand.h:229
int d_method
Definition: MatrixCommand.h:236
Definition: MatrixCommand.h:164
MatrixModel * d_model
Definition: MatrixCommand.h:320
bool d_inverse
Definition: MatrixCommand.h:263
MatrixModel * d_model
Definition: MatrixCommand.h:211
int d_start_row
Definition: MatrixCommand.h:160
int d_new_prec
Definition: MatrixCommand.h:118
QString d_old_formula
Definition: MatrixCommand.h:61
~MatrixPasteCommand()
Definition: MatrixCommand.h:315
Definition: MatrixCommand.h:190
QChar d_new_format
Definition: MatrixCommand.h:116
QString d_sep
Definition: MatrixCommand.h:290
int d_start_row
Definition: MatrixCommand.h:251
ColorMapType
Definition: Matrix.h:83