def _getDatasetItemActions(self, item=None, actionsgroup=None): if actionsgroup is None: actionsgroup = self._actionsmap['DatasetItem'] # RGB action = actionsgroup.findChild(QtWidgets.QAction, 'actionOpenRGBImageView') if gdalsupport.isRGB(item): # @TODO: remove this to allow multiple views on the same item for subwin in self._app.mdiarea.subWindowList(): #if subwin.item == item: # action.setEnabled(False) # break # @COMPATIBILITY: pyside 1.2.2 try: if subwin.item == item: action.setEnabled(False) break except NotImplementedError: if id(subwin.item) == id(item): action.setEnabled(False) break else: action.setEnabled(True) else: action.setEnabled(False) return actionsgroup
def _getDatasetItemActions(self, item=None, actionsgroup=None): if actionsgroup is None: actionsgroup = self._actionsmap['DatasetItem'] # RGB action = actionsgroup.findChild(QtWidgets.QAction, 'actionOpenRGBImageView') if gdalsupport.isRGB(item): # @TODO: remove this to allow multiple views on the same item for subwin in self._app.mdiarea.subWindowList(): if subwin.item == item: action.setEnabled(False) break else: action.setEnabled(True) else: action.setEnabled(False) return actionsgroup
def openSubDataset(self): item = self._app.currentItem() assert isinstance(item, modelitems.SubDatasetItem) if item.isopen(): if gdalsupport.isRGB(item): self.openRGBImageView(item) return try: # Only works for CachedDatasetItems cachedir = os.path.dirname(item.parent().vrtfilename) except AttributeError: id_ = gdalsupport.uniqueDatasetID(item.parent()) cachedir = os.path.join(modelitems.SubDatasetItem.CACHEDIR, id_) # sub-dataset index (starting from 1) index = item.row() - item.parent().RasterCount + 1 cachedir = os.path.join(cachedir, 'subdataset%02d' % index) item.open(cachedir)
def graphicsItemFactory(gdalobj, parent=None): '''Factory function for GDAL graphics items. Instantiates on object of the GDAL graphics item class taht best fits the *gdalobj* passed as argument. ''' if gdalsupport.isRGB(gdalobj): _log.debug('new GdalRgbGraphicsItem') return GdalRgbGraphicsItem(gdalobj, parent) elif gdalobj.DataType in (gdal.GDT_Byte, gdal.GDT_UInt16): _log.debug('new GdalUIntGraphicsItem') return UIntGdalGraphicsItem(gdalobj, parent) elif gdal.DataTypeIsComplex(gdalobj.DataType): _log.debug('new GdalComplexGraphicsItem') return GdalComplexGraphicsItem(gdalobj, parent) else: _log.debug('new GdalGraphicsItem') return GdalGraphicsItem(gdalobj, parent)
def __init__(self, dataset, parent=None, **kwargs): if not gdalsupport.isRGB(dataset): raise TypeError('RGB or RGBA iamge expected') super(GdalRgbGraphicsItem, self).__init__(dataset, parent, **kwargs) self.stretch = None