
Wed, 05/05/2010 - 11:19
Hi everyone, the ruberband almost drives me crazy these days. It's very easy to accomplish in MFC with the R2_NOT mode in drawing. But I've got no idea in OCC. I've tried to erase the earlier objects and draw the new ones with erase, clear, remove method in AIS_InteractiveContext.However ,unless I choose to eraseAll, I can never get my work done.
Yeah, does anyone can provide me with a simple sample in ruberband rectangle
I've got my own pseudocode as the followings.
void OnLButtonDown(¡¡¡¡)
{
save the point for drawing;
}
void OnMouseMove(¡¡¡¡)
{
if the point Number == 1
{
drawLine(points[0],thisPoint);//thisPoint means the point in MouseMove
myAIScontext->EraseAll();
DisplayMyShape();
}
else if point Number == 2
{
drawRectangle(Points[0],Points[1],thisPoint);//I use Three Points to Draw a //Rectangle
myAIScontext->EraseAll();
DisplayMyShape();
}
else
{
}
}
Wed, 05/05/2010 - 11:21
The code before can not get what I want, because I can not erase all the foregoing objects which I would want them to be displayed in the window.
Thu, 05/06/2010 - 11:43
You will have to use an overlay.
myLayer = new Visual3d_Layer(my_V3d_View->Viewer()->Viewer(), Aspect_TOL_OVERLAY, true);
Draw your rubberband on this layer
myLayer->Clear(); //make sure we draw on a clean layer
myLayer->SetOrtho(0, aWidth, aHeight, 0, Aspect_TOC_TOP_LEFT);
myLayer->Begin();
myLayer->SetColor(borderCol);
myLayer->SetTransparency(1.0);
myLayer->BeginPolyline();
myLayer->AddVertex(x1, y1);
myLayer->AddVertex(x2, y1);
myLayer->AddVertex(x2, y2);
myLayer->AddVertex(x1, y2);
myLayer->AddVertex(x1, y1);
myLayer->ClosePrimitive();
myLayer->End();
This ought to get you started.
Fri, 05/07/2010 - 12:40
Thanks,Leune
I've got it done with the erasing method.
myAISContext->Erase(myShape,1);
And I'll try this layer with my following work.