void LinkDialogProcessorGraphicsItem::paint(QPainter* p, const QStyleOptionGraphicsItem* options,
                                            QWidget* widget) {
    IVW_UNUSED_PARAM(options);
    IVW_UNUSED_PARAM(widget);
    p->save();

    QPen blackPen(QColor(0, 0, 0), 1);

    p->setPen(blackPen);
    p->setRenderHint(QPainter::Antialiasing, true);
    p->setViewTransformEnabled(false);
    QColor topColor(140, 140, 140);
    QColor middleColor(59, 61, 61);
    QColor bottomColor(40, 40, 40);
    // paint processor
    QLinearGradient grad(rect().topLeft(), rect().bottomLeft());

    grad.setColorAt(0.0f, topColor);
    grad.setColorAt(0.2f, middleColor);
    grad.setColorAt(1.0f, bottomColor);

    p->setBrush(grad);
    p->drawRoundedRect(rect(), linkdialog::processorRoundedCorners,
                       linkdialog::processorRoundedCorners);
    p->restore();
}
// Paint the horizontal handle as a gradient, paint
// the vertical handle as a line.
void QMacSplitterHandle::paintEvent(QPaintEvent *e)
{
    Q_UNUSED(e);
    QPainter painter(this);
    painter.setRenderHint(QPainter::SmoothPixmapTransform);
    painter.setWorldMatrixEnabled(false);
    painter.setViewTransformEnabled(false);

    QColor topColor(145, 145, 145);
    QColor bottomColor(142, 142, 142);
    QColor gradientStart(252, 252, 252);
    QColor gradientStop(223, 223, 223);

    if (orientation() == Qt::Vertical) {
        painter.setPen(topColor);
        painter.drawLine(0, 0, width(), 0);
        painter.setPen(bottomColor);
        painter.drawLine(0, height() - 1, width(), height() - 1);

        QLinearGradient linearGrad(QPointF(0, 0), QPointF(0, height() -3));
        linearGrad.setColorAt(0, gradientStart);
        linearGrad.setColorAt(1, gradientStop);
        painter.fillRect(QRect(QPoint(0,1), size() - QSize(0, 2)), QBrush(linearGrad));
    } else {
        painter.setPen(topColor);
        painter.drawLine(0, 0, 0, height());
    }
}
void ProcessorPortGraphicsItem::paint(QPainter* p, const QStyleOptionGraphicsItem* options,
                                      QWidget* widget) {
    p->save();
    p->setBrush(Qt::NoBrush);
    p->setRenderHint(QPainter::Antialiasing, true);

    QColor bottomColor(40, 40, 40);
    p->setPen(QPen(bottomColor, lineWidth_));

    uvec3 color = port_->getColorCode();

    QRectF portRect(QPointF(-size_, size_) / 2, QPointF(size_, -size_) / 2);
    QLinearGradient portGrad(portRect.topLeft(), portRect.bottomLeft());
    portGrad.setColorAt(0.0f,
                        QColor(std::min(255u, color.r * 6 / 10), 
                        std::min(255u, color.g * 6 / 10),
                        std::min(255u, color.b * 6 / 10)));
    portGrad.setColorAt(0.3f, QColor(color.r, color.g, color.b));
    portGrad.setColorAt(1.0f, QColor(color.r, color.g, color.b));
    p->setBrush(portGrad);
    p->drawRect(portRect);

    if (port_->isConnected()) {
        if (up_) {
            p->drawRect(portRect.adjusted(3, -3, -3, -0));
        } else {
            p->drawRect(portRect.adjusted(3, 0, -3, 3));
        }
    }

    p->restore();
}
Beispiel #4
0
void dtkSplitterHandle::paintEvent(QPaintEvent *event)
{
    Q_UNUSED(event);

    QPainter painter(this);
    
    QColor topColor(145, 145, 145);
    QColor bottomColor(142, 142, 142);
    QColor gradientStart(252, 252, 252);
    QColor gradientStop(223, 223, 223);
    
    if (orientation() == Qt::Vertical) {
	painter.setPen(topColor);
	painter.drawLine(0, 0, width(), 0);

	if(m_slim)
	    return;
	
	painter.setPen(bottomColor);
	painter.drawLine(0, height()-1, width(), height()-1);
	
	QLinearGradient linearGrad(QPointF(0, 0), QPointF(0, height()-3));
	linearGrad.setColorAt(0, gradientStart);
	linearGrad.setColorAt(1, gradientStop);
	painter.fillRect(QRect(QPoint(0,1), size() - QSize(0, 2)), QBrush(linearGrad));

    } else {
	painter.setPen(topColor);
	painter.drawLine(0, 0, 0, height());
    }
}
void LinkDialogProcessorGraphicsItem::paint(QPainter* p, const QStyleOptionGraphicsItem* options,
                                            QWidget* widget) {
    IVW_UNUSED_PARAM(options);
    IVW_UNUSED_PARAM(widget);
    p->save();
    p->setPen(Qt::black);
    p->setRenderHint(QPainter::Antialiasing, true);
    QColor topColor(140, 140, 140);
    QColor middleColor(59, 61, 61);
    QColor bottomColor(40, 40, 40);
    // paint processor
    QLinearGradient grad(rect().topLeft(), rect().bottomLeft());

    if (isSelected()) {
        grad.setColorAt(0.0f, topColor);
        grad.setColorAt(0.2f, middleColor);
        grad.setColorAt(0.5f, Qt::darkRed);
        grad.setColorAt(1.0f, bottomColor);
    } else {
        grad.setColorAt(0.0f, topColor);
        grad.setColorAt(0.2f, middleColor);
        grad.setColorAt(1.0f, bottomColor);
    }

    p->setBrush(grad);
    QPainterPath roundRectPath;
    QRectF bRect = rect();
    roundRectPath.moveTo(bRect.left(), bRect.top() + processorRoundedCorners);
    roundRectPath.lineTo(bRect.left(), bRect.bottom() - processorRoundedCorners);
    roundRectPath.arcTo(bRect.left(), bRect.bottom() - (2 * processorRoundedCorners),
                        (2 * processorRoundedCorners), (2 * processorRoundedCorners), 180.0, 90.0);
    roundRectPath.lineTo(bRect.right() - processorRoundedCorners, bRect.bottom());
    roundRectPath.arcTo(bRect.right() - (2 * processorRoundedCorners),
                        bRect.bottom() - (2 * processorRoundedCorners),
                        (2 * processorRoundedCorners), (2 * processorRoundedCorners), 270.0, 90.0);
    roundRectPath.lineTo(bRect.right(), bRect.top() + processorRoundedCorners);
    roundRectPath.arcTo(bRect.right() - (2 * processorRoundedCorners), bRect.top(),
                        (2 * processorRoundedCorners), (2 * processorRoundedCorners), 0.0, 90.0);
    roundRectPath.lineTo(bRect.left() + processorRoundedCorners, bRect.top());
    roundRectPath.arcTo(bRect.left(), bRect.top(), (2 * processorRoundedCorners),
                        (2 * processorRoundedCorners), 90.0, 90.0);
    p->drawPath(roundRectPath);
    p->restore();
}
void ProcessorGraphicsItem::paint(QPainter* p, const QStyleOptionGraphicsItem* options,
                                  QWidget* widget) {
    IVW_UNUSED_PARAM(options);
    IVW_UNUSED_PARAM(widget);
    p->save();
    p->setPen(Qt::NoPen);
    p->setRenderHint(QPainter::Antialiasing, true);
    QColor topColor(140, 140, 140);
    QColor middleColor(59, 61, 61);
    QColor bottomColor(40, 40, 40);
    // paint processor
    QLinearGradient grad(rect().topLeft(), rect().bottomLeft());

    if (isSelected()) {
        grad.setColorAt(0.0f, topColor);
        grad.setColorAt(0.2f, middleColor);
        grad.setColorAt(0.5f, Qt::darkRed);
        grad.setColorAt(1.0f, bottomColor);
    } else {
        grad.setColorAt(0.0f, topColor);
        grad.setColorAt(0.2f, middleColor);
        grad.setColorAt(1.0f, bottomColor);
    }

    QRectF bRect = rect();
    QPainterPath roundRectPath = makeRoundedBox(rect(), roundedCorners);

    p->setBrush(grad);
    p->drawPath(roundRectPath);
    QLinearGradient highlightGrad(rect().topLeft(), rect().bottomLeft());

    if (isSelected()) {
        highlightGrad.setColorAt(0.0f, bottomColor);
        highlightGrad.setColorAt(0.1f, bottomColor);
        highlightGrad.setColorAt(0.5f, Qt::darkRed);
        highlightGrad.setColorAt(1.0f, bottomColor);
    } else {
        highlightGrad.setColorAt(0.0f, bottomColor);
        highlightGrad.setColorAt(1.0f, bottomColor);
    }

    QPainterPath highlightPath;
    float highlightLength = bRect.width() / 8.0;
    highlightPath.moveTo(bRect.left(), bRect.top() + roundedCorners);
    highlightPath.lineTo(bRect.left(), bRect.bottom() - roundedCorners);
    highlightPath.arcTo(bRect.left(), bRect.bottom() - (2 * roundedCorners), (2 * roundedCorners),
                        (2 * roundedCorners), 180.0, 90.0);
    highlightPath.lineTo(bRect.left() + (bRect.width() / 2.0) + highlightLength, bRect.bottom());
    highlightPath.lineTo(bRect.left() + (bRect.width() / 2.0) - highlightLength, bRect.top());
    highlightPath.lineTo(bRect.left() + roundedCorners, bRect.top());
    highlightPath.arcTo(bRect.left(), bRect.top(), (2 * roundedCorners), (2 * roundedCorners), 90.0,
                        90.0);

    p->setBrush(highlightGrad);
    p->drawPath(highlightPath);
    p->setPen(QPen(QColor(164, 164, 164), 1.0));
    p->setBrush(Qt::NoBrush);
    p->drawPath(roundRectPath);

    p->restore();
}
const QImage& ImageTransformer::
RobertsTransform(const int thresholdValue)
{
    QImage NewImage(_DataHandled.size(),_DataHandled.format());

    int width = NewImage.width();
    int height = NewImage.height();
    int depth = NewImage.depth();
    if(depth==32)
    {
        for(int i=0;i<width-1;++i)
        {
            for (int j=0;j<height-1;++j)
            {
                QColor nowColor(_DataHandled.pixel(i,j));
                QColor rightColor(_DataHandled.pixel(i+1,j));
                QColor bottomColor(_DataHandled.pixel(i,j+1));
                int red = std::max(std::abs(nowColor.red()-rightColor.red()),
                        std::abs(nowColor.red()-bottomColor.red()));
                int green = std::max(std::abs(nowColor.green()-rightColor.green()),
                        std::abs(nowColor.green()-bottomColor.green()));
                int blue = std::max(std::abs(nowColor.blue()-rightColor.blue()),
                        std::abs(nowColor.blue()-bottomColor.blue()));
                if(red+blue+green>thresholdValue*3)
                {
                    NewImage.setPixel(i,j,QColor(red,green,blue).rgb());
                    //NewImage.setPixel(i,j,QColor(Qt::white).rgb());
                }
            }
        }

        /*最下面一排*/
        for(int i=0;i<width - 1;++i)
        {
            QColor nowColor(_DataHandled.pixel(i,height-1));
            QColor rightColor(_DataHandled.pixel(i+1,height-1));
            int red = std::abs(nowColor.red() - rightColor.red());
            int green = std::abs(nowColor.green() - rightColor.green());
            int blue = std::abs(nowColor.blue() - rightColor.blue());
            if(red+blue+green>thresholdValue*3)
            {
                NewImage.setPixel(i,height-1,QColor(red,green,blue).rgb());
                //NewImage.setPixel(i,j,QColor(Qt::white).rgb());
            }
        }

        /*最右边一排*/
        for(int j=0;j<height-1;++j)
        {
            QColor nowColor(_DataHandled.pixel(width-1,j));
            QColor bottomColor(_DataHandled.pixel(width-1,j+1));
            int red = std::abs(nowColor.red()-bottomColor.red());
            int green = std::abs(nowColor.green()-bottomColor.green());
            int blue = std::abs(nowColor.blue()-bottomColor.blue());
            if(red+blue+green>thresholdValue*3)
            {
                NewImage.setPixel(width-1,j,QColor(red,green,blue).rgb());
                //NewImage.setPixel(i,j,QColor(Qt::white).rgb());
            }
        }
        _DataHandled = NewImage;
    }
    return _DataHandled;
}