Changeset 5d89f43 in sasview for src/sas/qtgui/ColorMap.py
- Timestamp:
- Jan 25, 2017 8:51:26 AM (8 years ago)
- Branches:
- ESS_GUI, ESS_GUI_Docs, ESS_GUI_batch_fitting, ESS_GUI_bumps_abstraction, ESS_GUI_iss1116, ESS_GUI_iss879, ESS_GUI_iss959, ESS_GUI_opencl, ESS_GUI_ordering, ESS_GUI_sync_sascalc
- Children:
- 3bdbfcc
- Parents:
- 03c372d
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/sas/qtgui/ColorMap.py
- Property mode changed from 100755 to 100644
r03c372d r5d89f43 13 13 from sas.sasgui.guiframe.dataFitting import Data2D 14 14 from sas.qtgui.GuiUtils import formatNumber 15 from rangeSlider import RangeSlider 15 16 16 17 DEFAULT_MAP = 'jet' … … 20 21 21 22 class ColorMap(QtGui.QDialog, Ui_ColorMapUI): 23 apply_signal = QtCore.pyqtSignal(tuple, str) 22 24 def __init__(self, parent=None, cmap=None, vmin=0.0, vmax=100.0, data=None): 23 25 super(ColorMap, self).__init__() … … 32 34 self.rmaps = sorted(set(self.all_maps) - set(self.maps)) 33 35 34 self.vmin = vmin35 self.vmax = vmax36 self.vmin = self.vmin_orig = vmin 37 self.vmax = self.vmax_orig = vmax 36 38 37 39 # Initialize detector labels … … 40 42 # Initialize the combo box 41 43 self.initMapCombobox() 44 45 self.initRangeSlider() 42 46 43 47 # Add the color map component … … 52 56 self.txtMaxAmplitude.setValidator(validator_max) 53 57 58 # Set the initial amplitudes 59 self.txtMinAmplitude.setText(formatNumber(self.vmin)) 60 self.txtMaxAmplitude.setText(formatNumber(self.vmax)) 61 54 62 # Enforce constant size on the widget 55 63 self.setFixedSize(self.minimumSizeHint()) … … 61 69 self.chkReverse.stateChanged.connect(self.onColorMapReversed) 62 70 63 # Handle the reset button click71 # Handle the Reset button click 64 72 self.buttonBox.button(QtGui.QDialogButtonBox.Reset).clicked.connect(self.onReset) 73 74 # Handle the Apply button click 75 self.buttonBox.button(QtGui.QDialogButtonBox.Apply).clicked.connect(self.onApply) 65 76 66 77 # Handle the amplitude setup … … 86 97 # Go back to original settings 87 98 self._cmap = self._cmap_orig 99 self.vmin = self.vmin_orig 100 self.vmax = self.vmax_orig 88 101 self._norm = mpl.colors.Normalize(vmin=self.vmin, vmax=self.vmax) 89 self.txtM axAmplitude.clear()90 self.txtM inAmplitude.clear()102 self.txtMinAmplitude.setText(formatNumber(self.vmin)) 103 self.txtMaxAmplitude.setText(formatNumber(self.vmax)) 91 104 self.initMapCombobox() 105 self.slider.setMinimum(self.vmin) 106 self.slider.setMaximum(self.vmax) 107 self.slider.setLowValue(self.vmin) 108 self.slider.setHighValue(self.vmax) 92 109 # Redraw the widget 93 110 self.redrawColorBar() 94 111 self.canvas.draw() 112 113 def onApply(self): 114 """ 115 Respond to the Apply button click. 116 Send a signal to the plotter with vmin/vmax/cmap for chart update 117 """ 118 self.apply_signal.emit(self.norm(), self.cmap()) 95 119 96 120 def initDetectorData(self): … … 125 149 self.cbColorMap.setCurrentIndex(self.cbColorMap.findText(self._cmap)) 126 150 151 def initRangeSlider(self): 152 """ 153 Create and display the double slider for data range mapping. 154 """ 155 self.slider = RangeSlider() 156 self.slider.setMinimum(self.vmin) 157 self.slider.setMaximum(self.vmax) 158 self.slider.setLowValue(self.vmin) 159 self.slider.setHighValue(self.vmax) 160 self.slider.setOrientation(QtCore.Qt.Horizontal) 161 162 self.slider_label = QtGui.QLabel() 163 self.slider_label.setText("Drag the sliders to adjust color range.") 164 165 def set_vmin(value): 166 self.vmin = value 167 self.txtMinAmplitude.setText(str(value)) 168 self.updateMap() 169 def set_vmax(value): 170 self.vmax = value 171 self.txtMaxAmplitude.setText(str(value)) 172 self.updateMap() 173 174 self.slider.lowValueChanged.connect(set_vmin) 175 self.slider.highValueChanged.connect(set_vmin) 176 177 def updateMap(self): 178 self._norm = mpl.colors.Normalize(vmin=self.vmin, vmax=self.vmax) 179 self.redrawColorBar() 180 self.canvas.draw() 181 127 182 def initColorMap(self): 128 183 """ … … 131 186 self.fig = mpl.figure.Figure(figsize=(4, 1)) 132 187 self.ax1 = self.fig.add_axes([0.05, 0.65, 0.9, 0.15]) 188 133 189 self._norm = mpl.colors.Normalize(vmin=self.vmin, vmax=self.vmax) 134 190 self.redrawColorBar() 135 191 self.canvas = FigureCanvas(self.fig) 192 136 193 layout = QtGui.QVBoxLayout() 194 layout.addWidget(self.slider_label) 195 layout.addWidget(self.slider) 137 196 layout.addWidget(self.canvas) 197 138 198 self.widget.setLayout(layout) 139 199 … … 154 214 norm=self._norm, 155 215 orientation='horizontal') 156 self.cb.set_label(' Detector Colors')216 self.cb.set_label('Color map range') 157 217 158 218 def onColorMapReversed(self, isChecked): … … 177 237 178 238 self._cmap = new_map 179 # Clear ningthe content of the combobox.239 # Clear the content of the combobox. 180 240 # Needs signal blocking, or else onMapIndexChange() spoils it all 181 241 self.cbColorMap.blockSignals(True)
Note: See TracChangeset
for help on using the changeset viewer.