예제 #1
0
        private void PropertyControl_AddLayer()
        {
            Layerstack  currentLayerStack = (selectedNode as Workstation).Layerstack;
            CustomLayer newCustomLayer    = new CustomLayer(currentLayerStack.CreateUniqueName(), currentLayerStack.GetSize() - 1);

            currentLayerStack.AddLayer(newCustomLayer);
            propertyControl.AddLayerToLayerConfigControl(newCustomLayer.GetLayerName(), true);
        }
예제 #2
0
        protected override void OnStart()
        {
            var scene = new Scene();
            var layer = new CustomLayer();

            Engine.ChangeScene(scene);
            scene.AddLayer(layer);
        }
예제 #3
0
        public SvgLayer CreateSvgLayer(string name)
        {
            SvgLayer layer = new SvgLayer(this, name);

            Layers.Add(layer);
            CurrentLayer = layer;
            return(layer);
        }
예제 #4
0
        public void RemoveLayer(CustomLayer layer)
        {
            _render = false;
            CancelMeasure();
            while (_isRendering)
            {
                ;
            }
            var choice = _layerList.FirstOrDefault(k => k.Layer == layer);

            if (choice != null)
            {
                choice.Layer.Dispose();
                _layerList.Remove(choice);
            }
            _render = true;
        }
예제 #5
0
 public TaskLayerList(CustomLayer layer, Task measureTask)
 {
     Layer       = layer;
     MeasureTask = measureTask;
 }
        /// <summary>
        /// Recreates a scene based on parsed JSON data (SerializableScene).
        /// </summary>
        /// <param name="scene">The scene data we parsed from JSON</param>
        /// <param name="sceneId">The unique ID of the scene, used for downloading custom objects</param>
        public void ParseSerializableScene(SerializableScene scene, string sceneId)
        {
            HideObjectsInViewMode(scene.allowSceneEdit);

            CameraModeChanger.Instance.ActiveCamera.transform.position = new Vector3(scene.camera.position.x, scene.camera.position.y, scene.camera.position.z);
            CameraModeChanger.Instance.ActiveCamera.transform.rotation = new Quaternion(scene.camera.rotation.x, scene.camera.rotation.y, scene.camera.rotation.z, scene.camera.rotation.w);

            //Apply sunlight settings
            sunSettings.SetDateTimeFromString(scene.sunTimeStamp);

            //Fixed layer settings
            buildingsLayer.Active = scene.fixedLayers.buildings.active;
            treesLayer.Active     = scene.fixedLayers.trees.active;
            groundLayer.Active    = scene.fixedLayers.ground.active;

            buildingsLayer.EnableOptions(scene.allowSceneEdit);
            treesLayer.EnableOptions(scene.allowSceneEdit);
            groundLayer.EnableOptions(scene.allowSceneEdit);

            //Create annotations
            for (int i = 0; i < scene.annotations.Length; i++)
            {
                //Create the 2D annotation
                var annotationData = scene.annotations[i];

                Annotation annotation = Instantiate(annotationPrefab, annotationsContainer);
                annotation.WorldPointerFollower.WorldPosition = new Vector3(annotationData.position.x, annotationData.position.y, annotationData.position.z);
                annotation.BodyText        = annotationData.bodyText;
                annotation.AllowEdit       = scene.allowSceneEdit;
                annotation.waitingForClick = false;

                //Create a custom annotation layer
                CustomLayer newCustomAnnotationLayer = interfaceLayers.AddNewCustomObjectLayer(annotation.gameObject, LayerType.ANNOTATION, false);
                newCustomAnnotationLayer.RenameLayer(annotationData.bodyText);
                annotation.interfaceLayer = newCustomAnnotationLayer;
                newCustomAnnotationLayer.ViewingOnly(!scene.allowSceneEdit);

                newCustomAnnotationLayer.Active = annotationData.active;
            }

            //Create all custom layers with meshes
            for (int i = 0; i < scene.customLayers.Length; i++)
            {
                SerializableScene.CustomLayer customLayer = scene.customLayers[i];
                GameObject customObject = new GameObject();
                customObject.name = customLayer.layerName;
                if (scene.allowSceneEdit)
                {
                    customObject.AddComponent <Interactable>();
                }
                ApplyLayerMaterialsToObject(customLayer, customObject);

                CustomLayer newCustomLayer = interfaceLayers.AddNewCustomObjectLayer(customObject, LayerType.OBJMODEL, false);
                newCustomLayer.ViewingOnly(!scene.allowSceneEdit);
                newCustomLayer.EnableOptions(scene.allowSceneEdit);

                newCustomLayer.Active = customLayer.active;
                newCustomLayer.GetUniqueNestedMaterials();
                newCustomLayer.UpdateLayerPrimaryColor();

                StartCoroutine(GetCustomMeshObject(customObject, sceneId, customLayer.token, customLayer.position, customLayer.rotation, customLayer.scale));
            }

            //Create all custom camera points
            for (int i = 0; i < scene.cameraPoints.Length; i++)
            {
                SerializableScene.CameraPoint cameraPoint = scene.cameraPoints[i];
                GameObject cameraObject = Instantiate(cameraPrefab);
                cameraObject.name = cameraPoint.name;
                cameraObject.transform.SetParent(camerasContainer, false);
                cameraObject.GetComponent <WorldPointFollower>().WorldPosition    = cameraPoint.position;
                cameraObject.GetComponent <FirstPersonLocation>().savedRotation   = cameraPoint.rotation;
                cameraObject.GetComponent <FirstPersonLocation>().waitingForClick = false;
                CustomLayer newCustomLayer = interfaceLayers.AddNewCustomObjectLayer(cameraObject, LayerType.CAMERA);
                newCustomLayer.Active = true;
            }

            //Set material properties for fixed layers
            SetFixedLayerProperties(buildingsLayer, scene.fixedLayers.buildings);
            SetFixedLayerProperties(treesLayer, scene.fixedLayers.trees);
            SetFixedLayerProperties(groundLayer, scene.fixedLayers.ground);
        }
        private void WriteToTable()
        {
            CustomLayer   customLayer      = (CustomLayer)cbo_layers.SelectedItem;
            IFeatureLayer featureLayer     = customLayer.FeatureLayer();
            IFeatureClass featureClass     = customLayer.FeatureClass();
            int           fieldIndexName   = featureClass.FindField(cbo_fieldname.Text);
            int           fieldIndexStatus = featureClass.FindField(FIELD_NAME);


            ISchemaLock schemaLock = (ISchemaLock)featureClass;

            try
            {
                //schemaLock.ChangeSchemaLock(esriSchemaLock.esriExclusiveSchemaLock);

                if (rb_all.Checked)
                {
                    _editor.StartOperation();

                    IFeatureCursor cursor = featureClass.Search(null, false);
                    IFields        fields = cursor.Fields;

                    IFeature feature = cursor.NextFeature();

                    while (feature != null)
                    {
                        string value  = Convert.ToString(feature.get_Value(fieldIndexName));
                        bool   exists = _fileList[value];
                        feature.set_Value(fieldIndexStatus, exists ? "Exists" : "Missing");
                        feature.Store();
                        feature = cursor.NextFeature();
                    }
                    SaveFileTypeList(GetExtension());
                    _editor.StopOperation("File Tile Exister Ran");
                }

                if (rb_selected.Checked)
                {
                    _editor.StartOperation();

                    IFeatureSelection selection = featureLayer as IFeatureSelection;
                    IEnumIDs          IDs       = selection.SelectionSet.IDs;
                    IDs.Reset();

                    int oid = IDs.Next();

                    while (oid != -1)
                    {
                        IFeature feature = featureClass.GetFeature(oid);
                        if (feature != null)
                        {
                            bool exists = _fileList[Convert.ToString(feature.get_Value(fieldIndexName))];
                            feature.set_Value(fieldIndexStatus, exists ? "Exists" : "Missing");
                            feature.Store();
                            oid = IDs.Next();
                        }
                    }
                    SaveFileTypeList(GetExtension());
                    _editor.StopOperation("File Tile Exister Ran");
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(String.Format("Could Not Get Exclusive Schmea Lock\n{0}", ex.Message));
            }
            finally
            {
                //schemaLock.ChangeSchemaLock(esriSchemaLock.esriSharedSchemaLock);
            }
        }
        private void CreateField()
        {
            if (_editor.EditState != esriEditState.esriStateNotEditing)
            {
                MessageBox.Show("Stop Editing First", MB_TITLE, MessageBoxButtons.OK, MessageBoxIcon.Information);
                return;
            }

            if (cbo_layers.SelectedIndex < 0)
            {
                MessageBox.Show("Select A Layer", MB_TITLE, MessageBoxButtons.OK, MessageBoxIcon.Information);
                return;
            }

            CustomLayer   customLayer  = (CustomLayer)cbo_layers.SelectedItem;
            IFeatureClass FeatureClass = customLayer.FeatureClass();
            IFields       fields       = FeatureClass.Fields;

            int fieldIndex = _utilitiesArcMap.FindField(FeatureClass, FIELD_NAME);

            if (fieldIndex > -1)
            {
                IField field = FeatureClass.Fields.Field[fieldIndex];
                if (field.Type != esriFieldType.esriFieldTypeString)
                {
                    if (MessageBox.Show("Field exists as wrong field type. It needs to  be 'Text' Field. Should I delete and re-create?",
                                        MB_TITLE, MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No)
                    {
                        return;
                    }
                    FeatureClass.DeleteField(field);
                }
                else
                {
                    if (field.Length < 20)
                    {
                        if (MessageBox.Show("Field exists as wrong size. It needs to  be at least 20 in length. Should I delete and re-create?",
                                            MB_TITLE, MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No)
                        {
                            return;
                        }
                        FeatureClass.DeleteField(field);
                    }
                    else
                    {
                        return;
                    }
                }
            }

            IFieldEdit2 newField = new FieldClass() as IFieldEdit2;

            newField.Name_2         = FIELD_NAME;
            newField.Type_2         = esriFieldType.esriFieldTypeString;
            newField.Length_2       = 20;
            newField.DefaultValue_2 = "Unchecked";

            ISchemaLock schemaLock = (ISchemaLock)FeatureClass;

            try
            {
                schemaLock.ChangeSchemaLock(esriSchemaLock.esriExclusiveSchemaLock);
                FeatureClass.AddField(newField);
            }
            catch
            {
                MessageBox.Show("Cannot Aquire Exclusive Lock. Did Not Add Field", MB_TITLE, MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            finally
            {
                schemaLock.ChangeSchemaLock(esriSchemaLock.esriSharedSchemaLock);
            }
        }
        private bool CheckRequirements()
        {
            if (cbo_layers.SelectedIndex < 0)
            {
                MessageBox.Show("Choose A Layer", MB_TITLE, MessageBoxButtons.OK, MessageBoxIcon.Error);
                return(false);
            }

            if (cbo_fieldname.SelectedIndex < 0)
            {
                MessageBox.Show("Choose A Field Name", MB_TITLE, MessageBoxButtons.OK, MessageBoxIcon.Error);
                return(false);
            }

            if (String.IsNullOrEmpty(cbo_extension.Text) || String.IsNullOrWhiteSpace(cbo_extension.Text))
            {
                MessageBox.Show("Set An Extension", MB_TITLE, MessageBoxButtons.OK, MessageBoxIcon.Error);
                return(false);
            }

            if (string.IsNullOrWhiteSpace(txb_folderpath.Text) || string.IsNullOrWhiteSpace(txb_folderpath.Text))
            {
                MessageBox.Show("Set A Folder Path", MB_TITLE, MessageBoxButtons.OK, MessageBoxIcon.Error);
                return(false);
            }

            if (!Directory.Exists(txb_folderpath.Text))
            {
                MessageBox.Show("Folder Path Does Not Exist", MB_TITLE, MessageBoxButtons.OK, MessageBoxIcon.Error);
                return(false);
            }

            if (!rb_all.Checked && !rb_selected.Checked)
            {
                MessageBox.Show("Choose A Method", MB_TITLE, MessageBoxButtons.OK, MessageBoxIcon.Error);
                return(false);
            }

            CustomLayer customLayer = cbo_layers.SelectedItem as CustomLayer;

            if (customLayer == null)
            {
                MessageBox.Show("Error", MB_TITLE, MessageBoxButtons.OK, MessageBoxIcon.Error);
                return(false);
            }

            IFeatureClass featureClass = customLayer.FeatureClass();

            int fieldIndex = featureClass.FindField(FIELD_NAME);

            if (fieldIndex < 0)
            {
                MessageBox.Show("Please Create Field", MB_TITLE, MessageBoxButtons.OK, MessageBoxIcon.Error);
                return(false);
            }

            IField field = featureClass.Fields.Field[fieldIndex];

            if (field.Type != esriFieldType.esriFieldTypeString)
            {
                MessageBox.Show("Recreate Field, Wrong Type (text)", MB_TITLE, MessageBoxButtons.OK, MessageBoxIcon.Error);
                return(false);
            }


            if (field.Length < 20)
            {
                MessageBox.Show("Recreate Field, Wrong Size (>= 20)", MB_TITLE, MessageBoxButtons.OK, MessageBoxIcon.Error);
                return(false);
            }

            if (rb_selected.Checked)
            {
                IFeatureSelection selection = customLayer.FeatureLayer() as IFeatureSelection;

                if (selection.SelectionSet.Count == 0)
                {
                    MessageBox.Show("Select At Least One Feature", MB_TITLE, MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return(false);
                }
            }

            if (_editor.EditState != esriEditState.esriStateEditing)
            {
                MessageBox.Show("Start and Edit Operation");
                return(false);
            }

            return(true);
        }