int RefineConnectMouseProc::proc( HWND hwnd, int msg, int point, int flags, IPoint2 m ) { ViewExp *vpt = ip->GetViewport(hwnd); int res = TRUE; switch ( msg ) { case MOUSE_PROPCLICK: ip->SetStdCommandMode(CID_OBJMOVE); break; case MOUSE_POINT: if(HitTest(vpt,&m,HITTYPE_POINT,0) ) { HitLog &hits = vpt->GetSubObjHitList(); HitRecord *rec = hits.First(); HitRecord *bestRec = rec; DWORD best = rec->distance; while(rec) { rec = rec->Next(); if(rec) { if(rec->distance < best) { best = rec->distance; bestRec = rec; } } } ShapeHitData *hit = ((ShapeHitData *)bestRec->hitData); ss->DoRefineConnect(vpt, hit->shape, hit->poly, hit->index, m); } res = FALSE; break; case MOUSE_FREEMOVE: vpt->SnapPreview(m,m,NULL, SNAP_IN_3D); if ( HitTest(vpt,&m,HITTYPE_POINT,HIT_ABORTONHIT) ) { SetCursor(GetTransformCursor()); } else { SetCursor(LoadCursor(NULL,IDC_ARROW)); } break; } if ( vpt ) ip->ReleaseViewport(vpt); return res; }
int CreateLineMouseProc::proc( HWND hwnd, int msg, int point, int flags, IPoint2 m ) { ViewExp *vpt = ip->GetViewport(hwnd); int res = TRUE; static int poly, seg, vert; static BezierShape *shape; static Spline3D *spline; static BOOL creating = FALSE; static BOOL inserting = FALSE; static Matrix3 mat; static EditSplineMod *mod; static int originalInsert; if(creating) { // Ignore the messages the spline code doesn't care about... TH 3/12/99 switch(msg) { #ifdef DESIGN_VER case MOUSE_DBLCLICK: #endif case MOUSE_POINT: case MOUSE_MOVE: case MOUSE_ABORT: break; default: return TRUE; } vpt->getGW()->setTransform(mat); int res = shape->splines[poly]->Create(vpt,msg,point,flags,m,&mat,ip); // Must update the shape's selection set for this spline shape->UpdateSels(TRUE); switch(res) { case CREATE_STOP: es->EndCreateLine(); creating = FALSE; backspaceRouter.UnRegister(&pBack); break; case CREATE_ABORT: shape->DeleteSpline(poly); es->EndCreateLine(FALSE); creating = FALSE; backspaceRouter.UnRegister(&pBack); break; } mod->createShapeData->Invalidate(PART_GEOM); mod->NotifyDependents(FOREVER, PART_GEOM, REFMSG_CHANGE); ip->RedrawViews(ip->GetTime(), REDRAW_NORMAL); } else if(inserting) { // Ignore the messages the spline code doesn't care about... TH 3/12/99 switch(msg) { #ifdef DESIGN_VER case MOUSE_DBLCLICK: #endif case MOUSE_POINT: { for (int i = 0; i < shape->bindList.Count();i++) { if (poly == shape->bindList[i].segSplineIndex) { if ((seg!=-1)&&(originalInsert <= shape->bindList[i].seg)) { if (originalInsert == shape->bindList[i].seg) { { shape->bindList[i].seg++; } } else { shape->bindList[i].seg++; } } } } } case MOUSE_MOVE: case MOUSE_ABORT: break; default: return TRUE; } int res = shape->splines[poly]->Create(vpt,msg,point,flags,m,&mat,ip); // Must update the shape's selection set for this spline BitArray& vsel = shape->vertSel[poly]; BitArray& ssel = shape->segSel[poly]; while(vsel.GetSize() < shape->splines[poly]->Verts()) { vsel.SetSize(vsel.GetSize() + 3,1); vsel.Shift(RIGHT_BITSHIFT,3,vert+3); vsel.Clear(vert+2); vsel.Clear(vert+3); vsel.Clear(vert+4); } while(ssel.GetSize() < shape->splines[poly]->Segments()) { ssel.SetSize(ssel.GetSize() + 1,1); ssel.Shift(RIGHT_BITSHIFT,1,vert/3+1); ssel.Clear(vert/3+1); } switch(res) { case CREATE_STOP: { // Must update the shape's selection set for this spline BitArray& vsel = shape->vertSel[poly]; BitArray& ssel = shape->segSel[poly]; while(vsel.GetSize() > shape->splines[poly]->Verts()) { vsel.Shift(LEFT_BITSHIFT,3,vert+1); vsel.SetSize(vsel.GetSize() - 3,1); } while(ssel.GetSize() > shape->splines[poly]->Segments()) { ssel.Shift(LEFT_BITSHIFT,1,(vert+1)/3); ssel.SetSize(ssel.GetSize() - 1,1); } es->EndVertInsert(); inserting = FALSE; backspaceRouter.UnRegister(&iBack); for (int i = 0; i < shape->bindList.Count();i++) { if (poly == shape->bindList[i].segSplineIndex) { if ((seg!=-1)&&(originalInsert <= shape->bindList[i].seg)) { if (originalInsert == shape->bindList[i].seg) { { shape->bindList[i].seg--; } } else { shape->bindList[i].seg--; } } } } break; } case CREATE_ABORT: shape->DeleteSpline(poly); es->insertPoly = -1; es->EndVertInsert(); inserting = FALSE; backspaceRouter.UnRegister(&iBack); break; } mod->insertShapeData->Invalidate(PART_GEOM); mod->NotifyDependents(FOREVER, PART_GEOM, REFMSG_CHANGE); ip->RedrawViews(ip->GetTime(), REDRAW_NORMAL); } else { switch(msg) { case MOUSE_PROPCLICK: ip->SetStdCommandMode(CID_OBJMOVE); break; case MOUSE_POINT: mod = es; if((SplineShape::GetUseEndPointAutoConnect()==BST_CHECKED) && InsertWhere(vpt, &m, &shape, &poly, &seg, &vert)) { vert = es->StartVertInsert(vpt, shape, poly, seg, vert, &mod); if(vert < 0) { res = FALSE; break; } originalInsert = seg; mat = mod->insertTM; shape->splines[poly]->StartInsert(vpt, msg, point, flags, m, &mat, vert/3+1 ); // Must update the shape's selection set for this spline BitArray& vsel = shape->vertSel[poly]; BitArray& ssel = shape->segSel[poly]; while(vsel.GetSize() < shape->splines[poly]->Verts()) { vsel.SetSize(vsel.GetSize() + 3,1); vsel.Shift(RIGHT_BITSHIFT,3,vert+3); vsel.Clear(vert+2); vsel.Clear(vert+3); vsel.Clear(vert+4); } while(ssel.GetSize() < shape->splines[poly]->Segments()) { ssel.SetSize(ssel.GetSize() + 1,1); ssel.Shift(RIGHT_BITSHIFT,1,vert/3+1); ssel.Clear(vert/3+1); } inserting = TRUE; iBack.SetPtrs(mod, shape->splines[poly]); backspaceRouter.Register(&iBack); } else { if(!mod->StartCreateLine(&shape)) return CREATE_ABORT; poly = shape->splineCount; spline = shape->NewSpline(); shape->UpdateSels(TRUE); mat = mod->createTM; vpt->getGW()->setTransform(mat); if(spline->Create(vpt,msg,point,flags,m,&mat,ip) == CREATE_CONTINUE) { creating = TRUE; shape->UpdateSels(TRUE); pBack.SetPtrs(mod, spline); backspaceRouter.Register(&pBack); } else { shape->DeleteSpline(poly); res = FALSE; } } SetCursor(LoadCursor(hInstance,MAKEINTRESOURCE(IDC_ES_CROSS_HAIR))); break; case MOUSE_MOVE: case MOUSE_ABORT: res = FALSE; break; case MOUSE_FREEMOVE: if((SplineShape::GetUseEndPointAutoConnect()==BST_CHECKED) && InsertWhere(vpt, &m, &shape, &poly, &seg, &vert)) SetCursor(LoadCursor(hInstance,MAKEINTRESOURCE(IDC_CREATE_WELD))); else SetCursor(LoadCursor(hInstance,MAKEINTRESOURCE(IDC_ES_CROSS_HAIR))); vpt->SnapPreview(m,m,NULL, SNAP_IN_3D); break; } } if ( vpt ) ip->ReleaseViewport(vpt); return res; }