1 // OCC_2dView.cpp: implementation of the OCC_2dView class.
3 //////////////////////////////////////////////////////////////////////
6 #include "OCC_2dView.h"
10 #include "resource2d\RectangularGrid.h"
11 #include "resource2d\CircularGrid.h"
13 #include "Quantity_Color.hxx"
14 #include "Quantity_NameOfColor.hxx"
18 // the key for multi selection :
19 #define MULTISELECTIONKEY MK_SHIFT
21 // the key for shortcut ( use to activate dynamic rotation, panning )
22 #define CASCADESHORTCUTKEY MK_CONTROL
24 // define in witch case you want to display the popup
25 #define POPUPONBUTTONDOWN
27 /////////////////////////////////////////////////////////////////////////////
30 IMPLEMENT_DYNCREATE(OCC_2dView, CView)
32 BEGIN_MESSAGE_MAP(OCC_2dView, CView)
33 //{{AFX_MSG_MAP(OCC_2dView)
34 // NOTE - the ClassWizard will add and remove mapping macros here.
35 // DO NOT EDIT what you see in these blocks of generated code!
36 ON_COMMAND(ID_FILE_EXPORT_IMAGE, OnFileExportImage)
37 ON_COMMAND(ID_BUTTON2DGridRectLines, OnBUTTONGridRectLines)
38 ON_COMMAND(ID_BUTTON2DGridRectPoints, OnBUTTONGridRectPoints)
39 ON_COMMAND(ID_BUTTON2DGridCircLines, OnBUTTONGridCircLines)
40 ON_COMMAND(ID_BUTTON2DGridCircPoints, OnBUTTONGridCircPoints)
41 ON_COMMAND(ID_BUTTON2DGridValues, OnBUTTONGridValues)
42 ON_UPDATE_COMMAND_UI(ID_BUTTON2DGridValues, OnUpdateBUTTONGridValues)
43 ON_COMMAND(ID_BUTTON2DGridCancel, OnBUTTONGridCancel)
44 ON_UPDATE_COMMAND_UI(ID_BUTTON2DGridCancel, OnUpdateBUTTONGridCancel)
53 ON_COMMAND(ID_BUTTON2DFitAll, OnBUTTONFitAll)
54 ON_COMMAND(ID_BUTTON2DGlobPanning, OnBUTTONGlobPanning)
55 ON_COMMAND(ID_BUTTON2DPanning, OnBUTTONPanning)
56 ON_COMMAND(ID_BUTTON2DZoomProg, OnBUTTONZoomProg)
57 ON_COMMAND(ID_BUTTON2DZoomWin, OnBUTTONZoomWin)
58 ON_UPDATE_COMMAND_UI(ID_BUTTON2DGlobPanning, OnUpdateBUTTON2DGlobPanning)
59 ON_UPDATE_COMMAND_UI(ID_BUTTON2DPanning, OnUpdateBUTTON2DPanning)
60 ON_UPDATE_COMMAND_UI(ID_BUTTON2DZoomProg, OnUpdateBUTTON2DZoomProg)
61 ON_UPDATE_COMMAND_UI(ID_BUTTON2DZoomWin, OnUpdateBUTTON2DZoomWin)
62 ON_COMMAND(ID_Modify_ChangeBackground ,OnChangeBackground)
66 /////////////////////////////////////////////////////////////////////////////
67 // OCC_2dView construction/destruction
69 OCC_2dView::OCC_2dView()
71 // TODO: add construction code here
72 myCurrentMode = CurAction2d_Nothing;
76 OCC_2dView::~OCC_2dView()
78 Handle(V2d_Viewer) aViewer = myV2dView->Viewer();
79 aViewer->RemoveView(myV2dView);
80 if (m_Pen) delete m_Pen;
84 BOOL OCC_2dView::PreCreateWindow(CREATESTRUCT& cs)
86 // TODO: Modify the Window class or styles here by modifying
87 // the CREATESTRUCT cs
89 return CView::PreCreateWindow(cs);
92 /////////////////////////////////////////////////////////////////////////////
95 void OCC_2dView::OnDraw(CDC* pDC)
97 if (!myV2dView.IsNull())
101 void OCC_2dView::OnInitialUpdate()
103 CView::OnInitialUpdate();
105 Handle(WNT_Window) aWNTWindow;
106 aWNTWindow = new WNT_Window(((OCC_2dApp*)AfxGetApp())->GetGraphicDevice(),GetSafeHwnd());
107 aWNTWindow->SetBackground(Quantity_NOC_MATRAGRAY);
109 Handle(WNT_WDriver) aDriver= new WNT_WDriver(aWNTWindow);
110 myV2dView = new V2d_View(aDriver, ((OCC_2dDoc*)GetDocument())->GetViewer2D(),0,0,50);
112 // initialyse the grids dialogs
113 TheRectangularGridDialog.Create(CRectangularGrid::IDD, NULL);
114 TheCircularGridDialog.Create(CCircularGrid::IDD, NULL);
115 TheRectangularGridDialog.SetViewer (((OCC_2dDoc*)GetDocument())->GetViewer2D());
116 TheCircularGridDialog.SetViewer (((OCC_2dDoc*)GetDocument())->GetViewer2D());
118 Standard_Integer w=100 , h=100 ; /* Debug Matrox */
119 aWNTWindow->Size (w,h) ; /* Keeps me unsatisfied (rlb)..... */
120 /* Resize is not supposed to be done on */
122 /* I suspect another problem elsewhere */
123 ::PostMessage ( GetSafeHwnd () , WM_SIZE , SIZE_RESTORED , w + h*65536 ) ;
127 void OCC_2dView::OnFileExportImage()
129 CFileDialog dlg(FALSE,_T("*.BMP"),NULL,OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT,
130 _T("BMP Files (*.BMP)|*.bmp |GIF Files (*.GIF)|*.gif | PNG Files (*.PNG)|*.png"
131 "|JPEG Files (*.JPEG)|*.jpeg | PPM Files (*.PPM)|*.ppm | TIFF Files (*.TIFF)"
132 "|*.tiff | TGA Files (*.TGA)|*.tga | EXR Files (*.EXR)|*.exr||"),
135 if (dlg.DoModal() == IDOK)
137 SetCursor(AfxGetApp()->LoadStandardCursor(IDC_WAIT));
138 CString filename = dlg.GetPathName();
139 Handle(WNT_Window) aWNTWindow=
140 Handle(WNT_Window)::DownCast(myV2dView->Driver()->Window());
141 aWNTWindow->Dump ((Standard_CString)(LPCTSTR)filename);
142 SetCursor(AfxGetApp()->LoadStandardCursor(IDC_ARROW));
146 /////////////////////////////////////////////////////////////////////////////
147 // OCC_2dView diagnostics
150 void OCC_2dView::AssertValid() const
152 CView::AssertValid();
155 void OCC_2dView::Dump(CDumpContext& dc) const
160 CDocument* OCC_2dView::GetDocument() // non-debug version is inline
162 //ASSERT(m_pDocument->IsKindOf(RUNTIME_CLASS(OCC_2dDoc)));
166 #include <V2d_RectangularGrid.hxx>
167 void OCC_2dView::OnBUTTONGridRectLines()
169 Handle(V2d_Viewer) aViewer = myV2dView->Viewer();
170 aViewer->SetGridColor(Quantity_Color(Quantity_NOC_WHITE), Quantity_Color(Quantity_NOC_WHITE));
171 aViewer->ActivateGrid(Aspect_GT_Rectangular,
174 if (TheCircularGridDialog.IsWindowVisible())
176 TheCircularGridDialog.ShowWindow(SW_HIDE);
177 TheRectangularGridDialog.UpdateValues();
178 TheRectangularGridDialog.ShowWindow(SW_SHOW);
182 void OCC_2dView::OnBUTTONGridRectPoints()
184 Handle(V2d_Viewer) aViewer = myV2dView->Viewer();
185 aViewer->ActivateGrid(Aspect_GT_Rectangular,
187 aViewer->SetGridColor(Quantity_Color(Quantity_NOC_WHITE), Quantity_Color(Quantity_NOC_WHITE));
188 if (TheCircularGridDialog.IsWindowVisible())
190 TheCircularGridDialog.ShowWindow(SW_HIDE);
191 TheRectangularGridDialog.UpdateValues();
192 TheRectangularGridDialog.ShowWindow(SW_SHOW);
196 void OCC_2dView::OnBUTTONGridCircLines()
198 Handle(V2d_Viewer) aViewer = myV2dView->Viewer();
199 aViewer->SetGridColor(Quantity_Color(Quantity_NOC_WHITE), Quantity_Color(Quantity_NOC_WHITE));
200 aViewer->ActivateGrid(Aspect_GT_Circular,
204 if (TheRectangularGridDialog.IsWindowVisible())
206 TheRectangularGridDialog.ShowWindow(SW_HIDE);
207 TheCircularGridDialog.UpdateValues();
208 TheCircularGridDialog.ShowWindow(SW_SHOW);
212 void OCC_2dView::OnBUTTONGridCircPoints()
214 Handle(V2d_Viewer) aViewer = myV2dView->Viewer();
215 aViewer->SetGridColor(Quantity_Color(Quantity_NOC_WHITE), Quantity_Color(Quantity_NOC_WHITE));
216 aViewer->ActivateGrid(Aspect_GT_Circular,
218 if (TheRectangularGridDialog.IsWindowVisible())
220 TheRectangularGridDialog.ShowWindow(SW_HIDE);
221 TheCircularGridDialog.UpdateValues();
222 TheCircularGridDialog.ShowWindow(SW_SHOW);
226 void OCC_2dView::OnBUTTONGridValues()
228 Handle(V2d_Viewer) aViewer = myV2dView->Viewer();
229 Aspect_GridType TheGridtype = aViewer->GridType();
231 switch( TheGridtype )
233 case Aspect_GT_Rectangular:
234 TheRectangularGridDialog.UpdateValues();
235 TheRectangularGridDialog.ShowWindow(SW_SHOW);
237 case Aspect_GT_Circular:
238 TheCircularGridDialog.UpdateValues();
239 TheCircularGridDialog.ShowWindow(SW_SHOW);
242 Standard_Failure::Raise("invalid Aspect_GridType");
245 void OCC_2dView::OnUpdateBUTTONGridValues(CCmdUI* pCmdUI)
247 Handle(V2d_Viewer) aViewer = myV2dView->Viewer();
248 pCmdUI-> Enable( aViewer->IsActive() );
251 void OCC_2dView::OnBUTTONGridCancel()
253 Handle(V2d_Viewer) aViewer = myV2dView->Viewer();
254 aViewer->DeactivateGrid();
255 TheRectangularGridDialog.ShowWindow(SW_HIDE);
256 TheCircularGridDialog.ShowWindow(SW_HIDE);
259 void OCC_2dView::OnUpdateBUTTONGridCancel(CCmdUI* pCmdUI)
261 Handle(V2d_Viewer) aViewer = myV2dView->Viewer();
262 pCmdUI-> Enable( aViewer->IsActive() );
265 void OCC_2dView::OnLButtonDown(UINT nFlags, CPoint point)
267 // save the current mouse coordinate in min
268 myXmin=point.x; myYmin=point.y;
269 myXmax=point.x; myYmax=point.y;
271 if ( nFlags & CASCADESHORTCUTKEY )
273 // Button MB1 down Control :start zomming
276 else // if ( MULTISELECTIONKEY )
278 switch (myCurrentMode)
280 case CurAction2d_Nothing : // start a drag
281 DragEvent2D(point.x,point.y,-1);
283 case CurAction2d_DynamicZooming : // nothing
285 case CurAction2d_WindowZooming : // nothing
287 case CurAction2d_DynamicPanning :// nothing
289 case CurAction2d_GlobalPanning :// nothing
292 Standard_Failure::Raise(" incompatible Current Mode ");
299 void OCC_2dView::OnLButtonUp(UINT nFlags, CPoint point)
301 // TODO: Add your message handler code here and/or call default
302 if ( nFlags & CASCADESHORTCUTKEY )
308 switch (myCurrentMode)
310 case CurAction2d_Nothing :
311 if (point.x == myXmin && point.y == myYmin)
312 { // no offset between down and up --> selectEvent
315 if (nFlags & MULTISELECTIONKEY )
316 MultiInputEvent2D(point.x,point.y);
318 InputEvent2D (point.x,point.y);
321 DrawRectangle2D(myXmin,myYmin,myXmax,myYmax,Standard_False);
324 if (nFlags & MULTISELECTIONKEY)
325 MultiDragEvent2D(point.x,point.y,1);
327 DragEvent2D(point.x,point.y,1);
330 case CurAction2d_DynamicZooming :
332 myCurrentMode = CurAction2d_Nothing;
334 case CurAction2d_WindowZooming :
335 myXmax=point.x; myYmax=point.y;
336 DrawRectangle2D(myXmin,myYmin,myXmax,myYmax,Standard_False,LongDash);
337 if ((abs(myXmin-myXmax)>ValZWMin) || (abs(myYmin-myYmax)>ValZWMin))
338 // Test if the zoom window is greater than a minimale window.
340 // Do the zoom window between Pmin and Pmax
341 myV2dView->WindowFit(myXmin,myYmin,myXmax,myYmax);
343 myCurrentMode = CurAction2d_Nothing;
345 case CurAction2d_DynamicPanning :
346 myCurrentMode = CurAction2d_Nothing;
348 case CurAction2d_GlobalPanning :
349 myV2dView->Place(point.x,point.y,myCurZoom);
350 myCurrentMode = CurAction2d_Nothing;
353 Standard_Failure::Raise(" incompatible Current Mode ");
355 } //switch (myCurrentMode)
356 } // else // if ( CASCADESHORTCUTKEY )
359 void OCC_2dView::OnMButtonDown(UINT nFlags, CPoint point)
361 if ( nFlags & CASCADESHORTCUTKEY )
363 // Button MB2 down + CASCADESHORTCUTKEY : panning init
369 void OCC_2dView::OnMButtonUp(UINT nFlags, CPoint point)
371 if ( nFlags & CASCADESHORTCUTKEY )
373 // Button MB2 up + CASCADESHORTCUTKEY : panning stop
379 void OCC_2dView::OnRButtonDown(UINT nFlags, CPoint point)
381 #ifdef POPUPONBUTTONDOWN
382 if ( !(nFlags & CASCADESHORTCUTKEY) )
383 Popup2D(point.x,point.y);
387 void OCC_2dView::OnRButtonUp(UINT nFlags, CPoint point)
389 #ifndef POPUPONBUTTONDOWN
390 if ( !(nFlags & CASCADESHORTCUTKEY) )
391 Popup2D(point.x,point.y);
395 void OCC_2dView::OnMouseMove(UINT nFlags, CPoint point)
397 // ============================ LEFT BUTTON =======================
398 if ( (nFlags & MK_LBUTTON) &! (nFlags & MK_RBUTTON) ) // Left + Right is specific
400 if ( nFlags & CASCADESHORTCUTKEY )
402 // move with MB1 and CASCADESHORTCUTKEY : on the dynamic zooming
403 // Do the zoom in function of mouse's coordinates
404 myV2dView->Zoom(myXmax,myYmax,point.x,point.y);
405 // save the current mouse coordinate in min
409 else // if ( CASCADESHORTCUTKEY )
411 switch (myCurrentMode)
413 case CurAction2d_Nothing :
414 myXmax = point.x; myYmax = point.y;
415 DrawRectangle2D(myXmin,myYmin,myXmax,myYmax,Standard_False);
416 DragEvent2D(myXmax,myYmax,0);
417 DrawRectangle2D(myXmin,myYmin,myXmax,myYmax,Standard_True);
419 case CurAction2d_DynamicZooming :
420 myV2dView->Zoom(myXmax,myYmax,point.x,point.y);
421 // save the current mouse coordinate in min \n";
422 myXmax=point.x; myYmax=point.y;
424 case CurAction2d_WindowZooming :
425 myXmax = point.x; myYmax = point.y;
426 DrawRectangle2D(myXmin,myYmin,myXmax,myYmax,Standard_False,LongDash);
427 DrawRectangle2D(myXmin,myYmin,myXmax,myYmax,Standard_True,LongDash);
429 case CurAction2d_DynamicPanning :
430 myV2dView->Pan(point.x-myXmax,myYmax-point.y); // Realize the panning
431 myXmax = point.x; myYmax = point.y;
433 case CurAction2d_GlobalPanning : // nothing
436 Standard_Failure::Raise(" incompatible Current Mode ");
438 }// switch (myCurrentMode)
439 }// if ( nFlags & CASCADESHORTCUTKEY ) else
440 } else // if ( nFlags & MK_LBUTTON)
441 // ============================ MIDDLE BUTTON =======================
442 if ( nFlags & MK_MBUTTON)
444 if ( nFlags & CASCADESHORTCUTKEY )
446 myV2dView->Pan(point.x-myXmax,myYmax-point.y); // Realize the panning
447 myXmax = point.x; myYmax = point.y;
450 } else // if ( nFlags & MK_MBUTTON)
451 // ============================ RIGHT BUTTON =======================
452 if ( (nFlags & MK_RBUTTON) &! (nFlags & MK_LBUTTON) ) // Left + Right is specific
454 }else //if ( nFlags & MK_RBUTTON)
455 if ( (nFlags & MK_RBUTTON) && (nFlags & MK_LBUTTON) )
457 // in case of Left + Right : same as Middle
458 if ( nFlags & CASCADESHORTCUTKEY )
460 myV2dView->Pan(point.x-myXmax,myYmax-point.y); // Realize the panning
461 myXmax = point.x; myYmax = point.y;
463 }else //if ( nFlags & MK_RBUTTON)&& (nFlags & MK_LBUTTON)
464 // ============================ NO BUTTON =======================
466 myXmax = point.x; myYmax = point.y;
467 if (nFlags & MULTISELECTIONKEY)
468 MultiMoveEvent2D(point.x,point.y);
470 MoveEvent2D(point.x,point.y);
475 void OCC_2dView::OnSize(UINT nType, int cx, int cy)
477 // Take care : This fonction is call before OnInitialUpdate
478 if (!myV2dView.IsNull())
479 myV2dView->MustBeResized(V2d_TOWRE_ENLARGE_OBJECTS);
483 void OCC_2dView::OnBUTTONFitAll()
488 void OCC_2dView::OnBUTTONGlobPanning()
490 //save the current zoom value
491 myCurZoom = myV2dView->Zoom();
494 //myV2dView->Fitall();
497 myCurrentMode = CurAction2d_GlobalPanning;
499 void OCC_2dView::OnBUTTONPanning()
501 myCurrentMode = CurAction2d_DynamicPanning;
503 void OCC_2dView::OnBUTTONZoomProg()
505 myCurrentMode = CurAction2d_DynamicZooming;
507 void OCC_2dView::OnBUTTONZoomWin()
509 myCurrentMode = CurAction2d_WindowZooming;
511 void OCC_2dView::OnChangeBackground()
513 Standard_Real R1, G1, B1;
514 Handle(Aspect_WindowDriver) aWindowDriver = myV2dView->Driver();
515 Handle(Aspect_Window) aWindow = aWindowDriver->Window();
516 Aspect_Background ABack = aWindow->Background();
517 Quantity_Color aColor = ABack.Color();
518 aColor.Values(R1,G1,B1,Quantity_TOC_RGB);
520 m_clr = RGB(R1*255,G1*255,B1*255);
522 CColorDialog dlgColor(m_clr);
523 if (dlgColor.DoModal() == IDOK)
525 m_clr = dlgColor.GetColor();
526 R1 = GetRValue(m_clr)/255.;
527 G1 = GetGValue(m_clr)/255.;
528 B1 = GetBValue(m_clr)/255.;
529 aColor.SetValues(R1,G1,B1,Quantity_TOC_RGB);
530 ABack.SetColor(aColor);
531 aWindow->SetBackground(ABack);
537 void OCC_2dView::OnUpdateBUTTON2DGlobPanning(CCmdUI* pCmdUI)
539 pCmdUI->SetCheck (myCurrentMode == CurAction2d_GlobalPanning);
540 pCmdUI->Enable (myCurrentMode != CurAction2d_GlobalPanning);
543 void OCC_2dView::OnUpdateBUTTON2DPanning(CCmdUI* pCmdUI)
545 pCmdUI->SetCheck (myCurrentMode == CurAction2d_DynamicPanning);
546 pCmdUI->Enable (myCurrentMode != CurAction2d_DynamicPanning);
549 void OCC_2dView::OnUpdateBUTTON2DZoomProg(CCmdUI* pCmdUI)
551 pCmdUI->SetCheck (myCurrentMode == CurAction2d_DynamicZooming);
552 pCmdUI->Enable (myCurrentMode != CurAction2d_DynamicZooming);
555 void OCC_2dView::OnUpdateBUTTON2DZoomWin(CCmdUI* pCmdUI)
557 pCmdUI->SetCheck (myCurrentMode == CurAction2d_WindowZooming);
558 pCmdUI->Enable (myCurrentMode != CurAction2d_WindowZooming);
562 void OCC_2dView::DrawRectangle2D(const Standard_Integer MinX ,
563 const Standard_Integer MinY ,
564 const Standard_Integer MaxX ,
565 const Standard_Integer MaxY ,
566 const Standard_Boolean Draw ,
567 const LineStyle aLineStyle)
569 static int m_DrawMode;
570 if (!m_Pen && aLineStyle ==Solid )
571 {m_Pen = new CPen(PS_SOLID, 1, RGB(0,0,0)); m_DrawMode = R2_MERGEPENNOT;}
572 else if (!m_Pen && aLineStyle ==Dot )
573 {m_Pen = new CPen(PS_DOT, 1, RGB(0,0,0)); m_DrawMode = R2_XORPEN;}
574 else if (!m_Pen && aLineStyle == ShortDash)
575 {m_Pen = new CPen(PS_DASH, 1, RGB(255,0,0)); m_DrawMode = R2_XORPEN;}
576 else if (!m_Pen && aLineStyle == LongDash)
577 {m_Pen = new CPen(PS_DASH, 1, RGB(0,0,0)); m_DrawMode = R2_NOTXORPEN;}
578 else if (aLineStyle == Default)
579 { m_Pen = NULL; m_DrawMode = R2_MERGEPENNOT;}
582 CClientDC clientDC(this);
583 if (m_Pen) aOldPen = clientDC.SelectObject(m_Pen);
584 clientDC.SetROP2(m_DrawMode);
586 static Standard_Integer StoredMinX, StoredMaxX, StoredMinY, StoredMaxY;
587 static Standard_Boolean m_IsVisible;
589 if ( m_IsVisible && !Draw) // move or up : erase at the old position
591 clientDC.MoveTo(StoredMinX,StoredMinY); clientDC.LineTo(StoredMinX,StoredMaxY);
592 clientDC.LineTo(StoredMaxX,StoredMaxY);
593 clientDC.LineTo(StoredMaxX,StoredMinY); clientDC.LineTo(StoredMinX,StoredMinY);
597 StoredMinX = min ( MinX, MaxX );
598 StoredMinY = min ( MinY, MaxY );
599 StoredMaxX = max ( MinX, MaxX );
600 StoredMaxY = max ( MinY, MaxY);
602 if (Draw) // move : draw
604 clientDC.MoveTo(StoredMinX,StoredMinY); clientDC.LineTo(StoredMinX,StoredMaxY);
605 clientDC.LineTo(StoredMaxX,StoredMaxY);
606 clientDC.LineTo(StoredMaxX,StoredMinY); clientDC.LineTo(StoredMinX,StoredMinY);
610 if (m_Pen) clientDC.SelectObject(aOldPen);
615 // =====================================================================
617 //-----------------------------------------------------------------------------------------
619 //-----------------------------------------------------------------------------------------
620 void OCC_2dView::DragEvent2D(const Standard_Integer x ,
621 const Standard_Integer y ,
622 const Standard_Integer TheState )
624 // TheState == -1 button down
625 // TheState == 0 move
626 // TheState == 1 button up
628 static Standard_Integer theButtonDownX=0;
629 static Standard_Integer theButtonDownY=0;
639 ((OCC_2dDoc*)GetDocument())->GetInteractiveContext2D()->MoveTo(theButtonDownX,theButtonDownY,x,y,myV2dView);
644 ((OCC_2dDoc*)GetDocument())->GetInteractiveContext2D()->Select(true);
650 //-----------------------------------------------------------------------------------------
652 //-----------------------------------------------------------------------------------------
653 void OCC_2dView::InputEvent2D(const Standard_Integer x ,
654 const Standard_Integer y )
656 ((OCC_2dDoc*)GetDocument())->GetInteractiveContext2D()->Select(true);
660 //-----------------------------------------------------------------------------------------
662 //-----------------------------------------------------------------------------------------
663 void OCC_2dView::MoveEvent2D(const Standard_Integer x ,
664 const Standard_Integer y )
666 static bool LastIsGridActiveStatus = Standard_True;
667 if (myV2dView->Viewer()->IsActive() ) // about the grid
668 { myV2dView->ShowHit(x,y); LastIsGridActiveStatus = Standard_True;}
669 if (!myV2dView->Viewer()->IsActive() && LastIsGridActiveStatus ) // about the grid
670 {myV2dView->EraseHit(); LastIsGridActiveStatus = Standard_False;}
672 ((OCC_2dDoc*)GetDocument())->GetInteractiveContext2D()->MoveTo(x,y,myV2dView);
677 //-----------------------------------------------------------------------------------------
679 //-----------------------------------------------------------------------------------------
680 void OCC_2dView::MultiMoveEvent2D(const Standard_Integer x ,
681 const Standard_Integer y )
683 // MultiMoveEvent2D means we move the mouse in a multi selection mode
684 ((OCC_2dDoc*)GetDocument())->GetInteractiveContext2D()->MoveTo(x,y,myV2dView);
688 //-----------------------------------------------------------------------------------------
690 //-----------------------------------------------------------------------------------------
691 void OCC_2dView::MultiDragEvent2D(const Standard_Integer x ,
692 const Standard_Integer y ,
693 const Standard_Integer TheState)
695 static Standard_Integer theButtonDownX=0;
696 static Standard_Integer theButtonDownY=0;
706 ((OCC_2dDoc*)GetDocument())->GetInteractiveContext2D()->MoveTo(theButtonDownX,theButtonDownY,x,y,myV2dView);
711 ((OCC_2dDoc*)GetDocument())->GetInteractiveContext2D()->ShiftSelect(true);
716 //-----------------------------------------------------------------------------------------
718 //-----------------------------------------------------------------------------------------
719 void OCC_2dView::MultiInputEvent2D(const Standard_Integer x ,
720 const Standard_Integer y )
722 ((OCC_2dDoc*)GetDocument())->GetInteractiveContext2D()->ShiftSelect(true);
725 //-----------------------------------------------------------------------------------------
727 //-----------------------------------------------------------------------------------------
728 void OCC_2dView::Popup2D(const Standard_Integer x,
729 const Standard_Integer y )
734 // load the 'normal' popup
735 VERIFY(menu.LoadMenu(IDR_Popup2D));
736 // activate the sub menu '0'
737 pPopup= menu.GetSubMenu(0);
738 ASSERT(pPopup != NULL);
741 POINT winCoord = { x , y };
744 ClientToScreen ( &winCoord);
745 pPopup->TrackPopupMenu(TPM_LEFTALIGN | TPM_RIGHTBUTTON , winCoord.x, winCoord.y , AfxGetMainWnd());
749 void OCC_2dView::FitAll()