Counter Strike : Global Offensive Source Code
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

1931 lines
55 KiB

  1. //========= Copyright � 1996-2005, Valve Corporation, All rights reserved. ============//
  2. //
  3. // Purpose:
  4. //
  5. // $NoKeywords: $
  6. //=============================================================================//
  7. #include <stdafx.h>
  8. #include "hammer.h"
  9. #include "MainFrm.h"
  10. #include "FaceEditSheet.h"
  11. #include "GlobalFunctions.h"
  12. #include "DispDlg.h"
  13. #include "MapFace.h"
  14. #include "MapDisp.h"
  15. #include "ToolDisplace.h"
  16. #include "ToolManager.h"
  17. #include "SculptOptions.h"
  18. // memdbgon must be the last include file in a .cpp file!!!
  19. #include <tier0/memdbgon.h>
  20. #define DISPPAINT_DISTANCE_MIN 0
  21. #define DISPPAINT_DISTANCE_MAX 60
  22. #define DISPPAINT_SPATIALRADIUS_MIN 1
  23. #define DISPPAINT_SPATIALRADIUS_MAX 1024
  24. #define DISPPAINT_SPATIALRADIUS_STEP 16
  25. //=============================================================================
  26. //
  27. // Displacement Create Dialog Functions
  28. //
  29. BEGIN_MESSAGE_MAP(CDispCreateDlg, CDialog)
  30. //{{AFX_MSG_MAP(CDispCreateDlg)
  31. ON_WM_VSCROLL()
  32. //}}AFX_MSG_MAP
  33. END_MESSAGE_MAP()
  34. extern CToolDisplace* GetDisplacementTool();
  35. //-----------------------------------------------------------------------------
  36. // Purpose: constructor
  37. //-----------------------------------------------------------------------------
  38. CDispCreateDlg::CDispCreateDlg( CWnd *pParent ) :
  39. CDialog( CDispCreateDlg::IDD, pParent )
  40. {
  41. m_Power = 0;
  42. }
  43. //-----------------------------------------------------------------------------
  44. // Purpose:
  45. //-----------------------------------------------------------------------------
  46. BOOL CDispCreateDlg::OnInitDialog(void)
  47. {
  48. CDialog::OnInitDialog();
  49. // set the initial power "3"
  50. SetDlgItemInt( ID_DISP_CREATE_POWER, 3 );
  51. // setup the spinner - set range (range [2..4])
  52. m_spinPower.SetBuddy( &m_editPower );
  53. m_spinPower.SetRange( 2, 4 );
  54. m_spinPower.SetPos( 3 );
  55. return TRUE;
  56. }
  57. //-----------------------------------------------------------------------------
  58. // Purpose:
  59. //-----------------------------------------------------------------------------
  60. void CDispCreateDlg::DoDataExchange( CDataExchange *pDX )
  61. {
  62. CDialog::DoDataExchange( pDX );
  63. //{{AFX_DATA_MAP(CDispCreateDlg)
  64. DDX_Control( pDX, ID_DISP_CREATE_POWER_SPIN, m_spinPower );
  65. DDX_Control( pDX, ID_DISP_CREATE_POWER, m_editPower );
  66. DDX_Text( pDX, ID_DISP_CREATE_POWER, m_Power );
  67. //}}AFX_DATA_MAP
  68. // clamp the power
  69. if( m_Power < 2 ) { m_Power = 2; }
  70. if( m_Power > 4 ) { m_Power = 4; }
  71. }
  72. //-----------------------------------------------------------------------------
  73. //-----------------------------------------------------------------------------
  74. void CDispCreateDlg::OnVScroll( UINT nSBCode, UINT nPos, CScrollBar *pScrollBar )
  75. {
  76. m_spinPower.SetPos( nPos );
  77. SetDlgItemInt( ID_DISP_CREATE_POWER, nPos );
  78. }
  79. //=============================================================================
  80. //
  81. // Displacement Noise Dialog Functions
  82. //
  83. BEGIN_MESSAGE_MAP(CDispNoiseDlg, CDialog)
  84. //{{AFX_MSG_MAP(CDispNoiseDlg)
  85. ON_NOTIFY( UDN_DELTAPOS, ID_DISP_NOISE_MIN_SPIN, OnSpinUpDown )
  86. ON_NOTIFY( UDN_DELTAPOS, ID_DISP_NOISE_MAX_SPIN, OnSpinUpDown )
  87. //}}AFX_MSG_MAP
  88. END_MESSAGE_MAP()
  89. //-----------------------------------------------------------------------------
  90. // Purpose: constructor
  91. //-----------------------------------------------------------------------------
  92. CDispNoiseDlg::CDispNoiseDlg( CWnd *pParent ) :
  93. CDialog( CDispNoiseDlg::IDD, pParent )
  94. {
  95. m_Min = m_Max = 0.0f;
  96. }
  97. //-----------------------------------------------------------------------------
  98. // Purpose:
  99. //-----------------------------------------------------------------------------
  100. BOOL CDispNoiseDlg::OnInitDialog(void)
  101. {
  102. CDialog::OnInitDialog();
  103. //
  104. // set min, max initially to zero!!
  105. //
  106. CString strZero = "0.0";
  107. SetDlgItemText( ID_DISP_NOISE_MIN, strZero );
  108. SetDlgItemText( ID_DISP_NOISE_MAX, strZero );
  109. //
  110. // setup spinners
  111. //
  112. m_spinMin.SetBuddy( &m_editMin );
  113. m_spinMax.SetBuddy( &m_editMax );
  114. return TRUE;
  115. }
  116. //-----------------------------------------------------------------------------
  117. // Purpose:
  118. //-----------------------------------------------------------------------------
  119. void CDispNoiseDlg::DoDataExchange( CDataExchange *pDX )
  120. {
  121. CDialog::DoDataExchange( pDX );
  122. //{{AFX_DATA_MAP(CDispNoiseDlg)
  123. DDX_Control( pDX, ID_DISP_NOISE_MIN_SPIN, m_spinMin );
  124. DDX_Control( pDX, ID_DISP_NOISE_MAX_SPIN, m_spinMax );
  125. DDX_Control( pDX, ID_DISP_NOISE_MIN, m_editMin );
  126. DDX_Control( pDX, ID_DISP_NOISE_MAX, m_editMax );
  127. DDX_Text( pDX, ID_DISP_NOISE_MIN, m_Min );
  128. DDX_Text( pDX, ID_DISP_NOISE_MAX, m_Max );
  129. //}}AFX_DATA_MAP
  130. }
  131. //-----------------------------------------------------------------------------
  132. // Purpose:
  133. //-----------------------------------------------------------------------------
  134. void CDispNoiseDlg::OnSpinUpDown( NMHDR *pNMHDR, LRESULT *pResult )
  135. {
  136. //
  137. // get scroll up down edit box
  138. //
  139. NM_UPDOWN *pNMUpDown = ( NM_UPDOWN* )pNMHDR;
  140. switch( pNMUpDown->hdr.idFrom )
  141. {
  142. case ID_DISP_NOISE_MIN_SPIN:
  143. {
  144. CEdit *pEdit = ( CEdit* )GetDlgItem( ID_DISP_NOISE_MIN );
  145. CString strMin;
  146. pEdit->GetWindowText( strMin );
  147. m_Min = atof( strMin );
  148. m_Min += 0.5f * ( -pNMUpDown->iDelta );
  149. strMin.Format( "%4.2f", m_Min );
  150. pEdit->SetWindowText( strMin );
  151. *pResult = 0;
  152. break;
  153. }
  154. case ID_DISP_NOISE_MAX_SPIN:
  155. {
  156. CEdit *pEdit = ( CEdit* )GetDlgItem( ID_DISP_NOISE_MAX );
  157. CString strMax;
  158. pEdit->GetWindowText( strMax );
  159. m_Max = atof( strMax );
  160. m_Max += 0.5f * ( -pNMUpDown->iDelta );
  161. strMax.Format( "%4.2f", m_Max );
  162. pEdit->SetWindowText( strMax );
  163. *pResult = 0;
  164. break;
  165. }
  166. }
  167. }
  168. //=============================================================================
  169. //
  170. // Displacement Paint Distance Dialog Functions
  171. //
  172. BEGIN_MESSAGE_MAP(CDispPaintDistDlg, CDialog)
  173. //{{AFX_MSG_MAP(CDispPaintDistDlg)
  174. ON_BN_CLICKED( ID_DISP_PAINT_DIST_RAISELOWER, OnEffectRaiseLowerGeo )
  175. ON_BN_CLICKED( ID_DISP_PAINT_DIST_RAISETO, OnEffectRaiseToGeo )
  176. ON_BN_CLICKED( ID_DISP_PAINT_DIST_SMOOTH, OnEffectSmoothGeo )
  177. ON_BN_CLICKED( ID_DISPPAINT_SOFTEDGE, OnBrushTypeSoftEdge )
  178. ON_BN_CLICKED( ID_DISPPAINT_HARDEDGE, OnBrushTypeHardEdge )
  179. ON_BN_CLICKED( ID_DISP_PAINT_DIST_SPATIAL, OnCheckSpatial )
  180. ON_BN_CLICKED( ID_DISP_PAINT_DIST_AUTOSEW, OnCheckAutoSew )
  181. ON_CBN_SELCHANGE( ID_DISP_PAINT_DIST_BRUSH, OnComboBoxBrushGeo )
  182. ON_CBN_SELCHANGE( ID_DISP_PAINT_DIST_AXIS, OnComboBoxAxis )
  183. ON_WM_HSCROLL()
  184. ON_EN_CHANGE( ID_DISP_PAINT_DIST_EDIT_DISTANCE, OnEditDistance )
  185. ON_EN_CHANGE( ID_DISP_PAINT_DIST_EDIT_RADIUS, OnEditRadius )
  186. ON_WM_CLOSE()
  187. ON_WM_DESTROY()
  188. //}}AFX_MSG_MAP
  189. END_MESSAGE_MAP()
  190. //-----------------------------------------------------------------------------
  191. // Purpose: constructor
  192. //-----------------------------------------------------------------------------
  193. CDispPaintDistDlg::CDispPaintDistDlg( CWnd *pParent ) :
  194. CDialog( CDispPaintDistDlg::IDD, pParent )
  195. {
  196. }
  197. //-----------------------------------------------------------------------------
  198. // Purpose:
  199. //-----------------------------------------------------------------------------
  200. CDispPaintDistDlg::~CDispPaintDistDlg()
  201. {
  202. if ( m_comboboxBrush.m_hWnd )
  203. {
  204. m_comboboxBrush.Detach();
  205. }
  206. }
  207. //-----------------------------------------------------------------------------
  208. // Purpose:
  209. //-----------------------------------------------------------------------------
  210. BOOL CDispPaintDistDlg::OnInitDialog( void )
  211. {
  212. static bool bInit = false;
  213. CDialog::OnInitDialog();
  214. CToolDisplace *pTool = GetDisplacementTool();
  215. if ( !pTool )
  216. return FALSE;
  217. // Set spatial tool flag.
  218. if ( !pTool->IsSpatialPainting() )
  219. {
  220. pTool->ToggleSpatialPainting();
  221. }
  222. if ( !bInit )
  223. {
  224. m_flPrevDistance = 1.0f;
  225. m_flPrevRadius = 1.0f;
  226. m_nPrevBrush = 0;
  227. m_nPrevEffect = pTool->GetEffect();
  228. pTool->GetPaintAxis( m_nPrevPaintAxis, m_vecPrevPaintAxis );
  229. bInit = true;
  230. }
  231. else
  232. {
  233. SetWindowPos( &wndTop, m_DialogPosRect.left, m_DialogPosRect.top,
  234. m_DialogPosRect.Width(), m_DialogPosRect.Height(), SWP_NOZORDER );
  235. }
  236. // Initialize the combo boxes.
  237. InitComboBoxBrushGeo();
  238. InitComboBoxAxis();
  239. // Initialize the sliders.
  240. InitDistance();
  241. InitRadius();
  242. // Initialize the brush types.
  243. InitBrushType();
  244. return TRUE;
  245. }
  246. //-----------------------------------------------------------------------------
  247. //-----------------------------------------------------------------------------
  248. void CDispPaintDistDlg::InitDistance( void )
  249. {
  250. // Set the slider range and initialize the "buddy."
  251. m_sliderDistance.SetBuddy( &m_editDistance, FALSE );
  252. m_sliderDistance.SetRange( DISPPAINT_DISTANCE_MIN, DISPPAINT_DISTANCE_MAX );
  253. // Get the displacement tool.
  254. CToolDisplace *pTool = GetDisplacementTool();
  255. if ( pTool )
  256. {
  257. pTool->GetChannel( DISPPAINT_CHANNEL_POSITION, m_flPrevDistance );
  258. // Initialize the distance slider and edit box.
  259. UpdateSliderDistance( m_flPrevDistance, true );
  260. UpdateEditBoxDistance( m_flPrevDistance, true );
  261. }
  262. else
  263. {
  264. // Init distance slider and edit box.
  265. UpdateSliderDistance( 1.0f, true );
  266. UpdateEditBoxDistance( 1.0f, true );
  267. }
  268. }
  269. //-----------------------------------------------------------------------------
  270. //-----------------------------------------------------------------------------
  271. void CDispPaintDistDlg::InitRadius( void )
  272. {
  273. // Set the slider range and initialize the "buddy."
  274. m_sliderRadius.SetBuddy( &m_editRadius, FALSE );
  275. m_sliderRadius.SetRange( DISPPAINT_SPATIALRADIUS_MIN, DISPPAINT_SPATIALRADIUS_MAX );
  276. m_sliderRadius.SetTicFreq( DISPPAINT_SPATIALRADIUS_STEP );
  277. // Get the displacement tool.
  278. CToolDisplace *pTool = GetDisplacementTool();
  279. if ( pTool )
  280. {
  281. CButton *pcheckSpatial = ( CButton* )GetDlgItem( ID_DISP_PAINT_DIST_SPATIAL );
  282. if ( pTool->IsSpatialPainting() )
  283. {
  284. pcheckSpatial->SetCheck( true );
  285. EnableSliderRadius();
  286. DisablePaintingComboBoxes();
  287. }
  288. else
  289. {
  290. pcheckSpatial->SetCheck( false );
  291. DisableSliderRadius();
  292. EnablePaintingComboBoxes();
  293. }
  294. }
  295. }
  296. //-----------------------------------------------------------------------------
  297. //-----------------------------------------------------------------------------
  298. void CDispPaintDistDlg::EnableSliderRadius( void )
  299. {
  300. // Enable the radius slider and edit box.
  301. m_sliderRadius.EnableWindow( TRUE );
  302. m_editRadius.EnableWindow( TRUE );
  303. // Get the displacement tool and restore the radius.
  304. CToolDisplace *pTool = GetDisplacementTool();
  305. if ( pTool )
  306. {
  307. m_flPrevRadius = pTool->GetSpatialRadius();
  308. // Update the radius slider and edit box.
  309. UpdateSliderRadius( m_flPrevRadius, true );
  310. UpdateEditBoxRadius( m_flPrevRadius, true );
  311. }
  312. else
  313. {
  314. // Set the radius slider and edit box with default values.
  315. UpdateSliderRadius( 1.0f, true );
  316. UpdateEditBoxRadius( 1.0f, true );
  317. }
  318. }
  319. //-----------------------------------------------------------------------------
  320. //-----------------------------------------------------------------------------
  321. void CDispPaintDistDlg::DisableSliderRadius( void )
  322. {
  323. // Disable the radius slider and edit box.
  324. m_sliderRadius.EnableWindow( FALSE );
  325. m_editRadius.EnableWindow( FALSE );
  326. }
  327. //-----------------------------------------------------------------------------
  328. //-----------------------------------------------------------------------------
  329. void CDispPaintDistDlg::UpdateSpatialData( void )
  330. {
  331. // Get the displacement tool and restore the radius.
  332. CToolDisplace *pTool = GetDisplacementTool();
  333. if ( pTool )
  334. {
  335. m_flPrevRadius = pTool->GetSpatialRadius();
  336. // Update the radius slider and edit box.
  337. UpdateSliderRadius( m_flPrevRadius, true );
  338. UpdateEditBoxRadius( m_flPrevRadius, true );
  339. }
  340. }
  341. //-----------------------------------------------------------------------------
  342. //-----------------------------------------------------------------------------
  343. bool CDispPaintDistDlg::InitComboBoxBrushGeo( void )
  344. {
  345. //
  346. // get the displacement paint brush icon combo box
  347. //
  348. m_comboboxBrush.Attach( GetDlgItem( ID_DISP_PAINT_DIST_BRUSH )->m_hWnd );
  349. m_comboboxBrush.Init();
  350. // reset the size of the combo box list item
  351. m_comboboxBrush.SetItemHeight( -1, m_comboboxBrush.m_IconSize.cy + 2 );
  352. // initialize the radio button/brush combo box geometry data
  353. CToolDisplace *pTool = GetDisplacementTool();
  354. if ( pTool )
  355. {
  356. pTool->SetEffect( m_nPrevEffect );
  357. switch ( m_nPrevEffect )
  358. {
  359. case DISPPAINT_EFFECT_RAISELOWER:
  360. {
  361. pTool->SetEffect( DISPPAINT_EFFECT_RAISELOWER );
  362. SetEffectButtonGeo( DISPPAINT_EFFECT_RAISELOWER );
  363. FilterComboBoxBrushGeo( DISPPAINT_EFFECT_RAISELOWER, true );
  364. break;
  365. }
  366. case DISPPAINT_EFFECT_RAISETO:
  367. {
  368. pTool->SetEffect( DISPPAINT_EFFECT_RAISETO );
  369. SetEffectButtonGeo( DISPPAINT_EFFECT_RAISETO );
  370. FilterComboBoxBrushGeo( DISPPAINT_EFFECT_RAISETO, true );
  371. break;
  372. }
  373. case DISPPAINT_EFFECT_SMOOTH:
  374. {
  375. pTool->SetEffect( DISPPAINT_EFFECT_SMOOTH );
  376. SetEffectButtonGeo( DISPPAINT_EFFECT_SMOOTH );
  377. FilterComboBoxBrushGeo( DISPPAINT_EFFECT_SMOOTH, true );
  378. break;
  379. }
  380. default:
  381. {
  382. return false;
  383. }
  384. }
  385. OnComboBoxBrushGeo();
  386. }
  387. else
  388. {
  389. OnEffectRaiseLowerGeo();
  390. OnComboBoxBrushGeo();
  391. }
  392. return true;
  393. }
  394. //-----------------------------------------------------------------------------
  395. //-----------------------------------------------------------------------------
  396. void CDispPaintDistDlg::InitBrushType( void )
  397. {
  398. CToolDisplace *pTool = GetDisplacementTool();
  399. if ( pTool )
  400. {
  401. unsigned int uiBrushType = pTool->GetBrushType();
  402. switch ( uiBrushType )
  403. {
  404. case DISPPAINT_BRUSHTYPE_SOFT:
  405. {
  406. SetBrushTypeButtonGeo( DISPPAINT_BRUSHTYPE_SOFT );
  407. break;
  408. }
  409. case DISPPAINT_BRUSHTYPE_HARD:
  410. {
  411. SetBrushTypeButtonGeo( DISPPAINT_BRUSHTYPE_HARD );
  412. break;
  413. }
  414. }
  415. if ( pTool->IsSpatialPainting() )
  416. {
  417. EnableBrushTypeButtons();
  418. }
  419. else
  420. {
  421. DisableBrushTypeButtons();
  422. }
  423. }
  424. }
  425. //-----------------------------------------------------------------------------
  426. //-----------------------------------------------------------------------------
  427. void CDispPaintDistDlg::FilterComboBoxBrushGeo( unsigned int nEffect, bool bInit )
  428. {
  429. //
  430. // remove all the old combo box data
  431. //
  432. int count = m_comboboxBrush.GetCount();
  433. for ( int ndx = count - 1; ndx >= 0; ndx-- )
  434. {
  435. m_comboboxBrush.DeleteIcon( ndx );
  436. }
  437. //
  438. // add the new combo box data based on the current paint "effect"
  439. //
  440. CToolDisplace *pTool = GetDisplacementTool();
  441. if ( pTool )
  442. {
  443. CDispMapImageFilterManager *pFilterMgr;
  444. switch ( nEffect )
  445. {
  446. case DISPPAINT_EFFECT_RAISELOWER: { pFilterMgr = pTool->GetFilterRaiseLowerMgr(); break; }
  447. case DISPPAINT_EFFECT_RAISETO: { pFilterMgr = pTool->GetFilterRaiseToMgr(); break; }
  448. case DISPPAINT_EFFECT_SMOOTH: { pFilterMgr = pTool->GetFilterSmoothMgr(); break; }
  449. default: return;
  450. }
  451. if( pFilterMgr )
  452. {
  453. //
  454. // for each filter - add its icon to the icon combo box
  455. //
  456. for ( int iFilter = 0; iFilter < pFilterMgr->GetFilterCount(); iFilter++ )
  457. {
  458. // get the current filter
  459. CDispMapImageFilter *pFilter = pFilterMgr->GetFilter( iFilter );
  460. // get the application directory
  461. char appDir[MAX_PATH];
  462. APP()->GetDirectory( DIR_PROGRAM, appDir );
  463. // append the filters directory name
  464. strcat( appDir, "filters\\" );
  465. // append the directory prefix to the icon name
  466. CString iconFilename = appDir + pFilter->m_Name;
  467. // add the icon to the icon combo box
  468. m_comboboxBrush.AddIcon( iconFilename );
  469. }
  470. // set initial paint brush
  471. if( bInit )
  472. {
  473. m_comboboxBrush.SetCurSel( m_nPrevBrush );
  474. }
  475. else
  476. {
  477. m_comboboxBrush.SetCurSel( 0 );
  478. }
  479. }
  480. }
  481. }
  482. //-----------------------------------------------------------------------------
  483. //-----------------------------------------------------------------------------
  484. bool CDispPaintDistDlg::InitComboBoxAxis( void )
  485. {
  486. //
  487. // add the paint types to the combo box -- keep them in their "defined" order
  488. //
  489. CString strPaintDir;
  490. // axial x direction
  491. strPaintDir = "X-Axis";
  492. m_comboboxAxis.AddString( strPaintDir );
  493. // axial y direction
  494. strPaintDir = "Y-Axis";
  495. m_comboboxAxis.AddString( strPaintDir );
  496. // axial z direction
  497. strPaintDir = "Z-Axis";
  498. m_comboboxAxis.AddString( strPaintDir );
  499. // subdivision direction
  500. strPaintDir = "Subdiv Normal";
  501. m_comboboxAxis.AddString( strPaintDir );
  502. // face normal direction
  503. strPaintDir = "Face Normal";
  504. m_comboboxAxis.AddString( strPaintDir );
  505. // set initial value
  506. CToolDisplace *pTool = GetDisplacementTool();
  507. if ( pTool )
  508. {
  509. m_comboboxAxis.SetCurSel( m_nPrevPaintAxis );
  510. pTool->SetPaintAxis( m_nPrevPaintAxis, m_vecPrevPaintAxis );
  511. }
  512. else
  513. {
  514. m_comboboxAxis.SetCurSel( 4 );
  515. OnComboBoxAxis();
  516. }
  517. return true;
  518. }
  519. //-----------------------------------------------------------------------------
  520. // Purpose:
  521. //-----------------------------------------------------------------------------
  522. void CDispPaintDistDlg::EnablePaintingComboBoxes( void )
  523. {
  524. m_comboboxBrush.EnableWindow( TRUE );
  525. }
  526. //-----------------------------------------------------------------------------
  527. // Purpose:
  528. //-----------------------------------------------------------------------------
  529. void CDispPaintDistDlg::DisablePaintingComboBoxes( void )
  530. {
  531. m_comboboxBrush.EnableWindow( FALSE );
  532. }
  533. //-----------------------------------------------------------------------------
  534. // Purpose:
  535. //-----------------------------------------------------------------------------
  536. void CDispPaintDistDlg::EnableBrushTypeButtons( void )
  537. {
  538. CButton *pRadioButton;
  539. pRadioButton = ( CButton* )GetDlgItem( ID_DISPPAINT_SOFTEDGE );
  540. pRadioButton->EnableWindow( TRUE );
  541. pRadioButton = ( CButton* )GetDlgItem( ID_DISPPAINT_HARDEDGE );
  542. pRadioButton->EnableWindow( TRUE );
  543. }
  544. //-----------------------------------------------------------------------------
  545. // Purpose:
  546. //-----------------------------------------------------------------------------
  547. void CDispPaintDistDlg::DisableBrushTypeButtons( void )
  548. {
  549. CButton *pRadioButton;
  550. pRadioButton = ( CButton* )GetDlgItem( ID_DISPPAINT_SOFTEDGE );
  551. pRadioButton->EnableWindow( FALSE );
  552. pRadioButton = ( CButton* )GetDlgItem( ID_DISPPAINT_HARDEDGE );
  553. pRadioButton->EnableWindow( FALSE );
  554. }
  555. //-----------------------------------------------------------------------------
  556. // Purpose:
  557. //-----------------------------------------------------------------------------
  558. void CDispPaintDistDlg::DoDataExchange( CDataExchange *pDX )
  559. {
  560. CDialog::DoDataExchange( pDX );
  561. //{{AFX_DATA_MAP(CDispPaintDistDlg)
  562. DDX_Control( pDX, ID_DISP_PAINT_DIST_SLIDER_DISTANCE, m_sliderDistance );
  563. DDX_Control( pDX, ID_DISP_PAINT_DIST_SLIDER_RADIUS, m_sliderRadius );
  564. DDX_Control( pDX, ID_DISP_PAINT_DIST_EDIT_DISTANCE, m_editDistance );
  565. DDX_Control( pDX, ID_DISP_PAINT_DIST_EDIT_RADIUS, m_editRadius );
  566. DDX_Control( pDX, ID_DISP_PAINT_DIST_AXIS, m_comboboxAxis );
  567. //}}AFX_DATA_MAP
  568. }
  569. //-----------------------------------------------------------------------------
  570. //-----------------------------------------------------------------------------
  571. void CDispPaintDistDlg::OnComboBoxBrushGeo( void )
  572. {
  573. // get the displacement's filter manager
  574. CToolDisplace *pTool = GetDisplacementTool();
  575. if ( pTool )
  576. {
  577. // get current selection
  578. int iSel = m_comboboxBrush.GetCurSel();
  579. if ( iSel == LB_ERR )
  580. return;
  581. unsigned int nEffect = pTool->GetEffect();
  582. CDispMapImageFilterManager *pFilterMgr;
  583. switch ( nEffect )
  584. {
  585. case DISPPAINT_EFFECT_RAISELOWER: { pFilterMgr = pTool->GetFilterRaiseLowerMgr(); break; }
  586. case DISPPAINT_EFFECT_RAISETO: { pFilterMgr = pTool->GetFilterRaiseToMgr(); break; }
  587. case DISPPAINT_EFFECT_SMOOTH: { pFilterMgr = pTool->GetFilterSmoothMgr(); break; }
  588. default: return;
  589. }
  590. if ( pFilterMgr )
  591. {
  592. pFilterMgr->SetActiveFilter( iSel );
  593. }
  594. }
  595. }
  596. //-----------------------------------------------------------------------------
  597. //-----------------------------------------------------------------------------
  598. void CDispPaintDistDlg::OnComboBoxAxis( void )
  599. {
  600. // get the displacement tool
  601. CToolDisplace *pTool = GetDisplacementTool();
  602. if ( pTool )
  603. {
  604. //
  605. // get the current paint type selection
  606. //
  607. int ndxSel = m_comboboxAxis.GetCurSel();
  608. if ( ndxSel == LB_ERR )
  609. return;
  610. // update the paint type
  611. UpdateAxis( ndxSel );
  612. }
  613. }
  614. //-----------------------------------------------------------------------------
  615. //-----------------------------------------------------------------------------
  616. void CDispPaintDistDlg::UpdateAxis( int nAxis )
  617. {
  618. // get the displacement tool
  619. CToolDisplace *pTool = GetDisplacementTool();
  620. if ( !pTool )
  621. return;
  622. //
  623. // update the paint type - direction
  624. //
  625. switch ( nAxis )
  626. {
  627. case DISPPAINT_AXIS_X: { pTool->SetPaintAxis( nAxis, Vector( 1.0f, 0.0f, 0.0f ) ); return; }
  628. case DISPPAINT_AXIS_Y: { pTool->SetPaintAxis( nAxis, Vector( 0.0f, 1.0f, 0.0f ) ); return; }
  629. case DISPPAINT_AXIS_Z: { pTool->SetPaintAxis( nAxis, Vector( 0.0f, 0.0f, 1.0f ) ); return; }
  630. case DISPPAINT_AXIS_SUBDIV: { pTool->SetPaintAxis( nAxis, Vector( 0.0f, 0.0f, 0.0f ) ); return; }
  631. case DISPPAINT_AXIS_FACE: { pTool->SetPaintAxis( nAxis, Vector( 0.0f, 0.0f, 1.0f ) ); return; }
  632. default: { return; }
  633. }
  634. }
  635. //-----------------------------------------------------------------------------
  636. //-----------------------------------------------------------------------------
  637. void CDispPaintDistDlg::OnCheckAutoSew( void )
  638. {
  639. // get the displacement tool
  640. CToolDisplace *pTool = GetDisplacementTool();
  641. if ( pTool )
  642. {
  643. pTool->ToggleAutoSew();
  644. }
  645. }
  646. //-----------------------------------------------------------------------------
  647. //-----------------------------------------------------------------------------
  648. void CDispPaintDistDlg::OnCheckSpatial( void )
  649. {
  650. // Get the displacement tool and toggle the spatial painting bit.
  651. CToolDisplace *pTool = GetDisplacementTool();
  652. if ( pTool )
  653. {
  654. pTool->ToggleSpatialPainting();
  655. if ( pTool->IsSpatialPainting() )
  656. {
  657. EnableSliderRadius();
  658. DisablePaintingComboBoxes();
  659. EnableBrushTypeButtons();
  660. }
  661. else
  662. {
  663. DisableSliderRadius();
  664. EnablePaintingComboBoxes();
  665. DisableBrushTypeButtons();
  666. }
  667. }
  668. }
  669. //-----------------------------------------------------------------------------
  670. //-----------------------------------------------------------------------------
  671. void CDispPaintDistDlg::SetEffectButtonGeo( unsigned int nEffect )
  672. {
  673. CButton *radiobutton;
  674. radiobutton = ( CButton* )GetDlgItem( ID_DISP_PAINT_DIST_RAISELOWER );
  675. radiobutton->SetCheck( nEffect == DISPPAINT_EFFECT_RAISELOWER );
  676. radiobutton = ( CButton* )GetDlgItem( ID_DISP_PAINT_DIST_RAISETO );
  677. radiobutton->SetCheck( nEffect == DISPPAINT_EFFECT_RAISETO );
  678. radiobutton = ( CButton* )GetDlgItem( ID_DISP_PAINT_DIST_SMOOTH );
  679. radiobutton->SetCheck( nEffect == DISPPAINT_EFFECT_SMOOTH );
  680. }
  681. //-----------------------------------------------------------------------------
  682. // Purpose:
  683. //-----------------------------------------------------------------------------
  684. void CDispPaintDistDlg::SetBrushTypeButtonGeo( unsigned int uiBrushType )
  685. {
  686. CButton *pRadioButton;
  687. pRadioButton = ( CButton* )GetDlgItem( ID_DISPPAINT_SOFTEDGE );
  688. pRadioButton->SetCheck( uiBrushType == DISPPAINT_BRUSHTYPE_SOFT );
  689. pRadioButton = ( CButton* )GetDlgItem( ID_DISPPAINT_HARDEDGE );
  690. pRadioButton->SetCheck( uiBrushType == DISPPAINT_BRUSHTYPE_HARD );
  691. }
  692. //-----------------------------------------------------------------------------
  693. //-----------------------------------------------------------------------------
  694. void CDispPaintDistDlg::OnEffectRaiseLowerGeo( void )
  695. {
  696. // get the displacement tool
  697. CToolDisplace *pTool = GetDisplacementTool();
  698. if ( pTool )
  699. {
  700. pTool->SetEffect( DISPPAINT_EFFECT_RAISELOWER );
  701. SetEffectButtonGeo( DISPPAINT_EFFECT_RAISELOWER );
  702. FilterComboBoxBrushGeo( DISPPAINT_EFFECT_RAISELOWER, false );
  703. OnComboBoxBrushGeo();
  704. }
  705. }
  706. //-----------------------------------------------------------------------------
  707. //-----------------------------------------------------------------------------
  708. void CDispPaintDistDlg::OnEffectRaiseToGeo( void )
  709. {
  710. // get the displacement tool
  711. CToolDisplace *pTool = GetDisplacementTool();
  712. if( pTool )
  713. {
  714. pTool->SetEffect( DISPPAINT_EFFECT_RAISETO );
  715. SetEffectButtonGeo( DISPPAINT_EFFECT_RAISETO );
  716. FilterComboBoxBrushGeo( DISPPAINT_EFFECT_RAISETO, false );
  717. OnComboBoxBrushGeo();
  718. }
  719. }
  720. //-----------------------------------------------------------------------------
  721. //-----------------------------------------------------------------------------
  722. void CDispPaintDistDlg::OnEffectSmoothGeo( void )
  723. {
  724. // get the displacement tool
  725. CToolDisplace *pTool = GetDisplacementTool();
  726. if( pTool )
  727. {
  728. pTool->SetEffect( DISPPAINT_EFFECT_SMOOTH );
  729. SetEffectButtonGeo( DISPPAINT_EFFECT_SMOOTH );
  730. FilterComboBoxBrushGeo( DISPPAINT_EFFECT_SMOOTH, false );
  731. OnComboBoxBrushGeo();
  732. }
  733. }
  734. //-----------------------------------------------------------------------------
  735. // Purpose:
  736. //-----------------------------------------------------------------------------
  737. void CDispPaintDistDlg::OnBrushTypeSoftEdge( void )
  738. {
  739. CToolDisplace *pTool = GetDisplacementTool();
  740. if ( pTool )
  741. {
  742. pTool->SetBrushType( DISPPAINT_BRUSHTYPE_SOFT );
  743. SetBrushTypeButtonGeo( DISPPAINT_BRUSHTYPE_SOFT );
  744. }
  745. }
  746. //-----------------------------------------------------------------------------
  747. // Purpose:
  748. //-----------------------------------------------------------------------------
  749. void CDispPaintDistDlg::OnBrushTypeHardEdge( void )
  750. {
  751. CToolDisplace *pTool = GetDisplacementTool();
  752. if ( pTool )
  753. {
  754. pTool->SetBrushType( DISPPAINT_BRUSHTYPE_HARD );
  755. SetBrushTypeButtonGeo( DISPPAINT_BRUSHTYPE_HARD );
  756. }
  757. }
  758. //-----------------------------------------------------------------------------
  759. //-----------------------------------------------------------------------------
  760. void CDispPaintDistDlg::UpdateSliderDistance( float flDistance, bool bForceInit )
  761. {
  762. if ( ( flDistance != m_flPrevDistance ) || bForceInit )
  763. {
  764. int nDistance = ( int )flDistance;
  765. // clamp
  766. if( nDistance < DISPPAINT_DISTANCE_MIN ) { nDistance = DISPPAINT_DISTANCE_MIN; }
  767. if( nDistance > DISPPAINT_DISTANCE_MAX ) { nDistance = DISPPAINT_DISTANCE_MAX; }
  768. m_sliderDistance.SetPos( nDistance );
  769. }
  770. }
  771. //-----------------------------------------------------------------------------
  772. //-----------------------------------------------------------------------------
  773. void CDispPaintDistDlg::UpdateEditBoxDistance( float flDistance, bool bForceInit )
  774. {
  775. if ( ( flDistance != m_flPrevDistance ) || bForceInit )
  776. {
  777. CString strDistance;
  778. strDistance.Format( "%4.2f", flDistance );
  779. m_editDistance.SetWindowText( strDistance );
  780. }
  781. }
  782. //-----------------------------------------------------------------------------
  783. //-----------------------------------------------------------------------------
  784. void CDispPaintDistDlg::UpdateSliderRadius( float flRadius, bool bForceInit )
  785. {
  786. if ( ( flRadius != m_flPrevRadius ) || bForceInit )
  787. {
  788. int nRadius = ( int )flRadius;
  789. // clamp
  790. if( nRadius < DISPPAINT_SPATIALRADIUS_MIN ) { nRadius = DISPPAINT_SPATIALRADIUS_MIN; }
  791. if( nRadius > DISPPAINT_SPATIALRADIUS_MAX ) { nRadius = DISPPAINT_SPATIALRADIUS_MAX; }
  792. m_sliderRadius.SetPos( nRadius );
  793. }
  794. }
  795. //-----------------------------------------------------------------------------
  796. //-----------------------------------------------------------------------------
  797. void CDispPaintDistDlg::UpdateEditBoxRadius( float flRadius, bool bForceInit )
  798. {
  799. if ( ( flRadius != m_flPrevRadius ) || bForceInit )
  800. {
  801. CString strRadius;
  802. strRadius.Format( "%4.2f", flRadius );
  803. m_editRadius.SetWindowText( strRadius );
  804. }
  805. }
  806. //-----------------------------------------------------------------------------
  807. //-----------------------------------------------------------------------------
  808. void CDispPaintDistDlg::OnHScroll( UINT nSBCode, UINT nPos, CScrollBar *pScrollBar )
  809. {
  810. // Get the displacement tool.
  811. CToolDisplace *pTool = GetDisplacementTool();
  812. if ( pTool )
  813. {
  814. // Get the distance slider control.
  815. CSliderCtrl *pDistSlider = ( CSliderCtrl* )GetDlgItem( ID_DISP_PAINT_DIST_SLIDER_DISTANCE );
  816. if ( pDistSlider )
  817. {
  818. // Get the slider position.
  819. int nDistPos = pDistSlider->GetPos();
  820. if ( nDistPos != m_flPrevDistance )
  821. {
  822. // Update the displacement tool info.
  823. pTool->SetChannel( DISPPAINT_CHANNEL_POSITION, ( float )nDistPos );
  824. // Update the "buddy" edit box.
  825. CString strDistance;
  826. strDistance.Format( "%4.2f", ( float )nDistPos );
  827. m_editDistance.SetWindowText( strDistance );
  828. }
  829. }
  830. // Get the radius slider control.
  831. CSliderCtrl *pRadiusSlider = ( CSliderCtrl* )GetDlgItem( ID_DISP_PAINT_DIST_SLIDER_RADIUS );
  832. if ( pRadiusSlider )
  833. {
  834. // Get the slider position.
  835. int nRadiusPos = pRadiusSlider->GetPos();
  836. if ( nRadiusPos != m_flPrevRadius )
  837. {
  838. // Update the displacement tool info.
  839. pTool->SetSpatialRadius( ( float )nRadiusPos );
  840. // Update the "buddy" edit box.
  841. CString strRadius;
  842. strRadius.Format( "%4.2f", ( float )nRadiusPos );
  843. m_editRadius.SetWindowText( strRadius );
  844. }
  845. }
  846. }
  847. }
  848. //-----------------------------------------------------------------------------
  849. //-----------------------------------------------------------------------------
  850. void CDispPaintDistDlg::OnEditDistance( void )
  851. {
  852. //
  853. // get the edit box distance data
  854. //
  855. CString strDistance;
  856. m_editDistance.GetWindowText( strDistance );
  857. float flDistance = atof( strDistance );
  858. // get the displacement tool
  859. CToolDisplace *pTool = GetDisplacementTool();
  860. if ( pTool )
  861. {
  862. UpdateSliderDistance( flDistance, false );
  863. pTool->SetChannel( DISPPAINT_CHANNEL_POSITION, flDistance );
  864. // Save the change in the distance.
  865. m_flPrevDistance = flDistance;
  866. }
  867. }
  868. //-----------------------------------------------------------------------------
  869. //-----------------------------------------------------------------------------
  870. void CDispPaintDistDlg::OnEditRadius( void )
  871. {
  872. //
  873. // Get the edit box radius data.
  874. //
  875. CString strRadius;
  876. m_editRadius.GetWindowText( strRadius );
  877. float flRadius = atof( strRadius );
  878. // get the displacement tool
  879. CToolDisplace *pTool = GetDisplacementTool();
  880. if ( pTool )
  881. {
  882. UpdateSliderRadius( flRadius, false );
  883. pTool->SetSpatialRadius( flRadius );
  884. // Save the change in the spatial radius.
  885. m_flPrevRadius = flRadius;
  886. }
  887. }
  888. //-----------------------------------------------------------------------------
  889. //-----------------------------------------------------------------------------
  890. void CDispPaintDistDlg::OnClose( void )
  891. {
  892. // get the displacement tool and set selection tool active
  893. CToolDisplace *pDispTool = GetDisplacementTool();
  894. if( pDispTool )
  895. {
  896. pDispTool->SetTool( DISPTOOL_SELECT );
  897. }
  898. // set "select" as the current tool - this should destroy this dialog!!
  899. CFaceEditSheet *pSheet = ( CFaceEditSheet* )GetParent();
  900. if ( pSheet )
  901. {
  902. pSheet->m_DispPage.SetTool( CFaceEditDispPage::FACEEDITTOOL_SELECT );
  903. }
  904. }
  905. //-----------------------------------------------------------------------------
  906. //-----------------------------------------------------------------------------
  907. void CDispPaintDistDlg::OnDestroy( void )
  908. {
  909. //
  910. // save the current dialog data - window position, effect, etc...
  911. //
  912. GetWindowRect( &m_DialogPosRect );
  913. CToolDisplace *pTool = GetDisplacementTool();
  914. if ( pTool )
  915. {
  916. m_nPrevEffect = pTool->GetEffect();
  917. pTool->GetPaintAxis( m_nPrevPaintAxis, m_vecPrevPaintAxis );
  918. // Reset spatial tool flag.
  919. if ( pTool->IsSpatialPainting() )
  920. {
  921. pTool->ToggleSpatialPainting();
  922. }
  923. }
  924. m_nPrevBrush = m_comboboxBrush.GetCurSel();
  925. // detach the brush combo box!!
  926. m_comboboxBrush.Detach();
  927. }
  928. //=============================================================================
  929. //
  930. // Paint Scult Dialog Functions
  931. //
  932. BEGIN_MESSAGE_MAP(CPaintSculptDlg, CDialog)
  933. //{{AFX_MSG_MAP(CPaintSculptDlg)
  934. ON_BN_CLICKED( ID_DISP_PAINT_DIST_AUTOSEW, OnCheckAutoSew )
  935. ON_WM_CLOSE()
  936. ON_WM_DESTROY()
  937. ON_BN_CLICKED(IDC_SCULPT_PUSH, &CPaintSculptDlg::OnBnClickedSculptPush)
  938. ON_BN_CLICKED(IDC_SCULPT_CARVE, &CPaintSculptDlg::OnBnClickedSculptCarve)
  939. ON_BN_CLICKED(IDC_SCULPT_PROJECT, &CPaintSculptDlg::OnBnClickedSculptProject)
  940. ON_BN_CLICKED(IDC_SCULPT_BLEND, &CPaintSculptDlg::OnBnClickedSculptBlend)
  941. ON_WM_LBUTTONUP()
  942. ON_WM_LBUTTONDOWN()
  943. ON_WM_MOUSEMOVE()
  944. //}}AFX_MSG_MAP
  945. END_MESSAGE_MAP()
  946. //-----------------------------------------------------------------------------
  947. // Purpose: constructor
  948. //-----------------------------------------------------------------------------
  949. CPaintSculptDlg::CPaintSculptDlg( CWnd *pParent ) :
  950. CDialog( CPaintSculptDlg::IDD, pParent )
  951. {
  952. m_bAutoSew = true;
  953. m_SculptMode = SCULPT_MODE_PUSH;
  954. m_PushOptions = new CSculptPushOptions();
  955. m_CarveOptions = new CSculptCarveOptions();
  956. // m_ProjectOptions = new CSculptProjectOptions();
  957. m_BlendOptions = new CSculptBlendOptions();
  958. }
  959. //-----------------------------------------------------------------------------
  960. // Purpose: destructor
  961. //-----------------------------------------------------------------------------
  962. CPaintSculptDlg::~CPaintSculptDlg( )
  963. {
  964. delete m_PushOptions;
  965. delete m_CarveOptions;
  966. // delete m_ProjectOptions;
  967. delete m_BlendOptions;
  968. }
  969. //-----------------------------------------------------------------------------
  970. // Purpose: intialized the dialog
  971. // Output : returns true if successful
  972. //-----------------------------------------------------------------------------
  973. BOOL CPaintSculptDlg::OnInitDialog( )
  974. {
  975. static bool bInit = false;
  976. CDialog::OnInitDialog();
  977. CToolDisplace *pTool = GetDisplacementTool();
  978. if ( !pTool )
  979. {
  980. return FALSE;
  981. }
  982. #if 0
  983. // Set spatial tool flag.
  984. if ( !pTool->IsSpatialPainting() )
  985. {
  986. pTool->ToggleSpatialPainting();
  987. }
  988. #endif
  989. if ( !bInit )
  990. {
  991. bInit = true;
  992. }
  993. else
  994. {
  995. SetWindowPos( &wndTop, m_DialogPosRect.left, m_DialogPosRect.top, m_DialogPosRect.Width(), m_DialogPosRect.Height(), SWP_NOZORDER );
  996. }
  997. m_AutoSew.SetCheck( m_bAutoSew );
  998. m_PushOptions->SetPaintOwner( this );
  999. m_CarveOptions->SetPaintOwner( this );
  1000. // m_ProjectOptions->SetPaintOwner( this );
  1001. m_BlendOptions->SetPaintOwner( this );
  1002. if( !m_PushOptions->Create( IDD_DISP_SCULPT_PUSH_OPTIONS, this ) )
  1003. {
  1004. return FALSE;
  1005. }
  1006. if( !m_CarveOptions->Create( IDD_DISP_SCULPT_CARVE_OPTIONS, this ) )
  1007. {
  1008. return FALSE;
  1009. }
  1010. #if 0
  1011. if( !m_ProjectOptions->Create( IDD_DISP_SCULPT_PROJECT_OPTIONS, this ) )
  1012. {
  1013. return FALSE;
  1014. }
  1015. #endif
  1016. if( !m_BlendOptions->Create( IDD_DISP_SCULPT_BLEND_OPTIONS, this ) )
  1017. {
  1018. return FALSE;
  1019. }
  1020. RECT OptionsLoc, ThisLoc;
  1021. m_SculptOptionsLoc.GetWindowRect( &OptionsLoc );
  1022. GetWindowRect( &ThisLoc );
  1023. m_PushOptions->SetWindowPos( NULL, 10, OptionsLoc.top - ThisLoc.top - 20, 0, 0, SWP_NOSIZE | SWP_SHOWWINDOW );
  1024. m_CarveOptions->SetWindowPos( NULL, 10, OptionsLoc.top - ThisLoc.top - 20, 0, 0, SWP_NOSIZE | SWP_SHOWWINDOW );
  1025. // m_ProjectOptions->SetWindowPos( NULL, 10, OptionsLoc.top - ThisLoc.top - 20, 0, 0, SWP_NOSIZE | SWP_SHOWWINDOW );
  1026. m_BlendOptions->SetWindowPos( NULL, 10, OptionsLoc.top - ThisLoc.top - 20, 0, 0, SWP_NOSIZE | SWP_SHOWWINDOW );
  1027. m_PushOptions->ShowWindow( SW_HIDE );
  1028. m_CarveOptions->ShowWindow( SW_HIDE );
  1029. // m_ProjectOptions->ShowWindow( SW_HIDE );
  1030. m_BlendOptions->ShowWindow( SW_HIDE );
  1031. m_ProjectButton.EnableWindow( FALSE );
  1032. SetActiveMode( m_SculptMode );
  1033. return TRUE;
  1034. }
  1035. //-----------------------------------------------------------------------------
  1036. // Purpose: set up the data exchange between the dialog and variables
  1037. // Input : pDX - data exchange object
  1038. //-----------------------------------------------------------------------------
  1039. void CPaintSculptDlg::DoDataExchange( CDataExchange *pDX )
  1040. {
  1041. CDialog::DoDataExchange( pDX );
  1042. //{{AFX_DATA_MAP(CPaintSculptDlg)
  1043. //}}AFX_DATA_MAP
  1044. DDX_Control(pDX, IDC_SCULPT_OPTIONS_LOC, m_SculptOptionsLoc);
  1045. DDX_Control(pDX, ID_DISP_PAINT_DIST_AUTOSEW, m_AutoSew);
  1046. DDX_Control(pDX, IDC_SCULPT_PUSH, m_PushButton);
  1047. DDX_Control(pDX, IDC_SCULPT_CARVE, m_CarveButton);
  1048. DDX_Control(pDX, IDC_SCULPT_PROJECT, m_ProjectButton);
  1049. DDX_Control(pDX, IDC_SCULPT_BLEND, m_BlendButton);
  1050. }
  1051. //-----------------------------------------------------------------------------
  1052. // Purpose: Sets the autosew option
  1053. //-----------------------------------------------------------------------------
  1054. void CPaintSculptDlg::OnCheckAutoSew( )
  1055. {
  1056. m_bAutoSew = ( m_AutoSew.GetCheck() != 0 );
  1057. }
  1058. //-----------------------------------------------------------------------------
  1059. // Purpose: handles shutting down the dialog
  1060. //-----------------------------------------------------------------------------
  1061. void CPaintSculptDlg::OnClose( )
  1062. {
  1063. // get the displacement tool and set selection tool active
  1064. CToolDisplace *pDispTool = GetDisplacementTool();
  1065. if( pDispTool )
  1066. {
  1067. pDispTool->SetTool( DISPTOOL_SELECT );
  1068. }
  1069. // set "select" as the current tool - this should destroy this dialog!!
  1070. CFaceEditSheet *pSheet = ( CFaceEditSheet* )GetParent();
  1071. if ( pSheet )
  1072. {
  1073. pSheet->m_DispPage.SetTool( CFaceEditDispPage::FACEEDITTOOL_SELECT );
  1074. }
  1075. }
  1076. //-----------------------------------------------------------------------------
  1077. // Purpose: Handles the left button up
  1078. // Input : nFlags - button flags
  1079. // point - the location of the click
  1080. //-----------------------------------------------------------------------------
  1081. void CPaintSculptDlg::OnLButtonUp( UINT nFlags, CPoint point )
  1082. {
  1083. CToolDisplace *pDispTool = GetDisplacementTool();
  1084. if ( pDispTool != NULL )
  1085. {
  1086. CSculptPainter *painter = dynamic_cast< CSculptPainter * >( pDispTool->GetSculptPainter() );
  1087. if ( painter )
  1088. {
  1089. painter->OnLButtonUpDialog( nFlags, point );
  1090. }
  1091. }
  1092. __super::OnLButtonUp(nFlags, point);
  1093. }
  1094. //-----------------------------------------------------------------------------
  1095. // Purpose: Handles the left button down
  1096. // Input : nFlags - button flags
  1097. // point - the location of the click
  1098. //-----------------------------------------------------------------------------
  1099. void CPaintSculptDlg::OnLButtonDown( UINT nFlags, CPoint point )
  1100. {
  1101. CToolDisplace *pDispTool = GetDisplacementTool();
  1102. if ( pDispTool != NULL )
  1103. {
  1104. CSculptPainter *painter = dynamic_cast< CSculptPainter * >( pDispTool->GetSculptPainter() );
  1105. if ( painter )
  1106. {
  1107. painter->OnLButtonDownDialog( nFlags, point );
  1108. }
  1109. }
  1110. __super::OnLButtonDown(nFlags, point);
  1111. }
  1112. //-----------------------------------------------------------------------------
  1113. // Purpose: Handles mouse move
  1114. // Input : nFlags - button flags
  1115. // point - the location of the click
  1116. //-----------------------------------------------------------------------------
  1117. void CPaintSculptDlg::OnMouseMove( UINT nFlags, CPoint point )
  1118. {
  1119. CToolDisplace *pDispTool = GetDisplacementTool();
  1120. if ( pDispTool != NULL )
  1121. {
  1122. CSculptPainter *painter = dynamic_cast< CSculptPainter * >( pDispTool->GetSculptPainter() );
  1123. if ( painter )
  1124. {
  1125. painter->OnMouseMoveDialog( nFlags, point );
  1126. }
  1127. }
  1128. __super::OnMouseMove(nFlags, point);
  1129. }
  1130. //-----------------------------------------------------------------------------
  1131. // Purpose: handles the destruction of the window
  1132. //-----------------------------------------------------------------------------
  1133. void CPaintSculptDlg::OnDestroy( )
  1134. {
  1135. //
  1136. // save the current dialog data - window position, effect, etc...
  1137. //
  1138. GetWindowRect( &m_DialogPosRect );
  1139. CToolDisplace *pDispTool = GetDisplacementTool();
  1140. if( pDispTool )
  1141. {
  1142. pDispTool->GetSelectedDisps(); // ensure we have a selection count!
  1143. CDialog *painter = dynamic_cast< CDialog * >( pDispTool->GetSculptPainter() );
  1144. if ( painter )
  1145. {
  1146. painter->ShowWindow( SW_HIDE );
  1147. }
  1148. }
  1149. #if 0
  1150. CToolDisplace *pTool = GetDisplacementTool();
  1151. if ( pTool )
  1152. {
  1153. // Reset spatial tool flag.
  1154. if ( pTool->IsSpatialPainting() )
  1155. {
  1156. pTool->ToggleSpatialPainting();
  1157. }
  1158. }
  1159. #endif
  1160. }
  1161. //-----------------------------------------------------------------------------
  1162. // Purpose: sets the active mode to push
  1163. //-----------------------------------------------------------------------------
  1164. void CPaintSculptDlg::OnBnClickedSculptPush( )
  1165. {
  1166. SetActiveMode( SCULPT_MODE_PUSH );
  1167. }
  1168. //-----------------------------------------------------------------------------
  1169. // Purpose: sets the active mode to carve
  1170. //-----------------------------------------------------------------------------
  1171. void CPaintSculptDlg::OnBnClickedSculptCarve( )
  1172. {
  1173. SetActiveMode( SCULPT_MODE_CARVE );
  1174. }
  1175. //-----------------------------------------------------------------------------
  1176. // Purpose: sets the active mode to sculpt
  1177. //-----------------------------------------------------------------------------
  1178. void CPaintSculptDlg::OnBnClickedSculptProject( )
  1179. {
  1180. // SetActiveMode( SCULPT_MODE_PROJECT );
  1181. }
  1182. //-----------------------------------------------------------------------------
  1183. // Purpose: sets the active mode to blend
  1184. //-----------------------------------------------------------------------------
  1185. void CPaintSculptDlg::OnBnClickedSculptBlend( )
  1186. {
  1187. SetActiveMode( SCULPT_MODE_BLEND );
  1188. }
  1189. #if 0
  1190. //-----------------------------------------------------------------------------
  1191. // Purpose:
  1192. // Input :
  1193. // Output :
  1194. //-----------------------------------------------------------------------------
  1195. BOOL CPaintSculptDlg::PreTranslateMessage( MSG* pMsg )
  1196. {
  1197. return __super::PreTranslateMessage( pMsg );
  1198. }
  1199. #endif
  1200. //-----------------------------------------------------------------------------
  1201. // Purpose: sets the active mode
  1202. // Input : NewMode - the mode we are going to
  1203. //-----------------------------------------------------------------------------
  1204. void CPaintSculptDlg::SetActiveMode( SculptMode NewMode )
  1205. {
  1206. m_SculptMode = NewMode;
  1207. m_PushButton.SetCheck( m_SculptMode == SCULPT_MODE_PUSH );
  1208. m_CarveButton.SetCheck( m_SculptMode == SCULPT_MODE_CARVE );
  1209. m_ProjectButton.SetCheck( m_SculptMode == SCULPT_MODE_PROJECT );
  1210. m_BlendButton.SetCheck( m_SculptMode == SCULPT_MODE_BLEND );
  1211. CToolDisplace *pDispTool = GetDisplacementTool();
  1212. if( pDispTool )
  1213. {
  1214. pDispTool->GetSelectedDisps(); // ensure we have a selection count!
  1215. CDialog *painter = dynamic_cast< CDialog * >( pDispTool->GetSculptPainter() );
  1216. if ( painter )
  1217. {
  1218. painter->ShowWindow( SW_HIDE );
  1219. }
  1220. switch( m_SculptMode )
  1221. {
  1222. case SCULPT_MODE_PUSH:
  1223. m_PushOptions->ShowWindow( SW_SHOW );
  1224. pDispTool->SetSculptPainter( m_PushOptions );
  1225. break;
  1226. case SCULPT_MODE_CARVE:
  1227. m_CarveOptions->ShowWindow( SW_SHOW );
  1228. pDispTool->SetSculptPainter( m_CarveOptions );
  1229. break;
  1230. #if 0
  1231. case SCULPT_MODE_PROJECT:
  1232. m_ProjectOptions->ShowWindow( SW_SHOW );
  1233. pDispTool->SetSculptPainter( m_ProjectOptions );
  1234. break;
  1235. #endif
  1236. case SCULPT_MODE_BLEND:
  1237. m_BlendOptions->ShowWindow( SW_SHOW );
  1238. pDispTool->SetSculptPainter( m_BlendOptions );
  1239. break;
  1240. }
  1241. }
  1242. }
  1243. //=============================================================================
  1244. //
  1245. // Set Paint Distance Dialog Functions
  1246. //
  1247. BEGIN_MESSAGE_MAP(CDispPaintDataDlg, CDialog)
  1248. //{{AFX_MSG_MAP(CDispPaintDataDlg)
  1249. ON_BN_CLICKED( ID_DISP_PAINT_DATA_RAISELOWER, OnEffectRaiseLowerData )
  1250. ON_BN_CLICKED( ID_DISP_PAINT_DATA_RAISETO, OnEffectRaiseToData )
  1251. ON_BN_CLICKED( ID_DISP_PAINT_DATA_SMOOTH, OnEffectSmoothData )
  1252. ON_CBN_SELCHANGE( ID_DISP_PAINT_DATA_BRUSH, OnComboBoxBrushData )
  1253. ON_CBN_SELCHANGE( ID_DISP_PAINT_DATA_TYPE, OnComboBoxType )
  1254. ON_WM_HSCROLL()
  1255. ON_EN_CHANGE( ID_DISP_PAINT_DATA_EDIT_VALUE, OnEditValue )
  1256. ON_WM_CLOSE()
  1257. ON_WM_DESTROY()
  1258. //}}AFX_MSG_MAP
  1259. END_MESSAGE_MAP()
  1260. //-----------------------------------------------------------------------------
  1261. // Purpose: constructor
  1262. //-----------------------------------------------------------------------------
  1263. CDispPaintDataDlg::CDispPaintDataDlg( CWnd *pParent ) :
  1264. CDialog( CDispPaintDataDlg::IDD, pParent )
  1265. {
  1266. }
  1267. //-----------------------------------------------------------------------------
  1268. // Purpose:
  1269. //-----------------------------------------------------------------------------
  1270. CDispPaintDataDlg::~CDispPaintDataDlg()
  1271. {
  1272. if( m_comboboxBrush.m_hWnd )
  1273. {
  1274. m_comboboxBrush.Detach();
  1275. }
  1276. }
  1277. //-----------------------------------------------------------------------------
  1278. // Purpose:
  1279. //-----------------------------------------------------------------------------
  1280. BOOL CDispPaintDataDlg::OnInitDialog(void)
  1281. {
  1282. static bool bInit = false;
  1283. CDialog::OnInitDialog();
  1284. if( !bInit )
  1285. {
  1286. CToolDisplace *pDispTool = GetDisplacementTool();
  1287. if( pDispTool )
  1288. {
  1289. m_uiPrevEffect = pDispTool->GetEffect();
  1290. pDispTool->GetChannel( DISPPAINT_CHANNEL_ALPHA, m_fPrevPaintValue );
  1291. m_iPrevBrush = 0;
  1292. bInit = true;
  1293. }
  1294. }
  1295. else
  1296. {
  1297. SetWindowPos( &wndTop, m_DialogPosRect.left, m_DialogPosRect.top,
  1298. m_DialogPosRect.Width(), m_DialogPosRect.Height(), SWP_NOZORDER );
  1299. }
  1300. // initialize the sliders
  1301. InitValue();
  1302. // initialize the combo boxes
  1303. InitComboBoxBrushData();
  1304. InitComboBoxType();
  1305. return TRUE;
  1306. }
  1307. //-----------------------------------------------------------------------------
  1308. //-----------------------------------------------------------------------------
  1309. void CDispPaintDataDlg::InitValue( void )
  1310. {
  1311. // init slider value
  1312. m_sliderValue.SetBuddy( &m_editValue, FALSE );
  1313. m_sliderValue.SetRange( 1, 255 );
  1314. m_sliderValue.SetTicFreq( 25 );
  1315. CToolDisplace *pDispTool = GetDisplacementTool();
  1316. if( pDispTool )
  1317. {
  1318. pDispTool->SetChannel( DISPPAINT_CHANNEL_ALPHA, m_fPrevPaintValue );
  1319. // init slider value
  1320. UpdateSliderValue( m_fPrevPaintValue );
  1321. // initialize the value edit box
  1322. CString strValue;
  1323. strValue.Format( "%4.2f", m_fPrevPaintValue );
  1324. m_editValue.SetWindowText( strValue );
  1325. }
  1326. else
  1327. {
  1328. UpdateSliderValue( 15.0f );
  1329. // initialize the value edit box
  1330. m_editValue.SetWindowText( "15.00" );
  1331. }
  1332. }
  1333. //-----------------------------------------------------------------------------
  1334. //-----------------------------------------------------------------------------
  1335. bool CDispPaintDataDlg::InitComboBoxBrushData( void )
  1336. {
  1337. //
  1338. // get the displacement paint brush icon combo box
  1339. //
  1340. m_comboboxBrush.Attach( GetDlgItem( ID_DISP_PAINT_DATA_BRUSH )->m_hWnd );
  1341. m_comboboxBrush.Init();
  1342. // reset the size of the combo box list item
  1343. m_comboboxBrush.SetItemHeight( -1, m_comboboxBrush.m_IconSize.cy + 2 );
  1344. // set initial radio button/brush combo box data
  1345. // initialize the radio button/brush combo box geometry data
  1346. CToolDisplace *pDispTool = GetDisplacementTool();
  1347. if( pDispTool )
  1348. {
  1349. pDispTool->SetEffect( m_uiPrevEffect );
  1350. switch( m_uiPrevEffect )
  1351. {
  1352. case DISPPAINT_EFFECT_RAISELOWER:
  1353. {
  1354. pDispTool->SetEffect( DISPPAINT_EFFECT_RAISELOWER );
  1355. SetEffectButtonData( DISPPAINT_EFFECT_RAISELOWER );
  1356. FilterComboBoxBrushData( DISPPAINT_EFFECT_RAISELOWER, true );
  1357. break;
  1358. }
  1359. case DISPPAINT_EFFECT_RAISETO:
  1360. {
  1361. pDispTool->SetEffect( DISPPAINT_EFFECT_RAISETO );
  1362. SetEffectButtonData( DISPPAINT_EFFECT_RAISETO );
  1363. FilterComboBoxBrushData( DISPPAINT_EFFECT_RAISETO, true );
  1364. break;
  1365. }
  1366. case DISPPAINT_EFFECT_SMOOTH:
  1367. {
  1368. pDispTool->SetEffect( DISPPAINT_EFFECT_SMOOTH );
  1369. SetEffectButtonData( DISPPAINT_EFFECT_SMOOTH );
  1370. FilterComboBoxBrushData( DISPPAINT_EFFECT_SMOOTH, true );
  1371. break;
  1372. }
  1373. default:
  1374. {
  1375. return false;
  1376. }
  1377. }
  1378. OnComboBoxBrushData();
  1379. }
  1380. else
  1381. {
  1382. OnEffectRaiseLowerData();
  1383. OnComboBoxBrushData();
  1384. }
  1385. return true;
  1386. }
  1387. //-----------------------------------------------------------------------------
  1388. //-----------------------------------------------------------------------------
  1389. void CDispPaintDataDlg::FilterComboBoxBrushData( unsigned int uiEffect, bool bInit )
  1390. {
  1391. //
  1392. // remove all the old combo box data
  1393. //
  1394. int count = m_comboboxBrush.GetCount();
  1395. for( int ndx = count - 1; ndx >= 0; ndx-- )
  1396. {
  1397. m_comboboxBrush.DeleteIcon( ndx );
  1398. }
  1399. //
  1400. // add the new combo box data based on the current paint "effect"
  1401. //
  1402. CToolDisplace *pDispTool = GetDisplacementTool();
  1403. if( pDispTool )
  1404. {
  1405. CDispMapImageFilterManager *pFilterMgr;
  1406. switch( uiEffect )
  1407. {
  1408. case DISPPAINT_EFFECT_RAISELOWER: { pFilterMgr = pDispTool->GetFilterRaiseLowerMgr(); break; }
  1409. case DISPPAINT_EFFECT_RAISETO: { pFilterMgr = pDispTool->GetFilterRaiseToMgr(); break; }
  1410. case DISPPAINT_EFFECT_SMOOTH: { pFilterMgr = pDispTool->GetFilterSmoothMgr(); break; }
  1411. default: return;
  1412. }
  1413. if( pFilterMgr )
  1414. {
  1415. //
  1416. // for each filter - add its icon to the icon combo box
  1417. //
  1418. for( int ndxFilter = 0; ndxFilter < pFilterMgr->GetFilterCount(); ndxFilter++ )
  1419. {
  1420. // get the current filter
  1421. CDispMapImageFilter *pFilter = pFilterMgr->GetFilter( ndxFilter );
  1422. // get the application directory
  1423. char appDir[MAX_PATH];
  1424. APP()->GetDirectory( DIR_PROGRAM, appDir );
  1425. // append the filters directory name
  1426. strcat( appDir, "filters\\" );
  1427. // append the directory prefix to the icon name
  1428. CString iconFilename = appDir + pFilter->m_Name;
  1429. // add the icon to the icon combo box
  1430. m_comboboxBrush.AddIcon( iconFilename );
  1431. }
  1432. // set initial paint brush
  1433. if( bInit )
  1434. {
  1435. m_comboboxBrush.SetCurSel( m_iPrevBrush );
  1436. }
  1437. else
  1438. {
  1439. m_comboboxBrush.SetCurSel( 0 );
  1440. }
  1441. }
  1442. }
  1443. }
  1444. //-----------------------------------------------------------------------------
  1445. //-----------------------------------------------------------------------------
  1446. bool CDispPaintDataDlg::InitComboBoxType( void )
  1447. {
  1448. // alpha type
  1449. CString strType = "Alpha";
  1450. m_comboboxType.AddString( strType );
  1451. m_comboboxType.SetCurSel( 0 );
  1452. // turn off for now
  1453. m_comboboxType.EnableWindow( FALSE );
  1454. return true;
  1455. }
  1456. //-----------------------------------------------------------------------------
  1457. // Purpose:
  1458. //-----------------------------------------------------------------------------
  1459. void CDispPaintDataDlg::DoDataExchange( CDataExchange *pDX )
  1460. {
  1461. CDialog::DoDataExchange( pDX );
  1462. //{{AFX_DATA_MAP(CDispPaintDistDlg)
  1463. DDX_Control( pDX, ID_DISP_PAINT_DATA_SLIDER_VALUE, m_sliderValue );
  1464. DDX_Control( pDX, ID_DISP_PAINT_DATA_EDIT_VALUE, m_editValue );
  1465. DDX_Control( pDX, ID_DISP_PAINT_DATA_TYPE, m_comboboxType );
  1466. //}}AFX_DATA_MAP
  1467. }
  1468. //-----------------------------------------------------------------------------
  1469. //-----------------------------------------------------------------------------
  1470. void CDispPaintDataDlg::OnComboBoxBrushData( void )
  1471. {
  1472. // get the displacement's filter manager
  1473. CToolDisplace *pDispTool = GetDisplacementTool();
  1474. if( pDispTool )
  1475. {
  1476. // get current selection
  1477. int iSel = m_comboboxBrush.GetCurSel();
  1478. if( iSel == LB_ERR )
  1479. return;
  1480. unsigned int uiEffect = pDispTool->GetEffect();
  1481. CDispMapImageFilterManager *pFilterMgr;
  1482. switch( uiEffect )
  1483. {
  1484. case DISPPAINT_EFFECT_RAISELOWER: { pFilterMgr = pDispTool->GetFilterRaiseLowerMgr(); break; }
  1485. case DISPPAINT_EFFECT_RAISETO: { pFilterMgr = pDispTool->GetFilterRaiseToMgr(); break; }
  1486. case DISPPAINT_EFFECT_SMOOTH: { pFilterMgr = pDispTool->GetFilterSmoothMgr(); break; }
  1487. default: return;
  1488. }
  1489. if( pFilterMgr )
  1490. {
  1491. pFilterMgr->SetActiveFilter( iSel );
  1492. }
  1493. }
  1494. }
  1495. //-----------------------------------------------------------------------------
  1496. //-----------------------------------------------------------------------------
  1497. void CDispPaintDataDlg::OnComboBoxType( void )
  1498. {
  1499. return;
  1500. }
  1501. //-----------------------------------------------------------------------------
  1502. //-----------------------------------------------------------------------------
  1503. void CDispPaintDataDlg::SetEffectButtonData( unsigned int effect )
  1504. {
  1505. CButton *radiobutton;
  1506. radiobutton = ( CButton* )GetDlgItem( ID_DISP_PAINT_DATA_RAISELOWER );
  1507. radiobutton->SetCheck( effect == DISPPAINT_EFFECT_RAISELOWER );
  1508. radiobutton = ( CButton* )GetDlgItem( ID_DISP_PAINT_DATA_RAISETO );
  1509. radiobutton->SetCheck( effect == DISPPAINT_EFFECT_RAISETO );
  1510. radiobutton = ( CButton* )GetDlgItem( ID_DISP_PAINT_DATA_SMOOTH );
  1511. radiobutton->SetCheck( effect == DISPPAINT_EFFECT_SMOOTH );
  1512. }
  1513. //-----------------------------------------------------------------------------
  1514. //-----------------------------------------------------------------------------
  1515. void CDispPaintDataDlg::OnEffectRaiseLowerData( void )
  1516. {
  1517. // get the displacement tool
  1518. CToolDisplace *pDispTool = GetDisplacementTool();
  1519. if( pDispTool )
  1520. {
  1521. pDispTool->SetEffect( DISPPAINT_EFFECT_RAISELOWER );
  1522. SetEffectButtonData( DISPPAINT_EFFECT_RAISELOWER );
  1523. FilterComboBoxBrushData( DISPPAINT_EFFECT_RAISELOWER, false );
  1524. OnComboBoxBrushData();
  1525. }
  1526. }
  1527. //-----------------------------------------------------------------------------
  1528. //-----------------------------------------------------------------------------
  1529. void CDispPaintDataDlg::OnEffectRaiseToData( void )
  1530. {
  1531. // get the displacement tool
  1532. CToolDisplace *pDispTool = GetDisplacementTool();
  1533. if( pDispTool )
  1534. {
  1535. pDispTool->SetEffect( DISPPAINT_EFFECT_RAISETO );
  1536. SetEffectButtonData( DISPPAINT_EFFECT_RAISETO );
  1537. FilterComboBoxBrushData( DISPPAINT_EFFECT_RAISETO, false );
  1538. OnComboBoxBrushData();
  1539. }
  1540. }
  1541. //-----------------------------------------------------------------------------
  1542. //-----------------------------------------------------------------------------
  1543. void CDispPaintDataDlg::OnEffectSmoothData( void )
  1544. {
  1545. // get the displacement tool
  1546. CToolDisplace *pDispTool = GetDisplacementTool();
  1547. if( pDispTool )
  1548. {
  1549. pDispTool->SetEffect( DISPPAINT_EFFECT_SMOOTH );
  1550. SetEffectButtonData( DISPPAINT_EFFECT_SMOOTH );
  1551. FilterComboBoxBrushData( DISPPAINT_EFFECT_SMOOTH, false );
  1552. OnComboBoxBrushData();
  1553. }
  1554. }
  1555. //-----------------------------------------------------------------------------
  1556. //-----------------------------------------------------------------------------
  1557. void CDispPaintDataDlg::UpdateSliderValue( float fValue )
  1558. {
  1559. int iValue = ( int )fValue;
  1560. // clamp
  1561. if( iValue < 1 ) { iValue = 1; }
  1562. if( iValue > 255 ) { iValue = 255; }
  1563. m_sliderValue.SetPos( iValue );
  1564. }
  1565. //-----------------------------------------------------------------------------
  1566. //-----------------------------------------------------------------------------
  1567. void CDispPaintDataDlg::OnHScroll( UINT nSBCode, UINT nPos, CScrollBar *pScrollBar )
  1568. {
  1569. // get the displacement tool
  1570. CToolDisplace *pDispTool = GetDisplacementTool();
  1571. if( pDispTool )
  1572. {
  1573. // get the slider control
  1574. CSliderCtrl *pSlider = ( CSliderCtrl* )GetDlgItem( ID_DISP_PAINT_DATA_SLIDER_VALUE );
  1575. if( pSlider )
  1576. {
  1577. // get the slider position
  1578. int pos = pSlider->GetPos();
  1579. pDispTool->SetChannel( DISPPAINT_CHANNEL_ALPHA, ( float )pos );
  1580. //
  1581. // update "the buddy" the disp value cedit box
  1582. //
  1583. CString strValue;
  1584. strValue.Format( "%4.2f", ( float )pos );
  1585. m_editValue.SetWindowText( strValue );
  1586. }
  1587. }
  1588. }
  1589. //-----------------------------------------------------------------------------
  1590. //-----------------------------------------------------------------------------
  1591. void CDispPaintDataDlg::OnEditValue( void )
  1592. {
  1593. //
  1594. // get the edit box distance data
  1595. //
  1596. CString strValue;
  1597. m_editValue.GetWindowText( strValue );
  1598. float fValue = atof( strValue );
  1599. // get the displacement tool
  1600. CToolDisplace *pDispTool = GetDisplacementTool();
  1601. if( pDispTool )
  1602. {
  1603. UpdateSliderValue( fValue );
  1604. pDispTool->SetChannel( DISPPAINT_CHANNEL_ALPHA, fValue );
  1605. }
  1606. }
  1607. //-----------------------------------------------------------------------------
  1608. //-----------------------------------------------------------------------------
  1609. void CDispPaintDataDlg::OnClose( void )
  1610. {
  1611. // get the displacement tool and set selection tool active
  1612. CToolDisplace *pDispTool = GetDisplacementTool();
  1613. if( pDispTool )
  1614. {
  1615. pDispTool->SetTool( DISPTOOL_SELECT );
  1616. }
  1617. // set "select" as the current tool - this should destroy this dialog!!
  1618. CFaceEditSheet *pSheet = ( CFaceEditSheet* )GetParent();
  1619. if( pSheet )
  1620. {
  1621. pSheet->m_DispPage.SetTool( CFaceEditDispPage::FACEEDITTOOL_SELECT );
  1622. }
  1623. }
  1624. //-----------------------------------------------------------------------------
  1625. //-----------------------------------------------------------------------------
  1626. void CDispPaintDataDlg::OnDestroy( void )
  1627. {
  1628. // save the current window position
  1629. GetWindowRect( &m_DialogPosRect );
  1630. CToolDisplace *pDispTool = GetDisplacementTool();
  1631. if( pDispTool )
  1632. {
  1633. m_uiPrevEffect = pDispTool->GetEffect();
  1634. pDispTool->GetChannel( DISPPAINT_CHANNEL_ALPHA, m_fPrevPaintValue );
  1635. }
  1636. m_iPrevBrush = m_comboboxBrush.GetCurSel();
  1637. // detach the brush combo box!!
  1638. m_comboboxBrush.Detach();
  1639. }