Example #1
0
    def testSelectionSignalFrequency(self):

        d = {
            "a": {
                "e": 10,
            },
            "b": {
                "f": "g",
            },
        }

        p = Gaffer.DictPath(d, "/")
        w = GafferUI.PathListingWidget(p, allowMultipleSelection=True)
        _GafferUI._pathListingWidgetAttachTester(
            GafferUI._qtAddress(w._qtWidget()))

        c = GafferTest.CapturingSlot(w.selectionChangedSignal())
        self.assertEqual(len(c), 0)

        w.setSelectedPaths(
            [Gaffer.DictPath(d, "/a"),
             Gaffer.DictPath(d, "/b")])
        self.assertEqual(set([str(p) for p in w.getSelectedPaths()]),
                         set(["/a", "/b"]))

        self.assertEqual(len(c), 1)
Example #2
0
    def testExpansionSignalFrequency(self):

        d = {}
        for i in range(0, 10):
            dd = {}
            for j in range(0, 10):
                dd[str(j)] = j
            d[str(i)] = dd

        p = Gaffer.DictPath(d, "/")
        w = GafferUI.PathListingWidget(p)
        _GafferUI._pathListingWidgetAttachTester(
            GafferUI._qtAddress(w._qtWidget()))

        c = GafferTest.CapturingSlot(w.expansionChangedSignal())
        self.assertEqual(len(c), 0)

        w.setPathExpanded(Gaffer.DictPath(d, "/1"), True)
        self.assertEqual(len(c), 1)
        w.setPathExpanded(Gaffer.DictPath(d, "/1"), True)
        self.assertEqual(len(c), 1)

        w.setPathExpanded(Gaffer.DictPath(d, "/2"), True)
        self.assertEqual(len(c), 2)

        e = w.getExpandedPaths()
        self.assertEqual(len(e), 2)

        w.setExpandedPaths([])
        self.assertEqual(len(c), 3)

        w.setExpandedPaths(e)
        self.assertEqual(len(c), 4)
Example #3
0
    def testExpandedPaths(self):

        d = {}
        for i in range(0, 10):
            dd = {}
            for j in range(0, 10):
                dd[str(j)] = j
            d[str(i)] = dd

        p = Gaffer.DictPath(d, "/")

        w = GafferUI.PathListingWidget(p)
        self.assertEqual(len(w.getExpandedPaths()), 0)

        p1 = Gaffer.DictPath(d, "/1")
        self.assertEqual(w.getPathExpanded(p1), False)
        w.setPathExpanded(p1, True)
        self.assertEqual(w.getPathExpanded(p1), True)
        self.assertEqual(len(w.getExpandedPaths()), 1)
        self.assertEqual(str(list(w.getExpandedPaths())[0]), str(p1))

        w.setPathExpanded(p1, False)
        self.assertEqual(w.getPathExpanded(p1), False)
        self.assertEqual(len(w.getExpandedPaths()), 0)

        p2 = Gaffer.DictPath(d, "/2")
        p3 = Gaffer.DictPath(d, "/3")
        w.setExpandedPaths([p1, p2])
        self.assertEqual(w.getPathExpanded(p1), True)
        self.assertEqual(w.getPathExpanded(p2), True)
        self.assertEqual(w.getPathExpanded(p3), False)
        self.assertEqual(w.getExpandedPaths(), [p1, p2])

        w.setPath(Gaffer.DictPath({}, "/"))
        self.assertEqual(len(w.getExpandedPaths()), 0)
	def testExpandedPathsWhenPathChanges( self ) :

		d = {
			"a" : {
				"e" : 10,
			},
			"b" : {
				"f" : "g",
			},
		}

		p = Gaffer.DictPath( d, "/" )
		p1 = Gaffer.DictPath( d, "/a" )
		w = GafferUI.PathListingWidget( p, displayMode = GafferUI.PathListingWidget.DisplayMode.Tree )

		self.assertEqual( w.getPathExpanded( p1 ), False )
		w.setPathExpanded( p1, True )
		self.assertEqual( w.getPathExpanded( p1 ), True )

		# fake a change to the path
		p.pathChangedSignal()( p )

		# because the PathListingWidget only updates on idle events, we have
		# to run the event loop to get it to process the path changed signal.
		def stop() :
			GafferUI.EventLoop.mainEventLoop().stop()
			return False

		GafferUI.EventLoop.addIdleCallback( stop )
		GafferUI.EventLoop.mainEventLoop().start()

		# once it has processed things, the expansion should be exactly as it was.
		self.assertEqual( w.getPathExpanded( p1 ), True )
Example #5
0
    def testExpandedPathsWhenPathChangesWithSelection(self):

        d = {
            "a": {
                "e": 10,
            },
            "b": {
                "f": "g",
            },
        }

        p = Gaffer.DictPath(d, "/")
        pa = Gaffer.DictPath(d, "/a")
        pae = Gaffer.DictPath(d, "/a/e")
        w = GafferUI.PathListingWidget(
            p, displayMode=GafferUI.PathListingWidget.DisplayMode.Tree)

        self.assertEqual(w.getPathExpanded(pa), False)
        self.assertEqual(w.getPathExpanded(pae), False)

        w.setSelectedPaths([pa], expandNonLeaf=False)
        self.assertEqual(w.getPathExpanded(pa), False)
        self.assertEqual(w.getPathExpanded(pae), False)

        # fake a change to the path
        p.pathChangedSignal()(p)

        # because the PathListingWidget only updates on idle events, we have
        # to run the event loop to get it to process the path changed signal.
        self.waitForIdle(100)

        # once it has processed things, the expansion should be exactly as it was.
        self.assertEqual(w.getPathExpanded(pa), False)
        self.assertEqual(w.getPathExpanded(pae), False)
Example #6
0
    def testDictTypes(self):

        d = {
            "a": IECore.CompoundObject({
                "b": IECore.IntData(10),
            }),
            "c": IECore.CompoundData({
                "d": IECore.StringData("e"),
            }),
        }

        self.assertEqual(Gaffer.DictPath(d, "/").isLeaf(), False)
        self.assertEqual(Gaffer.DictPath(d, "/a").isLeaf(), False)
        self.assertEqual(Gaffer.DictPath(d, "/a/b").isLeaf(), True)
        self.assertEqual(Gaffer.DictPath(d, "/c").isLeaf(), False)
        self.assertEqual(Gaffer.DictPath(d, "/c/d").isLeaf(), True)

        self.assertEqual(
            Gaffer.DictPath(d, "/",
                            dictTypes=(dict, IECore.CompoundData)).isLeaf(),
            False)
        self.assertEqual(
            Gaffer.DictPath(d, "/a",
                            dictTypes=(dict, IECore.CompoundData)).isLeaf(),
            True)
        self.assertEqual(Gaffer.DictPath(d, "/a/b").isLeaf(), True)
        self.assertEqual(Gaffer.DictPath(d, "/c").isLeaf(), False)
        self.assertEqual(Gaffer.DictPath(d, "/c/d").isLeaf(), True)
Example #7
0
    def testExpansion(self):

        d = {}
        for i in range(0, 10):
            dd = {}
            for j in range(0, 10):
                dd[str(j)] = j
            d[str(i)] = dd

        p = Gaffer.DictPath(d, "/")

        w = GafferUI.PathListingWidget(p)
        _GafferUI._pathListingWidgetAttachTester(
            GafferUI._qtAddress(w._qtWidget()))

        self.assertTrue(w.getExpansion().isEmpty())

        cs = GafferTest.CapturingSlot(w.expansionChangedSignal())
        e = IECore.PathMatcher(["/1", "/2", "/2"])

        w.setExpansion(e)
        self.assertEqual(w.getExpansion(), e)
        self.assertEqual(len(cs), 1)

        w.setPath(Gaffer.DictPath({}, "/"))
        self.assertTrue(w.getExpansion().isEmpty())
    def testExpandedPathsWhenPathChangesWithSelection(self):

        d = {
            "a": {
                "e": 10,
            },
            "b": {
                "f": "g",
            },
        }

        p = Gaffer.DictPath(d, "/")
        pa = Gaffer.DictPath(d, "/a")
        pae = Gaffer.DictPath(d, "/a/e")
        w = GafferUI.PathListingWidget(
            p, displayMode=GafferUI.PathListingWidget.DisplayMode.Tree)
        _GafferUI._pathListingWidgetAttachTester(
            GafferUI._qtAddress(w._qtWidget()))

        self.assertEqual(w.getPathExpanded(pa), False)
        self.assertEqual(w.getPathExpanded(pae), False)

        w.setSelectedPaths([pa], expandNonLeaf=False)
        self.assertEqual(w.getPathExpanded(pa), False)
        self.assertEqual(w.getPathExpanded(pae), False)

        # Fake a change to the path and check that the expansion is exactly as
        # it was.
        self.__emitPathChanged(w)
        self.assertEqual(w.getPathExpanded(pa), False)
        self.assertEqual(w.getPathExpanded(pae), False)
    def testExpandedPathsWhenPathChanges(self):

        d = {
            "a": {
                "e": 10,
            },
            "b": {
                "f": "g",
            },
        }

        p = Gaffer.DictPath(d, "/")
        p1 = Gaffer.DictPath(d, "/a")
        w = GafferUI.PathListingWidget(
            p, displayMode=GafferUI.PathListingWidget.DisplayMode.Tree)
        _GafferUI._pathListingWidgetAttachTester(
            GafferUI._qtAddress(w._qtWidget()))

        self.assertEqual(w.getPathExpanded(p1), False)
        w.setPathExpanded(p1, True)
        self.assertEqual(w.getPathExpanded(p1), True)

        # Fake a change to the path and check that the expansion is exactly as
        # it was.
        self.__emitPathChanged(w)
        self.assertEqual(w.getPathExpanded(p1), True)
        self.assertEqual(self.__expansionFromQt(w), IECore.PathMatcher(["/a"]))
Example #10
0
    def testSelection(self):

        d = {}
        for i in range(0, 10):
            dd = {}
            for j in range(0, 10):
                dd[str(j)] = j
            d[str(i)] = dd

        p = Gaffer.DictPath(d, "/")

        w = GafferUI.PathListingWidget(p, allowMultipleSelection=True)
        _GafferUI._pathListingWidgetAttachTester(
            GafferUI._qtAddress(w._qtWidget()))
        self.assertTrue(w.getSelection().isEmpty())

        cs = GafferTest.CapturingSlot(w.selectionChangedSignal())
        s = IECore.PathMatcher(["/1", "/2/5", "/3/1"])

        w.setSelection(s)
        self.assertEqual(w.getSelection(), s)
        self.assertEqual(len(cs), 1)

        w.setPath(Gaffer.DictPath({}, "/"))
        self.assertTrue(w.getSelection().isEmpty())
Example #11
0
    def testExpandedPathsWhenPathChanges(self):

        d = {
            "a": {
                "e": 10,
            },
            "b": {
                "f": "g",
            },
        }

        p = Gaffer.DictPath(d, "/")
        p1 = Gaffer.DictPath(d, "/a")
        w = GafferUI.PathListingWidget(
            p, displayMode=GafferUI.PathListingWidget.DisplayMode.Tree)
        _GafferUI._pathListingWidgetAttachTester(
            GafferUI._qtAddress(w._qtWidget()))

        self.assertEqual(w.getPathExpanded(p1), False)
        w.setPathExpanded(p1, True)
        self.assertEqual(w.getPathExpanded(p1), True)

        # fake a change to the path
        p.pathChangedSignal()(p)

        # because the PathListingWidget only updates on idle events, we have
        # to run the event loop to get it to process the path changed signal.
        self.waitForIdle(100)

        # once it has processed things, the expansion should be exactly as it was.
        self.assertEqual(w.getPathExpanded(p1), True)
Example #12
0
    def testChildDictTypes(self):

        d = {"a": IECore.CompoundObject()}

        p = Gaffer.DictPath(d, "/")
        c = p.children()[0]
        self.assertEqual(c.isLeaf(), False)

        p = Gaffer.DictPath(d, "/", dictTypes=(dict, ))
        c = p.children()[0]
        self.assertEqual(c.isLeaf(), True)
Example #13
0
    def __init__(self, path):

        tmpPath = Gaffer.DictPath(
            {}, "/")  # empty path we can use till we get an indexed io file
        with GafferUI.ListContainer(borderWidth=8, spacing=8) as column:

            self.__pathWidget = GafferUI.PathWidget(tmpPath)

            with GafferUI.SplitContainer(
                    GafferUI.ListContainer.Orientation.Horizontal):

                self.__pathListing = GafferUI.PathListingWidget(
                    tmpPath,
                    columns=[
                        GafferUI.PathListingWidget.defaultNameColumn,
                        GafferUI.PathListingWidget.
                        defaultIndexedIODataTypeColumn,
                    ],
                    displayMode=GafferUI.PathListingWidget.DisplayMode.Tree,
                )

                self.__pathPreview = GafferUI.DataPathPreview(tmpPath)

        GafferUI.DeferredPathPreview.__init__(self, column, path)

        self.__prevPath = tmpPath
        self._updateFromPath()
Example #14
0
	def __init__( self, scriptNode, **kw ) :

		column = GafferUI.ListContainer( GafferUI.ListContainer.Orientation.Vertical, borderWidth = 8, spacing = 4 )

		GafferUI.NodeSetEditor.__init__( self, column, scriptNode, **kw )

		searchFilter = _GafferSceneUI._SceneHierarchySearchFilter()
		setFilter = _GafferSceneUI._SceneHierarchySetFilter()
		setFilter.setEnabled( False )

		self.__filter = Gaffer.CompoundPathFilter( [ searchFilter, setFilter ] )

		with column :

			with GafferUI.ListContainer( GafferUI.ListContainer.Orientation.Horizontal, spacing = 4 ) :

				_SearchFilterWidget( searchFilter )
				_SetFilterWidget( setFilter )

			self.__pathListing = GafferUI.PathListingWidget(
				Gaffer.DictPath( {}, "/" ), # temp till we make a ScenePath
				columns = [ GafferUI.PathListingWidget.defaultNameColumn ],
				allowMultipleSelection = True,
				displayMode = GafferUI.PathListingWidget.DisplayMode.Tree,
			)
			self.__pathListing.setDragPointer( "objects" )
			self.__pathListing.setSortable( False )

			self.__selectionChangedConnection = self.__pathListing.selectionChangedSignal().connect( Gaffer.WeakMethod( self.__selectionChanged ) )
			self.__expansionChangedConnection = self.__pathListing.expansionChangedSignal().connect( Gaffer.WeakMethod( self.__expansionChanged ) )

		self.__plug = None
		self._updateFromSet()
    def testSetExpansionClearsExpansionByUser(self):

        w = GafferUI.PathListingWidget(
            Gaffer.DictPath({
                "a": 1,
                "b": 2,
                "c": 3
            }, "/"),
            displayMode=GafferUI.PathListingWidget.DisplayMode.Tree)
        model = w._qtWidget().model()
        model.rowCount()  # Trigger population of top level of the model
        _GafferUI._pathModelWaitForPendingUpdates(GafferUI._qtAddress(model))
        self.assertEqual(w.getExpansion(), IECore.PathMatcher())

        w._qtWidget().expand(model.index(
            0, 0))  # Equivalent to a click by the user
        self.assertEqual(w.getExpansion(), IECore.PathMatcher(["/a"]))

        w.setExpansion(IECore.PathMatcher(["/b"]))
        _GafferUI._pathModelWaitForPendingUpdates(GafferUI._qtAddress(model))
        self.assertEqual(self.__expansionFromQt(w), IECore.PathMatcher(["/b"]))

        w._qtWidget().collapse(model.index(
            1, 0))  # Equivalent to a click by the user
        self.assertEqual(w.getExpansion(), IECore.PathMatcher())
        w.setExpansion(IECore.PathMatcher(["/b"]))
        _GafferUI._pathModelWaitForPendingUpdates(GafferUI._qtAddress(model))
        self.assertEqual(self.__expansionFromQt(w), IECore.PathMatcher(["/b"]))
Example #16
0
    def __init__(self, scriptNode, **kw):
        self.__column = GafferUI.ListContainer(borderWidth=8, spacing=6)
        GafferUI.EditorWidget.__init__(self, self.__column, scriptNode, **kw)

        with self.__column:
            GafferUI.Image("%s/pipeBrowser.png" % pipe.name())
            with GafferUI.ListContainer(
                    GafferUI.ListContainer.Orientation.Horizontal, spacing=6):
                GafferUI.Label("Role")
                modeMenu = GafferUI.SelectionMenu()
                for mode in self.__modes:
                    modeMenu.addItem(mode[0])

                self.__modeChangedConnection = modeMenu.currentIndexChangedSignal(
                ).connect(Gaffer.WeakMethod(self.__modeChanged))

            self.__pathChooser = GafferUI.PathChooserWidget(
                Gaffer.DictPath({}, "/"),
                previewTypes=GafferUI.PathPreviewWidget.types())
            self.__pathChooser.pathWidget().setVisible(True)
            # turns the listmode and path string invisible!
            self.__pathChooser.directoryPathWidget().parent().setVisible(True)

        self.__modeInstances = {}
        self.__currentModeInstance = None
        self.__modeChanged(modeMenu)
Example #17
0
    def __init__(self):

        GafferUI.PathListingWidget.__init__(
            self,
            Gaffer.DictPath({}, "/"),
            # listing displays the plug name and automatically sorts based on plug index
            columns=(GafferUI.PathListingWidget.Column(
                "dict:value", "Name", lambda x: x.plug.getName(),
                lambda x: x.index), ),
            displayMode=GafferUI.PathListingWidget.DisplayMode.Tree,
        )

        self.__parent = None  # the parent of the plugs we're listing

        self.setDragPointer("")

        self.setHeaderVisible(False)
        self.__dragEnterConnection = self.dragEnterSignal().connect(
            Gaffer.WeakMethod(self.__dragEnter))
        self.__dragMoveConnection = self.dragMoveSignal().connect(
            Gaffer.WeakMethod(self.__dragMove))
        self.__dragEndConnection = self.dragEndSignal().connect(
            Gaffer.WeakMethod(self.__dragEnd))
        self.__keyPressConnection = self.keyPressSignal().connect(
            Gaffer.WeakMethod(self.__keyPress))

        self.__metadataPlugValueChangedConnection = Gaffer.Metadata.plugValueChangedSignal(
        ).connect(Gaffer.WeakMethod(self.__plugMetadataChanged))
Example #18
0
    def __init__(self, scriptNode, **kw):

        self.__column = GafferUI.ListContainer(borderWidth=8, spacing=6)

        GafferUI.EditorWidget.__init__(self, self.__column, scriptNode, **kw)

        with self.__column:

            with GafferUI.ListContainer(
                    GafferUI.ListContainer.Orientation.Horizontal, spacing=6):

                GafferUI.Label("Location")

                modeMenu = GafferUI.MultiSelectionMenu(
                    allowMultipleSelection=False,
                    allowEmptySelection=False,
                )
                for mode in self.__modes:
                    modeMenu.append(mode[0])
                self.__modeChangedConnection = modeMenu.selectionChangedSignal(
                ).connect(Gaffer.WeakMethod(self.__modeChanged))

            self.__pathChooser = GafferUI.PathChooserWidget(
                Gaffer.DictPath({}, "/"),
                previewTypes=GafferUI.PathPreviewWidget.types())
            self.__pathChooser.pathWidget().setVisible(False)

        self.__modeInstances = {}
        self.__currentModeInstance = None
        modeMenu.setSelection([self.__modes[0][0]])
Example #19
0
	def __init__( self, path, previewTypes=[], allowMultipleSelection=False, **kw ) :
	
		self.__column = GafferUI.ListContainer( GafferUI.ListContainer.Orientation.Vertical, spacing=8 )
		
		GafferUI.Widget.__init__( self, self.__column, **kw )
		
		# we use this temporary path for our child widgets while constructing, and then call
		# self.setPath() to replace it with the real thing. this lets us avoid duplicating the
		# logic we need in setPath().
		tmpPath = Gaffer.DictPath( {}, "/" )
		with self.__column :
		
			# row for manipulating current directory
			with GafferUI.ListContainer( GafferUI.ListContainer.Orientation.Horizontal, spacing = 0 ) :
				
				self.__displayModeButton = GafferUI.Button( image = "pathListingTree.png", hasFrame=False )
				self.__displayModeButton.setToolTip( "Toggle between list and tree views" )
				self.__displayModeButtonClickedConnection = self.__displayModeButton.clickedSignal().connect( Gaffer.WeakMethod( self.__displayModeButtonClicked ) )
				
				reloadButton = GafferUI.Button( image = "refresh.png", hasFrame=False )
				reloadButton.setToolTip( "Refresh view" )
				self.__reloadButtonClickedConnection = reloadButton.clickedSignal().connect( Gaffer.WeakMethod( self.__reloadButtonClicked ) )
				
				upButton = GafferUI.Button( image = "pathUpArrow.png", hasFrame=False )
				upButton.setToolTip( "Up one level" )
				self.__upButtonClickedConnection = upButton.clickedSignal().connect( Gaffer.WeakMethod( self.__upButtonClicked ) )
				
				GafferUI.Spacer( IECore.V2i( 4, 4 ) )
				
				self.__dirPathWidget = GafferUI.PathWidget( tmpPath )
			
			# directory listing and preview widget
			with GafferUI.SplitContainer( GafferUI.SplitContainer.Orientation.Horizontal, expand=True ) as splitContainer :
			
				self.__directoryListing = GafferUI.PathListingWidget( tmpPath, allowMultipleSelection=allowMultipleSelection )
				self.__displayModeChangedConnection = self.__directoryListing.displayModeChangedSignal().connect( Gaffer.WeakMethod( self.__displayModeChanged ) )
				if len( previewTypes ) :
					self.__previewWidget = GafferUI.CompoundPathPreview( tmpPath, childTypes=previewTypes )
				else :
					self.__previewWidget = None
				
			if len( splitContainer ) > 1 :
				splitContainer.setSizes( [ 2, 1 ] ) # give priority to the listing over the preview
		
			# filter section
			self.__filterFrame = GafferUI.Frame( borderWidth=0, borderStyle=GafferUI.Frame.BorderStyle.None )
			self.__filter = None
				
			# path
			self.__pathWidget = GafferUI.PathWidget( tmpPath )
			self.__pathWidget.setVisible( allowMultipleSelection == False )
		
		self.__pathSelectedSignal = GafferUI.WidgetSignal()

		self.__listingSelectionChangedConnection = self.__directoryListing.selectionChangedSignal().connect( Gaffer.WeakMethod( self.__listingSelectionChanged ) )
		self.__listingSelectedConnection = self.__directoryListing.pathSelectedSignal().connect( Gaffer.WeakMethod( self.__pathSelected ) )
		self.__pathWidgetSelectedConnection = self.__pathWidget.activatedSignal().connect( Gaffer.WeakMethod( self.__pathSelected ) )
			
		self.__path = None
		self.setPath( path )
    def __init__(self, scriptNode, **kw):

        column = GafferUI.ListContainer(
            GafferUI.ListContainer.Orientation.Vertical, borderWidth=8)

        GafferUI.NodeSetEditor.__init__(self, column, scriptNode, **kw)

        with column:

            self.__pathListing = GafferUI.PathListingWidget(
                Gaffer.DictPath({}, "/"),  # temp till we make a ScenePath
                columns=[GafferUI.PathListingWidget.defaultNameColumn],
                allowMultipleSelection=True,
                displayMode=GafferUI.PathListingWidget.DisplayMode.Tree,
            )
            self.__pathListing.setDragPointer("objects")
            self.__pathListing.setSortable(False)

            self.__selectionChangedConnection = self.__pathListing.selectionChangedSignal(
            ).connect(Gaffer.WeakMethod(self.__selectionChanged))
            self.__expansionChangedConnection = self.__pathListing.expansionChangedSignal(
            ).connect(Gaffer.WeakMethod(self.__expansionChanged))

        self.__plug = None
        self.__playback = None
        self._updateFromSet()
    def testSelectionExpansion(self):

        d = {}
        for i in range(0, 10):
            dd = {}
            for j in range(0, 10):
                dd[str(j)] = j
            d[str(i)] = dd

        p = Gaffer.DictPath(d, "/")

        w = GafferUI.PathListingWidget(
            p,
            allowMultipleSelection=True,
            displayMode=GafferUI.PathListingWidget.DisplayMode.Tree)
        _GafferUI._pathListingWidgetAttachTester(
            GafferUI._qtAddress(w._qtWidget()))

        self.assertTrue(w.getSelection().isEmpty())
        self.assertTrue(w.getExpansion().isEmpty())

        s = IECore.PathMatcher(["/1", "/2", "/9", "/2/5"])
        w.setSelection(s, expandNonLeaf=True, scrollToFirst=False)
        self.assertEqual(w.getSelection(), s)
        _GafferUI._pathModelWaitForPendingUpdates(
            GafferUI._qtAddress(w._qtWidget().model()))
        self.assertEqual(w.getExpansion(),
                         IECore.PathMatcher(["/1", "/2", "/9"]))
Example #22
0
    def __init__(self, scriptNode, **kw):

        column = GafferUI.ListContainer(
            GafferUI.ListContainer.Orientation.Vertical,
            borderWidth=8,
            spacing=4)

        GafferUI.NodeSetEditor.__init__(self, column, scriptNode, **kw)

        searchFilter = _GafferSceneUI._HierarchyViewSearchFilter()
        setFilter = _GafferSceneUI._HierarchyViewSetFilter()
        setFilter.setEnabled(False)

        self.__filter = Gaffer.CompoundPathFilter([searchFilter, setFilter])

        with column:

            with GafferUI.ListContainer(
                    GafferUI.ListContainer.Orientation.Horizontal, spacing=4):

                _SearchFilterWidget(searchFilter)
                _SetFilterWidget(setFilter)

            self.__pathListing = GafferUI.PathListingWidget(
                Gaffer.DictPath({}, "/"),  # temp till we make a ScenePath
                columns=[GafferUI.PathListingWidget.defaultNameColumn],
                allowMultipleSelection=True,
                displayMode=GafferUI.PathListingWidget.DisplayMode.Tree,
            )
            self.__pathListing.setDragPointer("objects")
            self.__pathListing.setSortable(False)

            # Work around insanely slow selection of a range containing many
            # objects (using a shift-click). The default selection behaviour
            # is SelectRows and this triggers some terrible performance problems
            # in Qt. Since we only have a single column, there is no difference
            # between SelectItems and SelectRows other than the speed.
            #
            # This workaround isn't going to be sufficient when we come to add
            # additional columns to the HierarchyView. What _might_ work instead
            # is to override `QTreeView.setSelection()` in PathListingWidget.py,
            # so that we manually expand the selected region to include full rows,
            # and then don't have to pass the `QItemSelectionModel::Rows` flag to
            # the subsequent `QItemSelectionModel::select()` call. This would be
            # essentially the same method we used to speed up
            # `PathListingWidget.setSelection()`.
            #
            # Alternatively we could avoid QItemSelectionModel entirely by managing
            # the selection ourself as a persistent PathMatcher.
            self.__pathListing._qtWidget().setSelectionBehavior(
                self.__pathListing._qtWidget().SelectionBehavior.SelectItems)

            self.__selectionChangedConnection = self.__pathListing.selectionChangedSignal(
            ).connect(Gaffer.WeakMethod(self.__selectionChanged))
            self.__expansionChangedConnection = self.__pathListing.expansionChangedSignal(
            ).connect(Gaffer.WeakMethod(self.__expansionChanged))

        self.__plug = None
        self._updateFromSet()
Example #23
0
    def __updatePath(self):

        if self.__parent is None:
            # we have nothing to show - early out.
            self.setPath(Gaffer.DictPath({}, "/"))
            return

        # build a DictPath to represent our child plugs.

        plugs = self.__parent.children(Gaffer.Plug)
        plugs = GafferUI.PlugLayout.layoutOrder(plugs)

        d = {}
        for index, plug in enumerate(plugs):
            d[plug.getName()] = self.Entry(plug, index)

        self.setPath(Gaffer.DictPath(d, "/"))
Example #24
0
    def testDeeperExpandedPaths(self):

        p = Gaffer.DictPath({"a": {"b": {"c": {"d": 10}}}}, "/")

        w = GafferUI.PathListingWidget(p)
        w.setPathExpanded(p.copy().setFromString("/a/b/c"), True)

        self.assertTrue(w.getPathExpanded(p.copy().setFromString("/a/b/c")))
Example #25
0
    def testProperties(self):

        d = {
            "one": 1,
            "d": {
                "two": 2,
            },
        }

        p = Gaffer.DictPath(d, "/one")
        self.assertTrue("dict:value" in p.propertyNames())
        self.assertEqual(p.property("dict:value"), 1)

        p = Gaffer.DictPath(d, "/d")
        self.assertEqual(p.property("dict:value"), None)

        p = Gaffer.DictPath(d, "/ invalid")
        self.assertEqual(p.property("dict:value"), None)
    def testChangingDirectoryClearsSelection(self):

        path = Gaffer.DictPath({"a": {"b": {"c": 10}}}, "/")
        widget = GafferUI.PathListingWidget(path)

        widget.setSelection(IECore.PathMatcher(["/a"]))
        self.assertEqual(widget.getSelection(), IECore.PathMatcher(["/a"]))

        path.append("a")
        self.assertEqual(widget.getSelection(), IECore.PathMatcher())
Example #27
0
    def testRepr(self):

        d = {
            "one": 1,
            "two": 2,
        }

        p = Gaffer.DictPath(d, "/one")

        self.assertEqual(repr(p), "DictPath( '/one' )")
Example #28
0
    def __dictPath(self):

        dict = {}
        dict["dir"] = {}
        for f in IECore.FileSequence("a.#.exr 1-10").fileNames():
            dict["dir"][f] = 1
        for f in IECore.FileSequence("b.####.tiff 20-200x2").fileNames():
            dict["dir"][f] = 1

        return Gaffer.DictPath(dict, "/")
Example #29
0
    def testSortable(self):

        w = GafferUI.PathListingWidget(Gaffer.DictPath({}, "/"))
        self.assertTrue(w.getSortable())

        w.setSortable(False)
        self.assertFalse(w.getSortable())

        w.setSortable(True)
        self.assertTrue(w.getSortable())
Example #30
0
	def __setPathListingPath( self ) :

		if self.__plug is not None :
			# Note that we take a static copy of our current context for use in the ScenePath - this prevents the
			# PathListing from updating automatically when the original context changes, and allows us to have finer
			# grained control of the update in our _updateFromContext() method.
			self.__pathListing.setPath( GafferScene.ScenePath( self.__plug, Gaffer.Context( self.getContext() ), "/" ) )
			self.__transferExpansionFromContext()
			self.__transferSelectionFromContext()
		else :
			self.__pathListing.setPath( Gaffer.DictPath( {}, "/" ) )