new BlockView::newBusFinished
This commit is contained in:
@@ -172,8 +172,8 @@ QVector<BlockItemPin *> BlockItem::pins() const {
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
QVector<BlockItemPin *> BlockItem::pinsOnSide(Qt::Alignment al) const
|
|
||||||
{
|
QVector<BlockItemPin *> BlockItem::pinsOnSide(Qt::Alignment al) const {
|
||||||
return pins_.value(al);
|
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() {
|
void BlockItemPin::animAccept() {
|
||||||
if (!((BlockView *)scene()->views().back())->isBlockAnimationEnabled() && anim_accept.state() != QAbstractAnimation::Running) return;
|
if (!((BlockView *)scene()->views().back())->isBlockAnimationEnabled() && anim_accept.state() != QAbstractAnimation::Running) return;
|
||||||
anim_accept.setStartValue(pinSize());
|
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) {
|
void BlockItemPin::setState(State s) {
|
||||||
State os = state_;
|
State os = state_;
|
||||||
state_ = s;
|
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) {
|
void BlockItemPin::enlargePin(bool enlarge) {
|
||||||
double sz = enlarge ? 12. : 7;
|
double sz = enlarge ? 12. : 7;
|
||||||
if (anim_accept.state() == QAbstractAnimation::Running && enlarge) {
|
if (anim_accept.state() == QAbstractAnimation::Running && enlarge) {
|
||||||
|
|||||||
@@ -67,59 +67,49 @@ public:
|
|||||||
InputOutput = 0x3
|
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 {
|
enum {
|
||||||
Type = UserType + 3
|
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:
|
public slots:
|
||||||
void animAccept();
|
void animAccept();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void paint(QPainter * painter, const QStyleOptionGraphicsItem * option, QWidget * widget = 0) {}
|
void paint(QPainter *, const QStyleOptionGraphicsItem *, QWidget *) override {}
|
||||||
QRectF boundingRect() const {
|
QRectF boundingRect() const override;
|
||||||
return ell_item.boundingRect().translated(ell_item.pos()) | text_item.boundingRect().translated(text_item.pos());
|
int type() const override { return Type; }
|
||||||
}
|
QVariant itemChange(GraphicsItemChange change, const QVariant & value) override;
|
||||||
int type() const { return Type; }
|
void hoverEnterEvent(QGraphicsSceneHoverEvent * e) override;
|
||||||
QVariant itemChange(GraphicsItemChange change, const QVariant & value);
|
void hoverLeaveEvent(QGraphicsSceneHoverEvent * e) override;
|
||||||
void hoverEnterEvent(QGraphicsSceneHoverEvent * e);
|
|
||||||
void hoverLeaveEvent(QGraphicsSceneHoverEvent * e);
|
|
||||||
void _init(bool affect_parent = false);
|
void _init(bool affect_parent = false);
|
||||||
void _reparent();
|
void _reparent();
|
||||||
QGraphicsView * _view() const;
|
QGraphicsView * _view() const;
|
||||||
|
|
||||||
int bus_type;
|
int bus_type;
|
||||||
State state_;
|
State state_;
|
||||||
QGraphicsEllipseItem ell_item;
|
QGraphicsEllipseItem ell_item;
|
||||||
|
|||||||
@@ -50,8 +50,8 @@ void BlockView::_init() {
|
|||||||
_talpha = 0.;
|
_talpha = 0.;
|
||||||
ae_enabled = is_block_anim = is_nav_anim = true;
|
ae_enabled = is_block_anim = is_nav_anim = true;
|
||||||
nav_prev_aa = nav_prev_imaa = nav_prev_grid = true;
|
nav_prev_aa = nav_prev_imaa = nav_prev_grid = true;
|
||||||
square_node = block_emit_selection = false;
|
square_node = block_emit_selection = new_bus_started = false;
|
||||||
thumb_size = QSizeF(200, 200);
|
thumb_size = QSizeF(200, 200);
|
||||||
if (scene() == 0) {
|
if (scene() == 0) {
|
||||||
scene_ = new QGraphicsScene;
|
scene_ = new QGraphicsScene;
|
||||||
setScene(scene_);
|
setScene(scene_);
|
||||||
@@ -308,8 +308,7 @@ bool BlockView::eventFilter(QObject * o, QEvent * e) {
|
|||||||
}
|
}
|
||||||
// qDebug() << "new" << ;
|
// qDebug() << "new" << ;
|
||||||
prev_tcb = m_trace_with_buses;
|
prev_tcb = m_trace_with_buses;
|
||||||
newBusStarted(tmp_bus.busType());
|
startNewBus(tmp_bus.busType());
|
||||||
markPins(tmp_bus.busType());
|
|
||||||
if (qgraphicsitem_cast<BlockItemPin *>(mm_ci)->alignment() == Qt::AlignLeft ||
|
if (qgraphicsitem_cast<BlockItemPin *>(mm_ci)->alignment() == Qt::AlignLeft ||
|
||||||
qgraphicsitem_cast<BlockItemPin *>(mm_ci)->alignment() == Qt::AlignRight)
|
qgraphicsitem_cast<BlockItemPin *>(mm_ci)->alignment() == Qt::AlignRight)
|
||||||
wavetrace.setPreferredDirection(BlockViewWavetrace::Horizontal);
|
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::LeftButton)) btncnt++;
|
||||||
if (me->buttons().testFlag(Qt::RightButton)) btncnt++;
|
if (me->buttons().testFlag(Qt::RightButton)) btncnt++;
|
||||||
if (me->buttons().testFlag(QT_MID_BUTTON)) btncnt++;
|
if (me->buttons().testFlag(QT_MID_BUTTON)) btncnt++;
|
||||||
|
maybeEndNewBus();
|
||||||
cur_bus = 0;
|
cur_bus = 0;
|
||||||
mm_cancel = btncnt > 0;
|
mm_cancel = btncnt > 0;
|
||||||
if (mm_cancel || (me->button() == QT_MID_BUTTON) || (me->button() == Qt::RightButton)) {
|
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) {
|
void BlockView::getPinMC(bool * v) {
|
||||||
if (v) *v = m_pin_mc;
|
if (v) *v = m_pin_mc;
|
||||||
}
|
}
|
||||||
@@ -1665,8 +1682,7 @@ void BlockView::adjustThumb() {
|
|||||||
void BlockView::newBranch(BlockBusItem * item) {
|
void BlockView::newBranch(BlockBusItem * item) {
|
||||||
bus_from = item;
|
bus_from = item;
|
||||||
prev_tcb = m_trace_with_buses;
|
prev_tcb = m_trace_with_buses;
|
||||||
newBusStarted(item->busType());
|
startNewBus(item->busType());
|
||||||
markPins(item->busType());
|
|
||||||
new_branch = true;
|
new_branch = true;
|
||||||
tmp_bus.setBusType(item->busType());
|
tmp_bus.setBusType(item->busType());
|
||||||
if (item->selSegment >= 0) {
|
if (item->selSegment >= 0) {
|
||||||
@@ -1680,8 +1696,7 @@ void BlockView::newBranch(BlockBusItem * item) {
|
|||||||
void BlockView::startBusPointMove(int bus_type) {
|
void BlockView::startBusPointMove(int bus_type) {
|
||||||
move_bus_point = true;
|
move_bus_point = true;
|
||||||
prev_tcb = m_trace_with_buses;
|
prev_tcb = m_trace_with_buses;
|
||||||
newBusStarted(bus_type);
|
startNewBus(bus_type);
|
||||||
markPins(bus_type);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -172,6 +172,8 @@ protected:
|
|||||||
void emitActionEvent(BlockItemBase::Action action, QList<QGraphicsItem *> items);
|
void emitActionEvent(BlockItemBase::Action action, QList<QGraphicsItem *> items);
|
||||||
void setGhost(BlockItem * item);
|
void setGhost(BlockItem * item);
|
||||||
void clearGhost();
|
void clearGhost();
|
||||||
|
void startNewBus(int bus_type);
|
||||||
|
void maybeEndNewBus();
|
||||||
BlockItem * ghost() const { return ghost_; }
|
BlockItem * ghost() const { return ghost_; }
|
||||||
|
|
||||||
virtual void loadBus(BlockBusItem * bus) {}
|
virtual void loadBus(BlockBusItem * bus) {}
|
||||||
@@ -179,6 +181,7 @@ protected:
|
|||||||
virtual void copyBuses(QList<BlockBusItem *> items, QPointF offset) {}
|
virtual void copyBuses(QList<BlockBusItem *> items, QPointF offset) {}
|
||||||
virtual void newBusStarted(int bus_type) {}
|
virtual void newBusStarted(int bus_type) {}
|
||||||
virtual void newBusCreated(BlockBusItem * bus) {}
|
virtual void newBusCreated(BlockBusItem * bus) {}
|
||||||
|
virtual void newBusFinished() {}
|
||||||
|
|
||||||
QGraphicsScene * scene_;
|
QGraphicsScene * scene_;
|
||||||
QGraphicsRectItem sel_rect;
|
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,
|
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;
|
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 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 grid_step, grid_points, cur_scl, _talpha, thumb_scl;
|
||||||
double prev_app_scale;
|
double prev_app_scale;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user