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

0023776: Redesign of MFC samples after V2d viewer removing

This commit is contained in:
aba
2013-03-12 09:19:35 +04:00
parent fad8962a72
commit 5c1f974e17
212 changed files with 9053 additions and 19513 deletions

View File

@@ -4,8 +4,7 @@
#include "stdafx.h"
#include "OCC_3dView.h"
#include "OCC_3dApp.h"
#include "OCC_App.h"
#include "OCC_3dBaseDoc.h"
#include <res\OCC_Resource.h>
@@ -59,33 +58,31 @@ END_MESSAGE_MAP()
OCC_3dView::OCC_3dView()
{
// TODO: add construction code here
myXmin=0;
myYmin=0;
myXmax=0;
myYmax=0;
myCurZoom=0;
myWidth=0;
myHeight=0;
// will be set in OnInitial update, but, for more security :
myCurrentMode = CurAction3d_Nothing;
myDegenerateModeIsOn=Standard_True;
m_Pen = NULL;
// TODO: add construction code here
myXmin=0;
myYmin=0;
myXmax=0;
myYmax=0;
myCurZoom=0;
myWidth=0;
myHeight=0;
// will be set in OnInitial update, but, for more security :
myCurrentMode = CurAction3d_Nothing;
myDegenerateModeIsOn=Standard_True;
m_Pen = NULL;
}
OCC_3dView::~OCC_3dView()
{
if ( myView )
myView->Remove();
if (m_Pen) delete m_Pen;
if ( myView )
myView->Remove();
if (m_Pen) delete m_Pen;
}
BOOL OCC_3dView::PreCreateWindow(CREATESTRUCT& cs)
{
// TODO: Modify the Window class or styles here by modifying
// the CREATESTRUCT cs
return CView::PreCreateWindow(cs);
}
@@ -93,26 +90,25 @@ BOOL OCC_3dView::PreCreateWindow(CREATESTRUCT& cs)
// OCC_3dView drawing
void OCC_3dView::OnInitialUpdate()
{
CView::OnInitialUpdate();
myView = GetDocument()->GetViewer()->CreateView();
CView::OnInitialUpdate();
// set the default mode in wireframe ( not hidden line ! )
myView->SetDegenerateModeOn();
// store for restore state after rotation (witch is in Degenerated mode)
myDegenerateModeIsOn = Standard_True;
myView = GetDocument()->GetViewer()->CreateView();
// set the default mode in wireframe ( not hidden line ! )
myView->SetDegenerateModeOn();
// store for restore state after rotation (which is in Degenerated mode)
myDegenerateModeIsOn = Standard_True;
Handle(Graphic3d_WNTGraphicDevice) theGraphicDevice =
((OCC_3dApp*)AfxGetApp())->GetGraphicDevice();
Handle(WNT_Window) aWNTWindow = new WNT_Window(theGraphicDevice,GetSafeHwnd ());
myView->SetWindow(aWNTWindow);
if (!aWNTWindow->IsMapped()) aWNTWindow->Map();
Handle(Graphic3d_GraphicDriver) aGraphicDriver =
((OCC_App*)AfxGetApp())->GetGraphicDriver();
// store the mode ( nothing , dynamic zooming, dynamic ... )
myCurrentMode = CurAction3d_Nothing;
Handle(WNT_Window) aWNTWindow = new WNT_Window(GetSafeHwnd());
myView->SetWindow(aWNTWindow);
if (!aWNTWindow->IsMapped()) aWNTWindow->Map();
// store the mode ( nothing , dynamic zooming, dynamic ... )
myCurrentMode = CurAction3d_Nothing;
}
void OCC_3dView::OnDraw(CDC* pDC)
@@ -142,10 +138,10 @@ void OCC_3dView::Dump(CDumpContext& dc) const
CView::Dump(dc);
}
OCC_3dBaseDoc* OCC_3dView::GetDocument() // non-debug version is inline
OCC_3dDoc* OCC_3dView::GetDocument() // non-debug version is inline
{
// ASSERT(m_pDocument->IsKindOf(RUNTIME_CLASS(OCC_3dBaseDoc)));
return (OCC_3dBaseDoc*)m_pDocument;
return (OCC_3dDoc*)m_pDocument;
}
#endif //_DEBUG
@@ -189,23 +185,47 @@ void OCC_3dView::OnSize(UINT nType, int cx, int cy)
myView->MustBeResized();
}
// See the back View
void OCC_3dView::OnBUTTONBack()
{ myView->SetProj(V3d_Xneg); } // See the back View
{
myView->SetProj(V3d_Xneg);
}
// See the front View
void OCC_3dView::OnBUTTONFront()
{ myView->SetProj(V3d_Xpos); } // See the front View
{
myView->SetProj(V3d_Xpos);
}
// See the bottom View
void OCC_3dView::OnBUTTONBottom()
{ myView->SetProj(V3d_Zneg); } // See the bottom View
{
myView->SetProj(V3d_Zneg);
}
// See the top View
void OCC_3dView::OnBUTTONTop()
{ myView->SetProj(V3d_Zpos); } // See the top View
{
myView->SetProj(V3d_Zpos);
}
// See the left View
void OCC_3dView::OnBUTTONLeft()
{ myView->SetProj(V3d_Ypos); } // See the left View
void OCC_3dView::OnBUTTONRight()
{ myView->SetProj(V3d_Yneg); } // See the right View
{
myView->SetProj(V3d_Ypos);
}
// See the right View
void OCC_3dView::OnBUTTONRight()
{
myView->SetProj(V3d_Yneg);
}
// See the axonometric View
void OCC_3dView::OnBUTTONAxo()
{ myView->SetProj(V3d_XposYnegZpos); } // See the axonometric View
{
myView->SetProj(V3d_XposYnegZpos);
}
void OCC_3dView::OnBUTTONHlrOff()
{
@@ -222,7 +242,9 @@ void OCC_3dView::OnBUTTONHlrOn()
}
void OCC_3dView::OnBUTTONPan()
{ myCurrentMode = CurAction3d_DynamicPanning; }
{
myCurrentMode = CurAction3d_DynamicPanning;
}
void OCC_3dView::OnBUTTONPanGlo()
{
@@ -235,11 +257,14 @@ void OCC_3dView::OnBUTTONPanGlo()
}
void OCC_3dView::OnBUTTONReset()
{ myView->Reset(); }
{
myView->Reset();
}
void OCC_3dView::OnBUTTONRot()
{ myCurrentMode = CurAction3d_DynamicRotation; }
{
myCurrentMode = CurAction3d_DynamicRotation;
}
void OCC_3dView::OnBUTTONZoomAll()
{
@@ -260,144 +285,143 @@ void OCC_3dView::OnLButtonDown(UINT nFlags, CPoint point)
myXmax=point.x; myYmax=point.y;
if ( nFlags & MK_CONTROL )
{
// Button MB1 down Control :start zomming
// SetCursor(AfxGetApp()->LoadStandardCursor());
}
else // if ( Ctrl )
{
switch (myCurrentMode)
{
case CurAction3d_Nothing : // start a drag
if (nFlags & MK_SHIFT)
GetDocument()->ShiftDragEvent(myXmax,myYmax,-1,myView);
else
GetDocument()->DragEvent(myXmax,myYmax,-1,myView);
break;
break;
case CurAction3d_DynamicZooming : // noting
break;
case CurAction3d_WindowZooming : // noting
break;
case CurAction3d_DynamicPanning :// noting
break;
case CurAction3d_GlobalPanning :// noting
break;
case CurAction3d_DynamicRotation :
if (!myDegenerateModeIsOn)
myView->SetDegenerateModeOn();
myView->StartRotation(point.x,point.y);
break;
default :
Standard_Failure::Raise(" incompatible Current Mode ");
break;
}
{
// Button MB1 down Control :start zomming
// SetCursor(AfxGetApp()->LoadStandardCursor());
}
else // if ( Ctrl )
{
switch (myCurrentMode)
{
case CurAction3d_Nothing : // start a drag
if (nFlags & MK_SHIFT)
GetDocument()->ShiftDragEvent(myXmax,myYmax,-1,myView);
else
GetDocument()->DragEvent(myXmax,myYmax,-1,myView);
break;
break;
case CurAction3d_DynamicZooming : // noting
break;
case CurAction3d_WindowZooming : // noting
break;
case CurAction3d_DynamicPanning :// noting
break;
case CurAction3d_GlobalPanning :// noting
break;
case CurAction3d_DynamicRotation :
if (!myDegenerateModeIsOn)
myView->SetDegenerateModeOn();
myView->StartRotation(point.x,point.y);
break;
default :
Standard_Failure::Raise(" incompatible Current Mode ");
break;
}
}
}
void OCC_3dView::OnLButtonUp(UINT nFlags, CPoint point)
{
if ( nFlags & MK_CONTROL )
{
return;
}
else // if ( Ctrl )
{
switch (myCurrentMode)
{
case CurAction3d_Nothing :
if (point.x == myXmin && point.y == myYmin)
{ // no offset between down and up --> selectEvent
myXmax=point.x;
myYmax=point.y;
if (nFlags & MK_SHIFT )
GetDocument()->ShiftInputEvent(point.x,point.y,myView);
else
GetDocument()->InputEvent (point.x,point.y,myView);
} else
{
myXmax=point.x; myYmax=point.y;
DrawRectangle(myXmin,myYmin,myXmax,myYmax,Standard_False);
if (nFlags & MK_SHIFT)
GetDocument()->ShiftDragEvent(point.x,point.y,1,myView);
else
GetDocument()->DragEvent(point.x,point.y,1,myView);
}
break;
case CurAction3d_DynamicZooming :
// SetCursor(AfxGetApp()->LoadStandardCursor());
myCurrentMode = CurAction3d_Nothing;
break;
case CurAction3d_WindowZooming :
myXmax=point.x; myYmax=point.y;
DrawRectangle(myXmin,myYmin,myXmax,myYmax,Standard_False);
if ((abs(myXmin-myXmax)>ValZWMin) || (abs(myYmin-myYmax)>ValZWMin))
// Test if the zoom window is greater than a minimale window.
{
// Do the zoom window between Pmin and Pmax
myView->WindowFitAll(myXmin,myYmin,myXmax,myYmax);
}
myCurrentMode = CurAction3d_Nothing;
break;
case CurAction3d_DynamicPanning :
myCurrentMode = CurAction3d_Nothing;
break;
case CurAction3d_GlobalPanning :
myView->Place(point.x,point.y,myCurZoom);
myCurrentMode = CurAction3d_Nothing;
break;
case CurAction3d_DynamicRotation :
myCurrentMode = CurAction3d_Nothing;
if (!myDegenerateModeIsOn)
{
CWaitCursor aWaitCursor;
myView->SetDegenerateModeOff();
myDegenerateModeIsOn = Standard_False;
}
else
{
myView->SetDegenerateModeOn();
myDegenerateModeIsOn = Standard_True;
}
break;
default :
Standard_Failure::Raise(" incompatible Current Mode ");
break;
} //switch (myCurrentMode)
} // else // if ( Ctrl )
if ( nFlags & MK_CONTROL )
{
return;
}
else // if ( Ctrl )
{
switch (myCurrentMode)
{
case CurAction3d_Nothing :
if (point.x == myXmin && point.y == myYmin)
{ // no offset between down and up --> selectEvent
myXmax=point.x;
myYmax=point.y;
if (nFlags & MK_SHIFT )
GetDocument()->ShiftInputEvent(point.x,point.y,myView);
else
GetDocument()->InputEvent (point.x,point.y,myView);
} else
{
myXmax=point.x; myYmax=point.y;
DrawRectangle(myXmin,myYmin,myXmax,myYmax,Standard_False);
if (nFlags & MK_SHIFT)
GetDocument()->ShiftDragEvent(point.x,point.y,1,myView);
else
GetDocument()->DragEvent(point.x,point.y,1,myView);
}
break;
case CurAction3d_DynamicZooming :
// SetCursor(AfxGetApp()->LoadStandardCursor());
myCurrentMode = CurAction3d_Nothing;
break;
case CurAction3d_WindowZooming :
myXmax=point.x; myYmax=point.y;
DrawRectangle(myXmin,myYmin,myXmax,myYmax,Standard_False);
if ((abs(myXmin-myXmax)>ValZWMin) || (abs(myYmin-myYmax)>ValZWMin))
// Test if the zoom window is greater than a minimale window.
{
// Do the zoom window between Pmin and Pmax
myView->WindowFitAll(myXmin,myYmin,myXmax,myYmax);
}
myCurrentMode = CurAction3d_Nothing;
break;
case CurAction3d_DynamicPanning :
myCurrentMode = CurAction3d_Nothing;
break;
case CurAction3d_GlobalPanning :
myView->Place(point.x,point.y,myCurZoom);
myCurrentMode = CurAction3d_Nothing;
break;
case CurAction3d_DynamicRotation :
myCurrentMode = CurAction3d_Nothing;
if (!myDegenerateModeIsOn)
{
CWaitCursor aWaitCursor;
myView->SetDegenerateModeOff();
myDegenerateModeIsOn = Standard_False;
}
else
{
myView->SetDegenerateModeOn();
myDegenerateModeIsOn = Standard_True;
}
break;
default :
Standard_Failure::Raise(" incompatible Current Mode ");
break;
} //switch (myCurrentMode)
} // else // if ( Ctrl )
}
void OCC_3dView::OnMButtonDown(UINT nFlags, CPoint point)
{
if ( nFlags & MK_CONTROL )
{
// Button MB2 down Control : panning init
// SetCursor(AfxGetApp()->LoadStandardCursor());
}
if ( nFlags & MK_CONTROL )
{
// Button MB2 down Control : panning init
// SetCursor(AfxGetApp()->LoadStandardCursor());
}
}
void OCC_3dView::OnMButtonUp(UINT nFlags, CPoint point)
{
if ( nFlags & MK_CONTROL )
{
// Button MB2 down Control : panning init
// SetCursor(AfxGetApp()->LoadStandardCursor());
}
if ( nFlags & MK_CONTROL )
{
// Button MB2 down Control : panning init
// SetCursor(AfxGetApp()->LoadStandardCursor());
}
}
void OCC_3dView::OnRButtonDown(UINT nFlags, CPoint point)
{
if ( nFlags & MK_CONTROL )
{
// SetCursor(AfxGetApp()->LoadStandardCursor());
if (!myDegenerateModeIsOn)
myView->SetDegenerateModeOn();
myView->StartRotation(point.x,point.y);
}
else // if ( Ctrl )
{
GetDocument()->Popup(point.x,point.y,myView);
}
if ( nFlags & MK_CONTROL )
{
if (!myDegenerateModeIsOn)
myView->SetDegenerateModeOn();
myView->StartRotation(point.x,point.y);
}
else // if ( Ctrl )
{
GetDocument()->Popup(point.x,point.y,myView);
}
}
void OCC_3dView::OnRButtonUp(UINT nFlags, CPoint point)
@@ -417,84 +441,82 @@ void OCC_3dView::OnRButtonUp(UINT nFlags, CPoint point)
void OCC_3dView::OnMouseMove(UINT nFlags, CPoint point)
{
// ============================ LEFT BUTTON =======================
// ============================ LEFT BUTTON =======================
if ( nFlags & MK_LBUTTON)
{
if ( nFlags & MK_CONTROL )
{
if ( nFlags & MK_CONTROL )
{
// move with MB1 and Control : on the dynamic zooming
// Do the zoom in function of mouse's coordinates
myView->Zoom(myXmax,myYmax,point.x,point.y);
// save the current mouse coordinate in min
myXmax = point.x;
myYmax = point.y;
}
else // if ( Ctrl )
{
switch (myCurrentMode)
{
case CurAction3d_Nothing :
myXmax = point.x; myYmax = point.y;
DrawRectangle(myXmin,myYmin,myXmax,myYmax,Standard_False);
if (nFlags & MK_SHIFT)
GetDocument()->ShiftDragEvent(myXmax,myYmax,0,myView);
else
GetDocument()->DragEvent(myXmax,myYmax,0,myView);
DrawRectangle(myXmin,myYmin,myXmax,myYmax,Standard_True);
// move with MB1 and Control : on the dynamic zooming
// Do the zoom in function of mouse's coordinates
myView->Zoom(myXmax,myYmax,point.x,point.y);
// save the current mouse coordinate in min
myXmax = point.x;
myYmax = point.y;
}
else // if ( Ctrl )
{
switch (myCurrentMode)
{
case CurAction3d_Nothing :
myXmax = point.x; myYmax = point.y;
DrawRectangle(myXmin,myYmin,myXmax,myYmax,Standard_False);
if (nFlags & MK_SHIFT)
GetDocument()->ShiftDragEvent(myXmax,myYmax,0,myView);
else
GetDocument()->DragEvent(myXmax,myYmax,0,myView);
DrawRectangle(myXmin,myYmin,myXmax,myYmax,Standard_True);
break;
case CurAction3d_DynamicZooming :
myView->Zoom(myXmax,myYmax,point.x,point.y);
// save the current mouse coordinate in min \n";
myXmax=point.x; myYmax=point.y;
break;
case CurAction3d_WindowZooming :
myXmax = point.x; myYmax = point.y;
DrawRectangle(myXmin,myYmin,myXmax,myYmax,Standard_False,LongDash);
DrawRectangle(myXmin,myYmin,myXmax,myYmax,Standard_True,LongDash);
break;
case CurAction3d_DynamicPanning :
myView->Pan(point.x-myXmax,myYmax-point.y); // Realize the panning
myXmax = point.x; myYmax = point.y;
break;
case CurAction3d_GlobalPanning : // nothing
break;
case CurAction3d_DynamicRotation :
myView->Rotation(point.x,point.y);
myView->Redraw();
case CurAction3d_DynamicZooming :
myView->Zoom(myXmax,myYmax,point.x,point.y);
// save the current mouse coordinate in min \n";
myXmax=point.x; myYmax=point.y;
break;
default :
Standard_Failure::Raise(" incompatible Current Mode ");
case CurAction3d_WindowZooming :
myXmax = point.x; myYmax = point.y;
DrawRectangle(myXmin,myYmin,myXmax,myYmax,Standard_False,LongDash);
DrawRectangle(myXmin,myYmin,myXmax,myYmax,Standard_True,LongDash);
break;
}// switch (myCurrentMode)
}// if ( nFlags & MK_CONTROL ) else
} else // if ( nFlags & MK_LBUTTON)
// ============================ MIDDLE BUTTON =======================
if ( nFlags & MK_MBUTTON)
case CurAction3d_DynamicPanning :
myView->Pan(point.x-myXmax,myYmax-point.y); // Realize the panning
myXmax = point.x; myYmax = point.y;
break;
case CurAction3d_GlobalPanning : // nothing
break;
case CurAction3d_DynamicRotation :
myView->Rotation(point.x,point.y);
myView->Redraw();
break;
default :
Standard_Failure::Raise(" incompatible Current Mode ");
break;
}// switch (myCurrentMode)
}// if ( nFlags & MK_CONTROL ) else
}
else if ( nFlags & MK_MBUTTON)
{
if ( nFlags & MK_CONTROL )
{
if ( nFlags & MK_CONTROL )
{
myView->Pan(point.x-myXmax,myYmax-point.y); // Realize the panning
myXmax = point.x; myYmax = point.y;
myView->Pan(point.x-myXmax,myYmax-point.y); // Realize the panning
myXmax = point.x; myYmax = point.y;
}
} else // if ( nFlags & MK_MBUTTON)
// ============================ RIGHT BUTTON =======================
if ( nFlags & MK_RBUTTON)
}
}
else if ( nFlags & MK_RBUTTON)
{
if ( nFlags & MK_CONTROL )
{
if ( nFlags & MK_CONTROL )
{
myView->Rotation(point.x,point.y);
}
}else //if ( nFlags & MK_RBUTTON)
// ============================ NO BUTTON =======================
{ // No buttons
myXmax = point.x; myYmax = point.y;
if (nFlags & MK_SHIFT)
GetDocument()->ShiftMoveEvent(point.x,point.y,myView);
else
GetDocument()->MoveEvent(point.x,point.y,myView);
}
myView->Rotation(point.x,point.y);
}
}
else
{ // No buttons
myXmax = point.x; myYmax = point.y;
if (nFlags & MK_SHIFT)
GetDocument()->ShiftMoveEvent(point.x,point.y,myView);
else
GetDocument()->MoveEvent(point.x,point.y,myView);
}
}
void OCC_3dView::DrawRectangle(const Standard_Integer MinX ,