Tulip  4.2.0
Better Visualization Through Research
 All Classes Namespaces 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 QPushButton;
39 class QLabel;
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 
58  QMap<QWidget*,QVector<PlaceHolderWidget*> > _modeToSlots;
59  QMap<QWidget*,QWidget*> _modeSwitches;
60  tlp::GraphHierarchiesModel* _model;
61 
62  QString panelTitle(tlp::WorkspacePanel*) const;
63 
64  QLabel* _pageCountLabel;
65  bool _autoCenterViews;
66 
67 public:
68  explicit Workspace(QWidget *parent = NULL);
69  virtual ~Workspace();
70 
71  int addPanel(tlp::View*);
72  QList<tlp::View*> panels() const;
73 
74  bool isBottomFrameVisible() 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 switchToSplit3Mode();
84  void setSplit3ModeSwitch(QWidget*);
85  void switchToSplit32Mode();
86  void setSplit32ModeSwitch(QWidget*);
87  void switchToGridMode();
88  void setGridModeSwitch(QWidget*);
89  void switchToSixMode();
90  void setSixModeSwitch(QWidget*);
91 
92  void nextPage();
93  void previousPage();
94  void setExposeModeSwitch(QPushButton *);
95  void expose(bool);
96  void showExposeMode();
97  void hideExposeMode();
98 
99  void setActivePanel(tlp::View*);
100  void setModel(tlp::GraphHierarchiesModel*);
101 
102  void writeProject(tlp::TulipProject*,QMap<tlp::Graph*,QString>, tlp::PluginProgress*);
103  void readProject(tlp::TulipProject*,QMap<QString,tlp::Graph*>,tlp::PluginProgress*);
104 
105  void setBottomFrameVisible(bool);
106  void setPageCountLabel(QLabel* l);
107 
108  void redrawPanels(bool center=false);
109 
110  void setAutoCenterPanelsOnDraw(bool);
111 
112 signals:
113  void panelFocused(tlp::View*);
114  void addPanelRequest(tlp::Graph* g = NULL);
115  void importGraphRequest();
116 
117 protected slots:
118  void viewNeedsDraw();
119  void switchWorkspaceMode(QWidget* page);
120  void panelDestroyed(QObject*);
121  void updatePageCountLabel();
122  void updateAvailableModes();
123  void updatePanels();
124  void uncheckExposeButton();
125  QWidget* suitableMode(QWidget* oldMode);
126  WorkspacePanel* panelForScene(QObject* obj);
127  void swapPanelsRequested(WorkspacePanel* panel);
128  void updateStartupMode();
129 
130 protected:
131  virtual void dragEnterEvent(QDragEnterEvent* event);
132  virtual void dropEvent(QDropEvent* event);
133 
134  bool handleDragEnterEvent(QEvent* e, const QMimeData* mimedata);
135  bool handleDropEvent(const QMimeData* mimedata);
136 
137  bool eventFilter(QObject *, QEvent *);
138 
139  QWidget* currentModeWidget() const;
140  QVector<PlaceHolderWidget*> currentModeSlots() const;
141  unsigned int currentSlotsCount() const;
142 };
143 }
144 
145 #endif // WORKSPACE_H
146 ///@endcond