Esempio n. 1
0
void cbGraphView::contentsMouseMoveEvent(QMouseEvent *e)
{
	double x,y,dist;
	int xi,yi;

    xi=(int)(e->x()/(simulator->labCanvasWidth/(double)GRIDSIZE));
    yi=(int)(e->y()/(simulator->labCanvasHeight/(double)GRIDSIZE));

    if(xi>=0 && xi < GRIDSIZE && yi >=0 && yi < GRIDSIZE) {
        x=(xi+0.5)*simulator->Lab()->Width()/GRIDSIZE;
        y=(GRIDSIZE-yi-0.5)*simulator->Lab()->Height()/GRIDSIZE;
	    dist = simulator->distGrid[xi][yi];
        if(xi<GRIDSIZE/2) {
            distLabel->setPos(e->x()+10,e->y());
	    }
        else {
            distLabel->setPos(e->x()-200,e->y());
        }
        distLabel->setText(QString("(%1,%2) -> dist=%3").arg(x).arg(y).arg(dist));
	}
    else {
        distLabel->setText("Out of bounds");
	}

    scene()->update();
}
Esempio n. 2
0
bool
PacketsScene::setUpNodeLines ()
{
  bool foundNodes = false;
  QRectF r = sceneRect ();
  qreal height = r.bottom () - r.top ();
  m_borderHeight = 0.01 * height;
  m_lineLength = r.bottom () - m_borderHeight;
  r.setWidth (100 * m_interNodeSpacing);
  setSceneRect (r);
  uint32_t nodeCount = AnimNodeMgr::getInstance ()->getCount ();
  if (!nodeCount)
    return foundNodes;

  for (int lineIndex = 0; lineIndex < m_allowedNodes.count () ; ++lineIndex)
    {
      foundNodes = true;
      QGraphicsLineItem * lineItem = addLine (m_interNodeSpacing * lineIndex, m_borderHeight, m_interNodeSpacing * lineIndex, m_lineLength);
      m_nodeLines[m_allowedNodes[lineIndex]] = lineItem;

      QGraphicsSimpleTextItem * nodeIdText = new QGraphicsSimpleTextItem (QString::number (m_allowedNodes[lineIndex]));
      addItem (nodeIdText);
      m_nodeIdTexts.push_back (nodeIdText);
      nodeIdText->setPos (m_interNodeSpacing * lineIndex, -m_borderHeight);
      m_lineIndex[m_allowedNodes[lineIndex]] = lineIndex;
    }
  m_rulerLine->setLine (RULER_X, m_borderHeight, RULER_X, m_lineLength);
  return foundNodes;

}
Esempio n. 3
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);
    }
}
Esempio n. 4
0
asd::Waypoint* asd::Waypoint::Builder::build() {
    asd::Waypoint *waypoint = new asd::Waypoint;

    //
    // Properties
    //

    waypoint->setPen(properties_.pen());
    waypoint->setBrush(properties_.brush());
    waypoint->setZValue(properties_.zlayer());

    qreal size = properties_.size();
    waypoint->setRect(-size/2, -size/2, size, size);

    if (!name_.isEmpty()) {
        QGraphicsSimpleTextItem *text = new QGraphicsSimpleTextItem(waypoint);
        text->setPen(Qt::NoPen);
        text->setBrush(properties_.pen().brush());

        text->setText(name_);
    }

    waypoint->setPos(location_);

    return waypoint;
}
Esempio n. 5
0
 void UpdText()
 {
     if (nLootAmount > 0)
         text->setText(name + "\n" + QString::fromStdString(FormatMoney(nLootAmount)));
     else
         text->setText(name);
 }
Esempio n. 6
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;

}
Esempio n. 7
0
 void UpdTextPos(int64 lootAmount)
 {
     if (lootAmount > 0)
         text->setPos(x, std::max(0, y - 20));
     else
         text->setPos(x, std::max(0, y - 12));
 }
Esempio n. 8
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;
}
Esempio n. 9
0
void ToolTipItem::addToolTip(const QString &toolTip, const QIcon &icon, const QPixmap& pixmap)
{
	const IconMetrics& iconMetrics = defaultIconMetrics();

	QGraphicsPixmapItem *iconItem = 0;
	double yValue = title->boundingRect().height() + iconMetrics.spacing;
	Q_FOREACH (ToolTip t, toolTips) {
		yValue += t.second->boundingRect().height();
	}
	if (entryToolTip.second) {
		yValue += entryToolTip.second->boundingRect().height();
	}
	iconItem = new QGraphicsPixmapItem(this);
	if (!icon.isNull()) {
		iconItem->setPixmap(icon.pixmap(iconMetrics.sz_small, iconMetrics.sz_small));
	} else if (!pixmap.isNull()) {
		iconItem->setPixmap(pixmap);
	}
	const int sp2 = iconMetrics.spacing * 2;
	iconItem->setPos(sp2, yValue);

	QGraphicsSimpleTextItem *textItem = new QGraphicsSimpleTextItem(toolTip, this);
	textItem->setPos(sp2 + iconMetrics.sz_small + sp2, yValue);
	textItem->setBrush(QBrush(Qt::white));
	textItem->setFlag(ItemIgnoresTransformations);
	toolTips.push_back(qMakePair(iconItem, textItem));
}
Esempio n. 10
0
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));
        }
    }
}
Esempio n. 11
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);
}
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;
}
Esempio n. 14
0
void TimeScene::drawTime(DateTime currentDay, DTime time, QModelIndex index, int groupLevel) {
    QSize size = sizeHint(index);
    int bordermargin = (size.height() * .1) / 2;

    QBrush b;
    QPen pen(QColor(0, 0, 150));
    QBrush textBrush;
    if (groupLevel == 2) {
        b = QBrush(Qt::white);
        pen = QPen(QColor(0, 0, 150));
        textBrush = QBrush(Qt::darkBlue);
    }
    if (groupLevel == 1) {
        b = QBrush(Qt::lightGray);
        pen = QPen(QColor(0, 0, 50));
        textBrush = QBrush(Qt::blue);
    }
    if (groupLevel == 0) {
        b = QBrush(Qt::darkGray);
        pen = QPen(QColor(100, 100, 200));
        textBrush = QBrush(Qt::white);
    }

    int daysToStart = _startDate.daysTo(currentDay);
    int x1 = daysToStart * _dayWidth;
    int y1 = _currentY + bordermargin;
    int x2 = x1 + _dayWidth;
    int y2 = _currentY + size.height() - bordermargin;

//    QGraphicsRectItem* item = this->addRect(x1, y1, (x2 - x1), (y2 - y1), pen, b);
    QRect rect(x1, y1, (x2 - x1), (y2 - y1));
    GraphicsRectItem* item = new GraphicsRectItem(rect, index);
    this->addItem(item);
    item->setPen(pen);
    item->setBrush(b);
    item->setZValue(1);
    item->setAcceptHoverEvents(true);

    connect(item, SIGNAL(itemHoverEnter(QModelIndex)), this, SLOT(receiveItemHoverEnter(QModelIndex)));
    connect(item, SIGNAL(itemHoverLeave(QModelIndex)), this, SLOT(receiveItemHoverLeave(QModelIndex)));

    QFont font("Arial", 8);

    font.setBold((groupLevel <= 1));
    font.setItalic((groupLevel == 0));

    QGraphicsSimpleTextItem* text = addSimpleText(time.toQString(), font);
    text->setBrush(textBrush);
    text->setPos(x1 + 2, y1 + 1);
    text->setVisible(true);
    text->setZValue(1);
}
Esempio n. 15
0
void DivePlannerGraphics::pointInserted(const QModelIndex& parent, int start , int end)
{
	DiveHandler *item = new DiveHandler ();
	scene()->addItem(item);
	handles << item;

	QGraphicsSimpleTextItem *gasChooseBtn = new QGraphicsSimpleTextItem();
	scene()->addItem(gasChooseBtn);
	gasChooseBtn->setZValue(10);
	gasChooseBtn->setFlag(QGraphicsItem::ItemIgnoresTransformations);
	gases << gasChooseBtn;
	drawProfile();
}
Esempio n. 16
0
  foreach (const PropSet* word, words) {
    QTransform transf;
    QGraphicsSimpleTextItem* item = new QGraphicsSimpleTextItem();
#if QT_VERSION >= 0x040400
    item->setBoundingRegionGranularity(1.0);
#endif

    // Set the properties of item & transf
    foreach (const SetterFactory& setterFactory, setterFactories) {
      Setter* setter =
	getSetterAndDef(*word, def, setterFactory, setters).first;
      setter->apply(*word, *item, transf, filledArea);
    }
Esempio n. 17
0
void GraphViewer::onSceneMouseRelease(QGraphicsSceneMouseEvent *mouseEvent)
{

    // need to put the connecting line on the background otherwise it is detected under the mouse
    _drawingEdge->setZValue(EDGE_LINE_Z);

    QGraphicsItem * item = _scene.itemAt(mouseEvent->scenePos(), QTransform());
    if (qgraphicsitem_cast<QGraphicsEllipseItem*>(item)
            || qgraphicsitem_cast<QGraphicsSimpleTextItem*>(item))
    {
        QGraphicsEllipseItem* vertex = qgraphicsitem_cast<QGraphicsEllipseItem*>(item->parentItem());
        if (!vertex)
            vertex = qgraphicsitem_cast<QGraphicsEllipseItem*>(item);

        if (vertex)
        {
            double x = _drawingEdge->transform().dx();
            double y = _drawingEdge->transform().dy();
            _drawingEdge->setLine(0.0,0.0, vertex->scenePos().x()-x, vertex->scenePos().y()-y);
            _drawingEdge->setZValue(EDGE_LINE_Z);

            if (_drawingEdge->data(KEY_EDGE_VERTEX1) == vertex->data(KEY_EDGE_VERTEX1))
                _scene.removeItem(_drawingEdge);
            else
            {
                int defaultWeight = 1;
                _drawingEdge->setData(KEY_EDGE_VERTEX2, vertex->data(KEY_VERTEX_ID));
                _drawingEdge->setData(KEY_EDGE_WEIGHT, defaultWeight);
                // draw edge weight
                QGraphicsSimpleTextItem * edgeWeight = _scene.addSimpleText(QString("%1").arg(defaultWeight));
                edgeWeight->setParentItem(_drawingEdge);
                edgeWeight->setBrush(Qt::blue);
                QLineF line = _drawingEdge->line();
                edgeWeight->setTransform(
                            QTransform::fromScale(0.005, 0.005)
                            * QTransform::fromTranslate(line.x2()*0.5, line.y2()*0.5)
                            );
                edgeWeight->setZValue(EDGE_TEXT_Z);
                // add to graph edges
                _edges << _drawingEdge;
            }
        }
    }
    else
    {
        _scene.removeItem(_drawingEdge);
    }
    _isDrawingEdge=false;
    _drawingEdge=0;
}
Esempio n. 18
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;
}
Esempio n. 19
0
ItemBook::ItemBook(QString Title)
{
    dragging = false;
    this->Title = Title;

    QGraphicsScene scene;
    scene.setParent(this);
    scene.addText(this->Title);
    QPen pen(QColor(0,0,0));
    scene.addLine(QLineF(0,0,1,2));
    this->resize(64,64*1.5);
    this->setScene(&scene);

    QGraphicsSimpleTextItem text;
    text.setText("Hello world");
    scene.addItem(&text);
}
Esempio n. 20
0
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));
}
Esempio n. 21
0
QList<QGraphicsSimpleTextItem*> GTUtilsPhyTree::getLabels(HI::GUITestOpStatus &os, QGraphicsView *treeView){
    QList<QGraphicsSimpleTextItem*> result;
    if(treeView == NULL){
        treeView = qobject_cast<QGraphicsView*>(GTWidget::findWidget(os, "treeView"));
    }
    GT_CHECK_RESULT(treeView, "treeView not found", result);
    QList<QGraphicsItem*> list = treeView->scene()->items();

    foreach(QGraphicsItem* item, list){
        QGraphicsSimpleTextItem* textItem = qgraphicsitem_cast<QGraphicsSimpleTextItem*>(item);
        if(textItem){
            bool ok;
            QString s = textItem->text();
            s.toDouble(&ok);
            if(!ok){
                result<<textItem;
            }
        }
    }
Esempio n. 22
0
void ToolTipItem::addToolTip(const QString &toolTip, const QIcon &icon)
{
	QGraphicsPixmapItem *iconItem = 0;
	double yValue = title->boundingRect().height() + SPACING;
	Q_FOREACH (ToolTip t, toolTips) {
		yValue += t.second->boundingRect().height();
	}
	if (!icon.isNull()) {
		iconItem = new QGraphicsPixmapItem(icon.pixmap(ICON_SMALL, ICON_SMALL), this);
		iconItem->setPos(SPACING, yValue);
	}

	QGraphicsSimpleTextItem *textItem = new QGraphicsSimpleTextItem(toolTip, this);
	textItem->setPos(SPACING + ICON_SMALL + SPACING, yValue);
	textItem->setBrush(QBrush(Qt::white));
	textItem->setFlag(ItemIgnoresTransformations);
	toolTips.push_back(qMakePair(iconItem, textItem));
	expand();
}
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");
}
Esempio n. 24
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;
}
Esempio n. 25
0
void GraphViewer::onValueEdited()
{
    bool ok=false;
    int newvalue = _valueEditor.text().toInt(&ok);
    if (ok)
    {

        if (qgraphicsitem_cast<QGraphicsSimpleTextItem*>(_editedItem))
        {
            QGraphicsSimpleTextItem* text = qgraphicsitem_cast<QGraphicsSimpleTextItem*>(_editedItem);
            text->setText(QString("%1").arg(newvalue));
            QGraphicsItem* parent = text->parentItem();
            if (parent)
            {
                parent->setData(KEY_EDGE_WEIGHT, newvalue);
            }
            _valueEditor.hide();
        }

    }
}
Esempio n. 26
0
void
AnimatorScene::initGridCoordinates ()
{
  for (int i = 0; i < m_gridCoordinates.size (); ++i)
    {
      QGraphicsSimpleTextItem * item = m_gridCoordinates[i];
      removeItem (item);
      delete item;
    }
  m_gridCoordinates.clear ();
  for (int i = 0; i < 9; i++) // only 9 coordinates will be marked
    {
      QGraphicsSimpleTextItem * item = new QGraphicsSimpleTextItem;
      item->setFlag (QGraphicsItem::ItemIgnoresTransformations);
      m_gridCoordinates.push_back (item);
      addItem (item);

    }
  markGridCoordinates ();

}
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));
}
void MenuEquipmentScreen::nextEquipmentItem() {
	if (_currentEquipmentListItem == _activeEquipmentListItems.last()) {
		// If the last equipment item was selected
		if (_currentSelectedEquipmentString == (_equipmentStringList.size()-1)) {

			for (int i = 0; i < _activeEquipmentListItems.size(); i++) {
				QGraphicsSimpleTextItem *item = _activeEquipmentListItems.at(i);
				item->setText(_equipmentStringList.at(i));
			}

			_currentSelectedEquipmentString = 0;
			setCurrentEquipmentItem(_activeEquipmentListItems.at(0), 0);

		} else { // Else scroll to the next equipment item

			for (int i = 0; i < _activeEquipmentListItems.size()-1; i++) {
				QGraphicsSimpleTextItem *item = _activeEquipmentListItems.at(i);
				item->setText(_activeEquipmentListItems.at(i+1)->text());
			}

			_currentSelectedEquipmentString++;
			QGraphicsSimpleTextItem *item = _activeEquipmentListItems.at(_activeEquipmentListItems.size() - 1);
			item->setText(_equipmentStringList.at(_currentSelectedEquipmentString));
			setCurrentEquipmentItem(item, _equipmentList.at(_currentSelectedEquipmentString - 1));
		}

	} else {
		_currentSelectedEquipmentString++;
		setCurrentEquipmentItem(_activeEquipmentListItems.at(_activeEquipmentListItems.indexOf(_currentEquipmentListItem) + 1), _equipmentList.at(_currentSelectedEquipmentString -1));
	}
}
Esempio n. 29
0
void LogView::createHeader() {
    _headerScene->clear();
    _hourScene->clear();

    QSize size = headerSizeHint();

    QLinearGradient grad(0, 0, 0, size.height());
    int dark = 210;
    grad.setColorAt(1, QColor(dark, dark, dark));
    grad.setColorAt(0.7, QColor(dark + 20, dark + 20, dark + 20));
    grad.setColorAt(0, Qt::white);
    QBrush background(grad);
    QPen pen(QColor(220, 220, 220));
    QSize sizeHint = _logScene->viewSizeHint();
    _headerScene->addRect(0, 0, sizeHint.width() + verticalScrollBar()->width() + 200, size.height() + 1, pen, background)->setZValue(0);

    int columnSize = _logScene->dayWidth();

    DateTime startDate = _logScene->startDate().addDays(-1);
    DateTime today;
    today.setHour(0);
    today.setMin(0);
    today.setSecs(0);
    for (int x = 0; x < _logScene->totalDays(); x++) {
        QPen textPen(Qt::black);
        QGraphicsSimpleTextItem* text = _headerScene->addSimpleText(startDate.addDays(1).toQDateTime().toString("dd-MMM"), QFont("Arial", 8));
        text->setPos((x * columnSize + 2) + 50, 3);
        text->setVisible(true);
//        text->setPen(textPen);
        text->setZValue(1);
        if (startDate == today) {
            _todayPos = (x * columnSize + 2);
        }
        startDate = startDate.addDays(1);
    }
    _headerView.setMaximumHeight(headerSizeHint().height());

    for (int x = 0; x < 24; x++) {
        _hourScene->addRect(0, x*BLOCKSIZE, 50, BLOCKSIZE, pen, background)->setZValue(0);
        std::stringstream ss;
        ss << x << ":00";
        QGraphicsSimpleTextItem* text = _hourScene->addSimpleText(ss.str().c_str());
        text->setPos(10, (x * BLOCKSIZE) + 10);
        text->setVisible(true);
//        text->setPen(textPen);
        text->setZValue(1);
    }
    _hourView.setScene(_hourScene);
    _hourView.setMaximumWidth(50);
}
Esempio n. 30
0
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);
}