Ejemplo n.º 1
0
    public override void Start()
    {
        if (auxiliaryTool == null)
        {
            Debug.LogWarning(tool.Name + " Error!");
            geoController.EndOperation();
            return;
        }
        if (writeInput == null)
        {
            FormInput formInput = auxiliaryTool.FormInput();

            if (formInput != null)
            {
                inputPanel.SetFormForInput(formInput);

                inputPanel.OnValidate = (form) =>
                {
                    return(auxiliaryTool.ValidateInput(geometry, form));
                };

                inputPanel.OnClickSubmit = (form) =>
                {
                    geoController.record.SetForm(form);
                    geoController.records.Add(geoController.record);
                    addAuxiliary(geometry, form);
                };

                inputPanel.OnClickCancel = (form) =>
                {
                    geoController.EndOperation();
                };
            }
            else
            {
                addAuxiliary(geometry, null);
            }
        }
        else
        {
            addAuxiliary(geometry, writeInput);
        }
    }
Ejemplo n.º 2
0
    public override void Start()
    {
        if (auxiliaryTool == null)
        {
            Debug.LogWarning(tool.Name + " Error!");
            geoController.EndOperation();
            return;
        }

        inputPanel.SetFormForInput(auxiliaryTool.FormInput());

        inputPanel.OnValidate = (form) =>
        {
            return(auxiliaryTool.ValidateInput(geometry, form));
        };

        inputPanel.OnClickSubmit = (form) =>
        {
            Auxiliary auxiliary = auxiliaryTool.GenerateAuxiliary(geometry, form);
            auxiliary.InitWithGeometry(geometry);

            VertexUnit[] units    = auxiliary.units;
            GeoElement[] elements = auxiliary.elements;

            bool result = geometry.Assistor.AddAuxiliary(auxiliary);

            if (result)
            {
                foreach (VertexUnit unit in units)
                {
                    geometry.AddVertexUnit(unit);
                }

                foreach (GeoElement element in elements)
                {
                    geometry.AddElement(element);
                }

                AddState(auxiliary);

                geometryBehaviour.UpdateElements();
                foreach (GeoElement element in elements)
                {
                    geometryBehaviour.AddElement(element);
                }

                geometryBehaviour.UpdateSignsPosition();
                foreach (VertexUnit unit in units)
                {
                    geometryBehaviour.AddSign(unit.id);
                }


                Gizmo[] gizmos = auxiliary.gizmos;
                if (gizmos != null)
                {
                    foreach (Gizmo gizmo in gizmos)
                    {
                        geometry.AddGizmo(gizmo);
                        geometryBehaviour.AddGizmo(gizmo);
                    }
                }

                geometryBehaviour.UpdateGeometryShade();
            }
            else
            {
                // TODO
            }

            geoController.EndOperation();
        };

        inputPanel.OnClickCancel = (form) =>
        {
            geoController.EndOperation();
        };
    }