parameter.cpp
Go to the documentation of this file.
00001 /*
00002  * Software License Agreement (BSD License)
00003  *
00004  *  Point Cloud Library (PCL) - www.pointclouds.org
00005  *  Copyright (c) 2012, Willow Garage, Inc.
00006  *  All rights reserved.
00007  *
00008  *  Redistribution and use in source and binary forms, with or without
00009  *  modification, are permitted provided that the following conditions
00010  *  are met:
00011  *
00012  *   * Redistributions of source code must retain the above copyright
00013  *     notice, this list of conditions and the following disclaimer.
00014  *   * Redistributions in binary form must reproduce the above
00015  *     copyright notice, this list of conditions and the following
00016  *     disclaimer in the documentation and/or other materials provided
00017  *     with the distribution.
00018  *   * Neither the name of Willow Garage, Inc. nor the names of its
00019  *     contributors may be used to endorse or promote products derived
00020  *     from this software without specific prior written permission.
00021  *
00022  *  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
00023  *  "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
00024  *  LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
00025  *  FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
00026  *  COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
00027  *  INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
00028  *  BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
00029  *  LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
00030  *  CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
00031  *  LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
00032  *  ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
00033  *  POSSIBILITY OF SUCH DAMAGE.
00034  *
00035  */
00036 
00037 #include <pcl/apps/modeler/parameter.h>
00038 
00039 #include <cassert>
00040 #include <fstream>
00041 #include <iomanip>
00042 
00044 void
00045 pcl::modeler::Parameter::setModelData(QWidget *editor, QAbstractItemModel *model, const QModelIndex &index)
00046 {
00047   getEditorData(editor);
00048   std::pair<QVariant, int> model_data = toModelData();
00049   model->setData(index, model_data.first, model_data.second);
00050 }
00051 
00052 
00054 std::string
00055 pcl::modeler::IntParameter::valueTip() 
00056 {
00057   return QString("value range: [%1, %3]").arg(low_).arg(high_).toStdString();
00058 }
00059 
00061 QWidget *
00062 pcl::modeler::IntParameter::createEditor(QWidget *parent)
00063 {
00064   QSpinBox *editor = new QSpinBox(parent);
00065   editor->setMinimum(low_);
00066   editor->setMaximum(high_);
00067   editor->setSingleStep(step_);
00068 
00069   return editor;
00070 }
00071 
00073 void
00074 pcl::modeler::IntParameter::setEditorData(QWidget *editor)
00075 {
00076   QSpinBox *spinBox = static_cast<QSpinBox*>(editor);
00077   spinBox->setAlignment(Qt::AlignHCenter);
00078 
00079   int value = int (*this);
00080   spinBox->setValue(value);
00081 }
00082 
00084 void
00085 pcl::modeler::IntParameter::getEditorData(QWidget *editor)
00086 {
00087   QSpinBox *spinBox = static_cast<QSpinBox*>(editor);
00088   int value = spinBox->text().toInt();
00089   current_value_ = value;
00090 }
00091 
00093 std::pair<QVariant, int>
00094 pcl::modeler::IntParameter::toModelData()
00095 {
00096   std::pair<QVariant, int> model_data;
00097   model_data.first = int (*this);
00098   model_data.second = Qt::EditRole;
00099   return (model_data);
00100 }
00101 
00103 std::string
00104 pcl::modeler::BoolParameter::valueTip() 
00105 {
00106   return QString("bool value").toStdString();
00107 }
00108 
00110 QWidget *
00111 pcl::modeler::BoolParameter::createEditor(QWidget *parent)
00112 {
00113   QCheckBox *editor = new QCheckBox(parent);
00114 
00115   return editor;
00116 }
00117 
00119 void
00120 pcl::modeler::BoolParameter::setEditorData(QWidget *editor)
00121 {
00122   QCheckBox *checkBox = static_cast<QCheckBox*>(editor);
00123 
00124   bool value = bool (*this);
00125   checkBox->setCheckState(value?(Qt::Checked):(Qt::Unchecked));
00126 }
00127 
00129 void
00130   pcl::modeler::BoolParameter::getEditorData(QWidget *editor)
00131 {
00132   QCheckBox *checkBox = static_cast<QCheckBox*>(editor);
00133   bool value = (checkBox->checkState() == Qt::Checked);
00134   current_value_ = value;
00135 }
00136 
00138 std::pair<QVariant, int>
00139 pcl::modeler::BoolParameter::toModelData()
00140 {
00141   std::pair<QVariant, int> model_data;
00142   model_data.first = bool (*this);
00143   model_data.second = Qt::EditRole;
00144   return (model_data);
00145 }
00146 
00148 std::string
00149 pcl::modeler::DoubleParameter::valueTip() 
00150 {
00151   return QString("value range: [%1, %3]").arg(low_).arg(high_).toStdString();
00152 }
00153 
00155 QWidget *
00156 pcl::modeler::DoubleParameter::createEditor(QWidget *parent)
00157 {
00158   QDoubleSpinBox *editor = new QDoubleSpinBox(parent);
00159   editor->setMinimum(low_);
00160   editor->setMaximum(high_);
00161   editor->setSingleStep(step_);
00162   editor->setDecimals(6);
00163 
00164   return editor;
00165 }
00166 
00168 void
00169 pcl::modeler::DoubleParameter::setEditorData(QWidget *editor)
00170 {
00171   QDoubleSpinBox *spinBox = static_cast<QDoubleSpinBox*>(editor);
00172   spinBox->setAlignment(Qt::AlignHCenter);
00173 
00174   double value = double (*this);
00175   spinBox->setValue(value);
00176 }
00177 
00179 void
00180 pcl::modeler::DoubleParameter::getEditorData(QWidget *editor)
00181 {
00182   QDoubleSpinBox *spinBox = static_cast<QDoubleSpinBox*>(editor);
00183   double value = spinBox->text().toDouble();
00184   current_value_ = value;
00185 }
00186 
00188 std::pair<QVariant, int>
00189 pcl::modeler::DoubleParameter::toModelData()
00190 {
00191   std::pair<QVariant, int> model_data;
00192   model_data.first = double (*this);
00193   model_data.second = Qt::EditRole;
00194   return (model_data);
00195 }
00196 
00198 std::string
00199 pcl::modeler::ColorParameter::valueTip() 
00200 {
00201   return ("Color");
00202 }
00203 
00205 QWidget *
00206 pcl::modeler::ColorParameter::createEditor(QWidget *parent)
00207 {
00208   QColorDialog *editor = new QColorDialog(parent);
00209 
00210   return editor;
00211 }
00212 
00214 void
00215 pcl::modeler::ColorParameter::setEditorData(QWidget *editor)
00216 {
00217   QColorDialog *color_dialog = static_cast<QColorDialog*>(editor);
00218 
00219   QColor value = QColor (*this);
00220   color_dialog->setCurrentColor(value);
00221 
00222   return;
00223 }
00224 
00226 void
00227 pcl::modeler::ColorParameter::getEditorData(QWidget *editor)
00228 {
00229   QColorDialog *color_dialog = static_cast<QColorDialog*>(editor);
00230 
00231   QColor value = color_dialog->currentColor();
00232   current_value_ = value;
00233 }
00234 
00236 std::pair<QVariant, int>
00237 pcl::modeler::ColorParameter::toModelData()
00238 {
00239   std::pair<QVariant, int> model_data;
00240   model_data.first = QBrush(QColor(*this));
00241   model_data.second = Qt::BackgroundRole;
00242   return (model_data);
00243 }


pcl
Author(s): Open Perception
autogenerated on Wed Aug 26 2015 15:27:33