Moka Ihm Qt
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros
options-extrusion.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 
24 #include "options-extrusion.qt.hh"
25 #include "window.qt.hh"
26 #include "HtmlEntities.hh"
27 
28 #include <QtGui/QHBoxLayout>
29 #include <QtGui/QLabel>
30 
31 // Constructeur
32 //-------------
34  QTabWidget * parentTab )
35  :
36  QWidget ( parentTab ) ,
37  FParent ( parent ) ,
38  FUpdate ( false )
39 {
40  QBoxLayout * placement = new QBoxLayout ( QBoxLayout :: TopToBottom, this ) ;
41 
42  FCoudre = new QCheckBox ( *HTML::decode("Sew cells"
43  " adjacent extruded") , this ) ;
44 
45  // ---------------------------
46  FAffVecteur =
47  new QGroupBox ( "Extrusion following normal vector / thickening" ) ;
48  QHBoxLayout * avt_hbl = new QHBoxLayout ( FAffVecteur ) ;
49 
50 
51  FAffCoef = new QLabel ( "Coefficient:" ) ;
52  FSaisieCoef = new FloatSpinBox ( 0.1 ) ;
53 
54  avt_hbl -> addWidget (FAffCoef, 0, Qt::AlignLeft);
55  avt_hbl -> addWidget (FSaisieCoef, 1, Qt::AlignLeft);
56 
57  // ---------------------------
58  FAffRevolutionChemin = new QGroupBox(*HTML::decode("Extrusion following "
59  "path / Extrusion by revolution"));
60  QVBoxLayout* arc_vbl = new QVBoxLayout(FAffRevolutionChemin);
61 
62  QWidget * WidgetOrientation = new QWidget ( FAffRevolutionChemin ) ;
63  QHBoxLayout * Orientation = new QHBoxLayout ( WidgetOrientation ) ;
64 
65  FAffOrientation = new QLabel ( "Initial Orientation :" ) ;
66  FChoixOrientation = new QComboBox ;
67  FChoixOrientation -> addItem ( "No rotation" ) ;
68  FChoixOrientation -> addItem ( "Cells -> Path" ) ;
69  FChoixOrientation -> addItem ( "Path -> Cells" ) ;
70 
71  Orientation -> addWidget ( FAffOrientation, 0, Qt::AlignLeft ) ;
72  Orientation -> addWidget ( FChoixOrientation, 1, Qt::AlignLeft ) ;
73 
74  FOrienter =
75  new QCheckBox(*HTML::decode("Orientate extruded cells "));
76  FRedimensionner = new QCheckBox(*HTML::decode("Resize "
77  "extruded cells ")) ;
78  FPonderer = new QCheckBox(*HTML::decode("Weight radius of the "
79  " section")) ;
80 
81  arc_vbl -> addWidget (WidgetOrientation);
82  arc_vbl -> addWidget (FOrienter);
83  arc_vbl -> addWidget (FRedimensionner);
84  arc_vbl -> addWidget (FPonderer);
85 
86  //--------------------------------
87 
88  FAffChemin = new QGroupBox ( "Extrusion from path " );
89  QHBoxLayout * acm_hbl = new QHBoxLayout ( FAffChemin ) ;
90 
91  FAffPlacement = new QLabel ( "Original Position:" ) ;
92  FChoixPlacement = new QComboBox ;
93  FChoixPlacement -> addItem ( "No translation" ) ;
94  FChoixPlacement -> addItem ( "Cells -> Path" ) ;
95  FChoixPlacement -> addItem ( "Path -> Cells" ) ;
96 
97  acm_hbl -> addWidget(FAffPlacement, 0, Qt::AlignLeft);
98  acm_hbl -> addWidget(FChoixPlacement, 1, Qt::AlignLeft);
99 
100  //---------------------------------
101  FAffRevolution =
102  new QGroupBox ( *HTML::decode("Extrusion by revolution"));
103  QHBoxLayout * arv_hbl = new QHBoxLayout ( FAffRevolution ) ;
104 
105  QWidget * Widgetdiv = new QWidget ;
106  QHBoxLayout * div = new QHBoxLayout ( Widgetdiv ) ;
107 
108  FNbSubdivisions = new QLabel ( "Number of subdivisions:" , Widgetdiv ) ;
109  FSaisieNbSubdivisions = new QSpinBox ( Widgetdiv ) ;
110  FSaisieNbSubdivisions -> setMinimum ( 3 );
111  FSaisieNbSubdivisions -> setMaximum ( 1000 );
112  FSaisieNbSubdivisions -> setAccelerated(true);
113 
114  div -> addWidget ( FNbSubdivisions, 0, Qt::AlignLeft ) ;
115  div -> addWidget ( FSaisieNbSubdivisions, 1, Qt::AlignLeft ) ;
116 
117  QWidget * WidgetAngle = new QWidget ( FAffRevolution ) ;
118  QHBoxLayout * Angle = new QHBoxLayout ( WidgetAngle ) ;
119 
120  FAffAngle = new QLabel ( *HTML::decode("Angle of revolution:") ) ;
121  FSaisieAngle = new FloatSpinBox ( 5 , -360 , 360 , 2 , 5 ) ;
122  FSaisieAngle -> setWrapping ( true ) ;
123 
124  Angle -> addWidget ( FAffAngle, 0, Qt::AlignLeft ) ;
125  Angle -> addWidget ( FSaisieAngle, 1, Qt::AlignLeft ) ;
126 
127 
128  arv_hbl -> addWidget(Widgetdiv);
129  arv_hbl -> addWidget(WidgetAngle);
130 
131 
132  placement -> addWidget ( FAffVecteur ) ;
133  placement -> addWidget ( FAffRevolutionChemin ) ;
134  placement -> addWidget ( FAffChemin ) ;
135  placement -> addWidget ( FAffRevolution ) ;
136  placement -> addWidget ( FCoudre ) ;
137 
138  QObject :: connect ( FCoudre,
139  SIGNAL ( clicked ( ) ) ,
140  this ,
141  SLOT ( callbackAdjacentSews ( ) ) ) ;
142  QObject :: connect ( FOrienter ,
143  SIGNAL ( clicked ( ) ) ,
144  this ,
145  SLOT ( callbackDirectCells ( ) ) ) ;
146  QObject :: connect ( FRedimensionner ,
147  SIGNAL ( clicked ( ) ) ,
148  this ,
149  SLOT ( callbackScaleCells ( ) ) ) ;
150  QObject :: connect ( FPonderer ,
151  SIGNAL ( clicked ( ) ) ,
152  this ,
153  SLOT ( callbackPonderateSection ( ) ) ) ;
154  QObject :: connect ( FSaisieCoef ,
155  SIGNAL ( valueChanged ( double ) ) ,
156  this ,
157  SLOT ( callbackExtrusionCoef ( ) ) ) ;
158  QObject :: connect ( FSaisieAngle ,
159  SIGNAL ( valueChanged ( double ) ) ,
160  this ,
161  SLOT ( callbackRevolutionAngle ( ) ) ) ;
162 
163  QObject :: connect ( FSaisieNbSubdivisions ,
164  SIGNAL ( valueChanged ( int ) ) ,
165  this ,
166  SLOT ( callbackRevolutionNbEdges ( ) ) ) ;
167 
168  QObject :: connect ( FChoixOrientation ,
169  SIGNAL ( activated ( int ) ) ,
170  this ,
171  SLOT ( callbackInitialDirectCells ( ) ) ) ;
172  QObject :: connect ( FChoixPlacement ,
173  SIGNAL ( activated ( int ) ) ,
174  this ,
175  SLOT ( callbackInitialPositionCells ( ) ) ) ;
176 }
177 
178 
179 // Destructeur
180 //------------
182 {
183 }
184 
185 // Mise a jour de l'affichage
186 //---------------------------
188 {
189  FUpdate = true ;
190 
191  CParameterOperations * p = FParent -> getControler ( ) -> getParameterOperations ( ) ;
192 
193  FCoudre -> setChecked ( p -> getExtrusionAdjacentSews ( ) ) ;
194  FChoixPlacement -> setCurrentIndex ( p -> getExtrusionInitialPositionMode ( ) );
195  FChoixOrientation -> setCurrentIndex ( p -> getExtrusionInitialDirectionMode ( ) ) ;
196  FOrienter -> setChecked ( p -> getExtrusionDirection ( ) ) ;
197  FRedimensionner -> setChecked ( p -> getExtrusionScale ( ) ) ;
198  FPonderer -> setChecked ( p -> getExtrusionPonderateSection ( ) ) ;
199  FSaisieCoef -> setValuef ( p -> getExtrusionCoef ( ) ) ;
200  FSaisieNbSubdivisions -> setValue ( p -> getExtrusionRevolutionNbEdges ( ) ) ;
201  FSaisieAngle -> setValuef ( p -> getExtrusionRevolutionAngle ( ) ) ;
202 
203  FUpdate = false ;
204 }
205 
206 
207 // Slots
208 //------
209 
211 {
212  if ( ! FUpdate )
213  setAdjacentSews ( FCoudre -> isChecked ( ) ) ;
214 }
215 
217 {
218  if ( ! FUpdate )
219  setInitialPosition ( FChoixPlacement -> currentIndex ( ) ) ;
220 }
221 
223 {
224  if ( ! FUpdate )
225  setInitialDirection ( FChoixOrientation -> currentIndex ( ) ) ;
226 }
227 
229 {
230  if ( ! FUpdate )
231  setDirection ( FOrienter -> isChecked ( ) ) ;
232 }
233 
235 {
236  if ( ! FUpdate )
237  setScale ( FRedimensionner -> isChecked ( ) ) ;
238 }
239 
241 {
242  if ( ! FUpdate )
243  setPonderation ( FPonderer -> isChecked ( ) ) ;
244 }
245 
247 {
248  if ( ! FUpdate )
249  setExtrusionCoef ( FSaisieCoef -> valuef ( ) ) ;
250 }
251 
253 {
254  if ( ! FUpdate )
255  setRevolutionNbEdges ( FSaisieNbSubdivisions -> value ( ) ) ;
256 }
257 
259 {
260  if ( ! FUpdate )
261  setRevolutionAngle ( FSaisieAngle -> valuef ( ) ) ;
262 }
263 
264 
265 // Accesseurs en ecriture
267 {
268  FParent -> getControler ( ) -> getParameterOperations ( )
269  -> setExtrusionAdjacentSews ( b ) ;
270  update ( ) ;
271 }
272 
274 {
275  FParent -> getControler ( ) -> getParameterOperations ( )
276  -> setExtrusionInitialPositionMode ( m ) ;
277  update ( ) ;
278 }
279 
281 {
282  FParent -> getControler ( ) -> getParameterOperations ( )
283  -> setExtrusionInitialDirectionMode ( m ) ;
284  update ( ) ;
285 }
286 
288 {
289  FParent -> getControler ( ) -> getParameterOperations ( )
290  -> setExtrusionDirection ( b ) ;
291  update ( ) ;
292 }
293 
295 {
296  FParent -> getControler ( ) -> getParameterOperations ( )
297  -> setExtrusionScale ( b ) ;
298  update ( ) ;
299 }
300 
302 {
303  FParent -> getControler ( ) -> getParameterOperations ( )
304  -> setExtrusionPonderateSection ( b ) ;
305  update ( ) ;
306 }
307 
309 {
310  FParent -> getControler ( ) -> getParameterOperations ( )
311  -> setExtrusionCoef ( K ) ;
312  update ( ) ;
313 }
314 
316 {
317  assert ( n >= 3 ) ;
318 
319  FParent -> getControler ( ) -> getParameterOperations ( )
320  -> setExtrusionRevolutionNbEdges ( n ) ;
321  update ( ) ;
322 }
323 
324 void OptionsExtrusion :: setRevolutionAngle ( TCoordinate alpha )
325 {
326  while ( alpha < -360 )
327  alpha += 360 ;
328 
329  while ( alpha > +360 )
330  alpha -= 360 ;
331 
332  CParameterOperations * p = FParent -> getControler ( ) -> getParameterOperations ( ) ;
333 
334  if ( alpha == p -> getExtrusionRevolutionAngle ( ) )
335  return;
336 
337  p -> setExtrusionRevolutionAngle ( alpha ) ;
338  update ( ) ;
339 }