Hi,

I recently updated wxArt2D and I discovered a problem with
a2dCanvasObject::IsHitWorld() afterwards:

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";
                if( handle->GetName() == "MIDDLELEFT" )                 return 
"MIDDLELEFT";
                if( handle->GetName() == "UPPERMIDDLE" )                return 
"UPPERMIDDLE";
                if( handle->GetName() == "MIDDLERIGHT" )                return 
"MIDDLERIGHT";
                if( handle->GetName() == "LOWERMIDDLE" )                return 
"LOWERMIDDLE";
        }

        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";
                if( handle->GetName() == "MIDDLELEFT" )                 return 
"MIDDLELEFT";
                if( handle->GetName() == "UPPERMIDDLE" )                return 
"UPPERMIDDLE";
                if( handle->GetName() == "MIDDLERIGHT" )                return 
"MIDDLERIGHT";
                if( handle->GetName() == "LOWERMIDDLE" )                return 
"LOWERMIDDLE";
        }

        return "NOHANDLEHIT";
}



-------------------------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc.
Still grepping through log files to find problems?  Stop.
Now Search log events and configuration files using AJAX and a browser.
Download your FREE copy of Splunk now >>  http://get.splunk.com/
_______________________________________________
Wxart2d-users_dev mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/wxart2d-users_dev

Reply via email to