Salome HOME
Merge remote-tracking branch 'origin/hydro/imps_2017_salome_83' into hydro/imps_2017 hydro/imps_2017 v2.1.1__salome84
authorisn <isn@opencascade.com>
Tue, 28 Nov 2017 11:58:15 +0000 (14:58 +0300)
committerisn <isn@opencascade.com>
Tue, 28 Nov 2017 11:58:15 +0000 (14:58 +0300)
Conflicts:
src/OCCViewer/OCCViewer_ViewWindow.cxx

1  2 
src/OCCViewer/OCCViewer_Utilities.cxx
src/OCCViewer/OCCViewer_ViewWindow.cxx
src/OCCViewer/OCCViewer_ViewWindow.h

index 4705a35f177c3f1afcc74234e9085598da8fe7eb,8bb0bd4cd439a87d4df44284213dd00f3e52e2a0..8ee02c3b1eb535028dd0b59b88fb829a23dacdbe
@@@ -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;
++}
index a8c3c02e6a2408532d31b644984706579eb5b947,c307520368c9ef663a76f40b6a1af678fe6e65c6..26301651a2a0ee76a9832f6eacfc5f17980d34c7
  #include <Graphic3d_MapOfStructure.hxx>
  #include <Graphic3d_Structure.hxx>
  #include <Graphic3d_ExportFormat.hxx>
 -#if OCC_VERSION_LARGE > 0x06090000
  #include <Graphic3d_StereoMode.hxx>
  #include <Graphic3d_RenderingParams.hxx>
 -#endif
 -
 -#if OCC_VERSION_MAJOR < 7
 -  #include <Visual3d_View.hxx>
 -#endif
+ #include <Graphic3d_BndBox3d.hxx>
  
  #include <V3d_Plane.hxx>
  #include <V3d_Light.hxx>
@@@ -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<OCCViewer_ViewManager*>( 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;
+ }
Simple merge