Changeset 2d443fd in sasview for sansguiframe/src
- Timestamp:
- Sep 13, 2011 5:29:59 PM (13 years ago)
- Branches:
- master, 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, costrafo411, magnetic_scatt, release-4.1.1, release-4.1.2, release-4.2.2, release_4.0.1, ticket-1009, ticket-1094-headless, ticket-1242-2d-resolution, ticket-1243, ticket-1249, ticket885, unittest-saveload
- Children:
- 3858e0f
- Parents:
- 4e2fc799
- Location:
- sansguiframe/src/sans/guiframe/local_perspectives/plotting
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
sansguiframe/src/sans/guiframe/local_perspectives/plotting/Plotter1D.py
rc553b18 r2d443fd 373 373 name = plot.name 374 374 self._slicerpop.Append(id, "&Save Points as a File") 375 wx.EVT_MENU(self, id, self._onSave) 375 376 self._slicerpop.AppendSeparator() 376 377 if plot.name != 'SLD': 377 wx.EVT_MENU(self, id, self._onSave)378 378 id = wx.NewId() 379 379 self._slicerpop.Append(id, '&Linear Fit') -
sansguiframe/src/sans/guiframe/local_perspectives/plotting/profile_dialog.py
r9a3d433 r2d443fd 3 3 """ 4 4 import wx 5 import os 5 6 import sys 6 7 from copy import deepcopy … … 34 35 """ 35 36 ## Internal nickname for the window, used by the AUI manager 36 window_name = "S LDProfile"37 window_name = "Scattering Length Density Profile" 37 38 ## Name to appear on the window title bar 38 window_caption = "S LDProfile"39 window_caption = "Scattering Length Density Profile" 39 40 ## Flag to tell the AUI manager to put this panel in the center pane 40 41 CENTER_PANE = True … … 49 50 kwds = [] 50 51 self.SetWindowVariant(variant=FONT_VARIANT) 52 51 53 self.SetTitle("Scattering Length Density Profile") 52 self.parent = base54 self.parent = parent 53 55 self.data = data 54 56 self.str = self.data.__str__() … … 167 169 # NOt implemented 168 170 pass 169 171 172 def on_change_caption(self, name, old_caption, new_caption): 173 """ 174 """ 175 self.parent.parent.parent.on_change_caption(name, old_caption, new_caption) 170 176 171 177 … … 184 190 # Keep track of the parent Frame 185 191 self.parent = parent 192 self.window_name = "Scattering Length Density Profile" 193 self.window_caption = self.window_name 186 194 # Internal list of plottable names (because graph 187 195 # doesn't have a dictionary of handles for the plottables) … … 191 199 for idx in range(0, len(axes)): 192 200 self.axes_label.append(axes[idx]) 201 self.xaxis_label = '' 202 self.xaxis_unit = '' 203 self.yaxis_label = '' 204 self.yaxis_unit = '' 193 205 194 206 def add_image(self, plot): … … 204 216 #add axes 205 217 x1_label = self.axes_label[0] 206 self.graph.xaxis('\\rm{%s} '% x1_label, 'A') 207 self.graph.yaxis('\\rm{SLD} ', '10^{-6}A^{-2}') 218 self.xaxis_label = '\\rm{%s} '% x1_label 219 self.xaxis_unit = 'A' 220 self.graph.xaxis(self.xaxis_label, self.xaxis_unit) 221 self.yaxis_label = '\\rm{SLD} ' 222 self.yaxis_unit = '10^{-6}A^{-2}' 223 self.graph.yaxis(self.yaxis_label, self.yaxis_unit) 208 224 #draw 209 225 self.graph.render(self) … … 235 251 """ 236 252 pass 237 253 254 def onChangeCaption(self, event): 255 """ 256 Not implemented 257 """ 258 pass 259 260 def _onSave(self, evt): 261 """ 262 Save a data set to a text file 263 264 :param evt: Menu event 265 266 """ 267 268 path = None 269 wildcard = "Text files (*.txt)|*.txt|"\ 270 "CanSAS 1D files(*.xml)|*.xml" 271 default_name = "sld_profile" 272 if self.parent != None: 273 self._default_save_location = self.parent.parent._default_save_location 274 dlg = wx.FileDialog(self, "Choose a file", 275 self._default_save_location, 276 default_name, wildcard , wx.SAVE) 277 278 if dlg.ShowModal() == wx.ID_OK: 279 path = dlg.GetPath() 280 # ext_num = 0 for .txt, ext_num = 1 for .xml 281 # This is MAC Fix 282 ext_num = dlg.GetFilterIndex() 283 if ext_num == 0: 284 format = '.txt' 285 else: 286 format = '.xml' 287 path = os.path.splitext(path)[0] + format 288 mypath = os.path.basename(path) 289 290 #TODO: This is bad design. The DataLoader is designed 291 #to recognize extensions. 292 # It should be a simple matter of calling the . 293 #save(file, data, '.xml') method 294 # of the sans.dataloader.loader.Loader class. 295 from sans.dataloader.loader import Loader 296 #Instantiate a loader 297 loader = Loader() 298 data = self.parent.data 299 format = ".txt" 300 if os.path.splitext(mypath)[1].lower() == format: 301 # Make sure the ext included in the file name 302 # especially on MAC 303 fName = os.path.splitext(path)[0] + format 304 self._onsaveTXT(fName) 305 format = ".xml" 306 if os.path.splitext(mypath)[1].lower() == format: 307 # Make sure the ext included in the file name 308 # especially on MAC 309 fName = os.path.splitext(path)[0] + format 310 loader.save(fName, data, format) 311 try: 312 self._default_save_location = os.path.dirname(path) 313 self.parent.parent._default_save_location = self._default_save_location 314 except: 315 pass 316 dlg.Destroy() 317 238 318 class ViewerFrame(wx.Frame): 239 319 """
Note: See TracChangeset
for help on using the changeset viewer.