new BlockView::newBusFinished

This commit is contained in:
2023-04-13 18:21:21 +03:00
parent dc91237545
commit 94c1c73642
5 changed files with 125 additions and 53 deletions

View File

@@ -50,8 +50,8 @@ void BlockView::_init() {
_talpha = 0.;
ae_enabled = is_block_anim = is_nav_anim = true;
nav_prev_aa = nav_prev_imaa = nav_prev_grid = true;
square_node = block_emit_selection = false;
thumb_size = QSizeF(200, 200);
square_node = block_emit_selection = new_bus_started = false;
thumb_size = QSizeF(200, 200);
if (scene() == 0) {
scene_ = new QGraphicsScene;
setScene(scene_);
@@ -308,8 +308,7 @@ bool BlockView::eventFilter(QObject * o, QEvent * e) {
}
// qDebug() << "new" << ;
prev_tcb = m_trace_with_buses;
newBusStarted(tmp_bus.busType());
markPins(tmp_bus.busType());
startNewBus(tmp_bus.busType());
if (qgraphicsitem_cast<BlockItemPin *>(mm_ci)->alignment() == Qt::AlignLeft ||
qgraphicsitem_cast<BlockItemPin *>(mm_ci)->alignment() == Qt::AlignRight)
wavetrace.setPreferredDirection(BlockViewWavetrace::Horizontal);
@@ -483,6 +482,7 @@ bool BlockView::eventFilter(QObject * o, QEvent * e) {
if (me->buttons().testFlag(Qt::LeftButton)) btncnt++;
if (me->buttons().testFlag(Qt::RightButton)) btncnt++;
if (me->buttons().testFlag(QT_MID_BUTTON)) btncnt++;
maybeEndNewBus();
cur_bus = 0;
mm_cancel = btncnt > 0;
if (mm_cancel || (me->button() == QT_MID_BUTTON) || (me->button() == Qt::RightButton)) {
@@ -846,6 +846,23 @@ void BlockView::clearGhost() {
}
void BlockView::startNewBus(int bus_type) {
newBusStarted(bus_type);
markPins(bus_type);
new_bus_started = true;
}
void BlockView::maybeEndNewBus() {
if (!new_bus_started) return;
new_bus_started = false;
QMetaObject::invokeMethod(
this,
[this]() { newBusFinished(); },
Qt::QueuedConnection);
}
void BlockView::getPinMC(bool * v) {
if (v) *v = m_pin_mc;
}
@@ -1665,8 +1682,7 @@ void BlockView::adjustThumb() {
void BlockView::newBranch(BlockBusItem * item) {
bus_from = item;
prev_tcb = m_trace_with_buses;
newBusStarted(item->busType());
markPins(item->busType());
startNewBus(item->busType());
new_branch = true;
tmp_bus.setBusType(item->busType());
if (item->selSegment >= 0) {
@@ -1680,8 +1696,7 @@ void BlockView::newBranch(BlockBusItem * item) {
void BlockView::startBusPointMove(int bus_type) {
move_bus_point = true;
prev_tcb = m_trace_with_buses;
newBusStarted(bus_type);
markPins(bus_type);
startNewBus(bus_type);
}