Attacher: for reachable modes, display what's to add

For grayed out modes in list, show what's needed to get to the mode.
Like so:
"Normal to edge (add Vertex)"
This commit is contained in:
DeepSOIC
2016-05-03 16:05:40 +03:00
committed by wmayer
parent e6911adc50
commit 2b057ef192
3 changed files with 46 additions and 11 deletions

View File

@@ -675,15 +675,15 @@ void TaskDatumParameters::updateListOfModes(eMapMode curMode)
//obtain list of available modes:
Part::Datum* pcDatum = static_cast<Part::Datum*>(DatumView->getObject());
eMapMode suggMode = mmDeactivated;
std::set<eMapMode> reachableModes;
std::map<eMapMode, AttachEngine::refTypeStringList> reachableModes;
int lastValidModeItemIndex = mmDummy_NumberOfModes;
if (pcDatum->Support.getSize() > 0){
eSuggestResult msg;
suggMode = pcDatum->attacher().listMapModes(msg, &modesInList, 0, &reachableModes);
//add reachable modes to the list, too, but gray them out (using lastValidModeItemIndex, later)
lastValidModeItemIndex = modesInList.size()-1;
for(eMapMode m: reachableModes){
modesInList.push_back(m);
for(std::pair<const eMapMode, AttachEngine::refTypeStringList> &rm: reachableModes){
modesInList.push_back(rm.first);
}
} else {
//no references - display all modes
@@ -712,6 +712,20 @@ void TaskDatumParameters::updateListOfModes(eMapMode curMode)
if (i > lastValidModeItemIndex){
//potential mode - can be reached by selecting more stuff
item->setFlags(item->flags() & ~(Qt::ItemFlag::ItemIsEnabled | Qt::ItemFlag::ItemIsSelectable));
AttachEngine::refTypeStringList &extraRefs = reachableModes[mmode];
if (extraRefs.size() == 1){
QStringList buf;
for(eRefType rt : extraRefs[0]){
buf.append(AttacherGui::getShapeTypeText(rt));
}
item->setText(tr("%1 (add %2)").arg(
item->text(),
buf.join(QString::fromLatin1("+"))
));
} else {
item->setText(tr("%1 (add more references)").arg(item->text()));
}
} else if (mmode == suggMode){
//suggested mode - make bold
assert (item);