Skip to content

Commit 75dfed3

Browse files
committed
Fix draw text and arrow
1 parent b642c77 commit 75dfed3

File tree

1 file changed

+20
-9
lines changed

1 file changed

+20
-9
lines changed

src/Display/OCCViewer.py

+20-9
Original file line numberDiff line numberDiff line change
@@ -430,7 +430,11 @@ def DisplayVector(self, vec, pnt, update=False):
430430
pnt_start = gp_Pnt(start.X(), start.Y(), start.Z())
431431

432432
Prs3d_Arrow.Draw(
433-
aStructure, pnt_start, gp_Dir(vec), math.radians(20), vec.Magnitude()
433+
aStructure.CurrentGroup(),
434+
pnt_start,
435+
gp_Dir(vec),
436+
math.radians(20),
437+
vec.Magnitude(),
434438
)
435439
aStructure.Display()
436440
# it would be more coherent if a AIS_InteractiveObject
@@ -440,23 +444,30 @@ def DisplayVector(self, vec, pnt, update=False):
440444
return aStructure
441445

442446
def DisplayMessage(
443-
self, point, text_to_write, height=None, message_color=None, update=False
447+
self,
448+
point,
449+
text_to_write,
450+
height=14.0,
451+
message_color=(0.0, 0.0, 0.0),
452+
update=False,
444453
):
445454
"""
446455
:point: a gp_Pnt or gp_Pnt2d instance
447456
:text_to_write: a string
448-
:message_color: triple with the range 0-1
457+
:height: font height, 12 by defaults
458+
:message_color: triple with the range 0-1, default to black
449459
"""
450460
aStructure = Graphic3d_Structure(self._struc_mgr)
451-
text_aspect = Prs3d_TextAspect()
452461

453-
if message_color is not None:
454-
text_aspect.SetColor(rgb_color(*message_color))
455-
if height is not None:
456-
text_aspect.SetHeight(height)
462+
text_aspect = Prs3d_TextAspect()
463+
text_aspect.SetColor(rgb_color(*message_color))
464+
text_aspect.SetHeight(height)
457465
if isinstance(point, gp_Pnt2d):
458466
point = gp_Pnt(point.X(), point.Y(), 0)
459-
Prs3d_Text.Draw(aStructure, text_aspect, to_string(text_to_write), point)
467+
468+
Prs3d_Text.Draw(
469+
aStructure.CurrentGroup(), text_aspect, to_string(text_to_write), point
470+
)
460471
aStructure.Display()
461472
# @TODO: it would be more coherent if a AIS_InteractiveObject
462473
# is be returned

0 commit comments

Comments
 (0)