simplex-solver 3.0.18__37-abi3-win_amd64.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (81) hide show
  1. pysimplex.pyd +0 -0
  2. simplex_solver-3.0.18.dist-info/METADATA +87 -0
  3. simplex_solver-3.0.18.dist-info/RECORD +81 -0
  4. simplex_solver-3.0.18.dist-info/WHEEL +5 -0
  5. simplex_solver-3.0.18.dist-info/licenses/LICENSE +165 -0
  6. simplexui/__init__.py +54 -0
  7. simplexui/channelBox.py +862 -0
  8. simplexui/comboCheckDialog.py +335 -0
  9. simplexui/commands/__init__.py +16 -0
  10. simplexui/commands/alembicCommon.py +1045 -0
  11. simplexui/commands/applyCorrectives.py +455 -0
  12. simplexui/commands/buildIceXML.py +443 -0
  13. simplexui/commands/correctiveInterface.py +271 -0
  14. simplexui/commands/expandedExport.py +435 -0
  15. simplexui/commands/hdf5Convert.py +62 -0
  16. simplexui/commands/mayaCorrectiveInterface.py +164 -0
  17. simplexui/commands/mesh.py +1086 -0
  18. simplexui/commands/reorderSimplexPoints.py +103 -0
  19. simplexui/commands/rigidAlign.py +103 -0
  20. simplexui/commands/setDelta.xsicompound +60 -0
  21. simplexui/commands/smpxBlend.py +634 -0
  22. simplexui/commands/unsubdivide.py +1232 -0
  23. simplexui/commands/uvTransfer.py +986 -0
  24. simplexui/commands/xsiCorrectiveInterface.py +136 -0
  25. simplexui/dragFilter.py +299 -0
  26. simplexui/falloffDialog.py +476 -0
  27. simplexui/img/ChefHead.png +0 -0
  28. simplexui/img/frozen.png +0 -0
  29. simplexui/interface/__init__.py +30 -0
  30. simplexui/interface/dummyInterface.py +1564 -0
  31. simplexui/interface/mayaInterface.py +3197 -0
  32. simplexui/interface/xsiInterface.py +2944 -0
  33. simplexui/interfaceModel.py +1040 -0
  34. simplexui/interfaceModelTrees.py +439 -0
  35. simplexui/interfaceModel_Test.py +259 -0
  36. simplexui/items/__init__.py +26 -0
  37. simplexui/items/accessor.py +217 -0
  38. simplexui/items/combo.py +855 -0
  39. simplexui/items/falloff.py +780 -0
  40. simplexui/items/group.py +295 -0
  41. simplexui/items/progression.py +745 -0
  42. simplexui/items/shape.py +444 -0
  43. simplexui/items/simplex.py +1747 -0
  44. simplexui/items/slider.py +741 -0
  45. simplexui/items/stack.py +156 -0
  46. simplexui/items/traversal.py +969 -0
  47. simplexui/main.pyw +22 -0
  48. simplexui/menu/__init__.py +73 -0
  49. simplexui/menu/dummyPlugins/__init__.py +16 -0
  50. simplexui/menu/genericPlugins/__init__.py +16 -0
  51. simplexui/menu/genericPlugins/_builtins.py +260 -0
  52. simplexui/menu/genericPlugins/checkPossibleCombos.py +47 -0
  53. simplexui/menu/genericPlugins/exportSplit.py +61 -0
  54. simplexui/menu/genericPlugins/showFalloffs.py +24 -0
  55. simplexui/menu/genericPlugins/showTraversals.py +24 -0
  56. simplexui/menu/genericPlugins/simplexUvTransfer.py +109 -0
  57. simplexui/menu/genericPlugins/unsubdivide.py +71 -0
  58. simplexui/menu/mayaPlugins/__init__.py +16 -0
  59. simplexui/menu/mayaPlugins/exportOther.py +45 -0
  60. simplexui/menu/mayaPlugins/extractProgressives.py +67 -0
  61. simplexui/menu/mayaPlugins/freezeCombo.py +251 -0
  62. simplexui/menu/mayaPlugins/generateShapeIncrementals.py +100 -0
  63. simplexui/menu/mayaPlugins/importObjs.py +196 -0
  64. simplexui/menu/mayaPlugins/linearizeTraversal.py +49 -0
  65. simplexui/menu/mayaPlugins/makeShelfBtn.py +69 -0
  66. simplexui/menu/mayaPlugins/relaxToSelection.py +77 -0
  67. simplexui/menu/mayaPlugins/reloadDefinition.py +34 -0
  68. simplexui/menu/mayaPlugins/snapToNeutral.py +74 -0
  69. simplexui/menu/mayaPlugins/softSelectToCluster.py +204 -0
  70. simplexui/menu/mayaPlugins/tweakMix.py +138 -0
  71. simplexui/menu/mayaPlugins/updateRestShape.py +107 -0
  72. simplexui/menu/xsiPlugins/__init__.py +16 -0
  73. simplexui/simplexDialog.py +1391 -0
  74. simplexui/travCheckDialog.py +393 -0
  75. simplexui/traversalDialog.py +277 -0
  76. simplexui/ui/comboCheckDialog.ui +475 -0
  77. simplexui/ui/falloffDialog.ui +243 -0
  78. simplexui/ui/simplexDialog.ui +1458 -0
  79. simplexui/ui/travCheckDialog.ui +488 -0
  80. simplexui/ui/traversalDialog.ui +532 -0
  81. simplexui/utils.py +320 -0
@@ -0,0 +1,439 @@
1
+ # Copyright 2016, Blur Studio
2
+ #
3
+ # This file is part of Simplex.
4
+ #
5
+ # Simplex is free software: you can redistribute it and/or modify
6
+ # it under the terms of the GNU Lesser General Public License as published by
7
+ # the Free Software Foundation, either version 3 of the License, or
8
+ # (at your option) any later version.
9
+ #
10
+ # Simplex is distributed in the hope that it will be useful,
11
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
12
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
+ # GNU Lesser General Public License for more details.
14
+ #
15
+ # You should have received a copy of the GNU Lesser General Public License
16
+ # along with Simplex. If not, see <http://www.gnu.org/licenses/>.
17
+
18
+ from six.moves import range
19
+
20
+ from .dragFilter import DragFilter
21
+ from .items import Group
22
+ from Qt.QtCore import QItemSelection, QItemSelectionModel, QModelIndex, QRegExp, Qt
23
+ from Qt.QtGui import QRegExpValidator
24
+ from Qt.QtWidgets import QApplication, QLineEdit, QMenu, QStyledItemDelegate, QTreeView
25
+
26
+
27
+ class SimplexNameDelegate(QStyledItemDelegate):
28
+ """An QStyledItemDelegate subclass that implements a Regex validator"""
29
+
30
+ def __init__(self, parent=None):
31
+ super(SimplexNameDelegate, self).__init__(parent)
32
+ self._rx = QRegExp(r"[A-Za-z][A-Za-z0-9_]*")
33
+
34
+ def createEditor(self, parent, option, index):
35
+ editor = QLineEdit(parent)
36
+ rxv = QRegExpValidator(self._rx, editor)
37
+ editor.setValidator(rxv)
38
+ return editor
39
+
40
+
41
+ class SimplexTree(QTreeView):
42
+ """Abstract base tree displaying Simplex objects"""
43
+
44
+ def __init__(self, parent):
45
+ super(SimplexTree, self).__init__(parent)
46
+
47
+ self.expandModifier = Qt.ControlModifier
48
+ self.depthModifier = Qt.ShiftModifier
49
+
50
+ self._menu = None
51
+ self._plugins = []
52
+
53
+ self.expanded.connect(self.expandTree)
54
+ self.collapsed.connect(self.collapseTree)
55
+ self.connectMenus()
56
+
57
+ self.dragFilter = DragFilter(self.viewport())
58
+ self.viewport().installEventFilter(self.dragFilter)
59
+
60
+ self.dragFilter.dragTick.connect(self.dragTick)
61
+
62
+ self.delegate = SimplexNameDelegate(self)
63
+ self.setItemDelegateForColumn(0, self.delegate)
64
+
65
+ self.setColumnWidth(1, 50)
66
+ self.setColumnWidth(2, 20)
67
+
68
+ def setPlugins(self, plugins):
69
+ """Set the right-click menu plugins for the tree
70
+
71
+ Parameters
72
+ ----------
73
+ plugins : list
74
+ The list of plugins for the tree
75
+ """
76
+ self._plugins = plugins
77
+
78
+ def unifySelection(self):
79
+ """Handle selection across multiple Trees.
80
+ The other tree's selectionChanged signal will be connected to this
81
+ And it will clear the selection on this tree if no modifiers are being held
82
+ """
83
+ mods = QApplication.keyboardModifiers()
84
+ if not mods & (Qt.ControlModifier | Qt.ShiftModifier):
85
+ selModel = self.selectionModel()
86
+ selModel.blockSignals(True)
87
+ try:
88
+ selModel.clearSelection()
89
+ finally:
90
+ selModel.blockSignals(False)
91
+ self.viewport().update()
92
+
93
+ def hideRedundant(self, check):
94
+ """Update the filter model to show/hide single shapes
95
+
96
+ Parameters
97
+ ----------
98
+ check : bool
99
+ Whether to hid redundant
100
+ """
101
+ model = self.model()
102
+ model.filterShapes = check
103
+ model.invalidateFilter()
104
+
105
+ def stringFilter(self, filterString):
106
+ """Update the filter model with a filter string
107
+
108
+ Parameters
109
+ ----------
110
+ filterString : str
111
+ The string to filter on
112
+ """
113
+ model = self.model()
114
+ model.filterString = str(filterString)
115
+ model.invalidateFilter()
116
+
117
+ def isolate(self, sliderNames):
118
+ """Update the filter model with a whitelist of names
119
+
120
+ Parameters
121
+ ----------
122
+ sliderNames : [str, ...]
123
+ The names items to show
124
+ """
125
+ model = self.model()
126
+ model.isolateList = sliderNames
127
+ model.invalidateFilter()
128
+
129
+ def isolateSelected(self):
130
+ """Isolate the selected items"""
131
+ items = self.getSelectedItems()
132
+ isoList = [i.name for i in items]
133
+ self.isolate(isoList)
134
+
135
+ def exitIsolate(self):
136
+ """Remove all items from isolation"""
137
+ self.isolate([])
138
+
139
+ # Tree expansion/collapse code
140
+ def expandTree(self, index):
141
+ """Expand all items under index
142
+
143
+ Parameters
144
+ ----------
145
+ index : QModelIndex
146
+ The index to recursively expand
147
+ """
148
+ self.toggleTree(index, True)
149
+
150
+ def collapseTree(self, index):
151
+ """Collapse all items under index
152
+
153
+ Parameters
154
+ ----------
155
+ index : QModelIndex
156
+ The index to recursively collapse
157
+ """
158
+ self.toggleTree(index, False)
159
+
160
+ def resizeColumns(self):
161
+ '''Resize all columns to their contents "smartly"'''
162
+ model = self.model()
163
+ for i in range(model.columnCount() - 1):
164
+ oldcw = self.columnWidth(i)
165
+ self.resizeColumnToContents(i)
166
+ newcw = self.columnWidth(i) + 10
167
+ self.setColumnWidth(i, max(oldcw, newcw, 30))
168
+ self.setColumnWidth(model.columnCount() - 1, 5)
169
+
170
+ def toggleTree(self, index, expand):
171
+ """Recursively expand or collapse an entire sub-tree of an
172
+ index. If certain modifiers are held, then only a partial
173
+ sub-tree will be expanded
174
+
175
+ Parameters
176
+ ----------
177
+ index : QModelIndex
178
+ The index to change expansion
179
+ expand : bool
180
+ Whether to expand or collapse the item
181
+ """
182
+ # Separate function to deal with filtering capability
183
+ if not index.isValid():
184
+ return
185
+
186
+ model = self.model()
187
+ mods = QApplication.keyboardModifiers()
188
+ thing = model.itemFromIndex(index)
189
+ thing.expanded[id(self)] = expand
190
+
191
+ if mods & (self.expandModifier | self.depthModifier):
192
+ queue = [index]
193
+ self.blockSignals(True)
194
+ try:
195
+ while queue:
196
+ idx = queue.pop()
197
+ thing = model.itemFromIndex(idx)
198
+ thing.expanded[id(self)] = expand
199
+ self.setExpanded(idx, expand)
200
+ if mods & self.depthModifier:
201
+ if isinstance(thing, Group):
202
+ continue
203
+ for i in range(model.rowCount(idx)):
204
+ child = model.index(i, 0, idx)
205
+ if child and child.isValid():
206
+ queue.append(child)
207
+ finally:
208
+ self.blockSignals(False)
209
+
210
+ if expand:
211
+ self.resizeColumns()
212
+
213
+ def expandToItem(self, item):
214
+ """Make sure that all parents leading to `item` are expanded
215
+
216
+ Parameters
217
+ ----------
218
+ item : object
219
+ The item to expand to
220
+ """
221
+ model = self.model()
222
+ index = model.indexFromItem(item)
223
+ self.expandToIndex(index)
224
+
225
+ def expandToIndex(self, index):
226
+ """Make sure that all parents leading to `index` are expanded
227
+
228
+ Parameters
229
+ ----------
230
+ index : QModelIndex
231
+ The index to expand to
232
+ """
233
+ model = self.model()
234
+ while index and index.isValid():
235
+ self.setExpanded(index, True)
236
+ thing = model.itemFromIndex(index)
237
+ thing.expanded[id(self)] = True
238
+ index = index.parent()
239
+ self.resizeColumns()
240
+
241
+ def scrollToItem(self, item):
242
+ """Ensure that the item is scrolled to in the tree
243
+
244
+ Parameters
245
+ ----------
246
+ item : object
247
+ The Item to expand to
248
+ """
249
+ model = self.model()
250
+ index = model.indexFromItem(item)
251
+ self.scrollToIndex(index)
252
+
253
+ def scrollToIndex(self, index):
254
+ """Ensure that the index is scrolled to in the tree
255
+
256
+ Parameters
257
+ ----------
258
+ index : QModelIndex
259
+ The Index to expand to
260
+
261
+ """
262
+ self.expandToIndex(index)
263
+ self.scrollTo(index)
264
+
265
+ def storeExpansion(self):
266
+ """Store the expansion state of the tree for the undo stack"""
267
+ model = self.model()
268
+ queue = [model.index(0, 0, QModelIndex())]
269
+ while queue:
270
+ index = queue.pop()
271
+ item = model.itemFromIndex(index)
272
+ item.expanded[id(self)] = self.isExpanded(index)
273
+ for row in range(model.rowCount(index)):
274
+ queue.append(model.index(row, 0, index))
275
+
276
+ def setItemExpansion(self):
277
+ """Load the stored expansions onto the tree"""
278
+ model = self.model()
279
+ queue = [model.index(0, 0, QModelIndex())]
280
+ self.blockSignals(True)
281
+ try:
282
+ while queue:
283
+ index = queue.pop()
284
+ item = model.itemFromIndex(index)
285
+ exp = item.expanded.get(id(self), False)
286
+ self.setExpanded(index, exp)
287
+ for row in range(model.rowCount(index)):
288
+ queue.append(model.index(row, 0, index))
289
+ finally:
290
+ self.blockSignals(False)
291
+
292
+ def dragTick(self, ticks, mul):
293
+ """Deal with the ticks coming from the drag handler
294
+
295
+ Parameters
296
+ ----------
297
+ ticks : int
298
+ The number and direction of update ticks coming from the drag handler
299
+ mul : float
300
+ The multiplier based on user hotkeys
301
+ """
302
+ selModel = self.selectionModel()
303
+ if not selModel:
304
+ return
305
+ items = self.getSelectedItems()
306
+ for item in items:
307
+ if hasattr(item, "valueTick"):
308
+ item.valueTick(ticks, mul)
309
+ self.viewport().update()
310
+
311
+ # Menus and Actions
312
+ def connectMenus(self):
313
+ """Setup the QT signal/slot connections to the context menus"""
314
+ self.setContextMenuPolicy(Qt.CustomContextMenu)
315
+ self.customContextMenuRequested.connect(self.openMenu)
316
+
317
+ def openMenu(self, pos):
318
+ """Handle getting the data to show the context menu
319
+
320
+ Parameters
321
+ ----------
322
+ pos : QPoint
323
+ The position of the click
324
+ """
325
+ clickIdx = self.indexAt(pos)
326
+ selIdxs = self.getSelectedIndexes()
327
+ if self.window().simplex is None:
328
+ return
329
+ self.showContextMenu(clickIdx, selIdxs, self.viewport().mapToGlobal(pos))
330
+
331
+ def showContextMenu(self, clickIdx, indexes, pos):
332
+ """Handle showing the context menu items from the plugins
333
+
334
+ Parameters
335
+ ----------
336
+ clickIdx : QModelIndex
337
+ The model index that was clicked
338
+ indexes : [QModelIndex, ...]
339
+ The indexes that were selected
340
+ pos : QPoint
341
+ The position of the click
342
+ """
343
+ menu = QMenu()
344
+ for plug in self._plugins:
345
+ plug.registerContext(self, clickIdx, indexes, menu)
346
+ menu.exec_(pos)
347
+
348
+ # Selection
349
+ def getSelectedItems(self, typ=None):
350
+ """Get the selected tree items
351
+
352
+ Parameters
353
+ ----------
354
+ typ : Type
355
+ Only return selected items of this type. Optional
356
+
357
+ Returns
358
+ -------
359
+ [object, ...]
360
+ A list of selected tree items
361
+ """
362
+ selModel = self.selectionModel()
363
+ if not selModel:
364
+ return []
365
+ selIdxs = selModel.selectedIndexes()
366
+ selIdxs = [i for i in selIdxs if i.column() == 0]
367
+ model = self.model()
368
+ items = [model.itemFromIndex(i) for i in selIdxs]
369
+ if typ is not None:
370
+ items = [i for i in items if isinstance(i, typ)]
371
+ return items
372
+
373
+ def getSelectedIndexes(self, filtered=False):
374
+ """Get selected indexes for either the filtered or unfiltered models
375
+
376
+ Parameters
377
+ ----------
378
+ filtered : bool
379
+ Whether the model is filtered or not. Defaults to False
380
+
381
+ Returns
382
+ -------
383
+ [QModelIndex, ...]
384
+ A list of selected indexes
385
+ """
386
+ selModel = self.selectionModel()
387
+ if not selModel:
388
+ return []
389
+ selIdxs = selModel.selectedIndexes()
390
+ if filtered:
391
+ return selIdxs
392
+
393
+ model = self.model()
394
+ indexes = [model.mapToSource(i) for i in selIdxs]
395
+ return indexes
396
+
397
+ def setItemSelection(self, items):
398
+ """Set the selection based on a list of items
399
+
400
+ Parameters
401
+ ----------
402
+ items : [object, ...]
403
+ List of items to select
404
+ """
405
+ model = self.model()
406
+ idxs = [model.indexFromItem(i) for i in items]
407
+ idxs = [i for i in idxs if i and i.isValid()]
408
+
409
+ toSel = QItemSelection()
410
+ for idx in idxs:
411
+ toSel.merge(QItemSelection(idx, idx), QItemSelectionModel.Select)
412
+
413
+ for idx in idxs:
414
+ par = idx.parent()
415
+ if par.isValid():
416
+ self.scrollToIndex(par)
417
+
418
+ selModel = self.selectionModel()
419
+ selModel.select(toSel, QItemSelectionModel.ClearAndSelect)
420
+
421
+
422
+ # Currently, there's no difference between these
423
+ # Later on, though, they may be different
424
+ class SliderTree(SimplexTree):
425
+ """A SimplexTree sub-class for sliders"""
426
+
427
+ pass
428
+
429
+
430
+ class ComboTree(SimplexTree):
431
+ """A SimplexTree sub-class for combos"""
432
+
433
+ pass
434
+
435
+
436
+ class TraversalTree(SimplexTree):
437
+ """A SimplexTree sub-class for traversals"""
438
+
439
+ pass
@@ -0,0 +1,259 @@
1
+ # Copyright 2016, Blur Studio
2
+ #
3
+ # This file is part of Simplex.
4
+ #
5
+ # Simplex is free software: you can redistribute it and/or modify
6
+ # it under the terms of the GNU Lesser General Public License as published by
7
+ # the Free Software Foundation, either version 3 of the License, or
8
+ # (at your option) any later version.
9
+ #
10
+ # Simplex is distributed in the hope that it will be useful,
11
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
12
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
+ # GNU Lesser General Public License for more details.
14
+ #
15
+ # You should have received a copy of the GNU Lesser General Public License
16
+ # along with Simplex. If not, see <http://www.gnu.org/licenses/>.
17
+
18
+ from __future__ import absolute_import, print_function
19
+
20
+ import os
21
+ import sys
22
+
23
+ from six.moves import range
24
+
25
+ # Add the parent folder to the path so I can import SimplexUI
26
+ # Means I can run this test code from inside the module and
27
+ # keep everything together
28
+ base = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
29
+ sys.path.insert(0, base)
30
+
31
+ from .interfaceModel import (
32
+ ComboFilterModel,
33
+ ComboModel,
34
+ Simplex,
35
+ SimplexModel,
36
+ Slider,
37
+ SliderFilterModel,
38
+ SliderModel,
39
+ TraversalFilterModel,
40
+ TraversalModel,
41
+ )
42
+ from Qt.QtCore import QModelIndex
43
+ from Qt.QtWidgets import QApplication, QPushButton, QTreeView, QVBoxLayout, QWidget
44
+
45
+
46
+ # HELPERS
47
+ def expandRecursive(view, model, index=QModelIndex(), depth=0, debug=False):
48
+ """helper to expand the whole tree"""
49
+ view.setExpanded(index, True)
50
+ rows = model.rowCount(index)
51
+
52
+ if debug:
53
+ item = model.itemFromIndex(index)
54
+ print(
55
+ " " * depth
56
+ + "Name {0}, children {1}".format(item.name if item else None, rows)
57
+ )
58
+ print(
59
+ " " * depth
60
+ + "Depth {0}, Row {1}, Col {2}".format(depth, index.row(), index.column())
61
+ )
62
+
63
+ for row in range(rows):
64
+ child = model.index(row, 0, index)
65
+ if not child.isValid():
66
+ continue
67
+ expandRecursive(view, model, child, depth + 1)
68
+
69
+
70
+ def showTree(model):
71
+ app = QApplication(sys.argv)
72
+ tv = QTreeView()
73
+ tv.setModel(model)
74
+ expandRecursive(tv, model)
75
+ tv.resizeColumnToContents(0)
76
+ tv.show()
77
+ sys.exit(app.exec_())
78
+
79
+
80
+ def buildDummySystem(path, name="Face"):
81
+ if path.endswith(".json"):
82
+ simp = Simplex.buildSystemFromFile(path)
83
+ elif path.endswith(".smpx"):
84
+ simp = Simplex.buildSystemFromFile(path)
85
+ else:
86
+ raise IOError("Filepath is not .smpx or .json")
87
+ return simp
88
+
89
+
90
+ # DISPLAY TESTS
91
+ def testSliderDisplay(smpxPath, applyFilter=True):
92
+ simp = Simplex.buildSystemFromFile(smpxPath)
93
+ model = SimplexModel(simp, None)
94
+ model = SliderModel(model)
95
+ if applyFilter:
96
+ model = SliderFilterModel(model)
97
+ showTree(model)
98
+
99
+
100
+ def testComboDisplay(smpxPath, applyFilter=True):
101
+ simp = Simplex.buildSystemFromFile(smpxPath)
102
+ model = SimplexModel(simp, None)
103
+ model = ComboModel(model)
104
+ if applyFilter:
105
+ model = ComboFilterModel(model)
106
+ showTree(model)
107
+
108
+
109
+ def testTraversalDisplay(path, applyFilter=True):
110
+ simp = buildDummySystem(path)
111
+
112
+ model = SimplexModel(simp, None)
113
+ model = TraversalModel(model)
114
+ if applyFilter:
115
+ model = TraversalFilterModel(model)
116
+ showTree(model)
117
+
118
+
119
+ def testBaseDisplay(path):
120
+ simp = buildDummySystem(path)
121
+
122
+ model = SimplexModel(simp, None)
123
+ showTree(model)
124
+
125
+
126
+ def testEmptySimplex():
127
+ simp = Simplex.buildEmptySystem(None, "Face")
128
+ model = SimplexModel(simp, None)
129
+ model = SliderModel(model)
130
+ showTree(model)
131
+
132
+
133
+ # RowAdd Tests
134
+ def testNewSlider():
135
+ simp = Simplex.buildEmptySystem(None, "Face")
136
+ model = SimplexModel(simp, None)
137
+ smodel = SliderModel(model)
138
+ fmodel = SliderFilterModel(smodel)
139
+ fmodel.doFilter = True
140
+
141
+ app = QApplication(sys.argv)
142
+
143
+ topWid = QWidget()
144
+ lay = QVBoxLayout(topWid)
145
+
146
+ tv = QTreeView(topWid)
147
+ btn = QPushButton("NEW", topWid)
148
+ lay.addWidget(tv)
149
+ lay.addWidget(btn)
150
+
151
+ tv.setModel(fmodel)
152
+ expandRecursive(tv, fmodel)
153
+ topWid.show()
154
+
155
+ def newSlider():
156
+ return Slider.createSlider("NewSlider", simp)
157
+
158
+ btn.clicked.connect(newSlider)
159
+
160
+ sys.exit(app.exec_())
161
+
162
+
163
+ def testDeleteBase(path):
164
+ simp = buildDummySystem(path)
165
+ model = SimplexModel(simp, None)
166
+
167
+ # model = SliderModel(model)
168
+ # model = SliderFilterModel(model)
169
+
170
+ model = ComboModel(model)
171
+ # model = ComboFilterModel(model)
172
+
173
+ app = QApplication(sys.argv)
174
+
175
+ topWid = QWidget()
176
+ lay = QVBoxLayout(topWid)
177
+
178
+ tv = QTreeView(topWid)
179
+
180
+ btn = QPushButton("DELETE", topWid)
181
+ lay.addWidget(tv)
182
+ lay.addWidget(btn)
183
+
184
+ tv.setModel(model)
185
+ topWid.show()
186
+
187
+ expandRecursive(tv, model)
188
+ tv.resizeColumnToContents(0)
189
+
190
+ def delCallback():
191
+ sel = tv.selectedIndexes()
192
+ sel = [i for i in sel if i.column() == 0]
193
+ items = [s.model().itemFromIndex(s) for s in sel]
194
+ item = items[0]
195
+ print("Deleting", type(item), item.name)
196
+ item.delete()
197
+ tv.model().invalidateFilter()
198
+
199
+ btn.clicked.connect(delCallback)
200
+
201
+ sys.exit(app.exec_())
202
+
203
+
204
+ def testNewChild(path):
205
+ simp = buildDummySystem(path)
206
+ model = SimplexModel(simp, None)
207
+ model = SliderModel(model)
208
+ model = SliderFilterModel(model)
209
+
210
+ app = QApplication(sys.argv)
211
+
212
+ topWid = QWidget()
213
+ lay = QVBoxLayout(topWid)
214
+
215
+ tv = QTreeView(topWid)
216
+
217
+ btn = QPushButton("NEW", topWid)
218
+ lay.addWidget(tv)
219
+ lay.addWidget(btn)
220
+
221
+ tv.setModel(model)
222
+ topWid.show()
223
+
224
+ expandRecursive(tv, model)
225
+ tv.resizeColumnToContents(0)
226
+
227
+ def newCallback():
228
+ sel = tv.selectedIndexes()
229
+ sel = [i for i in sel if i.column() == 0]
230
+ items = [s.model().itemFromIndex(s) for s in sel]
231
+ # item = items[0]
232
+
233
+ # TODO
234
+ # find the child type of item
235
+ # make a new one of those
236
+
237
+ # tv.model().invalidateFilter()
238
+
239
+ btn.clicked.connect(newCallback)
240
+
241
+ sys.exit(app.exec_())
242
+
243
+
244
+ if __name__ == "__main__":
245
+ # basePath = r'D:\Users\tyler\Documents\GitHub\Simplex\scripts\SimplexUI\build'
246
+ basePath = r"D:\Users\tyler\Documents\GitHub\Simplex\Useful"
247
+ # path = os.path.join(basePath, 'male_Simplex_v005_Split.smpx')
248
+ # path = os.path.join(basePath, 'sphere_abcd_50.smpx')
249
+ # path = os.path.join(basePath, 'male_traversal3.json')
250
+ path = os.path.join(basePath, "SquareTest_Floater.json")
251
+
252
+ # Only works for one at a time
253
+ # testEmptySimplex()
254
+ # testBaseDisplay(path)
255
+ # testSliderDisplay(path, applyFilter=True)
256
+ # testComboDisplay(path, applyFilter=True)
257
+ # testTraversalDisplay(path, applyFilter=True)
258
+ # testNewSlider()
259
+ testDeleteBase(path)