public void OnTapGesture(Vector2 posView) { float touchRange = ccContext.SelectRadius; Vector2 pos = CCContext.ViewToModel(posView, ccContext.ModelViewMatrix); // Mask draw and erase if (activeTool == Tool.MaskDraw || activeTool == Tool.MaskErase) { bool foreground = activeTool == Tool.MaskDraw; CountLayerHelper.MaskDraw(pos, pos, foreground, frameBuffer, maskTexName, ccContext.ImageSize, unitSphereVertices, ccContext.DrawRadius); bUpdateROI = true; bUpdateSeqmentation = true; ccContext.RequestRender(); return; } // Tap pos in count view spacew float radius = CCContext.ViewToModel(touchRange, ccContext.ModelViewMatrix); switch (ccContext.CountLayerContext.ActiveTool) { case CountLayerContext.Tool.TagCreate: { // Make sure tag is inside ROI if ((pos - roiSphere.center).Length < roiSphere.radius) { tags.Add(new Tag(pos)); bUpdateSeqmentation = true; ccContext.RequestRender(); } break; } case CountLayerContext.Tool.TagDelete: { TagSelector selector = TagSelector.Select(tags, pos, radius); if (selector != null) { Tag tag = selector.GetPrimitive() as Tag; tags.Remove(tag); bUpdateSeqmentation = true; ccContext.RequestRender(); } break; } } }
public void OnDragStarted(Vector2 endPos, Vector2 translation) { Vector2 vPos = CCContext.ViewToModel(endPos, ccContext.ModelViewMatrix); Vector2 vDelta; vDelta.X = CCContext.ViewToModel(translation.X, ccContext.ModelViewMatrix); vDelta.Y = CCContext.ViewToModel(translation.Y, ccContext.ModelViewMatrix); // Mask draw and erase if (activeTool == Tool.MaskDraw || activeTool == Tool.MaskErase) { lastMaskDrawPos = vPos - vDelta; bool foreground = activeTool == Tool.MaskDraw; CountLayerHelper.MaskDraw(vPos, lastMaskDrawPos, foreground, frameBuffer, maskTexName, ccContext.ImageSize , unitSphereVertices, ccContext.DrawRadius); lastMaskDrawPos = vPos; return; } OnDrag(endPos, translation); }
public void OnDrag(Vector2 endPos, Vector2 translation) { Vector2 vPos = CCContext.ViewToModel(endPos, ccContext.ModelViewMatrix); // Mask draw and erase if (activeTool == Tool.MaskDraw || activeTool == Tool.MaskErase) { bool foreground = activeTool == Tool.MaskDraw; CountLayerHelper.MaskDraw(vPos, lastMaskDrawPos, foreground, frameBuffer, maskTexName, ccContext.ImageSize, unitSphereVertices, ccContext.DrawRadius); lastMaskDrawPos = vPos; bUpdateROI = true; ccContext.RequestRender(); return; } // Drag primitive if (selectedPrim != null) { Vector2 vDelta; vDelta.X = CCContext.ViewToModel(translation.X, ccContext.ModelViewMatrix); vDelta.Y = CCContext.ViewToModel(translation.Y, ccContext.ModelViewMatrix); selectedPrim.DragTo(vPos, vDelta); ccContext.RequestRender(); return; } // Pan view { Matrix4 trans = Matrix4.CreateTranslation(translation.X, translation.Y, 0); ccContext.ModelViewMatrix = ccContext.ModelViewMatrix * trans; } }