Changeset - 1d12f68d4882
[Not reviewed]
scalezoomer
0 5 0
Hasan Yavuz Ă–ZDERYA - 10 years ago 2015-08-27 15:44:42
hy@ozderya.net
change color of the scale picker according to background
5 files changed with 23 insertions and 2 deletions:
0 comments (0 inline, 0 general)
plot.cpp
Show inline comments
 
@@ -98,6 +98,7 @@ void Plot::darkBackground(bool enabled)
 
        grid.setPen(Qt::darkGray);
 
        zoomer.setRubberBandPen(QPen(Qt::white));
 
        zoomer.setTrackerPen(QPen(Qt::white));
 
        sZoomer.setPickerPen(QPen(Qt::white));
 
    }
 
    else
 
    {
 
@@ -105,6 +106,7 @@ void Plot::darkBackground(bool enabled)
 
        grid.setPen(Qt::lightGray);
 
        zoomer.setRubberBandPen(QPen(Qt::black));
 
        zoomer.setTrackerPen(QPen(Qt::black));
 
        sZoomer.setPickerPen(QPen(Qt::black));
 
    }
 
    replot();
 
}
scalepicker.cpp
Show inline comments
 
@@ -130,10 +130,17 @@ void ScalePicker::drawOverlay(QPainter* 
 
            int width = painter->device()->width();
 
            rect = QRect(0, firstPosPx, width, (currentPosPx-firstPosPx));
 
        }
 

	
 
        painter->setPen(_pen);
 
        painter->drawRect(rect);
 
    }
 
}
 

	
 
void ScalePicker::setPen(QPen pen)
 
{
 
    _pen = pen;
 
}
 

	
 
double ScalePicker::position(QMouseEvent* mouseEvent)
 
{
 
    double pos;
scalepicker.h
Show inline comments
 
@@ -22,6 +22,7 @@
 

	
 
#include <QObject>
 
#include <QMouseEvent>
 
#include <QPen>
 
#include <qwt_scale_widget.h>
 
#include <qwt_widget_overlay.h>
 

	
 
@@ -34,6 +35,7 @@ public:
 
    virtual bool eventFilter(QObject*, QEvent*);
 

	
 
    void drawOverlay(QPainter*); // called from ScalePickerOverlay
 
    void setPen(QPen pen);
 

	
 
signals:
 
    void pickStarted(double pos);
 
@@ -43,14 +45,16 @@ signals:
 
private:
 
    QwtScaleWidget* _scaleWidget;
 
    QwtWidgetOverlay* pickerOverlay; // ScalePickerOverlay
 
    double position(QMouseEvent*); // returns the axis mouse position relative to plot coordinates
 
    double positionPx(QMouseEvent*); // returns the axis mouse position in pixels
 
    QPen _pen;
 

	
 
    bool pressed;
 
    bool started;
 
    double firstPos; // converted to plot coordinates
 
    double firstPosPx; // pixel coordinates
 
    double currentPosPx; // current position in pixel coordinates
 

	
 
    double position(QMouseEvent*); // returns the axis mouse position relative to plot coordinates
 
    double positionPx(QMouseEvent*); // returns the axis mouse position in pixels
 
};
 

	
 
#endif // SCALEPICKER_H
scalezoomer.cpp
Show inline comments
 
@@ -32,6 +32,12 @@ ScaleZoomer::ScaleZoomer(QwtPlot* plot, 
 
    connect(&leftPicker, &ScalePicker::picked, this, &ScaleZoomer::leftPicked);
 
}
 

	
 
void ScaleZoomer::setPickerPen(QPen pen)
 
{
 
    bottomPicker.setPen(pen);
 
    leftPicker.setPen(pen);
 
}
 

	
 
void ScaleZoomer::bottomPicked(double firstPos, double lastPos)
 
{
 
    QRectF zRect;
scalezoomer.h
Show inline comments
 
@@ -21,6 +21,7 @@
 
#define SCALEZOOMER_H
 

	
 
#include <QObject>
 
#include <QPen>
 
#include <qwt_plot.h>
 
#include <qwt_plot_zoomer.h>
 

	
 
@@ -32,6 +33,7 @@ class ScaleZoomer : public QObject
 

	
 
public:
 
    ScaleZoomer(QwtPlot*, QwtPlotZoomer*);
 
    void setPickerPen(QPen pen);
 

	
 
private:
 
    QwtPlot* _plot;
0 comments (0 inline, 0 general)