]> AND Private Git Repository - blast.git/blob - Dispatcher.h
Logo AND Algorithmique Numérique Distribuée

Private GIT Repository
start to include clkdomain converters
[blast.git] / Dispatcher.h
1 #ifndef __DISPATCHER_H__
2 #define __DISPATCHER_H__
3
4 #include <iostream>
5
6 #include <QtCore>
7 #include <QtGui>
8 #include <QtWidgets>
9
10 class Graph;
11 class Parameters;
12 class MainWindow;
13 class GroupWidget;
14 class GroupScene;
15 class AbstractBoxItem;
16 class GroupItem;
17 class BoxItem;
18 class SourceItem;
19 class ConnectionItem;
20 class InterfaceItem;
21 class GroupBlock;
22 class FunctionalBlock;
23 #include "Exception.h"
24 class Exception;
25
26
27
28 using namespace std;
29 using namespace Qt;
30
31 /*!
32  * \brief The Dispatcher class
33  * The Dispatcher class represents the control part (in MVC) of the application. It relays
34  * user's interactions with the GUI into model's modifications and feeds back them onto the view.
35  */
36 class Dispatcher {
37
38 public:
39   Dispatcher(Parameters* _params,             
40              MainWindow* _window);
41
42   GroupWidget* loadProject(const QString& filename);
43
44   inline int getNumberOfScenes() { return groupList.length(); }
45   
46   void unselectAllItems(int direction=0);
47   void setCurrentGroupWidget(GroupWidget *win);
48   void changeConnectionMode(int mode = -1);
49
50
51   GroupWidget* createTopScene();
52   GroupWidget* createChildScene(GroupWidget* parentWidget, BoxItem* upperItemOfGroupItem = NULL);
53   void destroyScene(GroupScene* scene);
54   void showRaiseWindow(BoxItem *item);
55   void showRstClkIface(AbstractBoxItem *item);
56   void showWishboneIface(AbstractBoxItem *item);
57   GroupWidget *addNewEmptyGroup(GroupScene *scene, bool show = true);
58   void addNewFullGroup();  
59
60   inline GroupWidget* getCurrentGroup() { return currentGroup; }
61
62   inline void setSceneCounter(int value) { sceneCounter = value;}
63
64   bool isCurrentProject;
65
66 public slots:
67
68   // graph ops
69   QMap<int, QString> getAllGroupNames();
70   void generateVHDL() throw(Exception);
71
72   // scene ops
73   GroupScene* getSceneById(int id);
74   GroupScene* getSceneByName(QString name);
75   BoxItem* getBoxItemById(int id);
76   GroupItem* getGroupItemById(int id);
77   InterfaceItem* getInterfaceItemById(int id);
78
79
80   // block ops
81   BoxItem* addBlock(int idCategory, int idBlock, int idScene);
82   void removeBoxItem(BoxItem* item);
83   void duplicateBoxItem(BoxItem* item);
84   void renameFunctionalBlock(BoxItem* item);
85   void generateBlockVHDL(BoxItem* item);
86   void renameGroupBlock(GroupItem* item);
87   void renameSourceBlock(SourceItem* item);
88   void removeSourceItem(SourceItem* item);
89   void duplicateSourceItem(SourceItem* item);
90
91
92   // interface ops
93   /*!
94    * \brief connectInterToGroup
95    * \param item item is always owned by a BoxItem
96    *
97    * This method is called only when the user right clicks on an InterfaceItem (that belongs
98    * to a BoxItem and if it is NOT connected to an InterfaceItem of the GroupItem) and chooses
99    * connect to group in the contextual menu.
100    * Thus, parameter item is always owned by a BoxItem
101    */
102   void connectInterToGroup(InterfaceItem* item);  
103   /*!
104    * \brief removeFunctionalInterface
105    * \param item item is always owned by a BoxItem
106    *
107    * This method is called only when the user right clicks on an InterfaceItem (that belongs
108    * to a BoxItem that represents a functional block and has a multiplicity > 1) and chooses remove in the contextual menu.
109    * Thus, parameter item is always owned by a BoxItem
110    */
111   void removeFunctionalInterface(InterfaceItem* item);
112   /*!
113    * \brief removeGroupInterface
114    * \param item item is always owned by a GroupItem
115    *
116    * This method is called only when the user right clicks on an InterfaceItem (that belongs
117    * to a GroupItem and if it is connected only to an inner interface) and chooses remove in the contextual menu.
118    * Thus, parameter item is always owned by a GroupItem
119    */
120   void removeGroupInterface(InterfaceItem* item);
121   void duplicateInterfaceItem(InterfaceItem* item);
122   void showProperties(InterfaceItem *inter);
123   void renameInterface(InterfaceItem* item);
124   void showPatterns(InterfaceItem* item);
125   void showModifier(InterfaceItem* item);
126   void removeModifier(InterfaceItem* item);
127
128   // connection ops
129   bool createConnection(InterfaceItem *iface1, InterfaceItem *iface2, bool visible = true);
130   void removeAllBlockConnections(AbstractBoxItem *item);
131   void removeConnection(ConnectionItem *conn);
132
133
134   // analysis ops
135   void findGraphModifications(FunctionalBlock* block); // find modif so that block has compatible inputs
136
137   // others
138   void showBlocksLibrary();
139
140
141   void closeCurrentProject();
142
143 private:  
144
145   // the model
146   Parameters* params;
147
148   // attributes that corresponds to the views
149   MainWindow* mainWindow;
150   QList<GroupWidget*> groupList;
151   GroupWidget* currentGroup;
152   GroupWidget *topGroup;
153
154   static int sceneCounter;
155 };
156
157 #endif // __DISPATCHER_H__