Darwin  1.10(beta)
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
drwnMatrixEditor.h
1 /*****************************************************************************
2 ** DARWIN: A FRAMEWORK FOR MACHINE LEARNING RESEARCH AND DEVELOPMENT
3 ** Distributed under the terms of the BSD license (see the LICENSE file)
4 ** Copyright (c) 2007-2015, Stephen Gould
5 ** All rights reserved.
6 **
7 ******************************************************************************
8 ** FILENAME: drwnMatrixEditor.h
9 ** AUTHOR(S): Stephen Gould <stephen.gould@anu.edu.au>
10 ** DESCRIPTION:
11 ** Darwin GUI editor for Eigen::VectorXd and Eigen::MatrixXd.
12 **
13 *****************************************************************************/
14 
15 #pragma once
16 
17 #include "wx/wx.h"
18 #include "wx/utils.h"
19 #include "wx/dialog.h"
20 #include "wx/grid.h"
21 #include "wx/spinctrl.h"
22 #include "wx/textctrl.h"
23 
24 #include "Eigen/Core"
25 
26 using namespace std;
27 using namespace Eigen;
28 
29 enum {
30  EDIT_TEXT_MODE = wxID_HIGHEST + 100,
31 
32  ROWS_SPIN_CTRL = wxID_HIGHEST + 200,
33  COLS_SPIN_CTRL = wxID_HIGHEST + 210
34 };
35 
36 // drwnMatrixEditor ----------------------------------------------------------
37 
38 class drwnMatrixEditor : public wxDialog
39 {
40  protected:
41  bool _fixedRows;
42  bool _fixedCols;
43  wxGrid *_grid;
44  wxTextCtrl *_text;
45 
46  // TODO: _readOnly
47 
48  public:
49  drwnMatrixEditor(wxWindow *parent, const Eigen::MatrixXd *m, bool bFixed = true);
50  drwnMatrixEditor(wxWindow *parent, const Eigen::VectorXd *v, bool bFixed = true);
52 
53  // access
54  int getRows() const { return _grid->GetNumberRows(); }
55  int getCols() const { return _grid->GetNumberCols(); }
56 
57  Eigen::VectorXd getRow(int r = 0) const;
58  Eigen::VectorXd getCol(int c = 0) const;
59  Eigen::MatrixXd getMatrix() const;
60 
61  // event callbacks
62  void onBtnOkay(wxCommandEvent& event);
63  void onSpinCtrl(wxSpinEvent& event);
64  void onChangeMode(wxCommandEvent& event);
65 
66  protected:
67  DECLARE_EVENT_TABLE()
68 };
Definition: drwnMatrixEditor.h:38