Developer Documentation

- Main Page
- Related Pages
- Modules
- Namespaces
- Classes
- Files

- File List
- File Members

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