]> Creatis software - bbtk.git/blob - kernel/src/vtkKWBlackBoxDialog.cxx
Feature #1774
[bbtk.git] / kernel / src / vtkKWBlackBoxDialog.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 #ifdef USE_KWWIDGETS
29
30 #include "vtkKWBlackBoxDialog.h"
31 #include "bbtkKW.h"
32 #include "vtkObjectFactory.h"
33
34   //=========================================================================
35   // vtkKWBlackBoxWindow
36   //=========================================================================
37
38
39 /*
40   //=========================================================================
41   vtkKWBlackBoxWindow::vtkKWBlackBoxWindow()
42     : mShown(false)
43   {
44     bbtkDebugMessage("kw",9,"vtkKWBlackBoxWindow::vtkKWBlackBoxWindow()"
45                      <<std::endl);
46     bbtk::KW::IncNbWindowsAlive();
47   }
48   //=========================================================================
49
50
51
52   //=========================================================================
53   vtkKWBlackBoxWindow::~vtkKWBlackBoxWindow()
54   {
55     bbtkDebugMessage("kw",9,"vtkKWBlackBoxWindow::~vtkKWBlackBoxWindow() "
56                      <<this<<std::endl);
57     bbHide();
58     bbtk::KW::DecNbWindowsAlive();
59     if (!mBox.expired())
60       {
61         mBox.lock()->bbSetWindow(0);
62       }
63   }
64   //========================================================================= 
65
66
67   //=========================================================================
68   void vtkKWBlackBoxWindow::bbShow()
69   {
70     if (bbIsShown()) return;
71     bbtkDebugMessage("kw",9,"vtkKWBlackBoxWindow::bbShow()"<<std::endl);
72     bbtk::KW::IncNbWindowsShown();
73     mShown = true;
74   }
75   //=========================================================================
76
77   //=========================================================================
78   void vtkKWBlackBoxWindow::bbHide()
79   {
80     if (!bbIsShown()) return;
81     bbtkDebugMessage("kw",9,"vtkKWBlackBoxWindow::bbHide()"<<std::endl);
82     bbtk::KW::DecNbWindowsShown();
83     mShown = false;
84   }
85   //=========================================================================
86
87   //=========================================================================
88   void vtkKWBlackBoxWindow::bbClose()
89   {
90   }
91   //=========================================================================
92
93 */
94   //=========================================================================
95   // vtkKWBlackBoxDialog
96   //=========================================================================
97   
98   //-------------------------------------------------------------------------
99   vtkStandardNewMacro( vtkKWBlackBoxDialog );
100   vtkCxxRevisionMacro( vtkKWBlackBoxDialog, "$Revision: 1.4 $");
101   //-------------------------------------------------------------------------
102
103   //=========================================================================
104 vtkKWBlackBoxDialog::vtkKWBlackBoxDialog() 
105   : mShown(false)
106 {
107   bbtkDebugMessage("kw",9,"vtkKWBlackBoxDialog::vtkKWBlackBoxDialog()"
108                    <<std::endl);
109   bbtk::KW::IncNbWindowsAlive();
110   this->mFrame = vtkKWFrame::New();
111 }
112 //=========================================================================
113   //=========================================================================
114   vtkKWBlackBoxDialog::~vtkKWBlackBoxDialog()
115   {
116     bbtkDebugMessage("kw",9,"~vtkKWBlackBoxDialog()"<<std::endl);
117     this->mFrame->Delete();
118     bbHide();
119     bbtk::KW::DecNbWindowsAlive();
120     if (!mBox.expired())
121       {
122         mBox.lock()->bbSetWindow(0);
123       }
124   }
125   //=========================================================================
126
127 //=========================================================================
128 void vtkKWBlackBoxDialog::CreateWidget()
129 {
130   bbtkDebugMessage("kw",5,"vtkKWBlackBoxDialog::CreateWidget() ["
131                    <<bbGetBlackBox()->bbGetFullName()<<"]"<<std::endl);
132   if (this->IsCreated())
133     {
134       vtkErrorMacro("vtkKWBlackBoxDialog already created");
135       return;
136     }
137   
138   this->Superclass::CreateWidget();
139   
140   this->SetTitle((bbGetBlackBox()->bbGetInputWinTitle()+"            - bbtk (c) CREATIS").c_str());
141
142   this->mFrame->SetParent(this);
143   this->mFrame->Create();
144   this->mFrame->SetWidth ( bbGetBlackBox()->bbGetInputWinWidth() );
145   this->mFrame->SetHeight ( bbGetBlackBox()->bbGetInputWinHeight() );
146
147   this->Script("pack %s -side top -expand true",
148                this->mFrame->GetWidgetName());
149 }
150 //=========================================================================
151
152 /*
153 //=========================================================================
154 void vtkKWBlackBoxDialog::Pack()
155 {
156   this->Script("pack %s -side top -expand true",
157                this->mFrame->GetWidgetName());
158 }
159 //=========================================================================
160 */
161  //=========================================================================
162   void vtkKWBlackBoxDialog::Cancel()
163   {
164     bbtkDebugMessage("kw",9,"vtkKWBlackBoxDialog::Cancel()"<<std::endl);
165     //    this->Delete();
166
167     //    this->Withdraw();
168     bbHide();
169     this->Done = vtkKWDialog::StatusCanceled;
170     //    std::cout << "REFS= "<<this->GetReferenceCount()<<std::endl;
171     //    std::cout << "WINS= "<<this->GetApplication()->GetNumberOfWindows ()<<std::endl;
172     //    this->Delete();
173     
174   }
175   //=========================================================================
176   
177  
178 //=========================================================================
179   void vtkKWBlackBoxDialog::bbShow()
180   { 
181     if (bbIsShown()) return;
182     bbtkDebugMessage("kw",5,"vtkKWBlackBoxDialog::bbShow() ["
183                      <<bbGetBlackBox()->bbGetFullName()<<"]"<<std::endl);
184     bbtk::KW::IncNbWindowsShown();
185     mShown = true;
186     //    vtkKWBlackBoxWindow::bbShow();
187     //SetReturnCode( kwDialog::ShowModal() ); 
188     this->Display();
189     this->Invoke();
190     //    bbClose();
191   }
192   //=========================================================================
193
194   //=========================================================================
195   void vtkKWBlackBoxDialog::bbHide()
196   {
197     bbtkDebugMessage("kw",9,"vtkKWBlackBoxDialog::bbHide()"<<std::endl);
198     // vtkKWBlackBoxWindow::bbHide();
199     bbtk::KW::DecNbWindowsShown();
200     mShown = false;
201     //    Hide();
202     this->Withdraw(); 
203   }
204   //=========================================================================
205
206   //=========================================================================
207   void vtkKWBlackBoxDialog::bbClose()
208   {
209     bbtkDebugMessage("kw",9,"vtkKWBlackBoxDialog::bbClose()"<<std::endl);
210     this->Done = vtkKWDialog::StatusCanceled;
211     // this->Withdraw();  //   this->Delete();
212   }
213   //=========================================================================
214
215
216
217 /*
218
219
220   //=========================================================================
221   // vtkKWBlackBoxFrame
222   //=========================================================================
223
224   //-------------------------------------------------------------------------
225   vtkStandardNewMacro( vtkKWBlackBoxFrame );
226   vtkCxxRevisionMacro(vtkKWBlackBoxFrame, "$Revision: 1.4 $");
227   //-------------------------------------------------------------------------
228   //=========================================================================
229   vtkKWBlackBoxFrame::vtkKWBlackBoxFrame()
230   {
231     bbtkDebugMessage("kw",9,"vtkKWBlackBoxFrame::vtkKWBlackBoxFrame()"<<std::endl);
232   }
233   //=========================================================================
234   
235   //=========================================================================
236   vtkKWBlackBoxFrame::~vtkKWBlackBoxFrame()
237   {
238   }
239   //=========================================================================
240
241   //=========================================================================
242   void vtkKWBlackBoxFrame::bbShow() 
243   { 
244     if (bbIsShown()) return;
245     bbtkDebugMessage("kw",5,"vtkKWBlackBoxFrame::bbShow("
246                      <<bbGetBlackBox()->bbGetFullName()<<")"<<std::endl);
247     vtkKWBlackBoxWindow::bbShow();
248     // vtkKWFrame::Show();
249     this->Display();
250     // This Update is ** MANDATORY ** 
251     // to synchronize kwvtkRenderWindowInteractor objects
252     // (force kw objects creation **NOW**)
253  
254     if (bbGetBlackBox()) bbGetBlackBox()->bbUserOnShow();
255   }
256   //=========================================================================
257
258   //=========================================================================
259   void vtkKWBlackBoxFrame::bbHide()
260   {
261     bbtkDebugMessage("kw",9,"vtkKWBlackBoxFrame::bbHide()"<<std::endl);
262     vtkKWBlackBoxWindow::bbHide();
263     //  vtkKWFrame::Hide();
264     this->Withdraw();
265     if (bbGetBlackBox()) bbGetBlackBox()->bbUserOnHide();
266   }
267   //=========================================================================
268
269   //=========================================================================
270   void vtkKWBlackBoxFrame::bbClose()
271   {
272     bbtkDebugMessage("kw",9,"vtkKWBlackBoxFrame::bbClose()"<<std::endl);
273     //    vtkKWFrame::Close();
274     this->Delete();
275   }
276   //=========================================================================
277   */
278 #endif