BlockBusItem::PointInfo and BlockBusItem::pointInfo()
This commit is contained in:
@@ -315,6 +315,24 @@ QList<BlockItemPin * > BlockBusItem::connectedPins() const {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
BlockBusItem::PointInfo BlockBusItem::pointInfo(QPointF pos) const {
|
||||||
|
PointInfo ret;
|
||||||
|
int pi = -1, si = -1;
|
||||||
|
testPoint(pos, &pi, & si);
|
||||||
|
if (pi < 0 && si < 0) return ret;
|
||||||
|
if (si >= 0) {
|
||||||
|
ret.type = PointInfo::tSegment;
|
||||||
|
} else {
|
||||||
|
if (endpoints().contains(pi)) {
|
||||||
|
ret.type = PointInfo::tEndpoint;
|
||||||
|
ret.pin = connections_.value(pi, nullptr);
|
||||||
|
} else
|
||||||
|
ret.type = PointInfo::tNode;
|
||||||
|
}
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void BlockBusItem::setBusState(bool state) {
|
void BlockBusItem::setBusState(bool state) {
|
||||||
int s = state ? 1 : 0;
|
int s = state ? 1 : 0;
|
||||||
if (state_ == s) return;
|
if (state_ == s) return;
|
||||||
@@ -481,7 +499,7 @@ int BlockBusItem::neighborSegmentPoint(int point, int * seg) const {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void BlockBusItem::testPoint(QPointF pos, int * sel_point, int * sel_segment, bool for_trace) {
|
void BlockBusItem::testPoint(QPointF pos, int * sel_point, int * sel_segment, bool for_trace) const {
|
||||||
for (int i = 0; i < pol.size(); ++i) {
|
for (int i = 0; i < pol.size(); ++i) {
|
||||||
if ((pol[i] - pos).manhattanLength() <= (for_trace ? 5. : 10.)) { // Point
|
if ((pol[i] - pos).manhattanLength() <= (for_trace ? 5. : 10.)) { // Point
|
||||||
*sel_point = i;
|
*sel_point = i;
|
||||||
|
|||||||
@@ -34,6 +34,17 @@ public:
|
|||||||
BlockBusItem(const BlockBusItem & other);
|
BlockBusItem(const BlockBusItem & other);
|
||||||
~BlockBusItem() {;}
|
~BlockBusItem() {;}
|
||||||
|
|
||||||
|
struct QAD_BLOCKVIEW_EXPORT PointInfo {
|
||||||
|
enum Type {
|
||||||
|
tNone,
|
||||||
|
tNode, // point > 2 segments
|
||||||
|
tEndpoint,
|
||||||
|
tSegment
|
||||||
|
};
|
||||||
|
Type type = tNone;
|
||||||
|
BlockItemPin * pin = nullptr; // if tEndpoint and pin connected
|
||||||
|
};
|
||||||
|
|
||||||
void setGridStep(double gs) {grid_step = gs;}
|
void setGridStep(double gs) {grid_step = gs;}
|
||||||
void setEndpointsNumber(int num) {max_ep = num;}
|
void setEndpointsNumber(int num) {max_ep = num;}
|
||||||
void setImages(const QImage & bus, const QImage & end = QImage()) {im_bus = bus; im_end = end; update();}
|
void setImages(const QImage & bus, const QImage & end = QImage()) {im_bus = bus; im_end = end; update();}
|
||||||
@@ -66,6 +77,7 @@ public:
|
|||||||
bool isBusSelected() const {return selSegment >= 0 || selPoint >= 0;}
|
bool isBusSelected() const {return selSegment >= 0 || selPoint >= 0;}
|
||||||
QList<BlockItem * > connectedBlocks() const;
|
QList<BlockItem * > connectedBlocks() const;
|
||||||
QList<BlockItemPin * > connectedPins() const;
|
QList<BlockItemPin * > connectedPins() const;
|
||||||
|
PointInfo pointInfo(QPointF pos) const;
|
||||||
|
|
||||||
void setBusState(bool state);
|
void setBusState(bool state);
|
||||||
bool busState() const {return state_ > 0;}
|
bool busState() const {return state_ > 0;}
|
||||||
@@ -86,7 +98,7 @@ protected:
|
|||||||
void updateGeometry();
|
void updateGeometry();
|
||||||
bool checkDelete();
|
bool checkDelete();
|
||||||
void emitAction(BlockItemBase::Action a);
|
void emitAction(BlockItemBase::Action a);
|
||||||
void testPoint(QPointF pos, int * sel_point, int * sel_segment, bool for_trace = false);
|
void testPoint(QPointF pos, int * sel_point, int * sel_segment, bool for_trace = false) const;
|
||||||
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;
|
||||||
int pointSegmentsCount(int point, QList<int> * segs = 0) const;
|
int pointSegmentsCount(int point, QList<int> * segs = 0) const;
|
||||||
|
|||||||
Reference in New Issue
Block a user