bus joint paint now configured with BlockView::setBusSquareNodes(), square or round. By default round
This commit is contained in:
@@ -16,6 +16,7 @@ BlockBusItem::BlockBusItem(const BlockBusItem & other): QGraphicsObject(), Prope
|
|||||||
setPen(other.pen());
|
setPen(other.pen());
|
||||||
setBrush(other.brush());
|
setBrush(other.brush());
|
||||||
setBusType(other.busType());
|
setBusType(other.busType());
|
||||||
|
square_node = other.square_node;
|
||||||
max_ep = other.max_ep;
|
max_ep = other.max_ep;
|
||||||
pol = other.pol;
|
pol = other.pol;
|
||||||
segments = other.segments;
|
segments = other.segments;
|
||||||
@@ -46,6 +47,7 @@ void BlockBusItem::_init() {
|
|||||||
bu.setColor(Qt::darkGray);
|
bu.setColor(Qt::darkGray);
|
||||||
}
|
}
|
||||||
setPen(pu); setBrush(bu);
|
setPen(pu); setBrush(bu);
|
||||||
|
square_node = false;
|
||||||
max_ep = 0;
|
max_ep = 0;
|
||||||
selPoint = selSegment = state_ = -1;
|
selPoint = selSegment = state_ = -1;
|
||||||
pen_width = 2.;
|
pen_width = 2.;
|
||||||
@@ -219,6 +221,12 @@ void BlockBusItem::setColor(const QColor & c) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void BlockBusItem::setSquareNodes(bool yes) {
|
||||||
|
square_node = yes;
|
||||||
|
update();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void BlockBusItem::markAsInput() {
|
void BlockBusItem::markAsInput() {
|
||||||
mark_in = true;
|
mark_in = true;
|
||||||
mark_out = false;
|
mark_out = false;
|
||||||
@@ -299,7 +307,7 @@ QList<BlockItem * > BlockBusItem::connectedBlocks() const {
|
|||||||
QSet<BlockItem * > ret;
|
QSet<BlockItem * > ret;
|
||||||
foreach (BlockItemPin * p, pins)
|
foreach (BlockItemPin * p, pins)
|
||||||
ret << p->parent();
|
ret << p->parent();
|
||||||
return ret.toList();
|
return ret.values();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -678,7 +686,7 @@ void BlockBusItem::mouseMoveEvent(QGraphicsSceneMouseEvent * e) {
|
|||||||
|
|
||||||
|
|
||||||
void BlockBusItem::mouseReleaseEvent(QGraphicsSceneMouseEvent * e) {
|
void BlockBusItem::mouseReleaseEvent(QGraphicsSceneMouseEvent * e) {
|
||||||
mm_mods = 0;
|
mm_mods = Qt::KeyboardModifiers();
|
||||||
int btncnt = 0;
|
int btncnt = 0;
|
||||||
if (e->buttons().testFlag(Qt::LeftButton)) btncnt++;
|
if (e->buttons().testFlag(Qt::LeftButton)) btncnt++;
|
||||||
if (e->buttons().testFlag(Qt::RightButton)) btncnt++;
|
if (e->buttons().testFlag(Qt::RightButton)) btncnt++;
|
||||||
@@ -727,7 +735,10 @@ void BlockBusItem::paint(QPainter * p, const QStyleOptionGraphicsItem * o, QWidg
|
|||||||
p->setPen(_pen);
|
p->setPen(_pen);
|
||||||
p->drawLine(pol[segments[i].first], pol[segments[i].second]);
|
p->drawLine(pol[segments[i].first], pol[segments[i].second]);
|
||||||
if (pointSegmentsCount(segments[i].first) > 2) {
|
if (pointSegmentsCount(segments[i].first) > 2) {
|
||||||
p->drawEllipse(pol[segments[i].first], pen_width*0.7, pen_width*0.7);
|
_pen.setWidthF(pen_width * 1.8 + 2.);
|
||||||
|
_pen.setCapStyle(square_node ? Qt::SquareCap : Qt::RoundCap);
|
||||||
|
p->setPen(_pen);
|
||||||
|
p->drawPoint(pol[segments[i].first]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
p->setPen(_pen);
|
p->setPen(_pen);
|
||||||
|
|||||||
@@ -64,6 +64,7 @@ public:
|
|||||||
double width() const {return pen_width;}
|
double width() const {return pen_width;}
|
||||||
void setWidth(const double & w);
|
void setWidth(const double & w);
|
||||||
void setColor(const QColor & c);
|
void setColor(const QColor & c);
|
||||||
|
void setSquareNodes(bool yes);
|
||||||
int addPoint(const QPointF & point, bool update = true);
|
int addPoint(const QPointF & point, bool update = true);
|
||||||
int segmentPointPair(int point, int * seg = 0) const;
|
int segmentPointPair(int point, int * seg = 0) const;
|
||||||
void removePoint(int index);
|
void removePoint(int index);
|
||||||
@@ -122,7 +123,7 @@ protected:
|
|||||||
QImage im_bus, im_end;
|
QImage im_bus, im_end;
|
||||||
QPolygonF pol, bpol, pol_s;
|
QPolygonF pol, bpol, pol_s;
|
||||||
Qt::KeyboardModifiers mm_mods;
|
Qt::KeyboardModifiers mm_mods;
|
||||||
bool temp_;
|
bool temp_, square_node;
|
||||||
double pen_width, grid_step, im_bus_scale, im_end_scale;
|
double pen_width, grid_step, im_bus_scale, im_end_scale;
|
||||||
int selPoint, selSegment, max_ep, bus_type, state_;
|
int selPoint, selSegment, max_ep, bus_type, state_;
|
||||||
bool moved, deleted, mark_in, mark_out, new_segment, mm_cancel, lm_point;
|
bool moved, deleted, mark_in, mark_out, new_segment, mm_cancel, lm_point;
|
||||||
|
|||||||
@@ -8,6 +8,7 @@
|
|||||||
#include <QVector2D>
|
#include <QVector2D>
|
||||||
#include <QClipboard>
|
#include <QClipboard>
|
||||||
#include <QMimeData>
|
#include <QMimeData>
|
||||||
|
#include <QElapsedTimer>
|
||||||
|
|
||||||
const QString _BlockView_Mime_ = "_BlockView_copypaste_";
|
const QString _BlockView_Mime_ = "_BlockView_copypaste_";
|
||||||
|
|
||||||
@@ -45,9 +46,9 @@ void BlockView::_init() {
|
|||||||
smode = BlockView::MultiSelection;
|
smode = BlockView::MultiSelection;
|
||||||
cur_scl = thumb_scl = prev_app_scale = 1.;
|
cur_scl = thumb_scl = prev_app_scale = 1.;
|
||||||
_talpha = 0.;
|
_talpha = 0.;
|
||||||
ae_enabled = is_block_anim = true;
|
ae_enabled = is_block_anim = is_nav_anim = true;
|
||||||
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 = false;
|
||||||
thumb_size = QSizeF(200, 200);
|
thumb_size = QSizeF(200, 200);
|
||||||
if (scene() == 0) {
|
if (scene() == 0) {
|
||||||
scene_ = new QGraphicsScene;
|
scene_ = new QGraphicsScene;
|
||||||
@@ -938,6 +939,7 @@ void BlockView::addItem(QGraphicsItem * item, bool emit_action) {
|
|||||||
applyGridStep();
|
applyGridStep();
|
||||||
if (item->data(1005) == "connection") {
|
if (item->data(1005) == "connection") {
|
||||||
loadBus(qgraphicsitem_cast<BlockBusItem*>(item));
|
loadBus(qgraphicsitem_cast<BlockBusItem*>(item));
|
||||||
|
((BlockBusItem*)item)->setSquareNodes(square_node);
|
||||||
connect((BlockBusItem*)item, SIGNAL(destroyed(QObject*)), this, SLOT(removedBus(QObject*)), Qt::UniqueConnection);
|
connect((BlockBusItem*)item, SIGNAL(destroyed(QObject*)), this, SLOT(removedBus(QObject*)), Qt::UniqueConnection);
|
||||||
if (emit_action) emitActionEvent(BlockItemBase::BusAdd, QList<QGraphicsItem*>() << item);
|
if (emit_action) emitActionEvent(BlockItemBase::BusAdd, QList<QGraphicsItem*>() << item);
|
||||||
emit connectionsChanged();
|
emit connectionsChanged();
|
||||||
@@ -1236,7 +1238,7 @@ void BlockView::trace(QPointF scene_pos_from, QPointF scene_pos_to, BlockBusItem
|
|||||||
int dx = sr.left() / grid_step, dy = sr.top() / grid_step;
|
int dx = sr.left() / grid_step, dy = sr.top() / grid_step;
|
||||||
//qDebug() << dp;
|
//qDebug() << dp;
|
||||||
QPoint dp(-dx, -dy), qpt = quantize(scene_pos_to, grid_step).toPoint() / grid_step + dp;
|
QPoint dp(-dx, -dy), qpt = quantize(scene_pos_to, grid_step).toPoint() / grid_step + dp;
|
||||||
QTime tm;
|
QElapsedTimer tm;
|
||||||
tm.restart();
|
tm.restart();
|
||||||
wavetrace.resize(sr.size() / grid_step);
|
wavetrace.resize(sr.size() / grid_step);
|
||||||
wavetrace.fill(BlockViewWavetrace::Empty);
|
wavetrace.fill(BlockViewWavetrace::Empty);
|
||||||
@@ -1719,6 +1721,15 @@ void BlockView::checkPaste(bool queued) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void BlockView::setBusSquareNodes(bool yes) {
|
||||||
|
square_node = yes;
|
||||||
|
QList<BlockBusItem * > sbl = buses();
|
||||||
|
foreach (BlockBusItem * b, sbl) {
|
||||||
|
b->setSquareNodes(square_node);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void BlockView::newBranchTrace(BlockBusItem * item, QPointF to) {
|
void BlockView::newBranchTrace(BlockBusItem * item, QPointF to) {
|
||||||
trace(item->press_pos, to, &tmp_bus);
|
trace(item->press_pos, to, &tmp_bus);
|
||||||
|
|||||||
@@ -57,6 +57,7 @@ class QAD_EXPORT BlockView: public QGraphicsView
|
|||||||
Q_PROPERTY(bool pinMulticonnect READ isPinMulticonnectEnabled WRITE setPinMulticonnectEnabled)
|
Q_PROPERTY(bool pinMulticonnect READ isPinMulticonnectEnabled WRITE setPinMulticonnectEnabled)
|
||||||
Q_PROPERTY(bool miniMap READ isMiniMapEnabled WRITE setMiniMapEnabled)
|
Q_PROPERTY(bool miniMap READ isMiniMapEnabled WRITE setMiniMapEnabled)
|
||||||
Q_PROPERTY(bool zoomWheelOnly READ isZoomWheelOnly WRITE setZoomWheelOnly)
|
Q_PROPERTY(bool zoomWheelOnly READ isZoomWheelOnly WRITE setZoomWheelOnly)
|
||||||
|
Q_PROPERTY(bool busSquareNodes READ isBusSquareNodes WRITE setBusSquareNodes)
|
||||||
|
|
||||||
Q_PROPERTY(double _thumb READ _thumb WRITE _setThumb DESIGNABLE false SCRIPTABLE false)
|
Q_PROPERTY(double _thumb READ _thumb WRITE _setThumb DESIGNABLE false SCRIPTABLE false)
|
||||||
Q_PROPERTY(QRectF _nav READ _nav WRITE _setNav DESIGNABLE false SCRIPTABLE false)
|
Q_PROPERTY(QRectF _nav READ _nav WRITE _setNav DESIGNABLE false SCRIPTABLE false)
|
||||||
@@ -84,6 +85,7 @@ public:
|
|||||||
bool isPinMulticonnectEnabled() const {return m_pin_mc;}
|
bool isPinMulticonnectEnabled() const {return m_pin_mc;}
|
||||||
bool isMiniMapEnabled() const {return minimap;}
|
bool isMiniMapEnabled() const {return minimap;}
|
||||||
bool isZoomWheelOnly() const {return wheel_zoom;}
|
bool isZoomWheelOnly() const {return wheel_zoom;}
|
||||||
|
bool isBusSquareNodes() const {return square_node;}
|
||||||
double gridStep() const {return grid_step;}
|
double gridStep() const {return grid_step;}
|
||||||
double gridPointsWidth() const {return grid_points;}
|
double gridPointsWidth() const {return grid_points;}
|
||||||
SelectionMode selectionMode() const {return smode;}
|
SelectionMode selectionMode() const {return smode;}
|
||||||
@@ -195,7 +197,7 @@ protected:
|
|||||||
int timer_thumb, thumb_hide_delay, thick;
|
int timer_thumb, thumb_hide_delay, thick;
|
||||||
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 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 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;
|
bool nav_prev_aa, nav_prev_imaa, nav_prev_grid, square_node;
|
||||||
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;
|
||||||
|
|
||||||
@@ -235,6 +237,7 @@ public slots:
|
|||||||
void setPinMulticonnectEnabled(bool on) {m_pin_mc = on;}
|
void setPinMulticonnectEnabled(bool on) {m_pin_mc = on;}
|
||||||
void setMiniMapEnabled(bool on) {minimap = on;}
|
void setMiniMapEnabled(bool on) {minimap = on;}
|
||||||
void setZoomWheelOnly(bool on) {wheel_zoom = on;}
|
void setZoomWheelOnly(bool on) {wheel_zoom = on;}
|
||||||
|
void setBusSquareNodes(bool yes);
|
||||||
|
|
||||||
void zoom(double factor);
|
void zoom(double factor);
|
||||||
void zoomIn() {zoom(1.2);}
|
void zoomIn() {zoom(1.2);}
|
||||||
|
|||||||
Reference in New Issue
Block a user