340 lines
8.1 KiB
C++
340 lines
8.1 KiB
C++
#include "airticket.h"
|
|
#include "ui_airticket.h"
|
|
|
|
airTicket::airTicket(int tn, QWidget *parent) :
|
|
QDialog(parent),
|
|
ui(new Ui::airTicket)
|
|
{
|
|
ui->setupUi(this);
|
|
|
|
|
|
setWindowTitle(QString::fromLocal8Bit("Òðàññà %1").arg(tn+1));
|
|
setGeometry(750, 150, 226, 521);
|
|
|
|
ao = ((Widget*)parent)->targets.at(tn);
|
|
pbUC.clear();
|
|
pbUC<<ui->pushButton<<ui->pushButton_2<<ui->pushButton_3
|
|
<<ui->pushButton_4<<ui->pushButton_5<<ui->pushButton_6;
|
|
pbKZS.clear();
|
|
|
|
pbKZS<<ui->pushButton_7<<ui->pushButton_8<< ui->pushButton_9
|
|
<<ui->pushButton_10<<ui->pushButton_11<<ui->pushButton_12;
|
|
|
|
|
|
lbParam.clear();
|
|
lbParam <<ui->label_36<<ui->label_37<<ui->label_38
|
|
<<ui->label_39<<ui->label_40<<ui->label_41<<ui->label_42;
|
|
|
|
|
|
|
|
|
|
for (int i=0; i<6; i++)
|
|
{
|
|
pbUC[i]->setStyleSheet("background-color: rgb(220, 220, 220)");
|
|
pbUC[i]->setChecked(false);
|
|
pbKZS[i]->setStyleSheet("background-color: rgb(220, 220, 220)");
|
|
pbKZS[i]->setChecked(false);
|
|
|
|
connect(pbUC[i], SIGNAL(clicked()), this, SLOT(onCU_clicked()));
|
|
connect(pbKZS[i], SIGNAL(clicked()), this, SLOT(onKZS_clicked()));
|
|
}
|
|
msTick();
|
|
|
|
tmr = new QTimer(this);
|
|
connect(tmr, SIGNAL(timeout()), this, SLOT(msTick()));
|
|
tmr->start(500);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
airTicket::~airTicket()
|
|
{
|
|
|
|
((Widget*)parent())->openAirTicket = 0;
|
|
|
|
delete ui;
|
|
}
|
|
|
|
void airTicket::on_pushButton_13_clicked()
|
|
{
|
|
// ((Widget*)parent())->clearOpenWidget();
|
|
this->close();
|
|
}
|
|
|
|
|
|
void airTicket::msTick()
|
|
{
|
|
QPointF myP = ((Widget*)parent())->ownTS;
|
|
QPointF trgP;
|
|
|
|
|
|
QLineF lf;
|
|
trgP = ao->getPos();
|
|
|
|
lf = QLineF(myP, trgP);
|
|
qreal an = 90-lf.angle();
|
|
if (an<0) an+=360;
|
|
QString s = QString::number(an, 'f', 0);
|
|
s.append("°");
|
|
ui->label_2->setText(s);
|
|
|
|
int DU = an/6;
|
|
int mDU = int((an-DU*6)/6*100);
|
|
s = QString::number(DU);
|
|
s.append("-");
|
|
if (mDU<10) s.append("0");
|
|
s.append(QString::number(mDU));
|
|
ui->label_3->setText(s);
|
|
|
|
qreal len = lf.length()/10;
|
|
s.setNum(len, 'f', 1);
|
|
s.append(QString::fromLocal8Bit(" êì"));
|
|
ui->label_5->setText(s);
|
|
|
|
qreal h = (ao->h)/10;
|
|
s.setNum(h, 'f', 2);
|
|
ui->label_7->setText(s);
|
|
|
|
|
|
qreal kurs = ao->kurs();
|
|
qreal azim = an;
|
|
qreal res = 180-kurs+azim;
|
|
qreal P = len*cos(res*M_PI/180);
|
|
if (P<0) P=-P;
|
|
kurs=90-kurs;
|
|
if (kurs<0) kurs+=360;
|
|
s.setNum(kurs, 'f', 0);
|
|
s.append("° (");
|
|
s.append(QString::number(P, 'f', 1));
|
|
s.append(QString::fromLocal8Bit(" êì)"));
|
|
|
|
|
|
ui->label_9->setText(s);
|
|
qreal speed = ao->v0*10;
|
|
s.setNum(speed, 'f', 0);
|
|
s.append(QString::fromLocal8Bit(" ì/ñ"));
|
|
|
|
ui->label_10->setText(s);
|
|
|
|
speed = speed *3.6;
|
|
s.setNum(speed, 'f',0);
|
|
s.append(QString::fromLocal8Bit(" êì/÷"));
|
|
ui->label_12->setText(s);
|
|
|
|
switch (ao->gType)
|
|
{
|
|
case 1:
|
|
s = QString::fromLocal8Bit("÷óæîé");
|
|
|
|
QPushButton *pbt;
|
|
foreach (pbt, pbUC) pbt->show();
|
|
foreach (pbt, pbKZS) pbt->show();
|
|
|
|
break;
|
|
case 2:
|
|
s = QString::fromLocal8Bit("ñâîé");
|
|
foreach (pbt, pbUC) pbt->hide();
|
|
foreach (pbt, pbKZS) pbt->hide();
|
|
break;
|
|
case 3:
|
|
s = QString::fromLocal8Bit("ñâîé ãàðàíò.");
|
|
foreach (pbt, pbUC) pbt->hide();
|
|
foreach (pbt, pbKZS) pbt->hide();
|
|
break;
|
|
default:
|
|
s = QString::fromLocal8Bit("íåîïîçíàííûé");
|
|
foreach (pbt, pbUC) pbt->show();
|
|
foreach (pbt, pbKZS) pbt->show();
|
|
|
|
}
|
|
|
|
if ((ao->gType == 3)||(ao->gType == 2))
|
|
{
|
|
ui->label_46->hide();
|
|
ui->label_47->hide();
|
|
ui->frame_4->hide();
|
|
ui->frame_5->hide();
|
|
ui->pushButton_13->setGeometry(70,370,75,23);
|
|
|
|
resize(width(), 400);
|
|
|
|
|
|
}
|
|
|
|
ui->label_13->setText(s);
|
|
|
|
ui->label_15->setText(QString::number(ao->aType));
|
|
|
|
ui->label_17->setText("1");
|
|
|
|
ui->label_19->setText(QString::fromLocal8Bit("íåò"));
|
|
|
|
ui->label_22->setText(QString::fromLocal8Bit("0"));
|
|
|
|
qreal x = - ao->getPos().y()*100;
|
|
s.setNum(x, 'f', 0); s.append(" m.");
|
|
ui->label_25->setText(s);
|
|
|
|
qreal y = ao->getPos().x()*100;
|
|
s.setNum(y, 'f', 0); s.append(" m.");
|
|
ui->label_27->setText(s);
|
|
|
|
|
|
for (int i=0; i<6; i++)
|
|
{
|
|
go = ((Widget*)parent())->grObj.at(i+1);
|
|
pbUC[i]->setEnabled(go->exist);
|
|
pbKZS[i]->setEnabled(go->exist);
|
|
|
|
|
|
if (pbUC[i]->isEnabled())
|
|
{
|
|
if (ao->CU[i+1]==1)
|
|
{
|
|
pbUC[i]->setStyleSheet("background-color: rgb(0, 220, 100)");
|
|
pbUC[i]->setChecked(true);
|
|
pbKZS[i]->setStyleSheet("background-color: rgb(220, 220, 220)");
|
|
pbKZS[i]->setChecked(false);
|
|
}
|
|
if (ao->CU[i+1]==2)
|
|
{
|
|
pbKZS[i]->setStyleSheet("background-color: rgb(220, 0, 0)");
|
|
pbKZS[i]->setChecked(true);
|
|
pbUC[i]->setStyleSheet("background-color: rgb(220, 220, 220)");
|
|
pbUC[i]->setChecked(false);
|
|
}
|
|
if (ao->CU[i+1]==0)
|
|
{
|
|
pbUC[i]->setStyleSheet("background-color: rgb(220, 220, 220)");
|
|
pbUC[i]->setChecked(false);
|
|
pbKZS[i]->setStyleSheet("background-color: rgb(220, 220, 220)");
|
|
pbKZS[i]->setChecked(false);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
else
|
|
{
|
|
pbUC[i]->setStyleSheet("background-color: rgb(220, 220, 220)");
|
|
pbUC[i]->setChecked(false);
|
|
pbKZS[i]->setStyleSheet("background-color: rgb(220, 220, 220)");
|
|
pbKZS[i]->setChecked(false);
|
|
|
|
}
|
|
}
|
|
|
|
|
|
kurs = ao->kurs();
|
|
trgP = ao->getPos();
|
|
if (an<0) an+=360;
|
|
|
|
for (int i=0;i<7;i++)
|
|
{
|
|
go = ((Widget*)parent())->grObj.at(i);
|
|
if (go->exist)
|
|
{
|
|
|
|
myP = go->getPos();
|
|
lf = QLineF(myP, trgP);
|
|
an = 90-lf.angle();
|
|
res = 180-kurs+an;
|
|
len = lf.length()/10;
|
|
|
|
if (ao->v0 == 0)
|
|
{
|
|
P = len;
|
|
}
|
|
else
|
|
{
|
|
|
|
P = len*cos(res*M_PI/180);
|
|
if (P<0) P=-P;
|
|
}
|
|
s.setNum(P, 'f', 1);
|
|
lbParam.at(i)->setText(s);
|
|
}
|
|
}
|
|
}
|
|
|
|
void airTicket::onCU_clicked()
|
|
{
|
|
QPushButton *p = (QPushButton*)sender();
|
|
int i = pbUC.indexOf(p);
|
|
QString s = QString::fromLocal8Bit("ÊÖ > ");
|
|
|
|
tmr->stop();
|
|
go = ((Widget*)parent())->grObj.at(i+1);
|
|
if (p->isChecked())
|
|
{
|
|
|
|
ao->setCU(i+1);
|
|
int ret = go->addCU(ao->uid); // âåðíóëè >0 åñëè çàìåíèëèè ÖÓ ñî ñòàðîé öåëè íà íîâóþ
|
|
|
|
if (ret>=0)
|
|
{
|
|
foreach (ao_temp, ((Widget*)parent())->targets)
|
|
if (ao_temp->uid == ret) ao_temp->clearCU(i+1);
|
|
|
|
}
|
|
|
|
p->setStyleSheet("background-color: rgb(0, 220, 100)");
|
|
|
|
s.append(QString::number(i+1));
|
|
s.append(QString::fromLocal8Bit(" ïî "));
|
|
s.append(QString::number(ao->numer+1));
|
|
s.append(" ZZ 11 ");
|
|
s.append(QString::fromLocal8Bit("'Öåëü óíè÷òîæèòü'"));
|
|
// ((Widget*)parent())->addLogText(s);
|
|
((Widget*)parent())->sendCU(i+1, 11, ao->uid);
|
|
|
|
}
|
|
else
|
|
{
|
|
ao->clearCU(i+1);
|
|
go->removeCU(ao->uid);
|
|
((Widget*)parent())->sendCU(i+1, 99, ao->uid);
|
|
p->setStyleSheet("background-color: rgb(220, 220, 220)");
|
|
}
|
|
tmr->start(500);
|
|
|
|
}
|
|
void airTicket::onKZS_clicked()
|
|
{
|
|
QPushButton *p = (QPushButton*)sender();
|
|
|
|
int i = pbKZS.indexOf(p);
|
|
QString s = QString::fromLocal8Bit("ÊÖ > ");
|
|
|
|
tmr->stop();
|
|
go = ((Widget*)parent())->grObj.at(i+1);
|
|
if (p->isChecked())
|
|
{
|
|
ao->setCU(i+1,2);
|
|
go->removeCU(ao->uid);
|
|
p->setStyleSheet("background-color: rgb(220, 0, 0)");
|
|
s.append(QString::number(i+1));
|
|
s.append(QString::fromLocal8Bit(" ïî "));
|
|
s.append(QString::number(ao->numer+1));
|
|
s.append(" ZZ 33 ");
|
|
s.append(QString::fromLocal8Bit("'Áåçóñë. çàïðåò ñòðåëüáû'"));
|
|
// ((Widget*)parent())->addLogText(s);
|
|
((Widget*)parent())->sendCU(i+1, 33, ao->uid);
|
|
}
|
|
else
|
|
{
|
|
ao->clearCU(i+1);
|
|
((Widget*)parent())->sendCU(i+1, 99, ao->uid);
|
|
p->setStyleSheet("background-color: rgb(220, 220, 220)");
|
|
}
|
|
tmr->start(500);
|
|
|
|
}
|