git-svn-id: svn://db.shs.com.ru/libs@316 a8b55f48-bf90-11e4-a774-851b48703e85

This commit is contained in:
2017-11-15 14:27:51 +00:00
parent efeb95c1c3
commit ed362a6b55
8 changed files with 473 additions and 215 deletions

View File

@@ -28,7 +28,7 @@ BlockView::~BlockView() {
void BlockView::_init() {
grid_visible = grid_snap = pm_connect = navigation = m_connect = m_trace_with_buses = minimap = true;
mm_drag = moved = new_branch = new_bus = mm_cancel = iconnect = mm_copy = m_pin_mc = mm_thumb = false;
mm_drag = moved = new_branch = new_bus = mm_cancel = iconnect = mm_copy = m_pin_mc = mm_thumb = move_bus_point = false;
match_bus = bus_from = 0;
mm_ci = 0;
hpin = 0;
@@ -41,7 +41,7 @@ void BlockView::_init() {
smode = BlockView::MultiSelection;
cur_scl = thumb_scl = 1.;
_talpha = 0.;
ae_enabled = is_nav_anim = true;
ae_enabled = is_nav_anim = is_block_anim = true;
nav_prev_aa = nav_prev_grid = true;
thumb_size = QSizeF(200, 200);
if (scene() == 0) {
@@ -339,12 +339,11 @@ bool BlockView::eventFilter(QObject * o, QEvent * e) {
break;
}
if (hpin) {
if (hpin->state() == BlockItemPin::Accept)
hoverAcceptedPin(hpin);
else
hpin = 0;
} else
unhoverPins();
if (hpin->state() == BlockItemPin::Accept) {
unhoverPins(hpin);
hoverAcceptedPin(hpin, true);
} else hpin = 0;
} else unhoverPins();
if (new_branch) {
matchBus();
break;
@@ -1283,10 +1282,10 @@ void BlockView::markPins(int bus_type) {
BlockItemPin * p = qgraphicsitem_cast<BlockItemPin*>(i);
p->saveState();
if (m_pin_mc) {
if (p->busType() == tmp_bus.busType())
if (p->busType() == bus_type)
p->setState(BlockItemPin::Accept);
} else {
if (p->busType() == tmp_bus.busType() && p->state() == BlockItemPin::Disconnected)
if (p->busType() == bus_type && p->state() == BlockItemPin::Disconnected)
p->setState(BlockItemPin::Accept);
}
}
@@ -1307,17 +1306,20 @@ void BlockView::unmarkPins(bool to_normal) {
}
void BlockView::hoverAcceptedPin(BlockItemPin * pin) {
void BlockView::hoverAcceptedPin(BlockItemPin * pin, bool hover) {
if (!pin) return;
pin->resizePin(12.);
pin->enlargePin(hover);
}
void BlockView::unhoverPins() {
void BlockView::unhoverPins(BlockItemPin* excl_pin) {
QList<QGraphicsItem * > gi = scene_->items();
foreach (QGraphicsItem * i, gi)
if (i->data(1004) == "pin")
((BlockItemPin*)i)->resizePin();
foreach (QGraphicsItem * i, gi) {
if (excl_pin == ((BlockItemPin*)i)) continue;
if (i->data(1004) == "pin") {
((BlockItemPin*)i)->enlargePin(false);
}
}
}
@@ -1473,6 +1475,21 @@ void BlockView::newBranch(BlockBusItem * item) {
}
void BlockView::startBusPointMove(int bus_type) {
move_bus_point = true;
newBusStarted(bus_type);
markPins(bus_type);
}
void BlockView::endBusPointMove() {
move_bus_point = false;
unmarkPins();
reconnectAll();
}
void BlockView::newBranchTrace(BlockBusItem * item, QPointF to) {
trace(item->press_pos, to, &tmp_bus);
tmp_bus.show();
@@ -1601,6 +1618,7 @@ void BlockView::reconnectAll() {
buses << qgraphicsitem_cast<BlockBusItem*>(i);
}
foreach (BlockItemPin * p, pins) {
p->clearStateStack();
p->setState(BlockItemPin::Disconnected);
p->buses_.clear();
}