1 #include "CurveCreator_NewPointDlg.h"
\r
2 #include <QGridLayout>
\r
3 #include <QVBoxLayout>
\r
5 #include <QDoubleSpinBox>
\r
6 #include <QDialogButtonBox>
\r
7 #include <QDoubleValidator>
\r
8 #include <QRegExpValidator>
\r
9 #include <QAbstractButton>
\r
10 #include <QPushButton>
\r
13 CurveCreator_NewPointDlg::CurveCreator_NewPointDlg(CurveCreator::Dimension theDim, QWidget *parent) :
\r
14 QDialog(parent), myX(NULL), myY(NULL), myZ(NULL), myIsEdit(false)
\r
16 QGridLayout* aCoordLay = new QGridLayout();
\r
18 QString aTitle = QString(tr("ADD_NEW_POINT"));
\r
19 setWindowTitle(aTitle);
\r
21 QLabel* aLbl = new QLabel( tr("X_COORD"), this);
\r
22 myX = new QDoubleSpinBox(this);
\r
23 aCoordLay->addWidget(aLbl, 0, 0);
\r
24 aCoordLay->addWidget(myX, 0, 1 );
\r
26 aLbl = new QLabel( tr("Y_COORD"), this);
\r
27 myY = new QDoubleSpinBox(this);
\r
28 aCoordLay->addWidget(aLbl, 1, 0 );
\r
29 aCoordLay->addWidget(myY, 1, 1 );
\r
31 if( theDim == CurveCreator::Dim3d ){
\r
32 aLbl = new QLabel( tr("Z_COORD"), this);
\r
33 myZ = new QDoubleSpinBox(this);
\r
34 aCoordLay->addWidget(aLbl, 2,0 );
\r
35 aCoordLay->addWidget(myZ, 2,1 );
\r
38 myBtnBox = new QDialogButtonBox(this);
\r
39 myAddBtn = myBtnBox->addButton(tr("ADD_BTN"), QDialogButtonBox::AcceptRole );
\r
40 myContBtn = myBtnBox->addButton(tr("ADD_CONTINUE_BTN"), QDialogButtonBox::ResetRole );
\r
41 myBtnBox->addButton(tr("CANCEL"), QDialogButtonBox::RejectRole );
\r
43 connect( myBtnBox, SIGNAL(accepted()), this, SLOT(accept()));
\r
44 connect( myBtnBox, SIGNAL(rejected()), this, SLOT(reject()));
\r
45 connect( myBtnBox, SIGNAL(clicked(QAbstractButton*)), this, SLOT(onBtnClicked(QAbstractButton*) ));
\r
46 QVBoxLayout* aMainLay = new QVBoxLayout();
\r
47 aMainLay->addLayout(aCoordLay);
\r
48 aMainLay->addWidget(myBtnBox);
\r
49 setLayout(aMainLay);
\r
54 void CurveCreator_NewPointDlg::setSectionName( const QString& theName )
\r
56 mySectionName = theName;
\r
60 void CurveCreator_NewPointDlg::setEditMode( bool isEdit )
\r
65 myAddBtn->setText(tr("OK"));
\r
69 myAddBtn->setText(tr("ADD_BTN"));
\r
74 void CurveCreator_NewPointDlg::updateTitle()
\r
78 if( mySectionName.isEmpty() ){
\r
79 aTitle = tr("ADD_NEW_POINT");
\r
82 aTitle = QString(tr("ADD_NEW_POINT_TO_%1")).arg(mySectionName);
\r
86 aTitle = tr("SET_POINT_COORDINATES");
\r
88 setWindowTitle(aTitle);
\r
91 CurveCreator::Coordinates CurveCreator_NewPointDlg::getCoordinates() const
\r
93 CurveCreator::Coordinates aCoords;
\r
94 double anX = myX->value();
\r
95 aCoords.push_back(anX);
\r
96 double anY = myY->value();
\r
97 aCoords.push_back(anY);
\r
99 double aZ = myZ->value();
\r
100 aCoords.push_back(aZ);
\r
105 void CurveCreator_NewPointDlg::onBtnClicked(QAbstractButton* theBtn )
\r
107 if( myBtnBox->buttonRole(theBtn) == QDialogButtonBox::ResetRole ){
\r
112 void CurveCreator_NewPointDlg::clear()
\r
120 void CurveCreator_NewPointDlg::setCoordinates( const CurveCreator::Coordinates& theCoords )
\r
122 double anX = theCoords[0];
\r
123 myX->setValue(anX);
\r
124 double anY = theCoords[1];
\r
125 myY->setValue(anY);
\r
126 if( myZ && ( theCoords.size() == 3)){
\r
127 double aZ = theCoords[2];
\r
132 //=======================================================================
\r
133 // function: initSpinBox
\r
135 //=======================================================================
\r
136 void CurveCreator_NewPointDlg::initSpinBox(QDoubleSpinBox *theSpinBox)
\r
138 const double aCoordMin = -1.e+15;
\r
139 const double aCoordMax = 1.e+15;
\r
140 const double aStep = 10;
\r
141 const int aPrecision = 6;
\r
143 theSpinBox->setDecimals( qAbs( aPrecision ) );
\r
144 theSpinBox->setRange(aCoordMin, aCoordMax);
\r
145 theSpinBox->setSingleStep(aStep);
\r
146 theSpinBox->setValue(0.0);
\r