Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
B-ASIC - Better ASIC Toolbox
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
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
Computer Engineering
B-ASIC - Better ASIC Toolbox
Commits
d49e2ddc
Commit
d49e2ddc
authored
2 years ago
by
Oscar Gustafsson
Browse files
Options
Downloads
Patches
Plain Diff
Add support for orthogonal lines
parent
99e383b1
No related branches found
No related tags found
1 merge request
!104
Add support for orthogonal lines
Pipeline
#88074
passed
2 years ago
Stage: test
Changes
4
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
b_asic/GUI/_preferences.py
+1
-0
1 addition, 0 deletions
b_asic/GUI/_preferences.py
b_asic/GUI/arrow.py
+26
-7
26 additions, 7 deletions
b_asic/GUI/arrow.py
b_asic/GUI/drag_button.py
+13
-2
13 additions, 2 deletions
b_asic/GUI/drag_button.py
b_asic/GUI/main_window.py
+2
-1
2 additions, 1 deletion
b_asic/GUI/main_window.py
with
42 additions
and
10 deletions
b_asic/GUI/_preferences.py
+
1
−
0
View file @
d49e2ddc
...
...
@@ -14,3 +14,4 @@ MIN_HEIGHT_SCENE = 520
# Interface
LINECOLOR
=
QColor
(
*
SIGNAL_COLOR
)
GRID
=
19
This diff is collapsed.
Click to expand it.
b_asic/GUI/arrow.py
+
26
−
7
View file @
d49e2ddc
from
qtpy.QtCore
import
QPointF
from
qtpy.QtGui
import
QPen
,
QP
olygonF
from
qtpy.QtWidgets
import
QGraphicsP
olygon
Item
,
QMenu
from
qtpy.QtGui
import
QPen
,
QP
ainterPath
from
qtpy.QtWidgets
import
QGraphicsP
ath
Item
,
QMenu
from
b_asic.GUI._preferences
import
LINECOLOR
,
PORTHEIGHT
,
PORTWIDTH
from
b_asic.signal
import
Signal
class
Arrow
(
QGraphicsP
olygon
Item
):
class
Arrow
(
QGraphicsP
ath
Item
):
"""
Arrow/connection in signal flow graph GUI.
"""
def
__init__
(
self
,
source
,
destination
,
window
,
signal
=
None
,
parent
=
None
):
...
...
@@ -80,10 +80,29 @@ class Arrow(QGraphicsPolygonItem):
"""
Draw a line connecting self.source with self.destination. Used as callback when moving operations.
"""
ORTHOGONAL
=
True
OFFSET
=
2
*
PORTWIDTH
self
.
setPen
(
QPen
(
LINECOLOR
,
3
))
x0
=
self
.
source
.
operation
.
x
()
+
self
.
source
.
x
()
+
PORTWIDTH
y0
=
self
.
source
.
operation
.
y
()
+
self
.
source
.
y
()
+
PORTHEIGHT
/
2
y0
=
self
.
source
.
operation
.
y
()
+
self
.
source
.
y
()
+
PORTHEIGHT
/
2
x1
=
self
.
destination
.
operation
.
x
()
+
self
.
destination
.
x
()
y1
=
self
.
destination
.
operation
.
y
()
+
self
.
destination
.
y
()
+
PORTHEIGHT
/
2
p
=
QPolygonF
()
<<
QPointF
(
x0
,
y0
)
<<
QPointF
(
x1
,
y1
)
self
.
setPolygon
(
p
)
y1
=
(
self
.
destination
.
operation
.
y
()
+
self
.
destination
.
y
()
+
PORTHEIGHT
/
2
)
xmid
=
(
x0
+
x1
)
/
2
ymid
=
(
y0
+
y1
)
/
2
p
=
QPainterPath
(
QPointF
(
x0
,
y0
))
if
y0
==
y1
or
not
ORTHOGONAL
:
pass
elif
abs
(
x0
-
x1
)
<=
OFFSET
/
2
:
p
.
lineTo
(
QPointF
(
x0
+
OFFSET
,
y0
))
p
.
lineTo
(
QPointF
(
x0
+
OFFSET
,
ymid
))
p
.
lineTo
(
QPointF
(
x0
-
OFFSET
,
ymid
))
p
.
lineTo
(
QPointF
(
x0
-
OFFSET
,
y1
))
else
:
p
.
lineTo
(
QPointF
(
xmid
,
y0
))
p
.
lineTo
(
QPointF
(
xmid
,
y1
))
p
.
lineTo
(
QPointF
(
x1
,
y1
))
self
.
setPath
(
p
)
This diff is collapsed.
Click to expand it.
b_asic/GUI/drag_button.py
+
13
−
2
View file @
d49e2ddc
...
...
@@ -12,7 +12,7 @@ from qtpy.QtWidgets import QAction, QMenu, QPushButton
from
b_asic.GUI.properties_window
import
PropertiesWindow
from
b_asic.GUI.utils
import
decorate_class
,
handle_error
from
b_asic.GUI._preferences
import
MINBUTTONSIZE
from
b_asic.GUI._preferences
import
GRID
,
MINBUTTONSIZE
@decorate_class
(
handle_error
)
...
...
@@ -105,6 +105,15 @@ class DragButton(QPushButton):
else
:
self
.
select_button
(
event
.
modifiers
())
# Snap
point
=
self
.
pos
()
x
=
point
.
x
()
y
=
point
.
y
()
newx
=
GRID
*
round
(
x
/
GRID
)
newy
=
GRID
*
round
(
y
/
GRID
)
self
.
move
(
newx
,
newy
)
self
.
_window
.
scene
.
update
()
self
.
_window
.
graphic_view
.
update
()
super
().
mouseReleaseEvent
(
event
)
def
_toggle_button
(
self
,
pressed
=
False
):
...
...
@@ -117,7 +126,9 @@ class DragButton(QPushButton):
path_to_image
=
os
.
path
.
join
(
os
.
path
.
dirname
(
__file__
),
"
operation_icons
"
,
f
"
{
self
.
operation_path_name
}{
'
_grey.png
'
if
self
.
pressed
else
'
.png
'
}
"
,
(
f
"
{
self
.
operation_path_name
}{
'
_grey.png
'
if
self
.
pressed
else
'
.png
'
}
"
),
)
self
.
setIcon
(
QIcon
(
path_to_image
))
self
.
setIconSize
(
QSize
(
MINBUTTONSIZE
,
MINBUTTONSIZE
))
...
...
This diff is collapsed.
Click to expand it.
b_asic/GUI/main_window.py
+
2
−
1
View file @
d49e2ddc
...
...
@@ -37,6 +37,7 @@ from b_asic.GUI.port_button import PortButton
from
b_asic.GUI.select_sfg_window
import
SelectSFGWindow
from
b_asic.GUI._preferences
import
(
GAP
,
GRID
,
MINBUTTONSIZE
,
PORTHEIGHT
,
PORTWIDTH
,
...
...
@@ -540,7 +541,7 @@ class MainWindow(QMainWindow):
op
.
graph_id
,
op
,
op
.
type_name
().
lower
(),
True
,
window
=
self
)
if
position
is
None
:
attr_button
.
move
(
250
,
100
)
attr_button
.
move
(
GRID
*
3
,
GRID
*
2
)
else
:
attr_button
.
move
(
*
position
)
...
...
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