/[thuban]/branches/WIP-pyshapelib-bramz/Thuban/UI/baserenderer.py
ViewVC logotype

Diff of /branches/WIP-pyshapelib-bramz/Thuban/UI/baserenderer.py

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 2537 by jonathan, Fri Jan 21 14:01:25 2005 UTC revision 2552 by jonathan, Fri Jan 28 15:54:00 2005 UTC
# Line 458  class BaseRenderer: Line 458  class BaseRenderer:
458          # True  -- warp the image to the size of the whole screen          # True  -- warp the image to the size of the whole screen
459          # False -- only use the bound box of the layer (currently inaccurate)          # False -- only use the bound box of the layer (currently inaccurate)
460          if True:          if True:
461            #if False:
462              pmin = [0,height]              pmin = [0,height]
463              pmax = [width, 0]              pmax = [width, 0]
464          else:          else:
# Line 465  class BaseRenderer: Line 466  class BaseRenderer:
466              bb = [[[bb[0], bb[1]], [bb[2], bb[3]],],]              bb = [[[bb[0], bb[1]], [bb[2], bb[3]],],]
467              pmin, pmax = self.projected_points(layer, bb)[0]              pmin, pmax = self.projected_points(layer, bb)[0]
468    
469          fmin = [max(0, pmin[0]) - offx, offy - min(height, pmin[1])]          #print bb
470          fmax = [min(width, pmax[0]) - offx, offy - max(0, pmax[1])]          #print pmin, pmax
471    
472            fmin = [max(0, min(pmin[0], pmax[0])) - offx,
473                    offy - min(height, max(pmin[1], pmax[1]))]
474    
475            fmax = [min(width, max(pmin[0], pmax[0])) - offx,
476                    offy - max(0, min(pmin[1], pmax[1]))]
477    
478          xmin = fmin[0]/self.scale          xmin = fmin[0]/self.scale
479          ymin = fmin[1]/self.scale          ymin = fmin[1]/self.scale
# Line 477  class BaseRenderer: Line 484  class BaseRenderer:
484          height = int(min(height, round(fmax[1] - fmin[1] + 1)))          height = int(min(height, round(fmax[1] - fmin[1] + 1)))
485    
486          try:          try:
487              data = [width, height,              options = 0
488                      ProjectRasterFile(layer.GetImageFilename(),              if layer.UseMask(): options = options | 1
489                                       in_proj, out_proj,  
490                                       (xmin, ymin, xmax, ymax), "",              project_params = (layer.GetImageFilename(), in_proj, out_proj,
491                                       (width, height))                                (xmin, ymin, xmax, ymax), "", (width, height),
492                     ]                                options)
493          except (IOError, AttributeError, ValueError):  
494                data = (width, height, apply(ProjectRasterFile, project_params))
495    
496            except (MemoryError, IOError, AttributeError, ValueError):
497              # Why does this catch AttributeError and ValueError?              # Why does this catch AttributeError and ValueError?
498              # FIXME: The exception should be communicated to the user              # FIXME: The exception should be communicated to the user
499              # better.              # better.
500              traceback.print_exc()              traceback.print_exc()
501          else:          else:
502              mask = "#030104"              self.draw_raster_data(fmin[0]+offx, offy-fmax[1], data, "RAW")
             #mask = None  
             self.draw_raster_data(fmin[0]+offx, offy-fmax[1], data, "RAW", mask)  
503              data = None              data = None
504    
505      def draw_raster_data(self, x, y, data, format="BMP", mask = None):      def draw_raster_data(self, x, y, data, format="BMP"):
506          """Draw the raster image in data onto the DC with the top          """Draw the raster image in data onto the DC with the top
507          left corner at (x,y)          left corner at (x,y)
508    
509          The raster image data is a list holding the image width, height,          The raster image data is a tuple of the form
510          and data in the format indicated by the format parameter.              (width, height, (image_data, mask_data))
511            
512            holding the image width, height, image data, and mask data.
513            mask_data may be None if a mask should not be used. If
514            format is 'RAW' the data will be RGB values and the mask
515            will be in XMB format. Otherwise, both kinds
516            of data are assumed to be in the format specified in format.
517    
518          The format parameter is a string with the name of the format.          The format parameter is a string with the name of the format.
519          The following format names should be used:          The following format names should be used:
# Line 510  class BaseRenderer: Line 524  class BaseRenderer:
524    
525          The default format is 'BMP'.          The default format is 'BMP'.
526    
         The mask parameter determines how a mask (if any) is applied  
         to the image. mask can have the following values:  
           
           o  None -- no mask is used  
           o  Any object accepted by wxBitmap.SetMaskColour()  
           o  A one-bit image the same size as the image data  
   
527          This method has to be implemented by derived classes. The          This method has to be implemented by derived classes. The
528          implementation in the derived class should try to support at          implementation in the derived class should try to support at
529          least the formats specified above and may support more.          least the formats specified above and may support more.

Legend:
Removed from v.2537  
changed lines
  Added in v.2552

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26