ViewPtr ViewCollectionWidgetMixed::addView(View::Type type, LayoutRegion region) { ViewPtr view; mTotalRegion = merge(region, mTotalRegion); if (type==View::VIEW_3D) { ViewWidget* overlay = this->mViewCacheOverlay->retrieveView(); overlay->getView()->setType(type); overlay->show(); mOverlays.push_back(overlay); view = overlay->getView(); this->addWidgetToLayout(mLayout, overlay, region); } else { mBaseRegion = merge(region, mBaseRegion); view = mBaseLayout->addView(type, region); // re-add the base widget with updated position in grid this->addWidgetToLayout(mLayout, mBaseLayout, mBaseRegion); } view_utils::setStretchFactors(mLayout, mTotalRegion, 1); return view; }
ViewPtr LayoutWidgetUsingViewWidgets::addView(View::Type type, LayoutRegion region) { ViewWidget* view = this->retrieveView(type); view->getView()->setType(type); mLayout->addWidget(view, region.pos.row, region.pos.col, region.span.row, region.span.col); view_utils::setStretchFactors(mLayout, region, 1); view->show(); mViews.push_back(view); return view->getView(); }
void QViewWidget::setSelectedCamera(int index) { if (!viewMap.contains(sceneSelection.currentText()) || (index > ISOMETRIC && index < PERSPECTIVE)) return; ViewWidget * viewWidget = viewMap.value(sceneSelection.currentText()); osg::Vec3d cameraVector = viewWidget->getView()->getCameraManipulator()->getMatrix().getTrans(); double distance = pow((pow(cameraVector.x(),2) + pow(cameraVector.y(),2) + pow(cameraVector.z(),2)), 0.5); osg::Vec3d *eye = 0, center(0,0,0), up(0,0,1); switch (index) { case PERSPECTIVE: case ISOMETRIC: eye = new osg::Vec3d(0,distance,distance); break; case LEFT: eye = new osg::Vec3d(-distance,0,0); break; case RIGHT: eye = new osg::Vec3d(distance,0,0); break; case FRONT: eye = new osg::Vec3d(0,distance,0); break; case BACK: eye = new osg::Vec3d(0,-distance,0); break; case TOP: eye = new osg::Vec3d(0,0,distance); break; case BOTTOM: eye = new osg::Vec3d(0,0,-distance); break; } // if the change concerned the eye position, apply it if (eye) { viewWidget->getView()->getCameraManipulator()->setHomePosition(*eye,center,up); viewWidget->getView()->home(); delete eye; } }
ViewWidget* LayoutWidgetUsingViewWidgets::WidgetFromView(ViewPtr view) { for (unsigned i=0; i<mViews.size(); ++i) { ViewWidget* current = mViews[i]; if (current->getView()==view) return current; } return NULL; }
void QViewWidget::setSelectedScene(int index) { ViewWidget * viewWidget = viewMap.value(sceneSelection.itemText(index)); sceneStack->setCurrentWidget(viewWidget->getWidget()); viewWidget->getView()->requestRedraw(); }