From b84c14caebb77f971761adf9bb7780da89eac185 Mon Sep 17 00:00:00 2001 From: Florian Dupuy Date: Wed, 13 Mar 2024 13:27:24 +0100 Subject: [PATCH] vlLayoutFactoryParameter: add checkbox for substitute internal 2wt Signed-off-by: Florian Dupuy --- diagram-viewer/pom.xml | 4 ++ .../sld/SingleLineDiagramViewController.java | 44 ++++++++++--------- .../src/main/resources/sld/view.fxml | 13 +++--- 3 files changed, 36 insertions(+), 25 deletions(-) diff --git a/diagram-viewer/pom.xml b/diagram-viewer/pom.xml index 8b61e81..31fdae1 100644 --- a/diagram-viewer/pom.xml +++ b/diagram-viewer/pom.xml @@ -109,6 +109,7 @@ com.powsybl powsybl-network-area-diagram + 4.3.0-SNAPSHOT @@ -116,14 +117,17 @@ com.powsybl powsybl-single-line-diagram-core + 4.3.0-SNAPSHOT com.powsybl powsybl-single-line-diagram-cgmes-dl-conversion + 4.3.0-SNAPSHOT com.powsybl powsybl-single-line-diagram-cgmes-layout + 4.3.0-SNAPSHOT diff --git a/diagram-viewer/src/main/java/com/powsybl/diagram/viewer/sld/SingleLineDiagramViewController.java b/diagram-viewer/src/main/java/com/powsybl/diagram/viewer/sld/SingleLineDiagramViewController.java index b222963..68fa1fd 100644 --- a/diagram-viewer/src/main/java/com/powsybl/diagram/viewer/sld/SingleLineDiagramViewController.java +++ b/diagram-viewer/src/main/java/com/powsybl/diagram/viewer/sld/SingleLineDiagramViewController.java @@ -11,25 +11,25 @@ import com.powsybl.diagram.viewer.common.AbstractDiagramViewController; import com.powsybl.iidm.network.Container; import com.powsybl.iidm.network.Network; -import com.powsybl.sld.cgmes.dl.iidm.extensions.*; -import com.powsybl.sld.cgmes.layout.*; +import com.powsybl.sld.cgmes.dl.iidm.extensions.NetworkDiagramData; +import com.powsybl.sld.cgmes.layout.CgmesVoltageLevelLayoutFactory; import com.powsybl.sld.layout.*; -import com.powsybl.sld.layout.positionbyclustering.*; +import com.powsybl.sld.layout.positionbyclustering.PositionByClustering; import com.powsybl.sld.library.ComponentLibrary; import javafx.beans.binding.Bindings; -import javafx.beans.binding.BooleanBinding; -import javafx.beans.property.*; +import javafx.beans.property.ObjectProperty; import javafx.beans.value.ChangeListener; import javafx.fxml.FXML; import javafx.fxml.FXMLLoader; import javafx.scene.Parent; import javafx.scene.control.*; -import javafx.scene.layout.*; +import javafx.scene.layout.HBox; +import javafx.scene.layout.VBox; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import java.io.IOException; -import java.util.*; +import java.util.Objects; /** * @author Thomas Adam @@ -117,6 +117,9 @@ public class SingleLineDiagramViewController extends AbstractDiagramViewControll @FXML public CheckBox disconnectorsOnBusCheckBox; + @FXML + public VBox positionVoltageLevelLayoutFactoryParameters; + @FXML public CheckBox stackFeedersCheckBox; @@ -131,6 +134,8 @@ public class SingleLineDiagramViewController extends AbstractDiagramViewControll @FXML public CheckBox substituteSingularFictitiousNodesCheckBox; + @FXML + public CheckBox substituteInternalMiddle2wtByEquipmentNodesCheckBox; @FXML public Spinner scaleFactorSpinner; @@ -253,18 +258,15 @@ private void initialize() { cgmesDLDiagramsComboBox.getSelectionModel().selectFirst(); // Default selection without Network // PositionVoltageLevelLayoutFactory - BooleanBinding disableBinding = Bindings.createBooleanBinding(() -> voltageLevelLayoutComboBox.getSelectionModel().getSelectedItem() == SingleLineDiagramModel.VoltageLevelLayoutFactoryType.POSITION_WITH_EXTENSIONS || voltageLevelLayoutComboBox.getSelectionModel().getSelectedItem() == SingleLineDiagramModel.VoltageLevelLayoutFactoryType.POSITION_BY_CLUSTERING, voltageLevelLayoutComboBox.getSelectionModel().selectedItemProperty()); - stackFeedersCheckBox.visibleProperty().bind(disableBinding); - exceptionWhenPatternUnhandledCheckBox.visibleProperty().bind(disableBinding); - handleShuntsCheckBox.visibleProperty().bind(disableBinding); - removeFictitiousNodesCheckBox.visibleProperty().bind(disableBinding); - substituteSingularFictitiousNodesCheckBox.visibleProperty().bind(disableBinding); - // Force layout calculations when nodes are shown or hidden - stackFeedersCheckBox.managedProperty().bind(stackFeedersCheckBox.visibleProperty()); - exceptionWhenPatternUnhandledCheckBox.managedProperty().bind(exceptionWhenPatternUnhandledCheckBox.visibleProperty()); - handleShuntsCheckBox.managedProperty().bind(handleShuntsCheckBox.visibleProperty()); - removeFictitiousNodesCheckBox.managedProperty().bind(removeFictitiousNodesCheckBox.visibleProperty()); - substituteSingularFictitiousNodesCheckBox.managedProperty().bind(substituteSingularFictitiousNodesCheckBox.visibleProperty()); + positionVoltageLevelLayoutFactoryParameters.visibleProperty().bind(Bindings.createBooleanBinding( + () -> voltageLevelLayoutFactoryParametersEnabled(voltageLevelLayoutComboBox.getSelectionModel().getSelectedItem()), + voltageLevelLayoutComboBox.getSelectionModel().selectedItemProperty())); + positionVoltageLevelLayoutFactoryParameters.managedProperty().bind(positionVoltageLevelLayoutFactoryParameters.visibleProperty()); // Force view layout calculations when nodes are shown or hidden + } + + private boolean voltageLevelLayoutFactoryParametersEnabled(SingleLineDiagramModel.VoltageLevelLayoutFactoryType selectedItem) { + return selectedItem == SingleLineDiagramModel.VoltageLevelLayoutFactoryType.POSITION_WITH_EXTENSIONS + || selectedItem == SingleLineDiagramModel.VoltageLevelLayoutFactoryType.POSITION_BY_CLUSTERING; } public void addListener(ChangeListener changeListener) { @@ -284,6 +286,7 @@ public void addListener(ChangeListener changeListener) { handleShuntsCheckBox.selectedProperty().addListener(changeListener); removeFictitiousNodesCheckBox.selectedProperty().addListener(changeListener); substituteSingularFictitiousNodesCheckBox.selectedProperty().addListener(changeListener); + substituteInternalMiddle2wtByEquipmentNodesCheckBox.selectedProperty().addListener(changeListener); // LayoutParameters model.addListener(changeListener); @@ -374,7 +377,8 @@ public VoltageLevelLayoutFactoryCreator getVoltageLevelLayoutFactoryCreator() { .setExceptionIfPatternNotHandled(exceptionWhenPatternUnhandledCheckBox.isSelected()) .setHandleShunts(handleShuntsCheckBox.isSelected()) .setRemoveUnnecessaryFictitiousNodes(removeFictitiousNodesCheckBox.isSelected()) - .setSubstituteSingularFictitiousByFeederNode(substituteSingularFictitiousNodesCheckBox.isSelected()); + .setSubstituteSingularFictitiousByFeederNode(substituteSingularFictitiousNodesCheckBox.isSelected()) + .setSubstituteInternalMiddle2wtByEquipmentNodes(substituteInternalMiddle2wtByEquipmentNodesCheckBox.isSelected()); SingleLineDiagramModel.VoltageLevelLayoutFactoryType type = voltageLevelLayoutComboBox.getValue(); return switch (type) { case SMART -> SmartVoltageLevelLayoutFactory::new; diff --git a/diagram-viewer/src/main/resources/sld/view.fxml b/diagram-viewer/src/main/resources/sld/view.fxml index e70f16c..2cb3000 100644 --- a/diagram-viewer/src/main/resources/sld/view.fxml +++ b/diagram-viewer/src/main/resources/sld/view.fxml @@ -65,11 +65,14 @@