From: isn Date: Tue, 28 Nov 2017 11:58:15 +0000 (+0300) Subject: Merge remote-tracking branch 'origin/hydro/imps_2017_salome_83' into hydro/imps_2017 X-Git-Tag: v2.1.1__salome84 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=a4f96513cad26296270c4fd5cb947f1eb8c9722a;p=modules%2Fgui.git Merge remote-tracking branch 'origin/hydro/imps_2017_salome_83' into hydro/imps_2017 Conflicts: src/OCCViewer/OCCViewer_ViewWindow.cxx --- a4f96513cad26296270c4fd5cb947f1eb8c9722a diff --cc src/OCCViewer/OCCViewer_Utilities.cxx index 4705a35f1,8bb0bd4cd..8ee02c3b1 --- a/src/OCCViewer/OCCViewer_Utilities.cxx +++ b/src/OCCViewer/OCCViewer_Utilities.cxx @@@ -211,3 -232,36 +211,36 @@@ bool OCCViewer_Utilities::computeVisibl return true; } + + bool OCCViewer_Utilities::computeSceneBBCenter( const Handle(V3d_View) theView, + double& theX, double& theY, double& theZ ) + { + theX = 0, theY = 0, theZ = 0; + Bnd_Box aBox = theView->View()->MinMaxValues(); + if (!aBox.IsVoid()) + { + double Xmin, Ymin, Zmin, Xmax, Ymax, Zmax; + aBox.Get (Xmin, Ymin, Zmin, Xmax, Ymax, Zmax); + gp_Pnt aPnts[8] = + { + gp_Pnt (Xmin, Ymin, Zmin), gp_Pnt (Xmin, Ymin, Zmax), + gp_Pnt (Xmin, Ymax, Zmin), gp_Pnt (Xmin, Ymax, Zmax), + gp_Pnt (Xmax, Ymin, Zmin), gp_Pnt (Xmax, Ymin, Zmax), + gp_Pnt (Xmax, Ymax, Zmin), gp_Pnt (Xmax, Ymax, Zmax) + }; + + for (Standard_Integer i = 0; i < 8; i++) + { + const gp_Pnt& aCornPnt = aPnts[i]; + theX += aCornPnt.X(); + theY += aCornPnt.Y(); + theZ += aCornPnt.Z(); + } + + theX /= 8; + theY /= 8; + theZ /= 8; + return true; + } + return false; -} ++} diff --cc src/OCCViewer/OCCViewer_ViewWindow.cxx index a8c3c02e6,c30752036..26301651a --- a/src/OCCViewer/OCCViewer_ViewWindow.cxx +++ b/src/OCCViewer/OCCViewer_ViewWindow.cxx @@@ -80,8 -82,15 +80,9 @@@ #include #include #include -#if OCC_VERSION_LARGE > 0x06090000 #include #include + #include -#endif - -#if OCC_VERSION_MAJOR < 7 - #include -#endif #include #include @@@ -688,13 -725,20 +707,16 @@@ bool OCCViewer_ViewWindow::computeGravi if ( aStructure->IsEmpty() || !aStructure->IsVisible() || aStructure->CStructure()->IsForHighlight ) continue; - Bnd_Box aBox = aStructure->MinMaxValues(); - aXmin = aBox.IsVoid() ? RealFirst() : aBox.CornerMin().X(); - aYmin = aBox.IsVoid() ? RealFirst() : aBox.CornerMin().Y(); - aZmin = aBox.IsVoid() ? RealFirst() : aBox.CornerMin().Z(); - aXmax = aBox.IsVoid() ? RealLast() : aBox.CornerMax().X(); - aYmax = aBox.IsVoid() ? RealLast() : aBox.CornerMax().Y(); - aZmax = aBox.IsVoid() ? RealLast() : aBox.CornerMax().Z(); -#if OCC_VERSION_LARGE > 0x06070100 + Bnd_Box aBox1 = aStructure->MinMaxValues(); + const Graphic3d_BndBox3d& aBox = aStructure->CStructure()->BoundingBox(); + if (!aBox.IsValid()) + continue; + aXmin = /*aBox.IsVoid() ? RealFirst() :*/ aBox.CornerMin().x(); + aYmin = /*aBox.IsVoid() ? RealFirst() : */aBox.CornerMin().y(); + aZmin = /*aBox.IsVoid() ? RealFirst() : */aBox.CornerMin().z(); + aXmax = /*aBox.IsVoid() ? RealLast() : */aBox.CornerMax().x(); + aYmax = /*aBox.IsVoid() ? RealLast() : */aBox.CornerMax().y(); + aZmax = /*aBox.IsVoid() ? RealLast() : */aBox.CornerMax().z(); -#else - aStructure->MinMaxValues( aXmin, aYmin, aZmin, aXmax, aYmax, aZmax ); -#endif // Infinite structures are skipped Standard_Real aLIM = ShortRealLast() - 1.0; @@@ -1037,8 -1165,17 +1136,14 @@@ void OCCViewer_ViewWindow::vpMouseRelea case PANVIEW: case ZOOMVIEW: - resetState(); - break; -#if OCC_VERSION_LARGE <= 0x07000000 - myViewPort->getView()->ZFitAll(); -#endif + { + OCCViewer_ViewManager* aMgr = dynamic_cast( getViewManager() ); + bool isChained = aMgr->isChainedOperations(); + bool isReset = !( myOperation==PANVIEW && myPanningByBtn && isChained ) || theEvent->button() == Qt::RightButton; + if( isReset ) + resetState(); + break; + } case PANGLOBAL: if ( theEvent->button() == Qt::LeftButton ) { @@@ -3594,15 -3935,70 +3736,83 @@@ void OCCViewer_ViewWindow::onLightSourc } } +bool OCCViewer_ViewWindow::isActionVisible( ActionId theId ) const +{ + QAction* a = toolMgr()->action( theId ); + return a && a->isVisible(); +} + +void OCCViewer_ViewWindow::setActionVisible( ActionId theId, bool isVisible ) +{ + QAction* a = toolMgr()->action( theId ); + if( a ) + a->setVisible( isVisible ); +} ++ + void OCCViewer_ViewWindow::ProjAndPanToGravity(V3d_TypeOfOrientation CamOri) + { + const bool USE_XY = true; + + Handle(V3d_View) aView3d = myViewPort->getView(); + if (aView3d.IsNull()) + return; + + bool IsGr = false; + double X = 0, Y = 0, Z = 0; + if( USE_XY ) + { + const double EPS = 1E-6; + int xp = myViewPort->width()/2, yp = myViewPort->height()/2, xp1, yp1; + aView3d->Convert( xp, yp, X, Y, Z ); + + gp_Dir d = aView3d->Camera()->Direction(); + if( fabs( d.Z() ) > EPS ) + { + double t = -Z/d.Z(); + X += t*d.X(); + Y += t*d.Y(); + Z += t*d.Z(); + } + } + + // It is really necessary to compute gravity center even if it is not used in part of code below. + // Without this calculation the SetProj() method and other methods are not correct. + double X2, Y2, Z2; + IsGr = computeGravityCenter(X2, Y2, Z2); + if ( !IsGr ) + IsGr = OCCViewer_Utilities::computeSceneBBCenter(aView3d, X2, Y2, Z2); + + aView3d->SetProj(CamOri); + if (IsGr) + { + //aView3d->Update(); + Handle(Graphic3d_Camera) Cam = aView3d->Camera(); + gp_XYZ gp(X, Y, Z); + gp_Vec dir (Cam->Direction()); + gp_Pnt eye = Cam->Eye(); + gp_Vec V1(eye, gp); + Standard_Real D = dir.Dot(V1); + gp_Pnt ppdir = eye.Translated(D*dir); + gp_Vec V2(ppdir, gp); + gp_XYZ trEye = eye.XYZ() + V2.XYZ(); + + double xat, yat, zat; + aView3d->At(xat, yat, zat); + gp_Pnt At(xat, yat, zat); + gp_XYZ trAt = At.XYZ() + V2.XYZ(); + aView3d->SetEye(trEye.X(), trEye.Y(), trEye.Z()); + aView3d->SetAt(trAt.X(), trAt.Y(), trAt.Z()); + } + } + + + bool OCCViewer_ViewWindow::isAutomaticZoom() const + { + return myAutomaticZoom; + } + + void OCCViewer_ViewWindow::setAutomaticZoom(const bool isOn) + { + myAutomaticZoom = isOn; + } +