00001 // ***************************************************************************** 00002 // 00003 // Copyright (c) 2015, Southwest Research Institute® (SwRI®) 00004 // All rights reserved. 00005 // 00006 // Redistribution and use in source and binary forms, with or without 00007 // modification, are permitted provided that the following conditions are met: 00008 // * Redistributions of source code must retain the above copyright 00009 // notice, this list of conditions and the following disclaimer. 00010 // * Redistributions in binary form must reproduce the above copyright 00011 // notice, this list of conditions and the following disclaimer in the 00012 // documentation and/or other materials provided with the distribution. 00013 // * Neither the name of Southwest Research Institute® (SwRI®) nor the 00014 // names of its contributors may be used to endorse or promote products 00015 // derived from this software without specific prior written permission. 00016 // 00017 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 00018 // AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 00019 // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 00020 // ARE DISCLAIMED. IN NO EVENT SHALL Southwest Research Institute® BE LIABLE 00021 // FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 00022 // DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 00023 // SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 00024 // CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 00025 // LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 00026 // OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH 00027 // DAMAGE. 00028 // 00029 // ***************************************************************************** 00030 #ifndef SWRI_PROFILER_TOOLS_PARTITION_WIDGET_H_ 00031 #define SWRI_PROFILER_TOOLS_PARTITION_WIDGET_H_ 00032 00033 #include <QWidget> 00034 #include <QColor> 00035 #include <QRectF> 00036 #include <swri_profiler_tools/database_key.h> 00037 00038 QT_BEGIN_NAMESPACE 00039 class QHelpEvent; 00040 QT_END_NAMESPACE 00041 00042 namespace swri_profiler_tools 00043 { 00044 class Profile; 00045 class ProfileDatabase; 00046 class VariantAnimation; 00047 class PartitionWidget : public QWidget 00048 { 00049 Q_OBJECT; 00050 00051 public: 00052 PartitionWidget(QWidget *parent=0); 00053 ~PartitionWidget(); 00054 void setDatabase(ProfileDatabase *db); 00055 00056 public Q_SLOTS: 00057 void setActiveNode(int profile_key, int node_key); 00058 00059 Q_SIGNALS: 00060 void activeNodeChanged(int profile_key, int node_key); 00061 00062 00063 private: 00064 // This structure stores information about how profile nodes are 00065 // laid out. 00066 struct LayoutItem 00067 { 00068 int node_key; 00069 bool exclusive; 00070 QRectF rect; 00071 }; 00072 typedef std::vector<LayoutItem> Layout; 00073 00074 ProfileDatabase *db_; 00075 DatabaseKey active_key_; 00076 00077 // Controls animation of the rect that defines the view area in the 00078 // data space. 00079 VariantAnimation *view_animator_; 00080 QTransform win_from_data_; 00081 00082 Layout current_layout_; 00083 Layout layoutProfile(const Profile &profile); 00084 00085 void renderLayout(QPainter &painter, 00086 const QTransform &win_from_rect, 00087 const Layout &layout, 00088 const Profile &profile); 00089 00090 QTransform getTransform(const QRectF &win_rect, 00091 const QRectF &data_rect); 00092 00093 QRectF dataRect(const Layout &layout) const; 00094 00095 int itemAtPoint(const QPointF &point) const; 00096 00097 private Q_SLOTS: 00098 void updateData(); 00099 00100 protected: 00101 bool event(QEvent *event); 00102 void toolTipEvent(QHelpEvent *event); 00103 void paintEvent(QPaintEvent *event); 00104 void mousePressEvent(QMouseEvent *event); 00105 void mouseDoubleClickEvent(QMouseEvent *event); 00106 }; // class PartitionWidget 00107 } // namespace swri_profiler_tools 00108 #endif // SWRI_PROFILER_TOOLS_PARTITION_WIDGET_H_ 00109