From 3dba0e5e87ea73e96e64bc9c9ed6e5fd7c6921f3 Mon Sep 17 00:00:00 2001 From: Riegel <alexander.riegel@hft-stuttgart.de> Date: Thu, 14 Nov 2024 13:57:38 +0100 Subject: [PATCH] Add focusing function to polygon context menu --- .../CityDoctorLocalization.properties | 1 + .../CityDoctorLocalization_de.properties | 1 + .../stuttgart/citydoctor2/gui/MainWindow.java | 43 ++++++++++++++++++- .../citydoctor2/gui/VertexClickHandler.java | 15 ++++++- 4 files changed, 58 insertions(+), 2 deletions(-) diff --git a/CityDoctorParent/CityDoctorModel/src/main/resources/CityDoctorLocalization.properties b/CityDoctorParent/CityDoctorModel/src/main/resources/CityDoctorLocalization.properties index 353fd02..f7ad545 100644 --- a/CityDoctorParent/CityDoctorModel/src/main/resources/CityDoctorLocalization.properties +++ b/CityDoctorParent/CityDoctorModel/src/main/resources/CityDoctorLocalization.properties @@ -73,6 +73,7 @@ MainWindow.verticesTab=Vertices MainWindow.attributeTab=Attributes MainWindow.logTab=Log MainWindow.globalErrorsTab=Global Errors +MainWindow.focusCityObject=Focus object OpenFileDialog.fileLabel=File: OpenFileDialog.selectBtn=Select OpenFileDialog.loadBtn=Load diff --git a/CityDoctorParent/CityDoctorModel/src/main/resources/CityDoctorLocalization_de.properties b/CityDoctorParent/CityDoctorModel/src/main/resources/CityDoctorLocalization_de.properties index 58c4a4c..9023f19 100644 --- a/CityDoctorParent/CityDoctorModel/src/main/resources/CityDoctorLocalization_de.properties +++ b/CityDoctorParent/CityDoctorModel/src/main/resources/CityDoctorLocalization_de.properties @@ -71,6 +71,7 @@ MainWindow.verticesTab=Punkte MainWindow.attributeTab=Attribute MainWindow.logTab=Log MainWindow.globalErrorsTab=Globale Fehler +MainWindow.focusCityObject=Objekt fokussieren OpenFileDialog.fileLabel=Datei: OpenFileDialog.selectBtn=Ausw\u00e4hlen OpenFileDialog.loadBtn=Laden diff --git a/CityDoctorParent/Extensions/CityDoctorGUI/src/main/java/de/hft/stuttgart/citydoctor2/gui/MainWindow.java b/CityDoctorParent/Extensions/CityDoctorGUI/src/main/java/de/hft/stuttgart/citydoctor2/gui/MainWindow.java index 6084b57..64fb535 100644 --- a/CityDoctorParent/Extensions/CityDoctorGUI/src/main/java/de/hft/stuttgart/citydoctor2/gui/MainWindow.java +++ b/CityDoctorParent/Extensions/CityDoctorGUI/src/main/java/de/hft/stuttgart/citydoctor2/gui/MainWindow.java @@ -3,6 +3,7 @@ package de.hft.stuttgart.citydoctor2.gui; import de.hft.stuttgart.citydoctor2.CityDoctorValidation; import de.hft.stuttgart.citydoctor2.check.ValidationConfiguration; import de.hft.stuttgart.citydoctor2.datastructure.BoundingBox; +import de.hft.stuttgart.citydoctor2.datastructure.CityObject; import de.hft.stuttgart.citydoctor2.datastructure.FeatureType; import de.hft.stuttgart.citydoctor2.gui.logger.GuiLogger; import de.hft.stuttgart.citydoctor2.gui.tree.FeatureNode; @@ -300,7 +301,7 @@ public class MainWindow extends Application { BorderPane bp = loader.load(); highlightController = new HighlightController(world); renderer = new Renderer(this, highlightController); - clickHandler = new VertexClickHandler(errorView, renderer, stage); + clickHandler = new VertexClickHandler(errorView, renderer, stage, this); controller = new CityDoctorController(this, highlightController, renderer); mainToolBar = new MainToolBar(stage, controller, featurePane, renderer, this); viewPane.getChildren().add(mainToolBar.getToolBar()); @@ -1145,6 +1146,46 @@ public class MainWindow extends Application { controller.setOriginBB(b); } + public void showCityObjectDetail(CityObject co) { + FeatureType coType = co.getFeatureType(); + TreeView<Renderable> featureView; + Tab featureTab; + if (coType == FeatureType.BUILDING){ + featureView = buildingsView; + featureTab = buildingsTab; + } else if (coType == FeatureType.VEGETATION){ + featureView = vegetationView; + featureTab = vegetationTab; + } else if (coType == FeatureType.TRANSPORTATION){ + featureView = transView; + featureTab = transportationTab; + } else if (coType == FeatureType.TUNNEL){ + featureView = tunnelView; + featureTab = tunnelTab; + } else if (coType == FeatureType.BRIDGE){ + featureView = bridgeView; + featureTab = bridgeTab; + } else if (coType == FeatureType.WATER){ + featureView = waterView; + featureTab = waterTab; + } else if (coType == FeatureType.LAND){ + featureView = terrainView; + featureTab = terrainTab; + } else if (coType == FeatureType.CITY_FURNITURE){ + featureView = cityFurnitureView; + featureTab = cityFurnitureTab; + } else if (coType == FeatureType.GENERIC_CITY_OBJECT){ + featureView = otherObjectsView; + featureTab = otherObjectsTab; + } else { + throw new IllegalArgumentException("unknown feature type: " + coType); + } + featurePane.getSelectionModel().select(featureTab); + searchField.setText(co.getGmlId().getGmlString()); + searchBtn.fire(); + renderer.render(co); + } + public MainToolBar getMainToolbar() { return mainToolBar; } diff --git a/CityDoctorParent/Extensions/CityDoctorGUI/src/main/java/de/hft/stuttgart/citydoctor2/gui/VertexClickHandler.java b/CityDoctorParent/Extensions/CityDoctorGUI/src/main/java/de/hft/stuttgart/citydoctor2/gui/VertexClickHandler.java index e90172e..1f4e0dc 100644 --- a/CityDoctorParent/Extensions/CityDoctorGUI/src/main/java/de/hft/stuttgart/citydoctor2/gui/VertexClickHandler.java +++ b/CityDoctorParent/Extensions/CityDoctorGUI/src/main/java/de/hft/stuttgart/citydoctor2/gui/VertexClickHandler.java @@ -25,12 +25,14 @@ public class VertexClickHandler implements ClickHandler { private TreeView<Renderable> errorView; private Renderer renderer; private Stage stage; + private MainWindow mainWindow; private ParserConfiguration config; - public VertexClickHandler(TreeView<Renderable> errorView, Renderer renderer, Stage stage) { + public VertexClickHandler(TreeView<Renderable> errorView, Renderer renderer, Stage stage, MainWindow mainWindow) { this.errorView = errorView; this.renderer = renderer; this.stage = stage; + this.mainWindow = mainWindow; } public void setConfig(ParserConfiguration config) { @@ -58,6 +60,17 @@ public class VertexClickHandler implements ClickHandler { clipboard.setContent(content); }); cMenu.getItems().add(clipMi); + + MenuItem detailMi = new MenuItem(Localization.getText("MainWindow.focusCityObject")); + detailMi.setOnAction(ea -> { + CityObject parent = p.getParent().getParent(); + if (parent instanceof BoundarySurface bs) { + parent = bs.getParent(); + } + mainWindow.showCityObjectDetail(parent); + }); + cMenu.getItems().add(detailMi); + cMenu.show(stage, me.getScreenX(), me.getScreenY()); } } -- GitLab