]> Creatis software - bbtk.git/blob - kernel/src/bbtkKWBlackBox.cxx
Feature #1774
[bbtk.git] / kernel / src / bbtkKWBlackBox.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 /*=========================================================================
29   Program:   bbtk
30   Module:    $RCSfile: bbtkKWBlackBox.cxx,v $
31   Language:  C++
32   Date:      $Date: 2012/11/16 08:49:01 $
33   Version:   $Revision: 1.11 $
34 =========================================================================*/
35
36
37 /**
38  *  \file 
39  *  \brief 
40  */
41
42 #ifdef USE_KWWIDGETS
43
44 #include "bbtkKWBlackBox.h"
45 #include "bbtkBlackBoxOutputConnector.h"
46 #include "vtkKWBlackBoxDialog.h"
47
48 namespace bbtk
49 {
50   //=========================================================================
51   // KWBlackBox
52   //=========================================================================
53
54   //=========================================================================
55   //=========================================================================
56   //=========================================================================
57   //=========================================================================
58   BBTK_BLACK_BOX_IMPLEMENTATION(KWBlackBox,WidgetBlackBox<wxWindow>);
59   //=========================================================================
60   
61   //==================================================================    
62   /// Callback for creating a Dialog window (modal)
63   void WxBlackBox::bbCreateDialogWindow()
64   {
65     KW::GetApplication();
66     vtkKWBlackBoxDialog* win = vtkKWBlackBoxDialog::New();
67     show = (Window*) win;
68     win->bbSetBlackBox( GetThisPointer<KWBlackBox>());
69     KW::GetApplication()->AddWindow((vtkKWWindowBase*)win);
70     win->Create();
71     win->SetResizable(0,0);
72     
73     bbUserCreateWidget(win->GetFrame());
74     /*
75       KW::GetApplication()->Script
76       ("pack %s -expand yes -fill both",
77       bbGetOutputWidget()->GetWidgetName());
78     */
79     
80     KW::GetApplication()->Script("place %s -x 0 -y 0 -width %d -height %d",
81                                  bbGetOutputWidget()->GetWidgetName(),
82                                  bbGetInputWinWidth(),
83                                  bbGetInputWinHeight());
84   }
85   //==================================================================    
86
87   //==================================================================    
88   /// Callback for creating a Frame window 
89   void WxBlackBox::bbCreateFrameWindow()
90   {
91     bbtkWarning("KW: Frame windows not supported: creating a Dialog!");
92     bbCreateDialogWindow();
93   }
94   //==================================================================    
95
96
97   //==================================================================
98   vtkKWWidget*  KWBlackBox::bbCreateWidgetOfInput(const std::string& in, 
99                                                   vtkKWFrame* parent)
100   {
101     vtkKWWidget* w = 0;
102     // If input is connected 
103     BlackBoxInputConnector* c = bbGetInputConnectorMap().find(in)->second ;
104     if ( c->IsConnected() )                     
105       {
106         // Get black box from 
107         BlackBox::Pointer from = 
108           c->GetConnection()->GetBlackBoxFrom();
109         // Cast it into a KWBlackBox
110         KWBlackBox::Pointer wfrom = boost::dynamic_pointer_cast<KWBlackBox>(from);
111         // Call bbCreateWidget
112         wfrom->bbUserCreateWidget(parent);
113         // Get the widget created
114         w = wfrom->bbGetOutputWidget();
115       }
116     return w;
117   }
118   //==================================================================
119
120
121   //==================================================================
122   //  void KWBlackBox::InitWindowManagerIfNeeded() { KW::
123   void KWBlackBox::IncNbWindowsAlive() { KW::IncNbWindowsAlive(); }
124   void KWBlackBox::DecNbWindowsAlive() { KW::DecNbWindowsAlive(); }
125   int  KWBlackBox::GetNbWindowsAlive() { return KW::GetNbWindowsAlive(); }
126   bool KWBlackBox::IsSomeWindowAlive() { return KW::IsSomeWindowAlive(); }
127   
128   void KWBlackBox::IncNbWindowsShown() { KW::IncNbWindowsShown(); }
129   void KWBlackBox::DecNbWindowsShown() { KW::DecNbWindowsShown(); }
130   int  KWBlackBox::GetNbWindowsShown() { return KW::GetNbWindowsShown(); }
131   bool KWBlackBox::IsSomeWindowShown() { return KW::GetNbWindowsShown(); }
132   //==================================================================
133   
134 }//namespace bbtk
135
136 #endif
137