Moka Ihm Qt
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros
dialog-translation.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 /*********************************************/
25 /* CLASSE dialogTranslation */
26 /*********************************************/
27 #include "dialog-translation.qt.hh"
28 #include "window.qt.hh"
29 #include "HtmlEntities.hh"
30 #include "SpaceWidget.qt.hh"
31 
32 #include <QtGui/QPixmap>
33 
34 // Constructeur
35 //-------------
37  GMap3d :: CControlerGMap * controler)
38  :
39  dialogOperations(parent , new QString("Translation") ,
40  controler , Qt::BottomToolBarArea)
41 
42 {
43  QIcon p1(":/boutonReinit.png") ;
44  FReinit = new QPushButton(p1 , *HTML::decode("Reset")) ;
45  FSaisieTranslate =
46  new QCheckBox(*HTML::decode("Weighted Translation")) ;
47 
48  QIcon p2(":/boutonAnnuler.png") ;
49  FClose = new QPushButton(p2 , "Close") ;
50  FClose -> setShortcut(Qt :: Key_Space) ;
51 
52  FSaisie = new champsOperations(this) ;
53 
54  addWidget(FReinit);
55  addWidget(new SpaceWidget(SPACE_PIX_SIZE, 1));
56  addWidget(FSaisieTranslate);
57  addWidget(new SpaceWidget(SPACE_PIX_SIZE, 1));
58  addWidget(FClose);
59 
60  update() ;
61 
62  connect(FSaisie -> getSaisieX() , SIGNAL(valueChanged(double)) ,
63  this , SLOT(callbackVx())) ;
64 
65  connect(FSaisie -> getSaisieY() , SIGNAL(valueChanged(double)) ,
66  this , SLOT(callbackVy())) ;
67 
68  connect(FSaisie -> getSaisieZ() , SIGNAL(valueChanged(double)) ,
69  this , SLOT(callbackVz())) ;
70 
71  connect(FSaisie -> getButtonRecuperer() , SIGNAL(clicked()) ,
72  this, SLOT(callbackTakeVector())) ;
73 
74  connect(FReinit , SIGNAL(clicked()) ,
75  this , SLOT(callbackReinitVector())) ;
76 
77  connect(FSaisieTranslate , SIGNAL(clicked()) ,
78  this , SLOT(callbackTogglePonderation())) ;
79 
80  connect(FClose , SIGNAL(clicked()) ,
81  this , SLOT(callbackClose())) ;
82 }
83 
84 // Destructeur
85 //------------
87 {
88 }
89 // Mise a jour de l'affichage
90 //---------------------------
92 {
93  FUpdate = true ;
95 
99 
100  FSaisieTranslate->setChecked(getControler()
101  -> getObjectTranslationPonderation()) ;
102 
103  FParent -> repaint() ;
104  FUpdate = false ;
105 }
106 
107 // SLOTS
108 //------
109 void dialogTranslation :: callbackVx()
110 {
111  if (!FUpdate)
112  setVx(FSaisie -> getValueX()) ;
113 }
114 
115 void dialogTranslation :: callbackVy()
116 {
117  if (!FUpdate)
118  setVy(FSaisie -> getValueY()) ;
119 }
120 
121 void dialogTranslation :: callbackVz()
122 {
123  if (!FUpdate)
124  setVz(FSaisie -> getValueZ()) ;
125 }
126 
127 void dialogTranslation :: callbackTakeVector()
128 {
129  assert(FParent != NULL);
130  CVertex vector;
131 
132  if (getControler() -> takeVector(vector))
133  {
134  setV(getV() + vector) ;
135  FParent -> repaint() ;
136  }
137 }
138 
139 void dialogTranslation :: callbackReinitVector()
140 {
141  setV(ORIGIN) ;
142 }
143 
144 void dialogTranslation :: callbackTogglePonderation()
145 {
146  getControler() -> toggleObjectTranslationPonderation() ;
147  FParent -> repaint() ;
148 }
149 
150 // Accesseurs en lecture
151 //----------------------
152 TCoordinate dialogTranslation :: getVx() const
153 {
154  assert(FParent != NULL) ;
155  return getControler() -> getObjectTranslationVector() . getX() ;
156 }
157 
158 TCoordinate dialogTranslation :: getVy() const
159 {
160  assert(FParent != NULL) ;
161  return getControler() -> getObjectTranslationVector() . getY() ;
162 }
163 
164 TCoordinate dialogTranslation :: getVz() const
165 {
166  assert(FParent != NULL) ;
167  return getControler() -> getObjectTranslationVector() . getZ() ;
168 }
169 
171 {
172  assert(FParent != NULL) ;
173  return getControler() -> getObjectTranslationVector() ;
174 }
175 
176 // Accesseurs en ecriture
177 //-----------------------
178 void dialogTranslation :: setVx(TCoordinate k)
179 {
180  setV(CVertex(k , getVy() , getVz())) ;
181 }
182 
183 void dialogTranslation :: setVy(TCoordinate k)
184 {
185  setV(CVertex(getVx() , k , getVz())) ;
186 }
187 void dialogTranslation :: setVz(TCoordinate k)
188 {
189  setV(CVertex(getVx() , getVy() , k)) ;
190 }
191 
192 void dialogTranslation :: setV(const CVertex & V)
193 {
194  assert(FParent != NULL) ;
195  if (V == getV())
196  return;
197 
198  getControler() -> setObjectTranslationVector(V) ;
199  update() ;
200 }