Blockview changes:
1) Теперь для создания сегмента не надо держать Shift, а перемешение шины теперь с нажатой клавишей Shift 2) Режим трассировки шин теперь пытается проложить маршрут с возможностью пересечения шины под прямым углом 3) Теперь рисуются точки соединения сегментов если их больше 2х 4) Обновлена подсказка в tooltip p.s. update pip)
This commit is contained in:
2
pip
2
pip
Submodule pip updated: dac318c624...8c3349d84a
@@ -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;
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
@@ -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<QPoint> 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);
|
||||
|
||||
@@ -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<QVector<short> > field;
|
||||
QVector<QPoint> path_;
|
||||
QVector<QPoint> jumps;
|
||||
QPoint dps[4], st, fn;
|
||||
|
||||
};
|
||||
|
||||
@@ -4,11 +4,12 @@
|
||||
<context>
|
||||
<name>BlockBusItem</name>
|
||||
<message>
|
||||
<location filename="../blockbusitem.cpp" line="499"/>
|
||||
<location filename="../blockbusitem.cpp" line="500"/>
|
||||
<source>Add point: Ctrl + LeftClick
|
||||
Remove point\segment: Ctrl + RightClick
|
||||
New branch: Shift + LeftClick
|
||||
Remove connection: Shift + RightClick</source>
|
||||
Remove connection: Shift + RightClick
|
||||
Move point\segment: Shift + LeftPress
|
||||
Change trace mode: press Shift, when mouse move</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
</context>
|
||||
@@ -347,7 +348,7 @@ Image</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../drawtools.cpp" line="824"/>
|
||||
<location filename="../drawtools.cpp" line="837"/>
|
||||
<source>Select image</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
|
||||
@@ -4,16 +4,39 @@
|
||||
<context>
|
||||
<name>BlockBusItem</name>
|
||||
<message>
|
||||
<location filename="../blockbusitem.cpp" line="499"/>
|
||||
<source>Add point: Ctrl + LeftClick
|
||||
Remove point\segment: Ctrl + RightClick
|
||||
New branch: Shift + LeftClick
|
||||
Remove connection: Shift + RightClick</source>
|
||||
<translation>Добавить точку: Ctrl + LeftClick
|
||||
<translation type="vanished">Добавить точку: Ctrl + LeftClick
|
||||
Удалить точку\сегмент: Ctrl + RightClick
|
||||
Новая ветка: Shift + LeftClick
|
||||
Удалить шину: Shift + RightClick</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>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</source>
|
||||
<translation type="obsolete">Добавить точку: Ctrl + LeftClick
|
||||
Удалить точку\сегмент: Ctrl + RightClick
|
||||
Удалить шину: Shift + RightClick
|
||||
Переместить точку\сегмент: Shift + двига</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../blockbusitem.cpp" line="500"/>
|
||||
<source>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</source>
|
||||
<translation>Добавить точку: Ctrl + LeftClick
|
||||
Удалить точку\сегмент: Ctrl + RightClick
|
||||
Удалить шину: Shift + RightClick
|
||||
Переместить точку\сегмент: Shift + LeftPress
|
||||
Поменять режим трассировки: нажать Shift, во время перемещения мыши</translation>
|
||||
</message>
|
||||
</context>
|
||||
<context>
|
||||
<name>BlockEditor</name>
|
||||
@@ -363,7 +386,7 @@ Image</source>
|
||||
картинку</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../drawtools.cpp" line="824"/>
|
||||
<location filename="../drawtools.cpp" line="837"/>
|
||||
<source>Select image</source>
|
||||
<translation>Выбрать картинку</translation>
|
||||
</message>
|
||||
|
||||
Reference in New Issue
Block a user