##// END OF EJS Templates
Waveform display features...
leroy -
r21:b405108d1fe4 default
parent child
Show More
@@ -1,6 +1,6
1 1 <?xml version="1.0" encoding="UTF-8"?>
2 2 <!DOCTYPE QtCreatorProject>
3 <!-- Written by Qt Creator 2.4.1, 2013-04-26T15:28:06. -->
3 <!-- Written by Qt Creator 2.4.1, 2013-05-21T07:15:43. -->
4 4 <qtcreator>
5 5 <data>
6 6 <variable>ProjectExplorer.Project.ActiveTarget</variable>
@@ -2,7 +2,7
2 2 #define PARAMS_H
3 3
4 4 #define XMAX 2048
5 #define YMAX 10000
5 #define YMAX 35000
6 6 #define FONT_SIZE_WAVEFORM_TITLE 10
7 7 #define DEFAULT_SIZE 2048
8 8 #define BLK_SIZE 12
@@ -96,7 +96,7 rmapplugin::rmapplugin(QWidget *parent)
96 96 connect(this->UI->rmapSourceLogicalAddressSpinBox, SIGNAL(valueChanged(int)),
97 97 this->UI->gresbBridge, SLOT(sourceHasChanged(int)));
98 98 connect(this->UI->gresbBridge, SIGNAL(sendPacket(TMPacketToRead*)),
99 this, SLOT(receivePacketFromBridge(TMPacketToRead*)));
99 this, SLOT(receivePacketFromBridge(TMPacketToRead*)), Qt::DirectConnection);
100 100
101 101 //************
102 102 // Star Dundee
@@ -110,7 +110,7 rmapplugin::rmapplugin(QWidget *parent)
110 110 connect(this->UI->rmapSourceLogicalAddressSpinBox, SIGNAL(valueChanged(int)),
111 111 this->UI->starDundee, SLOT(sourceHasChanged(int)));
112 112 connect(this->UI->starDundee, SIGNAL(sendPacket(TMPacketToRead*)),
113 this, SLOT(receivePacketFromBridge(TMPacketToRead*)));
113 this, SLOT(receivePacketFromBridge(TMPacketToRead*)), Qt::DirectConnection);
114 114
115 115 connect(this->UI, SIGNAL(bridgeHasChanged(selectedBridge)), this, SLOT(bridgeHasChanged(selectedBridge)));
116 116
@@ -321,17 +321,16 void rmapplugin::buildWFAndDisplay(TMPac
321 321 data = &packet->Value[26]; // start of the first data block;
322 322 j = (pkt_nr-1) * 340;
323 323 for ( i=0; i<blk_nr; i++ ){
324 wfPacket->wf_v[j + i] = (short) ( (data[i * BLK_SIZE ] << 8) + (data[i*BLK_SIZE + 1]) );
325 wfPacket->wf_e1[j + i] = (short) ( (data[i * BLK_SIZE + 2] << 8) + (data[i*BLK_SIZE + 3]) );
326 wfPacket->wf_e2[j + i] = (short) ( (data[i * BLK_SIZE + 4] << 8) + (data[i*BLK_SIZE + 5]) );
327 wfPacket->wf_b1[j + i] = (short) ( (data[i * BLK_SIZE + 6] << 8) + (data[i*BLK_SIZE + 7]) );
328 wfPacket->wf_b2[j + i] = (short) ( (data[i * BLK_SIZE + 8] << 8) + (data[i*BLK_SIZE + 9]) );
329 wfPacket->wf_b3[j + i] = (short) ( (data[i * BLK_SIZE + 10] << 8) + (data[i*BLK_SIZE + 11]) );
324 wfPacket->wf_e1[j + i] = (short) ( (data[ (i * BLK_SIZE) ] << 8) + (data[ (i*BLK_SIZE) + 1]) );
325 wfPacket->wf_v[j + i] = (short) ( (data[ (i * BLK_SIZE) + 2] << 8) + (data[ (i*BLK_SIZE) + 3]) );
326 wfPacket->wf_b1[j + i] = (short) ( (data[ (i * BLK_SIZE) + 4] << 8) + (data[ (i*BLK_SIZE) + 5]) );
327 wfPacket->wf_e2[j + i] = (short) ( (data[ (i * BLK_SIZE) + 6] << 8) + (data[ (i*BLK_SIZE) + 7]) );
328 wfPacket->wf_b3[j + i] = (short) ( (data[ (i * BLK_SIZE) + 8] << 8) + (data[ (i*BLK_SIZE) + 9]) );
329 wfPacket->wf_b2[j + i] = (short) ( (data[ (i * BLK_SIZE) + 10] << 8) + (data[ (i*BLK_SIZE) + 11]) );
330 330 }
331 331 if (pkt_nr == 7)
332 332 {
333 emit displayOnConsole("all packets received, display waveform f" + QString::number(num_page));
334 this->UI->wfDisplay->displayOnPlot(wfPacket->wf_v, num_page, 0);
333 this->UI->wfDisplay->displayOnPlot(wfPacket->wf_v, num_page, 0);
335 334 this->UI->wfDisplay->displayOnPlot(wfPacket->wf_e1, num_page, 1);
336 335 this->UI->wfDisplay->displayOnPlot(wfPacket->wf_e2, num_page, 2);
337 336 this->UI->wfDisplay->displayOnPlot(wfPacket->wf_b1, num_page, 3);
@@ -7,111 +7,41 WFPlot::WFPlot(QWidget *parent) :
7 7 // Create Fonts
8 8 QFont font;
9 9 font = QFont(this->fontInfo().family(), FONT_SIZE_WAVEFORM_TITLE, QFont::Light);
10 customPlot = new QCustomPlot();
10 customPlot = new LppMonPlot();
11 11 mainLayout = new QVBoxLayout();
12 12
13 customPlot->setInteractions(QCustomPlot::iRangeDrag | QCustomPlot::iRangeZoom | QCustomPlot::iSelectAxes |
14 QCustomPlot::iSelectLegend | QCustomPlot::iSelectPlottables | QCustomPlot::iSelectTitle);
15 customPlot->setRangeDrag(Qt::Horizontal|Qt::Vertical);
16 customPlot->setRangeZoom(Qt::Horizontal|Qt::Vertical);
17 customPlot->xAxis->setRange(0, XMAX);
18 customPlot->yAxis->setRange(-YMAX, YMAX);
19 customPlot->setTitleFont(font);
20 //customPlot->setupFullAxesBox();
13 customPlot->setXaxisRange(0, XMAX);
14 customPlot->setYaxisRange(-YMAX, YMAX);
15 //customPlot->setTitleFont(font);
21 16
22 17 customPlot->addGraph();
23 18
24 19 mainLayout->addWidget(customPlot);
25 20
26 21 this->setLayout(mainLayout);
27
28 // connect slot that ties some axis selections together (especially opposite axes):
29 connect(customPlot, SIGNAL(selectionChangedByUser()), this, SLOT(selectionChanged()));
30 // connect slots that takes care that when an axis is selected, only that direction can be dragged and zoomed:
31 connect(customPlot, SIGNAL(mousePress(QMouseEvent*)), this, SLOT(mousePress()));
32 connect(customPlot, SIGNAL(mouseWheel(QWheelEvent*)), this, SLOT(mouseWheel()));
33 22 }
34 23
35 void WFPlot::selectionChanged()
36 {
37 /*
38 normally, axis base line, axis tick labels and axis labels are selectable separately, but we want
39 the user only to be able to select the axis as a whole, so we tie the selected states of the tick labels
40 and the axis base line together. However, the axis label shall be selectable individually.
41 24
42 The selection state of the left and right axes shall be synchronized as well as the state of the
43 bottom and top axes.
44
45 Further, we want to synchronize the selection of the graphs with the selection state of the respective
46 legend item belonging to that graph. So the user can select a graph by either clicking on the graph itself
47 or on its legend item.
48 */
49
50 // make top and bottom axes be selected synchronously, and handle axis and tick labels as one selectable object:
51 if (customPlot->xAxis->selected().testFlag(QCPAxis::spAxis) || customPlot->xAxis->selected().testFlag(QCPAxis::spTickLabels) ||
52 customPlot->xAxis2->selected().testFlag(QCPAxis::spAxis) || customPlot->xAxis2->selected().testFlag(QCPAxis::spTickLabels))
53 {
54 customPlot->xAxis2->setSelected(QCPAxis::spAxis|QCPAxis::spTickLabels);
55 customPlot->xAxis->setSelected(QCPAxis::spAxis|QCPAxis::spTickLabels);
56 }
57 // make left and right axes be selected synchronously, and handle axis and tick labels as one selectable object:
58 if (customPlot->yAxis->selected().testFlag(QCPAxis::spAxis) || customPlot->yAxis->selected().testFlag(QCPAxis::spTickLabels) ||
59 customPlot->yAxis2->selected().testFlag(QCPAxis::spAxis) || customPlot->yAxis2->selected().testFlag(QCPAxis::spTickLabels))
60 {
61 customPlot->yAxis2->setSelected(QCPAxis::spAxis|QCPAxis::spTickLabels);
62 customPlot->yAxis->setSelected(QCPAxis::spAxis|QCPAxis::spTickLabels);
63 }
64
65 // synchronize selection of graphs with selection of corresponding legend items:
66 for (int i=0; i<customPlot->graphCount(); ++i)
67 {
68 QCPGraph *graph = customPlot->graph(i);
69 QCPPlottableLegendItem *item = customPlot->legend->itemWithPlottable(graph);
70 if (item->selected() || graph->selected())
71 {
72 item->setSelected(true);
73 graph->setSelected(true);
74 }
75 }
76 }
77
78 void WFPlot::mousePress()
79 {
80 // if an axis is selected, only allow the direction of that axis to be dragged
81 // if no axis is selected, both directions may be dragged
82
83 if (customPlot->xAxis->selected().testFlag(QCPAxis::spAxis))
84 customPlot->setRangeDrag(customPlot->xAxis->orientation());
85 else if (customPlot->yAxis->selected().testFlag(QCPAxis::spAxis))
86 customPlot->setRangeDrag(customPlot->yAxis->orientation());
87 else
88 customPlot->setRangeDrag(Qt::Horizontal|Qt::Vertical);
89 }
90
91 void WFPlot::mouseWheel()
92 {
93 // if an axis is selected, only allow the direction of that axis to be zoomed
94 // if no axis is selected, both directions may be zoomed
95
96 if (customPlot->xAxis->selected().testFlag(QCPAxis::spAxis))
97 customPlot->setRangeZoom(customPlot->xAxis->orientation());
98 else if (customPlot->yAxis->selected().testFlag(QCPAxis::spAxis))
99 customPlot->setRangeZoom(customPlot->yAxis->orientation());
100 else
101 customPlot->setRangeZoom(Qt::Horizontal|Qt::Vertical);
102 }
103 25
104 26 void WFPlot::displayOnPlot(short *data, unsigned int size)
105 27 {
106 QVector<double> x(size), y(size);
28 QList<QVariant> qListX;
29 QList<QVariant> qListY;
30 qListX.clear();
31 qListY.clear();
107 32
108 33 for (unsigned int i=0; i<size; ++i)
109 34 {
110 x[i] = i;
111 y[i] = (double) data[i];
35 qListX.append(i);
36 qListY.append( (double) data[i] );
112 37 }
113 38
114 customPlot->graph(0)->setData(x, y);
115 customPlot->replot();
39 customPlot->setGraphData(0, qListX, qListY);
40 customPlot->rescaleAxis();
41 }
42
116 43
117 }
44
45
46
47
@@ -2,9 +2,9
2 2 #define WFPLOT_H
3 3
4 4 #include <QWidget>
5 #include <qcustomplot.h>
6 5 #include <QVBoxLayout>
7 6 #include <params.h>
7 #include <lppmonplot.h>
8 8
9 9 class WFPlot : public QWidget
10 10 {
@@ -12,16 +12,14 class WFPlot : public QWidget
12 12 public:
13 13 explicit WFPlot(QWidget *parent = 0);
14 14
15 QCustomPlot * customPlot;
16 15 void displayOnPlot(short *data, unsigned int size);
16
17 LppMonPlot *customPlot;
17 18 QVBoxLayout *mainLayout;
18 19
19 20 signals:
20 21
21 22 public slots:
22 void selectionChanged();
23 void mousePress();
24 void mouseWheel();
25 23
26 24 };
27 25
@@ -92,6 +92,8 void MainWindow::sendOnePacketAndOneTime
92 92
93 93 unsigned int MainWindow::Open()
94 94 {
95 U32 dwTickEnableStatus;
96
95 97 if (!USBSpaceWire_Open(&hDevice, UI->usbDeviceNumber_SPINBOX->value())) // Open the USB device
96 98 {
97 99 emit sendMessage("ERR *** in Open *** USBSpaceWire_Open(&hDevice, 0))");
@@ -119,6 +121,16 unsigned int MainWindow::Open()
119 121 emit sendMessage("ERR *** in Open *** Could not reset timecodes\n");
120 122 }
121 123 emit sendMessage("OK *** in Open *** reset timecodes");
124
125 // Clear the tick enable register
126 if (CFGSpaceWire_SetTickEnableStatus(hDevice, 6) != CFG_TRANSFER_SUCCESS)
127 emit sendMessage("Could not clear the tick enable register");
128 else
129 emit sendMessage("Cleared the tick enable register");
130
131 CFGSpaceWire_GetTickEnableStatus(hDevice, &dwTickEnableStatus);
132 emit sendMessage("OK *** in Open *** CFGSpaceWire_GetTickEnableStatus, code is " + QString::number(dwTickEnableStatus, 2));
133
122 134 }
123 135
124 136 unsigned int MainWindow::getLinkStatus(unsigned char link)
1 NO CONTENT: modified file, binary diff hidden
@@ -1,6 +1,6
1 1 <?xml version="1.0" encoding="UTF-8"?>
2 2 <!DOCTYPE QtCreatorProject>
3 <!-- Written by Qt Creator 2.4.1, 2013-04-02T16:07:04. -->
3 <!-- Written by Qt Creator 2.4.1, 2013-05-03T15:28:00. -->
4 4 <qtcreator>
5 5 <data>
6 6 <variable>ProjectExplorer.Project.ActiveTarget</variable>
General Comments 0
You need to be logged in to leave comments. Login now