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;
++}
#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>
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;
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 ) {
}
}
+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;
+ }
+