code brush
This commit is contained in:
@@ -68,7 +68,7 @@ void BlockBusItem::reconnect() {
|
||||
if (temp_) return;
|
||||
if (!scene()) return;
|
||||
if (scene()->views().isEmpty()) return;
|
||||
QMetaObject::invokeMethod(scene()->views().back(), "reconnectAll");
|
||||
qobject_cast<BlockView*>(scene()->views().back())->reconnectAll();
|
||||
}
|
||||
|
||||
|
||||
@@ -289,7 +289,6 @@ void BlockBusItem::simplify(bool full) {
|
||||
}
|
||||
if (pcnt == pol.size()) return;
|
||||
updateGeometry();
|
||||
//if (scene()) scene()->update();
|
||||
}
|
||||
|
||||
|
||||
@@ -302,7 +301,6 @@ int BlockBusItem::endpointCount() const {
|
||||
}
|
||||
|
||||
|
||||
|
||||
QList<BlockItem * > BlockBusItem::connectedBlocks() const {
|
||||
QList<BlockItemPin * > pins = connections_.values();
|
||||
QSet<BlockItem * > ret;
|
||||
@@ -413,8 +411,8 @@ bool BlockBusItem::checkDelete() {
|
||||
|
||||
|
||||
void BlockBusItem::emitAction(BlockItemBase::Action a) {
|
||||
QMetaObject::invokeMethod(scene()->views().back(), "schemeAction", Q_ARG(BlockItemBase::Action, a), Q_ARG(QList<QGraphicsItem*>, QList<QGraphicsItem*>() << this));
|
||||
QMetaObject::invokeMethod(scene()->views().back(), "connectionsChanged");
|
||||
qobject_cast<BlockView*>(scene()->views().back())->schemeAction(a, QList<QGraphicsItem*>() << this);
|
||||
qobject_cast<BlockView*>(scene()->views().back())->connectionsChanged();
|
||||
}
|
||||
|
||||
|
||||
@@ -438,7 +436,6 @@ QVector<int> BlockBusItem::endpointLine(int ep, double angle) const {
|
||||
int np = segmentPointPair(ep, &seg), pp = np;
|
||||
if (ep < 0 || np < 0) return ret;
|
||||
if (pol[np] == pol[ep]) return ret;
|
||||
//QPointF sp = pol[np] - pol[ep];
|
||||
QLineF l(pol[ep], pol[np]);
|
||||
//qDebug() << "first" << l.angle() << angle << (l.angle() != angle);
|
||||
if (qAbs(l.angle() - angle) > 0.1) return ret;
|
||||
@@ -597,7 +594,7 @@ void BlockBusItem::mousePressEvent(QGraphicsSceneMouseEvent * e) {
|
||||
bv->cur_bus = this;
|
||||
}
|
||||
if (new_segment) {
|
||||
QMetaObject::invokeMethod(scene()->views().back(), "newBranchCancel");
|
||||
qobject_cast<BlockView*>(scene()->views().back())->newBranchCancel();
|
||||
}
|
||||
new_segment = false;
|
||||
if ((selPoint < 0 || selPoint > pol.size() - 1) && (selSegment < 0) && e->modifiers().testFlag(Qt::ShiftModifier)) {
|
||||
@@ -606,8 +603,7 @@ void BlockBusItem::mousePressEvent(QGraphicsSceneMouseEvent * e) {
|
||||
}
|
||||
int btncnt = 0;
|
||||
if ((e->button() == Qt::LeftButton) && e->modifiers().testFlag(Qt::ShiftModifier)) {
|
||||
if (endpoints().contains(selPoint))
|
||||
QMetaObject::invokeMethod(scene()->views().back(), "startBusPointMove", Q_ARG(int, busType()));
|
||||
if (endpoints().contains(selPoint)) qobject_cast<BlockView*>(scene()->views().back())->startBusPointMove(bus_type);
|
||||
}
|
||||
if (e->buttons().testFlag(Qt::LeftButton )) btncnt++;
|
||||
if (e->buttons().testFlag(Qt::RightButton)) btncnt++;
|
||||
@@ -617,16 +613,6 @@ void BlockBusItem::mousePressEvent(QGraphicsSceneMouseEvent * e) {
|
||||
//qDebug() << "bus revert";
|
||||
mm_cancel = true;
|
||||
moved = false;
|
||||
/*QPointF lp = qp - press_pos;
|
||||
//qDebug() << lp;
|
||||
if (selPoint >= 0 && selPoint <= pol.size() - 1) {
|
||||
pol[selPoint] += lp;
|
||||
}
|
||||
if (selSegment >= 0 && selSegment <= segments.size() - 1) {
|
||||
pol[segments[selSegment].first] += lp;
|
||||
pol[segments[selSegment].second] += lp;
|
||||
}
|
||||
moved = true;*/
|
||||
pol = bpol;
|
||||
prepareGeometryChange();
|
||||
return;
|
||||
@@ -645,7 +631,7 @@ void BlockBusItem::mousePressEvent(QGraphicsSceneMouseEvent * e) {
|
||||
if (pointSegmentsCount(selPoint) >= 2 || selSegment >= 0)
|
||||
return;
|
||||
}
|
||||
QMetaObject::invokeMethod(scene()->views().back(), "newBranch", Q_ARG(BlockBusItem * , this));
|
||||
qobject_cast<BlockView*>(scene()->views().back())->newBranch(this);
|
||||
new_segment = true;
|
||||
return;
|
||||
}
|
||||
@@ -694,8 +680,7 @@ void BlockBusItem::mouseMoveEvent(QGraphicsSceneMouseEvent * e) {
|
||||
qp = quantize(e->scenePos(), grid_step);
|
||||
lp = qp - lp;
|
||||
if (e->buttons().testFlag(Qt::LeftButton) && mm_mods.testFlag(Qt::NoModifier) && new_segment) {
|
||||
if (bv)
|
||||
QMetaObject::invokeMethod(bv, "newBranchTrace", Q_ARG(BlockBusItem * , this), Q_ARG(QPointF, e->scenePos()));
|
||||
if (bv) qobject_cast<BlockView*>(scene()->views().back())->newBranchTrace(this, e->scenePos());
|
||||
return;
|
||||
}
|
||||
if (new_segment) {
|
||||
@@ -711,7 +696,6 @@ void BlockBusItem::mouseMoveEvent(QGraphicsSceneMouseEvent * e) {
|
||||
pol[segments[selSegment].second] += lp;
|
||||
}
|
||||
moved = true;
|
||||
//if (bv) bv->bus_moved = true;
|
||||
prepareGeometryChange();
|
||||
}
|
||||
}
|
||||
@@ -727,7 +711,7 @@ void BlockBusItem::mouseReleaseEvent(QGraphicsSceneMouseEvent * e) {
|
||||
if (e->buttons().testFlag(QT_MID_BUTTON )) btncnt++;
|
||||
if (btncnt == 0) mm_cancel = false;
|
||||
if (new_segment) {
|
||||
QMetaObject::invokeMethod(scene()->views().back(), "newBranchAccept", Q_ARG(BlockBusItem * , this));
|
||||
qobject_cast<BlockView*>(scene()->views().back())->newBranchAccept(this);
|
||||
updateGeometry();
|
||||
selPoint = selSegment = -1;
|
||||
}
|
||||
@@ -740,7 +724,6 @@ void BlockBusItem::mouseReleaseEvent(QGraphicsSceneMouseEvent * e) {
|
||||
emitAction( BlockItemBase::BusSegmentMove);
|
||||
}
|
||||
}
|
||||
QMetaObject::invokeMethod(scene()->views().back(), "endBusPointMove");
|
||||
moved = new_segment = false;
|
||||
QGraphicsObject::mouseReleaseEvent(e);
|
||||
}
|
||||
@@ -760,8 +743,6 @@ void BlockBusItem::paint(QPainter * p, const QStyleOptionGraphicsItem * o, QWidg
|
||||
p->setPen(pu);
|
||||
p->setBrush(bu);
|
||||
}
|
||||
//if (mark_in) {p->setPen(pa); p->setBrush(ba);}
|
||||
//if (mark_out) {p->setPen(pr); p->setBrush(br);}
|
||||
if (im_bus.isNull()) {
|
||||
QPen _pen(p->pen());
|
||||
for (int i = 0; i < segments.size(); ++i) {
|
||||
@@ -787,16 +768,10 @@ void BlockBusItem::paint(QPainter * p, const QStyleOptionGraphicsItem * o, QWidg
|
||||
tf.rotate(-QLineF(sp, ep).angle());
|
||||
tf.translate(0., -im_bus.height() / 2. * im_bus_scale);
|
||||
tf.scale(im_bus_scale, im_bus_scale);
|
||||
/*
|
||||
br.setTransform(tf);
|
||||
p->setPen(QPen(br, im_bus.height(), Qt::SolidLine, Qt::FlatCap, Qt::BevelJoin));
|
||||
p->drawLine(sp, ep);
|
||||
*/
|
||||
p->save();
|
||||
p->setTransform(tf, true);
|
||||
p->setPen(Qt::NoPen);
|
||||
p->setBrush(br);
|
||||
//p->drawLine(QPointF(0., 0.), QPointF(QLineF(sp, ep).length(), 0.));
|
||||
p->drawRect(QRectF(0., 0., QLineF(sp, ep).length() / qMax<double>(im_bus_scale, 1E-3), im_bus.height()));
|
||||
p->restore();
|
||||
}
|
||||
@@ -836,8 +811,6 @@ void BlockBusItem::paint(QPainter * p, const QStyleOptionGraphicsItem * o, QWidg
|
||||
p->drawLine(pol[segments[i].first], pol[segments[i].second]);
|
||||
}
|
||||
}
|
||||
//if (mark_in) {p->setPen(pa); p->setBrush(ba);}
|
||||
//if (mark_out) {p->setPen(pr); p->setBrush(br);}
|
||||
if (selPoint >= 0) {
|
||||
p->save();
|
||||
p->setPen(ph);
|
||||
|
||||
Reference in New Issue
Block a user