Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Why does complete understanding of Qt's scene graph coordinates lead no where?
Forum Updated to NodeBB v4.3 + New Features

Why does complete understanding of Qt's scene graph coordinates lead no where?

Scheduled Pinned Locked Moved Unsolved General and Desktop
5 Posts 2 Posters 537 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • enjoysmathE Offline
    enjoysmathE Offline
    enjoysmath
    wrote on last edited by enjoysmath
    #1
    def mouseMoveEvent(self, event):
          if self._placeItems:
              delta = event.scenePos() - event.lastScenePos()
              for item in self._placeItems:
                  item.setPos(item.pos() + item.mapToParent(item.mapFromScene(delta)))
          super().mouseMoveEvent(event)
    

    Approach: intuitively correct based on Qt's local/parent/scene coordinate system.
    Result: parented item shoots off into hyper space when you try to place it.

    def mouseMoveEvent(self, event):
           if self._placeItems:
               delta = event.scenePos() - event.lastScenePos()
               for item in self._placeItems:
                   item.setPos(item.pos() + delta)
           super().mouseMoveEvent(event)
    

    Approach: f*ck it, I'll just try passing in delta without transforming it!
    Result: The shit works! Idk why...

    Now multiply that by all the bugs you're going to run into... It starts to significantly effect debug time.

    1 Reply Last reply
    0
    • Kent-DorfmanK Offline
      Kent-DorfmanK Offline
      Kent-Dorfman
      wrote on last edited by
      #2

      just thinking out loud, but it seems you don't have a complete understanding of what coordinates are local and what coordinates are global. if the scenegraph stuff works like other Qt widgets then each widget has its own localized coordinate system, independent of the parent.

      I light my way forward with the fires of all the bridges I've burned behind me.

      enjoysmathE 3 Replies Last reply
      1
      • Kent-DorfmanK Kent-Dorfman

        just thinking out loud, but it seems you don't have a complete understanding of what coordinates are local and what coordinates are global. if the scenegraph stuff works like other Qt widgets then each widget has its own localized coordinate system, independent of the parent.

        enjoysmathE Offline
        enjoysmathE Offline
        enjoysmath
        wrote on last edited by
        #3
        This post is deleted!
        1 Reply Last reply
        0
        • Kent-DorfmanK Kent-Dorfman

          just thinking out loud, but it seems you don't have a complete understanding of what coordinates are local and what coordinates are global. if the scenegraph stuff works like other Qt widgets then each widget has its own localized coordinate system, independent of the parent.

          enjoysmathE Offline
          enjoysmathE Offline
          enjoysmath
          wrote on last edited by enjoysmath
          #4

          @Kent-Dorfman

          Even knowing that. My code still seems correct, so how would you do the proper transformation?

          For even this causes a shoot of into hyperspace:

          def mouseMoveEvent(self, event):
                 if self._placeItems:
                     delta = event.scenePos() - event.lastScenePos()
                     for item in self._placeItems:
                         p = item.parentItem()
                         if p: delta = p.mapFromScene(delta)
                         item.setPos(item.pos() + delta)
                         # BUGFIX: this doesn't work: item.mapToParent(item.mapFromScene(delta)))
                 super().mouseMoveEvent(event)
          
          1 Reply Last reply
          0
          • Kent-DorfmanK Kent-Dorfman

            just thinking out loud, but it seems you don't have a complete understanding of what coordinates are local and what coordinates are global. if the scenegraph stuff works like other Qt widgets then each widget has its own localized coordinate system, independent of the parent.

            enjoysmathE Offline
            enjoysmathE Offline
            enjoysmath
            wrote on last edited by
            #5

            @Kent-Dorfman yes, but if you have greatgrandparent-> grandparent-> parent -> item, then positioning of item is done in parent, so what I'm referring to is the the movement of item relative to scene, which by definition is a chaining of transformations. It's item.pos() + parent.pos() + grandparent.pos() + greatgrandparent.pos() for lack of better notation.

            1 Reply Last reply
            0

            • Login

            • Login or register to search.
            • First post
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • Users
            • Groups
            • Search
            • Get Qt Extensions
            • Unsolved