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
84 static QString normalizeName(const QString& name);
\r
86 /***************************************************
\r
87 attributes that are general to the application
\r
88 ***************************************************/
\r
89 BlockLibraryTree* categoryTree;
\r
90 QList<QString> refPathes;
\r
91 QList<QString> implPathes;
\r
92 QList<ReferenceBlock*> availableBlocks;
\r
93 QList<BlockImplementation*> availableImplementations;
\r
94 ReferenceBlock* delayRef;
\r
95 BlockImplementation* delayImpl;
\r
100 // defaults for vhdl
\r
102 int wbAddressWidth;
\r
103 QString validityExtension; //! the string to add to ports to obtain the name of the associated validity port.
\r
105 // defaults for scene elements
\r
106 int defaultBlockWidth;
\r
107 int defaultBlockHeight;
\r
108 QFont defaultBlockFont;
\r
109 QString defaultBlockFontName;
\r
110 int defaultBlockFontSize;
\r
113 int arrowLineLength;
\r
114 QFont defaultIfaceFont;
\r
115 QString defaultIfaceFontName;
\r
116 int defaultIfaceFontSize;
\r
118 QPainterPath dataArrowIn;
\r
119 QPainterPath dataArrowOut;
\r
120 QPainterPath clkrstArrow;
\r
123 /***************************************************
\r
124 attributes that are specific for the current project
\r
125 ****************************************************/
\r
126 bool isCurrentProject; // true if a projet is currently open
\r
127 int sceneMode; // takes values from MODE_XXX
\r
128 CursorState cursorState;
\r
129 EditState editState; // takes values from EDIT_STATE_XXX
\r
131 bool isRstClkShown;
\r
132 QMap<FunctionalBlock*, BoxItem*> blockToItem; // allow to retrieve a box item from a functionnal block
\r
133 QString projectPath;
\r
134 QString projectName;
\r
135 QString projectFile; // equals to projectPath/projectName.xml
\r
137 Graph* createGraph();
\r
138 void destroyGraph();
\r
139 inline Graph* getGraph() { return graph; }
\r
140 ReferenceBlock* getReferenceBlock(int idCategory, int idBlock); // get the reference block from its category and index
\r
141 ReferenceBlock* getHiddenReferenceBlock(QString blockName); // get a hidden block by name, i.e. in category 100
\r
142 FunctionalBlock* duplicateFunctionalBlock(FunctionalBlock* block); // adding a copy of a functional block to current group
\r
147 QDomElement openProjectFile(const QString& projectFileName) throw(Exception);
\r
148 GroupWidget *loadProject(QDomElement root) throw(Exception);
\r
150 void loadBlastConfiguration(QString confFile) throw(Exception);
\r
151 void loadReferencesFromXml() throw(Exception);
\r
152 void loadReferencesFromLib() throw(Exception);
\r
153 void saveReferencesToLib() throw(Exception);
\r
154 void createDelayBlock();
\r
156 void loadImplementationsFromXml() throw(Exception);
\r
157 void loadImplementationsFromLib() throw(Exception);
\r
158 void saveImplementationsToLib() throw(Exception);
\r
160 void addAvailableBlock(ReferenceBlock *block);
\r
161 void parametersValidation();
\r
162 void connectionsValidation();
\r
163 QList<AbstractBlock *> getBlocksToConfigure();
\r
165 void updateToolbar();
\r
168 ReferenceBlock* searchBlockByXml(QString xmlName);
\r
169 ReferenceBlock* searchBlockByMd5(QString sumMd5);
\r
171 BoxItem* searchFunctionalBlock(AbstractBlock* block);
\r
173 void save(QString confFile);
\r
179 Graph* graph; // the graph model of blocks
\r
180 Dispatcher* dispatcher;
\r
181 GroupScene* topScene;
\r
182 GroupScene* currentScene;
\r
184 void setArrowPathes();
\r
187 GroupScene* searchSceneById(int id, GroupScene* scene);
\r
188 BoxItem* searchBlockItemById(int id, GroupScene* scene);
\r
189 BoxItem* searchFunctionalBlockRecur(AbstractBlock* block, GroupScene* scene);
\r
190 GroupItem* searchGroupItemById(int id, GroupScene* scene);
\r
191 InterfaceItem* searchInterfaceItemById(int id, GroupScene *scene);
\r
193 void validateXmlFile(const QString& xmlFileName, const QString& xsdFileName, XmlFileType fileType) throw(Exception);
\r
194 bool validate(QFile& fileXml, QFile& fileSchema);
\r
199 #endif // __PARAMETERS_H__
\r