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 "select-bar.qt.hh"
00025 #include "window.qt.hh"
00026 #include "HtmlEntities.hh"
00027
00028 #include <QtGui/QVBoxLayout>
00029 #include <QtGui/QToolTip>
00030
00031 #define NB_SELECTION_BOUTONS 16
00032
00033
00034
00035
00036 static const char * const mokaLabels [ NB_SELECTION_BOUTONS ] =
00037 {
00038 "B",
00039 "0", "1", "2", "3",
00040 "01*", "02*", "03*",
00041 "12", "13", "23",
00042 "S", "A*", "F*", "V*", "C"
00043 } ;
00044
00045 static const TOrbit mokaOrbit [ NB_SELECTION_BOUTONS ] =
00046 {
00047 ORBIT_SELF,
00048 ORBIT_0, ORBIT_1, ORBIT_2, ORBIT_3,
00049 ORBIT_01 , ORBIT_02 , ORBIT_03,
00050 ORBIT_12 , ORBIT_13 , ORBIT_23,
00051 ORBIT_123, ORBIT_023, ORBIT_013, ORBIT_012, ORBIT_0123
00052 } ;
00053
00054 static const char * const mokaTooltips [ NB_SELECTION_BOUTONS ] =
00055 {
00056 "[----: Brin]",
00057 "[0---]", "[-1--]", "[--2-]", "[---3]",
00058 "[01--: Face/Volume (ou demi-face)]",
00059 "[0-2-: Arête/Volume]",
00060 "[0--3: Arête/Face (ou demi-arête)]",
00061 "[-12-: Sommet/Volume]", "[-1-3: Sommet/Face]",
00062 "[--23: Sommet/Arête (ou demi-sommet)]",
00063 "[-123: Sommet]", "[0-23: Arête]", "[01-3: Face]",
00064 "[012-: Volume]",
00065 "[0123: Composante connexe]"
00066 } ;
00067
00068
00069
00070
00071
00072 SelectBar :: SelectBar(Window * parent)
00073 :
00074 QToolBar(*HTML::decode("Sélection") , parent),
00075 FControler(parent -> getControler()),
00076 FParent(parent)
00077 {
00078 setAllowedAreas(Qt::LeftToolBarArea | Qt::RightToolBarArea);
00079
00080
00081
00082 QWidget * total = new QWidget(this) ;
00083 QVBoxLayout * bl = new QVBoxLayout(total) ;
00084 bl -> setSpacing(0);
00085
00086
00087
00088 FGroupe = new QGroupBox(total) ;
00089 QVBoxLayout * gpl = new QVBoxLayout(FGroupe) ;
00090 IdRadioButton * rb_tab[NB_SELECTION_BOUTONS];
00091
00092 for (int i = 0 ; i < NB_SELECTION_BOUTONS ; i++)
00093 {
00094 rb_tab[i] = new IdRadioButton(i, mokaLabels[i]) ;
00095 gpl -> addWidget(rb_tab[i]);
00096
00097 connect(rb_tab[i], SIGNAL(clicked(int)),
00098 this, SLOT(callBackClic(int))) ;
00099 }
00100
00101 rb_tab[0] -> setChecked(true);
00102
00103
00104 for (int i = 0 ; i < NB_SELECTION_BOUTONS ; i++)
00105 rb_tab[i] -> setToolTip(*HTML::decode(mokaTooltips [ i ])) ;
00106
00107
00108
00109
00110
00111 QWidget * sel = new QWidget ;
00112 sel -> setToolTip(*HTML::decode("Niveau de sélection")) ;
00113
00114 QHBoxLayout * bh = new QHBoxLayout(sel) ;
00115 bh -> setSpacing(0);
00116
00117
00118 int nb_selection_lev = FControler -> getNbSelectionLevels();
00119 FNiveaux = new IdPushButton * [ nb_selection_lev ] ;
00120
00121
00122 for (int i = 0;i < nb_selection_lev;i++)
00123 {
00124 FNiveaux [ i ] = new IdPushButton(i, QString::number(i + 1)) ;
00125 bh -> addWidget(FNiveaux [ i ]) ;
00126
00127 connect(FNiveaux[i], SIGNAL(clicked(int)),
00128 this, SLOT(callbackSelectionLevel(int))) ;
00129 }
00130
00131 FNiveaux [ 0 ] -> setEnabled(false) ;
00132
00133
00134 FBlock = new QPushButton("Block");
00135 FBlock->setCheckable(true);
00136 connect(FBlock, SIGNAL(toggled(bool)), this,
00137 SLOT(callbackToggleBlock(bool)));
00138
00139
00140 bl -> addWidget(FGroupe) ;
00141 bl -> addWidget(sel) ;
00142 bl -> addWidget(FBlock) ;
00143
00144 total -> setMaximumWidth(90);
00145 addWidget(total);
00146 }
00147
00148
00149
00150
00151 SelectBar :: ~SelectBar() { }
00152
00153
00154
00155 void SelectBar::callBackClic(int ind)
00156 {
00157 FControler->setSelectionOrbit(mokaOrbit [ ind ]) ;
00158 FParent->repaint() ;
00159 }
00160
00161 static bool freezed = false ;
00162
00163 void SelectBar::callbackSelectionLevel(int id)
00164 {
00165 if ( !freezed )
00166 setSelectionLevel(id) ;
00167 }
00168
00169 void SelectBar :: setSelectionLevel(int L , bool freeze)
00170 {
00171 if (! freeze)
00172 {
00173 FControler -> setSelectionLevel(L) ;
00174 FParent -> repaint() ;
00175 }
00176
00177 freezed = true;
00178
00179 for (int i = 0 ; i < FControler -> getNbSelectionLevels() ; i++)
00180 {
00181 if (FControler -> getSelectionLevel() == i)
00182 FNiveaux [ i ] -> setEnabled(false) ;
00183 else
00184 FNiveaux [ i ] -> setEnabled(true) ;
00185 }
00186
00187 freezed = false;
00188 }
00189
00190 void SelectBar :: niveauSuivant()
00191 {
00192 for (int i = 0 ; i < FControler -> getNbSelectionLevels() ; i++)
00193 {
00194 if (! FNiveaux [ i ] -> isEnabled())
00195 {
00196 setSelectionLevel((i + 1) % FControler->getNbSelectionLevels()) ;
00197 return ;
00198 }
00199 }
00200 }
00201
00202 void SelectBar::callbackToggleBlock( bool ABlock )
00203 {
00204 FControler->toggleModelBlocked();
00205 if ( !ABlock ) FParent->repaint();
00206 }
00207
00208
00209
00210