def export_alembic(self):
        self.saveFile()

        selectedReferences = []
        selectedItems = self.selection_list.selectedItems()
        for item in selectedItems:
            selectedReferences.append(item.text())
        print "Here are the references: ", selectedReferences

        if self.showConfirmAlembicDialog(selectedReferences) == "Yes":
            loadPlugin("AbcExport")
            filePath = cmds.file(q=True, sceneName=True)
            fileDir = os.path.dirname(filePath)

            proj = Project()
            checkout = proj.get_checkout(fileDir)
            body = proj.get_body(checkout.get_body_name())
            dept = checkout.get_department_name()
            elem = body.get_element(dept, checkout.get_element_name())
            abcFilePath = elem.get_cache_dir()

            for ref in selectedReferences:
                abcFilePath = os.path.join(abcFilePath, self.get_filename_for_reference(ref))
                print "abcFilePath", abcFilePath
                command = self.build_alembic_command(ref, abcFilePath)
                print "Export Alembic command: ", command
                Mel.eval(command)
                os.system("chmod 774 " + abcFilePath)

        self.close_dialog()
Example #2
0
class ElementList(QtGui.QListWidget):
    def __init__(self, parent):
        super(ElementList, self).__init__()
        self.parent = parent
        self.project = Project()
        self.elements = self.project.list_assets()
        self.initUI()       
        
    def initUI(self):
        #define gui elements
        self.refreshList('Asset')
            
    #Update the list based on the input element type
    def refreshList(self, element):
        if element == 'Asset':
            self.elements = self.project.list_assets()
        else:
            self.elements = self.project.list_shots()
            
        self.clear()
        for e in self.elements:
            self.addItem(e)

    def setElement(self, element):
        for idx in xrange(self.count()):
            eItem = self.item(idx)
            if str(eItem.text())==element:
                self.setCurrentRow(idx)
                break
class ElementList(QtGui.QListWidget):
    def __init__(self, parent):
        super(ElementList, self).__init__()
        self.parent = parent
        self.project = Project()
        self.elements = self.project.list_assets()
        self.initUI()       
        
    def initUI(self):
        #define gui elements
        self.refreshList('Asset')
            
    #Update the list based on the input element type
    def refreshList(self, element):
        if element == 'Asset':
            self.elements = self.project.list_assets()
        else:
            self.elements = self.project.list_shots()
            
        self.clear()
        for e in self.elements:
            self.addItem(e)

    def setElement(self, element):
        for idx in xrange(self.count()):
            eItem = self.item(idx)
            if str(eItem.text())==element:
                self.setCurrentRow(idx)
                break
def getElementCacheDirectory(path):
    proj = Project()
    checkout = proj.get_checkout(path)
    body = proj.get_body(checkout.get_body_name())
    elem = body.get_element(checkout.get_department_name(),
                            checkout.get_element_name())
    return elem.get_cache_dir()
Example #5
0
    def export_alembic(self):
        self.saveFile()

        selectedReferences = []
        selectedItems = self.selection_list.selectedItems()
        for item in selectedItems:
            selectedReferences.append(item.text())
        print "Here are the references: ", selectedReferences

        if self.showConfirmAlembicDialog(selectedReferences) == 'Yes':
            loadPlugin("AbcExport")
            filePath = cmds.file(q=True, sceneName=True)
            fileDir = os.path.dirname(filePath)

            proj = Project()
            checkout = proj.get_checkout(fileDir)
            body = proj.get_body(checkout.get_body_name())
            dept = checkout.get_department_name()
            elem = body.get_element(dept, checkout.get_element_name())
            abcFilePath = elem.get_cache_dir()

            for ref in selectedReferences:
                refAbcFilePath = os.path.join(
                    abcFilePath, self.get_filename_for_reference(ref))
                print "abcFilePath", refAbcFilePath
                command = self.build_alembic_command(ref, refAbcFilePath)
                print "Export Alembic command: ", command
                Mel.eval(command)
                os.system('chmod 774 ' + refAbcFilePath)

        self.close_dialog()
class AssetListWindow(QtGui.QListWidget):
    def __init__(self, parent):
        super(AssetListWindow, self).__init__()
        self.parent = parent
        self.current_selection = None
        self.project = Project()
        self.initUI()
        
    def initUI(self):
        self.currentItemChanged.connect(self.set_current_item)
        
    def set_current_item(self, index):
        self.current_selection = str(index.text())
        body = self.project.get_body(self.current_selection)
        element = body.get_element(str(self.parent.departmentMenu.currentText()))
        path = element.get_app_filepath()
        self.parent.filePath = path
        
    def refreshList(self, department):
        if department in Department.FRONTEND:
            asset_filter = None
            if(self.typeFilter.currentIndex()):
                asset_filter_str = str(self.typeFilter.currentText())
                asset_filter = (Asset.TYPE, operator.eq, asset_filter_str)
            self.elements = self.project.list_assets(asset_filter)
        else:
            self.elements = self.project.list_shots()
		    
        self.clear()
        for e in self.elements:
		    self.addItem(e)
Example #7
0
def go():
    project = Project()
    parent = maya_main_window()
    filePath = cmds.file(q=True, sceneName=True)
    element = project.get_checkout_element(os.path.dirname(filePath))
    global maya_rollback_dialog
    maya_rollback_dialog = RollbackWindow(element, parent)
    maya_rollback_dialog.finished.connect(rollback)
 def __init__(self, parent, src, dept_list=Department.ALL):
     super(ReferenceWindow, self).__init__()
     self.project = Project()
     self.parent = parent
     self.src = src
     self.filePaths = []
     self.done = True
     self.reference = False
     self.initUI(dept_list)
Example #9
0
 def __init__(self, src, parent, dept_list=Department.ALL):
     super(PublishWindow, self).__init__()
     self.environment = Environment()
     self.project = Project()
     self.eList = ElementList(self)
     self.parent = parent
     self.src = src
     self.result = None
     self.elementType = None
     self.initUI(dept_list)
     self.published = False
    def createAsset(self):
	    try:
	        name = str(self.textField.text())
	        name = name.replace(' ', '_')
	        project = Project()
	        if self.element == 'asset':
	            asset = project.create_asset(name)
	        else:
			    shot = project.create_shot(name)
	        app.quit()
	    except EnvironmentError, e:
		    print e
		    app.quit()
 def createAsset(self):
     try:
         name = str(self.textField.text())
         name = name.replace(' ', '_')
         project = Project()
         if self.element == 'asset':
             asset = project.create_asset(name)
         else:
             shot = project.create_shot(name)
         self.parent.accept()
     except EnvironmentError, e:
         print e
         self.parent.accept()
def generateGeometry(path=''):
	'''
		Function for generating geometry for Maya files.

		Creates the following output formats:
			.obj

		@return: True if all files were created successfully
				False if some files were not created

		@post: Missing filenames are printed out to both the Maya terminal as well
				as presented in a Maya confirm dialog.
	'''

	path = os.path.dirname(mc.file(q=True, sceneName=True))
	print 'generateGeometry start'
	if not os.path.exists (os.path.join(path, 'cache')):
		os.makedirs(os.path.join(path, 'cache'))

	#OBJPATH = os.path.join(path, "cache/objFiles")
	ABCPATH = os.path.join(path, "cache/abcFiles")

	#if os.path.exists(OBJPATH):
	#	shutil.rmtree(OBJPATH)
	if os.path.exists(ABCPATH):
		shutil.rmtree(ABCPATH)

	filePath = cmds.file(q=True, sceneName=True)
	fileDir = os.path.dirname(filePath)
	proj = Project()
	checkout = proj.get_checkout(fileDir)
	body = proj.get_body(checkout.get_body_name())
	elem = body.get_element(checkout.get_department_name(), checkout.get_element_name())
	abcFilePath = elem.get_cache_dir()


	selection = mc.ls(geometry=True, visible=True)
	selection_long = mc.ls(geometry=True, visible=True, long=True)

	# Temporarily disabled obj support (might not be needed)
	#objs = objExport(selection, OBJPATH)

	# Check to see if all .obj files were created
	#if not len(checkFiles(objs)) == 0:
	#	return False

	abcs = abcExport(selection_long, ABCPATH)
	if not len(checkFiles(abcs)) == 0:
		return False

	return True
Example #13
0
def generateGeometry(path=''):
    '''
		Function for generating geometry for Maya files.

		Creates the following output formats:
			.obj

		@return: True if all files were created successfully
				False if some files were not created

		@post: Missing filenames are printed out to both the Maya terminal as well
				as presented in a Maya confirm dialog.
	'''

    path = os.path.dirname(mc.file(q=True, sceneName=True))
    print 'generateGeometry start'
    if not os.path.exists(os.path.join(path, 'cache')):
        os.makedirs(os.path.join(path, 'cache'))

    #OBJPATH = os.path.join(path, "cache/objFiles")
    ABCPATH = os.path.join(path, "cache/abcFiles")

    #if os.path.exists(OBJPATH):
    #	shutil.rmtree(OBJPATH)
    if os.path.exists(ABCPATH):
        shutil.rmtree(ABCPATH)

    filePath = cmds.file(q=True, sceneName=True)
    fileDir = os.path.dirname(filePath)
    proj = Project()
    checkout = proj.get_checkout(fileDir)
    body = proj.get_body(checkout.get_body_name())
    elem = body.get_element(checkout.get_department_name(),
                            checkout.get_element_name())
    abcFilePath = elem.get_cache_dir()

    selection = mc.ls(geometry=True, visible=True)
    selection_long = mc.ls(geometry=True, visible=True, long=True)

    # Temporarily disabled obj support (might not be needed)
    #objs = objExport(selection, OBJPATH)

    # Check to see if all .obj files were created
    #if not len(checkFiles(objs)) == 0:
    #	return False

    abcs = abcExport(selection_long, ABCPATH)
    if not len(checkFiles(abcs)) == 0:
        return False

    return True
def getElementCacheDirectory(path, element=None):

    if element is None:
        proj = Project()
        checkout = proj.get_checkout(path)
        if checkout is None:
            message_gui.error(
                'There was a problem exporting the alembic to the correct location. Checkout the asset again and try one more time.'
            )
            return None
        body = proj.get_body(checkout.get_body_name())
        element = body.get_element(checkout.get_department_name(),
                                   checkout.get_element_name())

    return element.get_cache_dir()
Example #15
0
class TestAssetManager(unittest.TestCase):

	def setUp(self):
		self.project = Project()
		self.assets_dir = self.project.get_assets_dir()
		if not os.path.exists(self.assets_dir):
			os.mkdir(self.assets_dir)
		self.shots_dir = self.project.get_shots_dir()
		if not os.path.exists(self.shots_dir):
			os.mkdir(self.shots_dir)
		self.users_dir = self.project.get_users_dir()
		if not os.path.exists(self.users_dir):
			os.mkdir(self.users_dir)

	def tearDown(self):
		shutil.rmtree(self.assets_dir)
		shutil.rmtree(self.shots_dir)
		shutil.rmtree(self.users_dir)
 def __init__(self, parent, src, dept_list=Department.ALL):
     super(ReferenceWindow, self).__init__()
     self.project = Project()
     self.parent = parent
     self.src = src
     self.filePath = None
     self.done = True
     self.reference = False
     self.initUI(dept_list)
Example #17
0
 def __init__(self, element, parent):
     super(RollbackWindow, self).__init__()
     self.element = element
     self.parent = parent
     self.environment = Environment()
     self.project = Project()
     self.publishes = []
     self.result = None
     self.initUI()
     self.list_publishes()
 def __init__(self, src, parent):
     super(RollbackWindow, self).__init__()
     self.src = src
     self.parent = parent
     self.environment = Environment()
     self.project = Project()
     self.publishes = []
     self.result = None
     self.initUI()
     self.list_publishes()
Example #19
0
 def __init__(self, src, parent, dept_list=Department.ALL):
     super(PublishWindow, self).__init__()
     self.environment = Environment()
     self.project = Project()
     self.eList = ElementList(self)
     self.parent = parent
     self.src = src
     self.result = None
     self.elementType = None
     self.initUI(dept_list)
     self.published = False
Example #20
0
	def setUp(self):
		self.project = Project()
		self.assets_dir = self.project.get_assets_dir()
		if not os.path.exists(self.assets_dir):
			os.mkdir(self.assets_dir)
		self.shots_dir = self.project.get_shots_dir()
		if not os.path.exists(self.shots_dir):
			os.mkdir(self.shots_dir)
		self.users_dir = self.project.get_users_dir()
		if not os.path.exists(self.users_dir):
			os.mkdir(self.users_dir)
Example #21
0
def createBody(bodyType, name):
    project = Project()
    if bodyType == 'asset':

        msgBox = QtWidgets.QMessageBox()
        msgBox.setText(msgBox.tr("What type of asset is this?"))
        # noButton = msgBox.addButton(QtWidgets.QMessageBox.No)
        # yesButton = msgBox.addButton(QtWidgets.QMessageBox.Yes)
        cancelButton = msgBox.addButton(QtWidgets.QMessageBox.Cancel)
        setButton = msgBox.addButton(msgBox.tr("Set"),
                                     QtWidgets.QMessageBox.YesRole)
        propButton = msgBox.addButton(msgBox.tr("Prop"),
                                      QtWidgets.QMessageBox.YesRole)
        characterButton = msgBox.addButton(msgBox.tr("Character"),
                                           QtWidgets.QMessageBox.YesRole)
        accessoryButton = msgBox.addButton(msgBox.tr("Accessory"),
                                           QtWidgets.QMessageBox.YesRole)

        msgBox.exec_()

        if msgBox.clickedButton() == propButton:
            asset_type = AssetType.PROP
        elif msgBox.clickedButton() == characterButton:
            asset_type = AssetType.CHARACTER
        elif msgBox.clickedButton() == setButton:
            asset_type = AssetType.SET
        elif msgBox.clickedButton() == accessoryButton:
            asset_type = AssetType.ACCESSORY

        print asset_type + " is the asset type"
        asset = project.create_asset(name, asset_type)
    elif bodyType == 'shot':
        shot = project.create_shot(name)
    elif bodyType == 'tool':
        tool = project.create_tool(name)
    else:
        message_gui.error(
            bodyType +
            " is not a valid type!\nThis should not have happend. Please contact a Pipline Management Team member for help!\nTake a screenshot of this error and tell him/her that it came from new_body_gui.py"
        )
Example #22
0
 def __init__(self, element, parent):
     super(RollbackWindow, self).__init__()
     if element is None:
         message_gui.error("Please checkout a shot to rollback.\n")
         return
     self.element = element
     self.parent = parent
     self.environment = Environment()
     self.project = Project()
     self.publishes = []
     self.result = None
     self.initUI()
     self.list_publishes()
Example #23
0
class ElementList(QtWidgets.QListWidget):
    def __init__(self, parent):
        super(ElementList, self).__init__()
        self.parent = parent
        self.project = Project()
        self.elements = self.project.list_assets()
        self.initUI()

    def initUI(self):
        #define gui elements
        self.refreshList('Asset')

    #Update the list based on the input element type
    def refreshList(self, element):
        if element == 'Asset':
            self.elements = self.project.list_assets()
        elif element == 'Shot':
            self.elements = self.project.list_shots()
        elif element == 'Tool':
            self.elements = self.project.list_tools()
        elif element == 'CrowdCycle':
            self.elements = self.project.list_crowd_cycles()
        else:
            self.elements = list()
            message_gui.error(
                'There was a problem loading in the elements from of ' +
                str(element) + ' type.')
        self.clear()
        for e in self.elements:
            self.addItem(e)

    def setElement(self, element):
        for idx in xrange(self.count()):
            eItem = self.item(idx)
            if str(eItem.text()) == element:
                self.setCurrentRow(idx)
                break
Example #24
0
    def setUp(self):
        project_dir = os.path.dirname(os.path.realpath(__file__))
        self.assets_dir = os.path.join(project_dir, "assets")
        self.shots_dir = os.path.join(project_dir, "shots")
        self.users_dir = os.path.join(project_dir, "users")
        self.assmelby_dir = os.path.join(project_dir, "otls")
        pipeline_io.mkdir(self.assets_dir)
        pipeline_io.mkdir(self.shots_dir)
        pipeline_io.mkdir(self.users_dir)
        datadict = Environment.create_new_dict("test", self.assets_dir,
                                               self.shots_dir, self.users_dir,
                                               self.assmelby_dir)
        pipeline_io.writefile(Environment.PIPELINE_FILENAME, datadict)
        os.environ[Environment.PROJECT_ENV] = project_dir

        self.project = Project()
def createBody(bodyType, name):
    project = Project()
    if bodyType == 'asset':

        msgBox = QtWidgets.QMessageBox()
        msgBox.setText(msgBox.tr("What type of asset is this?"))
        # noButton = msgBox.addButton(QtWidgets.QMessageBox.No)
        # yesButton = msgBox.addButton(QtWidgets.QMessageBox.Yes)
        cancelButton = msgBox.addButton(QtWidgets.QMessageBox.Cancel)
        propButton = msgBox.addButton(msgBox.tr("Prop"),
                                      QtWidgets.QMessageBox.YesRole)
        characterButton = msgBox.addButton(msgBox.tr("Character"),
                                           QtWidgets.QMessageBox.YesRole)
        setButton = msgBox.addButton(msgBox.tr("Set"),
                                     QtWidgets.QMessageBox.YesRole)

        msgBox.exec_()

        if msgBox.clickedButton() == propButton:
            asset_type = AssetType.PROP
        elif msgBox.clickedButton() == characterButton:
            asset_type = AssetType.CHARACTER
        elif msgBox.clickedButton() == setButton:
            asset_type = AssetType.SET

        asset = project.create_asset(name, asset_type)
        #generate xml for houdini toolshelf
        try:
            byu_xml.writeXML(name)
        except Exception as error:
            print error
            message_gui.error(error.args)

    elif bodyType == 'shot':
        shot = project.create_shot(name)
    elif bodyType == 'tool':
        tool = project.create_tool(name)
    elif bodyType == 'crowd cycle':
        cycle = project.create_crowd_cycle(name)
    else:
        message_gui.error(
            bodyType +
            " is not a valid type!\nThis should not have happend. Please contact a Pipline Management Team member for help!\nTake a screenshot of this error and tell him/her that it came from new_body_gui.py"
        )
class RollbackWindow(QtGui.QWidget):
    
    finished = QtCore.pyqtSignal()
    
    def __init__(self, src, parent):
        super(RollbackWindow, self).__init__()
        self.src = src
        self.parent = parent
        self.environment = Environment()
        self.project = Project()
        self.publishes = []
        self.result = None
        self.initUI()
        self.list_publishes()
        
    def initUI(self):
        #define gui elements
        self.setGeometry(300,300,WINDOW_WIDTH,WINDOW_HEIGHT)
        self.setWindowTitle('Rollback Manager')
        
        self.publish_list = QtGui.QListWidget()
        self.publish_list.currentItemChanged.connect(self.update_detail_view)
        self.infoLabel = QtGui.QLabel()
        
        self.rollbackButton = QtGui.QPushButton('Rollback')
        self.rollbackButton.clicked.connect(self.rollback)
        self.cancelButton = QtGui.QPushButton('Cancel')
        self.cancelButton.clicked.connect(self.close)
        
        #set gui layout
        self.grid = QtGui.QGridLayout(self)
        self.setLayout(self.grid)
        self.grid.addWidget(self.publish_list, 0, 0, 3, 1)
        self.grid.addWidget(self.infoLabel, 0, 1)
        self.grid.addWidget(self.rollbackButton, 3, 0)
        self.grid.addWidget(self.cancelButton, 3, 1)
        
        self.show()
        
    def list_publishes(self):
        element = self.project.get_checkout_element(os.path.dirname(self.src))
        publishes = element.list_publishes();
        for p in publishes:
            publish = Publish(p[0], p[1], p[2])
            self.publishes = self.publishes + [publish]
            item = QtGui.QListWidgetItem(publish.timestamp)
            self.publish_list.addItem(item)
            
    def update_detail_view(self):
        selectedVersion = self.publishes[self.publish_list.currentRow()]
        self.infoLabel.setText("Author: {0} \nTimestamp: {1} \n\nComment: {2}".format(selectedVersion.author, selectedVersion.timestamp, selectedVersion.comment))
        
    def rollback(self):
        selectedVersion = self.publishes[self.publish_list.currentRow()]
        element = self.project.get_checkout_element(os.path.dirname(self.src))
        versionDir = element.get_version_dir(self.publish_list.currentRow())
        versionFile = listdir(versionDir)[0]
        filepath = versionDir + '/' + versionFile
        user = self.environment.get_current_username()
        comment = "Rollback to version dated \n{0}".format(selectedVersion.timestamp)
        element.publish(user, filepath, comment)
        #checkout element again to user to remove errors upon multiple uses of rollback
        self.result = element.checkout(user)
        self.close()
        
    def closeEvent(self, event):
        self.finished.emit()
        event.accept()
Example #27
0
class PublishWindow(QtWidgets.QWidget):

    finished = QtCore.Signal()

    def __init__(self, src, parent, dept_list=Department.ALL):
        super(PublishWindow, self).__init__()
        self.environment = Environment()
        self.project = Project()
        self.eList = ElementList(self)
        self.parent = parent
        self.src = src
        self.result = None
        self.elementType = None
        self.initUI(dept_list)
        self.published = False

    def initUI(self, dept_list):
        #load checkout information
        src_dir = os.path.dirname(self.src)
        checkout_element = self.project.get_checkout_element(src_dir)
        checkout_dept = None
        checkout_body_name = None
        if checkout_element is not None:
            checkout_dept = checkout_element.get_department()
            checkout_body_name = checkout_element.get_parent()

        #define gui elements
        self.setGeometry(300, 300, WINDOW_WIDTH, WINDOW_HEIGHT)
        self.setWindowTitle('Publish')
        self.menu = QtWidgets.QComboBox()
        self.menu.addItem('Asset')
        self.menu.addItem('Shot')
        self.departmentMenu = QtWidgets.QComboBox()
        checkout_idx = -1
        for i, dept in enumerate(dept_list):
            self.departmentMenu.addItem(dept)
            if dept == checkout_dept:
                checkout_idx = i

        self.departmentMenu.activated[str].connect(self.setElementType)
        self.filePath = QtWidgets.QLineEdit()
        self.filePath.setReadOnly(True)
        self.label = QtWidgets.QLabel('What did you change?')
        self.comment = QtWidgets.QTextEdit()
        self.lastPublish = QtWidgets.QTextEdit()
        self.lastPublish.setReadOnly(True)
        self.publishBtn = QtWidgets.QPushButton('Publish')
        self.publishBtn.setEnabled(False)

        self.eList.currentItemChanged.connect(self.selectElement)
        self.publishBtn.clicked.connect(self.publish)

        if checkout_idx > -1:
            self.departmentMenu.setCurrentIndex(checkout_idx)
        self.setElementType()
        self.eList.setElement(checkout_body_name)

        self.clearHistoryCheckbox = QtWidgets.QCheckBox(
            'Freeze all transformations and clear all construction history')

        #set gui layout
        self.grid = QtWidgets.QGridLayout(self)
        self.setLayout(self.grid)
        self.grid.addWidget(self.departmentMenu, 0, 0)
        self.grid.addWidget(self.clearHistoryCheckbox, 0, 1)

        self.grid.addWidget(self.lastPublish, 1, 1)
        self.grid.addWidget(self.label, 2, 1)
        self.grid.addWidget(self.comment, 3, 1)

        self.grid.addWidget(self.eList, 1, 0, 3, 1)
        self.grid.addWidget(self.filePath, 4, 0)
        self.grid.addWidget(self.publishBtn, 4, 1)

        self.show()

    def setElementType(self):
        self.department = str(self.departmentMenu.currentText())
        if self.department in Department.ASSET_DEPTS:
            self.elementType = 'Asset'
        elif self.department in Department.SHOT_DEPTS:
            self.elementType = 'Shot'
        elif self.department in Department.TOOL_DEPTS:
            self.elementType = 'Tool'
        elif self.department in Department.CROWD_DEPTS:
            self.elementType = 'CrowdCycle'
        else:
            message_gui.error('There was an error loading the ' +
                              str(self.department) + ' department')
        self.eList.refreshList(self.elementType)

    def selectElement(self):
        currentItem = self.eList.currentItem()
        print(currentItem)
        if currentItem is not None:
            self.filePath.setText(self.eList.currentItem().text(1))
            print("Current Item 0: " + self.eList.currentItem().text(0))
            print("Current Item 1: " + self.eList.currentItem().text(1))
            self.publishBtn.setEnabled(True)

            current_dept = str(self.departmentMenu.currentText())
            print("Current Department " + current_dept)

            asset_obj = self.project.get_body(str(currentItem.text(1)))
            element_obj = asset_obj.get_element(current_dept)
            last_publish = element_obj.get_last_publish()
            last_publish_comment = None
            if last_publish is not None:
                last_publish_comment = 'Last published {0} by {1} \n "{2}"'.format(
                    last_publish[1], last_publish[0], last_publish[2])
            else:
                last_publish_comment = 'No publishes for this element'
            self.lastPublish.setText(last_publish_comment)

    def publish(self):

        if str(self.comment.toPlainText()) == '':
            message_gui.error(
                'Please add a publish comment.\nComments help to track the progress.'
            )
            return

        self.elementType = str(self.menu.currentText())
        try:
            body = self.project.get_body(str(self.filePath.text()))
            element = body.get_element(str(self.departmentMenu.currentText()))

            self.user = self.environment.get_current_username()
            self.comment = str(self.comment.toPlainText())
            self.elementName = str(self.departmentMenu.currentText())
            self.result = element
            self.published = True
            self.close()
        except Exception, e:
            print e
            error = QtWidgets.QLineEdit()
            error.setText(str(e))
            self.grid.addWidget(error, 4, 1, 2, 1)
            traceback.print_stack()
class ReferenceWindow(QtGui.QWidget):
    
    finished = QtCore.pyqtSignal()
    
    def __init__(self, parent, src, dept_list=Department.ALL):
        super(ReferenceWindow, self).__init__()
        self.project = Project()
        self.parent = parent
        self.src = src
        self.filePath = None
        self.done = True
        self.reference = False
        self.initUI(dept_list)
        
    def initUI(self, dept_list):
        #define gui elements
        self.setGeometry(300,300,WINDOW_WIDTH,WINDOW_HEIGHT)
        self.setWindowTitle('Taijitu Reference Manager')
        self.departmentMenu = QtGui.QComboBox()
        for i in dept_list:
            self.departmentMenu.addItem(i)
        self.departmentMenu.activated[str].connect(self.setElementType)
        
        self.assetList = AssetListWindow(self)
        for asset in self.project.list_assets():
            item = QtGui.QListWidgetItem(asset)
            self.assetList.addItem(item)

        self.typeFilterLabel = QtGui.QLabel("Type Filter")
        self.typeFilterLabel.setAlignment(QtCore.Qt.AlignRight | QtCore.Qt.AlignVCenter)
        self.typeFilter = QtGui.QComboBox()
        self.typeFilter.addItem("all")
        for i in AssetType.ALL:
            self.typeFilter.addItem(i)
            
        self.typeFilter.currentIndexChanged.connect(self.setElementType)
        self.referenceButton = QtGui.QPushButton('Reference')
        self.referenceButton.clicked.connect(self.createReference)
        self.cancelButton = QtGui.QPushButton('Cancel')
        self.cancelButton.clicked.connect(self.close)
            
        #set gui layout
        self.grid = QtGui.QGridLayout(self)
        self.setLayout(self.grid)
        self.grid.addWidget(self.departmentMenu, 0, 0)
        self.grid.addWidget(self.assetList, 1, 0, 1, 0)
        self.grid.addWidget(self.typeFilterLabel, 2, 0)
        self.grid.addWidget(self.typeFilter, 2, 1)
        self.grid.addWidget(self.referenceButton, 3, 0)
        self.grid.addWidget(self.cancelButton, 3, 1)
        
        self.show()
        
    def setElementType(self, idx=0):
        department = str(self.departmentMenu.currentText())
        self.refreshList(department)
        
    def createReference(self):
        checkout = self.project.get_checkout(os.path.dirname(self.src))
        if checkout is not None:
            body_name = checkout.get_body_name()
            body = self.project.get_body(body_name)
            body.add_reference(self.assetList.current_selection)
        self.done = False
        self.reference = True
        self.close()

    def refreshList(self, department):
        if department in Department.FRONTEND:
            asset_filter = None
            if(self.typeFilter.currentIndex()):
                asset_filter_str = str(self.typeFilter.currentText())
                asset_filter = (Asset.TYPE, operator.eq, asset_filter_str)
            self.elements = self.project.list_assets(asset_filter)
        else:
            self.elements = self.project.list_shots()
            
        self.assetList.clear()
        for e in self.elements:
            self.assetList.addItem(e)
        
    def closeEvent(self, event):
        self.finished.emit()
        event.accept()
Example #29
0
class ElementList(QtWidgets.QTreeWidget):
    def __init__(self, parent):
        super(ElementList, self).__init__()
        self.parent = parent
        self.project = Project()
        self.elements = self.project.list_assets()
        self.initUI()

    def initUI(self):
        #define gui elements
        self.refreshList('Asset')

    def recurseTree(self, treeItem, array, asset):
        #This is for setting bottom level text attributes
        if len(array) == 0:
            treeItem.setText(1, asset)
            treeItem.setTextColor(0, "#3c83f9")
            font = QtGui.QFont()
            font.setPointSize(12)
            font.setBold(False)
            treeItem.setFont(0, font)
            return
        else:  #This is for setting parent level text attributes and settin up the structure
            item = QtWidgets.QTreeWidgetItem(array[0])
            item.setText(0, array[0])
            item.setText(1, "This is not a file")
            item.setTextColor(0, "#d0d0d0")
            font = QtGui.QFont()
            font.setPointSize(11)
            font.setBold(True)
            item.setFont(0, font)
            skip = False
            # this is to check if the child already exists
            for i in range(0, treeItem.childCount()):
                if treeItem.child(i).text(0) == item.text(0):
                    item = treeItem.child(i)
                    skip = True
            if skip == False:  # Executes if the child doesnt already exist
                treeItem.addChild(item)
            newArray = array[1:]
            self.recurseTree(item, newArray, asset)
        return

    #Update the list based on the input element type
    def refreshList(self, element):
        if element == 'Asset':
            self.elements = self.project.list_assets()
        elif element == 'Shot':
            self.elements = self.project.list_shots()
        elif element == 'Tool':
            self.elements = self.project.list_tools()
        elif element == 'CrowdCycle':
            self.elements = self.project.list_crowd_cycles()
        else:
            self.elements = list()
            message_gui.error(
                'There was a problem loading in the elements from of ' +
                str(element) + ' type.')
        self.clear()
        for e in self.elements:
            asset_array = e.split("_")
            firstelement = self.findItems(asset_array[0], 0, 0)
            if not firstelement:
                item = QtWidgets.QTreeWidgetItem(asset_array[0])
                item.setText(0, asset_array[0])
                item.setTextColor(0, "#d0d0d0")
                font = QtGui.QFont()
                font.setPointSize(11)
                font.setBold(True)
                item.setFont(0, font)
                self.recurseTree(item, asset_array[1:], e)
                self.insertTopLevelItem(0, item)
            else:
                self.recurseTree(firstelement[0], asset_array[1:], e)
            #self.addItem(e)

    def setElement(self, element):
        print(element)
Example #30
0
 def __init__(self, parent):
     super(ElementList, self).__init__()
     self.parent = parent
     self.project = Project()
     self.elements = self.project.list_assets()
     self.initUI()
class ElementBrowser(QtGui.QWidget):

    ASSETS = "Assets"
    SHOTS = "Shots"

    BODY_DATA_COLUMN = 1
    BODY_DESCRIPTION_COLUMN = 7

    @staticmethod
    def dark_palette():
        palette = QtGui.QPalette()
        base_color = QtGui.QColor(39,39,39)
        alt_color = QtGui.QColor(30,30,30)
        text_color = QtGui.QColor(192,192,192)
        highlight_color = QtGui.QColor(57,86,115)
        highlight_text_color = QtCore.Qt.white
        disabled_alt_color = QtGui.QColor(49,49,49)
        disabled_base_color = QtGui.QColor(40,40,40)
        disabled_text_color = QtGui.QColor(100,100,100)
        palette.setColor(QtGui.QPalette.Window, base_color)
        palette.setColor(QtGui.QPalette.WindowText, text_color)
        palette.setColor(QtGui.QPalette.Base, base_color)
        palette.setColor(QtGui.QPalette.AlternateBase, alt_color)
        palette.setColor(QtGui.QPalette.ToolTipBase, alt_color)
        palette.setColor(QtGui.QPalette.ToolTipText, text_color)
        palette.setColor(QtGui.QPalette.Button, base_color)
        palette.setColor(QtGui.QPalette.ButtonText, text_color)
        palette.setColor(QtGui.QPalette.Text, text_color)
        palette.setColor(QtGui.QPalette.Highlight, highlight_color)
        palette.setColor(QtGui.QPalette.HighlightedText, highlight_text_color)
        palette.setColor(QtGui.QPalette.Disabled, QtGui.QPalette.Window, disabled_base_color)
        palette.setColor(QtGui.QPalette.Disabled, QtGui.QPalette.WindowText, disabled_text_color)
        palette.setColor(QtGui.QPalette.Disabled, QtGui.QPalette.Base, disabled_text_color)
        palette.setColor(QtGui.QPalette.Disabled, QtGui.QPalette.AlternateBase, disabled_alt_color)
        palette.setColor(QtGui.QPalette.Disabled, QtGui.QPalette.Button, disabled_base_color)
        palette.setColor(QtGui.QPalette.Disabled, QtGui.QPalette.ButtonText, disabled_text_color)
        palette.setColor(QtGui.QPalette.Disabled, QtGui.QPalette.Text, disabled_text_color)
        return palette

    def __init__(self):
        QtGui.QWidget.__init__(self)
        self.setWindowTitle("Element Browser")
        self.setGeometry(0, 0, REF_WINDOW_WIDTH, REF_WINDOW_HEIGHT)
        self.palette = self.dark_palette()
        self.setPalette(self.palette)

        # initialize project
        self.project = Project()
        self.user_list = self.project.list_users()
        self.user_completer = QtGui.QCompleter(self.user_list)

        #filters
        self.filter_label = QtGui.QLabel("Filter by: ")

        self.dept_filter_label = QtGui.QLabel("Department")
        self.dept_filter_label.setAlignment(QtCore.Qt.AlignRight | QtCore.Qt.AlignVCenter)
        self.dept_filter = QtGui.QComboBox()
        self.dept_filter.addItem("all")
        for each in Department.ALL:
            self.dept_filter.addItem(each)
        self.dept_list = Department.ALL

        self.type_filter_label = QtGui.QLabel("Asset Type")
        self.type_filter_label.setAlignment(QtCore.Qt.AlignRight | QtCore.Qt.AlignVCenter)
        self.type_filter = QtGui.QComboBox()
        self.type_filter.addItem("all")
        for each in AssetType.ALL:
            self.type_filter.addItem(each)

        self.name_filter_label = QtGui.QLabel("Name")
        self.name_filter_label.setAlignment(QtCore.Qt.AlignRight | QtCore.Qt.AlignVCenter)
        self.name_filter = QtGui.QLineEdit()

        # menu bar
        self.menu_bar = QtGui.QMenuBar()
        self.view_menu = QtGui.QMenu("View")
        self.menu_bar.addMenu(self.view_menu)
        self.expand_action = self.view_menu.addAction("Expand All")
        self.user_list_action = self.view_menu.addAction("User Directory")
        self.theme_action = self.view_menu.addAction("Default Theme")
        self.theme_action.setCheckable(True)

        # asset/shot menu
        self.body_menu = QtGui.QComboBox()
        self.body_menu.addItem(self.ASSETS)
        self.body_menu.addItem(self.SHOTS)
        self.current_body = self.ASSETS
        self._set_bodies()

        # new button
        self.new_button = QtGui.QPushButton("New")

        # refresh button
        self.refresh_button = QtGui.QPushButton("Refresh")

        # tree
        self.tree = QtGui.QTreeWidget()
        self.tree.setItemDelegate(TreeGridDelegate(self.tree))
        self.columnCount = 8
        self.tree.setColumnCount(self.columnCount)
        tree_header = QtGui.QTreeWidgetItem(["name", "", "assigned", "status", "start", "end", "publish", "note"])
        self.tree.setHeaderItem(tree_header)

        self.init_tree = [None]*self.columnCount
        self.init_tree[0] = self.init_name
        self.init_tree[1] = self.init_dept
        self.init_tree[2] = self.init_assigned_user
        self.init_tree[3] = self.init_status
        self.init_tree[4] = self.init_start_date
        self.init_tree[5] = self.init_end_date
        self.init_tree[6] = self.init_last_publish
        self.init_tree[7] = self.init_note

        self._build_tree()

        self.update_tree = [None]*self.columnCount
        self.update_tree[0] = self.update_name
        self.update_tree[1] = self.update_dept
        self.update_tree[2] = self.update_assigned_user
        self.update_tree[3] = self.update_status
        self.update_tree[4] = self.update_start_date
        self.update_tree[5] = self.update_end_date
        self.update_tree[6] = self.update_last_publish
        self.update_tree[7] = self.update_note
        
        # status bar
        self.status_bar = QtGui.QStatusBar()

        # connect events
        self.expand_action.triggered.connect(self._expand_all)
        self.user_list_action.triggered.connect(self._show_user_directory)
        self.theme_action.triggered.connect(self._toggle_theme)
        self.body_menu.currentIndexChanged.connect(self._body_changed)
        self.new_button.clicked.connect(self._new_body)
        self.refresh_button.clicked.connect(self._refresh)
        self.tree.itemExpanded.connect(self._load_elements)
        self.tree.itemChanged.connect(self._item_edited)
        self.dept_filter.currentIndexChanged.connect(self._dept_filter_changed)
        self.name_filter.editingFinished.connect(self._filter_by_name)
        self.type_filter.currentIndexChanged.connect(self._refresh)

        # layout
        layout = QtGui.QVBoxLayout(self)
        layout.setSpacing(5)
        layout.setMargin(6)
        options_layout = QtGui.QGridLayout()
        options_layout.addWidget(self.body_menu, 0, 0)
        options_layout.addWidget(self.new_button, 0, 1)
        options_layout.addWidget(self.refresh_button, 0, 3)
        options_layout.setColumnMinimumWidth(0, 100)
        options_layout.setColumnMinimumWidth(1, 100)
        options_layout.setColumnMinimumWidth(3, 100)
        options_layout.setColumnStretch(2, 1)
        filter_layout = QtGui.QGridLayout()
        filter_layout.addWidget(self.filter_label, 0, 0)
        filter_layout.addWidget(self.dept_filter_label, 0, 1)
        filter_layout.addWidget(self.dept_filter, 0, 2)
        filter_layout.addWidget(self.name_filter_label, 0, 3)
        filter_layout.addWidget(self.name_filter, 0, 4)
        filter_layout.addWidget(self.type_filter_label, 0, 5)
        filter_layout.addWidget(self.type_filter, 0, 6)
        filter_layout.setColumnMinimumWidth(0, 50)
        filter_layout.setColumnMinimumWidth(1, 100)
        filter_layout.setColumnMinimumWidth(2, 100)
        filter_layout.setColumnMinimumWidth(3, 100)
        filter_layout.setColumnMinimumWidth(4, 100)
        filter_layout.setColumnMinimumWidth(5, 100)
        filter_layout.setColumnMinimumWidth(6, 100)
        cal = QtGui.QCalendarWidget()
        
        filter_layout.setColumnStretch(7, 1)
        layout.addWidget(self.menu_bar)
        layout.addLayout(options_layout)
        layout.addWidget(self.tree)
        layout.addLayout(filter_layout)
        # layout.addWidget(self.filter_label)
        # layout.addWidget(self.type_filter)
        # layout.addWidget(self.dept_filter)
        layout.addWidget(self.status_bar)
        self.setLayout(layout)

        request_email.check_user_email(self)

    def _build_tree(self):
        self.tree.clear()
        tree_state = self.tree.blockSignals(True)
        for body in self.bodies:
            if(str(self.name_filter.text()) in body):
                tree_item = QtGui.QTreeWidgetItem([body])
                self.tree.addTopLevelItem(tree_item)
                tree_flags = tree_item.flags()
                tree_item.setFlags(tree_flags | QtCore.Qt.ItemIsEditable)
                # for col in xrange(self.columnCount):
                #     tree_item.setBackground(col, QtGui.QColor(30,30,30))
                body_obj = self.project.get_body(body)
                self._load_body(body_obj, tree_item)
                tree_item.addChild(QtGui.QTreeWidgetItem()) # empty item
        self.tree.blockSignals(tree_state)

    def _load_body(self, body, item):
        tree_state = self.tree.blockSignals(True)
        item.setText(0, body.get_name())
        namelabel = TreeLabel(body.get_name())
        self.tree.setItemWidget(item, 0, namelabel)
        if self.current_body==self.ASSETS:
            body_type = body.get_type()
            item.setText(self.BODY_DATA_COLUMN, body_type)
            combobox = TreeComboBoxItem(item, self.BODY_DATA_COLUMN)
            type_idx = 0
            for idx, type in enumerate(AssetType.ALL):
                combobox.addItem(type)
                if type == body_type:
                    type_idx = idx
            combobox.setCurrentIndex(type_idx)
            self.tree.setItemWidget(item, self.BODY_DATA_COLUMN, combobox)
        elif self.current_body==self.SHOTS:
            item.setText(self.BODY_DATA_COLUMN, str(body.get_frame_range()))
        else:
            self.status_bar.showMessage("Error: unknown body type")

        description_edit = TreeLineEdit(body.get_description(), item, self.BODY_DESCRIPTION_COLUMN)
        self.tree.setItemWidget(item, self.BODY_DESCRIPTION_COLUMN, description_edit)

        for col in xrange(self.BODY_DATA_COLUMN+1, self.columnCount-1): # disable remaining columns
            emptylabel = TreeLabel()
            self.tree.setItemWidget(item, col, emptylabel)
        self.tree.blockSignals(tree_state)

    def _load_elements(self, item):
        tree_state = self.tree.blockSignals(True)
        body = str(item.text(0))
        body_obj = self.project.get_body(body)
        elements = []
        for dept in self.dept_list:
            dept_elements = body_obj.list_elements(dept)
            for dept_element in dept_elements:
                elements.append((dept, dept_element))
        item.takeChildren() # clear children
        for dept, element in elements:
            element_obj = body_obj.get_element(dept, element)
            child_item = QtGui.QTreeWidgetItem()
            item.addChild(child_item)
            child_item.setFlags(child_item.flags() | QtCore.Qt.ItemIsEditable)
            for col, init in enumerate(self.init_tree):
                init(element_obj, child_item, col)
        self.tree.blockSignals(tree_state)

    def _expand_all(self):
        # self.tree.expandAll()
        count = self.tree.topLevelItemCount()
        for i in xrange(count):
            item = self.tree.topLevelItem(i)
            self.tree.expandItem(item)
    
    def _show_user_directory(self):
        user_directory = UserListDialog(self)
        user_directory.show()

    def _toggle_theme(self):
        checked = self.theme_action.isChecked()
        if not checked:
            self.palette = self.dark_palette()
        else:
            self.palette = QtGui.QPalette()
        self.setPalette(self.palette)

    def _set_bodies(self):
        if self.current_body == self.ASSETS:
            asset_filter = None
            if(self.type_filter.currentIndex()):
                asset_filter_str = str(self.type_filter.currentText())
                asset_filter = (Asset.TYPE, operator.eq, asset_filter_str)
            self.bodies = self.project.list_assets(asset_filter)
        elif self.current_body == self.SHOTS:
            self.bodies = self.project.list_shots()
        else:
            self.bodies = []

    def _item_edited(self, item, column):
        parent = item.parent()
        if parent is not None:
            body = str(parent.text(0))
            body_obj = self.project.get_body(body)
            element = str(item.text(0))
            dept = str(item.text(1))
            element_obj = body_obj.get_element(dept, element)
            self.update_tree[column](element_obj, item, column)
            # self.tree.resizeColumnToContents(column)
        else:
            body = str(item.text(0))
            body_obj = self.project.get_body(body)
            if column==self.BODY_DATA_COLUMN:
                self._update_body_data(body_obj, item)
            elif column==self.BODY_DESCRIPTION_COLUMN:
                self._update_body_description(body_obj, item)
                

    def _refresh(self): # TODO: maintain expanded rows on refresh
        self._set_bodies()
        self._build_tree()
        self.status_bar.clearMessage()

    def _body_changed(self, index):
        self.current_body = str(self.body_menu.itemText(index))
        if(self.body_menu.currentIndex()):
            self.type_filter.setEnabled(False)
            self.type_filter_label.setEnabled(False)
        else:
            self.type_filter.setEnabled(True)
            self.type_filter_label.setEnabled(True)
        self._refresh()

    def _dept_filter_changed(self):
        if(self.dept_filter.currentIndex()):
            self.dept_list = [str(self.dept_filter.currentText())]
        else:
            self.dept_list = Department.ALL
        self._refresh()

    def _filter_by_name(self):
        self._refresh()
        # target = str(self.name_filter.text())
        # for i in reversed(xrange(self.tree.topLevelItemCount())):
        #     if (target not in self.tree.topLevelItem(i).text(0)):
        #         self.tree.takeTopLevelItem(i)

    def _new_body(self):
        from byugui import new_asset_gui
        self.new_body_dialog = new_asset_gui.CreateWindow(self)
        if self.current_body == self.ASSETS:
            self.new_body_dialog.setCurrentIndex(self.new_body_dialog.ASSET_INDEX)
        elif self.current_body == self.SHOTS:
            self.new_body_dialog.setCurrentIndex(self.new_body_dialog.SHOT_INDEX)
        self.new_body_dialog.finished.connect(self._refresh)

    def _update_body_data(self, body, item):
        if self.current_body==self.ASSETS:
            body.update_type(str(item.text(self.BODY_DATA_COLUMN)))
        elif self.current_body==self.SHOTS:
            body.update_frame_range(int(item.text(self.BODY_DATA_COLUMN)))
        else:
            self.status_bar.showMessage("Error: unknown body type")

    def _update_body_description(self, body, item):
        body.update_description(str(item.text(self.BODY_DESCRIPTION_COLUMN)))

    def _valid_date(self, date):
        try:
            date_obj = datetime.datetime.strptime(date, "%Y-%m-%d").date()
            return str(date_obj)
        except ValueError:
            self.status_bar.showMessage(date+" not a valid date, please use format: YYYY-MM-DD")
            return None

    def init_name(self, element, item, column):
        item.setText(column, element.get_name())
        namelabel = TreeLabel(element.get_name())
        self.tree.setItemWidget(item, column, namelabel)

    def init_dept(self, element, item, column):
        item.setText(column, element.get_department())
        deptlabel = TreeLabel(element.get_department())
        self.tree.setItemWidget(item, column, deptlabel)

    def init_assigned_user(self, element, item, column):
        user = element.get_assigned_user()
        item.setText(column, user)
        lineedit = TreeLineEdit(user, item, column)
        lineedit.setCompleter(self.user_completer)
        self.tree.setItemWidget(item, column, lineedit)

    def init_status(self, element, item, column):
        item.setText(column, element.get_status())
        combobox = TreeComboBoxItem(item, column)
        element_type = element.get_status()
        type_idx = 0
        for idx, type in enumerate(Status.ALL):
            combobox.addItem(type)
            if type == element_type:
                type_idx = idx
        combobox.setCurrentIndex(type_idx)
        self.tree.setItemWidget(item, column, combobox)

    def init_start_date(self, element, item, column):
        item.setText(column, element.get_start_date())

    def init_end_date(self, element, item, column):
        item.setText(column, element.get_end_date())

    def init_last_publish(self, element, item, column):
        publish = element.get_last_publish()
        if publish is not None:
            item.setText(column, publish[0]+", "+publish[1]+", "+publish[2])
        else:
            item.setText(column, "")

    def init_note(self, element, item, column):
        item.setText(column, element.get_last_note())

    def update_name(self, element, item, column):
        self.status_bar.showMessage("can't change name")

    def update_dept(self, element, item, column):
        self.status_bar.showMessage("can't change department")

    def update_assigned_user(self, element, item, column):
        user = str(item.text(column))
        if user in self.user_list:
            element.update_assigned_user(user)
            self.status_bar.clearMessage()
        else:
            self.tree.itemWidget(item, column).setText(element.get_assigned_user())
            self.status_bar.showMessage('"' + user + '" is not a valid username')

    def update_status(self, element, item, column):
        element.update_status(str(item.text(column)))
        self.status_bar.clearMessage()

    def update_start_date(self, element, item, column):
        date_str = str(item.text(column))
        valid_date_str = self._valid_date(date_str)
        if valid_date_str:
            element.update_start_date(valid_date_str)
            self.status_bar.clearMessage()
        else:
            self.init_start_date(element, item, column)

    def update_end_date(self, element, item, column):
        date_str = str(item.text(column))
        valid_date_str = self._valid_date(date_str)
        if valid_date_str:
            element.update_end_date(valid_date_str)
            self.status_bar.clearMessage()
        else:
            self.init_end_date(element, item, column)

    def update_last_publish(self, element, item, column):
        self.status_bar.showMessage("can't modify publish data")
        self.init_last_publish(element, item, column)

    def update_note(self, element, item, column):
        element.update_notes(str(item.text(column)))
        self.status_bar.clearMessage()
class CheckoutWindow(QtGui.QWidget):

    finished = QtCore.pyqtSignal()

    def __init__(self, parent, dept_list=Department.ALL):
        super(CheckoutWindow, self).__init__()
        self.parent = parent
        self.project = Project()
        self.environment = Environment()
        self.initUI(dept_list)
        
    def initUI(self, dept_list):
        #define gui elements
        self.resize(WINDOW_WIDTH,WINDOW_HEIGHT)
        self.setWindowTitle('Checkout')
        self.dept_tabs = QtGui.QTabWidget()
        self.dept_list = dept_list
        self.result = None
        #create tabs
        for dept in dept_list:
            tab = DepartmentTab(self)
            #tab = QtGui.QWidget()
            # self.dept_tabs.insertTab(self.ASSET_INDEX, tab, dept)
            self.dept_tabs.addTab(tab, dept)
            tab_layout = QtGui.QVBoxLayout()
            element_list = QtGui.QListWidget()
				
            if dept in Department.FRONTEND:
                for asset in self.project.list_assets():
                    item = QtGui.QListWidgetItem(asset)
                    element_list.addItem(item)
                    element_list.currentItemChanged.connect(self.set_current_item)
            elif dept in Department.BACKEND:
                for shot in self.project.list_shots():
                    item = QtGui.QListWidgetItem(shot)
                    element_list.addItem(item)
                    element_list.currentItemChanged.connect(self.set_current_item)
            tab_layout.addWidget(element_list)
            tab.setLayout(tab_layout)
            
        #create buttons
        self.checkout_button = QtGui.QPushButton('Checkout')
        self.checkout_button.clicked.connect(self.checkout)
        self.cancel_button = QtGui.QPushButton('Cancel')
        self.cancel_button.clicked.connect(self.close)    
		
        #create button layout
        button_layout = QtGui.QHBoxLayout()
        #button_layout.setSpacing(2)
        button_layout.addWidget(self.checkout_button)
        button_layout.addWidget(self.cancel_button)

        self.img = QtGui.QLabel()
        pixmap = QtGui.QPixmap(os.environ['BYU_TOOLS_DIR'] + '/byugui/assets/images/taijitu.jpg')
        scaled = pixmap.scaledToWidth(self.size().width())
        self.img.setPixmap(scaled)

        #create main layout
        main_layout = QtGui.QVBoxLayout()
        self.setLayout(main_layout)
        main_layout.addWidget(self.img)
        main_layout.setSpacing(5)
        main_layout.setMargin(6)
        main_layout.addWidget(self.dept_tabs)
        main_layout.addLayout(button_layout)
            
        self.show()
            
    def set_current_item(self, index):
        current_dept = self.dept_list[self.dept_tabs.currentIndex()]
        if current_dept in Department.FRONTEND:
            self.current_item = str(index.text())
        elif current_dept in Department.BACKEND:
            self.current_item = str(index.text())
            
    def checkout(self):
        """
        Checks out the currently selected item
        :return:
        """
        current_user = self.environment.get_current_username()
        current_dept = self.dept_list[self.dept_tabs.currentIndex()]
        asset_obj = self.project.get_body(self.current_item)
        element_obj = asset_obj.get_element(current_dept)
        element_path = element_obj.checkout(current_user)
        if element_path != None:
            # self.parent.close()
            self.result = element_path
            self.close()
            

    def closeEvent(self, event):
        self.finished.emit()
        event.accept()
Example #33
0
STARTPRE = -50

selection = mc.ls(selection=True)[0]
rigPrefix = re.search(r'\w*main_\w*:?Viking', selection, re.I).group()
rigPrefix = "viking_with_facial_rig_main"  #until I can figure out that regex lol

vikingBodyGeo = rigPrefix + '_body_GEO_01'
vikingRigName = rigPrefix + '_primary_global_cc_01'

cache_name = rigPrefix  # look in shots cfx/main/cache

#########################
## ESTABLISH CFX SCENE ##
#########################

project = Project()
environment = Environment()

# Create a global position locator for viking's starting location
mc.currentTime(STARTPRE)
globalPos = mc.spaceLocator(p=[0, 0, 0])
globPos = mc.rename(globalPos, "vikingGlobalPos")
mc.select(vikingRigName)
mc.select(globPos, add=True)
mc.pointConstraint(
    offset=[0, 0, 0],
    weight=1)  #constrains the globPos position to where viking's rig_main is
mc.orientConstraint(
    offset=[0, 0, 0], weight=1
)  #orients the globPos to match viking's rig_main (I think it just does the rotation)
class CheckoutWindow(QtGui.QWidget):

    finished = QtCore.pyqtSignal()

    def __init__(self, parent, dept_list=Department.ALL):
        super(CheckoutWindow, self).__init__()
        self.parent = parent
        self.project = Project()
        self.environment = Environment()
        self.initUI(dept_list)

    def initUI(self, dept_list):
        #define gui elements
        self.resize(WINDOW_WIDTH, WINDOW_HEIGHT)
        self.setWindowTitle('Checkout')
        self.dept_tabs = QtGui.QTabWidget()
        self.dept_list = dept_list
        self.result = None
        #create tabs
        for dept in dept_list:
            tab = DepartmentTab(self)
            self.dept_tabs.addTab(tab, dept)
            tab_layout = QtGui.QHBoxLayout()
            element_list = QtGui.QListWidget()
            commentBox = QtGui.QTextEdit()
            commentBox.setReadOnly(True)
            tab.commentBox = commentBox

            if dept in Department.FRONTEND:
                for asset in self.project.list_assets():
                    item = QtGui.QListWidgetItem(asset)
                    element_list.addItem(item)
                    element_list.currentItemChanged.connect(
                        self.set_current_item)
            elif dept in Department.BACKEND:
                for shot in self.project.list_shots():
                    item = QtGui.QListWidgetItem(shot)
                    element_list.addItem(item)
                    element_list.currentItemChanged.connect(
                        self.set_current_item)
            tab_layout.addWidget(element_list)
            tab_layout.addWidget(commentBox)
            tab.setLayout(tab_layout)

        #create buttons
        self.checkout_button = QtGui.QPushButton('Checkout')
        self.checkout_button.clicked.connect(self.checkout)
        self.cancel_button = QtGui.QPushButton('Cancel')
        self.cancel_button.clicked.connect(self.close)

        #create button layout
        button_layout = QtGui.QHBoxLayout()
        button_layout.addWidget(self.checkout_button)
        button_layout.addWidget(self.cancel_button)

        self.img = QtGui.QLabel()
        pixmap = QtGui.QPixmap(os.environ['BYU_TOOLS_DIR'] +
                               '/byugui/assets/images/taijitu.jpg')
        scaled = pixmap.scaledToWidth(self.size().width())
        self.img.setPixmap(scaled)

        #create main layout
        main_layout = QtGui.QVBoxLayout()
        self.setLayout(main_layout)
        main_layout.addWidget(self.img)
        main_layout.setSpacing(5)
        main_layout.setMargin(6)
        main_layout.addWidget(self.dept_tabs)
        main_layout.addLayout(button_layout)

        self.show()

    def set_current_item(self, index):
        current_dept = self.dept_list[self.dept_tabs.currentIndex()]
        if current_dept in Department.FRONTEND:
            self.current_item = str(index.text())
        elif current_dept in Department.BACKEND:
            self.current_item = str(index.text())

        asset_obj = self.project.get_body(self.current_item)
        element_obj = asset_obj.get_element(current_dept)
        last_publish = element_obj.get_last_publish()
        last_publish_comment = None
        if last_publish is not None:
            last_publish_comment = "Last published {0} by {1} \n \"{2}\"".format(
                last_publish[1], last_publish[0], last_publish[2])
        else:
            last_publish_comment = "No publishes for this element"
        currentTab = self.dept_tabs.currentWidget()
        currentTab.commentBox.setText(last_publish_comment)

    def checkout(self):
        """
        Checks out the currently selected item
        :return:
        """
        current_user = self.environment.get_current_username()
        current_dept = self.dept_list[self.dept_tabs.currentIndex()]
        asset_obj = self.project.get_body(self.current_item)
        element_obj = asset_obj.get_element(current_dept)
        element_path = element_obj.checkout(current_user)
        if element_path != None:
            self.result = element_path
            self.close()

    def closeEvent(self, event):
        self.finished.emit()
        event.accept()
    def __init__(self):
        QtGui.QWidget.__init__(self)
        self.setWindowTitle("Element Browser")
        self.setGeometry(0, 0, REF_WINDOW_WIDTH, REF_WINDOW_HEIGHT)
        self.palette = self.dark_palette()
        self.setPalette(self.palette)

        # initialize project
        self.project = Project()
        self.user_list = self.project.list_users()
        self.user_completer = QtGui.QCompleter(self.user_list)

        #filters
        self.filter_label = QtGui.QLabel("Filter by: ")

        self.dept_filter_label = QtGui.QLabel("Department")
        self.dept_filter_label.setAlignment(QtCore.Qt.AlignRight | QtCore.Qt.AlignVCenter)
        self.dept_filter = QtGui.QComboBox()
        self.dept_filter.addItem("all")
        for each in Department.ALL:
            self.dept_filter.addItem(each)
        self.dept_list = Department.ALL

        self.type_filter_label = QtGui.QLabel("Asset Type")
        self.type_filter_label.setAlignment(QtCore.Qt.AlignRight | QtCore.Qt.AlignVCenter)
        self.type_filter = QtGui.QComboBox()
        self.type_filter.addItem("all")
        for each in AssetType.ALL:
            self.type_filter.addItem(each)

        self.name_filter_label = QtGui.QLabel("Name")
        self.name_filter_label.setAlignment(QtCore.Qt.AlignRight | QtCore.Qt.AlignVCenter)
        self.name_filter = QtGui.QLineEdit()

        # menu bar
        self.menu_bar = QtGui.QMenuBar()
        self.view_menu = QtGui.QMenu("View")
        self.menu_bar.addMenu(self.view_menu)
        self.expand_action = self.view_menu.addAction("Expand All")
        self.user_list_action = self.view_menu.addAction("User Directory")
        self.theme_action = self.view_menu.addAction("Default Theme")
        self.theme_action.setCheckable(True)

        # asset/shot menu
        self.body_menu = QtGui.QComboBox()
        self.body_menu.addItem(self.ASSETS)
        self.body_menu.addItem(self.SHOTS)
        self.current_body = self.ASSETS
        self._set_bodies()

        # new button
        self.new_button = QtGui.QPushButton("New")

        # refresh button
        self.refresh_button = QtGui.QPushButton("Refresh")

        # tree
        self.tree = QtGui.QTreeWidget()
        self.tree.setItemDelegate(TreeGridDelegate(self.tree))
        self.columnCount = 8
        self.tree.setColumnCount(self.columnCount)
        tree_header = QtGui.QTreeWidgetItem(["name", "", "assigned", "status", "start", "end", "publish", "note"])
        self.tree.setHeaderItem(tree_header)
        tree_header_view = self.tree.header()
        tree_header_view.resizeSection(4, 120)
        tree_header_view.resizeSection(5, 120)

        self.init_tree = [None]*self.columnCount
        self.init_tree[0] = self.init_name
        self.init_tree[1] = self.init_dept
        self.init_tree[2] = self.init_assigned_user
        self.init_tree[3] = self.init_status
        self.init_tree[4] = self.init_start_date
        self.init_tree[5] = self.init_end_date
        self.init_tree[6] = self.init_last_publish
        self.init_tree[7] = self.init_note

        self._build_tree()

        self.update_tree = [None]*self.columnCount
        self.update_tree[0] = self.update_name
        self.update_tree[1] = self.update_dept
        self.update_tree[2] = self.update_assigned_user
        self.update_tree[3] = self.update_status
        self.update_tree[4] = self.update_start_date
        self.update_tree[5] = self.update_end_date
        self.update_tree[6] = self.update_last_publish
        self.update_tree[7] = self.update_note
        
        # status bar
        self.status_bar = QtGui.QStatusBar()

        # connect events
        self.expand_action.triggered.connect(self._expand_all)
        self.user_list_action.triggered.connect(self._show_user_directory)
        self.theme_action.triggered.connect(self._toggle_theme)
        self.body_menu.currentIndexChanged.connect(self._body_changed)
        self.new_button.clicked.connect(self._new_body)
        self.refresh_button.clicked.connect(self._refresh)
        self.tree.itemExpanded.connect(self._load_elements)
        self.tree.itemChanged.connect(self._item_edited)
        self.dept_filter.currentIndexChanged.connect(self._dept_filter_changed)
        self.name_filter.editingFinished.connect(self._filter_by_name)
        self.type_filter.currentIndexChanged.connect(self._refresh)

        # layout
        layout = QtGui.QVBoxLayout(self)
        layout.setSpacing(5)
        layout.setMargin(6)
        options_layout = QtGui.QGridLayout()
        options_layout.addWidget(self.body_menu, 0, 0)
        options_layout.addWidget(self.new_button, 0, 1)
        options_layout.addWidget(self.refresh_button, 0, 3)
        options_layout.setColumnMinimumWidth(0, 100)
        options_layout.setColumnMinimumWidth(1, 100)
        options_layout.setColumnMinimumWidth(3, 100)
        options_layout.setColumnStretch(2, 1)
        filter_layout = QtGui.QGridLayout()
        filter_layout.addWidget(self.filter_label, 0, 0)
        filter_layout.addWidget(self.dept_filter_label, 0, 1)
        filter_layout.addWidget(self.dept_filter, 0, 2)
        filter_layout.addWidget(self.name_filter_label, 0, 3)
        filter_layout.addWidget(self.name_filter, 0, 4)
        filter_layout.addWidget(self.type_filter_label, 0, 5)
        filter_layout.addWidget(self.type_filter, 0, 6)
        filter_layout.setColumnMinimumWidth(0, 50)
        filter_layout.setColumnMinimumWidth(1, 100)
        filter_layout.setColumnMinimumWidth(2, 100)
        filter_layout.setColumnMinimumWidth(3, 100)
        filter_layout.setColumnMinimumWidth(4, 100)
        filter_layout.setColumnMinimumWidth(5, 100)
        filter_layout.setColumnMinimumWidth(6, 100)
        
        filter_layout.setColumnStretch(7, 1)
        layout.addWidget(self.menu_bar)
        layout.addLayout(options_layout)
        layout.addWidget(self.tree)
        layout.addLayout(filter_layout)
        
        layout.addWidget(self.status_bar)
        self.setLayout(layout)

        request_email.check_user_email(self)
Example #36
0
def simpleBlast(startFrame, endFrame):
	
	src_dir = os.path.dirname(mc.file(q=True, sceneName=True))
	project = Project()
	playblast_element = project.get_checkout_element(src_dir)
	playblast_dept = None
	playblast_body_name = None
	playblast_dir = src_dir
	playblast_filename = "playblast.mov"
	if playblast_element is not None:
		playblast_dir = playblast_element.get_render_dir()
		playblast_filename = playblast_element.get_name()+".mov"
		playblast_dept = playblast_element.get_department()
		playblast_body_name = playblast_element.get_parent()
	name = os.path.join(playblast_dir, playblast_filename)
	
	currentPanel = mc.getPanel(wf=True)
	currentCamera = mc.modelEditor(currentPanel, q=True, camera=True)

	panelSwitch = []
	panelSwitch.append(mc.modelEditor(currentPanel, q=True, nc=True))
	panelSwitch.append(mc.modelEditor(currentPanel, q=True, ns=True))
	panelSwitch.append(mc.modelEditor(currentPanel, q=True, pm=True))
	panelSwitch.append(mc.modelEditor(currentPanel, q=True, sds=True))
	panelSwitch.append(mc.modelEditor(currentPanel, q=True, pl=True))
	panelSwitch.append(mc.modelEditor(currentPanel, q=True, lt=True))
	panelSwitch.append(mc.modelEditor(currentPanel, q=True, ca=True))
	panelSwitch.append(mc.modelEditor(currentPanel, q=True, j=True))
	panelSwitch.append(mc.modelEditor(currentPanel, q=True, ikh=True))
	panelSwitch.append(mc.modelEditor(currentPanel, q=True, df=True))
	panelSwitch.append(mc.modelEditor(currentPanel, q=True, dy=True))
	panelSwitch.append(mc.modelEditor(currentPanel, q=True, fl=True))
	panelSwitch.append(mc.modelEditor(currentPanel, q=True, hs=True))
	panelSwitch.append(mc.modelEditor(currentPanel, q=True, fo=True))
	panelSwitch.append(mc.modelEditor(currentPanel, q=True, lc=True))
	panelSwitch.append(mc.modelEditor(currentPanel, q=True, dim=True))
	panelSwitch.append(mc.modelEditor(currentPanel, q=True, ha=True))
	panelSwitch.append(mc.modelEditor(currentPanel, q=True, pv=True))
	panelSwitch.append(mc.modelEditor(currentPanel, q=True, tx=True))
	panelSwitch.append(mc.modelEditor(currentPanel, q=True, str=True))
	panelSwitch.append(mc.modelEditor(currentPanel, q=True, gr=True))
	panelSwitch.append(mc.modelEditor(currentPanel, q=True, cv=True))
	panelSwitch.append(mc.modelEditor(currentPanel, q=True, hu=True))

	mel.eval("lookThroughModelPanel "+currentCamera+" "+currentPanel)
	mc.modelEditor(currentPanel, e=True, allObjects=0)
	mc.modelEditor(currentPanel, e=True, polymeshes=1)
	mc.modelEditor(currentPanel, e=True, nurbsSurfaces=0)
	mc.modelEditor(currentPanel, e=True, strokes=1)
	mc.modelEditor(currentPanel, e=True, cameras=0)

	playback_slider = mel.eval('$tmpVar=$gPlayBackSlider')
	soundfile = mc.timeControl(playback_slider, q=True, sound=True)
	print soundfile

	mc.playblast(st=startFrame, et=endFrame, sound=soundfile, fmt="qt", compression="jpeg", qlt=100, forceOverwrite=True, filename=name,
	width=1920, height=817, offScreen=True, percent=100, v=False)

	mel.eval("lookThroughModelPanel "+currentCamera+" "+currentPanel)
	mc.modelEditor(currentPanel, e=True, nc=panelSwitch[0])
	mc.modelEditor(currentPanel, e=True, ns=panelSwitch[1])
	mc.modelEditor(currentPanel, e=True, pm=panelSwitch[2])
	mc.modelEditor(currentPanel, e=True, sds=panelSwitch[3])
	mc.modelEditor(currentPanel, e=True, pl=panelSwitch[4])
	mc.modelEditor(currentPanel, e=True, lt=panelSwitch[5])
	mc.modelEditor(currentPanel, e=True, ca=panelSwitch[6])
	mc.modelEditor(currentPanel, e=True, j=panelSwitch[7])
	mc.modelEditor(currentPanel, e=True, ikh=panelSwitch[8])
	mc.modelEditor(currentPanel, e=True, df=panelSwitch[9])
	mc.modelEditor(currentPanel, e=True, dy=panelSwitch[10])
	mc.modelEditor(currentPanel, e=True, fl=panelSwitch[11])
	mc.modelEditor(currentPanel, e=True, hs=panelSwitch[12])
	mc.modelEditor(currentPanel, e=True, fo=panelSwitch[13])
	mc.modelEditor(currentPanel, e=True, lc=panelSwitch[14])
	mc.modelEditor(currentPanel, e=True, dim=panelSwitch[15])
	mc.modelEditor(currentPanel, e=True, ha=panelSwitch[16])
	mc.modelEditor(currentPanel, e=True, pv=panelSwitch[17])
	mc.modelEditor(currentPanel, e=True, tx=panelSwitch[18])
	mc.modelEditor(currentPanel, e=True, str=panelSwitch[19])
	mc.modelEditor(currentPanel, e=True, gr=panelSwitch[20])
	mc.modelEditor(currentPanel, e=True, cv=panelSwitch[21])
	mc.modelEditor(currentPanel, e=True, hu=panelSwitch[22])
def generateScene():
    project = Project()
    environment = Environment()

    # Create a global position locator for Ten's Starting Location
    mc.currentTime(STARTANIM)
    globalPos = mc.spaceLocator(p=[0, 0, 0])
    globPos = mc.rename(globalPos, "tenGlobalPos")
    mc.select("ten_rig_main_m_global_CTL")
    mc.select(globPos, add=True)
    mc.pointConstraint(offset=[0, 0, 0], weight=1)
    mc.orientConstraint(offset=[0, 0, 0], weight=1)

    # Get transformation variables from globPos locator
    tx = mc.getAttr(globPos + ".translateX")
    ty = mc.getAttr(globPos + ".translateY")
    tz = mc.getAttr(globPos + ".translateZ")
    rx = mc.getAttr(globPos + ".rotateX")
    ry = mc.getAttr(globPos + ".rotateY")
    rz = mc.getAttr(globPos + ".rotateZ")

    # get alembic filepath for scene's animation (requires prior export)
    src = mc.file(q=True, sceneName=True)
    src_dir = os.path.dirname(src)
    checkout_element = project.get_checkout_element(src_dir)
    checkout_body_name = checkout_element.get_parent()
    body = project.get_body(checkout_body_name)
    element = body.get_element(Department.ANIM)
    cache_file = os.path.join(element.get_dir(), "cache", "ten_rig_main.abc")

    # checkout cfx scene for corresponding shot number
    current_user = environment.get_current_username()
    element = body.get_element(Department.CFX)
    cfx_filepath = element.checkout(current_user)

    #open cfx file
    if cfx_filepath is not None:
        if not mc.file(q=True, sceneName=True) == '':
            mc.file(save=True, force=True)  #save file

        if not os.path.exists(cfx_filepath):
            mc.file(new=True, force=True)
            mc.file(rename=cfx_filepath)
            mc.file(save=True, force=True)
        else:
            mc.file(cfx_filepath, open=True, force=True)

    # import alembic
    command = "AbcImport -mode import \"" + cache_file + "\""
    maya.mel.eval(command)

    # delete all geo except ten's skin and rename
    geometry = mc.ls(geometry=True)
    transforms = mc.listRelatives(geometry, p=True, path=True)
    mc.select(transforms, r=True)
    for geo in mc.ls(sl=True):
        if (geo != "ten_rig_main_Ten_Skin_RENDER"):
            mc.delete(geo)
    collide = "TEN_ANIM"
    mc.rename("ten_rig_main_Ten_Skin_RENDER", collide)

    # Reference Ten's Sim Robe
    body = project.get_body("ten_robe_sim")
    element = body.get_element(Department.MODEL)
    robe_file = element.get_app_filepath()
    mc.file(robe_file, reference=True)

    # Reference Ten's Hero Robe
    body = project.get_body("ten_robe")
    element = body.get_element(Department.MODEL)
    robe_hero_file = element.get_app_filepath()
    mc.file(robe_hero_file, reference=True)

    # Set Sim Robe transforms to variables above
    mc.setAttr("ten_robe_sim_model_main_ten_cloth.translateX", tx)
    mc.setAttr("ten_robe_sim_model_main_ten_cloth.translateY", ty)
    mc.setAttr("ten_robe_sim_model_main_ten_cloth.translateZ", tz)
    mc.setAttr("ten_robe_sim_model_main_ten_cloth.rotateX", rx)
    mc.setAttr("ten_robe_sim_model_main_ten_cloth.rotateY", ry)
    mc.setAttr("ten_robe_sim_model_main_ten_cloth.rotateZ", rz)

    # Set Hero Robe transforms to variables above
    mc.setAttr("ten_robe_model_main_TEN_ROBE_HERO.translateX", tx)
    mc.setAttr("ten_robe_model_main_TEN_ROBE_HERO.translateY", ty)
    mc.setAttr("ten_robe_model_main_TEN_ROBE_HERO.translateZ", tz)
    mc.setAttr("ten_robe_model_main_TEN_ROBE_HERO.rotateX", rx)
    mc.setAttr("ten_robe_model_main_TEN_ROBE_HERO.rotateY", ry)
    mc.setAttr("ten_robe_model_main_TEN_ROBE_HERO.rotateZ", rz)
def go():
    project = Project()
    environment = Environment()

    # Create a global position locator which will grab Jampa's position despite his scaled translations
    mc.currentTime(0)
    globalPos = mc.spaceLocator(p=[0,0,0])
    globPos = mc.rename(globalPos, "jampaGlobalPos")
    mc.select("jampa_rig_main_global_cc_01")
    mc.select(globPos, add=True)
    mc.pointConstraint(offset=[0,0,0], weight=1)
    mc.orientConstraint(offset=[0,0,0], weight=1)

    # Get transformation variables from globPos locator
    tx = mc.getAttr(globPos+".translateX")
    ty = mc.getAttr(globPos+".translateY")
    tz = mc.getAttr(globPos+".translateZ")
    rx = mc.getAttr(globPos+".rotateX")
    ry = mc.getAttr(globPos+".rotateY")
    rz = mc.getAttr(globPos+".rotateZ")

    # get alembic filepath for scene's animation (requires prior export)
    src = mc.file(q=True, sceneName=True)
    src_dir = os.path.dirname(src)
    checkout_element = project.get_checkout_element(src_dir)
    checkout_body_name = checkout_element.get_parent()
    body = project.get_body(checkout_body_name)
    element = body.get_element(Department.ANIM)
    cache_file = os.path.join(element.get_dir(), "cache", "jampa_rig_main.abc")

    # checkout cfx scene for corresponding shot number
    current_user = environment.get_current_username()
    element = body.get_element(Department.CFX)
    cfx_filepath = element.checkout(current_user)

    #open cfx file 
    if cfx_filepath is not None:
        if not mc.file(q=True, sceneName=True) == '':
            mc.file(save=True, force=True) #save file

        if not os.path.exists(cfx_filepath):
            mc.file(new=True, force=True)
            mc.file(rename=cfx_filepath)
            mc.file(save=True, force=True)
        else:
            mc.file(cfx_filepath, open=True, force=True)

    # import alembic
    command = "AbcImport -mode import \"" + cache_file + "\""
    maya.mel.eval(command)

    # delete all geo except jampa skin and rename
    geometry = mc.ls(geometry=True)
    transforms = mc.listRelatives(geometry, p=True, path=True)
    mc.select(transforms, r=True)
    for geo in mc.ls(sl=True):
        if(geo != "jampa_rig_main_jampa_geo_body"):
            mc.delete(geo)
    collide = "JAMPA_COLLIDE"
    mc.rename("jampa_rig_main_jampa_geo_body", collide)

    # reference robe
    body = project.get_body("jampa_robe")
    element = body.get_element(Department.MODEL)
    robe_file = element.get_app_filepath()
    mc.file(robe_file, reference=True)

    # set robe transforms to variables above
    mc.setAttr("jampa_robe_model_main_jampa_robe_sim.translateX", tx)
    mc.setAttr("jampa_robe_model_main_jampa_robe_sim.translateY", ty)
    mc.setAttr("jampa_robe_model_main_jampa_robe_sim.translateZ", tz)
    mc.setAttr("jampa_robe_model_main_jampa_robe_sim.rotateX", rx)
    mc.setAttr("jampa_robe_model_main_jampa_robe_sim.rotateY", ry)
    mc.setAttr("jampa_robe_model_main_jampa_robe_sim.rotateZ", rz)

    # make jampa skin a passive collider
    mc.select(collide)
    command = "makeCollideNCloth"
    maya.mel.eval(command)
    rigid_shape = "nRigid_jampa"
    mc.rename("nRigid1", rigid_shape)
    mc.setAttr(rigid_shape+".stickiness", 0.2)
    mc.setAttr(rigid_shape+".friction", 0.5)

    # make cloth objects and display layers of each robe piece
    jampa_torso = "jampa_robe_model_main_robe_torso_01"
    jampa_sash = "jampa_robe_model_main_robe_sash_01"
    jampa_skirt = "jampa_robe_model_main_robe_skirt_01"

    cloth_pieces = {jampa_torso, jampa_sash, jampa_skirt}
    command = "createNCloth 0"
    for cp in cloth_pieces:
        mc.select(cp)
        maya.mel.eval(command)
        mc.rename("nCloth1", "nCloth_"+cp)
        mc.select(cp)
        layername = "cloth_"+cp[:-3].replace("robe_model_main_robe_", "")
        mc.createDisplayLayer(name=layername.upper(), number=1, noRecurse=True)

    # set appropriate values in nucleus node
    nucleus = "nucleus_jampa"
    mc.rename("nucleus1", nucleus)
    mc.setAttr(nucleus+".subSteps", 30)
    mc.setAttr(nucleus+".startFrame", -30)
    mc.setAttr(nucleus+".spaceScale", 0.23)

    mc.currentTime(-50)
 def __init__(self, parent, dept_list=Department.ALL):
     super(CheckoutWindow, self).__init__()
     self.parent = parent
     self.project = Project()
     self.environment = Environment()
     self.initUI(dept_list)
def generateScene():
    project = Project()
    environment = Environment()

    # Create a global position locator for Ten's Starting Location
    mc.currentTime(STARTANIM)
    globalPos = mc.spaceLocator(p=[0,0,0])
    globPos = mc.rename(globalPos, "tenGlobalPos")
    mc.select("ten_rig_main_m_global_CTL")
    mc.select(globPos, add=True)
    mc.pointConstraint(offset=[0,0,0], weight=1)
    mc.orientConstraint(offset=[0,0,0], weight=1)

    # Get transformation variables from globPos locator
    tx = mc.getAttr(globPos+".translateX")
    ty = mc.getAttr(globPos+".translateY")
    tz = mc.getAttr(globPos+".translateZ")
    rx = mc.getAttr(globPos+".rotateX")
    ry = mc.getAttr(globPos+".rotateY")
    rz = mc.getAttr(globPos+".rotateZ")

    # get alembic filepath for scene's animation (requires prior export)
    src = mc.file(q=True, sceneName=True)
    src_dir = os.path.dirname(src)
    checkout_element = project.get_checkout_element(src_dir)
    checkout_body_name = checkout_element.get_parent()
    body = project.get_body(checkout_body_name)
    element = body.get_element(Department.ANIM)
    cache_file = os.path.join(element.get_dir(), "cache", "ten_rig_main.abc")

    # checkout cfx scene for corresponding shot number
    current_user = environment.get_current_username()
    element = body.get_element(Department.CFX)
    cfx_filepath = element.checkout(current_user)

    #open cfx file 
    if cfx_filepath is not None:
        if not mc.file(q=True, sceneName=True) == '':
            mc.file(save=True, force=True) #save file

        if not os.path.exists(cfx_filepath):
            mc.file(new=True, force=True)
            mc.file(rename=cfx_filepath)
            mc.file(save=True, force=True)
        else:
            mc.file(cfx_filepath, open=True, force=True)

    # import alembic
    command = "AbcImport -mode import \"" + cache_file + "\""
    maya.mel.eval(command)

    # delete all geo except ten's skin and rename
    geometry = mc.ls(geometry=True)
    transforms = mc.listRelatives(geometry, p=True, path=True)
    mc.select(transforms, r=True)
    for geo in mc.ls(sl=True):
        if(geo != "ten_rig_main_Ten_Skin_RENDER"):
            mc.delete(geo)
    collide = "TEN_ANIM"
    mc.rename("ten_rig_main_Ten_Skin_RENDER", collide)

    # Reference Ten's Sim Robe
    body = project.get_body("ten_robe_sim")
    element = body.get_element(Department.MODEL)
    robe_file = element.get_app_filepath()
    mc.file(robe_file, reference=True)
    
    # Reference Ten's Hero Robe
    body = project.get_body("ten_robe")
    element = body.get_element(Department.MODEL)
    robe_hero_file = element.get_app_filepath()
    mc.file(robe_hero_file, reference=True)
    
    # Set Sim Robe transforms to variables above
    mc.setAttr("ten_robe_sim_model_main_ten_cloth.translateX", tx)
    mc.setAttr("ten_robe_sim_model_main_ten_cloth.translateY", ty)
    mc.setAttr("ten_robe_sim_model_main_ten_cloth.translateZ", tz)
    mc.setAttr("ten_robe_sim_model_main_ten_cloth.rotateX", rx)
    mc.setAttr("ten_robe_sim_model_main_ten_cloth.rotateY", ry)
    mc.setAttr("ten_robe_sim_model_main_ten_cloth.rotateZ", rz)
    
    # Set Hero Robe transforms to variables above
    mc.setAttr("ten_robe_model_main_TEN_ROBE_HERO.translateX", tx)
    mc.setAttr("ten_robe_model_main_TEN_ROBE_HERO.translateY", ty)
    mc.setAttr("ten_robe_model_main_TEN_ROBE_HERO.translateZ", tz)
    mc.setAttr("ten_robe_model_main_TEN_ROBE_HERO.rotateX", rx)
    mc.setAttr("ten_robe_model_main_TEN_ROBE_HERO.rotateY", ry)
    mc.setAttr("ten_robe_model_main_TEN_ROBE_HERO.rotateZ", rz)
Example #41
0
class SelectionWindow(QtWidgets.QDialog):

    finished = QtCore.Signal()

    def __init__(self, parent, dept_list=Department.ALL, showWindow=True):
        super(SelectionWindow, self).__init__()
        self.parent = parent
        self.project = Project()
        self.environment = Environment()
        self.initUI(dept_list, showWindow)

    def initUI(self, dept_list, showWindow):
        #define gui elements
        self.resize(WINDOW_WIDTH, WINDOW_HEIGHT)
        self.setWindowTitle('Select Asset')
        self.dept_tabs = QtWidgets.QTabWidget()
        self.dept_list = dept_list
        self.result = None
        self.instructions = QtWidgets.QLabel(
            'Select the asset you would like affect:')

        #create Tabs
        self.createTabs()

        #create buttons
        self.select_button = QtWidgets.QPushButton('Select')
        self.select_button.clicked.connect(self.select)
        self.cancel_button = QtWidgets.QPushButton('Cancel')
        self.cancel_button.clicked.connect(self.close)

        #create button layout
        button_layout = QtWidgets.QHBoxLayout()
        button_layout.addWidget(self.select_button)
        button_layout.addWidget(self.cancel_button)

        self.img = QtWidgets.QLabel()
        image_path = os.path.join(os.environ['BYU_TOOLS_DIR'], 'byugui',
                                  'assets', 'images', 'film-banner.jpg')
        pixmap = QtGui.QPixmap(image_path)
        scaled = pixmap.scaledToWidth(self.size().width())
        self.img.setPixmap(scaled)

        #create main layout
        main_layout = QtWidgets.QVBoxLayout()
        self.setLayout(main_layout)
        main_layout.addWidget(self.img)
        main_layout.setSpacing(5)
        # main_layout.setMargin(6)
        main_layout.addWidget(self.instructions)
        main_layout.addWidget(self.dept_tabs)
        main_layout.addLayout(button_layout)

        if showWindow:
            self.show()

    def createTabs(self):
        #remember the current index so that we can restore it when we create the tabs
        currIndex = self.dept_tabs.currentIndex()
        #clear out the old tabs
        self.dept_tabs.clear()
        #create tabs
        for dept in self.dept_list:
            tab = DepartmentTab(self)
            self.dept_tabs.addTab(tab, dept)
            tab_layout = QtWidgets.QHBoxLayout()
            element_list = QtWidgets.QListWidget()

            if dept in Department.ASSET_DEPTS:
                for asset in self.project.list_assets():
                    item = QtWidgets.QListWidgetItem(asset)
                    element_list.addItem(item)
                    element_list.currentItemChanged.connect(
                        self.set_current_item)
            elif dept in Department.SHOT_DEPTS:
                for shot in self.project.list_shots():
                    item = QtWidgets.QListWidgetItem(shot)
                    element_list.addItem(item)
                    element_list.currentItemChanged.connect(
                        self.set_current_item)
            tab_layout.addWidget(element_list)
            tab.setLayout(tab_layout)

        #restore the previous index
        self.dept_tabs.setCurrentIndex(currIndex)

    def set_current_item(self, index):
        current_dept = self.dept_list[self.dept_tabs.currentIndex()]
        if current_dept in Department.ASSET_DEPTS:
            self.current_item = str(index.text())
        elif current_dept in Department.SHOT_DEPTS:
            self.current_item = str(index.text())

        asset_obj = self.project.get_body(self.current_item)
        element_obj = asset_obj.get_element(current_dept)
        last_publish = element_obj.get_last_publish()
        last_publish_comment = None
        if last_publish is not None:
            last_publish_comment = 'Last published {0} by {1} \n \"{2}\"'.format(
                last_publish[1], last_publish[0], last_publish[2])
        else:
            last_publish_comment = 'No publishes for this element'
        currentTab = self.dept_tabs.currentWidget()

    def hasPreviousPublish(self, body, department):
        asset_obj = self.project.get_body(body)
        element_obj = asset_obj.get_element(department)
        last_publish = element_obj.get_last_publish()
        if last_publish is None:
            return False
        return True

    def select(self):
        '''
		Selects the currently selected item
		:return:
		'''
        current_user = self.environment.get_current_username()
        current_dept = self.dept_list[self.dept_tabs.currentIndex()]

        asset_obj = self.project.get_body(self.current_item)
        element_obj = asset_obj.get_element(current_dept)
        if element_obj != None:
            self.result = element_obj
            self.close()

    def closeEvent(self, event):
        self.finished.emit()
        event.accept()
    def __init__(self):
        QtGui.QWidget.__init__(self)
        self.setWindowTitle("Element Browser")
        self.setGeometry(0, 0, REF_WINDOW_WIDTH, REF_WINDOW_HEIGHT)
        self.palette = self.dark_palette()
        self.setPalette(self.palette)

        # initialize project
        self.project = Project()
        self.user_list = self.project.list_users()
        self.user_completer = QtGui.QCompleter(self.user_list)

        #filters
        self.filter_label = QtGui.QLabel("Filter by: ")

        self.dept_filter_label = QtGui.QLabel("Department")
        self.dept_filter_label.setAlignment(QtCore.Qt.AlignRight | QtCore.Qt.AlignVCenter)
        self.dept_filter = QtGui.QComboBox()
        self.dept_filter.addItem("all")
        for each in Department.ALL:
            self.dept_filter.addItem(each)
        self.dept_list = Department.ALL

        self.type_filter_label = QtGui.QLabel("Asset Type")
        self.type_filter_label.setAlignment(QtCore.Qt.AlignRight | QtCore.Qt.AlignVCenter)
        self.type_filter = QtGui.QComboBox()
        self.type_filter.addItem("all")
        for each in AssetType.ALL:
            self.type_filter.addItem(each)

        self.name_filter_label = QtGui.QLabel("Name")
        self.name_filter_label.setAlignment(QtCore.Qt.AlignRight | QtCore.Qt.AlignVCenter)
        self.name_filter = QtGui.QLineEdit()

        # menu bar
        self.menu_bar = QtGui.QMenuBar()
        self.view_menu = QtGui.QMenu("View")
        self.menu_bar.addMenu(self.view_menu)
        self.expand_action = self.view_menu.addAction("Expand All")
        self.user_list_action = self.view_menu.addAction("User Directory")
        self.theme_action = self.view_menu.addAction("Default Theme")
        self.theme_action.setCheckable(True)

        # asset/shot menu
        self.body_menu = QtGui.QComboBox()
        self.body_menu.addItem(self.ASSETS)
        self.body_menu.addItem(self.SHOTS)
        self.current_body = self.ASSETS
        self._set_bodies()

        # new button
        self.new_button = QtGui.QPushButton("New")

        # refresh button
        self.refresh_button = QtGui.QPushButton("Refresh")

        # tree
        self.tree = QtGui.QTreeWidget()
        self.tree.setItemDelegate(TreeGridDelegate(self.tree))
        self.columnCount = 8
        self.tree.setColumnCount(self.columnCount)
        tree_header = QtGui.QTreeWidgetItem(["name", "", "assigned", "status", "start", "end", "publish", "note"])
        self.tree.setHeaderItem(tree_header)

        self.init_tree = [None]*self.columnCount
        self.init_tree[0] = self.init_name
        self.init_tree[1] = self.init_dept
        self.init_tree[2] = self.init_assigned_user
        self.init_tree[3] = self.init_status
        self.init_tree[4] = self.init_start_date
        self.init_tree[5] = self.init_end_date
        self.init_tree[6] = self.init_last_publish
        self.init_tree[7] = self.init_note

        self._build_tree()

        self.update_tree = [None]*self.columnCount
        self.update_tree[0] = self.update_name
        self.update_tree[1] = self.update_dept
        self.update_tree[2] = self.update_assigned_user
        self.update_tree[3] = self.update_status
        self.update_tree[4] = self.update_start_date
        self.update_tree[5] = self.update_end_date
        self.update_tree[6] = self.update_last_publish
        self.update_tree[7] = self.update_note
        
        # status bar
        self.status_bar = QtGui.QStatusBar()

        # connect events
        self.expand_action.triggered.connect(self._expand_all)
        self.user_list_action.triggered.connect(self._show_user_directory)
        self.theme_action.triggered.connect(self._toggle_theme)
        self.body_menu.currentIndexChanged.connect(self._body_changed)
        self.new_button.clicked.connect(self._new_body)
        self.refresh_button.clicked.connect(self._refresh)
        self.tree.itemExpanded.connect(self._load_elements)
        self.tree.itemChanged.connect(self._item_edited)
        self.dept_filter.currentIndexChanged.connect(self._dept_filter_changed)
        self.name_filter.editingFinished.connect(self._filter_by_name)
        self.type_filter.currentIndexChanged.connect(self._refresh)

        # layout
        layout = QtGui.QVBoxLayout(self)
        layout.setSpacing(5)
        layout.setMargin(6)
        options_layout = QtGui.QGridLayout()
        options_layout.addWidget(self.body_menu, 0, 0)
        options_layout.addWidget(self.new_button, 0, 1)
        options_layout.addWidget(self.refresh_button, 0, 3)
        options_layout.setColumnMinimumWidth(0, 100)
        options_layout.setColumnMinimumWidth(1, 100)
        options_layout.setColumnMinimumWidth(3, 100)
        options_layout.setColumnStretch(2, 1)
        filter_layout = QtGui.QGridLayout()
        filter_layout.addWidget(self.filter_label, 0, 0)
        filter_layout.addWidget(self.dept_filter_label, 0, 1)
        filter_layout.addWidget(self.dept_filter, 0, 2)
        filter_layout.addWidget(self.name_filter_label, 0, 3)
        filter_layout.addWidget(self.name_filter, 0, 4)
        filter_layout.addWidget(self.type_filter_label, 0, 5)
        filter_layout.addWidget(self.type_filter, 0, 6)
        filter_layout.setColumnMinimumWidth(0, 50)
        filter_layout.setColumnMinimumWidth(1, 100)
        filter_layout.setColumnMinimumWidth(2, 100)
        filter_layout.setColumnMinimumWidth(3, 100)
        filter_layout.setColumnMinimumWidth(4, 100)
        filter_layout.setColumnMinimumWidth(5, 100)
        filter_layout.setColumnMinimumWidth(6, 100)
        cal = QtGui.QCalendarWidget()
        
        filter_layout.setColumnStretch(7, 1)
        layout.addWidget(self.menu_bar)
        layout.addLayout(options_layout)
        layout.addWidget(self.tree)
        layout.addLayout(filter_layout)
        # layout.addWidget(self.filter_label)
        # layout.addWidget(self.type_filter)
        # layout.addWidget(self.dept_filter)
        layout.addWidget(self.status_bar)
        self.setLayout(layout)

        request_email.check_user_email(self)
 def __init__(self, parent):
     super(AssetListWindow, self).__init__()
     self.parent = parent
     self.current_selection = None
     self.project = Project()
     self.initUI()
Example #44
0
class PublishWindow(QtGui.QWidget):

    finished = QtCore.pyqtSignal()

    def __init__(self, src, parent, dept_list=Department.ALL):
        super(PublishWindow, self).__init__()
        self.environment = Environment()
        self.project = Project()
        self.eList = ElementList(self)
        self.parent = parent
        self.src = src
        self.result = None
        self.elementType = None
        self.initUI(dept_list)
        self.published = False
        
    def initUI(self, dept_list):
        #load checkout information
        src_dir = os.path.dirname(self.src)
        checkout_element = self.project.get_checkout_element(src_dir)
        checkout_dept = None
        checkout_body_name = None
        if checkout_element is not None:
            checkout_dept = checkout_element.get_department()
            checkout_body_name = checkout_element.get_parent()

        #define gui elements
        self.setGeometry(300,300,WINDOW_WIDTH,WINDOW_HEIGHT)
        self.setWindowTitle('Publish')
        self.menu = QtGui.QComboBox()
        self.menu.addItem('Asset')
        self.menu.addItem('Shot')
        self.departmentMenu = QtGui.QComboBox()
        checkout_idx = -1
        for i, dept in enumerate(dept_list):
            self.departmentMenu.addItem(dept)
            if dept==checkout_dept:
                checkout_idx = i
        
        self.departmentMenu.activated[str].connect(self.setElementType)
        self.filePath = QtGui.QLineEdit()
        self.filePath.setReadOnly(True)
        self.label = QtGui.QLabel('What did you change?')
        self.comment = QtGui.QTextEdit()
        self.publishBtn = QtGui.QPushButton('Publish')
        self.publishBtn.setEnabled(False)
        
        self.eList.currentItemChanged.connect(self.selectElement)
        self.publishBtn.clicked.connect(self.publish)

        if checkout_idx>-1:
            self.departmentMenu.setCurrentIndex(checkout_idx)
        self.setElementType()
        self.eList.setElement(checkout_body_name)
        
        #set gui layout
        self.grid = QtGui.QGridLayout(self)
        self.setLayout(self.grid)
        self.grid.addWidget(self.departmentMenu, 0, 0)
        self.grid.addWidget(self.label, 1, 1)
        self.grid.addWidget(self.eList, 2, 0)
        self.grid.addWidget(self.comment, 2, 1)
        self.grid.addWidget(self.filePath, 3, 0)
        self.grid.addWidget(self.publishBtn, 3, 1)
        
        self.show()
        
    def setElementType(self):
        department = str(self.departmentMenu.currentText())
        if department in Department.FRONTEND:
            self.elementType = 'Asset'
        else:
            self.elementType = 'Shot'
        self.eList.refreshList(self.elementType)
        
    def selectElement(self):
        currentItem = self.eList.currentItem()
        if currentItem is not None:
           self.filePath.setText(self.eList.currentItem().text())
           self.publishBtn.setEnabled(True)

    def publish(self):
        self.elementType = str(self.menu.currentText())
        # element = None
        # element = self.project.get_checkout_element(os.path.dirname(self.src))
        try:
            #Leave here to use for advanced options
            body = self.project.get_body(str(self.filePath.text()))
            element = body.get_element(str(self.departmentMenu.currentText()))
            # if self.elementType == 'Asset':
            #    asset = self.project.get_asset(str(self.filePath.text()))
            #    element = asset.get_element(str(self.departmentMenu.currentText()))
            # else:
            #    shot = self.project.get_shot(str(self.filePath.text()))
            #    element = shot.get_element(str(self.departmentMenu.currentText()))
        
            self.user = self.environment.get_current_username()
            self.comment = str(self.comment.toPlainText())
            self.result = element
            self.published = True
            self.close()
        except Exception, e:
            print e
            error = QtGui.QLineEdit()
            error.setText(str(e))
            self.grid.addWidget(error, 4, 1, 2, 1)
            traceback.print_stack()
def generateGeometry(path='', element=None):
    '''

		Function for generating geometry for Maya files.

		Creates the following output formats:
			.obj

		@return: True if all files were created successfully
				False if some files were not created

		@post: Missing filenames are printed out to both the Maya terminal as well
				as presented in a Maya confirm dialog.
	'''

    path = os.path.dirname(mc.file(q=True, sceneName=True))
    print 'generateGeometry start'
    if not os.path.exists(os.path.join(path, 'cache')):
        os.makedirs(os.path.join(path, 'cache'))

    #OBJPATH = os.path.join(path, 'cache', 'objFiles')
    ABCPATH = os.path.join(path, 'cache', 'abcFiles')

    #if os.path.exists(OBJPATH):
    #	shutil.rmtree(OBJPATH)
    if os.path.exists(ABCPATH):
        shutil.rmtree(ABCPATH)

    filePath = cmds.file(q=True, sceneName=True)
    fileDir = os.path.dirname(filePath)
    print 'This is the fileDir in question: ', fileDir

    abcFilePath = getElementCacheDirectory(fileDir, element)
    if abcFilePath is None:
        return False

    selection = mc.ls(geometry=True, visible=True)
    selection_long = mc.ls(geometry=True, visible=True, long=True)

    # Temporarily disabled obj support (might not be needed)
    #objs = objExport(selection, OBJPATH)

    # Check to see if all .obj files were created
    #if not len(checkFiles(objs)) == 0:
    #	return False
    proj = Project()
    if element is None:
        checkout = proj.get_checkout(path)
        if checkout is None:
            message_gui.error(
                'There was a problem exporting the alembic to the correct location. Checkout the asset again and try one more time.'
            )
            return None
        body = proj.get_body(checkout.get_body_name())
        element = body.get_element(checkout.get_department_name(),
                                   checkout.get_element_name())
    else:
        body = proj.get_body(element.get_parent())

    # We decided to try exporting all the geo into one alembic file instead of many. This is the line that does many
    # abcs = abcExport(selection_long, ABCPATH)
    if body.is_asset():
        if body.get_type() == AssetType.SET:
            abcs = abcExportLoadedReferences(ABCPATH)
        else:
            abcs = abcExportAll(element.get_long_name(), ABCPATH)
    else:
        abcs = abcExportAll(element.get_long_name(), ABCPATH)
    print str(body.is_asset()) + ' it is an asset'
    print 'The type is ' + body.get_type()
    if not len(checkFiles(abcs)) == 0:
        return False

    return True
Example #46
0
 def __init__(self, parent):
     super(ElementList, self).__init__()
     self.parent = parent
     self.project = Project()
     self.elements = self.project.list_assets()
     self.initUI()       
 def __init__(self, parent):
     super(AssetListWindow, self).__init__()
     self.parent = parent
     self.current_selection = None
     self.project = Project()
     self.initUI()
Example #48
0
 def __init__(self, parent, dept_list=Department.ALL, showWindow=True):
     super(SelectionWindow, self).__init__()
     self.parent = parent
     self.project = Project()
     self.environment = Environment()
     self.initUI(dept_list, showWindow)
class ReferenceWindow(QtGui.QWidget):

    finished = QtCore.pyqtSignal()

    def __init__(self, parent, src, dept_list=Department.ALL):
        super(ReferenceWindow, self).__init__()
        self.project = Project()
        self.parent = parent
        self.src = src
        self.filePaths = []
        self.done = True
        self.reference = False
        self.initUI(dept_list)

    def initUI(self, dept_list):
        #define gui elements
        self.setGeometry(300, 300, WINDOW_WIDTH, WINDOW_HEIGHT)
        self.setWindowTitle('Taijitu Reference Manager')
        self.departmentMenu = QtGui.QComboBox()
        for i in dept_list:
            self.departmentMenu.addItem(i)
        self.departmentMenu.activated[str].connect(self.setElementType)

        self.assetList = AssetListWindow(self)
        for asset in self.project.list_assets():
            item = QtGui.QListWidgetItem(asset)
            self.assetList.addItem(item)

        self.typeFilterLabel = QtGui.QLabel("Type Filter")
        self.typeFilterLabel.setAlignment(QtCore.Qt.AlignRight
                                          | QtCore.Qt.AlignVCenter)
        self.typeFilter = QtGui.QComboBox()
        self.typeFilter.addItem("all")
        for i in AssetType.ALL:
            self.typeFilter.addItem(i)

        self.typeFilter.currentIndexChanged.connect(self.setElementType)
        self.referenceButton = QtGui.QPushButton('Reference')
        self.referenceButton.clicked.connect(self.createReference)
        self.cancelButton = QtGui.QPushButton('Cancel')
        self.cancelButton.clicked.connect(self.close)

        #set gui layout
        self.grid = QtGui.QGridLayout(self)
        self.setLayout(self.grid)
        self.grid.addWidget(self.departmentMenu, 0, 0)
        self.grid.addWidget(self.assetList, 1, 0, 1, 0)
        self.grid.addWidget(self.typeFilterLabel, 2, 0)
        self.grid.addWidget(self.typeFilter, 2, 1)
        self.grid.addWidget(self.referenceButton, 3, 0)
        self.grid.addWidget(self.cancelButton, 3, 1)

        self.show()

    def setElementType(self, idx=0):
        department = str(self.departmentMenu.currentText())
        self.refreshList(department)

    def createReference(self):
        selected = []
        del self.filePaths[:]
        for item in self.assetList.selectedItems():
            body = self.project.get_body(str(item.text()))
            element = body.get_element(str(self.departmentMenu.currentText()))
            path = element.get_app_filepath()
            self.filePaths.append(path)
            selected.append(str(item.text()))
        checkout = self.project.get_checkout(os.path.dirname(self.src))
        if checkout is not None:
            body_name = checkout.get_body_name()
            body = self.project.get_body(body_name)
            for sel in selected:
                body.add_reference(sel)
        self.done = False
        self.reference = True
        self.close()

    def refreshList(self, department):
        if department in Department.FRONTEND:
            asset_filter = None
            if (self.typeFilter.currentIndex()):
                asset_filter_str = str(self.typeFilter.currentText())
                asset_filter = (Asset.TYPE, operator.eq, asset_filter_str)
            self.elements = self.project.list_assets(asset_filter)
        else:
            self.elements = self.project.list_shots()

        self.assetList.clear()
        for e in self.elements:
            self.assetList.addItem(e)

    def closeEvent(self, event):
        self.finished.emit()
        event.accept()
 def __init__(self, parent, dept_list=Department.ALL):
     super(CheckoutWindow, self).__init__()
     self.parent = parent
     self.project = Project()
     self.environment = Environment()
     self.initUI(dept_list)
def getElementCacheDirectory(path):
	proj = Project()
	checkout = proj.get_checkout(path)
	body = proj.get_body(checkout.get_body_name())
	elem = body.get_element(checkout.get_department_name(), checkout.get_element_name())
	return elem.get_cache_dir()