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); }
MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::MainWindow) { // ----------------------------------------------------------------------- ui->setupUi(this); QGraphicsScene *scene = new QGraphicsScene(this); ui->graphicsView->setScene(scene); // ----------------------------------------------------------------------- // kolor pedzla QBrush brush = QBrush(Qt::red); brush.setStyle(Qt::DiagCrossPattern); // tworzymy obiekts QGraphicsRectItem *rect = new QGraphicsRectItem(10, 10, 90, 90); rect->setBrush(brush); // ----------------------------------------------------------------------- // ----------------------------------------------------------------------- // definiujemy czas trwania animacji QTimeLine *timeLine = new QTimeLine(1000); timeLine->setFrameRange(0, 100); // definiujemy animacje QGraphicsItemAnimation *animation = new QGraphicsItemAnimation(); animation->setItem(rect); animation->setTimeLine(timeLine); // animacja int odcinek = 100; for (int i = 0; i < 100; ++i) animation->setPosAt(i / 100.0, QPointF(i, i)); // uruchamiamy scenę i animację scene->addItem(rect); timeLine->start(); }
void tst_QGraphicsEffect::itemHasNoContents() { QGraphicsRectItem *parent = new QGraphicsRectItem; parent->setFlag(QGraphicsItem::ItemHasNoContents); MyGraphicsItem *child = new MyGraphicsItem; child->setParentItem(parent); child->resize(200, 200); QGraphicsScene scene; scene.addItem(parent); QGraphicsView view(&scene); view.show(); QTest::qWaitForWindowShown(&view); QTRY_COMPARE(child->nbPaint, 1); CustomEffect *effect = new CustomEffect; parent->setGraphicsEffect(effect); QTRY_COMPARE(effect->numRepaints, 1); for (int i = 0; i < 3; ++i) { effect->reset(); effect->update(); QTRY_COMPARE(effect->numRepaints, 1); } }
void tst_QGraphicsEffect::itemHasNoContents() { QGraphicsRectItem *parent = new QGraphicsRectItem; parent->setFlag(QGraphicsItem::ItemHasNoContents); MyGraphicsItem *child = new MyGraphicsItem; child->setParentItem(parent); child->resize(200, 200); QGraphicsScene scene; scene.addItem(parent); QGraphicsView view(&scene); view.show(); QTest::qWaitForWindowShown(&view); #ifdef Q_OS_MAC if (QSysInfo::MacintoshVersion == QSysInfo::MV_LION) { QEXPECT_FAIL("", "QTBUG-26858", Abort); } #endif QTRY_COMPARE(child->nbPaint, 1); CustomEffect *effect = new CustomEffect; parent->setGraphicsEffect(effect); QTRY_COMPARE(effect->numRepaints, 1); for (int i = 0; i < 3; ++i) { effect->reset(); effect->update(); QTRY_COMPARE(effect->numRepaints, 1); } }
void RToLSlideAnimation::runOneStep(QGraphicsScene * scene) { if (scene && !scaledImage_.isNull() && !hasAnimationEnded()) { for (int i = 0; i < pixelInfo_.height_; ++i) { //slide if (currentPixel_ >= 2) { QGraphicsItem * graphicsItem = scene->itemAt((currentPixel_ - 2) * pixelInfo_.size_, i * pixelInfo_.size_, QTransform()); QGraphicsRectItem * rect = dynamic_cast<QGraphicsRectItem *>(graphicsItem); rect->setBrush(QBrush(QColor(150, 150, 150))); } if (currentPixel_ < pixelInfo_.width_ + 1) { QRgb rgba = scaledImage_.pixel(currentPixel_ - 1, i); QColor color = QColor::fromRgba(rgba); QGraphicsItem * graphicsItem = scene->itemAt((currentPixel_ - 1) * pixelInfo_.size_, i * pixelInfo_.size_, QTransform()); QGraphicsRectItem * rect = dynamic_cast<QGraphicsRectItem *>(graphicsItem); rect->setBrush(QBrush(color)); } } } --currentPixel_; }
void QGraphicsVolumeView::updatePixmaps() { for (int i = 0; i < _volumeDisplays.size(); i++) { const int w = _volumeDisplays[i].Width(); const int h = _volumeDisplays[i].Height(); const int s = _volumeDisplays[i].Count(); for (int j = 0; j < s; j++) { AIRVolumeDisplay& display = _volumeDisplays[i]; QGraphicsRectItem* item = display.GetSliceData<QGraphicsRectItem>(j); if (item != NULL) { QList<QGraphicsItem*> childItems = item->childItems(); if (childItems.size() > 0) { QGraphicsPixmapItem* pixmapItem = (QGraphicsPixmapItem*) childItems[0]; QTransform pixmapTransform; if (_xFlipped && !_yFlipped) { pixmapTransform.setMatrix(-1, 0, 0, 0, 1, 0, w, 0, 1); pixmapItem->setTransform(pixmapTransform); } else if (!_xFlipped && _yFlipped) { pixmapTransform.setMatrix(1, 0, 0, 0, -1, 0, 0, h, 1); pixmapItem->setTransform(pixmapTransform); } else if (_xFlipped && _yFlipped) { pixmapTransform.setMatrix(-1, 0, 0, 0, -1, 0, w, h, 1); pixmapItem->setTransform(pixmapTransform); } else { pixmapItem->resetTransform(); } } } } } }
void MainWindow::recepcionMensaje(int quien, int tipo){ qDebug() << "Llega mensaje de " << quien << " con el tipo " << tipo; QGraphicsRectItem *item; if (!asociacionPidItem.contains(quien)){ if (tipo == TIPO_CREADO) { int pos_x = qrand() % (int)escena->width(); int pos_y = qrand() % (int)escena->height(); item = escena->addRect(pos_x, pos_y, 10, 10, QPen(Qt::black), QBrush(Qt::yellow)); asociacionPidItem[quien] = item; } contadorDeProcesos++; } else { item = asociacionPidItem[quien]; switch (tipo) { case TIPO_ACTIVIDAD_1: item->setBrush(QBrush(Qt::red)); break; case TIPO_ACTIVIDAD_2: item->setBrush(QBrush(Qt::blue)); break; case TIPO_CERRADO: // Quitar el item de la pantalla escena->removeItem(item); // Quitar el item del arreglo asociacionPidItem.remove(quien); this->contadorDeProcesos++; } } // Actualizar actualizarEstadisticas(); }
void ConfigurationSpaceScene::eval() { this->thread->stop(); this->clear(); rl::math::Vector maximum(this->model->getDof()); this->model->getMaximum(maximum); rl::math::Vector minimum(this->model->getDof()); this->model->getMinimum(minimum); QGraphicsRectItem* rect = this->addRect( minimum(this->x), -maximum(this->y), std::abs(maximum(this->x) - minimum(this->x)), std::abs(maximum(this->y) - minimum(this->y)), QPen(Qt::NoPen), QBrush(Qt::white) ); rect->setZValue(0); this->thread->delta = this->delta; this->thread->model = this->model; this->thread->x = this->x; this->thread->y = this->y; this->thread->start(); }
void SymbolDataEditor::rememberChanges() { if (scene->items().isEmpty()) return; if (itemToChange == Item::InPoint) { QGraphicsEllipseItem* inPointItem = static_cast<QGraphicsEllipseItem *>(scene->items(Qt::AscendingOrder).at(Item::InPoint)); inPoint = inPointItem->rect().center(); } if (itemToChange == Item::OutPoint) { QGraphicsEllipseItem* outPointItem = static_cast<QGraphicsEllipseItem *>(scene->items(Qt::AscendingOrder).at(Item::OutPoint)); outPoint = outPointItem->rect().center(); } if (itemToChange == Item::LimitsRect) { QGraphicsRectItem* limitsRectItem = static_cast<QGraphicsRectItem *>(scene->items(Qt::AscendingOrder).at(Item::LimitsRect)); limits = limitsRectItem->rect(); } correctLimits(); }
void MainWindow::addRectangle() { WGraphicsVectorRectItem* item = new WGraphicsVectorRectItem; item->setRect(QRectF(100,50,50,50)); m_scene->addItem(item); QPointF pos = item->pos(); WGraphicsVectorRectItem* item2 = new WGraphicsVectorRectItem; item2->setRect(QRectF(200,50,50,50)); m_scene->addItem(item2); QPointF pos2 = item2->pos(); QGraphicsRectItem* r = new QGraphicsRectItem(150,100,50,50); r->setBrush(Qt::red); m_scene->addItem(r); QPointF posR = r->pos(); WGraphicsVectorNodeItem* node = new WGraphicsVectorNodeItem(0); node->setNodePos(QPointF(300,300)); node->setVisible(true); m_scene->addItem(node); QRectF bb(250,100,50,100); QPolygonF poly(bb); UserInitArea* uia = new UserInitArea(0, poly); uia->setBrush(QColor(255,255,255,10)); m_scene->addItem(uia); }
PoseMeshScene::PoseMeshScene(QObject *parent) : QGraphicsScene(parent) { double graphicsWidth = 512; double graphicsHeight = 1024; // This rectangle will be a visual representation // of the bounds that the map can be dragged in mCanvasRect.setLeft(0); mCanvasRect.setTop(0); mCanvasRect.setWidth(graphicsWidth); mCanvasRect.setHeight(graphicsHeight); mVerticalMeshOffset = mCanvasRect.y() + 64; QBrush canvasBrush(QColor(192, 192, 255)); QGraphicsRectItem *canvasItem = addRect(mCanvasRect, QPen(), canvasBrush); canvasItem->setZValue(-100.0f); canvasItem->setEnabled(false); QBrush backgroundBrush(QPixmap(":/images/checker.png")); setBackgroundBrush(backgroundBrush); CreateTest(); }
void MyScene::changeTileColor(int index) { if(rects[index] == NULL) { // so index does not exist int rectX = index % (width/11); int rectY = floor(index / (width/11)); // create new object QGraphicsRectItem *tempRectItem = new QGraphicsRectItem(rectX*11 + 1, rectY*11+1, 9, 9); tempRectItem->setBrush(QBrush(*light)); // default color is white tempRectItem->setPen(QPen(*light)); rects[index] = tempRectItem; /* when item is added ones to the scene it is possible to change it properties * without adding it again and agian */ addItem(rects[index]); } else { // code change tile color depend on current color if(rects[index]->brush().color() == *light) { rects[index]->setBrush(QBrush(*dark)); rects[index]->setPen(QPen(*dark)); } else { rects[index]->setBrush(QBrush(*light)); rects[index]->setPen(QPen(*light)); } } }
void tst_QGraphicsEffect::inheritOpacity() { QGraphicsScene scene; QGraphicsRectItem *rectItem = new QGraphicsRectItem(0, 0, 10, 10); CustomItem *item = new CustomItem(0, 0, 10, 10, rectItem); scene.addItem(rectItem); item->setGraphicsEffect(new DeviceEffect); item->setPen(Qt::NoPen); item->setBrush(Qt::red); rectItem->setOpacity(0.5); QGraphicsView view(&scene); view.show(); QTest::qWaitForWindowShown(&view); QTRY_VERIFY(item->numRepaints >= 1); int numRepaints = item->numRepaints; rectItem->setOpacity(1); // item should have been rerendered due to opacity changing QTRY_VERIFY(item->numRepaints > numRepaints); }
void ShapeFormulaNode::AddFillRect(qreal x, qreal y, qreal width, qreal height, QColor& color) { QGraphicsRectItem* i = new QGraphicsRectItem(x, y, width, height, item); i->setBrush(QBrush(color)); i->setPen(QPen(color)); ((QGraphicsItemGroup*)item)->addToGroup(i); }
void tst_QGraphicsEffect::boundingRect() { // No source; empty bounding rect. CustomEffect *effect = new CustomEffect; QCOMPARE(effect->boundingRect(), QRectF()); // Install effect on QGraphicsItem. QRectF itemRect(0, 0, 100, 100); QGraphicsRectItem *item = new QGraphicsRectItem; item->setRect(itemRect); item->setGraphicsEffect(effect); int margin = effect->margin(); QCOMPARE(effect->boundingRect(), itemRect.adjusted(-margin, -margin, margin, margin)); QCOMPARE(effect->boundingRect(), effect->boundingRectFor(itemRect)); // Make sure disabling/enabling the effect doesn't change the bounding rect. effect->setEnabled(false); QCOMPARE(effect->boundingRect(), itemRect.adjusted(-margin, -margin, margin, margin)); QCOMPARE(effect->boundingRect(), effect->boundingRectFor(itemRect)); effect->setEnabled(true); QCOMPARE(effect->boundingRect(), itemRect.adjusted(-margin, -margin, margin, margin)); QCOMPARE(effect->boundingRect(), effect->boundingRectFor(itemRect)); // Change effect margins. effect->setMargin(margin = 20); QCOMPARE(effect->boundingRect(), itemRect.adjusted(-margin, -margin, margin, margin)); QCOMPARE(effect->boundingRect(), effect->boundingRectFor(itemRect)); // Uninstall effect on QGraphicsItem. QPointer<CustomEffect> ptr = effect; item->setGraphicsEffect(0); QVERIFY(!ptr); delete item; }
int main(int argc, char **argv) { QApplication app( argc, argv ); QGraphicsScene scene; QGraphicsView view(&scene); view.setBackgroundBrush(QBrush(Qt::black)); view.setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOn); view.setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOn); view.setDragMode(QGraphicsView::ScrollHandDrag); view.show(); // view.showFullScreen(); QGraphicsRectItem *r = scene.addRect(-50, -50, 10, 10); r->setPen(QPen(QColor(255, 0, 0))); r->setBrush(QBrush(QColor(0, 255, 0))); r->show(); r = scene.addRect(0, 0, 10, 10); r->setPen(QPen(QColor(255, 0, 0))); r->setBrush(QBrush(QColor(0, 255, 0))); r->show(); r = scene.addRect(200, 200, 10, 10); r->setPen(QPen(QColor(255, 0, 0))); r->setBrush(QBrush(QColor(0, 255, 0))); r->show(); scene.setSceneRect(-100, -100, 100, 100); view.resize(200, 200); return app.exec(); }
void JackContextGraphicsScene::changeToCurrentContext() { delete graphicsClientItemsClient; clear(); QGraphicsRectItem *dummy = new QGraphicsRectItem(-5000, -5000, 10000, 10000, 0, this); dummy->setVisible(false); graphicsClientItemsClient = new GraphicsClientItemsClient(this); }
QAbstractGraphicsShapeItem* GIFactory::createPortAdapteeGI() { // cast here otherwise -PORT_RADIUS will be about 4 billion and something // since PORT_RADIUS is unsigned const qreal r = (qreal)PORT_RADIUS; QGraphicsRectItem* adaptee = new QGraphicsRectItem(-r / 2, -r / 2, r, r); adaptee->setVisible(true); return adaptee; }
Pong::Pong() { // players player1 = new QGraphicsRectItem(0, 0, PADDLE, PADDLE * 3); player1->setPos(PADDLE, (HEIGHT - PADDLE * 3) / 2); player1->setBrush(QBrush(Qt::gray)); addItem(player1); player2 = new QGraphicsRectItem(0, 0, PADDLE, PADDLE * 3); player2->setPos(WIDTH - PADDLE * 2, (HEIGHT - PADDLE * 3) / 2); player2->setBrush(QBrush(Qt::gray)); addItem(player2); // ball ball = new QGraphicsEllipseItem(0, 0, PADDLE, PADDLE); ball->setPos((WIDTH - PADDLE) / 2, (HEIGHT - PADDLE) / 2); ball->setBrush(QBrush(Qt::gray)); addItem(ball); // score tscore1 = new QGraphicsSimpleTextItem(); tscore1->setText("0"); tscore1->setFont(QFont("Times", 36, QFont::Bold)); tscore1->setPos(WIDTH / 2 - PADDLE - 24, PADDLE); tscore1->setBrush(QBrush(Qt::gray)); addItem(tscore1); tscore2 = new QGraphicsSimpleTextItem(); tscore2->setText("0"); tscore2->setFont(QFont("Times", 36, QFont::Bold)); tscore2->setPos(WIDTH / 2 + PADDLE, PADDLE); tscore2->setBrush(QBrush(Qt::gray)); addItem(tscore2); // line int h = 0; int pointSize = PADDLE / 4; while (h < HEIGHT) { QGraphicsRectItem *linePoint = new QGraphicsRectItem(0, 0, pointSize, pointSize); linePoint->setBrush(QBrush(Qt::gray)); linePoint->setPos((WIDTH - pointSize) / 2, h); addItem(linePoint); h += pointSize * 2; } score1 = 0; score2 = 0; dx = -1; dy = -1; speedUpCounter = 0; ballSpeed = 0.2; setSceneRect(0, 0, WIDTH, HEIGHT); setBackgroundBrush(QBrush(Qt::black)); QTimeLine *timer = new QTimeLine(); timer->setFrameRange(0, 100); timer->setLoopCount(10000); timer->start(); connect(timer, SIGNAL(frameChanged(int)), this, SLOT(value_changed(int))); }
void Game::drawPanel(int x, int y, int width, int height, QColor color, double opacity){ QGraphicsRectItem* panel = new QGraphicsRectItem(x,y,width,height); QBrush br; br.setStyle(Qt::SolidPattern); br.setColor(color); panel->setBrush(br); panel->setOpacity(opacity); scene->addItem(panel); }
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; }
QGraphicsItem* CGraphicsRectItem::createItem() { QGraphicsRectItem* pItem = new QGraphicsRectItem(m_Parent); drawPen(pItem); drawBrush(pItem); pItem->setRect(GET_VALUE(x).toInt(),GET_VALUE(y).toInt(),GET_VALUE(w).toInt(),GET_VALUE(h).toInt()); return pItem; }
void BoardView::setWinningText(std::string const & text) { this->_winner = text; this->getGameInfos()._ui.gameStatusLabel->setText(text.c_str()); QGraphicsRectItem* rectItem = this->_scene.addRect(0, 0, this->_scene.width(), this->scene()->height(), QPen(Qt::white), QBrush(Qt::white)); rectItem->setOpacity(0.8); QGraphicsTextItem* textItem = this->_scene.addText(text.c_str(), QFont("Ubuntu, Calibri", 24, 600)); textItem->adjustSize(); textItem->setPos(((this->_board->getSize() * this->_lineSpacing - textItem->textWidth()) / 2), 100); }
virtual void operator()(QGraphicsItem* item, const QRectF& rect) { QGraphicsRectItem* rectItem = dynamic_cast<QGraphicsRectItem*>(item); if (rectItem) { rectItem->setRect(rect); } }
JackContextGraphicsScene::JackContextGraphicsScene() : graphicsClientItemsClient(new GraphicsClientItemsClient(this)), waitForMacroPosition(false), waitForModulePosition(false) { setBackgroundBrush(QBrush(QColor("lightsteelblue"))); QGraphicsRectItem *dummy = new QGraphicsRectItem(-5000, -5000, 10000, 10000, 0, this); dummy->setVisible(false); }
void VisualNavbar::fillData() { graphicsScene->clear(); cursorGraphicsItem = nullptr; // Do not try to draw if no sections are available. if (mappedSegments.length() == 0) { return; } int w = this->graphicsView->width(); int h = this->graphicsView->height(); double width_per_byte = (double)w / (double)totalMappedSize; xToAddress.clear(); double current_x = 0; for (auto mappedSegment : mappedSegments) { RVA segment_size = mappedSegment.address_to - mappedSegment.address_from; double segment_width = (double)segment_size * width_per_byte; QGraphicsRectItem *rect = new QGraphicsRectItem(current_x, 0, segment_width, h); rect->setBrush(QBrush(Config()->getColor("gui.navbar.empty"))); graphicsScene->addItem(rect); drawMetadata(mappedSegment.strings, mappedSegment.address_from, current_x, width_per_byte, h, Config()->getColor("gui.navbar.str")); drawMetadata(mappedSegment.symbols, mappedSegment.address_from, current_x, width_per_byte, h, Config()->getColor("gui.navbar.sym")); drawMetadata(mappedSegment.functions, mappedSegment.address_from, current_x, width_per_byte, h, Config()->getColor("gui.navbar.code")); // Keep track of where which memory segment is mapped so we are able to convert from // address to X coordinate and vice versa. struct xToAddress x2a; x2a.x_start = current_x; x2a.x_end = current_x + segment_width; x2a.address_from = mappedSegment.address_from; x2a.address_to = mappedSegment.address_to; xToAddress.append(x2a); current_x += segment_width; } // Update scene width graphicsScene->setSceneRect(graphicsScene->itemsBoundingRect()); // Draw cursor drawCursor(); }
void DlgSettingsPointMatch::load (CmdMediator &cmdMediator) { LOG4CPP_INFO_S ((*mainCat)) << "DlgSettingsPointMatch::load"; setCmdMediator (cmdMediator); // Flush old data if (m_modelPointMatchBefore != 0) { delete m_modelPointMatchBefore; } if (m_modelPointMatchAfter != 0) { delete m_modelPointMatchAfter; } // Save new data m_modelPointMatchBefore = new DocumentModelPointMatch (cmdMediator.document()); m_modelPointMatchAfter = new DocumentModelPointMatch (cmdMediator.document()); // Sanity checks. Incoming defaults must be acceptable to the local limits ENGAUGE_ASSERT (POINT_SEPARATION_MIN <= m_modelPointMatchAfter->minPointSeparation()); ENGAUGE_ASSERT (POINT_SEPARATION_MAX > m_modelPointMatchAfter->minPointSeparation()); ENGAUGE_ASSERT (POINT_SIZE_MIN <= m_modelPointMatchAfter->maxPointSize()); ENGAUGE_ASSERT (POINT_SIZE_MAX > m_modelPointMatchAfter->maxPointSize()); // Populate controls m_spinMinPointSeparation->setValue(m_modelPointMatchAfter->minPointSeparation()); m_spinPointSize->setValue(m_modelPointMatchAfter->maxPointSize()); int indexAccepted = m_cmbAcceptedPointColor->findData(QVariant(m_modelPointMatchAfter->paletteColorAccepted())); ENGAUGE_ASSERT (indexAccepted >= 0); m_cmbAcceptedPointColor->setCurrentIndex(indexAccepted); int indexCandidate = m_cmbCandidatePointColor->findData(QVariant(m_modelPointMatchAfter->paletteColorCandidate())); ENGAUGE_ASSERT (indexCandidate >= 0); m_cmbCandidatePointColor->setCurrentIndex(indexCandidate); int indexRejected = m_cmbRejectedPointColor->findData(QVariant(m_modelPointMatchAfter->paletteColorRejected())); ENGAUGE_ASSERT (indexRejected >= 0); m_cmbRejectedPointColor->setCurrentIndex(indexRejected); initializeBox (); // Fix the preview size using an invisible boundary QGraphicsRectItem *boundary = m_scenePreview->addRect (QRect (0, 0, cmdMediator.document().pixmap().width (), cmdMediator.document().pixmap().height ())); boundary->setVisible (false); m_scenePreview->addPixmap (cmdMediator.document().pixmap()); updateControls(); enableOk (false); // Disable Ok button since there not yet any changes updatePreview(); }
void updateMap() { for(int i = 0; i < mapWidth; ++i) { for(int j = 0; j < mapHeight; ++j) { QGraphicsRectItem* rect = rects[RectsKey(j, i)]; if(pMap[i*mapWidth+j] == 0) rect->setBrush(QBrush(Qt::blue)); if(pMap[i*mapWidth+j] == 1) rect->setBrush(QBrush(Qt::red)); } } int pOutBuffer[128]; int nNumSteps = FindPath(startX, startY, endX, endY, pMap, mapWidth, mapHeight, pOutBuffer, 128); for(int i = 0; i < nNumSteps; i++) { int y = pOutBuffer[i]/mapWidth; int x = pOutBuffer[i] - y*mapWidth; QGraphicsRectItem* rect = rects[RectsKey(x, y)]; rect->setBrush(QBrush(Qt::green)); } if(startX != -1 && startY != -1) { QGraphicsRectItem* rect = rects[RectsKey(startX, startY)]; rect->setBrush(QBrush(Qt::green)); } if(endX != -1 && endY != -1) { QGraphicsRectItem* rect = rects[RectsKey(endX, endY)]; rect->setBrush(QBrush(Qt::gray)); } }
void CustomGraphicsScene::removeAllShapes() { QPainterPath path; path.addRect(this->sceneRect()); setSelectionArea(path); removeSelectedShapes(); this->clear(); QGraphicsRectItem *item; addItem(item = new QGraphicsRectItem(QRectF(0,0,10000,10000))); item->setVisible(false); }
QGraphicsItem * GameObject::getAnimation() const { if(animation && !display_model) return animation->getCurrentSprite(); else { QGraphicsRectItem * rect = new QGraphicsRectItem(this->getModelRect()) ; rect->setBrush(objBrush); return rect; } }