void Spectrogram::drawContourLines (QPainter *p, const QwtScaleMap &xMap, const QwtScaleMap &yMap, const QwtRasterData::ContourLines &contourLines) const
{
	//QwtPlotSpectrogram::drawContourLines(p, xMap, yMap, contourLines);

	QwtValueList levels = contourLevels();
    const int numLevels = (int)levels.size();
    for (int l = 0; l < numLevels; l++){
        const double level = levels[l];

        QPen pen = defaultContourPen();
        if ( pen.style() == Qt::NoPen )
            pen = contourPen(level);

        if ( pen.style() == Qt::NoPen )
            continue;

        p->setPen(QwtPainter::scaledPen(pen));

        const QPolygonF &lines = contourLines[level];
        for ( int i = 0; i < (int)lines.size(); i += 2 ){
            const QPointF p1( xMap.xTransform(lines[i].x()),
                yMap.transform(lines[i].y()) );
            const QPointF p2( xMap.xTransform(lines[i + 1].x()),
                yMap.transform(lines[i + 1].y()) );

            p->drawLine(p1, p2);
        }
    }

	if (d_show_labels)
		updateLabels(p, xMap, yMap, contourLines);
}
/*!
   Paint the contour lines

   \param painter Painter
   \param xMap Maps x-values into pixel coordinates.
   \param yMap Maps y-values into pixel coordinates.
   \param contourLines Contour lines

   \sa renderContourLines(), defaultContourPen(), contourPen()
*/
void QwtPlotSpectrogram::drawContourLines( QPainter *painter,
        const QwtScaleMap &xMap, const QwtScaleMap &yMap,
        const QwtRasterData::ContourLines &contourLines ) const
{
    if ( d_data->data == NULL )
        return;

    const int numLevels = d_data->contourLevels.size();
    for ( int l = 0; l < numLevels; l++ )
    {
        const double level = d_data->contourLevels[l];

        QPen pen = defaultContourPen();
        if ( pen.style() == Qt::NoPen )
            pen = contourPen( level );

        if ( pen.style() == Qt::NoPen )
            continue;

        painter->setPen( pen );

        const QPolygonF &lines = contourLines[level];
        for ( int i = 0; i < lines.size(); i += 2 )
        {
            const QPointF p1( xMap.transform( lines[i].x() ),
                yMap.transform( lines[i].y() ) );
            const QPointF p2( xMap.transform( lines[i+1].x() ),
                yMap.transform( lines[i+1].y() ) );

            QwtPainter::drawLine( painter, p1, p2 );
        }
    }
}
Example #3
0
QString PlotCurve::saveCurveLayout()
{
  Plot *plot = static_cast<Plot *>(this->plot());
  Graph *g = static_cast<Graph *>(plot->parent());

  int index = g->curveIndex(static_cast<QwtPlotCurve *>(this));
  int style = g->curveType(index);
  QString s = "<Style>" + QString::number(style) + "</Style>\n";

  if (style == Graph::Spline)
    s += "<LineStyle>5</LineStyle>\n";
  else if (style == Graph::VerticalSteps)
    s += "<LineStyle>6</LineStyle>\n";
  else
    s += "<LineStyle>" + QString::number(this->style()) + "</LineStyle>\n";

  QPen pen = this->pen();
  if (pen.style() != Qt::NoPen){
    s += "<Pen>\n";
    s += "\t<Color>" + pen.color().name() + "</Color>\n";
    s += "\t<Style>" + QString::number(pen.style()-1) + "</Style>\n";
    s += "\t<Width>" + QString::number(pen.widthF()) + "</Width>\n";
    s += "</Pen>\n";
  }

  QBrush brush = this->brush();
  if (brush.style() != Qt::NoBrush){
    s += "<Brush>\n";
    s += "\t<Color>" + brush.color().name() + "</Color>\n";
    s += "\t<Style>" + QString::number(PatternBox::patternIndex(brush.style())) + "</Style>\n";
    s += "</Brush>\n";
  }

  const QwtSymbol symbol = this->symbol();
  if (symbol.style() != QwtSymbol::NoSymbol){
    s += "<Symbol>\n";
    s += "\t<Style>" + QString::number(SymbolBox::symbolIndex(symbol.style())) + "</Style>\n";
    s += "\t<Size>" + QString::number(symbol.size().width()) + "</Size>\n";

    s += "\t<SymbolPen>\n";
    s += "\t\t<Color>" + symbol.pen().color().name() + "</Color>\n";
    s += "\t\t<Width>" + QString::number(symbol.pen().widthF()) + "</Width>\n";
    s += "\t</SymbolPen>\n";

    brush = this->brush();
    if (brush.style() != Qt::NoBrush){
      s += "\t<SymbolBrush>\n";
      s += "\t\t<Color>" + symbol.brush().color().name() + "</Color>\n";
      s += "\t\t<Style>" + QString::number(PatternBox::patternIndex(symbol.brush().style())) + "</Style>\n";
      s += "\t</SymbolBrush>\n";
    }
    s += "</Symbol>\n";
  }
  s += "<xAxis>" + QString::number(xAxis()) + "</xAxis>\n";
  s += "<yAxis>" + QString::number(yAxis()) + "</yAxis>\n";
  s += "<Visible>" + QString::number(isVisible()) + "</Visible>\n";
  return s;
}
Example #4
0
//not used anywhere
int Calligra::Sheets::Util::penCompare(QPen const & pen1, QPen const & pen2)
{
    if (pen1.style() == Qt::NoPen && pen2.style() == Qt::NoPen)
        return 0;

    if (pen1.style() == Qt::NoPen)
        return -1;

    if (pen2.style() == Qt::NoPen)
        return 1;

    if (pen1.width() < pen2.width())
        return -1;

    if (pen1.width() > pen2.width())
        return 1;

    if (pen1.style() < pen2.style())
        return -1;

    if (pen1.style() > pen2.style())
        return 1;

    if (pen1.color().name() < pen2.color().name())
        return -1;

    if (pen1.color().name() > pen2.color().name())
        return 1;

    return 0;
}
void QAbstractDiagramGraphicsItem::setPen(const QPen & pen)
{
    QStringList mAttrs;
    mAttrs << QString("color:#%1").arg(pen.color().rgb(),3, 16)
           << QString("width:%1").arg(pen.width());
    switch(pen.style()){
    case Qt::SolidLine:
        mAttrs << "style::solid";
        break;
    case Qt::DashLine:
        mAttrs << "style::dash";
        break;
    case Qt::DotLine:
        mAttrs << "style::dor";
        break;
    case Qt::DashDotLine:
        mAttrs << "style::dashdot";
        break;
    case Qt::DashDotDotLine:
        mAttrs << "style::dashdotdot";
        break;
    default:
        mAttrs << "style::solid";
        break;
    }
    setProperty("pen", mAttrs.join(";"));
}
Example #6
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 #7
0
void SCgModeBus::mouseMoveEvent (QGraphicsSceneMouseEvent * mouseEvent , bool afterSceneEvent)
{
    if(afterSceneEvent)
    {
        if(mDecoratedMode)
            mDecoratedMode->mouseMoveEvent(mouseEvent, afterSceneEvent);
        return;
    }

    if(mPathItem)
    {
        mouseEvent->accept();
        QVector2D vec(mouseEvent->scenePos() - mPathItem->points().last());

        QPen pen = mPathItem->pen();
        Qt::PenStyle s;

        if (vec.length() < 5.f)
            s = Qt::SolidLine;
        else
            s = Qt::DashDotLine;

        if(s != pen.style())
        {
            pen.setStyle(s);
            mPathItem->setPen(pen);
        }

        mPathItem->update(mouseEvent->scenePos());
        return;
    }

    if (mDecoratedMode)
        mDecoratedMode->mouseMoveEvent(mouseEvent, afterSceneEvent);
}
Example #8
0
QString Calligra::Sheets::Odf::encodePen(const QPen & pen)
{
//     kDebug()<<"encodePen( const QPen & pen ) :"<<pen;
    // NOTE Stefan: QPen api docs:
    //              A line width of zero indicates a cosmetic pen. This means
    //              that the pen width is always drawn one pixel wide,
    //              independent of the transformation set on the painter.
    QString s = QString("%1pt ").arg((pen.width() == 0) ? 1 : pen.width());
    switch (pen.style()) {
    case Qt::NoPen:
        return "none";
    case Qt::SolidLine:
        s += "solid";
        break;
    case Qt::DashLine:
        s += "dashed";
        break;
    case Qt::DotLine:
        s += "dotted";
        break;
    case Qt::DashDotLine:
        s += "dot-dash";
        break;
    case Qt::DashDotDotLine:
        s += "dot-dot-dash";
        break;
    default: break;
    }
    //kDebug() << " encodePen :" << s;
    if (pen.color().isValid()) {
        s += ' ' + Style::colorName(pen.color());
    }
    return s;
}
Example #9
0
void tst_QPen::stream()
{
    QFETCH(QPen, pen);

    QByteArray bytes;

    {
        QDataStream stream(&bytes, QIODevice::WriteOnly);
        stream << pen;
    }

    QPen cmp;
    {
        QDataStream stream(&bytes, QIODevice::ReadOnly);
        stream >> cmp;
    }

    QCOMPARE(pen.widthF(), cmp.widthF());
    QCOMPARE(pen.style(), cmp.style());
    QCOMPARE(pen.capStyle(), cmp.capStyle());
    QCOMPARE(pen.joinStyle(), cmp.joinStyle());
    QCOMPARE(pen.brush(), cmp.brush());

    QCOMPARE(pen, cmp);
}
void DateTimeGrid::paintMonthGrid( QPainter* painter,
                                  const QRectF& /*sceneRect*/,
                                  const QRectF& exposedRect,
                                  AbstractRowController* /*rowController*/,
                                  QWidget* widget )
{
    //qDebug()<<"paintMonthGrid()"<<scale()<<dayWidth();
    QDateTime dt = d->chartXtoDateTime( exposedRect.left() );
    dt.setTime( QTime( 0, 0, 0, 0 ) );
    dt = dt.addDays( 1 - dt.date().day() );
    for ( qreal x = d->dateTimeToChartX( dt ); x < exposedRect.right(); dt = dt.addDays( 1 ),x=d->dateTimeToChartX( dt ) ) {
        QPen pen = painter->pen();
        pen.setBrush( QApplication::palette().dark() );
        if ( dt.date().addMonths( 1 ).month() == 1 && dt.date().addDays( 1 ).day() == 1 ) {
            pen.setStyle( Qt::SolidLine );
        } else if ( dt.date().addDays( 1 ).day() == 1 ) {
            pen.setStyle( Qt::DashLine );
        } else {
            pen.setStyle( Qt::NoPen );
        }
        painter->setPen( pen );
        paintFreeDay( painter, x, exposedRect, dt.date(), widget );
        if ( pen.style() != Qt::NoPen ) {
            //qDebug()<<"paintMonthGrid()"<<dt;
            x += dayWidth() - 1;
            painter->drawLine( QPointF( x, exposedRect.top() ), QPointF( x, exposedRect.bottom() ) );
        }
    }
}
Example #11
0
void MythRenderOpenGL1::DrawRectPriv(const QRect &area, const QBrush &fillBrush,
                                     const QPen &linePen, int alpha)
{
    SetBlend(true);
    DisableTextures();
    glEnableClientState(GL_VERTEX_ARRAY);

    if (fillBrush.style() != Qt::NoBrush)
    {
        SetColor(fillBrush.color().red(), fillBrush.color().green(),
                 fillBrush.color().blue(), fillBrush.color().alpha());
        GLfloat *vertices = GetCachedVertices(GL_TRIANGLE_STRIP, area);
        glVertexPointer(2, GL_FLOAT, 0, vertices);
        glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
    }

    if (linePen.style() != Qt::NoPen)
    {
        SetColor(linePen.color().red(), linePen.color().green(),
                 linePen.color().blue(), linePen.color().alpha());
        glLineWidth(linePen.width());
        GLfloat *vertices = GetCachedVertices(GL_LINE_LOOP, area);
        glVertexPointer(2, GL_FLOAT, 0, vertices);
        glDrawArrays(GL_LINE_LOOP, 0, 4);
    }

    glDisableClientState(GL_VERTEX_ARRAY);
}
Example #12
0
qreal QSvgNode::strokeWidth(QPainter *p)
{
    QPen pen = p->pen();
    if (pen.style() == Qt::NoPen || pen.brush().style() == Qt::NoBrush || pen.isCosmetic())
        return 0;
    return pen.widthF();
}
//=============================================================================
int sstQt01PathStoreViewCls::AppendPathSymbol(int          iKey,
                                      QPainterPath oTmpPath,
                                      sstQt01ShapeType_enum eTmpPathType,
                                      QColor       oTmpColor,
                                      QPen         oTmpPen)
{

  //-----------------------------------------------------------------------------
  if ( iKey != 0) return -1;

  int iEleNum = oTmpPath.elementCount();
  for (int ii =1; ii <= iEleNum; ii++)
  {
    sstQt01PathElementCsv3Cls oShapeItemCsv;
    QPainterPath::Element oElement;
    oElement = oTmpPath.elementAt(ii-1);
    oShapeItemCsv.setAll(oElement.type,oElement.x,oElement.y, oTmpColor);
    if (oElement.type == 0)
    {
      oShapeItemCsv.setIPenStyle(oTmpPen.style());
      oShapeItemCsv.setIPenWidth(oTmpPen.width());
      oShapeItemCsv.setShapeType(eTmpPathType);
    }
  }

  return 0;
}
Example #14
0
void MythD3D9Painter::DrawRect(const QRect &area, const QBrush &fillBrush,
                               const QPen &linePen, int alpha)
{
    int style = fillBrush.style();
    if (style == Qt::SolidPattern || style == Qt::NoBrush)
    {
        if (!m_render)
            return;

        if (style != Qt::NoBrush)
            m_render->DrawRect(area, fillBrush.color(), alpha);

        if (linePen.style() != Qt::NoPen)
        {
            int lineWidth = linePen.width();
            QRect top(QPoint(area.x(), area.y()),
                      QSize(area.width(), lineWidth));
            QRect bot(QPoint(area.x(), area.y() + area.height() - lineWidth),
                      QSize(area.width(), lineWidth));
            QRect left(QPoint(area.x(), area.y()),
                       QSize(lineWidth, area.height()));
            QRect right(QPoint(area.x() + area.width() - lineWidth, area.y()),
                        QSize(lineWidth, area.height()));
            m_render->DrawRect(top,   linePen.color(), alpha);
            m_render->DrawRect(bot,   linePen.color(), alpha);
            m_render->DrawRect(left,  linePen.color(), alpha);
            m_render->DrawRect(right, linePen.color(), alpha);
        }
        return;
    }

    MythPainter::DrawRect(area, fillBrush, linePen, alpha);
}
Example #15
0
QVariant Util::decorationForVariant(const QVariant &value)
{
  switch (value.type()) {
  case QVariant::Brush:
  {
    const QBrush b = value.value<QBrush>();
    if (b.style() != Qt::NoBrush) {
      QPixmap p(16, 16);
      p.fill(QColor(0, 0, 0, 0));
      QPainter painter(&p);
      painter.setBrush(b);
      painter.drawRect(0, 0, p.width() - 1, p.height() - 1);
      return p;
    }
  }
  case QVariant::Color:
  {
    const QColor c = value.value<QColor>();
    if (c.isValid()) {
      QPixmap p(16, 16);
      QPainter painter(&p);
      painter.setBrush(QBrush(c));
      painter.drawRect(0, 0, p.width() - 1, p.height() - 1);
      return p;
    }
  }
  case QVariant::Cursor:
  {
    const QCursor c = value.value<QCursor>();
    if (!c.pixmap().isNull()) {
      return c.pixmap().scaled(16, 16, Qt::KeepAspectRatio, Qt::FastTransformation);
    }
  }
  case QVariant::Icon:
  {
    return value;
  }
  case QVariant::Pen:
  {
    const QPen pen = value.value<QPen>();
    if (pen.style() != Qt::NoPen) {
      QPixmap p(16, 16);
      p.fill(QColor(0, 0, 0, 0));
      QPainter painter(&p);
      painter.setPen(pen);
      painter.translate(0, 8 - pen.width() / 2);
      painter.drawLine(0, 0, p.width(), 0);
      return p;
    }
  }
  case QVariant::Pixmap:
  {
    const QPixmap p = value.value<QPixmap>();
    return QVariant::fromValue(p.scaled(16, 16, Qt::KeepAspectRatio, Qt::FastTransformation));
  }
  default: break;
  }

  return QVariant();
}
Example #16
0
void KigPainter::setPen( const QPen& p )
{
    color = p.color();
    width = p.width();
    style = p.style();
    mP.setPen(p);
}
Example #17
0
void SCgModePair::mouseMoveEvent ( QGraphicsSceneMouseEvent * mouseEvent )
{
    mouseEvent->accept();

    if(mPathItem)
    {
        mPathItem->update(mouseEvent->scenePos());

        SCgVisualObject *begObj = mObjectAtFirstPoint;
        SCgVisualObject *endObj = scene()->scgVisualObjectAt(mouseEvent->scenePos());

        QPen pen = mPathItem->pen();

        Qt::PenStyle s;

        if (endObj != begObj && endObj && begObj && endObj != begObj->parentItem())
            s = Qt::SolidLine;
        else
            s = Qt::DashDotLine;

        if(s != pen.style())
        {
            pen.setStyle(s);
            mPathItem->setPen(pen);
        }
    }
}
Example #18
0
QDomElement Calligra::Sheets::NativeFormat::createElement(const QString & tagname, const QPen & pen, QDomDocument & doc)
{
    QDomElement e(doc.createElement(tagname));
    e.setAttribute("color", pen.color().name());
    e.setAttribute("style", (int)pen.style());
    e.setAttribute("width", (int)pen.width());
    return e;
}
void DrawingPolyItem::setPen(const QPen& pen)
{
	setPenColor(pen.brush().color());
	setPenWidth(pen.widthF());
	setPenStyle(pen.style());
	setPenCapStyle(pen.capStyle());
	setPenJoinStyle(pen.joinStyle());
}
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();
}
Example #21
0
void createPenNode( QDomDocument& doc, QDomNode& parent,
                    const QString& elementName, const QPen& pen )
{
    QDomElement penElement = doc.createElement( elementName );
    parent.appendChild( penElement );
    createIntNode( doc, penElement, "Width", pen.width() );
    createColorNode( doc, penElement, "Color", pen.color() );
    createStringNode( doc, penElement, "Style", penStyleToString( pen.style() ) );
}
Example #22
0
void QJsonPaintEngine::updatePen(const QPen &pen)
{
	Q_D(QJsonPaintEngine);
#ifdef QT_PICTURE_DEBUG
	qDebug() << " -> updatePen(): width:" << pen.width() << "style:" << pen.style() << "color:" << pen.color().name();
#endif
	d->strokePen = pen;
	setCanvasPen();
}
void QgsSingleSymbolDialog::updateSet( const QgsSymbol *sy )
{
  if ( mLabelEdit->isEnabled() && mLabelEdit->text() != sy->label() )
    mLabelEdit->setEnabled( false );

  if ( lstSymbols->isEnabled() && lstSymbols->currentIndex().isValid() )
  {
    QAbstractItemModel *m = lstSymbols->model();

    if ( m->data( lstSymbols->currentIndex(), Qt::UserRole ).toString() != sy->pointSymbolName() )
      lstSymbols->setEnabled( false );
  }

  if ( mPointSizeSpinBox->isEnabled() && !doubleNear( mPointSizeSpinBox->value(), sy->pointSize() ) )
    mPointSizeSpinBox->setEnabled( false );

  if ( mPointSizeUnitsCheckBox->isEnabled() && mPointSizeUnitsCheckBox->isChecked() != sy->pointSizeUnits() )
    mPointSizeUnitsCheckBox->setEnabled( false );

  if ( mRotationClassificationComboBox->isEnabled() &&
       mRotationClassificationComboBox->itemData( mRotationClassificationComboBox->currentIndex() ).toInt() != sy->rotationClassificationField() )
    mRotationClassificationComboBox->setEnabled( false );

  if ( mScaleClassificationComboBox->isEnabled() &&
       mScaleClassificationComboBox->itemData( mScaleClassificationComboBox->currentIndex() ).toInt() != sy->scaleClassificationField() )
    mScaleClassificationComboBox->setEnabled( false );

  if ( mSymbolComboBox->isEnabled() &&
       mSymbolComboBox->itemData( mSymbolComboBox->currentIndex() ).toInt() != sy->symbolField() )
    mSymbolComboBox->setEnabled( false );

  if ( outlinewidthspinbox->isEnabled() && !doubleNear( outlinewidthspinbox->value(), sy->pen().widthF() ) )
    outlinewidthspinbox->setEnabled( false );

  if ( btnFillColor->isEnabled() &&  btnFillColor->color() != sy->brush().color() )
    btnFillColor->setEnabled( false );

  if ( btnOutlineColor->isEnabled() &&  btnOutlineColor->color() != sy->pen().color() )
    btnOutlineColor->setEnabled( false );

  if ( cboOutlineStyle->isEnabled() )
  {
    QPen myPen = sy->pen();
    QString myLineStyle = QgsSymbologyUtils::penStyle2QString( myPen.style() );
    if ( cboOutlineStyle->itemData( cboOutlineStyle->currentIndex(), Qt::UserRole ).toString() != myLineStyle )
      cboOutlineStyle->setEnabled( false );
  }

  if ( cboFillStyle->isEnabled() )
  {
    QBrush myBrush = sy->brush();
    QString myFillStyle =  QgsSymbologyUtils::brushStyle2QString( myBrush.style() );
    if ( cboFillStyle->itemData( cboFillStyle->currentIndex(), Qt::UserRole ).toString() != myFillStyle )
      cboFillStyle->setEnabled( false );
  }
}
Example #24
0
void SAPenSetWidget::setPen(const QPen &pen)
{
    m_curPen = pen;
    m_enableEmit = false;
    ui->pushButtonColor->setCurrentColor(pen.color());
    ui->comboBoxPenStyle->setStyle(pen.style());
    ui->spinBoxPenWidth->setValue(pen.width());
    ui->horizontalSliderColorAlpha->setValue(pen.color().alpha());
    m_enableEmit = true;
}
Example #25
0
void GraphModel::copyPropertiesFromGraph(const GraphModel *graph)
{
    using namespace global;
    if (graph) {
        QPen pen = graph->getPen();
        if (gIsLineWidthCopyable)
            setWidth(pen.widthF());
        if (gIsLineColorCopyable)
            setColor(pen.color());
        if (gIsLineStyleCopyable)
            setLineStyle(pen.style());
        if (gIsInterpolationCopyable)
            setLineInterpolation(graph->getLineInterpolation());

    //    if (gIsLineColorCopyable)
    //        setPenBrush(pen.brush());
        if (gIsDimensionCopyable)
            setUnit(graph->unit());


        QBrush brush = graph->brush();
        if (gIsBrushColorCopyable)
            setBrushColor(brush.color());
        if (gIsBrushStyleCopyable)
            setBrushStyle(brush.style());
        if (gIsBrushBasisCopyable)
            setFillBasis(graph->basisFillType());

        QCPScatterStyle scatterStyle = graph->getScatterStyle();
        if (gIsScatterShapeCopyable)
            setScatterShape(scatterStyle.shape());
        if (gIsScatterSizeCopyable)
            setScatterSize(scatterStyle.size());
        if (gIsScatterDecimationCopyable)
            setScatterDecimation(scatterStyle.decimation());

        if (gIsTransformationCopyable)
            setAffineConverter(graph->getAffineConverter());

        if (gIsStringRepresentationCopyable)
            setStringRepresentation(graph->stringRepresentation());

        if (gIsFiltersCopyable) {
            mFilterVector.clear();
            for(const auto& filter : graph->mFilterVector) {
                mFilterVector.push_back(filter->clone());
            }
        }
        updateOutputData();

    }


}
void KoOdfGraphicStyles::saveOdfStrokeStyle(KoGenStyle &styleStroke, KoGenStyles &mainStyles, const QPen &pen)
{
    // TODO implement all possibilities
    switch (pen.style()) {
    case Qt::NoPen:
        styleStroke.addProperty("draw:stroke", "none");
        return;
    case Qt::SolidLine:
        styleStroke.addProperty("draw:stroke", "solid");
        break;
    default: { // must be a dashed line
        styleStroke.addProperty("draw:stroke", "dash");
        // save stroke dash (14.14.7) which is severly limited, but still
        KoGenStyle dashStyle(KoGenStyle::StrokeDashStyle);
        dashStyle.addAttribute("draw:style", "rect");
        QVector<qreal> dashes = pen.dashPattern();
        dashStyle.addAttribute("draw:dots1", static_cast<int>(1));
        dashStyle.addAttributePt("draw:dots1-length", dashes[0]*pen.widthF());
        dashStyle.addAttributePt("draw:distance", dashes[1]*pen.widthF());
        if (dashes.size() > 2) {
            dashStyle.addAttribute("draw:dots2", static_cast<int>(1));
            dashStyle.addAttributePt("draw:dots2-length", dashes[2]*pen.widthF());
        }
        QString dashStyleName = mainStyles.insert(dashStyle, "dash");
        styleStroke.addProperty("draw:stroke-dash", dashStyleName);
        break;
    }
    }

    if (pen.brush().gradient()) {
        styleStroke.addProperty("koffice:stroke-gradient", saveOdfGradientStyle(mainStyles, pen.brush()));
    }
    else {
        styleStroke.addProperty("svg:stroke-color", pen.color().name());
        styleStroke.addProperty("svg:stroke-opacity", QString("%1").arg(pen.color().alphaF()));
    }
    styleStroke.addPropertyPt("svg:stroke-width", pen.widthF());

    switch (pen.joinStyle()) {
    case Qt::MiterJoin:
        styleStroke.addProperty("draw:stroke-linejoin", "miter");
        break;
    case Qt::BevelJoin:
        styleStroke.addProperty("draw:stroke-linejoin", "bevel");
        break;
    case Qt::RoundJoin:
        styleStroke.addProperty("draw:stroke-linejoin", "round");
        break;
    default:
        styleStroke.addProperty("draw:stroke-linejoin", "miter");
        styleStroke.addProperty("koffice:stroke-miterlimit", QString("%1").arg(pen.miterLimit()));
        break;
    }
}
Example #27
0
void ContourLinesEditor::insertLevel()
{
	if (!d_spectrogram)
		return;

	int row = table->currentRow();
	DoubleSpinBox *sb = (DoubleSpinBox*)table->cellWidget(row, 0);
	if (!sb)
		return;

	QwtDoubleInterval range = d_spectrogram->data().range();
	double current_value = sb->value();
	double previous_value = range.minValue ();
	sb = (DoubleSpinBox*)table->cellWidget(row - 1, 0);
	if (sb)
		previous_value = sb->value();

	double val = 0.5*(current_value + previous_value);

	table->blockSignals(true);
	table->insertRow(row);

	sb = new DoubleSpinBox();
	sb->setLocale(d_locale);
	sb->setDecimals(d_precision);
	sb->setValue(val);
	sb->setRange(range.minValue (), range.maxValue ());
	connect(sb, SIGNAL(activated(DoubleSpinBox *)), this, SLOT(spinBoxActivated(DoubleSpinBox *)));
    table->setCellWidget(row, 0, sb);

	QPen pen = d_spectrogram->defaultContourPen();
	if (pen.style() == Qt::NoPen)
		pen = d_spectrogram->contourPen (val);

	int width = 80;
	int height = 20;
	QPixmap pix(width, height);
	pix.fill(Qt::white);
	QPainter paint(&pix);
	paint.setRenderHint(QPainter::Antialiasing);
	paint.setPen(pen);
	paint.drawLine(0, height/2, width, height/2);
	paint.end();

	QLabel *lbl = new QLabel();
	lbl->setPixmap(pix);

	table->setCellWidget(row, 1, lbl);
	table->blockSignals(false);

	enableButtons(table->currentRow());
	d_pen_list.insert(row, pen);
}
void QwtPlotPropertySetDialog::updateCurveValue(QwtPlotCurve *cur)
{
    int baseID = getCurveBaseID(cur);
    m_property_id.setVarPropertyData(makeCurvePropertyID(baseID,ID_CurveTitle)
                                     ,cur->title().text());
    const QPen pen = cur->pen();
    m_property_id.setVarPropertyData(makeCurvePropertyID(baseID,ID_CurveColore)
                                     ,pen.color());
    m_property_id.setVarPropertyData(makeCurvePropertyID(baseID,ID_CurveWidth)
                                     ,pen.width());
    m_property_id.setVarPropertyData(makeCurvePropertyID(baseID,ID_CurvePenStyle)
                                     ,penStyle2Order(pen.style()));
}
Example #29
0
void Context2D::beginPainting()
{
    if (m_width <= 0 || m_height <=0)
        return;

    if (m_pixmap.width() != m_width || m_pixmap.height() != m_height) {
        if (m_painter.isActive())
            m_painter.end();
        m_pixmap = QPixmap(m_width, m_height);
        m_pixmap.fill(parent()->property("color").value<QColor>());
    }

    if (m_state.shadowBlur > 0 && m_painter.device() != &m_shadowbuffer) {
        if (m_painter.isActive())
            m_painter.end();
        updateShadowBuffer();
        m_painter.begin(&m_shadowbuffer);
        m_painter.setViewport(m_state.shadowOffsetX,
                              m_state.shadowOffsetY,
                              m_shadowbuffer.width(),
                              m_shadowbuffer.height());
        m_shadowbuffer.fill(Qt::transparent);
    }

    if (!m_painter.isActive()) {
        m_painter.begin(&m_pixmap);
        m_painter.setRenderHint(QPainter::Antialiasing);
        if (!m_state.clipPath.isEmpty())
            m_painter.setClipPath(m_state.clipPath);
        m_painter.setBrush(m_state.fillStyle);
        m_painter.setOpacity(m_state.globalAlpha);
        QPen pen;
        pen.setBrush(m_state.strokeStyle);
        if (pen.style() == Qt::NoPen)
            pen.setStyle(Qt::SolidLine);
        pen.setCapStyle(m_state.lineCap);
        pen.setJoinStyle(m_state.lineJoin);
        pen.setWidthF(m_state.lineWidth);
        pen.setMiterLimit(m_state.miterLimit);
        m_painter.setPen(pen);
    } else {
        setupPainter();
        m_state.flags = 0;
    }
}
void QPicturePaintEngine::updatePen(const QPen &pen)
{
    Q_D(QPicturePaintEngine);
#ifdef QT_PICTURE_DEBUG
    qDebug() << " -> updatePen(): width:" << pen.width() << "style:"
             << pen.style() << "color:" << pen.color();
#endif
    int pos;
    SERIALIZE_CMD(QPicturePrivate::PdcSetPen);
    if (d->pic_d->in_memory_only) {
        int index = d->pic_d->pen_list.size();
        d->pic_d->pen_list.append(pen);
        d->s << index;
    } else {
        d->s << pen;
    }
    writeCmdLength(pos, QRect(), false);
}