MCPcopy Create free account
hub / github.com/IfcOpenShell/IfcOpenShell / orientScene

Method orientScene

src/qtviewer/IfcViewerWidget.cpp:165–202  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

163}
164
165void IfcViewerWidget::orientScene(osg::ref_ptr<osg::Group> rootGroup)
166{
167 // Get the bounding-box
168 osg::ComputeBoundsVisitor cbv;
169 rootGroup->accept(cbv);
170 const osg::BoundingBox& bb = cbv.getBoundingBox();
171
172 // Center (average of opposite corners of bb)
173 osg::Vec3d center = (bb.corner(0) + bb.corner(7)) * 0.5;
174
175 // Radius (distance between the center and the corner)
176 // assuming corner(7) has maximum x,y,z coords
177 float radius = (bb.corner(7) - center).length();
178
179 // Calc. eye position
180 osg::Vec3d eye = center + osg::Vec3d(radius * 3, -radius * 3, 0.0);
181
182 osg::Vec3d up = osg::Vec3d(0.0, 0.0, 1.0);
183
184 // Set the camera's view matrix
185 // In case a cameraManipulator is set, lookAt position setting does not work on the camera
186 // as it is overridden.
187 // So set it on the manipulator and reapply it to the viewer
188 if (m_mouseHandler.valid())
189 {
190 m_mouseHandler->setHomePosition(eye, center, up);
191 }
192
193 m_viewer->setCameraManipulator(m_mouseHandler);
194
195 auto log = [center, radius, eye]() {
196 MessageLogger::log("center: " + std::to_string(center.length()));
197 MessageLogger::log("radius: " + std::to_string(radius));
198 MessageLogger::log("center: " + std::to_string(center.x()) + ", " + std::to_string(center.y()) + ", " + std::to_string(center.z()));
199 MessageLogger::log("eye: " + std::to_string(eye.x()) + ", " + std::to_string(eye.y()) + ", " + std::to_string(eye.z()));
200 };
201 //log();
202}

Callers

nothing calls this directly

Calls 2

to_stringFunction · 0.85
lengthMethod · 0.45

Tested by

no test coverage detected