PyDVT.ImageView (version 1.1.0, 08/11/2002)
index
/mntdirect/_bliss/users/gobbo/PyDVT/PyDVT/ImageView.py

ImageView.py
View derived class for 2d image displaying
 
 
Interface:
===========================
View interface
SetZoom

 
Modules
            
Command
EventHandler
PyDVT.ImageViewSelect
Numeric
PyDVT
spslut
sys
types

 
Classes
            
PyDVT.Filter.Filter
ColormapFilter
Image
ImageFilter
PyDVT.View.View(PyDVT.GUIBinding.Binding.Container)
ImageView

 
class ColormapFilter(PyDVT.Filter.Filter)
      View's standard filter
 
  
ConnectColormap(self, colormap_sel)
Connects the ColormapFilter object to a ColormapSelect object. The view object
will answer to ColormapChange events from Colormap object
Parameter:
colormap: colormap object
DataChanged(self, par) from PyDVT.Filter.Filter
DataCoord2SelectionCoord(self, data_coord)
Overriden to corret coords convertion based on reduction applied.
Destroy(self, source=None)
Virtual: See View.Destroy
DisconnectColormap(self)
Disconnects the ColormapFilter object from a ColormapSelect object.
Parameter:
colormap: colormap object
GetColormapParameters(self)
Gets colormap parameters of the view object, a dictionary, with the keys:
    AbsoluteMinMax: tuple (min,max) with the lowest and highest values of the data
    MinMax: tuple (min,max) with the lowest and highest values used for the colormap
    Scale: "Linear", "Logarithmic", "Gamma"
    Colormap: "GrayScale","Temperature","Red","Green","Blue" or "RevGrey"
    Gamma: Factor for gamma scale
    AutoScale: if set, generates MinMax according to the displayed data
               (takes highest and lowest values of the data)
GetData(self) from PyDVT.Filter.Filter
GetDataSelection(self) from PyDVT.Filter.Filter
GetInput(self) from PyDVT.Filter.Filter
GetOutput(self)
Returns the selection data (dictionary)
Keys:
    "name" : string
    "data" : 2d-NumPy array with the original data
    "image" : String with RGB representation of data
    "size": Size of the image
    "depth": 8 or 32
    "colormap_table": if "depth"==8, palette table, otherwize None           
    "filterchange" : flag indicating just a change in
                     filter parameters has taken place
                     (not the actual data).
                     ImageView always keeps Zoom/Position
                     if this flag is set.
GetSource(self) from PyDVT.Filter.Filter
Refresh(self) from PyDVT.Filter.Filter
SelectionCoord2DataCoord(self, selection_coord)
Overriden to corret coords convertion based on reduction applied.
SetColormapParameters(self, colormap_pars)
Sets colormap parameters of the view object
Parameters
colormap_pars: dictionary with the following keys (as described in GetColormapParameters):
    MinMax
    Scale
    Colormap
    AutoScale
    Gamma
    
    AbsoluteMinMax is not considered
SetReducParameters(self, reduc, fastreduc)
Sets reduction parameters 
Parameters:
reduc: scale to the reduction
fastreduc: if non-zero just eliminates rows/cols
SetSynchronized(self, synchronized) from PyDVT.Filter.Filter
__init__(self, name=None, source=None, synchronized=1, buffer_input=0)
Parameters:
    name: optional name of the function
    source: Source Filter/DataSelection
    synchronized: non-zero if on-line
    buffer_input: see Filter.__init__

 
class Image(ColormapFilter)
      View's simplified filter for direct NumPy interface.
(creates and hides it's own data object)
 
  
ConnectColormap(self, colormap_sel) from ColormapFilter
DataChanged(self, par) from PyDVT.Filter.Filter
DataCoord2SelectionCoord(self, data_coord) from ColormapFilter
Destroy(self, source=None)
If filter gets out of scope, this should be called to destroy
internally created data object.
DisconnectColormap(self) from ColormapFilter
GetColormapParameters(self) from ColormapFilter
GetData(self) from PyDVT.Filter.Filter
GetDataSelection(self) from PyDVT.Filter.Filter
GetInput(self) from PyDVT.Filter.Filter
GetOutput(self) from ColormapFilter
GetSource(self) from PyDVT.Filter.Filter
Refresh(self) from PyDVT.Filter.Filter
SelectionCoord2DataCoord(self, selection_coord) from ColormapFilter
SetColormapParameters(self, colormap_pars) from ColormapFilter
SetReducParameters(self, reduc, fastreduc) from ColormapFilter
SetSynchronized(self, synchronized) from PyDVT.Filter.Filter
__init__(self, data=None, name=None)
Parameters:
    data: NumPy 2d array to be displayed

 
class ImageFilter(PyDVT.Filter.Filter)
      View's standard filter to previously RGB generated images
(ImageFileData).
Obviously spslut is not used in this case.
 
  
DataChanged(self, par) from PyDVT.Filter.Filter
DataCoord2SelectionCoord(self, data_coord) from PyDVT.Filter.Filter
Destroy(self, source=None) from PyDVT.Filter.Filter
GetData(self) from PyDVT.Filter.Filter
GetDataSelection(self) from PyDVT.Filter.Filter
GetInput(self) from PyDVT.Filter.Filter
GetOutput(self)
Returns the selection data (dictionary)
Keys:
    "name" : string
    "data" : 2d-NumPy array with the original data (RGB values)
    "image" : String transformation of data
    "size" : dimentions of image
    "depth": always 32
    "colormap_table": None
GetSource(self) from PyDVT.Filter.Filter
Refresh(self) from PyDVT.Filter.Filter
SelectionCoord2DataCoord(self, selection_coord) from PyDVT.Filter.Filter
SetSynchronized(self, synchronized) from PyDVT.Filter.Filter
__init__(self, name=None, source=None, synchronized=1, buffer_input=0)
Parameters:
    name: optional name of the function
    source: Source Filter/DataSelection
    synchronized: non-zero if on-line
    buffer_input: see Filter.__init__

 
class ImageView(PyDVT.View.View)
      View derived class for image representation of 2d data.
This class accepts just one source object. If the SetData
is called with multiple sources, only the first one is considered.    
ImageView expects the following keys from it's source (GetOutput
method):
"image": string, image RGBX representation, as returned by spslut.
"size": size of image, tuple (x,y) .
"depth": 8 or 32(default)
"colormap_table": if "depth"==8, palette table, otherwize None           
"name": Optional. Not used for the moment.
"data": Optional. Reference to original NumPy array. Not used by this class,
        but derived classes and/or applications to retrieve original data.
"datachanged": Optional. Flag set by any intermediate Filter to signalize
               ImageView that a DataChange event was taken place due to
               a change in the parameters of the Filter, and not the
               data itself ("datachanged" equals to 0). If this flag is
               present and set to zero, ImageView don't change zoom/scroll
               position in a DataChange event, even if LockPosition is set
               to 0.
               
Interface:
===========================
View interface
SetZoom
ZoomTo
ClearZoomSelect
SetCursorType
GetColormapFilter
GetImagePositionValue
GetDataPositionValue
 
Overridables:    
===========================
View overridables
CreateMenu
EventPosition
 
Some of Drawable's methods are callable at application level (they're accessed
through View.GetDrawable() (see GUIBinding.Drawable2D):
 
  
AddMenuPopupCascade(self, label, menu) from PyDVT.View.View
AddMenuPopupItem(self, label, Command, Style='command') from PyDVT.View.View
AddMenuSeparator(self) from PyDVT.View.View
ClearMenu(self) from PyDVT.View.View
ClearZoomSelect(self)
Called to destroy zoom ViewSelect object.
Called in the zoom selection event, but applications can assure
the destruction by calling this.
CreateDrawable(self)
Virtual: See View.CreateDrawable
CreateMenu(self)
Can be overwritten by derived classes to create a
different popup menu
DataChanged(self, source=None)
Virtual: See View.DataChanged
DataCoord2ImageCoord(self, data_coord)
Virtual: See View.DataCoord2ImageCoord
DeleteMenuItem(self, index) from PyDVT.View.View
Destroy(self, source=None) from PyDVT.View.View
DisableMenuItem(self, index) from PyDVT.View.View
EnableMenuItem(self, index) from PyDVT.View.View
EventButtonPress(self, pos) from PyDVT.View.View
EventButtonPressMotion(self, pos) from PyDVT.View.View
EventButtonRelease(self, pos) from PyDVT.View.View
EventDoubleClick(self, pos) from PyDVT.View.View
EventKeyPress(self, key, flags) from PyDVT.View.View
EventMotion(self, pos) from PyDVT.View.View
EventPosition(self, source)
Overridable: Cursor callback event
Parameters:
    source: ImageViewSelect object thar generated the event
GetColormapFilter(self)
Auxiliar method. Search the filters recursively in order to find a ColormapFilter.
This can be useful to derived classes to retrieve the ColormapFilter (in order to
change its parameters) if some othere filters are cascaded after it.
If no ColormapFilter is found, returns None.
GetDataPositionValue(self, data_pos)
Returns the value of the data for a given data coordinate, in the
linked data object.
If invalid coordinate or no linked data, returns None
GetDrawable(self) from PyDVT.View.View
GetDrawableHeight(self) from PyDVT.View.View
GetDrawableWidth(self) from PyDVT.View.View
GetHeight(self) from PyDVT.GUIBinding.Binding.Container
GetImagePositionValue(self, image_pos)
Returns the value of the data for a given image coordinate.
If invalid coordinate or no ImageData present, returns None
GetPopupMenu(self) from PyDVT.View.View
GetPosition(self, event)
Virtual: See View.GetPosition
GetSaveFormats(self)
Returns tuple with supported save formats
GetSource(self) from PyDVT.View.View
GetWidth(self) from PyDVT.GUIBinding.Binding.Container
ImageCoord2DataCoord(self, view_coord) from PyDVT.View.View
Invalidate(self) from PyDVT.View.View
IsVisible(self) from PyDVT.GUIBinding.Binding.Container
LockPosition(self, value) from PyDVT.View.View
Redraw(self)
Virtual: See View.Redraw
Refresh(self) from PyDVT.View.View
Save(self, filename, format) from PyDVT.View.View
SetCursor(self, cursor) from PyDVT.View.View
SetCursorType(self, cursortype)
Sets the cursor
Parameters: 
    cursortype: "None" (default) or "Crosshairs"
                Both types generate EventPosition events
SetOnLine(self, value) from PyDVT.View.View
SetPointer(self, pointer) from PyDVT.GUIBinding.Binding.Container
SetSize(self, width, height) from PyDVT.GUIBinding.Binding.Container
SetSource(self, source=()) from PyDVT.View.View
SetZoom(self, val=None, rect=None, com=None)
Sets zoom state to the ImageView object
Parameters: (only one must be set)
  val:  a float, sets directly a value to the zoom factor
  rect: a tuple in the format (x0,y0,x1,y1), that defines the coordinates of
      the upper-left and the lower-right points of a zoomed area, in
      data selection coordinates.
  com:  can be "fit", "normal", "in" and "out"
Show(self) from PyDVT.GUIBinding.Binding.Container
Update(self) from PyDVT.View.View
ViewCoord2DataCoord(self, view_coord)
Virtual: See View.ViewCoord2DataCoord
ZoomTo(self)
Called from menu option: creates ImageViewSelectRect to define a
zoom region. Promotes zoom on selection event.
_ButtonPress(self, event) from PyDVT.View.View
_ButtonPressMotion(self, event) from PyDVT.View.View
_ButtonRelease(self, event) from PyDVT.View.View
_CmdLockPosition(self) from PyDVT.View.View
_CmdOnLine(self) from PyDVT.View.View
_DataChanged(self, source=None) from PyDVT.View.View
_DataDeleted(self, source=None) from PyDVT.View.View
_DoubleClick(self, event) from PyDVT.View.View
_EventZoomSelection(self, source)
_KeyPress(self, key, flags=None) from PyDVT.View.View
_Motion(self, event) from PyDVT.View.View
_RightButtonPress(self, event) from PyDVT.View.View
__init__(self, parent=None, pars={}, **kw)
See View.__init__
Parameters:
parent: parent window
pars: Dictionary with View initialization options
      New options defined by this class (in addiction to base class options):
        "ScrollMode": "ON","OFF","AUTO"
        "ZoomMode": "ON","OFF","FIT_TO_SCREEN"
        "Oversize" (Just in TkBinding):
              "AUTO_SET": manages automatically the oversize
              region when zooming/scrolling            
              "NONE": no oversize area
              "FULL_IMAGE": always loads complete
              float: defines directly the oversize area
        "StoreImageData": If set, view object stores "data" from it's selection
                          (if exists) in self.ImageData. By default it is not
                          stored, to save memory, but can be useful to access
                          pixel values when image data has ben changed in
                          relation to it's data object values, by any transformation.
kw:   keywords to container initialization

 
Author
             Alexandre Gobbo (gobbo@esrf.fr)