]> Creatis software - bbtk.git/blob - packages/qt/src/bbqtLayoutSplit.cxx
defaultBalues InitializeProcessing FinalizeProcessing
[bbtk.git] / packages / qt / src / bbqtLayoutSplit.cxx
1 /*=========================================================================                                                                               
2   Program:   bbtk
3   Module:    $RCSfile: bbqtLayoutSplit.cxx,v $
4   Language:  C++
5   Date:      $Date: 2009/05/14 16:21:19 $
6   Version:   $Revision: 1.2 $
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 /**
32  *  \file
33  *  \brief
34  */
35
36
37 #ifdef USE_QT
38
39 #include "bbqtLayoutSplit.h"
40 #include "bbqtPackage.h"
41 #include "bbtkUtilities.h"
42
43 #include <QSplitter>
44
45 namespace bbqt
46 {
47   BBTK_ADD_BLACK_BOX_TO_PACKAGE(qt,LayoutSplit);
48   BBTK_BLACK_BOX_IMPLEMENTATION(LayoutSplit,bbtk::QtBlackBox);
49
50         
51   void LayoutSplit::bbUserSetDefaultValues()
52   {
53     bbSetInputOrientation("VERTICAL");
54     //    bbSetInputProportion(50);
55
56     bbSetInputWidget1(NULL);
57     bbSetInputWidget2(NULL);
58     bbSetInputWidget3(NULL);
59     bbSetInputWidget4(NULL);
60     bbSetInputWidget5(NULL);
61     bbSetInputWidget6(NULL);
62     bbSetInputWidget7(NULL);
63     bbSetInputWidget8(NULL);
64     bbSetInputWidget9(NULL);
65
66     bbSetInputWeight1(1);
67     bbSetInputWeight2(1);
68     bbSetInputWeight3(1);
69     bbSetInputWeight4(1);
70     bbSetInputWeight5(1);
71     bbSetInputWeight6(1);
72     bbSetInputWeight7(1);
73     bbSetInputWeight8(1);
74     bbSetInputWeight9(1);
75   }
76
77         
78         void LayoutSplit::bbUserInitializeProcessing()
79         {
80         }
81         
82         void LayoutSplit::bbUserFinalizeProcessing()
83         {
84         }
85         
86         
87         
88         
89   void LayoutSplit::Process()
90   {
91   }
92
93   void LayoutSplit::CreateWidget(QWidget* parent)
94   {
95     Qt::Orientation ori;
96     if (bbtk::Utilities::loosematch(bbGetInputOrientation(),
97                                     "0|H|HORIZONTAL")==true)  
98       { ori = Qt::Horizontal; }
99     if (bbtk::Utilities::loosematch(bbGetInputOrientation(),
100                                     "1|V|VERTICAL")==true)      
101       { ori = Qt::Vertical; }
102     
103     QSplitter* w = new QSplitter(ori,parent);
104     QWidget* c;
105     int i=0;
106     if ((c=bbCreateWidgetOfInput("Widget1",w))!=0) 
107       {
108         w->addWidget(c);
109         w->setStretchFactor(i,bbGetInputWeight1());
110         i++;
111       }
112     if ((c=bbCreateWidgetOfInput("Widget2",w))!=0) 
113       {
114         w->addWidget(c);
115         w->setStretchFactor(i,bbGetInputWeight2());
116         i++;
117       }
118     if ((c=bbCreateWidgetOfInput("Widget3",w))!=0) 
119       {
120         w->addWidget(c);
121         w->setStretchFactor(i,bbGetInputWeight3());
122         i++;
123       }
124     if ((c=bbCreateWidgetOfInput("Widget4",w))!=0) 
125       {
126         w->addWidget(c);
127         w->setStretchFactor(i,bbGetInputWeight4());
128         i++;
129       }
130     if ((c=bbCreateWidgetOfInput("Widget5",w))!=0) 
131       {
132         w->addWidget(c);
133         w->setStretchFactor(i,bbGetInputWeight5());
134         i++;
135       }
136     if ((c=bbCreateWidgetOfInput("Widget6",w))!=0) 
137       {
138         w->addWidget(c);
139         w->setStretchFactor(i,bbGetInputWeight6());
140         i++;
141       }
142     if ((c=bbCreateWidgetOfInput("Widget7",w))!=0) 
143       {
144         w->addWidget(c);
145         w->setStretchFactor(i,bbGetInputWeight7());
146         i++;
147       }
148     if ((c=bbCreateWidgetOfInput("Widget8",w))!=0) 
149       {
150         w->addWidget(c);
151         w->setStretchFactor(i,bbGetInputWeight8());
152         i++;
153       }
154     if ((c=bbCreateWidgetOfInput("Widget9",w))!=0) 
155       {
156         w->addWidget(c);
157         w->setStretchFactor(i,bbGetInputWeight9());
158         i++;
159       }
160   
161     bbSetOutputWidget( w );
162   }
163
164
165   // This callback is necessary to get actual processing of the view 
166   // when window is shown
167   void  LayoutSplit::OnShowWidget()
168   {
169     bbUserOnShowWidget("Widget1");
170     bbUserOnShowWidget("Widget2");
171     bbUserOnShowWidget("Widget3");
172     bbUserOnShowWidget("Widget4");
173     bbUserOnShowWidget("Widget5");
174     bbUserOnShowWidget("Widget6");
175     bbUserOnShowWidget("Widget7");
176     bbUserOnShowWidget("Widget8");
177     bbUserOnShowWidget("Widget9");
178   }
179
180
181
182 }//namespace bbqt
183
184 #endif // USE_QT
185