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. Panoramic view in QGraphicsView
Forum Updated to NodeBB v4.3 + New Features

Panoramic view in QGraphicsView

Scheduled Pinned Locked Moved Unsolved General and Desktop
9 Posts 2 Posters 3.5k Views 2 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.
  • ck_eeC Offline
    ck_eeC Offline
    ck_ee
    wrote on last edited by
    #1

    hi, i have a panoramic 360° picture which i put on a QGraphicsScene and show with a QGraphicsView. I'd like to be able to pan it to the right or left infinitley and it would always repeat the image on the borders.

    Like this: ```
    http://www.airpano.ru/files/Brasil-Rio-de-Janeiro/2-2

    
    but only in one vertical direction ..
    1 Reply Last reply
    0
    • ck_eeC Offline
      ck_eeC Offline
      ck_ee
      wrote on last edited by
      #2

      push push push

      1 Reply Last reply
      0
      • mrjjM Offline
        mrjjM Offline
        mrjj
        Lifetime Qt Champion
        wrote on last edited by
        #3

        hi
        I am not sure you can make 360 images with QGraphicsView in any sane manner.
        I think you will need some opengl to do it.
        http://www.student.nada.kth.se/~nv91-gta/OpenGL/panorama/

        1 Reply Last reply
        2
        • ck_eeC Offline
          ck_eeC Offline
          ck_ee
          wrote on last edited by ck_ee
          #4

          the 360° view is already projected on a 2d image, i just need to find a way to stitch the ends together while panning over the view.

          mrjjM 1 Reply Last reply
          0
          • ck_eeC ck_ee

            the 360° view is already projected on a 2d image, i just need to find a way to stitch the ends together while panning over the view.

            mrjjM Offline
            mrjjM Offline
            mrjj
            Lifetime Qt Champion
            wrote on last edited by
            #5

            @ck_ee
            ok.
            and the ends are already stitch friendly?

            ck_eeC 1 Reply Last reply
            0
            • mrjjM mrjj

              @ck_ee
              ok.
              and the ends are already stitch friendly?

              ck_eeC Offline
              ck_eeC Offline
              ck_ee
              wrote on last edited by
              #6

              @mrjj yes

              mrjjM 1 Reply Last reply
              0
              • ck_eeC ck_ee

                @mrjj yes

                mrjjM Offline
                mrjjM Offline
                mrjj
                Lifetime Qt Champion
                wrote on last edited by
                #7

                @ck_ee
                oK.
                I never made such view.
                What if u have a QGraphicsItem with a paint event
                that paints a subset of the full image.
                Lets just say 300,300. You then slide the drawn area when
                camera is moved. When it reaches the end of full image, you
                must then copy the slice from the start of the full image so it wraps
                over. And the reverse in the reverse direction.
                I dont know how image really look so might not be possible but if image is
                already sort of projected then it could work.

                1 Reply Last reply
                1
                • ck_eeC Offline
                  ck_eeC Offline
                  ck_ee
                  wrote on last edited by ck_ee
                  #8

                  my solution: i placed the same picture twice (next to eachother) in the QGraphicsScene. Then i derived from QGraphicsView and implemented the following functions:

                  void CustomGraphicsView::mouseMoveEvent(QMouseEvent *pEvent) {
                      if (lastPos_ != pEvent->pos() && isLeftMouseButtonDown_) {
                          adjustViewport();
                      }
                  
                      lastPos_ = pEvent->pos();
                      QGraphicsView::mouseMoveEvent(pEvent);
                  }
                  
                  void CustomGraphicsView::mousePressEvent(QMouseEvent *pEvent) {
                      if (pEvent->buttons() == Qt::LeftButton) {
                          isLeftMouseButtonDown_ = true;
                      }
                      QGraphicsView::mousePressEvent(pEvent);
                  }
                  
                  void CustomGraphicsView::mouseReleaseEvent(QMouseEvent *pEvent) {
                      if (pEvent->buttons() == Qt::LeftButton) {
                          isLeftMouseButtonDown_ = false;
                      }
                      QGraphicsView::mouseReleaseEvent(pEvent);
                  }
                  
                  void CustomGraphicsView::adjustViewport() {
                      // allows infinite horizontal panning
                      int w = imageSize_.width();
                      QRectF r = mapToScene(viewport()
                          ->geometry()).boundingRect();
                  
                      // panning to the right
                      if (r.x() + r.width() > w * 2) {
                          centerOn(QPointF(r.x() - w + r.width() / 2,
                              r.y() + r.height() / 2));
                      }
                  
                      // panning to the left
                      if (r.x() < 2) {
                          centerOn(QPointF(w + r.width() / 2 , r.y() + r.height() / 2));
                      }
                  }
                  

                  Every time the right mouse button is held and the mouse is moved the viewport is adjusted. if the view comes to close to the left or right side it uses QGraphicsView::centerOn to jump to the other picture. So the illusion of a infinitley pannable panorama picture is created.

                  mrjjM 1 Reply Last reply
                  3
                  • ck_eeC ck_ee

                    my solution: i placed the same picture twice (next to eachother) in the QGraphicsScene. Then i derived from QGraphicsView and implemented the following functions:

                    void CustomGraphicsView::mouseMoveEvent(QMouseEvent *pEvent) {
                        if (lastPos_ != pEvent->pos() && isLeftMouseButtonDown_) {
                            adjustViewport();
                        }
                    
                        lastPos_ = pEvent->pos();
                        QGraphicsView::mouseMoveEvent(pEvent);
                    }
                    
                    void CustomGraphicsView::mousePressEvent(QMouseEvent *pEvent) {
                        if (pEvent->buttons() == Qt::LeftButton) {
                            isLeftMouseButtonDown_ = true;
                        }
                        QGraphicsView::mousePressEvent(pEvent);
                    }
                    
                    void CustomGraphicsView::mouseReleaseEvent(QMouseEvent *pEvent) {
                        if (pEvent->buttons() == Qt::LeftButton) {
                            isLeftMouseButtonDown_ = false;
                        }
                        QGraphicsView::mouseReleaseEvent(pEvent);
                    }
                    
                    void CustomGraphicsView::adjustViewport() {
                        // allows infinite horizontal panning
                        int w = imageSize_.width();
                        QRectF r = mapToScene(viewport()
                            ->geometry()).boundingRect();
                    
                        // panning to the right
                        if (r.x() + r.width() > w * 2) {
                            centerOn(QPointF(r.x() - w + r.width() / 2,
                                r.y() + r.height() / 2));
                        }
                    
                        // panning to the left
                        if (r.x() < 2) {
                            centerOn(QPointF(w + r.width() / 2 , r.y() + r.height() / 2));
                        }
                    }
                    

                    Every time the right mouse button is held and the mouse is moved the viewport is adjusted. if the view comes to close to the left or right side it uses QGraphicsView::centerOn to jump to the other picture. So the illusion of a infinitley pannable panorama picture is created.

                    mrjjM Offline
                    mrjjM Offline
                    mrjj
                    Lifetime Qt Champion
                    wrote on last edited by
                    #9

                    @ck_ee
                    thank you. very interesting.

                    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