Esempio n. 1
0
void matrixofpixels::HistogramPlotProperty(double Xmin, double Xmax, double Ymax)
{
    changeitems();
    setAxisAutoScale(this->xTop);
    setAxisAutoScale(this->xBottom);
    //setAxisFont(QwtPlot::xBottom,QFont("Helvetica",15,1));
    QwtText xlabel("Value");
    QwtText ylabel("Events");
    QColor col(Qt::red);
    xlabel.setColor(col);
    ylabel.setColor(col);
    xlabel.setFont(QFont("Helvetica",15,1));
    ylabel.setFont(QFont("Helvetica",15,1));
    setAxisTitle(QwtPlot::xBottom,xlabel);
    setAxisTitle(QwtPlot::yLeft,ylabel);

    setCanvasBackground(QColor(Qt::white));
    setAxisScale(QwtPlot::xBottom, Xmin, Xmax);
    setAxisMaxMinor(QwtPlot::xBottom, 0);
    setAxisScale(QwtPlot::yLeft, 0, Ymax);
    setAxisMaxMinor(QwtPlot::yLeft, 0);
    plotLayout()->setAlignCanvasToScales(true);

    his->attach(this);

    /*QwtPlotGrid **/grid = new QwtPlotGrid;
    grid->setMajPen(QPen(Qt::gray, 0, Qt::DotLine));
    grid->attach(this);

    replot();
}
Esempio n. 2
0
void Plot::autoscale()
{
    canvas->setZoomBase();
    setAxisAutoScale(xBottom);
    setAxisAutoScale(yLeft);
    replot();
    setAxisAutoScale(xBottom, false);
    setAxisAutoScale(yLeft, false);
    emit zoomed();
}
Esempio n. 3
0
void QcepPlot::autoScale()
{
  setAxisAutoScale(QwtPlot::yLeft);
  setAxisAutoScale(QwtPlot::xBottom);

  m_Zoomer -> setZoomBase();

//
//  replot();
}
Esempio n. 4
0
void matrixofpixels::PixPlotSpect(int TypeOfSpec,QwtMatrixRasterData *rasterpixdata)
{
    changeitems();
    MapPlot->setData(rasterpixdata);
    MapPlot->setRenderThreadCount(0);
    setAxisAutoScale(this->xTop);
    setAxisAutoScale(this->xBottom);



    switch (TypeOfSpec)
    {
    case 1:
        MapPlot->setColorMap(new ColorMap(BLUERED));
        break;
    case 2:
        MapPlot->setColorMap(new ColorMap(BLACKWHITE));
        break;
    default:
        MapPlot->setColorMap(new ColorMap(BLUERED));
    }

    MapPlot->attach(/*MainPlot*/this);

    const QwtInterval zInterval = MapPlot->data()->interval(Qt::ZAxis);

    setAxisScale(QwtPlot::xBottom, 0, Npix);
    setAxisMaxMinor(QwtPlot::xBottom, 0);
    setAxisScale(QwtPlot::yLeft, 0, Npix);
    setAxisMaxMinor(QwtPlot::yLeft, 0);

    //rightAxis = new QwtScaleWidget();
    QwtScaleWidget *rightAxis = axisWidget(QwtPlot::yRight);

    //rightAxis = axisWidget(QwtPlot::yRight);
    rightAxis->setColorBarEnabled(true);
    rightAxis->setColorBarWidth(20);
    rightAxis->setColorMap(zInterval, new ColorMap(TypeOfSpec) );
    //ColorMap(TypeOfSpec);

    plotLayout()->setAlignCanvasToScales(true);

    setAxisScale(QwtPlot::yRight,zInterval.minValue(),zInterval.maxValue());
    enableAxis(QwtPlot::yRight);
    replot();
    setAutoFillBackground(true);

    /**
      setAutoFillBackground(true); - autozapolnenie, ctobi isklyuchit'
    nalozjeniya graphikov
    */

}
Esempio n. 5
0
Plot::Plot(QWidget* parent) :
    QwtPlot(parent),
    controlIsPressed(false),
    exportSize(100, 100),
    resolution(150),
    xBase(0, 1000, 100),
    yBase(0, 1000, 100)
{
    setAutoFillBackground( true );
    grid = new Grid(this);
    legend = new LegendItem(this);
    canvas = new Canvas(this);
    setAxisAutoScale(xBottom, false);
    setAxisAutoScale(yLeft, false);
    connect(canvas, SIGNAL(zoomed()), SIGNAL(zoomed()));
}
QwtPlotCurve * PlotViewWidget::addCurveData(WaveformData *curveData, bool secondary, QColor col)
{
    maWaveformData << curveData;

    QwtPlotCurve *waveCurve = new QwtPlotCurve("dummy");
    waveCurve->setRenderHint(QwtPlotItem::RenderAntialiased);
    waveCurve->setPen(QPen(col));
    waveCurve->setSamples( curveData );
    maCurves << waveCurve;
    waveCurve->attach(this);

    if( !mSecondaryAxis || maCurves.length() == 0 ) // no secondary axis or just one plot
    {
        replot();
        setAxisScaleDiv(QwtPlot::yRight, axisScaleDiv(QwtPlot::yLeft));
        replot();
    }
    else
    {
        if(secondary)
        {
            setAxisAutoScale(QwtPlot::yRight);
            waveCurve->setYAxis(QwtPlot::yRight);
        }
        else
        {
            waveCurve->setYAxis(QwtPlot::yLeft);
        }
    }

    repaint();
    return waveCurve;
}
Esempio n. 7
0
DataPlotFFT::DataPlotFFT(QWidget *parent):
    QwtPlot(parent),
    d_data(NULL),
    d_curve(NULL)
{
    setAutoReplot(false);

    setFrameStyle(QFrame::NoFrame);
    setLineWidth(0);
    setCanvasLineWidth(2);

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

    QwtPlotGrid *grid = new QwtPlotGrid;
    grid->setMajPen(QPen(Qt::gray, 0, Qt::DotLine));
    grid->attach(this);

    setCanvasBackground(Qt::white);
    //setCanvasBackground(QColor(29, 100, 141)); // nice blue

    //setAxisAutoScale(xBottom);
    //s/etAxisAutoScale(yLeft);

    setAxisScale(xBottom, 0.5, -0.5);
    setAxisScale(yLeft, -10.00, 10.00);
    setAxisAutoScale(yLeft);
    //setAxisAutoScale(xBottom);

    replot();
}
SweepInspector::SweepInspector(QWidget *parent) : QwtPlot(parent), data(NULL), d_curve(NULL), picker(NULL) {
  setObjectName( "SweepData" );
  setTitle( "RF Sweep" );
  setAxisTitle( QwtPlot::xBottom, "Frequency");
  setAxisTitle( QwtPlot::yLeft, QString( "Power Level (dBm)"));
  setAutoReplot(true);

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

  canvas = new QwtPlotCanvas();
  canvas->setPalette( Qt::black );
  canvas->setBorderRadius(0);
  setCanvas(canvas);

  //Allow zooming / panning
  zoomer = new QwtPlotZoomer( canvas );
  zoomer->setRubberBandPen( QColor( Qt::white ) );
  zoomer->setTrackerPen( QColor( Qt::white ) );
  connect(zoomer, SIGNAL(zoomed(const QRectF &)), this, SLOT(zoomed(const QRectF &)));

  panner = new QwtPlotPanner( canvas );
  panner->setMouseButton( Qt::MidButton );

  //Show the X/Y markers that follow the mouse
  picker = new QwtPlotPicker(QwtPlot::xBottom, QwtPlot::yLeft, QwtPlotPicker::CrossRubberBand, QwtPicker::AlwaysOn, canvas);
  picker->setStateMachine( new QwtPickerTrackerMachine() );
  picker->setRubberBandPen( QColor( Qt::cyan ) );
  picker->setTrackerPen( QColor( Qt::cyan ) );

  //FreqdBmPicker *er = new FreqdBmPicker(QwtPlot::xBottom, QwtPlot::yLeft, QwtPlotPicker::CrossRubberBand, QwtPicker::AlwaysOn, canvas);

  //Setup grid
  grid = new QwtPlotGrid();
  grid->enableXMin( true );
  grid->enableYMin( true );
  QColor color(Qt::gray); color.setAlpha(128);
  grid->setMajorPen( color, 1, Qt::DotLine );
  grid->setMinorPen( color, 1, Qt::DotLine );
  grid->attach( this );

  //format in kHz, MHz, GHz, not raw values
  setAxisScaleDraw(QwtPlot::xBottom, new FreqScaleDraw);
  setAxisAutoScale(QwtPlot::xBottom, true);
  //setAxisScale(QwtPlot::xBottom, 1, 4.4e9, 4.4e9 / 5.0);
  //setAxisScale(QwtPlot::yLeft, -135, 20, 20.0);

  setAxisScale(QwtPlot::yRight, 0, 10, 1);
  setAxisScale(QwtPlot::xTop, 0, 10, 1);
  
  repaint();
  replot();
}
Esempio n. 9
0
void ICResultChart::setOrientation(int orientation)
{
    QwtPlot::Axis axis1, axis2;

    if (orientation == 0) {
        axis1 = QwtPlot::xBottom;
        axis2 = QwtPlot::yLeft;

        d_barChartItem->setOrientation(Qt::Vertical);
    } else {
        axis1 = QwtPlot::yLeft;
        axis2 = QwtPlot::xBottom;

        d_barChartItem->setOrientation(Qt::Horizontal);
    }

    setAxisTitle(axis2, tr("Number"));
    setAxisTitle(axis1, tr("Answers"));

    setAxisScaleDraw(axis1, new ChoicesScaleDraw(result.keys()));
    setAxisScaleDraw(axis2, new QwtScaleDraw);

    int size = result.size()-1 <= 0 ? 0: result.size()-1;
    if (size == 0) {
        setAxisAutoScale(axis1);
    }
    else {
        setAxisScale(axis1, 0, size, 1.0);
    }

    int maxsize = 0;
    foreach (int size, result.values()) {
        if (maxsize < size) maxsize = size;
    }

    setAxisScale(axis2, 0, maxsize * 1.3);

    QwtScaleDraw *scaleDraw1 = axisScaleDraw(axis1);
    scaleDraw1->enableComponent(QwtScaleDraw::Backbone, false);
    scaleDraw1->enableComponent(QwtScaleDraw::Ticks, false);

    QwtScaleDraw *scaleDraw2 = axisScaleDraw(axis2);
    scaleDraw2->enableComponent(QwtScaleDraw::Backbone, false);
    scaleDraw2->enableComponent(QwtScaleDraw::Ticks, true);

    //plotLayout()->setAlignCanvasToScales( true );
    plotLayout()->setAlignCanvasToScale(axis1, true);
    plotLayout()->setAlignCanvasToScale(axis2, false);

    plotLayout()->setCanvasMargin(0);
    updateCanvasMargins();

    replot();
}
Esempio n. 10
0
EEGPlot::EEGPlot(int channelId, QWidget *parent, const QObject* sender,
				 const char* dataSignal, unsigned int numChannels)
	: QwtPlot(parent)
	, m_channelId(channelId)
	, m_firstPacket(true)
	, m_numChannels(numChannels)
{
	setAutoReplot(false);

	setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
	CENT::connect(sender, dataSignal, this, SLOT(dataReceived(CentData::AnalogData)));

	m_curve = new QwtPlotCurve("signal channel");
	m_curve->setStyle(QwtPlotCurve::Lines);
	m_curve->setPen(QPen(Qt::darkBlue));

	m_curve->setRenderHint(QwtPlotItem::RenderAntialiased, false);
	m_curve->setPaintAttribute(QwtPlotCurve::ClipPolygons, true);
	
	m_arraySeriesData = new ArraySeriesData();
	m_curve->setData(m_arraySeriesData);
	m_curve->attach(this);

	// Canvas
	setCanvasBackground(QBrush(Qt::white));

	// Axes
	enableAxis(QwtPlot::yLeft, true);
	setAxisTitle(QwtPlot::yLeft, Y_AXIS_TEXT);
	setAxisAutoScale(QwtPlot::yLeft, true);
	setAxisScaleDraw(QwtPlot::yLeft, new IntegerScaleDraw);


	setAxisAutoScale(QwtPlot::xBottom, false);
	QwtText xText(tr(X_AXIS_TEXT_LOC));
	setAxisTitle(QwtPlot::xBottom, xText);

	CENT::connect(&m_redrawTimer, SIGNAL(timeout()), this, SLOT(replotManual()));
	m_redrawTimer.setInterval(200);
	m_redrawTimer.start();
}
void PlotViewWidget::toggleCurveAxisAssociation(int index)
{
    if(index >= maCurves.length()) { return; }
    if(maCurves.at(index)->yAxis() == QwtPlot::yLeft)
    {
        setAxisAutoScale(QwtPlot::yRight);
        maCurves.at(index)->setYAxis(QwtPlot::yRight);
    }
    else
    {
        maCurves.at(index)->setYAxis(QwtPlot::yLeft);
    }
    replot();
}
Esempio n. 12
0
void Plot::setLogX(bool on){

    if(!on){

        setAxisScaleEngine( QwtPlot::xBottom, new QwtLinearScaleEngine );
        setAxisAutoScale(QwtPlot::xBottom);
    }
    else{

        setAxisScaleEngine( QwtPlot::xBottom, new QwtLogScaleEngine );
        setAxisScale(QwtPlot::xBottom,0.01,d_curve1->maxXValue()*2);


    }

}
Esempio n. 13
0
void Plot::setLogY(bool on){
/*
 * Amplification means voltage ratio V2 / V1 = Vout / Vin, and voltage gain in dB = 20 × log (V2 / V1).
 *
  */
    if(!on){

        setAxisScaleEngine( QwtPlot::yLeft, new QwtLinearScaleEngine );
        setAxisAutoScale(QwtPlot::yLeft);

    }
    else{

        setAxisScaleEngine( QwtPlot::yLeft, new QwtLogScaleEngine );
        setAxisScale(QwtPlot::yLeft,d_average->minYValue(),d_average->maxYValue()*2);
    }

}
Esempio n. 14
0
PlotWidget::PlotWidget(QWidget *parent) :
    QwtPlot(parent),
    ui(new Ui::PlotWidget)
{
    ui->setupUi(this);

    // Setup plot stuff
    setAutoReplot(false);
    canvas()->setBorderRadius( 10 );

    plotLayout()->setAlignCanvasToScales(true);

    QwtLegend *legend = new QwtLegend;
    legend->setItemMode(QwtLegend::CheckableItem);
    insertLegend(legend, QwtPlot::RightLegend);

    setAxisTitle(QwtPlot::xBottom, " Time [s]");
    setAxisScaleDraw(QwtPlot::xBottom,
                     new QwtScaleDraw());
    setAxisAutoScale(QwtPlot::xBottom, false);
    setAxisScale(QwtPlot::xBottom, 0, Market::EXPERIMENT_RUNNING_TIME);
    setAxisLabelRotation(QwtPlot::xBottom, -50.0);
    setAxisLabelAlignment(QwtPlot::xBottom, Qt::AlignLeft | Qt::AlignBottom);

    setAxisTitle(QwtPlot::yLeft, " Price [$]");
    setAxisScaleDraw(QwtPlot::yLeft,
                     new QwtScaleDraw());
    setAxisScale(QwtPlot::yLeft, 0, MAX_PRICE_PLOT);
    setAxisLabelRotation(QwtPlot::yLeft, -50.0);
    setAxisLabelAlignment(QwtPlot::yLeft, Qt::AlignLeft | Qt::AlignBottom);

    // Setup the data
    asset1Data = new CircularBuffer((Market::EXPERIMENT_RUNNING_TIME)/2 + 4); // Running time, /2 for data every 2 seconds, + a safety buffer
    asset2Data = new CircularBuffer((Market::EXPERIMENT_RUNNING_TIME)/2 + 4);
    timeData = new CircularBuffer((Market::EXPERIMENT_RUNNING_TIME)/2 + 4);

    asset1Curve = new QwtPlotCurve("Asset 1");
    asset1Curve->setPen(QPen(Qt::red));
    asset1Curve->attach(this);

    asset2Curve = new QwtPlotCurve("Asset 2");
    asset2Curve->setPen(QPen(Qt::blue));
    asset2Curve->attach(this);
}
Esempio n. 15
0
Plot::Plot( QWidget *parent ):
    QwtPlot( parent )
{
    setAutoReplot( false );

    setTitle( "Movable Items" );

    const int margin = 5;
    setContentsMargins( margin, margin, margin, margin );

    setAutoFillBackground( true );
    setPalette( QColor( "DimGray" ).lighter( 110 ) );

    QwtPlotCanvas *canvas = new QwtPlotCanvas();
#if 0
    // a gradient making a replot slow on X11
    canvas->setStyleSheet(
        "border: 2px solid Black;"
        "border-radius: 15px;"
        "background-color: qlineargradient( x1: 0, y1: 0, x2: 0, y2: 1,"
            "stop: 0 LemonChiffon, stop: 0.5 PaleGoldenrod, stop: 1 LemonChiffon );"
    );
#else
    canvas->setStyleSheet(
        "border: 2px inset DimGray;"
        "border-radius: 15px;"
        "background: LemonChiffon;"
    );
#endif

    setCanvas( canvas );
    insertLegend( new Legend(), QwtPlot::RightLegend );

    populate();

    updateAxes();
    for ( int axis = 0; axis < QwtPlot::axisCnt; axis++ )
        setAxisAutoScale( axis, false );

    d_editor = new Editor( this );
    ( void ) new QwtPlotMagnifier( canvas );
}
Esempio n. 16
0
void FFTWidget::init() {
	setTitle("FFT");
	hrBpm = 0;
	hrMarker = new QwtPlotMarker();
	hrMarker->setLineStyle(QwtPlotMarker::VLine);
	hrMarker->setLinePen(QPen(QColor(255,255,255,100), 2, Qt::SolidLine));

	QPen pen;
	pen.setWidth(2);
	pen.setColor(Qt::blue);
	QwtSymbol *symb = new QwtSymbol(QwtSymbol::Diamond);
	symb->setPen(pen);
	symb->setSize(10);

	hrMarker->setSymbol(symb);
	hrMarker->attach(this);
	hrMarker->setVisible(false);
	setAxisAutoScale(QwtPlot::yLeft, true);
	counter = 0;
	dX = QVector<double>(size, 0);
	dY = QVector<double>(size, 0);
	dYBuf = QVector<double>(size, 0);
	hamming = QVector<double>(size, 0);

	dataIn = QVector<double>(size, 0);
	sampleInterval = 1000/fS;
	p = fftw_plan_r2r_1d( size, dataIn.data(), dYBuf.data(), FFTW_DHT, FFTW_ESTIMATE );

	for(int i=0;i<size;i++) {
		dX.replace(i, i*(fS/size));
		double tmp = 0.54 - 0.46*(2*3.1415*i/size);
		hamming.replace(i, tmp);
	}

	pen.setColor(Qt::red);

	curve = new QwtPlotCurve();
	curve->setPen(pen);
	curve->setRawSamples(dX.data(), dY.data(), size/2);
	curve->setRenderHint(QwtPlotItem::RenderAntialiased);
	curve->attach(this);
}
Esempio n. 17
0
void BarChart::setOrientation( int orientation )
{
    QwtPlot::Axis axis1, axis2;

    if ( orientation == 0 )
    {
        axis1 = QwtPlot::xBottom;
        axis2 = QwtPlot::yLeft;

        d_barChartItem->setOrientation( Qt::Vertical );
    }
    else
    {
        axis1 = QwtPlot::yLeft;
        axis2 = QwtPlot::xBottom;

        d_barChartItem->setOrientation( Qt::Horizontal );
    }

    //设置坐标轴的min max和step
    setAxisScale( axis1, 0, d_barChartItem->dataSize() - 1, 1.0 );
    setAxisAutoScale( axis2 );

    QwtScaleDraw *scaleDraw1 = axisScaleDraw( axis1 );
    scaleDraw1->enableComponent( QwtScaleDraw::Backbone, false );
    scaleDraw1->enableComponent( QwtScaleDraw::Ticks, false );

    QwtScaleDraw *scaleDraw2 = axisScaleDraw( axis2 );
    scaleDraw2->enableComponent( QwtScaleDraw::Backbone, true );
    scaleDraw2->enableComponent( QwtScaleDraw::Ticks, true );

    plotLayout()->setAlignCanvasToScale( axis1, true );
    plotLayout()->setAlignCanvasToScale( axis2, false );

    plotLayout()->setCanvasMargin( 0 );
    updateCanvasMargins();

    replot();
}
Esempio n. 18
0
Plot::Plot(QWidget *parent):
  QwtPlot(parent),
  d_origin(0),
  d_grid(0),
  d_marker(0),
  mStopped(true),
  mAxisSyncRequired(false),
  mColorMode(0),
  mTimeWindow(10.0),
  mAlignMode(RIGHT)
{
  setAutoReplot(false);

  // The backing store is important, when working with widget
  // overlays ( f.e rubberbands for zooming ). 
  // Here we don't have them and the internal 
  // backing store of QWidget is good enough.

  QwtPlotCanvas* plotCanvas = qobject_cast<QwtPlotCanvas*>(canvas());

  plotCanvas->setPaintAttribute(QwtPlotCanvas::BackingStore, false);


#if defined(Q_WS_X11)
  // Even if not recommended by TrollTech, Qt::WA_PaintOutsidePaintEvent
  // works on X11. This has a nice effect on the performance.

  plotCanvas->setAttribute(Qt::WA_PaintOutsidePaintEvent, true);

  // Disabling the backing store of Qt improves the performance
  // for the direct painter even more, but the canvas becomes
  // a native window of the window system, receiving paint events
  // for resize and expose operations. Those might be expensive
  // when there are many points and the backing store of
  // the canvas is disabled. So in this application
  // we better don't both backing stores.

  if ( plotCanvas->testPaintAttribute( QwtPlotCanvas::BackingStore ) )
  {
    plotCanvas->setAttribute(Qt::WA_PaintOnScreen, true);
    plotCanvas->setAttribute(Qt::WA_NoSystemBackground, true);
  }

#endif



  plotLayout()->setAlignCanvasToScales(true);

  setAxisAutoScale(QwtPlot::xBottom, false);
  setAxisAutoScale(QwtPlot::yLeft, false);

  setAxisTitle(QwtPlot::xBottom, "Time [s]");
  setAxisScale(QwtPlot::xBottom, 0, 10);
  setAxisScale(QwtPlot::yLeft, -4.0, 4.0);

  setAxisScaleDraw(QwtPlot::xBottom, new MyScaleDraw);

  initBackground();

  QwtPlotZoomer* zoomer = new MyZoomer(this);
  zoomer->setMousePattern(QwtEventPattern::QwtEventPattern::MouseSelect1, Qt::LeftButton, Qt::ShiftModifier);

  // disable MouseSelect3 action of the zoomer
  zoomer->setMousePattern(QwtEventPattern::MouseSelect3, Qt::NoButton);

  MyPanner *panner = new MyPanner(this);

  // zoom in/out with the wheel
  mMagnifier = new MyMagnifier(this);
  mMagnifier->setMouseButton(Qt::MiddleButton);

  const QColor c(Qt::darkBlue);
  zoomer->setRubberBandPen(c);
  zoomer->setTrackerPen(c);

  this->setMinimumHeight(200);
}
Esempio n. 19
0
bool CopasiPlot::initFromSpec(const CPlotSpecification* plotspec)
{
  mIgnoreUpdate = true;
  mpPlotSpecification = plotspec;

  if (mpZoomer) mpZoomer->setEnabled(false);

  // size_t k, kmax = mpPlotSpecification->getItems().size();

  setTitle(FROM_UTF8(mpPlotSpecification->getTitle()));

  mCurves.resize(mpPlotSpecification->getItems().size());
  mCurves = NULL;

  std::map< std::string, C2DPlotCurve * >::iterator found;

  CCopasiVector< CPlotItem >::const_iterator itPlotItem = mpPlotSpecification->getItems().begin();
  CCopasiVector< CPlotItem >::const_iterator endPlotItem = mpPlotSpecification->getItems().end();

  CVector< bool > Visible(mpPlotSpecification->getItems().size());
  Visible = true;
  bool * pVisible = Visible.array();

  for (; itPlotItem != endPlotItem; ++itPlotItem, ++pVisible)
    {
      // Qwt does not like it to reuse the curve as this may lead to access
      // violation. We therefore delete the curves but remember their visibility.
      if ((found = mCurveMap.find((*itPlotItem)->CCopasiParameter::getKey())) != mCurveMap.end())
        {
          *pVisible = found->second->isVisible();
        }
    }

  // Remove unused curves if definition has changed
  std::map< std::string, C2DPlotCurve * >::iterator it = mCurveMap.begin();
  std::map< std::string, C2DPlotCurve * >::iterator end = mCurveMap.end();

  for (; it != end; ++it)
    pdelete(it->second);

  mCurveMap.clear();

  itPlotItem = mpPlotSpecification->getItems().begin();
  pVisible = Visible.array();
  C2DPlotCurve ** ppCurve = mCurves.array();
  unsigned long int k = 0;
  bool needLeft = false;
  bool needRight = false;

  for (; itPlotItem != endPlotItem; ++itPlotItem, ++pVisible, ++ppCurve, ++k)
    {
      // set up the curve
      C2DPlotCurve * pCurve = new C2DPlotCurve(&mMutex,
          (*itPlotItem)->getType(),
          (*itPlotItem)->getActivity(),
          FROM_UTF8((*itPlotItem)->getTitle()));
      *ppCurve = pCurve;

      mCurveMap[(*itPlotItem)->CCopasiParameter::getKey()] = pCurve;

      //color handling should be similar for different curve types
      QColor color;

      if (pCurve->getType() == CPlotItem::curve2d
          || pCurve->getType() == CPlotItem::histoItem1d
          || pCurve->getType() == CPlotItem::bandedGraph)
        {
          std::string colorstr = *(*itPlotItem)->getValue("Color").pSTRING;
          color = CQPlotColors::getColor(colorstr, k);
        }

      pCurve->setPen(color);
      pCurve->attach(this);

      showCurve(pCurve, *pVisible);

      if (pCurve->getType() == CPlotItem::curve2d
          || pCurve->getType() == CPlotItem::bandedGraph)
        {
          needLeft = true;
          pCurve->setRenderHint(QwtPlotItem::RenderAntialiased);

          unsigned C_INT32 linetype = *(*itPlotItem)->getValue("Line type").pUINT;

          if (linetype == 0      //line
              || linetype == 3)  //line+symbols
            {
              pCurve->setStyle(QwtPlotCurve::Lines);
              unsigned C_INT32 linesubtype = *(*itPlotItem)->getValue("Line subtype").pUINT;
              C_FLOAT64 width = *(*itPlotItem)->getValue("Line width").pUDOUBLE;

              switch (linesubtype) //symbol type
                {
                  case 1:
                    pCurve->setPen(QPen(QBrush(color), width, Qt::DotLine, Qt::FlatCap));
                    break;

                  case 2:
                    pCurve->setPen(QPen(QBrush(color), width, Qt::DashLine));
                    break;

                  case 3:
                    pCurve->setPen(QPen(QBrush(color), width, Qt::DashDotLine));
                    break;

                  case 4:
                    pCurve->setPen(QPen(QBrush(color), width, Qt::DashDotDotLine));
                    break;

                  case 0:
                  default:
                    pCurve->setPen(QPen(QBrush(color), width, Qt::SolidLine));
                    break;
                }
            }

          if (linetype == 1) //points
            {
              C_FLOAT64 width = *(*itPlotItem)->getValue("Line width").pUDOUBLE;
              pCurve->setPen(QPen(color, width, Qt::SolidLine, Qt::RoundCap));
              pCurve->setStyle(QwtPlotCurve::Dots);
            }

          if (linetype == 2) //only symbols
            {
              pCurve->setStyle(QwtPlotCurve::NoCurve);
            }

          if (linetype == 2      //symbols
              || linetype == 3)  //line+symbols
            {
              unsigned C_INT32 symbolsubtype = *(*itPlotItem)->getValue("Symbol subtype").pUINT;

              switch (symbolsubtype) //symbol type
                {
                  case 1:
                    pCurve->setSymbol(QwtSymbol(QwtSymbol::Cross, QBrush(), QPen(QBrush(color), 2), QSize(7, 7)));
                    break;

                  case 2:
                    pCurve->setSymbol(QwtSymbol(QwtSymbol::Ellipse, QBrush(), QPen(QBrush(color), 1), QSize(8, 8)));
                    break;

                  case 0:
                  default:
                    pCurve->setSymbol(QwtSymbol(QwtSymbol::Cross, QBrush(color), QPen(QBrush(color), 1), QSize(5, 5)));
                    break;
                }
            }
        } //2d curves and banded graphs

      if (pCurve->getType() == CPlotItem::bandedGraph)
        {
          //set fill color
          QColor c = color;
          c.setAlpha(64);
          pCurve->setBrush(c);
        }

      if (pCurve->getType() == CPlotItem::histoItem1d)
        {
          pCurve->setIncrement(*(*itPlotItem)->getValue("increment").pDOUBLE);

          pCurve->setStyle(QwtPlotCurve::Steps);
          pCurve->setYAxis(QwtPlot::yRight);
          pCurve->setCurveAttribute(QwtPlotCurve::Inverted);

          needRight = true;
        }
    }

  if (plotspec->isLogX())
    setAxisScaleEngine(xBottom, new QwtLog10ScaleEngine());
  else
    setAxisScaleEngine(xBottom, new QwtLinearScaleEngine());

  setAxisAutoScale(xBottom);

  if (plotspec->isLogY())
    setAxisScaleEngine(yLeft, new QwtLog10ScaleEngine());
  else
    setAxisScaleEngine(yLeft, new QwtLinearScaleEngine());

  setAxisAutoScale(yLeft);

  enableAxis(yLeft, needLeft);

  if (needRight)
    {
      setAxisScaleEngine(yRight, new QwtLinearScaleEngine());
      setAxisTitle(yRight, "Percent %");
      enableAxis(yRight);
    }

  mIgnoreUpdate = false;

  return true; //TODO really check!
}
Esempio n. 20
0
void ZoomPlot :: ZoomOut () {
/*	setAxisScale (xBottom, xmin, xmax);
	setAxisScale (yLeft, ymin, ymax);*/
	setAxisAutoScale (xBottom);setAxisAutoScale (yLeft);
	replot();
}
Esempio n. 21
0
void BarChart::setOrientation(const QStringList &NameList)
{
    QwtPlot::Axis axis1, axis2;

	axis1 = QwtPlot::xBottom;
	axis2 = QwtPlot::yLeft;

	d_barChartItem->setOrientation(Qt::Vertical);

    setAxisScale( axis1, 0, d_barChartItem->dataSize() - 1, 1.0 );
    setAxisAutoScale( axis2 );

    //QwtScaleDraw *scaleDraw1 = axisScaleDraw( axis1 );
    //scaleDraw1->enableComponent( QwtScaleDraw::Backbone, false );
    //scaleDraw1->enableComponent( QwtScaleDraw::Ticks, false );

    //QwtScaleDraw *scaleDraw2 = axisScaleDraw( axis2 );
    //scaleDraw2->enableComponent( QwtScaleDraw::Backbone, true );
    //scaleDraw2->enableComponent( QwtScaleDraw::Ticks, true );

    //plotLayout()->setAlignCanvasToScale( axis1, true );
    //plotLayout()->setAlignCanvasToScale( axis2, false );

	//const struct
	//{
	//	const char *distro;
	//	const int hits;
	//	QColor color;

	//} pageHits[] =
	//{
	//	{ "Arch", 1114, QColor("DodgerBlue") },
	//	{ "Debian", 1373, QColor("#d70751") },
	//	{ "Fedora", 1638, QColor("SteelBlue") },
	//	{ "Mageia", 1395, QColor("Indigo") },
	//	{ "Mint", 3874, QColor(183, 255, 183) },
	//	{ "openSuSE", 1532, QColor(115, 186, 37) },
	//	{ "Puppy", 1059, QColor("LightSkyBlue") },
	//	{ "Ubuntu", 2391, QColor("FireBrick") },
	//	{ "Arch", 1114, QColor("DodgerBlue") },
	//	{ "Debian", 1373, QColor("#d70751") },
	//	{ "Fedora", 1638, QColor("SteelBlue") },
	//	{ "Mageia", 1395, QColor("Indigo") },
	//	{ "Mint", 3874, QColor(183, 255, 183) },
	//	{ "openSuSE", 1532, QColor(115, 186, 37) },
	//	{ "Puppy", 1059, QColor("LightSkyBlue") },
	//	{ "Ubuntu", 2391, QColor("FireBrick") }
	//};

	//for (uint i = 0; i < sizeof(pageHits) / sizeof(pageHits[0]); i++)
	//{
	//	d_distros += pageHits[i].distro; 

	//	//d_barChartItem->addDistro(
	//	//	pageHits[i].distro, pageHits[i].color);
	//}

	//setAxisTitle(axis1, "Distros");
	//setAxisMaxMinor(axis1, 3);
	setAxisScaleDraw(axis1, new DistroScaleDraw(NameList));
 
    plotLayout()->setCanvasMargin( 0 );
    updateCanvasMargins();
}
Esempio n. 22
0
void CurveWidget::autoScale()
{
    setAxisAutoScale(QwtPlot::xBottom);
    setAxisAutoScale(QwtPlot::yLeft);
}