OpenCores
URL https://opencores.org/ocsvn/riscv_vhdl/riscv_vhdl/trunk

Subversion Repositories riscv_vhdl

[/] [riscv_vhdl/] [trunk/] [debugger/] [src/] [gui_plugin/] [GnssWidgets/] [PlotWidget.h] - Blame information for rev 5

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 5 sergeykhbr
/**
2
 * @file
3
 * @copyright  Copyright 2017 GNSS Sensor Ltd. All right reserved.
4
 * @author     Sergey Khabarov - sergeykhbr@gmail.com
5
 * @brief      Generic Plot drawer widget.
6
 */
7
 
8
#pragma once
9
 
10
#include "api_core.h"   // MUST BE BEFORE QtWidgets.h or any other Qt header.
11
#include "attribute.h"
12
#include "igui.h"
13
#include "linecommon.h"
14
 
15
#include <QtWidgets/QWidget>
16
#include <QtWidgets/QMenu>
17
#include <QtGui/QPixmap>
18
#include <QtGui/QPainter>
19
#include <QtGui/qevent.h>
20
#include <QtWidgets/QMdiArea>
21
#include <QtWidgets/QMdiSubWindow>
22
#include <QtWidgets/QVBoxLayout>
23
 
24
namespace debugger {
25
 
26
static const int LINES_PER_PLOT_MAX = 8;
27
 
28
class PlotWidget : public QWidget,
29
                   public IGuiCmdHandler {
30
    Q_OBJECT
31
 
32
public:
33
    PlotWidget(IGui *igui, QWidget *parent = 0);
34
    virtual ~PlotWidget();
35
 
36
    /** IGuiCmdHandler */
37
    virtual void handleResponse(AttributeType *req, AttributeType *resp);
38
 
39
public slots:
40
    void slotUpdateByTimer();
41
    virtual void slotCmdResponse() =0;
42
    void slotRightClickMenu(const QPoint &p);
43
    void slotActionZoomClear();
44
 
45
signals:
46
    void signalCmdResponse();
47
 
48
protected:
49
    void resizeEvent(QResizeEvent *);
50
    void paintEvent(QPaintEvent *ev);
51
    void mousePressEvent(QMouseEvent *ev);
52
    void mouseMoveEvent(QMouseEvent *ev);
53
    void mouseReleaseEvent(QMouseEvent *ev);
54
    void keyPressEvent(QKeyEvent *event);
55
 
56
private:
57
    void renderAll();
58
    void renderAxis(QPainter &p);
59
    void renderLine(QPainter &p, LineCommon *pline);
60
    void renderMarker(QPainter &p);
61
    void renderSelection(QPainter &p);
62
    void renderInfoPanel(QPainter &p);
63
    int pix2epoch(QPoint pix);
64
 
65
    double borderUpValue(double v);
66
 
67
protected:
68
    IGui *igui_;
69
    AttributeType cmd_;
70
    AttributeType response_;
71
    AttributeType defaultLineCfg;
72
 
73
    QColor bkg1;
74
 
75
    bool waitingResp_;
76
    Qt::MouseButton pressed;
77
    QPoint pressStart;          /** Mouse Middle button start coordinates */
78
    QPoint pressEnd;            /** Mouse Middle button end coordinates */
79
 
80
    int epochStart;             /** Draw data starting from this index  */
81
    int epochTotal;             /** Draw the following number of epochs */
82
    int selectedEpoch;
83
 
84
    double dmax;
85
    double dmin;
86
    QPixmap pixmap;
87
 
88
    int lineTotal;
89
    int trackLineIdx;
90
    LineCommon *line_[LINES_PER_PLOT_MAX];
91
    QString groupName;
92
    QString groupUnits;
93
 
94
    QMenu *contextMenu;
95
    QRect rectMargined;
96
    QRect rectPlot;
97
};
98
 
99
class CpiPlot : public PlotWidget {
100
public:
101
    CpiPlot(IGui *igui, QWidget *parent = 0);
102
    virtual void slotCmdResponse();
103
};
104
 
105
class BusUtilPlot : public PlotWidget {
106
public:
107
    BusUtilPlot(IGui *igui, QWidget *parent = 0);
108
    virtual void slotCmdResponse();
109
};
110
 
111
 
112
class PlotQMdiSubWindow : public QMdiSubWindow {
113
    Q_OBJECT
114
public:
115
    PlotQMdiSubWindow(IGui *igui, QMdiArea *area, QWidget *parent,
116
                      QAction *act)
117
        : QMdiSubWindow(parent) {
118
        setAttribute(Qt::WA_DeleteOnClose);
119
        action_ = act;
120
        area_ = area;
121
 
122
        setWindowTitle(act->text());
123
        setMinimumWidth(400);
124
        setMinimumHeight(280);
125
        QWidget *pnew1 = new CpiPlot(igui, this);
126
        connect(parent, SIGNAL(signalUpdateByTimer()),
127
                pnew1, SLOT(slotUpdateByTimer()));
128
 
129
        QWidget *pnew2 = new BusUtilPlot(igui, this);
130
        connect(parent, SIGNAL(signalUpdateByTimer()),
131
                pnew2, SLOT(slotUpdateByTimer()));
132
 
133
        setWindowIcon(act->icon());
134
        act->setChecked(true);
135
 
136
        layout()->setSpacing(2);
137
        layout()->addWidget(pnew1);
138
        layout()->addWidget(pnew2);
139
        area_->addSubWindow(this);
140
        show();
141
    }
142
 
143
protected:
144
    void closeEvent(QCloseEvent *event_) Q_DECL_OVERRIDE {
145
        if (action_) {
146
            action_->setChecked(false);
147
        }
148
        area_->removeSubWindow(this);
149
        event_->accept();
150
    }
151
private:
152
    QAction *action_;
153
    QMdiArea *area_;
154
};
155
 
156
}  // namespace debugger

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.