コード例 #1
0
ファイル: Tuning.cpp プロジェクト: cr8tr/omnidome
      void Tuning::setup()
      {
        this->setFocusPolicy(Qt::TabFocus);
        this->installEventFilter(this->parent());
        layout_ = new TuningLayout(this);
        setLayout(layout_);

        setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed);

        /// Setup title bar
        titleBar_.reset(new TitleBar("Projector", this));
        connect(titleBar_.get(), SIGNAL(
                  closeButtonClicked()),              this,
                SLOT(prepareRemove()));
        connect(titleBar_.get(), SIGNAL(colorChanged(
                                          QColor const &)), this,
                SLOT(updateParameters()));
        connect(titleBar_.get(), SIGNAL(
                  freeSetupSelected()),               this,
                SLOT(
                  resetToFreeSetup()));
        connect(titleBar_.get(), SIGNAL(
                  peripheralSetupSelected()),         this,
                SLOT(resetToPeripheralSetup()));
        layout_->addWidget(titleBar_.get(), TuningLayout::Role::TITLE);

        /// Setup preview window
        glView_.reset(new TuningGLView(this));
        QSizePolicy _sizePolicy(QSizePolicy::Ignored,
                                QSizePolicy::Expanding);
        glView_->setSizePolicy(_sizePolicy);
        glView_->setKeepAspectRatio(true);
        glView_->setBorder(0.0);
        glView_->setViewOnly(true);
        glView_->setUpdateFrequency(10.0); // 10.0 fps
        glView_->installEventFilter(this);

        connect(glView_.get(), SIGNAL(dataModelChanged()), this,
                SIGNAL(dataModelChanged()));

        layout_->addWidget(glView_.get(), TuningLayout::Role::PREVIEW);

        /// FOV view slider
        /// @todo Connect this with threshold slider
        auto *_fov =  addWidget("FOV", 60.0, 10.0, 160.0);
        _fov->setSingleStep(1.0);
        _fov->setPageStep(5.0);
        _fov->setSuffix("°");
        connect(_fov, SIGNAL(valueChanged()), this, SLOT(setFov()));

        auto *_keystone = addWidget("Keystone", 0.0, -1.0, 2.0);
        _keystone->setSingleStep(0.01);
        _keystone->setPageStep(0.1);
        connect(_keystone, SIGNAL(valueChanged()), this,
                SLOT(setKeyStone()));

        /// Throw ratio slider
        /// @todo Connect this with FOV slider
        auto *_throwRatio = addWidget("Throw Ratio", 1.0, 0.2, 5.0);
        _throwRatio->setSingleStep(0.01);
        _throwRatio->setPageStep(0.05);

        //    _throwRatio->setScale(RangedFloat::Scale::RECIPROCAL);
        connect(_throwRatio, SIGNAL(valueChanged()), this,
                SLOT(setThrowRatio()));

        /// Yaw angle slider (all projector setups)
        auto && _yaw = addAngleWidget("Yaw", 0.0, 0.0, 360.0);
        _yaw->setSingleStep(0.1);
        _yaw->setPageStep(1.0);

        /// Tower height slider (PeripheralSetup only)
        auto && _towerHeight = addOffsetWidget("Tower Height",
                                               0.2,
                                               -0.5,
                                               1.0);

        /// Distance slider (PeripheralSetup only)
        auto && _distance = addOffsetWidget("Distance", 0.4, 0.0, 1.0);

        /// Shift offset slider (PeripheralSetup only)
        auto && _shift = addOffsetWidget("Shift", 0.0, -0.2, 0.2);

        /// X offset slider (FreeSetup only)
        auto && _x = addOffsetWidget("X", 0.0, -1.0, 1.0);

        /// Y offset slider (FreeSetup only)
        auto && _y = addOffsetWidget("Y", 0.0, -1.0, 1.0);

        /// Z offset slider (FreeSetup only)
        auto && _z = addOffsetWidget("Z", 0.0, -1.0, 1.0);

        /// Pitch angle slider (both setups)
        auto && _pitch = addAngleWidget("Pitch", 30.0, -180.0, 180.0);
        _pitch->setSingleStep(0.1);
        _pitch->setPageStep(1.0);
        _pitch->setPivot(0.0);

        /// Roll angle slider (both setups)
        auto && _roll = addAngleWidget("Roll", 0.0, -180.0, 180.0);
        _roll->setSingleStep(0.1);
        _roll->setPageStep(1.0);
        _roll->setPivot(0.0);

        /// Delta yaw angle slider (PeripheralSetup only)
        auto && _deltaYaw = addAngleWidget("Delta Yaw", 0.0, -45.0, 45.0);
        _deltaYaw->setSingleStep(0.1);
        _deltaYaw->setPageStep(1.0);
        _deltaYaw->setPivot(0.0);

        widgetgroup_type _titleAndPreview(
        {
          { titleBar_.get(), TuningLayout::Role::TITLE },
          { glView_.get(), TuningLayout::Role::PREVIEW }
        });

        auto addParameters =
          [&](widgetgroup_type const& _group,
              std::vector<QWidget *>const& _widgets) -> widgetgroup_type
          {
            widgetgroup_type _result = _group;

            for (auto& _widget :
                 _widgets) _result.emplace_back(_widget,
                                                TuningLayout::Role::PARAMETER);


            return _result;
          };

        addGroup("Minimized",
                 { { titleBar_.get(),
                     TuningLayout::Role::TITLE } });

        /// Make slider groups
        addGroup("PreviewOnly", _titleAndPreview);
        addGroup("FOVSliders",
                 addParameters(_titleAndPreview,
                               { _fov, _throwRatio, _keystone }));
        addGroup("FreeSetup",
                 addParameters(_titleAndPreview,
                               { _yaw, _pitch, _roll, _x, _y, _z, _fov,
                                 _throwRatio, _keystone }));
        addGroup("PeripheralSetup",
                 addParameters(_titleAndPreview,
                               { _yaw, _pitch, _distance, _towerHeight,
                                 _shift, _deltaYaw, _roll, _fov,
                                 _throwRatio, _keystone }));

        /// Setup/update mode
        sessionModeChange();

        for (int i = 0; i < layout_->count(); ++i) {
          auto _widget = layout_->itemAt(i)->widget();

          if (!_widget) continue;
          _widget->installEventFilter(this);
          _widget->installEventFilter(this->parent());
        }
      }
コード例 #2
0
ファイル: Tuning.cpp プロジェクト: flair2005/omnidome
      void Tuning::setup()
      {
        layout_ = new TuningLayout(this);
        setLayout(layout_);

        setSizePolicy(QSizePolicy::Expanding,QSizePolicy::Fixed);

        /// Setup title bar
        titleBar_ = new TitleBar("Projector",this);
        titleBar_->installEventFilter(this);
        connect(titleBar_,SIGNAL(closeButtonClicked()),this,SLOT(prepareRemove()));
        layout_->addWidget(titleBar_,TuningLayout::Role::TITLE);

        /// Setup preview window
        glView_ = new TuningGLView(this);
        QSizePolicy _sizePolicy(QSizePolicy::Ignored,QSizePolicy::Expanding);
        glView_->setSizePolicy(_sizePolicy);
        glView_->setKeepAspectRatio(true);
        glView_->setBorder(0.0);
        glView_->setViewOnly(true);
        glView_->installEventFilter(this);
        layout_->addWidget(glView_,TuningLayout::Role::PREVIEW);

        fullscreen_.reset(new TuningGLView());
        fullscreen_->setViewOnly(true);
        fullscreen_->setShowCursor(true);
        fullscreen_->hide();

        /// FOV view slider
        /// @todo Connect this with threshold slider
        auto* _fov =  addWidget("FOV",60.0,10.0,160.0);
        _fov->setSingleStep(4.0);
        _fov->setPageStep(45.0);
        _fov->setSuffix("°");
        connect(_fov,SIGNAL(valueChanged()),this,SLOT(setFov()));

        /// Throw ratio slider
        /// @todo Connect this with FOV slider
        auto* _throwRatio = addWidget("Throw Ratio",1.0,0.1,5.0);
        _throwRatio->setSingleStep(0.1);
        _throwRatio->setPageStep(0.3);
        connect(_throwRatio,SIGNAL(valueChanged()),this,SLOT(setThrowRatio()));

        /// Yaw angle slider (all projector setups)
        auto&& _yaw = addAngleWidget("Yaw",0.0,0.0,360.0);

        /// Tower height slider (PeripheralSetup only)
        auto&& _towerHeight = addOffsetWidget("Tower Height",2.0,-5.0,10.0);
        _towerHeight->setSingleStep(0.1);
        _towerHeight->setPageStep(1.0);
        _towerHeight->setPivot(0.0);

        /// Distance slider (PeripheralSetup only)
        auto&& _distance = addOffsetWidget("Distance",5.0,0.0,10.0);
        _distance->setPageStep(1.0);

        /// Shift offset slider (PeripheralSetup only)
        auto&& _shift = addOffsetWidget("Shift",0.0,-2.0,2.0);
        _shift->setPageStep(1.0);
        _shift->setPivot(0.0);

        /// X offset slider (FreeSetup only)
        auto&& _x = addOffsetWidget("X",0.0,-10.0,10.0);
        _x->setPageStep(1.0);
        _x->setPivot(0.0);

        /// Y offset slider (FreeSetup only)
        auto&& _y = addOffsetWidget("Y",0.0,-10.0,10.0);
        _y->setPageStep(1.0);
        _y->setPivot(0.0);

        /// Z offset slider (FreeSetup only)
        auto&& _z = addOffsetWidget("Z",0.0,-10.0,10.0);
        _z->setPageStep(1.0);
        _z->setPivot(0.0);

        /// Pitch angle slider (both setups)
        auto&& _pitch = addAngleWidget("Pitch",30.0,-90.0,90.0);
        _pitch->setPivot(0.0);

        /// Roll angle slider (both setups)
        auto&& _roll = addAngleWidget("Roll",0.0,-45.0,45.0);
        _roll->setSingleStep(1.0);
        _roll->setPageStep(5.0);
        _roll->setPivot(0.0);

        /// Delta yaw angle slider (PeripheralSetup only)
        auto&& _deltaYaw = addAngleWidget("Delta Yaw",0.0,-45.0,45.0);
        _deltaYaw->setSingleStep(1.0);
        _deltaYaw->setPageStep(5.0);
        _deltaYaw->setPivot(0.0);

        widgetgroup_type _titleAndPreview(
        {
          { titleBar_, TuningLayout::Role::TITLE } ,
          { glView_, TuningLayout::Role::PREVIEW }
        });

        auto addParameters = [&](widgetgroup_type const& _group, std::vector<QWidget*> const& _widgets) -> widgetgroup_type
        {
          widgetgroup_type _result = _group;
          for (auto& _widget : _widgets)
            _result.emplace_back(_widget,TuningLayout::Role::PARAMETER);
          return _result;
        };

        addGroup("Minimized", { { titleBar_, TuningLayout::Role::TITLE } });

        /// Make slider groups
        addGroup("PreviewOnly",_titleAndPreview);
        addGroup("FOVSliders",addParameters(_titleAndPreview, { _fov, _throwRatio }));
        addGroup("FreeSetup",addParameters( _titleAndPreview, {_yaw, _pitch, _roll, _x, _y, _z }));
        addGroup("PeripheralSetup",
                 addParameters( _titleAndPreview,
        { _yaw, _pitch, _distance, _towerHeight, _shift, _deltaYaw, _roll }));

        /// Setup/update mode
        sessionModeChange();
      }