Welcome to Dream.In.Code
Become a C++ Expert!

Join 150,221 C++ Programmers for FREE! Get instant access to thousands of C++ experts, tutorials, code snippets, and more! There are 2,168 people online right now. Registration is fast and FREE... Join Now!




creating an object (array)?

 
Reply to this topicStart new topic

creating an object (array)?

didgy58
7 Nov, 2007 - 01:03 PM
Post #1

D.I.C Head
**

Joined: 23 Oct, 2007
Posts: 218



Thanked: 1 times
My Contributions
hi guys, i just need a little help, ive created a function using the mouseclick that when a user clicks the mouse it draws a coil on the screen from that specified point. now the problem im having is that i can draw over it by clicking next to it , this is something i would like to stop, when i move the mouse over the coil i would like it to recognise that there is an object there and not be able to draw over it, and also from there i could implement a right mouse button command which would let me rotate the coil.

the question is how would i go about this im totally stuck with this part.

the code for my coil drawing is as follows.

CODE


void Ccoils2View::OnLButtonDown(Unit nFlags, CPoint point)

CView::OnLButtonDown(nFlags, point);

CDC *pDC=GETDC();
Ccoils2Doc*pDoc=GetDocument();
ASSERT_VALID(pDoc);
if (!pDoc)
return;

int angle ,z=0;
int x=0;
int y=0;
int x0=point.x;
int y0=point.y;

for (angle=0;,angle<105;angle++)
{

y=20*sin(angle*6.28/30+3.14);
x=20*cos(angle*6.28/30+3.14);
pDC->MoveTo(x+x0+angle,y+y0);
y=20*sin((angle+1)*6.28/30+3.14);
y=20*cos((angle+1)*6.28/30+3.14);

pDC->LineTo(x+x0+angle,y+y0);
}
}





im not sure if this makes much sense to you all out there,

here are the main things that im stuck on,

making the program recognise that there is an object already drawn there so that i can edit the rotation of it in the future and also not allow the program to drawn a new image over it

thanks again

dan.

This post has been edited by jjhaag: 7 Nov, 2007 - 07:46 PM
User is offlineProfile CardPM
+Quote Post

didgy58
RE: Creating An Object (array)?
7 Nov, 2007 - 01:26 PM
Post #2

D.I.C Head
**

Joined: 23 Oct, 2007
Posts: 218



Thanked: 1 times
My Contributions
been doin a bit more thinking on this, would i need to make a object that stores the four corner points of the space that the coil takes up and save them in an array

i.e. array 1(topleft,topright,bottomleft,bottomright) all these saved as x,y and then from here the points could be used to let the program know that there is an object in that specific place???

or is there another way that this would need to be done. is it possible to have four different values stored in a single array ie for coil 1(4 interger values)?

the more i think about this the more im getting confused.. anyhelp would be very much appreciated. maybe not even help with code but how to go about it as im stuck on that bit itself..

thanks again

dan.
User is offlineProfile CardPM
+Quote Post

Reply to this topicStart new topic
Time is now: 1/9/09 05:43AM

Be Social

Dream.In.Code RSS Feed Dream.In.Code LinkedIn Group Follow Us On Twitter

Live C++ Help!

C++ Tutorials

Reference Sheets

C++ Snippets

DIC Chatroom

Bye Bye Ads

Monthly Drawing

Thumb Drive

Top Contributors

Top 10 Kudos This Month