Moka Ihm Qt
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros
creation-tore.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 #include "creation-tore.qt.hh"
25 #include "window.qt.hh"
26 #include "HtmlEntities.hh"
27 #include "SpaceWidget.qt.hh"
28 
29 #include <QtGui/QLabel>
30 #include <QtGui/QHBoxLayout>
31 
32 /*******************************************************************/
33 /* CLASSE creationTore */
34 /*******************************************************************/
35 
37  GMap3d :: CControlerGMap * controler ) :
38  CreationObjet ( parent , HTML::decode("Create torus") ,
39  controler )
40 {
41  QWidget * widget = new QWidget ;
42 
43  QHBoxLayout * wid_hbl = new QHBoxLayout ( widget );
44  wid_hbl -> setSpacing(0);
45  wid_hbl -> setContentsMargins (0,0,0,0);
46 
47  FAffSub = new QLabel ( " Subdivisions: " ) ;
48  FAffPar = new QLabel ( *HTML::decode("Parallels: ") ) ;
49  FSaisiePar = new QSpinBox ;
50  FSaisiePar -> setMinimum ( 3 );
51  FSaisiePar -> setMaximum ( 100000 );
52  FSaisiePar -> setAccelerated(true);
53 
54  FAffMer = new QLabel ( *HTML::decode("Meridians: ") ) ;
55  FSaisieMer = new QSpinBox ;
56  FSaisieMer -> setMinimum ( 3 );
57  FSaisieMer -> setMaximum ( 100000 );
58  FSaisieMer -> setAccelerated(true);
59 
60  FAffRayon = new QLabel ( "Small radius/Large radius : " ) ;
61 
62  FSaisieRayon = new QSlider ( Qt::Horizontal ) ;
63  FSaisieRayon -> setTickPosition ( QSlider::TicksBothSides ) ;
64  FSaisieRayon -> setMinimum ( 0 ) ;
65  FSaisieRayon -> setMaximum ( 100 ) ;
66  FSaisieRayon -> setSingleStep ( 1 ) ;
67  FSaisieRayon -> setFixedWidth (200);
68 
69  FAffValRayon = new QLabel ;
70 
71  wid_hbl -> addWidget(FAffSub);
72  wid_hbl -> addWidget(FAffPar);
73  wid_hbl -> addWidget(FSaisiePar);
74  wid_hbl -> addSpacing(SPACE_PIX_SIZE);
75  wid_hbl -> addWidget(FAffMer);
76  wid_hbl -> addWidget(FSaisieMer);
77  wid_hbl -> addSpacing(SPACE_PIX_SIZE);
78  wid_hbl -> addWidget(FAffRayon);
79  wid_hbl -> addWidget(FSaisieRayon);
80  wid_hbl -> addWidget(FAffValRayon);
81  wid_hbl -> addSpacing(SPACE_PIX_SIZE);
82 
83  FChoix = new BoutonsCreation ( this, wid_hbl ) ;
84 
85  wid_hbl -> addStretch(1);
86  addWidget(widget);
87 
88  //*** Creation de la boite de positonnement ******
89  FPosit = new BoitePositionnement ( this , parent , OBJECT_TORUS ) ;
90 
91  update ( ) ;
92 
93  QObject::connect ( FSaisiePar , SIGNAL ( valueChanged ( int ) ) , this,
94  SLOT ( callbackParallels ( ) ) ) ;
95  QObject::connect ( FSaisieMer , SIGNAL ( valueChanged ( int ) ) , this,
96  SLOT ( callbackMeridians ( ) ) ) ;
97  QObject::connect ( FSaisieRayon , SIGNAL ( valueChanged ( int ) ) , this ,
98  SLOT ( callbackRR ( ) ) ) ;
99 
100 // QObject::connect ( FSaisieRayon , SIGNAL ( valueChanged ( int ) ) ,
101 // this , SLOT ( callbackVal ( ) ) ) ;
102 }
103 
105 {
106 }
107 
108 // Affichage
109 //----------
111 {
113 
114  FSaisieMer->setValue(FControler->getParameterCreation()
115  ->getTorusNbMeridians());
116  FSaisiePar->setValue(FControler->getParameterCreation()
117  ->getTorusNbParallels());
118  FSaisieRayon->setValue(int(FControler->getParameterCreation()
119  ->getTorusRadiusRapport()*100.0)) ;
120 }
121 
122 // SLOTS
123 //-------
124 void CreationTore :: callbackMeridians ( )
125 {
126  setMeridians ( getMeridians ( ) ) ;
127 }
128 
129 void CreationTore :: callbackParallels ( )
130 {
131  setParallels ( getParallels ( ) ) ;
132 }
133 
134 void CreationTore :: callbackRR ( )
135 {
136  setRR ( getRR ( ) ) ;
137 }
138 
139 /*
140 void CreationTore :: callbackVal ( )
141 {
142  char ValRayon [5] ;
143  sprintf (ValRayon , "%5.2f", (float (FSaisieRayon -> value ( ) )) / 100.0 ) ;
144  FAffValRayon -> setText ( ValRayon ) ;
145 
146 }
147 */
148 
149 // Accesseurs en lecture
150 //-----------------------
152 {
153  return FSaisieMer -> value ();
154 }
155 
157 {
158  return FSaisiePar -> value ();
159 }
160 
161 float CreationTore::getRR() const
162 {
163  float v = FSaisieRayon -> value () / 100.0 ;
164  return v ;
165 }
166 
167 // Accesseurs en ecriture
168 //------------------------
170 {
171  FControler -> getParameterCreation()->setTorusNbMeridians(m);
172  update( ) ;
173  repaint ( ) ;
174 }
175 
177 {
178  FControler -> getParameterCreation()->setTorusNbParallels(p);
179  update( ) ;
180  repaint ( ) ;
181 }
182 
183 void CreationTore::setRR(float v)
184 {
185  assert(v>=0); assert(v<=1);
186  FControler->getParameterCreation()->setTorusRadiusRapport(v);
187  update ( ) ;
188  repaint ( ) ;
189 }