2013-08-20 12:26:02 +02:00
|
|
|
#pragma GCC diagnostic push
|
|
|
|
#pragma GCC diagnostic ignored "-Weffc++"
|
|
|
|
#pragma GCC diagnostic ignored "-Wconversion"
|
|
|
|
#pragma GCC diagnostic ignored "-Wsign-conversion"
|
|
|
|
#pragma GCC diagnostic ignored "-Wctor-dtor-privacy"
|
2013-07-25 20:39:51 +02:00
|
|
|
#include "dialogline.h"
|
|
|
|
#include "ui_dialogline.h"
|
|
|
|
#include <QPushButton>
|
|
|
|
#include <QCloseEvent>
|
2013-08-20 12:26:02 +02:00
|
|
|
#pragma GCC diagnostic pop
|
2013-07-25 20:39:51 +02:00
|
|
|
|
|
|
|
DialogLine::DialogLine(const VContainer *data, QWidget *parent) :
|
2013-08-20 12:26:02 +02:00
|
|
|
DialogTool(data, parent), ui(new Ui::DialogLine), number(0), firstPoint(0), secondPoint(0){
|
2013-07-25 20:39:51 +02:00
|
|
|
ui->setupUi(this);
|
2013-07-28 00:18:06 +02:00
|
|
|
bOk = ui->buttonBox->button(QDialogButtonBox::Ok);
|
2013-07-25 20:39:51 +02:00
|
|
|
connect(bOk, &QPushButton::clicked, this, &DialogLine::DialogAccepted);
|
2013-07-28 00:18:06 +02:00
|
|
|
QPushButton *bCansel = ui->buttonBox->button(QDialogButtonBox::Cancel);
|
|
|
|
connect(bCansel, &QPushButton::clicked, this, &DialogLine::DialogRejected);
|
|
|
|
FillComboBoxPoints(ui->comboBoxFirstPoint);
|
|
|
|
FillComboBoxPoints(ui->comboBoxSecondPoint);
|
2013-07-25 20:39:51 +02:00
|
|
|
number = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
DialogLine::~DialogLine(){
|
|
|
|
delete ui;
|
|
|
|
}
|
|
|
|
|
|
|
|
qint64 DialogLine::getSecondPoint() const{
|
|
|
|
return secondPoint;
|
|
|
|
}
|
|
|
|
|
|
|
|
void DialogLine::setSecondPoint(const qint64 &value){
|
|
|
|
secondPoint = value;
|
|
|
|
VPointF point = data->GetPoint(value);
|
|
|
|
qint32 index = ui->comboBoxSecondPoint->findText(point.name());
|
|
|
|
if(index != -1){
|
|
|
|
ui->comboBoxSecondPoint->setCurrentIndex(index);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
qint64 DialogLine::getFirstPoint() const{
|
|
|
|
return firstPoint;
|
|
|
|
}
|
|
|
|
|
|
|
|
void DialogLine::setFirstPoint(const qint64 &value){
|
|
|
|
firstPoint = value;
|
|
|
|
VPointF point = data->GetPoint(value);
|
|
|
|
qint32 index = ui->comboBoxFirstPoint->findText(point.name());
|
|
|
|
if(index != -1){
|
|
|
|
ui->comboBoxFirstPoint->setCurrentIndex(index);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void DialogLine::DialogAccepted(){
|
|
|
|
qint32 index = ui->comboBoxFirstPoint->currentIndex();
|
|
|
|
firstPoint = qvariant_cast<qint64>(ui->comboBoxFirstPoint->itemData(index));
|
|
|
|
index = ui->comboBoxSecondPoint->currentIndex();
|
|
|
|
secondPoint = qvariant_cast<qint64>(ui->comboBoxSecondPoint->itemData(index));
|
|
|
|
DialogClosed(QDialog::Accepted);
|
|
|
|
}
|
|
|
|
|
2013-08-05 10:37:56 +02:00
|
|
|
void DialogLine::ChoosedObject(qint64 id, Scene::Type type){
|
2013-07-25 20:39:51 +02:00
|
|
|
if(type == Scene::Point){
|
|
|
|
VPointF point = data->GetPoint(id);
|
|
|
|
if(number == 0){
|
|
|
|
qint32 index = ui->comboBoxFirstPoint->findText(point.name());
|
|
|
|
if ( index != -1 ) { // -1 for not found
|
|
|
|
ui->comboBoxFirstPoint->setCurrentIndex(index);
|
|
|
|
number++;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if(number == 1){
|
|
|
|
qint32 index = ui->comboBoxSecondPoint->findText(point.name());
|
|
|
|
if ( index != -1 ) { // -1 for not found
|
|
|
|
ui->comboBoxSecondPoint->setCurrentIndex(index);
|
|
|
|
number = 0;
|
|
|
|
}
|
|
|
|
if(!isInitialized){
|
|
|
|
this->show();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|