git-svn-id: svn://db.shs.com.ru/libs@176 a8b55f48-bf90-11e4-a774-851b48703e85
This commit is contained in:
@@ -218,7 +218,7 @@ void BlockBusItem::simplify(bool full) {
|
|||||||
else sp[i] = pol[segments[segs[i]].first];
|
else sp[i] = pol[segments[segs[i]].first];
|
||||||
}
|
}
|
||||||
QLineF l0(sp[0], cp), l1(cp, sp[1]);
|
QLineF l0(sp[0], cp), l1(cp, sp[1]);
|
||||||
if (l0.angle() != l1.angle()) continue;
|
if (qAbs(l0.angle() - l1.angle()) > 0.1) continue;
|
||||||
if (segments[s0].first == p) {
|
if (segments[s0].first == p) {
|
||||||
if (segments[s1].first == p) segments[s0].first = segments[s1].second;
|
if (segments[s1].first == p) segments[s0].first = segments[s1].second;
|
||||||
else segments[s0].first = segments[s1].first;
|
else segments[s0].first = segments[s1].first;
|
||||||
@@ -313,6 +313,22 @@ BlockBusItem * BlockBusItem::copy() const {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void BlockBusItem::saveState() {
|
||||||
|
segments_s = segments;
|
||||||
|
ends_ind_s = ends_ind;
|
||||||
|
ends_s = ends;
|
||||||
|
pol_s = pol;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void BlockBusItem::restoreState() {
|
||||||
|
segments = segments_s;
|
||||||
|
ends_ind = ends_ind_s;
|
||||||
|
ends = ends_s;
|
||||||
|
pol = pol_s;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void BlockBusItem::updateGeometry() {
|
void BlockBusItem::updateGeometry() {
|
||||||
ends = endpoints();
|
ends = endpoints();
|
||||||
ends_ind.clear();
|
ends_ind.clear();
|
||||||
@@ -359,21 +375,25 @@ QVector<int> BlockBusItem::endpoints() const {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
QVector<int> BlockBusItem::endpointLine(int ep) const {
|
QVector<int> BlockBusItem::endpointLine(int ep, double angle) const {
|
||||||
QVector<int> ret;
|
QVector<int> ret;
|
||||||
int seg = -1;
|
int seg = -1;
|
||||||
int np = segmentPointPair(ep, &seg), pp = np;
|
int np = segmentPointPair(ep, &seg), pp = np;
|
||||||
if (ep < 0 || np < 0) return ret;
|
if (ep < 0 || np < 0) return ret;
|
||||||
if (pol[np] == pol[ep]) return ret;
|
if (pol[np] == pol[ep]) return ret;
|
||||||
QPointF sp = pol[np] - pol[ep];
|
//QPointF sp = pol[np] - pol[ep];
|
||||||
bool sdir = (qAbs(sp.x()) >= qAbs(sp.y()));
|
QLineF l(pol[ep], pol[np]);
|
||||||
|
//qDebug() << "first" << l.angle() << angle << (l.angle() != angle);
|
||||||
|
if (qAbs(l.angle() - angle) > 0.1) return ret;
|
||||||
|
//qDebug() << "check next" << segments.size();
|
||||||
for (int i = 0; i < segments.size(); ++i) {
|
for (int i = 0; i < segments.size(); ++i) {
|
||||||
|
//qDebug() << i << np << pointSegmentsCount(np);
|
||||||
if (np < 0) break;
|
if (np < 0) break;
|
||||||
if (pointSegmentsCount(np) != 2) break;
|
if (pointSegmentsCount(np) != 2) break;
|
||||||
if (i > 0) {
|
if (i > 0) {
|
||||||
sp = pol[np] - pol[pp];
|
QLineF l(pol[pp], pol[np]);
|
||||||
bool idir = (qAbs(sp.x()) >= qAbs(sp.y()));
|
//qDebug() << i << l.angle() << angle;
|
||||||
if (sdir != idir) break;
|
if (qAbs(l.angle() - angle) > 0.1) break;
|
||||||
}
|
}
|
||||||
ret << np;
|
ret << np;
|
||||||
pp = np;
|
pp = np;
|
||||||
|
|||||||
@@ -62,6 +62,9 @@ public:
|
|||||||
QByteArray save() const;
|
QByteArray save() const;
|
||||||
void load(const QByteArray & data);
|
void load(const QByteArray & data);
|
||||||
BlockBusItem * copy() const;
|
BlockBusItem * copy() const;
|
||||||
|
|
||||||
|
void saveState();
|
||||||
|
void restoreState();
|
||||||
|
|
||||||
enum {Type = UserType + 2};
|
enum {Type = UserType + 2};
|
||||||
|
|
||||||
@@ -72,7 +75,7 @@ protected:
|
|||||||
void checkDelete();
|
void checkDelete();
|
||||||
void emitAction(BlockItemBase::Action a);
|
void emitAction(BlockItemBase::Action a);
|
||||||
QVector<int> endpoints() const;
|
QVector<int> endpoints() const;
|
||||||
QVector<int> endpointLine(int ep) const;
|
QVector<int> endpointLine(int ep, double angle) const;
|
||||||
int pointSegmentsCount(int point, QList<int> * segs = 0) const;
|
int pointSegmentsCount(int point, QList<int> * segs = 0) const;
|
||||||
int neighborSegmentPoint(int point, int * seg) const;
|
int neighborSegmentPoint(int point, int * seg) const;
|
||||||
int type() const {return Type;}
|
int type() const {return Type;}
|
||||||
@@ -90,11 +93,11 @@ protected:
|
|||||||
QPen p_, ph, pu, pa, pr, pn;
|
QPen p_, ph, pu, pa, pr, pn;
|
||||||
QBrush b_, bh, bu, ba, br;
|
QBrush b_, bh, bu, ba, br;
|
||||||
QString tt, bus_name;
|
QString tt, bus_name;
|
||||||
QList<QPair<int, int> > segments, ends_ind;
|
QList<QPair<int, int> > segments, ends_ind, segments_s, ends_ind_s;
|
||||||
QMap<int, BlockItemPin * > connections_;
|
QMap<int, BlockItemPin * > connections_;
|
||||||
QVector<int> ends;
|
QVector<int> ends, ends_s;
|
||||||
QImage im_bus, im_end;
|
QImage im_bus, im_end;
|
||||||
QPolygonF pol, bpol;
|
QPolygonF pol, bpol, pol_s;
|
||||||
Qt::KeyboardModifiers mm_mods;
|
Qt::KeyboardModifiers mm_mods;
|
||||||
bool temp_;
|
bool temp_;
|
||||||
double pen_width, grid_step;
|
double pen_width, grid_step;
|
||||||
|
|||||||
@@ -316,8 +316,10 @@ bool BlockView::eventFilter(QObject * o, QEvent * e) {
|
|||||||
if (mm_cancel) return true;
|
if (mm_cancel) return true;
|
||||||
if (me->buttons().testFlag(Qt::LeftButton)) {
|
if (me->buttons().testFlag(Qt::LeftButton)) {
|
||||||
if (!mm_drag) {
|
if (!mm_drag) {
|
||||||
if ((screen_point - me->screenPos()).manhattanLength() >= QApplication::startDragDistance())
|
if ((screen_point - me->screenPos()).manhattanLength() >= QApplication::startDragDistance()) {
|
||||||
mm_drag = fmm_drag = true;
|
mm_drag = fmm_drag = true;
|
||||||
|
saveBusesState();
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
if (tmp_bus.isVisible()) {
|
if (tmp_bus.isVisible()) {
|
||||||
mil = scene_->items(me->scenePos());
|
mil = scene_->items(me->scenePos());
|
||||||
@@ -956,6 +958,20 @@ void BlockView::saveSelState() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void BlockView::saveBusesState() {
|
||||||
|
QList<BlockBusItem*> bl = buses();
|
||||||
|
foreach (BlockBusItem * b, bl)
|
||||||
|
b->saveState();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void BlockView::restoreBusesState() {
|
||||||
|
QList<BlockBusItem*> bl = buses();
|
||||||
|
foreach (BlockBusItem * b, bl)
|
||||||
|
b->restoreState();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void BlockView::applySelRect(QGraphicsSceneMouseEvent * me) {
|
void BlockView::applySelRect(QGraphicsSceneMouseEvent * me) {
|
||||||
QList<QGraphicsItem*> ci = sel_rect.collidingItems(Qt::IntersectsItemBoundingRect);
|
QList<QGraphicsItem*> ci = sel_rect.collidingItems(Qt::IntersectsItemBoundingRect);
|
||||||
QList<QGraphicsItem*> gi = scene_->items();
|
QList<QGraphicsItem*> gi = scene_->items();
|
||||||
@@ -1218,7 +1234,7 @@ void BlockView::moveBuses(const QList<QGraphicsItem * > & items, QPointF dp) {
|
|||||||
QList<QGraphicsItem * > gi = scene_->items();
|
QList<QGraphicsItem * > gi = scene_->items();
|
||||||
QVector<BlockItemPin * > pins;
|
QVector<BlockItemPin * > pins;
|
||||||
QList<BlockBusItem * > buses;
|
QList<BlockBusItem * > buses;
|
||||||
//qDebug() << "move";
|
//qDebug() << "move" << dp;
|
||||||
foreach (QGraphicsItem * i, items)
|
foreach (QGraphicsItem * i, items)
|
||||||
if (i->data(1006) == "item" && i->flags().testFlag(QGraphicsItem::ItemIsMovable))
|
if (i->data(1006) == "item" && i->flags().testFlag(QGraphicsItem::ItemIsMovable))
|
||||||
pins << qgraphicsitem_cast<BlockItem*>(i)->pins();
|
pins << qgraphicsitem_cast<BlockItem*>(i)->pins();
|
||||||
@@ -1255,9 +1271,15 @@ void BlockView::moveBuses(const QList<QGraphicsItem * > & items, QPointF dp) {
|
|||||||
}
|
}
|
||||||
}*/
|
}*/
|
||||||
QPointF pdp = dp;
|
QPointF pdp = dp;
|
||||||
if (p->alignment() == Qt::AlignTop || p->alignment() == Qt::AlignBottom) pdp.setY(0.);
|
double ang = 0.;
|
||||||
if (p->alignment() == Qt::AlignLeft || p->alignment() == Qt::AlignRight) pdp.setX(0.);
|
switch (p->alignment()) {
|
||||||
QVector<int> epl = b->endpointLine(ends[i]);
|
case Qt::AlignRight : pdp.setX(0.); ang = 0.; break;
|
||||||
|
case Qt::AlignTop : pdp.setY(0.); ang = 90.; break;
|
||||||
|
case Qt::AlignLeft : pdp.setX(0.); ang = 180.; break;
|
||||||
|
case Qt::AlignBottom: pdp.setY(0.); ang = 270.; break;
|
||||||
|
default: break;
|
||||||
|
}
|
||||||
|
QVector<int> epl = b->endpointLine(ends[i], ang);
|
||||||
foreach (int e, epl)
|
foreach (int e, epl)
|
||||||
b->movePoint(e, pdp);
|
b->movePoint(e, pdp);
|
||||||
b->movePoint(ends[i], dp);
|
b->movePoint(ends[i], dp);
|
||||||
|
|||||||
@@ -90,6 +90,8 @@ protected:
|
|||||||
void thumbShow();
|
void thumbShow();
|
||||||
void restoreSelState();
|
void restoreSelState();
|
||||||
void saveSelState();
|
void saveSelState();
|
||||||
|
void saveBusesState();
|
||||||
|
void restoreBusesState();
|
||||||
void applySelRect(QGraphicsSceneMouseEvent * me);
|
void applySelRect(QGraphicsSceneMouseEvent * me);
|
||||||
void applyGridStep();
|
void applyGridStep();
|
||||||
void trace(QPointF scene_pos_from, QPointF scene_pos_to, BlockBusItem * bus);
|
void trace(QPointF scene_pos_from, QPointF scene_pos_to, BlockBusItem * bus);
|
||||||
|
|||||||
@@ -87,16 +87,24 @@ void SessionManager::load(bool onlyMainwindow) {
|
|||||||
checks[i].second->setChecked(sr.getValue(checks[i].first, checks[i].second->isChecked()));
|
checks[i].second->setChecked(sr.getValue(checks[i].first, checks[i].second->isChecked()));
|
||||||
for (int i = 0; i < lines.size(); ++i)
|
for (int i = 0; i < lines.size(); ++i)
|
||||||
lines[i].second->setText(sr.getValue(lines[i].first, lines[i].second->text()));
|
lines[i].second->setText(sr.getValue(lines[i].first, lines[i].second->text()));
|
||||||
for (int i = 0; i < combos.size(); ++i)
|
for (int i = 0; i < combos.size(); ++i) {
|
||||||
combos[i].second->setCurrentIndex(sr.getValue(combos[i].first, combos[i].second->currentIndex()));
|
QComboBox * c = combos[i].second;
|
||||||
|
int v = sr.getValue(combos[i].first, c->currentIndex());
|
||||||
|
if (v >= 0 && v < c->count())
|
||||||
|
c->setCurrentIndex(v);
|
||||||
|
}
|
||||||
for (int i = 0; i < dspins.size(); ++i)
|
for (int i = 0; i < dspins.size(); ++i)
|
||||||
dspins[i].second->setValue(sr.getValue(dspins[i].first, dspins[i].second->value()));
|
dspins[i].second->setValue(sr.getValue(dspins[i].first, dspins[i].second->value()));
|
||||||
for (int i = 0; i < spins.size(); ++i)
|
for (int i = 0; i < spins.size(); ++i)
|
||||||
spins[i].second->setValue(sr.getValue(spins[i].first, spins[i].second->value()));
|
spins[i].second->setValue(sr.getValue(spins[i].first, spins[i].second->value()));
|
||||||
for (int i = 0; i < spinsliders.size(); ++i)
|
for (int i = 0; i < spinsliders.size(); ++i)
|
||||||
spinsliders[i].second->setValue(sr.getValue(spinsliders[i].first, spinsliders[i].second->value()));
|
spinsliders[i].second->setValue(sr.getValue(spinsliders[i].first, spinsliders[i].second->value()));
|
||||||
for (int i = 0; i < tabs.size(); ++i)
|
for (int i = 0; i < tabs.size(); ++i) {
|
||||||
tabs[i].second->setCurrentIndex(sr.getValue(tabs[i].first, tabs[i].second->currentIndex()));
|
QTabWidget * t = tabs[i].second;
|
||||||
|
int v = sr.getValue(tabs[i].first, t->currentIndex());
|
||||||
|
if (v >= 0 && v < t->count())
|
||||||
|
t->setCurrentIndex(v);
|
||||||
|
}
|
||||||
for (int i = 0; i < actions.size(); ++i)
|
for (int i = 0; i < actions.size(); ++i)
|
||||||
actions[i].second->setChecked(sr.getValue(actions[i].first, actions[i].second->isChecked()));
|
actions[i].second->setChecked(sr.getValue(actions[i].first, actions[i].second->isChecked()));
|
||||||
for (int i = 0; i < stringlists.size(); ++i)
|
for (int i = 0; i < stringlists.size(); ++i)
|
||||||
|
|||||||
Reference in New Issue
Block a user