1 #ifndef __PARAMETERS_H__
\r
2 #define __PARAMETERS_H__
\r
10 #include <QtXmlPatterns>
\r
13 class BlockLibraryTree;
\r
14 class AbstractBlock;
\r
15 class ReferenceBlock;
\r
17 class FunctionalBlock;
\r
19 class AbstractBoxItem;
\r
22 class InterfaceItem;
\r
26 #include "BlockImplementation.h"
\r
28 #include "Exception.h"
\r
31 // defines for current mode
\r
32 #define MODE_EDITION 1
\r
33 #define MODE_ADDBLOC 2
\r
34 #define MODE_ADDCONN 3
\r
37 using namespace std;
\r
41 * \brief The Parameters class
\r
43 * Parameters class represents the Model part of blast in MVC paradigm.
\r
44 * It contains all data necessary to create a design: the graph of blocks,
\r
51 enum Direction { NoDirection, East, North, West, South};
\r
53 /* state of cursorn:
\r
54 - CursorInBlock: cursor is within the main box of a block/group item
\r
55 - CursorOnBlockBorder: cursor is on a block/group item border
\r
56 - CursorOnInterface: cursor is on a block/group item Interface
\r
57 - CursorOnConnection: cursor is one a connection
\r
58 - CursorNowhere: none of the previous cases
\r
60 enum CursorState { CursorNowhere = 0, CursorInBlock, CursorInGroupTitle, CursorOnBorder, CursorOnInterface, CursorOnConnection };
\r
61 /* state of edition:
\r
64 enum EditState { EditNoOperation = 0, EditBlockMove, EditBlockResize, EditGroupMove, EditGroupResize, EditInterfaceMove, EditInterfaceDeselect, EditConnectionResize, EditStartConnection, EditCloseConnection, EditAbortConnection};
\r
66 enum XmlFileType { Configuration = 1, Reference, Implementation, Project };
\r
71 inline GroupScene* getCurrentScene() { return currentScene; }
\r
72 inline GroupScene* getTopScene() { return topScene; }
\r
75 inline void setTopScene(GroupScene* _topScene) { topScene = _topScene; }
\r
76 inline void setCurrentScene(GroupScene* _currentScene) { currentScene = _currentScene; }
\r
77 inline void setEditState(EditState state) { editState = state; }
\r
78 inline void setCursorState(CursorState state) { cursorState = state; }
\r
79 inline void setDispatcher(Dispatcher* _dispatcher) { dispatcher = _dispatcher;}
\r
81 /***************************************************
\r
82 attributes that are general to the application
\r
83 ***************************************************/
\r
84 BlockLibraryTree* categoryTree;
\r
85 QList<QString> refPathes;
\r
86 QList<QString> implPathes;
\r
87 QList<ReferenceBlock*> availableBlocks;
\r
88 QList<BlockImplementation*> availableImplementations;
\r
89 ReferenceBlock* delayRef;
\r
90 BlockImplementation* delayImpl;
\r
95 // defaults for vhdl
\r
98 QString validityExtension; //! the string to add to ports to obtain the name of the associated validity port.
\r
100 // defaults for scene elements
\r
101 int defaultBlockWidth;
\r
102 int defaultBlockHeight;
\r
103 QFont defaultBlockFont;
\r
104 QString defaultBlockFontName;
\r
105 int defaultBlockFontSize;
\r
108 int arrowLineLength;
\r
109 QFont defaultIfaceFont;
\r
110 QString defaultIfaceFontName;
\r
111 int defaultIfaceFontSize;
\r
113 QPainterPath inArrow;
\r
114 QPainterPath outArrow;
\r
116 /***************************************************
\r
117 attributes that are specific for the current project
\r
118 ****************************************************/
\r
119 bool isCurrentProject; // true if a projet is currently open
\r
120 int sceneMode; // takes values from MODE_XXX
\r
121 CursorState cursorState;
\r
122 EditState editState; // takes values from EDIT_STATE_XXX
\r
124 bool isRstClkShown;
\r
125 QMap<FunctionalBlock*, BoxItem*> blockToItem; // allow to retrieve a box item from a functionnal block
\r
127 Graph* createGraph();
\r
128 void destroyGraph();
\r
129 inline Graph* getGraph() { return graph; }
\r
130 ReferenceBlock* getReferenceBlock(int idCategory, int idBlock); // get the reference block from its category and index
\r
131 FunctionalBlock* duplicateFunctionalBlock(FunctionalBlock* block); // adding a copy of a functional block to current group
\r
136 QDomElement openProjectFile(const QString& projectFileName) throw(Exception);
\r
137 GroupWidget *loadProject(QDomElement root) throw(Exception);
\r
139 void loadBlastConfiguration(QString confFile) throw(Exception);
\r
140 void loadReferencesFromXml() throw(Exception);
\r
141 void loadReferencesFromLib() throw(Exception);
\r
142 void saveReferencesToLib() throw(Exception);
\r
143 void createDelayBlock();
\r
145 void loadImplementationsFromXml() throw(Exception);
\r
146 void loadImplementationsFromLib() throw(Exception);
\r
147 void saveImplementationsToLib() throw(Exception);
\r
149 void addAvailableBlock(ReferenceBlock *block);
\r
150 void parametersValidation();
\r
151 void connectionsValidation();
\r
152 QList<AbstractBlock *> getBlocksToConfigure();
\r
154 void updateToolbar();
\r
157 ReferenceBlock* searchBlockByXml(QString xmlName);
\r
158 ReferenceBlock* searchBlockByMd5(QString sumMd5);
\r
160 BoxItem* searchFunctionalBlock(AbstractBlock* block);
\r
162 void save(QString confFile);
\r
165 QString projectPath;
\r
168 Graph* graph; // the graph model of blocks
\r
169 Dispatcher* dispatcher;
\r
170 GroupScene* topScene;
\r
171 GroupScene* currentScene;
\r
173 void setArrowPathes();
\r
176 GroupScene* searchSceneById(int id, GroupScene* scene);
\r
177 BoxItem* searchBlockItemById(int id, GroupScene* scene);
\r
178 BoxItem* searchFunctionalBlockRecur(AbstractBlock* block, GroupScene* scene);
\r
179 GroupItem* searchGroupItemById(int id, GroupScene* scene);
\r
180 InterfaceItem* searchInterfaceItemById(int id, GroupScene *scene);
\r
182 void validateXmlFile(const QString& xmlFileName, const QString& xsdFileName, XmlFileType fileType) throw(Exception);
\r
183 bool validate(QFile& fileXml, QFile& fileSchema);
\r
188 #endif // __PARAMETERS_H__
\r