def testNewSlider(): simp = Simplex.buildEmptySystem(None, 'Face') model = SimplexModel(simp, None) smodel = SliderModel(model) fmodel = SliderFilterModel(smodel) fmodel.doFilter = True app = QApplication(sys.argv) topWid = QWidget() lay = QVBoxLayout(topWid) tv = QTreeView(topWid) btn = QPushButton('NEW', topWid) lay.addWidget(tv) lay.addWidget(btn) tv.setModel(fmodel) expandRecursive(tv, fmodel) topWid.show() newSlider = lambda: Slider.createSlider('NewSlider', simp) btn.clicked.connect(newSlider) sys.exit(app.exec_())
def testDeleteBase(path): simp = buildDummySystem(path) model = SimplexModel(simp, None) model = SliderModel(model) model = SliderFilterModel(model) app = QApplication(sys.argv) topWid = QWidget() lay = QVBoxLayout(topWid) tv = QTreeView(topWid) btn = QPushButton('DELETE', topWid) lay.addWidget(tv) lay.addWidget(btn) tv.setModel(model) topWid.show() expandRecursive(tv, model) tv.resizeColumnToContents(0) def delCallback(): sel = tv.selectedIndexes() sel = [i for i in sel if i.column() == 0] items = [s.model().itemFromIndex(s) for s in sel] items[0].delete() tv.model().invalidateFilter() btn.clicked.connect(delCallback) sys.exit(app.exec_())
def testSliderTreeDisplay(smpxPath): simp = Simplex.buildSystemFromSmpx(smpxPath) redAttrs = set([ u'lowerLipDepressor_X', u'stretcher_X', u'platysmaFlex_X', u'cheekRaiser_X', u'jawOpen', u'lidTightener_X', u'outerBrowRaiser_X', u'eyesClosed_X', u'cornerPuller_X', u'noseWrinkler_X', u'lipsBlow_X', u'cornerDepressor_X', u'funneler', u'browLateral_X', u'innerBrowRaiser_X', u'upperLipRaiser_X', u'chinRaiser', u'cheek_SuckBlow_X', u'pucker', u'eyeGaze_DownUp_X', u'eyeGaze_RightLeft_X', u'upperLidTweak_X', u'lowerLidTweak_X' ]) greenAttrs = set([ u'nasolabialDeepener_X', u'neckStretcher_X', u'lipsPressed_T', u'lipsPressed_B', u'throatCompress', u'lipsRolled_InOut_B', u'lipsRolled_InOut_T', u'sharpCornerPuller_X', u'dimpler_X', u'eyeBlink_X', u'scalpSlide_BackFwd', u'browDown_X', u'mouthSwing_RightLeft', u'sternoFlex_X', u'throatOpen' ]) blueAttrs = set([ u'adamsApple', u'noseSwing_RightLeft', u'nostrilCompress_X', u'jawThrust_BackFwd', u'eyesWide_X', u'lipsVerticalT_X', u'lipsVerticalB_X', u'earPull_X', u'lipsTighten_T', u'lipsTighten_B', u'lipsCompress_T', u'lipsCompress_B', u'lipsShift_RightLeft_B', u'lipsShift_RightLeft_T', u'lipsNarrowT_X', u'lipsNarrowB_X', u'jawSwing_RightLeft', u'nostril_SuckFlare_X', u'lipsCorner_DownUp_X', u'jawClench' ]) greyAttrs = set([u'lipsTogether']) app = QApplication(sys.argv) #tv = ChannelTree() tv = QTreeView() model = ChannelTreeModel(simp, None) #delegate = ChannelBoxDelegate() #slideFilter = SlideFilter(tv.viewport()) #slideFilter.slideButton = Qt.LeftButton #tv.viewport().installEventFilter(slideFilter) #slideFilter.slidePressed.connect(tv.slideStart) #slideFilter.slideReleased.connect(tv.slideStop) #slideFilter.slideTick.connect(tv.slideTick) #for g in simp.sliderGroups: #for item in g.items: #if item.name in redAttrs: #item.color = QColor(178, 103, 103) #elif item.name in greenAttrs: #item.color = QColor(90, 161, 27) #elif item.name in blueAttrs: #item.color = QColor(103, 141, 178) #elif item.name in greyAttrs: #item.color = QColor(130, 130, 130) tv.setModel(model) #tv.setItemDelegate(delegate) tv.show() sys.exit(app.exec_())
def showTree(model): app = QApplication(sys.argv) tv = QTreeView() tv.setModel(model) expandRecursive(tv, model) tv.resizeColumnToContents(0) tv.show() sys.exit(app.exec_())
def _test(): app = QApplication(sys.argv) path = r'C:\Users\tfox\Documents\GitHub\Simplex\scripts\SimplexUI\build\HeadMaleStandard_High_Unsplit.smpx' d = SimplexDialog() newSystem = Simplex.buildSystemFromSmpx(path, d.getCurrentObject(), sliderMul=1.0) d.setSystem(newSystem) d.show() sys.exit(app.exec_())
def testNewChild(path): simp = buildDummySystem(path) model = SimplexModel(simp, None) model = SliderModel(model) model = SliderFilterModel(model) app = QApplication(sys.argv) topWid = QWidget() lay = QVBoxLayout(topWid) tv = QTreeView(topWid) btn = QPushButton('NEW', topWid) lay.addWidget(tv) lay.addWidget(btn) tv.setModel(model) topWid.show() expandRecursive(tv, model) tv.resizeColumnToContents(0) def newCallback(): sel = tv.selectedIndexes() sel = [i for i in sel if i.column() == 0] items = [s.model().itemFromIndex(s) for s in sel] item = items[0] # TODO # find the child type of item # make a new one of those tv.model().invalidateFilter() btn.clicked.connect(newCallback) sys.exit(app.exec_())