void ImageLabelWidget::addRectangleTest() { QAbstractGraphicsShapeItem* i = scene_->addRect(0, 0, 25, 25); i->setFlag(QGraphicsItem::ItemIsMovable); i->setBrush(QColor(0,0,128,0)); i->setPen(QPen(QColor(255, 0, 0), 2)); i->setZValue(255); }
void CSharedPainterScene::drawLastItemBorderRect( void ) { if( ! lastAddItem_ ) return; if( ! lastAddItem_->drawingObject() ) return; QAbstractGraphicsShapeItem* i = reinterpret_cast<QAbstractGraphicsShapeItem *>(lastAddItem_->drawingObject()); if( ! i ) return; // setting style.. QPainterPath path = createCoveringBorderPath( lastItemBorderType_, i ); if ( path.isEmpty() ) return; clearLastItemBorderRect(); QAbstractGraphicsShapeItem* lastBorderItem = addPath( path ); lastBorderItem->setPen( QPen( Util::getComplementaryColor(backgroundColor_, penColor() ), 2) ); lastBorderItem->setZValue( currentZValue() ); lastCoverGraphicsItem_ = lastBorderItem; // clear lastTempBlinkShowFlag_ = true; lastTimeValue_ = QDateTime::currentDateTime().toMSecsSinceEpoch(); timeoutRemoveLastCoverItem_ = DEFAULT_TIMEOUT_REMOVE_LAST_COVER_ITEM; }
void Main::addCircle() { QAbstractGraphicsShapeItem* i = canvas.addEllipse(QRectF(0,0,50,50)); i->setFlag(QGraphicsItem::ItemIsMovable); i->setPen(Qt::NoPen); i->setBrush( QColor(qrand()%32*8,qrand()%32*8,qrand()%32*8) ); i->setPos(qrand()%int(canvas.width()),qrand()%int(canvas.height())); i->setZValue(qrand()%256); }
void Main::addRectangle() { QAbstractGraphicsShapeItem *i = canvas.addRect( QRectF(qrand()%int(canvas.width()), qrand()%int(canvas.height()), canvas.width()/5, canvas.width()/5) ); i->setFlag(QGraphicsItem::ItemIsMovable); int z = qrand()%256; i->setBrush( QColor(z,z,z) ); i->setPen( QPen(QColor(qrand()%32*8,qrand()%32*8,qrand()%32*8), 6) ); i->setZValue(z); }
void Lighting::setupScene() { m_scene.setSceneRect(-300, -200, 600, 460); QLinearGradient linearGrad(QPointF(-100, -100), QPointF(100, 100)); linearGrad.setColorAt(0, QColor(255, 255, 255)); linearGrad.setColorAt(1, QColor(192, 192, 255)); setBackgroundBrush(linearGrad); QRadialGradient radialGrad(30, 30, 30); radialGrad.setColorAt(0, Qt::yellow); radialGrad.setColorAt(0.2, Qt::yellow); radialGrad.setColorAt(1, Qt::transparent); QPixmap pixmap(60, 60); pixmap.fill(Qt::transparent); QPainter painter(&pixmap); painter.setPen(Qt::NoPen); painter.setBrush(radialGrad); painter.drawEllipse(0, 0, 60, 60); painter.end(); m_lightSource = m_scene.addPixmap(pixmap); m_lightSource->setZValue(2); for (int i = -2; i < 3; ++i) for (int j = -2; j < 3; ++j) { QAbstractGraphicsShapeItem *item; if ((i + j) & 1) item = new QGraphicsEllipseItem(0, 0, 50, 50); else item = new QGraphicsRectItem(0, 0, 50, 50); item->setPen(QPen(Qt::black, 1)); item->setBrush(QBrush(Qt::white)); QGraphicsDropShadowEffect *effect = new QGraphicsDropShadowEffect; effect->setBlurRadius(8); item->setGraphicsEffect(effect); item->setZValue(1); item->setPos(i * 80, j * 80); m_scene.addItem(item); m_items << item; } }
void Main::addLogo() { if ( logo_fn.isEmpty() ) return; if ( !logoimg ) { logoimg = new QImage[4]; logoimg[0].load( logo_fn ); logoimg[1] = logoimg[0].smoothScale( int(logoimg[0].width()*0.75), int(logoimg[0].height()*0.75) ); logoimg[2] = logoimg[0].smoothScale( int(logoimg[0].width()*0.5), int(logoimg[0].height()*0.5) ); logoimg[3] = logoimg[0].smoothScale( int(logoimg[0].width()*0.25), int(logoimg[0].height()*0.25) ); } QAbstractGraphicsShapeItem* i = new ImageItem(logoimg[qrand()%4]); canvas.addItem(i); i->setPos(qrand()%int(canvas.width()-logoimg->width()), qrand()%int(canvas.height()-logoimg->width())); i->setZValue(qrand()%256+256); }
void Main::addButterfly() { if ( butterfly_fn.isEmpty() ) return; if ( !butterflyimg ) { butterflyimg = new QImage[4]; butterflyimg[0].load( butterfly_fn ); butterflyimg[1] = butterflyimg[0].smoothScale( int(butterflyimg[0].width()*0.75), int(butterflyimg[0].height()*0.75) ); butterflyimg[2] = butterflyimg[0].smoothScale( int(butterflyimg[0].width()*0.5), int(butterflyimg[0].height()*0.5) ); butterflyimg[3] = butterflyimg[0].smoothScale( int(butterflyimg[0].width()*0.25), int(butterflyimg[0].height()*0.25) ); } QAbstractGraphicsShapeItem* i = new ImageItem(butterflyimg[qrand()%4]); canvas.addItem(i); i->setPos(qrand()%int(canvas.width()-butterflyimg->width()), qrand()%int(canvas.height()-butterflyimg->height())); i->setZValue(qrand()%256+250); }
void MatrixElement::setCurrent(bool current) { if (m_current == current) return; QAbstractGraphicsShapeItem *item = dynamic_cast<QAbstractGraphicsShapeItem *>(m_item); if (!item) return; QColor colour; if (!current) { colour = QColor(200, 200, 200); } else { if (event()->has(BaseProperties::TRIGGER_SEGMENT_ID)) { colour = Qt::gray; } else { long velocity = 100; event()->get<Int>(BaseProperties::VELOCITY, velocity); colour = DefaultVelocityColour::getInstance()->getColour(velocity); } } item->setBrush(colour); item->setZValue(current ? 1 : 0); if (current) { item->setPen (QPen(GUIPalette::getColour(GUIPalette::MatrixElementBorder), 0)); } else { item->setPen (QPen(GUIPalette::getColour(GUIPalette::MatrixElementLightBorder), 0)); } m_current = current; }