Add batch setting to parts tree for poly,base, and mode [skip ci]
parent
9d0a8fa88e
commit
7097c22c69
|
@ -459,7 +459,12 @@ void PartTreeWidget::showContextMenu(const QPoint &pos, bool shorted)
|
||||||
}
|
}
|
||||||
layout->addWidget(previewLabel);
|
layout->addWidget(previewLabel);
|
||||||
}
|
}
|
||||||
|
|
||||||
QComboBox *polyCountSelectBox = nullptr;
|
QComboBox *polyCountSelectBox = nullptr;
|
||||||
|
QComboBox *combineModeSelectBox = nullptr;
|
||||||
|
QComboBox *partTargetSelectBox = nullptr;
|
||||||
|
QComboBox *partBaseSelectBox = nullptr;
|
||||||
|
|
||||||
if (componentIds.size() <= 1) {
|
if (componentIds.size() <= 1) {
|
||||||
if (nullptr == component) {
|
if (nullptr == component) {
|
||||||
polyCountSelectBox = new QComboBox;
|
polyCountSelectBox = new QComboBox;
|
||||||
|
@ -485,9 +490,10 @@ void PartTreeWidget::showContextMenu(const QPoint &pos, bool shorted)
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
QWidget *widget = new QWidget;
|
|
||||||
if (nullptr != component) {
|
|
||||||
QHBoxLayout *componentLayerLayout = nullptr;
|
QHBoxLayout *componentLayerLayout = nullptr;
|
||||||
|
|
||||||
|
if (nullptr != component) {
|
||||||
if (nullptr == part || part->hasLayerFunction()) {
|
if (nullptr == part || part->hasLayerFunction()) {
|
||||||
QPushButton *clothSettingButton = new QPushButton();
|
QPushButton *clothSettingButton = new QPushButton();
|
||||||
connect(clothSettingButton, &QPushButton::clicked, this, [=]() {
|
connect(clothSettingButton, &QPushButton::clicked, this, [=]() {
|
||||||
|
@ -513,7 +519,6 @@ void PartTreeWidget::showContextMenu(const QPoint &pos, bool shorted)
|
||||||
componentLayerLayout->setStretch(0, 1);
|
componentLayerLayout->setStretch(0, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
QComboBox *combineModeSelectBox = nullptr;
|
|
||||||
if (nullptr == part || part->hasCombineModeFunction()) {
|
if (nullptr == part || part->hasCombineModeFunction()) {
|
||||||
combineModeSelectBox = new QComboBox;
|
combineModeSelectBox = new QComboBox;
|
||||||
for (size_t i = 0; i < (size_t)CombineMode::Count; ++i) {
|
for (size_t i = 0; i < (size_t)CombineMode::Count; ++i) {
|
||||||
|
@ -527,7 +532,6 @@ void PartTreeWidget::showContextMenu(const QPoint &pos, bool shorted)
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
QComboBox *partTargetSelectBox = nullptr;
|
|
||||||
if (nullptr != part && nullptr != partWidget) {
|
if (nullptr != part && nullptr != partWidget) {
|
||||||
partTargetSelectBox = new QComboBox;
|
partTargetSelectBox = new QComboBox;
|
||||||
for (size_t i = 0; i < (size_t)PartTarget::Count; ++i) {
|
for (size_t i = 0; i < (size_t)PartTarget::Count; ++i) {
|
||||||
|
@ -541,7 +545,6 @@ void PartTreeWidget::showContextMenu(const QPoint &pos, bool shorted)
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
QComboBox *partBaseSelectBox = nullptr;
|
|
||||||
if (nullptr != part && part->hasBaseFunction() && nullptr != partWidget) {
|
if (nullptr != part && part->hasBaseFunction() && nullptr != partWidget) {
|
||||||
partBaseSelectBox = new QComboBox;
|
partBaseSelectBox = new QComboBox;
|
||||||
for (size_t i = 0; i < (size_t)PartBase::Count; ++i) {
|
for (size_t i = 0; i < (size_t)PartBase::Count; ++i) {
|
||||||
|
@ -554,14 +557,115 @@ void PartTreeWidget::showContextMenu(const QPoint &pos, bool shorted)
|
||||||
emit groupOperationAdded();
|
emit groupOperationAdded();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
//QHBoxLayout *combineModeLayout = new QHBoxLayout;
|
if (componentIds.size() > 1) {
|
||||||
//combineModeLayout->setAlignment(Qt::AlignCenter);
|
if (nullptr == polyCountSelectBox) {
|
||||||
//combineModeLayout->setContentsMargins(0, 0, 0, 0);
|
std::set<PolyCount> polyCounts;
|
||||||
//combineModeLayout->setSpacing(0);
|
for (const auto &componentId: componentIds) {
|
||||||
//combineModeLayout->addWidget(combineModeSelectBox);
|
const Component *oneComponent = m_document->findComponent(componentId);
|
||||||
|
if (nullptr == oneComponent)
|
||||||
|
continue;
|
||||||
|
polyCounts.insert(oneComponent->polyCount);
|
||||||
|
}
|
||||||
|
if (!polyCounts.empty()) {
|
||||||
|
int startIndex = (1 == polyCounts.size()) ? 0 : 1;
|
||||||
|
polyCountSelectBox = new QComboBox;
|
||||||
|
if (0 != startIndex)
|
||||||
|
polyCountSelectBox->addItem(tr("Not Change"));
|
||||||
|
for (size_t i = 0; i < (size_t)PolyCount::Count; ++i) {
|
||||||
|
PolyCount count = (PolyCount)i;
|
||||||
|
polyCountSelectBox->addItem(PolyCountToDispName(count));
|
||||||
|
}
|
||||||
|
if (0 != startIndex)
|
||||||
|
polyCountSelectBox->setCurrentIndex(0);
|
||||||
|
else
|
||||||
|
polyCountSelectBox->setCurrentIndex((int)*polyCounts.begin());
|
||||||
|
connect(polyCountSelectBox, static_cast<void (QComboBox::*)(int)>(&QComboBox::currentIndexChanged), this, [=](int index) {
|
||||||
|
if (index < startIndex)
|
||||||
|
return;
|
||||||
|
for (const auto &componentId: componentIds) {
|
||||||
|
emit setComponentPolyCount(componentId, (PolyCount)(index - startIndex));
|
||||||
|
}
|
||||||
|
emit groupOperationAdded();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (nullptr == partBaseSelectBox) {
|
||||||
|
std::set<PartBase> partBases;
|
||||||
|
for (const auto &componentId: componentIds) {
|
||||||
|
const Component *oneComponent = m_document->findComponent(componentId);
|
||||||
|
if (nullptr == oneComponent || oneComponent->linkToPartId.isNull())
|
||||||
|
continue;
|
||||||
|
const SkeletonPart *onePart = m_document->findPart(oneComponent->linkToPartId);
|
||||||
|
if (nullptr == onePart)
|
||||||
|
continue;
|
||||||
|
partBases.insert(onePart->base);
|
||||||
|
}
|
||||||
|
if (!partBases.empty()) {
|
||||||
|
int startIndex = (1 == partBases.size()) ? 0 : 1;
|
||||||
|
partBaseSelectBox = new QComboBox;
|
||||||
|
if (0 != startIndex)
|
||||||
|
partBaseSelectBox->addItem(tr("Not Change"));
|
||||||
|
for (size_t i = 0; i < (size_t)PartBase::Count; ++i) {
|
||||||
|
PartBase base = (PartBase)i;
|
||||||
|
partBaseSelectBox->addItem(PartBaseToDispName(base));
|
||||||
|
}
|
||||||
|
if (0 != startIndex)
|
||||||
|
partBaseSelectBox->setCurrentIndex(0);
|
||||||
|
else
|
||||||
|
partBaseSelectBox->setCurrentIndex((int)*partBases.begin());
|
||||||
|
connect(partBaseSelectBox, static_cast<void (QComboBox::*)(int)>(&QComboBox::currentIndexChanged), this, [=](int index) {
|
||||||
|
if (index < startIndex)
|
||||||
|
return;
|
||||||
|
for (const auto &componentId: componentIds) {
|
||||||
|
const Component *oneComponent = m_document->findComponent(componentId);
|
||||||
|
if (nullptr == oneComponent || oneComponent->linkToPartId.isNull())
|
||||||
|
continue;
|
||||||
|
emit setPartBase(oneComponent->linkToPartId, (PartBase)(index - startIndex));
|
||||||
|
}
|
||||||
|
emit groupOperationAdded();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (nullptr == combineModeSelectBox) {
|
||||||
|
std::set<CombineMode> combineModes;
|
||||||
|
for (const auto &componentId: componentIds) {
|
||||||
|
const Component *oneComponent = m_document->findComponent(componentId);
|
||||||
|
if (nullptr == oneComponent)
|
||||||
|
continue;
|
||||||
|
combineModes.insert(oneComponent->combineMode);
|
||||||
|
}
|
||||||
|
if (!combineModes.empty()) {
|
||||||
|
int startIndex = (1 == combineModes.size()) ? 0 : 1;
|
||||||
|
combineModeSelectBox = new QComboBox;
|
||||||
|
if (0 != startIndex)
|
||||||
|
combineModeSelectBox->addItem(tr("Not Change"));
|
||||||
|
for (size_t i = 0; i < (size_t)CombineMode::Count; ++i) {
|
||||||
|
CombineMode mode = (CombineMode)i;
|
||||||
|
combineModeSelectBox->addItem(CombineModeToDispName(mode));
|
||||||
|
}
|
||||||
|
if (0 != startIndex)
|
||||||
|
combineModeSelectBox->setCurrentIndex(0);
|
||||||
|
else
|
||||||
|
combineModeSelectBox->setCurrentIndex((int)*combineModes.begin());
|
||||||
|
connect(combineModeSelectBox, static_cast<void (QComboBox::*)(int)>(&QComboBox::currentIndexChanged), this, [=](int index) {
|
||||||
|
if (index < startIndex)
|
||||||
|
return;
|
||||||
|
for (const auto &componentId: componentIds) {
|
||||||
|
emit setComponentCombineMode(componentId, (CombineMode)(index - startIndex));
|
||||||
|
}
|
||||||
|
emit groupOperationAdded();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
QWidget *widget = new QWidget;
|
||||||
QFormLayout *componentSettingsLayout = new QFormLayout;
|
QFormLayout *componentSettingsLayout = new QFormLayout;
|
||||||
|
|
||||||
if (nullptr != polyCountSelectBox)
|
if (nullptr != polyCountSelectBox)
|
||||||
componentSettingsLayout->addRow(tr("Poly"), polyCountSelectBox);
|
componentSettingsLayout->addRow(tr("Poly"), polyCountSelectBox);
|
||||||
if (nullptr != partBaseSelectBox)
|
if (nullptr != partBaseSelectBox)
|
||||||
|
@ -577,16 +681,7 @@ void PartTreeWidget::showContextMenu(const QPoint &pos, bool shorted)
|
||||||
newLayout->addLayout(layout);
|
newLayout->addLayout(layout);
|
||||||
newLayout->addLayout(componentSettingsLayout);
|
newLayout->addLayout(componentSettingsLayout);
|
||||||
widget->setLayout(newLayout);
|
widget->setLayout(newLayout);
|
||||||
} else {
|
|
||||||
QFormLayout *componentSettingsLayout = new QFormLayout;
|
|
||||||
if (nullptr != polyCountSelectBox)
|
|
||||||
componentSettingsLayout->addRow(tr("Poly"), polyCountSelectBox);
|
|
||||||
|
|
||||||
QVBoxLayout *newLayout = new QVBoxLayout;
|
|
||||||
newLayout->addLayout(layout);
|
|
||||||
newLayout->addLayout(componentSettingsLayout);
|
|
||||||
widget->setLayout(newLayout);
|
|
||||||
}
|
|
||||||
forDisplayPartImage.setDefaultWidget(widget);
|
forDisplayPartImage.setDefaultWidget(widget);
|
||||||
//if (!componentIds.empty()) {
|
//if (!componentIds.empty()) {
|
||||||
contextMenu.addAction(&forDisplayPartImage);
|
contextMenu.addAction(&forDisplayPartImage);
|
||||||
|
|
Loading…
Reference in New Issue