Basic Image AlgorithmS Library  2.8.0
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
ParamGUISample3.cpp

Example for using the parameter gui classes

Author
MIP
/*
This file is part of the BIAS library (Basic ImageAlgorithmS).
Copyright (C) 2003, 2004 (see file CONTACTS for details)
Multimediale Systeme der Informationsverarbeitung
Institut fuer Informatik
Christian-Albrechts-Universitaet Kiel
BIAS is free software; you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation; either version 2.1 of the License, or
(at your option) any later version.
BIAS is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License
along with BIAS; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
/**
@example ParamGUISample3.cpp
@relates ParamGUI
@brief Example for using the parameter gui classes
@ingroup g_examples
@author MIP
*/
#include <bias_config.h>
#include <wx/wx.h>
#include <Gui/ParamGUI.hh>
#include <Gui/StringConv.hh>
#include <Utils/Param.hh>
#include <iostream>
using namespace BIAS;
using namespace std;
// classes
/** \cond HIDDEN_SYMBOLS */
class MyAlgorithm : public ParamCallbackInterface
{
public:
MyAlgorithm(){coollevel = NULL;};
~MyAlgorithm(){};
void ParamAdd(Param &p) {
coollevel = p.AddParamInt("coollevel","Really cool threshold");
p.RegisterCallbackObject("coollevel",this); };
void ParameterChanged(const std::string &name, const void *data){
cout <<"Here is MyAlgorithm! My parameter \""<<name<<"\" changed"<<endl;
if (data == coollevel)
cout <<"Hey, it was \"coollevel\", new cool level is: "<<*coollevel
<<endl;
};
protected:
int *coollevel;
};
class MyApp : public wxApp
{
public:
virtual bool OnInit();
};
DECLARE_APP(MyApp)
class MyFrame : public wxFrame
{
public:
MyFrame();
~MyFrame();
ParamGUI param_;
};
// uncool global, for testing
MyAlgorithm *algo;
// implementation
IMPLEMENT_APP(MyApp)
bool MyApp::OnInit()
{
MyFrame *frame = new MyFrame();
frame->Show(TRUE);
SetTopWindow(frame);
return true;
}
MyFrame::MyFrame()
: wxFrame(NULL, -1, _T("ParamGUISample3"), wxDefaultPosition,
wxSize(400,600) )
{
param_.AddParamInt("SampleInt1","Hilfetext zu SampleInt1",0,-100,100,0,1);
param_.AddParamInt("SampleInt2","Hilfetext zu SampleInt2");
param_.AddParamBool("SampleBool1","Hilfetext zu SampleBool1",false,0,1);
param_.AddParamBool("SampleBool2","Hilfetext zu SampleBool2");
param_.AddParamDouble("SampleDouble1","Hilfetext zu SampleDouble1");
param_.AddParamString("SampleString1","Hilfetext zu SampleString1");
algo = new MyAlgorithm();
algo->ParamAdd(param_);
param_.ParseCommandLine(wxTheApp->argc,WxToAsciiArray(wxTheApp->argv,wxTheApp->argc));
param_.ShowData();
wxNotebook *MyNotebook;
MyNotebook = param_.GetNotebook(this);
#if wxCHECK_VERSION(2,5,2)
wxBoxSizer *nbsizer = new wxBoxSizer(wxHORIZONTAL);
nbsizer->Add(MyNotebook);
#else
wxNotebookSizer *nbsizer;
nbsizer = new wxNotebookSizer(MyNotebook);
#endif
SetSizer(nbsizer);
Show();
}
MyFrame::~MyFrame()
{
param_.ShowData();
}
/** \endcond */