Hi again,
I still have the following problem with a2dCanvasObject::IsHitWorld()
after my recent update of wxArt2D:
To me it seems that you have replaced:
a2dIterC ic( canvasView );
a2dCanvasObject *handle = obj->IsHitWorld( ic, x, y, wxLAYER_ALL,
a2dCANOBJHITOPTION_NOROOT );
which worked fine for me with:
a2dIterC ic( canvasView );
ic.SetPerLayerMode( true );
a2dHitEvent hitEvent = a2dHitEvent( x, y, false );
a2dCanvasObject *handle = obj->IsHitWorld( ic, hitEvent );
what I would suppose to do exactly the same but unfortunately never
finds an object.
I think I'm missing something important here but cannot figuere it out
myself. Could you help me, please?
Please see my code below.
Best regards
Glaz
void MyToolController::OnMouseEvent( wxMouseEvent& event )
{
double mx = event.GetX();
double my = event.GetY();
//to world coordinates to do hit test in world coordinates
double xw = GetCanvasView()->GetDrawer2D()->DeviceToWorldX( mx );
double yw = GetCanvasView()->GetDrawer2D()->DeviceToWorldY( my );
a2dCanvasObject *a2dCanObj = GetCanvasView()->IsHitWorld( xw, yw );
// The mouse is moving.
if( event.Moving() )
{
// The mouse is over an object.
if( a2dCanObj )
{
// Test if the mouse hit a handle.
// Old way - not working anymore since the wxArt2D update.
std::string handleHit = HitTest::handleHit( dguie, xw, yw,
GetCanvasView() );
// New way - never finds a handle.
std::string handleHit = HitTest::handleHit_2( dguie, xw, yw,
GetCanvasView() );
// Now do something with the found handle if a handle
// has been found.
}
}
// Old and formerly working way of doing the hit test.
// A static method.
std::string HitTest::handleHit( a2dCanvasObject *obj, double x, double
y, a2dCanvasView *canvasView )
{
a2dIterC ic( canvasView );
a2dCanvasObject *handle = obj->IsHitWorld( ic, x, y, wxLAYER_ALL,
a2dCANOBJHITOPTION_NOROOT );
if( handle )
{
if( handle->GetName() == "LOWERLEFT" ) return "LOWERLEFT";
if( handle->GetName() == "UPPERLEFT" ) return "UPPERLEFT";
if( handle->GetName() == "UPPERRIGHT" ) return "UPPERRIGHT";
if( handle->GetName() == "LOWERRIGHT" ) return "LOWERRIGHT";
}
return "NOHANDLEHIT";
}
// New but not working way of doing the hit test.
// A static method.
std::string HitTest::handleHit_2( a2dCanvasObject *obj, double x, double
y, a2dCanvasView *canvasView )
{
a2dIterC ic( canvasView );
ic.SetPerLayerMode( true );
a2dHitEvent hitEvent = a2dHitEvent( x, y, false );
//a2dCanvasObject *handle = obj->IsHitWorld( ic, hitEvent );
a2dCanvasObject *handle = obj->ChildIsHitWorld( ic, hitEvent );
if( handle )
{
if( handle->GetName() == "LOWERLEFT" ) return "LOWERLEFT";
if( handle->GetName() == "UPPERLEFT" ) return "UPPERLEFT";
if( handle->GetName() == "UPPERRIGHT" ) return "UPPERRIGHT";
if( handle->GetName() == "LOWERRIGHT" ) return "LOWERRIGHT";
}
return "NOHANDLEHIT";
}
-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2005.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
Wxart2d-users_dev mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/wxart2d-users_dev