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 QString validityExtension; //! the string to add to ports to obtain the name of the associated validity port.
\r
98 // defaults for scene elements
\r
99 int defaultBlockWidth;
\r
100 int defaultBlockHeight;
\r
101 QFont defaultBlockFont;
\r
102 QString defaultBlockFontName;
\r
103 int defaultBlockFontSize;
\r
106 int arrowLineLength;
\r
107 QFont defaultIfaceFont;
\r
108 QString defaultIfaceFontName;
\r
109 int defaultIfaceFontSize;
\r
111 QPainterPath inArrow;
\r
112 QPainterPath outArrow;
\r
114 /***************************************************
\r
115 attributes that are specific for the current project
\r
116 ****************************************************/
\r
117 bool isCurrentProject; // true if a projet is currently open
\r
118 int sceneMode; // takes values from MODE_XXX
\r
119 CursorState cursorState;
\r
120 EditState editState; // takes values from EDIT_STATE_XXX
\r
122 bool isRstClkShown;
\r
124 Graph* createGraph();
\r
125 void destroyGraph();
\r
126 inline Graph* getGraph() { return graph; }
\r
127 ReferenceBlock* getReferenceBlock(int idCategory, int idBlock); // get the reference block from its category and index
\r
128 FunctionalBlock* duplicateFunctionalBlock(FunctionalBlock* block); // adding a copy of a functional block to current group
\r
133 QDomElement openProjectFile(const QString& projectFileName) throw(Exception);
\r
134 GroupWidget *loadProject(QDomElement root) throw(Exception);
\r
136 void loadBlastConfiguration(QString confFile) throw(Exception);
\r
137 void loadReferencesFromXml() throw(Exception);
\r
138 void loadReferencesFromLib() throw(Exception);
\r
139 void saveReferencesToLib() throw(Exception);
\r
141 void loadImplementationsFromXml() throw(Exception);
\r
142 void loadImplementationsFromLib() throw(Exception);
\r
143 void saveImplementationsToLib() throw(Exception);
\r
145 void addAvailableBlock(ReferenceBlock *block);
\r
146 void parametersValidation();
\r
147 void connectionsValidation();
\r
148 QList<AbstractBlock *> getBlocksToConfigure();
\r
150 void updateToolbar();
\r
153 ReferenceBlock* searchBlockByXml(QString xmlName);
\r
154 ReferenceBlock* searchBlockByMd5(QString sumMd5);
\r
156 void save(QString confFile);
\r
159 QString projectPath;
\r
162 Graph* graph; // the graph model of blocks
\r
163 Dispatcher* dispatcher;
\r
164 GroupScene* topScene;
\r
165 GroupScene* currentScene;
\r
167 void setArrowPathes();
\r
170 GroupScene* searchSceneById(int id, GroupScene* scene);
\r
171 BoxItem* searchBlockItemById(int id, GroupScene* scene);
\r
172 GroupItem* searchGroupItemById(int id, GroupScene* scene);
\r
173 InterfaceItem* searchInterfaceItemById(int id, GroupScene *scene);
\r
175 void validateXmlFile(const QString& xmlFileName, const QString& xsdFileName, XmlFileType fileType) throw(Exception);
\r
176 bool validate(QFile& fileXml, QFile& fileSchema);
\r
181 #endif // __PARAMETERS_H__
\r