Пример #1
0
    def __init__(self, parent):
        ZoomPanel.__init__(self, parent)

        self._parent = parent
        self._zoom = 100
        self._renderTime = 0.00
        self._rendering = False
        self._viewportImage = utils.ConvertImageToWx(
            Image.new('RGBA', (256, 256)))

        self.Bind(wx.EVT_KEY_DOWN, self.OnKeyEvent)
Пример #2
0
    def Draw(self, dc):
        dc.ClearId(self.GetId())
        dc.SetId(self.GetId())

        thumb = self.GetThumbImage()

        x, y, w, h = self.GetRect()

        # Main body of the node
        dc.SetPen(wx.Pen(wx.Colour(self.GetBorderColor()), 2))
        dc.SetBrush(wx.Brush(wx.Colour(self.GetColor()), wx.SOLID))
        dc.DrawRoundedRectangle(x, y, w, h, 4)

        # Node header
        dc.SetPen(wx.TRANSPARENT_PEN)
        dc.SetBrush(wx.Brush(wx.Colour(self.GetHeaderColor()), wx.SOLID))
        dc.DrawRoundedRectangle(x + 1, y + 1, w - 3, 24, 2)

        # Node text
        dc.SetTextForeground(wx.Colour(self.GetTextColor()))
        dc.DrawText(utils.TruncateText(self.GetLabel()), x + 6, y + 3)

        # Thumbnail
        thumbnail_width = round((w - 10) / 1.1)
        thumbnail_height = thumb.size[1]

        _x = thumbnail_width / 2.0 - thumb.size[0] / 2.0
        _y = thumbnail_height / 2.0 - thumb.size[1] / 2.0

        thumb_rect = wx.Rect(x + ((w - thumbnail_width) / 2),
                             y + _y + 20 + self.GetLastSocketCoords(),
                             thumbnail_width,
                             thumbnail_height)

        # Draw thumbnail border and background
        dc.SetPen(wx.Pen(wx.Colour("#2B2B2B"), 1))
        dc.SetBrush(wx.Brush(ICON_BRUSH_CHECKERBOARD.GetBitmap()))
        dc.DrawRectangle(thumb_rect)

        # Draw thumbnail image
        dc.DrawBitmap(
            wx.Bitmap(utils.ConvertImageToWx(thumb)),
            x + _x + ((w - thumbnail_width) / 2),
            y + _y + 20 + self.GetLastSocketCoords(),
            True
        )

        # Sockets
        for socket in self.GetSockets():
            socket.Draw(dc)

        dc.SetIdBounds(self.GetId(), self.GetRect())
Пример #3
0
    def OnRenderResult(self, event):
        """ Called after the render is completed and the thread 
        returns the result. 
        """

        self._imageViewport.UpdateViewerImage(
            utils.ConvertImageToWx(self._renderer.GetRender()),
            self._renderer.GetTime())
        self._imageViewport.UpdateRenderText(False)
        self._statusBar.SetStatusText("Render Finished in {} sec.".format(
            self._renderer.GetTime()))

        self._nodeGraph.UpdateAllNodes()
Пример #4
0
    def _Render(self, jobID, abort_event):
        """ Internal rendering method. """
        if not abort_event():
            self._imageViewport.UpdateRenderText(True)
            self._renderer.Render(self._nodeGraph.GetNodes())
            render_time = self._renderer.GetTime()
            render_image = self._renderer.GetRender()
            if render_image is not None:
                self._imageViewport.UpdateViewerImage(
                    utils.ConvertImageToWx(render_image), render_time)
                self._abortEvent.set()
        else:
            self._abortEvent.clear()

        self._imageViewport.UpdateRenderText(False)
        return jobID
Пример #5
0
    def _PostRender(self, delayed_result):
        """ Internal post-render misc. """
        try:
            result = delayed_result.get()

            self._imageViewport.UpdateViewerImage(
                utils.ConvertImageToWx(self._renderer.GetRender()),
                self._renderer.GetTime())
            self._imageViewport.UpdateRenderText(False)
            self._statusBar.SetStatusText("Render Finished in {} sec.".format(
                self._renderer.GetTime()))

            self._nodeGraph.UpdateAllNodes()

            self._abortEvent.clear()
            return result
        except Exception as exc:
            print(
                'ERROR: PLEASE REPORT THE FOLLOWING ERROR TO THE DEVELOPERS: \n',
                exc)
            return
Пример #6
0
 def Render(self):
     """ Callable render method. This is intended to be the 'master' render
     method, called when the Node Graph image is to be rendered. After this is
     complete, the result event will be called.
     """
     if meta.ENABLE_THREADING is True:
         self._abortEvent.clear()
         self._jobID += 1
         delayedresult.startWorker(self._PostRender,
                                   self._Render,
                                   wargs=(self._jobID, self._abortEvent),
                                   jobID=self._jobID)
     else:
         self._imageViewport.UpdateInfoText(True)
         self._renderer.Render(self._nodeGraph.GetNodes())
         render_image = self._renderer.GetRender()
         if render_image is not None:
             self._imageViewport.UpdateViewerImage(
                 utils.ConvertImageToWx(render_image),
                 self._renderer.GetTime())
         self._imageViewport.UpdateInfoText(False)
         self._nodeGraph.UpdateAllNodes()
Пример #7
0
    def __init__(self, parent, size=wx.DefaultSize):
        wx.Panel.__init__(self, parent, size=size)

        self._parent = parent
        self._maxWidth  = size[0]
        self._maxHeight = size[1]

        self._pdc = wx.adv.PseudoDC()

        self.zoomValue = 0.05
        self._renderTime = 0.00

        default_img = utils.ConvertImageToWx(Image.new('RGBA', (256, 256)))
        self._viewportImage = ViewerImage(self, image=default_img,  _id=ID_IMAGE)
        self._imageCopy = self._viewportImage.GetImage()

        self.Bind(wx.EVT_PAINT, self.OnPaint)
        self.Bind(wx.EVT_ERASE_BACKGROUND, lambda x: None)
        self.Bind(wx.EVT_MOTION, self.OnMotion)
        self.Bind(wx.EVT_MOUSEWHEEL, self.OnMouseWheel)
        self.Bind(wx.EVT_LEFT_DOWN, self.OnMiddleDown)
        self.Bind(wx.EVT_KEY_DOWN, self.OnKeyEvent)
        self.Bind(wx.EVT_LEFT_UP, self.OnMiddleUp)
        self.Bind(wx.EVT_SIZE, self.OnSize)