void KisPixelSelection::applySelection(KisPixelSelectionSP selection, selectionAction action) { switch (action) { case SELECTION_REPLACE: // XXX: Shouldn't we actually replace the selection, instead of falling through to add? case SELECTION_ADD: addSelection(selection); break; case SELECTION_SUBTRACT: subtractSelection(selection); break; case SELECTION_INTERSECT: intersectSelection(selection); break; default: break; } }
/////////////// // INTERSECT // /////////////// void SelectionController::intersectSelection(const sf::IntRect& rect, const std::vector<nSet::o_line>& conf_l) { if (isSelected()) { intersectSelection(rect, static_cast<sf::Image*>(NULL)); setInverted(false); pos_lines = new nSet::positionned_olines(*pos_lines); FOR_I_INV (pos_lines->lines.size()) if (!rect.contains(pos_lines->lines[i].x, pos_lines->lines[i].y)) pos_lines->lines.erase(pos_lines->lines.begin() + i); pos_lines->lines.insert(pos_lines->lines.end(), conf_l.begin(), conf_l.end()); pos_lines->pos = getPosition(); if (!reline()) { UNDO->push(*new SelecUpdated(this, *image_selec, pos_lines->pos, *pos_lines, inverted)); emit selectionUpdated(3); } } else