Changeset 5584dee in sasview
- Timestamp:
- Nov 7, 2018 9:16:56 AM (6 years ago)
- Branches:
- ESS_GUI, ESS_GUI_batch_fitting, ESS_GUI_bumps_abstraction, ESS_GUI_iss1116, ESS_GUI_opencl, ESS_GUI_ordering, ESS_GUI_sync_sascalc
- Children:
- ebf86f1
- Parents:
- 1942f63
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/sas/qtgui/Utilities/ImageViewer.py
r1942f63 r5584dee 2 2 Image viewer widget. 3 3 """ 4 from PyQt5 import QtCore5 from PyQt5 import QtGui6 from PyQt5 import QtWidgets7 4 8 5 import os … … 10 7 import numpy as np 11 8 import matplotlib 12 matplotlib.interactive(False)13 9 import matplotlib.image as mpimg 10 11 from PyQt5 import QtWidgets 14 12 15 13 from sas.sascalc.dataloader.manipulations import reader2D_converter … … 23 21 from sas.qtgui.Utilities.UI.ImageViewerUI import Ui_ImageViewerUI 24 22 from sas.qtgui.Utilities.UI.ImageViewerOptionsUI import Ui_ImageViewerOptionsUI 23 matplotlib.interactive(False) 25 24 26 25 class ImageViewer(QtWidgets.QMainWindow, Ui_ImageViewerUI): … … 34 33 self.setupUi(self) 35 34 36 # add plotter to the frame35 # Other globals 37 36 self.plotter = None 38 37 self.hbox = None 38 self.filename = None 39 self.is_png = False 40 self.image = None 39 41 40 42 # disable menu items on empty canvas 41 43 self.disableMenus() 42 44 43 # set up signal callbacks44 self.addCallbacks()45 46 45 # set up menu item triggers 47 46 self.addTriggers() 48 49 def addCallbacks(self):50 pass51 47 52 48 def disableMenus(self): … … 121 117 """ 122 118 if self.plotter is not None: 123 self.plotter.onClipboardCopy()119 self.plotter.onClipboardCopy() 124 120 125 121 def actionConvertToData(self): … … 135 131 try: 136 132 self.convertImage(image, xmin, xmax, ymin, ymax, zscale) 137 except :138 err_msg = "Error occurred while converting Image to Data ."133 except Exception as ex: 134 err_msg = "Error occurred while converting Image to Data: " + str(ex) 139 135 logging.error(err_msg) 140 141 pass142 136 143 137 def actionHowTo(self): … … 174 168 # Any other formats (tiff, jpeg, etc) are passed 175 169 # to PIL which seems to have a problem in version 176 # 1.1.7 that causes a close error which shows up in 170 # 1.1.7 that causes a close error which shows up in 177 171 # the log file. This does not seem to have any adverse 178 172 # effects. PDB --- September 17, 2017. … … 184 178 origin = None 185 179 if self.is_png: 186 origin ='lower'180 origin = 'lower' 187 181 self.plotter.imageShow(flipped_image, origin=origin) 188 182 if not self.is_png: … … 191 185 ax.set_ylabel('y [pixel]') 192 186 self.plotter.figure.subplots_adjust(left=0.15, bottom=0.1, 193 right=0.95, top=0.95)187 right=0.95, top=0.95) 194 188 title = 'Picture: ' + self.filename 195 189 self.setWindowTitle(title) … … 197 191 except IOError as ex: 198 192 err_msg = "Failed to load '%s'.\n" % self.filename 199 logging.error(err_msg )193 logging.error(err_msg+str(ex)) 200 194 return 201 195 except Exception as ex: 202 196 err_msg = "Failed to show '%s'.\n" % self.filename 203 logging.error(err_msg )197 logging.error(err_msg+str(ex)) 204 198 return 205 199 … … 239 233 output.ymin = ymin 240 234 output.ymax = ymax 241 output.xaxis('\\rm{Q_{x}}', '\AA^{-1}')242 output.yaxis('\\rm{Q_{y}}', '\AA^{-1}')235 output.xaxis('\\rm{Q_{x}}', r'\AA^{-1}') 236 output.yaxis('\\rm{Q_{y}}', r'\AA^{-1}') 243 237 # Store loading process information 244 238 output.meta_data['loader'] = self.filename.split('.')[-1] + "Reader" … … 269 263 grey = np.rollaxis(rgb, axis=0) 270 264 else: 271 red, green, blue = np.rollaxis(rgb[..., :3], axis= 265 red, green, blue = np.rollaxis(rgb[..., :3], axis=-1) 272 266 grey = 0.299 * red + 0.587 * green + 0.114 * blue 273 267 max_i = rgb.max() 274 factor = 255.0 /max_i268 factor = 255.0/max_i 275 269 grey *= factor 276 270 return np.array(grey) … … 332 326 333 327 return (xmin, xmax, ymin, ymax, zscale) 334
Note: See TracChangeset
for help on using the changeset viewer.