I'm making a simple drawing application that uses vectors to draw things onto the screen (boy that was a weirdly worded sentence). Anyways, when the user clicks on the drawing space with the brush setting on, I need to:
1: Create a new object that contains the points of the line
2: Create a dynamic array containing all the points on that line
3: Append the new object onto a main array, so I can loop through that array and draw each line.
Does anyone know how I would do this? I don't know how to use wxArrays or wxLists, those macros creating them confuse me. Explanation?
Also, on a side note (but still relating to my program), does anyone know how to draw antialiased lines in wxWidgets?
Array of Array of wxPoints Topic is solved
-
- Ultimate wxWidgets Guru
- Posts: 536
- Joined: Fri Jan 07, 2005 3:44 pm
- Location: Finland
- Contact:
In your hpp file:
and at the end of your cpp file:
Code: Select all
WX_DECLARE_OBJARRAY(wxPoint, PointArray);
WX_DECLARE_OBJARRAY(PointArray, PointArrayList);
Code: Select all
#include <wx/arrimpl.cpp>
WX_DEFINE_OBJARRAY(PointArray);
WX_DEFINE_OBJARRAY(PointArrayList);
Visual C++ 9.0 / Windows XP Pro SP3 / wxWidgets 2.9.0 (SVN) | Colligere
All right, but how would I use that in my program? Do I have to create a new PointArrayList object? And how would I dynamically add some PointArrays to PointArrayList?
Thanks!
EDIT: Nevermind, it turns out that I do need to create a new PointArrayList object, and new PointArrays. I did this by putting "static PointArray *temp = NULL" in my mouse click event handler, and when the mouse button is down, I use "new" to allocate it, and when the mouse is up, I use temp->Clear and temp = NULL.
Thanks, hopefully my software will be finished soon!
Thanks!
EDIT: Nevermind, it turns out that I do need to create a new PointArrayList object, and new PointArrays. I did this by putting "static PointArray *temp = NULL" in my mouse click event handler, and when the mouse button is down, I use "new" to allocate it, and when the mouse is up, I use temp->Clear and temp = NULL.
Thanks, hopefully my software will be finished soon!
Now I'm having a problem getting PointArrays from the main PointArrayList. I do:
But that crashes as soon as it gets to p.Item(0). Can anyone help?
Code: Select all
PointArray p = pointlist.Item(0);
wxPoint point = p.Item(0);
-
- Earned some good credits
- Posts: 109
- Joined: Fri Sep 03, 2004 9:30 am
- Location: Brescia, Italy
Have you inserted some items before the .Item(0) call?ionstream wrote:Now I'm having a problem getting PointArrays from the main PointArrayList. I do:
But that crashes as soon as it gets to p.Item(0). Can anyone help?Code: Select all
PointArray p = pointlist.Item(0); wxPoint point = p.Item(0);
Sandro Sigala - Kynosoft, Brescia