##// END OF EJS Templates
New register explorer WIP...
New register explorer WIP !!!!!!!!!!!!!!!!!!!!!!!!!!!!! REMOVED OLD genericPySysdriver interface Now the plugins are directly exposed to python. ABI not compatible with previous plugins. !!!!!!!!!!!!!!!!!!!!!!!!!!!!!

File last commit:

r74:7e54838aea98 default
r79:3440ba47d0f1 default
Show More
SocExplorerPlot.cpp
535 lines | 13.7 KiB | text/x-c | CppLexer
/ src / common / SocExplorerPlot.cpp
Jeandet Alexis
First init of SocExplorer Repository.
r0 #include "SocExplorerPlot.h"
SocExplorerPlot::SocExplorerPlot(QWidget *parent) :
Improved zoom features on SocExplorer Plot.
r74 QWidget(parent), mRubberBand(new QRubberBand(QRubberBand::Rectangle, this))
Jeandet Alexis
First init of SocExplorer Repository.
r0 {
Improved zoom features on SocExplorer Plot.
r74 this->m_plot = new QCustomPlot(this);
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();
}
Jeandet Alexis
First init of SocExplorer Repository.
r0
Improved zoom features on SocExplorer Plot.
r74 SocExplorerPlot::~SocExplorerPlot()
{
delete mRubberBand;
Jeandet Alexis
First init of SocExplorer Repository.
r0 }
void SocExplorerPlot::show()
{
Improved zoom features on SocExplorer Plot.
r74 QWidget::show();
}
void SocExplorerPlot::replot()
{
this->m_plot->replot();
Jeandet Alexis
First init of SocExplorer Repository.
r0 }
void SocExplorerPlot::setTitle(QString title)
{
Improved zoom features on SocExplorer Plot.
r74 Q_UNUSED(title)
//this->m_plot->setTitle(title);
/*!
Jeandet Alexis
First init of SocExplorer Repository.
r0 @todo Function borcken fixe this!
*/
Improved zoom features on SocExplorer Plot.
r74 this->repaint();
Jeandet Alexis
First init of SocExplorer Repository.
r0 }
void SocExplorerPlot::setXaxisLabel(QString label)
{
Improved zoom features on SocExplorer Plot.
r74 this->m_plot->xAxis->setLabel(label);
this->repaint();
Jeandet Alexis
First init of SocExplorer Repository.
r0 }
void SocExplorerPlot::setYaxisLabel(QString label)
{
Improved zoom features on SocExplorer Plot.
r74 this->m_plot->yAxis->setLabel(label);
this->repaint();
Jeandet Alexis
First init of SocExplorer Repository.
r0 }
void SocExplorerPlot::setXaxisRange(double lower, double upper)
{
Improved zoom features on SocExplorer Plot.
r74 this->m_plot->xAxis->setRange(lower,upper);
Jeandet Alexis
First init of SocExplorer Repository.
r0 }
void SocExplorerPlot::setYaxisRange(double lower, double upper)
{
Improved zoom features on SocExplorer Plot.
r74 this->m_plot->yAxis->setRange(lower,upper);
Jeandet Alexis
First init of SocExplorer Repository.
r0 }
void SocExplorerPlot::rescaleAxis()
{
Improved zoom features on SocExplorer Plot.
r74 this->m_plot->rescaleAxes();
this->m_plot->replot();
Jeandet Alexis
First init of SocExplorer Repository.
r0 }
void SocExplorerPlot::setLegendFont(QFont font)
{
Improved zoom features on SocExplorer Plot.
r74 this->m_plot->legend->setFont(font);
this->repaint();
Jeandet Alexis
First init of SocExplorer Repository.
r0 }
void SocExplorerPlot::setLegendSelectedFont(QFont font)
{
Improved zoom features on SocExplorer Plot.
r74 this->m_plot->legend->setSelectedFont(font);
this->repaint();
Jeandet Alexis
First init of SocExplorer Repository.
r0 }
Updated QCustomPlot to 1.2
r18 void SocExplorerPlot::setAdaptativeSampling(int graphIndex, bool enable)
{
Improved zoom features on SocExplorer Plot.
r74 this->m_plot->graph(graphIndex)->setAdaptiveSampling(enable);
Updated QCustomPlot to 1.2
r18 }
Jeandet Alexis
First init of SocExplorer Repository.
r0 int SocExplorerPlot::addGraph()
{
Improved zoom features on SocExplorer Plot.
r74 this->m_plot->addGraph();
return this->m_plot->graphCount() -1;
}
bool SocExplorerPlot::removeGraph(int graphIndex)
{
return this->m_plot->removeGraph(graphIndex);
}
void SocExplorerPlot::removeAllGraphs()
{
int graphCount=this->m_plot->graphCount();
for(int i=0;i<graphCount;i++)
{
this->m_plot->removeGraph(0);
}
Jeandet Alexis
First init of SocExplorer Repository.
r0 }
void SocExplorerPlot::setGraphName(int graphIndex,QString name)
{
Improved zoom features on SocExplorer Plot.
r74 if(graphIndex<this->m_plot->graphCount())
Jeandet Alexis
First init of SocExplorer Repository.
r0 {
Improved zoom features on SocExplorer Plot.
r74 this->m_plot->graph(graphIndex)->setName(name);
Jeandet Alexis
First init of SocExplorer Repository.
r0 }
}
void SocExplorerPlot::setGraphData(int graphIndex, QList<QVariant> x, QList<QVariant> y)
{
Improved zoom features on SocExplorer Plot.
r74 if((graphIndex<this->m_plot->graphCount()) && (x.count()==y.count()))// && (x.at(0).type()==QVariant::Double))
Jeandet Alexis
First init of SocExplorer Repository.
r0 {
Improved zoom features on SocExplorer Plot.
r74 QVector<double> _x(x.count()), _y(y.count());
for(int i=0;i<x.count();i++)
Jeandet Alexis
First init of SocExplorer Repository.
r0 {
Improved zoom features on SocExplorer Plot.
r74 /*_x[i] = x.at(i).value<double>();
Jeandet Alexis
First init of SocExplorer Repository.
r0 _y[i] = y.at(i).value<double>();*/
Improved zoom features on SocExplorer Plot.
r74 _x[i] = x.at(i).toDouble();
_y[i] = y.at(i).toDouble();
Jeandet Alexis
First init of SocExplorer Repository.
r0 }
Improved zoom features on SocExplorer Plot.
r74 this->m_plot->graph(graphIndex)->setData(_x,_y);
Jeandet Alexis
First init of SocExplorer Repository.
r0 }
Improved zoom features on SocExplorer Plot.
r74 this->m_plot->replot();
Jeandet Alexis
First init of SocExplorer Repository.
r0 }
void SocExplorerPlot::addGraphData(int graphIndex, QList<QVariant> x, QList<QVariant> y)
{
Improved zoom features on SocExplorer Plot.
r74 if((graphIndex<this->m_plot->graphCount()) && (x.count()==y.count()))// && (x.at(0).type()==QVariant::Double))
Jeandet Alexis
First init of SocExplorer Repository.
r0 {
Improved zoom features on SocExplorer Plot.
r74 QVector<double> _x(x.count()), _y(y.count());
for(int i=0;i<x.count();i++)
Jeandet Alexis
First init of SocExplorer Repository.
r0 {
Improved zoom features on SocExplorer Plot.
r74 /*_x[i] = x.at(i).value<double>();
Jeandet Alexis
First init of SocExplorer Repository.
r0 _y[i] = y.at(i).value<double>();*/
Improved zoom features on SocExplorer Plot.
r74 _x[i] = x.at(i).toDouble();
_y[i] = y.at(i).toDouble();
Jeandet Alexis
First init of SocExplorer Repository.
r0 }
Improved zoom features on SocExplorer Plot.
r74 this->m_plot->graph(graphIndex)->addData(_x,_y);
Jeandet Alexis
First init of SocExplorer Repository.
r0 }
Improved zoom features on SocExplorer Plot.
r74 this->m_plot->replot();
Jeandet Alexis
First init of SocExplorer Repository.
r0 }
void SocExplorerPlot::addGraphData(int graphIndex, QVariant x, QVariant y)
{
Improved zoom features on SocExplorer Plot.
r74 if(graphIndex<this->m_plot->graphCount())// && (x.at(0).type()==QVariant::Double))
Jeandet Alexis
First init of SocExplorer Repository.
r0 {
Improved zoom features on SocExplorer Plot.
r74 this->m_plot->graph(graphIndex)->addData(x.toDouble(),y.toDouble());
Jeandet Alexis
First init of SocExplorer Repository.
r0 }
Improved zoom features on SocExplorer Plot.
r74 this->m_plot->replot();
Jeandet Alexis
First init of SocExplorer Repository.
r0 }
void SocExplorerPlot::setGraphPen(int graphIndex,QPen pen)
{
Improved zoom features on SocExplorer Plot.
r74 if(graphIndex<this->m_plot->graphCount())
Jeandet Alexis
First init of SocExplorer Repository.
r0 {
Improved zoom features on SocExplorer Plot.
r74 this->m_plot->graph(graphIndex)->setPen(pen);
Jeandet Alexis
First init of SocExplorer Repository.
r0 }
}
QPen SocExplorerPlot::getGraphPen(int graphIndex)
{
Improved zoom features on SocExplorer Plot.
r74 if(graphIndex<this->m_plot->graphCount())
Jeandet Alexis
First init of SocExplorer Repository.
r0 {
Improved zoom features on SocExplorer Plot.
r74 return this->m_plot->graph(graphIndex)->pen();
Jeandet Alexis
First init of SocExplorer Repository.
r0 }
Improved zoom features on SocExplorer Plot.
r74 return this->m_plot->graph()->pen();
Jeandet Alexis
First init of SocExplorer Repository.
r0 }
void SocExplorerPlot::setGraphLineStyle(int graphIndex,QString lineStyle)
{
Improved zoom features on SocExplorer Plot.
r74 if(graphIndex<this->m_plot->graphCount())
Jeandet Alexis
First init of SocExplorer Repository.
r0 {
Improved zoom features on SocExplorer Plot.
r74 if(!lineStyle.compare("none"))
Jeandet Alexis
First init of SocExplorer Repository.
r0 {
Improved zoom features on SocExplorer Plot.
r74 this->m_plot->graph(graphIndex)->setLineStyle(QCPGraph::lsNone);
return;
Jeandet Alexis
First init of SocExplorer Repository.
r0 }
Improved zoom features on SocExplorer Plot.
r74 if(!lineStyle.compare("line"))
Jeandet Alexis
First init of SocExplorer Repository.
r0 {
Improved zoom features on SocExplorer Plot.
r74 this->m_plot->graph(graphIndex)->setLineStyle(QCPGraph::lsLine);
return;
Jeandet Alexis
First init of SocExplorer Repository.
r0 }
Improved zoom features on SocExplorer Plot.
r74 if(!lineStyle.compare("stepleft"))
Jeandet Alexis
First init of SocExplorer Repository.
r0 {
Improved zoom features on SocExplorer Plot.
r74 this->m_plot->graph(graphIndex)->setLineStyle(QCPGraph::lsStepLeft);
return;
Jeandet Alexis
First init of SocExplorer Repository.
r0 }
Improved zoom features on SocExplorer Plot.
r74 if(!lineStyle.compare("stepright"))
Jeandet Alexis
First init of SocExplorer Repository.
r0 {
Improved zoom features on SocExplorer Plot.
r74 this->m_plot->graph(graphIndex)->setLineStyle(QCPGraph::lsStepRight);
return;
Jeandet Alexis
First init of SocExplorer Repository.
r0 }
Improved zoom features on SocExplorer Plot.
r74 if(!lineStyle.compare("stepcenter"))
Jeandet Alexis
First init of SocExplorer Repository.
r0 {
Improved zoom features on SocExplorer Plot.
r74 this->m_plot->graph(graphIndex)->setLineStyle(QCPGraph::lsStepCenter);
return;
Jeandet Alexis
First init of SocExplorer Repository.
r0 }
Improved zoom features on SocExplorer Plot.
r74 if(!lineStyle.compare("impulse"))
Jeandet Alexis
First init of SocExplorer Repository.
r0 {
Improved zoom features on SocExplorer Plot.
r74 this->m_plot->graph(graphIndex)->setLineStyle(QCPGraph::lsImpulse);
return;
Jeandet Alexis
First init of SocExplorer Repository.
r0 }
}
}
void SocExplorerPlot::setGraphScatterStyle(int graphIndex,QString scatterStyle)
{
Improved zoom features on SocExplorer Plot.
r74 if(graphIndex<this->m_plot->graphCount())
Jeandet Alexis
First init of SocExplorer Repository.
r0 {
Improved zoom features on SocExplorer Plot.
r74 if(!scatterStyle.compare("none"))
Jeandet Alexis
First init of SocExplorer Repository.
r0 {
Improved zoom features on SocExplorer Plot.
r74 this->m_plot->graph(graphIndex)->setScatterStyle(QCPScatterStyle::ssNone);
return;
Jeandet Alexis
First init of SocExplorer Repository.
r0 }
Improved zoom features on SocExplorer Plot.
r74 if(!scatterStyle.compare("dot"))
Jeandet Alexis
First init of SocExplorer Repository.
r0 {
Improved zoom features on SocExplorer Plot.
r74 this->m_plot->graph(graphIndex)->setScatterStyle(QCPScatterStyle::ssDot);
return;
Jeandet Alexis
First init of SocExplorer Repository.
r0 }
Improved zoom features on SocExplorer Plot.
r74 if(!scatterStyle.compare("cross"))
Jeandet Alexis
First init of SocExplorer Repository.
r0 {
Improved zoom features on SocExplorer Plot.
r74 this->m_plot->graph(graphIndex)->setScatterStyle(QCPScatterStyle::ssCross);
return;
Jeandet Alexis
First init of SocExplorer Repository.
r0 }
Improved zoom features on SocExplorer Plot.
r74 if(!scatterStyle.compare("plus"))
Jeandet Alexis
First init of SocExplorer Repository.
r0 {
Improved zoom features on SocExplorer Plot.
r74 this->m_plot->graph(graphIndex)->setScatterStyle(QCPScatterStyle::ssPlus);
return;
Jeandet Alexis
First init of SocExplorer Repository.
r0 }
Improved zoom features on SocExplorer Plot.
r74 if(!scatterStyle.compare("circle"))
Jeandet Alexis
First init of SocExplorer Repository.
r0 {
Improved zoom features on SocExplorer Plot.
r74 this->m_plot->graph(graphIndex)->setScatterStyle(QCPScatterStyle::ssCircle);
return;
Jeandet Alexis
First init of SocExplorer Repository.
r0 }
Improved zoom features on SocExplorer Plot.
r74 if(!scatterStyle.compare("disc"))
Jeandet Alexis
First init of SocExplorer Repository.
r0 {
Improved zoom features on SocExplorer Plot.
r74 this->m_plot->graph(graphIndex)->setScatterStyle(QCPScatterStyle::ssDisc);
return;
Jeandet Alexis
First init of SocExplorer Repository.
r0 }
Improved zoom features on SocExplorer Plot.
r74 if(!scatterStyle.compare("square"))
Jeandet Alexis
First init of SocExplorer Repository.
r0 {
Improved zoom features on SocExplorer Plot.
r74 this->m_plot->graph(graphIndex)->setScatterStyle(QCPScatterStyle::ssSquare);
return;
Jeandet Alexis
First init of SocExplorer Repository.
r0 }
Improved zoom features on SocExplorer Plot.
r74 if(!scatterStyle.compare("diamond"))
Jeandet Alexis
First init of SocExplorer Repository.
r0 {
Improved zoom features on SocExplorer Plot.
r74 this->m_plot->graph(graphIndex)->setScatterStyle(QCPScatterStyle::ssDiamond);
return;
Jeandet Alexis
First init of SocExplorer Repository.
r0 }
Improved zoom features on SocExplorer Plot.
r74 if(!scatterStyle.compare("star"))
Jeandet Alexis
First init of SocExplorer Repository.
r0 {
Improved zoom features on SocExplorer Plot.
r74 this->m_plot->graph(graphIndex)->setScatterStyle(QCPScatterStyle::ssStar);
return;
Jeandet Alexis
First init of SocExplorer Repository.
r0 }
Improved zoom features on SocExplorer Plot.
r74 if(!scatterStyle.compare("triangle"))
Jeandet Alexis
First init of SocExplorer Repository.
r0 {
Improved zoom features on SocExplorer Plot.
r74 this->m_plot->graph(graphIndex)->setScatterStyle(QCPScatterStyle::ssTriangle);
return;
Jeandet Alexis
First init of SocExplorer Repository.
r0 }
Improved zoom features on SocExplorer Plot.
r74 if(!scatterStyle.compare("invertedtriangle"))
Jeandet Alexis
First init of SocExplorer Repository.
r0 {
Improved zoom features on SocExplorer Plot.
r74 this->m_plot->graph(graphIndex)->setScatterStyle(QCPScatterStyle::ssTriangleInverted);
return;
Jeandet Alexis
First init of SocExplorer Repository.
r0 }
Improved zoom features on SocExplorer Plot.
r74 if(!scatterStyle.compare("crosssquare"))
Jeandet Alexis
First init of SocExplorer Repository.
r0 {
Improved zoom features on SocExplorer Plot.
r74 this->m_plot->graph(graphIndex)->setScatterStyle(QCPScatterStyle::ssCrossSquare);
return;
Jeandet Alexis
First init of SocExplorer Repository.
r0 }
Improved zoom features on SocExplorer Plot.
r74 if(!scatterStyle.compare("plussquare"))
Jeandet Alexis
First init of SocExplorer Repository.
r0 {
Improved zoom features on SocExplorer Plot.
r74 this->m_plot->graph(graphIndex)->setScatterStyle(QCPScatterStyle::ssPlusSquare);
return;
Jeandet Alexis
First init of SocExplorer Repository.
r0 }
Improved zoom features on SocExplorer Plot.
r74 if(!scatterStyle.compare("crosscircle"))
Jeandet Alexis
First init of SocExplorer Repository.
r0 {
Improved zoom features on SocExplorer Plot.
r74 this->m_plot->graph(graphIndex)->setScatterStyle(QCPScatterStyle::ssCrossCircle);
return;
Jeandet Alexis
First init of SocExplorer Repository.
r0 }
Improved zoom features on SocExplorer Plot.
r74 if(!scatterStyle.compare("pluscircle"))
Jeandet Alexis
First init of SocExplorer Repository.
r0 {
Improved zoom features on SocExplorer Plot.
r74 this->m_plot->graph(graphIndex)->setScatterStyle(QCPScatterStyle::ssPlusCircle);
return;
Jeandet Alexis
First init of SocExplorer Repository.
r0 }
Improved zoom features on SocExplorer Plot.
r74 if(!scatterStyle.compare("peace"))
Jeandet Alexis
First init of SocExplorer Repository.
r0 {
Improved zoom features on SocExplorer Plot.
r74 this->m_plot->graph(graphIndex)->setScatterStyle(QCPScatterStyle::ssPeace);
return;
Jeandet Alexis
First init of SocExplorer Repository.
r0 }
}
}
Improved zoom features on SocExplorer Plot.
r74 void SocExplorerPlot::setXaxisTickLabelType(QCPAxis::LabelType type)
{
this->m_plot->xAxis->setTickLabelType(type);
}
void SocExplorerPlot::setXaxisDateTimeFormat(const QString &format)
{
this->m_plot->xAxis->setDateTimeFormat(format);
}
Jeandet Alexis
First init of SocExplorer Repository.
r0
void SocExplorerPlot::keyPressEvent(QKeyEvent * event)
{
Improved zoom features on SocExplorer Plot.
r74 switch(event->key())
Jeandet Alexis
First init of SocExplorer Repository.
r0 {
case Qt::Key_Control:
Improved zoom features on SocExplorer Plot.
r74 this->ctrl_hold = true;
setCursor(Qt::CrossCursor);
break;
Jeandet Alexis
First init of SocExplorer Repository.
r0 case Qt::Key_Shift:
Improved zoom features on SocExplorer Plot.
r74 this->shift_hold = true;
break;
Jeandet Alexis
First init of SocExplorer Repository.
r0 case Qt::Key_M:
Improved zoom features on SocExplorer Plot.
r74 this->rescaleAxis();
break;
case Qt::Key_Left:
if(!ctrl_hold)
{
move(-0.1,Qt::Horizontal);
}
else
{
zoom(2,this->width()/2,Qt::Horizontal);
}
break;
case Qt::Key_Right:
if(!ctrl_hold)
{
move(0.1,Qt::Horizontal);
}
else
{
zoom(0.5,this->width()/2,Qt::Horizontal);
}
break;
case Qt::Key_Up:
if(!ctrl_hold)
{
move(0.1,Qt::Vertical);
}
else
{
zoom(0.5,this->height()/2,Qt::Vertical);
}
break;
case Qt::Key_Down:
if(!ctrl_hold)
{
move(-0.1,Qt::Vertical);
}
else
{
zoom(2,this->height()/2,Qt::Vertical);
}
break;
Jeandet Alexis
First init of SocExplorer Repository.
r0 default:
Improved zoom features on SocExplorer Plot.
r74 QWidget::keyPressEvent(event);
break;
Jeandet Alexis
First init of SocExplorer Repository.
r0 }
}
void SocExplorerPlot::keyReleaseEvent(QKeyEvent * event)
{
Improved zoom features on SocExplorer Plot.
r74 switch(event->key())
Jeandet Alexis
First init of SocExplorer Repository.
r0 {
case Qt::Key_Control:
Improved zoom features on SocExplorer Plot.
r74 event->accept();
this->ctrl_hold = false;
break;
Jeandet Alexis
First init of SocExplorer Repository.
r0 case Qt::Key_Shift:
Improved zoom features on SocExplorer Plot.
r74 event->accept();
this->shift_hold = false;
break;
Jeandet Alexis
First init of SocExplorer Repository.
r0 default:
Improved zoom features on SocExplorer Plot.
r74 QWidget::keyReleaseEvent(event);
break;
Jeandet Alexis
First init of SocExplorer Repository.
r0 }
Improved zoom features on SocExplorer Plot.
r74 setCursor(Qt::ArrowCursor);
Jeandet Alexis
First init of SocExplorer Repository.
r0 }
void SocExplorerPlot::wheelEvent(QWheelEvent * event)
{
Improved zoom features on SocExplorer Plot.
r74 double factor;
double wheelSteps = event->delta()/120.0; // a single step delta is +/-120 usually
if(ctrl_hold)
Jeandet Alexis
First init of SocExplorer Repository.
r0 {
Improved zoom features on SocExplorer Plot.
r74 if (event->orientation()==Qt::Vertical)//mRangeZoom.testFlag(Qt::Vertical))
Jeandet Alexis
First init of SocExplorer Repository.
r0 {
Improved zoom features on SocExplorer Plot.
r74 setCursor(Qt::SizeVerCursor);
factor = pow(this->m_plot->axisRect()->rangeZoomFactor(Qt::Vertical), wheelSteps);
zoom(factor,event->pos().y(),Qt::Vertical);
Jeandet Alexis
First init of SocExplorer Repository.
r0 }
Improved zoom features on SocExplorer Plot.
r74 QWidget::wheelEvent(event);
return;
Jeandet Alexis
First init of SocExplorer Repository.
r0 }
Improved zoom features on SocExplorer Plot.
r74 if(shift_hold)
{
if (event->orientation()==Qt::Vertical)//mRangeZoom.testFlag(Qt::Vertical))
{
setCursor(Qt::SizeHorCursor);
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);
Jeandet Alexis
First init of SocExplorer Repository.
r0 }
void SocExplorerPlot::mousePressEvent(QMouseEvent *event)
{
Improved zoom features on SocExplorer Plot.
r74 if(event->button()==Qt::LeftButton)
Jeandet Alexis
First init of SocExplorer Repository.
r0 {
Improved zoom features on SocExplorer Plot.
r74 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();
}
Jeandet Alexis
First init of SocExplorer Repository.
r0 }
Improved zoom features on SocExplorer Plot.
r74 QWidget::mousePressEvent(event);
Jeandet Alexis
First init of SocExplorer Repository.
r0 }
void SocExplorerPlot::mouseReleaseEvent(QMouseEvent *event)
{
Improved zoom features on SocExplorer Plot.
r74 if(event->button()==Qt::LeftButton)
{
this->mouse_hold = false;
}
if (mRubberBand->isVisible())
Jeandet Alexis
First init of SocExplorer Repository.
r0 {
Improved zoom features on SocExplorer Plot.
r74 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();
Jeandet Alexis
First init of SocExplorer Repository.
r0 }
Improved zoom features on SocExplorer Plot.
r74 setCursor(Qt::ArrowCursor);
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();
Jeandet Alexis
First init of SocExplorer Repository.
r0 }
Improved zoom features on SocExplorer Plot.
r74 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();
}
Jeandet Alexis
First init of SocExplorer Repository.
r0 void SocExplorerPlot::mouseMoveEvent(QMouseEvent *event)
{
Improved zoom features on SocExplorer Plot.
r74 if(mouse_hold)
Jeandet Alexis
First init of SocExplorer Repository.
r0 {
Improved zoom features on SocExplorer Plot.
r74 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();
Jeandet Alexis
First init of SocExplorer Repository.
r0 }
Improved zoom features on SocExplorer Plot.
r74 if (mRubberBand->isVisible())
{
mRubberBand->setGeometry(QRect(mOrigin, event->pos()).normalized());
}
QWidget::mouseMoveEvent(event);
Jeandet Alexis
First init of SocExplorer Repository.
r0 }