]> Creatis software - bbtk.git/blob - samples/SampleWidgetsBase/bbtkSampleWidgetsBase.cxx
#3202 BBTK Feature New Normal - fast algorithm for ImageBoundaries box
[bbtk.git] / samples / SampleWidgetsBase / bbtkSampleWidgetsBase.cxx
1 /*
2  # ---------------------------------------------------------------------
3  #
4  # Copyright (c) CREATIS (Centre de Recherche en Acquisition et Traitement de l'Image
5  #                        pour la SantÈ)
6  # Authors : Eduardo Davila, Frederic Cervenansky, Claire Mouton
7  # Previous Authors : Laurent Guigues, Jean-Pierre Roux
8  # CreaTools website : www.creatis.insa-lyon.fr/site/fr/creatools_accueil
9  #
10  #  This software is governed by the CeCILL-B license under French law and
11  #  abiding by the rules of distribution of free software. You can  use,
12  #  modify and/ or redistribute the software under the terms of the CeCILL-B
13  #  license as circulated by CEA, CNRS and INRIA at the following URL
14  #  http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.html
15  #  or in the file LICENSE.txt.
16  #
17  #  As a counterpart to the access to the source code and  rights to copy,
18  #  modify and redistribute granted by the license, users are provided only
19  #  with a limited warranty  and the software's author,  the holder of the
20  #  economic rights,  and the successive licensors  have only  limited
21  #  liability.
22  #
23  #  The fact that you are presently reading this means that you have had
24  #  knowledge of the CeCILL-B license and that you accept its terms.
25  # ------------------------------------------------------------------------ */
26
27
28 #include <bbwxSlider.h>
29 #include <bbwxOutputText.h>
30
31 //=========================================================================
32 // Different examples of using black boxes in C++
33 // Here we do not use wxWidgets however WxBlackBox work in **Dialog** mode 
34 //=========================================================================
35
36 //=========================================================================
37 void SimpleSliderDialog()
38 {
39   std::cout << "============== Simple Slider dialog 1" << std::endl;
40    try
41     {
42       bbwx::Slider::Pointer slider = bbwx::Slider::New("slider");
43                 std::cout << "============== Simple Slider dialog " << std::endl;
44       //      slider->bbGetHelp();
45       slider->bbSetInputWinDialog(true);  // mandatory
46                 std::cout << "============== Simple Slider dialog 3" << std::endl; 
47       slider->bbExecute();
48       std::cout << "Slider Output = "<< slider->bbGetOutputOut() << std::endl;
49     }
50   catch (bbtk::Exception e)
51     {
52       e.Print();
53     } 
54 }
55 //=========================================================================
56
57 //=========================================================================
58 void SliderOutputTextWithoutFactory()
59 {
60   std::cout << "============== Slider->OutputText without Factory" 
61             << std::endl;
62   try
63     {
64       bbwx::Slider::Pointer slider = bbwx::Slider::New("slider");
65       bbwx::OutputText::Pointer text = bbwx::OutputText::New("text");
66       bbtk::Connection::Pointer s2t = bbtk::Connection::New(slider,"Out",
67                                                             text,"In");
68       text->bbExecute();
69     }
70   catch (bbtk::Exception e)
71     {
72       bbtk::MessageManager::SetMessageLevel("Error",1);
73       e.Print();
74     }
75 }
76 //=========================================================================
77
78
79 //=========================================================================
80 #include <bbtkFactory.h>
81 #include <bbwxLayoutLine.h>
82 void SliderOutputTextWithFactory()
83 {
84   std::cout << "============== Slider->OutputText **WITH** Factory" 
85             << std::endl;
86   try
87     {
88       bbtk::Factory::Pointer factory = bbtk::Factory::New();
89   
90       factory->LoadPackage("std");
91
92       bbwx::Slider::Pointer     slider   = bbwx::Slider::New("slider");
93       bbwx::OutputText::Pointer text     = bbwx::OutputText::New("text");
94       bbtk::Connection::Pointer s2t      = bbtk::Connection::New(slider,"Out",
95                                                             text,"In",
96                                                             factory);
97       bbwx::LayoutLine::Pointer layout   = bbwx::LayoutLine::New("layout");
98       bbtk::Connection::Pointer c1       = bbtk::Connection::New(slider,"Widget",
99                                                            layout,"Widget1");
100       bbtk::Connection::Pointer c2       = bbtk::Connection::New(text,"Widget",
101                                                            layout,"Widget2");
102                                                            
103       bbtk::Connection::Pointer c3       = bbtk::Connection::New(slider,"BoxChange",
104                                                            text,"BoxExecute");
105       // OR 
106       //      text->bbSetInputBoxProcessMode("Reactive");
107       
108       layout->bbSetInputWinDialog(true);
109       layout->bbExecute();
110     }
111   catch (bbtk::Exception e)
112     {
113       bbtk::MessageManager::SetMessageLevel("Error",1);
114       e.Print();
115     }
116 }
117 //=========================================================================
118
119 //=========================================================================
120 int main(int argv, char* argc[])
121 {
122   // To track all ...
123   //  bbtk::MessageManager::SetMessageLevel("all",9);
124   
125   SimpleSliderDialog();
126   SliderOutputTextWithoutFactory();
127   SliderOutputTextWithFactory();
128
129   // To get the list of bbtk object still allocated after main ends
130   // bbtk::StaticInitTime::PrintObjectListInfo = true;
131   // bbtk::MessageManager::SetMessageLevel("object",1);
132 }
133 //=========================================================================