Changeset 940aca7 in sasview for sansguiframe/src/sans/guiframe/local_perspectives/plotting/profile_dialog.py
- Timestamp:
- May 19, 2012 10:17:02 AM (12 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:
- baa915c
- Parents:
- d225e32
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
sansguiframe/src/sans/guiframe/local_perspectives/plotting/profile_dialog.py
r2d443fd r940aca7 53 53 self.SetTitle("Scattering Length Density Profile") 54 54 self.parent = parent 55 self._mgr = None 55 56 self.data = data 56 57 self.str = self.data.__str__() … … 75 76 self.newplot.dy = None 76 77 self.newplot.name = 'SLD' 78 self.newplot.id = self.newplot.name 77 79 self.plotpanel.add_image(self.newplot) 78 80 self.plotpanel.subplot.set_ylim(min(data_plot.y) - _Y_OFF , … … 81 83 max(data_plot.x) + _X_OFF) 82 84 #self.Centre() 85 self.plotpanel.resizing = False 86 self.plotpanel.canvas.set_resizing(self.plotpanel.resizing) 87 self.plotpanel.subplot.figure.canvas.draw_idle() 83 88 self.Layout() 84 89 … … 175 180 self.parent.parent.parent.on_change_caption(name, old_caption, new_caption) 176 181 182 def disable_app_menu(self, panel): 183 """ 184 Disable menu bar 185 """ 186 # Not implemented! 187 return 177 188 178 189 class SLDplotpanel(PlotPanel): … … 203 214 self.yaxis_label = '' 204 215 self.yaxis_unit = '' 216 self.resizing = True 205 217 206 218 def add_image(self, plot): … … 208 220 Add image(Theory1D) 209 221 """ 210 self.plots[plot.name] = plot 211 self.plots[plot.name].is_data = False 212 #init graph 213 #self.gaph = Graph() 222 self.plots[plot.id] = plot 223 self.plots[plot.id].is_data = True 214 224 #add plot 215 225 self.graph.add(plot) … … 222 232 self.yaxis_unit = '10^{-6}A^{-2}' 223 233 self.graph.yaxis(self.yaxis_label, self.yaxis_unit) 234 #self.subplot.figure.canvas.draw_idle() 235 # For latter scale changes 236 self.plots[plot.id].xaxis('\\rm{%s} '% x1_label, 'A') 237 self.plots[plot.id].yaxis('\\rm{SLD} ', '10^{-6}A^{-2}') 224 238 #draw 225 239 self.graph.render(self) 226 self.subplot.figure.canvas.draw_idle()227 228 # For latter scale changes229 self.plots[plot.name].xaxis('\\rm{%s} '% x1_label, 'A')230 self.plots[plot.name].yaxis('\\rm{SLD} ', '10^{-6}A^{-2}')231 240 232 241 def on_set_focus(self, event): … … 257 266 """ 258 267 pass 259 268 260 269 def _onSave(self, evt): 261 270 """ … … 265 274 266 275 """ 267 268 path = None 269 wildcard = "Text files (*.txt)|*.txt|"\ 270 "CanSAS 1D files(*.xml)|*.xml" 271 default_name = "sld_profile" 276 menu = evt.GetEventObject() 277 id = evt.GetId() 278 self.set_selected_from_menu(menu, id) 279 data = self.plots[self.graph.selected_plottable] 280 default_name = data.label 281 if default_name.count('.') > 0: 282 default_name = default_name.split('.')[0] 283 default_name += "_out" 272 284 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 285 # What an ancestor! 286 fit_panel = self.parent.parent.parent 287 fit_panel.parent.save_data1d(data, default_name) 288 318 289 class ViewerFrame(wx.Frame): 319 290 """
Note: See TracChangeset
for help on using the changeset viewer.