#include "OCC_3dBaseDoc.h"
#include <res\OCC_Resource.h>
-#include <Visual3d_View.hxx>
-
#include <Graphic3d_ExportFormat.hxx>
#include <Graphic3d_Camera.hxx>
OCC_3dView::OCC_3dView()
: myCurrentMode (CurAction3d_Nothing),
- myXmin (0),
- myYmin (0),
- myXmax (0),
- myYmax (0),
- myCurZoom (0.0),
myWidth (0),
myHeight (0),
- myHlrModeIsOn (Standard_False),
- m_Pen (NULL)
+ myHlrModeIsOn (Standard_False)
{
// TODO: add construction code here
}
OCC_3dView::~OCC_3dView()
{
- if (myView)
+ if (myView.IsNull())
{
myView->Remove();
}
delete m_pStereoDlg;
- 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);
+ // TODO: Modify the Window class or styles here by modifying
+ // the CREATESTRUCT cs
+ cs.lpszClass = ::AfxRegisterWndClass(CS_HREDRAW | CS_VREDRAW | CS_DBLCLKS | CS_OWNDC, ::LoadCursor(NULL, IDC_ARROW), NULL, NULL);
+ return CView::PreCreateWindow(cs);
}
/////////////////////////////////////////////////////////////////////////////
if(myWidth != aRect.Width() || myHeight != aRect.Height()) {
myWidth = aRect.Width();
myHeight = aRect.Height();
- ::PostMessage ( GetSafeHwnd () , WM_SIZE , SW_SHOW , myWidth + myHeight*65536 );
+ ::PostMessage ( GetSafeHwnd() , WM_SIZE , SW_SHOW , myWidth + myHeight*65536 );
}
myView->Redraw();
}
GetDocument()->ExportView (myView);
}
-void OCC_3dView::OnSize(UINT /*nType*/, int /*cx*/, int /*cy*/)
+void OCC_3dView::OnSize(UINT nType, int cx, int cy)
{
+ OCC_BaseView::OnSize (nType, cx, cy);
if (!myView.IsNull())
myView->MustBeResized();
}
// See the back View
void OCC_3dView::OnBUTTONBack()
{
- myView->SetProj(V3d_Xneg);
+ myView->SetProj(V3d_Ypos);
}
// See the front View
void OCC_3dView::OnBUTTONFront()
{
- myView->SetProj(V3d_Xpos);
+ myView->SetProj(V3d_Yneg);
}
// See the bottom View
// See the left View
void OCC_3dView::OnBUTTONLeft()
{
- myView->SetProj(V3d_Ypos);
+ myView->SetProj(V3d_Xneg);
}
// See the right View
void OCC_3dView::OnBUTTONRight()
{
- myView->SetProj(V3d_Yneg);
+ myView->SetProj(V3d_Xpos);
}
// See the axonometric View
{
myHlrModeIsOn = Standard_False;
myView->SetComputedMode (myHlrModeIsOn);
+ myView->Redraw();
}
void OCC_3dView::OnBUTTONHlrOn()
SetCursor(AfxGetApp()->LoadStandardCursor(IDC_WAIT));
myHlrModeIsOn = Standard_True;
myView->SetComputedMode (myHlrModeIsOn);
+ myView->Redraw();
SetCursor(AfxGetApp()->LoadStandardCursor(IDC_ARROW));
}
myView->StartRotation(point.x,point.y);
break;
default :
- Standard_Failure::Raise(" incompatible Current Mode ");
+ throw Standard_Failure(" incompatible Current Mode ");
break;
}
}
}
else // if ( Ctrl )
{
+ const Handle(AIS_InteractiveContext)& aContext = GetDocument()->GetAISContext();
switch (myCurrentMode)
{
case CurAction3d_Nothing :
} else
{
myXmax=point.x; myYmax=point.y;
- DrawRectangle(myXmin,myYmin,myXmax,myYmax,Standard_False);
+ drawRectangle (myXmin, myYmin, myXmax, myYmax, aContext, Standard_False);
if (nFlags & MK_SHIFT)
GetDocument()->ShiftDragEvent(point.x,point.y,1,myView);
else
break;
case CurAction3d_WindowZooming :
myXmax=point.x; myYmax=point.y;
- DrawRectangle(myXmin,myYmin,myXmax,myYmax,Standard_False);
+ drawRectangle (myXmin, myYmin, myXmax, myYmax, aContext, Standard_False);
if ((abs(myXmin-myXmax)>ValZWMin) || (abs(myYmin-myYmax)>ValZWMin))
// Test if the zoom window is greater than a minimale window.
{
{
CWaitCursor aWaitCursor;
myView->SetComputedMode (myHlrModeIsOn);
+ myView->Redraw();
}
else
{
}
break;
default :
- Standard_Failure::Raise(" incompatible Current Mode ");
+ throw Standard_Failure(" incompatible Current Mode ");
break;
} //switch (myCurrentMode)
} // else // if ( Ctrl )
void OCC_3dView::OnRButtonUp(UINT /*nFlags*/, CPoint /*point*/)
{
SetCursor(AfxGetApp()->LoadStandardCursor(IDC_WAIT));
- myView->SetComputedMode (myHlrModeIsOn);
+ if (myHlrModeIsOn)
+ {
+ myView->SetComputedMode (myHlrModeIsOn);
+ myView->Redraw();
+ }
SetCursor(AfxGetApp()->LoadStandardCursor(IDC_ARROW));
}
{
// 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);
+ myView->Zoom (myXmax,myYmax,point.x,point.y);
// save the current mouse coordinate in min
myXmax = point.x;
myYmax = point.y;
}
else // if ( Ctrl )
{
+ const Handle(AIS_InteractiveContext)& aContext = GetDocument()->GetAISContext();
switch (myCurrentMode)
{
case CurAction3d_Nothing :
- DrawRectangle(myXmin,myYmin,myXmax,myYmax,Standard_False);
myXmax = point.x;
myYmax = point.y;
GetDocument()->ShiftDragEvent(myXmax,myYmax,0,myView);
else
GetDocument()->DragEvent(myXmax,myYmax,0,myView);
- DrawRectangle(myXmin,myYmin,myXmax,myYmax,Standard_True);
+
+ drawRectangle (myXmin, myYmin, myXmax, myYmax, aContext);
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;
+ 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);
+ myXmax = point.x;
+ myYmax = point.y;
+ drawRectangle (myXmin, myYmin, myXmax, myYmax, aContext);
break;
case CurAction3d_DynamicPanning :
myView->Pan(point.x-myXmax,myYmax-point.y); // Realize the panning
myView->Redraw();
break;
default :
- Standard_Failure::Raise(" incompatible Current Mode ");
+ throw Standard_Failure(" incompatible Current Mode ");
break;
}// switch (myCurrentMode)
}// if ( nFlags & MK_CONTROL ) else
if ( nFlags & MK_CONTROL )
{
myView->Pan(point.x-myXmax,myYmax-point.y); // Realize the panning
- myXmax = point.x; myYmax = point.y;
-
+ myXmax = point.x;
+ myYmax = point.y;
}
}
else if ( nFlags & MK_RBUTTON)
}
}
else
- { // No buttons
- myXmax = point.x; myYmax = point.y;
+ { // No buttons
+ myXmax = point.x;
+ myYmax = point.y;
if (nFlags & MK_SHIFT)
GetDocument()->ShiftMoveEvent(point.x,point.y,myView);
else
}
}
-void OCC_3dView::DrawRectangle(const Standard_Integer MinX ,
- const Standard_Integer MinY ,
- const Standard_Integer MaxX ,
- const Standard_Integer MaxY ,
- const Standard_Boolean Draw ,
- const LineStyle aLineStyle)
-{
- static int m_DrawMode;
- if (!m_Pen && aLineStyle ==Solid )
- {m_Pen = new CPen(PS_SOLID, 1, RGB(0,0,0)); m_DrawMode = R2_MERGEPENNOT;}
- else if (!m_Pen && aLineStyle ==Dot )
- {m_Pen = new CPen(PS_DOT, 1, RGB(0,0,0)); m_DrawMode = R2_XORPEN;}
- else if (!m_Pen && aLineStyle == ShortDash)
- {m_Pen = new CPen(PS_DASH, 1, RGB(255,0,0)); m_DrawMode = R2_XORPEN;}
- else if (!m_Pen && aLineStyle == LongDash)
- {m_Pen = new CPen(PS_DASH, 1, RGB(0,0,0)); m_DrawMode = R2_NOTXORPEN;}
- else if (aLineStyle == Default)
- { m_Pen = NULL; m_DrawMode = R2_MERGEPENNOT;}
-
- CPen* aOldPen = NULL;
- CClientDC clientDC(this);
- if (m_Pen) aOldPen = clientDC.SelectObject(m_Pen);
- clientDC.SetROP2(m_DrawMode);
-
- static Standard_Integer StoredMinX, StoredMaxX, StoredMinY, StoredMaxY;
- static Standard_Boolean m_IsVisible;
-
- if ( m_IsVisible && !Draw) // move or up : erase at the old position
- {
- clientDC.MoveTo(StoredMinX,StoredMinY); clientDC.LineTo(StoredMinX,StoredMaxY);
- clientDC.LineTo(StoredMaxX,StoredMaxY);
- clientDC.LineTo(StoredMaxX,StoredMinY); clientDC.LineTo(StoredMinX,StoredMinY);
- m_IsVisible = false;
- }
-
- StoredMinX = min ( MinX, MaxX );
- StoredMinY = min ( MinY, MaxY );
- StoredMaxX = max ( MinX, MaxX );
- StoredMaxY = max ( MinY, MaxY);
-
- if (Draw) // move : draw
- {
- clientDC.MoveTo(StoredMinX,StoredMinY); clientDC.LineTo(StoredMinX,StoredMaxY);
- clientDC.LineTo(StoredMaxX,StoredMaxY);
- clientDC.LineTo(StoredMaxX,StoredMinY); clientDC.LineTo(StoredMinX,StoredMinY);
- m_IsVisible = true;
- }
-
- if (m_Pen) clientDC.SelectObject(aOldPen);
-}
-
-
-
void OCC_3dView::OnUpdateBUTTONHlrOff(CCmdUI* pCmdUI)
{
pCmdUI->SetCheck (!myHlrModeIsOn);