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