Skip to content

Commit

Permalink
vlLayoutFactoryParameter: add checkbox for substitute internal 2wt
Browse files Browse the repository at this point in the history
Signed-off-by: Florian Dupuy <florian.dupuy@rte-france.com>
  • Loading branch information
flo-dup committed Mar 29, 2024
1 parent 54cce2c commit ef119c8
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 19 deletions.
4 changes: 4 additions & 0 deletions diagram-viewer/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -109,21 +109,25 @@
<dependency>
<groupId>com.powsybl</groupId>
<artifactId>powsybl-network-area-diagram</artifactId>
<version>4.3.0-SNAPSHOT</version>
</dependency>
<!-- __________________________________________________________________________ -->
<!-- SLD -->
<!-- __________________________________________________________________________ -->
<dependency>
<groupId>com.powsybl</groupId>
<artifactId>powsybl-single-line-diagram-core</artifactId>
<version>4.3.0-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>com.powsybl</groupId>
<artifactId>powsybl-single-line-diagram-cgmes-dl-conversion</artifactId>
<version>4.3.0-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>com.powsybl</groupId>
<artifactId>powsybl-single-line-diagram-cgmes-layout</artifactId>
<version>4.3.0-SNAPSHOT</version>
</dependency>
<!-- __________________________________________________________________________ -->
<!-- JavaFX -->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,14 @@
import com.powsybl.sld.layout.positionfromextension.PositionFromExtension;
import com.powsybl.sld.library.ComponentLibrary;
import javafx.beans.binding.Bindings;
import javafx.beans.binding.BooleanBinding;
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.HBox;
import javafx.scene.layout.VBox;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

Expand Down Expand Up @@ -118,6 +118,9 @@ public class SingleLineDiagramViewController extends AbstractDiagramViewControll
@FXML
public CheckBox disconnectorsOnBusCheckBox;

@FXML
public VBox positionVoltageLevelLayoutFactoryParameters;

@FXML
public CheckBox stackFeedersCheckBox;

Expand All @@ -132,6 +135,8 @@ public class SingleLineDiagramViewController extends AbstractDiagramViewControll

@FXML
public CheckBox substituteSingularFictitiousNodesCheckBox;
@FXML
public CheckBox substituteInternalMiddle2wtByEquipmentNodesCheckBox;

@FXML
public Spinner<Double> scaleFactorSpinner;
Expand Down Expand Up @@ -254,18 +259,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<Object> changeListener) {
Expand All @@ -285,6 +287,7 @@ public void addListener(ChangeListener<Object> changeListener) {
handleShuntsCheckBox.selectedProperty().addListener(changeListener);
removeFictitiousNodesCheckBox.selectedProperty().addListener(changeListener);
substituteSingularFictitiousNodesCheckBox.selectedProperty().addListener(changeListener);
substituteInternalMiddle2wtByEquipmentNodesCheckBox.selectedProperty().addListener(changeListener);

// LayoutParameters
model.addListener(changeListener);
Expand Down Expand Up @@ -375,7 +378,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;
Expand Down
13 changes: 8 additions & 5 deletions diagram-viewer/src/main/resources/sld/view.fxml
Original file line number Diff line number Diff line change
Expand Up @@ -65,11 +65,14 @@
<ComboBox fx:id="substationLayoutComboBox"/>
<Label text="VoltageLevel Layout:"/>
<EnumChoiceBox enumType="com.powsybl.diagram.viewer.sld.SingleLineDiagramModel$VoltageLevelLayoutFactoryType" fx:id="voltageLevelLayoutComboBox" initialValue="SMART"/>
<CheckBox fx:id="stackFeedersCheckBox" text="Stack feeders" selected="true"/>
<CheckBox fx:id="exceptionWhenPatternUnhandledCheckBox" text="Exception when pattern unhandled"/>
<CheckBox fx:id="handleShuntsCheckBox" text="Handle shunts"/>
<CheckBox fx:id="removeFictitiousNodesCheckBox" text="Remove fictitious nodes" selected="true"/>
<CheckBox fx:id="substituteSingularFictitiousNodesCheckBox" text="Substitute singular fictitious nodes" selected="true"/>
<VBox fx:id="positionVoltageLevelLayoutFactoryParameters">
<CheckBox fx:id="stackFeedersCheckBox" text="Stack feeders" selected="true"/>
<CheckBox fx:id="exceptionWhenPatternUnhandledCheckBox" text="Exception when pattern unhandled"/>
<CheckBox fx:id="handleShuntsCheckBox" text="Handle shunts"/>
<CheckBox fx:id="removeFictitiousNodesCheckBox" text="Remove fictitious nodes" selected="true"/>
<CheckBox fx:id="substituteSingularFictitiousNodesCheckBox" text="Substitute singular fictitious nodes" selected="true"/>
<CheckBox fx:id="substituteInternalMiddle2wtByEquipmentNodesCheckBox" text="Intern cells for internal 2wt" selected="true"/>
</VBox>
<Label text="CGMES-DL Diagrams:"/>
<ComboBox fx:id="cgmesDLDiagramsComboBox"/>
<Separator>
Expand Down

0 comments on commit ef119c8

Please sign in to comment.