Moka Ihm Qt
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros
dialog-moveto.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 dialogMoveto */
26 /*********************************************/
27 #include "dialog-moveto.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("MoveTo") ,
40  controler , Qt::BottomToolBarArea),
41  FSelectedDart(NULL)
42 
43 {
44  QIcon p1(":/boutonReinit.png") ;
45  FReinit = new QPushButton(p1 , *HTML::decode("Reset")) ;
46 
47  QIcon p2(":/boutonAnnuler.png") ;
48  FClose = new QPushButton(p2 , "Close") ;
49  FClose -> setShortcut(Qt :: Key_Space) ;
50 
51  FSaisie = new champsOperations(this,NULL,false) ;
52 
53  addWidget(FReinit);
54  addWidget(new SpaceWidget(SPACE_PIX_SIZE, 1));
55  addWidget(FClose);
56 
57  update() ;
58 
59  connect(FSaisie -> getSaisieX() , SIGNAL(valueChanged(double)) ,
60  this , SLOT(callbackXPos())) ;
61 
62  connect(FSaisie -> getSaisieY() , SIGNAL(valueChanged(double)) ,
63  this , SLOT(callbackYPos())) ;
64 
65  connect(FSaisie -> getSaisieZ() , SIGNAL(valueChanged(double)) ,
66  this , SLOT(callbackZPos())) ;
67 
68  connect(FReinit , SIGNAL(clicked()) ,
69  this , SLOT(callbackReinitPos())) ;
70 
71  connect(FClose , SIGNAL(clicked()) ,
72  this , SLOT(callbackClose())) ;
73 }
74 
75 // Destructeur
76 //------------
78 {
79 }
80 // Mise a jour de l'affichage
81 //---------------------------
83 {
84  FUpdate = true ;
86 
87  if ( FSelectedDart!=getControler()->getLastSelectedDart() )
88  {
89  FSelectedDart = getControler()->getLastSelectedDart();
90  if ( FSelectedDart!=NULL )
91  FInitialPos = getControler()->getVertexPosition();
92  }
93 
94  if (FSelectedDart!=NULL)
95  {
96  FSaisie->getSaisieX()->setEnabled(true);
97  FSaisie->getSaisieY()->setEnabled(true);
98  FSaisie->getSaisieZ()->setEnabled(true);
99 
103  }
104  else
105  {
106  FSaisie->getSaisieX()->setEnabled(false);
107  FSaisie->getSaisieY()->setEnabled(false);
108  FSaisie->getSaisieZ()->setEnabled(false);
109  }
110 
111  FParent -> repaint() ;
112 
113  FUpdate = false ;
114 }
115 
116 // SLOTS
117 //------
118 void dialogMoveto :: callbackXPos()
119 {
120  if (!FUpdate)
121  setXPos(FSaisie -> getValueX()) ;
122 }
123 
124 void dialogMoveto :: callbackYPos()
125 {
126  if (!FUpdate)
127  setYPos(FSaisie -> getValueY()) ;
128 }
129 
130 void dialogMoveto :: callbackZPos()
131 {
132  if (!FUpdate)
133  setZPos(FSaisie -> getValueZ()) ;
134 }
135 
136 void dialogMoveto :: callbackReinitPos()
137 {
138  setPos(FInitialPos) ;
139 }
140 
141 // Accesseurs en lecture
142 //----------------------
143 TCoordinate dialogMoveto :: getXPos() const
144 {
145  assert(FParent != NULL) ;
146  return getControler()->getVertexPosition().getX() ;
147 }
148 
149 TCoordinate dialogMoveto :: getYPos() const
150 {
151  assert(FParent != NULL) ;
152  return getControler()->getVertexPosition().getY() ;
153 }
154 
155 TCoordinate dialogMoveto :: getZPos() const
156 {
157  assert(FParent != NULL) ;
158  return getControler()->getVertexPosition().getZ() ;
159 }
160 
162 {
163  assert(FParent != NULL) ;
164  return getControler()->getVertexPosition() ;
165 }
166 
167 // Accesseurs en ecriture
168 //-----------------------
169 void dialogMoveto :: setXPos(TCoordinate k)
170 {
171  setPos(CVertex(k , getYPos() , getZPos())) ;
172 }
173 
174 void dialogMoveto :: setYPos(TCoordinate k)
175 {
176  setPos(CVertex(getXPos() , k , getZPos())) ;
177 }
178 void dialogMoveto :: setZPos(TCoordinate k)
179 {
180  setPos(CVertex(getXPos() , getYPos() , k)) ;
181 }
182 
183 void dialogMoveto :: setPos(const CVertex & AVertex)
184 {
185  assert(FParent != NULL) ;
186  if (AVertex == getPos())
187  return;
188 
189  getControler() -> setVertexPosition(AVertex) ;
190  update() ;
191 }