Friday, August 31, 2018

Drag and Drop from a QTreeWidget to another QTreeWidget

Sweet mercy of mercies. I've been trying for *much* too long to figure out how the (hell!) to drag-and-drop simple MIME data from one Qt (in this case, PyQt) QTreeWidget to another QTreeWidget. After what felt like about 1000 pages of StackOverflow that I read through, I finally found a super-helpful example from someone demonstrating custom MIME types.

I just wanted a simple example of drag-and-drop from one QAbstractItemView to another, and so while that example was fantastic, I was able to simplify it much more to demonstrate just a simple-as-heck/dumb-as-anything/silly-old drag-and-drop. The documentation is shockingly bad about Drag-And-Drop in general in Qt, and I feel like it's so overly complicated when you just want to do something simple... I figured I'd repost this demo code here for the possibly-millions of other folks with the exact same question as I had: "How do I just.. like... drag and drop a SIMPLE thing from on QTreeWidget to another?!?!"

My friends, the answer is annoyingly simple, and there's nothing special here. You don't need to set a bazillion obscure flags on your QTreeWidgetItems or the other 1000 things I tried before landing on the simple way to do it. Here you are (and to my future self who is trying to remember this example... you're welcome) :)


from PyQt4 import QtCore
from PyQt4 import QtGui

class DragDropTreeWidget(QtGui.QTreeWidget):
    def __init__(self):
        super(DragDropTreeWidget, self).__init__()        
        self.setRootIsDecorated(False) # I'm using the QTreeWidget like a QTableWidget here.
        self.setSelectionMode(QtGui.QAbstractItemView.SingleSelection)
    
    def mimeTypes(self):
        mimetypes = QtGui.QTreeWidget.mimeTypes(self)
        mimetypes.append("text/plain")
        return mimetypes

    def startDrag(self, allowableActions):
        drag = QtGui.QDrag(self)
        
        # only one item is selectable at once so self.selectedItems() should have a length of 1 only
        selectedItems = self.selectedItems()
        if len(selectedItems) < 1:
            return
        # else use the first item
        selectedTreeWidgetItem = selectedItems[0]

        # for this to work, just note that you need to add your own extension to the QTreeWidgetItem
        # so you can implement this simple data getter method.
        dragAndDropName = selectedTreeWidgetItem.dragAndDropName()
        
        mimedata = QtCore.QMimeData()
        mimedata.setText(dragAndDropName)        
        drag.setMimeData(mimedata)
        drag.exec_(allowableActions)

    def dropEvent(self, event):
        if event.mimeData().hasFormat("text/plain"):
            passedData = event.mimeData().text()
            event.acceptProposedAction()
            print "passedData", passedData
            # TODO handle drop event (prob emit a signal to be caught somewhere else)


Magnificent! So that's it... amazingly. Nothing else is required. See... drag and drop in PyQt IS simple... right??! Anyone?!?

Note that to instantiate this demo you should do something like so, twice. Make two of these tree widgets and add them to your MainWindow and then you can test drag and drop between them.
=============
treeWidget = DragDropTreeWidget()        
header = QtGui.QTreeWidgetItem(["Header Name"])
treeWidget.setHeaderItem(header)

# Note this item should actually be a custom extension of QTreeWidgetItem if you want to implement the "dragAndDropName" method mentioned above.
root = QtGui.QTreeWidgetItem("Item in tree") 
treeWidget.addTopLevelItem(root)
treeWidget.setDragEnabled(True)
==============

Happy drag-and-dropping, friends!

Tuesday, August 07, 2018

Tuesday, May 29, 2018

Check out all the Star Wars and Pixar toys on "My Disney Desk" at ILM!

Disney D23 just posted this fun video we shot a few weeks ago of me at "My Disney Desk" -- talking about some of the work I do here at ILM, and sharing some of my favourite Pixar and Star Wars toys that adorn my office here at ILM's San Francisco office. Enjoy!



If you love all things Pixar, you need to check out the desk of Industrial Light & Magic’s Mike Jutan, one of the award-winning creators of the BlockParty software, which has been used to create special effects in some of your favorite films, such as Pirates of the Caribbean: Dead Man’s Chest and the upcoming Solo: A Star Wars Story. When he’s not making movie magic, Jutan maintains an amazing Pixar collection, including an impressive selection of characters from Cars. He’s working his dream job—and he’s got a dream desk to match!

Wednesday, February 14, 2018

Academy Sci-Tech Awards acceptance speech posted!

Wow, that was quick! The official Oscars YouTube channel posted our acceptance speech from the Academy Scientific & Technical Awards Ceremony the morning after we gave it! The ceremony was absolutely incredible -- it was held at the Beverly Wilshire in Beverly Hills, CA on Saturday, February 10, 2018. This is a lifelong dream come true for all of us, and the ILM BlockParty team is incredibly grateful for this honour. Please also see my previous blog post for the "long version" of my thank-you list :)

Check out our acceptance speech here (along with Sir Patrick Stewart's opening and introduction!), along with some recently posted articles from the Canadian news media and a CBC Radio interview I gave last month about the award.



CBC Radio (Interview)
London man to receive technical Oscar next month

The Canadian Press (Multiple Outlets)
Metro News: Several Canadians to get sci-tech Oscars for work on films including 'Star Wars'
CBC: Several Canadians to get sci-tech Oscars 'for technology that's changed the industry'
National Post: Several Canadians to get sci-tech Oscars for work on films including 'Star Wars'
etalk: Canadian engineer Mike Jutan among 'math geeks' grabbing Oscar honours
CP24: Several Canadians to get sci-tech Oscars for work on films including 'Star Wars'

Thursday, January 04, 2018

We WON a Technical ACADEMY AWARD!!!!!!!!!!!

Today is the culmination of a lifelong dream... we WON a Technical ACADEMY AWARD!!!!!!!!!!!!!!!!!!! We are being presented with this unbelievable honour from the Academy of Motion Picture Arts and Sciences for our BlockParty Procedural Rigging System at ILM, a project that we have put many, many, many years of effort, love, hope, dreams, and grit into.

Congratulations to my fellow honourees: the illustrious and magnificently brilliant Dr. Rachel Heck Rose, and the supremely innovative VFX legends Jason Smith and Jeff White for challenging what rigging can be and deeply questioning how it could be achieved.

Industrial Light & Magic is a magical place, a mix of art and science geniuses, and so many more people contributed to this effort and made it possible. Most notably, the vision and dedication of John Doublestein is how we were able to make such a groundbreaking solution. To Jacob Buck and Abs Jahromi for pushing us to make this work for this most insane of rigs (read: "Transformers"), to Brian Paik and Chris Havreberg and Chase Cooper and many others for making sure we solved soft-body creatures in absurdly scalable way (read: "Warcraft"). To Darby Johnston, Erik Dillinger, Kent Oberheu for your support, ingenuity, and incredible efforts as we launched full-force into this. To Eric Feng and Yuting Ye for your undying work and engineering mastery. To Scott Jones for making sure we were reaching all artist-level audiences appropriately. There are so many more to thank, but know this: if you helped in any way... we truly and deeply appreciate your incredible support to help lead us to this stage.

I've often referred to this as the "Gold Medal of Computer Graphics". This is a lifelong dream come true. This is an achievement I've dreamed of since I was a 10 year old kid, watching ILM's unbelievable work in Terminator 2: Judgement Day, and dreaming of one day, being one of the people who helps make beautiful imagery possible through a blend of art and science. Thank you to many supporting characters in this goal, throughout the years -- my parents Arthur Jutan and Cheryll Rose Jutan for your unbelievable encouragement and dedication to your son's dreams, to my sister Norma Hall for letting me always use the computer, at all hours of the night, even when she had school work to do, to my best buddies Matthew Lausch and Alex Finlayson for sharing our drive and commitment to Computer Science with each other, to my wife Michal Jutan for her infinite love, support, encouragement, hand-holding, de-nervousing, and a list of about 10000 other things she does to keep me on track and at my best.

And finally, to the many professional supporters in my life, people who took a chance on this little energetic kid from London, Ontario, who was so desperate to use Computer Science to help making movies "even more awesome": Josh Cameron for being the best damn mentor and MEL teacher I could have ever asked for, to Kevin Tate for giving me a chance in my initial interview for Alias|Wavefront, to John Gross and Shai Hinitz for their mentoring, support, encouragement, and reference letters that made my parents prouder than almost anything else I've ever done, to Kevin Tureski for looking out for me and finding amazing opportunities (TEDx!) to help me spread my wings, to Marc Sondheimer and Guido Quaroni for an opportunity of a lifetime at Pixar and to Jacob Brooks, Franklin Chance, Matthew Atabet Parrott and Kurt Phillips for being the best of buddies to a nervous Canadian dude trying his damnedest to make a good impression in California. And finally, to my family at ILM: the wise, gracious, and brilliant Cary Phillips for being a guiding light for my career, to Rachel Heck Rose for being the perfect teammate, friend, and leader over the last 10 years, and for all others who helped support my career, my goals, and find wild and wonderful opportunities for me to jump into and do my best work.

Thank you all (and the many more I'm sure I missed) for all your help in getting us to this momentous moment.

Here is the official press release from The Academy:

TECHNICAL ACHIEVEMENT AWARDS (ACADEMY CERTIFICATES)

To Jason Smith and Jeff White for the original design, and to Rachel Rose and Mike Jutan for the architecture and engineering, of the BlockParty procedural rigging system at Industrial Light & Magic.
BlockParty streamlines the rigging process through a comprehensive connection framework, a novel graphical user interface, and volumetric rig transfer, which has enabled ILM to build richly detailed and unique creatures while greatly improving artist productivity.
and a great article from The Wrap explaining a bit more: