Skip to content

Commit

Permalink
<Enhancement>[Line Shape]: <description>
Browse files Browse the repository at this point in the history
[
* Highlight all part of Ogl Associations
* Highlight]

[#122]
  • Loading branch information
hasii2011 committed Jan 20, 2025
1 parent 9574347 commit e62e1f0
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 12 deletions.
22 changes: 16 additions & 6 deletions src/miniogl/LineShape.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,12 @@
from logging import getLogger

from wx import BLACK_BRUSH
from wx import RED_BRUSH
from wx import WHITE_BRUSH
from wx import BLACK_PEN
from wx import DC
from wx import RED_PEN
from wx import WHITE_BRUSH

from wx import DC

from miniogl.Common import Common
from miniogl.Common import CommonLine
Expand Down Expand Up @@ -244,24 +246,25 @@ def Draw(self, dc: DC, withChildren: bool = True):
if self._selected:
dc.SetPen(RED_PEN)
if self._spline:
dc.SetPen(self.pen)
dc.DrawSpline(line)
else:
dc.SetPen(self.pen)
dc.DrawLines(line)

for control in self._controls:
control.Draw(dc)
if self._selected:
self._srcAnchor.Draw(dc)
self._dstAnchor.Draw(dc)
dc.SetPen(BLACK_PEN)

if self._drawArrow:
u, v = line[-2], line[-1]
self.DrawArrow(dc, u, v)
if withChildren:
# LineShape.clsLogger.debug(f'Call DrawChildren()')
self.DrawChildren(dc)

dc.SetPen(BLACK_PEN)

def DrawBorder(self, dc):
"""
Draw the border of the shape, for fast rendering.
Expand Down Expand Up @@ -307,10 +310,17 @@ def DrawArrow(self, dc: DC, u: Tuple[int, int], v: Tuple[int, int]):
]

if self.fillArrow is True:
dc.SetBrush(BLACK_BRUSH)
if self._selected is True:
dc.SetBrush(RED_BRUSH)
else:
dc.SetBrush(BLACK_BRUSH)
else:
dc.SetBrush(WHITE_BRUSH)

if self._selected is True:
dc.SetPen(RED_PEN)
else:
dc.SetPen(BLACK_PEN)
dc.DrawPolygon(points)

dc.SetBrush(WHITE_BRUSH)
Expand Down
18 changes: 14 additions & 4 deletions src/ogl/OglAssociation.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,15 @@
from math import cos
from math import sin

from wx import BLACK_BRUSH
from wx import BLACK_PEN
from wx import RED_PEN
from wx import BLACK_BRUSH
from wx import RED_BRUSH
from wx import WHITE_BRUSH
from wx import DC
from wx import FONTFAMILY_DEFAULT
from wx import FONTSTYLE_NORMAL
from wx import FONTWEIGHT_NORMAL
from wx import WHITE_BRUSH

from wx import Font

Expand Down Expand Up @@ -172,9 +174,17 @@ def drawDiamond(self, dc: DC, filled: bool = False):
points: DiamondPoints = OglAssociation.calculateDiamondPoints(lineSegments=line)
# self.oglAssociationLogger.debug(f'{points:}')

dc.SetPen(BLACK_PEN)
if self._selected is True:
dc.SetPen(RED_PEN)
else:
dc.SetPen(BLACK_PEN)

if filled:
dc.SetBrush(BLACK_BRUSH)
if self._selected is True:
dc.SetBrush(RED_BRUSH)
else:
dc.SetBrush(BLACK_BRUSH)

else:
dc.SetBrush(WHITE_BRUSH)
dc.DrawPolygon(points)
Expand Down
4 changes: 3 additions & 1 deletion src/ogl/OglInterface.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ def Draw(self, dc: DC, withChildren: bool = True):
"""
self.updateLabels()
if self._visible:

line = self.segments
if self._selected:
dc.SetPen(RED_PEN)
Expand All @@ -99,7 +100,6 @@ def Draw(self, dc: DC, withChildren: bool = True):
if self._selected:
self._srcAnchor.Draw(dc)
self._dstAnchor.Draw(dc)
dc.SetPen(BLACK_PEN)

if self._drawArrow:
u, v = line[-2], line[-1]
Expand All @@ -108,5 +108,7 @@ def Draw(self, dc: DC, withChildren: bool = True):
if withChildren is True:
self.DrawChildren(dc)

dc.SetPen(BLACK_PEN)

def __repr__(self):
return f'OglInterface - {super().__repr__()}'
2 changes: 1 addition & 1 deletion src/ogl/_version.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = '3.6.1'
__version__ = '3.6.2'

0 comments on commit e62e1f0

Please sign in to comment.