|
|
@@ -118,6 +118,7 @@ void PLC::applyProjectToScene(const Project& proj) |
|
|
|
Item* item = creatItem(d.type); |
|
|
|
if (!item) continue; |
|
|
|
item->setPos(d.x, d.y); |
|
|
|
item->setRegisterId(d.registerId); |
|
|
|
connect(item, &Item::requestCopy, ui->graphicsView, &MyGraphicsView::onItemRequestCopy); |
|
|
|
connect(item, &Item::requestDelete, ui->graphicsView, &MyGraphicsView::onItemRequestDelete); |
|
|
|
connect(item, &Item::requestBindRegister, ui->graphicsView, &MyGraphicsView::onItemRequestBindRegister); |
|
|
@@ -150,6 +151,7 @@ void PLC::extractSceneToProject(Project& proj) |
|
|
|
d.type = it->itemType(); |
|
|
|
d.x = it->pos().x(); |
|
|
|
d.y = it->pos().y(); |
|
|
|
d.registerId = it->registerId(); |
|
|
|
proj.items_.append(d); |
|
|
|
} |
|
|
|
// (3) 存连线数据 |
|
|
@@ -212,6 +214,7 @@ void PLC::btnInsertClicked() |
|
|
|
newItem->setPos(insertPos); |
|
|
|
connect(newItem, &Item::requestCopy, ui->graphicsView, &MyGraphicsView::onItemRequestCopy); |
|
|
|
connect(newItem, &Item::requestDelete, ui->graphicsView, &MyGraphicsView::onItemRequestDelete); |
|
|
|
connect(newItem, &Item::requestBindRegister, ui->graphicsView, &MyGraphicsView::onItemRequestBindRegister); |
|
|
|
ui->graphicsView->scene()->addItem(newItem); |
|
|
|
|
|
|
|
// 5. 新建两条连线 |
|
|
|