Esempio 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
Esempio 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))
Esempio 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))
Esempio 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)
Esempio 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)
Esempio 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
Esempio 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)
Esempio 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)
Esempio 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))
Esempio 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)
Esempio 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)
Esempio 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)
 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
Esempio 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)
Esempio 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)
Esempio 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)
Esempio 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)
Esempio 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)
Esempio 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()
Esempio 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()
Esempio 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)
Esempio 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)
Esempio 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
Esempio 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)
Esempio 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)
Esempio 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)
Esempio 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)
Esempio 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))
Esempio 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()
Esempio 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()
Esempio n. 31
0
 def shutdown_request():
     QCoreApplication.postEvent(mainwindow, QEvent(Updater.QUIT_EVENT_TYPE))
Esempio n. 32
0
 def nextImage(self):
     QCoreApplication.postEvent(self.parent, NextImageGrowthEvent())
Esempio n. 33
0
 def abort(self):
     QCoreApplication.postEvent(self.parent, AbortImageGrowthEvent())
Esempio n. 34
0
 def __on_anchorClicked(self, anchor):
     ev = QuickHelpDetailRequestEvent(anchor.toString(), anchor)
     QCoreApplication.postEvent(self, ev)
Esempio n. 35
0
 def _update(self):
     """
     Schedule processing at a later time.
     """
     QCoreApplication.postEvent(self, QEvent(QEvent.UpdateRequest))
Esempio n. 36
0
 def shutdown_request():
     QCoreApplication.postEvent(mainwindow, QEvent(Updater.QUIT_EVENT_TYPE))
Esempio n. 37
0
def to_main(func, *args, **kwargs):
    QCoreApplication.postEvent(QCoreApplication.instance(),
                               ProxyToMainEvent(func, *args, **kwargs))
Esempio n. 38
0
 def abort(self, reason, **others):
     e = AbortPlottingEvent(reason)
     if others:
         e.others = others
     QCoreApplication.postEvent(self.parent, e)
Esempio n. 39
0
 def update_nb_images(self, nb):
     QCoreApplication.postEvent(self.parent, UpdateNbImageEvent(nb))
Esempio n. 40
0
 def image_ready(self):
     QCoreApplication.postEvent(self.parent, ImageReadyPlottingEvent())
Esempio n. 41
0
 def update_nb_images(self, nb):
     QCoreApplication.postEvent(self.parent, UpdateNbImageEvent(nb))
Esempio n. 42
0
 def image_ready(self):
     QCoreApplication.postEvent(self.parent, ImageReadyPlottingEvent())
Esempio n. 43
0
 def finished(self):
     if self.loading:
         QCoreApplication.postEvent(self.parent, FinishLoadingEvent())
         self.loading = False
     else:
         QCoreApplication.postEvent(self.parent, FinishPlottingEvent())
Esempio n. 44
0
 def finished(self):
     if self.loading:
         QCoreApplication.postEvent(self.parent, FinishLoadingEvent())
         self.loading = False
     else:
         QCoreApplication.postEvent(self.parent, FinishPlottingEvent())
Esempio n. 45
0
 def delay_method_call(self, *args, **kwargs):
     event = QueuedCallEvent(method.__get__(self), args, kwargs)
     QCoreApplication.postEvent(self, event)
Esempio n. 46
0
 def _update(self):
     """
     Schedule processing at a later time.
     """
     QCoreApplication.postEvent(self, QEvent(QEvent.UpdateRequest))
Esempio 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()
Esempio n. 48
0
 def start(self):
     QCoreApplication.postEvent(self, ExecuteCallEvent())
Esempio n. 49
0
 def start(self):
     QCoreApplication.postEvent(self, ExecuteCallEvent())
Esempio n. 50
0
 def delay_method_call(self, *args, **kwargs):
     event = QueuedCallEvent(method.__get__(self), args, kwargs)
     QCoreApplication.postEvent(self, event)
Esempio n. 51
0
 def schedule_later():
     QCoreApplication.postEvent(self, event,
                                Qt.LowEventPriority - 10)
Esempio n. 52
0
 def nextImage(self):
     QCoreApplication.postEvent(self.parent, NextImageEvent())
Esempio n. 53
0
 def finished(self):
     QCoreApplication.postEvent(self.parent, FinishImageGrowthEvent())
Esempio n. 54
0
 def schedule_later():
     QCoreApplication.postEvent(
         self, event, Qt.LowEventPriority - 10)
Esempio n. 55
0
 def abort(self, reason, **others):
     e = AbortPlottingEvent(reason)
     if others:
         e.others = others
     QCoreApplication.postEvent(self.parent, e)