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
a32dbe1c
Commit
a32dbe1c
authored
2 years ago
by
Oscar Gustafsson
Browse files
Options
Downloads
Plain Diff
Merge branch 'orthogonallines' into 'master'
Add support for orthogonal lines See merge request
!104
parents
99e383b1
d49e2ddc
No related branches found
No related tags found
1 merge request
!104
Add support for orthogonal lines
Pipeline
#88076
passed
2 years ago
Stage: test
Stage: deploy
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 @
a32dbe1c
...
@@ -14,3 +14,4 @@ MIN_HEIGHT_SCENE = 520
...
@@ -14,3 +14,4 @@ MIN_HEIGHT_SCENE = 520
# Interface
# Interface
LINECOLOR
=
QColor
(
*
SIGNAL_COLOR
)
LINECOLOR
=
QColor
(
*
SIGNAL_COLOR
)
GRID
=
19
This diff is collapsed.
Click to expand it.
b_asic/GUI/arrow.py
+
26
−
7
View file @
a32dbe1c
from
qtpy.QtCore
import
QPointF
from
qtpy.QtCore
import
QPointF
from
qtpy.QtGui
import
QPen
,
QP
olygonF
from
qtpy.QtGui
import
QPen
,
QP
ainterPath
from
qtpy.QtWidgets
import
QGraphicsP
olygon
Item
,
QMenu
from
qtpy.QtWidgets
import
QGraphicsP
ath
Item
,
QMenu
from
b_asic.GUI._preferences
import
LINECOLOR
,
PORTHEIGHT
,
PORTWIDTH
from
b_asic.GUI._preferences
import
LINECOLOR
,
PORTHEIGHT
,
PORTWIDTH
from
b_asic.signal
import
Signal
from
b_asic.signal
import
Signal
class
Arrow
(
QGraphicsP
olygon
Item
):
class
Arrow
(
QGraphicsP
ath
Item
):
"""
Arrow/connection in signal flow graph GUI.
"""
"""
Arrow/connection in signal flow graph GUI.
"""
def
__init__
(
self
,
source
,
destination
,
window
,
signal
=
None
,
parent
=
None
):
def
__init__
(
self
,
source
,
destination
,
window
,
signal
=
None
,
parent
=
None
):
...
@@ -80,10 +80,29 @@ class Arrow(QGraphicsPolygonItem):
...
@@ -80,10 +80,29 @@ class Arrow(QGraphicsPolygonItem):
"""
"""
Draw a line connecting self.source with self.destination. Used as callback when moving operations.
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
))
self
.
setPen
(
QPen
(
LINECOLOR
,
3
))
x0
=
self
.
source
.
operation
.
x
()
+
self
.
source
.
x
()
+
PORTWIDTH
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
()
x1
=
self
.
destination
.
operation
.
x
()
+
self
.
destination
.
x
()
y1
=
self
.
destination
.
operation
.
y
()
+
self
.
destination
.
y
()
+
PORTHEIGHT
/
2
y1
=
(
p
=
QPolygonF
()
<<
QPointF
(
x0
,
y0
)
<<
QPointF
(
x1
,
y1
)
self
.
destination
.
operation
.
y
()
self
.
setPolygon
(
p
)
+
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 @
a32dbe1c
...
@@ -12,7 +12,7 @@ from qtpy.QtWidgets import QAction, QMenu, QPushButton
...
@@ -12,7 +12,7 @@ from qtpy.QtWidgets import QAction, QMenu, QPushButton
from
b_asic.GUI.properties_window
import
PropertiesWindow
from
b_asic.GUI.properties_window
import
PropertiesWindow
from
b_asic.GUI.utils
import
decorate_class
,
handle_error
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
)
@decorate_class
(
handle_error
)
...
@@ -105,6 +105,15 @@ class DragButton(QPushButton):
...
@@ -105,6 +105,15 @@ class DragButton(QPushButton):
else
:
else
:
self
.
select_button
(
event
.
modifiers
())
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
)
super
().
mouseReleaseEvent
(
event
)
def
_toggle_button
(
self
,
pressed
=
False
):
def
_toggle_button
(
self
,
pressed
=
False
):
...
@@ -117,7 +126,9 @@ class DragButton(QPushButton):
...
@@ -117,7 +126,9 @@ class DragButton(QPushButton):
path_to_image
=
os
.
path
.
join
(
path_to_image
=
os
.
path
.
join
(
os
.
path
.
dirname
(
__file__
),
os
.
path
.
dirname
(
__file__
),
"
operation_icons
"
,
"
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
.
setIcon
(
QIcon
(
path_to_image
))
self
.
setIconSize
(
QSize
(
MINBUTTONSIZE
,
MINBUTTONSIZE
))
self
.
setIconSize
(
QSize
(
MINBUTTONSIZE
,
MINBUTTONSIZE
))
...
...
This diff is collapsed.
Click to expand it.
b_asic/GUI/main_window.py
+
2
−
1
View file @
a32dbe1c
...
@@ -37,6 +37,7 @@ from b_asic.GUI.port_button import PortButton
...
@@ -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.select_sfg_window
import
SelectSFGWindow
from
b_asic.GUI._preferences
import
(
from
b_asic.GUI._preferences
import
(
GAP
,
GAP
,
GRID
,
MINBUTTONSIZE
,
MINBUTTONSIZE
,
PORTHEIGHT
,
PORTHEIGHT
,
PORTWIDTH
,
PORTWIDTH
,
...
@@ -540,7 +541,7 @@ class MainWindow(QMainWindow):
...
@@ -540,7 +541,7 @@ class MainWindow(QMainWindow):
op
.
graph_id
,
op
,
op
.
type_name
().
lower
(),
True
,
window
=
self
op
.
graph_id
,
op
,
op
.
type_name
().
lower
(),
True
,
window
=
self
)
)
if
position
is
None
:
if
position
is
None
:
attr_button
.
move
(
250
,
100
)
attr_button
.
move
(
GRID
*
3
,
GRID
*
2
)
else
:
else
:
attr_button
.
move
(
*
position
)
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