00001
00002
00003
00004
00005
00006
00007
00008
00009
00010 #include "PSQt/WdgPointPos3D.h"
00011 #include "PSQt/Logger.h"
00012
00013 #include <iostream>
00014 #include <sstream>
00015
00016
00017 namespace PSQt {
00018
00019
00020
00021 WdgPointPos3D::WdgPointPos3D( QWidget *parent
00022 , const std::string& label1
00023 , const std::string& label2
00024 , const std::string& label3
00025 , const float& val1
00026 , const float& val2
00027 , const float& val3
00028 , const bool& show_boarder
00029 , const unsigned& fld_width
00030 , const unsigned& prec1
00031 , const unsigned& prec2
00032 , const unsigned& prec3
00033 )
00034
00035 : Frame(parent)
00036 , m_show_boarder(show_boarder)
00037 , m_fld_width(fld_width)
00038 , m_prec1(prec1)
00039 , m_prec2(prec2)
00040 , m_prec3(prec3)
00041 {
00042 Frame::setBoarderVisible(show_boarder);
00043
00044 m_lab1 = new QLabel(label1.c_str());
00045 m_lab2 = new QLabel(label2.c_str());
00046 m_lab3 = new QLabel(label3.c_str());
00047
00048 m_edi1 = new QLineEdit("");
00049 m_edi2 = new QLineEdit("");
00050 m_edi3 = new QLineEdit("");
00051 m_edi1 -> setFixedWidth(m_fld_width);
00052 m_edi2 -> setFixedWidth(m_fld_width);
00053 m_edi3 -> setFixedWidth(m_fld_width);
00054 m_edi1 -> setValidator(new QDoubleValidator(-100000, 100000, m_prec1, this));
00055 m_edi2 -> setValidator(new QDoubleValidator(-100000, 100000, m_prec2, this));
00056 m_edi3 -> setValidator(new QDoubleValidator(-100000, 100000, m_prec3, this));
00057
00058
00059
00060
00061 setPointPos(val1,val2,val3);
00062
00063 connect(m_edi1, SIGNAL(editingFinished()), this, SLOT(onEdi()));
00064 connect(m_edi2, SIGNAL(editingFinished()), this, SLOT(onEdi()));
00065 connect(this, SIGNAL(posIsChanged(const float&, const float&, const float&)),
00066 this, SLOT(testPosIsChanged(const float&, const float&, const float&)) );
00067
00068 QHBoxLayout *hbox = new QHBoxLayout;
00069 hbox -> addWidget(m_lab1);
00070 hbox -> addWidget(m_edi1);
00071 hbox -> addWidget(m_lab2);
00072 hbox -> addWidget(m_edi2);
00073 hbox -> addWidget(m_lab3);
00074 hbox -> addWidget(m_edi3);
00075 this -> setLayout(hbox);
00076
00077 this -> setWindowTitle(tr("WdgPointPos3D"));
00078 this -> setFixedHeight( (m_show_boarder)? 50 : 36);
00079 if (! m_show_boarder) this -> setContentsMargins(-9,-9,-9,-9);
00080
00081
00082
00083 this -> showTips();
00084 }
00085
00086
00087
00088 void
00089 WdgPointPos3D::showTips()
00090 {
00091 m_edi1 -> setToolTip("Type value to change");
00092 m_edi2 -> setToolTip("Type value to change");
00093 m_edi3 -> setToolTip("Type value to change");
00094 }
00095
00096
00097
00098 void
00099 WdgPointPos3D::resizeEvent(QResizeEvent *event)
00100 {
00101
00102 }
00103
00104
00105
00106 void
00107 WdgPointPos3D::closeEvent(QCloseEvent *event)
00108 {
00109 QWidget::closeEvent(event);
00110 stringstream ss; ss << "closeEvent(...): type = " << event -> type();
00111 MsgInLog(_name_(), INFO, ss.str());
00112 }
00113
00114
00115
00116
00117
00118
00119 void
00120 WdgPointPos3D::setPointPos(const float& x, const float& y, const float& z)
00121 {
00122
00123 stringstream ss1, ss2, ss3;
00124 ss1 << fixed << std::setprecision(m_prec1) << x;
00125 ss2 << fixed << std::setprecision(m_prec2) << y;
00126 ss3 << fixed << std::setprecision(m_prec3) << z;
00127
00128 m_edi1->setText(ss1.str().c_str());
00129 m_edi2->setText(ss2.str().c_str());
00130 m_edi3->setText(ss3.str().c_str());
00131
00132
00133
00134
00135 }
00136
00137
00138
00139 void
00140 WdgPointPos3D::onEdi()
00141 {
00142 std::string str1 = (m_edi1 -> displayText()).toStdString();
00143 std::string str2 = (m_edi2 -> displayText()).toStdString();
00144 std::string str3 = (m_edi3 -> displayText()).toStdString();
00145
00146 float val1, val2, val3;
00147 stringstream ss; ss << str1 << ' ' << str2 << ' ' << str3;
00148 ss >> val1 >> val2 >> val3;
00149
00150 emit posIsChanged(val1, val2, val3);
00151 }
00152
00153
00154
00155 void
00156 WdgPointPos3D::testPosIsChanged(const float& x, const float& y, const float& z)
00157 {
00158 stringstream ss; ss << "3-d point position is changed to x: " << x << " y: " << y << " z: " << z;
00159 MsgInLog(_name_(), INFO, ss.str());
00160
00161 }
00162
00163
00164
00165
00166
00167 }
00168
00169