145 lines
3.1 KiB
C++
145 lines
3.1 KiB
C++
|
#include "upravview.h"
|
||
|
#include <QTimer>
|
||
|
|
||
|
upravView::upravView(QWidget *parent) :
|
||
|
QGraphicsView(parent)
|
||
|
{
|
||
|
|
||
|
|
||
|
}
|
||
|
|
||
|
void upravView::msTick()
|
||
|
{
|
||
|
qDebug("1234");
|
||
|
|
||
|
|
||
|
}
|
||
|
|
||
|
|
||
|
void upravView::drawBackground(QPainter *painter, const QRectF &rect)
|
||
|
{
|
||
|
|
||
|
painter->save();
|
||
|
painter->setBrush(QBrush(Qt::darkGray));
|
||
|
painter->drawRect(rect);
|
||
|
painter->restore();
|
||
|
painter->setPen(Qt::lightGray);
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
}
|
||
|
|
||
|
|
||
|
void upravView::drawForeground(QPainter *painter, const QRectF &rect)
|
||
|
{
|
||
|
QPointF p1, p2, p;
|
||
|
p1 = rect.topLeft();
|
||
|
p2 = rect.bottomRight();
|
||
|
painter->setPen(Qt::lightGray);
|
||
|
|
||
|
QBrush br = painter->brush();
|
||
|
br.setStyle(Qt::SolidPattern);
|
||
|
br.setColor(Qt::darkGray);
|
||
|
painter->setBrush(br);
|
||
|
|
||
|
painter->drawRect(p1.x(),p1.y(), rect.width(), 59);
|
||
|
|
||
|
for (int i=69; i<380;i+=45)
|
||
|
{
|
||
|
|
||
|
painter->drawLine(i, p1.y(), i,p1.y()+60);
|
||
|
}
|
||
|
|
||
|
|
||
|
|
||
|
groundObj* me = obj->at(0);
|
||
|
|
||
|
int targetsCount = 0;
|
||
|
int acAbRock = 0;
|
||
|
int acAbAll = 0;
|
||
|
for (int i=0; i< tar->count(); i++) if (tar->at(i)->exist) targetsCount++;
|
||
|
for (int i=1; i<obj->count(); i++)
|
||
|
if (obj->at(i)->exist)
|
||
|
{
|
||
|
if (obj->at(i)->boegotov)
|
||
|
{
|
||
|
// if (obj->at(i)->allR)
|
||
|
acAbRock++;
|
||
|
acAbAll+=obj->at(i)->activeR;
|
||
|
}
|
||
|
}
|
||
|
|
||
|
QImage pic = me->pic;
|
||
|
pic.setColor(0, QColor(Qt::cyan).rgb());
|
||
|
QRectF r(p1.x()+25, p1.y()+10, 30, 30);
|
||
|
painter->drawImage(r, pic);
|
||
|
|
||
|
QFont f=painter->font();
|
||
|
f.setPointSize(12);
|
||
|
painter->setFont(f);
|
||
|
|
||
|
painter->setPen(Qt::yellow);
|
||
|
painter->drawText(p1.x(), p1.y()+20, QString::number(targetsCount));
|
||
|
painter->drawText(p1.x()+60, p1.y()+20, QString::number(acAbRock));
|
||
|
painter->drawText(p1.x()+55, p1.y()+50, QString::number(acAbAll));
|
||
|
|
||
|
|
||
|
|
||
|
for (int i=1; i<7; i++)
|
||
|
{
|
||
|
me = obj->at(i);
|
||
|
if (me->exist)
|
||
|
{
|
||
|
pic = me->pic;
|
||
|
if (me->boegotov)
|
||
|
{
|
||
|
pic.setColor(0, QColor(Qt::cyan).rgb());
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
pic.setColor(0, QColor(Qt::red).rgb());
|
||
|
}
|
||
|
QRectF r(p1.x()+75+45*(i-1), p1.y()+5, 28, 28);
|
||
|
painter->drawImage(r, pic);
|
||
|
|
||
|
|
||
|
painter->save();
|
||
|
painter->setPen(Qt::white);
|
||
|
p=r.topLeft();
|
||
|
p+=QPointF(-2, 7);
|
||
|
f.setPixelSize(12);
|
||
|
painter->setFont(f);
|
||
|
painter->drawText(p, tr("%1").arg(i));
|
||
|
|
||
|
painter->restore();
|
||
|
|
||
|
painter->setPen(Qt::green);
|
||
|
|
||
|
f.setPixelSize(11);
|
||
|
painter->setFont(f);
|
||
|
p=r.topRight();
|
||
|
p+=QPointF(2, 13);
|
||
|
|
||
|
|
||
|
if (me->activeR==0)
|
||
|
painter->setPen(Qt::red);
|
||
|
painter->drawText(p, tr("%1").arg(me->allR));
|
||
|
|
||
|
|
||
|
p+=QPointF(0, 15);
|
||
|
painter->drawText(p, tr("%1").arg(me->activeR));
|
||
|
painter->setPen(Qt::white);
|
||
|
for (int k =0;k<4;k++)
|
||
|
painter->drawRect(QRectF(r.bottomLeft()+QPointF(9*k,5), QSizeF(7,7)));
|
||
|
}
|
||
|
}
|
||
|
|
||
|
}
|
||
|
|
||
|
|
||
|
void upravView::mouseReleaseEvent(QMouseEvent *e)
|
||
|
{
|
||
|
e->accept();
|
||
|
}
|