#ifndef QT_GRAPH_VIEW_H #define QT_GRAPH_VIEW_H #include #include #include #include "component/view/GraphView.h" #include "data/graph/Graph.h" #include "qt/utility/QtScrollSpeedChangeListener.h" #include "qt/utility/QtThreadedFunctor.h" #include "utility/types.h" struct DummyEdge; struct DummyNode; class MessageActivateTrail; class QLabel; class QMouseEvent; class QPushButton; class QSequentialAnimationGroup; class QSlider; class QtGraphEdge; class QtGraphicsView; class QtGraphNode; class QtGraphView : public QObject , public GraphView { Q_OBJECT public: QtGraphView(ViewLayout* viewLayout); virtual ~QtGraphView(); // View implementation virtual void createWidgetWrapper(); virtual void initView(); virtual void refreshView(); // ScreenSearchResponder implementation virtual bool isVisible() const; virtual void findMatches(ScreenSearchSender* sender, const std::string& query); virtual void activateMatch(size_t matchIndex); virtual void deactivateMatch(size_t matchIndex); virtual void clearMatches(); // GraphView implementation virtual void rebuildGraph( std::shared_ptr graph, const std::vector>& nodes, const std::vector>& edges, const GraphParams params); virtual void clear(); virtual void focusTokenIds(const std::vector& focusedTokenIds); virtual void defocusTokenIds(const std::vector& defocusedTokenIds); virtual void resizeView(); virtual Vec2i getViewSize() const; virtual void scrollToValues(int xValue, int yValue); virtual void activateEdge(Id edgeId, bool centerOrigin); private slots: void updateScrollBars(); void finishedTransition(); void clickedInEmptySpace(); void pressedCharacterKey(QChar c); void scrolled(int); void resized(); void trailDepthChanged(int); void clickedCollapse(); void clickedExpand(); void clickedBackwardTrail(); void clickedForwardTrail(); private: MessageActivateTrail getMessageActivateTrail(bool forward); void activateTrail(bool forward); void updateTrailButtons(); void switchToNewGraphData(); QtGraphicsView* getView() const; void doResize(); std::shared_ptr findNodeRecursive(const std::list>& nodes, Id tokenId); std::shared_ptr createNodeRecursive( QGraphicsView* view, std::shared_ptr parentNode, const DummyNode* node, bool multipleActive); std::shared_ptr createEdge( QGraphicsView* view, const DummyEdge* edge, std::set* visibleEdgeIds, Graph::TrailMode trailMode, QPointF pathOffset, bool useBezier); std::shared_ptr createAggregationEdge( QGraphicsView* view, const DummyEdge* edge, std::set* visibleEdgeIds); QRectF itemsBoundingRect(const std::list>& items) const; QRectF getSceneRect(const std::list>& items) const; void centerNode(QtGraphNode* node); void compareNodesRecursive( std::list> newSubNodes, std::list> oldSubNodes, std::list* appearingNodes, std::list* vanishingNodes, std::vector>* remainingNodes); void createTransition(); QtThreadedLambdaFunctor m_onQtThread; std::shared_ptr m_graph; std::shared_ptr m_oldGraph; std::list> m_edges; std::list> m_oldEdges; std::list> m_nodes; std::list> m_oldNodes; std::vector> m_activeNodes; std::shared_ptr m_oldActiveNode; bool m_centerActiveNode; bool m_scrollToTop; bool m_restoreScroll; Vec2i m_scrollValues; bool m_isIndexedList; std::shared_ptr m_transition; QPointF m_sceneRectOffset; QtScrollSpeedChangeListener m_scrollSpeedChangeListenerHorizontal; QtScrollSpeedChangeListener m_scrollSpeedChangeListenerVertical; QWidget* m_trailWidget; QPushButton* m_expandButton; QPushButton* m_collapseButton; QPushButton* m_forwardTrailButton; QPushButton* m_backwardTrailButton; QSlider* m_trailDepthSlider; QLabel* m_trailDepthLabel; std::vector m_virtualNodeRects; // Name matches std::vector m_matchedNodes; }; #endif // QT_GRAPH_VIEW_H