Hi Mike,

How about make your own derived a2dDrawing class, and do intercept the events 
given down here:
(first just put break points at those, to see when they are issued)
I assume you have tools and undo redo with the commandprocessor on the 
a2dDrawing.
You need to set that drawing to your a2dCanvas.

SO in you own drawing class, you can do things like next, this at least should 
tell you that 
rectangles are added are removed.
For change rectangles, maybe the OnChangeDrawings can helps you.
The rect changed should have pending flag set. So iterate the objects, and test 
on that.

If that is not enough, make your own derived rectangle, and via its m_root, you 
can call functions 
in your MyDRawing class.
Like when editing is busy/done, or its pending flags gets set. See the virtual 
a2dCanvasObject::SetPending() which you can override in your own rect object.
See the editing functionality in a2dRect, and how to get to the original 
object, and not the editcopy.

Hope this helps, else mail again.

Regards,

Klaas

void MyDrawing::OnDoEvent( a2dCommandProcessorEvent& event )
{
     a2dCommand *command = event.GetCommand();
     const a2dCommandId* comId = command->GetCommandId();

     if ( ( comId == &a2dCommand_AddObject::Id ) )
     {
         a2dCanvasObject *obj = wxDynamicCast(command, 
a2dCommand_AddObject)->GetCanvasObject();
         a2dRect* rect = wxDynamicCast( obj, a2dRect );
         if (rect)
         {
             wxLogDebug( wxString::Format("Do AddObject: %s, %p", 
rect->GetClassInfo()->GetClassName(), rect) );
         }
     }
     else if ( ( comId == &a2dCommand_AddObjects::Id ) )
     {
         a2dCanvasObjectList& objlist = wxDynamicCast(command, 
a2dCommand_AddObjects)->GetObjectList();
         for( a2dCanvasObjectList::iterator iter = objlist.begin(); iter != 
objlist.end(); ++iter )
         {
             a2dRect* rect = wxDynamicCast( (*iter).Get(), a2dRect );
            if  (rect)
           {
             wxLogDebug( wxString::Format("Do AddObject: %s, %p", 
rect->GetClassInfo()->GetClassName(), rect) );
           }

         }
     }
     else if ( ( comId == &a2dCommand_ReleaseObject::Id ) )
     {
         a2dCanvasObject *obj = wxDynamicCast(command, 
a2dCommand_AddObject)->GetCanvasObject();
         a2dRect* rect = wxDynamicCast( obj, a2dRect );
         if (rect)
         {
             wxLogDebug( wxString::Format("Do AddObject: %s, %p", 
rect->GetClassInfo()->GetClassName(), rect) );
        }
     }
     else
     {
         //wxLogDebug( wxString::Format("Do Cmd Name: %s", comId->GetName() ) );
     }
     event.Skip();
}



BEGIN_EVENT_TABLE( a2dDrawing, a2dObject )
     EVT_IDLE( a2dDrawing::OnIdle )
     EVT_COM_EVENT( a2dDrawing::OnComEvent )
     EVT_NEW_CAMELEON( a2dDrawing::OnAddCameleon )
     EVT_DO( a2dDrawing::OnDoEvent )
     EVT_UNDO( a2dDrawing::OnUndoEvent )
     EVT_REDO( a2dDrawing::OnRedoEvent )
     EVT_CHANGEDMODIFY_DRAWING( a2dDrawing::OnChangeDrawings )
END_EVENT_TABLE()


void a2dDrawing::OnDoEvent( a2dCommandProcessorEvent& event )
{
     if ( event.GetCommand()->Modifies() )
         Modify( true );
}

void a2dDrawing::OnRedoEvent( a2dCommandProcessorEvent& event )
{
     if ( event.GetCommand()->Modifies() )
         Modify( true );
}

void a2dDrawing::OnUndoEvent( a2dCommandProcessorEvent& event )
{
     if ( event.GetCommand()->Modifies() )
         Modify( false );
}

void a2dDrawing::OnChangeDrawings( a2dDrawingEvent& event )
{
     event.Skip();
}

void a2dDrawing::Modify( bool increment )
{
     if ( increment )
         m_documentModified++;
     else
         m_documentModified--;

     a2dDrawingEvent event( 0, wxEVT_CHANGEDMODIFY_DRAWING, this );
     event.SetEventObject( this );
     event.SetModified( increment ? +1 : -1 );
     if ( !ProcessEvent( event ) )
     {
         //parent is processed in ProcessEvent() already
     }
}



On 10/27/2016 12:10 AM, Mike Gibson wrote:
> Hi Klaas,
>
> My IDE marked them as errors. I didn't notice that they were only warnings. I 
> got the first 
> problem fixed. BUT I'm having a lot of difficulty getting events connected 
> properly in wxArt2d. I 
> was hoping you could steer me in the right direction. Here's what I have (and 
> need):
>
> I have a wxDialog which has a a2dCanvas in it. I want the user to be able to 
> draw and edit 
> rectangles on the canvas, but I need to capture data about the rectangles. 
> The only things I need are:
> - I need to know when a new rectangle is created, and need to get a pointer 
> to the rectangle.
> - I need to know when an existing rectangle is edited (moved or resized 
> only), and be able to 
> access the new dimensions of the rectangle.
>
> I've tried connecting wxEVT_CANVASOBJECT_RESIZE_EVENTs to the rectangle and 
> giving the rectangle 
> an event handler function, I've tried the same giving my wxDialog class the 
> event handler 
> function. I've tried connecting many different types of events to the 
> a2dstToolContr, I've tried 
> deriving my own rectangle class and connecting events, I've tried deriving my 
> own tool control 
> from a2dstToolContr and connecting events, I've tried getting events from the 
> a2dDrawRectangleTool, and I can't get anything to work.
>
> How do I capture these events?
>
> I appreciate how responsive you are, thanks!
> - Mike


------------------------------------------------------------------------------
The Command Line: Reinvented for Modern Developers
Did the resurgence of CLI tooling catch you by surprise?
Reconnect with the command line and become more productive. 
Learn the new .NET and ASP.NET CLI. Get your free copy!
http://sdm.link/telerik
_______________________________________________
Wxart2d-users_dev mailing list
Wxart2d-users_dev@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/wxart2d-users_dev

Reply via email to