Basic Image AlgorithmS Library  2.8.0
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
ParamGUI.hh
1 #ifndef __ParamGUI_hh__
2 #define __ParamGUI_hh__
3 
4 #include <bias_config.h>
5 #include <Base/Common/BIASpragmaStart.hh>
6 
7 // STL headers
8 #include <map>
9 
10 // BIAS headers
11 #include <Utils/ParamTypes.hh>
12 #include <Utils/Param.hh>
13 
14 // WX headers
15 #include <wx/wx.h>
16 #include <wx/spinctrl.h>
17 #include <wx/notebook.h>
18 
19 namespace BIAS
20 {
21  struct BIASGui_EXPORT ItemAndWidget {
22  wxControl *widget;
24  };
25 
26  /** @class ParamGUIPanel
27  @ingroup g_gui
28  @brief this provides a gui interface for the BIAS::Param class.
29  It is derived from wxPanel and can therefor be integrated in any
30  wx application
31  @author evers/mdunda */
32  class BIASGui_EXPORT ParamGUIPanel : public wxPanel
33  {
34  public:
35  ParamGUIPanel(wxWindow *parent);
36  ~ParamGUIPanel();
37 
38  // methods for adding widgets
39  void AddIntWidgets(BIAS::ParamTypeInt *item);
40  void AddBoolWidgets(BIAS::ParamTypeBool *item);
41  void AddDoubleWidgets(BIAS::ParamTypeDouble *item);
42  void AddStringWidgets(BIAS::ParamTypeString *item);
43  void AddVecDblWidgets(BIAS::ParamTypeVecDbl *item);
44  void AddVecIntWidgets(BIAS::ParamTypeVecInt *item);
45  void AddEnumWidgets(BIAS::ParamTypeEnum *item);
46 
47  protected:
49  private: // avoid DLL export
50  std::map<unsigned int, struct ItemAndWidget> WidgetIDs_;
51  protected:
52  wxFlexGridSizer *Grid_;
53 
54  // event handling methods
55  void OnSpinCtrl(wxSpinEvent &event);
56  void OnCheckBox(wxCommandEvent &event);
57  void OnTextEnter(wxCommandEvent &event);
58  void OnChoice(wxCommandEvent &event);
59 
60  // WX macro to declare an event table for this object
61  DECLARE_EVENT_TABLE()
62  };
63 
64  class BIASGui_EXPORT ParamGUI;
65 
66  /**
67  * \brief this provides a gui interface for the BIAS::Param class.
68  * It is derived from wxDialog and can therefor be integrated in any
69  * wx application and displayed as a dialog */
70  class BIASGui_EXPORT ParamGUIDialog : public wxDialog
71  {
72  public:
73  ParamGUIDialog(wxWindow *parent,const wxString& title,
74  const wxPoint &p,const wxSize &s, ParamGUI *pg,
75  bool bChancelButton=true);
76  ~ParamGUIDialog();
77  protected:
78 
79  DECLARE_EVENT_TABLE()
80  };
81 
82  /** @class ParamGUI
83  @ingroup g_gui
84  @brief The main Parameter Gui interface, derived from BIAS::Param
85  and extends this class. Provides a wxPanel, a wxFrame, a dialog or a notebook
86  with the parameters sorted by their groups
87  @author evers/mdunda */
88  class BIASGui_EXPORT ParamGUI : public BIAS::Param
89  {
90  public:
91  ParamGUI();
92  ~ParamGUI();
93 
94  /** Builds up a wxPanel with the parameters specified by GroupID.
95  @return a pointer to the new panel
96  @return NULL on error
97  @author mdunda 03 2004 */
98  wxPanel* GetPanel(wxWindow *parent, int GroupID=GRP_ALL);
99 
100  /** Builds up a wxNotebook with each parameter group on one page.
101  Group-ID -1 (GRP_NOSHOW) will be ignored.
102  @return a pointer to the new notebook
103  @retrun NULL on error
104  @author mdunda 03 2004
105  now GroupNames are shown in tabs if all Groupnames are set
106  ischiller 08.09.04
107  */
108  wxNotebook* GetNotebook(wxWindow *parent);
109 
110  /** Builds up a standalone wxFrame with a notebook embedded in it.
111  @return a pointer to the new frame
112  @retrun NULL on error
113  @author mdunda 03 2004 */
114  wxFrame* GetFrame(wxWindow *parent);
115 
116 
117  /** Builds up a wxDialog with a notebook embedded in it.
118  @return a pointer to the new dialog
119  @retrun NULL on error
120  @author evers 2004-01 */
121  ParamGUIDialog* GetDialog(wxWindow *parent, const wxString &title,
122  bool bChancelButton=true);
123 
124 
125  }; // class
126 
127  class wxChoiceWithMemory : public wxChoice
128  {
129  public:
130  wxChoiceWithMemory() : wxChoice() {};
131  wxChoiceWithMemory(wxWindow *parent, wxWindowID id,
132  const wxPoint &pos=wxDefaultPosition,
133  const wxSize &size=wxDefaultSize, int n=0,
134  const wxString choices[]=NULL, long style=0,
135  const wxValidator &validator=wxDefaultValidator,
136  const wxString &name=wxChoiceNameStr) :
137  wxChoice(parent,id,pos,size,n,choices,style,validator,name) {};
138  wxChoiceWithMemory(wxWindow *parent, wxWindowID id,
139  const wxPoint &pos, const wxSize &size,
140  const wxArrayString &choices, long style=0,
141  const wxValidator &validator=wxDefaultValidator,
142  const wxString &name=wxChoiceNameStr):
143  wxChoice(parent,id,pos,size, choices,style,validator,name) {};
144 
145  void AddDataToMemory(int index);
146  int GetIndexForSelection(int selection);
147  int GetSelectionForIndex(int index);
148 
149  protected:
150  //maps selection to externally assigned index numbers;
151  //e.g. 0->5, 1->4, 2->3 ....
152  std::map<int, int> memorySelectionToIndex_;
153  std::map<int, int> memoryIndexToSelection_;
154  };
155 } // namespace
156 
157 #include <Base/Common/BIASpragmaEnd.hh>
158 
159 #endif /* __ParamGUI_hh__ */
The main Parameter Gui interface, derived from BIAS::Param and extends this class.
Definition: ParamGUI.hh:88
class BIASGui_EXPORT ParamGUI
Definition: ParamGUI.hh:64
wxControl * widget
Definition: ParamGUI.hh:22
wxChoiceWithMemory(wxWindow *parent, wxWindowID id, const wxPoint &pos=wxDefaultPosition, const wxSize &size=wxDefaultSize, int n=0, const wxString choices[]=NULL, long style=0, const wxValidator &validator=wxDefaultValidator, const wxString &name=wxChoiceNameStr)
Definition: ParamGUI.hh:131
int GetSelectionForIndex(int index)
Definition: ParamGUI.cpp:588
wxChoiceWithMemory(wxWindow *parent, wxWindowID id, const wxPoint &pos, const wxSize &size, const wxArrayString &choices, long style=0, const wxValidator &validator=wxDefaultValidator, const wxString &name=wxChoiceNameStr)
Definition: ParamGUI.hh:138
This file holds the definitions of the parameter types used by BIAS::Param.
Definition: ParamTypes.hh:49
BIAS::ParamTypeBase * item
Definition: ParamGUI.hh:23
std::map< int, int > memoryIndexToSelection_
Definition: ParamGUI.hh:153
wxWindow * Parent_
Definition: ParamGUI.hh:48
std::map< int, int > memorySelectionToIndex_
Definition: ParamGUI.hh:152
this provides a gui interface for the BIAS::Param class.
Definition: ParamGUI.hh:32
This class Param provides generic support for parameters.
Definition: Param.hh:231
this provides a gui interface for the BIAS::Param class.
Definition: ParamGUI.hh:70
int GetIndexForSelection(int selection)
Definition: ParamGUI.cpp:581
void AddDataToMemory(int index)
Definition: ParamGUI.cpp:574
wxFlexGridSizer * Grid_
Definition: ParamGUI.hh:52