Example #1
0
        public void Unselect(int index)
        {
            SelectionElement e = selection[index];

            e.UnHighlight();
            selection.RemoveAt(index);
        }
Example #2
0
 private int GetIndex(SceneNode node, int patchID)
 {
     for (int i = 0; i < selection.Count; ++i)
     {
         SelectionElement e = selection[i];
         if (node == e.Origin && patchID == e.PatchID)
         {
             return(i);
         }
     }
     return(-1);
 }
Example #3
0
        public void Clear()
        {
            for (int i = 0; i < selection.Count; ++i)
            {
                SelectionElement e = selection[i];
                e.UnHighlight();
                //e.Node.Selected = false;
                //if (e.PatchID >= 0)
                //    e.Node.Delete();
            }
            selection.Clear();

            //sg.Call<SelectableSceneNode>(delegate(SelectableSceneNode n) { n.Selected = false; });
        }
Example #4
0
        public bool Select(SceneNode node, int geometryID = 0)
        {
            SelectableSceneNode n = node as SelectableSceneNode;

            if (n != null)
            {
                if (!multiSelect)
                {
                    Clear();
                }

                //n.Selected = true;
                //selectedNodes.Add(n);

                SelectionElement se = new SelectionElement(n, geometryID);
                se.Highlight();

                selection.Add(se);
                return(true);
            }
            return(false);
        }
Example #5
0
        public bool Select(Double2 xy, out PickingResult result)
        {
            bool unselect = inputHandler.IsKeyPressed(Key.ShiftLeft);
            List <PickingResult> r;

            result = null;
            if (sg.Pick(xy, 5, out r))
            {
                if (Validator == null)
                {
                    result = r[0];
                }
                else
                {
                    bool success = false;
                    for (int i = 0; i < r.Count; ++i)
                    {
                        result = r[i];
                        if (Validator(result))
                        {
                            success = true;
                            break;
                        }
                    }
                    if (!success)
                    {
                        return(false);
                    }
                }
            }
            else
            {
                return(false);
            }

            if (Pick != null)
            {
                Pick(result, unselect);
            }

            int geometryID = result.GeometryIndex;


            int id = result.PrimitiveIndex;
            PhongPatchPNTriangleGeometry g = result.Node.Geometries[geometryID] as PhongPatchPNTriangleGeometry;

            if (g != null && patchSelectionEnabled)
            {
                int patchID = g.GetRangeIndex(id);
                int index   = GetIndex(result.Node, patchID);

                if (index < 0 && !unselect)
                {
                    if (!multiSelect)
                    {
                        Clear();
                    }

                    SelectionElement se = new SelectionElement(result.Node, geometryID, patchID);
                    se.Highlight();
                    selection.Add(se);
                }
                else if (index >= 0 && unselect)
                {
                    Unselect(index);
                }
                return(true);
            }
            else
            {
                SelectableSceneNode n = result.Node as SelectableSceneNode;
                if (n != null)
                {
                    int index = GetIndex(result.Node, -1);

                    if (index < 0 && !unselect)
                    {
                        if (!multiSelect)
                        {
                            Clear();
                        }

                        SelectionElement se = new SelectionElement(result.Node, geometryID);
                        se.Highlight();
                        selection.Add(se);
                    }
                    else if (index >= 0 && unselect)
                    {
                        Unselect(index);
                    }
                    return(true);
                }
            }
            return(false);
            //}
            //return false;
            //else if (!multiSelect)
            //    Clear();
        }