animation in blockview 2
git-svn-id: svn://db.shs.com.ru/libs@317 a8b55f48-bf90-11e4-a774-851b48703e85
This commit is contained in:
@@ -495,8 +495,10 @@ void BlockBusItem::hoverMoveEvent(QGraphicsSceneHoverEvent * e) {
|
|||||||
if (temp_) return;
|
if (temp_) return;
|
||||||
QPointF sp = e->scenePos();
|
QPointF sp = e->scenePos();
|
||||||
int pp = selPoint;
|
int pp = selPoint;
|
||||||
|
int ps = selSegment;
|
||||||
|
bool empt = !(selPoint >= 0 || selSegment >= 0);
|
||||||
testPoint(sp, &selPoint, &selSegment);
|
testPoint(sp, &selPoint, &selSegment);
|
||||||
if (selPoint >= 0 && pp < 0) {
|
if ((selPoint >= 0 && pp != selPoint) || (selSegment >= 0 && ps != selSegment)) {
|
||||||
if (((BlockView *)scene()->views().back())->isBlockAnimationEnabled()) {
|
if (((BlockView *)scene()->views().back())->isBlockAnimationEnabled()) {
|
||||||
setPointSize(0);
|
setPointSize(0);
|
||||||
anim_point_size.start();
|
anim_point_size.start();
|
||||||
@@ -504,6 +506,12 @@ void BlockBusItem::hoverMoveEvent(QGraphicsSceneHoverEvent * e) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (selPoint >= 0 || selSegment >= 0) {
|
if (selPoint >= 0 || selSegment >= 0) {
|
||||||
|
if (empt) {
|
||||||
|
QList<BlockItemPin * > pins = connectedPins();
|
||||||
|
foreach (BlockItemPin * p, pins) {
|
||||||
|
p->animAccept();
|
||||||
|
}
|
||||||
|
}
|
||||||
setToolTip(tt);
|
setToolTip(tt);
|
||||||
update();
|
update();
|
||||||
return;
|
return;
|
||||||
@@ -674,20 +682,20 @@ void BlockBusItem::mouseReleaseEvent(QGraphicsSceneMouseEvent * e) {
|
|||||||
if (moved) {
|
if (moved) {
|
||||||
simplify(false);
|
simplify(false);
|
||||||
if (lm_point) {
|
if (lm_point) {
|
||||||
QMetaObject::invokeMethod(scene()->views().back(), "endBusPointMove", Qt::QueuedConnection);
|
|
||||||
emitAction(BlockItemBase::BusPointMove);
|
emitAction(BlockItemBase::BusPointMove);
|
||||||
} else {
|
} else {
|
||||||
reconnect();
|
reconnect();
|
||||||
emitAction( BlockItemBase::BusSegmentMove);
|
emitAction( BlockItemBase::BusSegmentMove);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
QMetaObject::invokeMethod(scene()->views().back(), "endBusPointMove");
|
||||||
moved = new_segment = false;
|
moved = new_segment = false;
|
||||||
QGraphicsObject::mouseReleaseEvent(e);
|
QGraphicsObject::mouseReleaseEvent(e);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void BlockBusItem::paint(QPainter * p, const QStyleOptionGraphicsItem * o, QWidget * w) {
|
void BlockBusItem::paint(QPainter * p, const QStyleOptionGraphicsItem * o, QWidget * w) {
|
||||||
ph.setWidthF(pen_width + 1.);
|
ph.setWidthF(pen_width + point_size / 2.);
|
||||||
pu.setWidthF(pen_width);
|
pu.setWidthF(pen_width);
|
||||||
pa.setWidthF(pen_width);
|
pa.setWidthF(pen_width);
|
||||||
pr.setWidthF(pen_width);
|
pr.setWidthF(pen_width);
|
||||||
|
|||||||
@@ -21,7 +21,7 @@ BlockItemPin::BlockItemPin(Qt::Alignment a, int bus_type_, const QString & text_
|
|||||||
anim_accept.setTargetObject(this);
|
anim_accept.setTargetObject(this);
|
||||||
anim_accept.setPropertyName("pinSize");
|
anim_accept.setPropertyName("pinSize");
|
||||||
anim_accept.setEasingCurve(QEasingCurve::InOutQuad);
|
anim_accept.setEasingCurve(QEasingCurve::InOutQuad);
|
||||||
anim_accept.setDuration(200);
|
anim_accept.setDuration(150);
|
||||||
connect(&anim_accept, SIGNAL(finished()), this, SLOT(animationAccept()));
|
connect(&anim_accept, SIGNAL(finished()), this, SLOT(animationAccept()));
|
||||||
setState(Disconnected);
|
setState(Disconnected);
|
||||||
setAlignment(a);
|
setAlignment(a);
|
||||||
@@ -33,14 +33,20 @@ BlockItemPin::BlockItemPin(Qt::Alignment a, int bus_type_, const QString & text_
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void BlockItemPin::animAccept() {
|
||||||
|
if (!((BlockView *)scene()->views().back())->isBlockAnimationEnabled() && anim_accept.state() != QAbstractAnimation::Running) return;
|
||||||
|
anim_accept.setStartValue(pinSize());
|
||||||
|
anim_accept.setEndValue(10.);
|
||||||
|
anim_accept.start();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void BlockItemPin::setState(State s) {
|
void BlockItemPin::setState(State s) {
|
||||||
State os = state_;
|
State os = state_;
|
||||||
state_ = s;
|
state_ = s;
|
||||||
setBrush(br[int(state_)]);
|
setBrush(br[int(state_)]);
|
||||||
if (s == Accept && os != Accept && anim_accept.state() != QAbstractAnimation::Running && ((BlockView *)scene()->views().back())->isBlockAnimationEnabled()) {
|
if (s == Accept && os != Accept) {
|
||||||
anim_accept.setStartValue(pinSize());
|
animAccept();
|
||||||
anim_accept.setEndValue(10.);
|
|
||||||
anim_accept.start();
|
|
||||||
}
|
}
|
||||||
update();
|
update();
|
||||||
}
|
}
|
||||||
@@ -93,10 +99,10 @@ void BlockItemPin::_init(bool affect_parent) {
|
|||||||
text_item.setPos(0, -tbr.height() / 2.);
|
text_item.setPos(0, -tbr.height() / 2.);
|
||||||
text_item.setTransformOriginPoint(0, tbr.height() / 2.);
|
text_item.setTransformOriginPoint(0, tbr.height() / 2.);
|
||||||
switch (align) {
|
switch (align) {
|
||||||
case Qt::AlignBottom: ell_item.setStartAngle(16*0); text_item.setRotation(-90.); text_item.moveBy(0, -r * 1.5); break;
|
case Qt::AlignBottom: ell_item.setStartAngle(16*0); text_item.setRotation(-90.); text_item.moveBy(0, -r * 1.5); break;
|
||||||
case Qt::AlignRight: ell_item.setStartAngle(16*90); text_item.setRotation(0.); text_item.moveBy(-tbr.width() - r * 1.5, 0); break;
|
case Qt::AlignRight: ell_item.setStartAngle(16*90); text_item.setRotation(0.); text_item.moveBy(-tbr.width() - r * 1.5, 0); break;
|
||||||
case Qt::AlignTop: ell_item.setStartAngle(16*180); text_item.setRotation(-90.); text_item.moveBy(0, tbr.width() + r * 1.5); break;
|
case Qt::AlignTop: ell_item.setStartAngle(16*180); text_item.setRotation(-90.); text_item.moveBy(0, tbr.width() + r * 1.5); break;
|
||||||
case Qt::AlignLeft: ell_item.setStartAngle(16*270); text_item.setRotation(0.); text_item.moveBy(r * 1.5, 0); break;
|
case Qt::AlignLeft: ell_item.setStartAngle(16*270); text_item.setRotation(0.); text_item.moveBy(r * 1.5, 0); break;
|
||||||
default: break;
|
default: break;
|
||||||
}
|
}
|
||||||
if (affect_parent && parent_)
|
if (affect_parent && parent_)
|
||||||
|
|||||||
@@ -73,6 +73,9 @@ public:
|
|||||||
|
|
||||||
enum {Type = UserType + 3};
|
enum {Type = UserType + 3};
|
||||||
|
|
||||||
|
public slots:
|
||||||
|
void animAccept();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void paint(QPainter * painter, const QStyleOptionGraphicsItem * option, QWidget * widget = 0) {}
|
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());}
|
QRectF boundingRect() const {return ell_item.boundingRect().translated(ell_item.pos()) | text_item.boundingRect().translated(text_item.pos());}
|
||||||
|
|||||||
@@ -1168,8 +1168,8 @@ void BlockView::clearBusStates() {
|
|||||||
if (i->data(1005) == "connection") {
|
if (i->data(1005) == "connection") {
|
||||||
BlockBusItem * b = qgraphicsitem_cast<BlockBusItem*>(i);
|
BlockBusItem * b = qgraphicsitem_cast<BlockBusItem*>(i);
|
||||||
b->clearBusState();
|
b->clearBusState();
|
||||||
if (i != bus_from && i != match_bus)
|
// if (i != bus_from && i != match_bus)
|
||||||
b->selPoint = b->selSegment = -1;
|
//b->selPoint = b->selSegment = -1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1285,8 +1285,12 @@ void BlockView::markPins(int bus_type) {
|
|||||||
if (p->busType() == bus_type)
|
if (p->busType() == bus_type)
|
||||||
p->setState(BlockItemPin::Accept);
|
p->setState(BlockItemPin::Accept);
|
||||||
} else {
|
} else {
|
||||||
if (p->busType() == bus_type && p->state() == BlockItemPin::Disconnected)
|
if (p->busType() == bus_type) {
|
||||||
p->setState(BlockItemPin::Accept);
|
if (p->state() == BlockItemPin::Disconnected)
|
||||||
|
p->setState(BlockItemPin::Accept);
|
||||||
|
// else
|
||||||
|
// p->animAccept();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user