Tulip  4.0.0
Better Visualization Through Research
 All Classes Files Functions Variables Enumerations Enumerator Properties Groups Pages
Workspace.h
1 /*
2  *
3  * This file is part of Tulip (www.tulip-software.org)
4  *
5  * Authors: David Auber and the Tulip development Team
6  * from LaBRI, University of Bordeaux 1 and Inria Bordeaux - Sud Ouest
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 <QtCore/QMap>
25 #include <QtCore/QPair>
26 #include <QtGui/QWidget>
27 #include <QtCore/QAbstractItemModel>
28 #include <tulip/tulipconf.h>
29 #include <tulip/DataSet.h>
30 #include <tulip/WorkspaceExposeWidget.h>
31 
32 class PlaceHolderWidget;
33 
34 namespace Ui {
35 class Workspace;
36 }
37 
38 class QLabel;
39 namespace tlp {
40 class PluginProgress;
41 class View;
42 class WorkspacePanel;
43 class Graph;
44 class GraphHierarchiesModel;
45 class TulipProject;
46 
47 class TLP_QT_SCOPE Workspace: public QWidget {
48  Q_OBJECT
49 
50  Q_PROPERTY(bool bottomFrameVisible READ isBottomFrameVisible WRITE setBottomFrameVisible)
51 
52  Ui::Workspace* _ui;
53  QList<WorkspacePanel*> _panels;
54  int _currentPanelIndex;
55  QWidget* _oldWorkspaceMode;
56 
57  QMap<QWidget*,QVector<PlaceHolderWidget*> > _modeToSlots;
58  QMap<QWidget*,QWidget*> _modeSwitches;
59  tlp::GraphHierarchiesModel* _model;
60 
61  QString panelTitle(tlp::WorkspacePanel*) const;
62 
63  QLabel* _pageCountLabel;
64 
65 public:
66  explicit Workspace(QWidget *parent = NULL);
67  virtual ~Workspace();
68 
69  int addPanel(tlp::View*);
70  QList<tlp::View*> panels() const;
71 
72  bool isBottomFrameVisible() const;
73 
74 public slots:
75  void delView(tlp::View* view);
76  void switchToStartupMode();
77  void switchToSingleMode();
78  void setSingleModeSwitch(QWidget*);
79  void switchToSplitMode();
80  void setSplitModeSwitch(QWidget*);
81  void switchToSplit3Mode();
82  void setSplit3ModeSwitch(QWidget*);
83  void switchToSplit32Mode();
84  void setSplit32ModeSwitch(QWidget*);
85  void switchToGridMode();
86  void setGridModeSwitch(QWidget*);
87  void switchToSixMode();
88  void setSixModeSwitch(QWidget*);
89 
90  void nextPage();
91  void previousPage();
92  void expose(bool);
93  void showExposeMode();
94  void hideExposeMode();
95 
96  void setActivePanel(tlp::View*);
97  void setModel(tlp::GraphHierarchiesModel*);
98 
99  void writeProject(tlp::TulipProject*,QMap<tlp::Graph*,QString>, tlp::PluginProgress*);
100  void readProject(tlp::TulipProject*,QMap<QString,tlp::Graph*>,tlp::PluginProgress*);
101 
102  void setBottomFrameVisible(bool);
103  void setPageCountLabel(QLabel* l);
104 
105  void redrawPanels(bool center=false);
106 
107 signals:
108  void panelFocused(tlp::View*);
109  void addPanelRequest(tlp::Graph* g = NULL);
110 
111 protected slots:
112  void viewNeedsDraw();
113  void switchWorkspaceMode(QWidget* page);
114  void panelDestroyed(QObject*);
115  void updatePageCountLabel();
116  void updateAvailableModes();
117  void updatePanels();
118  void uncheckExposeButton();
119  QWidget* suitableMode(QWidget* oldMode);
120  WorkspacePanel* panelForScene(QObject* obj);
121  void swapPanelsRequested(WorkspacePanel* panel);
122 
123 protected:
124  virtual void dragEnterEvent(QDragEnterEvent* event);
125  virtual void dropEvent(QDropEvent* event);
126 
127  bool handleDragEnterEvent(QEvent* e, const QMimeData* mimedata);
128  bool handleDropEvent(const QMimeData* mimedata);
129 
130  bool eventFilter(QObject *, QEvent *);
131 
132  QWidget* currentModeWidget() const;
133  QVector<PlaceHolderWidget*> currentModeSlots() const;
134  unsigned int currentSlotsCount() const;
135 };
136 }
137 
138 #endif // WORKSPACE_H
139 ///@endcond