本文整理汇总了C++中gui::View3DInventorViewer类的典型用法代码示例。如果您正苦于以下问题:C++ View3DInventorViewer类的具体用法?C++ View3DInventorViewer怎么用?C++ View3DInventorViewer使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了View3DInventorViewer类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: getRelevantBoundBox
SbBox3f ViewProviderDatum::getRelevantBoundBox () const {
std::vector<App::DocumentObject *> objs;
// Probe body first
PartDesign::Body* body = PartDesign::Body::findBodyOf ( this->getObject() );
if (body) {
objs = body->getFullModel ();
} else {
// Probe if we belongs to some group
App::DocumentObjectGroup* group = App::DocumentObjectGroup::getGroupOfObject ( this->getObject () );
if(group) {
objs = group->getObjects ();
} else {
// Fallback to whole document
objs = this->getObject ()->getDocument ()->getObjects ();
}
}
Gui::View3DInventorViewer* viewer = static_cast<Gui::View3DInventor*>(this->getActiveView())->getViewer();
SoGetBoundingBoxAction bboxAction(viewer->getSoRenderManager()->getViewportRegion());
SbBox3f bbox = getRelevantBoundBox (bboxAction, objs);
if ( bbox.getVolume () < Precision::Confusion() ) {
bbox.extendBy ( defaultBoundBox () );
}
return bbox;
}
开发者ID:sanguinariojoe,项目名称:FreeCAD,代码行数:29,代码来源:ViewProviderDatum.cpp
示例2: on_fileChooser_fileNameSelected
void TextureMapping::on_fileChooser_fileNameSelected(const QString& s)
{
QImage image;
if (!image.load(s)) {
QMessageBox::warning(this, tr("No image"), tr("The specified file is not a valid image file."));
return;
}
if (!this->grp) {
Gui::Document* doc = Gui::Application::Instance->activeDocument();
if (doc) {
Gui::MDIView* mdi = doc->getActiveView();
if (mdi && mdi->isDerivedFrom(View3DInventor::getClassTypeId())) {
Gui::View3DInventorViewer* view = static_cast<View3DInventor*>(mdi)->getViewer();
this->grp = static_cast<SoGroup *>(view->getSceneGraph());
this->grp->ref();
this->grp->insertChild(this->tex,1);
if (ui->checkEnv->isChecked())
this->grp->insertChild(this->env,2);
}
}
}
if (!this->grp) {
QMessageBox::warning(this, tr("No 3d view"), tr("No active 3d view found."));
return;
}
SoSFImage texture;
Gui::BitmapFactory().convert(image, texture);
this->tex->image = texture;
//this->tex->filename = (const char*)s.toUtf8();
App::GetApplication().Config()["TextureImage"] = (const char*)s.toUtf8();
}
开发者ID:3DPrinterGuy,项目名称:FreeCAD,代码行数:34,代码来源:TextureMapping.cpp
示例3: DefineNodesCallback
void TaskCreateNodeSet::DefineNodesCallback(void * ud, SoEventCallback * n)
{
// show the wait cursor because this could take quite some time
Gui::WaitCursor wc;
TaskCreateNodeSet *taskBox = static_cast<TaskCreateNodeSet *>(ud);
// When this callback function is invoked we must in either case leave the edit mode
Gui::View3DInventorViewer* view = reinterpret_cast<Gui::View3DInventorViewer*>(n->getUserData());
view->setEditing(false);
view->removeEventCallback(SoMouseButtonEvent::getClassTypeId(), DefineNodesCallback,ud);
n->setHandled();
SbBool clip_inner;
std::vector<SbVec2f> clPoly = view->getGLPolygon(&clip_inner);
if (clPoly.size() < 3)
return;
if (clPoly.front() != clPoly.back())
clPoly.push_back(clPoly.front());
SoCamera* cam = view->getSoRenderManager()->getCamera();
SbViewVolume vv = cam->getViewVolume();
Gui::ViewVolumeProjection proj(vv);
Base::Polygon2D polygon;
for (std::vector<SbVec2f>::const_iterator it = clPoly.begin(); it != clPoly.end(); ++it)
polygon.Add(Base::Vector2D((*it)[0],(*it)[1]));
taskBox->DefineNodes(polygon,proj,clip_inner);
}
开发者ID:DeepSOIC,项目名称:FreeCAD-ellipse,代码行数:31,代码来源:TaskCreateNodeSet.cpp
示例4: make_pair
//should return a configuration? frontdir,upDir mapped in DPG
std::pair<Base::Vector3d,Base::Vector3d> TaskProjGroup::get3DViewDir()
{
std::pair<Base::Vector3d,Base::Vector3d> result;
Base::Vector3d viewDir(0.0,-1.0,0.0); //default to front
Base::Vector3d viewUp(0.0,0.0,1.0); //default to top
std::list<MDIView*> mdis = Gui::Application::Instance->activeDocument()->getMDIViews();
Gui::View3DInventor *view;
Gui::View3DInventorViewer *viewer = nullptr;
for (auto& m: mdis) { //find the 3D viewer
view = dynamic_cast<Gui::View3DInventor*>(m);
if (view) {
viewer = view->getViewer();
break;
}
}
if (!viewer) {
Base::Console().Log("LOG - TaskProjGroup could not find a 3D viewer\n");
return std::make_pair( viewDir, viewUp);
}
SbVec3f dvec = viewer->getViewDirection();
SbVec3f upvec = viewer->getUpDirection();
viewDir = Base::Vector3d(dvec[0], dvec[1], dvec[2]);
viewUp = Base::Vector3d(upvec[0],upvec[1],upvec[2]);
viewDir *= -1.0; //Inventor dir is opposite TD dir, Inventor up is same as TD up
viewDir = DrawUtil::closestBasis(viewDir);
viewUp = DrawUtil::closestBasis(viewUp);
result = std::make_pair(viewDir,viewUp);
return result;
}
开发者ID:itain,项目名称:FreeCAD,代码行数:32,代码来源:TaskProjGroup.cpp
示例5: rotateView
void NaviCubeImplementation::rotateView(int axis,float rotAngle) {
SbRotation viewRot = m_View3DInventorViewer->getCameraOrientation();
SbVec3f up;
viewRot.multVec(SbVec3f(0,1,0),up);
SbVec3f out;
viewRot.multVec(SbVec3f(0,0,1),out);
SbVec3f& u = up;
SbVec3f& o = out;
SbVec3f right (u[1]*o[2]-u[2]*o[1], u[2]*o[0]-u[0]*o[2], u[0]*o[1]-u[1]*o[0]);
SbVec3f direction;
switch (axis) {
default :
return;
case DIR_UP :
direction = up;
break;
case DIR_OUT :
direction = out;
break;
case DIR_RIGHT :
direction = right;
break;
}
SbRotation rot(direction, -rotAngle*M_PI/180.0);
SbRotation newViewRot = viewRot * rot;
m_View3DInventorViewer->setCameraOrientation(newViewRot);
}
开发者ID:lanigb,项目名称:FreeCAD,代码行数:33,代码来源:NaviCube.cpp
示例6: measureDistanceCallback
void ViewProviderMeasureDistance::measureDistanceCallback(void * ud, SoEventCallback * n)
{
const SoMouseButtonEvent * mbe = static_cast<const SoMouseButtonEvent*>(n->getEvent());
Gui::View3DInventorViewer* view = reinterpret_cast<Gui::View3DInventorViewer*>(n->getUserData());
PointMarker *pm = reinterpret_cast<PointMarker*>(ud);
// Mark all incoming mouse button events as handled, especially, to deactivate the selection node
n->getAction()->setHandled();
if (mbe->getButton() == SoMouseButtonEvent::BUTTON2 && mbe->getState() == SoButtonEvent::UP) {
n->setHandled();
view->setEditing(false);
view->removeEventCallback(SoMouseButtonEvent::getClassTypeId(), measureDistanceCallback, ud);
pm->deleteLater();
}
else if (mbe->getButton() == SoMouseButtonEvent::BUTTON1 && mbe->getState() == SoButtonEvent::DOWN) {
const SoPickedPoint * point = n->getPickedPoint();
if (point == NULL) {
Base::Console().Message("No point picked.\n");
return;
}
n->setHandled();
pm->addPoint(point->getPoint());
if (pm->countPoints() == 2) {
QEvent *e = new QEvent(QEvent::User);
QApplication::postEvent(pm, e);
// leave mode
view->setEditing(false);
view->removeEventCallback(SoMouseButtonEvent::getClassTypeId(), measureDistanceCallback, ud);
pm->deleteLater();
}
}
}
开发者ID:Barleyman,项目名称:FreeCAD_sf_master,代码行数:33,代码来源:ViewProviderMeasureDistance.cpp
示例7: stopSelection
void MeshSelection::stopSelection()
{
Gui::View3DInventorViewer* viewer = getViewer();
if (viewer) {
stopInteractiveCallback(viewer);
viewer->navigationStyle()->stopSelection();
}
}
开发者ID:5263,项目名称:FreeCAD,代码行数:8,代码来源:MeshSelection.cpp
示例8: activated
void CmdTestWidgetShape::activated(int iMsg)
{
SandboxGui::SoWidgetShape* shape = new SandboxGui::SoWidgetShape;
shape->setWidget(new QCalendarWidget());
Gui::MDIView* view = Gui::getMainWindow()->activeWindow();
Gui::View3DInventorViewer* viewer = static_cast<Gui::View3DInventor*>(view)->getViewer();
static_cast<SoGroup*>(viewer->getSceneGraph())->addChild(shape);
}
开发者ID:Didier94,项目名称:FreeCAD_sf_master,代码行数:8,代码来源:Command.cpp
示例9: unsetCursor
void DrawSketchHandler::unsetCursor(void)
{
Gui::MDIView* view = Gui::getMainWindow()->activeWindow();
if (view && view->isDerivedFrom(Gui::View3DInventor::getClassTypeId())) {
Gui::View3DInventorViewer* viewer = static_cast<Gui::View3DInventor*>(view)->getViewer();
viewer->getWidget()->setCursor(oldCursor);
}
}
开发者ID:davidlni,项目名称:FreeCAD,代码行数:8,代码来源:DrawSketchHandler.cpp
示例10: Poly
void TaskCreateNodeSet::Poly(void)
{
Gui::Document* doc = Gui::Application::Instance->activeDocument();
Gui::MDIView* view = doc->getActiveView();
if (view->getTypeId().isDerivedFrom(Gui::View3DInventor::getClassTypeId())) {
Gui::View3DInventorViewer* viewer = ((Gui::View3DInventor*)view)->getViewer();
viewer->setEditing(true);
viewer->startSelection(Gui::View3DInventorViewer::Clip);
viewer->addEventCallback(SoMouseButtonEvent::getClassTypeId(), DefineNodesCallback,this);
}
}
开发者ID:DeepSOIC,项目名称:FreeCAD-ellipse,代码行数:11,代码来源:TaskCreateNodeSet.cpp
示例11: deselectTriangle
void MeshSelection::deselectTriangle()
{
this->addToSelection = false;
Gui::View3DInventorViewer* viewer = this->getViewer();
if (viewer) {
viewer->setEditingCursor(QCursor(Qt::OpenHandCursor));
stopInteractiveCallback(viewer);
startInteractiveCallback(viewer, pickFaceCallback);
}
}
开发者ID:gale320,项目名称:FreeCAD_sf_master,代码行数:11,代码来源:MeshSelection.cpp
示例12: selectTriangle
void MeshSelection::selectTriangle()
{
this->addToSelection = true;
Gui::View3DInventorViewer* viewer = this->getViewer();
if (viewer) {
stopInteractiveCallback(viewer);
viewer->navigationStyle()->stopSelection();
startInteractiveCallback(viewer, pickFaceCallback);
viewer->setEditingCursor(QCursor(Qt::PointingHandCursor));
}
}
开发者ID:5263,项目名称:FreeCAD,代码行数:12,代码来源:MeshSelection.cpp
示例13: finishEditing
void MeshFillHole::finishEditing()
{
Gui::View3DInventor* view = static_cast<Gui::View3DInventor*>(parent());
Gui::View3DInventorViewer* viewer = view->getViewer();
viewer->setEditing(false);
//viewer->setRedirectToSceneGraph(false);
viewer->removeEventCallback(SoEvent::getClassTypeId(),
MeshFillHole::fileHoleCallback, this);
myConnection.disconnect();
this->deleteLater();
static_cast<SoGroup*>(viewer->getSceneGraph())->removeChild(myBridgeRoot);
}
开发者ID:Barleyman,项目名称:FreeCAD_sf_master,代码行数:12,代码来源:MeshEditor.cpp
示例14: activated
void CmdInspectElement::activated(int iMsg)
{
Gui::Document* doc = Gui::Application::Instance->activeDocument();
Gui::View3DInventor* view = static_cast<Gui::View3DInventor*>(doc->getActiveView());
if (view) {
Gui::View3DInventorViewer* viewer = view->getViewer();
viewer->setEditing(true);
viewer->setRedirectToSceneGraph(true);
viewer->setEditingCursor(QCursor(Gui::BitmapFactory().pixmap("mesh_pipette"),4,29));
viewer->addEventCallback(SoButtonEvent::getClassTypeId(),
InspectionGui::ViewProviderInspection::inspectCallback);
}
}
开发者ID:lainegates,项目名称:FreeCAD,代码行数:13,代码来源:Command.cpp
示例15: setCursor
void DrawSketchHandler::setCursor(const QPixmap &p,int x,int y)
{
Gui::MDIView* view = Gui::getMainWindow()->activeWindow();
if (view && view->isDerivedFrom(Gui::View3DInventor::getClassTypeId())) {
Gui::View3DInventorViewer* viewer = static_cast<Gui::View3DInventor*>(view)->getViewer();
oldCursor = viewer->getWidget()->cursor();
QCursor cursor(p, x, y);
actCursor = cursor;
viewer->getWidget()->setCursor(cursor);
}
}
开发者ID:davidlni,项目名称:FreeCAD,代码行数:13,代码来源:DrawSketchHandler.cpp
示例16: getScaleFactor
float SoZoomTranslation::getScaleFactor()
{
// Dividing by 5 seems to work well
Gui::MDIView *mdi = Gui::Application::Instance->activeDocument()->getActiveView();
if (mdi && mdi->isDerivedFrom(Gui::View3DInventor::getClassTypeId())) {
Gui::View3DInventorViewer *viewer = static_cast<Gui::View3DInventor *>(mdi)->getViewer();
this->scale = viewer->getCamera()->getViewVolume(viewer->getCamera()->aspectRatio.getValue()).getWorldToScreenScale(SbVec3f(0.f, 0.f, 0.f), 0.1f) / 5;
return this->scale;
} else {
return this->scale;
}
}
开发者ID:Barleyman,项目名称:FreeCAD_sf_master,代码行数:13,代码来源:SoZoomTranslation.cpp
示例17: isActive
bool CmdInspectElement::isActive(void)
{
App::Document* doc = App::GetApplication().getActiveDocument();
if (!doc || doc->countObjectsOfType(Inspection::Feature::getClassTypeId()) == 0)
return false;
Gui::MDIView* view = Gui::getMainWindow()->activeWindow();
if (view && view->isDerivedFrom(Gui::View3DInventor::getClassTypeId())) {
Gui::View3DInventorViewer* viewer = static_cast<Gui::View3DInventor*>(view)->getViewer();
return !viewer->isEditing();
}
return false;
}
开发者ID:Didier94,项目名称:FreeCAD_sf_master,代码行数:14,代码来源:Command.cpp
示例18: startEditing
void MeshFaceAddition::startEditing(MeshGui::ViewProviderMesh* vp)
{
Gui::View3DInventor* view = static_cast<Gui::View3DInventor*>(parent());
Gui::View3DInventorViewer* viewer = view->getViewer();
viewer->setEditing(true);
viewer->setRedirectToSceneGraph(true);
faceView->mesh = vp;
faceView->attach(vp->getObject());
viewer->addViewProvider(faceView);
//faceView->mesh->startEditing();
viewer->addEventCallback(SoEvent::getClassTypeId(),
MeshFaceAddition::addFacetCallback, this);
}
开发者ID:Barleyman,项目名称:FreeCAD_sf_master,代码行数:14,代码来源:MeshEditor.cpp
示例19: isActive
bool CmdFemDefineNodesSet::isActive(void)
{
// Check for the selected mesh feature (all Mesh types)
if (getSelection().countObjectsOfType(Fem::FemMeshObject::getClassTypeId()) != 1)
return false;
Gui::MDIView* view = Gui::getMainWindow()->activeWindow();
if (view && view->isDerivedFrom(Gui::View3DInventor::getClassTypeId())) {
Gui::View3DInventorViewer* viewer = static_cast<Gui::View3DInventor*>(view)->getViewer();
return !viewer->isEditing();
}
return false;
}
开发者ID:Barleyman,项目名称:FreeCAD_sf_master,代码行数:14,代码来源:Command.cpp
示例20: handleEvent
bool ViewProviderMeshNode::handleEvent(const SoEvent * const ev,Gui::View3DInventorViewer &Viewer)
{
if ( m_bEdit )
{
unsetEdit();
std::vector<SbVec2f> clPoly = Viewer.getPickedPolygon();
if ( clPoly.size() < 3 )
return true;
if ( clPoly.front() != clPoly.back() )
clPoly.push_back(clPoly.front());
// get the normal of the front clipping plane
SbVec3f b,n;
Viewer.getNearPlane(b, n);
Base::Vector3f cPoint(b[0],b[1],b[2]), cNormal(n[0],n[1],n[2]);
SoCamera* pCam = Viewer.getCamera();
SbViewVolume vol = pCam->getViewVolume ();
// create a tool shape from these points
std::vector<MeshCore::MeshGeomFacet> aFaces;
bool ok = ViewProviderMesh::createToolMesh( clPoly, vol, cNormal, aFaces );
// Get the attached mesh property
Mesh::PropertyMeshKernel& meshProp = ((Mesh::Feature*)pcObject)->Mesh;
// Get the facet indices inside the tool mesh
std::vector<unsigned long> indices;
MeshCore::MeshKernel cToolMesh;
cToolMesh = aFaces;
MeshCore::MeshFacetGrid cGrid(meshProp.getValue().getKernel());
MeshCore::MeshAlgorithm cAlg(meshProp.getValue().getKernel());
cAlg.GetFacetsFromToolMesh(cToolMesh, cNormal, cGrid, indices);
meshProp.deleteFacetIndices( indices );
// update open edge display if needed
// if ( pcOpenEdge )
// {
// showOpenEdges(false);
// showOpenEdges(true);
// }
Viewer.render();
if ( !ok ) // note: the mouse grabbing needs to be released
//QMessageBox::warning(Viewer.getWidget(),"Invalid polygon","The picked polygon seems to have self-overlappings.\n\nThis could lead to strange rersults.");
Base::Console().Message("The picked polygon seems to have self-overlappings. This could lead to strange results.");
}
return false;
}
开发者ID:3DPrinterGuy,项目名称:FreeCAD,代码行数:49,代码来源:ViewProviderMeshNode.cpp
注:本文中的gui::View3DInventorViewer类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论