Basic Image AlgorithmS Library  2.8.0
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
ParamGUISample3.cpp
1 /*
2 This file is part of the BIAS library (Basic ImageAlgorithmS).
3 
4 Copyright (C) 2003, 2004 (see file CONTACTS for details)
5  Multimediale Systeme der Informationsverarbeitung
6  Institut fuer Informatik
7  Christian-Albrechts-Universitaet Kiel
8 
9 
10 BIAS is free software; you can redistribute it and/or modify
11 it under the terms of the GNU Lesser General Public License as published by
12 the Free Software Foundation; either version 2.1 of the License, or
13 (at your option) any later version.
14 
15 BIAS is distributed in the hope that it will be useful,
16 but WITHOUT ANY WARRANTY; without even the implied warranty of
17 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 GNU Lesser General Public License for more details.
19 
20 You should have received a copy of the GNU Lesser General Public License
21 along with BIAS; if not, write to the Free Software
22 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
23 */
24 
25 
26 /**
27  @example ParamGUISample3.cpp
28  @relates ParamGUI
29  @brief Example for using the parameter gui classes
30  @ingroup g_examples
31  @author MIP
32 */
33 
34 #include <bias_config.h>
35 #include <wx/wx.h>
36 
37 #include <Gui/ParamGUI.hh>
38 #include <Gui/StringConv.hh>
39 #include <Utils/Param.hh>
40 #include <iostream>
41 
42 using namespace BIAS;
43 using namespace std;
44 
45 // classes
46 /** \cond HIDDEN_SYMBOLS */
47 class MyAlgorithm : public ParamCallbackInterface
48 {
49 public:
50  MyAlgorithm(){coollevel = NULL;};
51  ~MyAlgorithm(){};
52 
53  void ParamAdd(Param &p) {
54  coollevel = p.AddParamInt("coollevel","Really cool threshold");
55  p.RegisterCallbackObject("coollevel",this); };
56  void ParameterChanged(const std::string &name, const void *data){
57  cout <<"Here is MyAlgorithm! My parameter \""<<name<<"\" changed"<<endl;
58  if (data == coollevel)
59  cout <<"Hey, it was \"coollevel\", new cool level is: "<<*coollevel
60  <<endl;
61  };
62 
63 protected:
64  int *coollevel;
65 };
66 
67 class MyApp : public wxApp
68 {
69  public:
70  virtual bool OnInit();
71 };
72 
73 DECLARE_APP(MyApp)
74 
75 class MyFrame : public wxFrame
76 {
77 public:
78  MyFrame();
79  ~MyFrame();
80  ParamGUI param_;
81 };
82 
83 
84 // uncool global, for testing
85 MyAlgorithm *algo;
86 
87 // implementation
88 
89 IMPLEMENT_APP(MyApp)
90 
91 bool MyApp::OnInit()
92 {
93  MyFrame *frame = new MyFrame();
94  frame->Show(TRUE);
95  SetTopWindow(frame);
96  return true;
97 }
98 
99 MyFrame::MyFrame()
100  : wxFrame(NULL, -1, _T("ParamGUISample3"), wxDefaultPosition,
101  wxSize(400,600) )
102 {
103  param_.AddParamInt("SampleInt1","Hilfetext zu SampleInt1",0,-100,100,0,1);
104  param_.AddParamInt("SampleInt2","Hilfetext zu SampleInt2");
105  param_.AddParamBool("SampleBool1","Hilfetext zu SampleBool1",false,0,1);
106  param_.AddParamBool("SampleBool2","Hilfetext zu SampleBool2");
107  param_.AddParamDouble("SampleDouble1","Hilfetext zu SampleDouble1");
108  param_.AddParamString("SampleString1","Hilfetext zu SampleString1");
109 
110  algo = new MyAlgorithm();
111  algo->ParamAdd(param_);
112 
113  param_.ParseCommandLine(wxTheApp->argc,WxToAsciiArray(wxTheApp->argv,wxTheApp->argc));
114  param_.ShowData();
115  wxNotebook *MyNotebook;
116  MyNotebook = param_.GetNotebook(this);
117 #if wxCHECK_VERSION(2,5,2)
118  wxBoxSizer *nbsizer = new wxBoxSizer(wxHORIZONTAL);
119  nbsizer->Add(MyNotebook);
120 #else
121  wxNotebookSizer *nbsizer;
122  nbsizer = new wxNotebookSizer(MyNotebook);
123 #endif
124  SetSizer(nbsizer);
125  Show();
126 }
127 
128 MyFrame::~MyFrame()
129 {
130  param_.ShowData();
131 }
132 
133 /** \endcond */
The main Parameter Gui interface, derived from BIAS::Param and extends this class.
Definition: ParamGUI.hh:88
int RegisterCallbackObject(const std::string &name, ParamCallbackInterface *obj)
Definition: Param.cpp:1813
This class provides an interface to be called if parameter changes occured.
Definition: Param.hh:74
This class Param provides generic support for parameters.
Definition: Param.hh:231
Class for converting an array of wxStrings to an array of non-const ASCII strings.
Definition: StringConv.hh:60
int * AddParamInt(const std::string &name, const std::string &help, int deflt=0, int min=std::numeric_limits< int >::min(), int max=std::numeric_limits< int >::max(), char cmdshort=0, int Group=GRP_NOSHOW)
For all adding routines:
Definition: Param.cpp:276