1 // HLRView.cpp : implementation of the CHLRView2D class
8 #include "resource2d\RectangularGrid.h"
9 #include "resource2d\CircularGrid.h"
14 //#define new DEBUG_NEW
16 static char THIS_FILE[] = __FILE__;
19 // the key for multi selection :
20 #define MULTISELECTIONKEY MK_SHIFT
22 // the key for shortcut ( use to activate dynamic rotation, panning )
23 #define CASCADESHORTCUTKEY MK_CONTROL
25 // define in witch case you want to display the popup
26 #define POPUPONBUTTONDOWN
28 /////////////////////////////////////////////////////////////////////////////
31 IMPLEMENT_DYNCREATE(CHLRView2D, OCC_2dView)
33 BEGIN_MESSAGE_MAP(CHLRView2D, OCC_2dView)
34 //{{AFX_MSG_MAP(CHLRView2D)
39 /////////////////////////////////////////////////////////////////////////////
40 // CHLRView2D construction/destruction
42 CHLRView2D::CHLRView2D()
46 CHLRView2D::~CHLRView2D()
50 CHLRDoc* CHLRView2D::GetDocument() // non-debug version is inline
52 //ASSERT(m_pDocument->IsKindOf(RUNTIME_CLASS(OCC_2dDoc)));
53 return (CHLRDoc*)m_pDocument;
57 void CHLRView2D::OnInitialUpdate()
59 Handle(WNT_Window) aWNTWindow;
60 aWNTWindow = new WNT_Window(GetSafeHwnd(),Quantity_NOC_GRAY);
61 myV2dView = GetDocument()->GetViewer2D()->CreateView();
62 myV2dView->SetWindow(aWNTWindow);
64 // initialyse the grids dialogs
65 TheRectangularGridDialog.Create(CRectangularGrid::IDD, NULL);
66 TheCircularGridDialog.Create(CCircularGrid::IDD, NULL);
67 TheRectangularGridDialog.SetViewer (GetDocument()->GetViewer2D());
68 TheCircularGridDialog.SetViewer (GetDocument()->GetViewer2D());
70 Standard_Integer w=100 , h=100 ; /* Debug Matrox */
71 aWNTWindow->Size (w,h) ; /* Keeps me unsatisfied (rlb)..... */
72 /* Resize is not supposed to be done on */
74 /* I suspect another problem elsewhere */
75 ::PostMessage ( GetSafeHwnd () , WM_SIZE , SIZE_RESTORED , w + h*65536 ) ;
78 //-----------------------------------------------------------------------------------------
80 //-----------------------------------------------------------------------------------------
81 void CHLRView2D::DragEvent2D(const Standard_Integer /*x*/,
82 const Standard_Integer /*y*/,
83 const Standard_Integer /*TheState*/)
88 //-----------------------------------------------------------------------------------------
90 //-----------------------------------------------------------------------------------------
91 void CHLRView2D::InputEvent2D(const Standard_Integer /*x*/,
92 const Standard_Integer /*y*/)
96 //-----------------------------------------------------------------------------------------
98 //-----------------------------------------------------------------------------------------
99 void CHLRView2D::MoveEvent2D(const Standard_Integer /*x*/,
100 const Standard_Integer /*y*/)
104 //-----------------------------------------------------------------------------------------
106 //-----------------------------------------------------------------------------------------
107 void CHLRView2D::MultiMoveEvent2D(const Standard_Integer /*x*/,
108 const Standard_Integer /*y*/)
112 //-----------------------------------------------------------------------------------------
114 //-----------------------------------------------------------------------------------------
115 void CHLRView2D::MultiDragEvent2D(const Standard_Integer /*x*/,
116 const Standard_Integer /*y*/,
117 const Standard_Integer /*TheState*/)
121 //-----------------------------------------------------------------------------------------
123 //-----------------------------------------------------------------------------------------
124 void CHLRView2D::MultiInputEvent2D(const Standard_Integer /*x*/,
125 const Standard_Integer /*y*/)
129 //-----------------------------------------------------------------------------------------
131 //-----------------------------------------------------------------------------------------
132 void CHLRView2D::OnMouseMove(UINT nFlags, CPoint point)
134 if ( (nFlags & MK_LBUTTON) &! (nFlags & MK_RBUTTON) ) // Left + Right is specific
136 if ( nFlags & CASCADESHORTCUTKEY )
138 // move with MB1 and CASCADESHORTCUTKEY : on the dynamic zooming
139 // Do the zoom in function of mouse's coordinates
140 myV2dView->Zoom(myXmax,myYmax,point.x,point.y);
144 else // if ( CASCADESHORTCUTKEY )
146 switch (myCurrentMode)
148 case CurAction2d_Nothing :
151 DragEvent2D(myXmax,myYmax,0);
153 case CurAction2d_DynamicZooming :
154 myV2dView->Zoom(myXmax,myYmax,point.x,point.y);
158 case CurAction2d_WindowZooming :
162 case CurAction2d_DynamicPanning :
163 myV2dView->Pan(point.x-myXmax,myYmax-point.y); // Realize the panning
167 case CurAction2d_GlobalPanning :
170 Standard_Failure::Raise(" incompatible Current Mode ");
174 } else if ( nFlags & MK_MBUTTON)
176 if ( nFlags & CASCADESHORTCUTKEY )
178 myV2dView->Pan (point.x-myXmax,myYmax-point.y);
182 } else if ( (nFlags & MK_RBUTTON) &! (nFlags & MK_LBUTTON) )
185 else if ( (nFlags & MK_RBUTTON) && (nFlags & MK_LBUTTON) )
187 if ( nFlags & CASCADESHORTCUTKEY )
189 myV2dView->Pan(point.x-myXmax,myYmax-point.y); // Realize the panning
190 myXmax = point.x; myYmax = point.y;
197 if (nFlags & MULTISELECTIONKEY)
199 MultiMoveEvent2D(point.x,point.y);
203 MoveEvent2D(point.x,point.y);
209 void CHLRView2D::AssertValid() const
211 OCC_2dView::AssertValid();
214 void CHLRView2D::Dump(CDumpContext& dc) const
216 OCC_2dView::Dump(dc);