private void DisplayLayersSelector(ref WMSTexture wmsTexture, WMSInfo wmsInfo, out bool layerChanged) { layerChanged = false; EditorGUILayout.BeginVertical(EditorStyles.helpBox); EditorGUILayout.LabelField("Layers"); WMSLayer[] layers = wmsInfo.layers; for (int i = 0; i < layers.Length; i++) { if (layers[i].name != "") { bool newToggleValue = EditorGUILayout.ToggleLeft(layers[i].title, (wmsTexture.LayerSelected(layers[i].name))); layerChanged |= (newToggleValue != wmsTexture.LayerSelected(layers[i].name)); wmsTexture.SetLayerSelected(layers[i].name, newToggleValue); } } if (wmsTexture.SelectedLayersNumber() == 0) { EditorGUILayout.HelpBox("No layers selected", MessageType.Warning); } EditorGUILayout.EndVertical(); }
public WMSInfo AsInfo(int zIndex) { WMSInfo info = new WMSInfo(); info.coordinateSystemId = int.Parse(this.projection.Split(':')[1]); info.url = this.url; info.layers = this.layers.ToList(); info.zIndex = zIndex; return(info); }
private void DisplayBoundingBoxSelector(ref WMSTexture wmsTexture, WMSInfo wmsInfo, out bool boundingBoxChanged) { boundingBoxChanged = false; List <string> boundingBoxesNames = wmsInfo.GetBoundingBoxesNames(wmsTexture.selectedLayers).ToList(); boundingBoxesNames.Insert(0, "Select bounding box from server"); if (boundingBoxesNames.Count > 1) { int newBoundingBoxIndex = EditorGUILayout.Popup( "BBs from server", 0, boundingBoxesNames.ToArray() ) - 1; boundingBoxChanged = (newBoundingBoxIndex != -1); if (boundingBoxChanged) { wmsTexture.SRS = wmsInfo.GetBoundingBox(wmsTexture.selectedLayers, newBoundingBoxIndex).SRS; WMSBoundingBox currentBoundingBox = wmsInfo.GetBoundingBox(wmsTexture.selectedLayers, newBoundingBoxIndex); wmsTexture.bottomLeftCoordinates = currentBoundingBox.bottomLeftCoordinates; wmsTexture.topRightCoordinates = currentBoundingBox.topRightCoordinates; wmsTexture.RequestTexturePreview(); } else { if (wmsTexture.selectedLayers.Count == 1) { // If we have one layer selected, use the SRS of its first bounding box. wmsTexture.SRS = wmsInfo.GetBoundingBox(wmsTexture.selectedLayers, 0).SRS; } } } }
public void DisplayBoundingBoxPanel(ref WMSTexture wmsTexture, ref WMSInfo wmsInfo, out bool boundingBoxChanged) { EditorGUILayout.BeginVertical(EditorStyles.helpBox); EditorGUILayout.LabelField("Bounding Box"); DisplayBoundingBoxSelector(ref wmsTexture, wmsInfo, out boundingBoxChanged); EditorGUILayout.LabelField("SRS", wmsTexture.SRS); wmsTexture.keepBoundingBoxRatio = EditorGUILayout.Toggle("Keep ratio", wmsTexture.keepBoundingBoxRatio); Vector2 newBottomLeftCoordinates = EditorGUILayout.Vector2Field( "Bottom left coords.", wmsTexture.bottomLeftCoordinates ); Vector2 newTopRightCoordinates = EditorGUILayout.Vector2Field( "Top right coords.", wmsTexture.topRightCoordinates ); UpdateBoundingBox( ref wmsTexture.bottomLeftCoordinates, ref wmsTexture.topRightCoordinates, newBottomLeftCoordinates, newTopRightCoordinates, wmsTexture.keepBoundingBoxRatio); if (GUILayout.Button("Update bounding box preview (may take a while)")) { wmsTexture.RequestTexturePreview(); } EditorGUILayout.EndVertical(); }
private void DisplayServerSelector(ref WMSTexture wmsTexture, out bool serverChanged) { serverChanged = false; DisplayServerPopup(ref wmsTexture, ref serverChanged); string newServerURL = EditorGUILayout.TextField("Server URL:", wmsTexture.serverURL); serverChanged |= (newServerURL != wmsTexture.serverURL); wmsTexture.serverURL = newServerURL; if ((wmsTexture.wmsRequestID != "") && (wmsInfoRequester.GetRequestStatus(wmsTexture.wmsRequestID) == RequestStatus.OK)) { WMSInfo wmsInfo = wmsInfoRequester.GetResponse(wmsTexture.wmsRequestID); if (!bookmarks.ServerIsBookmarked(wmsInfo.serverTitle)) { DisplayServerBookmarkButton(wmsInfo.serverTitle, wmsTexture.serverURL); //} else { // RemoveServerFromBookmarksButton (requestStatus.response.serverTitle); } } }
public override void OnInspectorGUI() { if (Application.isPlaying) { EditorGUILayout.LabelField("Currently play mode editting is not allowed"); return; } WMSTexture wmsTexture = (WMSTexture)target; bool serverChanged = false; bool layerChanged = false; bool boundingBoxChanged = false; EditorGUILayout.BeginVertical(EditorStyles.helpBox); EditorGUILayout.LabelField("Server"); DisplayServerSelector(ref wmsTexture, out serverChanged); if (serverChanged) { wmsTexture.selectedLayers.Clear(); RequestWMSInfo(ref wmsTexture); } RequestStatus requestStatus = wmsInfoRequester.GetRequestStatus(wmsTexture.wmsRequestID); if (requestStatus != RequestStatus.OK) { if (requestStatus == RequestStatus.DOWNLOADING) { EditorGUILayout.HelpBox("Downloading WMS info ...", MessageType.Info); } else if (requestStatus == RequestStatus.ERROR) { string errorLog = wmsInfoRequester.GetErrorLog(wmsTexture.wmsRequestID); EditorGUILayout.HelpBox("ERROR downloading WMS info: \n" + errorLog, MessageType.Error); } if (GUI.changed) { EditorUtility.SetDirty(wmsTexture); EditorSceneManager.MarkSceneDirty(EditorSceneManager.GetActiveScene()); } EditorGUILayout.EndVertical(); return; } WMSInfo wmsInfo = wmsInfoRequester.GetResponse(wmsTexture.wmsRequestID); EditorGUILayout.LabelField("Server title: " + wmsInfo.serverTitle); EditorGUILayout.LabelField("Server abstract: " + wmsInfo.serverAbstract); EditorGUILayout.EndVertical(); if (wmsInfo.GetLayerTitles().Length > 0) { DisplayLayersSelector(ref wmsTexture, wmsInfo, out layerChanged); if (layerChanged) { wmsTexture.RequestTexturePreview(); } if (wmsTexture.SelectedLayersNumber() > 0) { DisplayBoundingBoxPanel(ref wmsTexture, ref wmsInfo, out boundingBoxChanged); } } else { EditorGUILayout.HelpBox("No layers returned by server", MessageType.Warning); } if (wmsTexture.IsDownloading()) { EditorGUILayout.HelpBox("Downloading texture from server...", MessageType.Info); } // Mark the target assert as changed ("dirty") so Unity save it to disk. if (GUI.changed) { EditorUtility.SetDirty(wmsTexture); EditorSceneManager.MarkSceneDirty(EditorSceneManager.GetActiveScene()); } }