groupItem = NULL;
}
+/*
+void GroupScene::mouseMoveEvent(QGraphicsSceneMouseEvent *event) {
+
+ //QGraphicsScene::mouseMoveEvent(event);
+
+ QPointF p = event->scenePos();
+ cout << p.x() << "," << p.y() << endl;
+
+}
+*/
+
void GroupScene::setSelectedInterface(int id, InterfaceItem* iface) {
if ((id < 1)|| (id > 2)) return;
selectedInterfaces[id-1] = iface;
int GroupScene::setItemsId(int countInit) {
int counter = countInit;
groupItem->setId(counter++);
+ if (isTopScene()) {
+ foreach(SourceItem *item, sourceItems){
+ item->setId(counter++);
+ }
+ }
foreach(BoxItem *item, boxItems){
item->setId(counter++);
}
foreach(InterfaceItem* inter, groupItem->getInterfaces()){
inter->setId(counter++);
}
+ if (isTopScene()) {
+ foreach(SourceItem *item, sourceItems){
+ foreach(InterfaceItem* inter, item->getInterfaces()){
+ inter->setId(counter++);
+ }
+ }
+ }
foreach(BoxItem *item, boxItems){
foreach(InterfaceItem* inter, item->getInterfaces()){
inter->setId(counter++);
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);
}
void GroupScene::addSourceItem(SourceItem* item) {
+ // adding item to the scene
+ addItem(item);
+ item->setZValue(1);
// add item from the QList
sourceItems.append(item);
}
sourceItems.removeAll(item);
}
-void GroupScene::createConnectionItem(InterfaceItem *iface1, InterfaceItem *iface2) {
+void GroupScene::createConnectionItem(InterfaceItem *iface1, InterfaceItem *iface2, bool visible) {
ConnectionItem* conn = NULL;
conn = new ConnectionItem(iface1,iface2, dispatcher, params);
+ conn->setVisible(visible);
addItem(conn);
addConnectionItem(conn);
}
}
void GroupScene::removeConnectionItem(ConnectionItem* item) {
+
+ // remove connection from/to InterfaceItem
+ InterfaceItem* fromIfaceItem = item->getFromInterfaceItem();
+ InterfaceItem* toIfaceItem = item->getToInterfaceItem();
+ fromIfaceItem->removeConnectionItem(item);
+ toIfaceItem->removeConnectionItem(item);
+
// remove item from the viewport
removeItem(item);
// remove item from the QList
if (selectedInterfaces[0] != NULL) {
selectedInterfaces[0]->selected = false;
- selectedInterfaces[0] == NULL;
+ selectedInterfaces[0] = NULL;
}
if (selectedInterfaces[1] != NULL) {
selectedInterfaces[1]->selected = false;
- selectedInterfaces[1] == NULL;
+ selectedInterfaces[1] = NULL;
}
}