Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
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 }