00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047
00048
00049
00050
00051
00052
00053
00054 #include "QtCoordFrameDialog.hh"
00055 #include "../Scenegraph/CoordFrameNode.hh"
00056
00057 #include <qcombobox.h>
00058 #include <qpushbutton.h>
00059 #include <qgroupbox.h>
00060
00061
00062
00063
00064
00065 namespace ACG {
00066 namespace QtWidgets {
00067
00068
00069
00070
00071
00072 QtCoordFrameDialog::
00073 QtCoordFrameDialog( QWidget* _parent,
00074 SceneGraph::CoordFrameNode* _node,
00075 Qt::WFlags _fl )
00076
00077 : QDialog(_parent, _fl),
00078 node_(_node)
00079
00080 {
00081 ui_.setupUi( this );
00082
00083 connect( ui_.OkButton, SIGNAL( clicked() ), this, SLOT( apply_changes() ) );
00084 connect( ui_.OkButton, SIGNAL( clicked() ), this, SLOT( accept() ) );
00085 connect( ui_.ApplyButton, SIGNAL( clicked() ), this, SLOT( apply_changes() ) );
00086 connect( ui_.CancelButton, SIGNAL( clicked() ), this, SLOT( reject() ) );
00087 connect( ui_.CancelButton, SIGNAL( clicked() ), this, SLOT( undo_changes() ) );
00088 connect( ui_.x_add_button, SIGNAL( clicked() ), this, SLOT( add_x_plane() ) );
00089 connect( ui_.x_mod_button, SIGNAL( clicked() ), this, SLOT( mod_x_plane() ) );
00090 connect( ui_.x_del_button, SIGNAL( clicked() ), this, SLOT( del_x_plane() ) );
00091 connect( ui_.y_add_button, SIGNAL( clicked() ), this, SLOT( add_y_plane() ) );
00092 connect( ui_.y_mod_button, SIGNAL( clicked() ), this, SLOT( mod_y_plane() ) );
00093 connect( ui_.y_del_button, SIGNAL( clicked() ), this, SLOT( del_y_plane() ) );
00094 connect( ui_.z_add_button, SIGNAL( clicked() ), this, SLOT( add_z_plane() ) );
00095 connect( ui_.z_mod_button, SIGNAL( clicked() ), this, SLOT( mod_z_plane() ) );
00096 connect( ui_.z_del_button, SIGNAL( clicked() ), this, SLOT( del_z_plane() ) );
00097
00098 update_values();
00099 }
00100
00101
00102
00103
00104
00105 void
00106 QtCoordFrameDialog::show()
00107 {
00108 update_values();
00109 QDialog::show();
00110 }
00111
00112
00113
00114
00115
00116 void
00117 QtCoordFrameDialog::update_values()
00118 {
00119 x_planes_bak_ = node_->x_planes();
00120 y_planes_bak_ = node_->y_planes();
00121 z_planes_bak_ = node_->z_planes();
00122
00123 planes2combo(x_planes_bak_, ui_.x_combobox);
00124 planes2combo(y_planes_bak_, ui_.y_combobox);
00125 planes2combo(z_planes_bak_, ui_.z_combobox);
00126
00127
00128 QString s, title;
00129
00130 title = ( QString("X-Planes: [") +
00131 s.setNum(node_->bb_min()[0], 'f', 4) +
00132 QString(", ") +
00133 s.setNum(node_->bb_max()[0], 'f', 4) +
00134 QString("]") );
00135 ui_.x_groupbox->setTitle(title);
00136
00137 title = ( QString("Y-Planes: [") +
00138 s.setNum(node_->bb_min()[1], 'f', 4) +
00139 QString(", ") +
00140 s.setNum(node_->bb_max()[1], 'f', 4) +
00141 QString("]") );
00142 ui_.y_groupbox->setTitle(title);
00143
00144 title = ( QString("Z-Planes: [") +
00145 s.setNum(node_->bb_min()[2], 'f', 4) +
00146 QString(", ") +
00147 s.setNum(node_->bb_max()[2], 'f', 4) +
00148 QString("]") );
00149 ui_.z_groupbox->setTitle(title);
00150 }
00151
00152
00153
00154
00155
00156 void
00157 QtCoordFrameDialog::combo2planes(const QComboBox* _combo,
00158 std::vector<float>& _planes)
00159 {
00160 unsigned int i(0), N(_combo->count());
00161
00162 _planes.clear();
00163 _planes.reserve(N);
00164
00165 for (; i<N; ++i)
00166 _planes.push_back(_combo->itemText(i).toFloat());
00167 }
00168
00169
00170 void
00171 QtCoordFrameDialog::planes2combo(const std::vector<float>& _planes,
00172 QComboBox* _combo)
00173 {
00174 std::vector<float>::const_iterator p_it, p_end;
00175 QString s;
00176
00177 _combo->clear();
00178 for (p_it=_planes.begin(), p_end=_planes.end(); p_it!=p_end; ++p_it)
00179 _combo->addItem(s.setNum(*p_it, 'f', 3));
00180 }
00181
00182
00183
00184
00185
00186 void QtCoordFrameDialog::apply_changes()
00187 {
00188 std::vector<float> planes;
00189
00190 combo2planes(ui_.x_combobox, planes);
00191 node_->set_x_planes(planes);
00192
00193 combo2planes(ui_.y_combobox, planes);
00194 node_->set_y_planes(planes);
00195
00196 combo2planes(ui_.z_combobox, planes);
00197 node_->set_z_planes(planes);
00198
00199 emit signalNodeChanged(node_);
00200 }
00201
00202
00203
00204
00205
00206 void QtCoordFrameDialog::undo_changes()
00207 {
00208 node_->set_x_planes(x_planes_bak_);
00209 node_->set_y_planes(y_planes_bak_);
00210 node_->set_z_planes(z_planes_bak_);
00211
00212 emit signalNodeChanged(node_);
00213 }
00214
00215
00216
00217
00218
00219 void QtCoordFrameDialog::add_x_plane()
00220 {
00221 ui_.x_combobox->addItem(ui_.x_combobox->currentText());
00222 apply_changes();
00223 }
00224
00225 void QtCoordFrameDialog::mod_x_plane()
00226 {
00227 ui_.x_combobox->setItemText(ui_.x_combobox->currentIndex(),ui_.x_combobox->currentText());
00228 apply_changes();
00229 }
00230
00231 void QtCoordFrameDialog::del_x_plane()
00232 {
00233 ui_.x_combobox->removeItem(ui_.x_combobox->currentIndex());
00234 apply_changes();
00235 }
00236
00237
00238
00239
00240
00241 void QtCoordFrameDialog::add_y_plane()
00242 {
00243 ui_.y_combobox->addItem(ui_.y_combobox->currentText());
00244 apply_changes();
00245 }
00246
00247 void QtCoordFrameDialog::mod_y_plane()
00248 {
00249 ui_.y_combobox->setItemText(ui_.y_combobox->currentIndex(),ui_.y_combobox->currentText());
00250 apply_changes();
00251 }
00252
00253 void QtCoordFrameDialog::del_y_plane()
00254 {
00255 ui_.y_combobox->removeItem(ui_.y_combobox->currentIndex());
00256 apply_changes();
00257 }
00258
00259
00260
00261
00262
00263 void QtCoordFrameDialog::add_z_plane()
00264 {
00265 ui_.z_combobox->addItem(ui_.z_combobox->currentText());
00266 apply_changes();
00267 }
00268
00269 void QtCoordFrameDialog::mod_z_plane()
00270 {
00271 ui_.z_combobox->setItemText(ui_.z_combobox->currentIndex(),ui_.z_combobox->currentText());
00272 apply_changes();
00273 }
00274
00275 void QtCoordFrameDialog::del_z_plane()
00276 {
00277 ui_.z_combobox->removeItem(ui_.z_combobox->currentIndex());
00278 apply_changes();
00279 }
00280
00281
00282
00283 }
00284 }
00285