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