Files
DRAMSys/DRAMSys/analyzer/presentation/traceplot.h
2015-06-23 16:31:19 +02:00

189 lines
5.4 KiB
C++

/*
* Copyright (c) 2015, University of Kaiserslautern
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
* met:
*
* 1. Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* 3. Neither the name of the copyright holder nor the names of its
* contributors may be used to endorse or promote products derived from
* this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER
* OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* Authors:
* Janik Schlemminger
* Robert Gernhardt
* Matthias Jung
*/
#ifndef TRACEPLOT_H
#define TRACEPLOT_H
#include <qwt_plot.h>
#include <QString>
#include <QColor>
#include <qwt_scale_draw.h>
#include <vector>
#include <qwt_plot_marker.h>
#include <QAction>
#include <qwt_plot_zoneitem.h>
#include "traceplotitem.h"
#include "tracenavigator.h"
#include "queryeditor.h"
#include "markerplotitem.h"
/* A plot that plots all phases and transactions of a trace file
* Y Axis : Bank0,...,Bank7,Trans,CC
* X Axis : Time
*
*/
class TracePlotMouseLabel;
class TracePlot : public QwtPlot
{
Q_OBJECT
public:
TracePlot(QWidget *parent = NULL);
void init(TraceNavigator* navigator);
Timespan GetCurrentTimespan();
traceTime ZoomLevel() const{return zoomLevel;}
void setUpActions();
void setUpContextMenu();
public Q_SLOTS:
void currentTraceTimeChanged();
void selectedTransactionsChanged();
void commentsChanged();
Q_SIGNALS:
void tracePlotZoomChanged();
void colorGroupingChanged(ColorGrouping colorgrouping);
private Q_SLOTS:
void on_executeQuery();
void on_selectNextRefresh();
void on_selectNextActivate();
void on_selectNextPrecharge();
void on_colorGroupingPhase();
void on_colorGroupingTransaction();
void on_colorGroupingThread();
void on_goToTransaction();
void on_goToPhase();
void on_deselectAll();
void on_insertComment();
void on_goToTime();
void on_exportToPDF();
private:
bool isInitialized;
TraceNavigator* navigator;
TraceDrawingProperties drawingProperties;
TracePlotItem *tracePlotItem;
QwtPlotZoneItem *zoomZone;
std::vector<std::shared_ptr<Transaction>> transactions;
QueryEditor *queryEditor;
QMenu* contextMenu;
void setUpTracePlotItem();
void setUpDrawingProperties();
void setUpGrid();
void setUpAxis();
void setUpZoom();
void setUpQueryEditor();
void connectNavigatorQ_SIGNALS();
void getAndDrawComments();
/* zooming
*
*/
traceTime zoomLevel;
constexpr static int minZoomClks = 10;
constexpr static int maxZoomClks = 2000;
constexpr static int GridVisiblityClks = 100;
constexpr static int textVisibilityClks = 200;
traceTime minZoomLevel,maxZoomLevel, textVisibilityZoomLevel;
constexpr static double zoomFactor = 0.8;
void zoomIn(traceTime zoomCenter);
void zoomOut(traceTime zoomCenter);
void setZoomLevel(traceTime newZoomLevel);
void exitZoomMode();
void enterZoomMode();
/* keyboard an mouse events
*
*/
bool eventFilter( QObject *object, QEvent *event );
QAction* goToTime;
QAction* goToTransaction;
QAction* goToPhase;
QAction* showQueryEditor;
QAction* insertComment;
QAction* deselectAll;
QAction* selectNextRefresh;
QAction* selectNextActivate;
QAction* selectNextPrecharge;
QAction* setColorGroupingPhase;
QAction* setColorGroupingTransaction;
QAction* setColorGroupingThread;
QAction* exportToPdf;
TracePlotMouseLabel* mouseLabel;
void openContextMenu(const QPoint& pos,const QPoint& mouseDown);
QPoint contextMenuMouseDown;
void SelectTransaction(int x, int y);
void keyPressEvent(QKeyEvent *keyPressedEvent);
void keyReleaseEvent(QKeyEvent *keyReleasedEvent);
struct KeyPressData
{
bool ctrlPressed, shiftPressed;
KeyPressData():ctrlPressed(false),shiftPressed(false){}
};
struct MouseDownData
{
traceTime mouseDownTime;
Timespan zoomSpan;
int mouseDownX;
bool mouseIsDownForDragging;
bool mouseIsDownForZooming;
MouseDownData(): mouseDownTime(0),mouseDownX(0),mouseIsDownForDragging(false),mouseIsDownForZooming(false){}
};
MouseDownData mouseDownData;
KeyPressData keyPressData;
};
#endif // TRACEPLOT_H