예제 #1
0
        private void OnTriggerDoublePress()
        {
            if (_appState.editSession.IsActive())
            {
                IVirgisLayer editableLayer = _appState.editSession.editableLayer;
                FeatureType  dataType      = editableLayer.featureType;
                switch (dataType)
                {
                case FeatureType.LINE:
                    if (_newFeature != null)
                    {
                        VirgisFeature temp = _lastVertex[0];
                        _lastVertex.Clear();
                        temp.UnSelected(SelectionType.SELECT);
                        // if edit mode is snap to anchor and start and end vertexes are at the same position
                        if (_appState.editSession.mode == EditSession.EditMode.SnapAnchor &&
                            _firstVertex.transform.position == temp.transform.position)
                        {
                            (_newFeature as Dataline).MakeLinearRing();
                        }
                        // complete adding line feature
                        _newFeature = null;
                    }
                    break;

                case FeatureType.POLYGON:
                    if (_newFeature != null)
                    {
                        // complete adding polygon feature
                        _newFeature = null;
                        VirgisFeature temp = _lastVertex[0];
                        _lastVertex.Clear();
                        temp.UnSelected(SelectionType.SELECT);
                    }
                    break;
                }
            }
        }
예제 #2
0
        private void OnTriggerSinglePress(Vector3 posWhenSinglePress)
        {
            if (_appState.editSession.IsActive())
            {
                IVirgisLayer editableLayer = _appState.editSession.editableLayer;
                FeatureType  dataType      = editableLayer.featureType;
                Datapoint[]  vertexes;
                switch (dataType)
                {
                case FeatureType.POINT:
                    VirgisFeature point = editableLayer.AddFeature(new Vector3[1] {
                        posWhenSinglePress
                    });
                    point.UnSelected(SelectionType.SELECT);
                    break;

                case FeatureType.LINE:
                    //Debug.Log($"ShapeAdder add Vertex");
                    if (_newFeature != null)
                    {
                        _newFeature.AddVertex(posWhenSinglePress);
                    }
                    else
                    {
                        _newFeature = editableLayer.AddFeature(new Vector3[2] {
                            posWhenSinglePress, posWhenSinglePress + Vector3.one * 0.1f
                        });
                        // get the last vertex
                        vertexes     = (_newFeature as Dataline).GetVertexes();
                        _firstVertex = vertexes[0];
                        _lastVertex.Add(vertexes[1]);
                        _firstVertex.UnSelected(SelectionType.SELECT);
                    }
                    break;

                case FeatureType.POLYGON:
                    if (_newFeature != null)
                    {
                        if (_lastVertex.Count == 1)
                        {
                            _newFeature.transform.GetComponentInChildren <Dataline>().AddVertex(posWhenSinglePress);
                        }
                        else
                        {
                            _lastVertex[0].UnSelected(SelectionType.SELECT);
                            _lastVertex.RemoveAt(0);
                        }
                    }
                    else
                    {
                        _newFeature = editableLayer.AddFeature(new Vector3[4] {
                            posWhenSinglePress, posWhenSinglePress + Vector3.right * 0.01f, posWhenSinglePress + Vector3.up * 0.01f, posWhenSinglePress
                        });
                        vertexes     = (_newFeature as Datapolygon).GetVertexes();
                        _firstVertex = vertexes[0];
                        _lastVertex.Add(vertexes[1]);
                        _lastVertex.Add(vertexes[2]);
                    }
                    break;
                }
            }
        }