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 "creation-options.qt.hh"
00025 #include "window.qt.hh"
00026
00027 #include <QtGui/QPixmap>
00028 #include <QtGui/QLabel>
00029 #include <QtGui/QBoxLayout>
00030 #include <Qt3Support/Q3Accel>
00031
00032 static const char * const coordLabels [ 3 ] =
00033 {
00034 " X" , " Y" , " Z"
00035 } ;
00036
00037
00038
00039
00040 BoitePositionnement :: BoitePositionnement(CreationObjet * lien ,
00041 Window * parent , int objet) :
00042 QDialog(parent),
00043 FLien(lien),
00044 FModifie(true),
00045 FNumObject(objet)
00046 {
00047
00048 QBoxLayout * total = new QBoxLayout(QBoxLayout :: TopToBottom, this) ;
00049
00050
00051 QWidget * widCentre = new QWidget(this) ;
00052 QBoxLayout * boxCentre = new QBoxLayout(QBoxLayout :: LeftToRight,
00053 widCentre);
00054
00055 FTitreCentre = new QLabel(" Centre : " , widCentre) ;
00056 boxCentre -> addWidget(FTitreCentre) ;
00057
00058 for (int i = 0 ; i < 3 ; i++)
00059 {
00060 FAffCentre [ i ] = new QLabel(coordLabels [ i ] , widCentre) ;
00061 boxCentre -> addWidget(FAffCentre [ i ] , Qt::AlignHCenter) ;
00062 FSaisieCentre [ i ] = new FloatSpinBox(0.5, -1000 , 1000);
00063 boxCentre -> addWidget(FSaisieCentre [ i ] , Qt::AlignHCenter) ;
00064 }
00065 total -> addWidget(widCentre) ;
00066
00067
00068 QWidget * widFacteur = new QWidget(this) ;
00069 QBoxLayout * boxFacteur = new QBoxLayout(QBoxLayout :: LeftToRight,
00070 widFacteur);
00071 FTitreFacteur = new QLabel(" Facteur d'agrandissement : " , widFacteur) ;
00072 boxFacteur -> addWidget(FTitreFacteur) ;
00073
00074 FSaisieFacteur = new FloatSpinBox(0.2, -1000 , 1000);
00075 boxFacteur -> addWidget(FSaisieFacteur , Qt::AlignHCenter) ;
00076
00077 total -> addWidget(widFacteur) ;
00078
00079
00080 QWidget * widProportions = new QWidget(this) ;
00081 QBoxLayout * boxProportions = new QBoxLayout(QBoxLayout :: LeftToRight,
00082 widProportions) ;
00083
00084 FTitreProportions = new QLabel(" Proportions : " , widProportions) ;
00085 boxProportions -> addWidget(FTitreProportions) ;
00086
00087 for (int i = 0 ; i < 3 ; i++)
00088 {
00089 FAffProportions [ i ] = new QLabel(coordLabels [ i ] ,
00090 widProportions) ;
00091 boxProportions -> addWidget(FAffProportions [ i ] , Qt::AlignHCenter) ;
00092
00093 FSaisieProportions [ i ] = new FloatSpinBox(0.2, -1000 , 1000);
00094 boxProportions -> addWidget(FSaisieProportions [ i ], 0,
00095 Qt::AlignHCenter) ;
00096 }
00097
00098 total -> addWidget(widProportions) ;
00099
00100
00101 QWidget * widDimensions = new QWidget(this) ;
00102 QBoxLayout * boxDimensions =
00103 new QBoxLayout(QBoxLayout :: LeftToRight, widDimensions);
00104
00105 FTitreDimensions = new QLabel(" Dimensions : " , widDimensions) ;
00106 boxDimensions -> addWidget(FTitreDimensions) ;
00107
00108 for (int i = 0 ; i < 3 ; i++)
00109 {
00110 FAffDimensions [ i ] = new QLabel(coordLabels [ i ] , widDimensions) ;
00111 boxDimensions->addWidget(FAffDimensions [ i ] , 0, Qt::AlignHCenter) ;
00112
00113 FSaisieDimensions [ i ] = new FloatSpinBox(0.5, -1000 , 1000);
00114 boxDimensions->addWidget(FSaisieDimensions[i], 0, Qt::AlignHCenter);
00115 }
00116
00117 total -> addWidget(widDimensions) ;
00118
00119
00120 QWidget * widRotations = new QWidget(this) ;
00121 QBoxLayout * boxRotations = new QBoxLayout(QBoxLayout :: LeftToRight,
00122 widRotations) ;
00123
00124 FTitreRotations = new QLabel(" Rotations : " , widRotations) ;
00125 boxRotations -> addWidget(FTitreRotations) ;
00126
00127 for (int i = 0 ; i < 3 ; i++)
00128 {
00129 FAffRotations [ i ] = new QLabel(coordLabels [ i ] , widRotations) ;
00130 boxRotations -> addWidget(FAffRotations [ i ] , Qt::AlignHCenter) ;
00131
00132 FSaisieRotations [ i ] = new FloatSpinBox(5 , -180.0 , 180.0 , 0 , 0.0);
00133 FSaisieRotations [ i ] -> setWrapping ( true ) ;
00134 boxRotations -> addWidget(FSaisieRotations [ i ] , Qt::AlignHCenter) ;
00135 }
00136 total -> addWidget(widRotations) ;
00137
00138
00139 QWidget * widPoleNord = new QWidget(this) ;
00140 QBoxLayout * boxPoleNord = new QBoxLayout(QBoxLayout :: LeftToRight,
00141 widPoleNord) ;
00142
00143 FTitrePoleNord = new QLabel(" PoleNord : " , widPoleNord) ;
00144 boxPoleNord -> addWidget(FTitrePoleNord) ;
00145
00146 for (int i = 0 ; i < 3 ; i++)
00147 {
00148 FAffPoleNord [ i ] = new QLabel(coordLabels [ i ] , widPoleNord) ;
00149 boxPoleNord -> addWidget(FAffPoleNord [ i ] , Qt::AlignHCenter) ;
00150
00151 FSaisiePoleNord [ i ] = new FloatSpinBox(0.5, -1000 , 1000);
00152 boxPoleNord -> addWidget(FSaisiePoleNord [ i ] , Qt::AlignHCenter) ;
00153 }
00154
00155 total -> addWidget(widPoleNord) ;
00156
00157
00158 QWidget * widEquateur = new QWidget(this) ;
00159 QBoxLayout * boxEquateur = new QBoxLayout(QBoxLayout :: LeftToRight,
00160 widEquateur);
00161
00162 FTitreEquateur = new QLabel(" Equateur : " , widEquateur) ;
00163 boxEquateur -> addWidget(FTitreEquateur) ;
00164
00165 for (int i = 0 ; i < 3 ; i++)
00166 {
00167 FAffEquateur [ i ] = new QLabel(coordLabels [ i ] , widEquateur) ;
00168 boxEquateur -> addWidget(FAffEquateur [ i ] , Qt::AlignHCenter) ;
00169
00170 FSaisieEquateur [ i ] = new FloatSpinBox(0.5, -1000 , 1000);
00171 boxEquateur -> addWidget(FSaisieEquateur [ i ] , Qt::AlignHCenter) ;
00172 }
00173
00174 total -> addWidget(widEquateur) ;
00175
00176
00177 QWidget * widMasquer = new QWidget(this) ;
00178 QBoxLayout * boxMasquer = new QBoxLayout(QBoxLayout :: LeftToRight,
00179 widMasquer) ;
00180
00181 QIcon p1(":/masquer.png");
00182 FMasquer = new QPushButton(p1 , "Masquer" , widMasquer) ;
00183 FMasquer -> setFixedSize(110 , 30) ;
00184 FMasquer -> setShortcut(Qt::CTRL + Qt::Key_P) ;
00185 FMasquer -> setFocus() ;
00186
00187 boxMasquer -> addWidget(FMasquer , Qt::AlignHCenter) ;
00188 total -> addWidget(widMasquer) ;
00189
00190
00191 for (int i = 0 ; i < 3 ; i++)
00192 {
00193 QObject :: connect(FSaisieCentre [ i ] ,
00194 SIGNAL(valueChanged(double)),
00195 this , SLOT(callbackCenter())) ;
00196 QObject :: connect(FSaisieProportions [ i ] ,
00197 SIGNAL(valueChanged(double)) , this ,
00198 SLOT(callbackProportions())) ;
00199 QObject :: connect(FSaisieDimensions [ i ] ,
00200 SIGNAL(valueChanged(double)) , this ,
00201 SLOT(callbackDimensions())) ;
00202 QObject :: connect(FSaisieRotations [ i ] ,
00203 SIGNAL(valueChanged(double)) , this ,
00204 SLOT(callbackRotations())) ;
00205 QObject :: connect(FSaisiePoleNord [ i ] ,
00206 SIGNAL(valueChanged(double)) , this ,
00207 SLOT(callbackFirstVertex())) ;
00208 QObject :: connect(FSaisieEquateur [ i ] ,
00209 SIGNAL(valueChanged(double)) , this ,
00210 SLOT(callbackNormalVector())) ;
00211 }
00212 QObject :: connect(FSaisieFacteur ,
00213 SIGNAL(valueChanged(double)) , this ,
00214 SLOT(callbackScale())) ;
00215
00216 QObject :: connect(FMasquer ,
00217 SIGNAL(clicked()) , this ,
00218 SLOT(hide())) ;
00219
00220 Q3Accel * Raccourci = new Q3Accel(this) ;
00221 Raccourci -> insertItem(QKeySequence(Qt::Key_Space) , 2) ;
00222 Raccourci -> connectItem(2 , FLien , SLOT(cancel())) ;
00223 }
00224
00225
00226
00227
00228 BoitePositionnement :: ~BoitePositionnement() { }
00229
00230
00231
00232 void BoitePositionnement :: update()
00233 {
00234 FModifie = false ;
00235 CParameterObjectPosition* p =
00236 FLien -> getControler() ->
00237 getParameterObjectPosition(FNumObject) ;
00238
00239 FSaisieFacteur -> setValuef(p -> getScale()) ;
00240
00241 FSaisieProportions[0]->setValuef(p->getProportionX());
00242 FSaisieProportions[1]->setValuef(p->getProportionY());
00243 FSaisieProportions[2]->setValuef(p->getProportionZ());
00244
00245 FSaisieDimensions[0]->setValuef(p->getDimensionX());
00246 FSaisieDimensions[1]->setValuef(p->getDimensionY());
00247 FSaisieDimensions[2]->setValuef(p->getDimensionZ());
00248
00249 FSaisieRotations[0]->setValue((int)p->getRotationX());
00250 FSaisieRotations[1]->setValue((int)p->getRotationY());
00251 FSaisieRotations[2]->setValue((int)p->getRotationZ());
00252
00253 FSaisieCentre[0]->setValuef(p->getCenterX());
00254 FSaisieCentre[1]->setValuef(p->getCenterY());
00255 FSaisieCentre[2]->setValuef(p->getCenterZ());
00256
00257 FSaisiePoleNord[0]->setValuef(p->getFirstVertexX());
00258 FSaisiePoleNord[1]->setValuef(p->getFirstVertexY());
00259 FSaisiePoleNord[2]->setValuef(p->getFirstVertexZ());
00260
00261 FSaisieEquateur[0]->setValuef(p->getNormalVectorX());
00262 FSaisieEquateur[1]->setValuef(p->getNormalVectorY());
00263 FSaisieEquateur[2]->setValuef(p->getNormalVectorZ());
00264
00265 FModifie = true ;
00266 }
00267
00268
00269
00270 void BoitePositionnement :: callbackScale()
00271 {
00272 if (FModifie)
00273 setScale(getScale()) ;
00274 }
00275
00276 void BoitePositionnement :: callbackProportions()
00277 {
00278 if (FModifie)
00279 setProportions(getProportions()) ;
00280 }
00281
00282 void BoitePositionnement :: callbackDimensions()
00283 {
00284 if (FModifie)
00285 setDimensions(getDimensions()) ;
00286 }
00287
00288 void BoitePositionnement :: callbackCenter()
00289 {
00290 if (FModifie)
00291 setCenter(getCenter()) ;
00292 }
00293
00294 void BoitePositionnement :: callbackRotations()
00295 {
00296 if (FModifie)
00297 setRotations(getRotations()) ;
00298 }
00299
00300 void BoitePositionnement :: callbackFirstVertex()
00301 {
00302 if (FModifie)
00303 setFirstVertex(getFirstVertex()) ;
00304 }
00305
00306 void BoitePositionnement :: callbackNormalVector()
00307 {
00308 if (FModifie)
00309 setNormalVector(getNormalVector()) ;
00310 }
00311
00312
00313
00314
00315 TCoordinate BoitePositionnement :: getScale() const
00316 {
00317 return FSaisieFacteur -> valuef() ;
00318 }
00319
00320 CVertex BoitePositionnement :: getProportions() const
00321 {
00322 return CVertex(FSaisieProportions[0]-> valuef(),
00323 FSaisieProportions[1]-> valuef(),
00324 FSaisieProportions[2]-> valuef());
00325 }
00326
00327 CVertex BoitePositionnement :: getDimensions() const
00328 {
00329 return CVertex(FSaisieDimensions[0]-> valuef(),
00330 FSaisieDimensions[1]-> valuef(),
00331 FSaisieDimensions[2]-> valuef());
00332 }
00333
00334 CVertex BoitePositionnement :: getCenter() const
00335 {
00336 return CVertex(FSaisieCentre[0]-> valuef(),
00337 FSaisieCentre[1]-> valuef(),
00338 FSaisieCentre[2]-> valuef());
00339 }
00340
00341 CVertex BoitePositionnement :: getRotations() const
00342 {
00343 return CVertex(FSaisieRotations[0]-> value(),
00344 FSaisieRotations[1]-> value(),
00345 FSaisieRotations[2]-> value());
00346 }
00347
00348 CVertex BoitePositionnement :: getFirstVertex() const
00349 {
00350 return CVertex(FSaisiePoleNord[0]-> valuef(),
00351 FSaisiePoleNord[1]-> valuef(),
00352 FSaisiePoleNord[2]-> valuef());
00353 }
00354
00355 CVertex BoitePositionnement :: getNormalVector() const
00356 {
00357 return CVertex(FSaisieEquateur[0]-> valuef(),
00358 FSaisieEquateur[1]-> valuef(),
00359 FSaisieEquateur[2]-> valuef());
00360 }
00361
00362 void BoitePositionnement :: activateYProportions(bool b)
00363 {
00364 FSaisieProportions[1]->setEnabled(b);
00365 FSaisieDimensions [1]->setEnabled(b);
00366 }
00367
00368 void BoitePositionnement :: activateZProportions(bool b)
00369 {
00370 FSaisieProportions[2]->setEnabled(b);
00371 FSaisieDimensions [2]->setEnabled(b);
00372 }
00373
00374
00375
00376
00377 void BoitePositionnement :: setScale(TCoordinate s)
00378 {
00379 FLien->getControler()->getParameterObjectPosition(FNumObject)->setScale(s);
00380 update() ;
00381 FLien->repaint();
00382 }
00383
00384 void BoitePositionnement :: setProportions(const CVertex & p)
00385 {
00386 FLien->getControler()->
00387 getParameterObjectPosition(FNumObject)->setProportions(p);
00388 update();
00389 FLien -> repaint() ;
00390 }
00391
00392 void BoitePositionnement :: setDimensions(const CVertex & d)
00393 {
00394 FLien->getControler()->
00395 getParameterObjectPosition(FNumObject)->setDimensions(d);
00396 update();
00397 FLien -> repaint() ;
00398 }
00399
00400 void BoitePositionnement :: setRotations(const CVertex & alpha)
00401 {
00402 FLien->getControler()->
00403 getParameterObjectPosition(FNumObject)->setRotations(alpha);
00404 update();
00405 FLien -> repaint() ;
00406 }
00407
00408 void BoitePositionnement :: setCenter(const CVertex & C)
00409 {
00410 FLien->getControler()
00411 ->getParameterObjectPosition(FNumObject)->setCenter(C);
00412 update();
00413 FLien -> repaint() ;
00414 }
00415
00416 void BoitePositionnement :: setFirstVertex(const CVertex & S)
00417 {
00418 FLien->getControler()->
00419 getParameterObjectPosition(FNumObject)->setFirstVertex(S);
00420 update();
00421 FLien -> repaint() ;
00422 }
00423
00424 void BoitePositionnement :: setNormalVector(const CVertex & N)
00425 {
00426 FLien->getControler()->
00427 getParameterObjectPosition(FNumObject)->setNormalVector(N);
00428 update();
00429 FLien -> repaint() ;
00430 }
00431
00432 void BoitePositionnement :: show()
00433 {
00434 QDialog :: show() ;
00435 FMasquer -> setFocus() ;
00436 }