Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
beat
beat.editor
Commits
d9c5aa88
Commit
d9c5aa88
authored
Aug 06, 2020
by
Flavio TARSETTI
Browse files
Merge branch '185_toolchain_preview' into 'master'
Toolchain preview in experiment editor See merge request
!145
parents
c5f86eb1
0b6f9c5e
Pipeline
#41813
passed with stages
in 27 minutes and 58 seconds
Changes
3
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
beat/editor/test/test_toolchaineditor.py
View file @
d9c5aa88
...
...
@@ -27,6 +27,7 @@ import pytest
import
simplejson
as
json
from
PyQt5.QtCore
import
QFile
from
PyQt5.QtWidgets
import
QGraphicsItem
from
PyQt5.QtWidgets
import
QGraphicsScene
from
PyQt5.QtWidgets
import
QGraphicsView
...
...
@@ -37,6 +38,7 @@ from ..widgets.toolchaineditor import BlockType
from
..widgets.toolchaineditor
import
LoopWidget
from
..widgets.toolchaineditor
import
ToolchainEditor
from
..widgets.toolchaineditor
import
ToolchainView
from
..widgets.toolchaineditor
import
ToolchainWidget
from
..widgets.toolchainscene
import
ToolchainScene
from
.conftest
import
prefix
from
.conftest
import
sync_prefix
...
...
@@ -171,8 +173,33 @@ class TestLoopWidget:
assert
listwidget
.
item
(
0
).
text
()
==
"No valid algorithm found"
class
TestToolchainWidget
:
"""Test the toolchain widget"""
@
pytest
.
mark
.
parametrize
(
"toolchain"
,
get_valid_toolchains
(
prefix
))
@
pytest
.
mark
.
parametrize
(
"editable"
,
[
True
,
False
])
def
test_editable
(
self
,
qtbot
,
test_prefix
,
toolchain
,
editable
):
reference_json
=
get_toolchain_declaration
(
test_prefix
,
toolchain
)
widget
=
ToolchainWidget
()
widget
.
show
()
qtbot
.
addWidget
(
widget
)
qtbot
.
waitForWindowShown
(
widget
)
widget
.
setEditionEnabled
(
editable
)
assert
widget
.
isEditionEnabled
()
==
editable
assert
widget
.
toolbar
.
isVisible
()
==
editable
widget
.
load
(
reference_json
)
reference_flags
=
QGraphicsItem
.
ItemIsSelectable
|
QGraphicsItem
.
ItemIsMovable
for
item
in
widget
.
scene
.
items
():
if
editable
:
assert
item
.
flags
()
and
reference_flags
else
:
assert
not
item
.
flags
()
and
reference_flags
class
TestToolchainEditor
:
"""Test that the
mock
editor works correctly"""
"""Test that the
toolchain
editor works correctly"""
@
pytest
.
mark
.
parametrize
(
"toolchain"
,
get_valid_toolchains
(
prefix
))
def
test_load_and_dump
(
self
,
qtbot
,
test_prefix
,
toolchain
):
...
...
beat/editor/widgets/experimenteditor.py
View file @
d9c5aa88
...
...
@@ -68,6 +68,7 @@ from .editor import AbstractAssetEditor
from
.scrollwidget
import
EditorListWidget
from
.scrollwidget
import
ScrollWidget
from
.spinboxes
import
NumpySpinBox
from
.toolchaineditor
import
ToolchainWidget
PARAMETER_TYPE_KEY
=
"parameter_type"
DEFAULT_VALUE_KEY
=
"default_value"
...
...
@@ -1153,6 +1154,8 @@ class ExperimentEditor(AbstractAssetEditor):
self
.
analyzers_widget
=
ContainerWidget
()
self
.
globalparameters_widget
=
GlobalParametersEditor
(
self
.
prefixPath
())
self
.
globalparameters_widget
.
setEnvironmentModel
(
self
.
processing_env_model
)
self
.
toolchain_widget
=
ToolchainWidget
()
self
.
toolchain_widget
.
setEditionEnabled
(
False
)
self
.
tabwidget
=
QTabWidget
()
self
.
tabwidget
.
addTab
(
self
.
datasets_widget
,
self
.
tr
(
"Datasets"
))
...
...
@@ -1164,6 +1167,7 @@ class ExperimentEditor(AbstractAssetEditor):
self
.
tabwidget
.
addTab
(
self
.
globalparameters_widget
,
self
.
tr
(
"Global parameters"
)
)
self
.
tabwidget
.
addTab
(
self
.
toolchain_widget
,
self
.
tr
(
"Toolchain"
))
self
.
layout
().
addWidget
(
self
.
tabwidget
)
...
...
@@ -1469,6 +1473,10 @@ class ExperimentEditor(AbstractAssetEditor):
for
widget
in
self
.
datasets_widget
.
widget_list
:
widget
.
loadToolchainData
(
toolchain
)
asset
=
Asset
(
self
.
prefix_path
,
AssetType
.
TOOLCHAIN
,
toolchain
)
if
asset
.
is_valid
:
self
.
toolchain_widget
.
load
(
asset
.
declaration
)
def
clearBlockErrors
(
self
):
"""Clear error hinting"""
...
...
beat/editor/widgets/toolchaineditor.py
View file @
d9c5aa88
...
...
@@ -28,7 +28,6 @@ from functools import partial
import
simplejson
as
json
from
beat.backend.python.algorithm
import
Algorithm
from
PyQt5.QtCore
import
QFile
from
PyQt5.QtCore
import
QPointF
from
PyQt5.QtCore
import
QRect
...
...
@@ -64,6 +63,8 @@ from PyQt5.QtWidgets import QToolBar
from
PyQt5.QtWidgets
import
QVBoxLayout
from
PyQt5.QtWidgets
import
QWidget
from
beat.backend.python.algorithm
import
Algorithm
from
..backend.asset
import
Asset
from
..backend.asset
import
AssetType
from
..backend.assetmodel
import
AssetModel
...
...
@@ -904,7 +905,7 @@ class Block(QGraphicsObject):
self
.
setAcceptHoverEvents
(
True
)
self
.
setFlag
(
QGraphicsItem
.
ItemIsSelectable
,
True
)
self
.
setFlag
(
QGraphicsItem
.
ItemIsMovable
)
self
.
setFlag
(
QGraphicsItem
.
ItemIsMovable
,
True
)
# Geometry settings
self
.
width
=
config
[
"width"
]
...
...
@@ -1107,6 +1108,10 @@ class Block(QGraphicsObject):
def
mouseDoubleClickEvent
(
self
,
event
):
"""Update block information"""
if
not
self
.
flags
()
and
QGraphicsItem
.
ItemIsSelectable
:
return
value
=
None
ok
=
False
block_updated
=
False
...
...
@@ -1421,6 +1426,7 @@ class ToolchainWidget(QWidget):
def
__init__
(
self
,
parent
=
None
):
super
().
__init__
(
parent
=
parent
)
self
.
__edition_enabled
=
True
self
.
json_object
=
{}
self
.
sequential_loop_processor_list
=
[]
...
...
@@ -1499,6 +1505,26 @@ class ToolchainWidget(QWidget):
)
action
.
setEnabled
(
False
)
def
__update_items
(
self
):
for
item
in
self
.
scene
.
items
():
item
.
setFlag
(
QGraphicsItem
.
ItemIsSelectable
,
self
.
__edition_enabled
)
item
.
setFlag
(
QGraphicsItem
.
ItemIsMovable
,
self
.
__edition_enabled
)
def
isEditionEnabled
(
self
):
"""Returns whether this widget allows edition"""
return
self
.
__edition_enabled
@
pyqtSlot
(
bool
)
def
setEditionEnabled
(
self
,
enabled
):
"""Sets whether this widget allows edition"""
if
self
.
__edition_enabled
==
enabled
:
return
self
.
__edition_enabled
=
enabled
self
.
toolbar
.
setVisible
(
enabled
)
self
.
__update_items
()
def
add_loop_block
(
self
):
loops
,
ok
=
LoopDialog
.
getLoops
(
self
,
...
...
@@ -1598,6 +1624,7 @@ class ToolchainWidget(QWidget):
block
.
dataChanged
.
emit
()
self
.
blocks
.
append
(
block
)
self
.
scene
.
addItem
(
block
)
self
.
__update_items
()
def
update_channel_path
(
self
,
block
,
old_channel
,
new_channel
):
# check if current block is synchronized on old_channel
...
...
@@ -1687,7 +1714,6 @@ class ToolchainWidget(QWidget):
block
.
dataChanged
.
connect
(
self
.
dataChanged
)
block
.
dataChanged
.
emit
()
self
.
blocks
.
append
(
block
)
self
.
scene
.
addItem
(
block
)
def
set_prefix_databases_algorithms_lists
(
self
,
...
...
@@ -1764,6 +1790,8 @@ class ToolchainWidget(QWidget):
self
.
connections
.
append
(
connection
)
self
.
scene
.
addItem
(
connection
)
self
.
__update_items
()
def
dump
(
self
):
"""Returns the json used to load the widget"""
...
...
Write
Preview
Supports
Markdown
0%
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!
Cancel
Please
register
or
sign in
to comment