[Need help] View does'n work well when change the selection mode

My program works well when it is initializes. The view can be translate,rotate and scale.
However when I change the selection mode, it doesn't work well.Set the face selection mode for example, then I rotate the view use the mouse, the model rotate, however when i click the blank space or sometimes even move the mouse over the model, the model change to the position when fit and looks really unstable. I really don't know how it happens. Does the view in the neutral point different from the local context? Here are some codes relate to the question:

void MoveEvent( const Standard_Integer theMouseX, const Standard_Integer theMouseY, const Handle(V3d_View)& theView )
{
myAISContext->MoveTo (theMouseX, theMouseY, theView);
}

void InputEvent (const Standard_Integer theMouseX,
const Standard_Integer theMouseY,
const Handle(V3d_View)& theView)
{
myAISContext->MoveTo (theMouseX, theMouseY, theView);

Standard_Boolean haslocalcontext=myAISContext->HasOpenedContext();
if (!haslocalcontext)
return;

myAISContext->Select(Standard_True);
myAISContext->InitSelected();
if (myAISContext->MoreSelected())
{
TopoDS_Shape aShape=myAISContext->SelectedShape();
AddoccPickElement(aShape);//put the picked one into a list
}
}

//set face selection mode
void OnSelectFace()
{
myAISContext->CloseAllContexts(Standard_False);
myAISContext->OpenLocalContext();
myAISContext->ActivateStandardMode(TopAbs_FACE);
}

wait for some tips, thanks!

tiantangtl@foxmail.com's picture

My system is windows 8.1
My compiler is Visual Studio 2010
My OCC version is 6.7.0