void MenuEquipmentScreen::initialize(BattleCharacterItem *character, Inventory *inventory) {
	QFont font("Times", 12, QFont::Bold);
	QBrush brush(Qt::white);
	_state = EQUIPPED_SELECTION;

	// Set character and inventory
	_character = character;
	_inventory = inventory;

	// Set the character's equipment
	QPointF position(_equippedEquipmentItem->pos().x(), _equippedEquipmentItem->pos().y() + 40);

	QStringList equipmentHeaders;
	equipmentHeaders << "Main Hand: " << "Off Hand: "
		<< "Helmet: " << "Torso: " << "Leggings: " << "Gloves: " << "Boots: "
		<< "Earring: " << "Necklace: " << "Ring: ";
	QVector<EquipmentPiece*> equipment = _character->getEquipment()->getEquipment();
	_currentEquippedEquipmentPiece = equipment.at(0);
	_equippedEquipmentItem->setText("Equipment of " + _character->getName());

	for (int i = 0; i < equipment.size(); i++) {
		QString itemText;
		itemText.append(equipmentHeaders.at(i));
		
		if (!!equipment.at(i))
			itemText.append(equipment.at(i)->getName());

		QGraphicsSimpleTextItem *item = new QGraphicsSimpleTextItem(this);
		item->setText(itemText);
		item->setBrush(brush);
		item->setFont(font);
		item->setPos(position);

		_equippedEquipmentItems.append(item);
		position.setY(position.y() + 20);
	}

	setCurrentEquippedItem(_equippedEquipmentItems.at(0), equipment.at(0));

	// Set Image
	if (_character->getCharacter()->getBattleImage().second != QString()) {
		QPixmap battlerImage = _character->getCharacter()->getBattleImage().first;

		if ((battlerImage.width() > _characterImage->boundingRect().width()) || (battlerImage.height() > _characterImage->boundingRect().height()))
			battlerImage = battlerImage.scaled(QSize(200, 200), Qt::KeepAspectRatio);
		
		QPixmap frame(200, 200);
		frame.fill(Qt::transparent);
		QPainter painter(&frame);
		painter.setCompositionMode(QPainter::CompositionMode_SourceOver);

		QPoint position(0, 0);
		position.setX(frame.width()/2 - battlerImage.width()/2);
		position.setY(frame.height()/2 - battlerImage.height()/2);
		painter.drawPixmap(position, battlerImage);
		painter.end();

		_characterImage->setPixmap(frame);
		
	} else {
		QPixmap image(200, 200);
		image.fill(Qt::transparent);
		_characterImage->setPixmap(image);
	}
}
Exemple #2
0
bool DiagramScene::showGrid()
{
    if(maxvaluey==minvaluey)
        maxvaluey=minvaluey+10;

    int split = 10;
    qreal xsteps = (maxvaluey-minvaluey)/4;
    QFont font;
    font.setPointSizeF((maxvaluey-minvaluey)*2*(prec/100));

    grid = new QGraphicsLineItem();
    //mouseline
    mouseline = new QGraphicsLineItem(minvaluex*prec,-minvaluey*prec,minvaluex*prec,-maxvaluey*prec);
    addItem(mouseline);

    QGraphicsLineItem *yline = new QGraphicsLineItem(minvaluex*prec,-maxvaluey*prec,minvaluex*prec,-minvaluey*prec,grid);
    Q_UNUSED(yline);
    qreal stepsize = (maxvaluey-minvaluey)/split;

    //y-axe
    for(qreal value=minvaluey + stepsize; value <= maxvaluey; value=value+stepsize)
    {
        QGraphicsSimpleTextItem *text = new QGraphicsSimpleTextItem ( QString::number(value*yscale), grid);
        text->setPos((minvaluex*prec+(maxvaluey-minvaluey)/100)*prec,-value*prec);
        text->setFont(font);
    }

    xaxes = new QGraphicsLineItem(grid);
    //x-axe
    QGraphicsLineItem *xline = new QGraphicsLineItem(minvaluex*prec,-minvaluey*prec,maxvaluex*prec,-minvaluey*prec,xaxes);
    Q_UNUSED(xline);

    for(qreal value=minvaluex; value < maxvaluex; value=value+xsteps)
    {
        QGraphicsSimpleTextItem *text = new QGraphicsSimpleTextItem ( QString::number(value), xaxes);
        text->setFont(font);
        qreal th = text->boundingRect().bottomLeft().y()-text->boundingRect().topLeft().y();
        text->setPos(value*prec+(minvaluex+(maxvaluey-minvaluey)/100)*prec, -minvaluey*prec-th);
    }

    //draw legend
    legend.clear();

    for(int index=0; index < data.size(); index++)
    {
        legend.push_back(new QGraphicsSimpleTextItem (data.keys().at(index), mouseline));
        legend[index]->setFont(font);
        qreal th = legend[index]->boundingRect().bottomLeft().y()-legend[index]->boundingRect().topLeft().y();
        QGraphicsRectItem *rect = new QGraphicsRectItem( (minvaluex*prec+((maxvaluey-minvaluey)/100)*3)*prec, -maxvaluey*prec + index*th*1.5 , th,th, mouseline);
        QBrush brush( QColor(((index+1)*948)%200+50,((index+1)*123)%200+50,((index+1)*11)%200+50));
        rect->setBrush(brush);
        legend[index]->setPos((minvaluex*prec+((maxvaluey-minvaluey)/100)*8)*prec,-maxvaluey*prec + index*th*1.5 );
    }

    addItem(grid);
    return true;
}
SubdRepresentation::SubdRepresentation(Rectangle rect, Crop& crop, QDate date) :
    rect(rect), crop(crop)
{
    this->setRect(get_rect().get_x(), - get_rect().get_y() - get_rect().get_height(),
                  get_rect().get_width(), get_rect().get_height());
    if (crop)
    {
        Plant& plant = crop.get_plant();
        QString text = toQString(plant.get_name());
        //text = re.sub("\s+", "\n", text)
        QGraphicsSimpleTextItem *textw =  new QGraphicsSimpleTextItem(text);
        QFont font = textw->font();
        font.setPointSize(6);
        font.setWeight(25);
        textw->setFont(font);
        center_text(textw, this->boundingRect());
        textw->setParentItem(this);
        QString color_str = toQString(plant.get_color_str());
        if (color_str == "") { color_str = "#FF00FF"; }
        QColor color = QColor(color_str);
        if (crop.is_planned_at_date(fromQDate(date)) && !crop.is_active_at_date(fromQDate(date)))
        {
            this->setBrush(QBrush(color, Qt::BDiagPattern));
        }
        else
        {
            this->setBrush(QBrush(color));
        }
    }
}
ModelItemGraphics::ModelItemGraphics(const QPointF& Coords, const QString& ID,
                                     QGraphicsItem* Parent):
  QGraphicsRectItem(Coords.x(),Coords.y(),m_DefaultSize.width(),m_DefaultSize.height(),Parent),
  m_ID(ID), m_Ghost(false), m_Initialized(false)
{
  setPen(QPen(QBrush(QColor(BUILDER_MODELVIEW_BORDERCOLOR)),2));

  setFlag(QGraphicsItem::ItemIsMovable);
  setFlag(QGraphicsItem::ItemSendsGeometryChanges, true);

  setCursor(QCursor(Qt::OpenHandCursor));


  // Model item ID
  QGraphicsSimpleTextItem* IDGraphics = new QGraphicsSimpleTextItem(ID,Parent);
  IDGraphics->setParentItem(this);

  QFont TmpFont = IDGraphics->font();
  TmpFont.setPointSize(10);
  IDGraphics->setFont(TmpFont);

  QRectF IDRect = IDGraphics->boundingRect();

  if (rect().width() < IDRect.width()+20)
  setRect(Coords.x(),Coords.y(),IDRect.width()+20,m_DefaultSize.height());

  IDGraphics->setPos((rect().width()/2)-(IDRect.width()/2),(m_DefaultSize.height()/2)-(IDRect.height()/2));
}
Exemple #5
0
void controlGraph::drawFixedPoints() {
    QHash<QString, fixedPoint>::iterator i;
    QHash<QString, bGraphicsEllipseItem*>::iterator ii;

    for (ii = elliseFixedPointHash.begin(); ii != elliseFixedPointHash.end(); ++ii)delete ii.value();
    elliseFixedPointHash.clear();

    for (i = fixedPoints->begin(); i != fixedPoints->end(); ++i) {
        bGraphicsEllipseItem *e = new bGraphicsEllipseItem(0);
        scene.addItem(e);
        e->setRect(1.0 * (i->panValue -  rangeMinPan) * scene.width() / visibleRangePan - 15, scene.height() - 1.0 * (i->tiltValue -  rangeMinPan) * scene.height() / visibleRangeTilt - 15 , 30, 30 );
        e->setBrush(QBrush(QColor("#d3f9fe")));
        if(i->timelapseMember == 1)e->setBrush(QBrush(QColor("#19c6ee")));
        e->setZValue(1);

        QGraphicsSimpleTextItem *et = new QGraphicsSimpleTextItem(e);
        et->setPos(1.0 * (i->panValue - rangeMinTilt) * scene.width() / visibleRangePan - 20, scene.height() - 1.0 * (i->tiltValue - rangeMinTilt) * scene.height() / visibleRangeTilt - 30);
        et->setFont(QFont("Calibri", 14, QFont::Normal));

        et->setText(i->name);
        et->setZValue(1);

        elliseFixedPointHash.insert(i.key(), e);
    }
}
void GameArena::slotMapWinner(qint8 playerId, bool end) {
    QFont bigText;
    bigText.setPointSize(32);
    bigText.setWeight(QFont::Bold);

    QGraphicsSimpleTextItem* textOver = new QGraphicsSimpleTextItem();
    if(playerId == -1)
        textOver->setText("DRAW GAME!");
    else
        textOver->setText(QString("PLAYER ") + QString::number(playerId + 1) + QString(" WINS!"));
    textOver->setFont(bigText);
    textOver->setZValue(1.0);

    scene->addItem(textOver);

    QGraphicsSimpleTextItem* text2 = new QGraphicsSimpleTextItem();
    text2->setText(textOver->text());
    text2->setFont(bigText);
    text2->setZValue(0.9);
    text2->setX(text2->x() + 1);
    text2->setY(text2->y() + 1);
    text2->setBrush(QBrush(Qt::white));

    scene->addItem(text2);
}
Exemple #7
0
NodeGui::NodeGui(unsigned int id, std::string name)
    : QGraphicsEllipseItem(-35 - ADJUST, -10 - ADJUST, 70 + ADJUST, 20 + ADJUST),
      id_(id),
      name_(name),
      abbrev_(QString::fromStdString(name)),
      nodeColor(Qt::gray),
      secondNodeColor(Qt::gray),
      colorFixed(false)
{
    setFlag(ItemIsMovable);
    setFlag(ItemSendsGeometryChanges);
    setCursor(Qt::ArrowCursor);
    setAcceptHoverEvents(true);
    setZValue(-1);

    if (name.size() > 12){
        setToolTip(abbrev_);
    }

    if (abbrev_.size() > 12){
        abbrev_.resize(12);
        for (int i = 10; i<12; i++){
            abbrev_[i]='.';
        }
    }

	QGraphicsSimpleTextItem* child = new QGraphicsSimpleTextItem(this);
	QFont f("Monospace", 6);
	child->setFont(f);
	child->setText(abbrev_);
	child->setPos(getStart(abbrev_), - QFontMetrics(f).height() / 2.f);

	setColors(nodeColor, secondNodeColor);
}
Exemple #8
0
QGraphicsItem* CGraphicsTextItem::createItem()
{
	QGraphicsSimpleTextItem* pItem = new QGraphicsSimpleTextItem(m_Parent);
	QFont font;
	//字体宽度
	font.setWeight(GET_VALUE(p_FontWidth).toInt());
	//字体大小
	font.setPixelSize(GET_VALUE(fs).toInt());
	//字间距
	font.setWordSpacing(GET_VALUE(p_FontInterval).toInt());
	//字体高度
	//字体类型
	QString strFamily(GET_VALUE(ff));

	if (!strFamily.isEmpty())
	{
		font.setFamily(strFamily);
	}

	pItem->setFont(font);

	//字体颜色
	QPen pen;
	QStringList lstLc = GET_VALUE(lc).split(',');
	pen.setColor(QColor::fromRgb(lstLc[0].toInt(),lstLc[1].toInt(),lstLc[2].toInt()));
	pItem->setPen(pen);

	pItem->setText(GET_VALUE(ts));
	return pItem;

}
Exemple #9
0
QGraphicsItem* TextContent::createGraphicsItem(const QRectF& rect)
{

    QFile   file(_url);
    if(!file.open(QIODevice::ReadOnly))
        throw 0;

    int rectHeight = rect.height();

    QTextStream in(&file);
    QString text (in.readAll());

    QGraphicsSimpleTextItem* item = new QGraphicsSimpleTextItem();
    // measuring text
    QFont newFont( item->font() );
    newFont.setStyleStrategy( QFont::OpenGLCompatible );
    int textSize = 0;
    int textHeightInPixels = 1;
    while(textHeightInPixels < rectHeight)
    {
        ++textSize;
        newFont.setPointSize(textSize);
        QFontMetrics fm(newFont);
        fm.width(text);
        textHeightInPixels = fm.height();
    }

    newFont.setPointSize( textSize-1 );
    item->setFont( newFont );
    item->setText( text );

    return item;
}
void EffectItemBase::createText(const QString &text)
{
    QGraphicsSimpleTextItem * textItem = new QGraphicsSimpleTextItem(text, this);
    QFont font = textItem->font();
    font.setPointSize(FontSize);
    textItem->setFont(font);
    QRectF textBox = textItem->boundingRect();
    QPointF offset = rect().center() - textBox.center();
    textItem->translate(offset.x(), offset.y());
}
void MenuEquipmentScreen::equippedItemSelected() {
	// Reset updated stats and equipment list
	_updatedStatsItem->setText(QString());
	for (int i = 0; i < _updatedStatsItems.size(); i++)
		delete _updatedStatsItems.at(i);
	_updatedStatsItems.clear();

	_equipmentList.clear();
	_equipmentStringList.clear();
	_currentSelectedEquipmentString = 0;
	_currentEquipmentListItem = 0;
	_equipmentListItem->setText(QString());
	for (int i = 0; i < _activeEquipmentListItems.size(); i++)
		delete _activeEquipmentListItems.at(i);
	_activeEquipmentListItems.clear();

	// Build the equipmentlist
	QVector<QPair<EquipmentPiece*, int>> equipment = _inventory->getEquipment();
	for (int i = 0; i < equipment.size();) {
		if (!equipmentFilter(equipment.at(i).first))
			equipment.remove(i);
		else {
			_equipmentList.append(equipment.at(i).first);
			i++;
		}
	}

	// Set the equipment list
	QFont font ("Times", 12, QFont::Bold);
	QBrush brush(Qt::white);
	QPointF position(_equipmentListItem->pos().x(), _equipmentListItem->pos().y() + 20);

	_currentSelectedEquipmentString = 0;
	_equipmentStringList.append(QString("Clear equipment slot"));
	for (int i = 0; i < _equipmentList.size(); i++)
		_equipmentStringList.append(_equipmentList.at(i)->getName());

	_equipmentListItem->setText("Select equipment:");
	for (int i = 0; i < qMin<int>(_equipmentStringList.size(), 8); i++) {
		QGraphicsSimpleTextItem *item = new QGraphicsSimpleTextItem(_equipmentListPanel);

		item->setBrush(brush);
		item->setFont(font);
		item->setText(_equipmentStringList.at(i));
		item->setPos(position);

		position.setY(position.y() + 20);
		_activeEquipmentListItems.append(item);
	}

	setCurrentEquipmentItem(_activeEquipmentListItems.first(), 0);
	_state = MenuEquipmentScreen::EQUIPMENT_SELECTION;
}
Exemple #12
0
GameProcessor::GameProcessor(YagwScene &ygws)
  : scene(ygws),
    player(0),
    disclaimer(0),
    gia(*this, ygws.width(), ygws.height(), player),
    cfg(ConfManager("config.cfg")),
    playerFire(0)
{
    QObject::connect(&scene, SIGNAL(newEntity(Entity*)), this, SLOT(loadEntity(Entity*)));
    QObject::connect(&scene, SIGNAL(newFire(Entity*)), this, SLOT(loadFire(Entity*)));
    QObject::connect(&scene, SIGNAL(phase2()), this, SLOT(advance()));
    GameProcessor::affDelimiters();
    QObject::connect(&scene, SIGNAL(forwardKeyPressEvent(QKeyEvent*)), this, SLOT(keyPressEvent(QKeyEvent*)));
    GameProcessor::createDisclaimer("Press RETURN to start");


    QGraphicsSimpleTextItem *txt = this->scene.addSimpleText("Lives:");
// attention on perd le pointeur. a changer.
    QFont font;
    QPen pen(Qt::red, 1, Qt::DashLine, Qt::RoundCap, Qt::RoundJoin);
    font.setBold(true);
    font.setPointSize(20);
    txt->setFont(font);
    txt->setBrush(Qt::red);
    txt->setPen(pen);
    txt->setPos(WINSIZE_X / 2  + 5,- WINSIZE_Y / 2 + 10);
    QString str("Score:\n");
    str += QString::number(Score::get_instance()->getScore()) + QString::fromAscii("\nMax:\n") + QString::number(Score::get_instance()->getMax());
    txt = this->scene.addSimpleText(str);
    txt->setFont(font);
    txt->setBrush(Qt::red);
    txt->setPen(pen);
    txt->setPos(WINSIZE_X / 2  + 5,- WINSIZE_Y / 2 + 200);
    this->score = txt;
    //GameProcessor::affGrid();
}
void MenuMainScreen::createOptions() {
	QFont font ("Times", 12, QFont::Bold);
	QBrush brush(Qt::white);

	QStringList options;
	options << "Character" << "Equipment" << "Abilities" << "Inventory" << "Exit";
	int x = 25, y = 40;
	for (int i = 0; i < options.size(); i++) {
		QGraphicsSimpleTextItem *item = new QGraphicsSimpleTextItem(options.at(i), _optionsPanel);
		item->setBrush(brush);
		item->setFont(font);
		item->setPos(x, y);
		_options.append(item);

		y += 30;
	}

	setCurrentOption(_options.at(0));
}
void MenuEquipmentScreen::setCurrentEquippedItem(QGraphicsSimpleTextItem *item, EquipmentPiece *equipment) {
	QBrush whiteBrush(Qt::white);
	QBrush yellowBrush(Qt::yellow);
	QFont font("Times", 12, QFont::Bold);

	if (!!_currentEquippedEquipmentItem)
		_currentEquippedEquipmentItem->setBrush(whiteBrush);

	_currentEquippedEquipmentItem = item;
	_currentEquippedEquipmentItem->setBrush(yellowBrush);
	_currentEquippedEquipmentPiece = equipment;

	// Reset the current selected equipped item
	_equippedStatsItem->setText(QString());
	for (int i = 0; i < _equippedStatsItems.size(); i++)
		delete _equippedStatsItems.at(i);
	_equippedStatsItems.clear();

	// If the current slot contains an equipment piece
	if (!!_currentEquippedEquipmentPiece) {
		QPointF position(_equippedStatsItem->pos().x(), _equippedStatsItem->pos().y() + 20);
		_equippedStatsItem->setText("Attributes of " + equipment->getName());
		QVector<QPair<Attribute*, int>> attributes = equipment->getAttributes();

		for (int i = 0; i < attributes.size(); i++) {
			QPair<Attribute*, int> it = attributes.at(i);
			QString itemText(it.first->getName() + " + " + QString::number(it.second));

			QGraphicsSimpleTextItem *item = new QGraphicsSimpleTextItem(_equipmentStatsPanel);

			item->setText(itemText);
			item->setBrush(whiteBrush);
			item->setFont(font);
			item->setPos(position);

			_equippedStatsItems.append(item);
			position.setY(position.y() + 20);
		}

	} else
		_equippedStatsItem->setText("No equipment selected");
}
Exemple #15
0
void HomeScreen::initSprite()
{
	_sprite = new QGraphicsWidget();

	QGraphicsItem* item;
	QGraphicsSimpleTextItem* text;
	QGraphicsProxyWidget* proxy;
	QLabel* label;
	QFont font;

	item = new QGraphicsPixmapItem();
	item->setParentItem(_sprite);
	item->setPos((BACKGROUND_W - (400.0f / 0.75f)) * 0.5f, BACKGROUND_H - 400.0f);
	_avatar = static_cast<QGraphicsPixmapItem*>(item);

	item = new QGraphicsPixmapItem(LoaderThread::instance()->getCachedPixmap(IMAGE_TITLE));
	item->setParentItem(_sprite);
	item->setPos(232.0f, 128.0f);

	font = QFont("Arial");
	font.setPixelSize(12);
	font.setWeight(QFont::Normal);
	font.setStretch(80);

	text = new QGraphicsSimpleTextItem("http://conanchen.com/Kinetris");
	text->setBrush(QColor::fromRgb(0xFF, 0xFF, 0xFF));
	text->setFont(font);
	text->setParentItem(_sprite);
	text->setPos(248.0f, 264.0f - 3.0f);

	label = new QLabel();
	label->resize(784, 24);
	label->setStyleSheet("background-color: transparent; color: #FFFFFF;");
	label->setAlignment(Qt::AlignTop | Qt::AlignHCenter);
	proxy = new QGraphicsProxyWidget();
	proxy->setParentItem(_sprite);
	proxy->setWidget(label);
	proxy->setPos(248.0f, 592.0f - 6.0f);
	_sprite_status = proxy;
	_status = label;
}
Exemple #16
0
/**
Either increments or decrements a life. Checks for game over.
@param choice Integer that determines whether life increments or decrements.
*/
void Game::life(int choice)
{
	QString temp = "";
	switch(choice) {
		case 0:
			lives--;
			gScene->removeItem(lAmount);
			temp = QString::number(lives);
			lAmount = new QGraphicsSimpleTextItem(temp);
			lAmount->setPos(70, 460);
			lAmount->setFont(font);
			lAmount->setZValue(2);
			gScene->addItem(lAmount);
			break;
		case 1:
			lives++;
			gScene->removeItem(lAmount);
			temp = QString::number(lives);
			lAmount = new QGraphicsSimpleTextItem(temp);
			lAmount->setPos(70, 460);
			lAmount->setFont(font);
			lAmount->setZValue(2);
			gScene->addItem(lAmount);
			break;
	}
	if(lives == 0) {
		QGraphicsSimpleTextItem *over = new QGraphicsSimpleTextItem("Game Over!");
		over->setPos(100, 225);
		QFont *fonto = new QFont;
		fonto->setPixelSize(50);
		over->setFont(*fonto);
		over->setZValue(3);
		gScene->addItem(over);
		timer->stop();
		overG = true;
	}
}
Exemple #17
0
void TerrainProfileGraph::drawHoverCursor(const QPointF& position)
{
  if (_hoverLine)
  {
    _scene->removeItem(_hoverLine);
    delete _hoverLine;
    _hoverLine = 0L;
  }

  if (_graphField.width() < 2 || _graphField.height() < 2)
    return;

  double xPos = position.x() < _graphField.x() ? _graphField.x() : (position.x() > _graphField.x() + _graphField.width() ? _graphField.x() + _graphField.width() : position.x());

  QLineF vLine(xPos, _graphField.y(), xPos, _graphField.y() + _graphField.height());

  QPointF* intersect = new QPointF;
  bool foundIntersect = false;
  for (int i=0; i < _graphLines.count(); i++)
  {
    if (vLine.intersect(_graphLines[i], intersect) == QLineF::BoundedIntersection)
    {
      foundIntersect = true;
      break;
    }
  }

  if (foundIntersect)
  {
    // Draw the upper line segment.  Also serves as the parent item.
    _hoverLine = new QGraphicsLineItem(xPos, _graphField.y(), xPos, intersect->y() - 3);
    _hoverLine->setPen(_hoverPen);
    _hoverLine->setZValue(OVERLAY_Z);
    _scene->addItem(_hoverLine);

    // Draw the box around the intersect point
    QGraphicsRectItem* hoverBox = new QGraphicsRectItem(xPos - 3, intersect->y() - 3, 6, 6);
    hoverBox->setPen(_hoverPen);
    hoverBox->setBrush(Qt::NoBrush);
    hoverBox->setZValue(OVERLAY_Z);
    hoverBox->setParentItem(_hoverLine);

    // Draw the lower line segment
    QGraphicsLineItem* lowerLine = new QGraphicsLineItem(xPos, intersect->y() + 3, xPos, _graphField.y() + _graphField.height() + 5);
    lowerLine->setPen(_hoverPen);
    lowerLine->setZValue(OVERLAY_Z);
    lowerLine->setParentItem(_hoverLine);

    // Draw the text and background
    double y = (1.0 - ((intersect->y() - _graphField.y()) / _graphField.height())) * (_graphMaxY - _graphMinY) + _graphMinY;
    int textOffset = 10;

    QGraphicsSimpleTextItem* hoverText = new QGraphicsSimpleTextItem(QString::number(y) + tr("m"));
    hoverText->setBrush(QBrush(_axesColor));
    hoverText->setFont(_graphFont);
    hoverText->setZValue(OVERLAY_Z);

    if (intersect->x() + textOffset + hoverText->boundingRect().width() < _graphField.x() + _graphField.width())
      hoverText->setPos(intersect->x() + textOffset, intersect->y() - hoverText->boundingRect().height());
    else
      hoverText->setPos(intersect->x() - textOffset - hoverText->boundingRect().width(), intersect->y() - hoverText->boundingRect().height());

    QGraphicsRectItem* hoverTextBackground = new QGraphicsRectItem(hoverText->x() - 3, hoverText->y() - 1, 
                                                                   hoverText->boundingRect().width() + 6,
                                                                   hoverText->boundingRect().height() + 1);
    hoverTextBackground->setPen(_axesPen);
    hoverTextBackground->setBrush(QBrush(_graphColor));
    hoverTextBackground->setZValue(OVERLAY_Z);
    hoverTextBackground->setParentItem(_hoverLine);

    hoverText->setParentItem(_hoverLine);

    // Update callback
    if (_positionCallback.valid())
    {
      double distanceFactor = ((xPos - _graphField.x()) / (double)_graphField.width());

      osg::Vec3d worldStart, worldEnd;
      _calculator->getStart(ALTMODE_ABSOLUTE).toWorld(worldStart);
      _calculator->getEnd(ALTMODE_ABSOLUTE).toWorld(worldEnd);

      double worldX = (worldEnd.x() - worldStart.x()) * distanceFactor + worldStart.x();
      double worldY = (worldEnd.y() - worldStart.y()) * distanceFactor + worldStart.y();
      double worldZ = (worldEnd.z() - worldStart.z()) * distanceFactor + worldStart.z();

      GeoPoint mapPos;
      mapPos.fromWorld(_calculator->getStart().getSRS(), osg::Vec3d(worldX, worldY, worldZ));

      _positionCallback->updatePosition(mapPos.y(), mapPos.x(), hoverText->text().toStdString());
    }
  }
  else
  {
    // No intersect found so just draw the full line at xPos
    _hoverLine = new QGraphicsLineItem(xPos, _graphField.y(), xPos, _graphField.y() + _graphField.height() + 5);
    _hoverLine->setPen(_hoverPen);
    _hoverLine->setZValue(OVERLAY_Z);
    _scene->addItem(_hoverLine);
  }

  // Draw distance text
  double x = ((xPos - _graphField.x()) / _graphField.width()) * _totalDistance;

  BoxedSimpleTextItem* distanceText = new BoxedSimpleTextItem(QString::number(x / 1000.0, 'f', 2) + tr("km"), _backgroundColor);
  distanceText->setBrush(QBrush(_axesColor));
  distanceText->setFont(_graphFont);
  distanceText->setZValue(OVERLAY_Z);
  if(xPos - 2 - distanceText->boundingRect().width() > _graphField.x())
  {
      distanceText->setPos(xPos - 2 - distanceText->boundingRect().width(), _graphField.y() + _graphField.height() + 2);
  }
  else
  {
      distanceText->setPos(xPos + 2, _graphField.y() + _graphField.height() + 2);
  }
  distanceText->setParentItem(_hoverLine);

  // Draw selection box
  drawSelectionBox(xPos);

  delete intersect;
}
void MenuEquipmentScreen::setCurrentEquipmentItem(QGraphicsSimpleTextItem *item, EquipmentPiece *equipment) {
	// Set brushes
	QBrush whiteBrush(Qt::white);
	QBrush yellowBrush(Qt::yellow);
	QBrush greenBrush(Qt::green);
	QBrush redBrush(Qt::red);
	QFont font("Times", 12, QFont::Bold);

	// Set current item
	if (!!_currentEquipmentListItem)
		_currentEquipmentListItem->setBrush(whiteBrush);

	_currentEquipmentListItem = item;
	_currentEquipmentListItem->setBrush(yellowBrush);

	// Reset the updated equipment stats
	_updatedStatsItem->setText(QString());
	for (int i = 0; i < _updatedStatsItems.size(); i++)
		delete _updatedStatsItems.at(i);
	_updatedStatsItems.clear();

	// Set the updated equipment stats
	QPointF position(_updatedStatsItem->pos().x(), _updatedStatsItem->pos().y() + 20);
	_updatedStatsItem->setText("Preview:");

	QVector<QPair<Attribute*, int>> currentEquipped(0);
	if (!!_currentEquippedEquipmentPiece)
		currentEquipped = _currentEquippedEquipmentPiece->getAttributes();

	QVector<QPair<Attribute*, int>> previewEquipped(0);
	if (!!equipment)
		previewEquipped = equipment->getAttributes();

	// First go over all of the currently equipped 
	// attributes for comparison.
	for (int i = 0; i < currentEquipped.size(); i++) {
		QPair<Attribute*, int> it1 = currentEquipped.at(i);
		QPair<Attribute*, int> it2(0, 0);

		for (int j = 0; j < previewEquipped.size();) {
			if (previewEquipped.at(j).first == it1.first) {
				it2 = previewEquipped.at(j);
				previewEquipped.remove(j);
				break;
			} else {
				j++;
			}
		}

		QGraphicsSimpleTextItem *item = new QGraphicsSimpleTextItem(_updatedStatsPanel);
		item->setText(it1.first->getName() + " + " + QString::number(it2.second));
		item->setFont(font);
		item->setPos(position);

		// Set brush
		if (it1.second > it2.second)
			item->setBrush(redBrush);
		else if (it1.second < it2.second)
			item->setBrush(greenBrush);
		else
			item->setBrush(whiteBrush);

		position.setY(position.y() + 20);
		_updatedStatsItems.append(item);
	}

	// Go over all the attributes of the considered
	// Equipment Piece for comparison.
	for (int i = 0; i < previewEquipped.size(); i++) {
		QPair<Attribute*, int> it = previewEquipped.at(i);

		QGraphicsSimpleTextItem *item = new QGraphicsSimpleTextItem(_updatedStatsPanel);
		item->setText(it.first->getName() + " + " + QString::number(it.second));
		item->setFont(font);
		item->setBrush(greenBrush);
		item->setPos(position);

		position.setY(position.y() + 20);
		_updatedStatsItems.append(item);
	}
}
GraphicsPortItem::GraphicsPortItem(GraphicsClientItemsClient *client_, const QString &fullPortName_, int style_, QFont font_, int padding, QGraphicsItem *parent) :
    QGraphicsPathItem(parent),
    client(client_),
    fullPortName(fullPortName_),
    shortPortName(fullPortName.split(":")[1]),
    dataType(client->getPortType(fullPortName)),
    isInput(client->getPortFlags(fullPortName) & JackPortIsInput),
    style(style_),
    font(font_),
    showMenu(false)
{
    bool gradient = false;
    QColor captionColor(0xfc, 0xf9, 0xc2);
    setPen(QPen(QBrush(Qt::black), 2));
    setBrush(QBrush(captionColor));
    setFlags(QGraphicsItem::ItemSendsScenePositionChanges);
    setCursor(Qt::ArrowCursor);
    font.setStyleStrategy(QFont::PreferAntialias);
    QFontMetrics fontMetrics(font);
    int portPadding = padding;

    QGraphicsSimpleTextItem *portTextItem = new QGraphicsSimpleTextItem(shortPortName, this);
    portTextItem->setFont(font);
    portTextItem->setPos(portPadding, 0);
    portRect = portTextItem->boundingRect().adjusted(-portPadding, -portPadding, portPadding, portPadding).translated(portTextItem->pos());

    QPainterPath portPath;
    if (style == 0) {
        portPath = portPath.united(EllipsePath(portRect));
    } else if (style == 1) {
        portPath = portPath.united(SpeechBubblePath(portRect, portRect.height() / 4, portRect.height() / 4, Qt::AbsoluteSize));
    } else if (style == 2) {
        portPath = portPath.united(RoundedRectanglePath(portRect, portPadding + fontMetrics.height() / 2, portPadding + fontMetrics.height() / 2));
    } else if (style == 3) {
        portPath = portPath.united(RectanglePath(portRect));
    }
    setPath(portPath);

    // register the port registration callback at the jack server:
    QObject::connect(client, SIGNAL(portRegistered(QString,QString,int)), this, SLOT(onPortRegistered(QString,QString,int)), Qt::QueuedConnection);
    QObject::connect(client, SIGNAL(portUnregistered(QString,QString,int)), this, SLOT(onPortUnregistered(QString,QString,int)), Qt::QueuedConnection);
    QObject::connect(client, SIGNAL(portConnected(QString,QString)), this, SLOT(onPortConnected(QString,QString)), Qt::QueuedConnection);
    QObject::connect(client, SIGNAL(portDisconnected(QString,QString)), this, SLOT(onPortDisconnected(QString,QString)), Qt::QueuedConnection);

    if (gradient) {
        QLinearGradient gradient(portRect.topLeft(), portRect.bottomRight());
        gradient.setColorAt(0, Qt::white);
        gradient.setColorAt(1, QColor("wheat"));
        setBrush(QBrush(gradient));
    }

    // create the context menu:
    connectMenu = contextMenu.addMenu("Connect");
    disconnectMenu = contextMenu.addMenu("Disconnect");
    // create the entries in connect- and disconnect-menus, as well as graphical representations of existing connections:
    QStringList connectedPorts = client->getConnectedPorts(fullPortName);
    QSet<QString> connectedPortsSet;
    for (int i = 0; i < connectedPorts.size(); i++) {
        // create an entry in the disconnect-menu:
        QAction *action = disconnectMenu->addAction(connectedPorts[i]);
        action->setData(connectedPorts[i]);
        QObject::connect(action, SIGNAL(triggered()), this, SLOT(onDisconnectAction()));
        mapPortNamesToActions[connectedPorts[i]] = action;
        connectedPortsSet.insert(connectedPorts[i]);
        // create a graphical representation of the connection:
        if (isInput) {
            client->getPortConnectionItem(connectedPorts[i], fullPortName)->setPos(fullPortName, getConnectionScenePos());
        } else {
            client->getPortConnectionItem(fullPortName, connectedPorts[i])->setPos(fullPortName, getConnectionScenePos());
        }
    }
    // get all available ports that can be connected to this:
    QStringList connectablePorts = client->getPorts(0, dataType.toAscii().data(), isInput ? JackPortIsOutput : JackPortIsInput);
    for (int i = 0; i < connectablePorts.size(); i++) {
        // skip ports that are already connected:
        if (!connectedPortsSet.contains(connectablePorts[i])) {
            // create an entry in the connect-menu:
            QAction *action = connectMenu->addAction(connectablePorts[i]);
            action->setData(connectablePorts[i]);
            QObject::connect(action, SIGNAL(triggered()), this, SLOT(onConnectAction()));
            mapPortNamesToActions[connectablePorts[i]] = action;
        }
    }
    disconnectMenu->setEnabled(disconnectMenu->actions().size());
    connectMenu->setEnabled(connectMenu->actions().size());
}
Exemple #20
0
bool ZipplXmlReader::read( QIODevice *dev )
{
  setDevice( dev );
  bool res = true;
  bool metaMode = false;
  mCurrParent = 0;
  mCurrSpot = 0;

  QGraphicsScene *scene = mGraphWidget->scene();
  int spotID = 0;

  while (!atEnd()) {
    readNext();

    if( isStartElement() ) {
      qDebug() << "XML name: " << name();

      if( name() == "presentation") {
        // presentation mode: debug & presentation
        QString mode = attributes().value("mode").toString();
        if( !mode.isEmpty() ) mMode = mode;

        mPath = attributes().value("path").toString();
        if( !mPath.endsWith('/') ) mPath += "/";


        qreal dx = qrealAttrib("width") / -2.0;
        qreal dy = qrealAttrib("height") / -2.0;
        QRectF rect( dx, dy, -2.0*dx, -2.0*dy );
        scene->setSceneRect( rect );
      } else if( name() == "meta" ) {
        metaMode = true;
      } else if( name() == "title" && metaMode ) {
        mPresentationTitle = readElementText();
      } else if( name() == "description" && metaMode ) {
        mPresentationDescr = readElementText();
      } else if( name() == "date" && metaMode ) {
        mPresentationDate = readElementText();
      } else if( name() == "name" && metaMode ) {
        mAuthorName = readElementText();
      } else if( name() == "email" && metaMode ) {
        mAuthorEmail = readElementText();
      } else if( name() == "tocentry" ) {
        if( mCurrSpot ) {
          mCurrSpot->setData( TOCENTRY, readElementText() );
        }
      } else if( name() == "spot" ) {
        if( mCurrParent != 0 ) {
          qDebug() << "Strange: Current Parent should be zero here!";
        }
        QGraphicsRectItem *rectItem = new QGraphicsRectItem( );

        rectItem->setPen( pen( rectItem->pen(), QColor("#aeaeae") ));

        mCurrParent = rectItem;
        mCurrSpot = rectItem;
        mCurrParent->setData( ID, QVariant( spotID++ ));

        mCurrParent->setPos( position() );

        rectItem->setBrush( brush( rectItem->brush() ) );

        scene->addItem( mCurrParent );
        mSpots.append( mCurrParent );

        // Prepare the hidden items list
        GraphicsItemList list;
        mHiddenItems.insert( mCurrParent, list );

      } else if( name() == "hidden" ) {
        QGraphicsRectItem *rectItem = new QGraphicsRectItem( mCurrParent, scene );
        rectItem->setPen( QPen( QColor( 240, 240, 240 )));

        // append this hidden item to the list of hiddens of the parent spot.
        GraphicsItemList list = mHiddenItems[mCurrSpot];
        list.append( rectItem );
        mHiddenItems[mCurrSpot] = list;

        mCurrParent = rectItem;
        mCurrParent->setData( ID, QVariant( spotID++ ));

      } else if( name() == "rect" ) {
        if( mCurrParent ) { // within a spot
          qDebug() << "Creating a rectangle!";
          QGraphicsRectItem *rectItem = new QGraphicsRectItem( mCurrParent, scene );

          qreal width = qrealAttrib( "width" );
          qreal height = qrealAttrib( "height" );

          QPointF pos = position();
          if( width > 0 && height > 0 ) {
            rectItem->setRect( pos.x(), pos.y(), width, height );
          } else {
            rectItem->setPos( pos );
          }
          rectItem->setPen( pen( rectItem->pen() ) );

          mCurrParent = rectItem;
        }
      } else if( name() == "circle" ) {
        QPointF pos = position();
        QGraphicsEllipseItem *ellipse = new QGraphicsEllipseItem( mCurrParent, scene );
        // ellipse->setBrush( getBrush() );
        qreal r = 2.0 * qrealAttrib( "r" );

        QRectF rect( pos, QSizeF( r, r ) );

        ellipse->setPen( pen( ellipse->pen() ) );

        ellipse->setRect( rect );


      } else if( name() == "text" ) {
        QGraphicsSimpleTextItem *textItem = new QGraphicsSimpleTextItem( mCurrParent, scene );

        QString font = attributes().value("font").toString();
        QString size = attributes().value("size").toString();


        QFont currFont = textItem->font();
        if( !font.isEmpty() ) {
          currFont.setFamily( font );
          textItem->setFont( currFont );
        }
        if( !size.isEmpty() ) {
          currFont.setPointSize( size.toInt() );
          textItem->setFont( currFont );
        }

        textItem->setPos( position() );

        // set the brush
        QBrush b( textItem->brush() );
        b.setColor( color() );

        textItem->setBrush( b );

        QString text = readElementText();
        textItem->setText( text );

      } else if( name() == "image" ) {
        if( handleImg( scene ) ) {

        }
      }
    } else if( isEndElement() ) {
      qDebug( ) << "XML CLOSE: " << name().toString();
      if( name() == "spot" || name() == "toc" ) {
        QRectF rect = mCurrParent->childrenBoundingRect();
        rect.setX(0);
        rect.setY(0);
        qgraphicsitem_cast<QGraphicsRectItem*>(mCurrParent)->setRect( rect);
        mCurrParent = 0;
      } else if( name() == "rect" ) {
        QGraphicsRectItem *item = qgraphicsitem_cast<QGraphicsRectItem*>(mCurrParent);

        if( item->rect().isEmpty() )
          item->setRect( mCurrParent->childrenBoundingRect() );
        mCurrParent = mCurrParent->parentItem();
      } else if( name() == "hidden") {
        mCurrParent->setOpacity( 0.0 );
        mCurrParent = mCurrParent->parentItem();
      } else if( name() == "meta" ) {
        metaMode = false;
      }
    }
  }

  createToc( scene );

  return res;
}
Exemple #21
0
void LogScene::getTaskItem(const QModelIndex &index) {
    Task* task = _model->task(index);

    Calendar* calendar = task->project()->projectDefaultCalendar();
    int hoursInDay = calendar->endHour().hour() - calendar->startHour().hour();
    std::vector<TaskLog*>* logs =task->logs();
    double startHour = 0;//calendar->startHour().hour();
    double endHour = 24;//calendar->endHour().hour() + 1;
    double minuteSize = (double)24*BLOCKSIZE / (double)((endHour - startHour) * 60);
    int red = 0;
    for (std::vector<TaskLog*>::iterator iter = logs->begin(); iter != logs->end(); iter++) {
        TaskLog* log = *iter;

        QSize size = sizeHint(index);

        int bordermargin = (size.height() * .4) / 2;

        int daysToStart = _startDate.daysTo(*log->start);
        double x1 = (double)daysToStart * (double)_dayWidth;
        DTime logStartTime = log->start->time();
        double y1 = (double)(logStartTime.totalMinutes() - (startHour*60)) * minuteSize;

        double x2 = (daysToStart + 1) * (double)_dayWidth;
        DTime logEndTime = log->end->time();
        if (log->end->getDay() != log->start->getDay()) {
            logEndTime = DTime(23, 59, 59);
        }
        double y2 = (double)(logEndTime.totalMinutes() - (startHour*60)) * minuteSize;

        QBrush b(task->taskColor());//QImage(":/img/task_bar.png"));//(QPixmap(":/img/task_bar.png"));
        red += 20;
        QColor penColor((task->taskColor().red() < 100) ? 0: (task->taskColor().red() - 100),
                        (task->taskColor().green() < 100) ? 0: (task->taskColor().green() - 100),
                        (task->taskColor().blue() < 100) ? 0: (task->taskColor().blue() - 100));
        QPen pen(penColor);
        if (log->activeLog) {
            pen.setWidth(3);
        }

        QGraphicsItem* item = this->addRect(x1, y1, (x2 - x1), (y2 - y1), pen, b);
        item->setZValue(1);
        if ((y2 - y1) > 20) {
            QFont f("Arial", 8);
            f.setWeight(QFont::Light);
            QBrush brush(penColor);

            std::string description = *task->shortDescription();
            int textY = y1 + 5;
            while (description.length() > 0) {
                std::string label;
                if (description.length() > 15) {
                    label = description.substr(0, 15);
                    description = description.substr(15);
                    if ((label.at(label.length() - 1) != ' ') &&
                        (description.at(0) != ' ')) {
                        int pos;
                        if ((pos = label.rfind(' ')) != std::string::npos) {
                            description = label.substr(pos) + description;
                            label = label.substr(0, pos);
                        }
                    }
                } else {
                    label = description;
                    description = "";
                }
                label = label.erase(label.find_last_not_of(" \n\r\t")+1);
                description = description.erase(description.find_last_not_of(" \n\r\t")+1);
                if ((textY + 20) < y2) {
                    QGraphicsSimpleTextItem* text = this->addSimpleText(tr(label.c_str()));
                    text->setPos(x1 + 10, textY);
                    //text->rotate(90);
                    text->setVisible(true);
                    text->setBrush(brush);
                    text->setFont(f);
                    text->setZValue(2);
                    textY += 15;
                } else {
                    break;
                }
            }
        }
        _currentY += sizeHint(index).height();
    }
    delete(logs);
}
Exemple #22
0
void VisualMatrix::initSprite()
{
	_sprite = new QGraphicsWidget();

	QGraphicsItem* item;
	QGraphicsWidget* widget;
	QGraphicsRectItem* rect;
	QGraphicsColorizeEffect* effect;
	QGraphicsSimpleTextItem* text;
	QGraphicsProxyWidget* proxy;
	QLabel* label;
	QFont font;

	// Frame
	{
		item = new QGraphicsPixmapItem(LoaderThread::instance()->getCachedPixmap(IMAGE_FRAME_BG));
		item->setParentItem(_sprite);
		item->setPos(0.0f, 0.0f);
	}

	// Frame
	{
		item = new QGraphicsPixmapItem(LoaderThread::instance()->getCachedPixmap(IMAGE_FRAME_MG));
		item->setParentItem(_sprite);
		item->setPos(0.0f, 0.0f);
	}

	// Avatar
	{
		widget = new QGraphicsWidget();
		widget->resize(BLOCK_LARGE * 10, BLOCK_LARGE * 20);
		widget->setFlags(QGraphicsItem::ItemClipsChildrenToShape);
		widget->setParentItem(_sprite);
		widget->setPos(170.0f, 50.0f);
		
		item = new QGraphicsPixmapItem();
		item->setParentItem(widget);
		item->setPos(((BLOCK_LARGE * 10) - (320.0f / 0.75f)) * 0.5f, (BLOCK_LARGE * 20) - 320.0f);
		
		_avatar = widget;
	}

	// Help
	{
		widget = new QGraphicsWidget();
		widget->resize(BLOCK_LARGE * 10, BLOCK_LARGE * 20);
		widget->setFlags(QGraphicsItem::ItemClipsChildrenToShape);
		widget->setParentItem(_sprite);
		widget->setPos(170.0f, 50.0f);
		
		rect = new QGraphicsRectItem(0.0f, 0.0f, BLOCK_LARGE * 10, BLOCK_LARGE * 20);
		rect->setBrush(QBrush(QColor::fromRgb(0x00, 0x00, 0x00, 0xC0)));
		rect->setParentItem(widget);
		
		font = QApplication::font();
		font.setFamily("Arial");
		font.setPixelSize(16);
		font.setWeight(QFont::Bold);
		font.setStretch(80);
		
		text = new QGraphicsSimpleTextItem(tr("Slide left and right: Move."));
		text->setBrush(QColor::fromRgb(0xC0, 0xC0, 0xC0));
		text->setFont(font);
		text->setParentItem(widget);
		text->setPos(((BLOCK_LARGE * 10) - text->boundingRect().width()) * 0.5f, 217.0f - 6.0f);
		
		text = new QGraphicsSimpleTextItem(tr("Swipe up: Hold.  Swipe down: Drop."));
		text->setBrush(QColor::fromRgb(0xC0, 0xC0, 0xC0));
		text->setFont(font);
		text->setParentItem(widget);
		text->setPos(((BLOCK_LARGE * 10) - text->boundingRect().width()) * 0.5f, 237.0f - 6.0f);
		
		text = new QGraphicsSimpleTextItem(tr("Pull back, and make circles: Rotate."));
		text->setBrush(QColor::fromRgb(0xC0, 0xC0, 0xC0));
		text->setFont(font);
		text->setParentItem(widget);
		text->setPos(((BLOCK_LARGE * 10) - text->boundingRect().width()) * 0.5f, 257.0f - 6.0f);

//		widget->setVisible(false);
		
		_sprite_help = widget;
	}

	// Lines
	{
		rect = new QGraphicsRectItem(120.0f - 1.0f, 220.0f - 1.0f, 8.0f + 2.0f, 144.0f + 2.0f);
		rect->setBrush(QBrush(LoaderThread::instance()->getCachedPixmap(IMAGE_LINES_PROGRESS)));
		rect->setParentItem(_sprite);

		_sprite_lines = rect;
	}

	// Frame
	{
		item = new QGraphicsPixmapItem(LoaderThread::instance()->getCachedPixmap(IMAGE_FRAME_FG));
		item->setParentItem(_sprite);
		item->setPos(0.0f, 0.0f);
	}

	// Field
	{
		widget = new QGraphicsWidget();
		widget->resize(BLOCK_LARGE * 10, BLOCK_LARGE * 20);
		widget->setFlags(QGraphicsItem::ItemClipsChildrenToShape);
		widget->setParentItem(_sprite);
		widget->setPos(170.0f, 50.0f);
		
		_sprite_field = widget;

		_sprite_space.fill(NULL, _rows * _cols);
	}

	// Ghost
	{
		widget = new QGraphicsWidget();
		widget->resize(BLOCK_LARGE * 4, BLOCK_LARGE * 4);
		widget->setParentItem(_sprite_field);
		widget->setPos(BLOCK_LARGE * getShapePositionInField(18, 3));
		
		for (int i = 0; i < 4; ++i)
		{
			item = new QGraphicsPixmapItem(LoaderThread::instance()->getCachedPixmap(IMAGE_BLOCK_GHOST));
			item->setParentItem(widget);
		}
	
		_sprite_ghost = widget;
	}

	// Tetromino
	{
		widget = new QGraphicsWidget();
		widget->resize(BLOCK_LARGE * 4, BLOCK_LARGE * 4);
		widget->setParentItem(_sprite_field);
		widget->setPos(BLOCK_LARGE * getShapePositionInField(18, 3));
		widget->setZValue(1.0f);
		
		effect = new QGraphicsColorizeEffect(widget);
		effect->setColor(QColor::fromRgb(0xFF, 0xFF, 0xFF));
		effect->setStrength(0.0f);
		widget->setGraphicsEffect(effect);
		
		for (int i = 0; i < 4; ++i)
		{
			item = new QGraphicsPixmapItem();
			item->setParentItem(widget);
		}
		
		_sprite_tetromino = widget;
	}

	// Hold
	{
		widget = new QGraphicsWidget();
		widget->resize(BLOCK_LARGE * 4, BLOCK_LARGE * 2);
		widget->setScale(BLOCK_SMALL / BLOCK_LARGE);
		widget->setParentItem(_sprite);
		widget->setPos(56.0f, 108.0f + BLOCK_SMALL);
		
		effect = new QGraphicsColorizeEffect(widget);
		effect->setColor(QColor::fromRgb(0xFF, 0xFF, 0xFF));
		effect->setStrength(0.0f);
		widget->setGraphicsEffect(effect);
		
		for (int i = 0; i < 4; ++i)
		{
			item = new QGraphicsPixmapItem();
			item->setParentItem(widget);
		}
		
		_sprite_hold = widget;
	}

	// Hold fail
	{
		item = new QGraphicsPixmapItem(LoaderThread::instance()->getCachedPixmap(IMAGE_FAIL));
		item->setScale(BLOCK_SMALL / BLOCK_LARGE);
		item->setParentItem(_sprite);
		item->setPos(56.0f + (BLOCK_SMALL * 3), 108.0f + (BLOCK_SMALL * 3));
		item->setVisible(false);
	
		_sprite_holdFail = item;
	}

	// Next
	{
		widget = new QGraphicsWidget();
		widget->resize(BLOCK_LARGE * 4, BLOCK_LARGE * 2);
		widget->setScale(BLOCK_SMALL / BLOCK_LARGE);
		widget->setParentItem(_sprite);
		widget->setPos(460.0f, 108.0f + BLOCK_SMALL);
		
		effect = new QGraphicsColorizeEffect(widget);
		effect->setColor(QColor::fromRgb(0xFF, 0xFF, 0xFF));
		effect->setStrength(0.0f);
		widget->setGraphicsEffect(effect);
		
		for (int i = 0; i < 4; ++i)
		{
			item = new QGraphicsPixmapItem();
			item->setParentItem(widget);
		}
	
		_sprite_next << widget;
	}

	// Next
	{
		widget = new QGraphicsWidget();
		widget->resize(BLOCK_LARGE * 4, BLOCK_LARGE * 2);
		widget->setScale(BLOCK_SMALL / BLOCK_LARGE);
		widget->setParentItem(_sprite);
		widget->setPos(460.0f, 228.0f + BLOCK_SMALL);
		
		effect = new QGraphicsColorizeEffect(widget);
		effect->setColor(QColor::fromRgb(0xFF, 0xFF, 0xFF));
		effect->setStrength(0.0f);
		widget->setGraphicsEffect(effect);
		
		for (int i = 0; i < 4; ++i)
		{
			item = new QGraphicsPixmapItem();
			item->setParentItem(widget);
		}
	
		_sprite_next << widget;
	}

	// Next
	{
		widget = new QGraphicsWidget();
		widget->resize(BLOCK_LARGE * 4, BLOCK_LARGE * 2);
		widget->setScale(BLOCK_SMALL / BLOCK_LARGE);
		widget->setParentItem(_sprite);
		widget->setPos(460.0f, 292.0f + BLOCK_SMALL);
		
		effect = new QGraphicsColorizeEffect(widget);
		effect->setColor(QColor::fromRgb(0xFF, 0xFF, 0xFF));
		effect->setStrength(0.0f);
		widget->setGraphicsEffect(effect);
		
		for (int i = 0; i < 4; ++i)
		{
			item = new QGraphicsPixmapItem();
			item->setParentItem(widget);
		}
		
		_sprite_next << widget;
	}

	// Font
	{
		font = QApplication::font();
		font.setCapitalization(QFont::AllUppercase);
	}

	// Hold
	{
		text = new QGraphicsSimpleTextItem(tr("Hold"));
		text->setBrush(QColor::fromRgb(0x00, 0x00, 0x00));
		text->setFont(font);
		text->setParentItem(_sprite);
		text->setPos(56.0f, 80.0f - 6.0f);
	}

	// Next
	{
		text = new QGraphicsSimpleTextItem(tr("Next"));
		text->setBrush(QColor::fromRgb(0x00, 0x00, 0x00));
		text->setFont(font);
		text->setParentItem(_sprite);
		text->setPos(526.0f - text->boundingRect().width(), 80.0f - 6.0f);
	}

	// Level
	{
		text = new QGraphicsSimpleTextItem(tr("Level"));
		text->setBrush(QColor::fromRgb(0x00, 0x00, 0x00));
		text->setFont(font);
		text->setParentItem(_sprite);
		text->setPos(56.0f, 316.0f - 6.0f);
	}

	// Level
	{
		label = new QLabel();
		label->resize(48, 24);
		label->setStyleSheet("background-color: transparent; color: #FFFFFF;");
		label->setAlignment(Qt::AlignTop | Qt::AlignLeft);
		
		proxy = new QGraphicsProxyWidget();
		proxy->setParentItem(_sprite);
		proxy->setWidget(label);
		proxy->setPos(56.0f, 344.0f - 6.0f);
	
		_sprite_level = label;
	}

	// Score
	{
		text = new QGraphicsSimpleTextItem(tr("Score"));
		text->setBrush(QColor::fromRgb(0x00, 0x00, 0x00));
		text->setFont(font);
		text->setParentItem(_sprite);
		text->setPos(176.0f, 564.0f - 6.0f);
	}

	// Score
	{
		label = new QLabel();
		label->resize(148, 24);
		label->setStyleSheet("background-color: transparent; color: #FFFFFF;");
		label->setAlignment(Qt::AlignTop | Qt::AlignRight);
		
		proxy = new QGraphicsProxyWidget();
		proxy->setParentItem(_sprite);
		proxy->setWidget(label);
		proxy->setPos(256.0f, 564.0f - 6.0f);
		
		_sprite_score = label;
	}

	// Countdown
	{
		widget = new QGraphicsWidget();
		widget->resize(BLOCK_LARGE * 10, BLOCK_LARGE * 20);
		widget->setFlags(QGraphicsItem::ItemClipsChildrenToShape);
		widget->setParentItem(_sprite);
		widget->setPos(170.0f, 50.0f);

		rect = new QGraphicsRectItem(0.0f, 0.0f, BLOCK_LARGE * 10, BLOCK_LARGE * 20);
		rect->setBrush(QBrush(QColor::fromRgb(0x00, 0x00, 0x00, 0xC0)));
		rect->setParentItem(widget);

		item = new QGraphicsPixmapItem(LoaderThread::instance()->getCachedPixmap(IMAGE_COUNT[0]));
		item->setParentItem(widget);
		item->setPos(77.0f, 197.0f);
		item->setVisible(false);
		_sprite_count << item;

		item = new QGraphicsPixmapItem(LoaderThread::instance()->getCachedPixmap(IMAGE_COUNT[1]));
		item->setParentItem(widget);
		item->setPos(77.0f, 197.0f);
		item->setVisible(false);
		_sprite_count << item;

		item = new QGraphicsPixmapItem(LoaderThread::instance()->getCachedPixmap(IMAGE_COUNT[2]));
		item->setParentItem(widget);
		item->setPos(77.0f, 197.0f);
		item->setVisible(false);
		_sprite_count << item;

		widget->setVisible(false);
		
		_sprite_countdown = widget;
	}

	// Game over
	{
		widget = new QGraphicsWidget();
		widget->resize(BLOCK_LARGE * 10, BLOCK_LARGE * 20);
		widget->setFlags(QGraphicsItem::ItemClipsChildrenToShape);
		widget->setParentItem(_sprite);
		widget->setPos(170.0f, 50.0f);
		widget->setZValue(8.0f);
		
		rect = new QGraphicsRectItem(0.0f, 0.0f, BLOCK_LARGE * 10, BLOCK_LARGE * 20);
		rect->setBrush(QBrush(QColor::fromRgb(0x00, 0x00, 0x00, 0xC0)));
		rect->setParentItem(widget);
		
		item = new QGraphicsPixmapItem(LoaderThread::instance()->getCachedPixmap(IMAGE_OVER));
		item->setParentItem(widget);
		item->setPos(4.0f, 172.0f);
		
		rect = new QGraphicsRectItem(0.0f, 0.0f, BLOCK_LARGE * 10, BLOCK_LARGE * 20);
		rect->setBrush(QBrush(QColor::fromRgb(0xFF, 0xFF, 0xFF)));
		rect->setParentItem(widget);
		_sprite_overFlash = rect;
		
		widget->setVisible(false);
		
		_sprite_over = widget;
	}
}
Exemple #23
0
CalendarGraphicsItem::CalendarGraphicsItem(CalendarControl * cc, QGraphicsItem * parent)
  : QGraphicsRectItem(0.0, 0.0, __width, __height, parent)
{
  _controller = cc;

  QDate today = QDate::currentDate();
  QDate firstMonthDay = QDate(today.year(), today.month(), 1);
  QDate firstCalendarDay = firstMonthDay.addDays(firstMonthDay.dayOfWeek() * -1);
  if(firstMonthDay.dayOfWeek() < 2)
    firstCalendarDay = firstCalendarDay.addDays(-7);

  _selectedDay = today;

  QString prev = QObject::tr("<");
  QString prevprev = QObject::tr("<<");
  QString next = QObject::tr(">");
  QString nextnext = QObject::tr(">>");

  QGraphicsSimpleTextItem * textItem;
  QGraphicsRectItem * rectItem;

  rectItem = new QGraphicsRectItem(0.0, 0.0, __width, __titleHeight, this);
  rectItem->setBrush(blackFill);
  _items.insert("titleBackground", rectItem);

  textItem = new QGraphicsSimpleTextItem(today.toString("MMMM yyyy"), this);
  textItem->setFont(monthfont);
  textItem->setZValue(2);
  textItem->setBrush(whiteFill);
  QPointF ct = rectItem->boundingRect().center();
  QRectF rt = textItem->boundingRect();
  textItem->setPos(ct.x() - (rt.width() / 2),
                   ct.y() - (rt.height() / 2));
  _items.insert("title", textItem);

  qreal offset = 0.1 * __dpi;
  qreal nw = 0;
  GraphicsTextButtonItem * tbtnItem = 0;
  tbtnItem = new GraphicsTextButtonItem(prevprev, this);
  tbtnItem->setFont(navfont);
  tbtnItem->setZValue(3);
  tbtnItem->setBrush(Qt::lightGray);
  tbtnItem->setRolloverBrush(Qt::green);
  tbtnItem->scale(0.5, 1);
  tbtnItem->setReceiver(this);
  rt = tbtnItem->boundingRect();
  tbtnItem->setPos(offset, ct.y() - (rt.height() / 2));
  nw = rt.width();
  _items.insert("fastrewind", tbtnItem);

  tbtnItem = new GraphicsTextButtonItem(nextnext, this);
  tbtnItem->setFont(navfont);
  tbtnItem->setZValue(3);
  tbtnItem->setBrush(Qt::lightGray);
  tbtnItem->setRolloverBrush(Qt::green);
  tbtnItem->scale(0.5, 1);
  tbtnItem->setReceiver(this);
  rt = tbtnItem->boundingRect();
  tbtnItem->setPos(rectItem->boundingRect().right() - offset - (rt.width() / 2), ct.y() - (rt.height() / 2));
  nw = qMax(nw, rt.width()) / 2;
  offset += (nw * 1.5);
  _items.insert("fastforward", tbtnItem);

  tbtnItem = new GraphicsTextButtonItem(prev, this);
  tbtnItem->setFont(navfont);
  tbtnItem->setZValue(3);
  tbtnItem->setBrush(Qt::lightGray);
  tbtnItem->setRolloverBrush(Qt::green);
  tbtnItem->scale(0.5, 1);
  tbtnItem->setReceiver(this);
  rt = tbtnItem->boundingRect();
  tbtnItem->setPos(offset, ct.y() - (rt.height() / 2));
  _items.insert("rewind", tbtnItem);

  tbtnItem = new GraphicsTextButtonItem(next, this);
  tbtnItem->setFont(navfont);
  tbtnItem->setZValue(3);
  tbtnItem->setBrush(Qt::lightGray);
  tbtnItem->setRolloverBrush(Qt::green);
  tbtnItem->scale(0.5, 1);
  tbtnItem->setReceiver(this);
  rt = tbtnItem->boundingRect();
  tbtnItem->setPos(rectItem->boundingRect().right() - offset - (rt.width() / 2), ct.y() - (rt.height() / 2));
  _items.insert("forward", tbtnItem);

  QDate date;
  qreal dayWidth = __width / 7.0;
  QApplication::setOverrideCursor(Qt::WaitCursor);
  for(int wday = 0; wday < 7; wday++)
  {
    for(int week = 0; week < 6; week++)
    {
      date = firstCalendarDay.addDays((7 * week) + wday);

      if(0 == week)
      {
        rectItem = new QGraphicsRectItem(wday * dayWidth, 0.5 * __dpi, dayWidth, 0.25 * __dpi, this);
        _items.insert(QString("weekday%1").arg(week), rectItem);
        textItem = new QGraphicsSimpleTextItem(date.toString("dddd"), this);
        textItem->setFont(wdayfont);
        textItem->setZValue(2);
        ct = rectItem->boundingRect().center();
        rt = textItem->boundingRect();
        textItem->setPos(ct.x() - (rt.width() / 2),
                         ct.y() - (rt.height() / 2));
        _items.insert(QString("weekday%1Text").arg(week), textItem);
      }

      QBrush fill;
      QBrush dayFill = blackFill;
      if(date == _selectedDay)
        fill = selectedFill;
      else if(date.month() != today.month())
      {
        fill = nonMonthFill;
        dayFill = nonMonthDayFill;
      }
      else if(date == today)
        fill = todayFill;
      else if(date.dayOfWeek() > 5)
        fill = weekendFill;

      rectItem = new QGraphicsRectItem(wday * dayWidth, (0.75  + (1.25 * week)) * __dpi, dayWidth, 1.25 * __dpi, this);
      rectItem->setBrush(fill);
      _items.insert(QString("day%1").arg((7 * week) + wday), rectItem);
      rt = QRectF(rectItem->pos(), rectItem->boundingRect().size());
      double offset = rt.width() / 3;
      textItem = new QGraphicsSimpleTextItem(QString::number(date.day()), this);
      textItem->setFont(dayfont);
      textItem->setZValue(2);
      textItem->setBrush(dayFill);
      textItem->setPos(rectItem->boundingRect().topLeft());
      textItem->moveBy(5.0, 5.0);
      _items.insert(QString("day%1Number").arg((7 * week) + wday), textItem);

      rt = QRectF(textItem->pos(), textItem->boundingRect().size());

      QString additionalText;
      if(_controller)
        additionalText = _controller->contents(date);
      textItem = new QGraphicsSimpleTextItem(additionalText, this);
      textItem->setFont(notesfont);
      textItem->setZValue(2);
      textItem->setBrush(dayFill);
      textItem->setPos(rt.left() + offset,
                       rt.top() + (rt.height() * 1.5));
      _items.insert(QString("day%1Text").arg((7 * week) + wday), textItem);
    }
  }
  QApplication::restoreOverrideCursor();
}
void GraphicsClientItem::initItem()
{
    // delete all children (except the inner item):
    QList<QGraphicsItem*> children = childItems();
    for (int i = 0; i < children.size(); i++) {
        if (children[i] != controlsItem) {
            if (GraphicsPortItem *portItem = dynamic_cast<GraphicsPortItem*>(children[i])) {
                portItem->deleteLater();
            } else {
                delete children[i];
            }
        }
    }

    bool gradient = false;
    QFont commandsFont = font;
    commandsFont.setBold(true);
    commandsFont.setStyleStrategy(QFont::PreferAntialias);
    QFontMetrics fontMetrics(font);
    int portPadding = fontMetrics.height() / 3;
    int padding = fontMetrics.height() + portPadding * 2;

    QGraphicsSimpleTextItem *textItem = new QGraphicsSimpleTextItem(clientName, this);
    textItem->setFont(font);
    textItem->setPos(padding, padding);
    QStringList inputPorts = clientItemsClient->getPorts(QString(QRegExp::escape(clientName) + ":.*").toAscii().data(), 0, JackPortIsInput);
    QList<GraphicsPortItem*> inputPortItems;
    int inputPortsWidth = -portPadding;
    int minimumInputPortWidth = 0;
    for (int i = 0; i < inputPorts.size(); i++) {
        inputPortItems.append(new GraphicsPortItem(clientItemsClient, inputPorts[i], 3, font, portPadding, this));
        if (isMacroItem()) {
            QPen pen = inputPortItems.back()->pen();
            pen.setColor(QColor("steelblue"));
            inputPortItems.back()->setPen(pen);
        }
        inputPortsWidth += inputPortItems[i]->getRect().width() + portPadding;
        if ((i == 0) || (inputPortItems[i]->getRect().width() < minimumInputPortWidth)) {
            minimumInputPortWidth = inputPortItems[i]->getRect().width();
        }
    }
    QStringList outputPorts = clientItemsClient->getPorts(QString(QRegExp::escape(clientName) + ":.*").toAscii().data(), 0, JackPortIsOutput);
    QList<GraphicsPortItem*> outputPortItems;
    int outputPortsWidth = -portPadding;
    int minimumOutputPortWidth = 0;
    for (int i = 0; i < outputPorts.size(); i++) {
        outputPortItems.append(new GraphicsPortItem(clientItemsClient, outputPorts[i], 3, font, portPadding, this));
        if (isMacroItem()) {
            QPen pen = outputPortItems.back()->pen();
            pen.setColor(QColor("steelblue"));
            outputPortItems.back()->setPen(pen);
        }
        outputPortsWidth += outputPortItems[i]->getRect().width() + portPadding;
        if ((i == 0) || (outputPortItems[i]->getRect().width() < minimumOutputPortWidth)) {
            minimumOutputPortWidth = outputPortItems[i]->getRect().width();
        }
    }

    rect = (textItem->boundingRect().translated(textItem->pos())).adjusted(-padding, -padding, padding, padding);
//    if (rect.width() < inputPortsWidth + (portPadding - minimumInputPortWidth) * 2) {
//        rect.setWidth(inputPortsWidth + (portPadding - minimumInputPortWidth) * 2);
//    }
//    if (rect.width() < outputPortsWidth + (portPadding - minimumOutputPortWidth) * 2) {
//        rect.setWidth(outputPortsWidth + (portPadding - minimumOutputPortWidth) * 2);
//    }
    if (rect.width() < inputPortsWidth) {
        rect.setWidth(inputPortsWidth);
    }
    if (rect.width() < outputPortsWidth) {
        rect.setWidth(outputPortsWidth);
    }
    if (gradient) {
        QLinearGradient gradient(rect.topLeft(), rect.bottomRight());
        gradient.setColorAt(0, Qt::white);
        gradient.setColorAt(1, QColor(0xfc, 0xf9, 0xc2));//QColor("royalblue").lighter());
        setBrush(QBrush(gradient));
    }

    QPainterPath bodyPath;
    if (clientStyle == 0) {
        bodyPath = EllipsePath(rect);
    } else if (clientStyle == 1) {
        bodyPath = SpeechBubblePath(rect, rect.height() / 4, rect.height() / 4, Qt::AbsoluteSize);
    } else if (clientStyle == 2){
        bodyPath = RoundedRectanglePath(rect, padding + fontMetrics.height(), padding + fontMetrics.height());
    } else if (clientStyle == 3) {
        bodyPath = RectanglePath(rect);
    }

    for (int i = 0, x = (inputPortsWidth > rect.width() ? (rect.width() - inputPortsWidth) / 2 : 0); i < inputPorts.size(); i++) {
        GraphicsPortItem *portItem = inputPortItems[i];
        portItem->setFlag(QGraphicsItem::ItemStacksBehindParent, true);
        portItem->setPos(x, 0);
        QRectF portRect(portItem->getRect().translated(portItem->pos()));

        QPainterPath portPath;
        portPath.addRect(QRectF(portRect.topLeft(), 0.5 * (portRect.topRight() + portRect.bottomRight())));
        int portStyle = (portItem->isAudioType() ? audioPortStyle : midiPortStyle);
        if (portStyle == 0) {
            portPath += EllipsePath(portRect);
        } else if (portStyle == 1) {
            portPath += SpeechBubblePath(portRect, 0.7, 0.7);
        } else if (portStyle == 2) {
            portPath += RoundedRectanglePath(portRect, portPadding + fontMetrics.height() / 2, portPadding + fontMetrics.height() / 2);
        } else if (portStyle == 3) {
            portPath += RectanglePath(portRect);
        }
        bodyPath -= portPath;

        x += portRect.width() + portPadding;
    }
    for (int i = 0, x = (outputPortsWidth > rect.width() ? (rect.width() - outputPortsWidth) / 2 : 0); i < outputPorts.size(); i++) {
        GraphicsPortItem *portItem = outputPortItems[i];
        portItem->setFlag(QGraphicsItem::ItemStacksBehindParent, true);
        portItem->setPos(x, rect.height() - fontMetrics.height());
        QRectF portRect(portItem->getRect().translated(portItem->pos()));

        QPainterPath portPath;
        portPath.addRect(QRectF(0.5 * (portRect.topLeft() + portRect.bottomLeft()), portRect.bottomRight()));
        int portStyle = (portItem->isAudioType() ? audioPortStyle : midiPortStyle);
        if (portStyle == 0) {
            portPath += EllipsePath(portRect);
        } else if (portStyle == 1) {
            portPath += SpeechBubblePath(portRect, 0.7, 0.7);
        } else if (portStyle == 2) {
            portPath += RoundedRectanglePath(portRect, portPadding + fontMetrics.height() / 2, portPadding + fontMetrics.height() / 2);
        } else if (portStyle == 3) {
            portPath += RectanglePath(portRect);
        }
        bodyPath -= portPath;

        x += portRect.width() + portPadding;
    }
    QPainterPath combinedPath = bodyPath;

    setPath(combinedPath);
}
Exemple #25
0
void TerrainProfileGraph::drawAxes(double yMin, double yMax, double yScale, double xMax, QRect &out_field)
{
  QBrush axesBrush(_axesColor);

  // Create min/max text items
  QGraphicsSimpleTextItem* yMinText = new QGraphicsSimpleTextItem(QString::number(yMin));
  yMinText->setBrush(axesBrush);
  yMinText->setFont(_graphFont);

  QGraphicsSimpleTextItem* yMaxText = new QGraphicsSimpleTextItem(QString::number(yMax));
  yMaxText->setBrush(axesBrush);
  yMaxText->setFont(_graphFont);

  QGraphicsSimpleTextItem* xMaxText = new QGraphicsSimpleTextItem(QString::number(xMax));
  xMaxText->setBrush(axesBrush);
  xMaxText->setFont(_graphFont);


  // Calculate positioning offsets and set out_field to actual graph bounds
  double fontHalfHeight = yMinText->boundingRect().height() / 2.0;

  int textSpacing = 8;
  int xOffset = (int)osg::maximum(yMinText->boundingRect().width(), yMaxText->boundingRect().width()) + textSpacing;
  int yOffset = (int)xMaxText->boundingRect().height() + textSpacing;
  int xAxisY = _graphHeight - yOffset;

  out_field.setCoords(xOffset, (int)fontHalfHeight, _graphWidth, xAxisY);


  // Draw background rectangle
  _scene->addRect(out_field, QPen(Qt::NoPen), QBrush(_fieldColor))->setZValue(FIELD_Z);


  // Add min/max text items to the scene
  yMinText->setPos(xOffset - textSpacing - yMinText->boundingRect().width(), xAxisY - fontHalfHeight);
  yMinText->setZValue(AXES_Z);
  _scene->addItem(yMinText);

  yMaxText->setPos(xOffset - textSpacing - yMaxText->boundingRect().width(), 0);
  yMaxText->setZValue(AXES_Z);
  _scene->addItem(yMaxText);

  xMaxText->setPos(_graphWidth - xMaxText->boundingRect().width(), _graphHeight - xMaxText->boundingRect().height());
  xMaxText->setZValue(AXES_Z);
  _scene->addItem(xMaxText);


  // Draw the main axes and x-axis end cap
  _scene->addLine(xOffset, fontHalfHeight, xOffset, xAxisY + 5, _axesPen)->setZValue(AXES_Z);
  _scene->addLine(xOffset - 5, xAxisY, _graphWidth, xAxisY, _axesPen)->setZValue(AXES_Z);
  _scene->addLine(_graphWidth, xAxisY - 5, _graphWidth, xAxisY + 5, _axesPen)->setZValue(AXES_Z);

  // Draw horizontal graph lines
  double yGraphScale = (yScale / (yMax - yMin)) * out_field.height();
  double graphLineY = xAxisY - yGraphScale;
  for (double y = yMin + yScale; y <= yMax; y += yScale)
  {
    _scene->addLine(xOffset - 5, graphLineY, _graphWidth, graphLineY, _axesPen)->setZValue(AXES_Z);;

    if (y != yMax)
    {
      QGraphicsSimpleTextItem* yText = new QGraphicsSimpleTextItem(QString::number(y));
      yText->setBrush(axesBrush);
      yText->setFont(_graphFont);
      yText->setPos(xOffset - textSpacing - yText->boundingRect().width(), graphLineY - fontHalfHeight);
      yText->setZValue(AXES_Z);
      _scene->addItem(yText);
    }

    graphLineY -= yGraphScale;
  }
}