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