Skip to content

Commit

Permalink
Merge branch 'refs/heads/devel' into 199_finalize_cgmes_import
Browse files Browse the repository at this point in the history
# Conflicts:
#	.idea/workspace.xml
#	src/tests/test_cgmes_raw_cross_roundtrip.py
  • Loading branch information
SanPen committed Oct 7, 2024
2 parents 6de127d + 23974c3 commit 884f51c
Show file tree
Hide file tree
Showing 53 changed files with 1,884 additions and 417 deletions.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file added Grids_and_profiles/grids/NL_microgrid.gridcal
Binary file not shown.
Binary file not shown.
350 changes: 350 additions & 0 deletions Grids_and_profiles/grids/ejemplo_facts.raw

Large diffs are not rendered by default.

290 changes: 290 additions & 0 deletions Grids_and_profiles/grids/ejemplo_facts_v33.raw

Large diffs are not rendered by default.

Binary file added Grids_and_profiles/grids/fubm_caseHVDC_vt.ods
Binary file not shown.
Binary file not shown.
Binary file added Grids_and_profiles/grids/ntc_8_bus.gridcal
Binary file not shown.
Binary file not shown.
58 changes: 45 additions & 13 deletions src/GridCal/Gui/Diagrams/MapWidget/grid_map_widget.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
from PySide6.QtGui import (QIcon, QPixmap, QImage, QPainter, QStandardItemModel, QStandardItem, QColor,
QDropEvent, QWheelEvent)

from GridCal.Gui.SubstationDesigner.substation_designer import SubstationDesigner
from GridCalEngine.Devices.Diagrams.map_location import MapLocation
from GridCalEngine.Devices.Substation import Bus
from GridCalEngine.Devices.Branches.line import Line
Expand Down Expand Up @@ -857,15 +858,46 @@ def dropEvent(self, event: QDropEvent):
y0 = point0.y()
lat, lon = self.to_lat_lon(x=x0, y=y0)

# print(f"Dropped at x:{x0}, y:{y0}, lat:{lat}, lon:{lon}")

if obj_type == self.library_model.get_substation_mime_data():
api_object = Substation(name=f"Substation {self.circuit.get_substation_number()}",
latitude=lat,
longitude=lon)
self.circuit.add_substation(obj=api_object)
substation_graphics = self.add_api_substation(api_object=api_object, lat=lat, lon=lon)
substation_graphics.add_voltage_level()
self.create_substation_with_dialogue(lat=lat, lon=lon)

def create_substation_with_dialogue(self, lat, lon):
"""
Create a substation using the dialogue
:param lat:
:param lon:
:return:
"""
kv = self.gui.get_default_voltage()
dlg = SubstationDesigner(grid=self.circuit, default_voltage=kv)
dlg.exec()
if dlg.was_ok():

# create the SE
se_object = Substation(name=dlg.get_name(), latitude=lat, longitude=lon)

self.circuit.add_substation(obj=se_object)
substation_graphics = self.add_api_substation(api_object=se_object, lat=lat, lon=lon)

for vl_template in dlg.get_voltage_levels():

# substation_graphics.add_voltage_level()
vl = VoltageLevel(name=f"{se_object.name} @{kv}KV VL",
Vnom=vl_template.voltage,
substation=se_object)
self.circuit.add_voltage_level(vl)

bus = Bus(name=f"{se_object.name} @{kv}KV bus",
Vnom=vl_template.voltage,
substation=se_object,
voltage_level=vl)
self.circuit.add_bus(obj=bus)

# add the vl graphics
self.add_api_voltage_level(substation_graphics=substation_graphics, api_object=vl)

# sort voltage levels
substation_graphics.sort_voltage_levels()

def wheelEvent(self, event: QWheelEvent):
"""
Expand All @@ -874,12 +906,12 @@ def wheelEvent(self, event: QWheelEvent):
:return:
"""

# SANTIAGO: NO TOCAR ESTO ES EL COMPORTAMIENTO DESEADO
# SANTIAGO: DO NOT TOUCH, THIS IS THE DESIRED BEHAVIOUR
self.update_device_sizes()

def get_branch_width(self):
def get_branch_width(self) -> float:
"""
Get the desired branch width
:return:
"""
max_zoom = self.map.max_level
Expand All @@ -888,9 +920,9 @@ def get_branch_width(self):
scale = self.diagram.min_branch_width + (zoom - min_zoom) / (max_zoom - min_zoom)
return scale

def update_device_sizes(self):
def update_device_sizes(self) -> None:
"""
Updat ethe devices' sizes
:return:
"""

Expand Down
30 changes: 15 additions & 15 deletions src/GridCal/Gui/Diagrams/MapWidget/map_widget.py
Original file line number Diff line number Diff line change
Expand Up @@ -469,12 +469,12 @@ def __init__(self,
self.view_tlat = 0

# some cursors
self.standard_cursor = QCursor(Qt.ArrowCursor)
self.box_select_cursor = QCursor(Qt.CrossCursor)
self.wait_cursor = QCursor(Qt.WaitCursor)
self.drag_cursor = QCursor(Qt.OpenHandCursor)
self.standard_cursor = QCursor(Qt.CursorShape.ArrowCursor)
self.box_select_cursor = QCursor(Qt.CursorShape.CrossCursor)
self.wait_cursor = QCursor(Qt.CursorShape.WaitCursor)
self.drag_cursor = QCursor(Qt.CursorShape.OpenHandCursor)

self.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Expanding)
self.setSizePolicy(QSizePolicy.Policy.Expanding, QSizePolicy.Policy.Expanding)
self.setMinimumSize(self.tile_width, self.tile_height)

self.setMouseTracking(True)
Expand Down Expand Up @@ -672,9 +672,9 @@ def mouseReleaseEvent(self, event: QMouseEvent) -> None:
self.setCursor(self.default_cursor)

b = event.button()
if b == Qt.NoButton:
if b == Qt.MouseButton.NoButton:
pass
elif b == Qt.LeftButton:
elif b == Qt.MouseButton.LeftButton:
self.left_mbutton_down = False

if self.start_drag_x is None:
Expand All @@ -688,10 +688,10 @@ def mouseReleaseEvent(self, event: QMouseEvent) -> None:
longitude, latitude = self.view_to_geo(x, y)
self.position_callback(latitude, longitude, x, y)

elif b == Qt.MidButton:
elif b == Qt.MouseButton.MiddleButton:
self.mid_mbutton_down = False

elif b == Qt.RightButton:
elif b == Qt.MouseButton.RightButton:
self.right_mbutton_down = False

else:
Expand All @@ -705,13 +705,13 @@ def mouseDoubleClickEvent(self, event: QMouseEvent):
:return:
"""
b = event.button()
if b == Qt.NoButton:
if b == Qt.MouseButton.NoButton:
pass
elif b == Qt.LeftButton:
elif b == Qt.MouseButton.LeftButton:
pass
elif b == Qt.MidButton:
elif b == Qt.MouseButton.MiddleButton:
pass
elif b == Qt.RightButton:
elif b == Qt.MouseButton.RightButton:
pass
else:
pass
Expand Down Expand Up @@ -781,7 +781,7 @@ def mouseMoveEvent(self, event: QMouseEvent):
def keyPressEvent(self, event: QKeyEvent):
"""Capture a key press."""

if event.key() == Qt.Key_Shift:
if event.key() == Qt.Key.Key_Shift:
self.shift_down = True
self.default_cursor = self.box_select_cursor
self.setCursor(self.default_cursor)
Expand All @@ -792,7 +792,7 @@ def keyReleaseEvent(self, event: QKeyEvent):
"""Capture a key release."""

key = event.key()
if event.key() == Qt.Key_Shift:
if event.key() == Qt.Key.Key_Shift:
self.shift_down = False
self.default_cursor = self.standard_cursor
self.setCursor(self.default_cursor)
Expand Down
1 change: 0 additions & 1 deletion src/GridCal/Gui/Diagrams/base_diagram_widget.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
from typing import List, Dict, Union, Tuple, Callable, TYPE_CHECKING
import numpy as np
import cv2
from docutils.nodes import title
from matplotlib import pyplot as plt

from PySide6.QtCore import Qt
Expand Down
Loading

0 comments on commit 884f51c

Please sign in to comment.