@@ -21,7 +21,7 @@ def __init__(self, *args, **kwargs):
21
21
# set colormaps
22
22
cmaps = ["viridis" , "plasma" , "afmhot" , "seismic" ]
23
23
for cm in cmaps :
24
- self .qmpa_cmap_cb .addItem (cm )
24
+ self .qmpa_cmap_cb .addItem (cm , cm )
25
25
self .qmpa_cmap_cb .setCurrentIndex (0 )
26
26
self .qmap_data_cb .currentIndexChanged .connect (
27
27
self .on_qmap_data_changed )
@@ -44,8 +44,9 @@ def mpl_qmap_update(self):
44
44
if self .fd .tabs .currentWidget () == self :
45
45
fdist = self .current_curve
46
46
# Get all selected curves with the same path
47
- fdist_map = self .fd .selected_curves .subgroup_with_path (fdist .path )
48
- self .update_qmap (fdist_map , fdist_map .index (fdist ))
47
+ fdist_group = self .fd .selected_curves .subgroup_with_path (
48
+ fdist .path )
49
+ self .update_qmap (fdist_group , fdist )
49
50
50
51
def on_qmap_cmap_changed (self ):
51
52
"""colormap selection changed"""
@@ -57,7 +58,7 @@ def on_qmap_data_changed(self):
57
58
self .qmap_sp_range1 .blockSignals (True )
58
59
self .qmap_sp_range2 .blockSignals (True )
59
60
if hasattr (self , "_cache_qmap_spin_ctl" ):
60
- data = self .qmap_data_cb .currentIndex ()
61
+ data = self .qmap_data_cb .currentData ()
61
62
if data in self ._cache_qmap_spin_ctl :
62
63
vmin , vmax = self ._cache_qmap_spin_ctl [data ]
63
64
else :
@@ -73,7 +74,7 @@ def on_qmap_min_max_changed(self):
73
74
# store spin control values for data column
74
75
vmin = self .qmap_sp_range1 .value ()
75
76
vmax = self .qmap_sp_range2 .value ()
76
- data = self .qmap_data_cb .currentIndex ()
77
+ data = self .qmap_data_cb .currentData ()
77
78
if not hasattr (self , "_cache_qmap_spin_ctl" ):
78
79
self ._cache_qmap_spin_ctl = {}
79
80
self ._cache_qmap_spin_ctl [data ] = (vmin , vmax )
@@ -92,12 +93,29 @@ def on_qmap_selection(self, idx):
92
93
item = fd .list_curves .topLevelItem (idcurve )
93
94
fd .list_curves .setCurrentItem (item )
94
95
95
- def update_qmap (self , fdist_map , index ):
96
+ def update_qmap (self , fdist_group , fdist ):
97
+ """Update the QMap plotting data
98
+
99
+ Parameters
100
+ ----------
101
+ fdist_group: nanite.IndentationGroup
102
+ Indentation group containing all curves that will be
103
+ part of the map
104
+ fdist: nanite.Indentation
105
+ Indentation curve that is currently selected. If `fdist`
106
+ is not in `fdist_group`, then the red selection square
107
+ is hidden.
108
+ """
109
+ if fdist in fdist_group :
110
+ index = fdist_group .index (fdist )
111
+ else :
112
+ index = None
113
+
96
114
# Build list of possible selections
97
115
selist = nanite .qmap .available_features
98
116
99
117
# Get plotting parameter and check if it makes sense
100
- feature = self .qmap_data_cb .currentText ()
118
+ feature = self .qmap_data_cb .currentData ()
101
119
if not feature or feature not in selist :
102
120
# Use a default plotting map
103
121
feature = "data min height"
@@ -113,19 +131,22 @@ def update_qmap(self, fdist_map, index):
113
131
self .qmap_data_cb .removeItem (0 )
114
132
# add new items
115
133
for item in selist :
116
- self .qmap_data_cb .addItem (item )
134
+ self .qmap_data_cb .addItem (item , item )
117
135
self .qmap_data_cb .setCurrentIndex (selist .index (feature ))
118
136
self .qmap_data_cb .blockSignals (False )
119
137
120
- if len (fdist_map ) > 1 :
138
+ if len (fdist_group ) > 1 :
121
139
# Get map data
122
- qmap = nanite .QMap (fdist_map )
140
+ qmap = nanite .QMap (fdist_group )
123
141
# update plot
124
142
self .mpl_qmap .update (qmap = qmap ,
125
143
feature = feature ,
126
- cmap = self .qmpa_cmap_cb .currentText (),
144
+ cmap = self .qmpa_cmap_cb .currentData (),
127
145
vmin = self .qmap_sp_range1 .value (),
128
146
vmax = self .qmap_sp_range2 .value ())
129
- self .mpl_qmap .set_selection_by_index (index )
147
+ if index is not None :
148
+ self .mpl_qmap .set_selection_by_index (index )
149
+ else :
150
+ self .mpl_qmap .show_selection (False )
130
151
else :
131
152
self .mpl_qmap .reset ()
0 commit comments