new BlockView::newBusFinished
This commit is contained in:
@@ -172,8 +172,8 @@ QVector<BlockItemPin *> BlockItem::pins() const {
|
||||
return ret;
|
||||
}
|
||||
|
||||
QVector<BlockItemPin *> BlockItem::pinsOnSide(Qt::Alignment al) const
|
||||
{
|
||||
|
||||
QVector<BlockItemPin *> BlockItem::pinsOnSide(Qt::Alignment al) const {
|
||||
return pins_.value(al);
|
||||
}
|
||||
|
||||
|
||||
@@ -36,6 +36,48 @@ BlockItemPin::BlockItemPin(Qt::Alignment a, int bus_type_, const QString & text_
|
||||
}
|
||||
|
||||
|
||||
void BlockItemPin::setPen(const QPen & p) {
|
||||
ell_item.setPen(p);
|
||||
}
|
||||
|
||||
|
||||
QPen BlockItemPin::pen() const {
|
||||
return ell_item.pen();
|
||||
}
|
||||
|
||||
|
||||
void BlockItemPin::setBrush(const QBrush & b) {
|
||||
ell_item.setBrush(b);
|
||||
}
|
||||
|
||||
|
||||
QBrush BlockItemPin::brush() const {
|
||||
return ell_item.brush();
|
||||
}
|
||||
|
||||
|
||||
QString BlockItemPin::text() const {
|
||||
return text_item.text();
|
||||
}
|
||||
|
||||
|
||||
void BlockItemPin::setBusType(int type_) {
|
||||
bus_type = type_;
|
||||
}
|
||||
|
||||
|
||||
void BlockItemPin::setAlignment(Qt::Alignment a) {
|
||||
align = a;
|
||||
_init(true);
|
||||
}
|
||||
|
||||
|
||||
void BlockItemPin::setText(const QString & t) {
|
||||
text_item.setText(t);
|
||||
_init(true);
|
||||
}
|
||||
|
||||
|
||||
void BlockItemPin::animAccept() {
|
||||
if (!((BlockView *)scene()->views().back())->isBlockAnimationEnabled() && anim_accept.state() != QAbstractAnimation::Running) return;
|
||||
anim_accept.setStartValue(pinSize());
|
||||
@@ -44,6 +86,11 @@ void BlockItemPin::animAccept() {
|
||||
}
|
||||
|
||||
|
||||
QRectF BlockItemPin::boundingRect() const {
|
||||
return ell_item.boundingRect().translated(ell_item.pos()) | text_item.boundingRect().translated(text_item.pos());
|
||||
}
|
||||
|
||||
|
||||
void BlockItemPin::setState(State s) {
|
||||
State os = state_;
|
||||
state_ = s;
|
||||
@@ -55,6 +102,23 @@ void BlockItemPin::setState(State s) {
|
||||
}
|
||||
|
||||
|
||||
void BlockItemPin::saveState() {
|
||||
sstate_.push(state_);
|
||||
}
|
||||
|
||||
|
||||
bool BlockItemPin::restoreState() {
|
||||
if (sstate_.isEmpty()) return false;
|
||||
setState(sstate_.pop());
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
void BlockItemPin::clearStateStack() {
|
||||
sstate_.clear();
|
||||
}
|
||||
|
||||
|
||||
void BlockItemPin::enlargePin(bool enlarge) {
|
||||
double sz = enlarge ? 12. : 7;
|
||||
if (anim_accept.state() == QAbstractAnimation::Running && enlarge) {
|
||||
|
||||
@@ -67,59 +67,49 @@ public:
|
||||
InputOutput = 0x3
|
||||
};
|
||||
|
||||
void setPen(const QPen & p) { ell_item.setPen(p); }
|
||||
QPen pen() const { return ell_item.pen(); }
|
||||
void setBrush(const QBrush & b) { ell_item.setBrush(b); }
|
||||
QBrush brush() const { return ell_item.brush(); }
|
||||
|
||||
int busType() const { return bus_type; }
|
||||
Qt::Alignment alignment() const { return align; }
|
||||
QString text() const { return text_item.text(); }
|
||||
State state() const { return state_; }
|
||||
|
||||
void setBusType(int type_) { bus_type = type_; }
|
||||
void setAlignment(Qt::Alignment a) {
|
||||
align = a;
|
||||
_init(true);
|
||||
}
|
||||
void setText(const QString & t) {
|
||||
text_item.setText(t);
|
||||
_init(true);
|
||||
}
|
||||
void setState(State s);
|
||||
|
||||
void saveState() { sstate_.push(state_); }
|
||||
bool restoreState() {
|
||||
if (sstate_.isEmpty()) return false;
|
||||
setState(sstate_.pop());
|
||||
return true;
|
||||
}
|
||||
void clearStateStack() { sstate_.clear(); }
|
||||
|
||||
void enlargePin(bool enlarge);
|
||||
|
||||
BlockItem * parent() const { return parent_; }
|
||||
QList<BlockBusItem *> connectedBuses() const { return buses_; }
|
||||
|
||||
enum {
|
||||
Type = UserType + 3
|
||||
};
|
||||
|
||||
void setPen(const QPen & p);
|
||||
QPen pen() const;
|
||||
void setBrush(const QBrush & b);
|
||||
QBrush brush() const;
|
||||
|
||||
int busType() const { return bus_type; }
|
||||
Qt::Alignment alignment() const { return align; }
|
||||
QString text() const;
|
||||
State state() const { return state_; }
|
||||
|
||||
void setBusType(int type_);
|
||||
void setAlignment(Qt::Alignment a);
|
||||
void setText(const QString & t);
|
||||
void setState(State s);
|
||||
|
||||
void saveState();
|
||||
bool restoreState();
|
||||
void clearStateStack();
|
||||
|
||||
void enlargePin(bool enlarge);
|
||||
|
||||
|
||||
BlockItem * parent() const { return parent_; }
|
||||
QList<BlockBusItem *> connectedBuses() const { return buses_; }
|
||||
|
||||
public slots:
|
||||
void animAccept();
|
||||
|
||||
protected:
|
||||
void paint(QPainter * painter, const QStyleOptionGraphicsItem * option, QWidget * widget = 0) {}
|
||||
QRectF boundingRect() const {
|
||||
return ell_item.boundingRect().translated(ell_item.pos()) | text_item.boundingRect().translated(text_item.pos());
|
||||
}
|
||||
int type() const { return Type; }
|
||||
QVariant itemChange(GraphicsItemChange change, const QVariant & value);
|
||||
void hoverEnterEvent(QGraphicsSceneHoverEvent * e);
|
||||
void hoverLeaveEvent(QGraphicsSceneHoverEvent * e);
|
||||
void paint(QPainter *, const QStyleOptionGraphicsItem *, QWidget *) override {}
|
||||
QRectF boundingRect() const override;
|
||||
int type() const override { return Type; }
|
||||
QVariant itemChange(GraphicsItemChange change, const QVariant & value) override;
|
||||
void hoverEnterEvent(QGraphicsSceneHoverEvent * e) override;
|
||||
void hoverLeaveEvent(QGraphicsSceneHoverEvent * e) override;
|
||||
void _init(bool affect_parent = false);
|
||||
void _reparent();
|
||||
QGraphicsView * _view() const;
|
||||
|
||||
int bus_type;
|
||||
State state_;
|
||||
QGraphicsEllipseItem ell_item;
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -172,6 +172,8 @@ protected:
|
||||
void emitActionEvent(BlockItemBase::Action action, QList<QGraphicsItem *> items);
|
||||
void setGhost(BlockItem * item);
|
||||
void clearGhost();
|
||||
void startNewBus(int bus_type);
|
||||
void maybeEndNewBus();
|
||||
BlockItem * ghost() const { return ghost_; }
|
||||
|
||||
virtual void loadBus(BlockBusItem * bus) {}
|
||||
@@ -179,6 +181,7 @@ protected:
|
||||
virtual void copyBuses(QList<BlockBusItem *> items, QPointF offset) {}
|
||||
virtual void newBusStarted(int bus_type) {}
|
||||
virtual void newBusCreated(BlockBusItem * bus) {}
|
||||
virtual void newBusFinished() {}
|
||||
|
||||
QGraphicsScene * scene_;
|
||||
QGraphicsRectItem sel_rect;
|
||||
@@ -206,7 +209,7 @@ protected:
|
||||
bool mm_drag, new_bus, new_branch, moved, mm_cancel, iconnect, mm_copy, mm_thumb, ae_enabled, is_nav_anim, is_block_anim,
|
||||
move_bus_point;
|
||||
bool grid_visible, grid_snap, pm_connect, navigation, m_connect, m_trace_with_buses, m_pin_mc, minimap, prev_tcb, wheel_zoom;
|
||||
bool nav_prev_aa, nav_prev_imaa, nav_prev_grid, square_node, block_emit_selection;
|
||||
bool nav_prev_aa, nav_prev_imaa, nav_prev_grid, square_node, block_emit_selection, new_bus_started;
|
||||
double grid_step, grid_points, cur_scl, _talpha, thumb_scl;
|
||||
double prev_app_scale;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user