Exemple #1
0
 def _GenerateMissingSplash(self, app_name):
     image = QtGui.QImage(self.WIDTH, self.HEIGHT, QtGui.QImage.Format_RGB32)
     painter = QtGui.QPainter(image)
     painter.fillRect(image.rect(), QtGui.QBrush(QtGui.QColor(50, 50, 50)))
     font = QtGui.QFont("serif",
                        min((self.WIDTH / len(app_name))*1.4, 250), 75, True)
     painter.setFont(font)
     painter.setPen(QtGui.QColor(80, 80, 80))
     painter.drawText(30, image.height() - 60, app_name)
     return image
Exemple #2
0
    def _paintSelected(self, painter, option, index):
        painter.save()
        try:
            self._drawBackground(painter, option, index)

            # Draw the selection overlay
            self._drawSelectionOverlay(painter, option)

            # Draw the icon, if any
            value = index.data(QtCore.Qt.DecorationRole)
            if value is not None:
                icon = QtGui.QIcon(value)
                icon.paint(painter, option.rect.adjusted(3, 1, -1, -1),
                           QtCore.Qt.AlignLeft)
                option.rect.adjust(22, 0, 0, 0)

            # Draw the text
            painter.setPen(QtGui.QColor(index.data(QtCore.Qt.ForegroundRole)))
            painter.setFont(QtGui.QFont(index.data(QtCore.Qt.FontRole)))
            painter.drawText(
                option.rect.adjusted(3, -1, -3, 0),
                QtCore.Qt.TextAlignmentRole | QtCore.Qt.AlignVCenter,
                str(index.data(QtCore.Qt.DisplayRole)))
        finally:
            painter.restore()
            del painter
    def __paintSelection(self, painter):
        if self.__selectionRange == None: return
        selection = (min(self.__selectionRange[0], self.__selectionRange[1]), max(self.__selectionRange[0], self.__selectionRange[1]))

        leftExtent = self.__getTickArea(selection[0])
        rightExtent = self.__getTickArea(selection[1] - 1)
        selectionExtent = QtCore.QRect(leftExtent.left(), leftExtent.top(), rightExtent.right() - leftExtent.left() + 2, leftExtent.height()/2)
        painter.fillRect(selectionExtent, QtGui.QBrush(QtGui.QColor(75, 75, 75)))
    def __paintFloatTime(self, painter):
        if self.__floatTime == None: return

        timeExtent = self.__getTickArea(self.__floatTime)
        oldPen = painter.pen()
        painter.setPen(QtGui.QColor(90, 90, 90))
        painter.drawLine(timeExtent.left(), timeExtent.top(), timeExtent.left(), timeExtent.bottom())

        if self.__selectionRange:
            painter.setPen(QtGui.QColor(255,255,255))
        else:
            painter.setPen(QtGui.QColor(128, 128, 128))
        metric = QtGui.QFontMetrics(painter.font())
        frameString = str(self.__floatTime)
        xPos = timeExtent.left() - metric.width(frameString) / 2
        yPos =  timeExtent.top() + metric.ascent()
        painter.drawText(xPos, yPos, frameString)
        painter.setPen(oldPen)
    def __paintEndTime(self, painter):
        endFrame = self.endFrame()
        timeExtent = self.__getTickArea(endFrame)
        oldPen = painter.pen()
        painter.setPen(QtGui.QColor(255, 0, 0))
        painter.drawLine(timeExtent.left(), timeExtent.top(), timeExtent.left(), 0)

        metric = QtGui.QFontMetrics(painter.font())
        frameString = str(int(endFrame))
        xPos = timeExtent.left() - metric.width(frameString) / 2
        yPos =  metric.ascent() + 1
        painter.drawText(xPos, yPos, frameString)
        painter.setPen(oldPen)
Exemple #6
0
    def __init__(self, app, app_name, version, resource_path):
        self.app = app

        self.WIDTH = 640
        self.HEIGHT = 346
        self.COLOR_TEXT = QtGui.QColor(180, 180, 180)
        self.MSG_FLAGS = QtCore.Qt.AlignRight | QtCore.Qt.AlignBottom

        image = self._findSplash(app_name, version, resource_path)
        if image:
            pixmap = QtGui.QPixmap.fromImage(image)
            self.splash = QtWidgets.QSplashScreen(pixmap, QtCore.Qt.WindowStaysOnTopHint)
            self.splash.show()
            self.app.processEvents()
Exemple #7
0
    def __init__(self, parent):
        QtWidgets.QWidget.__init__(self, parent)

        self.__color = QtGui.QColor(55, 200, 55)
        self.__brush = QtGui.QBrush()
        self.__brush.setColor(self.__color)
        self.__brush.setStyle(QtCore.Qt.SolidPattern)

        self.__show = opencue.api.findShow("clo")
        self.__history = [0] * 100
        self.__line = 575
        self.__max = max(self.__line * 1.2, 80)

        self.__timer = QtCore.QTimer(self)
        self.__timer.timeout.connect(self.addNumber)

        self.__timer.start(10000)
    def __paintLabels(self, painter):
        tickExtent = self.__getTickAreaExtent()
        labelHeight = tickExtent.height() / 3
        labelPeriod = self.__getLabelPeriod()
        if labelPeriod == 0: return

        firstLabel = self.__frameRange[0] + labelPeriod - 1
        firstLabel = firstLabel - (firstLabel % labelPeriod)

        frames = []
        for frame in range(int(firstLabel), int(self.__frameRange[1])+1, int(labelPeriod)):
            frames.append(frame)
        if frames[0] != self.__frameRange[0]:
            frames.insert(0, self.__frameRange[0])
        if frames[-1] != self.__frameRange[1]:
            frames.append(self.__frameRange[1])

        oldPen = painter.pen()

        # draw hatches for labelled frames
        painter.setPen(self.palette().color(QtGui.QPalette.Foreground))
        for frame in frames:
            xPos = self.__getTickArea(frame).left()
            painter.drawLine(xPos, -labelHeight, xPos, 0)

        painter.setPen(QtGui.QColor(10, 10, 10))

        metric = QtGui.QFontMetrics(painter.font())
        yPos = metric.ascent() + 1
        rightEdge = -10000
        width = metric.width(str(frames[-1]))
        farEdge = self.__getTickArea(frames[-1]).right() - width / 2

        farEdge -= 4

        for frame in frames:
            xPos = self.__getTickArea(frame).left()
            frameString = str(frame)
            width = metric.width(frameString)
            xPos = xPos - width / 2
            if (xPos > rightEdge and xPos + width < farEdge) or frame is frames[-1]:
                painter.drawText(xPos, yPos, frameString)
                rightEdge = xPos + width + 4
        painter.setPen(oldPen)
Exemple #9
0
class AbstractDelegate(QtWidgets.QItemDelegate):
    """Handles drawing of items for the TreeWidget. Provides special handling
    for selected jobs in order to still display background color."""
    __colorInvalid = QtGui.QColor()
    __brushSelected = QtGui.QBrush(QtCore.Qt.Dense4Pattern)
    __colorUsed = QtGui.QColor(255, 0, 0)
    __colorFree = QtGui.QColor(0, 255, 0)

    def __init__(self, parent, jobProgressBarColumn=None, *args):
        QtWidgets.QItemDelegate.__init__(self, parent, *args)

    def paint(self, painter, option, index):
        if option.state & QtWidgets.QStyle.State_Selected:
            # If selected cell
            self._paintSelected(painter, option, index)
        else:
            # Everything else
            QtWidgets.QItemDelegate.paint(self, painter, option, index)

    def _paintDifferenceBar(self, painter, option, index, used, total):
        if not total:
            return
        painter.save()
        try:
            self._drawBackground(painter, option, index)

            rect = option.rect.adjusted(2, 6, -2, -6)
            ratio = rect.width() / float(total)
            length = int(ceil(ratio * (used)))
            painter.fillRect(rect, self.__colorUsed)
            painter.fillRect(rect.adjusted(length, 0, 0, 0), self.__colorFree)

            if option.state & QtWidgets.QStyle.State_Selected:
                self._drawSelectionOverlay(painter, option)
        finally:
            painter.restore()
            del painter

    def _drawProgressBar(self, painter, rect, frameStateTotals):
        """Returns the list that defines the column.
        @type  painter: QPainter
        @param painter: The painter to draw with
        @type  rect: QRect
        @param rect: The area to draw in
        @type  frameStateTotals: dict
        @param frameStateTotals: Dictionary of frame states and their amount"""
        ratio = rect.width() / float(
            sum([list(values)[1] for values in frameStateTotals]))
        for frameState in FRAME_STATES:
            length = int(ceil(ratio * list(frameStateTotals)[frameState][1]))
            if length > 0:
                rect.setWidth(length)
                painter.fillRect(rect, RGB_FRAME_STATE[frameState])
                rect.setX(rect.x() + length)

    def _paintSelected(self, painter, option, index):
        painter.save()
        try:
            self._drawBackground(painter, option, index)

            # Draw the selection overlay
            self._drawSelectionOverlay(painter, option)

            # Draw the icon, if any
            value = index.data(QtCore.Qt.DecorationRole)
            if value is not None:
                icon = QtGui.QIcon(value)
                icon.paint(painter, option.rect.adjusted(3, 1, -1, -1),
                           QtCore.Qt.AlignLeft)
                option.rect.adjust(22, 0, 0, 0)

            # Draw the text
            painter.setPen(QtGui.QColor(index.data(QtCore.Qt.ForegroundRole)))
            painter.setFont(QtGui.QFont(index.data(QtCore.Qt.FontRole)))
            painter.drawText(
                option.rect.adjusted(3, -1, -3, 0),
                QtCore.Qt.TextAlignmentRole | QtCore.Qt.AlignVCenter,
                str(index.data(QtCore.Qt.DisplayRole)))
        finally:
            painter.restore()
            del painter

    def _drawBackground(self, painter, option, index):
        # Draw the background color
        painter.setPen(NO_PEN)
        role = index.data(QtCore.Qt.BackgroundRole)
        if role is not None:
            painter.setBrush(QtGui.QBrush(role))
        else:
            painter.setBrush(NO_BRUSH)
        painter.drawRect(option.rect)

    def _drawSelectionOverlay(self, painter, option):
        # Draw the selection
        if option.rect.width() > 0:
            selectionPen = QtGui.QPen(self.__colorInvalid)
            selectionPen.setWidth(0)
            painter.setPen(selectionPen)
            painter.setBrush(self.__brushSelected)
            painter.drawRect(option.rect)
Exemple #10
0
 def __init__(self, parent, *args):
     AbstractDelegate.__init__(self, parent, *args)
     self.__color = QtGui.QColor(55, 200, 55)
     self.__brush = QtGui.QBrush()
     self.__brush.setColor(self.__color)
     self.__brush.setStyle(QtCore.Qt.SolidPattern)
Exemple #11
0
#
#  Unless required by applicable law or agreed to in writing, software
#  distributed under the License is distributed on an "AS IS" BASIS,
#  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
#  See the License for the specific language governing permissions and
#  limitations under the License.

from math import ceil

import Constants
import Utils

from Manifest import opencue, QtCore, QtGui, QtWidgets

RGB_FRAME_STATE = {
    opencue.api.job_pb2.SUCCEEDED: QtGui.QColor(55, 200, 55),
    opencue.api.job_pb2.RUNNING: QtGui.QColor(200, 200, 55),
    opencue.api.job_pb2.WAITING: QtGui.QColor(135, 207, 235),
    opencue.api.job_pb2.DEPEND: QtGui.QColor(160, 32, 240),
    opencue.api.job_pb2.DEAD: QtGui.QColor(255, 0, 0),
    opencue.api.job_pb2.EATEN: QtGui.QColor(150, 0, 0)
}

# This controls display order
FRAME_STATES = (opencue.api.job_pb2.SUCCEEDED, opencue.api.job_pb2.RUNNING,
                opencue.api.job_pb2.WAITING, opencue.api.job_pb2.DEPEND,
                opencue.api.job_pb2.DEAD, opencue.api.job_pb2.EATEN)

NO_PEN = QtGui.QPen(QtCore.Qt.NoPen)
NO_BRUSH = QtGui.QBrush(QtCore.Qt.NoBrush)
Exemple #12
0
class CueStateBarWidget(QtWidgets.QWidget):
    """Creates a bar that graphically displays the state of all jobs displayed"""
    __colorInvalid = QtGui.QColor()
    __brushPattern = QtGui.QBrush(QtCore.Qt.Dense4Pattern)
    def __init__(self, sourceTree, parent = None):
        """CueStateBar init
        @type  sourceTree: QTreeWidget
        @param sourceTree: The tree to get the jobs from
        @type  parent: QWidget
        @param parent: The parent widget"""
        QtWidgets.QWidget.__init__(self, parent)
        self.setContentsMargins(8, 1, 1, 1)
        self.setFixedWidth(22)

        self.__sourceTree = weakref.proxy(sourceTree)
        self.__colors = []
        self.__baseColor = QtGui.qApp.palette().color(QtGui.QPalette.Base)
        self.__colorsLock = QtCore.QReadWriteLock()
        self.__timer = QtCore.QTimer(self)
        self.__lastUpdate = 0

        self.__timer.timeout.connect(self.updateColors)
        self.__sourceTree.verticalScrollBar().valueChanged.connect(self.update)
        self.__sourceTree.verticalScrollBar().rangeChanged.connect(self.__updateColors)

        self.__timer.start(10000)

    def mousePressEvent(self, mouseEvent):
        """Sets the position on the scroll bar based on the click position
        @type  mouseEvent: QEvent
        @param mouseEvent: The mouse click event"""
        self.__movePosition(mouseEvent.y())

    def mouseMoveEvent(self, mouseEvent):
        """Sets the position on the scroll bar based on the mouse position
        @type  mouseEvent: QEvent
        @param mouseEvent: The mouse click event"""
        self.__movePosition(mouseEvent.y())

    def __movePosition(self, yPos):
        """Sets the position on the scroll bar based on the given position
        @type  yPos: int
        @param yPos: Vertical position on the widget"""
        scrollBar = self.__sourceTree.verticalScrollBar()
        docLength = scrollBar.maximum() + scrollBar.pageStep()
        pos = yPos * docLength/float(self.height())

        scrollBar.setValue(int(pos - scrollBar.pageStep()/2))

    def paintEvent(self, event):
        """Called when the widget is being redrawn
        @type  event: QEvent
        @param event: The draw event"""
        assert threading.currentThread().getName() == "MainThread"
        self.__colorsLock.lockForWrite()
        try:
            if not self.__colors:
                return
            colors = self.__colors
        finally:
            self.__colorsLock.unlock()

        painter = QtGui.QPainter(self)
        painter.save()
        try:
            rect = self.contentsRect()

            # Number of pixels per job
            ratio = float(rect.height())/len(colors)
            # How far down the slider is
            shift = self.__sourceTree.verticalScrollBar().value() * ratio
            # Length not covered by the slider
            offPage = self.__sourceTree.verticalScrollBar().maximum() * ratio

            painter.drawPixmap(self.contentsRect(),
                               self.__background,
                               self.__background.rect())

            # Draw the slider
            pen = QtGui.QPen(self.__colorInvalid)
            pen.setWidth(0)
            painter.setPen(pen)
            painter.setBrush(self.__brushPattern)
            painter.drawRect(rect.adjusted(2, shift, -2, -offPage + shift))
        finally:
            painter.restore()
            painter.end()
            del painter

    def __updateBackgroundPixmap(self, colors):
        """Updates the background image buffer based on the given colors
        @type  colors: list<QBrush>
        @param colors: List of job background colors"""
        # Could draw it the max size and allow the resize on drawPixmap
        # that way the same buffer is always used
        assert threading.currentThread().getName() == "MainThread"
        buffer = QtGui.QPixmap(self.contentsRect().size())
        buffer.fill(self.__baseColor)

        if colors:
            painter = QtGui.QPainter()
            painter.begin(buffer)
            try:
                rect = buffer.rect()

                # Number of jobs
                amount = len(colors)
                # Number of pixels per job
                ratio = float(rect.height())/amount

                for index, color in enumerate(colors):
                    if color:
                        painter.fillRect(rect.adjusted(0,
                                                       ratio * index,
                                                       0,
                                                       -(ratio * (amount - index - 1))),
                                         color)
            finally:
                painter.end()
                del painter

        self.__background = buffer

    def updateColors(self):
        """Calls __updateColors if it has been sufficient time since the last
        update"""
        if time.time() - self.__lastUpdate > 10:
            self.__updateColors()

    def __updateColors(self):
        """Calls __processUpdateColors in 1 second"""
        self.__lastUpdate = time.time()
        QtCore.QTimer.singleShot(1000, self.__processUpdateColors)

    def __processUpdateColors(self):
        """Updates the list of colors to display
        calls __updateBackgroundPixmap to build pixmap
        calls update to redraw"""
        items = self.__sourceTree.findItems("",
                                            QtCore.Qt.MatchContains |
                                            QtCore.Qt.MatchRecursive,
                                            0)

        colors = []
        for item in items:
            color = QtGui.QBrush(item.data(0, QtCore.Qt.BackgroundRole))
            if color.color() == self.__baseColor:
                colors.append(None)
            else:
                colors.append(color)

        self.__colorsLock.lockForWrite()
        try:
            self.__colors = colors
        finally:
            self.__colorsLock.unlock()

        self.__updateBackgroundPixmap(colors)

        self.update()
 def __paintBackground(self, painter):
     bgBrush = self.palette().window()
     painter.fillRect(0, 0, self.width() - self.__right_margin, self.height(), bgBrush)
     highlightBrush = QtGui.QBrush(QtGui.QColor(75, 75, 75))
     painter.fillRect(0, self.height()/2, self.width() - self.__right_margin+5, self.height()/2,  highlightBrush)
Exemple #14
0
def ColorF(r, g, b):
    c = QtGui.QColor()
    c.setRgbF(r, g, b)
    return c
Exemple #15
0
def GreyF(value):
    c = QtGui.QColor()
    c.setRgbF(value, value, value)
    return c
Exemple #16
0
    c = GreyF(0.55)
    p.setColor(QtGui.QPalette.Disabled, p.BrightText, c)

    return p


def GreyF(value):
    c = QtGui.QColor()
    c.setRgbF(value, value, value)
    return c


def ColorF(r, g, b):
    c = QtGui.QColor()
    c.setRgbF(r, g, b)
    return c


COLOR_JOB_PAUSED_BACKGROUND = QtGui.QColor(49, 75, 87)
COLOR_JOB_DYING_BACKGROUND = QtGui.QColor(94, 33, 33)
COLOR_JOB_FINISHED_BACKGROUND = QtGui.QColor(55, 125, 55, 100)
COLOR_JOB_WITHOUT_PROCS = QtGui.QColor(68, 172, 65, 100)
COLOR_JOB_DEPENDED = QtGui.QColor(238, 130, 238, 100)
COLOR_JOB_HIGH_MEMORY = QtGui.QColor(132, 132, 26)

COLOR_GROUP_BACKGROUND = GreyF(0.18)
COLOR_GROUP_FOREGROUND = GreyF(0.79)
COLOR_SHOW_BACKGROUND = GreyF(0.13)
COLOR_SHOW_FOREGROUND = GreyF(0.79)
COLOR_JOB_FOREGROUND = GreyF(0.79)
Exemple #17
0
import datetime
import glob
import re

from opencue.compiled_proto import job_pb2

import eta
from AbstractTreeWidget import *
from AbstractWidgetItem import *
from Manifest import os, QtCore, QtGui, QtWidgets, opencue
from MenuActions import MenuActions

logger = Logger.getLogger(__file__)

QCOLOR_BLACK = QtGui.QColor(QtCore.Qt.black)
QCOLOR_GREEN = QtGui.QColor(QtCore.Qt.green)
STATUS_COLUMN = 3
PROC_COLUMN = 5
CHECKPOINT_COLUMN = 7
RUNTIME_COLUMN = 9
MEMORY_COLUMN = 11
LASTLINE_COLUMN = 15

LOCALRESOURCE = "%s/" % os.getenv("HOST", "unknown").split(".")[0]


class FrameMonitorTree(AbstractTreeWidget):

    job_changed = QtCore.Signal()
    handle_filter_layers_byLayer = QtCore.Signal(list)
Exemple #18
0
EMAIL_BODY_PREFIX = "Your PSTs request that you check "
EMAIL_BODY_SUFFIX = "\n\n"
EMAIL_DOMAIN = ""

URL_USERGUIDE = ""
URL_SUGGESTION = ""
URL_BUG = ""

DEFAULT_EDITOR = "gview -R -m -M -U %s/gvimrc +" % DEFAULT_INI_PATH

EMPTY_INDEX = QtCore.QModelIndex()

QVARIANT_CENTER = QtCore.Qt.AlignCenter
QVARIANT_RIGHT = QtCore.Qt.AlignRight
QVARIANT_NULL = None
QVARIANT_BLACK = QtGui.QColor(QtCore.Qt.black)
QVARIANT_GREY = QtGui.QColor(QtCore.Qt.gray)

ALLOWED_TAGS = ("general", "desktop", "playblast", "util", "preprocess", "wan",
                "cuda", "splathw", 'naiad', 'massive')

RGB_FRAME_STATE = {
    opencue.api.job_pb2.DEAD: QtGui.QColor(255, 0, 0),
    opencue.api.job_pb2.DEPEND: QtGui.QColor(160, 32, 240),
    opencue.api.job_pb2.EATEN: QtGui.QColor(150, 0, 0),
    opencue.api.job_pb2.RUNNING: QtGui.QColor(200, 200, 55),
    opencue.api.job_pb2.SETUP: QtGui.QColor(160, 32, 240),
    opencue.api.job_pb2.SUCCEEDED: QtGui.QColor(55, 200, 55),
    opencue.api.job_pb2.WAITING: QtGui.QColor(135, 207, 235),
    opencue.api.job_pb2.CHECKPOINT: QtGui.QColor(61, 98, 247)
}