Salome HOME
Merge branch 'master' of newgeom:newgeom.git
[modules/shaper.git] / src / XGUI / XGUI_ViewPort.cpp
index 997845808a55297a2f33bded293459caead843da..4398cabaa5d6c97c5f69ca0aacced541c6e19678 100644 (file)
@@ -14,7 +14,6 @@
 #include "XGUI_Viewer.h"
 #include "XGUI_Constants.h"
 
-#include <QGuiApplication>
 #include <QPaintEvent>
 #include <QPainter>
 #include <QFileInfo>
@@ -272,8 +271,6 @@ XGUI_ViewPort::XGUI_ViewPort(XGUI_ViewWindow* theParent, const Handle(V3d_Viewer
     myActiveView = myPerspView;
   }
   myActiveView->SetSurfaceDetail(V3d_TEX_ALL);
-
-  //setBackground( Qtx::BackgroundData( Qt::black ) ); // set default background
 }
 
 //***********************************************
@@ -727,3 +724,55 @@ void XGUI_ViewPort::setBackground(const XGUI_ViewBackground& bgData)
     emit vpChangeBackground(myBackground);
   }
 }
+
+void XGUI_ViewPort::fitAll(bool theKeepScale, bool theWithZ, bool theUpd)
+{
+  if ( activeView().IsNull() )
+    return;
+
+  if ( theKeepScale )
+    myScale = activeView()->Scale();
+
+  Standard_Real aMargin = 0.01;
+  activeView()->FitAll( aMargin, theWithZ, theUpd );
+  activeView()->SetZSize(0.);
+  emit vpTransformed( );
+}
+
+void XGUI_ViewPort::syncronizeWith( const XGUI_ViewPort* ref )
+{
+  Handle(V3d_View) refView = ref->getView();
+  Handle(V3d_View) tgtView = getView();
+
+  /*  The following params are copied:
+      - view type( ortho/persp )
+      - position of view point
+      - orientation of high point
+      - position of the eye
+      - projection vector
+      - view center ( 2D )
+      - view twist
+      - view scale
+  */
+
+  /* we'll update after setting all params */
+  tgtView->SetImmediateUpdate( Standard_False );
+
+  /* perspective */
+  if ( refView->Type() == V3d_PERSPECTIVE )
+    tgtView->SetFocale( refView->Focale() );
+
+  /* copy params */
+  Standard_Real x, y, z;
+  refView->At( x, y, z ); tgtView->SetAt( x, y, z );
+  refView->Up( x, y, z ); tgtView->SetUp( x, y, z );
+  refView->Eye( x, y, z ); tgtView->SetEye( x, y, z );
+  refView->Proj( x, y, z ); tgtView->SetProj( x, y, z );
+  refView->Center( x, y ); tgtView->SetCenter( x, y );
+  tgtView->SetScale( refView->Scale() );
+  tgtView->SetTwist( refView->Twist() );
+
+  /* update */
+  tgtView->Update();
+  tgtView->SetImmediateUpdate( Standard_True );
+}