00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024 #include "options-ponderation.qt.hh"
00025 #include "window.qt.hh"
00026 #include "HtmlEntities.hh"
00027
00028 #include <QtGui/QLabel>
00029 #include <QtGui/QVBoxLayout>
00030
00031
00032
00033 OptionsPonderation :: OptionsPonderation ( Window * parent , QTabWidget * parentTab )
00034 :
00035 QWidget ( parentTab ) ,
00036 FParent ( parent ) ,
00037 FUpdate ( false )
00038 {
00039 QBoxLayout * placement = new QBoxLayout ( QBoxLayout::TopToBottom, this ) ;
00040
00042 FAffDistance = new QGroupBox ( *HTML::decode("Distance à ..."));
00043 QVBoxLayout* afd_vbl = new QVBoxLayout(FAffDistance);
00044
00045 FSaisieDistance = new QComboBox ;
00046 FSaisieDistance -> addItem ( "Sommet" ) ;
00047 FSaisieDistance -> addItem ( "Droite" ) ;
00048 FSaisieDistance -> addItem ( "Plan" ) ;
00049
00050 QWidget * WidgetDistance2 = new QWidget ;
00051 QBoxLayout * distance2 = new QBoxLayout ( QBoxLayout::LeftToRight,
00052 WidgetDistance2 ) ;
00053
00054 FAffSommet = new QLabel ( "Sommet :" ) ;
00055
00056 for (int i = 0 ; i < 3 ; i++ ) {
00057 FSaisieCoefSommet [i] = new FloatSpinBox ( 0.5 ) ;
00058 }
00059 FRecupSommet = new QPushButton ( "Recuperer" ) ;
00060
00061 FAffCoefSommet [0] = new QLabel ( "X :" ) ;
00062 FAffCoefSommet [1] = new QLabel ( "Y :" ) ;
00063 FAffCoefSommet [2] = new QLabel ( "Z :" ) ;
00064
00065 distance2 -> addWidget ( FAffCoefSommet [0], 0, Qt::AlignLeft ) ;
00066 distance2 -> addWidget ( FSaisieCoefSommet [0], 1, Qt::AlignLeft ) ;
00067 distance2 -> addSpacing ( 10 ) ;
00068 distance2 -> addWidget ( FAffCoefSommet [1], 0, Qt::AlignLeft ) ;
00069 distance2 -> addWidget ( FSaisieCoefSommet [1], 1, Qt::AlignLeft ) ;
00070 distance2 -> addSpacing ( 10 ) ;
00071 distance2 -> addWidget ( FAffCoefSommet [2], 0, Qt::AlignLeft ) ;
00072 distance2 -> addWidget ( FSaisieCoefSommet [2], 1, Qt::AlignLeft ) ;
00073 distance2 -> addSpacing ( 10 ) ;
00074 distance2 -> addWidget ( FRecupSommet ) ;
00075
00076
00077 QWidget * WidgetDistance3 = new QWidget ;
00078 QBoxLayout * distance3 = new QBoxLayout ( QBoxLayout::LeftToRight, WidgetDistance3 ) ;
00079
00080 FAffVecteur = new QLabel ( "Vecteur :" ) ;
00081
00082 for (int i = 0 ; i < 3 ; i++ )
00083 FSaisieCoefVecteur [i] = new FloatSpinBox ( 0.5 ) ;
00084
00085 FRecupVecteur = new QPushButton ( "Recuperer" ) ;
00086
00087 FAffCoefVecteur [0] = new QLabel ( "X :" ) ;
00088 FAffCoefVecteur [1] = new QLabel ( "Y :" ) ;
00089 FAffCoefVecteur [2] = new QLabel ( "Z :" ) ;
00090
00091 distance3 -> addWidget ( FAffCoefVecteur [0], 0, Qt::AlignLeft ) ;
00092 distance3 -> addWidget ( FSaisieCoefVecteur [0], 1, Qt::AlignLeft ) ;
00093 distance3 -> addSpacing ( 10 ) ;
00094 distance3 -> addWidget ( FAffCoefVecteur [1], 0, Qt::AlignLeft ) ;
00095 distance3 -> addWidget ( FSaisieCoefVecteur [1], 1, Qt::AlignLeft ) ;
00096 distance3 -> addSpacing ( 10 ) ;
00097 distance3 -> addWidget ( FAffCoefVecteur [2], 0, Qt::AlignLeft ) ;
00098 distance3 -> addWidget ( FSaisieCoefVecteur [2], 1, Qt::AlignLeft ) ;
00099 distance3 -> addSpacing ( 10 ) ;
00100 distance3 -> addWidget ( FRecupVecteur ) ;
00101
00102
00103 afd_vbl -> addWidget(FSaisieDistance, 0, Qt::AlignCenter);
00104 afd_vbl -> addWidget(FAffSommet);
00105 afd_vbl -> addWidget(WidgetDistance2);
00106 afd_vbl -> addWidget(FAffVecteur);
00107 afd_vbl -> addWidget(WidgetDistance3);
00108
00110 QWidget * WidgetBas = new QWidget (this) ;
00111 QBoxLayout * bas = new QBoxLayout ( QBoxLayout::LeftToRight, WidgetBas ) ;
00112
00115 FAffEtalonnageDistance = new QGroupBox ( "Etalonnage des distances" );
00116 FAffEtalonnageDistance -> setCheckable(true);
00117 FAffEtalonnageDistance -> setChecked(false);
00118
00119 QVBoxLayout * aed_vbl = new QVBoxLayout ( FAffEtalonnageDistance ) ;
00120
00121 QWidget * WidgetMin1 = new QWidget ;
00122 QHBoxLayout * min1 = new QHBoxLayout ( WidgetMin1) ;
00123 FAffMinDistance = new QLabel ( "Minimum :" ) ;
00124 FSaisieMinDistance = new FloatSpinBox ( 0.5 ) ;
00125
00126 min1 -> addWidget ( FAffMinDistance, 0, Qt::AlignRight ) ;
00127 min1 -> addWidget ( FSaisieMinDistance, 0, Qt::AlignLeft ) ;
00128
00129 QWidget * WidgetMax1 = new QWidget ;
00130 QHBoxLayout * max1 = new QHBoxLayout ( WidgetMax1 ) ;
00131 FAffMaxDistance = new QLabel ( "Maximum :" ) ;
00132 FSaisieMaxDistance = new FloatSpinBox ( 0.5 ) ;
00133
00134 max1 -> addWidget ( FAffMaxDistance, 0, Qt::AlignRight ) ;
00135 max1 -> addWidget ( FSaisieMaxDistance, 0, Qt::AlignLeft ) ;
00136
00137 aed_vbl -> addWidget(WidgetMin1);
00138 aed_vbl -> addWidget(WidgetMax1);
00139
00142 QWidget * WidgetCentre = new QWidget (this) ;
00143 QBoxLayout * centre = new QBoxLayout ( QBoxLayout::LeftToRight, WidgetCentre ) ;
00144
00145 FSaisieFonction = new QComboBox ;
00146 FSaisieFonction -> addItem ( *HTML::decode("linéaire") ) ;
00147 FSaisieFonction -> addItem ( "quadratique" ) ;
00148 FSaisieFonction -> addItem ( "exponentielle" ) ;
00149 FSaisieFonction -> addItem ( "logarithmique" ) ;
00150 FSaisieFonction -> addItem ( "sinusoidale" ) ;
00151 FSaisieFonction -> addItem ( "cosinusoidale" ) ;
00152
00153 centre -> addWidget( new QLabel ( *HTML::decode("Fonction appliquée : ") ), 0 , Qt::AlignLeft );
00154 centre -> addWidget( FSaisieFonction , 1 , Qt::AlignLeft ) ;
00155
00158 FAffEtalonnageResultat =
00159 new QGroupBox ( *HTML::decode("Etalonnage des résultats") );
00160 FAffEtalonnageResultat -> setCheckable(true);
00161 FAffEtalonnageResultat -> setChecked(false);
00162
00163 QVBoxLayout * aer_vbl = new QVBoxLayout ( FAffEtalonnageResultat ) ;
00164
00165 QWidget * WidgetMin2 = new QWidget ;
00166 QHBoxLayout * min2 = new QHBoxLayout ( WidgetMin2) ;
00167 FAffMinResultat = new QLabel ( "Minimum :" ) ;
00168 FSaisieMinResultat = new FloatSpinBox ( 0.5 ) ;
00169
00170 min2 -> addWidget ( FAffMinResultat, 0, Qt::AlignRight ) ;
00171 min2 -> addWidget ( FSaisieMinResultat, 0, Qt::AlignLeft ) ;
00172
00173 QWidget * WidgetMax2 = new QWidget ;
00174 QHBoxLayout * max2 = new QHBoxLayout ( WidgetMax2 ) ;
00175 FAffMaxResultat = new QLabel ( "Maximum :" ) ;
00176 FSaisieMaxResultat = new FloatSpinBox ( 0.5 ) ;
00177
00178 max2 -> addWidget ( FAffMaxResultat, 0, Qt::AlignRight ) ;
00179 max2 -> addWidget ( FSaisieMaxResultat, 0, Qt::AlignLeft ) ;
00180
00181 aer_vbl -> addWidget(WidgetMin2);
00182 aer_vbl -> addWidget(WidgetMax2);
00183
00184 bas -> addWidget ( FAffEtalonnageDistance ) ;
00185 bas -> addWidget ( FAffEtalonnageResultat ) ;
00186
00187 placement -> addWidget ( FAffDistance ) ;
00188 placement -> addWidget ( WidgetCentre ) ;
00189 placement -> addWidget ( WidgetBas ) ;
00190
00191
00192
00193
00194 QObject :: connect ( FSaisieDistance ,
00195 SIGNAL ( activated ( int ) ) ,
00196 this ,
00197 SLOT ( callbackDistance ( ) ) ) ;
00198 QObject :: connect ( FSaisieFonction ,
00199 SIGNAL ( activated ( int ) ) ,
00200 this ,
00201 SLOT ( callbackFunction ( ) ) ) ;
00202 QObject :: connect ( FAffEtalonnageDistance ,
00203 SIGNAL ( clicked ( ) ) ,
00204 this ,
00205 SLOT ( callbackToggleEtalonnageDistances ( ) ) ) ;
00206 QObject :: connect ( FAffEtalonnageResultat ,
00207 SIGNAL ( clicked ( ) ) ,
00208 this ,
00209 SLOT ( callbackToggleEtalonnageResultats ( ) ) ) ;
00210 QObject :: connect ( FSaisieMinDistance ,
00211 SIGNAL ( valueChanged ( double ) ) ,
00212 this ,
00213 SLOT ( callbackMin1Changed ( ) ) ) ;
00214 QObject :: connect ( FSaisieMaxDistance ,
00215 SIGNAL ( valueChanged ( double ) ) ,
00216 this ,
00217 SLOT ( callbackMax1Changed ( ) ) ) ;
00218 QObject :: connect ( FSaisieMinResultat ,
00219 SIGNAL ( valueChanged ( double ) ) ,
00220 this ,
00221 SLOT ( callbackMin2Changed ( ) ) ) ;
00222 QObject :: connect ( FSaisieMaxResultat ,
00223 SIGNAL ( valueChanged ( double ) ) ,
00224 this ,
00225 SLOT ( callbackMax2Changed ( ) ) ) ;
00226
00227 for (int i = 0 ; i < 3 ; i ++ ) {
00228 QObject :: connect ( FSaisieCoefSommet [i] ,
00229 SIGNAL ( valueChanged ( double ) ) ,
00230 this ,
00231 SLOT ( callbackVertexChanged ( ) ) ) ;
00232
00233 QObject :: connect ( FSaisieCoefVecteur [i] ,
00234 SIGNAL ( valueChanged ( double ) ) ,
00235 this ,
00236 SLOT ( callbackVectorChanged ( ) ) ) ;
00237 }
00238
00239 QObject :: connect ( FRecupSommet ,
00240 SIGNAL ( clicked ( ) ) ,
00241 this ,
00242 SLOT ( callbackTakeCenter ( ) ) ) ;
00243 QObject :: connect ( FRecupVecteur ,
00244 SIGNAL ( clicked ( ) ) ,
00245 this ,
00246 SLOT ( callbackTakeVector ( ) ) ) ;
00247 }
00248
00249
00250
00251
00252 OptionsPonderation :: ~OptionsPonderation ( )
00253 {
00254 }
00255
00256
00257
00258 void OptionsPonderation :: update ( )
00259 {
00260 FUpdate = true ;
00261
00262 CParameterObjectPonderation * p = FParent -> getControler ( ) -> getParameterObjectPonderation ( ) ;
00263
00264 FSaisieCoefSommet [ 0 ] -> setValuef ( p -> getPonderationCenter ( ) . getX ( ) ) ;
00265 FSaisieCoefSommet [ 1 ] -> setValuef ( p -> getPonderationCenter ( ) . getY ( ) ) ;
00266 FSaisieCoefSommet [ 2 ] -> setValuef ( p -> getPonderationCenter ( ) . getZ ( ) ) ;
00267
00268 FSaisieCoefVecteur [ 0 ] -> setValuef ( p -> getPonderationVector ( ) . getX ( ) ) ;
00269 FSaisieCoefVecteur [ 1 ] -> setValuef ( p -> getPonderationVector ( ) . getY ( ) ) ;
00270 FSaisieCoefVecteur [ 2 ] -> setValuef ( p -> getPonderationVector ( ) . getZ ( ) ) ;
00271
00272
00273 FSaisieDistance -> setCurrentIndex ( p->getPonderationType ( ) ) ;
00274
00275 const char * vectorLabs [] = {"", "Vecteur directeur: ", "Vecteur normal: "};
00276
00277 for ( int i = 0 ; i < 3 ; ++i )
00278 if ( i == p -> getPonderationType ( ) )
00279 FAffVecteur -> setText ( vectorLabs [ i ] ) ;
00280
00281 for ( int i = 0 ; i < 3 ; ++i )
00282 FSaisieCoefVecteur [ i ] -> setEnabled ( p -> getPonderationType ( ) != 0 ) ;
00283
00284 FRecupVecteur -> setEnabled ( p -> getPonderationType ( ) != 0 ) ;
00285
00286
00287 FSaisieFonction -> setCurrentIndex ( p->getPonderationFunctionType ( ) ) ;
00288
00289
00290 FSaisieMinDistance -> setValuef ( p -> getPonderationStretchInMin ( ) ) ;
00291 FSaisieMaxDistance -> setValuef ( p -> getPonderationStretchInMax ( ) ) ;
00292 FSaisieMinResultat -> setValuef ( p -> getPonderationStretchOutMin ( ) ) ;
00293 FSaisieMaxResultat -> setValuef ( p -> getPonderationStretchOutMax ( ) ) ;
00294
00295
00296 FAffEtalonnageDistance -> setChecked ( p -> getPonderationStretchIn ( ) ) ;
00297 FAffEtalonnageResultat -> setChecked ( p -> getPonderationStretchOut ( ) ) ;
00298
00299 FUpdate = false ;
00300 }
00301
00302
00303
00304
00305
00306 void OptionsPonderation :: callbackDistance ( )
00307 {
00308 if ( ! FUpdate )
00309 setDistanceType ( ( TDistanceType ) FSaisieDistance -> currentIndex ( ) ) ;
00310 }
00311
00312 void OptionsPonderation :: callbackFunction ( )
00313 {
00314 if ( ! FUpdate )
00315 setFunctionType((TFunctionType) FSaisieFonction -> currentIndex ( ) ) ;
00316 update ( ) ;
00317 }
00318
00319 void OptionsPonderation :: callbackTakeCenter ( )
00320 {
00321 CVertex center;
00322 if ( FParent -> getControler ( ) -> takeCenter ( center ) )
00323 setCenter ( center ) ;
00324 }
00325
00326 void OptionsPonderation :: callbackTakeVector ( )
00327 {
00328 CVertex vector;
00329 if ( FParent -> getControler ( ) -> takeVector ( vector ) )
00330 setVector ( vector ) ;
00331 }
00332
00333 void OptionsPonderation :: callbackToggleEtalonnageDistances ( )
00334 {
00335 if ( ! FUpdate )
00336 setEtalonnageDistances ( FAffEtalonnageDistance -> isChecked ( ) ) ;
00337 }
00338
00339 void OptionsPonderation :: callbackToggleEtalonnageResultats ( )
00340 {
00341 if ( ! FUpdate )
00342 setEtalonnageResultats ( FAffEtalonnageResultat -> isChecked ( ) ) ;
00343 }
00344
00345 void OptionsPonderation :: callbackVertexChanged ( )
00346 {
00347 if ( ! FUpdate )
00348 setCenter ( CVertex ( FSaisieCoefSommet [ 0 ] -> valuef ( ) ,
00349 FSaisieCoefSommet [ 1 ] -> valuef ( ) ,
00350 FSaisieCoefSommet [ 2 ] -> valuef ( ) ) ) ;
00351 }
00352
00353 void OptionsPonderation :: callbackVectorChanged ( )
00354 {
00355 if ( ! FUpdate )
00356 setVector ( CVertex ( FSaisieCoefVecteur [ 0 ] -> valuef ( ) ,
00357 FSaisieCoefVecteur [ 1 ] -> valuef ( ) ,
00358 FSaisieCoefVecteur [ 2 ] -> valuef ( ) ) ) ;
00359 }
00360
00361 void OptionsPonderation :: callbackMin1Changed ( )
00362 {
00363 if ( ! FUpdate )
00364 setMin1 ( FSaisieMinDistance -> valuef ( ) ) ;
00365 }
00366
00367 void OptionsPonderation :: callbackMax1Changed ( )
00368 {
00369 if ( ! FUpdate )
00370 setMax1 ( FSaisieMaxDistance -> valuef ( ) ) ;
00371 }
00372
00373 void OptionsPonderation :: callbackMin2Changed ( )
00374 {
00375 if ( ! FUpdate )
00376 setMin2 ( FSaisieMinResultat -> valuef ( ) ) ;
00377 }
00378
00379 void OptionsPonderation :: callbackMax2Changed ( )
00380 {
00381 if ( ! FUpdate )
00382 setMax2 ( FSaisieMaxResultat -> valuef ( ) ) ;
00383 }
00384
00385
00386
00387
00388
00389 void OptionsPonderation :: setCenter ( const CVertex & vertex)
00390 {
00391 FParent -> getControler ( ) -> getParameterObjectPonderation ( ) ->
00392 setPonderationCenter ( vertex ) ;
00393 update();
00394 }
00395
00396 void OptionsPonderation :: setVector ( const CVertex & vertex )
00397 {
00398
00399 FParent -> getControler ( ) -> getParameterObjectPonderation ( ) ->
00400 setPonderationVector ( vertex ) ;
00401 update();
00402 }
00403
00404 void OptionsPonderation :: setDistanceType ( TPonderationType type )
00405 {
00406 FParent -> getControler ( ) -> getParameterObjectPonderation ( ) ->
00407 setPonderationType ( type ) ;
00408 update();
00409 }
00410
00411 void OptionsPonderation :: setFunctionType( TFunctionType type )
00412 {
00413 FParent -> getControler ( ) -> getParameterObjectPonderation ( ) ->
00414 setPonderationFunctionType ( type ) ;
00415 update();
00416 }
00417
00418 void OptionsPonderation :: setMin1 ( TCoordinate v )
00419 {
00420 FParent -> getControler ( ) -> getParameterObjectPonderation ( ) ->
00421 setPonderationStretchInMin ( v ) ;
00422 update();
00423 }
00424
00425 void OptionsPonderation :: setMax1 ( TCoordinate v )
00426 {
00427 FParent -> getControler ( ) -> getParameterObjectPonderation ( ) ->
00428 setPonderationStretchInMax ( v ) ;
00429 update();
00430 }
00431
00432 void OptionsPonderation :: setMin2 ( TCoordinate v )
00433 {
00434 FParent -> getControler ( ) -> getParameterObjectPonderation ( ) ->
00435 setPonderationStretchOutMin ( v ) ;
00436 update ( ) ;
00437 }
00438
00439 void OptionsPonderation :: setMax2 ( TCoordinate v )
00440 {
00441 FParent -> getControler ( ) -> getParameterObjectPonderation ( ) ->
00442 setPonderationStretchOutMax ( v ) ;
00443 update();
00444 }
00445
00446 void OptionsPonderation :: setEtalonnageDistances ( bool b )
00447 {
00448 FParent -> getControler ( ) -> getParameterObjectPonderation ( ) ->
00449 setPonderationStretchIn ( b ) ;
00450 update();
00451 }
00452
00453 void OptionsPonderation :: setEtalonnageResultats ( bool b )
00454 {
00455 FParent -> getControler ( ) -> getParameterObjectPonderation ( ) ->
00456 setPonderationStretchOut ( b ) ;
00457 update();
00458 }
00459