Exemplo n.º 1
1
void
DigestTreeScene::updateNode(QString sessionPrefix, QString nick, uint64_t seqNo)
{
  Roster_iterator it = m_roster.find(sessionPrefix);
  if (it == m_roster.end()) {
    DisplayUserPtr p(new DisplayUser());
    p->setPrefix(sessionPrefix);
    p->setSeq(seqNo);
    m_roster.insert(p->getPrefix(), p);
    plot(m_rootDigest);
  }
  else {
    it.value()->setSeq(seqNo);
    DisplayUserPtr p = it.value();
    QGraphicsTextItem *item = p->getSeqTextItem();
    QGraphicsRectItem *rectItem = p->getInnerRectItem();
    std::string s = boost::lexical_cast<std::string>(p->getSeqNo());
    item->setPlainText(s.c_str());
    QRectF textBR = item->boundingRect();
    QRectF rectBR = rectItem->boundingRect();
    item->setPos(rectBR.x() + (rectBR.width() - textBR.width())/2,
                 rectBR.y() + (rectBR.height() - textBR.height())/2);
  }
  m_displayRootDigest->setPlainText(m_rootDigest);
  updateNick(sessionPrefix, nick);
}
Exemplo n.º 2
0
MagicMenuItem::MagicMenuItem()
{
  int itemSize = 55;

  setRect( -itemSize/2, -itemSize/2, itemSize, itemSize );
  setBrush( QColor( 230,229,229 ) );

  QPen pen;
  pen.setBrush( Qt::NoBrush );
  setPen( pen );

  QGraphicsTextItem *textItem = new QGraphicsTextItem( i18n("Magic"), this );

  int textWidth = textItem->boundingRect().width();
  int textHeight = textItem->boundingRect().height();

  textItem->setPos( - textWidth / 2, - textHeight / 2 );

  m_fanMenu = new FanMenu( this );
  m_fanMenu->setZValue( 50 );
  m_fanMenu->hide();
  m_fanMenu->setStartAngle( 80 );
  m_fanMenu->setEndAngle( 280 );

  FanMenuItem *menuItem = m_fanMenu->addItem( i18n("Reset\nlayout") );
  connect( menuItem, SIGNAL( clicked() ), SIGNAL( resetLayout() ) );
  menuItem = m_fanMenu->addItem( i18n("Settings") );
  connect( menuItem, SIGNAL( clicked() ), SIGNAL( showSettings() ) );

  m_fanMenu->setupItems( 80 );

  setAcceptHoverEvents( true );
}
Exemplo n.º 3
0
void IdentityItem::updateItem( const Polka::Identity &identity )
{
  m_identity = identity;

  foreach( QGraphicsItem *child, childItems() ) {
    delete child;
  }

  if ( identity.type() == "group" ) {
    int circleSize = m_itemSize + 14;
    QGraphicsEllipseItem *groupCircle = new QGraphicsEllipseItem( this );
    groupCircle->setRect( -circleSize/2, -circleSize/2,
      circleSize, circleSize );
    QPen pen;
    pen.setBrush( Qt::white );
    pen.setWidth( 4 );
    groupCircle->setPen( pen );
  }

  QPixmap pixmap = m_model->pixmap( identity );

  QGraphicsItem *item = new QGraphicsPixmapItem( pixmap, this );
  item->setPos( -pixmap.width() / 2, -pixmap.height() / 2 );

  QGraphicsTextItem *textItem = new QGraphicsTextItem( identity.name().value() );

  int textWidth = textItem->boundingRect().width();
  int textHeight = textItem->boundingRect().height();

  m_nameItem = new RoundedRectItem( this );
  m_nameItem->setRect( 0, 0, textWidth, textHeight );
  m_nameItem->setBrush( QColor( 255,255,230 ) );
  m_nameItem->setZValue( 10 );

  textItem->setParentItem( m_nameItem );

  m_nameItem->setPos( - textWidth / 2, 30 );

  m_fanMenu = new FanMenu( this );
  m_fanMenu->setZValue( 50 );

  FanMenuItem *menuItem = m_fanMenu->addItem( i18n("Remove") );
  connect( menuItem, SIGNAL( clicked() ), SLOT( emitRemoveIdentity() ) );
  m_checkMenuItem = m_fanMenu->addItem( i18n("Check") );
  connect( m_checkMenuItem, SIGNAL( clicked() ), SLOT( checkItem() ) );
  if ( identity.type() == "group" ) {
    menuItem = m_fanMenu->addItem( i18n("Go to") );
  } else {
    menuItem = m_fanMenu->addItem( i18n("Show") );
  }
  connect( menuItem, SIGNAL( clicked() ), SLOT( emitShowIdentity() ) );
  m_fanMenu->setupItems();

  hidePopups();
}
Exemplo n.º 4
0
void TXaxis::setAnswersForBarChart(QList<TgroupedQAunit>& listOfLists) {
    setLength(m_qWidth * (listOfLists.size() + 1));
    update(boundingRect());
    m_ticTips.clear();
    for (int i = 0; i < listOfLists.size(); i++) {
        QGraphicsTextItem *ticTip = new QGraphicsTextItem();
        ticTip->setHtml(listOfLists[i].description());
        TgraphicsTextTip::alignCenter(ticTip);
        if ((ticTip->boundingRect().width() * scale()) > m_qWidth)
            ticTip->setScale(((qreal)m_qWidth * scale()) / ticTip->boundingRect().width());
        scene()->addItem(ticTip);
        ticTip->setPos(pos().x() + mapValue(i + 1) - (ticTip->boundingRect().width() * ticTip->scale()) / 2 , pos().y() + 15);
        m_ticTips << ticTip;
    }
}
Exemplo n.º 5
0
void MainWindow::draw_legend(QPointF const& start)
{
	QGraphicsTextItem* var = scene->addText("VAR", legend_font);
	QPointF nstart = QPointF(start.x() -var->boundingRect().size().width(), start.y() -var->boundingRect().size().height());
	var->setPos(nstart);
	var->setDefaultTextColor(clr_var);

	QGraphicsTextItem* abs = scene->addText("ABS", legend_font);
	abs->setPos(nstart.x(), nstart.y() -11);
	abs->setDefaultTextColor(clr_abs);

	QGraphicsTextItem* app = scene->addText("APP", legend_font);
	app->setPos(nstart.x(), nstart.y() -22);
	app->setDefaultTextColor(clr_app);
}
void KeypointItem::showDescription()
{
	if(!placeHolder_ || !placeHolder_->isVisible())
	{
		if(!placeHolder_)
		{
			QString info = QString( "Keypoint = %1\n"
									"Word = %2\n"
									"Response = %3\n"
									"Angle = %4\n"
									"X = %5\n"
									"Y = %6\n"
									"Size = %7").arg(id_).arg(wordID_).arg(kpt_.response).arg(kpt_.angle).arg(kpt_.pt.x).arg(kpt_.pt.y).arg(kpt_.size);

			placeHolder_ = new QGraphicsRectItem();
			placeHolder_->setVisible(false);
			this->scene()->addItem(placeHolder_);
			placeHolder_->setBrush(QBrush(QColor ( 0, 0, 0, 170 ))); // Black transparent background
			QGraphicsTextItem * text = new QGraphicsTextItem(placeHolder_);
			text->setDefaultTextColor(this->pen().color().rgb());
			text->setPlainText(info);
			placeHolder_->setRect(text->boundingRect());
		}


		QPen pen = this->pen();
		this->setPen(QPen(pen.color(), pen.width()+2));
		placeHolder_->setZValue(this->zValue()+1);
		placeHolder_->setPos(this->mapToScene(0,0));
		placeHolder_->setVisible(true);
	}
}
Exemplo n.º 7
0
/**@brief displays a new screen to indicate that the player has won the game */
void Game::display_end_screen() {
    level->input->releaseKeyboard();
    level->clear();
    delete level;
    level = nullptr;

    //clear the screen from the level
    scene = new QGraphicsScene();
    setScene(scene);

    //next create the end screen text
    QGraphicsTextItem* endText = new QGraphicsTextItem(QString("You defeated all the demons! Congratulations Champion!"));
    //set font and size
    QFont endFont ("Adventure", 25);
    endText->setFont(endFont);
    //position the text
    int endXPos = this->width()/2 - endText->boundingRect().width()/2;
    int endYPos = 150;
    endText->setPos(endXPos, endYPos);
    //add it to the scene
    scene->addItem(endText);


    //create back to main menu button
    Button* returnToMenu = new Button(QString("Return to Menu"));
    //position button
    int returnXPos = this->width()/2 - returnToMenu->boundingRect().width()/2;
    int returnYPos = 425;
    returnToMenu->setPos(returnXPos, returnYPos);
    //connect this button to quit the game
    QObject::connect(returnToMenu, SIGNAL(clicked()), this, SLOT(displayMainMenu()));
    scene->addItem(returnToMenu);
}
Exemplo n.º 8
0
//! [3]
void View::addItems()
{
    int officeCount = officeTable->rowCount();

    int imageOffset = 150;
    int leftMargin = 70;
    int topMargin = 40;

    for (int i = 0; i < officeCount; i++) {
        ImageItem *image;
        QGraphicsTextItem *label;
        QSqlRecord record = officeTable->record(i);

        int id = record.value("id").toInt();
        QString file = record.value("file").toString();
        QString location = record.value("location").toString();

        int columnOffset = ((i / 3) * 37);
        int x = ((i / 3) * imageOffset) + leftMargin + columnOffset;
        int y = ((i % 3) * imageOffset) + topMargin;

        image = new ImageItem(id, QPixmap(":/" + file));
        image->setData(0, i);
        image->setPos(x, y);
        scene->addItem(image);

        label = scene->addText(location);
        QPointF labelOffset((150 - label->boundingRect().width()) / 2, 120.0);
        label->setPos(QPointF(x, y) + labelOffset);
    }
}
Exemplo n.º 9
0
QRectF Visualizer::putWord(QString word, float x, float y, bool isOnTop, int pos, QMap<int, QVector<int> > map) {
    QGraphicsTextItem *wordItem = new QGraphicsTextItem(QString(word));
    if(selWordRef.isActive()) {
        if(selWordRef.isOnTop() == isOnTop) {
            if(selWordRef.getPos() == pos) {
                wordItem->setDefaultTextColor(QColor("red"));
            }
        } else {
            QMapIterator<int, QVector<int> > i(map);
            while(i.hasNext()) {
                i.next();
                qDebug() << i.key() << " --- " << selWordRef.getPos() - 1;
            }
            QVector<int> targets = map[selWordRef.getPos() - 1];
            if(targets.contains(pos)) {
                wordItem->setDefaultTextColor(QColor("orange"));
            }
        }
    }
    wordItem->setFont(font);
    wordItem->setPos(x, y);
    wordItem->setData(IS_ON_TOP_KEY, QVariant(isOnTop));
    wordItem->setData(POS_KEY, QVariant(pos));
    QRectF rect = wordItem->boundingRect();
    scene->addItem(wordItem);
    return rect;
}
Exemplo n.º 10
0
void 
RSceneDevice::TextUTF8(double x, double y, char *str,
		       double rot, double hadj,
		       R_GE_gcontext *gc)
{
    if (debug) Rprintf("RSceneDevice::TextUTF8\n");
    int col = gc->col;
    //double gamma = gc->gamma;
    double cex = gc->cex;
    double ps = gc->ps;
    double lineheight = gc->lineheight;
    int fontface = gc->fontface;
    char* fontfamily = gc->fontfamily; // [201] ??
    QString qstr = QString::fromUtf8(str);
    QGraphicsTextItem 
	*text = addText(qstr, 
			r2qFont(fontfamily, fontface, ps, cex, lineheight,
				defaultFamily()));
    text->setDefaultTextColor(r2qColor(col));
    QRectF brect = text->boundingRect();
    text->rotate(-rot);
    text->translate(-hadj * brect.width(), -0.7 * brect.height());
    text->setPos(x, y);
    addClippedItem(text);
    return;
}
Exemplo n.º 11
0
/**@brief shows a set of instructions for the user to understand gameplay */
void Game::display_instructions() {
    //start by clearing the scene from the Main Menu
    scene->clear();

    //next we create the instructions portion
    QGraphicsTextItem* instructionsText =
            new QGraphicsTextItem (QString("You are about to embark on an epic quest champion! In order to protect the\n"
                                           "Emerald Dream, you must cleanse the land of demons. Use WASD or the arrow\n"
                                           "keys to move around and Spacebar to fire your wrath attack. At any time you\n"
                                           "can hit escape if the battle becomes too intense. Beware of the demons, if they\n"
                                           "cross the threshold this will lower your health. If your health reaches 0, you\n"
                                           "lose the game. If you kill 10 of the demons, you win! You have all you need\n"
                                           "now fulfill your druidic duties! May Elune be with you!"));
    //set the font and size
    QFont instructFont ("Lithos Pro", 17);
    instructionsText->setFont(instructFont);
    //position the text
    int instructXPos = this->width()/2 - instructionsText->boundingRect().width()/2;
    int instructYPos = 150;
    instructionsText->setPos(instructXPos, instructYPos);
    //add it to the scene
    scene->addItem(instructionsText);

    //create the Back to Main Menu Button
    Button* returnToMenu = new Button(QString("Return to Menu"));
    //position button
    int returnXPos = this->width()/2 - returnToMenu->boundingRect().width()/2;
    int returnYPos = 425;
    returnToMenu->setPos(returnXPos, returnYPos);
    //connect this button to quit the game
    QObject::connect(returnToMenu, SIGNAL(clicked()), this, SLOT(displayMainMenu()));
    scene->addItem(returnToMenu);

}
Exemplo n.º 12
0
/**@brief creates a new display to indicate that the player has lost and needs to restart */
void Game::display_game_over() {
    qDebug() << "game over.";

    level->input->releaseKeyboard();
    level->clear();
    delete level;
    level = nullptr;

    //clear the screen from the level
    scene = new QGraphicsScene();
    setScene(scene);

    //next create the Game Over text
    QGraphicsTextItem* gameOverText = new QGraphicsTextItem(QString("You Perished. Game Over."));
    //set font and size
    QFont game_over_font ("28 Days Later", 25);
    gameOverText->setFont(game_over_font);
    //position the text
    int gameOverXPos = this->width()/2 - gameOverText->boundingRect().width()/2;
    int gameOverYPos = 150;
    gameOverText->setPos(gameOverXPos, gameOverYPos);
    //add it to the scene
    scene->addItem(gameOverText);


    //create back to main menu button
    Button* returnToMenu = new Button(QString("Return to Menu"));
    //position button
    int returnXPos = this->width()/2 - returnToMenu->boundingRect().width()/2;
    int returnYPos = 425;
    returnToMenu->setPos(returnXPos, returnYPos);
    //connect this button to quit the game
    QObject::connect(returnToMenu, SIGNAL(clicked()), this, SLOT(displayMainMenu()));
    scene->addItem(returnToMenu);
}
Exemplo n.º 13
0
QGraphicsTextItem * GraphicsButton::decorateKey(const QRectF & cell,int group,int level) {
  QString text = m_keydef->getDecoration(group,level);
  QGraphicsTextItem * item = new QGraphicsTextItem(this);

  int scriptCount = 0;
  /// Get the script for the text and use it as CSS selector
  /// selectors are case insensitive
  ///
  QString script;
  if (text.size() == 1) {
    script = UcdScripts::getScript(text.at(0).unicode());
    if ( ! script.isEmpty()) {
      scriptCount = 1;
    }
  }
  else {
    script = UcdScripts::getScript(text,&scriptCount);
    if (scriptCount != 1) {
      script = "default";
    }
  }
  script = script.toCaseFolded();
  if (! m_css.isEmpty())
    item->document()->setDefaultStyleSheet(m_css);
  /// this stops Arabic being moved to the right
  QTextOption topt;
  topt.setTextDirection(Qt::LeftToRight);
  item->document()->setDefaultTextOption(topt);
  QString sep("<br/>");
  QString html;
  QStringList w = text.toHtmlEscaped().split(QChar(' '),QString::SkipEmptyParts);
  //  QFont f("Amiri",30);
  //  item->setFont(f);
  //  html = QString("<html><body><span class=\"%1\">%2</span></body></html>").arg(script).arg(text);
  html = QString("<span class=\"%1\">%2</span>").arg(script).arg(w.join("<br/>"));

  item->setHtml(html);//Html(html);

  QRectF wr = item->boundingRect();

  /// align the text centrally in its bounding rect
  qreal dx = cell.width() - wr.width();
  qreal dy = cell.height() - wr.height();


  if (m_keydef->centerText(group,level)) {
    dy = dy/2;
  }
  else {
    int vpos = m_keydef->getVerticalAdjust(group,level);
    dy += vpos;
  }

  item->setPos(cell.topLeft() + QPointF(dx/2,dy));//dy/2));
  item->setDefaultTextColor(m_textColor);
  this->setBrush(QBrush(m_backgroundUpColor));
  this->setPen(QPen(m_textColor));
  return item;
}
Exemplo n.º 14
0
void GameScene::displayPoints(long p_wonPoints, qreal p_xPos, qreal p_yPos)
{
    // Launch a singleShot timer
    QTimer::singleShot(1000, this, SLOT(hidePoints()));

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

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

    // Positioning and customization of the point label
    tempRef->setDefaultTextColor(QColor(QLatin1Literal("#FFFF00")));
    tempRef->setFont(QFont(QLatin1Literal("Helvetica"), 15, QFont::Normal, false));
    tempRef->setPos(p_xPos - (tempRef->boundingRect().width() / 2), p_yPos - (tempRef->boundingRect().height() / 2));
    tempRef->setZValue(-1);
}
void LegendItem::addId(int i) {
    QGraphicsTextItem* id = new QGraphicsTextItem(this);
    id->setHtml(QString("[%1]").arg(i));
    id->setFont(getFont());

    int idXPos = 0;
    int idYPos = _currHeight + _space;

    if (id->boundingRect().width() > rect().width()) {
      idXPos = (int)(0 - id->boundingRect().width() / 2);
    } else {
      idXPos = (int)((rect().width() - id->boundingRect().width()) / 2);
    }

    id->setPos(idXPos, idYPos);

    _currHeight += _space + (int)(id->boundingRect().height());
}
Exemplo n.º 16
0
int main(int argc, char **argv)
{
    Q_INIT_RESOURCE(stickman);
    QApplication app(argc, argv);

    StickMan *stickMan = new StickMan;
    stickMan->setDrawSticks(false);

    QGraphicsTextItem *textItem = new QGraphicsTextItem();
    textItem->setHtml("<font color=\"white\"><b>Stickman</b>"
        "<p>"
        "Tell the stickman what to do!"
        "</p>"
        "<p><i>"
        "<li>Press <font color=\"purple\">J</font> to make the stickman jump.</li>"
        "<li>Press <font color=\"purple\">D</font> to make the stickman dance.</li>"
        "<li>Press <font color=\"purple\">C</font> to make him chill out.</li>"
        "<li>When you are done, press <font color=\"purple\">Escape</font>.</li>"
        "</i></p>"
        "<p>If he is unlucky, the stickman will get struck by lightning, and never jump, dance or chill out again."
        "</p></font>");
    qreal w = textItem->boundingRect().width();
    QRectF stickManBoundingRect = stickMan->mapToScene(stickMan->boundingRect()).boundingRect();
    textItem->setPos(-w / 2.0, stickManBoundingRect.bottom() + 25.0);

    QGraphicsScene scene;
    scene.addItem(stickMan);

    scene.addItem(textItem);
    scene.setBackgroundBrush(Qt::black);

    GraphicsView view;
    view.setRenderHints(QPainter::Antialiasing);
    view.setTransformationAnchor(QGraphicsView::NoAnchor);
    view.setScene(&scene);

    QRectF sceneRect = scene.sceneRect();
    // making enough room in the scene for stickman to jump and die
    view.resize(sceneRect.width() + 100, sceneRect.height() + 100);
    view.setSceneRect(sceneRect);

    view.show();
    view.setFocus();

    LifeCycle cycle(stickMan, &view);
    cycle.setDeathAnimation(":/animations/dead.bin");

    cycle.addActivity(":/animations/jumping.bin", Qt::Key_J);
    cycle.addActivity(":/animations/dancing.bin", Qt::Key_D);
    cycle.addActivity(":/animations/chilling.bin", Qt::Key_C);

    cycle.start();


    return app.exec();
}
void LegendItem::addName(const QString& n) {
    QGraphicsTextItem* name = new QGraphicsTextItem(this);
    QString html = n;
    html.replace(QString(" "), QString("<br/>"));
    name->setHtml(QString("<p align=\"center\">%1</p>").arg(html));
    name->setFont(getFont());

    int nameXPos = 0;
    int nameYPos = (int)(rect().height() - _space - name->boundingRect().height());

    if (name->boundingRect().width() > rect().width()) {
      nameXPos = (int)(0 - name->boundingRect().width() / 2);
    } else {
      nameXPos = (int)((rect().width() - name->boundingRect().width()) / 2);
    }

    name->setPos(nameXPos, nameYPos);
    _currHeight = (int)(_space + name->boundingRect().height());
}
Exemplo n.º 18
0
MainMenuItem::MainMenuItem()
  : m_defaultItemSize( 55 )
{
  m_timer.setSingleShot( true );
  connect( &m_timer, SIGNAL( timeout() ), SLOT( hideItems() ) );

  setItemSize( m_defaultItemSize );

  setBrush( QColor( 230,229,229 ) );

  QPen pen;
  pen.setBrush( Qt::NoBrush );
  setPen( pen );

  QGraphicsTextItem *textItem = new QGraphicsTextItem( i18n("Menu"), this );

  int textWidth = textItem->boundingRect().width();
  int textHeight = textItem->boundingRect().height();

  textItem->setPos( - textWidth / 2, - textHeight / 2 );

  m_fanMenu = new FanMenu( this );
  m_fanMenu->setZValue( 50 );
  m_fanMenu->hide();
  m_fanMenu->setStartAngle( 170 );
  m_fanMenu->setEndAngle( 280 );
  m_fanMenu->setRadius( 220 );
  m_fanMenu->setSpacing( 5 );

  FanMenuItem *menuItem = m_fanMenu->addItem( i18n("Clone\ngroup") );
  connect( menuItem, SIGNAL( clicked() ), SIGNAL( cloneGroup() ) );
  menuItem = m_fanMenu->addItem( i18n("Remove\ngroup") );
  connect( menuItem, SIGNAL( clicked() ), SIGNAL( removeGroup() ) );
  menuItem = m_fanMenu->addItem( i18n("Add\ngroup") );
  connect( menuItem, SIGNAL( clicked() ), SIGNAL( addGroup() ) );
  menuItem = m_fanMenu->addItem( i18n("Add\nperson") );
  connect( menuItem, SIGNAL( clicked() ), SIGNAL( addPerson() ) );

  m_fanMenu->setupItems( 90 );

  setAcceptHoverEvents( true );
}
Exemplo n.º 19
0
void NodeBackDropPrivate::refreshLabelText(const QString &text)
{
    QString textLabel = text;
    textLabel.replace("\n", "<br>");
    textLabel.prepend("<div align=\"left\">");
    textLabel.append("</div>");
    QFont f;
    String_KnobGui::parseFont(textLabel, f);
    label->setFont(f);

    label->setHtml(textLabel);
    
    QRectF labelBbox = label->boundingRect();
    QRectF nameBbox = name->boundingRect();
    QRectF bbox = _publicInterface->boundingRect();
    int w = std::max(std::max(bbox.width(), labelBbox.width()),nameBbox.width());
    int h = std::max(labelBbox.height() + nameBbox.height() * 1.5 + 10, bbox.height());
    _publicInterface->resize(w, h);
    _publicInterface->update();

}
Exemplo n.º 20
0
void GameManager::endGame()
{
	end++;
	if(end == NUM_PILES_BASE)
	{
		QFont font("Dejavu", 24, QFont::Bold);
		QGraphicsTextItem *endGameText = scene->addText(trUtf8("Вы выйграли!!!"), font);
		QRectF rc = endGameText->boundingRect();
		endGameText->setPos(rc.x() - rc.center().x(), rc.y() - rc.center().y());
		endGameText->setDefaultTextColor(QColor(255, 255, 0));
		endGameText->setZValue(100);
	}
}
Exemplo n.º 21
0
/**@brief sets up the Main Menu before gameplay begins */
void Game::displayMainMenu() {
    //clear scene in case someone comes from the instructions
    scene->clear();

    //need to remove current background to allow level to set background
    this->setBackgroundBrush(Qt::NoBrush);
    //load in background photo
    this->setBackgroundBrush(QBrush(QImage(":/images/emeraldDream.jpg").scaled(1024,768)));

    //start by creating Title Text
    QGraphicsTextItem* titleText = new QGraphicsTextItem(QString("Protect the Emerald Dream"));
    QFont titleFont ("Adventure", 50); //sets title font and size
    titleText->setFont(titleFont);
    //now we position the text
    int titleXPos = this->width()/2 - titleText->boundingRect().width()/2;
    int titleYPos = 150;
    titleText->setPos(titleXPos, titleYPos);
    //now we add it to the scene
    scene->addItem(titleText);

    //next we create the Play Button
    Button* playButton = new Button(QString("Play"));
    //now we position the button
    int buttonXPos = this->width()/2 - playButton->boundingRect().width()/2;
    int buttonYPos = 275;
    playButton->setPos(buttonXPos, buttonYPos);
    //connect this button to start the game
    QObject::connect(playButton, SIGNAL(clicked()), this, SLOT(start()));
    //now we add it to the scene
    scene->addItem(playButton);

    //create the Instructions Button
    Button* instructionsButton = new Button(QString("Instructions"));
    //position button
    int instructXPos = this->width()/2 - instructionsButton->boundingRect().width()/2;
    int instructYPos = 350;
    instructionsButton->setPos(instructXPos, instructYPos);
    //connect this button to show instructions
    QObject::connect(instructionsButton, SIGNAL(clicked()), this, SLOT(display_instructions()));
    scene->addItem(instructionsButton);

    //create the Quit Button
    Button* quitButton = new Button(QString("Quit"));
    //position button
    int quitXPos = this->width()/2 - quitButton->boundingRect().width()/2;
    int quitYPos = 425;
    quitButton->setPos(quitXPos, quitYPos);
    //connect this button to quit the game
    QObject::connect(quitButton, SIGNAL(clicked()), this, SLOT(close()));
    scene->addItem(quitButton);
}
Exemplo n.º 22
0
void MainMenu::displayMainMenu()
{
    QGraphicsTextItem * titleText = new QGraphicsTextItem(tr("Starlight"));
    QFont titleFont("calibri", 50);
    titleText->setFont(titleFont);

    int titleX = this->width() / 2 - titleText->boundingRect().width() /2;
    int titleY = 50;
    titleText->setPos(titleX, titleY);
    scene_->addItem(titleText);

    Button * playButton = new Button(tr("Play"));

    int playX = this->width() / 2 - playButton->boundingRect().width() /2;
    int playY = 150;
    playButton->setPos(playX, playY);
    connect(playButton, &Button::clicked, this, &MainMenu::start);

    scene_->addItem(playButton);


    Button * rulesButton = new Button(tr("Rules"));

    int ruleX = this->width() / 2 - rulesButton->boundingRect().width() / 2;
    int ruleY = 225;
    rulesButton->setPos(ruleX, ruleY);
    connect(rulesButton, &Button::clicked, this, &MainMenu::help);

    scene_->addItem(rulesButton);


    Button * editorButton = new Button(tr("Editor"));

    int editX = this->width() / 2 - editorButton->boundingRect().width() /2;
    int editY = 300;
    editorButton->setPos(editX, editY);
    connect(editorButton, &Button::clicked, this, &MainMenu::editor);

    scene_->addItem(editorButton);


    Button * quitButton = new Button(tr("Exit"));

    int quitX = this->width() / 2 - quitButton->boundingRect().width() /2;
    int quitY = 375;
    quitButton->setPos(quitX, quitY);
    connect(quitButton, &Button::clicked, this, &QGraphicsView::close);

    scene_->addItem(quitButton);
}
Exemplo n.º 23
0
void TXaxis::setAnswersList(QList<TQAunit*> *answers, Tlevel* level) {
    m_answers = answers;
    m_level = level;
    setLength(m_qWidth * (m_answers->size() + 1));
    update(boundingRect());
    m_ticTips.clear();
    for (int i = 0; i < m_answers->size(); i++) {
        QGraphicsTextItem *ticTip = new QGraphicsTextItem();
        setTicText(ticTip, m_answers->operator[](i), i + 1);
        scene()->addItem(ticTip);
        ticTip->setPos(pos().x() + mapValue(i+1) - ticTip->boundingRect().width() / 2 , pos().y() + 15);
        m_ticTips << ticTip;
    }
}
Exemplo n.º 24
0
/// Adds a caption for a graph beneath the actual diagram.
void DiagramScene::addCaption(const QString &name, QPen &pen)
{
	QGraphicsItemGroup* caption = new QGraphicsItemGroup(NULL);
	QGraphicsLineItem* l = addLine(0,0,100,0,pen);
	QGraphicsTextItem* t = addText(name);
	l->setPos(0,0);
	t->setPos(110, -(t->boundingRect()).height() / 2);
	caption->addToGroup(l);
	caption->addToGroup(t);
	caption->setFlag(QGraphicsItem::ItemIgnoresTransformations, true);

	_graphCaptions.push_back(caption);
	addItem(_graphCaptions[_graphCaptions.size() - 1]);
}
Exemplo n.º 25
0
void
DigestTreeScene::reDrawNode(DisplayUserPtr p, QColor rimColor)
{
    QGraphicsRectItem *rimItem = p->getRimRectItem();
    rimItem->setBrush(QBrush(rimColor));
    QGraphicsRectItem *innerItem = p->getInnerRectItem();
    innerItem->setBrush(QBrush(Qt::lightGray));
    QGraphicsTextItem *seqTextItem = p->getSeqTextItem();
    std::string s = boost::lexical_cast<std::string>(p->getSeqNo());
    seqTextItem->setPlainText(s.c_str());
    QRectF textBR = seqTextItem->boundingRect();
    QRectF innerBR = innerItem->boundingRect();
    seqTextItem->setPos(innerBR.x() + (innerBR.width() - textBR.width())/2,
                        innerBR.y() + (innerBR.height() - textBR.height())/2);
}
Exemplo n.º 26
0
 void View::addItems()
 {
     int imageOffset = 140;
     int leftMargin = 40;
     int topMargin = 40;

     if(comportamiento == 0)
     {
         query.prepare("select imagen_pk from e_imagen where (url = '"+carpeta+"' and reporte_operatorio_pk IS NULL)");
         qDebug()<<"Entro a NULL"<<endl;

     }
     else
     {
         query.prepare("select imagen_pk from e_imagen where (url = '"+carpeta+"' and reporte_operatorio_pk = '"+documento+"')");
         qDebug()<<"Entro a "<<documento<<endl;
         //qDebug("select imagen_pk from e_imagen where (url = '"+carpeta.toStdString()+"' and reporte_operatorio_pk = '"+documento.toStdString()+"')");

     }
     int i = 0;
     query.exec();
     while(query.next())
     {
         QGraphicsTextItem *label = new QGraphicsTextItem;
         int id = query.value(0).toInt();
         QString file = query.value(0).toString()+".JPG";
         qDebug()<<"Agregando al visor"<<file<<endl;
         QFileInfo fileInfo(file);
         //fecha de creacion de archivo
         QString location = fileInfo.created().toString();
         int columnOffset = ((i / 3) * 37);
         int x = ((i / 3) * imageOffset) + leftMargin + columnOffset;
         int y = ((i % 3) * imageOffset) + topMargin;
         ImageItem *image = new ImageItem(id, QPixmap(file));
         image->setData(0, i);
         image->setPos(x, y);
         scene->addItem(image);
         label = scene->addText(location);
         QPointF labelOffset((150 - label->boundingRect().width()) / 2, 120.0);
         label->setPos(QPointF(x, y) + labelOffset);
         i++;
         //Guardando los punteros para luego eliminarlos;
         QPair<QGraphicsTextItem*, ImageItem*> par_punteros;
         par_punteros.first = label;
         par_punteros.second = image;
         punteros.push_back(par_punteros);
     }
 }
// -----------------------------------------------------------------------------
//
// -----------------------------------------------------------------------------
void ImageGraphicsDelegate::_displayTextMessage(QString message)
{
  if (NULL != m_CurrentGraphicsItem)
  {
    m_GraphicsScene->removeItem(m_CurrentGraphicsItem); //Remove the image that is displaying
    m_CurrentGraphicsItem->setParentItem(NULL); // Set the parent to NULL
    delete m_CurrentGraphicsItem; // Delete the object
  }
  m_CurrentGraphicsItem = NULL;
  QGraphicsTextItem* tItem = m_GraphicsScene->addText(message); // Add the new image into the display

  QRectF rect = tItem->boundingRect();
  m_GraphicsScene->setSceneRect(rect);
  m_GraphicsView->setScene(m_GraphicsScene);
  m_GraphicsView->centerOn(tItem);
  m_GraphicsScene->update(rect);
}
Exemplo n.º 28
0
void
DigestTreeScene::updateNick(QString sessionPrefix, QString nick)
{
  Roster_iterator it = m_roster.find(sessionPrefix);
  if (it != m_roster.end()) {
    DisplayUserPtr p = it.value();
    if (nick != p->getNick()) {
      p->setNick(nick);
      QGraphicsTextItem *nickItem = p->getNickTextItem();
      QGraphicsRectItem *nickRectItem = p->getNickRectItem();
      nickItem->setPlainText(p->getNick());
      QRectF rectBR = nickRectItem->boundingRect();
      QRectF nickBR = nickItem->boundingRect();
      nickItem->setPos(rectBR.x() + (rectBR.width() - nickBR.width())/2, rectBR.y() + 5);
    }
  }
}
Exemplo n.º 29
0
void PSV_CircularIndicatorItem::drawMark(int zValue)
{
    double colorCircleRadius = m_colorCircleRadiusRatio * m_outerRadius;
    double value= m_min;
    double dValue = (m_max - m_min) / m_numTicks;
    QString strValue;
    for(int i=0;i<=m_numTicks;i++)
    {
        QPointF topPot;
        QPointF bottomPot;

        if(i%10==0)
        {
            strValue=QObject::tr("%1").arg(value);
            bottomPot = QPointF(m_rect.center().x(), m_rect.center().y() - colorCircleRadius);
            topPot = QPointF(m_rect.center().x(), m_rect.center().y() - colorCircleRadius*1.05);
            value+=10 * dValue;
            QGraphicsTextItem* item = new QGraphicsTextItem(strValue, this);
            item->setDefaultTextColor(QColor(Qt::white));
            item->setFont(m_markFont);
            item->setZValue(zValue);
            QRectF rectF = item->boundingRect();
            QPointF movePointF = QPointF(m_rect.center().x() - 0.5 * rectF.width()
                                         , m_rect.center().y() - colorCircleRadius*1.05 - rectF.height());
            item->moveBy(movePointF.x(), movePointF.y());
            item->setTransform(QTransform().translate(m_rect.center().x() - movePointF.x(), m_rect.center().y() - movePointF.y()).rotate(270 * i / 100-135).translate(-(m_rect.center().x() - movePointF.x()), -(m_rect.center().y() - movePointF.y())));
        }
        else if(i%5==0)
        {
            bottomPot = QPointF(m_rect.center().x(), m_rect.center().y() - colorCircleRadius);
            topPot = QPointF(m_rect.center().x(), m_rect.center().y() - colorCircleRadius*1.03);
        }
        else
        {
            bottomPot = QPointF(m_rect.center().x(), m_rect.center().y() - colorCircleRadius);
            topPot = QPointF(m_rect.center().x(), m_rect.center().y() - colorCircleRadius*1.01);
        }
        QGraphicsLineItem* item = new QGraphicsLineItem(QLineF(topPot, bottomPot), this);
        item->setPen(QPen(Qt::white));
        item->setZValue(zValue);
        item->setTransform(QTransform().translate(m_rect.center().x(), m_rect.center().y()).rotate(270.0 * i / 100-135).translate(-m_rect.center().x(), -m_rect.center().y()));
    }
}
Exemplo n.º 30
0
double 
RSceneDevice::StrWidthUTF8(char *str,
			   R_GE_gcontext *gc)
{
    if (debug) Rprintf("RSceneDevice::StrWidthUTF8\n");
    double cex = gc->cex;
    double ps = gc->ps;
    double lineheight = gc->lineheight;
    int fontface = gc->fontface;
    char* fontfamily = gc->fontfamily;
    QString qstr = QString::fromUtf8(str);
    QGraphicsTextItem *text = new QGraphicsTextItem(str, 0);
    text->setFont(r2qFont(fontfamily, fontface, 
			  ps, cex, lineheight,
			  defaultFamily()));
    QRectF brect = text->boundingRect();
    delete text;
    return brect.width();
}