Example #1
0
void OverviewWidget::setFps(int fps) {
    QList<QGraphicsItem*> items = overviewScene_->items();
    for (int i = 0; i < items.size(); ++i) {
        if (!(dynamic_cast<CurrentFrameGraphicsItem*>(items.at(i)) || dynamic_cast<QGraphicsRectItem*>(items.at(i))))
            overviewScene_->removeItem(items.at(i));
    }
    fps_ = fps;
    int secs = 0;
    for (int x = 0; x < duration_ + fps; x+=fps) {
        if (x % (2*fps) == 0) {
            overviewScene_->addLine(x, 15, x, 35);
            QGraphicsTextItem* textItem = overviewScene_->addText(QString::fromStdString(getTimeString(secs)));
            textItem->moveBy(x-14, -5);

        }
        else if (x % fps == 0) {
            overviewScene_->addLine(x, 20, x, 30);
        }
        secs+=1;
    }
    overviewView_->setCurrentFrame(0);
    overviewScene_->addRect(0, 25, duration_, 1);
    overviewView_->setSceneRect(-2,-2, duration_, 60);


    highlight_->setRect(scrollBarPosition_/zoom_, -15, (viewportWidth_ - 60) / zoom_ , 85);
    highlight_->show();

    highlightBar_->setRect(scrollBarPosition_/zoom_, -15, (viewportWidth_ - 60) / zoom_ , 15);
    highlightBar_->show();

    previews_.clear();
}
    void addBoxedItem(QGraphicsItem* item, QString title) {
        QGraphicsRectItem* box = createBox();
        item->setParentItem(box);

        QString htmlTitle = QString("<center>%1</center>").arg(title);
        QGraphicsTextItem *textItem = new QGraphicsTextItem();
        textItem->setDefaultTextColor(Qt::blue);
        QFont font;
        font.setPixelSize(10);
        textItem->setFont(font);

        textItem->setHtml(htmlTitle);

        textItem->setTextWidth(WIDTH);
        textItem->setParentItem(box);
        textItem->moveBy(0, 110);
        nextPosition();
    }
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()));
    }
}
Example #4
0
/**
 Main function
**/
int main(int argc, char **argv)
{

    showTime.start();
    
#ifdef Q_WS_QWS
    if(argc < 3) {qDebug() << USAGE_STRING; exit(-1);}
    QString configFileName = QString(argv[2]);
#else
    if(argc < 2) {qDebug() << USAGE_STRING; exit(-1);} 
    QString configFileName = QString(argv[1]);
#endif
    QFile file(configFileName);
    if (!file.open(QIODevice::ReadOnly)) {
        qDebug() << "  Xgxperf_launcher:: Couldn't open the config file (" << configFileName << ")";
        return -1;
    }
   
    QApplication app(argc, argv);
    int screenWidth = app.desktop()->screenGeometry().width();
    int screenHeight = app.desktop()->screenGeometry().height();    
    QLinearGradient backGradient(0,0,0,screenHeight);


    backGradient.setColorAt(0, QColor(35,143,192,255));
    backGradient.setColorAt(0.2, Qt::black );        
    backGradient.setColorAt(1, QColor(35,143,192,255));    

    QGraphicsScene scene(0, 0, 460, 620);

    QGraphicsItem *iconWidgetParent = new QGraphicsRectItem;

    //Add parent widget to scene
    scene.addItem(iconWidgetParent);
    iconWidgetParent->setScale(1.0);    
    iconWidgetParent->setPos(0,0);
    
    //Draw the text at top
    QGraphicsTextItem *pTextItem = new QGraphicsTextItem("XgxPerf Toolkit");
    QFont titleFont("Tahoma",36); 
    pTextItem->setFont(titleFont);
    pTextItem->setPos(50,10);
    pTextItem->setDefaultTextColor(Qt::white);
    scene.addItem(pTextItem);

    //Result/ notification at the bottom
    QFont textFont = QFont(QString("Tahoma"),14);        
    QGraphicsTextItem* pResultItem = new QGraphicsTextItem("Status Window: \n Click on an icon to start benchmarking...", 0);
    pResultItem->setFont(textFont);
    pResultItem->setDefaultTextColor(Qt::white);
    scene.addItem(pResultItem);
    pResultItem->moveBy(0, 500);

    QXmlStreamReader reader(&file);
    queryFromConfigStream(reader);
    screenFromQuery(iconWidgetParent, pResultItem);

    //Create final view    
    View *view = new View(&scene);
    view->setBackgroundBrush(backGradient);    
    view->setWindowTitle(QT_TRANSLATE_NOOP(QGraphicsView, "XgxPerf Benchmark Launcher"));
    //view->setViewportUpdateMode(QGraphicsView::BoundingRectViewportUpdate);
    //view->setCacheMode(QGraphicsView::CacheBackground);
    view->setViewportUpdateMode(QGraphicsView::FullViewportUpdate);
    view->setRenderHints(QPainter::Antialiasing | QPainter::SmoothPixmapTransform);
    
    
    qDebug() << "showtime before view->show()" << showTime.elapsed();    
    view->show();
    return app.exec();
}
Example #5
0
void PSV_AxisDownItem::updateItem()
{
//    m_markFont.setPointSizeF(m_rect.width() * m_rect.height() * 0.0005);
    updateLabels();
    QPen linePen(QBrush(m_lineColor), m_lineWidth);
    QPen barPen(QBrush(m_markColor), m_markWidth);
    {
        QGraphicsLineItem* lineItem = new QGraphicsLineItem(this);
        lineItem->setPen(linePen);
        lineItem->setLine(m_rect.right() + 2 * m_arrowsLength, m_rect.top()
                          , m_rect.left(), m_rect.top());
        lineItem->setZValue(1);

        QGraphicsLineItem* arrowsItem_up = new QGraphicsLineItem(this);
        arrowsItem_up->setPen(linePen);
        arrowsItem_up->setLine(m_rect.right() + 2 * m_arrowsLength, m_rect.y()
                                 , m_rect.right() + m_arrowsLength, m_rect.y()- 0.5 * m_arrowsLength);
        arrowsItem_up->setZValue(1);

        QGraphicsLineItem* arrowsItem_right = new QGraphicsLineItem(this);
        arrowsItem_right->setPen(linePen);
        arrowsItem_right->setLine(m_rect.right() + 2 * m_arrowsLength, m_rect.y()
                                  , m_rect.right() + m_arrowsLength, m_rect.y() + 0.5 * m_arrowsLength);
        arrowsItem_right->setZValue(1);
    }
    int count = m_labelList.count();
    if(count <= 1)
    {
        return;
    }
    double dx = 0.0;
    double dy = 0.0;
    if(m_isCenter && m_isList)
    {
        dx = 0.5 * m_rect.width() / count;
    }
    else
    {
        count--;
    }

    double oneSpace = m_rect.width() / count;
    m_markPointList.clear();
    bool isRotate = false;
    qreal maxHeight = 0.0;;
    qreal maxWidth = 0.0;;
    if(m_isCenter && m_isList)
    {
        count = m_labelList.count() + 1;
    }
    else
    {
        count = m_labelList.count();
    }

    for(int index = 0; index < m_labelList.count(); ++index)
    {
        QPair<QVariant, QString> labelPair = m_labelList.at(index);
        QGraphicsTextItem* textItem = new QGraphicsTextItem(labelPair.second, this);
        textItem->setDefaultTextColor(m_defaultColor);
        textItem->setFont(m_markFont);
        qreal height = textItem->boundingRect().height();
        qreal width = textItem->boundingRect().width();
        if(index == 0)
        {
            if(width > oneSpace && height < 2*oneSpace)//ФЭК±ґ¦Ан
            {
               isRotate = true;
               maxHeight = width;
               maxWidth = height;
            }
            else
            {
                maxHeight = height;
                maxWidth = width;
            }
        }
        qreal x = m_rect.left() + (index * (m_rect.width())) / (count - 1);
        qreal y = m_rect.top() + m_markLength;
        if(isRotate)
        {
#if QT_VERSION > QT_VERSION_CHECK(4, 6, 0)
            textItem->setRotation(90);
#else
            textItem->rotate(90);
#endif

            textItem->setPos(x + 0.5 * height, y);
            if(maxHeight < width)
            {
                maxHeight = width;
            }
            if(maxWidth < height)
            {
                maxWidth = height;
            }
        }
        else
        {
            textItem->setPos(x - 0.5 * width, y);
            if(maxHeight < height)
            {
                maxHeight = height;
            }
            if(maxWidth < width)
            {
                maxWidth = width;
            }
        }
        textItem->moveBy(dx,dy);
        QGraphicsLineItem *lineItem = new QGraphicsLineItem(this);
        lineItem->setPen(barPen);
        if(index != 0 && index != count -1)
        {
            lineItem->setLine(x - 0.5 * barPen.width(), m_rect.top(), x - 0.5 * barPen.width(), m_rect.top() + m_markLength);
        }
        else
        {
            lineItem->setLine(x, m_rect.top(), x, m_rect.top() + m_markLength);
        }
        m_markPointList.append(QPointF(x - 0.5 * barPen.width(), m_rect.top()));
    }
    //=================
    m_validRect =  QRectF(m_rect.x() - 0.5 * maxWidth
                          ,m_rect.y()
                          ,m_rect.width() + maxWidth
                          ,m_markLength + maxHeight);
//    QGraphicsRectItem *item = new QGraphicsRectItem(m_validRect,this);
}
Example #6
0
Window::Window(const QString &title, const QSizeF &size)
    :title(title), size(size), keep_when_disappear(false)
{
    setFlags(ItemIsMovable);

    QPixmap *bg;
    bg = size.width()>size.height() ?
                new QPixmap("image/system/tip.png")
              : new QPixmap("image/system/about.png");
    QImage bgimg = bg->toImage();
    outimg = new QImage(size.toSize(),QImage::Format_ARGB32);

    qreal pad = 10;

    int w = bgimg.width();
    int h = bgimg.height();

    int tw = outimg->width();
    int th  =outimg->height();

    qreal xc = (w - 2*pad)/(tw - 2*pad);
    qreal yc = (h - 2*pad)/(th - 2*pad);

    for(int i=0;i<tw;i++)
        for(int j=0;j<th;j++)
        {
            int x = i;
            int y = j;

            if( x>=pad && x<=(tw - pad) ) x = pad + (x - pad)*xc;
            else if(x>=(tw-pad))x = w - (tw - x);

            if( y>=pad && y<=(th - pad) ) y = pad + (y - pad)*yc;
            else if(y>=(th-pad))y = h - (th - y);


            QRgb rgb = bgimg.pixel(x,y);
            outimg->setPixel(i,j,rgb);
        }


    scaleTransform = new QGraphicsScale(this);
    scaleTransform->setXScale(1.05);
    scaleTransform->setYScale(0.95);
    scaleTransform->setOrigin(QVector3D(
                                  this->boundingRect().width()/2,
                                  this->boundingRect().height()/2,
                                  0
                                  ));

    QList<QGraphicsTransform *> transforms;
    transforms << scaleTransform;
    setTransformations(transforms);

    this->setOpacity(0.0);

    QGraphicsTextItem * titleItem = new QGraphicsTextItem(this);

    QString style;
    style.append("font-size:18pt; ");
    style.append("color:#77c379; ");
    style.append(QString("font-family: %1").arg(Config.SmallFont.family()));

    QString content;
    content.append(QString("<h style=\"%1\">%2</h>")
                   .arg(style).arg(title));

    titleItem->setHtml(content);
    titleItem->moveBy(size.width()/2 - titleItem->boundingRect().width()/2,10);
}
Example #7
0
void Widget::createHelp( void ) 
{
   QGraphicsTextItem *helpText = scene->addText("Choisir les cartes a changer");
   helpText->moveBy( 150, 50 );
}