}\r
/* NB: a generator is a block that has no data inputs\r
* and has at least one data output.\r
- * By the way, blokcs that have no data input/output\r
+ * By the way, blocks that have no data input/output\r
* (like clkrstgen) are not generators !\r
*/\r
bool AbstractBlock::isGeneratorBlock() {\r
#include "ConnectedInterface.h"
-AbstractBoxItem:: AbstractBoxItem(AbstractBlock *_refBlock, Dispatcher *_dispatcher, Parameters *_params, QGraphicsItem *parent) : QGraphicsItem(parent) {
+AbstractBoxItem:: AbstractBoxItem(AbstractBlock *_refBlock, Dispatcher *_dispatcher, Parameters *_params, LockType _lock, QGraphicsItem *parent) : QGraphicsItem(parent) {
dispatcher = _dispatcher;
params = _params;
refBlock = _refBlock;
+ lock = _lock;
QFontMetrics fmId(params->defaultBlockFont);
nameWidth = fmId.width(refBlock->getName());
nameHeight = fmId.height();
// NOTE : initInterfaces() is only called in subclasses
}
-AbstractBoxItem::AbstractBoxItem(Dispatcher *_dispatcher, Parameters *_params, QGraphicsItem* parent) : QGraphicsItem(parent) {
+AbstractBoxItem::AbstractBoxItem(Dispatcher *_dispatcher, Parameters *_params, LockType _lock, QGraphicsItem* parent) : QGraphicsItem(parent) {
dispatcher = _dispatcher;
- params = _params;
+ params = _params;
refBlock = NULL;
+ lock = _lock;
nameWidth = 0;
nameHeight = 0;
nameMargin = 10;
enum BorderType { NoBorder = 0, BorderEast, BorderNorth, BorderWest, BorderSouth, CornerSouthEast, Title};
enum ChangeType { Resize = 0, InterfaceMove };
+ enum LockType { NoLock = 0, Position = 1, Dimension = 2, Interfaces = 4, Names = 8};
- AbstractBoxItem(AbstractBlock *_refBlock, Dispatcher *_dispatcher, Parameters *_params, QGraphicsItem* parent = Q_NULLPTR);
- AbstractBoxItem(Dispatcher *_dispatcher, Parameters *_params, QGraphicsItem* parent = Q_NULLPTR);
+ AbstractBoxItem(AbstractBlock *_refBlock, Dispatcher *_dispatcher, Parameters *_params, LockType _lock = NoLock, QGraphicsItem* parent = Q_NULLPTR);
+ AbstractBoxItem(Dispatcher *_dispatcher, Parameters *_params, LockType _lock = NoLock, QGraphicsItem* parent = Q_NULLPTR);
virtual ~AbstractBoxItem();
void setWishboneVisible(bool b);
void setDimension(int x, int y);
inline void setCurrentInterface(InterfaceItem* iface) { currentInterface = iface; }
+ inline void setLock(int _lock) { lock = _lock; }
+ inline void lockPosition() { lock = lock | Position; }
+ inline void unlockPosition() { lock = (lock&Position)^lock; }
+ inline void lockDimension() { lock = lock | Dimension; }
+ inline void unlockDimension() { lock = (lock&Dimension)^lock; }
+ inline void lockInterfaces() { lock = lock | Interfaces; }
+ inline void unlockInterfaces() { lock = (lock&Interfaces)^lock; }
+ inline void lockNames() { lock = lock | Names; }
+ inline void unlockNames() { lock = (lock&Names)^lock; }
// testers
virtual bool isBoxItem();
inline bool isRstClkVisible(){ return rstClkVisible;}
inline bool isWishboneVisible(){ return wishboneVisible;}
bool isInterfaces(int orientation) const;
-
+ inline bool isPositionLock() { return (lock&Position)!=0?true:false; }
+ inline bool isDimensionLock() { return (lock&Dimension)!=0?true:false; }
+ inline bool isInterfacesLock() { return (lock&Interfaces)!=0?true:false; }
+ inline bool isNamesLock() { return (lock&Names)!=0?true:false; }
// others
QRectF boundingRectInScene();
virtual void nameChanged() = 0; // called when an interface or box name have changed
int ifaceMargin; // the margin around each side of interfaces' name
QPointF originPoint; // the left-top point that is the origin of the bounding box, in the item coordinates
+ int lock;
bool selected;
bool rstClkVisible; //! true if clock/reset interfaces are visible
bool wishboneVisible; //! true if wishbone interfaces are visible
return ret;
}
-QString AbstractInterface::toVHDL(int context, int flags) throw(Exception) {
+QString AbstractInterface::toVHDL(IfaceVHDLContext context, int flags) throw(Exception) {
if (isReferenceInterface()) throw(Exception(IFACE_INVALID_TYPE));
int typeFromString(const QString &_type);
- QString toVHDL(int context, int flags) throw(Exception);
+ QString toVHDL(IfaceVHDLContext context, int flags) throw(Exception);
protected:
QString name;
int idBlock = item->data(2,Qt::DisplayRole).toInt();
QVariant v = comboScenes->currentData();
cout << "adding block to scene " << v.toInt() << endl;
- dispatcher->addBlock(idParent, idBlock, v.toInt());
+ dispatcher->addBlock(Dispatcher::Design, idParent, idBlock, v.toInt());
}
// only take the first selected
BoxItem::BoxItem(AbstractBlock *_refBlock,
Dispatcher *_dispatcher,
- Parameters *_params, GroupItem *parent) throw(Exception) : AbstractBoxItem( _refBlock, _dispatcher, _params, parent) {
+ Parameters *_params, GroupItem *parent, LockType _lock, SpanType _span, Position _hPos, Position _vPos) throw(Exception) : AbstractBoxItem( _refBlock, _dispatcher, _params, _lock, parent) {
/* NOTE :
_refBlock : mandatory a FunctionalBlock or a GroupBlock
*/
- if (_refBlock->isReferenceBlock()) throw(Exception(BLOCK_INVALID_TYPE));
+ if (_refBlock->isReferenceBlock()) throw(Exception(BLOCK_INVALID_TYPE));
+
+ span = _span;
+ hPos = _hPos;
+ vPos = _vPos;
childGroupItem = NULL;
//boxWidth = params->defaultBlockWidth;
selected = false;
setZValue(100);
- setFlags(QGraphicsItem::ItemIsMovable | QGraphicsItem::ItemIsSelectable | QGraphicsItem::ItemSendsGeometryChanges);
+ QGraphicsItem::GraphicsItemFlags flags = QGraphicsItem::ItemIsSelectable;
+ if (!isPositionLock()) {
+ flags |= QGraphicsItem::ItemIsMovable;
+ }
+ if (!isDimensionLock()) {
+ flags |= QGraphicsItem::ItemSendsGeometryChanges;
+ }
+ setFlags(flags);
initInterfaceItems();
updateGeometry(InterfaceMove);
//cout << "pos in group: " << x() << "," << y() << endl;
}
-BoxItem::BoxItem(Dispatcher *_dispatcher, Parameters *_params, GroupItem *parent) throw(Exception) : AbstractBoxItem(_dispatcher, _params, parent) {
+BoxItem::BoxItem(Dispatcher *_dispatcher, Parameters *_params, GroupItem *parent, LockType _lock, SpanType _span, Position _hPos, Position _vPos) throw(Exception) : AbstractBoxItem(_dispatcher, _params, _lock, parent) {
+
+ span = _span;
+ hPos = _hPos;
+ vPos = _vPos;
refBlock = NULL;
childGroupItem = NULL;
selected = false;
setZValue(100);
- setFlags(QGraphicsItem::ItemIsMovable | QGraphicsItem::ItemIsSelectable | QGraphicsItem::ItemSendsGeometryChanges);
+ QGraphicsItem::GraphicsItemFlags flags = QGraphicsItem::ItemIsSelectable;
+ if (!isPositionLock()) {
+ flags |= QGraphicsItem::ItemIsMovable;
+ }
+ if (!isDimensionLock()) {
+ flags |= QGraphicsItem::ItemSendsGeometryChanges;
+ }
+ setFlags(flags);
boxWidth = params->defaultBlockWidth;
boxHeight = params->defaultBlockHeight;
int mode = getScene()->getEditionMode();
- dispatcher->setCurrentGroupWidget(getScene()->getGroupWidget());
+ dispatcher->setCurrentGroupWidget(Dispatcher::Design, getScene()->getGroupWidget());
if ((mode == GroupScene::AddConnection) && (params->cursorState == Parameters::CursorOnInterface)) {
InterfaceItem *inter = getInterfaceItemFromCursor(x,y);
else if (params->editState == Parameters::EditCloseConnection) {
InterfaceItem* iface1 = getScene()->getSelectedInterface(1);
InterfaceItem* iface2 = getScene()->getSelectedInterface(2);
- bool ok = dispatcher->createConnection(iface1,iface2);
+ bool ok = dispatcher->createConnection(Dispatcher::Design, iface1,iface2);
if (ok) {
iface1->selected = false;
update(iface1->boundingRect());
if (selectedAction == removeAction) {
if(ifaceItem != NULL) {
- dispatcher->removeFunctionalInterface(ifaceItem);
+ dispatcher->removeFunctionalInterface(Dispatcher::Design, ifaceItem);
}
else {
- dispatcher->removeBoxItem(this);
+ dispatcher->removeBoxItem(Dispatcher::Design, this);
}
}
else if (selectedAction == duplicateAction) {
- dispatcher->duplicateBoxItem(this);
+ dispatcher->duplicateBoxItem(Dispatcher::Design, this);
}
else if(selectedAction == renameAction){
if(ifaceItem != NULL) {
- dispatcher->renameInterface(ifaceItem);
+ dispatcher->renameInterface(Dispatcher::Design, ifaceItem);
}
else {
if (refBlock->isFunctionalBlock()) {
- dispatcher->renameFunctionalBlock(this);
+ dispatcher->renameFunctionalBlock(Dispatcher::Design, this);
}
else if (refBlock->isGroupBlock()) {
- dispatcher->renameGroupBlock(childGroupItem);
+ dispatcher->renameGroupBlock(Dispatcher::Design, childGroupItem);
}
}
}
else if(selectedAction == showProperties){
- dispatcher->showProperties(ifaceItem);
+ dispatcher->showProperties(Dispatcher::Design, ifaceItem);
}
else if (selectedAction == connectToGroup){
- dispatcher->connectInterToGroup(ifaceItem);
+ dispatcher->connectInterToGroup(Dispatcher::Design, ifaceItem);
}
else if (selectedAction == cloneInterface){
- dispatcher->duplicateInterfaceItem(ifaceItem);
+ dispatcher->duplicateInterfaceItem(Dispatcher::Design, ifaceItem);
}
else if (selectedAction == openWindow){
- dispatcher->showRaiseWindow(this);
+ dispatcher->showRaiseWindow(Dispatcher::Design, this);
}
else if(selectedAction == showRstClkIface) {
- dispatcher->showRstClkIface(this);
+ dispatcher->showRstClkIface(Dispatcher::Design, this);
}
else if(selectedAction == showWishboneIface) {
- dispatcher->showWishboneIface(this);
+ dispatcher->showWishboneIface(Dispatcher::Design, this);
}
else if(selectedAction == showParameters) {
new ParametersWindow(refBlock, params, NULL);
}
else if(selectedAction == showPatterns) {
- dispatcher->showPatterns(ifaceItem);
+ dispatcher->showPatterns(Dispatcher::Design, ifaceItem);
}
else if(selectedAction == removeModifier) {
- dispatcher->removeModifier(ifaceItem);
+ dispatcher->removeModifier(Dispatcher::Design, ifaceItem);
}
else if(selectedAction == showModifier) {
- dispatcher->showModifier(ifaceItem);
+ dispatcher->showModifier(Dispatcher::Design, ifaceItem);
}
else if(selectedAction == generateVHDL) {
- dispatcher->generateBlockVHDL(this);
+ dispatcher->generateBlockVHDL(Dispatcher::Design, this);
}
}
class BoxItem : public AbstractBoxItem {
public:
- BoxItem(AbstractBlock *_refBlock, Dispatcher *_dispatcher, Parameters *_params, GroupItem* parent) throw(Exception);
- BoxItem(Dispatcher *_dispatcher, Parameters *_params, GroupItem* parent) throw(Exception);
+
+ enum Position { Left = 1, Right, Top, Bottom, Center};
+ enum SpanType { NoSpan = 0, HSpan = 1, VSpan = 2 };
+
+ BoxItem(AbstractBlock *_refBlock, Dispatcher *_dispatcher, Parameters *_params, GroupItem* parent, LockType _lock = NoLock, SpanType _span = NoSpan, Position _hPos = Center, Position _vPos = Center) throw(Exception);
+ BoxItem(Dispatcher *_dispatcher, Parameters *_params, GroupItem* parent, LockType _lock = NoLock, SpanType _span = NoSpan, Position _hPos = Center, Position _vPos = Center) throw(Exception);
~BoxItem();
void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget = 0);
protected:
+ SpanType span;
+ Position hPos;
+ Position vPos;
+
void updateMinimumSize(); // modify the minimum size
bool updateGeometry(ChangeType type); // modify the originPoint and the total dimension
private:
/* NOTE :
- A BlockItem is always graphically within a GroupItem, inside the same scene.
+ A BoxItem is always graphically within a GroupItem, inside the same scene.
- A BlockItem may also be the graphical view of a GroupBlock. In this case, there exists a child scene
+ A BoxItem may also be the graphical view of a GroupBlock. In this case, there exists a child scene
containing a GroupItem. insideGroup atribute refers to this GroupItem and thus, may be NULL if the current
blockItem represents a functional block
*/
QAction * selectedAction= menu.exec(event->screenPos());
if(selectedAction == removeAction){
- dispatcher->removeConnection(this);
+ dispatcher->removeConnection(Dispatcher::Design, this);
}
}
}
params = _params;
mainWindow =_window;
params->setDispatcher(this);
- currentGroup = NULL;
- topGroup = NULL;
+ currentGroupWidget = NULL;
+ topGroupWidget = NULL;
}
GroupWidget *Dispatcher::loadProject(const QString& filename) {
params->setCurrentScene(scene);
*/
try {
- topGroup = params->loadProject(root);
+ topGroupWidget = params->loadProject(root);
}
catch(Exception e){
cerr << qPrintable(e.getDefaultMessage()) << endl;
params->projectPath = info.absolutePath();
params->projectName = info.baseName();
cout << "project path = " << qPrintable(params->projectPath) << endl;
- groupList.append(topGroup);
- return topGroup;
+ groupList.append(topGroupWidget);
+ return topGroupWidget;
}
void Dispatcher::closeCurrentProject() {
}
groupList.clear();
params->destroyGraph();
- topGroup = NULL;
- currentGroup = NULL;
+ topGroupWidget = NULL;
+ currentGroupWidget = NULL;
sceneCounter = 0;
}
-bool Dispatcher::createConnection(InterfaceItem *iface1, InterfaceItem *iface2, bool visible) {
+void Dispatcher::setSceneCounter(Context context, int value) {
+
+ if (context != Load) return;
+ sceneCounter = value;
+}
+
+bool Dispatcher::createConnection(Context context, InterfaceItem *iface1, InterfaceItem *iface2, bool visible) {
ConnectedInterface* ref1 = iface1->refInter;
ConnectedInterface* ref2 = iface2->refInter;
iface1->getOwner()->getScene()->createConnectionItem(iface1,iface2, visible);
- unselectAllItems();
+ unselectAllItems(context);
params->unsaveModif = true;
cout << "created a connection from " << qPrintable(ref1->getName()) << " to " << qPrintable(ref2->getName()) << endl;
return true;
}
-void Dispatcher::unselectAllItems(int direction){
+void Dispatcher::unselectAllItems(Context context, int direction){
GroupScene *scene = params->getCurrentScene();
scene->update();
}
-void Dispatcher::setCurrentGroupWidget(GroupWidget *win){
+void Dispatcher::setCurrentGroupWidget(Context context, GroupWidget *win){
win->setFocus();
win->changeConnectionMode(-1);
- currentGroup = win;
+ currentGroupWidget = win;
params->setCurrentScene(win->getScene());
}
-void Dispatcher::changeConnectionMode(int mode){
+void Dispatcher::changeConnectionMode(Context context, int mode){
/*
foreach(GroupWidget* win, groupList){
*/
}
-void Dispatcher::generateVHDL() throw(Exception) {
+void Dispatcher::generateVHDL(Context context) throw(Exception) {
static QString fctName = "Dispatcher::generateVHDL()";
#ifdef DEBUG_FCTNAME
cout << "call to " << qPrintable(fctName) << endl;
}
-void Dispatcher::generateBlockVHDL(BoxItem *item){
+void Dispatcher::generateBlockVHDL(Context context, BoxItem *item){
static QString fctName = "Dispatcher::generateBlockVHDL()";
#ifdef DEBUG_FCTNAME
cout << "call to " << qPrintable(fctName) << endl;
}
}
-void Dispatcher::renameFunctionalBlock(BoxItem *item){
+void Dispatcher::renameFunctionalBlock(Context context, BoxItem *item){
static QString fctName = "Dispatcher::renameFunctionalBlock()";
#ifdef DEBUG_FCTNAME
cout << "call to " << qPrintable(fctName) << endl;
item->nameChanged();
}
-void Dispatcher::renameGroupBlock(GroupItem *item){
+void Dispatcher::renameGroupBlock(Context context, GroupItem *item){
static QString fctName = "Dispatcher::renameGroupBlock()";
#ifdef DEBUG_FCTNAME
cout << "call to " << qPrintable(fctName) << endl;
mainWindow->getLibrary()->updateComboScene();
}
-void Dispatcher::renameSourceBlock(SourceItem *item){
+void Dispatcher::renameSourceBlock(Context context, SourceItem *item){
static QString fctName = "Dispatcher::renameSourceBlock()";
#ifdef DEBUG_FCTNAME
cout << "call to " << qPrintable(fctName) << endl;
}
-void Dispatcher::renameInterface(InterfaceItem *item) {
+void Dispatcher::renameInterface(Context context, InterfaceItem *item) {
static QString fctName = "Dispatcher::renameInterface()";
#ifdef DEBUG_FCTNAME
cout << "call to " << qPrintable(fctName) << endl;
item->getOwner()->nameChanged();
}
-void Dispatcher::showPatterns(InterfaceItem *item) {
+void Dispatcher::showPatterns(Context context, InterfaceItem *item) {
static QString fctName = "Dispatcher::showPatterns()";
#ifdef DEBUG_FCTNAME
cout << "call to " << qPrintable(fctName) << endl;
QMessageBox::information(NULL,"Interface pattern",msg,QMessageBox::Ok,QMessageBox::Ok);
}
-void Dispatcher::showModifier(InterfaceItem *item) {
+void Dispatcher::showModifier(Context context, InterfaceItem *item) {
static QString fctName = "Dispatcher::showModifier()";
#ifdef DEBUG_FCTNAME
cout << "call to " << qPrintable(fctName) << endl;
QMessageBox::information(NULL,"Interface pattern",msg,QMessageBox::Ok,QMessageBox::Ok);
}
-void Dispatcher::removeModifier(InterfaceItem *item) {
+void Dispatcher::removeModifier(Context context, InterfaceItem *item) {
static QString fctName = "Dispatcher::showModifier()";
#ifdef DEBUG_FCTNAME
cout << "call to " << qPrintable(fctName) << endl;
}
-void Dispatcher::duplicateBoxItem(BoxItem *item){
+void Dispatcher::duplicateBoxItem(Context context, BoxItem *item){
static QString fctName = "Dispatcher::duplicateBoxItem()";
#ifdef DEBUG_FCTNAME
cout << "call to " << qPrintable(fctName) << endl;
}
}
-void Dispatcher::duplicateSourceItem(SourceItem *item) {
+void Dispatcher::duplicateSourceItem(Context context, SourceItem *item) {
static QString fctName = "Dispatcher::duplicateSourceItem()";
#ifdef DEBUG_FCTNAME
cout << "call to " << qPrintable(fctName) << endl;
}
}
-void Dispatcher::duplicateInterfaceItem(InterfaceItem *item) {
+void Dispatcher::duplicateInterfaceItem(Context context, InterfaceItem *item) {
static QString fctName = "Dispatcher::duplicateInterfaceItem()";
#ifdef DEBUG_FCTNAME
cout << "call to " << qPrintable(fctName) << endl;
}
-BoxItem* Dispatcher::addBlock(int idCategory, int idBlock, int idScene) {
+BoxItem* Dispatcher::addBlock(Context context, int idCategory, int idBlock, int idScene) {
static QString fctName = "Dispatcher::addBlock()";
#ifdef DEBUG_FCTNAME
cout << "call to " << qPrintable(fctName) << endl;
#endif
bool newSource = false;
BoxItem* item = NULL;
- GroupScene *scene = getSceneById(idScene);
- ReferenceBlock* ref = params->getReferenceBlock(idCategory,idBlock);
- // if block has no inputs, propose to add it as a source to top scene
- if ((scene->isTopScene()) && (ref->isGeneratorBlock())) {
- int ret = QMessageBox::question(NULL,"Adding a block to top scene","Selected block may be used as a source for the top scene. Do you want to add it as a source ?");
- if (ret == QMessageBox::Yes) {
- newSource = true;
- }
- }
- if (newSource) {
- FunctionalBlock* newOne = params->getGraph()->createSourceBlock(ref);
- scene->createSourceItem(newOne);
- }
- else {
- GroupBlock* group = AB_TO_GRP(scene->getGroupItem()->getRefBlock());
- FunctionalBlock* newOne = params->getGraph()->createFunctionalBlock(group, ref);
- item = scene->createBoxItem(newOne);
- params->blockToItem.insert(newOne,item);
+
+ /* For now, this method is only used while designing and not loading */
+ if (context == Design) {
+ GroupScene *scene = getSceneById(idScene);
+ ReferenceBlock* ref = params->getReferenceBlock(idCategory,idBlock);
+ // if block has no inputs, propose to add it as a source to top scene
+ if ((scene->isTopScene()) && (ref->isGeneratorBlock())) {
+ int ret = QMessageBox::question(NULL,"Adding a block to top scene","Selected block may be used as a source for the top scene. Do you want to add it as a source ?");
+ if (ret == QMessageBox::Yes) {
+ newSource = true;
+ }
+ }
+ if (newSource) {
+ FunctionalBlock* newOne = params->getGraph()->createSourceBlock(ref, true);
+ scene->createSourceItem(newOne);
+ }
+ else {
+ GroupBlock* group = AB_TO_GRP(scene->getGroupItem()->getRefBlock());
+ FunctionalBlock* newOne = params->getGraph()->createFunctionalBlock(group, ref, true);
+ item = scene->createBoxItem(newOne);
+ params->blockToItem.insert(newOne,item);
+ }
+ params->unsaveModif = true;
}
- params->unsaveModif = true;
+
return item;
}
-GroupWidget *Dispatcher::createTopScene(){
+GroupWidget *Dispatcher::createTopScene(Context context){
static QString fctName = "Dispatcher::createTopScene()";
#ifdef DEBUG_FCTNAME
cout << "call to " << qPrintable(fctName) << endl;
#endif
- // creating the model part of the group
- Graph* graph = params->createGraph();
+ bool createIfaces = true;
+ if (context == Load) {
+ createIfaces = false;
+ }
+ // creating the graph and thus, the topgroup
+ Graph* graph = params->createGraph(createIfaces);
+ // get the top group
GroupBlock *topBlock = graph->getTopGroup();
- // creating the clkrstgen block
- ReferenceBlock* ref = params->getHiddenReferenceBlock("clkrstgen");
- FunctionalBlock* newOne = params->getGraph()->createFunctionalBlock(topBlock, ref);
- ConnectedInterface* fromIface = AI_TO_CON(topBlock->getIfaceFromName("ext_clk"));
- ConnectedInterface* toIface = AI_TO_CON(newOne->getIfaceFromName("ext_clk"));
- fromIface->connectTo(toIface);
- fromIface = AI_TO_CON(topBlock->getIfaceFromName("ext_reset"));
- toIface = AI_TO_CON(newOne->getIfaceFromName("ext_reset"));
- fromIface->connectTo(toIface);
-
- // creating a fake and not connected interface
- //AbstractInterface* iface = new GroupInterface(refBlock,"grp_iface",AbstractInterface::Input,AbstractInterface::Top);
-
- // creating the group widget
- topGroup = new GroupWidget(NULL,this,params);
- currentGroup = topGroup;
+ // creating the top group widget
+ topGroupWidget = new GroupWidget(NULL,this,params);
+ currentGroupWidget = topGroupWidget;
// getting the newly created scene
- GroupScene *scene = topGroup->getScene();
+ GroupScene *scene = topGroupWidget->getScene();
scene->setId(sceneCounter++);
params->setTopScene(scene);
params->setCurrentScene(scene);
// creating the view part of the group
GroupItem *group = new GroupItem(NULL,topBlock,this,params);
-
+ // associate the top scene to the top group iten
+ scene->setGroupItem(group);
// adding the fake interface to the top group item
//InterfaceItem* item = new InterfaceItem(0.0 , Parameters::West, (ConnectedInterface*)iface, group, params);
//group->addInterface(item,true);
- scene->setGroupItem(group);
- groupList.append(topGroup);
- return topGroup;
+ if (context == Design) {
+ // creating the clkrstgen block
+ ReferenceBlock* ref = params->getHiddenReferenceBlock("clkrstgen");
+ FunctionalBlock* newOne = params->getGraph()->createFunctionalBlock(topBlock, ref, true);
+ ConnectedInterface* fromIface = AI_TO_CON(topBlock->getIfaceFromName("ext_clk"));
+ ConnectedInterface* toIface = AI_TO_CON(newOne->getIfaceFromName("ext_clk"));
+ fromIface->connectTo(toIface);
+ fromIface = AI_TO_CON(topBlock->getIfaceFromName("ext_reset"));
+ toIface = AI_TO_CON(newOne->getIfaceFromName("ext_reset"));
+ fromIface->connectTo(toIface);
+ // create the clkrstgen boxitem
+ BoxItem* item = scene->createBoxItem(newOne, GroupScene::Left, GroupScene::Top, AbstractBoxItem::Position, BoxItem::HSpan);
+ params->blockToItem.insert(newOne,item);
+ }
+
+
+ groupList.append(topGroupWidget);
+ return topGroupWidget;
}
-GroupWidget* Dispatcher::addNewEmptyGroup(GroupScene* scene, bool show) {
+GroupWidget* Dispatcher::addNewEmptyGroup(Context context, GroupScene* scene, bool show) {
static QString fctName = "Dispatcher::addNewEmptyGroup();";
#ifdef DEBUG_FCTNAME
cout << "call to " << qPrintable(fctName) << endl;
params->unsaveModif = true;
- GroupWidget* child = createChildScene(scene->getGroupWidget(),newItem);
+ GroupWidget* child = createChildScene(context, scene->getGroupWidget(),newItem);
if (show) child->show();
return child;
}
-GroupWidget *Dispatcher::createChildScene(GroupWidget* parentWidget, BoxItem *upperItemOfGroupItem) {
+GroupWidget *Dispatcher::createChildScene(Context context, GroupWidget* parentWidget, BoxItem *upperItemOfGroupItem) {
static QString fctName = "Dispatcher::createChildScene()";
#ifdef DEBUG_FCTNAME
cout << "call to " << qPrintable(fctName) << endl;
return group;
}
-void Dispatcher::destroyScene(GroupScene *scene) {
+void Dispatcher::destroyScene(Context context, GroupScene *scene) {
foreach(GroupScene* s, scene->getChildrenScene()) {
- destroyScene(s);
+ destroyScene(context, s);
}
if (scene->getNbChildScene() == 0) {
}
}
-void Dispatcher::showRaiseWindow(BoxItem *item) {
+void Dispatcher::showRaiseWindow(Context context, BoxItem *item) {
static QString fctName = "Dispatcher::showRaiseWindow()";
#ifdef DEBUG_FCTNAME
cout << "call to " << qPrintable(fctName) << endl;
win->raise();
win->activateWindow();
- currentGroup = win;
- params->setCurrentScene(currentGroup->getScene());
+ currentGroupWidget = win;
+ params->setCurrentScene(currentGroupWidget->getScene());
}
-void Dispatcher::showRstClkIface(AbstractBoxItem *item) {
+void Dispatcher::showRstClkIface(Context context, AbstractBoxItem *item) {
static QString fctName = "Dispatcher::showRstClkIface()";
#ifdef DEBUG_FCTNAME
cout << "call to " << qPrintable(fctName) << endl;
}
-void Dispatcher::showWishboneIface(AbstractBoxItem *item) {
+void Dispatcher::showWishboneIface(Context context, AbstractBoxItem *item) {
static QString fctName = "Dispatcher::showWishboneIface()";
#ifdef DEBUG_FCTNAME
cout << "call to " << qPrintable(fctName) << endl;
item->setWishboneVisible(!item->isWishboneVisible());
}
-void Dispatcher::addNewFullGroup() {
+void Dispatcher::addNewFullGroup(Context context) {
static QString fctName = "Dispatcher::addNewFullGroup()";
#ifdef DEBUG_FCTNAME
cout << "call to " << qPrintable(fctName) << endl;
#endif
}
-void Dispatcher::removeBoxItem(BoxItem *item) {
+void Dispatcher::removeBoxItem(Context context, BoxItem *item) {
static QString fctName = "Dispatcher::removeBoxItem()";
#ifdef DEBUG_FCTNAME
cout << "call to " << qPrintable(fctName) << endl;
#endif
+ if (context != Design) return;
+
/* a BoxItem (group of func) can be removed only if none of its
interfaces is connected to a group interface that is itself
connected to another one.
if (ret == QMessageBox::Cancel) {
return;
}
- removeAllBlockConnections(item);
+ removeAllBlockConnections(context, item);
if (item->getRefBlock()->isFunctionalBlock()) {
FunctionalBlock* block = AB_TO_FUN(item->getRefBlock());
// remove all child scenes recursively
GroupItem* subgroup = item->getChildGroupItem();
- destroyScene(subgroup->getScene());
+ destroyScene(context, subgroup->getScene());
// remove the BoxItem
item->getScene()->removeBoxItem(item);
// remove the group from the graph
}
}
-void Dispatcher::removeAllBlockConnections(AbstractBoxItem *item) {
+void Dispatcher::removeAllBlockConnections(Context context, AbstractBoxItem *item) {
static QString fctName = "Dispatcher::removeAllBlockConnection()";
#ifdef DEBUG_FCTNAME
cout << "call to " << qPrintable(fctName) << endl;
foreach(InterfaceItem* ifaceItem, item->getInterfaces()) {
foreach(ConnectionItem* conn, ifaceItem->connections) {
- removeConnection(conn);
+ removeConnection(context, conn);
}
}
}
-void Dispatcher::removeSourceItem(SourceItem *item) {
+void Dispatcher::removeSourceItem(Context context, SourceItem *item) {
static QString fctName = "Dispatcher::removeSourceItem()";
#ifdef DEBUG_FCTNAME
cout << "call to " << qPrintable(fctName) << endl;
if (ret == QMessageBox::Cancel) {
return;
}
- removeAllBlockConnections(item);
+ removeAllBlockConnections(context, item);
FunctionalBlock* block = AB_TO_FUN(item->getRefBlock());
item->getScene()->removeSourceItem(item);
}
-void Dispatcher::removeConnection(ConnectionItem *connItem) {
+void Dispatcher::removeConnection(Context context, ConnectionItem *connItem) {
static QString fctName = "Dispatcher::removeConnection()";
#ifdef DEBUG_FCTNAME
cout << "call to " << qPrintable(fctName) << endl;
mainWindow->getLibrary()->raise();
}
-void Dispatcher::showProperties(InterfaceItem *inter) {
+void Dispatcher::showProperties(Context context, InterfaceItem *inter) {
new InterfacePropertiesWindow(inter);
}
That action will create a new InterfaceItem on the GroupItem and a connectionItem between the
interfaces.
*/
-void Dispatcher::connectInterToGroup(InterfaceItem *item){
+void Dispatcher::connectInterToGroup(Context context, InterfaceItem *item){
// getting the GroupBlock and GroupItem that are parent of the block that owns item
ConnectedInterface *refInter = item->refInter;
parentItem->addInterfaceItem(groupIfaceItem,true);
// creating the connection, in graph and with an item
- createConnection(item, groupIfaceItem);
+ createConnection(context, item, groupIfaceItem);
// if groupItem is not topGroup, must also add a new interface to the parent BlockItem
BoxItem* parent2Item = parentItem->getParentItem();
parentItem->getScene()->updateConnectionItemsShape();
- unselectAllItems();
+ unselectAllItems(context);
params->unsaveModif = true;
}
-void Dispatcher::removeFunctionalInterface(InterfaceItem *item) {
+void Dispatcher::removeFunctionalInterface(Context context, InterfaceItem *item) {
static QString fctName = "Dispatcher::removeBlockInterface()";
#ifdef DEBUG_FCTNAME
cout << "call to " << qPrintable(fctName) << endl;
that allows to remove an interface.
*/
foreach(ConnectionItem* conn, item->connections) {
- removeConnection(conn);
+ removeConnection(context, conn);
}
ConnectedInterface* ref = item->refInter;
fun->removeInterface(ref);
}
-void Dispatcher::removeGroupInterface(InterfaceItem *item) {
+void Dispatcher::removeGroupInterface(Context context, InterfaceItem *item) {
static QString fctName = "Dispatcher::removeGroupInterface()";
#ifdef DEBUG_FCTNAME
cout << "call to " << qPrintable(fctName) << endl;
ones to a GroupItem, it is automatically deleted.
*/
foreach(ConnectionItem* conn, item->connections) {
- removeConnection(conn);
+ removeConnection(context, conn);
}
}
return NULL;
}
-void Dispatcher::findGraphModifications(FunctionalBlock *block) {
+void Dispatcher::findGraphModifications(Context context, FunctionalBlock *block) {
static QString fctName = "Dispatcher::findGraphModifications()";
#ifdef DEBUG_FCTNAME
cout << "call to " << qPrintable(fctName) << endl;
class Dispatcher {
public:
+ /*!
+ * \brief The Context enum
+ * Some methods are called while creating a design from scratch or when loading
+ * a desgin from a project file previously saved. Thus, their behavior may change
+ * according to the situation. Context is used to specifiy the situation.
+ * Must be always specified.
+ */
+ enum Context {AnyContext = 0, Design = 1, Load = 2 };
+
Dispatcher(Parameters* _params,
MainWindow* _window);
GroupWidget* loadProject(const QString& filename);
- inline int getNumberOfScenes() { return groupList.length(); }
-
- void unselectAllItems(int direction=0);
- void setCurrentGroupWidget(GroupWidget *win);
- void changeConnectionMode(int mode = -1);
-
-
- GroupWidget* createTopScene();
- GroupWidget* createChildScene(GroupWidget* parentWidget, BoxItem* upperItemOfGroupItem = NULL);
- void destroyScene(GroupScene* scene);
- void showRaiseWindow(BoxItem *item);
- void showRstClkIface(AbstractBoxItem *item);
- void showWishboneIface(AbstractBoxItem *item);
- GroupWidget *addNewEmptyGroup(GroupScene *scene, bool show = true);
- void addNewFullGroup();
- inline GroupWidget* getCurrentGroup() { return currentGroup; }
-
- inline void setSceneCounter(int value) { sceneCounter = value;}
bool isCurrentProject;
-public slots:
-
- // graph ops
- QMap<int, QString> getAllGroupNames();
- void generateVHDL() throw(Exception);
-
- // scene ops
+ /**************************
+ * scene ops
+ *************************/
+ // getters
GroupScene* getSceneById(int id);
GroupScene* getSceneByName(QString name);
BoxItem* getBoxItemById(int id);
GroupItem* getGroupItemById(int id);
InterfaceItem* getInterfaceItemById(int id);
-
-
- // block ops
- BoxItem* addBlock(int idCategory, int idBlock, int idScene);
- void removeBoxItem(BoxItem* item);
- void duplicateBoxItem(BoxItem* item);
- void renameFunctionalBlock(BoxItem* item);
- void generateBlockVHDL(BoxItem* item);
- void renameGroupBlock(GroupItem* item);
- void renameSourceBlock(SourceItem* item);
- void removeSourceItem(SourceItem* item);
- void duplicateSourceItem(SourceItem* item);
+ inline GroupWidget* getCurrentGroup() { return currentGroupWidget; }
+ inline int getNumberOfScenes() { return groupList.length(); }
+ // setters
+ void showRaiseWindow(Context context, BoxItem *item);
+ void showRstClkIface(Context context, AbstractBoxItem *item);
+ void showWishboneIface(Context context, AbstractBoxItem *item);
+ void unselectAllItems(Context context, int direction=0);
+ void setCurrentGroupWidget(Context context, GroupWidget *win);
+ void changeConnectionMode(Context context, int mode = -1);
+ void setSceneCounter(Context context, int value);
+ // testers
+ // others
+ GroupWidget* createTopScene(Context context);
+ GroupWidget* createChildScene(Context context, GroupWidget* parentWidget, BoxItem* upperItemOfGroupItem = NULL);
+ void destroyScene(Context context, GroupScene* scene);
+ GroupWidget *addNewEmptyGroup(Context context, GroupScene *scene, bool show = true);
+ void addNewFullGroup(Context context);
+
+ /**************************
+ * graph ops
+ *************************/
+ // getters
+ QMap<int, QString> getAllGroupNames();
+ // setters
+ // testers
+ // others
+ void generateVHDL(Context context) throw(Exception);
+
+ /**************************
+ * block ops
+ *************************/
+ BoxItem* addBlock(Context context, int idCategory, int idBlock, int idScene);
+ void removeBoxItem(Context context, BoxItem* item);
+ void duplicateBoxItem(Context context, BoxItem* item);
+ void renameFunctionalBlock(Context context, BoxItem* item);
+ void generateBlockVHDL(Context context, BoxItem* item);
+ void renameGroupBlock(Context context, GroupItem* item);
+ void renameSourceBlock(Context context, SourceItem* item);
+ void removeSourceItem(Context context, SourceItem* item);
+ void duplicateSourceItem(Context context, SourceItem* item);
// interface ops
* connect to group in the contextual menu.
* Thus, parameter item is always owned by a BoxItem
*/
- void connectInterToGroup(InterfaceItem* item);
+ void connectInterToGroup(Context context, InterfaceItem* item);
/*!
* \brief removeFunctionalInterface
* \param item item is always owned by a BoxItem
* to a BoxItem that represents a functional block and has a multiplicity > 1) and chooses remove in the contextual menu.
* Thus, parameter item is always owned by a BoxItem
*/
- void removeFunctionalInterface(InterfaceItem* item);
+ void removeFunctionalInterface(Context context, InterfaceItem* item);
/*!
* \brief removeGroupInterface
* \param item item is always owned by a GroupItem
* to a GroupItem and if it is connected only to an inner interface) and chooses remove in the contextual menu.
* Thus, parameter item is always owned by a GroupItem
*/
- void removeGroupInterface(InterfaceItem* item);
- void duplicateInterfaceItem(InterfaceItem* item);
- void showProperties(InterfaceItem *inter);
- void renameInterface(InterfaceItem* item);
- void showPatterns(InterfaceItem* item);
- void showModifier(InterfaceItem* item);
- void removeModifier(InterfaceItem* item);
+ void removeGroupInterface(Context context, InterfaceItem* item);
+ void duplicateInterfaceItem(Context context, InterfaceItem* item);
+ void showProperties(Context context, InterfaceItem *inter);
+ void renameInterface(Context context, InterfaceItem* item);
+ void showPatterns(Context context, InterfaceItem* item);
+ void showModifier(Context context, InterfaceItem* item);
+ void removeModifier(Context context, InterfaceItem* item);
// connection ops
- bool createConnection(InterfaceItem *iface1, InterfaceItem *iface2, bool visible = true);
- void removeAllBlockConnections(AbstractBoxItem *item);
- void removeConnection(ConnectionItem *conn);
+ bool createConnection(Context context, InterfaceItem *iface1, InterfaceItem *iface2, bool visible = true);
+ void removeAllBlockConnections(Context context, AbstractBoxItem *item);
+ void removeConnection(Context context, ConnectionItem *conn);
// analysis ops
- void findGraphModifications(FunctionalBlock* block); // find modif so that block has compatible inputs
+ void findGraphModifications(Context context, FunctionalBlock* block); // find modif so that block has compatible inputs
// others
void showBlocksLibrary();
// attributes that corresponds to the views
MainWindow* mainWindow;
QList<GroupWidget*> groupList;
- GroupWidget* currentGroup;
- GroupWidget *topGroup;
+ GroupWidget* currentGroupWidget;
+ GroupWidget *topGroupWidget;
static int sceneCounter;
};
#include "ArithmeticEvaluator.h"\r
\r
\r
-FunctionalBlock::FunctionalBlock(GroupBlock *_parent, ReferenceBlock *_reference) throw(Exception) : AbstractBlock() {\r
+FunctionalBlock::FunctionalBlock(GroupBlock *_parent, ReferenceBlock *_reference, bool createIfaces) throw(Exception) : AbstractBlock() {\r
//if (! _reference->isReferenceBlock()) throw(Exception(BLOCK_INVALID_TYPE));\r
//if (! _group->isGroupBlock()) throw(Exception(BLOCK_INVALID_TYPE));\r
reference = _reference;\r
delta = -1;\r
evaluator = NULL;\r
\r
+ if (createIfaces) {\r
+ populate();\r
+ }\r
+\r
}\r
\r
FunctionalBlock::~FunctionalBlock() {\r
class FunctionalBlock : public AbstractBlock {\r
public:\r
\r
- FunctionalBlock(GroupBlock* _parent, ReferenceBlock* _reference) throw(Exception);\r
+ FunctionalBlock(GroupBlock* _parent, ReferenceBlock* _reference, bool createIfaces = true) throw(Exception);\r
~FunctionalBlock();\r
// getters\r
inline ReferenceBlock* getReference() { return reference; }\r
// first case: interface of blocks within the same group\r
if (getOwner()->getParent() == iface->getOwner()->getParent()) {\r
\r
- if ((direction == Output) && (iface->getDirection() == Input)) return true;\r
- if ((direction == InOut) && (iface->getDirection() == InOut)) return true;\r
+ if ((direction == Output) && (iface->getDirection() == Input) && (purpose == iface->getPurpose())) return true;\r
+ if ((direction == InOut) && (iface->getDirection() == InOut) && (purpose == iface->getPurpose())) return true;\r
}\r
// second case: iface = interface of the group that contains owner of this\r
else if (getOwner()->getParent() == iface->getOwner()) {\r
- if ((direction == Output) && (iface->getDirection() == Output)) return true;\r
- if ((direction == InOut) && (iface->getDirection() == InOut)) return true;\r
+ if ((direction == Output) && (iface->getDirection() == Output) && (purpose == iface->getPurpose())) return true;\r
+ if ((direction == InOut) && (iface->getDirection() == InOut) && (purpose == iface->getPurpose())) return true;\r
}\r
else if ((getOwner()->isSourceBlock()) && (iface->getOwner()->isTopGroupBlock())) {\r
- if ((direction == Output) && (iface->getDirection() == Input)) return true;\r
+ if ((direction == Output) && (iface->getDirection() == Input) && (purpose == iface->getPurpose())) return true;\r
}\r
\r
return false;\r
\r
if (getOwner()->getParent() == iface->getOwner()->getParent()) {\r
\r
- if ((direction == Input) && (iface->getDirection() == Output)) return true;\r
- if ((direction == InOut) && (iface->getDirection() == InOut)) return true;\r
+ if ((direction == Input) && (iface->getDirection() == Output) && (purpose == iface->getPurpose())) return true;\r
+ if ((direction == InOut) && (iface->getDirection() == InOut) && (purpose == iface->getPurpose())) return true;\r
}\r
else if (getOwner()->getParent() == iface->getOwner()) {\r
- if ((direction == Input) && (iface->getDirection() == Input)) return true;\r
- if ((direction == InOut) && (iface->getDirection() == InOut)) return true;\r
+ if ((direction == Input) && (iface->getDirection() == Input) && (purpose == iface->getPurpose())) return true;\r
+ if ((direction == InOut) && (iface->getDirection() == InOut) && (purpose == iface->getPurpose())) return true;\r
}\r
\r
return false;\r
#include "ReferenceBlock.h"
#include "FunctionalBlock.h"
-Graph::Graph() {
- topGroup = new GroupBlock(NULL);
+Graph::Graph(bool createTopGroupIface) {
+ topGroup = new GroupBlock(NULL, createTopGroupIface);
topGroup->setName("top group");
groups.append(topGroup);
}
return topGroup->getInterfaces();
}
-GroupBlock* Graph::createChildGroupBlock(GroupBlock* parent) {
- GroupBlock* b = new GroupBlock(parent);
+GroupBlock* Graph::createChildGroupBlock(GroupBlock* parent, bool createGroupIface) {
+ GroupBlock* b = new GroupBlock(parent, createGroupIface);
groups.append(b);
return b;
}
return NULL;
}
-FunctionalBlock* Graph::createFunctionalBlock(GroupBlock* group, ReferenceBlock* ref) {
+FunctionalBlock* Graph::createFunctionalBlock(GroupBlock* group, ReferenceBlock* ref, bool createIfaces) {
- FunctionalBlock* newBlock = new FunctionalBlock(group,ref);
- newBlock->populate();
+ FunctionalBlock* newBlock = new FunctionalBlock(group,ref, createIfaces);
group->addBlock(newBlock);
return newBlock;
GroupBlock* group = AB_TO_GRP(block->getParent());
// adding to the graph
- FunctionalBlock* newBlock = createFunctionalBlock(group,ref);
+ FunctionalBlock* newBlock = createFunctionalBlock(group,ref, true);
return newBlock;
}
return block;
}
-FunctionalBlock* Graph::createSourceBlock(ReferenceBlock* ref) {
+FunctionalBlock* Graph::createSourceBlock(ReferenceBlock* ref, bool createIfaces) {
- FunctionalBlock* newBlock = new FunctionalBlock(NULL,ref);
- newBlock->populate();
+ FunctionalBlock* newBlock = new FunctionalBlock(NULL,ref, createIfaces);
sources.append(newBlock);
return newBlock;
}
ReferenceBlock* ref = block->getReference();
// adding to the graph
- FunctionalBlock* newBlock = createSourceBlock(ref);
+ FunctionalBlock* newBlock = createSourceBlock(ref, true);
return newBlock;
}
class Graph {
public:
- Graph();
+ Graph(bool createTopGroupIface = true);
~Graph();
// getters
inline QList<GroupBlock*> getAllGroups() { return groups; }
// methods for group blocks
- GroupBlock* createChildGroupBlock(GroupBlock* parent);
+ GroupBlock* createChildGroupBlock(GroupBlock* parent, bool createGroupIface = true);
void removeGroupBlock(GroupBlock *group);
GroupBlock* getGroupBlockByName(QString name);
// methods for functional blocks
- FunctionalBlock* createFunctionalBlock(GroupBlock *group, ReferenceBlock *ref);
+ FunctionalBlock* createFunctionalBlock(GroupBlock *group, ReferenceBlock *ref, bool createIfaces = true);
FunctionalBlock* duplicateFunctionalBlock(FunctionalBlock *block);
bool removeFunctionalBlock(FunctionalBlock* block);
FunctionalBlock* getFunctionalBlockByName(QString name, GroupBlock* parent = NULL); //! if parent = NULL, search in the whole graph
// methods for source blocks
- FunctionalBlock* createSourceBlock(ReferenceBlock *ref);
+ FunctionalBlock* createSourceBlock(ReferenceBlock *ref, bool createIfaces = true);
FunctionalBlock* duplicateSourceBlock(FunctionalBlock *block);
FunctionalBlock* getSourceBlockByName(QString name);
bool removeSourceBlock(FunctionalBlock* block);
int GroupBlock::counter = 1;
-GroupBlock::GroupBlock(GroupBlock *_parent) throw(Exception) : AbstractBlock() {
+GroupBlock::GroupBlock(GroupBlock *_parent, bool createIfaces) throw(Exception) : AbstractBlock() {
GroupInterface* clk = NULL;
GroupInterface* rst = NULL;
class GroupBlock : public AbstractBlock {
public:
- GroupBlock(GroupBlock* _parent) throw(Exception);
+ GroupBlock(GroupBlock* _parent, bool createIfaces = true) throw(Exception);
virtual ~GroupBlock();
// getters
if (connIface->getConnectedFrom() != NULL) return false;
if (this->getOwner() == iface->getOwner()->getParent()) {
- if ((direction == Input) && (iface->getDirection() == Input)) return true;
- if ((direction == InOut) && (iface->getDirection() == InOut)) return true;
+ if ((direction == Input) && (iface->getDirection() == Input) && (purpose == iface->getPurpose())) return true;
+ if ((direction == InOut) && (iface->getDirection() == InOut) && (purpose == iface->getPurpose())) return true;
}
else if (this->getOwner()->getParent() == iface->getOwner()->getParent()) {
- if ((direction == Output) && (iface->getDirection() == Input)) return true;
- if ((direction == InOut) && (iface->getDirection() == InOut)) return true;
+ if ((direction == Output) && (iface->getDirection() == Input) && (purpose == iface->getPurpose())) return true;
+ if ((direction == InOut) && (iface->getDirection() == InOut) && (purpose == iface->getPurpose())) return true;
}
else if (this->getOwner()->getParent() == iface->getOwner()) {
- if ((direction == Output) && (iface->getDirection() == Output)) return true;
- if ((direction == InOut) && (iface->getDirection() == InOut)) return true;
+ if ((direction == Output) && (iface->getDirection() == Output) && (purpose == iface->getPurpose())) return true;
+ if ((direction == InOut) && (iface->getDirection() == InOut) && (purpose == iface->getPurpose())) return true;
}
if (getConnectedFrom() != NULL) return false;
if (this->getOwner() == iface->getOwner()->getParent()) {
- if ((direction == Output) && (iface->getDirection() == Output)) return true;
- if ((direction == InOut) && (iface->getDirection() == InOut)) return true;
+ if ((direction == Output) && (iface->getDirection() == Output) && (purpose == iface->getPurpose())) return true;
+ if ((direction == InOut) && (iface->getDirection() == InOut) && (purpose == iface->getPurpose())) return true;
}
else if (this->getOwner()->getParent() == iface->getOwner()->getParent()) {
- if ((direction == Input) && (iface->getDirection() == Output)) return true;
- if ((direction == InOut) && (iface->getDirection() == InOut)) return true;
+ if ((direction == Input) && (iface->getDirection() == Output) && (purpose == iface->getPurpose())) return true;
+ if ((direction == InOut) && (iface->getDirection() == InOut) && (purpose == iface->getPurpose())) return true;
}
else if (this->getOwner()->getParent() == iface->getOwner()) {
- if ((direction == Input) && (iface->getDirection() == Input)) return true;
- if ((direction == InOut) && (iface->getDirection() == InOut)) return true;
+ if ((direction == Input) && (iface->getDirection() == Input) && (purpose == iface->getPurpose())) return true;
+ if ((direction == InOut) && (iface->getDirection() == InOut) && (purpose == iface->getPurpose())) return true;
}
else if ((getOwner()->isTopGroupBlock()) && (iface->getOwner()->isSourceBlock())) {
- if ((direction == Input) && (iface->getDirection() == Output)) return true;
+ if ((direction == Input) && (iface->getDirection() == Output) && (purpose == iface->getPurpose())) return true;
}
return false;
int mode = getScene()->getEditionMode();
- dispatcher->setCurrentGroupWidget(getScene()->getGroupWidget());
+ dispatcher->setCurrentGroupWidget(Dispatcher::Design, getScene()->getGroupWidget());
if ((mode == GroupScene::AddConnection) && (params->cursorState == Parameters::CursorOnInterface)) {
InterfaceItem *inter = getInterfaceItemFromCursor(x,y);
else if (params->editState == Parameters::EditCloseConnection) {
InterfaceItem* iface1 = getScene()->getSelectedInterface(1);
InterfaceItem* iface2 = getScene()->getSelectedInterface(2);
- bool ok = dispatcher->createConnection(iface1,iface2);
+ bool ok = dispatcher->createConnection(Dispatcher::Design, iface1,iface2);
if (ok) {
iface1->selected = false;
update(iface1->boundingRect());
if(selectedAction == renameAction){
if(ifaceItem != NULL)
- dispatcher->renameInterface(ifaceItem);
+ dispatcher->renameInterface(Dispatcher::Design, ifaceItem);
else
- dispatcher->renameGroupBlock(this);
+ dispatcher->renameGroupBlock(Dispatcher::Design, this);
}
else if(selectedAction == showProperties){
- dispatcher->showProperties(ifaceItem);
+ dispatcher->showProperties(Dispatcher::Design, ifaceItem);
}
else if (selectedAction == removeAction) {
- dispatcher->removeGroupInterface(ifaceItem);
+ dispatcher->removeGroupInterface(Dispatcher::Design, ifaceItem);
}
else if(selectedAction == showParameters) {
new ParametersWindow(refBlock, params, NULL);
return counter;
}
-BoxItem *GroupScene::createBoxItem(AbstractBlock *block) {
+BoxItem *GroupScene::createBoxItem(AbstractBlock *block, BoxItem::Position hPos, BoxItem::Position vPos, AbstractBoxItem::LockType lock, BoxItem::SpanType span) {
- BoxItem* item = new BoxItem(block,dispatcher,params,groupItem);
+ BoxItem* item = new BoxItem(block,dispatcher,params,groupItem, lock, span);
item->setZValue(1);
// add item from the QList
boxItems.append(item);
// repainting the group
groupItem->updateShape();
// center the new block
- QPointF newPos((groupItem->getWidth()-item->getTotalWidth())/2.0, (groupItem->getHeight()-item->getTotalHeight())/2.0);
+ double x,y;
+ if (hPos == BoxItem::Left) {
+ x = 0;
+ }
+ else if (hPos == BoxItem::Center) {
+ x = (groupItem->getWidth()-item->getTotalWidth())/2.0;
+ }
+ else if (hPos == BoxItem::Right) {
+ x = groupItem->getWidth()-item->getTotalWidth();
+ }
+ if (vPos == BoxItem::Top) {
+ y = 0;
+ }
+ else if (vPos == BoxItem::Center) {
+ y = (groupItem->getHeight()-item->getTotalHeight())/2.0;
+ }
+ else if (vPos == BoxItem::Bottom) {
+ y = groupItem->getHeight()-item->getTotalHeight();
+ }
+ QPointF newPos(x,y);
newPos = newPos-item->getOriginPoint();
item->moveTo(newPos);
class AbstractBlock;
class GroupWidget;
class GroupItem;
+#include "BoxItem.h"
class BoxItem;
class SourceItem;
class AbstractBoxItem;
*/
enum EditMode { InitState, AddConnection, ItemEdition };
+
GroupScene(GroupScene* _parentScene, GroupWidget* _window, Dispatcher* _dispatcher, Parameters* _params, bool topScene = false, QObject *parent = 0);
~GroupScene();
// others
// BoxItem related
- BoxItem* createBoxItem(AbstractBlock* block); //! create a new BoxItem and place it at the center of the scene
+ BoxItem* createBoxItem(AbstractBlock* block, BoxItem::Position hPos = Center, BoxItem::Position vPos = Center, AbstractBoxItem::LockType lock = AbstractBoxItem::NoLock, BoxItem::SpanType span = BoxItem::NoSpan); //! create a new BoxItem and place it at the center of the scene
void addBoxItem(BoxItem* item); //! add an already configured BoxItem in the scene.
void removeBoxItem(BoxItem* item);
scene = new GroupScene(NULL, this, dispatcher, params, true);
}
else {
- topGroup = true;
+ topGroup = false;
scene = new GroupScene(upperGroup->getScene(), this, dispatcher, params, false);
}
void GroupWidget::mousePressEvent(QMouseEvent *e) {
- dispatcher->setCurrentGroupWidget(this);
+ dispatcher->setCurrentGroupWidget(Dispatcher::Design, this);
QWidget::mousePressEvent(e);
}
}
void GroupWidget::slotEdit() {
- dispatcher->unselectAllItems();
+ dispatcher->unselectAllItems(Dispatcher::Design);
getScene()->setEditionMode(GroupScene::ItemEdition);
updateBlockButton();
}
void GroupWidget::slotCopyBlock() {
foreach (BoxItem *item, params->getCurrentScene()->getBoxItems()) {
if(item->isSelected()){
- dispatcher->duplicateBoxItem(item);
+ dispatcher->duplicateBoxItem(Dispatcher::Design, item);
}
}
}
void GroupWidget::slotAddConnection() {
- dispatcher->unselectAllItems();
+ dispatcher->unselectAllItems(Dispatcher::Design);
getScene()->setEditionMode(GroupScene::AddConnection);
updateBlockButton();
}
void GroupWidget::slotNewEmptyGroup() {
- dispatcher->addNewEmptyGroup(scene);
+ dispatcher->addNewEmptyGroup(Dispatcher::Design, scene);
}
void GroupWidget::slotNewGroup()
{
- dispatcher->addNewFullGroup();
+ dispatcher->addNewFullGroup(Dispatcher::Design );
}
void GroupWidget::slotDeleteItems() {
foreach (BoxItem *item, scene->getBoxItems()) {
if(item->isSelected()){
- dispatcher->removeBoxItem(item);
+ dispatcher->removeBoxItem(Dispatcher::Design, item);
}
}
foreach (ConnectionItem *item, scene->getConnectionItems()) {
if(item->isSelected()){
- dispatcher->removeConnection(item);
+ dispatcher->removeConnection(Dispatcher::Design, item);
}
}
}
if (ret == 1) {
enableProjectActions(true, PROJECT_CLOSE | PROJECT_SAVE | PROJECT_SAVEAS | PROJECT_LIB, OP_RAZ);
enableAnalysisActions(true, ANALYSIS_ANALYZE | ANALYSIS_GENERATE, OP_RAZ);
- GroupWidget* topGroup = dispatcher->createTopScene();
+ GroupWidget* topGroup = dispatcher->createTopScene(Dispatcher::Design);
addTopGroup(topGroup);
library->updateComboScene();
library->show();
msg += " is not compatible with its input pattern.\nDo you want to launch automatic modification process to ensure the compatibility ?";
int ret = QMessageBox::question(this,tr("Building references library"),msg, QMessageBox::Ok | QMessageBox::Cancel, QMessageBox::Ok);
if (ret == QMessageBox::Ok) {
- dispatcher->findGraphModifications(toBlock);
+ dispatcher->findGraphModifications(Dispatcher::Design, toBlock);
}
}
}
void MainWindow::slotGenerateVHDL() {
try {
- dispatcher->generateVHDL();
+ dispatcher->generateVHDL(Dispatcher::Design);
}
catch(Exception e) {
cerr << qPrintable(e.getMessage()) << endl;
void MainWindow::mousePressEvent(QMouseEvent *e) {
if (dispatcher->getCurrentGroup() != NULL) {
- dispatcher->setCurrentGroupWidget(dispatcher->getCurrentGroup());
+ dispatcher->setCurrentGroupWidget(Dispatcher::Design, dispatcher->getCurrentGroup());
}
QMainWindow::mousePressEvent(e);
}
layDirProj->addWidget(dirProjEdit);
layDirProj->addWidget(dirProjButton);
+ QHBoxLayout *layClk = new QHBoxLayout;
+ QLabel* clkLab1 = new QLabel(tr("Main clock freq."));
+ QLabel* clkLab2 = new QLabel(tr("MHz"));
+ clkEdit = new QLineEdit("100");
+ layClk->addWidget(clkLab1);
+ layClk->addWidget(clkEdit);
+ layClk->addWidget(clkLab2);
+
+ QHBoxLayout *layAuto = new QHBoxLayout;
+ autoConnClkCheck = new QCheckBox("Auto-connect blocks to main clock");
+ autoConnClkCheck->setChecked(true);
+
QVBoxLayout *layAll = new QVBoxLayout;
layAll->addLayout(layNameProj);
layAll->addLayout(layDirProj);
+ layAll->addLayout(layClk);
+ layAll->addLayout(layAuto);
setContent(layAll);
connect(dirProjButton,SIGNAL(clicked()),this,SLOT(chooseProjectPath()));
connect(nameProjEdit,SIGNAL(textChanged(QString)),this,SLOT(checkProjectName(QString)));
connect(dirProjEdit,SIGNAL(textChanged(QString)),this,SLOT(checkProjectPath(QString)));
-
}
+
void NewProjectDialog::checkBeforeAccept() {
- if ((!nameProjEdit->text().isEmpty()) && (pathOk)) {
- //cout << "all ok" << endl;
- params->projectPath = dirProjEdit->text();
- params->projectFile = params->projectPath + "/" + params->projectName + ".xml";
+ if ((nameProjEdit->text().isEmpty()) || (!pathOk)) {
- accept();
+ int ret = QMessageBox::warning(this,"Cannot create the project","Invalid project path");
+ return;
+ }
+ double freq;
+ bool ok = false;
+ freq = clkEdit->text().toDouble(&ok);
+ if (!ok) {
+ int ret = QMessageBox::warning(this,"Cannot create the project","Invalid main clock frequency (in MHz)");
+ return;
}
- else {
- int ret = QMessageBox::warning(this,"Cannot create the project","Invalid project path");
+ //cout << "all ok" << endl;
+ params->projectPath = dirProjEdit->text();
+ params->projectFile = params->projectPath + "/" + params->projectName + ".xml";
+ params->clocks.append(freq);
+ if (autoConnClkCheck->isChecked()) {
+ params->autoConnMainClk = true;
+ }
+ else {
+ params->autoConnMainClk = false;
}
+
+ accept();
+
}
void NewProjectDialog::chooseProjectPath() {
QLineEdit *nameProjEdit;
QLineEdit *dirProjEdit;
QPushButton *dirProjButton;
+ QCheckBox *autoConnClkCheck;
+ QLineEdit *clkEdit;
+
bool pathOk;
private slots:
void checkBeforeAccept();
void chooseProjectPath();
void checkProjectPath(QString name);
- void checkProjectName(QString name);
-
+ void checkProjectName(QString name);
};
refPathes.clear();\r
}\r
\r
-Graph* Parameters::createGraph() {\r
- graph = new Graph();\r
+Graph* Parameters::createGraph(bool createTopGroupIfaces) {\r
+ graph = new Graph(createTopGroupIfaces);\r
return graph;\r
}\r
\r
if(!ok) throw(Exception(PROJECTFILE_CORRUPTED));\r
\r
if (idUpperScene == -1) {\r
- topGroup = dispatcher->createTopScene();\r
+ topGroup = dispatcher->createTopScene(Dispatcher::Load);\r
topScene->setId(idScene);\r
groupItem = topScene->getGroupItem(); \r
cout << "top group added to scene n°" << idScene << endl;\r
else {\r
cout << "trying to create scene n°" << idScene << " with upper scene n°" <<idUpperScene << endl;\r
GroupScene* upperScene = searchSceneById(idUpperScene, topScene);\r
- groupWidget = dispatcher->addNewEmptyGroup(upperScene,false);\r
+ groupWidget = dispatcher->addNewEmptyGroup(Dispatcher::Load, upperScene,false);\r
groupWidget->getScene()->setId(idScene);\r
groupItem = groupWidget->getScene()->getGroupItem(); \r
}\r
cout << qPrintable(groupItem->getRefBlock()->getName()) << " has upper box item in " << qPrintable(groupItem->getParentItem()->getScene()->getGroupItem()->getRefBlock()->getName()) << endl;\r
} \r
}\r
- dispatcher->setSceneCounter(maxIdScene+1);\r
+ dispatcher->setSceneCounter(Dispatcher::Load, maxIdScene+1);\r
cout << "groupItems loaded and windows created succefully!" << endl;\r
\r
/**********************************************************\r
InterfaceItem *iface2 = searchInterfaceItemById(to,topScene);\r
\r
if(iface1 != NULL && iface2 != NULL){\r
- dispatcher->createConnection(iface1,iface2);\r
+ dispatcher->createConnection(Dispatcher::Load, iface1,iface2);\r
} else {\r
cout << "interfaces not found, connect canceled!" << endl;\r
}\r
QString projectPath;\r
QString projectName;\r
QString projectFile; // equals to projectPath/projectName.xml\r
+ bool autoConnMainClk; // true if auto-connection to main clock (i.e. ext_clk)\r
+ QList<double> clocks; // clocks[0] is the main clock.\r
\r
- Graph* createGraph();\r
+ Graph* createGraph(bool createTopGroupIfaces = true);\r
void destroyGraph();\r
inline Graph* getGraph() { return graph; } \r
ReferenceBlock* getReferenceBlock(int idCategory, int idBlock); // get the reference block from its category and index\r
int mode = getScene()->getEditionMode();
- dispatcher->setCurrentGroupWidget(getScene()->getGroupWidget());
+ dispatcher->setCurrentGroupWidget(Dispatcher::Design, getScene()->getGroupWidget());
if ((mode == GroupScene::AddConnection) && (params->cursorState == Parameters::CursorOnInterface)) {
InterfaceItem *inter = getInterfaceItemFromCursor(x,y);
else if (params->editState == Parameters::EditCloseConnection) {
InterfaceItem* iface1 = getScene()->getSelectedInterface(1);
InterfaceItem* iface2 = getScene()->getSelectedInterface(2);
- bool ok = dispatcher->createConnection(iface1,iface2);
+ bool ok = dispatcher->createConnection(Dispatcher::Design, iface1,iface2);
if (ok) {
iface1->selected = false;
update(iface1->boundingRect());
if(selectedAction == NULL) return ;
if (selectedAction == removeAction) {
- dispatcher->removeSourceItem(this);
+ dispatcher->removeSourceItem(Dispatcher::Design, this);
}
else if (selectedAction == duplicateAction) {
- dispatcher->duplicateSourceItem(this);
+ dispatcher->duplicateSourceItem(Dispatcher::Design, this);
}
else if(selectedAction == renameAction){
if(ifaceItem != NULL) {
- dispatcher->renameInterface(ifaceItem);
+ dispatcher->renameInterface(Dispatcher::Design, ifaceItem);
}
else {
- dispatcher->renameSourceBlock(this);
+ dispatcher->renameSourceBlock(Dispatcher::Design, this);
}
}
else if(selectedAction == showProperties){
- dispatcher->showProperties(ifaceItem);
+ dispatcher->showProperties(Dispatcher::Design, ifaceItem);
}
else if(selectedAction == showParameters){
new ParametersWindow(refBlock, params, NULL);
}
else if(selectedAction == showPatterns) {
- dispatcher->showPatterns(ifaceItem);
+ dispatcher->showPatterns(Dispatcher::Design, ifaceItem);
}
}
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE QtCreatorProject>
-<!-- Written by QtCreator 4.2.0, 2018-04-13T16:44:04. -->
+<!-- Written by QtCreator 4.2.0, 2018-04-20T16:47:23. -->
<qtcreator>
<data>
<variable>EnvironmentId</variable>
+++ /dev/null
-((1{$group_size}0{$group_delay-1}){($item_per_line-1)|$group_size}1{1+(($item_per_line-1)%$group_size)}0{$line_delay-1}){$nb_lines}
\ No newline at end of file