Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
G
Gryphon
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Monterey Phoenix
User Interfaces
Gryphon
Commits
f8f696f3
Commit
f8f696f3
authored
4 years ago
by
Allen, Bruce (CIV)
Browse files
Options
Downloads
Patches
Plain Diff
add branch node
parent
113bdf9a
No related branches found
No related tags found
No related merge requests found
Pipeline
#5005
failed
4 years ago
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
python/views/activity_diagram.py
+24
-5
24 additions, 5 deletions
python/views/activity_diagram.py
python/views/gantt_chart.py
+12
-10
12 additions, 10 deletions
python/views/gantt_chart.py
with
36 additions
and
15 deletions
python/views/activity_diagram.py
+
24
−
5
View file @
f8f696f3
...
...
@@ -12,6 +12,8 @@ ACTIVITY_W = 127
ACTIVITY_H
=
17
DECISION_W
=
14
DECISION_H
=
14
BRANCH_W
=
350
BRANCH_H
=
17
START_D
=
10
END_D
=
10
END_D2
=
3
...
...
@@ -39,6 +41,8 @@ def _xy_in(json_node):
raise
RuntimeError
(
"
bad
"
)
elif
json_node
[
0
]
==
"
e
"
:
return
x
,
y
-
END_D
/
2
elif
json_node
[
0
]
==
"
b
"
:
return
x
,
y
-
BRANCH_H
/
2
else
:
raise
RuntimeError
(
"
bad
"
)
...
...
@@ -50,6 +54,8 @@ def _xy_out(json_node):
return
x
,
y
+
DECISION_H
/
2
elif
json_node
[
0
]
==
"
s
"
:
return
x
,
y
+
START_D
/
2
elif
json_node
[
0
]
==
"
b
"
:
return
x
,
y
+
BRANCH_H
/
2
elif
json_node
[
0
]
==
"
e
"
:
raise
RuntimeError
(
"
bad
"
)
else
:
...
...
@@ -77,8 +83,13 @@ def _add_node_path(json_node, path):
d2
=
END_D2
path
.
addEllipse
(
x
-
d
/
2
,
y
-
d
/
2
,
d
,
d
)
path
.
addEllipse
(
x
-
d2
/
2
,
y
-
d2
/
2
,
d2
,
d2
)
elif
json_node
[
0
]
==
"
b
"
:
w
=
BRANCH_W
h
=
BRANCH_H
left
=
ACTIVITY_W
/
2
path
.
addRect
(
x
-
left
,
y
-
h
/
2
,
w
,
h
)
else
:
raise
RuntimeError
(
"
bad
"
)
raise
RuntimeError
(
"
bad
node type:
'
%s
'"
%
json_node
[
0
]
)
def
_add_edge_path
(
from_json_node
,
to_json_node
,
path
):
from_x
,
from_y
=
_xy_out
(
from_json_node
)
...
...
@@ -161,12 +172,10 @@ class ActivityDiagram(QGraphicsItem):
def
paint
(
self
,
painter
,
_option
,
_widget
):
w
=
ACTIVITY_W
h
=
ACTIVITY_H
title_w
=
self
.
bounding_rect
.
width
()
# title
painter
.
drawText
(
QRectF
(
0
,
TITLE_Y
,
title_w
,
h
),
Qt
.
AlignCenter
,
painter
.
drawText
(
QRectF
(
0
,
TITLE_Y
,
title_w
,
20
),
Qt
.
AlignCenter
,
self
.
title
)
# painter_path of nodes and edges
...
...
@@ -174,8 +183,18 @@ class ActivityDiagram(QGraphicsItem):
# any text
for
node
in
self
.
nodes
:
if
node
[
0
]
==
"
a
"
:
# activity has text
if
node
[
0
]
==
"
a
"
:
# activity
w
=
ACTIVITY_W
h
=
ACTIVITY_H
x
,
y
=
_xy
(
node
)
painter
.
drawText
(
QRectF
(
x
-
w
/
2
,
y
-
h
/
2
,
w
,
h
),
Qt
.
AlignCenter
,
node
[
4
])
elif
node
[
0
]
==
"
b
"
:
# branch
w
=
BRANCH_W
h
=
BRANCH_H
x
,
y
=
_xy
(
node
)
painter
.
drawText
(
QRectF
(
x
-
ACTIVITY_W
/
2
,
y
-
h
/
2
,
w
,
h
),
Qt
.
AlignCenter
,
node
[
5
])
else
:
pass
# some nodes don't have text
This diff is collapsed.
Click to expand it.
python/views/gantt_chart.py
+
12
−
10
View file @
f8f696f3
...
...
@@ -6,7 +6,8 @@ from PyQt5.QtWidgets import QGraphicsItem
from
next_graphics_index
import
next_graphics_index
MAX_BAR_W
=
200
BAR_H
=
20
ROW_H
=
20
ROW_SPACING
=
4
CHART_Y
=
20
+
20
+
20
# 2 titles and spacing
def
_text_width
(
text
):
...
...
@@ -67,7 +68,7 @@ class GanttChart(QGraphicsItem):
self
.
gantt_chart_w
=
max
([
_text_width
(
self
.
title
),
_text_width
(
self
.
legend
),
self
.
max_bar_name_w
+
MAX_BAR_W
])
self
.
gantt_chart_h
=
CHART_Y
+
BAR
_H
*
self
.
num_bars
self
.
gantt_chart_h
=
CHART_Y
+
ROW
_H
*
self
.
num_bars
# rectangle for mouse sense
self
.
bounding_path
=
QPainterPath
()
...
...
@@ -101,13 +102,14 @@ class GanttChart(QGraphicsItem):
self
.
legend
)
# bars
s
=
ROW_SPACING
/
2
for
i
in
range
(
len
(
self
.
bar_names
)):
# bar names
painter
.
drawText
(
QRectF
(
2
,
CHART_Y
+
BAR
_H
*
i
,
CHART_Y
+
ROW
_H
*
i
,
self
.
max_bar_name_w
,
BAR
_H
),
ROW
_H
),
Qt
.
AlignCenter
,
self
.
bar_names
[
i
])
# non-zero start time bar value labels
...
...
@@ -116,23 +118,23 @@ class GanttChart(QGraphicsItem):
if
start
>
0
:
painter
.
drawText
(
QRectF
(
self
.
max_bar_name_w
,
CHART_Y
+
BAR
_H
*
i
,
CHART_Y
+
ROW
_H
*
i
,
start_x
,
BAR
_H
),
ROW
_H
),
Qt
.
AlignCenter
,
"
%s
"
%
self
.
bar_starts
[
i
])
# stop time bar value labels
stop
=
self
.
bar_stops
[
i
]
stop_x
=
stop
*
self
.
bar_scale
painter
.
drawText
(
QRectF
(
self
.
max_bar_name_w
+
start_x
,
CHART_Y
+
BAR
_H
*
i
,
CHART_Y
+
ROW
_H
*
i
,
stop_x
,
BAR
_H
),
ROW
_H
),
Qt
.
AlignCenter
,
"
%s
"
%
self
.
bar_stops
[
i
])
# stop time bar
painter
.
drawRect
(
self
.
max_bar_name_w
+
start_x
,
CHART_Y
+
BAR
_H
*
i
,
CHART_Y
+
ROW
_H
*
i
+
ROW_SPACING
/
2
,
stop_x
,
BAR_H
)
ROW_H
-
ROW_SPACING
)
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment