コード例 #1
0
 def __init__(self, parent):
     Component.__init__(self, parent)
     TextBase.__init__(self)
     RadioBase.__init__(self)
     CheckBase.__init__(self)
     TipBase.__init__(self)
     self.command = ''
     self.changeEvent('checked', self.__onCheckChanged, postevent=False)
コード例 #2
0
 def __init__(self, parent):
     Component.__init__(self, parent)
     TextBase.__init__(self)
     RadioBase.__init__(self)
     CheckBase.__init__(self)
     TipBase.__init__(self)
     self.command = ''
     self.changeEvent('checked', self.__onCheckChanged, postevent=False)
コード例 #3
0
class ColorMapObserver(Observer):
    def __init__(self, parent, colorSubject):
        self.colorSubject = colorSubject
        Observer.__init__(self, colorSubject)

        # Color Map Component
        self._colorMapComponent = Component(parent)
        self._colorMapComponent.background = r'Images\HSVColorMap.jpg'
        self._colorMapComponent.rect = (100, 200, 200, 200)

        self._colorMapComponent.bind('Mouse Move', self._onMouseMoved)
        self._colorMapComponent.bind('Mouse Down', self._onMouseDown)

        # Cursor component on the color Map
        self._colorMapCursorComponent = Component(parent)
        self._colorMapCursorComponent.bgColor = color.black
        self._colorMapCursorComponent.rect = (200, 200, 5, 5)

    # Update the cursor on the color map
    def update(self):
        (x, y) = self._hs2xy(self.colorSubject.getH(),
                             self.colorSubject.getS())
        self._colorMapCursorComponent.xy = (x + self._colorMapComponent.left,
                                            y + self._colorMapComponent.top)

    # Color map component callback function
    def _onMouseMoved(self, x, y, unused):
        if self._colorMapComponent.getIsMouseDown():
            self._onMouseDown(x, y, unused)

    def _onMouseDown(self, x, y, unused):
        (tempH, tempS, tempV) = self._xy2hsv(x, y)
        if tempS <= 100:
            self.colorSubject.setHSV(tempH, tempS, tempV)

    # From color map coordinates to HSV
    def _xy2hsv(self, x, y):
        h = math.atan2(y - 100, x - 100) * 180 / math.pi
        if h < 0:
            h = h + 360.0
        s = ((x - 100)**2 + (y - 100)**2)**0.5
        return (round(h), round(s), 100)

    # From HSV to color map coordinates
    def _hs2xy(self, h, s):
        h = h / 180.0 * math.pi
        x = 100 + s * math.cos(h)
        y = 100 + s * math.sin(h)
        return (int(round(x)), int(round(y)))
コード例 #4
0
    def __init__(self, parent, colorSubject):
        self.colorSubject = colorSubject
        Observer.__init__(self, colorSubject)

        self._colorComponent = Component(parent)
        self._colorComponent.bgColor = color.black
        self._colorComponent.rect = (25, 85, 50, 50)
コード例 #5
0
    def __init__(self, parent, colorSubject):
        self.colorSubject = colorSubject
        Observer.__init__(self, colorSubject)

        # Color Map Component
        self._colorMapComponent = Component(parent)
        self._colorMapComponent.background = r'Images\HSVColorMap.jpg'
        self._colorMapComponent.rect = (100, 200, 200, 200)

        self._colorMapComponent.bind('Mouse Move', self._onMouseMoved)
        self._colorMapComponent.bind('Mouse Down', self._onMouseDown)

        # Cursor component on the color Map
        self._colorMapCursorComponent = Component(parent)
        self._colorMapCursorComponent.bgColor = color.black
        self._colorMapCursorComponent.rect = (200, 200, 5, 5)
コード例 #6
0
class ColorMapObserver(Observer):
    def __init__(self, parent, colorSubject):
        self.colorSubject = colorSubject
        Observer.__init__(self, colorSubject)
        
        # Color Map Component
        self._colorMapComponent = Component(parent)
        self._colorMapComponent.background = r'Images\HSVColorMap.jpg'
        self._colorMapComponent.rect = (100, 200, 200, 200)
        
        self._colorMapComponent.bind('Mouse Move', self._onMouseMoved)
        self._colorMapComponent.bind('Mouse Down', self._onMouseDown)

        # Cursor component on the color Map   
        self._colorMapCursorComponent = Component(parent)
        self._colorMapCursorComponent.bgColor = color.black
        self._colorMapCursorComponent.rect = (200, 200, 5, 5)
    
    # Update the cursor on the color map     
    def update(self):     
        (x, y) = self._hs2xy(self.colorSubject.getH(), self.colorSubject.getS())
        self._colorMapCursorComponent.xy = (x + self._colorMapComponent.left, y + self._colorMapComponent.top)
        
    # Color map component callback function       
    def _onMouseMoved(self, x, y, unused):
        if self._colorMapComponent.getIsMouseDown():
            self._onMouseDown(x, y, unused)
            
    def _onMouseDown(self, x, y, unused):
        (tempH, tempS, tempV) = self._xy2hsv(x, y)
        if tempS <= 100:
            self.colorSubject.setHSV(tempH, tempS, tempV)
            
    # From color map coordinates to HSV
    def _xy2hsv(self, x, y):
        h = math.atan2(y - 100, x - 100) * 180 / math.pi
        if h < 0:
            h = h + 360.0 
        s = ((x - 100) ** 2 + (y - 100) ** 2) ** 0.5
        return (round(h), round(s), 100)

    # From HSV to color map coordinates
    def _hs2xy(self, h, s):
        h = h / 180.0 * math.pi
        x = 100 + s * math.cos(h)
        y = 100 + s * math.sin(h)
        return (int(round(x)), int(round(y)))
コード例 #7
0
    def __init__(self, parent, colorSubject):
        self.colorSubject = colorSubject
        Observer.__init__(self, colorSubject)
        
        # Color Map Component
        self._colorMapComponent = Component(parent)
        self._colorMapComponent.background = r'Images\HSVColorMap.jpg'
        self._colorMapComponent.rect = (100, 200, 200, 200)
        
        self._colorMapComponent.bind('Mouse Move', self._onMouseMoved)
        self._colorMapComponent.bind('Mouse Down', self._onMouseDown)

        # Cursor component on the color Map   
        self._colorMapCursorComponent = Component(parent)
        self._colorMapCursorComponent.bgColor = color.black
        self._colorMapCursorComponent.rect = (200, 200, 5, 5)