Developer Documentation
QtClippingDialog.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
45
46//=============================================================================
47//
48// CLASS QtClippingDialog - IMPLEMENTATION
49//
50//=============================================================================
51
52//== INCLUDES =================================================================
53
54
55#include "QtClippingDialog.hh"
56
57#include "../Scenegraph/ClippingNode.hh"
58
59
60//== NAMESPACES ===============================================================
61
62
63namespace ACG {
64namespace QtWidgets {
65
66
67//== IMPLEMENTATION ==========================================================
68
69
71QtClippingDialog( QWidget * _parent,
73 : QDialog( _parent ),
74 node_( _node )
75{
76 ui_.setupUi( this );
77
78 connect( ui_.setButton, SIGNAL( clicked() ),
79 this, SLOT( set_plane() ) );
80 connect( ui_.sweepRangeSlider, SIGNAL( valueChanged(int) ),
81 this, SLOT( sweep_plane(int) ) );
82
83 update_values();
84 connect( ui_.okButton, SIGNAL( clicked() ),
85 this, SLOT( accept() ) );
86
87 layout()->setSizeConstraint( QLayout::SetFixedSize );
88
89}
90
91
92//-----------------------------------------------------------------------------
93
94
95void
96QtClippingDialog::show()
97{
98 update_values();
99 QDialog::show();
100}
101
102
103//-----------------------------------------------------------------------------
104
105
106void
107QtClippingDialog::update_values()
108{
109 QString s;
110
111 const Vec3f& position = node_->position();
112 ui_.positionXLineEdit->setText(s.setNum(position[0], 'f', 3));
113 ui_.positionYLineEdit->setText(s.setNum(position[1], 'f', 3));
114 ui_.positionZLineEdit->setText(s.setNum(position[2], 'f', 3));
115
116 const Vec3f& normal = node_->normal();
117 ui_.normalXLineEdit->setText(s.setNum(normal[0], 'f', 3));
118 ui_.normalYLineEdit->setText(s.setNum(normal[1], 'f', 3));
119 ui_.normalZLineEdit->setText(s.setNum(normal[2], 'f', 3));
120
121 float slice_width = node_->slice_width();
122 ui_.sliceWidthLineEdit->setText(s.setNum(slice_width, 'f', 3));
123}
124
125
126//-----------------------------------------------------------------------------
127
128
129void
130QtClippingDialog::set_plane()
131{
132 // set plane
133 Vec3f position( ui_.positionXLineEdit->text().toFloat(),
134 ui_.positionYLineEdit->text().toFloat(),
135 ui_.positionZLineEdit->text().toFloat() );
136
137 Vec3f normal( ui_.normalXLineEdit->text().toFloat(),
138 ui_.normalYLineEdit->text().toFloat(),
139 ui_.normalZLineEdit->text().toFloat() );
140
141 float slice_width = ui_.sliceWidthLineEdit->text().toFloat();
142
143 node_->set_plane(position, normal, slice_width);
144
145
146 // reset slider
147 ui_.sweepRangeSlider->setValue(0);
148
149
150 emit signalNodeChanged(node_);
151}
152
153
154//-----------------------------------------------------------------------------
155
156
157void
158QtClippingDialog::set_sweep_range(float _radius)
159{
160 QString s;
161 ui_.sweepRangeLineEdit->setText(s.setNum(_radius, 'f', 3));
162}
163
164
165//-----------------------------------------------------------------------------
166
167
168void
169QtClippingDialog::sweep_plane(int _i)
170{
171 float range = ui_.sweepRangeLineEdit->text().toFloat();
172 float offset = ((float)_i) / 100.0 * range;
173
174 node_->set_offset(offset);
175
176 emit signalNodeChanged(node_);
177}
178
179
180//=============================================================================
181} // namespace QtWidgets
182} // namespace ACG
183//=============================================================================
QtClippingDialog(QWidget *_parent, SceneGraph::ClippingNode *_node)
Default constructor.
const Vec3f & position() const
get position
void set_plane(const Vec3f &_position, const Vec3f &_normal, float _eps=0.0)
set position and normal of plane
Definition: ClippingNode.cc:77
float slice_width() const
get slice width
void set_offset(float _dist)
sweep plane along normal by _dist
const Vec3f & normal() const
get normal
Namespace providing different geometric functions concerning angles.