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(); }
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); } }