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
21 class InterfaceItem;
\r
24 #include "BlockImplementation.h"
\r
26 #include "Exception.h"
\r
29 // defines for current mode
\r
30 #define MODE_EDITION 1
\r
31 #define MODE_ADDBLOC 2
\r
32 #define MODE_ADDCONN 3
\r
35 using namespace std;
\r
39 * \brief The Parameters class
\r
41 * Parameters class represents the Model part of blast in MVC paradigm.
\r
42 * It contains all data necessary to create a design: the graph of blocks,
\r
49 enum Direction { NoDirection, East, North, West, South};
\r
51 /* state of cursorn:
\r
52 - CursorInBlock: cursor is within the main box of a block/group item
\r
53 - CursorOnBlockBorder: cursor is on a block/group item border
\r
54 - CursorOnInterface: cursor is on a block/group item Interface
\r
55 - CursorOnConnection: cursor is one a connection
\r
56 - CursorNowhere: none of the previous cases
\r
58 enum CursorState { CursorNowhere = 0, CursorInBlock, CursorInGroupTitle, CursorOnBorder, CursorOnInterface, CursorOnConnection };
\r
59 /* state of edition:
\r
62 enum EditState { EditNoOperation = 0, EditBlockMove, EditBlockResize, EditGroupMove, EditGroupResize, EditInterfaceMove, EditInterfaceDeselect, EditConnectionResize, EditStartConnection, EditCloseConnection, EditAbortConnection};
\r
64 enum XmlFileType { Configuration = 1, Reference, Implementation, Project };
\r
69 inline GroupScene* getCurrentScene() { return currentScene; }
\r
70 inline GroupScene* getTopScene() { return topScene; }
\r
73 inline void setTopScene(GroupScene* _topScene) { topScene = _topScene; }
\r
74 inline void setCurrentScene(GroupScene* _currentScene) { currentScene = _currentScene; }
\r
75 inline void setEditState(EditState state) { editState = state; }
\r
76 inline void setCursorState(CursorState state) { cursorState = state; }
\r
77 inline void setDispatcher(Dispatcher* _dispatcher) { dispatcher = _dispatcher;}
\r
79 /***************************************************
\r
80 attributes that are general to the application
\r
81 ***************************************************/
\r
82 BlockLibraryTree* categoryTree;
\r
83 QList<QString> refPathes;
\r
84 QList<QString> implPathes;
\r
85 QList<ReferenceBlock*> availableBlocks;
\r
86 QList<BlockImplementation*> availableImplementations;
\r
92 // defaults for vhdl
\r
95 // defaults for scene elements
\r
96 int defaultBlockWidth;
\r
97 int defaultBlockHeight;
\r
98 QFont defaultBlockFont;
\r
99 QString defaultBlockFontName;
\r
100 int defaultBlockFontSize;
\r
103 int arrowLineLength;
\r
104 QFont defaultIfaceFont;
\r
105 QString defaultIfaceFontName;
\r
106 int defaultIfaceFontSize;
\r
108 QPainterPath inArrow;
\r
109 QPainterPath outArrow;
\r
111 /***************************************************
\r
112 attributes that are specific for the current project
\r
113 ****************************************************/
\r
114 bool isCurrentProject; // true if a projet is currently open
\r
115 int sceneMode; // takes values from MODE_XXX
\r
116 CursorState cursorState;
\r
117 EditState editState; // takes values from EDIT_STATE_XXX
\r
119 bool isRstClkShown;
\r
121 Graph* createGraph();
\r
122 void destroyGraph();
\r
123 inline Graph* getGraph() { return graph; }
\r
124 ReferenceBlock* getReferenceBlock(int idCategory, int idBlock); // get the reference block from its category and index
\r
125 FunctionalBlock* duplicateFunctionalBlock(FunctionalBlock* block); // adding a copy of a functional block to current group
\r
130 QDomElement openProjectFile(const QString& projectFileName) throw(Exception);
\r
131 void loadProject(QDomElement root);
\r
133 void loadBlastConfiguration(QString confFile) throw(Exception);
\r
134 void loadReferencesFromXml() throw(Exception);
\r
135 void loadReferencesFromLib() throw(Exception);
\r
136 void saveReferencesToLib() throw(Exception);
\r
138 void loadImplementationsFromXml() throw(Exception);
\r
139 void loadImplementationsFromLib() throw(Exception);
\r
140 void saveImplementationsToLib() throw(Exception);
\r
142 void addAvailableBlock(ReferenceBlock *block);
\r
143 void parametersValidation();
\r
144 void connectionsValidation();
\r
145 QList<AbstractBlock *> getBlocksToConfigure();
\r
147 void updateToolbar();
\r
150 ReferenceBlock* searchBlockByXml(QString xmlName);
\r
151 ReferenceBlock* searchBlockByMd5(QString sumMd5);
\r
153 void save(QString confFile);
\r
156 QString projectPath;
\r
159 Graph* graph; // the graph model of blocks
\r
160 Dispatcher* dispatcher;
\r
161 GroupScene* topScene;
\r
162 GroupScene* currentScene;
\r
164 void setArrowPathes();
\r
167 GroupScene* searchSceneById(int id, GroupScene* scene);
\r
168 BoxItem* searchBlockItemById(int id, GroupScene* scene);
\r
169 GroupItem* searchGroupItemById(int id, GroupScene* scene);
\r
170 InterfaceItem* searchInterfaceItemById(int id, GroupScene *scene);
\r
172 void validateXmlFile(const QString& xmlFileName, const QString& xsdFileName, XmlFileType fileType) throw(Exception);
\r
173 bool validate(QFile& fileXml, QFile& fileSchema);
\r
178 #endif // __PARAMETERS_H__
\r