Moka Ihm Qt
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros
operation-chanfreinage.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 #include <Qt3Support/Q3Accel>
31 
32 
33 // Constructeur
34 //-------------
36  :
37  QDialog ( parent ) ,
38  FParent ( parent ) ,
39  FUpdate ( false )
40 {
41  // Modifie le titre de la boite de dialogue
42  setWindowTitle ( "chamfering" ) ;
43 
44  // Definition des raccourcis claviers
45 
46  Q3Accel * Raccourci = new Q3Accel ( this ) ;
47  Raccourci -> insertItem ( QKeySequence ( Qt :: Key_Space ) , 9 ) ;
48  Raccourci -> connectItem ( 9 , FParent ,
49  SLOT ( callbackHideAllWindow ( ) ) ) ;
50 
51 
52  QBoxLayout * placement = new QBoxLayout ( QBoxLayout::TopToBottom, this ) ;
53 
55  QWidget * WidgetHaut = new QWidget ( this ) ;
56  QBoxLayout * haut = new QBoxLayout ( QBoxLayout::LeftToRight, WidgetHaut );
57 
58  FAffSommet = new QLabel ( "Weights of vertices" , WidgetHaut ) ;
59 
60  FSaisie[0] = new FloatSpinBox ( 0.1 ) ;
61 
62  FGetSommet = new QPushButton ( "Get" , WidgetHaut ) ;
63  FSetSommet = new QPushButton ( "Set" , WidgetHaut ) ;
64  FNextSommet = new QPushButton ( ">>" , WidgetHaut ) ;
65 
66  haut -> addWidget ( FAffSommet ) ;
67  haut -> addWidget ( FSaisie[0] ) ;
68  haut -> addWidget ( FGetSommet ) ;
69  haut -> addWidget ( FSetSommet ) ;
70  haut -> addWidget ( FNextSommet ) ;
71 
73  QWidget * WidgetBas = new QWidget ( this ) ;
74  QBoxLayout * bas = new QBoxLayout ( QBoxLayout::LeftToRight, WidgetBas ) ;
75 
76  FAffArete = new QLabel ( *HTML::decode("Weights of edges") ,
77  WidgetBas ) ;
78  FSaisie[1] = new FloatSpinBox ( 0.1 ) ;
79  FGetArete = new QPushButton ( "Get" , WidgetBas ) ;
80  FSetArete = new QPushButton ( "Set" , WidgetBas) ;
81  FNextArete = new QPushButton ( " >>" , WidgetBas ) ;
82 
83  bas -> addWidget ( FAffArete ) ;
84  bas -> addWidget ( FSaisie[1] ) ;
85  bas -> addWidget ( FGetArete ) ;
86  bas -> addWidget ( FSetArete ) ;
87  bas -> addWidget ( FNextArete ) ;
88 
89  FClose = new QPushButton ( "Close" , this ) ;
90  QObject :: connect ( FClose ,
91  SIGNAL ( clicked ( ) ) ,
92  this ,
93  SLOT ( close ( ) ) ) ;
94  FClose -> setFocus ( ) ;
95  placement -> addWidget ( WidgetHaut ) ;
96  placement -> addWidget ( WidgetBas ) ;
97  placement -> addWidget ( FClose ) ;
98 
99  QObject :: connect ( FSaisie[0] ,
100  SIGNAL ( valueChanged ( double ) ) ,
101  this ,
102  SLOT ( callbackRounding0Coef ( ) ) ) ;
103 
104  QObject :: connect ( FGetSommet ,
105  SIGNAL ( clicked ( ) ) ,
106  this ,
107  SLOT ( callbackGet0 ( ) ) ) ;
108  QObject :: connect ( FSetSommet ,
109  SIGNAL ( clicked ( ) ) ,
110  this ,
111  SLOT ( callbackSet0 ( ) ) ) ;
112 
113  QObject :: connect ( FNextSommet ,
114  SIGNAL ( clicked ( ) ) ,
115  this ,
116  SLOT ( callbackNext0 ( ) ) ) ;
117 
118 
119  QObject :: connect ( FSaisie[1] ,
120  SIGNAL ( valueChanged ( double ) ) ,
121  this ,
122  SLOT ( callbackRounding1Coef ( ) ) ) ;
123 
124  QObject :: connect ( FGetArete ,
125  SIGNAL ( clicked ( ) ) ,
126  this ,
127  SLOT ( callbackGet1 ( ) ) ) ;
128  QObject :: connect ( FSetArete ,
129  SIGNAL ( clicked ( ) ) ,
130  this ,
131  SLOT ( callbackSet1 ( ) ) ) ;
132  QObject :: connect ( FNextArete ,
133  SIGNAL ( clicked ( ) ) ,
134  this ,
135  SLOT ( callbackNext1 ( ) ) ) ;
136 
137  update ( ) ;
138 
139 }
140 
141 // Destructeur
142 //------------
144 {
145 }
146 
147 // Mise a jour de l'affichage
148 //---------------------------
150 {
151  CParameterOperations * p = FParent -> getControler ( )
152  -> getParameterOperations();
153 
154  FSaisie[0] -> setValuef ( p -> getDefaultRoundingCoefForVertices() );
155  FSaisie[1] -> setValuef ( p -> getDefaultRoundingCoefForEdges () );
156 }
157 
158 
159 // SLOTS
160 //------
162 {
163  if (!FUpdate)
164  setRoundingCoef(0, FSaisie[0]->valuef());
165 }
166 
168 {
169  if (!FUpdate)
170  setRoundingCoef(1, FSaisie[1]->valuef());
171 }
172 
174 {
175  getCoef ( 0 ) ;
176 }
177 
179 {
180  getCoef ( 1 ) ;
181 }
182 
184 {
185  setCoef ( 0 ) ;
186 }
187 
189 {
190  setCoef ( 1 ) ;
191 }
192 
194 {
195  nextCoef ( 0 ) ;
196 }
197 
199 {
200  nextCoef ( 1 ) ;
201 }
202 
203 
204 // Accesseurs
205 //-----------
206 void OperationChanfreinage :: getCoef ( int ADimension )
207 {
208 #ifdef MODULE_ROUNDING
209  TCoordinate value;
210  bool same = FParent ->
211  getControler ( ) ->
212  modeRoundingGetCoefOfMarkedDarts ( ADimension , value ) ;
213 
214  if (same)
215  FSaisie [ ADimension ] -> setValuef ( value ) ;
216 
217 #endif // MODULE_ROUNDING
218 }
219 
220 void OperationChanfreinage :: setCoef ( int ADimension )
221 {
222 #ifdef MODULE_ROUNDING
223  FParent -> getControler ( )
224  ->modeRoundingSetCoefOfMarkedDarts ( ADimension,
225  FSaisie [ ADimension ] -> valuef ( ) ) ;
226 #endif // MODULE_ROUNDING
227 }
228 
229 void OperationChanfreinage :: nextCoef ( int ADimension )
230 {
231 #ifdef MODULE_ROUNDING
232  float result = FParent ->
233  getControler ( ) ->
234  modeRoundingSelectNextCoef ( ADimension ) ;
235  FSaisie [ ADimension ] -> setValuef ( result ) ;
236  FParent -> repaint ( ) ;
237 #endif // MODULE_ROUNDING
238 }
239 
240 // Accesseur en ecriture
241 //----------------------
242 
244 {
245  CParameterOperations * p = FParent ->
246  getControler ( ) -> getParameterOperations ( ) ;
247 
248  switch ( i )
249  {
250  case 0 :
251  p -> setDefaultRoundingCoefForVertices ( k ) ;
252  break ;
253 
254  case 1 :
255  p -> setDefaultRoundingCoefForEdges ( k ) ;
256  break ;
257 
258  default :
259  assert ( false ) ;
260  }
261 
262  update ( ) ;
263 }