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
8eef7392
Commit
8eef7392
authored
May 18, 2022
by
Valentin Valls
Browse files
Rework item creation UI as an item param editor
parent
3960e2fd
Pipeline
#75286
passed with stages
in 120 minutes and 16 seconds
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
bliss/flint/widgets/curve_plot_property.py
View file @
8eef7392
...
...
@@ -270,13 +270,13 @@ class _AddItemAction(qt.QWidgetAction):
menu
:
qt
.
QMenu
=
self
.
sender
()
menu
.
clear
()
availableItem
Fac
tor
y
=
{
availableItem
ParamEdi
tor
=
{
MaxCurveItem
:
None
,
MinCurveItem
:
None
,
DerivativeItem
:
None
,
NegativeItem
:
None
,
GaussianFitItem
:
None
,
NormalizedCurveItem
:
self
.
__
create
Normalized
,
NormalizedCurveItem
:
self
.
__
edit
Normalized
Params
,
NormalizedZeroOneItem
:
None
,
}
...
...
@@ -284,14 +284,14 @@ class _AddItemAction(qt.QWidgetAction):
if
isinstance
(
item
,
plot_item_model
.
CurveMixIn
):
menu
.
addSection
(
"Statistics"
)
for
className
,
chassFac
tor
y
in
availableItem
Fac
tor
y
.
items
():
for
className
,
edi
tor
in
availableItem
ParamEdi
tor
.
items
():
try
:
name
=
className
.
NAME
except
Exception
:
name
=
className
.
__name__
if
c
h
ass
Factory
is
None
:
chassFactory
=
functools
.
partial
(
self
.
__createChildItem
,
className
)
chassFactory
=
functools
.
partial
(
self
.
__createChildItem
,
c
l
ass
Name
,
editor
)
action
=
qt
.
QAction
(
self
)
action
.
setText
(
name
)
icon
=
icons
.
getQIcon
(
"flint:icons/item-stats"
)
...
...
@@ -307,23 +307,39 @@ class _AddItemAction(qt.QWidgetAction):
def
__selectionChanged
(
self
,
current
:
plot_model
.
Item
):
self
.
defaultWidget
().
setEnabled
(
current
is
not
None
)
def
__createChildItem
(
self
,
itemClass
):
def
__createChildItem
(
self
,
itemClass
,
itemEditor
):
parentItem
=
self
.
parent
().
selectedPlotItem
()
if
parentItem
is
not
None
:
plotModel
=
parentItem
.
plot
()
newItem
=
itemClass
(
plotModel
)
newItem
.
setSource
(
parentItem
)
with
plotModel
.
transaction
():
plotModel
.
addItem
(
newItem
)
# FIXME: It would be better to make it part of the model
plotModel
.
tagUserEditTime
()
if
parentItem
is
None
:
return
plotModel
=
parentItem
.
plot
()
newItem
=
itemClass
(
plotModel
)
if
itemEditor
is
not
None
:
result
=
itemEditor
(
newItem
)
if
not
result
:
newItem
.
deleteLater
()
return
def
__createNormalized
(
self
):
# Sanity check as we did a user selection in between it is not atomic
parentItem
=
self
.
parent
().
selectedPlotItem
()
if
parentItem
is
None
:
newItem
.
deleteLater
()
return
# Avoid strong reference
parentItem
=
None
plotModel
=
parentItem
.
plot
()
if
plotModel
is
None
:
newItem
.
deleteLater
()
return
newItem
.
setSource
(
parentItem
)
with
plotModel
.
transaction
():
plotModel
.
addItem
(
newItem
)
# FIXME: It would be better to make it part of the model
plotModel
.
tagUserEditTime
()
def
__editNormalizedParams
(
self
,
item
:
NormalizedCurveItem
):
"""Edit NormalizedCurveItem parameters.
Returns true if the edition succeeded, else false.
"""
parentWidget
=
self
.
parent
()
scan
=
parentWidget
.
scan
()
dialog
=
SelectChannelDialog
(
parentWidget
)
...
...
@@ -333,22 +349,11 @@ class _AddItemAction(qt.QWidgetAction):
return
monitorName
=
dialog
.
selectedChannelName
()
if
monitorName
is
None
:
return
# As we did a user selection make sure the item is still there
parentItem
=
self
.
parent
().
selectedPlotItem
()
if
parentItem
is
None
:
return
plotModel
=
parentItem
.
plot
()
if
plotModel
is
None
:
return
newItem
=
NormalizedCurveItem
(
plotModel
)
return
False
plotModel
=
item
.
plot
()
channel
=
plot_model
.
ChannelRef
(
plotModel
,
monitorName
)
newItem
.
setMonitorChannel
(
channel
)
newItem
.
setSource
(
parentItem
)
with
plotModel
.
transaction
():
plotModel
.
addItem
(
newItem
)
# FIXME: It would be better to make it part of the model
plotModel
.
tagUserEditTime
()
item
.
setMonitorChannel
(
channel
)
return
True
class
_DataItem
(
_property_tree_helper
.
ScanRowItem
):
...
...
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