Пример #1
0
    def layoutRow(self, rect, scale, row):
        # [TODO]
        if len(row) == 0:
            return rect

        if rect.width() > rect.height():
            dir = 'Horizontal'
        else:
            dir = 'Vertical'

        primary = max(rect.width(), rect.height())

        sum = row.sumTotalSizes()
        secondary = int(sum * (1.0 * scale) / primary)

        if sum == 0:  # Prevent division by zero.
            return rect

        if secondary < self._parentView.minTileSize(
        ):  # We don't want tiles that small.
            return rect

        offset = 0
        remaining = primary

        for fileInfo in row:
            childSize = int((1.0 * fileInfo.totalSize()) /
                            (1.0 * sum) * primary + 0.5)
            if childSize > remaining:  # Prevent overflow because of accumulated rounding errors
                childSize = remaining

            remaining -= childSize

            if childSize >= self._parentView.minTileSize():
                if dir == 'Horizontal':
                    childRect = Rect(Point(rect.x() + offset, rect.y()),
                                     Size(childSize, secondary))
                else:
                    childRect = Rect(Point(rect.x(),
                                           rect.y() + offset),
                                     Size(secondary, childSize))

                tile = TreemapTile(self._parentView,
                                   self,
                                   fileInfo,
                                   childRect,
                                   orientation='Auto')
                # What should I do with the tile ?
                offset += childSize

        if (dir == 'Horizontal'):
            newRect = Rect(Point(rect.x(),
                                 rect.y() + secondary),
                           Size(rect.width(),
                                rect.height() - secondary))
        else:
            newRect = Rect(Point(rect.x() + secondary, rect.y()),
                           Size(rect.width() - secondary, rect.height()))

        return newRect
Пример #2
0
    def createChildrenSimple(self, rect, orientation):
        dir = orientation
        childDir = orientation

        if dir == 'Auto':
            if rect.width() > rect.height():
                dir = 'Horizontal'
            else:
                dir = 'Vertical'

        if orientation == 'Horizontal': childDir = 'Vertical'
        if orientation == 'Vertical': childDir = 'Horizontal'

        offset = 0
        size = {'Horizontal': rect.width(), 'Vertical': rect.height()}[dir]
        # count    = 0
        scale = (1.0 * size) / (1.0 * self._orig.totalSize())

        fileInfoList = FileInfoList(self._orig,
                                    minSize=self._parentView.minTileSize() /
                                    scale,
                                    bySize=True,
                                    param='AsSubDir')

        # KFileInfoSortedBySizeIterator it( _orig,
        #                               (KFileSize) ( _parentView->minTileSize() / scale ),
        #                               KDotEntryAsSubDir );

        for fileInfo in fileInfoList:
            childSize = fileInfo.totalSize()
            if childSize >= self._parentView.minTileSize():
                if dir == 'Horizontal':
                    childRect = Rect(point=Point(rect.x() + offset, rect.y()),
                                     size=Size(childSize, rect.height()))
                else:
                    childRect = Rect(point=Point(rect.x(),
                                                 rect.y() + offset),
                                     size=Size(rect.width(), childSize))

                tile = TreemapTile(self._parentView, self, fileInfo, childRect,
                                   childDir)

                offset += childSize
Пример #3
0
    def dump(self, gsize=None):
        if gsize != None:
            self._size = gsize
        if self._size == None:
            self._size = Size(810, 540)
        self._tmv = TreemapView(self._tree, None, self._size)
        size = self._tmv.visibleSize()

        if self.NEEDHANDLE:
            self._file = file(self._filename, 'wt')

        self._start_dump()
        self._tmv.draw(self)
        self._end_dump()

        if self.NEEDHANDLE:
            self._file.close()
Пример #4
0
    def dump(self,gsize=None) :
        if gsize != None :
            self._size = gsize
        if self._size == None :
            self._size = Size(self._configuration.get_value('width'),self._configuration.get_value('height'))
        self._tmv = TreemapView( self._tree, self._size, self._configuration )
        size = self._tmv.visibleSize()

        if self.NEEDHANDLE :
            self._file = file(self._filename,'wt')

        self._start_dump()
        self._tmv.draw(self)
        self._end_dump()

        if self.NEEDHANDLE :
            self._file.close()
Пример #5
0
    def dump(self, gsize=None):
        """This method really start the dump. You should not override it. Override _start_dump, _end_dump or add_rect instead."""
        if gsize != None:
            self._size = gsize
        if self._size == None:
            self._size = Size(self._configuration.get_value('width'),
                              self._configuration.get_value('height'))
        self._treemapview = TreemapView(self._tree, self._size)
        size = self._treemapview.visibleSize()

        if self.NEEDHANDLE:
            self._file = file(self._filename, 'wt')

        self._start_dump()
        self._treemapview.draw(self)
        self._end_dump()

        if self.NEEDHANDLE:
            self._file.close()