Esempio n. 1
0
    private void OnGUI()
    {
        // styles
        var titleLabelStyle = new GUIStyle(GUI.skin.label)
        {
            alignment = TextAnchor.MiddleCenter, fontSize = 14
        };
        var subtitleLabelStyle = new GUIStyle(GUI.skin.label)
        {
            alignment = TextAnchor.MiddleCenter, fontSize = 10
        };

        GUILayout.Space(10);
        EditorGUILayout.LabelField("HD Map Import", titleLabelStyle, GUILayout.ExpandWidth(true));
        GUILayout.Space(5);
        EditorGUILayout.LabelField("", GUI.skin.horizontalSlider);
        GUILayout.Space(10);

        EditorGUILayout.HelpBox("Settings", UnityEditor.MessageType.Info);
        var selectedNew = EditorGUILayout.Popup("Import Format", Selected, importFormats);

        GUILayout.Space(10);


        if (Selected != selectedNew)
        {
            FileName = "";
            Selected = selectedNew;
        }

        if (importFormats[Selected] == "Lanelet2 Map")
        {
            EditorGUILayout.HelpBox("Select File...", UnityEditor.MessageType.Info);
            GUILayout.BeginHorizontal();
            FileName = EditorGUILayout.TextField(FileName);
            if (GUILayout.Button("...", GUILayout.ExpandWidth(false)))
            {
                var path = EditorUtility.OpenFilePanel("Open Lanelet2 HD Map", "", "osm");
                if (!string.IsNullOrEmpty(path))
                {
                    FileName = path;
                }
            }
            GUILayout.EndHorizontal();
        }

        //if (importFormats[Selected] == "OpenDRIVE Map")
        //{
        //    EditorGUILayout.HelpBox("Select File...", UnityEditor.MessageType.Info);
        //    GUILayout.BeginHorizontal();
        //    FileName = EditorGUILayout.TextField(FileName);
        //    if (GUILayout.Button("...", GUILayout.ExpandWidth(false)))
        //    {
        //        var path = EditorUtility.OpenFilePanel("Open OpenDRIVE Map", "", "xodr");
        //        if (!string.IsNullOrEmpty(path))
        //        {
        //            FileName = path;
        //        }
        //    }
        //    GUILayout.EndHorizontal();
        //}

        if (GUILayout.Button(new GUIContent("Import", $"Import {importFormats[Selected]}")))
        {
            if (string.IsNullOrEmpty(FileName))
            {
                EditorUtility.DisplayDialog("Error", "Please specify input file/folder name!", "OK");
                return;
            }

            if (importFormats[Selected] == "Lanelet2 Map")
            {
                LaneLet2MapImporter laneLet2MapImporter = new LaneLet2MapImporter();
                laneLet2MapImporter.ImportLanelet2Map(FileName);
            }

            //if (importFormats[Selected] == "OpenDRIVE Map")
            //{
            //    OpenDriveMapImporter openDriveMapImporter = new OpenDriveMapImporter();
            //    openDriveMapImporter.ImportOpenDriveMap(FileName);
            //}
        }
    }
Esempio n. 2
0
    private void OnGUI()
    {
        // styles
        var titleLabelStyle = new GUIStyle(GUI.skin.label)
        {
            alignment = TextAnchor.MiddleCenter, fontSize = 14
        };
        var subtitleLabelStyle = new GUIStyle(GUI.skin.label)
        {
            alignment = TextAnchor.MiddleCenter, fontSize = 10
        };

        GUILayout.Space(10);
        EditorGUILayout.LabelField("HD Map Import", titleLabelStyle, GUILayout.ExpandWidth(true));
        GUILayout.Space(5);
        EditorGUILayout.LabelField("", GUI.skin.horizontalSlider);
        GUILayout.Space(10);

        EditorGUILayout.HelpBox("Settings", UnityEditor.MessageType.Info);
        var selectedNew = EditorGUILayout.Popup("Import Format", Selected, importFormats);

        GUILayout.Space(10);


        if (Selected != selectedNew)
        {
            FileName = "";
            Selected = selectedNew;
        }

        if (importFormats[Selected] == "Apollo HD Map")
        {
            DownSampleDistanceThreshold = EditorGUILayout.FloatField(
                new GUIContent("Distance Threshold", "distance threshold to down sample imported points"),
                DownSampleDistanceThreshold);
            DownSampleDeltaThreshold = EditorGUILayout.FloatField(
                new GUIContent("Delta Threshold", "delta threshold to down sample imported turning lines"),
                DownSampleDeltaThreshold);
            IsMeshNeeded = GUILayout.Toggle(IsMeshNeeded, " Create Signal/sign Mesh?");
            SelectFile(importFormats[Selected], "bin");
        }
        else if (importFormats[Selected] == "Lanelet2 Map")
        {
            SelectFile(importFormats[Selected], "osm");
        }
        // else if (importFormats[Selected] == "OpenDRIVE Map")
        // {
        //     SelectFile(importFormats[Selected], "xodr");
        // }

        if (GUILayout.Button(new GUIContent("Import", $"Import {importFormats[Selected]}")))
        {
            if (string.IsNullOrEmpty(FileName))
            {
                EditorUtility.DisplayDialog("Error", "Please specify input file/folder name!", "OK");
                return;
            }

            if (importFormats[Selected] == "Apollo HD Map")
            {
                ApolloMapImporter ApolloMapImporter = new ApolloMapImporter(
                    DownSampleDistanceThreshold, DownSampleDeltaThreshold, IsMeshNeeded);
                ApolloMapImporter.ImportApolloMap(FileName);
            }
            else if (importFormats[Selected] == "Lanelet2 Map")
            {
                LaneLet2MapImporter laneLet2MapImporter = new LaneLet2MapImporter();
                laneLet2MapImporter.ImportLanelet2Map(FileName);
            }
            // else if (importFormats[Selected] == "OpenDRIVE Map")
            // {
            //     OpenDriveMapImporter openDriveMapImporter = new OpenDriveMapImporter();
            //     openDriveMapImporter.ImportOpenDriveMap(FileName);
            // }
        }
    }