MCPcopy Create free account
hub / github.com/FreeCAD/FreeCAD / createView

Method createView

src/Gui/Document.cpp:2304–2379  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2302}
2303
2304MDIView* Document::createView(const Base::Type& typeId, CreateViewMode mode)
2305{
2306 if (!typeId.isDerivedFrom(MDIView::getClassTypeId())) {
2307 return nullptr;
2308 }
2309
2310 std::list<MDIView*> theViews = this->getMDIViewsOfType(typeId);
2311 if (typeId == View3DInventor::getClassTypeId()) {
2312
2313 QOpenGLWidget* shareWidget = nullptr;
2314 // VBO rendering doesn't work correctly when we don't share the OpenGL widgets
2315 if (!theViews.empty()) {
2316 auto firstView = static_cast<View3DInventor*>(theViews.front());
2317 shareWidget = qobject_cast<QOpenGLWidget*>(firstView->getViewer()->getGLWidget());
2318
2319 const std::string& camera = firstView->getCamera();
2320 saveCameraSettings(camera.c_str());
2321 }
2322
2323 auto view3D = new View3DInventor(this, getMainWindow(), shareWidget);
2324 if (!theViews.empty()) {
2325 auto firstView = static_cast<View3DInventor*>(theViews.front());
2326 std::string overrideMode = firstView->getViewer()->getOverrideMode();
2327 view3D->getViewer()->setOverrideMode(overrideMode);
2328 }
2329
2330 // attach the viewproviders. we need to make sure that we only attach the toplevel ones
2331 // and not viewproviders which are claimed by other providers. To ensure this we first
2332 // add all providers and then remove the ones already claimed
2333
2334 std::vector<App::DocumentObject*> child_vps;
2335 for (const auto& vp : d->_ViewProviderMap) {
2336 view3D->getViewer()->addViewProvider(vp.second);
2337 std::vector<App::DocumentObject*> children = vp.second->claimChildren3D();
2338 child_vps.insert(child_vps.end(), children.begin(), children.end());
2339 }
2340
2341 for (const auto& va : d->_ViewProviderMapAnnotation) {
2342 view3D->getViewer()->addViewProvider(va.second);
2343 std::vector<App::DocumentObject*> children = va.second->claimChildren3D();
2344 child_vps.insert(child_vps.end(), children.begin(), children.end());
2345 }
2346
2347 for (App::DocumentObject* obj : child_vps) {
2348 view3D->getViewer()->removeViewProvider(getViewProvider(obj));
2349 }
2350
2351 // When cloning the view, don't increment the window counter as the old view will be deleted
2352 // shortly after.
2353 if (mode != CreateViewMode::Clone) {
2354 const char* name = getDocument()->Label.getValue();
2355 QString title
2356 = QStringLiteral("%1 : %2[*]").arg(QString::fromUtf8(name)).arg(d->_iWinCount++);
2357
2358 view3D->setWindowTitle(title);
2359 }
2360
2361 view3D->setWindowModified(this->isModified());

Callers 5

activatedMethod · 0.45
slotNewDocumentMethod · 0.45
activateViewMethod · 0.45
cloneMethod · 0.45
prepare_viewMethod · 0.45

Calls 15

getMDIViewsOfTypeMethod · 0.95
isModifiedMethod · 0.95
getGLWidgetMethod · 0.80
getOverrideModeMethod · 0.80
getMainWindowFunction · 0.70
getViewProviderFunction · 0.70
getDocumentFunction · 0.70
isDerivedFromMethod · 0.45
emptyMethod · 0.45
frontMethod · 0.45
getViewerMethod · 0.45
getCameraMethod · 0.45

Tested by

no test coverage detected