⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 qwt_plot_picker.cpp

📁 软件无线电的平台
💻 CPP
字号:
/* -*- mode: C++ ; c-file-style: "stroustrup" -*- ***************************** * Qwt Widget Library * Copyright (C) 1997   Josef Wilgen * Copyright (C) 2002   Uwe Rathmann * * This library is free software; you can redistribute it and/or * modify it under the terms of the Qwt License, Version 1.0 *****************************************************************************/#include "qwt_plot.h"#include "qwt_double_rect.h"#include "qwt_painter.h"#include "qwt_array.h"#include "qwt_plot_picker.h"/*!  \brief Create a plot picker  The picker is set to those x- and y-axis of the plot  that are enabled. If both or no x-axis are enabled, the picker  is set to QwtPlot::xBottom. If both or no y-axis are  enabled, it is set to QwtPlot::yLeft.  \param canvas Plot canvas to observe, also the parent object  \param name Object name*/  QwtPlotPicker::QwtPlotPicker(QwtPlotCanvas *canvas, const char *name):    QwtPicker(canvas, name),    d_xAxis(-1),    d_yAxis(-1){    if ( !canvas )        return;    // attach axes    int xAxis = QwtPlot::xBottom;    const QwtPlot *plot = QwtPlotPicker::plot();    if ( !plot->axisEnabled(QwtPlot::xBottom) &&        plot->axisEnabled(QwtPlot::xTop) )    {        xAxis = QwtPlot::xTop;    }    int yAxis = QwtPlot::yLeft;    if ( !plot->axisEnabled(QwtPlot::yLeft) &&        plot->axisEnabled(QwtPlot::yRight) )    {        yAxis = QwtPlot::yRight;    }    setAxis(xAxis, yAxis);}/*!  Create a plot picker  \param xAxis Set the x axis of the picker  \param yAxis Set the y axis of the picker  \param canvas Plot canvas to observe, also the parent object  \param name Object name*/QwtPlotPicker::QwtPlotPicker(int xAxis, int yAxis,         QwtPlotCanvas *canvas, const char *name):    QwtPicker(canvas, name),    d_xAxis(xAxis),    d_yAxis(yAxis){}/*!  Create a plot picker  \param xAxis X axis of the picker  \param yAxis Y axis of the picker  \param selectionFlags Or磀 value of SelectionType, RectSelectionType and                        SelectionMode  \param rubberBand Rubberband style  \param cursorLabelMode Cursor label mode  \param canvas Plot canvas to observe, also the parent object  \param name Object name  \sa QwtPicker, QwtPicker::setSelectionFlags(), QwtPicker::setRubberBand(),      QwtPicker::setCursorLabelMode*/QwtPlotPicker::QwtPlotPicker(int xAxis, int yAxis, int selectionFlags,        RubberBand rubberBand, DisplayMode cursorLabelMode,        QwtPlotCanvas *canvas, const char *name):    QwtPicker(selectionFlags, rubberBand, cursorLabelMode, canvas, name),    d_xAxis(xAxis),    d_yAxis(yAxis){}//! Return observed plot canvasQwtPlotCanvas *QwtPlotPicker::canvas(){    QWidget *w = parentWidget();    if ( w && w->inherits("QwtPlotCanvas") )        return (QwtPlotCanvas *)w;    return NULL;}//! Return Observed plot canvasconst QwtPlotCanvas *QwtPlotPicker::canvas() const{    return ((QwtPlotPicker *)this)->canvas();}//! Return plot widget, containing the observed plot canvasQwtPlot *QwtPlotPicker::plot(){    QObject *w = canvas();    if ( w )    {        w = w->parent();        if ( w && w->inherits("QwtPlot") )            return (QwtPlot *)w;    }    return NULL;}//! Return plot widget, containing the observed plot canvasconst QwtPlot *QwtPlotPicker::plot() const{    return ((QwtPlotPicker *)this)->plot();}//! Return normalized bounding rect of the axesQwtDoubleRect QwtPlotPicker::scaleRect() const{    const QwtPlot *plt = plot();    const QwtDoubleRect rect(        plt->axisScale(xAxis())->lBound(),        plt->axisScale(xAxis())->hBound(),        plt->axisScale(yAxis())->lBound(),        plt->axisScale(yAxis())->hBound()    );    return rect.normalize();}/*!  Set the x and y axes of the picker  \param xAxis X axis  \param yAxis Y axis*/void QwtPlotPicker::setAxis(int xAxis, int yAxis){    const QwtPlot *plt = plot();    if ( !plt )        return;    if ( xAxis != d_xAxis || yAxis != d_yAxis )    {        d_xAxis = xAxis;        d_yAxis = yAxis;    }}//! Return x axisint QwtPlotPicker::xAxis() const{    return d_xAxis;}//! Return y axisint QwtPlotPicker::yAxis() const{    return d_yAxis;}/*!  Translate a pixel position into a position string  \param pos Position in pixel coordinates  \return Position string*/QString QwtPlotPicker::cursorLabel(const QPoint &pos) const{    return cursorLabel(invTransform(pos));}/*!  \brief Translate a position into a position string  In case of HLineRubberBand the label is the value of the  y position, in case of VLineRubberBand the value of the x position.  Otherwise the label contains x and y position separated by a 

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -