diff --git a/samples/mfc/standard/04_Viewer3d/src/OCCDemo_Presentation.cpp b/samples/mfc/standard/04_Viewer3d/src/OCCDemo_Presentation.cpp index a0b2baacdb..d49d65f834 100755 --- a/samples/mfc/standard/04_Viewer3d/src/OCCDemo_Presentation.cpp +++ b/samples/mfc/standard/04_Viewer3d/src/OCCDemo_Presentation.cpp @@ -257,20 +257,20 @@ Handle_AIS_Shape OCCDemo_Presentation::drawShape return aGraphicShape; } -void OCCDemo_Presentation::GetViewCenter(V3d_Coordinate& Xc, V3d_Coordinate& Yc) +void OCCDemo_Presentation::GetViewAt (V3d_Coordinate& theX, V3d_Coordinate& theY, V3d_Coordinate& theZ) { - CMDIFrameWnd *pFrame = (CMDIFrameWnd*)AfxGetApp()->m_pMainWnd; - CMDIChildWnd *pChild = (CMDIChildWnd *) pFrame->GetActiveFrame(); - CViewer3dView *pView = (CViewer3dView *) pChild->GetActiveView(); - pView->GetViewCenter(Xc,Yc); + CMDIFrameWnd *pFrame = (CMDIFrameWnd*)AfxGetApp()->m_pMainWnd; + CMDIChildWnd *pChild = (CMDIChildWnd *) pFrame->GetActiveFrame(); + CViewer3dView *pView = (CViewer3dView *) pChild->GetActiveView(); + pView->GetViewAt (theX, theY, theZ); } -void OCCDemo_Presentation::SetViewCenter(V3d_Coordinate Xc, V3d_Coordinate Yc) +void OCCDemo_Presentation::SetViewAt (const V3d_Coordinate theX, const V3d_Coordinate theY, const V3d_Coordinate theZ) { - CMDIFrameWnd *pFrame = (CMDIFrameWnd*)AfxGetApp()->m_pMainWnd; - CMDIChildWnd *pChild = (CMDIChildWnd *) pFrame->GetActiveFrame(); - CViewer3dView *pView = (CViewer3dView *) pChild->GetActiveView(); - pView->SetViewCenter(Xc,Yc); + CMDIFrameWnd *pFrame = (CMDIFrameWnd*)AfxGetApp()->m_pMainWnd; + CMDIChildWnd *pChild = (CMDIChildWnd *) pFrame->GetActiveFrame(); + CViewer3dView *pView = (CViewer3dView *) pChild->GetActiveView(); + pView->SetViewAt (theX, theY, theZ); } void OCCDemo_Presentation::GetViewEye(V3d_Coordinate& X, V3d_Coordinate& Y, V3d_Coordinate& Z) diff --git a/samples/mfc/standard/04_Viewer3d/src/OCCDemo_Presentation.h b/samples/mfc/standard/04_Viewer3d/src/OCCDemo_Presentation.h index b523d7922f..7a19f5e9eb 100755 --- a/samples/mfc/standard/04_Viewer3d/src/OCCDemo_Presentation.h +++ b/samples/mfc/standard/04_Viewer3d/src/OCCDemo_Presentation.h @@ -50,10 +50,10 @@ public: void NextSample() {myIndex++;} void PrevSample() {myIndex--;} virtual void DoSample() = 0; - static void GetViewCenter(V3d_Coordinate& Xc, V3d_Coordinate& Yc); - static void SetViewCenter(const V3d_Coordinate Xc, const V3d_Coordinate Yc); - static void GetViewEye(V3d_Coordinate& X, V3d_Coordinate& Y, V3d_Coordinate& Z); - static void SetViewEye(V3d_Coordinate X, V3d_Coordinate Y, V3d_Coordinate Z); + static void GetViewAt (V3d_Coordinate& theX, V3d_Coordinate& theY, V3d_Coordinate& theZ); + static void SetViewAt (const V3d_Coordinate theX, const V3d_Coordinate theY, const V3d_Coordinate theZ); + static void GetViewEye (V3d_Coordinate& X, V3d_Coordinate& Y, V3d_Coordinate& Z); + static void SetViewEye (V3d_Coordinate X, V3d_Coordinate Y, V3d_Coordinate Z); static Quantity_Factor GetViewScale(); static void SetViewScale(Quantity_Factor Coef); static void ResetView(); diff --git a/samples/mfc/standard/04_Viewer3d/src/Viewer3dView.cpp b/samples/mfc/standard/04_Viewer3d/src/Viewer3dView.cpp index 32489d8514..2930111c6c 100755 --- a/samples/mfc/standard/04_Viewer3d/src/Viewer3dView.cpp +++ b/samples/mfc/standard/04_Viewer3d/src/Viewer3dView.cpp @@ -1183,14 +1183,14 @@ void CViewer3dView::Reset() } } -void CViewer3dView::GetViewCenter(V3d_Coordinate& Xc, V3d_Coordinate& Yc) +void CViewer3dView::GetViewAt (V3d_Coordinate& theX, V3d_Coordinate& theY, V3d_Coordinate& theZ) const { - myView->Center(Xc,Yc); + myView->At (theX, theY, theZ); } -void CViewer3dView::SetViewCenter(V3d_Coordinate Xc, V3d_Coordinate Yc) +void CViewer3dView::SetViewAt (const V3d_Coordinate theX, const V3d_Coordinate theY, const V3d_Coordinate theZ) { - myView->SetCenter(Xc,Yc); + myView->SetAt (theX, theY, theZ); } void CViewer3dView::GetViewEye(V3d_Coordinate& X, V3d_Coordinate& Y, V3d_Coordinate& Z) diff --git a/samples/mfc/standard/04_Viewer3d/src/Viewer3dView.h b/samples/mfc/standard/04_Viewer3d/src/Viewer3dView.h index 2cd175eda6..f634a7d9aa 100755 --- a/samples/mfc/standard/04_Viewer3d/src/Viewer3dView.h +++ b/samples/mfc/standard/04_Viewer3d/src/Viewer3dView.h @@ -39,17 +39,17 @@ protected: // create from serialization only DECLARE_DYNCREATE(CViewer3dView) public: - CViewer3dDoc* GetDocument(); - void Redraw() { myView->Redraw(); }; - void InitButtons(); - void Reset(); - void GetViewCenter(V3d_Coordinate& Xc, V3d_Coordinate& Yc); - void CViewer3dView::SetViewCenter(V3d_Coordinate Xc, V3d_Coordinate Yc); - void GetViewEye(V3d_Coordinate& X, V3d_Coordinate& Y, V3d_Coordinate& Z); - void SetViewEye(const V3d_Coordinate X,const V3d_Coordinate Y,const V3d_Coordinate Z); - Quantity_Factor GetViewScale(); - void SetViewScale(const Quantity_Factor Coef); - void FitAll() { myView->FitAll(); myView->ZFitAll(); }; + CViewer3dDoc* GetDocument(); + void Redraw() { myView->Redraw(); }; + void InitButtons(); + void Reset(); + void GetViewAt (V3d_Coordinate& theX, V3d_Coordinate& theY, V3d_Coordinate& theZ) const; + void SetViewAt (const V3d_Coordinate theX, const V3d_Coordinate theY, const V3d_Coordinate theZ); + void GetViewEye (V3d_Coordinate& X, V3d_Coordinate& Y, V3d_Coordinate& Z); + void SetViewEye (const V3d_Coordinate X,const V3d_Coordinate Y,const V3d_Coordinate Z); + Quantity_Factor GetViewScale(); + void SetViewScale (const Quantity_Factor Coef); + void FitAll() { myView->FitAll(); myView->ZFitAll(); }; // Overrides diff --git a/samples/mfc/standard/10_Convert/src/Convert_Presentation.cpp b/samples/mfc/standard/10_Convert/src/Convert_Presentation.cpp index 4b01dd3579..bd3383c260 100755 --- a/samples/mfc/standard/10_Convert/src/Convert_Presentation.cpp +++ b/samples/mfc/standard/10_Convert/src/Convert_Presentation.cpp @@ -69,6 +69,7 @@ Convert_Presentation::Convert_Presentation() myIndex = 0; myNbFuncs = sizeof(SampleFuncs)/sizeof(PSampleFuncType); myNbSamples = myNbFuncs; + FitMode = true; } ////////////////////////////////////////////////////////////////////// @@ -84,7 +85,6 @@ void Convert_Presentation::DoSample() (this->*SampleFuncs[myIndex])(); } - //================================================================ // Function : Convert_Presentation::drawSurfaceAndItsBSpline // Purpose : @@ -332,7 +332,7 @@ void Convert_Presentation::sampleRevolSurface() { FitMode=false; ResetView(); - SetViewCenter(176.84682,102.12892); + TranslateView(-176.84682, -102.12892); SetViewScale(0.69326); getAISContext()->EraseAll(); diff --git a/samples/mfc/standard/10_Convert/src/OCCDemo_Presentation.cpp b/samples/mfc/standard/10_Convert/src/OCCDemo_Presentation.cpp index 391571d639..ea8b4d076d 100755 --- a/samples/mfc/standard/10_Convert/src/OCCDemo_Presentation.cpp +++ b/samples/mfc/standard/10_Convert/src/OCCDemo_Presentation.cpp @@ -257,20 +257,20 @@ Handle_AIS_Shape OCCDemo_Presentation::drawShape return aGraphicShape; } -void OCCDemo_Presentation::GetViewCenter(V3d_Coordinate& Xc, V3d_Coordinate& Yc) +void OCCDemo_Presentation::GetViewAt (V3d_Coordinate& theX, V3d_Coordinate& theY, V3d_Coordinate& theZ) { - CMDIFrameWnd *pFrame = (CMDIFrameWnd*)AfxGetApp()->m_pMainWnd; - CMDIChildWnd *pChild = (CMDIChildWnd *) pFrame->GetActiveFrame(); - COCCDemoView *pView = (COCCDemoView *) pChild->GetActiveView(); - pView->GetViewCenter(Xc,Yc); + CMDIFrameWnd *pFrame = (CMDIFrameWnd*)AfxGetApp()->m_pMainWnd; + CMDIChildWnd *pChild = (CMDIChildWnd *) pFrame->GetActiveFrame(); + COCCDemoView *pView = (COCCDemoView *) pChild->GetActiveView(); + pView->GetViewAt (theX, theY, theZ); } -void OCCDemo_Presentation::SetViewCenter(V3d_Coordinate Xc, V3d_Coordinate Yc) +void OCCDemo_Presentation::SetViewAt (const V3d_Coordinate theX, const V3d_Coordinate theY, const V3d_Coordinate theZ) { - CMDIFrameWnd *pFrame = (CMDIFrameWnd*)AfxGetApp()->m_pMainWnd; - CMDIChildWnd *pChild = (CMDIChildWnd *) pFrame->GetActiveFrame(); - COCCDemoView *pView = (COCCDemoView *) pChild->GetActiveView(); - pView->SetViewCenter(Xc,Yc); + CMDIFrameWnd *pFrame = (CMDIFrameWnd*)AfxGetApp()->m_pMainWnd; + CMDIChildWnd *pChild = (CMDIChildWnd *) pFrame->GetActiveFrame(); + COCCDemoView *pView = (COCCDemoView *) pChild->GetActiveView(); + pView->SetViewAt (theX, theY, theZ); } void OCCDemo_Presentation::GetViewEye(V3d_Coordinate& X, V3d_Coordinate& Y, V3d_Coordinate& Z) @@ -311,4 +311,12 @@ void OCCDemo_Presentation::ResetView() CMDIChildWnd *pChild = (CMDIChildWnd *) pFrame->GetActiveFrame(); COCCDemoView *pView = (COCCDemoView *) pChild->GetActiveView(); pView->Reset(); -} \ No newline at end of file +} + +void OCCDemo_Presentation::TranslateView (const V3d_Coordinate theX, const V3d_Coordinate theY) +{ + CMDIFrameWnd *pFrame = (CMDIFrameWnd*)AfxGetApp()->m_pMainWnd; + CMDIChildWnd *pChild = (CMDIChildWnd *) pFrame->GetActiveFrame(); + COCCDemoView *pView = (COCCDemoView *) pChild->GetActiveView(); + pView->Translate (theX, theY); +} diff --git a/samples/mfc/standard/10_Convert/src/OCCDemo_Presentation.h b/samples/mfc/standard/10_Convert/src/OCCDemo_Presentation.h index 61e219e959..e79086f8b8 100755 --- a/samples/mfc/standard/10_Convert/src/OCCDemo_Presentation.h +++ b/samples/mfc/standard/10_Convert/src/OCCDemo_Presentation.h @@ -50,14 +50,14 @@ public: void NextSample() {myIndex++;} void PrevSample() {myIndex--;} virtual void DoSample() = 0; - static void GetViewCenter(V3d_Coordinate& Xc, V3d_Coordinate& Yc); - static void SetViewCenter(const V3d_Coordinate Xc, const V3d_Coordinate Yc); - static void GetViewEye(V3d_Coordinate& X, V3d_Coordinate& Y, V3d_Coordinate& Z); - static void SetViewEye(V3d_Coordinate X, V3d_Coordinate Y, V3d_Coordinate Z); + static void GetViewAt (V3d_Coordinate& theX, V3d_Coordinate& theY, V3d_Coordinate& theZ); + static void SetViewAt (const V3d_Coordinate theX, const V3d_Coordinate theY, const V3d_Coordinate theZ); + static void GetViewEye (V3d_Coordinate& X, V3d_Coordinate& Y, V3d_Coordinate& Z); + static void SetViewEye (V3d_Coordinate X, V3d_Coordinate Y, V3d_Coordinate Z); static Quantity_Factor GetViewScale(); static void SetViewScale(Quantity_Factor Coef); static void ResetView(); - + static void TranslateView (const V3d_Coordinate theX, const V3d_Coordinate theY); // place one-time initialization code in this function virtual void Init() {} diff --git a/samples/mfc/standard/10_Convert/src/WNT/OCCDemoView.cpp b/samples/mfc/standard/10_Convert/src/WNT/OCCDemoView.cpp index 7195257527..3cd62d5915 100755 --- a/samples/mfc/standard/10_Convert/src/WNT/OCCDemoView.cpp +++ b/samples/mfc/standard/10_Convert/src/WNT/OCCDemoView.cpp @@ -97,6 +97,8 @@ void COCCDemoView::OnInitialUpdate() CView::OnInitialUpdate(); myView = GetDocument()->GetViewer()->CreateView(); + myView->SetViewMappingDefault(); + myView->SetViewOrientationDefault(); Handle(WNT_Window) aWNTWindow = new WNT_Window(GetSafeHwnd ()); myView->SetWindow(aWNTWindow); @@ -543,14 +545,14 @@ void COCCDemoView::OnUpdateBUTTONHlrOn(CCmdUI* pCmdUI) pCmdUI->Enable (myVisMode != VIS_HLR); } -void COCCDemoView::GetViewCenter(V3d_Coordinate& Xc, V3d_Coordinate& Yc) +void COCCDemoView::GetViewAt (V3d_Coordinate& theX, V3d_Coordinate& theY, V3d_Coordinate& theZ) const { - myView->Center(Xc,Yc); + myView->At (theX, theY, theZ); } -void COCCDemoView::SetViewCenter(V3d_Coordinate Xc, V3d_Coordinate Yc) +void COCCDemoView::SetViewAt (const V3d_Coordinate theX, const V3d_Coordinate theY, const V3d_Coordinate theZ) { - myView->SetCenter(Xc,Yc); + myView->SetAt (theX, theY, theZ); } void COCCDemoView::GetViewEye(V3d_Coordinate& X, V3d_Coordinate& Y, V3d_Coordinate& Z) @@ -572,3 +574,8 @@ void COCCDemoView::SetViewScale(Quantity_Factor Coef) { myView->SetScale(Coef); } + +void COCCDemoView::Translate (const Standard_Real theX, const Standard_Real theY) +{ + myView->Panning (theX, theY); +} diff --git a/samples/mfc/standard/10_Convert/src/WNT/OCCDemoView.h b/samples/mfc/standard/10_Convert/src/WNT/OCCDemoView.h index d385c4371f..6bfa56e5f9 100755 --- a/samples/mfc/standard/10_Convert/src/WNT/OCCDemoView.h +++ b/samples/mfc/standard/10_Convert/src/WNT/OCCDemoView.h @@ -27,13 +27,18 @@ protected: // create from serialization only // Attributes public: COCCDemoDoc* GetDocument(); - void FitAll() { myView->FitAll(); myView->ZFitAll(); }; - void GetViewCenter(V3d_Coordinate& Xc, V3d_Coordinate& Yc); - void SetViewCenter(const V3d_Coordinate Xc, const V3d_Coordinate Yc); - void GetViewEye(V3d_Coordinate& X, V3d_Coordinate& Y, V3d_Coordinate& Z); - void SetViewEye(const V3d_Coordinate X,const V3d_Coordinate Y,const V3d_Coordinate Z); + void FitAll() + { + myView->FitAll(); + myView->ZFitAll(); + }; + void GetViewAt (V3d_Coordinate& theX, V3d_Coordinate& theY, V3d_Coordinate& theZ) const; + void SetViewAt (const V3d_Coordinate theX, const V3d_Coordinate theY, const V3d_Coordinate theZ); + void GetViewEye (V3d_Coordinate& X, V3d_Coordinate& Y, V3d_Coordinate& Z); + void SetViewEye (const V3d_Coordinate X,const V3d_Coordinate Y,const V3d_Coordinate Z); Quantity_Factor GetViewScale(); void SetViewScale(const Quantity_Factor Coef); + void Translate (const V3d_Coordinate theX, const V3d_Coordinate theY); // Operations diff --git a/samples/mfc/standard/Common/OCC_StereoConfigDlg.cpp b/samples/mfc/standard/Common/OCC_StereoConfigDlg.cpp index 6251b0daa6..4a73d16a59 100644 --- a/samples/mfc/standard/Common/OCC_StereoConfigDlg.cpp +++ b/samples/mfc/standard/Common/OCC_StereoConfigDlg.cpp @@ -105,9 +105,11 @@ void OCC_StereoConfigDlg::OnHScroll(UINT theSBCode, UINT thePos, CScrollBar* the void OCC_StereoConfigDlg::UpdateCamera() { // update camera properties and redraw view - Handle(Graphic3d_Camera)& aCamera = myView->Camera(); + const Handle(Graphic3d_Camera)& aCamera = myView->Camera(); if (aCamera.IsNull()) + { return; + } // change IOD Graphic3d_Camera::IODType aIODType = diff --git a/samples/qt/Common/src/DocumentCommon.cxx b/samples/qt/Common/src/DocumentCommon.cxx index 64d428ca08..66737667ed 100755 --- a/samples/qt/Common/src/DocumentCommon.cxx +++ b/samples/qt/Common/src/DocumentCommon.cxx @@ -16,13 +16,16 @@ #include #include -Handle(V3d_Viewer) DocumentCommon::Viewer( const Standard_CString /*aDisplay*/, - const Standard_ExtString aName, - const Standard_CString aDomain, - const Standard_Real ViewSize, - const V3d_TypeOfOrientation ViewProj, - const Standard_Boolean ComputedMode, - const Standard_Boolean aDefaultComputedMode ) +// ======================================================================= +// function : Viewer +// purpose : +// ======================================================================= +Handle(V3d_Viewer) DocumentCommon::Viewer (const Standard_ExtString theName, + const Standard_CString theDomain, + const Standard_Real theViewSize, + const V3d_TypeOfOrientation theViewProj, + const Standard_Boolean theComputedMode, + const Standard_Boolean theDefaultComputedMode ) { static Handle(OpenGl_GraphicDriver) aGraphicDriver; @@ -30,14 +33,23 @@ Handle(V3d_Viewer) DocumentCommon::Viewer( const Standard_CString /*aDisplay*/, { Handle(Aspect_DisplayConnection) aDisplayConnection; #if !defined(_WIN32) && !defined(__WIN32__) && (!defined(__APPLE__) || defined(MACOSX_USE_GLX)) - aDisplayConnection = new Aspect_DisplayConnection (aDisplay); + aDisplayConnection = new Aspect_DisplayConnection (qgetenv ("DISPLAY").constData()); #endif aGraphicDriver = new OpenGl_GraphicDriver (aDisplayConnection); } - return new V3d_Viewer(aGraphicDriver,aName,aDomain,ViewSize,ViewProj, - Quantity_NOC_GRAY30,V3d_ZBUFFER,V3d_GOURAUD,V3d_WAIT, - ComputedMode,aDefaultComputedMode,V3d_TEX_NONE); + return new V3d_Viewer (aGraphicDriver, + theName, + theDomain, + theViewSize, + theViewProj, + Quantity_NOC_GRAY30, + V3d_ZBUFFER, + V3d_GOURAUD, + V3d_WAIT, + theComputedMode, + theDefaultComputedMode, + V3d_TEX_NONE); } DocumentCommon::DocumentCommon( const int theIndex, ApplicationCommonWindow* app ) @@ -47,13 +59,13 @@ myIndex( theIndex ), myNbViews( 0 ) { TCollection_ExtendedString a3DName ("Visu3D"); - myViewer = Viewer (qgetenv ("DISPLAY").constData(), - a3DName.ToExtString(), "", 1000.0, V3d_XposYnegZpos, Standard_True, Standard_True); - myViewer->SetDefaultLights(); - myViewer->SetLightOn(); + myViewer = Viewer (a3DName.ToExtString(), "", 1000.0, V3d_XposYnegZpos, Standard_True, Standard_True); - myContext = new AIS_InteractiveContext (myViewer); + myViewer->SetDefaultLights(); + myViewer->SetLightOn(); + + myContext = new AIS_InteractiveContext (myViewer); } DocumentCommon::~DocumentCommon() diff --git a/samples/qt/Common/src/DocumentCommon.h b/samples/qt/Common/src/DocumentCommon.h index 8d05a6a30a..150de48f9f 100755 --- a/samples/qt/Common/src/DocumentCommon.h +++ b/samples/qt/Common/src/DocumentCommon.h @@ -48,13 +48,12 @@ public slots: void onTransparency( int ); private: - Handle(V3d_Viewer) Viewer( const Standard_CString aDisplay, - const Standard_ExtString aName, - const Standard_CString aDomain, - const Standard_Real ViewSize, - const V3d_TypeOfOrientation ViewProj, - const Standard_Boolean ComputedMode, - const Standard_Boolean aDefaultComputedMode ); + Handle(V3d_Viewer) Viewer (const Standard_ExtString theName, + const Standard_CString theDomain, + const Standard_Real theViewSize, + const V3d_TypeOfOrientation theViewProj, + const Standard_Boolean theComputedMode, + const Standard_Boolean theDefaultComputedMode ); protected: ApplicationCommonWindow* myApp;