#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<pushButton<pushButton_2<pushButton_3 <pushButton_4<pushButton_5<pushButton_6; pbKZS.clear(); pbKZS<pushButton_7<pushButton_8<< ui->pushButton_9 <pushButton_10<pushButton_11<pushButton_12; lbParam.clear(); lbParam <label_36<label_37<label_38 <label_39<label_40<label_41<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); }