/branches/JStudio3D/source/Tools/Editor/View.cpp

# · C++ · 1350 lines · 954 code · 221 blank · 175 comment · 131 complexity · 57263915034789d89e8d357034b24e0f MD5 · raw file

  1. /****************************************************************************************/
  2. /* VIEW.CPP */
  3. /* */
  4. /* Author: */
  5. /* Description: */
  6. /* */
  7. /* The contents of this file are subject to the Jet3D Public License */
  8. /* Version 1.02 (the "License"); you may not use this file except in */
  9. /* compliance with the License. You may obtain a copy of the License at */
  10. /* http://www.jet3d.com */
  11. /* */
  12. /* Software distributed under the License is distributed on an "AS IS" */
  13. /* basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See */
  14. /* the License for the specific language governing rights and limitations */
  15. /* under the License. */
  16. /* */
  17. /* The Original Code is Jet3D, released December 12, 1999. */
  18. /* Copyright (C) 1996-1999 Eclipse Entertainment, L.L.C. All Rights Reserved */
  19. /* */
  20. /****************************************************************************************/
  21. /* Open Source Revision -----------------------------------------------------------------
  22. By: Dennis Tierney (DJT) dtierney@oneoverz.com
  23. On: 12/27/99 8:58:41 PM
  24. Comments: 1) Added menu items and handlers for "Clone Selected"
  25. ----------------------------------------------------------------------------------------*/
  26. #include "stdafx.h"
  27. #include "jwe.h"
  28. #include "MainFrm.h"
  29. #include "Ram.h"
  30. #include "Util.h"
  31. #include "View.h"
  32. #include "MemDC.h"
  33. #ifdef _DEBUG
  34. #define new DEBUG_NEW
  35. #undef THIS_FILE
  36. static char THIS_FILE[] = __FILE__;
  37. #endif
  38. #define AUTOSCROLL_MARGIN 4
  39. #define AUTOSCROLL_TIMER 1
  40. #define AUTOSCROLL_PERIOD 100
  41. #define AUTOSCROLL_DISTANCE 8
  42. int CJweView::m_CXDRAG = 2 ;
  43. int CJweView::m_CYDRAG = 2 ;
  44. /////////////////////////////////////////////////////////////////////////////
  45. // CJweView
  46. IMPLEMENT_DYNCREATE(CJweView, CView)
  47. BEGIN_MESSAGE_MAP(CJweView, CView)
  48. //{{AFX_MSG_MAP(CJweView)
  49. ON_WM_ERASEBKGND()
  50. ON_WM_CREATE()
  51. ON_WM_DESTROY()
  52. ON_WM_SIZE()
  53. ON_WM_LBUTTONDOWN()
  54. ON_WM_MOUSEMOVE()
  55. ON_WM_LBUTTONUP()
  56. ON_WM_SETCURSOR()
  57. ON_WM_RBUTTONUP()
  58. ON_WM_MOUSEWHEEL()
  59. ON_COMMAND(IDM_VIEW_ZOOMIN, OnViewZoomin)
  60. ON_UPDATE_COMMAND_UI(IDM_VIEW_ZOOMIN, OnUpdateViewZoomin)
  61. ON_COMMAND(IDM_VIEW_ZOOMOUT, OnViewZoomout)
  62. ON_UPDATE_COMMAND_UI(IDM_VIEW_ZOOMOUT, OnUpdateViewZoomout)
  63. ON_COMMAND(IDM_VIEW_CENTERSELCTION, OnViewCenterselction)
  64. ON_WM_TIMER()
  65. ON_WM_RBUTTONDOWN()
  66. //---------------------------------------------------
  67. // Added DJT
  68. //---------------------------------------------------
  69. ON_COMMAND(ID_EDIT_CLONE, OnEditClone)
  70. ON_UPDATE_COMMAND_UI(ID_EDIT_CLONE, OnUpdateEditClone)
  71. ON_WM_MBUTTONDOWN()
  72. ON_WM_MBUTTONUP()
  73. //---------------------------------------------------
  74. // End DJT
  75. //---------------------------------------------------
  76. //}}AFX_MSG_MAP
  77. // Standard printing commands
  78. //ON_COMMAND(ID_FILE_PRINT, CView::OnFilePrint)
  79. //ON_COMMAND(ID_FILE_PRINT_DIRECT, CView::OnFilePrint)
  80. //ON_COMMAND(ID_FILE_PRINT_PREVIEW, CView::OnFilePrintPreview)
  81. ON_COMMAND_RANGE( IDM_VIEW_TOP, IDM_VIEW_RESERVED4, OnViewType)
  82. ON_UPDATE_COMMAND_UI_RANGE( IDM_VIEW_TOP, IDM_VIEW_RESERVED4, OnUpdateViewType)
  83. END_MESSAGE_MAP()
  84. /////////////////////////////////////////////////////////////////////////////
  85. // CJweView construction/destruction
  86. CJweView::CJweView() : m_nViewType(0), m_pOrtho(NULL), m_bCaptured(false), m_ScrollType(VIEW_SCROLL_NONE),
  87. m_bDragging(false), m_Mode(VIEW_MODE_NONE),
  88. m_bInit(false), m_bPanning(false)
  89. {
  90. m_CXDRAG = ::GetSystemMetrics( SM_CXDRAG ) ;
  91. m_CYDRAG = ::GetSystemMetrics( SM_CYDRAG ) ;
  92. }
  93. CJweView::~CJweView()
  94. {
  95. }
  96. BOOL CJweView::PreCreateWindow(CREATESTRUCT& cs)
  97. {
  98. // TODO: Modify the Window class or styles here by modifying
  99. // the CREATESTRUCT cs
  100. return CView::PreCreateWindow(cs);
  101. }
  102. void CJweView::OnViewType(UINT nID)
  103. {
  104. Ortho_ViewType ovt ;
  105. m_nViewType = nID ; // View Type (Top, Side, Front) also Menu ID
  106. switch( nID )
  107. {
  108. case IDM_VIEW_TOP : ovt = Ortho_ViewTop ; break ;
  109. case IDM_VIEW_FRONT : ovt = Ortho_ViewFront ; break ;
  110. case IDM_VIEW_SIDE: ovt = Ortho_ViewSide ; break ;
  111. default:
  112. ASSERT( 0 ) ;
  113. ovt = Ortho_ViewTop ;
  114. }
  115. Ortho_SetViewType( m_pOrtho, ovt ) ;
  116. Ortho_ResetSettings( m_pOrtho, Ortho_GetWidth( m_pOrtho ), Ortho_GetHeight( m_pOrtho ) ) ;
  117. // Render_ResizeView (VCam, Width, Height);
  118. // Ortho_SetCameraPos( m_pOrtho, &SaveCameraPos);
  119. // Ortho_SetAnglesRPY(VCam, &SaveOrientation);
  120. // Ortho_SetZoom (VCam, ZoomFactor);
  121. }// OnViewType
  122. // Added JH 11.3.2000
  123. Ortho *CJweView::GetOrtho()
  124. { return m_pOrtho;
  125. }
  126. void CJweView::OnUpdateViewType( CCmdUI* pCmdUI )
  127. {
  128. pCmdUI->Enable( TRUE ) ;
  129. pCmdUI->SetCheck( pCmdUI->m_nID == m_nViewType ) ;
  130. }// OnUpdateViewType
  131. /////////////////////////////////////////////////////////////////////////////
  132. // CJweView drawing
  133. void CJweView::OnDraw(CDC* pDC)
  134. {
  135. CRect r ;
  136. CJweDoc* pDoc = GetDocument();
  137. ASSERT_VALID(pDoc);
  138. const jeExtBox * pNewBrushBounds;
  139. CRect totalAreaWnd; // prepare for flicker-free view drawing
  140. GetClientRect(&totalAreaWnd);
  141. // Create a memory bufffer DC and draw to THAT
  142. CMemDC memDC(pDC, totalAreaWnd, totalAreaWnd, &m_ViewBuffer );
  143. if (m_ViewBuffer.IsDirty()) // If it's empty or uninitialized, let's draw to it
  144. {
  145. GetClientRect( &r ) ;
  146. CBrush MyBrush(Settings_GetGridBk());
  147. memDC.GetSafeCDC()->FillRect(&r,&MyBrush);
  148. CBrush SelBrush( RGB(255,0,0) ) ;
  149. if( !pDoc->m_bLoaded )
  150. return;
  151. pDoc->DrawGrid(memDC.GetSafeCDC(), m_pOrtho);
  152. pDoc->DrawConstructorLine( memDC.GetSafeCDC(), m_pOrtho );
  153. pDoc->DrawObjects( memDC.GetSafeCDC(), m_pOrtho );
  154. pDoc->DrawSelected( memDC.GetSafeCDC(), m_pOrtho );
  155. if( m_Mode == VIEW_MODE_ROTATE_HANDLE || m_Mode == VIEW_MODE_ROTATE_SUBSELECTION )
  156. {
  157. DrawRotateBox( memDC.m_hDC );
  158. pDoc->DrawSelectAxis( m_pOrtho, memDC.m_hDC );
  159. }
  160. else
  161. pDoc->DrawSelectBounds( memDC.GetSafeCDC(), m_pOrtho );
  162. pDoc->DrawOrthoName( memDC.GetSafeCDC(), m_pOrtho );
  163. pNewBrushBounds = pDoc->GetNewBrushBounds();
  164. if( jeExtBox_IsValid( pNewBrushBounds ) )
  165. {
  166. Ortho_WorldToViewRect( m_pOrtho, pNewBrushBounds, (Rect*)&r );
  167. memDC.GetSafeCDC()->FrameRect( &r, &SelBrush ) ;
  168. pDoc->PrintRectDimensions (memDC.GetSafeCDC(),m_pOrtho,pNewBrushBounds); // Added JH 3.3.2000
  169. }else
  170. if( m_Mode == VIEW_MODE_SELECT_RECT )
  171. {
  172. r.left = m_ptAnchor.x ;
  173. r.top = m_ptAnchor.y ;
  174. r.right = m_ptLastMouse.x ;
  175. r.bottom = m_ptLastMouse.y ;
  176. r.NormalizeRect() ;
  177. memDC.GetSafeCDC()->FrameRect( &r, &SelBrush ) ;
  178. }
  179. if( this==GetParentFrame()->GetActiveView() )
  180. {
  181. GetClientRect( &r ) ;
  182. CBrush RedBrush( RGB(255,0,0) ) ;
  183. memDC.GetSafeCDC()->FrameRect( &r, &RedBrush );
  184. }
  185. // once all drawing is done,
  186. if (!memDC.CopyToScreen(0))
  187. MessageBeep(0);; // flip the buffer to the screen
  188. }
  189. }// OnDraw
  190. /* ORIG
  191. /////////////////////////////////////////////////////////////////////////////
  192. // CJweView drawing
  193. void CJweView::OnDraw(CDC* pDC)
  194. {
  195. CRect r ;
  196. CJweDoc* pDoc = GetDocument();
  197. ASSERT_VALID(pDoc);
  198. const jeExtBox * pNewBrushBounds;
  199. // Added 28.3.2000 Double Buffering :)
  200. CDC *pdrawDC = CDC::FromHandle(pDC->m_hDC);
  201. CMemDC memDC(pdrawDC);
  202. CDC *pDCNew = &memDC;
  203. GetClientRect( &r ) ;
  204. CBrush MyBrush(Settings_GetGridBk());
  205. memDC->FillRect(&r,&MyBrush);
  206. // EOF JH
  207. CBrush SelBrush( RGB(255,0,0) ) ;
  208. if( !pDoc->m_bLoaded )
  209. return;
  210. pDoc->DrawGrid( pDCNew, m_pOrtho);
  211. pDoc->DrawConstructorLine( pDCNew, m_pOrtho );
  212. pDoc->DrawObjects( pDCNew, m_pOrtho );
  213. pDoc->DrawSelected( pDCNew, m_pOrtho );
  214. if( m_Mode == VIEW_MODE_ROTATE_HANDLE || m_Mode == VIEW_MODE_ROTATE_SUBSELECTION )
  215. {
  216. DrawRotateBox( pDCNew->m_hDC );
  217. pDoc->DrawSelectAxis( m_pOrtho, pDCNew->m_hDC );
  218. }
  219. else
  220. pDoc->DrawSelectBounds( pDCNew, m_pOrtho );
  221. pDoc->DrawOrthoName( pDCNew, m_pOrtho );
  222. pNewBrushBounds = pDoc->GetNewBrushBounds();
  223. if( jeExtBox_IsValid( pNewBrushBounds ) )
  224. {
  225. Ortho_WorldToViewRect( m_pOrtho, pNewBrushBounds, (Rect*)&r );
  226. pDCNew->FrameRect( &r, &SelBrush ) ;
  227. pDoc->PrintRectDimensions (pDCNew,m_pOrtho,pNewBrushBounds); // Added JH 3.3.2000
  228. }else
  229. if( m_Mode == VIEW_MODE_SELECT_RECT )
  230. {
  231. r.left = m_ptAnchor.x ;
  232. r.top = m_ptAnchor.y ;
  233. r.right = m_ptLastMouse.x ;
  234. r.bottom = m_ptLastMouse.y ;
  235. r.NormalizeRect() ;
  236. pDCNew->FrameRect( &r, &SelBrush ) ;
  237. }
  238. if( this==GetParentFrame()->GetActiveView() )
  239. {
  240. GetClientRect( &r ) ;
  241. CBrush RedBrush( RGB(255,0,0) ) ;
  242. pDCNew->FrameRect( &r, &RedBrush );
  243. }
  244. }// OnDraw
  245. */
  246. /////////////////////////////////////////////////////////////////////////////
  247. // CJweView printing
  248. /*
  249. BOOL CJweView::OnPreparePrinting(CPrintInfo* pInfo)
  250. {
  251. // default preparation
  252. return DoPreparePrinting(pInfo);
  253. }
  254. void CJweView::OnBeginPrinting(CDC* pDC, CPrintInfo* pInfo)
  255. {
  256. // TODO: add extra initialization before printing
  257. }
  258. void CJweView::OnEndPrinting(CDC* pDC, CPrintInfo* pInfo)
  259. {
  260. // TODO: add cleanup after printing
  261. }
  262. */
  263. /////////////////////////////////////////////////////////////////////////////
  264. // CJweView diagnostics
  265. #ifdef _DEBUG
  266. void CJweView::AssertValid() const
  267. {
  268. CView::AssertValid();
  269. }
  270. void CJweView::Dump(CDumpContext& dc) const
  271. {
  272. CView::Dump(dc);
  273. }
  274. CJweDoc* CJweView::GetDocument() // non-debug version is inline
  275. {
  276. ASSERT(m_pDocument->IsKindOf(RUNTIME_CLASS(CJweDoc)));
  277. return (CJweDoc*)m_pDocument;
  278. }
  279. #endif //_DEBUG
  280. /////////////////////////////////////////////////////////////////////////////
  281. // CJweView message handlers
  282. BOOL CJweView::OnEraseBkgnd(CDC* pDC)
  283. {
  284. CRect rect ;
  285. GetClientRect( &rect ) ;
  286. pDC->FillSolidRect( &rect, Settings_GetGridBk( ) ) ;
  287. return true ;
  288. }// OnEraseBkgnd
  289. int32 CJweView::GetViewSigniture()
  290. {
  291. switch( Ortho_GetViewType( m_pOrtho ) )
  292. {
  293. case Ortho_ViewFront:
  294. return( 'FRNT' );
  295. case Ortho_ViewSide:
  296. return( 'SIDE' );
  297. case Ortho_ViewTop:
  298. return( 'OTOP' );
  299. default:
  300. ASSERT(0 );
  301. break;
  302. }
  303. return( 0 );
  304. }
  305. void CJweView::OnInitialUpdate()
  306. {
  307. jeVec3d Angles = { 0.0f, 0.0f, 0.0f } ;
  308. jeVec3d CameraPos = { 0.0f, 0.0f, 0.0f } ;
  309. CView::OnInitialUpdate();
  310. // Get saved state information from the DOC
  311. Ortho_SetZoom( m_pOrtho, 1.0f ) ;
  312. Ortho_SetAngles( m_pOrtho, &Angles ) ;
  313. Ortho_SetCameraPos( m_pOrtho, &CameraPos ) ;
  314. m_bInit = true ; // This flag prevents activate view from setting a doc that isn't init'ed
  315. ((CMainFrame*)AfxGetMainWnd())->SetCurrentDocument( GetDocument() ) ;
  316. WndReg_RegisterWindow( GetSafeHwnd(), GetViewSigniture() );
  317. // Update grid status bar (DOC)
  318. }// OnInitialUpdate
  319. int CJweView::OnCreate(LPCREATESTRUCT lpCreateStruct)
  320. {
  321. if (CView::OnCreate(lpCreateStruct) == -1)
  322. return -1;
  323. m_pOrtho = Ortho_Create( ) ;
  324. if( m_pOrtho == NULL )
  325. return -1 ;
  326. // TODO: Add your specialized creation code here
  327. return 0;
  328. }
  329. void CJweView::OnDestroy()
  330. {
  331. CView::OnDestroy();
  332. if( m_pOrtho )
  333. Ortho_Destroy( &m_pOrtho ) ;
  334. }// OnDestroy
  335. void CJweView::OnSize(UINT nType, int cx, int cy)
  336. {
  337. CView::OnSize(nType, cx, cy);
  338. Ortho_ResizeView( m_pOrtho, cx, cy);
  339. Ortho_UpdateWorldBounds( m_pOrtho ) ;
  340. }// OnSize
  341. void CJweView::OnLButtonDown(UINT nFlags, CPoint point)
  342. {
  343. CJweDoc * pDoc = GetDocument() ;
  344. if( m_Mode == VIEW_MODE_DRAG_BRUSH_HEIGHT )
  345. {
  346. ASSERT( pDoc->isPlaceBrushMode() );
  347. ShowCursor(TRUE);
  348. ReleaseCapture();
  349. m_bCaptured = false;
  350. m_bDragging = false;
  351. pDoc->PlaceBrush( JE_FALSE );
  352. m_Mode = VIEW_MODE_NONE;
  353. return;
  354. }
  355. if( pDoc->isPlaceLightMode() )
  356. m_Mode = VIEW_MODE_PLACELIGHT;
  357. else
  358. if( pDoc->isPlaceBrushMode() )
  359. m_Mode = VIEW_MODE_PLACEBRUSH;
  360. SetCapture( ) ;
  361. m_bCaptured = true ;
  362. m_ptAnchor = point ;
  363. m_ptLastMouse = point ;
  364. CView::OnLButtonDown(nFlags, point);
  365. }// OnLButtonDown
  366. int32 CJweView::GetAutoScrollRegion( POINT * ptCursor )
  367. {
  368. CRect rect ;
  369. int32 ScrollType = VIEW_SCROLL_NONE;
  370. if( m_Mode == VIEW_MODE_DRAG_BRUSH_HEIGHT )
  371. return( VIEW_SCROLL_NONE );
  372. GetClientRect( &rect ) ;
  373. if( rect.PtInRect( *ptCursor ) )
  374. return( VIEW_SCROLL_NONE );
  375. if( ptCursor->x < rect.left + AUTOSCROLL_MARGIN )
  376. ScrollType |= VIEW_SCROLL_LEFT;
  377. else
  378. if( ptCursor->x > rect.right - AUTOSCROLL_MARGIN )
  379. ScrollType |= VIEW_SCROLL_RIGHT;
  380. if( ptCursor->y < rect.top + AUTOSCROLL_MARGIN )
  381. ScrollType |= VIEW_SCROLL_UP;
  382. else
  383. if( ptCursor->y > rect.bottom - AUTOSCROLL_MARGIN )
  384. ScrollType |= VIEW_SCROLL_DOWN;
  385. return( ScrollType );
  386. }
  387. void CJweView::SetAutoScroll( int32 ScrollRegion )
  388. {
  389. if( ScrollRegion == VIEW_SCROLL_NONE )
  390. {
  391. m_ScrollType = VIEW_SCROLL_NONE;
  392. KillTimer( AUTOSCROLL_TIMER );
  393. }
  394. else
  395. {
  396. if( m_ScrollType == VIEW_SCROLL_NONE )
  397. {
  398. SetTimer( AUTOSCROLL_TIMER, AUTOSCROLL_PERIOD, NULL );
  399. m_ScrollType = ScrollRegion;
  400. }
  401. }
  402. }
  403. void CJweView::SetUpRotateBox(jeExtBox *pSelBounds)
  404. {
  405. float dx, dy;
  406. jeExtBox_GetTranslation( pSelBounds, &m_Center3d );
  407. Ortho_WorldToView( m_pOrtho, &m_Center3d, (Point*)&m_SelCenter );
  408. dx = (float)(m_ptAnchor.x - m_SelCenter.x);
  409. dy = (float)(m_ptAnchor.y - m_SelCenter.y);
  410. m_RotateRadius = (float)sqrt( double((dx*dx) + (dy*dy)) );
  411. m_RotateBox.left = m_SelCenter.x - (int)m_RotateRadius;
  412. m_RotateBox.right = m_SelCenter.x + (int)m_RotateRadius;
  413. m_RotateBox.top = m_SelCenter.y - (int)m_RotateRadius;
  414. m_RotateBox.bottom = m_SelCenter.y + (int)m_RotateRadius;
  415. }
  416. void CJweView::DrawRotateBox( HDC hDC)
  417. {
  418. HBRUSH hOldBrush ;
  419. COLORREF coBackGround ;
  420. COLORREF coOld ;
  421. Rect Box;
  422. Point CursorHandle;
  423. float dx, dy;
  424. float Dist;
  425. coBackGround = Settings_GetSelectedBk() ;
  426. hOldBrush = SelectBrush( hDC, GetStockObject( NULL_BRUSH ) ) ;
  427. coOld = SetBkColor( hDC, coBackGround ) ;
  428. Ellipse(
  429. hDC,
  430. m_RotateBox.left,
  431. m_RotateBox.top,
  432. m_RotateBox.right,
  433. m_RotateBox.bottom
  434. );
  435. SetBkColor( hDC, coOld ) ;
  436. SelectBrush( hDC, hOldBrush ) ;
  437. Box.Left = m_ptAnchor.x - 4;
  438. Box.Right = m_ptAnchor.x + 4;
  439. Box.Top = m_ptAnchor.y - 4;
  440. Box.Bottom = m_ptAnchor.y + 4;
  441. Ellipse(
  442. hDC,
  443. Box.Left,
  444. Box.Top,
  445. Box.Right,
  446. Box.Bottom
  447. );
  448. dx = (float)(m_ptLastMouse.x - m_SelCenter.x);
  449. dy = (float)(m_ptLastMouse.y - m_SelCenter.y);
  450. Dist = (float)sqrt( double((dx*dx) + (dy*dy)) );
  451. CursorHandle.X = (int)(dx*m_RotateRadius/Dist + m_SelCenter.x);
  452. CursorHandle.Y = (int)(dy*m_RotateRadius/Dist + m_SelCenter.y);
  453. Box.Left = CursorHandle.X - 4;
  454. Box.Right = CursorHandle.X + 4;
  455. Box.Top = CursorHandle.Y - 4;
  456. Box.Bottom = CursorHandle.Y + 4;
  457. Ellipse(
  458. hDC,
  459. Box.Left,
  460. Box.Top,
  461. Box.Right,
  462. Box.Bottom
  463. );
  464. }
  465. void CJweView::SetBeginDragViewMode(POINT ptCursor)
  466. {
  467. jeBoolean bHasSelection;
  468. jeBoolean bHasSubSelection;
  469. jeBoolean bShiftHeld ;
  470. jeBoolean bControlHeld ;
  471. jeExtBox WorldBox ;
  472. jeExtBox SubSelBox ;
  473. SELECT_HANDLE Handle ;
  474. SELECT_HANDLE SubHandle ;
  475. DOC_HANDLE_MODE HandleMode;
  476. int32 SubModFlags = 0;
  477. CJweDoc * pDoc = GetDocument() ;
  478. DOC_CONSTRUCTORS Constructor;
  479. bShiftHeld = Util_IsKeyDown( VK_SHIFT ) ;
  480. bControlHeld = Util_IsKeyDown( VK_CONTROL ) ;
  481. bHasSelection = pDoc->HasSelections( &WorldBox );
  482. if( bHasSelection )
  483. Handle = pDoc->ViewPointHandle( m_pOrtho, (Point*)&m_ptAnchor, &WorldBox ) ;
  484. else
  485. Handle = Select_None;
  486. bHasSubSelection = pDoc->HasSubSelections( &SubSelBox );
  487. if( bHasSubSelection )
  488. SubModFlags = pDoc->SubSelXFormModFlags();
  489. SubHandle = pDoc->SubViewPointHandle( m_pOrtho, (Point*)&m_ptAnchor, &SubSelBox ) ;
  490. Constructor = pDoc->ViewPointConstructor( m_pOrtho, (Point*)&m_ptAnchor );
  491. ASSERT( m_Mode == VIEW_MODE_NONE || m_Mode == VIEW_MODE_PLACEBRUSH);
  492. if( pDoc->isPlaceBrushMode() ) //Are we in Drag New Brush Rect Mode
  493. m_Mode = VIEW_MODE_DRAG_BRUSH_RECT;
  494. else
  495. if( bHasSubSelection && (SubModFlags & SubSelect_Rotate )&& SubHandle != Select_None )
  496. {
  497. jeExtBox SelBounds;
  498. pDoc->BeginRotateSub( ) ;
  499. if( pDoc->HasSubSelections( &SelBounds ) )
  500. SetUpRotateBox(&SelBounds);
  501. m_Mode = VIEW_MODE_ROTATE_SUBSELECTION;
  502. }
  503. else
  504. if( bHasSubSelection && (SubModFlags & SubSelect_Move )&& Ortho_IsViewPointInWorldBox( m_pOrtho, m_ptAnchor.x, m_ptAnchor.y, &SubSelBox ))
  505. {
  506. pDoc->BeginMoveSub( ) ;
  507. m_Mode = VIEW_MODE_MOVE_SUBSELECTION;
  508. }
  509. else
  510. if( pDoc->IsVertexManipulationMode() && bShiftHeld ) //Are we Dragging a Vertext
  511. {
  512. m_Mode = VIEW_MODE_DRAG_VERTEX;
  513. pDoc->BeginMoveVerts( m_pOrtho ) ;
  514. }
  515. else
  516. if( bHasSelection && Handle != Select_None ) //Are we Dragging a handle
  517. {
  518. if( pDoc->BeginMoveHandle( m_pOrtho, Handle, &HandleMode ) )
  519. {
  520. switch( HandleMode )
  521. {
  522. case DOC_HANDLE_SIZE:
  523. m_Mode = VIEW_MODE_SIZE_HANDLE;
  524. break;
  525. case DOC_HANDLE_ROTATE:
  526. jeExtBox SelBounds;
  527. m_Mode = VIEW_MODE_ROTATE_HANDLE;
  528. if( pDoc->HasSelections( &SelBounds ) )
  529. SetUpRotateBox(&SelBounds);
  530. break;
  531. case DOC_HANDLE_SHEAR:
  532. m_Mode = VIEW_MODE_SHEAR_HANDLE;
  533. break;
  534. }
  535. m_SizeType = Handle ;
  536. }
  537. }
  538. else //Are we Dragging a selction
  539. if( bHasSelection && Ortho_IsViewPointInWorldBox( m_pOrtho, m_ptAnchor.x, m_ptAnchor.y, &WorldBox ) )
  540. {
  541. m_Mode = VIEW_MODE_MOVE_SELECTION;
  542. m_SizeType = Select_NearestCornerHandle( m_pOrtho, (Point*)&ptCursor, &WorldBox ) ;
  543. pDoc->BeginMove( m_pOrtho, m_SizeType, bShiftHeld ) ;
  544. }
  545. else
  546. if( Constructor != DOC_NO_CONSTRUCTOR )
  547. {
  548. switch( Constructor )
  549. {
  550. case DOC_VERTICAL_CONSTRUCTOR:
  551. m_Mode = VIEW_DRAG_VCONSTRUCTOR;
  552. break;
  553. case DOC_HORIZONTAL_CONSTRUCTOR:
  554. m_Mode = VIEW_DRAG_HCONSTRUCTOR;
  555. break;
  556. case DOC_BOTH_CONSTRUCTOR:
  557. m_Mode = VIEW_DRAG_BCONSTRUCTOR;
  558. break;
  559. default:
  560. ASSERT(0);
  561. break;
  562. }
  563. }
  564. else
  565. m_Mode = VIEW_MODE_SELECT_RECT;
  566. }
  567. void CJweView::Pan( jeVec3d *pWorldDistance )
  568. {
  569. m_bPanning = true;
  570. jeVec3d_Scale( pWorldDistance, -1.0f, pWorldDistance ) ;
  571. Ortho_MoveCamera( m_pOrtho, pWorldDistance ) ;
  572. Invalidate(false); //TRUE
  573. }
  574. jeBoolean CJweView::IsBeginDrag( POINT ptCursor )
  575. {
  576. return( m_Mode != VIEW_MODE_PLACELIGHT && //We are not placing a light
  577. false == m_bDragging && //We are not already draging
  578. ( abs( ptCursor.x - m_ptAnchor.x) > m_CXDRAG || //Either we have moved enough in the X
  579. abs( ptCursor.y - m_ptAnchor.y) > m_CYDRAG )); // Or moved enough in the Y
  580. }
  581. void CJweView::Drag( POINT ptCursor, jeVec3d *pWorldDistance )
  582. {
  583. CJweDoc * pDoc = GetDocument() ;
  584. switch( m_Mode )
  585. {
  586. case VIEW_MODE_MOVE_SELECTION:
  587. pDoc->MoveSelected( m_SizeType, pWorldDistance ) ;
  588. break;
  589. case VIEW_MODE_MOVE_SUBSELECTION:
  590. pDoc->MoveSelectedSub( m_SizeType, pWorldDistance ) ;
  591. break;
  592. case VIEW_MODE_ROTATE_SUBSELECTION:
  593. pDoc->RotateSelectedSub( m_pOrtho, (Point*)&ptCursor, (Point*)&m_ptAnchor ) ;
  594. break;
  595. case VIEW_MODE_ROTATE_HANDLE:
  596. {
  597. pDoc->MoveHandle( m_pOrtho, pWorldDistance, m_SizeType, (Point*)&ptCursor, (Point*)&m_ptAnchor, &m_Center3d ) ;
  598. {
  599. RECT dirtyRect = m_RotateBox;
  600. Rect_Inflate( (Rect*)&dirtyRect, 4, 4 );
  601. InvalidateRect( &dirtyRect, false ); // TRUE
  602. }
  603. }
  604. break;
  605. case VIEW_MODE_SIZE_HANDLE:
  606. case VIEW_MODE_SHEAR_HANDLE:
  607. pDoc->MoveHandle( m_pOrtho, pWorldDistance, m_SizeType, (Point*)&ptCursor, (Point*)&m_ptAnchor, &m_Center3d ) ;
  608. break;
  609. case VIEW_MODE_DRAG_VERTEX:
  610. pDoc->MoveVerts( m_pOrtho, pWorldDistance ) ;
  611. break;
  612. case VIEW_MODE_DRAG_BRUSH_HEIGHT:
  613. {
  614. CPoint ScreenPt;
  615. m_ptVertualMouse.x += ptCursor.x - m_ptAnchor.x;
  616. m_ptVertualMouse.y += ptCursor.y - m_ptAnchor.y;
  617. pDoc->SetNewBrushHeight( m_pOrtho, (Point*)&m_ptVertualMouse, (Point*)&m_ptAnchor);
  618. ScreenPt = m_ptAnchor;
  619. ClientToScreen( &ScreenPt ) ;
  620. SetCursorPos( ScreenPt.x, ScreenPt.y );
  621. }
  622. break;
  623. case VIEW_MODE_DRAG_BRUSH_RECT:
  624. {
  625. pDoc->SetNewBrushBound( m_pOrtho, (Point*)&ptCursor, (Point*)&m_ptAnchor );
  626. }
  627. break;
  628. case VIEW_DRAG_HCONSTRUCTOR:
  629. pDoc->MoveConstructor( m_pOrtho, DOC_HORIZONTAL_CONSTRUCTOR, (Point*)&ptCursor, (Point*)&m_ptAnchor );
  630. break;
  631. case VIEW_DRAG_VCONSTRUCTOR:
  632. pDoc->MoveConstructor( m_pOrtho, DOC_VERTICAL_CONSTRUCTOR, (Point*)&ptCursor, (Point*)&m_ptAnchor );
  633. break;
  634. case VIEW_DRAG_BCONSTRUCTOR:
  635. pDoc->MoveConstructor( m_pOrtho, DOC_BOTH_CONSTRUCTOR, (Point*)&ptCursor, (Point*)&m_ptAnchor );
  636. break;
  637. case VIEW_MODE_SELECT_RECT:
  638. Invalidate(false); //TRUE
  639. break;
  640. }
  641. }
  642. void CJweView::OnMouseMove(UINT nFlags, CPoint point)
  643. {
  644. jeVec3d WorldDistance ;
  645. POINT ptCursor ;
  646. int dx, dy ;
  647. if( m_bCaptured )
  648. {
  649. ::GetCursorPos( &ptCursor ) ;
  650. ScreenToClient( &ptCursor ) ;
  651. OnSetCursor( this, HTCLIENT, 0 ) ;
  652. dx = ptCursor.x - m_ptLastMouse.x ;
  653. dy = ptCursor.y - m_ptLastMouse.y ;
  654. if( dx==0 && dy == 0 )
  655. return;
  656. Ortho_ViewToWorldDistance( m_pOrtho, dx, dy, &WorldDistance ) ;
  657. if( Util_IsKeyDown( VK_SPACE ) )
  658. {
  659. if( m_bZooming )
  660. {
  661. DoZoom (-dy * 0.01f) ;
  662. m_ptLastMouse = ptCursor ;
  663. return;
  664. }
  665. Pan( &WorldDistance );
  666. m_ptLastMouse = ptCursor ;
  667. return;
  668. }
  669. // Added JH
  670. if (m_bPanning && (eMouseRightButton)Settings_GetMouse_RightBut()==mbrPaning)
  671. {
  672. Pan( &WorldDistance );
  673. m_ptLastMouse = ptCursor ;
  674. return;
  675. }
  676. // EOF JH
  677. m_bPanning = false;
  678. if( m_bZooming )
  679. {
  680. m_bZooming = false;
  681. m_bCaptured = false;
  682. ReleaseCapture();
  683. return;
  684. }
  685. if( IsBeginDrag( ptCursor ) )
  686. {
  687. SetBeginDragViewMode( ptCursor );
  688. m_bDragging = true ;
  689. }
  690. if( m_bDragging )
  691. {
  692. int32 ScrollRegion;
  693. ScrollRegion = GetAutoScrollRegion( &ptCursor );
  694. if( ScrollRegion != m_ScrollType )
  695. {
  696. SetAutoScroll( ScrollRegion );
  697. }
  698. Drag(ptCursor, &WorldDistance);
  699. }
  700. m_ptLastMouse = ptCursor ;
  701. }// Mouse Move Captured
  702. #define WITH_DJT_HOTSELECT
  703. #ifdef WITH_DJT_HOTSELECT
  704. else if (MouseSettings_GetHotSelect())
  705. {
  706. CView * pActiveView = GetParentFrame()->GetActiveView();
  707. // Mouse not captured,
  708. // if this view is not active, then activate it
  709. if (this != pActiveView)
  710. {
  711. GetParentFrame()->SetActiveView(this, TRUE);
  712. }
  713. }
  714. #endif
  715. CView::OnMouseMove(nFlags, point);
  716. }// OnMouseMove
  717. void CJweView::DragEnd(CPoint point)
  718. {
  719. CJweDoc* pDoc = GetDocument() ;
  720. jeExtBox WorldBounds ;
  721. jeBoolean bControlHeld ;
  722. bControlHeld = Util_IsKeyDown( VK_CONTROL ) ;
  723. switch( m_Mode )
  724. {
  725. case VIEW_MODE_DRAG_VERTEX:
  726. pDoc->EndMoveVerts() ;
  727. m_Mode = VIEW_MODE_NONE;
  728. break;
  729. case VIEW_MODE_MOVE_SELECTION:
  730. pDoc->EndMove( ) ;
  731. m_Mode = VIEW_MODE_NONE;
  732. break;
  733. case VIEW_MODE_MOVE_SUBSELECTION:
  734. pDoc->EndMoveSub( ) ;
  735. m_Mode = VIEW_MODE_NONE;
  736. break;
  737. case VIEW_MODE_ROTATE_SUBSELECTION:
  738. pDoc->EndRotateSub( ) ;
  739. m_Mode = VIEW_MODE_NONE;
  740. {
  741. RECT dirtyRect = m_RotateBox;
  742. Rect_Inflate( (Rect*)&dirtyRect, 4, 4 );
  743. InvalidateRect( &dirtyRect, false ); // TRUE
  744. }
  745. break;
  746. case VIEW_MODE_ROTATE_HANDLE:
  747. {
  748. RECT dirtyRect = m_RotateBox;
  749. Rect_Inflate( (Rect*)&dirtyRect, 4, 4 );
  750. InvalidateRect( &dirtyRect, false ); //TRUE
  751. }
  752. case VIEW_MODE_SIZE_HANDLE:
  753. case VIEW_MODE_SHEAR_HANDLE:
  754. pDoc->EndMoveHandle( ) ;
  755. m_Mode = VIEW_MODE_NONE;
  756. break;
  757. case VIEW_MODE_DRAG_BRUSH_RECT:
  758. SetCapture( ) ;
  759. m_bCaptured = true ;
  760. m_ptAnchor = point ;
  761. m_ptVertualMouse = point;
  762. m_ptLastMouse = point ;
  763. m_bDragging = true ;
  764. m_Mode = VIEW_MODE_DRAG_BRUSH_HEIGHT;
  765. ShowCursor(FALSE);
  766. break;
  767. case VIEW_DRAG_HCONSTRUCTOR:
  768. case VIEW_DRAG_VCONSTRUCTOR:
  769. case VIEW_DRAG_BCONSTRUCTOR:
  770. m_Mode = VIEW_MODE_NONE;
  771. break;
  772. case VIEW_MODE_SELECT_RECT:
  773. Invalidate(false) ; //TRUE // Get rid of rectangle -- might sel nothing
  774. Ortho_ViewToWorldRect( m_pOrtho, (Point*)&m_ptAnchor, (Point*)&m_ptLastMouse, &WorldBounds ) ;
  775. pDoc->RectangleSelect( &WorldBounds, bControlHeld ) ;
  776. m_Mode = VIEW_MODE_NONE;
  777. break;
  778. }
  779. }
  780. void CJweView::OnLButtonUp(UINT nFlags, CPoint point)
  781. {
  782. jeBoolean bControlHeld ;
  783. jeVec3d World ;
  784. if( m_bCaptured )
  785. {
  786. CJweDoc* pDoc = GetDocument() ;
  787. bControlHeld = Util_IsKeyDown( VK_CONTROL ) ;
  788. ReleaseCapture() ;
  789. m_bCaptured = false ;
  790. if( m_ScrollType != VIEW_SCROLL_NONE )
  791. KillTimer(AUTOSCROLL_TIMER );
  792. m_ScrollType = VIEW_SCROLL_NONE;
  793. if( m_bDragging )
  794. {
  795. m_bDragging = false ;
  796. DragEnd(point);
  797. pDoc->UpdateStats();
  798. }
  799. else
  800. {
  801. Ortho_ViewToWorld( m_pOrtho, point.x, point.y, &World ) ;
  802. if( m_Mode == VIEW_MODE_NONE )
  803. {
  804. if( !m_bPanning )
  805. pDoc->Select( m_pOrtho, (Point*)&point, LEVEL_TOGGLE, bControlHeld ) ;
  806. }
  807. else
  808. {
  809. pDoc->PlaceAtPoint( m_pOrtho, (Point*)&point, JE_FALSE );
  810. m_Mode = VIEW_MODE_NONE;
  811. }
  812. }
  813. if( m_bPanning )
  814. {
  815. m_bPanning = false;
  816. }
  817. }
  818. CView::OnLButtonUp(nFlags, point);
  819. }// OnLButtonUp
  820. BOOL CJweView::OnSetCursor(CWnd* pWnd, UINT nHitTest, UINT message)
  821. {
  822. POINT ptCursor ;
  823. CJweDoc* pDoc = GetDocument() ;
  824. if( HTCLIENT == nHitTest )
  825. {
  826. if(
  827. ( m_bCaptured && Util_IsKeyDown( VK_SPACE ) ) ||// Panning?
  828. // Added JH
  829. (m_bPanning && (eMouseRightButton)Settings_GetMouse_RightBut()==mbrPaning ) // Panning?
  830. // EOF JH
  831. )
  832. {
  833. ::SetCursor( ::LoadCursor( 0, IDC_SIZEALL ) ) ;
  834. }
  835. else
  836. {
  837. {
  838. ::GetCursorPos( &ptCursor ) ;
  839. ScreenToClient( &ptCursor ) ;
  840. pDoc->SetCursor( m_pOrtho, &ptCursor ) ;
  841. }
  842. }
  843. return true ;
  844. }
  845. return CView::OnSetCursor(pWnd, nHitTest, message);
  846. }// OnSetCursor
  847. // TEST CODE
  848. void CJweView::OnRButtonUp(UINT nFlags, CPoint point)
  849. {
  850. CJweDoc* pDoc = GetDocument() ;
  851. if( m_Mode == VIEW_MODE_PLACELIGHT || m_Mode == VIEW_MODE_PLACEBRUSH )
  852. {
  853. pDoc->PlaceAtPoint( m_pOrtho,(Point *)&point, JE_TRUE );
  854. m_Mode = VIEW_MODE_NONE;
  855. }
  856. if( m_bZooming )
  857. {
  858. ReleaseCapture( ) ;
  859. m_bCaptured = false ;
  860. m_bZooming = false;
  861. }
  862. // Added JH
  863. if( m_bPanning )
  864. {
  865. ReleaseCapture( ) ;
  866. m_bCaptured = false ;
  867. m_bPanning = false;
  868. }
  869. // EOF JH
  870. CView::OnRButtonUp(nFlags, point);
  871. }
  872. // END TEST CODE
  873. //---------------------------------------------------
  874. // Edited DJT
  875. //
  876. // Mouse wheel's action contingent upon
  877. // MouseSettings_GetWheelState()
  878. //---------------------------------------------------
  879. BOOL CJweView::OnMouseWheel(UINT nFlags, short zDelta, CPoint pt)
  880. {
  881. eMouseWheel eState = MouseSettings_GetWheelState();
  882. switch (eState)
  883. {
  884. case mwZoom:
  885. if( zDelta > 0 )
  886. DoZoom (0.1f) ;
  887. else
  888. DoZoom (-0.1f) ;
  889. break;
  890. case mwDisabled:
  891. default:
  892. break;
  893. }
  894. return CView::OnMouseWheel(nFlags, zDelta, pt);
  895. }// OnMouseWheel
  896. //---------------------------------------------------
  897. // End DJT
  898. //---------------------------------------------------
  899. void CJweView::DoZoom( jeFloat fZoomInc )
  900. {
  901. Ortho_ZoomChange( m_pOrtho, fZoomInc ) ;
  902. InvalidateRect( NULL, false ) ; //TRUE
  903. }// DoZoom
  904. void CJweView::OnUpdate(CView* pSender, LPARAM lHint, CObject* pHint)
  905. {
  906. jeExtBox * pWorldBounds ;
  907. Rect ViewRect ;
  908. if( pHint == NULL )
  909. {
  910. Invalidate(false) ; // EMPTY
  911. return ;
  912. }
  913. pWorldBounds = (jeExtBox*)pHint ;
  914. if( Ortho_TestWorldToViewRect( m_pOrtho, pWorldBounds, &ViewRect ) )
  915. {
  916. // Adjust for handles
  917. InflateRect( (LPRECT)&ViewRect, HALFHANDLESIZE, HALFHANDLESIZE ) ;
  918. InvalidateRect( (LPCRECT)&ViewRect, false ) ; //TRUE
  919. }
  920. lHint;
  921. pSender;
  922. }// OnUpdate
  923. void CJweView::OnActivateView(BOOL bActivate, CView* pActivateView, CView* pDeactiveView)
  924. {
  925. Invalidate( false ) ; //TRUE // Force our red-frame on active to draw
  926. CView::OnActivateView(bActivate, pActivateView, pDeactiveView);
  927. if( m_bInit && this == pActivateView )
  928. {
  929. ((CMainFrame*)AfxGetMainWnd())->SetCurrentDocument( GetDocument() ) ;
  930. }
  931. }// OnActivateView
  932. void CJweView::OnViewZoomin()
  933. {
  934. DoZoom( 0.1f ) ;
  935. }// OnViewZoomin
  936. void CJweView::OnUpdateViewZoomin(CCmdUI* pCmdUI)
  937. {
  938. pCmdUI->Enable( true ) ;
  939. }//OnUpdateViewZoomin
  940. void CJweView::OnViewZoomout()
  941. {
  942. DoZoom( -0.1f ) ;
  943. }// OnViewZoomout
  944. void CJweView::OnUpdateViewZoomout(CCmdUI* pCmdUI)
  945. {
  946. pCmdUI->Enable( true ) ;
  947. }// OnUpdateViewZoomout
  948. void CJweView::SetCameraPos( jeVec3d * Pos )
  949. {
  950. Ortho_SetCameraPos( m_pOrtho, Pos );
  951. Invalidate(false); // TRUE
  952. }
  953. void CJweView::AbortMode()
  954. {
  955. if( m_bCaptured )
  956. {
  957. ReleaseCapture() ;
  958. m_bCaptured = false ;
  959. ShowCursor( TRUE );
  960. if( m_ScrollType != VIEW_SCROLL_NONE )
  961. KillTimer(AUTOSCROLL_TIMER );
  962. m_ScrollType = VIEW_SCROLL_NONE;
  963. m_Mode = VIEW_MODE_NONE;
  964. if( m_bDragging )
  965. {
  966. m_bDragging = false ;
  967. }
  968. }
  969. Invalidate(false); //TRUE
  970. }
  971. void CJweView::OnViewCenterselction()
  972. {
  973. CJweDoc * pDoc;
  974. pDoc = GetDocument();
  975. ASSERT( pDoc != NULL );
  976. pDoc->CenterViewsOnSelection( );
  977. }
  978. void CJweView::OnTimer(UINT nIDEvent)
  979. {
  980. if( nIDEvent == AUTOSCROLL_TIMER )
  981. {
  982. int x = 0;
  983. int y = 0;
  984. jeVec3d WorldDistance;
  985. CPoint point;
  986. point = m_ptLastMouse;
  987. if( m_ScrollType & VIEW_SCROLL_UP )
  988. y = -AUTOSCROLL_DISTANCE;
  989. else
  990. if( m_ScrollType & VIEW_SCROLL_DOWN )
  991. y = AUTOSCROLL_DISTANCE;
  992. if( m_ScrollType & VIEW_SCROLL_LEFT )
  993. x = -AUTOSCROLL_DISTANCE;
  994. else
  995. if( m_ScrollType & VIEW_SCROLL_RIGHT )
  996. x = AUTOSCROLL_DISTANCE;
  997. m_ptLastMouse.x -= x;
  998. m_ptLastMouse.y -= y;
  999. m_ptAnchor.x -= x;
  1000. m_ptAnchor.y -= y;
  1001. m_SelCenter.x -= x;
  1002. m_SelCenter.y -= y;
  1003. m_RotateBox.left -= x;
  1004. m_RotateBox.right -= x;
  1005. m_RotateBox.top -= y;
  1006. m_RotateBox.bottom -= y;
  1007. Ortho_ViewToWorldDistance( m_pOrtho, x, y, &WorldDistance ) ;
  1008. Ortho_MoveCamera( m_pOrtho, &WorldDistance ) ;
  1009. OnMouseMove(0, point);
  1010. Invalidate(false); //FALSE
  1011. }
  1012. CView::OnTimer(nIDEvent);
  1013. }
  1014. void CJweView::OnRButtonDown(UINT nFlags, CPoint point)
  1015. {
  1016. CJweDoc* pDoc = GetDocument() ;
  1017. Rect MenuRect = { 4, 4, 128, 20 }; // Need to figure out true text box
  1018. // Added JH
  1019. if ((eMouseRightButton)Settings_GetMouse_RightBut()==mbrPaning)
  1020. {
  1021. SetCapture( ) ;
  1022. m_bCaptured = true ;
  1023. // m_bZooming = true;
  1024. m_bPanning = true;
  1025. m_ptLastMouse = point ;
  1026. }
  1027. // EOF JH
  1028. if( Rect_IsPointIn( &MenuRect, (Point *) &point ) )
  1029. {
  1030. SetFocus();
  1031. ShowMenu(point);
  1032. Invalidate(false); //TRUE
  1033. return;
  1034. }
  1035. if( Util_IsKeyDown( VK_SPACE ) )
  1036. {
  1037. SetCapture( ) ;
  1038. m_bCaptured = true ;
  1039. m_bZooming = true;
  1040. m_ptLastMouse = point ;
  1041. }
  1042. else
  1043. if( m_Mode == VIEW_MODE_DRAG_BRUSH_HEIGHT )
  1044. {
  1045. ASSERT( pDoc->isPlaceBrushMode() );
  1046. ShowCursor(TRUE);
  1047. ReleaseCapture();
  1048. m_bCaptured = false;
  1049. m_bDragging = false;
  1050. pDoc->PlaceBrush( JE_TRUE );
  1051. m_Mode = VIEW_MODE_NONE;
  1052. return;
  1053. }
  1054. if( pDoc->isPlaceBrushMode() )
  1055. m_Mode = VIEW_MODE_PLACEBRUSH;
  1056. CView::OnRButtonDown(nFlags, point);
  1057. }
  1058. void CJweView::ShowMenu( CPoint point)
  1059. {
  1060. CMenu ContextMenu;
  1061. CMenu *SubMenu;
  1062. ClientToScreen( &point );
  1063. ContextMenu.LoadMenu( IDR_VIEW );
  1064. SubMenu = ContextMenu.GetSubMenu( 0 );
  1065. SubMenu->TrackPopupMenu( TPM_LEFTALIGN, point.x, point.y, this, NULL );
  1066. }
  1067. //---------------------------------------------------
  1068. // Added DJT
  1069. //---------------------------------------------------
  1070. void CJweView::OnUpdateEditClone(CCmdUI* pCmdUI)
  1071. {
  1072. pCmdUI->Enable(Level_HasSelections(GetDocument()->GetLevel())) ;
  1073. }
  1074. void CJweView::OnEditClone()
  1075. {
  1076. jeProperty_List *pArray;
  1077. CMainFrame * pMainFrm;
  1078. CJweDoc * pDoc = GetDocument();
  1079. Level * pLevel = pDoc->GetLevel();
  1080. if( JE_FALSE == Select_DupAndDeselectSelections(pLevel))
  1081. return ;
  1082. pMainFrm = (CMainFrame*)AfxGetMainWnd();
  1083. pMainFrm->AddSelection(pDoc);
  1084. // Nudge the new cloned selection
  1085. jeVec3d WorldDistance;
  1086. Ortho_ViewToWorldDistance(m_pOrtho, 16, 16, &WorldDistance);
  1087. pDoc->MoveSelected((SELECT_HANDLE)0, &WorldDistance);
  1088. pArray = Select_BuildDescriptor(pLevel);
  1089. pMainFrm->SetProperties(pArray);
  1090. pMainFrm->UpdatePanel( MAINFRM_PANEL_LISTS ) ;
  1091. }
  1092. void CJweView::OnMButtonUp(UINT nFlags, CPoint point)
  1093. {
  1094. CView::OnMButtonUp(nFlags, point);
  1095. }
  1096. void CJweView::OnMButtonDown(UINT nFlags, CPoint point)
  1097. {
  1098. CJweDoc* pDoc = GetDocument() ;
  1099. eMouseMiddleButton eState = MouseSettings_GetMiddleButtonState();
  1100. switch (eState)
  1101. {
  1102. case mbSelectAll:
  1103. pDoc->SelectAll(JE_TRUE);
  1104. break;
  1105. case mbSelectNone:
  1106. pDoc->DeselectAll(JE_TRUE);
  1107. break;
  1108. case mbDisabled:
  1109. default:
  1110. break;
  1111. }
  1112. CView::OnRButtonDown(nFlags, point);
  1113. }
  1114. //---------------------------------------------------
  1115. // End DJT
  1116. //---------------------------------------------------