void EditFaceDataMod::ChangeBegin () { if (selLevel == SEL_OBJECT) return; if (efdRestore) { delete efdRestore; efdRestore = NULL; } // Find the modcontext with the selected faces. // NOTE that as currently written, this modifier won't // support setting FaceFloats on more than one node at a time. ModContextList mcList; INodeTab nodes; ip->GetModContexts(mcList,nodes); int numSelected=0, whichFace; float value; bool valueDetermined=true; EditFaceDataModData *relevantMD; if (selLevel) { for (int i = 0; i < mcList.Count(); i++) { EditFaceDataModData *meshData = (EditFaceDataModData*)mcList[i]->localData; if (!meshData) continue; meshData->DescribeSelection (numSelected, whichFace, value, valueDetermined); if (!numSelected) continue; relevantMD = meshData; break; } } nodes.DisposeTemporary (); if (!numSelected) return; efdRestore = new EditFaceDataRestore (this, relevantMD); }
void EditFaceDataMod::ClearSelection(int selLevel) { ModContextList list; INodeTab nodes; ip->GetModContexts(list,nodes); EditFaceDataModData *d; for (int i=0; i<list.Count(); i++) { d = (EditFaceDataModData*)list[i]->localData; if (!d) continue; // Check if we have anything selected first: switch (selLevel) { case SEL_FACE: if (!d->GetFaceSel().NumberSet()) continue; else break; } if (theHold.Holding() && !d->GetHeld()) theHold.Put (new SelectRestore (this, d)); d->SynchSize (); switch (selLevel) { case SEL_FACE: d->GetFaceSel().ClearAll(); break; } } nodes.DisposeTemporary(); SelectionChanged (); }
void EditFaceDataMod::UpdateDialog () { TSTR buf; int numFaces=0, whichFace=0; float value = 1.0f; bool valueDetermined = true; if (!hParams) return; ModContextList mcList; INodeTab nodes; ip->GetModContexts(mcList,nodes); if (selLevel) { for (int i = 0; i < mcList.Count(); i++) { EditFaceDataModData *meshData = (EditFaceDataModData*)mcList[i]->localData; if (!meshData) continue; int numSelectedHere; meshData->DescribeSelection (numSelectedHere, whichFace, value, valueDetermined); numFaces += numSelectedHere; } } ISpinnerControl *spin = GetISpinner (GetDlgItem (hParams, IDC_VALUE_SPIN)); ICustButton *but = GetICustButton (GetDlgItem (hParams, IDC_RESET_SELECTION)); switch (selLevel) { case SEL_FACE: if (numFaces==1) { buf.printf (GetString(IDS_FACE_SELECTED), whichFace+1); } else { if (numFaces) buf.printf (GetString (IDS_FACES_SELECTED), numFaces); else buf = GetString (IDS_NO_FACE_SELECTED); } but->Enable (numFaces); spin->Enable (numFaces); if (numFaces && valueDetermined) { spin->SetIndeterminate (false); spin->SetValue (value, FALSE); } else { spin->SetIndeterminate (true); } break; case SEL_OBJECT: buf = GetString (IDS_OBJECT_SELECTED); spin->Disable(); but->Disable (); break; } SetDlgItemText(hParams,IDC_FACE_SELECTED,buf); ReleaseISpinner (spin); ReleaseICustButton (but); }
void EditFaceDataMod::ResetSelection () { ModContextList list; INodeTab nodes; ip->GetModContexts(list,nodes); EditFaceDataModData *d; theHold.Begin (); for (int i=0; i<list.Count(); i++) { d = (EditFaceDataModData*)list[i]->localData; if (!d) continue; EditFaceDataRestore *efd = new EditFaceDataRestore (this, d); d->ResetFace (d->GetFaceSel()); efd->After (); theHold.Put (efd); } nodes.DisposeTemporary(); theHold.Accept (GetString (IDS_RESET_SELECTED)); ValueChanged (); }
void EditFaceDataMod::InvertSelection(int selLevel) { ModContextList list; INodeTab nodes; ip->GetModContexts(list,nodes); EditFaceDataModData *d; for (int i=0; i<list.Count(); i++) { d = (EditFaceDataModData*)list[i]->localData; if (!d) continue; if (theHold.Holding() && !d->GetHeld()) theHold.Put(new SelectRestore(this,d)); d->SynchSize(); switch (selLevel) { case SEL_FACE: d->GetFaceSel() = ~d->GetFaceSel(); break; } } nodes.DisposeTemporary(); SelectionChanged (); }
void FaceDataToColorMod::DisplayColors () { if (!mpInterface) return; int channel = 0; if (mpParams) mpParams->GetValue (pb_channel, TimeValue(0), channel, FOREVER); ModContextList mcList; INodeTab nodes; mpInterface->GetModContexts(mcList,nodes); for (int nd = 0; nd<nodes.Count(); nd++) { nodes[nd]->SetCVertMode (true); nodes[nd]->SetShadeCVerts (true); if (channel) nodes[nd]->SetVertexColorType (nvct_illumination); else nodes[nd]->SetVertexColorType (nvct_color); //nodes[nd]->NotifyDependents (FOREVER, PART_DISPLAY, REFMSG_CHANGE); } // KLUGE: above notify dependents call only seems to set a limited refresh region. Result looks bad. // So we do this instead: NotifyDependents (FOREVER, PART_DISPLAY, REFMSG_CHANGE); mpInterface->RedrawViews (mpInterface->GetTime()); }
void EditFaceDataMod::SelectSubComponent (HitRecord *hitRec, BOOL selected, BOOL all, BOOL invert) { EditFaceDataModData *d = NULL, *od = NULL; ModContextList mcList; INodeTab nodes; ip->GetModContexts(mcList,nodes); BitArray nsel; for (int nd=0; nd<mcList.Count(); nd++) { d = (EditFaceDataModData*) mcList[nd]->localData; if (d==NULL) continue; HitRecord *hr = hitRec; if (!all && (hr->modContext->localData != d)) continue; for (; hr!=NULL; hr=hr->Next()) if (hr->modContext->localData == d) break; if (hr==NULL) continue; Mesh *mesh = d->GetCacheMesh(); MNMesh *mnmesh = d->GetCacheMNMesh(); if (!mesh && !mnmesh) continue; if (theHold.Holding() && !d->GetHeld()) theHold.Put (new SelectRestore (this, d)); switch (selLevel) { case SEL_FACE: nsel = d->GetFaceSel(); for (; hr != NULL; hr=hr->Next()) { if (d != hr->modContext->localData) continue; nsel.Set (hr->hitInfo, invert ? !d->GetFaceSel()[hr->hitInfo] : selected); if (!all) break; } d->GetFaceSel() = nsel; break; } } nodes.DisposeTemporary (); SelectionChanged (); }