Exemplo n.º 1
0
    def mousePressEvent(self, event):
        anchor_item = self.scene.item_at(event.scenePos(),
                                         items.NodeAnchorItem,
                                         buttons=Qt.LeftButton)
        if anchor_item and event.button() == Qt.LeftButton:
            # Start a new link starting at item
            self.from_item = anchor_item.parentNodeItem()
            if isinstance(anchor_item, items.SourceAnchorItem):
                self.direction = NewLinkAction.FROM_SOURCE
                self.source_item = self.from_item
            else:
                self.direction = NewLinkAction.FROM_SINK
                self.sink_item = self.from_item

            event.accept()

            helpevent = QuickHelpTipEvent(
                self.tr("Create a new link"),
                self.tr('<h3>Create new link</h3>'
                        '<p>Drag a link to an existing node or release on '
                        'an empty spot to create a new node.</p>'
#                        '<a href="help://orange-canvas/create-new-links">'
#                        'More ...</a>'
                        )
            )
            QCoreApplication.postEvent(self.document, helpevent)

            return True
        else:
            # Whoever put us in charge did not know what he was doing.
            self.cancel(self.ErrorReason)
            return False
Exemplo n.º 2
0
 def showssd(self, param):
     if param == 'ALL' or param == 'OFF':
         qapp.postEvent(qapp.instance(), DisplayFlagEvent('SSD', param))
     else:
         idx = self.sim.traf.id2idx(param)
         if idx >= 0:
             qapp.postEvent(qapp.instance(), DisplayFlagEvent('SSD', idx))
Exemplo n.º 3
0
 def showssd(self, param):
     if param == "ALL" or param == "OFF":
         qapp.postEvent(qapp.instance(), DisplayFlagEvent("SSD", param))
     else:
         idx = self.sim.traf.id2idx(param)
         if idx >= 0:
             qapp.postEvent(qapp.instance(), DisplayFlagEvent("SSD", idx))
Exemplo n.º 4
0
 def end(self):
     self.cleanup()
     # Remove the help tip set in mousePressEvent
     self.macro = None
     helpevent = QuickHelpTipEvent("", "")
     QCoreApplication.postEvent(self.document, helpevent)
     UserInteraction.end(self)
Exemplo n.º 5
0
 def scrollPage(self, degrees=180, afterScroll=None):
     # do 180 degree scroll down
     event = QWheelEvent(QCursor.pos(), -1 * (degrees / 15) * 120, Qt.MouseButtons(), Qt.KeyboardModifiers(),
                         Qt.Vertical)
     QCoreApplication.postEvent(self, event)
     if afterScroll:
         afterScroll(self)
Exemplo n.º 6
0
    def mousePressEvent(self, event):
        anchor_item = self.scene.item_at(event.scenePos(),
                                         items.NodeAnchorItem,
                                         buttons=Qt.LeftButton)
        if anchor_item and event.button() == Qt.LeftButton:
            # Start a new link starting at item
            self.from_item = anchor_item.parentNodeItem()
            if isinstance(anchor_item, items.SourceAnchorItem):
                self.direction = NewLinkAction.FROM_SOURCE
                self.source_item = self.from_item
            else:
                self.direction = NewLinkAction.FROM_SINK
                self.sink_item = self.from_item

            event.accept()

            helpevent = QuickHelpTipEvent(
                self.tr("Create a new link"),
                self.
                tr('<h3>Create new link</h3>'
                   '<p>Drag a link to an existing node or release on '
                   'an empty spot to create a new node.</p>'
                   #                        '<a href="help://orange-canvas/create-new-links">'
                   #                        'More ...</a>'
                   ))
            QCoreApplication.postEvent(self.document, helpevent)

            return True
        else:
            # Whoever put us in charge did not know what he was doing.
            self.cancel(self.ErrorReason)
            return False
Exemplo n.º 7
0
 def end(self):
     self.cleanup()
     # Remove the help tip set in mousePressEvent
     self.macro = None
     helpevent = QuickHelpTipEvent("", "")
     QCoreApplication.postEvent(self.document, helpevent)
     UserInteraction.end(self)
Exemplo n.º 8
0
 def scrollPage(self, degrees=180, afterScroll=None):
     # do 180 degree scroll down
     event = QWheelEvent(QCursor.pos(), -1 * (degrees / 15) * 120,
                         Qt.MouseButtons(), Qt.KeyboardModifiers(),
                         Qt.Vertical)
     QCoreApplication.postEvent(self, event)
     if afterScroll:
         afterScroll(self)
Exemplo n.º 9
0
 def pan(self, pan, absolute=False):
     if absolute:
         self.ctrlat = pan[0]
         self.ctrlon = pan[1]
     else:
         self.ctrlat += pan[0]
         self.ctrlon += pan[1]
     qapp.postEvent(qapp.instance(), PanZoomEvent(pan=pan, absolute=absolute))
Exemplo n.º 10
0
def down(x, y):
    event = QMouseEvent(
        QEvent.MouseButtonPress,
        QPoint(x, y),
        QPoint(x, y),
        Qt.LeftButton,
        Qt.LeftButton,
        Qt.NoModifier
    )
    QCoreApplication.postEvent(desktop, event)
Exemplo n.º 11
0
def up(x, y):
    event = QMouseEvent(
        QEvent.MouseButtonRelease,
        QPoint(x, y),
        QPoint(x, y),
        Qt.LeftButton,
        Qt.LeftButton,
        Qt.NoModifier
    )
    QCoreApplication.postEvent(desktop, event)
Exemplo n.º 12
0
    def _stateChanged(self, future, state):
        """
        The `future` state has changed (called by :class:`Future`).
        """
        ev = StateChangedEvent(state)

        if self.thread() is QThread.currentThread():
            QCoreApplication.sendEvent(self, ev)
        else:
            QCoreApplication.postEvent(self, ev)
Exemplo n.º 13
0
 def update(self):
     painter = QPainter(self)#CApplication.getTelaPrincipal())
     painter.translate(self.getPos())
     self.paint(painter)
     painter.end()
     
     if not CApplication.updateRequested():
         CApplication.setUpdateRequested(True)
         QCoreApplication.postEvent(CApplication.getInstance(), EventoUpdateConsole(EventoUpdateConsole.UpdateRequest))
         return
Exemplo n.º 14
0
    def _stateChanged(self, future, state):
        """
        The `future` state has changed (called by :class:`Future`).
        """
        ev = StateChangedEvent(state)

        if self.thread() is QThread.currentThread():
            QCoreApplication.sendEvent(self, ev)
        else:
            QCoreApplication.postEvent(self, ev)
Exemplo n.º 15
0
    def end(self):
        self.down_pos = None
        self.arrow_item = None
        self.annotation = None
        self.document.view().setCursor(Qt.ArrowCursor)

        # Clear the help tip
        helpevent = QuickHelpTipEvent("", "")
        QCoreApplication.postEvent(self.document, helpevent)

        UserInteraction.end(self)
Exemplo n.º 16
0
    def end(self):
        self.down_pos = None
        self.arrow_item = None
        self.annotation = None
        self.document.view().setCursor(Qt.ArrowCursor)

        # Clear the help tip
        helpevent = QuickHelpTipEvent("", "")
        QCoreApplication.postEvent(self.document, helpevent)

        UserInteraction.end(self)
Exemplo n.º 17
0
 def send_aircraft_data(self):
     data = ACDataEvent()
     data.id = list(self.sim.traf.id)
     data.lat = np.array(self.sim.traf.lat, dtype=np.float32, copy=True)
     data.lon = np.array(self.sim.traf.lon, dtype=np.float32, copy=True)
     data.alt = np.array(self.sim.traf.alt, dtype=np.float32, copy=True)
     data.tas = np.array(self.sim.traf.tas, dtype=np.float32, copy=True)
     data.iconf = np.array(self.sim.traf.iconf, copy=True)
     data.confcpalat = np.array(self.sim.traf.dbconf.latowncpa, copy=True)
     data.confcpalon = np.array(self.sim.traf.dbconf.lonowncpa, copy=True)
     data.trk = np.array(self.sim.traf.trk, dtype=np.float32, copy=True)
     qapp.postEvent(qapp.instance(), data)
Exemplo n.º 18
0
 def showroute(self, acid):
     data = RouteDataEvent()
     data.acidx = self.sim.traf.id2idx(acid)
     if data.acidx >= 0:
         route = self.sim.traf.route[data.acidx]
         n_segments = len(route.wplat) + 1
         data.lat = np.empty(n_segments, dtype=np.float32)
         data.lat[0] = self.sim.traf.lat[data.acidx]
         data.lat[1:] = route.wplat
         data.lon = np.empty(n_segments, dtype=np.float32)
         data.lon[0] = self.sim.traf.lon[data.acidx]
         data.lon[1:] = route.wplon
     qapp.postEvent(qapp.instance(), data)
Exemplo n.º 19
0
 def delay_method_call(self, *args, **kwargs):
     if self.thread() != QThread.currentThread():
         semaphore = QSemaphore()
     else:
         semaphore = None
     event = QueuedCallEvent(method, (self, ) + args, kwargs, semaphore)
     QCoreApplication.postEvent(self, event)
     if semaphore is None:
         QCoreApplication.sendPostedEvents()
     else:
         # Wait until the other thread's event loop processes the event
         semaphore.acquire()
     return event.result()
Exemplo n.º 20
0
 def delay_method_call(self, *args, **kwargs):
     if self.thread() != QThread.currentThread():
         semaphore = QSemaphore()
     else:
         semaphore = None
     event = QueuedCallEvent(method, (self,) + args, kwargs, semaphore)
     QCoreApplication.postEvent(self, event)
     if semaphore is None:
         QCoreApplication.sendPostedEvents()
     else:
         # Wait until the other thread's event loop processes the event
         semaphore.acquire()
     return event.result()
Exemplo n.º 21
0
    def start(self):
        self.document.view().setCursor(Qt.CrossCursor)

        helpevent = QuickHelpTipEvent(
            self.tr("Click and drag to create a new arrow"),
            self.
            tr('<h3>New arrow annotation</h3>'
               '<p>Click and drag to create a new arrow annotation</p>'
               #                    '<a href="help://orange-canvas/arrow-annotations>'
               #                    'More ...</a>'
               ))
        QCoreApplication.postEvent(self.document, helpevent)

        UserInteraction.start(self)
Exemplo n.º 22
0
    def start(self):
        self.document.view().setCursor(Qt.CrossCursor)

        helpevent = QuickHelpTipEvent(
            self.tr("Click and drag to create a new arrow"),
            self.tr('<h3>New arrow annotation</h3>'
                    '<p>Click and drag to create a new arrow annotation</p>'
#                    '<a href="help://orange-canvas/arrow-annotations>'
#                    'More ...</a>'
                    )
        )
        QCoreApplication.postEvent(self.document, helpevent)

        UserInteraction.start(self)
Exemplo n.º 23
0
 def send_siminfo(self):
     t = time.time()
     dt = t - self.prevtime
     qapp.postEvent(
         qapp.instance(),
         SimInfoEvent(
             (self.sim.samplecount - self.prevcount) / dt,
             self.sim.simdt,
             self.sim.simt,
             self.sim.traf.ntraf,
             self.sim.mode,
         ),
     )
     self.prevtime = t
     self.prevcount = self.sim.samplecount
Exemplo n.º 24
0
    def start(self):
        self.document.view().setCursor(Qt.CrossCursor)

        helpevent = QuickHelpTipEvent(
            self.tr("Click to create a new text annotation"),
            self.tr('<h3>New text annotation</h3>'
                    '<p>Click (and drag to resize) on the canvas to create '
                    'a new text annotation item.</p>'
#                    '<a href="help://orange-canvas/text-annotations">'
#                    'More ...</a>'
                    )
        )
        QCoreApplication.postEvent(self.document, helpevent)

        UserInteraction.start(self)
Exemplo n.º 25
0
    def end(self):
        if self.control is not None:
            self.scene.removeItem(self.control)

        self.control = None
        self.down_pos = None
        self.annotation_item = None
        self.annotation = None
        self.document.view().setCursor(Qt.ArrowCursor)

        # Clear the help tip
        helpevent = QuickHelpTipEvent("", "")
        QCoreApplication.postEvent(self.document, helpevent)

        UserInteraction.end(self)
Exemplo n.º 26
0
    def end(self):
        if self.control is not None:
            self.scene.removeItem(self.control)

        self.control = None
        self.down_pos = None
        self.annotation_item = None
        self.annotation = None
        self.document.view().setCursor(Qt.ArrowCursor)

        # Clear the help tip
        helpevent = QuickHelpTipEvent("", "")
        QCoreApplication.postEvent(self.document, helpevent)

        UserInteraction.end(self)
Exemplo n.º 27
0
    def start(self):
        self.document.view().setCursor(Qt.CrossCursor)

        helpevent = QuickHelpTipEvent(
            self.tr("Click to create a new text annotation"),
            self.
            tr('<h3>New text annotation</h3>'
               '<p>Click (and drag to resize) on the canvas to create '
               'a new text annotation item.</p>'
               #                    '<a href="help://orange-canvas/text-annotations">'
               #                    'More ...</a>'
               ))
        QCoreApplication.postEvent(self.document, helpevent)

        UserInteraction.start(self)
Exemplo n.º 28
0
    def objappend(self, objtype, objname, data_in):
        if data_in is None:
            # This is an object delete event
            data = None
        elif objtype == 1 or objtype == 4:
            # LINE(1) or POLY(4)
            data = np.array(data_in, dtype=np.float32)
        elif objtype == 2:
            # BOX
            data = np.array(
                [data_in[0], data_in[1], data_in[0], data_in[3], data_in[2], data_in[3], data_in[2], data_in[1]],
                dtype=np.float32,
            )

        elif objtype == 3:
            # CIRCLE
            pass

        qapp.postEvent(qapp.instance(), DisplayShapeEvent(objname, data))
Exemplo n.º 29
0
    def keyPressEvent(self, event):
        if self.autocomplete.active:
            if self.autocomplete.keyPressEvent(event):
                return
        elif self.calltip.active:
            if self.calltip.keyPressEvent(event):
                return

        m = event.modifiers()
        k = event.key()
        t = event.text()
        # Disable some shortcuts 
        if self.disable_shortcuts and \
                m & Qt.ControlModifier and k in [Qt.Key_A, Qt.Key_R,
                                                 Qt.Key_C, Qt.Key_K,
                                                 Qt.Key_X, Qt.Key_V,
                                                 Qt.Key_Y, Qt.Key_Z]:
            new_ev = QKeyEvent(event.type(), k, m, t)
            event.ignore()
            QCoreApplication.postEvent(self.parent(), new_ev)
            return
        elif k == Qt.Key_Tab:
            if self.tab_pressed():
                return
        elif k == Qt.Key_Backtab:
            if self.backtab_pressed():
                return
        elif k == Qt.Key_Backspace:
            if self.backspace_pressed():
                return
        elif k == Qt.Key_Period or \
              (k == Qt.Key_Space and event.modifiers() == Qt.ControlModifier):
            QPlainTextEdit.keyPressEvent(self, event)
            self.autocomplete_pressed()
            return
        elif k in [Qt.Key_ParenLeft, Qt.Key_BraceLeft, Qt.Key_BracketLeft]:
            QPlainTextEdit.keyPressEvent(self, event)
            self.paren_opened(k)
            return
        QPlainTextEdit.keyPressEvent(self, event)
        if k == Qt.Key_Return or k == Qt.Key_Enter:
            self.after_return_pressed()
Exemplo n.º 30
0
    def keyPressEvent(self, event):
        if self.autocomplete.active:
            if self.autocomplete.keyPressEvent(event):
                return
        elif self.calltip.active:
            if self.calltip.keyPressEvent(event):
                return

        m = event.modifiers()
        k = event.key()
        t = event.text()
        # Disable some shortcuts 
        if self.disable_shortcuts and \
                m & Qt.ControlModifier and k in [Qt.Key_A, Qt.Key_R,
                                                 Qt.Key_C, Qt.Key_K,
                                                 Qt.Key_X, Qt.Key_V,
                                                 Qt.Key_Y, Qt.Key_Z]:
            new_ev = QKeyEvent(event.type(), k, m, t)
            event.ignore()
            QCoreApplication.postEvent(self.parent(), new_ev)
            return
        elif k == Qt.Key_Tab:
            if self.tab_pressed():
                return
        elif k == Qt.Key_Backtab:
            if self.backtab_pressed():
                return
        elif k == Qt.Key_Backspace:
            if self.backspace_pressed():
                return
        elif k == Qt.Key_Period or \
              (k == Qt.Key_Space and event.modifiers() == Qt.ControlModifier):
            QPlainTextEdit.keyPressEvent(self, event)
            self.autocomplete_pressed()
            return
        elif k in [Qt.Key_ParenLeft, Qt.Key_BraceLeft, Qt.Key_BracketLeft]:
            QPlainTextEdit.keyPressEvent(self, event)
            self.paren_opened(k)
            return
        QPlainTextEdit.keyPressEvent(self, event)
        if k == Qt.Key_Return or k == Qt.Key_Enter:
            self.after_return_pressed()
Exemplo n.º 31
0
 def shutdown_request():
     QCoreApplication.postEvent(mainwindow, QEvent(Updater.QUIT_EVENT_TYPE))
Exemplo n.º 32
0
 def nextImage(self):
     QCoreApplication.postEvent(self.parent, NextImageGrowthEvent())
Exemplo n.º 33
0
 def abort(self):
     QCoreApplication.postEvent(self.parent, AbortImageGrowthEvent())
Exemplo n.º 34
0
 def __on_anchorClicked(self, anchor):
     ev = QuickHelpDetailRequestEvent(anchor.toString(), anchor)
     QCoreApplication.postEvent(self, ev)
Exemplo n.º 35
0
 def _update(self):
     """
     Schedule processing at a later time.
     """
     QCoreApplication.postEvent(self, QEvent(QEvent.UpdateRequest))
Exemplo n.º 36
0
 def shutdown_request():
     QCoreApplication.postEvent(mainwindow, QEvent(Updater.QUIT_EVENT_TYPE))
Exemplo n.º 37
0
def to_main(func, *args, **kwargs):
    QCoreApplication.postEvent(QCoreApplication.instance(),
                               ProxyToMainEvent(func, *args, **kwargs))
Exemplo n.º 38
0
 def abort(self, reason, **others):
     e = AbortPlottingEvent(reason)
     if others:
         e.others = others
     QCoreApplication.postEvent(self.parent, e)
Exemplo n.º 39
0
 def update_nb_images(self, nb):
     QCoreApplication.postEvent(self.parent, UpdateNbImageEvent(nb))
Exemplo n.º 40
0
 def image_ready(self):
     QCoreApplication.postEvent(self.parent, ImageReadyPlottingEvent())
Exemplo n.º 41
0
 def update_nb_images(self, nb):
     QCoreApplication.postEvent(self.parent, UpdateNbImageEvent(nb))
Exemplo n.º 42
0
 def image_ready(self):
     QCoreApplication.postEvent(self.parent, ImageReadyPlottingEvent())
Exemplo n.º 43
0
 def finished(self):
     if self.loading:
         QCoreApplication.postEvent(self.parent, FinishLoadingEvent())
         self.loading = False
     else:
         QCoreApplication.postEvent(self.parent, FinishPlottingEvent())
Exemplo n.º 44
0
 def finished(self):
     if self.loading:
         QCoreApplication.postEvent(self.parent, FinishLoadingEvent())
         self.loading = False
     else:
         QCoreApplication.postEvent(self.parent, FinishPlottingEvent())
Exemplo n.º 45
0
 def delay_method_call(self, *args, **kwargs):
     event = QueuedCallEvent(method.__get__(self), args, kwargs)
     QCoreApplication.postEvent(self, event)
Exemplo n.º 46
0
 def _update(self):
     """
     Schedule processing at a later time.
     """
     QCoreApplication.postEvent(self, QEvent(QEvent.UpdateRequest))
Exemplo n.º 47
0
 def delay_method_call(self, *args, **kwargs):
     event = QueuedCallEvent(method, (self, ) + args, kwargs)
     QCoreApplication.postEvent(self, event)
     QCoreApplication.sendPostedEvents()
     return event.result()
Exemplo n.º 48
0
 def start(self):
     QCoreApplication.postEvent(self, ExecuteCallEvent())
Exemplo n.º 49
0
 def start(self):
     QCoreApplication.postEvent(self, ExecuteCallEvent())
Exemplo n.º 50
0
 def delay_method_call(self, *args, **kwargs):
     event = QueuedCallEvent(method.__get__(self), args, kwargs)
     QCoreApplication.postEvent(self, event)
Exemplo n.º 51
0
 def schedule_later():
     QCoreApplication.postEvent(self, event,
                                Qt.LowEventPriority - 10)
Exemplo n.º 52
0
 def nextImage(self):
     QCoreApplication.postEvent(self.parent, NextImageEvent())
Exemplo n.º 53
0
 def finished(self):
     QCoreApplication.postEvent(self.parent, FinishImageGrowthEvent())
Exemplo n.º 54
0
 def schedule_later():
     QCoreApplication.postEvent(
         self, event, Qt.LowEventPriority - 10)
Exemplo n.º 55
0
 def abort(self, reason, **others):
     e = AbortPlottingEvent(reason)
     if others:
         e.others = others
     QCoreApplication.postEvent(self.parent, e)