Exemplo n.º 1
0
        public override void drawControlHandles(ref List <string> visited, Matrix4x4 consumerM, bool beingDrawnFromConsumer)
        {
            Matrix4x4 prevHandlesMatrix = Handles.matrix;

            FreeCurve gener = (FreeCurve)parametricObject.generator;



            base.drawControlHandles(ref visited, consumerM, true);

            if (alreadyVisited(ref visited, "FreeCurveHandler"))
            {
                return;
            }



            AXParameter p = parametricObject.getParameter("Output Shape");

            if (p == null || p.getPaths() == null)
            {
                return;
            }


            parametricObject.model.addActiveFreeCurve(parametricObject);

            Event e = Event.current;

            if (ArchimatixEngine.sceneViewState == ArchimatixEngine.SceneViewState.AddPoint && e.type == EventType.keyDown && (e.keyCode == KeyCode.Escape || e.keyCode == KeyCode.Return))
            {
                ArchimatixEngine.setSceneViewState(ArchimatixEngine.SceneViewState.Default);


                e.Use();
            }


            handlePoints = new List <Vector2>();


            bool handleHasChanged = false;

            /*
             * Matrix4x4 context        = parametricObject.model.transform.localToWorldMatrix * generator.parametricObject.worldDisplayMatrix;
             * if (generator.hasOutputsConnected() || parametricObject.is2D())
             *      context *= generator.localMatrix.inverse;
             * else
             *      context *= parametricObject.getAxisRotationMatrix().inverse  * generator.localMatrix.inverse * parametricObject.getAxisRotationMatrix();
             *
             * Handles.matrix = context;
             */
            Handles.matrix = parametricObject.model.transform.localToWorldMatrix * generator.parametricObject.worldDisplayMatrix;            // * generator.localMatrix.inverse;


            float gridDim = parametricObject.model.snapSizeGrid * 100;

            // axis
            Handles.color = Color.red;
            Handles.DrawLine(new Vector3(-gridDim / 2, 0, 0), new Vector3(gridDim / 2, 0, 0));
            Handles.color = Color.green;
            Handles.DrawLine(new Vector3(0, -gridDim / 2, 0), new Vector3(0, gridDim / 2, 0));

            // grid

            if (ArchimatixEngine.snappingOn())
            {
                Handles.color = new Color(1, .5f, .65f, .15f);
            }
            else
            {
                Handles.color = new Color(1, .5f, .65f, .05f);
            }


            AXEditorUtilities.DrawGrid3D(gridDim, parametricObject.model.snapSizeGrid);



            //Handles.matrix = Matrix4x4.identity;

            CurvePoint newCurvePoint      = null;;
            int        newCurvePointIndex = -1;

            if (parametricObject.curve != null)
            {
                //if (Event.current.type == EventType.mouseDown)
                //	selectedIndex = -1;

                //Vector3 pos;



                for (int i = 0; i < parametricObject.curve.Count; i++)
                {
                    //Debug.Log (i + ": "+ parametricObject.curve[i].position);

                    // Control points in Curve

                    bool pointIsSelected = (generator.selectedIndices != null && generator.selectedIndices.Contains(i));



                    Vector3 pos = new Vector3(parametricObject.curve[i].position.x, parametricObject.curve[i].position.y, 0);



                    Handles.color = (pointIsSelected) ? Color.white :  Color.magenta;

                    float capSize = .13f * HandleUtility.GetHandleSize(pos);

                    if (pointIsSelected)
                    {
                        capSize = .17f * HandleUtility.GetHandleSize(pos);
                    }



                    // POSITION
                    //pos = new Vector3(parametricObject.curve[i].position.x, parametricObject.curve[i].position.y, 0);

//					pos = Handles.FreeMoveHandle(
//						pos,
//						Quaternion.identity,
//						capSize,
//						Vector3.zero,
//						(controlID, positione, rotation, size) =>
//					{
//						if (GUIUtility.hotControl > 0 && controlID == GUIUtility.hotControl)
//						Debug.Log("YOP");
//						Handles.SphereCap(controlID, positione, rotation, size);
//					});


                    pos = Handles.FreeMoveHandle(
                        pos,
                        Quaternion.identity,
                        capSize,
                        Vector3.zero,
                        (controlID, position, rotation, size) =>
                    {
                        if (GUIUtility.hotControl > 0 && controlID == GUIUtility.hotControl)
                        {
                            //Debug.Log("*** " + e.type + " -" + e.keyCode + "-");

                            // MOUSE DOWN ON HANDLE!

                            Undo.RegisterCompleteObjectUndo(parametricObject.model, "FreeCurve");
                            //Debug.Log(controlID + ": " + e.type);

                            ArchimatixEngine.selectedFreeCurve = gener;

                            //Debug.Log("SELECT NODE " +i + " ci="+controlID);

                            if (i == 0 && ArchimatixEngine.sceneViewState == ArchimatixEngine.SceneViewState.AddPoint)
                            {
                                generator.P_Output.shapeState = ShapeState.Closed;
                                ArchimatixEngine.setSceneViewState(ArchimatixEngine.SceneViewState.Default);
                            }
                            else if (e.shift && !ArchimatixEngine.mouseIsDownOnHandle)
                            {
                                generator.toggleItem(i);
                            }

                            else if (gener.selectedIndices == null || gener.selectedIndices.Count < 2)
                            {
                                if (!generator.isSelected(i))
                                {
                                    generator.selectOnlyItem(i);
                                }
                            }
                            ArchimatixEngine.isPseudoDraggingSelectedPoint = i;

                            // CONVERT TO BEZIER
                            if (e.alt)
                            {
                                gener.convertToBezier(i);
                            }



                            for (int j = 0; j < generator.P_Output.Dependents.Count; j++)
                            {
                                generator.P_Output.Dependents [j].parametricObject.generator.adjustWorldMatrices();
                            }


                            ArchimatixEngine.mouseDownOnSceneViewHandle();
                        }


                        Handles.SphereCap(controlID, position, rotation, size);
                    });



                    // MID_SEGEMNET HANDLE

                    if (i < parametricObject.curve.Count)
                    {
                        //Handles.matrix = parametricObject.model.transform.localToWorldMatrix * generator.parametricObject.worldDisplayMatrix * generator.localMatrix.inverse;

                        Handles.color = Color.cyan;

                        //Debug.Log("mid handle "+i);

                        CurvePoint a = parametricObject.curve[i];

                        int next_i = (i == parametricObject.curve.Count - 1) ? 0 : i + 1;

                        CurvePoint b = parametricObject.curve[next_i];

                        if (a.isPoint() && b.isPoint())
                        {
                            pos = Vector2.Lerp(a.position, b.position, .5f);
                        }
                        else
                        {
                            Vector2 pt = FreeCurve.bezierValue(a, b, .5f);
                            pos = (Vector3)pt;
                        }

                        EditorGUI.BeginChangeCheck();

                                                #if UNITY_5_6_OR_NEWER
                        pos = Handles.FreeMoveHandle(
                            pos,
                            Quaternion.identity,
                            .06f * HandleUtility.GetHandleSize(pos),
                            Vector3.zero,
                            (controlID, positione, rotation, size, eventType) =>
                        {
                            if (GUIUtility.hotControl > 0 && controlID == GUIUtility.hotControl)
                            {
                                ArchimatixEngine.selectedFreeCurve = gener;
                            }
                            Handles.CubeHandleCap(controlID, positione, rotation, size, eventType);
                        });
                                                #else
                        pos = Handles.FreeMoveHandle(
                            pos,
                            Quaternion.identity,
                            .06f * HandleUtility.GetHandleSize(pos),
                            Vector3.zero,
                            (controlID, positione, rotation, size) =>
                        {
                            if (GUIUtility.hotControl > 0 && controlID == GUIUtility.hotControl)
                            {
                                ArchimatixEngine.selectedFreeCurve = gener;
                            }
                            Handles.CubeCap(controlID, positione, rotation, size);
                        });
                                                #endif

                        if (EditorGUI.EndChangeCheck())
                        {
                            // add point to spline at i using pos.x, pos.y
                            Undo.RegisterCompleteObjectUndo(parametricObject.model, "New Midpoint");

                            //Debug.Log(pos);
                            //Debug.Log(ArchimatixEngine.isPseudoDraggingSelectedPoint + " ::: " + (i));

                            //if (ArchimatixEngine.isPseudoDraggingSelectedPoint != (i+1))
                            if (ArchimatixEngine.isPseudoDraggingSelectedPoint == -1)
                            {
                                //Debug.Log("CREATE!!!!");
                                newCurvePoint = new CurvePoint(pos.x, pos.y);

                                newCurvePointIndex = i + 1;

                                parametricObject.curve.Insert(newCurvePointIndex, newCurvePoint);
                                ArchimatixEngine.isPseudoDraggingSelectedPoint = newCurvePointIndex;
                                generator.selectedIndex = newCurvePointIndex;

                                generator.selectOnlyItem(newCurvePointIndex);
                            }

                            parametricObject.model.isAltered();
                        }
                    }
                }                 // \loop


                // BEZIER HANDLES LOOP
                for (int i = 0; i < parametricObject.curve.Count; i++)
                {
                    //Debug.Log (i + ": "+ parametricObject.curve[i].position);

                    // Control points in Curve

                    bool pointIsSelected = (generator.selectedIndices != null && generator.selectedIndices.Contains(i));



                    Vector3 pos  = new Vector3(parametricObject.curve[i].position.x, parametricObject.curve[i].position.y, 0);
                    Vector3 posA = new Vector3(parametricObject.curve[i].position.x + parametricObject.curve[i].localHandleA.x, parametricObject.curve[i].position.y + parametricObject.curve[i].localHandleA.y, 0);
                    Vector3 posB = new Vector3(parametricObject.curve[i].position.x + parametricObject.curve[i].localHandleB.x, parametricObject.curve[i].position.y + parametricObject.curve[i].localHandleB.y, 0);


                    Handles.color = (pointIsSelected) ? Color.white :  Color.magenta;



                    if (pointIsSelected)
                    {
                        Handles.color = Color.magenta;

                        if (parametricObject.curve[i].isBezierPoint())
                        {
                            Handles.color = Color.white;
                            Handles.DrawLine(pos, posA);
                            Handles.DrawLine(pos, posB);



                            EditorGUI.BeginChangeCheck();
                            posA = Handles.FreeMoveHandle(
                                posA,
                                Quaternion.identity,
                                .1f * HandleUtility.GetHandleSize(pos),
                                Vector3.zero,
                                Handles.SphereCap
                                );

                            if (EditorGUI.EndChangeCheck())
                            {
                                Undo.RegisterCompleteObjectUndo(parametricObject.model, "FreeformShapee");
                                handleHasChanged = true;

                                parametricObject.curve[i].setHandleA(new Vector2(posA.x, posA.y));



                                //parametricObject.curve[i].localHandleA = new Vector2(pos.x, pos.y) - parametricObject.curve[i].position;
                                //parametricObject.model.generate("Move FreeForm Shape Handle");
                                parametricObject.model.isAltered();
                            }



                            // HANDLE_B


                            EditorGUI.BeginChangeCheck();
                            posB = Handles.FreeMoveHandle(
                                posB,
                                Quaternion.identity,
                                .1f * HandleUtility.GetHandleSize(pos),
                                Vector3.zero,
                                Handles.SphereCap
                                );

                            if (EditorGUI.EndChangeCheck())
                            {
                                Undo.RegisterCompleteObjectUndo(parametricObject.model, "FreeformShapee");
                                handleHasChanged = true;
                                //parametricObject.curve[i].localHandleB = new Vector2(pos.x, pos.y) - parametricObject.curve[i].position;
                                parametricObject.curve[i].setHandleB(new Vector2(posB.x, posB.y));



                                //parametricObject.model.generate("Move FreeForm Shape Handle");
                                parametricObject.model.isAltered();
                            }
                        }
                    }             // selected
                }                 // \bezier handles loop



                if (handleHasChanged)
                {
                }
            }

            Handles.matrix = prevHandlesMatrix;
        }
Exemplo n.º 2
0
        public override void OnSceneGUI()
        {
            AXModel model = ArchimatixEngine.currentModel;


            FreeCurve gener = (FreeCurve)generator;

            Event e = Event.current;



            if (model != null)
            {
                Matrix4x4 context = parametricObject.model.transform.localToWorldMatrix * generator.parametricObject.worldDisplayMatrix;                // * generator.localMatrix;



                drawGUIControls();



                if ((ArchimatixEngine.sceneViewState == ArchimatixEngine.SceneViewState.AddPoint || (e.type == EventType.mouseDrag && ArchimatixEngine.isPseudoDraggingSelectedPoint >= 0)) && !e.alt)
                {
                    Vector3 v1 = context.MultiplyPoint3x4(Vector3.zero);
                    Vector3 v2 = context.MultiplyPoint3x4(new Vector3(100, 0, 0));
                    Vector3 v3 = context.MultiplyPoint3x4(new Vector3(0, 100, 0));

                    //Debug.Log ("-"+ArchimatixEngine.sceneViewState + "- plane points: " + v1 + ", " + v2+ ", " + v3 );


                    Plane drawingSurface = new Plane(v1, v2, v3);


                    //Matrix4x4 = parametricObject.model.transform.localToWorldMatrix * generator.parametricObject.worldDisplayMatrix;// * generator.localMatrix.inverse;



                    Ray ray = HandleUtility.GUIPointToWorldRay(e.mousePosition);

                    float   rayDistance = 0;
                    Vector3 hitPoint;



                    // Point on Plane
                    if (drawingSurface.Raycast(ray, out rayDistance))
                    {
                        hitPoint = ray.GetPoint(rayDistance);


                        Vector3 hit_position3D = new Vector3(hitPoint.x, hitPoint.y, hitPoint.z);



                        if (ArchimatixEngine.snappingOn())
                        {
                            hit_position3D = AXGeometryTools.Utilities.SnapToGrid(hit_position3D, parametricObject.model.snapSizeGrid);
                        }



                        int nearId = HandleUtility.nearestControl;

                        if (nearId == 0)
                        {
                            Color cyan = Color.cyan;
                            cyan.a = .1f;

                            float hScale = .09f * HandleUtility.GetHandleSize(hit_position3D);
                            float lScale = 5 * hScale;

                            Handles.color = cyan;
                            Handles.DrawSolidDisc(hit_position3D,
                                                  Vector3.up,
                                                  hScale);

                            cyan.a        = .8f;
                            Handles.color = cyan;
                            Handles.DrawWireDisc(hit_position3D,
                                                 Vector3.up,
                                                 2 * hScale);


                            Handles.DrawLine(hit_position3D + lScale * Vector3.forward, hit_position3D - lScale * Vector3.forward);

                            //Handles.color = Color.white;
                            Handles.DrawLine(hit_position3D + lScale * Vector3.right, hit_position3D - lScale * Vector3.right);


                            // put visual cue under mouse....
                            //Debug.Log (hitPoint);
                        }



                        hitPoint = context.inverse.MultiplyPoint3x4(hitPoint);

                        Vector2 hit_position2D = new Vector2(hitPoint.x, hitPoint.y);

                        if (ArchimatixEngine.snappingOn())
                        {
                            hit_position2D = AXGeometryTools.Utilities.SnapToGrid(hit_position2D, parametricObject.model.snapSizeGrid);
                        }


                        // EVENTS

                        if (e.type == EventType.MouseDown && !e.alt && nearId == 0 && e.button == 0)
                        {
                            ArchimatixEngine.isPseudoDraggingSelectedPoint = -1;

                            if (gener != null)
                            {
                                if (!e.control)                                  // add to end of line
                                {
                                    // ADD POINT AT END

                                    gener.parametricObject.curve.Add(new CurvePoint(hit_position2D.x, hit_position2D.y));
                                    gener.selectedIndex = gener.parametricObject.curve.Count - 1;
                                }
                                else                                 // ADD POINT TO BEGINNING
                                {
                                    gener.parametricObject.curve.Insert(0, new CurvePoint(hit_position2D.x, hit_position2D.y));
                                    gener.selectedIndex = 0;
                                }


                                ArchimatixEngine.isPseudoDraggingSelectedPoint = gener.selectedIndex;
                                model.autobuild();
                            }
                        }
                        else if (e.type == EventType.mouseDrag)
                        {
                            //Debug.Log("Dragging "+ ArchimatixEngine.isPseudoDraggingSelectedPoint + " :: " +  generator.selectedIndices);

                            if (gener == ArchimatixEngine.selectedFreeCurve && ArchimatixEngine.isPseudoDraggingSelectedPoint >= 0)
                            {
                                if (gener.parametricObject.curve.Count > ArchimatixEngine.isPseudoDraggingSelectedPoint && generator.selectedIndices != null)
                                {
                                    // The actual point being dragged:
                                    Vector2 displ = hit_position2D - gener.parametricObject.curve[ArchimatixEngine.isPseudoDraggingSelectedPoint].position;
                                    gener.parametricObject.curve[ArchimatixEngine.isPseudoDraggingSelectedPoint].position = hit_position2D;


                                    for (int i = 0; i < model.activeFreeCurves.Count; i++)
                                    {
                                        FreeCurve fc = (FreeCurve)model.activeFreeCurves[i].generator;

                                        if (fc != null && fc.selectedIndices != null)
                                        {
                                            for (int j = 0; j < fc.selectedIndices.Count; j++)
                                            {
                                                if (!(fc == gener && fc.selectedIndices[j] == ArchimatixEngine.isPseudoDraggingSelectedPoint))
                                                {
                                                    fc.parametricObject.curve[fc.selectedIndices[j]].position += displ;
                                                }
                                            }
                                        }
                                    }

                                    //Debug.Log ("DRAGGING");
                                    parametricObject.setAltered();
                                    model.isAltered();
                                    generator.adjustWorldMatrices();
                                }
                            }
                        }
                        if (e.type == EventType.mouseUp)
                        {
                            //if (ArchimatixEngine.isPseudoDraggingSelectedPoint > -1)


                            ArchimatixEngine.isPseudoDraggingSelectedPoint = -1;
                            ArchimatixEngine.draggingNewPointAt            = -1;
                            //model.autobuild();

                            //Debug.Log("mouse up");
                        }


                        if ((e.type == EventType.mouseDown) || (e.type == EventType.mouseDrag && ArchimatixEngine.isPseudoDraggingSelectedPoint >= 0) || (e.type == EventType.mouseUp))
                        {
                            //e.Use();
                        }



                        SceneView sv = SceneView.lastActiveSceneView;
                        if (sv != null)
                        {
                            sv.Repaint();
                        }
                    }
                }
            }
        }         // \OnScenView
    public static void processEventCommand(Event e, AXModel model)
    {
        if (e.type == EventType.ValidateCommand)
        {
            e.Use();
        }

        //Debug.Log("-> processEventCommand 1: PROCESS COMMAND "+e.commandName);


        var view = SceneView.lastActiveSceneView;

        string focusedControlName = GUI.GetNameOfFocusedControl();

        if (model != null)
        {
            // intercept this command and use for po's
            switch (e.commandName)
            {
            case "UndoRedoPerformed":
                //Debug.Log ("UndoRedoPerformed");
                model.cleanGraph();
                model.autobuild();

                for (int i = 0; i < model.selectedPOs.Count; i++)
                {
                    model.selectedPOs[i].generator.adjustWorldMatrices();
                }

                // SCENEVIEW
                if (SceneView.lastActiveSceneView != null)
                {
                    SceneView.lastActiveSceneView.Repaint();
                }


                //model.setRenderMode( AXModel.RenderMode.GameObjects );
                model.cacheThumbnails("AXGeometryTools.Utilities::processEventCommand::UndoRedoPerformed");


                if (e.type != EventType.Repaint && e.type != EventType.Layout)
                {
                    e.Use();
                }
                break;


            case "SelectAll":

                Debug.Log("SelectAll");
                model.selectAll();


                e.Use();
                break;

            case "Copy":
                //Debug.Log ("COPY ..."+ GUI.GetNameOfFocusedControl());

                //Debug.Log ("buf: " + EditorGUIUtility.systemCopyBuffer);

                //Debug.Log("-"+focusedControlName+"-");
                //Debug.Log((string.IsNullOrEmpty(focusedControlName) || !focusedControlName.Contains("_Text_")));
                if (string.IsNullOrEmpty(focusedControlName) || !focusedControlName.Contains("_Text_"))
                {
                    if (model.selectedPOs.Count > 0)
                    {
                        EditorGUIUtility.systemCopyBuffer = LibraryEditor.poWithSubNodes_2_JSON(model.selectedPOs[0], true);
                    }
                    if (e.type != EventType.Repaint && e.type != EventType.Layout)
                    {
                        e.Use();
                    }
                }

                break;

            case "Paste":
                //Debug.Log ("PASTE");
                //Debug.Log(GUI.GetNameOfFocusedControl());

                //if (string.IsNullOrEmpty(GUI.GetNameOfFocusedControl()))
                //{
                Undo.RegisterCompleteObjectUndo(model, "Paste");
                string focusedControlNameBeforePaste = GUI.GetNameOfFocusedControl();
                if (string.IsNullOrEmpty(focusedControlNameBeforePaste) || !focusedControlNameBeforePaste.Contains("_Text_"))
                {
                    //model.deselectAll();

                    Library.pasteParametricObjectFromString(EditorGUIUtility.systemCopyBuffer);
                    model.autobuild();

                    if (e.type != EventType.Repaint && e.type != EventType.Layout)
                    {
                        e.Use();
                    }
                }
                model.autobuild();

                break;

            case "Duplicate":
                Undo.RegisterCompleteObjectUndo(model, "Duplicate");

                //Debug.Log ("Duplicate Command");
                if (model.selectedPOs.Count > 0)
                {
                    AXParametricObject selectedPO = model.selectedPOs[0];

                    instancePO(selectedPO);
                }

                model.autobuild();

                if (e.type != EventType.Repaint && e.type != EventType.Layout)
                {
                    e.Use();
                }
                break;

            case "Cut":
                Undo.RegisterCompleteObjectUndo(model, "Cut");
                //EditorGUIUtility.systemCopyBuffer = JSONSerializersAX.allSelectedPOsAsJson(model);


                if (string.IsNullOrEmpty(focusedControlName) || !focusedControlName.Contains("_Text_"))
                {
                    if (model.selectedPOs.Count > 0)
                    {
                        EditorGUIUtility.systemCopyBuffer = LibraryEditor.poWithSubNodes_2_JSON(model.selectedPOs[0], true);
                    }


                    if (e.shift)
                    {
                        model.deleteSelectedPOsAndInputs();
                    }
                    else
                    {
                        model.deleteSelectedPOs();
                    }

                    model.autobuild();
                    if (e.type != EventType.Repaint && e.type != EventType.Layout)
                    {
                        e.Use();
                    }
                }



                break;

            case "SoftDelete":
            case "Delete":

                //Debug.Log("DELETE");
                // see if it is a selected point on a curve
                //if (ArchimatixEngine

                /*
                 * FreeCurve selectedFreeCurve = null;
                 *
                 * if ( model.selectedPOs != null && model.selectedPOs.Count == 1 &&  model.selectedPOs[0] != null && model.selectedPOs[0].generator != null &&  model.selectedPOs[0].generator is FreeCurve)
                 * {
                 *      selectedFreeCurve = (FreeCurve) model.selectedPOs[0].generator;
                 * }
                 *
                 * if (selectedFreeCurve != null && selectedFreeCurve.selectedIndices != null  &&  selectedFreeCurve.selectedIndices.Count > 0)
                 * {
                 *      // delete points
                 *      selectedFreeCurve.deleteSelected();
                 * }
                 */

                // SELECTED POINTS TO DELETE?
                //Debug.Log("focusedControlName="+focusedControlName);
                if (string.IsNullOrEmpty(focusedControlName) || !focusedControlName.Contains("_Text_"))
                {
                    bool foundSelectedPoints = false;

                    if (model.activeFreeCurves.Count > 0)
                    {
                        for (int i = 0; i < model.activeFreeCurves.Count; i++)
                        {
                            FreeCurve gener = (FreeCurve)model.activeFreeCurves[i].generator;


                            //Debug.Log("gener.hasSelectedPoints()="+gener.hasSelectedPoints());
                            if (gener.hasSelectedPoints())
                            {
                                foundSelectedPoints = true;
                                gener.deleteSelected();
                            }
                        }
                    }
                    //Debug.Log("foundSelectedPoints="+foundSelectedPoints);

                    if (foundSelectedPoints)
                    {
                        ArchimatixEngine.mouseIsDownOnHandle = false;
                    }
                    else if (e.shift)
                    {
                        Undo.RegisterCompleteObjectUndo(model, "Delete Nodes");
                        model.deleteSelectedPOsAndInputs();
                    }
                    // [S.Darkwell: changed else to this else if to fix bug: "Fix pressing Delete key without Node selected still registers undo event" https://archimatixbeta.slack.com/files/s.darkwell/F1DJRQ3LL/fix_pressing_delete_key_without_node_selected_still_registers_undo_event.cs  - 2016.06.02]
                    else if (model.selectedPOs.Count > 0)
                    {
                        Undo.RegisterCompleteObjectUndo(model, "Delete Node");
                        model.deleteSelectedPOs();
                    }
                    else if (model.selectedParameterInputRelation != null)
                    {
                        Undo.RegisterCompleteObjectUndo(model, "Delete Dependancy");
                        model.selectedParameterInputRelation.makeIndependent();
                        model.selectedParameterInputRelation = null;
                    }
                    else if (model.selectedRelationInGraph != null)
                    {
                        Undo.RegisterCompleteObjectUndo(model, "Delete Relation");
                        model.unrelate(model.selectedRelationInGraph);
                        model.selectedRelationInGraph = null;
                    }

                    //Debug.Log("*********************************** DELETE");
                    model.remapMaterialTools();

                    model.autobuild();

                    //Debug.Log("caching here G");
                    model.cacheThumbnails();
                    e.Use();
                }



                break;



            case "FrameSelected":

                if (view != null)
                {
                    float framePadding = 400;


                    if (model.selectedPOs == null || model.selectedPOs.Count == 0)
                    {
                        //model.selectAll();
                        model.selectAllVisibleInGroup(model.currentWorkingGroupPO);


                        Rect allRect = AXUtilities.getBoundaryRectFromPOs(model.selectedPOs);
                        allRect.x      -= framePadding;
                        allRect.y      -= framePadding;
                        allRect.width  += framePadding * 2;
                        allRect.height += framePadding * 2;

                        AXNodeGraphEditorWindow.zoomToRectIfOpen(allRect);
                        model.deselectAll();
                    }
                    else if (model.selectedPOs.Count > 1)
                    {
                        Rect allRect = AXUtilities.getBoundaryRectFromPOs(model.selectedPOs);
                        allRect.x      -= framePadding;
                        allRect.y      -= framePadding;
                        allRect.width  += framePadding * 2;
                        allRect.height += framePadding * 2;

                        AXNodeGraphEditorWindow.zoomToRectIfOpen(allRect);
                    }
                    else
                    {
                        //frame first po
                        AXParametricObject currPO = model.cycleSelectedPO;                        // model.selectedPOs[0];

                        if (currPO == null)
                        {
                            currPO = model.mostRecentlySelectedPO;
                        }

                        if (currPO == null && model.selectedPOs != null && model.selectedPOs.Count > 0)
                        {
                            currPO = model.selectedPOs[0];
                        }

                        if (currPO == null)
                        {
                            currPO = model.selectFirstHeadPO();
                        }

                        if (currPO != null)
                        {
                            Matrix4x4 m = model.transform.localToWorldMatrix * currPO.worldDisplayMatrix;                            // * currPO.getLocalMatrix();

                            if (m.isIdentity)
                            {
                                m = currPO.generator.localMatrix;
                            }

                            Vector3 position = m.MultiplyPoint(currPO.bounds.center);


                            if (currPO.bounds.size.magnitude > .005 && currPO.bounds.size.magnitude < 10000)
                            {
                                view.LookAt(position, view.camera.transform.rotation, currPO.bounds.size.magnitude * 1.01f);
                            }
                            else
                            {
                                //Debug.Log("FrameSelected - select ParametricObjectObject bounds not good: "+currPO.bounds.size.magnitude);
                            }

                            //if (currPO.grouper != null )
                            //{
                            AXNodeGraphEditorWindow.displayGroupIfOpen(currPO.grouper);
                            //}
                            //model.beginPanningToPoint(currPO.rect.center);
                            AXNodeGraphEditorWindow.zoomToRectIfOpen(currPO.rect);
                        }
                    }
                    if (e.type != EventType.Repaint && e.type != EventType.Layout)
                    {
                        e.Use();
                    }
                }

                break;
            }
        }

        // EDITOR WINDOW

        ArchimatixEngine.repaintGraphEditorIfExistsAndOpen();

        // SCENEVIEW
        if (view != null)
        {
            view.Repaint();
        }


        lastCommand = e.commandName;
    }