diff --git a/pip b/pip index dac318c..8c3349d 160000 --- a/pip +++ b/pip @@ -1 +1 @@ -Subproject commit dac318c624c986926c6a1ead06b852d432570678 +Subproject commit 8c3349d84afb922878cc77b38825504af03a339a diff --git a/qad/blockview/blockbusitem.cpp b/qad/blockview/blockbusitem.cpp index a15424a..098fe9f 100644 --- a/qad/blockview/blockbusitem.cpp +++ b/qad/blockview/blockbusitem.cpp @@ -496,7 +496,12 @@ void BlockBusItem::testPoint(QPointF pos, int * sel_point, int * sel_segment) { void BlockBusItem::hoverEnterEvent(QGraphicsSceneHoverEvent * e) { - tt = bus_name + (bus_name.isEmpty() ? "" : "\n\n") + tr("Add point: Ctrl + LeftClick\nRemove point\\segment: Ctrl + RightClick\nNew branch: Shift + LeftClick\nRemove connection: Shift + RightClick"); + tt = bus_name + (bus_name.isEmpty() ? "" : "\n\n") + + tr("Add point: Ctrl + LeftClick\n" + "Remove point\\segment: Ctrl + RightClick\n" + "Remove connection: Shift + RightClick\n" + "Move point\\segment: Shift + LeftPress\n" + "Change trace mode: press Shift, when mouse move"); } @@ -563,12 +568,12 @@ void BlockBusItem::mousePressEvent(QGraphicsSceneMouseEvent * e) { QMetaObject::invokeMethod(scene()->views().back(), "newBranchCancel"); } new_segment = false; - if ((selPoint < 0 || selPoint > pol.size() - 1) && (selSegment < 0)) { + if ((selPoint < 0 || selPoint > pol.size() - 1) && (selSegment < 0) && e->modifiers().testFlag(Qt::ShiftModifier)) { QGraphicsObject::mousePressEvent(e); return; } int btncnt = 0; - if (endpoints().contains(selPoint) && e->button() == Qt::LeftButton) + if (endpoints().contains(selPoint) && (e->button() == Qt::LeftButton) && e->modifiers().testFlag(Qt::ShiftModifier)) QMetaObject::invokeMethod(scene()->views().back(), "startBusPointMove", Q_ARG(int, busType())); if (e->buttons().testFlag(Qt::LeftButton)) btncnt++; if (e->buttons().testFlag(Qt::RightButton)) btncnt++; @@ -591,28 +596,26 @@ void BlockBusItem::mousePressEvent(QGraphicsSceneMouseEvent * e) { prepareGeometryChange(); return; } - if (e->modifiers().testFlag(Qt::ShiftModifier)) { - if (e->buttons().testFlag(Qt::LeftButton)) { - if (selSegment >= 0) - press_pos = quantize(nearestPointOnLine(pol[segments[selSegment].first], pol[segments[selSegment].second], e->scenePos()), grid_step); - else { - if (selPoint >= 0) - press_pos = pol[selPoint]; - else + if (e->buttons().testFlag(Qt::LeftButton) && e->modifiers().testFlag(Qt::NoModifier)) { + if (selSegment >= 0) + press_pos = quantize(nearestPointOnLine(pol[segments[selSegment].first], pol[segments[selSegment].second], e->scenePos()), grid_step); + else { + if (selPoint >= 0) + press_pos = pol[selPoint]; + else + return; + } + if (max_ep >= 2) { + if (endpointCount() >= max_ep) + if (pointSegmentsCount(selPoint) >= 2 || selSegment >= 0) return; - } - if (max_ep >= 2) { - if (endpointCount() >= max_ep) - if (pointSegmentsCount(selPoint) >= 2 || selSegment >= 0) - return; - } - QMetaObject::invokeMethod(scene()->views().back(), "newBranch", Q_ARG(BlockBusItem * , this)); - new_segment = true; - return; - } - if (e->buttons().testFlag(Qt::RightButton)) { - deleteLater(); } + QMetaObject::invokeMethod(scene()->views().back(), "newBranch", Q_ARG(BlockBusItem * , this)); + new_segment = true; + return; + } + if (e->buttons().testFlag(Qt::RightButton) && e->modifiers().testFlag(Qt::ShiftModifier)) { + deleteLater(); } if (e->modifiers().testFlag(Qt::ControlModifier)) { if (e->buttons().testFlag(Qt::RightButton)) { @@ -635,24 +638,22 @@ void BlockBusItem::mousePressEvent(QGraphicsSceneMouseEvent * e) { return; } } - if (e->modifiers().testFlag(Qt::ShiftModifier)) { - if (e->buttons().testFlag(Qt::RightButton)) { - if (deleted) return; - deleted = true; - } + if (e->buttons().testFlag(Qt::RightButton)) { + if (deleted) return; + deleted = true; } } void BlockBusItem::mouseMoveEvent(QGraphicsSceneMouseEvent * e) { if (temp_ || mm_cancel) return; - if (((selPoint < 0 || selPoint > pol.size() - 1) && (selSegment < 0)) && !new_segment) { + if (((selPoint < 0 || selPoint > pol.size() - 1) && (selSegment < 0)) && !new_segment && mm_mods.testFlag(Qt::ShiftModifier)) { QGraphicsObject::mouseMoveEvent(e); return; } qp = quantize(e->scenePos(), grid_step); lp = qp - lp; - if (e->buttons().testFlag(Qt::LeftButton) && mm_mods.testFlag(Qt::ShiftModifier) && new_segment) { + if (e->buttons().testFlag(Qt::LeftButton) && mm_mods.testFlag(Qt::NoModifier) && new_segment) { QMetaObject::invokeMethod(scene()->views().back(), "newBranchTrace", Q_ARG(BlockBusItem * , this), Q_ARG(QPointF, e->scenePos())); return; } @@ -722,6 +723,7 @@ void BlockBusItem::paint(QPainter * p, const QStyleOptionGraphicsItem * o, QWidg if (im_bus.isNull()) { for (int i = 0; i < segments.size(); ++i) { p->drawLine(pol[segments[i].first], pol[segments[i].second]); + if (pointSegmentsCount(segments[i].first) > 2) p->drawEllipse(pol[segments[i].first], pen_width*0.7, pen_width*0.7); } } else { QBrush br; diff --git a/qad/blockview/blockview.cpp b/qad/blockview/blockview.cpp index e98c575..8a44783 100644 --- a/qad/blockview/blockview.cpp +++ b/qad/blockview/blockview.cpp @@ -1277,7 +1277,7 @@ void BlockView::trace(QPointF scene_pos_from, QPointF scene_pos_to, BlockBusItem for (int j = 0; j < steps; ++j) { QPoint tp = quantize(cp, grid_step).toPoint() / grid_step + dp; if (tp != qpt) - wavetrace.fill(tp, BlockViewWavetrace::Blocked); + wavetrace.fill(tp, BlockViewWavetrace::Jump); //qDebug() << " set" << cp; cp += QPointF(sx, sy); } diff --git a/qad/blockview/blockviewwavetrace.cpp b/qad/blockview/blockviewwavetrace.cpp index 867631a..72b597c 100644 --- a/qad/blockview/blockviewwavetrace.cpp +++ b/qad/blockview/blockviewwavetrace.cpp @@ -5,7 +5,7 @@ BlockViewWavetrace::BlockViewWavetrace(int width, int height) { max_steps = 512; resize(width, height); - setPreferredDirection(BlockViewWavetrace::Horizontal); + setPreferredDirection(Horizontal); } @@ -40,6 +40,10 @@ void BlockViewWavetrace::fill(const QRect & rect, short val) { field[i][j] = val; } +void BlockViewWavetrace::fill(int px, int py, short val) { + field[px][py] = val; +} + bool BlockViewWavetrace::trace(const QPoint & start, const QPoint & finish) { st = start; @@ -48,12 +52,24 @@ bool BlockViewWavetrace::trace(const QPoint & start, const QPoint & finish) { //qDebug() << "trace" << start << finish; //return true; int cx, cy; - short cl = 0, empty = (short)BlockViewWavetrace::Empty; + short cl = 0; QRect frect(0, 0, wid - 1, hei - 1); QVector cpnts, npnts; fill(st, cl); - cpnts.push_back(st); - if (field[fn.x()][fn.y()] == (short)BlockViewWavetrace::Blocked) + jumps.clear(); + cpnts.append(st); + auto checkAndFill = [this, &npnts, &frect](int x, int y, short c) { + if (!frect.contains(x, y)) return; + short p = field[x][y]; + if (p == (short)Empty || p == (short)Jump) { + npnts.append(QPoint(x, y)); + fill(x, y, c); + } + if (p == (short)Jump) { + jumps.append(QPoint(x, y)); + } + }; + if (field[fn.x()][fn.y()] < (short)Empty) return false; while (cpnts.size() > 0) { npnts.clear(); @@ -65,34 +81,14 @@ bool BlockViewWavetrace::trace(const QPoint & start, const QPoint & finish) { } cx = cpnts[i].x() - 1; cy = cpnts[i].y(); - if (frect.contains(cx, cy)) { - if (field[cx][cy] == empty) { - npnts.push_back(QPoint(cx, cy)); - fill(cx, cy, cl); - } - } + checkAndFill(cx, cy, cl); cx = cpnts[i].x() + 1; - if (frect.contains(cx, cy)) { - if (field[cx][cy] == empty) { - npnts.push_back(QPoint(cx, cy)); - fill(cx, cy, cl); - } - } + checkAndFill(cx, cy, cl); cx = cpnts[i].x(); cy = cpnts[i].y() - 1; - if (frect.contains(cx, cy)) { - if (field[cx][cy] == empty) { - npnts.push_back(QPoint(cx, cy)); - fill(cx, cy, cl); - } - } + checkAndFill(cx, cy, cl); cy = cpnts[i].y() + 1; - if (frect.contains(cx, cy)) { - if (field[cx][cy] == empty) { - npnts.push_back(QPoint(cx, cy)); - fill(cx, cy, cl); - } - } + checkAndFill(cx, cy, cl); } cpnts = npnts; //qDebug() << cl << ": " << cpnts.size(); @@ -108,68 +104,48 @@ void BlockViewWavetrace::gatherPath() { path_.push_front(st); return; } - int cx, cy; int pa = -1, ca = -1; bool first = true; short cl = field[fn.x()][fn.y()]; QRect frect(0, 0, wid, hei); QPoint cpnt = fn; //cout << "start from " << cl << endl; + auto checkAndStep = [this, &cpnt, &first, &frect] (int & dir, short c, int & ca_, int pa_)->bool { + int cx = cpnt.x() + dps[dir].x(); + int cy = cpnt.y() + dps[dir].y(); + dir++; + if (frect.contains(cx, cy)) { + if (field[cx][cy] == c) { + if (jumps.contains(QPoint(cx, cy))) { + int jx = cx - 1; + int jy = cy; + if (jumps.contains(QPoint(jx, jy))) fill(jx, jy, (short)Jump); + jx = cx + 1; + if (jumps.contains(QPoint(jx, jy))) fill(jx, jy, (short)Jump); + jx = cx; + jy = cy - 1; + if (jumps.contains(QPoint(jx, jy))) fill(jx, jy, (short)Jump); + jy = cy + 1; + if (jumps.contains(QPoint(jx, jy))) fill(jx, jy, (short)Jump); + } + ca_ = QLineF(QPointF(cx, cy), cpnt).angle(); + if (ca_ != pa_ && !first) + path_.push_front(cpnt); + cpnt = QPoint(cx, cy); + first = false; + return true; + } + } + return false; + }; while (cl > 0) { cl--; pa = ca; int dir = 0; - cx = cpnt.x() + dps[dir].x(); - cy = cpnt.y() + dps[dir].y(); - dir++; - if (frect.contains(cx, cy)) { - if (field[cx][cy] == cl) { - ca = QLineF(QPointF(cx, cy), cpnt).angle(); - if (ca != pa && !first) - path_.push_front(cpnt); - cpnt = QPoint(cx, cy); - first = false; - continue; - } - } - cx = cpnt.x() + dps[dir].x(); - cy = cpnt.y() + dps[dir].y(); - dir++; - if (frect.contains(cx, cy)) { - if (field[cx][cy] == cl) { - ca = QLineF(QPointF(cx, cy), cpnt).angle(); - if (ca != pa && !first) - path_.push_front(cpnt); - cpnt = QPoint(cx, cy); - first = false; - continue; - } - } - cx = cpnt.x() + dps[dir].x(); - cy = cpnt.y() + dps[dir].y(); - dir++; - if (frect.contains(cx, cy)) { - if (field[cx][cy] == cl) { - ca = QLineF(QPointF(cx, cy), cpnt).angle(); - if (ca != pa && !first) - path_.push_front(cpnt); - cpnt = QPoint(cx, cy); - first = false; - continue; - } - } - cx = cpnt.x() + dps[dir].x(); - cy = cpnt.y() + dps[dir].y(); - if (frect.contains(cx, cy)) { - if (field[cx][cy] == cl) { - ca = QLineF(QPointF(cx, cy), cpnt).angle(); - if (ca != pa && !first) - path_.push_front(cpnt); - cpnt = QPoint(cx, cy); - first = false; - continue; - } - } + if (checkAndStep(dir, cl, ca, pa)) continue; + if (checkAndStep(dir, cl, ca, pa)) continue; + if (checkAndStep(dir, cl, ca, pa)) continue; + if (checkAndStep(dir, cl, ca, pa)) continue; } path_.push_front(st); //cout << path_.size() << endl; @@ -178,13 +154,13 @@ void BlockViewWavetrace::gatherPath() { void BlockViewWavetrace::setPreferredDirection(BlockViewWavetrace::Direction dir) { dir_ = dir; - if (dir == BlockViewWavetrace::Horizontal) { + if (dir == Horizontal) { dps[0] = QPoint(0, -1); dps[1] = QPoint(0, 1); dps[2] = QPoint(-1, 0); dps[3] = QPoint(1, 0); } - if (dir == BlockViewWavetrace::Vertical) { + if (dir == Vertical) { dps[2] = QPoint(0, -1); dps[3] = QPoint(0, 1); dps[0] = QPoint(-1, 0); diff --git a/qad/blockview/blockviewwavetrace.h b/qad/blockview/blockviewwavetrace.h index 3435ba4..f95a8c7 100644 --- a/qad/blockview/blockviewwavetrace.h +++ b/qad/blockview/blockviewwavetrace.h @@ -27,7 +27,7 @@ class QAD_EXPORT BlockViewWavetrace { public: BlockViewWavetrace(int width = 1, int height = 1); - enum CellState {Empty = -1, Blocked = -2}; + enum CellState {Empty = -1, Blocked = -2, Jump = -3}; enum Direction {NoTrace, Horizontal, Vertical}; int width() const {return wid;} @@ -37,7 +37,7 @@ public: void fill(short val = -1); void fill(const QRect & rect, short val = -1); void fill(const QPoint & point, short val = -1) {field[point.x()][point.y()] = val;} - void fill(int px, int py, short val = -1) {field[px][py] = val;} + void fill(int px, int py, short val); void fill(BlockViewWavetrace::CellState val = Empty) {fill((short)val);} void fill(const QRect & rect, BlockViewWavetrace::CellState val = Empty) {fill(rect, (short)val);} void fill(const QPoint & point, BlockViewWavetrace::CellState val = Empty) {fill(point, (short)val);} @@ -56,6 +56,7 @@ private: Direction dir_; QVector > field; QVector path_; + QVector jumps; QPoint dps[4], st, fn; }; diff --git a/qad/blockview/lang/qad_blockview_en.ts b/qad/blockview/lang/qad_blockview_en.ts index a8abcb3..62674b5 100644 --- a/qad/blockview/lang/qad_blockview_en.ts +++ b/qad/blockview/lang/qad_blockview_en.ts @@ -4,11 +4,12 @@ BlockBusItem - + Add point: Ctrl + LeftClick Remove point\segment: Ctrl + RightClick -New branch: Shift + LeftClick -Remove connection: Shift + RightClick +Remove connection: Shift + RightClick +Move point\segment: Shift + LeftPress +Change trace mode: press Shift, when mouse move @@ -347,7 +348,7 @@ Image - + Select image diff --git a/qad/blockview/lang/qad_blockview_ru.ts b/qad/blockview/lang/qad_blockview_ru.ts index 9a7ecdc..2772d81 100644 --- a/qad/blockview/lang/qad_blockview_ru.ts +++ b/qad/blockview/lang/qad_blockview_ru.ts @@ -4,16 +4,39 @@ BlockBusItem - Add point: Ctrl + LeftClick Remove point\segment: Ctrl + RightClick New branch: Shift + LeftClick Remove connection: Shift + RightClick - Добавить точку: Ctrl + LeftClick + Добавить точку: Ctrl + LeftClick Удалить точку\сегмент: Ctrl + RightClick Новая ветка: Shift + LeftClick Удалить шину: Shift + RightClick + + Add point: Ctrl + LeftClick +Remove point\segment: Ctrl + RightClick +Remove connection: Shift + RightClick +Move point\segment: Shift + mouse move +Change trace mode: press Shift, when mouse move + Добавить точку: Ctrl + LeftClick +Удалить точку\сегмент: Ctrl + RightClick +Удалить шину: Shift + RightClick +Переместить точку\сегмент: Shift + двига + + + + Add point: Ctrl + LeftClick +Remove point\segment: Ctrl + RightClick +Remove connection: Shift + RightClick +Move point\segment: Shift + LeftPress +Change trace mode: press Shift, when mouse move + Добавить точку: Ctrl + LeftClick +Удалить точку\сегмент: Ctrl + RightClick +Удалить шину: Shift + RightClick +Переместить точку\сегмент: Shift + LeftPress +Поменять режим трассировки: нажать Shift, во время перемещения мыши + BlockEditor @@ -363,7 +386,7 @@ Image картинку - + Select image Выбрать картинку