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