Skip to content

Commit

Permalink
Improved the light/dark scheme
Browse files Browse the repository at this point in the history
  • Loading branch information
SanPen committed Jun 10, 2023
1 parent ad98b18 commit 1dd9e71
Show file tree
Hide file tree
Showing 24 changed files with 661 additions and 410 deletions.
779 changes: 393 additions & 386 deletions .idea/workspace.xml

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,5 @@ Cython
pyproj
pyarrow
fastparquet
darkdetect
pyqtdarktheme
31 changes: 17 additions & 14 deletions src/GridCal/Engine/Devices/bus.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,8 @@ def __init__(self, name="Bus", idtag=None, code='', vnom=10, vmin=0.9, vmax=1.1,
'Is the bus active? used to disable the bus.'),
'is_slack': GCProp('', bool, 'Force the bus to be of slack type.'),
'is_dc': GCProp('', bool, 'Is this bus of DC type?.'),
'is_tr_bus': GCProp('', bool, 'Is this bus part of a composite transformer, such as a 3-winding transformer?.'),
'is_tr_bus': GCProp('', bool,
'Is this bus part of a composite transformer, such as a 3-winding transformer?.'),
'Vnom': GCProp('kV', float,
'Nominal line voltage of the bus.'),
'Vm0': GCProp('p.u.', float, 'Voltage module guess.'),
Expand All @@ -119,15 +120,16 @@ def __init__(self, name="Bus", idtag=None, code='', vnom=10, vmin=0.9, vmax=1.1,
'Resistance of the fault.\n'
'This is used for short circuit studies.'),
'x_fault': GCProp('p.u.', float, 'Reactance of the fault.\n'
'This is used for short circuit studies.'),
'This is used for short circuit studies.'),
'x': GCProp('px', float, 'x position in pixels.'),
'y': GCProp('px', float, 'y position in pixels.'),
'h': GCProp('px', float, 'height of the bus in pixels.'),
'w': GCProp('px', float, 'Width of the bus in pixels.'),
'country': GCProp('', DeviceType.CountryDevice, 'Country of the bus'),
'area': GCProp('', DeviceType.AreaDevice, 'Area of the bus'),
'zone': GCProp('', DeviceType.ZoneDevice, 'Zone of the bus'),
'substation': GCProp('', DeviceType.SubstationDevice, 'Substation of the bus.'),
'substation': GCProp('', DeviceType.SubstationDevice,
'Substation of the bus.'),
'longitude': GCProp('deg', float, 'longitude of the bus.'),
'latitude': GCProp('deg', float, 'latitude of the bus.')},
non_editable_attributes=['idtag'],
Expand Down Expand Up @@ -428,7 +430,8 @@ def get_voltage_guess(self, logger=None, use_stored_guess=False):
vm = elm.Vset
elif elm.Vset != vm:
if logger is not None:
logger.append('Different set points at ' + self.name + ': ' + str(elm.Vset) + ' !=' + str(v))
logger.append(
'Different set points at ' + self.name + ': ' + str(elm.Vset) + ' !=' + str(v))

return v

Expand Down Expand Up @@ -797,23 +800,23 @@ def get_devices_list(self):
:return: list of connected objects
"""
return self.loads + \
self.controlled_generators + \
self.batteries + \
self.static_generators + \
self.shunts + \
self.external_grids
self.controlled_generators + \
self.batteries + \
self.static_generators + \
self.shunts + \
self.external_grids

def get_device_number(self):
"""
Return a list of all the connected objects
:return: list of connected objects
"""
return len(self.loads) + \
len(self.controlled_generators) + \
len(self.batteries) + \
len(self.static_generators) + \
len(self.shunts) + \
len(self.external_grids)
len(self.controlled_generators) + \
len(self.batteries) + \
len(self.static_generators) + \
len(self.shunts) + \
len(self.external_grids)

def ensure_area_objects(self, circuit: "MultiCircuit"):
"""
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@


class InputsAnalysisResults(ResultsTemplate):
tpe = 'Inputs Analysis'

def __init__(self, grid: MultiCircuit):
"""
Expand Down
18 changes: 18 additions & 0 deletions src/GridCal/Gui/GridEditorWidget/battery_graphics.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,24 @@ def __init__(self, parent, api_obj, diagramScene):
self.setPos(self.parent.x(), self.parent.y() + 100)
self.update_line(self.pos())

def recolour_mode(self):

if self.api_object is not None:
if self.api_object.active:
self.color = ACTIVE['color']
self.style = ACTIVE['style']
else:
self.color = DEACTIVATED['color']
self.style = DEACTIVATED['style']
else:
self.color = ACTIVE['color']
self.style = ACTIVE['style']

pen = QPen(self.color, self.width, self.style)
self.glyph.setPen(pen)
self.nexus.setPen(pen)
self.label.setDefaultTextColor(self.color)

def update_line(self, pos):
"""
Update the line that joins the parent and this object
Expand Down
3 changes: 3 additions & 0 deletions src/GridCal/Gui/GridEditorWidget/bus_graphics.py
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,9 @@ def recolour_mode(self):
self.style = ACTIVE['style']

self.label.setDefaultTextColor(ACTIVE['text'])
self.set_tile_color(self.color)
for e in self.api_object.get_devices_list():
e.graphic_obj.recolour_mode()

def set_label(self, val: str):
"""
Expand Down
15 changes: 15 additions & 0 deletions src/GridCal/Gui/GridEditorWidget/dc_line_graphics.py
Original file line number Diff line number Diff line change
Expand Up @@ -271,6 +271,21 @@ def __init__(self, fromPort: TerminalItem, toPort: TerminalItem, diagramScene, w
if fromPort and toPort:
self.redraw()

def recolour_mode(self):

if self.api_object is not None:
if self.api_object.active:
self.color = ACTIVE['color']
self.style = ACTIVE['style']
else:
self.color = DEACTIVATED['color']
self.style = DEACTIVATED['style']
else:
self.color = ACTIVE['color']
self.style = ACTIVE['style']

self.set_colour(self.color, self.width, self.style)

def set_colour(self, color: QColor, w, style: Qt.PenStyle):
"""
Set color and style
Expand Down
17 changes: 14 additions & 3 deletions src/GridCal/Gui/GridEditorWidget/editor.py
Original file line number Diff line number Diff line change
Expand Up @@ -1520,10 +1520,21 @@ def schematic_from_api(self, explode_factor=1.0, prog_func=None, text_func=None)
self.align_schematic()

def recolour_mode(self):
for bus in self.circuit.buses:
"""
Change the colour according to the system theme
:return:
"""
for elm in self.circuit.buses:
if elm.graphic_obj is not None:
elm.graphic_obj.recolour_mode()

if bus.graphic_obj is not None:
bus.graphic_obj.recolour_mode()
for elm in self.circuit.get_branches():
if elm.graphic_obj is not None:
elm.graphic_obj.recolour_mode()

for elm in self.circuit.transformers3w:
if elm.graphic_obj is not None:
elm.graphic_obj.recolour_mode()

def set_dark_mode(self):
is_dark = True
Expand Down
18 changes: 18 additions & 0 deletions src/GridCal/Gui/GridEditorWidget/generator_graphics.py
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,24 @@ def __init__(self, parent, api_obj, diagramScene):
self.setPos(self.parent.x(), self.parent.y() + 100)
self.update_line(self.pos())

def recolour_mode(self):

if self.api_object is not None:
if self.api_object.active:
self.color = ACTIVE['color']
self.style = ACTIVE['style']
else:
self.color = DEACTIVATED['color']
self.style = DEACTIVATED['style']
else:
self.color = ACTIVE['color']
self.style = ACTIVE['style']

pen = QPen(self.color, self.width, self.style)
self.glyph.setPen(pen)
self.nexus.setPen(pen)
self.label.setDefaultTextColor(self.color)

def update_line(self, pos):
"""
Update the line that joins the parent and this object
Expand Down
2 changes: 1 addition & 1 deletion src/GridCal/Gui/GridEditorWidget/generic_graphics.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ def set_light_mode():
ACTIVE['text'] = Qt.black


class LineUpdateMixin(object):
class LineUpdateMixin:

def __init__(self, parent):
super(LineUpdateMixin, self).__init__(parent)
Expand Down
15 changes: 15 additions & 0 deletions src/GridCal/Gui/GridEditorWidget/hvdc_graphics.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,21 @@ def __init__(self, fromPort: TerminalItem, toPort: TerminalItem, diagramScene, w
if fromPort and toPort:
self.redraw()

def recolour_mode(self):

if self.api_object is not None:
if self.api_object.active:
self.color = ACTIVE['color']
self.style = ACTIVE['style']
else:
self.color = DEACTIVATED['color']
self.style = DEACTIVATED['style']
else:
self.color = ACTIVE['color']
self.style = ACTIVE['style']

self.set_colour(self.color, self.width, self.style)

def set_colour(self, color: QColor, w, style: Qt.PenStyle):
"""
Set color and style
Expand Down
15 changes: 15 additions & 0 deletions src/GridCal/Gui/GridEditorWidget/line_graphics.py
Original file line number Diff line number Diff line change
Expand Up @@ -307,6 +307,21 @@ def __init__(self, fromPort: TerminalItem, toPort: TerminalItem | None, diagramS
if fromPort and toPort:
self.redraw()

def recolour_mode(self):

if self.api_object is not None:
if self.api_object.active:
self.color = ACTIVE['color']
self.style = ACTIVE['style']
else:
self.color = DEACTIVATED['color']
self.style = DEACTIVATED['style']
else:
self.color = ACTIVE['color']
self.style = ACTIVE['style']

self.set_colour(self.color, self.width, self.style)

def set_colour(self, color: QColor, w, style: Qt.PenStyle):
"""
Set color and style
Expand Down
17 changes: 17 additions & 0 deletions src/GridCal/Gui/GridEditorWidget/load_graphics.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,23 @@ def __init__(self, parent, api_obj, diagramScene):
self.setPos(self.parent.x(), self.parent.y() + 100)
self.update_line(self.pos())

def recolour_mode(self):

if self.api_object is not None:
if self.api_object.active:
self.color = ACTIVE['color']
self.style = ACTIVE['style']
else:
self.color = DEACTIVATED['color']
self.style = DEACTIVATED['style']
else:
self.color = ACTIVE['color']
self.style = ACTIVE['style']

pen = QPen(self.color, self.width, self.style)
self.nexus.setPen(pen)
self.glyph.setPen(pen)

def update_line(self, pos):
"""
Update the line that joins the parent and this object
Expand Down
18 changes: 18 additions & 0 deletions src/GridCal/Gui/GridEditorWidget/shunt_graphics.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,24 @@ def __init__(self, parent, api_obj, diagramScene):
self.setPos(self.parent.x(), self.parent.y() + 100)
self.update_line(self.pos())

def recolour_mode(self):

if self.api_object is not None:
if self.api_object.active:
self.color = ACTIVE['color']
self.style = ACTIVE['style']
else:
self.color = DEACTIVATED['color']
self.style = DEACTIVATED['style']
else:
self.color = ACTIVE['color']
self.style = ACTIVE['style']

pen = QPen(self.color, self.width, self.style)
self.nexus.setPen(pen)
for l in self.lines:
l.setPen(pen)

def update_line(self, pos):
"""
Update the line that joins the parent and this object
Expand Down
18 changes: 18 additions & 0 deletions src/GridCal/Gui/GridEditorWidget/static_generator_graphics.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,24 @@ def __init__(self, parent, api_obj, diagramScene):
self.setPos(self.parent.x(), self.parent.y() + 100)
self.update_line(self.pos())

def recolour_mode(self):

if self.api_object is not None:
if self.api_object.active:
self.color = ACTIVE['color']
self.style = ACTIVE['style']
else:
self.color = DEACTIVATED['color']
self.style = DEACTIVATED['style']
else:
self.color = ACTIVE['color']
self.style = ACTIVE['style']

pen = QPen(self.color, self.width, self.style)
self.glyph.setPen(pen)
self.nexus.setPen(pen)
self.label.setDefaultTextColor(self.color)

def update_line(self, pos):
"""
Update the line that joins the parent and this object
Expand Down
15 changes: 15 additions & 0 deletions src/GridCal/Gui/GridEditorWidget/transformer2w_graphics.py
Original file line number Diff line number Diff line change
Expand Up @@ -352,6 +352,21 @@ def __init__(self, fromPort: TerminalItem, toPort: TerminalItem, diagramScene, w
if fromPort and toPort:
self.redraw()

def recolour_mode(self):

if self.api_object is not None:
if self.api_object.active:
self.color = ACTIVE['color']
self.style = ACTIVE['style']
else:
self.color = DEACTIVATED['color']
self.style = DEACTIVATED['style']
else:
self.color = ACTIVE['color']
self.style = ACTIVE['style']

self.set_colour(self.color, self.width, self.style)

def set_colour(self, color: QColor, w, style: Qt.PenStyle):
"""
Set color and style
Expand Down
25 changes: 23 additions & 2 deletions src/GridCal/Gui/GridEditorWidget/transformer3w_graphics.py
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,8 @@ def __init__(self, diagramScene: "DiagramScene",
self.terminals: List[TerminalItem] = list()
self.connection_lines: List[LineGraphicItem | None] = list()

pen = QPen(self.color, self.pen_width, self.style)

for i in range(self.n_windings):
# create objects
winding_circle = QGraphicsEllipseItem(parent=self)
Expand All @@ -121,8 +123,8 @@ def __init__(self, diagramScene: "DiagramScene",
terminal.setRotation(angles_deg[i])

# set objects style
winding_circle.setPen(QPen(self.color, self.pen_width, self.style))
terminal.setPen(QPen(self.color, self.pen_width, self.style))
winding_circle.setPen(pen)
terminal.setPen(pen)

self.winding_circles.append(winding_circle)
self.terminals.append(terminal)
Expand All @@ -136,6 +138,25 @@ def __init__(self, diagramScene: "DiagramScene",
# other actions
self.set_winding_tool_tips()

def recolour_mode(self):

if self.api_object is not None:
if self.api_object.active:
self.color = ACTIVE['color']
self.style = ACTIVE['style']
else:
self.color = DEACTIVATED['color']
self.style = DEACTIVATED['style']
else:
self.color = ACTIVE['color']
self.style = ACTIVE['style']

pen = QPen(self.color, self.pen_width, self.style)
for i in range(self.n_windings):
self.winding_circles[i].setPen(pen)
self.terminals[i].setPen(pen)
self.connection_lines[i].recolour_mode()

def set_winding_tool_tips(self):
"""
Set
Expand Down
Loading

0 comments on commit 1dd9e71

Please sign in to comment.