Only allow item been selected when visible
parent
38fb0c022a
commit
28a95aedee
|
@ -607,7 +607,10 @@ bool SkeletonGraphicsWidget::mousePress(QMouseEvent *event)
|
||||||
QPointF sideProfile = mainProfile;
|
QPointF sideProfile = mainProfile;
|
||||||
if (m_addFromNodeItem) {
|
if (m_addFromNodeItem) {
|
||||||
auto itemIt = nodeItemMap.find(m_addFromNodeItem->id());
|
auto itemIt = nodeItemMap.find(m_addFromNodeItem->id());
|
||||||
|
if (SkeletonProfile::Main == m_addFromNodeItem->profile())
|
||||||
sideProfile.setX(itemIt->second.second->origin().x());
|
sideProfile.setX(itemIt->second.second->origin().x());
|
||||||
|
else
|
||||||
|
mainProfile.setX(itemIt->second.first->origin().x());
|
||||||
} else {
|
} else {
|
||||||
if (mainProfile.x() >= scene()->width() / 2) {
|
if (mainProfile.x() >= scene()->width() / 2) {
|
||||||
sideProfile.setX(mainProfile.x() - scene()->width() / 4);
|
sideProfile.setX(mainProfile.x() - scene()->width() / 4);
|
||||||
|
@ -636,11 +639,9 @@ bool SkeletonGraphicsWidget::mousePress(QMouseEvent *event)
|
||||||
clearRangeSelection();
|
clearRangeSelection();
|
||||||
}
|
}
|
||||||
if (m_hoveredNodeItem) {
|
if (m_hoveredNodeItem) {
|
||||||
m_hoveredNodeItem->setChecked(true);
|
addItemToRangeSelection(m_hoveredNodeItem);
|
||||||
m_rangeSelectionSet.insert(m_hoveredNodeItem);
|
|
||||||
} else if (m_hoveredEdgeItem) {
|
} else if (m_hoveredEdgeItem) {
|
||||||
m_hoveredEdgeItem->setChecked(true);
|
addItemToRangeSelection(m_hoveredEdgeItem);
|
||||||
m_rangeSelectionSet.insert(m_hoveredEdgeItem);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!m_rangeSelectionSet.empty()) {
|
if (!m_rangeSelectionSet.empty()) {
|
||||||
|
@ -958,6 +959,10 @@ void SkeletonGraphicsWidget::partVisibleStateChanged(QUuid partId)
|
||||||
|
|
||||||
bool SkeletonGraphicsWidget::checkSkeletonItem(QGraphicsItem *item, bool checked)
|
bool SkeletonGraphicsWidget::checkSkeletonItem(QGraphicsItem *item, bool checked)
|
||||||
{
|
{
|
||||||
|
if (checked) {
|
||||||
|
if (!item->isVisible())
|
||||||
|
return false;
|
||||||
|
}
|
||||||
if (item->data(0) == "node") {
|
if (item->data(0) == "node") {
|
||||||
SkeletonGraphicsNodeItem *nodeItem = (SkeletonGraphicsNodeItem *)item;
|
SkeletonGraphicsNodeItem *nodeItem = (SkeletonGraphicsNodeItem *)item;
|
||||||
if (checked != nodeItem->checked())
|
if (checked != nodeItem->checked())
|
||||||
|
@ -1115,8 +1120,7 @@ void SkeletonGraphicsWidget::selectPartAll()
|
||||||
}
|
}
|
||||||
if (node->partId != choosenPartId)
|
if (node->partId != choosenPartId)
|
||||||
continue;
|
continue;
|
||||||
checkSkeletonItem(item, true);
|
addItemToRangeSelection(item);
|
||||||
m_rangeSelectionSet.insert(item);
|
|
||||||
}
|
}
|
||||||
for (const auto &it: edgeItemMap) {
|
for (const auto &it: edgeItemMap) {
|
||||||
SkeletonGraphicsEdgeItem *item = SkeletonProfile::Main == choosenProfile ? it.second.first : it.second.second;
|
SkeletonGraphicsEdgeItem *item = SkeletonProfile::Main == choosenProfile ? it.second.first : it.second.second;
|
||||||
|
@ -1128,8 +1132,7 @@ void SkeletonGraphicsWidget::selectPartAll()
|
||||||
}
|
}
|
||||||
if (edge->partId != choosenPartId)
|
if (edge->partId != choosenPartId)
|
||||||
continue;
|
continue;
|
||||||
checkSkeletonItem(item, true);
|
addItemToRangeSelection(item);
|
||||||
m_rangeSelectionSet.insert(item);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1144,14 +1147,26 @@ void SkeletonGraphicsWidget::selectAll()
|
||||||
}
|
}
|
||||||
for (const auto &it: nodeItemMap) {
|
for (const auto &it: nodeItemMap) {
|
||||||
SkeletonGraphicsNodeItem *item = SkeletonProfile::Main == choosenProfile ? it.second.first : it.second.second;
|
SkeletonGraphicsNodeItem *item = SkeletonProfile::Main == choosenProfile ? it.second.first : it.second.second;
|
||||||
checkSkeletonItem(item, true);
|
addItemToRangeSelection(item);
|
||||||
m_rangeSelectionSet.insert(item);
|
|
||||||
}
|
}
|
||||||
for (const auto &it: edgeItemMap) {
|
for (const auto &it: edgeItemMap) {
|
||||||
SkeletonGraphicsEdgeItem *item = SkeletonProfile::Main == choosenProfile ? it.second.first : it.second.second;
|
SkeletonGraphicsEdgeItem *item = SkeletonProfile::Main == choosenProfile ? it.second.first : it.second.second;
|
||||||
|
addItemToRangeSelection(item);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void SkeletonGraphicsWidget::addItemToRangeSelection(QGraphicsItem *item)
|
||||||
|
{
|
||||||
|
if (!item->isVisible())
|
||||||
|
return;
|
||||||
checkSkeletonItem(item, true);
|
checkSkeletonItem(item, true);
|
||||||
m_rangeSelectionSet.insert(item);
|
m_rangeSelectionSet.insert(item);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void SkeletonGraphicsWidget::removeItemFromRangeSelection(QGraphicsItem *item)
|
||||||
|
{
|
||||||
|
checkSkeletonItem(item, false);
|
||||||
|
m_rangeSelectionSet.erase(item);
|
||||||
}
|
}
|
||||||
|
|
||||||
void SkeletonGraphicsWidget::unselectAll()
|
void SkeletonGraphicsWidget::unselectAll()
|
||||||
|
|
|
@ -332,6 +332,8 @@ private:
|
||||||
void removeItem(QGraphicsItem *item);
|
void removeItem(QGraphicsItem *item);
|
||||||
QVector2D centerOfNodeItemSet(const std::set<SkeletonGraphicsNodeItem *> &set);
|
QVector2D centerOfNodeItemSet(const std::set<SkeletonGraphicsNodeItem *> &set);
|
||||||
bool isSingleNodeSelected();
|
bool isSingleNodeSelected();
|
||||||
|
void addItemToRangeSelection(QGraphicsItem *item);
|
||||||
|
void removeItemFromRangeSelection(QGraphicsItem *item);
|
||||||
private:
|
private:
|
||||||
QGraphicsPixmapItem *m_backgroundItem;
|
QGraphicsPixmapItem *m_backgroundItem;
|
||||||
const SkeletonDocument *m_document;
|
const SkeletonDocument *m_document;
|
||||||
|
|
Loading…
Reference in New Issue