|
|
|
|
@@ -464,9 +464,14 @@ bool BlockView::eventFilter(QObject * o, QEvent * e) {
|
|
|
|
|
}
|
|
|
|
|
if (!mm_mods.testFlag(Qt::ControlModifier) && !mm_mods.testFlag(Qt::ShiftModifier)) {
|
|
|
|
|
if (!mdp.isNull()) moved = true;
|
|
|
|
|
foreach(QGraphicsItem * i, sel_items)
|
|
|
|
|
if (i->flags().testFlag(QGraphicsItem::ItemIsMovable)) i->setPos(i->pos() + mdp);
|
|
|
|
|
if (!me->modifiers().testFlag(Qt::AltModifier)) moveBuses(sel_items, mdp);
|
|
|
|
|
bool is_correct = true;
|
|
|
|
|
if (!me->modifiers().testFlag(Qt::AltModifier)) is_correct = moveBuses(sel_items, mdp);
|
|
|
|
|
if (is_correct) {
|
|
|
|
|
for (auto * i: sel_items)
|
|
|
|
|
if (i->flags().testFlag(QGraphicsItem::ItemIsMovable)) i->setPos(i->pos() + mdp);
|
|
|
|
|
} else {
|
|
|
|
|
scene_point -= mdp;
|
|
|
|
|
}
|
|
|
|
|
setCursor(Qt::ClosedHandCursor);
|
|
|
|
|
}
|
|
|
|
|
return true;
|
|
|
|
|
@@ -1487,28 +1492,42 @@ void BlockView::simplifyBuses() {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void BlockView::moveBuses(const QList<QGraphicsItem *> & items, QPointF dp) {
|
|
|
|
|
if (dp.isNull()) return;
|
|
|
|
|
bool BlockView::moveBuses(const QList<QGraphicsItem *> & items, QPointF dp) {
|
|
|
|
|
if (dp.isNull()) return true;
|
|
|
|
|
QList<QGraphicsItem *> gi = scene_->items();
|
|
|
|
|
QVector<BlockItemPin *> pins;
|
|
|
|
|
QList<BlockBusItem *> buses;
|
|
|
|
|
QList<BlockBusItem *> buses_m_part, buses_m_all;
|
|
|
|
|
QMap<BlockBusItem *, QPolygonF> saved_pols;
|
|
|
|
|
// qDebug() << "move" << dp;
|
|
|
|
|
foreach(QGraphicsItem * i, items)
|
|
|
|
|
for (auto * i: items)
|
|
|
|
|
if ((i->data(bvidType).toInt() == bvitBlock) && i->flags().testFlag(QGraphicsItem::ItemIsMovable))
|
|
|
|
|
pins << qgraphicsitem_cast<BlockItem *>(i)->pins();
|
|
|
|
|
foreach(QGraphicsItem * i, gi)
|
|
|
|
|
if (i->data(bvidType).toInt() == bvitBus) buses << qgraphicsitem_cast<BlockBusItem *>(i);
|
|
|
|
|
foreach(BlockBusItem * b, buses) {
|
|
|
|
|
QList<BlockItemPin *> bpins = b->connections_.values();
|
|
|
|
|
if (!bpins.isEmpty()) {
|
|
|
|
|
foreach(BlockItemPin * p, pins)
|
|
|
|
|
for (auto * i: gi) {
|
|
|
|
|
if (i->data(bvidType).toInt() == bvitBus) {
|
|
|
|
|
auto * b = qgraphicsitem_cast<BlockBusItem *>(i);
|
|
|
|
|
QList<BlockItemPin *> bpins = b->connectedPins();
|
|
|
|
|
if (bpins.isEmpty()) continue;
|
|
|
|
|
bool affect = false;
|
|
|
|
|
for (auto * i: pins) {
|
|
|
|
|
if (bpins.contains(i)) {
|
|
|
|
|
affect = true;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if (!affect) continue;
|
|
|
|
|
for (auto * p: pins)
|
|
|
|
|
bpins.removeAll(p);
|
|
|
|
|
if (bpins.isEmpty()) {
|
|
|
|
|
b->movePolyline(dp);
|
|
|
|
|
continue;
|
|
|
|
|
if (bpins.isEmpty())
|
|
|
|
|
buses_m_all << b;
|
|
|
|
|
else {
|
|
|
|
|
buses_m_part << b;
|
|
|
|
|
saved_pols[b] = b->pol;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
foreach(BlockItemPin * p, pins) {
|
|
|
|
|
}
|
|
|
|
|
bool incorrect_move = false;
|
|
|
|
|
for (auto * b: buses_m_part) {
|
|
|
|
|
for (auto * p: pins) {
|
|
|
|
|
QList<int> ends = b->connections_.keys(p);
|
|
|
|
|
for (int i = 0; i < ends.size(); ++i) {
|
|
|
|
|
QPointF pdp = dp;
|
|
|
|
|
@@ -1533,12 +1552,26 @@ void BlockView::moveBuses(const QList<QGraphicsItem *> & items, QPointF dp) {
|
|
|
|
|
default: break;
|
|
|
|
|
}
|
|
|
|
|
QVector<int> epl = b->endpointLine(ends[i], ang);
|
|
|
|
|
foreach(int e, epl)
|
|
|
|
|
for (int e: epl)
|
|
|
|
|
b->movePoint(e, pdp);
|
|
|
|
|
b->movePoint(ends[i], dp);
|
|
|
|
|
if (b->hasNullSegment()) {
|
|
|
|
|
incorrect_move = true;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if (incorrect_move) break;
|
|
|
|
|
}
|
|
|
|
|
if (incorrect_move) break;
|
|
|
|
|
}
|
|
|
|
|
if (incorrect_move) {
|
|
|
|
|
for (auto * b: buses_m_part)
|
|
|
|
|
b->pol = saved_pols.value(b);
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
for (auto * b: buses_m_all)
|
|
|
|
|
b->movePolyline(dp);
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|