Plot2D::Plot2D(QWidget *parent) : QCustomPlot(parent), canvasBrush_(Qt::white) {
  setBackgroundColor(canvasBrush_);
  setAutoAddPlottableToLegend(false);
  setInteractions(QCP::iRangeDrag | QCP::iRangeZoom | QCP::iSelectAxes |
                  QCP::iSelectLegend | QCP::iSelectPlottables);
  plotLayout()->clear();
}
Exemple #2
0
PlotterWidget::PlotterWidget(QWidget *parent): QCustomPlot(parent), m_main_scale(0), m_plots_container(0)
{
    //clear the layout
    plotLayout()->clear(); //clear all

    /// a main scale object at LEFT
    m_main_scale = new  MainScale(this);
    plotLayout()->addElement(0,0,m_main_scale);

    /// an area with plots at RIGHT
    m_plots_container = new PlotsContainer();
    plotLayout()->addElement(0,1, m_plots_container);

    /// a group for aligning graphs
    m_group = new QCPMarginGroup(this);
    getMainAxisRect()->setMarginGroup(QCP::msTop|QCP::msBottom, m_group);

    setInteractions(QCP::iRangeDrag | QCP::iRangeZoom | QCP::iSelectPlottables | QCP::iSelectAxes );

//    SinglePlot * sp =  new SinglePlot(this);

//    spc::ContinousValuesLog * log =  new spc::ContinousValuesLog;
//    log->resize(100);
//    for(int i = 0 ; i < log->size(); ++i)
//        log->setValue(i, i);

//    sp->updateDataWith(log);
//    addSinglePlot(sp);

    replot();

}
Exemple #3
0
TsunamiPlot::TsunamiPlot(QWidget *parent) : QCustomPlot(parent) {
//    setupFullAxesBox();

//    setRangeDrag(Qt::Horizontal|Qt::Vertical);
//    setRangeZoom(Qt::Horizontal|Qt::Vertical);
    setInteractions( QCP::iRangeDrag | QCP::iRangeZoom );
//    setInteraction( QCP::iSelectAxes | QCP::iZo QCustomPlot::iSelectPlottables );
}
DrawInteraction::DrawInteraction(QWidget *parent) :
    QCustomPlot(parent)
{
    resize(600,400);

    statusBar = new QStatusBar(this);

    srand(QDateTime::currentDateTime().toTime_t());

    setInteractions(QCP::iRangeDrag | QCP::iRangeZoom | QCP::iSelectAxes |
                                      QCP::iSelectLegend | QCP::iSelectPlottables);
    xAxis->setRange(-8, 8);
    yAxis->setRange(-5, 5);
    axisRect()->setupFullAxesBox();

    plotLayout()->insertRow(0);
    plotLayout()->addElement(0, 0, new QCPPlotTitle(this, "Interaction Example"));

    xAxis->setLabel("x Axis");
    yAxis->setLabel("y Axis");
    legend->setVisible(true);
    QFont legendFont = font();
    legendFont.setPointSize(10);
    legend->setFont(legendFont);
    legend->setSelectedFont(legendFont);
    legend->setSelectableParts(QCPLegend::spItems); // legend box shall not be selectable, only legend items

    addRandomGraph();
    addRandomGraph();
    addRandomGraph();
    addRandomGraph();

    // connect slot that ties some axis selections together (especially opposite axes):
    connect(this, SIGNAL(selectionChangedByUser()), this, SLOT(selectionChanged()));
    // connect slots that takes care that when an axis is selected, only that direction can be dragged and zoomed:
    connect(this, SIGNAL(mousePress(QMouseEvent*)), this, SLOT(mousePress()));
    connect(this, SIGNAL(mouseWheel(QWheelEvent*)), this, SLOT(mouseWheel()));

    // make bottom and left axes transfer their ranges to top and right axes:
    connect(xAxis, SIGNAL(rangeChanged(QCPRange)), xAxis2, SLOT(setRange(QCPRange)));
    connect(yAxis, SIGNAL(rangeChanged(QCPRange)), yAxis2, SLOT(setRange(QCPRange)));

    // connect some interaction slots:
    connect(this, SIGNAL(titleDoubleClick(QMouseEvent*,QCPPlotTitle*)), this, SLOT(titleDoubleClick(QMouseEvent*,QCPPlotTitle*)));
    connect(this, SIGNAL(axisDoubleClick(QCPAxis*,QCPAxis::SelectablePart,QMouseEvent*)), this, SLOT(axisLabelDoubleClick(QCPAxis*,QCPAxis::SelectablePart)));
    connect(this, SIGNAL(legendDoubleClick(QCPLegend*,QCPAbstractLegendItem*,QMouseEvent*)), this, SLOT(legendDoubleClick(QCPLegend*,QCPAbstractLegendItem*)));

    // connect slot that shows a message in the status bar when a graph is clicked:
    connect(this, SIGNAL(plottableClick(QCPAbstractPlottable*,QMouseEvent*)), this, SLOT(graphClicked(QCPAbstractPlottable*)));

    // setup policy and connect slot for context menu popup:
    setContextMenuPolicy(Qt::CustomContextMenu);
    connect(this, SIGNAL(customContextMenuRequested(QPoint)), this, SLOT(contextMenuRequest(QPoint)));
}
Exemple #5
0
QCustomPlotExt::QCustomPlotExt(QWidget *parent) :
    QCustomPlot(parent),
    marker(NULL)
{
    clearExt();
    setInteractions(QCP::iRangeDrag | QCP::iRangeZoom);
    axisRect()->setRangeDrag(Qt::Horizontal | Qt::Vertical);
    axisRect()->setRangeZoom(Qt::Horizontal | Qt::Vertical);
    connect(this, SIGNAL(mouseWheel(QWheelEvent*)), this, SLOT(mouseWheel(QWheelEvent*)));
    connect(xAxis, SIGNAL(rangeChanged(QCPRange)), this, SLOT(xAxisRangeChanged(QCPRange)));
    connect(yAxis, SIGNAL(rangeChanged(QCPRange)), this, SLOT(yAxisRangeChanged(QCPRange)));
}
void PlotWidgetLevelDrawingState::initializeState()
{
    setInteractions();
    setCursorShape();
    mPlotWidget->updateTracers();
}