Hallo everyone,
I am trying to write an MDL that recenters certain views when a datapoint or tentative Point is placed in a specified distance from the last one.
For this task I want to use e.g. the mdlState_setFunction(STATE_DATAPOINT, centre2_processDataPoint) with the user function 'centre2_processDataPoint'. So where can i find the possible Parameters for this function? I would like to have e.g. something like:
bool centre2_processDataPoint(( Dpoint3d *datapointP, // Pointer to placed datapoint int view // View-number in datapoint was placed){ ... }
bool centre2_processDataPoint(
(
Dpoint3d *datapointP, // Pointer to placed datapoint
int view // View-number in datapoint was placed
)
{ ... }
Because the distance for which an update of a view should take place is depending on the size of the view, I would need as well a user function that is called by mdlWindow_setFunction(WINDOW_MODIFYEVENTS , centre2_viewChanged) with a user function like this:
bool centre2_viewChanged(( int event, // Event-Type int viewNr // View-Number){...}
Where can I find possible Parameters for a user function that is set for a certain Event in mdlWindow_setFunction, mdlView_setFunction, mdlState_setFunction etc.?
So I am not sure where I can find the possible Parameters for user functions that are set for a certain event-Typ (like mdlWindow_setFunction, mdlView_setFunction, mdlState_setFunction etc.), to be sure that only Parameters are used that can be filled and used properly.
Many thanks for any help,
Ines Wieland
Hi Ines,
please (please please please please) read and follow best practices!
How you question can be answered when it's not clear what version do you use? I am aware of V8i tag, but (at first) there are many V8i versions available and (at second) your code, based on C style events monitoring, looks more like V8.0 code or (at the best case) V8 2004 Edition.
Is there any reason why modern C++ API is not used (with appropriate "tool classes")?
With regards,
Jan
Bentley Accredited Developer: iTwin Platform - AssociateLabyrinth Technology | dev.notes() | cad.point
Hi Jan,
I beg you pardon for not having followed the best practice rules! (Is there any way to 'repair' this mistake, by changing the subject somehow?)
The MDL I am trying to create should be for Microstation V8i SELECTseries 10 (german) in C/C++.
But I have to admit that I am more familiar with old C Style MDLs (because most of our existing MDLs from my predecessor were made in that way), than with the modern C++ API, which I understood is something like an Extension, that does not replace all old functionality. Or does it?
(If there is a way to get better Knowledge about the usage of the C++ API let me know!)
Many thanks and Kind regards,
Ines
I beg you pardon, but on Friday I seemed to be a little bit to enthusiastic, because I didn't noticed that I still used the mdlView_setFunction (VIEW_MOTION, <function-name>) instead of the mdlState_setFunction(STATE_DATAPOINT, <function-name>), which was done for testing-purposes only.
With the mdlView_setFunction the recentering-function for the other views is permanently called, when the mouse is moved, even after a reset or during a primitive-command (like e.g. placing a smartline), but not only for single datapoint-events.
As soon as I replace the mdlView_setFunction with the mdlState_setFunction(STATE_DATAPOINT, <function-name>) it only works directly after the start of the MDL, but will not work anymore after using the reset-button or after starting a primitive-command. So this seemed to be the same Problem, than with the MstnViewTool i tested, which you told me is assumed behaviour.
Is there any other possibility (than given with the mdlView_setFunction-variations) to create something like a "Background"-function that is called every-time a datapoint or tentative-Point is placed, no matter if it is during a primitive-command or not?
I saw a huge number of *_setFunctions in the Function reference Manual, but have no idea, if one of these other functions would help me to solve my Problem.
Many thanks and best regards
Ines Wieland said:Is there any other possibility
maybe it's the right time to stop focusing and discussing functions/methods and to specify exactly what functionality do you need to ensure. I am aware it's maybe already written in this discussion, but it has become quite long ;-)
As far as I see your problem, you want to monitor when mouse data point is clicked in a view, completely independently from "active tool mechanism" (state machine)? Consequently, you would like to receive the button pressed even notification regardless what tool is active?
Regards,
yes I would like to have a function, that is called when a mouse data Point is placed in a view, independ from the active view-tool or primitive-tool.
(The aim is to recenter specified other views [that may have different zoom, orientation or Levels displayed] if the "active" coordinate from data-point is too far from the old view-center away. The permanent recentering with the usage of the VIEW_MOTION-Event seems to be to much in case of big data and/or attached raster-data).
Ines Wieland said: I would like to have a function, that is called when a mouse data Point is placed in a view, independ from the active view-tool or primitive-tool
If a view motion callback is too data-intensive then perhaps a global locate callback would do what you want?
Regards, Jon Summers LA Solutions
Ines Wieland said: that is called when a mouse data Point is placed in a view, independ from the active view-tool or primitive-tool.
in such case I guess mdlState_setFunction with STATE_DATAPOINT parameter is the only way.
I think all other information necessary to change another view can be retrieved through API when STATE_DATAPOINT callback is triggered.
Ines Wieland said:The permanent recentering with the usage of the VIEW_MOTION-Event seems to be to much in case of big data and/or attached raster-data).
Yes, when implemented in simple synchronous way. To monitor and react on view redraw (or any other change) should be avoided as much as possible, but sometimes it's necessary. In such case, I guess to implement some reactive observer, that is able to filter consequent stream of events, and to react only to the last one (when nothing new happens for defined amount of time, is necessary. Often it leads to quite complex code.
Hi Jon,
if I understand correctly you propose to use the mdlLocate_setFunction(LOCATE_GLOBAL_LOCATE, <function-name>) to solve the Problem. But where can I find the Parameters, that can be used for the corresponding user-callback-function??
(That is a general question for ALL*_setFunction, because there is no such Information in the header-files !)
Many thanks and best regards,
Ines Wieland said:if I understand correctly you propose to use the mdlLocate_setFunction(LOCATE_GLOBAL_LOCATE, <function-name>)
I would start with mdlState_setFunction(STATE_DATAPOINT, stateFunc), but I am not sure whether it's reset or not when primitive command is started (in other words, whether there can be more state functions registered for one event). It's long time I worked with these functions and now with powerful C++ classes, it seems I have become a bit lazy ;-)
Ines Wieland said:That is a general question for ALL*_setFunction, because there is no such Information in the header-files !
Yes, that's true. CONNECT Edition doc contains the functions descriptions, but I am not sure how it can be compared with V8i ... my assumption is that many from them are pretty the same.
Ines Wieland said:That is a general question for all *_setFunction, because there is no such information in the header-files!
*_setFunction
Yes: that problem first arose with MDL for V8, which is now two decades ago! I retained the MDL help file for MDL V7, because that contains the relevant function prototypes. Despite my several complaints to Bentley Systems, the prototypes never made it into the documenation or the header files.
Ines Wieland said:you propose to use the mdlLocate_setFunction
Yes: but I see that there is a better way with the MicroStationAPI.
mdlLocate_setFunction has been superceded by typesafe methods in LocateCallback. Use these methods to designate user functions to be called during MicroStation's element location process.
You might try SetGlobalPreLocateFunction.
SetGlobalPreLocateFunction
Jon Summers said:You might try SetGlobalPreLocateFunction
is this really a Function of the MicroStationAPI for v8i (or for Connect-Version)? Because I could not find it, or i misunderstood something (part of which class is this function?).
Best regards,
Oops! SetGlobalPreLocateFunction is CONNECT. For V8i you should use mdlLocate_setFunction (LOCATE_PRELOCATE, yourCallback).
mdlLocate_setFunction (LOCATE_PRELOCATE, yourCallback)