INT_PTR CALLBACK SideBar1RollupDialogProc( HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam )
{

	UnwrapMod *mod = DLGetWindowLongPtr<UnwrapMod*>(hWnd);
	if ( !mod && message != WM_INITDIALOG ) 
		return FALSE;

	BOOL processed = mod->GetUIManager()->MessageProc(hWnd,message,wParam,lParam);
	if (processed)
		return TRUE;

	switch ( message ) 
	{
	case WM_INITDIALOG:
		{
			DLSetWindowLongPtr(hWnd, lParam);
			mod = (UnwrapMod*)lParam;
		}

		return TRUE;

	case WM_DESTROY:
	case WM_MOUSEACTIVATE:
	case WM_LBUTTONDOWN:
	case WM_LBUTTONUP:
	case WM_MOUSEMOVE:            
		return FALSE;
/*
	case WM_COMMAND:
		switch (LOWORD(wParam)) 
		{

		}
*/
	}
	return FALSE;
}
Beispiel #2
0
INT_PTR CALLBACK UnwrapUnfoldFloaterDlgProc(
		HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
	{
	UnwrapMod *mod = (UnwrapMod*)GetWindowLongPtr(hWnd,GWLP_USERDATA);
	//POINTS p = MAKEPOINTS(lParam);	commented out by sca 10/7/98 -- causing warning since unused.

	switch (msg) {
		case WM_INITDIALOG:
			{

			mod = (UnwrapMod*)lParam;
			mod->unfoldHWND = hWnd;

			SetWindowLongPtr(hWnd,GWLP_USERDATA,lParam);

			HWND hMethod = GetDlgItem(hWnd,IDC_METHOD_COMBO);
			SendMessage(hMethod, CB_RESETCONTENT, 0, 0);

			SendMessage(hMethod, CB_ADDSTRING, 0, (LPARAM)(LPCTSTR) GetString(IDS_FARTHESTFACE));
			SendMessage(hMethod, CB_ADDSTRING, 0, (LPARAM)(LPCTSTR) GetString(IDS_CLOSESTFACE));

			SendMessage(hMethod, CB_SETCURSEL, mod->unfoldMethod, 0L);

//set normalize cluster
			CheckDlgButton(hWnd,IDC_NORMALIZE_CHECK,mod->unfoldNormalize);

			break;
			}


		case WM_COMMAND:
			switch (LOWORD(wParam)) {
				case IDC_OK:
					{
					mod->SaveUnfoldDialogPos();


					BOOL tempNormalize;
					int tempMethod;

					tempNormalize = mod->unfoldNormalize;
					tempMethod = mod->unfoldMethod;

					HWND hMethod = GetDlgItem(hWnd,IDC_METHOD_COMBO);
					mod->unfoldMethod = SendMessage(hMethod, CB_GETCURSEL, 0L, 0);


					mod->unfoldNormalize = IsDlgButtonChecked(hWnd,IDC_NORMALIZE_CHECK);

					mod->fnUnfoldSelectedPolygonsNoParams();

					mod->unfoldNormalize = tempNormalize;
					mod->unfoldMethod = tempMethod;


					EndDialog(hWnd,1);
					
					break;
					}
				case IDC_CANCEL:
					{
				
					mod->SaveFlattenDialogPos();

					EndDialog(hWnd,0);

					break;
					}
				case IDC_DEFAULT:
					{

//get align
					mod->unfoldNormalize = IsDlgButtonChecked(hWnd,IDC_NORMALIZE_CHECK);
					HWND hMethod = GetDlgItem(hWnd,IDC_METHOD_COMBO);
					mod->unfoldMethod = SendMessage(hMethod, CB_GETCURSEL, 0L, 0);

					break;
					}

				}
			break;

		default:
			return FALSE;
		}
	return TRUE;
	}
Beispiel #3
0
INT_PTR CALLBACK UnwrapRelaxFloaterDlgProc(
	HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
{
	UnwrapMod *mod = DLGetWindowLongPtr<UnwrapMod*>(hWnd);
	//POINTS p = MAKEPOINTS(lParam); commented out by sca 10/7/98 -- causing warning since unused.

	static ISpinnerControl *iAmount = NULL;
	static ISpinnerControl *iIterations = NULL;
	static ISpinnerControl *iStretch = NULL;

	static BOOL bBoundary = TRUE;
	static BOOL bCorner = FALSE;
	static float amount = 1.0f;
	static int iterations = 1;

	switch (msg) {
	  case WM_INITDIALOG:
		  {


			  mod = (UnwrapMod*)lParam;
			  mod->relaxHWND = hWnd;

			  DLSetWindowLongPtr(hWnd, lParam);
			  ::SetWindowContextHelpId(hWnd, idh_unwrap_relax);

			  ICustButton *iButton = GetICustButton(GetDlgItem(hWnd, IDC_RUN_BUTTON));
			  if (iButton)
			  {
				  iButton->SetType(CBT_CHECK);
				  iButton->SetCheck(FALSE);
				  iButton->SetHighlightColor(GREEN_WASH);
				  ReleaseICustButton(iButton);
			  }

			  //create relax amount spinner and set value
			  iAmount = SetupFloatSpinner(
				  hWnd,IDC_RELAX_AMOUNTSPIN,IDC_RELAX_AMOUNT,
				  0.0f,1.0f,mod->relaxAmount);  
			  iAmount->SetScale(0.01f);
			  amount = mod->relaxAmount;

			  iIterations = SetupIntSpinner(
				  hWnd,IDC_RELAX_ITERATIONSSPIN,IDC_RELAX_ITERATIONS,
				  0,100000,mod->relaxIteration);   
			  iIterations->SetScale(1.f);
			  iterations = mod->relaxIteration;

			  iStretch = SetupFloatSpinner(
				  hWnd,IDC_RELAX_STRETCHSPIN,IDC_RELAX_STRETCH,
				  0.0f,1.0f,mod->relaxStretch); 
			  iStretch->SetScale(0.001f);

			  HWND hType = GetDlgItem(hWnd,IDC_RELAXTYPE_COMBO);
			  SendMessage(hType, CB_RESETCONTENT, 0, 0);
			  SendMessage(hType, CB_ADDSTRING, 0, (LPARAM)(LPCTSTR) GetString(IDS_PW_RELAX_FACE));
			  SendMessage(hType, CB_ADDSTRING, 0, (LPARAM)(LPCTSTR) GetString(IDS_PW_RELAX_EDGE));
			  SendMessage(hType, CB_ADDSTRING, 0, (LPARAM)(LPCTSTR) GetString(IDS_PW_RELAX_CENTERS));
			  SendMessage(hType, CB_SETCURSEL, (mod->relaxType), 0L);

			  //set align cluster
			  bBoundary = mod->relaxBoundary;
			  bCorner = mod->relaxSaddle;
			  CheckDlgButton(hWnd,IDC_BOUNDARY_CHECK,bBoundary);
			  CheckDlgButton(hWnd,IDC_CORNERS_CHECK,bCorner);

			  //restore window pos
			  mod->SetRelaxDialogPos();
			  //start the hold begin

			  if (mod->relaxType == 2)
			  {           
				  iStretch->Enable(FALSE);
				  HWND hCheck = GetDlgItem(hWnd,IDC_BOUNDARY_CHECK);
				  EnableWindow(hCheck,TRUE);
				  hCheck = GetDlgItem(hWnd,IDC_CORNERS_CHECK);
				  EnableWindow(hCheck,TRUE);
			  }
			  else
			  {           
				  iStretch->Enable(TRUE);
				  HWND hCheck = GetDlgItem(hWnd,IDC_BOUNDARY_CHECK);
				  EnableWindow(hCheck,TRUE);
				  hCheck = GetDlgItem(hWnd,IDC_CORNERS_CHECK);
				  EnableWindow(hCheck,FALSE);
			  }

			  break;
		  }
	  case WM_SYSCOMMAND:
		  if ((wParam & 0xfff0) == SC_CONTEXTHELP) 
		  {
			  MaxSDK::IHelpSystem::GetInstance()->ShowProductHelpForTopic(idh_unwrap_relax); 
		  }
		  return FALSE;
		  break;
	  case CC_SPINNER_BUTTONDOWN:
		  if (LOWORD(wParam) == IDC_UNWRAP_BIASSPIN) 
		  {
		  }
		  break;

	  case WM_CUSTEDIT_ENTER:
	  case CC_SPINNER_BUTTONUP:
		  mod->RelaxThreadOp(UnwrapMod::KThreadReStart,hWnd);
		  break;



	  case WM_CLOSE:

		  mod->RelaxThreadOp(UnwrapMod::KThreadEnd,hWnd);

		  if (iAmount) ReleaseISpinner(iAmount);
		  if (iIterations) ReleaseISpinner(iIterations);
		  if (iStretch) ReleaseISpinner(iStretch);
		  iAmount = NULL;
		  iIterations = NULL;
		  iStretch = NULL;

		  mod->hRelaxDialog = NULL;
		  EndDialog(hWnd,0);
		  break;
	  case WM_ACTIVATE:
		  mod->RelaxThreadOp(UnwrapMod::KThreadEnd,hWnd);
		  break;


	  case WM_COMMAND:
		  switch (LOWORD(wParam)) 
		  {

		  case IDC_BOUNDARY_CHECK:
		  case IDC_CORNERS_CHECK:
			  mod->RelaxThreadOp(UnwrapMod::KThreadReStart,hWnd);
			  break;

		  case IDC_RUN_BUTTON:
			  {



				  ICustButton *iButton = GetICustButton(GetDlgItem(hWnd, IDC_RUN_BUTTON));
				  if (iButton && iButton->IsChecked())
				  {
					  theHold.Begin();
					  mod->HoldPoints();
					  theHold.Accept(GetString(IDS_PW_RELAX));

					  mod->RelaxThreadOp(UnwrapMod::KThreadStart,hWnd);

				  }
				  else
					  mod->RelaxThreadOp(UnwrapMod::KThreadEnd,hWnd);

				  mod->InvalidateView();
				  TimeValue t = GetCOREInterface()->GetTime();
				  mod->NotifyDependents(FOREVER, PART_TEXMAP, REFMSG_CHANGE);
				  GetCOREInterface()->RedrawViews(t);

				  break;
			  }

			  break;
		  case IDC_APPLY:
			  {
				  //make sure when end any existing threads
				  mod->RelaxThreadOp(UnwrapMod::KThreadEnd,hWnd);



				  theHold.Begin();
				  mod->HoldPoints();
				  theHold.Accept(GetString(IDS_PW_RELAX));

				  bBoundary = IsDlgButtonChecked(hWnd,IDC_BOUNDARY_CHECK);
				  bCorner = IsDlgButtonChecked(hWnd,IDC_CORNERS_CHECK);

				  amount = iAmount->GetFVal();
				  float stretch = iStretch->GetFVal();
				  iterations = iIterations->GetIVal();

				  HWND hType = GetDlgItem(hWnd,IDC_RELAXTYPE_COMBO);
				  int type = SendMessage(hType, CB_GETCURSEL, 0L, 0);

				  HWND hStatus = GetDlgItem(hWnd,IDC_STATUSTEXT);

				  if (type == 0)
					  mod->fnRelaxByFaceAngle(iterations,stretch,amount,bBoundary,hStatus);
				  else if (type == 1)
					  mod->fnRelaxByEdgeAngle(iterations,stretch,amount,bBoundary,hStatus);
				  else if (type == 2)
					  mod->RelaxVerts2(amount,iterations,bBoundary,bCorner);

				  mod->InvalidateView();
				  TimeValue t = GetCOREInterface()->GetTime();
				  mod->NotifyDependents(FOREVER, PART_TEXMAP, REFMSG_CHANGE);
				  GetCOREInterface()->RedrawViews(t);

				  mod->relaxAmount = amount;
				  mod->relaxIteration = iterations;
				  mod->relaxStretch = stretch;
				  mod->relaxType = type;
				  mod->relaxBoundary = bBoundary;
				  mod->relaxSaddle = bCorner;

				  break;
			  }

		  case IDC_REVERT:
			  {
				  mod->RelaxThreadOp(UnwrapMod::KThreadEnd,hWnd);

				  mod->hRelaxDialog = NULL;
				  EndDialog(hWnd,0);
				  break;
			  }
		  case IDC_RELAXTYPE_COMBO:
			  if (HIWORD(wParam)== CBN_SELCHANGE)
			  {
				  mod->RelaxThreadOp(UnwrapMod::KThreadReStart,hWnd);

				  HWND hType = GetDlgItem(hWnd,IDC_RELAXTYPE_COMBO);
				  int type = SendMessage(hType, CB_GETCURSEL, 0L, 0);
				  if (type == 2)
				  {           
					  iStretch->Enable(FALSE);
					  HWND hCheck = GetDlgItem(hWnd,IDC_BOUNDARY_CHECK);
					  EnableWindow(hCheck,TRUE);
					  hCheck = GetDlgItem(hWnd,IDC_CORNERS_CHECK);
					  EnableWindow(hCheck,TRUE);
				  }
				  else
				  {           
					  iStretch->Enable(TRUE);
					  HWND hCheck = GetDlgItem(hWnd,IDC_BOUNDARY_CHECK);
					  EnableWindow(hCheck,TRUE);
					  hCheck = GetDlgItem(hWnd,IDC_CORNERS_CHECK);
					  EnableWindow(hCheck,FALSE);
				  }

			  }
			  break;

		  case IDC_DEFAULT:
			  {
				  mod->RelaxThreadOp(UnwrapMod::KThreadEnd,hWnd);
				  //get bias
				  amount = iAmount->GetFVal();
				  iterations = iIterations->GetIVal();
				  float stretch = iStretch->GetFVal();
				  HWND hType = GetDlgItem(hWnd,IDC_RELAXTYPE_COMBO);
				  int type = SendMessage(hType, CB_GETCURSEL, 0L, 0);

				  mod->relaxAmount = amount;
				  mod->relaxIteration = iterations;
				  mod->relaxStretch = stretch;
				  mod->relaxType = type;


				  //get align
				  bCorner = IsDlgButtonChecked(hWnd,IDC_CORNERS_CHECK);
				  bBoundary = IsDlgButtonChecked(hWnd,IDC_BOUNDARY_CHECK);
				  mod->relaxBoundary = bBoundary;
				  mod->relaxSaddle = bCorner;
				  //set as defaults
				  break;
			  }
		  }
		  break;

	  default:
		  return FALSE;
	}
	return TRUE;
}
INT_PTR CALLBACK UnwrapUnfoldMapFloaterDlgProc(
		HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
	{
	UnwrapMod *mod = DLGetWindowLongPtr<UnwrapMod*>(hWnd);

	static ISpinnerControl *spinThreshold = NULL;

	static int bottomHeight = 0;

	switch (msg) {
		case WM_INITDIALOG:
			{

			

			mod = (UnwrapMod*)lParam;
			mod->fnRegularMapSetHWND(hWnd);

			DLSetWindowLongPtr(hWnd, lParam);
			::SetWindowContextHelpId(hWnd, idh_unwrap_peltmap);
			SendMessage(hWnd, WM_SETICON, ICON_SMALL, GetClassLongPtr(mod->ip->GetMAXHWnd(), GCLP_HICONSM)); // mjm - 3.12.99

			HWND hMethod = GetDlgItem(hWnd,IDC_LIMIT_COMBO);
			SendMessage(hMethod, CB_RESETCONTENT, 0, 0);
			SendMessage(hMethod, CB_ADDSTRING, 0, (LPARAM)(LPCTSTR) GetString(IDS_LIMIT_FULL));
			SendMessage(hMethod, CB_ADDSTRING, 0, (LPARAM)(LPCTSTR) GetString(IDS_LIMIT_PARTIAL));
			SendMessage(hMethod, CB_ADDSTRING, 0, (LPARAM)(LPCTSTR) GetString(IDS_LIMIT_ALWAYS));

			HWND hAutoFit = GetDlgItem(hWnd,IDC_AUTOFIT_COMBO);
			SendMessage(hAutoFit, CB_RESETCONTENT, 0, 0);
			SendMessage(hAutoFit, CB_ADDSTRING, 0, (LPARAM)(LPCTSTR) GetString(IDS_AUTOFIT_NONE));
			SendMessage(hAutoFit, CB_ADDSTRING, 0, (LPARAM)(LPCTSTR) GetString(IDS_AUTOFIT_LAST));
			SendMessage(hAutoFit, CB_ADDSTRING, 0, (LPARAM)(LPCTSTR) GetString(IDS_AUTOFIT_ALL));


			spinThreshold = SetupFloatSpinner(
				hWnd,IDC_UNWRAP_AUTOWELD_THRESHOLD_SPIN,IDC_UNWRAP_AUTOWELD_THRESHOLD,
				0.0f,1.0f,mod->fnRegularMapGetAutoWeldThreshold());		

			ICustButton *iButton = GetICustButton(GetDlgItem(hWnd, IDC_UNWRAP_STARTNEWCLUSTER));
			if (iButton)
			{
				iButton->SetType(CBT_CHECK);
				ReleaseICustButton(iButton);
			}

			mod->fnRegularMapSetPickStartFace(TRUE);
			mod->fnRegularMapUpdateUI();
			break;
			}
		case WM_SYSCOMMAND:
			if ((wParam & 0xfff0) == SC_CONTEXTHELP) 
			{
				MaxSDK::IHelpSystem::GetInstance()->ShowProductHelpForTopic(idh_unwrap_peltmap); 
			}
			return FALSE;
			break;

		case CC_SPINNER_CHANGE:
			{
				mod->fnRegularMapSetAutoWeldThreshold(spinThreshold->GetFVal());

				TSTR mstr = _T("$.modifiers[#unwrap_uvw].unwrap6.RegularMapSetAutoWeldThreshold");
				macroRecorder->FunctionCall(mstr, 1, 0,mr_float,mod->fnRegularMapGetAutoWeldThreshold());
				macroRecorder->EmitScript();

				break;
			}
		case WM_DESTROY:
			mod->fnRegularMapSetHWND(NULL);
			mod->fnRegularMapEnd();
			ReleaseISpinner(spinThreshold);
			spinThreshold = NULL;
			break;
		case WM_CLOSE:
			{
				EndDialog(hWnd,1);
				break;
			}

		case WM_COMMAND:
			switch (LOWORD(wParam)) 
			{
			case IDC_UNWRAP_STARTNEWCLUSTER:
				{
					ICustButton *iButton = GetICustButton(GetDlgItem(hWnd, IDC_UNWRAP_STARTNEWCLUSTER));
					if (iButton)
					{						
						if (mod->fnRegularMapGetPickStartFace())
						{
							iButton->SetCheck(FALSE);
							mod->fnRegularMapSetPickStartFace(FALSE);
						}
						else
						{
							iButton->SetCheck(TRUE);
							mod->fnRegularMapSetPickStartFace(TRUE);

						}
						ReleaseICustButton(iButton);
					}
				break;
				}
			case IDC_LIMIT_COMBO:
				{
					if (HIWORD(wParam)== CBN_SELCHANGE)
					{	
						HWND hMethod = GetDlgItem(hWnd,IDC_LIMIT_COMBO);
						int limit = SendMessage(hMethod, CB_GETCURSEL, 0L, 0);

						TSTR mstr = _T("$.modifiers[#unwrap_uvw].unwrap6.RegularMapSetLimit");
						macroRecorder->FunctionCall(mstr, 1, 0,mr_int,limit);
						macroRecorder->EmitScript();

						if (limit == 0)
							mod->fnRegularMapSetLimit(kRegular);
						else if (limit == 1)
							mod->fnRegularMapSetLimit(kPartial);
						else if (limit == 2)
							mod->fnRegularMapSetLimit(kAbnormal);

					}
				break;
				}
			case IDC_AUTOFIT_COMBO: 				
				{
					if (HIWORD(wParam)== CBN_SELCHANGE)
					{	
						HWND hAutofit = GetDlgItem(hWnd,IDC_AUTOFIT_COMBO);
						int autofit = SendMessage(hAutofit, CB_GETCURSEL, 0L, 0);

						TSTR mstr = _T("$.modifiers[#unwrap_uvw].unwrap6.RegularMapSetAutoFit");
						macroRecorder->FunctionCall(mstr, 1, 0,mr_int,autofit);
						macroRecorder->EmitScript();

						mod->fnRegularMapSetAutoFit(autofit);
					}
					break;
				}
			case IDC_AUTOWELD_CHECK: 				
				{
					BOOL value = GetCheckBox(hWnd,IDC_AUTOWELD_CHECK);

					TSTR mstr = _T("$.modifiers[#unwrap_uvw].unwrap6.RegularMapSetAutoWeld");
					macroRecorder->FunctionCall(mstr, 1, 0,mr_bool,value);
					macroRecorder->EmitScript();


					mod->fnRegularMapSetAutoWeld(value);
					break;
				}
			case IDC_SINGLESTEP_CHECK: 				
				{
					BOOL value = GetCheckBox(hWnd,IDC_SINGLESTEP_CHECK);

					TSTR mstr = _T("$.modifiers[#unwrap_uvw].unwrap6.RegularMapSetSingleStep");
					macroRecorder->FunctionCall(mstr, 1, 0,mr_bool,value);
					macroRecorder->EmitScript();

					mod->fnRegularMapSetSingleStep(value);
					break;
				}
			case IDC_NORMALIZE_CHECK: 				
				{
					BOOL value = GetCheckBox(hWnd,IDC_NORMALIZE_CHECK);

					TSTR mstr = _T("$.modifiers[#unwrap_uvw].unwrap6.RegularMapSetNormalize");
					macroRecorder->FunctionCall(mstr, 1, 0,mr_bool,value);
					macroRecorder->EmitScript();					

					mod->fnRegularMapSetNormalize(value);
					break;
				}

			case IDC_RESETFACES:
				{
					TSTR mstr = _T("$.modifiers[#unwrap_uvw].unwrap6.RegularMapResetFaces");
					macroRecorder->FunctionCall(mstr, 0, 0);
					macroRecorder->EmitScript();


					mod->fnRegularMapResetFaces();
					break;
				}
			case IDC_ADVANCESELECTED:
				{

					TSTR mstr = _T("$.modifiers[#unwrap_uvw].unwrap6.RegularMapAdvanceSelected");
					macroRecorder->FunctionCall(mstr, 1, 0,mr_bool,mod->fnRegularMapGetSingleStep());
					macroRecorder->EmitScript();
					

					mod->fnRegularMapAdvanceSelected(mod->fnRegularMapGetSingleStep());
					mod->fnRegularMapFitView();
					break;
				}
			case IDC_ADVANCEU:
				{
					TSTR mstr = _T("$.modifiers[#unwrap_uvw].unwrap6.RegularMapAdvanceUV");
					macroRecorder->FunctionCall(mstr, 5, 0,
												mr_bool,true,
												mr_bool,false,
												mr_bool,true,
												mr_bool,false,
												mr_bool,mod->fnRegularMapGetSingleStep());
					macroRecorder->EmitScript();

					mod->fnRegularMapAdvanceUV(true,false,true,false,mod->fnRegularMapGetSingleStep());
					mod->fnRegularMapFitView();
					break;
				}
			case IDC_ADVANCEV:
				{
					TSTR mstr = _T("$.modifiers[#unwrap_uvw].unwrap6.RegularMapAdvanceUV");
					macroRecorder->FunctionCall(mstr, 5, 0,
						mr_bool,false,
						mr_bool,true,
						mr_bool,false,
						mr_bool,true,						
						mr_bool,mod->fnRegularMapGetSingleStep());
					mod->fnRegularMapAdvanceUV(false,true,false,true,mod->fnRegularMapGetSingleStep());
					mod->fnRegularMapFitView();
					break;
				}
			case IDC_COMMIT:
				{
					mod->fnRegularMapEnd();
					mod->fnSetMapMode(UNFOLDMAP);
					break;
				}
			}

		default:
			return FALSE;
		}
	return TRUE;
	}
Beispiel #5
0
INT_PTR CALLBACK UnwrapFlattenFloaterDlgProc(
      HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
   {
   UnwrapMod *mod = DLGetWindowLongPtr<UnwrapMod*>(hWnd);
   //POINTS p = MAKEPOINTS(lParam); commented out by sca 10/7/98 -- causing warning since unused.
   static ISpinnerControl *iAngle = NULL;
   static ISpinnerControl *iSpacing = NULL;

   switch (msg) {
      case WM_INITDIALOG:


         mod = (UnwrapMod*)lParam;
         mod->flattenHWND = hWnd;

         DLSetWindowLongPtr(hWnd, lParam);
		 ::SetWindowContextHelpId(hWnd, idh_unwrap_flattenmap);

//create spinners and set value
         iAngle = SetupFloatSpinner(
            hWnd,IDC_UNWRAP_ANGLESPIN,IDC_UNWRAP_ANGLE,
            0.0f,180.0f,mod->flattenAngleThreshold);  
         iSpacing = SetupFloatSpinner(
            hWnd,IDC_UNWRAP_SPACINGSPIN,IDC_UNWRAP_SPACING,
            0.0f,1.0f,mod->flattenSpacing);  

//set align cluster
         CheckDlgButton(hWnd,IDC_NORMALIZE_CHECK,mod->flattenNormalize);
         CheckDlgButton(hWnd,IDC_ROTATE_CHECK,mod->flattenRotate);
         CheckDlgButton(hWnd,IDC_COLLAPSE_CHECK,mod->flattenCollapse);
         mod->SetFlattenDialogPos();

         break;

	  case WM_SYSCOMMAND:
		  if ((wParam & 0xfff0) == SC_CONTEXTHELP) 
		  {
			  MaxSDK::IHelpSystem::GetInstance()->ShowProductHelpForTopic(idh_unwrap_flattenmap); 
		  }
		  return FALSE;
		  break;
      case WM_COMMAND:
         switch (LOWORD(wParam)) {
            case IDC_OK:
               {
               mod->SaveFlattenDialogPos();


               float tempSpacing, tempAngle;
               BOOL tempNormalize, tempRotate, tempCollapse;
               tempSpacing = mod->flattenSpacing;
               tempAngle = mod->flattenAngleThreshold;
               tempNormalize = mod->flattenNormalize;
               tempRotate = mod->flattenRotate;
               tempCollapse = mod->flattenCollapse;


               mod->flattenSpacing = iSpacing->GetFVal()*0.5f;
               mod->flattenAngleThreshold = iAngle->GetFVal();

               mod->flattenNormalize = IsDlgButtonChecked(hWnd,IDC_NORMALIZE_CHECK);
               mod->flattenRotate = IsDlgButtonChecked(hWnd,IDC_ROTATE_CHECK);
               mod->flattenCollapse = IsDlgButtonChecked(hWnd,IDC_COLLAPSE_CHECK); 

               BOOL byMatID = IsDlgButtonChecked(hWnd,IDC_BYMATIDS_CHECK); 

               if (byMatID)
                  mod->fnFlattenMapByMatIDNoParams();
               else mod->fnFlattenMapNoParams();

			    mod->flattenSpacing *= 2.0f;
/*
               mod->flattenSpacing = tempSpacing;
               mod->flattenAngleThreshold = tempAngle;
               mod->flattenNormalize = tempNormalize;
               mod->flattenRotate = tempRotate;
               mod->flattenCollapse= tempCollapse;
*/


               ReleaseISpinner(iAngle);
               iAngle = NULL;
               ReleaseISpinner(iSpacing);
               iSpacing = NULL;

               EndDialog(hWnd,1);
               
               break;
               }
            case IDC_CANCEL:
               {
            
               mod->SaveFlattenDialogPos();
               ReleaseISpinner(iAngle);
               iAngle = NULL;
               ReleaseISpinner(iSpacing);
               iSpacing = NULL;

               EndDialog(hWnd,0);

               break;
               }
            case IDC_DEFAULT:
               {
//get bias
               mod->flattenSpacing = iSpacing->GetFVal();
               mod->flattenAngleThreshold = iAngle->GetFVal();

//get align
               mod->flattenNormalize = IsDlgButtonChecked(hWnd,IDC_NORMALIZE_CHECK);
               mod->flattenRotate = IsDlgButtonChecked(hWnd,IDC_ROTATE_CHECK);
               mod->flattenCollapse = IsDlgButtonChecked(hWnd,IDC_COLLAPSE_CHECK); 
               
//set as defaults
               break;
               }

            }
         break;

      default:
         return FALSE;
      }
   return TRUE;
   }