-
Notifications
You must be signed in to change notification settings - Fork 1.2k
/
mainWindow.py
3855 lines (3201 loc) · 163 KB
/
mainWindow.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
#
# Copyright 2016 Pixar
#
# Licensed under the Apache License, Version 2.0 (the "Apache License")
# with the following modification; you may not use this file except in
# compliance with the Apache License and the following modification to it:
# Section 6. Trademarks. is deleted and replaced with:
#
# 6. Trademarks. This License does not grant permission to use the trade
# names, trademarks, service marks, or product names of the Licensor
# and its affiliates, except as required to comply with Section 4(c) of
# the License and to reproduce the content of the NOTICE file.
#
# You may obtain a copy of the Apache License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the Apache License with the above modification is
# distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
# KIND, either express or implied. See the Apache License for the specific
# language governing permissions and limitations under the Apache License.
#
from PySide import QtGui, QtCore
import stageView
from stageView import StageView
from mainWindowUI import Ui_MainWindow
from nodeContextMenu import NodeContextMenu
from headerContextMenu import HeaderContextMenu
from layerStackContextMenu import LayerStackContextMenu
from attributeViewContextMenu import AttributeViewContextMenu
from customAttributes import _GetCustomAttributes
from nodeViewItem import NodeViewItem
from pxr import Usd, UsdGeom, UsdUtils, UsdImaging
from pxr import Gf
from pxr import Glf
from pxr import Pcp
from pxr import Sdf
from pxr import Tf
from pxr import Plug
from ._usdviewq import Utils
from collections import deque
from collections import OrderedDict
from time import time, sleep
import re, sys, os, uuid, tempfile
import prettyPrint
import watchWindow
import adjustClipping
import referenceEditor
from settings import Settings
from common import FallbackTextColor, ClampedTextColor, KeyframeTextColor,\
DefaultTextColor, HeaderColor, RedColor, BoldFont, \
GetAttributeColor, Timer, BusyContext, DumpMallocTags
# Upper HUD entries (declared in variables for abstraction)
PRIM = "Prims"
CV = "CVs"
VERT = "Verts"
FACE = "Faces"
# Lower HUD entries
PLAYBACK = "Playback"
RENDER = "Render"
GETBOUNDS = "BBox"
# Name for nodes that have no type
NOTYPE = "Typeless"
INDEX_VALUE, INDEX_METADATA, INDEX_LAYERSTACK = range(3)
# Tf Debug entries to include in debug menu
TF_DEBUG_MENU_ENTRIES = ["HD", "HDX", "USD", "USDIMAGING", "USDVIEWQ"]
PRIMVIEW_HELP_TEXT = """
<center><span style="font-weight:bold;">Meaning of Prim Styling</span></center>
<br>
<span style="text-decoration:underline;">Font style:</span>
<br>
Abstract prims (class and children)
<br>
<span style="font-style:italic;">Undefined prims (overs)</span>
<br>
<span style="font-weight:bold;">Defined prims (def)</span>
<br>
<br>
<span style="text-decoration:underline;">Font color:</span>
<br>
<span style="color:rgb(135, 206, 250);">Instanced Prim</span>
<br>
<span style="color:rgb(222, 158, 46);">Prim with Composition Arcs (refs, inherits, etc)</span>
<br>
<span style="color:rgb(118, 136, 217);">Instance Master Prim</span>
<br>
<span style="color:rgb(148, 105, 30);">Dimmed colors </span>
<span style="color:rgb(78, 91, 145);">denote </span>
<span style="color:rgb(151, 151, 151);">inactive prims</span>
"""
def isWritableUsdPath(path):
if not os.access(path, os.W_OK):
return (False, 'Path is not a writable file.')
return (True, '')
def getBackupFile(path):
# get a backup file name like myfile.0.usd
number = 0
extindex = path.rfind('.')
if extindex == -1:
exindex = len(path)
while os.access(path[:extindex] + '.' + str(number) + path[extindex:], os.F_OK):
number = number + 1
return path[:extindex] + '.' + str(number) + path[extindex:]
def uniquify_tablewidgetitems(a):
""" Eliminates duplicate list entries in a list
of TableWidgetItems. It relies on the row property
being available for comparison.
"""
if (len(a) == 0):
tmp = []
else:
tmp = [a[0]]
# XXX: we need to compare row #s because
# PySide doesn't allow equality comparison for QTableWidgetItems
tmp_rows = set()
tmp_rows.add(a[0].row())
for i in range(1,len(a)):
if (a[i].row() not in tmp_rows):
tmp.append(a[i])
tmp_rows.add(a[i].row())
return tmp
def drange(start, stop, step):
"""Like builtin range() but allows decimals and is a closed interval
that is, it's inclusive of stop"""
r = start
lst = []
epsilon = 1e-3 * step
while r <= stop+epsilon:
lst.append(r)
r += step
return lst
def _settingsWarning(filePath):
"""Send a warning because the settings file should never fail to load
"""
import traceback
import sys
msg = sys.stderr
print >> msg, "------------------------------------------------------------"
print >> msg, "WARNING: Unknown problem while trying to access settings:"
print >> msg, "------------------------------------------------------------"
print >> msg, "This message is being sent because the settings file (%s) " \
"could not be read" % filePath
print >> msg, "--"
traceback.print_exc(file=msg)
print >> msg, "--"
print >> msg, "Please file a bug if this warning persists"
print >> msg, "Attempting to continue... "
print >> msg, "------------------------------------------------------------"
class VariantComboBox(QtGui.QComboBox):
def __init__(self, parent, prim, variantSetName, mainWindow):
QtGui.QComboBox.__init__(self, parent)
self.prim = prim
self.variantSetName = variantSetName
self.mainWindow = mainWindow
def updateVariantSelection(self, index):
variantSet = self.prim.GetVariantSet(self.variantSetName)
currentVariantSelection = variantSet.GetVariantSelection()
newVariantSelection = str(self.currentText())
if currentVariantSelection != newVariantSelection:
with Timer() as t:
variantSet.SetVariantSelection(newVariantSelection)
# We need to completely re-generate the prim tree because
# changing a prim's variant set can change the namespace
# hierarchy.
self.mainWindow._updatePrimTreeForVariantSwitch()
if self.mainWindow._printTiming:
t.PrintTime("change variantSet %s to %s" %
(variantSet.GetName(), newVariantSelection))
def _GetShortString(prop, frame):
from customAttributes import CustomAttribute
if isinstance(prop, (Usd.Attribute, CustomAttribute)):
val = prop.Get(frame)
elif isinstance(prop, Sdf.AttributeSpec):
if frame == Usd.TimeCode.Default():
val = prop.default
else:
numTimeSamples = -1
if prop.HasInfo('timeSamples'):
numTimeSamples = prop.layer.GetNumTimeSamplesForPath(prop.path)
if numTimeSamples == -1:
val = prop.default
elif numTimeSamples == 1:
return "1 time sample"
else:
return str(numTimeSamples) + " time samples"
elif isinstance(prop, Sdf.RelationshipSpec):
return str(prop.targetPathList)
from scalarTypes import GetScalarTypeFromAttr
scalarType, isArray = GetScalarTypeFromAttr(prop)
result = ''
if isArray:
def arrayToStr(a):
from itertools import chain
elems = a if len(a) <= 6 else chain(a[:3], ['...'], a[-3:])
return '[' + ', '.join(map(str, elems)) + ']'
if val is not None and len(val):
result = "%s[%d]: %s" % (scalarType, len(val), arrayToStr(val))
else:
result = "%s[]" % scalarType
else:
result = str(val)
return result[:500]
class MainWindow(QtGui.QMainWindow):
@classmethod
def clearSettings(cls):
settingsPath = cls._outputBaseDirectory()
settingsPath = os.path.join(settingsPath, 'state')
if not os.path.exists(settingsPath):
print "INFO: ClearSettings requested, but there were no settings " \
"currently stored"
return
os.remove(settingsPath)
print "INFO: Settings restored to default"
def _configurePlugins(self):
try:
from pixar import UsdviewPlug
UsdviewPlug.ConfigureView(self)
except ImportError:
pass
def __del__(self):
# This is needed to free Qt items before exit; Qt hits failed GTK
# assertions without it.
self._nodeToItemMap.clear()
def __init__(self, parent, parserData):
QtGui.QMainWindow.__init__(self, parent)
self._nodeToItemMap = {}
self._itemsToPush = []
self._currentNodes = []
self._currentProp = None
self._console = None
self._interpreter = None
self._parserData = parserData
self._noRender = parserData.noRender
self._unloaded = parserData.unloaded
self._currentFrame = Usd.TimeCode.Default()
self._updateBlock = 0
import os
self._debug = os.getenv('USDVIEW_DEBUG', False)
self._printTiming = parserData.timing or self._debug
self._lastViewContext = {}
self._statusFileName = 'state'
self._deprecatedStatusFileName = '.usdviewrc'
self._mallocTags = parserData.mallocTagStats
self._nodeViewHelpDlg = None
MainWindow._renderer = parserData.renderer
if MainWindow._renderer == 'simple':
os.environ['HD_ENABLED'] = '0'
self.show()
self._ui = Ui_MainWindow()
self._ui.setupUi(self)
self.installEventFilter(self)
# read the stage here
self._stage = self._openStage(self._parserData.usdFile)
if not self._stage:
sys.exit(0)
if not self._stage.GetPseudoRoot():
print parserData.usdFile, 'has no prims; exiting.'
sys.exit(0)
self._initialSelectNode = self._stage.GetPrimAtPath(parserData.primPath)
if not self._initialSelectNode:
print 'Could not find prim at path <%s> to select. '\
'Ignoring...' % parserData.primPath
self._initialSelectNode = None
self._timeSamples = None
self._stageView = None
self._startingPrimCamera = None
self.setWindowTitle(parserData.usdFile)
self._statusBar = QtGui.QStatusBar(self)
self.setStatusBar(self._statusBar)
settingsPathDir = self._outputBaseDirectory()
settingsPath = os.path.join(settingsPathDir, self._statusFileName)
deprecatedSettingsPath = \
os.path.join(settingsPathDir, self._deprecatedStatusFileName)
if (os.path.isfile(deprecatedSettingsPath) and
not os.path.isfile(settingsPath)):
warning = ('\nWARNING: The settings file at: '
+ str(deprecatedSettingsPath) + ' is deprecated.\n'
+ 'These settings are not being used, the new '
+ 'settings file will be located at: '
+ str(settingsPath) + '.\n')
print warning
self._settings = Settings(settingsPath)
try:
self._settings.load()
except IOError:
# try to force out a new settings file
try:
self._settings.save()
except:
_settingsWarning(settingsPath)
except EOFError:
# try to force out a new settings file
try:
self._settings.save()
except:
_settingsWarning(settingsPath)
except:
_settingsWarning(settingsPath)
QtGui.QApplication.setOverrideCursor(QtCore.Qt.BusyCursor)
self._timer = QtCore.QTimer(self)
# Timeout interval in ms. We set it to 0 so it runs as fast as
# possible. In advanceFrameForPlayback we use the sleep() call
# to slow down rendering to self.framesPerSecond fps.
self._timer.setInterval(0)
self._lastFrameTime = time()
self._colorsDict = {'Black':(0.0,0.0,0.0,0.0),
'Grey (Dark)':(0.3,0.3,0.3,0.0),
'Grey (Light)':(0.7,0.7,0.7,0.0),
'White':(1.0,1.0,1.0,0.0),
'Yellow':(1.0,1.0,0.0,0.0),
'Cyan':(0.0,1.0,1.0,0.0)}
# We need to store the trinary selHighlightMode state here,
# because the stageView only deals in True/False (because it
# cannot know anything about playback state).
# We store the highlightColorName so that we can compare state during
# initialization without inverting the name->value logic
self._selHighlightMode = "Only when paused"
self._highlightColorName = "Yellow"
# Initialize the upper HUD info
self._upperHUDInfo = dict()
# declare dictionary keys for the fps info too
self._fpsHUDKeys = (RENDER, PLAYBACK)
# Initialize fps HUD with empty strings
self._fpsHUDInfo = dict(zip(self._fpsHUDKeys,
["N/A", "N/A"]))
self._startTime = self._endTime = time()
# Create action groups
self._ui.threePointLights = QtGui.QActionGroup(self)
self._ui.colorGroup = QtGui.QActionGroup(self)
self._nodeViewResetTimer = QtCore.QTimer(self)
self._nodeViewResetTimer.setInterval(250)
QtCore.QObject.connect(self._nodeViewResetTimer,
QtCore.SIGNAL('timeout()'),
self._resetNodeView)
# Idle timer to push off-screen data to the UI.
self._nodeViewUpdateTimer = QtCore.QTimer(self)
self._nodeViewUpdateTimer.setInterval(0)
QtCore.QObject.connect(self._nodeViewUpdateTimer,
QtCore.SIGNAL('timeout()'),
self._updateNodeView)
# This creates the _stageView and restores state from setings file
self._resetSettings()
if self._stageView:
self._stageView.complexity = parserData.complexity
# This is for validating frame values input on the "Frame" line edit
validator = QtGui.QDoubleValidator(self)
self._ui.frameField.setValidator(validator)
self._ui.rangeEnd.setValidator(validator)
self._ui.rangeBegin.setValidator(validator)
stepValidator = QtGui.QDoubleValidator(self)
stepValidator.setRange(0.01, 1e7, 2)
self._ui.stepSize.setValidator(stepValidator)
# This causes the last column of the attribute view (the value)
# to be stretched to fill the available space
self._ui.attributeView.horizontalHeader().setStretchLastSection(True)
self._ui.attributeView.setSelectionBehavior(
QtGui.QAbstractItemView.SelectRows)
self._ui.nodeView.setSelectionBehavior(
QtGui.QAbstractItemView.SelectRows)
# This allows ctrl and shift clicking for multi-selecting
self._ui.attributeView.setSelectionMode(
QtGui.QAbstractItemView.ExtendedSelection)
self._ui.attributeView.setHorizontalScrollMode(
QtGui.QAbstractItemView.ScrollPerPixel)
self._ui.frameSlider.setTracking(self._ui.redrawOnScrub.isChecked())
for action in (self._ui.actionBlack,
self._ui.actionGrey_Dark,
self._ui.actionGrey_Light,
self._ui.actionWhite):
self._ui.colorGroup.addAction(action)
action.setChecked(str(action.text()) == self._stageView.clearColor)
self._ui.colorGroup.setExclusive(True)
for action in (self._ui.actionKey,
self._ui.actionFill,
self._ui.actionBack):
self._ui.threePointLights.addAction(action)
self._ui.threePointLights.setExclusive(False)
self._ui.renderModeActionGroup = QtGui.QActionGroup(self)
for action in (self._ui.actionWireframe,
self._ui.actionWireframeOnSurface,
self._ui.actionSmooth_Shaded,
self._ui.actionFlat_Shaded,
self._ui.actionPoints,
self._ui.actionGeom_Only,
self._ui.actionGeom_Smooth,
self._ui.actionGeom_Flat,
self._ui.actionHidden_Surface_Wireframe):
self._ui.renderModeActionGroup.addAction(action)
action.setChecked(str(action.text()) == self._stageView.renderMode)
self._ui.renderModeActionGroup.setExclusive(True)
if self._stageView.renderMode not in \
[str(a.text()) for a in
self._ui.renderModeActionGroup.actions()]:
print "Warning: Unknown render mode '%s', falling back to '%s'" % (
self._stageView.renderMode,
str(self._ui.renderModeActionGroup.actions()[0].text()))
self._ui.renderModeActionGroup.actions()[0].setChecked(True)
self._changeRenderMode(self._ui.renderModeActionGroup.actions()[0])
self._ui.pickModeActionGroup = QtGui.QActionGroup(self)
for action in (self._ui.actionPick_Prims,
self._ui.actionPick_Models,
self._ui.actionPick_Instances):
self._ui.pickModeActionGroup.addAction(action)
action.setChecked(str(action.text()) == self._stageView.pickMode)
self._ui.pickModeActionGroup.setExclusive(True)
if self._stageView.pickMode not in \
[str(a.text()) for a in
self._ui.pickModeActionGroup.actions()]:
print "Warning: Unknown pick mode '%s', falling back to '%s'" % (
pickMode,
str(self._ui.pickModeActionGroup.actions()[0].text()))
self._ui.pickModeActionGroup.actions()[0].setChecked(True)
self._changePickMode(self._ui.pickModeActionGroup.actions()[0])
# The error-checking pattern here seems wrong? Error checking
# should happen in the changeXXX methods. All we're checking here
# is the values we hardcoded ourselves in the init function!
self._ui.selHighlightModeActionGroup = QtGui.QActionGroup(self)
for action in (self._ui.actionNever,
self._ui.actionOnly_when_paused,
self._ui.actionAlways):
self._ui.selHighlightModeActionGroup.addAction(action)
action.setChecked(str(action.text()) == self._selHighlightMode)
self._ui.selHighlightModeActionGroup.setExclusive(True)
self._ui.highlightColorActionGroup = QtGui.QActionGroup(self)
for action in (self._ui.actionSelYellow,
self._ui.actionSelCyan,
self._ui.actionSelWhite):
self._ui.highlightColorActionGroup.addAction(action)
action.setChecked(str(action.text()) == self._highlightColorName)
self._ui.highlightColorActionGroup.setExclusive(True)
self._ui.interpolationActionGroup = QtGui.QActionGroup(self)
self._ui.interpolationActionGroup.setExclusive(True)
for interpolationType in Usd.InterpolationType.allValues:
action = self._ui.menuInterpolation.addAction(interpolationType.displayName)
action.setCheckable(True)
action.setChecked(self._stage.GetInterpolationType() == interpolationType)
self._ui.interpolationActionGroup.addAction(action)
self._ui.nodeViewDepthGroup = QtGui.QActionGroup(self)
for i in range(1,9):
action = getattr(self._ui,"actionLevel_" + str(i))
self._ui.nodeViewDepthGroup.addAction(action)
# needed to set color of boxes
graphicsScene = QtGui.QGraphicsScene()
self._ui.attribLegendColorFallback.setScene(graphicsScene)
self._ui.attribLegendColorDefault.setScene(graphicsScene)
self._ui.attribLegendColorKeyframe.setScene(graphicsScene)
self._ui.attribLegendColorClamped.setScene(graphicsScene)
# set color of attribute viewer legend boxes
self._ui.attribLegendColorFallback.setForegroundBrush(FallbackTextColor)
self._ui.attribLegendColorDefault.setForegroundBrush(DefaultTextColor)
self._ui.attribLegendColorKeyframe.setForegroundBrush(KeyframeTextColor)
self._ui.attribLegendColorClamped.setForegroundBrush(ClampedTextColor)
# set the context menu policy for the node browser and attribute
# inspector headers. This is so we can have a context menu on the
# headers that allows you to select which columns are visible.
self._ui.attributeView.horizontalHeader()\
.setContextMenuPolicy(QtCore.Qt.CustomContextMenu)
self._ui.nodeView.header()\
.setContextMenuPolicy(QtCore.Qt.CustomContextMenu)
# Set custom context menu for attribute browser
self._ui.attributeView\
.setContextMenuPolicy(QtCore.Qt.CustomContextMenu)
# Set custom context menu for layer stack browser
self._ui.layerStackView\
.setContextMenuPolicy(QtCore.Qt.CustomContextMenu)
# Set the node view header to have a fixed size type and vis columns
nvh = self._ui.nodeView.header()
nvh.setResizeMode(0, QtGui.QHeaderView.Stretch)
nvh.setResizeMode(1, QtGui.QHeaderView.ResizeToContents)
nvh.setResizeMode(2, QtGui.QHeaderView.ResizeToContents)
avh = self._ui.attributeView.horizontalHeader()
avh.setResizeMode(2, QtGui.QHeaderView.ResizeToContents)
# XXX:
# To avoid QTBUG-12850 (https://bugreports.qt.io/browse/QTBUG-12850),
# we force the horizontal scrollbar to always be visible for all
# QTableWidget widgets in use.
self._ui.attributeView.setHorizontalScrollBarPolicy(
QtCore.Qt.ScrollBarAlwaysOn)
self._ui.metadataView.setHorizontalScrollBarPolicy(
QtCore.Qt.ScrollBarAlwaysOn)
self._ui.layerStackView.setHorizontalScrollBarPolicy(
QtCore.Qt.ScrollBarAlwaysOn)
self._ui.attributeValueEditor.setMainWindow(self)
QtCore.QObject.connect(self._ui.currentPathWidget,
QtCore.SIGNAL('editingFinished()'),
self._currentPathChanged)
QtCore.QObject.connect(self._ui.nodeView,
QtCore.SIGNAL('itemSelectionChanged()'),
self._itemSelectionChanged)
QtCore.QObject.connect(self._ui.nodeView,
QtCore.SIGNAL('itemClicked(QTreeWidgetItem *, int)'),
self._itemClicked)
QtCore.QObject.connect(self._ui.nodeView.header(),
QtCore.SIGNAL('customContextMenuRequested(QPoint)'),
self._nodeViewHeaderContextMenu)
self._ui.nodeView.header().setToolTip(PRIMVIEW_HELP_TEXT)
QtCore.QObject.connect(self._timer, QtCore.SIGNAL('timeout()'),
self._advanceFrameForPlayback)
QtCore.QObject.connect(self._ui.nodeView, QtCore.SIGNAL(
'customContextMenuRequested(QPoint)'),
self._nodeViewContextMenu)
QtCore.QObject.connect(self._ui.nodeView, QtCore.SIGNAL(
'expanded(QModelIndex)'),
self._nodeViewExpanded)
QtCore.QObject.connect(self._ui.frameSlider,
QtCore.SIGNAL('valueChanged(int)'),
self.setFrame)
QtCore.QObject.connect(self._ui.frameSlider,
QtCore.SIGNAL('sliderMoved(int)'),
self._sliderMoved)
QtCore.QObject.connect(self._ui.frameSlider,
QtCore.SIGNAL('sliderReleased()'),
self._updateOnFrameChange)
QtCore.QObject.connect(self._ui.frameField,
QtCore.SIGNAL('editingFinished()'),
self._frameStringChanged)
QtCore.QObject.connect(self._ui.rangeBegin,
QtCore.SIGNAL('editingFinished()'),
self._rangeBeginChanged)
QtCore.QObject.connect(self._ui.stepSize,
QtCore.SIGNAL('editingFinished()'),
self._stepSizeChanged)
QtCore.QObject.connect(self._ui.rangeEnd,
QtCore.SIGNAL('editingFinished()'),
self._rangeEndChanged)
QtCore.QObject.connect(self._ui.actionFrame_Forward,
QtCore.SIGNAL('triggered()'),
self._advanceFrame)
QtCore.QObject.connect(self._ui.actionFrame_Backwards,
QtCore.SIGNAL('triggered()'),
self._retreatFrame)
QtCore.QObject.connect(self._ui.actionReset_View,
QtCore.SIGNAL('triggered()'),
self._resetView)
QtCore.QObject.connect(self._ui.actionToggle_Viewer_Mode,
QtCore.SIGNAL('triggered()'),
self._toggleViewerMode)
QtCore.QObject.connect(self._ui.actionRenderGraphDefault,
QtCore.SIGNAL('triggered()'),
self._defaultRenderGraph)
QtCore.QObject.connect(self._ui.showBBoxes,
QtCore.SIGNAL('toggled(bool)'),
self._showBBoxes)
QtCore.QObject.connect(self._ui.showAABBox,
QtCore.SIGNAL('toggled(bool)'),
self._showAABBox)
QtCore.QObject.connect(self._ui.showOBBox,
QtCore.SIGNAL('toggled(bool)'),
self._showOBBox)
QtCore.QObject.connect(self._ui.showBBoxPlayback,
QtCore.SIGNAL('toggled(bool)'),
self._showBBoxPlayback)
QtCore.QObject.connect(self._ui.useExtentsHint,
QtCore.SIGNAL('toggled(bool)'),
self._setUseExtentsHint)
QtCore.QObject.connect(self._ui.showInterpreter,
QtCore.SIGNAL('triggered()'),
self._showInterpreter)
QtCore.QObject.connect(self._ui.redrawOnScrub,
QtCore.SIGNAL('toggled(bool)'),
self._redrawOptionToggled)
QtCore.QObject.connect(self._ui.actionWatch_Window,
QtCore.SIGNAL('toggled(bool)'),
self._watchWindowToggled)
QtCore.QObject.connect(self._ui.actionRecompute_Clipping_Planes,
QtCore.SIGNAL('triggered()'),
self._stageView.detachAndReClipFromCurrentCamera)
QtCore.QObject.connect(self._ui.actionAdjust_Clipping,
QtCore.SIGNAL('triggered(bool)'),
self._adjustClippingPlanes)
QtCore.QObject.connect(self._ui.actionOpen,
QtCore.SIGNAL('triggered()'),
self._openFile)
QtCore.QObject.connect(self._ui.actionSave_Overrides_As,
QtCore.SIGNAL('triggered()'),
self._saveOverridesAs)
QtCore.QObject.connect(self._ui.actionQuit,
QtCore.SIGNAL('triggered()'),
self._cleanAndClose)
QtCore.QObject.connect(self._ui.actionReopen_Stage,
QtCore.SIGNAL('triggered()'),
self._reopenStage)
QtCore.QObject.connect(self._ui.actionReload_All_Layers,
QtCore.SIGNAL('triggered()'),
self._reloadStage)
QtCore.QObject.connect(self._ui.actionFrame_Selection,
QtCore.SIGNAL('triggered()'),
self._frameSelection)
QtCore.QObject.connect(self._ui.actionToggle_Framed_View,
QtCore.SIGNAL('triggered()'),
self._toggleFramedView)
QtCore.QObject.connect(self._ui.actionAdjust_FOV,
QtCore.SIGNAL('triggered()'),
self._adjustFOV)
QtCore.QObject.connect(self._ui.actionComplexity,
QtCore.SIGNAL('triggered()'),
self._adjustComplexity)
QtCore.QObject.connect(self._ui.actionDisplay_Guides,
QtCore.SIGNAL('toggled(bool)'),
self._toggleDisplayGuides)
QtCore.QObject.connect(self._ui.actionDisplay_Rendering_Guides,
QtCore.SIGNAL('toggled(bool)'),
self._toggleDisplayRenderingGuides)
QtCore.QObject.connect(self._ui.actionDisplay_Camera_Oracles,
QtCore.SIGNAL('toggled(bool)'),
self._toggleDisplayCameraOracles)
QtCore.QObject.connect(self._ui.actionDisplay_PrimId,
QtCore.SIGNAL('toggled(bool)'),
self._toggleDisplayPrimId)
QtCore.QObject.connect(self._ui.actionEnable_Hardware_Shading,
QtCore.SIGNAL('toggled(bool)'),
self._toggleEnableHardwareShading)
QtCore.QObject.connect(self._ui.actionCull_Backfaces,
QtCore.SIGNAL('toggled(bool)'),
self._toggleCullBackfaces)
QtCore.QObject.connect(self._ui.attributeInspector,
QtCore.SIGNAL('currentChanged(int)'),
self._updateAttributeInspector)
QtCore.QObject.connect(self._ui.attributeView,
QtCore.SIGNAL('itemSelectionChanged()'),
self._refreshWatchWindow)
QtCore.QObject.connect(self._ui.attributeView,
QtCore.SIGNAL('cellClicked(int,int)'),
self._attributeViewItemClicked)
QtCore.QObject.connect(self._ui.attributeView, QtCore.SIGNAL(
'currentItemChanged(QTableWidgetItem *, QTableWidgetItem *)'),
self._populateAttributeInspector)
QtCore.QObject.connect(self._ui.attributeView.horizontalHeader(),
QtCore.SIGNAL('customContextMenuRequested(QPoint)'),
self._attributeViewHeaderContextMenu)
QtCore.QObject.connect(self._ui.attributeView,
QtCore.SIGNAL('customContextMenuRequested(QPoint)'),
self._attributeViewContextMenu)
QtCore.QObject.connect(self._ui.layerStackView,
QtCore.SIGNAL('customContextMenuRequested(QPoint)'),
self._layerStackContextMenu)
QtCore.QObject.connect(self._ui.renderModeActionGroup,
QtCore.SIGNAL('triggered(QAction *)'),
self._changeRenderMode)
QtCore.QObject.connect(self._ui.pickModeActionGroup,
QtCore.SIGNAL('triggered(QAction *)'),
self._changePickMode)
QtCore.QObject.connect(self._ui.selHighlightModeActionGroup,
QtCore.SIGNAL('triggered(QAction *)'),
self._changeSelHighlightMode)
QtCore.QObject.connect(self._ui.highlightColorActionGroup,
QtCore.SIGNAL('triggered(QAction *)'),
self._changeHighlightColor)
QtCore.QObject.connect(self._ui.interpolationActionGroup,
QtCore.SIGNAL('triggered(QAction *)'),
self._changeInterpolationType)
QtCore.QObject.connect(self._ui.actionAmbient_Only,
QtCore.SIGNAL('triggered(bool)'),
self._ambientOnlyClicked)
QtCore.QObject.connect(self._ui.actionKey,
QtCore.SIGNAL('triggered(bool)'),
self._onKeyLightClicked)
QtCore.QObject.connect(self._ui.actionFill,
QtCore.SIGNAL('triggered(bool)'),
self._onFillLightClicked)
QtCore.QObject.connect(self._ui.actionBack,
QtCore.SIGNAL('triggered(bool)'),
self._onBackLightClicked)
QtCore.QObject.connect(self._ui.colorGroup,
QtCore.SIGNAL('triggered(QAction *)'),
self._changeBgColor)
QtCore.QObject.connect(self._ui.threePointLights,
QtCore.SIGNAL('triggered(QAction *)'),
self._stageView.update)
QtCore.QObject.connect(self._ui.nodeViewDepthGroup,
QtCore.SIGNAL('triggered(QAction *)'),
self._changeNodeViewDepth)
QtCore.QObject.connect(self._ui.actionExpand_All,
QtCore.SIGNAL('triggered()'),
lambda: self._expandToDepth(1000000))
QtCore.QObject.connect(self._ui.actionCollapse_All,
QtCore.SIGNAL('triggered()'),
self._ui.nodeView.collapseAll)
QtCore.QObject.connect(self._ui.actionShow_Inactive_Nodes,
QtCore.SIGNAL('triggered()'),
self._toggleShowInactiveNodes)
QtCore.QObject.connect(self._ui.actionShow_Master_Prims,
QtCore.SIGNAL('triggered()'),
self._toggleShowMasterPrims)
QtCore.QObject.connect(self._ui.actionShow_Undefined_Prims,
QtCore.SIGNAL('triggered()'),
self._toggleShowUndefinedPrims)
QtCore.QObject.connect(self._ui.actionShow_Abstract_Prims,
QtCore.SIGNAL('triggered()'),
self._toggleShowAbstractPrims)
QtCore.QObject.connect(self._ui.actionRollover_Prim_Info,
QtCore.SIGNAL('triggered()'),
self._toggleRolloverPrimInfo)
QtCore.QObject.connect(self._ui.nodeViewHelp,
QtCore.SIGNAL('clicked()'),
self._showNodeViewHelpDlg)
self._ui.nodeViewHelp.setToolTip(PRIMVIEW_HELP_TEXT)
QtCore.QObject.connect(self._ui.nodeViewLineEdit,
QtCore.SIGNAL('returnPressed()'),
self._ui.nodeViewFindNext.click)
QtCore.QObject.connect(self._ui.nodeViewFindNext,
QtCore.SIGNAL('clicked()'),
self._nodeViewFindNext)
QtCore.QObject.connect(self._ui.attrViewLineEdit,
QtCore.SIGNAL('returnPressed()'),
self._ui.attrViewFindNext.click)
QtCore.QObject.connect(self._ui.attrViewFindNext,
QtCore.SIGNAL('clicked()'),
self._attrViewFindNext)
QtCore.QObject.connect(self._ui.playButton,
QtCore.SIGNAL('clicked()'),
self._playClicked)
QtCore.QObject.connect(self._ui.actionHUD,
QtCore.SIGNAL('triggered()'),
self._updateHUDMenu)
QtCore.QObject.connect(self._ui.actionHUD_Info,
QtCore.SIGNAL('triggered()'),
self._updateHUDMenu)
QtCore.QObject.connect(self._ui.actionHUD_VBO,
QtCore.SIGNAL('triggered()'),
self._HUDMenuChanged)
QtCore.QObject.connect(self._ui.actionHUD_Complexity,
QtCore.SIGNAL('triggered()'),
self._HUDMenuChanged)
QtCore.QObject.connect(self._ui.actionHUD_Performance,
QtCore.SIGNAL('triggered()'),
self._HUDMenuChanged)
QtCore.QObject.connect(self._ui.actionHUD_GPUstats,
QtCore.SIGNAL('triggered()'),
self._HUDMenuChanged)
self.addAction(self._ui.actionIncrementComplexity1)
self.addAction(self._ui.actionIncrementComplexity2)
self.addAction(self._ui.actionDecrementComplexity)
QtCore.QObject.connect(self._ui.actionIncrementComplexity1,
QtCore.SIGNAL('triggered()'),
self._incrementComplexity)
QtCore.QObject.connect(self._ui.actionIncrementComplexity2,
QtCore.SIGNAL('triggered()'),
self._incrementComplexity)
QtCore.QObject.connect(self._ui.actionDecrementComplexity,
QtCore.SIGNAL('triggered()'),
self._decrementComplexity)
QtCore.QObject.connect(self._ui.attributeValueEditor,
QtCore.SIGNAL('editComplete(QString)'),
self.editComplete)
# Edit Prim menu
QtCore.QObject.connect(self._ui.menuEdit_Node,
QtCore.SIGNAL('aboutToShow()'),
self._updateEditNodeMenu)
QtCore.QObject.connect(self._ui.actionFind_Prims,
QtCore.SIGNAL('triggered()'),
self._ui.nodeViewLineEdit.setFocus)
QtCore.QObject.connect(self._ui.actionJump_to_Stage_Root,
QtCore.SIGNAL('triggered()'),
self.resetSelectionToPseudoroot)
QtCore.QObject.connect(self._ui.actionJump_to_Model_Root,
QtCore.SIGNAL('triggered()'),
self.jumpToEnclosingModelSelectedPrims)
QtCore.QObject.connect(self._ui.actionJump_to_Bound_Look,
QtCore.SIGNAL('triggered()'),
self.jumpToBoundLookSelectedPrims)
QtCore.QObject.connect(self._ui.actionJump_to_Master,
QtCore.SIGNAL('triggered()'),
self.jumpToMasterSelectedPrims)
QtCore.QObject.connect(self._ui.actionMake_Visible,
QtCore.SIGNAL('triggered()'),
self.visSelectedPrims)
# Add extra, Presto-inspired shortcut for Make Visible
self._ui.actionMake_Visible.setShortcuts(["Shift+H", "Ctrl+Shift+H"])
QtCore.QObject.connect(self._ui.actionMake_Invisible,
QtCore.SIGNAL('triggered()'),
self.invisSelectedPrims)
QtCore.QObject.connect(self._ui.actionVis_Only,
QtCore.SIGNAL('triggered()'),
self.visOnlySelectedPrims)
QtCore.QObject.connect(self._ui.actionRemove_Session_Visibility,
QtCore.SIGNAL('triggered()'),
self.removeVisSelectedPrims)
QtCore.QObject.connect(self._ui.actionReset_All_Session_Visibility,
QtCore.SIGNAL('triggered()'),
self.resetSessionVisibility)
QtCore.QObject.connect(self._ui.actionLoad,
QtCore.SIGNAL('triggered()'),
self.loadSelectedPrims)
QtCore.QObject.connect(self._ui.actionUnload,
QtCore.SIGNAL('triggered()'),
self.unloadSelectedPrims)
QtCore.QObject.connect(self._ui.actionActivate,
QtCore.SIGNAL('triggered()'),
self.activateSelectedPrims)
QtCore.QObject.connect(self._ui.actionDeactivate,
QtCore.SIGNAL('triggered()'),
self.deactivateSelectedPrims)
self._setupDebugMenu()
# configure plugins
self._configurePlugins()
# save splitter states
QtCore.QObject.connect(self._ui.nodeStageSplitter,
QtCore.SIGNAL('splitterMoved(int, int)'),
self._splitterMoved)
QtCore.QObject.connect(self._ui.topBottomSplitter,
QtCore.SIGNAL('splitterMoved(int, int)'),
self._splitterMoved)
QtCore.QObject.connect(self._ui.attribBrowserInspectorSplitter,
QtCore.SIGNAL('splitterMoved(int, int)'),
self._splitterMoved)
#create a timer for saving splitter states only when they stop moving
self._splitterTimer = QtCore.QTimer(self)
self._splitterTimer.setInterval(500)
QtCore.QObject.connect(self._splitterTimer, QtCore.SIGNAL('timeout()'),