INT_PTR PFOperatorInstanceShapeDlgProc::DlgProc( TimeValue t, IParamMap2 *map, HWND hWnd, UINT msg,
											   WPARAM wParam, LPARAM lParam )
{
	ICustButton *iBut;
	PFOperatorInstanceShape *op;
	INode* obj;
	TSTR name;
	BOOL separateAny, animatedShape, addRandomOffset, setScale;

	switch ( msg )
	{
	case WM_INITDIALOG:
		// Set ICustButton properties
		iBut = GetICustButton(GetDlgItem(hWnd, IDC_PICK));
		iBut->SetType(CBT_CHECK);
		iBut->SetHighlightColor(GREEN_WASH);
		ReleaseICustButton(iBut);
		// Send the message to notify the initialization of dialog
		map->GetParamBlock()->NotifyDependents( FOREVER, (PartID)map, kInstanceShape_RefMsg_InitDlg );
		break;
	case WM_DESTROY:
		break;
	case WM_COMMAND:
		switch ( LOWORD( wParam ) )
		{
		case IDC_PICK:
			map->GetParamBlock()->NotifyDependents( FOREVER, PART_OBJ, kInstanceShape_RefMsg_PickObj );
			break;
		case IDC_UPDATESHAPE:
			map->GetParamBlock()->NotifyDependents( FOREVER, PART_OBJ, kInstanceShape_RefMsg_UpdateShape );
			break;
		case IDC_NEW:
			map->GetParamBlock()->NotifyDependents( FOREVER, PART_OBJ, kInstanceShape_RefMsg_NewRand );
			break;
		case kInstanceShape_message_name:
			op = reinterpret_cast <PFOperatorInstanceShape *> (lParam);
			obj = (op) ? const_cast <INode*> (op->object()) : NULL;
			name = (obj) ? obj->GetName() : GetString(IDS_NONE);
			UpdateObjectNameDlg(hWnd, name);
			break;
		case kInstanceShape_message_type:
			op = reinterpret_cast <PFOperatorInstanceShape *> (lParam);
			separateAny = map->GetParamBlock()->GetInt(kInstanceShape_sepGroup, t) ||
							map->GetParamBlock()->GetInt(kInstanceShape_sepHierarchy, t) ||
							map->GetParamBlock()->GetInt(kInstanceShape_sepElements, t);
			UpdateParticleShapeDlg(hWnd, op->meshData());
			UpdateRandomShapeDlg(hWnd, separateAny);
			break;
		case kInstanceShape_message_enterPick:
			iBut = GetICustButton(GetDlgItem(hWnd, IDC_PICK));
			iBut->SetCheck(TRUE);
			ReleaseICustButton(iBut);
			break;
		case kInstanceShape_message_exitPick:
			iBut = GetICustButton(GetDlgItem(hWnd, IDC_PICK));
			iBut->SetCheck(FALSE);
			ReleaseICustButton(iBut);
			break;
		case kInstanceShape_message_animate:
			animatedShape = map->GetParamBlock()->GetInt(kInstanceShape_animatedShape, t);
			addRandomOffset = map->GetParamBlock()->GetInt(kInstanceShape_syncRandom, t);
			UpdateAnimatedSahpeDlg( hWnd, animatedShape, addRandomOffset );
			break;
		case kInstanceShape_message_setScale:
			setScale = map->GetParamBlock()->GetInt(kInstanceShape_setScale, t);
			UpdateScaleDlg( hWnd, setScale);
			break;
		}
		break;
	}
	return FALSE;
}
Пример #2
0
INT_PTR BerconTileDlgProc::DlgProc(TimeValue t,IParamMap2 *map,HWND hWnd,UINT msg,WPARAM wParam,LPARAM lParam)	{	
	switch (msg) {
		case WM_INITDIALOG:	{			
			// Lock buttons			
			ICustButton* custButton = GetICustButton(GetDlgItem(hWnd, IDC_LOCKEDGE));
			custButton->SetText(_T("L"));
			ReleaseICustButton(custButton);
			custButton = GetICustButton(GetDlgItem(hWnd, IDC_LOCK));
			custButton->SetText(_T("L"));
			ReleaseICustButton(custButton); 

			// Style
			HWND hwndMap = GetDlgItem(hWnd, IDC_TYPE);  
			SendMessage(hwndMap, CB_ADDSTRING, 0, (LPARAM)GetString(IDS_TILETYPE_11)); // Custom
			SendMessage(hwndMap, CB_ADDSTRING, 0, (LPARAM)GetString(IDS_TILETYPE_10)); // Herringbone
			SendMessage(hwndMap, CB_ADDSTRING, 0, (LPARAM)GetString(IDS_TILETYPE_9)); // Stack
			SendMessage(hwndMap, CB_ADDSTRING, 0, (LPARAM)GetString(IDS_TILETYPE_0)); // Stretcher			
			SendMessage(hwndMap, CB_ADDSTRING, 0, (LPARAM)GetString(IDS_TILETYPE_1)); // Flemish Stretcher
			SendMessage(hwndMap, CB_ADDSTRING, 0, (LPARAM)GetString(IDS_TILETYPE_2)); // Common
			SendMessage(hwndMap, CB_ADDSTRING, 0, (LPARAM)GetString(IDS_TILETYPE_3)); // Flemish
			SendMessage(hwndMap, CB_ADDSTRING, 0, (LPARAM)GetString(IDS_TILETYPE_4)); // Monk
			SendMessage(hwndMap, CB_ADDSTRING, 0, (LPARAM)GetString(IDS_TILETYPE_5)); // Flemish Garden Wall
			SendMessage(hwndMap, CB_ADDSTRING, 0, (LPARAM)GetString(IDS_TILETYPE_6)); // English
			SendMessage(hwndMap, CB_ADDSTRING, 0, (LPARAM)GetString(IDS_TILETYPE_7)); // English Cross
			SendMessage(hwndMap, CB_ADDSTRING, 0, (LPARAM)GetString(IDS_TILETYPE_8)); // Double

			// Soften
			hwndMap = GetDlgItem(hWnd, IDC_SOFTEN);  
			SendMessage(hwndMap, CB_ADDSTRING, 0, (LPARAM)GetString(IDS_TILESOFTEN_0));
			SendMessage(hwndMap, CB_ADDSTRING, 0, (LPARAM)GetString(IDS_TILESOFTEN_1));
			SendMessage(hwndMap, CB_ADDSTRING, 0, (LPARAM)GetString(IDS_TILESOFTEN_2));
			SendMessage(hwndMap, CB_ADDSTRING, 0, (LPARAM)GetString(IDS_TILESOFTEN_3));

			// UV rotation
			hwndMap = GetDlgItem(hWnd, IDC_ROTUV);  
			SendMessage(hwndMap, CB_ADDSTRING, 0, (LPARAM)GetString(IDS_TILEROT_0));
			SendMessage(hwndMap, CB_ADDSTRING, 0, (LPARAM)GetString(IDS_TILEROT_1));
			SendMessage(hwndMap, CB_ADDSTRING, 0, (LPARAM)GetString(IDS_TILEROT_2));
			SendMessage(hwndMap, CB_ADDSTRING, 0, (LPARAM)GetString(IDS_TILEROT_3));	

			// Auto scale
			hwndMap = GetDlgItem(hWnd, IDC_AUTO);  
			SendMessage(hwndMap, CB_ADDSTRING, 0, (LPARAM)GetString(IDS_TILEUVW_0));
			SendMessage(hwndMap, CB_ADDSTRING, 0, (LPARAM)GetString(IDS_TILEUVW_1));
			SendMessage(hwndMap, CB_ADDSTRING, 0, (LPARAM)GetString(IDS_TILEUVW_2));
			SendMessage(hwndMap, CB_ADDSTRING, 0, (LPARAM)GetString(IDS_TILEUVW_3));
			SendMessage(hwndMap, CB_ADDSTRING, 0, (LPARAM)GetString(IDS_TILEUVW_4));
			SendMessage(hwndMap, CB_ADDSTRING, 0, (LPARAM)GetString(IDS_TILEUVW_5));

			// Set correct dropdown value			
			int curIndex;
			map->GetParamBlock()->GetValue(tile_style, t, curIndex, FOREVER);
			SendMessage(GetDlgItem(hWnd, IDC_TYPE), CB_SETCURSEL, (WPARAM)curIndex, 0);
			map->GetParamBlock()->GetValue(soften, t, curIndex, FOREVER);
			SendMessage(GetDlgItem(hWnd, IDC_SOFTEN), CB_SETCURSEL, (WPARAM)curIndex, 0);
			map->GetParamBlock()->GetValue(pb_rotUV, t, curIndex, FOREVER);
			SendMessage(GetDlgItem(hWnd, IDC_ROTUV), CB_SETCURSEL, (WPARAM)curIndex, 0);
			map->GetParamBlock()->GetValue(pb_auto, t, curIndex, FOREVER);
			SendMessage(GetDlgItem(hWnd, IDC_AUTO), CB_SETCURSEL, (WPARAM)curIndex, 0);
			break;
		}		
		case WM_SHOWWINDOW:	{					
			// Set correct dropdown value
			int curIndex;
			map->GetParamBlock()->GetValue(tile_style, t, curIndex, FOREVER);
			SendMessage(GetDlgItem(hWnd, IDC_TYPE), CB_SETCURSEL, (WPARAM)curIndex, 0);
			map->GetParamBlock()->GetValue(soften, t, curIndex, FOREVER);
			SendMessage(GetDlgItem(hWnd, IDC_SOFTEN), CB_SETCURSEL, (WPARAM)curIndex, 0);
			map->GetParamBlock()->GetValue(pb_rotUV, t, curIndex, FOREVER);
			SendMessage(GetDlgItem(hWnd, IDC_ROTUV), CB_SETCURSEL, (WPARAM)curIndex, 0);
			map->GetParamBlock()->GetValue(pb_auto, t, curIndex, FOREVER);
			SendMessage(GetDlgItem(hWnd, IDC_AUTO), CB_SETCURSEL, (WPARAM)curIndex, 0);
			break;
		}
		default: return FALSE;
	}
	return TRUE;
}
Пример #3
0
void PickTarget::ExitMode(IObjParam *ip)
   {
   ICustButton *iBut = GetICustButton(GetDlgItem(mo->hParams1,IDC_PICK_MORPHTARG));
   iBut->SetCheck(FALSE);
   ReleaseICustButton(iBut);
   }
Пример #4
0
void EditPolyPaintDeformDlgProc::SetEnables (HWND hWnd) {
	PaintModeID paintMode = mpEPoly->GetPaintMode();

	bool isModelingMode = (mpEPoly->getParamBlock()->GetInt(epm_animation_mode) == 0);
	BOOL isPaintPushPull =	(paintMode==PAINTMODE_PAINTPUSHPULL? TRUE:FALSE);
	BOOL isPaintRelax =		(paintMode==PAINTMODE_PAINTRELAX? TRUE:FALSE);
	BOOL isErasing  =		(paintMode==PAINTMODE_ERASEDEFORM? TRUE:FALSE);
	BOOL isActive =			(mpEPoly->IsPaintDataActive(PAINTMODE_DEFORM)? TRUE:FALSE);

	ICustButton* but = GetICustButton (GetDlgItem (hWnd, IDC_PAINTDEFORM_PUSHPULL));
	but->Enable (isModelingMode);
	but->SetCheck( isPaintPushPull );
	ReleaseICustButton (but);

	but = GetICustButton (GetDlgItem (hWnd, IDC_PAINTDEFORM_RELAX));
	but->Enable (isModelingMode);
	but->SetCheck( isPaintRelax );
	ReleaseICustButton (but);

	but = GetICustButton (GetDlgItem (hWnd, IDC_PAINTDEFORM_REVERT));
	but->Enable( isActive && isModelingMode );
	but->SetCheck( isErasing );
	ReleaseICustButton (but);

	ISpinnerControl *spin = GetISpinner (GetDlgItem (hWnd, IDC_PAINTDEFORM_VALUE_SPIN));
	spin->Enable ((!isPaintRelax) && (!isErasing) && isModelingMode);
	ReleaseISpinner (spin);
	BOOL enablePushPull = (((!isPaintRelax) && (!isErasing) && isModelingMode)? TRUE:FALSE);
	HWND hDlgItem = GetDlgItem (hWnd, IDC_PAINTDEFORM_VALUE_LABEL);
	EnableWindow( hDlgItem, enablePushPull );
	hDlgItem = GetDlgItem (hWnd, IDC_PAINTAXIS_BORDER);
	EnableWindow( hDlgItem, enablePushPull );
	hDlgItem = GetDlgItem (hWnd, IDC_PAINTAXIS_ORIGNORMS);
	EnableWindow( hDlgItem, enablePushPull );
	hDlgItem = GetDlgItem (hWnd, IDC_PAINTAXIS_DEFORMEDNORMS);
	EnableWindow( hDlgItem, enablePushPull );
	hDlgItem = GetDlgItem (hWnd, IDC_PAINTAXIS_XFORM);
	EnableWindow( hDlgItem, enablePushPull );
	hDlgItem = GetDlgItem (hWnd, IDC_PAINTAXIS_XFORM_X);
	EnableWindow( hDlgItem, enablePushPull );
	hDlgItem = GetDlgItem (hWnd, IDC_PAINTAXIS_XFORM_Y);
	EnableWindow( hDlgItem, enablePushPull );
	hDlgItem = GetDlgItem (hWnd, IDC_PAINTAXIS_XFORM_Z);
	EnableWindow( hDlgItem, enablePushPull );

	EnableWindow (GetDlgItem (hWnd, IDC_PAINTDEFORM_SIZE_LABEL), isModelingMode);
	EnableWindow (GetDlgItem (hWnd, IDC_PAINTDEFORM_STRENGTH_LABEL), isModelingMode);

	spin = GetISpinner (GetDlgItem (hWnd, IDC_PAINTDEFORM_SIZE_SPIN));
	spin->Enable (isModelingMode);
	ReleaseISpinner (spin);

	spin = GetISpinner (GetDlgItem (hWnd, IDC_PAINTDEFORM_STRENGTH_SPIN));
	spin->Enable (isModelingMode);
	ReleaseISpinner (spin);

	but = GetICustButton (GetDlgItem (hWnd, IDC_PAINTDEFORM_OPTIONS));
	but->Enable (isModelingMode);
	ReleaseICustButton (but);

	but = GetICustButton (GetDlgItem (hWnd, IDC_PAINTDEFORM_APPLY));
	but->Enable( isActive && isModelingMode );
	ReleaseICustButton (but);

	but = GetICustButton (GetDlgItem (hWnd, IDC_PAINTDEFORM_CANCEL));
	but->Enable( isActive && isModelingMode );
	ReleaseICustButton (but);
}
Пример #5
0
void EditPatchMod::RefreshSelType() 
{
	if (!hSelectPanel)
		return;
	if (hOpsPanel)
	{
		// Set up or remove the surface properties rollup if needed
		if (hSurfPanel)
		{
			rsSurf = IsRollupPanelOpen(hSurfPanel);
			ip->DeleteRollupPage(hSurfPanel);
			hSurfPanel = NULL;
		}
		if (hTilePanel)
		{
			rsTile = IsRollupPanelOpen(hTilePanel);
			ip->DeleteRollupPage(hTilePanel);
			hTilePanel = NULL;
		}
		if (hEdgePanel)
		{
			rsEdge = IsRollupPanelOpen(hEdgePanel);
			ip->DeleteRollupPage(hEdgePanel);
			hEdgePanel = NULL;
		}
		/* watje 3 - 18 - 99
		if (selLevel == EP_OBJECT)
		{
		hSurfPanel = ip->AddRollupPage(hInstance, MAKEINTRESOURCE(IDD_EDPATCH_SURF_OBJ),
		PatchObjSurfDlgProc, GetString(IDS_TH_SURFACEPROPERTIES), (LPARAM) this, rsSurf ? 0 : APPENDROLL_CLOSED);
		}
		else
		*/
		if (selLevel == EP_PATCH)
		{
			hSurfPanel = ip->AddRollupPage(hInstance, MAKEINTRESOURCE(IDD_EDPATCH_SURF),
				PatchSurfDlgProc, GetString(IDS_TH_SURFACEPROPERTIES), (LPARAM) this, rsSurf ? 0 : APPENDROLL_CLOSED);
		}
		if (selLevel == EP_TILE)
		{
			hTilePanel = ip->AddRollupPage(hInstance, MAKEINTRESOURCE(IDD_EDPATCH_TILE),
				PatchTileDlgProc, "Tile Properties", (LPARAM) this, rsTile ? 0 : APPENDROLL_CLOSED);
		}
		if (selLevel == EP_EDGE)
		{
			hEdgePanel = ip->AddRollupPage(hInstance, MAKEINTRESOURCE(IDD_EDPATCH_EDGE),
				PatchEdgeDlgProc, "Edge Properties", (LPARAM) this, rsEdge ? 0 : APPENDROLL_CLOSED);
		}
		SetSurfDlgEnables();
		SetTileDlgEnables();
		SetEdgeDlgEnables();
	}
	
	ICustToolbar *iToolbar = GetICustToolbar(GetDlgItem(hSelectPanel, IDC_SELTYPE));
	ICustButton *but;
	for (int i = 1; i < 5; i++)
	{
		but = iToolbar->GetICustButton(butIDs[i]);
		but->SetCheck(GetSubobjectLevel() == i);
		ReleaseICustButton(but);
	}
	ReleaseICustToolbar(iToolbar);
	SetSelDlgEnables();
	SetOpsDlgEnables();
	UpdateSelectDisplay();
	PatchSelChanged();
}
Пример #6
0
void PickControlNode::ExitMode(IObjParam *ip)
   {
   ICustButton *iBut = GetICustButton(GetDlgItem(mod->hParams,IDC_PICKBB));
   if (iBut) iBut->SetCheck(FALSE);
   ReleaseICustButton(iBut);
   }
Пример #7
0
INT_PTR ParticleMesherParamsMapDlgProc::DlgProc(
      TimeValue t,IParamMap2 *map,HWND hWnd,UINT msg,WPARAM wParam,LPARAM lParam)
         
   {


   switch (msg) {
      case WM_INITDIALOG:
         {
         mod->hParams = hWnd;

         ICustButton *iBut = GetICustButton(GetDlgItem(hWnd,IDC_PICKBB));
         iBut->SetType(CBT_CHECK);
         iBut->SetHighlightColor(GREEN_WASH);

         if (mod->ip)
            {
            if (mod->ip->GetCommandPanelTaskMode() == TASK_MODE_CREATE)
               {
               iBut->Enable(FALSE);
               }

            }

         ReleaseICustButton(iBut);
         mod->UpdateUI();


         break;
         }
      case WM_COMMAND:
         {
         switch (LOWORD(wParam)) 
            {
            case IDC_ADDPF_EVENT_BUTTON:
               mod->PickPFEvents(hWnd);
               break;
            case IDC_BBOX:
               {
               mod->UpdateUI();
               break;
               }
            case IDC_UPDATE:
               {
               mod->lastTime = -999999;
               mod->ivalid.SetEmpty();
               mod->NotifyDependents(FOREVER,PART_ALL,REFMSG_CHANGE);
               break;
               }
            case  IDC_PICKBB:
               {
               if (mod->ip->GetCommandMode() == (CommandMode *) &thePickMode) {
                  mod->ip->SetStdCommandMode(CID_OBJMOVE);
                  }
               else                 
                  {
                  thePickMode.mod  = mod;             
                  mod->ip->SetPickMode(&thePickMode);
                  }

               }

            }
         break;
         }



      }
   return FALSE;
   }
Пример #8
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;
	}
Пример #10
0
void UnwrapMod::RelaxThreadOp(int operation, HWND hWnd)
{
	ISpinnerControl *iAmount = NULL;
	ISpinnerControl *iStretch = NULL;

	//this is a structure that holds all our info we are passing to the thread


	iAmount = GetISpinner(GetDlgItem(hWnd,IDC_RELAX_AMOUNTSPIN));
	iStretch = GetISpinner(GetDlgItem(hWnd,IDC_RELAX_STRETCHSPIN));


	mRelaxThreadData.mod = this;
	HWND hType = GetDlgItem(hWnd,IDC_RELAXTYPE_COMBO);
	mRelaxThreadData.mType = SendMessage(hType, CB_GETCURSEL, 0L, 0);
	if (iAmount)
		mRelaxThreadData.mAmount = iAmount->GetFVal();
	else
		mRelaxThreadData.mAmount = 0.1f;

	mRelaxThreadData.mBoundary = IsDlgButtonChecked(hWnd,IDC_BOUNDARY_CHECK);
	if (iStretch)
		mRelaxThreadData.mStretch = iStretch->GetFVal();
	else
		mRelaxThreadData.mStretch = 0.0f;
	mRelaxThreadData.mCorner = IsDlgButtonChecked(hWnd,IDC_CORNERS_CHECK);

	mRelaxThreadData.mIterations = 1000000;

	ReleaseISpinner(iAmount);
	ReleaseISpinner(iStretch);


	if (operation == KThreadStart)
	{				
		unsigned int threadID;
		ICustButton *iButton = GetICustButton(GetDlgItem(relaxHWND, IDC_RUN_BUTTON));
		if (iButton )
		{
			iButton->SetCheck(TRUE);
			iButton->SetText(GetString(IDS_SPLINEMAP_ENDRELAX));
		}
		if (iButton)
			ReleaseICustButton(iButton);

		mRelaxThreadHandle = (HANDLE)_beginthreadex( NULL, 0, &CallRelaxThread, (void *) &mRelaxThreadData, 0, &threadID );


	}
	else if (operation == KThreadReStart)
	{
		//only restart if we have a current thread running
		if (mRelaxThreadHandle && mRelaxThreadData.mStarted)
		{

			ICustButton *iButton = GetICustButton(GetDlgItem(relaxHWND, IDC_RUN_BUTTON));
			if (iButton )
			{
				iButton->SetCheck(FALSE);
			}


			for (int ldID = 0; ldID < mMeshTopoData.Count(); ldID++)
			{
				mMeshTopoData[ldID]->SetUserCancel(TRUE);
			}

			WaitForSingleObject( mRelaxThreadHandle, INFINITE );

			CloseHandle( mRelaxThreadHandle );

			mRelaxThreadHandle = NULL;


			for (int ldID = 0; ldID < mMeshTopoData.Count(); ldID++)
			{
				mMeshTopoData[ldID]->SetUserCancel(FALSE);
			}		

			if (iButton )
			{
				iButton->SetCheck(TRUE);
			}

			if (iButton)
				ReleaseICustButton(iButton);

			unsigned int threadID;
			mRelaxThreadHandle = (HANDLE)_beginthreadex( NULL, 0, &CallRelaxThread, (void *) &mRelaxThreadData, 0, &threadID );
		}
	}
	else if (operation == KThreadEnd)
	{

		ICustButton *iButton = GetICustButton(GetDlgItem(relaxHWND, IDC_RUN_BUTTON));
		if (iButton)
		{
			iButton->SetText(GetString(IDS_SPLINEMAP_STARTRELAX));
			iButton->SetCheck(FALSE);
			ReleaseICustButton(iButton);
		}

		for (int ldID = 0; ldID < mMeshTopoData.Count(); ldID++)
		{
			mMeshTopoData[ldID]->SetUserCancel(TRUE);
		}

		WaitForSingleObject( mRelaxThreadHandle, INFINITE );

		CloseHandle( mRelaxThreadHandle );

		mRelaxThreadHandle = NULL;

		for (int ldID = 0; ldID < mMeshTopoData.Count(); ldID++)
		{
			mMeshTopoData[ldID]->SetUserCancel(FALSE);
		}



	}


}
Пример #11
0
unsigned __stdcall  CallRelaxThread(void *data)
{
	MaxSDK::Util::UseLanguagePackLocale();

	RelaxThreadData *threadData = (RelaxThreadData *) data;

	threadData->mLocalData.SetCount( threadData->mod->GetMeshTopoDataCount());
	for (int i = 0; i <  threadData->mod->GetMeshTopoDataCount(); i++)
		threadData->mLocalData[i] =  threadData->mod->GetMeshTopoData(i);

	threadData->mStarted = TRUE;

	DisableAccelerators();  



	BOOL rigSelected = FALSE;
	MeshTopoData *peltLD = threadData->mod->peltData.mBaseMeshTopoDataCurrent;
	if (threadData->mod->peltData.peltDialog.hWnd)
	{		
		if (peltLD)
		{
			for (int i = 0; i < threadData->mod->peltData.rigPoints.Count(); i++)
			{
				int index = threadData->mod->peltData.rigPoints[i].lookupIndex;
				if (peltLD->GetTVVertSelected(index))
					rigSelected = TRUE;
			}
		}
	}

	GetCOREInterface()->DisableSceneRedraw();
	//if we are not instanced we can just start up unwrap relax and go
	if ((threadData->mod->GetMeshTopoDataCount() == 1) && !rigSelected)
	{
		if (threadData->mType == 0)
			threadData->mod->fnRelaxByFaceAngle(threadData->mIterations,threadData->mStretch,threadData->mAmount,threadData->mBoundary,NULL);
		else if (threadData->mType == 1)
			threadData->mod->fnRelaxByEdgeAngle(threadData->mIterations,threadData->mStretch,threadData->mAmount,threadData->mBoundary,NULL);
		else if (threadData->mType == 2)
			threadData->mod->RelaxVerts2(threadData->mAmount,threadData->mIterations,threadData->mBoundary,threadData->mCorner,FALSE);
	}
	//if we have multiple instance it gets more complicated
	//since only the first relax instance will ever run
	else
	{
		BOOL done = FALSE;
		threadData->mIterations = 5;
		for (int ldID = 0; ldID < threadData->mLocalData.Count(); ldID++)
		{
			threadData->mLocalData[ldID]->SetUserCancel(FALSE);
		}
		while(!done)
		{
			for (int ldID = 0; ldID < threadData->mLocalData.Count(); ldID++)
			{
				if (threadData->mLocalData[ldID]->GetUserCancel())
					done = TRUE;
			}
			if (threadData->mType == 0)
				threadData->mod->fnRelaxByFaceAngle(threadData->mIterations,threadData->mStretch,threadData->mAmount,threadData->mBoundary,NULL);
			else if (threadData->mType == 1)
				threadData->mod->fnRelaxByEdgeAngle(threadData->mIterations,threadData->mStretch,threadData->mAmount,threadData->mBoundary,NULL);
			else if (threadData->mType == 2)
				threadData->mod->RelaxVerts2(threadData->mAmount,threadData->mIterations,threadData->mBoundary,threadData->mCorner,FALSE);

			if (rigSelected)
				threadData->mod->peltData.RelaxRig(threadData->mIterations,threadData->mAmount,threadData->mBoundary,threadData->mod);
		}
	}



	for (int ldID = 0; ldID < threadData->mod->GetMeshTopoDataCount(); ldID++)
	{
		threadData->mod->GetMeshTopoData(ldID)->SetUserCancel(FALSE);
	}


	GetCOREInterface()->EnableSceneRedraw();
	EnableAccelerators();   
	threadData->mStarted = FALSE;

	ICustButton *iButton = GetICustButton(GetDlgItem(threadData->mod->relaxHWND, IDC_RUN_BUTTON));
	if (iButton)
	{
		if (iButton->IsChecked())
		{
			iButton->SetText(GetString(IDS_SPLINEMAP_STARTRELAX));
			iButton->SetCheck(FALSE);
		}
		ReleaseICustButton(iButton);
	}

	_endthreadex(0);


	return 0;
}
void PFOperatorMaterialDynamicDlgProc::UpdateDlg( HWND hWnd, IParamBlock2* pblock, TimeValue t)
{
	int assign = pblock->GetInt(kMaterialDynamic_assignMaterial, t);
	int assignID  = pblock->GetInt(kMaterialDynamic_assignID, t);
	int type = pblock->GetInt(kMaterialDynamic_type, t);
	int randAge = pblock->GetInt(kMaterialDynamic_randomizeAge, t);
	int randOffset = pblock->GetInt(kMaterialDynamic_randomizeRotoscoping, t);

	ICustButton* but = GetICustButton(GetDlgItem(hWnd, IDC_MATERIAL));
	but->Enable( assign != 0);
	ReleaseICustButton(but);

	BOOL enable = ((assign != 0) && (assignID == 0)) 
				|| ((assignID != 0) && (type != kMaterialDynamic_type_particleID));
	EnableWindow( GetDlgItem( hWnd, IDC_TEXT_MTLIDOFFSET), enable);
	ISpinnerControl* spin = GetISpinner(GetDlgItem(hWnd, IDC_MTLIDOFFSETSPIN));
	spin->Enable( enable );
	ReleaseISpinner( spin );

	bool enableAssign = (assignID != 0);
	EnableWindow( GetDlgItem( hWnd, IDC_SHOWINVIEWPORT), enableAssign);
	EnableWindow( GetDlgItem( hWnd, IDC_ANIMATEDFRAME), enableAssign);
	EnableWindow( GetDlgItem( hWnd, IDC_TYPE_PARTID), enableAssign);
	EnableWindow( GetDlgItem( hWnd, IDC_SUBMTLSFRAME), enableAssign);
	EnableWindow( GetDlgItem( hWnd, IDC_TYPE_MTLID), enableAssign);
	EnableWindow( GetDlgItem( hWnd, IDC_TYPE_CYCLE), enableAssign);
	EnableWindow( GetDlgItem( hWnd, IDC_TYPE_RANDOM), enableAssign);

	bool enableAnimated = (enableAssign && (type == kMaterialDynamic_type_particleID));
	bool enableMaxOffset = (enableAnimated && (randAge != 0));
	EnableWindow( GetDlgItem( hWnd, IDC_RESETAGE), enableAnimated);
	EnableWindow( GetDlgItem( hWnd, IDC_RANDOMIZEAGE), enableAnimated);
	EnableWindow( GetDlgItem( hWnd, IDC_MAXOFFSETTEXT), enableMaxOffset);
	spin = GetISpinner(GetDlgItem(hWnd, IDC_MAXOFFSETSPIN));
	spin->Enable( enableMaxOffset );
	ReleaseISpinner( spin );

	bool enableMtlID = (enableAssign && (type == kMaterialDynamic_type_materialID));
	spin = GetISpinner(GetDlgItem(hWnd, IDC_MATERIALIDSPIN));
	spin->Enable( enableMtlID );
	ReleaseISpinner( spin );
	
	bool enableRoto = (enableAssign && (type >= kMaterialDynamic_type_cycle));
	EnableWindow( GetDlgItem( hWnd, IDC_NUMSUBSTEXT), enableRoto);
	EnableWindow( GetDlgItem( hWnd, IDC_RATETEXT), enableRoto);
	spin = GetISpinner(GetDlgItem(hWnd, IDC_NUMSUBSSPIN));
	spin->Enable( enableRoto );
	ReleaseISpinner( spin );
	spin = GetISpinner(GetDlgItem(hWnd, IDC_RATESPIN));
	spin->Enable( enableRoto );
	ReleaseISpinner( spin );
	EnableWindow( GetDlgItem( hWnd, IDC_LOOP), enableAssign && (type == kMaterialDynamic_type_cycle));

	bool enableSync = (enableAssign && ((type == kMaterialDynamic_type_materialID)
									|| ( type == kMaterialDynamic_type_cycle)) );
	EnableWindow( GetDlgItem( hWnd, IDC_SYNCBYTEXT), enableSync);
	EnableWindow( GetDlgItem( hWnd, IDC_SYNC), enableSync);
	EnableWindow( GetDlgItem( hWnd, IDC_SYNCRANDOM), enableSync);
	spin = GetISpinner(GetDlgItem(hWnd, IDC_SYNCOFFSETSPIN));
	spin->Enable( enableSync && (randOffset != 0) );
	ReleaseISpinner( spin );
}
Пример #13
0
RefResult PFOperatorMaterialStatic::NotifyRefChanged(Interval changeInt, RefTargetHandle hTarget,
													 PartID& partID, RefMessage message)
{
	IParamMap2* map;
	TSTR dynamicNameSuffix;

	if ( hTarget == pblock() ) {
		switch (message)
		{
		case REFMSG_CHANGE:
			{
				ParamID lastUpdateID = pblock()->LastNotifyParamID();
				if (lastUpdateID == kMaterialStatic_material) {
					if (updateFromMXSMtl()) {
						NotifyDependents(FOREVER, PART_MTL, kPFMSG_UpdateMaterial, NOTIFY_ALL, TRUE);
						NotifyDependents(FOREVER, 0, kPFMSG_DynamicNameChange, NOTIFY_ALL, TRUE);
					}
					UpdatePViewUI(lastUpdateID);
					return REF_STOP;
				}
				if (!(theHold.Holding() || theHold.RestoreOrRedoing())) return REF_STOP;
			switch ( lastUpdateID )
				{
				case kMaterialStatic_assignMaterial:
					RefreshUI(kMaterialStatic_message_assignMaterial);
					NotifyDependents(FOREVER, PART_MTL, kPFMSG_UpdateMaterial, NOTIFY_ALL, TRUE);
					NotifyDependents(FOREVER, 0, kPFMSG_DynamicNameChange, NOTIFY_ALL, TRUE);
					break;
				case kMaterialStatic_assignID:
					RefreshUI(kMaterialStatic_message_assignID);
					break;
				case kMaterialStatic_type:
					RefreshUI(kMaterialStatic_message_type);
					break;
				case kMaterialStatic_rateType:
					RefreshUI(kMaterialStatic_message_rateType);
					break;
				}
				UpdatePViewUI(lastUpdateID);
				break;
			}
		case REFMSG_NODE_WSCACHE_UPDATED:
			updateFromRealMtl();
			break;
		// Initialization of Dialog
		case kMaterialStatic_RefMsg_InitDlg:
			// Set ICustButton properties for MaterialStatic DAD button
			map = (IParamMap2*)partID;
			if (map != NULL) {
				HWND hWnd = map->GetHWnd();
				if (hWnd) {
					ICustButton *iBut = GetICustButton(GetDlgItem(hWnd, IDC_MATERIAL));
					iBut->SetDADMgr(_dadMgr());
					ReleaseICustButton(iBut);
				}
			}
			// Refresh UI
			RefreshUI(kMaterialStatic_message_assignMaterial);
			RefreshUI(kMaterialStatic_message_assignID);
			return REF_STOP;
		// New Random Seed
		case kMaterialStatic_RefMsg_NewRand:
			theHold.Begin();
			NewRand();
			theHold.Accept(GetString(IDS_NEWRANDOMSEED));
			return REF_STOP;
		}
	}
	if ( hTarget == const_cast <Mtl*> (material()) ) {
		switch (message)
		{
		case REFMSG_CHANGE:
			return REF_STOP;
//			if (ignoreRefMsgNotify()) return REF_STOP;
//			if (!(theHold.Holding() || theHold.RestoreOrRedoing())) return REF_STOP;
			break;
		case REFMSG_NODE_NAMECHANGE:
			if (HasDynamicName(dynamicNameSuffix)) {
				if (lastDynamicName() != dynamicNameSuffix) {
					_lastDynamicName() = dynamicNameSuffix;
					NotifyDependents(FOREVER, 0, kPFMSG_DynamicNameChange, NOTIFY_ALL, TRUE);
					UpdatePViewUI(kMaterialStatic_material);
				}
			}
			return REF_STOP;
		case REFMSG_TARGET_DELETED:
			_material() = NULL;
			if (pblock() != NULL)
				pblock()->SetValue(kMaterialStatic_material, 0, NULL);
			if (theHold.Holding()) {
				if (HasDynamicName(dynamicNameSuffix)) {
					if (lastDynamicName() != dynamicNameSuffix) {
						_lastDynamicName() = dynamicNameSuffix;
						NotifyDependents(FOREVER, 0, kPFMSG_DynamicNameChange, NOTIFY_ALL, TRUE);
						UpdatePViewUI(kMaterialStatic_material);
					}
				}
			}
			break;
		}
	}

	return REF_SUCCEED;
}
void TestSpawnOnCollisionDlgProc::UpdateDeflectorsDlg( HWND hWnd, int numDeflectors )
{
	ICustButton* button = GetICustButton( GetDlgItem( hWnd, IDC_REMOVE_COLLISION ) );
	button->Enable( numDeflectors > 0 );
	ReleaseICustButton( button );
}
	void OrientConstRotation::RedrawListbox(TimeValue t,  int sel)
	{
		if (hWnd == NULL) return;
		if (!ip || editCont != this) return;
		int isWorldinListboxFlag = 0;
		if(!orientCD.NumParamMaps()) return;
		int selection = SendDlgItemMessage(hWnd, IDC_ORIENT_TARG_LIST, LB_GETCURSEL, 0, 0);
//		IParamBlock2* pb = orientCD.GetParamMap(0)->GetParamBlock();
		SendDlgItemMessage(hWnd, IDC_ORIENT_TARG_LIST, LB_RESETCONTENT, 0, 0);
		int ts = 64;  // appears smaller than necessary since for a large no of targets the vertical scroll bar needs space
		SendDlgItemMessage(hWnd, IDC_ORIENT_TARG_LIST, LB_SETTABSTOPS, 1, (LPARAM)&ts);
		int ct = pblock->Count(orientation_target_list);
		int ctf = pblock->Count(orientation_target_weight);
		if (ct != ctf) return;		// CAL-09/10/02: In the middle of changing table size.

		for (int i = 0; i < ct; i++){				
			TSTR str;
			INode *testNode;
			testNode = pblock->GetINode(orientation_target_list, t, i);
			if (testNode == NULL){
				str.printf( _T("%-s\t%-d"), // NOTE: for tab "\t" to use, check "use tabstops" in the resource listbox properties
										_T("World"), (int)pblock->GetFloat(orientation_target_weight, t, i));
				isWorldinListboxFlag = 1;
				ICustButton *iPickOb;
				iPickOb	= GetICustButton(GetDlgItem(hWnd, IDC_ORIENT_PICK_WORLD));
				if (iPickOb != NULL){
					iPickOb->Enable(FALSE);
					ReleaseICustButton(iPickOb);
				}
			}
			else{
				float wwt = pblock->GetFloat(orientation_target_weight, t, i);
				const TCHAR * nname = testNode->GetName();
				str.printf(_T("%-s\t%-d"), 
				testNode->GetName(),
				(int)pblock->GetFloat(orientation_target_weight, t, i));
			}
			SendDlgItemMessage(hWnd, IDC_ORIENT_TARG_LIST, LB_ADDSTRING, 0, (LPARAM)(LPCTSTR) str.data());			
		}

		if(!isWorldinListboxFlag){
				ICustButton *iPickOb;
				iPickOb	= GetICustButton(GetDlgItem(hWnd, IDC_ORIENT_PICK_WORLD));
				if (iPickOb != NULL){
					iPickOb->Enable(TRUE);
					ReleaseICustButton(iPickOb);
				}
		}

		if (ct > 0){
			if (sel >= 0){
				SendDlgItemMessage(hWnd, IDC_ORIENT_TARG_LIST, LB_SETCURSEL, sel, 0);
			}
			else{
//		int selection = SendDlgItemMessage(hWnd, IDC_POS_TARG_LIST, LB_GETCURSEL, 0, 0);
				if (selection >= 0){
					SendDlgItemMessage(hWnd, IDC_ORIENT_TARG_LIST, LB_SETCURSEL, selection, 0);
					last_selection = selection;
				}
				else if (ct == 1){
					SendDlgItemMessage(hWnd, IDC_ORIENT_TARG_LIST, LB_SETCURSEL, 0, 0);
					last_selection = 0;
				}
			}
			
			ISpinnerControl* spin = GetISpinner(GetDlgItem(hWnd, IDC_ORIENT_CONS_WEIGHT_SPINNER));
			if (last_selection >= 0 && spin != NULL){
				float value = pblock->GetFloat(orientation_target_weight, GetCOREInterface()->GetTime(), last_selection);
				spin->SetValue(value, FALSE);
			}
			ReleaseISpinner(spin);
		}
		HWND hListBox = GetDlgItem(hWnd, IDC_ORIENT_TARG_LIST);
		int extent = computeHorizontalExtent(hListBox, TRUE, 1, &ts);
		SendMessage(hListBox, LB_SETHORIZONTALEXTENT, extent, 0);
		UpdateWindow(hWnd);
	}
		INT_PTR DlgProc(TimeValue t, IParamMap2 *map, HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
		{	

			OrientConstRotation* p = (OrientConstRotation*)map->GetParamBlock()->GetOwner();
			UpdateOrientName(p);
			p->hWnd = hWnd;
			int ct = p->pblock->Count(orientation_target_list);
//			int ctf = p->pblock->Count(orientation_target_weight);

			switch (msg) 
			{
				case WM_INITDIALOG:
				{
					int selection = p->last_selection;

					ICustButton *iBut = GetICustButton(GetDlgItem(hWnd,IDC_ORIENT_TARG_PICKNODE));
					iBut->SetType(CBT_CHECK);
					iBut->SetHighlightColor(GREEN_WASH);
					ReleaseICustButton(iBut);
					
					ISpinnerControl* spin = SetupFloatSpinner(hWnd, IDC_ORIENT_CONS_WEIGHT_SPINNER, IDC_ORIENT_CONS_WEIGHT_EDIT, 0.0f, 100.0f, 50.0f, 1.0f);
					spin = GetISpinner(GetDlgItem(hWnd, IDC_ORIENT_CONS_WEIGHT_SPINNER));
					
					// CAL-09/10/02: automatically set last_selection to 0 when there're targets
					if (p->pblock->Count(orientation_target_list) < 1) { 
						// nothing is selected OR there are no targets
						// all buttons - target_delete, weight_edit, weight_spinner -- are disabled
						EnableWindow(GetDlgItem(p->hWnd, IDC_ORIENT_CONS_WEIGHT_EDIT), FALSE);
						EnableWindow(GetDlgItem(p->hWnd, IDC_ORIENT_CONS_WEIGHT_SPINNER), FALSE);
						ICustButton *iPickOb1;
						iPickOb1	= GetICustButton(GetDlgItem(p->hWnd, IDC_REMOVE_ORIENT_TARG));
						if (iPickOb1 != NULL){
							iPickOb1->Enable(FALSE);		
							ReleaseICustButton(iPickOb1);
						}
						spin->SetValue(0.0f, FALSE);		
					} else {
						if (selection < 0)
							p->last_selection = selection = 0;

						// there is a valid selection 
						// automatically means there is AT LEAST one target
						Control *cont = p->pblock->GetControllerByID(orientation_target_weight, selection); 
						// until it is animated, paramblock doesn't have a controller assigned in it yet.
						if (spin) {
							if ((cont != NULL) && cont->IsKeyAtTime(t,KEYAT_ROTATION))
								spin->SetKeyBrackets(TRUE);
							else
								spin->SetKeyBrackets(FALSE);
						}

						if(p->pickWorldFlag){
							ICustButton *iPickOb;
							iPickOb	= GetICustButton(GetDlgItem(p->hWnd, IDC_ORIENT_PICK_WORLD));
							if (iPickOb != NULL){
								iPickOb->Enable(FALSE);
								ReleaseICustButton(iPickOb);
							}

						}

						if (p->pblock->Count(orientation_target_list) == 1){// there is only one target
							// the "delete" button should be enabled
							ICustButton *iPickOb1;
							iPickOb1 = GetICustButton(GetDlgItem(p->hWnd, IDC_REMOVE_ORIENT_TARG));
							if (iPickOb1 != NULL){
								iPickOb1->Enable(TRUE);		
								ReleaseICustButton(iPickOb1);
							}
							// the rest are disabled
//							EnableWindow(GetDlgItem(p->hWnd, IDC_ORIENT_CONS_WEIGHT_EDIT), FALSE);
//							EnableWindow(GetDlgItem(p->hWnd, IDC_ORIENT_CONS_WEIGHT_SPINNER), FALSE);
						}
						else if (p->pblock->Count(orientation_target_list) > 1){ 
							// there are more than one targets
							// all buttons - delete, weight_edit, weight_spinner -- are enabled
							EnableWindow(GetDlgItem(p->hWnd, IDC_ORIENT_CONS_WEIGHT_EDIT), TRUE);
							EnableWindow(GetDlgItem(p->hWnd, IDC_ORIENT_CONS_WEIGHT_SPINNER), TRUE);
							ICustButton *iPickOb1;
							iPickOb1 = GetICustButton(GetDlgItem(p->hWnd, IDC_REMOVE_ORIENT_TARG));
							if (iPickOb1 != NULL){
								iPickOb1->Enable(TRUE);		
								ReleaseICustButton(iPickOb1);
							}
						}
					}
					ReleaseISpinner(spin);
					p->RedrawListbox(GetCOREInterface()->GetTime(), selection);
					return TRUE;	
				}
				break;


				case WM_COMMAND:
				{
					
					int selection;
					
					if (LOWORD(wParam) == IDC_ORIENT_TARG_LIST && HIWORD(wParam) == LBN_SELCHANGE)
					{
						selection = SendDlgItemMessage(p->hWnd, IDC_ORIENT_TARG_LIST, LB_GETCURSEL, 0, 0);
						p->last_selection = selection;
						if (selection >= 0){
						// there is a valid selection 
							// automatically means there is AT LEAST one target
							if (p->pblock->Count(orientation_target_list) == 1){ // there is only one target
								// the "delete" button should be enabled
								ICustButton *iPickOb1;
								iPickOb1 = GetICustButton(GetDlgItem(p->hWnd, IDC_REMOVE_ORIENT_TARG));
								if (iPickOb1 != NULL){
									iPickOb1->Enable(TRUE);		
									ReleaseICustButton(iPickOb1);
								}
//								// the rest are disabled
//								EnableWindow(GetDlgItem(p->hWnd, IDC_ORIENT_CONS_WEIGHT_EDIT), FALSE);
//								EnableWindow(GetDlgItem(p->hWnd, IDC_ORIENT_CONS_WEIGHT_SPINNER), FALSE);
							}

							else  if (p->pblock->Count(orientation_target_list) > 1){ 
							// there are more than one targets
								// all buttons - delete, weight_edit, weight_spinner -- are enabled
								EnableWindow(GetDlgItem(p->hWnd, IDC_ORIENT_CONS_WEIGHT_EDIT), TRUE);
								EnableWindow(GetDlgItem(p->hWnd, IDC_ORIENT_CONS_WEIGHT_SPINNER), TRUE);
								ICustButton *iPickOb1;
								iPickOb1 = GetICustButton(GetDlgItem(p->hWnd, IDC_REMOVE_ORIENT_TARG));
								if (iPickOb1 != NULL){
									iPickOb1->Enable(TRUE);		
									ReleaseICustButton(iPickOb1);
								}

								ISpinnerControl* spin = GetISpinner(GetDlgItem(hWnd, IDC_ORIENT_CONS_WEIGHT_SPINNER));
								float value = map->GetParamBlock()->GetFloat(orientation_target_weight, t, selection);
								spin->SetValue(value, FALSE);

								Control *cont = p->pblock->GetControllerByID(orientation_target_weight, selection); // until it is animated, paramblock doesn't have a controller assigned in it yet.
								if (spin && (cont != NULL)) {
									if (cont->IsKeyAtTime(t,KEYAT_ROTATION)){
										spin->SetKeyBrackets(TRUE);
									} 
								}
								else {
									spin->SetKeyBrackets(FALSE);
								}
								ReleaseISpinner(spin);
							}
							p->RedrawListbox(GetCOREInterface()->GetTime(), selection);							
						}
						
						else if (selection < 0 || p->pblock->Count(orientation_target_list) < 1){ 
						// nothing is selected OR there are no targets
							// all buttons - target_delete, weight_edit, weight_spinner -- are disabled
							EnableWindow(GetDlgItem(p->hWnd, IDC_ORIENT_CONS_WEIGHT_EDIT), FALSE);
							EnableWindow(GetDlgItem(p->hWnd, IDC_ORIENT_CONS_WEIGHT_SPINNER), FALSE);
							ICustButton *iPickOb1;
							iPickOb1	= GetICustButton(GetDlgItem(p->hWnd, IDC_REMOVE_ORIENT_TARG));
							if (iPickOb1 != NULL){
								iPickOb1->Enable(FALSE);		
								ReleaseICustButton(iPickOb1);
							}
						}
					}

					else if (LOWORD(wParam) == IDC_ORIENT_TARG_PICKNODE){
						thePickMode.p  = p;					
						p->ip->SetPickMode(&thePickMode);
					}

					else if (LOWORD(wParam) == IDC_REMOVE_ORIENT_TARG){
						selection = SendDlgItemMessage(p->hWnd, IDC_ORIENT_TARG_LIST, LB_GETCURSEL, 0, 0);
						p->last_selection = selection;
						if (selection >= 0){
							theHold.Begin();
							p->DeleteTarget(selection);
							theHold.Accept(GetString(IDS_AG_ORIENTATION_LIST));
						}
//						p->RedrawListbox(GetCOREInterface()->GetTime(), selection-1);
					}

					else if (LOWORD(wParam) == IDC_ORIENT_PICK_WORLD){
						INode *nullNode = NULL;
						p->AppendTarget(nullNode);
						
						p->pickWorldFlag = 1;

						p->NotifyDependents(FOREVER,PART_ALL,REFMSG_CHANGE); // so that the change is updated
						ICustButton *iPickOb;
						iPickOb	= GetICustButton(GetDlgItem(p->hWnd, IDC_ORIENT_PICK_WORLD));
						if (iPickOb != NULL){
							iPickOb->Enable(FALSE);
							ReleaseICustButton(iPickOb);
						}
						p->RedrawListbox(GetCOREInterface()->GetTime());
					}

				
				}
				break;


				case CC_SPINNER_CHANGE:
				{
					if (LOWORD(wParam) == IDC_ORIENT_CONS_WEIGHT_SPINNER) {
						int selection = SendDlgItemMessage(p->hWnd, IDC_ORIENT_TARG_LIST, LB_GETCURSEL, 0, 0);

						// CAL-09/10/02: need to start a hold if it's not holding to handle type-in values
						BOOL isHold = theHold.Holding();
						if (!isHold) theHold.Begin();

						ISpinnerControl* spin = GetISpinner(GetDlgItem(hWnd, IDC_ORIENT_CONS_WEIGHT_SPINNER));

						if (selection >= 0) {
							float value = ((ISpinnerControl *)lParam)->GetFVal();
							map->GetParamBlock()->SetValue(orientation_target_weight, t, value, selection);

							Control *cont = p->pblock->GetControllerByID(orientation_target_weight, selection); // until it is animated, paramblock doesn't have a controller assigned in it yet.
							if (spin)
								spin->SetKeyBrackets(((cont != NULL) && cont->IsKeyAtTime(t,KEYAT_ROTATION)) ? TRUE : FALSE);

							p->RedrawListbox(GetCOREInterface()->GetTime(), selection);
						} else {
							if (spin) spin->SetValue(0.0f, FALSE);
						}

						if (spin) ReleaseISpinner(spin);

						if (!isHold) theHold.Accept(GetString(IDS_RB_PARAMETERCHANGE));
					}
				}			
				break;

			}
			return FALSE;
		}