Beispiel #1
0
    public static int OnGUI(Rect pRect, AXNodeGraphEditorWindow editor, AXShape shp)
    {
        Color shapeColor = editor.getDataColor(AXParameter.DataType.Spline);

        Color origBG = GUI.backgroundColor;


        //Rect pRect = new Rect(x1+12, cur_y, width-20,lineHgt);
        float cur_x = ArchimatixUtils.cur_x;
        //float box_x = cur_x + ArchimatixUtils.indent;
        float box_w = ArchimatixUtils.paletteRect.width - cur_x - 3 * ArchimatixUtils.indent;



        int x1      = (int)pRect.x - ArchimatixUtils.indent;
        int cur_y   = (int)pRect.y;
        int width   = (int)pRect.width;
        int lineHgt = ArchimatixUtils.lineHgt;
        int gap     = 5;

        Rect boxRect = pRect;

        boxRect = new Rect(cur_x + ArchimatixUtils.indent, cur_y, box_w, ArchimatixUtils.lineHgt);

        Rect lRect = new Rect(x1 + 11, cur_y, 50, lineHgt);

        if (!shp.isOpen && shp.inputs != null)
        {
            foreach (AXParameter sp in  shp.inputs)
            {
                sp.inputPoint  = new Vector2(ArchimatixUtils.paletteRect.x, ArchimatixUtils.paletteRect.y + cur_y + lineHgt / 2);
                sp.outputPoint = new Vector2(ArchimatixUtils.paletteRect.x + ArchimatixUtils.paletteRect.width, ArchimatixUtils.paletteRect.y + cur_y + lineHgt / 2);
            }
        }



        // Header
        //EditorGUI.BeginChangeCheck();

        //GUI.Button(pRect, Name);
        GUI.color = Color.white;

        GUI.backgroundColor = shapeColor;



        //
        shp.isOpen = true;

        if (shp.isOpen)
        {
            /*  INPUTS
             */


            GUIStyle labelstyle = GUI.skin.GetStyle("Label");
            labelstyle.alignment  = TextAnchor.MiddleLeft;
            labelstyle.fixedWidth = 100;
            labelstyle.fontSize   = 12;

            //Rect boxRect = new Rect (x1 + 22, cur_y, width - 38, lineHgt);
            //Rect editRect = new Rect (x1 + 22, cur_y, width - 38, lineHgt);


            //Archimatix.cur_x += Archimatix.indent;
            // INPUT SHAPE PARAMETERS
            for (int i = 0; i < shp.inputs.Count; i++)
            {
                AXParameter sp = shp.inputs [i];

                sp.inputPoint  = new Vector2(ArchimatixUtils.paletteRect.x, ArchimatixUtils.paletteRect.y + cur_y + lineHgt / 2);
                sp.outputPoint = new Vector2(ArchimatixUtils.paletteRect.x + ArchimatixUtils.paletteRect.width, ArchimatixUtils.paletteRect.y + cur_y + lineHgt / 2);

                cur_y = ParameterSplineGUI.OnGUI_Spline(new Rect(x1, cur_y, width, lineHgt), editor, sp);
            }
            //Archimatix.cur_x -= Archimatix.indent;

            // Empty / New SHAPE PARAMETER

            if (editor.OutputParameterBeingDragged != null && editor.OutputParameterBeingDragged.Type != AXParameter.DataType.Spline)
            {
                GUI.enabled = false;
            }

            if (GUI.Button(new Rect(-3, cur_y, lineHgt, lineHgt), ""))
            {
                //Debug.Log ("make shape 2");
                AXParameter new_p = shp.addInput();
                editor.inputSocketClicked(new_p);
                editor.OutputParameterBeingDragged = null;
            }

            GUI.enabled = true;

            boxRect = new Rect(x1 + 11, cur_y, width - 38, lineHgt);
            GUI.Box(boxRect, " ");
            GUI.Box(boxRect, " ");
            //boxRect.x += 10;
            GUI.Label(boxRect, "Empty Shape");


            cur_y += lineHgt + gap;


            //cur_y += 2*gap;



            //Rect bRect = boxRect;

            lRect.y = cur_y;


            /*  SPECIFIC OUTPUT  PARAMETERS
             */
            //lRect.y = cur_y;
            //GUI.Label(lRect, "Output Combinations");
            cur_y += gap;

            //Archimatix.cur_x += Archimatix.indent;

            GUI.color           = Color.white;
            GUI.backgroundColor = Color.white;

            //Rect foldRect = new Rect(ArchimatixUtils.indent*2, cur_y, 30,lineHgt);


            //outputParametersOpen = EditorGUI.Foldout(foldRect, outputParametersOpen, "Merge Results");



            /*
             * if (false && shp.outputParametersOpen)
             * {
             *      cur_y += lineHgt;
             *      ArchimatixUtils.cur_x += ArchimatixUtils.indent;
             *
             *      bool tmp_boolval;
             *      bRect.x = ArchimatixUtils.indent*3+4;//width-lineHgt;
             *
             *
             *      // difference
             *      shp.difference.inputPoint   = new Vector2 (ArchimatixUtils.paletteRect.x,                                   ArchimatixUtils.paletteRect.y + cur_y + lineHgt / 2);
             *      shp.difference.outputPoint  = new Vector2 (ArchimatixUtils.paletteRect.x + ArchimatixUtils.paletteRect.width,   ArchimatixUtils.paletteRect.y + cur_y + lineHgt / 2);
             *      bRect.y = cur_y-2;
             *      lRect.y = cur_y;
             *
             *      cur_y = ParameterSplineGUI.OnGUI_Spline(new Rect(x1, cur_y, width,lineHgt), editor, shp.difference);
             *
             *      tmp_boolval = (shp.combineType == AXShape.CombineType.Difference);
             *      EditorGUI.BeginChangeCheck ();
             *      tmp_boolval = EditorGUI.Toggle (bRect, "",  tmp_boolval);
             *      if (EditorGUI.EndChangeCheck ()) {
             *              Undo.RegisterCompleteObjectUndo (shp.Parent.model, "value change for combineType" );
             *              shp.combineType = AXShape.CombineType.Difference;
             *              shp.parametricObject.model.autobuild();
             *      }
             *
             *      // difference
             *      shp.differenceRail.inputPoint   = new Vector2 (ArchimatixUtils.paletteRect.x,                                   ArchimatixUtils.paletteRect.y + cur_y + lineHgt / 2);
             *      shp.differenceRail.outputPoint  = new Vector2 (ArchimatixUtils.paletteRect.x + ArchimatixUtils.paletteRect.width,   ArchimatixUtils.paletteRect.y + cur_y + lineHgt / 2);
             *
             *      bRect.y = cur_y-2;
             *
             *      cur_y = ParameterSplineGUI.OnGUI_Spline(new Rect(x1, cur_y, width, lineHgt), editor, shp.differenceRail);
             *
             *      tmp_boolval = (shp.combineType == AXShape.CombineType.DifferenceRail);
             *      EditorGUI.BeginChangeCheck ();
             *      tmp_boolval = EditorGUI.Toggle (bRect, "",  tmp_boolval);
             *      if (EditorGUI.EndChangeCheck ()) {
             *              Undo.RegisterCompleteObjectUndo (shp.Parent.model, "value change for combineType" );
             *              shp.combineType = AXShape.CombineType.DifferenceRail;
             *              shp.parametricObject.model.autobuild();
             *      }
             *
             *      cur_y += gap;
             *
             *
             *
             *      // INTERSECTION
             *      shp.intersection.inputPoint     = new Vector2 (ArchimatixUtils.paletteRect.x,                                   ArchimatixUtils.paletteRect.y + cur_y + lineHgt / 2);
             *      shp.intersection.outputPoint    = new Vector2 (ArchimatixUtils.paletteRect.x + ArchimatixUtils.paletteRect.width,   ArchimatixUtils.paletteRect.y + cur_y + lineHgt / 2);
             *      bRect.y = cur_y-2;
             *
             *      cur_y = ParameterSplineGUI.OnGUI_Spline(new Rect(x1, cur_y, width, lineHgt), editor, shp.intersection);
             *
             *      tmp_boolval = (shp.combineType == AXShape.CombineType.Intersection);
             *      EditorGUI.BeginChangeCheck ();
             *      tmp_boolval = EditorGUI.Toggle (bRect, "",  tmp_boolval);
             *      if (EditorGUI.EndChangeCheck ()) {
             *              Undo.RegisterCompleteObjectUndo (shp.Parent.model, "value change for combineType" );
             *              Debug.Log("YA");
             *              shp.combineType = AXShape.CombineType.Intersection;
             *              shp.parametricObject.model.autobuild();
             *      }
             *
             *
             *      // INTERSECTION_RAIL
             *      shp.intersectionRail.inputPoint     = new Vector2 (ArchimatixUtils.paletteRect.x,                                   ArchimatixUtils.paletteRect.y + cur_y + lineHgt / 2);
             *      shp.intersectionRail.outputPoint    = new Vector2 (ArchimatixUtils.paletteRect.x + ArchimatixUtils.paletteRect.width,   ArchimatixUtils.paletteRect.y + cur_y + lineHgt / 2);
             *      bRect.y = cur_y-2;
             *
             *      cur_y = ParameterSplineGUI.OnGUI_Spline(new Rect(x1, cur_y, width, lineHgt), editor, shp.intersectionRail);
             *
             *      tmp_boolval = (shp.combineType == AXShape.CombineType.IntersectionRail);
             *      EditorGUI.BeginChangeCheck ();
             *      tmp_boolval = EditorGUI.Toggle (bRect, "",  tmp_boolval);
             *      if (EditorGUI.EndChangeCheck ()) {
             *              Undo.RegisterCompleteObjectUndo (shp.Parent.model, "value change for combineType" );
             *              shp.combineType = AXShape.CombineType.IntersectionRail;
             *              shp.parametricObject.model.autobuild();
             *      }
             *
             *      cur_y += gap;
             *
             *
             *
             *      // union
             *      shp.union.inputPoint    = new Vector2 (ArchimatixUtils.paletteRect.x,                                   ArchimatixUtils.paletteRect.y + cur_y + lineHgt / 2);
             *      shp.union.outputPoint   = new Vector2 (ArchimatixUtils.paletteRect.x + ArchimatixUtils.paletteRect.width,   ArchimatixUtils.paletteRect.y + cur_y + lineHgt / 2);
             *      bRect.y = cur_y-2;
             *
             *      cur_y = ParameterSplineGUI.OnGUI_Spline(new Rect(x1, cur_y, width, lineHgt), editor, shp.union);
             *
             *      tmp_boolval = (shp.combineType == AXShape.CombineType.Union);
             *      EditorGUI.BeginChangeCheck ();
             *      tmp_boolval = EditorGUI.Toggle (bRect, "",  tmp_boolval);
             *      if (EditorGUI.EndChangeCheck ()) {
             *              Undo.RegisterCompleteObjectUndo (shp.Parent.model, "value change for combineType" );
             *              shp.combineType = AXShape.CombineType.Union;
             *              shp.parametricObject.model.autobuild();
             *      }
             *
             *      cur_y += gap;
             *
             *
             *
             *      // grouped
             *      if (shp.grouped == null || shp.grouped.Type == AXParameter.DataType.Float)
             *              shp.grouped             = shp.createSplineParameter(AXParameter.ParameterType.Output, "Grouped");
             *
             *      shp.grouped.inputPoint  = new Vector2 (ArchimatixUtils.paletteRect.x,                                   ArchimatixUtils.paletteRect.y + cur_y + lineHgt / 2);
             *      shp.grouped.outputPoint     = new Vector2 (ArchimatixUtils.paletteRect.x + ArchimatixUtils.paletteRect.width,   ArchimatixUtils.paletteRect.y + cur_y + lineHgt / 2);
             *      bRect.y = cur_y-2;
             *
             *      cur_y = ParameterSplineGUI.OnGUI_Spline(new Rect(x1, cur_y, width, lineHgt), editor, shp.grouped);
             *
             *      tmp_boolval = (shp.combineType == AXShape.CombineType.Grouped);
             *      EditorGUI.BeginChangeCheck ();
             *      tmp_boolval = EditorGUI.Toggle (bRect, "",  tmp_boolval);
             *      if (EditorGUI.EndChangeCheck ()) {
             *              Undo.RegisterCompleteObjectUndo (shp.Parent.model, "value change for combineType" );
             *              shp.combineType = AXShape.CombineType.Grouped;
             *              shp.parametricObject.model.autobuild();
             *      }
             *
             *
             *
             *
             *      ArchimatixUtils.cur_x -= ArchimatixUtils.indent;
             *
             *
             * }
             */
            //Archimatix.cur_x -= Archimatix.indent;
            //cur_y += lineHgt;
        }


        GUI.backgroundColor = origBG;

        return(cur_y);
    }     // OnGUI
Beispiel #2
0
        // return the height of this gui area
        public static void OnGUI(int win_id, AXNodeGraphEditorWindow editor, AXParametricObject po)
        {
            Event e = Event.current;

            AXModel model = editor.model;


            AXParameter p;

            string buttonLabel;
            Rect   buttonRect;

            Color inactiveColor = new Color(.7f, .7f, .7f);


            Color oldBackgroundColor = GUI.backgroundColor;



            // START LAYOUT OF INNER PALETTE


            // Horizontal layput
            float winMargin  = ArchimatixUtils.indent;
            float innerWidth = po.rect.width - 2 * winMargin;



            int x1 = 10;
            int x2 = 20;

            // vertical layut
            int cur_y   = 25;
            int gap     = ArchimatixUtils.gap;
            int lineHgt = ArchimatixUtils.lineHgt;


//		if (EditorGUIUtility.isProSkin)
//		{
//			GUI.color = po.generator.GUIColorPro;
//			GUI.backgroundColor = Color.Lerp(po.generator.GUIColorPro, Color.white, .5f) ;
//		}
//		else
//		{
//			GUI.color = po.generator.GUIColor;
//			GUI.backgroundColor = Color.Lerp(po.generator.GUIColor, Color.white, .5f) ;
//
//		}



            // DRAW HIGHLIGHT AROUND SELECTED NODE PALETTE
            if (model.isSelected(po))
            {
                float pad     = (EditorGUIUtility.isProSkin) ? 1 : 1;
                Rect  outline = new Rect(0, 0, po.rect.width - pad, po.rect.height - pad);
                Handles.color = Color.white;

                Handles.DrawSolidRectangleWithOutline(outline, new Color(1, 1, 1, 0f), ArchimatixEngine.AXGUIColors ["NodePaletteHighlightRect"]);
                //Handles.DrawSolidRectangleWithOutline(outline, new Color(.1f, .1f, .3f, .05f), new Color(.1f, .1f, .8f, 1f));
            }


            // TITLE

            if (GUI.Button(new Rect(x1, cur_y, innerWidth - lineHgt * 2 - 6, lineHgt * 2), po.Name))
            {
//				po.isEditing = true;
//				for (int i = 0; i < po.parameters.Count; i++) {
//					p = po.parameters [i];
//					p.isEditing = false;
//				}
                po.isMini = false;
            }


            if (ArchimatixEngine.nodeIcons.ContainsKey(po.Type))
            {
                EditorGUI.DrawTextureTransparent(new Rect(x1 + innerWidth - lineHgt * 2 - 4, cur_y, lineHgt * 2, lineHgt * 2), ArchimatixEngine.nodeIcons [po.Type], ScaleMode.ScaleToFit, 1.0F);
            }


            cur_y += lineHgt + 2 * gap;



            // DO THUMBNAIL / DROP_ZONE



            int bottomPadding    = 55;
            int splineCanvasSize = (int)(po.rect.width - 60);

            editor.mostRecentThumbnailRect = new Rect(x1, cur_y + lineHgt, innerWidth, innerWidth);

            Rect lowerRect = new Rect(0, cur_y - 50, po.rect.width, po.rect.width);


            if (po.thumbnailState == ThumbnailState.Open)
            {
                //if (po.Output != null && po.Output.Type == AXParameter.DataType.Spline)
                if (po.is2D())
                {
                    AXParameter output_p = po.generator.getPreferredOutputParameter();
                    if (po.generator.hasOutputsReady())
                    {
                        if (ArchimatixEngine.nodeIcons.ContainsKey("Blank"))
                        {
                            EditorGUI.DrawTextureTransparent(editor.mostRecentThumbnailRect, ArchimatixEngine.nodeIcons ["Blank"], ScaleMode.ScaleToFit, 1.0F);
                        }

                        Color color = po.thumbnailLineColor;

                        if (color.Equals(Color.clear))
                        {
                            color = Color.magenta;
                        }

                        GUIDrawing.DrawPathsFit(output_p, new Vector2(po.rect.width / 2, cur_y + po.rect.width / 2), po.rect.width - 60, ArchimatixEngine.AXGUIColors ["ShapeColor"]);
                    }
                    else if (ArchimatixEngine.nodeIcons.ContainsKey(po.Type.ToString()))
                    {
                        EditorGUI.DrawTextureTransparent(editor.mostRecentThumbnailRect, ArchimatixEngine.nodeIcons [po.Type], ScaleMode.ScaleToFit, 1.0F);
                    }
                }
                else
                {
                    //Debug.Log ("po.renTex.IsCreated()="+po.renTex.IsCreated());

                    //Debug.Log (po.renTex + " :::::::::::::::::::::::--::



                    if (po.generator is PrefabInstancer && po.prefab != null)
                    {
                        Texture2D thumber = AssetPreview.GetAssetPreview(po.prefab);
                        if (e.type == EventType.Repaint)
                        {
                            if (thumber != null)
                            {
                                EditorGUI.DrawTextureTransparent(editor.mostRecentThumbnailRect, thumber, ScaleMode.ScaleToFit, 1.0F);
                            }
                            else
                            {
                                EditorGUI.DrawTextureTransparent(editor.mostRecentThumbnailRect, ArchimatixEngine.nodeIcons [po.Type], ScaleMode.ScaleToFit, 1.0F);
                            }
                        }
                    }
                    else if (((po.Output != null && po.Output.meshes != null && po.Output.meshes.Count > 0) || po.generator is MaterialTool) && (po.renTex != null || po.thumbnail != null))
                    {                   //if ( po.thumbnail != null )
                        //Debug.Log("thumb " + po.renTex);
                        if (e.type == EventType.Repaint)
                        {
                            EditorGUI.DrawTextureTransparent(editor.mostRecentThumbnailRect, po.renTex, ScaleMode.ScaleToFit, 1.0F);


                            // DROP ZONE

                            if (po.generator is Grouper && editor.editorState == AXNodeGraphEditorWindow.EditorState.DraggingNodePalette && editor.mouseIsDownOnPO != po && po != model.currentWorkingGroupPO)
                            {
                                if (editor.mostRecentThumbnailRect.Contains(e.mousePosition))
                                {
                                    EditorGUI.DrawTextureTransparent(editor.mostRecentThumbnailRect, editor.dropZoneOverTex, ScaleMode.ScaleToFit, 1.0F);
                                    editor.OverDropZoneOfPO = po;
                                }
                                else
                                {
                                    EditorGUI.DrawTextureTransparent(editor.mostRecentThumbnailRect, editor.dropZoneTex, ScaleMode.ScaleToFit, 1.0F);
                                }
                            }
                        }
                        //else
                        //	GUI.DrawTexture(editor.mostRecentThumbnailRect, po.thumbnail, ScaleMode.ScaleToFit, false, 1.0F);



                        if (editor.mostRecentThumbnailRect.Contains(e.mousePosition) || editor.draggingThumbnailOfPO == po)
                        {
                            Rect orbitButtonRect = new Rect(x1 + innerWidth - 16 - 3, cur_y + lineHgt + 3, 16, 16);

                            if (e.command || e.control)
                            {
                                EditorGUI.DrawTextureTransparent(orbitButtonRect, editor.dollyIconTex);
                            }
                            else
                            {
                                EditorGUI.DrawTextureTransparent(orbitButtonRect, editor.orbitIconTex);
                            }


                            if (e.type == EventType.MouseDown && orbitButtonRect.Contains(e.mousePosition))
                            {
                                model.selectOnlyPO(po);
                                editor.draggingThumbnailOfPO = po;
                                e.Use();
                            }
                        }
                    }
                    else if (ArchimatixEngine.nodeIcons.ContainsKey(po.Type.ToString()))
                    {
                        EditorGUI.DrawTextureTransparent(editor.mostRecentThumbnailRect, ArchimatixEngine.nodeIcons [po.Type], ScaleMode.ScaleToFit, 1.0F);

                        // DROP ZONE

                        if (po.generator is Grouper && editor.editorState == AXNodeGraphEditorWindow.EditorState.DraggingNodePalette && editor.mouseIsDownOnPO != po && po != model.currentWorkingGroupPO)
                        {
                            if (editor.mostRecentThumbnailRect.Contains(e.mousePosition))
                            {
                                EditorGUI.DrawTextureTransparent(editor.mostRecentThumbnailRect, editor.dropZoneOverTex, ScaleMode.ScaleToFit, 1.0F);
                                editor.OverDropZoneOfPO = po;
                            }
                            else
                            {
                                EditorGUI.DrawTextureTransparent(editor.mostRecentThumbnailRect, editor.dropZoneTex, ScaleMode.ScaleToFit, 1.0F);
                            }
                        }
                    }
                }

                cur_y += lineHgt + bottomPadding + splineCanvasSize + gap;

                po.rect.height = cur_y;
                cur_y         += 4 * gap;
            }
            else
            {
                // no thumbnail
                cur_y         += 2 * lineHgt;
                po.rect.height = cur_y;
            }



            // INLETS
            // INPUT ITEMS
            // Parameter Lines

            //for (int i=0; i<po.parameters.Count; i++) {
            if ((po.inputControls != null && po.inputControls.children != null))
            {
                for (int i = 0; i < po.inputControls.children.Count; i++)
                {
                    p = (AXParameter)po.inputControls.children [i];


                    if (p.PType != AXParameter.ParameterType.Input)
                    {
                        continue;
                    }


                    //if ( p.DependsOn != null && !p.DependsOn.Parent.isOpen && ! p.Name.Contains ("External"))
                    //	continue;


                    //if (parametricObjects_Property != null)
                    if (model.parametricObjects != null)
                    {
                        // these points are world, not rlative to the this GUIWindow
                        p.inputPoint  = new Vector2(po.rect.x, po.rect.y + 100);
                        p.outputPoint = new Vector2(po.rect.x + po.rect.width, po.rect.y + cur_y + lineHgt / 2);
                    }
                }
            }



            // OUTLETS

            if (po.outputsNode != null)
            {
                for (int i = 0; i < po.outputsNode.children.Count; i++)
                {
                    p = (AXParameter)po.outputsNode.children [i];

                    if (p == null)
                    {
                        continue;
                    }

                    //if (p.hasInputSocket || ! p.hasOutputSocket)
                    if (p.PType != AXParameter.ParameterType.Output)
                    {
                        continue;
                    }


                    //if (parametricObjects_Property != null)
                    if (model.parametricObjects != null)
                    {
                        // these points are world, not relative to the this GUIWindow
                        p.inputPoint  = new Vector2(po.rect.x, po.rect.y + cur_y + lineHgt / 2);
                        p.outputPoint = new Vector2(po.rect.x + po.rect.width, po.rect.y + po.rect.width);


                        Rect pRect = new Rect(x1, cur_y, innerWidth, lineHgt);


                        //if (parameters_Property.arraySize > i)
                        if (po.parameters != null && po.parameters.Count > i)
                        {
                            int hgt = 0;

                            if (po.is2D())
                            {
                                hgt   = ParameterSplineGUI.OnGUI_Spline(pRect, editor, p);
                                cur_y = hgt + gap;
                            }
                            else
                            {
                                //hgt = ParameterGUI.OnGUI (pRect, editor, p);
                                //cur_y += hgt + gap;

                                Color dataColor = editor.getDataColor(p.Type);

                                // PERSONAL
                                if (!EditorGUIUtility.isProSkin)
                                {
                                    dataColor = new Color(dataColor.r, dataColor.b, dataColor.g, .3f);
                                }

                                GUI.color = dataColor;

                                buttonLabel = (editor.OutputParameterBeingDragged == p) ? "-" : "";
                                buttonRect  = new Rect(p.Parent.rect.width - pRect.height - 10, p.Parent.rect.width - 10, 2 * ArchimatixEngine.buttonSize, 2 * ArchimatixEngine.buttonSize);

                                // button color
                                if (editor.InputParameterBeingDragged != null)
                                {
                                    if (editor.InputParameterBeingDragged.Type != p.Type)
                                    {
                                        GUI.backgroundColor = inactiveColor;
                                    }
                                    else if (buttonRect.Contains(Event.current.mousePosition))
                                    {
                                        GUI.backgroundColor = Color.white;
                                    }
                                }
                                else if (editor.OutputParameterBeingDragged != null)
                                {
                                    if (editor.OutputParameterBeingDragged == p)
                                    {
                                        GUI.backgroundColor = Color.white;
                                    }
                                    else
                                    {
                                        GUI.backgroundColor = inactiveColor;
                                    }
                                }


                                if (GUI.Button(buttonRect, buttonLabel))
                                {
                                    if (editor.InputParameterBeingDragged != null && editor.InputParameterBeingDragged.Type != p.Type)
                                    {
                                        editor.InputParameterBeingDragged = null;
                                    }
                                    else
                                    {
                                        editor.outputSocketClicked(p);
                                    }
                                }
                            }
                        }
                    }
                }
            }



            // FOOTER //



            // STATS
            if (po.stats_VertCount > 0 || po.generator is MaterialTool)
            {
                string statsText;

                if (po.generator is MaterialTool)
                {
                    statsText = (po.generator as MaterialTool).texelsPerUnit.ToString("F0") + " Texels/Unit";
                }
                else
                {
                    statsText = po.stats_VertCount + " verts";

                    if (po.stats_TriangleCount > 0)
                    {
                        statsText += ", " + po.stats_TriangleCount + " tris";
                    }
                }

                GUIStyle   statlabelStyle        = GUI.skin.GetStyle("Label");
                TextAnchor prevStatTextAlignment = statlabelStyle.alignment;
                statlabelStyle.alignment    = TextAnchor.MiddleLeft;
                EditorGUIUtility.labelWidth = 500;
                GUI.Label(new Rect(10, po.rect.height - x2 + 2, 500, lineHgt), statsText);
                statlabelStyle.alignment = prevStatTextAlignment;
            }



            if (e.type == EventType.MouseDown && lowerRect.Contains(e.mousePosition))
            {
                editor.clearFocus();
                GUI.FocusWindow(po.guiWindowId);
            }

            // WINDOW RESIZE
            buttonRect = new Rect(po.rect.width - 16, po.rect.height - 17, 14, 14);
            if (e.type == EventType.MouseDown && buttonRect.Contains(e.mousePosition))
            {
                Undo.RegisterCompleteObjectUndo(model, "GUI Window Resize");

                editor.editorState             = AXNodeGraphEditorWindow.EditorState.DragResizingNodePalleteWindow;
                editor.DraggingParameticObject = po;
            }
            //GUI.Button ( buttonRect, "∆", GUIStyle.none);
            GUI.Button(buttonRect, editor.resizeCornerTexture, GUIStyle.none);


            if (e.type == EventType.MouseDown && buttonRect.Contains(e.mousePosition))
            {
            }

            //cur_y += lineHgt + gap;

            // Window title bar is the dragable area
            //GUI.DragWindow(headerRect);

            if (editor.draggingThumbnailOfPO == null || editor.draggingThumbnailOfPO != po)
            {
                GUI.DragWindow();
            }
        }
Beispiel #3
0
    }     // OnGUI

    public static int displayOutput(Rect pRect, AXNodeGraphEditorWindow editor, AXShape shp)
    {
        float cur_x = ArchimatixUtils.cur_x;
        //float box_x = cur_x + ArchimatixUtils.indent;
        float box_w = ArchimatixUtils.paletteRect.width - cur_x - 3 * ArchimatixUtils.indent;

        int x1      = (int)pRect.x - ArchimatixUtils.indent;
        int cur_y   = (int)pRect.y;
        int width   = (int)pRect.width;
        int lineHgt = ArchimatixUtils.lineHgt;
        int gap     = 5;

        Rect boxRect = pRect;

        boxRect = new Rect(cur_x + ArchimatixUtils.indent, cur_y, box_w, ArchimatixUtils.lineHgt);

        Rect lRect = new Rect(x1 + 11, cur_y, 50, lineHgt);


        Rect bRect = boxRect;

        lRect.y = cur_y;


        //cur_y += lineHgt;
        ArchimatixUtils.cur_x += ArchimatixUtils.indent;

        bool tmp_boolval;

        bRect.x = ArchimatixUtils.indent * 3 + 4;    //width-lineHgt;


        // difference
        shp.difference.inputPoint  = new Vector2(ArchimatixUtils.paletteRect.x, ArchimatixUtils.paletteRect.y + cur_y + lineHgt / 2);
        shp.difference.outputPoint = new Vector2(ArchimatixUtils.paletteRect.x + ArchimatixUtils.paletteRect.width, ArchimatixUtils.paletteRect.y + cur_y + lineHgt / 2);
        bRect.y = cur_y - 1;
        lRect.y = cur_y;

        cur_y = ParameterSplineGUI.OnGUI_Spline(new Rect(x1, cur_y, width, lineHgt), editor, shp.difference);

        tmp_boolval = (shp.combineType == AXShape.CombineType.Difference);
        EditorGUI.BeginChangeCheck();
        tmp_boolval = EditorGUI.Toggle(bRect, "", tmp_boolval);
        if (EditorGUI.EndChangeCheck())
        {
            Undo.RegisterCompleteObjectUndo(shp.Parent.model, "value change for combineType");
            shp.combineType = AXShape.CombineType.Difference;
            shp.parametricObject.model.generate();
        }

        // difference
        shp.differenceRail.inputPoint  = new Vector2(ArchimatixUtils.paletteRect.x, ArchimatixUtils.paletteRect.y + cur_y + lineHgt / 2);
        shp.differenceRail.outputPoint = new Vector2(ArchimatixUtils.paletteRect.x + ArchimatixUtils.paletteRect.width, ArchimatixUtils.paletteRect.y + cur_y + lineHgt / 2);

        bRect.y = cur_y - 1;

        cur_y = ParameterSplineGUI.OnGUI_Spline(new Rect(x1, cur_y, width, lineHgt), editor, shp.differenceRail);

        tmp_boolval = (shp.combineType == AXShape.CombineType.DifferenceRail);
        EditorGUI.BeginChangeCheck();
        tmp_boolval = EditorGUI.Toggle(bRect, "", tmp_boolval);
        if (EditorGUI.EndChangeCheck())
        {
            Undo.RegisterCompleteObjectUndo(shp.Parent.model, "value change for combineType");
            shp.combineType = AXShape.CombineType.DifferenceRail;
            shp.parametricObject.model.generate();
        }

        cur_y += gap;



        // INTERSECTION
        shp.intersection.inputPoint  = new Vector2(ArchimatixUtils.paletteRect.x, ArchimatixUtils.paletteRect.y + cur_y + lineHgt / 2);
        shp.intersection.outputPoint = new Vector2(ArchimatixUtils.paletteRect.x + ArchimatixUtils.paletteRect.width, ArchimatixUtils.paletteRect.y + cur_y + lineHgt / 2);
        bRect.y = cur_y - 1;

        cur_y = ParameterSplineGUI.OnGUI_Spline(new Rect(x1, cur_y, width, lineHgt), editor, shp.intersection);

        tmp_boolval = (shp.combineType == AXShape.CombineType.Intersection);
        EditorGUI.BeginChangeCheck();
        tmp_boolval = EditorGUI.Toggle(bRect, "", tmp_boolval);
        if (EditorGUI.EndChangeCheck())
        {
            Undo.RegisterCompleteObjectUndo(shp.Parent.model, "value change for combineType");
            shp.combineType = AXShape.CombineType.Intersection;
            shp.parametricObject.model.generate();
        }


        // INTERSECTION_RAIL
        shp.intersectionRail.inputPoint  = new Vector2(ArchimatixUtils.paletteRect.x, ArchimatixUtils.paletteRect.y + cur_y + lineHgt / 2);
        shp.intersectionRail.outputPoint = new Vector2(ArchimatixUtils.paletteRect.x + ArchimatixUtils.paletteRect.width, ArchimatixUtils.paletteRect.y + cur_y + lineHgt / 2);
        bRect.y = cur_y - 1;

        cur_y = ParameterSplineGUI.OnGUI_Spline(new Rect(x1, cur_y, width, lineHgt), editor, shp.intersectionRail);

        tmp_boolval = (shp.combineType == AXShape.CombineType.IntersectionRail);
        EditorGUI.BeginChangeCheck();
        tmp_boolval = EditorGUI.Toggle(bRect, "", tmp_boolval);
        if (EditorGUI.EndChangeCheck())
        {
            Undo.RegisterCompleteObjectUndo(shp.Parent.model, "value change for combineType");
            shp.combineType = AXShape.CombineType.IntersectionRail;
            shp.parametricObject.model.generate();
        }

        cur_y += gap;



        // union
        shp.union.inputPoint  = new Vector2(ArchimatixUtils.paletteRect.x, ArchimatixUtils.paletteRect.y + cur_y + lineHgt / 2);
        shp.union.outputPoint = new Vector2(ArchimatixUtils.paletteRect.x + ArchimatixUtils.paletteRect.width, ArchimatixUtils.paletteRect.y + cur_y + lineHgt / 2);
        bRect.y = cur_y - 1;

        cur_y = ParameterSplineGUI.OnGUI_Spline(new Rect(x1, cur_y, width, lineHgt), editor, shp.union);

        tmp_boolval = (shp.combineType == AXShape.CombineType.Union);
        EditorGUI.BeginChangeCheck();
        tmp_boolval = EditorGUI.Toggle(bRect, "", tmp_boolval);
        if (EditorGUI.EndChangeCheck())
        {
            Undo.RegisterCompleteObjectUndo(shp.Parent.model, "value change for combineType");
            shp.combineType = AXShape.CombineType.Union;
            shp.parametricObject.model.generate();
        }

        cur_y += gap;



        // grouped
        if (shp.grouped == null || shp.grouped.Type == AXParameter.DataType.Float)
        {
            shp.grouped = shp.createSplineParameter(AXParameter.ParameterType.Output, "Grouped");
        }

        shp.grouped.inputPoint  = new Vector2(ArchimatixUtils.paletteRect.x, ArchimatixUtils.paletteRect.y + cur_y + lineHgt / 2);
        shp.grouped.outputPoint = new Vector2(ArchimatixUtils.paletteRect.x + ArchimatixUtils.paletteRect.width, ArchimatixUtils.paletteRect.y + cur_y + lineHgt / 2);
        bRect.y = cur_y - 1;

        cur_y = ParameterSplineGUI.OnGUI_Spline(new Rect(x1, cur_y, width, lineHgt), editor, shp.grouped);

        tmp_boolval = (shp.combineType == AXShape.CombineType.Grouped);
        EditorGUI.BeginChangeCheck();
        tmp_boolval = EditorGUI.Toggle(bRect, "", tmp_boolval);
        if (EditorGUI.EndChangeCheck())
        {
            Undo.RegisterCompleteObjectUndo(shp.Parent.model, "value change for combineType");
            shp.combineType = AXShape.CombineType.Grouped;
            shp.parametricObject.model.generate();
        }



        ArchimatixUtils.cur_x -= ArchimatixUtils.indent;



        //Archimatix.cur_x -= Archimatix.indent;
        cur_y += lineHgt * 2;

        return(cur_y);
    }