
www.Usenet.com
| <-- __Chronological__ --> | <-- __Thread__ --> |
Hi all,
I am here once again with my stupid querries.
But believe me its helping a lot.
I wanted to check complex dynamics and made following code
with the help of some snippets from this newsgroup only.
Please have a look. is it OK?
1. I give a point
2. In function a I create two elements , a line and a linestring
from point (0,0) and from (10,10) respectively and their
common end point is the point which I have given.
I create these two elements and set them for dynamic
descriptor.
3. I give a point again and the two elements are created and added to
file with their end point to the point passed to
function b.
4. paste dynamic gives the dynamic effect as i move cursor.
10,10
/
------- /
0,0 1st pt
10,10
\
----------\
0,0 2nd pt
Dynamic update works fine .
But as I give second point the first case also displayed and second also
,Until I give reset, first case display wont go.
Please Try to compile and run then you will know.
Could you please let me know the modification.
Any help is apreciated.
Thank you .
Lee
#include <mdl.h> /* system include files */
#include <tcb.h> /* system include files */
#include <mselems.h>
#include <userfnc.h>
void a();
void b();
Private void pasteDynamics
(
Dpoint3d *pointP, // Current cursor pos
int view
);
Dpoint3d orgPoint3d;
Dpoint3d pt[2];
MSElement lineElement, circleElement;
void main()
{
mdlOutput_prompt("Give a point");
mdlState_setFunction(STATE_DATAPOINT,a);
}
void a(Dpoint3d *a_point3d)
{
MSElementDescr *dynamicEdP;
orgPoint3d = *a_point3d;
pt[0].x=0.0;
pt[0].y=0.0;
pt[1]=orgPoint3d;
mdlLine_create(&lineElement,NULL,pt);
mdlElmdscr_new( &dynamicEdP, NULL, &lineElement);
pt[0].x=10.0*tcb->uorpersub*tcb->subpermast;
pt[0].y=10.0*tcb->uorpersub*tcb->subpermast;
mdlLineString_create(&circleElement,NULL,pt,2);
mdlElmdscr_appendElement( dynamicEdP, &circleElement);
mdlDynamic_setElmDescr (dynamicEdP);
mdlState_dynamicUpdate ( pasteDynamics, FALSE);
mdlState_setFunction(STATE_DATAPOINT,b);
mdlOutput_prompt("Give last point");
}
Private void pasteDynamics
(
Dpoint3d *pointP, // Current cursor pos
int view
)
{
Transform transform;
if (mdlElement_getType( dgnBuf) == LINE_ELM)
{
DPoint3d points[2];
points[0].x = 0.0;
points[0].y = 0.0;
points[1] = *pointP;
mdlLine_create(dgnBuf, dgnBuf, points);
}
else (mdlElement_getType( dgnBuf) == 4)
{
DPoint3d points[2];
points[0].x = 10.0*tcb->uorpersub*tcb->subpermast;
points[0].y = 10.0*tcb->uorpersub*tcb->subpermast;
points[1] = *pointP;
mdlLineString_create(dgnBuf, dgnBuf, points,2);
}
}
void b(Dpoint3d *pointP)
{
pt[0].x=0.0;
pt[0].y=0.0;
pt[1]=*pointP;
mdlLine_create(&lineElement,NULL,pt);
pt[0].x=10.0*tcb->uorpersub*tcb->subpermast;
pt[0].y=10.0*tcb->uorpersub*tcb->subpermast;
mdlLineString_create(&circleElement,NULL,pt,2);
mdlElement_add(&lineElement);
mdlElement_add(&circleElement);
mdlElement_display(&lineElement,NORMALDRAW);
mdlElement_display(&circleElement,NORMALDRAW);
mdlSystem_exit(NULL,1);
}
--
Posted via Mailgate.ORG Server - http://www.Mailgate.ORG
| <-- __Chronological__ --> | <-- __Thread__ --> |