OpenWalnut  1.5.0dev
WQtNetworkEditor.h
1 //---------------------------------------------------------------------------
2 //
3 // Project: OpenWalnut ( http://www.openwalnut.org )
4 //
5 // Copyright 2009 OpenWalnut Community, BSV@Uni-Leipzig and CNCF@MPI-CBS
6 // For more information see http://www.openwalnut.org/copying
7 //
8 // This file is part of OpenWalnut.
9 //
10 // OpenWalnut is free software: you can redistribute it and/or modify
11 // it under the terms of the GNU Lesser General Public License as published by
12 // the Free Software Foundation, either version 3 of the License, or
13 // (at your option) any later version.
14 //
15 // OpenWalnut is distributed in the hope that it will be useful,
16 // but WITHOUT ANY WARRANTY; without even the implied warranty of
17 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 // GNU Lesser General Public License for more details.
19 //
20 // You should have received a copy of the GNU Lesser General Public License
21 // along with OpenWalnut. If not, see <http://www.gnu.org/licenses/>.
22 //
23 //---------------------------------------------------------------------------
24 
25 #ifndef WQTNETWORKEDITOR_H
26 #define WQTNETWORKEDITOR_H
27 
28 #include <list>
29 #include <memory>
30 #include <string>
31 
32 #include <QDockWidget>
33 #include <QVBoxLayout>
34 #include <QWidget>
35 
36 #include "../WQtCombinerToolbar.h"
37 #include "../guiElements/WQtDockWidget.h"
38 #include "WQtNetworkEditorView.h"
39 #include "WQtNetworkItem.h"
40 #include "WQtNetworkScene.h"
41 #include "WQtNetworkSceneLayout.h"
42 #include "core/kernel/WModule.h"
43 
44 // forward declaration
45 class WMainWindow;
46 class WQtNetworkItemGrid;
47 
48 /**
49  * Container widget to hold the WQtNetworkScene
50  */
52 {
53  Q_OBJECT
54 public:
55  /**
56  * constructor
57  *
58  * \param parent The widget that manages this widget
59  */
60  explicit WQtNetworkEditor( WMainWindow* parent = 0 );
61 
62  /**
63  * destructor.
64  */
65  virtual ~WQtNetworkEditor();
66 
67  /**
68  * Simple search the WQtNetworkItem that belongs to the WModule
69  *
70  * \param module a WModule
71  * \return WQtNetworkItem belongs to the WModule
72  */
73  WQtNetworkItem* findItemByModule( std::shared_ptr< WModule > module );
74 
75  /**
76  * Connect SIGNALS with SLOTS
77  */
78  void connectSlots();
79 
80  /**
81  * Query a list of selected items.
82  *
83  * \return the list
84  **/
86 
87  /**
88  * Clears the selection.
89  */
90  void clearSelection();
91 
92  /**
93  * Select the item representing the given module. If module not found or NULL, nothing is selected.
94  *
95  * \param module the module
96  */
97  void selectByModule( WModule::SPtr module );
98 
99  /**
100  * Returns the current scene.
101  *
102  * \return the scene
103  */
105 
106  /**
107  * Get the view handling the scene.
108  *
109  * \return the view.
110  */
112 
113  /**
114  * Get the layouter of the scene.
115  *
116  * \return the layout instance
117  */
119 
120 public slots:
121 
122  /**
123  * Set new scene rect
124  */
125  void updateSceneRect();
126 
127 protected:
128  /**
129  * Reference to the main window of the application.
130  */
132 
133  /**
134  * Everytime a module is associated, ready, connected, disconnected, removed or
135  * deleted the kernels emits a signal and here we look how to behave.
136  *
137  * \param event the event that should be handled here.
138  * \return if event was accepted or not
139  */
140  virtual bool event( QEvent* event );
141 
142 private:
143  WQtNetworkScene* m_scene; //!< the scene managing the items
144 
145  WQtNetworkSceneLayout* m_layout; //!< the layouter of the scene
146 
147  QList< WQtNetworkItem* > m_items; //!< a list of the WQtNetworkItems in the WQtNetworkScene
148 
149  /**
150  * Action which uses a compatibles list (submenu) to connect a selected item with other existing modules.
151  */
153 
154  /**
155  * Action which uses a compatibles list (submenu) to connect a selected item with other prototypes.
156  */
158 
159  /**
160  * Action which disconnects a connector from the module.
161  */
163 
164  /**
165  * The view controlling several scene transformations.
166  */
168 
169  WQtNetworkItemGrid* m_grid; //!< we use a grid to place the items
170 
171 private slots:
172 
173  /**
174  * Determines possible Connections and the propertytab.
175  */
176  void selectItem();
177 
178  /**
179  * Called by a timer to allow updates of all module items.
180  */
181  void updateCycle();
182 };
183 
184 #endif // WQTNETWORKEDITOR_H
This class contains the main window and the layout of the widgets within the window.
Definition: WMainWindow.h:66
std::shared_ptr< WModule > SPtr
Shared pointer to a WModule.
Definition: WModule.h:106
Advanced QDockWidget.
Definition: WQtDockWidget.h:50
This class extends the basic functionality of QGraphicsView to allow comfortable panning and zooming.
Container widget to hold the WQtNetworkScene.
void selectByModule(WModule::SPtr module)
Select the item representing the given module.
void updateCycle()
Called by a timer to allow updates of all module items.
virtual bool event(QEvent *event)
Everytime a module is associated, ready, connected, disconnected, removed or deleted the kernels emit...
void selectItem()
Determines possible Connections and the propertytab.
WQtNetworkItem * findItemByModule(std::shared_ptr< WModule > module)
Simple search the WQtNetworkItem that belongs to the WModule.
WQtNetworkEditorView * getView()
Get the view handling the scene.
WQtNetworkScene * m_scene
the scene managing the items
void clearSelection()
Clears the selection.
QAction * m_connectWithModuleAction
Action which uses a compatibles list (submenu) to connect a selected item with other existing modules...
QAction * m_connectWithPrototypeAction
Action which uses a compatibles list (submenu) to connect a selected item with other prototypes.
void updateSceneRect()
Set new scene rect.
WQtNetworkSceneLayout * m_layout
the layouter of the scene
WMainWindow * m_mainWindow
Reference to the main window of the application.
QList< QGraphicsItem * > selectedItems() const
Query a list of selected items.
void connectSlots()
Connect SIGNALS with SLOTS.
QList< WQtNetworkItem * > m_items
a list of the WQtNetworkItems in the WQtNetworkScene
WQtNetworkScene * getScene()
Returns the current scene.
WQtNetworkSceneLayout * getLayout()
Get the layouter of the scene.
QAction * m_disconnectAction
Action which disconnects a connector from the module.
WQtNetworkItemGrid * m_grid
we use a grid to place the items
WQtNetworkEditorView * m_view
The view controlling several scene transformations.
virtual ~WQtNetworkEditor()
destructor.
WQtNetworkEditor(WMainWindow *parent=0)
constructor
Implement a virtual grid for placing QGraphicsItems.
This class represents a WModule as QGraphicsItem and contains a reference to its in- and outports.
Layout manager class for a QGraphicsScene.
The scene containing the whole graph.