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 dataArrowIn;
\r
114 QPainterPath dataArrowOut;
\r
115 QPainterPath clkrstArrow;
\r
118 /***************************************************
\r
119 attributes that are specific for the current project
\r
120 ****************************************************/
\r
121 bool isCurrentProject; // true if a projet is currently open
\r
122 int sceneMode; // takes values from MODE_XXX
\r
123 CursorState cursorState;
\r
124 EditState editState; // takes values from EDIT_STATE_XXX
\r
126 bool isRstClkShown;
\r
127 QMap<FunctionalBlock*, BoxItem*> blockToItem; // allow to retrieve a box item from a functionnal block
\r
129 Graph* createGraph();
\r
130 void destroyGraph();
\r
131 inline Graph* getGraph() { return graph; }
\r
132 ReferenceBlock* getReferenceBlock(int idCategory, int idBlock); // get the reference block from its category and index
\r
133 ReferenceBlock* getHiddenReferenceBlock(QString blockName); // get a hidden block by name, i.e. in category 100
\r
134 FunctionalBlock* duplicateFunctionalBlock(FunctionalBlock* block); // adding a copy of a functional block to current group
\r
139 QDomElement openProjectFile(const QString& projectFileName) throw(Exception);
\r
140 GroupWidget *loadProject(QDomElement root) throw(Exception);
\r
142 void loadBlastConfiguration(QString confFile) throw(Exception);
\r
143 void loadReferencesFromXml() throw(Exception);
\r
144 void loadReferencesFromLib() throw(Exception);
\r
145 void saveReferencesToLib() throw(Exception);
\r
146 void createDelayBlock();
\r
148 void loadImplementationsFromXml() throw(Exception);
\r
149 void loadImplementationsFromLib() throw(Exception);
\r
150 void saveImplementationsToLib() throw(Exception);
\r
152 void addAvailableBlock(ReferenceBlock *block);
\r
153 void parametersValidation();
\r
154 void connectionsValidation();
\r
155 QList<AbstractBlock *> getBlocksToConfigure();
\r
157 void updateToolbar();
\r
160 ReferenceBlock* searchBlockByXml(QString xmlName);
\r
161 ReferenceBlock* searchBlockByMd5(QString sumMd5);
\r
163 BoxItem* searchFunctionalBlock(AbstractBlock* block);
\r
165 void save(QString confFile);
\r
168 QString projectPath;
\r
171 Graph* graph; // the graph model of blocks
\r
172 Dispatcher* dispatcher;
\r
173 GroupScene* topScene;
\r
174 GroupScene* currentScene;
\r
176 void setArrowPathes();
\r
179 GroupScene* searchSceneById(int id, GroupScene* scene);
\r
180 BoxItem* searchBlockItemById(int id, GroupScene* scene);
\r
181 BoxItem* searchFunctionalBlockRecur(AbstractBlock* block, GroupScene* scene);
\r
182 GroupItem* searchGroupItemById(int id, GroupScene* scene);
\r
183 InterfaceItem* searchInterfaceItemById(int id, GroupScene *scene);
\r
185 void validateXmlFile(const QString& xmlFileName, const QString& xsdFileName, XmlFileType fileType) throw(Exception);
\r
186 bool validate(QFile& fileXml, QFile& fileSchema);
\r
191 #endif // __PARAMETERS_H__
\r