Example #1
0
void t_libraryEditor::paintCircle(QPainter &painter, const t_CircleObject &ob)
{
    QPen dotPen;
    dotPen.setWidth(ob.thickness);
    dotPen.setStyle(Qt::SolidLine);
    dotPen.setColor(g_color);
    painter.setPen(dotPen);
    painter.setBrush(Qt::NoBrush);

    painter.drawEllipse(QPoint(ob.posx, ob.posy), ob.radius, ob.radius);
}
LegendItem::LegendItem(QGraphicsItem* parent, int width, int height)
: QGraphicsRectItem(parent),
_currHeight(0){
    setRect(QRect(0, 0, width, height));
    QPen p;
    p.setColor(Qt::black);
    p.setStyle(Qt::SolidLine);
    setPen(p);

    _font.setPointSize(10);
}
Example #3
0
void TilesetWidget::paintEvent(QPaintEvent *event)
{
    auto state = MainWindow::getCurrentState();

    // no open documents?
    if (!state)
        return;

    QPainter painter;

    painter.begin(this);
    painter.fillRect(event->rect(), QWidget::palette().color(QWidget::backgroundRole()));

    painter.setBrush(QColor(0,0,0));
    painter.setPen(Qt::NoPen);

    QPen pen;
    pen.setColor({149,195,244,255});
    pen.setWidth(hasFocus() ? 3 : 1 );
    pen.setStyle(Qt::PenStyle::SolidLine);

    auto tileProperties = state->getTileProperties();
    int tw = tileProperties.size.width();
    int th = tileProperties.size.height();

    int max_tiles = 256 / (tw*th);

    for (int i=0; i<max_tiles;i++)
    {
        quint8 charIdx = tileProperties.interleaved == 1 ?
                                                    i * tw * th :
                                                    i;

        int w = (i * tw) % _columns;
        int h = th * ((i * tw) / _columns);

        for (int char_idx=0; char_idx < (tw * th); char_idx++)
        {
            int local_w = w + char_idx % tw;
            int local_h = h + char_idx / tw;

            utilsDrawChar(state, &painter, _pixelSize, QPoint(OFFSET, OFFSET), QPoint(local_w, local_h), charIdx);

            charIdx += tileProperties.interleaved;
        }
    }

    painter.setPen(Qt::NoPen);

    paintFocus(painter);
    paintSelectedTile(painter);

    painter.end();
}
void PlotDialog::setupPlot()
{

    QVector<double> x, y;
    getDataFromDB(y);
    y.insert(0, 0);
    for (int i = 0; i < y.size(); i++) {
        x.push_back(i);
    }

    //ui->customPlot->plotLayout()->insertRow(0);
    //ui->customPlot->plotLayout()->addElement(0, 0, new QCPPlotTitle(ui->customPlot, "Sensening Data Co2(ppm)"));
    ui->customPlot->addGraph();
    ui->customPlot->graph()->setLineStyle(QCPGraph::lsLine);
    QPen pen;
    pen.setColor(QColor(255, 200, 20, 200));
    pen.setStyle(Qt::DashLine);
    pen.setWidthF(2.5);
    ui->customPlot->graph()->setPen(pen);
    ui->customPlot->graph()->setBrush(QBrush(QColor(255,200,20,70)));

    ui->customPlot->graph(0)->setData(x,y);

    switch (dataType) {
    case CO2_TYPE:
        ui->customPlot->yAxis->setLabel("Sensening data Co2(ppm)");
         ui->customPlot->yAxis->setRange(0, 1000);
         break;
    case TMP_TYPE:
         ui->customPlot->yAxis->setLabel("c");
         ui->customPlot->yAxis->setRange(0, 50);
         break;
    case HUM_TYPE:
         ui->customPlot->yAxis->setLabel("%");
         ui->customPlot->yAxis->setRange(0, 100);
         break;
    case ILL_TYPE:
         ui->customPlot->yAxis->setLabel("KLux");
         ui->customPlot->yAxis->setRange(0, 100);
         break;
    }

    ui->customPlot->xAxis->setTicks(false);
    ui->customPlot->xAxis->setTickLabels(false);
    ui->customPlot->xAxis->setUpperEnding(QCPLineEnding::esSpikeArrow);
    ui->customPlot->yAxis->setUpperEnding(QCPLineEnding::esSpikeArrow);
    qDebug() << "y.size" << y.size();

    ui->customPlot->xAxis->setRange(0, y.size());

    ui->customPlot->xAxis->setUpperEnding(QCPLineEnding::esSpikeArrow);
    ui->customPlot->yAxis->setUpperEnding(QCPLineEnding::esSpikeArrow);
    ui->customPlot->replot();
}
Example #5
0
void CurveLine::drawControlLines(QPainter *painter)
{
	QPolygonF line = mEdge->line();

	QPen pen = painter->pen();
	pen.setStyle(Qt::DashLine);
	painter->save();
	painter->setPen(pen);
	painter->drawLine(line[0], line[1]);
	painter->drawLine(line[2], line[3]);
	painter->restore();
}
// 畫外框的格式
void ItemComponent::setPaintBorderFont( QPainter* painter )
{
	QPen qPen;
	painter->setBrush(Qt::NoBrush);
	if (isSelected())
	{
		qPen.setStyle(Qt::SolidLine);
		qPen.setWidth(4);
		qPen.setBrush(QColor(172, 210, 74));
		painter->setPen(qPen);
	}
}
Example #7
0
QPen LinePlotCanvas::preparePainter(QPainter *painter, LinePlot* plot)
{
    painter->setRenderHint(QPainter::Antialiasing, plot->antialias());

    // Get the style right
    QPen pen = QPen();
    pen.setCosmetic(true);
    pen.setColor( plot->line()->color() );

    QString style = plot->line()->style();
    if (style == ".") {
        pen.setStyle(Qt::SolidLine);
    } else {
        pen.setStyle( LineSpec::styleMap[style] );
    }

    pen.setWidthF( plot->line()->width() );
    painter->setPen(pen);

    return pen;
}
void QgsUniqueValueDialog::setSymbolColor( QgsSymbol *symbol, QColor thecolor )
{
  QPen pen;
  QBrush brush;
  if ( mVectorLayer->geometryType() == QGis::Line )
  {
    pen.setColor( thecolor );
    pen.setStyle( Qt::SolidLine );
    pen.setWidthF( symbol->lineWidth() );
  }
  else
  {
    brush.setColor( thecolor );
    brush.setStyle( Qt::SolidPattern );
    pen.setColor( Qt::black );
    pen.setStyle( Qt::SolidLine );
    pen.setWidthF( symbol->lineWidth() );
  }
  symbol->setPen( pen );
  symbol->setBrush( brush );
}
Example #9
0
void cube::drawPolyColor(Polygon & poly, QColor& color)
{
    QPen pen;
    pen.setColor(color);
    pen.setStyle(Qt::SolidLine);
    m_cubePainter->setPen(pen);
    ScreenPolygonCoordsStruct tmpSCoords = poly.getScreenCords();
    QVector <QPoint> pointArr;
    pointArr.clear();
    pointArr.append(tmpSCoords.v0);
    pointArr.append(tmpSCoords.v1);
    pointArr.append(tmpSCoords.v2);

    qSort(pointArr.begin(),pointArr.end(),pointCompare);
    QPoint A = pointArr[0];
    QPoint B = pointArr[1];
    QPoint C = pointArr[2];


    int sy = A.y();
    int x1,x2;
    for (sy = A.y(); sy >= C.y(); sy--) {
        if (A.y() == C.y())
        {
            x1 = A.x();
        }
        else
        {
            x1 = (int)(A.x() + (sy - A.y()) * (C.x() - A.x()) / (C.y() - A.y()));
        }
        if (sy > B.y())
            if (A.y() == B.y())
            {
                x2 = A.x();
            }
        else
            {
                x2 = (int)(A.x() + (sy - A.y()) * (B.x() - A.x()) / (B.y() - A.y()));
            }
      else {
            if (C.y() == B.y())
            {
                x2 = B.x();
            }
        else
            {
                x2 = (int)(B.x() + (sy - B.y()) * (C.x() - B.x()) / (C.y() - B.y()));
            }
      }
        m_cubePainter->drawLine(x1,sy,x2,sy);
    }
}
void DateTimeGrid::paintHourGrid( QPainter* painter,
                              const QRectF& /*sceneRect*/,
                              const QRectF& exposedRect,
                              AbstractRowController* /*rowController*/,
                              QWidget* /*widget*/ )
{
    //qDebug()<<"paintHourGrid()"<<scale()<<dayWidth();
    QDateTime dt = d->chartXtoDateTime( exposedRect.left() );
    dt.setTime( QTime( dt.time().hour(), 0, 0, 0 ) );
    for ( qreal x = d->dateTimeToChartX( dt ); x < exposedRect.right(); dt = dt.addSecs( 60*60 ),x=d->dateTimeToChartX( dt ) ) {
        QPen pen = painter->pen();
        pen.setBrush( QApplication::palette().dark() );
        if ( dt.time() == QTime( 23, 0, 0 ) ) {
            pen.setStyle( Qt::SolidLine );
        } else {
            pen.setStyle( Qt::DashLine );
        }
        painter->setPen( pen );
        x += ( dayWidth() / 24.0 ) - 1;
        painter->drawLine( QPointF( x, exposedRect.top() ), QPointF( x, exposedRect.bottom() ) );
    }
}
Example #11
0
QPen KivioLineStyle::pen( float scale ) const
{
    QPen p;
    float s = m_width * scale;

    p.setColor( m_color );
    p.setWidth( (int)s );
    p.setJoinStyle( (Qt::PenJoinStyle)m_joinStyle );
    p.setCapStyle( (Qt::PenCapStyle)m_capStyle );
    p.setStyle( (Qt::PenStyle)m_style );

    return p;
}
Example #12
0
void background::draw(QPainter *painter)
{
    painter->fillRect(0,0,width, height, QBrush(Qt::black,Qt::SolidPattern));
    painter->drawRect(0,0,width,height);

    QPen temp;
    temp.setBrush(Qt::white);
    temp.setStyle(Qt::DashLine);
    painter->setPen(temp);
    painter->drawLine(width/2,0,width/2,height);
    painter->drawText(text_left, left);
    painter->drawText(text_right, right);
}
Example #13
0
void GraphicsShot::paint(QPainter *painter, const QStyleOptionGraphicsItem *, QWidget *)
{
    QPen newPen = pen();
    newPen.setWidth(2);
    newPen.setColor(_startItem->agent()->color());
    newPen.setStyle(Qt::DotLine);

    setLine(_startItem->x(), _startItem->y(),
            _endItem->x(), _endItem->y());

    painter->setPen(newPen);
    painter->drawLine(line());
}
Example #14
0
QVariant OperatorItem::itemChange(GraphicsItemChange change, const QVariant &value)
{
    if(change == ItemSelectedHasChanged)
    {
        QPen currentPen = m_opRect->pen();

        if(isSelected())
            currentPen.setStyle(Qt::DashLine);
        else
            currentPen.setStyle(Qt::SolidLine);

        m_opRect->setPen(currentPen);
        
        return value;
    }
    if(change == ItemPositionHasChanged)
    {
        updateConnectionPositions();
    }

    return QGraphicsItem::itemChange(change, value);
}
Example #15
0
// virtual
void AbstractGroupItem::paint(QPainter *p, const QStyleOptionGraphicsItem *option, QWidget *)
{
    QColor bgcolor(100, 100, 200, 100);
    QRectF bound = option->exposedRect.adjusted(0, 0, 1, 1);
    p->setClipRect(bound);
    p->setBrush(bgcolor);
    QPen pen = p->pen();
    pen.setColor(QColor(200, 90, 90));
    pen.setStyle(Qt::DashLine);
    pen.setWidthF(0.0);
    p->setPen(pen);
    p->drawRoundedRect(boundingRect().adjusted(0, 0, -1, 0), 3, 3);
}
Example #16
0
// virtual
void AbstractGroupItem::paint(QPainter *p, const QStyleOptionGraphicsItem *option, QWidget *)
{
    const double scale = option->matrix.m11();
    QRect clipRect = option->exposedRect.toRect();
    clipRect.adjust(0, 0, 1 / scale + 0.5, 1);
    p->fillRect(option->exposedRect, QColor(100, 100, 200, 100));
    p->setClipRect(clipRect);
    QPen pen = p->pen();
    pen.setColor(QColor(200, 90, 90));
    pen.setStyle(Qt::DashLine);
    p->setPen(pen);
    p->drawRect(boundingRect());
}
Example #17
0
/* ------- прочитать настройки ------- */
void ViewPlot::settingRead()
{
    stngViewPlot->beginGroup("ViewPlot");

    // ЗОЗ
    ui->qwtPlot_spectrogram->setContourPen( stngViewPlot->value("ZozColor", "#ff0000").value<QColor>(),
                                            stngViewPlot->value("ZozWidth", 1).toFloat() );
    // Сетка
    QPen penGrid;
    penGrid.setColor( stngViewPlot->value("GridColor", "#7c7c7c").value<QColor>() );
    penGrid.setWidth( stngViewPlot->value("GridWidth", 1).toInt() );

    // Шрифт
    QFont fnt;
    fnt = stngViewPlot->value("GridFont", "Arial").value<QFont>();
    // Оси
    ui->qwtPlot_spectrogram->setAxisFontForAll(fnt);
    // Легенда
    QwtText crvTitle (curve->title());
    crvTitle.setFont(fnt);
    curve->setTitle(crvTitle);
    // Координаты
    ui->label->setFont(fnt);
    // Маркеры
    markerH->setFont(fnt);
    markerV->setFont(fnt);

    if(stngViewPlot->value("GridStyle", 0).toInt() == 0)
        penGrid.setStyle(Qt::SolidLine);
    else if(stngViewPlot->value("GridStyle", 0).toInt() == 1)
        penGrid.setStyle(Qt::DashLine);
    else if(stngViewPlot->value("GridStyle", 0).toInt() == 2)
        penGrid.setStyle(Qt::DotLine);
    else
        penGrid.setStyle(Qt::DashDotDotLine);

    ui->qwtPlot_spectrogram->setGridPen(penGrid);
    stngViewPlot->endGroup();
}
Example #18
0
Graph::Graph(QWidget *parent) : QWidget(parent){
  ui.setupUi(this);
  
  // Задаём положение окна по центру
  /*QDesktopWidget desktop;
  QRect rect = desktop.availableGeometry(desktop.primaryScreen());
  QPoint center = rect.center();
  center.setX(center.x() - (this->width()/2));
  center.setY(center.y() - (this->height()/2));
  move(center);*/
    
  // Создаём окно
  this->setWindowTitle(QString::fromUtf8("График"));
  
  // Файл с настройками
  settings_read = new QSettings("settings.conf",QSettings::IniFormat);
  settings_write = new QSettings("settings.conf",QSettings::IniFormat);
  
  // Настройка отрисовки графика
  grid = new QwtPlotGrid;
  grid->enableXMin(true);
  grid->setMajPen(QPen(Qt::black,0,Qt::DotLine));
  grid->setMinPen(QPen(Qt::gray,0,Qt::DotLine));
  grid->attach(ui.qwtGraph);
  
  curveTimeForce = new QwtPlotCurve();
  curveTimeForce->attach(ui.qwtGraph);
  
  QPen curvePen;
  curvePen.setStyle(Qt::DashLine);
  curvePen.setBrush(Qt::blue);
  curveTimeForce->setPen(curvePen);
  
  QwtSymbol symbolPoint;
  symbolPoint.setStyle(QwtSymbol::Rect);
  symbolPoint.setPen(QColor(Qt::blue));
  symbolPoint.setSize(5);
  curveTimeForce->setSymbol(symbolPoint);
  
  // Установка единиц измерения силы
  connect( this->ui.rbAdc, SIGNAL( clicked() ), this, SLOT( rbAdcSet() ) );
  connect( this->ui.rbNewton, SIGNAL( clicked() ), this, SLOT( rbNewtonSet() ) );
  connect( this->ui.rbKgf, SIGNAL( clicked() ), this, SLOT( rbKgfSet() ) );
  nPoints = 0;
  ui.rbAdc->setChecked(1);
  ui.qwtGraph->setAxisTitle(QwtPlot::yLeft,QString::fromUtf8("F, ед. ацп"));
  ui.qwtGraph->setAxisTitle(QwtPlot::xBottom,QString::fromUtf8("t, секунды"));
  
  // Загрузка настроек
  loadSettings();
}
void ImageWidget::restore(Graph *g, const QStringList& lst)
{
	int frameStyle = 0;
	QPen pen = QPen(Qt::black, 1, Qt::SolidLine, Qt::SquareCap, Qt::MiterJoin);
	double x = 0.0, y = 0.0, right = 0.0, bottom = 0.0;
	QStringList::const_iterator line;
	QString fn;
	bool save_xpm = false;
	ImageWidget *i = NULL;
	for (line = lst.begin(); line != lst.end(); line++){
        QString s = *line;
        if (s.contains("<Frame>"))
			frameStyle = s.remove("<Frame>").remove("</Frame>").toInt();
		else if (s.contains("<Color>"))
			pen.setColor(QColor(s.remove("<Color>").remove("</Color>")));
		else if (s.contains("<FrameWidth>"))
			pen.setWidth(s.remove("<FrameWidth>").remove("</FrameWidth>").toInt());
		else if (s.contains("<LineStyle>"))
			pen.setStyle(PenStyleBox::penStyle(s.remove("<LineStyle>").remove("</LineStyle>").toInt()));
		else if (s.contains("<x>"))
			x = s.remove("<x>").remove("</x>").toDouble();
		else if (s.contains("<y>"))
			y = s.remove("<y>").remove("</y>").toDouble();
		else if (s.contains("<right>"))
			right = s.remove("<right>").remove("</right>").toDouble();
		else if (s.contains("<bottom>"))
			bottom = s.remove("<bottom>").remove("</bottom>").toDouble();
		else if (s.contains("<path>"))
			i = g->addImage(s.remove("<path>").remove("</path>"));
		else if (s.contains("<xpm>")){
			save_xpm = true;
			if (!i){
				QString xpm;
				while ( s != "</xpm>" ){
					s = *(++line);
					xpm += s + "\n";
				}
				QImage image;
    			if (image.loadFromData(xpm.toAscii()))
					i = g->addImage(image);
			}
		}
	}

	if (i){
		i->setFrameStyle(frameStyle);
		i->setFramePen(pen);
		i->setCoordinates(x, y, right, bottom);
		i->setSaveInternally(save_xpm);
	}
}
Example #20
0
void CCJKShapeLine::DrawArrow(QPainter *painter, ArrowTypeFlag arrowType, const QPointF &p, const QPointF &p1, const QPointF &p2, qreal arrowSize)
{
	CJK_D(CCJKShapeLine);

	QPen pen = d->pen;
	pen.setStyle(Qt::SolidLine);
	pen.setJoinStyle(Qt::MiterJoin);
	painter->setPen(pen);

	switch (arrowType)
	{
	case ArrowArc:
	{
		QPainterPath path;
		path.moveTo(p1);
		path.lineTo(p);
		path.lineTo(p2);
		QPointF c = QPointF((p1.x() + p2.x() + p.x()) / 3, (p1.y() + p2.y() + p.y()) / 3);
		path.quadTo(c, p1);
		painter->drawPath(path);
	}
	break;
	case ArrowLine:
	{
		QBrush brsh(Qt::NoBrush);
		painter->setBrush(brsh);
		pen.setCapStyle(Qt::SquareCap);
		QPainterPath path;
		path.moveTo(p1);
		path.lineTo(p);
		path.lineTo(p2);
		painter->drawPath(path);
	}
	break;
	case ArrowCircle:
	{
		painter->drawEllipse(p, arrowSize / 2, arrowSize / 2);
	}
	break;
	case ArrowTriangle:
	default:
	{
		QPolygonF arrowHead;
		arrowHead << p << p1 << p2;
		painter->drawPolygon(arrowHead);
		break;
	}
	}
	painter->setBrush(d->brush);
	painter->setPen(d->pen);
}
Example #21
0
void Line::draw(QPainter& p, qreal scale) const
{	
	QVector<QPointF> points = _points;
    for (int i=0; i <_points.size(); ++i)
    {
        points[i] *= scale;
    }
    
    if (!_finished && !_mousePoint.isNull())
        points.append(_mousePoint * scale);
	
	QPen shapePen;
	shapePen.setStyle(Qt::SolidLine);
	shapePen.setColor(color());
	shapePen.setWidth(2);
	p.setPen(shapePen);
	
	p.drawPolyline(points.data(), points.size());
	
	shapePen.setWidth(4);
	p.setPen(shapePen);
	
	p.drawPoints(points.data(), points.size());
	
	if (_selected)
	{
		QPen selectedPen;
		selectedPen.setStyle(Qt::SolidLine);
		selectedPen.setColor(Qt::green);
		selectedPen.setWidth(6);
		p.setPen(selectedPen);
		
		p.drawPoints(points.data(), points.size());
	}
		
    if (_sibling)
        _sibling->draw(p, scale);
}
void EllipseObject::paint(QPainter* painter, const QStyleOptionGraphicsItem* option, QWidget* /*widget*/)
{
    QGraphicsScene* objScene = scene();
    if(!objScene) return;

    QPen paintPen = pen();
    if(option->state & QStyle::State_Selected)  { paintPen.setStyle(Qt::DashLine); }
    if(objScene->property(ENABLE_LWT).toBool()) { paintPen = lineWeightPen(); }
    painter->setPen(paintPen);

    updateRubber(painter);

    painter->drawEllipse(rect());
}
void DateTimeGrid::paintDayGrid( QPainter* painter,
                                  const QRectF& /*sceneRect*/,
                                  const QRectF& exposedRect,
                                  AbstractRowController* /*rowController*/,
                                  QWidget* widget )
{
    //qDebug()<<"paintDayGrid()"<<scale()<<dayWidth();
    QDateTime dt = d->chartXtoDateTime( exposedRect.left() );
    dt.setTime( QTime( 0, 0, 0, 0 ) );
    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().addDays( 1 ).dayOfWeek() == d->weekStart ) {
            pen.setStyle( Qt::SolidLine );
        } else {
            pen.setStyle( Qt::DashLine );
        }
        painter->setPen( pen );
        paintFreeDay( painter, x, exposedRect, dt.date(), widget );
        x += dayWidth() - 1;
        painter->drawLine( QPointF( x, exposedRect.top() ), QPointF( x, exposedRect.bottom() ) );
    }
}
Example #24
0
  void CreatorItem::paint(QPainter* painter, const QStyleOptionGraphicsItem* , QWidget* )
  {
    QPen pen;
    if (zValue() < depth_)
      pen.setStyle(Qt::DotLine);
    painter->setPen(pen);

    QBrush brush(color_);
    if (zValue() < depth_)
      brush.setStyle(Qt::Dense4Pattern);
    painter->setBrush(brush);

    painter->drawRect(0, 0, 9, 9);
  }
Example #25
0
void QITitleLableWidget::paintEvent(QPaintEvent *event)
{
    QPainter paint(this);
    paint.setRenderHint(QPainter::Antialiasing);
    QFont font;
    font.setFamily(QStringLiteral("微软雅黑"));
    font.setPointSize(10);
    QPen tPen;
    tPen.setColor(QColor(255,255,255));
    tPen.setStyle(Qt::SolidLine);
    paint.setPen(tPen);
    paint.setFont(font);
    paint.drawText(0,-2,75,24,Qt::AlignCenter,QStringLiteral("豆瓣音乐 FM"));
}
Example #26
0
void DrawWidget::mouseMoveEvent(QMouseEvent * e)
{
    QPainter *painter = new QPainter(pix);
    QPen pen;
    pen.setStyle((Qt::PenStyle)style);      	
    pen.setWidth(weight);
    pen.setColor(color);
    painter->setPen(pen);
    
    painter->drawLine(startPos,e->pos());
    startPos = e->pos();
    update();
    
}
void DrawingPolylineItem::render(QPainter* painter, const DrawingStyleOptions& styleOptions)
{
	DrawingItemPoint* point0 = point(0);
	DrawingItemPoint* point1 = point(numberOfPoints() - 1);
	QList<DrawingItemPoint*> lPoints = points();
	QPolygonF polygon;
	DrawingItemPoint* otherPoint;
	qreal theta;

	// Polyline
	for(auto pointIter = lPoints.begin(); pointIter != lPoints.end(); pointIter++)
		polygon.append((*pointIter)->pos());

	setupPainter(painter, styleOptions, pen());
	painter->drawPolyline(polygon);

	// Arrows
	if (pen().style() != Qt::NoPen)
	{
		QPen arrowPen = pen();
		arrowPen.setStyle(Qt::SolidLine);
		setupPainter(painter, styleOptions, arrowPen, styleOptions.outputBrush(DrawingStyleOptions::Background));

		otherPoint = point(1);
		if (otherPoint)
		{
			theta = qAtan2(otherPoint->y() - point0->y(),
				otherPoint->x() - point0->x()) * 180.0 / 3.1414592654;

			if (Drawing::magnitude(otherPoint->pos() - point0->pos()) > startArrowSize())
				startArrow().render(painter, point0->pos(), theta);
		}

		otherPoint = point(numberOfPoints() - 2);
		if (otherPoint)
		{
			theta = qAtan2(otherPoint->y() - point1->y(),
				otherPoint->x() - point1->x()) * 180.0 / 3.1414592654;

			if (Drawing::magnitude(otherPoint->pos() - point1->pos()) > endArrowSize())
				endArrow().render(painter, point1->pos(), theta);
		}
	}

#ifdef DEBUG_DRAW_ITEM_SHAPE
	painter->setBrush(Qt::magenta);
	painter->setPen(QPen(Qt::magenta, 1));
	painter->drawPath(shape());
#endif
}
Example #28
0
void
Node::paint(QPainter * painter, const QStyleOptionGraphicsItem * option,
	    QWidget * widget)
{
    Q_UNUSED(option);
    Q_UNUSED(widget);
    QColor brushColor;

    brushColor = nodeFill;
    painter->setBrush(brushColor);

    QPen pen;
    // TODO: is this code not defunct?  It seems to be over-ridden.
    if (isSelected())
        pen.setStyle(Qt::DotLine);
    else
        pen.setStyle(Qt::SolidLine);

    if (choose == 1)
        pen.setStyle(Qt::DotLine);
    else if (choose == 2)
        pen.setStyle(Qt::DashLine);
    else
        pen.setStyle(Qt::SolidLine);

    pen.setColor(nodeLine);
    painter->setPen(pen);

    painter->drawEllipse(-1 * nodeDiameter / 2,
                         -1 * nodeDiameter / 2,
                         nodeDiameter, nodeDiameter);

    text->setPos(this->boundingRect().center().x()
		 - text->boundingRect().width() / 2.,
                 this->boundingRect().center().y()
                 - text->boundingRect().height() / 2.);
}
Example #29
0
int main( int argc, char** argv ) {
    QApplication app( argc, argv );

    Widget widget;
    widget.resize( 600, 600 );

    QVector< double > vec0,  vec1,  vec2;

    vec0 << 5 << 1 << 3 << 4 << 1;
    vec1 << 3 << 6 << 2 << 4 << 8;
    vec2 << 0 << 7 << 1 << 2 << 1;

    widget.setDataset( 0, vec0, "vec0" );
    widget.setDataset( 1, vec1, "vec1" );
    widget.setDataset( 2, vec2, "vec2" );
    widget.setSubType(  Widget::Percent );

    //Configure a pen and draw a line
    //a dot line for column 1
    QPen pen;
    QBrush brush;
    pen.setWidth(3);
    pen.setStyle( Qt::DotLine );
    pen.setColor(  Qt::yellow );
    brush.setColor(  Qt::yellow );
    // call your diagram and set the new pen
    // and brush
    widget.lineDiagram()->setPen(  1 , pen );
    widget.lineDiagram()->setBrush( 1,  brush );

    //set up a legend
    Legend* legend = new Legend( &widget );
    legend->setPosition( Position::East );
    legend->setAlignment( Qt::AlignCenter );
    legend->setOrientation( Qt::Vertical );
    legend->setLegendStyle( Legend::LinesOnly );
    legend->setShowLines(  true );
    widget.addLegend( legend );
    //Set up your Attributes
    //display areas
    LineAttributes la( widget.lineDiagram()->lineAttributes() );
    la.setDisplayArea(  true );
    la.setTransparency( 25 );
    widget.lineDiagram()->setLineAttributes( la );

    widget.show();

    return app.exec();
}
Example #30
0
void t_libraryEditor::paintPin(QPainter &painter, const t_PinObject &ob)
{
    QPen dotPen;
    dotPen.setWidth(4);
    dotPen.setStyle(Qt::SolidLine);
    dotPen.setColor(g_color);
    painter.setPen(dotPen);
    painter.setBrush(Qt::NoBrush);

    painter.setBackground(QBrush(QColor(0,0,0,0)));

    QFont tFont;
    tFont.setPixelSize(ob.name_text_size);
    painter.setFont(tFont);

    int16_t tox, toy;
    tox = toy = 0;
    if(ob.direction == 'U')
    {
        tox = ob.posx;
        toy = ob.posy - ob.length;
    }
    else if(ob.direction == 'D')
    {
        tox = ob.posx;
        toy = ob.posy + ob.length;
    }
    else if(ob.direction == 'R')
    {
        tox = ob.posx + ob.length;
        toy = ob.posy;
    }
    else if(ob.direction == 'L')
    {
        tox = ob.posx - ob.length;
        toy = ob.posy;
    }
/*    if(currentComponent->flags & (1 << DRAW_PINNUMBER))
        painter.drawText(QPoint(ob.posx - 10, ob.posy - 10), QString::fromStdString(ob.num));
    if(currentComponent->flags & (1 << DRAW_PINNAME))
        painter.drawText(QPoint(ob.posx - 10, ob.posy + 10), QString::fromStdString(ob.name));
*/
    painter.drawLine(ob.posx, ob.posy, tox, toy);

    dotPen.setColor(p_color);
    dotPen.setWidth(2);
    painter.setPen(dotPen);
    painter.drawEllipse(QPoint(ob.posx, ob.posy), 10, 10);
}