void DragSelectionTool::RasterDeformTool::applyTransform(FourPoints bbox) { RasterSelectionTool *tool = (RasterSelectionTool *)getTool(); tool->setNewFreeDeformer(); if (!m_deformUndo) m_deformUndo = new UndoRasterDeform(tool); RasterSelection *selection = dynamic_cast<RasterSelection *>(tool->getSelection()); assert(selection); FourPoints realBbox = bbox * selection->getTransformation().inv(); RasterFreeDeformer *freeDeformer = (RasterFreeDeformer *)tool->getFreeDeformer(); freeDeformer->setNoAntialiasing(tool->getNoAntialiasingValue()); freeDeformer->setPoints(realBbox.getP00(), realBbox.getP10(), realBbox.getP11(), realBbox.getP01()); freeDeformer->deformImage(); selection->setFloatingSeletion(freeDeformer->getImage()); VectorFreeDeformer *vectorFreeDeformer = tool->getSelectionFreeDeformer(); if (vectorFreeDeformer) { vectorFreeDeformer->setPoints(realBbox.getP00(), realBbox.getP10(), realBbox.getP11(), realBbox.getP01()); vectorFreeDeformer->deformImage(); TVectorImage *vi = vectorFreeDeformer->getDeformedImage(); std::vector<TStroke> newStrokes; int i; for (i = 0; i < (int)vi->getStrokeCount(); i++) newStrokes.push_back(*(vi->getStroke(i))); selection->setStrokes(newStrokes); } tool->m_deformValues.m_isSelectionModified = true; if (!m_isDragging) tool->notifyImageChanged(); }
std::vector<int> getSelectedStrokes(TVectorImage &vi, const LevelSelection &levelSelection) { struct locals { static void selectStyles(const TVectorImage &vi, const std::set<int> &styles, std::vector<int> &strokes) { UINT s, sCount = vi.getStrokeCount(); for (s = 0; s != sCount; ++s) { if (styles.count(vi.getStroke(s)->getStyle())) strokes.push_back(s); } } }; // locals std::vector<int> strokes; switch (levelSelection.filter()) { case LevelSelection::EMPTY:; CASE LevelSelection::WHOLE : strokes.assign(boost::make_counting_iterator(0u), boost::make_counting_iterator(vi.getStrokeCount())); CASE LevelSelection::SELECTED_STYLES : locals::selectStyles(vi, levelSelection.styles(), strokes); CASE LevelSelection::BOUNDARY_STROKES : getBoundaries(vi, strokes); } return strokes; }
static void selectStyles(const TVectorImage &vi, const std::set<int> &styles, std::vector<int> &strokes) { UINT s, sCount = vi.getStrokeCount(); for (s = 0; s != sCount; ++s) { if (styles.count(vi.getStroke(s)->getStyle())) strokes.push_back(s); } }