mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-21 21:05:31 +08:00
Ref T509, changed to Qwt (instead of QChart) using bar chart
This commit is contained in:
committed by
Mat Sutcliffe
parent
3fa25798ce
commit
dba043c23f
81
src/blackgui/graphs/barchart.h
Normal file
81
src/blackgui/graphs/barchart.h
Normal file
@@ -0,0 +1,81 @@
|
||||
/* Copyright (C) 2019
|
||||
* swift project Community / Contributors
|
||||
*
|
||||
* This file is part of swift project. It is subject to the license terms in the LICENSE file found in the top-level
|
||||
* directory of this distribution and at http://www.swift-project.org/license.html. No part of swift project,
|
||||
* including this file, may be copied, modified, propagated, or distributed except according to the terms
|
||||
* contained in the LICENSE file.
|
||||
*/
|
||||
|
||||
//! \file
|
||||
|
||||
#ifndef BLACKGUI_GRAPH_BARCHART_H
|
||||
#define BLACKGUI_GRAPH_BARCHART_H
|
||||
|
||||
#include "blackgui/blackguiexport.h"
|
||||
|
||||
#include <qwt_plot.h>
|
||||
#include <qwt_scale_draw.h>
|
||||
#include <qwt_plot_multi_barchart.h>
|
||||
|
||||
#include <QScopedPointer>
|
||||
#include <QStringList>
|
||||
#include <QList>
|
||||
|
||||
namespace BlackGui
|
||||
{
|
||||
namespace Graphs
|
||||
{
|
||||
/**
|
||||
* For axis labels
|
||||
*/
|
||||
class CTextScaleDraw: public QwtScaleDraw
|
||||
{
|
||||
public:
|
||||
//! Constructorxs
|
||||
CTextScaleDraw(const QStringList &texts);
|
||||
|
||||
//! Value to label
|
||||
virtual QwtText label(double v) const override;
|
||||
|
||||
//! Labels
|
||||
void setLabels(const QStringList &labels) { m_labels = labels; }
|
||||
|
||||
//! Any labels?
|
||||
bool hasLabels() const { return !m_labels.isEmpty(); }
|
||||
|
||||
private:
|
||||
QStringList m_labels;
|
||||
};
|
||||
|
||||
/**
|
||||
* Bar chart, modified version of QWT examples
|
||||
*/
|
||||
class BLACKGUI_EXPORT CBarChart: public QwtPlot
|
||||
{
|
||||
public:
|
||||
//! Constructor
|
||||
CBarChart(QWidget * = nullptr);
|
||||
|
||||
//! Style
|
||||
void setStyle(QwtPlotMultiBarChart::ChartStyle style);
|
||||
|
||||
//! Set number of symbols
|
||||
void setSymbols(const QString &title, const QString &color);
|
||||
|
||||
//! Set number of symbols
|
||||
void setSymbols(const QStringList &titles, const QStringList &colors);
|
||||
|
||||
//! Samples with 1 bar per sample
|
||||
void setSamples1Bar(const QList<double> &samples, const QStringList &labels, Qt::Orientation orientation);
|
||||
|
||||
private:
|
||||
//! Orientation
|
||||
void setOrientation(Qt::Orientation, const QStringList &labels);
|
||||
|
||||
QScopedPointer<QwtPlotMultiBarChart> m_barChartItem;
|
||||
};
|
||||
} // ns
|
||||
} // ns
|
||||
|
||||
#endif
|
||||
Reference in New Issue
Block a user