Esempio n. 1
0
    def correct_wcs(self):
        # small local function to strip comment and blank lines
        def _flt(line):
            line = line.strip()
            if line.startswith('#'):
                return False
            if len(line) == 0:
                return False
            return True

        # extract image and reference coords from text widgets
        txt1 = self.w.report.get_text()
        lines1 = filter(_flt, txt1.split('\n'))
        txt2 = self.w.correct.get_text()
        lines2 = filter(_flt, txt2.split('\n'))
        assert len(lines1) == len(lines2), \
               Exception("Number of lines don't match in reports")

        img_coords = list(map(lambda l: map(float, l.split(',')[3:5]), lines1))
        #print "img coords:", img_coords
        ref_coords = list(map(lambda l: map(float, l.split(',')[0:2]), lines2))
        #print "ref coords:", ref_coords

        image = self.fitsimage.get_image()
        self.fv.nongui_do(self._calc_match, image, img_coords, ref_coords)
Esempio n. 2
0
    def correct_wcs(self):
        # small local function to strip comment and blank lines
        def _flt(line):
            line = line.strip()
            if line.startswith('#'):
                return False
            if len(line) == 0:
                return False
            return True

        # extract image and reference coords from text widgets
        txt1 = self.w.report.get_text()
        lines1 = filter(_flt, txt1.split('\n'))
        txt2 = self.w.correct.get_text()
        lines2 = filter(_flt, txt2.split('\n'))
        assert len(lines1) == len(lines2), \
               Exception("Number of lines don't match in reports")

        img_coords = list(map(lambda l: map(float, l.split(',')[3:5]), lines1))
        #print "img coords:", img_coords
        ref_coords = list(map(lambda l: map(float, l.split(',')[0:2]), lines2))
        #print "ref coords:", ref_coords

        image = self.fitsimage.get_image()
        self.fv.nongui_do(self._calc_match, image, img_coords, ref_coords)
Esempio n. 3
0
    def set_focus(self, name):
        self.logger.debug("Focusing plugin '%s'" % (name))
        lname = name.lower()
        bnch = self.active[lname]
        if bnch.exclusive:
            self.logger.debug("focus=%s exclusive=%s" % (
                self.focus, self.exclusive))
            defocus = list(filter(lambda x: x in self.exclusive, self.focus))
            self.logger.debug("defocus: %s" % (str(defocus)))
            for xname in defocus:
                self.clear_focus(xname)

        pInfo = bnch.pInfo
        # If this is a local plugin, raise the channel associated with the
        # plug in
        if pInfo.chinfo is not None:
            itab = pInfo.chinfo.name
            self.logger.debug("raising tab %s" % (itab))
            self.ds.raise_tab(itab)

            self.logger.debug("resuming plugin %s" % (name))
            pInfo.obj.resume()
            self.highlight_taskbar(bnch)
            # TODO: Need to account for the fact that not all plugins
            # end up in the workspace "Dialogs"
            self.ds.raise_tab('Dialogs')

        self.focus.add(lname)
        if pInfo.widget is not None:
            self.logger.debug("raising tab %s" % (pInfo.tabname))
            self.ds.raise_tab(pInfo.tabname)
Esempio n. 4
0
    def set_focus(self, name):
        self.logger.debug("Focusing plugin '%s'" % (name))
        lname = name.lower()
        bnch = self.active[lname]
        if bnch.exclusive:
            self.logger.debug("focus=%s exclusive=%s" % (
                self.focus, self.exclusive))
            defocus = list(filter(lambda x: x in self.exclusive, self.focus))
            self.logger.debug("defocus: %s" % (str(defocus)))
            for xname in defocus:
                self.clear_focus(xname)

        pInfo = bnch.pInfo
        # If this is a local plugin, raise the channel associated with the
        # plug in
        if pInfo.chinfo is not None:
            itab = pInfo.chinfo.name
            self.logger.debug("raising channel tab %s" % (itab))
            self.ds.raise_tab(itab)

            self.logger.debug("resuming plugin %s" % (name))
            pInfo.obj.resume()
            self.make_callback('focus-plugin', bnch)

        self.focus.add(lname)
        if pInfo.widget is not None:
            self.logger.debug("raising plugin tab %s" % (pInfo.tabname))
            if pInfo.is_toplevel:
                pInfo.widget.raise_()
            else:
                self.ds.raise_tab(pInfo.tabname)
Esempio n. 5
0
    def _do_pick(self, canvas, event, data_x, data_y, ptype, viewer):
        # check for objects at this location
        objs = canvas.select_items_at(viewer, (data_x, data_y))

        picked = set(filter(lambda obj: obj.pickable, objs))

        newly_out = self._pick_cur_objs - picked
        newly_in = picked - self._pick_cur_objs
        self._pick_cur_objs = picked

        if ptype not in ('move', 'up'):
            self._pick_sel_objs = picked

        # leaving an object
        for obj in newly_out:
            pt = obj.crdmap.data_to((data_x, data_y))
            obj.make_callback('pick-leave', canvas, event, pt)

        # entering an object
        for obj in newly_in:
            pt = obj.crdmap.data_to((data_x, data_y))
            obj.make_callback('pick-enter', canvas, event, pt)

        # pick down/up
        res = False
        for obj in self._pick_sel_objs:
            cb_name = 'pick-%s' % (ptype)
            self.logger.debug("%s event in %s obj at x, y = %d, %d" %
                              (cb_name, obj.kind, data_x, data_y))

            pt = obj.crdmap.data_to((data_x, data_y))
            if obj.make_callback(cb_name, canvas, event, pt):
                res = True

        return res
Esempio n. 6
0
    def _do_pick(self, canvas, event, data_x, data_y, cb_name, viewer):
        # check for objects at this location
        objs = canvas.select_items_at(viewer, (data_x, data_y))

        picked = set(filter(lambda obj: obj.pickable, objs))

        newly_out = self._pick_cur_objs - picked
        newly_in = picked - self._pick_cur_objs
        self._pick_cur_objs = picked

        # leaving an object
        for obj in newly_out:
            pt = obj.crdmap.data_to((data_x, data_y))
            obj.make_callback('pick-leave', canvas, event, pt)

        # entering an object
        for obj in newly_in:
            pt = obj.crdmap.data_to((data_x, data_y))
            obj.make_callback('pick-enter', canvas, event, pt)

        # pick down/up
        for obj in picked:
            self.logger.debug("%s event in %s obj at x, y = %d, %d" %
                              (cb_name, obj.kind, data_x, data_y))

            pt = obj.crdmap.data_to((data_x, data_y))
            obj.make_callback(cb_name, canvas, event, pt)

        return True
Esempio n. 7
0
    def set_focus(self, name):
        self.logger.debug("Focusing plugin '%s'" % (name))
        lname = name.lower()
        bnch = self.active[lname]
        if bnch.exclusive:
            self.logger.debug("focus=%s exclusive=%s" %
                              (self.focus, self.exclusive))
            defocus = list(filter(lambda x: x in self.exclusive, self.focus))
            self.logger.debug("defocus: %s" % (str(defocus)))
            for xname in defocus:
                self.clear_focus(xname)

        pInfo = bnch.pInfo
        # If this is a local plugin, raise the channel associated with the
        # plug in
        if pInfo.chinfo != None:
            itab = pInfo.chinfo.name
            self.logger.debug("raising tab %s" % (itab))
            self.ds.raise_tab(itab)

            self.logger.debug("resuming plugin %s" % (name))
            pInfo.obj.resume()
            self.highlight_taskbar(bnch)
            # TODO: Need to account for the fact that not all plugins
            # end up in the workspace "Dialogs"
            self.ds.raise_tab('Dialogs')

        self.focus.add(lname)
        if pInfo.widget != None:
            self.logger.debug("raising tab %s" % (pInfo.tabname))
            self.ds.raise_tab(pInfo.tabname)
Esempio n. 8
0
    def update_pending(self, timeout=0.0, elapsed_max=0.02):

        self.assert_gui_thread()

        # Process "out-of-band" events
        # self.logger.debug("1. processing out-of-band GUI events")
        try:
            self.app.process_events()

        except Exception as e:
            self.logger.error(str(e))

        # Process "in-band" GUI events
        # self.logger.debug("2. processing approx %d in-band GUI events" % (
        #                    self.gui_queue.qsize()))
        done = False
        time_start = time.time()
        while not done:
            try:
                future = self.gui_queue.get(block=True,
                                            timeout=timeout)
                self._execute_future(future)

            except Queue.Empty:
                done = True

            if time.time() - time_start > elapsed_max:
                done = True

        # Execute all the one-shots
        # self.logger.debug("3. processing one-shot GUI events")
        deqs = list(filter(lambda deq: len(deq) > 0, self.oneshots.values()))
        for deq in deqs:
            try:
                future = deq.pop()

                self._execute_future(future)

            except IndexError:
                continue

        # Process "out-of-band" events, again
        # self.logger.debug("4. processing out-of-band GUI events")
        try:
            self.app.process_events()

        except Exception as e:
            self.logger.error(str(e))
Esempio n. 9
0
    def set_focus(self, name):
        self.logger.debug("Focusing plugin '%s'" % (name))
        lname = name.lower()
        bnch = self.active[lname]
        if bnch.exclusive:
            self.logger.debug("focus=%s exclusive=%s" % (
                self.focus, self.exclusive))
            defocus = list(filter(lambda x: x in self.exclusive, self.focus))
            self.logger.debug("defocus: %s" % (str(defocus)))
            for xname in defocus:
                self.clear_focus(xname)

        p_info = bnch.pInfo
        # If this is a local plugin, raise the channel associated with the
        # plug in
        if p_info.chinfo is not None:
            self.logger.debug("resuming plugin %s" % (name))
            p_info.obj.resume()

        self.focus.add(lname)
        self.make_callback('focus-plugin', bnch)

        if p_info.widget is not None:
            self.logger.debug("raising plugin tab %s" % (p_info.tabname))
            if p_info.is_toplevel:
                p_info.widget.raise_()
            else:
                self.ds.raise_tab(p_info.tabname)

        if p_info.chinfo is not None:
            chname = p_info.chinfo.name
            self.logger.debug("changing channel to %s" % (chname))
            # Alternative could just be to raise the channel tab rather
            # than making all the global plugins switch over to the new
            # channel
            #self.ds.raise_tab(chname)
            self.fv.change_channel(chname)
Esempio n. 10
0
 def getTagsByTagpfx(self, tagpfx):
     res = []
     keys = filter(lambda k: k.startswith(tagpfx), self.tags.keys())
     return keys
Esempio n. 11
0
 def get_tags_by_tag_pfx(self, tagpfx):
     res = []
     keys = filter(lambda k: k.startswith(tagpfx), self.tags.keys())
     return keys
Esempio n. 12
0
 def get_objects_by_kinds(self, kinds):
     return filter(lambda obj: obj.kind in kinds, self.objects)
Esempio n. 13
0
 def get_objects_by_kind(self, kind):
     return filter(lambda obj: obj.kind == kind, self.objects)
Esempio n. 14
0
 def get_objects_by_kinds(self, kinds):
     return filter(lambda obj: obj.kind in kinds, self.objects)
Esempio n. 15
0
 def get_objects_by_kind(self, kind):
     return filter(lambda obj: obj.kind == kind, self.objects)
Esempio n. 16
0
    def update_pending(self, timeout=0.0, elapsed_max=0.02):

        self.assert_gui_thread()

        # Process "out-of-band" events
        # self.logger.debug("1. processing out-of-band GUI events")
        try:
            self.app.process_events()

        except Exception as e:
            self.logger.error(str(e))

        # Process "in-band" GUI events
        # self.logger.debug("2. processing approx %d in-band GUI events" % (
        #                    self.gui_queue.qsize()))
        done = False
        time_start = time.time()

        # First process priority futures
        while not done:
            try:
                future = self.priority_gui_queue.get(block=False)
                self._execute_future(future)

            except Queue.Empty:
                break

            if time.time() - time_start > elapsed_max:
                done = True

        # Next process non-priority futures
        while not done:
            try:
                future = self.gui_queue.get(block=True, timeout=timeout)
                self._execute_future(future)

            except Queue.Empty:
                done = True

            if time.time() - time_start > elapsed_max:
                done = True

        # Execute all the one-shots
        # self.logger.debug("3. processing one-shot GUI events")
        deqs = list(filter(lambda deq: len(deq) > 0, self.oneshots.values()))
        for deq in deqs:
            try:
                future = deq.pop()

                self._execute_future(future)

            except IndexError:
                continue

        # Process "out-of-band" events, again
        # self.logger.debug("4. processing out-of-band GUI events")
        try:
            self.app.process_events()

        except Exception as e:
            self.logger.error(str(e))