예제 #1
0
 def OnLeftDown(self, event):
     x, y = event.GetPosition()
     self.origMouseDownPosition = event.GetPosition()
     
     self.hideListBox()
     shiftdown = wx.GetKeyState(wx.WXK_SHIFT)
     ctrldown = wx.GetKeyState(wx.WXK_CONTROL)
     
     # Clear all selection except with click on an existing selection
     if not shiftdown and not self.hovered_node in self.selected_nodes:
         self.selected_nodes.clear()
         
     if self.hovered_node:
         if self.hovered_node not in self.selected_nodes:
             self.selected_nodes.append(self.hovered_node)
         if not self.selected_plug:
             rect = self.nodeRects[self.hovered_node]
             # check if X is clicked
             if self.hovered_node.can_delete and x>(rect.x+rect.width)-20 and y<rect.y+20:
                 self.removeNode(self.hovered_node)
     
     elif self.selected_plug and ctrldown and self.selected_plug.inParam:
         self.selected_plug.setDefaultValue()
         self.graph.requires_compilation = True
     elif self.selected_plug:
         self.selected_nodes = [self.selected_plug.parent]
         
     self.lastx, self.lasty = x, y
     self.Refresh()
예제 #2
0
	def OnKeyChar(self, keyCode):
		if keyCode == wx.WXK_DELETE or keyCode == wx.WXK_NUMPAD_DELETE:
			if self._selectedObj is not None:
				self._deleteObject(self._selectedObj)
				self.QueueRefresh()
		if keyCode == wx.WXK_UP:
			self.layerSelect.setValue(self.layerSelect.getValue() + 1)
			self.QueueRefresh()
		elif keyCode == wx.WXK_DOWN:
			self.layerSelect.setValue(self.layerSelect.getValue() - 1)
			self.QueueRefresh()
		elif keyCode == wx.WXK_PAGEUP:
			self.layerSelect.setValue(self.layerSelect.getValue() + 10)
			self.QueueRefresh()
		elif keyCode == wx.WXK_PAGEDOWN:
			self.layerSelect.setValue(self.layerSelect.getValue() - 10)
			self.QueueRefresh()

		if keyCode == wx.WXK_F3 and wx.GetKeyState(wx.WXK_SHIFT):
			shaderEditor(self, self.ShaderUpdate, self._objectLoadShader.getVertexShader(), self._objectLoadShader.getFragmentShader())
		if keyCode == wx.WXK_F4 and wx.GetKeyState(wx.WXK_SHIFT):
			from collections import defaultdict
			from gc import get_objects
			self._beforeLeakTest = defaultdict(int)
			for i in get_objects():
				self._beforeLeakTest[type(i)] += 1
		if keyCode == wx.WXK_F5 and wx.GetKeyState(wx.WXK_SHIFT):
			from collections import defaultdict
			from gc import get_objects
			self._afterLeakTest = defaultdict(int)
			for i in get_objects():
				self._afterLeakTest[type(i)] += 1
			for k in self._afterLeakTest:
				if self._afterLeakTest[k]-self._beforeLeakTest[k]:
					print k, self._afterLeakTest[k], self._beforeLeakTest[k], self._afterLeakTest[k] - self._beforeLeakTest[k]
예제 #3
0
 def OnIdle(
     self, Event
 ):  # during idle time, handle keystrokes for shortcuts. This procedure is repeated in module datacore
     global KeyPressHash
     # initialise storage object used to remember keys pressed last time, for chord detection in correct order
     if not hasattr(self, 'PrevChordKeys'): self.PrevChordKeys = []
     KeysDownThisTime = [
     ]  # prepare list of key codes that are 'hit' and match any keys in KeyPressHash
     KeyPressIndexHit = None  # which item (index in KeyPressHash) is to be invoked
     for (HashIndex, (KeyStroke, Handler, Args)) in enumerate(
             KeyPressHash
     ):  # check each keystroke registered in KeyPressHash
         if type(KeyStroke) is int:
             if wx.GetKeyState(KeyStroke):
                 KeysDownThisTime.append(KeyStroke)
                 if not (KeyStroke in self.PrevChordKeys):
                     KeyPressIndexHit = HashIndex  # KeyStroke has been detected this time, but not last time
         elif type(KeyStroke) is list:  # key chord handling
             ChordFulfilled = True
             for k in KeyStroke:  # check each key in KeyStroke
                 if wx.GetKeyState(k): KeysDownThisTime.append(k)
                 else: ChordFulfilled = False
             # check that (1) all keys in KeyStroke are pressed, AND
             # (2) not all of them were pressed last time (i.e. >=1 of them is newly pressed)
             if ChordFulfilled and not set(KeyStroke).issubset(
                     set(self.PrevChordKeys)):
                 KeyPressIndexHit = HashIndex  # invoke handler if keystroke detected
     self.PrevChordKeys = KeysDownThisTime  # store currently-pressed keys for comparison next time
     # Must do the line above BEFORE invoking Handler - else KeyStrokes newly defined in Handler may falsely activate
     if (KeyPressIndexHit is not None):
         (KeyStroke, Handler, Args) = KeyPressHash[KeyPressIndexHit]
         Handler(**Args)  # invoke handler
예제 #4
0
    def on_release(self, event):
        """
        Function triggered on button release event from plot.
        Currently wired to trigger on_save_figure_dialog on middle button.
        :param event: wx.Event
        :return: None
        """
        if event.button == 1:
            if wx.GetKeyState(wx.WXK_ALT):
                try:
                    self.zoom.switch_label()
                except:
                    print "Could not switch on labels"
        if event.button == 2:
            if wx.GetKeyState(wx.WXK_CONTROL):
                dlg = DoubleInputDialog(self)
                dlg.initialize_interface("Matplotlib RC Parameters", "RC Param Name:", 'lines.markersize',
                                         "Value:", "6")
                dlg.ShowModal()
                rcname = dlg.value
                rcval = dlg.value2
                print rcname, rcval
                rcParams[rcname] = rcval
            elif wx.GetKeyState(wx.WXK_ALT):
                dlg = DoubleInputDialog(self)
                dlg.initialize_interface("Set Plot X Range", "Min:", '',
                                         "Max:", "")
                dlg.ShowModal()
                minval = dlg.value
                maxval = dlg.value2

                try:
                    minval = float(minval)
                    maxval = float(maxval)
                    self.zoom.set_manual(minval, maxval)
                    print "Manually Set Zoom:", minval, maxval
                except:
                    print "Error converting string to float:", minval, maxval
            elif wx.GetKeyState(wx.WXK_SHIFT):
                dlg = DoubleInputDialog(self)
                dlg.initialize_interface("Set Plot Y Range", "Min:", '',
                                         "Max:", "")
                dlg.ShowModal()
                minval = dlg.value
                maxval = dlg.value2

                try:
                    minval = float(minval)
                    maxval = float(maxval)
                    self.zoom.set_manual_y(minval, maxval)
                    print "Manually Set Zoom:", minval, maxval
                except:
                    print "Error converting string to float:", minval, maxval
            elif wx.GetKeyState(wx.WXK_SPACE):
                try:
                    self.zoom.switch_label()
                except:
                    print "Could not switch on labels"
            else:
                self.on_save_fig_dialog(event)
예제 #5
0
    def OnKeyUp(self, event):
        kc = event.GetKeyCode()
        if kc == ATTACK:
            self.normal_attack()
        elif kc == THROW_HAMMER:
            self.throw_hammer()
        elif kc == THROW_BOMB:
            self.throw_bomb()
        elif kc == RUN:
            self.user.run()

        # ball = self.user.get_ball()
        # if self.power > 0 and ball and ball.vx == 0 and ball.vy == 0:
        # ball.vx = 8.333 * math.cos(math.pi * self.dir / 180)
        # ball.vy = -8.333 * math.sin(math.pi * self.dir / 180)
            # print("vx: ", ball.vx, " vy: ", ball.vy)
        # if self.power == 0:
        #     ball.vx = 0
        #     ball.vy = 0
        if self.user.mouseMove == 0:
            olddir = self.dir
            oldpower = self.power
            if kc in [LEFT, RIGHT, UP, DOWN]:
                left = wx.GetKeyState(LEFT) and -1 or 0
                right = wx.GetKeyState(RIGHT) and 1 or 0
                up = wx.GetKeyState(UP) and -1 or 0
                down = wx.GetKeyState(DOWN) and 1 or 0
                self.calc_dir_power(left, right, up, down)
예제 #6
0
    def onWheelEvent(self, evt):
        
        # Ignore wheel if trying to measure     
        if wx.GetKeyState(wx.WXK_ALT) or not self.insideAxes: 
            return

        # Update cursor
        pub.sendMessage('motion_mode', dataOut=[self.shiftKey, self.ctrlKey, self.altKey, 
                                                self.addToTable, True, self.buttonDown, 
                                                self.dragged])
        
        if self.allowWheel:
            # The actual work
            for axes in self.axes:
                x0, x1 = axes.get_xlim()
                y0, y1 = axes.get_ylim()
                
                if self.data_lims is not None:
                    xmin, ymin, xmax, ymax = self.data_lims
                else:
                    xmin, ymin, xmax, ymax = axes.data_lims
                
                # Zoom in X-axis only
                if not wx.GetKeyState(wx.WXK_SHIFT):
                    # calculate diff
                    try:
                        x0_diff, x1_diff = evt.xdata-x0, x1-evt.xdata
                        x_sum = x0_diff + x1_diff
                    except: return
                    
                    stepSize = evt.step * ((x1 - x0)/50)
                    newXmin = x0-(stepSize*(x0_diff/x_sum))
                    newXmax = x1+(stepSize*(x1_diff/x_sum))
                    # Check if the X-values are off the data lims
                    if newXmin < xmin: newXmin = xmin
                    if newXmax > xmax: newXmax = xmax
                    axes.set_xlim((newXmin, newXmax))
                
                # Zoom in Y-axis only
                elif wx.GetKeyState(wx.WXK_SHIFT):
                    # Check if its 1D plot 
                    if self.plotName in ['1D', 'CalibrationDT', 'MS']:
                        stepSize = evt.step * ((y1 - y0)/25)
                        axes.set_ylim((0, y1+stepSize))
                    elif self.plotName != '1D':
                        try:
                            y0_diff, y1_diff = evt.xdata-y0, y1-evt.xdata
                            y_sum = y0_diff + y1_diff
                        except: return
                        
                        stepSize = evt.step * ((y1 - y0)/50)
                        newYmin = y0-(stepSize*(y0_diff/y_sum))
                        newYmax = y1+(stepSize*(y1_diff/y_sum))
                        # Check if the Y-values are off the data lims
                        if newYmin < ymin: newYmin = ymin
                        if newYmax > ymax: newYmax = ymax
                        
                        axes.set_ylim((newYmin, newYmax))
                
            self.canvas.draw()
예제 #7
0
 def motion(self, event):
     '''Handles panning & zooming for mouse click+drag events.'''
     if DOWN not in (self.left, self.right):
         return
     #print 'Mouse movement:', x, y
     (w, h) = self.window.size
     dx = event.X - self.position[0]
     dy = event.Y - self.position[1]
     if self.left == DOWN:
         if wx.GetKeyState(wx.WXK_CONTROL):
             # Mouse movement zooms in/out relative to target position
             if dx != 0.0:
                 self.window.camera_pos_rtp[0] *= (float(w - dx) / w)
         elif wx.GetKeyState(wx.WXK_SHIFT):
             # Mouse movement pans target position in  plane of the window
             camera_pos = np.array(rtp_to_xyz(*self.window.camera_pos_rtp))
             view_vec = -np.array(rtp_to_xyz(*self.window.camera_pos_rtp))
             zhat = np.array([0.0, 0.0, 1.0])
             right = -np.cross(zhat, view_vec)
             right /= np.sum(np.square(right))
             up = np.cross(right, view_vec)
             up /= np.sum(np.square(up))
             dr = right * (4.0 * dx / w)
             du = up * (4.0 * dy / h)
             self.window.target_pos += du - dr
         else:
             # Mouse movement creates a rotation about the target position
             xangle = 2.0 * self.window.fovy * float(dx) / h
             yangle = 2.0 * self.window.fovy * float(dy) / h
             rtp = self.window.camera_pos_rtp
             rtp[1] = min(max(rtp[1] - yangle, 0.05), 179.95)
             self.window.camera_pos_rtp[2] -= xangle
     self.position = (event.X, event.Y)
     self.window.Refresh()
     event.Skip()
예제 #8
0
    def Modifier(self, event):
        if UTILS_Utilisateurs.VerificationDroitsUtilisateurActuel(
                "familles_fiche", "consulter") == False:
            return
        # Si on est dans le DLG Rattachement
        if self.GetParent().GetName() == "DLG_Rattachement":
            self.GetParent().OnBoutonOk(None)
            return
        # Si on est dans le panel de recherche d'individus
        if len(self.Selection()) == 0:
            dlg = wx.MessageDialog(
                self,
                _(u"Vous n'avez sélectionné aucun individu dans la liste !"),
                _(u"Erreur de saisie"), wx.OK | wx.ICON_EXCLAMATION)
            dlg.ShowModal()
            dlg.Destroy()
            return
        # Ouvrir la fiche famille de l'individu
        track = self.Selection()[0]

        ouvrirGrille = False
        ouvrirFicheInd = False
        if event != None:
            # Ouverture grille de l'individu si touche CTRL enfoncée
            if wx.GetKeyState(wx.WXK_CONTROL) == True or event.GetId() == 60:
                ouvrirGrille = True

            # Ouverture fiche de l'individu si touche SHIFT enfoncée
            if wx.GetKeyState(wx.WXK_SHIFT) == True or event.GetId() == 70:
                ouvrirFicheInd = True

        # Ouverture de la fiche famille
        self.OuvrirFicheFamille(track, ouvrirGrille, ouvrirFicheInd)
예제 #9
0
    def __onSelChanged(self, event):
        ctrlstate = wx.GetKeyState(wx.WXK_CONTROL)
        shiftstate = wx.GetKeyState(wx.WXK_SHIFT)

        if (ctrlstate or shiftstate) and not self.__externalPageSelect:
            self._application.mainWindow.tabsController.openInTab(
                self.selectedPage, True)
        else:
            self._application.selectedPage = self.selectedPage
예제 #10
0
    def getKeyCode(self):
        modifier = 0

        if wx.GetKeyState(wx.WXK_SHIFT):
            modifier |= ID_KEY_SHIFT

        if wx.GetKeyState(wx.WXK_CONTROL):
            modifier |= ID_KEY_CTRL

        return modifier
예제 #11
0
 def wheel(self, evt):
     d = evt.GetWheelRotation()
     if wx.GetKeyState(wx.WXK_CONTROL):
         self.zScroll -= d * 0.01
         self.Refresh(eraseBackground=False)
     elif wx.GetKeyState(wx.WXK_SHIFT):
         self.xScroll -= d * 0.01
         self.Refresh(eraseBackground=False)
     else:
         self.yScroll -= d * 0.01
         self.Refresh(eraseBackground=False)
예제 #12
0
 def OnKeyDown(self, event):
     if self.user.mouseMove > 0:
         return
     olddir = self.dir
     oldpower = self.power
     kc = event.GetKeyCode()
     if kc in [LEFT, RIGHT, UP, DOWN]:
         left = wx.GetKeyState(LEFT) and -1 or 0
         right = wx.GetKeyState(RIGHT) and 1 or 0
         up = wx.GetKeyState(UP) and -1 or 0
         down = wx.GetKeyState(DOWN) and 1 or 0
         self.calc_dir_power(left, right, up, down)
예제 #13
0
        def process_key_state(self):
            try:
                up = 0b0001 if wx.GetKeyState(wx.WXK_UP) else 0
            except wx._core.PyNoAppError:
                return
            down = 0b0010 if wx.GetKeyState(wx.WXK_DOWN) else 0
            left = 0b0100 if wx.GetKeyState(wx.WXK_LEFT) else 0
            right = 0b1000 if wx.GetKeyState(wx.WXK_RIGHT) else 0
            self.input['joysticks'][0] = up | down | left | right

            trig = 0
            if wx.GetKeyState(wx.WXK_TAB):
                trig |= 1
            self.input['joystick_triggers'] = trig
            # print("joy", self.input['joy0'], "trig", self.input['trig0'])

            # console keys will reflect being pressed if at any time between
            # frames the key has been pressed
            mod = 0
            if wx.GetKeyState(wx.WXK_F2) or self.forced_modifier == 'option':
                mod |= akey.OPTION_FLAG
            if wx.GetKeyState(wx.WXK_F3) or self.forced_modifier == 'select':
                mod |= akey.SELECT_FLAG
            if wx.GetKeyState(wx.WXK_F4) or self.forced_modifier == 'start':
                mod |= akey.START_FLAG
            self.input['flags'] = mod
예제 #14
0
    def VerifKeyStates(self):
        """ est utilisé pour être sûr que le programme a bien remarqué les touches pressées """
        etat_Control = wx.GetKeyState(wx.WXK_CONTROL)
        etat_Shift = wx.GetKeyState(wx.WXK_SHIFT)
        etat_Alt = wx.GetKeyState(wx.WXK_ALT)

        if etat_Control == True:
            self.multiSelect = "CONTROL"
        if etat_Shift == True:
            self.multiSelect = "SHIFT"
            self.multiSelectWE = True
        if etat_Alt == True:
            self.multiSelect = "SHIFT"
            self.multiSelectWE = False
예제 #15
0
    def likselct(self, event):
        colo = ''

        couleur = ''
        Btn = event.GetEventObject()
        #giorno farmacho con un clic su un giorno
        if not wx.GetKeyState(wx.WXK_SHIFT):
            if self.col2:
                Btn.SetBackgroundColour(self.col2[0])
            else:
                pass

            self.tptable = []
            #colo=Btn.GetBackgroundColour()
            self.col.append(couleur)

            self.tptable.append(Btn.GetName())
        #giorno farmacho con un Shift su piu giorni
        if wx.GetKeyState(wx.WXK_SHIFT):
            #Btn.SetBackgroundColour(self.col2[0])
            self.tptable.append(Btn.GetName())
            if len(self.tptable) == 2:
                if self.tptable[0] == self.tptable[1]:
                    self.tptable[0] = copy.copy(self.tptable[1])
                if self.tptable[0] != self.tptable[1]:
                    self.bt2 = self.tptable[0]
                    self.bt1 = self.tptable[1]
                    dataInizio = min(
                        dt.datetime.strptime(self.bt1, '%Y-%m-%d'),
                        dt.datetime.strptime(self.bt2, '%Y-%m-%d'))
                    dataFine = max(dt.datetime.strptime(self.bt1, '%Y-%m-%d'),
                                   dt.datetime.strptime(self.bt2, '%Y-%m-%d'))

                    btname = ''
                    while (dataInizio <= dataFine):
                        btname = '%d-%02d-%02d' % (
                            dataInizio.year, dataInizio.month, dataInizio.day)
                        if btname in self.dicoButton.keys():
                            if self.col and self.col2 and self.dicoButton:
                                self.dicoButton[btname].SetBackgroundColour(
                                    self.col2[0])
                            else:
                                pass
                        else:
                            pass
                        dataInizio = dataInizio + dt.timedelta(days=1)
                    self.tptable = []
                    #self.tptable=[]
            if len(self.tptable) > 2: self.tptable = []
        self.callback(event)
예제 #16
0
    def OnKeyDown(self, evt):
        action = None
        type = None
        key = evt.GetKeyCode()

        if not self.isInitGL:
            pub.sendMessage("EVENT_KEY_DOWN", event=evt)
            return

        #key_list    = [wx.WXK_LEFT,wx.WXK_RIGHT,wx.WXK_HOME,wx.WXK_END,wx.WXK_UP,wx.WXK_DOWN,wx.WXK_PAGEUP,wx.WXK_PAGEDOWN]
        #action_ctrl = ["FAST_REWIND","FAST_FORWARD","START","END"]

        #if key in key_list:
        #   evt.Skip()
        #   return

        #--- scroll time fast by window
        if (wx.GetKeyState(wx.WXK_CONTROL) == True):

            if key == (wx.WXK_LEFT):
                action = "FAST_REWIND"
            elif key == (wx.WXK_RIGHT):
                action = "FAST_FORWARD"
            elif key == (wx.WXK_HOME):
                action = "START"
            elif key == (wx.WXK_END):
                action = "END"
    #----
        elif key == (wx.WXK_F11):
            action = "TIME_DISPLAY_ALL"
        elif key == (wx.WXK_F12):
            action = "CHANNELS_DISPLAY_ALL"

    #--- scroll time by scroll step
        elif key == wx.WXK_LEFT:
            action = "REWIND"
        elif key == wx.WXK_RIGHT:
            action = "FORWARD"

        #--- scroll channels
        elif key == wx.WXK_UP:
            action = "UP"
        elif key == wx.WXK_DOWN:
            action = "DOWN"
        elif key == wx.WXK_PAGEUP:
            action = "PAGEUP"
        elif key == wx.WXK_PAGEDOWN:
            action = "PAGEDOWN"
        elif key == wx.WXK_HOME:
            action = "TOP"
        elif key == wx.WXK_END:
            action = "BOTTOM"

    #---
        if action:
            self.plot.data.opt.action(action)
            self.update()

        else:
            pub.sendMessage("EVENT_KEY_DOWN", event=evt)
예제 #17
0
    def onMouseMove(self, x, y, dx, dy):
        if self._state == 'rotateView':
            self._app.getView().setYaw(self._app.getView().getYaw() + dx)
            self._app.getView().setPitch(self._app.getView().getPitch() - dy)
        if self._state == 'dragObjectOrSelect':
            obj = self._app.getView().getFocusObject()
            if obj is not None and isinstance(
                    obj, DisplayableObject) and not obj.isSelected():
                if not wx.GetKeyState(wx.WXK_CONTROL):
                    self._app.getScene().deselectAll()
                obj.setSelected(True)
            self._state = 'dragObject'
        if self._state == 'dragObject':
            mouse_ray = self._app.getView().projectScreenPositionToRay(x, y)
            plane_z = Plane(numpy.array([0, 0, 1], numpy.float32),
                            self._dragPos3D[2])

            cursor_on_plane = plane_z.intersectRay(mouse_ray)
            delta = numpy.array(cursor_on_plane[0:2] - self._dragPos3D[0:2],
                                numpy.float32)
            self._dragPos3D[0:2] = cursor_on_plane[0:2]

            for obj in self._app.getScene().getObjects():
                if obj.isSelected():
                    obj.setPosition(obj.getPosition() + delta)
예제 #18
0
    def buttonClickedCallback(self, button, number):
        """
		A method called when user clicks a button representing 
					 a time point
		"""
        shift = wx.GetKeyState(wx.WXK_SHIFT)
        numbers = []
        minNum, maxNum = number, number
        if shift and self.lastNumber >= 0:
            minNum = min(number, self.lastNumber)
            maxNum = max(number, self.lastNumber)
        for num in range(minNum, maxNum + 1):
            flag = not self.selectedFrames.get(num, False)
            if num == self.lastNumber: flag = not flag
            numbers.append((num, flag))

        for num, flag in numbers:
            do_cmd = self.parentPath + ".timepointSelection.setTimepoint(%d, %s)" % (
                num, str(flag))
            undo_cmd = self.parentPath + ".timepointSelection.setTimepoint(%d, %s)" % (
                num, str(not flag))

            if flag:
                descstr = "Select timepoint %d for processing" % num
            else:
                descstr = "Unselect timepoint %d for processing" % num
            cmd = lib.Command.Command(lib.Command.GUI_CMD,
                                      None,
                                      None,
                                      do_cmd,
                                      undo_cmd,
                                      desc=descstr)
            cmd.run()

        self.lastNumber = number
    def onInputChar(self, evt):
        id = evt.GetId()
        key = evt.GetKeyCode()
        if (key == wx.WXK_RETURN):
            self.goTo()
            return
        if (key == wx.WXK_SPACE):
            if self.tc2 and wx.GetKeyState(wx.WXK_CONTROL):
                text = self.TC2.GetValue()
            elif self.tc1:
                text = self.TC1.GetValue()
            wx.CallLater(30, speech.speakMessage, text)
            return

            return

        elif id == self.entriesListID and ((key == wx.WXK_DELETE) or
                                           (key == wx.WXK_NUMPAD_DELETE)):
            if gui.messageBox(_("Are you sure you wish to delete this items?"),
                              _("Deletion of items"),
                              wx.YES_NO | wx.ICON_WARNING) != wx.YES:
                return
            self.delete()
            return

        elif (key == wx.WXK_ESCAPE):
            self.Close()
            return
        evt.Skip()
예제 #20
0
    def show_preview(self, frame, tooltip_config):
        """
		When hovering over a link, show a tooltip iff:
		a) previewer is hidden
		b) shift is held down
		c) moving over link in previewer (or descendant)

		Otherwise, we handle it in our previewer
		"""
        if not self.aui_pane.IsShown():
            return False

        if frame == self:
            return False

        if wx.GetKeyState(wx.WXK_SHIFT):
            return False

        f = frame
        while f.logical_parent:
            f = f.logical_parent
            if f == self:
                return False

        self.tooltip_config = tooltip_config
        self.ShowTooltip()
        return True
예제 #21
0
파일: main.py 프로젝트: yncat/falcon
 def DelaiedCall(self, callable):
     """メニューから、すぐに何かを読み上げる機能を実行すると、メニューが閉じてリストに戻った読み上げにかき消されてしまう。なので、エンターが押されているかどうかを判定して、その場合にcallableの実行時間を遅らせる。"""
     if not wx.GetKeyState(wx.WXK_RETURN):
         callable()
         return
     else:
         later = wx.CallLater(200, callable)
예제 #22
0
    def OnMouseMotion(self, e):
        p0, p1 = self.getMouseRay(e.GetX(), e.GetY())
        p0 -= self.getObjectCenterPos() - self._viewTarget
        p1 -= self.getObjectCenterPos() - self._viewTarget

        if e.Dragging() and self._mouseState is not None:
            if e.LeftIsDown() and not e.RightIsDown():
                self._mouseState = 'drag'
                if wx.GetKeyState(wx.WXK_SHIFT):
                    a = math.cos(math.radians(self._yaw)) / 3.0
                    b = math.sin(math.radians(self._yaw)) / 3.0
                    self._viewTarget[0] += float(e.GetX() - self._mouseX) * -a
                    self._viewTarget[1] += float(e.GetX() - self._mouseX) * b
                    self._viewTarget[0] += float(e.GetY() - self._mouseY) * b
                    self._viewTarget[1] += float(e.GetY() - self._mouseY) * a
                else:
                    self._yaw += e.GetX() - self._mouseX
                    self._pitch -= e.GetY() - self._mouseY
                if self._pitch > 170:
                    self._pitch = 170
                if self._pitch < 10:
                    self._pitch = 10
            elif (e.LeftIsDown() and e.RightIsDown()) or e.MiddleIsDown():
                self._mouseState = 'drag'
                self._zoom += e.GetY() - self._mouseY
                if self._zoom < 1:
                    self._zoom = 1
                if self._zoom > numpy.max(self._machineSize) * 3:
                    self._zoom = numpy.max(self._machineSize) * 3

        self._mouseX = e.GetX()
        self._mouseY = e.GetY()
예제 #23
0
	def _on_identity_item_activated(self, event):
		data = self._LCTRL_identity.get_selected_item_data(only_one = True)
		if data is None:
			gmDispatcher.send(signal = 'display_widget', name = 'gmNotebookedPatientEditionPlugin')

		# <ctrl> down ?
		if not wx.GetKeyState(wx.WXK_CONTROL):
			gmDispatcher.send(signal = 'display_widget', name = 'gmNotebookedPatientEditionPlugin')

		# <ctrl> down !
		if isinstance(data, gmPerson.cPersonName):
			ea = gmDemographicsWidgets.cPersonNameEAPnl(self, -1, name = data)
			dlg = gmEditArea.cGenericEditAreaDlg2(self, -1, edit_area = ea, single_entry = True)
			dlg.SetTitle(_('Cloning name'))
			dlg.ShowModal()
			return

		if isinstance(data, dict):
			key = list(data)[0]
			val = data[key]
			if key == 'id':
				ea = gmDemographicsWidgets.cExternalIDEditAreaPnl(self, -1, external_id = val)
				ea.id_holder = gmPerson.gmCurrentPatient()
				dlg = gmEditArea.cGenericEditAreaDlg2(self, -1, edit_area = ea, single_entry = True)
				dlg.SetTitle(_('Editing external ID'))
				dlg.ShowModal()
				return
			if key == 'job':
				gmDemographicsWidgets.edit_occupation()
				return
예제 #24
0
 def __OnLeftDown_(self, evt):
     (index, flags) = self.HitTest(evt.GetPosition())
     if flags == wx.LIST_HITTEST_ONITEMICON:
         img_idx = self.GetItem(index).GetImage()
         flag_check = img_idx == 0
         begin_index = index
         end_index = index
         if self.__last_check_ is not None \
                 and wx.GetKeyState(wx.WXK_SHIFT):
             last_index, last_flag_check = self.__last_check_
             if last_flag_check == flag_check:
                 # XXX what if the previous item is deleted or new items
                 # are inserted?
                 item_count = self.GetItemCount()
                 if last_index < item_count:
                     if last_index < index:
                         begin_index = last_index
                         end_index = index
                     elif last_index > index:
                         begin_index = index
                         end_index = last_index
                     else:
                         assert False
         while begin_index <= end_index:
             self.CheckItem(begin_index, flag_check)
             begin_index += 1
         self.__last_check_ = (index, flag_check)
     else:
         evt.Skip()
예제 #25
0
 def onAddNote(self, event):
     _with_tags = wx.GetKeyState(wx.WXK_SHIFT)
     insertionPoint = self.view.contentTextCtrl.GetInsertionPoint()
     comment_text = self.view.get_text_from_user(
         # Translators: the title of a dialog to add a comment
         _("New Comment"),
         # Translators: the label of an edit field to enter a comment
         _("Comment:"),
         style=wx.OK | wx.CANCEL | wx.TE_MULTILINE | wx.CENTER,
     )
     if not comment_text:
         return
     note = NoteTaker(self.reader).create(title="",
                                          content=comment_text,
                                          position=insertionPoint)
     self.service.style_comment(self.view, insertionPoint)
     if _with_tags:
         # add tags
         tags_text = self.view.get_text_from_user(
             # Translators: title of a dialog
             _("Tag Comment"),
             # Translators: label of a text entry
             _("Tags:"),
         )
         if tags_text:
             for tag in tags_text.split():
                 note.tags.append(tag.strip())
             NoteTaker.model.session.commit()
예제 #26
0
    def on_mouse_motion(self, e):
        if e.Dragging() and self._mouse_state is not None:
            if e.LeftIsDown() and not e.RightIsDown():
                self._mouse_state = 'drag'
                if wx.GetKeyState(wx.WXK_SHIFT):
                    a = math.cos(math.radians(self._yaw)) / 3.0
                    b = math.sin(math.radians(self._yaw)) / 3.0
                    self._view_target[0] += float(e.GetX() -
                                                  self._mouse_x) * -a
                    self._view_target[1] += float(e.GetX() - self._mouse_x) * b
                    self._view_target[0] += float(e.GetY() - self._mouse_y) * b
                    self._view_target[1] += float(e.GetY() - self._mouse_y) * a
                else:
                    self._yaw += e.GetX() - self._mouse_x
                    self._pitch -= e.GetY() - self._mouse_y
                if self._pitch > 170:
                    self._pitch = 170
                if self._pitch < 10:
                    self._pitch = 10
            elif (e.LeftIsDown() and e.RightIsDown()) or e.MiddleIsDown():
                self._mouse_state = 'drag'
                self._zoom += e.GetY() - self._mouse_y
                if self._zoom < 1:
                    self._zoom = 1
                if self._zoom > numpy.max(self._machine_size) * 3:
                    self._zoom = numpy.max(self._machine_size) * 3

        self._mouse_x = e.GetX()
        self._mouse_y = e.GetY()
예제 #27
0
 def OnDrag(self, p0, p1):
     cursorX0, cursorY0, cursorZ0, cursorYZ, cursorXZ, cursorXY = self._ProjectToPlanes(
         p0, p1)
     if self.dragPlane == 'XY':
         angle = math.atan2(cursorZ0[1], cursorZ0[0]) * 180 / math.pi
     elif self.dragPlane == 'XZ':
         angle = math.atan2(cursorY0[2], cursorY0[0]) * 180 / math.pi
     else:
         angle = math.atan2(cursorX0[2], cursorX0[1]) * 180 / math.pi
     diff = angle - self.dragStartAngle
     if wx.GetKeyState(wx.WXK_SHIFT):
         diff = round(diff / 1) * 1
     else:
         diff = round(diff / 15) * 15
     if diff > 180:
         diff -= 360
     if diff < -180:
         diff += 360
     rad = diff / 180.0 * math.pi
     self.dragEndAngle = self.dragStartAngle + diff
     if self.dragPlane == 'XY':
         self.parent.tempMatrix = numpy.matrix(
             [[math.cos(rad), math.sin(rad), 0],
              [-math.sin(rad), math.cos(rad), 0], [0, 0, 1]], numpy.float64)
     elif self.dragPlane == 'XZ':
         self.parent.tempMatrix = numpy.matrix(
             [[math.cos(rad), 0, math.sin(rad)], [0, 1, 0],
              [-math.sin(rad), 0, math.cos(rad)]], numpy.float64)
     else:
         self.parent.tempMatrix = numpy.matrix(
             [[1, 0, 0], [0, math.cos(rad), math.sin(rad)],
              [0, -math.sin(rad), math.cos(rad)]], numpy.float64)
예제 #28
0
    def OnZoomFun(self, event):
        # get the current x and y limits
        if not self.GetToolState(self.wx_ids['Zoom']):
            return
        if self._nav_stack.empty():
            self.push_current()
        base_scale = 2.0
        ax = self.figure.gca()
        cur_xlim = ax.get_xlim()
        cur_ylim = ax.get_ylim()

        xdata = event.xdata  # get event x location
        ydata = event.ydata  # get event y location
        if xdata is None:
            return
        if ydata is None:
            return

        if event.button == 'down':
            # deal with zoom in
            scale_factor = 1.0 / base_scale
        elif event.button == 'up':
            # deal with zoom out
            scale_factor = base_scale
        else:
            # deal with something that should never happen
            scale_factor = 1.0

        new_width = (cur_xlim[1] - cur_xlim[0]) * scale_factor
        new_height = (cur_ylim[1] - cur_ylim[0]) * scale_factor

        relx = (cur_xlim[1] - xdata) / (cur_xlim[1] - cur_xlim[0])
        rely = (cur_ylim[1] - ydata) / (cur_ylim[1] - cur_ylim[0])
        xzoom = yzoom = True
        if wx.GetKeyState(wx.WXK_CONTROL_X):
            yzoom = False
        elif wx.GetKeyState(wx.WXK_CONTROL_Y):
            xzoom = False
        if (xzoom) and new_width * (1 - relx) > 0:
            ax.set_xlim(
                [xdata - new_width * (1 - relx), xdata + new_width * (relx)])
        if (yzoom) and new_height * (1 - rely) > 0:
            ax.set_ylim(
                [ydata - new_height * (1 - rely), ydata + new_height * (rely)])
        self.canvas.draw()
예제 #29
0
 def btn_action(evt,
                tab_data=tab_data,
                actuator=actuator,
                axis=axis,
                factor=factor):
     # Button events don't contain key state, so check ourselves
     if wx.GetKeyState(wx.WXK_SHIFT):
         factor /= 10
     tab_data.step(actuator, axis, factor)
예제 #30
0
 def OnMouseMotion(self, event):
     x, y = event.GetPosition()
     dx, dy = x-self.lastx, y-self.lasty
     self.lastx, self.lasty = x, y
     
     if event.Dragging():
         if event.MiddleIsDown():
             self.panx += dx
             self.pany += dy
         elif event.LeftIsDown():
             if self.selected_plug: # find 2nd plug
                 self.selected_plug2 = None
                 for plug, loc in self.pluglocation.items():
                     lx, ly = loc
                     if x>=lx-PLUG_CIRCLE_RADIUS and x<=lx+PLUG_CIRCLE_RADIUS and y>=ly-PLUG_CIRCLE_RADIUS and y<=ly+PLUG_CIRCLE_RADIUS:
                         if self.selected_plug != plug:
                             self.selected_plug2 = plug
                         break
             elif self.selected_nodes and self.hovered_node and (not self.selection_rect.width>0 or not self.selection_rect.height>0): # move node
                 for node in self.selected_nodes:
                     node.location[0] += dx
                     node.location[1] += dy
             else: # selection rect
                 x1, y1 = x, y
                 x2, y2 = self.origMouseDownPosition
                 if x2<x1:
                     x1,x2=x2,x1
                 if y2<y1:
                     y1,y2=y2,y1
                 self.selection_rect = wx.Rect(x1,y1,x2-x1,y2-y1)
                 
                 self.rect_selected_nodes.clear()
                 if not wx.GetKeyState(wx.WXK_SHIFT):
                     self.selected_nodes.clear()
                 for node, rect in self.nodeRects.items():
                     if rect.Intersects(self.selection_rect):
                         if node not in self.rect_selected_nodes:
                             self.rect_selected_nodes.append(node)
                 
     else: # find node/ 1st plug
         self.hovered_node = None
         self.selected_plug = None
         self.selected_plug2 = None
         found = False
         for plug, loc in self.pluglocation.items():
             lx, ly = loc
             if x>=lx-PLUG_CIRCLE_RADIUS and x<=lx+PLUG_CIRCLE_RADIUS and y>=ly-PLUG_CIRCLE_RADIUS and y<=ly+PLUG_CIRCLE_RADIUS:
                 self.selected_plug = plug
                 found = True
                 break
         if not found: # if no plug found
             for node, rect in self.nodeRects.items():
                 if rect.Contains(x,y):
                     self.hovered_node = node
                     break
     self.Refresh()