]> Creatis software - bbtk.git/blob - kernel/src/bbtkKWBlackBox.cxx
*** empty log message ***
[bbtk.git] / kernel / src / bbtkKWBlackBox.cxx
1 /*=========================================================================                                                                               
2   Program:   bbtk
3   Module:    $RCSfile: bbtkKWBlackBox.cxx,v $
4   Language:  C++
5   Date:      $Date: 2009/04/08 07:56:11 $
6   Version:   $Revision: 1.9 $
7 =========================================================================*/
8
9 /* ---------------------------------------------------------------------
10
11 * Copyright (c) CREATIS-LRMN (Centre de Recherche en Imagerie Medicale)
12 * Authors : Eduardo Davila, Laurent Guigues, Jean-Pierre Roux
13 *
14 *  This software is governed by the CeCILL-B license under French law and 
15 *  abiding by the rules of distribution of free software. You can  use, 
16 *  modify and/ or redistribute the software under the terms of the CeCILL-B 
17 *  license as circulated by CEA, CNRS and INRIA at the following URL 
18 *  http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.html 
19 *  or in the file LICENSE.txt.
20 *
21 *  As a counterpart to the access to the source code and  rights to copy,
22 *  modify and redistribute granted by the license, users are provided only
23 *  with a limited warranty  and the software's author,  the holder of the
24 *  economic rights,  and the successive licensors  have only  limited
25 *  liability. 
26 *
27 *  The fact that you are presently reading this means that you have had
28 *  knowledge of the CeCILL-B license and that you accept its terms.
29 * ------------------------------------------------------------------------ */                                                                         
30 /**
31  *  \file 
32  *  \brief 
33  */
34
35 #ifdef USE_KWWIDGETS
36
37
38
39
40  
41 #include "bbtkKWBlackBox.h"
42 #include "bbtkBlackBoxOutputConnector.h"
43 #include "vtkKWBlackBoxDialog.h"
44
45
46 namespace bbtk
47 {
48
49   //=========================================================================
50   // KWBlackBox
51   //=========================================================================
52
53   //=========================================================================
54   //=========================================================================
55   //=========================================================================
56   //=========================================================================
57   BBTK_BLACK_BOX_IMPLEMENTATION(KWBlackBox,WidgetBlackBox<wxWindow>);
58   //=========================================================================
59   
60   //==================================================================    
61   /// Callback for creating a Dialog window (modal)
62   void WxBlackBox::bbCreateDialogWindow()
63   {
64     KW::GetApplication();
65     vtkKWBlackBoxDialog* win = vtkKWBlackBoxDialog::New();
66     show = (Window*) win;
67     win->bbSetBlackBox( GetThisPointer<KWBlackBox>());
68     KW::GetApplication()->AddWindow((vtkKWWindowBase*)win);
69     win->Create();
70     win->SetResizable(0,0);
71     
72     bbUserCreateWidget(win->GetFrame());
73     /*
74       KW::GetApplication()->Script
75       ("pack %s -expand yes -fill both",
76       bbGetOutputWidget()->GetWidgetName());
77     */
78     
79     KW::GetApplication()->Script("place %s -x 0 -y 0 -width %d -height %d",
80                                  bbGetOutputWidget()->GetWidgetName(),
81                                  bbGetInputWinWidth(),
82                                  bbGetInputWinHeight());
83     
84
85   }
86   //==================================================================    
87
88   //==================================================================    
89   /// Callback for creating a Frame window 
90   void WxBlackBox::bbCreateFrameWindow()
91   {
92     bbtkWarning("KW: Frame windows not supported: creating a Dialog!");
93     bbCreateDialogWindow();
94   }
95   //==================================================================    
96
97
98   //==================================================================
99   vtkKWWidget*  KWBlackBox::bbCreateWidgetOfInput(const std::string& in, 
100                                                   vtkKWFrame* parent)
101   {
102     vtkKWWidget* w = 0;
103     // If input is connected 
104     BlackBoxInputConnector* c = bbGetInputConnectorMap().find(in)->second ;
105     if ( c->IsConnected() )                     
106       {
107         // Get black box from 
108         BlackBox::Pointer from = 
109           c->GetConnection()->GetBlackBoxFrom();
110         // Cast it into a KWBlackBox
111         KWBlackBox::Pointer wfrom = boost::dynamic_pointer_cast<KWBlackBox>(from);
112         // Call bbCreateWidget
113         wfrom->bbUserCreateWidget(parent);
114         // Get the widget created
115         w = wfrom->bbGetOutputWidget();
116       }
117     return w;
118   }
119   //==================================================================
120
121
122   //==================================================================
123   //  void KWBlackBox::InitWindowManagerIfNeeded() { KW::
124   void KWBlackBox::IncNbWindowsAlive() { KW::IncNbWindowsAlive(); }
125   void KWBlackBox::DecNbWindowsAlive() { KW::DecNbWindowsAlive(); }
126   int  KWBlackBox::GetNbWindowsAlive() { return KW::GetNbWindowsAlive(); }
127   bool KWBlackBox::IsSomeWindowAlive() { return KW::IsSomeWindowAlive(); }
128   
129   void KWBlackBox::IncNbWindowsShown() { KW::IncNbWindowsShown(); }
130   void KWBlackBox::DecNbWindowsShown() { KW::DecNbWindowsShown(); }
131   int  KWBlackBox::GetNbWindowsShown() { return KW::GetNbWindowsShown(); }
132   bool KWBlackBox::IsSomeWindowShown() { return KW::GetNbWindowsShown(); }
133   //==================================================================
134   
135 }//namespace bbtk
136
137
138 #endif
139