Exemplo n.º 1
0
        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;
            }
            }
        }
Exemplo n.º 2
0
        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);
        }
Exemplo n.º 3
0
        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;
            }
        }
Exemplo n.º 4
0
        public bool OnSelect(Vector2 posView)
        {
            float touchRange = ccContext.SelectRadius;

            Vector2 p      = CCContext.ViewToModel(posView, ccContext.ModelViewMatrix);
            float   radius = CCContext.ViewToModel(touchRange, ccContext.ModelViewMatrix);

            switch (activeTool)
            {
            case Tool.ROIEdit:
            {
                selectedPrim = SphereSelector.Select(roiSphere, p, radius, true, true);
                if (selectedPrim != null)
                {
                    ccContext.RequestRender();
                    return(true);
                }
                break;
            }

            case Tool.TagCreate:
            case Tool.TagDelete:
            {
                selectedPrim = TagSelector.Select(tags, p, radius);
                if (selectedPrim != null)
                {
                    ccContext.RequestRender();
                    Console.WriteLine("selected:" + selectedPrim.GetPrimitive());
                    return(true);
                }
                break;
            }
            }

            return(false);
        }