1
0
mirror of https://git.dev.opencascade.org/repos/occt.git synced 2025-04-04 18:06:22 +03:00

0024001: Stereographic rendering support

Deleted TODOs which were used when branch was built without OpenCL.
Modified test case bugs/vis/bug23747_2 (changed textured shape)
This commit is contained in:
duv 2014-01-23 14:44:31 +04:00 committed by bugmaster
parent 1190746b3c
commit b5ac8292b0
99 changed files with 5345 additions and 7308 deletions

View File

@ -90,6 +90,8 @@ BEGIN
SEPARATOR
BUTTON ID_FILE_EXPORT_IMAGE
SEPARATOR
BUTTON ID_BUTTON_STEREO
SEPARATOR
BUTTON ID_APP_ABOUT
END
@ -264,6 +266,11 @@ BEGIN
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
/////////////////////////////////////////////////////////////////////////////

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.1 KiB

After

Width:  |  Height:  |  Size: 3.2 KiB

View File

@ -135,6 +135,7 @@ void CAnimationView3D::OnInitialUpdate()
aViewer = GetDocument()->GetViewer();
aViewer->SetDefaultTypeOfView (V3d_PERSPECTIVE);
myView = aViewer->CreateView();
// store for restore state after rotation (witch is in Degenerated mode)
@ -156,8 +157,6 @@ void CAnimationView3D::OnInitialUpdate()
/* 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;
@ -892,37 +891,37 @@ void CAnimationView3D::Twist (int x , int /*y*/)
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()
@ -958,9 +957,9 @@ 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 ;

View File

@ -59,7 +59,7 @@ public:
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);
@ -138,8 +138,6 @@ private:
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 ;

View File

@ -210,7 +210,6 @@ enum CurrentAction3d {
#include "HLRAlgo_Projector.hxx"
#include "Aspect_MarkMap.hxx"
#include <V3d_PerspectiveView.hxx>
#include <Geom_BSplineSurface.hxx>
#include <TopoDS_Face.hxx>
#include <TopoDS_Solid.hxx>

View File

@ -9,7 +9,11 @@
#include <res\OCC_Resource.h>
#include <Visual3d_View.hxx>
#include <Graphic3d_ExportFormat.hxx>
#include <Graphic3d_Camera.hxx>
#include <OpenGl_GraphicDriver.hxx>
#define ValZWMin 1
@ -31,6 +35,7 @@ BEGIN_MESSAGE_MAP(OCC_3dView, CView)
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)
@ -49,6 +54,7 @@ BEGIN_MESSAGE_MAP(OCC_3dView, CView)
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()
@ -73,9 +79,13 @@ OCC_3dView::OCC_3dView()
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)
@ -97,15 +107,27 @@ void OCC_3dView::OnInitialUpdate()
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*/)
@ -600,3 +622,33 @@ void OCC_3dView::OnModifyChangeBackground()
}
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);
}
}

View File

@ -11,6 +11,7 @@
#include "OCC_BaseView.h"
#include "OCC_3dDoc.h"
#include "OCC_StereoConfigDlg.h"
#include <Standard_Macro.hxx>
enum CurAction3d {
@ -81,6 +82,8 @@ protected:
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()
@ -111,6 +114,11 @@ protected:
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

View File

@ -5,11 +5,13 @@
#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"
/////////////////////////////////////////////////////////////////////////////
@ -24,6 +26,8 @@ BEGIN_MESSAGE_MAP(OCC_App, CWinApp)
// 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()
/////////////////////////////////////////////////////////////////////////////
@ -174,3 +178,57 @@ void OCC_App::SetSampleName(LPCTSTR Name)
{
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);
}

View File

@ -27,11 +27,13 @@ public:
}
// 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;

View File

@ -66,4 +66,40 @@ OCC_BaseDoc::OCC_BaseDoc()
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);
}

View File

@ -68,6 +68,11 @@ public:
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;

View File

@ -0,0 +1,248 @@
///////////////////////////////////////////////////////////////////////////////
// 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;
}

View File

@ -0,0 +1,55 @@
///////////////////////////////////////////////////////////////////////////////
// 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

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.2 KiB

After

Width:  |  Height:  |  Size: 3.5 KiB

Binary file not shown.

View File

@ -5,6 +5,7 @@
#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
@ -62,10 +63,17 @@
#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
@ -140,6 +148,9 @@
#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
@ -180,8 +191,8 @@
#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

View File

@ -280,6 +280,25 @@ BEGIN
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
@ -345,6 +364,8 @@ BEGIN
BUTTON ID_BUTTONRot
BUTTON ID_BUTTONReset
SEPARATOR
BUTTON ID_BUTTON_STEREOCONFIG
SEPARATOR
BUTTON ID_BUTTONHlrOff
BUTTON ID_BUTTONHlrOn
END
@ -486,6 +507,14 @@ BEGIN
HORZGUIDE, 336
END
IDD_DIALOG_STEREO, DIALOG
BEGIN
LEFTMARGIN, 7
RIGHTMARGIN, 159
TOPMARGIN, 7
BOTTOMMARGIN, 170
END
IDD_ParamsFacesPage, DIALOG
BEGIN
LEFTMARGIN, 7
@ -657,6 +686,12 @@ BEGIN
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
/////////////////////////////////////////////////////////////////////////////

View File

@ -292,6 +292,22 @@
<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" />
@ -739,6 +755,7 @@
<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" />

View File

@ -120,6 +120,9 @@
<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>
@ -232,6 +235,9 @@
<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>

View File

@ -525,6 +525,22 @@
<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>
@ -747,6 +763,7 @@
<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" />

View File

@ -84,6 +84,9 @@
<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>
@ -196,6 +199,9 @@
<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>

View File

@ -1168,6 +1168,10 @@
/>
</FileConfiguration>
</File>
<File
RelativePath="..\..\..\..\Common\OCC_StereoConfigDlg.cpp"
>
</File>
<File
RelativePath="..\..\..\..\Common\RadiusParamsPage.cpp"
>
@ -1839,6 +1843,10 @@
RelativePath="..\..\..\..\Common\res\OCC_Resource.h"
>
</File>
<File
RelativePath="..\..\..\..\Common\OCC_StereoConfigDlg.h"
>
</File>
<File
RelativePath="..\..\..\..\Common\RadiusParamsPage.h"
>

View File

@ -1169,6 +1169,10 @@
/>
</FileConfiguration>
</File>
<File
RelativePath="..\..\..\..\Common\OCC_StereoConfigDlg.cpp"
>
</File>
<File
RelativePath="..\..\..\..\Common\RadiusParamsPage.cpp"
>
@ -1840,6 +1844,10 @@
RelativePath="..\..\..\..\Common\res\OCC_Resource.h"
>
</File>
<File
RelativePath="..\..\..\..\Common\OCC_StereoConfigDlg.h"
>
</File>
<File
RelativePath="..\..\..\..\Common\RadiusParamsPage.h"
>

View File

@ -71,3 +71,6 @@ Graphic3d_ClipPlane.cxx
Graphic3d_ClipPlane_Handle.hxx
Graphic3d_SequenceOfHClipPlane.hxx
Graphic3d_SequenceOfHClipPlane_Handle.hxx
Graphic3d_Camera.cxx
Graphic3d_Camera.hxx
Graphic3d_Camera_Handle.hxx

View File

@ -411,6 +411,7 @@ is
imported MarkerImage;
imported MarkerImage_Handle;
imported Camera_Handle;
primitive PtrFrameBuffer;
primitive Vec2;

View File

@ -17,6 +17,9 @@
#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>
@ -71,6 +74,8 @@ public:
int SurfaceDetail;
Graphic3d_SequenceOfHClipPlane ClipPlanes;
Handle(Graphic3d_Camera) Camera;
};
class Graphic3d_CView
@ -88,7 +93,7 @@ public:
ptrUnderLayer (NULL),
ptrOverLayer (NULL),
Backfacing (0),
GContext (NULL),
GContext (NULL),
GDisplayCB (NULL),
GClientData (NULL),
ptrFBO (NULL),
@ -98,11 +103,7 @@ public:
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:
@ -116,12 +117,6 @@ 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;

View File

@ -0,0 +1,917 @@
// 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);
}

View File

@ -0,0 +1,558 @@
// 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

View File

@ -0,0 +1,22 @@
// 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

View File

@ -123,13 +123,6 @@ is
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;
@ -325,50 +318,6 @@ is
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;
@ -402,6 +351,10 @@ is
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;
@ -431,18 +384,6 @@ is
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;

View File

@ -92,5 +92,4 @@ NCollection_DefineAlloc.hxx
NCollection_Vec2.hxx
NCollection_Vec3.hxx
NCollection_Vec4.hxx
NCollection_Mat4.hxx

View File

@ -17,11 +17,11 @@
#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

View File

@ -23,8 +23,8 @@
#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()
@ -33,7 +33,7 @@ IMPLEMENT_STANDARD_RTTIEXT (NIS_View, V3d_OrthographicView)
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)
{
@ -107,78 +107,109 @@ void NIS_View::RemoveContext (NIS_InteractiveContext * theCtx)
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() };
// Fit depth
const gp_XYZ& aBMin = aCorner[0];
const gp_XYZ& aBMax = aCorner[1];
gp_Pnt anAABBCenter ((aBMin.X() + aBMax.X()) * 0.5,
(aBMin.Y() + aBMax.Y()) * 0.5,
(aBMin.Z() + aBMax.Z()) * 0.5);
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) {
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());
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);
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;
}
}
else {
Umin = Umax = U;
Vmin = Vmax = V;
if ( (Umax > Umin) && (Vmax > Vmin) )
{
gp_Pnt ViewDims = myCamera->ViewDimensions();
Standard_Real DxvOld = ViewDims.X();
Standard_Real Xrp, Yrp, DxvNew, DyvNew;
DxvNew = Abs(Umax - Umin); DyvNew = Abs(Vmax - Vmin);
DxvNew *= (1. + theCoef);
DyvNew *= (1. + theCoef);
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. ;
// 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;
}
aResult = Standard_True;
}
else
{
doFit = Standard_False;
}
}
if ( (Umax > Umin) && (Vmax > Vmin) ) {
Standard_Real OldUmin,OldUmax,OldVmin,OldVmax;
MyViewMapping.WindowLimit(OldUmin, OldVmin, OldUmax, OldVmax);
Standard_Real DxvOld = Abs(OldUmax - OldUmin);
// make a margin
Standard_Real Xrp, Yrp, DxvNew, DyvNew;
DxvNew = Abs(Umax - Umin); DyvNew = Abs(Vmax - Vmin);
DxvNew *= (1. + theCoef);
DyvNew *= (1. + theCoef);
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. ;
// 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;
aResult = Standard_True;
}
else doFit = Standard_False;
if (!aResult)
{
myCamera->BeginUpdate();
myCamera->SetCenter (aCenterBefore);
myCamera->SetEye (anEyeBefore);
myCamera->EndUpdate();
}
}

View File

@ -17,7 +17,7 @@
#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>
@ -31,7 +31,7 @@ class gp_Ax1;
/**
* 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>
@ -53,7 +53,7 @@ class gp_Ax1;
* AddContext and RemoveContext.
*/
class NIS_View : public V3d_OrthographicView
class NIS_View : public V3d_View
{
public:
// ---------- PUBLIC METHODS ----------

View File

@ -43,7 +43,6 @@ OpenGl_Workspace_5.cxx
Handle_OpenGl_View.hxx
OpenGl_View.hxx
OpenGl_View.cxx
OpenGl_View_1.cxx
OpenGl_View_2.cxx
OpenGl_Light.hxx
OpenGl_Trihedron.hxx
@ -70,8 +69,6 @@ OpenGl_PriorityList.cxx
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

View File

@ -100,8 +100,10 @@ OpenGl_Context::OpenGl_Context (const Handle(OpenGl_Caps)& theCaps)
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
@ -193,6 +195,103 @@ Standard_Integer OpenGl_Context::MaxClipPlanes() const
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 :
@ -658,6 +757,11 @@ void OpenGl_Context::init()
// 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);
@ -1003,23 +1107,6 @@ void OpenGl_Context::init()
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

View File

@ -33,6 +33,7 @@
#include <TCollection_AsciiString.hxx>
#include <Handle_OpenGl_Context.hxx>
#include <OpenGl_Clipping.hxx>
#include <OpenGl_GlCore11.hxx>
//! Forward declarations
struct OpenGl_GlCore12;
@ -195,11 +196,17 @@ public:
//! 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.
@ -305,6 +312,36 @@ public:
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.
@ -370,15 +407,17 @@ private: // context info
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

View File

@ -50,7 +50,6 @@ OpenGl_Display::OpenGl_Display (const Handle(Aspect_DisplayConnection)& theDispl
myDBuffer(Standard_True),
myDither(Standard_True),
myBackDither(Standard_False),
myWalkthrough(Standard_False),
mySymPerspective(Standard_False),
myOffsetFactor(1.F),
myOffsetUnits(0.F),
@ -138,9 +137,6 @@ void OpenGl_Display::Init()
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;

View File

@ -56,7 +56,6 @@ public:
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
{
@ -91,7 +90,6 @@ public:
Standard_Boolean myDBuffer;
Standard_Boolean myDither;
Standard_Boolean myBackDither;
Standard_Boolean myWalkthrough;
Standard_Boolean mySymPerspective;
Standard_ShortReal myOffsetFactor;
Standard_ShortReal myOffsetUnits;

View File

@ -92,7 +92,7 @@ void OpenGl_Flipper::Render (const Handle(OpenGl_Workspace)& theWorkspace) const
{ 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
{
@ -114,8 +114,8 @@ void OpenGl_Flipper::Render (const Handle(OpenGl_Workspace)& theWorkspace) const
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)

View File

@ -106,7 +106,6 @@ public:
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);
@ -155,22 +154,18 @@ public:
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);

View File

@ -25,13 +25,6 @@ Standard_Integer OpenGl_GraphicDriver::InquireLightLimit ()
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);

View File

@ -135,54 +135,6 @@ void OpenGl_GraphicDriver::DepthCueing (const Graphic3d_CView& ACView, const Sta
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;
@ -514,6 +466,19 @@ void OpenGl_GraphicDriver::SetClipPlanes (const Graphic3d_CStructure& theCStruct
}
}
//=======================================================================
//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;
@ -568,32 +533,6 @@ Standard_Boolean OpenGl_GraphicDriver::View (Graphic3d_CView& theCView)
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;

View File

@ -154,7 +154,7 @@ void OpenGl_ShaderManager::UpdateLightSourceStateTo (const OpenGl_ListOfLight* t
// 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();
@ -164,7 +164,7 @@ void OpenGl_ShaderManager::UpdateProjectionStateTo (const Tmatrix3& theProjectio
// 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();
@ -174,7 +174,7 @@ void OpenGl_ShaderManager::UpdateModelWorldStateTo (const Tmatrix3& theModelWorl
// 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();
@ -184,7 +184,7 @@ void OpenGl_ShaderManager::UpdateWorldViewStateTo (const Tmatrix3& theWorldViewM
// 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();
@ -194,7 +194,7 @@ void OpenGl_ShaderManager::RevertProjectionStateTo (const Tmatrix3& theProjectio
// 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();
@ -204,7 +204,7 @@ void OpenGl_ShaderManager::RevertModelWorldStateTo (const Tmatrix3& theModelWorl
// 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();

View File

@ -90,10 +90,10 @@ public:
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;
@ -104,10 +104,10 @@ public:
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;
@ -118,10 +118,10 @@ public:
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;

View File

@ -71,7 +71,7 @@ OpenGl_ProjectionState::OpenGl_ProjectionState()
// 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;
@ -116,7 +116,7 @@ OpenGl_ModelWorldState::OpenGl_ModelWorldState()
// 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;
@ -161,7 +161,7 @@ OpenGl_WorldViewState::OpenGl_WorldViewState()
// 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;

View File

@ -53,7 +53,7 @@ public:
OpenGl_ProjectionState();
//! Sets new projection matrix.
void Set (const Tmatrix3& theProjectionMatrix);
void Set (const Tmatrix3* theProjectionMatrix);
//! Returns current projection matrix.
const Tmatrix3& ProjectionMatrix() const;
@ -78,7 +78,7 @@ public:
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;
@ -103,7 +103,7 @@ public:
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;

View File

@ -617,9 +617,9 @@ void OpenGl_Structure::Render (const Handle(OpenGl_Workspace) &AWorkspace) 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);
@ -767,7 +767,7 @@ void OpenGl_Structure::Render (const Handle(OpenGl_Workspace) &AWorkspace) const
{ 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
{

View File

@ -110,9 +110,26 @@ void OpenGl_Trihedron::redraw (const Handle(OpenGl_Workspace)& theWorkspace) con
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);
@ -303,9 +320,26 @@ void OpenGl_Trihedron::redrawZBuffer (const Handle(OpenGl_Workspace)& theWorkspa
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);

View File

@ -42,34 +42,6 @@ static const OPENGL_BG_TEXTURE myDefaultBgTexture = { 0, 0, 0, Aspect_FM_CENTERE
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 };
@ -89,15 +61,13 @@ OpenGl_View::OpenGl_View (const CALL_DEF_VIEWCONTEXT &AContext,
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),
@ -106,14 +76,11 @@ OpenGl_View::OpenGl_View (const CALL_DEF_VIEWCONTEXT &AContext,
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)
@ -127,8 +94,6 @@ OpenGl_View::OpenGl_View (const CALL_DEF_VIEWCONTEXT &AContext,
break;
}
myCurrOrientationState = myStateCounter->Increment(); // <-- delete after merge with camera
myCurrViewMappingState = myStateCounter->Increment(); // <-- delete after merge with camera
myCurrLightSourceState = myStateCounter->Increment();
#ifdef HAVE_OPENCL
@ -240,21 +205,8 @@ void OpenGl_View::SetVisualisation (const CALL_DEF_VIEWCONTEXT &AContext)
//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);
@ -262,138 +214,6 @@ void OpenGl_View::SetClipLimit (const Graphic3d_CView& theCView)
/*----------------------------------------------------------------------*/
//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)
{
@ -405,29 +225,8 @@ void OpenGl_View::SetFog (const Graphic3d_CView& theCView,
{
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;
@ -495,8 +294,8 @@ void OpenGl_View::EndTransformPersistence(const Handle(OpenGl_Context)& theCtx)
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);
}
}
@ -581,9 +380,10 @@ const TEL_TRANSFORM_PERSISTENCE* OpenGl_View::BeginTransformPersistence (const H
// 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;
@ -659,8 +459,28 @@ const TEL_TRANSFORM_PERSISTENCE* OpenGl_View::BeginTransformPersistence (const H
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];
}
}
}
/*----------------------------------------------------------------------*/

View File

@ -36,7 +36,6 @@
#include <Graphic3d_SequenceOfHClipPlane.hxx>
#include <Visual3d_TypeOfSurfaceDetail.hxx>
#include <OpenGl_telem_view.hxx>
#include <OpenGl_LayerList.hxx>
#include <OpenGl_Light.hxx>
@ -62,15 +61,6 @@ struct OPENGL_BG_GRADIENT
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 {
@ -91,6 +81,7 @@ struct OPENGL_FOG
TEL_COLOUR Color;
};
struct OpenGl_Matrix;
class OpenGl_GraduatedTrihedron;
class OpenGl_Structure;
class OpenGl_Trihedron;
@ -114,9 +105,9 @@ class OpenGl_View : public MMgt_TShared
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);
@ -131,22 +122,8 @@ class OpenGl_View : public MMgt_TShared
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; }
@ -202,6 +179,9 @@ class OpenGl_View : public MMgt_TShared
//! 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; }
@ -218,6 +198,20 @@ public:
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
@ -225,22 +219,12 @@ public:
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;
@ -263,10 +247,11 @@ public:
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;

View File

@ -1,254 +0,0 @@
// 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;
}
}
}
}
/*----------------------------------------------------------------------*/

File diff suppressed because it is too large Load Diff

View File

@ -13,7 +13,7 @@
// 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>
@ -24,6 +24,7 @@
#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)
@ -168,6 +169,21 @@ OpenGl_Window::OpenGl_Window (const Handle(OpenGl_Display)& theDisplay,
}
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);
@ -395,7 +411,8 @@ OpenGl_Window::OpenGl_Window (const Handle(OpenGl_Display)& theDisplay,
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;
@ -406,13 +423,18 @@ OpenGl_Window::OpenGl_Window (const Handle(OpenGl_Display)& theDisplay,
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;
@ -444,9 +466,29 @@ OpenGl_Window::OpenGl_Window (const Handle(OpenGl_Display)& theDisplay,
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.");
@ -773,20 +815,32 @@ void OpenGl_Window::DisableFeatures() const
* 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
}
}
// =======================================================================

View File

@ -553,12 +553,10 @@ void OpenGl_Workspace::Redraw (const Graphic3d_CView& theCView,
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)
@ -619,5 +617,5 @@ void OpenGl_Workspace::Redraw (const Graphic3d_CView& theCView,
#endif
// reset render mode state
aGlCtx->SetFeedback (Standard_False);
aGlCtx->FetchState();
}

View File

@ -215,23 +215,7 @@ static void getMaxFrameSize(Standard_Integer& theWidth,
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
@ -389,9 +373,10 @@ Standard_Boolean OpenGl_Workspace::Print
}
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

View File

@ -266,11 +266,11 @@ const OpenGl_Matrix * OpenGl_Workspace::SetStructureMatrix (const OpenGl_Matrix
{
if (aRevert)
{
myGlContext->ShaderManager()->RevertModelWorldStateTo (lmat.mat);
myGlContext->ShaderManager()->RevertModelWorldStateTo (&lmat.mat);
}
else
{
myGlContext->ShaderManager()->UpdateModelWorldStateTo (lmat.mat);
myGlContext->ShaderManager()->UpdateModelWorldStateTo (&lmat.mat);
}
}

View File

@ -1957,13 +1957,23 @@ void GenerateCornerRays (const GLdouble theInvModelProj[16],
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() +
@ -2007,7 +2017,7 @@ Standard_Boolean OpenGl_Workspace::Raytrace (const Graphic3d_CView& theCView,
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];

View File

@ -1,343 +0,0 @@
// 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);
}

View File

@ -1,84 +0,0 @@
// 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

View File

@ -25,7 +25,6 @@
#include <PrsMgr_Prs.hxx>
#include <PrsMgr_ModedPresentation.hxx>
#include <Visual3d_View.hxx>
#include <Visual3d_ViewOrientation.hxx>
#include <Graphic3d_Structure.hxx>
#include <Precision.hxx>
@ -343,25 +342,26 @@ void PrsMgr_Presentation3d::Compute(const Handle(Graphic3d_DataStructureManager)
//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;
}

View File

@ -37,25 +37,8 @@
//=======================================================================
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();
}
//=======================================================================
@ -413,15 +396,46 @@ gp_Lin Select3D_Projector::Shoot
{
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;
}

View File

@ -29,7 +29,6 @@
#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)

View File

@ -25,7 +25,6 @@
#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>
@ -436,29 +435,8 @@ Standard_Boolean StdSelect_ViewerSelector3d::UpdateProj(const Handle(V3d_View)&
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 (aView);
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);
}
if (Abs (aView->Scale() - mylastzoom) > 1.e-3)

View File

@ -30,17 +30,6 @@ package V3d
-- 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,
@ -170,6 +159,17 @@ is
-- 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
------------------------
@ -180,12 +180,6 @@ is
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.

View File

@ -1,63 +0,0 @@
-- 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;

View File

@ -1,70 +0,0 @@
// 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);}

View File

@ -1,106 +0,0 @@
-- 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;

View File

@ -1,148 +0,0 @@
// 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();
}

View File

@ -73,6 +73,8 @@ class View from V3d inherits TShared from MMgt
uses
-- S3892
Pnt from gp,
Dir from gp,
Ax3 from gp,
LayerMgr from V3d,
ColorScale from V3d,
@ -95,15 +97,15 @@ uses
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,
@ -142,10 +144,10 @@ raises
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
@ -401,6 +403,14 @@ is
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
@ -783,10 +793,6 @@ is
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
@ -872,13 +878,12 @@ is
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
@ -893,6 +898,10 @@ is
-- 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
@ -931,10 +940,6 @@ is
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
@ -1288,42 +1293,17 @@ is
---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:
@ -1489,7 +1469,8 @@ is
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
@ -1497,6 +1478,9 @@ is
-- 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 )
@ -1576,6 +1560,55 @@ is
---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
@ -1610,13 +1643,18 @@ is
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 ;
@ -1654,6 +1692,15 @@ fields
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 ),

File diff suppressed because it is too large Load Diff

View File

@ -22,8 +22,6 @@
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.
************************************************************************/
@ -43,90 +41,53 @@
/*----------------------------------------------------------------------*/
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();
}
@ -148,43 +109,41 @@ void V3d_View::Move(const V3d_TypeOfAxe Axe , const Standard_Real Length, const
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");
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");
}
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) ;
}
#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();
}
@ -204,39 +163,25 @@ void V3d_View::Translate(const V3d_TypeOfAxe Axe, const Standard_Real Length,con
}
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() ;
void V3d_View::Translate(const Standard_Real theLength, const Standard_Boolean theStart) {
Standard_Real aVx, aVy, aVz ;
if (theStart)
{
myCamStartOpCenter = myCamera->Center() ;
}
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) ;
}
#endif
MyDefaultViewAxis.Coord (aVx, aVy, aVz);
gp_Pnt aNewCenter (myCamStartOpCenter.XYZ() - gp_Pnt (aVx, aVy, aVz).XYZ() * theLength);
myCamera->SetCenter (aNewCenter);
AutoZFit();
ImmediateUpdate();
}

View File

@ -63,243 +63,236 @@
void V3d_View::SetGrid (const gp_Ax3& aPlane, const Handle(Aspect_Grid)& aGrid)
{
MyPlane = aPlane;
MyGrid = 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 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 ());
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 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;
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;
}
}
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;
}
return NewPoint;
}
Standard_Boolean IsRectangular =
MyGrid->IsKind (STANDARD_TYPE (Aspect_RectangularGrid));
Standard_Boolean IsRectangular =
MyGrid->IsKind (STANDARD_TYPE (Aspect_RectangularGrid));
Graphic3d_Vertex P1;
Graphic3d_Vertex P1;
Standard_Real XO = 0.0, YO = 0.0;
Standard_Real XOp, YOp;
Standard_Real XAp, YAp;
Standard_Real XBp, YBp;
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();
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;
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();
if (IsRectangular) {
Standard_Real XS, YS;
Handle(Aspect_RectangularGrid) theGrid =
*(Handle(Aspect_RectangularGrid) *) &MyGrid;
XS = theGrid->XStep (), YS = theGrid->YStep ();
// get grid normal
MyPlane.Direction().Coord (x2, y2, z2);
gp_Vec aPlaneNormal (x2, y2, z2);
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;
gp_Vec aPointOnPlane = gp_Vec (0.0, 0.0, 0.0);
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;
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 Determin = XAp*YBp - XBp*YAp;
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);
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 aT = - aPointOnCamera.Dot (aPlaneNormal) /
aPointFromCamera.Dot (aPlaneNormal);
aPointOnPlane = aPointOnCamera + aPointFromCamera * aT;
}
Standard_Real DistOP = Sqrt (XPp*XPp + YPp*YPp);
if (IsRectangular) {
Standard_Real XS, YS;
Handle(Aspect_RectangularGrid) theGrid =
*(Handle(Aspect_RectangularGrid) *) &MyGrid;
XS = theGrid->XStep (), YS = theGrid->YStep ();
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;
}
// 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);
} // for (i=1; i<=DN*2; i++)
// 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());
Standard_Real DistOCur = Sqrt (XCurp*XCurp + YCurp*YCurp);
}
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);
// Determination of the circle of the grid closest to P
Standard_Integer N = Standard_Integer (DistOP / DistOCur + 0.5);
Standard_Real Radius = N * RS;
// project point on plane to grid local space
gp_Vec aToPoint (gp_Pnt (x0, y0, z0),
gp_Pnt (aPointOnPlane.X(), aPointOnPlane.Y(), aPointOnPlane.Z()));
X1 = Cos (Alpha * ICur) * Radius,
Y1 = Sin (Alpha * ICur) * Radius,
Z1 = 0.0;
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);
// 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
// clamp point to grid
Standard_Real anRSteps = Round (anR / RS);
Standard_Real aPhiSteps = Round (aPhi / Alpha);
toCartesianCoords (anRSteps * RS, aPhiSteps * Alpha, aLocalX, aLocalY);
NewPoint.SetCoord (CurPoint.X (), CurPoint.Y (), CurPoint.Z ());
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);
}
@ -307,17 +300,17 @@ void V3d_View::ZBufferTriedronSetup(const Quantity_NameOfColor XColor,
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 */

View File

@ -61,8 +61,6 @@ uses
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,

View File

@ -43,8 +43,6 @@
#include <V3d_Viewer.ixx>
#include <V3d_View.hxx>
#include <V3d_BadValue.hxx>
#include <V3d_OrthographicView.hxx>
#include <V3d_PerspectiveView.hxx>
/*----------------------------------------------------------------------*/
@ -108,11 +106,9 @@ myDisplayPlaneLength (theViewSize)
//-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( ) {

View File

@ -785,7 +785,7 @@ static Standard_Integer VDump (Draw_Interpretor& di, Standard_Integer argc, cons
{
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;
}
@ -810,6 +810,8 @@ static Standard_Integer VDump (Draw_Interpretor& di, Standard_Integer argc, cons
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);
@ -829,8 +831,24 @@ static Standard_Integer VDump (Draw_Interpretor& di, Standard_Integer argc, cons
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;
@ -3412,10 +3430,10 @@ void ViewerTest::Commands(Draw_Interpretor& theCommands)
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);

View File

@ -3179,7 +3179,7 @@ static int VPrintView (Draw_Interpretor& di, Standard_Integer argc,
{
#ifndef WNT
di << "Printing implemented only for wnt!\n";
return 1;
return 0;
#else
Handle(AIS_InteractiveContext) aContextAIS = NULL;
@ -3202,12 +3202,13 @@ static int VPrintView (Draw_Interpretor& di, Standard_Integer argc,
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;
}
@ -3217,9 +3218,19 @@ static int VPrintView (Draw_Interpretor& di, Standard_Integer argc,
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)
{
@ -3257,7 +3268,24 @@ static int VPrintView (Draw_Interpretor& di, Standard_Integer argc,
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)
@ -4370,11 +4398,13 @@ static Standard_Integer VViewParams (Draw_Interpretor& di,
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;
}
@ -5312,6 +5342,223 @@ static int VSetTextureMode (Draw_Interpretor& theDi, Standard_Integer theArgsNb,
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 :
@ -6115,7 +6362,7 @@ void ViewerTest::ViewerCommands(Draw_Interpretor& theCommands)
"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",
@ -6147,6 +6394,9 @@ void ViewerTest::ViewerCommands(Draw_Interpretor& theCommands)
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);
@ -6188,6 +6438,31 @@ void ViewerTest::ViewerCommands(Draw_Interpretor& theCommands)
__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);

View File

@ -259,18 +259,6 @@ is
---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

View File

@ -84,14 +84,13 @@ uses
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,
@ -136,15 +135,6 @@ is
---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
---------------------------------------------------
@ -308,13 +298,6 @@ is
-- 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
@ -323,13 +306,6 @@ is
-- 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
@ -710,36 +686,24 @@ is
---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 &
DefaultCamera (me)
returns Camera_Handle from Graphic3d
is static;
---Level: Public
---Purpose: @return the default camera of <me>.
---C++: return const &
ViewMapping ( me )
returns ViewMapping from Visual3d
is static;
---Level: Public
---Purpose: Returns the current mapping of the view <me>.
Camera (me)
returns Camera_Handle from Graphic3d
is static;
---Level: Public
---Purpose: @return the camera of <me>.
---C++: return const &
ViewMappingDefault ( me )
returns ViewMapping from Visual3d
is static;
---Level: Public
---Purpose: Returns the current reset mapping of the view <me>.
ViewOrientation ( me )
returns ViewOrientation from Visual3d
is static;
---Level: Public
---Purpose: Returns the current orientation of the view <me>.
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
@ -923,22 +887,6 @@ is
-- 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
@ -1181,9 +1129,6 @@ fields
-- Reminder : A view is defined by:
-- - a ViewManager
-- - a ContextView
-- - a ViewMapping
-- - a ViewOrientation
--
-- the associated C structure
MyCView : CView from Graphic3d;
@ -1191,28 +1136,9 @@ fields
-- 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;
@ -1238,6 +1164,8 @@ fields
MyGTrihedron : CGraduatedTrihedron from Graphic3d;
myDefaultCamera : Camera_Handle from Graphic3d;
friends
class ViewManager from Visual3d

File diff suppressed because it is too large Load Diff

View File

@ -119,55 +119,6 @@ is
---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;

View File

@ -505,433 +505,6 @@ Visual3d_SetIteratorOfSetOfView MyIterator(MyDefinedView);
}
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;

View File

@ -1,299 +0,0 @@
-- 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
--
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;

View File

@ -1,335 +0,0 @@
// 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();
}

View File

@ -1,256 +0,0 @@
-- 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
--
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;

View File

@ -1,253 +0,0 @@
// 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;
}

View File

@ -1,53 +1,53 @@
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
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 348
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

View File

@ -1,53 +1,53 @@
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
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 348
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

45
tests/bugs/vis/bug22337 Normal file
View File

@ -0,0 +1,45 @@
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

View File

@ -7,7 +7,7 @@ puts ""
vinit
vclear
vaxo
box b 10 20 30
psphere b 20
vdisplay b
vsetdispmode b 1
vfit

43
tests/bugs/vis/bug24001 Normal file
View File

@ -0,0 +1,43 @@
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

View File

@ -6,13 +6,14 @@ puts "========"
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"

View File

@ -10,8 +10,8 @@ vsetdispmode b 1
OCC280 0 1
set x_coord 10
set y_coord 240
set x_coord 22
set y_coord 230
puts "Before View->FitAll()"

View File

@ -12,41 +12,41 @@ OCC280 1 0
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________________

View File

@ -12,41 +12,41 @@ OCC280 1 1
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

View File

@ -1,7 +1,3 @@
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 "========"

View File

@ -1,6 +1,3 @@
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 "========"
@ -18,6 +15,7 @@ vaxo
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

View File

@ -1,6 +1,3 @@
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 "========"