X-Git-Url: https://bilbo.iut-bm.univ-fcomte.fr/and/gitweb/blast.git/blobdiff_plain/1b7818e18ed7bcf3464e307b97c6e0e6d72cc69b..4327c2b8817b627249d98d889835726217c81a4e:/GroupScene.cpp?ds=sidebyside diff --git a/GroupScene.cpp b/GroupScene.cpp index 0eaa8a1..13b6e11 100644 --- a/GroupScene.cpp +++ b/GroupScene.cpp @@ -5,10 +5,11 @@ #include "GroupWidget.h" #include "GroupItem.h" #include "BoxItem.h" -#include "SourceItem.h" +#include "StimuliItem.h" #include "ConnectionItem.h" #include "InterfaceItem.h" #include "AbstractBlock.h" +#include "Graph.h" GroupScene::GroupScene(GroupScene *_parentScene, GroupWidget *_window, Dispatcher* _dispatcher, Parameters* _params, bool _topScene, QObject *parent) : QGraphicsScene(parent) { dispatcher = _dispatcher; @@ -73,7 +74,7 @@ int GroupScene::setItemsId(int countInit) { int counter = countInit; groupItem->setId(counter++); if (isTopScene()) { - foreach(SourceItem *item, sourceItems){ + foreach(StimuliItem *item, stimuliItems){ item->setId(counter++); } } @@ -89,7 +90,7 @@ int GroupScene::setInterfacesId(int countInit) { inter->setId(counter++); } if (isTopScene()) { - foreach(SourceItem *item, sourceItems){ + foreach(StimuliItem *item, stimuliItems){ foreach(InterfaceItem* inter, item->getInterfaces()){ inter->setId(counter++); } @@ -103,15 +104,17 @@ int GroupScene::setInterfacesId(int countInit) { return counter; } -BoxItem *GroupScene::createBoxItem(AbstractBlock *block, BoxItem::Position hPos, BoxItem::Position vPos, AbstractBoxItem::LockType lock, BoxItem::SpanType span) { +BoxItem *GroupScene::createBoxItem(AbstractBlock *block, BoxItem::Position position, int lock, BoxItem::SpanType span) { - BoxItem* item = new BoxItem(block,dispatcher,params,groupItem, lock, span); + BoxItem* item = new BoxItem(block,dispatcher,params,groupItem, lock, span, position); item->setZValue(1); // add item from the QList boxItems.append(item); // repainting the group groupItem->updateShape(); - // center the new block + +/* + // position the new block double x,y; if (hPos == BoxItem::Left) { x = 0; @@ -134,7 +137,7 @@ BoxItem *GroupScene::createBoxItem(AbstractBlock *block, BoxItem::Position hPos, QPointF newPos(x,y); newPos = newPos-item->getOriginPoint(); item->moveTo(newPos); - +*/ return item; } @@ -154,35 +157,44 @@ void GroupScene::removeBoxItem(BoxItem* item) { groupItem->updateShape(); } -SourceItem *GroupScene::createSourceItem(AbstractBlock *block) { +BoxItem* GroupScene::searchBoxItemByName(QString name) { + foreach(BoxItem* item, boxItems) { + if (item->getRefBlock()->getName() == name) { + return item; + } + } + return NULL; +} + +StimuliItem *GroupScene::createStimuliItem(AbstractBlock *block) { - SourceItem* item = new SourceItem(block,dispatcher,params); + StimuliItem* item = new StimuliItem(block,dispatcher,params); // adding item to the scene addItem(item); item->setZValue(1); // add item from the QList - sourceItems.append(item); + stimuliItems.append(item); // center the new block QPointF groupPos = groupItem->pos(); - QPointF newPos(groupPos.x()-item->getTotalWidth()-50, groupPos.y()); + QPointF newPos(groupPos.x()-item->getTotalWidth()-100, groupPos.y()); newPos = newPos-item->getOriginPoint(); item->moveTo(newPos); return item; } -void GroupScene::addSourceItem(SourceItem* item) { +void GroupScene::addStimuliItem(StimuliItem* item) { // adding item to the scene addItem(item); item->setZValue(1); // add item from the QList - sourceItems.append(item); + stimuliItems.append(item); } -void GroupScene::removeSourceItem(SourceItem* item) { +void GroupScene::removeStimuliItem(StimuliItem* item) { // remove item from the viewport removeItem(item); // remove item from the QList - sourceItems.removeAll(item); + stimuliItems.removeAll(item); } void GroupScene::createConnectionItem(InterfaceItem *iface1, InterfaceItem *iface2, bool visible) { @@ -266,12 +278,22 @@ void GroupScene::save(QXmlStreamWriter &writer) { else { writer.writeAttribute("upper_scene",QString::number(parentScene->getId())); } + if (isTopScene()) { + QString clkList = ""; + QList lst = params->getGraph()->getClocks(); + foreach(double d, lst) { + clkList += QString::number(d)+","; + } + clkList.chop(1); + writer.writeAttribute("clkList",clkList); + + } groupItem->save(writer); if (isTopScene()) { writer.writeStartElement("source_items"); - writer.writeAttribute("count",QString::number(sourceItems.length())); - foreach(SourceItem* item, sourceItems) { + writer.writeAttribute("count",QString::number(stimuliItems.length())); + foreach(StimuliItem* item, stimuliItems) { item->save(writer); } writer.writeEndElement(); // source_items