labplot  2.8.2
About: LabPlot is an application for plotting and analysis of 2D and 3D functions and data. It is a complete rewrite of LabPlot1 and lacks in the first release a lot of features available in the predecessor. On the other hand, the GUI and the usability is more superior.
  Fossies Dox: labplot-2.8.2.tar.gz  ("unofficial" and yet experimental doxygen-generated source code documentation)  

MatrixView.h
Go to the documentation of this file.
1 /***************************************************************************
2  File : MatrixView.cpp
3  Project : LabPlot
4  Description : View class for Matrix
5  --------------------------------------------------------------------
6  Copyright : (C) 2015-2019 Alexander Semke (alexander.semke@web.de)
7  Copyright : (C) 2008-2009 Tilman Benkert (thzs@gmx.net)
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 
30 #ifndef MATRIXVIEW_H
31 #define MATRIXVIEW_H
32 
33 #include <QWidget>
34 #include <QList>
35 #include <QShortcut>
38 
39 class Matrix;
40 class MatrixModel;
41 
42 class QPrinter;
43 class QAction;
44 class QLabel;
45 class QMenu;
46 class QStackedWidget;
47 class QTableView;
48 
49 class MatrixView : public QWidget {
50  Q_OBJECT
51 
52 public:
53  explicit MatrixView(Matrix*);
54  ~MatrixView() override;
55 
56  MatrixModel* model() const;
57 
58  int selectedColumnCount(bool full = false) const;
59  bool isColumnSelected(int col, bool full = false) const;
60  int selectedRowCount(bool full = false) const;
61  bool isRowSelected(int row, bool full = false) const;
62  int firstSelectedColumn(bool full = false) const;
63  int lastSelectedColumn(bool full = false) const;
64  int firstSelectedRow(bool full = false) const;
65  int lastSelectedRow(bool full = false) const;
66  bool isCellSelected(int row, int col) const;
67  void setCellSelected(int row, int col);
68  void setCellsSelected(int first_row, int first_col, int last_row, int last_col);
69  void getCurrentCell(int* row, int* col) const;
70 
71  void resizeHeaders();
72  void adjustHeaders();
73  void exportToFile(const QString& path, const QString& separator, QLocale::Language) const;
74  void exportToLaTeX(const QString&, const bool verticalHeaders, const bool horizontalHeaders,
75  const bool latexHeaders, const bool gridLines,
76  const bool entire, const bool captions) const;
77  void exportToFits(const QString& fileName, const int exportTo) const;
78 
79 public slots:
80  void createContextMenu(QMenu*) const;
81  void print(QPrinter*) const;
82 
83 private:
84  void init();
85  void initActions();
86  void initMenus();
87  void connectActions();
88  void goToCell(int row, int col);
89  void updateImage();
90 
91  bool eventFilter(QObject*, QEvent*) override;
92  void keyPressEvent(QKeyEvent*) override;
93 
94  QStackedWidget* m_stackedWidget;
95  QTableView* m_tableView;
96  QLabel* m_imageLabel;
99  QImage m_image;
100  bool m_imageIsDirty{true};
101 
102  //Actions
107 
117 
122 
126 
132 
136  QAction* action_add_rows;
138 
143 
144  //Menus
146  QMenu* m_columnMenu;
147  QMenu* m_rowMenu;
148  QMenu* m_matrixMenu;
150 
151  QShortcut* sel_all;
152 
153 private slots:
154  void goToCell();
155  void advanceCell();
156  void handleHorizontalSectionResized(int logicalIndex, int oldSize, int newSize);
157  void handleVerticalSectionResized(int logicalIndex, int oldSize, int newSize);
158 
159  void switchView(QAction*);
160  void matrixDataChanged();
161 
162  void fillWithFunctionValues();
163  void fillWithConstValues();
164 
165  void cutSelection();
166  void copySelection();
167  void pasteIntoSelection();
168  void clearSelectedCells();
169 
170  void headerFormatChanged(QAction*);
171 
172  void modifyValues();
173 
174  void addColumns();
175  void insertEmptyColumns();
176  void removeSelectedColumns();
177  void clearSelectedColumns();
178  void addRows();
179  void insertEmptyRows();
180  void removeSelectedRows();
181  void clearSelectedRows();
182 
183  void showColumnStatistics();
184  void showRowStatistics();
185 };
186 
187 #endif
Model for the access to data of a Matrix-object.
Definition: MatrixModel.h:37
void removeSelectedRows()
Definition: MatrixView.cpp:948
QAction * action_recalculate
Definition: MatrixView.h:112
void getCurrentCell(int *row, int *col) const
Definition: MatrixView.cpp:542
bool isCellSelected(int row, int col) const
Definition: MatrixView.cpp:523
QAction * action_clear_matrix
Definition: MatrixView.h:109
QAction * action_divide_value
Definition: MatrixView.h:121
QAction * action_transpose
Definition: MatrixView.h:114
QAction * action_statistics_rows
Definition: MatrixView.h:137
QAction * action_duplicate
Definition: MatrixView.h:113
MatrixModel * m_model
Definition: MatrixView.h:98
void exportToFits(const QString &fileName, const int exportTo) const
QAction * action_clear_columns
Definition: MatrixView.h:129
QAction * action_header_format_2
Definition: MatrixView.h:124
QAction * action_remove_columns
Definition: MatrixView.h:128
QAction * action_data_view
Definition: MatrixView.h:139
void adjustHeaders()
Definition: MatrixView.cpp:383
void switchView(QAction *)
Definition: MatrixView.cpp:837
void pasteIntoSelection()
Definition: MatrixView.cpp:682
QAction * action_mirror_horizontally
Definition: MatrixView.h:116
QShortcut * sel_all
Definition: MatrixView.h:151
bool isColumnSelected(int col, bool full=false) const
Definition: MatrixView.cpp:443
void cutSelection()
Definition: MatrixView.cpp:639
QAction * action_add_columns
Definition: MatrixView.h:130
int firstSelectedColumn(bool full=false) const
Definition: MatrixView.cpp:477
void insertEmptyRows()
Definition: MatrixView.cpp:925
QAction * action_insert_rows
Definition: MatrixView.h:133
QAction * action_insert_columns
Definition: MatrixView.h:127
void resizeHeaders()
Definition: MatrixView.cpp:415
void clearSelectedCells()
Definition: MatrixView.cpp:745
void headerFormatChanged(QAction *)
Definition: MatrixView.cpp:854
MatrixView(Matrix *)
Definition: MatrixView.cpp:67
void initActions()
Definition: MatrixView.cpp:142
int lastSelectedColumn(bool full=false) const
Definition: MatrixView.cpp:490
void matrixDataChanged()
Definition: MatrixView.cpp:848
void fillWithFunctionValues()
Definition: MatrixView.cpp:617
QAction * action_add_value
Definition: MatrixView.h:118
~MatrixView() override
Definition: MatrixView.cpp:86
void removeSelectedColumns()
Definition: MatrixView.cpp:893
int selectedRowCount(bool full=false) const
Definition: MatrixView.cpp:454
Matrix * m_matrix
Definition: MatrixView.h:97
void init()
Definition: MatrixView.cpp:94
void exportToLaTeX(const QString &, const bool verticalHeaders, const bool horizontalHeaders, const bool latexHeaders, const bool gridLines, const bool entire, const bool captions) const
QAction * action_header_format_1
Definition: MatrixView.h:123
QAction * action_fill_const
Definition: MatrixView.h:142
void goToCell()
Definition: MatrixView.cpp:589
void addRows()
Definition: MatrixView.cpp:921
QMenu * m_matrixMenu
Definition: MatrixView.h:148
int firstSelectedRow(bool full=false) const
Definition: MatrixView.cpp:502
void createContextMenu(QMenu *) const
Definition: MatrixView.cpp:331
void setCellsSelected(int first_row, int first_col, int last_row, int last_col)
Definition: MatrixView.cpp:533
void keyPressEvent(QKeyEvent *) override
Definition: MatrixView.cpp:570
QAction * action_header_format_3
Definition: MatrixView.h:125
QAction * action_set_formula
Definition: MatrixView.h:111
QAction * action_clear_rows
Definition: MatrixView.h:135
void setCellSelected(int row, int col)
Definition: MatrixView.cpp:529
void showRowStatistics()
QMenu * m_selectionMenu
Definition: MatrixView.h:145
MatrixModel * model() const
Definition: MatrixView.cpp:90
void copySelection()
Definition: MatrixView.cpp:650
void fillWithConstValues()
Definition: MatrixView.cpp:622
QAction * action_fill_function
Definition: MatrixView.h:141
QAction * action_cut_selection
Definition: MatrixView.h:103
QMenu * m_columnMenu
Definition: MatrixView.h:146
QAction * action_mirror_vertically
Definition: MatrixView.h:115
void handleVerticalSectionResized(int logicalIndex, int oldSize, int newSize)
Definition: MatrixView.cpp:612
QAction * action_select_all
Definition: MatrixView.h:108
QAction * action_multiply_value
Definition: MatrixView.h:120
void handleHorizontalSectionResized(int logicalIndex, int oldSize, int newSize)
Definition: MatrixView.cpp:607
int selectedColumnCount(bool full=false) const
Definition: MatrixView.cpp:431
void updateImage()
Definition: MatrixView.cpp:800
QImage m_image
Definition: MatrixView.h:99
void clearSelectedColumns()
Definition: MatrixView.cpp:906
void connectActions()
Definition: MatrixView.cpp:214
int lastSelectedRow(bool full=false) const
Definition: MatrixView.cpp:515
void initMenus()
Definition: MatrixView.cpp:252
QAction * action_add_rows
Definition: MatrixView.h:136
void addColumns()
Definition: MatrixView.cpp:867
QAction * action_clear_selection
Definition: MatrixView.h:106
QAction * action_image_view
Definition: MatrixView.h:140
bool m_imageIsDirty
Definition: MatrixView.h:100
void advanceCell()
Definition: MatrixView.cpp:583
bool isRowSelected(int row, bool full=false) const
Definition: MatrixView.cpp:466
void insertEmptyColumns()
Definition: MatrixView.cpp:871
QAction * action_paste_into_selection
Definition: MatrixView.h:105
bool eventFilter(QObject *, QEvent *) override
Definition: MatrixView.cpp:553
QAction * action_remove_rows
Definition: MatrixView.h:134
QLabel * m_imageLabel
Definition: MatrixView.h:96
void modifyValues()
Definition: MatrixView.cpp:206
QMenu * m_headerFormatMenu
Definition: MatrixView.h:149
QAction * action_subtract_value
Definition: MatrixView.h:119
void showColumnStatistics()
void exportToFile(const QString &path, const QString &separator, QLocale::Language) const
QAction * action_copy_selection
Definition: MatrixView.h:104
void print(QPrinter *) const
Definition: MatrixView.cpp:980
QTableView * m_tableView
Definition: MatrixView.h:95
QAction * action_statistics_columns
Definition: MatrixView.h:131
QAction * action_go_to_cell
Definition: MatrixView.h:110
QStackedWidget * m_stackedWidget
Definition: MatrixView.h:94
QMenu * m_rowMenu
Definition: MatrixView.h:147
void clearSelectedRows()
Definition: MatrixView.cpp:961
Definition: Matrix.h:41