示例#1
0
 void setTag(const ItemTags::Tag &tag)
 {
     if ( isTagValid(tag) ) {
         QWidget tagWidget;
         initTagWidget(&tagWidget, tag, smallerFont(QFont()));
         m_pixmap = QPixmap(tagWidget.sizeHint());
         m_pixmap.fill(Qt::transparent);
         QPainter painter(&m_pixmap);
         tagWidget.render(&painter);
     } else {
         m_pixmap = QPixmap();
     }
 }
示例#2
0
CIncrementalPlot::CIncrementalPlot(const QColor& Back, const QColor& Front, const QColor& Grid, const QString& yAxis, EUnits eUnits, QWidget *parent)
:QWidget(parent)
{
	m_bReplotPending = false;
	m_iLimit = HR2S(1);

	m_pMainLayout = new QVBoxLayout();
	m_pMainLayout->setMargin(0);

	m_pChart = new QwtPlot();

	m_pMainLayout->addWidget(m_pChart);

	setLayout(m_pMainLayout);

	m_pChart->setStyleSheet(QString("color: rgb(%1, %2, %3); background-color: rgb(%4, %5, %6);")
		.arg(Front.red()).arg(Front.green()).arg(Front.blue())
		.arg(Back.red()).arg(Back.green()).arg(Back.blue()));

	QFont smallerFont(QApplication::font());
	m_pChart->setAxisScaleDraw(QwtPlot::xBottom, new CDateScale);
	switch(eUnits)
	{
	case eBytes: m_pChart->setAxisScaleDraw(QwtPlot::yLeft, new CRateScale);
	}
	m_pChart->setAxisFont(QwtPlot::yLeft,smallerFont);
	m_pChart->setAxisFont(QwtPlot::xBottom,smallerFont);

	m_pChart->plotLayout()->setAlignCanvasToScales(true);

	QwtLegendEx* pLegend = new QwtLegendEx;
	pLegend->setStyleSheet(QString("color: rgb(%1, %2, %3);")
		.arg(Front.red()).arg(Front.green()).arg(Front.blue()));
	m_pChart->insertLegend(pLegend, QwtPlot::BottomLegend);

	QwtPlotGrid *pGrid = new QwtPlotGrid;
	pGrid->setMajorPen(QPen(Grid,0,Qt::DotLine));
	pGrid->attach(m_pChart);

	QwtPlotPanner *pPanner = new QwtPlotPanner(m_pChart->canvas());
	pPanner->setAxisEnabled(QwtPlot::yRight,false);
	pPanner->setAxisEnabled(QwtPlot::xTop,false);
	pPanner->setMouseButton(Qt::MidButton);
	
	m_pChart->setAxisAutoScale(QwtPlot::yLeft);
	m_pChart->setAxisAutoScale(QwtPlot::xBottom);
	m_pChart->setAxisTitle(QwtPlot::yLeft,yAxis);
	//m_pChart->setAxisTitle(QwtPlot::xBottom,tr("Time"));
}