Tulip  5.7.4
Large graphs analysis and drawing
Workspace.h
1 /*
2  *
3  * This file is part of Tulip (https://tulip.labri.fr)
4  *
5  * Authors: David Auber and the Tulip development Team
6  * from LaBRI, University of Bordeaux
7  *
8  * Tulip is free software; you can redistribute it and/or modify
9  * it under the terms of the GNU Lesser General Public License
10  * as published by the Free Software Foundation, either version 3
11  * of the License, or (at your option) any later version.
12  *
13  * Tulip is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
16  * See the GNU General Public License for more details.
17  *
18  */
19 ///@cond DOXYGEN_HIDDEN
20 
21 #ifndef WORKSPACE_H
22 #define WORKSPACE_H
23 
24 #include <QWidget>
25 #include <QMap>
26 
27 #include <tulip/tulipconf.h>
28 #include <tulip/Graph.h>
29 
30 class PlaceHolderWidget;
31 
32 namespace Ui {
33 class Workspace;
34 }
35 
36 class QAbstractButton;
37 class QLabel;
38 class QMimeData;
39 
40 namespace tlp {
41 class PluginProgress;
42 class View;
43 class WorkspacePanel;
44 class GraphHierarchiesModel;
45 class TulipProject;
46 
47 class TLP_QT_SCOPE Workspace : public QWidget {
48  Q_OBJECT
49 
50  Ui::Workspace *_ui;
51  std::vector<WorkspacePanel *> _panels;
52  unsigned int _currentPanelIndex;
53  QWidget *_oldWorkspaceMode;
54  WorkspacePanel *_focusedPanel;
55  bool _focusedPanelHighlighting;
56 
57  QMap<QWidget *, std::vector<PlaceHolderWidget *>> _modeToSlots;
58  QMap<QWidget *, QWidget *> _modeSwitches;
59  GraphHierarchiesModel *_model;
60  QAbstractButton *_exposeButton;
61 
62  QString panelTitle(WorkspacePanel *) const;
63 
64  bool _autoCenterViews;
65 
66 public:
67  explicit Workspace(QWidget *parent = nullptr);
68  ~Workspace() override;
69 
70  int addPanel(tlp::View *);
71  inline bool empty() const {
72  return _panels.empty();
73  }
74  std::vector<tlp::View *> panels() const;
75 
76 public slots:
77  void delView(tlp::View *view);
78  void switchToStartupMode();
79  void switchToSingleMode();
80  void setSingleModeSwitch(QWidget *);
81  void switchToSplitMode();
82  void setSplitModeSwitch(QWidget *);
83  void switchToSplitHorizontalMode();
84  void setSplitHorizontalModeSwitch(QWidget *);
85  void switchToSplit3Mode();
86  void setSplit3ModeSwitch(QWidget *);
87  void switchToSplit32Mode();
88  void setSplit32ModeSwitch(QWidget *);
89  void switchToSplit33Mode();
90  void setSplit33ModeSwitch(QWidget *);
91  void switchToGridMode();
92  void setGridModeSwitch(QWidget *);
93  void switchToSixMode();
94  void setSixModeSwitch(QWidget *);
95 
96  void nextPage();
97  void previousPage();
98  void setExposeModeSwitch(QAbstractButton *);
99  void expose(bool);
100  void showExposeMode();
101  void hideExposeMode();
102  void closeAll();
103  void setActivePanel(tlp::View *);
104  void setModel(tlp::GraphHierarchiesModel *);
105  tlp::GraphHierarchiesModel *graphModel() const;
106 
107  void writeProject(tlp::TulipProject *, QMap<tlp::Graph *, QString>, tlp::PluginProgress *);
108  void readProject(tlp::TulipProject *, QMap<QString, tlp::Graph *>, tlp::PluginProgress *);
109 
110  void setPageCountLabel(QLabel *l);
111 
112  void redrawPanels(bool center = false);
113 
114  void setAutoCenterPanelsOnDraw(bool);
115 
116  void setFocusedPanelHighlighting(bool);
117 
118  void setGraphForFocusedPanel(tlp::Graph *);
119 
120 signals:
121  void panelFocused(tlp::View *);
122  void focusedPanelSynchronized();
123  void addPanelRequest(tlp::Graph *g = nullptr);
124  void importGraphRequest();
125  void panelsEmpty();
126 
127 protected slots:
128  void viewNeedsDraw();
129  void switchWorkspaceMode(QWidget *page);
130  void panelDestroyed(QObject *);
131  void updatePageCountLabel();
132  void updateAvailableModes();
133  void updatePanels();
134  void uncheckExposeButton();
135  QWidget *suitableMode(QWidget *oldMode);
136  WorkspacePanel *panelForScene(QObject *obj);
137  void swapPanelsRequested(WorkspacePanel *panel);
138  void updateStartupMode();
139  void changeFocusedPanelSynchronization(bool);
140 
141 protected:
142  void dragEnterEvent(QDragEnterEvent *event) override;
143  void dropEvent(QDropEvent *event) override;
144 
145  bool handleDragEnterEvent(QEvent *e, const QMimeData *mimedata);
146  bool handleDropEvent(const QMimeData *mimedata);
147 
148  bool eventFilter(QObject *, QEvent *) override;
149 
150  QWidget *currentModeWidget() const;
151  std::vector<PlaceHolderWidget *> currentModeSlots() const;
152  unsigned int currentSlotsCount() const;
153 
154  void setFocusedPanel(WorkspacePanel *panel);
155 };
156 } // namespace tlp
157 
158 #endif // WORKSPACE_H
159 ///@endcond
PluginProcess subclasses are meant to notify about the progress state of some process (typically a pl...
View plugins provide a way to dynamically add to a Tulip plateform various ways to visualize a graph.
Definition: View.h:95