Ejemplo n.º 1
0
	def newSystem(self):
		if self._currentObject is None:
			QMessageBox.warning(self, 'Warning', 'Must have a current object selection')
			return

		newName, good = QInputDialog.getText(self, "New System", "Enter a name for the new system")
		if not good:
			return

		newName = str(newName)
		if not NAME_CHECK.match(newName):
			message = 'System name can only contain letters and numbers, and cannot start with a number'
			QMessageBox.warning(self, 'Warning', message)
			return

		newSystem = Simplex.buildEmptySystem(self._currentObject, newName, sliderMul=self._sliderMul)
		with signalsBlocked(self.uiCurrentSystemCBOX):
			self.uiCurrentSystemCBOX.addItem(newName)
			self.uiCurrentSystemCBOX.setCurrentIndex(self.uiCurrentSystemCBOX.count()-1)
			self.setSystem(newSystem)
Ejemplo n.º 2
0
    def newFalloff(self):
        if not self.simplex.falloffs:
            return
        foNames = [f.name for f in self.simplex.falloffs]
        tempName = getNextName("NewFalloff", foNames)

        newName, good = QInputDialog.getText(
            self,
            "Rename Falloff",
            "Enter a new name for the Falloff",
            text=tempName)
        if not good:
            return

        if not NAME_CHECK.match(newName):
            message = 'Falloff name can only contain letters and numbers, and cannot start with a number'
            QMessageBox.warning(self, 'Warning', message)
            return

        nn = getNextName(newName, foNames)
        Falloff.createPlanar(nn, self.simplex, 'X', 1.0, 0.66, 0.33, -1.0)
Ejemplo n.º 3
0
    def newTrav(self):
        sliders = self.parent().uiSliderTREE.getSelectedItems(Slider)
        combos = self.parent().uiComboTREE.getSelectedItems(Combo)
        items = sliders + combos

        if len(items) != 2:
            message = 'Must have exactly 2 other controller selected'
            QMessageBox.warning(self, 'Warning', message)
            return None

        # the progressor will have more shapes in the prog
        val0 = items[0].prog.getValues()
        val1 = items[1].prog.getValues()
        pos0count = len([i for i in val0 if i > 0])
        neg0count = len([i for i in val0 if i < 0])
        pos1count = len([i for i in val1 if i > 0])
        neg1count = len([i for i in val1 if i < 0])

        # Find the prog item
        vals = [pos0count, neg0count, pos1count, neg1count]
        mIdx = vals.index(max(vals))
        iidx = 0 if mIdx < 2 else 1
        progItem = items[iidx]
        multItem = items[iidx - 1]

        progFlip = (mIdx % 2) == 1
        multFlip = False

        name = Traversal.buildTraversalName(progItem, multItem, progFlip,
                                            multFlip)
        return Traversal.createTraversal(name,
                                         self.simplex,
                                         multItem,
                                         progItem,
                                         multFlip,
                                         progFlip,
                                         count=vals[mIdx])
Ejemplo n.º 4
0
	def importObjFolder(self, folder):
		''' Import all objs from a user selected folder '''
		if not os.path.isdir(folder):
			QMessageBox.warning(self, 'Warning', 'Folder does not exist')
			return

		paths = os.listdir(folder)
		paths = [i for i in paths if i.endswith('.obj')]
		if not paths:
			QMessageBox.warning(self, 'Warning', 'Folder does not contain any .obj files')
			return

		shapeDict = {shape.name: shape for shape in self.simplex.shapes}

		inPairs = {}
		for path in paths:
			shapeName = os.path.splitext(os.path.basename(path))[0]
			shape = shapeDict.get(shapeName)
			if shape is not None:
				inPairs[shapeName] = path
			else:
				sfx = "_Extract"
				if shapeName.endswith(sfx):
					shapeName = shapeName[:-len(sfx)]
					shape = shapeDict.get(shapeName)
					if shape is not None:
						inPairs[shapeName] = path

		sliderMasters, comboMasters = {}, {}
		for masters in [self.simplex.sliders, self.simplex.combos]:
			for master in masters:
				for pp in master.prog.pairs:
					shape = shapeDict.get(pp.shape.name)
					if shape is not None:
						if shape.name in inPairs:
							if isinstance(master, Slider):
								sliderMasters[shape.name] = master
							if isinstance(master, Combo):
								comboMasters[shape.name] = master

		comboDepth = {}
		for k, v in comboMasters.iteritems():
			depth = len(v.pairs)
			comboDepth.setdefault(depth, {})[k] = v

		pBar = QProgressDialog("Loading from Mesh", "Cancel", 0, len(comboMasters) + len(sliderMasters), self)
		pBar.show()

		for shapeName, slider in sliderMasters.iteritems():
			pBar.setValue(pBar.value() + 1)
			pBar.setLabelText("Loading Obj :\n{0}".format(shapeName))
			QApplication.processEvents()
			if pBar.wasCanceled():
				return

			path = inPairs[shapeName]
			mesh = self.simplex.DCC.importObj(os.path.join(folder, path))

			shape = shapeDict[shapeName]
			self.simplex.DCC.connectShape(shape, mesh=mesh, live=False, delete=True)

		for depth in sorted(comboDepth.keys()):
			for shapeName, combo in comboDepth[depth].iteritems():
				pBar.setValue(pBar.value() + 1)
				pBar.setLabelText("Loading Obj :\n{0}".format(shapeName))
				QApplication.processEvents()
				if pBar.wasCanceled():
					return

				path = inPairs[shapeName]
				mesh = self.simplex.DCC.importObj(os.path.join(folder, path))
				shape = shapeDict[shapeName]
				self.simplex.DCC.connectComboShape(combo, shape, mesh=mesh, live=False, delete=True)

		pBar.close()