QGraphicsItem *MapScene::createLayerItem(Layer *layer) { QGraphicsItem *layerItem = nullptr; if (TileLayer *tl = layer->asTileLayer()) { layerItem = new TileLayerItem(tl, mMapDocument); } else if (ObjectGroup *og = layer->asObjectGroup()) { const ObjectGroup::DrawOrder drawOrder = og->drawOrder(); ObjectGroupItem *ogItem = new ObjectGroupItem(og); int objectIndex = 0; for (MapObject *object : og->objects()) { MapObjectItem *item = new MapObjectItem(object, mMapDocument, ogItem); if (drawOrder == ObjectGroup::TopDownOrder) item->setZValue(item->y()); else item->setZValue(objectIndex); mObjectItems.insert(object, item); ++objectIndex; } layerItem = ogItem; } else if (ImageLayer *il = layer->asImageLayer()) { layerItem = new ImageLayerItem(il, mMapDocument); } Q_ASSERT(layerItem); layerItem->setVisible(layer->isVisible()); return layerItem; }
void GridLine::setVisible (bool visible) { for (int i = 0; i < m_segments.count(); i++) { QGraphicsItem *item = m_segments [i]; item->setVisible (visible); } }
/*! \brief Called by the UAVObject which got updated Updates the numeric value and/or the icon if the dial wants this. */ void MonitorWidget::telemetryUpdated(double txRate, double rxRate) { double txIndex = (txRate - minValue) / (maxValue - minValue) * txNodes.count(); double rxIndex = (rxRate - minValue) / (maxValue - minValue) * rxNodes.count(); if (connected) { this->setToolTip(QString("Tx: %0 bytes/s, Rx: %1 bytes/s").arg(txRate).arg(rxRate)); } for (int i = 0; i < txNodes.count(); i++) { QGraphicsItem *node = txNodes.at(i); bool visible = ( /*connected &&*/ (i < txIndex)); if (visible != node->isVisible()) { node->setVisible(visible); node->update(); } } for (int i = 0; i < rxNodes.count(); i++) { QGraphicsItem *node = rxNodes.at(i); bool visible = ( /*connected &&*/ (i < rxIndex)); if (visible != node->isVisible()) { node->setVisible(visible); node->update(); } } if (txSpeed) { if (connected) { txSpeed->setPlainText(QString("%0").arg(txRate)); } txSpeed->setVisible(connected); txSpeed->update(); } if (rxSpeed) { if (connected) { rxSpeed->setPlainText(QString("%0").arg(rxRate)); } rxSpeed->setVisible(connected); rxSpeed->update(); } update(); }
void dmz::QtPluginCanvasObjectBasic::_process_item_state ( ObjectStruct &os, const Mask &State, const String &GroupName, const Config &ItemList) { StateGroupStruct *group (os.groupTable.lookup (GroupName)); if (!group) { if (!GroupName) { group = &(os.defaultGroup); } else { group = new StateGroupStruct (GroupName); if (os.groupTable.store (GroupName, group)) { group->next = os.groupList; os.groupList = group; } else { delete group; group = 0; } } } if (group) { StateStruct *ss (new StateStruct (State)); ss->next = group->stateList; group->stateList = ss; group->groupState |= ss->State; if (!(group->defaultState) && !(ss->State)) { group->defaultState = ss; } ConfigIterator it; Config cd; while (ItemList.get_next_config (it, cd)) { const String Name (config_to_string ("name", cd)); QGraphicsItem *item (os.itemTable.lookup (Name)); if (item) { item->setVisible (False); ss->itemTable.store (ss->itemTable.get_count (), item); } } } }
void Checker::setVisibleSide (SideSegments &sideSegments, bool visible) { for (int i = 0; i < sideSegments.count(); i++) { QGraphicsItem *item = sideSegments [i]; if (item != 0) { item->setVisible (visible); } } }
// Converts the value into an percentage: // this enables smooth movement in moveIndex below void TelemetryMonitorWidget::showTelemetry() { txIndex = (txValue-minValue)/(maxValue-minValue) * NODE_NUMELEM; rxIndex = (rxValue-minValue)/(maxValue-minValue) * NODE_NUMELEM; if (connected) this->setToolTip(QString("Tx: %0 bytes/sec\nRx: %1 bytes/sec").arg(txValue).arg(rxValue)); else this->setToolTip(QString("Disconnected")); int i; int nodeMargin = 8; int leftMargin = 60; QGraphicsItem* node; for (i=0; i < txNodes.count(); i++) { node = txNodes.at(i); node->setPos((i*(node->boundingRect().width() + nodeMargin)) + leftMargin, (node->boundingRect().height()/2) - 2); node->setVisible(connected && i < txIndex); node->update(); } for (i=0; i < rxNodes.count(); i++) { node = rxNodes.at(i); node->setPos((i*(node->boundingRect().width() + nodeMargin)) + leftMargin, (node->boundingRect().height()*2) - 2); node->setVisible(connected && i < rxIndex); node->update(); } QRectF rect = graph->boundingRect(); txSpeed->setPos(rect.right() - 110, rect.top()); txSpeed->setPlainText(QString("%0").arg(txValue)); txSpeed->setVisible(connected); rxSpeed->setPos(rect.right() - 110, rect.top() + (rect.height() / 2)); rxSpeed->setPlainText(QString("%0").arg(rxValue)); rxSpeed->setVisible(connected); update(); }
void Widget::placeborders(){ double P=500,Q=300; QRectF lol2(P,Q,50,100); QGraphicsItem* lol = scene->addRect(lol2); lol->setTransformOriginPoint(P+25,Q+50); lol->setRotation(45); QGraphicsRectItem* lolI = new QGraphicsRectItem(P*scale,Q*scale,50*scale,100*scale); lolI->setTransformOriginPoint((P+25)*scale,(Q+50)*scale); lolI->setRotation(45); lol->setVisible(true); next = next->addToList(new rectangle(lolI,(P+25)*scale,(Q+50)*scale, lol,true,50*scale,100*scale)); QRectF top(0,0,990,10); QRectF left(0,0,10,690); QRectF right(980,0,10,690); QRectF bottom(0,680,990,10); QGraphicsRectItem* Rtop = new QGraphicsRectItem(0*scale,0*scale,990*scale,10*scale); QGraphicsRectItem* Rleft = new QGraphicsRectItem(0*scale,0*scale,10*scale,690*scale); QGraphicsRectItem* Rright = new QGraphicsRectItem(980*scale,0*scale,10*scale,690*scale); QGraphicsRectItem* Rbottom = new QGraphicsRectItem(0*scale,680*scale,990*scale,10*scale); QGraphicsItem* itop = scene->addRect(top); itop->setVisible(true); QGraphicsItem* ileft = scene->addRect(left); ileft->setVisible(true); QGraphicsItem* iright = scene->addRect(right); iright->setVisible(true); QGraphicsItem* ibottom = scene->addRect(bottom); ibottom->setVisible(true); next = next->addToList(new rectangle(Rtop,990/2*scale,5*scale, itop,true,990*scale,10*scale)); next = next->addToList(new rectangle(Rleft,5*scale,690/2*scale, ileft,true,10*scale,690*scale)); next = next->addToList(new rectangle(Rright,985*scale,690/2*scale, iright,true,10*scale,690*scale)); next = next->addToList(new rectangle(Rbottom,990/2*scale,685*scale, ibottom,true,990*scale,10*scale)); }
/** * A layer has changed. This can mean that the layer visibility, opacity or * offset changed. */ void MapItem::layerChanged(Layer *layer) { Preferences *prefs = Preferences::instance(); QGraphicsItem *layerItem = mLayerItems.value(layer); Q_ASSERT(layerItem); layerItem->setVisible(layer->isVisible()); qreal multiplier = 1; if (prefs->highlightCurrentLayer() && isAbove(mapDocument()->currentLayer(), layer)) multiplier = opacityFactor; layerItem->setOpacity(layer->opacity() * multiplier); layerItem->setPos(layer->offset()); updateBoundingRect(); // possible layer offset change }
/** * A layer has changed. This can mean that the layer visibility, opacity or * offset changed. */ void MapScene::layerChanged(int index) { const Layer *layer = mMapDocument->map()->layerAt(index); QGraphicsItem *layerItem = mLayerItems.at(index); layerItem->setVisible(layer->isVisible()); qreal multiplier = 1; if (mHighlightCurrentLayer && mMapDocument->currentLayerIndex() < index) multiplier = opacityFactor; layerItem->setOpacity(layer->opacity() * multiplier); layerItem->setPos(layer->offset()); // Layer offset may have changed, affecting the scene rect and grid updateSceneRect(); if (mGridVisible) update(); }
void GraphicsScene::showCurves (bool show, bool showAll, const QString &curveNameWanted) { LOG4CPP_INFO_S ((*mainCat)) << "GraphicsScene::showCurves" << " show=" << (show ? "true" : "false") << " showAll=" << (showAll ? "true" : "false") << " curve=" << curveNameWanted.toLatin1().data(); const QList<QGraphicsItem*> &items = QGraphicsScene::items(); QList<QGraphicsItem*>::const_iterator itr; for (itr = items.begin(); itr != items.end(); itr++) { QGraphicsItem* item = *itr; // Skip the image and only process the Points bool isPoint = (item->data (DATA_KEY_GRAPHICS_ITEM_TYPE).toInt () == GRAPHICS_ITEM_TYPE_POINT); bool isCurve = (item->data (DATA_KEY_GRAPHICS_ITEM_TYPE).toInt () == GRAPHICS_ITEM_TYPE_LINE); if (isPoint || isCurve) { bool showThis = show; if (show && !showAll) { QString identifier = item->data (DATA_KEY_IDENTIFIER).toString (); if (isPoint) { QString curveNameGot = Point::curveNameFromPointIdentifier (identifier); showThis = (curveNameWanted == curveNameGot); } else { showThis = (curveNameWanted == identifier); } } item->setVisible (showThis); } } }
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; } }