Changeset 3551:159691071cb7 in orange


Ignore:
Timestamp:
04/18/07 09:46:19 (7 years ago)
Author:
mitar
Branch:
default
Convert:
4b1877dcfc5d82e7fe3a8e7ca4a679b5b2699e05
Message:

Some Mac OS X specific compatibility code for canvas.

Location:
orange/OrangeWidgets
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • orange/OrangeWidgets/Associate/OWDistanceMap.py

    r3480 r3551  
    568568    def __init__(self, bitmap, canvas, width, height, palette, depth=8, numColors=256, x=0, y=0, z=0): 
    569569        QCanvasRectangle.__init__(self, canvas) 
    570         self.image = QImage(bitmap, width, height, depth, palette, numColors, QImage.LittleEndian) 
     570    self.image = QImage(bitmap, width, height, depth, signedPalette(palette), numColors, QImage.LittleEndian) # palette should be 32 bit, what is not so on some platforms (Mac) so we force it 
    571571        self.image.bitmap = bitmap # this is tricky: bitmap should not be freed, else we get mess. hence, we store it in the object 
    572572        self.canvas = canvas 
  • orange/OrangeWidgets/ColorPalette.py

    r1886 r3551  
    1919specialColorLabelWidth = 160 
    2020paletteInterpolationColors = 250 
     21 
     22# On Mac OS X QRgb is really unsigned int and so Python uses long int for it (as it 
     23# cannot store it always in signed int), but this breaks QImage as it expects palette 
     24# of ints, so we are manually casting long unsigned ints to signed ints (even if QRgb 
     25# should be in fact unsigned) 
     26def signedPalette(palette): 
     27    def signedInt(long): 
     28        if type(long) == int: 
     29            return long 
     30        elif long > 0xFFFFFFFF: 
     31             long &= 0xFFFFFFFF 
     32         
     33    if long & 0x80000000: 
     34            return int(-((long ^ 0xFFFFFFFF) + 1)) 
     35        else: 
     36            return int(long) 
     37     
     38    return [signedInt(color) for color in palette] 
    2139 
    2240class ColorPalette(QWidget): 
     
    287305        dx = 140; dy = colorButtonSize 
    288306        bmp = chr(252)*dx*2 + reduce(lambda x,y:x+y, [chr(i*250/dx) for i in range(dx)] * (dy-4)) + chr(252)*dx*2  
    289         image = QImage(bmp, dx, dy, 8, palette, 256, QImage.LittleEndian) 
     307        image = QImage(bmp, dx, dy, 8, signedPalette(palette), 256, QImage.LittleEndian) # palette should be 32 bit, what is not so on some platforms (Mac) so we force it 
    290308        pm = QPixmap() 
    291309        pm.convertFromImage(image, QPixmap.Color); 
  • orange/OrangeWidgets/OWGUI.py

    r3488 r3551  
    688688        self.makeConsistent = Disabler(self, master, value, type = HIDER) 
    689689        if self.pixmaps != []: 
    690             self.setBackgroundPixmap(self.pixmaps[self.master.getdeepattr(self.value)]) 
     690        # a little compatibility for QT 3.3 (on Mac at least) 
     691            if hasattr(self, "setPaletteBackgroundPixmap"): 
     692        self.setPaletteBackgroundPixmap(self.pixmaps[self.master.getdeepattr(self.value)]) 
     693        else: 
     694        self.setBackgroundPixmap(self.pixmaps[self.master.getdeepattr(self.value)]) 
    691695 
    692696        if widgets != []: 
     
    696700        self.master.__setattr__(self.value, not self.master.getdeepattr(self.value)) 
    697701        if self.pixmaps != []: 
    698             self.setBackgroundPixmap(self.pixmaps[self.master.getdeepattr(self.value)]) 
     702        # a little compatibility for QT 3.3 (on Mac at least) 
     703        if hasattr(self, "setPaletteBackgroundPixmap"): 
     704        self.setPaletteBackgroundPixmap(self.pixmaps[self.master.getdeepattr(self.value)]) 
     705        else: 
     706            self.setBackgroundPixmap(self.pixmaps[self.master.getdeepattr(self.value)]) 
    699707        self.makeConsistent.__call__() 
    700708 
     
    703711        self.disables = widgets or [] 
    704712        if self.pixmaps != []: 
    705             self.setBackgroundPixmap(self.pixmaps[self.master.getdeepattr(self.value)]) 
     713        # a little compatibility for QT 3.3 (on Mac at least) 
     714        if hasattr(self, "setPaletteBackgroundPixmap"): 
     715        self.setPaletteBackgroundPixmap(self.pixmaps[self.master.getdeepattr(self.value)]) 
     716        else: 
     717            self.setBackgroundPixmap(self.pixmaps[self.master.getdeepattr(self.value)]) 
    706718        self.makeConsistent.__call__() 
    707719 
  • orange/OrangeWidgets/OWGraph.py

    r3544 r3551  
    5252        self.showAxisScale = 1 
    5353        self.showMainTitle = FALSE 
    54         self.mainTitle = None 
     54        self.mainTitle = "" 
    5555        self.showXaxisTitle = FALSE 
    56         self.XaxisTitle = None 
     56        self.XaxisTitle = "" 
    5757        self.showYLaxisTitle = FALSE 
    58         self.YLaxisTitle = None 
     58        self.YLaxisTitle = "" 
    5959        self.showYRaxisTitle = FALSE 
    60         self.YRaxisTitle = None 
     60        self.YRaxisTitle = "" 
    6161 
    6262        self.state = ZOOMING 
  • orange/OrangeWidgets/Visualize/OWLinProjGraph.py

    r3539 r3551  
    77from orngScaleLinProjData import * 
    88import orngVisFuncts 
     9import ColorPalette 
    910 
    1011# indices in curveData 
     
    839840                palette.extend([qRgb(255, 255, 255) for i in range(256-len(palette))]) 
    840841 
    841 #            image = QImage(imagebmp, (2*rx + 3) & ~3, 2*ry, 8, palette, 256, QImage.LittleEndian) 
    842             image = QImage(imagebmp, (rx + 3) & ~3, ry, 8, palette, 256, QImage.LittleEndian) 
     842#            image = QImage(imagebmp, (2*rx + 3) & ~3, 2*ry, 8, ColorPalette.signedPalette(palette), 256, QImage.LittleEndian) # palette should be 32 bit, what is not so on some platforms (Mac) so we force it 
     843            image = QImage(imagebmp, (rx + 3) & ~3, ry, 8, ColorPalette.signedPalette(palette), 256, QImage.LittleEndian) # palette should be 32 bit, what is not so on some platforms (Mac) so we force it 
    843844            self.potentialsBmp = QPixmap() 
    844845            self.potentialsBmp.convertFromImage(image) 
  • orange/OrangeWidgets/Visualize/OWScatterPlotGraph.py

    r3534 r3551  
    88import orngVisFuncts 
    99from orngScaleScatterPlotData import * 
     10import ColorPalette 
    1011 
    1112DONT_SHOW_TOOLTIPS = 0 
     
    549550                palette.extend([qRgb(255, 255, 255) for i in range(256-len(palette))]) 
    550551 
    551             image = QImage(imagebmp, (rx + 3) & ~3, ry, 8, palette, 256, QImage.LittleEndian) 
     552            image = QImage(imagebmp, (rx + 3) & ~3, ry, 8, ColorPalette.signedPalette(palette), 256, QImage.LittleEndian) 
    552553            self.potentialsBmp = QPixmap() 
    553554            self.potentialsBmp.convertFromImage(image) 
Note: See TracChangeset for help on using the changeset viewer.