NumeRe v1.1.4
NumeRe: Framework für Numerische Rechnungen
tableviewer.hpp
Go to the documentation of this file.
1/*****************************************************************************
2 NumeRe: Framework fuer Numerische Rechnungen
3 Copyright (C) 2017 Erik Haenel et al.
4
5 This program is free software: you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation, either version 3 of the License, or
8 (at your option) any later version.
9
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
14
15 You should have received a copy of the GNU General Public License
16 along with this program. If not, see <http://www.gnu.org/licenses/>.
17******************************************************************************/
18
19
20#ifndef TABLEVIEWER_HPP
21#define TABLEVIEWER_HPP
22
23#include <wx/wx.h>
24#include <wx/grid.h>
25
26#include <vector>
27#include <string>
28
30#include "../../kernel/core/datamanagement/container.hpp"
31#include "../../kernel/core/datamanagement/table.hpp"
32
33class TablePanel;
34
41class TableViewer : public wxGrid
42{
43 private:
44 size_t nHeight;
45 size_t nWidth;
49 wxGridCellCoords lastCursorPosition;
50 wxGridCellCoordsArray selectedCells;
51 std::vector<int> m_currentColTypes;
52 std::string m_displayName;
53 std::string m_intName;
54
55 // External window elements
57 wxStatusBar* m_statusBar;
58
59 void layoutGrid();
60
61 void OnKeyDown(wxKeyEvent& event);
62 void OnChar(wxKeyEvent& event);
63 void OnEnter(wxMouseEvent& event);
64 void OnCellChange(wxGridEvent& event);
65 void OnCellSelect(wxGridEvent& event);
66 void OnCellRangeSelect(wxGridRangeSelectEvent& event);
67 void OnLabelDoubleClick(wxGridEvent& event);
68 void updateFrame();
69 void deleteSelection();
70 int findLastElement(int nCol);
71 bool isNumerical(const std::string& sCell);
72 bool isEmptyCol(int col);
73 wxString replaceCtrlChars(const wxString& sStr);
74 void copyContents();
75 void pasteContents(bool useCursor = false);
77 void UpdateColumnAlignment(int col);
78 std::vector<wxString> getLinesFromPaste(const wxString& data);
79 void replaceDecimalSign(wxString& text);
80 void replaceTabSign(wxString& text);
82 wxGridCellCoords CreateEmptyGridSpace(int rows, int headrows, int cols, bool useCursor = false);
83
84 mu::value_type CellToCmplx(int row, int col);
85
86 double calculateMin(const wxGridCellCoordsContainer& coords);
87 double calculateMax(const wxGridCellCoordsContainer& coords);
90
91 void updateStatusBar(const wxGridCellCoordsContainer& coords, wxGridCellCoords* cursor = nullptr);
92 void createMenuBar();
93
94 wxString copyCell(int row, int col);
95
97 wxGridCellCoords m_lastRightClick;
98
99
100 public:
101 TableViewer(wxWindow* parent, wxWindowID id, wxStatusBar* statusbar, TablePanel* parentPanel, const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize, long style = wxWANTS_CHARS, const wxString& name = wxGridNameStr);
102
103 void SetData(NumeRe::Container<std::string>& _stringTable, const std::string& sName, const std::string& sIntName);
104 void SetData(NumeRe::Table& _table, const std::string& sName, const std::string& sIntName);
107
108 void SetTableReadOnly(bool isReadOnly = true);
109 void SetDefaultSize(size_t rows = 1, size_t cols = 1) __attribute__ ((deprecated));
110 void OnLabelRightClick(wxGridEvent& event);
111 void OnCellRightClick(wxGridEvent& event);
112 void OnMenu(wxCommandEvent& event);
113 void insertElement(int id);
114 void removeElement(int id);
115 void saveTable(bool saveAs = false);
116 void reloadTable();
117 void changeColType();
118 void finalize();
119
120 wxString getSelectedValues();
121
122
123 size_t GetHeight() {return nHeight;}
124 size_t GetWidth() {return nWidth;}
125
127 {
142 };
143
145};
146
147#endif // TABLEVIEWER_HPP
148
This data container is a copy- efficient table to interchange data between Kernel and GUI.
Definition: table.hpp:87
Generic table panel, which also contains all meta UI elements.
This class is an adaption of the wxGrid class to present the tabular data in NumeRe's memory and enab...
Definition: tableviewer.hpp:42
void OnCellSelect(wxGridEvent &event)
This member function will highlight the cursor position in the grid and update the status bar corresp...
void deleteSelection()
This member function will delete the contents of the selected cells by setting them to NaN.
wxGridCellCoords CreateEmptyGridSpace(int rows, int headrows, int cols, bool useCursor=false)
This member function creates the needed space in the grid, which is needed to paste data.
double calculateMax(const wxGridCellCoordsContainer &coords)
This member function calculates the maximal value of the selected cells.
std::string m_intName
Definition: tableviewer.hpp:53
void applyConditionalCellColourScheme()
Apply a conditional cell colour scheme to the selected cells.
void replaceDecimalSign(wxString &text)
This member function replaces the german comma decimal sign with the dot used in anglo-american notat...
std::vector< int > m_currentColTypes
Definition: tableviewer.hpp:51
bool isGridNumeReTable
Definition: tableviewer.hpp:48
void SetData(NumeRe::Container< std::string > &_stringTable, const std::string &sName, const std::string &sIntName)
This member function is the data setter for string and cluster tables.
void copyContents()
This member function will copy the contents of the selected cells to the clipboard.
void UpdateColumnAlignment(int col)
Changes the alignment of a whole column to reflect its internal type.
void changeColType()
Enables the switching of the column types of the selected columns.
bool isEmptyCol(int col)
This member function will determine, whether the selected column is completely empty or not.
void OnLabelRightClick(wxGridEvent &event)
This member function displays the context menu for labels.
void createZeroElementTable()
This member function creates a zero- element table to visualize empty tables (or non-existent ones).
size_t nHeight
Definition: tableviewer.hpp:44
size_t GetHeight()
wxGridCellCoords m_lastRightClick
Definition: tableviewer.hpp:97
void saveTable(bool saveAs=false)
Saves the currently displayed table directly to the selected file.
int findLastElement(int nCol)
This member function will search the last non-empty cell in the selected column.
NumeRe::Table GetData()
This member function returns the internal NumeRe::Table from the data provider object.
mu::value_type calculateSum(const wxGridCellCoordsContainer &coords)
This member function calculates the sum of the selected cells.
void OnChar(wxKeyEvent &event)
This member function appends necessary columns or rows, if the user entered a character in the last c...
std::string m_displayName
Definition: tableviewer.hpp:52
void finalize()
Ensure that the editors are all closed.
wxMenu m_popUpMenu
Definition: tableviewer.hpp:96
double calculateMin(const wxGridCellCoordsContainer &coords)
This member function calculates the minimal value of the selected cells.
void SetDefaultSize(size_t rows=1, size_t cols=1) __attribute__((deprecated))
This member function creates an empty table of some size.
void OnMenu(wxCommandEvent &event)
This member function is the menu command event handler function. It will redirect the control to the ...
void layoutGrid()
This private member function will layout the initial grid after the data table was set.
bool isNumerical(const std::string &sCell)
This is a simple helper function to determine, whether the entered cell value is a numerical value.
wxGridCellCoords lastCursorPosition
Definition: tableviewer.hpp:49
TableViewer(wxWindow *parent, wxWindowID id, wxStatusBar *statusbar, TablePanel *parentPanel, const wxPoint &pos=wxDefaultPosition, const wxSize &size=wxDefaultSize, long style=wxWANTS_CHARS, const wxString &name=wxGridNameStr)
Constructor.
Definition: tableviewer.cpp:66
void removeElement(int id)
This member function processes the removing of cells, columns or rows.
@ ID_MENU_CHANGE_COL_TYPE
void OnCellChange(wxGridEvent &event)
This member function processes the values entered in the table and updates the frame after entering (...
wxStatusBar * m_statusBar
Definition: tableviewer.hpp:57
void SetTableReadOnly(bool isReadOnly=true)
This member function declares the table to be read-only and enables the context menu entries,...
void OnCellRangeSelect(wxGridRangeSelectEvent &event)
This member function will calculate the simple statistics if the user selected a range of cells in th...
void replaceTabSign(wxString &text)
This member function replaces the tabulator character with whitespaces.
mu::value_type calculateAvg(const wxGridCellCoordsContainer &coords)
This member function calculates the average of the selected cells.
void reloadTable()
Reloads the currently displayed table data from the kernel.
wxString copyCell(int row, int col)
This member function returns the contents of the selected cells and replaces whitespaces with undersc...
size_t nFirstNumRow
Definition: tableviewer.hpp:46
void updateFrame()
This member function is called every time the grid itself changes to draw the frame colours.
void OnCellRightClick(wxGridEvent &event)
This member function displays the context menu for cells.
void OnLabelDoubleClick(wxGridEvent &event)
This member function will autosize the columns, if the user double clicked on their labels.
size_t GetWidth()
wxString getSelectedValues()
Returns the values of all selected cells as a string list.
mu::value_type CellToCmplx(int row, int col)
Return the cell value as value_type.
void OnEnter(wxMouseEvent &event)
This member function is the event handler for entering this window. It will activate the focus and br...
std::vector< wxString > getLinesFromPaste(const wxString &data)
This member function transformes the data obtained by the clipboard into a table- like layout.
void createMenuBar()
Creates a menu bar in the top frame.
NumeRe::Table GetDataCopy()
This member function returns a safe copy of the internal NumeRe::Table.
TablePanel * m_parentPanel
Definition: tableviewer.hpp:56
wxString replaceCtrlChars(const wxString &sStr)
This member function is a simple helper to replace underscores with whitespaces.
void OnKeyDown(wxKeyEvent &event)
This member function tracks the entered keys and processes a keybord navigation.
size_t nWidth
Definition: tableviewer.hpp:45
wxGridCellCoordsArray selectedCells
Definition: tableviewer.hpp:50
void updateStatusBar(const wxGridCellCoordsContainer &coords, wxGridCellCoords *cursor=nullptr)
This member function updates the status bar of the enclosing ViewerFrame.
void insertElement(int id)
This member function processes the insertion of new empty cells, columns or rows.
void pasteContents(bool useCursor=false)
This member function handles the case that the user tries to paste text contents, which may be be con...
A class to simplify the access to different types of grid cell coords. Especially useful in the conte...
__attribute__((force_align_arg_pointer)) static Matrix calcEigenVectsAndValues(const Matrix &_mMatrix
This static function does the whole eigenvalues, eigenvectors and diagonalizing stuff.
MUP_BASETYPE value_type
The numeric datatype used by the parser.
Definition: muParserDef.h:251
char name[32]
Definition: resampler.cpp:371