QtClippingDialog.cc

00001 /*===========================================================================*\
00002  *                                                                           *
00003  *                              OpenFlipper                                  *
00004  *      Copyright (C) 2001-2009 by Computer Graphics Group, RWTH Aachen      *
00005  *                           www.openflipper.org                             *
00006  *                                                                           *
00007  *---------------------------------------------------------------------------*
00008  *  This file is part of OpenFlipper.                                        *
00009  *                                                                           *
00010  *  OpenFlipper is free software: you can redistribute it and/or modify      *
00011  *  it under the terms of the GNU Lesser General Public License as           *
00012  *  published by the Free Software Foundation, either version 3 of           *
00013  *  the License, or (at your option) any later version with the              *
00014  *  following exceptions:                                                    *
00015  *                                                                           *
00016  *  If other files instantiate templates or use macros                       *
00017  *  or inline functions from this file, or you compile this file and         *
00018  *  link it with other files to produce an executable, this file does        *
00019  *  not by itself cause the resulting executable to be covered by the        *
00020  *  GNU Lesser General Public License. This exception does not however       *
00021  *  invalidate any other reasons why the executable file might be            *
00022  *  covered by the GNU Lesser General Public License.                        *
00023  *                                                                           *
00024  *  OpenFlipper is distributed in the hope that it will be useful,           *
00025  *  but WITHOUT ANY WARRANTY; without even the implied warranty of           *
00026  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the            *
00027  *  GNU Lesser General Public License for more details.                      *
00028  *                                                                           *
00029  *  You should have received a copy of the GNU LesserGeneral Public          *
00030  *  License along with OpenFlipper. If not,                                  *
00031  *  see <http://www.gnu.org/licenses/>.                                      *
00032  *                                                                           *
00033 \*===========================================================================*/
00034 
00035 /*===========================================================================*\
00036  *                                                                           *
00037  *   $Revision: 6743 $                                                       *
00038  *   $Author: moebius $                                                      *
00039  *   $Date: 2009-08-05 11:03:10 +0200 (Mi, 05. Aug 2009) $                   *
00040  *                                                                           *
00041 \*===========================================================================*/
00042 
00043 
00044 
00045 //=============================================================================
00046 //
00047 //  CLASS QtClippingDialog - IMPLEMENTATION
00048 //
00049 //=============================================================================
00050 
00051 //== INCLUDES =================================================================
00052 
00053 
00054 #include "QtClippingDialog.hh"
00055 
00056 #include "../Scenegraph/ClippingNode.hh"
00057 
00058 #include <QPushButton>
00059 #include <QSlider>
00060 #include <QLineEdit>
00061 
00062 
00063 //== NAMESPACES ===============================================================
00064 
00065 
00066 namespace ACG {
00067 namespace QtWidgets {
00068 
00069 
00070 //== IMPLEMENTATION ========================================================== 
00071 
00072 
00073 QtClippingDialog::
00074 QtClippingDialog( QWidget                  * _parent,
00075                   SceneGraph::ClippingNode * _node )
00076   : QDialog( _parent ),
00077     node_( _node )
00078 {
00079   ui_.setupUi( this );
00080 
00081   connect( ui_.setButton, SIGNAL( clicked() ),
00082            this, SLOT( set_plane() ) );
00083   connect( ui_.sweepRangeSlider, SIGNAL( sliderMoved(int) ),
00084            this, SLOT( sweep_plane(int) ) );
00085 
00086   update_values();
00087   connect( ui_.okButton, SIGNAL( clicked() ),
00088            this, SLOT( accept() ) );
00089 
00090   layout()->setSizeConstraint( QLayout::SetFixedSize );
00091 
00092 }
00093  
00094 
00095 //-----------------------------------------------------------------------------
00096 
00097 
00098 void 
00099 QtClippingDialog::show()
00100 {
00101   update_values();
00102   QDialog::show();
00103 }
00104 
00105 
00106 //-----------------------------------------------------------------------------
00107 
00108 
00109 void 
00110 QtClippingDialog::update_values()
00111 {
00112   QString s;
00113 
00114   const Vec3f& position = node_->position();
00115   ui_.positionXLineEdit->setText(s.setNum(position[0], 'f', 3));
00116   ui_.positionYLineEdit->setText(s.setNum(position[1], 'f', 3));
00117   ui_.positionZLineEdit->setText(s.setNum(position[2], 'f', 3));
00118 
00119   const Vec3f& normal = node_->normal();
00120   ui_.normalXLineEdit->setText(s.setNum(normal[0], 'f', 3));
00121   ui_.normalYLineEdit->setText(s.setNum(normal[1], 'f', 3));
00122   ui_.normalZLineEdit->setText(s.setNum(normal[2], 'f', 3));
00123 
00124   float slice_width = node_->slice_width();
00125   ui_.sliceWidthLineEdit->setText(s.setNum(slice_width, 'f', 3));
00126 }
00127 
00128 
00129 //-----------------------------------------------------------------------------
00130 
00131 
00132 void 
00133 QtClippingDialog::set_plane()
00134 {
00135   // set plane
00136   Vec3f position( ui_.positionXLineEdit->text().toFloat(),
00137                   ui_.positionYLineEdit->text().toFloat(),
00138                   ui_.positionZLineEdit->text().toFloat() );
00139 
00140   Vec3f normal( ui_.normalXLineEdit->text().toFloat(),
00141                 ui_.normalYLineEdit->text().toFloat(),
00142                 ui_.normalZLineEdit->text().toFloat() );
00143 
00144   float slice_width = ui_.sliceWidthLineEdit->text().toFloat();
00145 
00146   node_->set_plane(position, normal, slice_width);
00147 
00148 
00149   // reset slider
00150   ui_.sweepRangeSlider->setValue(0);
00151 
00152 
00153   emit signalNodeChanged(node_);
00154 }
00155 
00156 
00157 //-----------------------------------------------------------------------------
00158 
00159 
00160 void 
00161 QtClippingDialog::set_sweep_range(float _radius)
00162 {
00163   QString s;
00164   ui_.sweepRangeLineEdit->setText(s.setNum(_radius, 'f', 3));
00165 }
00166 
00167 
00168 //-----------------------------------------------------------------------------
00169 
00170 
00171 void 
00172 QtClippingDialog::sweep_plane(int _i)
00173 {
00174   float range  = ui_.sweepRangeLineEdit->text().toFloat();
00175   float offset = ((float)_i) / 100.0 * range;
00176 
00177   node_->set_offset(offset);
00178 
00179   emit signalNodeChanged(node_);
00180 }
00181 
00182 
00183 //=============================================================================
00184 } // namespace QtWidgets
00185 } // namespace ACG
00186 //=============================================================================

acg pic Project OpenFlipper, ©  Computer Graphics Group, RWTH Aachen. Documentation generated using doxygen .