model_input_config_widget.cpp
Go to the documentation of this file.
1 //i_path_input_c
2 // Created by yijiangh on 6/17/17.
3 //
4 #include <ros/console.h>
5 #include <QString>
6 #include <QFileDialog>
7 
9 #include <ui_model_input_config.h>
10 
11 choreo_gui::ModelInputConfigWidget::ModelInputConfigWidget(choreo_msgs::ModelInputParameters params)
12  : params_(params)
13 {
14  ui_ = new Ui::ModelInputConfigWindow();
15  ui_->setupUi(this);
16 
17  connect(ui_->pushbutton_accept, SIGNAL(clicked()), this, SLOT(accept_changes_handler()));
18  connect(ui_->pushbutton_cancel, SIGNAL(clicked()), this, SLOT(cancel_changes_handler()));
19  connect(ui_->pushbutton_save, SIGNAL(clicked()), this, SLOT(save_changes_handler()));
20 
21  connect(ui_->pushbutton_readfile, SIGNAL(clicked()), this, SLOT(get_file_path_handler()));
22 
23  ui_->lineedit_ref_pt_x->setValidator(new QDoubleValidator(this));
24  ui_->lineedit_ref_pt_y->setValidator(new QDoubleValidator(this));
25  ui_->lineedit_ref_pt_z->setValidator(new QDoubleValidator(this));
26  ui_->lineedit_element_diameter->setValidator(new QDoubleValidator(this));
27  ui_->lineedit_shrink_length->setValidator(new QDoubleValidator(this));
28  ui_->lineedit_unit_process_timeout->setValidator(new QDoubleValidator(this));
29  ui_->lineedit_rrt_timeout->setValidator(new QDoubleValidator(this));
30 
31  last_filepath_ = "/home";
32 }
33 
35 {
36  ui_->lineedit_filepath->setText(QString(params_.file_name.c_str()));
37 
38  ui_->lineedit_ref_pt_x->setText(QString::number(params_.ref_pt_x));
39  ui_->lineedit_ref_pt_y->setText(QString::number(params_.ref_pt_y));
40  ui_->lineedit_ref_pt_z->setText(QString::number(params_.ref_pt_z));
41 
42  ui_->lineedit_element_diameter->setText(QString::number(params_.element_diameter));
43  ui_->lineedit_shrink_length->setText(QString::number(params_.shrink_length));
44 
45  ui_->lineedit_unit_process_timeout->setText(QString::number(params_.clt_rrt_unit_process_timeout));
46  ui_->lineedit_rrt_timeout->setText(QString::number(params_.clt_rrt_timeout));
47 
48  ui_->combobox_unit->setCurrentIndex(params_.unit_type);
49 }
50 
52 {
53  params_.file_name = ui_->lineedit_filepath->text().toLocal8Bit().constData();
54 
55  params_.ref_pt_x = ui_->lineedit_ref_pt_x->text().toDouble();
56  params_.ref_pt_y = ui_->lineedit_ref_pt_y->text().toDouble();
57  params_.ref_pt_z = ui_->lineedit_ref_pt_z->text().toDouble();
58 
59  params_.element_diameter = ui_->lineedit_element_diameter->text().toDouble();
60  params_.shrink_length = ui_->lineedit_shrink_length->text().toDouble();
61 
62  params_.clt_rrt_unit_process_timeout = ui_->lineedit_unit_process_timeout->text().toDouble();
63  params_.clt_rrt_timeout = ui_->lineedit_rrt_timeout->text().toDouble();
64 
65  params_.unit_type = ui_->combobox_unit->currentIndex();
66 }
67 
69 {
70  switch (params_.unit_type)
71  {
72  case choreo_msgs::ModelInputParameters::MILLIMETER:
73  return 0;
74  case choreo_msgs::ModelInputParameters::CENTIMETER:
75  return 1;
76  case choreo_msgs::ModelInputParameters::INCH:
77  return 2;
78  case choreo_msgs::ModelInputParameters::FOOT:
79  return 3;
80  case choreo_msgs::ModelInputParameters::METER:
81  return 4;
82  default:
83  return -1;
84  }
85 }
86 
88 {
89  QString filename = QFileDialog::getOpenFileName(
90  this,
91  tr("Open File"),
92  QString::fromStdString(last_filepath_),
93  tr("pwf Files (*.pwf)"));
94 
95  params_.file_name = filename.toLocal8Bit().constData();
96  last_filepath_ = filename.toLocal8Bit().constData();
97 
99 }
filename
virtual void update_display_fields()
Reads the internal data structure to update the fields of the GUI.
ModelInputConfigWidget(choreo_msgs::ModelInputParameters params)
virtual void update_internal_fields()
Reads the fields of the GUI to update the internal data structure.
choreo_msgs::ModelInputParameters params_


choreo_gui
Author(s): Yijiang Huang
autogenerated on Thu Jul 18 2019 03:58:56