Exemple #1
0
RefResult CreateSWrapObjectProc::NotifyRefChanged(
	Interval changeInt, 
	RefTargetHandle hTarget, 
	PartID& partID,  
	RefMessage message) 
	{
	switch (message) {
		case REFMSG_PRENOTIFY_PASTE:
		case REFMSG_TARGET_SELECTIONCHANGE:
		 	if ( ignoreSelectionChange ) {
				break;
				}
		 	if ( SWrapObj && SWrapNode==hTarget ) {
				// this will set camNode== NULL;
				theHold.Suspend();
				DeleteReference(0);
				theHold.Resume();
				goto endEdit;
				}
			// fall through

		case REFMSG_TARGET_DELETED:		
			if (SWrapObj && SWrapNode==hTarget ) {
				endEdit:
				if (createInterface->GetCommandMode()->ID() == CID_STDPICK) 
				{ if (SWrapObj->creating) 
						{  theCreateSWrapObjectMode.JumpStart(SWrapObj->ip,SWrapObj);
							createInterface->SetCommandMode(&theCreateSWrapObjectMode);
					    } 
				  else {createInterface->SetStdCommandMode(CID_OBJMOVE);}
				}
#ifdef _OSNAP
				SWrapObj->ClearAFlag(A_OBJ_LONG_CREATE);
#endif
				SWrapObj->EndEditParams( (IObjParam*)createInterface, 0, NULL);
				SWrapObj  = NULL;				
				SWrapNode    = NULL;
				CreateNewObject();	
				attachedToNode = FALSE;
				}
			break;		
		}
	return REF_SUCCEED;
	}
Exemple #2
0
int CreateSWrapObjectProc::proc(HWND hwnd,int msg,int point,int flag,
				IPoint2 m )
{	int res=TRUE;	
	ViewExp *vpx = createInterface->GetViewport(hwnd); 
	assert( vpx );

#ifdef _3D_CREATE
	DWORD snapdim = SNAP_IN_3D;
#else
	DWORD snapdim = SNAP_IN_PLANE;
#endif
	switch ( msg ) {
		case MOUSE_POINT:
			switch ( point ) {
				case 0:
					assert( SWrapObj );					
					vpx->CommitImplicitGrid(m, flag );
					if ( createInterface->SetActiveViewport(hwnd) ) {
						return FALSE;
						}

					if (createInterface->IsCPEdgeOnInView()) { 
						res = FALSE;
						goto done;
						}

					if ( attachedToNode ) {
				   		// send this one on its way
#ifdef _OSNAP
                    SWrapObj->ClearAFlag(A_OBJ_LONG_CREATE);
#endif
				   		SWrapObj->EndEditParams( (IObjParam*)createInterface, 0, NULL);
						if (SWrapNode) {
							theHold.Suspend();
							DeleteReference(0);
							theHold.Resume();
							}

						// new object
						CreateNewObject();   // creates SWrapObj
						}

				   	theHold.Begin();	 // begin hold for undo
					mat.IdentityMatrix();

					// link it up
					SWrapNode = createInterface->CreateObjectNode( SWrapObj);
					attachedToNode = TRUE;
					assert( SWrapNode );					
					createCB = NULL;
					createInterface->SelectNode( SWrapNode );
					
					// Reference the new node so we'll get notifications.
					theHold.Suspend();
					MakeRefByID( FOREVER, 0, SWrapNode);
					theHold.Resume();
					mat.IdentityMatrix();
				default:				
					res = createmethod(vpx,msg,point,flag,m,mat);
					createInterface->SetNodeTMRelConstPlane(SWrapNode, mat);
					if (res==CREATE_ABORT)
						goto abort;
					if (res==CREATE_STOP){
#ifdef _OSNAP
                        SWrapObj->ClearAFlag(A_OBJ_LONG_CREATE);
#endif
						theHold.Accept(GetString(IDS_AP_CREATE));	
					}
					createInterface->RedrawViews(createInterface->GetTime()); 
					break;
				}			
			break;

		case MOUSE_MOVE:
			res = createmethod(vpx,msg,point,flag,m,mat);
			createInterface->SetNodeTMRelConstPlane(SWrapNode, mat);
			if (res==CREATE_ABORT)
				goto abort;
			if (res==CREATE_STOP){
#ifdef _OSNAP
               SWrapObj->ClearAFlag(A_OBJ_LONG_CREATE);
#endif
			   theHold.Accept(GetString(IDS_AP_CREATE));	
			}
			createInterface->RedrawViews(createInterface->GetTime()); 
		break;

/*			res = createmethod(vpx,msg,point,flag,m,mat);
			createInterface->SetNodeTMRelConstPlane(SWrapNode, mat);
			if (res==CREATE_ABORT)
				goto abort;
			if (res==CREATE_STOP)
				theHold.Accept(GetString(IDS_AP_CREATE));	
			createInterface->RedrawViews(createInterface->GetTime()); 
		break;*/
	case MOUSE_PROPCLICK:
		createInterface->SetStdCommandMode(CID_OBJMOVE);
		break;
	case MOUSE_ABORT: 
	abort:
		assert( SWrapObj );
#ifdef _OSNAP
			SWrapObj->ClearAFlag(A_OBJ_LONG_CREATE);
#endif
		SWrapObj->EndEditParams( (IObjParam*)createInterface,0,NULL);
		theHold.Cancel();	 // deletes both the object and target.
		if (theHold.GetGlobalPutCount()!=lastPutCount) 
					GetSystemSetting(SYSSET_CLEAR_UNDO);
		SWrapNode = NULL;			
		createInterface->RedrawViews(createInterface->GetTime()); 
		CreateNewObject();	
		attachedToNode = FALSE;
		res = FALSE;
		break;
	case MOUSE_FREEMOVE:
			SetCursor(LoadCursor(hInstance, MAKEINTRESOURCE(IDC_CROSS_HAIR)));
#ifdef _OSNAP  //PREVIEW SNAP
			res = createmethod(vpx,msg,point,flag,m,mat);
#endif
		vpx->TrackImplicitGrid(m);
			break;

		}
	done:
	if ((res == CREATE_STOP)||(res==CREATE_ABORT))
		vpx->ReleaseImplicitGrid();
	createInterface->ReleaseViewport(vpx); 
	return res;
	}