##// END OF EJS Templates
added quick fileName generation for data export, and fixed wrong date reading...
added quick fileName generation for data export, and fixed wrong date reading on cassini data files.

File last commit:

r10:63067c6877ba default
r10:63067c6877ba default
Show More
SocExplorerPlot.cpp
669 lines | 18.0 KiB | text/x-c | CppLexer
/ src / SocExplorerPlot.cpp
First init
r0 /*------------------------------------------------------------------------------
-- This file is a part of the QLop Software
-- Copyright (C) 2015, Plasma Physics Laboratory - CNRS
--
-- This program is free software; you can redistribute it and/or modify
-- it under the terms of the GNU General Public License as published by
-- the Free Software Foundation; either version 2 of the License, or
-- (at your option) any later version.
--
-- This program is distributed in the hope that it will be useful,
-- but WITHOUT ANY WARRANTY; without even the implied warranty of
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-- GNU General Public License for more details.
--
-- You should have received a copy of the GNU General Public License
-- along with this program; if not, write to the Free Software
-- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-------------------------------------------------------------------------------*/
/*-- Author : Alexis Jeandet
-- Mail : alexis.jeandet@member.fsf.org
----------------------------------------------------------------------------*/
#include "SocExplorerPlot.h"
Added Python Console and some Wrappers....
r5 #include <QSvgGenerator>
#include <qcpdocumentobject.h>
#include <QPdfWriter>
#include <QPrinter>
First init
r0
SocExplorerPlot::SocExplorerPlot(QWidget *parent) :
added zoom box.
r2 QWidget(parent), mRubberBand(new QRubberBand(QRubberBand::Rectangle, this))
First init
r0 {
Removed hack from QCustomPlot, moved to QCustomPlotVect class.
r7 this->m_plot = new QCustomPlotVect(this);
Drag and drop implemented, improved plot interactions.
r1 this->m_plot->setInteractions(QCP::iRangeDrag | QCP::iSelectAxes |
QCP::iSelectLegend | QCP::iSelectPlottables);
this->m_plot->axisRect()->setRangeDrag(Qt::Horizontal|Qt::Vertical);
this->m_plot->axisRect()->setRangeZoom(Qt::Horizontal|Qt::Vertical);
this->m_mainlayout = new QGridLayout(this);
this->setLayout(this->m_mainlayout);
this->m_mainlayout->addWidget(this->m_plot);
this->setMinimumSize(400,300);
this->setFocusPolicy(Qt::WheelFocus);
this->m_plot->setAttribute(Qt::WA_TransparentForMouseEvents);
this->ctrl_hold = false;
this->shift_hold = false;
this->mouse_hold = false;
this->m_plot->setNoAntialiasingOnDrag(true);
this->show();
this->m_plot->legend->setVisible(true);
First init
r0 }
added zoom box.
r2 SocExplorerPlot::~SocExplorerPlot()
{
delete mRubberBand;
}
First init
r0 void SocExplorerPlot::show()
{
QWidget::show();
}
void SocExplorerPlot::replot()
{
Added Python Console and some Wrappers....
r5 this->m_plot->replot();
}
void SocExplorerPlot::exportToSVG(const QString &fileName)
{
QSvgGenerator printer;
printer.setFileName(fileName);
QCPPainter qcpPainter;
qcpPainter.begin(&printer);
m_plot->toPainter(&qcpPainter, m_plot->width(), m_plot->height());
qcpPainter.end();
}
void SocExplorerPlot::exportToPDF(const QString &fileName)
{
A lot of refactoring:...
r6 QPrinter printer(QPrinter::HighResolution);
printer.setOutputFormat(QPrinter::PdfFormat);
printer.setOrientation(QPrinter::Landscape);
printer.setOutputFileName(fileName);
printer.setFullPage(true);
QCPPainter qcpPainter;
qcpPainter.begin(&printer);
m_plot->toPainter(&qcpPainter, printer.width(), printer.height());
qcpPainter.end();
First init
r0 }
Removed hack from QCustomPlot, moved to QCustomPlotVect class.
r7 void SocExplorerPlot::addAction(SocExplorerPlotActions *action)
{
this->m_actions.append(action);
QWidget::addAction((QAction*)action);
}
QVector<QCPData> *SocExplorerPlot::getVisibleData(int graphIndex)
{
plot view export works on cassini fgm data.
r8 QVector<QCPData> *visibleData=((QCPGraphVect*)m_plot->graph(graphIndex))->getVisibleData();
return visibleData;
Removed hack from QCustomPlot, moved to QCustomPlotVect class.
r7 }
First init
r0 void SocExplorerPlot::setTitle(QString title)
{
Drag and drop implemented, improved plot interactions.
r1 Q_UNUSED(title)
//this->m_plot->setTitle(title);
/*!
First init
r0 @todo Function borcken fixe this!
*/
added quick fileName generation for data export, and fixed wrong date reading...
r10 this->m_Title = title;
A lot of refactoring:...
r6 emit titleChanged(title);
this->repaint();
First init
r0 }
added quick fileName generation for data export, and fixed wrong date reading...
r10 const QString &SocExplorerPlot::title()
{
return m_Title;
}
First init
r0 void SocExplorerPlot::setXaxisLabel(QString label)
{
Drag and drop implemented, improved plot interactions.
r1 this->m_plot->xAxis->setLabel(label);
Added preliminary version of FFT and removed memory leak.
r9 this->repaint();
}
void SocExplorerPlot::setXaxisLog()
{
this->m_plot->xAxis->setScaleType(QCPAxis::stLogarithmic);
First init
r0 }
void SocExplorerPlot::setYaxisLabel(QString label)
{
Drag and drop implemented, improved plot interactions.
r1 this->m_plot->yAxis->setLabel(label);
Added preliminary version of FFT and removed memory leak.
r9 this->repaint();
}
void SocExplorerPlot::setYaxisLog()
{
this->m_plot->yAxis->setScaleType(QCPAxis::stLogarithmic);
First init
r0 }
void SocExplorerPlot::setXaxisRange(double lower, double upper)
{
Drag and drop implemented, improved plot interactions.
r1 this->m_plot->xAxis->setRange(lower,upper);
First init
r0 }
void SocExplorerPlot::setYaxisRange(double lower, double upper)
{
Drag and drop implemented, improved plot interactions.
r1 this->m_plot->yAxis->setRange(lower,upper);
First init
r0 }
void SocExplorerPlot::rescaleAxis()
{
Drag and drop implemented, improved plot interactions.
r1 this->m_plot->rescaleAxes();
this->m_plot->replot();
First init
r0 }
void SocExplorerPlot::setLegendFont(QFont font)
{
Drag and drop implemented, improved plot interactions.
r1 this->m_plot->legend->setFont(font);
this->repaint();
First init
r0 }
void SocExplorerPlot::setLegendSelectedFont(QFont font)
{
Drag and drop implemented, improved plot interactions.
r1 this->m_plot->legend->setSelectedFont(font);
this->repaint();
First init
r0 }
void SocExplorerPlot::setAdaptativeSampling(int graphIndex, bool enable)
{
Drag and drop implemented, improved plot interactions.
r1 this->m_plot->graph(graphIndex)->setAdaptiveSampling(enable);
First init
r0 }
Changed QCustomPlot data from QMap to QVector....
r3 void SocExplorerPlot::setUseFastVector(int graphIndex, bool enable)
{
Removed hack from QCustomPlot, moved to QCustomPlotVect class.
r7 // TODO deprecated
// this->m_plot->graph(graphIndex)->setUseFastVectors(enable);
Changed QCustomPlot data from QMap to QVector....
r3 }
First init
r0 int SocExplorerPlot::addGraph()
{
Drag and drop implemented, improved plot interactions.
r1 this->m_plot->addGraph();
First init
r0 return this->m_plot->graphCount() -1;
}
bool SocExplorerPlot::removeGraph(int graphIndex)
{
Removed hack from QCustomPlot, moved to QCustomPlotVect class.
r7 return this->m_plot->removeGraph(graphIndex);
}
int SocExplorerPlot::graphCount()
{
return m_plot->graphCount();
First init
r0 }
void SocExplorerPlot::removeAllGraphs()
{
int graphCount=this->m_plot->graphCount();
for(int i=0;i<graphCount;i++)
{
this->m_plot->removeGraph(0);
}
}
void SocExplorerPlot::setGraphName(int graphIndex,QString name)
{
Drag and drop implemented, improved plot interactions.
r1 if(graphIndex<this->m_plot->graphCount())
First init
r0 {
Drag and drop implemented, improved plot interactions.
r1 this->m_plot->graph(graphIndex)->setName(name);
added quick fileName generation for data export, and fixed wrong date reading...
r10 }
}
const QString &SocExplorerPlot::graphName(int graphIndex)
{
if(graphIndex<this->m_plot->graphCount())
{
return this->m_plot->graph(graphIndex)->name();
First init
r0 }
added quick fileName generation for data export, and fixed wrong date reading...
r10 return "";
First init
r0 }
void SocExplorerPlot::setGraphData(int graphIndex, QList<QVariant> x, QList<QVariant> y)
{
Drag and drop implemented, improved plot interactions.
r1 if((graphIndex<this->m_plot->graphCount()) && (x.count()==y.count()) && (x.at(0).type()==QVariant::Double))
First init
r0 {
Drag and drop implemented, improved plot interactions.
r1 QVector<double> _x(x.count()), _y(y.count());
for(int i=0;i<x.count();i++)
First init
r0 {
Drag and drop implemented, improved plot interactions.
r1 /*_x[i] = x.at(i).value<double>();
First init
r0 _y[i] = y.at(i).value<double>();*/
Drag and drop implemented, improved plot interactions.
r1 _x[i] = x.at(i).toDouble();
_y[i] = y.at(i).toDouble();
First init
r0 }
Drag and drop implemented, improved plot interactions.
r1 this->m_plot->graph(graphIndex)->setData(_x,_y);
First init
r0 }
Drag and drop implemented, improved plot interactions.
r1 else
{
if((graphIndex<this->m_plot->graphCount()) && (x.count()==y.count()) && (x.at(0).type()==QVariant::DateTime))
First init
r0 {
Drag and drop implemented, improved plot interactions.
r1 QVector<double> _x(x.count()), _y(y.count());
for(int i=0;i<x.count();i++)
First init
r0 {
Drag and drop implemented, improved plot interactions.
r1 /*_x[i] = x.at(i).value<double>();
First init
r0 _y[i] = y.at(i).value<double>();*/
Drag and drop implemented, improved plot interactions.
r1 _x[i] = x.at(i).toDateTime().toMSecsSinceEpoch();
_y[i] = y.at(i).toDouble();
First init
r0 }
Drag and drop implemented, improved plot interactions.
r1 this->m_plot->graph(graphIndex)->setData(_x,_y);
this->m_plot->xAxis->setTickLabelType(QCPAxis::ltDateTime);
this->m_plot->xAxis->setDateTimeFormat("hh:mm:ss.zzz");
First init
r0
}
Drag and drop implemented, improved plot interactions.
r1 }
this->m_plot->replot();
First init
r0 }
void SocExplorerPlot::setGraphData(int graphIndex, QCPDataMap *data, bool copy, bool replot)
{
if((graphIndex<this->m_plot->graphCount()))// && (x.at(0).type()==QVariant::Double))
Drag and drop implemented, improved plot interactions.
r1 {
First init
r0 this->m_plot->graph(graphIndex)->setData(data,copy);
Drag and drop implemented, improved plot interactions.
r1 }
First init
r0 if(replot)
this->m_plot->replot();
}
Changed QCustomPlot data from QMap to QVector....
r3 void SocExplorerPlot::setGraphData(int graphIndex,QVector<QCPData> *data, bool replot)
{
if((graphIndex<this->m_plot->graphCount()))// && (x.at(0).type()==QVariant::Double))
{
Removed hack from QCustomPlot, moved to QCustomPlotVect class.
r7 ((QCPGraphVect*)this->m_plot->graph(graphIndex))->setData(data);
Changed QCustomPlot data from QMap to QVector....
r3 }
if(replot)
this->m_plot->replot();
}
First init
r0 void SocExplorerPlot::addGraphData(int graphIndex, QList<QVariant> x, QList<QVariant> y)
{
Drag and drop implemented, improved plot interactions.
r1 if((graphIndex<this->m_plot->graphCount()) && (x.count()==y.count()))// && (x.at(0).type()==QVariant::Double))
First init
r0 {
Drag and drop implemented, improved plot interactions.
r1 QVector<double> _x(x.count()), _y(y.count());
for(int i=0;i<x.count();i++)
First init
r0 {
Drag and drop implemented, improved plot interactions.
r1 /*_x[i] = x.at(i).value<double>();
First init
r0 _y[i] = y.at(i).value<double>();*/
Drag and drop implemented, improved plot interactions.
r1 _x[i] = x.at(i).toDouble();
_y[i] = y.at(i).toDouble();
First init
r0 }
Drag and drop implemented, improved plot interactions.
r1 this->m_plot->graph(graphIndex)->addData(_x,_y);
First init
r0 }
Drag and drop implemented, improved plot interactions.
r1 this->m_plot->replot();
First init
r0 }
void SocExplorerPlot::addGraphData(int graphIndex, QVariant x, QVariant y)
{
Drag and drop implemented, improved plot interactions.
r1 if(graphIndex<this->m_plot->graphCount())// && (x.at(0).type()==QVariant::Double))
First init
r0 {
Drag and drop implemented, improved plot interactions.
r1 this->m_plot->graph(graphIndex)->addData(x.toDouble(),y.toDouble());
First init
r0 }
Drag and drop implemented, improved plot interactions.
r1 this->m_plot->replot();
First init
r0 }
void SocExplorerPlot::setGraphPen(int graphIndex,QPen pen)
{
Drag and drop implemented, improved plot interactions.
r1 if(graphIndex<this->m_plot->graphCount())
First init
r0 {
Drag and drop implemented, improved plot interactions.
r1 this->m_plot->graph(graphIndex)->setPen(pen);
First init
r0 }
}
QPen SocExplorerPlot::getGraphPen(int graphIndex)
{
Drag and drop implemented, improved plot interactions.
r1 if(graphIndex<this->m_plot->graphCount())
First init
r0 {
Drag and drop implemented, improved plot interactions.
r1 return this->m_plot->graph(graphIndex)->pen();
First init
r0 }
Drag and drop implemented, improved plot interactions.
r1 return this->m_plot->graph()->pen();
First init
r0 }
void SocExplorerPlot::setGraphLineStyle(int graphIndex,QString lineStyle)
{
Drag and drop implemented, improved plot interactions.
r1 if(graphIndex<this->m_plot->graphCount())
First init
r0 {
Drag and drop implemented, improved plot interactions.
r1 if(!lineStyle.compare("none"))
First init
r0 {
Drag and drop implemented, improved plot interactions.
r1 this->m_plot->graph(graphIndex)->setLineStyle(QCPGraph::lsNone);
return;
First init
r0 }
Drag and drop implemented, improved plot interactions.
r1 if(!lineStyle.compare("line"))
First init
r0 {
Drag and drop implemented, improved plot interactions.
r1 this->m_plot->graph(graphIndex)->setLineStyle(QCPGraph::lsLine);
return;
First init
r0 }
Drag and drop implemented, improved plot interactions.
r1 if(!lineStyle.compare("stepleft"))
First init
r0 {
Drag and drop implemented, improved plot interactions.
r1 this->m_plot->graph(graphIndex)->setLineStyle(QCPGraph::lsStepLeft);
return;
First init
r0 }
Drag and drop implemented, improved plot interactions.
r1 if(!lineStyle.compare("stepright"))
First init
r0 {
Drag and drop implemented, improved plot interactions.
r1 this->m_plot->graph(graphIndex)->setLineStyle(QCPGraph::lsStepRight);
return;
First init
r0 }
Drag and drop implemented, improved plot interactions.
r1 if(!lineStyle.compare("stepcenter"))
First init
r0 {
Drag and drop implemented, improved plot interactions.
r1 this->m_plot->graph(graphIndex)->setLineStyle(QCPGraph::lsStepCenter);
return;
First init
r0 }
Drag and drop implemented, improved plot interactions.
r1 if(!lineStyle.compare("impulse"))
First init
r0 {
Drag and drop implemented, improved plot interactions.
r1 this->m_plot->graph(graphIndex)->setLineStyle(QCPGraph::lsImpulse);
return;
First init
r0 }
}
}
void SocExplorerPlot::setGraphScatterStyle(int graphIndex,QString scatterStyle)
{
Drag and drop implemented, improved plot interactions.
r1 if(graphIndex<this->m_plot->graphCount())
First init
r0 {
Drag and drop implemented, improved plot interactions.
r1 if(!scatterStyle.compare("none"))
First init
r0 {
Drag and drop implemented, improved plot interactions.
r1 this->m_plot->graph(graphIndex)->setScatterStyle(QCPScatterStyle::ssNone);
return;
First init
r0 }
Drag and drop implemented, improved plot interactions.
r1 if(!scatterStyle.compare("dot"))
First init
r0 {
Drag and drop implemented, improved plot interactions.
r1 this->m_plot->graph(graphIndex)->setScatterStyle(QCPScatterStyle::ssDot);
return;
First init
r0 }
Drag and drop implemented, improved plot interactions.
r1 if(!scatterStyle.compare("cross"))
First init
r0 {
Drag and drop implemented, improved plot interactions.
r1 this->m_plot->graph(graphIndex)->setScatterStyle(QCPScatterStyle::ssCross);
return;
First init
r0 }
Drag and drop implemented, improved plot interactions.
r1 if(!scatterStyle.compare("plus"))
First init
r0 {
Drag and drop implemented, improved plot interactions.
r1 this->m_plot->graph(graphIndex)->setScatterStyle(QCPScatterStyle::ssPlus);
return;
First init
r0 }
Drag and drop implemented, improved plot interactions.
r1 if(!scatterStyle.compare("circle"))
First init
r0 {
Drag and drop implemented, improved plot interactions.
r1 this->m_plot->graph(graphIndex)->setScatterStyle(QCPScatterStyle::ssCircle);
return;
First init
r0 }
Drag and drop implemented, improved plot interactions.
r1 if(!scatterStyle.compare("disc"))
First init
r0 {
Drag and drop implemented, improved plot interactions.
r1 this->m_plot->graph(graphIndex)->setScatterStyle(QCPScatterStyle::ssDisc);
return;
First init
r0 }
Drag and drop implemented, improved plot interactions.
r1 if(!scatterStyle.compare("square"))
First init
r0 {
Drag and drop implemented, improved plot interactions.
r1 this->m_plot->graph(graphIndex)->setScatterStyle(QCPScatterStyle::ssSquare);
return;
First init
r0 }
Drag and drop implemented, improved plot interactions.
r1 if(!scatterStyle.compare("diamond"))
First init
r0 {
Drag and drop implemented, improved plot interactions.
r1 this->m_plot->graph(graphIndex)->setScatterStyle(QCPScatterStyle::ssDiamond);
return;
First init
r0 }
Drag and drop implemented, improved plot interactions.
r1 if(!scatterStyle.compare("star"))
First init
r0 {
Drag and drop implemented, improved plot interactions.
r1 this->m_plot->graph(graphIndex)->setScatterStyle(QCPScatterStyle::ssStar);
return;
First init
r0 }
Drag and drop implemented, improved plot interactions.
r1 if(!scatterStyle.compare("triangle"))
First init
r0 {
Drag and drop implemented, improved plot interactions.
r1 this->m_plot->graph(graphIndex)->setScatterStyle(QCPScatterStyle::ssTriangle);
return;
First init
r0 }
Drag and drop implemented, improved plot interactions.
r1 if(!scatterStyle.compare("invertedtriangle"))
First init
r0 {
Drag and drop implemented, improved plot interactions.
r1 this->m_plot->graph(graphIndex)->setScatterStyle(QCPScatterStyle::ssTriangleInverted);
return;
First init
r0 }
Drag and drop implemented, improved plot interactions.
r1 if(!scatterStyle.compare("crosssquare"))
First init
r0 {
Drag and drop implemented, improved plot interactions.
r1 this->m_plot->graph(graphIndex)->setScatterStyle(QCPScatterStyle::ssCrossSquare);
return;
First init
r0 }
Drag and drop implemented, improved plot interactions.
r1 if(!scatterStyle.compare("plussquare"))
First init
r0 {
Drag and drop implemented, improved plot interactions.
r1 this->m_plot->graph(graphIndex)->setScatterStyle(QCPScatterStyle::ssPlusSquare);
return;
First init
r0 }
Drag and drop implemented, improved plot interactions.
r1 if(!scatterStyle.compare("crosscircle"))
First init
r0 {
Drag and drop implemented, improved plot interactions.
r1 this->m_plot->graph(graphIndex)->setScatterStyle(QCPScatterStyle::ssCrossCircle);
return;
First init
r0 }
Drag and drop implemented, improved plot interactions.
r1 if(!scatterStyle.compare("pluscircle"))
First init
r0 {
Drag and drop implemented, improved plot interactions.
r1 this->m_plot->graph(graphIndex)->setScatterStyle(QCPScatterStyle::ssPlusCircle);
return;
First init
r0 }
Drag and drop implemented, improved plot interactions.
r1 if(!scatterStyle.compare("peace"))
First init
r0 {
Drag and drop implemented, improved plot interactions.
r1 this->m_plot->graph(graphIndex)->setScatterStyle(QCPScatterStyle::ssPeace);
return;
First init
r0 }
Drag and drop implemented, improved plot interactions.
r1 }
First init
r0 }
void SocExplorerPlot::setXaxisTickLabelType(QCPAxis::LabelType type)
{
this->m_plot->xAxis->setTickLabelType(type);
}
void SocExplorerPlot::setXaxisDateTimeFormat(const QString &format)
{
this->m_plot->xAxis->setDateTimeFormat(format);
}
void SocExplorerPlot::keyPressEvent(QKeyEvent * event)
{
Drag and drop implemented, improved plot interactions.
r1 switch(event->key())
First init
r0 {
case Qt::Key_Control:
Drag and drop implemented, improved plot interactions.
r1 this->ctrl_hold = true;
added zoom box.
r2 setCursor(Qt::CrossCursor);
Drag and drop implemented, improved plot interactions.
r1 break;
First init
r0 case Qt::Key_Shift:
Drag and drop implemented, improved plot interactions.
r1 this->shift_hold = true;
break;
First init
r0 case Qt::Key_M:
Drag and drop implemented, improved plot interactions.
r1 this->rescaleAxis();
break;
case Qt::Key_Left:
if(!ctrl_hold)
{
added zoom box.
r2 move(-0.1,Qt::Horizontal);
Drag and drop implemented, improved plot interactions.
r1 }
else
{
zoom(2,this->width()/2,Qt::Horizontal);
}
break;
case Qt::Key_Right:
if(!ctrl_hold)
{
added zoom box.
r2 move(0.1,Qt::Horizontal);
Drag and drop implemented, improved plot interactions.
r1 }
else
{
zoom(0.5,this->width()/2,Qt::Horizontal);
}
break;
case Qt::Key_Up:
if(!ctrl_hold)
{
added zoom box.
r2 move(0.1,Qt::Vertical);
Drag and drop implemented, improved plot interactions.
r1 }
else
{
zoom(0.5,this->height()/2,Qt::Vertical);
}
break;
case Qt::Key_Down:
if(!ctrl_hold)
{
added zoom box.
r2 move(-0.1,Qt::Vertical);
Drag and drop implemented, improved plot interactions.
r1 }
else
{
zoom(2,this->height()/2,Qt::Vertical);
}
break;
First init
r0 default:
Drag and drop implemented, improved plot interactions.
r1 QWidget::keyPressEvent(event);
break;
First init
r0 }
}
void SocExplorerPlot::keyReleaseEvent(QKeyEvent * event)
{
Drag and drop implemented, improved plot interactions.
r1 switch(event->key())
First init
r0 {
case Qt::Key_Control:
Drag and drop implemented, improved plot interactions.
r1 event->accept();
this->ctrl_hold = false;
break;
First init
r0 case Qt::Key_Shift:
Drag and drop implemented, improved plot interactions.
r1 event->accept();
this->shift_hold = false;
break;
First init
r0 default:
Drag and drop implemented, improved plot interactions.
r1 QWidget::keyReleaseEvent(event);
break;
First init
r0 }
added zoom box.
r2 setCursor(Qt::ArrowCursor);
First init
r0 }
void SocExplorerPlot::wheelEvent(QWheelEvent * event)
{
Drag and drop implemented, improved plot interactions.
r1 double factor;
double wheelSteps = event->delta()/120.0; // a single step delta is +/-120 usually
if(ctrl_hold)
First init
r0 {
Drag and drop implemented, improved plot interactions.
r1 if (event->orientation()==Qt::Vertical)//mRangeZoom.testFlag(Qt::Vertical))
First init
r0 {
added zoom box.
r2 setCursor(Qt::SizeVerCursor);
Drag and drop implemented, improved plot interactions.
r1 factor = pow(this->m_plot->axisRect()->rangeZoomFactor(Qt::Vertical), wheelSteps);
zoom(factor,event->pos().y(),Qt::Vertical);
First init
r0 }
Drag and drop implemented, improved plot interactions.
r1 QWidget::wheelEvent(event);
return;
First init
r0 }
Drag and drop implemented, improved plot interactions.
r1 if(shift_hold)
{
if (event->orientation()==Qt::Vertical)//mRangeZoom.testFlag(Qt::Vertical))
{
added zoom box.
r2 setCursor(Qt::SizeHorCursor);
Drag and drop implemented, improved plot interactions.
r1 factor = pow(this->m_plot->axisRect()->rangeZoomFactor(Qt::Horizontal), wheelSteps);
zoom(factor,event->pos().x(),Qt::Horizontal);
}
QWidget::wheelEvent(event);
return;
}
move(wheelSteps/10,Qt::Horizontal);
QWidget::wheelEvent(event);
First init
r0 }
void SocExplorerPlot::mousePressEvent(QMouseEvent *event)
{
Drag and drop implemented, improved plot interactions.
r1 if(event->button()==Qt::LeftButton)
First init
r0 {
added zoom box.
r2 if(ctrl_hold)
{
setCursor(Qt::CrossCursor);
mOrigin = event->pos();
mRubberBand->setGeometry(QRect(mOrigin, QSize()));
mRubberBand->show();
}
else
{
setCursor(Qt::ClosedHandCursor);
mDragStart = event->pos();
this->mouse_hold = true;
DragStartHorzRange = this->m_plot->axisRect()->rangeDragAxis(Qt::Horizontal)->range();
DragStartVertRange = this->m_plot->axisRect()->rangeDragAxis(Qt::Vertical)->range();
}
First init
r0 }
Drag and drop implemented, improved plot interactions.
r1 QWidget::mousePressEvent(event);
First init
r0 }
void SocExplorerPlot::mouseReleaseEvent(QMouseEvent *event)
{
Drag and drop implemented, improved plot interactions.
r1 if(event->button()==Qt::LeftButton)
First init
r0 {
Drag and drop implemented, improved plot interactions.
r1 this->mouse_hold = false;
First init
r0 }
added zoom box.
r2 if (mRubberBand->isVisible())
{
const QRect & zoomRect = mRubberBand->geometry();
int xp1, yp1, xp2, yp2;
zoomRect.getCoords(&xp1, &yp1, &xp2, &yp2);
double x1 = this->m_plot->xAxis->pixelToCoord(xp1);
double x2 = this->m_plot->xAxis->pixelToCoord(xp2);
double y1 = this->m_plot->yAxis->pixelToCoord(yp1);
double y2 = this->m_plot->yAxis->pixelToCoord(yp2);
this->m_plot->xAxis->setRange(x1, x2);
this->m_plot->yAxis->setRange(y1, y2);
mRubberBand->hide();
this->m_plot->replot();
}
setCursor(Qt::ArrowCursor);
Drag and drop implemented, improved plot interactions.
r1 QWidget::mouseReleaseEvent(event);
}
void SocExplorerPlot::zoom(double factor, int center, Qt::Orientation orientation)
{
QCPAxis* axis = this->m_plot->axisRect()->rangeZoomAxis(orientation);
axis->scaleRange(factor, axis->pixelToCoord(center));
this->m_plot->replot();
First init
r0 }
Drag and drop implemented, improved plot interactions.
r1 void SocExplorerPlot::move(double factor, Qt::Orientation orientation)
{
QCPAxis* axis = this->m_plot->axisRect()->rangeDragAxis(orientation);
double rg = (axis->range().upper - axis->range().lower)*(factor);
axis->setRange(axis->range().lower+(rg), axis->range().upper+(rg));
this->m_plot->replot();
}
First init
r0 void SocExplorerPlot::mouseMoveEvent(QMouseEvent *event)
{
Drag and drop implemented, improved plot interactions.
r1 if(mouse_hold)
First init
r0 {
Drag and drop implemented, improved plot interactions.
r1 QCPAxis* Haxis = this->m_plot->axisRect()->rangeDragAxis(Qt::Horizontal);
QCPAxis* Vaxis = this->m_plot->axisRect()->rangeDragAxis(Qt::Vertical);
double diff = Haxis->pixelToCoord(mDragStart.x()) - Haxis->pixelToCoord(event->pos().x());
Haxis->setRange(DragStartHorzRange.lower+diff, DragStartHorzRange.upper+diff);
diff = Vaxis->pixelToCoord(mDragStart.y()) - Vaxis->pixelToCoord(event->pos().y());
Vaxis->setRange(DragStartVertRange.lower+diff, DragStartVertRange.upper+diff);
this->m_plot->replot();
First init
r0 }
added zoom box.
r2 if (mRubberBand->isVisible())
{
mRubberBand->setGeometry(QRect(mOrigin, event->pos()).normalized());
}
Drag and drop implemented, improved plot interactions.
r1 QWidget::mouseMoveEvent(event);
First init
r0 }