0024623: Visualization - improve selection mechanism
[occt.git] / src / IVtkVTK / IVtkVTK_View.cxx
index e7db1cf..39cff7c 100644 (file)
@@ -18,6 +18,7 @@
 #include <vtkAutoInit.h>
 #include <vtkCamera.h>
 #include <vtkRenderer.h>
+#include <vtkRenderWindow.h>
 #include <vtkTransform.h>
 
 // Initialization of VTK object factories.
@@ -159,3 +160,56 @@ bool IVtkVTK_View::DisplayToWorld (const gp_XY& theDisplayPnt, gp_XYZ& theWorldP
 
   return true;
 }
+
+//================================================================
+// Function : GetWindowSize
+// Purpose  :
+//================================================================
+void IVtkVTK_View::GetWindowSize (int& theX, int& theY) const
+{
+  int* aSize = myRenderer->GetRenderWindow()->GetSize();
+  theX = aSize[0];
+  theY = aSize[1];
+}
+
+//================================================================
+// Function : GetCamera
+// Purpose  :
+//================================================================
+void IVtkVTK_View::GetCamera (Graphic3d_Mat4d& theProj,
+                              Graphic3d_Mat4d& theOrient,
+                              Standard_Boolean& theIsOrtho) const
+{
+  theIsOrtho = !IsPerspective();
+
+  vtkMatrix4x4* aCompositeProj =
+    myRenderer->GetActiveCamera()->GetCompositeProjectionTransformMatrix (myRenderer->GetTiledAspectRatio(),
+                                                                          0,
+                                                                          1);
+  for (Standard_Integer aRow = 0; aRow < 4; ++aRow)
+  {
+    for (Standard_Integer aCol = 0; aCol < 4; ++aCol)
+    {
+      theProj.SetValue (aRow, aCol, aCompositeProj->GetElement (aRow, aCol));
+    }
+  }
+
+  theOrient.InitIdentity();
+}
+
+//================================================================
+// Function : GetViewport
+// Purpose  :
+//================================================================
+void IVtkVTK_View::GetViewport (Standard_Real& theX,
+                                Standard_Real& theY,
+                                Standard_Real& theWidth,
+                                Standard_Real& theHeight) const
+{
+  Standard_Real aViewport[4];
+  myRenderer->GetViewport (aViewport);
+  theX = aViewport[0];
+  theY = aViewport[1];
+  theWidth  = aViewport[2];
+  theHeight = aViewport[3];
+}