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
Bliss
bliss
Commits
1a34c16d
Commit
1a34c16d
authored
May 21, 2021
by
Valentin Valls
Browse files
Fix copyItemConfig type checking
parent
db09153a
Pipeline
#47157
passed with stages
in 134 minutes and 21 seconds
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
bliss/flint/helper/model_helper.py
View file @
1a34c16d
...
...
@@ -732,11 +732,9 @@ def copyItemsFromRoiNames(
def
copyItemConfig
(
sourceItem
:
plot_model
.
Item
,
destinationItem
:
plot_model
.
Item
):
"""Copy the configuration and the item tree from a source item to a
destination item"""
if
not
isinstance
(
destinationItem
,
type
(
sourceItem
)):
raise
TypeError
(
"Both items must have the same type. Found %s"
%
type
(
destinationItem
)
)
if
isinstance
(
sourceItem
,
plot_item_model
.
CurveItem
):
if
isinstance
(
sourceItem
,
plot_item_model
.
CurveItem
)
and
isinstance
(
destinationItem
,
plot_item_model
.
CurveItem
):
destinationItem
.
setVisible
(
sourceItem
.
isVisible
())
destinationItem
.
setYAxis
(
sourceItem
.
yAxis
())
...
...
@@ -752,10 +750,16 @@ def copyItemConfig(sourceItem: plot_model.Item, destinationItem: plot_model.Item
newItem
.
setSource
(
destinationSource
)
destinationPlot
.
addItem
(
newItem
)
sourceToDest
[
item
]
=
newItem
elif
isinstance
(
sourceItem
,
plot_item_model
.
RoiItem
):
elif
isinstance
(
sourceItem
,
plot_item_model
.
RoiItem
)
and
isinstance
(
destinationItem
,
plot_item_model
.
RoiItem
):
destinationItem
.
setVisible
(
sourceItem
.
isVisible
())
else
:
raise
TypeError
(
"Only available for curve item. Found %s"
%
type
(
sourceItem
))
raise
TypeError
(
"No copy available from item type %s to %s"
%
(
type
(
sourceItem
),
type
(
destinationItem
))
)
def
updateXAxis
(
...
...
tests/qt/flint/helper/test_model_helper.py
View file @
1a34c16d
...
...
@@ -843,6 +843,16 @@ def test_update_xaxis_with_index():
assert
items
[
0
].
yChannel
().
name
()
==
"y1"
def
test_copy_config__with_xaxis_item
():
"""Check that we can copy config between 2 different kinds of CurveItem"""
plot
=
plot_item_model
.
CurvePlot
()
i1
=
add_item
(
plot
,
"x1"
,
"y1"
)
i1
.
setYAxis
(
"right"
)
i2
=
add_item
(
plot
,
None
,
"y2"
,
xIndex
=
True
)
model_helper
.
copyItemConfig
(
i1
,
i2
)
assert
i2
.
yAxis
()
==
"right"
def
test_update_xaxis_index_with_channel
():
plot
=
plot_item_model
.
CurvePlot
()
add_item
(
plot
,
None
,
"y1"
,
xIndex
=
True
)
...
...
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