Example #1
0
QwtBeginner::QwtBeginner(QWidget *parent)
    : QWidget(parent)
{
    funPlot = new QwtPlot;

    funPlot->setTitle("Function");
    QPen myPen = QPen(Qt::blue);
    myPen.setWidth(2);
    myPen.setCapStyle(Qt::RoundCap);
    QPen dotPen = QPen(Qt::red);
    dotPen.setWidth(5);
    dotPen.setCapStyle(Qt::RoundCap);

    myCurve = new QwtPlotCurve;
    myCurve->setPen(myPen);
    myCurve->attach(funPlot);

    dot = new QwtPlotCurve;
    dot->setPen(dotPen);
    dot->attach(funPlot);
    dot->setStyle(QwtPlotCurve::Dots);

    QHBoxLayout *plotsLayout = new QHBoxLayout;
    plotsLayout->setSpacing(10);
    plotsLayout->addWidget(funPlot);

    QVBoxLayout *widgetLayout = new QVBoxLayout;
    widgetLayout->addLayout(plotsLayout);

    setLayout(widgetLayout);
}
Example #2
0
void SVGPaintServer::setPenProperties(const RenderObject* object, const RenderStyle* style, QPen& pen) const
{
    pen.setWidthF(SVGRenderStyle::cssPrimitiveToLength(object, style->svgStyle()->strokeWidth(), 1.0));

    if (style->svgStyle()->capStyle() == ButtCap)
        pen.setCapStyle(Qt::FlatCap);
    else if (style->svgStyle()->capStyle() == RoundCap)
        pen.setCapStyle(Qt::RoundCap);

    if (style->svgStyle()->joinStyle() == MiterJoin) {
        pen.setJoinStyle(Qt::MiterJoin);
        pen.setMiterLimit((qreal) style->svgStyle()->strokeMiterLimit());
    } else if(style->svgStyle()->joinStyle() == RoundJoin)
        pen.setJoinStyle(Qt::RoundJoin);

    const DashArray& dashes = WebCore::dashArrayFromRenderingStyle(style);
    double dashOffset = SVGRenderStyle::cssPrimitiveToLength(object, style->svgStyle()->strokeDashOffset(), 0.0);

    unsigned int dashLength = !dashes.isEmpty() ? dashes.size() : 0;
    if(dashLength) {
        QVector<qreal> pattern;
        unsigned int count = (dashLength % 2) == 0 ? dashLength : dashLength * 2;

        for(unsigned int i = 0; i < count; i++)
            pattern.append(dashes[i % dashLength] / (float)pen.widthF());

        pen.setDashPattern(pattern);

        Q_UNUSED(dashOffset);
        // TODO: dash-offset, does/will qt4 API allow it? (Rob)
    }
}
Example #3
0
////////////////////////////////////////////////////////////////////////////////
/// CPuzzleNodeArtist::drawArrow
///
/// @description              This function draws an arrow indicating a start
///                           node.
/// @pre                      None
/// @post                     An arrow is drawn on the screen indicating the
///                           start node.
///
/// @param painter:           This is a pointer to the QPainter object which
///                           draws the arrow to the screen.
/// @param boundingRect:      This is the bounding rectangle of the node which
///                           is the start node.
/// @param angleNorthOfEast:  This is the angle in degrees from the East
///                           direction going North to draw the arrow at.
///
/// @limitations              None
///
////////////////////////////////////////////////////////////////////////////////
void CPuzzleNodeArtist::drawArrow( QPainter *painter, QRect &boundingRect,
                                   qreal angleNorthOfEast )
{
    QMatrix backupMatrix = painter->matrix();
    QPen backupPen = painter->pen();

    QPen editPen = m_style->getPen();
    int w = painter->pen().width();
    int d = m_style->getNodeRadius() * 2;

    painter->translate( boundingRect.center() );
    painter->rotate( -angleNorthOfEast );
    painter->translate( (d/2)+(w*2), 0 );

    editPen.setCapStyle( Qt::FlatCap );
    painter->setPen( editPen );
    painter->drawLine( 5,  4, (int)(d*.60),  4 );
    painter->drawLine( 5, -4, (int)(d*.60), -4 );

    editPen.setCapStyle( Qt::SquareCap );
    painter->setPen( editPen );
    painter->drawLine( 0, 0, (int)(d*.25),  (int)(d*.25) );
    painter->drawLine( 0, 0, (int)(d*.25), -(int)(d*.25) );

    painter->setPen( backupPen );
    painter->setMatrix( backupMatrix );
}
Example #4
0
// Parse a <g> tag while opening a file
void svgParseGroup(const QDomElement &element, NoteEditor *editor, QPen pen)
{
    if (element.tagName() != "g") return;

    // Convert the <g> tag into a QPen
    if (element.hasAttribute("stroke-width"))
        pen.setWidthF(element.attribute("stroke-width").toDouble());
    if (element.hasAttribute("stroke")) {
        // Colors by hex value with '#' prefix
        if (element.attribute("stroke").at(0) == '#') {
            pen.setColor(QColor(element.attribute("stroke")
                                .right(6).toInt(0, 16)));
        }
        // TODO: handle colors by name
    }

    if (element.hasAttribute("stroke-linecap")) {
        QString linecap = element.attribute("stroke-linecap");
        if (linecap == "square") {
            pen.setCapStyle(Qt::SquareCap);
        } else if (linecap == "round") {
            pen.setCapStyle(Qt::RoundCap);
        } else if (linecap == "butt") {
            pen.setCapStyle(Qt::FlatCap);
        }
    }

    QDomElement child = element.firstChildElement();
    while (!child.isNull()) {
        if (child.tagName() == "g") {
            svgParseGroup(child, editor, pen);
        } else if (child.tagName() == "polyline") {
            // Get curve from points, add to editor
            Curve *curve = new Curve(pen);
            QStringList pointStrs = child.attribute("points")
                    .split(' ', QString::SkipEmptyParts);
            QStringList::iterator itr;
            for (itr = pointStrs.begin(); itr != pointStrs.end(); ++itr) {
                QStringList curPointStr =
                        itr->split(',', QString::SkipEmptyParts);
                QPointF point(curPointStr[0].toDouble(),
                              curPointStr[1].toDouble());
                editor->addPointToCurve(point, curve);
            }
            editor->addCurve(curve);
        }
        child = child.nextSiblingElement();
    }
}
Example #5
0
// ********************************************************
ImageBufferData::ImageBufferData(const IntSize& size, bool accelerated)
{
    QPainter* painter = new QPainter;
    m_painter = adoptPtr(painter);

#if ENABLE(ACCELERATED_2D_CANVAS)
    if (accelerated) {
        m_impl = adoptPtr(new ImageBufferDataPrivateAccelerated(size));
    } else
#endif
        m_impl = adoptPtr(new ImageBufferDataPrivateUnaccelerated(size));

    if (!m_impl->paintDevice())
        return;
    if (!painter->begin(m_impl->paintDevice()))
        return;

    painter->setRenderHints(QPainter::Antialiasing | QPainter::HighQualityAntialiasing);
    QPen pen = painter->pen();
    pen.setColor(Qt::black);
    pen.setWidth(1);
    pen.setCapStyle(Qt::FlatCap);
    pen.setJoinStyle(Qt::SvgMiterJoin);
    pen.setMiterLimit(10);
    painter->setPen(pen);
    QBrush brush = painter->brush();
    brush.setColor(Qt::black);
    painter->setBrush(brush);
    painter->setCompositionMode(QPainter::CompositionMode_SourceOver);
}
Example #6
0
void GLEDrawingObject::setPenProperties(QPen& pen) {
	setSimplePenProperties(pen);
	GLEDrawObject* obj = getGLEObject();
	int cap = obj->getIntProperty(GLEDOPropertyLineCap);
	switch (cap) {
		case GLELineCapButt:
			pen.setCapStyle(Qt::FlatCap);
			break;
		case GLELineCapRound:
			pen.setCapStyle(Qt::RoundCap);
			break;
		case GLELineCapSquare:
			pen.setCapStyle(Qt::SquareCap);
			break;
	}
}
Example #7
0
void DoubleSlider::paintEvent(QPaintEvent *)
{
  QPainter painter(this);
  QStyleOptionSlider option;
  option.initFrom(this);
  option.maximum = maximum();
  option.minimum = minimum();
  option.sliderPosition = v1;
  style()->drawComplexControl(QStyle::CC_Slider, &option, &painter, this);
  QRect handle1 = style()->subControlRect(QStyle::CC_Slider, &option, QStyle::SC_SliderHandle, this);

  option.sliderPosition = v2;
  option.subControls = QStyle::SC_SliderHandle;
  style()->drawComplexControl(QStyle::CC_Slider, &option, &painter, this);
  QRect handle2 = style()->subControlRect(QStyle::CC_Slider, &option, QStyle::SC_SliderHandle, this);
  QPen p;
  p.setColor(QColor(0, 0, 200, 150));
  p.setWidth(handle1.height()-6);
  p.setCapStyle(Qt::FlatCap);
  painter.setPen(p);
  QRect groove = style()->subControlRect(QStyle::CC_Slider, &option, QStyle::SC_SliderGroove, this);
  int wi = handle1.width();
  painter.drawLine(handle1.x()+wi, handle1.height()/2,  handle2.x(), handle1.height()/2);

   painter.end();
}
Example #8
0
void QmitkScalarBarOverlay::GetProperties( mitk::PropertyList::Pointer pl )
{
  if ( pl.IsNull() )
    return;

  QPen pen = QPen();


  mitk::PropertyList::Pointer propertyList = pl;
  QPalette palette = QPalette();

  // get the desired color of the textOverlays
  mitk::ColorProperty::Pointer colorProp =
    dynamic_cast<mitk::ColorProperty*>( propertyList->GetProperty( "overlay.color" ) );

  if ( colorProp.IsNull() )
  {
    MITK_DEBUG << "creating new colorProperty";
    colorProp = mitk::ColorProperty::New( 127.0, 196.0, 232.0 );
  }

  mitk::Color color = colorProp->GetColor();
  pen.setColor( QColor( color[0],color[1],color[2],255 ) );
  pen.setStyle( Qt::SolidLine );
  pen.setCapStyle( Qt::FlatCap );
  pen.setJoinStyle( Qt::MiterJoin );

  m_ScalarBar->SetPen( pen );
}
void Context2D::setupPainter()
{
    m_painter.setRenderHint(QPainter::Antialiasing, true);
    if ((m_state.flags & DirtyClippingRegion) && !m_state.clipPath.isEmpty())
        m_painter.setClipPath(m_state.clipPath);
    if (m_state.flags & DirtyFillStyle)
        m_painter.setBrush(m_state.fillStyle);
    if (m_state.flags & DirtyGlobalAlpha)
        m_painter.setOpacity(m_state.globalAlpha);
    if (m_state.flags & DirtyGlobalCompositeOperation)
        m_painter.setCompositionMode(m_state.globalCompositeOperation);
    if (m_state.flags & MDirtyPen) {
        QPen pen = m_painter.pen();
        if (m_state.flags & DirtyStrokeStyle)
            pen.setBrush(m_state.strokeStyle);
        if (m_state.flags & DirtyLineWidth)
            pen.setWidthF(m_state.lineWidth);
        if (m_state.flags & DirtyLineCap)
            pen.setCapStyle(m_state.lineCap);
        if (m_state.flags & DirtyLineJoin)
            pen.setJoinStyle(m_state.lineJoin);
        if (m_state.flags & DirtyMiterLimit)
            pen.setMiterLimit(m_state.miterLimit);
        m_painter.setPen(pen);
    }
}
Example #10
0
 void
 eyes::ShowPointer ()
 {
    QPoint mid (this->width()/2, this->height()/2);
    double midx = double(mid.x());
    double midy = double(mid.y());
    QPoint cursPoint (QCursor::pos());
    QPoint midGlobal = this->mapToGlobal(mid);
    double dx = double(cursPoint.x()) - double (midGlobal.x());
    double dy = double(cursPoint.y()) - double (midGlobal.y());
    double dist = sqrt(dx*dx + dy*dy);
    double theta = -atan2(dx,dy) * 180.0/M_PI;
    double len = (midx > midy ? midy : midx);
    if (len > dist) { len = dist; }
    int    shortlen = int(len /10.0);
    
    QPainter paint(this);
    paint.setRenderHint(QPainter::HighQualityAntialiasing);
    paint.setBrush(Qt::NoBrush);
    QPen linePen;
    linePen.setColor(QColor(0,0,255,255));
    linePen.setWidth(len*0.05);
    linePen.setCapStyle(Qt::RoundCap);
    paint.setPen(linePen);
    paint.translate(mid);
    paint.rotate(theta);
    paint.save();
    paint.drawLine(0,0,0,int(len));
    paint.restore();
    paint.translate(0,int(len));
    paint.drawLine(0,0,-shortlen,-shortlen);
    paint.drawLine(0,0,shortlen, -shortlen);
 }
Example #11
0
void KivioStencilFormatDlg::initLineEndStyles()
{
  QBitmap mask;
  QPixmap pix(m_lineEndStyleCBox->width(), 17);
  QPainter p(&pix, m_lineEndStyleCBox);
  QPen pen;
  pen.setColor(QColor(0, 0, 0));
  pen.setWidth(4);
  pen.setStyle(SolidLine);
  pen.setJoinStyle(RoundJoin);
  p.setBrush(white);

  for (int i = 0; i < 3; i++) {
    pix.fill(white);
    pen.setCapStyle(static_cast<PenCapStyle>(i * 0x10));
    p.setPen(pen);
    p.drawLine(6, 8, pix.width() - 12, 8);

    mask = pix;
    pix.setMask(mask);
    m_lineEndStyleCBox->insertItem(pix, i);
  }

  p.end();
}
Example #12
0
bool AbstractGeoPolygonGraphicsItem::configurePainter(GeoPainter *painter, const ViewportParams &viewport) const
{
    QPen currentPen = painter->pen();
    GeoDataStyle::ConstPtr style = this->style();
    if (!style) {
        painter->setPen( QPen() ); // "style-less" polygons: a 1px black solid line
    }
    else {
        const GeoDataPolyStyle& polyStyle = style->polyStyle();

        if (polyStyle.outline()) {
            const GeoDataLineStyle& lineStyle = style->lineStyle();

            // To save performance we avoid making changes to the painter's pen.
            // So we first take a copy of the actual painter pen, make changes to it
            // and only if the resulting pen is different from the actual pen
            // we replace the painter's pen with our new pen.

            // We want to avoid the mandatory detach in QPen::setColor(),
            // so we carefully check whether applying the setter is needed
            currentPen.setColor(lineStyle.paintedColor());
            currentPen.setWidthF(lineStyle.width());
            currentPen.setCapStyle(lineStyle.capStyle());
            currentPen.setStyle(lineStyle.penStyle());

            if (painter->pen().color() != currentPen.color()) {
                painter->setPen(currentPen);
            }
        }
        else {
            // polygons without outline: Qt::NoPen (not drawn)
            if (currentPen.style() != Qt::NoPen) {
                painter->setPen(Qt::NoPen);
            }
        }

        if (!polyStyle.fill()) {            
            painter->setBrush(Qt::transparent);
        }
        else {
            const QColor paintedColor = polyStyle.paintedColor();
            if (painter->brush().color() != paintedColor ||
                painter->brush().style() != polyStyle.brushStyle()) {
                if (!polyStyle.texturePath().isEmpty() || !polyStyle.textureImage().isNull()) {
                    GeoDataCoordinates coords = latLonAltBox().center();
                    qreal x, y;
                    viewport.screenCoordinates(coords, x, y);
                    QBrush brush(texture(polyStyle.texturePath(), paintedColor));
                    painter->setBrush(brush);
                    painter->setBrushOrigin(QPoint(x,y));
                }
                else {
                    painter->setBrush(QBrush(paintedColor, polyStyle.brushStyle()));
                }
            }
        }
    }

    return true;
}
Example #13
0
void OGraphicsEllipseItem::mouseReleaseEvent(QGraphicsSceneMouseEvent *event)
{
	DBG_p("OGraphicsEllipseItem::mouseReleaseEvent\n");
	OGraphicsScene *s = dynamic_cast<OGraphicsScene *>(scene());
	OASSET(s != NULL);
	QList<QGraphicsItem *> il = s->selectedItems();
//	extractItemsByType(&il, ClassInfo::OConfNode);
	extractItemsByTypes(&il, ClassInfo::OConfNode, ClassInfo::OLogpoolNode);
	DBG_p("il.size()=%d\n", il.size());
	if (il.size() == 2) {
		OAbstractNode *no1 = dynamic_cast<OAbstractNode*>(il[0]);
		OAbstractNode *no2 = dynamic_cast<OAbstractNode*>(il[1]);
		if (no1 == NULL || no2 == NULL) return;
		OGraphicsEllipseItem *el1 = no1->getSelectedPoint();
		OGraphicsEllipseItem *el2 = no2->getSelectedPoint();
		if (OAbstractNode::connect(no1, el1, no2, el2)) {
			QPointF e_size = QPointF(ELLIPSE_SIZE / 2, ELLIPSE_SIZE / 2);
			QLineF lf(el1->getAbsolutePos() + e_size, el2->getAbsolutePos() + e_size);
			QGraphicsLineItem *gli = new QGraphicsLineItem(lf);
//			gli->setFlag(QGraphicsItem::ItemIsSelectable);
			el1->setLine(gli);
			el2->setLine(gli);
			QPen p;
			p.setColor(ELLIPSE_DEFAULT_COLOR);
			p.setCapStyle(Qt::RoundCap);
			p.setWidth(5);
			gli->setPen(p);
			s->addItem(gli);
		}
		el1->unselect();
		el2->unselect();
		s->clearSelection();
	}
}
Example #14
0
QImage* createNumber(int i,int r,int g,int b,int a)
{
    QImage* img = new QImage(32,32,QImage::Format_ARGB32);
    QPainter *p = new QPainter();
    QBrush br;
    p->begin(img);
    QColor black(0,0,0,0);
    for (int i=0;i<img->width();i++)
        for (int j=0;j<img->height();j++)
        {
            img->setPixel(i,j,black.rgba());
        }
    QColor txtcolor(r,g,b,a);
    QPen pen;
    pen.setStyle(Qt::SolidLine);
    pen.setWidth(3);
    pen.setBrush(txtcolor);
    pen.setCapStyle(Qt::RoundCap);
    pen.setJoinStyle(Qt::RoundJoin);
    p->setPen(pen);
    QFont f;
    f.setBold(true);
    f.setPointSize(26);
    p->setFont(f);
    p->drawText(img->width()/2-15,img->height()/2-15,30,30,Qt::AlignCenter,QString("%1").arg(i));
    p->end();
    delete p;
    return img;
}
Example #15
0
void UBSpinningWheel::paintEvent(QPaintEvent *event)
{
    Q_UNUSED(event);

    qreal side = qMin(width() / 2, height() / 2);

    QPainter painter(this);
    painter.setRenderHint(QPainter::Antialiasing);
    painter.translate(width() / 2, height() / 2);

    QPen pen;
    pen.setWidthF(side / 6.5);
    pen.setCapStyle(Qt::RoundCap);

    painter.setPen(pen);
    painter.rotate(30 * (mPosition % 12));

    for(int i = 0; i < 12; i++)
    {
        painter.drawLine(QPointF(side / 2, 0), QPointF(0.9 * side, 0));
        painter.rotate(30);
        QColor color = pen.color();
        color.setAlphaF(0.25 + (i / 16.));
        pen.setColor(color);
        painter.setPen(pen);
    }
}
Example #16
0
void CurveLine::drawPort(QPainter *painter, int portNumber)
{
	if ((portNumber == 0) || (portNumber == mEdge->line().count() - 1)) {
		LineHandler::drawPort(painter, portNumber);
		return;
	}

	QPen pen;
	pen.setCapStyle(Qt::RoundCap);
	QColor color;
	QPointF p1(-0.25, 0);
	QPointF p2(0.25, 0);

	color.setNamedColor("#ffcc66");
	pen.setWidth(12);
	pen.setColor(color);
	painter->setPen(pen);
	painter->drawLine(p1, p2);

	color.setNamedColor("#ff6666");
	pen.setWidth(3);
	pen.setColor(color);
	painter->setPen(pen);
	painter->drawLine(p1, p2);
}
Example #17
0
ImageBufferData::ImageBufferData(const IntSize& size)
    : m_pixmap(size)
{
    if (m_pixmap.isNull())
        return;

    m_pixmap.fill(QColor(Qt::transparent));

    QPainter* painter = new QPainter;
    m_painter = adoptPtr(painter);

    if (!painter->begin(&m_pixmap))
        return;

    // Since ImageBuffer is used mainly for Canvas, explicitly initialize
    // its painter's pen and brush with the corresponding canvas defaults
    // NOTE: keep in sync with CanvasRenderingContext2D::State
    QPen pen = painter->pen();
    pen.setColor(Qt::black);
    pen.setWidth(1);
    pen.setCapStyle(Qt::FlatCap);
    pen.setJoinStyle(Qt::SvgMiterJoin);
    pen.setMiterLimit(10);
    painter->setPen(pen);
    QBrush brush = painter->brush();
    brush.setColor(Qt::black);
    painter->setBrush(brush);
    painter->setCompositionMode(QPainter::CompositionMode_SourceOver);
    
    m_image = StillImage::createForRendering(&m_pixmap);
}
Example #18
0
void QPaintEngineEx::drawPoints(const QPoint *points, int pointCount)
{
    QPen pen = state()->pen;
    if (pen.capStyle() == Qt::FlatCap)
        pen.setCapStyle(Qt::SquareCap);

    if (pen.brush().isOpaque()) {
        while (pointCount > 0) {
            int count = qMin(pointCount, 16);
            qreal pts[64];
            int oset = -1;
            for (int i=0; i<count; ++i) {
                pts[++oset] = points[i].x();
                pts[++oset] = points[i].y();
                pts[++oset] = points[i].x() + 1/63.;
                pts[++oset] = points[i].y();
            }
            QVectorPath path(pts, count * 2, qpaintengineex_line_types_16, QVectorPath::LinesHint);
            stroke(path, pen);
            pointCount -= 16;
            points += 16;
        }
    } else {
        for (int i=0; i<pointCount; ++i) {
            qreal pts[] = { qreal(points[i].x()), qreal(points[i].y()),
                            qreal(points[i].x() +1/63.), qreal(points[i].y()) };
            QVectorPath path(pts, 2, 0);
            stroke(path, pen);
        }
    }
}
Example #19
0
void DrawStaticLoading(
		QPainter &p,
		QRectF rect,
		int stroke,
		QPen pen,
		QBrush brush) {
	PainterHighQualityEnabler hq(p);

	p.setBrush(brush);
	pen.setWidthF(stroke);
	pen.setCapStyle(Qt::RoundCap);
	pen.setJoinStyle(Qt::RoundJoin);
	p.setPen(pen);
	p.drawEllipse(rect);

	const auto center = rect.center();
	const auto first = QPointF(center.x(), rect.y() + 1.5 * stroke);
	const auto delta = center.y() - first.y();
	const auto second = QPointF(center.x() + delta * 2 / 3., center.y());
	if (delta > 0) {
		QPainterPath path;
		path.moveTo(first);
		path.lineTo(center);
		path.lineTo(second);
		p.drawPath(path);
	}
}
void QgsMeshVectorRenderer::draw()
{
  // Set up the render configuration options
  QPainter *painter = mContext.painter();
  painter->save();
  if ( mContext.flags() & QgsRenderContext::Antialiasing )
    painter->setRenderHint( QPainter::Antialiasing, true );

  painter->setRenderHint( QPainter::Antialiasing );
  QPen pen = painter->pen();
  pen.setCapStyle( Qt::FlatCap );
  pen.setJoinStyle( Qt::MiterJoin );

  double penWidth = mContext.convertToPainterUnits( mCfg.lineWidth(),
                    QgsUnitTypes::RenderUnit::RenderMillimeters );
  pen.setWidthF( penWidth );
  pen.setColor( mCfg.color() );
  painter->setPen( pen );

  if ( mDataOnVertices )
    drawVectorDataOnVertices();
  else
    drawVectorDataOnFaces();

  painter->restore();
}
void PlaylistItemDelegate::createPlayIcon() {
    qreal maxRatio = 2.0;
    playIcon = QPixmap(thumbWidth * maxRatio, thumbHeight * maxRatio);
    playIcon.setDevicePixelRatio(maxRatio);
    playIcon.fill(Qt::transparent);

    QPixmap tempPixmap(thumbWidth * maxRatio, thumbHeight * maxRatio);
    tempPixmap.setDevicePixelRatio(maxRatio);
    tempPixmap.fill(Qt::transparent);
    QPainter painter(&tempPixmap);
    painter.setRenderHints(QPainter::Antialiasing, true);

    const int hPadding = padding * 6;
    const int vPadding = padding * 2;

    QPolygon polygon;
    polygon << QPoint(hPadding, vPadding) << QPoint(thumbWidth - hPadding, thumbHeight / 2)
            << QPoint(hPadding, thumbHeight - vPadding);
    painter.setBrush(Qt::white);
    QPen pen;
    pen.setColor(Qt::white);
    pen.setWidth(padding);
    pen.setJoinStyle(Qt::RoundJoin);
    pen.setCapStyle(Qt::RoundCap);
    painter.setPen(pen);
    painter.drawPolygon(polygon);
    painter.end();

    QPainter painter2(&playIcon);
    painter2.setOpacity(.75);
    painter2.drawPixmap(0, 0, tempPixmap);
}
Example #22
0
void GaugeCompass::drawScale(QPainter *painter)
{
    int radius = 85;
    painter->save();
    painter->setPen(foreground);

    //总共8格,4格为NESW字母,4格为线条
    int steps = 8;
    double angleStep = 360.0 / steps;
    QPen pen = painter->pen();
    pen.setCapStyle(Qt::RoundCap);
    pen.setWidth(4);
    painter->setPen(pen);

    //%2整数部分绘制NESW字母,其余绘制线条刻度
    for (int i = 0; i <= steps; i++) {
        if (i % 2 != 0) {
            painter->drawLine(0, radius - 10, 0, radius);
        }

        painter->rotate(angleStep);
    }

    painter->restore();
}
Example #23
0
////////////////////////////////////////////////////////////////////////////////
/// CPuzzleSpanArtist::paintStraightArrow
///
/// @description         This function paints an arrow on the straight edge
///                      between the two given nodes, pointing at the second
///                      node.
/// @pre                 None
/// @post                An arrow is painted on the straight edge pointing to
///                      the second node.
///
/// @param nodeFromPos:  This is the point the straight edge begins at.
/// @param nodeToPos:    This is the point the straight edge terminates at.
/// @param painter:      This is a pointer to the QPainter which will paint the
///                      edge.
///
/// @limitations         None
///
////////////////////////////////////////////////////////////////////////////////
void CPuzzleSpanArtist::paintStraightArrow( QPoint nodeFromPos,
                                            QPoint nodeToPos,
                                            QPainter *painter )
{
    QMatrix backupMatrix = painter->matrix();

    QPen pen = painter->pen();
    int w = painter->pen().width();
    int d = m_style->getNodeRadius() * 2;

    painter->translate( nodeToPos );
    painter->rotate( -angleNorthOfEast( nodeFromPos, nodeToPos )*180/PI );
    painter->translate( (d/2)+(w/2), 0 );

    //painter->drawLine( 0, 0, (int)(d*.25),  (int)(d*.25) );
    //painter->drawLine( 0, 0, (int)(d*.25), -(int)(d*.25) );
 
    pen.setCapStyle( Qt::RoundCap );
    pen.setJoinStyle( Qt::RoundJoin );
    painter->setBrush(Qt::color1);
    painter->setPen(pen);
    painter->drawPolygon(QPolygonF() << QPointF(0,0) 
			 << QPointF(d/6,d/8)
			 << QPointF(d/6,-d/8));
   
    painter->setMatrix( backupMatrix );
}
Example #24
0
void PlaylistItemDelegate::createPlayIcon() {
    playIcon = QPixmap(THUMB_WIDTH, THUMB_HEIGHT);
    playIcon.fill(Qt::transparent);

    QPixmap tempPixmap(THUMB_WIDTH, THUMB_HEIGHT);
    tempPixmap.fill(Qt::transparent);
    QPainter painter(&tempPixmap);
    painter.setRenderHints(QPainter::Antialiasing, true);

    const int hPadding = PADDING*6;
    const int vPadding = PADDING*2;

    QPolygon polygon;
    polygon << QPoint(hPadding, vPadding)
            << QPoint(THUMB_WIDTH-hPadding, THUMB_HEIGHT/2)
            << QPoint(hPadding, THUMB_HEIGHT-vPadding);
    painter.setBrush(Qt::white);
    QPen pen;
    pen.setColor(Qt::white);
    pen.setWidth(PADDING);
    pen.setJoinStyle(Qt::RoundJoin);
    pen.setCapStyle(Qt::RoundCap);
    painter.setPen(pen);
    painter.drawPolygon(polygon);
    painter.end();

    QPainter painter2(&playIcon);
    painter2.setOpacity(.75);
    painter2.drawPixmap(0, 0, tempPixmap);
}
Example #25
0
  void LaserScanPlugin::DrawIcon()
  {
    if (icon_)
    {
      QPixmap icon(16, 16);
      icon.fill(Qt::transparent);

      QPainter painter(&icon);
      painter.setRenderHint(QPainter::Antialiasing, true);

      QPen pen;
      pen.setWidth(4);
      pen.setCapStyle(Qt::RoundCap);
      
      pen.setColor(InterpolateColors(min_color_, max_color_, 0.2));
      painter.setPen(pen);
      painter.drawPoint(2, 13);
      
      pen.setColor(InterpolateColors(min_color_, max_color_, 0.6));
      painter.setPen(pen);
      painter.drawPoint(4, 6);
      
      pen.setColor(InterpolateColors(min_color_, max_color_, 0.4));
      painter.setPen(pen);
      painter.drawPoint(12, 9);
      
      pen.setColor(InterpolateColors(min_color_, max_color_, 0.8));
      painter.setPen(pen);
      painter.drawPoint(13, 2);

      icon_->SetPixmap(icon);
    }
  }
Example #26
0
void PlotCurve::drawSideLines(QPainter *p, const QwtScaleMap &xMap,
                              const QwtScaleMap &yMap, int from, int to) const {
  if (!p || dataSize() <= 0)
    return;

  if (to < 0)
    to = dataSize() - 1;

  p->save();
  QPen pen = p->pen();
  pen.setCapStyle(Qt::FlatCap);
  pen.setJoinStyle(Qt::MiterJoin);
  p->setPen(pen);

  double lw = 0.5 * pen.widthF();
  const double xl = xMap.xTransform(x(from)) - lw;
  const double xr = xMap.xTransform(x(to)) + lw;
  const double yl = yMap.xTransform(y(from)) - lw;
  const double yr = yMap.xTransform(y(to)) - lw;
  const double base = yMap.xTransform(baseline());

  p->drawLine(QPointF(xl, yl), QPointF(xl, base));
  p->drawLine(QPointF(xr, yr), QPointF(xr, base));

  p->restore();
}
Example #27
0
void radeon_profile::setupGraphsStyle()
{
    QPen pen;
    pen.setWidth(ui->spin_lineThick->value());
    pen.setCapStyle(Qt::SquareCap);
    pen.setColor(ui->graphColorsList->topLevelItem(TEMP_LINE)->backgroundColor(1));
    ui->plotTemp->graph(0)->setPen(pen);
    ui->plotFanProfile->graph(0)->setPen(pen);
    pen.setColor(ui->graphColorsList->topLevelItem(GPU_CLOCK_LINE)->backgroundColor(1));
    ui->plotClocks->graph(0)->setPen(pen);
    pen.setColor(ui->graphColorsList->topLevelItem(MEM_CLOCK_LINE)->backgroundColor(1));
    ui->plotClocks->graph(1)->setPen(pen);
    pen.setColor(ui->graphColorsList->topLevelItem(UVD_VIDEO_LINE)->backgroundColor(1));
    ui->plotClocks->graph(2)->setPen(pen);
    pen.setColor(ui->graphColorsList->topLevelItem(UVD_DECODER_LINE)->backgroundColor(1));
    ui->plotClocks->graph(3)->setPen(pen);
    pen.setColor(ui->graphColorsList->topLevelItem(CORE_VOLTS_LINE)->backgroundColor(1));
    ui->plotVolts->graph(0)->setPen(pen);
    pen.setColor(ui->graphColorsList->topLevelItem(MEM_VOLTS_LINE)->backgroundColor(1));
    ui->plotVolts->graph(1)->setPen(pen);

    ui->plotTemp->setBackground(QBrush(ui->graphColorsList->topLevelItem(TEMP_BG)->backgroundColor(1)));
    ui->plotClocks->setBackground(QBrush(ui->graphColorsList->topLevelItem(CLOCKS_BG)->backgroundColor(1)));
    ui->plotVolts->setBackground(QBrush(ui->graphColorsList->topLevelItem(VOLTS_BG)->backgroundColor(1)));
    ui->plotFanProfile->setBackground(QBrush(ui->graphColorsList->topLevelItem(TEMP_BG)->backgroundColor(1)));
}
Example #28
0
static inline void qwtDrawXCrossSymbols( QPainter *painter,
    const QPointF *points, int numPoints, const QwtSymbol &symbol )
{
    const QSize size = symbol.size();
    int off = 0;

    QPen pen = symbol.pen();
    if ( pen.width() > 1 )
    {
        pen.setCapStyle( Qt::FlatCap );
        off = 1;
    }
    painter->setPen( pen );


    if ( QwtPainter::roundingAlignment( painter ) )
    {
        const int sw = size.width();
        const int sh = size.height();
        const int sw2 = size.width() / 2;
        const int sh2 = size.height() / 2;

        for ( int i = 0; i < numPoints; i++ )
        {
            const QPointF &pos = points[i];

            const int x = qRound( pos.x() );
            const int y = qRound( pos.y() );

            const int x1 = x - sw2;
            const int x2 = x1 + sw + off;
            const int y1 = y - sh2;
            const int y2 = y1 + sh + off;

            QwtPainter::drawLine( painter, x1, y1, x2, y2 );
            QwtPainter::drawLine( painter, x2, y1, x1, y2 );
        }
    }
    else
    {
        const double sw = size.width();
        const double sh = size.height();
        const double sw2 = 0.5 * size.width();
        const double sh2 = 0.5 * size.height();

        for ( int i = 0; i < numPoints; i++ )
        {
            const QPointF &pos = points[i];

            const double x1 = pos.x() - sw2;
            const double x2 = x1 + sw;
            const double y1 = pos.y() - sh2;
            const double y2 = y1 + sh;

            QwtPainter::drawLine( painter, x1, y1, x2, y2 );
            QwtPainter::drawLine( painter, x1, y2, x2, y1 );
        }
    }
}
Example #29
0
QPen* getPen(const CLGraphicalPrimitive1D *item, const CLGroup *group, const CLRenderResolver* resolver, const CLBoundingBox * /*pBB*/)
{
  QColor color; double width;

  if (item != NULL && item->isSetStroke())
    {
      color = getColor(item->getStroke(), resolver);
    }
  else if (group != NULL && group->isSetStroke())
    {
      color = getColor(group->getStroke(), resolver);
    }
  else return new QPen(Qt::transparent);

  if (item != NULL && item->isSetStrokeWidth())
    {
      width = item->getStrokeWidth();
    }
  else if (group != NULL && group->isSetStrokeWidth())
    {
      width = group->getStrokeWidth();
    }
  else return new QPen(Qt::transparent);

  QPen *result = new QPen(color, width);
  result->setCapStyle(Qt::RoundCap);
  result->setJoinStyle(Qt::RoundJoin);

  if (item != NULL && item->isSetDashArray())
    {
      const std::vector<unsigned int>& raw = item->getDashArray();
      std::vector<unsigned int>::const_iterator start = raw.begin();
      QVector<qreal> pattern;

      while (start != raw.end())
        {
          pattern << *start;
          ++start;
        }

      result->setDashPattern(pattern);
    }
  else if (group != NULL && group->isSetDashArray())
    {
      const std::vector<unsigned int>& raw = group->getDashArray();
      std::vector<unsigned int>::const_iterator start = raw.begin();
      QVector<qreal> pattern;

      while (start != raw.end())
        {
          pattern << *start;
          ++start;
        }

      result->setDashPattern(pattern);
    }

  return result;
}
void GeoLineStringGraphicsItem::paint( GeoPainter* painter, const ViewportParams* viewport )
{
    if ( !style() )
    {
        painter->save();
        painter->setPen( QPen() );
        painter->drawPolyline( *m_lineString );
        painter->restore();
        return;
    }
    
    if(style()->lineStyle().paintedColor() == Qt::transparent)
        return;

    painter->save();
    QPen currentPen = painter->pen();

    if ( currentPen.color() != style()->lineStyle().paintedColor() )
        currentPen.setColor( style()->lineStyle().paintedColor() );

    if ( currentPen.widthF() != style()->lineStyle().width() ||
            style()->lineStyle().physicalWidth() != 0.0 )
    {
        if ( float( viewport->radius() ) / EARTH_RADIUS * style()->lineStyle().physicalWidth() < style()->lineStyle().width() )
            currentPen.setWidthF( style()->lineStyle().width() );
        else
            currentPen.setWidthF( float( viewport->radius() ) / EARTH_RADIUS * style()->lineStyle().physicalWidth() );
    }

    if ( currentPen.capStyle() != style()->lineStyle().capStyle() )
        currentPen.setCapStyle( style()->lineStyle().capStyle() );

    if ( currentPen.style() != style()->lineStyle().penStyle() )
        currentPen.setStyle( style()->lineStyle().penStyle() );
    
    if ( style()->lineStyle().penStyle() == Qt::CustomDashLine )
        currentPen.setDashPattern( style()->lineStyle().dashPattern() );

    if ( painter->mapQuality() != Marble::HighQuality
            && painter->mapQuality() != Marble::PrintQuality )
    {
        QColor penColor = currentPen.color();
        penColor.setAlpha( 255 );
        currentPen.setColor( penColor );
    }

    if ( painter->pen() != currentPen ) painter->setPen( currentPen );
    if ( style()->lineStyle().background() )
    {
        QBrush brush = painter->background();
        brush.setColor( style()->polyStyle().paintedColor() );
        painter->setBackground( brush );

        painter->setBackgroundMode( Qt::OpaqueMode );
    }
    painter->drawPolyline( *m_lineString );
    painter->restore();
}