Skip to content

Commit

Permalink
Changes based on wwmayer's comments
Browse files Browse the repository at this point in the history
  • Loading branch information
AjinkyaDahale authored and wwmayer committed Jan 31, 2017
1 parent fb2cd4d commit e8c822c
Showing 1 changed file with 14 additions and 13 deletions.
27 changes: 14 additions & 13 deletions src/Mod/Sketcher/Gui/CommandConstraints.cpp
Expand Up @@ -244,8 +244,8 @@ void finishDistanceConstraint(Gui::Command* cmd, Sketcher::SketchObject* sketch,

void showNoConstraintBetweenExternal()
{
QMessageBox::warning(Gui::getMainWindow(), QObject::tr("Wrong selection"),
QObject::tr("Cannot add a constraint between two external geometries!"));
QMessageBox::warning(Gui::getMainWindow(), QObject::tr("Wrong selection"),
QObject::tr("Cannot add a constraint between two external geometries!"));
}

bool checkBothExternal(int GeoId1, int GeoId2)
Expand Down Expand Up @@ -833,21 +833,19 @@ class DrawSketchHandlerGenConstraint: public DrawSketchHandler
{
public:
DrawSketchHandlerGenConstraint(const char* cursor[], CmdSketcherConstraint *_cmd)
: constraintCursor(cursor), cmd(_cmd) {}
: constraintCursor(cursor), cmd(_cmd), selFilterGate(nullptr) {}
virtual ~DrawSketchHandlerGenConstraint()
{
Gui::Selection().rmvSelectionGate();
}

virtual void activated(ViewProviderSketch *)
{
ongoingSequences = new std::set<int>(); //TODO: make it contain more values
_tempOnSequences = new std::set<int>();
selFilterGate = new GenericConstraintSelection(sketchgui->getObject());

resetOngoingSequences();

selSeq = *(new std::vector<SelIdPair>());
selSeq.clear();

Gui::Selection().rmvSelectionGate();
Gui::Selection().addSelectionGate(selFilterGate);
Expand Down Expand Up @@ -922,10 +920,10 @@ class DrawSketchHandlerGenConstraint: public DrawSketchHandler
onSketchPos.x,
onSketchPos.y,
0.f);
_tempOnSequences->clear();
_tempOnSequences.clear();
allowedSelTypes = 0;
for (std::set<int>::iterator token = ongoingSequences->begin();
token != ongoingSequences->end(); ++token) {
for (std::set<int>::iterator token = ongoingSequences.begin();
token != ongoingSequences.end(); ++token) {
if ((cmd->allowedSelSequences).at(*token).at(seqIndex) == newSelType) {
if (seqIndex == (cmd->allowedSelSequences).at(*token).size()-1) {
// TODO: One of the sequences is completed. Pass to cmd->applyConstraint
Expand All @@ -936,7 +934,7 @@ class DrawSketchHandlerGenConstraint: public DrawSketchHandler

return true;
}
_tempOnSequences->insert(*token);
_tempOnSequences.insert(*token);
allowedSelTypes = allowedSelTypes | (cmd->allowedSelSequences).at(*token).at(seqIndex+1);
}
}
Expand All @@ -960,14 +958,14 @@ class DrawSketchHandlerGenConstraint: public DrawSketchHandler
int allowedSelTypes = 0;

/// indices of currently ongoing sequences in cmd->allowedSequences
std::set<int> *ongoingSequences, *_tempOnSequences;
std::set<int> ongoingSequences, _tempOnSequences;
/// Index within the selection sequences active
unsigned int seqIndex;

void resetOngoingSequences() {
ongoingSequences->clear();
ongoingSequences.clear();
for (unsigned int i = 0; i < cmd->allowedSelSequences.size(); i++) {
ongoingSequences->insert(i);
ongoingSequences.insert(i);
}
seqIndex = 0;

Expand Down Expand Up @@ -1276,6 +1274,9 @@ void CmdSketcherConstrainVertical::activated(int iMsg)
if (selection.size() != 1) {
// QMessageBox::warning(Gui::getMainWindow(), QObject::tr("Wrong selection"),
// QObject::tr("Select an edge from the sketch."));
ActivateHandler(getActiveGuiDocument(),
new DrawSketchHandlerGenConstraint(constraintCursor, this));
getSelection().clearSelection();
return;
}

Expand Down

0 comments on commit e8c822c

Please sign in to comment.