From a0e99c425e493e53dfa4ff8963ef23924b09fd62 Mon Sep 17 00:00:00 2001 From: DeepSOIC Date: Tue, 3 May 2016 02:07:05 +0300 Subject: [PATCH] Attacher: display modes that can be reached Attachment mode list used to display only the modes that fit current references. Now, modes that can be reached by adding more references are listed too, but grayed out. --- src/Mod/Part/App/Attacher.cpp | 13 +++++++++++-- src/Mod/Part/App/Attacher.h | 5 ++++- src/Mod/PartDesign/Gui/TaskDatumParameters.cpp | 17 ++++++++++++++--- 3 files changed, 29 insertions(+), 6 deletions(-) diff --git a/src/Mod/Part/App/Attacher.cpp b/src/Mod/Part/App/Attacher.cpp index 0493014176..f4e8b31476 100644 --- a/src/Mod/Part/App/Attacher.cpp +++ b/src/Mod/Part/App/Attacher.cpp @@ -247,7 +247,8 @@ Base::Placement AttachEngine::placementFactory(const gp_Dir &ZAxis, eMapMode AttachEngine::listMapModes(eSuggestResult& msg, std::vector* allApplicableModes, - std::set* nextRefTypeHint) const + std::set* nextRefTypeHint, + std::set* reachableModes) const { //replace a pointer with a valid reference, to avoid checks for zero pointer everywhere std::vector buf; @@ -263,6 +264,12 @@ eMapMode AttachEngine::listMapModes(eSuggestResult& msg, std::set &hints = *nextRefTypeHint; hints.clear(); + std::set buf3; + if (reachableModes == 0) + reachableModes = &buf3; + std::set &mlist_reachable = *reachableModes; + mlist_reachable.clear(); + std::vector parts; std::vector shapes; @@ -305,8 +312,10 @@ eMapMode AttachEngine::listMapModes(eSuggestResult& msg, } } - if (score > 0 && str.size() > typeStr.size()) + if (score > 0 && str.size() > typeStr.size()){ hints.insert(str[typeStr.size()]); + reachableModes->insert(eMapMode(iMode)); + } //size check is last, because we needed to collect hints if (str.size() != typeStr.size()) diff --git a/src/Mod/Part/App/Attacher.h b/src/Mod/Part/App/Attacher.h index 1f380c7773..d69abfd964 100644 --- a/src/Mod/Part/App/Attacher.h +++ b/src/Mod/Part/App/Attacher.h @@ -216,10 +216,13 @@ public: //methods * right type. * * @param nextRefTypeHint (output). A hint of what can be added to references. + * + * @param reachableModes (output). List of modes that can be reached by selecing more references. */ virtual eMapMode listMapModes(eSuggestResult &msg, std::vector* allApplicableModes = 0, - std::set* nextRefTypeHint = 0) const; + std::set* nextRefTypeHint = 0, + std::set *reachableModes = 0) const; /** * @brief getHint function returns a set of types that user can add to diff --git a/src/Mod/PartDesign/Gui/TaskDatumParameters.cpp b/src/Mod/PartDesign/Gui/TaskDatumParameters.cpp index 5f54140ade..8fb79507dd 100644 --- a/src/Mod/PartDesign/Gui/TaskDatumParameters.cpp +++ b/src/Mod/PartDesign/Gui/TaskDatumParameters.cpp @@ -675,9 +675,16 @@ void TaskDatumParameters::updateListOfModes(eMapMode curMode) //obtain list of available modes: Part::Datum* pcDatum = static_cast(DatumView->getObject()); eMapMode suggMode = mmDeactivated; + std::set reachableModes; + int lastValidModeItemIndex = mmDummy_NumberOfModes; if (pcDatum->Support.getSize() > 0){ eSuggestResult msg; - suggMode = pcDatum->attacher().listMapModes(msg, &modesInList); + 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); + } } else { //no references - display all modes modesInList.clear(); @@ -702,13 +709,17 @@ void TaskDatumParameters::updateListOfModes(eMapMode curMode) AttacherGui::getRefListForMode(pcDatum->attacher(),mmode).join(QString::fromLatin1("\n"))); if (mmode == curMode) iSelect = ui->listOfModes->item(i); - if (mmode == suggMode){ - //make it bold + if (i > lastValidModeItemIndex){ + //potential mode - can be reached by selecting more stuff + item->setFlags(item->flags() & ~(Qt::ItemFlag::ItemIsEnabled | Qt::ItemFlag::ItemIsSelectable)); + } else if (mmode == suggMode){ + //suggested mode - make bold assert (item); QFont fnt = item->font(); fnt.setBold(true); item->setFont(fnt); } + } } //restore selection