1
0
mirror of https://git.dev.opencascade.org/repos/occt.git synced 2025-08-09 13:22:24 +03:00

0031521: Samples - update MFC ImportExport sample to use AIS_ViewController

The following MFC samples have been updated to use AIS_ViewController:
Geometry, HLR, ImportExport, Modeling, OCAF, Triangulation, Viewer2D.
This commit is contained in:
kgv
2020-04-24 17:03:20 +03:00
committed by bugmaster
parent ab9e277f15
commit 7ff18fb9cc
17 changed files with 593 additions and 1447 deletions

View File

@@ -128,7 +128,7 @@ void CHLRDoc::FitAll2DViews(Standard_Boolean UpdateViewer)
if(pCurrentView->IsKindOf(RUNTIME_CLASS(OCC_2dView)) )
{
ASSERT_VALID(pCurrentView);
((OCC_2dView*)pCurrentView)->GetV2dView()->FitAll();
((OCC_2dView*)pCurrentView)->FitAll();
}
}
}

View File

@@ -8,23 +8,12 @@
#include "resource2d\RectangularGrid.h"
#include "resource2d\CircularGrid.h"
#define ValZWMin 1
#ifdef _DEBUG
//#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
// the key for multi selection :
#define MULTISELECTIONKEY MK_SHIFT
// the key for shortcut ( use to activate dynamic rotation, panning )
#define CASCADESHORTCUTKEY MK_CONTROL
// define in witch case you want to display the popup
#define POPUPONBUTTONDOWN
/////////////////////////////////////////////////////////////////////////////
// CHLRView2D
@@ -32,7 +21,6 @@ IMPLEMENT_DYNCREATE(CHLRView2D, OCC_2dView)
BEGIN_MESSAGE_MAP(CHLRView2D, OCC_2dView)
//{{AFX_MSG_MAP(CHLRView2D)
ON_WM_MOUSEMOVE()
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
@@ -41,170 +29,26 @@ END_MESSAGE_MAP()
CHLRView2D::CHLRView2D()
{
/// TODO
/// Override MouseMove event to exclude rectangle selection emulation as
/// no selection is supported in DragEvent2D for this view.
}
CHLRView2D::~CHLRView2D()
{
}
const Handle(AIS_InteractiveContext)& CHLRView2D::GetAISContext() const
{
return ((CHLRDoc*)m_pDocument)->GetInteractiveContext2D();
}
CHLRDoc* CHLRView2D::GetDocument() // non-debug version is inline
{
//ASSERT(m_pDocument->IsKindOf(RUNTIME_CLASS(OCC_2dDoc)));
return (CHLRDoc*)m_pDocument;
}
void CHLRView2D::OnInitialUpdate()
{
Handle(WNT_Window) aWNTWindow;
aWNTWindow = new WNT_Window(GetSafeHwnd(),Quantity_NOC_GRAY);
myV2dView = GetDocument()->GetViewer2D()->CreateView();
myV2dView->SetWindow(aWNTWindow);
// initialyse the grids dialogs
TheRectangularGridDialog.Create(CRectangularGrid::IDD, NULL);
TheCircularGridDialog.Create(CCircularGrid::IDD, NULL);
TheRectangularGridDialog.SetViewer (GetDocument()->GetViewer2D());
TheCircularGridDialog.SetViewer (GetDocument()->GetViewer2D());
Standard_Integer w=100 , h=100 ; /* Debug Matrox */
aWNTWindow->Size (w,h) ; /* Keeps me unsatisfied (rlb)..... */
/* Resize is not supposed to be done on */
/* Matrox */
/* I suspect another problem elsewhere */
::PostMessage ( GetSafeHwnd () , WM_SIZE , SIZE_RESTORED , w + h*65536 ) ;
}
//-----------------------------------------------------------------------------------------
//
//-----------------------------------------------------------------------------------------
void CHLRView2D::DragEvent2D(const Standard_Integer /*x*/,
const Standard_Integer /*y*/,
const Standard_Integer /*TheState*/)
{
}
//-----------------------------------------------------------------------------------------
//
//-----------------------------------------------------------------------------------------
void CHLRView2D::InputEvent2D(const Standard_Integer /*x*/,
const Standard_Integer /*y*/)
{
}
//-----------------------------------------------------------------------------------------
//
//-----------------------------------------------------------------------------------------
void CHLRView2D::MoveEvent2D(const Standard_Integer /*x*/,
const Standard_Integer /*y*/)
{
}
//-----------------------------------------------------------------------------------------
//
//-----------------------------------------------------------------------------------------
void CHLRView2D::MultiMoveEvent2D(const Standard_Integer /*x*/,
const Standard_Integer /*y*/)
{
}
//-----------------------------------------------------------------------------------------
//
//-----------------------------------------------------------------------------------------
void CHLRView2D::MultiDragEvent2D(const Standard_Integer /*x*/,
const Standard_Integer /*y*/,
const Standard_Integer /*TheState*/)
{
}
//-----------------------------------------------------------------------------------------
//
//-----------------------------------------------------------------------------------------
void CHLRView2D::MultiInputEvent2D(const Standard_Integer /*x*/,
const Standard_Integer /*y*/)
{
}
//-----------------------------------------------------------------------------------------
//
//-----------------------------------------------------------------------------------------
void CHLRView2D::OnMouseMove(UINT nFlags, CPoint point)
{
if ( (nFlags & MK_LBUTTON) &! (nFlags & MK_RBUTTON) ) // Left + Right is specific
{
if ( nFlags & CASCADESHORTCUTKEY )
{
// move with MB1 and CASCADESHORTCUTKEY : on the dynamic zooming
// Do the zoom in function of mouse's coordinates
myV2dView->Zoom(myXmax,myYmax,point.x,point.y);
myXmax = point.x;
myYmax = point.y;
}
else // if ( CASCADESHORTCUTKEY )
{
switch (myCurrentMode)
{
case CurAction2d_Nothing :
myXmax = point.x;
myYmax = point.y;
DragEvent2D(myXmax,myYmax,0);
break;
case CurAction2d_DynamicZooming :
myV2dView->Zoom(myXmax,myYmax,point.x,point.y);
myXmax=point.x;
myYmax=point.y;
break;
case CurAction2d_WindowZooming :
myXmax = point.x;
myYmax = point.y;
break;
case CurAction2d_DynamicPanning :
myV2dView->Pan(point.x-myXmax,myYmax-point.y); // Realize the panning
myXmax = point.x;
myYmax = point.y;
break;
case CurAction2d_GlobalPanning :
break;
default :
throw Standard_Failure(" incompatible Current Mode ");
break;
}
}
} else if ( nFlags & MK_MBUTTON)
{
if ( nFlags & CASCADESHORTCUTKEY )
{
myV2dView->Pan (point.x-myXmax,myYmax-point.y);
myXmax = point.x;
myYmax = point.y;
}
} else if ( (nFlags & MK_RBUTTON) &! (nFlags & MK_LBUTTON) )
{
}
else if ( (nFlags & MK_RBUTTON) && (nFlags & MK_LBUTTON) )
{
if ( nFlags & CASCADESHORTCUTKEY )
{
myV2dView->Pan(point.x-myXmax,myYmax-point.y); // Realize the panning
myXmax = point.x; myYmax = point.y;
}
}
else
{ // No buttons
myXmax = point.x;
myYmax = point.y;
if (nFlags & MULTISELECTIONKEY)
{
MultiMoveEvent2D(point.x,point.y);
}
else
{
MoveEvent2D(point.x,point.y);
}
}
}
#ifdef _DEBUG
void CHLRView2D::AssertValid() const
{

View File

@@ -20,37 +20,15 @@ class CHLRView2D : public OCC_2dView
protected: // create from serialization only
CHLRView2D();
DECLARE_DYNCREATE(CHLRView2D)
// Override MouseMove event to exclude rectangle selection emulation as
// no selection is supported in DragEvent2D for this view.
afx_msg void OnMouseMove(UINT nFlags, CPoint point);
DECLARE_MESSAGE_MAP()
// Overrides
// ClassWizard generated virtual function overrides
//{{AFX_VIRTUAL(CHLRView2D)
protected:
virtual void OnInitialUpdate(); // called first time after construct
//}}AFX_VIRTUAL
//! Return interactive context for HLR presentations.
virtual const Handle(AIS_InteractiveContext)& GetAISContext() const Standard_OVERRIDE;
// Implementation
public:
virtual ~CHLRView2D();
CHLRDoc* GetDocument();
virtual void DragEvent2D (const Standard_Integer x,
const Standard_Integer y,
const Standard_Integer TheState);
virtual void InputEvent2D (const Standard_Integer x,
const Standard_Integer y);
virtual void MoveEvent2D (const Standard_Integer x,
const Standard_Integer y );
virtual void MultiMoveEvent2D (const Standard_Integer x,
const Standard_Integer y );
virtual void MultiDragEvent2D (const Standard_Integer x,
const Standard_Integer y ,
const Standard_Integer TheState);
virtual void MultiInputEvent2D (const Standard_Integer x,
const Standard_Integer y );
#ifdef _DEBUG
virtual void AssertValid() const;
virtual void Dump(CDumpContext& dc) const;