Commit 53f34e88 authored by Langella Olivier's avatar Langella Olivier
Browse files

zoom on y using ctrl key

parent ed29eb71
......@@ -21,6 +21,7 @@ Plot::Plot(QWidget *parent) :
legend->setFont(QFont("Helvetica",9));
// set locale to english, so we get english decimal separator:
//setLocale(QLocale(QLocale::English, QLocale::UnitedKingdom));
setFocusPolicy(Qt::ClickFocus);
qDebug() << "Plot(QWidget *parent) end";
}
......@@ -226,6 +227,22 @@ const QColor Plot::getNewColors() {
return color;
}
void Plot::keyPressEvent(QKeyEvent *event)
{
if(event->key() == Qt::Key_Control) {
_control_key = true;
}
qDebug() << "Plot::keyPressEvent end";
}
void Plot::keyReleaseEvent(QKeyEvent *event)
{
if(event->key() == Qt::Key_Control) {
_control_key = false;
}
qDebug() << "Plot::keyReleaseEvent end";
}
void Plot::mousePressEvent(QMouseEvent *event) {
qDebug() << "Plot::mousePressEvent begin " << xAxis->pixelToCoord(event->x()) << " " << yAxis->pixelToCoord(event->y());
_click = true;
......@@ -242,13 +259,18 @@ void Plot::mouseReleaseEvent(QMouseEvent *event) {
void Plot::mouseMoveEvent (QMouseEvent *event) {
if (_click) {
qDebug() << "Plot::mouseMoveEvent begin " << xAxis->pixelToCoord(event->x()) << " " << yAxis->pixelToCoord(event->y());
this->xAxis->moveRange(xAxis->pixelToCoord(_old_x)-xAxis->pixelToCoord(event->x()));
pappso::pappso_double y = yAxis->pixelToCoord(event->y());
if (y < 0) {
y =0;
}
if (y > 0) {
this->yAxis->scaleRange( _old_y/y, 0);
if (_control_key) {
if (y > 0) {
this->yAxis->scaleRange( _old_y/y, 0);
}
}
else {
this->xAxis->moveRange(xAxis->pixelToCoord(_old_x)-xAxis->pixelToCoord(event->x()));
}
_old_x = event->x();
_old_y = y;
......
......@@ -55,6 +55,8 @@ protected:
virtual void mouseMoveEvent (QMouseEvent *event);
virtual void mousePressEvent(QMouseEvent *event);
virtual void mouseReleaseEvent(QMouseEvent *event);
virtual void keyPressEvent(QKeyEvent *event);
virtual void keyReleaseEvent(QKeyEvent *event);
private:
const QColor getNewColors();
......@@ -63,6 +65,7 @@ private:
McqXicNoConstSp _p_xic;
std::vector<QCPGraph *> _graph_peak_list;
bool _click=false;
bool _control_key= false;
pappso::pappso_double _old_x;
pappso::pappso_double _old_y;
//QCPGraph * _p_graph_peak_border;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment