partition_widget.h
Go to the documentation of this file.
1 // *****************************************************************************
2 //
3 // Copyright (c) 2015, Southwest Research Institute® (SwRI®)
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 // * Redistributions of source code must retain the above copyright
9 // notice, this list of conditions and the following disclaimer.
10 // * Redistributions in binary form must reproduce the above copyright
11 // notice, this list of conditions and the following disclaimer in the
12 // documentation and/or other materials provided with the distribution.
13 // * Neither the name of Southwest Research Institute® (SwRI®) nor the
14 // names of its contributors may be used to endorse or promote products
15 // derived from this software without specific prior written permission.
16 //
17 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
18 // AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
19 // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
20 // ARE DISCLAIMED. IN NO EVENT SHALL Southwest Research Institute® BE LIABLE
21 // FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
22 // DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
23 // SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
24 // CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
25 // LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
26 // OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
27 // DAMAGE.
28 //
29 // *****************************************************************************
30 #ifndef SWRI_PROFILER_TOOLS_PARTITION_WIDGET_H_
31 #define SWRI_PROFILER_TOOLS_PARTITION_WIDGET_H_
32 
33 #include <QWidget>
34 #include <QColor>
35 #include <QRectF>
37 
38 QT_BEGIN_NAMESPACE
39 class QHelpEvent;
40 QT_END_NAMESPACE
41 
42 namespace swri_profiler_tools
43 {
44 class Profile;
45 class ProfileDatabase;
46 class VariantAnimation;
47 class PartitionWidget : public QWidget
48 {
49  Q_OBJECT;
50 
51  public:
52  PartitionWidget(QWidget *parent=0);
54  void setDatabase(ProfileDatabase *db);
55 
56  public Q_SLOTS:
57  void setActiveNode(int profile_key, int node_key);
58 
59  Q_SIGNALS:
60  void activeNodeChanged(int profile_key, int node_key);
61 
62 
63  private:
64  // This structure stores information about how profile nodes are
65  // laid out.
66  struct LayoutItem
67  {
68  int node_key;
69  bool exclusive;
70  QRectF rect;
71  };
72  typedef std::vector<LayoutItem> Layout;
73 
76 
77  // Controls animation of the rect that defines the view area in the
78  // data space.
80  QTransform win_from_data_;
81 
83  Layout layoutProfile(const Profile &profile);
84 
85  void renderLayout(QPainter &painter,
86  const QTransform &win_from_rect,
87  const Layout &layout,
88  const Profile &profile);
89 
90  QTransform getTransform(const QRectF &win_rect,
91  const QRectF &data_rect);
92 
93  QRectF dataRect(const Layout &layout) const;
94 
95  int itemAtPoint(const QPointF &point) const;
96 
97  private Q_SLOTS:
98  void updateData();
99 
100  protected:
101  bool event(QEvent *event);
102  void toolTipEvent(QHelpEvent *event);
103  void paintEvent(QPaintEvent *event);
104  void mousePressEvent(QMouseEvent *event);
105  void mouseDoubleClickEvent(QMouseEvent *event);
106 }; // class PartitionWidget
107 } // namespace swri_profiler_tools
108 #endif // SWRI_PROFILER_TOOLS_PARTITION_WIDGET_H_
109 
swri_profiler_tools::PartitionWidget::db_
ProfileDatabase * db_
Definition: partition_widget.h:74
swri_profiler_tools::PartitionWidget::dataRect
QRectF dataRect(const Layout &layout) const
Definition: partition_widget.cpp:122
swri_profiler_tools::PartitionWidget::mousePressEvent
void mousePressEvent(QMouseEvent *event)
Definition: partition_widget.cpp:350
swri_profiler_tools::PartitionWidget::setDatabase
void setDatabase(ProfileDatabase *db)
Definition: partition_widget.cpp:70
swri_profiler_tools::Profile
Definition: profile.h:141
swri_profiler_tools::PartitionWidget::renderLayout
void renderLayout(QPainter &painter, const QTransform &win_from_rect, const Layout &layout, const Profile &profile)
Definition: partition_widget.cpp:259
swri_profiler_tools::PartitionWidget::Layout
std::vector< LayoutItem > Layout
Definition: partition_widget.h:72
swri_profiler_tools::VariantAnimation
Definition: variant_animation.h:40
swri_profiler_tools::PartitionWidget::activeNodeChanged
void activeNodeChanged(int profile_key, int node_key)
swri_profiler_tools::PartitionWidget::setActiveNode
void setActiveNode(int profile_key, int node_key)
Definition: partition_widget.cpp:148
swri_profiler_tools::PartitionWidget::event
bool event(QEvent *event)
Definition: partition_widget.cpp:312
swri_profiler_tools::PartitionWidget::layoutProfile
Layout layoutProfile(const Profile &profile)
Definition: partition_widget.cpp:182
swri_profiler_tools::DatabaseKey
Definition: database_key.h:36
swri_profiler_tools::PartitionWidget::LayoutItem
Definition: partition_widget.h:66
swri_profiler_tools::ProfileDatabase
Definition: profile_database.h:42
swri_profiler_tools::PartitionWidget
Definition: partition_widget.h:47
swri_profiler_tools::PartitionWidget::mouseDoubleClickEvent
void mouseDoubleClickEvent(QMouseEvent *event)
Definition: partition_widget.cpp:354
swri_profiler_tools::PartitionWidget::getTransform
QTransform getTransform(const QRectF &win_rect, const QRectF &data_rect)
Definition: partition_widget.cpp:287
swri_profiler_tools::PartitionWidget::view_animator_
VariantAnimation * view_animator_
Definition: partition_widget.h:79
swri_profiler_tools::PartitionWidget::LayoutItem::node_key
int node_key
Definition: partition_widget.h:68
swri_profiler_tools::PartitionWidget::active_key_
DatabaseKey active_key_
Definition: partition_widget.h:75
swri_profiler_tools::PartitionWidget::LayoutItem::exclusive
bool exclusive
Definition: partition_widget.h:69
swri_profiler_tools::PartitionWidget::toolTipEvent
void toolTipEvent(QHelpEvent *event)
Definition: partition_widget.cpp:322
database_key.h
swri_profiler_tools::PartitionWidget::paintEvent
void paintEvent(QPaintEvent *event)
Definition: partition_widget.cpp:102
swri_profiler_tools::PartitionWidget::updateData
void updateData()
Definition: partition_widget.cpp:87
swri_profiler_tools::PartitionWidget::current_layout_
Layout current_layout_
Definition: partition_widget.h:82
swri_profiler_tools::PartitionWidget::win_from_data_
QTransform win_from_data_
Definition: partition_widget.h:80
swri_profiler_tools::PartitionWidget::~PartitionWidget
~PartitionWidget()
Definition: partition_widget.cpp:66
swri_profiler_tools
Definition: database_key.h:34
swri_profiler_tools::PartitionWidget::LayoutItem::rect
QRectF rect
Definition: partition_widget.h:70
swri_profiler_tools::PartitionWidget::itemAtPoint
int itemAtPoint(const QPointF &point) const
Definition: partition_widget.cpp:301
swri_profiler_tools::PartitionWidget::PartitionWidget
PartitionWidget(QWidget *parent=0)
Definition: partition_widget.cpp:55


swri_profiler_tools
Author(s):
autogenerated on Wed Mar 2 2022 01:06:28