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 "dialog-rotation.qt.hh"
00025 #include "window.qt.hh"
00026 #include "HtmlEntities.hh"
00027 #include "SpaceWidget.qt.hh"
00028
00029 #include <QtGui/QPixmap>
00030 #include <QtGui/QLabel>
00031 #include <QtGui/QBoxLayout>
00032 #include <QtGui/QGridLayout>
00033
00034
00035
00036 dialogRotation :: dialogRotation(Window * parent ,
00037 GMap3d :: CControlerGMap * controler)
00038 :
00039 dialogOperations(parent , new QString("Rotation") ,
00040 controler , Qt::BottomToolBarArea)
00041 {
00042
00043
00044 QWidget * haut = new QWidget ;
00045 QHBoxLayout * bb = new QHBoxLayout(haut) ;
00046 bb -> setSpacing(0);
00047 bb -> setContentsMargins(0, 0, 0, 0);
00048
00049 FAffSaisie = new QLabel(" Centre : ") ;
00050 FAffAngle = new QLabel("Angle : ") ;
00051 FSaisieAngle = new FloatSpinBox(5 , -180.0 , 180.0 , 0 , 5.0);
00052 FSaisieAngle -> setWrapping(true) ;
00053 QIcon p3(":/boutonReinit.png") ;
00054 FReinitAngle =
00055 new QPushButton(p3, *HTML::decode("Réinitialiser angle")) ;
00056
00057
00058 FSaisie = new champsOperations(this , bb) ;
00059 bb -> addSpacing(SPACE_PIX_SIZE) ;
00060 bb -> addWidget(FAffAngle) ;
00061 bb -> addWidget(FSaisieAngle) ;
00062 bb -> addSpacing(SPACE_PIX_SIZE) ;
00063 bb -> addWidget(FReinitAngle) ;
00064 bb -> addStretch(1);
00065
00066
00067 QWidget * bas = new QWidget ;
00068 QHBoxLayout * bh = new QHBoxLayout(bas) ;
00069 bh -> setSpacing(0);
00070 bh -> setContentsMargins(0, 0, 0, 0);
00071
00072 FAffAxe = new QLabel(" Vecteur Axe : ") ;
00073 FPonderation = new QCheckBox
00074 (*HTML::decode("Rotation pondérée")) ;
00075 QIcon p2(":/boutonAnnuler.png") ;
00076 FClose = new QPushButton(p2 , "Fermer") ;
00077 FClose -> setShortcut(Qt :: Key_Space) ;
00078
00079
00080 FSaisieAxe = new champsOperations(this, bh) ;
00081 bh -> addSpacing(SPACE_PIX_SIZE) ;
00082 bh -> addWidget(FPonderation) ;
00083 bh -> addSpacing(SPACE_PIX_SIZE) ;
00084 bh -> addWidget(FClose) ;
00085 bh -> addStretch(1);
00086
00087
00088 QWidget * centre = new QWidget ;
00089 QGridLayout * gl = new QGridLayout(centre);
00090
00091 gl -> setHorizontalSpacing(0);
00092 gl -> setVerticalSpacing(2);
00093 gl -> setContentsMargins(0, 0, 0, 0);
00094 gl -> addWidget(FAffSaisie, 0, 0, Qt::AlignRight) ;
00095 gl -> addWidget(FAffAxe, 1, 0, Qt::AlignRight) ;
00096 gl -> addWidget(haut, 0, 1) ;
00097 gl -> addWidget(bas, 1, 1) ;
00098
00099 addWidget(centre);
00100
00101 update() ;
00102
00103 connect(FSaisie -> getSaisieX() , SIGNAL(valueChanged(double)) ,
00104 this , SLOT(callbackCx())) ;
00105
00106 connect(FSaisie -> getSaisieY() , SIGNAL(valueChanged(double)) ,
00107 this , SLOT(callbackCy())) ;
00108
00109 connect(FSaisie -> getSaisieZ() , SIGNAL(valueChanged(double)) ,
00110 this , SLOT(callbackCz())) ;
00111
00112 connect(FSaisie -> getButtonRecuperer() , SIGNAL(clicked()) ,
00113 this, SLOT(callbackTakeCenter())) ;
00114
00115 connect(FSaisieAngle , SIGNAL(valueChanged(double)) ,
00116 this , SLOT(callbackA())) ;
00117
00118 connect(FReinitAngle , SIGNAL(clicked()) ,
00119 this , SLOT(callbackReinitAngle())) ;
00120
00121 connect(FSaisieAxe -> getSaisieX() , SIGNAL(valueChanged(double)) ,
00122 this , SLOT(callbackVx())) ;
00123
00124 connect(FSaisieAxe -> getSaisieY() , SIGNAL(valueChanged(double)) ,
00125 this , SLOT(callbackVy())) ;
00126
00127 connect(FSaisieAxe -> getSaisieZ() , SIGNAL(valueChanged(double)) ,
00128 this , SLOT(callbackVz())) ;
00129
00130 connect(FSaisieAxe -> getButtonRecuperer() , SIGNAL(clicked()) ,
00131 this, SLOT(callbackTakeVector())) ;
00132
00133 connect(FPonderation , SIGNAL(clicked()) ,
00134 this , SLOT(callbackTogglePonderation())) ;
00135
00136 connect(FClose , SIGNAL(clicked()) ,
00137 this , SLOT(callbackClose())) ;
00138 }
00139
00140
00141
00142 dialogRotation :: ~dialogRotation()
00143 {}
00144
00145
00146 void dialogRotation :: update()
00147 {
00148 FUpdate = true ;
00149
00150 dialogOperations :: update() ;
00151
00152 assert(FParent != NULL) ;
00153
00154 FPonderation -> setChecked(getControler()
00155 -> getObjectRotationPonderation()) ;
00156
00157 CVertex V = getControler() -> getObjectRotationAxeVertex() ;
00158 FSaisie -> setValueX(V.getX()) ;
00159 FSaisie -> setValueY(V.getY()) ;
00160 FSaisie -> setValueZ(V.getZ()) ;
00161
00162 V = getControler()->getObjectRotationAxeVector();
00163
00164 FSaisieAxe -> setValueX(V.getX()) ;
00165 FSaisieAxe -> setValueY(V.getY()) ;
00166 FSaisieAxe -> setValueZ(V.getZ()) ;
00167
00168 FSaisieAngle -> setValuef(getControler() ->
00169 getObjectRotationAngle()) ;
00170
00171 FParent -> repaint() ;
00172 FUpdate = false ;
00173 }
00174
00175 void dialogRotation :: callbackCx()
00176 {
00177 if (! FUpdate)
00178 setCx(FSaisie -> getValueX()) ;
00179 }
00180
00181 void dialogRotation :: callbackCy()
00182 {
00183 if (! FUpdate)
00184 setCy(FSaisie -> getValueY()) ;
00185 }
00186
00187 void dialogRotation :: callbackCz()
00188 {
00189 if (! FUpdate)
00190 setCz(FSaisie -> getValueZ()) ;
00191 }
00192
00193 void dialogRotation :: callbackVx()
00194 {
00195 if (! FUpdate)
00196 setVx(FSaisieAxe -> getValueX()) ;
00197 }
00198
00199 void dialogRotation :: callbackVy()
00200 {
00201 if (! FUpdate)
00202 setVy(FSaisieAxe -> getValueY()) ;
00203 }
00204
00205 void dialogRotation :: callbackVz()
00206 {
00207 if (! FUpdate)
00208 setVz(FSaisieAxe -> getValueZ()) ;
00209 }
00210
00211 void dialogRotation :: callbackA()
00212 {
00213 if (! FUpdate)
00214 setA(FSaisieAngle -> valuef()) ;
00215 }
00216
00217 void dialogRotation :: callbackTakeCenter()
00218 {
00219 assert(FParent != NULL) ;
00220 CVertex center;
00221 if (getControler() -> takeCenter(center))
00222 setC(center) ;
00223 }
00224
00225 void dialogRotation :: callbackTakeVector()
00226 {
00227 assert(FParent != NULL) ;
00228 CVertex vector;
00229 if (getControler() -> takeVector(vector))
00230 setV(vector) ;
00231 }
00232
00233 void dialogRotation :: callbackReinitAngle()
00234 {
00235 if (! FUpdate)
00236 setA(0) ;
00237 }
00238
00239 void dialogRotation :: callbackTogglePonderation()
00240 {
00241 if (! FUpdate)
00242 {
00243 getControler() -> toggleObjectRotationPonderation() ;
00244 FParent -> repaint() ;
00245 }
00246 }
00247
00248
00249
00250 TCoordinate dialogRotation :: getCx() const
00251 {
00252 assert(FParent != NULL) ;
00253 return getControler() -> getObjectRotationAxeVertex() . getX() ;
00254 }
00255
00256 TCoordinate dialogRotation :: getCy() const
00257 {
00258 assert(FParent != NULL) ;
00259 return getControler() -> getObjectRotationAxeVertex() . getY() ;
00260 }
00261
00262 TCoordinate dialogRotation :: getCz() const
00263 {
00264 assert(FParent != NULL) ;
00265 return getControler() -> getObjectRotationAxeVertex() . getZ() ;
00266 }
00267
00268 TCoordinate dialogRotation :: getVx() const
00269 {
00270 assert(FParent != NULL) ;
00271 return getControler() -> getObjectRotationAxeVector() . getX() ;
00272 }
00273
00274 TCoordinate dialogRotation :: getVy() const
00275 {
00276 assert(FParent != NULL) ;
00277 return getControler() -> getObjectRotationAxeVector() . getY() ;
00278 }
00279
00280 TCoordinate dialogRotation :: getVz() const
00281 {
00282 assert(FParent != NULL) ;
00283 return getControler() -> getObjectRotationAxeVector() . getZ() ;
00284 }
00285
00286
00287
00288 void dialogRotation :: setCx(TCoordinate k)
00289 {
00290 setC(CVertex(k , getCy() , getCz())) ;
00291 }
00292
00293 void dialogRotation :: setCy(TCoordinate k)
00294 {
00295 setC(CVertex(getCx() , k , getCz())) ;
00296 }
00297
00298 void dialogRotation :: setCz(TCoordinate k)
00299 {
00300 setC(CVertex(getCz() , getCy() , k)) ;
00301 }
00302
00303 void dialogRotation :: setVx(TCoordinate k)
00304 {
00305 setV(CVertex(k , getVy() , getVz())) ;
00306 }
00307
00308 void dialogRotation :: setVy(TCoordinate k)
00309 {
00310 setV(CVertex(getVx() , k , getVz())) ;
00311 }
00312
00313 void dialogRotation :: setVz(TCoordinate k)
00314 {
00315 setV(CVertex(getVx() , getVy() , k)) ;
00316 }
00317
00318 void dialogRotation :: setC(const CVertex & C)
00319 {
00320 assert(FParent != NULL) ;
00321 if (C == getControler() -> getObjectRotationAxeVertex())
00322 return;
00323
00324 getControler() -> setObjectRotationAxeVertex(C) ;
00325 update() ;
00326 }
00327
00328 void dialogRotation :: setV(const CVertex & V)
00329 {
00330 assert(FParent != NULL) ;
00331 if (V == getControler() -> getObjectRotationAxeVector())
00332 return;
00333
00334 getControler() -> setObjectRotationAxeVector(V) ;
00335 update() ;
00336 }
00337
00338 void dialogRotation :: setA(TCoordinate A)
00339 {
00340 assert(FParent != NULL) ;
00341
00342 A = limit(A) ;
00343
00344 if (A == getControler() -> getObjectRotationAngle())
00345 return;
00346
00347 getControler() -> setObjectRotationAngle(A) ;
00348 update() ;
00349 }