Example #1
0
/*
QPair<int, int> ClassItem::ganttIndex() const
{
	int class_ix = startSlotItem()->classItemIndex(this);
	int slot_ix = ganttItem()->startSlotItemIndex(startSlotItem());
	return QPair<int, int>(slot_ix, class_ix);
}
*/
void ClassItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
{
	QColor c_runner = color();
	QColor c_free = c_runner;
	c_free.setAlpha(64);
	auto r = rect();
	QRectF r1 = r;
	r1.setWidth(minToPx(1));
	r1.setHeight(r.height() / 8);
	painter->save();
	painter->fillRect(r, c_free);
	auto dt = data();
	int interval = dt.startIntervalMin();
	for (int i = 0; i < runsAndVacantCount(); ++i) {
		r1.moveLeft(minToPx(i * interval));
		//QColor c = (i == 0)? c_first: c_runner;
		painter->fillRect(r1, c_runner);
		painter->drawRect(r1);
	}
	if(isSelected()) {
		painter->save();
		qreal w = r.height() / 15;
		QPen p;
		p.setColor(QColor(Qt::blue).lighter());
		p.setWidthF(w);
		painter->setPen(p);
		w /= 2;
		QRectF r2 = r.adjusted(w, w, -w, -w);
		painter->drawRect(r2);
		painter->restore();
	}
	if(clashingClasses().count()) {
		painter->save();
		qreal w = r.height() / 15;
		QPen p;
		p.setColor(Qt::red);
		p.setWidthF(w);
		painter->setPen(p);
		w /= 2;
		QRectF r2 = r.adjusted(w, w, -w, -w);
		painter->drawRect(r2);
		painter->restore();
	}
	if(m_dropInsertsBefore.isValid()) {
		QColor c_insert = c_runner;
		//c_insert.setAlpha(128);
		QRectF r2 = r;
		r2.setWidth(minToPx(2));
		if(!m_dropInsertsBefore.toBool()) {
			r2.moveLeft(r.width() - r2.width());
		}
		painter->fillRect(r2, c_insert);
		QPen p;
		p.setColor(color());
		painter->setPen(p);
		painter->drawRect(r2);
	}
	painter->restore();
	Super::paint(painter, option, widget);
}
SpeedPlotView::SpeedPlotView(QWidget *parent)
    : QGraphicsView(parent)
    , m_viewablePointsCount(MIN5_SEC)
    , m_maxCapacity(HOUR6_SEC)
{
    QPen greenPen;
    greenPen.setWidthF(1.5);
    greenPen.setColor(QColor(134, 196, 63));
    QPen bluePen;
    bluePen.setWidthF(1.5);
    bluePen.setColor(QColor(50, 153, 255));

    m_properties[UP] = GraphProperties(tr("Total Upload"), bluePen);
    m_properties[DOWN] = GraphProperties(tr("Total Download"), greenPen);

    bluePen.setStyle(Qt::DashLine);
    greenPen.setStyle(Qt::DashLine);
    m_properties[PAYLOAD_UP] = GraphProperties(tr("Payload Upload"), bluePen);
    m_properties[PAYLOAD_DOWN] = GraphProperties(tr("Payload Download"), greenPen);

    bluePen.setStyle(Qt::DashDotLine);
    greenPen.setStyle(Qt::DashDotLine);
    m_properties[OVERHEAD_UP] = GraphProperties(tr("Overhead Upload"), bluePen);
    m_properties[OVERHEAD_DOWN] = GraphProperties(tr("Overhead Download"), greenPen);

    bluePen.setStyle(Qt::DashDotDotLine);
    greenPen.setStyle(Qt::DashDotDotLine);
    m_properties[DHT_UP] = GraphProperties(tr("DHT Upload"), bluePen);
    m_properties[DHT_DOWN] = GraphProperties(tr("DHT Download"), greenPen);

    bluePen.setStyle(Qt::DotLine);
    greenPen.setStyle(Qt::DotLine);
    m_properties[TRACKER_UP] = GraphProperties(tr("Tracker Upload"), bluePen);
    m_properties[TRACKER_DOWN] = GraphProperties(tr("Tracker Download"), greenPen);
}
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();
}
void QgsSimpleLineSymbolLayerV2::applyDataDefinedSymbology( QgsSymbolV2RenderContext& context, QPen& pen, QPen& selPen, double& offset )
{
  //data defined properties
  double scaledWidth = 0;
  if ( mStrokeWidthExpression )
  {
    scaledWidth = mStrokeWidthExpression->evaluate( const_cast<QgsFeature*>( context.feature() ) ).toDouble()
                  * QgsSymbolLayerV2Utils::lineWidthScaleFactor( context.renderContext(), mWidthUnit );
    pen.setWidthF( scaledWidth );
    selPen.setWidthF( scaledWidth );
  }
  else if ( context.renderHints() & QgsSymbolV2::DataDefinedSizeScale )
  {
    scaledWidth = mWidth * QgsSymbolLayerV2Utils::lineWidthScaleFactor( context.renderContext(), mWidthUnit );
    pen.setWidthF( scaledWidth );
    selPen.setWidthF( scaledWidth );
  }

  //color
  if ( mStrokeColorExpression )
  {
    pen.setColor( QgsSymbolLayerV2Utils::decodeColor( mStrokeColorExpression->evaluate( const_cast<QgsFeature*>( context.feature() ) ).toString() ) );
  }

  //offset
  offset = mOffset;
  if ( mLineOffsetExpression )
  {
    offset = mLineOffsetExpression->evaluate( const_cast<QgsFeature*>( context.feature() ) ).toDouble();
  }

  //dash dot vector
  if ( mDashPatternExpression )
  {
    QVector<qreal> dashVector;
    QStringList dashList = mDashPatternExpression->evaluate( const_cast<QgsFeature*>( context.feature() ) ).toString().split( ";" );
    QStringList::const_iterator dashIt = dashList.constBegin();
    for ( ; dashIt != dashList.constEnd(); ++dashIt )
    {
      dashVector.push_back( dashIt->toDouble() * QgsSymbolLayerV2Utils::lineWidthScaleFactor( context.renderContext(), mCustomDashPatternUnit ) / mPen.widthF() );
    }
    pen.setDashPattern( dashVector );
  }

  //join style
  if ( mJoinStyleExpression )
  {
    QString joinStyleString = mJoinStyleExpression->evaluate( const_cast<QgsFeature*>( context.feature() ) ).toString();
    pen.setJoinStyle( QgsSymbolLayerV2Utils::decodePenJoinStyle( joinStyleString ) );
  }

  //cap style
  if ( mCapStyleExpression )
  {
    QString capStyleString = mCapStyleExpression->evaluate( const_cast<QgsFeature*>( context.feature() ) ).toString();
    pen.setCapStyle( QgsSymbolLayerV2Utils::decodePenCapStyle( capStyleString ) );
  }
}
Example #5
0
/*!
	save preferences settings from the dialog to the outside world...
*/
void Preferences::savePrefs()
{
	QPen pen;

	map->setBackgroundBrush(ui.backgroundColour->currentColor());
	map->setGridTextBrush(ui.gridTextPenColour->currentColor());
	
	// careful to retain any other properties of these pens... just change colour
	pen = map->getGridPen();   pen.setColor(ui.gridPenColour->currentColor());   map->setGridPen(pen);
	pen = map->getOriginPen(); pen.setColor(ui.originPenColour->currentColor()); map->setOriginPen(pen);

	// change colour and line width (but not other properties) of these...
	pen = map->getTrackPen();   pen.setColor(ui.trackPenColour->currentColor());  pen.setWidthF(ui.trackLineWidth->value()); map->setTrackPen(pen);
	pen = map->getRoadPen();    pen.setColor(ui.roadPenColour->currentColor());   pen.setWidthF(ui.roadLineWidth->value());  map->setRoadPen(pen);
	
	map->setTrackScaling(ui.trackExaggerateSmall->isChecked() ? MapWidget::Scale_Exaggerated : MapWidget::Scale_WithView);
	map->setRoadScaling(ui.roadExaggerateSmall->isChecked() ? MapWidget::Scale_Exaggerated : MapWidget::Scale_WithView);

	map->setGridTextFont(gridFont);
	map->setTextFont(textFont);

	//TODO: CHeck the path is OK before committing
	if (ui.pathSerzAutolocate->isChecked())
	{
		import->setSerzAuto(true);
	}
	else
	{
		import->setSerzAuto(false);
		import->setSerzPath(ui.pathSerz->text());
	}

	import->setTempPath(ui.pathTempFolder->text());

	// these two bools should always be opposite, so if the same a change needs to be made.
	if (ui.pathRailworksRoutesAutolocate->isChecked() && locater->isRoutefolderSpecified())
	{
		// the change is to use the default folders...
		locater->defaultRWLocations();
		locater->defaultRoutes();
	}
	else if (!ui.pathRailworksRoutesAutolocate->isChecked() && !locater->isRoutefolderSpecified())
	{
		// the change is to set a folder...
		locater->setSpecifiedRouteFolder(ui.pathRailworksRoutes->text());
	}
	// 
	map->showLoftEnds(ui.markLoftSegments->isChecked());
	map->setFastRender(ui.fastRendering->isChecked());
	//ui.reportRouteInconsistencies->isChecked()
	map->setWheelZoom(ui.reverseMousewheelZoom->isChecked() ? MapWidget::Zoom_InOut : MapWidget::Zoom_OutIn);

	QSettings settings;
	settings.setValue("logFile", ui.logFilename->text());
}
Example #6
0
void QgsDiagram::setPenWidth( QPen& pen, const QgsDiagramSettings& s, const QgsRenderContext& c )
{
  if ( s.sizeType == QgsDiagramSettings::MM )
  {
    pen.setWidthF( s.penWidth * c.scaleFactor() );
  }
  else
  {
    pen.setWidthF( s.penWidth / c.mapToPixel().mapUnitsPerPixel() );
  }
}
Example #7
0
/*!
  \brief Draw the grid

  The grid is drawn into the bounding rectangle such that
  gridlines begin and end at the rectangle's borders. The X and Y
  maps are used to map the scale divisions into the drawing region
  screen.
  \param painter  Painter
  \param mx X axis map
  \param my Y axis
  \param r Contents rect of the plot canvas
  */
void Grid::draw(QPainter *painter,
		const QwtScaleMap &mx, const QwtScaleMap &my,
		const QRect &r) const
{

	double x_factor = (double)painter->device()->logicalDpiX()/(double)plot()->logicalDpiX();
	double y_factor = (double)painter->device()->logicalDpiY()/(double)plot()->logicalDpiY();

	//  draw minor X gridlines
	QPen pen = minPen();
	pen.setWidthF(pen.widthF() * x_factor);
	painter->setPen(pen);

	if (xMinEnabled()){
		drawLines(painter, r, Qt::Vertical, mx,
				xScaleDiv().ticks(QwtScaleDiv::MinorTick));
		drawLines(painter, r, Qt::Vertical, mx,
				xScaleDiv().ticks(QwtScaleDiv::MediumTick));
	}

	//  draw minor Y gridlines
	pen = d_min_pen_y;
	pen.setWidthF(pen.widthF() * y_factor);
	painter->setPen(pen);

	if (yMinEnabled()){
		drawLines(painter, r, Qt::Horizontal, my,
				yScaleDiv().ticks(QwtScaleDiv::MinorTick));
		drawLines(painter, r, Qt::Horizontal, my,
				yScaleDiv().ticks(QwtScaleDiv::MediumTick));
	}

	//  draw major X gridlines
	pen = majPen();
	pen.setWidthF(pen.widthF() * x_factor);
	painter->setPen(pen);

	if (xEnabled()){
		drawLines(painter, r, Qt::Vertical, mx,
				xScaleDiv().ticks (QwtScaleDiv::MajorTick));
	}

	//  draw major Y gridlines
	pen = d_maj_pen_y;
	pen.setWidthF(pen.widthF() * y_factor);
	painter->setPen(pen);

	if (yEnabled()){
		drawLines(painter, r, Qt::Horizontal, my,
				yScaleDiv().ticks (QwtScaleDiv::MajorTick));
	}
}
bool OLSAdaptiveNodeExpandStatusVisualizer::tryPerformAdaptableVisualization(OLSOntologyGraphNodeItem *nodeToVisualize,
            OLSOntologyGraphNodeItem *nodeWithVisualizeInfo, QPainter *painter)
{
    if (nodeToVisualize == nullptr || painter == nullptr)
        return false;
    int plusSize = getParameterValueOrDefaultInt(m_plusSizeStr, nodeWithVisualizeInfo, m_plusSize);
    OLSAdaptiveNodeVisualizerMaster::stepOfAdaptableVisualization(m_textAreaVisualizers, nodeToVisualize, painter);
    if (nodeToVisualize->expandState() != ExpandState::NotExpandable) {
        QPainterPath path;
        QRectF rect = nodeToVisualize->rect();
        QPointF mid(rect.x() - rect.height() / 2, rect.y() + rect.height() / 2);
        if (nodeToVisualize->expandState() == ExpandState::NotExpanded) {
            path.moveTo(mid - QPointF(0, -plusSize));
            path.lineTo(mid - QPointF(0, plusSize));
        }
        path.moveTo(mid - QPointF(-plusSize, 0));
        path.lineTo(mid - QPointF(plusSize, 0));

        QPen pen;
        pen.setWidthF(2.0);
        QPen oldPen = painter->pen();
        painter->setPen(pen);
        painter->drawPath(path);
        painter->setPen(oldPen);
    }
    qDebug() << OLS_AVIS_NODE_EXPAND_STATUS__VISUALIZER_CLASS;
    return true;
}
Example #9
0
void REPainter::StrokeRect(const RERect& rc, float lineWidth)
{
    if(!_painter) return;
    QPen pen = _painter->pen();
    QBrush brush = _painter->brush();
    float oldLineWidth = pen.widthF();

    pen.setWidthF(lineWidth);
    _painter->setPen(pen);
    _painter->setBrush(Qt::NoBrush);
    _painter->drawRect(rc.ToQRectF());

    pen.setWidthF(oldLineWidth);
    _painter->setPen(pen);
    _painter->setBrush(brush);
}
void KoOdtFrameReportTextBox::createStyle(KoGenStyles *coll)
{
    QFont font = textBox()->textStyle().font;

    KoGenStyle ps(KoGenStyle::ParagraphStyle, "paragraph");
    m_paragraphStyleName = coll->insert(ps, "P");

    // text style
    KoGenStyle ts(KoGenStyle::TextStyle, "text");
    ts.addProperty("fo:font-family", font.family());
    ts.addPropertyPt("fo:font-size", font.pointSizeF());
    ts.addProperty("fo:font-weight", font.weight() * 10);
    ts.addProperty("fo:color", textBox()->textStyle().foregroundColor.name());
    QString fs;
    switch (font.style()) {
        case QFont::StyleNormal: fs = "normal"; break;
        case QFont::StyleItalic: fs = "italic"; break;
        case QFont::StyleOblique: fs = "oblique"; break;
    }
    ts.addProperty("fo:font-style", fs);
    m_textStyleName = coll->insert(ts, "T");

    KoGenStyle gs(KoGenStyle::GraphicStyle, "graphic");
    QPen pen;
    pen.setColor(textBox()->lineStyle().lineColor);
    pen.setWidthF(textBox()->lineStyle().weight);
    pen.setStyle(textBox()->lineStyle().style);
    KoOdfGraphicStyles::saveOdfStrokeStyle(gs, coll, pen);
    gs.addProperty("style:horizontal-pos", "from-left");
    gs.addProperty("style:horizontal-rel", "page");
    gs.addProperty("style:vertical-pos", "from-top");
    gs.addProperty("style:vertical-rel", "page");
    gs.addProperty("fo:background-color", textBox()->textStyle().backgroundColor.name());
    m_frameStyleName = coll->insert(gs, "F");
}
Example #11
0
void Radar::PrintPlanes(QPainter &painter)
{
    int row = 1;
    int col = 0;
    for (AConstIterator iter = Acs.begin(), end = Acs.end(); iter != end; iter ++)
    {
        qDebug("print");
        row = 1;
        col = (int)(iter.value().Heading / 11.25);

        if (iter.key() == selectedIcao)
        {
            QPen pen;
            pen.setColor(QColor(180, 200, 0));
            pen.setWidthF(2);
            painter.setBrush(QColor(0, 0, 0, 50));
            painter.setPen(pen);
            painter.setRenderHint(QPainter::Antialiasing, true);
            painter.drawEllipse(QPointF(iter.value().r_x, iter.value().r_y), 19, 19);
            painter.setRenderHint(QPainter::Antialiasing, false);
            row = 0;
        }


        painter.drawPixmap(iter.value().r_x - 17, iter.value().r_y - 17, icon_width, icon_height,
                               sprite,
                               col * icon_width, row * icon_height, icon_width, icon_height);
    }
}
Example #12
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 #13
0
void MainWindow::plot3(QCustomPlot *customPlot)
{
  QVector<double> x0(pts), y0(pts);

  update_w(w,1.0);
  double y_inc = 1.0; 
  for (int i=0; i<pts; ++i)   {
    x0[i] = (double)0.5*i/pts;
    y0[i] = y_inc*(w[i]);
  }

  customPlot->graph()->setData(x0, y0);
  customPlot->graph()->setLineStyle(QCPGraph::lsLine); 
  customPlot->graph()->setScatterStyle(QCPScatterStyle::ssNone); // (QCP::ScatterStyle)(rand()%9+1));
  QPen graphPen;
  graphPen.setColor(QColor(Qt::GlobalColor(5+graph_counter)));
  graphPen.setWidthF(2);
  customPlot->graph()->setPen(graphPen);
  customPlot->xAxis->setRange(0,0.5);
  customPlot->yAxis->setRange(-90,10);
  customPlot->legend->setVisible(true);
  //  customPlot->setInteraction(QCustomPlot::iSelectPlottables);
  customPlot->graph()->setName(QString(shape.c_str()));
  customPlot->replot();
}
Example #14
0
void GLEDrawingObject::setSimplePenProperties(QPen& pen) {
	QColor col;
	GLEDrawObject* obj = getGLEObject();
	GLEColor* color = obj->getProperties()->getColorProperty(GLEDOPropertyColor);
	col.setRgbF(color->getRed(), color->getGreen(), color->getBlue());
	pen.setColor(col);
	double lwidth = obj->getProperties()->getRealProperty(GLEDOPropertyLineWidth);
	pen.setWidthF(QGLE::relGLEToQt(lwidth, dpi));
	GLEString* lstyle = obj->getProperties()->getStringProperty(GLEDOPropertyLineStyle);
	if (lstyle->length() == 1 && lstyle->get(0) > (unsigned int)'1') {
		QVector<qreal> dashes;
		const char *defline[] = {"","","12","41","14","92","1282","9229","4114","54","73","7337","6261","2514"};
		const char *myline = defline[lstyle->get(0)-'0'];
		int len = strlen(myline);
		for (int i = 0; i < len; i++) {
			double value = (myline[i]-'0');
			dashes.append((qreal)QGLE::relGLEToQt(value*0.04, dpi));
		}
		pen.setDashPattern(dashes);
	} else if (lstyle->length() > 1) {
		QVector<qreal> dashes;
		for (unsigned int i = 0; i < lstyle->length(); i++) {
			double value = (lstyle->get(i)-'0');
			dashes.append((qreal)QGLE::relGLEToQt(value*0.04, dpi));
		}
		pen.setDashPattern(dashes);
	}
}
Example #15
0
void QPaintEnginePrivate::drawBoxTextItem(const QPointF &p, const QTextItemInt &ti)
{
    if (!ti.glyphs.numGlyphs)
        return;

    // any fixes here should probably also be done in QFontEngineBox::draw
    const int size = qRound(ti.fontEngine->ascent());
    QVarLengthArray<QFixedPoint> positions;
    QVarLengthArray<glyph_t> glyphs;
    QTransform matrix = QTransform::fromTranslate(p.x(), p.y() - size);
    ti.fontEngine->getGlyphPositions(ti.glyphs, matrix, ti.flags, glyphs, positions);
    if (glyphs.size() == 0)
        return;

    QSize s(size - 3, size - 3);

    QPainter *painter = q_func()->state->painter();
    painter->save();
    painter->setBrush(Qt::NoBrush);
    QPen pen = painter->pen();
    pen.setWidthF(ti.fontEngine->lineThickness().toReal());
    painter->setPen(pen);
    for (int k = 0; k < positions.size(); k++)
        painter->drawRect(QRectF(positions[k].toPointF(), s));
    painter->restore();
}
/**
	Dessine la borne
	@param p QPainter a utiliser pour rendre le dessin
	@param options Options pour affiner le rendu
	@param widget Widget sur lequel le rendu est effectue
*/
void PartTerminal::paint(QPainter *p, const QStyleOptionGraphicsItem *options, QWidget *widget) {
	Q_UNUSED(widget);
	p -> save();
	
	// annulation des renderhints
	p -> setRenderHint(QPainter::Antialiasing,          false);
	p -> setRenderHint(QPainter::TextAntialiasing,      false);
	p -> setRenderHint(QPainter::SmoothPixmapTransform, false);
	
	QPen t;
	t.setWidthF(1.0);
	t.setCosmetic(options && options -> levelOfDetail < 1.0);
	
	// dessin de la borne en rouge
	t.setColor(isSelected() ? Terminal::neutralColor : Qt::red);
	p -> setPen(t);
	p -> drawLine(QPointF(0.0, 0.0), second_point);
	
	// dessin du point d'amarrage au conducteur en bleu
	t.setColor(isSelected() ? Qt::red : Terminal::neutralColor);
	p -> setPen(t);
	p -> setBrush(Terminal::neutralColor);
	p -> drawPoint(QPointF(0.0, 0.0));
	p -> restore();

	if (m_hovered)
		drawShadowShape(p);
}
Example #17
0
void PlotCurve::setCurveWidth(qreal width)
{
  mWidth = width;
  QPen customPen = pen();
  customPen.setWidthF(mWidth);
  setPen(customPen);
}
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();
}
QSizeF QgsRasterSymbolLegendNode::drawSymbol( const QgsLegendSettings &settings, ItemContext *ctx, double itemHeight ) const
{
  if ( ctx && ctx->painter )
  {
    QColor itemColor = mColor;
    if ( QgsRasterLayer *rasterLayer = qobject_cast<QgsRasterLayer *>( layerNode()->layer() ) )
    {
      if ( QgsRasterRenderer *rasterRenderer = rasterLayer->renderer() )
        itemColor.setAlpha( rasterRenderer->opacity() * 255.0 );
    }
    ctx->painter->setBrush( itemColor );

    if ( settings.drawRasterStroke() )
    {
      QPen pen;
      pen.setColor( settings.rasterStrokeColor() );
      pen.setWidthF( settings.rasterStrokeWidth() );
      pen.setJoinStyle( Qt::MiterJoin );
      ctx->painter->setPen( pen );
    }
    else
    {
      ctx->painter->setPen( Qt::NoPen );
    }

    ctx->painter->drawRect( QRectF( ctx->point.x(), ctx->point.y() + ( itemHeight - settings.symbolSize().height() ) / 2,
                                    settings.symbolSize().width(), settings.symbolSize().height() ) );
  }
  return settings.symbolSize();
}
void AverageSceneItem::paintStimLine(QPainter *painter)
{
    if(m_lAverageData.size() == 0)
        return;

    //Plot averaged data
    QRectF boundingRect = this->boundingRect();
    QPainterPath path = QPainterPath(QPointF(boundingRect.x(), boundingRect.y() + boundingRect.height()/2));

    int dsFactor = 1;
    int totalCols =  m_lAverageData.first().second;
    totalCols / boundingRect.width()<1 ? dsFactor = 1 : dsFactor = totalCols / boundingRect.width();

    if(dsFactor == 0)
        dsFactor = 1;

    QPen pen;
    pen.setStyle(Qt::SolidLine);
    pen.setColor(Qt::red);
    pen.setWidthF(3);
    painter->setPen(pen);

    path.moveTo(boundingRect.x()+abs(m_firstLastSample.first)/dsFactor, boundingRect.y());
    path.lineTo(boundingRect.x()+abs(m_firstLastSample.first)/dsFactor, boundingRect.y()+boundingRect.height());

    path.moveTo(boundingRect.x(),boundingRect.y()+boundingRect.height()/2);
    path.lineTo(boundingRect.x()+m_lAverageData.first().second/dsFactor, boundingRect.y()+boundingRect.height()/2);

    painter->drawPath(path);
}
void ChanWidgetLED::paintEvent(QPaintEvent * /* event*/ )
{
    QPainter painter(this);
    initCoordinateSystem(painter);
    int h,s,v,a;
    QColor c,back = color();
    c=back;

    if (!m_checked || !isEnabled())
    {
        back.getHsv(&h,&s,&v,&a);
        s*=0.20;
        back.setHsv(h,s,v,a);
    }
    painter.setBrush(back);

    QPen pen;
    c.getHsv(&h,&s,&v,&a);
    s*=0.5;
    c.setHsv(h,s,v,a);

    pen.setColor(c);
    pen.setWidthF(3.0);

    painter.drawEllipse(-(size-size/10)/2,-(size-size/10)/2,(size-size/10),(size-size/10));
    painter.end();

    drawBackground(); // to maluje na tym co dotychczas to co jest w bitmapce
}
Example #22
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 AverageSceneItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
{
    Q_UNUSED(option);
    Q_UNUSED(widget);

    //set posistion
    this->setPos(75*m_qpChannelPosition.x(), -75*m_qpChannelPosition.y());

    painter->setRenderHint(QPainter::Antialiasing, true);

//    //Plot bounding rect / drawing region of this item
//    painter->drawRect(this->boundingRect());

    //Plot stim time
    painter->save();
    paintStimLine(painter);
    painter->restore();

    //Plot average data
    painter->save();
    paintAveragePath(painter);
    painter->restore();

    // Plot channel name
    QStaticText staticElectrodeName = QStaticText(m_sChannelName);
    QSizeF sizeText = staticElectrodeName.size();
    painter->save();
    QPen pen;
    pen.setColor(Qt::yellow);
    pen.setWidthF(5);
    painter->setPen(pen);
    painter->drawStaticText(boundingRect().x(), boundingRect().y(), staticElectrodeName);
    painter->restore();
}
void TransferFunctionEditorView::drawForeground(QPainter* painter, const QRectF& rect) {
    QPen pen;
    pen.setCosmetic(true);
    pen.setWidthF(1.5);
    pen.setColor(Qt::lightGray);
    painter->setPen(pen);

    QRectF sRect = sceneRect();

    if (maskHorizontal_.x > 0.0f) {
        double leftMaskBorder = maskHorizontal_.x * sRect.width();
        QRectF r(0.0, rect.top(), leftMaskBorder, rect.height());
        QLineF line(leftMaskBorder, rect.top(), leftMaskBorder, rect.bottom());
        painter->fillRect(r, QColor(25, 25, 25, 100));
        painter->drawLine(line);
    }

    if (maskHorizontal_.y < 1.0f) {
        double rightMaskBorder = maskHorizontal_.y * sRect.width();
        QRectF r(rightMaskBorder, rect.top(), sRect.right() - rightMaskBorder, rect.height());
        QLineF line(rightMaskBorder, rect.top(), rightMaskBorder, rect.bottom());
        painter->fillRect(r, QColor(25, 25, 25, 100));
        painter->drawLine(line);
    }

    QGraphicsView::drawForeground(painter, rect);
}
/**
 * @brief Diagram::Diagram
 * Constructor
 * @param project : The project of this diagram and also parent QObject
 */
Diagram::Diagram(QETProject *project) :
	QGraphicsScene           (project),
	project_                 (NULL),
	diagram_qet_version_     (-1),
	draw_grid_               (true),
	use_border_              (true),
	draw_terminals_          (true),
	draw_colored_conductors_ (true)
{
	setProject(project);
	qgi_manager_ = new QGIManager(this);
	setBackgroundBrush(Qt::white);
	conductor_setter_ = new QGraphicsLineItem(0, 0);
	conductor_setter_ -> setZValue(1000000);
	QPen t;
	t.setColor(Qt::black);
	t.setWidthF(1.5);
	t.setStyle(Qt::DashLine);
	conductor_setter_ -> setPen(t);
	conductor_setter_ -> setLine(QLineF(QPointF(0.0, 0.0), QPointF(0.0, 0.0)));
	
		//Init object for manage movement
	elements_mover_      = new ElementsMover();
	element_texts_mover_ = new ElementTextsMover();

	connect(&border_and_titleblock, SIGNAL(needTitleBlockTemplate(const QString &)), this, SLOT(setTitleBlockTemplate(const QString &)));
	connect(&border_and_titleblock, SIGNAL(diagramTitleChanged(const QString &)),    this, SLOT(titleChanged(const QString &)));
}
Example #26
0
OperatorItem::OperatorItem(OperatorModel* model, QGraphicsItem * parent)
  : QGraphicsObject(parent),
    m_model(model)
{
    QPainterPath path;
    path.addRoundedRect(QRectF(-SIZE/2, -SIZE/2, SIZE, SIZE), RADIUS, RADIUS);
    m_opRect = new QGraphicsPathItem(path, this);
    QPen pen = m_opRect->pen();
    pen.setWidthF(WIDTH);
    m_opRect->setPen(pen);
    m_opRect->setBrush(Qt::white);
    setPos(m_model->pos());
    
    m_label = new QGraphicsTextItem(this);
    m_label->setPlainText(QString::fromStdString(m_model->op()->name()));
    m_label->setPos(-m_label->boundingRect().width()/2, SIZE/2 + LABEL_OFFSET);
    
    setFlag(ItemIsMovable, true);
    setFlag(ItemIsSelectable, true);
    setFlag(ItemIsFocusable, true);
    setFlag(ItemSendsScenePositionChanges, true);
    
    setInitialized(model->isInitialized());
    
    connect(m_model, SIGNAL(nameChanged(QString)), this, SLOT(setName(QString)));
    connect(m_model, SIGNAL(initializedChanged(bool)), this, SLOT(setInitialized(bool)));
    connect(m_model, SIGNAL(posChanged(QPointF)), this, SLOT(setOperatorPos(QPointF)));
    connect(m_model, SIGNAL(connectorOccupiedChanged(OperatorModel::ConnectorType,uint,bool)),
            this, SLOT(setConnectorOccupied(OperatorModel::ConnectorType,uint,bool)));
    connect(m_model, SIGNAL(activeChanged(bool)), this, SLOT(resetAllConnectors()));
}
Example #27
0
/**
	Constructeur
	@param parent Le QObject parent du schema
*/
Diagram::Diagram(QObject *parent) :
	QGraphicsScene(parent),
	draw_grid_(true),
	use_border_(true),
	draw_terminals_(true),
	draw_colored_conductors_(true),
	project_(0),
	read_only_(false),
	diagram_qet_version_(-1)
{
	undo_stack_ = new QUndoStack();
	qgi_manager_ = new QGIManager(this);
	setBackgroundBrush(Qt::white);
	conductor_setter_ = new QGraphicsLineItem(0, 0);
	conductor_setter_ -> setZValue(1000000);
	QPen t;
	t.setColor(Qt::black);
	t.setWidthF(1.5);
	t.setStyle(Qt::DashLine);
	conductor_setter_ -> setPen(t);
	conductor_setter_ -> setLine(QLineF(QPointF(0.0, 0.0), QPointF(0.0, 0.0)));
	
	// initialise les objets gerant les deplacements
	elements_mover_ = new ElementsMover();           // deplacements d'elements/conducteurs/textes
	element_texts_mover_ = new ElementTextsMover();  // deplacements d'ElementTextItem
	
	connect(
		&border_and_titleblock, SIGNAL(needTitleBlockTemplate(const QString &)),
		this, SLOT(setTitleBlockTemplate(const QString &))
	);
	connect(
		&border_and_titleblock, SIGNAL(diagramTitleChanged(const QString &)),
		this, SLOT(titleChanged(const QString &))
	);
}
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 #29
0
/**
 * @brief widgetBarChart::drawYear draw a given year on a bar chart
 * @param sel the index of the selected year
 */
void widgetBarChart::drawYear(const int &sel) {
    QCPBars *bar = new QCPBars(ui->widgetBarChart_2->xAxis,ui->widgetBarChart_2->yAxis);
    bar->setName(_meas->yearRange().at(sel));
    bar->setWidth(BAR_WIDTH);
    QPen pen;
    bar->setBrush(COLOUR_LIST[sel%5]);
    pen.setWidthF(PEN_WIDTH);

    QVector<double> valueData, keyData;
    ui->widgetBarChart_2->addPlottable(bar);
    double i = 0.25 + 0.2*ui->widgetBarChart_2->xAxis->plottables().size();
    QList<QListWidgetItem*> tempList = ui->listBarChartMunicipality->selectedItems();
    for(QList<QListWidgetItem*>::Iterator it = tempList.begin(); it != tempList.end(); ++it) {
        QListWidgetItem *tempItem = *it;
        keyData << i;
        i+=1.5;
        try {
            valueData.append(_meas->findMuni(tempItem->text()).getYear(_meas->yearRange().at(sel)).value());
        } catch (std::string s) {
            valueData.append(0.0);
        }
    }
    bar->setData(keyData,valueData);
    bar->keyAxis()->setTickVector(keyData);
    ui->widgetBarChart_2->legend->setVisible(true);
    ui->widgetBarChart_2->replot();
}
Example #30
0
void MainWindow::plot2(QCustomPlot *customPlot)
{
  QVector<double> x0(pts), y0(pts);

  update_w(w,1.0);
  double y_inc = 1.0; 
  for (int i=0; i<pts; ++i)   {
    x0[i] = (double)0.5*i/pts;
    y0[i] = y_inc*(w[i]);
  }
  order = get_order();
  ui->order->setText(QApplication::translate("MainWindow", std::to_string(order).c_str(), 0));
  ui->ripple->setText(QApplication::translate("MainWindow", std::to_string(ripple()).c_str(), 0));
  ui->fc->setText(QApplication::translate("MainWindow", std::to_string(fc()).c_str(), 0));
  
  customPlot->graph()->setData(x0, y0);
  customPlot->graph()->setLineStyle(QCPGraph::lsLine); //(QCPGraph::LineStyle)(rand()%5+1));
  customPlot->graph()->setScatterStyle(QCPScatterStyle::ssNone); // (QCP::ScatterStyle)(rand()%9+1));
  QPen graphPen;
  //  graphPen.setColor(QColor(rand()%245+10, rand()%245+10, rand()%245+10));
  //graphPen.setWidthF(rand()/(double)RAND_MAX*2+1);

  graph_counter++;
  graph_counter = graph_counter%9;
  graphPen.setColor(QColor(Qt::GlobalColor(5+graph_counter)));
  graphPen.setWidthF(2);
  customPlot->graph()->setPen(graphPen);
  customPlot->xAxis->setRange(0,0.5);
  customPlot->yAxis->setRange(-90,10);
  customPlot->legend->setVisible(true);
  //  customPlot->setInteraction(QCustomPlot::iSelectPlottables);
  customPlot->graph()->setName(QString(shape.c_str()));
  customPlot->replot();
}