Esempio n. 1
0
void MultiLayer::setFonts(const QFont &titleFnt, const QFont &scaleFnt,
                          const QFont &numbersFnt, const QFont &legendFnt) {
  for (int i = 0; i < (int)graphsList.count(); i++) {
    Graph *gr = (Graph *)graphsList.at(i);
    QwtPlot *plot = gr->plotWidget();

    QwtText text = plot->title();
    text.setFont(titleFnt);
    plot->setTitle(text);
    for (int j = 0; j < QwtPlot::axisCnt; j++) {
      plot->setAxisFont(j, numbersFnt);

      text = plot->axisTitle(j);
      text.setFont(scaleFnt);
      plot->setAxisTitle(j, text);
    }

    QVector<int> keys = gr->textMarkerKeys();
    for (int k = 0; k < (int)keys.size(); k++) {
      Legend *mrk = (Legend *)gr->textMarker(keys[k]);
      if (mrk) mrk->setFont(legendFnt);
    }
    plot->replot();
  }
  emit modifiedPlot();
}
Esempio n. 2
0
  /**
   * Constructor, creates a new HistogramToolWindow
   * 
   * @param title 
   * @param parent 
   */
  HistogramToolWindow::HistogramToolWindow(QString title,QWidget *parent) : PlotWindow(title, parent) {
    p_plot->enableAxis(QwtPlot::yRight);
    QwtText *leftLabel = new QwtText("Frequency",
                                     QwtText::PlainText);

    leftLabel->setColor(Qt::darkCyan);
    QFont font = leftLabel->font();
    font.setPointSize(13);
    font.setBold(true);
    leftLabel->setFont(font);
    p_plot->setAxisTitle(QwtPlot::yLeft, *leftLabel);

    p_dock = new QDockWidget("Histogram Info",this);
    p_dock->setAllowedAreas(Qt::AllDockWidgetAreas);
    p_dock->setFloating(false);
    p_dock->setObjectName("DockWidget");
    p_dock->setMinimumWidth(130);
    p_mainWindow->addDockWidget(Qt::LeftDockWidgetArea, p_dock, Qt::Vertical);

    QwtText *rtLabel = new QwtText("Percentage",
                                   QwtText::PlainText);
    rtLabel->setColor(Qt::red);
    font = rtLabel->font();
    font.setPointSize(13);
    font.setBold(true);
    rtLabel->setFont(font);
    p_plot->setAxisTitle(QwtPlot::yRight,*rtLabel);    

    setAxisLabel(QwtPlot::xBottom,"Pixel Value (DN)");

    setScale(QwtPlot::yRight,0,100);

    setPlotBackground(Qt::white);
  }
Esempio n. 3
0
//--------------------------------------------------------------------------------------------------
/// 
//--------------------------------------------------------------------------------------------------
void RiuPvtPlotWidget::setPlotDefaults(QwtPlot* plot)
{
    // Plot background and frame look
    QPalette newPalette(plot->palette());
    newPalette.setColor(QPalette::Background, Qt::white);
    plot->setPalette(newPalette);

    plot->setAutoFillBackground(true);
    plot->setCanvasBackground(Qt::white);

    QFrame* canvasFrame = dynamic_cast<QFrame*>(plot->canvas());
    if (canvasFrame)
    {
        canvasFrame->setFrameShape(QFrame::NoFrame);
    }

    // Grid
    {
        QwtPlotGrid* grid = new QwtPlotGrid;
        grid->attach(plot);
        QPen gridPen(Qt::SolidLine);
        gridPen.setColor(Qt::lightGray);
        grid->setPen(gridPen);
    }

    // Axis number font
    {
        QFont axisFont = plot->axisFont(QwtPlot::xBottom);
        axisFont.setPointSize(8);
        plot->setAxisFont(QwtPlot::xBottom, axisFont);
        plot->setAxisFont(QwtPlot::yLeft, axisFont);
    }

    // Axis title font
    {
        QwtText axisTitle = plot->axisTitle(QwtPlot::xBottom);
        QFont axisTitleFont = axisTitle.font();
        axisTitleFont.setPointSize(8);
        axisTitleFont.setBold(false);
        axisTitle.setFont(axisTitleFont);
        axisTitle.setRenderFlags(Qt::AlignRight);
        plot->setAxisTitle(QwtPlot::xBottom, axisTitle);
        plot->setAxisTitle(QwtPlot::yLeft, axisTitle);
    }

    // Title font
    {
        QwtText plotTitle = plot->title();
        QFont titleFont = plotTitle.font();
        titleFont.setPointSize(12);
        plotTitle.setFont(titleFont);
        plot->setTitle(plotTitle);
    }


    plot->setAxisMaxMinor(QwtPlot::xBottom, 2);
    plot->setAxisMaxMinor(QwtPlot::yLeft, 3);

    plot->plotLayout()->setAlignCanvasToScales(true);
}
Esempio n. 4
0
void CBioPlot::SetupPlot(const char * title)
{
	QwtText label;

	// start with a clean plot
	if (thePlot == NULL) delete thePlot;

	// create a new plot
	thePlot = new QwtPlot();

	// we do our own painting
	thePlot->setAutoReplot( false );

	// for faster painting, apparently
	thePlot->canvas()->setAttribute(Qt::WA_PaintOutsidePaintEvent, true);

	// plot can be rescaled
	thePlot->setSizePolicy( QSizePolicy::Expanding, QSizePolicy::Expanding );

	// plot background
	thePlot->setCanvasBackground(QColor(Qt::white));

	// font to use for axes etc
	thePlot->setAxisFont(  QwtPlot::yLeft,   axis_font );
	thePlot->setAxisFont(  QwtPlot::yRight,  axis_font );
	thePlot->setAxisFont(  QwtPlot::xBottom, axis_font );
	thePlot->setAxisFont(  QwtPlot::xTop,    axis_font );

	// x-axis label
	label = QString("t (s)");
	label.setFont( axis_font );
	thePlot->setAxisTitle( QwtPlot::xBottom, label );

	// y-axis label
	label = QString(title);
	label.setFont( axis_font );
	thePlot->setAxisTitle( QwtPlot::yLeft, label );

	// set the left margin
	thePlot->axisScaleDraw( QwtPlot::yLeft )->setMinimumExtent( MARGIN );

	// max 5 ticks on the vertical axis
	thePlot->setAxisMaxMajor( QwtPlot::yLeft,  5);
	thePlot->setAxisMaxMajor( QwtPlot::yRight, 5);

	// setup the scale of the time axis
	SetAxisScale();

	//// set autoscaling for the y-axis, but start at [-1,1]
	thePlot->setAxisScale    ( QwtPlot::yLeft, -1, 1 );
	thePlot->setAxisAutoScale( QwtPlot::yLeft );

	// plot everything we made so far
	thePlot->replot();
}
void ConfigStabilizationWidget::setupExpoPlot()
{
    ui->expoPlot->setMouseTracking(false);
    ui->expoPlot->setAxisScale(QwtPlot::xBottom, 0, 100, 25);

    QwtText title;
    title.setText(tr("Input %"));
    title.setFont(ui->expoPlot->axisFont(QwtPlot::xBottom));
    ui->expoPlot->setAxisTitle(QwtPlot::xBottom, title);
    ui->expoPlot->setAxisScale(QwtPlot::yLeft, 0, 100, 25);

    title.setText(tr("Output %"));
    title.setFont(ui->expoPlot->axisFont(QwtPlot::yLeft));
    ui->expoPlot->setAxisTitle(QwtPlot::yLeft, title);
    QwtPlotCanvas *plotCanvas = dynamic_cast<QwtPlotCanvas *>(ui->expoPlot->canvas());
    if (plotCanvas) {
        plotCanvas->setFrameStyle(QFrame::NoFrame);
    }
    ui->expoPlot->canvas()->setCursor(QCursor());

    m_plotGrid.setMajorPen(QColor(Qt::gray));
    m_plotGrid.setMinorPen(QColor(Qt::lightGray));
    m_plotGrid.enableXMin(false);
    m_plotGrid.enableYMin(false);
    m_plotGrid.attach(ui->expoPlot);

    m_expoPlotCurveRoll.setRenderHint(QwtPlotCurve::RenderAntialiased);
    QColor rollColor(Qt::red);
    rollColor.setAlpha(180);
    m_expoPlotCurveRoll.setPen(QPen(rollColor, 2));
    m_expoPlotCurveRoll.attach(ui->expoPlot);
    replotExpoRoll(ui->expoSpinnerRoll->value());
    m_expoPlotCurveRoll.show();

    QColor pitchColor(Qt::green);
    pitchColor.setAlpha(180);
    m_expoPlotCurvePitch.setRenderHint(QwtPlotCurve::RenderAntialiased);
    m_expoPlotCurvePitch.setPen(QPen(pitchColor, 2));
    m_expoPlotCurvePitch.attach(ui->expoPlot);
    replotExpoPitch(ui->expoSpinnerPitch->value());
    m_expoPlotCurvePitch.show();

    QColor yawColor(Qt::blue);
    yawColor.setAlpha(180);
    m_expoPlotCurveYaw.setRenderHint(QwtPlotCurve::RenderAntialiased);
    m_expoPlotCurveYaw.setPen(QPen(yawColor, 2));
    m_expoPlotCurveYaw.attach(ui->expoPlot);
    replotExpoYaw(ui->expoSpinnerYaw->value());
    m_expoPlotCurveYaw.show();
}
Esempio n. 6
0
        AllPlotZoneLabel(AllPlot *_parent, int _zone_number)
        {
            parent = _parent;
            zone_number = _zone_number;

            RideItem *rideItem = parent->rideItem;


            if (! rideItem)
                return;


            const Zones *zones       = rideItem->zones;
            int zone_range     = rideItem->zoneRange();

            // create new zone labels if we're shading
            if (parent->shadeZones() && (zone_range >= 0)) {
                QList <int> zone_lows = zones->getZoneLows(zone_range);
                QList <QString> zone_names = zones->getZoneNames(zone_range);
                int num_zones = zone_lows.size();
                assert(zone_names.size() == num_zones);
                if (zone_number < num_zones) {
                    watts =
                        (
                            (zone_number + 1 < num_zones) ?
                            0.5 * (zone_lows[zone_number] + zone_lows[zone_number + 1]) :
                            (
                                (zone_number > 0) ?
                                (1.5 * zone_lows[zone_number] - 0.5 * zone_lows[zone_number - 1]) :
                                2.0 * zone_lows[zone_number]
                            )
                        );

                    text = QwtText(zone_names[zone_number]);
                    if (_parent->referencePlot == NULL) {
                        text.setFont(QFont("Helvetica",24, QFont::Bold));
                    } else {
                        text.setFont(QFont("Helvetica",12, QFont::Bold));
                    }

                    QColor text_color = zoneColor(zone_number, num_zones);
                    text_color.setAlpha(64);
                    text.setColor(text_color);
                }
            }

            setZ(1.0 + zone_number / 100.0);
        }
Esempio n. 7
0
void PlotPropertiesGUI::labelsFontClicked()
{
    bool ok;
    QFont newFont = QFontDialog::getFont(&ok, plotter->axisTitle(QwtPlot::xBottom).font(),
                                         this, "TerraME Observer : Chart - Select Font");
    if ((ok) && (newFont != plotter->axisTitle(QwtPlot::xBottom).font()) )
    {
        QwtText text = plotter->axisTitle(QwtPlot::xBottom);
        text.setFont(newFont);
        plotter->setAxisTitle(QwtPlot::xBottom, text);

        text = plotter->axisTitle(QwtPlot::yLeft);
        text.setFont(newFont);
        plotter->setAxisTitle(QwtPlot::yLeft, text);
    }
}
Esempio n. 8
0
void QwtPicker::drawTracker(QPainter *painter) const
{
    const QRect textRect = trackerRect(painter->font());
    if ( !textRect.isEmpty() )
    {
        QwtText label = trackerText(d_data->trackerPosition);
        if ( !label.isEmpty() )
        {
            painter->save();

#if defined(Q_WS_MAC)
            // Antialiased fonts are broken on the Mac.
#if QT_VERSION >= 0x040000 
            painter->setRenderHint(QPainter::TextAntialiasing, false);
#else
            QFont fnt = label.usedFont(painter->font());
            fnt.setStyleStrategy(QFont::NoAntialias);
            label.setFont(fnt);
#endif
#endif
            label.draw(painter, textRect);

            painter->restore();
        }
    }
}
Esempio n. 9
0
/* ------- Шрифт ------- */
void ViewPlot::settingFont()
{
    bool bOk;
    QFont fnt = QFontDialog::getFont( &bOk, stngViewPlot->value("ViewPlot/GridFont", QFont("Arial")).value<QFont>() );

    if(bOk) {
        stngViewPlot->setValue( "ViewPlot/GridFont", fnt );
        // Оси
        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);
    }
    ui->qwtPlot_spectrogram->replot();
    plotSquare();
    QRect rectFrame ( ui->frame->geometry() );
    rectFrame.setX(rectFrame.x() + 1);
    ui->frame->setGeometry(rectFrame);
}
Esempio n. 10
0
void Spectrogram::createLabels()
{
	clearLabels();

	QwtValueList levels = contourLevels();
	const int numLevels = levels.size();
    for (int l = 0; l < numLevels; l++){
		PlotMarker *m = new PlotMarker(l, d_labels_angle);

		QwtText t = QwtText(QString::number(levels[l]));
		t.setColor(d_labels_color);
		t.setFont(d_labels_font);

		if (d_white_out_labels)
			t.setBackgroundBrush(QBrush(Qt::white));
        else
            t.setBackgroundBrush(QBrush(Qt::transparent));
		m->setLabel(t);

        int x_axis = xAxis();
        int y_axis = yAxis();
		m->setAxis(x_axis, y_axis);

        if (d_graph && d_show_labels)
			m->attach(d_graph);
		d_labels_list << m;
	}
}
Esempio n. 11
0
void SaxsviewImage::setAxisTitleFont(const QFont& font) {
  for (int i = QwtPlot::yLeft; i < QwtPlot::axisCnt; ++i) {
    QwtText t = axisTitle(i);
    t.setFont(font);
    setAxisTitle(i, t);
  }
}
void SweepInspector::loadSweep(int index) {
  //load in new sweep values from data
  if (data == NULL) return;
  if ( (index < 0)  || (index >= data->getNumSweeps())) return;

  //remove old data and get new
  if (d_curve) d_curve->attach(NULL);
  detachItems();
  fsweep sweep = data->getSweep(index);

  d_curve = new QwtPlotCurve( data->timestampFromIndex(index) ); //Qwt will delete() this when its done with it
  d_curve->setRenderHint( QwtPlotItem::RenderAntialiased );
  d_curve->setStyle( QwtPlotCurve::Lines );
  d_curve->setPen( QColor( Qt::yellow ), 2, Qt::SolidLine );
  d_curve->setSamples( sweep );
  d_curve->attach(this);

  QwtInterval frange = data->limits(FREQ);
  //setAxisScale(QwtPlot::xBottom, frange.minValue(), frange.maxValue(), (frange.maxValue() - frange.minValue())/ 5.0);
  //setAxisScale(QwtPlot::yLeft, -135, 20, 10.0);
  setTitle( QString("RF Sweep @ %1").arg(data->timestampFromIndex(index)) );
  //set maximum zoom out
  zoomer->setZoomBase(QRectF(QPointF(frange.minValue(), 40), QPointF(frange.maxValue(), -135)));
  zoomer->zoomBase();

  //find max, min, and average values and drop it on plot as well
  double max = sweep.first().y(), min = sweep.first().y(), avg=0;
  for(int i=0; i < sweep.size(); i++) {
    max = std::max(max, sweep.at(i).y());
    min = std::min(min, sweep.at(i).y());
    avg += sweep.at(i).y();
  } avg /= sweep.size();

  //add markers onto the plot
  QwtPlotMarker *one = new QwtPlotMarker(), *two = new QwtPlotMarker();
  one->attach(this); one->setAxes(QwtPlot::xTop, QwtPlot::yRight);
  two->attach(this); two->setAxes(QwtPlot::xTop, QwtPlot::yRight);

  QwtText tone = QwtText(QString("Max: %1 dBm\nMin: %2 dBm\nAvg: %3 dBm").arg(max).arg(min).arg(avg));
  tone.setFont( QFont( "Helvetica", 10, QFont::Bold ) );
  tone.setColor( Qt::green );
  tone.setRenderFlags(Qt::AlignTop | Qt::AlignLeft);

  one->setLabel(tone);
  one->setValue(0, 10);
  one->setLabelAlignment(Qt::AlignBottom | Qt::AlignRight);

  QwtText ttwo(data->plotText());
  ttwo.setFont( QFont( "Helvetica", 10, QFont::Bold ) );
  ttwo.setColor( Qt::white );
  ttwo.setRenderFlags(Qt::AlignBottom | Qt::AlignRight);

  two->setLabel(ttwo);
  two->setValue(10, 10);
  two->setLabelAlignment(Qt::AlignBottom | Qt::AlignLeft);

  replot();
  repaint();
}
Esempio n. 13
0
void Plot2D::topAxisFontSize(const unsigned axisFontSize)
{
  QwtText title = m_qwtPlot->axisTitle(QwtPlot::xTop);
  QFont font = title.font();
  font.setPointSize(axisFontSize);
  title.setFont(font);
  m_qwtPlot->setAxisTitle(QwtPlot::xTop, title);
}
Esempio n. 14
0
void Plot2D::titleFontSize(const unsigned titleFontSize)
{
  QwtText title = m_qwtPlot->title();
  QFont font = title.font();
  font.setPointSize(titleFontSize);
  title.setFont(font);
  m_qwtPlot->setTitle(title);
}
Esempio n. 15
0
WindowMain::WindowMain(QWidget *parent, Qt::WindowFlags flags)
	:QMainWindow(parent, flags)
{
	ui.setupUi(this);

	setWindowState(Qt::WindowMaximized);

	m_fileMenu = ui.menuBar->addMenu(QStringLiteral("文件"));
	QAction* webImportAct = m_fileMenu->addAction(QStringLiteral("从Html导入....."));
	connect(webImportAct, SIGNAL(triggered()), this, SLOT(slotImportFromHtml()));

	m_toolMenu = ui.menuBar->addMenu(QStringLiteral("工具"));
	QAction* viewSingleAct = m_toolMenu->addAction(QStringLiteral("单个号码通信视图"));
	connect(viewSingleAct, SIGNAL(triggered()), this, SLOT(slotViewSingle()));
	QAction* chartAct = m_toolMenu->addAction(QStringLiteral("数据列表"));
	connect(chartAct, SIGNAL(triggered()), this, SLOT(slotCallLogTable()));

	QMenu* helpMenu = ui.menuBar->addMenu(QStringLiteral("帮助"));
	QAction* abortAct = helpMenu->addAction(QStringLiteral("关于软件"));
	connect(abortAct, SIGNAL(triggered()), this, SLOT(slotAbout()));

	QwtText axisTitle;
	QFont axisTitleFont;
	axisTitleFont.setPixelSize(16);

	axisTitle.setText(QStringLiteral("通话时间(秒)"));
	axisTitle.setFont(axisTitleFont);
	m_timePlot = new CallLogPlot(ui.qwtPlot, this);
	m_timePlot->getPlot()->enableAxis(QwtPlot::xBottom, false);
	m_timePlot->getPlot()->setAxisTitle(QwtPlot::yLeft, axisTitle);

	axisTitle.setText(QStringLiteral("通话次数(次)"));
	axisTitle.setFont(axisTitleFont);
	m_countPlot = new CallLogPlot(ui.qwtPlot_2, this);
	m_countPlot->getPlot()->setAxisTitle(QwtPlot::yLeft, axisTitle);

	ui.dateEdit->setCalendarPopup(true);
	ui.dateEdit_2->setCalendarPopup(true);

	connect(ui.pushButton, SIGNAL(clicked()), this, SLOT(slotDateTimeChanged()));
	connect(ObjectRegister::instance(), SIGNAL(signalTrialTimeout()), this, SLOT(slotTrialTimeout()));
	connect(ObjectRegister::instance(), SIGNAL(signalSuccessRegister()), this, SLOT(slotSuccessRegister()));

	slotCallLogChanged();
}
Esempio n. 16
0
    PfPvPlotZoneLabel(PfPvPlot *_parent, int _zone_number)
    {
        parent = _parent;
        RideItem *rideItem = parent->rideItem;
        zone_number = _zone_number;

        // get zone data from ride or athlete ...
        const Zones *zones;
        int zone_range = -1;

        if (parent->context->isCompareIntervals) {

            zones = parent->context->athlete->zones();
            if (!zones) return;

            // use first compare interval date
            if (parent->context->compareIntervals.count())
                zone_range = zones->whichRange(parent->context->compareIntervals[0].data->startTime().date());

            // still not set 
            if (zone_range == -1)
                zone_range = zones->whichRange(QDate::currentDate());

        } else if (rideItem) {

            zones = rideItem->zones;
            zone_range = rideItem->zoneRange();

        } else {

            return; // nulls

        }

        setZ(1.0 + zone_number / 100.0);

        // create new zone labels if we're shading
        if (zone_range >= 0) {

            // retrieve zone setup
            QList <int> zone_lows = zones->getZoneLows(zone_range);
            QList <QString> zone_names = zones->getZoneNames(zone_range);
            int num_zones = zone_lows.size();
            if(zone_names.size() != num_zones) return;

            if (zone_number < num_zones) {

                watts = ((zone_number + 1 < num_zones) ?  0.5 * (zone_lows[zone_number] + zone_lows[zone_number + 1]) : ( (zone_number > 0) ?  (1.5 * zone_lows[zone_number] - 0.5 * zone_lows[zone_number - 1]) : 2.0 * zone_lows[zone_number]));

                text = QwtText(zone_names[zone_number]);
                text.setFont(QFont("Helvetica",24, QFont::Bold));
                QColor text_color = zoneColor(zone_number, num_zones);
                text_color.setAlpha(64);
                text.setColor(text_color);
            }
        }
    }
Esempio n. 17
0
//--------------------------------------------------------------------------------------------------
/// 
//--------------------------------------------------------------------------------------------------
void RiuSummaryQwtPlot::setDefaults()
{
    QPalette newPalette(palette());
    newPalette.setColor(QPalette::Background, Qt::white);
    setPalette(newPalette);

    setAutoFillBackground(true);
    setCanvasBackground(Qt::white);

    QFrame* canvasFrame = dynamic_cast<QFrame*>(canvas());
    if (canvasFrame)
    {
        canvasFrame->setFrameShape(QFrame::NoFrame);
    }

    canvas()->setMouseTracking(true);
    canvas()->installEventFilter(this);

    QPen gridPen(Qt::SolidLine);
    gridPen.setColor(Qt::lightGray);
    m_grid->setPen(gridPen);

    enableAxis(QwtPlot::xBottom, true);
    enableAxis(QwtPlot::yLeft, true);
    enableAxis(QwtPlot::xTop, false);
    enableAxis(QwtPlot::yRight, false);

    plotLayout()->setAlignCanvasToScales(true);

    useDateBasedTimeAxis();

    QFont xAxisFont = axisFont(QwtPlot::xBottom);
    xAxisFont.setPixelSize(11);
    setAxisFont(QwtPlot::xBottom, xAxisFont);
    setAxisMaxMinor(QwtPlot::xBottom, 2);

    QFont yAxisFont = axisFont(QwtPlot::yLeft);
    yAxisFont.setPixelSize(11);
    setAxisFont(QwtPlot::yLeft, yAxisFont);

    setAxisMaxMinor(QwtPlot::yLeft, 3);

    QwtText axisTitleY = axisTitle(QwtPlot::yLeft);
    QFont yAxisTitleFont = axisTitleY.font();
    yAxisTitleFont.setPixelSize(11);
    yAxisTitleFont.setBold(false);
    axisTitleY.setFont(yAxisTitleFont);
    axisTitleY.setRenderFlags(Qt::AlignRight);
    setAxisTitle(QwtPlot::yLeft, axisTitleY);


    QwtLegend* legend = new QwtLegend(this);
    // The legend will be deleted in the destructor of the plot or when 
    // another legend is inserted.
    this->insertLegend(legend, BottomLegend);
}
Esempio n. 18
0
QmitkHistogramWidget::QmitkHistogramWidget(QWidget * parent, bool showreport)
  : QDialog(parent)
{
  QBoxLayout *layout = new QVBoxLayout(this);

  //***histogram***

  QGroupBox *hgroupbox = new QGroupBox("", this);

  hgroupbox->setMinimumSize(900, 400);

  m_Plot = new QwtPlot(hgroupbox);
  m_Plot->setCanvasBackground(QColor(Qt::white));
  m_Plot->setTitle("Histogram");
  QwtText text = m_Plot->titleLabel()->text();
  text.setFont(QFont("Helvetica", 12, QFont::Normal));

  QwtPlotGrid *grid = new QwtPlotGrid;
  grid->enableXMin(true);
  grid->enableYMin(true);
  grid->setMajPen(QPen(Qt::black, 0, Qt::DotLine));
  grid->setMinPen(QPen(Qt::gray, 0 , Qt::DotLine));
  grid->attach(m_Plot);

  layout->addWidget(hgroupbox);

  layout->setSpacing(20);

  if (showreport == true)
  {
    //***report***
    QGroupBox *rgroupbox = new QGroupBox("", this);

    rgroupbox->setMinimumSize(900, 400);

    QLabel *label = new QLabel("Gray  Value  Analysis", rgroupbox);
    label->setAlignment(Qt::AlignHCenter);
    label->setFont(QFont("Helvetica", 14, QFont::Bold));

    m_Textedit = new QTextEdit(rgroupbox);
    m_Textedit->setFont(QFont("Helvetica", 12, QFont::Normal));
    m_Textedit->setReadOnly(true);

    layout->addWidget(rgroupbox);
  }

  m_Picker = new QwtPlotPicker(QwtPlot::xBottom, QwtPlot::yLeft,
    QwtPicker::PointSelection, 
    QwtPlotPicker::NoRubberBand, QwtPicker::AlwaysOn, 
    m_Plot->canvas());

  connect(m_Picker, SIGNAL(selected(const QwtDoublePoint &)),
    SLOT(OnSelect(const QwtDoublePoint &)));
}
Esempio n. 19
0
void PlotPropertiesGUI::titlesFontClicked()
{
    bool ok;
    QFont newFont = QFontDialog::getFont(&ok, plotter->title().font(),
                                         this, "TerraME Observer : Chart - Select Font");
    if ((ok) && (newFont != plotter->title().font()) )
    {
        QwtText text = plotter->title();
        text.setFont(newFont);
        plotter->setTitle(text);
    }
}
Esempio n. 20
0
void Spectrogram::setLabelsFont(const QFont& font)
{
	if (font == d_labels_font)
        return;

    d_labels_font = font;

    foreach(QwtPlotMarker *m, d_labels_list){
		QwtText t = m->label();
		t.setFont(font);
		m->setLabel(t);
	}
void QwtHistogram::loadLabels()
{
	clearLabels();

	int size = this->dataSize();
	if (!size)
		return;

	QwtPlot *d_plot = plot();
	if (!d_plot)
		return;

	int index = 0;
	for (int i = 0; i < size; i++){
		PlotMarker *m = new PlotMarker(index, d_labels_angle);

		QwtText t = QwtText(QString::number(y(i)));
		t.setColor(d_labels_color);
		t.setFont(d_labels_font);
		if (d_white_out_labels)
			t.setBackgroundBrush(QBrush(Qt::white));
		else
			t.setBackgroundBrush(QBrush(Qt::transparent));
		m->setLabel(t);

		int x_axis = xAxis();
		int y_axis = yAxis();
		m->setAxis(x_axis, y_axis);

		QSize size = t.textSize();
		int dx = int(d_labels_x_offset*0.01*size.height());
		int dy = -int((d_labels_y_offset*0.01 + 0.5)*size.height());
		int x2 = d_plot->transform(x_axis, x(index)) + dx;
		int y2 = d_plot->transform(y_axis, y(index)) + dy;
		switch(d_labels_align){
			case Qt::AlignLeft:
			break;
			case Qt::AlignHCenter:
				x2 -= size.width()/2;
			break;
			case Qt::AlignRight:
				x2 -= size.width();
			break;
		}
		m->setXValue(d_plot->invTransform(x_axis, x2));
		m->setYValue(d_plot->invTransform(y_axis, y2));
		m->attach(d_plot);
		d_labels_list << m;
		index++;
	}

	d_show_labels = true;
}
//! Initialize axes
void QwtPlot::initAxesData()
{
    int axisId;

    for( axisId = 0; axisId < axisCnt; axisId++)
        d_axisData[axisId] = new AxisData;

    d_axisData[yLeft]->scaleWidget = 
        new QwtScaleWidget(QwtScaleDraw::LeftScale, this);
    d_axisData[yRight]->scaleWidget = 
        new QwtScaleWidget(QwtScaleDraw::RightScale, this);
    d_axisData[xTop]->scaleWidget = 
        new QwtScaleWidget(QwtScaleDraw::TopScale, this);
    d_axisData[xBottom]->scaleWidget = 
        new QwtScaleWidget(QwtScaleDraw::BottomScale, this);


    QFont fscl(fontInfo().family(), 10);
    QFont fttl(fontInfo().family(), 12, QFont::Bold);

    for(axisId = 0; axisId < axisCnt; axisId++)
    {
        AxisData &d = *d_axisData[axisId];

        d.scaleWidget->setFont(fscl);
        d.scaleWidget->setMargin(2);

        QwtText text;
        text.setFont(fttl);
        d.scaleWidget->setTitle(text);

        d.doAutoScale = true;

        d.minValue = 0.0;
        d.maxValue = 1000.0;
        d.stepSize = 0.0;

        d.maxMinor = 5;
        d.maxMajor = 8;

        d.scaleEngine = new QwtLinearScaleEngine;

        d.scaleDiv.invalidate();
    }

    d_axisData[yLeft]->isEnabled = true;
    d_axisData[yRight]->isEnabled = false;
    d_axisData[xBottom]->isEnabled = true;
    d_axisData[xTop]->isEnabled = false;
}
Esempio n. 23
0
void caStripPlot::addText(double x, double y, char* text, QColor c, int fontsize)
{
    QwtPlotMarker *mY = new QwtPlotMarker();
    QwtText txt;
    txt.setText(text);
    txt.setFont(QFont("Helvetica",fontsize, QFont::Bold));
    txt.setColor(c);
    mY->setLabel(txt);
    mY->setLabelAlignment(Qt::AlignRight | Qt::AlignTop);
    mY->setXValue(x);
    mY->setYValue(y);
    mY->attach(this);
    replot();
}
Esempio n. 24
0
void Plot2D::setupUi(QWidget *widget)
{
  QSizePolicy sizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
  sizePolicy.setHorizontalStretch(20);
  sizePolicy.setVerticalStretch(20);
  sizePolicy.setHeightForWidth(widget->sizePolicy().hasHeightForWidth());
  widget->setSizePolicy(sizePolicy);

  m_vBoxLayout = new QVBoxLayout(widget);

  m_qwtPlot = new QwtPlot(this);

  QFont font;
  font.setPointSize(8);

  QwtText xAxis;
  xAxis.setFont(font);
  m_qwtPlot->setAxisTitle(QwtPlot::xBottom, xAxis);

  QwtText yAxis;
  yAxis.setFont(font);
  m_qwtPlot->setAxisTitle(QwtPlot::yLeft, yAxis);

}
Esempio n. 25
0
void VectorPlot::addHorizontalLine(double value, QString labelText)
{
	QPen pen(QColor(0, 0, 255));

	QwtPlotMarker* horizontalLineMarker = new QwtPlotMarker();
	horizontalLineMarker->setLineStyle(QwtPlotMarker::HLine);
	horizontalLineMarker->setLinePen(pen);
	horizontalLineMarker->setYValue(value);

	QwtText label;
	label.setText(labelText);
	QFont font = label.font();
	font.setPointSize(9);
	label.setFont(font);

	horizontalLineMarker->setLabel(label);
	horizontalLineMarker->setLabelAlignment(Qt::AlignTop | Qt::AlignLeft);

	horizontalLineMarker->attach(plot);
}
Esempio n. 26
0
OneCurvePlot::OneCurvePlot(QWidget* parent):
QwtPlot(parent),m_curve(NULL),m_xUnits("")
{
  QFont font = parent->font();
  setAxisFont(QwtPlot::xBottom, font);
  setAxisFont(QwtPlot::yLeft, font);
  QwtText dummyText;
  dummyText.setFont(font);
  setAxisTitle(xBottom,dummyText);
  canvas()->setCursor(Qt::ArrowCursor);
  setContextMenuPolicy(Qt::DefaultContextMenu);
  m_zoomer = new QwtPlotZoomer(QwtPlot::xBottom, QwtPlot::yLeft,
      QwtPicker::DragSelection | QwtPicker::CornerToCorner, QwtPicker::AlwaysOff, canvas());
  m_zoomer->setRubberBandPen(QPen(Qt::black));
  QList<QColor> colors;
  m_colors << Qt::red<< Qt::green  << Qt::blue << Qt::cyan << Qt::magenta << Qt::yellow << Qt::gray;
  m_colors << Qt::darkRed<< Qt::darkGreen  << Qt::darkBlue << Qt::darkCyan << Qt::darkMagenta << Qt::darkYellow << Qt::darkGray;
  m_colorIndex = 0;
  m_x0 = 0;
  m_y0 = 0;
}
Esempio n. 27
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();
}
Esempio n. 28
0
void WidgetMooPlot::varSelectionChanged()
{
    // getting variables names
    QString xVarName = _ui->comboAbscissa->itemData(_ui->comboAbscissa->currentIndex()).toString();
    QString yVarName = _ui->comboOrdinate->itemData(_ui->comboOrdinate->currentIndex()).toString();


    // updating short names
    QString shortXVarName = xVarName;


    QString shortYVarName = yVarName;




    QFont font;
    font.setPointSize(8);
    font.setBold(true);
    font.setStyleStrategy(QFont::PreferAntialias);

    QwtText xtitle;
    xtitle.setFont(font);
    xtitle.setText(shortXVarName);

    QwtText ytitle;
    ytitle.setFont(font);
    ytitle.setText(shortYVarName);

    _plot1->setAxisTitle(QwtPlot::yLeft,ytitle);
    _plot1->setAxisTitle(QwtPlot::xBottom,xtitle);

    VariableResult *XObjResult;
    VariableResult *YObjResult;
    VariableResult *XVarResult;
    VariableResult *YVarResult;
    int XType,YType; //0 = Obj, 1 = Var



    bool xfound = false;
    bool yfound = false;


    // looking in optObjectives
    VariableResult* XVar;
    XVar= _result->optObjectivesResults()->findItem(xVarName);
    if (XVar)
    {
        XObjResult = XVar;
        XType = 0;
        xfound = true;
    }
    else
    {
        //looking in optVariables
        XVar = _result->optVariablesResults()->findItem(xVarName);
        if(XVar)
        {
            XVarResult = XVar;
            XType = 1;
            xfound=true;
        }
    }

    VariableResult* YVar;
    YVar = _result->optObjectivesResults()->findItem(yVarName);
    if (YVar)
    {
        YObjResult = YVar;
        YType = 0;
        yfound = true;
    }
    else
    {
        //looking in optVariables
        YVar = _result->optVariablesResults()->findItem(yVarName);
        if(YVar)
        {
            YVarResult = YVar;
            YType = 1;
            yfound = true;
        }
    }


    // plot new variables
    if(xfound && yfound)
    {
        switch(XType)
        {
        case 0 :
            switch(YType)
            {
            case 0 :
                _plot1->setXYVar(XObjResult,YObjResult);
                break;

            case 1 :
                _plot1->setXYVar(XObjResult,YVarResult);
                break;
            }
            break;
        case 1 :
            switch(YType)
            {
            case 0 :
                _plot1->setXYVar(XVarResult,YObjResult);
                break;

            case 1 :
                _plot1->setXYVar(XVarResult,YVarResult);
                break;
            }
            break;
        }
    }
}
void QwtPlotPrintFilter::reset(QwtPlotItem *item) const
{
    if ( d_data->cache == 0 )
        return;

    const PrivateData::Cache &cache = *d_data->cache;

    switch(item->rtti())
    {
        case QwtPlotItem::Rtti_PlotGrid:
        {
            QwtPlotGrid *grid = (QwtPlotGrid *)item;

            QPen pen = grid->majPen();
            pen.setColor(cache.gridColors[0]);
            grid->setMajPen(pen);

            pen = grid->minPen();
            pen.setColor(cache.gridColors[1]);
            grid->setMinPen(pen);

            break;
        }
        case QwtPlotItem::Rtti_PlotCurve:
        {
            QwtPlotCurve *c = (QwtPlotCurve *)item;

            QwtSymbol symbol = c->symbol();

            if ( cache.curveSymbolPenColors.contains(c) )
            {
                symbol.setPen(cache.curveSymbolPenColors[c]);
            }

            if ( cache.curveSymbolBrushColors.contains(c) )
            {
                QBrush brush = symbol.brush();
                brush.setColor(cache.curveSymbolBrushColors[c]);
                symbol.setBrush(brush);
            }
            c->setSymbol(symbol);

            if ( cache.curveColors.contains(c) )
            {
                QPen pen = c->pen();
                pen.setColor(cache.curveColors[c]);
                c->setPen(pen);
            }

            break;
        }
        case QwtPlotItem::Rtti_PlotMarker:
        {
            QwtPlotMarker *m = (QwtPlotMarker *)item;

            if ( cache.markerFonts.contains(m) )
            {
                QwtText label = m->label();
                label.setFont(cache.markerFonts[m]);
                m->setLabel(label);
            }

            if ( cache.markerLabelColors.contains(m) )
            {
                QwtText label = m->label();
                label.setColor(cache.markerLabelColors[m]);
                m->setLabel(label);
            }

            if ( cache.markerLineColors.contains(m) )
            {
                QPen pen = m->linePen();
                pen.setColor(cache.markerLineColors[m]);
                m->setLinePen(pen);
            }
            
            QwtSymbol symbol = m->symbol();

            if ( cache.markerSymbolPenColors.contains(m) )
            {
                QPen pen = symbol.pen();
                pen.setColor(cache.markerSymbolPenColors[m]);
                symbol.setPen(pen);
            }

            if ( cache.markerSymbolBrushColors.contains(m) )
            {
                QBrush brush = symbol.brush();
                brush.setColor(cache.markerSymbolBrushColors[m]);
                symbol.setBrush(brush);
            }

            m->setSymbol(symbol);

            break;
        }
        default:
            break;
    }
}
Esempio n. 30
0
void QgsHistogramWidget::drawHistogram()
{
  // clear plot
  mpPlot->detachItems();

  //ensure all children get removed
  mpPlot->setAutoDelete( true );
  // Set axis titles
  if ( !mXAxisTitle.isEmpty() )
    mpPlot->setAxisTitle( QwtPlot::xBottom, mXAxisTitle );
  if ( !mYAxisTitle.isEmpty() )
    mpPlot->setAxisTitle( QwtPlot::yLeft, mYAxisTitle );
  mpPlot->setAxisFont( QwtPlot::xBottom, this->font() );
  mpPlot->setAxisFont( QwtPlot::yLeft, this->font() );
  QFont titleFont = this->font();
  titleFont.setBold( true );
  QwtText xAxisText = mpPlot->axisTitle( QwtPlot::xBottom );
  xAxisText.setFont( titleFont );
  mpPlot->setAxisTitle( QwtPlot::xBottom, xAxisText );
  QwtText yAxisText = mpPlot->axisTitle( QwtPlot::yLeft );
  yAxisText.setFont( titleFont );
  mpPlot->setAxisTitle( QwtPlot::yLeft, yAxisText );
  mpPlot->setAxisAutoScale( QwtPlot::yLeft );
  mpPlot->setAxisAutoScale( QwtPlot::xBottom );

  // add a grid
  QwtPlotGrid *grid = new QwtPlotGrid();
  grid->enableX( false );
  grid->setPen( mGridPen );
  grid->attach( mpPlot );

  // make colors list
  mHistoColors.clear();
  Q_FOREACH ( const QgsRendererRange &range, mRanges )
  {
    mHistoColors << ( range.symbol() ? range.symbol()->color() : Qt::black );
  }

  //draw histogram
  QwtPlotHistogram *plotHistogram = nullptr;
  plotHistogram = createPlotHistogram( !mRanges.isEmpty() ? mRanges.at( 0 ).label() : QString(),
                                       !mRanges.isEmpty() ? QBrush( mHistoColors.at( 0 ) ) : mBrush,
                                       !mRanges.isEmpty() ? Qt::NoPen : mPen );
  QVector<QwtIntervalSample> dataHisto;

  int bins = mBinsSpinBox->value();
  QList<double> edges = mHistogram.binEdges( bins );
  QList<int> counts = mHistogram.counts( bins );

  int rangeIndex = 0;
  int lastValue = 0;

  for ( int bin = 0; bin < bins; ++bin )
  {
    int binValue = counts.at( bin );

    //current bin crosses two graduated ranges, so we split between
    //two histogram items
    if ( rangeIndex < mRanges.count() - 1 && edges.at( bin ) > mRanges.at( rangeIndex ).upperValue() )
    {
      rangeIndex++;
      plotHistogram->setSamples( dataHisto );
      plotHistogram->attach( mpPlot );
      plotHistogram = createPlotHistogram( mRanges.at( rangeIndex ).label(), mHistoColors.at( rangeIndex ) );
      dataHisto.clear();
      dataHisto << QwtIntervalSample( lastValue, mRanges.at( rangeIndex - 1 ).upperValue(), edges.at( bin ) );
    }

    double upperEdge = !mRanges.isEmpty() ? qMin( edges.at( bin + 1 ), mRanges.at( rangeIndex ).upperValue() )
                       : edges.at( bin + 1 );

    dataHisto << QwtIntervalSample( binValue, edges.at( bin ), upperEdge );

    lastValue = binValue;
  }

  plotHistogram->setSamples( dataHisto );
  plotHistogram->attach( mpPlot );

  mRangeMarkers.clear();
  Q_FOREACH ( const QgsRendererRange &range, mRanges )
  {
    QwtPlotMarker *rangeMarker = new QwtPlotMarker();
    rangeMarker->attach( mpPlot );
    rangeMarker->setLineStyle( QwtPlotMarker::VLine );
    rangeMarker->setXValue( range.upperValue() );
    rangeMarker->setLabel( QString::number( range.upperValue() ) );
    rangeMarker->setLabelOrientation( Qt::Vertical );
    rangeMarker->setLabelAlignment( Qt::AlignLeft | Qt::AlignTop );
    rangeMarker->show();
    mRangeMarkers << rangeMarker;
  }