Changeset 1576
- Timestamp:
- Nov 21, 2014 9:58:58 AM (8 years ago)
- Location:
- trunk
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/GSASIIIO.py
r1574 r1576 136 136 137 137 ''' 138 if not ospath.exists(imagefile): 139 dlg = wx.FileDialog(G2frame, 'Bad image file name; choose name', '.', '',\ 138 if not os.path.exists(imagefile): 139 print 'Image file '+imagefile+' not found' 140 fil = imagefile.replace('\\','/') # windows?! 141 # see if we can find a file with same name or in a similarly named sub-dir 142 pth,fil = os.path.split(fil) 143 prevpth = None 144 while pth and pth != prevpth: 145 prevpth = pth 146 if os.path.exists(os.path.join(G2frame.dirname,fil)): 147 print 'found image file '+os.path.join(G2frame.dirname,fil) 148 return os.path.join(G2frame.dirname,fil) 149 pth,enddir = os.path.split(pth) 150 fil = os.path.join(enddir,fil) 151 # not found as a subdirectory, drop common parts of path for last saved & image file names 152 # if image was .../A/B/C/imgs/ima.ge 153 # & GPX was .../A/B/C/refs/fil.gpx but is now .../NEW/TEST/TEST1 154 # will look for .../NEW/TEST/TEST1/imgs/ima.ge, .../NEW/TEST/imgs/ima.ge, .../NEW/imgs/ima.ge and so on 155 Controls = G2frame.PatternTree.GetItemPyData(G2gd.GetPatternTreeItemId(G2frame,G2frame.root, 'Controls')) 156 gpxPath = Controls.get('LastSavedAs','').replace('\\','/').split('/') # blank in older .GPX files 157 imgPath = imagefile.replace('\\','/').split('/') 158 for p1,p2 in zip(gpxPath,imgPath): 159 if p1 == p2: 160 gpxPath.pop(0),imgPath.pop(0) 161 else: 162 break 163 fil = os.path.join(*imgPath) # file with non-common prefix elements 164 prevpth = None 165 pth = os.path.abspath(G2frame.dirname) 166 while pth and pth != prevpth: 167 prevpth = pth 168 if os.path.exists(os.path.join(pth,fil)): 169 print 'found image file '+os.path.join(pth,fil) 170 return os.path.join(pth,fil) 171 pth,enddir = os.path.split(pth) 172 GSASIIpath.IPyBreak() 173 174 if not os.path.exists(imagefile): 175 dlg = wx.FileDialog(G2frame, 'Previous image file not found; open here', '.', '',\ 140 176 'Any image file (*.edf;*.tif;*.tiff;*.mar*;*.ge*;*.avg;*.sum;*.img)\ 141 177 |*.edf;*.tif;*.tiff;*.mar*;*.ge*;*.avg;*.sum;*.img|\ … … 242 278 ext = ospath.splitext(imagefile)[1] 243 279 Comments = [] 280 Image = None 244 281 if ext == '.tif' or ext == '.tiff': 245 282 Comments,Data,Npix,Image = GetTifData(imagefile) … … 270 307 if not imageOnly: 271 308 EditImageParms(G2frame,Data,Comments,Image,imagefile) 309 else: 310 print 'Extension for file '+imagefile+' not recognized' 311 if Image is None: 312 raise Exception('No image read') 272 313 if imageOnly: 273 314 if TRANSP: … … 940 981 file = open(G2frame.GSASprojectfile,'wb') 941 982 print 'save to file: ',G2frame.GSASprojectfile 983 # stick the file name into the tree 984 Controls = G2frame.PatternTree.GetItemPyData(G2gd.GetPatternTreeItemId(G2frame,G2frame.root, 'Controls')) 985 Controls['LastSavedAs'] = G2frame.GSASprojectfile 942 986 wx.BeginBusyCursor() 943 987 try: -
trunk/GSASIIimgGUI.py
r1571 r1576 1024 1024 1025 1025 def UpdateMasks(G2frame,data): 1026 '''Shows and handles the controls on the "Masks" 1027 data tree entry 1026 '''Shows and handles the controls on the "Masks" data tree entry 1028 1027 ''' 1029 1028 … … 1235 1234 G2frame.dataFrame.GetStatusBar().SetStatusText('Ring mask active - LB pick ring location') 1236 1235 else: 1237 G2frame.dataFrame.GetStatusBar().SetStatusText("To add mask: On 2D Powder Image, key a:arc, r:ring, s:spot, p:polygon, f:frame")1238 G2frame.dataDisplay = wx .Panel(G2frame.dataFrame)1236 G2frame.dataFrame.GetStatusBar().SetStatusText("To add mask: press a,r,s,p or f on 2D image for arc/ring/spot/polygon/frame") 1237 G2frame.dataDisplay = wxscroll.ScrolledPanel(G2frame.dataFrame) 1239 1238 mainSizer = wx.BoxSizer(wx.VERTICAL) 1240 1239 mainSizer.Add((5,10),0) … … 1272 1271 delSpotId = [] 1273 1272 if spots: 1273 lbl = wx.StaticText(parent=G2frame.dataDisplay,label=' Spot masks') 1274 lbl.SetBackgroundColour(wx.Colour(200,200,210)) 1275 mainSizer.Add(lbl,0,wx.EXPAND|wx.ALIGN_CENTER,0) 1274 1276 littleSizer = wx.FlexGridSizer(0,3,0,5) 1275 littleSizer.Add(wx.StaticText(parent=G2frame.dataDisplay,label=' Spot masks:'),0,WACV)1276 littleSizer.Add((5,0),0)1277 littleSizer.Add((5,0),0)1278 1277 littleSizer.Add(wx.StaticText(parent=G2frame.dataDisplay,label=' position, mm'),0,WACV) 1279 1278 littleSizer.Add(wx.StaticText(parent=G2frame.dataDisplay,label=' diameter, mm'),0,WACV) … … 1301 1300 delRingId = [] 1302 1301 if rings: 1302 lbl = wx.StaticText(parent=G2frame.dataDisplay,label=' Ring masks') 1303 lbl.SetBackgroundColour(wx.Colour(200,200,210)) 1304 mainSizer.Add(lbl,0,wx.EXPAND|wx.ALIGN_CENTER,0) 1303 1305 littleSizer = wx.FlexGridSizer(0,3,0,5) 1304 littleSizer.Add(wx.StaticText(parent=G2frame.dataDisplay,label=' Ring masks:'),0,WACV)1305 littleSizer.Add((5,0),0)1306 littleSizer.Add((5,0),0)1307 1306 littleSizer.Add(wx.StaticText(parent=G2frame.dataDisplay,label=' 2-theta,deg'),0,WACV) 1308 1307 littleSizer.Add(wx.StaticText(parent=G2frame.dataDisplay,label=' thickness, deg'),0,WACV) … … 1330 1329 delArcId = [] 1331 1330 if arcs: 1331 lbl = wx.StaticText(parent=G2frame.dataDisplay,label=' Arc masks') 1332 lbl.SetBackgroundColour(wx.Colour(200,200,210)) 1333 mainSizer.Add(lbl,0,wx.EXPAND|wx.ALIGN_CENTER,0) 1332 1334 littleSizer = wx.FlexGridSizer(0,4,0,5) 1333 littleSizer.Add(wx.StaticText(parent=G2frame.dataDisplay,label=' Arc masks:'),0,WACV)1334 littleSizer.Add((5,0),0)1335 littleSizer.Add((5,0),0)1336 littleSizer.Add((5,0),0)1337 1335 littleSizer.Add(wx.StaticText(parent=G2frame.dataDisplay,label=' 2-theta,deg'),0,WACV) 1338 1336 littleSizer.Add(wx.StaticText(parent=G2frame.dataDisplay,label=' azimuth, deg'),0,WACV) … … 1367 1365 delFrameId = [] 1368 1366 if polygons: 1367 lbl = wx.StaticText(parent=G2frame.dataDisplay,label=' Polygon masks (on plot RB vertex drag to move,\nLB vertex drag to insert)') 1368 lbl.SetBackgroundColour(wx.Colour(200,200,210)) 1369 mainSizer.Add(lbl,0,wx.EXPAND|wx.ALIGN_CENTER,0) 1369 1370 littleSizer = wx.FlexGridSizer(0,2,0,5) 1370 littleSizer.Add(wx.StaticText(parent=G2frame.dataDisplay,label=' Polygon masks:'),0,WACV)1371 littleSizer.Add((5,0),0)1372 1371 for polygon in polygons: 1373 1372 if polygon: … … 1383 1382 mainSizer.Add(littleSizer,0,) 1384 1383 if frame: 1384 lbl = wx.StaticText(parent=G2frame.dataDisplay,label=' Frame mask (on plot RB vertex drag to move,\nLB vertex drag to insert)') 1385 lbl.SetBackgroundColour(wx.Colour(200,200,210)) 1386 mainSizer.Add(lbl,0,wx.EXPAND|wx.ALIGN_CENTER,0) 1385 1387 littleSizer = wx.FlexGridSizer(0,2,0,5) 1386 littleSizer.Add(wx.StaticText(parent=G2frame.dataDisplay,label=' Frame mask:'),0,1387 WACV)1388 littleSizer.Add((5,0),0)1389 1388 frameList = [] 1390 1389 for x,y in frame: … … 1397 1396 littleSizer.Add(frameDelete,0,WACV) 1398 1397 mainSizer.Add(littleSizer,0,) 1399 if (frame or polygons):1400 mainSizer.Add(wx.StaticText(G2frame.dataDisplay,1401 label=' For frame and polygons: on plot RB vertex drag to move, LB vertex drag to insert'),0,WACV)1398 #if (frame or polygons): 1399 # mainSizer.Add(wx.StaticText(G2frame.dataDisplay, 1400 # label=' For frame and polygons: on plot RB vertex drag to move, LB vertex drag to insert'),0,WACV) 1402 1401 mainSizer.Layout() 1403 1402 G2frame.dataDisplay.SetSizer(mainSizer) 1404 1403 G2frame.dataDisplay.SetSize(mainSizer.Fit(G2frame.dataFrame)) 1404 G2frame.dataDisplay.SetupScrolling() 1405 1405 Size = mainSizer.Fit(G2frame.dataFrame) 1406 Size[0] = 450 1406 Size[0] += 50 # room for scrollbar & status msg 1407 Size[1] = min(Size[1],500) 1408 G2frame.dataDisplay.SetSize(Size) 1407 1409 G2frame.dataFrame.setSizePosLeft(Size) 1408 1410
Note: See TracChangeset
for help on using the changeset viewer.