Exemplo n.º 1
0
void Main::addText()
{
    QGraphicsTextItem* i = canvas.addText("QCanvasText");
    i->setFlag(QGraphicsItem::ItemIsMovable);
    i->setPos(qrand()%int(canvas.width()),qrand()%int(canvas.height()));
    i->setZValue(qrand()%256);
}
Exemplo n.º 2
0
  HelpText(MyScene *scene){
    QFont font = g_editor->main_window->font();
    font.setPointSize(15);
    font.setPixelSize(15);

    // When is this text shown?
    _text = scene->addText(
                           // "* Add objects with right mouse button\n"
                           "* Move objects with right mouse button.\n"
                           "\n"
                           "* Double-click the name of an object to open GUI. (only if there is one)\n"
                           "\n"
                           "* Delete objects or connections by pressing SHIFT and click left.\n"
                           "  - Alternatively, click with middle mouse button.\n"
                           "\n"
                           "* Select more than one object by holding CTRL when clicking.\n"
                           "  - Alternatively, mark an area of objects with left mouse button.\n"
                           "\n"
                           "* To autoconnect a new object to an existing object, right click at the input or output of an existing object.\n"
                           "\n"
                           "* Zoom in and out by pressing CTRL and using the scroll wheel.\n"
                           ,
                           font);

    _text->setDefaultTextColor(get_qcolor(HIGH_BACKGROUND_COLOR_NUM).light(70));
    _text->setPos(-150,-150);
    _text->setZValue(-1000);

    setSingleShot(true);
    setInterval(1000*60);
    start();
  }
Exemplo n.º 3
0
void GameManager::endGame()
{
	end++;
	if(end == NUM_PILES_BASE)
	{
		QFont font("Dejavu", 24, QFont::Bold);
		QGraphicsTextItem *endGameText = scene->addText(trUtf8("Вы выйграли!!!"), font);
		QRectF rc = endGameText->boundingRect();
		endGameText->setPos(rc.x() - rc.center().x(), rc.y() - rc.center().y());
		endGameText->setDefaultTextColor(QColor(255, 255, 0));
		endGameText->setZValue(100);
	}
}
Exemplo n.º 4
0
QGraphicsTextItem* TlinearChart::getTextItem(int fontSize) {
	QGraphicsTextItem *item = new QGraphicsTextItem();
	QFont f;
	f.setPixelSize(fontSize);
	item->setFont(f);
	QColor C(palette().text().color());
	C.setAlpha(75);
	Tcolor::merge(C, palette().base().color());
	item->setDefaultTextColor(C);
	scene->addItem(item);
	item->setZValue(15);
	return item;
}
Exemplo n.º 5
0
void GameScene::displayPoints(long p_wonPoints, qreal p_xPos, qreal p_yPos)
{
    // Launch a singleShot timer
    QTimer::singleShot(1000, this, SLOT(hidePoints()));

    // Add a label in the list of won points Labels
    m_wonPointsLabels.prepend(new QGraphicsTextItem(QString::number(p_wonPoints)));
    addItem(m_wonPointsLabels.first());

    // Temporary reference to the first item in the list
    QGraphicsTextItem *tempRef = m_wonPointsLabels.first();

    // Positioning and customization of the point label
    tempRef->setDefaultTextColor(QColor(QLatin1Literal("#FFFF00")));
    tempRef->setFont(QFont(QLatin1Literal("Helvetica"), 15, QFont::Normal, false));
    tempRef->setPos(p_xPos - (tempRef->boundingRect().width() / 2), p_yPos - (tempRef->boundingRect().height() / 2));
    tempRef->setZValue(-1);
}
Exemplo n.º 6
0
QGraphicsRectItem* JourGraphicScene::ajouterEvenement(const QString &titre, const QTime &deb,
                                                      const Duree &dur, Evenement*e, const QColor& coul_fond, const QColor& coul_contour)
{

    // affichage du rectangle
    int mins_ecoulees = -deb.secsTo(QTime(6,0)) / 60;
    QTime fin = deb;
    fin = fin.addSecs(dur.getDureeEnMinutes() * 60);

    qreal y = ( hauteur / nb_minutes ) * mins_ecoulees;
    qreal h = ( hauteur / nb_minutes ) * dur.getDureeEnHeures()*60;

    EvenementGraphicItem *tache = new EvenementGraphicItem(-2,y-1,largeur+3,h+1,e);
    tache->setPen(QPen(coul_contour));
    tache->setBrush(QBrush(coul_fond));
    QGraphicsScene::addItem(tache);
    tache->setFlag(QGraphicsItem::ItemIsSelectable);
    tache->setZValue(1);


    // affichage du texte dans le rectangle
    int Xtxt = 0,Ytxt = y;
    QString s;
    if(dur.getDureeEnMinutes()<30)
        return 0;
    else if(dur.getDureeEnMinutes()<75)
    {
        Xtxt = -3;
        Ytxt = y - 3;
        s = deb.toString("hh:mm") + "   -   " + fin.toString("hh:mm");
    }else if(dur.getDureeEnMinutes() >= 75)
        s = deb.toString("hh:mm") + "   -   " + fin.toString("hh:mm") + "\n" + titre;
    else
        s = deb.toString("hh:mm") + "   -   " + fin.toString("hh:mm");

    QGraphicsTextItem *txt = QGraphicsScene::addText(s,QFont("Helvetica",8));
    txt->setDefaultTextColor(QColor("black"));
    txt->setTextWidth(95);
    txt->setX(Xtxt);
    txt->setY(Ytxt);
    txt->setZValue(2);

    return tache;
}
void PSV_CircularIndicatorItem::drawMark(int zValue)
{
    double colorCircleRadius = m_colorCircleRadiusRatio * m_outerRadius;
    double value= m_min;
    double dValue = (m_max - m_min) / m_numTicks;
    QString strValue;
    for(int i=0;i<=m_numTicks;i++)
    {
        QPointF topPot;
        QPointF bottomPot;

        if(i%10==0)
        {
            strValue=QObject::tr("%1").arg(value);
            bottomPot = QPointF(m_rect.center().x(), m_rect.center().y() - colorCircleRadius);
            topPot = QPointF(m_rect.center().x(), m_rect.center().y() - colorCircleRadius*1.05);
            value+=10 * dValue;
            QGraphicsTextItem* item = new QGraphicsTextItem(strValue, this);
            item->setDefaultTextColor(QColor(Qt::white));
            item->setFont(m_markFont);
            item->setZValue(zValue);
            QRectF rectF = item->boundingRect();
            QPointF movePointF = QPointF(m_rect.center().x() - 0.5 * rectF.width()
                                         , m_rect.center().y() - colorCircleRadius*1.05 - rectF.height());
            item->moveBy(movePointF.x(), movePointF.y());
            item->setTransform(QTransform().translate(m_rect.center().x() - movePointF.x(), m_rect.center().y() - movePointF.y()).rotate(270 * i / 100-135).translate(-(m_rect.center().x() - movePointF.x()), -(m_rect.center().y() - movePointF.y())));
        }
        else if(i%5==0)
        {
            bottomPot = QPointF(m_rect.center().x(), m_rect.center().y() - colorCircleRadius);
            topPot = QPointF(m_rect.center().x(), m_rect.center().y() - colorCircleRadius*1.03);
        }
        else
        {
            bottomPot = QPointF(m_rect.center().x(), m_rect.center().y() - colorCircleRadius);
            topPot = QPointF(m_rect.center().x(), m_rect.center().y() - colorCircleRadius*1.01);
        }
        QGraphicsLineItem* item = new QGraphicsLineItem(QLineF(topPot, bottomPot), this);
        item->setPen(QPen(Qt::white));
        item->setZValue(zValue);
        item->setTransform(QTransform().translate(m_rect.center().x(), m_rect.center().y()).rotate(270.0 * i / 100-135).translate(-m_rect.center().x(), -m_rect.center().y()));
    }
}
Exemplo n.º 8
0
void QGraphicsVolumeView::updateDisplay(int volumeId) {
    if (this->isHidden()) {
        return;
    }
    
    if (_airImages == NULL) {
        return;
    }

    _currentSliceMarker = NULL;

    QFont sliceIndexFont("Courier", 20);

    int showingVolumeCount = _showAll ? _airImages->Count() : 1;
    for (int id = 0; id < showingVolumeCount; id++) {
        AIRImageDisplay src = _airImages->at(id);
        if (_volumeDisplays.size() <= id) {
            _volumeDisplays.push_back(AIRVolumeDisplay());
        }
        if (!_volumeDisplays[id].Has(src)) {
            _volumeDisplays[id].SetDisplay(src);
        }
        if (_volumeDisplays[id].UpdateSlice(_directionCache, _useNavigationImage)) {
            const int w = _volumeDisplays[id].Width();
            const int h = _volumeDisplays[id].Height();
            const int s = _volumeDisplays[id].Count();

            for (int i = 0; i < s; i++) {
                int realSliceIdx = i;
                int colPos = i * w;
                int rowPos = id * h;

                QGraphicsRectItem* item = _volumeDisplays[id].GetSliceData<QGraphicsRectItem>(i);
                QGraphicsPixmapItem* pixmapItem = NULL;
                uchar* colorPointer = _volumeDisplays[id].GetColorImageBuffer(i);

                QPixmap pixmap = QPixmap::fromImage(QImage(colorPointer, w, h, QImage::Format_ARGB32));
                if (item == NULL) {
                    item = new QGraphicsRectItem(QRect(0, 0, w, h));
                    item->setPen(Qt::NoPen);
                    item->setBrush(Qt::NoBrush);
                    item->setPos(colPos, rowPos);
                    item->setData(SliceIndex, QVariant(i));
                    item->setData(AnnotationType, QVariant(SliceImage));
                    item->setData(RealSliceIndex, QVariant(realSliceIdx));

                    pixmapItem = new QGraphicsPixmapItem(QPixmap::fromImage(QImage(_volumeDisplays[id].GetColorImageBuffer(i), w, h, QImage::Format_ARGB32)), item);
                    pixmapItem->setZValue(1);

                    QGraphicsTextItem* text = new QGraphicsTextItem(QString("#%1.%2").arg(id).arg(realSliceIdx), item);
                    text->setFont(sliceIndexFont);
                    text->setPos(3, 3);
                    text->setZValue(2);
                    text->setDefaultTextColor(Qt::yellow);

                    _volumeDisplays[id].SetSliceData(i, item);
                    scene()->addItem(item);
                } else {
                    QGraphicsPixmapItem* pixmapItem = (QGraphicsPixmapItem*) item->childItems()[0];
                    pixmapItem->setPixmap(pixmap);
                }

                if (_workingSet.contains(i)) {
                    addWorkingSetItem(item);
                }
            }
        }
    }
    updatePixmaps();
}
Exemplo n.º 9
0
void RayDisplayScene::lightenSender(int senderId, const int &angle)
{
	clearRayNumbers();
	QVector<QLineF> &senderCollidedRays = clearCollidedRays(senderId);
	clearTriangles();
	QVector<Ray> senderRays;
	senderRays.reserve(10);
	for (int i = 1; i < mSidedReceivers.size(); i++) {
		const int sideIdx = (mSenders.at(senderId).side + i) % mSidedReceivers.size();
		for (int j = 0; j < mSidedReceivers.at(sideIdx).size(); j++) {
			QLineF line(mSenders.at(senderId).r->pos(), mSidedReceivers.at(sideIdx).at(j)->pos());
			int lineAngle = int(line.angle()) - mSenders.at(senderId).rotation;
			if ((lineAngle > -angle / 2 && lineAngle < angle / 2) || (lineAngle - 360 > -angle / 2 && lineAngle - 360 < angle / 2)) {
				QGraphicsTextItem *rayNumber;
				rayNumber = addText(QString::number(senderRays.size()));
				rayNumber->setPos(line.p2());
				rayNumber->setZValue(3);
				mRayNumbers << rayNumber;
				senderRays << Ray{line, true, (j == 0) || (j == mSidedReceivers.at(sideIdx).size() - 1) /* corner ray */};
			}
		}
	}
	for (int i = 0; i < senderRays.size(); i++) {
		QGraphicsLineItem *r = nullptr;
		if (!mCollisionEnabled || mCircles.size() <= 1) {
			r = addLine(senderRays.at(i).line, QPen(QBrush(Qt::blue), 1));
		} else {
			/*const int size = mObstacle.size();
			for (int j = 0; j < size; j++) {
				QLineF obsLine(mObstacle.at(j), mObstacle.at((j + 1) % size));
				if (senderRays.at(i).line.intersect(obsLine, nullptr) == QLineF::BoundedIntersection) {
					senderRays[i].visible = false;
					break;
				}
			}*/
			const int size = mCircles.size();
			for (int j = 0; j < size; j++) {
				if (pointToLineDistSquared(mCircles.at(j).center, senderRays.at(i).line) <= mCircles.at(j).radius * mCircles.at(j).radius) {
					senderRays[i].visible = false;
					break;
				}
			}
			if (senderRays.at(i).visible) {
				r = addLine(senderRays.at(i).line, QPen(QBrush(Qt::blue), 1));
			}
		}
		if (r != nullptr) {
			mRays.append(r);
		}
	}
	// add border rays of another colour
	if (senderRays.size() > 0) {
		QGraphicsLineItem *r = nullptr;
		// first
		{
			r = addLine(senderRays.at(0).line, QPen(QBrush(Qt::yellow), 1));
			mRays.append(r);
		}
		// last
		if (senderRays.size() > 1/* && !senderRays.at(senderRays.size() - 1).visible*/) {
			//senderCollidedRays << senderRays.at(senderRays.size() - 1).line;
			r = addLine(senderRays.at(senderRays.size() - 1).line, QPen(QBrush(Qt::yellow), 1));
			mRays.append(r);
		}
		// on every state change
		for (int i = 1; i < senderRays.size() - 1; i++) {
			if (!senderRays.at(i).visible && (senderRays.at(i - 1).visible || senderRays.at(i + 1).visible)) {
				senderCollidedRays << senderRays.at(i).line;
				r = addLine(senderRays.at(i).line, QPen(QBrush(Qt::red), 1));
				mCollidedRaysGraphics[senderId] << r;
			}
		}
	}

	// ******************************
	// -----8<------8<-------8<------

	//cv::Mat cvImage = cvtrack1(senderId, senderRays);

	//cv::imshow(QString(QString("plepleple ")/* + QString::number(senderId)*/).toStdString(), cvImage);
	/*for (int i = 0; i < mCvPolygons.size(); i++) {
		for (int j = 0; j < mCvPolygons.at(i).size(); j++) {
			cv::fillConvexPoly(cvImage, cvPoints.constData(), cvPoints.size(), cv::Scalar(127));
		}
	}*/

	//cvTrack2(cvImage);

	updateCollisions();
}
Exemplo n.º 10
-1
    void WeekScene::addCalendar()
    {
        const KCalendarSystem* cal = KGlobal::locale()->calendar();

        QGraphicsTextItem* tmp = addText("Dinges");
        QFontMetricsF fm(tmp->font());
        removeItem(tmp);
        delete tmp;


        // first add 7 rectangles for each day of the week
        xoff = fm.width("00:00") + 10;
        yoff = 2 * fm.height() + 10;
        day_width = LongestDayWidth(fm) * 1.5;
        hour_height = fm.height() * 1.5;

        status = addText(i18n("Current schedule:"));
        status->setPos(QPointF(0, 0));
        status->setZValue(2);

        QPen pen(SchedulerPluginSettings::scheduleLineColor());
        QBrush brush(SchedulerPluginSettings::scheduleBackgroundColor());

        for (int i = 0; i < 7; i++)
        {
            QGraphicsRectItem* item = addRect(xoff + day_width * i, yoff, day_width, 24 * hour_height, pen, brush);
            item->setZValue(1);

            QString day = cal->weekDayName(i + 1);

            // make sure day is centered in the middle of the column
            qreal dlen = fm.width(day);
            qreal mid = xoff + day_width * (i + 0.5);
            qreal start = mid - dlen * 0.5;

            QGraphicsTextItem* t = addText(day);
            t->setPos(QPointF(start, fm.height() + 5));
            t->setZValue(2);

            rects.append(item);
        }

        // draw hour lines
        for (int i = 0; i <= 24; i++)
        {
            QGraphicsLineItem* item = addLine(0, yoff + i * hour_height, xoff + 7 * day_width, yoff + i * hour_height, pen);
            item->setZValue(2);

            if (i < 24)
            {
                QGraphicsTextItem* t = addText(QString("%1:00").arg(i));
                t->setPos(QPointF(0, yoff + i * hour_height));
                t->setZValue(2);
            }
            lines.append(item);
        }

        ;
        gline[0] = new GuidanceLine(xoff, yoff, xoff + 7 * day_width + 10);
        gline[0]->setVisible(false);
        gline[1] = new GuidanceLine(xoff, yoff, xoff + 7 * day_width + 10);
        gline[1]->setVisible(false);
        addItem(gline[0]);
        addItem(gline[1]);

        QRectF r = sceneRect();
        r.setHeight(r.height() + 10);
        setSceneRect(r);
    }