Wed, 07/10/2002 - 21:38
Hi, everybody:
Now my code can move AIS_Shape with Mouse, but one important deficiency is the `move' is not persisted. I use the following code:
//handler for WM_MOUSEMOVE:
gp_Trsf trsf;
trsf.SetTranslation(oldPnt, newPnt);
// m_hSelected is a Handle_AIS_Shape
hAISContext->SetLocation(m_hSelected, trsf);
hAISContext->Redisplay(m_hSelected);
this code can move AIS_Shape with mouse correctly, but next I try to move the same AIS_Shape, it will return to original location and then move starting from there!
So I add code to change the underlying TopoDS_Shape and reset this shape to AIS_Shape.
But I didn't know how can I synchronize two TopLoc_Location for both AIS_Shape & TopoDS_Shape, i.e. if I use m_hSelected->Location() as Location of associated TopoDS_Shape, it will be placed on a strange position. Could someone help me?
Thu, 07/11/2002 - 05:50
Hi,
Maybe you can use the code like as following:
//handler for WM_MOUSEMOVE:
gp_Trsf trsf;
trsf.SetTranslation(oldPnt, newPnt);
// m_hSelected is a Handle_AIS_Shape
aShape=m_hSelected ->Shape();
BRepBuilderAPI_Transform myTrsf(aShape,trsf,Standard_False);
aShape= myTrsf.Shape();
m_hSelected->Set(aShape);
hAISContext->Redisplay(m_hSelected);
Good luck,
Angel.
Thu, 07/11/2002 - 16:51
Thank you Angel. Now my code can run.
But I want to know more. My first code uses TopoDS_Shape::SetLocation(), it gaves incorrect result. And If I change BRepBuilderAPI_Transform to SetLocation, it is also wrong.
But OCC Sample often use SetLocation, I want to know when to use BRepBuilderAPI_Transform and when to use SetLocation?
Fri, 07/12/2002 - 03:29
Hi,
There is no TopoDS_Shape::SetLocation()and only has AIS_InteractiveContext::SetLocation. It mean you just only modify graphic representation but TopoDS is still in the original position.
Sincerely,
Angel
Fri, 07/12/2002 - 08:01
Sorry, I mean TopoDS_Shape.Location(). It exits and I use it a lot. MFC sample also use this function.
Fri, 07/12/2002 - 10:33
Hi,
You can see BRepBuilderAPI_Transform.cxx,and you'll find it use TopoDS_Shape.Moved().
Thu, 07/11/2002 - 17:06
Hi, Angel,
I think your code could be changed for the better if using the followed method.
gp_Trsf trsf;
trsf.SetTranslation(oldPnt, newPnt);
// m_hSelected is a Handle_AIS_Shape
aShape=m_hSelected ->Shape();
//BRepBuilderAPI_Transform myTrsf(aShape,trsf,Standard_False);
// aShape= myTrsf.Shape();
aShape.Location(trsf); m_hSelected->Set(aShape);
hAISContext->Redisplay(m_hSelected);
Fri, 07/12/2002 - 08:13
Hi, Du,
Sorry, I am afraid this code will not work as imagine.
In fact, after reading Angle's post, I first change my code just like yours, but there will be more modification for oldPnt & newPnt, one must commit this change in WM_LBUTTONUP handler, etc. Much more consideration.
I think Angel's method is the easiest way, at least in my code.
But I still a question, i.e. the difference between TopoDS_Shape.Location & BRepBuilderAPI_Transform.
Thu, 07/11/2002 - 15:26
Hi,
Can Anybody help me in erasing background object when I move object on mouse move event
Thu, 07/11/2002 - 15:51
In your CView class, add to the method OnDraw the following code :
myView->Redraw();