How to change locate criteria during 'mdlState_startModifyCommand'?

Status
Not open for further replies.

foo

Usenet Archive
Joined
Sep 9, 2001
Messages
144
Reaction score
0
Hi, everyone

I am using mdl function 'mdlState_startModifyCommand' to sart a modify command which first locate a line element and second locate a shape element. How to implement this? My code is as following, it does not start second location.

boolean identifyState;

Private void filterElems (int preLocate, MSElementUnion *elmP, int fileNum, ULong filePos) { if (identifyState){ // accept shape and reject all other elems }else{ // accept line and reject all other elems } } Public void startCmd (void) { mdlLocate_allowLocked ; mdlState_startModifyCommand (startCmd, acceptShapeFunc, NULL, acceptLineFunc, NULL, 13, 1, FALSE,
1);
mdlLocate_setFunction (LOCATE_POSTLOCATE, filterElems); mdlLocate_init ; }

Any help is greatly appreciated.

Foo.
 
I am using mdl function 'mdlState_startModifyCommand' to sart a modify command which first locate a line element and second locate a shape element. How to implement this? My code is as following, it does not start second location.

The mdlState_xxx functions let you create a state machine. For a simple primitive operation (e.g. place cell) there are three states:
1 Initialise command
2 Dynamics
3 Datapoint

For a PLACE LINE command, you need an extra state to capture the end-point of the line:
1 Initialise command
2 Datapoint1
3 Dynamics
4 Datapoint2

After the first mdlState_xxx function, you can modify or extend the state machine using, for example, mdlState_setFunction (STATE_DATAPOINT, yourFunctionName);

The mdlState_startModifyCommand initialises the state machine. In your case, you want to add an extra locate state after the first locate is complete.
One way to do this is:
mdlState_startModifyCommand (resetFunc, stateLocate1, NULL, NULL, ...);

void stateLocate1 (DPoint3d *pt, int view) {
// This is the accept function established by the first call to // mdlState_startModifyCommand ; int fileNum1 = 0; ULong filePos1= mdlElement_getFilePos (FILEPOS_CURRENT, &fileNum1; // You probably want to save the filePos1& fileNum1of the first // locate at this point

// Start a second locate state machine
mdlState_startModifyCommand (resetFunc, stateLocate2, NULL, NULL, ...); } void stateLocate2 (DPoint3d *pt, int view) { // This is the accept function established by the second call to // mdlState_startModifyCommand ; int fileNum2 = 0; ULong filePos2 = mdlElement_getFilePos (FILEPOS_CURRENT, &fileNum2; // You probably want to save the filePos2 & fileNum2 of the second // locate at this point

mdlState_restartCurrentCommand ;
}
 
Mr. Jon

I am very appreciated for your response. But the two
'mdlState_startModifyCommand' is not suitable for me because two 'mdlState_startModifyCommand' need four points (1. identify first elem; 2. accept first elem; 3. identify second elem; 4. accept second elem). I want user enter two data points to select two elems like MS command extend tool.

In 2001-05-18 12:56:04 PST 'Re: Reset' message, you had said to Mr. om that we can identify first elem in 'showFunc', identify second elem in 'acceptFunc'. I just want so, but need to change locate criteria after accept first elem. This is my problem. Sorry for my English.

Foo.
 
I am very appreciated for your response. But the two
'mdlState_startModifyCommand' is not suitable for me because two 'mdlState_startModifyCommand' need four points (1. identify first elem; 2. accept first elem; 3. identify second elem; 4. accept second elem). I want user enter two data points to select two elems like MS command extend tool.

If you don't want to use 'mdlState_startModifyCommand' twice, then you must do something like this:
1 Use mdlState_startModifyCommand (resetFunc, acceptFunc1, ...) to start your state machine 2 In the first accept function, modify the state machine and locate logic to look for a second element void acceptFunc1 (DPoint3d *pt, int view) { // Save current element's file position in globals g_filePos1 = mdlElement_getFilePos (FILEPOS_CURRENT, &g_fileNum1); mdlState_setFunction (STATE_DATAPOINT, acceptFunc2); mdlLocate_restart ; } void acceptFunc2 (DPoint3d *pt, int view) { int fileNum2; ULong filePos2 = mdlElement_getFilePos (FILEPOS_CURRENT, &g_fileNum2);

// Now you have g_filePos1, g_fileNum1
// and filePos2, fileNum2
// You can read both elements and do whatever you want MSElement_descr *pElm1 = NULL; MSElement_descr *pElm2 = NULL;

mdlElmdscr_readToMaster (&pElm1, g_filePos1, g_fileNum1, FALSE, NULL); mdlElmdscr_readToMaster (&pElm1, filePos2, fileNum2, FALSE, NULL);

// ...

if (pElm1)
mdlElmdscr_freeAll (&pElm1);
if (pElm2)
mdlElmdscr_freeAll (&pElm2);
mdlState_restartCurrentCommand ;
}
 
Hi foo,

Have a look at the element location logic in
http://members.tripod.ca/mindseye/Pipend.html. It identifies two elements and then generates dynamic elements until a third data point is entered. The logic is not very pretty, but it works well.
 
Status
Not open for further replies.

Latest threads

Back
Top