Tulip  5.2.0
Large graphs analysis and drawing
Workspace.h
1 /*
2  *
3  * This file is part of Tulip (http://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 #include <QVector>
27 
28 #include <tulip/tulipconf.h>
29 
30 class PlaceHolderWidget;
31 
32 namespace Ui {
33 class Workspace;
34 }
35 
36 class QPushButton;
37 class QLabel;
38 class QMimeData;
39 
40 namespace tlp {
41 class PluginProgress;
42 class View;
43 class WorkspacePanel;
44 class Graph;
45 class GraphHierarchiesModel;
46 class TulipProject;
47 
48 class TLP_QT_SCOPE Workspace : public QWidget {
49  Q_OBJECT
50 
51  Q_PROPERTY(bool bottomFrameVisible READ isBottomFrameVisible WRITE setBottomFrameVisible)
52 
53  Ui::Workspace *_ui;
54  QList<WorkspacePanel *> _panels;
55  int _currentPanelIndex;
56  QWidget *_oldWorkspaceMode;
57  WorkspacePanel *_focusedPanel;
58  bool _focusedPanelHighlighting;
59 
60  QMap<QWidget *, QVector<PlaceHolderWidget *>> _modeToSlots;
61  QMap<QWidget *, QWidget *> _modeSwitches;
62  GraphHierarchiesModel *_model;
63 
64  QString panelTitle(WorkspacePanel *) const;
65 
66  bool _autoCenterViews;
67 
68 public:
69  explicit Workspace(QWidget *parent = nullptr);
70  ~Workspace() override;
71 
72  int addPanel(tlp::View *);
73  QList<tlp::View *> panels() const;
74 
75  bool isBottomFrameVisible() const;
76 
77 public slots:
78  void delView(tlp::View *view);
79  void switchToStartupMode();
80  void switchToSingleMode();
81  void setSingleModeSwitch(QWidget *);
82  void switchToSplitMode();
83  void setSplitModeSwitch(QWidget *);
84  void switchToSplitHorizontalMode();
85  void setSplitHorizontalModeSwitch(QWidget *);
86  void switchToSplit3Mode();
87  void setSplit3ModeSwitch(QWidget *);
88  void switchToSplit32Mode();
89  void setSplit32ModeSwitch(QWidget *);
90  void switchToSplit33Mode();
91  void setSplit33ModeSwitch(QWidget *);
92  void switchToGridMode();
93  void setGridModeSwitch(QWidget *);
94  void switchToSixMode();
95  void setSixModeSwitch(QWidget *);
96 
97  void nextPage();
98  void previousPage();
99  void setExposeModeSwitch(QPushButton *);
100  void expose(bool);
101  void showExposeMode();
102  void hideExposeMode();
103  void closeAll();
104  void setActivePanel(tlp::View *);
105  void setModel(tlp::GraphHierarchiesModel *);
106  tlp::GraphHierarchiesModel *graphModel() const;
107 
108  void writeProject(tlp::TulipProject *, QMap<tlp::Graph *, QString>, tlp::PluginProgress *);
109  void readProject(tlp::TulipProject *, QMap<QString, tlp::Graph *>, tlp::PluginProgress *);
110 
111  void setBottomFrameVisible(bool);
112  void setPageCountLabel(QLabel *l);
113 
114  void redrawPanels(bool center = false);
115 
116  void setAutoCenterPanelsOnDraw(bool);
117 
118  void setFocusedPanelHighlighting(bool);
119 
120  void setGraphForFocusedPanel(tlp::Graph *);
121 
122 signals:
123  void panelFocused(tlp::View *);
124  void focusedPanelSynchronized();
125  void addPanelRequest(tlp::Graph *g = nullptr);
126  void importGraphRequest();
127 
128 protected slots:
129  void viewNeedsDraw();
130  void switchWorkspaceMode(QWidget *page);
131  void panelDestroyed(QObject *);
132  void updatePageCountLabel();
133  void updateAvailableModes();
134  void updatePanels();
135  void uncheckExposeButton();
136  QWidget *suitableMode(QWidget *oldMode);
137  WorkspacePanel *panelForScene(QObject *obj);
138  void swapPanelsRequested(WorkspacePanel *panel);
139  void updateStartupMode();
140  void changeFocusedPanelSynchronization(bool);
141 
142 protected:
143  void dragEnterEvent(QDragEnterEvent *event) override;
144  void dropEvent(QDropEvent *event) override;
145 
146  bool handleDragEnterEvent(QEvent *e, const QMimeData *mimedata);
147  bool handleDropEvent(const QMimeData *mimedata);
148 
149  bool eventFilter(QObject *, QEvent *) override;
150 
151  QWidget *currentModeWidget() const;
152  QVector<PlaceHolderWidget *> currentModeSlots() const;
153  unsigned int currentSlotsCount() const;
154 
155  void setFocusedPanel(WorkspacePanel *panel);
156 };
157 }
158 
159 #endif // WORKSPACE_H
160 ///@endcond
The TulipProject object handles the content of a Tulip project.
Definition: TulipProject.h:82
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:90