How to use the uwsift.common.Flags function in uwsift

To help you get started, we’ve selected a few uwsift examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github ssec / sift / uwsift / model / document.py View on Github external
for prod in que.all():
                    frm = self.frame_info_for_product(prod, when_overlaps=when)
                    if frm is not None:
                        frames.append(frm)
                if not frames:
                    LOG.warning("track {} with no frames - skipping (missing files or resources?)".format(track))
                    continue
                LOG.debug("found {} frames for track {}".format(len(frames), track))
                frames.sort(key=lambda x: x.when.s)
                track_span = Span.from_s_e(frames[0].when.s, frames[-1].when.e) if frames else None
                trk = TrackInfo(
                    track=track,
                    presentation=self.doc.family_presentation.get(track),
                    when=track_span,
                    frames=frames,
                    state=Flags(),  # FIXME
                    primary=' '.join(reversed(fam.split(FCS_SEP))),  # fam_nfo[Info.DISPLAY_FAMILY],
                    secondary=' '.join(reversed(ctg.split(FCS_SEP)))
                )
                yield z, trk
github ssec / sift / uwsift / workspace / workspace.py View on Github external
def product_state(self, uuid: UUID) -> Flags:
        state = Flags(self._state[uuid])
        # add any derived information
        if uuid in self._available:
            state.add(State.ATTACHED)
        with self._inventory as s:
            ncontent = s.query(Content).filter_by(uuid=uuid).count()
        if ncontent > 0:
            state.add(State.CACHED)
        return state
github ssec / sift / uwsift / model / document.py View on Github external
write_cmap_dir = os.path.join(cmap_base_dir, 'user')  # writeable
        self.read_cmap_dir = read_cmap_dir
        self.write_cmap_dir = write_cmap_dir
        importable_cmap_cats = [
            (True, SITE_CATEGORY, read_cmap_dir),
            (False, USER_CATEGORY, write_cmap_dir)
        ]
        for read_only, cmap_cat, cmap_dir in importable_cmap_cats:
            if not os.path.exists(cmap_dir):
                os.makedirs(cmap_dir)
            else:
                self.colormaps.import_colormaps(cmap_dir, read_only=read_only, category=cmap_cat)

        # timeline document storage setup with initial track order and time range
        self.product_state = defaultdict(Flags)
        self.track_state = defaultdict(Flags)
        self.track_order = ZList()
        self.track_frame_locks = {}
        self.family_calculation = {}
        self.family_composition = {}
        self.family_presentation = {}

        # scan available metadata for initial state
        # FIXME: refresh this once background scan finishes and new products are found
        # self.timeline_span = self.playback_span = self.potential_product_span()
        self.sync_potential_tracks_from_metadata()
github ssec / sift / uwsift / control / doc_ws_as_timeline_scene.py View on Github external
def _translate_to_visual_state(s: Flags) -> Flags:
    f = Flags()
    for x in s:
        f.update(DOC_STATE_TO_VISUAL_STATE.get(x) or set())
    return f
github ssec / sift / uwsift / view / timeline / scene.py View on Github external
from uuid import uuid1 as uuidgen
        once = datetime.utcnow()

        def minutes_td(minutes):
            return timedelta(minutes=minutes)
        # assert(hasattr(self, '_track_order'))
        self._span = Span(once - minutes_td(10), minutes_td(30))
        track0 = QTrackItem(self, self.coords, 'IMAGE:test::timeline:GOES-21:QBI:mars', 1,
                            "G21 QBI B99 BT", "test track", tooltip="peremptorily cromulent")
        # scene.addItem(abitrack)  # done in init
        frame01 = QFrameItem(track0, self.coords, uuidgen(), once + minutes_td(5), minutes_td(5),
                             Flags([VisualState.BUSY]), "abi1", "fulldiskimus")
        track1 = QTrackItem(self, self.coords, 'IMAGE:test::timeline:Himawari-11:AHI:mars', 0,
                            "H11 AHI B99 Rad", "second test track", tooltip="nominally cromulent")
        frame11 = QFrameItem(track1, self.coords, uuidgen(), once + minutes_td(6), minutes_td(1),
                             Flags([VisualState.READY]), "ahi1", "JP04")
        # self.insert_track(track0)
        # self.insert_track(track1)
        # assert(hasattr(self, '_propagate_max_z'))
        self.propagate_max_z()
        for track in [track0, track1]:
            track.update_pos_bounds()
            track.update_frame_positions()
        # scene.addItem(frame1)  # done in init
        # blabla = QGraphicsTextItem('abcdcba')
        # font = QFont('White Rabbit')
        # blabla.setFont(font)
        # blabla.setPos(140, 100)
        # self.addItem(blabla)
        # blabla = None
        self.content = [track0, frame01, track1, frame11]
github ssec / sift / uwsift / view / timeline / items.py View on Github external
tooltip: str = None, state: Flags = None, colormap: [QGradient, QImage] = None,
                 min: float = None, max: float = None):
        """Create a track and connect it to its Scene
        """
        super(QTrackItem, self).__init__()
        self.frames = []
        self._scene = ref(scene) if scene else None
        self._scale = scale
        self._track = track
        self._z = z
        self._title = title
        self._subtitle = subtitle
        self._icon = icon
        self._metadata = metadata or {}
        self._tooltip = tooltip
        self._state = Flags(state or [])
        self._colormap = colormap
        self._min, self._max = min, max
        self.setToolTip(tooltip or "{}\n{}".format(title, subtitle))
        self.setFlag(QGraphicsItem.ItemClipsChildrenToShape, enabled=True)
        self.update_pos_bounds()
        self._update_decorations()
        scene.add_track(self)
        self.setAcceptDrops(True)
github ssec / sift / uwsift / model / document.py View on Github external
def product_state(self, uuid: UUID) -> Flags:
        """Merge document state with workspace state
        """
        s = Flags()
        s.update(self.ws.product_state(uuid))
        # s.update(self.doc.product_state.get(prod.uuid) or Flags())
        return s
github ssec / sift / uwsift / view / timeline / items.py View on Github external
title: str, subtitle: str = None, thumb: QPixmap = None,
                 metadata: Mapping[str, Any] = None):
        """create a frame representation and add it to a timeline track within a scene
        Args:
            track: which timeline to add it to
            state: initial state
            start: frame start time
            duration: frame duration
            title: title of frame
            subtitle: subtitle (below title, optional)
            thumb: thumbnail image (via pillow), optional, may not be displayed if space is not available
            uuid: UUID of workspace representation
        """
        super(QFrameItem, self).__init__()
        self._track = ref(track)
        self._state = Flags(state)
        self._scale = scale
        self._start = start
        self._duration = duration
        self._title = title
        self._subtitle = subtitle
        self._thumb = thumb
        self._metadata = metadata
        self._uuid = uuid
        self.setToolTip("{}\n{}".format(title, subtitle))
        # self._pen, self._brush = track.default_frame_pen_brush
        # if pen:
        #     LOG.debug('setting pen')
        #     self.setPen(pen)
        # if brush:
        #     LOG.debug('setting brush')
        #     self.setBrush(brush)