ok sorry I just realize after typing the last message that pin need a
canvasobject parent
My tool work but I would like to avoid to put pins on the same place
or to close from
another one, but the problem is that pin is not add immediately when I
click so if I click
fast severals pins can be put at the same point here's the code
if (!m_active)
{
event.Skip();
return;
}
if ( GetBusy() )
GetCanvasView()->SetCursor( m_toolBusyCursor );
else
GetCanvasView()->SetCursor( m_toolcursor );
m_x = event.GetX();
m_y = event.GetY();
MouseToToolWorld( m_x, m_y, m_xwprev, m_ywprev );
double unRestx = m_xwprev;
double unResty = m_ywprev;
a2dRestrictionEngine *restrict = a2dCanvasGlobals->GetRestrictionEngine();
if(restrict)
restrict->RestrictPoint(m_xwprev, m_ywprev);
if (event.LeftDown() && !GetBusy())
{
a2dGetCmdh()->SetLastXyEntry( m_xwprev, m_ywprev );
a2dCanvasObject* hitobject = GetCanvasView()->IsHitWorld(
m_xwprev, m_ywprev, wxLAYER_ALL, a2dCANOBJHITOPTION_LAYERS );
//click on object
if(hitobject == NULL)
{
wxMessageBox(_("A Pin must placed on an object"),
_("Pin"), wxICON_INFORMATION | wxOK);
return;
}
//check if there is not a pin too close
//for all children
for( a2dCanvasObjectList::iterator iterp =
hitobject->GetChildObjectList()->begin(); iterp !=
hitobject->GetChildObjectList()->end(); ++iterp )
{
a2dPin* pin = wxDynamicCast( (*iterp).Get(), a2dPin );
if (pin!=NULL)
{
//compute distance
float distance = sqrtf(
powf((pin->GetAbsX()-m_xwprev),2.0f) +
powf((pin->GetAbsY()-m_ywprev),2.0f));
if(distance <= m_minRadius)
{
wxMessageBox(_("Pin to close from another one (min
radius = ")+wxString::Format(wxT("%f"),m_minRadius)+wxT(" )"),
_("Pin"), wxICON_INFORMATION | wxOK);
return;
}
}
}
EnterBusyMode();
// add the pin connections in an undoable way
a2dPin* pin = new a2dPin(hitobject, wxT("PinIn"),
a2dPinClass::ObjectInput, m_xwprev-hitobject->GetBboxMinX(),m_ywprev
-hitobject->GetBboxMinY());
GetCanvasCommandProcessor()->Submit( new a2dCommand_AddObject(
pin->GetParent(), pin), true ); //this makes it save
FinishBusyMode();
}
else
event.Skip();
}
-------------------------------------------------------------------------
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