Deleted TODOs which were used when branch was built without OpenCL.
Modified test case bugs/vis/bug23747_2 (changed textured shape)
SEPARATOR
BUTTON ID_FILE_EXPORT_IMAGE
SEPARATOR
+ BUTTON ID_BUTTON_STEREO
+ SEPARATOR
BUTTON ID_APP_ABOUT
END
ID_FILE_MRU_FILE1 "Open recent file\nRecent file"
END
+STRINGTABLE
+BEGIN
+ ID_BUTTON_STEREO "Toggle stereographic mode on / off"
+END
+
#endif // English (U.S.) resources
/////////////////////////////////////////////////////////////////////////////
aViewer = GetDocument()->GetViewer();
aViewer->SetDefaultTypeOfView (V3d_PERSPECTIVE);
+
myView = aViewer->CreateView();
// store for restore state after rotation (witch is in Degenerated mode)
/* I suspect another problem elsewhere */
::PostMessage ( GetSafeHwnd () , WM_SIZE , SIZE_RESTORED , w + h*65536 ) ;
- myPView = Handle(V3d_PerspectiveView)::DownCast (myView);
-
m_Tune.Create ( IDD_TUNE , NULL ) ;
RECT dlgrect;
myView->SetTwist (a) ;
}
-void CAnimationView3D::SetFocal(double dFocus,double dAngle)
+//=============================================================================
+// function: SetFocal
+// purpose:
+//=============================================================================
+void CAnimationView3D::SetFocal (double theFocus, double theAngle)
{
- double v [3] ;
- double l ;
- int i ;
- v [0] = m_Atx - m_Eyex ;
- v [1] = m_Aty - m_Eyey ;
- v [2] = m_Atz - m_Eyez ;
+ Handle(Graphic3d_Camera) aCamera = myView->Camera();
- l = sqrt ( v[0]*v[0] + v[1]*v[1] + v[2]*v[2] ) ;
- if ( l > 1.e-3 ) {
- for ( i=0 ; i<3 ; i++ )
- v [i] = v [i] / l * dFocus ;
+ gp_Pnt anAt = aCamera->Center();
+ gp_Pnt anEye = aCamera->Eye();
- m_Focus = dFocus ;
+ gp_Vec aLook (anAt, anEye);
- m_Atx = v [0] + m_Eyex ;
- m_Aty = v [1] + m_Eyey ;
- m_Atz = v [2] + m_Eyez ;
+ if (aCamera->Distance() > 1.e-3)
+ {
+ aLook = aLook / aCamera->Distance() * theFocus;
- myView->SetImmediateUpdate ( Standard_False ) ;
- myView->SetAt ( m_Atx , m_Aty , m_Atz ) ;
- m_dAngle = dAngle ;
- dAngle = dAngle * M_PI / 180. ;
- myPView->SetAngle ( dAngle ) ;
- dAngle = myPView->Angle () ;
+ m_Focus = theFocus;
- myView->SetImmediateUpdate ( Standard_True ) ;
- myView->Update ();
- }
+ anAt.SetX (aLook.X() + anEye.X());
+ anAt.SetY (aLook.Y() + anEye.Y());
+ anAt.SetZ (aLook.Z() + anEye.Z());
+
+ m_dAngle = theAngle;
+
+ aCamera->SetCenter (anAt);
+ aCamera->SetFOVy (theAngle);
+
+ myView->Update();
+ }
}
void CAnimationView3D::ReloadData()
dy = m_Aty - m_Eyey ;
dz = m_Atz - m_Eyez ;
- m_Focus = sqrt ( dx * dx + dy * dy + dz * dz ) ;
- m_dAngle = myPView->Angle () ;
- m_dAngle = m_dAngle * 180. / M_PI ;
+ m_Focus = sqrt (dx * dx + dy * dy + dz * dz);
+
+ m_dAngle = myView->Camera()->FOVy();
m_Tune.m_dAngle = m_dAngle ;
m_Tune.m_dFocus = m_Focus ;
void SetDimensions ();
void ReloadData();
CTune m_Tune;
- void SetFocal ( double dFocus , double dAngle );
+ void SetFocal (double theFocus, double theAngle);
void Fly (int x , int y);
void Turn (int x , int y);
void Roll (int x , int y);
Quantity_Factor myCurZoom;
Standard_Boolean myHlrModeIsOn;
- Handle_V3d_PerspectiveView myPView;
-
View3D_CurrentAction myCurrentMode;
double m_Atx , m_Aty , m_Atz ;
double m_Eyex , m_Eyey , m_Eyez ;
#include "HLRAlgo_Projector.hxx"
#include "Aspect_MarkMap.hxx"
-#include <V3d_PerspectiveView.hxx>
#include <Geom_BSplineSurface.hxx>
#include <TopoDS_Face.hxx>
#include <TopoDS_Solid.hxx>
#include <res\OCC_Resource.h>
#include <Visual3d_View.hxx>
+
#include <Graphic3d_ExportFormat.hxx>
+#include <Graphic3d_Camera.hxx>
+
+#include <OpenGl_GraphicDriver.hxx>
#define ValZWMin 1
ON_COMMAND(ID_BUTTONRot, OnBUTTONRot)
ON_COMMAND(ID_BUTTONTop, OnBUTTONTop)
ON_COMMAND(ID_BUTTONZoomAll, OnBUTTONZoomAll)
+ ON_COMMAND(ID_BUTTON_STEREOCONFIG, OnStereoConfigButton)
ON_WM_SIZE()
ON_COMMAND(ID_FILE_EXPORT_IMAGE, OnFileExportImage)
ON_COMMAND(ID_BUTTONZoomProg, OnBUTTONZoomProg)
ON_UPDATE_COMMAND_UI(ID_BUTTONZoomProg, OnUpdateBUTTONZoomProg)
ON_UPDATE_COMMAND_UI(ID_BUTTONZoomWin, OnUpdateBUTTONZoomWin)
ON_UPDATE_COMMAND_UI(ID_BUTTONRot, OnUpdateBUTTONRot)
+ ON_UPDATE_COMMAND_UI(ID_BUTTON_STEREOCONFIG, OnUpdateStereoConfigButton)
ON_COMMAND(ID_Modify_ChangeBackground , OnModifyChangeBackground)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
OCC_3dView::~OCC_3dView()
{
- if ( myView )
+ if (myView)
+ {
myView->Remove();
- if (m_Pen) delete m_Pen;
+ }
+
+ delete m_pStereoDlg;
+ delete m_Pen;
}
BOOL OCC_3dView::PreCreateWindow(CREATESTRUCT& cs)
myHlrModeIsOn = Standard_False;
myView->SetComputedMode (myHlrModeIsOn);
- Handle(Graphic3d_GraphicDriver) aGraphicDriver =
- ((OCC_App*)AfxGetApp())->GetGraphicDriver();
+ Handle(OpenGl_GraphicDriver) aDriver =
+ Handle(OpenGl_GraphicDriver)::DownCast (((OCC_App*)AfxGetApp())->GetGraphicDriver());
Handle(WNT_Window) aWNTWindow = new WNT_Window(GetSafeHwnd());
+
myView->SetWindow(aWNTWindow);
- if (!aWNTWindow->IsMapped()) aWNTWindow->Map();
+ myView->Camera()->SetProjectionType (aDriver->Options().contextStereo
+ ? Graphic3d_Camera::Projection_Stereo
+ : Graphic3d_Camera::Projection_Orthographic);
+
+ if (!aWNTWindow->IsMapped())
+ {
+ aWNTWindow->Map();
+ }
// store the mode ( nothing , dynamic zooming, dynamic ... )
myCurrentMode = CurAction3d_Nothing;
+
+ m_pStereoDlg = new OCC_StereoConfigDlg (this);
+ m_pStereoDlg->SetView (myView);
+ m_pStereoDlg->Create (IDD_DIALOG_STEREO, this);
}
void OCC_3dView::OnDraw(CDC* /*pDC*/)
}
myView->Redraw();
}
+
+//=============================================================================
+// function: OnStereoConfigButton
+// purpose: Open stereographic configuration dialog
+//=============================================================================
+void OCC_3dView::OnStereoConfigButton()
+{
+ m_pStereoDlg->ShowWindow (SW_SHOW);
+}
+
+//=============================================================================
+// function: OnUpdateStereoConfigButton
+// purpose: Enable / disable state of stereo configuration button
+//=============================================================================
+void OCC_3dView::OnUpdateStereoConfigButton (CCmdUI* theCmdUI)
+{
+ // get camera
+ Handle(Graphic3d_Camera) aCamera = myView->Camera();
+
+ // check that button is enabled
+ Standard_Boolean isEnabled = !aCamera.IsNull() && aCamera->IsStereo();
+
+ // update toggle state
+ theCmdUI->Enable (isEnabled);
+
+ if (!isEnabled)
+ {
+ m_pStereoDlg->ShowWindow (SW_HIDE);
+ }
+}
#include "OCC_BaseView.h"
#include "OCC_3dDoc.h"
+#include "OCC_StereoConfigDlg.h"
#include <Standard_Macro.hxx>
enum CurAction3d {
afx_msg void OnUpdateBUTTONZoomWin(CCmdUI* pCmdUI);
afx_msg void OnUpdateBUTTONRot(CCmdUI* pCmdUI);
afx_msg void OnModifyChangeBackground();
+ afx_msg void OnStereoConfigButton();
+ afx_msg void OnUpdateStereoConfigButton (CCmdUI* theCmdUI);
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
const Standard_Integer MaxY ,
const Standard_Boolean Draw ,
const LineStyle aLineStyle = Default );
+
+private:
+
+ //! Persistent non blocking stereo configuration dialog
+ OCC_StereoConfigDlg* m_pStereoDlg;
};
#ifndef _DEBUG // debug version in OCC_3dView.cpp
#include <stdafx.h>
#include "OCC_App.h"
-
+#include "OCC_BaseDoc.h"
#include <res\OCC_Resource.h>
#include <Standard_Version.hxx>
+#include <OpenGl_GraphicDriver.hxx>
#include <OSD.hxx>
+
#include "afxwin.h"
/////////////////////////////////////////////////////////////////////////////
// Standard file based document commands
ON_COMMAND(ID_FILE_NEW, CWinApp::OnFileNew)
ON_COMMAND(ID_FILE_OPEN, CWinApp::OnFileOpen)
+ ON_COMMAND(ID_BUTTON_STEREO, &OCC_App::OnStereo)
+ ON_UPDATE_COMMAND_UI(ID_BUTTON_STEREO, &OCC_App::OnUpdateStereo)
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
{
SampleName = Name;
}
+
+//=============================================================================
+// function: OnStereo
+// purpose:
+//=============================================================================
+void OCC_App::OnStereo()
+{
+ Handle(OpenGl_GraphicDriver) aDriver = Handle(OpenGl_GraphicDriver)::DownCast (myGraphicDriver);
+
+ int anAnswer = MessageBox(NULL,
+ "It is required to switch OpenGl context to turn on / off hardware stereo support. "
+ "The document views need to be re-created to change \"GL\" context pixel format. "
+ "This will close all current views and open new one (the model will be kept).\n"
+ "Do you want to continue?", "Enable/disable hardware stereo support", MB_OKCANCEL | MB_ICONQUESTION);
+ if (anAnswer != IDOK)
+ {
+ return;
+ }
+
+ Standard_Boolean& aStereoMode = aDriver->ChangeOptions().contextStereo;
+
+ aStereoMode = !aStereoMode;
+
+ // reset document views
+ POSITION aTemplateIt = GetFirstDocTemplatePosition();
+
+ while (aTemplateIt != NULL)
+ {
+ CDocTemplate* aTemplate = (CDocTemplate*)GetNextDocTemplate (aTemplateIt);
+
+ POSITION aDocumentIt = aTemplate->GetFirstDocPosition();
+
+ while (aDocumentIt != NULL)
+ {
+ OCC_BaseDoc* aDocument = dynamic_cast<OCC_BaseDoc*> (aTemplate->GetNextDoc (aDocumentIt));
+ if (aDocument == NULL)
+ continue;
+
+ aDocument->ResetDocumentViews (aTemplate);
+ }
+ }
+}
+
+//=============================================================================
+// function: OnUpdateStereo
+// purpose:
+//=============================================================================
+void OCC_App::OnUpdateStereo (CCmdUI* theCmdUI)
+{
+ Handle(OpenGl_GraphicDriver) aDriver =
+ Handle(OpenGl_GraphicDriver)::DownCast (myGraphicDriver);
+
+ theCmdUI->SetCheck (!aDriver.IsNull() && aDriver->Options().contextStereo);
+}
}
// Implementation
- //{{AFX_MSG(OCC_BaseApp)
- afx_msg void OnAppAbout();
- // NOTE - the ClassWizard will add and remove member functions here.
- // DO NOT EDIT what you see in these blocks of generated code !
- //}}AFX_MSG
+ //{{AFX_MSG(OCC_BaseApp)
+ afx_msg void OnAppAbout();
+ afx_msg void OnStereo();
+ afx_msg void OnUpdateStereo (CCmdUI* theCmdUI);
+ // NOTE - the ClassWizard will add and remove member functions here.
+ // DO NOT EDIT what you see in these blocks of generated code !
+ //}}AFX_MSG
DECLARE_MESSAGE_MAP()
protected:
Handle_Graphic3d_GraphicDriver myGraphicDriver;
OCC_BaseDoc::~OCC_BaseDoc()
{
+}
+
+//=============================================================================
+// function: ResetDocumentViews
+// purpose:
+//=============================================================================
+void OCC_BaseDoc::ResetDocumentViews (CDocTemplate* theTemplate)
+{
+ // do not delete document if no views
+ BOOL isAutoDelete = m_bAutoDelete;
+ m_bAutoDelete = FALSE;
+
+ // close all opened views
+ POSITION aViewIt = GetFirstViewPosition();
+ while (aViewIt)
+ {
+ CView* aView = GetNextView (aViewIt);
+ if (aView == NULL)
+ {
+ continue;
+ }
+
+ RemoveView (aView);
+
+ aView->GetParentFrame()->SendMessage (WM_CLOSE);
+ }
+
+ // create new view frame
+ CFrameWnd* aNewFrame = theTemplate->CreateNewFrame (this, NULL);
+ m_bAutoDelete = isAutoDelete;
+
+ // init frame
+ theTemplate->InitialUpdateFrame(aNewFrame, this);
+
+
+
}
virtual void Popup (const Standard_Integer /*theMouseX*/,
const Standard_Integer /*theMouseY*/,
const Handle(V3d_View)& /*theView*/) {}
+
+public:
+
+ void ResetDocumentViews (CDocTemplate* theTemplate);
+
protected:
Handle(V3d_Viewer) myViewer;
--- /dev/null
+///////////////////////////////////////////////////////////////////////////////
+// OCC_StereoConfigDlg.cpp : source file
+///////////////////////////////////////////////////////////////////////////////
+
+#include "stdafx.h"
+#include "OCC_StereoConfigDlg.h"
+#include <Graphic3d_Camera.hxx>
+
+BEGIN_MESSAGE_MAP (OCC_StereoConfigDlg, CDialog)
+
+ ON_WM_HSCROLL()
+ ON_NOTIFY (UDN_DELTAPOS, IDC_SPIN_FOCUS, OnSpinFocus)
+ ON_NOTIFY (UDN_DELTAPOS, IDC_SPIN_IOD, OnSpinIOD)
+ ON_BN_CLICKED (IDC_CHECK_FOCUS_RELATIVE, OnCheckFocus)
+ ON_BN_CLICKED (IDC_CHECK_IOD_RELATIVE, OnCheckIOD)
+ ON_EN_CHANGE (IDC_EDIT_FOCUS, OnChangeFocus)
+ ON_EN_CHANGE (IDC_EDIT_IOD, OnChangeIOD)
+
+END_MESSAGE_MAP()
+
+// round up value macro
+#define ROUND_UP(X) X = (Round(X * 10000.0) / 10000.0)
+
+// slider tick conversion
+#define TO_SLIDER(X) (Standard_Integer)Round(X * 10)
+
+// back conversion from slider ticks
+#define FROM_SLIDER(X) X / 10.0
+
+// ============================================================================
+// function: SetView
+// purpose:
+// ============================================================================
+void OCC_StereoConfigDlg::SetView (const Handle(V3d_View)& theView)
+{
+ myView = theView;
+
+ // access initial values
+ myIOD = myView->Camera()->IOD();
+ myFocus = myView->Camera()->ZFocus();
+ mySliderFocus = TO_SLIDER(myFocus);
+ myIsRelativeIOD = (myView->Camera()->GetIODType() == Graphic3d_Camera::IODType_Relative);
+ myIsRelativeFocus = (myView->Camera()->ZFocusType() == Graphic3d_Camera::FocusType_Relative);
+}
+
+// ============================================================================
+// function: DoDataExchange
+// purpose:
+// ============================================================================
+void OCC_StereoConfigDlg::DoDataExchange(CDataExchange* theDX)
+{
+ CDialog::DoDataExchange(theDX);
+
+ DDX_Text (theDX, IDC_EDIT_IOD, myIOD);
+ DDV_MinMaxDouble (theDX, myIOD, -DBL_MAX, DBL_MAX);
+
+ if (myIsRelativeFocus)
+ {
+ // do slider data exchange
+ DDX_Slider (theDX, IDC_SLIDER_FOCUS, (int&)mySliderFocus);
+ DDV_MinMaxSlider (theDX, mySliderFocus, TO_SLIDER(0.1), TO_SLIDER(10));
+
+ // show up value in edit field
+ Standard_Real aEditValue = FROM_SLIDER (mySliderFocus);
+ DDX_Text (theDX, IDC_EDIT_FOCUS, aEditValue);
+
+ // update focus value correspondingly
+ myFocus = FROM_SLIDER (mySliderFocus);
+ }
+ else
+ {
+ DDX_Text (theDX, IDC_EDIT_FOCUS, myFocus);
+ DDV_MinMaxDouble (theDX, myFocus, 50, DBL_MAX);
+
+ mySliderFocus = TO_SLIDER(1.0);
+ DDX_Slider (theDX, IDC_SLIDER_FOCUS, (int&)mySliderFocus);
+ }
+
+ DDX_Check (theDX, IDC_CHECK_FOCUS_RELATIVE, (int&)myIsRelativeFocus);
+ DDX_Check (theDX, IDC_CHECK_IOD_RELATIVE, (int&)myIsRelativeIOD);
+
+ CEdit* aFocusEdit = (CEdit*) GetDlgItem (IDC_EDIT_FOCUS);
+ aFocusEdit->EnableWindow (myIsRelativeFocus != Standard_True);
+
+ CSliderCtrl* aSlider = (CSliderCtrl*) GetDlgItem (IDC_SLIDER_FOCUS);
+ aSlider->EnableWindow (myIsRelativeFocus == Standard_True);
+}
+
+// ============================================================================
+// function: OnHScroll
+// purpose:
+// ============================================================================
+void OCC_StereoConfigDlg::OnHScroll(UINT theSBCode, UINT thePos, CScrollBar* theScrollBar)
+{
+ UpdateData (true);
+ UpdateData (false);
+ UpdateCamera();
+ CWnd::OnHScroll(theSBCode, thePos, theScrollBar);
+}
+
+// ============================================================================
+// function: UpdateCamera
+// purpose:
+// ============================================================================
+void OCC_StereoConfigDlg::UpdateCamera()
+{
+ // update camera properties and redraw view
+ Handle(Graphic3d_Camera)& aCamera = myView->Camera();
+ if (aCamera.IsNull())
+ return;
+
+ // change IOD
+ Graphic3d_Camera::IODType aIODType =
+ myIsRelativeIOD ? Graphic3d_Camera::IODType_Relative :
+ Graphic3d_Camera::IODType_Absolute;
+
+ aCamera->SetIOD (aIODType, myIOD);
+
+ // change Focus
+ Graphic3d_Camera::FocusType aFocusType =
+ myIsRelativeFocus ? Graphic3d_Camera::FocusType_Relative :
+ Graphic3d_Camera::FocusType_Absolute;
+
+ aCamera->SetZFocus (aFocusType, myFocus);
+
+ // redraw view
+ myView->Redraw();
+}
+
+// ============================================================================
+// function: OnCheckFocus
+// purpose:
+// ============================================================================
+void OCC_StereoConfigDlg::OnCheckFocus()
+{
+ UpdateData (true);
+
+ // change focus to some predefined values
+ if (myIsRelativeFocus)
+ myFocus = 1.0;
+ else
+ myFocus = 100.0;
+
+ UpdateData (false);
+ UpdateCamera();
+}
+
+// ============================================================================
+// function: OnCheckIOD
+// purpose:
+// ============================================================================
+void OCC_StereoConfigDlg::OnCheckIOD()
+{
+ UpdateData (true);
+ UpdateCamera();
+}
+
+// ============================================================================
+// function: OnChangeFocus
+// purpose:
+// ============================================================================
+void OCC_StereoConfigDlg::OnChangeFocus()
+{
+ // keep previous value
+ Standard_Real aPrevFocus = myFocus;
+
+ // read data from ui controls
+ if (UpdateData (true))
+ {
+ UpdateCamera();
+ }
+ else
+ {
+ // revert back
+ myFocus = aPrevFocus;
+ UpdateData (false);
+ }
+}
+
+// ============================================================================
+// function: OnChangeIOD
+// purpose:
+// ============================================================================
+void OCC_StereoConfigDlg::OnChangeIOD()
+{
+ // keep previous value
+ Standard_Real aPrevIOD = myIOD;
+
+ // read data from ui controls
+ if (UpdateData (true))
+ {
+ UpdateCamera();
+ }
+ else
+ {
+ // revert back
+ myIOD = aPrevIOD;
+ UpdateData (false);
+ }
+}
+
+// ============================================================================
+// function: OnSpinFocus
+// purpose:
+// ============================================================================
+void OCC_StereoConfigDlg::OnSpinFocus (NMHDR* theNMHDR, LRESULT* theResult)
+{
+ NM_UPDOWN* aNMUpDown = (NM_UPDOWN*)theNMHDR;
+
+ const double aStep = 0.1; // use small incremental step
+ const double aDelta = aNMUpDown->iDelta * aStep; // get delta
+
+ // changes value
+ myFocus -= (Standard_Real)aDelta;
+
+ // round up value
+ ROUND_UP (myFocus);
+
+ // actualize view & ui controls
+ UpdateData (false);
+ UpdateCamera();
+
+ *theResult = 0;
+}
+
+// ============================================================================
+// function: OnSpinIOD
+// purpose:
+// ============================================================================
+void OCC_StereoConfigDlg::OnSpinIOD (NMHDR* theNMHDR, LRESULT* theResult)
+{
+ NM_UPDOWN* aNMUpDown = (NM_UPDOWN*)theNMHDR;
+
+ const double aStep = 0.01; // use small incremental step
+ const double aDelta = aNMUpDown->iDelta * aStep; // get delta
+
+ // changes value
+ myIOD -= (Standard_Real)aDelta;
+
+ // round up value
+ ROUND_UP (myIOD);
+
+ // actualize view & ui controls
+ UpdateData (false);
+ UpdateCamera();
+
+ *theResult = 0;
+}
--- /dev/null
+///////////////////////////////////////////////////////////////////////////////
+// OCC_StereoConfigDlg.h : header file
+///////////////////////////////////////////////////////////////////////////////
+
+#ifndef OCC_StereoConfigDlg_Header
+#define OCC_StereoConfigDlg_Header
+
+#if _MSC_VER >= 1000
+#pragma once
+#endif // _MSC_VER >= 1000
+
+#include "res\OCC_Resource.h"
+#include <V3d_View.hxx>
+
+// Dialog to dynamically configure 3D Viewer stereo
+// projection properties.
+class AFX_EXT_CLASS OCC_StereoConfigDlg : public CDialog
+{
+public:
+
+ OCC_StereoConfigDlg (CWnd* theParent = NULL)
+ : CDialog (IDD_DIALOG_STEREO, theParent) {}
+
+ void SetView (const Handle(V3d_View)& theView);
+
+protected:
+
+ virtual void DoDataExchange (CDataExchange* theDX);
+
+ void UpdateCamera();
+
+// Implementation
+protected:
+
+ afx_msg void OnCheckFocus();
+ afx_msg void OnCheckIOD();
+ afx_msg void OnChangeFocus();
+ afx_msg void OnChangeIOD();
+ afx_msg void OnSpinFocus (NMHDR* theNMHDR, LRESULT* theResult);
+ afx_msg void OnSpinIOD (NMHDR* theNMHDR, LRESULT* theResult);
+ afx_msg void OnHScroll(UINT theSBCode, UINT thePos, CScrollBar* theScrollBar);
+
+ DECLARE_MESSAGE_MAP()
+
+private:
+
+ Standard_Real myIOD;
+ Standard_Real myFocus;
+ Standard_Integer mySliderFocus;
+ Standard_Boolean myIsRelativeIOD;
+ Standard_Boolean myIsRelativeFocus;
+ Handle(V3d_View) myView;
+};
+
+#endif
#define IDD_ParamsFacesPage 101
#define IDR_POPUP 116
#define IDD_Dimension 119
+#define IDD_DIALOG_STEREO 120
#define IDD_LengthParamsEdgePage 122
#define IDD_LengthParamsVerticesPage 123
#define IDD_LengthParamsEdgesPage 125
#define IDC_TextDisplayMode 1047
#define IDC_TextDisplayModeStatic 1048
#define IDC_DimensionColor 1049
-#define IDC_FacesSt1 1052
-#define IDC_FacesSt2 1053
-#define IDC_FacesBtn1 1054
-#define IDC_FacesBtn2 1055
+#define IDC_EDIT_IOD 1050
+#define IDC_SPIN_IOD 1051
+#define IDC_CHECK_IOD_RELATIVE 1052
+#define IDC_CHECK_FOCUS_RELATIVE 1053
+#define IDC_SLIDER_FOCUS 1054
+#define IDC_EDIT_FOCUS 1055
+#define IDC_SPIN_FOCUS 1056
+#define IDC_FacesSt1 1057
+#define IDC_FacesSt2 1058
+#define IDC_FacesBtn1 1059
+#define IDC_FacesBtn2 1060
#define ID_WINDOW_NEW3D 1151
#define ID_OBJECT_DISPLAYALL 1201
#define ID_OBJECT_MATERIAL 1205
#define ID_OBJECT_DIMENSIONS 40035
#define ID_OBJECT_DIM 40036
#define ID_LOCALCONTEXT_ADDDIMENSION 40037
+#define ID_BUTTON_STEREOSETTINGS 40038
+#define ID_BUTTON_STEREO 40039
+#define ID_BUTTON_STEREOCONFIG 40040
#define ID_FILE_IMPORT_CSFDB 40100
#define ID_FILE_IMPORT_BREP 40101
#define ID_FILE_IMPORT_STEP 40102
#ifdef APSTUDIO_INVOKED
#ifndef APSTUDIO_READONLY_SYMBOLS
#define _APS_NEXT_RESOURCE_VALUE 131
-#define _APS_NEXT_COMMAND_VALUE 40038
-#define _APS_NEXT_CONTROL_VALUE 1055
+#define _APS_NEXT_COMMAND_VALUE 40041
+#define _APS_NEXT_CONTROL_VALUE 1061
#define _APS_NEXT_SYMED_VALUE 101
#endif
#endif
PUSHBUTTON "Change dimension color",IDC_DimensionColor,105,156,63,24,BS_MULTILINE
CONTROL "",IDC_Flyout,"msctls_trackbar32",TBS_TOP | TBS_TOOLTIPS | WS_TABSTOP,73,112,100,20
END
+IDD_DIALOG_STEREO DIALOGEX 0, 0, 166, 177
+STYLE DS_SETFONT | DS_MODALFRAME | DS_FIXEDSYS | WS_POPUP | WS_CAPTION | WS_SYSMENU
+CAPTION "Configure stereo"
+FONT 8, "MS Shell Dlg", 400, 0, 0x1
+BEGIN
+ EDITTEXT IDC_EDIT_IOD,88,42,41,12,ES_AUTOHSCROLL | WS_GROUP
+ CONTROL "",IDC_SPIN_IOD,"msctls_updown32",UDS_AUTOBUDDY | UDS_ARROWKEYS | WS_GROUP,130,42,11,12
+ GROUPBOX "Stereo focus properties:",IDC_STATIC,7,72,149,96
+ GROUPBOX "Eye separation properties:",IDC_STATIC,6,6,150,60
+ LTEXT "Intraocular distance:",IDC_STATIC,18,43,68,8
+ CONTROL "",IDC_CHECK_IOD_RELATIVE,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,102,24,16,10
+ LTEXT "Relative to focal length:",IDC_STATIC,18,24,78,8
+ CONTROL "",IDC_CHECK_FOCUS_RELATIVE,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,102,90,16,10
+ LTEXT "Relative to focal length:",IDC_STATIC,18,90,78,8
+ CONTROL "",IDC_SLIDER_FOCUS,"msctls_trackbar32",TBS_TOP | WS_TABSTOP,18,108,126,24
+ LTEXT "Fixed value:",IDC_STATIC,18,146,40,8
+ EDITTEXT IDC_EDIT_FOCUS,67,144,41,12,ES_AUTOHSCROLL | WS_GROUP
+ CONTROL "",IDC_SPIN_FOCUS,"msctls_updown32",UDS_AUTOBUDDY | UDS_ARROWKEYS | WS_GROUP,108,144,11,12
+END
IDD_ParamsFacesPage DIALOGEX 0, 0, 134, 73
STYLE DS_SETFONT | DS_FIXEDSYS | WS_CHILD
BUTTON ID_BUTTONRot
BUTTON ID_BUTTONReset
SEPARATOR
+ BUTTON ID_BUTTON_STEREOCONFIG
+ SEPARATOR
BUTTON ID_BUTTONHlrOff
BUTTON ID_BUTTONHlrOn
END
HORZGUIDE, 336
END
+ IDD_DIALOG_STEREO, DIALOG
+ BEGIN
+ LEFTMARGIN, 7
+ RIGHTMARGIN, 159
+ TOPMARGIN, 7
+ BOTTOMMARGIN, 170
+ END
+
IDD_ParamsFacesPage, DIALOG
BEGIN
LEFTMARGIN, 7
ID_LOCALCONTEXT_ADDDIMENSION "Add new dimension for selected objetcs"
END
+STRINGTABLE
+BEGIN
+ ID_BUTTON_STEREOSETTINGS "Configure stereo properties"
+ ID_BUTTON_STEREO "Toggle stereographic mode on / off"
+END
+
#endif // English (U.S.) resources
/////////////////////////////////////////////////////////////////////////////
<AdditionalIncludeDirectories Condition="'$(Configuration)|$(Platform)'=='Release|x64'">%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<PreprocessorDefinitions Condition="'$(Configuration)|$(Platform)'=='Release|x64'">%(PreprocessorDefinitions)</PreprocessorDefinitions>
</ClCompile>
+ <ClCompile Include="..\..\..\..\Common\OCC_StereoConfigDlg.cpp">
+ <Optimization Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">Disabled</Optimization>
+ <AdditionalIncludeDirectories Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
+ <PreprocessorDefinitions Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ <BasicRuntimeChecks Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">EnableFastChecks</BasicRuntimeChecks>
+ <Optimization Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">Disabled</Optimization>
+ <AdditionalIncludeDirectories Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
+ <PreprocessorDefinitions Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ <BasicRuntimeChecks Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">EnableFastChecks</BasicRuntimeChecks>
+ <Optimization Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">MaxSpeed</Optimization>
+ <AdditionalIncludeDirectories Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
+ <PreprocessorDefinitions Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ <Optimization Condition="'$(Configuration)|$(Platform)'=='Release|x64'">MaxSpeed</Optimization>
+ <AdditionalIncludeDirectories Condition="'$(Configuration)|$(Platform)'=='Release|x64'">%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
+ <PreprocessorDefinitions Condition="'$(Configuration)|$(Platform)'=='Release|x64'">%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ </ClCompile>
<ClCompile Include="..\..\..\..\Common\LengthParamsEdgePage.cpp" />
<ClCompile Include="..\..\..\..\Common\LengthParamsEdgesPage.cpp" />
<ClCompile Include="..\..\..\..\Common\LengthParamsVerticesPage.cpp" />
<ClInclude Include="..\..\..\..\Common\OCC_BaseDoc.h" />
<ClInclude Include="..\..\..\..\Common\OCC_BaseView.h" />
<ClInclude Include="..\..\..\..\Common\OCC_MainFrame.h" />
+ <ClInclude Include="..\..\..\..\Common\OCC_StereoConfigDlg.h" />
<ClInclude Include="..\..\..\..\Common\RadiusParamsPage.h" />
<ClInclude Include="..\..\..\..\Common\ParamsFacesPage.h" />
<ClInclude Include="..\..\..\..\Common\res\OCC_Resource.h" />
<ClCompile Include="..\..\..\..\Common\ISession2D\ISession2D_Shape.cpp">
<Filter>Source Files\ISession2D-src</Filter>
</ClCompile>
+ <ClCompile Include="..\..\..\..\Common\OCC_StereoConfigDlg.cpp">
+ <Filter>Source Files</Filter>
+ </ClCompile>
<ClCompile Include="..\..\..\..\Common\DimensionDlg.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClInclude Include="..\..\..\..\Common\ISession2D\ISession2D_Shape.h">
<Filter>Header Files\ISession2D-headers</Filter>
</ClInclude>
+ <ClInclude Include="..\..\..\..\Common\OCC_StereoConfigDlg.h">
+ <Filter>Header Files</Filter>
+ </ClInclude>
<ClInclude Include="..\..\..\..\Common\DimensionDlg.h">
<Filter>Header Files</Filter>
</ClInclude>
<AdditionalIncludeDirectories Condition="'$(Configuration)|$(Platform)'=='Release|x64'">%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<PreprocessorDefinitions Condition="'$(Configuration)|$(Platform)'=='Release|x64'">%(PreprocessorDefinitions)</PreprocessorDefinitions>
</ClCompile>
+ <ClCompile Include="..\..\..\..\Common\OCC_StereoConfigDlg.cpp">
+ <Optimization Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">Disabled</Optimization>
+ <AdditionalIncludeDirectories Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
+ <PreprocessorDefinitions Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ <BasicRuntimeChecks Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">EnableFastChecks</BasicRuntimeChecks>
+ <Optimization Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">Disabled</Optimization>
+ <AdditionalIncludeDirectories Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
+ <PreprocessorDefinitions Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ <BasicRuntimeChecks Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">EnableFastChecks</BasicRuntimeChecks>
+ <Optimization Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">MaxSpeed</Optimization>
+ <AdditionalIncludeDirectories Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
+ <PreprocessorDefinitions Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ <Optimization Condition="'$(Configuration)|$(Platform)'=='Release|x64'">MaxSpeed</Optimization>
+ <AdditionalIncludeDirectories Condition="'$(Configuration)|$(Platform)'=='Release|x64'">%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
+ <PreprocessorDefinitions Condition="'$(Configuration)|$(Platform)'=='Release|x64'">%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ </ClCompile>
<ClCompile Include="..\..\..\..\Common\ImportExport\SaveCSFDBDlg.cpp">
<Optimization Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">Disabled</Optimization>
<AdditionalIncludeDirectories Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<ClInclude Include="..\..\..\..\Common\ParamsFacesPage.h" />
<ClInclude Include="..\..\..\..\Common\res\OCC_Resource.h" />
<ClInclude Include="..\..\..\..\Common\ResultDialog.h" />
+ <ClInclude Include="..\..\..\..\Common\OCC_StereoConfigDlg.h" />
<ClInclude Include="..\..\..\..\Common\ImportExport\SaveCSFDBDlg.h" />
<ClInclude Include="..\..\..\..\Common\ImportExport\SaveSTEPDlg.h" />
<ClInclude Include="..\..\..\..\Common\StdAfx.h" />
<ClCompile Include="..\..\..\..\Common\ResultDialog.cpp">
<Filter>Source Files</Filter>
</ClCompile>
+ <ClCompile Include="..\..\..\..\Common\OCC_StereoConfigDlg.cpp">
+ <Filter>Source Files</Filter>
+ </ClCompile>
<ClCompile Include="..\..\..\..\Common\ImportExport\SaveCSFDBDlg.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClInclude Include="..\..\..\..\Common\ResultDialog.h">
<Filter>Header Files</Filter>
</ClInclude>
+ <ClInclude Include="..\..\..\..\Common\OCC_StereoConfigDlg.h">
+ <Filter>Header Files</Filter>
+ </ClInclude>
<ClInclude Include="..\..\..\..\Common\ImportExport\SaveCSFDBDlg.h">
<Filter>Header Files</Filter>
</ClInclude>
/>
</FileConfiguration>
</File>
+ <File
+ RelativePath="..\..\..\..\Common\OCC_StereoConfigDlg.cpp"
+ >
+ </File>
<File
RelativePath="..\..\..\..\Common\RadiusParamsPage.cpp"
>
RelativePath="..\..\..\..\Common\res\OCC_Resource.h"
>
</File>
+ <File
+ RelativePath="..\..\..\..\Common\OCC_StereoConfigDlg.h"
+ >
+ </File>
<File
RelativePath="..\..\..\..\Common\RadiusParamsPage.h"
>
/>
</FileConfiguration>
</File>
+ <File
+ RelativePath="..\..\..\..\Common\OCC_StereoConfigDlg.cpp"
+ >
+ </File>
<File
RelativePath="..\..\..\..\Common\RadiusParamsPage.cpp"
>
RelativePath="..\..\..\..\Common\res\OCC_Resource.h"
>
</File>
+ <File
+ RelativePath="..\..\..\..\Common\OCC_StereoConfigDlg.h"
+ >
+ </File>
<File
RelativePath="..\..\..\..\Common\RadiusParamsPage.h"
>
Graphic3d_ClipPlane_Handle.hxx
Graphic3d_SequenceOfHClipPlane.hxx
Graphic3d_SequenceOfHClipPlane_Handle.hxx
+Graphic3d_Camera.cxx
+Graphic3d_Camera.hxx
+Graphic3d_Camera_Handle.hxx
imported MarkerImage;
imported MarkerImage_Handle;
+ imported Camera_Handle;
primitive PtrFrameBuffer;
primitive Vec2;
#include <InterfaceGraphic_Graphic3d.hxx>
#include <InterfaceGraphic_Visual3d.hxx>
#include <Handle_Graphic3d_TextureEnv.hxx>
+#include <Graphic3d_Camera.hxx>
+
+#include <Standard_Type.hxx>
#include <Graphic3d_CLight.hxx>
#include <Graphic3d_SequenceOfHClipPlane.hxx>
int SurfaceDetail;
Graphic3d_SequenceOfHClipPlane ClipPlanes;
+
+ Handle(Graphic3d_Camera) Camera;
};
class Graphic3d_CView
ptrUnderLayer (NULL),
ptrOverLayer (NULL),
Backfacing (0),
- GContext (NULL),
+ GContext (NULL),
GDisplayCB (NULL),
GClientData (NULL),
ptrFBO (NULL),
IsReflectionsEnabled (1),
IsAntialiasingEnabled (0)
{
- memset(&Orientation,0,sizeof(Orientation));
- memset(&Mapping,0,sizeof(Mapping));
- memset(&OrientationReset,0,sizeof(OrientationReset));
- memset(&MappingReset,0,sizeof(MappingReset));
- memset(&DefWindow,0,sizeof(DefWindow));
+ memset(&DefWindow,0,sizeof(DefWindow));
}
public:
int Active;
- CALL_DEF_VIEWORIENTATION Orientation;
- CALL_DEF_VIEWMAPPING Mapping;
-
- CALL_DEF_VIEWORIENTATION OrientationReset;
- CALL_DEF_VIEWMAPPING MappingReset;
-
CALL_DEF_VIEWCONTEXT Context;
CALL_DEF_WINDOW DefWindow;
--- /dev/null
+// Created on: 2013-05-29
+// Created by: Anton POLETAEV
+// Copyright (c) 1999-2014 OPEN CASCADE SAS
+//
+// This file is part of Open CASCADE Technology software library.
+//
+// This library is free software; you can redistribute it and / or modify it
+// under the terms of the GNU Lesser General Public version 2.1 as published
+// by the Free Software Foundation, with special exception defined in the file
+// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
+// distribution for complete text of the license and disclaimer of any warranty.
+//
+// Alternatively, this file may be used under the terms of Open CASCADE
+// commercial license or contractual agreement.
+
+#include <gp_Pln.hxx>
+#include <Standard_ShortReal.hxx>
+
+#include <Graphic3d_Vec4.hxx>
+#include <Graphic3d_Camera.hxx>
+
+#include <Standard_Atomic.hxx>
+
+IMPLEMENT_STANDARD_HANDLE(Graphic3d_Camera, Standard_Transient)
+IMPLEMENT_STANDARD_RTTIEXT(Graphic3d_Camera, Standard_Transient)
+
+namespace
+{
+ // (degrees -> radians) * 0.5
+ static const Standard_ShortReal DTR_HALF = 0.5f * 0.0174532925f;
+
+ // atomic state counter
+ static volatile Standard_Integer THE_STATE_COUNTER = 0;
+};
+
+// =======================================================================
+// function : Graphic3d_Camera
+// purpose :
+// =======================================================================
+Graphic3d_Camera::Graphic3d_Camera()
+: myUp (0.0, 1.0, 0.0),
+ myEye (0.0, 0.0, -1500.0),
+ myCenter (0.0, 0.0, 0.0),
+ myProjectionShift (0.0, 0.0, 0.0),
+ myAxialScale (1.0, 1.0, 1.0),
+ myProjType (Projection_Orthographic),
+ myFOVy (45.0),
+ myZNear (0.001),
+ myZFar (3000.0),
+ myAspect (1.0),
+ myScale (1000.0),
+ myZFocus (1.0),
+ myZFocusType (FocusType_Relative),
+ myIOD (0.05),
+ myIODType (IODType_Relative),
+ myNbUpdateLocks (0)
+{
+ myProjectionState = (Standard_Size)Standard_Atomic_Increment (&THE_STATE_COUNTER);
+ myOrientationState = (Standard_Size)Standard_Atomic_Increment (&THE_STATE_COUNTER);
+
+ myOrientation.InitIdentity();
+ myMProjection.InitIdentity();
+ myLProjection.InitIdentity();
+ myRProjection.InitIdentity();
+
+ UpdateProjection();
+ UpdateOrientation();
+}
+
+// =======================================================================
+// function : Graphic3d_Camera
+// purpose :
+// =======================================================================
+Graphic3d_Camera::Graphic3d_Camera (const Handle(Graphic3d_Camera)& theOther)
+: myNbUpdateLocks (0)
+{
+ Copy (theOther);
+}
+
+// =======================================================================
+// function : CopyMappingData
+// purpose :
+// =======================================================================
+void Graphic3d_Camera::CopyMappingData (const Handle(Graphic3d_Camera)& theOtherCamera)
+{
+ myProjectionShift = theOtherCamera->myProjectionShift;
+ myFOVy = theOtherCamera->myFOVy;
+ myZNear = theOtherCamera->myZNear;
+ myZFar = theOtherCamera->myZFar;
+ myAspect = theOtherCamera->myAspect;
+ myScale = theOtherCamera->myScale;
+ myZFocus = theOtherCamera->myZFocus;
+ myZFocusType = theOtherCamera->myZFocusType;
+ myIOD = theOtherCamera->myIOD;
+ myIODType = theOtherCamera->myIODType;
+ myProjType = theOtherCamera->myProjType;
+
+ myProjectionState = theOtherCamera->myProjectionState;
+
+ UpdateProjection();
+}
+
+// =======================================================================
+// function : CopyOrientationData
+// purpose :
+// =======================================================================
+void Graphic3d_Camera::CopyOrientationData (const Handle(Graphic3d_Camera)& theOtherCamera)
+{
+ myUp = theOtherCamera->myUp;
+ myEye = theOtherCamera->myEye;
+ myCenter = theOtherCamera->myCenter;
+ myAxialScale = theOtherCamera->myAxialScale;
+
+ myOrientationState = theOtherCamera->myOrientationState;
+
+ UpdateOrientation();
+}
+
+// =======================================================================
+// function : Copy
+// purpose :
+// =======================================================================
+void Graphic3d_Camera::Copy (const Handle(Graphic3d_Camera)& theOther)
+{
+ BeginUpdate();
+ CopyMappingData (theOther);
+ CopyOrientationData (theOther);
+ EndUpdate();
+}
+
+// =======================================================================
+// function : SetEye
+// purpose :
+// =======================================================================
+void Graphic3d_Camera::SetEye (const gp_Pnt& theEye)
+{
+ myEye = theEye;
+ UpdateOrientation();
+}
+
+// =======================================================================
+// function : SetCenter
+// purpose :
+// =======================================================================
+void Graphic3d_Camera::SetCenter (const gp_Pnt& theCenter)
+{
+ myCenter = theCenter;
+ UpdateOrientation();
+}
+
+// =======================================================================
+// function : SetUp
+// purpose :
+// =======================================================================
+void Graphic3d_Camera::SetUp (const gp_Dir& theUp)
+{
+ myUp = theUp;
+ UpdateOrientation();
+}
+
+// =======================================================================
+// function : SetProjectionShift
+// purpose :
+// =======================================================================
+void Graphic3d_Camera::SetProjectionShift (const gp_Pnt& theProjShift)
+{
+ myProjectionShift = theProjShift;
+ UpdateProjection();
+}
+
+// =======================================================================
+// function : SetAxialScale
+// purpose :
+// =======================================================================
+void Graphic3d_Camera::SetAxialScale (const gp_Pnt& theAxialScale)
+{
+ myAxialScale = theAxialScale;
+ UpdateOrientation();
+}
+
+// =======================================================================
+// function : SetDistance
+// purpose :
+// =======================================================================
+void Graphic3d_Camera::SetDistance (const Standard_Real theDistance)
+{
+ gp_Vec aCenter2Eye (Direction());
+ aCenter2Eye.Reverse();
+ aCenter2Eye.Scale (theDistance);
+ SetEye (Center().Translated (aCenter2Eye));
+}
+
+// =======================================================================
+// function : Distance
+// purpose :
+// =======================================================================
+Standard_Real Graphic3d_Camera::Distance() const
+{
+ return myEye.Distance (myCenter);
+}
+
+// =======================================================================
+// function : SetDirection
+// purpose :
+// =======================================================================
+void Graphic3d_Camera::SetDirection (const gp_Dir& theDir)
+{
+ gp_Vec aScaledDir (theDir);
+ aScaledDir.Scale (Distance());
+ aScaledDir.Reverse();
+ SetEye (Center().Translated (aScaledDir));
+}
+
+// =======================================================================
+// function : Direction
+// purpose :
+// =======================================================================
+gp_Dir Graphic3d_Camera::Direction() const
+{
+ return gp_Dir (gp_Vec (myEye, myCenter));
+}
+
+// =======================================================================
+// function : SetScale
+// purpose :
+// =======================================================================
+void Graphic3d_Camera::SetScale (const Standard_Real theScale)
+{
+ myScale = theScale;
+
+ switch (myProjType)
+ {
+ case Projection_Perspective :
+ case Projection_Stereo :
+ case Projection_MonoLeftEye :
+ case Projection_MonoRightEye :
+ {
+ Standard_Real aDistance = theScale * 0.5 / Tan(myFOVy * M_PI / 360.0);
+ SetDistance (aDistance);
+ }
+
+ default :
+ break;
+ }
+
+ UpdateProjection();
+}
+
+// =======================================================================
+// function : Scale
+// purpose :
+// =======================================================================
+Standard_Real Graphic3d_Camera::Scale() const
+{
+ switch (myProjType)
+ {
+ case Projection_Orthographic :
+ return myScale;
+
+ // case Projection_Perspective :
+ // case Projection_Stereo :
+ // case Projection_MonoLeftEye :
+ // case Projection_MonoRightEye :
+ default :
+ return Distance() * 2.0 * Tan(myFOVy * M_PI / 360.0);
+ }
+}
+
+// =======================================================================
+// function : SetProjectionType
+// purpose :
+// =======================================================================
+void Graphic3d_Camera::SetProjectionType (const Projection theProjectionType)
+{
+ Projection anOldType = myProjType;
+
+ if (anOldType == theProjectionType)
+ {
+ return;
+ }
+
+ myProjType = theProjectionType;
+
+ switch (myProjType)
+ {
+ case Projection_Orthographic :
+ case Projection_Perspective :
+ case Projection_MonoLeftEye :
+ case Projection_MonoRightEye :
+ myLProjection.InitIdentity();
+ myRProjection.InitIdentity();
+ break;
+
+ default:
+ break;
+ }
+
+ UpdateProjection();
+}
+
+// =======================================================================
+// function : SetFOVy
+// purpose :
+// =======================================================================
+void Graphic3d_Camera::SetFOVy (const Standard_Real theFOVy)
+{
+ myFOVy = theFOVy;
+ UpdateProjection();
+}
+
+// =======================================================================
+// function : SetZNear
+// purpose :
+// =======================================================================
+void Graphic3d_Camera::SetZNear (const Standard_Real theZNear)
+{
+ myZNear = theZNear;
+
+ // it is important to prevent too low ZNear values relatively to ZFar
+ // so we can not just pass Precision::Confusion() to it
+ const Standard_Real aTolerance = 0.001;
+ const Standard_Real aMinimumZ = myZFar * aTolerance;
+ const Standard_Real aMinimumGap = aTolerance;
+ // while it is possible to manually set up pretty small ZNear value,
+ // it may affect project / unproject operations dramatically
+ if (myZNear < aMinimumZ)
+ {
+ myZNear = aMinimumZ;
+ }
+
+ if (myZFar < (myZNear + aMinimumGap))
+ {
+ myZFar = myZNear + aMinimumGap;
+ }
+
+ UpdateProjection();
+}
+
+// =======================================================================
+// function : SetZFar
+// purpose :
+// =======================================================================
+void Graphic3d_Camera::SetZFar (const Standard_Real theZFar)
+{
+ myZFar = theZFar;
+
+ // it is important to prevent too low ZNear values relatively to ZFar
+ // so we can not just pass Precision::Confusion() to it
+ const Standard_Real aTolerance = 0.001;
+ const Standard_Real aMinimumGap = aTolerance;
+
+ // while it is possible to manually set up pretty small ZNear value,
+ // it may affect project / unproject operations dramatically
+ if (myZFar < (myZNear + aMinimumGap))
+ {
+ myZFar = myZNear + aMinimumGap;
+ }
+
+ UpdateProjection();
+}
+
+// =======================================================================
+// function : SetAspect
+// purpose :
+// =======================================================================
+void Graphic3d_Camera::SetAspect (const Standard_Real theAspect)
+{
+ myAspect = theAspect;
+ UpdateProjection();
+}
+
+// =======================================================================
+// function : SetZFocus
+// purpose :
+// =======================================================================
+void Graphic3d_Camera::SetZFocus(const FocusType theType, const Standard_Real theZFocus)
+{
+ myZFocusType = theType;
+ myZFocus = theZFocus;
+ UpdateProjection();
+}
+
+// =======================================================================
+// function : SetIOD
+// purpose :
+// =======================================================================
+void Graphic3d_Camera::SetIOD (const IODType theType, const Standard_Real theIOD)
+{
+ myIODType = theType;
+ myIOD = theIOD;
+ UpdateProjection();
+}
+
+// =======================================================================
+// function : OrthogonalizeUp
+// purpose :
+// =======================================================================
+void Graphic3d_Camera::OrthogonalizeUp()
+{
+ gp_Dir aDir = Direction();
+ gp_Dir aLeft = aDir.Crossed (Up());
+
+ // recompute up as: up = left x direction
+ SetUp (aLeft.Crossed (aDir));
+}
+
+// =======================================================================
+// function : BeginUpdate
+// purpose :
+// =======================================================================
+void Graphic3d_Camera::BeginUpdate()
+{
+ myNbUpdateLocks++;
+}
+
+// =======================================================================
+// function : EndUpdate
+// purpose :
+// =======================================================================
+void Graphic3d_Camera::EndUpdate()
+{
+ if (myNbUpdateLocks > 0)
+ myNbUpdateLocks--;
+
+ // if number of locks > 0, the updates are bypassed
+ UpdateProjection();
+ UpdateOrientation();
+}
+
+// =======================================================================
+// function : Transform
+// purpose :
+// =======================================================================
+void Graphic3d_Camera::Transform (const gp_Trsf& theTrsf)
+{
+ myUp.Transform (theTrsf);
+ myEye.Transform (theTrsf);
+ myCenter.Transform (theTrsf);
+ UpdateOrientation();
+}
+
+// =======================================================================
+// function : safePointCast
+// purpose :
+// =======================================================================
+static Graphic3d_Vec4 safePointCast (const gp_Pnt& thePnt)
+{
+ Standard_Real aLim = 1e15f;
+
+ // have to deal with values greater then max float
+ gp_Pnt aSafePoint = thePnt;
+ const Standard_Real aBigFloat = aLim * 0.1f;
+ if (Abs (aSafePoint.X()) > aLim)
+ aSafePoint.SetX (aSafePoint.X() >= 0 ? aBigFloat : -aBigFloat);
+ if (Abs (aSafePoint.Y()) > aLim)
+ aSafePoint.SetY (aSafePoint.Y() >= 0 ? aBigFloat : -aBigFloat);
+ if (Abs (aSafePoint.Z()) > aLim)
+ aSafePoint.SetZ (aSafePoint.Z() >= 0 ? aBigFloat : -aBigFloat);
+
+ // convert point
+ Graphic3d_Vec4 aPnt (static_cast<Standard_ShortReal> (aSafePoint.X()),
+ static_cast<Standard_ShortReal> (aSafePoint.Y()),
+ static_cast<Standard_ShortReal> (aSafePoint.Z()), 1.0f);
+
+ return aPnt;
+}
+
+// =======================================================================
+// function : Project
+// purpose :
+// =======================================================================
+gp_Pnt Graphic3d_Camera::Project (const gp_Pnt& thePnt) const
+{
+ const Graphic3d_Mat4& aViewMx = OrientationMatrix();
+ const Graphic3d_Mat4& aProjMx = ProjectionMatrix();
+
+ // use compatible type of point
+ Graphic3d_Vec4 aPnt = safePointCast (thePnt);
+
+ aPnt = aViewMx * aPnt; // convert to view coordinate space
+ aPnt = aProjMx * aPnt; // convert to projection coordinate space
+
+ const Standard_Real aInvW = 1.0 / Standard_Real (aPnt.w());
+
+ return gp_Pnt (aPnt.x() * aInvW, aPnt.y() * aInvW, aPnt.z() * aInvW);
+}
+
+// =======================================================================
+// function : UnProject
+// purpose :
+// =======================================================================
+gp_Pnt Graphic3d_Camera::UnProject (const gp_Pnt& thePnt) const
+{
+ const Graphic3d_Mat4& aViewMx = OrientationMatrix();
+ const Graphic3d_Mat4& aProjMx = ProjectionMatrix();
+
+ Graphic3d_Mat4 aInvView;
+ Graphic3d_Mat4 aInvProj;
+
+ // this case should never happen
+ if (!aViewMx.Inverted (aInvView) || !aProjMx.Inverted (aInvProj))
+ {
+ return gp_Pnt (0.0, 0.0, 0.0);
+ }
+
+ // use compatible type of point
+ Graphic3d_Vec4 aPnt = safePointCast (thePnt);
+
+ aPnt = aInvProj * aPnt; // convert to view coordinate space
+ aPnt = aInvView * aPnt; // convert to world coordinate space
+
+ const Standard_Real aInvW = 1.0 / Standard_Real (aPnt.w());
+
+ return gp_Pnt (aPnt.x() * aInvW, aPnt.y() * aInvW, aPnt.z() * aInvW);
+}
+
+// =======================================================================
+// function : ConvertView2Proj
+// purpose :
+// =======================================================================
+gp_Pnt Graphic3d_Camera::ConvertView2Proj (const gp_Pnt& thePnt) const
+{
+ const Graphic3d_Mat4& aProjMx = ProjectionMatrix();
+
+ // use compatible type of point
+ Graphic3d_Vec4 aPnt = safePointCast (thePnt);
+
+ aPnt = aProjMx * aPnt; // convert to projection coordinate space
+
+ const Standard_Real aInvW = 1.0 / Standard_Real (aPnt.w());
+
+ return gp_Pnt (aPnt.x() * aInvW, aPnt.y() * aInvW, aPnt.z() * aInvW);
+}
+
+// =======================================================================
+// function : ConvertProj2View
+// purpose :
+// =======================================================================
+gp_Pnt Graphic3d_Camera::ConvertProj2View (const gp_Pnt& thePnt) const
+{
+ const Graphic3d_Mat4& aProjMx = ProjectionMatrix();
+
+ Graphic3d_Mat4 aInvProj;
+
+ // this case should never happen, but...
+ if (!aProjMx.Inverted (aInvProj))
+ {
+ return gp_Pnt(0, 0, 0);
+ }
+
+ // use compatible type of point
+ Graphic3d_Vec4 aPnt = safePointCast (thePnt);
+
+ aPnt = aInvProj * aPnt; // convert to view coordinate space
+
+ const Standard_Real aInvW = 1.0 / Standard_Real (aPnt.w());
+
+ return gp_Pnt (aPnt.x() * aInvW, aPnt.y() * aInvW, aPnt.z() * aInvW);
+}
+
+// =======================================================================
+// function : ConvertWorld2View
+// purpose :
+// =======================================================================
+gp_Pnt Graphic3d_Camera::ConvertWorld2View (const gp_Pnt& thePnt) const
+{
+ const Graphic3d_Mat4& aViewMx = OrientationMatrix();
+
+ // use compatible type of point
+ Graphic3d_Vec4 aPnt = safePointCast (thePnt);
+
+ aPnt = aViewMx * aPnt; // convert to view coordinate space
+
+ const Standard_Real aInvW = 1.0 / Standard_Real (aPnt.w());
+
+ return gp_Pnt (aPnt.x() * aInvW, aPnt.y() * aInvW, aPnt.z() * aInvW);
+}
+
+// =======================================================================
+// function : ConvertView2World
+// purpose :
+// =======================================================================
+gp_Pnt Graphic3d_Camera::ConvertView2World (const gp_Pnt& thePnt) const
+{
+ const Graphic3d_Mat4& aViewMx = OrientationMatrix();
+
+ Graphic3d_Mat4 aInvView;
+
+ if (!aViewMx.Inverted (aInvView))
+ {
+ return gp_Pnt(0, 0, 0);
+ }
+
+ // use compatible type of point
+ Graphic3d_Vec4 aPnt = safePointCast (thePnt);
+
+ aPnt = aInvView * aPnt; // convert to world coordinate space
+
+ const Standard_Real aInvW = 1.0 / Standard_Real (aPnt.w());
+
+ return gp_Pnt (aPnt.x() * aInvW, aPnt.y() * aInvW, aPnt.z() * aInvW);
+}
+
+// =======================================================================
+// function : ViewDimensions
+// purpose :
+// =======================================================================
+gp_Pnt Graphic3d_Camera::ViewDimensions () const
+{
+ // view plane dimensions
+ Standard_Real aSizeY = IsOrthographic() ? myScale : (2.0 * Distance() * Tan (DTR_HALF * myFOVy));
+ Standard_Real aSizeX = myAspect * aSizeY;
+
+ // and frustum depth
+ return gp_Pnt (aSizeX, aSizeY, myZFar - myZNear);
+}
+
+// =======================================================================
+// function : WindowLimit
+// purpose :
+// =======================================================================
+void Graphic3d_Camera::WindowLimit (Standard_Real& theUMin,
+ Standard_Real& theVMin,
+ Standard_Real& theUMax,
+ Standard_Real& theVMax) const
+{
+ gp_Pnt aViewDims = ViewDimensions();
+ gp_Pnt aShift = ProjectionShift();
+ theUMin = -aViewDims.X() * 0.5 - aShift.X();
+ theVMin = -aViewDims.Y() * 0.5 - aShift.Y();
+ theUMax = aViewDims.X() * 0.5 - aShift.X();
+ theVMax = aViewDims.Y() * 0.5 - aShift.Y();
+}
+
+// =======================================================================
+// function : UpdateProjection
+// purpose :
+// =======================================================================
+void Graphic3d_Camera::UpdateProjection()
+{
+ if (myNbUpdateLocks > 0)
+ {
+ return;
+ }
+
+ myProjectionState = (Standard_Size)Standard_Atomic_Increment (&THE_STATE_COUNTER);
+
+ // sets top of frustum based on FOVy and near clipping plane
+ Standard_Real aDYHalf;
+ if (IsOrthographic())
+ {
+ aDYHalf = myScale * 0.5;
+ }
+ else
+ {
+ aDYHalf = myZNear * Tan (DTR_HALF * myFOVy);
+ }
+
+ // sets right of frustum based on aspect ratio
+ Standard_Real aDXHalf = myAspect * aDYHalf;
+
+ Standard_ShortReal aLeft = (Standard_ShortReal) -aDXHalf;
+ Standard_ShortReal aRight = (Standard_ShortReal) aDXHalf;
+ Standard_ShortReal aBot = (Standard_ShortReal) -aDYHalf;
+ Standard_ShortReal aTop = (Standard_ShortReal) aDYHalf;
+ Standard_ShortReal aNear = (Standard_ShortReal) myZNear;
+ Standard_ShortReal aFar = (Standard_ShortReal) myZFar;
+ Standard_ShortReal aShiftX = (Standard_ShortReal) myProjectionShift.X();
+ Standard_ShortReal aShiftY = (Standard_ShortReal) myProjectionShift.Y();
+
+ Standard_ShortReal aIOD = (myIODType == IODType_Relative)
+ ? (Standard_ShortReal)(myIOD * Distance())
+ : (Standard_ShortReal)(myIOD);
+
+ Standard_ShortReal aFocus = (myZFocusType == FocusType_Relative)
+ ? (Standard_ShortReal)(myZFocus * Distance())
+ : (Standard_ShortReal)(myZFocus);
+
+ switch (myProjType)
+ {
+ case Projection_Orthographic :
+ OrthoProj (aLeft, aRight, aBot, aTop, aNear, aFar, aShiftX, aShiftY, myMProjection);
+ break;
+
+ case Projection_Perspective :
+ PerspectiveProj (aLeft, aRight, aBot, aTop, aNear, aFar, aShiftX, aShiftY, myMProjection);
+ break;
+
+ case Projection_MonoLeftEye :
+ {
+ StereoEyeProj (aLeft, aRight, aBot, aTop, aNear,
+ aFar, aIOD, aFocus, aShiftX, aShiftY,
+ Standard_True, myMProjection);
+ break;
+ }
+
+ case Projection_MonoRightEye :
+ {
+ StereoEyeProj (aLeft, aRight, aBot, aTop, aNear,
+ aFar, aIOD, aFocus, aShiftX, aShiftY,
+ Standard_False, myMProjection);
+ break;
+ }
+
+ case Projection_Stereo :
+ {
+ PerspectiveProj (aLeft, aRight, aBot, aTop, aNear, aFar, aShiftX, aShiftY, myMProjection);
+
+ StereoEyeProj (aLeft, aRight, aBot, aTop, aNear,
+ aFar, aIOD, aFocus, aShiftX, aShiftY,
+ Standard_True, myLProjection);
+
+ StereoEyeProj (aLeft, aRight, aBot, aTop, aNear,
+ aFar, aIOD, aFocus, aShiftX, aShiftY,
+ Standard_False, myRProjection);
+ break;
+ }
+ }
+}
+
+// =======================================================================
+// function : UpdateOrientation
+// purpose :
+// =======================================================================
+void Graphic3d_Camera::UpdateOrientation()
+{
+ if (myNbUpdateLocks > 0)
+ {
+ return;
+ }
+
+ myOrientationState = (Standard_Size)Standard_Atomic_Increment (&THE_STATE_COUNTER);
+
+ Graphic3d_Vec3 anEye ((Standard_ShortReal) myEye.X(),
+ (Standard_ShortReal) myEye.Y(),
+ (Standard_ShortReal) myEye.Z());
+
+ Graphic3d_Vec3 aCenter ((Standard_ShortReal) myCenter.X(),
+ (Standard_ShortReal) myCenter.Y(),
+ (Standard_ShortReal) myCenter.Z());
+
+ Graphic3d_Vec3 anUp ((Standard_ShortReal) myUp.X(),
+ (Standard_ShortReal) myUp.Y(),
+ (Standard_ShortReal) myUp.Z());
+
+ Graphic3d_Vec3 anAxialScale ((Standard_ShortReal) myAxialScale.X(),
+ (Standard_ShortReal) myAxialScale.Y(),
+ (Standard_ShortReal) myAxialScale.Z());
+
+ LookOrientation (anEye, aCenter, anUp, anAxialScale, myOrientation);
+
+ // Update orthogonalized Up vector
+ myUp = gp_Dir (anUp.x(), anUp.y(), anUp.z());
+}
+
+// =======================================================================
+// function : OrthoProj
+// purpose :
+// =======================================================================
+void Graphic3d_Camera::OrthoProj (const Standard_ShortReal theLeft,
+ const Standard_ShortReal theRight,
+ const Standard_ShortReal theBottom,
+ const Standard_ShortReal theTop,
+ const Standard_ShortReal theNear,
+ const Standard_ShortReal theFar,
+ const Standard_ShortReal theShiftX,
+ const Standard_ShortReal theShiftY,
+ Graphic3d_Mat4& theOutMx)
+{
+ // row 0
+ theOutMx.ChangeValue (0, 0) = 2.0f / (theRight - theLeft);
+ theOutMx.ChangeValue (0, 1) = 0.0f;
+ theOutMx.ChangeValue (0, 2) = 0.0f;
+ theOutMx.ChangeValue (0, 3) = - (theRight + theLeft) / (theRight - theLeft);
+
+ // row 1
+ theOutMx.ChangeValue (1, 0) = 0.0f;
+ theOutMx.ChangeValue (1, 1) = 2.0f / (theTop - theBottom);
+ theOutMx.ChangeValue (1, 2) = 0.0f;
+ theOutMx.ChangeValue (1, 3) = - (theTop + theBottom) / (theTop - theBottom);
+
+ // row 2
+ theOutMx.ChangeValue (2, 0) = 0.0f;
+ theOutMx.ChangeValue (2, 1) = 0.0f;
+ theOutMx.ChangeValue (2, 2) = -2.0f / (theFar - theNear);
+ theOutMx.ChangeValue (2, 3) = - (theFar + theNear) / (theFar - theNear);
+
+ // row 3
+ theOutMx.ChangeValue (3, 0) = 0.0f;
+ theOutMx.ChangeValue (3, 1) = 0.0f;
+ theOutMx.ChangeValue (3, 2) = 0.0f;
+ theOutMx.ChangeValue (3, 3) = 1.0f;
+
+ Graphic3d_Mat4 aViewportShift;
+ aViewportShift.ChangeValue (0, 3) = theShiftX;
+ aViewportShift.ChangeValue (1, 3) = theShiftY;
+
+ theOutMx.Multiply (aViewportShift);
+}
+
+// =======================================================================
+// function : PerspectiveProj
+// purpose :
+// =======================================================================
+void Graphic3d_Camera::PerspectiveProj (const Standard_ShortReal theLeft,
+ const Standard_ShortReal theRight,
+ const Standard_ShortReal theBottom,
+ const Standard_ShortReal theTop,
+ const Standard_ShortReal theNear,
+ const Standard_ShortReal theFar,
+ const Standard_ShortReal theShiftX,
+ const Standard_ShortReal theShiftY,
+ Graphic3d_Mat4& theOutMx)
+{
+ // column 0
+ theOutMx.ChangeValue (0, 0) = (2.0f * theNear) / (theRight - theLeft);
+ theOutMx.ChangeValue (1, 0) = 0.0f;
+ theOutMx.ChangeValue (2, 0) = 0.0f;
+ theOutMx.ChangeValue (3, 0) = 0.0f;
+
+ // column 1
+ theOutMx.ChangeValue (0, 1) = 0.0f;
+ theOutMx.ChangeValue (1, 1) = (2.0f * theNear) / (theTop - theBottom);
+ theOutMx.ChangeValue (2, 1) = 0.0f;
+ theOutMx.ChangeValue (3, 1) = 0.0f;
+
+ // column 2
+ theOutMx.ChangeValue (0, 2) = (theRight + theLeft) / (theRight - theLeft);
+ theOutMx.ChangeValue (1, 2) = (theTop + theBottom) / (theTop - theBottom);
+ theOutMx.ChangeValue (2, 2) = -(theFar + theNear) / (theFar - theNear);
+ theOutMx.ChangeValue (3, 2) = -1.0f;
+
+ // column 3
+ theOutMx.ChangeValue (0, 3) = 0.0f;
+ theOutMx.ChangeValue (1, 3) = 0.0f;
+ theOutMx.ChangeValue (2, 3) = -(2.0f * theFar * theNear) / (theFar - theNear);
+ theOutMx.ChangeValue (3, 3) = 0.0f;
+
+ Graphic3d_Mat4 aViewportShift;
+ aViewportShift.ChangeValue (0, 3) = theShiftX;
+ aViewportShift.ChangeValue (1, 3) = theShiftY;
+
+ theOutMx.Multiply (aViewportShift);
+}
+
+// =======================================================================
+// function : StereoEyeProj
+// purpose :
+// =======================================================================
+void Graphic3d_Camera::StereoEyeProj (const Standard_ShortReal theLeft,
+ const Standard_ShortReal theRight,
+ const Standard_ShortReal theBottom,
+ const Standard_ShortReal theTop,
+ const Standard_ShortReal theNear,
+ const Standard_ShortReal theFar,
+ const Standard_ShortReal theIOD,
+ const Standard_ShortReal theZFocus,
+ const Standard_ShortReal theShiftX,
+ const Standard_ShortReal theShiftY,
+ const Standard_Boolean theIsLeft,
+ Graphic3d_Mat4& theOutMx)
+{
+ Standard_ShortReal aDx = theIsLeft ? ( 0.5f * theIOD) : (-0.5f * theIOD);
+ Standard_ShortReal aDXStereoShift = aDx * theNear / theZFocus;
+
+ // construct eye projection matrix
+ PerspectiveProj (theLeft + aDXStereoShift,
+ theRight + aDXStereoShift,
+ theBottom, theTop, theNear, theFar,
+ theShiftX, theShiftY,
+ theOutMx);
+
+ if (theIOD != 0.0f)
+ {
+ // X translation to cancel parallax
+ theOutMx.Translate (Graphic3d_Vec3 (aDx, 0.0f, 0.0f));
+ }
+}
+
+// =======================================================================
+// function : LookOrientation
+// purpose :
+// =======================================================================
+void Graphic3d_Camera::LookOrientation (const Graphic3d_Vec3& theEye,
+ const Graphic3d_Vec3& theLookAt,
+ Graphic3d_Vec3& theUpDir,
+ const Graphic3d_Vec3& theAxialScale,
+ Graphic3d_Mat4& theOutMx)
+{
+ Graphic3d_Vec3 aForward = theLookAt - theEye;
+ aForward.Normalize();
+
+ // side = forward x up
+ Graphic3d_Vec3 aSide = Graphic3d_Vec3::Cross (aForward, theUpDir);
+ aSide.Normalize();
+
+ // recompute up as: up = side x forward
+ Graphic3d_Vec3 anUp = Graphic3d_Vec3::Cross (aSide, aForward);
+ theUpDir = anUp;
+
+ Graphic3d_Mat4 aLookMx;
+ aLookMx.SetRow (0, aSide);
+ aLookMx.SetRow (1, anUp);
+ aLookMx.SetRow (2, -aForward);
+
+ theOutMx.InitIdentity();
+ theOutMx.Multiply (aLookMx);
+
+ theOutMx.Translate (-theEye);
+
+ Graphic3d_Mat4 anAxialScaleMx;
+ anAxialScaleMx.ChangeValue (0, 0) = theAxialScale.x();
+ anAxialScaleMx.ChangeValue (1, 1) = theAxialScale.y();
+ anAxialScaleMx.ChangeValue (2, 2) = theAxialScale.z();
+
+ theOutMx.Multiply (anAxialScaleMx);
+}
--- /dev/null
+// Created on: 2013-05-29
+// Created by: Anton POLETAEV
+// Copyright (c) 1999-2014 OPEN CASCADE SAS
+//
+// This file is part of Open CASCADE Technology software library.
+//
+// This library is free software; you can redistribute it and / or modify it
+// under the terms of the GNU Lesser General Public version 2.1 as published
+// by the Free Software Foundation, with special exception defined in the file
+// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
+// distribution for complete text of the license and disclaimer of any warranty.
+//
+// Alternatively, this file may be used under the terms of Open CASCADE
+// commercial license or contractual agreement.
+
+#ifndef _Graphic3d_Camera_HeaderFile
+#define _Graphic3d_Camera_HeaderFile
+
+#include <Graphic3d_Mat4.hxx>
+#include <Graphic3d_Vec3.hxx>
+
+#include <gp_Dir.hxx>
+#include <gp_Pnt.hxx>
+
+#include <Standard_Macro.hxx>
+#include <Standard_TypeDef.hxx>
+
+DEFINE_STANDARD_HANDLE (Graphic3d_Camera, Standard_Transient)
+
+//! Camera class provides object-oriented approach to setting up projection
+//! and orientation properties of 3D view.
+class Graphic3d_Camera : public Standard_Transient
+{
+
+public:
+
+ //! Enumerates supported monographic projections.
+ //! - Projection_Orthographic : orthographic projection.
+ //! - Projection_Perspective : perspective projection.
+ //! - Projection_Stere : stereographic projection.
+ //! - Projection_MonoLeftEye : mono projection for stereo left eye.
+ //! - Projection_MonoRightEye : mono projection for stereo right eye.
+ enum Projection
+ {
+ Projection_Orthographic,
+ Projection_Perspective,
+ Projection_Stereo,
+ Projection_MonoLeftEye,
+ Projection_MonoRightEye
+ };
+
+ //! Enumerates approaches to define stereographic focus.
+ //! - FocusType_Absolute : focus is specified as absolute value.
+ //! - FocusType_Relative : focus is specified relative to
+ //! (as coefficient of) camera focal length.
+ enum FocusType
+ {
+ FocusType_Absolute,
+ FocusType_Relative
+ };
+
+ //! Enumerates approaches to define Intraocular distance.
+ //! - IODType_Absolute : Intraocular distance is defined as absolute value.
+ //! - IODType_Relative : Intraocular distance is defined relative to
+ //! (as coefficient of) camera focal length.
+ enum IODType
+ {
+ IODType_Absolute,
+ IODType_Relative
+ };
+
+public:
+
+ //! Default constructor.
+ //! Initializes camera with the following properties:
+ //! Eye (0, 0, -2); Center (0, 0, 0); Up (0, 1, 0);
+ //! Type (Orthographic); FOVy (45); Scale (1000); IsStereo(false);
+ //! ZNear (0.1); ZFar (100); Aspect(1);
+ //! ZFocus(1.0); ZFocusType(Relative); IOD(0.05); IODType(Relative)
+ Standard_EXPORT Graphic3d_Camera();
+
+ //! Copy constructor.
+ //! @param theOther [in] the camera to copy from.
+ Standard_EXPORT Graphic3d_Camera (const Handle(Graphic3d_Camera)& theOther);
+
+ //! Initialize mapping related parameters from other camera handle.
+ Standard_EXPORT void CopyMappingData (const Handle(Graphic3d_Camera)& theOtherCamera);
+
+ //! Initialize orientation related parameters from other camera handle.
+ Standard_EXPORT void CopyOrientationData (const Handle(Graphic3d_Camera)& theOtherCamera);
+
+ //! Copy properties of another camera.
+ //! @param theOther [in] the camera to copy from.
+ Standard_EXPORT void Copy (const Handle(Graphic3d_Camera)& theOther);
+
+ //! Returns modification state of camera projection matrix
+ Standard_Size ProjectionState() const
+ {
+ return myProjectionState;
+ }
+
+ //! Returns modification state of camera model-view matrix
+ Standard_Size ModelViewState() const
+ {
+ return myOrientationState;
+ }
+
+ //! Sets camera Eye position.
+ //! @param theEye [in] the location of camera's Eye.
+ Standard_EXPORT void SetEye (const gp_Pnt& theEye);
+
+ //! Get camera Eye position.
+ //! @return camera eye location.
+ const gp_Pnt& Eye() const
+ {
+ return myEye;
+ }
+
+ //! Sets Center of the camera.
+ //! @param theCenter [in] the point where the camera looks at.
+ Standard_EXPORT void SetCenter (const gp_Pnt& theCenter);
+
+ //! Get Center of the camera.
+ //! @return the point where the camera looks at.
+ const gp_Pnt& Center() const
+ {
+ return myCenter;
+ }
+
+ //! Sets camera Up direction vector.
+ //! @param theUp [in] the Up direction vector.
+ Standard_EXPORT void SetUp (const gp_Dir& theUp);
+
+ //! Get camera Up direction vector.
+ //! @return Camera's Up direction vector.
+ const gp_Dir& Up() const
+ {
+ return myUp;
+ }
+
+ //! Set camera projection shift vector.<br>
+ //! Used for compatibility with older view mechanics. Applied after
+ //! view transform and before projection step (P * Shift * V).
+ //! @param theProjShift [in] the projection shift vector.
+ Standard_EXPORT void SetProjectionShift (const gp_Pnt& theProjShift);
+
+ //! Get camera projection shift vector.
+ //! @return Camera's projection shift vector.
+ const gp_Pnt& ProjectionShift() const
+ {
+ return myProjectionShift;
+ }
+
+ //! Set camera axial scale.<br>
+ //! @param theAxialScale [in] the axial scale vector.
+ Standard_EXPORT void SetAxialScale (const gp_Pnt& theAxialScale);
+
+ //! Get camera axial scale.
+ //! @return Camera's axial scale.
+ const gp_Pnt& AxialScale() const
+ {
+ return myAxialScale;
+ }
+
+ //! Set distance of Eye from camera Center.
+ //! @param theDistance [in] the distance.
+ Standard_EXPORT void SetDistance (const Standard_Real theDistance);
+
+ //! Get distance of Eye from camera Center.
+ //! @return the distance.
+ Standard_EXPORT Standard_Real Distance() const;
+
+ //! Sets camera look direction.
+ //! @param theDir [in] the direction.
+ Standard_EXPORT void SetDirection (const gp_Dir& theDir);
+
+ //! Get camera look direction.
+ //! @return camera look direction.
+ Standard_EXPORT gp_Dir Direction() const;
+
+ //! Sets camera scale. For orthographic projection the scale factor
+ //! corresponds to parallel scale of view mapping (i.e. size
+ //! of viewport). For perspective camera scale is converted to
+ //! distance.
+ //! @param theScale [in] the scale factor.
+ Standard_EXPORT void SetScale (const Standard_Real theScale);
+
+ //! Get camera scale.
+ //! @return camera scale factor.
+ Standard_EXPORT Standard_Real Scale() const;
+
+ //! Change camera projection type.
+ //! While switching between perspective and ortho projection types
+ //! ZNear and ZFar value conversion is performed due to different
+ //! coordinate systems (made for compatibility, to be improved..)
+ //! @param theProjectionType [in] the camera projection type.
+ Standard_EXPORT void SetProjectionType (const Projection theProjection);
+
+ //! @return camera projection type.
+ Projection ProjectionType() const
+ {
+ return myProjType;
+ }
+
+ //! Check that the camera projection is orthographic.
+ //! @return boolean flag that indicates whether the camera's projection is
+ //! orthographic or not.
+ Standard_Boolean IsOrthographic() const
+ {
+ return (myProjType == Projection_Orthographic);
+ }
+
+ //! Check whether the camera projection is stereo.
+ //! Please note that stereo rendering is now implemented with support of
+ //! Quad buffering.
+ //! @return boolean flag indicating whether the stereographic L/R projection
+ //! is chosen.
+ Standard_Boolean IsStereo() const
+ {
+ return (myProjType == Projection_Stereo);
+ }
+
+ //! Set Field Of View (FOV) in y axis for perspective projection.
+ //! @param theFOVy [in] the FOV in degrees.
+ Standard_EXPORT void SetFOVy (const Standard_Real theFOVy);
+
+ //! Get Field Of View (FOV) in y axis.
+ //! @return the FOV value in degrees.
+ Standard_Real FOVy() const
+ {
+ return myFOVy;
+ }
+
+ //! Change the Near Z-clipping plane position.
+ //! @param theZNear [in] the distance of the plane from the Eye.
+ Standard_EXPORT void SetZNear (const Standard_Real theZNear);
+
+ //! Get the Near Z-clipping plane position.
+ //! @return the distance of the plane from the Eye.
+ Standard_Real ZNear() const
+ {
+ return myZNear;
+ }
+
+ //! Change the Far Z-clipping plane position.
+ //! @param theZFar [in] the distance of the plane from the Eye.
+ Standard_EXPORT void SetZFar (const Standard_Real theZFar);
+
+ //! Get the Far Z-clipping plane position.
+ //! @return the distance of the plane from the Eye.
+ Standard_Real ZFar() const
+ {
+ return myZFar;
+ }
+
+ //! Change display ratio.
+ //! @param theAspect [in] the display ratio.
+ Standard_EXPORT void SetAspect (const Standard_Real theAspect);
+
+ //! Get camera display ratio.
+ //! @return display ratio.
+ Standard_Real Aspect() const
+ {
+ return myAspect;
+ }
+
+ //! Sets stereographic focus distance.
+ //! @param theType [in] the focus definition type. Focus can be defined
+ //! as absolute value or relatively to (as coefficient of) coefficient of
+ //! camera focal length.
+ //! @param theZFocus [in] the focus absolute value or coefficient depending
+ //! on the passed definition type.
+ Standard_EXPORT void SetZFocus (const FocusType theType, const Standard_Real theZFocus);
+
+ //! Get stereographic focus value.
+ //! @return absolute or relative stereographic focus value
+ //! depending on its definition type.
+ Standard_Real ZFocus() const
+ {
+ return myZFocus;
+ }
+
+ //! Get stereographic focus definition type.
+ //! @return definition type used for stereographic focus.
+ FocusType ZFocusType() const
+ {
+ return myZFocusType;
+ }
+
+ //! Sets Intraocular distance.
+ //! @param theType [in] the IOD definition type. IOD can be defined as
+ //! absolute value or relatively to (as coefficient of) camera focal length.
+ //! @param theIOD [in] the Intraocular distance.
+ Standard_EXPORT void SetIOD (const IODType theType, const Standard_Real theIOD);
+
+ //! Get Intraocular distance value.
+ //! @return absolute or relative IOD value depending on its definition type.
+ Standard_Real IOD() const
+ {
+ return myIOD;
+ }
+
+ //! Get Intraocular distance definition type.
+ //! @return definition type used for Intraocular distance.
+ IODType GetIODType() const
+ {
+ return myIODType;
+ }
+
+ //! Get orientation matrix.
+ //! @return camera orientation matrix.
+ const Graphic3d_Mat4& OrientationMatrix() const
+ {
+ return myOrientation;
+ }
+
+ //! Get monographic or middle point projection matrix used for monographic
+ //! rendering and for point projection / unprojection.
+ //! @return monographic projection matrix.
+ const Graphic3d_Mat4& ProjectionMatrix() const
+ {
+ return myMProjection;
+ }
+
+ //! @return stereographic matrix computed for left eye. Please note
+ //! that this method is used for rendering for <i>Projection_Stereo</i>.
+ const Graphic3d_Mat4& ProjectionStereoLeft() const
+ {
+ return myLProjection;
+ }
+
+ //! @return stereographic matrix computed for right eye. Please note
+ //! that this method is used for rendering for <i>Projection_Stereo</i>.
+ const Graphic3d_Mat4& ProjectionStereoRight() const
+ {
+ return myRProjection;
+ }
+
+public:
+
+ //! Orthogonalize up direction vector.
+ Standard_EXPORT void OrthogonalizeUp();
+
+ //! Suspend internal data recalculation when changing set of camera
+ //! properties. This method is optional and can be used for pieces
+ //! of code which are critical to performance. Note that the method
+ //! supports stacked calls (carried out by internal counter).
+ Standard_EXPORT void BeginUpdate();
+
+ //! Unset lock set by <i>BeginUpdate</i> and invoke data recalculation when
+ //! there are no more locks left. This method is optional and can be used
+ //! for pieces of code which are critical to performance.
+ Standard_EXPORT void EndUpdate();
+
+ // Basic camera operations
+public:
+
+ //! Transform orientation components of the camera:
+ //! Eye, Up and Center points.
+ //! @param theTrsf [in] the transformation to apply.
+ Standard_EXPORT void Transform (const gp_Trsf& theTrsf);
+
+ //! Calculate view plane size at center (target) point
+ //! and distance between ZFar and ZNear planes.
+ //! @return values in form of gp_Pnt (Width, Height, Depth).
+ Standard_EXPORT gp_Pnt ViewDimensions () const;
+
+ //! Calculate view plane dimensions with projection shift applied.
+ //! Analog to old ViewMapping.WindowLimit() function.
+ //! @param theUMin [out] the u component of min corner of the rect.
+ //! @param theVMin [out] the v component of min corner of the rect.
+ //! @param theUMax [out] the u component of max corner of the rect.
+ //! @param theVMax [out] the v component of max corner of the rect.
+ Standard_EXPORT void WindowLimit (Standard_Real& theUMin,
+ Standard_Real& theVMin,
+ Standard_Real& theUMax,
+ Standard_Real& theVMax) const;
+
+ // Projection methods
+public:
+
+ //! Project point from world coordinate space to
+ //! normalized device coordinates (mapping).
+ //! @param thePnt [in] the 3D point in WCS.
+ //! @return mapped point in NDC.
+ Standard_EXPORT gp_Pnt Project (const gp_Pnt& thePnt) const;
+
+ //! Unproject point from normalized device coordinates
+ //! to world coordinate space.
+ //! @param thePnt [in] the NDC point.
+ //! @return 3D point in WCS.
+ Standard_EXPORT gp_Pnt UnProject (const gp_Pnt& thePnt) const;
+
+ //! Convert point from view coordinate space to
+ //! projection coordinate space.
+ //! @param thePnt [in] the point in VCS.
+ //! @return point in NDC.
+ Standard_EXPORT gp_Pnt ConvertView2Proj (const gp_Pnt& thePnt) const;
+
+ //! Convert point from projection coordinate space
+ //! to view coordinate space.
+ //! @param thePnt [in] the point in NDC.
+ //! @return point in VCS.
+ Standard_EXPORT gp_Pnt ConvertProj2View (const gp_Pnt& thePnt) const;
+
+ //! Convert point from world coordinate space to
+ //! view coordinate space.
+ //! @param thePnt [in] the 3D point in WCS.
+ //! @return point in VCS.
+ Standard_EXPORT gp_Pnt ConvertWorld2View (const gp_Pnt& thePnt) const;
+
+ //! Convert point from view coordinate space to
+ //! world coordinates.
+ //! @param thePnt [in] the 3D point in VCS.
+ //! @return point in WCS.
+ Standard_EXPORT gp_Pnt ConvertView2World (const gp_Pnt& thePnt) const;
+
+ // managing projection and orientation cache:
+public:
+
+ //! Compute and cache projection matrices.
+ void UpdateProjection();
+
+ //! Compute and cache orientation matrix.
+ void UpdateOrientation();
+
+private:
+
+ //! Compose orthographic projection matrix for
+ //! the passed camera volume mapping.
+ //! @param theLeft [in] the left mapping (clipping) coordinate.
+ //! @param theRight [in] the right mapping (clipping) coordinate.
+ //! @param theBottom [in] the bottom mapping (clipping) coordinate.
+ //! @param theTop [in] the top mapping (clipping) coordinate.
+ //! @param theNear [in] the near mapping (clipping) coordinate.
+ //! @param theFar [in] the far mapping (clipping) coordinate.
+ //! @param theShiftX [in] the shift x coordinate.
+ //! @param theShiftY [in] the shift y coordinate.
+ //! @param theOutMx [out] the projection matrix.
+ static void
+ OrthoProj (const Standard_ShortReal theLeft,
+ const Standard_ShortReal theRight,
+ const Standard_ShortReal theBottom,
+ const Standard_ShortReal theTop,
+ const Standard_ShortReal theNear,
+ const Standard_ShortReal theFar,
+ const Standard_ShortReal theShiftX,
+ const Standard_ShortReal theShiftY,
+ Graphic3d_Mat4& theOutMx);
+
+ //! Compose perspective projection matrix for
+ //! the passed camera volume mapping.
+ //! @param theLeft [in] the left mapping (clipping) coordinate.
+ //! @param theRight [in] the right mapping (clipping) coordinate.
+ //! @param theBottom [in] the bottom mapping (clipping) coordinate.
+ //! @param theTop [in] the top mapping (clipping) coordinate.
+ //! @param theNear [in] the near mapping (clipping) coordinate.
+ //! @param theFar [in] the far mapping (clipping) coordinate.
+ //! @param theShiftX [in] the shift x coordinate.
+ //! @param theShiftY [in] the shift y coordinate.
+ //! @param theOutMx [out] the projection matrix.
+ static void
+ PerspectiveProj (const Standard_ShortReal theLeft,
+ const Standard_ShortReal theRight,
+ const Standard_ShortReal theBottom,
+ const Standard_ShortReal theTop,
+ const Standard_ShortReal theNear,
+ const Standard_ShortReal theFar,
+ const Standard_ShortReal theShiftX,
+ const Standard_ShortReal theShiftY,
+ Graphic3d_Mat4& theOutMx);
+
+ //! Compose projection matrix for L/R stereo eyes.
+ //! @param theLeft [in] the left mapping (clipping) coordinate.
+ //! @param theRight [in] the right mapping (clipping) coordinate.
+ //! @param theBottom [in] the bottom mapping (clipping) coordinate.
+ //! @param theTop [in] the top mapping (clipping) coordinate.
+ //! @param theNear [in] the near mapping (clipping) coordinate.
+ //! @param theFar [in] the far mapping (clipping) coordinate.
+ //! @param theIOD [in] the Intraocular distance.
+ //! @param theZFocus [in] the z coordinate of off-axis
+ //! projection plane with zero parallax.
+ //! @param theShiftX [in] the shift x coordinate.
+ //! @param theShiftY [in] the shift y coordinate.
+ //! @param theIsLeft [in] boolean flag to choose between L/R eyes.
+ //! @param theOutMx [out] the projection matrix.
+ static void
+ StereoEyeProj (const Standard_ShortReal theLeft,
+ const Standard_ShortReal theRight,
+ const Standard_ShortReal theBottom,
+ const Standard_ShortReal theTop,
+ const Standard_ShortReal theNear,
+ const Standard_ShortReal theFar,
+ const Standard_ShortReal theIOD,
+ const Standard_ShortReal theZFocus,
+ const Standard_ShortReal theShiftX,
+ const Standard_ShortReal theShiftY,
+ const Standard_Boolean theIsLeft,
+ Graphic3d_Mat4& theOutMx);
+
+ //! Construct "look at" orientation transformation.
+ //! Reference point differs for perspective and ortho modes
+ //! (made for compatibility, to be improved..).
+ //! @param theEye [in] the eye coordinates in 3D space.
+ //! @param theLookAt [in] the point the camera looks at.
+ //! @param theUpDir [in] the up direction vector.
+ //! @param theAxialScale [in] the axial scale vector.
+ //! @param theOutMx [in/out] the orientation matrix.
+ static void
+ LookOrientation (const Graphic3d_Vec3& theEye,
+ const Graphic3d_Vec3& theLookAt,
+ Graphic3d_Vec3& theUpDir,
+ const Graphic3d_Vec3& theAxialScale,
+ Graphic3d_Mat4& theOutMx);
+
+private:
+
+ gp_Dir myUp; //!< Camera up direction vector.
+ gp_Pnt myEye; //!< Camera eye position.
+ gp_Pnt myCenter; //!< Camera center.
+
+ gp_Pnt myProjectionShift; //!< Camera projection shift for compatibility.
+ gp_Pnt myAxialScale; //!< Camera axial scale.
+
+ Projection myProjType; //!< Projection type used for rendering.
+ Standard_Real myFOVy; //!< Field Of View in y axis.
+ Standard_Real myZNear; //!< Distance to near clipping plane.
+ Standard_Real myZFar; //!< Distance to far clipping plane.
+ Standard_Real myAspect; //!< Width to height display ratio.
+
+ Standard_Real myScale; //!< Specifies parallel scale for orthographic projection.
+ Standard_Real myZFocus; //!< Stereographic focus value.
+ FocusType myZFocusType; //!< Stereographic focus definition type.
+
+ Standard_Real myIOD; //!< Intraocular distance value.
+ IODType myIODType; //!< Intraocular distance definition type.
+
+ //! Number of locks set up on internal data recalculation by
+ //! <i>(BeginUpdate, EndUpdate)</i> pairs. The counter provides effective
+ //! use of the mentioned methods when camera properties are modified
+ //! in stacked functions.
+ Standard_Integer myNbUpdateLocks;
+
+ Graphic3d_Mat4 myOrientation; //!< Camera orientation matrix.
+ Graphic3d_Mat4 myMProjection; //!< Monographic projection matrix.
+ Graphic3d_Mat4 myLProjection; //!< Projection matrix for left eye.
+ Graphic3d_Mat4 myRProjection; //!< Projection matrix for right eye.
+
+ Standard_Size myProjectionState;
+ Standard_Size myOrientationState;
+
+public:
+
+ DEFINE_STANDARD_RTTI(Graphic3d_Camera);
+
+};
+
+#endif
--- /dev/null
+// Created on: 2013-05-31
+// Created by: Anton POLETAEV
+// Copyright (c) 1999-2014 OPEN CASCADE SAS
+//
+// This file is part of Open CASCADE Technology software library.
+//
+// This library is free software; you can redistribute it and / or modify it
+// under the terms of the GNU Lesser General Public version 2.1 as published
+// by the Free Software Foundation, with special exception defined in the file
+// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
+// distribution for complete text of the license and disclaimer of any warranty.
+//
+// Alternatively, this file may be used under the terms of Open CASCADE
+// commercial license or contractual agreement.
+
+#ifndef _Graphic3d_Camera_Handle_H__
+#define _Graphic3d_Camera_Handle_H__
+
+#include <Graphic3d_Camera.hxx>
+typedef Handle(Graphic3d_Camera) Graphic3d_Camera_Handle;
+
+#endif
is deferred;
---Purpose: call_togl_inquirelight
- InquireMat ( me : mutable;
- ACView : CView from Graphic3d;
- AMatO : out Array2OfReal from TColStd;
- AMatM : out Array2OfReal from TColStd )
- is deferred;
- ---Purpose: call_togl_inquiremat
-
InquirePlaneLimit ( me : mutable )
returns Integer from Standard
is deferred;
is deferred;
---Purpose: call_togl_cliplimit
- ProjectRaster ( me : mutable;
- ACView : CView from Graphic3d;
- AX : ShortReal from Standard;
- AY : ShortReal from Standard;
- AZ : ShortReal from Standard;
- AU : out Integer from Standard;
- AV : out Integer from Standard )
- returns Boolean from Standard
- is deferred;
- ---Purpose: call_togl_unproject_raster
-
- UnProjectRaster ( me : mutable;
- ACView : CView from Graphic3d;
- Axm : Integer from Standard;
- Aym : Integer from Standard;
- AXM : Integer from Standard;
- AYM : Integer from Standard;
- AU : Integer from Standard;
- AV : Integer from Standard;
- AX : out ShortReal from Standard;
- AY : out ShortReal from Standard;
- AZ : out ShortReal from Standard )
- returns Boolean from Standard
- is deferred;
- ---Purpose: call_togl_unproject_raster
-
- UnProjectRasterWithRay ( me : mutable;
- ACView : CView from Graphic3d;
- Axm : Integer from Standard;
- Aym : Integer from Standard;
- AXM : Integer from Standard;
- AYM : Integer from Standard;
- AU : Integer from Standard;
- AV : Integer from Standard;
- AX : out ShortReal from Standard;
- AY : out ShortReal from Standard;
- AZ : out ShortReal from Standard;
- DX : out ShortReal from Standard;
- DY : out ShortReal from Standard;
- DZ : out ShortReal from Standard )
- returns Boolean from Standard
- is deferred;
- ---Purpose: call_togl_unproject_raster_with_ray
-
RatioWindow ( me : mutable;
ACView : CView from Graphic3d )
is deferred;
SetClipPlanes (me : mutable; theCStructure : CStructure from Graphic3d) is deferred;
---Purpose: Pass clip planes to the associated graphic driver structure.
+ SetCamera (me : mutable; theCView : CView from Graphic3d)
+ is deferred;
+ ---Purpose: Inform graphic driver if camera assigned to view changes.
+
SetVisualisation ( me : mutable;
ACView : CView from Graphic3d )
is deferred;
is deferred;
---Purpose: call_togl_view
- ViewMapping ( me : mutable;
- ACView : CView from Graphic3d;
- AWait : Boolean from Standard )
- is deferred;
- ---Purpose: call_togl_viewmapping
-
- ViewOrientation ( me : mutable;
- ACView : CView from Graphic3d;
- AWait : Boolean from Standard )
- is deferred;
- ---Purpose: call_togl_vieworientation
-
Environment ( me : mutable;
ACView : CView from Graphic3d )
is deferred;
NCollection_Vec2.hxx
NCollection_Vec3.hxx
NCollection_Vec4.hxx
-
NCollection_Mat4.hxx
#define Handle_NIS_View_HeaderFile
#include <Standard_DefineHandle.hxx>
-#include <Handle_V3d_OrthographicView.hxx>
+#include <Handle_V3d_View.hxx>
class NIS_View;
// Definition of HANDLE object using Standard_DefineHandle.hxx
-DEFINE_STANDARD_HANDLE (NIS_View, V3d_OrthographicView)
+DEFINE_STANDARD_HANDLE (NIS_View, V3d_View)
#endif
#include <OpenGl_GlCore11.hxx>
-IMPLEMENT_STANDARD_HANDLE (NIS_View, V3d_OrthographicView)
-IMPLEMENT_STANDARD_RTTIEXT (NIS_View, V3d_OrthographicView)
+IMPLEMENT_STANDARD_HANDLE (NIS_View, V3d_View)
+IMPLEMENT_STANDARD_RTTIEXT (NIS_View, V3d_View)
//=======================================================================
//function : NIS_View()
NIS_View::NIS_View (const Handle(V3d_Viewer)& theViewer,
const Handle(Aspect_Window)& theWindow)
- : V3d_OrthographicView (theViewer),
+ : V3d_View (theViewer),
myIsTopHilight(Standard_False),
myDoHilightSelected(Standard_True)
{
Standard_Boolean NIS_View::FitAll3d (const Quantity_Coefficient theCoef)
{
Standard_Boolean aResult(Standard_False);
- /*
- Standard_Integer aLimp[4] = { 1000000, -1000000, 1000000, -1000000 };
- GetBndBox( aLimp[0], aLimp[1], aLimp[2], aLimp[3] );
- if (aLimp[1] > -1000000 && aLimp[3] > -1000000 &&
- aLimp[0] < aLimp[1] && aLimp[2] < aLimp[3])
- {
- // Scale the view
- WindowFit (aLimp[0], aLimp[2], aLimp[1], aLimp[3]);
- aResult = Standard_True;
- }
- */
Bnd_B3f aBox = GetBndBox();
// Check that the box is not empty
- if (aBox.IsVoid() == Standard_False && MyView->IsDefined() == Standard_True) {
+ if (aBox.IsVoid() == Standard_False && MyView->IsDefined() == Standard_True)
+ {
// Convert the 3D box to 2D representation in view coordinates
- Standard_Real Umin = 0.,Umax = 0.,Vmin = 0.,Vmax = 0.,U,V,W;
gp_XYZ aCoord;
const gp_XYZ aCorner[2] = { aBox.CornerMin(), aBox.CornerMax() };
- Standard_Boolean doFit = Standard_True;
- while (doFit) {
+ // Fit depth
+ const gp_XYZ& aBMin = aCorner[0];
+ const gp_XYZ& aBMax = aCorner[1];
- for (Standard_Integer i = 0; i < 8; i++) {
- if (i & 0x1) aCoord.SetX (aCorner[0].X());
- else aCoord.SetX (aCorner[1].X());
- if (i & 0x2) aCoord.SetY (aCorner[0].Y());
- else aCoord.SetY (aCorner[1].Y());
- if (i & 0x4) aCoord.SetZ (aCorner[0].Z());
- else aCoord.SetZ (aCorner[1].Z());
+ gp_Pnt anAABBCenter ((aBMin.X() + aBMax.X()) * 0.5,
+ (aBMin.Y() + aBMax.Y()) * 0.5,
+ (aBMin.Z() + aBMax.Z()) * 0.5);
- MyView->Projects(aCoord.X(), aCoord.Y(), aCoord.Z(), U, V, W);
- if (i) {
- Umin = Min(Umin, U); Umax = Max(Umax, U);
- Vmin = Min(Vmin, V); Vmax = Max(Vmax, V);
- }
- else {
- Umin = Umax = U;
- Vmin = Vmax = V;
+ gp_Vec aCenter2AABB (myCamera->Center(), anAABBCenter);
+ gp_Dir aDir = myCamera->Direction();
+
+ // distance projection onto camera direction
+ Standard_Real aDistToBox = -aCenter2AABB.Dot (aDir);
+ gp_Vec aZShift = gp_Vec (aDir).Reversed().Scaled (aDistToBox);
+
+ gp_Pnt anEyeBefore = myCamera->Eye();
+ gp_Pnt aCenterBefore = myCamera->Center();
+
+ myCamera->BeginUpdate();
+ myCamera->SetEye (myCamera->Eye().Translated (aZShift));
+ myCamera->SetCenter (myCamera->Center().Translated (aZShift));
+ myCamera->EndUpdate();
+
+ Standard_Real Umin = RealLast();
+ Standard_Real Umax = RealFirst();
+ Standard_Real Vmin = RealLast();
+ Standard_Real Vmax = RealFirst();
+ Standard_Real U, V, W;
+
+ Standard_Boolean doFit = Standard_True;
+ while (doFit)
+ {
+ for (Standard_Integer i = 0; i < 8; i++) {
+ if (i & 0x1) aCoord.SetX (aCorner[0].X());
+ else aCoord.SetX (aCorner[1].X());
+ if (i & 0x2) aCoord.SetY (aCorner[0].Y());
+ else aCoord.SetY (aCorner[1].Y());
+ if (i & 0x4) aCoord.SetZ (aCorner[0].Z());
+ else aCoord.SetZ (aCorner[1].Z());
+
+ MyView->Projects(aCoord.X(), aCoord.Y(), aCoord.Z(), U, V, W);
+ if (i) {
+ Umin = Min(Umin, U); Umax = Max(Umax, U);
+ Vmin = Min(Vmin, V); Vmax = Max(Vmax, V);
+ }
+ else {
+ Umin = Umax = U;
+ Vmin = Vmax = V;
+ }
}
- }
- if ( (Umax > Umin) && (Vmax > Vmin) ) {
- Standard_Real OldUmin,OldUmax,OldVmin,OldVmax;
- MyViewMapping.WindowLimit(OldUmin, OldVmin, OldUmax, OldVmax);
- Standard_Real DxvOld = Abs(OldUmax - OldUmin);
+ if ( (Umax > Umin) && (Vmax > Vmin) )
+ {
+ gp_Pnt ViewDims = myCamera->ViewDimensions();
+ Standard_Real DxvOld = ViewDims.X();
+
+ Standard_Real Xrp, Yrp, DxvNew, DyvNew;
- // make a margin
- Standard_Real Xrp, Yrp, DxvNew, DyvNew;
+ DxvNew = Abs(Umax - Umin); DyvNew = Abs(Vmax - Vmin);
+ DxvNew *= (1. + theCoef);
+ DyvNew *= (1. + theCoef);
- DxvNew = Abs(Umax - Umin); DyvNew = Abs(Vmax - Vmin);
- DxvNew *= (1. + theCoef);
- DyvNew *= (1. + theCoef);
+ Standard_Real aRatio = DxvNew / DxvOld;
- Standard_Real aRatio = DxvNew / DxvOld;
+ Xrp = (Umin + Umax)/2. ; Yrp = (Vmin + Vmax)/2. ;
+ Umin = Xrp - DxvNew/2. ; Umax = Xrp + DxvNew/2. ;
+ Vmin = Yrp - DyvNew/2. ; Vmax = Yrp + DyvNew/2. ;
- Xrp = (Umin + Umax)/2. ; Yrp = (Vmin + Vmax)/2. ;
- Umin = Xrp - DxvNew/2. ; Umax = Xrp + DxvNew/2. ;
- Vmin = Yrp - DyvNew/2. ; Vmax = Yrp + DyvNew/2. ;
+ // fit view
+ FitAll (Umin, Vmin, Umax, Vmax);
- // fit view
- FitAll(Umin, Vmin, Umax, Vmax);
+ // ratio 1e+6 often gives calculation error(s), reduce it
+ // if (aRatio < 1e+6) doFit = Standard_False;
+ if (aRatio < 100)
+ {
+ doFit = Standard_False;
+ }
- // ratio 1e+6 often gives calculation error(s), reduce it
- // if (aRatio < 1e+6) doFit = Standard_False;
- if (aRatio < 100) doFit = Standard_False;
- aResult = Standard_True;
+ aResult = Standard_True;
+ }
+ else
+ {
+ doFit = Standard_False;
+ }
}
- else doFit = Standard_False;
+ if (!aResult)
+ {
+ myCamera->BeginUpdate();
+ myCamera->SetCenter (aCenterBefore);
+ myCamera->SetEye (anEyeBefore);
+ myCamera->EndUpdate();
}
}
#define NIS_View_HeaderFile
#include <Handle_NIS_InteractiveObject.hxx>
-#include <V3d_OrthographicView.hxx>
+#include <V3d_View.hxx>
#include <Standard_DefineHandle.hxx>
#include <NCollection_List.hxx>
#include <NCollection_Vector.hxx>
/**
* Manager of a single window with OpenGL context, used by one or more
* NIS_InteractiveContext instances.
- * This class inherits V3d_OrthograpicView therefore its instances can be used
+ * This class inherits V3d_View therefore its instances can be used
* to display any object that is normally handled by Graphic3d/V3d/AIS classes.
* Also the standard view operations: Pan, Rotate, Zoom, mouse API, etc. are
* supported due to this inheritance.<p>
* AddContext and RemoveContext.
*/
-class NIS_View : public V3d_OrthographicView
+class NIS_View : public V3d_View
{
public:
// ---------- PUBLIC METHODS ----------
Handle_OpenGl_View.hxx
OpenGl_View.hxx
OpenGl_View.cxx
-OpenGl_View_1.cxx
OpenGl_View_2.cxx
OpenGl_Light.hxx
OpenGl_Trihedron.hxx
OpenGl_AVIWriter.hxx
OpenGl_AVIWriter.cxx
OpenGl_tsm.hxx
-OpenGl_telem_view.cxx
-OpenGl_telem_view.hxx
OpenGl_FrameBuffer.hxx
OpenGl_FrameBuffer.cxx
OpenGl_Texture.cxx
myMaxClipPlanes (6),
myGlVerMajor (0),
myGlVerMinor (0),
- myIsFeedback (Standard_False),
- myIsInitialized (Standard_False)
+ myRenderMode (GL_RENDER),
+ myIsInitialized (Standard_False),
+ myIsStereoBuffers (Standard_False),
+ myDrawBuffer (0)
{
#if defined(MAC_OS_X_VERSION_10_3) && !defined(MACOSX_USE_GLX)
// Vendors can not extend functionality on this system
return myMaxClipPlanes;
}
+// =======================================================================
+// function : SetDrawBufferLeft
+// purpose :
+// =======================================================================
+void OpenGl_Context::SetDrawBufferLeft()
+{
+ switch (myDrawBuffer)
+ {
+ case GL_BACK_RIGHT :
+ case GL_BACK :
+ glDrawBuffer (GL_BACK_LEFT);
+ myDrawBuffer = GL_BACK_LEFT;
+ break;
+
+ case GL_FRONT_RIGHT :
+ case GL_FRONT :
+ glDrawBuffer (GL_FRONT_LEFT);
+ myDrawBuffer = GL_FRONT_LEFT;
+ break;
+
+ case GL_FRONT_AND_BACK :
+ case GL_RIGHT :
+ glDrawBuffer (GL_LEFT);
+ myDrawBuffer = GL_LEFT;
+ break;
+ }
+}
+
+// =======================================================================
+// function : SetDrawBufferRight
+// purpose :
+// =======================================================================
+void OpenGl_Context::SetDrawBufferRight()
+{
+ switch (myDrawBuffer)
+ {
+ case GL_BACK_LEFT :
+ case GL_BACK :
+ glDrawBuffer (GL_BACK_RIGHT);
+ myDrawBuffer = GL_BACK_RIGHT;
+ break;
+
+ case GL_FRONT_LEFT :
+ case GL_FRONT :
+ glDrawBuffer (GL_FRONT_RIGHT);
+ myDrawBuffer = GL_FRONT_RIGHT;
+ break;
+
+ case GL_FRONT_AND_BACK :
+ case GL_LEFT :
+ glDrawBuffer (GL_RIGHT);
+ myDrawBuffer = GL_RIGHT;
+ break;
+ }
+}
+
+// =======================================================================
+// function : SetDrawBufferMono
+// purpose :
+// =======================================================================
+void OpenGl_Context::SetDrawBufferMono()
+{
+ switch (myDrawBuffer)
+ {
+ case GL_BACK_LEFT :
+ case GL_BACK_RIGHT :
+ glDrawBuffer (GL_BACK);
+ myDrawBuffer = GL_BACK;
+ break;
+
+ case GL_FRONT_LEFT :
+ case GL_FRONT_RIGHT :
+ glDrawBuffer (GL_FRONT);
+ myDrawBuffer = GL_FRONT;
+ break;
+
+ case GL_LEFT :
+ case GL_RIGHT :
+ glDrawBuffer (GL_FRONT_AND_BACK);
+ myDrawBuffer = GL_FRONT_AND_BACK;
+ break;
+ }
+}
+
+// =======================================================================
+// function : FetchState
+// purpose :
+// =======================================================================
+void OpenGl_Context::FetchState()
+{
+ // cache feedback mode state
+ glGetIntegerv (GL_RENDER_MODE, &myRenderMode);
+
+ // cache draw buffer state
+ glGetIntegerv (GL_DRAW_BUFFER, &myDrawBuffer);
+}
+
// =======================================================================
// function : Share
// purpose :
// get number of maximum clipping planes
glGetIntegerv (GL_MAX_CLIP_PLANES, &myMaxClipPlanes);
glGetIntegerv (GL_MAX_TEXTURE_SIZE, &myMaxTexDim);
+
+ GLint aStereo;
+ glGetIntegerv (GL_STEREO, &aStereo);
+ myIsStereoBuffers = aStereo == 1;
+
if (extAnis)
{
glGetIntegerv (GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT, &myAnisoMax);
core20 = myGlCore20;
}
}
-// =======================================================================
-// function : IsFeedback
-// purpose :
-// =======================================================================
-Standard_Boolean OpenGl_Context::IsFeedback() const
-{
- return myIsFeedback;
-}
-
-// =======================================================================
-// function : SetFeedback
-// purpose :
-// =======================================================================
-void OpenGl_Context::SetFeedback (const Standard_Boolean theFeedbackOn)
-{
- myIsFeedback = theFeedbackOn;
-}
// =======================================================================
// function : MemoryInfo
#include <TCollection_AsciiString.hxx>
#include <Handle_OpenGl_Context.hxx>
#include <OpenGl_Clipping.hxx>
+#include <OpenGl_GlCore11.hxx>
//! Forward declarations
struct OpenGl_GlCore12;
//! Swap front/back buffers for this GL context (should be activated before!).
Standard_EXPORT void SwapBuffers();
- //! Return true if active mode is GL_FEEDBACK (cached state)
- Standard_EXPORT Standard_Boolean IsFeedback() const;
+ //! Return true if active mode is GL_RENDER (cached state)
+ Standard_Boolean IsRender() const
+ {
+ return myRenderMode == GL_RENDER;
+ }
- //! Setup feedback mode cached state
- Standard_EXPORT void SetFeedback (const Standard_Boolean theFeedbackOn);
+ //! Return true if active mode is GL_FEEDBACK (cached state)
+ Standard_Boolean IsFeedback() const
+ {
+ return myRenderMode == GL_FEEDBACK;
+ }
//! This function retrieves information from GL about free GPU memory that is:
//! - OS-dependent. On some OS it is per-process and on others - for entire system.
const unsigned int theSeverity,
const TCollection_ExtendedString& theMessage);
+
+
+ //! @return true if OpenGl context supports left and
+ //! right rendering buffers.
+ Standard_Boolean HasStereoBuffers() const
+ {
+ return myIsStereoBuffers;
+ }
+
+ //! Switch to left stereographic rendering buffer.
+ //! This method can be used to keep unchanged choise
+ //! of front/back/both buffer rendering.
+ Standard_EXPORT void SetDrawBufferLeft();
+
+ //! Switch to right stereographic rendering buffer.
+ //! This method can be used to keep unchanged choise
+ //! of front/back/both buffer rendering.
+ Standard_EXPORT void SetDrawBufferRight();
+
+ //! Switch to non-stereographic rendering buffer.
+ //! This method can be used to keep unchanged choise
+ //! of front/back/both buffer rendering.
+ Standard_EXPORT void SetDrawBufferMono();
+
+ //! Fetch OpenGl context state. This class tracks value of several OpenGl
+ //! state variables. Consulting the cached values is quicker than
+ //! doing the same via OpenGl API. Call this method if any of the controlled
+ //! OpenGl state variables has a possibility of being out-of-date.
+ Standard_EXPORT void FetchState();
+
private:
//! Wrapper to system function to retrieve GL function pointer by name.
OpenGl_Clipping myClippingState; //!< state of clip planes
- void* myGlLibHandle; //!< optional handle to GL library
- OpenGl_GlCore20* myGlCore20; //!< common structure for GL core functions upto 2.0
- Standard_Integer myAnisoMax; //!< maximum level of anisotropy texture filter
- Standard_Integer myMaxTexDim; //!< value for GL_MAX_TEXTURE_SIZE
- Standard_Integer myMaxClipPlanes; //!< value for GL_MAX_CLIP_PLANES
- Standard_Integer myGlVerMajor; //!< cached GL version major number
- Standard_Integer myGlVerMinor; //!< cached GL version minor number
- Standard_Boolean myIsFeedback; //!< flag indicates GL_FEEDBACK mode
- Standard_Boolean myIsInitialized; //!< flag indicates initialization state
+ void* myGlLibHandle; //!< optional handle to GL library
+ OpenGl_GlCore20* myGlCore20; //!< common structure for GL core functions upto 2.0
+ Standard_Integer myAnisoMax; //!< maximum level of anisotropy texture filter
+ Standard_Integer myMaxTexDim; //!< value for GL_MAX_TEXTURE_SIZE
+ Standard_Integer myMaxClipPlanes; //!< value for GL_MAX_CLIP_PLANES
+ Standard_Integer myGlVerMajor; //!< cached GL version major number
+ Standard_Integer myGlVerMinor; //!< cached GL version minor number
+ Standard_Integer myRenderMode; //!< value for active rendering mode
+ Standard_Boolean myIsInitialized; //!< flag indicates initialization state
+ Standard_Boolean myIsStereoBuffers; //!< context supports stereo buffering
+ Standard_Integer myDrawBuffer; //!< current draw buffer.
Handle(OpenGl_ShaderManager) myShaderManager; //! support object for managing shader programs
myDBuffer(Standard_True),
myDither(Standard_True),
myBackDither(Standard_False),
- myWalkthrough(Standard_False),
mySymPerspective(Standard_False),
myOffsetFactor(1.F),
myOffsetUnits(0.F),
if (getenv("CALL_OPENGL_NO_BACKDITHER") != NULL)
myBackDither = Standard_False;
- if (getenv("CSF_WALKTHROUGH") != NULL)
- myWalkthrough = Standard_True;
-
/* OCC18942: Test if symmetric perspective projection should be turned on */
if (getenv("CSF_SYM_PERSPECTIVE") != NULL)
mySymPerspective = Standard_True;
Standard_Boolean DBuffer () const { return myDBuffer; }
Standard_Boolean Dither () const { return myDither; }
Standard_Boolean BackDither () const { return myBackDither; }
- Standard_Boolean Walkthrough () const { return myWalkthrough; }
Standard_Boolean SymPerspective() const { return mySymPerspective; }
Standard_Boolean PolygonOffset (Standard_ShortReal &AFactor, Standard_ShortReal &AUnits) const
{
Standard_Boolean myDBuffer;
Standard_Boolean myDither;
Standard_Boolean myBackDither;
- Standard_Boolean myWalkthrough;
Standard_Boolean mySymPerspective;
Standard_ShortReal myOffsetFactor;
Standard_ShortReal myOffsetUnits;
{ 0.f, 0.f, 1.f, 0.f },
{ 0.f, 0.f, 0.f, 1.f } };
- aContext->ShaderManager()->RevertModelWorldStateTo (aModelWorldState);
+ aContext->ShaderManager()->RevertModelWorldStateTo (&aModelWorldState);
}
else
{
Tmatrix3 aProjection;
glGetFloatv (GL_PROJECTION_MATRIX, *aProjection);
- aContext->ShaderManager()->UpdateWorldViewStateTo (aWorldView);
- aContext->ShaderManager()->UpdateProjectionStateTo (aProjection);
+ aContext->ShaderManager()->UpdateWorldViewStateTo (&aWorldView);
+ aContext->ShaderManager()->UpdateProjectionStateTo (&aProjection);
}
if (aCurrMode != GL_MODELVIEW)
Standard_EXPORT void End ();
Standard_EXPORT Standard_Integer InquireLightLimit ();
- Standard_EXPORT void InquireMat (const Graphic3d_CView& ACView, TColStd_Array2OfReal& AMatO, TColStd_Array2OfReal& AMatM);
Standard_EXPORT Standard_Integer InquireViewLimit ();
Standard_EXPORT void Blink (const Graphic3d_CStructure& ACStructure,const Standard_Boolean Create);
Standard_EXPORT void BoundaryBox (const Graphic3d_CStructure& ACStructure, const Standard_Boolean Create);
Standard_EXPORT void ClipLimit (const Graphic3d_CView& ACView, const Standard_Boolean AWait);
Standard_EXPORT void DeactivateView (const Graphic3d_CView& ACView);
Standard_EXPORT void DepthCueing (const Graphic3d_CView& ACView, const Standard_Boolean AFlag);
- Standard_EXPORT Standard_Boolean ProjectRaster (const Graphic3d_CView& ACView, const Standard_ShortReal AX, const Standard_ShortReal AY, const Standard_ShortReal AZ, Standard_Integer& AU, Standard_Integer& AV);
- Standard_EXPORT Standard_Boolean UnProjectRaster (const Graphic3d_CView& ACView, const Standard_Integer Axm, const Standard_Integer Aym, const Standard_Integer AXM, const Standard_Integer AYM, const Standard_Integer AU, const Standard_Integer AV, Standard_ShortReal& AX, Standard_ShortReal& AY, Standard_ShortReal& AZ);
- Standard_EXPORT Standard_Boolean UnProjectRasterWithRay (const Graphic3d_CView& ACView, const Standard_Integer Axm, const Standard_Integer Aym, const Standard_Integer AXM, const Standard_Integer AYM, const Standard_Integer AU, const Standard_Integer AV, Standard_ShortReal& AX, Standard_ShortReal& AY, Standard_ShortReal& AZ, Standard_ShortReal& DX, Standard_ShortReal& DY, Standard_ShortReal& DZ);
Standard_EXPORT void RatioWindow (const Graphic3d_CView& ACView);
Standard_EXPORT void Redraw (const Graphic3d_CView& ACView, const Aspect_CLayer2d& ACUnderLayer, const Aspect_CLayer2d& ACOverLayer, const Standard_Integer x = 0, const Standard_Integer y = 0, const Standard_Integer width = 0, const Standard_Integer height = 0);
Standard_EXPORT void RemoveView (const Graphic3d_CView& ACView);
Standard_EXPORT void SetLight (const Graphic3d_CView& ACView);
Standard_EXPORT void SetClipPlanes (const Graphic3d_CView& theCView);
Standard_EXPORT void SetClipPlanes (const Graphic3d_CStructure& theCStructure);
+ Standard_EXPORT void SetCamera (const Graphic3d_CView& theCView);
Standard_EXPORT void SetVisualisation (const Graphic3d_CView& ACView);
Standard_EXPORT void TransformStructure (const Graphic3d_CStructure& ACStructure);
Standard_EXPORT void Transparency (const Graphic3d_CView& ACView, const Standard_Boolean AFlag);
Standard_EXPORT void Update (const Graphic3d_CView& ACView, const Aspect_CLayer2d& ACUnderLayer, const Aspect_CLayer2d& ACOverLayer);
Standard_EXPORT Standard_Boolean View (Graphic3d_CView& ACView);
- Standard_EXPORT void ViewMapping (const Graphic3d_CView& ACView, const Standard_Boolean AWait);
- Standard_EXPORT void ViewOrientation (const Graphic3d_CView& ACView,const Standard_Boolean AWait);
Standard_EXPORT void Environment (const Graphic3d_CView& ACView);
Standard_EXPORT void SetStencilTestOptions (const Graphic3d_CGroup& theCGroup, const Standard_Boolean theIsEnabled);
Standard_EXPORT void Text (const Graphic3d_CGroup& ACGroup, const Standard_CString AText, const Graphic3d_Vertex& APoint, const Standard_Real AHeight, const Quantity_PlaneAngle AAngle, const Graphic3d_TextPath ATp, const Graphic3d_HorizontalTextAlignment AHta, const Graphic3d_VerticalTextAlignment AVta, const Standard_Boolean EvalMinMax = Standard_True);
return (myGlDisplay.IsNull() ? 0 : myGlDisplay->Facilities().MaxLights);
}
-void OpenGl_GraphicDriver::InquireMat (const Graphic3d_CView& ACView, TColStd_Array2OfReal& AMatO, TColStd_Array2OfReal& AMatM)
-{
- const OpenGl_CView *aCView = (const OpenGl_CView *)ACView.ptrView;
- if (aCView)
- aCView->View->GetMatrices(AMatO,AMatM,ACView.Orientation.IsCustomMatrix);
-}
-
Standard_Integer OpenGl_GraphicDriver::InquireViewLimit ()
{
return (myGlDisplay.IsNull() ? 0 : myGlDisplay->Facilities().MaxViews);
aCView->View->SetFog(ACView, AFlag);
}
-Standard_Boolean OpenGl_GraphicDriver::ProjectRaster (const Graphic3d_CView& ACView, const Standard_ShortReal AX, const Standard_ShortReal AY, const Standard_ShortReal AZ, Standard_Integer& AU, Standard_Integer& AV)
-{
- const OpenGl_CView *aCView = (const OpenGl_CView *)ACView.ptrView;
- if (!aCView)
- return Standard_False;
-
- Standard_Integer aWidth = aCView->WS->Width();
- Standard_Integer aHeight = aCView->WS->Height();
- Standard_ShortReal xr, yr;
- if (aCView->View->ProjectObjectToRaster(aWidth, aHeight, AX, AY, AZ, xr, yr))
- {
- AU = (Standard_Integer) xr;
- AV = aHeight - (Standard_Integer) yr;
- return Standard_True;
- }
-
- return Standard_False;
-}
-
-Standard_Boolean OpenGl_GraphicDriver::UnProjectRaster (const Graphic3d_CView& ACView, const Standard_Integer /*Axm*/, const Standard_Integer Aym, const Standard_Integer /*AXM*/, const Standard_Integer AYM, const Standard_Integer AU, const Standard_Integer AV, Standard_ShortReal& Ax, Standard_ShortReal& Ay, Standard_ShortReal& Az)
-{
- const OpenGl_CView *aCView = (const OpenGl_CView *)ACView.ptrView;
- if (!aCView)
- return Standard_False;
-
- const Standard_Integer aWidth = aCView->WS->Width();
- const Standard_Integer aHeight = aCView->WS->Height();
-
- /*
- Patched by P.Dolbey: the window pixel height decreased by one
- in order for yr to remain within valid coordinate range [0; Ym -1]
- where Ym means window pixel height.
- */
- return aCView->View->ProjectRasterToObject( aWidth, aHeight, AU, (AYM-1)-Aym-AV, Ax, Ay, Az );
-}
-
-Standard_Boolean OpenGl_GraphicDriver::UnProjectRasterWithRay (const Graphic3d_CView& ACView, const Standard_Integer /*Axm*/, const Standard_Integer Aym, const Standard_Integer /*AXM*/, const Standard_Integer AYM, const Standard_Integer AU, const Standard_Integer AV, Standard_ShortReal& Ax, Standard_ShortReal& Ay, Standard_ShortReal& Az, Standard_ShortReal& Dx, Standard_ShortReal& Dy, Standard_ShortReal& Dz)
-{
- const OpenGl_CView *aCView = (const OpenGl_CView *)ACView.ptrView;
- if (!aCView)
- return Standard_False;
-
- const Standard_Integer aWidth = aCView->WS->Width();
- const Standard_Integer aHeight = aCView->WS->Height();
-
- return aCView->View->ProjectRasterToObjectWithRay( aWidth, aHeight, AU, AYM-Aym-AV, Ax, Ay, Az, Dx, Dy, Dz );
-}
-
void OpenGl_GraphicDriver::RatioWindow (const Graphic3d_CView& theCView)
{
const OpenGl_CView* aCView = (const OpenGl_CView* )theCView.ptrView;
}
}
+//=======================================================================
+//function : SetCamera
+//purpose :
+//=======================================================================
+void OpenGl_GraphicDriver::SetCamera (const Graphic3d_CView& theCView)
+{
+ const OpenGl_CView *aCView = (const OpenGl_CView *)theCView.ptrView;
+ if (aCView)
+ {
+ aCView->View->SetCamera (theCView.Context.Camera);
+ }
+}
+
void OpenGl_GraphicDriver::SetVisualisation (const Graphic3d_CView& ACView)
{
const OpenGl_CView *aCView = (const OpenGl_CView *)ACView.ptrView;
return Standard_True;
}
-void OpenGl_GraphicDriver::ViewMapping (const Graphic3d_CView& ACView, const Standard_Boolean AWait)
-{
- const OpenGl_CView *aCView = (const OpenGl_CView *)ACView.ptrView;
- if (aCView)
- {
- aCView->View->SetMapping (myGlDisplay, ACView);
- if (!AWait)
- {
- aCView->WS->Resize(ACView.DefWindow);
- }
- }
-}
-
-void OpenGl_GraphicDriver::ViewOrientation (const Graphic3d_CView& ACView, const Standard_Boolean AWait)
-{
- const OpenGl_CView *aCView = (const OpenGl_CView *)ACView.ptrView;
- if (aCView)
- {
- aCView->View->SetOrientation(ACView);
- if (!AWait)
- {
- aCView->WS->Resize(ACView.DefWindow);
- }
- }
-}
-
void OpenGl_GraphicDriver::SetBackFacingModel (const Graphic3d_CView& ACView)
{
const OpenGl_CView *aCView = (const OpenGl_CView *)ACView.ptrView;
// function : SetProjectionState
// purpose : Sets new state of OCCT projection transform
// =======================================================================
-void OpenGl_ShaderManager::UpdateProjectionStateTo (const Tmatrix3& theProjectionMatrix)
+void OpenGl_ShaderManager::UpdateProjectionStateTo (const Tmatrix3* theProjectionMatrix)
{
myProjectionState.Set (theProjectionMatrix);
myProjectionState.Update();
// function : SetModelWorldState
// purpose : Sets new state of OCCT model-world transform
// =======================================================================
-void OpenGl_ShaderManager::UpdateModelWorldStateTo (const Tmatrix3& theModelWorldMatrix)
+void OpenGl_ShaderManager::UpdateModelWorldStateTo (const Tmatrix3* theModelWorldMatrix)
{
myModelWorldState.Set (theModelWorldMatrix);
myModelWorldState.Update();
// function : SetWorldViewState
// purpose : Sets new state of OCCT world-view transform
// =======================================================================
-void OpenGl_ShaderManager::UpdateWorldViewStateTo (const Tmatrix3& theWorldViewMatrix)
+void OpenGl_ShaderManager::UpdateWorldViewStateTo (const Tmatrix3* theWorldViewMatrix)
{
myWorldViewState.Set (theWorldViewMatrix);
myWorldViewState.Update();
// function : RevertProjectionStateTo
// purpose : Reverts state of OCCT projection transform
// =======================================================================
-void OpenGl_ShaderManager::RevertProjectionStateTo (const Tmatrix3& theProjectionMatrix)
+void OpenGl_ShaderManager::RevertProjectionStateTo (const Tmatrix3* theProjectionMatrix)
{
myProjectionState.Set (theProjectionMatrix);
myProjectionState.Revert();
// function : RevertModelWorldStateTo
// purpose : Reverts state of OCCT model-world transform
// =======================================================================
-void OpenGl_ShaderManager::RevertModelWorldStateTo (const Tmatrix3& theModelWorldMatrix)
+void OpenGl_ShaderManager::RevertModelWorldStateTo (const Tmatrix3* theModelWorldMatrix)
{
myModelWorldState.Set (theModelWorldMatrix);
myModelWorldState.Revert();
// function : RevertWorldViewStateTo
// purpose : Reverts state of OCCT world-view transform
// =======================================================================
-void OpenGl_ShaderManager::RevertWorldViewStateTo (const Tmatrix3& theWorldViewMatrix)
+void OpenGl_ShaderManager::RevertWorldViewStateTo (const Tmatrix3* theWorldViewMatrix)
{
myWorldViewState.Set (theWorldViewMatrix);
myWorldViewState.Revert();
Standard_EXPORT const OpenGl_ProjectionState& ProjectionState() const;
//! Updates state of OCCT projection transform.
- Standard_EXPORT void UpdateProjectionStateTo (const Tmatrix3& theProjectionMatrix);
+ Standard_EXPORT void UpdateProjectionStateTo (const Tmatrix3* theProjectionMatrix);
//! Reverts state of OCCT projection transform.
- Standard_EXPORT void RevertProjectionStateTo (const Tmatrix3& theProjectionMatrix);
+ Standard_EXPORT void RevertProjectionStateTo (const Tmatrix3* theProjectionMatrix);
//! Pushes current state of OCCT projection transform to specified program.
Standard_EXPORT void PushProjectionState (const Handle(OpenGl_ShaderProgram)& theProgram) const;
Standard_EXPORT const OpenGl_ModelWorldState& ModelWorldState() const;
//! Updates state of OCCT model-world transform.
- Standard_EXPORT void UpdateModelWorldStateTo (const Tmatrix3& theModelWorldMatrix);
+ Standard_EXPORT void UpdateModelWorldStateTo (const Tmatrix3* theModelWorldMatrix);
//! Reverts state of OCCT model-world transform.
- Standard_EXPORT void RevertModelWorldStateTo (const Tmatrix3& theModelWorldMatrix);
+ Standard_EXPORT void RevertModelWorldStateTo (const Tmatrix3* theModelWorldMatrix);
//! Pushes current state of OCCT model-world transform to specified program.
Standard_EXPORT void PushModelWorldState (const Handle(OpenGl_ShaderProgram)& theProgram) const;
Standard_EXPORT const OpenGl_WorldViewState& WorldViewState() const;
//! Updates state of OCCT world-view transform.
- Standard_EXPORT void UpdateWorldViewStateTo (const Tmatrix3& theWorldViewMatrix);
+ Standard_EXPORT void UpdateWorldViewStateTo (const Tmatrix3* theWorldViewMatrix);
//! Reverts state of OCCT world-view transform.
- Standard_EXPORT void RevertWorldViewStateTo (const Tmatrix3& theWorldViewMatrix);
+ Standard_EXPORT void RevertWorldViewStateTo (const Tmatrix3* theWorldViewMatrix);
//! Pushes current state of OCCT world-view transform to specified program.
Standard_EXPORT void PushWorldViewState (const Handle(OpenGl_ShaderProgram)& theProgram) const;
// function : Set
// purpose : Sets new OCCT projection state
// =======================================================================
-void OpenGl_ProjectionState::Set (const Tmatrix3& theProjectionMatrix)
+void OpenGl_ProjectionState::Set (const Tmatrix3* theProjectionMatrix)
{
memcpy (myProjectionMatrix, theProjectionMatrix, sizeof (Tmatrix3));
myInverseNeedUpdate = true;
// function : Set
// purpose : Sets new model-world matrix
// =======================================================================
-void OpenGl_ModelWorldState::Set (const Tmatrix3& theModelWorldMatrix)
+void OpenGl_ModelWorldState::Set (const Tmatrix3* theModelWorldMatrix)
{
memcpy (myModelWorldMatrix, theModelWorldMatrix, sizeof (Tmatrix3));
myInverseNeedUpdate = true;
// function : Set
// purpose : Sets new world-view matrix
// =======================================================================
-void OpenGl_WorldViewState::Set (const Tmatrix3& theWorldViewMatrix)
+void OpenGl_WorldViewState::Set (const Tmatrix3* theWorldViewMatrix)
{
memcpy (myWorldViewMatrix, theWorldViewMatrix, sizeof (Tmatrix3));
myInverseNeedUpdate = true;
OpenGl_ProjectionState();
//! Sets new projection matrix.
- void Set (const Tmatrix3& theProjectionMatrix);
+ void Set (const Tmatrix3* theProjectionMatrix);
//! Returns current projection matrix.
const Tmatrix3& ProjectionMatrix() const;
OpenGl_ModelWorldState();
//! Sets new model-world matrix.
- void Set (const Tmatrix3& theModelWorldMatrix);
+ void Set (const Tmatrix3* theModelWorldMatrix);
//! Returns current model-world matrix.
const Tmatrix3& ModelWorldMatrix() const;
OpenGl_WorldViewState();
//! Sets new world-view matrix.
- void Set (const Tmatrix3& theWorldViewMatrix);
+ void Set (const Tmatrix3* theWorldViewMatrix);
//! Returns current world-view matrix.
const Tmatrix3& WorldViewMatrix() const;
Tmatrix3 aProjection;
glGetFloatv (GL_PROJECTION_MATRIX, *aProjection);
- aCtx->ShaderManager()->UpdateModelWorldStateTo (aModelWorld);
- aCtx->ShaderManager()->UpdateWorldViewStateTo (aWorldView);
- aCtx->ShaderManager()->UpdateProjectionStateTo (aProjection);
+ aCtx->ShaderManager()->UpdateModelWorldStateTo (&aModelWorld);
+ aCtx->ShaderManager()->UpdateWorldViewStateTo (&aWorldView);
+ aCtx->ShaderManager()->UpdateProjectionStateTo (&aProjection);
}
glMatrixMode (GL_MODELVIEW);
{ 0.f, 0.f, 1.f, 0.f },
{ 0.f, 0.f, 0.f, 1.f } };
- aContext->ShaderManager()->RevertModelWorldStateTo (aModelWorldState);
+ aContext->ShaderManager()->RevertModelWorldStateTo (&aModelWorldState);
}
else
{
modelMatrix[3][0] = 0.;
modelMatrix[3][1] = 0.;
modelMatrix[3][2] = 0.;
- projMatrix[3][0] = 0.;
- projMatrix[3][1] = 0.;
- projMatrix[3][2] = 0.;
+
+ projMatrix[0][0] = 2.0 / U;
+ projMatrix[0][1] = 0.0;
+ projMatrix[0][2] = 0.0;
+ projMatrix[0][3] = 0.0;
+
+ projMatrix[1][0] = 0.0;
+ projMatrix[1][1] = 2.0 / V;
+ projMatrix[1][2] = 0.0;
+ projMatrix[1][3] = 0.0;
+
+ projMatrix[2][0] = 0.0;
+ projMatrix[2][1] = 0.0;
+ projMatrix[2][2] = -2.0 * 1e-7;
+ projMatrix[2][3] = 0.0;
+
+ projMatrix[3][0] = 0.0;
+ projMatrix[3][1] = 0.0;
+ projMatrix[3][2] = 0.0;
+ projMatrix[3][3] = 1.0;
/* sauvegarde du contexte des matrices avant chargement */
glMatrixMode (GL_MODELVIEW);
modelMatrix[3][0] = 0.;
modelMatrix[3][1] = 0.;
modelMatrix[3][2] = 0.;
- projMatrix[3][0] = 0.;
- projMatrix[3][1] = 0.;
- projMatrix[3][2] = 0.;
+
+ projMatrix[0][0] = 2.0 / U;
+ projMatrix[0][1] = 0.0;
+ projMatrix[0][2] = 0.0;
+ projMatrix[0][3] = 0.0;
+
+ projMatrix[1][0] = 0.0;
+ projMatrix[1][1] = 2.0 / V;
+ projMatrix[1][2] = 0.0;
+ projMatrix[1][3] = 0.0;
+
+ projMatrix[2][0] = 0.0;
+ projMatrix[2][1] = 0.0;
+ projMatrix[2][2] = -2.0 * 1e-7;
+ projMatrix[2][3] = 0.0;
+
+ projMatrix[3][0] = 0.0;
+ projMatrix[3][1] = 0.0;
+ projMatrix[3][2] = 0.0;
+ projMatrix[3][3] = 1.0;
/* save matrix */
glMatrixMode (GL_MODELVIEW);
static const OPENGL_BG_GRADIENT myDefaultBgGradient = { {{ 0.F, 0.F, 0.F, 1.F }}, {{ 0.F, 0.F, 0.F, 1.F }}, Aspect_GFM_NONE };
static const Tmatrix3 myDefaultMatrix = { { 1.F, 0.F, 0.F, 0.F }, { 0.F, 1.F, 0.F, 0.F }, { 0.F, 0.F, 1.F, 0.F }, { 0.F, 0.F, 0.F, 1.F } };
static const OPENGL_ZCLIP myDefaultZClip = { { Standard_True, 0.F }, { Standard_True, 1.F } };
-static const OPENGL_EXTRA_REP myDefaultExtra =
-{
- //vrp
- { 0.F, 0.F, 0.F },
- //vpn
- { 0.F, 0.F, 1.F },
- //vup
- { 0.F, 1.F, 0.F },
- //map
- {
- //window
- { 0.F, 0.F, 1.F, 1.F },
- //viewport
- { 0.F, 0.F, 0.F, 1.F, 1.F, 1.F },
- //proj
- TelParallel,
- //prp
- { 0.F, 0.F, 0.F },
- //vpd
- 0.F,
- //fpd
- 0.F,
- //bpd
- -1.F
- },
- //scaleFactors
- { 1.F, 1.F, 1.F }
-};
static const OPENGL_FOG myDefaultFog = { Standard_False, 0.F, 1.F, { { 0.F, 0.F, 0.F, 1.F } } };
static const TEL_TRANSFORM_PERSISTENCE myDefaultTransPers = { 0, 0.F, 0.F, 0.F };
myBackfacing(0),
myBgTexture(myDefaultBgTexture),
myBgGradient(myDefaultBgGradient),
- //myOrientationMatrix(myDefaultMatrix),
- //myMappingMatrix(myDefaultMatrix),
//shield_indicator = TOn,
//shield_colour = { { 0.F, 0.F, 0.F, 1.F } },
//border_indicator = TOff,
//border_colour = { { 0.F, 0.F, 0.F, 1.F } },
//active_status = TOn,
myZClip(myDefaultZClip),
- myExtra(myDefaultExtra),
+ myCamera(AContext.Camera),
myFog(myDefaultFog),
myTrihedron(NULL),
myGraduatedTrihedron(NULL),
myAntiAliasing(Standard_False),
myTransPers(&myDefaultTransPers),
myIsTransPers(Standard_False),
+ myProjectionState (0),
+ myModelViewState (0),
myStateCounter (theCounter),
- myLastOrientationState (0, 0),
- myLastViewMappingState (0, 0),
myLastLightSourceState (0, 0)
{
- // Initialize matrices
- memcpy(myOrientationMatrix,myDefaultMatrix,sizeof(Tmatrix3));
- memcpy(myMappingMatrix,myDefaultMatrix,sizeof(Tmatrix3));
// Shading method
switch (AContext.Model)
break;
}
- myCurrOrientationState = myStateCounter->Increment(); // <-- delete after merge with camera
- myCurrViewMappingState = myStateCounter->Increment(); // <-- delete after merge with camera
myCurrLightSourceState = myStateCounter->Increment();
#ifdef HAVE_OPENCL
//call_togl_cliplimit
void OpenGl_View::SetClipLimit (const Graphic3d_CView& theCView)
{
- myZClip.Back.Limit =
- (theCView.Context.ZClipBackPlane - theCView.Mapping.BackPlaneDistance) /
- (theCView.Mapping.FrontPlaneDistance - theCView.Mapping.BackPlaneDistance);
- myZClip.Front.Limit =
- (theCView.Context.ZClipFrontPlane - theCView.Mapping.BackPlaneDistance) /
- (theCView.Mapping.FrontPlaneDistance - theCView.Mapping.BackPlaneDistance);
- if (myZClip.Back.Limit < 0.0f)
- myZClip.Back.Limit = 0.0f;
- if (myZClip.Front.Limit > 1.0f)
- myZClip.Front.Limit = 1.0f;
- if (myZClip.Back.Limit > myZClip.Front.Limit)
- {
- myZClip.Back.Limit = 0.0f;
- myZClip.Front.Limit = 1.0f;
- }
+ myZClip.Back.Limit = theCView.Context.ZClipBackPlane;
+ myZClip.Front.Limit = theCView.Context.ZClipFrontPlane;
myZClip.Back.IsOn = (theCView.Context.BackZClipping != 0);
myZClip.Front.IsOn = (theCView.Context.FrontZClipping != 0);
/*----------------------------------------------------------------------*/
-//call_togl_viewmapping
-void OpenGl_View::SetMapping (const Handle(OpenGl_Display)& theGlDisplay,
- const Graphic3d_CView& theCView)
-{
- const float ratio = theCView.DefWindow.dy / theCView.DefWindow.dx;
- const float r_ratio = theCView.DefWindow.dx / theCView.DefWindow.dy;
-
- TEL_VIEW_MAPPING Map;
-
- Map.window.xmin = theCView.Mapping.WindowLimit.um;
- Map.window.ymin = theCView.Mapping.WindowLimit.vm;
- Map.window.xmax = theCView.Mapping.WindowLimit.uM;
- Map.window.ymax = theCView.Mapping.WindowLimit.vM;
-
- Map.viewport.xmin = 0.F;
- Map.viewport.xmax = ( 1.F < r_ratio ? 1.F : r_ratio );
- Map.viewport.ymin = 0.F;
- Map.viewport.ymax = ( 1.F < ratio ? 1.F : ratio );
- Map.viewport.zmin = 0.F;
- Map.viewport.zmax = 1.F;
-
- // projection type
- switch (theCView.Mapping.Projection)
- {
- case 0 :
- Map.proj = TelPerspective;
- break;
- case 1 :
- Map.proj = TelParallel;
- break;
- }
-
- // projection reference point
- Map.prp[0] = theCView.Mapping.ProjectionReferencePoint.x;
- Map.prp[1] = theCView.Mapping.ProjectionReferencePoint.y;
- Map.prp[2] = theCView.Mapping.ProjectionReferencePoint.z;
- if (!theGlDisplay.IsNull() && !theGlDisplay->Walkthrough())
- Map.prp[2] += theCView.Mapping.FrontPlaneDistance;
-
- // view plane distance
- Map.vpd = theCView.Mapping.ViewPlaneDistance;
-
- // back plane distance
- Map.bpd = theCView.Mapping.BackPlaneDistance;
-
- // front plane distance
- Map.fpd = theCView.Mapping.FrontPlaneDistance;
-
- Tint err_ind = 0;
-
- // use user-defined matrix
- if (theCView.Mapping.IsCustomMatrix)
- {
- int i, j;
- for( i = 0; i < 4; i++ )
- for( j = 0; j < 4; j++ )
- myMappingMatrix[i][j] = theCView.Mapping.ProjectionMatrix[i][j];
- }
- else
- TelEvalViewMappingMatrix (theGlDisplay, &Map, &err_ind, myMappingMatrix);
-
- if (!err_ind)
- myExtra.map = Map;
-
- myCurrViewMappingState = myStateCounter->Increment();
-}
-
-/*----------------------------------------------------------------------*/
-
-//call_togl_vieworientation
-void OpenGl_View::SetOrientation (const Graphic3d_CView& theCView)
-{
- Tfloat Vrp[3];
- Tfloat Vpn[3];
- Tfloat Vup[3];
- Tfloat ScaleFactors[3];
-
- Vrp[0] = theCView.Orientation.ViewReferencePoint.x;
- Vrp[1] = theCView.Orientation.ViewReferencePoint.y;
- Vrp[2] = theCView.Orientation.ViewReferencePoint.z;
-
- Vpn[0] = theCView.Orientation.ViewReferencePlane.x;
- Vpn[1] = theCView.Orientation.ViewReferencePlane.y;
- Vpn[2] = theCView.Orientation.ViewReferencePlane.z;
-
- Vup[0] = theCView.Orientation.ViewReferenceUp.x;
- Vup[1] = theCView.Orientation.ViewReferenceUp.y;
- Vup[2] = theCView.Orientation.ViewReferenceUp.z;
-
- ScaleFactors[0] = theCView.Orientation.ViewScaleX;
- ScaleFactors[1] = theCView.Orientation.ViewScaleY;
- ScaleFactors[2] = theCView.Orientation.ViewScaleZ;
-
- Tint err_ind = 0;
-
- // use user-defined matrix
- if (theCView.Orientation.IsCustomMatrix)
- {
- int i, j;
- for( i = 0; i < 4; i++ )
- for( j = 0; j < 4; j++ )
- myOrientationMatrix[i][j] = theCView.Orientation.ModelViewMatrix[i][j];
- }
- else
- {
- TelEvalViewOrientationMatrix (Vrp, Vpn, Vup, ScaleFactors, &err_ind, myOrientationMatrix);
- }
-
- if (!err_ind)
- {
- myExtra.vrp[0] = Vrp[0];
- myExtra.vrp[1] = Vrp[1];
- myExtra.vrp[2] = Vrp[2];
-
- myExtra.vpn[0] = Vpn[0];
- myExtra.vpn[1] = Vpn[1];
- myExtra.vpn[2] = Vpn[2];
-
- myExtra.vup[0] = Vup[0];
- myExtra.vup[1] = Vup[1];
- myExtra.vup[2] = Vup[2];
-
- myExtra.scaleFactors[0] = ScaleFactors[0],
- myExtra.scaleFactors[1] = ScaleFactors[1],
- myExtra.scaleFactors[2] = ScaleFactors[2];
- }
-
- myCurrOrientationState = myStateCounter->Increment();
-}
-
-/*----------------------------------------------------------------------*/
-
void OpenGl_View::SetFog (const Graphic3d_CView& theCView,
const Standard_Boolean theFlag)
{
{
myFog.IsOn = Standard_True;
- myFog.Front =
- (theCView.Context.DepthFrontPlane - theCView.Mapping.BackPlaneDistance) /
- (theCView.Mapping.FrontPlaneDistance - theCView.Mapping.BackPlaneDistance);
-
- myFog.Back =
- (theCView.Context.DepthBackPlane - theCView.Mapping.BackPlaneDistance) /
- (theCView.Mapping.FrontPlaneDistance - theCView.Mapping.BackPlaneDistance);
-
- if (myFog.Front < 0.F)
- myFog.Front = 0.F;
- else if (myFog.Front > 1.F)
- myFog.Front = 1.F;
-
- if (myFog.Back < 0.F)
- myFog.Back = 0.F;
- else if (myFog.Back > 1.F)
- myFog.Back = 1.F;
-
- if (myFog.Back > myFog.Front)
- {
- myFog.Front = 1.F;
- myFog.Back = 0.F;
- }
+ myFog.Front = theCView.Context.DepthFrontPlane;
+ myFog.Back = theCView.Context.DepthBackPlane;
myFog.Color.rgb[0] = theCView.DefWindow.Background.r;
myFog.Color.rgb[1] = theCView.DefWindow.Background.g;
glGetFloatv (GL_PROJECTION_MATRIX, *aResultProjection);
// Set OCCT state uniform variables
- theCtx->ShaderManager()->RevertWorldViewStateTo (aResultWorldView);
- theCtx->ShaderManager()->RevertProjectionStateTo (aResultProjection);
+ theCtx->ShaderManager()->RevertWorldViewStateTo (&aResultWorldView);
+ theCtx->ShaderManager()->RevertProjectionStateTo (&aResultProjection);
}
}
// prevent scaling-on-axis
if (theTransPers->mode & TPF_ZOOM)
{
- const double aScaleX = myExtra.scaleFactors[0];
- const double aScaleY = myExtra.scaleFactors[1];
- const double aScaleZ = myExtra.scaleFactors[2];
+ const gp_Pnt anAxialScale = myCamera->AxialScale();
+ const double aScaleX = anAxialScale.X();
+ const double aScaleY = anAxialScale.Y();
+ const double aScaleZ = anAxialScale.Z();
for (int i = 0; i < 3; ++i)
{
aModelMatrix[0][i] /= aScaleX;
glGetFloatv (GL_PROJECTION_MATRIX, *aResultProjection);
// Set OCCT state uniform variables
- theCtx->ShaderManager()->UpdateWorldViewStateTo (aResultWorldView);
- theCtx->ShaderManager()->UpdateProjectionStateTo (aResultProjection);
+ theCtx->ShaderManager()->UpdateWorldViewStateTo (&aResultWorldView);
+ theCtx->ShaderManager()->UpdateProjectionStateTo (&aResultProjection);
return aTransPersPrev;
}
+
+/*----------------------------------------------------------------------*/
+
+void OpenGl_View::GetMatrices (TColStd_Array2OfReal& theMatOrient,
+ TColStd_Array2OfReal& theMatMapping) const
+{
+ const OpenGl_Matrix* aProj = (const OpenGl_Matrix*) &myCamera->ProjectionMatrix();
+ const OpenGl_Matrix* aOrient = (const OpenGl_Matrix*) &myCamera->OrientationMatrix();
+
+ int i, j;
+ for (i = 0; i < 4; ++i)
+ {
+ for (j = 0; j < 4; ++j)
+ {
+ theMatOrient (i, j) = aOrient->mat[j][i];
+ theMatMapping (i, j) = aProj-> mat[j][i];
+ }
+ }
+}
+/*----------------------------------------------------------------------*/
#include <Graphic3d_SequenceOfHClipPlane.hxx>
#include <Visual3d_TypeOfSurfaceDetail.hxx>
-#include <OpenGl_telem_view.hxx>
#include <OpenGl_LayerList.hxx>
#include <OpenGl_Light.hxx>
Aspect_GradientFillMethod type;
};
-struct OPENGL_EXTRA_REP
-{
- Tfloat vrp[3];
- Tfloat vpn[3];
- Tfloat vup[3];
- TEL_VIEW_MAPPING map;
- Tfloat scaleFactors[3];
-};
-
struct OPENGL_ZCLIP
{
struct {
TEL_COLOUR Color;
};
+struct OpenGl_Matrix;
class OpenGl_GraduatedTrihedron;
class OpenGl_Structure;
class OpenGl_Trihedron;
void SetClipPlanes (const Graphic3d_SequenceOfHClipPlane &thePlanes) { myClipPlanes = thePlanes; }
void SetVisualisation (const CALL_DEF_VIEWCONTEXT &AContext);
+ void SetCamera (const Handle(Graphic3d_Camera)& theCamera) { myCamera = theCamera; }
+
void SetClipLimit (const Graphic3d_CView& theCView);
- void SetMapping (const Handle(OpenGl_Display)& theGlDisplay, const Graphic3d_CView& theCView);
- void SetOrientation (const Graphic3d_CView& theCView);
void SetFog (const Graphic3d_CView& theCView, const Standard_Boolean theFlag);
const Graphic3d_CGraduatedTrihedron& theCubic);
void GraduatedTrihedronErase (const Handle(OpenGl_Context)& theCtx);
- Standard_Boolean ProjectObjectToRaster (const Standard_Integer w, const Standard_Integer h,
- const Standard_ShortReal x, const Standard_ShortReal y, const Standard_ShortReal z,
- Standard_ShortReal &xr, Standard_ShortReal &yr);
- Standard_Boolean ProjectRasterToObject (const Standard_Integer w, const Standard_Integer h,
- const Standard_Integer xr, const Standard_Integer yr,
- Standard_ShortReal &x, Standard_ShortReal &y, Standard_ShortReal &z);
- Standard_Boolean ProjectRasterToObjectWithRay (const Standard_Integer w, const Standard_Integer h,
- const Standard_Integer xr, const Standard_Integer yr,
- Standard_ShortReal &x, Standard_ShortReal &y, Standard_ShortReal &z,
- Standard_ShortReal &dx, Standard_ShortReal &dy, Standard_ShortReal &dz);
- void GetMatrices (TColStd_Array2OfReal& theMatOrient,
- TColStd_Array2OfReal& theMatMapping,
- const Standard_Boolean theIsCustom) const;
-
- Standard_Real Height () const { return (myExtra.map.window.xmax - myExtra.map.window.xmin); }
- Standard_Real Width () const { return (myExtra.map.window.ymax - myExtra.map.window.ymin); }
+ Standard_Real Height () const { return myCamera->ViewDimensions().X(); }
+ Standard_Real Width () const { return myCamera->ViewDimensions().Y(); }
Standard_Integer Backfacing () const { return myBackfacing; }
//! Returns visualization mode for objects in the view.
Visual3d_TypeOfSurfaceDetail SurfaceDetail() const { return mySurfaceDetail; }
+ void GetMatrices (TColStd_Array2OfReal& theMatOrient,
+ TColStd_Array2OfReal& theMatMapping) const;
+
#ifdef HAVE_OPENCL
//! Returns modification state for ray-tracing.
Standard_Size ModificationState() const { return myModificationState; }
const Graphic3d_CView& theCView,
const Aspect_CLayer2d& theCLayer);
+ //! Redraw contents of model scene: clipping planes,
+ //! lights, structures. The peculiar properties of "scene" is that
+ //! it requires empty Z-Buffer and uses projection and orientation
+ //! matrices supplied by 3d view.
+ //! @param thePrintCtx [in] printer context which facilitates tiled printing.
+ //! @param theWorkspace [in] rendering workspace.
+ //! @param theCView [in] view data.
+ //! @param theProjection [in] view projection matrix.
+ //! @param theOrientation [in] view orientation matrix.
+ void RedrawScene (const Handle(OpenGl_PrinterContext)& thePrintContext,
+ const Handle(OpenGl_Workspace)& theWorkspace,
+ const OpenGl_Matrix* theProjection,
+ const OpenGl_Matrix* theOrientation);
+
Handle(OpenGl_Texture) myTextureEnv;
Visual3d_TypeOfSurfaceDetail mySurfaceDetail; //WSSurfaceDetail
Standard_Integer myBackfacing; //WSBackfacing
OPENGL_BG_TEXTURE myBgTexture; //WSBgTexture
OPENGL_BG_GRADIENT myBgGradient; //WSBgGradient
- //{ myViewRep
- Tmatrix3 myOrientationMatrix;
- Tmatrix3 myMappingMatrix;
-
- //Tint shield_indicator;
- //TEL_COLOUR shield_colour;
- //Tint border_indicator;
- //TEL_COLOUR border_colour;
- //Tint active_status;
-
OPENGL_ZCLIP myZClip;
- OPENGL_EXTRA_REP myExtra;
- //}
Graphic3d_SequenceOfHClipPlane myClipPlanes;
+ Handle(Graphic3d_Camera) myCamera;
+
OPENGL_FOG myFog;
OpenGl_Trihedron* myTrihedron;
OpenGl_GraduatedTrihedron* myGraduatedTrihedron;
const TEL_TRANSFORM_PERSISTENCE *myTransPers;
Standard_Boolean myIsTransPers;
+ //! Modification state
+ Standard_Size myProjectionState;
+ Standard_Size myModelViewState;
OpenGl_StateCounter* myStateCounter;
- Standard_Size myCurrOrientationState; // <-- delete it after merge with new camera
- Standard_Size myCurrViewMappingState; // <-- delete it after merge with new camera
Standard_Size myCurrLightSourceState;
typedef std::pair<Standard_Size, Standard_Size> StateInfo;
+++ /dev/null
-// Created on: 2011-09-20
-// Created by: Sergey ZERCHANINOV
-// Copyright (c) 2011-2014 OPEN CASCADE SAS
-//
-// This file is part of Open CASCADE Technology software library.
-//
-// This library is free software; you can redistribute it and / or modify it
-// under the terms of the GNU Lesser General Public version 2.1 as published
-// by the Free Software Foundation, with special exception defined in the file
-// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
-// distribution for complete text of the license and disclaimer of any warranty.
-//
-// Alternatively, this file may be used under the terms of Open CASCADE
-// commercial license or contractual agreement.
-
-#include <OpenGl_GlCore11.hxx>
-
-#include <OpenGl_View.hxx>
-
-#include <Visual3d_Layer.hxx>
-
-#include <OpenGl_tgl_funcs.hxx>
-#include <OpenGl_PrinterContext.hxx>
-#include <OpenGl_Workspace.hxx>
-
-/*----------------------------------------------------------------------*/
-
-//TelProjectionRaster in OpenGl_telem_util.cxx
-Standard_Boolean OpenGl_View::ProjectObjectToRaster (const Standard_Integer w, const Standard_Integer h,
- const Standard_ShortReal x, const Standard_ShortReal y, const Standard_ShortReal z,
- Standard_ShortReal &xr, Standard_ShortReal &yr)
-{
- int i, j, k;
-
- GLdouble modelMatrix[16];
- for (k = 0, i = 0; i < 4; i++)
- for (j = 0; j < 4; j++, k++)
- modelMatrix[k] = ( GLdouble )myOrientationMatrix[i][j];
-
- GLdouble projMatrix[16];
- for (k = 0, i = 0; i < 4; i++)
- for (j = 0; j < 4; j++, k++)
- projMatrix[k] = ( GLdouble )myMappingMatrix[i][j];
-
- GLint viewport[4];
- viewport[0] = 0;
- viewport[1] = 0;
- viewport[2] = w;
- viewport[3] = h;
-
- /*
- * glGetIntegerv (GL_VIEWPORT, viewport);
- * glGetDoublev (GL_MODELVIEW_MATRIX, modelMatrix);
- * glGetDoublev (GL_PROJECTION_MATRIX, projMatrix);
- */
-
- GLdouble winx, winy, winz;
- if (gluProject (( GLdouble )x, ( GLdouble )y, ( GLdouble )z, modelMatrix, projMatrix, viewport, &winx, &winy, &winz))
- {
- xr = ( Standard_ShortReal )winx;
- yr = ( Standard_ShortReal )winy;
- return Standard_True;
- }
-
- xr = 0.F;
- yr = 0.F;
- return Standard_False;
-}
-
-/*----------------------------------------------------------------------*/
-//TelUnProjectionRaster
-Standard_Boolean OpenGl_View::ProjectRasterToObject (const Standard_Integer w, const Standard_Integer h,
- const Standard_Integer xr, const Standard_Integer yr,
- Standard_ShortReal &x, Standard_ShortReal &y, Standard_ShortReal &z)
-{
- int i, j, k;
-
- GLdouble modelMatrix[16];
- for (k = 0, i = 0; i < 4; i++)
- for (j = 0; j < 4; j++, k++)
- modelMatrix[k] = ( GLdouble )myOrientationMatrix[i][j];
-
- GLdouble projMatrix[16];
- for (k = 0, i = 0; i < 4; i++)
- for (j = 0; j < 4; j++, k++)
- projMatrix[k] = ( GLdouble )myMappingMatrix[i][j];
-
- GLint viewport[4];
- viewport[0] = 0;
- viewport[1] = 0;
- viewport[2] = w;
- viewport[3] = h;
-
- /*
- * glGetIntegerv (GL_VIEWPORT, viewport);
- * glGetDoublev (GL_MODELVIEW_MATRIX, modelMatrix);
- * glGetDoublev (GL_PROJECTION_MATRIX, projMatrix);
- */
-
- GLdouble objx, objy, objz;
- if (gluUnProject (( GLdouble )xr, ( GLdouble )yr, 0.0, modelMatrix, projMatrix, viewport, &objx, &objy, &objz))
- {
- x = ( Standard_ShortReal )objx;
- y = ( Standard_ShortReal )objy;
- z = ( Standard_ShortReal )objz;
- return Standard_True;
- }
-
- x = 0.F;
- y = 0.F;
- z = 0.F;
- return Standard_False;
-}
-
-/*----------------------------------------------------------------------*/
-//TelUnProjectionRasterWithRay
-Standard_Boolean OpenGl_View::ProjectRasterToObjectWithRay (const Standard_Integer w, const Standard_Integer h,
- const Standard_Integer xr, const Standard_Integer yr,
- Standard_ShortReal &x, Standard_ShortReal &y, Standard_ShortReal &z,
- Standard_ShortReal &dx, Standard_ShortReal &dy, Standard_ShortReal &dz)
-{
- int i, j, k;
-
- GLdouble modelMatrix[16];
- for (k = 0, i = 0; i < 4; i++)
- for (j = 0; j < 4; j++, k++)
- modelMatrix[k] = ( GLdouble )myOrientationMatrix[i][j];
-
- GLdouble projMatrix[16];
- for (k = 0, i = 0; i < 4; i++)
- for (j = 0; j < 4; j++, k++)
- projMatrix[k] = ( GLdouble )myMappingMatrix[i][j];
-
- GLint viewport[4];
- viewport[0] = 0;
- viewport[1] = 0;
- viewport[2] = w;
- viewport[3] = h;
-
- /*
- * glGetIntegerv (GL_VIEWPORT, viewport);
- * glGetDoublev (GL_MODELVIEW_MATRIX, modelMatrix);
- * glGetDoublev (GL_PROJECTION_MATRIX, projMatrix);
- */
-
- const GLdouble winx = ( GLdouble )xr;
- const GLdouble winy = ( GLdouble )yr;
-
- GLdouble objx, objy, objz;
- if (gluUnProject (winx, winy, 0.0, modelMatrix, projMatrix, viewport, &objx, &objy, &objz))
- {
- GLdouble objx1, objy1, objz1;
- if (gluUnProject (winx, winy, -10.0, modelMatrix, projMatrix, viewport, &objx1, &objy1, &objz1))
- {
- x = ( Standard_ShortReal )objx;
- y = ( Standard_ShortReal )objy;
- z = ( Standard_ShortReal )objz;
- dx = ( Standard_ShortReal )(objx-objx1);
- dy = ( Standard_ShortReal )(objy-objy1);
- dz = ( Standard_ShortReal )(objz-objz1);
- return Standard_True;
- }
- }
-
- x = 0.F;
- y = 0.F;
- z = 0.F;
- dx = 0.F;
- dy = 0.F;
- dz = 0.F;
- return Standard_False;
-}
-
-/*----------------------------------------------------------------------*/
-
-//call_togl_inquiremat
-void OpenGl_View::GetMatrices (TColStd_Array2OfReal& theMatOrient,
- TColStd_Array2OfReal& theMatMapping,
- const Standard_Boolean theIsCustom) const
-{
- int i, j;
- if (theIsCustom)
- {
- // OCC18942: Trying to return the current matrices instead of calculating them anew.
- // This in particular allows using application-defined matrices.
- for (i = 0; i < 4; ++i)
- {
- for (j = 0; j < 4; ++j)
- {
- theMatOrient (i, j) = myOrientationMatrix[j][i];
- theMatMapping (i, j) = myMappingMatrix[j][i];
- }
- }
- return;
- }
-
- int anErr = 0;
- Tmatrix3 aMatOri;
- Tmatrix3 aMatMapping;
-
- view_map3 aViewMap;
- memcpy (&aViewMap.win, &myExtra.map.window, sizeof(Tlimit));
- memcpy (&aViewMap.proj_vp, &myExtra.map.viewport, sizeof(Tlimit3));
- switch (myExtra.map.proj)
- {
- default:
- case TelParallel: aViewMap.proj_type = TYPE_PARAL; break;
- case TelPerspective: aViewMap.proj_type = TYPE_PERSPECT; break;
- }
- aViewMap.proj_ref_point.x = myExtra.map.prp[0];
- aViewMap.proj_ref_point.y = myExtra.map.prp[1];
- aViewMap.proj_ref_point.z = myExtra.map.prp[2];
- aViewMap.view_plane = myExtra.map.vpd;
- aViewMap.back_plane = myExtra.map.bpd;
- aViewMap.front_plane = myExtra.map.fpd;
-
- call_func_eval_ori_matrix3 ((const point3* )myExtra.vrp,
- (const vec3* )myExtra.vpn,
- (const vec3* )myExtra.vup,
- &anErr, aMatOri);
- if (anErr == 0)
- call_func_eval_map_matrix3 (&aViewMap, &anErr, aMatMapping);
-
- if (anErr == 0)
- {
- for (i = 0; i < 4; ++i)
- {
- for (j = 0; j < 4; ++j)
- {
- theMatOrient (i, j) = aMatOri[j][i];
- theMatMapping (i, j) = aMatMapping[j][i];
- }
- }
- return;
- }
-
- // return just identity matrices
- for (i = 0; i < 4; ++i)
- {
- for (j = 0; j < 4; ++j)
- {
- if (i == j) {
- theMatMapping (i, j) = 1.0;
- theMatOrient (i, j) = 1.0;
- }
- else {
- theMatMapping (i, j) = 0.0;
- theMatOrient (i, j) = 0.0;
- }
- }
- }
-}
-
-/*----------------------------------------------------------------------*/
glEnable (theLightGlId++);
}
-/*----------------------------------------------------------------------*/
-/*
-* Prototypes
-*/
-
-static void call_util_apply_trans2( float ix, float iy, float iz, matrix3 mat,
- float *ox, float *oy, float *oz );
-static void call_util_mat_mul( matrix3 mat_a, matrix3 mat_b, matrix3 mat_c);
-
-/*----------------------------------------------------------------------*/
-/*
-* Fonctions externes
-*/
-
-/*
-* Evaluates orientation matrix.
-*/
-/* OCC18942: obsolete in OCCT6.3, might be removed in further versions! */
-void call_func_eval_ori_matrix3 (const point3* vrp, // view reference point
- const vec3* vpn, // view plane normal
- const vec3* vup, // view up vector
- int* err_ind,
- float mout[4][4]) // OUT view orientation matrix
-{
-
- /* Translate to VRP then change the basis.
- * The old basis is: e1 = < 1, 0, 0>, e2 = < 0, 1, 0>, e3 = < 0, 0, 1>.
- * The new basis is: ("x" means cross product)
- * e3' = VPN / |VPN|
- * e1' = VUP x VPN / |VUP x VPN|
- * e2' = e3' x e1'
- * Therefore the transform from old to new is x' = TAx, where:
- *
- * | e1'x e2'x e3'x 0 | | 1 0 0 0 |
- * A = | e1'y e2'y e3'y 0 |, T = | 0 1 0 0 |
- * | e1'z e2'z e3'z 0 | | 0 0 1 0 |
- * | 0 0 0 1 | | -vrp.x -vrp.y -vrp.z 1 |
- *
- */
-
- /*
- * These ei's are really ei primes.
- */
- register float (*m)[4][4];
- point3 e1, e2, e3, e4;
- double s, v;
-
- /*
- * e1' = VUP x VPN / |VUP x VPN|, but do the division later.
- */
- e1.x = vup->delta_y * vpn->delta_z - vup->delta_z * vpn->delta_y;
- e1.y = vup->delta_z * vpn->delta_x - vup->delta_x * vpn->delta_z;
- e1.z = vup->delta_x * vpn->delta_y - vup->delta_y * vpn->delta_x;
- s = sqrt( e1.x * e1.x + e1.y * e1.y + e1.z * e1.z);
- e3.x = vpn->delta_x;
- e3.y = vpn->delta_y;
- e3.z = vpn->delta_z;
- v = sqrt( e3.x * e3.x + e3.y * e3.y + e3.z * e3.z);
- /*
- * Check for vup and vpn colinear (zero dot product).
- */
- if ((s > -EPSI) && (s < EPSI))
- *err_ind = 2;
- else
- /*
- * Check for a normal vector not null.
- */
- if ((v > -EPSI) && (v < EPSI))
- *err_ind = 3;
- else {
- /*
- * Normalize e1
- */
- e1.x /= ( float )s;
- e1.y /= ( float )s;
- e1.z /= ( float )s;
- /*
- * e3 = VPN / |VPN|
- */
- e3.x /= ( float )v;
- e3.y /= ( float )v;
- e3.z /= ( float )v;
- /*
- * e2 = e3 x e1
- */
- e2.x = e3.y * e1.z - e3.z * e1.y;
- e2.y = e3.z * e1.x - e3.x * e1.z;
- e2.z = e3.x * e1.y - e3.y * e1.x;
- /*
- * Add the translation
- */
- e4.x = -( e1.x * vrp->x + e1.y * vrp->y + e1.z * vrp->z);
- e4.y = -( e2.x * vrp->x + e2.y * vrp->y + e2.z * vrp->z);
- e4.z = -( e3.x * vrp->x + e3.y * vrp->y + e3.z * vrp->z);
- /*
- * Homogeneous entries
- *
- * | e1.x e2.x e3.x 0.0 | | 1 0 0 0 |
- * | e1.y e2.y e3.y 0.0 | * | 0 1 0 0 |
- * | e1.z e2.z e3.z 0.0 | | a b 1 c |
- * | e4.x e4.y e4.z 1.0 | | 0 0 0 1 |
- */
-
- m = (float (*)[4][4])mout;
-
- (*m)[0][0] = e1.x;
- (*m)[0][1] = e2.x;
- (*m)[0][2] = e3.x;
- (*m)[0][3] = ( float )0.0;
-
- (*m)[1][0] = e1.y;
- (*m)[1][1] = e2.y;
- (*m)[1][2] = e3.y;
- (*m)[1][3] = ( float )0.0;
-
- (*m)[2][0] = e1.z;
- (*m)[2][1] = e2.z;
- (*m)[2][2] = e3.z;
- (*m)[2][3] = ( float )0.0;
-
- (*m)[3][0] = e4.x;
- (*m)[3][1] = e4.y;
- (*m)[3][2] = e4.z;
- (*m)[3][3] = ( float )1.0;
-
- *err_ind = 0;
- }
-}
-
-/*----------------------------------------------------------------------*/
-/*
-* Evaluates mapping matrix.
-*/
-/* OCC18942: obsolete in OCCT6.3, might be removed in further versions! */
-void call_func_eval_map_matrix3(
- view_map3 *Map,
- int *err_ind,
- matrix3 mat)
-{
- int i, j;
- matrix3 Tpar, Spar;
- matrix3 Tper, Sper;
- matrix3 Shear;
- matrix3 Scale;
- matrix3 Tprp;
- matrix3 aux_mat1, aux_mat2, aux_mat3;
- point3 Prp;
-
- *err_ind = 0;
- for (i=0; i<4; i++)
- for (j=0; j<4; j++)
- Spar[i][j] = Sper[i][j] = aux_mat1[i][j] = aux_mat2[i][j] =
- aux_mat3[i][j] = Tper[i][j] = Tpar[i][j] = Tprp[i][j] =
- Shear[i][j] = Scale[i][j] = ( float )(i == j);
-
- Prp.x = Map->proj_ref_point.x;
- Prp.y = Map->proj_ref_point.y;
- Prp.z = Map->proj_ref_point.z;
-
- /*
- * Type Parallele
- */
- if (Map->proj_type == TYPE_PARAL)
- {
- float umid, vmid;
- point3 temp;
-
-#ifdef FMN
- float cx, cy, gx, gy, xsf, ysf, zsf;
- float fpd, bpd;
- float dopx, dopy, dopz;
- matrix3 tmat = { { ( float )1.0, ( float )0.0, ( float )0.0, ( float )0.0 },
- { ( float )0.0, ( float )1.0, ( float )0.0, ( float )0.0 },
- { ( float )0.0, ( float )0.0, ( float )1.0, ( float )0.0 },
- { ( float )0.0, ( float )0.0, ( float )0.0, ( float )1.0 } };
- matrix3 smat = { { ( float )1.0, ( float )0.0, ( float )0.0, ( float )0.0 },
- { ( float )0.0, ( float )1.0, ( float )0.0, ( float )0.0 },
- { ( float )0.0, ( float )0.0, ( float )1.0, ( float )0.0 },
- { ( float )0.0, ( float )0.0, ( float )0.0, ( float )1.0 } };
- matrix3 shmat = { { ( float )1.0, ( float )0.0, ( float )0.0, ( float )0.0 },
- { ( float )0.0, ( float )1.0, ( float )0.0, ( float )0.0 },
- { ( float )0.0, ( float )0.0, ( float )1.0, ( float )0.0 },
- { ( float )0.0, ( float )0.0, ( float )0.0, ( float )1.0 } };
- matrix3 tshmat = { { ( float )1.0, ( float )0.0, ( float )0.0, ( float )0.0 },
- { ( float )0.0, ( float )1.0, ( float )0.0, ( float )0.0 },
- { ( float )0.0, ( float )0.0, ( float )1.0, ( float )0.0 },
- { ( float )0.0, ( float )0.0, ( float )0.0, ( float )1.0 } };
-
- /* centers */
- cx = Map->win.x_min + Map->win.x_max, cx /= ( float )2.0;
- cy = Map->win.y_min + Map->win.y_max, cy /= ( float )2.0;
-
- gx = 2.0/ (Map->win.x_max - Map->win.x_min);
- gy = 2.0/ (Map->win.y_max - Map->win.y_min);
-
- tmat[0][3] = -cx;
- tmat[1][3] = -cy;
- tmat[2][3] = (Map->front_plane + Map->back_plane)/(Map->front_plane - Map->back_plane);
-
- smat[0][0] = gx;
- smat[1][1] = gy;
- smat[2][2] = -2./(Map->front_plane - Map->back_plane);
-
- /* scale factors */
- dopx = cx - Prp.x;
- dopy = cy - Prp.y;
- dopz = - Prp.z;
-
- /* map matrix */
- shmat[0][2] = -(dopx/dopz);
- shmat[1][2] = -(dopy/dopz);
-
- /* multiply to obtain mapping matrix */
- call_util_mat_mul( tmat, shmat, tshmat );
- call_util_mat_mul( smat, tshmat, mat );
-
- return;
-#endif
-
- /* CAL */
- Map->proj_vp.z_min = ( float )0.0;
- Map->proj_vp.z_max = ( float )1.0;
- /* CAL */
-
- /* Shear matrix calculation */
- umid = ( float )(Map->win.x_min+Map->win.x_max)/( float )2.0;
- vmid = ( float )(Map->win.y_min+Map->win.y_max)/( float )2.0;
- if(Prp.z == Map->view_plane){
- /* Projection reference point is on the view plane */
- *err_ind = 1;
- return;
- }
- Shear[2][0] = ( float )(-1.0) * ((Prp.x-umid)/(Prp.z-Map->view_plane));
- Shear[2][1] = ( float )(-1.0) * ((Prp.y-vmid)/(Prp.z-Map->view_plane));
-
- /*
- * Calculate the lower left coordinate of the view plane
- * after the Shearing Transformation.
- */
- call_util_apply_trans2(Map->win.x_min, Map->win.y_min,
- Map->view_plane, Shear, &(temp.x), &(temp.y), &(temp.z));
-
- /* Translate the back plane to the origin */
- Tpar[3][0] = ( float )(-1.0) * temp.x;
- Tpar[3][1] = ( float )(-1.0) * temp.y;
- Tpar[3][2] = ( float )(-1.0) * Map->back_plane;
-
- call_util_mat_mul(Shear, Tpar, aux_mat1);
-
- /* Calculation of Scaling transformation */
- Spar[0][0] = ( float )1.0 / (Map->win.x_max - Map->win.x_min);
- Spar[1][1] = ( float )1.0 / (Map->win.y_max - Map->win.y_min);
- Spar[2][2] = ( float )1.0 / (Map->front_plane - Map->back_plane );
- call_util_mat_mul (aux_mat1, Spar, aux_mat2);
- /* Atlast we transformed view volume to NPC */
-
- /* Translate and scale the view plane to projection view port */
- if(Map->proj_vp.x_min < 0.0 || Map->proj_vp.y_min < 0.0 ||
- Map->proj_vp.z_min < 0.0 || Map->proj_vp.x_max > 1.0 ||
- Map->proj_vp.y_max > 1.0 || Map->proj_vp.z_max > 1.0 ||
- Map->proj_vp.x_min > Map->proj_vp.x_max ||
- Map->proj_vp.y_min > Map->proj_vp.y_max ||
- Map->proj_vp.z_min > Map->proj_vp.z_max){
- *err_ind = 1;
- return;
- }
- for(i=0; i<4; i++)
- for(j=0; j<4; j++)
- aux_mat1[i][j] = (float)(i==j);
- aux_mat1[0][0] = Map->proj_vp.x_max-Map->proj_vp.x_min;
- aux_mat1[1][1] = Map->proj_vp.y_max-Map->proj_vp.y_min;
- aux_mat1[2][2] = Map->proj_vp.z_max-Map->proj_vp.z_min;
- aux_mat1[3][0] = Map->proj_vp.x_min;
- aux_mat1[3][1] = Map->proj_vp.y_min;
- aux_mat1[3][2] = Map->proj_vp.z_min;
- call_util_mat_mul (aux_mat2, aux_mat1, mat);
-
- return;
- }
-
- /*
- * Type Perspective
- */
- else if (Map->proj_type == TYPE_PERSPECT)
- {
- float umid, vmid;
- float B, F, V;
- float Zvmin;
-
- /* CAL */
- Map->proj_vp.z_min = ( float )0.0;
- Map->proj_vp.z_max = ( float )1.0;
- /* CAL */
-
- B = Map->back_plane;
- F = Map->front_plane;
- V = Map->view_plane;
-
- if(Prp.z == Map->view_plane){
- /* Centre of Projection is on the view plane */
- *err_ind = 1;
- return;
- }
- if(Map->proj_vp.x_min < 0.0 || Map->proj_vp.y_min < 0.0 ||
- Map->proj_vp.z_min < 0.0 || Map->proj_vp.x_max > 1.0 ||
- Map->proj_vp.y_max > 1.0 || Map->proj_vp.z_max > 1.0 ||
- Map->proj_vp.x_min > Map->proj_vp.x_max ||
- Map->proj_vp.y_min > Map->proj_vp.y_max ||
- Map->proj_vp.z_min > Map->proj_vp.z_max ||
- F < B){
- *err_ind = 1;
- return;
- }
-
- /* This is the transformation to move VRC to Center Of Projection */
- Tprp[3][0] = ( float )(-1.0)*Prp.x;
- Tprp[3][1] = ( float )(-1.0)*Prp.y;
- Tprp[3][2] = ( float )(-1.0)*Prp.z;
-
- /* Calculation of Shear matrix */
- umid = ( float )(Map->win.x_min+Map->win.x_max)/( float )2.0-Prp.x;
- vmid = ( float )(Map->win.y_min+Map->win.y_max)/( float )2.0-Prp.y;
- Shear[2][0] = ( float )(-1.0)*umid/(Map->view_plane-Prp.z);
- Shear[2][1] = ( float )(-1.0)*vmid/(Map->view_plane-Prp.z);
- call_util_mat_mul(Tprp, Shear, aux_mat3);
-
- /* Scale the view volume to canonical view volume
- * Centre of projection at origin.
- * 0 <= N <= -1, -0.5 <= U <= 0.5, -0.5 <= V <= 0.5
- */
- Scale[0][0] = (( float )(-1.0)*Prp.z+V)/
- ((Map->win.x_max-Map->win.x_min)*(( float )(-1.0)*Prp.z+B));
- Scale[1][1] = (( float )(-1.0)*Prp.z+V)/
- ((Map->win.y_max-Map->win.y_min)*(( float )(-1.0)*Prp.z+B));
- Scale[2][2] = ( float )(-1.0) / (( float )(-1.0)*Prp.z+B);
-
- call_util_mat_mul(aux_mat3, Scale, aux_mat1);
-
- /*
- * Transform the Perspective view volume into
- * Parallel view volume.
- * Lower left coordinate: (-0.5,-0.5, -1)
- * Upper right coordinate: (0.5, 0.5, 1.0)
- */
- Zvmin = ( float )(-1.0*(-1.0*Prp.z+F)/(-1.0*Prp.z+B));
- aux_mat2[2][2] = ( float )1.0/(( float )1.0+Zvmin);
- aux_mat2[2][3] = ( float )(-1.0);
- aux_mat2[3][2] = ( float )(-1.0)*Zvmin*aux_mat2[2][2];
- aux_mat2[3][3] = ( float )0.0;
- call_util_mat_mul(aux_mat1, aux_mat2, Shear);
-
- for(i=0; i<4; i++)
- for(j=0; j<4; j++)
- aux_mat1[i][j] = aux_mat2[i][j] = (float)(i==j);
-
- /* Translate and scale the view plane to projection view port */
- aux_mat2[0][0] = (Map->proj_vp.x_max-Map->proj_vp.x_min);
- aux_mat2[1][1] = (Map->proj_vp.y_max-Map->proj_vp.y_min);
- aux_mat2[2][2] = (Map->proj_vp.z_max-Map->proj_vp.z_min);
- aux_mat2[3][0] = aux_mat2[0][0]/( float )2.0+Map->proj_vp.x_min;
- aux_mat2[3][1] = aux_mat2[1][1]/( float )2.0+Map->proj_vp.y_min;
- aux_mat2[3][2] = aux_mat2[2][2]+Map->proj_vp.z_min;
- call_util_mat_mul (Shear, aux_mat2, mat);
-
- return;
- }
- else
- *err_ind = 1;
-}
-
/*----------------------------------------------------------------------*/
-static void
-call_util_apply_trans2( float ix, float iy, float iz, matrix3 mat,
- float *ox, float *oy, float *oz )
+void OpenGl_View::DrawBackground (const Handle(OpenGl_Workspace)& theWorkspace)
{
- float temp;
- *ox = ix*mat[0][0]+iy*mat[1][0]+iz*mat[2][0]+mat[3][0];
- *oy = ix*mat[0][1]+iy*mat[1][1]+iz*mat[2][1]+mat[3][1];
- *oz = ix*mat[0][2]+iy*mat[1][2]+iz*mat[2][2]+mat[3][2];
- temp = ix * mat[0][3]+iy * mat[1][3]+iz * mat[2][3]+mat[3][3];
- *ox /= temp;
- *oy /= temp;
- *oz /= temp;
-}
-
-/*----------------------------------------------------------------------*/
-
-static void
-call_util_mat_mul( matrix3 mat_a, matrix3 mat_b, matrix3 mat_c)
-{
- int i, j, k;
-
- for (i=0; i<4; i++)
- for (j=0; j<4; j++)
- for (mat_c[i][j] = ( float )0.0,k=0; k<4; k++)
- mat_c[i][j] += mat_a[i][k] * mat_b[k][j];
-}
-
-/*----------------------------------------------------------------------*/
-
-void OpenGl_View::DrawBackground (const Handle(OpenGl_Workspace) &AWorkspace)
-{
- /////////////////////////////////////////////////////////////////////////////
- // Step 1: Prepare for redraw
-
- // Render background
- if ( (AWorkspace->NamedStatus & OPENGL_NS_WHITEBACK) == 0 &&
- ( myBgTexture.TexId != 0 || myBgGradient.type != Aspect_GFM_NONE ) )
+ if ( (theWorkspace->NamedStatus & OPENGL_NS_WHITEBACK) == 0 &&
+ ( myBgTexture.TexId != 0 || myBgGradient.type != Aspect_GFM_NONE ) )
{
- const Standard_Integer aViewWidth = AWorkspace->Width();
- const Standard_Integer aViewHeight = AWorkspace->Height();
+ const Standard_Integer aViewWidth = theWorkspace->Width();
+ const Standard_Integer aViewHeight = theWorkspace->Height();
glPushAttrib( GL_ENABLE_BIT | GL_TEXTURE_BIT );
glDisable( GL_BLEND ); //push GL_ENABLE_BIT
- glColor3fv( AWorkspace->BackgroundColor().rgb );
- glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_DECAL); //push GL_TEXTURE_BIT
+ glColor3fv (theWorkspace->BackgroundColor().rgb);
+ glTexEnvi (GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_DECAL); //push GL_TEXTURE_BIT
// Note that texture is mapped using GL_REPEAT wrapping mode so integer part
// is simply ignored, and negative multiplier is here for convenience only
glPopAttrib(); //GL_ENABLE_BIT | GL_TEXTURE_BIT
- if ( AWorkspace->UseZBuffer() )
- glEnable( GL_DEPTH_TEST );
+ if (theWorkspace->UseZBuffer())
+ glEnable (GL_DEPTH_TEST);
/* GL_DITHER on/off pour le trace */
- if (AWorkspace->Dither())
+ if (theWorkspace->Dither())
glEnable (GL_DITHER);
else
glDisable (GL_DITHER);
//call_func_redraw_all_structs_proc
void OpenGl_View::Render (const Handle(OpenGl_PrinterContext)& thePrintContext,
- const Handle(OpenGl_Workspace) &AWorkspace,
- const Graphic3d_CView& ACView,
- const Aspect_CLayer2d& ACUnderLayer,
- const Aspect_CLayer2d& ACOverLayer)
+ const Handle(OpenGl_Workspace) &theWorkspace,
+ const Graphic3d_CView& theCView,
+ const Aspect_CLayer2d& theCUnderLayer,
+ const Aspect_CLayer2d& theCOverLayer)
{
+ // ==================================
+ // Step 1: Prepare for redraw
+ // ==================================
+
+ const Handle(OpenGl_Context)& aContext = theWorkspace->GetGlContext();
+
// Store and disable current clipping planes
- const Handle(OpenGl_Context)& aContext = AWorkspace->GetGlContext();
- const Standard_Integer aMaxClipPlanes = aContext->MaxClipPlanes();
- const GLenum lastid = GL_CLIP_PLANE0 + aMaxClipPlanes;
- OPENGL_CLIP_PLANE *oldPlanes = new OPENGL_CLIP_PLANE[aMaxClipPlanes];
- OPENGL_CLIP_PLANE *ptrPlane = oldPlanes;
- GLenum planeid = GL_CLIP_PLANE0;
- for ( ; planeid < lastid; planeid++, ptrPlane++ )
+ Standard_Integer aMaxPlanes = aContext->MaxClipPlanes();
+
+ OPENGL_CLIP_PLANE *aOldPlanes = new OPENGL_CLIP_PLANE[aMaxPlanes];
+ OPENGL_CLIP_PLANE *aPtrPlane = aOldPlanes;
+
+ GLenum aClipPlaneId = GL_CLIP_PLANE0;
+ const GLenum aClipLastId = GL_CLIP_PLANE0 + aMaxPlanes;
+ for (; aClipPlaneId < aClipLastId; aClipPlaneId++, aPtrPlane++)
{
- glGetClipPlane( planeid, ptrPlane->Equation );
- if ( ptrPlane->isEnabled )
+ glGetClipPlane (aClipPlaneId, aPtrPlane->Equation);
+ if (aPtrPlane->isEnabled)
{
- glDisable( planeid );
- ptrPlane->isEnabled = GL_TRUE;
+ glDisable (aClipPlaneId);
+ aPtrPlane->isEnabled = GL_TRUE;
}
else
{
- ptrPlane->isEnabled = GL_FALSE;
+ aPtrPlane->isEnabled = GL_FALSE;
}
}
// Set OCCT state uniform variables
const Handle(OpenGl_ShaderManager) aManager = aContext->ShaderManager();
- if (StateInfo (myCurrLightSourceState, aManager->LightSourceState().Index()) != myLastLightSourceState)
- {
- aManager->UpdateLightSourceStateTo (&myLights);
- myLastLightSourceState = StateInfo (myCurrLightSourceState, aManager->LightSourceState().Index());
- }
- if (StateInfo (myCurrViewMappingState, aManager->ProjectionState().Index()) != myLastViewMappingState)
- {
- aManager->UpdateProjectionStateTo (myMappingMatrix);
- myLastViewMappingState = StateInfo (myCurrViewMappingState, aManager->ProjectionState().Index());
- }
- if (StateInfo (myCurrOrientationState, aManager->WorldViewState().Index()) != myLastOrientationState)
- {
- aManager->UpdateWorldViewStateTo (myOrientationMatrix);
- myLastOrientationState = StateInfo (myCurrOrientationState, aManager->WorldViewState().Index());
- }
- if (aManager->ModelWorldState().Index() == 0)
+ if (!aManager->IsEmpty())
{
- Tmatrix3 aModelWorldState = { { 1.f, 0.f, 0.f, 0.f },
- { 0.f, 1.f, 0.f, 0.f },
- { 0.f, 0.f, 1.f, 0.f },
- { 0.f, 0.f, 0.f, 1.f } };
-
- aManager->UpdateModelWorldStateTo (aModelWorldState);
+ if (StateInfo (myCurrLightSourceState, aManager->LightSourceState().Index()) != myLastLightSourceState)
+ {
+ aManager->UpdateLightSourceStateTo (&myLights);
+ myLastLightSourceState = StateInfo (myCurrLightSourceState, aManager->LightSourceState().Index());
+ }
+
+ if (myProjectionState != myCamera->ProjectionState())
+ {
+ myProjectionState = myCamera->ProjectionState();
+ aManager->UpdateProjectionStateTo ((const Tmatrix3*)myCamera->ProjectionMatrix().GetData());
+ }
+
+ if (myModelViewState != myCamera->ModelViewState())
+ {
+ myModelViewState = myCamera->ModelViewState();
+ aManager->UpdateWorldViewStateTo ((const Tmatrix3*)myCamera->OrientationMatrix().GetData());
+ }
+
+ if (aManager->ModelWorldState().Index() == 0)
+ {
+ Tmatrix3 aModelWorldState = { { 1.f, 0.f, 0.f, 0.f },
+ { 0.f, 1.f, 0.f, 0.f },
+ { 0.f, 0.f, 1.f, 0.f },
+ { 0.f, 0.f, 0.f, 1.f } };
+
+ aContext->ShaderManager()->UpdateModelWorldStateTo (&aModelWorldState);
+ }
}
- /////////////////////////////////////////////////////////////////////////////
- // Step 1: Prepare for redraw
+ // ====================================
+ // Step 2: Redraw background
+ // ====================================
// Render background
- DrawBackground (AWorkspace);
+ DrawBackground (theWorkspace);
// Switch off lighting by default
glDisable(GL_LIGHTING);
- /////////////////////////////////////////////////////////////////////////////
- // Step 2: Draw underlayer
- RedrawLayer2d (thePrintContext, ACView, ACUnderLayer);
+ // =================================
+ // Step 3: Draw underlayer
+ // =================================
+
+ RedrawLayer2d (thePrintContext, theCView, theCUnderLayer);
- /////////////////////////////////////////////////////////////////////////////
- // Step 3: Redraw main plane
+ // =================================
+ // Step 4: Redraw main plane
+ // =================================
// Setup face culling
GLboolean isCullFace = GL_FALSE;
glEnable( GL_CULL_FACE );
glCullFace( GL_BACK );
}
- else
+ else
glDisable( GL_CULL_FACE );
}
- //TsmPushAttri(); /* save previous graphics context */
-
- // if the view is scaled normal vectors are scaled to unit length for correct displaying of shaded objects
- if(myExtra.scaleFactors[0] != 1.F ||
- myExtra.scaleFactors[1] != 1.F ||
- myExtra.scaleFactors[2] != 1.F)
+ // if the view is scaled normal vectors are scaled to unit
+ // length for correct displaying of shaded objects
+ const gp_Pnt anAxialScale = myCamera->AxialScale();
+ if(anAxialScale.X() != 1.F ||
+ anAxialScale.Y() != 1.F ||
+ anAxialScale.Z() != 1.F)
glEnable(GL_NORMALIZE);
else if(glIsEnabled(GL_NORMALIZE))
glDisable(GL_NORMALIZE);
- // Apply View Projection
- // This routine activates the Projection matrix for a view.
-
- glMatrixMode( GL_PROJECTION );
-
-#ifdef _WIN32
- // add printing scale/tiling transformation
- if (!thePrintContext.IsNull())
- {
- thePrintContext->LoadProjTransformation();
- }
- else
-#endif
- glLoadIdentity();
-
- glMultMatrixf( (const GLfloat *) myMappingMatrix );
-
- // Add translation necessary for the environnement mapping
- if (mySurfaceDetail != Visual3d_TOD_NONE)
- {
- // OCC280: FitAll work incorrect for perspective view if the SurfaceDetail mode is V3d_TEX_ENVIRONMENT or V3d_TEX_ALL
- // const GLfloat dep = vptr->vrep.extra.map.fpd * 0.5F;
- const GLfloat dep = (myExtra.map.fpd + myExtra.map.bpd) * 0.5F;
- glTranslatef(-dep*myExtra.vpn[0],-dep*myExtra.vpn[1],-dep*myExtra.vpn[2]);
- }
-
- // Apply matrix
- AWorkspace->SetViewMatrix((const OpenGl_Matrix *)myOrientationMatrix);
-
-/*
-While drawing after a clipplane has been defined and enabled, each vertex
-is transformed to eye-coordinates, where it is dotted with the transformed
-clipping plane equation. Eye-coordinate vertexes whose dot product with
-the transformed clipping plane equation is positive or zero are in, and
-require no clipping. Those eye-coordinate vertexes whose dot product is
-negative are clipped. Because clipplane clipping is done in eye-
-coordinates, changes to the projection matrix have no effect on its
-operation.
-
-A point and a normal are converted to a plane equation in the following manner:
-
-point = [Px,Py,Pz]
-
-normal = |Nx|
-|Ny|
-|Nz|
-
-plane equation = |A|
-|B|
-|C|
-|D|
-A = Nx
-B = Ny
-C = Nz
-D = -[Px,Py,Pz] dot |Nx|
-|Ny|
-|Nz|
-
-*/
-
// Apply Fog
if ( myFog.IsOn )
{
- const GLfloat ramp = myExtra.map.fpd - myExtra.map.bpd;
- const GLfloat fog_start = myFog.Front * ramp - myExtra.map.fpd;
- const GLfloat fog_end = myFog.Back * ramp - myExtra.map.fpd;
-
- glFogi(GL_FOG_MODE, GL_LINEAR);
- glFogf(GL_FOG_START, fog_start);
- glFogf(GL_FOG_END, fog_end);
- glFogfv(GL_FOG_COLOR, myFog.Color.rgb);
- glEnable(GL_FOG);
- }
- else
- glDisable(GL_FOG);
-
- // Apply Lights
- {
- // setup lights
- Graphic3d_Vec4 anAmbientColor (THE_DEFAULT_AMBIENT[0],
- THE_DEFAULT_AMBIENT[1],
- THE_DEFAULT_AMBIENT[2],
- THE_DEFAULT_AMBIENT[3]);
- GLenum aLightGlId = GL_LIGHT0;
- for (OpenGl_ListOfLight::Iterator aLightIt (myLights);
- aLightIt.More(); aLightIt.Next())
+ Standard_Real aFogFrontConverted = (Standard_Real )myFog.Front + myCamera->Distance();
+ if (myCamera->ZFar() < aFogFrontConverted)
{
- bind_light (aLightIt.Value(), aLightGlId, anAmbientColor);
+ aFogFrontConverted = myCamera->ZFar();
+ myFog.Front = (Standard_ShortReal )(aFogFrontConverted - myCamera->Distance());
}
- // apply accumulated ambient color
- anAmbientColor.a() = 1.0f;
- glLightModelfv (GL_LIGHT_MODEL_AMBIENT, anAmbientColor.GetData());
-
- if (aLightGlId != GL_LIGHT0)
+ Standard_Real aFogBackConverted = (Standard_Real )myFog.Back + myCamera->Distance();
+ if (myCamera->ZFar() < aFogFrontConverted)
{
- glEnable (GL_LIGHTING);
+ aFogBackConverted = myCamera->ZFar();
+ myFog.Back = (Standard_ShortReal )(aFogBackConverted - myCamera->Distance());
}
- // switch off unused lights
- for (; aLightGlId <= GL_LIGHT7; ++aLightGlId)
+
+ if (aFogFrontConverted > aFogBackConverted)
{
- glDisable (aLightGlId);
- }
+ myFog.Front = (Standard_ShortReal )(aFogFrontConverted - myCamera->Distance());
+ myFog.Back = (Standard_ShortReal )(aFogBackConverted - myCamera->Distance());
+ }
+
+ glFogi(GL_FOG_MODE, GL_LINEAR);
+ glFogf(GL_FOG_START, (Standard_ShortReal )aFogFrontConverted);
+ glFogf(GL_FOG_END, (Standard_ShortReal )aFogBackConverted);
+ glFogfv(GL_FOG_COLOR, myFog.Color.rgb);
+ glEnable(GL_FOG);
}
+ else
+ glDisable(GL_FOG);
// Apply InteriorShadingMethod
glShadeModel( myIntShadingMethod == TEL_SM_FLAT ? GL_FLAT : GL_SMOOTH );
- // Apply clipping planes
+ // Apply AntiAliasing
+ if (myAntiAliasing)
+ theWorkspace->NamedStatus |= OPENGL_NS_ANTIALIASING;
+ else
+ theWorkspace->NamedStatus &= ~OPENGL_NS_ANTIALIASING;
+
+ if (!aManager->IsEmpty())
{
- if (myZClip.Back.IsOn || myZClip.Front.IsOn)
- {
- const GLdouble ramp = myExtra.map.fpd - myExtra.map.bpd;
+ aManager->UpdateClippingState();
+ }
- Handle(Graphic3d_ClipPlane) aPlaneBack;
- Handle(Graphic3d_ClipPlane) aPlaneFront;
+ // Redraw 3d scene
+ if (!myCamera->IsStereo() || !aContext->HasStereoBuffers())
+ {
+ // single-pass monographic rendering
+ const OpenGl_Matrix* aProj = (const OpenGl_Matrix*) &myCamera->ProjectionMatrix();
- if (myZClip.Back.IsOn)
- {
- const GLdouble back = ramp * myZClip.Back.Limit + myExtra.map.bpd;
- const Graphic3d_ClipPlane::Equation aBackEquation (0.0, 0.0, 1.0, -back);
- aPlaneBack = new Graphic3d_ClipPlane (aBackEquation);
- }
+ const OpenGl_Matrix* aOrient = (const OpenGl_Matrix*) &myCamera->OrientationMatrix();
- if (myZClip.Front.IsOn)
- {
- const GLdouble front = ramp * myZClip.Front.Limit + myExtra.map.bpd;
- const Graphic3d_ClipPlane::Equation aFrontEquation (0.0, 0.0, -1.0, front);
- aPlaneFront = new Graphic3d_ClipPlane (aFrontEquation);
- }
+ // redraw scene with normal orientation and projection
+ RedrawScene (thePrintContext, theWorkspace, aProj, aOrient);
+ }
+ else
+ {
+ // two stereographic passes
+ const OpenGl_Matrix* aLProj = (const OpenGl_Matrix*) &myCamera->ProjectionStereoLeft();
+ const OpenGl_Matrix* aRProj = (const OpenGl_Matrix*) &myCamera->ProjectionStereoRight();
+ const OpenGl_Matrix* aOrient = (const OpenGl_Matrix*) &myCamera->OrientationMatrix();
- // do some "memory allocation"-wise optimization
- if (!aPlaneBack.IsNull() || !aPlaneFront.IsNull())
- {
- Graphic3d_SequenceOfHClipPlane aSlicingPlanes;
- if (!aPlaneBack.IsNull())
- {
- aSlicingPlanes.Append (aPlaneBack);
- }
+ // safely switch to left Eye buffer
+ aContext->SetDrawBufferLeft();
- if (!aPlaneFront.IsNull())
- {
- aSlicingPlanes.Append (aPlaneFront);
- }
+ // redraw left Eye
+ RedrawScene (thePrintContext, theWorkspace, aLProj, aOrient);
- // add planes at loaded view matrix state
- aContext->ChangeClipping().AddView (aSlicingPlanes, AWorkspace);
- }
- }
-
- // Apply user clipping planes
- if (!myClipPlanes.IsEmpty())
+ // reset depth buffer of first rendering pass
+ if (theWorkspace->UseDepthTest())
{
- Graphic3d_SequenceOfHClipPlane aUserPlanes;
- Graphic3d_SequenceOfHClipPlane::Iterator aClippingIt (myClipPlanes);
- for (; aClippingIt.More(); aClippingIt.Next())
- {
- const Handle(Graphic3d_ClipPlane)& aClipPlane = aClippingIt.Value();
- if (aClipPlane->IsOn())
- {
- aUserPlanes.Append (aClipPlane);
- }
- }
-
- if (!aUserPlanes.IsEmpty())
- {
- // add planes at actual matrix state.
- aContext->ChangeClipping().AddWorld (aUserPlanes);
- }
+ glClear (GL_DEPTH_BUFFER_BIT);
}
+ // safely switch to right Eye buffer
+ aContext->SetDrawBufferRight();
- if (!aManager->IsEmpty())
- {
- aManager->UpdateClippingState();
- }
- }
+ // redraw right Eye
+ RedrawScene (thePrintContext, theWorkspace, aRProj, aOrient);
- // Apply AntiAliasing
- {
- if (myAntiAliasing)
- AWorkspace->NamedStatus |= OPENGL_NS_ANTIALIASING;
- else
- AWorkspace->NamedStatus &= ~OPENGL_NS_ANTIALIASING;
+ // switch back to monographic rendering
+ aContext->SetDrawBufferMono();
}
- // Clear status bitfields
- AWorkspace->NamedStatus &= ~(OPENGL_NS_2NDPASSNEED | OPENGL_NS_2NDPASSDO);
-
- // Added PCT for handling of textures
- switch (mySurfaceDetail)
- {
- case Visual3d_TOD_NONE:
- AWorkspace->NamedStatus |= OPENGL_NS_FORBIDSETTEX;
- AWorkspace->DisableTexture();
- // Render the view
- RenderStructs(AWorkspace);
- break;
-
- case Visual3d_TOD_ENVIRONMENT:
- AWorkspace->NamedStatus |= OPENGL_NS_FORBIDSETTEX;
- AWorkspace->EnableTexture (myTextureEnv);
- // Render the view
- RenderStructs(AWorkspace);
- AWorkspace->DisableTexture();
- break;
-
- case Visual3d_TOD_ALL:
- // First pass
- AWorkspace->NamedStatus &= ~OPENGL_NS_FORBIDSETTEX;
- // Render the view
- RenderStructs(AWorkspace);
- AWorkspace->DisableTexture();
-
- // Second pass
- if (AWorkspace->NamedStatus & OPENGL_NS_2NDPASSNEED)
- {
- AWorkspace->NamedStatus |= OPENGL_NS_2NDPASSDO;
- AWorkspace->EnableTexture (myTextureEnv);
-
- /* sauvegarde de quelques parametres OpenGL */
- GLint blend_dst, blend_src;
- GLint zbuff_f;
- GLboolean zbuff_w;
- glGetBooleanv(GL_DEPTH_WRITEMASK, &zbuff_w);
- glGetIntegerv(GL_DEPTH_FUNC, &zbuff_f);
- glGetIntegerv(GL_BLEND_DST, &blend_dst);
- glGetIntegerv(GL_BLEND_SRC, &blend_src);
- GLboolean zbuff_state = glIsEnabled(GL_DEPTH_TEST);
- GLboolean blend_state = glIsEnabled(GL_BLEND);
-
- glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
- glEnable(GL_BLEND);
-
- glDepthFunc(GL_EQUAL);
- glDepthMask(GL_FALSE);
- glEnable(GL_DEPTH_TEST);
-
- AWorkspace->NamedStatus |= OPENGL_NS_FORBIDSETTEX;
-
- // Render the view
- RenderStructs(AWorkspace);
- AWorkspace->DisableTexture();
-
- /* restauration des parametres OpenGL */
- glBlendFunc(blend_src, blend_dst);
- if (!blend_state) glDisable(GL_BLEND);
-
- glDepthFunc(zbuff_f);
- glDepthMask(zbuff_w);
- if (!zbuff_state) glDisable(GL_DEPTH_FUNC);
- }
- break;
- }
+ // ===============================
+ // Step 5: Trihedron
+ // ===============================
// Resetting GL parameters according to the default aspects
// in order to synchronize GL state with the graphic driver state
// before drawing auxiliary stuff (trihedrons, overlayer)
// and invoking optional callbacks
- AWorkspace->ResetAppliedAspect();
+ theWorkspace->ResetAppliedAspect();
aContext->ChangeClipping().RemoveAll();
// display global trihedron
if (myTrihedron != NULL)
{
- myTrihedron->Render (AWorkspace);
+ myTrihedron->Render (theWorkspace);
}
if (myGraduatedTrihedron != NULL)
{
- myGraduatedTrihedron->Render (AWorkspace);
+ myGraduatedTrihedron->Render (theWorkspace);
}
// Restore face culling
glDisable ( GL_CULL_FACE );
}
- /////////////////////////////////////////////////////////////////////////////
- // Step 6: Draw overlayer
+ // ===============================
+ // Step 6: Redraw overlay
+ // ===============================
+
const int aMode = 0;
- AWorkspace->DisplayCallback (ACView, (aMode | OCC_PRE_OVERLAY));
+ theWorkspace->DisplayCallback (theCView, (aMode | OCC_PRE_OVERLAY));
- RedrawLayer2d (thePrintContext, ACView, ACOverLayer);
+ RedrawLayer2d (thePrintContext, theCView, theCOverLayer);
- AWorkspace->DisplayCallback (ACView, aMode);
+ theWorkspace->DisplayCallback (theCView, aMode);
+
+ // ===============================
+ // Step 7: Finalize
+ // ===============================
// Restore clipping planes
- for ( ptrPlane = oldPlanes, planeid = GL_CLIP_PLANE0; planeid < lastid; planeid++, ptrPlane++ )
+ aClipPlaneId = GL_CLIP_PLANE0;
+ aPtrPlane = aOldPlanes;
+
+ for (; aClipPlaneId < aClipLastId; aClipPlaneId++, aPtrPlane++)
{
- glClipPlane( planeid, ptrPlane->Equation );
- if ( ptrPlane->isEnabled )
- glEnable( planeid );
+ glClipPlane (aClipPlaneId, aPtrPlane->Equation);
+ if (aPtrPlane->isEnabled)
+ glEnable (aClipPlaneId);
else
- glDisable( planeid );
+ glDisable (aClipPlaneId);
}
- delete[] oldPlanes;
+
+ delete[] aOldPlanes;
}
/*----------------------------------------------------------------------*/
Standard_Integer anOldLayer = theStructure->GetZLayer ();
myZLayers.ChangeLayer (theStructure, anOldLayer, theNewLayerId);
}
+
+//=======================================================================
+//function : RedrawScene
+//purpose :
+//=======================================================================
+
+void OpenGl_View::RedrawScene (const Handle(OpenGl_PrinterContext)& thePrintContext,
+ const Handle(OpenGl_Workspace)& theWorkspace,
+ const OpenGl_Matrix* theProjection,
+ const OpenGl_Matrix* theOrientation)
+{
+ const Handle(OpenGl_Context)& aContext = theWorkspace->GetGlContext();
+
+ if (myZClip.Back.IsOn || myZClip.Front.IsOn)
+ {
+ Handle(Graphic3d_ClipPlane) aPlaneBack;
+ Handle(Graphic3d_ClipPlane) aPlaneFront;
+
+ if (myZClip.Back.IsOn)
+ {
+ Standard_Real aClipBackConverted = (Standard_Real )myZClip.Front.Limit + myCamera->Distance();
+ if (myCamera->ZFar() < aClipBackConverted)
+ {
+ aClipBackConverted = myCamera->ZFar();
+ myZClip.Back.Limit = (Standard_ShortReal )(aClipBackConverted - myCamera->Distance());
+ }
+ const Graphic3d_ClipPlane::Equation aBackEquation (0.0, 0.0, 1.0, (Standard_ShortReal )aClipBackConverted);
+ aPlaneBack = new Graphic3d_ClipPlane (aBackEquation);
+ }
+
+ if (myZClip.Front.IsOn)
+ {
+ Standard_Real aClipFrontConverted = (Standard_Real )myZClip.Front.Limit + myCamera->Distance();
+ if (myCamera->ZNear() > aClipFrontConverted)
+ {
+ aClipFrontConverted = myCamera->ZNear();
+ myZClip.Front.Limit = (Standard_ShortReal )(aClipFrontConverted - myCamera->Distance());
+ }
+ const Graphic3d_ClipPlane::Equation aFrontEquation (0.0, 0.0, -1.0, (Standard_ShortReal )-aClipFrontConverted);
+ aPlaneFront = new Graphic3d_ClipPlane (aFrontEquation);
+ }
+
+ // do some "memory allocation"-wise optimization
+ if (!aPlaneBack.IsNull() || !aPlaneFront.IsNull())
+ {
+ Graphic3d_SequenceOfHClipPlane aSlicingPlanes;
+ if (!aPlaneBack.IsNull())
+ {
+ aSlicingPlanes.Append (aPlaneBack);
+ }
+
+ if (!aPlaneFront.IsNull())
+ {
+ aSlicingPlanes.Append (aPlaneFront);
+ }
+
+ // add planes at loaded view matrix state
+ aContext->ChangeClipping().AddView (aSlicingPlanes, theWorkspace);
+ }
+ }
+
+ // Apply user clipping planes
+ if (!myClipPlanes.IsEmpty())
+ {
+ Graphic3d_SequenceOfHClipPlane aUserPlanes;
+ Graphic3d_SequenceOfHClipPlane::Iterator aClippingIt (myClipPlanes);
+ for (; aClippingIt.More(); aClippingIt.Next())
+ {
+ const Handle(Graphic3d_ClipPlane)& aClipPlane = aClippingIt.Value();
+ if (aClipPlane->IsOn())
+ {
+ aUserPlanes.Append (aClipPlane);
+ }
+ }
+
+ if (!aUserPlanes.IsEmpty())
+ {
+ // add planes at actual matrix state.
+ aContext->ChangeClipping().AddWorld (aUserPlanes);
+ }
+
+ if (!aContext->ShaderManager()->IsEmpty())
+ {
+ aContext->ShaderManager()->UpdateClippingState();
+ }
+ }
+
+ // Setup view projection
+ glMatrixMode (GL_PROJECTION);
+
+#ifdef _WIN32
+ // add printing scale/tiling transformation
+ if (!thePrintContext.IsNull())
+ {
+ thePrintContext->LoadProjTransformation();
+ }
+ else
+#endif
+ glLoadIdentity();
+
+ glMultMatrixf ((const GLfloat*)theProjection);
+
+ if (!thePrintContext.IsNull())
+ {
+ // update shader uniform projection matrix with new data
+ Tmatrix3 aResultProjection;
+ glGetFloatv (GL_PROJECTION_MATRIX, *aResultProjection);
+ aContext->ShaderManager()->UpdateProjectionStateTo (&aResultProjection);
+
+ // force shader uniform restore on next frame
+ myProjectionState = 0;
+ }
+
+ // Setup view orientation
+ theWorkspace->SetViewMatrix (theOrientation);
+
+ // Apply Lights
+ {
+ // setup lights
+ Graphic3d_Vec4 anAmbientColor (THE_DEFAULT_AMBIENT[0],
+ THE_DEFAULT_AMBIENT[1],
+ THE_DEFAULT_AMBIENT[2],
+ THE_DEFAULT_AMBIENT[3]);
+ GLenum aLightGlId = GL_LIGHT0;
+ for (OpenGl_ListOfLight::Iterator aLightIt (myLights);
+ aLightIt.More(); aLightIt.Next())
+ {
+ bind_light (aLightIt.Value(), aLightGlId, anAmbientColor);
+ }
+
+ // apply accumulated ambient color
+ anAmbientColor.a() = 1.0f;
+ glLightModelfv (GL_LIGHT_MODEL_AMBIENT, anAmbientColor.GetData());
+
+ if (aLightGlId != GL_LIGHT0)
+ {
+ glEnable (GL_LIGHTING);
+ }
+ // switch off unused lights
+ for (; aLightGlId <= GL_LIGHT7; ++aLightGlId)
+ {
+ glDisable (aLightGlId);
+ }
+ }
+
+ // Clear status bitfields
+ theWorkspace->NamedStatus &= ~(OPENGL_NS_2NDPASSNEED | OPENGL_NS_2NDPASSDO);
+
+ // Added PCT for handling of textures
+ switch (mySurfaceDetail)
+ {
+ case Visual3d_TOD_NONE:
+ theWorkspace->NamedStatus |= OPENGL_NS_FORBIDSETTEX;
+ theWorkspace->DisableTexture();
+ // Render the view
+ RenderStructs (theWorkspace);
+ break;
+
+ case Visual3d_TOD_ENVIRONMENT:
+ theWorkspace->NamedStatus |= OPENGL_NS_FORBIDSETTEX;
+ theWorkspace->EnableTexture (myTextureEnv);
+ // Render the view
+ RenderStructs (theWorkspace);
+ theWorkspace->DisableTexture();
+ break;
+
+ case Visual3d_TOD_ALL:
+ // First pass
+ theWorkspace->NamedStatus &= ~OPENGL_NS_FORBIDSETTEX;
+ // Render the view
+ RenderStructs (theWorkspace);
+ theWorkspace->DisableTexture();
+
+ // Second pass
+ if (theWorkspace->NamedStatus & OPENGL_NS_2NDPASSNEED)
+ {
+ theWorkspace->NamedStatus |= OPENGL_NS_2NDPASSDO;
+ theWorkspace->EnableTexture (myTextureEnv);
+
+ // Remember OpenGl properties
+ GLint aSaveBlendDst, aSaveBlendSrc;
+ GLint aSaveZbuffFunc;
+ GLboolean aSaveZbuffWrite;
+ glGetBooleanv (GL_DEPTH_WRITEMASK, &aSaveZbuffWrite);
+ glGetIntegerv (GL_DEPTH_FUNC, &aSaveZbuffFunc);
+ glGetIntegerv (GL_BLEND_DST, &aSaveBlendDst);
+ glGetIntegerv (GL_BLEND_SRC, &aSaveBlendSrc);
+ GLboolean wasZbuffEnabled = glIsEnabled (GL_DEPTH_TEST);
+ GLboolean wasBlendEnabled = glIsEnabled (GL_BLEND);
+
+ // Change the properties for second rendering pass
+ glBlendFunc (GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
+ glEnable (GL_BLEND);
+
+ glDepthFunc (GL_EQUAL);
+ glDepthMask (GL_FALSE);
+ glEnable (GL_DEPTH_TEST);
+
+ theWorkspace->NamedStatus |= OPENGL_NS_FORBIDSETTEX;
+
+ // Render the view
+ RenderStructs (theWorkspace);
+ theWorkspace->DisableTexture();
+
+ // Restore properties back
+ glBlendFunc (aSaveBlendSrc, aSaveBlendDst);
+ if (!wasBlendEnabled)
+ glDisable (GL_BLEND);
+
+ glDepthFunc (aSaveZbuffFunc);
+ glDepthMask (aSaveZbuffWrite);
+ if (!wasZbuffEnabled)
+ glDisable (GL_DEPTH_FUNC);
+ }
+ break;
+ }
+}
// Alternatively, this file may be used under the terms of Open CASCADE
// commercial license or contractual agreement.
-#include <OpenGl_GlCore11.hxx>
+#include <OpenGl_GlCore12.hxx>
#include <InterfaceGraphic.hxx>
#include <Aspect_GraphicDeviceDefinitionError.hxx>
#include <TCollection_AsciiString.hxx>
+#include <TCollection_ExtendedString.hxx>
IMPLEMENT_STANDARD_HANDLE(OpenGl_Window,MMgt_TShared)
IMPLEMENT_STANDARD_RTTIEXT(OpenGl_Window,MMgt_TShared)
}
int aPixelFrmtId = ChoosePixelFormat (aWindowDC, &aPixelFrmt);
+
+ // in case of failure try without stereo if any
+ if (aPixelFrmtId == 0 && theCaps->contextStereo)
+ {
+ TCollection_ExtendedString aMsg ("OpenGl_Window::CreateWindow: "
+ "ChoosePixelFormat is unable to find stereo supported pixel format. "
+ "Choosing similar non stereo format.");
+ myGlContext->PushMessage (GL_DEBUG_SOURCE_APPLICATION_ARB,
+ GL_DEBUG_TYPE_OTHER_ARB,
+ 0, GL_DEBUG_SEVERITY_HIGH_ARB, aMsg);
+
+ aPixelFrmt.dwFlags &= ~PFD_STEREO;
+ aPixelFrmtId = ChoosePixelFormat (aWindowDC, &aPixelFrmt);
+ }
+
if (aPixelFrmtId == 0)
{
ReleaseDC (aWindow, aWindowDC);
if (aVis != NULL)
{
// check Visual for OpenGl context's parameters compability
- int isGl = 0, isDoubleBuffer = 0, isRGBA = 0, aDepthSize = 0, aStencilSize = 0;
+ int isGl = 0, isDoubleBuffer = 0, isRGBA = 0, isStereo = 0;
+ int aDepthSize = 0, aStencilSize = 0;
if (glXGetConfig (aDisp, aVis, GLX_USE_GL, &isGl) != 0)
isGl = 0;
if (glXGetConfig (aDisp, aVis, GLX_DOUBLEBUFFER, &isDoubleBuffer) != 0)
isDoubleBuffer = 0;
+ if (glXGetConfig (aDisp, aVis, GLX_STEREO, &isStereo) != 0)
+ isStereo = 0;
+
if (glXGetConfig (aDisp, aVis, GLX_DEPTH_SIZE, &aDepthSize) != 0)
aDepthSize = 0;
if (glXGetConfig (aDisp, aVis, GLX_STENCIL_SIZE, &aStencilSize) != 0)
aStencilSize = 0;
- if (!isGl || !aDepthSize || !aStencilSize || !isRGBA || (isDoubleBuffer ? 1 : 0) != (myDisplay->DBuffer()? 1 : 0))
+ if (!isGl || !aDepthSize || !isRGBA || !aStencilSize ||
+ (isDoubleBuffer ? 1 : 0) != (myDisplay->DBuffer() ? 1 : 0) ||
+ (isStereo ? 1 : 0) != (theCaps->contextStereo ? 1 : 0))
{
XFree (aVis);
aVis = NULL;
if (myDisplay->DBuffer())
anAttribs[anIter++] = GLX_DOUBLEBUFFER;
+ // warning: this flag may be set to None, so it need to be last in anAttribs
+ Standard_Integer aStereoFlagPos = anIter;
+ if (theCaps->contextStereo)
+ anAttribs[anIter++] = GLX_STEREO;
+
anAttribs[anIter++] = None;
aVis = glXChooseVisual (aDisp, scr, anAttribs);
+
+ // in case of failure try without stereo if any
+ if (aVis == NULL && theCaps->contextStereo)
+ {
+ TCollection_ExtendedString aMsg ("OpenGl_Window::CreateWindow: "
+ "glXChooseVisual is unable to find stereo supported pixel format. "
+ "Choosing similar non stereo format.");
+ myGlContext->PushMessage (GL_DEBUG_SOURCE_APPLICATION_ARB,
+ GL_DEBUG_TYPE_OTHER_ARB,
+ 0, GL_DEBUG_SEVERITY_HIGH_ARB, aMsg);
+
+ anAttribs[aStereoFlagPos] = None;
+ aVis = glXChooseVisual (aDisp, scr, anAttribs);
+ }
+
if (aVis == NULL)
{
Aspect_GraphicDeviceDefinitionError::Raise ("OpenGl_Window::CreateWindow: glXChooseVisual failed.");
* code for simplicity.)
*/
+ if ((myGlContext->myGlVerMajor >= 1) && (myGlContext->myGlVerMinor >= 2))
+ {
#ifdef GL_EXT_convolution
- glDisable(GL_CONVOLUTION_1D_EXT);
- glDisable(GL_CONVOLUTION_2D_EXT);
- glDisable(GL_SEPARABLE_2D_EXT);
+ if (myGlContext->CheckExtension ("GL_CONVOLUTION_1D_EXT"))
+ glDisable(GL_CONVOLUTION_1D_EXT);
+
+ if (myGlContext->CheckExtension ("GL_CONVOLUTION_2D_EXT"))
+ glDisable(GL_CONVOLUTION_2D_EXT);
+
+ if (myGlContext->CheckExtension ("GL_SEPARABLE_2D_EXT"))
+ glDisable(GL_SEPARABLE_2D_EXT);
#endif
#ifdef GL_EXT_histogram
- glDisable(GL_HISTOGRAM_EXT);
- glDisable(GL_MINMAX_EXT);
+ if (myGlContext->CheckExtension ("GL_SEPARABLE_2D_EXT"))
+ glDisable(GL_HISTOGRAM_EXT);
+
+ if (myGlContext->CheckExtension ("GL_MINMAX_EXT"))
+ glDisable(GL_MINMAX_EXT);
#endif
#ifdef GL_EXT_texture3D
- glDisable(GL_TEXTURE_3D_EXT);
+ if (myGlContext->CheckExtension ("GL_TEXTURE_3D_EXT"))
+ glDisable(GL_TEXTURE_3D_EXT);
#endif
+ }
}
// =======================================================================
Handle(OpenGl_Context) aGlCtx = GetGlContext();
aGlCtx->ReleaseDelayed();
- // cache render mode state
- GLint aRendMode = GL_RENDER;
- glGetIntegerv (GL_RENDER_MODE, &aRendMode);
- aGlCtx->SetFeedback (aRendMode == GL_FEEDBACK);
+ // fetch OpenGl context state
+ aGlCtx->FetchState();
- Tint toSwap = (aRendMode == GL_RENDER); // swap buffers
+ Tint toSwap = (aGlCtx->IsRender()); // swap buffers
GLint aViewPortBack[4];
OpenGl_FrameBuffer* aFrameBuffer = (OpenGl_FrameBuffer* )theCView.ptrFBO;
if (aFrameBuffer != NULL)
#endif
// reset render mode state
- aGlCtx->SetFeedback (Standard_False);
+ aGlCtx->FetchState();
}
theWidth = (Standard_Integer)aMaxX;
theHeight = (Standard_Integer)aMaxY;
}
-// ---------------------------------------------------------------
-// Function: getDimensionsTiling
-// Purpose: calculate maximum possible dimensions for framebuffer
-// in tiling mode according to the view size
-// ---------------------------------------------------------------
-static void getDimensionsTiling (Standard_Integer& theFrameWidth,
- Standard_Integer& theFrameHeight,
- const int theViewWidth,
- const int theViewHeight)
-{
- // fit the maximum dimensions into the printing area
- if (theFrameWidth > theViewWidth)
- theFrameWidth = theViewWidth;
- if (theFrameHeight > theViewHeight)
- theFrameHeight = theViewHeight;
-}
// ---------------------------------------------------------------
// Function: initBufferStretch
// Purpose: calculate initialization sizes for frame buffer
}
else if (IsTiling)
{
- getDimensionsTiling (aFrameWidth, aFrameHeight, width, height);
- if (aPrevWidth >= aFrameWidth && aPrevHeight >= aFrameHeight)
- isUsable = true;
+ // use previous frame buffer with its dimensions
+ aFrameWidth = aPrevWidth;
+ aFrameHeight = aPrevHeight;
+ isUsable = true;
}
// if it is enough memory for image paste dc operation
{
if (aRevert)
{
- myGlContext->ShaderManager()->RevertModelWorldStateTo (lmat.mat);
+ myGlContext->ShaderManager()->RevertModelWorldStateTo (&lmat.mat);
}
else
{
- myGlContext->ShaderManager()->UpdateModelWorldStateTo (lmat.mat);
+ myGlContext->ShaderManager()->UpdateModelWorldStateTo (&lmat.mat);
}
}
1.f);
aOrigin = MatVecMult (theInvModelProj, aOrigin);
+ aOrigin.x() = aOrigin.x() / aOrigin.w();
+ aOrigin.y() = aOrigin.y() / aOrigin.w();
+ aOrigin.z() = aOrigin.z() / aOrigin.w();
+ aOrigin.w() = 1.f;
OpenGl_RTVec4f aDirect (float(x),
float(y),
1.f,
1.f);
- aDirect = MatVecMult (theInvModelProj, aDirect) - aOrigin;
+ aDirect = MatVecMult (theInvModelProj, aDirect);
+ aDirect.x() = aDirect.x() / aDirect.w();
+ aDirect.y() = aDirect.y() / aDirect.w();
+ aDirect.z() = aDirect.z() / aDirect.w();
+ aDirect.w() = 1.f;
+
+ aDirect = aDirect - aOrigin;
GLdouble aInvLen = 1.f / sqrt (aDirect.x() * aDirect.x() +
aDirect.y() * aDirect.y() +
TColStd_Array2OfReal theOrientation (0, 3, 0, 3);
TColStd_Array2OfReal theViewMapping (0, 3, 0, 3);
- myView->GetMatrices (theOrientation, theViewMapping, Standard_True);
+ myView->GetMatrices (theOrientation, theViewMapping);
GLdouble aOrientationMatrix[16];
GLdouble aViewMappingMatrix[16];
+++ /dev/null
-// Copyright (c) 1999-2014 OPEN CASCADE SAS
-//
-// This file is part of Open CASCADE Technology software library.
-//
-// This library is free software; you can redistribute it and / or modify it
-// under the terms of the GNU Lesser General Public version 2.1 as published
-// by the Free Software Foundation, with special exception defined in the file
-// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
-// distribution for complete text of the license and disclaimer of any warranty.
-//
-// Alternatively, this file may be used under the terms of Open CASCADE
-// commercial license or contractual agreement.
-
-/***********************************************************************
-
-FONCTION :
-----------
-File OpenGl_telem_view :
-
-************************************************************************/
-
-#include <OpenGl_GlCore11.hxx>
-#include <OpenGl_telem_view.hxx>
-#include <OpenGl_telem_util.hxx>
-#include <OpenGl_Display.hxx>
-
-static void
-EvalViewMappingMatrix (const Handle(OpenGl_Display)& theGlDisplay,
- tel_view_mapping mapping /* View Mapping */,
- Tint* error_ind /* Out: Error Indicator */,
- Tmatrix3 mat /* Out: Mapping Matrix * */,
- Tint flag,
- Tfloat cx,
- Tfloat cy,
- Tint /*clip_flag*/,
- Tlimit3* /*clip_limit*/
- )
-{
- Tfloat gx, gy, xsf, ysf, zsf;
- Tfloat fpd, bpd;
-
- /* OCC18942 */
- Tfloat n, f, r, l, t, b, Zprp, dx, dy, VPD;
-
- /* FSXXX */
- /* GLint gdtmp; */
- Tlimit3 vp = { ( float )-1.0, ( float )1.0, ( float )-1.0, ( float )1.0, ( float )1.0, ( float )-1.0 };
- Tmatrix3 pmat = { { ( float )1.0, ( float )0.0, ( float )0.0, ( float )0.0 },
- { ( float )0.0, ( float )1.0, ( float )0.0, ( float )0.0 },
- { ( float )0.0, ( float )0.0, ( float )1.0, ( float )0.0 },
- { ( float )0.0, ( float )0.0, ( float )0.0, ( float )1.0 } };
- Tmatrix3 mmat = { { ( float )1.0, ( float )0.0, ( float )0.0, ( float )0.0 },
- { ( float )0.0, ( float )1.0, ( float )0.0, ( float )0.0 },
- { ( float )0.0, ( float )0.0, ( float )1.0, ( float )0.0 },
- { ( float )0.0, ( float )0.0, ( float )0.0, ( float )1.0 } };
-
- fpd = mapping->fpd;
- bpd = mapping->bpd;
-
- /* invalid window */
- if( mapping->window.xmin >= mapping->window.xmax ||
- mapping->window.ymin >= mapping->window.ymax )
- {
- *error_ind = 1;
- return;
- }
-
- /* invalid viewport */
- if( mapping->viewport.xmin >= mapping->viewport.xmax ||
- mapping->viewport.ymin >= mapping->viewport.ymax ||
- mapping->viewport.zmin >= mapping->viewport.zmax )
- {
- *error_ind = 2;
- return;
- }
-
- /* invalid back/front plane distances */
- if( mapping->bpd >= mapping->fpd )
- {
- *error_ind = 3;
- return;
- }
-
- /* prp between front and back planes */
- if (theGlDisplay.IsNull() || !theGlDisplay->Walkthrough())
- {
- if( mapping->prp[2] < mapping->fpd &&
- mapping->prp[2] > mapping->bpd )
- {
- *error_ind = 4;
- return;
- }
- }
-
- if( mapping->prp[2] == mapping->vpd )
- {
- *error_ind = 5; /* prp on view plane */
- return;
- }
-
- if( mapping->viewport.xmin < 0 ||
- mapping->viewport.xmax > 1 ||
- mapping->viewport.ymin < 0 ||
- mapping->viewport.ymax > 1 ||
- mapping->viewport.zmin < 0 ||
- mapping->viewport.zmax > 1 )
- {
- *error_ind = 6; /* viewport limits outside NPC space */
- return;
- }
-
- *error_ind = 0;
-
- /* OCC18942: Moved here while debugging perspective projection matrix */
- /* centers */
- if( flag == 0 )
- {
- cx = mapping->window.xmin + mapping->window.xmax, cx /= ( float )2.0;
- cy = mapping->window.ymin + mapping->window.ymax, cy /= ( float )2.0;
- }
-
- gx = (cx - mapping->prp[0]) / (mapping->vpd - mapping->prp[2]);
- gy = (cy - mapping->prp[1]) / (mapping->vpd - mapping->prp[2]);
-
-#ifdef PRINT
- printf("EvalViewMappingMatrix \n");
- printf("prp %f %f %f \n", mapping->prp[0], mapping->prp[1], mapping->prp[2]);
- printf("vpd fpd bpd %f %f %f \n", mapping->vpd, mapping->fpd, mapping->bpd);
- printf("window limit %f %f %f %f\n", mapping->window.xmin, mapping->window.xmax,
- mapping->window.ymin, mapping->window.ymax);
- printf("viewport limit %f %f %f %f\n", mapping->viewport.xmin, mapping->viewport.xmax,
- mapping->viewport.ymin, mapping->viewport.ymax);
-#endif
-
- /* projection matrix */
- if( mapping->proj == TelParallel )
- {
-
- pmat[2][0] = -gx; pmat[3][0] = mapping->vpd*gx;
- pmat[2][1] = -gy; pmat[3][1] = mapping->vpd*gy;
- }
- else if (!theGlDisplay.IsNull() && !theGlDisplay->SymPerspective())/* TelPerspective */
- {
- pmat[0][0] = pmat[1][1] = mapping->prp[2] - mapping->vpd;
- pmat[2][0] = -gx;
- pmat[2][1] = -gy;
- pmat[2][3] = ( float )-1.0;
- pmat[3][0] = mapping->vpd * gx;
- pmat[3][1] = mapping->vpd * gy;
- pmat[3][3] = mapping->prp[2];
-
- /* modify the next two cells to change clipping policy */
- if (!theGlDisplay.IsNull() && !theGlDisplay->Walkthrough())
- {
- pmat[2][2] = mapping->prp[2] - ( fpd + bpd );
- pmat[3][2] = fpd * bpd;
- }
- }
- /* OCC18942: New approach to calculation of mapping (projection) matrix */
- else
- {
- dx = mapping->window.xmax - mapping->window.xmin;
- dy = mapping->window.ymax - mapping->window.ymin;
- Zprp = mapping->prp[2];
- VPD = Zprp - mapping->vpd;
-
- /*
- Calculate canonical perspective projection parameters as if we were about
- to use glFrustum() to create symmetric perspective frustum.
-
- After the view orientation matrix is applied, the coordinate system origin is located
- at the VRP and oriented properly. However, the viewplane has width = dx and height = dy
- and its center (cx, cy, VPD) is not always located at the view Z axis.
- The canonical perspective projection matrix assumes the eye is located at (0, 0, 0).
- Thus the old approach resulted in a non-symmetric perspective,
- as X and Y coordinates of the projection reference point (PRP) were not updated
- when cx and cy changed. Moreover, such "static" perspective had some other disadvantages,
- such as non-realistic panning, i.e. instead of moving the eye (or camera) over the model
- a sort of "frame" moved over the static perspective projection picture,
- exposing a part of this static picture to the user.
-
- In order to make the perspective symmetric, we need to translate
- the coordinate system to PRP before projection.
- Thus we translate X, Y and Z co-ordinates by -cx, -cy and -Zprp respectively.
-
- NOTE: mat[i][j] means j-th element of i-th column, as OpenGL accepts the matrices
- in column-major order, while in C two-dimensional arrays are stored in memory
- in row-major order!
-
- VPD is used below instead of near clipping plane dispance (n) in order to simplify
- calculation of l and r values. If we did not use VPD in the matrix calculation, we would have to
- project 0.5 * dx, -0.5 * dx, 0.5 * dy and - 0.5 * dy onto the near clipping plane
- to calculate these values.
-
- Pending issues:
- 1. It is still necessary to find a way to calculate the perspective projection matrix
- for TPM_WALKTHROUGH projection model. This projection model is not supported yet
- by the new code.
- */
- r = .5f * dx;
- l = -r;
- t = .5f * dy;
- b = -t;
- n = Zprp - fpd; f = Zprp - bpd;
-
- mat[0][0] = 2.f * VPD / (r - l);
- mat[1][1] = 2.f * VPD / (t - b);
- mat[2][0] = (r + l) / (r - l);
- mat[2][1] = (t + b) / (t - b);
- mat[2][2] = - (f + n) / (f - n);
- mat[2][3] = -1.f;
- /*
- The last column takes into account translation along X, Y and Z axis
- before projecting. This can be considered as a result of right-multiplying the canonical
- perspective projection matrix P by a translation matrix T
- (it differs form the canonical matrix by the last column only):
- | 1 0 0 -cx |
- | 0 1 0 -cy |
- mat = P * T, where T = | 0 0 1 -Zprp |
- | 0 0 0 1 |
- */
- mat[3][0] = -mat[2][0] * Zprp - mat[0][0] * cx;
- mat[3][1] = -mat[2][1] * Zprp - mat[1][1] * cy;
- mat[3][2] = -2.f * f * n / (f - n) - mat[2][2] * Zprp;
- mat[3][3] = Zprp;
-
-#ifdef PRINT
- printf("r l t b n f: %f %f %f %f %f %f \n", r,l,t,b,n,f);
- printf( "mapping_matrix (new code):\n" );
- pr_matrix(mat);
-#endif
-
- /* return here, as further calculations are related to the old approach */
- return;
- }
-
- /* scale factors */
- xsf = (vp.xmax - vp.xmin) / (mapping->window.xmax - mapping->window.xmin);
- ysf = (vp.ymax - vp.ymin) / (mapping->window.ymax - mapping->window.ymin);
- zsf = (vp.zmax - vp.zmin) / (fpd - bpd);
-
- /* map matrix */
- mmat[0][0] = xsf, mmat[1][1] = ysf, mmat[2][2] = zsf;
- mmat[3][0] = vp.xmin - xsf*mapping->window.xmin;
- mmat[3][1] = vp.ymin - ysf*mapping->window.ymin;
- mmat[3][2] = vp.zmin - zsf*bpd;
-
- /* multiply to obtain mapping matrix */
- TelMultiplymat3( mat, pmat, mmat );
-
-#ifdef PRINT
- printf( "mapping_matrix :\n" );
- pr_matrix(mat);
-#endif
-}
-
-void
-TelEvalViewOrientationMatrix( Tfloat *vrp /* View Reference Point */,
- Tfloat *vpn /* View Plane Normal */,
- Tfloat *vup /* View Up Vector */,
- Tfloat *asf /* Axial Scale Factors */,
- Tint *error_ind/* Out: Error indicator */,
- Tmatrix3 rmat /* Out: Orientation Matrix */
- )
-{
- Tfloat u[3], v[3], n[3], f;
-
- /* view plane normal of zero length */
- if( vecmag(vpn) == 0.0 )
- {
- *error_ind = 1;
- return;
- }
-
- /* view up vector of zero length */
- if( vecmag(vup) == 0.0 )
- {
- *error_ind = 2;
- return;
- }
-
- /* view up vector parallel to view plane normal */
- vecang(vup, vpn, f);
- if( f == 0.0 )
- {
- *error_ind = 3;
- return;
- }
-
- *error_ind = 0;
-
- veccpy(n, vpn);
- veccpy(v, vup);
- vecnrm(n);
-
- veccrs(u,v,n); /* up vector cross plane normal gives U axis */
- vecnrm(u);
-
- veccrs(v,n,u); /* plane normal cross U axis gives modified up vector */
- vecnrm(v); /* redundant ? */
-
- /* rotate to align along u, v, n */
- rmat[0][0] = ( float )u[0] * asf[0],
- rmat[0][1] = ( float )v[0] * asf[0],
- rmat[0][2] = ( float )n[0] * asf[0],
- rmat[0][3] = ( float )0.0;
-
- rmat[1][0] = ( float )u[1] * asf[1],
- rmat[1][1] = ( float )v[1] * asf[1],
- rmat[1][2] = ( float )n[1] * asf[1],
- rmat[1][3] = ( float )0.0;
-
- rmat[2][0] = ( float )u[2] * asf[2],
- rmat[2][1] = ( float )v[2] * asf[2],
- rmat[2][2] = ( float )n[2] * asf[2],
- rmat[2][3] = ( float )0.0;
-
- /* translate to centre at vrp */
-
- rmat[3][0] = - ( float ) (u[0]*vrp[0] + u[1]*vrp[1] + u[2]*vrp[2]);
- rmat[3][1] = - ( float ) (v[0]*vrp[0] + v[1]*vrp[1] + v[2]*vrp[2]);
- rmat[3][2] = - ( float ) (n[0]*vrp[0] + n[1]*vrp[1] + n[2]*vrp[2]);
- rmat[3][3] = ( float )1.0;
-
-#ifdef PRINT
- printf("TelEvalViewOrientationMatrix \n");
- printf("view_ref_pt %f %f %f \n", vrp[0], vrp[1], vrp[2]);
- printf("view_up_vec %f %f %f \n", vup[0], vup[1], vup[2]);
- printf("view_plane_normal %f %f %f \n", vpn[0], vpn[1], vpn[2]);
- pr_matrix(rmat);
-#endif
-
- return;
-}
-
-void TelEvalViewMappingMatrix (const Handle(OpenGl_Display)& theGlDisplay,
- tel_view_mapping mapping /* View Mapping */,
- Tint *error_ind /* Out: Error Indicator */,
- Tmatrix3 mat /* Out: Mapping Matrix */
- )
-{
- EvalViewMappingMatrix (theGlDisplay, mapping, error_ind, mat, 0, ( float )0.0, ( float )0.0, 0, 0);
-}
+++ /dev/null
-// Copyright (c) 1995-1999 Matra Datavision
-// Copyright (c) 1999-2014 OPEN CASCADE SAS
-//
-// This file is part of Open CASCADE Technology software library.
-//
-// This library is free software; you can redistribute it and / or modify it
-// under the terms of the GNU Lesser General Public version 2.1 as published
-// by the Free Software Foundation, with special exception defined in the file
-// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
-// distribution for complete text of the license and disclaimer of any warranty.
-//
-// Alternatively, this file may be used under the terms of Open CASCADE
-// commercial license or contractual agreement.
-
-/***********************************************************************
-
-FONCTION :
-----------
-File OpenGl_telem_view.h :
-
-
-REMARQUES:
-----------
-
-
-HISTORIQUE DES MODIFICATIONS :
---------------------------------
-xx-xx-xx : xxx ; Creation.
-02-07-96 : FMN ; Suppression WSWSHeight et WSWSWidth
-Suppression de TelSetWSWindow
-03-07-96 : FMN ; A une workstation correspond une vue.
-Suppression de TelGetViewportAtLocation()
-Suppression de TelPrintAllViews()
-03-03-98 : FMN ; Suppression variable externe TglWhetherPerspective
-
-************************************************************************/
-
-#ifndef OPENGL_TELEM_VIEW_H
-#define OPENGL_TELEM_VIEW_H
-
-#include <InterfaceGraphic_tgl_all.hxx>
-#include <Handle_OpenGl_Display.hxx>
-
-typedef struct
-{
- Tfloat xmin;
- Tfloat xmax;
- Tfloat ymin;
- Tfloat ymax;
-} Tlimit;
-
-typedef struct
-{
- Tfloat xmin;
- Tfloat xmax;
- Tfloat ymin;
- Tfloat ymax;
- Tfloat zmin;
- Tfloat zmax;
-} Tlimit3;
-
-typedef enum
-{
- TelParallel, TelPerspective
-} TelProjType;
-
-typedef struct
-{
- Tlimit window;
- Tlimit3 viewport;
- TelProjType proj;
- Tfloat prp[3];
- Tfloat vpd;
- Tfloat fpd;
- Tfloat bpd;
-} TEL_VIEW_MAPPING, *tel_view_mapping;
-
-extern void /* vrp, vpn, vup, error_ind, mat */
-TelEvalViewOrientationMatrix(Tfloat*, Tfloat*, Tfloat*, Tfloat*, Tint*, Tmatrix3);
-
-extern void /* mapping, error_ind, mat */
-TelEvalViewMappingMatrix (const Handle(OpenGl_Display)& theGlDisplay, tel_view_mapping theMapping, Tint* theError, Tmatrix3 theMat);
-
-#endif
#include <PrsMgr_Prs.hxx>
#include <PrsMgr_ModedPresentation.hxx>
#include <Visual3d_View.hxx>
-#include <Visual3d_ViewOrientation.hxx>
#include <Graphic3d_Structure.hxx>
#include <Precision.hxx>
//purpose :
//=======================================================================
-Handle(Prs3d_Projector) PrsMgr_Presentation3d::Projector(const Handle(Graphic3d_DataStructureManager)& aProjector) {
- Visual3d_ViewOrientation VO = Handle(Visual3d_View)::DownCast(aProjector)->ViewOrientation();
+Handle(Prs3d_Projector) PrsMgr_Presentation3d::Projector(const Handle(Graphic3d_DataStructureManager)& aProjector)
+{
+ const Handle(Graphic3d_Camera)& aCamera = Handle(Visual3d_View)::DownCast (aProjector)->Camera();
+
Standard_Real DX, DY, DZ,XAt, YAt , ZAt,XUp, YUp, ZUp;
- VO.ViewReferencePlane().Coord(DX, DY, DZ);
- VO.ViewReferencePoint().Coord(XAt,YAt,ZAt);
- VO.ViewReferenceUp().Coord(XUp, YUp, ZUp);
- Visual3d_ViewMapping VM = Handle(Visual3d_View)::DownCast(aProjector)->ViewMapping();
- Standard_Boolean pers = (VM.Projection() == Visual3d_TOP_PERSPECTIVE);
- Standard_Real focale = 0.0 ;
- if (pers) {
- Standard_Real Xrp,Yrp,Zrp,ViewPlane,FrontPlane ;
- Graphic3d_Vertex Prp = VM.ProjectionReferencePoint() ;
- Prp.Coord(Xrp,Yrp,Zrp);
- FrontPlane = VM.FrontPlaneDistance() ;
- ViewPlane = VM.ViewPlaneDistance() ;
- focale = FrontPlane + Zrp - ViewPlane ;
- }
- Handle(Prs3d_Projector) Proj = new Prs3d_Projector(pers,focale,DX, DY, DZ,XAt, YAt , ZAt,XUp, YUp, ZUp);
- return Proj;
+ gp_Dir aDir = aCamera->Direction().Reversed();
+ DX = aDir.X(); DY = aDir.Y(); DZ = aDir.Z();
+
+ gp_Pnt anAt = aCamera->Center();
+ XAt = anAt.X(); YAt = anAt.Y(); ZAt = anAt.Z();
+
+ gp_Dir anUp = aCamera->Up();
+ XUp = anUp.X(); YUp = anUp.Y(); ZUp = anUp.Z();
+
+ Standard_Boolean pers = !aCamera->IsOrthographic();
+ Standard_Real focale = aCamera->Scale();
+
+ Handle(Prs3d_Projector) aProj =
+ new Prs3d_Projector(pers, focale, DX, DY, DZ, XAt, YAt, ZAt, XUp, YUp, ZUp);
+ return aProj;
}
//=======================================================================
Select3D_Projector::Select3D_Projector(const Handle(V3d_View)& aViou)
-: myPersp(aViou->Type()==V3d_PERSPECTIVE),
- myFocus(aViou->Focale()),
- myView(aViou)
+ : myView (aViou)
{
- Standard_Real Xat,Yat,Zat,XUp,YUp,ZUp,DX,DY,DZ;
- //Standard_Boolean Pers=Standard_False;
-
- aViou->At(Xat,Yat,Zat);
- aViou->Up(XUp,YUp,ZUp);
- aViou->Proj(DX,DY,DZ);
- gp_Pnt At (Xat,Yat,Zat);
- gp_Dir Zpers (DX,DY,DZ);
- gp_Dir Ypers (XUp,YUp,ZUp);
- gp_Dir Xpers = Ypers.Crossed(Zpers);
- gp_Ax3 Axe (At, Zpers, Xpers);
- myScaledTrsf.SetTransformation(Axe);
- myGTrsf.SetTrsf(myScaledTrsf);
- Scaled();
-
}
//=======================================================================
{
gp_Lin L;
- if (myPersp) {
- L = gp_Lin(gp_Pnt(0,0, myFocus),
- gp_Dir(X,Y,-myFocus));
+ if (!myView.IsNull())
+ {
+ Handle(Graphic3d_Camera) aCamera = myView->Camera();
+
+ Standard_Real aUMin, aVMin, aUMax, aVMax;
+ aCamera->WindowLimit (aUMin, aVMin, aUMax, aVMax);
+
+ gp_Pnt aPos = aCamera->ConvertView2World (gp_Pnt (X, Y, 1.0));
+ gp_Pnt aEyePos = aCamera->Eye();
+
+ gp_Dir aDir;
+
+ if (aCamera->IsOrthographic())
+ {
+ aDir = aCamera->Direction();
+ }
+ else
+ {
+ aDir = gp_Dir (aPos.X() - aEyePos.X(),
+ aPos.Y() - aEyePos.Y(),
+ aPos.Z() - aEyePos.Z());
+ }
+
+ L = gp_Lin (aPos, aDir);
}
- else {
- L = gp_Lin(gp_Pnt(X,Y,0),
- gp_Dir(0,0,-1));
+ else
+ {
+ if (myPersp) {
+ L = gp_Lin(gp_Pnt(0,0, myFocus),
+ gp_Dir(X,Y,-myFocus));
+ }
+ else {
+ L = gp_Lin(gp_Pnt(X,Y,0),
+ gp_Dir(0,0,-1));
+ }
+
+ Transform(L, myInvTrsf);
}
- Transform(L, myInvTrsf);
+
+
return L;
}
#include <gp_Pnt.hxx>
#include <gp_Dir.hxx>
#include <gp_Ax3.hxx>
-#include <V3d_PerspectiveView.hxx>
#include <StdSelect_BRepOwner.hxx>
Handle(Select3D_Projector) StdSelect::GetProjector(const Handle(V3d_View)& aViou)
#include <gp_Ax3.hxx>
#include <gp_GTrsf.hxx>
#include <gp_Pln.hxx>
-#include <V3d_PerspectiveView.hxx>
#include <Select3D_SensitiveEntity.hxx>
#include <Graphic3d_ArrayOfPolylines.hxx>
#include <Graphic3d_SequenceOfHClipPlane.hxx>
mycenter[jmod] = myprevcenter[jmod];
}
- gp_Dir Zpers (mycoeff[6], mycoeff[7], mycoeff[8]);
- gp_Dir Ypers (mycoeff[3], mycoeff[4], mycoeff[5]);
- gp_Dir Xpers = Ypers.Crossed (Zpers);
- gp_XYZ loc (mycoeff[0], mycoeff[1], mycoeff[2]);
- gp_Mat matrix;
- matrix.SetCols (Xpers.XYZ(), Ypers.XYZ(), Zpers.XYZ());
- gp_Mat matScale (mycoeff[11], 0, 0, 0, mycoeff[12], 0, 0, 0, mycoeff[13]);
- matrix.Transpose();
- loc.Multiply (matrix);
- loc.Reverse ();
- matrix.Multiply (matScale);
- gp_GTrsf GT;
- GT.SetTranslationPart (loc);
- GT.SetVectorialPart (matrix);
-
- myprj = new Select3D_Projector (GT, Pers, mycoeff[9]);
-
- // SAV 08/05/02 : fix for detection problem in a perspective view
- if (aView->Type() == V3d_PERSPECTIVE)
- myprj->SetView (aView);
- // NKV 31/07/07 : fix for detection problem in case of custom matrix
- else if (aView->ViewOrientation().IsCustomMatrix())
- myprj->SetView (aView);
+ myprj = new Select3D_Projector (aView);
+
}
if (Abs (aView->Scale() - mylastzoom) > 1.e-3)
-- of the 3D Viewer. It provides a set of high level commands
-- to control the views and viewing modes. This package is
-- complementary to the Visual3D graphic package.
- -- Warning
- -- The CSF_WALKTHROUGH variable enables you to
- -- manage the perspective of the view in the viewer by
- -- defining setenv CSF_WALKTHROUGH "Yes".
- -- If you use the syntax unsetenv
- -- CSF_WALKTHROUGH, you undefine the variable
- -- (you make sure that the variable is deactivated). In
- -- this case, the eye is located outside the 3D bounding
- -- box of the view. This is the default behavior for
- -- managing the view perspective.
-
uses
TColStd,
-- TOBM_ALWAYS_DISPLAYED force display of back faces
-- TOBM_NEVER_DISPLAYED disable display of back faces
+ enumeration StereoDumpOptions is
+ SDO_MONO,
+ SDO_LEFT_EYE,
+ SDO_RIGHT_EYE
+ end StereoDumpOptions;
+ ---Purpose : Options to be used with image dumping.
+ --
+ -- SDO_MONO dump monographic projection for stereo camera
+ -- SDO_LEFT_EYE dump left eye projection for stereo camera
+ -- SDO_RIGHT_EYE dump right eye projection for stereo camera
+
------------------------
---Category: The classes
------------------------
class View;
---Purpose: Provides a set of services common to all types of view.
- class OrthographicView;
- ---Purpose: Services of an orthogonal view.
-
- class PerspectiveView;
- ---Purpose: Services of a perspective view.
-
class LayerMgr;
---Purpose: Services of layer management.
+++ /dev/null
--- Created on: 1992-01-21
--- Created by: GG
--- Copyright (c) 1992-1999 Matra Datavision
--- Copyright (c) 1999-2014 OPEN CASCADE SAS
---
--- This file is part of Open CASCADE Technology software library.
---
--- This library is free software; you can redistribute it and / or modify it
--- under the terms of the GNU Lesser General Public version 2.1 as published
--- by the Free Software Foundation, with special exception defined in the file
--- OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
--- distribution for complete text of the license and disclaimer of any warranty.
---
--- Alternatively, this file may be used under the terms of Open CASCADE
--- commercial license or contractual agreement.
-
-class OrthographicView from V3d
-
- ---Version:
-
- ---Purpose: Define an orthographic view.
- -- See the methods of the Class View
-
- ---Keywords: View,Orthographic
-
- ---Warning:
-
- ---References:
-
-
-inherits View from V3d
-
-uses
-
- Viewer from V3d,
- PerspectiveView from V3d
-
-is
-
- Create ( VM : mutable Viewer ) returns mutable OrthographicView;
- ---Level : Public
- ---Purpose: Define an orthographic view in the viewer VM.
-
- Create ( VM : mutable Viewer ; V : PerspectiveView )
- returns mutable OrthographicView;
- ---Level : Public
- ---Purpose: Defines an orthographic view from a Perspective view.
- -- The parameters of the original view are duplicated
- -- in the resulting view (Projection,Mapping,Context) .
- -- The view thus created must be activated in a new
- -- window.
-
- Create ( VM : mutable Viewer ; V : OrthographicView )
- returns mutable OrthographicView;
- ---Level : Public
- ---Purpose: Defines one orthographic view from another.
- -- The parameters of the original view are duplicated
- -- in the resulting view. (Projection,Mapping,Context) .
- -- The view thus created must be activated in a new window.
-
- Copy ( me ) returns mutable OrthographicView from V3d is static;
- ---Level : Public
-end OrthographicView;
+++ /dev/null
-// Created by: GG
-// Copyright (c) 1991-1999 Matra Datavision
-// Copyright (c) 1999-2014 OPEN CASCADE SAS
-//
-// This file is part of Open CASCADE Technology software library.
-//
-// This library is free software; you can redistribute it and / or modify it
-// under the terms of the GNU Lesser General Public version 2.1 as published
-// by the Free Software Foundation, with special exception defined in the file
-// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
-// distribution for complete text of the license and disclaimer of any warranty.
-//
-// Alternatively, this file may be used under the terms of Open CASCADE
-// commercial license or contractual agreement.
-
-// Modified 25-02-98 : FMN ; PERF.27: Optimization of view creation from an existing view
-
-
-//-Version
-
-//-Design
-
-//-Warning
-
-//-References
-
-//-Language C++ 2.1
-
-// for Test method
-
-// for the class
-#include <V3d_View.hxx>
-#include <V3d_OrthographicView.ixx>
-#include <V3d_PerspectiveView.hxx>
-
-//-Declarations
-
-//-Aliases
-
-//-Global data definitions
-
-//-Constructors
-
-V3d_OrthographicView::V3d_OrthographicView (const Handle(V3d_Viewer)& VM):V3d_View (VM) {
-
- MyType = V3d_ORTHOGRAPHIC ;
- MyViewMapping.SetProjection(Visual3d_TOP_PARALLEL) ;
- SetViewMappingDefault() ;
- SetViewOrientationDefault() ;
-}
-
-V3d_OrthographicView::V3d_OrthographicView (const Handle(V3d_Viewer)& VM, const Handle(V3d_PerspectiveView)& V):V3d_View (VM,V) {
-
- MyType = V3d_ORTHOGRAPHIC ;
- MyViewMapping.SetProjection(Visual3d_TOP_PARALLEL) ;
- SetZoom(0.1, Standard_True);
- SetViewMappingDefault() ;
- SetViewOrientationDefault() ;
-}
-
-V3d_OrthographicView::V3d_OrthographicView (const Handle(V3d_Viewer)& VM, const Handle(V3d_OrthographicView)& V):V3d_View (VM,V) {
-
- MyType = V3d_ORTHOGRAPHIC ;
- MyViewMapping.SetProjection(Visual3d_TOP_PARALLEL) ;
- SetViewMappingDefault() ;
- SetViewOrientationDefault() ;
-}
-
-Handle(V3d_OrthographicView) V3d_OrthographicView::Copy () const {
- return new V3d_OrthographicView(this->Viewer(),this);}
+++ /dev/null
--- Created on: 1992-01-21
--- Created by: GG
--- Copyright (c) 1992-1999 Matra Datavision
--- Copyright (c) 1999-2014 OPEN CASCADE SAS
---
--- This file is part of Open CASCADE Technology software library.
---
--- This library is free software; you can redistribute it and / or modify it
--- under the terms of the GNU Lesser General Public version 2.1 as published
--- by the Free Software Foundation, with special exception defined in the file
--- OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
--- distribution for complete text of the license and disclaimer of any warranty.
---
--- Alternatively, this file may be used under the terms of Open CASCADE
--- commercial license or contractual agreement.
-
--- Update:
-
-
-class PerspectiveView from V3d
-
- ---Purpose : Creates and modifies a perspective
- -- See the methods of the class View
-
-
-
-inherits View from V3d
-
-
-uses
-
- Viewer from V3d,
- OrthographicView from V3d,
- PlaneAngle from Quantity
-
-raises
-
- BadValue from V3d
-
-is
-
- Create ( VM : mutable Viewer ) returns mutable PerspectiveView;
- ---Level: Public
- ---Purpose: Defines a perspective view in a viewer VM.
- -- The default angle of opening is given
- -- by the viewer.
-
-
- Create ( VM : mutable Viewer ; V : OrthographicView )
- returns mutable PerspectiveView;
- ---Level: Public
- ---Purpose: Creates a perspective view from the parameters
- -- of an orthographic view.
- -- The parameters of the original view are duplicated
- -- in the resulting view (Projection,Mapping,Context) .
- -- The view thus created must be activated in a new window.
- -- The default angle of opening is given
- -- by the viewer.
-
-
-
- Create ( VM : mutable Viewer ; V : PerspectiveView )
- returns mutable PerspectiveView ;
- ---Level: Public
- ---Purpose: Creates one perspective view from another.
- -- The parameters of the original view are duplicated
- -- in the resulting view (Projection,Mapping,Context) .
- -- The view thus created must be activated in a new window.
-
- Copy ( me ) returns mutable PerspectiveView from V3d is static;
- ---Level: Public
-
- --------------------------------------------------------
- ---Category: Methods to modify the status of the view
- --------------------------------------------------------
-
- SetAngle ( me : mutable ; Angle : PlaneAngle )
- ---Level: Public
- ---Purpose: Modifies the angle of opening of the perspective in RADIANS.
- -- The projection window is resized according to the
- -- formula :
- -- TAN(Angle/2) = Size/Length
- -- Size expresses the smallest dimension of the window.
- -- Length expresses the focal length.
- raises BadValue from V3d
- ---Purpose: Warning! raises BadValue from V3d
- -- if the opening angle is <= 0 or >= PI
- is static;
-
- Angle ( me ) returns PlaneAngle is static;
- ---Level: Public
- ---Purpose: Returns the value of the angle of opening.
-
- SetPerspective ( me : mutable ; Angle : PlaneAngle;
- UVRatio, ZNear, ZFar : Real )
- ---Level: Public
- ---Purpose: Modifies the viewing perspective volume by given
- -- angle of opening of the perspective in RADIANS,
- -- aspect ratio of window width to its height and
- -- near and far clipping planes
- raises BadValue from V3d
- -- if the opening angle is <= 0 or >= PI or
- -- the ZNear<0, ZFar<0 or ZNear>=Zfar.
- is static;
-
-end PerspectiveView;
+++ /dev/null
-// Created by: GG
-// Copyright (c) 1991-1999 Matra Datavision
-// Copyright (c) 1999-2014 OPEN CASCADE SAS
-//
-// This file is part of Open CASCADE Technology software library.
-//
-// This library is free software; you can redistribute it and / or modify it
-// under the terms of the GNU Lesser General Public version 2.1 as published
-// by the Free Software Foundation, with special exception defined in the file
-// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
-// distribution for complete text of the license and disclaimer of any warranty.
-//
-// Alternatively, this file may be used under the terms of Open CASCADE
-// commercial license or contractual agreement.
-
-// Modified 07-10-96 : CQ ; correction PRO4522
-// Modified 23-02-98 : FMN ; Replace PI by Standard_PI
-// Modified 25-02-98 : FMN ; PERF.27: Optimisation of view creation from an existing view
-// Modified 02-09-98 : FMN ; Correction problem of angle calculation in V3d_PerspectiveView::Angle().
-// Modified 23-11-98 : FMN ; PRO14896: Correction of the management of the perspective (cf Programming Guide)
-// If the angle is modified the WindowLimit changes not the focal.
-// 22-12-98 : FMN ; Rename CSF_WALKTHROW into CSF_WALKTHROUGH
-
-// IMP240100 //GG -> Activates WalkThrough model.
-
-
-//-Version
-
-//-Design
-
-//-Warning
-
-//-References
-
-//-Language C++ 2.1
-
-
-// for Test method
-
-// for the class
-#include <V3d_View.hxx>
-#include <V3d_PerspectiveView.ixx>
-#include <Visual3d_View.hxx>
-#include <V3d_BadValue.hxx>
-
-V3d_PerspectiveView::V3d_PerspectiveView (const Handle(V3d_Viewer)& VM):V3d_View (VM,V3d_PERSPECTIVE) {
- MyViewMapping.SetProjection(Visual3d_TOP_PERSPECTIVE) ;
- SetAngle(VM->DefaultAngle()) ;
-// SetZoom(10.0, Standard_True);
- SetViewMappingDefault() ;
- SetViewOrientationDefault() ;
-}
-
-V3d_PerspectiveView::V3d_PerspectiveView (const Handle(V3d_Viewer)& VM, const Handle(V3d_OrthographicView)& V):V3d_View (VM,V,V3d_PERSPECTIVE) {
- MyViewMapping.SetProjection(Visual3d_TOP_PERSPECTIVE) ;
- SetAngle(VM->DefaultAngle()) ;
-// SetZoom(10.0, Standard_True);
- SetViewMappingDefault() ;
- SetViewOrientationDefault() ;
-}
-
-V3d_PerspectiveView::V3d_PerspectiveView (const Handle(V3d_Viewer)& VM, const Handle(V3d_PerspectiveView)& V):V3d_View (VM,V,V3d_PERSPECTIVE) {
- MyViewMapping.SetProjection(Visual3d_TOP_PERSPECTIVE) ;
-// SetZoom(10.0, Standard_True);
- SetViewMappingDefault() ;
- SetViewOrientationDefault() ;
-}
-
-Handle(V3d_PerspectiveView) V3d_PerspectiveView::Copy() const {
- return new V3d_PerspectiveView(this->Viewer(),this);}
-
-//-Methods, in order
-
-void V3d_PerspectiveView::SetAngle(const Standard_Real Angle) {
-
- Standard_Real focale,Umin,Vmin,Umax,Vmax,Dxv,Dyv,Rap,Xrp,Yrp;
-
- V3d_BadValue_Raise_if ( Angle <= 0. || Angle >= M_PI, "V3d_PerspectiveView::SetAngle, bad angle");
-
- MyViewMapping.WindowLimit(Umin,Vmin,Umax,Vmax) ;
- Dxv = Abs(Umax - Umin)/2. ; Dyv = Abs(Vmax - Vmin)/2.;
- focale = Focale();
- Xrp = (Umin + Umax)/2. ; Yrp = (Vmin + Vmax)/2. ;
- Rap = Dxv / Dyv;
- if( Dxv >= Dyv ) {
- Dyv = Abs(focale * tan(Angle/2.)) ;
- Dxv = Rap * Dyv;
- } else {
- Dxv = Abs(focale * tan(Angle/2.)) ;
- Dyv = Dxv / Rap;
- }
- Umin = Xrp - Dxv ; Umax = Xrp + Dxv ;
- Vmin = Yrp - Dyv ; Vmax = Yrp + Dyv ;
- MyViewMapping.SetWindowLimit(Umin,Vmin,Umax,Vmax) ;
- MyView->SetViewMapping(MyViewMapping) ;
- ImmediateUpdate();
-}
-
-Standard_Real V3d_PerspectiveView::Angle()const {
-
-// Graphic3d_Vertex Prp ;
- Standard_Real focale,Umin,Vmin,Umax,Vmax,Dxv,Dyv ;
- Standard_Real angle = M_PI ;
-
- MyViewMapping.WindowLimit(Umin,Vmin,Umax,Vmax) ;
- focale = Focale() ;
- Dxv = (Umax - Umin)/2. ; Dyv = (Vmax - Vmin)/2. ;
- if( focale > 0. ) {
- if( Dxv >= Dyv ) {
- angle = 2.*atan(Dyv/focale) ;
- } else {
- angle = 2.*atan(Dxv/focale) ;
- }
- }
-
- return angle ;
-}
-
-void V3d_PerspectiveView::SetPerspective(const Standard_Real Angle, const Standard_Real UVRatio,
- const Standard_Real ZNear, const Standard_Real ZFar)
-{
- Standard_Real Umin,Vmin,Umax,Vmax,Yrp,Zrp,du,dv;
-
- V3d_BadValue_Raise_if ( ZNear <= 0. || ZFar <= 0. || ZNear >= ZFar, "V3d_PerspectiveView::SetPerspective, bad distances");
- V3d_BadValue_Raise_if ( Angle <= 0. || Angle >= M_PI, "V3d_PerspectiveView::SetAngle, bad angle");
-
- Graphic3d_Vertex PRP = MyViewMapping.ProjectionReferencePoint() ;
- Yrp = Zrp = 0.;
-
- PRP.SetCoord(Zrp, Yrp, Zrp);
- MyViewMapping.SetProjectionReferencePoint(PRP);
-
- Standard_Real size = (ZFar - ZNear) / 2.;
-
- MyViewMapping.SetFrontPlaneDistance(size);
- MyViewMapping.SetBackPlaneDistance(-size);
- MyViewMapping.SetViewPlaneDistance(size);
-
- // recompute window limits by mapping to view plane
- dv = Abs(ZNear * tan(Angle/2.));
- du = dv * UVRatio;
- Umin = -du; Umax = du;
- Vmin = -dv; Vmax = dv;
- MyViewMapping.SetWindowLimit(Umin, Vmin, Umax, Vmax);
-
- MyView->SetViewMapping(MyViewMapping) ;
- ImmediateUpdate();
-}
uses
-- S3892
+ Pnt from gp,
+ Dir from gp,
Ax3 from gp,
LayerMgr from V3d,
ColorScale from V3d,
TypeOfZclipping from V3d,
TypeOfProjectionModel from V3d,
TypeOfBackfacingModel from V3d,
+ StereoDumpOptions from V3d,
Viewer from V3d,
Light from V3d,
View from Visual3d,
- ViewMapping from Visual3d,
- ViewOrientation from Visual3d,
ContextView from Visual3d,
Vector from Graphic3d,
Vertex from Graphic3d,
Plotter from Graphic3d,
+ Camera_Handle from Graphic3d,
Window from Aspect,
PixMap from Image,
BufferType from Graphic3d,
is
Create ( VM : mutable Viewer; Type : TypeOfView from V3d = V3d_ORTHOGRAPHIC );
- ---Purpose: Initialises the view.
+ ---Purpose: Initializes the view.
- Create ( VM : mutable Viewer ; V : View from V3d; Type : TypeOfView from V3d = V3d_ORTHOGRAPHIC );
- ---Purpose: Initialises the view by copying.
+ Create (theVM : mutable Viewer; theView : View from V3d);
+ ---Purpose: Initializes the view by copying.
--------------------------------------------------------
---Category: Methods to modify the Status of the view
returns Boolean from Standard;
---Purpose: sets the immediate update mode and returns the previous one.
+ SetAutoZFitMode( me : mutable; theMode : Boolean );
+ ---Level: public
+ ---Purpose: sets the auto z-fit mode
+
+ AutoZFitMode( me ) returns Boolean;
+ ---Level: public
+ ---Purpose: returns current auto z-fit mode
+
---------------------------------------------------
-- Triedron methods
raises BadValue from V3d ;
-- If the eye, view point, or high point are aligned or confused.
- SetViewOrientation ( me : mutable; VO : ViewOrientation from Visual3d );
- ---Level: Public
- ---Purpose: Modifies the orientation of the view.
-
SetViewOrientationDefault( me : mutable );
---Level: Public
---Purpose: Saves the current state of the orientation of the view
raises BadValue from V3d ;
-- If the one of factors <= 0
- FitAll ( me : mutable ; Coef : Coefficient = 0.01;
- FitZ: Boolean from Standard = Standard_False; update : Boolean from Standard = Standard_True )
+ FitAll ( me : mutable ; Coef : Coefficient = 0.01; update : Boolean from Standard = Standard_True )
---Level: Public
---Purpose: Automatic zoom/panning. Objects in the view are visualised
-- so as to occupy the maximum space while respecting the
-- margin coefficient and the initial height /width ratio.
- -- NOTE than the original Z size of the view is NOT modified .
+ -- Fits Z depending on AutoZFit option.
raises BadValue from V3d ;
-- If the margin coefficient is <0 ou >= 1 or
-- Updates the view
-- If the margin coefficient is <0 ou or
-- If No Objects are displayed in the view
+ AutoZFit ( me : mutable );
+ ---Level: Public
+ ---Purpose: Automatic z-range fitting with ZFitAll. Works only if myAutoZFit enabled.
+
DepthFitAll( me : mutable ; Aspect : Coefficient = 0.01;
Margin : Coefficient = 0.01 );
---Level: Public
raises BadValue from V3d;
-- If the ZNear<0, ZFar<0 or ZNear>=Zfar.
- SetViewMapping ( me : mutable; VM : ViewMapping from Visual3d );
- ---Level: Public
- ---Purpose: Modifies the mapping of the view.
-
SetViewMappingDefault( me : mutable );
---Level: Public
---Purpose: Saves the current view mapping. This will be the
---Level: Advanced
---Purpose: Returns the associated Visual3d view.
- ViewMapping ( me ) returns ViewMapping from Visual3d is static;
- ---Level: Advanced
- ---Purpose: Returns the current mapping of the view.
-
- ViewOrientation ( me ) returns ViewOrientation from Visual3d is static;
- ---Level: Advanced
- ---Purpose: Returns the current orientation of the view.
-
- ScreenAxis( myclass ; Vpn,Vup : Vector from Graphic3d ;
+ ScreenAxis( myclass ; Vpn,Vup : Dir from gp ;
Xaxe,Yaxe,Zaxe : out Vector from Graphic3d )
returns Boolean is private ;
---Purpose: Determines the screen axes in the reference
-- framework of the view.
- InitMatrix ( myclass ; Matrix : out Array2OfReal from TColStd ) is private ;
-
- Multiply( myclass ;
- Left, Right : Array2OfReal from TColStd ;
- Matrix : out Array2OfReal from TColStd )
- returns Boolean from Standard is private ;
- RotAxis( myclass ; Vrp : Vertex from Graphic3d ;
- Axe : Vector from Graphic3d ; Angle : PlaneAngle ;
- Matrix : out Array2OfReal from TColStd ) is private ;
- ---Purpose: Determines the rotation matrice around an axis
- -- for a given angle.
-
- TrsPoint( myclass ; P : Vertex from Graphic3d ;
- Matrix : Array2OfReal from TColStd )
- returns Vertex from Graphic3d is private ;
- ---Purpose: Transforms the point P according to the matrice Matrix .
-
- TrsPoint( myclass ; V : Vector from Graphic3d ;
+ TrsPoint( myclass ; V : Vertex from Graphic3d ;
Matrix : Array2OfReal from TColStd )
- returns Vector from Graphic3d is private ;
- ---Purpose: Transforms the vector V according to the matrice Matrix .
+ returns Vertex from Graphic3d is private ;
+ ---Purpose: Transforms the Vertex V according to the matrice Matrix .
ImmediateUpdate (me) is static protected;
---Purpose:
theWidth : Integer from Standard;
theHeight : Integer from Standard;
theBufferType : BufferType from Graphic3d = Graphic3d_BT_RGB;
- theForceCentered : Boolean from Standard = Standard_True )
+ theForceCentered : Boolean from Standard = Standard_True;
+ theStereoOptions : StereoDumpOptions from V3d = V3d_SDO_MONO )
returns Boolean from Standard;
---Level : Public
---Purpose : dump the full contents of the view
-- buffer type <theBufferType>. If <theForceCentered> is true
-- view scene will be centered.
-- Pixmap will be automatically (re)allocated when needed.
+ -- For stereographic camera by default the monographic projection
+ -- is used during dumping. <theStereoOptions> flag can be used to
+ -- dump projection for left right eye.
SetProjModel( me : mutable;
amOdel: TypeOfProjectionModel from V3d = V3d_TPM_SCREEN )
---Purpose: Get clip planes.
-- @return sequence clip planes that have been set for the view
+ SetCamera (me : mutable; theCamera : Camera_Handle from Graphic3d) is static;
+ ---Level: Public
+ ---Purpose: Change camera used by view.
+
+ Camera (me) returns Camera_Handle from Graphic3d is static;
+ ---Level: Public
+ ---Purpose: Returns camera object of the view.
+ -- @return: handle to camera object, or NULL if 3D view does not use
+ -- the camera approach.
+
+ FitCamera (me : mutable;
+ theXmin : Real from Standard;
+ theYmin : Real from Standard;
+ theZmin : Real from Standard;
+ theXmax : Real from Standard;
+ theYmax : Real from Standard;
+ theZmax : Real from Standard) is protected;
+ ---Level: Protected
+ ---Purpose: Transform camera to fit in the passed bounding box
+ -- specified in world coordinate space.
+ -- @param theXmin [in] x min bounding.
+ -- @param theYmin [in] y min bounding.
+ -- @param theZmin [in] z min bounding.
+ -- @param theXmax [in] x max bounding.
+ -- @param theYmax [in] y max bounding.
+ -- @param theZmax [in] z max bounding.
+
+ ZoomCamera (me : mutable;
+ theUSize : Real from Standard;
+ theVSize : Real from Standard;
+ theZDepth : Real from Standard = 0.0) is protected;
+ ---Level: Protected
+ ---Purpose: Zoom camera to fit the section defined in view coordinate space
+ -- lying on the view direction ray. For orthogonal camera the method
+ -- changes scale, for perspective adjusts Eye location about the Center point.
+ -- Depth by Z defines distance of the zoomed section from camera Center.
+ -- It is optional and for orthographic camera has no effect.
+ -- @param theUSize [in] size of view section on U axis (horizontal to the screen).
+ -- @param theVSize [in] size of view section on V axis (vertical to the screen).
+ -- @param theZDepth [in] distance from camera center to the specified section.
+
+ PanCamera (me : mutable;
+ theU : Real from Standard;
+ theV : Real from Standard) is protected;
+ ---Level: Protected
+ ---Purpose: Pan camera along the view plane on the passed U, V distances.
+ -- @param theU [in] the horizontal panning.
+ -- @param theV [in] the vertical panning.
+
SetRaytracingMode (me : mutable) is static;
---Level: Public
---Purpose: enables OpenCL-based ray-tracing mode
fields
- MyType : TypeOfView from V3d is protected ;
+ myOldMouseX : Real is protected;
+ myOldMouseY : Real is protected;
+ myCamStartOpUp : Dir from gp is protected;
+ myCamStartOpEye : Pnt from gp is protected;
+ myCamStartOpBnd : Real[6] is protected;
+ myCamStartOpCenter : Pnt from gp is protected;
+ myCamera : Camera_Handle from Graphic3d is protected;
+
MyViewer : ViewerPointer from V3d ;
MyActiveLights: ListOfTransient from V3d;
MyView : View from Visual3d is protected ;
- MyViewMapping : ViewMapping from Visual3d is protected ;
- MyViewOrientation : ViewOrientation from Visual3d ;
MyViewContext : ContextView from Visual3d ;
MyBackground: Background from Aspect ;
MyGradientBackground: GradientBackground from Aspect ;
MyTransparencyFlag : Boolean from Standard;
myImmediateUpdate: Boolean from Standard is protected;
+
+ myXscreenAxis: Vector from Graphic3d;
+ myYscreenAxis: Vector from Graphic3d;
+ myZscreenAxis: Vector from Graphic3d;
+ myViewAxis: Vector from Graphic3d;
+ myGravityReferencePoint: Vertex from Graphic3d;
+ myCamProjectionShift: Pnt from gp;
+ myAutoZFitMode: Boolean from Standard;
+
friends
SetViewOn from class Viewer from V3d ( me : mutable ),
06-11-98 : CAL ; PRO ?????. Probleme dans ZFitAll si un point dans la vue.
13-06-98 : FMN ; PRO14896: Correction sur la gestion de la perspective (cf Programming Guinde)
29-OCT-98 : DCB : Adding ScreenCopy () method.
-22-12-98 : FMN ; Rename CSF_WALKTHROW en CSF_WALKTHROUGH
10-11-99 : GG ; PRO19603 Add Redraw( area ) method
IMP130100 : GG
-> Don't increase too much the ZSize.
//GER61351 //GG_15/12/99 Add SetBackgroundColor() and BackgroundColor() methods
-#define IMP240100 //GG
-// -> Remove PixToRef() method ,use
-// instead the equivalent Convert() method.
-// -> Rename RefToPix() to Convert() method.
-// -> Remove the grid computation in Convert()
-// method. Use instead the NEW ConvertToGrid() methods.
-// Reason is the Convert() method is call by
-// StdSelect_ViewSelector3d_Pick() from
-// AIS_InteractiveContext() and it's not possible
-// to select an object vertex when the grid is active!
-// -> Remove grid echo marker definition
-// (reported in the viewer)
-// -> Add SetProjModel() methods.
-
-#define G004 //VKH 15-11-99
-// -> Add Dump() methods
-// -> GG 07/03/00 Use the new MMSize()
-// method from Aspect_Window class.
-
-#define IMP210200 //GG Add Transparency() method
-
-#define IMP250200 //GG With SetDepth() method, when the requested
-// depth is < 0.,
-// move the view ref point and the eye,instead
-// only the eye.
-
#define IMP020300 //GG Don't use ZFitAll in during Rotation
// for perf improvment
#include <Standard_TypeMismatch.hxx>
#include <Visual3d_ViewManager.hxx>
#include <Visual3d_Light.hxx>
-#include <Graphic3d_Structure.hxx>
-#include <Graphic3d_MapIteratorOfMapOfStructure.hxx>
-#include <Graphic3d_MapOfStructure.hxx>
-#include <Graphic3d_TextureEnv.hxx>
#include <Image_AlienPixMap.hxx>
#include <V3d.hxx>
#include <V3d_View.ixx>
#include <V3d_BadValue.hxx>
+#include <V3d_StereoDumpOptions.hxx>
#include <Standard_ShortReal.hxx>
#include <gp_Dir.hxx>
+#include <gp_Pln.hxx>
#include <TColStd_Array2OfReal.hxx>
#include <Visual3d_TransientManager.hxx>
#include <Precision.hxx>
-// S3892
+#include <Graphic3d_Structure.hxx>
+#include <Graphic3d_MapIteratorOfMapOfStructure.hxx>
+#include <Graphic3d_MapOfStructure.hxx>
+#include <Graphic3d_TextureEnv.hxx>
#include <Graphic3d_AspectMarker3d.hxx>
#include <Graphic3d_GraphicDriver.hxx>
* Constant
*/
-#define Zmargin 1.
#define DEUXPI (2. * M_PI)
-/*----------------------------------------------------------------------*/
-/*
-* Local data definitions
-*/
-
-
-static Standard_Real MyXwindowCenter ;
-static Standard_Real MyYwindowCenter ;
-static Standard_Real MyWindowWidth ;
-static Standard_Real MyWindowHeight ;
-
-#define LOPTIM
-#ifndef LOPTIM
-static Graphic3d_Vector MyXscreenAxis ;
-static Graphic3d_Vector MyYscreenAxis ;
-static Graphic3d_Vector MyZscreenAxis ;
-static Graphic3d_Vector MyViewReferencePlane ;
-static Graphic3d_Vector MyViewReferenceUp ;
-static Graphic3d_Vector MyViewAxis ;
-static Graphic3d_Vertex MyViewReferencePoint ;
-static Graphic3d_Vertex MyGravityReferencePoint ;
-static Graphic3d_Vertex MyProjReferencePoint ;
-#else
-static Graphic3d_Vector& _MyXscreenAxis() {
- static Graphic3d_Vector MyXscreenAxis;
- return MyXscreenAxis;
-}
-#define MyXscreenAxis _MyXscreenAxis()
-
-static Graphic3d_Vector& _MyYscreenAxis() {
- static Graphic3d_Vector MyYscreenAxis;
- return MyYscreenAxis;
-}
-#define MyYscreenAxis _MyYscreenAxis()
-
-static Graphic3d_Vector& _MyZscreenAxis() {
- static Graphic3d_Vector MyZscreenAxis;
- return MyZscreenAxis;
-}
-#define MyZscreenAxis _MyZscreenAxis()
-
-static Graphic3d_Vector& _MyViewReferencePlane() {
- static Graphic3d_Vector MyViewReferencePlane;
- return MyViewReferencePlane;
-}
-#define MyViewReferencePlane _MyViewReferencePlane()
-
-static Graphic3d_Vector& _MyViewReferenceUp() {
- static Graphic3d_Vector MyViewReferenceUp;
- return MyViewReferenceUp;
-}
-#define MyViewReferenceUp _MyViewReferenceUp()
-
-static Graphic3d_Vector& _MyViewAxis() {
- static Graphic3d_Vector MyViewAxis;
- return MyViewAxis;
-}
-#define MyViewAxis _MyViewAxis()
-
-static Graphic3d_Vertex& _MyViewReferencePoint() {
- static Graphic3d_Vertex MyViewReferencePoint;
- return MyViewReferencePoint;
-}
-#define MyViewReferencePoint _MyViewReferencePoint()
-
-static Graphic3d_Vertex& _MyGravityReferencePoint() {
- static Graphic3d_Vertex MyGravityReferencePoint;
- return MyGravityReferencePoint;
-}
-#define MyGravityReferencePoint _MyGravityReferencePoint()
-
-static Graphic3d_Vertex& _MyProjReferencePoint() {
- static Graphic3d_Vertex MyProjReferencePoint;
- return MyProjReferencePoint;
-}
-#define MyProjReferencePoint _MyProjReferencePoint()
-#endif // LOPTIM
-
/*----------------------------------------------------------------------*/
//-Constructors
V3d_View::V3d_View(const Handle(V3d_Viewer)& VM, const V3d_TypeOfView Type ) :
-MyType ( Type ),
-MyProjModel(V3d_TPM_SCREEN),
-MyViewer(VM.operator->()),
-MyActiveLights(),
-MyViewContext (),
-myActiveLightsIterator(),
-SwitchSetFront(Standard_False),
-MyTrsf (1, 4, 1, 4) // S3892
+ MyProjModel(V3d_TPM_SCREEN),
+ MyViewer(VM.operator->()),
+ MyActiveLights(),
+ MyViewContext (),
+ myActiveLightsIterator(),
+ SwitchSetFront(Standard_False),
+ MyTrsf (1, 4, 1, 4),
+ myAutoZFitMode (Standard_True)
{
myImmediateUpdate = Standard_False;
MyView = new Visual3d_View(MyViewer->Viewer());
else
MyViewContext.SetBackZClippingOff ();
- // Visualisation and Shading Model
+ // Visualization and Shading Model
MyViewContext.SetModel ((MyView->Context ()).Model ());
MyViewContext.SetVisualization ((MyView->Context ()).Visualization ());
MyViewContext.SetTextureEnv (MyView->Context ().TextureEnv ());
// } End of retrieval of the definition of ViewContext.
- MyViewMapping = MyView->ViewMapping() ;
- MyViewOrientation = MyView->ViewOrientation() ;
MyBackground = VM->GetBackgroundColor() ;
MyGradientBackground = VM->GetGradientBackground() ;
- SetAxis(0.,0.,0.,1.,1.,1.) ;
- SetVisualization(VM->DefaultVisualization()) ;
- SetShadingModel(VM->DefaultShadingModel()) ;
- SetSurfaceDetail(VM->DefaultSurfaceDetail()) ;
- SetTwist(0.) ;
- SetAt(0.,0.,0.) ;
- SetProj(VM->DefaultViewProj()) ;
- SetSize(VM->DefaultViewSize()) ;
+ // camera init
+ Handle(Graphic3d_Camera) aCamera = new Graphic3d_Camera();
+ aCamera->SetFOVy (45.0);
+ aCamera->SetIOD (Graphic3d_Camera::IODType_Relative, 0.05);
+ aCamera->SetZFocus (Graphic3d_Camera::FocusType_Relative, 1.0);
+ SetCamera (aCamera);
+
+ SetAxis (0.,0.,0.,1.,1.,1.);
+ SetVisualization (VM->DefaultVisualization());
+ SetShadingModel (VM->DefaultShadingModel());
+ SetSurfaceDetail (VM->DefaultSurfaceDetail());
+ SetTwist (0.);
+ SetAt (0.,0.,0.);
+ SetProj (VM->DefaultViewProj());
+ SetSize (VM->DefaultViewSize());
Standard_Real zsize = VM->DefaultViewSize();
- SetZSize(2.*zsize+zsize*Zmargin) ;
- SetZClippingDepth(0.);
- SetZClippingWidth(zsize);
- SetZCueingDepth(0.);
- SetZCueingWidth(zsize);
- SetDepth(VM->DefaultViewSize()/2.) ;
- SetCenter(0.,0.) ;
+ SetZSize (2.*zsize);
+ SetZClippingDepth (0.);
+ SetZClippingWidth (zsize);
+ SetZCueingDepth (0.);
+ SetZCueingWidth (zsize);
+ SetDepth (VM->DefaultViewSize()/2.0);
+ SetCenter (0.,0.);
SetViewMappingDefault();
- VM->AddView(this) ;
+ VM->AddView (this);
Init();
myImmediateUpdate = Standard_True;
- // S3892
-#ifndef IMP240100
-#endif //IMP240100
+ aCamera->SetProjectionType ((Type == V3d_ORTHOGRAPHIC)
+ ? Graphic3d_Camera::Projection_Orthographic
+ : Graphic3d_Camera::Projection_Perspective);
-#ifdef IMP210200
MyTransparencyFlag = Standard_False;
-#endif
}
/*----------------------------------------------------------------------*/
-V3d_View::V3d_View(const Handle(V3d_Viewer)& VM,const Handle(V3d_View)& V, const V3d_TypeOfView Type ) :
-MyType ( Type ),
+V3d_View::V3d_View(const Handle(V3d_Viewer)& theVM,const Handle(V3d_View)& theView) :
MyProjModel(V3d_TPM_SCREEN),
-MyViewer(VM.operator->()),
+MyViewer(theVM.operator->()),
MyActiveLights(),
MyViewContext (),
myActiveLightsIterator(),
SwitchSetFront(Standard_False),
-MyTrsf (1, 4, 1, 4) // S3892
+MyTrsf (1, 4, 1, 4),
+myAutoZFitMode (Standard_True)
{
- Handle(Visual3d_View) FromView = V->View() ;
+ Handle(Visual3d_View) aFromView = theView->View();
myImmediateUpdate = Standard_False;
- MyView = new Visual3d_View(MyViewer->Viewer());
+ MyView = new Visual3d_View (MyViewer->Viewer());
- for (V->InitActiveLights();V->MoreActiveLights();V->NextActiveLights()){
- MyActiveLights.Append(V->ActiveLight());}
+ for (theView->InitActiveLights(); theView->MoreActiveLights(); theView->NextActiveLights())
+ {
+ MyActiveLights.Append (theView->ActiveLight());
+ }
- MyViewContext = FromView->Context() ;
+ MyViewContext = aFromView->Context() ;
- MyViewMapping = FromView->ViewMapping() ;
- MyViewOrientation = FromView->ViewOrientation() ;
- MyBackground = FromView->Background() ;
- MyGradientBackground = FromView->GradientBackground();
+ SetCamera (new Graphic3d_Camera (theView->Camera()));
- MyView->SetContext(MyViewContext) ;
+ MyBackground = aFromView->Background() ;
+ MyGradientBackground = aFromView->GradientBackground();
+
+ MyView->SetContext (MyViewContext) ;
+
+ SetAxis (0.0, 0.0, 0.0, 1.0, 1.0, 1.0);
+
+ theVM->AddView (this);
- SetAxis(0.,0.,0.,1.,1.,1.) ;
- VM->AddView(this) ;
Init();
+
myImmediateUpdate = Standard_True;
}
MyView->SetWindow(TheWindow) ;
FitAll(TheWindow,a,b,c,d);
MyView->SetContext(MyViewContext) ;
- MyView->SetViewOrientation(MyViewOrientation) ;
MyView->SetBackground(MyBackground) ;
MyViewer->SetViewOn(this) ;
MyWindow = TheWindow;
// particularly in class NIS_View.
MyWindow = TheWindow;
// SetWindow carries out SetRatio and modifies
- // ViewMapping and ViewMappingDefault of MyView.
- MyViewMapping = MyView->ViewMapping() ;
MyView->SetContext(MyViewContext) ;
- MyView->SetViewMapping(MyViewMapping) ;
- MyView->SetViewOrientation(MyViewOrientation) ;
MyView->SetBackground(MyBackground) ;
MyViewer->SetViewOn(this) ;
MyView->Redraw() ;
// particularly in class NIS_View.
MyWindow = aWindow;
MyView->SetWindow(aWindow, aContext, aDisplayCB, aClientData) ;
- MyViewMapping = MyView->ViewMapping() ;
MyView->SetContext(MyViewContext) ;
- MyView->SetViewMapping(MyViewMapping) ;
- MyView->SetViewOrientation(MyViewOrientation) ;
MyView->SetBackground(MyBackground) ;
MyViewer->SetViewOn(this) ;
MyView->Redraw() ;
if( MyView->IsDefined() ) {
MyView->Resized() ;
- MyViewMapping = MyView->ViewMapping();
MyView->Redraw();
}
}
Nx /= D ; Ny /= D ; Nz /= D ;
MyDefaultViewPoint.SetCoord(X,Y,Z) ;
MyDefaultViewAxis.SetCoord(Nx,Ny,Nz) ;
- MyDefaultViewAxis.Normalize() ;
}
/*----------------------------------------------------------------------*/
void V3d_View::SetFront()
{
gp_Ax3 a = MyViewer->PrivilegedPlane();
- Standard_Real xo,yo,zo,vx,vy,vz,xu,yu,zu;
+ Standard_Real xo, yo, zo, vx, vy, vz, xu, yu, zu;
a.Direction().Coord(vx,vy,vz);
a.YDirection().Coord(xu,yu,zu);
a.Location().Coord(xo,yo,zo);
+ myCamera->BeginUpdate();
+ myCamera->SetCenter (gp_Pnt (xo, yo, zo));
if(SwitchSetFront)
- MyViewOrientation.SetViewReferencePlane(Graphic3d_Vector(-vx,-vy,-vz));
+ myCamera->SetDirection (gp_Dir (vx, vy, vz));
else
- MyViewOrientation.SetViewReferencePlane(Graphic3d_Vector(vx,vy,vz));
-
- SwitchSetFront = !SwitchSetFront;
+ myCamera->SetDirection (gp_Dir (vx, vy, vz).Reversed());
+ myCamera->SetUp (gp_Dir (xu, yu, zu));
- MyViewOrientation.SetViewReferenceUp(Graphic3d_Vector(xu,yu,zu));
- MyViewOrientation.SetViewReferencePoint(Graphic3d_Vertex(xo,yo,zo));
+ AutoZFit();
+ myCamera->EndUpdate();
- MyView->SetViewOrientation(MyViewOrientation) ;
+ SwitchSetFront = !SwitchSetFront;
ImmediateUpdate();
}
/*----------------------------------------------------------------------*/
-void V3d_View::Rotate(const Standard_Real ax, const Standard_Real ay, const Standard_Real az, const Standard_Boolean Start)
+void V3d_View::Rotate (const Standard_Real ax,
+ const Standard_Real ay,
+ const Standard_Real az,
+ const Standard_Boolean Start)
{
- Standard_Real Ax = ax ;
- Standard_Real Ay = ay ;
- Standard_Real Az = az ;
- Graphic3d_Vector Vpn,Vup ;
- TColStd_Array2OfReal Matrix(0,3,0,3) ;
- TColStd_Array2OfReal Rmatrix(0,3,0,3) ;
+ Standard_Real Ax = ax;
+ Standard_Real Ay = ay;
+ Standard_Real Az = az;
- if( Ax > 0. ) while ( Ax > DEUXPI ) Ax -= DEUXPI ;
- else if( Ax < 0. ) while ( Ax < -DEUXPI ) Ax += DEUXPI ;
- if( Ay > 0. ) while ( Ay > DEUXPI ) Ay -= DEUXPI ;
- else if( Ay < 0. ) while ( Ay < -DEUXPI ) Ay += DEUXPI ;
- if( Az > 0. ) while ( Az > DEUXPI ) Az -= DEUXPI ;
- else if( Az < 0. ) while ( Az < -DEUXPI ) Az += DEUXPI ;
+ if( Ax > 0. ) while ( Ax > DEUXPI ) Ax -= DEUXPI;
+ else if( Ax < 0. ) while ( Ax < -DEUXPI ) Ax += DEUXPI;
+ if( Ay > 0. ) while ( Ay > DEUXPI ) Ay -= DEUXPI;
+ else if( Ay < 0. ) while ( Ay < -DEUXPI ) Ay += DEUXPI;
+ if( Az > 0. ) while ( Az > DEUXPI ) Az -= DEUXPI;
+ else if( Az < 0. ) while ( Az < -DEUXPI ) Az += DEUXPI;
+
+ if (Start)
+ {
+ myCamStartOpUp = myCamera->Up();
+ myCamStartOpEye = myCamera->Eye();
+ myCamStartOpCenter = myCamera->Center();
+ }
+
+ myCamera->BeginUpdate();
+ myCamera->SetUp (myCamStartOpUp);
+ myCamera->SetEye (myCamStartOpEye);
+ myCamera->SetCenter (myCamStartOpCenter);
+
+ // rotate camera around 3 initial axes
+ gp_Dir aBackDir (gp_Vec (myCamStartOpCenter, myCamStartOpEye));
+ gp_Dir aXAxis (myCamStartOpUp.Crossed (aBackDir));
+ gp_Dir aYAxis (aBackDir.Crossed (aXAxis));
+ gp_Dir aZAxis (aXAxis.Crossed (aYAxis));
+
+ gp_Trsf aRot[3], aTrsf;
+ aRot[0].SetRotation (gp_Ax1 (myCamStartOpCenter, aYAxis), -Ax);
+ aRot[1].SetRotation (gp_Ax1 (myCamStartOpCenter, aXAxis), Ay);
+ aRot[2].SetRotation (gp_Ax1 (myCamStartOpCenter, aZAxis), Az);
+ aTrsf.Multiply (aRot[0]);
+ aTrsf.Multiply (aRot[1]);
+ aTrsf.Multiply (aRot[2]);
+
+ myCamera->Transform (aTrsf);
+
+ myCamera->EndUpdate();
+
+ AutoZFit();
- if( Start ) {
- MyViewReferencePoint = MyViewOrientation.ViewReferencePoint() ;
- MyViewReferencePlane = MyViewOrientation.ViewReferencePlane() ;
- MyViewReferenceUp = MyViewOrientation.ViewReferenceUp() ;
- if (!ScreenAxis(MyViewReferencePlane,MyViewReferenceUp,
- MyXscreenAxis,MyYscreenAxis,MyZscreenAxis))
- V3d_BadValue::Raise ("V3d_View::Rotate, alignment of Eye,At,Up");
- }
-
- InitMatrix(Matrix) ;
-
- if( Ax != 0. ) RotAxis(MyViewReferencePoint,MyYscreenAxis,-Ax,Matrix);
- if( Ay != 0. ) {
- RotAxis(MyViewReferencePoint,MyXscreenAxis,Ay,Rmatrix) ;
- Multiply(Matrix, Rmatrix, Matrix);
- }
- if( Az != 0. ) {
- RotAxis(MyViewReferencePoint,MyZscreenAxis,Az,Rmatrix) ;
- Multiply(Matrix, Rmatrix, Matrix);
- }
- Vpn = TrsPoint(MyViewReferencePlane,Matrix) ;
- MyViewOrientation.SetViewReferencePlane(Vpn) ;
- Vup = TrsPoint(MyViewReferenceUp,Matrix) ;
- MyViewOrientation.SetViewReferenceUp(Vup) ;
- MyView->SetViewOrientation(MyViewOrientation) ;
-#ifdef IMP020300
- SetZSize(0.) ;
-#endif
ImmediateUpdate();
}
void V3d_View::Rotate(const Standard_Real ax, const Standard_Real ay, const Standard_Real az,
const Standard_Real X, const Standard_Real Y, const Standard_Real Z, const Standard_Boolean Start)
{
+
Standard_Real Ax = ax ;
Standard_Real Ay = ay ;
Standard_Real Az = az ;
- Graphic3d_Vector Vpn,Vup ;
- Graphic3d_Vertex Vrp ;
- TColStd_Array2OfReal Matrix(0,3,0,3) ;
- TColStd_Array2OfReal Rmatrix(0,3,0,3) ;
if( Ax > 0. ) while ( Ax > DEUXPI ) Ax -= DEUXPI ;
else if( Ax < 0. ) while ( Ax < -DEUXPI ) Ax += DEUXPI ;
if( Az > 0. ) while ( Az > DEUXPI ) Az -= DEUXPI ;
else if( Az < 0. ) while ( Az < -DEUXPI ) Az += DEUXPI ;
- if( Start ) {
- MyGravityReferencePoint.SetCoord(X,Y,Z) ;
- MyViewReferencePoint = MyViewOrientation.ViewReferencePoint() ;
- MyViewReferencePlane = MyViewOrientation.ViewReferencePlane() ;
- MyViewReferenceUp = MyViewOrientation.ViewReferenceUp() ;
- if (!ScreenAxis(MyViewReferencePlane,MyViewReferenceUp,
- MyXscreenAxis,MyYscreenAxis,MyZscreenAxis))
- V3d_BadValue::Raise ("V3d_View::Rotate, alignment of Eye,At,Up");
- }
-
- InitMatrix(Matrix) ;
-
- if( Ax != 0. ) RotAxis(MyGravityReferencePoint,MyYscreenAxis,-Ax,Matrix);
- if( Ay != 0. ) {
- RotAxis(MyGravityReferencePoint,MyXscreenAxis,Ay,Rmatrix) ;
- Multiply(Matrix, Rmatrix, Matrix);
- }
- if( Az != 0. ) {
- RotAxis(MyGravityReferencePoint,MyZscreenAxis,Az,Rmatrix) ;
- Multiply(Matrix, Rmatrix, Matrix);
- }
- Vrp = TrsPoint(MyViewReferencePoint,Matrix) ;
- MyViewOrientation.SetViewReferencePoint(Vrp) ;
- Vpn = TrsPoint(MyViewReferencePlane,Matrix) ;
- MyViewOrientation.SetViewReferencePlane(Vpn) ;
- Vup = TrsPoint(MyViewReferenceUp,Matrix) ;
- MyViewOrientation.SetViewReferenceUp(Vup) ;
- MyView->SetViewOrientation(MyViewOrientation) ;
-#ifdef IMP020300
- SetZSize(0.) ;
-#endif
+ if (Start)
+ {
+ myGravityReferencePoint.SetCoord (X, Y, Z);
+ myCamStartOpUp = myCamera->Up();
+ myCamStartOpEye = myCamera->Eye();
+ myCamStartOpCenter = myCamera->Center();
+ }
+
+ const Graphic3d_Vertex& aVref = myGravityReferencePoint;
+
+ myCamera->BeginUpdate();
+ myCamera->SetUp (myCamStartOpUp);
+ myCamera->SetEye (myCamStartOpEye);
+ myCamera->SetCenter (myCamStartOpCenter);
+
+ // rotate camera around 3 initial axes
+ gp_Pnt aRCenter (aVref.X(), aVref.Y(), aVref.Z());
+
+ gp_Dir aZAxis (myCamera->Direction().Reversed());
+ gp_Dir aYAxis (myCamera->Up());
+ gp_Dir aXAxis (aYAxis.Crossed (aZAxis));
+
+ gp_Trsf aRot[3], aTrsf;
+ aRot[0].SetRotation (gp_Ax1 (aRCenter, aYAxis), -Ax);
+ aRot[1].SetRotation (gp_Ax1 (aRCenter, aXAxis), Ay);
+ aRot[2].SetRotation (gp_Ax1 (aRCenter, aZAxis), Az);
+ aTrsf.Multiply (aRot[0]);
+ aTrsf.Multiply (aRot[1]);
+ aTrsf.Multiply (aRot[2]);
+
+ myCamera->Transform (aTrsf);
+ myCamera->EndUpdate();
+
+ AutoZFit();
+
ImmediateUpdate();
}
const Standard_Real X, const Standard_Real Y, const Standard_Real Z, const Standard_Boolean Start)
{
Standard_Real Angle = angle ;
- Graphic3d_Vector Vpn,Vup ;
- Graphic3d_Vertex Vrp ;
- TColStd_Array2OfReal Matrix(0,3,0,3) ;
if( Angle > 0. ) while ( Angle > DEUXPI ) Angle -= DEUXPI ;
else if( Angle < 0. ) while ( Angle < -DEUXPI ) Angle += DEUXPI ;
- if( Start ) {
- MyGravityReferencePoint.SetCoord(X,Y,Z) ;
- MyViewReferencePoint = MyViewOrientation.ViewReferencePoint() ;
- MyViewReferencePlane = MyViewOrientation.ViewReferencePlane() ;
- MyViewReferenceUp = MyViewOrientation.ViewReferenceUp() ;
+ if (Start)
+ {
+ myGravityReferencePoint.SetCoord (X, Y, Z);
+ myCamStartOpUp = myCamera->Up();
+ myCamStartOpEye = myCamera->Eye();
+ myCamStartOpCenter = myCamera->Center();
+
switch (Axe) {
case V3d_X :
- MyViewAxis.SetCoord(1.,0.,0.) ;
+ myViewAxis.SetCoord(1.,0.,0.) ;
break ;
case V3d_Y :
- MyViewAxis.SetCoord(0.,1.,0.) ;
+ myViewAxis.SetCoord(0.,1.,0.) ;
break ;
case V3d_Z :
- MyViewAxis.SetCoord(0.,0.,1.) ;
+ myViewAxis.SetCoord(0.,0.,1.) ;
break ;
}
+
+ myCamStartOpUp = myCamera->Up();
+ myCamStartOpEye = myCamera->Eye();
+ myCamStartOpCenter = myCamera->Center();
}
- RotAxis(MyGravityReferencePoint,MyViewAxis,Angle,Matrix) ;
- Vrp = TrsPoint(MyViewReferencePoint,Matrix) ;
- MyViewOrientation.SetViewReferencePoint(Vrp) ;
- Vpn = TrsPoint(MyViewReferencePlane,Matrix) ;
- MyViewOrientation.SetViewReferencePlane(Vpn) ;
- Vup = TrsPoint(MyViewReferenceUp,Matrix) ;
- MyViewOrientation.SetViewReferenceUp(Vup) ;
- MyView->SetViewOrientation(MyViewOrientation) ;
-#ifdef IMP020300
- SetZSize(0.) ;
-#endif
+ const Graphic3d_Vertex& aVref = myGravityReferencePoint;
+
+ myCamera->BeginUpdate();
+ myCamera->SetUp (myCamStartOpUp);
+ myCamera->SetEye (myCamStartOpEye);
+ myCamera->SetCenter (myCamStartOpCenter);
+
+ // rotate camera around passed axis
+ gp_Trsf aRotation;
+ gp_Pnt aRCenter (aVref.X(), aVref.Y(), aVref.Z());
+ gp_Dir aRAxis ((Axe == V3d_X) ? 1.0 : 0.0,
+ (Axe == V3d_Y) ? 1.0 : 0.0,
+ (Axe == V3d_Z) ? 1.0 : 0.0);
+
+ aRotation.SetRotation (gp_Ax1 (aRCenter, aRAxis), Angle);
+ myCamera->Transform (aRotation);
+
+ myCamera->EndUpdate();
+
+ AutoZFit();
+
ImmediateUpdate();
}
void V3d_View::Rotate(const Standard_Real angle, const Standard_Boolean Start)
{
- Standard_Real Angle = angle ;
- Graphic3d_Vector Vpn,Vup ;
- TColStd_Array2OfReal Matrix(0,3,0,3) ;
+ Standard_Real Angle = angle;
if( Angle > 0. ) while ( Angle > DEUXPI ) Angle -= DEUXPI ;
else if( Angle < 0. ) while ( Angle < -DEUXPI ) Angle += DEUXPI ;
if( Start ) {
- MyViewReferencePoint = MyViewOrientation.ViewReferencePoint() ;
- MyViewReferencePlane = MyViewOrientation.ViewReferencePlane() ;
- MyViewReferenceUp = MyViewOrientation.ViewReferenceUp() ;
+ myCamStartOpUp = myCamera->Up();
+ myCamStartOpEye = myCamera->Eye();
+ myCamStartOpCenter = myCamera->Center();
}
- RotAxis(MyDefaultViewPoint,MyDefaultViewAxis,Angle,Matrix) ;
-#ifdef BUC60952
- Graphic3d_Vertex Vrp ;
- Vrp = TrsPoint(MyViewReferencePoint,Matrix) ;
- MyViewOrientation.SetViewReferencePoint(Vrp) ;
-#endif
- Vpn = TrsPoint(MyViewReferencePlane,Matrix) ;
- MyViewOrientation.SetViewReferencePlane(Vpn) ;
- Vup = TrsPoint(MyViewReferenceUp,Matrix) ;
- MyViewOrientation.SetViewReferenceUp(Vup) ;
- MyView->SetViewOrientation(MyViewOrientation) ;
-#ifdef IMP020300
- SetZSize(0.) ;
-#endif
+ const Graphic3d_Vertex& aPnt = MyDefaultViewPoint;
+ const Graphic3d_Vector& anAxis = MyDefaultViewAxis;
+
+ myCamera->BeginUpdate();
+ myCamera->SetUp (myCamStartOpUp);
+ myCamera->SetEye (myCamStartOpEye);
+ myCamera->SetCenter (myCamStartOpCenter);
+
+ gp_Trsf aRotation;
+ gp_Pnt aRCenter (aPnt.X(), aPnt.Y(), aPnt.Z());
+ gp_Dir aRAxis (anAxis.X(), anAxis.Y(), anAxis.Z());
+ aRotation.SetRotation (gp_Ax1 (aRCenter, aRAxis), Angle);
+ myCamera->Transform (aRotation);
+
+ myCamera->EndUpdate();
+
+ AutoZFit();
+
ImmediateUpdate();
}
void V3d_View::Turn(const Standard_Real ax, const Standard_Real ay, const Standard_Real az, const Standard_Boolean Start)
{
- Standard_Real Ax = ax ;
- Standard_Real Ay = ay ;
- Standard_Real Az = az ;
- Graphic3d_Vertex Vrp,Eye ;
- Graphic3d_Vector Vpn,Vup ;
- Standard_Real Xrp,Yrp,Zrp,Xpn,Ypn,Zpn,Xat,Yat,Zat,Xeye,Yeye,Zeye ;
- TColStd_Array2OfReal Matrix(0,3,0,3) ;
- TColStd_Array2OfReal Rmatrix(0,3,0,3) ;
+ Standard_Real Ax = ax;
+ Standard_Real Ay = ay;
+ Standard_Real Az = az;
if( Ax > 0. ) while ( Ax > DEUXPI ) Ax -= DEUXPI ;
else if( Ax < 0. ) while ( Ax < -DEUXPI ) Ax += DEUXPI ;
else if( Az < 0. ) while ( Az < -DEUXPI ) Az += DEUXPI ;
if( Start ) {
- MyProjReferencePoint = MyViewMapping.ProjectionReferencePoint();
- MyViewReferencePoint = MyViewOrientation.ViewReferencePoint() ;
- MyViewReferencePlane = MyViewOrientation.ViewReferencePlane() ;
- MyViewReferenceUp = MyViewOrientation.ViewReferenceUp() ;
- if (!ScreenAxis(MyViewReferencePlane,MyViewReferenceUp,
- MyXscreenAxis,MyYscreenAxis,MyZscreenAxis))
- V3d_BadValue::Raise ("V3d_View::Turn, alignment of Eye,At,Up");
- }
-
- InitMatrix(Matrix) ;
- MyProjReferencePoint.Coord(Xrp,Yrp,Zrp) ;
- MyViewReferencePoint.Coord(Xat,Yat,Zat) ;
- MyViewReferencePlane.Coord(Xpn,Ypn,Zpn) ;
- Xeye = Zrp*Xpn + Xat ; Yeye = Zrp*Ypn + Yat ; Zeye = Zrp*Zpn + Zat ;
- Eye.SetCoord(Xeye,Yeye,Zeye) ;
- if( Ax != 0. ) RotAxis(Eye,MyYscreenAxis,-Ax,Matrix) ;
- if( Ay != 0. ) {
- RotAxis(Eye,MyXscreenAxis,Ay,Rmatrix) ;
- Multiply(Matrix, Rmatrix, Matrix);
- }
- if( Az != 0. ) {
- RotAxis(Eye,MyZscreenAxis,Az,Rmatrix) ;
- Multiply(Matrix, Rmatrix, Matrix);
- }
- Vrp = TrsPoint(MyViewReferencePoint,Matrix) ;
- MyViewOrientation.SetViewReferencePoint(Vrp) ;
- Vpn = TrsPoint(MyViewReferencePlane,Matrix) ;
- MyViewOrientation.SetViewReferenceUp(Vpn) ;
- Vup = TrsPoint(MyViewReferenceUp,Matrix) ;
- MyViewOrientation.SetViewReferenceUp(Vup) ;
- MyView->SetViewOrientation(MyViewOrientation) ;
-#ifdef IMP020300
- SetZSize(0.) ;
-#else
- // Check ZClipping planes
- Standard_Real Zmax ;
- Vrp.Coord(Xat,Yat,Zat) ;
- Zmax = Sqrt( Xat*Xat + Yat*Yat + Zat*Zat) ;
- if( Zmax > MyViewMapping.FrontPlaneDistance() &&
- MyProjModel == V3d_TPM_SCREEN ) {
- SetZSize(2.*Zmax+Zmax*Zmargin) ;
- }
-#endif
- ImmediateUpdate();
+ myCamStartOpUp = myCamera->Up();
+ myCamStartOpEye = myCamera->Eye();
+ myCamStartOpCenter = myCamera->Center();
+ }
+
+ myCamera->BeginUpdate();
+ myCamera->SetUp (myCamStartOpUp);
+ myCamera->SetEye (myCamStartOpEye);
+ myCamera->SetCenter (myCamStartOpCenter);
+
+ // rotate camera around 3 initial axes
+ gp_Pnt aRCenter = myCamera->Eye();
+ gp_Dir aZAxis (myCamera->Direction().Reversed());
+ gp_Dir aYAxis (myCamera->Up());
+ gp_Dir aXAxis (aYAxis.Crossed (aZAxis));
+
+ gp_Trsf aRot[3], aTrsf;
+ aRot[0].SetRotation (gp_Ax1 (aRCenter, aYAxis), -Ax);
+ aRot[1].SetRotation (gp_Ax1 (aRCenter, aXAxis), Ay);
+ aRot[2].SetRotation (gp_Ax1 (aRCenter, aZAxis), Az);
+ aTrsf.Multiply (aRot[0]);
+ aTrsf.Multiply (aRot[1]);
+ aTrsf.Multiply (aRot[2]);
+
+ myCamera->Transform (aTrsf);
+ myCamera->EndUpdate();
+
+ AutoZFit();
+
+ ImmediateUpdate();
}
/*----------------------------------------------------------------------*/
void V3d_View::Turn(const Standard_Real angle, const Standard_Boolean Start)
{
Standard_Real Angle = angle ;
- Graphic3d_Vertex Vrp,Eye ;
- Graphic3d_Vector Vpn,Vup ;
- Standard_Real Xrp,Yrp,Zrp,Xpn,Ypn,Zpn,Xat,Yat,Zat,Xeye,Yeye,Zeye ;
- TColStd_Array2OfReal Matrix(0,3,0,3) ;
if( Angle > 0. ) while ( Angle > DEUXPI ) Angle -= DEUXPI ;
else if( Angle < 0. ) while ( Angle < -DEUXPI ) Angle += DEUXPI ;
if( Start ) {
- MyProjReferencePoint = MyViewMapping.ProjectionReferencePoint();
- MyViewReferencePoint = MyViewOrientation.ViewReferencePoint() ;
- MyViewReferencePlane = MyViewOrientation.ViewReferencePlane() ;
- MyViewReferenceUp = MyViewOrientation.ViewReferenceUp() ;
- }
- MyProjReferencePoint.Coord(Xrp,Yrp,Zrp) ;
- MyViewReferencePoint.Coord(Xat,Yat,Zat) ;
- MyViewReferencePlane.Coord(Xpn,Ypn,Zpn) ;
- Xeye = Zrp*Xpn + Xat ; Yeye = Zrp*Ypn + Yat ; Zeye = Zrp*Zpn + Zat ;
- Eye.SetCoord(Xeye,Yeye,Zeye) ;
- RotAxis(Eye,MyDefaultViewAxis,Angle,Matrix) ;
- Vrp = TrsPoint(MyViewReferencePoint,Matrix) ;
- MyViewOrientation.SetViewReferencePoint(Vrp) ;
- Vpn = TrsPoint(MyViewReferencePlane,Matrix) ;
- MyViewOrientation.SetViewReferencePlane(Vpn) ;
- Vup = TrsPoint(MyViewReferenceUp,Matrix) ;
- MyViewOrientation.SetViewReferenceUp(Vup) ;
- MyView->SetViewOrientation(MyViewOrientation) ;
-#ifdef IMP020300
- SetZSize(0.) ;
-#else
- // Check ZClipping planes
- Standard_Real Zmax ;
- Vrp.Coord(Xat,Yat,Zat) ;
- Zmax = Sqrt( Xat*Xat + Yat*Yat + Zat*Zat ) ;
- if( Zmax > MyViewMapping.FrontPlaneDistance() &&
- MyProjModel == V3d_TPM_SCREEN ) {
- SetZSize(2.*Zmax+Zmax*Zmargin) ;
- }
-#endif
- ImmediateUpdate();
+ myCamStartOpUp = myCamera->Up();
+ myCamStartOpEye = myCamera->Eye();
+ myCamStartOpCenter = myCamera->Center();
+ }
+
+ myCamera->BeginUpdate();
+ myCamera->SetUp (myCamStartOpUp);
+ myCamera->SetEye (myCamStartOpEye);
+ myCamera->SetCenter (myCamStartOpCenter);
+
+ const Graphic3d_Vector& anAxis = MyDefaultViewAxis;
+
+ gp_Trsf aRotation;
+ gp_Pnt aRCenter = myCamera->Eye();
+ gp_Dir aRAxis (anAxis.X(), anAxis.Y(), anAxis.Z());
+ aRotation.SetRotation (gp_Ax1 (aRCenter, aRAxis), Angle);
+ myCamera->Transform (aRotation);
+
+ myCamera->EndUpdate();
+
+ AutoZFit();
+
+ ImmediateUpdate();
}
void V3d_View::SetTwist(const Standard_Real angle)
{
Standard_Real Angle = angle ;
- TColStd_Array2OfReal Matrix(0,3,0,3) ;
- Standard_Boolean TheStatus ;
+ Standard_Boolean TheStatus;
if( Angle > 0. ) while ( Angle > DEUXPI ) Angle -= DEUXPI ;
else if( Angle < 0. ) while ( Angle < -DEUXPI ) Angle += DEUXPI ;
- MyViewReferencePlane = MyViewOrientation.ViewReferencePlane() ;
- MyViewReferenceUp.SetCoord(0.,0.,1.) ;
- TheStatus = ScreenAxis(MyViewReferencePlane,MyViewReferenceUp,
- MyXscreenAxis,MyYscreenAxis,MyZscreenAxis) ;
+ gp_Dir aReferencePlane (myCamera->Direction().Reversed());
+ gp_Dir anUp;
+
+ anUp = gp_Dir (0.0, 0.0, 1.0);
+
+ TheStatus = ScreenAxis(aReferencePlane, anUp,
+ myXscreenAxis,myYscreenAxis,myZscreenAxis) ;
if( !TheStatus ) {
- MyViewReferenceUp.SetCoord(0.,1.,0.) ;
- TheStatus = ScreenAxis(MyViewReferencePlane,MyViewReferenceUp,
- MyXscreenAxis,MyYscreenAxis,MyZscreenAxis) ;
+ anUp = gp_Dir (0.0, 1.0, 0.0);
+ TheStatus = ScreenAxis(aReferencePlane, anUp,
+ myXscreenAxis,myYscreenAxis,myZscreenAxis) ;
}
if( !TheStatus ) {
- MyViewReferenceUp.SetCoord(1.,0.,0.) ;
- TheStatus = ScreenAxis(MyViewReferencePlane,MyViewReferenceUp,
- MyXscreenAxis,MyYscreenAxis,MyZscreenAxis) ;
+ anUp = gp_Dir (1.0, 0.0, 0.0);
+ TheStatus = ScreenAxis(aReferencePlane, anUp,
+ myXscreenAxis,myYscreenAxis,myZscreenAxis) ;
}
V3d_BadValue_Raise_if( !TheStatus,"V3d_ViewSetTwist, alignment of Eye,At,Up,");
+
+ gp_Pnt aRCenter = myCamera->Center();
+ gp_Dir aZAxis (myCamera->Direction().Reversed());
+
+ gp_Trsf aTrsf;
+ aTrsf.SetRotation (gp_Ax1 (aRCenter, aZAxis), Angle);
+
+ Standard_Real myYscreenAxisX, myYscreenAxisY, myYscreenAxisZ;
+ myYscreenAxis.Coord (myYscreenAxisX, myYscreenAxisY, myYscreenAxisZ);
+
+ myCamera->BeginUpdate();
+ myCamera->SetUp (gp_Dir (myYscreenAxisX, myYscreenAxisY, myYscreenAxisZ));
+ myCamera->Transform (aTrsf);
+ myCamera->EndUpdate();
+
+ AutoZFit();
- MyViewReferencePoint = MyViewOrientation.ViewReferencePoint() ;
- RotAxis(MyViewReferencePoint,MyZscreenAxis,Angle,Matrix) ;
- MyViewReferenceUp = TrsPoint(MyYscreenAxis,Matrix) ;
- MyViewOrientation.SetViewReferenceUp(MyViewReferenceUp) ;
- MyView->SetViewOrientation(MyViewOrientation) ;
ImmediateUpdate();
}
-#ifdef IMP240100
-void V3d_View::SetProjModel( const V3d_TypeOfProjectionModel aModel )
+void V3d_View::SetAutoZFitMode (Standard_Boolean theMode)
{
- MyProjModel = aModel;
+ myAutoZFitMode = theMode;
}
-V3d_TypeOfProjectionModel V3d_View::ProjModel() const
+Standard_Boolean V3d_View::AutoZFitMode () const
{
- return MyProjModel;
+ return myAutoZFitMode;
}
-#endif
void V3d_View::SetEye(const Standard_Real X,const Standard_Real Y,const Standard_Real Z)
{
- Standard_Real Angle,Xat,Yat,Zat,Xrp,Yrp,Zrp,Xpn,Ypn,Zpn ;
- Angle = Twist() ;
- MyProjReferencePoint = MyViewMapping.ProjectionReferencePoint() ;
- MyProjReferencePoint.Coord(Xrp,Yrp,Zrp) ;
- MyViewReferencePoint = MyViewOrientation.ViewReferencePoint() ;
- MyViewReferencePoint.Coord(Xat,Yat,Zat) ;
- MyViewReferenceUp = MyViewOrientation.ViewReferenceUp() ;
- Xpn = X - Xat ; Ypn = Y - Yat ; Zpn = Z - Zat ;
- Zrp = Sqrt(Xpn*Xpn + Ypn*Ypn + Zpn*Zpn) ;
- V3d_BadValue_Raise_if( Zrp <= 0. , "V3d_View::SetEye:: Eye,At are Confused");
-
- Xpn /= Zrp ; Ypn /= Zrp ; Zpn /= Zrp ;
- MyViewReferencePlane.SetCoord(Xpn,Ypn,Zpn) ;
- MyViewOrientation.SetViewReferencePlane(MyViewReferencePlane) ;
- MyProjReferencePoint.SetCoord(Xrp,Yrp,Zrp) ;
- MyViewMapping.SetProjectionReferencePoint(MyProjReferencePoint);
+ Standard_Real Angle;
+ Angle = Twist();
+
+ myCamera->SetEye (gp_Pnt (X, Y, Z));
Standard_Boolean update = myImmediateUpdate;
myImmediateUpdate = Standard_False;
- if( MyProjModel == V3d_TPM_WALKTHROUGH ) {
- //FMN desactivation temp SetTwist(Angle) ;
- // Set infos.
- MyView->SetViewOrientation(MyViewOrientation) ;
- MyView->SetViewMapping(MyViewMapping) ;
- } else {
- SetTwist(Angle) ;
- }
-#ifdef IMP020300
- SetZSize(0.) ;
-#else
- // Check ZClipping planes
- Standard_Real Zmax = Sqrt( X*X + Y*Y + Z*Z ) ;
- if( Zmax > MyViewMapping.FrontPlaneDistance() &&
- MyProjModel == V3d_TPM_SCREEN ) {
- SetZSize(2.*Zmax+Zmax*Zmargin) ;
- } else {
- if( MyType == V3d_PERSPECTIVE ) SetFocale(focale) ;
- MyView->SetViewMapping(MyViewMapping);
- }
-#endif
- myImmediateUpdate = update;
- ImmediateUpdate();
+
+ SetTwist(Angle);
+
+ AutoZFit();
+
+ myImmediateUpdate = update;
+ ImmediateUpdate();
}
void V3d_View::SetDepth(const Standard_Real Depth)
{
- Standard_Real Xrp,Yrp,Zrp ;
-#ifdef IMP250200
- V3d_BadValue_Raise_if( Depth == 0. ,"V3d_View::SetDepth, bad depth");
-#else
- V3d_BadValue_Raise_if( Depth <= 0. ,"V3d_View::SetDepth, bad depth");
-#endif
+ V3d_BadValue_Raise_if (Depth == 0. ,"V3d_View::SetDepth, bad depth");
- MyViewReferencePoint = MyViewOrientation.ViewReferencePoint() ;
- MyViewReferencePlane = MyViewOrientation.ViewReferencePlane() ;
- MyProjReferencePoint = MyViewMapping.ProjectionReferencePoint() ;
- MyProjReferencePoint.Coord(Xrp,Yrp,Zrp) ;
-#ifdef IMP250200
if( Depth > 0. )
-#endif
{
- Zrp = Depth;
- MyProjReferencePoint.SetCoord(Xrp,Yrp,Zrp) ;
- MyViewMapping.SetProjectionReferencePoint(MyProjReferencePoint);
- }
-
- // Check ZClipping planes
- Standard_Real Xat,Yat,Zat,Xpn,Ypn,Zpn,Xeye,Yeye,Zeye ;
- MyViewReferencePoint.Coord(Xat,Yat,Zat) ;
- MyViewReferencePlane.Coord(Xpn,Ypn,Zpn) ;
-#ifdef IMP250200
- if( Depth < 0. ) { // Move the view ref point instead of the eye.
- Xeye = Xpn*Zrp + Xat ; Yeye = Ypn*Zrp + Yat ; Zeye = Zpn*Zrp + Zat ;
- Zrp = Abs(Depth) ;
- Xat = Xeye - Xpn*Zrp ; Yat = Yeye - Ypn*Zrp ; Zat = Zeye - Zpn*Zrp;
- MyViewReferencePoint.SetCoord(Xat,Yat,Zat) ;
- MyProjReferencePoint.SetCoord(Xrp,Yrp,Zrp) ;
- MyViewOrientation.SetViewReferencePoint(MyViewReferencePoint) ;
- MyView->SetViewOrientation(MyViewOrientation);
+ // Move eye using center (target) as anchor.
+ myCamera->SetDistance (Depth);
+ }
+ else
+ {
+ // Move the view ref point instead of the eye.
+ gp_Vec aDir (myCamera->Direction());
+ gp_Pnt aCameraEye = myCamera->Eye();
+ gp_Pnt aCameraCenter = aCameraEye.Translated (aDir.Multiplied (Abs (Depth)));
+
+ myCamera->SetCenter (aCameraCenter);
}
-#endif
-#ifdef IMP020300
- MyView->SetViewMapping(MyViewMapping) ;
- SetZSize(0.) ;
-#else
- Xeye = Xpn*Zrp + Xat ; Yeye = Ypn*Zrp + Yat ; Zeye = Zpn*Zrp + Zat ;
- Standard_Real Zmax = Sqrt( Xeye*Xeye + Yeye*Yeye + Zeye*Zeye );
-
- if( Zmax > MyViewMapping.FrontPlaneDistance() &&
- MyProjModel == V3d_TPM_SCREEN ) {
- SetZSize(2.*Zmax+Zmax*Zmargin) ;
- } else {
- if( MyType == V3d_PERSPECTIVE ) SetFocale(focale) ;
-#ifdef IMP250200
- if( Depth > 0. )
-#endif
- MyView->SetViewMapping(MyViewMapping) ;
- }
-#endif
- ImmediateUpdate();
+ AutoZFit();
+
+ ImmediateUpdate();
}
V3d_BadValue_Raise_if( Sqrt(Vx*Vx + Vy*Vy + Vz*Vz) <= 0.,
"V3d_View::SetProj, null projection vector");
- Angle = Twist() ;
- MyViewReferencePlane.SetCoord(Vx,Vy,Vz) ;
- MyViewReferencePlane.Normalize() ;
- MyViewOrientation.SetViewReferencePlane(MyViewReferencePlane) ;
+ Angle = Twist();
+
+ myCamera->SetDirection (gp_Dir (Vx, Vy, Vz).Reversed());
+
Standard_Boolean update = myImmediateUpdate;
myImmediateUpdate = Standard_False;
+
if( MyProjModel == V3d_TPM_SCREEN ) SetTwist(Angle) ;
-#ifdef IMP020300
- SetZSize(0.) ;
-#endif
+
+ AutoZFit();
+
myImmediateUpdate = update;
ImmediateUpdate();
}
void V3d_View::SetProj( const V3d_TypeOfOrientation Orientation )
{
- MyViewReferencePlane = V3d::GetProjAxis(Orientation) ;
- MyViewOrientation.SetViewReferencePlane(MyViewReferencePlane) ;
- // MSV 14.03.2007: reset ViewReferencePoint to debug LH3D14955
- MyViewOrientation.SetViewReferencePoint(Graphic3d_Vertex (0.0f, 0.0f, 0.0f));
Standard_Real Xpn=0;
Standard_Real Ypn=0;
Standard_Real Zpn=0;
switch (Orientation) {
case V3d_Zpos :
- Ypn = 1. ;
- break ;
+ Ypn = 1.;
+ break;
case V3d_Zneg :
- Ypn = -1. ;
- break ;
+ Ypn = -1.;
+ break;
default:
Zpn = 1.;
}
- SetUp(Xpn,Ypn,Zpn);
-#ifdef IMP020300
- SetZSize(0.) ;
-#endif
+
+ const Graphic3d_Vector& aBck = V3d::GetProjAxis (Orientation);
+ myCamera->BeginUpdate();
+ myCamera->SetCenter (gp_Pnt (0, 0, 0));
+ myCamera->SetDirection (gp_Dir (aBck.X(), aBck.Y(), aBck.Z()).Reversed());
+ myCamera->SetUp (gp_Dir (Xpn, Ypn, Zpn));
+ myCamera->EndUpdate();
+
+ AutoZFit();
+
ImmediateUpdate();
}
void V3d_View::SetAt(const Standard_Real X,const Standard_Real Y,const Standard_Real Z)
{
- Standard_Real Angle,Xrp,Yrp,Zrp,Xpn,Ypn,Zpn,Xat,Yat,Zat ;
- Standard_Real Xeye,Yeye,Zeye ;
-
- Angle = Twist() ;
- MyProjReferencePoint = MyViewMapping.ProjectionReferencePoint() ;
- MyProjReferencePoint.Coord(Xrp,Yrp,Zrp) ;
- MyViewReferencePlane = MyViewOrientation.ViewReferencePlane() ;
- MyViewReferencePlane.Coord(Xpn,Ypn,Zpn) ;
- MyViewReferencePoint = MyViewOrientation.ViewReferencePoint() ;
- MyViewReferencePoint.Coord(Xat,Yat,Zat) ;
- Xeye = Zrp*Xpn + Xat ; Yeye = Zrp*Ypn + Yat ; Zeye = Zrp*Zpn + Zat ;
- Xpn = Xeye - X ; Ypn = Yeye - Y ; Zpn = Zeye - Z ;
- Zrp = Sqrt(Xpn*Xpn + Ypn*Ypn + Zpn*Zpn) ;
- V3d_BadValue_Raise_if( Zrp <= 0.,
- "V3d_View::SetAt, Eye,At are Confused");
-
- Xpn /= Zrp ; Ypn /= Zrp ; Zpn /= Zrp ;
- MyViewReferencePoint.SetCoord(X,Y,Z) ;
- MyViewOrientation.SetViewReferencePoint(MyViewReferencePoint) ;
- MyViewReferencePlane.SetCoord(Xpn,Ypn,Zpn) ;
- MyViewOrientation.SetViewReferencePlane(MyViewReferencePlane) ;
- MyProjReferencePoint.SetCoord(Xrp,Yrp,Zrp) ;
- MyViewMapping.SetProjectionReferencePoint(MyProjReferencePoint);
+ Standard_Real Angle;
+
+ Angle = Twist();
+
+ myCamera->SetCenter (gp_Pnt (X, Y, Z));
Standard_Boolean update = myImmediateUpdate;
myImmediateUpdate = Standard_False;
- if( MyProjModel == V3d_TPM_WALKTHROUGH ) {
- //FMN desactivation temp SetTwist(Angle) ;
- // Set infos.
- MyView->SetViewOrientation(MyViewOrientation) ;
- MyView->SetViewMapping(MyViewMapping) ;
- } else {
- SetTwist(Angle) ;
- }
-#ifdef IMP020300
- MyView->SetViewMapping(MyViewMapping);
- SetZSize(0.) ;
-#else
+
+ SetTwist(Angle) ;
+
+ AutoZFit();
+
+ myImmediateUpdate = update;
ImmediateUpdate();
- // Check ZClipping planes
- Standard_Real Zmax = Sqrt( X*X + Y*Y + Z*Z ) ;
- if( Zmax > MyViewMapping.FrontPlaneDistance() &&
- MyProjModel == V3d_TPM_SCREEN ) {
- SetZSize(2.*Zmax+Zmax*Zmargin) ;
- } else {
- if( MyType == V3d_PERSPECTIVE ) SetFocale(focale) ;
- MyView->SetViewMapping(MyViewMapping);
- }
-#endif
- myImmediateUpdate = update;
- ImmediateUpdate();
}
void V3d_View::SetUp(const Standard_Real Vx,const Standard_Real Vy,const Standard_Real Vz)
V3d_BadValue_Raise_if( Sqrt(Vx*Vx + Vy*Vy + Vz*Vz) <= 0. ,
"V3d_View::SetUp, nullUp vector");
- MyViewReferencePlane = MyViewOrientation.ViewReferencePlane() ;
- MyViewReferenceUp.SetCoord(Vx,Vy,Vz) ;
- MyViewReferenceUp.Normalize() ;
- TheStatus = ScreenAxis(MyViewReferencePlane,MyViewReferenceUp,
- MyXscreenAxis,MyYscreenAxis,MyZscreenAxis) ;
+ gp_Dir aReferencePlane (myCamera->Direction().Reversed());
+ gp_Dir anUp (Vx, Vy, Vz);
+
+ TheStatus = ScreenAxis(aReferencePlane,anUp,
+ myXscreenAxis,myYscreenAxis,myZscreenAxis) ;
if( !TheStatus ) {
- MyViewReferenceUp.SetCoord(0.,0.,1.) ;
- TheStatus = ScreenAxis(MyViewReferencePlane,MyViewReferenceUp,
- MyXscreenAxis,MyYscreenAxis,MyZscreenAxis) ;
+ anUp = gp_Dir (0.0, 0.0, 1.0);
+ TheStatus = ScreenAxis(aReferencePlane,anUp,
+ myXscreenAxis,myYscreenAxis,myZscreenAxis) ;
}
if( !TheStatus ) {
- MyViewReferenceUp.SetCoord(0.,1.,0.) ;
- TheStatus = ScreenAxis(MyViewReferencePlane,MyViewReferenceUp,
- MyXscreenAxis,MyYscreenAxis,MyZscreenAxis) ;
+ anUp = gp_Dir (0.0, 1.0, 0.0);
+ TheStatus = ScreenAxis(aReferencePlane,anUp,
+ myXscreenAxis,myYscreenAxis,myZscreenAxis) ;
}
if( !TheStatus ) {
- MyViewReferenceUp.SetCoord(1.,0.,0.) ;
- TheStatus = ScreenAxis(MyViewReferencePlane,MyViewReferenceUp,
- MyXscreenAxis,MyYscreenAxis,MyZscreenAxis) ;
+ anUp = gp_Dir (1.0, 0.0, 0.0);
+ TheStatus = ScreenAxis(aReferencePlane,anUp,
+ myXscreenAxis,myYscreenAxis,myZscreenAxis) ;
}
V3d_BadValue_Raise_if( !TheStatus,"V3d_View::Setup, alignment of Eye,At,Up");
- MyViewReferenceUp = MyYscreenAxis ;
- MyViewOrientation.SetViewReferenceUp(MyViewReferenceUp) ;
- MyView->SetViewOrientation(MyViewOrientation) ;
+ Standard_Real myYscreenAxisX, myYscreenAxisY, myYscreenAxisZ;
+ myYscreenAxis.Coord (myYscreenAxisX, myYscreenAxisY, myYscreenAxisZ);
+
+ myCamera->BeginUpdate();
+ myCamera->SetUp (gp_Dir (myYscreenAxisX, myYscreenAxisY, myYscreenAxisZ));
+ AutoZFit();
+ myCamera->EndUpdate();
+
ImmediateUpdate();
}
{
Standard_Boolean TheStatus ;
- MyViewReferenceUp = V3d::GetProjAxis(Orientation) ;
- MyViewReferencePlane = MyViewOrientation.ViewReferencePlane() ;
- TheStatus = ScreenAxis(MyViewReferencePlane,MyViewReferenceUp,
- MyXscreenAxis,MyYscreenAxis,MyZscreenAxis) ;
+ gp_Dir aReferencePlane (myCamera->Direction().Reversed());
+ gp_Dir anUp;
+
+ const Graphic3d_Vector& aViewReferenceUp = V3d::GetProjAxis(Orientation) ;
+ anUp = gp_Dir (aViewReferenceUp.X(), aViewReferenceUp.Y(), aViewReferenceUp.Z());
+
+ TheStatus = ScreenAxis(aReferencePlane,anUp,
+ myXscreenAxis,myYscreenAxis,myZscreenAxis) ;
if( !TheStatus ) {
- MyViewReferenceUp.SetCoord(0.,0.,1.) ;
- TheStatus = ScreenAxis(MyViewReferencePlane,MyViewReferenceUp,
- MyXscreenAxis,MyYscreenAxis,MyZscreenAxis) ;
+ anUp = gp_Dir (0.,0.,1.);
+ TheStatus = ScreenAxis(aReferencePlane,anUp,
+ myXscreenAxis,myYscreenAxis,myZscreenAxis) ;
}
if( !TheStatus ) {
- MyViewReferenceUp.SetCoord(0.,1.,0.) ;
- TheStatus = ScreenAxis(MyViewReferencePlane,MyViewReferenceUp,
- MyXscreenAxis,MyYscreenAxis,MyZscreenAxis) ;
+ anUp = gp_Dir (0.,1.,0.);
+ TheStatus = ScreenAxis(aReferencePlane,anUp,
+ myXscreenAxis,myYscreenAxis,myZscreenAxis) ;
}
if( !TheStatus ) {
- MyViewReferenceUp.SetCoord(1.,0.,0.) ;
- TheStatus = ScreenAxis(MyViewReferencePlane,MyViewReferenceUp,
- MyXscreenAxis,MyYscreenAxis,MyZscreenAxis) ;
+ anUp = gp_Dir (1.,0.,0.);
+ TheStatus = ScreenAxis(aReferencePlane,anUp,
+ myXscreenAxis,myYscreenAxis,myZscreenAxis) ;
}
V3d_BadValue_Raise_if( !TheStatus, "V3d_View::SetUp, alignment of Eye,At,Up");
- MyViewReferenceUp = MyYscreenAxis ;
- MyViewOrientation.SetViewReferenceUp(MyViewReferenceUp) ;
- MyView->SetViewOrientation(MyViewOrientation) ;
- ImmediateUpdate();
-}
+ Standard_Real myYscreenAxisX, myYscreenAxisY, myYscreenAxisZ;
+ myYscreenAxis.Coord (myYscreenAxisX, myYscreenAxisY, myYscreenAxisZ);
+
+ myCamera->BeginUpdate();
+ myCamera->SetUp (gp_Dir (myYscreenAxisX, myYscreenAxisY, myYscreenAxisZ));
+ AutoZFit();
+ myCamera->EndUpdate();
-void V3d_View::SetViewOrientation(const Visual3d_ViewOrientation& VO)
-{
- MyViewOrientation = VO;
- MyView->SetViewOrientation(MyViewOrientation) ;
ImmediateUpdate();
}
void V3d_View::SetViewOrientationDefault()
{
- MyView->SetViewOrientation(MyViewOrientation) ;
MyView->SetViewOrientationDefault() ;
+
ImmediateUpdate();
}
void V3d_View::ResetViewOrientation()
{
MyView->ViewOrientationReset() ;
- MyViewOrientation = MyView->ViewOrientation() ;
+
ImmediateUpdate();
}
void V3d_View::Reset( const Standard_Boolean update )
{
- MyView->ViewOrientationReset() ;
- MyViewOrientation = MyView->ViewOrientation() ;
- MyView->ViewMappingReset();
- MyViewMapping = MyView->ViewMapping() ;
+ Handle(Graphic3d_Camera) aDefaultCamera = MyView->DefaultCamera();
+
+ if (!aDefaultCamera.IsNull())
+ {
+ myCamera->BeginUpdate();
+ myCamera->CopyMappingData (aDefaultCamera);
+ myCamera->CopyOrientationData (aDefaultCamera);
+ myCamera->EndUpdate();
+ }
- ZFitAll (Zmargin);
+ AutoZFit();
SwitchSetFront = Standard_False;
-#ifdef IMP020300
+
if( !myImmediateUpdate && update ) Update();
-#else
- ImmediateUpdate();
-#endif
}
void V3d_View::Panning(const Standard_Real Dx, const Standard_Real Dy, const Quantity_Factor aZoomFactor, const Standard_Boolean Start)
{
- Standard_Real Umin,Vmin,Umax,Vmax,Xrp,Yrp,Zrp,Dxv,Dyv ;
V3d_BadValue_Raise_if( aZoomFactor <= 0.,"V3d_View::Panning, bad zoom factor");
if( Start ) {
- MyProjReferencePoint = MyViewMapping.ProjectionReferencePoint() ;
- MyViewMapping.WindowLimit(Umin,Vmin,Umax,Vmax) ;
- MyXwindowCenter = (Umin + Umax)/2. ;
- MyYwindowCenter = (Vmin + Vmax)/2. ;
- MyWindowWidth = Abs(Umax - Umin) ;
- MyWindowHeight = Abs(Vmax - Vmin) ;
- V3d_BadValue_Raise_if( MyWindowWidth <= 0. || MyWindowHeight <= 0. ,
- "V3d_View::Panning, Window Size is NULL");
- }
- MyProjReferencePoint.Coord(Xrp,Yrp,Zrp) ;
- Xrp = MyXwindowCenter - Dx ;
- Yrp = MyYwindowCenter - Dy ;
- Dxv = MyWindowWidth/aZoomFactor ; Dyv = MyWindowHeight/aZoomFactor ;
- Umin = Xrp - Dxv/2. ; Umax = Xrp + Dxv/2. ;
- Vmin = Yrp - Dyv/2. ; Vmax = Yrp + Dyv/2. ;
- MyViewMapping.SetWindowLimit(Umin,Vmin,Umax,Vmax) ;
- if( MyType != V3d_PERSPECTIVE ) {
- MyProjReferencePoint.SetCoord(Xrp,Yrp,Zrp) ;
- MyViewMapping.SetProjectionReferencePoint(MyProjReferencePoint) ;
- }
- MyView->SetViewMapping(MyViewMapping) ;
+ myCamStartOpEye = myCamera->Eye();
+ myCamStartOpCenter = myCamera->Center();
+ myCamProjectionShift = myCamera->ProjectionShift();
+ }
+
+ myCamera->BeginUpdate();
+ myCamera->SetEye (myCamStartOpEye);
+ myCamera->SetCenter (myCamStartOpCenter);
+ myCamera->SetProjectionShift (myCamProjectionShift);
+ PanCamera (-Dx, -Dy);
+ gp_Pnt aViewDims = myCamera->ViewDimensions();
+ ZoomCamera (aViewDims.X() / aZoomFactor, aViewDims.Y() / aZoomFactor);
+ myCamera->EndUpdate();
+
ImmediateUpdate();
}
void V3d_View::SetCenter(const Standard_Real Xc, const Standard_Real Yc)
{
- Standard_Real Umin,Vmin,Umax,Vmax,Xrp,Yrp,Zrp ;
+ myCamera->SetProjectionShift (gp_Pnt (-Xc, -Yc, 0.0));
- MyProjReferencePoint = MyViewMapping.ProjectionReferencePoint() ;
- MyProjReferencePoint.Coord(Xrp,Yrp,Zrp) ;
- MyXwindowCenter = Xrp = Xc ; MyYwindowCenter = Yrp = Yc ;
- MyViewMapping.WindowLimit(Umin,Vmin,Umax,Vmax) ;
- MyWindowWidth = Abs(Umax - Umin) ; MyWindowHeight = Abs(Vmax - Vmin) ;
- V3d_BadValue_Raise_if( MyWindowWidth <= 0. || MyWindowHeight <= 0. ,
- "V3d_View::SetCenter, Window Size is NULL");
-
- Umin = Xc - MyWindowWidth/2. ; Vmin = Yc - MyWindowHeight/2. ;
- Umax = Xc + MyWindowWidth/2. ; Vmax = Yc + MyWindowHeight/2. ;
- MyViewMapping.SetWindowLimit(Umin,Vmin,Umax,Vmax) ;
- if( MyType != V3d_PERSPECTIVE ) {
- MyProjReferencePoint.SetCoord(Xrp,Yrp,Zrp) ;
- MyViewMapping.SetProjectionReferencePoint(MyProjReferencePoint) ;
- }
- MyView->SetViewMapping(MyViewMapping) ;
ImmediateUpdate();
}
void V3d_View::SetSize(const Standard_Real Size)
{
- Standard_Real Umin,Vmin,Umax,Vmax,Rap ;
-
V3d_BadValue_Raise_if( Size <= 0.,
"V3d_View::SetSize, Window Size is NULL");
+ myCamera->BeginUpdate();
+ myCamera->SetScale (Size);
+ AutoZFit();
+ myCamera->EndUpdate();
- MyViewMapping.WindowLimit(Umin,Vmin,Umax,Vmax) ;
- MyWindowWidth = Abs(Umax - Umin) ;
- MyWindowHeight = Abs(Vmax - Vmin) ;
- MyXwindowCenter = (Umin + Umax)/2. ;
- MyYwindowCenter = (Vmin + Vmax)/2. ;
- Rap = MyWindowWidth/MyWindowHeight ;
- if( MyWindowWidth >= MyWindowHeight ) {
- MyWindowWidth = Size ; MyWindowHeight = Size/Rap ;
- } else {
- MyWindowHeight = Size ; MyWindowWidth = Size*Rap ;
- }
- Umin = MyXwindowCenter - MyWindowWidth/2. ;
- Vmin = MyYwindowCenter - MyWindowHeight/2. ;
- Umax = MyXwindowCenter + MyWindowWidth/2. ;
- Vmax = MyYwindowCenter + MyWindowHeight/2. ;
- MyViewMapping.SetWindowLimit(Umin,Vmin,Umax,Vmax) ;
- MyView->SetViewMapping(MyViewMapping) ;
ImmediateUpdate();
}
{
Standard_Real Zmax = Size/2.;
-#ifdef IMP020300
+ Standard_Real aDistance = myCamera->Distance();
+
if( Size <= 0. ) {
- Standard_Real Xat,Yat,Zat,Xpn,Ypn,Zpn,Xrp,Yrp,Zrp,Xeye,Yeye,Zeye;
- MyViewReferencePoint.Coord(Xat,Yat,Zat) ;
- MyProjReferencePoint.Coord(Xrp,Yrp,Zrp) ;
- MyViewReferencePlane.Coord(Xpn,Ypn,Zpn) ;
- Xeye = Zrp*Xpn + Xat ; Yeye = Zrp*Ypn + Yat ; Zeye = Zrp*Zpn + Zat;
- Zmax = Sqrt( Xeye*Xeye + Yeye*Yeye + Zeye*Zeye );
- if( Zmax <= MyViewMapping.FrontPlaneDistance() ) return;
+ Zmax = aDistance;
}
-#else
- V3d_BadValue_Raise_if( Size <= 0.,
- "V3d_View::SetZSize, Window ZSize is NULL");
-#endif
- Standard_Real Front = MyViewContext.ZClippingFrontPlane() ;
- Standard_Real Back = MyViewContext.ZClippingBackPlane() ;
+ Standard_Real Front = MyViewContext.ZClippingFrontPlane();
+ Standard_Real Back = MyViewContext.ZClippingBackPlane();
- MyViewMapping.SetFrontPlaneDistance(Zmax) ;
- MyViewMapping.SetBackPlaneDistance(-Zmax) ;
+ myCamera->SetZFar (Zmax + aDistance * 2.0);
+ myCamera->SetZNear (-Zmax + aDistance);
- // OCC18942
- if( MyProjModel != V3d_TPM_WALKTHROUGH ) {
- MyViewMapping.SetViewPlaneDistance(MyType == V3d_PERSPECTIVE ? 0. : Zmax) ;
- }
-
- MyView->SetViewMapping(MyViewMapping) ;
- if( MyViewContext.FrontZClippingIsOn() ||
- MyViewContext.BackZClippingIsOn() )
+ if (MyViewContext.FrontZClippingIsOn() ||
+ MyViewContext.BackZClippingIsOn())
{
- MyViewContext.SetZClippingFrontPlane(Front) ;
- MyViewContext.SetZClippingBackPlane(Back) ;
- MyView->SetContext(MyViewContext) ;
+ MyViewContext.SetZClippingFrontPlane (Front);
+ MyViewContext.SetZClippingBackPlane (Back);
+ MyView->SetContext (MyViewContext);
}
}
void V3d_View::SetZoom(const Standard_Real Coef,const Standard_Boolean Start)
{
- Standard_Real Umin,Vmin,Umax,Vmax,Dxv,Dyv ;
V3d_BadValue_Raise_if( Coef <= 0.,"V3d_View::SetZoom, bad coefficient");
- if( Start ) {
- MyViewMapping.WindowLimit(Umin,Vmin,Umax,Vmax) ;
- MyXwindowCenter = (Umin + Umax)/2. ;
- MyYwindowCenter = (Vmin + Vmax)/2. ;
- MyWindowWidth = Abs(Umax - Umin) ;
- MyWindowHeight = Abs(Vmax - Vmin) ;
+ if (Start)
+ {
+ myCamStartOpEye = myCamera->Eye();
+ myCamStartOpCenter = myCamera->Center();
}
+ Standard_Real aViewWidth = myCamera->ViewDimensions().X();
+ Standard_Real aViewHeight = myCamera->ViewDimensions().Y();
+
// ensure that zoom will not be too small or too big
Standard_Real coef = Coef;
- if ( MyWindowWidth < coef * Precision::Confusion() )
- coef = MyWindowWidth / Precision::Confusion();
- else if ( MyWindowWidth > coef * 1e12 )
- coef = MyWindowWidth / 1e12;
- if ( MyWindowHeight < coef * Precision::Confusion() )
- coef = MyWindowHeight / Precision::Confusion();
- else if ( MyWindowHeight > coef * 1e12 )
- coef = MyWindowHeight / 1e12;
-
- Dxv = MyWindowWidth/coef;
- Dyv = MyWindowHeight/coef;
- Umin = MyXwindowCenter - Dxv/2. ; Umax = MyXwindowCenter + Dxv/2. ;
- Vmin = MyYwindowCenter - Dyv/2. ; Vmax = MyYwindowCenter + Dyv/2. ;
- MyViewMapping.SetWindowLimit(Umin,Vmin,Umax,Vmax) ;
- MyView->SetViewMapping(MyViewMapping) ;
+ if (aViewWidth < coef * Precision::Confusion())
+ {
+ coef = aViewWidth / Precision::Confusion();
+ }
+ else if (aViewWidth > coef * 1e12)
+ {
+ coef = aViewWidth / 1e12;
+ }
+ if (aViewHeight < coef * Precision::Confusion())
+ {
+ coef = aViewHeight / Precision::Confusion();
+ }
+ else if (aViewHeight > coef * 1e12)
+ {
+ coef = aViewHeight / 1e12;
+ }
+
+ myCamera->BeginUpdate();
+ myCamera->SetEye (myCamStartOpEye);
+ myCamera->SetCenter (myCamStartOpCenter);
+ myCamera->SetScale (myCamera->Scale() / Coef);
+ AutoZFit();
+ myCamera->EndUpdate();
+
ImmediateUpdate();
}
void V3d_View::SetScale( const Standard_Real Coef )
{
- Standard_Real Umin,Vmin,Umax,Vmax,Xrp,Yrp,Dxv,Dyv ;
- Visual3d_ViewMapping VMD = MyView->ViewMappingDefault() ;
-
V3d_BadValue_Raise_if( Coef <= 0. ,"V3d_View::SetScale, bad coefficient");
- VMD.WindowLimit(Umin,Vmin,Umax,Vmax) ;
- Dxv = Abs(Umax - Umin) ; Dyv = Abs(Vmax - Vmin) ;
- Dxv /= Coef ; Dyv /= Coef ;
- MyViewMapping.WindowLimit(Umin,Vmin,Umax,Vmax) ;
- Xrp = (Umin + Umax)/2. ; Yrp = (Vmin + Vmax)/2. ;
- Umin = Xrp - Dxv/2. ; Umax = Xrp + Dxv/2. ;
- Vmin = Yrp - Dyv/2. ; Vmax = Yrp + Dyv/2. ;
- MyViewMapping.SetWindowLimit(Umin,Vmin,Umax,Vmax) ;
- MyView->SetViewMapping(MyViewMapping) ;
+ Handle(Graphic3d_Camera) aDefaultCamera = MyView->DefaultCamera();
+
+ myCamera->BeginUpdate();
+
+ // Strange behavior for the sake of compatibility.
+ if (!aDefaultCamera.IsNull())
+ {
+ myCamera->SetAspect (aDefaultCamera->Aspect());
+ Standard_Real aDefaultScale = aDefaultCamera->Scale();
+ myCamera->SetScale (aDefaultScale / Coef);
+ }
+ else
+ {
+ myCamera->SetScale (myCamera->Scale() / Coef);
+ }
+
+ AutoZFit();
+ myCamera->EndUpdate();
+
ImmediateUpdate();
}
void V3d_View::SetAxialScale( const Standard_Real Sx, const Standard_Real Sy, const Standard_Real Sz )
{
- Standard_Real Xmin,Ymin,Zmin,Xmax,Ymax,Zmax,U,V,W ;
- Standard_Real Umin,Vmin,Wmin,Umax,Vmax,Wmax ;
V3d_BadValue_Raise_if( Sx <= 0. || Sy <= 0. || Sz <= 0.,"V3d_View::SetAxialScale, bad coefficient");
- MyViewOrientation.SetAxialScale( Sx, Sy, Sz );
- Aspect_TypeOfUpdate updateMode = MyView->ViewManager()->UpdateMode();
- MyView->ViewManager()->SetUpdateMode(Aspect_TOU_ASAP);
- MyView->SetViewOrientation(MyViewOrientation);
- MyView->ViewManager()->SetUpdateMode(updateMode);
-
- MyView->MinMaxValues(Xmin,Ymin,Zmin,Xmax,Ymax,Zmax) ;
-
- Standard_Real LIM = ShortRealLast() -1.;
- if (Abs(Xmin) > LIM || Abs(Ymin) > LIM || Abs(Zmin) > LIM
- || Abs(Xmax) > LIM || Abs(Ymax) > LIM || Abs(Zmax) > LIM ) {
- return;
- }
-
- MyView->Projects(Xmin,Ymin,Zmin,Umin,Vmin,Wmin) ;
- MyView->Projects(Xmax,Ymax,Zmax,Umax,Vmax,Wmax) ;
- Umax = Max(Umin,Umax) ; Vmax = Max(Vmin,Vmax) ;
- MyView->Projects(Xmin,Ymin,Zmax,U,V,W) ;
- Umax = Max(Umax,U) ; Vmax = Max(Vmax,V) ;
- Wmin = Min(W,Wmin) ; Wmax = Max(W,Wmax) ;
- MyView->Projects(Xmax,Ymin,Zmax,U,V,W) ;
- Umax = Max(Umax,U) ; Vmax = Max(Vmax,V) ;
- Wmin = Min(W,Wmin) ; Wmax = Max(W,Wmax) ;
- MyView->Projects(Xmax,Ymin,Zmin,U,V,W) ;
- Umax = Max(Umax,U) ; Vmax = Max(Vmax,V) ;
- Wmin = Min(W,Wmin) ; Wmax = Max(W,Wmax) ;
- MyView->Projects(Xmax,Ymax,Zmin,U,V,W) ;
- Umax = Max(Umax,U) ; Vmax = Max(Vmax,V) ;
- Wmin = Min(W,Wmin) ; Wmax = Max(W,Wmax) ;
- MyView->Projects(Xmin,Ymax,Zmax,U,V,W) ;
- Umax = Max(Umax,U) ; Vmax = Max(Vmax,V) ;
- Wmin = Min(W,Wmin) ; Wmax = Max(W,Wmax) ;
- MyView->Projects(Xmin,Ymax,Zmin,U,V,W) ;
- Umax = Max(Umax,U) ; Vmax = Max(Vmax,V) ;
- Umax = Max(Umax,Vmax) ;
- Wmin = Min(W,Wmin) ; Wmax = Max(W,Wmax) ;
- Wmax = Max(Abs(Wmin),Abs(Wmax)) ;
- Wmax = Max(Abs(Umax),Abs(Wmax)) ;
-
- if( Wmax > 0. ) {
- SetZSize(2.*Wmax + Wmax) ;
- }
+ myCamera->BeginUpdate();
+ myCamera->SetAxialScale (gp_Pnt (Sx, Sy, Sz));
+ AutoZFit();
+ myCamera->EndUpdate();
}
-void V3d_View::FitAll(const Standard_Real Coef, const Standard_Boolean FitZ,
- const Standard_Boolean update)
+void V3d_View::FitAll(const Standard_Real Coef, const Standard_Boolean update)
{
- Standard_Real Umin, Umax, Vmin, Vmax, Xrp, Yrp, Zrp, U, V, W, U1, V1, W1;
Standard_Real Xmin, Ymin, Zmin, Xmax, Ymax, Zmax;
- Standard_Real DxvOld, DyvOld, DxvNew, DyvNew;
- Standard_Integer Nstruct = MyView->NumberOfDisplayedStructures();
-
- if ((Nstruct <= 0) || (Coef < 0.0) || (Coef > 1.0))
- {
-#ifndef IMP020300
- ImmediateUpdate();
-#endif
- return;
- }
-
- MyProjReferencePoint = MyViewMapping.ProjectionReferencePoint();
- MyProjReferencePoint.Coord (Xrp, Yrp, Zrp);
- if (MyView->IsDefined())
- {
- Standard_Integer Xpixel, Ypixel;
- MyWindow->Size (Xpixel, Ypixel);
- DxvOld = Xpixel;
- DyvOld = Ypixel;
- }
- else
- {
- MyViewMapping.WindowLimit (Umin, Vmin, Umax, Vmax);
- DxvOld = Abs (Umax - Umin);
- DyvOld = Abs (Vmax - Vmin);
- }
- if ((DxvOld == 0.0) || (DyvOld == 0.0))
- {
- return;
- }
-
- Standard_Real aWinRatio = DxvOld / DyvOld;
// retrieve min / max values for current displayed objects
MyView->MinMaxValues (Xmin, Ymin, Zmin,
if (Abs(Xmin) > LIM || Abs(Ymin) > LIM || Abs(Zmin) > LIM
|| Abs(Xmax) > LIM || Abs(Ymax) > LIM || Abs(Zmax) > LIM)
{
-#ifndef IMP020300
ImmediateUpdate();
-#endif
return;
}
- // eliminate fluctuations between sequential FitAll() calls
- MyViewMapping.SetWindowLimit (-1.0 * aWinRatio, -1.0, 1.0 * aWinRatio, 1.0);
- if (MyType != V3d_PERSPECTIVE)
+ myCamera->BeginUpdate();
+ FitCamera (Xmin, Ymin, Zmin, Xmax, Ymax, Zmax);
+ myCamera->SetScale (myCamera->Scale() * (1.0 + Coef));
+ AutoZFit();
+ myCamera->EndUpdate();
+
+ if (myImmediateUpdate || update)
{
- MyProjReferencePoint.SetCoord (0.0, 0.0, Zrp);
- MyViewMapping.SetProjectionReferencePoint (MyProjReferencePoint);
+ Update();
}
- MyView->SetViewMapping (MyViewMapping);
+}
- // iterate 2 times to find optimal view plane size
- // (use view plane values computed on previous iteration)
- for (Standard_Integer aIteration = 2; aIteration > 0; --aIteration)
+//===============================================================================================
+//function : AutoZFit
+//purpose :
+//===============================================================================================
+void V3d_View::AutoZFit()
+{
+ if (myAutoZFitMode)
{
- MyView->Projects (Xmin, Ymin, Zmin, U, V, W);
- MyView->Projects (Xmax, Ymax, Zmax, U1, V1, W1);
- Umin = Min (U, U1); Umax = Max (U, U1);
- Vmin = Min (V, V1); Vmax = Max (V, V1);
+ ZFitAll();
+ }
+}
- MyView->Projects (Xmin, Ymin, Zmax, U, V, W);
- Umin = Min (U, Umin); Umax = Max (U, Umax);
- Vmin = Min (V, Vmin); Vmax = Max (V, Vmax);
+void V3d_View::ZFitAll (const Standard_Real theCoeff)
+{
+ V3d_BadValue_Raise_if (theCoeff <= 0.0, "V3d_View::ZFitAll, bad margin coefficient");
- MyView->Projects (Xmax, Ymin, Zmax, U, V, W);
- Umin = Min (U, Umin); Umax = Max (U, Umax);
- Vmin = Min (V, Vmin); Vmax = Max (V, Vmax);
+ Standard_Real aMinMax[6];
- MyView->Projects (Xmax, Ymin, Zmin, U, V, W);
- Umin = Min (U, Umin); Umax = Max (U, Umax);
- Vmin = Min (V, Vmin); Vmax = Max (V, Vmax);
+ MyView->MinMaxValues (aMinMax[0], aMinMax[1], aMinMax[2], aMinMax[3], aMinMax[4], aMinMax[5]);
- MyView->Projects (Xmax, Ymax, Zmin, U, V, W);
- Umin = Min (U, Umin); Umax = Max (U, Umax);
- Vmin = Min (V, Vmin); Vmax = Max (V, Vmax);
+ gp_Pnt aBMin = gp_Pnt (aMinMax[0], aMinMax[1], aMinMax[2]);
+ gp_Pnt aBMax = gp_Pnt (aMinMax[3], aMinMax[4], aMinMax[5]);
- MyView->Projects (Xmin, Ymax, Zmax, U, V, W);
- Umin = Min (U, Umin); Umax = Max (U, Umax);
- Vmin = Min (V, Vmin); Vmax = Max (V, Vmax);
+ // check bounding box for validness
+ Standard_Real aLim = (ShortRealLast() - 1.0);
+ if (Abs (aBMin.X()) > aLim || Abs (aBMin.Y()) > aLim || Abs (aBMin.Z()) > aLim ||
+ Abs (aBMax.X()) > aLim || Abs (aBMax.Y()) > aLim || Abs (aBMax.Z()) > aLim)
+ {
+ SetZSize (0.0);
+ ImmediateUpdate();
+ return;
+ }
- MyView->Projects (Xmin, Ymax, Zmin, U, V, W);
- Umin = Min (U, Umin); Umax = Max (U, Umax);
- Vmin = Min (V, Vmin); Vmax = Max (V, Vmax);
+ // adapt bound points
+ gp_Pnt aPnts[8] =
+ { gp_Pnt (aBMin.X(), aBMin.Y(), aBMin.Z()),
+ gp_Pnt (aBMin.X(), aBMin.Y(), aBMax.Z()),
+ gp_Pnt (aBMin.X(), aBMax.Y(), aBMin.Z()),
+ gp_Pnt (aBMin.X(), aBMax.Y(), aBMax.Z()),
+ gp_Pnt (aBMax.X(), aBMin.Y(), aBMin.Z()),
+ gp_Pnt (aBMax.X(), aBMin.Y(), aBMax.Z()),
+ gp_Pnt (aBMax.X(), aBMax.Y(), aBMin.Z()),
+ gp_Pnt (aBMax.X(), aBMax.Y(), aBMax.Z()) };
- DxvNew = Abs (Umax - Umin);
- DyvNew = Abs (Vmax - Vmin);
+ // camera Eye plane
+ gp_Dir aDir = myCamera->Direction();
+ gp_Pnt anEye = myCamera->Eye();
+ gp_Pln aCamPln (anEye, aDir);
- if (DyvNew < 10.0 * Precision::Confusion())
- {
- if (DxvNew < 10.0 * Precision::Confusion())
- {
- // whole scene projected to point
- DxvNew = Max (Abs (Zmax - Zmin), (Max (Abs (Xmax - Xmin), Abs (Ymax - Ymin))));
- if (DxvNew < 10.0 * Precision::Confusion())
- {
- // this is really just one (!) point and zooming has no any effect
- // just center the view
- DyvNew = DyvOld;
- DxvNew = DxvOld;
- }
- else
- {
- // we look along some line
- // fit view like that to see whole scene on rotation
- DxvNew += Coef * DxvNew;
- DyvNew = DxvNew / aWinRatio;
- }
- }
- else
- {
- // whole scene projected to horizontal line
- DxvNew += Coef * DxvNew;
- DyvNew = DxvNew / aWinRatio;
- }
- }
- else
- {
- // general case (or DxvNew == 0.0 - vertical line)
- // safe original ratio
- Standard_Real aFitRatio = DxvNew / DyvNew;
- if (aFitRatio >= aWinRatio)
- {
- DxvNew += Coef * DxvNew;
- DyvNew = DxvNew / aWinRatio;
- }
- else
- {
- DyvNew += Coef * DyvNew;
- DxvNew = DyvNew * aWinRatio;
- }
- }
+ Standard_Real aMinDist = RealLast() - 1;
+ Standard_Real aMaxDist = RealFirst() + 1;
+
+ gp_Pnt anAxialScale = myCamera->AxialScale();
- // new scene center
- Xrp = 0.5 * (Umin + Umax);
- Yrp = 0.5 * (Vmin + Vmax);
+ // get minimum and maximum distances to the eye plane
+ for (Standard_Integer aPntIt = 0; aPntIt < 8; ++aPntIt)
+ {
+ gp_Pnt aPnt = aPnts[aPntIt];
+
+ aPnt = gp_Pnt (aPnt.X() * anAxialScale.X(),
+ aPnt.Y() * anAxialScale.Y(),
+ aPnt.Z() * anAxialScale.Z());
- // new window limits
- Umin = Xrp - 0.5 * DxvNew;
- Umax = Xrp + 0.5 * DxvNew;
- Vmin = Yrp - 0.5 * DyvNew;
- Vmax = Yrp + 0.5 * DyvNew;
- MyViewMapping.SetWindowLimit (Umin, Vmin, Umax, Vmax);
+ Standard_Real aDistance = aCamPln.Distance (aPnt);
- if (MyType != V3d_PERSPECTIVE)
+ // check if the camera is intruded into the scene
+ if (aDir.IsOpposite (gp_Vec (anEye, aPnt), M_PI * 0.5))
{
- // center the view
- MyProjReferencePoint.SetCoord (Xrp, Yrp, Zrp);
- MyViewMapping.SetProjectionReferencePoint (MyProjReferencePoint);
+ aDistance *= -1;
}
- MyView->SetViewMapping (MyViewMapping);
- }
- if (FitZ)
- {
- ZFitAll (Zmargin);
-#ifdef IMP020300
- }
- else
- {
- ImmediateUpdate();
-#endif
- }
-#ifdef IMP020300
- if (!myImmediateUpdate && update)
- {
- Update();
+ aMinDist = Min (aDistance, aMinDist);
+ aMaxDist = Max (aDistance, aMaxDist);
}
-#endif
-}
-void V3d_View::ZFitAll(const Standard_Real Coef)
-{
- Standard_Real Xmin,Ymin,Zmin,Xmax,Ymax,Zmax,U,V,W ;
- Standard_Real Umin,Vmin,Wmin,Umax,Vmax,Wmax ;
- // CAL 6/11/98
- Standard_Integer Nstruct = MyView->NumberOfDisplayedStructures() ;
+ // compute depth of bounding box center
+ Standard_Real aMidDepth = (aMinDist + aMaxDist) * 0.5;
+ Standard_Real aHalfDepth = (aMaxDist - aMinDist) * 0.5;
- if( MyType == V3d_PERSPECTIVE ) {
- ImmediateUpdate();
- return ;
- }
+ // compute enlarged or shrank near and far z ranges.
+ Standard_Real aZNear = aMidDepth - aHalfDepth * theCoeff;
+ Standard_Real aZFar = aMidDepth + aHalfDepth * theCoeff;
- if( (Nstruct <= 0) || (Coef < 0.) ) {
- ImmediateUpdate();
- return ;
- }
+ myCamera->BeginUpdate();
- MyView->MinMaxValues(Xmin,Ymin,Zmin,Xmax,Ymax,Zmax) ;
+ if (myCamera->IsOrthographic())
+ {
+ myCamera->SetZFar (myCamera->Distance() * 3.0);
+ myCamera->SetZNear (0.0);
- Standard_Real LIM = ShortRealLast() -1.;
- if (Abs(Xmin) > LIM || Abs(Ymin) > LIM || Abs(Zmin) > LIM
- || Abs(Xmax) > LIM || Abs(Ymax) > LIM || Abs(Zmax) > LIM ) {
- ImmediateUpdate();
- return ;
+ if (aZNear < 0.0)
+ {
+ myCamera->SetDistance (myCamera->Distance() - (aZNear + myCamera->ZNear()) + 10.0);
}
+ }
+ else
+ {
+ myCamera->SetZFar (aZFar);
+ myCamera->SetZNear (aZNear);
+ }
- // CAL 6/11/98
- // Case when view contains only a point
- if (Xmin == Xmax && Ymin == Ymax && Zmin == Zmax) {
- ImmediateUpdate();
- return ;
- }
- MyView->Projects(Xmin,Ymin,Zmin,Umin,Vmin,Wmin) ;
- MyView->Projects(Xmax,Ymax,Zmax,Umax,Vmax,Wmax) ;
- MyView->Projects(Xmin,Ymin,Zmax,U,V,W) ;
- Wmin = Min(W,Wmin) ; Wmax = Max(W,Wmax) ;
- MyView->Projects(Xmax,Ymin,Zmax,U,V,W) ;
- Wmin = Min(W,Wmin) ; Wmax = Max(W,Wmax) ;
- MyView->Projects(Xmax,Ymin,Zmin,U,V,W) ;
- Wmin = Min(W,Wmin) ; Wmax = Max(W,Wmax) ;
- MyView->Projects(Xmax,Ymax,Zmin,U,V,W) ;
- Wmin = Min(W,Wmin) ; Wmax = Max(W,Wmax) ;
- MyView->Projects(Xmin,Ymax,Zmax,U,V,W) ;
- Wmin = Min(W,Wmin) ; Wmax = Max(W,Wmax) ;
- MyView->Projects(Xmin,Ymax,Zmin,U,V,W) ;
- Wmin = Min(W,Wmin) ; Wmax = Max(W,Wmax) ;
- Wmax = Max(Abs(Wmin),Abs(Wmax)) ;
- if( Wmax > 0. ) {
- SetZSize(2.*Wmax + Coef * Wmax) ;
- }
- ImmediateUpdate();
+ myCamera->EndUpdate();
+
+ ImmediateUpdate();
}
+
+// Better to use ZFitAll instead.
void V3d_View::DepthFitAll(const Quantity_Coefficient Aspect,
const Quantity_Coefficient Margin)
{
Standard_Real Xmin,Ymin,Zmin,Xmax,Ymax,Zmax,U,V,W,U1,V1,W1 ;
Standard_Real Umin,Vmin,Wmin,Umax,Vmax,Wmax ;
- Standard_Real Xrp,Yrp,Zrp,Dx,Dy,Dz,Size;
+ Standard_Real Dx,Dy,Dz,Size;
Standard_Integer Nstruct = MyView->NumberOfDisplayedStructures() ;
- if( (Nstruct <= 0) || (Aspect < 0.) || (Margin < 0.) || (Margin > 1.)) {
+ if((Nstruct <= 0) || (Aspect < 0.) || (Margin < 0.) || (Margin > 1.)) {
ImmediateUpdate();
return ;
}
- MyProjReferencePoint = MyViewMapping.ProjectionReferencePoint() ;
- MyProjReferencePoint.Coord(Xrp,Yrp,Zrp) ;
-
MyView->MinMaxValues(Xmin,Ymin,Zmin,Xmax,Ymax,Zmax) ;
Standard_Real LIM = ShortRealLast() -1.;
void V3d_View::FitAll(const Standard_Real Xmin, const Standard_Real Ymin, const Standard_Real Xmax, const Standard_Real Ymax)
{
FitAll(MyWindow,Xmin,Ymin,Xmax,Ymax);
-#ifndef IMP020300
+
ImmediateUpdate();
-#endif
}
void V3d_View::WindowFitAll(const Standard_Integer Xmin, const Standard_Integer Ymin, const Standard_Integer Xmax, const Standard_Integer Ymax)
void V3d_View::WindowFit(const Standard_Integer Xmin, const Standard_Integer Ymin, const Standard_Integer Xmax, const Standard_Integer Ymax)
{
- Standard_Real x1,y1,x2,y2;
- Convert(Xmin,Ymin,x1,y1);
- Convert(Xmax,Ymax,x2,y2);
- FitAll(x1,y1,x2,y2);
-}
+ if (!myCamera->IsOrthographic())
+ {
+ // normalize view coordiantes
+ Standard_Integer aWinWidth, aWinHeight;
+ MyWindow->Size (aWinWidth, aWinHeight);
-void V3d_View::SetViewMapping(const Visual3d_ViewMapping& VM)
-{
- MyViewMapping = VM;
- // ajust view type according to mapping projection
- // NOTE: Might be dangerous, potentially conflicts with the C++ view class
- // (orthographic or perspective)! Use with care!
- if ( VM.Projection() == Visual3d_TOP_PERSPECTIVE )
- MyType = V3d_PERSPECTIVE;
- else MyType = V3d_ORTHOGRAPHIC;
+ // z coordinate of camera center
+ Standard_Real aDepth = myCamera->Project (myCamera->Center()).Z();
+
+ // camera projection coordinate are in NDC which are normalized [-1, 1]
+ Standard_Real aUMin = (2.0 / aWinWidth) * Xmin - 1.0;
+ Standard_Real aUMax = (2.0 / aWinWidth) * Xmax - 1.0;
+ Standard_Real aVMin = (2.0 / aWinHeight) * Ymin - 1.0;
+ Standard_Real aVMax = (2.0 / aWinHeight) * Ymax - 1.0;
+
+ // compute camera panning
+ gp_Pnt aScreenCenter (0.0, 0.0, aDepth);
+ gp_Pnt aFitCenter ((aUMin + aUMax) * 0.5, (aVMin + aVMax) * 0.5, aDepth);
+ gp_Pnt aPanTo = myCamera->ConvertProj2View (aFitCenter);
+ gp_Pnt aPanFrom = myCamera->ConvertProj2View (aScreenCenter);
+ gp_Vec aPanVec (aPanFrom, aPanTo);
+
+ gp_Pnt a1 (aUMin, aVMin, 0.0);
+ gp_Pnt a2 (aUMax, aVMax, 0.0);
+ gp_Pnt ap1 = myCamera->ConvertProj2View (a1);
+ gp_Pnt ap2 = myCamera->ConvertProj2View (a2);
+
+ // compute section size
+ gp_Pnt aFitTopRight (aUMax, aVMax, aDepth);
+ gp_Pnt aFitBotLeft (aUMin, aVMin, aDepth);
+ gp_Pnt aViewBotLeft = myCamera->ConvertProj2View (aFitBotLeft);
+ gp_Pnt aViewTopRight = myCamera->ConvertProj2View (aFitTopRight);
+
+ Standard_Real aUSize = aViewTopRight.X() - aViewBotLeft.X();
+ Standard_Real aVSize = aViewTopRight.Y() - aViewBotLeft.Y();
+
+ myCamera->BeginUpdate();
+ PanCamera (aPanVec.X(), -aPanVec.Y());
+ ZoomCamera (aUSize, aVSize);
+ AutoZFit();
+ myCamera->EndUpdate();
+ }
+ else
+ {
+ Standard_Real x1,y1,x2,y2;
+ Convert(Xmin,Ymin,x1,y1);
+ Convert(Xmax,Ymax,x2,y2);
- MyView->SetViewMapping(MyViewMapping) ;
- ImmediateUpdate();
+ FitAll(x1,y1,x2,y2);
+ }
}
void V3d_View::SetViewMappingDefault()
{
- MyView->SetViewMapping(MyViewMapping) ;
MyView->SetViewMappingDefault();
+
ImmediateUpdate();
}
void V3d_View::ResetViewMapping()
{
MyView->ViewMappingReset();
- MyViewMapping = MyView->ViewMapping() ;
-#ifdef IMP020300
- ZFitAll (Zmargin);
+
Update();
-#else
- ImmediateUpdate();
-#endif
}
+void V3d_View::ConvertToGrid(const Standard_Integer Xp, const Standard_Integer Yp, Standard_Real& Xg, Standard_Real& Yg, Standard_Real& Zg) const
+{
+ Graphic3d_Vertex aVrp;
+ Standard_Real anX, anY, aZ;
+ Convert (Xp, Yp, anX, anY, aZ);
+ aVrp.SetCoord (anX, anY, aZ);
+
+ if( MyViewer->Grid()->IsActive() ) {
+ Graphic3d_Vertex aNewVrp = Compute (aVrp) ;
+ aNewVrp.Coord (Xg,Yg,Zg) ;
+ } else
+ aVrp.Coord (Xg,Yg,Zg) ;
+}
+
+void V3d_View::ConvertToGrid(const Standard_Real X, const Standard_Real Y, const Standard_Real Z, Standard_Real& Xg, Standard_Real& Yg, Standard_Real& Zg) const
+{
+ if( MyViewer->Grid()->IsActive() ) {
+ Graphic3d_Vertex aVrp (X,Y,Z) ;
+ Graphic3d_Vertex aNewVrp = Compute (aVrp) ;
+ aNewVrp.Coord(Xg,Yg,Zg) ;
+ } else {
+ Xg = X; Yg = Y; Zg = Z;
+ }
+}
+
+
Standard_Real V3d_View::Convert(const Standard_Integer Vp) const
{
- Standard_Real Umin,Umax,Vmin,Vmax,Dxv,Vv ;
- Standard_Integer Dxw,Dyw ;
+ Standard_Integer aDxw, aDyw ;
- V3d_UnMapped_Raise_if( !MyView->IsDefined(), "view has no window");
+ V3d_UnMapped_Raise_if (!MyView->IsDefined(), "view has no window");
- MyWindow->Size(Dxw,Dyw);
- MyViewMapping.WindowLimit(Umin,Vmin,Umax,Vmax) ;
- Dxv = Umax - Umin ;
- Vv = Dxv*(Standard_Real)Vp/(Standard_Real)Dxw ;
+ MyWindow->Size (aDxw, aDyw);
+ Standard_Real aValue;
+
+ gp_Pnt aViewDims = myCamera->ViewDimensions();
+ aValue = aViewDims.X() * (Standard_Real)Vp / (Standard_Real)aDxw;
- return Vv ;
+ return aValue;
}
void V3d_View::Convert(const Standard_Integer Xp, const Standard_Integer Yp, Standard_Real& Xv, Standard_Real& Yv) const
{
- Standard_Real Umin,Umax,Vmin,Vmax,Dxv,Dyv ;
- Standard_Integer Dxw,Dyw ;
+ Standard_Integer aDxw, aDyw;
- V3d_UnMapped_Raise_if( !MyView->IsDefined(), "view has no window");
+ V3d_UnMapped_Raise_if (!MyView->IsDefined(), "view has no window");
+
+ MyWindow->Size (aDxw, aDyw);
+
+ gp_Pnt aPoint (Xp * 2.0 / aDxw - 1.0, (aDyw - Yp) * 2.0 / aDyw - 1.0, 0.0);
+ aPoint = myCamera->ConvertProj2View (aPoint);
- MyWindow->Size(Dxw,Dyw);
- MyViewMapping.WindowLimit(Umin,Vmin,Umax,Vmax) ;
- Dxv = Umax - Umin ; Dyv = Vmax - Vmin ;
- Xv = Umin + Dxv*(Standard_Real)Xp/(Standard_Real)Dxw ;
- Yv = Vmin + Dyv*(Standard_Real)(Dyw-Yp)/(Standard_Real)Dyw ;
+ Xv = aPoint.X();
+ Yv = aPoint.Y();
}
Standard_Integer V3d_View::Convert(const Standard_Real Vv) const
{
- V3d_UnMapped_Raise_if( !MyView->IsDefined(), "view has no window");
+ V3d_UnMapped_Raise_if (!MyView->IsDefined(), "view has no window");
+
+ Standard_Integer aDxw, aDyw;
+ MyWindow->Size (aDxw, aDyw);
- Standard_Integer Dxw, Dyw;
- MyWindow->Size(Dxw,Dyw);
+ gp_Pnt aViewDims = myCamera->ViewDimensions();
+ Standard_Integer aValue = RealToInt (aDxw * Vv / (aViewDims.X()));
- Standard_Real Umin,Umax,Vmin,Vmax;
- MyViewMapping.WindowLimit(Umin,Vmin,Umax,Vmax) ;
- Standard_Real Dxv = Umax - Umin;
- return RealToInt ( Dxw * Vv / Dxv );
+ return aValue;
}
void V3d_View::Convert(const Standard_Real Xv, const Standard_Real Yv, Standard_Integer& Xp, Standard_Integer& Yp) const
{
- V3d_UnMapped_Raise_if( !MyView->IsDefined(), "view has no window");
+ V3d_UnMapped_Raise_if (!MyView->IsDefined(), "view has no window");
- Standard_Integer Dxw, Dyw;
- MyWindow->Size(Dxw,Dyw);
+ Standard_Integer aDxw, aDyw;
+ MyWindow->Size (aDxw, aDyw);
- Standard_Real Umin,Umax,Vmin,Vmax;
- MyViewMapping.WindowLimit(Umin,Vmin,Umax,Vmax) ;
- Standard_Real Dxv = Umax - Umin;
- Standard_Real Dyv = Vmax - Vmin;
+ gp_Pnt aPoint (Xv, Yv, 0.0);
+ aPoint = myCamera->ConvertView2Proj (aPoint);
+ aPoint = gp_Pnt ((aPoint.X() + 1.0) * aDxw / 2.0, aDyw - (aPoint.Y() + 1.0) * aDyw / 2.0, 0.0);
- // CAL 15/12/93 warning: double assigned to int
- Xp = RealToInt (Dxw*(Xv - Umin)/Dxv);
- // CAL 15/12/93 warning: double assigned to int
- Yp = Dyw - RealToInt (Dyw*(Yv - Vmin)/Dyv);
+ Xp = RealToInt (aPoint.X());
+ Yp = RealToInt (aPoint.Y());
}
void V3d_View::Convert(const Standard_Integer Xp, const Standard_Integer Yp, Standard_Real& X, Standard_Real& Y, Standard_Real& Z) const
{
- Graphic3d_Vertex Vrp ;
- Vrp = (MyViewer->Viewer())->ConvertCoord(MyWindow,Xp,Yp) ;
- Vrp.Coord(X,Y,Z) ;
-#ifndef IMP240100
+ V3d_UnMapped_Raise_if (!MyView->IsDefined(), "view has no window");
+ Standard_Integer aHeight, aWidth;
+ MyWindow->Size (aWidth, aHeight);
+
+ Standard_Real anX = 2.0 * Xp / aWidth - 1.0;
+ Standard_Real anY = 2.0 * (aHeight - 1 - Yp) / aHeight - 1.0;
+ Standard_Real aZ = 2.0 * 0.0 - 1.0;
+
+ gp_Pnt aResult = myCamera->UnProject (gp_Pnt (anX, anY, aZ));
+
+ X = aResult.X();
+ Y = aResult.Y();
+ Z = aResult.Z();
+
+ Graphic3d_Vertex aVrp;
+ aVrp.SetCoord (X, Y, Z);
+
if( MyViewer->Grid()->IsActive() ) {
- Graphic3d_Vertex NewVrp = Compute(Vrp) ;
- NewVrp.Coord(X,Y,Z) ;
+ Graphic3d_Vertex aNewVrp = Compute (aVrp) ;
+ aNewVrp.Coord (X, Y, Z) ;
}
-#endif
}
void V3d_View::ConvertWithProj(const Standard_Integer Xp, const Standard_Integer Yp, Standard_Real& X, Standard_Real& Y, Standard_Real& Z, Standard_Real& Dx, Standard_Real& Dy, Standard_Real& Dz) const
{
- Graphic3d_Vertex Vrp ;
- Graphic3d_Vector Proj ;
- (MyViewer->Viewer())->ConvertCoordWithProj(MyWindow,Xp,Yp, Vrp, Proj) ;
- Vrp.Coord(X,Y,Z) ;
- Proj.Coord(Dx,Dy,Dz) ;
-#ifndef IMP240100
- if( MyViewer->Grid()->IsActive() ) {
- Graphic3d_Vertex NewVrp = Compute(Vrp) ;
- NewVrp.Coord(X,Y,Z) ;
- }
-#endif
-}
+ V3d_UnMapped_Raise_if( !MyView->IsDefined(), "view has no window");
+ Standard_Integer aHeight, aWidth;
+ MyWindow->Size (aWidth, aHeight);
-#ifdef IMP240100
-void V3d_View::ConvertToGrid(const Standard_Integer Xp, const Standard_Integer Yp, Standard_Real& Xg, Standard_Real& Yg, Standard_Real& Zg) const
-{
- Graphic3d_Vertex Vrp ;
- Vrp = (MyViewer->Viewer())->ConvertCoord(MyWindow,Xp,Yp) ;
- if( MyViewer->Grid()->IsActive() ) {
- Graphic3d_Vertex NewVrp = Compute(Vrp) ;
- NewVrp.Coord(Xg,Yg,Zg) ;
- } else
- Vrp.Coord(Xg,Yg,Zg) ;
-}
+ Standard_Real anX = 2.0 * Xp / aWidth - 1.0;
+ Standard_Real anY = 2.0 * (aHeight - 1 - Yp) / aHeight - 1.0;
+ Standard_Real aZ = 2.0 * 0.0 - 1.0;
-void V3d_View::ConvertToGrid(const Standard_Real X, const Standard_Real Y, const Standard_Real Z, Standard_Real& Xg, Standard_Real& Yg, Standard_Real& Zg) const
-{
- if( MyViewer->Grid()->IsActive() ) {
- Graphic3d_Vertex Vrp(X,Y,Z) ;
- Graphic3d_Vertex NewVrp = Compute(Vrp) ;
- NewVrp.Coord(Xg,Yg,Zg) ;
- } else {
- Xg = X; Yg = Y; Zg = Z;
- }
-}
-#endif
+ gp_Pnt aResult = myCamera->UnProject (gp_Pnt (anX, anY, aZ));
+
+ X = aResult.X();
+ Y = aResult.Y();
+ Z = aResult.Z();
+
+ Graphic3d_Vertex aVrp;
+ aVrp.SetCoord (X, Y, Z);
+
+ aResult = myCamera->UnProject (gp_Pnt (anX, anY, aZ - 10.0));
+
+ Dx = X - aResult.X();
+ Dy = Y - aResult.Y();
+ Dz = Z - aResult.Z();
-#ifndef IMP240100
-void V3d_View::PixToRef(const Standard_Integer Xp, const Standard_Integer Yp, Standard_Real& X, Standard_Real& Y, Standard_Real& Z) const
-{
- Graphic3d_Vertex Vrp ;
- Vrp = (MyViewer->Viewer())->ConvertCoord(MyWindow,Xp,Yp) ;
- Vrp.Coord(X,Y,Z) ;
if( MyViewer->Grid()->IsActive() ) {
- Graphic3d_Vertex NewVrp = Compute(Vrp) ;
- NewVrp.Coord(X,Y,Z) ;
+ Graphic3d_Vertex aNewVrp = Compute (aVrp) ;
+ aNewVrp.Coord (X, Y, Z) ;
}
}
-#endif
-#ifdef IMP240100
void V3d_View::Convert(const Standard_Real X, const Standard_Real Y, const Standard_Real Z, Standard_Integer& Xp, Standard_Integer& Yp) const
-#else
-void V3d_View::RefToPix(const Standard_Real X, const Standard_Real Y, const Standard_Real Z, Standard_Integer& Xp, Standard_Integer& Yp) const
-#endif
{
- Graphic3d_Vertex Vrp(X,Y,Z) ;
- (MyViewer->Viewer())->ConvertCoord(MyWindow,Vrp,Xp,Yp) ;
+ V3d_UnMapped_Raise_if( !MyView->IsDefined(), "view has no window");
+ Standard_Integer aHeight, aWidth;
+ MyWindow->Size (aWidth, aHeight);
+
+ gp_Pnt aPoint = myCamera->Project (gp_Pnt (X, Y, Z));
+
+ Xp = RealToInt ((aPoint.X() + 1) * 0.5 * aWidth);
+ Yp = RealToInt ((aPoint.Y() + 1) * 0.5 * aHeight);
}
void V3d_View::Project(const Standard_Real X, const Standard_Real Y, const Standard_Real Z, Standard_Real &Xp, Standard_Real &Yp) const
{
- if ( MyType != V3d_PERSPECTIVE )
- {
- // use old implementation
- Standard_Real Zp;
- MyView->Projects( X, Y, Z, Xp, Yp, Zp );
- }
- else
- {
- // NKV - Using raster projection
- Standard_Integer Xpx, Ypx;
- Convert(X, Y, Z, Xpx, Ypx);
- Convert(Xpx, Ypx, Xp, Yp);
- }
+ Standard_Real Zp;
+ MyView->Projects (X, Y, Z, Xp, Yp, Zp);
}
void V3d_View::BackgroundColor(const Quantity_TypeOfColor Type,Standard_Real& V1, Standard_Real& V2, Standard_Real& V3) const
Standard_Real V3d_View::Scale() const
{
- Standard_Real Umin,Vmin,Umax,Vmax,Dxv ;
- Visual3d_ViewMapping VMD = MyView->ViewMappingDefault() ;
- Standard_Real S = 0. ;
+ Handle(Graphic3d_Camera) aDefaultCamera = MyView->DefaultCamera();
+
+ Standard_Real aCameraScale;
+
+ // Strange behavior for the sake of compatibility.
+ if (!aDefaultCamera.IsNull())
+ {
+ Standard_Real aDefaultScale = aDefaultCamera->Scale();
+ aCameraScale = aDefaultScale / myCamera->Scale();
+ }
+ else
+ {
+ aCameraScale = myCamera->Scale();
+ }
- VMD.WindowLimit(Umin,Vmin,Umax,Vmax) ;
- Dxv = Umax - Umin ;
- MyViewMapping.WindowLimit(Umin,Vmin,Umax,Vmax) ;
- if( Umax > Umin && Vmax > Vmin ) S = Dxv/(Umax - Umin) ;
- return S ;
+ return aCameraScale;
}
void V3d_View::AxialScale(Standard_Real& Sx, Standard_Real& Sy, Standard_Real& Sz) const
{
- MyViewOrientation.AxialScale( Sx, Sy, Sz );
+ gp_Pnt anAxialScale = myCamera->AxialScale();
+ Sx = anAxialScale.X();
+ Sy = anAxialScale.Y();
+ Sz = anAxialScale.Z();
}
void V3d_View::Center(Standard_Real& Xc, Standard_Real& Yc) const
{
- Standard_Real Umin,Vmin,Umax,Vmax ;
+ gp_Pnt aCamProjShift = myCamera->ProjectionShift();
- MyViewMapping.WindowLimit(Umin,Vmin,Umax,Vmax) ;
- Xc = (Umin + Umax)/2. ;
- Yc = (Vmin + Vmax)/2. ;
+ Xc = -aCamProjShift.X();
+ Yc = -aCamProjShift.Y();
}
void V3d_View::Size(Standard_Real& Width, Standard_Real& Height) const
{
- Standard_Real Umin,Vmin,Umax,Vmax ;
+ gp_Pnt aViewDims = myCamera->ViewDimensions();
- MyViewMapping.WindowLimit(Umin,Vmin,Umax,Vmax) ;
- Width = Umax - Umin ;
- Height = Vmax - Vmin ;
+ Width = aViewDims.X();
+ Height = aViewDims.Y();
}
Standard_Real V3d_View::ZSize() const
{
- Standard_Real Wmin,Wmax,Depth ;
+ gp_Pnt aViewDims = myCamera->ViewDimensions();
- Wmax = MyViewMapping.FrontPlaneDistance() ;
- Wmin = MyViewMapping.BackPlaneDistance() ;
- Depth = 2. * Max(Wmin,Wmax) ;
- return (Depth) ;
+ return aViewDims.Z();
}
Standard_Integer V3d_View::MinMax(Standard_Real& Umin, Standard_Real& Vmin, Standard_Real& Umax, Standard_Real& Vmax) const
Standard_Integer V3d_View::Gravity(Standard_Real& X, Standard_Real& Y, Standard_Real& Z) const
{
- Standard_Real Xmin,Ymin,Zmin,Xmax,Ymax,Zmax,U,V,W ;
- Standard_Real Umin,Vmin,Umax,Vmax ;
+ Standard_Real Xmin,Ymin,Zmin,Xmax,Ymax,Zmax;
Standard_Integer Nstruct,Npoint ;
Graphic3d_MapOfStructure MySetOfStructures;
Graphic3d_MapIteratorOfMapOfStructure MyIterator(MySetOfStructures) ;
- MyViewMapping.WindowLimit(Umin,Vmin,Umax,Vmax) ;
Npoint = 0 ; X = Y = Z = 0. ;
- for( ; MyIterator.More(); MyIterator.Next()) {
- if (!(MyIterator.Key())->IsEmpty()) {
- (MyIterator.Key())->MinMaxValues(Xmin,Ymin,Zmin,
- Xmax,Ymax,Zmax) ;
-
- Standard_Real LIM = ShortRealLast() -1.;
- if (! (Abs(Xmin) > LIM || Abs(Ymin) > LIM || Abs(Zmin) > LIM
- || Abs(Xmax) > LIM || Abs(Ymax) > LIM || Abs(Zmax) > LIM )) {
-
- MyView->Projects(Xmin,Ymin,Zmin,U,V,W) ;
- if( U >= Umin && U <= Umax && V >= Vmin && V <= Vmax ) {
- Npoint++ ; X += Xmin ; Y += Ymin ; Z += Zmin ;
- }
- MyView->Projects(Xmax,Ymin,Zmin,U,V,W) ;
- if( U >= Umin && U <= Umax && V >= Vmin && V <= Vmax ) {
- Npoint++ ; X += Xmax ; Y += Ymin ; Z += Zmin ;
- }
- MyView->Projects(Xmin,Ymax,Zmin,U,V,W) ;
- if( U >= Umin && U <= Umax && V >= Vmin && V <= Vmax ) {
- Npoint++ ; X += Xmin ; Y += Ymax ; Z += Zmin ;
- }
- MyView->Projects(Xmax,Ymax,Zmin,U,V,W) ;
- if( U >= Umin && U <= Umax && V >= Vmin && V <= Vmax ) {
- Npoint++ ; X += Xmax ; Y += Ymax ; Z += Zmin ;
- }
- MyView->Projects(Xmin,Ymin,Zmax,U,V,W) ;
- if( U >= Umin && U <= Umax && V >= Vmin && V <= Vmax ) {
- Npoint++ ; X += Xmin ; Y += Ymin ; Z += Zmax ;
- }
- MyView->Projects(Xmax,Ymin,Zmax,U,V,W) ;
- if( U >= Umin && U <= Umax && V >= Vmin && V <= Vmax ) {
- Npoint++ ; X += Xmax ; Y += Ymin ; Z += Zmax ;
- }
- MyView->Projects(Xmin,Ymax,Zmax,U,V,W) ;
- if( U >= Umin && U <= Umax && V >= Vmin && V <= Vmax ) {
- Npoint++ ; X += Xmin ; Y += Ymax ; Z += Zmax ;
- }
- MyView->Projects(Xmax,Ymax,Zmax,U,V,W) ;
- if( U >= Umin && U <= Umax && V >= Vmin && V <= Vmax ) {
- Npoint++ ; X += Xmax ; Y += Ymax ; Z += Zmax ;
- }
+ for (; MyIterator.More(); MyIterator.Next())
+ {
+ const Handle(Graphic3d_Structure)& aStruct = MyIterator.Key();
+ if (!aStruct->IsEmpty())
+ {
+ aStruct->MinMaxValues (Xmin, Ymin, Zmin, Xmax, Ymax, Zmax);
+
+ // use camera projection to find gravity point
+ 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 aPntIt = 0; aPntIt < 8; ++aPntIt)
+ {
+ const gp_Pnt& aBndPnt = aPnts[aPntIt];
+
+ gp_Pnt aProjected = myCamera->Project (aBndPnt);
+ const Standard_Real& U = aProjected.X();
+ const Standard_Real& V = aProjected.Y();
+ if (Abs(U) <= 1.0 && Abs(V) <= 1.0)
+ {
+ Npoint++;
+ X += aBndPnt.X();
+ Y += aBndPnt.Y();
+ Z += aBndPnt.Z();
}
+ }
}
}
if( Npoint > 0 ) {
void V3d_View::Eye(Standard_Real& X, Standard_Real& Y, Standard_Real& Z) const
{
- Graphic3d_Vertex Prp ;
- Graphic3d_Vector Vpn ;
- Standard_Real Xrp,Yrp,Zrp,Xpn,Ypn,Zpn,Xat,Yat,Zat ;
-
- MyViewReferencePoint = MyViewOrientation.ViewReferencePoint() ;
- MyViewReferencePoint.Coord(Xat,Yat,Zat) ;
- Prp = MyViewMapping.ProjectionReferencePoint() ;
- Prp.Coord(Xrp,Yrp,Zrp) ;
- Vpn = MyViewOrientation.ViewReferencePlane() ;
- Vpn.Coord(Xpn,Ypn,Zpn) ;
- X = Zrp*Xpn + Xat; Y = Zrp*Ypn + Yat; Z = Zrp*Zpn + Zat;
+ gp_Pnt aCameraEye = myCamera->Eye();
+ X = aCameraEye.X();
+ Y = aCameraEye.Y();
+ Z = aCameraEye.Z();
}
void V3d_View::FocalReferencePoint(Standard_Real& X, Standard_Real& Y,Standard_Real& Z) const
{
- Graphic3d_Vertex PRP,VRPoint;
- Graphic3d_Vector VRPlane;
- Standard_Real FPD,Xprp,Yprp,Zprp;
- Standard_Real Xvrp,Yvrp,Zvrp,DXvrp,DYvrp,DZvrp;
-
- if ( MyType == V3d_PERSPECTIVE ) {
- PRP = MyViewMapping.ProjectionReferencePoint() ;
- FPD = MyViewMapping.FrontPlaneDistance();
- PRP.Coord(Xprp,Yprp,Zprp);
- VRPoint = MyViewOrientation.ViewReferencePoint();
- VRPoint.Coord(Xvrp,Yvrp,Zvrp);
- VRPlane = MyViewOrientation.ViewReferencePlane();
- VRPlane.Coord(DXvrp,DYvrp,DZvrp);
- X = (FPD + Zprp) * DXvrp + Xvrp;
- Y = (FPD + Zprp) * DYvrp + Yvrp;
- Z = (FPD + Zprp) * DZvrp + Zvrp;
- }
- else Eye(X,Y,Z);
+ Eye (X,Y,Z);
}
void V3d_View::ProjReferenceAxe(const Standard_Integer Xpix, const Standard_Integer Ypix, Standard_Real& XP, Standard_Real& YP, Standard_Real& ZP, Standard_Real& VX, Standard_Real& VY, Standard_Real& VZ) const
{
Standard_Real Xo,Yo,Zo;
- Convert(Xpix,Ypix,XP,YP,ZP);
- if ( MyType == V3d_PERSPECTIVE ) {
- FocalReferencePoint(Xo,Yo,Zo);
+ Convert (Xpix, Ypix, XP, YP, ZP);
+ if ( Type() == V3d_PERSPECTIVE )
+ {
+ FocalReferencePoint (Xo,Yo,Zo);
VX = Xo - XP;
VY = Yo - YP;
VZ = Zo - ZP;
}
- else {
- Proj(VX,VY,VZ);
+ else
+ {
+ Proj (VX,VY,VZ);
}
}
Standard_Real V3d_View::Depth() const
{
- Graphic3d_Vertex Prp ;
- Standard_Real Xrp,Yrp,Zrp ;
-
- Prp = MyViewMapping.ProjectionReferencePoint() ;
- Prp.Coord(Xrp,Yrp,Zrp) ;
- return Zrp ;
+ return myCamera->Distance();
}
void V3d_View::Proj(Standard_Real& Dx, Standard_Real& Dy, Standard_Real& Dz) const
{
- Graphic3d_Vector Vpn ;
-
- Vpn = MyViewOrientation.ViewReferencePlane() ;
- Vpn.Coord(Dx,Dy,Dz) ;
+ gp_Dir aCameraDir = myCamera->Direction().Reversed();
+ Dx = aCameraDir.X();
+ Dy = aCameraDir.Y();
+ Dz = aCameraDir.Z();
}
void V3d_View::At(Standard_Real& X, Standard_Real& Y, Standard_Real& Z) const
{
- Graphic3d_Vertex Vrp ;
-
- Vrp = MyViewOrientation.ViewReferencePoint() ;
- Vrp.Coord(X,Y,Z) ;
+ gp_Pnt aCameraCenter = myCamera->Center();
+ X = aCameraCenter.X();
+ Y = aCameraCenter.Y();
+ Z = aCameraCenter.Z();
}
void V3d_View::Up(Standard_Real& Vx, Standard_Real& Vy, Standard_Real& Vz) const
{
- Graphic3d_Vector Vup ;
-
- Vup = MyViewOrientation.ViewReferenceUp() ;
- Vup.Coord(Vx,Vy,Vz) ;
+ gp_Dir aCameraUp = myCamera->Up();
+ Vx = aCameraUp.X();
+ Vy = aCameraUp.Y();
+ Vz = aCameraUp.Z();
}
Standard_Real V3d_View::Twist() const
{
Standard_Real Xup,Yup,Zup,Xpn,Ypn,Zpn,X0,Y0,Z0 ;
Standard_Real pvx,pvy,pvz,pvn,sca,angle ;
- Graphic3d_Vector Vpn,Vup,Xaxis,Yaxis,Zaxis ;
+ Graphic3d_Vector Xaxis,Yaxis,Zaxis ;
Standard_Boolean TheStatus ;
- Vpn = MyViewOrientation.ViewReferencePlane() ;
- Vpn.Coord(Xpn,Ypn,Zpn) ;
- Vup.SetCoord(0.,0.,1.) ;
- TheStatus = ScreenAxis(Vpn,Vup,Xaxis,Yaxis,Zaxis) ;
+ gp_Dir aReferencePlane (myCamera->Direction().Reversed());
+ gp_Dir anUp;
+
+ Proj(Xpn,Ypn,Zpn);
+ anUp = gp_Dir (0.,0.,1.) ;
+ TheStatus = ScreenAxis (aReferencePlane, anUp,Xaxis,Yaxis,Zaxis) ;
if( !TheStatus ) {
- Vup.SetCoord(0.,1.,0.) ;
- TheStatus = ScreenAxis(Vpn,Vup,Xaxis,Yaxis,Zaxis) ;
+ anUp = gp_Dir (0.,1.,0.) ;
+ TheStatus = ScreenAxis (aReferencePlane, anUp,Xaxis,Yaxis,Zaxis) ;
}
if( !TheStatus ) {
- Vup.SetCoord(1.,0.,0.) ;
- TheStatus = ScreenAxis(Vpn,Vup,Xaxis,Yaxis,Zaxis) ;
+ anUp = gp_Dir (1.,0.,0.) ;
+ TheStatus = ScreenAxis (aReferencePlane, anUp,Xaxis,Yaxis,Zaxis) ;
}
Yaxis.Coord(X0,Y0,Z0) ;
- Vup = MyViewOrientation.ViewReferenceUp() ;
- Vup.Coord(Xup,Yup,Zup) ;
+
+ Up(Xup,Yup,Zup) ;
/* Compute Cross Vector From Up & Origin */
pvx = Y0*Zup - Z0*Yup ;
pvy = Z0*Xup - X0*Zup ;
V3d_TypeOfView V3d_View::Type() const
{
- return (MyType) ;
+ return myCamera->IsOrthographic() ? V3d_ORTHOGRAPHIC : V3d_PERSPECTIVE;
}
void V3d_View::SetFocale( const Standard_Real focale )
{
- Standard_TypeMismatch_Raise_if (MyType != V3d_PERSPECTIVE,
- "the view is not a perspective view");
- Standard_Real Xrp,Yrp,Zrp,ViewPlane,FrontPlane ;
- Graphic3d_Vertex Prp ;
- Prp = MyViewMapping.ProjectionReferencePoint() ;
- Prp.Coord(Xrp,Yrp,Zrp) ;
- if( MyProjModel == V3d_TPM_WALKTHROUGH ) {
- ViewPlane = Zrp - focale ;
- } else {
- FrontPlane = MyViewMapping.FrontPlaneDistance() ;
- ViewPlane = FrontPlane + Zrp - focale ;
+ if (myCamera->IsOrthographic())
+ {
+ return;
}
- MyViewMapping.SetViewPlaneDistance(ViewPlane) ;
- MyView->SetViewMapping(MyViewMapping) ;
+
+ Standard_Real aFOVyRad = ATan (focale / (myCamera->Distance() * 2.0));
+
+ myCamera->SetFOVy (aFOVyRad * (360 / M_PI));
ImmediateUpdate();
}
-Standard_Real V3d_View::Focale( ) const
+Standard_Real V3d_View::Focale() const
{
- Standard_Real Xrp,Yrp,Zrp,ViewPlane,FrontPlane ;
- Standard_Real focale = 0.0 ;
- Graphic3d_Vertex Prp ;
-
- if( MyType == V3d_PERSPECTIVE ) {
- Prp = MyViewMapping.ProjectionReferencePoint() ;
- Prp.Coord(Xrp,Yrp,Zrp) ;
- ViewPlane = MyViewMapping.ViewPlaneDistance() ;
- if( MyProjModel == V3d_TPM_WALKTHROUGH ) {
- focale = Zrp - ViewPlane ;
- } else {
- FrontPlane = MyViewMapping.FrontPlaneDistance() ;
- focale = FrontPlane + Zrp - ViewPlane ;
- }
+ if (myCamera->IsOrthographic())
+ {
+ return 0.0;
}
- return (focale) ;
+
+ return myCamera->Distance() * 2.0 * Tan(myCamera->FOVy() * M_PI / 360.0);
}
void V3d_View::SetViewingVolume(const Standard_Real Left, const Standard_Real Right,
const Standard_Real Bottom, const Standard_Real Top,
const Standard_Real ZNear, const Standard_Real ZFar)
{
- Standard_Real Umin,Vmin,Umax,Vmax,Xrp,Yrp,Zrp;
-
- V3d_BadValue_Raise_if ( ZNear <= 0. || ZFar <= 0. || ZNear >= ZFar, "V3d_View::SetVolume, bad distances");
-
- MyProjReferencePoint = MyViewMapping.ProjectionReferencePoint() ;
- MyProjReferencePoint.Coord(Xrp,Yrp,Zrp) ;
- Zrp = ZNear;
-
- Standard_Real size = (ZFar - ZNear) / 2.;
+ V3d_BadValue_Raise_if (ZNear >= ZFar, "V3d_View::SetVolume, bad distances");
- MyViewMapping.SetFrontPlaneDistance(size);
- MyViewMapping.SetBackPlaneDistance(-size);
- // keep view plane at front plane distance
- MyViewMapping.SetViewPlaneDistance(MyType == V3d_PERSPECTIVE ? 0. : size);
+ myCamera->BeginUpdate();
- // set window limits
- Umin = Left; Umax = Right;
- Vmin = Bottom; Vmax = Top;
- MyViewMapping.SetWindowLimit(Left, Bottom, Right, Top);
+ myCamera->SetZFar (ZFar);
+ myCamera->SetZNear (ZNear);
- // Update window center
- if ( MyType == V3d_PERSPECTIVE ) {
- Xrp = Yrp = 0.0;
- }
- else {
- Xrp = (Umin + Umax)/2. ; Yrp = (Vmin + Vmax)/2. ;
+ myCamera->SetScale (Top - Bottom);
+ myCamera->SetAspect ((Right - Left) / (Top - Bottom));
+ gp_Pnt aCameraProjShift (-(Left + Right) / 2.0, -(Bottom + Top) / 2.0, 0.0);
+ myCamera->SetProjectionShift (aCameraProjShift);
+ if (myCamera->IsOrthographic())
+ {
+ myCamera->SetDistance (Abs (ZNear));
}
- MyProjReferencePoint.SetCoord(Xrp,Yrp,Zrp) ;
- MyViewMapping.SetProjectionReferencePoint(MyProjReferencePoint);
+ AutoZFit();
+ myCamera->EndUpdate();
- MyView->SetViewMapping(MyViewMapping) ;
- // SetZSize(0.);
ImmediateUpdate();
}
return MyView ;
}
-Visual3d_ViewMapping V3d_View::ViewMapping() const
-{
- return MyViewMapping;
-}
-
-Visual3d_ViewOrientation V3d_View::ViewOrientation() const
-{
- return MyViewOrientation;
-}
-
-Standard_Boolean V3d_View::ScreenAxis( const Graphic3d_Vector &Vpn, const Graphic3d_Vector &Vup, Graphic3d_Vector &Xaxe, Graphic3d_Vector &Yaxe, Graphic3d_Vector &Zaxe)
-{
- Standard_Real Xpn,Ypn,Zpn,Xup,Yup,Zup ;
- Standard_Real dx1,dy1,dz1,dx2,dy2,dz2,xx,yy,zz ;
-
- Vpn.Coord(Xpn,Ypn,Zpn) ;
- Vup.Coord(Xup,Yup,Zup) ;
- xx = Yup*Zpn - Zup*Ypn ;
- yy = Zup*Xpn - Xup*Zpn ;
- zz = Xup*Ypn - Yup*Xpn ;
- Xaxe.SetCoord(xx,yy,zz) ;
- if( Xaxe.LengthZero() ) return Standard_False;
- Xaxe.Normalize() ; Xaxe.Coord(dx1,dy1,dz1) ;
- xx = Ypn*dz1 - Zpn*dy1 ;
- yy = Zpn*dx1 - Xpn*dz1 ;
- zz = Xpn*dy1 - Ypn*dx1 ;
- Yaxe.SetCoord(xx,yy,zz) ;
- if( Yaxe.LengthZero() ) return Standard_False;
- Yaxe.Normalize() ; Yaxe.Coord(dx2,dy2,dz2) ;
- xx = dy1*dz2 - dz1*dy2 ;
- yy = dz1*dx2 - dx1*dz2 ;
- zz = dx1*dy2 - dy1*dx2 ;
- Zaxe.SetCoord(xx,yy,zz) ;
- if( Zaxe.LengthZero() ) return Standard_False;
- Zaxe.Normalize() ;
- return Standard_True ;
-}
-
-void V3d_View::InitMatrix( TColStd_Array2OfReal& Matrix )
-{
- Standard_Integer LR = Matrix.LowerRow() ;
- Standard_Integer UR = Matrix.UpperRow() ;
- Standard_Integer LC = Matrix.LowerCol() ;
- Standard_Integer UC = Matrix.UpperCol() ;
- Standard_Integer I,J ;
-
- for( I=LR ; I<=UR ; I++ ) {
- for( J=LC ; J<=UC ; J++ ) Matrix(I,J) = 0. ;
- }
- for( I=LR,J=LC ; I<=UR ; I++,J++ ) Matrix(I,J) = 1. ;
-}
-
-Standard_Boolean V3d_View::Multiply (const TColStd_Array2OfReal& Left, const TColStd_Array2OfReal& Right, TColStd_Array2OfReal& Matrix)
-{
- Standard_Integer llr = Left.LowerRow ();
- Standard_Integer llc = Left.LowerCol ();
- Standard_Integer luc = Left.UpperCol ();
-
- Standard_Integer rlr = Right.LowerRow ();
- Standard_Integer rur = Right.UpperRow ();
- Standard_Integer rlc = Right.LowerCol ();
-
- Standard_Integer mlr = Matrix.LowerRow ();
- Standard_Integer mur = Matrix.UpperRow ();
- Standard_Integer mlc = Matrix.LowerCol ();
- Standard_Integer muc = Matrix.UpperCol ();
-
- TColStd_Array2OfReal Result (mlr, mur, mlc, muc);
-
- InitMatrix (Result);
-
- // Left et Right incompatibles
- if (luc - llc + 1 != rur - rlr + 1)
- return Standard_False;
-
- Standard_Integer i, j, k;
-
- Standard_Real Som;
- Standard_Integer I1 = llr;
-
- for (i=mlr; i<=mur; i++) {
- Standard_Integer J2 = rlc;
- for (j=mlc; j<=muc; j++) {
- Som = 0.0;
- Standard_Integer J1 = llc;
- Standard_Integer I2 = rlr;
- for (k=llc; k<=luc; k++) {
- Som = Som + Left (I1, J1) * Right (I2, J2);
- J1++;
- I2++;
- }
- Result (i, j) = Som;
- J2++;
- }
- I1++;
- }
-
- for (i=mlr; i<=mur; i++)
- for (j=mlc; j<=muc; j++)
- Matrix (i, j) = Result (i, j);
-
+Standard_Boolean V3d_View::ScreenAxis( const gp_Dir &Vpn, const gp_Dir &Vup, Graphic3d_Vector &Xaxe, Graphic3d_Vector &Yaxe, Graphic3d_Vector &Zaxe)
+{
+ Standard_Real Xpn, Ypn, Zpn, Xup, Yup, Zup;
+ Standard_Real dx1, dy1, dz1, xx, yy, zz;
+
+ Xpn = Vpn.X(); Ypn = Vpn.Y(); Zpn = Vpn.Z();
+ Xup = Vup.X(); Yup = Vup.Y(); Zup = Vup.Z();
+ xx = Yup*Zpn - Zup*Ypn;
+ yy = Zup*Xpn - Xup*Zpn;
+ zz = Xup*Ypn - Yup*Xpn;
+ Xaxe.SetCoord (xx, yy, zz);
+ if (Xaxe.LengthZero()) return Standard_False;
+ Xaxe.Normalize();
+ Xaxe.Coord(dx1, dy1, dz1);
+ xx = Ypn*dz1 - Zpn*dy1;
+ yy = Zpn*dx1 - Xpn*dz1;
+ zz = Xpn*dy1 - Ypn*dx1;
+ Yaxe.SetCoord (xx, yy, zz) ;
+ if (Yaxe.LengthZero()) return Standard_False;
+ Yaxe.Normalize();
+
+ Zaxe.SetCoord (Xpn, Ypn, Zpn);
+ Zaxe.Normalize();
return Standard_True;
}
-/*----------------------------------------------------------------------*/
-
-void V3d_View::RotAxis( const Graphic3d_Vertex &Vrp, const Graphic3d_Vector &Axe, const Standard_Real angle, TColStd_Array2OfReal& Matrix )
-{
- Standard_Real Xrp,Yrp,Zrp,Xaxe,Yaxe,Zaxe ;
- Standard_Real sina,cosa,cos1m,terms1,terms2,terms3 ;
- Standard_Real termc12,termc13,termc23,vcal ;
- TColStd_Array2OfReal Tmatrix(0,3,0,3) ;
- TColStd_Array2OfReal Rmatrix(0,3,0,3) ;
-
- InitMatrix(Matrix) ;
- InitMatrix(Tmatrix) ;
-
- Vrp.Coord(Xrp,Yrp,Zrp) ;
- Axe.Coord(Xaxe,Yaxe,Zaxe) ;
- /* translation of x,y,z */
- Tmatrix(0,3) = Xrp ; Tmatrix(1,3) = Yrp ; Tmatrix(2,3) = Zrp ;
- /* rotation around an axis */
- cosa = cos(angle); sina = sin(angle); cos1m = 1. - cosa ;
- termc12 = Xaxe * Yaxe * cos1m ;
- termc13 = Xaxe * Zaxe * cos1m ;
- termc23 = Yaxe * Zaxe * cos1m ;
- terms1 = Xaxe * sina ;
- terms2 = Yaxe * sina ;
- terms3 = Zaxe * sina ;
-
- vcal = Xaxe * Xaxe ;
- Rmatrix(0,0) = vcal + ( 1. - vcal ) * cosa ;
- Rmatrix(1,0) = termc12 + terms3 ;
- Rmatrix(2,0) = termc13 - terms2 ;
- Rmatrix(3,0) = 0. ;
- Rmatrix(0,1) = termc12 - terms3 ;
- vcal = Yaxe * Yaxe ;
- Rmatrix(1,1) = vcal + ( 1. - vcal ) * cosa ;
- Rmatrix(2,1) = termc23 + terms1 ;
- Rmatrix(3,1) = 0. ;
- Rmatrix(0,2) = termc13 + terms2 ;
- Rmatrix(1,2) = termc23 - terms1 ;
- vcal = Zaxe * Zaxe ;
- Rmatrix(2,2) = vcal + ( 1. - vcal ) * cosa ;
- Rmatrix(3,2) = 0. ;
- Rmatrix(0,3) = 0. ;
- Rmatrix(1,3) = 0. ;
- Rmatrix(2,3) = 0. ;
- Rmatrix(3,3) = 1. ;
- /* produced by two matrices */
- Multiply(Tmatrix, Rmatrix, Matrix);
- /* translation invert */
- Tmatrix(0,3) = -Xrp;
- Tmatrix(1,3) = -Yrp;
- Tmatrix(2,3) = -Zrp;
- /* product final */
- Multiply(Matrix, Tmatrix, Matrix);
-}
-
-/*----------------------------------------------------------------------*/
-
Graphic3d_Vertex V3d_View::TrsPoint( const Graphic3d_Vertex &P, const TColStd_Array2OfReal &Matrix )
{
Graphic3d_Vertex PP ;
ur = Matrix.UpperRow ();
lc = Matrix.LowerCol ();
uc = Matrix.UpperCol ();
- if ( (ur - lr + 1 != 4) || (uc - lc + 1 != 4) ) {
+ if ((ur - lr + 1 != 4) || (uc - lc + 1 != 4) ) {
P.Coord(X,Y,Z) ;
PP.SetCoord(X,Y,Z) ;
return PP ;
return PP ;
}
-Graphic3d_Vector V3d_View::TrsPoint( const Graphic3d_Vector& V, const TColStd_Array2OfReal& Matrix )
-{
- Graphic3d_Vector VV ;
- Standard_Real X,Y,Z,XX,YY,ZZ ;
-
- // CAL. S3892
- Standard_Integer lr, ur, lc, uc;
- lr = Matrix.LowerRow ();
- ur = Matrix.UpperRow ();
- lc = Matrix.LowerCol ();
- uc = Matrix.UpperCol ();
- if ( (ur - lr + 1 != 4) || (uc - lc + 1 != 4) ) {
- V.Coord(X,Y,Z) ;
- VV.SetCoord(X,Y,Z) ;
- return VV ;
- }
- V.Coord(X,Y,Z) ;
- XX = X*Matrix(lr,lc)+Y*Matrix(lr,lc+1)+Z*Matrix(lr,lc+2) ;
- YY = X*Matrix(lr+1,lc)+Y*Matrix(lr+1,lc+1)+Z*Matrix(lr+1,lc+2) ;
- ZZ = X*Matrix(lr+2,lc)+Y*Matrix(lr+2,lc+1)+Z*Matrix(lr+2,lc+2) ;
- VV.SetCoord(XX,YY,ZZ) ; VV.Normalize() ;
- return VV ;
-}
-
void V3d_View::Pan(const Standard_Integer Dx, const Standard_Integer Dy,const Quantity_Factor aZoomFactor)
{
- Panning(Convert(Dx),Convert(Dy),aZoomFactor,Standard_True);
+ Panning (Convert(Dx), Convert(Dy), aZoomFactor, Standard_True);
}
void V3d_View::Zoom (const Standard_Integer X1,
dzoom = (d > 0) ? dzoom : 1.0 / dzoom;
V3d_BadValue_Raise_if( dzoom <= 0.,"V3d_View::ZoomAtPoint, bad coefficient");
- Standard_Real Umin,Vmin,Umax,Vmax;
- MyViewMapping.WindowLimit(Umin,Vmin,Umax,Vmax);
-
- MyXwindowCenter = (Umin + Umax) / 2.0;
- MyYwindowCenter = (Vmin + Vmax) / 2.0;
- MyWindowWidth = Abs(Umax - Umin);
- MyWindowHeight = Abs(Vmax - Vmin);
+ Standard_Real aViewWidth = myCamera->ViewDimensions().X();
+ Standard_Real aViewHeight = myCamera->ViewDimensions().Y();
// Ensure that zoom will not be too small or too big.
Standard_Real coef = dzoom;
- if (MyWindowWidth < coef * Precision::Confusion())
- coef = MyWindowWidth / Precision::Confusion();
- else if (MyWindowWidth > coef * 1e12)
- coef = MyWindowWidth / 1e12;
- if (MyWindowHeight < coef * Precision::Confusion())
- coef = MyWindowHeight / Precision::Confusion();
- else if (MyWindowHeight > coef * 1e12)
- coef = MyWindowHeight / 1e12;
-
- Standard_Real Dxv = MyWindowWidth / coef;
- Standard_Real Dyv = MyWindowHeight / coef;
-
- Umin = MyXwindowCenter - Dxv/2.0; Umax = MyXwindowCenter + Dxv/2.0;
- Vmin = MyYwindowCenter - Dyv/2.0; Vmax = MyYwindowCenter + Dyv/2.0;
-
- // Pan the point backwards.
- Dxv = (XS - X0) / coef;
- Dyv = (YS - Y0) / coef;
-
- MyXwindowCenter = (Umin + Umax) / 2.0;
- MyYwindowCenter = (Vmin + Vmax) / 2.0;
- MyWindowWidth = Abs(Umax - Umin);
- MyWindowHeight = Abs(Vmax - Vmin);
-
- Standard_Real Xrp,Yrp,Zrp;
- MyProjReferencePoint = MyViewMapping.ProjectionReferencePoint();
- MyProjReferencePoint.Coord(Xrp,Yrp,Zrp);
-
- Xrp = MyXwindowCenter - Dxv;
- Yrp = MyYwindowCenter - Dyv;
-
- Umin = Xrp - MyWindowWidth / 2.0; Umax = Xrp + MyWindowWidth / 2.0;
- Vmin = Yrp - MyWindowHeight / 2.0; Vmax = Yrp + MyWindowHeight / 2.0;
-
- // Set new reference plane coordintes of the window.
- MyViewMapping.SetWindowLimit(Umin,Vmin,Umax,Vmax);
- if (MyType != V3d_PERSPECTIVE)
+ if (aViewWidth < coef * Precision::Confusion())
+ {
+ coef = aViewWidth / Precision::Confusion();
+ }
+ else if (aViewWidth > coef * 1e12)
+ {
+ coef = aViewWidth / 1e12;
+ }
+ if (aViewHeight < coef * Precision::Confusion())
+ {
+ coef = aViewHeight / Precision::Confusion();
+ }
+ else if (aViewHeight > coef * 1e12)
{
- MyProjReferencePoint.SetCoord(Xrp,Yrp,Zrp);
- MyViewMapping.SetProjectionReferencePoint(MyProjReferencePoint);
+ coef = aViewHeight / 1e12;
}
- MyView->SetViewMapping(MyViewMapping);
+
+ V3d_Coordinate Dxv = (XS - X0) / coef;
+ V3d_Coordinate Dyv = (YS - Y0) / coef;
+
+ myCamera->SetScale (myCamera->Scale() / coef);
+ PanCamera (-Dxv, -Dyv);
+
+ AutoZFit();
// Update the view.
SetImmediateUpdate(update);
}
}
+
void V3d_View::FitAll(const Handle(Aspect_Window)& aWindow,
const Standard_Real Xmin,
const Standard_Real Ymin,
const Standard_Real Xmax,
const Standard_Real Ymax)
{
+ // normalize view coordinates
+ Standard_Integer aWinWidth, aWinHeight;
+ aWindow->Size (aWinWidth, aWinHeight);
- Standard_Real Umin,Umax,Vmin,Vmax,Xrp,Yrp,Zrp ;
- Standard_Real DxvOld,DyvOld,DxvNew,DyvNew,RapOld,RapNew ;
- Standard_Integer Xpixel,Ypixel;
- //Standard_Integer Xleft,Yup,Xright,Ylow ;
+ // compute camera panning
+ gp_Vec aPanVec ((Xmin + Xmax) * 0.5, (Ymin + Ymax) * 0.5, 0.0);
- V3d_BadValue_Raise_if( (Xmin == Xmax) || (Ymin == Ymax) ,
- "V3d_View::FitAll, Window Size is NULL");
+ // compute section size
+ gp_Pnt aViewBotLeft (Xmin, Ymin, 0.0);
+ gp_Pnt aViewTopRight (Xmax, Ymax, 0.0);
- MyProjReferencePoint = MyViewMapping.ProjectionReferencePoint() ;
- MyProjReferencePoint.Coord(Xrp,Yrp,Zrp) ;
- aWindow->Size(Xpixel,Ypixel);
- DxvOld = Xpixel; DyvOld = Ypixel;
+ Standard_Real aUSize = Abs (Xmax - Xmin);
+ Standard_Real aVSize = Abs (Ymax - Ymin);
+
+ myCamera->BeginUpdate();
+ myCamera->SetProjectionShift (gp_Pnt (0.0, 0.0, 0.0));
+ PanCamera (aPanVec.X(), aPanVec.Y());
+ ZoomCamera (aUSize, aVSize);
+ myCamera->EndUpdate();
+
+ AutoZFit();
- if( (DxvOld == 0.) || (DyvOld == 0.) ) return ;
- RapOld = DxvOld/DyvOld ;
- DxvNew = Abs(Xmax - Xmin) ; DyvNew = Abs(Ymax - Ymin) ;
- RapNew = DxvNew/DyvNew ;
- if( RapNew >= RapOld ) {
- DyvNew = DxvNew/RapOld ;
- } else {
- DxvNew = DyvNew*RapOld ;
- }
- Xrp = (Xmin + Xmax)/2. ; Yrp = (Ymin + Ymax)/2. ;
- Umin = Xrp - DxvNew/2. ; Vmin = Yrp - DyvNew/2. ;
- Umax = Xrp + DxvNew/2. ; Vmax = Yrp + DyvNew/2. ;
- MyViewMapping.SetWindowLimit(Umin,Vmin,Umax,Vmax) ;
- if( MyType != V3d_PERSPECTIVE ) {
- MyProjReferencePoint.SetCoord(Xrp,Yrp,Zrp) ;
- MyViewMapping.SetProjectionReferencePoint(MyProjReferencePoint);
- }
- MyView->SetViewMapping(MyViewMapping) ;
-#ifdef IMP020300
Update();
-#else
- ImmediateUpdate();
-#endif
}
#ifdef IMP250900
const Standard_Integer Y,
const Quantity_Ratio zRotationThreshold)
{
-
sx = X; sy = Y;
Standard_Real x,y;
Size(x,y);
void V3d_View::Rotation(const Standard_Integer X,
const Standard_Integer Y)
{
-
#ifdef IMP210600
if( rx == 0. || ry == 0. ) {
StartRotation(X,Y);
if( !myComputedMode || !MyViewer->DefaultComputedMode() ) {
SetComputedMode(Standard_False);
}
-
-#ifdef IMP240100
- OSD_Environment env_walkthrow("CSF_WALKTHROUGH");
- env_walkthrow.SetName( "CSF_WALKTHROUGH" );
- if ( env_walkthrow.Value () != "" ) MyProjModel = V3d_TPM_WALKTHROUGH;
- else MyProjModel = V3d_TPM_SCREEN;
-#endif
}
void V3d_View::SetPlotter(const Handle(Graphic3d_Plotter)& aPlotter)
Standard_Integer aWinWidth, aWinHeight;
MyWindow->Size (aWinWidth, aWinHeight);
Image_AlienPixMap anImage;
+
return ToPixMap (anImage, aWinWidth, aWinHeight, theBufferType) && anImage.Save (theFile);
}
const Standard_Integer theWidth,
const Standard_Integer theHeight,
const Graphic3d_BufferType& theBufferType,
- const Standard_Boolean theIsForceCentred)
+ const Standard_Boolean theIsForceCentred,
+ const V3d_StereoDumpOptions theStereoOptions)
{
Graphic3d_CView* cView = (Graphic3d_CView* )MyView->CView();
}
}
- //szv: save mapping
- Visual3d_ViewMapping prevMapping = MyView->ViewMapping();
+ Handle(Graphic3d_Camera) aStoreMapping = new Graphic3d_Camera();
+
+ aStoreMapping->Copy (myCamera);
Standard_Real Umin, Vmin, Umax, Vmax;
+ if (myCamera->IsStereo())
+ {
+ switch (theStereoOptions)
+ {
+ case V3d_SDO_MONO :
+ myCamera->SetProjectionType (Graphic3d_Camera::Projection_Perspective);
+ break;
+
+ case V3d_SDO_LEFT_EYE :
+ myCamera->SetProjectionType (Graphic3d_Camera::Projection_MonoLeftEye);
+ break;
+
+ case V3d_SDO_RIGHT_EYE :
+ myCamera->SetProjectionType (Graphic3d_Camera::Projection_MonoRightEye);
+ break;
+ }
+ }
+
if (theIsForceCentred)
{
- //szv: get mapping frame
Standard_Real PUmin, PVmin, PUmax, PVmax;
- prevMapping.WindowLimit (PUmin, PVmin, PUmax, PVmax);
+ myCamera->WindowLimit (PUmin, PVmin, PUmax, PVmax);
- //szv: calculate expansion
+ // calculate expansion
Umin = PUmin; Vmin = PVmin; Umax = PUmax; Vmax = PVmax;
Standard_Real oldWidth = (PUmax - PUmin), oldHeight = (PVmax - PVmin);
Standard_Real newWidth = (oldHeight * aFBOVPSizeX) / aFBOVPSizeY;
Umax = PUmax + delta;
}
- //szv: apply expanded mapping
- MyViewMapping.SetWindowLimit (Umin, Vmin, Umax, Vmax);
- MyView->SetViewMapping (MyViewMapping);
+ FitAll (Umin, Vmin, Umax, Vmax);
}
- //workround for rendering list of Over and Under Layers
+ //workaround for rendering list of Over and Under Layers
if (!MyLayerMgr.IsNull())
{
MyLayerMgr->Compute();
// render immediate structures into back buffer rather than front
Handle(Graphic3d_GraphicDriver) aDriver = Handle(Graphic3d_GraphicDriver)::DownCast (MyView->GraphicDriver());
const Standard_Boolean aPrevImmediateMode = aDriver.IsNull() ? Standard_True : aDriver->SetImmediateModeDrawToFront (*cView, Standard_False);
-
Redraw();
if (!aDriver.IsNull())
aDriver->SetImmediateModeDrawToFront (*cView, aPrevImmediateMode);
}
- //szv: restore mapping
- MyViewMapping = prevMapping;
- MyView->SetViewMapping (prevMapping);
+ myCamera->Copy (aStoreMapping);
Standard_Boolean isSuccess = Standard_True;
myImmediateUpdate = theImmediateUpdate;
return aPreviousMode;
}
+
+// =======================================================================
+// function : SetCamera
+// purpose :
+// =======================================================================
+void V3d_View::SetCamera (const Handle(Graphic3d_Camera)& theCamera)
+{
+ myCamera = theCamera;
+
+ MyView->SetCamera (theCamera);
+}
+
+// =======================================================================
+// function : GetCamera
+// purpose :
+// =======================================================================
+Handle(Graphic3d_Camera) V3d_View::Camera() const
+{
+ return myCamera;
+}
+
+// =======================================================================
+// function : FitCamera
+// purpose :
+// =======================================================================
+void V3d_View::FitCamera (const Standard_Real theXmin,
+ const Standard_Real theYmin,
+ const Standard_Real theZmin,
+ const Standard_Real theXmax,
+ const Standard_Real theYmax,
+ const Standard_Real theZmax)
+{
+ if (myCamera.IsNull())
+ return;
+
+ // check bounding box for validness
+ Standard_Real aLim = (ShortRealLast() - 1.0);
+ if (Abs (theXmin) > aLim || Abs (theYmin) > aLim || Abs (theZmin) > aLim ||
+ Abs (theXmax) > aLim || Abs (theYmax) > aLim || Abs (theZmax) > aLim)
+ return;
+
+ // place camera center at the geometrical center
+ // of the passed bounding box
+ gp_Pnt aCenter ((theXmin + theXmax) * 0.5,
+ (theYmin + theYmax) * 0.5,
+ (theZmin + theZmax) * 0.5);
+
+ // adapt bound points
+ gp_Pnt aPnts[8] =
+ { gp_Pnt (theXmin, theYmin, theZmin),
+ gp_Pnt (theXmin, theYmin, theZmax),
+ gp_Pnt (theXmin, theYmax, theZmin),
+ gp_Pnt (theXmin, theYmax, theZmax),
+ gp_Pnt (theXmax, theYmin, theZmin),
+ gp_Pnt (theXmax, theYmin, theZmax),
+ gp_Pnt (theXmax, theYmax, theZmin),
+ gp_Pnt (theXmax, theYmax, theZmax) };
+
+ Standard_Real aViewMinX = (RealLast() - 1);
+ Standard_Real aViewMinY = (RealLast() - 1);
+ Standard_Real aViewMinZ = (RealLast() - 1);
+ Standard_Real aViewMaxX = (RealFirst() + 1);
+ Standard_Real aViewMaxY = (RealFirst() + 1);
+ Standard_Real aViewMaxZ = (RealFirst() + 1);
+
+ // find out minimum and maximum values of bounding box
+ // converted to view space. the limits point out a rectangular
+ // section parallel to the screen that camera should zoom in.
+ for (Standard_Integer aPntIt = 0; aPntIt < 8; ++aPntIt)
+ {
+ gp_Pnt aView = myCamera->ConvertWorld2View (aPnts[aPntIt]);
+ aViewMinX = Min (aViewMinX, aView.X());
+ aViewMinY = Min (aViewMinY, aView.Y());
+ aViewMaxX = Max (aViewMaxX, aView.X());
+ aViewMaxY = Max (aViewMaxY, aView.Y());
+ aViewMinZ = Min (aViewMinZ, aView.Z());
+ aViewMaxZ = Max (aViewMaxZ, aView.Z());
+ }
+
+ // evaluate section size for x1 zoom.
+ Standard_Real aSectU = (aViewMaxX - aViewMinX);
+ Standard_Real aSectV = (aViewMaxY - aViewMinY);
+
+ // zoom camera to front plane of bounding box. the camera
+ // is set up at the center of bbox, so the depth is half
+ // space of it in view coordinate space.
+ Standard_Real aSectDepth = (aViewMaxZ - aViewMinZ) * 0.5;
+
+ // re-compute Eye position
+ gp_Vec aBck = gp_Vec (myCamera->Center(), myCamera->Eye());
+ gp_Pnt aEye = aCenter.Translated (aBck);
+
+ // start camera updates
+ myCamera->BeginUpdate();
+
+ if (myCamera->IsOrthographic())
+ {
+ Standard_Real anX = (aViewMaxX + aViewMinX) * 0.5;
+ Standard_Real anY = (aViewMaxY + aViewMinY) * 0.5;
+ myCamera->SetProjectionShift (gp_Pnt (-anX, -anY, 0.0));
+ }
+ else
+ {
+ myCamera->SetProjectionShift (gp_Pnt (0.0, 0.0, 0.0));
+ myCamera->SetCenter (aCenter);
+ myCamera->SetEye (aEye);
+ }
+
+ // zoom camera to fit in the bounding box.
+ ZoomCamera (aSectU, aSectV, aSectDepth);
+
+ // re-evaluate camera
+ myCamera->EndUpdate();
+}
+
+// =======================================================================
+// function : ZoomCamera
+// purpose :
+// =======================================================================
+void V3d_View::ZoomCamera (const Standard_Real theUSize,
+ const Standard_Real theVSize,
+ const Standard_Real theZDepth)
+{
+ if (myCamera.IsNull())
+ return;
+
+ // compute maximum section size along both directions.
+ Standard_Real anAspect = myCamera->Aspect();
+ Standard_Real aSize = Max (theUSize / anAspect, theVSize);
+
+ myCamera->BeginUpdate();
+ myCamera->SetScale (aSize);
+
+ if (!myCamera->IsOrthographic())
+ {
+ myCamera->SetDistance (myCamera->Distance() + theZDepth);
+ }
+
+ AutoZFit();
+
+ myCamera->EndUpdate();
+}
+
+// =======================================================================
+// function : PanCamera
+// purpose : panning is fun
+// =======================================================================
+void V3d_View::PanCamera (const Standard_Real theU,
+ const Standard_Real theV)
+{
+ if (myCamera.IsNull())
+ return;
+
+ if (myCamera->IsOrthographic())
+ {
+ // Projection based panning for compatibility.
+ myCamera->SetProjectionShift (myCamera->ProjectionShift().
+ Translated (gp_Vec (-theU, -theV, 0.0)));
+ }
+ else
+ {
+ gp_Vec anUp = myCamera->Up();
+ gp_Vec aSide = myCamera->Direction().Crossed (anUp);
+
+ gp_Vec aPanU = aSide.Scaled (theU);
+ gp_Vec aPanV = anUp.Scaled (theV);
+ gp_Pnt aPannedEye (myCamera->Eye());
+ gp_Pnt aPannedCenter (myCamera->Center());
+
+ aPannedEye.Translate (aPanU);
+ aPannedEye.Translate (aPanV);
+ aPannedCenter.Translate (aPanU);
+ aPannedCenter.Translate (aPanV);
+
+ myCamera->BeginUpdate();
+ myCamera->SetEye (aPannedEye);
+ myCamera->SetCenter (aPannedCenter);
+ myCamera->EndUpdate();
+ }
+
+ AutoZFit();
+}
00-09-92 : GG ; Creation.
24-12-97 : FMN ; Suppression de GEOMLITE
13-06-98 : FMN ; PRO14896: Correction sur la gestion de la perspective (cf Programming Guide)
- 22-12-98 : FMN ; Rename CSF_WALKTHROW en CSF_WALKTHROUGH
- IMP240100: GG -> Activates WalkThrough model.
************************************************************************/
/*----------------------------------------------------------------------*/
void V3d_View::Move(const Standard_Real Dx, const Standard_Real Dy, const Standard_Real Dz, const Standard_Boolean Start) {
-
- Graphic3d_Vertex Prp ;
- Graphic3d_Vector Vpn ;
- Standard_Real XX,XY,XZ,YX,YY,YZ,ZX,ZY,ZZ ;
- Standard_Real Xrp,Yrp,Zrp,Xpn,Ypn,Zpn,Xeye,Yeye,Zeye ;
- if( Start ) {
- MyViewReferencePoint = MyViewOrientation.ViewReferencePoint() ;
- MyViewReferencePlane = MyViewOrientation.ViewReferencePlane() ;
- MyProjReferencePoint = MyViewMapping.ProjectionReferencePoint() ;
- MyViewReferenceUp = MyViewOrientation.ViewReferenceUp() ;
- if (!ScreenAxis(MyViewReferencePlane,MyViewReferenceUp,
- MyXscreenAxis,MyYscreenAxis,MyZscreenAxis))
- V3d_BadValue::Raise ("V3d_View::Move, alignment of Eye,At,Up");
+ if( Start )
+ {
+ myCamStartOpEye = myCamera->Eye();
+
+ gp_Dir aReferencePlane (myCamera->Direction().Reversed());
+ gp_Dir anUp (myCamera->Up());
+ if (!ScreenAxis (aReferencePlane, anUp, MyXscreenAxis, MyYscreenAxis, MyZscreenAxis))
+ {
+ V3d_BadValue::Raise ("V3d_View::Translate, alignment of Eye,At,Up");
+ }
}
- MyXscreenAxis.Coord(XX,XY,XZ) ;
- MyYscreenAxis.Coord(YX,YY,YZ) ;
- MyZscreenAxis.Coord(ZX,ZY,ZZ) ;
- MyProjReferencePoint.Coord(Xrp,Yrp,Zrp) ;
- MyViewReferencePlane.Coord(Xpn,Ypn,Zpn) ;
- Xeye = Zrp*Xpn + Dx*XX + Dy*YX + Dz*ZX ;
- Yeye = Zrp*Ypn + Dx*XY + Dy*YY + Dz*ZY ;
- Zeye = Zrp*Zpn + Dx*XZ + Dy*YZ + Dz*ZZ ;
- Zrp = sqrt( Xeye*Xeye + Yeye*Yeye + Zeye*Zeye ) ;
- V3d_BadValue_Raise_if( Zrp <= 0. ,"V3d_View::Move:: Eye,At are Confused");
-
- Prp.SetCoord(Xrp,Yrp,Zrp) ;
- MyViewMapping.SetProjectionReferencePoint(Prp) ;
- Xpn = Xeye / Zrp ; Ypn = Yeye / Zrp ; Zpn = Zeye / Zrp ;
- Vpn.SetCoord(Xpn,Ypn,Zpn) ;
- MyViewOrientation.SetViewReferencePlane(Vpn) ;
- MyView->SetViewOrientation(MyViewOrientation) ;
-
- // Check ZClipping planes
- MyView->SetViewMapping(MyViewMapping) ;
- SetZSize(0.);
+
+ Standard_Real XX, XY, XZ, YX, YY, YZ, ZX, ZY, ZZ;
+
+ MyXscreenAxis.Coord (XX,XY,XZ);
+ MyYscreenAxis.Coord (YX,YY,YZ);
+ MyZscreenAxis.Coord (ZX,ZY,ZZ);
+
+ myCamera->SetEye (myCamStartOpEye);
+
+ myCamera->SetEye (myCamera->Eye().XYZ()
+ + Dx * gp_Pnt (XX, XY, XZ).XYZ()
+ + Dy * gp_Pnt (YX, YY, YZ).XYZ()
+ + Dz * gp_Pnt (ZX, ZY, ZZ).XYZ()
+ );
+
+ AutoZFit();
+
ImmediateUpdate();
}
void V3d_View::Move(const Standard_Real Length, const Standard_Boolean Start) {
- Graphic3d_Vertex Prp ;
- Graphic3d_Vector Vpn ;
- Standard_Real Vx,Vy,Vz ;
- Standard_Real Xrp,Yrp,Zrp,Xpn,Ypn,Zpn,Xeye,Yeye,Zeye ;
- if( Start ) {
- MyViewReferencePoint = MyViewOrientation.ViewReferencePoint() ;
- MyViewReferencePlane = MyViewOrientation.ViewReferencePlane() ;
- MyProjReferencePoint = MyViewMapping.ProjectionReferencePoint() ;
- }
- MyDefaultViewAxis.Coord(Vx,Vy,Vz) ;
- MyProjReferencePoint.Coord(Xrp,Yrp,Zrp) ;
- MyViewReferencePlane.Coord(Xpn,Ypn,Zpn) ;
- Xeye = Zrp*Xpn + Vx*Length ;
- Yeye = Zrp*Ypn + Vy*Length ;
- Zeye = Zrp*Zpn + Vz*Length ;
- Zrp = sqrt( Xeye*Xeye + Yeye*Yeye + Zeye*Zeye ) ;
- V3d_BadValue_Raise_if( Zrp <= 0. ,"V3d_View::Move:: Eye,At are Confused");
-
- Prp.SetCoord(Xrp,Yrp,Zrp) ;
- MyViewMapping.SetProjectionReferencePoint(Prp) ;
- Xpn = Xeye / Zrp ; Ypn = Yeye / Zrp ; Zpn = Zeye / Zrp ;
- Vpn.SetCoord(Xpn,Ypn,Zpn) ;
- MyViewOrientation.SetViewReferencePlane(Vpn) ;
- MyView->SetViewOrientation(MyViewOrientation) ;
-
-#ifdef IMP020300
- MyView->SetViewMapping(MyViewMapping) ;
- SetZSize(0.);
-#else
- // Check ZClipping planes
- Standard_Real Zmax,Xat,Yat,Zat ;
- MyViewReferencePoint.Coord(Xat,Yat,Zat) ;
- Xeye += Xat ; Yeye += Yat ; Zeye += Zat ;
- Zmax = sqrt( Xeye*Xeye + Yeye*Yeye + Zeye*Zeye ) ;
- if( Zmax > MyViewMapping.FrontPlaneDistance() &&
- MyProjModel == V3d_TPM_SCREEN ) {
- SetZSize(2.*Zmax+Zmax*Zmargin) ;
- } else {
- if( MyType == V3d_PERSPECTIVE ) {
- SetFocale(focale) ;
- }
- MyView->SetViewMapping(MyViewMapping) ;
+
+ if( Start )
+ {
+ myCamStartOpEye = myCamera->Eye();
}
-#endif
+ myCamera->SetEye (myCamStartOpEye);
+
+ Standard_Real Vx, Vy, Vz;
+ MyDefaultViewAxis.Coord (Vx, Vy, Vz) ;
+
+ myCamera->SetEye (myCamera->Eye().XYZ() + Length * gp_Pnt (Vx, Vy, Vz).XYZ());
+
+ AutoZFit();
+
ImmediateUpdate();
}
void V3d_View::Translate(const Standard_Real Dx, const Standard_Real Dy, const Standard_Real Dz, const Standard_Boolean Start) {
- Graphic3d_Vertex Vrp ;
- Standard_Real XX,XY,XZ,YX,YY,YZ,ZX,ZY,ZZ ;
- Standard_Real Xat,Yat,Zat ;
- if( Start ) {
- MyViewReferencePoint = MyViewOrientation.ViewReferencePoint() ;
- MyViewReferencePlane = MyViewOrientation.ViewReferencePlane() ;
- MyViewReferenceUp = MyViewOrientation.ViewReferenceUp() ;
- MyProjReferencePoint = MyViewMapping.ProjectionReferencePoint();
- if (!ScreenAxis(MyViewReferencePlane,MyViewReferenceUp,
- MyXscreenAxis,MyYscreenAxis,MyZscreenAxis))
- V3d_BadValue::Raise ("V3d_View::Translate, alignment of Eye,At,Up");
- }
- MyXscreenAxis.Coord(XX,XY,XZ) ;
- MyYscreenAxis.Coord(YX,YY,YZ) ;
- MyZscreenAxis.Coord(ZX,ZY,ZZ) ;
- MyViewReferencePoint.Coord(Xat,Yat,Zat) ;
- Xat -= Dx*XX + Dy*YX + Dz*ZX ;
- Yat -= Dx*XY + Dy*YY + Dz*ZY ;
- Zat -= Dx*XZ + Dy*YZ + Dz*ZZ ;
- Vrp.SetCoord(Xat,Yat,Zat) ;
- MyViewOrientation.SetViewReferencePoint(Vrp) ;
- MyView->SetViewOrientation(MyViewOrientation) ;
-#ifdef IMP020300
- SetZSize(0.);
-#else
- // Check ZClipping planes
- Standard_Real Xpn,Ypn,Zpn,Xrp,Yrp,Zrp,Xeye,Yeye,Zeye,Zmax ;
- MyProjReferencePoint.Coord(Xrp,Yrp,Zrp) ;
- MyViewReferencePlane.Coord(Xpn,Ypn,Zpn) ;
- Xeye = Zrp*Xpn + Xat ; Yeye = Zrp*Ypn + Yat ; Zeye = Zrp*Zpn + Zat ;
- Zmax = Max(sqrt( Xeye*Xeye + Yeye*Yeye + Zeye*Zeye ) ,
- sqrt( Xat*Xat + Yat*Yat + Zat*Zat )) ;
- if( Zmax > MyViewMapping.FrontPlaneDistance() &&
- MyProjModel == V3d_TPM_SCREEN ) {
- SetZSize(2.*Zmax+Zmax*Zmargin) ;
+ if( Start )
+ {
+ myCamStartOpEye = myCamera->Eye();
+ myCamStartOpCenter = myCamera->Center();
+
+ gp_Dir aReferencePlane (myCamera->Direction().Reversed());
+ gp_Dir anUp (myCamera->Up());
+ if (!ScreenAxis (aReferencePlane, anUp,
+ MyXscreenAxis,MyYscreenAxis,MyZscreenAxis))
+ V3d_BadValue::Raise ("V3d_View::Translate, alignment of Eye,At,Up");
}
-#endif
+
+ Standard_Real XX, XY, XZ, YX, YY, YZ, ZX, ZY, ZZ;
+
+ MyXscreenAxis.Coord (XX,XY,XZ);
+ MyYscreenAxis.Coord (YX,YY,YZ);
+ MyZscreenAxis.Coord (ZX,ZY,ZZ);
+
+ myCamera->SetEye (myCamStartOpEye);
+ myCamera->SetCenter (myCamStartOpCenter);
+
+ myCamera->SetCenter (myCamera->Center().XYZ()
+ - Dx * gp_Pnt (XX, XY, XZ).XYZ()
+ - Dy * gp_Pnt (YX, YY, YZ).XYZ()
+ - Dz * gp_Pnt (ZX, ZY, ZZ).XYZ()
+ );
+
+ myCamera->SetEye (myCamera->Eye().XYZ()
+ - Dx * gp_Pnt (XX, XY, XZ).XYZ()
+ - Dy * gp_Pnt (YX, YY, YZ).XYZ()
+ - Dz * gp_Pnt (ZX, ZY, ZZ).XYZ()
+ );
+
+ AutoZFit();
+
ImmediateUpdate();
}
}
void V3d_View::Place (const Standard_Integer ix, const Standard_Integer iy,
const Quantity_Factor aZoomFactor) {
- Standard_Real xpos,ypos;
- Standard_Integer xc,yc;
- Center(xpos,ypos);
- Convert(xpos,ypos,xc,yc);
- Pan(xc-ix,iy-yc,aZoomFactor/Scale());
+ Standard_Real xpos, ypos;
+ Standard_Integer xc, yc;
+ Center (xpos, ypos);
+ Convert (xpos, ypos, xc, yc);
+ Pan (xc - ix, iy - yc, aZoomFactor / Scale());
}
-void V3d_View::Translate(const Standard_Real Length,const Standard_Boolean Start) {
- Graphic3d_Vertex Vrp ;
- Standard_Real Xat,Yat,Zat,Vx,Vy,Vz ;
- if( Start ) {
- MyViewReferencePoint = MyViewOrientation.ViewReferencePoint() ;
- }
- MyDefaultViewAxis.Coord(Vx,Vy,Vz) ;
- MyViewReferencePoint.Coord(Xat,Yat,Zat) ;
- Xat -= Vx*Length ; Yat -= Vy*Length ; Zat -= Vz*Length ;
- Vrp.SetCoord(Xat,Yat,Zat) ;
- MyViewOrientation.SetViewReferencePoint(Vrp) ;
- MyView->SetViewOrientation(MyViewOrientation) ;
-
-#ifdef IMP020300
- SetZSize(0.);
-#else
- // Check ZClipping planes
- Standard_Real Xpn,Ypn,Zpn,Xrp,Yrp,Zrp,Xeye,Yeye,Zeye,Zmax ;
- MyProjReferencePoint.Coord(Xrp,Yrp,Zrp) ;
- MyViewReferencePlane.Coord(Xpn,Ypn,Zpn) ;
- Xeye = Zrp*Xpn + Xat ; Yeye = Zrp*Ypn + Yat ; Zeye = Zrp*Zpn + Zat ;
- Zmax = Max(sqrt( Xeye*Xeye + Yeye*Yeye + Zeye*Zeye ) ,
- sqrt( Xat*Xat + Yat*Yat + Zat*Zat )) ;
- if( Zmax > MyViewMapping.FrontPlaneDistance() &&
- MyProjModel == V3d_TPM_SCREEN ) {
- SetZSize(2.*Zmax+Zmax*Zmargin) ;
+
+void V3d_View::Translate(const Standard_Real theLength, const Standard_Boolean theStart) {
+
+ Standard_Real aVx, aVy, aVz ;
+ if (theStart)
+ {
+ myCamStartOpCenter = myCamera->Center() ;
}
-#endif
+ MyDefaultViewAxis.Coord (aVx, aVy, aVz);
+ gp_Pnt aNewCenter (myCamStartOpCenter.XYZ() - gp_Pnt (aVx, aVy, aVz).XYZ() * theLength);
+ myCamera->SetCenter (aNewCenter);
+
+ AutoZFit();
+
ImmediateUpdate();
}
void V3d_View::SetGrid (const gp_Ax3& aPlane, const Handle(Aspect_Grid)& aGrid)
{
- MyPlane = aPlane;
- MyGrid = aGrid;
-
- Standard_Real xl, yl, zl;
- Standard_Real xdx, xdy, xdz;
- Standard_Real ydx, ydy, ydz;
- Standard_Real dx, dy, dz;
- aPlane.Location ().Coord (xl, yl, zl);
- aPlane.XDirection ().Coord (xdx, xdy, xdz);
- aPlane.YDirection ().Coord (ydx, ydy, ydz);
- aPlane.Direction ().Coord (dx, dy, dz);
-
- Standard_Real CosAlpha = Cos (MyGrid->RotationAngle ());
- Standard_Real SinAlpha = Sin (MyGrid->RotationAngle ());
-
- TColStd_Array2OfReal Trsf1 (1, 4, 1, 4);
- Trsf1 (4, 4) = 1.0;
- Trsf1 (4, 1) = Trsf1 (4, 2) = Trsf1 (4, 3) = 0.0;
- // Translation
- Trsf1 (1, 4) = xl,
- Trsf1 (2, 4) = yl,
- Trsf1 (3, 4) = zl;
- // Transformation change of marker
- Trsf1 (1, 1) = xdx,
- Trsf1 (2, 1) = xdy,
- Trsf1 (3, 1) = xdz,
- Trsf1 (1, 2) = ydx,
- Trsf1 (2, 2) = ydy,
- Trsf1 (3, 2) = ydz,
- Trsf1 (1, 3) = dx,
- Trsf1 (2, 3) = dy,
- Trsf1 (3, 3) = dz;
-
- TColStd_Array2OfReal Trsf2 (1, 4, 1, 4);
- Trsf2 (4, 4) = 1.0;
- Trsf2 (4, 1) = Trsf2 (4, 2) = Trsf2 (4, 3) = 0.0;
- // Translation of the origin
- Trsf2 (1, 4) = -MyGrid->XOrigin (),
- Trsf2 (2, 4) = -MyGrid->YOrigin (),
- Trsf2 (3, 4) = 0.0;
- // Rotation Alpha around axis -Z
- Trsf2 (1, 1) = CosAlpha,
- Trsf2 (2, 1) = -SinAlpha,
- Trsf2 (3, 1) = 0.0,
- Trsf2 (1, 2) = SinAlpha,
- Trsf2 (2, 2) = CosAlpha,
- Trsf2 (3, 2) = 0.0,
- Trsf2 (1, 3) = 0.0,
- Trsf2 (2, 3) = 0.0,
- Trsf2 (3, 3) = 1.0;
-
- Standard_Real valuetrsf;
- Standard_Real valueoldtrsf;
- Standard_Real valuenewtrsf;
- Standard_Integer i, j, k;
- // Calculation of the product of matrices
- for (i=1; i<=4; i++)
- for (j=1; j<=4; j++) {
- MyTrsf (i, j) = 0.0;
- for (k=1; k<=4; k++) {
- valueoldtrsf = Trsf1 (i, k);
- valuetrsf = Trsf2 (k, j);
- valuenewtrsf = MyTrsf (i, j) + valueoldtrsf * valuetrsf;
- MyTrsf (i, j) = valuenewtrsf;
- }
- }
+ MyPlane = aPlane;
+ MyGrid = aGrid;
+
+ Standard_Real xl, yl, zl;
+ Standard_Real xdx, xdy, xdz;
+ Standard_Real ydx, ydy, ydz;
+ Standard_Real dx, dy, dz;
+ aPlane.Location ().Coord (xl, yl, zl);
+ aPlane.XDirection ().Coord (xdx, xdy, xdz);
+ aPlane.YDirection ().Coord (ydx, ydy, ydz);
+ aPlane.Direction ().Coord (dx, dy, dz);
+
+ Standard_Real CosAlpha = Cos (MyGrid->RotationAngle ());
+ Standard_Real SinAlpha = Sin (MyGrid->RotationAngle ());
+
+ TColStd_Array2OfReal Trsf1 (1, 4, 1, 4);
+ Trsf1 (4, 4) = 1.0;
+ Trsf1 (4, 1) = Trsf1 (4, 2) = Trsf1 (4, 3) = 0.0;
+ // Translation
+ Trsf1 (1, 4) = xl,
+ Trsf1 (2, 4) = yl,
+ Trsf1 (3, 4) = zl;
+ // Transformation change of marker
+ Trsf1 (1, 1) = xdx,
+ Trsf1 (2, 1) = xdy,
+ Trsf1 (3, 1) = xdz,
+ Trsf1 (1, 2) = ydx,
+ Trsf1 (2, 2) = ydy,
+ Trsf1 (3, 2) = ydz,
+ Trsf1 (1, 3) = dx,
+ Trsf1 (2, 3) = dy,
+ Trsf1 (3, 3) = dz;
+
+ TColStd_Array2OfReal Trsf2 (1, 4, 1, 4);
+ Trsf2 (4, 4) = 1.0;
+ Trsf2 (4, 1) = Trsf2 (4, 2) = Trsf2 (4, 3) = 0.0;
+ // Translation of the origin
+ Trsf2 (1, 4) = -MyGrid->XOrigin (),
+ Trsf2 (2, 4) = -MyGrid->YOrigin (),
+ Trsf2 (3, 4) = 0.0;
+ // Rotation Alpha around axis -Z
+ Trsf2 (1, 1) = CosAlpha,
+ Trsf2 (2, 1) = -SinAlpha,
+ Trsf2 (3, 1) = 0.0,
+ Trsf2 (1, 2) = SinAlpha,
+ Trsf2 (2, 2) = CosAlpha,
+ Trsf2 (3, 2) = 0.0,
+ Trsf2 (1, 3) = 0.0,
+ Trsf2 (2, 3) = 0.0,
+ Trsf2 (3, 3) = 1.0;
+
+ Standard_Real valuetrsf;
+ Standard_Real valueoldtrsf;
+ Standard_Real valuenewtrsf;
+ Standard_Integer i, j, k;
+ // Calculation of the product of matrices
+ for (i=1; i<=4; i++)
+ for (j=1; j<=4; j++) {
+ MyTrsf (i, j) = 0.0;
+ for (k=1; k<=4; k++) {
+ valueoldtrsf = Trsf1 (i, k);
+ valuetrsf = Trsf2 (k, j);
+ valuenewtrsf = MyTrsf (i, j) + valueoldtrsf * valuetrsf;
+ MyTrsf (i, j) = valuenewtrsf;
+ }
+ }
}
void V3d_View::SetGridActivity (const Standard_Boolean AFlag)
{
- if (AFlag) MyGrid->Activate ();
- else MyGrid->Deactivate ();
+ if (AFlag) MyGrid->Activate ();
+ else MyGrid->Deactivate ();
}
void V3d_View::SetGridGraphicValues (const Handle(Aspect_Grid)& )
{
}
+
+void toPolarCoords (const Standard_Real theX, const Standard_Real theY,
+ Standard_Real& theR, Standard_Real& thePhi)
+{
+ theR = Sqrt (theX * theX + theY * theY);
+ thePhi = ATan2 (theY, theX);
+}
+
+void toCartesianCoords (const Standard_Real theR, const Standard_Real thePhi,
+ Standard_Real& theX, Standard_Real& theY)
+{
+ theX = theR * Cos (thePhi);
+ theY = theR * Sin (thePhi);
+}
+
Graphic3d_Vertex V3d_View::Compute (const Graphic3d_Vertex & AVertex) const
{
- Graphic3d_Vertex CurPoint, NewPoint;
- Standard_Real X1, Y1, Z1, X2, Y2, Z2;
- Standard_Real XPp, YPp;
+ Graphic3d_Vertex CurPoint, NewPoint;
+ Standard_Real X1, Y1, Z1, X2, Y2, Z2;
+ Standard_Real XPp, YPp;
- MyView->ViewOrientation ().ViewReferencePlane ().Coord (X1, Y1, Z1);
- MyPlane.Direction ().Coord (X2, Y2, Z2);
+ gp_Dir aRefPlane = myCamera->Direction().Reversed();
+ X1 = aRefPlane.X(); Y1 = aRefPlane.Y(); Z1 = aRefPlane.Z();
+ MyPlane.Direction ().Coord (X2, Y2, Z2);
- gp_Dir VPN (X1, Y1, Z1);
- gp_Dir GPN (X2, Y2, Z2);
+ gp_Dir VPN (X1, Y1, Z1);
+ gp_Dir GPN (X2, Y2, Z2);
- AVertex.Coord (X1, Y1, Z1);
- Project (X1, Y1, Z1, XPp, YPp);
+ AVertex.Coord (X1, Y1, Z1);
+ Project (X1, Y1, Z1, XPp, YPp);
- // Casw when the plane of the grid and the plane of the view
- // are perpendicular to MYEPSILON2 close radians
- if (Abs (VPN.Angle (GPN) - M_PI / 2.) < MYEPSILON2) {
- NewPoint.SetCoord (X1, Y1, Z1);
+ // Casw when the plane of the grid and the plane of the view
+ // are perpendicular to MYEPSILON2 close radians
+ if (Abs (VPN.Angle (GPN) - M_PI / 2.) < MYEPSILON2) {
+ NewPoint.SetCoord (X1, Y1, Z1);
#ifdef IMP240100
- MyViewer->ShowGridEcho(this,NewPoint);
+ MyViewer->ShowGridEcho(this,NewPoint);
#endif //IMP240100
- return NewPoint;
- }
-
- Standard_Boolean IsRectangular =
- MyGrid->IsKind (STANDARD_TYPE (Aspect_RectangularGrid));
-
- Graphic3d_Vertex P1;
-
- Standard_Real XO = 0.0, YO = 0.0;
- Standard_Real XOp, YOp;
- Standard_Real XAp, YAp;
- Standard_Real XBp, YBp;
-
- X1 = XO, Y1 = YO, Z1 = 0.0;
- // MyTrsf * Point to return to the plane of 3D grid
- P1.SetCoord (X1, Y1, Z1);
- CurPoint = V3d_View::TrsPoint (P1, MyTrsf);
- CurPoint.Coord (X2, Y2, Z2);
- Project (X2, Y2, Z2, XOp, YOp);
- XPp = XPp - XOp, YPp = YPp - YOp;
-
- if (IsRectangular) {
- Standard_Real XS, YS;
- Handle(Aspect_RectangularGrid) theGrid =
- *(Handle(Aspect_RectangularGrid) *) &MyGrid;
- XS = theGrid->XStep (), YS = theGrid->YStep ();
-
- X1 = XO + XS, Y1 = YO, Z1 = 0.0;
- // MyTrsf * Point to return to the plane of 3D grid
- P1.SetCoord (X1, Y1, Z1);
- CurPoint = V3d_View::TrsPoint (P1, MyTrsf);
- CurPoint.Coord (X2, Y2, Z2);
- Project (X2, Y2, Z2, XAp, YAp);
- XAp = XAp - XOp, YAp = YAp - YOp;
-
- X1 = XO, Y1 = YO + YS, Z1 = 0.0;
- // MyTrsf * Point to return to the plane of 3D grid
- P1.SetCoord (X1, Y1, Z1);
- CurPoint = V3d_View::TrsPoint (P1, MyTrsf);
- CurPoint.Coord (X2, Y2, Z2);
- Project (X2, Y2, Z2, XBp, YBp);
- XBp = XBp - XOp, YBp = YBp - YOp;
-
- Standard_Real Determin = XAp*YBp - XBp*YAp;
-
- Z1 = 0.0;
- if (Abs (Determin) > MYEPSILON1) {
- X1 = (YBp*XPp - XBp*YPp) / Determin;
- Y1 = (XAp*YPp - YAp*XPp) / Determin;
- X1 = (X1 > 0. ?
- Standard_Real (Standard_Integer (Abs (X1)+0.5)) * XS :
- - Standard_Real (Standard_Integer (Abs (X1)+0.5)) * XS);
- Y1 = (Y1 > 0. ?
- Standard_Real (Standard_Integer (Abs (Y1)+0.5)) * YS :
- - Standard_Real (Standard_Integer (Abs (Y1)+0.5)) * YS);
- // MyTrsf * Point to return to the plane of 3D grid
- P1.SetCoord (X1, Y1, Z1);
- CurPoint = V3d_View::TrsPoint (P1, MyTrsf);
- CurPoint.Coord (X2, Y2, Z2);
- }
- else {
- //cout << "*****************" << endl;
- //cout << "Zero Determinant!" << endl;
- //cout << "*****************" << endl;
- AVertex.Coord (X2, Y2, Z2);
- CurPoint.SetCoord (X2, Y2, Z2);
- }
- } // IsRectangular
- else {
- Standard_Real RS;
- Standard_Integer DN;
- Standard_Real Alpha;
- Handle(Aspect_CircularGrid) theGrid =
- *(Handle(Aspect_CircularGrid) *) &MyGrid;
- RS = theGrid->RadiusStep ();
- DN = theGrid->DivisionNumber ();
- Alpha = M_PI / Standard_Real (DN);
-
- Standard_Real DistOP = Sqrt (XPp*XPp + YPp*YPp);
-
- Standard_Integer i, ICur=0;
- Standard_Real Angle, AngleCur;
- Standard_Real XCurp=0, YCurp=0;
- gp_Dir2d OP (XPp, YPp);
- AngleCur = 2 * M_PI;
- for (i=1; i<=DN*2; i++) {
- X1 = XO + Cos (Alpha * i) * RS,
- Y1 = YO + Sin (Alpha * i) * RS,
- Z1 = 0.0;
- // MyTrsf * Point to return to the plane of 3D grid
- P1.SetCoord (X1, Y1, Z1);
- CurPoint = V3d_View::TrsPoint (P1, MyTrsf);
- CurPoint.Coord (X2, Y2, Z2);
- Project (X2, Y2, Z2, XAp, YAp);
- XAp = XAp - XOp, YAp = YAp - YOp;
- gp_Dir2d OA (XAp, YAp);
- Angle = OP.Angle (OA);
- if (Abs (AngleCur) > Abs (Angle)) {
- ICur = i;
- AngleCur = Angle;
- XCurp = XAp, YCurp = YAp;
- }
-
- } // for (i=1; i<=DN*2; i++)
-
- Standard_Real DistOCur = Sqrt (XCurp*XCurp + YCurp*YCurp);
-
- // Determination of the circle of the grid closest to P
- Standard_Integer N = Standard_Integer (DistOP / DistOCur + 0.5);
- Standard_Real Radius = N * RS;
-
- X1 = Cos (Alpha * ICur) * Radius,
- Y1 = Sin (Alpha * ICur) * Radius,
- Z1 = 0.0;
-
- // MyTrsf * Point to return to the plane of 3D grid
- P1.SetCoord (X1, Y1, Z1);
- CurPoint = V3d_View::TrsPoint (P1, MyTrsf);
- CurPoint.Coord (X2, Y2, Z2);
- } // IsCircular
-
- NewPoint.SetCoord (CurPoint.X (), CurPoint.Y (), CurPoint.Z ());
+ return NewPoint;
+ }
+
+ Standard_Boolean IsRectangular =
+ MyGrid->IsKind (STANDARD_TYPE (Aspect_RectangularGrid));
+
+ Graphic3d_Vertex P1;
+
+ Standard_Real x0, y0, z0, x1, y1, z1, x2, y2, z2;
+
+ P1.SetCoord (0.0, 0.0, 0.0);
+ CurPoint = V3d_View::TrsPoint (P1, MyTrsf);
+ CurPoint.Coord (x0, y0, z0);
+
+ // get grid axes in world space
+ P1.SetCoord (1.0, 0.0, 0.0);
+ CurPoint = V3d_View::TrsPoint (P1, MyTrsf);
+ CurPoint.Coord (x1, y1, z1);
+ gp_Vec aGridX (gp_Pnt (x0, y0, z0), gp_Pnt (x1, y1, z1));
+ aGridX.Normalize();
+
+ P1.SetCoord (0.0, 1.0, 0.0);
+ CurPoint = V3d_View::TrsPoint (P1, MyTrsf);
+ CurPoint.Coord (x2, y2, z2);
+ gp_Vec aGridY (gp_Pnt (x0, y0, z0), gp_Pnt (x2, y2, z2));
+ aGridY.Normalize();
+
+ // get grid normal
+ MyPlane.Direction().Coord (x2, y2, z2);
+ gp_Vec aPlaneNormal (x2, y2, z2);
+
+ gp_Vec aPointOnPlane = gp_Vec (0.0, 0.0, 0.0);
+
+ AVertex.Coord (x1, y1, z1);
+
+ // project ray from camera onto grid plane
+ if (!myCamera->IsOrthographic())
+ {
+ gp_Vec aPointFromCamera = gp_Vec (myCamera->Eye(), gp_Pnt (x1, y1, z1));
+ aPointFromCamera.Normalize();
+
+ Standard_Real aT = - gp_Vec (myCamera->Eye().XYZ()).Dot (aPlaneNormal) /
+ aPointFromCamera.Dot (aPlaneNormal);
+ aPointOnPlane = gp_Vec (myCamera->Eye().XYZ()) + aPointFromCamera * aT;
+ } else
+ {
+ gp_Vec aPointFromCamera (myCamera->Direction());
+ gp_Vec aPointOnCamera (gp_Vec (x1, y1, z1) - aPointFromCamera);
+
+ Standard_Real aT = - aPointOnCamera.Dot (aPlaneNormal) /
+ aPointFromCamera.Dot (aPlaneNormal);
+ aPointOnPlane = aPointOnCamera + aPointFromCamera * aT;
+ }
+
+ if (IsRectangular) {
+ Standard_Real XS, YS;
+ Handle(Aspect_RectangularGrid) theGrid =
+ *(Handle(Aspect_RectangularGrid) *) &MyGrid;
+ XS = theGrid->XStep (), YS = theGrid->YStep ();
+
+ // project point on plane to grid local space
+ gp_Vec aToPoint (gp_Pnt (x0, y0, z0),
+ gp_Pnt (aPointOnPlane.X(), aPointOnPlane.Y(), aPointOnPlane.Z()));
+ Standard_Real anXSteps = Round (aGridX.Dot (aToPoint) / XS);
+ Standard_Real anYSteps = Round (aGridY.Dot (aToPoint) / YS);
+
+ // clamp point to grid
+ gp_Vec aResult = aGridX * anXSteps * XS + aGridY * anYSteps * YS + gp_Vec (x0, y0, z0);
+ NewPoint.SetCoord (aResult.X(), aResult.Y(), aResult.Z());
+
+ }
+ else // IsCircular
+ {
+ Standard_Real RS;
+ Standard_Integer DN;
+ Standard_Real Alpha;
+ Handle(Aspect_CircularGrid) theGrid =
+ *(Handle(Aspect_CircularGrid) *) &MyGrid;
+ RS = theGrid->RadiusStep ();
+ DN = theGrid->DivisionNumber ();
+ Alpha = M_PI / Standard_Real (DN);
+
+ // project point on plane to grid local space
+ gp_Vec aToPoint (gp_Pnt (x0, y0, z0),
+ gp_Pnt (aPointOnPlane.X(), aPointOnPlane.Y(), aPointOnPlane.Z()));
+
+ Standard_Real anR = 0.0, aPhi = 0.0;
+ Standard_Real aLocalX = aGridX.Dot (aToPoint);
+ Standard_Real aLocalY = aGridY.Dot (aToPoint);
+ toPolarCoords (aLocalX, aLocalY, anR, aPhi);
+
+ // clamp point to grid
+ Standard_Real anRSteps = Round (anR / RS);
+ Standard_Real aPhiSteps = Round (aPhi / Alpha);
+ toCartesianCoords (anRSteps * RS, aPhiSteps * Alpha, aLocalX, aLocalY);
+
+ gp_Vec aResult = aGridX * aLocalX + aGridY * aLocalY + gp_Vec (x0, y0, z0);
+ NewPoint.SetCoord (aResult.X(), aResult.Y(), aResult.Z());
+ }
#ifdef IMP240100
- MyViewer->ShowGridEcho(this,NewPoint);
+ MyViewer->ShowGridEcho(this,NewPoint);
#endif //IMP240100
- return NewPoint;
+ return NewPoint;
}
// Triedron methods : the Triedron is a non-zoomable object.
void V3d_View::ZBufferTriedronSetup(const Quantity_NameOfColor XColor,
- const Quantity_NameOfColor YColor,
- const Quantity_NameOfColor ZColor,
- const Standard_Real SizeRatio,
- const Standard_Real AxisDiametr,
- const Standard_Integer NbFacettes)
+ const Quantity_NameOfColor YColor,
+ const Quantity_NameOfColor ZColor,
+ const Standard_Real SizeRatio,
+ const Standard_Real AxisDiametr,
+ const Standard_Integer NbFacettes)
{
MyView->ZBufferTriedronSetup(XColor, YColor, ZColor, SizeRatio, AxisDiametr, NbFacettes);
}
void V3d_View::TriedronDisplay (const Aspect_TypeOfTriedronPosition APosition,
const Quantity_NameOfColor AColor, const Standard_Real AScale, const V3d_TypeOfVisualization AMode )
{
- MyView->TriedronDisplay (APosition, AColor, AScale, (AMode == V3d_WIREFRAME));
+ MyView->TriedronDisplay (APosition, AColor, AScale, (AMode == V3d_WIREFRAME));
}
void V3d_View::TriedronErase ( )
{
- MyView->TriedronErase ( );
+ MyView->TriedronErase ( );
}
void V3d_View::TriedronEcho (const Aspect_TypeOfTriedronEcho AType )
{
- MyView->TriedronEcho (AType);
+ MyView->TriedronEcho (AType);
}
void V3d_View::GetGraduatedTrihedron(/* Names of axes */
Background from Aspect,
GradientBackground from Aspect,
Parameter from Quantity,
- OrthographicView from V3d,
- PerspectiveView from V3d,
AsciiString,ExtendedString from TCollection,
Ax3 from gp,Structure from Graphic3d,
Vertex from Graphic3d,
#include <V3d_Viewer.ixx>
#include <V3d_View.hxx>
#include <V3d_BadValue.hxx>
-#include <V3d_OrthographicView.hxx>
-#include <V3d_PerspectiveView.hxx>
/*----------------------------------------------------------------------*/
//-Methods, in order
-Handle(V3d_View) V3d_Viewer::CreateView () {
- if (MyDefaultTypeOfView == V3d_ORTHOGRAPHIC)
- return new V3d_OrthographicView(this);
- else
- return new V3d_PerspectiveView(this);
+Handle(V3d_View) V3d_Viewer::CreateView ()
+{
+ return new V3d_View(this, MyDefaultTypeOfView);
}
void V3d_Viewer::SetViewOn( ) {
{
if (argc < 2)
{
- di<<"Use: "<<argv[0]<<" <filename>.{png|bmp|jpg|gif} [buffer={rgb|rgba|depth}] [width height]\n";
+ di<<"Use: "<<argv[0]<<" <filename>.{png|bmp|jpg|gif} [buffer={rgb|rgba|depth}] [width height] [stereoproj={L|R}]\n";
return 1;
}
Standard_Integer aWidth = (argc > 3) ? Draw::Atoi (argv[3]) : 0;
Standard_Integer aHeight = (argc > 4) ? Draw::Atoi (argv[4]) : 0;
+ TCollection_AsciiString aStereoProj ((argc > 5) ? argv[5] : "");
+
Handle(AIS_InteractiveContext) IC;
Handle(V3d_View) view;
GetCtxAndView (IC, view);
return 0;
}
+ V3d_StereoDumpOptions aStereoOpts = V3d_SDO_MONO;
+
+ if (!aStereoProj.IsEmpty())
+ {
+ aStereoProj.UpperCase();
+ if (aStereoProj == "L")
+ {
+ aStereoOpts = V3d_SDO_LEFT_EYE;
+ }
+
+ if (aStereoProj == "R")
+ {
+ aStereoOpts = V3d_SDO_RIGHT_EYE;
+ }
+ }
+
Image_AlienPixMap aPixMap;
- if (!view->ToPixMap (aPixMap, aWidth, aHeight, aBufferType))
+ if (!view->ToPixMap (aPixMap, aWidth, aHeight, aBufferType, Standard_True, aStereoOpts))
{
di << "Dumping failed!\n";
return 1;
theCommands.Add("vdump",
#ifdef HAVE_FREEIMAGE
- "<filename>.{png|bmp|jpg|gif} [buffer={rgb|rgba|depth}] [width height]"
+ "<filename>.{png|bmp|jpg|gif} [buffer={rgb|rgba|depth}] [width height] [stereoproj={L|R}]"
"\n\t\t: Dumps contents of viewer window to PNG, BMP, JPEG or GIF file",
#else
- "<filename>.{ppm} [buffer={rgb|rgba|depth}] [width height]"
+ "<filename>.{ppm} [buffer={rgb|rgba|depth}] [width height] [stereoproj={L|R}]"
"\n\t\t: Dumps contents of viewer window to PPM image file",
#endif
__FILE__,VDump,group);
{
#ifndef WNT
di << "Printing implemented only for wnt!\n";
- return 1;
+ return 0;
#else
Handle(AIS_InteractiveContext) aContextAIS = NULL;
else if (argc < 4)
{
di << "Use: " << argv[0];
- di << " width height filename [print algo=0]\n";
+ di << " width height filename [print algo=0] [tile_width tile_height]\n";
di << "width, height of the intermediate buffer for operation\n";
di << "algo : {0|1}\n";
di << " 0 - stretch algorithm\n";
di << " 1 - tile algorithm\n";
di << "test printing algorithms into an intermediate buffer\n";
+ di << "using specific tile size if provided\n";
di << "with saving output to an image file\n";
return 1;
}
Standard_Integer aHeight = Draw::Atoi (argv[2]);
Standard_Integer aMode = 0;
TCollection_AsciiString aFileName = TCollection_AsciiString (argv[3]);
- if (argc==5)
+ if (argc >= 5)
aMode = Draw::Atoi (argv[4]);
+ Standard_Integer aTileWidth = 0;
+ Standard_Integer aTileHeight = 0;
+ Standard_Boolean isTileSizeProvided = Standard_False;
+ if (argc == 7)
+ {
+ isTileSizeProvided = Standard_True;
+ aTileWidth = Draw::Atoi (argv[5]);
+ aTileHeight = Draw::Atoi (argv[6]);
+ }
+
// check the input parameters
if (aWidth <= 0 || aHeight <= 0)
{
if (aMode == 0)
isPrinted = aView->Print(anDC,1,1,0,Aspect_PA_STRETCH);
else
- isPrinted = aView->Print(anDC,1,1,0,Aspect_PA_TILE);
+ {
+ if (isTileSizeProvided)
+ {
+ Graphic3d_CView* aCView = static_cast<Graphic3d_CView*> (ViewerTest::CurrentView()->View()->CView());
+ Graphic3d_PtrFrameBuffer anOldBuffer = static_cast<Graphic3d_PtrFrameBuffer> (aCView->ptrFBO);
+ aCView->ptrFBO = aView->View()->FBOCreate (aTileWidth, aTileHeight);
+
+ isPrinted = aView->Print (anDC, 1, 1, 0, Aspect_PA_TILE);
+
+ Graphic3d_PtrFrameBuffer aNewBuffer = static_cast<Graphic3d_PtrFrameBuffer> (aCView->ptrFBO);
+ aView->View()->FBORelease (aNewBuffer);
+ aCView->ptrFBO = anOldBuffer;
+ }
+ else
+ {
+ isPrinted = aView->Print (anDC, 1, 1, 0, Aspect_PA_TILE);
+ }
+ }
// succesfully printed into an intermediate buffer
if (isPrinted)
Standard_Real anAISViewAtX = atof (argv [10]);
Standard_Real anAISViewAtY = atof (argv [11]);
Standard_Real anAISViewAtZ = atof (argv [12]);
- anAISView -> V3d_View::SetScale (anAISViewScale);
+ anAISView -> V3d_View::Camera()->BeginUpdate();
anAISView -> V3d_View::SetCenter (anAISViewCenterCoordinateX, anAISViewCenterCoordinateY);
anAISView -> V3d_View::SetAt (anAISViewAtX, anAISViewAtY, anAISViewAtZ);
+ anAISView -> V3d_View::SetScale (anAISViewScale);
anAISView -> V3d_View::SetProj (anAISViewProjX, anAISViewProjY, anAISViewProjZ);
anAISView -> V3d_View::SetUp (anAISViewUpX, anAISViewUpY, anAISViewUpZ);
+ anAISView -> V3d_View::Camera()->EndUpdate();
}
return 0;
}
return 0;
}
+//===============================================================================================
+//function : VZRange
+//purpose :
+//===============================================================================================
+static int VZRange (Draw_Interpretor& theDi, Standard_Integer theArgsNb, const char** theArgVec)
+{
+ if (ViewerTest::CurrentView().IsNull())
+ {
+ theDi << theArgVec[0] << ": Call vinit before this command, please.\n";
+ return 1;
+ }
+
+ Handle(Graphic3d_Camera) aCamera = ViewerTest::CurrentView()->Camera();
+
+ if (theArgsNb < 2)
+ {
+ theDi << "ZNear: " << aCamera->ZNear() << "\n";
+ theDi << "ZFar: " << aCamera->ZFar() << "\n";
+ return 0;
+ }
+
+ if (theArgsNb == 3)
+ {
+ Standard_Real aNewZNear = atof (theArgVec[1]);
+ Standard_Real aNewZFar = atof (theArgVec[2]);
+
+ aCamera->BeginUpdate();
+ aCamera->SetZFar (aNewZFar);
+ aCamera->SetZNear (aNewZNear);
+ aCamera->EndUpdate();
+ }
+ else
+ {
+ theDi << theArgVec[0] << ": wrong command arguments. Type help for more information.\n";
+ return 1;
+ }
+
+ return 0;
+}
+
+//===============================================================================================
+//function : VAutoZFit
+//purpose :
+//===============================================================================================
+static int VAutoZFit (Draw_Interpretor& theDi, Standard_Integer theArgsNb, const char** theArgVec)
+{
+ if (ViewerTest::CurrentView().IsNull())
+ {
+ theDi << theArgVec[0] << ": Call vinit before this command, please.\n";
+ return 1;
+ }
+
+ if (theArgsNb < 2)
+ {
+ theDi << "Auto z-fit mode: " << (ViewerTest::CurrentView()->AutoZFitMode() ? "enabled" : "disabled");
+ return 0;
+ }
+
+ if (theArgsNb == 2)
+ {
+ Standard_Real aNewMode = atoi (theArgVec[1]);
+
+ ViewerTest::CurrentView()->SetAutoZFitMode (aNewMode != 0);
+ }
+ else
+ {
+ theDi << theArgVec[0] << ": wrong command arguments. Type help for more information.\n";
+ return 1;
+ }
+
+ return 0;
+}
+
+//===============================================================================================
+//function : VChangeCamera
+//purpose :
+//===============================================================================================
+static int VChangeCamera (Draw_Interpretor& theDi, Standard_Integer theArgsNb, const char** theArgVec)
+{
+ if (ViewerTest::CurrentView().IsNull())
+ {
+ theDi << theArgVec[0] << ": Call vinit before this command, please.\n";
+ return 1;
+ }
+
+ const char anErrorMessage[] = ": wrong command arguments. Type help for more information.\n";
+ if (theArgsNb < 3)
+ {
+ theDi << theArgVec[0] << anErrorMessage;
+ return 1;
+ }
+
+ Handle(Graphic3d_Camera) aCamera = ViewerTest::CurrentView()->Camera();
+
+ TCollection_AsciiString aCommand (theArgVec[1]);
+ TCollection_AsciiString aValue (theArgVec[2]);
+
+ aCommand.LowerCase();
+ aValue.LowerCase();
+
+ if (aCommand == "proj")
+ {
+ if (aValue == "ortho")
+ {
+ aCamera->SetProjectionType (Graphic3d_Camera::Projection_Orthographic);
+ }
+ else if (aValue == "persp")
+ {
+ aCamera->SetProjectionType (Graphic3d_Camera::Projection_Perspective);
+ }
+ else if (aValue == "left")
+ {
+ aCamera->SetProjectionType (Graphic3d_Camera::Projection_MonoLeftEye);
+ }
+ else if (aValue == "right")
+ {
+ aCamera->SetProjectionType (Graphic3d_Camera::Projection_MonoRightEye);
+ }
+ else if (aValue == "stereo")
+ {
+ aCamera->SetProjectionType (Graphic3d_Camera::Projection_Stereo);
+ }
+ else
+ {
+ theDi << theArgVec[0] << anErrorMessage;
+ return 1;
+ }
+
+ ViewerTest::CurrentView()->ZFitAll();
+ }
+ else if (aCommand == "dist")
+ {
+ aCamera->SetDistance (aValue.RealValue());
+ ViewerTest::CurrentView()->ZFitAll();
+ }
+ else if (aCommand == "iod")
+ {
+ aCamera->SetIOD (aCamera->GetIODType(), aValue.RealValue());
+ }
+ else if (aCommand == "zfocus")
+ {
+ aCamera->SetZFocus (aCamera->ZFocusType(), aValue.RealValue());
+ }
+ else if (aCommand == "fov")
+ {
+ aCamera->SetFOVy (aValue.RealValue());
+ }
+ else if (aCommand == "zfocustype")
+ {
+ if (aValue == "absolute")
+ {
+ aCamera->SetZFocus (Graphic3d_Camera::FocusType_Absolute, aCamera->ZFocus());
+ }
+ else if (aValue == "relative")
+ {
+ aCamera->SetZFocus (Graphic3d_Camera::FocusType_Relative, aCamera->ZFocus());
+ }
+ else
+ {
+ theDi << theArgVec[0] << anErrorMessage;
+ return 1;
+ }
+ }
+ else if (aCommand == "iodtype")
+ {
+ if (aValue == "absolute")
+ {
+ aCamera->SetIOD (Graphic3d_Camera::IODType_Absolute, aCamera->IOD());
+ }
+ else if (aValue == "relative")
+ {
+ aCamera->SetIOD (Graphic3d_Camera::IODType_Relative, aCamera->IOD());
+ }
+ else
+ {
+ theDi << theArgVec[0] << anErrorMessage;
+ return 1;
+ }
+ }
+ else
+ {
+ theDi << theArgVec[0] << anErrorMessage;
+ return 1;
+ }
+
+ ViewerTest::CurrentView()->Redraw();
+
+ return 0;
+}
+
+//==============================================================================
+//function : VStereo
+//purpose :
+//==============================================================================
+
+static int VStereo (Draw_Interpretor& theDI,
+ Standard_Integer theArgNb,
+ const char** theArgVec)
+{
+ if (theArgNb < 2)
+ {
+ Handle(V3d_View) aView = ViewerTest::CurrentView();
+ if (aView.IsNull())
+ {
+ std::cerr << "No active view. Please call vinit.\n";
+ return 0;
+ }
+
+ Standard_Boolean isActive = ViewerTest_myDefaultCaps.contextStereo;
+ theDI << "Stereo " << (isActive ? "ON" : "OFF") << "\n";
+ return 0;
+ }
+
+ ViewerTest_myDefaultCaps.contextStereo = Draw::Atoi (theArgVec[1]) != 0;
+ return 0;
+}
+
//===============================================================================================
//function : VDefaults
//purpose :
"vgraduatedtrihedron : 1/0 (display/erase) [Xname Yname Zname [Font [isMultibyte]]]",
__FILE__,VGraduatedTrihedron,group);
theCommands.Add("vprintview" ,
- "vprintview : width height filename [algo=0] : Test print algorithm: algo = 0 - stretch, algo = 1 - tile",
+ "vprintview : width height filename [algo=0] [tile_width tile_height] : Test print algorithm: algo = 0 - stretch, algo = 1 - tile",
__FILE__,VPrintView,group);
theCommands.Add("vzlayer",
"vzlayer : add/del/get [id] : Z layer operations in v3d viewer: add new z layer, delete z layer, get z layer ids",
theCommands.Add ("vvbo",
"vvbo [{0|1}] : turn VBO usage On/Off; affects only newly displayed objects",
__FILE__, VVbo, group);
+ theCommands.Add ("vstereo",
+ "\nvstereo [{0|1}] : turn stereo usage On/Off; affects only newly displayed objects",
+ __FILE__, VStereo, group);
theCommands.Add ("vcaps",
"vcaps [vbo={0|1}] [sprites={0|1}] [soft={0|1}] : modify particular graphic driver options",
__FILE__, VCaps, group);
__FILE__,VZClipping,group);
theCommands.Add ("vnbselected",
"vnbselected", __FILE__, VNbSelected, group);
+ theCommands.Add ("vchangecamera",
+ " changes camera parameters \n"
+ "- vchangecamera [param_type] [value]\n"
+ "- vchangecamera proj {ortho/persp/left/right/stereo}\n"
+ " Projection type including left and right stereo parts.\n"
+ "- vchangecamera dist [real]\n"
+ " Sets distance from target point to camera eye (moving eye).\n"
+ "- vchangecamera iod [real]\n"
+ " Intraocular distance value.\n"
+ "- vchangecamera zfocus [real]\n"
+ " Stereographic focus value.\n"
+ "- vchangecamera fov [real]\n"
+ " Field Of View value (in degrees).\n"
+ "- vchangecamera zfocustype {absolute/relative}\n"
+ " Stereographic focus definition type (absolute value or coefficient).\n"
+ "- vchangecamera iodtype {absolute/relative}\n"
+ " Intraocular distance definition type (absolute value or coefficient).\n",
+ __FILE__, VChangeCamera, group);
+ theCommands.Add ("vautozfit", "command to enable or disable automatic z-range adjusting\n"
+ " vautozfit [1|0]",
+ __FILE__,VAutoZFit, group);
+ theCommands.Add ("vzrange", "command to manually access znear and zfar values\n"
+ " vzrange - without parameters shows current values\n"
+ " vzrange [znear] [zfar] - applies provided values to view",
+ __FILE__,VZRange, group);
theCommands.Add("vantialiasing",
"vantialiasing 1|0",
__FILE__,VAntialiasing,group);
---Purpose: 3D Visualiser
---Category: The classes
- class ViewMapping;
- ---Purpose: This class describes a projection and a system of
- -- coordinates called NPC.(Normalized Projection Coordinates)
- ---Category: The classes
-
- class ViewOrientation;
- ---Purpose: This class describes the manner in which the
- -- observer looks at the visualised scene.
- -- It defines a coordinates system called VRC
- -- (View Reference Coordinates) with 3 axes U,V,N
- ---Category: The classes
-
class TransientManager;
---Purpose: 3D Transient Visualiser
---Category: The classes
Structure from Graphic3d,
SequenceOfStructure from Graphic3d,
MapOfStructure from Graphic3d,
+ Camera_Handle from Graphic3d,
ContextView from Visual3d,
Layer from Visual3d,
Light from Visual3d,
SetOfLight from Visual3d,
TypeOfAnswer from Visual3d,
- ViewMapping from Visual3d,
- ViewOrientation from Visual3d,
ViewManager from Visual3d,
ViewManagerPtr from Visual3d,
---Purpose: Creates a view in the viewer <AManager> with a default
-- orientation and a default mapping.
- Create ( AManager : mutable ViewManager from Visual3d;
- VO : ViewOrientation from Visual3d;
- VM : ViewMapping from Visual3d;
- CTX : ContextView from Visual3d )
- returns mutable View from Visual3d;
- ---Level: Public
- ---Purpose: Creates a view in the viewer <AManager> with the orientation
- -- <VO>, the mapping <VM>, and the context<CTX>.
-
---------------------------------------------------
-- Category: Methods to modify the class definition
---------------------------------------------------
-- Warning: Raises TransformError if the matrix isn't a 4x4 matrix.
raises TransformError from Visual3d is static;
- SetViewMapping ( me : mutable;
- VM : ViewMapping from Visual3d )
- is static;
- ---Level: Public
- ---Purpose: Modifies the mapping of the view <me>.
- ---Category: Methods to modify the class definition
-
SetViewMappingDefault ( me : mutable )
is static;
---Level: Public
-- done by the ViewmappingReset method.
---Category: Methods to modify the class definition
- SetViewOrientation ( me : mutable;
- VO : ViewOrientation from Visual3d )
- is static;
- ---Level: Public
- ---Purpose: Modifies the orientation of <me>.
- ---Category: Methods to modify the class definition
-
SetViewOrientationDefault ( me : mutable )
is static;
---Level: Public
---Purpose: Returns the coordinates of the projection of the
-- 3d coordinates <AX>, <AY>, <AZ>.
- Transform ( me )
- returns Array2OfReal from TColStd
- is static;
- ---Level: Public
- ---Purpose: Returns the transformation associated to the view <me>
- ---C++: return const &
-
- ViewMapping ( me )
- returns ViewMapping from Visual3d
- is static;
- ---Level: Public
- ---Purpose: Returns the current mapping of the view <me>.
-
- ViewMappingDefault ( me )
- returns ViewMapping from Visual3d
- is static;
- ---Level: Public
- ---Purpose: Returns the current reset mapping of the view <me>.
+ DefaultCamera (me)
+ returns Camera_Handle from Graphic3d
+ is static;
+ ---Level: Public
+ ---Purpose: @return the default camera of <me>.
+ ---C++: return const &
- ViewOrientation ( me )
- returns ViewOrientation from Visual3d
- is static;
- ---Level: Public
- ---Purpose: Returns the current orientation of the view <me>.
+ Camera (me)
+ returns Camera_Handle from Graphic3d
+ is static;
+ ---Level: Public
+ ---Purpose: @return the camera of <me>.
+ ---C++: return const &
- ViewOrientationDefault ( me )
- returns ViewOrientation from Visual3d
- is static;
- ---Level: Public
- ---Purpose: Returns the current reset orientation of the view <me>.
+ SetCamera (me : mutable; theCamera : Camera_Handle from Graphic3d) is static;
+ ---Level: Public
+ ---Purpose: Set camera object to provide orientation and projection matrices
+ -- for graphic driver.
Window ( me )
returns Window from Aspect
-- displayed in the view <me>.
---Category: Private methods
- MatrixOfMapping ( me : mutable )
- returns Array2OfReal from TColStd
- is static; -- private;
- ---C++: return const &
- ---Level: Internal
- ---Purpose: Returns the current matrix of mapping of the view <me>.
- -- Warning: Stores the current matrix of mapping.
-
- MatrixOfOrientation ( me : mutable )
- returns Array2OfReal from TColStd
- is static; -- private;
- ---C++: return const &
- ---Level: Internal
- ---Purpose: Returns the current matrix of orientation of the view <me>.
- -- Warning: Stores the current matrix of orientation.
-
SetRatio ( me : mutable )
is static private;
---Level: Internal
-- Reminder : A view is defined by:
-- - a ViewManager
-- - a ContextView
--- - a ViewMapping
--- - a ViewOrientation
---
-- the associated C structure
MyCView : CView from Graphic3d;
-- the context of the view : Aliasing, Depth-Cueing, Lights ...
MyContext : ContextView from Visual3d;
- -- the current mapping of the view
- MyViewMapping : ViewMapping from Visual3d;
-
- -- the reset mapping of the view
- MyViewMappingReset : ViewMapping from Visual3d;
-
- -- the current orientation of the view
- MyViewOrientation : ViewOrientation from Visual3d;
-
- -- the reset orientation of the view
- MyViewOrientationReset : ViewOrientation from Visual3d;
-
-- the associated window
MyWindow : Window from Aspect;
- -- the transformation
- MyTransformation : Array2OfReal from TColStd;
-
- -- the matrix management
- MyMatrixOfMapping : Array2OfReal from TColStd;
- MyMatrixOfOrientation : Array2OfReal from TColStd;
-
-- association Structure_COMPUTE and Structure_Computed
MyTOCOMPUTESequence : SequenceOfStructure from Graphic3d;
MyCOMPUTEDSequence : SequenceOfStructure from Graphic3d;
MyGTrihedron : CGraduatedTrihedron from Graphic3d;
+ myDefaultCamera : Camera_Handle from Graphic3d;
+
friends
class ViewManager from Visual3d
A view is defined by :
- ViewManager
- ContextView
- - ViewMapping
- - ViewOrientation
HISTORIQUE DES MODIFICATIONS :
--------------------------------
Visual3d_View::Visual3d_View (const Handle(Visual3d_ViewManager)& AManager):
MyContext (),
-MyViewMapping (),
-MyViewMappingReset (),
-MyViewOrientation (),
-MyViewOrientationReset (),
-MyTransformation (0, 3, 0, 3),
-MyMatrixOfMapping (0, 3, 0, 3),
-MyMatrixOfOrientation (0, 3, 0, 3),
MyTOCOMPUTESequence (),
MyCOMPUTEDSequence (),
MyDisplayedStructure ()
{
-Standard_Integer i, j;
MyPtrViewManager = AManager.operator->();
MyCView.ViewId = int (AManager->Identification (this));
MyCView.Context.NbActiveLight = 0;
- for (i=0; i<=3; i++)
- for (j=0; j<=3; j++)
- if (i == j) MyTransformation (i, j) = 1.0;
- else MyTransformation (i, j) = 0.0;
-
-Standard_Real X, Y, Z;
-
- (MyViewOrientation.ViewReferencePoint ()).Coord (X, Y, Z);
- MyCView.Orientation.ViewReferencePoint.x = float (X);
- MyCView.Orientation.ViewReferencePoint.y = float (Y);
- MyCView.Orientation.ViewReferencePoint.z = float (Z);
- (MyViewOrientation.ViewReferencePlane ()).Coord (X, Y, Z);
- MyCView.Orientation.ViewReferencePlane.x = float (X);
- MyCView.Orientation.ViewReferencePlane.y = float (Y);
- MyCView.Orientation.ViewReferencePlane.z = float (Z);
- (MyViewOrientation.ViewReferenceUp ()).Coord (X, Y, Z);
- MyCView.Orientation.ViewReferenceUp.x = float (X);
- MyCView.Orientation.ViewReferenceUp.y = float (Y);
- MyCView.Orientation.ViewReferenceUp.z = float (Z);
-
-Standard_Real Sx, Sy, Sz;
-
- MyViewOrientation.AxialScale(Sx, Sy, Sz);
- MyCView.Orientation.ViewScaleX = float (Sx);
- MyCView.Orientation.ViewScaleY = float (Sy);
- MyCView.Orientation.ViewScaleZ = float (Sz);
-
- // NKV : 23/07/07 - Define custom MODELVIEW matrix
- MyCView.Orientation.IsCustomMatrix = 0;
- memset( (float*)MyCView.Orientation.ModelViewMatrix, 0, 16*sizeof( float ) );
- MyCView.Orientation.ModelViewMatrix[0][0] =
- MyCView.Orientation.ModelViewMatrix[1][1] =
- MyCView.Orientation.ModelViewMatrix[2][2] =
- MyCView.Orientation.ModelViewMatrix[3][3] = 1.;
- //
-
-Standard_Real um, vm, uM, vM;
-
- MyCView.Mapping.Projection = int (MyViewMapping.Projection ());
- (MyViewMapping.ProjectionReferencePoint ()).Coord (X, Y, Z);
- MyCView.Mapping.ProjectionReferencePoint.x = float (X);
- MyCView.Mapping.ProjectionReferencePoint.y = float (Y);
- MyCView.Mapping.ProjectionReferencePoint.z = float (Z);
- MyCView.Mapping.ViewPlaneDistance =
- float (MyViewMapping.ViewPlaneDistance ());
- MyCView.Mapping.BackPlaneDistance =
- float (MyViewMapping.BackPlaneDistance ());
- MyCView.Mapping.FrontPlaneDistance =
- float (MyViewMapping.FrontPlaneDistance ());
- MyViewMapping.WindowLimit (um, vm, uM, vM);
- MyCView.Mapping.WindowLimit.um = float (um);
- MyCView.Mapping.WindowLimit.vm = float (vm);
- MyCView.Mapping.WindowLimit.uM = float (uM);
- MyCView.Mapping.WindowLimit.vM = float (vM);
-
- // NKV : 23/07/07 - Define custom MODELVIEW matrix
- MyCView.Mapping.IsCustomMatrix = 0;
- memset( (float*)MyCView.Mapping.ProjectionMatrix, 0, 16*sizeof( float ) );
- MyCView.Mapping.ProjectionMatrix[0][0] =
- MyCView.Mapping.ProjectionMatrix[1][1] =
- MyCView.Mapping.ProjectionMatrix[2][2] =
- MyCView.Mapping.ProjectionMatrix[3][3] = 1.;
- //
-
MyCView.Context.ZBufferActivity = -1;
- MyMatOfMapIsEvaluated = Standard_False;
- MyMatOfOriIsEvaluated = Standard_False;
-
IsInitialized = Standard_False;
ComputedModeIsActive = Standard_False;
MyCView.Backfacing = 0;
}
-Visual3d_View::Visual3d_View (const Handle(Visual3d_ViewManager)& AManager, const Visual3d_ViewOrientation& VO, const Visual3d_ViewMapping& VM, const Visual3d_ContextView& CTX):
-MyTransformation (0, 3, 0, 3),
-MyMatrixOfMapping (0, 3, 0, 3),
-MyMatrixOfOrientation (0, 3, 0, 3),
-MyTOCOMPUTESequence (),
-MyCOMPUTEDSequence (),
-MyDisplayedStructure ()
-{
-Standard_Integer i, j;
-
- MyPtrViewManager = AManager.operator->();
- MyViewOrientation = VO;
- MyViewMapping = VM;
- MyContext = CTX;
- MyViewOrientationReset = VO;
- MyViewMappingReset = VM;
-
- MyCView.ViewId = int (AManager->Identification (this));
- MyCView.Active = 0;
- MyCView.IsDeleted = 0;
-
- MyCView.WsId = -1;
- MyCView.DefWindow.IsDefined = 0;
-
- MyCView.Context.NbActiveLight = 0;
-
- for (i=0; i<=3; i++)
- for (j=0; j<=3; j++)
- if (i == j) MyTransformation (i, j) = 1.0;
- else MyTransformation (i, j) = 0.0;
-
-Standard_Real X, Y, Z;
-
- (MyViewOrientation.ViewReferencePoint ()).Coord (X, Y, Z);
- MyCView.Orientation.ViewReferencePoint.x = float (X);
- MyCView.Orientation.ViewReferencePoint.y = float (Y);
- MyCView.Orientation.ViewReferencePoint.z = float (Z);
- (MyViewOrientation.ViewReferencePlane ()).Coord (X, Y, Z);
- MyCView.Orientation.ViewReferencePlane.x = float (X);
- MyCView.Orientation.ViewReferencePlane.y = float (Y);
- MyCView.Orientation.ViewReferencePlane.z = float (Z);
- (MyViewOrientation.ViewReferenceUp ()).Coord (X, Y, Z);
- MyCView.Orientation.ViewReferenceUp.x = float (X);
- MyCView.Orientation.ViewReferenceUp.y = float (Y);
- MyCView.Orientation.ViewReferenceUp.z = float (Z);
-
-Standard_Real Sx, Sy, Sz;
-
- MyViewOrientation.AxialScale(Sx, Sy, Sz);
- MyCView.Orientation.ViewScaleX = float (Sx);
- MyCView.Orientation.ViewScaleY = float (Sy);
- MyCView.Orientation.ViewScaleZ = float (Sz);
-
- // NKV : 23/07/07 - Define custom MODELVIEW matrix
- if (MyViewOrientation.IsCustomMatrix()) {
- MyCView.Orientation.IsCustomMatrix = 1;
- for ( i = 0; i < 4; i++)
- for ( j = 0; j < 4; j++)
- MyCView.Orientation.ModelViewMatrix[i][j] =
- (Standard_ShortReal)MyViewOrientation.MyModelViewMatrix->Value(i,j);
- }
- else {
- MyCView.Orientation.IsCustomMatrix = 0;
- memset( (float*)MyCView.Orientation.ModelViewMatrix, 0, 16*sizeof( float ) );
- MyCView.Orientation.ModelViewMatrix[0][0] =
- MyCView.Orientation.ModelViewMatrix[1][1] =
- MyCView.Orientation.ModelViewMatrix[2][2] =
- MyCView.Orientation.ModelViewMatrix[3][3] = 1.;
- }
- //
-
-Standard_Real um, vm, uM, vM;
-
- MyCView.Mapping.Projection = int (MyViewMapping.Projection ());
- (MyViewMapping.ProjectionReferencePoint ()).Coord (X, Y, Z);
- MyCView.Mapping.ProjectionReferencePoint.x = float (X);
- MyCView.Mapping.ProjectionReferencePoint.y = float (Y);
- MyCView.Mapping.ProjectionReferencePoint.z = float (Z);
- MyCView.Mapping.ViewPlaneDistance =
- float (MyViewMapping.ViewPlaneDistance ());
- MyCView.Mapping.BackPlaneDistance =
- float (MyViewMapping.BackPlaneDistance ());
- MyCView.Mapping.FrontPlaneDistance =
- float (MyViewMapping.FrontPlaneDistance ());
- MyViewMapping.WindowLimit (um, vm, uM, vM);
- MyCView.Mapping.WindowLimit.um = float (um);
- MyCView.Mapping.WindowLimit.vm = float (vm);
- MyCView.Mapping.WindowLimit.uM = float (uM);
- MyCView.Mapping.WindowLimit.vM = float (vM);
-
- // NKV : 23/07/07 - Define custom MODELVIEW matrix
- if (MyViewMapping.IsCustomMatrix()) {
- MyCView.Mapping.IsCustomMatrix = 1;
- for ( i = 0; i < 4; i++)
- for ( j = 0; j < 4; j++)
- MyCView.Mapping.ProjectionMatrix[i][j] =
- (Standard_ShortReal)MyViewMapping.MyProjectionMatrix->Value(i,j);
- }
- else {
- MyCView.Mapping.IsCustomMatrix = 0;
- memset( (float*)MyCView.Mapping.ProjectionMatrix, 0, 16*sizeof( float ) );
- MyCView.Mapping.ProjectionMatrix[0][0] =
- MyCView.Mapping.ProjectionMatrix[1][1] =
- MyCView.Mapping.ProjectionMatrix[2][2] =
- MyCView.Mapping.ProjectionMatrix[3][3] = 1.;
- }
- //
-
- MyCView.Context.ZBufferActivity = -1;
-
- MyMatOfMapIsEvaluated = Standard_False;
- MyMatOfOriIsEvaluated = Standard_False;
-
- IsInitialized = Standard_False;
- ComputedModeIsActive = Standard_False;
-
- MyCView.ptrUnderLayer = 0;
- MyCView.ptrOverLayer = 0;
- MyCView.GContext = 0;
- MyCView.GDisplayCB = 0;
- MyCView.GClientData = 0;
-
- MyGraphicDriver = MyViewManager->GraphicDriver();
-
-}
-
-//-Destructors
-
//-Methods, in order
// RIC120302
void Visual3d_View::SetWindow (const Handle(Aspect_Window)& AWindow,
void Visual3d_View::SetWindow (const Handle(Aspect_Window)& theWindow)
{
+ if (IsDeleted ()) return;
- if (IsDeleted ()) return;
-
- if (IsDefined ())
- Visual3d_ViewDefinitionError::Raise ("Window already defined");
-
- MyWindow = theWindow;
- MyCView.WsId = MyCView.ViewId;
- MyCView.DefWindow.IsDefined = 1;
+ if (IsDefined ())
+ {
+ Visual3d_ViewDefinitionError::Raise ("Window already defined");
+ }
+ MyWindow = theWindow;
+ MyCView.WsId = MyCView.ViewId;
+ MyCView.DefWindow.IsDefined = 1;
#if (defined(_WIN32) || defined(__WIN32__))
const Handle(WNT_Window) aWin = Handle(WNT_Window)::DownCast (theWindow);
MyCView.DefWindow.XWindow = (HWND )(aWin->HWindow());
MyCView.IsDeleted = 1;
MyCView.DefWindow.IsDefined = 0;
- MyMatOfMapIsEvaluated = Standard_False;
- MyMatOfOriIsEvaluated = Standard_False;
-
IsInitialized = Standard_False;
MyWindow.Nullify ();
}
-void Visual3d_View::SetRatio () {
-
- if (IsDeleted ()) return;
-
-Aspect_TypeOfUpdate UpdateMode = MyViewManager->UpdateMode ();
- MyViewManager->SetUpdateMode (Aspect_TOU_WAIT);
-
-Standard_Real Umin, Vmin, Umax, Vmax;
-Standard_Integer Dxw, Dyw;
-Standard_Real Dxv, Dyv;
-Standard_Real Xc, Yc;
-Standard_Real Rap;
-
- Rap = 0. ;
- MyWindow->Size (Dxw, Dyw);
- MyViewMapping.WindowLimit(Umin,Vmin,Umax,Vmax) ;
- Xc = (Umin + Umax)/2. ; Yc = (Vmin + Vmax)/2. ;
- Dxv = Umax - Umin ; Dyv = Vmax - Vmin ;
- if( Dxw > 0 && Dyw > 0 ) Rap = (Standard_Real)Dyw/(Standard_Real)Dxw ;
- if( Rap > 0.0 ) {
-
- if( Dxv <= Dyv )
- {
- if (Rap <= 1.0)
- {
- Dyv = Dxv;
- Dxv = Dxv/Rap;
- }
- else
- {
- Dxv = Dxv;
- Dyv = Dxv*Rap;
- }
- }
- else
- {
- if (Rap <= 1.0)
- {
- Dxv = Dyv/Rap;
- Dyv = Dyv;
- }
- else
- {
- Dxv = Dyv;
- Dyv = Dyv*Rap;
- }
- }
-
- Umin = Xc - Dxv/2. ; Vmin = Yc - Dyv/2. ;
- Umax = Xc + Dxv/2. ; Vmax = Yc + Dyv/2. ;
-
- MyViewMapping.SetWindowLimit(Umin,Vmin,Umax,Vmax) ;
-
- // Update before SetViewMapping.
+void Visual3d_View::SetRatio()
+{
+ if (IsDeleted())
+ {
+ return;
+ }
- MyCView.DefWindow.dx = float( Dxw );
- MyCView.DefWindow.dy = float( Dyw );
+ Aspect_TypeOfUpdate UpdateMode = MyViewManager->UpdateMode();
- SetViewMapping (MyViewMapping);
-// SetViewMappingDefault ();
- // FMN+ Update Ratio for MyViewMappingReset
+ MyViewManager->SetUpdateMode (Aspect_TOU_WAIT);
- MyViewMappingReset.WindowLimit(Umin,Vmin,Umax,Vmax) ;
- Xc = (Umin + Umax)/2. ; Yc = (Vmin + Vmax)/2. ;
- Dxv = Umax - Umin ; Dyv = Vmax - Vmin ;
+ Standard_Integer aWidth, aHeight;
- if( Dxv <= Dyv )
- {
- if (Rap <= 1.0)
- {
- Dyv = Dxv;
- Dxv = Dxv/Rap;
- }
- else
- {
- Dxv = Dxv;
- Dyv = Dxv*Rap;
- }
- }
- else
- {
- if (Rap <= 1.0)
- {
- Dxv = Dyv/Rap;
- Dyv = Dyv;
- }
- else
- {
- Dxv = Dyv;
- Dyv = Dyv*Rap;
- }
- }
+ MyWindow->Size (aWidth, aHeight);
- Umin = Xc - Dxv/2. ; Vmin = Yc - Dyv/2. ;
- Umax = Xc + Dxv/2. ; Vmax = Yc + Dyv/2. ;
+ if( aWidth > 0 && aHeight > 0 )
+ {
+ Standard_Real aRatio = (Standard_Real)aWidth / (Standard_Real)aHeight;
- MyViewMappingReset.SetWindowLimit(Umin,Vmin,Umax,Vmax) ;
+ MyCView.DefWindow.dx = Standard_ShortReal (aWidth);
+ MyCView.DefWindow.dy = Standard_ShortReal (aHeight);
- // FMN- Update Ratio for MyViewMappingReset
+ MyGraphicDriver->RatioWindow (MyCView);
- MyGraphicDriver->RatioWindow (MyCView);
- }
+ // Update camera aspect
+ Handle(Graphic3d_Camera) aCamera = MyCView.Context.Camera;
- // Force recalculation of 2 matrices.
- //
- // The current view can help to reconstruct a copied view
- // that is itself. Owing to SetWindow and SetRatio the
- // recalculation of matrices of this new view is imposed.
- MyMatOfMapIsEvaluated = Standard_False;
- MyMatOfOriIsEvaluated = Standard_False;
+ if (!aCamera.IsNull())
+ {
+ aCamera->SetAspect (aRatio);
+ }
- MyViewManager->SetUpdateMode (UpdateMode);
- if (UpdateMode == Aspect_TOU_ASAP) Update ();
+ if (!myDefaultCamera.IsNull())
+ {
+ myDefaultCamera->SetAspect (aRatio);
+ }
+ }
+ MyViewManager->SetUpdateMode (UpdateMode);
+ if (UpdateMode == Aspect_TOU_ASAP)
+ Update();
}
void Visual3d_View::UpdateLights()
}
-void Visual3d_View::SetTransform (const TColStd_Array2OfReal& AMatrix) {
-
- if (IsDeleted ()) return;
-
-Standard_Integer lr, ur, lc, uc;
-Standard_Integer i, j;
-
- // Assign the new transformation in an array [0..3][0..3]
- // Avoid problems if the has defined a matrice [1..4][1..4]
- // ou [3..6][-1..2] !!
- lr = AMatrix.LowerRow ();
- ur = AMatrix.UpperRow ();
- lc = AMatrix.LowerCol ();
- uc = AMatrix.UpperCol ();
-
- if ( (ur - lr + 1 != 4) || (uc - lc + 1 != 4) )
- Visual3d_TransformError::Raise ("Transform : not a 4x4 matrix");
-
- for (i=0; i<=3; i++)
- for (j=0; j<=3; j++)
- MyTransformation (i, j) = AMatrix (lr + i, lc + j);
-
-Graphic3d_Vector VPN;
-Graphic3d_Vertex VRP;
-Graphic3d_Vector VUP;
-Standard_Real Sx, Sy, Sz;
-
-Visual3d_ViewOrientation NewViewOrientation;
-
- VPN = MyViewOrientation.ViewReferencePlane ();
- VRP = MyViewOrientation.ViewReferencePoint ();
- VUP = MyViewOrientation.ViewReferenceUp ();
- MyViewOrientation.AxialScale(Sx, Sy, Sz);
-
- NewViewOrientation.SetViewReferencePlane
- (Graphic3d_Structure::Transforms (Transform (), VPN));
-
- NewViewOrientation.SetViewReferencePoint
- (Graphic3d_Structure::Transforms (Transform (), VRP));
-
- NewViewOrientation.SetViewReferenceUp
- (Graphic3d_Structure::Transforms (Transform (), VUP));
- NewViewOrientation.SetAxialScale(Sx, Sy, Sz);
-
- SetViewOrientation (NewViewOrientation);
-
- MyMatOfOriIsEvaluated = Standard_False;
-
-}
-
-const TColStd_Array2OfReal& Visual3d_View::Transform () const {
-
- return (MyTransformation);
-
-}
-
-void Visual3d_View::SetViewOrientation (const Visual3d_ViewOrientation& VO) {
-
- if (IsDeleted ()) return;
-
- MyViewOrientation = VO;
-
- Standard_Real X, Y, Z;
- // Tests on modification of parameters.
- Standard_Boolean VUPIsModified = Standard_False;
- Standard_Boolean VRPIsModified = Standard_False;
- Standard_Boolean VRUIsModified = Standard_False;
- Standard_Boolean ScaleIsModified = Standard_False;
- Standard_Boolean CustomIsModified = Standard_False;
-
- (MyViewOrientation.ViewReferencePoint ()).Coord (X, Y, Z);
- VUPIsModified =
- MyCView.Orientation.ViewReferencePoint.x != float (X)
- || MyCView.Orientation.ViewReferencePoint.y != float (Y)
- || MyCView.Orientation.ViewReferencePoint.z != float (Z);
- MyCView.Orientation.ViewReferencePoint.x = float (X);
- MyCView.Orientation.ViewReferencePoint.y = float (Y);
- MyCView.Orientation.ViewReferencePoint.z = float (Z);
-
- (MyViewOrientation.ViewReferencePlane ()).Coord (X, Y, Z);
- VRPIsModified =
- MyCView.Orientation.ViewReferencePlane.x != float (X)
- || MyCView.Orientation.ViewReferencePlane.y != float (Y)
- || MyCView.Orientation.ViewReferencePlane.z != float (Z);
- MyCView.Orientation.ViewReferencePlane.x = float (X);
- MyCView.Orientation.ViewReferencePlane.y = float (Y);
- MyCView.Orientation.ViewReferencePlane.z = float (Z);
-
- (MyViewOrientation.ViewReferenceUp ()).Coord (X, Y, Z);
- VRUIsModified =
- MyCView.Orientation.ViewReferenceUp.x != float (X)
- || MyCView.Orientation.ViewReferenceUp.y != float (Y)
- || MyCView.Orientation.ViewReferenceUp.z != float (Z);
- MyCView.Orientation.ViewReferenceUp.x = float (X);
- MyCView.Orientation.ViewReferenceUp.y = float (Y);
- MyCView.Orientation.ViewReferenceUp.z = float (Z);
-
- MyViewOrientation.AxialScale(X, Y, Z);
- ScaleIsModified =
- MyCView.Orientation.ViewScaleX != float (X)
- || MyCView.Orientation.ViewScaleY != float (Y)
- || MyCView.Orientation.ViewScaleZ != float (Z);
- MyCView.Orientation.ViewScaleX = float (X);
- MyCView.Orientation.ViewScaleY = float (Y);
- MyCView.Orientation.ViewScaleZ = float (Z);
-
- CustomIsModified =
- (MyCView.Orientation.IsCustomMatrix != MyViewOrientation.IsCustomMatrix());
- MyCView.Orientation.IsCustomMatrix = MyViewOrientation.IsCustomMatrix();
- if ( MyViewOrientation.IsCustomMatrix() ) {
- Standard_Integer i, j;
- for (i = 0; i < 4; i++)
- for (j = 0; j < 4; j++) {
- if (!CustomIsModified) CustomIsModified =
- MyCView.Orientation.ModelViewMatrix[i][j] != MyViewOrientation.MyModelViewMatrix->Value(i,j);
- }
- }
-
-#ifdef TRACE_TRSF
- cout << "Visual3d_View::SetViewOrientation\n";
- if (VUPIsModified || VRPIsModified || VRUIsModified || ScaleIsModified || CustomIsModified)
- cout << "VUPIsModified : " << VUPIsModified
- << ", VRPIsModified : " << VRPIsModified
- << ", VRUIsModified : " << VRUIsModified
- << ", CustomIsModified : " << CustomIsModified
- << ", ScaleIsModified : " << ScaleIsModified << "\n" << flush;
- else
- cout << "no modification\n" << flush;
-#endif
-
- // restart if one of parameters is modified
- if (!IsInitialized || VUPIsModified || VRPIsModified
- || VRUIsModified || ScaleIsModified || CustomIsModified) {
-
- MyMatOfOriIsEvaluated = !VUPIsModified && !VRPIsModified
- && !VRUIsModified && !ScaleIsModified;
-
- if (! IsDefined ()) return;
-
- Standard_Boolean AWait = Standard_False; // => immediate update
- MyGraphicDriver->ViewOrientation (MyCView, AWait);
- IsInitialized = Standard_True;
- Compute ();
-
- if (MyViewManager->UpdateMode () == Aspect_TOU_ASAP) Update ();
- }
-
-}
-
-Visual3d_ViewOrientation Visual3d_View::ViewOrientation () const {
-
- return (MyViewOrientation);
-
-}
-
-Visual3d_ViewOrientation Visual3d_View::ViewOrientationDefault () const {
-
- return (MyViewOrientationReset);
-
-}
-
-void Visual3d_View::SetViewOrientationDefault () {
-
- MyViewOrientationReset.Assign (MyViewOrientation);
-
-}
-
-void Visual3d_View::ViewOrientationReset () {
-
- if (IsDeleted ()) return;
-
- MyViewOrientation = MyViewOrientationReset;
-
- Standard_Real X, Y, Z;
-
- // Tests on modification of parameters.
- Standard_Boolean VUPIsModified = Standard_False;
- Standard_Boolean VRPIsModified = Standard_False;
- Standard_Boolean VRUIsModified = Standard_False;
- Standard_Boolean ScaleIsModified = Standard_False;
- Standard_Boolean CustomIsModified = Standard_False;
-
- (MyViewOrientation.ViewReferencePoint ()).Coord (X, Y, Z);
- VUPIsModified =
- MyCView.Orientation.ViewReferencePoint.x != float (X)
- || MyCView.Orientation.ViewReferencePoint.y != float (Y)
- || MyCView.Orientation.ViewReferencePoint.z != float (Z);
- MyCView.Orientation.ViewReferencePoint.x = float (X);
- MyCView.Orientation.ViewReferencePoint.y = float (Y);
- MyCView.Orientation.ViewReferencePoint.z = float (Z);
-
- (MyViewOrientation.ViewReferencePlane ()).Coord (X, Y, Z);
- VRPIsModified =
- MyCView.Orientation.ViewReferencePlane.x != float (X)
- || MyCView.Orientation.ViewReferencePlane.y != float (Y)
- || MyCView.Orientation.ViewReferencePlane.z != float (Z);
- MyCView.Orientation.ViewReferencePlane.x = float (X);
- MyCView.Orientation.ViewReferencePlane.y = float (Y);
- MyCView.Orientation.ViewReferencePlane.z = float (Z);
-
- (MyViewOrientation.ViewReferenceUp ()).Coord (X, Y, Z);
- VRUIsModified =
- MyCView.Orientation.ViewReferenceUp.x != float (X)
- || MyCView.Orientation.ViewReferenceUp.y != float (Y)
- || MyCView.Orientation.ViewReferenceUp.z != float (Z);
- MyCView.Orientation.ViewReferenceUp.x = float (X);
- MyCView.Orientation.ViewReferenceUp.y = float (Y);
- MyCView.Orientation.ViewReferenceUp.z = float (Z);
-
- MyViewOrientation.AxialScale(X, Y, Z);
- ScaleIsModified =
- MyCView.Orientation.ViewScaleX != float (X)
- || MyCView.Orientation.ViewScaleY != float (Y)
- || MyCView.Orientation.ViewScaleZ != float (Z);
- MyCView.Orientation.ViewScaleX = float (X);
- MyCView.Orientation.ViewScaleY = float (Y);
- MyCView.Orientation.ViewScaleZ = float (Z);
-
- CustomIsModified =
- MyCView.Orientation.IsCustomMatrix != MyViewOrientation.IsCustomMatrix();
- MyCView.Orientation.IsCustomMatrix = MyViewOrientation.IsCustomMatrix();
- if ( MyViewOrientation.IsCustomMatrix() ) {
- Standard_Integer i, j;
- for (i = 0; i < 4; i++)
- for (j = 0; j < 4; j++) {
- if (!CustomIsModified) CustomIsModified =
- MyCView.Orientation.ModelViewMatrix[i][j] != MyViewOrientation.MyModelViewMatrix->Value(i,j);
- }
- }
-
-
-#ifdef TRACE_TRSF
- cout << "Visual3d_View::ViewOrientationReset\n";
- if (VUPIsModified || VRPIsModified || VRUIsModified || ScaleIsModified || CustomIsModified)
- cout << "VUPIsModified : " << VUPIsModified
- << ", VRPIsModified : " << VRPIsModified
- << ", VRUIsModified : " << VRUIsModified
- << ", CustomIsModified : " << CustomIsModified
- << ", ScaleIsModified : " << ScaleIsModified << "\n" << flush;
- else
- cout << "no modification\n" << flush;
-#endif
-
- // Restart if one of parameters is modified
- if (!IsInitialized || VUPIsModified || VRPIsModified
- || VRUIsModified || ScaleIsModified || CustomIsModified) {
-
- MyMatOfOriIsEvaluated = !VUPIsModified && !VRPIsModified
- && !VRUIsModified && !ScaleIsModified;
-
- if (! IsDefined ()) return;
-
- Standard_Boolean AWait = Standard_False; // => immediate update
- MyGraphicDriver->ViewOrientation (MyCView, AWait);
- IsInitialized = Standard_True;
- Compute ();
-
- if (MyViewManager->UpdateMode () == Aspect_TOU_ASAP) Update ();
- }
+// =======================================================================
+// function : DefaultCamera
+// purpose :
+// =======================================================================
+const Handle(Graphic3d_Camera)& Visual3d_View::DefaultCamera() const
+{
+ return myDefaultCamera;
}
-void Visual3d_View::SetViewMapping (const Visual3d_ViewMapping& VM) {
-
- if (IsDeleted ()) return;
-
-Visual3d_TypeOfProjection OldType = MyViewMapping.Projection ();
-Visual3d_TypeOfProjection NewType = VM.Projection ();
-
- MyViewMapping = VM;
-
-Standard_Real X, Y, Z;
-Standard_Real um, vm, uM, vM;
-
- MyCView.Mapping.Projection = int (MyViewMapping.Projection ());
- (MyViewMapping.ProjectionReferencePoint ()).Coord (X, Y, Z);
- MyCView.Mapping.ProjectionReferencePoint.x = float (X);
- MyCView.Mapping.ProjectionReferencePoint.y = float (Y);
- MyCView.Mapping.ProjectionReferencePoint.z = float (Z);
- MyCView.Mapping.ViewPlaneDistance =
- float (MyViewMapping.ViewPlaneDistance ());
- MyCView.Mapping.BackPlaneDistance =
- float (MyViewMapping.BackPlaneDistance ());
- MyCView.Mapping.FrontPlaneDistance =
- float (MyViewMapping.FrontPlaneDistance ());
- MyViewMapping.WindowLimit (um, vm, uM, vM);
- MyCView.Mapping.WindowLimit.um = float (um);
- MyCView.Mapping.WindowLimit.vm = float (vm);
- MyCView.Mapping.WindowLimit.uM = float (uM);
- MyCView.Mapping.WindowLimit.vM = float (vM);
-
- MyCView.Mapping.IsCustomMatrix = MyViewMapping.IsCustomMatrix();
- if (MyViewMapping.IsCustomMatrix()) {
- Standard_Integer i, j;
- for (i = 0; i < 4; i++)
- for (j = 0; j < 4; j++)
- MyCView.Mapping.ProjectionMatrix[i][j] =
- (Standard_ShortReal)MyViewMapping.MyProjectionMatrix->Value(i,j);
- }
-
- MyMatOfMapIsEvaluated = Standard_False;
+// =======================================================================
+// function : Camera
+// purpose :
+// =======================================================================
+const Handle(Graphic3d_Camera)& Visual3d_View::Camera() const{ return MyCView.Context.Camera;}
- if (! IsDefined ()) return;
-
-Standard_Boolean AWait = Standard_False; // => immediate update
- MyGraphicDriver->ViewMapping (MyCView, AWait);
-
- // Passage Parallele/Perspective
- if (OldType != NewType)
- Compute ();
+// =======================================================================
+// function : SetCamera
+// purpose :
+// =======================================================================
+void Visual3d_View::SetCamera (const Handle(Graphic3d_Camera)& theCamera)
+{
+ MyCView.Context.Camera = theCamera;
- if (MyViewManager->UpdateMode () == Aspect_TOU_ASAP) Update ();
+ MyGraphicDriver->SetCamera (MyCView);
+ if (MyViewManager->UpdateMode() == Aspect_TOU_ASAP)
+ {
+ Update();
+ }
}
-Visual3d_ViewMapping Visual3d_View::ViewMapping () const {
-
- return (MyViewMapping);
+// =======================================================================
+// function : SetViewOrientationDefault
+// purpose :
+// =======================================================================
+void Visual3d_View::SetViewOrientationDefault ()
+{
+ if (myDefaultCamera.IsNull())
+ {
+ myDefaultCamera = new Graphic3d_Camera();
+ }
+ myDefaultCamera->CopyOrientationData (MyCView.Context.Camera);
}
-Visual3d_ViewMapping Visual3d_View::ViewMappingDefault () const {
+// =======================================================================
+// function : ViewOrientationReset
+// purpose :
+// =======================================================================
+void Visual3d_View::ViewOrientationReset ()
+{
+ if (IsDeleted())
+ {
+ return;
+ }
- return (MyViewMappingReset);
+ if (!myDefaultCamera.IsNull())
+ {
+ MyCView.Context.Camera->CopyOrientationData (myDefaultCamera);
+ }
+ if (MyViewManager->UpdateMode() == Aspect_TOU_ASAP)
+ {
+ Update();
+ }
}
-void Visual3d_View::SetViewMappingDefault () {
-
- MyViewMappingReset.Assign (MyViewMapping);
-
+// =======================================================================
+// function : SetViewMappingDefault
+// purpose :
+// =======================================================================
+void Visual3d_View::SetViewMappingDefault()
+{
+ if (myDefaultCamera.IsNull())
+ {
+ myDefaultCamera = new Graphic3d_Camera();
+ }
+ myDefaultCamera->CopyMappingData (MyCView.Context.Camera);
}
-void Visual3d_View::ViewMappingReset () {
-
- if (IsDeleted ()) return;
-
- MyViewMapping = MyViewMappingReset;
-
-Standard_Real X, Y, Z;
-Standard_Real um, vm, uM, vM;
-
- MyCView.Mapping.Projection = int (MyViewMapping.Projection ());
- (MyViewMapping.ProjectionReferencePoint ()).Coord (X, Y, Z);
- MyCView.Mapping.ProjectionReferencePoint.x = float (X);
- MyCView.Mapping.ProjectionReferencePoint.y = float (Y);
- MyCView.Mapping.ProjectionReferencePoint.z = float (Z);
- MyCView.Mapping.ViewPlaneDistance =
- float (MyViewMapping.ViewPlaneDistance ());
- MyCView.Mapping.BackPlaneDistance =
- float (MyViewMapping.BackPlaneDistance ());
- MyCView.Mapping.FrontPlaneDistance =
- float (MyViewMapping.FrontPlaneDistance ());
- MyViewMapping.WindowLimit (um, vm, uM, vM);
- MyCView.Mapping.WindowLimit.um = float (um);
- MyCView.Mapping.WindowLimit.vm = float (vm);
- MyCView.Mapping.WindowLimit.uM = float (uM);
- MyCView.Mapping.WindowLimit.vM = float (vM);
-
- MyCView.Mapping.IsCustomMatrix = MyViewMapping.IsCustomMatrix();
- if (MyViewMapping.IsCustomMatrix()) {
- Standard_Integer i, j;
- for (i = 0; i < 4; i++)
- for (j = 0; j < 4; j++)
- MyCView.Mapping.ProjectionMatrix[i][j] =
- (Standard_ShortReal)MyViewMapping.MyProjectionMatrix->Value(i,j);
- }
-
- MyMatOfMapIsEvaluated = Standard_False;
-
- if (! IsDefined ()) return;
-
-Standard_Boolean AWait = Standard_False; // => immediate update
- MyGraphicDriver->ViewMapping (MyCView, AWait);
+// =======================================================================
+// function : ViewMappingReset
+// purpose :
+// =======================================================================
+void Visual3d_View::ViewMappingReset ()
+{
+ if (IsDeleted ())
+ {
+ return;
+ }
- if (MyViewManager->UpdateMode () == Aspect_TOU_ASAP) Update ();
+ if (!myDefaultCamera.IsNull())
+ {
+ MyCView.Context.Camera->CopyMappingData (myDefaultCamera);
+ }
+ if (MyViewManager->UpdateMode() == Aspect_TOU_ASAP)
+ {
+ Update();
+ }
}
void Visual3d_View::SetContext (const Visual3d_ContextView& CTX) {
}
-void Visual3d_View::Update () {
+void Visual3d_View::Update ()
+{
+ IsInitialized = Standard_True;
- Update (MyViewManager->UnderLayer (), MyViewManager->OverLayer ());
+ Compute ();
+ Update (MyViewManager->UnderLayer (), MyViewManager->OverLayer ());
}
void Visual3d_View::Update (const Handle(Visual3d_Layer)& AnUnderLayer, const Handle(Visual3d_Layer)& AnOverLayer) {
Iterator.More ();
Iterator.Next ()) {
- if (!Iterator.Key()->IsVisible())
- {
- continue;
- }
-
- if ( (Iterator.Key ())->IsInfinite ()){
+ if ((Iterator.Key ())->IsInfinite ()){
//XMin, YMin .... ZMax are initialized by means of infinite line data
(Iterator.Key ())->MinMaxValues (Xm, Ym, Zm, XM, YM, ZM);
if ( Xm != RealFirst() && Xm < XMin )
if (YMax < YMin) { Ym = YMin; YMin = YMax; YMax = Ym; }
if (ZMax < ZMin) { Zm = ZMin; ZMin = ZMax; ZMax = Zm; }
}
- Standard_Real Sx, Sy, Sz;
- MyViewOrientation.AxialScale(Sx, Sy, Sz);
- XMin = (Sx > 1. && XMin < RealFirst ()/Sx)?RealFirst (): XMin*Sx;
- XMax = (Sx > 1. && XMax > RealLast ()/Sx)?RealLast (): XMax*Sx;
- YMin = (Sy > 1. && YMin < RealFirst ()/Sy)?RealFirst (): YMin*Sy;
- YMax = (Sy > 1. && YMax > RealLast ()/Sy)?RealLast (): YMax*Sy;
- ZMin = (Sz > 1. && ZMin < RealFirst ()/Sz)?RealFirst (): ZMin*Sz;
- ZMax = (Sz > 1. && ZMax > RealLast ()/Sz)?RealLast (): ZMax*Sz;
}
void Visual3d_View::MinMaxValues (Standard_Real& XMin, Standard_Real& YMin, Standard_Real& XMax, Standard_Real& YMax) {
if (YMax < YMin) { Yp = YMax; YMax = YMin; YMin = Yp; }
}
-const TColStd_Array2OfReal& Visual3d_View::MatrixOfOrientation () {
-
- if (! MyMatOfOriIsEvaluated) {
- MyGraphicDriver->InquireMat
- (MyCView, MyMatrixOfOrientation, MyMatrixOfMapping);
- MyMatOfMapIsEvaluated = Standard_True;
- MyMatOfOriIsEvaluated = Standard_True;
- }
-
- return (MyMatrixOfOrientation);
-
-}
-
-const TColStd_Array2OfReal& Visual3d_View::MatrixOfMapping () {
-
- if (! MyMatOfMapIsEvaluated) {
- MyGraphicDriver->InquireMat
- (MyCView, MyMatrixOfOrientation, MyMatrixOfMapping);
- MyMatOfMapIsEvaluated = Standard_True;
- MyMatOfOriIsEvaluated = Standard_True;
- }
-
- return (MyMatrixOfMapping);
-
-}
Standard_Integer Visual3d_View::NumberOfDisplayedStructures () const {
}
-#ifdef OLD_METHOD
-void Visual3d_View::Projects (const Standard_Real AX, const Standard_Real AY, const Standard_Real AZ, Standard_Real& APX, Standard_Real& APY, Standard_Real& APZ) const {
-
-math_Vector PtDC (0,3), PtWC (0,3);
-
-// RLE method:
-// Otherwise use new on Visual3d_View (constructor+destructor)
-// as Projects is a const method or MatrixOfOrientation and
-// MatrixOfMapping is not.
-Visual3d_View * const newthis = (Visual3d_View * const) this;
- newthis->MatrixOfOrientation ();
- newthis->MatrixOfMapping ();
-
-// World Coordinate Space
- PtWC (0) = AX;
- PtWC (1) = AY;
- PtWC (2) = AZ;
- PtWC (3) = 1.0;
-
- // WCS -> View Reference Coordinate Space
- math_Vector PtVRC(0,3);
- PtVRC = MyMatrixOfOrientation.Multiplied (PtWC);
-
- // VRCS -> Normalized Projection Coordinate Space
- math_Vector PtNPC(0,3);
- PtNPC = MyMatrixOfMapping.Multiplied (PtVRC);
- for (Standard_Integer i=0; i<3; i++) PtNPC (i) = PtNPC (i) / PtNPC (3);
-
-#ifdef DEBUG
- printf("Display coordinates PtNPC: %f,%f,%f,%f\n",
- PtNPC(0),PtNPC(1),PtNPC(2),PtNPC(3));
-#endif // DEBUG
-
- Standard_Real Ratio;
-#ifdef DEBUG
- // NPCS -> Device Coordinate Space
- Standard_Real Dx = Standard_Real (MyCView.DefWindow.dx);
- Standard_Real Dy = Standard_Real (MyCView.DefWindow.dy);
-
- Ratio = Dx / Dy;
- PtDC (0) = PtNPC (0) * Dx;
- PtDC (1) = Dy - PtNPC (1) * Dy * Ratio;
-
- printf("Display coordinates : %f,%f,%f,%f\n",
- PtDC(0),PtDC(1),PtDC(2),PtDC(3));
-#endif // DEBUG
-
- // NPCS -> Window Space
-Standard_Real um, vm, uM, vM;
- MyViewMapping.WindowLimit (um, vm, uM, vM);
-
- Ratio = (uM - um) / (vM - vm);
- if (Ratio >= 1.0)
- PtNPC (1) = PtNPC (1) * Ratio;
- else
- PtNPC (0) = PtNPC (0) / Ratio;
-
-#ifdef DEBUG
- printf("Display coordinates PtNPC: %f,%f,%f,%f\n",
- PtNPC(0),PtNPC(1),PtNPC(2),PtNPC(3));
-#endif // DEBUG
-
- Standard_Real fpd = MyViewMapping.FrontPlaneDistance ();
- Standard_Real bpd = MyViewMapping.BackPlaneDistance ();
-
- /*
- * Coordinates of PtNPC are described in the space
- * [0-1]x[0-1]x[0-1].
- * It is necessary to transform x and y in the window space.
- * It is necessary to transform z in the space of back and front
- * plane, taking into account clipping planes.
- * Z clipping planes are defined between 0 and 1.
- */
-
- APX = PtNPC (0) * (uM - um) + um;
- APY = PtNPC (1) * (vM - vm) + vm;
- APZ = PtNPC (2) * (fpd - bpd) + bpd;
-
-#ifdef DEBUG
- Standard_Integer l,c;
- printf("OrientationMatrix :");
- for( l=0 ; l<4 ; l++ ) {
- printf("\n %d->",l);
- for( c=0 ; c<4 ; c++ ) {
- printf(" %f ,",MyMatrixOfOrientation(c,l));
- }
- }
- printf("\n\n");
- printf("MappingMatrix :");
- for( l=0 ; l<4 ; l++ ) {
- printf("\n %d->",l);
- for( c=0 ; c<4 ; c++ ) {
- printf(" %f ,",MyMatrixOfMapping(c,l));
- }
- }
- printf("\n\n");
- printf("World coordinates : %f,%f,%f,%f\n",
- PtWC(0),PtWC(1),PtWC(2),PtWC(3));
- printf("View coordinates : %f,%f,%f,%f\n",
- PtVRC(0),PtVRC(1),PtVRC(2),PtVRC(3));
- printf("Display coordinates : %f,%f,%f,%f\n",
- PtNPC(0),PtNPC(1),PtNPC(2),PtNPC(3));
- printf("Window limit : %f,%f,%f,%f\n",um,vm,uM,vM);
- printf("Ratio : %f\n",Ratio);
- printf("Front-plane : %f back-plane : %f\n",fpd,bpd);
- printf("Projection : %f,%f,%f\n \n",APX,APY,APZ);
-#endif
-
-}
-#endif /* OLD_METHOD */
+void Visual3d_View::Projects (const Standard_Real AX,
+ const Standard_Real AY,
+ const Standard_Real AZ,
+ Standard_Real& APX,
+ Standard_Real& APY,
+ Standard_Real& APZ)
+{
+ Handle(Graphic3d_Camera) aCamera = MyCView.Context.Camera;
-// OCC18942: This method is likely to duplicate Visual3d_ViewManager::ConvertCoord() one,
-// therefore it is necessary to consider merging the two methods or making them call the same
-// graphic driver's method after OCCT 6.3.
-void Visual3d_View::Projects (const Standard_Real AX, const Standard_Real AY, const Standard_Real AZ, Standard_Real& APX, Standard_Real& APY, Standard_Real& APZ) {
+ Standard_Real aUmin, aVMin, aUMax, aVMax;
+ Standard_Real aNear, aFar;
+ aCamera->WindowLimit (aUmin, aVMin, aUMax, aVMax);
-Standard_Real PtX, PtY, PtZ, PtT;
-Standard_Real APT;
-static Standard_Real Ratio, um, vm, uM, vM;
-static Standard_Real fpd, bpd;
+ aNear = aCamera->ZNear();
+ aFar = aCamera->ZFar();
- if (! MyMatOfOriIsEvaluated || ! MyMatOfMapIsEvaluated) {
- MyGraphicDriver->InquireMat
- (MyCView, MyMatrixOfOrientation, MyMatrixOfMapping);
- MyMatOfOriIsEvaluated = MyMatOfMapIsEvaluated = Standard_True;
- }
+ gp_Pnt aPoint (AX, AY, AZ);
+ aPoint = aCamera->Project (aPoint);
- // WCS -> View Reference Coordinate Space
- PtX = MyMatrixOfOrientation (0, 0) * AX
- + MyMatrixOfOrientation (0, 1) * AY
- + MyMatrixOfOrientation (0, 2) * AZ
- + MyMatrixOfOrientation (0, 3);
- PtY = MyMatrixOfOrientation (1, 0) * AX
- + MyMatrixOfOrientation (1, 1) * AY
- + MyMatrixOfOrientation (1, 2) * AZ
- + MyMatrixOfOrientation (1, 3);
- PtZ = MyMatrixOfOrientation (2, 0) * AX
- + MyMatrixOfOrientation (2, 1) * AY
- + MyMatrixOfOrientation (2, 2) * AZ
- + MyMatrixOfOrientation (2, 3);
- PtT = MyMatrixOfOrientation (3, 0) * AX
- + MyMatrixOfOrientation (3, 1) * AY
- + MyMatrixOfOrientation (3, 2) * AZ
- + MyMatrixOfOrientation (3, 3);
-
- // VRCS -> Normalized Projection Coordinate Space
- APX = MyMatrixOfMapping (0, 0) * PtX
- + MyMatrixOfMapping (0, 1) * PtY
- + MyMatrixOfMapping (0, 2) * PtZ
- + MyMatrixOfMapping (0, 3) * PtT;
- APY = MyMatrixOfMapping (1, 0) * PtX
- + MyMatrixOfMapping (1, 1) * PtY
- + MyMatrixOfMapping (1, 2) * PtZ
- + MyMatrixOfMapping (1, 3) * PtT;
- APZ = MyMatrixOfMapping (2, 0) * PtX
- + MyMatrixOfMapping (2, 1) * PtY
- + MyMatrixOfMapping (2, 2) * PtZ
- + MyMatrixOfMapping (2, 3) * PtT;
- APT = MyMatrixOfMapping (3, 0) * PtX
- + MyMatrixOfMapping (3, 1) * PtY
- + MyMatrixOfMapping (3, 2) * PtZ
- + MyMatrixOfMapping (3, 3) * PtT;
-
- APX /= APT;
- APY /= APT;
- APZ /= APT;
-
- // NPCS -> Window Space
- MyViewMapping.WindowLimit (um, vm, uM, vM);
- fpd = MyViewMapping.FrontPlaneDistance ();
- bpd = MyViewMapping.BackPlaneDistance ();
-
- if(MyCView.Mapping.IsCustomMatrix) {
- // OCC18942: SAN - If orientation and mapping matrices are those used by OpenGL
- // visualization, then X, Y and Z coordinates normally vary between -1 and 1
- APX = ( APX + 1 ) * 0.5 * (uM - um) + um;
- APY = ( APY + 1 ) * 0.5 * (vM - vm) + vm;
- } else {
- Ratio = (uM - um) / (vM - vm);
- if (Ratio >= 1.0)
- APY *= Ratio;
- else
- APX /= Ratio;
-
- /*
- * Coordinates of APX, APY, APZ are described in the space
- * [0-1]x[0-1]x[0-1].
- * It is necessary to transform x and y in the window space.
- * It is necessary to transform z in the space of back and front
- * plane, taking into account clipping planes.
- * Z clipping planes are defined between 0 and 1.
- */
- APX = APX * (uM - um) + um;
- APY = APY * (vM - vm) + vm;
- }
- APZ = APZ * (fpd - bpd) + bpd;
+ APX = (aPoint.X() + 1) * 0.5 * (aUMax - aUmin) + aUmin;
+ APY = (aPoint.Y() + 1) * 0.5 * (aVMax - aVMin) + aVMin;
+ APZ = aPoint.Z() * (aFar - aNear) + aNear;
}
Standard_Integer Visual3d_View::Identification () const {
---Purpose: Returns the group of views activated in the visualiser <me>.
---Category: Inquire methods
- ConvertCoord ( me;
- AWindow : Window from Aspect;
- AVertex : Vertex from Graphic3d;
- AU, AV : out Integer from Standard )
- is static;
- ---Level: Public
- ---Purpose: Applies the view orientation transformation, the
- -- view mapping transformation and view clip, the
- -- display transformation to the vertex <AVertex>.
- -- Returns the pixel coordinates <AU>, <AV>.
- -- Warning: Returns <AU> = <AV> = IntegerLast () if the
- -- evaluation is impossible.
- -- -- Bad Window, Numeric error...
- ---Category: Inquire methods
-
- ConvertCoord ( me;
- AWindow : Window from Aspect;
- AU, AV : Integer from Standard )
- returns Vertex from Graphic3d
- is static;
- ---Level: Public
- ---Purpose: Applies the inverse of the display transformation, the
- -- inverse of the view mapping transformation and view clip,
- -- the inverse of the view orientation transformation to
- -- the pixel coordinates <AU>, <AV>.
- -- Returns the world coordinates <AVertex>.
- -- Warning: Returns AVertex (X, Y, Z) with X = Y = Z = RealLast ()
- -- if the evaluation is impossible.
- -- -- Bad Window, Numeric error...
- ---Category: Inquire methods
-
- ConvertCoordWithProj ( me;
- AWindow : Window from Aspect;
- AU, AV : Integer from Standard;
- Point : out Vertex from Graphic3d;
- Proj : out Vector from Graphic3d )
- is static;
- ---Level: Public
- ---Purpose: Applies the inverse of the display transformation, the
- -- inverse of the view mapping transformation and view clip,
- -- the inverse of the view orientation transformation to
- -- the pixel coordinates <AU>, <AV>.
- -- Returns the world coordinates <AVertex> and projection ray <AVector>.
- -- Warning: Returns AVertex (X, Y, Z) with X = Y = Z = RealLast () and
- -- AVector (VX, VY, VZ) with VX = VY = VZ = 0.
- -- if the evaluation is impossible.
- -- -- Bad Window, Numeric error...
- ---Category: Inquire methods
-
DefinedView ( me )
returns HSetOfView from Visual3d
is static;
}
-void Visual3d_ViewManager::ConvertCoord (const Handle(Aspect_Window)& AWindow, const Graphic3d_Vertex& AVertex, Standard_Integer& AU, Standard_Integer& AV) const {
-
-// Convert only if the data is correct
-Standard_Boolean Exist;
-Graphic3d_CView TheCView;
-//Graphic3d_Vertex Point;
-
-TColStd_Array2OfReal Ori_Matrix (0,3,0,3);
-TColStd_Array2OfReal Map_Matrix (0,3,0,3);
-
-Standard_Integer Width, Height;
-Standard_Real AX, AY, AZ;
-Standard_Real Dx, Dy, Ratio;
-
- Exist = ViewExists (AWindow, TheCView);
-
- if (! Exist) {
- AU = AV = IntegerLast ();
- }
- else {
- // NKV - 11.02.08 - Use graphic driver functions
- Standard_Boolean Result;
-
- AVertex.Coord (AX, AY, AZ);
-
- Result = MyGraphicDriver->ProjectRaster (TheCView,
- Standard_ShortReal (AX), Standard_ShortReal (AY), Standard_ShortReal (AZ),
- AU, AV);
-
- // the old code
- if (!Result) {
-
- Standard_Real PtX, PtY, PtZ, PtT;
- Standard_Real APX, APY, APZ;
- Standard_Real APT;
-
- Visual3d_SetIteratorOfSetOfView MyIterator(MyDefinedView);
-
- Standard_Integer stop = 0;
-
- while ((! stop) && (MyIterator.More ())) {
- if (TheCView.ViewId ==
- (MyIterator.Value ())->Identification ()) {
- Ori_Matrix =
- (MyIterator.Value ())->MatrixOfOrientation ();
- Map_Matrix =
- (MyIterator.Value ())->MatrixOfMapping ();
- stop = 1;
- }
-
- // MyIterator.Next () is located on the next view
- MyIterator.Next ();
- }
-
-
- // WCS -> View Reference Coordinate Space
- PtX = Ori_Matrix (0, 0) * AX
- + Ori_Matrix (0, 1) * AY
- + Ori_Matrix (0, 2) * AZ
- + Ori_Matrix (0, 3);
- PtY = Ori_Matrix (1, 0) * AX
- + Ori_Matrix (1, 1) * AY
- + Ori_Matrix (1, 2) * AZ
- + Ori_Matrix (1, 3);
- PtZ = Ori_Matrix (2, 0) * AX
- + Ori_Matrix (2, 1) * AY
- + Ori_Matrix (2, 2) * AZ
- + Ori_Matrix (2, 3);
- PtT = Ori_Matrix (3, 0) * AX
- + Ori_Matrix (3, 1) * AY
- + Ori_Matrix (3, 2) * AZ
- + Ori_Matrix (3, 3);
-
- // VRCS -> Normalized Projection Coordinate Space
- APX = Map_Matrix (0, 0) * PtX
- + Map_Matrix (0, 1) * PtY
- + Map_Matrix (0, 2) * PtZ
- + Map_Matrix (0, 3) * PtT;
- APY = Map_Matrix (1, 0) * PtX
- + Map_Matrix (1, 1) * PtY
- + Map_Matrix (1, 2) * PtZ
- + Map_Matrix (1, 3) * PtT;
- APZ = Map_Matrix (2, 0) * PtX
- + Map_Matrix (2, 1) * PtY
- + Map_Matrix (2, 2) * PtZ
- + Map_Matrix (2, 3) * PtT;
- APT = Map_Matrix (3, 0) * PtX
- + Map_Matrix (3, 1) * PtY
- + Map_Matrix (3, 2) * PtZ
- + Map_Matrix (3, 3) * PtT;
-
- if (APT == 0. || stop == 0) {
- AU = AV = IntegerLast ();
- }
- else {
- APX /= APT;
- APY /= APT;
- APZ /= APT;
-
- // NPCS -> Device Coordinate Space
- AWindow->Size (Width, Height);
- Dx = Standard_Real (Width);
- Dy = Standard_Real (Height);
- Ratio = Dx / Dy;
- if (Ratio >= 1.) {
- AU = Standard_Integer (APX * Dx);
- AV = Standard_Integer (Dy - APY * Dy * Ratio);
- }
- else {
- AU = Standard_Integer (APX * Dx / Ratio);
- AV = Standard_Integer (Dy - APY * Dy);
- }
- }
- }
- }
-
-}
-
-Graphic3d_Vertex Visual3d_ViewManager::ConvertCoord (const Handle(Aspect_Window)& AWindow, const Standard_Integer AU, const Standard_Integer AV) const {
-
-// Convert only if the data is correct
-Graphic3d_CView TheCView;
-Graphic3d_Vertex Point;
-
- if (ViewExists (AWindow, TheCView))
- {
-Standard_Integer Width, Height;
-Standard_ShortReal x, y, z;
-Standard_Boolean Result;
-
- AWindow->Size (Width, Height);
-
- Result = MyGraphicDriver->UnProjectRaster (TheCView,
- 0, 0, Width, Height,
- AU, AV, x, y, z);
-
- // unproject is done by UnProjectRaster
- if (Result) {
- Point.SetCoord
- (Standard_Real (x), Standard_Real (y), Standard_Real (z));
- }
- // unproject cannot be done by UnProjectRaster
- // Code suspended since drivers Phigs and Pex are abandoned.
- else {
-
-Standard_Real NPCX, NPCY, NPCZ;
-Standard_Real VRCX, VRCY, VRCZ, VRCT;
-Standard_Real WCX, WCY, WCZ, WCT;
-
-TColStd_Array2OfReal TOri_Matrix (0,3,0,3);
-TColStd_Array2OfReal TMap_Matrix (0,3,0,3);
-TColStd_Array2OfReal TOri_Matrix_Inv (0,3,0,3);
-TColStd_Array2OfReal TMap_Matrix_Inv (0,3,0,3);
-
-Standard_Real Dx, Dy, Ratio;
-Visual3d_SetIteratorOfSetOfView MyIterator(MyDefinedView);
-
-Standard_Integer stop = 0;
-
- while ((! stop) && (MyIterator.More ())) {
- if (TheCView.ViewId ==
- (MyIterator.Value ())->Identification ()) {
- TOri_Matrix =
- (MyIterator.Value ())->MatrixOfOrientation ();
- TMap_Matrix =
- (MyIterator.Value ())->MatrixOfMapping ();
- stop = 1;
- }
-
- // MyIterator.Next () is located on the next view
- MyIterator.Next ();
- }
-
- // View Mapping Transformation and View Clip, inversion
- Aspect::Inverse (TMap_Matrix, TMap_Matrix_Inv);
-
- // View Orientation Transformation, inversion
- Aspect::Inverse (TOri_Matrix, TOri_Matrix_Inv);
-
- // (AU, AV) : Device Coordinate Space
- // DCS -> NPCS Normalized Projection Coordinate Space
- Dx = Standard_Real (Width);
- Dy = Standard_Real (Height);
- Ratio = Dx / Dy;
-
- if (Ratio >= 1.) {
- NPCX = Standard_Real (AU) / Dx;
- NPCY = (Dy - Standard_Real (AV)) / Dx;
- }
- else {
- NPCX = Standard_Real (AU) / Dy;
- NPCY = (Dy - Standard_Real (AV)) / Dy;
- }
- NPCZ = 0.0;
-
- // NPCS -> VRCS View Reference Coordinate Space
- // PtVRC = Map_Matrix_Inv.Multiplied (PtNPC);
-
- VRCX = TMap_Matrix_Inv (0, 0) * NPCX
- + TMap_Matrix_Inv (0, 1) * NPCY
- + TMap_Matrix_Inv (0, 2) * NPCZ
- + TMap_Matrix_Inv (0, 3);
- VRCY = TMap_Matrix_Inv (1, 0) * NPCX
- + TMap_Matrix_Inv (1, 1) * NPCY
- + TMap_Matrix_Inv (1, 2) * NPCZ
- + TMap_Matrix_Inv (1, 3);
- VRCZ = TMap_Matrix_Inv (2, 0) * NPCX
- + TMap_Matrix_Inv (2, 1) * NPCY
- + TMap_Matrix_Inv (2, 2) * NPCZ
- + TMap_Matrix_Inv (2, 3);
- VRCT = TMap_Matrix_Inv (3, 0) * NPCX
- + TMap_Matrix_Inv (3, 1) * NPCY
- + TMap_Matrix_Inv (3, 2) * NPCZ
- + TMap_Matrix_Inv (3, 3);
-
- // VRCS -> WCS World Coordinate Space
- // PtWC = Ori_Matrix_Inv.Multiplied (PtVRC);
-
- WCX = TOri_Matrix_Inv (0, 0) * VRCX
- + TOri_Matrix_Inv (0, 1) * VRCY
- + TOri_Matrix_Inv (0, 2) * VRCZ
- + TOri_Matrix_Inv (0, 3) * VRCT;
- WCY = TOri_Matrix_Inv (1, 0) * VRCX
- + TOri_Matrix_Inv (1, 1) * VRCY
- + TOri_Matrix_Inv (1, 2) * VRCZ
- + TOri_Matrix_Inv (1, 3) * VRCT;
- WCZ = TOri_Matrix_Inv (2, 0) * VRCX
- + TOri_Matrix_Inv (2, 1) * VRCY
- + TOri_Matrix_Inv (2, 2) * VRCZ
- + TOri_Matrix_Inv (2, 3) * VRCT;
- WCT = TOri_Matrix_Inv (3, 0) * VRCX
- + TOri_Matrix_Inv (3, 1) * VRCY
- + TOri_Matrix_Inv (3, 2) * VRCZ
- + TOri_Matrix_Inv (3, 3) * VRCT;
-
- if (WCT != 0.)
- Point.SetCoord (WCX/WCT, WCY/WCT, WCZ/WCT);
- }
- }
-
- return (Point);
-
-}
-
-void Visual3d_ViewManager::ConvertCoordWithProj (const Handle(Aspect_Window)& AWindow, const Standard_Integer AU, const Standard_Integer AV, Graphic3d_Vertex& Point, Graphic3d_Vector& Proj) const {
-
-// Conversion only if the data is correct
-Graphic3d_CView TheCView;
-
- if (! ViewExists (AWindow, TheCView)) {
- Point.SetCoord (0., 0., 0.);
- Proj.SetCoord (0., 0., 0.);
- }
- else {
-Standard_Integer Width, Height;
-Standard_ShortReal x, y, z;
-Standard_ShortReal dx, dy, dz;
-Standard_Boolean Result;
-
- AWindow->Size (Width, Height);
-
- Result = MyGraphicDriver->UnProjectRasterWithRay (TheCView,
- 0, 0, Width, Height,
- AU, AV, x, y, z, dx, dy, dz);
-
- // unproject is done by UnProjectRaster
- if (Result) {
- Point.SetCoord
- (Standard_Real (x), Standard_Real (y), Standard_Real (z));
- Proj.SetCoord
- (Standard_Real (dx), Standard_Real (dy), Standard_Real (dz));
- Proj.Normalize();
- }
- // unproject cannot be done by UnProjectRaster
- // Code is suspended since drivers Phigs are Pex abandoned.
- else {
-
-Standard_Real NPCX, NPCY, NPCZ;
-Standard_Real VRCX, VRCY, VRCZ, VRCT;
-Standard_Real WCX, WCY, WCZ, WCT;
-
-TColStd_Array2OfReal TOri_Matrix (0,3,0,3);
-TColStd_Array2OfReal TMap_Matrix (0,3,0,3);
-TColStd_Array2OfReal TOri_Matrix_Inv (0,3,0,3);
-TColStd_Array2OfReal TMap_Matrix_Inv (0,3,0,3);
-
-Standard_Real Dx, Dy, Ratio;
-Visual3d_SetIteratorOfSetOfView MyIterator(MyDefinedView);
-
-Standard_Integer stop = 0;
-
- while ((! stop) && (MyIterator.More ())) {
- if (TheCView.ViewId ==
- (MyIterator.Value ())->Identification ()) {
- TOri_Matrix =
- (MyIterator.Value ())->MatrixOfOrientation ();
- TMap_Matrix =
- (MyIterator.Value ())->MatrixOfMapping ();
- stop = 1;
- }
-
- // MyIterator.Next () is located on the next view
- MyIterator.Next ();
- }
-
- // View Mapping Transformation and View Clip, inversion
- Aspect::Inverse (TMap_Matrix, TMap_Matrix_Inv);
-
- // View Orientation Transformation, inversion
- Aspect::Inverse (TOri_Matrix, TOri_Matrix_Inv);
-
- // (AU, AV) : Device Coordinate Space
- // DCS -> NPCS Normalized Projection Coordinate Space
- Dx = Standard_Real (Width);
- Dy = Standard_Real (Height);
- Ratio = Dx / Dy;
-
- if (Ratio >= 1.) {
- NPCX = Standard_Real (AU) / Dx;
- NPCY = (Dy - Standard_Real (AV)) / Dx;
- }
- else {
- NPCX = Standard_Real (AU) / Dy;
- NPCY = (Dy - Standard_Real (AV)) / Dy;
- }
- NPCZ = 0.0;
-
- // NPCS -> VRCS View Reference Coordinate Space
- // PtVRC = Map_Matrix_Inv.Multiplied (PtNPC);
-
- VRCX = TMap_Matrix_Inv (0, 0) * NPCX
- + TMap_Matrix_Inv (0, 1) * NPCY
- + TMap_Matrix_Inv (0, 2) * NPCZ
- + TMap_Matrix_Inv (0, 3);
- VRCY = TMap_Matrix_Inv (1, 0) * NPCX
- + TMap_Matrix_Inv (1, 1) * NPCY
- + TMap_Matrix_Inv (1, 2) * NPCZ
- + TMap_Matrix_Inv (1, 3);
- VRCZ = TMap_Matrix_Inv (2, 0) * NPCX
- + TMap_Matrix_Inv (2, 1) * NPCY
- + TMap_Matrix_Inv (2, 2) * NPCZ
- + TMap_Matrix_Inv (2, 3);
- VRCT = TMap_Matrix_Inv (3, 0) * NPCX
- + TMap_Matrix_Inv (3, 1) * NPCY
- + TMap_Matrix_Inv (3, 2) * NPCZ
- + TMap_Matrix_Inv (3, 3);
-
- // VRCS -> WCS World Coordinate Space
- // PtWC = Ori_Matrix_Inv.Multiplied (PtVRC);
-
- WCX = TOri_Matrix_Inv (0, 0) * VRCX
- + TOri_Matrix_Inv (0, 1) * VRCY
- + TOri_Matrix_Inv (0, 2) * VRCZ
- + TOri_Matrix_Inv (0, 3) * VRCT;
- WCY = TOri_Matrix_Inv (1, 0) * VRCX
- + TOri_Matrix_Inv (1, 1) * VRCY
- + TOri_Matrix_Inv (1, 2) * VRCZ
- + TOri_Matrix_Inv (1, 3) * VRCT;
- WCZ = TOri_Matrix_Inv (2, 0) * VRCX
- + TOri_Matrix_Inv (2, 1) * VRCY
- + TOri_Matrix_Inv (2, 2) * VRCZ
- + TOri_Matrix_Inv (2, 3) * VRCT;
- WCT = TOri_Matrix_Inv (3, 0) * VRCX
- + TOri_Matrix_Inv (3, 1) * VRCY
- + TOri_Matrix_Inv (3, 2) * VRCZ
- + TOri_Matrix_Inv (3, 3) * VRCT;
-
- if (WCT != 0.)
- Point.SetCoord (WCX/WCT, WCY/WCT, WCZ/WCT);
- else
- Point.SetCoord (0., 0., 0.);
-
- // Define projection ray
- NPCZ = 10.0;
-
- // NPCS -> VRCS View Reference Coordinate Space
- // PtVRC = Map_Matrix_Inv.Multiplied (PtNPC);
-
- VRCX = TMap_Matrix_Inv (0, 0) * NPCX
- + TMap_Matrix_Inv (0, 1) * NPCY
- + TMap_Matrix_Inv (0, 2) * NPCZ
- + TMap_Matrix_Inv (0, 3);
- VRCY = TMap_Matrix_Inv (1, 0) * NPCX
- + TMap_Matrix_Inv (1, 1) * NPCY
- + TMap_Matrix_Inv (1, 2) * NPCZ
- + TMap_Matrix_Inv (1, 3);
- VRCZ = TMap_Matrix_Inv (2, 0) * NPCX
- + TMap_Matrix_Inv (2, 1) * NPCY
- + TMap_Matrix_Inv (2, 2) * NPCZ
- + TMap_Matrix_Inv (2, 3);
- VRCT = TMap_Matrix_Inv (3, 0) * NPCX
- + TMap_Matrix_Inv (3, 1) * NPCY
- + TMap_Matrix_Inv (3, 2) * NPCZ
- + TMap_Matrix_Inv (3, 3);
-
- // VRCS -> WCS World Coordinate Space
- // PtWC = Ori_Matrix_Inv.Multiplied (PtVRC);
-
- WCX = TOri_Matrix_Inv (0, 0) * VRCX
- + TOri_Matrix_Inv (0, 1) * VRCY
- + TOri_Matrix_Inv (0, 2) * VRCZ
- + TOri_Matrix_Inv (0, 3) * VRCT;
- WCY = TOri_Matrix_Inv (1, 0) * VRCX
- + TOri_Matrix_Inv (1, 1) * VRCY
- + TOri_Matrix_Inv (1, 2) * VRCZ
- + TOri_Matrix_Inv (1, 3) * VRCT;
- WCZ = TOri_Matrix_Inv (2, 0) * VRCX
- + TOri_Matrix_Inv (2, 1) * VRCY
- + TOri_Matrix_Inv (2, 2) * VRCZ
- + TOri_Matrix_Inv (2, 3) * VRCT;
- WCT = TOri_Matrix_Inv (3, 0) * VRCX
- + TOri_Matrix_Inv (3, 1) * VRCY
- + TOri_Matrix_Inv (3, 2) * VRCZ
- + TOri_Matrix_Inv (3, 3) * VRCT;
-
- if (WCT != 0.) {
- Proj.SetCoord (WCX/WCT, WCY/WCT, WCZ/WCT);
- Proj.Normalize();
- }
- else
- Proj.SetCoord (0., 0., 0.);
- }
- }
-
-}
-
-
Standard_Boolean Visual3d_ViewManager::ViewExists (const Handle(Aspect_Window)& AWindow, Graphic3d_CView& TheCView) const {
Standard_Boolean Exist = Standard_False;
+++ /dev/null
--- Created on: 1991-06-12
--- Created by: NW,JPB,CAL
--- Copyright (c) 1991-1999 Matra Datavision
--- Copyright (c) 1999-2014 OPEN CASCADE SAS
---
--- This file is part of Open CASCADE Technology software library.
---
--- This library is free software; you can redistribute it and / or modify it
--- under the terms of the GNU Lesser General Public version 2.1 as published
--- by the Free Software Foundation, with special exception defined in the file
--- OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
--- distribution for complete text of the license and disclaimer of any warranty.
---
--- Alternatively, this file may be used under the terms of Open CASCADE
--- commercial license or contractual agreement.
-
-class ViewMapping from Visual3d
-
- ---Version:
-
- ---Purpose: This class allows the definition of a projection and
- -- a system of coordinates called NPC.
- -- (Normalized Projection Coordinates).
- -- The projection can be parallel or perspective.
- -- References: The definitions are Phigs oriented.
- -- Keywords: View, Mapping, Window, View Plane, Front Plane,
- -- BackPlane, Projection Type, Reset, Projection
- -- Summary of 3D View Mapping --
- -- The view mapping transformation defines the --
- -- window-to-viewport mapping of View Reference --
- -- Coordinates (VRC) to Normalized Projection --
- -- Coordinates (NPC). --
- -- CAS.CADE supports two kinds of projection : --
- -- Parallel : --
- -- The Projection Reference Point (PRP) --
- -- determines the direction of projection. --
- -- Perspective : --
- -- The projector lines converge at the --
- -- Projection Reference Point (PRP). --
- -- To define a view mapping transformation you --
- -- must define : --
- -- The Projection Type --
- -- The Projection Reference Point (PRP) --
- -- The Distance from Back Plane (BPD) --
- -- The Distance from Front Plane (FPD) --
- -- The Distance from View Plane (VPD) --
- -- The Window in the View Plane. --
-
-
-uses
-
- Vertex from Graphic3d,
-
- HArray2OfReal from TColStd,
-
- TypeOfProjection from Visual3d
-
-raises
-
- ViewMappingDefinitionError from Visual3d
-
-is
-
-
-
- Create
- returns ViewMapping from Visual3d;
- ---Level: Public
- ---Purpose: Creates a projection.
- --
- -- TypeOfProjection = TOP_PARALLEL
- -- PRP : Projection Reference Point= (0.5, 0.5, 2.0)
- -- BPD : Distance from Back Plane = 0.0
- -- FPD : Distance from Front Plane = 1.0
- -- VPD : Distance from View Plane = 1.0
- -- WUmin = 0.0
- -- WUmax = 1.0
- -- WVmin = 0.0
- -- WVmax = 1.0
-
- Create ( AType : TypeOfProjection from Visual3d;
- PRP : Vertex from Graphic3d;
- BPD, FPD, VPD : Real from Standard;
- WUmin,WVmin : Real from Standard;
- WUmax,WVmax : Real from Standard )
- returns ViewMapping from Visual3d
- ---Level: Public
- ---Purpose: Creates a projection.
- --
- -- TypeOfProjection : TOP_PERSPECTIVE
- -- TOP_PARALLEL
- -- PRP : Projection Reference Point with respect to
- -- coordinate system VRC, defined by the
- -- class ViewOrientation.
- -- BPD : Distance from Back Plane.
- -- FPD : Distance from Front Plane.
- -- VPD : Distance from View Plane.
- -- These three values are with respect to VRP, according to
- -- the N axis of the VRC coordinate system, defined by the class
- -- ViewOrientation.
- -- WUmin,WUmax,WVmin,WVmax : Visible part of the plane of
- -- projection defined with respect to the UV axes of coordinate
- -- system VRC.
- -- That's what allows modification of the zoom/panning.
- -- The mapping of the visible part of the plane of projection
- -- on the screen is done in the window.
- -- That's why multiple views on the same window is not allowed.
- -- Warning: Raises ViewMappingDefinitionError
- -- if the specified window is invalid.
- -- if <PRP> is between the front and back planes.
- -- if <PRP> is positioned on the view plane.
- -- if the back plane is in front of the front plane.
- raises ViewMappingDefinitionError from Visual3d;
-
- ---------------------------------------------------
- -- Category: Methods to modify the class definition
- ---------------------------------------------------
-
- SetBackPlaneDistance ( me : in out;
- BPD : Real from Standard )
- ---Level: Public
- ---Purpose: Modifies the back clipping plane.
- -- Category: Methods to modify the class definition
- -- Warning: Raises ViewMappingDefinitionError
- -- if <PRP> is between the front and back planes.
- -- if <PRP> is positioned on the view plane.
- -- if the back plane is in front of the front plane.
- raises ViewMappingDefinitionError from Visual3d is static;
-
- SetFrontPlaneDistance ( me : in out;
- FPD : Real from Standard )
- ---Level: Public
- ---Purpose: Modifies the front clipping plane.
- -- Category: Methods to modify the class definition
- -- Warning: Raises ViewMappingDefinitionError
- -- if <PRP> is between the front and back planes.
- -- if <PRP> is positioned on the view plane.
- -- if the back plane is in front of the front plane.
- raises ViewMappingDefinitionError from Visual3d is static;
-
- SetProjection ( me : in out;
- AType : TypeOfProjection from Visual3d )
- is static;
- ---Level: Public
- ---Purpose: Modifies the type of projection.
- --
- -- TypeOfProjection : TOP_PERSPECTIVE
- -- TOP_PARALLEL
- --
- ---Category: Methods to modify the class definition
-
- SetProjectionReferencePoint ( me : in out;
- PRP : Vertex from Graphic3d )
- ---Level: Public
- ---Purpose: Modifies the PRP.
- -- Category: Methods to modify the class definition
- -- Warning: Raises ViewMappingDefinitionError
- -- if <PRP> is between the front and back planes.
- -- if <PRP> is positioned on the view plane.
- raises ViewMappingDefinitionError from Visual3d is static;
-
- SetViewPlaneDistance ( me : in out;
- VPD : Real from Standard )
- ---Level: Public
- ---Purpose: Modifies the distance of the view plane of projection.
- -- Category: Methods to modify the class definition
- -- Warning: Raises ViewMappingDefinitionError
- -- if <PRP> is positioned on the view plane.
- raises ViewMappingDefinitionError from Visual3d is static;
-
- SetWindowLimit ( me : in out;
- Umin,Vmin,Umax,Vmax : Real from Standard )
- ---Level: Public
- ---Purpose: Modifies the visible part of the projection plane.
- -- Category: Methods to modify the class definition
- -- Warning: Raises ViewMappingDefinitionError if the
- -- specified window is invalid.
- raises ViewMappingDefinitionError from Visual3d is static;
-
- SetCustomProjectionMatrix( me : in out;
- Mat : HArray2OfReal from TColStd ) is static;
- ---Level: Public
- ---Purpose: Sets custom PROJECTION matrix for the OpenGl context
-
- ----------------------------
- -- Category: Inquire methods
- ----------------------------
-
- BackPlaneDistance ( me )
- returns Real from Standard
- is static;
- ---Level: Public
- ---Purpose: Returns the distance from the back clipping plane
- -- of this view mapping.
- ---Category: Inquire methods
-
- FrontPlaneDistance ( me )
- returns Real from Standard
- is static;
- ---Level: Public
- ---Purpose: Returns the distance from the front clipping plane
- -- of this view mapping.
- ---Category: Inquire methods
-
- Projection ( me )
- returns TypeOfProjection from Visual3d
- is static;
- ---Level: Public
- ---Purpose: Returns the type of projection.
- ---Category: Inquire methods
-
- ProjectionReferencePoint ( me )
- returns Vertex from Graphic3d
- is static;
- ---Level: Public
- ---Purpose: Returns the PRP.
- ---Category: Inquire methods
-
- ViewPlaneDistance ( me )
- returns Real from Standard
- is static;
- ---Level: Public
- ---Purpose: Returns the distance from the projection plane.
- ---Category: Inquire methods
-
- WindowLimit ( me;
- Umin,Vmin,Umax,Vmax : out Real from Standard )
- is static;
- ---Level: Public
- ---Purpose: Returns the visible part of the projection plane.
- ---Category: Inquire methods
-
- IsCustomMatrix( me )
- returns Boolean from Standard
- is static;
- ---Level: Public
- ---Purpose: Returns whether the custom PROJECTION matrix is used.
-
- ----------------------------
- -- Category: Private methods
- ----------------------------
-
- Assign ( me : in out;
- Other : ViewMapping from Visual3d )
- is static private;
- ---Level: Internal
- ---Purpose: Copies the content of <Other> into <me>.
- ---Category: Private methods
-
---\f
-
-fields
-
---
--- Class : Visual3d_ViewMapping
---
--- Purpose : Declaration of variables specific to
--- the mapping of views.
---
--- Reminder : A view mapping is defined by :
--- - the reference point of projection
--- - the type of projection
--- - a distance from the Back Plane
--- - a distance from the Front Plane
--- - a distance from the Projection Plane
--- - the definition of the visible part of the
--- plane of projection
---
-
- -- the reference point of projection
- MyReferencePoint : Vertex from Graphic3d;
-
- -- the type of projection
- MyProjectionType : TypeOfProjection from Visual3d;
-
- -- the distance from the Back Plane
- MyBackPlaneDistance : Real from Standard;
-
- -- the distance from the Front Plane
- MyFrontPlaneDistance : Real from Standard;
-
- -- the distance from the Projection Plane
- MyViewPlaneDistance : Real from Standard;
-
- -- the limits of the visible part of the plane
- -- MyWindowLimits[0] = u left lower corner.
- -- MyWindowLimits[1] = v left lower corner.
- -- MyWindowLimits[2] = u right upper corner.
- -- MyWindowLimits[3] = v right upper corner.
- MyWindowLimits : Real[4];
-
- -- the custom PROJECTION matrix to set directly to OpenGl context
- MyProjectionMatrix : HArray2OfReal from TColStd;
-
-friends
-
- class View from Visual3d
-
-end ViewMapping;
+++ /dev/null
-// Created by: NW,JPB,CAL
-// Copyright (c) 1991-1999 Matra Datavision
-// Copyright (c) 1999-2014 OPEN CASCADE SAS
-//
-// This file is part of Open CASCADE Technology software library.
-//
-// This library is free software; you can redistribute it and / or modify it
-// under the terms of the GNU Lesser General Public version 2.1 as published
-// by the Free Software Foundation, with special exception defined in the file
-// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
-// distribution for complete text of the license and disclaimer of any warranty.
-//
-// Alternatively, this file may be used under the terms of Open CASCADE
-// commercial license or contractual agreement.
-
-// Modified
-// 22-12-98 : FMN ; Rename CSF_WALKTHROW en CSF_WALKTHROUGH
-// 23-07-07 : NKV ; Define custom PROJECTION matrix for OpenGl context
-
-
-//-Version
-
-//-Design Declaration of variables specific to mapping of views
-
-//-Warning Mapping of a view is defined by :
-// - reference point of projection
-// - type of projection
-// - distance for the Back Plane
-// - distance for the Front Plane
-// - distance for the Projection Plane
-
-//-References
-
-//-Language C++ 2.0
-
-//-Declarations
-
-// for the class
-#include <Visual3d_ViewMapping.ixx>
-#include <Precision.hxx>
-
-// Perspective
-#include <OSD_Environment.hxx>
-static OSD_Environment env_walkthrow;
-
-static Standard_Boolean Visual3dWalkthrow()
-{
- static Standard_Integer isWalkthrow( -1 );
- if ( isWalkthrow < 0 ) {
- isWalkthrow = 1;
- OSD_Environment WalkThrow("CSF_WALKTHROUGH");
- if ( WalkThrow.Value().IsEmpty() )
- isWalkthrow = 0;
- }
- return ( isWalkthrow != 0 );
-}
-
-
-//-Aliases
-
-//-Global data definitions
-
-// -- le point reference de projection
-// MyReferencePoint : Vertex;
-
-// -- le type de projection
-// MyProjectionType : TypeOfProjection;
-
-// -- la distance pour le Back Plane
-// MyBackPlaneDistance : Standard_Real;
-
-// -- la distance pour le Front Plane
-// MyFrontPlaneDistance : Standard_Real;
-
-// -- la distance pour le Projection Plane
-// MyViewPlaneDistance : Standard_Real;
-
-// -- les limites de la partie visible du plan
-// -- MyWindowLimits[0] = u du coin inferieur gauche.
-// -- MyWindowLimits[1] = v du coin inferieur gauche.
-// -- MyWindowLimits[2] = u du coin superieur droit.
-// -- MyWindowLimits[3] = v du coin superieur droit.
-// MyWindowLimits : Standard_Real[4];
-
-//-Constructors
-
-//-Destructors
-
-//-Methods, in order
-
-Visual3d_ViewMapping::Visual3d_ViewMapping ():
-MyReferencePoint (0.5, 0.5, 2.0),
-MyProjectionType (Visual3d_TOP_PARALLEL) {
- if ( Visual3dWalkthrow() )
- {
- MyBackPlaneDistance = -1.0;
- MyFrontPlaneDistance = 1.0;
- MyViewPlaneDistance = 0.0;
- }
- else
- {
- MyBackPlaneDistance = 0.0;
- MyFrontPlaneDistance = 1.0;
- MyViewPlaneDistance = 1.0;
- }
-
- MyWindowLimits[0] = 0.0;
- MyWindowLimits[1] = 0.0;
- MyWindowLimits[2] = 1.0;
- MyWindowLimits[3] = 1.0;
-
-}
-
-Visual3d_ViewMapping::Visual3d_ViewMapping (const Visual3d_TypeOfProjection AType, const Graphic3d_Vertex& PRP, const Standard_Real BPD, const Standard_Real FPD, const Standard_Real VPD, const Standard_Real WUmin, const Standard_Real WVmin, const Standard_Real WUmax, const Standard_Real WVmax):
-MyReferencePoint (PRP),
-MyProjectionType (AType),
-MyBackPlaneDistance (BPD),
-MyFrontPlaneDistance (FPD),
-MyViewPlaneDistance (VPD) {
-
- if ( (WUmin >= WUmax) || (WVmin >= WVmax) )
- Visual3d_ViewMappingDefinitionError::Raise
- ("Invalid window; WUmin > WUmax or WVmin > WVmax");
-
- if (BPD > FPD)
- Visual3d_ViewMappingDefinitionError::Raise
- ("The back plane is in front of the front plane");
-
-/*
- A TESTER AVEC LE VRP ?
- Visual3d_ViewMappingDefinitionError::Raise
- ("The projection reference point is between the front and back planes");
-
- if (PRP.Z () == VPD)
- Visual3d_ViewMappingDefinitionError::Raise
-("The projection reference point cannot be positioned on the view plane");
-*/
-
- MyWindowLimits[0] = WUmin;
- MyWindowLimits[1] = WVmin;
- MyWindowLimits[2] = WUmax;
- MyWindowLimits[3] = WVmax;
-
-}
-
-void Visual3d_ViewMapping::SetProjection (const Visual3d_TypeOfProjection AType) {
-
- MyProjectionType = AType;
-
-}
-
-Visual3d_TypeOfProjection Visual3d_ViewMapping::Projection () const {
-
- return (MyProjectionType);
-
-}
-
-void Visual3d_ViewMapping::SetProjectionReferencePoint (const Graphic3d_Vertex& PRP) {
-
-/*
-Standard_Real VPD, BPD, FPD;
-
- VPD = MyViewPlaneDistance;
- BPD = MyBackPlaneDistance;
- FPD = MyFrontPlaneDistance;
-
- A TESTER AVEC LE VRP ?
- Visual3d_ViewMappingDefinitionError::Raise
- ("The projection reference point is between the front and back planes");
-
- if (PRP.Z () == VPD)
- Visual3d_ViewMappingDefinitionError::Raise
-("The projection reference point cannot be positioned on the view plane");
-*/
-
- MyReferencePoint = PRP;
-
-}
-
-Graphic3d_Vertex Visual3d_ViewMapping::ProjectionReferencePoint () const {
-
- return (MyReferencePoint);
-
-}
-
-void Visual3d_ViewMapping::SetViewPlaneDistance (const Standard_Real VPD) {
-
-/*
-Standard_Real PRPZ, BPD, FPD;
-
- PRPZ = MyReferencePoint.Z ();
- BPD = MyBackPlaneDistance;
- FPD = MyFrontPlaneDistance;
-
- A TESTER AVEC LE VRP ?
- Visual3d_ViewMappingDefinitionError::Raise
- ("The projection reference point is between the front and back planes");
-
- if (PRPZ == VPD)
- Visual3d_ViewMappingDefinitionError::Raise
-("The projection reference point cannot be positioned on the view plane");
-*/
-
- MyViewPlaneDistance = VPD;
-
-}
-
-Standard_Real Visual3d_ViewMapping::ViewPlaneDistance () const {
-
- return (MyViewPlaneDistance);
-
-}
-
-void Visual3d_ViewMapping::SetBackPlaneDistance (const Standard_Real BPD) {
-
-/*
-Standard_Real VPD, PRPZ, FPD;
-
- PRPZ = MyReferencePoint.Z ();
- VPD = MyViewPlaneDistance;
- FPD = MyFrontPlaneDistance;
-
- if (BPD > FPD)
- Visual3d_ViewMappingDefinitionError::Raise
- ("The back plane is in front of the front plane");
-
- A TESTER AVEC LE VRP ?
- Visual3d_ViewMappingDefinitionError::Raise
- ("The projection reference point is between the front and back planes");
-*/
-
- MyBackPlaneDistance = BPD;
-}
-
-Standard_Real Visual3d_ViewMapping::BackPlaneDistance () const {
-
- return (MyBackPlaneDistance);
-}
-
-void Visual3d_ViewMapping::SetFrontPlaneDistance (const Standard_Real FPD) {
-
-/*
-Standard_Real VPD, BPD, PRPZ;
-
- PRPZ = MyReferencePoint.Z ();
- VPD = MyViewPlaneDistance;
- BPD = MyBackPlaneDistance;
-
- if (BPD > FPD)
- Visual3d_ViewMappingDefinitionError::Raise
- ("The back plane is in front of the front plane");
-
- A TESTER AVEC LE VRP ?
- Visual3d_ViewMappingDefinitionError::Raise
- ("The projection reference point is between the front and back planes");
-*/
-
- MyFrontPlaneDistance = FPD;
-
-}
-
-Standard_Real Visual3d_ViewMapping::FrontPlaneDistance () const {
-
- return (MyFrontPlaneDistance);
-
-}
-
-void Visual3d_ViewMapping::SetWindowLimit (const Standard_Real Umin, const Standard_Real Vmin, const Standard_Real Umax, const Standard_Real Vmax) {
-
- if ( (Umin >= Umax) || (Vmin >= Vmax) )
- Visual3d_ViewMappingDefinitionError::Raise
- ("Invalid window; WUmin > WUmax or WVmin > WVmax");
-
- if( (Umax - Umin) < Precision::Confusion() || (Vmax - Vmin) < Precision::Confusion())
- Visual3d_ViewMappingDefinitionError::Raise
- ("Window is too small");
-
- MyWindowLimits[0] = Umin;
- MyWindowLimits[1] = Vmin;
- MyWindowLimits[2] = Umax;
- MyWindowLimits[3] = Vmax;
-
-}
-
-void Visual3d_ViewMapping::WindowLimit (Standard_Real& Umin, Standard_Real& Vmin, Standard_Real& Umax, Standard_Real& Vmax) const {
-
- Umin = MyWindowLimits[0];
- Vmin = MyWindowLimits[1];
- Umax = MyWindowLimits[2];
- Vmax = MyWindowLimits[3];
-
-}
-
-void Visual3d_ViewMapping::SetCustomProjectionMatrix(const Handle(TColStd_HArray2OfReal)& Mat)
-{
- MyProjectionMatrix = Mat;
-}
-
-Standard_Boolean Visual3d_ViewMapping::IsCustomMatrix() const
-{
- return !MyProjectionMatrix.IsNull()
- && MyProjectionMatrix->LowerRow() == 0
- && MyProjectionMatrix->LowerCol() == 0
- && MyProjectionMatrix->UpperRow() == 3
- && MyProjectionMatrix->UpperCol() == 3;
-}
-
-
-void Visual3d_ViewMapping::Assign (const Visual3d_ViewMapping& Other) {
-
-Standard_Real X, Y, Z;
-
- (Other.ProjectionReferencePoint ()).Coord (X, Y, Z);
- MyReferencePoint.SetCoord (X, Y, Z);
-
- MyProjectionType = Other.Projection ();
-
- MyBackPlaneDistance = Other.BackPlaneDistance ();
-
- MyFrontPlaneDistance = Other.FrontPlaneDistance ();
-
- MyViewPlaneDistance = Other.ViewPlaneDistance ();
-
- Other.WindowLimit (MyWindowLimits[0], MyWindowLimits[1],
- MyWindowLimits[2], MyWindowLimits[3]);
-
- if ( Other.IsCustomMatrix() ) {
- MyProjectionMatrix = new TColStd_HArray2OfReal( 0, 3, 0, 3 );
- for (Standard_Integer i = 0; i < 4; i++)
- for (Standard_Integer j = 0; j < 4; j++)
- MyProjectionMatrix->SetValue( i, j, Other.MyProjectionMatrix->Value(i, j) );
- }
- else
- MyProjectionMatrix.Nullify();
-}
+++ /dev/null
--- Created on: 1991-06-12
--- Created by: NW,JPB,CAL
--- Copyright (c) 1991-1999 Matra Datavision
--- Copyright (c) 1999-2014 OPEN CASCADE SAS
---
--- This file is part of Open CASCADE Technology software library.
---
--- This library is free software; you can redistribute it and / or modify it
--- under the terms of the GNU Lesser General Public version 2.1 as published
--- by the Free Software Foundation, with special exception defined in the file
--- OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
--- distribution for complete text of the license and disclaimer of any warranty.
---
--- Alternatively, this file may be used under the terms of Open CASCADE
--- commercial license or contractual agreement.
-
-class ViewOrientation from Visual3d
-
- ---Version:
-
- ---Purpose: This class allows the definition of the manner in
- -- which an observer looks at the visualised scene.
- -- It defines a coordinate system called VRC
- -- (View Reference Coordinates) with 3 axes U,V,N
- -- Summary of 3D View Orientation --
- -- --
- -- The view orientation transformation defines --
- -- the relationship between World Coordinates --
- -- (WC) and View Reference Coordinates (VRC) --
- -- --
- -- To define a view orientation transformation --
- -- you must define : --
- -- --
- -- The View Reference Point (VRP) --
- -- The View Plane Normal (VPN) --
- -- The View Up Vector (VUP). --
- --
- -- Optionally, it is possible to specify anisotropic
- -- (axial) scale factors. This allows to scale the scene
- -- using individual scale values along each coordinate axis.
-
-uses
-
- Vector from Graphic3d,
- Vertex from Graphic3d,
-
- HArray2OfReal from TColStd
-
-raises
-
- ViewOrientationDefinitionError from Visual3d
-
-is
-
-
- Create
- returns ViewOrientation from Visual3d;
- ---Level: Public
- ---Purpose: Creates a VRC coordinate system.
- -- VRP : Origin of the VRC coordinate system.
- -- (default value : 0.0, 0.0, 0.0)
- -- VPN : Vector normal to the plane of visualisation.
- -- (default value : 0.0, 0.0, 1.0)
- -- VUP : Vector for which the projection in the plane
- -- of visualisation defines the axis V of a VRC
- -- coordinate system.
- -- (default value : 0.0, 1.0, 0.0)
-
- Create ( VRP : Vertex from Graphic3d;
- VPN : Vector from Graphic3d;
- VUP : Vector from Graphic3d )
- returns ViewOrientation from Visual3d
- ---Level: Public
- ---Purpose: Creates a VRC coordinate system.
- -- VRP : Origin of the VRC coordinate system.
- -- VPN : Vector normal to the plane of visualisation.
- -- VUP : Vector for which the projection in the plane
- -- of visualisation defines the axis V of a VRC
- -- coordinate system.
- -- This vector can be likened to the
- -- vertical of the observer.
- -- Warning: Raises ViewOrientationDefinitionError
- -- if <VPN> is null.
- -- if <VUP> is null.
- -- if <VPN> and <VUP> are parallel.
- raises ViewOrientationDefinitionError from Visual3d;
-
- Create ( VRP : Vertex from Graphic3d;
- VPN : Vector from Graphic3d;
- Twist : Real from Standard )
- returns ViewOrientation from Visual3d
- ---Level: Internal
- ---Purpose: Creates a VRC coordinate system.
- -- VRP : Origin of VRC coordinate system.
- -- VPN : Normal vector to the plane of visualisation.
- -- Twist : Angle in radians of the V axis in the VRC
- -- coordinate system with the projection in
- -- the plane of visualisation of the Zm axis
- -- in the model space.
- -- Warning: Raises ViewOrientationDefinitionError if <VPN> is null.
- raises ViewOrientationDefinitionError from Visual3d;
-
- Create ( VRP : Vertex from Graphic3d;
- Azim, Inc, Twist : Real from Standard )
- returns ViewOrientation from Visual3d
- ---Level: Internal
- ---Purpose: Creates a VRC coordinate system.
- -- VRP : Origin of the VRC coordinate system.
- -- Azim : Angle in radians of the plane of visualisation
- -- with the XmYm plane of the model space.
- -- Inc : Angle in radians of the plane of visualisation
- -- with the YmZm plane of the model space.
- -- Twist : Angle in radians of the V axis in the VRC
- -- coordinate system with the projection in
- -- the plane of visualisation of the Zm axis
- -- in the model space.
- -- Warning: Raises ViewOrientationDefinitionError
- raises ViewOrientationDefinitionError from Visual3d;
-
- ---------------------------------------------------
- -- Category: Methods to modify the class definition
- ---------------------------------------------------
-
- SetViewReferencePlane ( me : in out;
- VPN : Vector from Graphic3d )
- ---Level: Public
- ---Purpose: Modifies the plane of visualisation
- -- defined by a normal vector.
- -- Category: Methods to modify the class definition
- -- Warning: Raises ViewOrientationDefinitionError if <VPN> is null.
- raises ViewOrientationDefinitionError from Visual3d is static;
-
- SetViewReferencePoint ( me : in out;
- VRP : Vertex from Graphic3d )
- is static;
- ---Level: Public
- ---Purpose: Modifies the origin of the VRC coordinate system
- ---Category: Methods to modify the class definition
-
- SetViewReferenceUp ( me : in out;
- VUP : Vector from Graphic3d )
- ---Level: Public
- ---Purpose: Modifies the vertical of the observer.
- -- Category: Methods to modify the class definition
- -- Warning: Raises ViewOrientationDefinitionError if <VUP> is null.
- raises ViewOrientationDefinitionError from Visual3d is static;
-
- SetAxialScale ( me : in out ;
- Sx, Sy, Sz : Real from Standard )
- ---Level: Public
- ---Purpose: Sets axial scale factors of the view
- raises ViewOrientationDefinitionError from Visual3d ;
- -- If the one of factors <= 0
-
- SetCustomModelViewMatrix( me : in out;
- Mat : HArray2OfReal from TColStd ) is static;
- ---Level: Public
- ---Purpose: Sets custom MODELVIEW matrix for the OpenGl context
-
- ----------------------------
- -- Category: Inquire methods
- ----------------------------
-
- Twist ( me )
- returns Real from Standard
- is static;
- ---Level: Internal
- ---Purpose: Returns the angle in radians of the V axis in the VRC
- -- coordinate system with the projection in the plane of
- -- visualisation of the Zm axis in the model space.
- ---Category: Inquire methods
-
- ViewReferencePlane ( me )
- returns Vector from Graphic3d
- is static;
- ---Level: Public
- ---Purpose: Returns the normal to the plane of projection.
- ---Category: Inquire methods
-
- ViewReferencePoint ( me )
- returns Vertex from Graphic3d
- is static;
- ---Level: Public
- ---Purpose: Returns origin of the VRC coordinate system.
- ---Category: Inquire methods
-
- ViewReferenceUp ( me )
- returns Vector from Graphic3d
- is static;
- ---Level: Public
- ---Purpose: Returns the vertical of the observer.
- ---Category: Inquire methods
-
- AxialScale ( me ; Sx, Sy, Sz : out Real from Standard ) ;
- ---Level: Public
- ---Purpose: Returns current values of the axial scale factors.
-
- IsCustomMatrix( me )
- returns Boolean from Standard
- is static;
- ---Level: Public
- ---Purpose: Returns whether the custom MODELVIEW matrix is used.
-
- ----------------------------
- -- Category: Private methods
- ----------------------------
-
- Assign ( me : in out;
- Other : ViewOrientation from Visual3d )
- is static private;
- ---Level: Internal
- ---Purpose: Copies the content of <Other> into <me>.
- ---Category: Private methods
-
---\f
-
-fields
-
---
--- Class : Visual3d_ViewOrientation
---
--- Purpose : Declaration of variables specific to
--- the view orientation
---
--- Reminders : the orientation of a view is defined by :
--- - the origin point of the coordinate system
--- - the normal vector to the plane of visualisation
--- - the vector vertical to the observer
---
-
- -- the coordinate system origin point
- MyViewReferencePoint : Vertex from Graphic3d;
-
- -- the normal vector to the plane of visualisation
- MyViewPlaneNormal : Vector from Graphic3d;
-
- -- the vertical vector of the observer
- MyViewUpVector : Vector from Graphic3d;
-
- -- the scale parameter of the X axis
- MyScaleX : Real from Standard;
-
- -- the scale parameter of the Y axis
- MyScaleY : Real from Standard;
-
- -- the scale parameter of the Z axis
- MyScaleZ : Real from Standard;
-
- -- the custom MODELVIEW matrix to set directly to OpenGl context
- MyModelViewMatrix : HArray2OfReal from TColStd;
-
-friends
-
- class View from Visual3d
-
-end ViewOrientation;
+++ /dev/null
-// Created by: NW,JPB,CAL
-// Copyright (c) 1991-1999 Matra Datavision
-// Copyright (c) 1999-2014 OPEN CASCADE SAS
-//
-// This file is part of Open CASCADE Technology software library.
-//
-// This library is free software; you can redistribute it and / or modify it
-// under the terms of the GNU Lesser General Public version 2.1 as published
-// by the Free Software Foundation, with special exception defined in the file
-// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
-// distribution for complete text of the license and disclaimer of any warranty.
-//
-// Alternatively, this file may be used under the terms of Open CASCADE
-// commercial license or contractual agreement.
-
-//-Version
-
-//-Design Declaration of variables specific to the orientation of views
-
-//-Warning The view orientation is defined by :
-// - the point of origin of the reference mark
-// - the normal vector to the visualisation plane
-// - the vertical vector of the viewer
-
-//-References
-
-//-Language C++ 2.0
-
-//-Declarations
-
-// for the class
-#include <Visual3d_ViewOrientation.ixx>
-
-//-Aliases
-
-//-Global data definitions
-
-// -- le point origine du repere
-// MyViewReferencePoint : Vertex;
-
-// -- le vecteur normal au plan de visualisation
-// MyViewPlaneNormal : Vector;
-
-// -- le vecteur vertical de l'observateur
-// MyViewUpVector : Vector;
-
-//-Constructors
-
-//-Destructors
-
-//-Methods, in order
-
-Visual3d_ViewOrientation::Visual3d_ViewOrientation ():
-MyViewReferencePoint (0.0, 0.0, 0.0),
-MyViewPlaneNormal (0.0, 0.0, 1.0),
-MyViewUpVector (0.0, 1.0, 0.0),
-MyScaleX(1.0),
-MyScaleY(1.0),
-MyScaleZ(1.0) {
-}
-
-Visual3d_ViewOrientation::Visual3d_ViewOrientation (const Graphic3d_Vertex& VRP, const Graphic3d_Vector& VPN, const Graphic3d_Vector& VUP):
-MyViewReferencePoint (VRP),
-MyViewPlaneNormal (VPN),
-MyViewUpVector (VUP),
-MyScaleX(1.0),
-MyScaleY(1.0),
-MyScaleZ(1.0) {
-
- if (Graphic3d_Vector::NormeOf (VPN) == 0.0)
- Visual3d_ViewOrientationDefinitionError::Raise
- ("Bad value for ViewPlaneNormal");
-
- if (Graphic3d_Vector::NormeOf (VUP) == 0.0)
- Visual3d_ViewOrientationDefinitionError::Raise
- ("Bad value for ViewUpVector");
-
- if (Graphic3d_Vector::IsParallel (VPN, VUP))
- Visual3d_ViewOrientationDefinitionError::Raise
- ("ViewPlaneNormal and ViewUpVector are parallel");
-
-}
-
-Visual3d_ViewOrientation::Visual3d_ViewOrientation (const Graphic3d_Vertex& VRP, const Graphic3d_Vector& VPN, const Standard_Real /*Twist*/) {
-
- if (Graphic3d_Vector::NormeOf (VPN) == 0.0)
- Visual3d_ViewOrientationDefinitionError::Raise
- ("Bad value for ViewPlaneNormal");
-
- cout << "\nVisual3d_ViewOrientation : Not Yet Implemented\n\n" << flush;
-
- MyViewReferencePoint = VRP;
- MyViewPlaneNormal = VPN;
-
-}
-
-Visual3d_ViewOrientation::Visual3d_ViewOrientation (const Graphic3d_Vertex& VRP, const Standard_Real /*Azim*/, const Standard_Real /*Inc*/, const Standard_Real /*Twist*/) {
-
- cout << "\nVisual3d_ViewOrientation : Not Yet Implemented\n\n" << flush;
-
- MyViewReferencePoint = VRP;
-
-}
-
-void Visual3d_ViewOrientation::SetViewReferencePoint (const Graphic3d_Vertex& VRP) {
-
- MyViewReferencePoint = VRP;
-
-}
-
-Graphic3d_Vertex Visual3d_ViewOrientation::ViewReferencePoint () const {
-
- return (MyViewReferencePoint);
-
-}
-
-void Visual3d_ViewOrientation::SetViewReferencePlane (const Graphic3d_Vector& VPN) {
-
- if (Graphic3d_Vector::NormeOf (VPN) == 0.0)
- Visual3d_ViewOrientationDefinitionError::Raise
- ("Bad value for ViewPlaneNormal");
-
- MyViewPlaneNormal = VPN;
-
-}
-
-Graphic3d_Vector Visual3d_ViewOrientation::ViewReferencePlane () const {
-
- return (MyViewPlaneNormal);
-
-}
-
-void Visual3d_ViewOrientation::SetViewReferenceUp (const Graphic3d_Vector& VUP) {
-
- if (Graphic3d_Vector::NormeOf (VUP) == 0.0)
- Visual3d_ViewOrientationDefinitionError::Raise
- ("Bad value for ViewUpVector");
-
- MyViewUpVector = VUP;
-
-}
-
-void Visual3d_ViewOrientation::SetAxialScale (const Standard_Real Sx, const Standard_Real Sy, const Standard_Real Sz) {
- if ( Sx <= 0. || Sy <= 0. || Sz <= 0. )
- Visual3d_ViewOrientationDefinitionError::Raise
- ("Bad value for ViewUpVector");
- MyScaleX = Sx;
- MyScaleY = Sy;
- MyScaleZ = Sz;
-}
-
-Graphic3d_Vector Visual3d_ViewOrientation::ViewReferenceUp () const {
-
- return (MyViewUpVector);
-
-}
-
-void Visual3d_ViewOrientation::Assign (const Visual3d_ViewOrientation& Other) {
-
-Standard_Real X, Y, Z;
-
- (Other.ViewReferencePoint ()).Coord (X, Y, Z);
- MyViewReferencePoint.SetCoord (X, Y, Z);
-
- (Other.ViewReferencePlane ()).Coord (X, Y, Z);
- MyViewPlaneNormal.SetCoord (X, Y, Z);
-
- (Other.ViewReferenceUp ()).Coord (X, Y, Z);
- MyViewUpVector.SetCoord (X, Y, Z);
-
- if ( Other.IsCustomMatrix() ) {
- MyModelViewMatrix = new TColStd_HArray2OfReal( 0, 3, 0, 3);
- for (Standard_Integer i = 0; i < 4; i++)
- for (Standard_Integer j = 0; j < 4; j++)
- MyModelViewMatrix->SetValue( i, j, Other.MyModelViewMatrix->Value(i, j) );
- }
- else
- MyModelViewMatrix.Nullify();
-}
-
-Standard_Real Visual3d_ViewOrientation::Twist () const {
-
-cout << "\nVisual3d_ViewOrientation::Twist : Not Yet Implemented\n\n" << flush;
-
-#ifdef OK
-Standard_Real Xrp, Yrp, Zrp;
-Standard_Real Xpn, Ypn, Zpn;
-Standard_Real Xup, Yup, Zup;
-Standard_Real a1, b1, c1, a2, b2, c2;
-Standard_Real pvx, pvy, pvz;
-Standard_Real an1, an2;
-Standard_Real pvn, sca, angle;
-
- MyViewReferencePoint.Coord (Xrp, Yrp, Zrp) ;
- MyViewPlaneNormal.Coord (Xpn, Ypn, Zpn) ;
- MyViewUpVector.Coord (Xup, Yup, Zup) ;
-
- Xrp -= Xpn ; Yrp -= Ypn ; Zrp -= Zpn ;
- Xup -= Xpn ; Yup -= Ypn ; Zup -= Zpn ;
- /* Compute Plane Normal EYE, AT, UP */
- a1 = Yrp*Zup - Yup*Zrp ;
- b1 = Zrp*Xup - Zup*Xrp ;
- c1 = Xrp*Yup - Xup*Yrp ;
- /* Compute Plane Normal EYE, AT, YAXIS */
- a2 = -Zrp ;
- b2 = 0. ;
- c2 = Xrp ;
- /* Compute Cross Vector from 2 last Normals */
- pvx = b1*c2 - c1*b2 ;
- pvy = c1*a2 - a1*c2 ;
- pvz = a1*b2 - b1*a2 ;
- /* Normalize vectors */
- an1 = a1*a1 + b1*b1 + c1*c1 ;
- an2 = a2*a2 + b2*b2 + c2*c2 ;
- pvn = pvx*pvx + pvy*pvy + pvz*pvz ;
- /* Compute Angle */
- if (angle > 1.) angle = 1. ;
- else if ( angle < -1. ) angle = -1. ;
- angle = asin (angle) / (M_PI / 180.0);
- sca = a1*a2 + b1*b2 + c1*c2 ;
- if (sca < 0.) angle = 180. - angle ;
- if ( (angle > 0.) && (angle < 180.) ) {
- sca = - (pvx*Xrp + pvy*Yrp + pvz*Zrp) ;
- if (sca > 0.) angle = 360. - angle ;
- }
-
- return (angle * M_PI / 180.0);
-#else
- return (M_PI / 180.0);
-#endif
-
-}
-
-void Visual3d_ViewOrientation::AxialScale(Standard_Real& Sx, Standard_Real& Sy, Standard_Real& Sz)const {
- Sx = MyScaleX;
- Sy = MyScaleY;
- Sz = MyScaleZ;
-}
-
-
-void Visual3d_ViewOrientation::SetCustomModelViewMatrix(const Handle(TColStd_HArray2OfReal)& Mat)
-{
- MyModelViewMatrix = Mat;
-}
-
-Standard_Boolean Visual3d_ViewOrientation::IsCustomMatrix() const
-{
- return !MyModelViewMatrix.IsNull()
- && MyModelViewMatrix->LowerRow() == 0
- && MyModelViewMatrix->LowerCol() == 0
- && MyModelViewMatrix->UpperRow() == 3
- && MyModelViewMatrix->UpperCol() == 3;
-}
-
-puts "========================"
-puts "OCC137"
-puts "========================"
-###############################################################
-#Patch description:
-#
-#MIT010717 : 3D selection management
-#>>> MIT010717 : Selection management
-#
-# * Package OpenGl (OpenGl_execstruct.c)
-#
-# @ Avoid drawing quality problem on selected face,
-# enable/disable Z offset on highlighted faces.
-#
-#>>> MIT010717 : drawing management
-#
-# * Package OpenGl (OpenGl_indexpolygon.c, ...)
-#
-# @ Avoid to undraw faces with confused points
-###############################################################
-puts "========================"
-
-vinit
-box b 10 10 10
-vdisplay b
-vfit
-vsetdispmode 1
-
-puts "Only bottom face should be highlighted."
-
-vselmode 4 1
-
-OCC137 1
-OCC137_z
-
-set x_coord 105
-set y_coord 350
-
-vmoveto $x_coord $y_coord
-
-set x_coord 105
-set y_coord 340
-
-checkcolor $x_coord $y_coord 0 1 1
-
-set x_coord 105
-set y_coord 340
-vviewparams 60.6309 7.07107 4.08248 0.592163 -0.60038 -0.537482 0.369921 -0.390032 0.843228 -3.28175 3.38875 3.0464
-
-checkcolor $x_coord $y_coord 0.78 0.54 0.09
-
-set only_screen 1
+\r
+puts "========================"\r
+puts "OCC137"\r
+puts "========================" \r
+###############################################################\r
+#Patch description:\r
+#\r
+#MIT010717 : 3D selection management\r
+#>>> MIT010717 : Selection management \r
+#\r
+# * Package OpenGl (OpenGl_execstruct.c) \r
+#\r
+# @ Avoid drawing quality problem on selected face, \r
+# enable/disable Z offset on highlighted faces. \r
+#\r
+#>>> MIT010717 : drawing management \r
+#\r
+# * Package OpenGl (OpenGl_indexpolygon.c, ...) \r
+#\r
+# @ Avoid to undraw faces with confused points \r
+###############################################################\r
+puts "========================"\r
+\r
+vinit\r
+box b 10 10 10\r
+vdisplay b\r
+vfit\r
+vsetdispmode 1\r
+\r
+puts "Only bottom face should be highlighted."\r
+\r
+vselmode 4 1\r
+\r
+OCC137 1\r
+OCC137_z\r
+\r
+set x_coord 105\r
+set y_coord 348\r
+\r
+vmoveto $x_coord $y_coord\r
+\r
+set x_coord 105\r
+set y_coord 340\r
+\r
+checkcolor $x_coord $y_coord 0 1 1\r
+\r
+set x_coord 105\r
+set y_coord 340\r
+vviewparams 60.6309 7.07107 4.08248 0.592163 -0.60038 -0.537482 0.369921 -0.390032 0.843228 -3.28175 3.38875 3.0464\r
+\r
+checkcolor $x_coord $y_coord 0.78 0.54 0.09\r
+ \r
+set only_screen 1\r
-
-puts "========================"
-puts "OCC137"
-puts "========================"
-###############################################################
-#Patch description:
-#
-#MIT010717 : 3D selection management
-#>>> MIT010717 : Selection management
-#
-# * Package OpenGl (OpenGl_execstruct.c)
-#
-# @ Avoid drawing quality problem on selected face,
-# enable/disable Z offset on highlighted faces.
-#
-#>>> MIT010717 : drawing management
-#
-# * Package OpenGl (OpenGl_indexpolygon.c, ...)
-#
-# @ Avoid to undraw faces with confused points
-###############################################################
-puts "========================"
-
-vinit
-box b 10 10 10
-vdisplay b
-vfit
-vsetdispmode 1
-
-puts "Only bottom face should be highlighted."
-
-OCC137 1
-OCC137_z
-
-vselmode 4 1
-
-set x_coord 105
-set y_coord 350
-
-vmoveto $x_coord $y_coord
-
-set x_coord 105
-set y_coord 340
-
-checkcolor $x_coord $y_coord 0 1 1
-
-vviewparams 60.6309 7.07107 4.08248 0.592163 -0.60038 -0.537482 0.369921 -0.390032 0.843228 -3.28175 3.38875 3.0464
-set x_coord 105
-set y_coord 340
-
-checkcolor $x_coord $y_coord 0.78 0.54 0.09
-
-set only_screen 1
+\r
+puts "========================"\r
+puts "OCC137"\r
+puts "========================" \r
+###############################################################\r
+#Patch description:\r
+#\r
+#MIT010717 : 3D selection management\r
+#>>> MIT010717 : Selection management \r
+#\r
+# * Package OpenGl (OpenGl_execstruct.c) \r
+#\r
+# @ Avoid drawing quality problem on selected face, \r
+# enable/disable Z offset on highlighted faces. \r
+#\r
+#>>> MIT010717 : drawing management \r
+#\r
+# * Package OpenGl (OpenGl_indexpolygon.c, ...) \r
+#\r
+# @ Avoid to undraw faces with confused points \r
+###############################################################\r
+puts "========================"\r
+\r
+vinit\r
+box b 10 10 10\r
+vdisplay b\r
+vfit\r
+vsetdispmode 1\r
+\r
+puts "Only bottom face should be highlighted."\r
+\r
+OCC137 1\r
+OCC137_z\r
+\r
+vselmode 4 1\r
+\r
+set x_coord 105\r
+set y_coord 348\r
+\r
+vmoveto $x_coord $y_coord\r
+\r
+set x_coord 105\r
+set y_coord 340\r
+\r
+checkcolor $x_coord $y_coord 0 1 1\r
+\r
+vviewparams 60.6309 7.07107 4.08248 0.592163 -0.60038 -0.537482 0.369921 -0.390032 0.843228 -3.28175 3.38875 3.0464\r
+set x_coord 105\r
+set y_coord 340\r
+\r
+checkcolor $x_coord $y_coord 0.78 0.54 0.09\r
+\r
+set only_screen 1\r
--- /dev/null
+puts "========"
+puts "OCC22337"
+puts "Test vprintview with new camera and shaders"
+puts "========"
+
+pload ALL
+vinit
+box b 10 10 10
+vdisplay b
+vrotate 1 0 0
+vfit
+vsetdispmode 1
+
+# test vprintview work
+# make sure that the images with forced tiles and without are the same
+vchangecamera proj ortho
+vfit
+set aTitle "ortho"
+vprintview 512 512 $imagedir/${casename}_${aTitle}.png rgb
+set aTitle "ortho-tiles"
+vprintview 512 512 $imagedir/${casename}_${aTitle}.png rgb 1 256 256
+
+vchangecamera proj persp
+vfit
+set aTitle "persp"
+vprintview 512 512 $imagedir/${casename}_${aTitle}.png rgb
+set aTitle "persp-tiles"
+vprintview 512 512 $imagedir/${casename}_${aTitle}.png rgb 1 256 256
+
+vshaderprog phong
+
+vchangecamera proj ortho
+vfit
+set aTitle "ortho-shader"
+vprintview 512 512 $imagedir/${casename}_${aTitle}.png rgb
+set aTitle "ortho-shader-tiles"
+vprintview 512 512 $imagedir/${casename}_${aTitle}.png rgb 1 256 256
+
+vchangecamera proj persp
+vfit
+set aTitle "persp-shader"
+vprintview 512 512 $imagedir/${casename}_${aTitle}.png rgb
+set aTitle "persp-shader-tiles"
+vprintview 512 512 $imagedir/${casename}_${aTitle}.png rgb 1 256 256
+
vinit
vclear
vaxo
-box b 10 20 30
+psphere b 20
vdisplay b
vsetdispmode b 1
vfit
--- /dev/null
+puts "========"
+puts "OCC24001"
+puts "Camera dump test"
+puts "========"
+
+box b 1 2 3
+vinit
+vdisplay b
+
+# initialize camera parameters
+vchangecamera fov 45
+vchangecamera iodtype relative
+vchangecamera iod 0.05
+vchangecamera zfocustype relative
+vchangecamera zfocus 1.0
+
+# test vdump work
+# make sure that neither of 4 produced images match each other
+vchangecamera proj ortho
+vfit
+set aTitle "ortho"
+vdump $imagedir/${casename}_${aTitle}.png rgb 512 512
+vchangecamera proj persp
+vfit
+set aTitle "persp"
+vdump $imagedir/${casename}_${aTitle}.png rgb 512 512
+vchangecamera proj stereo
+set aTitle "stereoR"
+vdump $imagedir/${casename}_${aTitle}.png rgb 512 512 R
+set aTitle "stereoL"
+vdump $imagedir/${casename}_${aTitle}.png rgb 512 512 L
+
+# test context stereo mode swicthing
+# if not supported by hardware it must not crash
+vstereo 1
+vclose all
+vinit
+vdisplay b
+vchangecamera proj stereo
+vfit
+set aTitle "afterSwitch"
+vdump $imagedir/${casename}_${aTitle}.png rgb 512 512 R
+
vinit
box b 100 900 300
vdisplay b
-vfit
OCC280 0 0
# selected point
-set x_coord 218
-set y_coord 196
+set x_coord 22
+set y_coord 230
+
+vfit
# There is not selection
puts "There is not selection"
OCC280 0 1
-set x_coord 10
-set y_coord 240
+set x_coord 22
+set y_coord 230
puts "Before View->FitAll()"
vfit
-set x1 165
-set y1 109
+set x1 135
+set y1 170
-set x2 380
-set y2 26
+set x2 314
+set y2 97
-set x3 215
-set y3 130
+set x3 172
+set y3 184
-set x4 31
-set y4 199
+set x4 32
+set y4 241
-set x5 188
-set y5 254
+set x5 156
+set y5 263
-set x6 351
-set y6 177
+set x6 305
+set y6 186
-set x7 216
-set y7 287
+set x7 186
+set y7 280
-set x8 22
-set y8 373
+set x8 54
+set y8 342
-set x9 2
-set y9 249
+set x9 32
+set y9 286
-set x10 345
-set y10 92
+set x10 295
+set y10 142
-set x11 393
-set y11 109
+set x11 322
+set y11 153
-set x12 52
-set y12 284
+set x12 56
+set y12 305
#
# ___________2________________
vfit
-set x1 165
-set y1 109
+set x1 135
+set y1 170
-set x2 380
-set y2 26
+set x2 314
+set y2 97
-set x3 215
-set y3 130
+set x3 172
+set y3 184
-set x4 31
-set y4 199
+set x4 32
+set y4 241
-set x5 188
-set y5 254
+set x5 156
+set y5 263
-set x6 351
-set y6 177
+set x6 305
+set y6 186
-set x7 216
-set y7 287
+set x7 186
+set y7 280
-set x8 22
-set y8 373
+set x8 54
+set y8 342
-set x9 2
-set y9 249
+set x9 32
+set y9 286
-set x10 345
-set y10 92
+set x10 295
+set y10 142
-set x11 393
-set y11 109
+set x11 322
+set y11 153
-set x12 52
-set y12 284
+set x12 56
+set y12 305
set Black_R 0
set Black_G 0
-puts "TODO ?OCC24130 Debian60-64: OCCT was compiled without OpenCL support!"
-puts "TODO ?OCC24130 Windows: TKOpenGl | Type\: Error | ID\: 0 | Severity\: High | Message\:"
-puts "TODO ?OCC24130 Debian60-64 Windows: OpenCL device info is unavailable!"
-
puts "========"
puts "OCC24130 Implementing ray tracing visualization core"
puts "========"
-puts "TODO ?OCC24130 Windows: TKOpenGl | Type\: Error | ID\: 0 | Severity\: High | Message\:"
-puts "TODO ?OCC24130 Debian60-64 Windows: OpenCL device info is unavailable!"
-
puts "========"
puts "Ray Tracing - check rendering of multi-connected structures"
puts "========"
vconnectsh b1c -3 0 0 1 0 0 0 0 1 b1 b2
vfit
vrotate 0.2 0.0 0.0
+vfit
vclear
vconnectsh b1c -3 0 0 1 0 0 0 0 1 b1 b2
-puts "TODO ?OCC24130 Windows: TKOpenGl | Type\: Error | ID\: 0 | Severity\: High | Message\:"
-puts "TODO ?OCC24130 Debian60-64 Windows: OpenCL device info is unavailable!"
-
puts "========"
puts "Ray Tracing - check lighting on Plastic material"
puts "========"