#include "OCC_MainFrame.h"
#include "Viewer3dApp.h"
#include "Viewer3dDoc.h"
-#include "ZClippingDlg.h"
-#include "ZCueingDlg.h"
#include "ScaleDlg.h"
#include "ShadingModelDlg.h"
#include "ModelClippingDlg.h"
#include "TrihedronDlg.h"
+#include <AIS_RubberBand.hxx>
#include <V3d_AmbientLight.hxx>
#include <V3d_DirectionalLight.hxx>
#include <V3d_PositionalLight.hxx>
ON_COMMAND(ID_SPOT_LIGHT, OnSpotLight)
ON_COMMAND(ID_POSITIONAL_LIGHT, OnPositionalLight)
ON_COMMAND(ID_AMBIENT_LIGHT, OnAmbientLight)
- ON_COMMAND(ID_ZCUEING, OnZcueing)
ON_COMMAND(ID_SCALE, OnScale)
- ON_COMMAND(ID_ZCLIPPING, OnZclipping)
ON_COMMAND(ID_SHADINGMODEL, OnShadingmodel)
ON_COMMAND(ID_ANTIALIASINGONOFF, OnAntialiasingonoff)
ON_COMMAND(ID_CLEAR_LIGHTS, OnClearLights)
// CViewer3dView construction/destruction
CViewer3dView::CViewer3dView()
+: scaleX (1),
+ scaleY (1),
+ scaleZ (1),
+ myVisMode (VIS_SHADE),
+ myCurrentMode (CurAction3d_Nothing),
+ myXmin (0),
+ myYmin (0),
+ myXmax (0),
+ myYmax (0),
+ myCurZoom (0.0),
+ NbActiveLights (2), // There are 2 default active lights
+ myHlrModeIsOn (Standard_False),
+ myRect (new AIS_RubberBand (Quantity_NOC_WHITE, Aspect_TOL_SOLID, 1.0)),
+ myAxisKey (0),
+ myScaleDirection (0)
{
- // TODO: add construction code here
- myXmin=0;
- myYmin=0;
- myXmax=0;
- myYmax=0;
- myCurZoom=0;
- myWidth=0;
- myHeight=0;
-
- scaleX = 1;
- scaleY = 1;
- scaleZ = 1;
-
- myAxisKey = 0;
- myScaleDirection = 0;
-
-
- myVisMode = VIS_SHADE;
-
- // will be set in OnInitial update, but, for more security :
- myCurrentMode = CurAction3d_Nothing;
- myDegenerateModeIsOn=Standard_True;
- m_Pen = NULL;
- NbActiveLights=2; // There are 2 default active lights
- myGraphicDriver = Handle(Graphic3d_GraphicDriver)::DownCast(
- ((CViewer3dApp*)AfxGetApp())->GetGraphicDevice()->GraphicDriver() );
+ // TODO: add construction code here
+ myGraphicDriver = ((CViewer3dApp*)AfxGetApp())->GetGraphicDriver();
}
CViewer3dView::~CViewer3dView()
{
- myView->Remove();
- if (m_Pen) delete m_Pen;
+ myView->Remove();
}
BOOL CViewer3dView::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);
}
/////////////////////////////////////////////////////////////////////////////
// CViewer3dView drawing
void CViewer3dView::OnInitialUpdate()
{
- CView::OnInitialUpdate();
-
-
- myView = GetDocument()->GetViewer()->CreateView();
-
- // 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;
-
-
- Handle(Graphic3d_WNTGraphicDevice) theGraphicDevice =
- ((CViewer3dApp*)AfxGetApp())->GetGraphicDevice();
-
- Handle(WNT_Window) aWNTWindow = new WNT_Window(theGraphicDevice,GetSafeHwnd ());
- myView->SetWindow(aWNTWindow);
- if (!aWNTWindow->IsMapped()) aWNTWindow->Map();
-
-// 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 ) ;
-
- // store the mode ( nothing , dynamic zooming, dynamic ... )
- myCurrentMode = CurAction3d_Nothing;
- myVisMode = VIS_SHADE;
- RedrawVisMode();
+ CView::OnInitialUpdate();
+
+ myView = GetDocument()->GetViewer()->CreateView();
+
+ // store for restore state after rotation (witch is in Degenerated mode)
+ myHlrModeIsOn = Standard_False;
+ myView->SetComputedMode (myHlrModeIsOn);
+
+ Handle(WNT_Window) aWNTWindow = new WNT_Window (GetSafeHwnd());
+ myView->SetWindow(aWNTWindow);
+ if (!aWNTWindow->IsMapped()) aWNTWindow->Map();
+
+ // 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 ) ;
+
+ // store the mode ( nothing , dynamic zooming, dynamic ... )
+ myCurrentMode = CurAction3d_Nothing;
+ myVisMode = VIS_SHADE;
+ RedrawVisMode();
}
-void CViewer3dView::OnDraw(CDC* pDC)
+void CViewer3dView::OnDraw(CDC* /*pDC*/)
{
CViewer3dDoc* pDoc = GetDocument();
ASSERT_VALID(pDoc);
- CRect aRect;
- GetWindowRect(aRect);
- if(myWidth != aRect.Width() || myHeight != aRect.Height()) {
- myWidth = aRect.Width();
- myHeight = aRect.Height();
- ::PostMessage ( GetSafeHwnd () , WM_SIZE , SW_SHOW , myWidth + myHeight*65536 );
- }
myView->Redraw();
-
}
/////////////////////////////////////////////////////////////////////////////
gp_Pnt ConvertClickToPoint(Standard_Real x, Standard_Real y, Handle(V3d_View) aView)
{
- V3d_Coordinate XEye,YEye,ZEye,XAt,YAt,ZAt;
+ Standard_Real XEye,YEye,ZEye,XAt,YAt,ZAt;
aView->Eye(XEye,YEye,ZEye);
aView->At(XAt,YAt,ZAt);
gp_Pnt EyePoint(XEye,YEye,ZEye);
return ResultPoint;
}
-void CViewer3dView::OnSize(UINT nType, int cx, int cy)
+void CViewer3dView::OnSize(UINT nType, int cx, int cy)
{
+ CView::OnSize (nType, cx, cy);
if (!myView.IsNull())
myView->MustBeResized();
}
void CViewer3dView::OnBUTTONBack()
{
- myView->SetProj(V3d_Xneg);
+ myView->SetProj(V3d_Ypos);
TCollection_AsciiString Message("\
-myView->SetProj(V3d_Xneg);\n\
+myView->SetProj(V3d_Ypos);\n\
");
// Update The Result Message Dialog
} // See the back View
void CViewer3dView::OnBUTTONFront()
{
- myView->SetProj(V3d_Xpos);
+ myView->SetProj(V3d_Yneg);
TCollection_AsciiString Message("\
-myView->SetProj(V3d_Xpos);\n\
+myView->SetProj(V3d_Yneg);\n\
");
// Update The Result Message Dialog
void CViewer3dView::OnBUTTONLeft()
{
- myView->SetProj(V3d_Ypos);
+ myView->SetProj(V3d_Xneg);
TCollection_AsciiString Message("\
-myView->SetProj(V3d_Ypos);\n\
+myView->SetProj(V3d_Xneg);\n\
");
// Update The Result Message Dialog
} // See the left View
void CViewer3dView::OnBUTTONRight()
{
- myView->SetProj(V3d_Yneg);
+ myView->SetProj(V3d_Xpos);
TCollection_AsciiString Message("\
-myView->SetProj(V3d_Yneg);\n\
+myView->SetProj(V3d_Xpos);\n\
");
// Update The Result Message Dialog
void CViewer3dView::OnBUTTONHlrOff()
{
- myView->SetDegenerateModeOn();
- myDegenerateModeIsOn = Standard_True;
+ myHlrModeIsOn = Standard_False;
+ myView->SetComputedMode (myHlrModeIsOn);
+ myView->Redraw();
-TCollection_AsciiString Message("\
-myView->SetDegenerateModeOn();\n\
- ");
+ TCollection_AsciiString aMsg ("myView->SetComputedMode (Standard_False);\n"
+ " ");
// Update The Result Message Dialog
-GetDocument()->UpdateResultMessageDlg("SetDegenerateModeOn",Message);
+ GetDocument()->UpdateResultMessageDlg ("SetComputedMode", aMsg);
}
void CViewer3dView::OnBUTTONHlrOn()
{
SetCursor(AfxGetApp()->LoadStandardCursor(IDC_WAIT));
- myView->SetDegenerateModeOff();
- myDegenerateModeIsOn = Standard_False;
+ myHlrModeIsOn = Standard_True;
+ myView->SetComputedMode (myHlrModeIsOn);
+ myView->Redraw();
SetCursor(AfxGetApp()->LoadStandardCursor(IDC_ARROW));
-TCollection_AsciiString Message("\
-myView->SetDegenerateModeOff();\n\
- ");
+ TCollection_AsciiString aMsg ("myView->SetComputedMode (Standard_True);\n"
+ " ");
// Update The Result Message Dialog
-GetDocument()->UpdateResultMessageDlg("SetDegenerateModeOff",Message);
+ GetDocument()->UpdateResultMessageDlg ("SetComputedMode", aMsg);
}
void CViewer3dView::OnBUTTONPan()
case CurAction3d_GlobalPanning :// noting
break;
case CurAction3d_DynamicRotation :
- if (!myDegenerateModeIsOn)
- myView->SetDegenerateModeOn();
- myView->StartRotation(point.x,point.y);
- break;
+ if (myHlrModeIsOn)
+ {
+ myView->SetComputedMode (Standard_False);
+ }
+ myView->StartRotation (point.x, point.y);
+ break;
case CurAction3d_BeginPositionalLight :
{
p1 = ConvertClickToPoint(point.x,point.y,myView);
myCurrent_PositionalLight->SetPosition(p1.X(),p1.Y(),p1.Z()) ;
- GetDocument()->GetAISContext()->CloseLocalContext();
((OCC_MainFrame*)AfxGetMainWnd())->SetStatusMessage("Ready");
myCurrentMode = CurAction3d_Nothing;
case CurAction3d_BeginSpotLight :
{
p1 = ConvertClickToPoint(point.x,point.y,myView);
- myCurrent_SpotLight = new V3d_SpotLight(myView->Viewer(),0.,0.,1., p1.X(),p1.Y(),p1.Z(),Quantity_NOC_RED);
+ myCurrent_SpotLight = new V3d_SpotLight (p1, gp_Dir (gp_XYZ (0.0, 0.0, 1.0) - p1.XYZ()), Quantity_NOC_RED);
myView->SetLightOn(myCurrent_SpotLight);
NbActiveLights++;
p2 = gp_Pnt(p1.X(),p1.Y(),p1.Z()+1.);
BRepPrimAPI_MakeCone MakeCone(gp_Ax2(p1, gp_Dir(gp_Vec(p1, p2))),
0, (p1.Distance(p2))/tan(1.04), coneHeigth);
spotConeShape->Set(MakeCone.Solid());
- GetDocument()->GetAISContext()->Display(spotConeShape,0,-1);
+ GetDocument()->GetAISContext()->Display (spotConeShape, 0, -1, false);
((OCC_MainFrame*)AfxGetMainWnd())->SetStatusMessage("Pick the target point");
myCurrentMode = CurAction3d_TargetSpotLight;
}
break;
case CurAction3d_EndSpotLight :
- GetDocument()->GetAISContext()->Erase(spotConeShape);
- GetDocument()->GetAISContext()->CloseLocalContext();
+ GetDocument()->GetAISContext()->Erase (spotConeShape, Standard_True);
((OCC_MainFrame*)AfxGetMainWnd())->SetStatusMessage("Ready");
myCurrentMode = CurAction3d_Nothing;
break;
p2 = gp_Pnt(p1.X(),p1.Y(),p1.Z()+1.);
BRepBuilderAPI_MakeEdge MakeEdge(p1, p2);
directionalEdgeShape->Set(MakeEdge.Edge());
- GetDocument()->GetAISContext()->Display(directionalEdgeShape,0,-1);
+ GetDocument()->GetAISContext()->Display (directionalEdgeShape, 0, -1, Standard_True);
// Create a directional light
- myCurrent_DirectionalLight = new V3d_DirectionalLight(myView->Viewer(), p1.X(),p1.Y(),p1.Z(),0.,0.,1.);
+ myCurrent_DirectionalLight = new V3d_DirectionalLight (gp_Dir (p1.XYZ() - gp_XYZ (0.,0.,1.)));
myView->SetLightOn(myCurrent_DirectionalLight);
NbActiveLights++;
((OCC_MainFrame*)AfxGetMainWnd())->SetStatusMessage("Pick the target point");
}
break;
case CurAction3d_EndDirectionalLight:
- GetDocument()->GetAISContext()->Erase(directionalEdgeShape);
- GetDocument()->GetAISContext()->CloseLocalContext();
+ GetDocument()->GetAISContext()->Erase (directionalEdgeShape, Standard_True);
((OCC_MainFrame*)AfxGetMainWnd())->SetStatusMessage("Ready");
myCurrentMode = CurAction3d_Nothing;
break;
}
}
-void CViewer3dView::OnKeyDown(UINT nChar, UINT nRepCnt, UINT nFlags)
+void CViewer3dView::OnKeyDown(UINT nChar, UINT /*nRepCnt*/, UINT /*nFlags*/)
{
if( nChar == X_Key || nChar == Y_Key || nChar == Z_Key )
}
break;
case CurAction3d_DynamicZooming :
- // SetCursor(AfxGetApp()->LoadStandardCursor());
+ // SetCursor(AfxGetApp()->LoadStandardCursor());
myCurrentMode = CurAction3d_Nothing;
break;
case CurAction3d_WindowZooming :
} // else // if ( Ctrl )
}
-void CViewer3dView::OnMButtonDown(UINT nFlags, CPoint point)
+void CViewer3dView::OnMButtonDown(UINT nFlags, CPoint /*point*/)
{
if ( nFlags & MK_CONTROL )
{
// Button MB2 down Control : panning init
- // SetCursor(AfxGetApp()->LoadStandardCursor());
+ // SetCursor(AfxGetApp()->LoadStandardCursor());
}
}
-void CViewer3dView::OnMButtonUp(UINT nFlags, CPoint point)
+void CViewer3dView::OnMButtonUp(UINT nFlags, CPoint /*point*/)
{
if ( nFlags & MK_CONTROL )
{
// Button MB2 down Control : panning init
- // SetCursor(AfxGetApp()->LoadStandardCursor());
+ // SetCursor(AfxGetApp()->LoadStandardCursor());
}
}
void CViewer3dView::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 )
+ {
+ // SetCursor(AfxGetApp()->LoadStandardCursor());
+ if (myHlrModeIsOn)
+ {
+ myView->SetComputedMode (Standard_False);
+ }
+ myView->StartRotation (point.x, point.y);
+ }
+ else // if ( Ctrl )
+ {
+ GetDocument()->Popup (point.x, point.y, myView);
+ }
}
-void CViewer3dView::OnRButtonUp(UINT nFlags, CPoint point)
+void CViewer3dView::OnRButtonUp(UINT /*nFlags*/, CPoint /*point*/)
{
- SetCursor(AfxGetApp()->LoadStandardCursor(IDC_WAIT));
- if (!myDegenerateModeIsOn)
- {
- myView->SetDegenerateModeOff();
- myDegenerateModeIsOn = Standard_False;
- } else
- {
- myView->SetDegenerateModeOn();
- myDegenerateModeIsOn = Standard_True;
- }
- SetCursor(AfxGetApp()->LoadStandardCursor(IDC_ARROW));
+ SetCursor(AfxGetApp()->LoadStandardCursor(IDC_WAIT));
+ if (myHlrModeIsOn)
+ {
+ myView->SetComputedMode (myHlrModeIsOn);
+ myView->Redraw();
+ }
+ SetCursor(AfxGetApp()->LoadStandardCursor(IDC_ARROW));
}
void CViewer3dView::OnMouseMove(UINT nFlags, CPoint point)
switch (myCurrentMode)
{
case CurAction3d_Nothing :
- myXmax = point.x; myYmax = point.y;
- DrawRectangle(myXmin,myYmin,myXmax,myYmax,Standard_False);
+
+ myXmax = point.x; myYmax = point.y;
if (nFlags & MK_SHIFT)
GetDocument()->ShiftDragEvent(myXmax,myYmax,0,myView);
else
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);
+ DrawRectangle(myXmin,myYmin,myXmax,myYmax,Standard_True, Aspect_TOL_DASH);
break;
case CurAction3d_DynamicPanning :
{
BRepBuilderAPI_MakeEdge MakeEdge(p1, p2);
directionalEdgeShape->Set(MakeEdge.Edge());
- GetDocument()->GetAISContext()->Redisplay(directionalEdgeShape,0,-1);
+ GetDocument()->GetAISContext()->Redisplay(directionalEdgeShape,0,Standard_True);
myCurrent_DirectionalLight->SetDirection(p2.X()-p1.X(),p2.Y()-p1.Y(),p2.Z()-p1.Z());
myView->UpdateLights();
+ myView->Redraw();
}
}
else if (myCurrentMode == CurAction3d_BeginPositionalLight)
//Update the light dynamically
myCurrent_PositionalLight->SetPosition(p2.X(),p2.Y(),p2.Z());
myView->UpdateLights();
+ myView->Redraw();
}
else if (myCurrentMode == CurAction3d_TargetSpotLight)
{
BRepPrimAPI_MakeCone MakeCone(gp_Ax2(p1, gp_Dir(gp_Vec(p1, p2))),
0, (p1.Distance(p2))/tan(1.04), coneHeigth);
spotConeShape->Set(MakeCone.Solid());
- GetDocument()->GetAISContext()->Redisplay(spotConeShape,0,-1);
+ GetDocument()->GetAISContext()->Redisplay(spotConeShape,0,Standard_True);
myCurrent_SpotLight->SetDirection(p2.X()-p1.X(),p2.Y()-p1.Y(),p2.Z()-p1.Z());
myView->UpdateLights();
+ myView->Redraw();
}
}
else if (myCurrentMode == CurAction3d_EndSpotLight)
BRepPrimAPI_MakeCone MakeCone(gp_Ax2(p1, gp_Dir(gp_Vec(p1, p2))),
0, p2.Distance(p3), coneHeigth);
spotConeShape->Set(MakeCone.Solid());
- GetDocument()->GetAISContext()->Redisplay(spotConeShape,0,-1);
- myCurrent_SpotLight->SetAngle(atan(p2.Distance(p3)/p1.Distance(p2))) ;
+ GetDocument()->GetAISContext()->Redisplay(spotConeShape,0,Standard_True);
+ myCurrent_SpotLight->SetAngle((float )atan(p2.Distance(p3)/p1.Distance(p2))) ;
myView->UpdateLights();
+ myView->Redraw();
}
}
- if (nFlags & MK_SHIFT)
+ else if (nFlags & MK_SHIFT)
+ {
GetDocument()->ShiftMoveEvent(point.x,point.y,myView);
+ }
else
+ {
GetDocument()->MoveEvent(point.x,point.y,myView);
+ }
}
}
-void CViewer3dView::OnUpdateBUTTONHlrOff(CCmdUI* pCmdUI)
+void CViewer3dView::OnUpdateBUTTONHlrOff (CCmdUI* pCmdUI)
{
- pCmdUI->SetCheck (myDegenerateModeIsOn);
- pCmdUI->Enable (!myDegenerateModeIsOn);
+ pCmdUI->SetCheck (!myHlrModeIsOn);
+ pCmdUI->Enable (myHlrModeIsOn);
}
-void CViewer3dView::OnUpdateBUTTONHlrOn(CCmdUI* pCmdUI)
+void CViewer3dView::OnUpdateBUTTONHlrOn (CCmdUI* pCmdUI)
{
- pCmdUI->SetCheck (!myDegenerateModeIsOn);
- pCmdUI->Enable (myDegenerateModeIsOn);
+ pCmdUI->SetCheck (myHlrModeIsOn);
+ pCmdUI->Enable (!myHlrModeIsOn);
}
void CViewer3dView::OnUpdateBUTTONPanGlo(CCmdUI* pCmdUI)
pCmdUI->Enable (myCurrentMode != CurAction3d_DynamicRotation);
}
-void CViewer3dView::DrawRectangle(const Standard_Integer MinX ,
- const Standard_Integer MinY ,
- const Standard_Integer MaxX ,
- const Standard_Integer MaxY ,
- const Standard_Boolean Draw ,
- const LineStyle aLineStyle)
+void CViewer3dView::DrawRectangle (Standard_Integer theMinX,
+ Standard_Integer theMinY,
+ Standard_Integer theMaxX,
+ Standard_Integer theMaxY,
+ Standard_Boolean theToDraw,
+ Aspect_TypeOfLine theLineType)
{
- 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;
- 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);
+ const Handle(AIS_InteractiveContext)& aCtx = GetDocument()->GetAISContext();
+ if (!theToDraw)
+ {
+ aCtx->Remove (myRect, false);
+ aCtx->CurrentViewer()->RedrawImmediate();
+ return;
+ }
- 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);
+ CRect aRect;
+ GetWindowRect (aRect);
+ myRect->SetLineType (theLineType);
+ myRect->SetRectangle (theMinX, aRect.Height() - theMinY, theMaxX, aRect.Height() - theMaxY);
+ if (!aCtx->IsDisplayed (myRect))
+ {
+ aCtx->Display (myRect, false);
+ }
+ else
+ {
+ aCtx->Redisplay (myRect, false);
+ }
+ aCtx->CurrentViewer()->RedrawImmediate();
}
void CViewer3dView::OnModifyChangeBackground()
// Checking if the Active lights limit number is not reached
if( NbActiveLights>=myGraphicDriver->InquireLightLimit() )
{
- char tmpStr[128];
- sprintf_s(tmpStr, "You have reach the limit number of active lights (%d).\n Clear lights to create new ones.",
- myGraphicDriver->InquireLightLimit());
- MessageBox(tmpStr,"Light creation", MB_OK);
+ CString aMsg;
+ aMsg.Format (L"You have reach the limit number of active lights (%d).\n Clear lights to create new ones.", myGraphicDriver->InquireLightLimit());
+ MessageBox (aMsg, L"Light creation", MB_OK);
return;
}
UpdateData(TRUE);
((OCC_MainFrame*)AfxGetMainWnd())->SetStatusMessage("Pick a first point");
- GetDocument()->GetAISContext()->OpenLocalContext();
myCurrentMode = CurAction3d_BeginDirectionalLight;
TCollection_AsciiString Message("\
-myCurrent_DirectionalLight = new V3d_DirectionalLight(myView->Viewer(), Xt, Yt, Zt, Xp, Yp, Zp);\n\
+myCurrent_DirectionalLight = new V3d_DirectionalLight (gp_Dir (theDirection));\n\
\n\
myView->SetLightOn(myCurrent_DirectionalLight);\n\
\n\
// Checking if the Active lights limit number is not reached
if( NbActiveLights>=myGraphicDriver->InquireLightLimit() )
{
- char tmpStr[128];
- sprintf_s(tmpStr, "You have reach the limit number of active lights (%d).\n Clear lights to create new ones.",
- myGraphicDriver->InquireLightLimit());
- MessageBox(tmpStr,"Light creation", MB_OK);
+ CString aMsg;
+ aMsg.Format(L"You have reach the limit number of active lights (%d).\n Clear lights to create new ones.", myGraphicDriver->InquireLightLimit());
+ MessageBox (aMsg, L"Light creation", MB_OK);
return;
}
- GetDocument()->GetAISContext()->OpenLocalContext();
((OCC_MainFrame*)AfxGetMainWnd())->SetStatusMessage("Pick the light position");
myCurrentMode = CurAction3d_BeginSpotLight;
TCollection_AsciiString Message("\
-myCurrent_SpotLight = new V3d_SpotLight(myView->Viewer(), Xt, Yt, Zt, Xp, Yp, Zp,Quantity_NOC_RED);\n\
+myCurrent_SpotLight = new V3d_SpotLight (gp_Pnt (thePosition), gp_Dir (theDirection), Quantity_NOC_RED);\n\
\n\
myView->SetLightOn(myCurrent_SpotLight);\n\
\n\
// Checking if the Active lights limit number is not reached
if( NbActiveLights>=myGraphicDriver->InquireLightLimit() )
{
- char tmpStr[128];
- sprintf_s(tmpStr, "You have reach the limit number of active lights (%d).\n Clear lights to create new ones.",
- myGraphicDriver->InquireLightLimit());
- MessageBox(tmpStr,"Light creation", MB_OK);
+ CString aMsg;
+ aMsg.Format(L"You have reach the limit number of active lights (%d).\n Clear lights to create new ones.", myGraphicDriver->InquireLightLimit());
+ MessageBox(aMsg, L"Light creation", MB_OK);
return;
}
- GetDocument()->GetAISContext()->OpenLocalContext();
- myCurrent_PositionalLight=new V3d_PositionalLight(myView->Viewer(),0,0,0,Quantity_NOC_GREEN,1,0);
+ myCurrent_PositionalLight=new V3d_PositionalLight (gp_Pnt (0,0,0), Quantity_NOC_GREEN);
+ myCurrent_PositionalLight->SetAttenuation (1, 0);
myView->SetLightOn(myCurrent_PositionalLight);
NbActiveLights++;
((OCC_MainFrame*)AfxGetMainWnd())->SetStatusMessage("Pick the light position");
myCurrentMode = CurAction3d_BeginPositionalLight;
TCollection_AsciiString Message("\
-myCurrent_PositionalLight=new V3d_PositionalLight(myView->Viewer(),Xp, Yp, Zp,Quantity_NOC_GREEN,1,0);\n\
+myCurrent_PositionalLight=new V3d_PositionalLight (gp_Pnt(thePosition),Quantity_NOC_GREEN);\n\
+myCurrent_PositionalLight->SetAttenuation (1, 0);\n\
\n\
myView->SetLightOn(myCurrent_PositionalLight) ;\n\
");
// Checking if the Active lights limit number is not reached
if( NbActiveLights>=myGraphicDriver->InquireLightLimit() )
{
- char tmpStr[128];
- sprintf_s(tmpStr, "You have reach the limit number of active lights (%d).\n Clear lights to create new ones.",
- myGraphicDriver->InquireLightLimit());
- MessageBox(tmpStr,"Light creation", MB_OK);
+ CString aMsg;
+ aMsg.Format(L"You have reach the limit number of active lights (%d).\n Clear lights to create new ones.", myGraphicDriver->InquireLightLimit());
+ MessageBox(aMsg, L"Light creation", MB_OK);
return;
}
- GetDocument()->GetAISContext()->OpenLocalContext();
- myCurrent_AmbientLight=new V3d_AmbientLight(myView->Viewer(), Quantity_NOC_GRAY);
+ myCurrent_AmbientLight=new V3d_AmbientLight (Quantity_NOC_GRAY);
myView->SetLightOn(myCurrent_AmbientLight) ;
NbActiveLights++;
- GetDocument()->GetAISContext()->CloseLocalContext();
myView->UpdateLights();
+ myView->Redraw();
TCollection_AsciiString Message("\
-myCurrent_AmbientLight=new V3d_AmbientLight(myView->Viewer(), Quantity_NOC_GRAY);\n\
+myCurrent_AmbientLight=new V3d_AmbientLight(Quantity_NOC_GRAY);\n\
\n\
myView->SetLightOn(myCurrent_AmbientLight) ;\n\
");
myView->Redraw();
}
-void CViewer3dView::OnZcueing()
-{
- ZCueingDlg Dlg(myView, GetDocument());
- Dlg.DoModal();
- myView->Redraw();
-}
-
-void CViewer3dView::OnZclipping()
-{
- ZClippingDlg Dlg(myView, GetDocument());
- Dlg.DoModal();
- myView->Redraw();
-}
-
//V3d_View.hxx
void CViewer3dView::OnShadingmodel()
void CViewer3dView::OnAntialiasingonoff()
{
- if(!myView->Antialiasing())
- myView->SetAntialiasingOn();
- else
- myView->SetAntialiasingOff();
-
+ Graphic3d_RenderingParams& aParams = myView->ChangeRenderingParams();
+ aParams.NbMsaaSamples = aParams.NbMsaaSamples == 0 ? 8 : 0;
myView->Update();
TCollection_AsciiString Message("\
-if(!myView->Antialiasing())\n\
- myView->SetAntialiasingOn();\n\
-else\n\
- myView->SetAntialiasingOff();\n\
+Graphic3d_RenderingParams& aParams = myView->ChangeRenderingParams();\n\
+aParams.NbMsaaSamples = aParams.NbMsaaSamples == 0 ? 8 : 0;\n\
");
// Update The Result Message Dialog
GetDocument()->UpdateResultMessageDlg("SetAntialiasingOn/SetAntialiasingOff",Message);
}
-void CViewer3dView::OnClearLights()
+void CViewer3dView::OnClearLights()
{
-// Setting Off all viewer active lights
- for(myView->Viewer()->InitActiveLights(); myView->Viewer()->MoreActiveLights(); myView->Viewer()->NextActiveLights())
- myView->Viewer()->SetLightOff(myView->Viewer()->ActiveLight());
-// Setting Off all view active lights
- for(myView->InitActiveLights(); myView->MoreActiveLights(); myView->NextActiveLights())
- myView->SetLightOff(myView->ActiveLight());
+// Setting Off all viewer active lights
+ V3d_ListOfLight lights;
+ for (V3d_ListOfLightIterator anIter = myView->Viewer()->ActiveLightIterator(); anIter.More(); anIter.Next())
+ {
+ lights.Append (anIter.Value());
+ }
+ V3d_ListOfLightIterator itrLights(lights);
+ for (; itrLights.More(); itrLights.Next())
+ {
+ myView->Viewer()->SetLightOff (itrLights.Value());
+ }
- myView->Viewer()->SetDefaultLights();// Setting the default lights on
+// Setting Off all view active lights
+ lights.Clear();
+ for (V3d_ListOfLightIterator anIter = myView->ActiveLightIterator(); anIter.More(); anIter.Next())
+ {
+ lights.Append (anIter.Value());
+ }
+ itrLights.Initialize (lights);
+ for (; itrLights.More(); itrLights.Next())
+ {
+ myView->SetLightOff (itrLights.Value());
+ }
- NbActiveLights = 2;// There are 2 default active lights
+ myView->Viewer()->SetDefaultLights(); // Setting the default lights on
- myView->Update();
+ NbActiveLights = 2; // There are 2 default active lights
+
+ myView->Update();
TCollection_AsciiString Message("\
-for(myView->Viewer()->InitActiveLights(); myView->Viewer()->MoreActiveLights(); myView->Viewer()->NextActiveLights())\n\
- myView->Viewer()->SetLightOff(myView->Viewer()->ActiveLight()); //Setting Off all viewer active lights\n\
-for(myView->InitActiveLights(); myView->MoreActiveLights(); myView->NextActiveLights())\n\
- myView->SetLightOff(myView->ActiveLight()); //Setting Off all view active lights\n\
+// Setting Off all viewer active lights\n\
+V3d_ListOfLight lights;\n\
+for (V3d_ListOfLightIterator anIter = myView->Viewer()->ActiveLightIterator(); anIter.More(); anIter.Next())\n\
+{\n\
+ lights.Append (anIter.Value());\n\
+}\n\
+V3d_ListOfLightIterator itrLights(lights);\n\
+for (; itrLights.More(); itrLights.Next())\n\
+{\n\
+ myView->Viewer()->SetLightOff (itrLights.Value())\n\
+}\n\
+\n\
+// Setting Off all view active lights\n\
+lights.Clear();\n\
+for (V3d_ListOfLightIterator anIter = myView->ActiveLightIterator(); anIter.More(); anIter.Next())\n\
+{\n\
+ lights.Append (anIter.Value());\n\
+}\n\
+itrLights.Initialize(lights);\n\
+for (; itrLights.More(); itrLights.Next())\n\
+{\n\
+ myView->SetLightOff (itrLights.Value());\n\
+}\n\
\n\
myView->Viewer()->SetDefaultLights();// Setting the default lights on\n\
");
void CViewer3dView::OnModelclipping()
{
- if( myPlane.IsNull() )
- {
-//creates a plane defined : center of the box ( 50,50,50) and 1 direction
- gp_Pln tmpPln(gp_Pnt(0,0,0),gp_Dir(1,0,0));
-//getting the coefficients of the gp_Pln ( ax+by+cz+d = 0 )
- Standard_Real A,B,C,D;
- tmpPln.Coefficients(A,B,C,D);
-//with these coefficients, creating a V3d_Plane
- myPlane = new V3d_Plane(
- GetDocument()->GetViewer(),A,B,C,D);
-//creates the Face
-//NOTE : the face must be behind the clipping plane !!
- tmpPln = gp_Pln(gp_Pnt(0.1,0,0),gp_Dir(1,0,0));
- BRepBuilderAPI_MakeFace MakeFace(tmpPln, 200, -200, 410, -410);
- TopoDS_Face S = MakeFace.Face();
-//display the face
- myShape = new AIS_Shape(S);
- }
-
- CModelClippingDlg Dlg(myView, myPlane, myShape, GetDocument());
- Dlg.DoModal();
+ if (myClippingPlane.IsNull())
+ {
+ gp_Pln aClipPlane (gp_Pnt (0.0, 0.0, 0.0), gp_Dir (1.0, 0.0, 0.0));
+ gp_Pln aFacePlane (gp_Pnt (0.1, 0.0, 0.0), gp_Dir (1.0, 0.0, 0.0));
+
+ // create clipping plane and add to view
+ myClippingPlane = new Graphic3d_ClipPlane (aClipPlane);
+
+ // shape to represent clipping plane
+ BRepBuilderAPI_MakeFace aMakeFaceCommand (aFacePlane, 200.0, -200.0, 410.0, -410.0);
+ TopoDS_Face aShape = aMakeFaceCommand.Face();
+ myShape = new AIS_Shape (aShape);
+ myShape->SetTransparency (0.5);
+ }
+
+ CModelClippingDlg aClippingDlg (myView, myShape, myClippingPlane, GetDocument());
+
+ aClippingDlg.DoModal();
}
void CViewer3dView::OnOptionsTrihedronStaticTrihedron()
}
}
-void CViewer3dView::GetViewCenter(V3d_Coordinate& Xc, V3d_Coordinate& Yc)
+void CViewer3dView::GetViewAt (Standard_Real& theX, Standard_Real& theY, Standard_Real& theZ) const
{
- myView->Center(Xc,Yc);
+ myView->At (theX, theY, theZ);
}
-void CViewer3dView::SetViewCenter(V3d_Coordinate Xc, V3d_Coordinate Yc)
+void CViewer3dView::SetViewAt (const Standard_Real theX, const Standard_Real theY, const Standard_Real theZ)
{
- myView->SetCenter(Xc,Yc);
+ myView->SetAt (theX, theY, theZ);
}
-void CViewer3dView::GetViewEye(V3d_Coordinate& X, V3d_Coordinate& Y, V3d_Coordinate& Z)
+void CViewer3dView::GetViewEye(Standard_Real& X, Standard_Real& Y, Standard_Real& Z)
{
myView->Eye(X,Y,Z);
}
-void CViewer3dView::SetViewEye(V3d_Coordinate X, V3d_Coordinate Y, V3d_Coordinate Z)
+void CViewer3dView::SetViewEye(Standard_Real X, Standard_Real Y, Standard_Real Z)
{
myView->SetEye(X,Y,Z);
}
-Quantity_Factor CViewer3dView::GetViewScale()
+Standard_Real CViewer3dView::GetViewScale()
{
return myView->Scale();
}
-void CViewer3dView::SetViewScale(Quantity_Factor Coef)
+void CViewer3dView::SetViewScale(Standard_Real Coef)
{
myView->SetScale(Coef);
}
switch (myVisMode)
{
case VIS_WIREFRAME:
- GetDocument()->GetAISContext()->SetDisplayMode(AIS_WireFrame);
+ GetDocument()->GetAISContext()->SetDisplayMode (AIS_WireFrame, Standard_True);
myView->SetComputedMode (Standard_False);
+ myView->Redraw();
break;
case VIS_SHADE:
- GetDocument()->GetAISContext()->SetDisplayMode(AIS_Shaded);
+ GetDocument()->GetAISContext()->SetDisplayMode (AIS_Shaded, Standard_True);
myView->SetComputedMode (Standard_False);
+ myView->Redraw();
break;
case VIS_HLR:
SetCursor(AfxGetApp()->LoadStandardCursor(IDC_WAIT));
myView->SetComputedMode (Standard_True);
+ myView->Redraw();
SetCursor(AfxGetApp()->LoadStandardCursor(IDC_ARROW));
- GetDocument()->GetAISContext()->SetDisplayMode(AIS_WireFrame);
+ GetDocument()->GetAISContext()->SetDisplayMode (AIS_WireFrame, Standard_True);
break;
}
}