Skip to content

Commit

Permalink
Attacher: display modes that can be reached
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
DeepSOIC authored and wwmayer committed May 7, 2016
1 parent 096d285 commit e6911ad
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 6 deletions.
13 changes: 11 additions & 2 deletions src/Mod/Part/App/Attacher.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,8 @@ Base::Placement AttachEngine::placementFactory(const gp_Dir &ZAxis,

eMapMode AttachEngine::listMapModes(eSuggestResult& msg,
std::vector<eMapMode>* allApplicableModes,
std::set<eRefType>* nextRefTypeHint) const
std::set<eRefType>* nextRefTypeHint,
std::set<eMapMode>* reachableModes) const
{
//replace a pointer with a valid reference, to avoid checks for zero pointer everywhere
std::vector<eMapMode> buf;
Expand All @@ -263,6 +264,12 @@ eMapMode AttachEngine::listMapModes(eSuggestResult& msg,
std::set<eRefType> &hints = *nextRefTypeHint;
hints.clear();

std::set<eMapMode> buf3;
if (reachableModes == 0)
reachableModes = &buf3;
std::set<eMapMode> &mlist_reachable = *reachableModes;
mlist_reachable.clear();


std::vector<App::GeoFeature*> parts;
std::vector<const TopoDS_Shape*> shapes;
Expand Down Expand Up @@ -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())
Expand Down
5 changes: 4 additions & 1 deletion src/Mod/Part/App/Attacher.h
Original file line number Diff line number Diff line change
Expand Up @@ -216,10 +216,13 @@ class PartExport AttachEngine : public Base::BaseClass
* 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<eMapMode>* allApplicableModes = 0,
std::set<eRefType>* nextRefTypeHint = 0) const;
std::set<eRefType>* nextRefTypeHint = 0,
std::set<eMapMode> *reachableModes = 0) const;

/**
* @brief getHint function returns a set of types that user can add to
Expand Down
17 changes: 14 additions & 3 deletions src/Mod/PartDesign/Gui/TaskDatumParameters.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -675,9 +675,16 @@ 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;
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();
Expand All @@ -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
Expand Down

0 comments on commit e6911ad

Please sign in to comment.