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
27 #include "ExternalResource.h"
\r
29 #include "Exception.h"
\r
32 // defines for current mode
\r
33 #define MODE_EDITION 1
\r
34 #define MODE_ADDBLOC 2
\r
35 #define MODE_ADDCONN 3
\r
38 using namespace std;
\r
42 * \brief The Parameters class
\r
44 * Parameters class represents the Model part of blast in MVC paradigm.
\r
45 * It contains all data necessary to create a design: the graph of blocks,
\r
52 enum Direction { NoDirection, East, North, West, South};
\r
54 /* state of cursorn:
\r
55 - CursorInBlock: cursor is within the main box of a block/group item
\r
56 - CursorOnBlockBorder: cursor is on a block/group item border
\r
57 - CursorOnInterface: cursor is on a block/group item Interface
\r
58 - CursorOnConnection: cursor is one a connection
\r
59 - CursorNowhere: none of the previous cases
\r
61 enum CursorState { CursorNowhere = 0, CursorInBlock, CursorInGroupTitle, CursorOnBorder, CursorOnInterface, CursorOnConnection };
\r
62 /* state of edition:
\r
65 enum EditState { EditNoOperation = 0, EditBlockMove, EditBlockResize, EditGroupMove, EditGroupResize, EditInterfaceMove, EditInterfaceDeselect, EditConnectionResize, EditStartConnection, EditCloseConnection, EditAbortConnection};
\r
67 enum XmlFileType { Configuration = 1, Reference, Implementation, Project };
\r
72 inline GroupScene* getCurrentScene() { return currentScene; }
\r
73 inline GroupScene* getTopScene() { return topScene; }
\r
76 inline void setTopScene(GroupScene* _topScene) { topScene = _topScene; }
\r
77 inline void setCurrentScene(GroupScene* _currentScene) { currentScene = _currentScene; }
\r
78 inline void setEditState(EditState state) { editState = state; }
\r
79 inline void setCursorState(CursorState state) { cursorState = state; }
\r
80 inline void setDispatcher(Dispatcher* _dispatcher) { dispatcher = _dispatcher;}
\r
85 static QString normalizeName(const QString& name);
\r
86 QList<ExternalResource*> searchResourceByName(const QString& name);
\r
88 /***************************************************
\r
89 attributes that are general to the application
\r
90 ***************************************************/
\r
91 BlockLibraryTree* categoryTree;
\r
92 QList<QString> refPathes;
\r
93 QList<QString> implPathes;
\r
94 QList<QString> sourcePathes;
\r
95 QList<ReferenceBlock*> availableBlocks;
\r
96 QList<BlockImplementation*> availableImplementations;
\r
97 QList<ExternalResource*> availableResources;
\r
99 ReferenceBlock* delayRef;
\r
100 BlockImplementation* delayImpl;
\r
105 // defaults for vhdl
\r
107 int wbAddressWidth;
\r
108 QString validityExtension; //! the string to add to ports to obtain the name of the associated validity port.
\r
110 // defaults for scene elements
\r
111 int defaultBlockWidth;
\r
112 int defaultBlockHeight;
\r
113 QFont defaultBlockFont;
\r
114 QString defaultBlockFontName;
\r
115 int defaultBlockFontSize;
\r
118 int arrowLineLength;
\r
119 QFont defaultIfaceFont;
\r
120 QString defaultIfaceFontName;
\r
121 int defaultIfaceFontSize;
\r
123 QPainterPath dataArrowIn;
\r
124 QPainterPath dataArrowOut;
\r
125 QPainterPath clkrstArrow;
\r
128 /***************************************************
\r
129 attributes that are specific for the current project
\r
130 ****************************************************/
\r
131 bool isCurrentProject; // true if a projet is currently open
\r
132 int sceneMode; // takes values from MODE_XXX
\r
133 CursorState cursorState;
\r
134 EditState editState; // takes values from EDIT_STATE_XXX
\r
136 bool isRstClkShown;
\r
137 QMap<FunctionalBlock*, BoxItem*> blockToItem; // allow to retrieve a box item from a functionnal block
\r
138 QString projectPath;
\r
139 QString projectName;
\r
140 QString projectFile; // equals to projectPath/projectName.xml
\r
142 Graph* createGraph();
\r
143 void destroyGraph();
\r
144 inline Graph* getGraph() { return graph; }
\r
145 ReferenceBlock* getReferenceBlock(int idCategory, int idBlock); // get the reference block from its category and index
\r
146 ReferenceBlock* getHiddenReferenceBlock(QString blockName); // get a hidden block by name, i.e. in category 100
\r
147 FunctionalBlock* duplicateFunctionalBlock(FunctionalBlock* block); // adding a copy of a functional block to current group
\r
152 QDomElement openProjectFile(const QString& projectFileName) throw(Exception);
\r
153 GroupWidget *loadProject(QDomElement root) throw(Exception);
\r
155 void loadBlastConfiguration(QString confFile) throw(Exception);
\r
156 void loadReferencesFromXml() throw(Exception);
\r
157 void loadReferencesFromLib() throw(Exception);
\r
158 void saveReferencesToLib() throw(Exception);
\r
159 void createDelayBlock();
\r
161 void loadImplementationsFromXml() throw(Exception);
\r
162 void loadImplementationsFromLib() throw(Exception);
\r
163 void saveImplementationsToLib() throw(Exception);
\r
165 void loadSources() throw(Exception);
\r
167 void addAvailableBlock(ReferenceBlock *block);
\r
168 void parametersValidation();
\r
169 void connectionsValidation();
\r
170 QList<AbstractBlock *> getBlocksToConfigure();
\r
172 void updateToolbar();
\r
175 ReferenceBlock* searchBlockByXml(QString xmlName);
\r
176 ReferenceBlock* searchBlockByMd5(QString sumMd5);
\r
178 BoxItem* searchFunctionalBlock(AbstractBlock* block);
\r
180 void save(QString confFile);
\r
186 Graph* graph; // the graph model of blocks
\r
187 Dispatcher* dispatcher;
\r
188 GroupScene* topScene;
\r
189 GroupScene* currentScene;
\r
191 void setArrowPathes();
\r
194 GroupScene* searchSceneById(int id, GroupScene* scene);
\r
195 BoxItem* searchBlockItemById(int id, GroupScene* scene);
\r
196 BoxItem* searchFunctionalBlockRecur(AbstractBlock* block, GroupScene* scene);
\r
197 GroupItem* searchGroupItemById(int id, GroupScene* scene);
\r
198 InterfaceItem* searchInterfaceItemById(int id, GroupScene *scene);
\r
200 void validateXmlFile(const QString& xmlFileName, const QString& xsdFileName, XmlFileType fileType) throw(Exception);
\r
201 bool validate(QFile& fileXml, QFile& fileSchema);
\r
206 #endif // __PARAMETERS_H__
\r