Skip to content

Commit 8a36eb0

Browse files
committed
add test diagraminfodialog
1 parent 0a44195 commit 8a36eb0

File tree

2 files changed

+252
-1
lines changed

2 files changed

+252
-1
lines changed

devsimpy/DiagramInfoDialog.py

Lines changed: 91 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ def __init__(self, parent, diagram_info, puml_component, puml_class):
3232
"""
3333
wx.Dialog.__init__(self, parent, wx.ID_ANY, _("Diagram Information"),
3434
style=wx.DEFAULT_DIALOG_STYLE|wx.RESIZE_BORDER)
35-
self.SetSize((700, 500))
35+
self.SetSize((750, 550))
3636

3737
self.puml_component = puml_component
3838
self.puml_class = puml_class
@@ -48,22 +48,77 @@ def __init__(self, parent, diagram_info, puml_component, puml_class):
4848
info_panel = wx.Panel(notebook)
4949
info_sizer = wx.BoxSizer(wx.VERTICAL)
5050

51+
# Header avec bouton info
52+
info_header = wx.BoxSizer(wx.HORIZONTAL)
53+
info_label = wx.StaticText(info_panel, wx.ID_ANY, _("Diagram Statistics"))
54+
info_label.SetFont(wx.Font(10, wx.FONTFAMILY_DEFAULT, wx.FONTSTYLE_NORMAL, wx.FONTWEIGHT_BOLD))
55+
info_help_btn = wx.Button(info_panel, wx.ID_ANY, "?", size=(25, 25))
56+
info_help_btn.SetToolTip(_("Show information about this tab"))
57+
58+
info_header.Add(info_label, 0, wx.ALIGN_CENTER_VERTICAL|wx.ALL, 5)
59+
info_header.Add(info_help_btn, 0, wx.ALIGN_CENTER_VERTICAL|wx.LEFT, 5)
60+
info_header.AddStretchSpacer()
61+
62+
info_sizer.Add(info_header, 0, wx.EXPAND|wx.ALL, 5)
63+
5164
text_ctrl = wx.TextCtrl(info_panel, wx.ID_ANY, diagram_info,
5265
style=wx.TE_MULTILINE|wx.TE_READONLY|wx.TE_WORDWRAP)
5366
info_sizer.Add(text_ctrl, 1, wx.EXPAND|wx.ALL, 10)
5467
info_panel.SetSizer(info_sizer)
5568

69+
# Event handler for info button
70+
info_help_btn.Bind(wx.EVT_BUTTON, lambda e: wx.MessageBox(
71+
_("This tab shows general statistics about your DEVS model:\n\n"
72+
"• Number of atomic models (basic components)\n"
73+
"• Number of coupled models (hierarchical components)\n"
74+
"• Number of connections between models\n"
75+
"• Hierarchy depth level\n"
76+
"• Number of input/output ports"),
77+
_("Diagram Statistics Help"),
78+
wx.OK|wx.ICON_INFORMATION
79+
))
80+
5681
notebook.AddPage(info_panel, _("Information"))
5782

5883
# --- PAGE 2: PlantUML Component Diagram ---
5984
comp_panel = wx.Panel(notebook)
6085
comp_sizer = wx.BoxSizer(wx.VERTICAL)
6186

87+
# Header avec bouton info
88+
comp_header = wx.BoxSizer(wx.HORIZONTAL)
89+
comp_label = wx.StaticText(comp_panel, wx.ID_ANY, _("Component Diagram (PlantUML)"))
90+
comp_label.SetFont(wx.Font(10, wx.FONTFAMILY_DEFAULT, wx.FONTSTYLE_NORMAL, wx.FONTWEIGHT_BOLD))
91+
comp_help_btn = wx.Button(comp_panel, wx.ID_ANY, "?", size=(25, 25))
92+
comp_help_btn.SetToolTip(_("Show information about this tab"))
93+
94+
comp_header.Add(comp_label, 0, wx.ALIGN_CENTER_VERTICAL|wx.ALL, 5)
95+
comp_header.Add(comp_help_btn, 0, wx.ALIGN_CENTER_VERTICAL|wx.LEFT, 5)
96+
comp_header.AddStretchSpacer()
97+
98+
comp_sizer.Add(comp_header, 0, wx.EXPAND|wx.ALL, 5)
99+
62100
comp_text = wx.TextCtrl(comp_panel, wx.ID_ANY, puml_component,
63101
style=wx.TE_MULTILINE|wx.TE_READONLY|wx.TE_WORDWRAP|wx.HSCROLL)
64102
comp_text.SetFont(wx.Font(9, wx.FONTFAMILY_TELETYPE, wx.FONTSTYLE_NORMAL, wx.FONTWEIGHT_NORMAL))
65103
comp_sizer.Add(comp_text, 1, wx.EXPAND|wx.ALL, 10)
66104

105+
# Event handler for component help button
106+
comp_help_btn.Bind(wx.EVT_BUTTON, lambda e: wx.MessageBox(
107+
_("Component Diagram shows the STRUCTURAL view of your DEVS model:\n\n"
108+
"• Packages represent coupled models (hierarchical structure)\n"
109+
"• Components represent atomic models (basic components)\n"
110+
"• Arrows show connections between components\n"
111+
"• Ports (in/out) are displayed on each component\n\n"
112+
"This diagram is useful for understanding:\n"
113+
"- Model architecture and composition\n"
114+
"- Data flow between components\n"
115+
"- Hierarchical organization\n\n"
116+
"Use 'Copy to Clipboard' to paste in PlantUML editor\n"
117+
"or 'View Online' to see it rendered directly."),
118+
_("Component Diagram Help"),
119+
wx.OK|wx.ICON_INFORMATION
120+
))
121+
67122
# Boutons pour Component diagram
68123
comp_btn_sizer = wx.BoxSizer(wx.HORIZONTAL)
69124

@@ -83,11 +138,46 @@ def __init__(self, parent, diagram_info, puml_component, puml_class):
83138
class_panel = wx.Panel(notebook)
84139
class_sizer = wx.BoxSizer(wx.VERTICAL)
85140

141+
# Header avec bouton info
142+
class_header = wx.BoxSizer(wx.HORIZONTAL)
143+
class_label = wx.StaticText(class_panel, wx.ID_ANY, _("Class Diagram (PlantUML)"))
144+
class_label.SetFont(wx.Font(10, wx.FONTFAMILY_DEFAULT, wx.FONTSTYLE_NORMAL, wx.FONTWEIGHT_BOLD))
145+
class_help_btn = wx.Button(class_panel, wx.ID_ANY, "?", size=(25, 25))
146+
class_help_btn.SetToolTip(_("Show information about this tab"))
147+
148+
class_header.Add(class_label, 0, wx.ALIGN_CENTER_VERTICAL|wx.ALL, 5)
149+
class_header.Add(class_help_btn, 0, wx.ALIGN_CENTER_VERTICAL|wx.LEFT, 5)
150+
class_header.AddStretchSpacer()
151+
152+
class_sizer.Add(class_header, 0, wx.EXPAND|wx.ALL, 5)
153+
86154
class_text = wx.TextCtrl(class_panel, wx.ID_ANY, puml_class,
87155
style=wx.TE_MULTILINE|wx.TE_READONLY|wx.TE_WORDWRAP|wx.HSCROLL)
88156
class_text.SetFont(wx.Font(9, wx.FONTFAMILY_TELETYPE, wx.FONTSTYLE_NORMAL, wx.FONTWEIGHT_NORMAL))
89157
class_sizer.Add(class_text, 1, wx.EXPAND|wx.ALL, 10)
90158

159+
# Event handler for class help button
160+
class_help_btn.Bind(wx.EVT_BUTTON, lambda e: wx.MessageBox(
161+
_("Class Diagram shows the IMPLEMENTATION view with inheritance:\n\n"
162+
"• 'DEVS Framework' package: base classes from the framework\n"
163+
" (DomainBehavior, DomainStructure, Coupled, etc.)\n"
164+
"• 'User Models' package: your custom model classes\n"
165+
"• Arrows show inheritance relationships (parent ← child)\n"
166+
"• Methods and attributes are listed for each class\n"
167+
"• Ports (IPorts/OPorts) are shown as attributes\n\n"
168+
"This diagram is useful for understanding:\n"
169+
"- Complete Python class hierarchy\n"
170+
"- Which framework classes your models inherit from\n"
171+
"- Methods implemented in each class\n"
172+
"- Object-oriented structure of your models\n\n"
173+
"Colors:\n"
174+
"- Blue: Atomic models\n"
175+
"- Green: Coupled models\n"
176+
"- Gray: Framework classes"),
177+
_("Class Diagram Help"),
178+
wx.OK|wx.ICON_INFORMATION
179+
))
180+
91181
# Boutons pour Class diagram
92182
class_btn_sizer = wx.BoxSizer(wx.HORIZONTAL)
93183

tests/test_diagraminfodialog.py

Lines changed: 161 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,161 @@
1+
from ApplicationController import TestApp
2+
3+
# Exemple de code PlantUML pour le component diagram
4+
puml_component = """@startuml
5+
!theme plain
6+
skinparam linetype polyline
7+
8+
package "TestModel" {
9+
10+
component "Generator" as Generator {
11+
portout out0
12+
}
13+
14+
component "Processor" as Processor {
15+
portin in0
16+
portout out0
17+
}
18+
19+
package "Coupled_System" as Coupled_System {
20+
21+
component "SubProcessor1" as SubProcessor1 {
22+
portin in0
23+
portout out0
24+
}
25+
26+
component "SubProcessor2" as SubProcessor2 {
27+
portin in0
28+
portout out0
29+
}
30+
31+
' Connections
32+
SubProcessor1 --> SubProcessor2 : out0→in0
33+
34+
}
35+
36+
component "Collector" as Collector {
37+
portin in0
38+
}
39+
40+
' Connections
41+
Generator --> Processor : out0→in0
42+
Processor --> Coupled_System : out0→in0
43+
Coupled_System --> Collector : out0→in0
44+
45+
}
46+
47+
@enduml"""
48+
49+
# Exemple de code PlantUML pour le class diagram
50+
puml_class = """@startuml
51+
!theme plain
52+
skinparam classAttributeIconSize 0
53+
skinparam class {
54+
BackgroundColor<<atomic>> LightBlue
55+
BackgroundColor<<coupled>> LightGreen
56+
BackgroundColor<<framework>> WhiteSmoke
57+
}
58+
59+
package "DEVS Framework" {
60+
61+
abstract class DomainBehavior <<framework>> {
62+
' DomainInterface.DomainBehavior
63+
# state : dict
64+
--
65+
+ intTransition()
66+
+ extTransition(inputs)
67+
+ outputFnc()
68+
+ timeAdvance()
69+
}
70+
71+
abstract class DomainStructure <<framework>> {
72+
' DomainInterface.DomainStructure
73+
# IPorts : list
74+
# OPorts : list
75+
# componentSet : dict
76+
--
77+
+ addInPort(name)
78+
+ addOutPort(name)
79+
+ addSubModel(model)
80+
}
81+
82+
class Coupled <<framework>> {
83+
' DomainInterface.Coupled
84+
# IC : list
85+
# EIC : list
86+
# EOC : list
87+
--
88+
+ select(models)
89+
}
90+
91+
}
92+
93+
package "User Models" {
94+
95+
class Generator <<atomic>> {
96+
' MyLibrary.Generator
97+
- period : float
98+
- count : int
99+
--
100+
+ out0 : OutputPort
101+
--
102+
+ intTransition()
103+
+ outputFnc()
104+
+ timeAdvance()
105+
}
106+
107+
class Processor <<atomic>> {
108+
' MyLibrary.Processor
109+
- processing_time : float
110+
--
111+
+ in0 : InputPort
112+
+ out0 : OutputPort
113+
--
114+
+ extTransition(inputs)
115+
+ outputFnc()
116+
}
117+
118+
class Collector <<atomic>> {
119+
' MyLibrary.Collector
120+
- data : list
121+
--
122+
+ in0 : InputPort
123+
--
124+
+ extTransition(inputs)
125+
}
126+
127+
class CoupledSystem <<coupled>> {
128+
' MyLibrary.CoupledSystem
129+
}
130+
131+
}
132+
133+
' Inheritance relationships
134+
DomainBehavior <|-- Generator
135+
DomainBehavior <|-- Processor
136+
DomainBehavior <|-- Collector
137+
DomainStructure <|-- Coupled
138+
Coupled <|-- CoupledSystem
139+
140+
@enduml"""
141+
142+
# Informations du diagramme
143+
diagram_info = """Path: /home/user/models/TestModel.dsp
144+
Number of atomic devs models: 5
145+
Number of coupled devs models: 1
146+
Number of coupling: 4
147+
Number of deep level (description hierarchy): 2
148+
Number of input port models: 0
149+
Number of output port models: 0"""
150+
151+
import wx
152+
153+
from ApplicationController import TestApp
154+
from DiagramInfoDialog import DiagramInfoDialog
155+
156+
# Run the test
157+
app = TestApp(0)
158+
159+
dlg = DiagramInfoDialog(None, diagram_info, puml_component, puml_class)
160+
161+
app.RunTest(dlg)

0 commit comments

Comments
 (0)