Ejemplo n.º 1
0
 def select_linked(self):
     from tentaculo.gui.wlinkedfiles import w_linkedfiles
     wnd = w_linkedfiles(capp.app_window())
     wnd.setTask(self.__task)
     if (wnd.run() > 0):
         self.refresh.emit()
         self.request_close.emit()
Ejemplo n.º 2
0
def about():
    from tentaculo.gui import wabout
    wndParent = capp.app_window()
    wnd = wabout.w_about(parent=wndParent)
    wnd.run()
    if capp.HOST == capp.STANDALONE:
        wnd.deleteLater()
Ejemplo n.º 3
0
def file(title, start_dir=None):
    res = None
    dir = QFileDialog.getOpenFileNames(capp.app_window(), title, start_dir)
    if isinstance(dir, tuple):
        res = dir[0] if len(dir[0]) > 0 else None
    else:
        res = dir if len(dir) > 0 else None
    return res
Ejemplo n.º 4
0
def string(request, items, editable, title=default_title):
    clogger.CLogger().log.info('String request: %s', request)
    res = u""
    input = QInputDialog.getItem(capp.app_window(), title, request, items, 0,
                                 editable)
    if input[1]: res = input[0]
    clogger.CLogger().log.info('Answer: %s', res)
    return res
Ejemplo n.º 5
0
def question(message, title=default_title):
    clogger.CLogger().log.info(
        'Question: %s',
        message,
    )
    res = QMessageBox.question(capp.app_window(), title, message)
    clogger.CLogger().log.info('Answer: %s', res)
    return res == QMessageBox.Yes
Ejemplo n.º 6
0
	def login_to(self, acc):
		menu.window_close()
		dlogin = wlogin.Wlogin(parent = capp.app_window())
		acc = dlogin.start_login(self.login_as, acc, self.cfg.get('autologin'), self.cfg.get('remember'), self.cfg.get('accounts'))
		if acc:
			self.cfg.update({'autologin': dlogin.autologin()})
			self.cfg.update({'remember': dlogin.remember()})
		
		return acc
Ejemplo n.º 7
0
def publish():
    global WND_HANDLE, SPLASH_HANDLE
    from tentaculo.api.icerebro import db
    if db.Db().login():
        from tentaculo.gui import sendreport
        window_close(True)
        WND_HANDLE = sendreport.w_createReport(to_publish=True,
                                               parent=capp.app_window())
        WND_HANDLE.run()
        SPLASH_HANDLE.finish(WND_HANDLE)
        if capp.HOST == capp.STANDALONE:
            QApplication.exec_()
            WND_HANDLE.deleteLater()
Ejemplo n.º 8
0
def browser():
    global WND_HANDLE, SPLASH_HANDLE
    from tentaculo.api.icerebro import db
    if db.Db().login():
        from tentaculo.gui import taskwindow
        window_close(True)
        WND_HANDLE = taskwindow.w_taskwindow(link_mode=True,
                                             parent=capp.app_window())
        WND_HANDLE.run()
        SPLASH_HANDLE.finish(WND_HANDLE)
        if capp.HOST == capp.STANDALONE:
            QApplication.exec_()
            WND_HANDLE.deleteLater()
Ejemplo n.º 9
0
def error(message, title=default_title):
    clogger.CLogger().log.error(message, exc_info=1)
    QMessageBox.critical(capp.app_window(), title, message)
Ejemplo n.º 10
0
def directory(title, start_dir=None):
    dir = QFileDialog.getExistingDirectory(capp.app_window(), title, start_dir)
    #clogger.CLogger().log.info('Save directory selected: %s', dir)
    return dir
Ejemplo n.º 11
0
def warning(message, title=default_title):
    clogger.CLogger().log.warning(message)
    QMessageBox.warning(capp.app_window(), title, message)
Ejemplo n.º 12
0
def info(message, title=default_title):
    clogger.CLogger().log.info(message)
    QMessageBox.information(capp.app_window(), title, message)
Ejemplo n.º 13
0
    def take(self):
        if capp.HOST == capp.MAYA or capp.HOST == capp.MAYA2:
            view = omui.M3dView.active3dView()
            view.setColorMask(1, 1, 1, 0)
            width = view.portWidth()
            height = view.portHeight()
            image = om.MImage()
            if view.getRendererName() == view.kViewport2Renderer:
                image.create(view.portWidth(), view.portHeight(), 4,
                             om.MImage.kFloat)
                view.readColorBuffer(image)
                image.convertPixelFormat(om.MImage.kByte)
            else:
                view.readColorBuffer(image)
            ptr = ctypes.cast(image.pixels().__long__(),
                              ctypes.POINTER(ctypes.c_char))
            ptrAsStr = ctypes.string_at(ptr, width * height * 4)
            image = QImage(ptrAsStr, width, height, QImage.Format_RGB32)
            image = image.mirrored(horizontal=False, vertical=True)
            self.img = QPixmap.fromImage(image)
            self.set(self.save(self.img))

        elif capp.HOST == capp.NUKE:
            viewer = nuke.activeViewer()
            viewer_input = nuke.ViewerWindow.activeInput(viewer)
            viewer_node = nuke.activeViewer().node()

            if viewer_input is not None and viewer_node is not None:
                inputNode = nuke.Node.input(viewer_node, viewer_input)

                out_path = os.path.join(utils.tempdir(),
                                        "cerebro_screen.png").replace(
                                            '\\', '/')

                node_write = nuke.nodes.Write(file=out_path,
                                              name="cerebro_screen_node",
                                              file_type="png")
                node_write.setInput(0, inputNode)

                cur_frame = int(nuke.knob("frame"))
                nuke.execute(node_write.name(), cur_frame, cur_frame)

                self.set(out_path)
                # Cleanup
                for n in [node_write]:
                    nuke.delete(n)

        elif capp.HOST == capp.HOUDINI:
            cur_desktop = hou.ui.curDesktop()
            frame = hou.frame()
            desktop = cur_desktop.name()
            panetab = cur_desktop.paneTabOfType(
                hou.paneTabType.SceneViewer).name()
            persp = cur_desktop.paneTabOfType(
                hou.paneTabType.SceneViewer).curViewport().name()
            camera_path = desktop + '.' + panetab + ".world." + persp

            out_path = os.path.join(utils.tempdir(),
                                    "cerebro_screen.jpg").replace('\\', '/')
            hou.hscript("viewwrite -r 800 600 -f {0} {1} {2} '{3}'".format(
                frame, frame, camera_path, out_path))

            self.set(out_path)

        elif capp.HOST == capp.MAX:
            view = MaxPlus.ViewportManager.GetActiveViewport()
            bm = MaxPlus.Factory.CreateBitmap()
            storage = MaxPlus.Factory.CreateStorage(7)
            info = storage.GetBitmapInfo()

            bm.SetStorage(storage)
            bm.DeleteStorage()

            res = view.GetDIB(info, bm)
            if res:
                #bm.Display()
                out_path = os.path.join(utils.tempdir(), "cerebro_screen.jpg")

                info.SetName(out_path)
                bm.OpenOutput(info)
                bm.Write(info)
                bm.Close(info)

                self.set(out_path)

        elif capp.HOST == capp.C4D:
            xres, yres = 800, 600
            doc = c4d.documents.GetActiveDocument()
            rd = c4d.documents.RenderData()
            rd[c4d.RDATA_XRES] = xres
            rd[c4d.RDATA_YRES] = yres
            rd[c4d.RDATA_RENDERENGINE] = c4d.RDATA_RENDERENGINE_PREVIEWHARDWARE

            bmp = c4d.bitmaps.BaseBitmap()
            if bmp.Init(xres, yres) == c4d.IMAGERESULT_OK:
                res = c4d.documents.RenderDocument(doc, rd.GetData(), bmp,
                                                   c4d.RENDERFLAGS_EXTERNAL)
                if res == c4d.RENDERRESULT_OK:
                    out_path = os.path.join(utils.tempdir(),
                                            "cerebro_screen.png")
                    res = bmp.Save(out_path, c4d.FILTER_PNG)
                    if res == c4d.IMAGERESULT_OK:
                        self.set(out_path)

        elif capp.HOST == capp.BLENDER:
            out_path = os.path.join(utils.tempdir(), "cerebro_screen.png")

            for window in bpy.context.window_manager.windows:
                screen = window.screen
                for area in screen.areas:
                    if area.type == 'VIEW_3D':
                        for space in area.spaces:
                            if space.type == 'VIEW_3D':
                                for region in area.regions:
                                    if region.type == 'WINDOW':
                                        L_altBpyCtx = {  # defining alternative context (allowing modifications without altering real one)
                                            'area':
                                            area  # our 3D View (first found)
                                            ,
                                            'blend_data':
                                            bpy.context.
                                            blend_data  # just to suppress PyContext warning, doesn't seem to have any effect
                                            #, 'edit_text' : bpy.context.edit_text	# just to suppress PyContext warning, doesn't seem to have any effect
                                            ,
                                            'region':
                                            None  # just to suppress PyContext warning, doesn't seem to have any effect
                                            ,
                                            'scene':
                                            window.scene
                                            if utils.PY37 else screen.scene,
                                            'space':
                                            space,
                                            'screen':
                                            window.screen,
                                            'window':
                                            window  # current window, could also copy context
                                        }
                                        bpy.ops.screen.screenshot(
                                            L_altBpyCtx,
                                            filepath=out_path,
                                            check_existing=False,
                                            full=False)
                                        break  #XXX: limit to the window of the 3D View
                                break  #XXX: limit to the corresponding space (3D View)
                        break  #XXX: limit to the first 3D View (area)

            self.set(out_path)

        elif capp.HOST == capp.STANDALONE:
            out_path = os.path.join(utils.tempdir(), "standalone_screen.png")
            if standalone.message_function("screenshot", [out_path])[0]:
                self.set(out_path)

        elif capp.HOST == capp.KATANA:
            out_path = os.path.join(utils.tempdir(), "cerebro_screen.png")
            wnd = capp.app_window()
            pix = QPixmap.grabWindow(wnd.winId())
            pix.save(out_path)
            self.set(out_path)

        return self.img