mirror of
https://github.com/jkriege2/JKQtPlotter.git
synced 2024-12-25 10:01:38 +08:00
added Qt data model that allows to switch all graphs between visible and invisible and shows all graphs in the plot + removed several warnings
This commit is contained in:
parent
c8c3b607b1
commit
0f8c308421
@ -35,7 +35,8 @@
|
||||
#include <QPrintPreviewWidget>
|
||||
#include <QDialog>
|
||||
#include "jkqtpbaseplotter.h"
|
||||
#include<QPrinter>
|
||||
#include "jkqtpplotsmodel.h"
|
||||
#include <QPrinter>
|
||||
#include <QPrinterInfo>
|
||||
#include <QPrintDialog>
|
||||
#include <QGridLayout>
|
||||
@ -144,7 +145,7 @@ QSizeF JKQtBasePlotter::getTextSizeSize(const QString &fontName, double fontSize
|
||||
* JKQtPlotterBase
|
||||
**************************************************************************************************************************/
|
||||
JKQtBasePlotter::JKQtBasePlotter(bool datastore_internal, QObject* parent, JKQTPdatastore* datast):
|
||||
QObject(parent)
|
||||
QObject(parent), m_plotsModel(nullptr), xAxis(nullptr), yAxis(nullptr)
|
||||
{
|
||||
|
||||
dataColumnsListWidget=NULL;
|
||||
@ -177,6 +178,8 @@ JKQtBasePlotter::JKQtBasePlotter(bool datastore_internal, QObject* parent, JKQTP
|
||||
|
||||
xAxis=new JKQTPhorizontalAxis(this);
|
||||
yAxis=new JKQTPverticalAxis(this);
|
||||
m_plotsModel=new JKQTPPlotsModel(this);
|
||||
connect(this, SIGNAL(plotUpdated()), m_plotsModel, SLOT(plotUpdated()));
|
||||
|
||||
|
||||
emitSignals=false;
|
||||
@ -4090,10 +4093,10 @@ void JKQtBasePlotter::setAllGraphsVisible()
|
||||
if (emitPlotSignals) emit plotUpdated();
|
||||
}
|
||||
|
||||
void JKQtBasePlotter::setGraphVisible(int i)
|
||||
void JKQtBasePlotter::setGraphVisible(int i, bool visible)
|
||||
{
|
||||
JKQTPgraph* g=graphs.value(i, NULL);
|
||||
if (g) g->set_visible(true);
|
||||
if (g) g->set_visible(visible);
|
||||
if (emitPlotSignals) emit plotUpdated();
|
||||
}
|
||||
|
||||
|
@ -68,7 +68,7 @@
|
||||
#define JKQTPBASEPLOTTER_H
|
||||
|
||||
|
||||
|
||||
class JKQTPPlotsModel; // forward
|
||||
|
||||
|
||||
/** \brief base class for 2D plotter classes
|
||||
@ -207,6 +207,9 @@ class LIB_EXPORT JKQtBasePlotter: public QObject {
|
||||
/** \brief object used for the y-axis */
|
||||
JKQTPverticalAxis* yAxis;
|
||||
|
||||
/** \brief model representing all Plots in this plotter and showing their visible/invisible state */
|
||||
JKQTPPlotsModel* m_plotsModel;
|
||||
|
||||
/** \brief filename for the ini file in which to save the user settings
|
||||
* \see jkqtplotter_base_userprops
|
||||
*/
|
||||
@ -237,7 +240,7 @@ class LIB_EXPORT JKQtBasePlotter: public QObject {
|
||||
double paintMagnification;
|
||||
|
||||
/** \brief the decimal separator used when exporting data to text files */
|
||||
JKQTPPROPERTY(QString, CSVdecimalSeparator);
|
||||
JKQTPPROPERTY(QString, CSVdecimalSeparator)
|
||||
/** \brief this string is used to introduce comments in text output when exporting data */
|
||||
JKQTPPROPERTY(QString, CSVcommentInitializer)
|
||||
|
||||
@ -256,7 +259,7 @@ class LIB_EXPORT JKQtBasePlotter: public QObject {
|
||||
|
||||
/** \brief free space between widget top border and plot top border, this property may be set by the user and is possibly altered
|
||||
* by the key positioning algorithm. The altered value is written to iplotBorderTop */
|
||||
JKQTPPROPERTY(int, plotBorderTop);
|
||||
JKQTPPROPERTY(int, plotBorderTop)
|
||||
/** \brief free space between widget top border and plot top border, as used to plot the graph (mnay be altered from user input ) */
|
||||
int iplotBorderTop;
|
||||
int iplotKeyBorderTop;
|
||||
@ -264,19 +267,19 @@ class LIB_EXPORT JKQtBasePlotter: public QObject {
|
||||
int iTitleHeight;
|
||||
/** \brief free space between widget left border and plot left border, this property may be set by the user and is possibly altered
|
||||
* by the key positioning algorithm. The altered value is written to iplotBorderLeft */
|
||||
JKQTPPROPERTY(int, plotBorderLeft);
|
||||
JKQTPPROPERTY(int, plotBorderLeft)
|
||||
/** \brief free space between widget top border and plot top border, as used to plot the graph (mnay be altered from user input ) */
|
||||
int iplotBorderLeft;
|
||||
int iplotKeyBorderLeft;
|
||||
/** \brief free space between widget bottom border and plot bottom border, this property may be set by the user and is possibly altered
|
||||
* by the key positioning algorithm. The altered value is written to iplotBorderBottom */
|
||||
JKQTPPROPERTY(int, plotBorderBottom);
|
||||
JKQTPPROPERTY(int, plotBorderBottom)
|
||||
/** \brief free space between widget top border and plot top border, as used to plot the graph (mnay be altered from user input ) */
|
||||
int iplotBorderBottom;
|
||||
int iplotKeyBorderBottom;
|
||||
/** \brief free space between widget right border and plot right border, this property may be set by the user and is possibly altered
|
||||
* by the key positioning algorithm. The altered value is written to iplotBorderRight */
|
||||
JKQTPPROPERTY(int, plotBorderRight);
|
||||
JKQTPPROPERTY(int, plotBorderRight)
|
||||
/** \brief free space between widget top border and plot top border, as used to plot the graph (mnay be altered from user input ) */
|
||||
int iplotBorderRight;
|
||||
int iplotKeyBorderRight;
|
||||
@ -293,14 +296,14 @@ class LIB_EXPORT JKQtBasePlotter: public QObject {
|
||||
int iplotBorderRight_nographs;
|
||||
|
||||
/** \brief indicates whether the widget should maintain an aspect ratio of plotwidth and plotheight */
|
||||
JKQTPPROPERTY(bool, maintainAspectRatio);
|
||||
JKQTPPROPERTY(bool, maintainAspectRatio)
|
||||
/** \brief the aspect ratio of plotwidth and plotheight to maintain, if \c maintainAspectRatio==true */
|
||||
JKQTPPROPERTY(double, aspectRatio);
|
||||
JKQTPPROPERTY(double, aspectRatio)
|
||||
|
||||
/** \brief indicates whether the axes should maintain an aspect ratio */
|
||||
JKQTPPROPERTY(bool, maintainAxisAspectRatio);
|
||||
JKQTPPROPERTY(bool, maintainAxisAspectRatio)
|
||||
/** \brief the aspect ratio of axis widths to maintain, if \c maintainAxisAspectRatio==true */
|
||||
JKQTPPROPERTY(double, axisAspectRatio);
|
||||
JKQTPPROPERTY(double, axisAspectRatio)
|
||||
|
||||
/** \brief plot width in pixels inside the widget (calculated by calcPlotScaling() from plotBorderLeft, plotBorderRight and widgetWidth) */
|
||||
int plotWidth;
|
||||
@ -310,16 +313,16 @@ class LIB_EXPORT JKQtBasePlotter: public QObject {
|
||||
|
||||
|
||||
/** \brief color of the plotted graph */
|
||||
JKQTPPROPERTY(QColor, graphColor);
|
||||
JKQTPPROPERTY(QColor, graphColor)
|
||||
/** \brief colors used in modes where more than one graph is beeing plottet */
|
||||
QColor manyGraphsColor[50];
|
||||
QColor def_manyGraphsColor[50];
|
||||
/** \brief number of actually defined items in manyGraphsColor */
|
||||
int manyGraphsColorCount;
|
||||
/** \brief pen styles used in modes where more than one graph is beeing plottet */
|
||||
JKQTPPROPERTY(Qt::PenStyle, manyGraphsStyle[5]);
|
||||
JKQTPPROPERTY(Qt::PenStyle, manyGraphsStyle[5])
|
||||
/** \brief width of the plotted graph (in pixel) */
|
||||
JKQTPPROPERTY(double, graphWidth);
|
||||
JKQTPPROPERTY(double, graphWidth)
|
||||
|
||||
|
||||
|
||||
@ -329,64 +332,64 @@ class LIB_EXPORT JKQtBasePlotter: public QObject {
|
||||
|
||||
|
||||
/** \brief color of the coordinate system */
|
||||
JKQTPPROPERTY(QColor, systemColor);
|
||||
JKQTPPROPERTY(QColor, systemColor)
|
||||
/** \brief width of the coordinate (in pixel) */
|
||||
JKQTPPROPERTY(double, systemWidth);
|
||||
JKQTPPROPERTY(double, systemWidth)
|
||||
/** \brief color of the background*/
|
||||
JKQTPPROPERTY(QColor, backgroundColor);
|
||||
JKQTPPROPERTY(QColor, backgroundColor)
|
||||
/** \brief color of the background when exporting*/
|
||||
JKQTPPROPERTY(QColor, exportBackgroundColor);
|
||||
JKQTPPROPERTY(QColor, exportBackgroundColor)
|
||||
/** \brief color of the plot's background*/
|
||||
JKQTPPROPERTY(QColor, plotBackgroundColor);
|
||||
JKQTPPROPERTY(QColor, plotBackgroundColor)
|
||||
|
||||
|
||||
/** \brief indicates whether to plot a frame around the key */
|
||||
JKQTPPROPERTY(bool, showKeyFrame);
|
||||
JKQTPPROPERTY(bool, showKeyFrame)
|
||||
/** \brief color of the key frame line */
|
||||
JKQTPPROPERTY(QColor, keyFrameColor);
|
||||
JKQTPPROPERTY(QColor, keyFrameColor)
|
||||
/** \brief width of the key frame line */
|
||||
JKQTPPROPERTY(double, keyFrameWidth);
|
||||
JKQTPPROPERTY(double, keyFrameWidth)
|
||||
/** \brief color of the key background */
|
||||
JKQTPPROPERTY(QColor, keyBackgroundColor);
|
||||
JKQTPPROPERTY(QColor, keyBackgroundColor)
|
||||
/** \brief indicates whether to plot a key */
|
||||
JKQTPPROPERTY(bool, showKey);
|
||||
JKQTPPROPERTY(bool, showKey)
|
||||
/** \brief font face for key labels */
|
||||
JKQTPPROPERTY(QString, keyFont);
|
||||
JKQTPPROPERTY(QString, keyFont)
|
||||
/** \brief font size for key labels [in points] */
|
||||
JKQTPPROPERTY(double, keyFontSize);
|
||||
JKQTPPROPERTY(double, keyFontSize)
|
||||
/** \brief width of a key item in pixels [in units of width of 'X' set in keyFont, keyFontSize] */
|
||||
JKQTPPROPERTY(double, key_item_width);
|
||||
JKQTPPROPERTY(double, key_item_width)
|
||||
/** \brief height of a key item in pixels [in units of height keyFont, keyFontSize] */
|
||||
JKQTPPROPERTY(double, key_item_height);
|
||||
JKQTPPROPERTY(double, key_item_height)
|
||||
/** \brief length of the line samples in the key in pixels [in units of width of 'X' set in keyFont, keyFontSize] */
|
||||
JKQTPPROPERTY(double, key_line_length);
|
||||
JKQTPPROPERTY(double, key_line_length)
|
||||
/** \brief x-distance between key frame and key content [in units of width of 'X' set in keyFont, keyFontSize] */
|
||||
JKQTPPROPERTY(double, keyXMargin);
|
||||
JKQTPPROPERTY(double, keyXMargin)
|
||||
/** \brief y-distance between key frame and key content [in units of width of 'x' set in keyFont, keyFontSize] */
|
||||
JKQTPPROPERTY(double, keyYMargin);
|
||||
JKQTPPROPERTY(double, keyYMargin)
|
||||
/** \brief x-offset of the key from the border of the plot [in units of width of 'X' set in keyFont, keyFontSize] */
|
||||
JKQTPPROPERTY(double, keyXOffset);
|
||||
JKQTPPROPERTY(double, keyXOffset)
|
||||
/** \brief y-offset of the key from the border of the plot [in units of width of 'x' set in keyFont, keyFontSize] */
|
||||
JKQTPPROPERTY(double, keyYOffset);
|
||||
JKQTPPROPERTY(double, keyYOffset)
|
||||
/** \brief distance between key line example and key text [in units of width of 'X' set in keyFont, keyFontSize] */
|
||||
JKQTPPROPERTY(double, keyXSeparation);
|
||||
JKQTPPROPERTY(double, keyXSeparation)
|
||||
/** \brief distance between two key entries [in units of height of keyFont, keyFontSize] */
|
||||
JKQTPPROPERTY(double, keyYSeparation);
|
||||
JKQTPPROPERTY(double, keyYSeparation)
|
||||
/** \brief key position */
|
||||
JKQTPPROPERTY(JKQTPkeyPosition, keyPosition);
|
||||
JKQTPPROPERTY(JKQTPkeyPosition, keyPosition)
|
||||
/** \brief the key layout */
|
||||
JKQTPPROPERTY(JKQTPkeyLayout, keyLayout);
|
||||
JKQTPPROPERTY(JKQTPkeyLayout, keyLayout)
|
||||
/** \brief determine width of the key automatically */
|
||||
JKQTPPROPERTY(bool, keyAutosize);
|
||||
JKQTPPROPERTY(bool, keyAutosize)
|
||||
|
||||
/** \brief the plot label text */
|
||||
QString plotLabel;
|
||||
|
||||
/** \brief the plot label font name */
|
||||
JKQTPPROPERTY(QString, plotLabelFontname);
|
||||
JKQTPPROPERTY(QString, plotLabelFontname)
|
||||
|
||||
/** \brief the plot label font size */
|
||||
JKQTPPROPERTY(double, plotLabelFontSize);
|
||||
JKQTPPROPERTY(double, plotLabelFontSize)
|
||||
|
||||
/** \brief calculate the scaling and offset values from axis min/max values */
|
||||
void calcPlotScaling(JKQTPEnhancedPainter& painter);
|
||||
@ -398,20 +401,20 @@ class LIB_EXPORT JKQtBasePlotter: public QObject {
|
||||
bool emitSignals;
|
||||
|
||||
/** \brief specifies whether to use antialiasing for plotting the coordinate system */
|
||||
JKQTPPROPERTY(bool, useAntiAliasingForSystem);
|
||||
JKQTPPROPERTY(bool, useAntiAliasingForSystem)
|
||||
|
||||
/** \brief specifies whether to use antialiasing for plotting the graphs
|
||||
*
|
||||
* \note You can set this property \c false to increase plotting speed of complex plots (with many graphs inside). You can reach a
|
||||
* roughly three-fold speed improvement!
|
||||
*/
|
||||
JKQTPPROPERTY(bool, useAntiAliasingForGraphs);
|
||||
JKQTPPROPERTY(bool, useAntiAliasingForGraphs)
|
||||
|
||||
/** \brief specifies whether to use antialiasing when drawing any text
|
||||
* \note You can set this property \c false to increase plotting speed of complex plots (with many graphs inside). You can reach a
|
||||
* roughly three-fold speed improvement!
|
||||
*/
|
||||
JKQTPPROPERTY(bool, useAntiAliasingForText);
|
||||
JKQTPPROPERTY(bool, useAntiAliasingForText)
|
||||
|
||||
/** \brief multiplier which is used for font sizes when the plot is exported/printed */
|
||||
double fontSizePrintMultiplier;
|
||||
@ -442,7 +445,7 @@ class LIB_EXPORT JKQtBasePlotter: public QObject {
|
||||
|
||||
|
||||
/** \brief hidden default constructor */
|
||||
JKQtBasePlotter() {};
|
||||
JKQtBasePlotter() {}
|
||||
|
||||
|
||||
|
||||
@ -752,7 +755,10 @@ class LIB_EXPORT JKQtBasePlotter: public QObject {
|
||||
virtual ~JKQtBasePlotter();
|
||||
|
||||
/** \brief returns a pointer to the datastore used by this object */
|
||||
inline JKQTPdatastore* getDatastore() { return datastore; };
|
||||
inline JKQTPdatastore* getDatastore() { return datastore; }
|
||||
|
||||
/** \brief returns model representing all Plots in this plotter and showing their visible/invisible state */
|
||||
inline JKQTPPlotsModel* getPlotsModel() { return m_plotsModel; }
|
||||
|
||||
/** \brief tells the plotter object to use the given external datastore.
|
||||
*
|
||||
@ -806,10 +812,10 @@ class LIB_EXPORT JKQtBasePlotter: public QObject {
|
||||
void resize(int width, int height);
|
||||
|
||||
/** \brief gets the width of the plot widget */
|
||||
inline int getWidth() {return widgetWidth; };
|
||||
inline int getWidth() {return widgetWidth; }
|
||||
|
||||
/** \brief gets the width of the plot widget */
|
||||
inline int getHeight() {return widgetHeight; };
|
||||
inline int getHeight() {return widgetHeight; }
|
||||
|
||||
/** \brief sets the width of the plot widget */
|
||||
void setHeight(int heigh);
|
||||
@ -827,16 +833,16 @@ class LIB_EXPORT JKQtBasePlotter: public QObject {
|
||||
void setXY(double xminn, double xmaxx, double yminn, double ymaxx);
|
||||
|
||||
/** \brief returns the current x-axis min */
|
||||
inline double getXMin() const {return xAxis->getMin(); };
|
||||
inline double getXMin() const {return xAxis->getMin(); }
|
||||
|
||||
/** \brief returns the current x-axis max */
|
||||
inline double getXMax() const {return xAxis->getMax(); };
|
||||
inline double getXMax() const {return xAxis->getMax(); }
|
||||
|
||||
/** \brief returns the current y-axis min */
|
||||
inline double getYMin() const {return yAxis->getMin(); };
|
||||
inline double getYMin() const {return yAxis->getMin(); }
|
||||
|
||||
/** \brief returns the current y-axis max */
|
||||
inline double getYMax() const {return yAxis->getMax(); };
|
||||
inline double getYMax() const {return yAxis->getMax(); }
|
||||
|
||||
|
||||
|
||||
@ -1121,7 +1127,7 @@ class LIB_EXPORT JKQtBasePlotter: public QObject {
|
||||
|
||||
void setAllGraphsInvisible();
|
||||
void setAllGraphsVisible();
|
||||
void setGraphVisible(int i);
|
||||
void setGraphVisible(int i, bool visible=true);
|
||||
|
||||
/** \brief add a new graph, returns it's position in the graphs list, if the graph is already in the plot, this returns the index in the list */
|
||||
size_t addGraph(JKQTPgraph* gr);
|
||||
|
@ -16,7 +16,8 @@ HEADERS += $$PWD/jkqtpbaseplotter.h \
|
||||
$$PWD/jkqtpoverlayelements.h \
|
||||
$$PWD/jkqtpgeoelements.h \
|
||||
$$PWD/jkqtpmathparser.h \
|
||||
$$PWD/jkqtp_imexport.h
|
||||
$$PWD/jkqtp_imexport.h \
|
||||
$$PWD/jkqtpplotsmodel.h
|
||||
|
||||
|
||||
SOURCES += $$PWD/jkqtpbaseplotter.cpp \
|
||||
@ -32,7 +33,8 @@ SOURCES += $$PWD/jkqtpbaseplotter.cpp \
|
||||
$$PWD/jkqtpparsedfunctionelements.cpp \
|
||||
$$PWD/jkqtpoverlayelements.cpp \
|
||||
$$PWD/jkqtpgeoelements.cpp \
|
||||
$$PWD/jkqtpmathparser.cpp
|
||||
$$PWD/jkqtpmathparser.cpp \
|
||||
$$PWD/jkqtpplotsmodel.cpp
|
||||
|
||||
|
||||
RESOURCES += $$PWD/jkqtpbaseplotter.qrc
|
||||
|
89
jkqtpplotsmodel.cpp
Normal file
89
jkqtpplotsmodel.cpp
Normal file
@ -0,0 +1,89 @@
|
||||
/*
|
||||
Copyright (c) 2008-2018 Jan W. Krieger (<jan@jkrieger.de>, <j.krieger@dkfz.de>), German Cancer Research Center
|
||||
|
||||
|
||||
|
||||
This software is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Lesser General Public License (LGPL) as published by
|
||||
the Free Software Foundation, either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Lesser General Public License (LGPL) for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public License (LGPL)
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
|
||||
|
||||
/** \file jkqtpplotsmodel.cpp
|
||||
* \ingroup jkqtpbaseplotter
|
||||
*/
|
||||
|
||||
#include "jkqtpplotsmodel.h"
|
||||
#include "jkqtpbaseplotter.h"
|
||||
#include "jkqtptools.h"
|
||||
#include <QImage>
|
||||
|
||||
|
||||
|
||||
JKQTPPlotsModel::JKQTPPlotsModel(JKQtBasePlotter *parent):
|
||||
QAbstractTableModel(parent), m_plotter(parent)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
int JKQTPPlotsModel::rowCount(const QModelIndex &/*parent*/) const
|
||||
{
|
||||
return static_cast<int>(m_plotter->getGraphCount());
|
||||
}
|
||||
|
||||
int JKQTPPlotsModel::columnCount(const QModelIndex &/*parent*/) const
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
QVariant JKQTPPlotsModel::data(const QModelIndex &index, int role) const
|
||||
{
|
||||
if (role == Qt::DisplayRole) {
|
||||
if (index.row()<m_plotter->getGraphCount()) return m_plotter->getGraph(index.row())->get_title();
|
||||
} else if (role == Qt::CheckStateRole) {
|
||||
if (index.row()<m_plotter->getGraphCount()) return m_plotter->getGraph(index.row())->get_visible()?Qt::Checked:Qt::Unchecked;
|
||||
} else if (role == Qt::DecorationRole) {
|
||||
if (index.row()<m_plotter->getGraphCount()) {
|
||||
QImage img(16,16,QImage::Format_ARGB32);
|
||||
{
|
||||
JKQTPEnhancedPainter painter(&img);
|
||||
QRectF rect(0,0,16,16);
|
||||
m_plotter->getGraph(index.row())->drawKeyMarker(painter, rect);
|
||||
}
|
||||
return img;
|
||||
}
|
||||
}
|
||||
return QVariant();
|
||||
}
|
||||
|
||||
bool JKQTPPlotsModel::setData(const QModelIndex &index, const QVariant &value, int role)
|
||||
{
|
||||
if (role == Qt::CheckStateRole) {
|
||||
if (index.row()<m_plotter->getGraphCount()) {
|
||||
m_plotter->setGraphVisible(index.row(), value.toBool());
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
Qt::ItemFlags JKQTPPlotsModel::flags(const QModelIndex &index) const
|
||||
{
|
||||
return Qt::ItemIsUserCheckable | QAbstractTableModel::flags(index);
|
||||
}
|
||||
|
||||
void JKQTPPlotsModel::plotUpdated()
|
||||
{
|
||||
beginResetModel();
|
||||
endResetModel();
|
||||
}
|
60
jkqtpplotsmodel.h
Normal file
60
jkqtpplotsmodel.h
Normal file
@ -0,0 +1,60 @@
|
||||
/*
|
||||
Copyright (c) 2008-2018 Jan W. Krieger (<jan@jkrieger.de>, <j.krieger@dkfz.de>), German Cancer Research Center (DKFZ) & IWR, University of Heidelberg
|
||||
|
||||
|
||||
|
||||
This software is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Lesser General Public License (LGPL) as published by
|
||||
the Free Software Foundation, either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Lesser General Public License (LGPL) for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public License (LGPL)
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* \defgroup jkqtpplotsmodel data model with all plots ina JKQtBasePlotter (+ allows to switch them visible/invisible)
|
||||
* \ingroup jkqtpbaseplotter
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
/** \file jkqtpplotsmodel.h
|
||||
* \ingroup jkqtpbaseplotter
|
||||
*/
|
||||
|
||||
#ifndef JKQTPPLOTSMODEL_H
|
||||
#define JKQTPPLOTSMODEL_H
|
||||
|
||||
#include "jkqtpbaseplotter.h"
|
||||
#include "jkqtp_imexport.h"
|
||||
|
||||
#include <QAbstractTableModel>
|
||||
|
||||
class JKQtBasePlotter; // forward
|
||||
/** \brief data model with all plots ina JKQtBasePlotter (+ allows to switch them visible/invisible) */
|
||||
class JKQTPPlotsModel : public QAbstractTableModel
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
JKQTPPlotsModel(JKQtBasePlotter *parent);
|
||||
int rowCount(const QModelIndex &parent = QModelIndex()) const override ;
|
||||
int columnCount(const QModelIndex &parent = QModelIndex()) const override;
|
||||
QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override;
|
||||
bool setData(const QModelIndex & index, const QVariant & value, int role = Qt::EditRole) override;
|
||||
Qt::ItemFlags flags(const QModelIndex & index) const override ;
|
||||
public slots:
|
||||
void plotUpdated();
|
||||
private:
|
||||
JKQtBasePlotter* m_plotter;
|
||||
};
|
||||
|
||||
|
||||
#endif // JKQTPPLOTSMODEL_H
|
48
jkqtptools.h
48
jkqtptools.h
@ -151,24 +151,24 @@
|
||||
inline virtual void set_##varname (const typedef_set_##varname & __value) \
|
||||
{ \
|
||||
this->varname = __value; \
|
||||
}; \
|
||||
} \
|
||||
/** \brief returns the property varname. \see varname for more information */ \
|
||||
inline virtual type get_##varname () const \
|
||||
{\
|
||||
return this->varname; \
|
||||
};
|
||||
}
|
||||
#define JKQTPGET_SET_VMACRO(type,varname) \
|
||||
typedef type typedef_set_##varname ;\
|
||||
/** \brief sets the property varname to the specified \a __value. \details Description of the parameter varname is: <CENTER>\copybrief varname.</CENTER> \see varname for more information */ \
|
||||
inline virtual void set_##varname (const typedef_set_##varname & __value) \
|
||||
{ \
|
||||
this->varname = __value; \
|
||||
}; \
|
||||
} \
|
||||
/** \brief returns the property varname. \see varname for more information */ \
|
||||
inline virtual type get_##varname () const \
|
||||
{\
|
||||
return this->varname; \
|
||||
};
|
||||
}
|
||||
#define JKQTPGetSetMacro(type,varname) JKQTPGET_SET_MACRO(type,varname)
|
||||
|
||||
/**
|
||||
@ -184,11 +184,11 @@
|
||||
{ \
|
||||
this->varname = __value; \
|
||||
this-> paramsChanged=true; \
|
||||
}; \
|
||||
} \
|
||||
inline virtual type get_##varname () const /** \brief returns the property varname. \see varname for more information */ \
|
||||
{\
|
||||
return this->varname; \
|
||||
};
|
||||
}
|
||||
#define JKQTPGetSetMacroP(type,varname) JKQTPGET_SET_MACRO_P(type,varname)
|
||||
|
||||
/**
|
||||
@ -205,12 +205,12 @@
|
||||
this-> paramsChanged=true; \
|
||||
inst; \
|
||||
} \
|
||||
}; \
|
||||
} \
|
||||
/** \brief returns the property varname. \see varname for more information */ \
|
||||
inline virtual type get_##varname () const \
|
||||
{ \
|
||||
return this->varname; \
|
||||
};
|
||||
}
|
||||
#define JKQTPGetSetMacroIP(type,varname,inst) JKQTPGET_SET_MACRO_IP(type,varname,inst)
|
||||
|
||||
/**
|
||||
@ -226,12 +226,12 @@
|
||||
this->varname = __value; \
|
||||
inst; \
|
||||
} \
|
||||
}; \
|
||||
} \
|
||||
/** \brief returns the property varname. \see varname for more information */ \
|
||||
inline virtual type get_##varname () const \
|
||||
{\
|
||||
return this->varname; \
|
||||
};
|
||||
}
|
||||
#define JKQTPGetSetMacroI(type,varname,inst) JKQTPGET_SET_MACRO_I(type,varname,inst)
|
||||
|
||||
/**
|
||||
@ -249,17 +249,17 @@
|
||||
if (this->varname2 != __value2) { \
|
||||
this->varname2 = __value2; \
|
||||
} \
|
||||
}; \
|
||||
} \
|
||||
/** \brief returns the property varname. \see varname for more information */ \
|
||||
inline virtual type get_##varname () const \
|
||||
{\
|
||||
return this->varname; \
|
||||
}; \
|
||||
} \
|
||||
/** \brief returns the property varname2. \see varname2 for more information */\
|
||||
inline virtual type2 get_##varname2 () const \
|
||||
{\
|
||||
return this->varname2; \
|
||||
};
|
||||
}
|
||||
#define JKQTPGetSetMacroTwo(name,type,varname,type2,varname2) JKQTPGET_SET_MACRO_TWO(name,type,varname,type2,varname2)
|
||||
|
||||
/**
|
||||
@ -282,17 +282,17 @@
|
||||
if (set) { \
|
||||
inst; \
|
||||
} \
|
||||
}; \
|
||||
} \
|
||||
/** \brief returns the property varname. \see varname for more information */ \
|
||||
inline virtual type get_##varname () const \
|
||||
{\
|
||||
return this->varname; \
|
||||
}; \
|
||||
} \
|
||||
/** \brief returns the property varname2. \see varname2 for more information */ \
|
||||
inline virtual type2 get_##varname2 () const \
|
||||
{\
|
||||
return this->varname2; \
|
||||
};
|
||||
}
|
||||
#define JKQTPGetSetMacroTwoI(name,type,varname,type2,varname2,inst) JKQTPGET_SET_MACRO_TWO_I(name,type,varname,type2,varname2,inst)
|
||||
|
||||
|
||||
@ -308,12 +308,12 @@
|
||||
{\
|
||||
this->varname = __value; \
|
||||
inst; \
|
||||
}; \
|
||||
} \
|
||||
/** \brief returns the property varname. \see varname for more information */ \
|
||||
inline virtual type get_##varname () const \
|
||||
{\
|
||||
return this->varname; \
|
||||
};
|
||||
}
|
||||
#define JKQTPGetSetMacroINC(type,varname,inst) JKQTPGET_SET_MACRO_INC(type,varname,inst)
|
||||
|
||||
/** \brief create get_varname() and set_varname(type __value) methods/functions
|
||||
@ -324,7 +324,7 @@
|
||||
#define JKQTPGET_MACRO(type,varname) \
|
||||
/** \brief returns the property varname. \details Description of the parameter varname is: <CENTER>\copybrief varname.</CENTER>. \see varname for more information */ \
|
||||
inline virtual type get_##varname() const \
|
||||
{ return this->varname; };
|
||||
{ return this->varname; }
|
||||
|
||||
#define JKQTPGetMacro(type,varname) JKQTPGET_MACRO(type,varname)
|
||||
|
||||
@ -340,7 +340,7 @@
|
||||
inline virtual void set_##varname (const typedef_set_##varname & __value) \
|
||||
{ \
|
||||
this->varname = __value; \
|
||||
};
|
||||
}
|
||||
#define JKQTPSetMacro(type,varname) JKQTPSET_MACRO(type,varname)
|
||||
|
||||
/**
|
||||
@ -359,7 +359,7 @@
|
||||
this->varname = __value; \
|
||||
this->paramsChanged=true; \
|
||||
} \
|
||||
};
|
||||
}
|
||||
#define JKQTPSetMacroP(type,varname) JKQTPSET_MACRO_P(type,varname)
|
||||
|
||||
/**
|
||||
@ -375,7 +375,7 @@
|
||||
this->varname = __value; \
|
||||
inst; \
|
||||
} \
|
||||
};
|
||||
}
|
||||
#define JKQTPSetMacroI(type,varname,inst) JKQTPSET_MACRO_I(type,varname,inst)
|
||||
|
||||
/**
|
||||
@ -391,7 +391,7 @@
|
||||
if (this->varname != __value) { \
|
||||
this->varname = __value; \
|
||||
} \
|
||||
};
|
||||
}
|
||||
#define JKQTPSetMacroIBefore(type,varname,inst) JKQTPSET_MACRO_I_BEFORE(type,varname,inst)
|
||||
/**
|
||||
* \brief like SetMacroP(), but adds the instruction \a inst to the set method. This may be used
|
||||
@ -407,7 +407,7 @@
|
||||
this->paramsChanged=true; \
|
||||
inst; \
|
||||
} \
|
||||
};
|
||||
}
|
||||
#define JKQTPSetMacroIP(type,varname,inst) JKQTPSET_MACRO_IP(type,varname,inst)
|
||||
/*@}*/
|
||||
|
||||
|
@ -51,9 +51,16 @@ TestMain::TestMain(QWidget *parent) :
|
||||
plotBot->get_plotter()->set_userSettigsFilename(QApplication::applicationDirPath()+"/usersettings.ini", "plot/");
|
||||
plotBot2->get_plotter()->set_userSettigsFilename(QApplication::applicationDirPath()+"/usersettings.ini", "plot/");
|
||||
|
||||
QListView* listPlots=new QListView(win);
|
||||
listPlots->setModel(plot->get_plotter()->getPlotsModel());
|
||||
listPlots->setMaximumWidth(256);
|
||||
QVBoxLayout* layout=new QVBoxLayout(win);
|
||||
layout->addWidget(plot);
|
||||
layout->addWidget(plotBot);
|
||||
QGridLayout* layout_grid=new QGridLayout(win);
|
||||
layout_grid->addWidget(plot,0,0,1,1);
|
||||
layout_grid->addWidget(plotBot,1,0,1,1);
|
||||
layout_grid->addWidget(listPlots,0,1,1,1);
|
||||
layout_grid->setColumnStretch(0,1);
|
||||
layout->addLayout(layout_grid);
|
||||
layout->addWidget(plotBot2);
|
||||
win->setLayout(layout);
|
||||
win->resize(1000, 800);
|
||||
|
@ -16,6 +16,7 @@
|
||||
#include "../../jkqtpoverlayelements.h"
|
||||
#include "../../jkqtpparsedfunctionelements.h"
|
||||
#include "../../jkqtpbaseelements.h"
|
||||
#include "../../jkqtpplotsmodel.h"
|
||||
#include "../../jkqtptools.h"
|
||||
|
||||
#define N1 200
|
||||
|
Loading…
Reference in New Issue
Block a user