mirror of
https://gitlab.com/pholy/OSCAR-code.git
synced 2025-04-19 04:00:45 +00:00
Added Min/Max YAxis editor to Context menu
This commit is contained in:
parent
514d88c68a
commit
0e8972358a
@ -15,7 +15,6 @@
|
|||||||
#include <QTimer>
|
#include <QTimer>
|
||||||
#include <QFontMetrics>
|
#include <QFontMetrics>
|
||||||
#include <QWidgetAction>
|
#include <QWidgetAction>
|
||||||
#include <QCheckBox>
|
|
||||||
|
|
||||||
#if QT_VERSION >= QT_VERSION_CHECK(5,0,0)
|
#if QT_VERSION >= QT_VERSION_CHECK(5,0,0)
|
||||||
# include <QWindow>
|
# include <QWindow>
|
||||||
@ -357,6 +356,7 @@ gGraphView::gGraphView(QWidget *parent, gGraphView *shared)
|
|||||||
context_menu->addAction(tr("Reset Graph Layout"), this, SLOT(resetLayout()));
|
context_menu->addAction(tr("Reset Graph Layout"), this, SLOT(resetLayout()));
|
||||||
|
|
||||||
context_menu->addSeparator();
|
context_menu->addSeparator();
|
||||||
|
limits_menu = context_menu->addMenu(tr("Graph Limits"));
|
||||||
plots_menu = context_menu->addMenu(tr("Plots"));
|
plots_menu = context_menu->addMenu(tr("Plots"));
|
||||||
connect(plots_menu, SIGNAL(triggered(QAction*)), this, SLOT(onPlotsClicked(QAction*)));
|
connect(plots_menu, SIGNAL(triggered(QAction*)), this, SLOT(onPlotsClicked(QAction*)));
|
||||||
|
|
||||||
@ -370,6 +370,7 @@ gGraphView::gGraphView(QWidget *parent, gGraphView *shared)
|
|||||||
|
|
||||||
lines_menu = context_menu->addMenu(tr("Dotted Lines"));
|
lines_menu = context_menu->addMenu(tr("Dotted Lines"));
|
||||||
connect(lines_menu, SIGNAL(triggered(QAction*)), this, SLOT(onLinesClicked(QAction*)));
|
connect(lines_menu, SIGNAL(triggered(QAction*)), this, SLOT(onLinesClicked(QAction*)));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void gGraphView::togglePin()
|
void gGraphView::togglePin()
|
||||||
@ -1662,6 +1663,46 @@ protected:
|
|||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
MinMaxWidget::MinMaxWidget(gGraph * graph, QWidget *parent): QWidget(parent), graph(graph)
|
||||||
|
{
|
||||||
|
|
||||||
|
// setWindowFlags(windowFlags() | Qt::Popup);
|
||||||
|
createLayout();
|
||||||
|
}
|
||||||
|
|
||||||
|
void MinMaxWidget::onMinChanged(double d)
|
||||||
|
{
|
||||||
|
graph->rec_miny = d;
|
||||||
|
graph->timedRedraw(0);
|
||||||
|
}
|
||||||
|
void MinMaxWidget::onMaxChanged(double d)
|
||||||
|
{
|
||||||
|
graph->rec_maxy = d;
|
||||||
|
graph->timedRedraw(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
void MinMaxWidget::createLayout()
|
||||||
|
{
|
||||||
|
QHBoxLayout *layout = new QHBoxLayout;
|
||||||
|
layout->setMargin(4);
|
||||||
|
layout->setSpacing(4);
|
||||||
|
checkbox = new QCheckBox(" ",this);
|
||||||
|
checkbox->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::MinimumExpanding);
|
||||||
|
minbox = new QDoubleSpinBox(this);
|
||||||
|
maxbox = new QDoubleSpinBox(this);
|
||||||
|
minbox->setMinimum(-99999.9);
|
||||||
|
maxbox->setMinimum(-99999.9);
|
||||||
|
minbox->setMaximum(99999.9);
|
||||||
|
maxbox->setMaximum(99999.9);
|
||||||
|
graph->graphView()->connect(minbox, SIGNAL(valueChanged(double)), this, SLOT(onMinChanged(double)));
|
||||||
|
graph->graphView()->connect(maxbox, SIGNAL(valueChanged(double)), this, SLOT(onMaxChanged(double)));
|
||||||
|
layout->addWidget(checkbox);
|
||||||
|
layout->addWidget(new QLabel(STR_TR_Min));
|
||||||
|
layout->addWidget(minbox);
|
||||||
|
layout->addWidget(new QLabel(STR_TR_Max));
|
||||||
|
layout->addWidget(maxbox);
|
||||||
|
this->setLayout(layout);
|
||||||
|
}
|
||||||
|
|
||||||
void gGraphView::populateMenu(gGraph * graph)
|
void gGraphView::populateMenu(gGraph * graph)
|
||||||
{
|
{
|
||||||
@ -1672,6 +1713,19 @@ void gGraphView::populateMenu(gGraph * graph)
|
|||||||
font.setBold(true);
|
font.setBold(true);
|
||||||
font.setPointSize(font.pointSize() + 3);
|
font.setPointSize(font.pointSize() + 3);
|
||||||
|
|
||||||
|
limits_menu->clear();
|
||||||
|
QWidgetAction * widget = new QWidgetAction(this);
|
||||||
|
MinMaxWidget * minmax = new MinMaxWidget(graph, this);
|
||||||
|
|
||||||
|
widget->setDefaultWidget(minmax);
|
||||||
|
|
||||||
|
minmax->setMax(graph->rec_maxy);
|
||||||
|
minmax->setMin(graph->rec_miny);
|
||||||
|
minmax->setChecked(true);
|
||||||
|
|
||||||
|
limits_menu->addAction(widget);
|
||||||
|
|
||||||
|
|
||||||
// First check for any linechart for this graph..
|
// First check for any linechart for this graph..
|
||||||
gLineChart * lc = dynamic_cast<gLineChart *>(findLayer(graph,LT_LineChart));
|
gLineChart * lc = dynamic_cast<gLineChart *>(findLayer(graph,LT_LineChart));
|
||||||
if (lc) {
|
if (lc) {
|
||||||
|
@ -19,6 +19,8 @@
|
|||||||
#include <QRect>
|
#include <QRect>
|
||||||
#include <QPixmapCache>
|
#include <QPixmapCache>
|
||||||
#include <QMenu>
|
#include <QMenu>
|
||||||
|
#include <QCheckBox>
|
||||||
|
#include <QDoubleSpinBox>
|
||||||
|
|
||||||
#ifndef BROKEN_OPENGL_BUILD
|
#ifndef BROKEN_OPENGL_BUILD
|
||||||
#include <QGLWidget>
|
#include <QGLWidget>
|
||||||
@ -28,6 +30,39 @@
|
|||||||
#include <Graphs/glcommon.h>
|
#include <Graphs/glcommon.h>
|
||||||
#include <SleepLib/day.h>
|
#include <SleepLib/day.h>
|
||||||
|
|
||||||
|
|
||||||
|
class MinMaxWidget:public QWidget
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
public:
|
||||||
|
explicit MinMaxWidget(gGraph * graph, QWidget *parent);
|
||||||
|
~MinMaxWidget() {}
|
||||||
|
|
||||||
|
void createLayout();
|
||||||
|
|
||||||
|
void setMin(double d) {
|
||||||
|
minbox->setValue(d);
|
||||||
|
}
|
||||||
|
void setMax(double d) {
|
||||||
|
maxbox->setValue(d);
|
||||||
|
}
|
||||||
|
double min() { return minbox->value(); }
|
||||||
|
double max() { return maxbox->value(); }
|
||||||
|
|
||||||
|
void setChecked(bool b) { checkbox->setChecked(b); }
|
||||||
|
bool checked() { return checkbox->isChecked(); }
|
||||||
|
|
||||||
|
public slots:
|
||||||
|
void onMinChanged(double d);
|
||||||
|
void onMaxChanged(double d);
|
||||||
|
|
||||||
|
protected:
|
||||||
|
gGraph * graph;
|
||||||
|
QCheckBox *checkbox;
|
||||||
|
QDoubleSpinBox *minbox;
|
||||||
|
QDoubleSpinBox *maxbox;
|
||||||
|
};
|
||||||
|
|
||||||
enum FlagType { FT_Bar, FT_Dot, FT_Span };
|
enum FlagType { FT_Bar, FT_Dot, FT_Span };
|
||||||
|
|
||||||
|
|
||||||
@ -441,6 +476,7 @@ class gGraphView
|
|||||||
Layer * findLayer(gGraph * graph, LayerType type);
|
Layer * findLayer(gGraph * graph, LayerType type);
|
||||||
|
|
||||||
void populateMenu(gGraph *);
|
void populateMenu(gGraph *);
|
||||||
|
QMenu * limits_menu;
|
||||||
QMenu * lines_menu;
|
QMenu * lines_menu;
|
||||||
QMenu * plots_menu;
|
QMenu * plots_menu;
|
||||||
|
|
||||||
|
@ -1911,8 +1911,8 @@ border: 2px solid #56789a; border-radius: 30px;
|
|||||||
<rect>
|
<rect>
|
||||||
<x>0</x>
|
<x>0</x>
|
||||||
<y>0</y>
|
<y>0</y>
|
||||||
<width>100</width>
|
<width>180</width>
|
||||||
<height>30</height>
|
<height>700</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
<property name="palette">
|
<property name="palette">
|
||||||
@ -3059,8 +3059,8 @@ border-radius: 10px;
|
|||||||
<rect>
|
<rect>
|
||||||
<x>0</x>
|
<x>0</x>
|
||||||
<y>0</y>
|
<y>0</y>
|
||||||
<width>100</width>
|
<width>180</width>
|
||||||
<height>30</height>
|
<height>700</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
<property name="mouseTracking">
|
<property name="mouseTracking">
|
||||||
@ -3491,11 +3491,6 @@ border-radius: 10px;
|
|||||||
<string>Ctrl+L</string>
|
<string>Ctrl+L</string>
|
||||||
</property>
|
</property>
|
||||||
</action>
|
</action>
|
||||||
<action name="actionFoo">
|
|
||||||
<property name="text">
|
|
||||||
<string>Foo</string>
|
|
||||||
</property>
|
|
||||||
</action>
|
|
||||||
<action name="action">
|
<action name="action">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string/>
|
<string/>
|
||||||
|
Loading…
Reference in New Issue
Block a user