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 "options-extrusion.qt.hh"
00025 #include "window.qt.hh"
00026 #include "HtmlEntities.hh"
00027
00028 #include <QtGui/QHBoxLayout>
00029 #include <QtGui/QLabel>
00030
00031
00032
00033 OptionsExtrusion :: OptionsExtrusion ( Window * parent ,
00034 QTabWidget * parentTab )
00035 :
00036 QWidget ( parentTab ) ,
00037 FParent ( parent ) ,
00038 FUpdate ( false )
00039 {
00040 QBoxLayout * placement = new QBoxLayout ( QBoxLayout :: TopToBottom, this ) ;
00041
00042 FCoudre = new QCheckBox ( *HTML::decode("Coudre entre elles les cellules"
00043 " extrudées adjacentes") , this ) ;
00044
00045
00046 FAffVecteur =
00047 new QGroupBox ( "Extrusion selon vecteur normal / Epaississement" ) ;
00048 QHBoxLayout * avt_hbl = new QHBoxLayout ( FAffVecteur ) ;
00049
00050
00051 FAffCoef = new QLabel ( "Coefficient :" ) ;
00052 FSaisieCoef = new FloatSpinBox ( 0.1 ) ;
00053
00054 avt_hbl -> addWidget (FAffCoef, 0, Qt::AlignLeft);
00055 avt_hbl -> addWidget (FSaisieCoef, 1, Qt::AlignLeft);
00056
00057
00058 FAffRevolutionChemin = new QGroupBox(*HTML::decode("Extrusion selon "
00059 "chemin / Extrusion par révolution"));
00060 QVBoxLayout* arc_vbl = new QVBoxLayout(FAffRevolutionChemin);
00061
00062 QWidget * WidgetOrientation = new QWidget ( FAffRevolutionChemin ) ;
00063 QHBoxLayout * Orientation = new QHBoxLayout ( WidgetOrientation ) ;
00064
00065 FAffOrientation = new QLabel ( "Orientation initiale :" ) ;
00066 FChoixOrientation = new QComboBox ;
00067 FChoixOrientation -> addItem ( "Pas de rotation" ) ;
00068 FChoixOrientation -> addItem ( "Cellules -> Chemin" ) ;
00069 FChoixOrientation -> addItem ( "Chemin -> Cellules" ) ;
00070
00071 Orientation -> addWidget ( FAffOrientation, 0, Qt::AlignLeft ) ;
00072 Orientation -> addWidget ( FChoixOrientation, 1, Qt::AlignLeft ) ;
00073
00074 FOrienter =
00075 new QCheckBox(*HTML::decode("Orienter les cellules extrudées"));
00076 FRedimensionner = new QCheckBox(*HTML::decode("Redimensionner les "
00077 "cellules extrudées")) ;
00078 FPonderer = new QCheckBox(*HTML::decode("Pondérer le rayon de la"
00079 " section")) ;
00080
00081 arc_vbl -> addWidget (WidgetOrientation);
00082 arc_vbl -> addWidget (FOrienter);
00083 arc_vbl -> addWidget (FRedimensionner);
00084 arc_vbl -> addWidget (FPonderer);
00085
00086
00087
00088 FAffChemin = new QGroupBox ( "Extrusion selon chemin" );
00089 QHBoxLayout * acm_hbl = new QHBoxLayout ( FAffChemin ) ;
00090
00091 FAffPlacement = new QLabel ( "Placement initial :" ) ;
00092 FChoixPlacement = new QComboBox ;
00093 FChoixPlacement -> addItem ( "Pas de translation" ) ;
00094 FChoixPlacement -> addItem ( "Cellules -> Chemin" ) ;
00095 FChoixPlacement -> addItem ( "Chemin -> Cellules" ) ;
00096
00097 acm_hbl -> addWidget(FAffPlacement, 0, Qt::AlignLeft);
00098 acm_hbl -> addWidget(FChoixPlacement, 1, Qt::AlignLeft);
00099
00100
00101 FAffRevolution =
00102 new QGroupBox ( *HTML::decode("Extrusion par révolution"));
00103 QHBoxLayout * arv_hbl = new QHBoxLayout ( FAffRevolution ) ;
00104
00105 QWidget * Widgetdiv = new QWidget ;
00106 QHBoxLayout * div = new QHBoxLayout ( Widgetdiv ) ;
00107
00108 FNbSubdivisions = new QLabel ( "Nombre de subdivisions :" , Widgetdiv ) ;
00109 FSaisieNbSubdivisions = new QSpinBox ( Widgetdiv ) ;
00110 FSaisieNbSubdivisions -> setMinimum ( 3 );
00111 FSaisieNbSubdivisions -> setMaximum ( 1000 );
00112 FSaisieNbSubdivisions -> setAccelerated(true);
00113
00114 div -> addWidget ( FNbSubdivisions, 0, Qt::AlignLeft ) ;
00115 div -> addWidget ( FSaisieNbSubdivisions, 1, Qt::AlignLeft ) ;
00116
00117 QWidget * WidgetAngle = new QWidget ( FAffRevolution ) ;
00118 QHBoxLayout * Angle = new QHBoxLayout ( WidgetAngle ) ;
00119
00120 FAffAngle = new QLabel ( *HTML::decode("Angle de révolution :") ) ;
00121 FSaisieAngle = new FloatSpinBox ( 5 , -360 , 360 , 2 , 5 ) ;
00122 FSaisieAngle -> setWrapping ( true ) ;
00123
00124 Angle -> addWidget ( FAffAngle, 0, Qt::AlignLeft ) ;
00125 Angle -> addWidget ( FSaisieAngle, 1, Qt::AlignLeft ) ;
00126
00127
00128 arv_hbl -> addWidget(Widgetdiv);
00129 arv_hbl -> addWidget(WidgetAngle);
00130
00131
00132 placement -> addWidget ( FAffVecteur ) ;
00133 placement -> addWidget ( FAffRevolutionChemin ) ;
00134 placement -> addWidget ( FAffChemin ) ;
00135 placement -> addWidget ( FAffRevolution ) ;
00136 placement -> addWidget ( FCoudre ) ;
00137
00138 QObject :: connect ( FCoudre,
00139 SIGNAL ( clicked ( ) ) ,
00140 this ,
00141 SLOT ( callbackAdjacentSews ( ) ) ) ;
00142 QObject :: connect ( FOrienter ,
00143 SIGNAL ( clicked ( ) ) ,
00144 this ,
00145 SLOT ( callbackDirectCells ( ) ) ) ;
00146 QObject :: connect ( FRedimensionner ,
00147 SIGNAL ( clicked ( ) ) ,
00148 this ,
00149 SLOT ( callbackScaleCells ( ) ) ) ;
00150 QObject :: connect ( FPonderer ,
00151 SIGNAL ( clicked ( ) ) ,
00152 this ,
00153 SLOT ( callbackPonderateSection ( ) ) ) ;
00154 QObject :: connect ( FSaisieCoef ,
00155 SIGNAL ( valueChanged ( double ) ) ,
00156 this ,
00157 SLOT ( callbackExtrusionCoef ( ) ) ) ;
00158 QObject :: connect ( FSaisieAngle ,
00159 SIGNAL ( valueChanged ( double ) ) ,
00160 this ,
00161 SLOT ( callbackRevolutionAngle ( ) ) ) ;
00162
00163 QObject :: connect ( FSaisieNbSubdivisions ,
00164 SIGNAL ( valueChanged ( int ) ) ,
00165 this ,
00166 SLOT ( callbackRevolutionNbEdges ( ) ) ) ;
00167
00168 QObject :: connect ( FChoixOrientation ,
00169 SIGNAL ( activated ( int ) ) ,
00170 this ,
00171 SLOT ( callbackInitialDirectCells ( ) ) ) ;
00172 QObject :: connect ( FChoixPlacement ,
00173 SIGNAL ( activated ( int ) ) ,
00174 this ,
00175 SLOT ( callbackInitialPositionCells ( ) ) ) ;
00176 }
00177
00178
00179
00180
00181 OptionsExtrusion :: ~OptionsExtrusion ( )
00182 {
00183 }
00184
00185
00186
00187 void OptionsExtrusion :: update ( )
00188 {
00189 FUpdate = true ;
00190
00191 CParameterOperations * p = FParent -> getControler ( ) -> getParameterOperations ( ) ;
00192
00193 FCoudre -> setChecked ( p -> getExtrusionAdjacentSews ( ) ) ;
00194 FChoixPlacement -> setCurrentIndex ( p -> getExtrusionInitialPositionMode ( ) );
00195 FChoixOrientation -> setCurrentIndex ( p -> getExtrusionInitialDirectionMode ( ) ) ;
00196 FOrienter -> setChecked ( p -> getExtrusionDirection ( ) ) ;
00197 FRedimensionner -> setChecked ( p -> getExtrusionScale ( ) ) ;
00198 FPonderer -> setChecked ( p -> getExtrusionPonderateSection ( ) ) ;
00199 FSaisieCoef -> setValuef ( p -> getExtrusionCoef ( ) ) ;
00200 FSaisieNbSubdivisions -> setValue ( p -> getExtrusionRevolutionNbEdges ( ) ) ;
00201 FSaisieAngle -> setValuef ( p -> getExtrusionRevolutionAngle ( ) ) ;
00202
00203 FUpdate = false ;
00204 }
00205
00206
00207
00208
00209
00210 void OptionsExtrusion :: callbackAdjacentSews ( )
00211 {
00212 if ( ! FUpdate )
00213 setAdjacentSews ( FCoudre -> isChecked ( ) ) ;
00214 }
00215
00216 void OptionsExtrusion :: callbackInitialPositionCells ( )
00217 {
00218 if ( ! FUpdate )
00219 setInitialPosition ( FChoixPlacement -> currentIndex ( ) ) ;
00220 }
00221
00222 void OptionsExtrusion :: callbackInitialDirectCells ( )
00223 {
00224 if ( ! FUpdate )
00225 setInitialDirection ( FChoixOrientation -> currentIndex ( ) ) ;
00226 }
00227
00228 void OptionsExtrusion :: callbackDirectCells ( )
00229 {
00230 if ( ! FUpdate )
00231 setDirection ( FOrienter -> isChecked ( ) ) ;
00232 }
00233
00234 void OptionsExtrusion :: callbackScaleCells ( )
00235 {
00236 if ( ! FUpdate )
00237 setScale ( FRedimensionner -> isChecked ( ) ) ;
00238 }
00239
00240 void OptionsExtrusion :: callbackPonderateSection ( )
00241 {
00242 if ( ! FUpdate )
00243 setPonderation ( FPonderer -> isChecked ( ) ) ;
00244 }
00245
00246 void OptionsExtrusion :: callbackExtrusionCoef ( )
00247 {
00248 if ( ! FUpdate )
00249 setExtrusionCoef ( FSaisieCoef -> valuef ( ) ) ;
00250 }
00251
00252 void OptionsExtrusion :: callbackRevolutionNbEdges ( )
00253 {
00254 if ( ! FUpdate )
00255 setRevolutionNbEdges ( FSaisieNbSubdivisions -> value ( ) ) ;
00256 }
00257
00258 void OptionsExtrusion :: callbackRevolutionAngle ( )
00259 {
00260 if ( ! FUpdate )
00261 setRevolutionAngle ( FSaisieAngle -> valuef ( ) ) ;
00262 }
00263
00264
00265
00266 void OptionsExtrusion :: setAdjacentSews ( bool b )
00267 {
00268 FParent -> getControler ( ) -> getParameterOperations ( )
00269 -> setExtrusionAdjacentSews ( b ) ;
00270 update ( ) ;
00271 }
00272
00273 void OptionsExtrusion :: setInitialPosition ( int m )
00274 {
00275 FParent -> getControler ( ) -> getParameterOperations ( )
00276 -> setExtrusionInitialPositionMode ( m ) ;
00277 update ( ) ;
00278 }
00279
00280 void OptionsExtrusion :: setInitialDirection ( int m )
00281 {
00282 FParent -> getControler ( ) -> getParameterOperations ( )
00283 -> setExtrusionInitialDirectionMode ( m ) ;
00284 update ( ) ;
00285 }
00286
00287 void OptionsExtrusion :: setDirection ( bool b )
00288 {
00289 FParent -> getControler ( ) -> getParameterOperations ( )
00290 -> setExtrusionDirection ( b ) ;
00291 update ( ) ;
00292 }
00293
00294 void OptionsExtrusion :: setScale ( bool b )
00295 {
00296 FParent -> getControler ( ) -> getParameterOperations ( )
00297 -> setExtrusionScale ( b ) ;
00298 update ( ) ;
00299 }
00300
00301 void OptionsExtrusion :: setPonderation ( bool b )
00302 {
00303 FParent -> getControler ( ) -> getParameterOperations ( )
00304 -> setExtrusionPonderateSection ( b ) ;
00305 update ( ) ;
00306 }
00307
00308 void OptionsExtrusion :: setExtrusionCoef ( TCoordinate K )
00309 {
00310 FParent -> getControler ( ) -> getParameterOperations ( )
00311 -> setExtrusionCoef ( K ) ;
00312 update ( ) ;
00313 }
00314
00315 void OptionsExtrusion :: setRevolutionNbEdges ( int n )
00316 {
00317 assert ( n >= 3 ) ;
00318
00319 FParent -> getControler ( ) -> getParameterOperations ( )
00320 -> setExtrusionRevolutionNbEdges ( n ) ;
00321 update ( ) ;
00322 }
00323
00324 void OptionsExtrusion :: setRevolutionAngle ( TCoordinate alpha )
00325 {
00326 while ( alpha < -360 )
00327 alpha += 360 ;
00328
00329 while ( alpha > +360 )
00330 alpha -= 360 ;
00331
00332 CParameterOperations * p = FParent -> getControler ( ) -> getParameterOperations ( ) ;
00333
00334 if ( alpha == p -> getExtrusionRevolutionAngle ( ) )
00335 return;
00336
00337 p -> setExtrusionRevolutionAngle ( alpha ) ;
00338 update ( ) ;
00339 }