コード例 #1
0
/*!
   \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();
}
コード例 #2
0
 void visit(QList<QGraphicsItem *> *items)
 {
     for (int i = 0; i < items->size(); ++i) {
         QGraphicsItem *item = items->at(i);
         if (!item->d_func()->itemDiscovered && item->isVisible()) {
             item->d_func()->itemDiscovered = 1;
             foundItems->prepend(item);
         }
     }
 }
コード例 #3
0
void UBDesktopAnnotationController::updateMask(bool bTransparent)
{
    if(bTransparent)
    {
        // Here we have to generate a new mask This method is certainly resource
        // consuming but for the moment this is the only solution that I found.
        mMask = QPixmap(mTransparentDrawingView->width(), mTransparentDrawingView->height());

        QPainter p;

        p.begin(&mMask);

        p.setPen(Qt::red);
        p.setBrush(QBrush(Qt::red));

        // Here we draw the widget mask
        if(mDesktopPalette->isVisible())
        {
            p.drawRect(mDesktopPalette->geometry().x(), mDesktopPalette->geometry().y(), mDesktopPalette->width(), mDesktopPalette->height());
        }
        if(UBApplication::boardController->paletteManager()->mKeyboardPalette->isVisible())
        {
            p.drawRect(UBApplication::boardController->paletteManager()->mKeyboardPalette->geometry().x(), UBApplication::boardController->paletteManager()->mKeyboardPalette->geometry().y(), 
                UBApplication::boardController->paletteManager()->mKeyboardPalette->width(), UBApplication::boardController->paletteManager()->mKeyboardPalette->height());
        }

        if(UBApplication::boardController->paletteManager()->leftPalette()->isVisible())
        {
            QRect leftPalette(UBApplication::boardController->paletteManager()->leftPalette()->geometry().x(),
                        UBApplication::boardController->paletteManager()->leftPalette()->geometry().y(),
                        UBApplication::boardController->paletteManager()->leftPalette()->width(),
                        UBApplication::boardController->paletteManager()->leftPalette()->height());

            QRect tabsPalette(UBApplication::boardController->paletteManager()->leftPalette()->getTabPaletteRect());

            p.drawRect(leftPalette);
            p.drawRect(tabsPalette);
        }

        if(UBApplication::boardController->paletteManager()->rightPalette()->isVisible())
        {
            QRect rightPalette(UBApplication::boardController->paletteManager()->rightPalette()->geometry().x(),
                        UBApplication::boardController->paletteManager()->rightPalette()->geometry().y(),
                        UBApplication::boardController->paletteManager()->rightPalette()->width(),
                        UBApplication::boardController->paletteManager()->rightPalette()->height());

            QRect tabsPalette(UBApplication::boardController->paletteManager()->rightPalette()->getTabPaletteRect());

            p.drawRect(rightPalette);
            p.drawRect(tabsPalette);
        }

        p.end();

        // Then we add the annotations. We create another painter because we need to
        // apply transformations on it for coordinates matching
        QPainter annotationPainter;

        QTransform trans;
        trans.translate(mTransparentDrawingView->width()/2, mTransparentDrawingView->height()/2);

        annotationPainter.begin(&mMask);
        annotationPainter.setPen(Qt::red);
        annotationPainter.setBrush(Qt::red);

        annotationPainter.setTransform(trans);

        QList<QGraphicsItem*> allItems = mTransparentDrawingScene->items();

        for(int i = 0; i < allItems.size(); i++)
        {
            QGraphicsItem* pCrntItem = allItems.at(i);

            if(pCrntItem->isVisible())
            {
                QPainterPath crntPath = pCrntItem->shape();
                QRectF rect = crntPath.boundingRect();

                annotationPainter.drawRect(rect);
            }
        }

        annotationPainter.end();

        mTransparentDrawingView->setMask(mMask.createMaskFromColor(Qt::black));
    }
    else
    {
        // Remove the mask
        QPixmap noMask(mTransparentDrawingView->width(), mTransparentDrawingView->height());
        mTransparentDrawingView->setMask(noMask.mask());
    }
}