def __init__(self, parentItem, Z=1, umpx=1): Overlay.__init__(self, parentItem, Z=Z) self.opt = set(['xmass', 'ymass', 'radius', 'angle']) self.circle = QtGui.QGraphicsEllipseItem(parent=self) self.circle.setPen(self.pen) self.circle.setPos(0, 0) self.umpx = umpx
def __init__(self, overlayId, app): Overlay.__init__(self, OVERLAY_APP, overlayId) EventHandler.__init__(self) self.app = app # which app is this overlay tied to self.bounds.setAll(app.left, app.right, app.top, app.bottom) self.displayId = app.getDisplayId() self.aspectRatio = self.bounds.getWidth() / float(self.bounds.getHeight()) self.minAppSize = 300 # min app size in either direction self.z = self.app.getZvalue() self.__resetOverlay() self.capturedCorner = APP self.lastClickPos = (0,0) self.lastClickDeviceId = None self.overCorner = APP # register for the events that are fired when an app changes self.registerForEvent(EVT_APP_INFO, self.__onAppChanged) self.registerForEvent(EVT_Z_CHANGE, self.__onZChanged) # register for the events that are fired by devices self.registerForEvent(EVT_MOVE, self.__onOver) self.registerForEvent(EVT_CLICK, self.__onClick) self.registerForEvent(EVT_DRAG, self.__onDrag) self.registerForEvent(EVT_ROTATE, self.__onRotate) self.registerForEvent(EVT_ZOOM, self.__onZoom) self.registerForEvent(EVT_ARROW, self.__onArrow) self.registerForEvent(EVT_LEFT_WINDOW, self.__onLeftWindow) # register for the events from the special devices self.registerForEvent(EVT_MOVE_SPECIAL, self.__onSpecialMove) self.registerForEvent(EVT_ENTERED_WINDOW_SPECIAL, self.__onEnteredWindowSpecial) self.registerForEvent(EVT_LEFT_WINDOW_SPECIAL, self.__onLeftWindowSpecial)
def __init__(self, app=None, direction=VERTICAL): Overlay.__init__(self, OVERLAY_SPLITTER) EventHandler.__init__(self, app) self.direction = direction self.__enlarged = False self.__scaleMultiplier = 4.0 self._canScale = False self.mouseOverScale = 1.0 self.setTransparency(255) self.z = BOTTOM_Z - 10 self.relPos = 0.5 # relative to the section it splits self._preCollapsedPos = self.relPos self.__buffer = int(20 * getGlobalScale()) self._collapsed = False self.registerForEvent(EVT_DRAG, self.__onDrag) self.registerForEvent(EVT_CLICK, self.__onClick) self.registerForEvent(EVT_MOVE, self.__onMove) self.registerForEvent(EVT_LEFT_WINDOW, self._onLeftWindow) self.registerForEvent(EVT_ENTERED_WINDOW, self._onEnteredWindow) if direction == VERTICAL: self.__image = opj("images", "vertical_divider.png") else: self.__image = opj("images", "horizontal_divider.png")
def __init__(self, app=None): Overlay.__init__(self, OVERLAY_BUTTON) EventHandler.__init__(self, app) # register for the events that are fired by devices self.registerForEvent(EVT_CLICK, self._onClick) self.registerForEvent(EVT_MOVE, self._onMove) self.registerForEvent(EVT_LEFT_WINDOW, self._onLeftWindow) self.registerForEvent(EVT_ENTERED_WINDOW, self._onEnteredWindow) # paths to images drawn for different button states self.__upImage = "images/default_button_up.png" self.__downImage = "" self.__overImage = "" self.__doPlaySound = True # button can be a toggle self._isToggle = False self.__radioFunc = True self.__clicked = False self._manual = False self._radio = False # current state of the button self.__state = UP_STATE # callbacks you can register self.__onDown = None self.__onUp = None self._lastDevice = None self.__minTimeBetweenClicks = 0.5 # by default, allow rapid successive clicks self.__lastUp = 0.0 self.__lastDown = 0.0
def __init__(self, app=None, label="", fontSize=NORMAL): """ If you pass in None for app, the widget will reside on the top layer above all apps but below pointers. """ Overlay.__init__(self, OVERLAY_LABEL) EventHandler.__init__(self, app) self.setLabel(label, fontSize) self.__drawBackground = True
def __init__(self, parentItem, Z=1): Overlay.__init__(self, parentItem, Z) self.label = MetaItem(parent=self) self.label.setText('Empty') self.label.setFlags(QtGui.QGraphicsItem.ItemIsSelectable | QtGui.QGraphicsItem.ItemIsFocusable | QtGui.QGraphicsItem.ItemIsMovable | QtGui.QGraphicsItem.ItemIgnoresTransformations) self.menu = QtGui.QMenu() self.acts = {}
def __init__(self, app): Overlay.__init__(self, OVERLAY_APP) EventHandler.__init__(self, app) # must set size and pos first self._canScale = False self.setSize(1.0, 1.0) # same size as the app self.setPos(0.0, 0.0) # right over the app self._zOffset = APP_OVERLAY_Z self._allowSelection = True # some initial params self.minAppSize = 250 # min app size in either direction self.capturedCorner = APP self.lastClickPos = (0,0) self.lastClickDeviceId = None self.overCorner = APP self.bounds = self.getBounds() # from EventHandler base class self._clickDownTime = 0.0 self.__startedDrag = False # for accidental touches... # if less than X seconds has passed between two double clicks, # maximize to the whole display, otherwise, just within the section self._lastDoubleClick = 0.0 self.__maximizeThreshold = 1.3 # seconds between two double clicks... # for closing apps self.__multiTouchStartTime = -1 self.org = getLayoutOrganization() # get the filename from appLauncher if "imageviewer" in app.getName().lower() or \ "mplayer" in app.getName().lower() or \ "stereo3d" in app.getName().lower() or \ "pdf" in app.getName().lower(): # get the config info from the right appLauncher if app.getLauncherId() != "none": appLauncher = xmlrpclib.ServerProxy("http://" + app.getLauncherId()) try: res = appLauncher.getAppConfigInfo( app.getAppId() ) except: print "\nUnable to connect to appLauncher on", app.getLauncherId(), "so not saving this app: ", app.getName() else: print "appLauncher.getAppConfigInfo : ", res if res != -1: configName, optionalArgs = res if "imageviewer" in app.getName().lower(): # filename at the beginning of the command line for images self.fullpathname = optionalArgs.split()[0].strip('"') self.filename = os.path.basename( self.fullpathname ) else: # filename at the end of the command line for movies self.fullpathname = optionalArgs.split()[-1].strip('"') self.filename = os.path.basename( self.fullpathname ) if getShowWindowTitleBar(): self.setTooltip(self.filename, LARGER)
def __init__(self, app=None, direction=HORIZONTAL): """ If you pass in None for app, the widget will reside on the top layer above all apps but below pointers. """ Overlay.__init__(self, OVERLAY_SIZER) EventHandler.__init__(self, app) self.__direction = direction # let the events pass through since we are transparent self._eventTransparent = True
def __init__(self, parentItem, Z=1, startLine=True): Overlay.__init__(self, parentItem, Z=Z) self.opt = set( ['startLine', 'slope', 'const', 'domain', 'roi', 'crop']) # Create base and height lines self.line = QtGui.QGraphicsLineItem(parent=self) if not startLine: self.pen.setColor(QtGui.QColor('red')) self.line.setPen(self.pen) self.startLine = startLine
def __init__(self, parentItem, Z=1, umpx=1): Overlay.__init__(self, parentItem, Z=Z) self.opt = set( ['profile', 'iA', 'roi', 'angle', 'w', 'h', 'xmass', 'ymass', 'crop']) # Create base and height lines self.base = QtGui.QGraphicsLineItem(parent=self) self.base.setPen(self.pen) self.height = QtGui.QGraphicsLineItem(parent=self) self.height.setPen(self.pen) self.umpx = umpx
def __init__(self, parentItem, is_hsm, Z=2, profile_name='profile'): Overlay.__init__(self, parentItem, Z=Z) self.opt = set([profile_name, 'roi', 'crop']) self.profile_name = profile_name self.path = QtGui.QGraphicsPathItem(parent=self) self.path.setPen(self.pen) self.color.setAlpha(80) self.path.setBrush(QtGui.QBrush(self.color)) self.create_profile_points = create_profile_points_generic if is_hsm: self.create_profile_points = create_profile_points_for_hsm
def __init__(self, overlayId): Overlay.__init__(self, OVERLAY_POINTER, overlayId) self.state = RESET self.lastOrientation = 0 self.inApp = False self.__savedState = [self.state, self.lastOrientation, self.inApp] # some devices only produce one analog event so set it here if so # (e.g. a zoom-only puck) # this is used when the device enters an application in order to show # the correct pointer shape describing what the device can do self.onlyAnalogEvent = None
def __init__(self, parentItem, Z=1): Overlay.__init__(self, parentItem, Z=Z) self.opt = set(['profile', 'iA', 'iB', 'iC', 'iD', 'roi', 'crop']) # Create Points attributes, iA, iB, etc for p in self.opt: if not p.startswith('i'): continue g = QtGui.QGraphicsEllipseItem(parent=self) g.setPen(self.pen) g.setZValue(self.Z) g.setPos(0, 0) setattr(self, p, g)
def __init__(self, parentItem, sample=False, Z=1): Overlay.__init__(self, parentItem, Z) self._opt = 'roi' self.remObj = sample self.moving = False self.pen.setStyle(QtCore.Qt.DotLine) self.current = {self._opt: [0, 0, 0, 0]} # Graphical elements: # ROI Box self.box = HookRect(parent=self) self.box.hookPress = self.blockUpdates self.box.hookRelease = self.setCurrent self.box.hook = self.move self.box.setPen(self.pen) self.box.setZValue(self.Z) self.grid = Grid(self, self.Z) # ROI Corners self.ptul = HookPoint( w=10, h=10, pen=self.pen, Z=self.Z + 1, parent=self) self.ptul.setFlag(QtGui.QGraphicsItem.ItemIgnoresTransformations, True) self.ptbr = HookPoint( w=10, h=10, pen=self.pen, Z=self.Z + 2, parent=self) self.ptbr.setFlag(QtGui.QGraphicsItem.ItemIgnoresTransformations, True) # Text label self.label = QtGui.QGraphicsTextItem(str(self.Z), parent=self) self.label.setDefaultTextColor(self.color) self.label.setFlag( QtGui.QGraphicsItem.ItemIgnoresTransformations, True) self.font = self.label.font() # Imposto gli hook dei punti in modo che quando vengono mossi # provochino il ridimensionamento del rettangolo self.ptul.hook = self.reDim self.ptul.hookPress = self.blockUpdates # al rilascio del mouse, i valori vengono applicati sul server self.ptul.hookRelease = self.setCurrent self.ptbr.hook = self.reDim self.ptbr.hookPress = self.blockUpdates self.ptbr.hookRelease = self.setCurrent
def __init__(self, app=None): """ If you pass in None for app, the widget will reside on the top layer above all apps but below pointers. """ Overlay.__init__(self, OVERLAY_PANEL) EventHandler.__init__(self, app) self.registerForEvent(EVT_DRAG, self.__onDrag) self.registerForEvent(EVT_CLICK, self._onClick) self._allowDrag = False # ONLY USE WITH ABSOLUTE POSITION!!! (wont work when aligned) self.__fitInWidth = True self.__fitInHeight = True self.__borderWidth = 0 self._zOffset -= 0.01 # just below the other widgets self.px = self.py = 0
def __init__(self, x=0, y=0): Overlay.__init__(self, OVERLAY_POINTER) EventHandler.__init__(self) self.setSize(50,75) self.setPos(x,y) self.setDrawOrder(POST_DRAW) self.state = RESET self.lastOrientation = 0 self.inApp = False self.__savedState = [self.state, self.lastOrientation, self.inApp] # some devices only produce one analog event so set it here if so # (e.g. a zoom-only puck) # this is used when the device enters an application in order to show # the correct pointer shape describing what the device can do self.onlyAnalogEvent = None self._eventTransparent = True # so that we dont receive our own clicks... self.__image = ""