CAVAPA-GUI  30.5.2014
 All Classes Namespaces Functions Variables Typedefs Enumerations Pages
graphwidget.h
1 /****************************************************************************
2  * Copyright (c) 2014, Joel Kivelä, Erkki Koskenkorva, Oskari Leppäaho,
3  * Mika Lehtinen and Petri Partanen.
4  * All rights reserved.
5  *
6  * Redistribution and use in source and binary forms, with or without
7  * modification, are permitted provided that the following conditions are met:
8  *
9  * * Redistributions of source code must retain the above copyright
10  * notice, this list of conditions and the following disclaimer.
11  * * Redistributions in binary form must reproduce the above copyright
12  * notice, this list of conditions and the following disclaimer in the
13  * documentation and/or other materials provided with the distribution.
14  * * Neither the name of the copyright holders nor the names of its
15  * contributors may be used to endorse or promote products derived from
16  * this software without specific prior written permission.
17  *
18  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
19  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
20  * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
21  * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR
22  * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
23  * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
24  * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
25  * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
26  * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
27  * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
28  * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 ****************************************************************************/
30 #ifndef GRAPHWIDGET_H
31 #define GRAPHWIDGET_H
32 
33 #include <QWidget>
34 #include <QtWidgets>
35 #include "../common.h"
36 
37 #include <QtSvg/QSvgGenerator>
38 
39 #include "markerdialog.h"
40 #include "graphsettingsdialog.h"
41 #include "exportdialog.h"
42 
43 namespace Ui {
44 class GraphWidget;
45 }
46 
47 namespace cavapa_gui
48 {
57 class GraphWidget : public QWidget
58 {
59  Q_OBJECT
60 public:
61  explicit GraphWidget(QWidget *parent = 0);
62  ~GraphWidget();
63 
68  void updateData(const FrameStats& new_data);
69 
76  void updateStatistics(const std::vector<FrameStats>& stats);
77 
78 
79  void getSettings(GraphSettings settings);
81 
82 
83  void setMarkers(std::vector<GraphMarker> markers);
84  void setMarkerHistory(std::vector<std::string> history);
85  std::vector<GraphMarker> getMarkers();
86  std::vector<std::string> getMarkerHistory();
87 
88 public slots:
97  void requestStatistics(FrameTime start, FrameTime stop, int points)
98  { emit statisticsRequested(start, stop, points); }
99 
100  void sendDefaultSettings();
101  void sendPreviousSettings();
102 
103  void printGraphToFile();
104 
105  void removeFromHistory(int i);
106 
107  void reset();
108 
109  void setZoomInActive(bool active);
110  void setZoomOutActive(bool active);
111  void setScrollLeftActive(bool active);
112  void setScrollRightActive(bool active);
113  void setScrollBarSize(int size);
114 
115  void changeFixed();
116  void changeAbsoluteEnabled(bool ae);
117 
119 
120 private:
121  Ui::GraphWidget *ui;
122 
123  // actions for the context menu (right click -menu)
124  QAction *DeleteMarker;
125  QAction *CreateMarker;
126  QAction *colorsettings;
127  QAction *savetosvg;
128  QAction *exportSelectionToFile;
129 
130  // settings
131  GraphSettings defaultsettings;
132  GraphSettings currentsettings;
133  GraphSettings newsettings;
134 
135  // dialogs
136  ExportDialog exportdialog;
137  MarkerDialog markerdialog;
138  GraphSettingsDialog graphsettings;
139 
140  // last entered text
141  QString lasttext;
142 
143  // marker history
144  std::vector <std::string> markerhistory;
145 
146 signals:
155  void statisticsRequested(FrameTime start, FrameTime stop, int points);
156 
161  void sendGraphSettings(GraphSettings currentsettings);
165  void settingsChanged();
172  bool exportCommand(const ExportOptions& options);
177  void pointedFrame(FrameTime point);
178 
182  void markerChanged();
183 
184 private slots:
185 
186  void zoomGraphIn();
187 
188  void setShowCountF(bool count);
189  void setShowActivityF(bool activity);
190  void setTimeRelativeF(bool relative);
191  void removeMarkerF();
192 
193  void setNewMarkerText(QString newtext);
194  void setMarkerText();
195 
196  void setTimeMarkers(QDateTime start, QDateTime end);
197  void changeRTLabelText(bool rt);
198  void on_horizontalScrollBar_sliderMoved(int position);
199  void setScrollBar(int position);
200  void on_checkBoxLatest_stateChanged(int arg1);
201  void contextMenuEvent(QContextMenuEvent *event);
202  void on_timeEdit_timeChanged(const QTime &time);
203 
204  void openExportDialog();
205 
206  void updateCurrent(GraphSettings settings);
207  void saveCurrent(GraphSettings settings);
208  void sendMarkerText();
209 
210  void changeSettings();
211  void informChange();
212 
213  void on_timeEditStart_dateTimeChanged(const QDateTime &dateTime);
214  void on_timeEditEnd_dateTimeChanged(const QDateTime &dateTime);
215 
216  void on_buttonZoomIn_clicked();
217  void on_radioButtonRelative_clicked();
218  void on_radioButtonAbsolute_clicked();
219  void on_checkBoxActivity_clicked();
220  void on_checkBoxCount_clicked();
221  void on_checkBoxMarkers_clicked();
222 };
223 } // namespace
224 
225 #endif // GRAPHWIDGET_H
void requestStatistics(FrameTime start, FrameTime stop, int points)
Requests statistical data.
Definition: graphwidget.h:97
Class for settings dialog of graphwidget.
Definition: graphsettingsdialog.h:53
void updateStatistics(const std::vector< FrameStats > &stats)
Updates the graph with new statistics.
Definition: graphwidget.cpp:311
void sendDefaultSettings()
Sets default settings into graph settings dialog.
Definition: graphwidget.cpp:186
Structure for holding frame statistics on activity.
Definition: common.h:285
void changeAbsoluteEnabled(bool ae)
Sets whether absolute time button is active or inactive.
Definition: graphwidget.cpp:541
void changeFixed()
Set fixed time window -button disabled.
Definition: graphwidget.cpp:339
void sendGraphSettings(GraphSettings currentsettings)
Sends current settings of the graph to parent.
void setZoomOutActive(bool active)
Sets zoom out button active or inactive.
Definition: graphwidget.cpp:509
GraphSettings giveSettings()
Gives current settings to parent.
Definition: graphwidget.cpp:213
void setScrollBarSize(int size)
Sets the scroll bar size.
Definition: graphwidget.cpp:533
void setMarkerHistory(std::vector< std::string > history)
Sets the marker history from parent when loading saved measurement.
Definition: graphwidget.cpp:252
void removeFromHistory(int i)
Removes the selected marker text from marker history.
Definition: graphwidget.cpp:262
void reset()
Resets the graph and nulls the clocks.
Definition: graphwidget.cpp:491
void getSettings(GraphSettings settings)
Gets settings from the parent and sets them as the current ones.
Definition: graphwidget.cpp:201
GraphWidget(QWidget *parent=0)
Constructs the GraphWidget.
Definition: graphwidget.cpp:40
void updateData(const FrameStats &new_data)
Informs the graph about a new frame statistics.
Definition: graphwidget.cpp:303
void settingsChanged()
Sends notify to parent that graph's settings have been changed.
std::uint64_t FrameTime
Used to store milliseconds interval in frame times.
Definition: common.h:138
Graph settings type for font/colors/line widths.
Definition: activitygraph.h:75
The widget holds the ActivityGraph and all its controls.
Definition: graphwidget.h:57
void setScrollRightActive(bool active)
Sets slide right button active or inactive.
Definition: graphwidget.cpp:525
void printGraphToFile()
Saves the graph in to scalable svg image file.
Definition: graphwidget.cpp:434
void setScrollLeftActive(bool active)
Sets slide left button active or inactive.
Definition: graphwidget.cpp:517
The structure holds CSV export options.
Definition: common.h:183
std::vector< GraphMarker > getMarkers()
Gets markers from the graph and passes them to parent.
Definition: graphwidget.cpp:477
std::vector< std::string > getMarkerHistory()
Passes marker history to parent.
Definition: graphwidget.cpp:485
void markerChanged()
Informs the parent of marker adding.
void openExportSelectionDialog()
Opens export dialog and send values from ui objects into it.
Definition: graphwidget.cpp:464
void setMarkers(std::vector< GraphMarker > markers)
Sets the markers from parent when loading saved measurement.
Definition: graphwidget.cpp:241
Class for marker creation dialog of the graphwidget.
Definition: markerdialog.h:53
void statisticsRequested(FrameTime start, FrameTime stop, int points)
Signal to be emitted when the graph wants data to be retrieved.
void pointedFrame(FrameTime point)
Sends pointed frametime from graph to parent.
Class for export dialog of graphwidget.
Definition: exportdialog.h:54
void sendPreviousSettings()
Gets the previous graph settings (when settings dialog canceled).
Definition: graphwidget.cpp:415
bool exportCommand(const ExportOptions &options)
Passes export command with generated options from ExportDialog to parent.
void setZoomInActive(bool active)
Sets zoom in button active or inactive.
Definition: graphwidget.cpp:501