Moka Ihm Qt
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros
options-interpolation.qt.cc
Go to the documentation of this file.
1 /*
2  * Moka : Un modeleur de 3-G-cartes.
3  * Copyright (C) 2004, Moka Team, Université de Poitiers, Laboratoire SIC
4  * http://www.sic.sp2mi.univ-poitiers.fr/
5  * Copyright (C) 2009, Guillaume Damiand, CNRS, LIRIS,
6  * guillaume.damiand@liris.cnrs.fr, http://liris.cnrs.fr/
7  *
8  * This file is part of Moka
9  *
10  * This program is free software: you can redistribute it and/or modify
11  * it under the terms of the GNU General Public License as published by
12  * the Free Software Foundation, either version 3 of the License, or
13  * (at your option) any later version.
14  *
15  * This program is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18  * GNU General Public License for more details.
19  *
20  * You should have received a copy of the GNU General Public License
21  * along with this program. If not, see <http://www.gnu.org/licenses/>.
22  */
23 
25 #include "window.qt.hh"
26 #include "HtmlEntities.hh"
27 
28 #include <QtGui/QLabel>
29 #include <QtGui/QBoxLayout>
30 
31 // Constructeur
32 //-------------
33 OptionsInterpolation :: OptionsInterpolation ( Window * parent , QTabWidget * parentTab )
34  :
35  QWidget ( parentTab ) ,
36  FParent ( parent ) ,
37  FUpdate ( false )
38 {
39  QBoxLayout * placement = new QBoxLayout ( QBoxLayout::TopToBottom, this ) ;
40 
41  FNbSubdivision = new QGroupBox("Number of subdivisions");
42  QVBoxLayout* nsd_vbl = new QVBoxLayout(FNbSubdivision);
43 
45  QWidget * WidgetSub0 = new QWidget ( this ) ;
46  QBoxLayout * sub0 = new QBoxLayout ( QBoxLayout::LeftToRight, WidgetSub0 ) ;
47 
48  FNbDiv [0] =
49  new QLabel ( *HTML::decode("Following the first dimension : ") ) ;
50  FSaisieNbDiv [0] = new QSpinBox ;
51  FSaisieNbDiv [0] -> setMinimum ( 1 );
52  FSaisieNbDiv [0] -> setMaximum ( 1000 );
53  FSaisieNbDiv [0] -> setAccelerated(true);
54 
55  sub0 -> addWidget ( FNbDiv [0], 0, Qt::AlignLeft ) ;
56  sub0 -> addWidget ( FSaisieNbDiv [0], 1, Qt::AlignLeft ) ;
57 
59  QWidget * WidgetSub1 = new QWidget ( this ) ;
60  QBoxLayout * sub1 = new QBoxLayout ( QBoxLayout::LeftToRight, WidgetSub1 ) ;
61  FNbDiv [1] =
62  new QLabel ( *HTML::decode("Following the second dimension :") ) ;
63  FSaisieNbDiv [1] = new QSpinBox ;
64  FSaisieNbDiv [1] -> setMinimum ( 1 );
65  FSaisieNbDiv [1] -> setMaximum ( 1000 );
66  FSaisieNbDiv [1] -> setAccelerated(true);
67 
68  sub1 -> addWidget ( FNbDiv [1], 0, Qt::AlignLeft ) ;
69  sub1 -> addWidget ( FSaisieNbDiv [1], 1, Qt::AlignLeft ) ;
70 
72  QWidget * WidgetSub2 = new QWidget ( this ) ;
73  QBoxLayout * sub2 = new QBoxLayout ( QBoxLayout::LeftToRight, WidgetSub2 ) ;
74  FNbDiv [2] =
75  new QLabel ( *HTML::decode("Following the third dimension : ")) ;
76  FSaisieNbDiv [2] = new QSpinBox ;
77  FSaisieNbDiv [2] -> setMinimum ( 1 );
78  FSaisieNbDiv [2] -> setMaximum ( 1000 );
79  FSaisieNbDiv [2] -> setAccelerated(true);
80 
81  sub2 -> addWidget ( FNbDiv [2], 0, Qt::AlignLeft ) ;
82  sub2 -> addWidget ( FSaisieNbDiv [2], 1, Qt::AlignLeft ) ;
83 
84  nsd_vbl -> addWidget ( WidgetSub0 ) ;
85  nsd_vbl -> addWidget ( WidgetSub1 ) ;
86  nsd_vbl -> addWidget ( WidgetSub2 ) ;
87 
88 
90  FAffInterpolation = new QGroupBox ( "Interpolation" ) ;
91  QVBoxLayout* aip_vbl = new QVBoxLayout(FAffInterpolation);
92 
93  FFusionInterpolation = new QCheckBox ( *HTML::decode("Merge created mesh with the initial objet") ) ;
94  FCoudreInterpolation = new QCheckBox ( *HTML::decode("Sew created meshes corresponding to adjacent cells") ) ;
95 
96  aip_vbl -> addWidget(FFusionInterpolation);
97  aip_vbl -> addWidget(FCoudreInterpolation);
98 
100  FAffLissage = new QGroupBox ("Smoothing") ;
101  QVBoxLayout* als_vbl = new QVBoxLayout(FAffLissage);
102 
103  QWidget * WidgetMethode = new QWidget ;
104  QBoxLayout * methode = new QBoxLayout ( QBoxLayout::LeftToRight, WidgetMethode ) ;
105 
106  FAffMethode = new QLabel ( *HTML::decode("Method: ") ) ;
107  FSaisieMethode = new QComboBox ;
108  FSaisieMethode -> addItem ( "Hermite" ) ;
109  FSaisieMethode -> addItem ( "Bezier" ) ;
110  FSaisieMethode -> addItem ( "Overhauser" ) ;
111  FSaisieMethode -> addItem ( "Spline") ;
112 
113  methode -> addWidget ( FAffMethode , 0, Qt::AlignLeft) ;
114  methode -> addWidget ( FSaisieMethode , 1, Qt::AlignLeft) ;
115 
116  FFusionLissage = new QCheckBox ( *HTML::decode("Merge created mesh with the initial objet") ) ;
117  FCoudreLissage = new QCheckBox ( *HTML::decode("Sew created meshes corresponding to adjacent cells") ) ;
118 
119  als_vbl -> addWidget ( WidgetMethode );
120  als_vbl -> addWidget ( FFusionLissage ) ;
121  als_vbl -> addWidget ( FCoudreLissage ) ;
122 
123 
126  placement -> addWidget ( FNbSubdivision );
127  placement -> addWidget ( FAffInterpolation ) ;
128  placement -> addWidget ( FAffLissage ) ;
129 
130  QObject :: connect ( FSaisieNbDiv [0] ,
131  SIGNAL ( valueChanged ( int ) ) ,
132  this ,
133  SLOT ( callbackSizeX ( ) ) ) ;
134  QObject :: connect ( FSaisieNbDiv [1] ,
135  SIGNAL ( valueChanged ( int ) ) ,
136  this ,
137  SLOT ( callbackSizeY ( ) ) ) ;
138  QObject :: connect ( FSaisieNbDiv [2] ,
139  SIGNAL ( valueChanged ( int ) ) ,
140  this ,
141  SLOT ( callbackSizeZ ( ) ) ) ;
142 
143  QObject :: connect ( FFusionInterpolation ,
144  SIGNAL ( clicked ( ) ) ,
145  this ,
146  SLOT (callbackInterpolationMerges ( ) ) ) ;
147  QObject :: connect ( FCoudreInterpolation ,
148  SIGNAL ( clicked ( ) ) ,
149  this ,
150  SLOT (callbackInterpolationSews ( ) ) ) ;
151 
152  QObject :: connect ( FFusionLissage ,
153  SIGNAL ( clicked ( ) ) ,
154  this ,
155  SLOT ( callbackSmoothMerges ( ) ) ) ;
156  QObject :: connect ( FCoudreLissage ,
157  SIGNAL ( clicked ( ) ) ,
158  this ,
159  SLOT ( callbackSmoothSews ( ) ) ) ;
160  QObject :: connect ( FSaisieMethode ,
161  SIGNAL ( activated ( int ) ) ,
162  this ,
163  SLOT ( callbackSmoothMethod ( ) ) ) ;
164 
165 }
166 
167 
168 // Destructeur
169 //------------
171 {
172 }
173 
174 
175 // Mise a jour de l'affichage
176 //---------------------------
178 {
179  FUpdate = true ;
180  CParameterOperations* p = FParent -> getControler ( ) -> getParameterOperations ( ) ;
181 
182  FSaisieNbDiv [ 0 ] -> setValue ( p -> getMeshNbSubdivisionsX ( ) ) ;
183  FSaisieNbDiv [ 1 ] -> setValue ( p -> getMeshNbSubdivisionsY ( ) ) ;
184  FSaisieNbDiv [ 2 ] -> setValue ( p -> getMeshNbSubdivisionsZ ( ) ) ;
185 
186  FFusionInterpolation -> setChecked ( p -> getInterpolationMerges ( ) ) ;
187  FCoudreInterpolation -> setChecked ( p -> getInterpolationSews ( ) ) ;
188 
189  FCoudreInterpolation -> setEnabled ( p -> isActiveInterpolationSews ( ) ) ;
190 
191  FFusionLissage -> setChecked ( p -> getSmoothMerges ( ) ) ;
192  FCoudreLissage -> setChecked ( p -> getSmoothSews ( ) ) ;
193 
194  FFusionLissage -> setEnabled ( p -> isActiveSmoothMerges ( ) ) ;
195  FCoudreLissage -> setEnabled ( p -> isActiveSmoothSews ( ) ) ;
196 
197  FSaisieMethode -> setCurrentIndex ( p -> getSmoothMethod ( ) ) ;
198 
199  FUpdate = false ;
200 }
201 
202 
204 {
205  if ( ! FUpdate )
206  setSizeX ( FSaisieNbDiv [ 0 ] -> value ( ) ) ;
207 }
208 
210 {
211  if ( ! FUpdate )
212  setSizeY ( FSaisieNbDiv [ 1 ] -> value ( ) ) ;
213 }
214 
216 {
217  if ( ! FUpdate )
218  setSizeZ ( FSaisieNbDiv [ 2 ] -> value ( ) ) ;
219 }
220 
222 {
223  if ( ! FUpdate )
224  setInterpolationMerges ( FFusionInterpolation -> isChecked ( ) ) ;
225 }
226 
228 {
229  if ( ! FUpdate )
230  setInterpolationSews ( FCoudreInterpolation -> isChecked ( ) ) ;
231 }
232 
234 {
235  if ( ! FUpdate )
236  setSmoothMethod ( FSaisieMethode -> currentIndex ( ) ) ;
237 }
238 
240 {
241  if ( ! FUpdate )
242  setSmoothMerges ( FFusionLissage -> isChecked ( ) ) ;
243 }
244 
246 {
247  if ( ! FUpdate )
248  setSmoothSews ( FCoudreLissage -> isChecked ( ) ) ;
249 }
250 
251 // Accesseur en lecture
252 //---------------------
254 {
255  return FParent -> getControler ( ) ->
256  getParameterOperations ( ) -> getSmoothMethod ( ) ;
257 }
258 
260 {
261  return FParent -> getControler ( ) ->
262  getParameterOperations ( ) -> getInterpolationMerges ( ) ;
263 }
264 
266 {
267  return FParent -> getControler ( ) ->
268  getParameterOperations ( ) -> getInterpolationSews ( ) ;
269 }
270 
272 {
273  return FParent -> getControler ( ) ->
274  getParameterOperations ( ) -> getSmoothMerges ( ) ;
275 }
276 
278 { return FParent -> getControler ( ) ->
279  getParameterOperations ( ) -> getSmoothSews ( ) ;
280 }
281 
282 // Accesseurs en ecriture
283 //-----------------------
285 {
286  assert ( s >= 0 ) ;
287  FParent -> getControler ( ) ->
288  getParameterOperations ( ) -> setMeshNbSubdivisionsX ( s ) ;
289  update ( ) ;
290 }
291 
293 {
294  assert ( s >= 0 ) ;
295  FParent -> getControler ( ) -> getParameterOperations ( )
296  ->setMeshNbSubdivisionsY ( s ) ;
297  update ( ) ;
298 }
299 
301 {
302  assert ( s >= 0 ) ;
303  FParent -> getControler ( ) ->
304  getParameterOperations ( ) -> setMeshNbSubdivisionsZ ( s ) ;
305  update ( ) ;
306 }
307 
309 {
310  FParent -> getControler ( ) -> getParameterOperations ( )
311  -> setInterpolationMerges ( b ) ;
312  update ( ) ;
313 }
314 
316 {
317  FParent -> getControler ( ) -> getParameterOperations ( )
318  -> setInterpolationSews ( b ) ;
319  update ( ) ;
320 }
321 
323 {
324  FParent -> getControler ( ) -> getParameterOperations ( )
325  -> setSmoothMethod ( m ) ;
326  update ( ) ;
327 }
328 
330 {
331  FParent -> getControler ( ) -> getParameterOperations ( )
332  -> setSmoothMerges ( b ) ;
333  update ( ) ;
334 }
335 
337 {
338  FParent -> getControler ( ) -> getParameterOperations ( )
339  -> setSmoothSews ( b ) ;
340  update ( ) ;
341 }