Developer Documentation
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
QtCoordFrameDialog.cc
1 /*===========================================================================*\
2  * *
3  * OpenFlipper *
4  * Copyright (c) 2001-2015, RWTH-Aachen University *
5  * Department of Computer Graphics and Multimedia *
6  * All rights reserved. *
7  * www.openflipper.org *
8  * *
9  *---------------------------------------------------------------------------*
10  * This file is part of OpenFlipper. *
11  *---------------------------------------------------------------------------*
12  * *
13  * Redistribution and use in source and binary forms, with or without *
14  * modification, are permitted provided that the following conditions *
15  * are met: *
16  * *
17  * 1. Redistributions of source code must retain the above copyright notice, *
18  * this list of conditions and the following disclaimer. *
19  * *
20  * 2. Redistributions in binary form must reproduce the above copyright *
21  * notice, this list of conditions and the following disclaimer in the *
22  * documentation and/or other materials provided with the distribution. *
23  * *
24  * 3. Neither the name of the copyright holder nor the names of its *
25  * contributors may be used to endorse or promote products derived from *
26  * this software without specific prior written permission. *
27  * *
28  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS *
29  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED *
30  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A *
31  * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER *
32  * OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, *
33  * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, *
34  * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR *
35  * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF *
36  * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING *
37  * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS *
38  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. *
39  * *
40 \*===========================================================================*/
41 
42 /*===========================================================================*\
43  * *
44  * $Revision$ *
45  * $Author$ *
46  * $Date$ *
47  * *
48 \*===========================================================================*/
49 
50 
51 
52 //=============================================================================
53 //
54 // CLASS QtCoordFrameDialog - IMPLEMENTATION
55 //
56 //=============================================================================
57 
58 
59 //== INCLUDES =================================================================
60 
61 #include "QtCoordFrameDialog.hh"
62 #include "../Scenegraph/CoordFrameNode.hh"
63 
64 
65 //== NAMESPACES ==============================================================
66 
67 
68 namespace ACG {
69 namespace QtWidgets {
70 
71 
72 //== IMPLEMENTATION ==========================================================
73 
74 
75 QtCoordFrameDialog::
76 QtCoordFrameDialog( QWidget* _parent,
77  SceneGraph::CoordFrameNode* _node,
78  Qt::WindowFlags _fl )
79 
80  : QDialog(_parent, _fl),
81  node_(_node)
82 
83 {
84  ui_.setupUi( this );
85 
86  connect( ui_.OkButton, SIGNAL( clicked() ), this, SLOT( apply_changes() ) );
87  connect( ui_.OkButton, SIGNAL( clicked() ), this, SLOT( accept() ) );
88  connect( ui_.ApplyButton, SIGNAL( clicked() ), this, SLOT( apply_changes() ) );
89  connect( ui_.CancelButton, SIGNAL( clicked() ), this, SLOT( reject() ) );
90  connect( ui_.CancelButton, SIGNAL( clicked() ), this, SLOT( undo_changes() ) );
91  connect( ui_.x_add_button, SIGNAL( clicked() ), this, SLOT( add_x_plane() ) );
92  connect( ui_.x_mod_button, SIGNAL( clicked() ), this, SLOT( mod_x_plane() ) );
93  connect( ui_.x_del_button, SIGNAL( clicked() ), this, SLOT( del_x_plane() ) );
94  connect( ui_.y_add_button, SIGNAL( clicked() ), this, SLOT( add_y_plane() ) );
95  connect( ui_.y_mod_button, SIGNAL( clicked() ), this, SLOT( mod_y_plane() ) );
96  connect( ui_.y_del_button, SIGNAL( clicked() ), this, SLOT( del_y_plane() ) );
97  connect( ui_.z_add_button, SIGNAL( clicked() ), this, SLOT( add_z_plane() ) );
98  connect( ui_.z_mod_button, SIGNAL( clicked() ), this, SLOT( mod_z_plane() ) );
99  connect( ui_.z_del_button, SIGNAL( clicked() ), this, SLOT( del_z_plane() ) );
100 
101  update_values();
102 }
103 
104 
105 //-----------------------------------------------------------------------------
106 
107 
108 void
109 QtCoordFrameDialog::show()
110 {
111  update_values();
112  QDialog::show();
113 }
114 
115 
116 //-----------------------------------------------------------------------------
117 
118 
119 void
120 QtCoordFrameDialog::update_values()
121 {
122  x_planes_bak_ = node_->x_planes();
123  y_planes_bak_ = node_->y_planes();
124  z_planes_bak_ = node_->z_planes();
125 
126  planes2combo(x_planes_bak_, ui_.x_combobox);
127  planes2combo(y_planes_bak_, ui_.y_combobox);
128  planes2combo(z_planes_bak_, ui_.z_combobox);
129 
130 
131  QString s, title;
132 
133  title = ( QString("X-Planes: [") +
134  s.setNum(node_->bb_min()[0], 'f', 4) +
135  QString(", ") +
136  s.setNum(node_->bb_max()[0], 'f', 4) +
137  QString("]") );
138  ui_.x_groupbox->setTitle(title);
139 
140  title = ( QString("Y-Planes: [") +
141  s.setNum(node_->bb_min()[1], 'f', 4) +
142  QString(", ") +
143  s.setNum(node_->bb_max()[1], 'f', 4) +
144  QString("]") );
145  ui_.y_groupbox->setTitle(title);
146 
147  title = ( QString("Z-Planes: [") +
148  s.setNum(node_->bb_min()[2], 'f', 4) +
149  QString(", ") +
150  s.setNum(node_->bb_max()[2], 'f', 4) +
151  QString("]") );
152  ui_.z_groupbox->setTitle(title);
153 }
154 
155 
156 //-----------------------------------------------------------------------------
157 
158 
159 void
160 QtCoordFrameDialog::combo2planes(const QComboBox* _combo,
161  std::vector<float>& _planes)
162 {
163  unsigned int i(0), N(_combo->count());
164 
165  _planes.clear();
166  _planes.reserve(N);
167 
168  for (; i<N; ++i)
169  _planes.push_back(_combo->itemText(i).toFloat());
170 }
171 
172 
173 void
174 QtCoordFrameDialog::planes2combo(const std::vector<float>& _planes,
175  QComboBox* _combo)
176 {
177  std::vector<float>::const_iterator p_it, p_end;
178  QString s;
179 
180  _combo->clear();
181  for (p_it=_planes.begin(), p_end=_planes.end(); p_it!=p_end; ++p_it)
182  _combo->addItem(s.setNum(*p_it, 'f', 3));
183 }
184 
185 
186 //-----------------------------------------------------------------------------
187 
188 
189 void QtCoordFrameDialog::apply_changes()
190 {
191  std::vector<float> planes;
192 
193  combo2planes(ui_.x_combobox, planes);
194  node_->set_x_planes(planes);
195 
196  combo2planes(ui_.y_combobox, planes);
197  node_->set_y_planes(planes);
198 
199  combo2planes(ui_.z_combobox, planes);
200  node_->set_z_planes(planes);
201 
202  emit signalNodeChanged(node_);
203 }
204 
205 
206 //-----------------------------------------------------------------------------
207 
208 
209 void QtCoordFrameDialog::undo_changes()
210 {
211  node_->set_x_planes(x_planes_bak_);
212  node_->set_y_planes(y_planes_bak_);
213  node_->set_z_planes(z_planes_bak_);
214 
215  emit signalNodeChanged(node_);
216 }
217 
218 
219 //-----------------------------------------------------------------------------
220 
221 
222 void QtCoordFrameDialog::add_x_plane()
223 {
224  ui_.x_combobox->addItem(ui_.x_combobox->currentText());
225  apply_changes();
226 }
227 
228 void QtCoordFrameDialog::mod_x_plane()
229 {
230  ui_.x_combobox->setItemText(ui_.x_combobox->currentIndex(),ui_.x_combobox->currentText());
231  apply_changes();
232 }
233 
234 void QtCoordFrameDialog::del_x_plane()
235 {
236  ui_.x_combobox->removeItem(ui_.x_combobox->currentIndex());
237  apply_changes();
238 }
239 
240 
241 //-----------------------------------------------------------------------------
242 
243 
244 void QtCoordFrameDialog::add_y_plane()
245 {
246  ui_.y_combobox->addItem(ui_.y_combobox->currentText());
247  apply_changes();
248 }
249 
250 void QtCoordFrameDialog::mod_y_plane()
251 {
252  ui_.y_combobox->setItemText(ui_.y_combobox->currentIndex(),ui_.y_combobox->currentText());
253  apply_changes();
254 }
255 
256 void QtCoordFrameDialog::del_y_plane()
257 {
258  ui_.y_combobox->removeItem(ui_.y_combobox->currentIndex());
259  apply_changes();
260 }
261 
262 
263 //-----------------------------------------------------------------------------
264 
265 
266 void QtCoordFrameDialog::add_z_plane()
267 {
268  ui_.z_combobox->addItem(ui_.z_combobox->currentText());
269  apply_changes();
270 }
271 
272 void QtCoordFrameDialog::mod_z_plane()
273 {
274  ui_.z_combobox->setItemText(ui_.z_combobox->currentIndex(),ui_.z_combobox->currentText());
275  apply_changes();
276 }
277 
278 void QtCoordFrameDialog::del_z_plane()
279 {
280  ui_.z_combobox->removeItem(ui_.z_combobox->currentIndex());
281  apply_changes();
282 }
283 
284 
285 //=============================================================================
286 } // namespace QtWidgets
287 } // namespace ACG
288 //=============================================================================
Namespace providing different geometric functions concerning angles.
Definition: DBSCANT.cc:51