Add select by component
parent
b945ab9725
commit
717c8ef266
|
@ -603,6 +603,8 @@ SkeletonDocumentWindow::SkeletonDocumentWindow() :
|
||||||
connect(partTreeWidget, &SkeletonPartTreeWidget::lockDescendantComponents, m_document, &SkeletonDocument::lockDescendantComponents);
|
connect(partTreeWidget, &SkeletonPartTreeWidget::lockDescendantComponents, m_document, &SkeletonDocument::lockDescendantComponents);
|
||||||
connect(partTreeWidget, &SkeletonPartTreeWidget::unlockDescendantComponents, m_document, &SkeletonDocument::unlockDescendantComponents);
|
connect(partTreeWidget, &SkeletonPartTreeWidget::unlockDescendantComponents, m_document, &SkeletonDocument::unlockDescendantComponents);
|
||||||
|
|
||||||
|
connect(partTreeWidget, &SkeletonPartTreeWidget::addPartToSelection, graphicsWidget, &SkeletonGraphicsWidget::addPartToSelection);
|
||||||
|
|
||||||
connect(m_document, &SkeletonDocument::componentNameChanged, partTreeWidget, &SkeletonPartTreeWidget::componentNameChanged);
|
connect(m_document, &SkeletonDocument::componentNameChanged, partTreeWidget, &SkeletonPartTreeWidget::componentNameChanged);
|
||||||
connect(m_document, &SkeletonDocument::componentChildrenChanged, partTreeWidget, &SkeletonPartTreeWidget::componentChildrenChanged);
|
connect(m_document, &SkeletonDocument::componentChildrenChanged, partTreeWidget, &SkeletonPartTreeWidget::componentChildrenChanged);
|
||||||
connect(m_document, &SkeletonDocument::componentRemoved, partTreeWidget, &SkeletonPartTreeWidget::componentRemoved);
|
connect(m_document, &SkeletonDocument::componentRemoved, partTreeWidget, &SkeletonPartTreeWidget::componentRemoved);
|
||||||
|
|
|
@ -1939,6 +1939,41 @@ void SkeletonGraphicsWidget::addSelectEdge(QUuid edgeId)
|
||||||
hoverPart(QUuid());
|
hoverPart(QUuid());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void SkeletonGraphicsWidget::addPartToSelection(QUuid partId)
|
||||||
|
{
|
||||||
|
SkeletonProfile choosenProfile = SkeletonProfile::Main;
|
||||||
|
if (m_hoveredNodeItem) {
|
||||||
|
choosenProfile = m_hoveredNodeItem->profile();
|
||||||
|
} else if (m_hoveredEdgeItem) {
|
||||||
|
choosenProfile = m_hoveredEdgeItem->profile();
|
||||||
|
}
|
||||||
|
QUuid choosenPartId = partId;
|
||||||
|
for (const auto &it: nodeItemMap) {
|
||||||
|
SkeletonGraphicsNodeItem *item = SkeletonProfile::Main == choosenProfile ? it.second.first : it.second.second;
|
||||||
|
const SkeletonNode *node = m_document->findNode(item->id());
|
||||||
|
if (!node)
|
||||||
|
continue;
|
||||||
|
if (choosenPartId.isNull()) {
|
||||||
|
choosenPartId = node->partId;
|
||||||
|
}
|
||||||
|
if (node->partId != choosenPartId)
|
||||||
|
continue;
|
||||||
|
addItemToRangeSelection(item);
|
||||||
|
}
|
||||||
|
for (const auto &it: edgeItemMap) {
|
||||||
|
SkeletonGraphicsEdgeItem *item = SkeletonProfile::Main == choosenProfile ? it.second.first : it.second.second;
|
||||||
|
const SkeletonEdge *edge = m_document->findEdge(item->id());
|
||||||
|
if (!edge)
|
||||||
|
continue;
|
||||||
|
if (choosenPartId.isNull()) {
|
||||||
|
choosenPartId = edge->partId;
|
||||||
|
}
|
||||||
|
if (edge->partId != choosenPartId)
|
||||||
|
continue;
|
||||||
|
addItemToRangeSelection(item);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void SkeletonGraphicsWidget::selectPartAll()
|
void SkeletonGraphicsWidget::selectPartAll()
|
||||||
{
|
{
|
||||||
unselectAll();
|
unselectAll();
|
||||||
|
|
|
@ -433,6 +433,7 @@ public slots:
|
||||||
void selectAll();
|
void selectAll();
|
||||||
void unselectAll();
|
void unselectAll();
|
||||||
void selectPartAll();
|
void selectPartAll();
|
||||||
|
void addPartToSelection(QUuid partId);
|
||||||
void cut();
|
void cut();
|
||||||
void copy();
|
void copy();
|
||||||
void flipHorizontally();
|
void flipHorizontally();
|
||||||
|
|
|
@ -97,6 +97,7 @@ void SkeletonPartTreeWidget::showContextMenu(const QPoint &pos)
|
||||||
QAction unlockAction(tr("Unlock"), this);
|
QAction unlockAction(tr("Unlock"), this);
|
||||||
QAction invertAction(tr("Invert"), this);
|
QAction invertAction(tr("Invert"), this);
|
||||||
QAction cancelInverseAction(tr("Cancel Inverse"), this);
|
QAction cancelInverseAction(tr("Cancel Inverse"), this);
|
||||||
|
QAction selectAction(tr("Select"), this);
|
||||||
|
|
||||||
if (!component->linkToPartId.isNull()) {
|
if (!component->linkToPartId.isNull()) {
|
||||||
emit checkPart(component->linkToPartId);
|
emit checkPart(component->linkToPartId);
|
||||||
|
@ -128,6 +129,15 @@ void SkeletonPartTreeWidget::showContextMenu(const QPoint &pos)
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (!component->childrenIds.empty()) {
|
if (!component->childrenIds.empty()) {
|
||||||
|
connect(&selectAction, &QAction::triggered, [=]() {
|
||||||
|
std::vector<QUuid> partIds;
|
||||||
|
m_document->collectComponentDescendantParts(componentId, partIds);
|
||||||
|
for (const auto &partId: partIds) {
|
||||||
|
emit addPartToSelection(partId);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
contextMenu.addAction(&selectAction);
|
||||||
|
|
||||||
connect(&showAction, &QAction::triggered, [=]() {
|
connect(&showAction, &QAction::triggered, [=]() {
|
||||||
emit showDescendantComponents(componentId);
|
emit showDescendantComponents(componentId);
|
||||||
});
|
});
|
||||||
|
|
|
@ -37,6 +37,7 @@ signals:
|
||||||
void showDescendantComponents(QUuid componentId);
|
void showDescendantComponents(QUuid componentId);
|
||||||
void lockDescendantComponents(QUuid componentId);
|
void lockDescendantComponents(QUuid componentId);
|
||||||
void unlockDescendantComponents(QUuid componentId);
|
void unlockDescendantComponents(QUuid componentId);
|
||||||
|
void addPartToSelection(QUuid partId);
|
||||||
public:
|
public:
|
||||||
SkeletonPartTreeWidget(const SkeletonDocument *document, QWidget *parent);
|
SkeletonPartTreeWidget(const SkeletonDocument *document, QWidget *parent);
|
||||||
QTreeWidgetItem *findComponentItem(QUuid componentId);
|
QTreeWidgetItem *findComponentItem(QUuid componentId);
|
||||||
|
|
Loading…
Reference in New Issue