src/editmodes/magicWandMode.cc

changeset 840
d077dd19bf9a
parent 833
ad681d97d341
child 844
11587d419d2f
equal deleted inserted replaced
839:5f822ad61875 840:d077dd19bf9a
44 { 44 {
45 // All boundaries obviously share vertices with the object, therefore they're all in the list 45 // All boundaries obviously share vertices with the object, therefore they're all in the list
46 // of candidates. 46 // of candidates.
47 for (auto it = candidates.begin(); it != candidates.end(); ++it) 47 for (auto it = candidates.begin(); it != candidates.end(); ++it)
48 { 48 {
49 if (not eq ((*it)->type(), OBJ_Line, OBJ_CondLine) || (*it)->vertex (0) == (*it)->vertex (1)) 49 if (not eq ((*it)->type(), OBJ_Line, OBJ_CondLine) or (*it)->vertex (0) == (*it)->vertex (1))
50 continue; 50 continue;
51 51
52 int matches = 0; 52 int matches = 0;
53 53
54 for (int i = 0; i < obj->numVertices(); ++i) 54 for (int i = 0; i < obj->numVertices(); ++i)
128 try 128 try
129 { 129 {
130 // If we're doing this on lines, we need exact type match. Surface types (quads and 130 // If we're doing this on lines, we need exact type match. Surface types (quads and
131 // triangles) can be mixed. Also don't consider self a candidate, and don't consider 131 // triangles) can be mixed. Also don't consider self a candidate, and don't consider
132 // objects we have already processed. 132 // objects we have already processed.
133 if ((candidate == obj) || 133 if ((candidate == obj) or
134 (candidate->color() != obj->color()) || 134 (candidate->color() != obj->color()) or
135 (_selection.contains (candidate)) || 135 (_selection.contains (candidate)) or
136 (matchesneeded == 1 && (candidate->type() != objtype)) || 136 (matchesneeded == 1 and (candidate->type() != objtype)) or
137 ((candidate->numVertices() > 2) ^ (matchesneeded == 2))) 137 ((candidate->numVertices() > 2) ^ (matchesneeded == 2)))
138 { 138 {
139 throw 0; 139 throw 0;
140 } 140 }
141 141
158 throw 0; // Not enough matches. 158 throw 0; // Not enough matches.
159 159
160 // Check if a boundary gets in between the objects. 160 // Check if a boundary gets in between the objects.
161 for (auto boundary : boundaries) 161 for (auto boundary : boundaries)
162 { 162 {
163 if (eq (matches[0], std::get<0> (boundary), std::get<1> (boundary)) && 163 if (eq (matches[0], std::get<0> (boundary), std::get<1> (boundary)) and
164 eq (matches[1], std::get<0> (boundary), std::get<1> (boundary))) 164 eq (matches[1], std::get<0> (boundary), std::get<1> (boundary)))
165 { 165 {
166 throw 0; 166 throw 0;
167 } 167 }
168 } 168 }
201 bool MagicWandMode::mouseReleased (MouseEventData const& data) 201 bool MagicWandMode::mouseReleased (MouseEventData const& data)
202 { 202 {
203 if (Super::mouseReleased (data)) 203 if (Super::mouseReleased (data))
204 return true; 204 return true;
205 205
206 if (data.releasedButtons & Qt::LeftButton && not data.mouseMoved) 206 if (data.releasedButtons & Qt::LeftButton and not data.mouseMoved)
207 { 207 {
208 MagicType wandtype = MagicWandMode::Set; 208 MagicType wandtype = MagicWandMode::Set;
209 209
210 if (data.keymods & Qt::ShiftModifier) 210 if (data.keymods & Qt::ShiftModifier)
211 wandtype = MagicWandMode::Additive; 211 wandtype = MagicWandMode::Additive;

mercurial