BOOL IsButtonChecked(HWND hWnd,int id) { ICustButton *iBut; BOOL res; iBut = GetICustButton(GetDlgItem(hWnd,id)); res = iBut->IsChecked(); ReleaseICustButton(iBut); return res; }
static INT_PTR CALLBACK SelectBySmoothDlgProc (HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam) { static DWORD *param; int i(0); ICustButton* iBut = NULL; static SmoothingGroupUIHandler smoothingGroupUIHandler; switch (msg) { case WM_INITDIALOG: ThePopupPosition()->Set (hWnd); param = (DWORD*)lParam; for (i=IDC_SMOOTH_GRP1; i<IDC_SMOOTH_GRP1+32; i++) if(GetDlgItem(hWnd,i)) SendMessage(GetDlgItem(hWnd,i),CC_COMMAND,CC_CMD_SET_TYPE,CBT_CHECK); selectBySmoothGroups = 0; smoothingGroupUIHandler.UpdateSmoothButtons (hWnd, selectBySmoothGroups, 0, param[0]); CheckDlgButton(hWnd,IDC_CLEARSELECTION, selectBySmoothClear); break; case WM_COMMAND: if (LOWORD(wParam)>=IDC_SMOOTH_GRP1 && LOWORD(wParam)<=IDC_SMOOTH_GRP32) { iBut = GetICustButton(GetDlgItem(hWnd,LOWORD(wParam))); int shift = LOWORD(wParam) - IDC_SMOOTH_GRP1; if (iBut->IsChecked()) selectBySmoothGroups |= 1<<shift; else selectBySmoothGroups &= ~(1<<shift); ReleaseICustButton(iBut); break; } switch (LOWORD(wParam)) { case IDOK: ThePopupPosition()->Scan (hWnd); if(GetDlgItem(hWnd,IDC_CLEARSELECTION)) selectBySmoothClear = IsDlgButtonChecked(hWnd,IDC_CLEARSELECTION) ? true : false; EndDialog(hWnd,1); break; case IDCANCEL: ThePopupPosition()->Scan (hWnd); EndDialog(hWnd,0); break; } break; default: return FALSE; } return TRUE; }
INT_PTR SmoothDlgProc::DlgProc(TimeValue t, IParamMap2 *map, HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam) { switch (msg) { case WM_INITDIALOG: #ifndef USE_SIMPLIFIED_SMOOTH_MODIFIER_UI { for (int i=IDC_SMOOTH_GRP1; i<IDC_SMOOTH_GRP1+32; i++) { ICustButton *iBut = GetICustButton(GetDlgItem(hWnd,i)); iBut->SetType (CBT_CHECK); ReleaseICustButton (iBut); } } #endif uiValid = false; break; case WM_PAINT: if (uiValid) break; Update (hWnd, t); break; case WM_COMMAND: if (LOWORD(wParam)>=IDC_SMOOTH_GRP1 && LOWORD(wParam)<=IDC_SMOOTH_GRP32) { IParamBlock2 *pblock = (IParamBlock2*)map->GetParamBlock(); ICustButton *iBut = GetICustButton(GetDlgItem(hWnd,LOWORD(wParam))); int bits; pblock->GetValue (sm_smoothbits, t, bits, FOREVER); int shift = LOWORD(wParam) - IDC_SMOOTH_GRP1; if (iBut->IsChecked()) bits |= 1<<shift; else bits &= ~(1<<shift); theHold.Begin (); pblock->SetValue (sm_smoothbits, t, bits); theHold.Accept (GetString (IDS_VS_SMGROUP)); ReleaseICustButton(iBut); return REDRAW_VIEWS; } break; } return FALSE; }
void SmoothingGroupUIHandler::SetSmoothing (HWND hWnd, int buttonID, EPolyMod *pMod) { ICustButton *pBut = GetICustButton (GetDlgItem (hWnd, buttonID)); if (pBut == NULL) return; bool set = pBut->IsChecked()!=0; IParamBlock2 *pBlock = pMod->getParamBlock (); int i = buttonID - IDC_SMOOTH_GRP1; DWORD bit = DWORD(1)<<i; theHold.Begin (); bool startFresh = (pMod->GetPolyOperationID() != ep_op_smooth); if (startFresh) pMod->EpModSetOperation (ep_op_smooth); int acceptID; if (set) { int smoothers = startFresh ? 0 : pBlock->GetInt (epm_smooth_group_set); DWORD *realSmoothers = (DWORD *)((void *)&smoothers); (*realSmoothers) |= bit; pBlock->SetValue (epm_smooth_group_set, 0, smoothers); acceptID = IDS_SET_SMOOTHING; } else { int smoothers = startFresh ? 0 : pBlock->GetInt (epm_smooth_group_clear); DWORD *realSmoothers = (DWORD *)((void *)&smoothers); (*realSmoothers) |= bit; pBlock->SetValue (epm_smooth_group_clear, 0, smoothers); // Make sure to remove this from the ones being "set" as well, if needed: if (!startFresh && (smoothers = pBlock->GetInt (epm_smooth_group_set)) != 0) { if ((*realSmoothers) & bit) { (*realSmoothers) -= bit; pBlock->SetValue (epm_smooth_group_set, 0, smoothers); } } acceptID = IDS_CLEAR_SMOOTHING; } theHold.Accept (GetString (acceptID)); }
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; }
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; }