Locate functionality a bit dodgy

Status
Not open for further replies.

Andrew Lowe

Usenet Archive
Joined
Jul 8, 2000
Messages
27
Reaction score
0
Hi all,
I have some functionality where a user can select a text element, accept it, select a near by line, accept it and then the text will be aligned parallel to the selected line. If the user then selects another line, the text, which represents a number, will be incremented, a new element created and then placed next to the newly selected line and so on, select line, increment number, place new text, select line, increment number, place.......

I have filters in place, mdlLocate_setElemSearchMask set to find only text when I am looking for text and lines when I am looking for lines. There are also some mdlLocate_setFunction(LOCATE_POSTLOCATE, XXX) to make sure some selection criteria are obeyed.

The problem arises if I start the functionality and then before I select any text, select, say, the delete command, delete something and then restart the functionality. I would expect it to work as expected, select the text, accept, select the line...., but instead it applies the selection criteria for the lines, the second stage, for the first stage and disallows the selection of the text. It displays the correct prompts but does not accept my text selection. Debugging printf's reveal that it is using the line selection criteria. Has anyone come across this sort of problem before, the wrong selection criteria being applied when I am trying to select something? Is there a way of totally restarting the selection process? I have

mdlState_clear;
mdlState_startDefaultCommand;
mdlCurrTrans_clear;
mdlLocate_normal;

already at the top of the functionality to try and reset things but nothing seems to work.

Any ideas would be greatly appreciated.

Regards,
Andrew Lowe
 
Andrew ...

I have some functionality where a user can select a text element, accept it, select a near by line, accept it and then the text will be aligned parallel to the selected line.

I have filters in place, mdlLocate_setElemSearchMask set to find only text when I am looking for text and lines when I am looking for lines. There are also some mdlLocate_setFunction(LOCATE_POSTLOCATE, XXX) to make sure some selection criteria are obeyed.

The problem arises if I start the functionality and then before I select any text, select, say, the delete command, delete something and then restart the functionality. I would expect it to work as expected, select the text, accept, select the line...., but instead it applies the selection criteria for the lines,

If your command starts by setting up MicroStation's state machine (i.e. mdlState_startPrimitive or mdlState_startModifyCommand ), then whenever another command starts a primitive your state machine should be cancelled.

Even if you are not using one of those functions in your command, you can alway do this to ensure that MicroStation knows to initialise the state machine:

void cmdLocateLineAndText (void)
cmdNumber CMD_LOCATE_LINE_AND_TEXT
{
mdlState_startPrimitive (NULL, NULL, CMD_MESSAGE_ID, PROMPT_MESSAGE_ID);

...
...
}

You can also add specific directives in your subsequent location code that tell MicroStation what to do when the user does <reset> during the command:
mdlState_setFunction (STATE_RESET, functionThatPerformsResetStuff);

void functionThatPerformsResetStuff (void) {
...
...
//optionally
// mdlState_restartCurrentCommand ;
}
 
Nice try Jon, but unfortunetly no cigar.

If you are used to the weird and whacky ways of MDL, you will appreciate this one. The original functionality I referred to allowed the user to select a text string that contained numbers, the selected text was then incremented and the user then prompted to select a line to place the incremented number next to. This increment number/place next to line loop then went on as long as the user wanted, building upon the initially selected text. My original problem was that if the function was terminated, select the element selection tool, select "draw a line" etc and then the function restarted, the element selection and filtering was all screwed up, you couldn't select the initial piece of test, it wanted a line.

Something I think I didn't originally mention was that there was also a small dialogue box that popped up at the start of the functionality which displayed the incremented number and the increment value. After much buggerising around, and trying Jon's suggestion as well, I eventually discovered that it was the MDL function mdlDialog_itemsSynch that caused the problem. I commented out the part of code that updated my litle dialogue box and the thing now works fine. I then tried updating the dialogue with all of the synch functions I could find but it still caused the dodgy behaviour. So if anyone can explain this one, it would be greatly appreciated.

To paraphrase, does anyone know of any restrictions on updating dialogue box items, pushing text into a text thingy, whilst in the process of doing some mdlState_startModifyCommand/mdlLocate_restart stuff. Any thoughts greatly appreciated.

Regards,
Andrew Lowe

"Jon Summers" wrote:
Andrew ...

> I have some functionality where a user can select a text element,
[SNIP]
...
...
[SNIP]
If your command starts by setting up MicroStation's state machine (i.e. mdlState_startPrimitive or mdlState_startModifyCommand ), then whenever another command starts a primitive your state machine should be cancelled.

Even if you are not using one of those functions in your command, you can alway do this to ensure that MicroStation knows to initialise the state machine:

void cmdLocateLineAndText (void)
cmdNumber CMD_LOCATE_LINE_AND_TEXT
{
...
 
Andrew ...

My original problem was that if the
function was terminated, select the element selection tool, select "draw a line" etc and then the function restarted, the element selection and filtering was all screwed up, you couldn't select the initial piece of test, it wanted a line.

The MicroStation primitive has cleared the state machine. When your command starts, it should be as if it had never been invoked previously. If the locate logic is behaving oddly, maybe you have some static variables around that need to be reinitialised. That is, the mdlLocate_init, mdlLocate_noElemNoLocked , and mdlLocate_setElemSearchMask should probably be called right at the start of your command.

Something I think I didn't originally mention was that there was also a small dialogue box that popped up at the start of the functionality
Is the dialog modal? A modeless dialog should give you any problem. What variable are you using to display the node increment value?
 
Status
Not open for further replies.

Latest threads

Back
Top