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()
79 if (m_Pen) delete m_Pen;
82 BOOL OCC_2dView::PreCreateWindow(CREATESTRUCT& cs)
84 // TODO: Modify the Window class or styles here by modifying
85 // the CREATESTRUCT cs
86 return CView::PreCreateWindow(cs);
89 /////////////////////////////////////////////////////////////////////////////
92 void OCC_2dView::OnDraw(CDC* pDC)
94 if (!myV2dView.IsNull())
98 void OCC_2dView::OnInitialUpdate()
100 CView::OnInitialUpdate();
102 Handle(WNT_Window) aWNTWindow = new WNT_Window(GetSafeHwnd(),Quantity_NOC_MATRAGRAY);
103 myV2dView =((OCC_2dDoc*)GetDocument())->GetViewer2D()->CreateView();
104 myV2dView->SetWindow(aWNTWindow);
105 myV2dView->SetZClippingType(V3d_OFF);
106 myV2dView->SetSurfaceDetail(V3d_TEX_ALL);
107 // initialize the grids dialogs
108 TheRectangularGridDialog.Create(CRectangularGrid::IDD, NULL);
109 TheCircularGridDialog.Create(CCircularGrid::IDD, NULL);
110 TheRectangularGridDialog.SetViewer (((OCC_2dDoc*)GetDocument())->GetViewer2D());
111 TheCircularGridDialog.SetViewer (((OCC_2dDoc*)GetDocument())->GetViewer2D());
113 Standard_Integer w=100 , h=100 ; /* Debug Matrox */
114 aWNTWindow->Size (w,h) ; /* Keeps me unsatisfied (rlb)..... */
115 /* Resize is not supposed to be done on */
117 /* I suspect another problem elsewhere */
118 ::PostMessage ( GetSafeHwnd () , WM_SIZE , SIZE_RESTORED , w + h*65536 ) ;
122 void OCC_2dView::OnFileExportImage()
125 filter = _T("EXR Files (*.EXR)|*.exr|TGA Files (*.TGA)|*.tga|TIFF Files (*.TIFF)|*.tiff|"
126 "PPM Files (*.PPM)|*.ppm|JPEG Files(*.JPEG)|*.jpeg|PNG Files (*.PNG)|*.png|"
127 "GIF Files (*.GIF)|*.gif|BMP Files (*.BMP)|*.bmp|PS Files (*.PS)|*.ps|"
128 "EPS Files (*.EPS)|*.eps|TEX Files (*.TEX)|*.tex|PDF Files (*.PDF)|*.pdf"
129 "|SVG Files (*.SVG)|*.svg|PGF Files (*.PGF)|*.pgf|EMF Files (*.EMF)|*.emf||");
130 CFileDialog dlg(FALSE,_T("*.BMP"),NULL,OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT,
135 if (dlg.DoModal() == IDOK)
137 SetCursor(AfxGetApp()->LoadStandardCursor(IDC_WAIT));
138 CString aFileName = dlg.GetPathName();
139 CString ext = dlg.GetFileExt();
140 if (!(ext.CompareNoCase("ps")) || !(ext.CompareNoCase("emf"))
141 || !(ext.CompareNoCase("pdf")) || !(ext.CompareNoCase("eps"))
142 || !(ext.CompareNoCase("tex")) || !(ext.CompareNoCase("svg"))
143 || !(ext.CompareNoCase("pgf")))
145 Graphic3d_ExportFormat exFormat;
146 if (!(ext.CompareNoCase("ps"))) exFormat = Graphic3d_EF_PostScript;
147 else exFormat = Graphic3d_EF_EnhPostScript;
148 myV2dView->View()->Export( aFileName, exFormat );
151 myV2dView->Dump(aFileName);
152 SetCursor(AfxGetApp()->LoadStandardCursor(IDC_ARROW));
156 /////////////////////////////////////////////////////////////////////////////
157 // OCC_2dView diagnostics
160 void OCC_2dView::AssertValid() const
162 CView::AssertValid();
165 void OCC_2dView::Dump(CDumpContext& dc) const
170 OCC_2dDoc* OCC_2dView::GetDocument() // non-debug version is inline
172 //ASSERT(m_pDocument->IsKindOf(RUNTIME_CLASS(OCC_2dDoc)));
173 return (OCC_2dDoc*)m_pDocument;
176 void OCC_2dView::OnBUTTONGridRectLines()
178 Handle(V3d_Viewer) aViewer = myV2dView->Viewer();
179 Handle(Graphic3d_AspectMarker3d) aGridAspect = new Graphic3d_AspectMarker3d(Aspect_TOM_BALL,Quantity_NOC_WHITE,2);
180 aViewer->SetGridEcho(aGridAspect);
181 Standard_Integer aWidth=0, aHeight=0, anOffset=0;
182 myV2dView->Window()->Size(aWidth,aHeight);
183 aViewer->SetRectangularGridGraphicValues(aWidth,aHeight,anOffset);
184 aViewer->ActivateGrid(Aspect_GT_Rectangular, Aspect_GDM_Lines);
187 if (TheCircularGridDialog.IsWindowVisible())
189 TheCircularGridDialog.ShowWindow(SW_HIDE);
190 TheRectangularGridDialog.UpdateValues();
191 TheRectangularGridDialog.ShowWindow(SW_SHOW);
195 void OCC_2dView::OnBUTTONGridRectPoints()
197 Handle(V3d_Viewer) aViewer = myV2dView->Viewer();
198 Handle(Graphic3d_AspectMarker3d) aGridAspect = new Graphic3d_AspectMarker3d(Aspect_TOM_BALL,Quantity_NOC_WHITE,2);
199 aViewer->SetGridEcho(aGridAspect);
200 Standard_Integer aWidth=0, aHeight=0, anOffset=0;
201 myV2dView->Window()->Size(aWidth,aHeight);
202 aViewer->SetRectangularGridGraphicValues(aWidth,aHeight,anOffset);
203 aViewer->ActivateGrid(Aspect_GT_Rectangular, Aspect_GDM_Points);
206 if (TheCircularGridDialog.IsWindowVisible())
208 TheCircularGridDialog.ShowWindow(SW_HIDE);
209 TheRectangularGridDialog.UpdateValues();
210 TheRectangularGridDialog.ShowWindow(SW_SHOW);
214 void OCC_2dView::OnBUTTONGridCircLines()
216 Handle(V3d_Viewer) aViewer = myV2dView->Viewer();
217 Handle(Graphic3d_AspectMarker3d) aGridAspect = new Graphic3d_AspectMarker3d(Aspect_TOM_BALL,Quantity_NOC_WHITE,2);
218 aViewer->SetGridEcho(aGridAspect);
219 Standard_Integer aWidth=0, aHeight=0, anOffset=0;
220 myV2dView->Window()->Size(aWidth,aHeight);
221 aViewer->SetCircularGridGraphicValues(aWidth>aHeight?aWidth:aHeight,anOffset);
222 aViewer->ActivateGrid(Aspect_GT_Circular, Aspect_GDM_Lines);
226 if (TheRectangularGridDialog.IsWindowVisible())
228 TheRectangularGridDialog.ShowWindow(SW_HIDE);
229 TheCircularGridDialog.UpdateValues();
230 TheCircularGridDialog.ShowWindow(SW_SHOW);
234 void OCC_2dView::OnBUTTONGridCircPoints()
236 Handle(V3d_Viewer) aViewer = myV2dView->Viewer();
237 Handle(Graphic3d_AspectMarker3d) aGridAspect = new Graphic3d_AspectMarker3d(Aspect_TOM_BALL,Quantity_NOC_WHITE,2);
238 aViewer->SetGridEcho(aGridAspect);
239 Standard_Integer aWidth=0, aHeight=0, anOffset=0;
240 myV2dView->Window()->Size(aWidth,aHeight);
241 aViewer->SetCircularGridGraphicValues(aWidth>aHeight?aWidth:aHeight,anOffset);
242 aViewer->ActivateGrid(Aspect_GT_Circular, Aspect_GDM_Points);
244 if (TheRectangularGridDialog.IsWindowVisible())
246 TheRectangularGridDialog.ShowWindow(SW_HIDE);
247 TheCircularGridDialog.UpdateValues();
248 TheCircularGridDialog.ShowWindow(SW_SHOW);
252 void OCC_2dView::OnBUTTONGridValues()
254 Handle(V3d_Viewer) aViewer = myV2dView->Viewer();
255 Aspect_GridType TheGridtype = aViewer->GridType();
257 switch( TheGridtype )
259 case Aspect_GT_Rectangular:
260 TheRectangularGridDialog.UpdateValues();
261 TheRectangularGridDialog.ShowWindow(SW_SHOW);
263 case Aspect_GT_Circular:
264 TheCircularGridDialog.UpdateValues();
265 TheCircularGridDialog.ShowWindow(SW_SHOW);
268 Standard_Failure::Raise("invalid Aspect_GridType");
271 void OCC_2dView::OnUpdateBUTTONGridValues(CCmdUI* pCmdUI)
273 Handle(V3d_Viewer) aViewer = myV2dView->Viewer();
274 pCmdUI-> Enable( aViewer->IsActive() );
277 void OCC_2dView::OnBUTTONGridCancel()
279 Handle(V3d_Viewer) aViewer = myV2dView->Viewer();
280 aViewer->DeactivateGrid();
281 TheRectangularGridDialog.ShowWindow(SW_HIDE);
282 TheCircularGridDialog.ShowWindow(SW_HIDE);
285 void OCC_2dView::OnUpdateBUTTONGridCancel(CCmdUI* pCmdUI)
287 Handle(V3d_Viewer) aViewer = myV2dView->Viewer();
288 pCmdUI-> Enable( aViewer->IsActive() );
291 void OCC_2dView::OnLButtonDown(UINT nFlags, CPoint point)
293 // save the current mouse coordinate in min
294 myXmin=point.x; myYmin=point.y;
295 myXmax=point.x; myYmax=point.y;
297 if ( nFlags & CASCADESHORTCUTKEY )
299 // Button MB1 down Control :start zomming
302 else // if ( MULTISELECTIONKEY )
304 switch (myCurrentMode)
306 case CurAction2d_Nothing : // start a drag
307 DragEvent2D(point.x,point.y,-1);
309 case CurAction2d_DynamicZooming : // nothing
311 case CurAction2d_WindowZooming : // nothing
313 case CurAction2d_DynamicPanning :// nothing
315 case CurAction2d_GlobalPanning :// nothing
318 Standard_Failure::Raise(" incompatible Current Mode ");
325 void OCC_2dView::OnLButtonUp(UINT nFlags, CPoint point)
327 // TODO: Add your message handler code here and/or call default
328 if ( nFlags & CASCADESHORTCUTKEY )
334 switch (myCurrentMode)
336 case CurAction2d_Nothing :
337 if (point.x == myXmin && point.y == myYmin)
338 { // no offset between down and up --> selectEvent
341 if (nFlags & MULTISELECTIONKEY )
342 MultiInputEvent2D(point.x,point.y);
344 InputEvent2D (point.x,point.y);
347 DrawRectangle2D(myXmin,myYmin,myXmax,myYmax,Standard_False);
350 if (nFlags & MULTISELECTIONKEY)
351 MultiDragEvent2D(point.x,point.y,1);
353 DragEvent2D(point.x,point.y,1);
356 case CurAction2d_DynamicZooming :
358 myCurrentMode = CurAction2d_Nothing;
360 case CurAction2d_WindowZooming :
361 myXmax=point.x; myYmax=point.y;
362 DrawRectangle2D(myXmin,myYmin,myXmax,myYmax,Standard_False,LongDash);
363 if ((abs(myXmin-myXmax)>ValZWMin) || (abs(myYmin-myYmax)>ValZWMin))
364 // Test if the zoom window is greater than a minimale window.
366 // Do the zoom window between Pmin and Pmax
367 myV2dView->WindowFit(myXmin,myYmin,myXmax,myYmax);
369 myCurrentMode = CurAction2d_Nothing;
371 case CurAction2d_DynamicPanning :
372 myCurrentMode = CurAction2d_Nothing;
374 case CurAction2d_GlobalPanning :
375 myV2dView->Place(point.x,point.y,myCurZoom);
376 myCurrentMode = CurAction2d_Nothing;
379 Standard_Failure::Raise(" incompatible Current Mode ");
381 } //switch (myCurrentMode)
382 } // else // if ( CASCADESHORTCUTKEY )
385 void OCC_2dView::OnMButtonDown(UINT nFlags, CPoint point)
387 if ( nFlags & CASCADESHORTCUTKEY )
389 // Button MB2 down + CASCADESHORTCUTKEY : panning init
394 void OCC_2dView::OnMButtonUp(UINT nFlags, CPoint point)
396 if ( nFlags & CASCADESHORTCUTKEY )
398 // Button MB2 up + CASCADESHORTCUTKEY : panning stop
402 void OCC_2dView::OnRButtonDown(UINT nFlags, CPoint point)
404 #ifdef POPUPONBUTTONDOWN
405 if ( !(nFlags & CASCADESHORTCUTKEY) )
406 Popup2D(point.x,point.y);
410 void OCC_2dView::OnRButtonUp(UINT nFlags, CPoint point)
412 #ifndef POPUPONBUTTONDOWN
413 if ( !(nFlags & CASCADESHORTCUTKEY) )
414 Popup2D(point.x,point.y);
418 void OCC_2dView::OnMouseMove(UINT nFlags, CPoint point)
420 // ============================ LEFT BUTTON =======================
421 if ( (nFlags & MK_LBUTTON) &! (nFlags & MK_RBUTTON) ) // Left + Right is specific
423 if ( nFlags & CASCADESHORTCUTKEY )
425 // move with MB1 and CASCADESHORTCUTKEY : on the dynamic zooming
426 // Do the zoom in function of mouse's coordinates
427 myV2dView->Zoom(myXmax,myYmax,point.x,point.y);
428 // save the current mouse coordinate in min
432 else // if ( CASCADESHORTCUTKEY )
434 switch (myCurrentMode)
436 case CurAction2d_Nothing :
437 myXmax = point.x; myYmax = point.y;
438 DrawRectangle2D(myXmin,myYmin,myXmax,myYmax,Standard_False);
439 DragEvent2D(myXmax,myYmax,0);
440 DrawRectangle2D(myXmin,myYmin,myXmax,myYmax,Standard_True);
442 case CurAction2d_DynamicZooming :
443 myV2dView->Zoom(myXmax,myYmax,point.x,point.y);
444 // save the current mouse coordinate in min \n";
445 myXmax=point.x; myYmax=point.y;
447 case CurAction2d_WindowZooming :
448 myXmax = point.x; myYmax = point.y;
449 DrawRectangle2D(myXmin,myYmin,myXmax,myYmax,Standard_False,LongDash);
450 DrawRectangle2D(myXmin,myYmin,myXmax,myYmax,Standard_True,LongDash);
452 case CurAction2d_DynamicPanning :
453 myV2dView->Pan(point.x-myXmax,myYmax-point.y); // Realize the panning
454 myXmax = point.x; myYmax = point.y;
456 case CurAction2d_GlobalPanning : // nothing
459 Standard_Failure::Raise(" incompatible Current Mode ");
461 }// switch (myCurrentMode)
462 }// if ( nFlags & CASCADESHORTCUTKEY ) else
463 } else // if ( nFlags & MK_LBUTTON)
464 // ============================ MIDDLE BUTTON =======================
465 if ( nFlags & MK_MBUTTON)
467 if ( nFlags & CASCADESHORTCUTKEY )
469 myV2dView->Pan(point.x-myXmax,myYmax-point.y); // Realize the panning
470 myXmax = point.x; myYmax = point.y;
473 } else // if ( nFlags & MK_MBUTTON)
474 // ============================ RIGHT BUTTON =======================
475 if ( (nFlags & MK_RBUTTON) &! (nFlags & MK_LBUTTON) ) // Left + Right is specific
477 }else //if ( nFlags & MK_RBUTTON)
478 if ( (nFlags & MK_RBUTTON) && (nFlags & MK_LBUTTON) )
480 // in case of Left + Right : same as Middle
481 if ( nFlags & CASCADESHORTCUTKEY )
483 myV2dView->Pan(point.x-myXmax,myYmax-point.y); // Realize the panning
484 myXmax = point.x; myYmax = point.y;
486 }else //if ( nFlags & MK_RBUTTON)&& (nFlags & MK_LBUTTON)
487 // ============================ NO BUTTON =======================
489 myXmax = point.x; myYmax = point.y;
490 if (nFlags & MULTISELECTIONKEY)
491 MultiMoveEvent2D(point.x,point.y);
493 MoveEvent2D(point.x,point.y);
498 void OCC_2dView::OnSize(UINT nType, int cx, int cy)
500 // Take care : This fonction is call before OnInitialUpdate
501 if (!myV2dView.IsNull())
502 myV2dView->MustBeResized();
506 void OCC_2dView::OnBUTTONFitAll()
511 void OCC_2dView::OnBUTTONGlobPanning()
513 //save the current zoom value
514 myCurZoom = myV2dView->Scale();
520 myCurrentMode = CurAction2d_GlobalPanning;
522 void OCC_2dView::OnBUTTONPanning()
524 myCurrentMode = CurAction2d_DynamicPanning;
526 void OCC_2dView::OnBUTTONZoomProg()
528 myCurrentMode = CurAction2d_DynamicZooming;
530 void OCC_2dView::OnBUTTONZoomWin()
532 myCurrentMode = CurAction2d_WindowZooming;
534 void OCC_2dView::OnChangeBackground()
536 Standard_Real R1, G1, B1;
537 Handle(Aspect_Window) aWindow = myV2dView->Window();
538 Aspect_Background ABack = aWindow->Background();
539 Quantity_Color aColor = ABack.Color();
540 aColor.Values(R1,G1,B1,Quantity_TOC_RGB);
542 m_clr = RGB(R1*255,G1*255,B1*255);
544 CColorDialog dlgColor(m_clr);
545 if (dlgColor.DoModal() == IDOK)
547 m_clr = dlgColor.GetColor();
548 R1 = GetRValue(m_clr)/255.;
549 G1 = GetGValue(m_clr)/255.;
550 B1 = GetBValue(m_clr)/255.;
551 aColor.SetValues(R1,G1,B1,Quantity_TOC_RGB);
552 myV2dView->SetBackgroundColor(aColor);
558 void OCC_2dView::OnUpdateBUTTON2DGlobPanning(CCmdUI* pCmdUI)
560 pCmdUI->SetCheck (myCurrentMode == CurAction2d_GlobalPanning);
561 pCmdUI->Enable (myCurrentMode != CurAction2d_GlobalPanning);
564 void OCC_2dView::OnUpdateBUTTON2DPanning(CCmdUI* pCmdUI)
566 pCmdUI->SetCheck (myCurrentMode == CurAction2d_DynamicPanning);
567 pCmdUI->Enable (myCurrentMode != CurAction2d_DynamicPanning);
570 void OCC_2dView::OnUpdateBUTTON2DZoomProg(CCmdUI* pCmdUI)
572 pCmdUI->SetCheck (myCurrentMode == CurAction2d_DynamicZooming);
573 pCmdUI->Enable (myCurrentMode != CurAction2d_DynamicZooming);
576 void OCC_2dView::OnUpdateBUTTON2DZoomWin(CCmdUI* pCmdUI)
578 pCmdUI->SetCheck (myCurrentMode == CurAction2d_WindowZooming);
579 pCmdUI->Enable (myCurrentMode != CurAction2d_WindowZooming);
583 void OCC_2dView::DrawRectangle2D(const Standard_Integer MinX,
584 const Standard_Integer MinY,
585 const Standard_Integer MaxX,
586 const Standard_Integer MaxY,
587 const Standard_Boolean Draw,
588 const LineStyle aLineStyle)
590 static int m_DrawMode;
591 if (!m_Pen && aLineStyle ==Solid )
592 {m_Pen = new CPen(PS_SOLID, 1, RGB(0,0,0)); m_DrawMode = R2_MERGEPENNOT;}
593 else if (!m_Pen && aLineStyle ==Dot )
594 {m_Pen = new CPen(PS_DOT, 1, RGB(0,0,0)); m_DrawMode = R2_XORPEN;}
595 else if (!m_Pen && aLineStyle == ShortDash)
596 {m_Pen = new CPen(PS_DASH, 1, RGB(255,0,0)); m_DrawMode = R2_XORPEN;}
597 else if (!m_Pen && aLineStyle == LongDash)
598 {m_Pen = new CPen(PS_DASH, 1, RGB(0,0,0)); m_DrawMode = R2_NOTXORPEN;}
599 else if (aLineStyle == Default)
600 { m_Pen = NULL; m_DrawMode = R2_MERGEPENNOT;}
603 CClientDC clientDC(this);
604 if (m_Pen) aOldPen = clientDC.SelectObject(m_Pen);
605 clientDC.SetROP2(m_DrawMode);
607 static Standard_Integer StoredMinX, StoredMaxX, StoredMinY, StoredMaxY;
608 static Standard_Boolean m_IsVisible;
610 if ( m_IsVisible && !Draw) // move or up : erase at the old position
612 clientDC.MoveTo(StoredMinX,StoredMinY); clientDC.LineTo(StoredMinX,StoredMaxY);
613 clientDC.LineTo(StoredMaxX,StoredMaxY);
614 clientDC.LineTo(StoredMaxX,StoredMinY); clientDC.LineTo(StoredMinX,StoredMinY);
618 StoredMinX = min ( MinX, MaxX );
619 StoredMinY = min ( MinY, MaxY );
620 StoredMaxX = max ( MinX, MaxX );
621 StoredMaxY = max ( MinY, MaxY);
623 if (Draw) // move : draw
625 clientDC.MoveTo(StoredMinX,StoredMinY); clientDC.LineTo(StoredMinX,StoredMaxY);
626 clientDC.LineTo(StoredMaxX,StoredMaxY);
627 clientDC.LineTo(StoredMaxX,StoredMinY); clientDC.LineTo(StoredMinX,StoredMinY);
631 if (m_Pen) clientDC.SelectObject(aOldPen);
636 // =====================================================================
638 //-----------------------------------------------------------------------------------------
640 //-----------------------------------------------------------------------------------------
641 void OCC_2dView::DragEvent2D(const Standard_Integer x,
642 const Standard_Integer y,
643 const Standard_Integer TheState)
645 // TheState == -1 button down
646 // TheState == 0 move
647 // TheState == 1 button up
649 static Standard_Integer theButtonDownX=0;
650 static Standard_Integer theButtonDownY=0;
660 ((OCC_2dDoc*)GetDocument())->GetInteractiveContext()->MoveTo(x,y,myV2dView);
661 ((OCC_2dDoc*)GetDocument())->GetInteractiveContext()->Select(theButtonDownX,theButtonDownY,x,y,myV2dView);
666 ((OCC_2dDoc*)GetDocument())->GetInteractiveContext()->Select(true);
671 //-----------------------------------------------------------------------------------------
673 //-----------------------------------------------------------------------------------------
674 void OCC_2dView::InputEvent2D(const Standard_Integer x ,
675 const Standard_Integer y )
677 ((OCC_2dDoc*)GetDocument())->GetInteractiveContext()->Select(true);
680 //-----------------------------------------------------------------------------------------
682 //-----------------------------------------------------------------------------------------
683 void OCC_2dView::MoveEvent2D(const Standard_Integer x,
684 const Standard_Integer y)
686 if(myV2dView->Viewer()->Grid()->IsActive())
688 Quantity_Length aGridX=0,aGridY=0,aGridZ=0;
689 myV2dView->ConvertToGrid(x,y,aGridX,aGridY,aGridZ);
690 //View is not updated automatically in ConvertToGrid
693 ((OCC_2dDoc*)GetDocument())->GetInteractiveContext()->MoveTo(x,y,myV2dView);
696 //-----------------------------------------------------------------------------------------
698 //-----------------------------------------------------------------------------------------
699 void OCC_2dView::MultiMoveEvent2D(const Standard_Integer x,
700 const Standard_Integer y)
702 // MultiMoveEvent2D means we move the mouse in a multi selection mode
703 ((OCC_2dDoc*)GetDocument())->GetInteractiveContext()->MoveTo(x,y,myV2dView);
706 //-----------------------------------------------------------------------------------------
708 //-----------------------------------------------------------------------------------------
709 void OCC_2dView::MultiDragEvent2D(const Standard_Integer x ,
710 const Standard_Integer y ,
711 const Standard_Integer TheState)
713 static Standard_Integer theButtonDownX=0;
714 static Standard_Integer theButtonDownY=0;
724 ((OCC_2dDoc*)GetDocument())->GetInteractiveContext()->MoveTo(x,y,myV2dView);
725 ((OCC_2dDoc*)GetDocument())->GetInteractiveContext()->ShiftSelect(theButtonDownX,theButtonDownY,x,y,myV2dView);;
730 ((OCC_2dDoc*)GetDocument())->GetInteractiveContext()->ShiftSelect(true);
735 //-----------------------------------------------------------------------------------------
737 //-----------------------------------------------------------------------------------------
738 void OCC_2dView::MultiInputEvent2D(const Standard_Integer x ,
739 const Standard_Integer y )
741 ((OCC_2dDoc*)GetDocument())->GetInteractiveContext()->ShiftSelect(true);
744 //-----------------------------------------------------------------------------------------
746 //-----------------------------------------------------------------------------------------
747 void OCC_2dView::Popup2D(const Standard_Integer x,
748 const Standard_Integer y )
753 // load the 'normal' popup
754 VERIFY(menu.LoadMenu(IDR_Popup2D));
755 // activate the sub menu '0'
756 pPopup= menu.GetSubMenu(0);
757 ASSERT(pPopup != NULL);
760 POINT winCoord = { x , y };
761 ClientToScreen ( &winCoord);
762 pPopup->TrackPopupMenu(TPM_LEFTALIGN | TPM_RIGHTBUTTON , winCoord.x, winCoord.y , AfxGetMainWnd());
765 void OCC_2dView::FitAll()