ilnumerics - Plotcube with a fixed display area and customized double-click-handler -


i need plotcube fixed display area , double click handler restores view. derived class ilplotcude , put following code setting limits in constructor:

: float max = 1000f; limits.ymax = max; limits.xmax = max; limits.zmax = max; limits.ymin = -max; limits.xmin = -max; limits.zmin = -max; aspectratiomode = aspectratiomode.maintainratios; : 

i have installed doubleclick-handler in class code above , additional line reset rotation:

: if (args.cancel) return; if (!args.directionup) return; rotation = matrix4.identity; float max = 1000f; limits.ymax = max; limits.xmax = max; limits.zmax = max; limits.ymin = -max; limits.xmin = -max; limits.zmin = -max; aspectratiomode = aspectratiomode.maintainratios;  args.refresh = true; args.cancel = true; : 

the handler executed nothing happens. testing purposes, put same code directly function onmousedoubleclick of of base class ilplotcube (instead of function call reset ()). works expected, cannot final solution.

has idea, what's wrong ?

a mouse event handler commonly registered on global scene. each panel / driver creates own synchronized copy of scene rendering afterwards. user interacts synchronized copy rotation, pan etc. , synchronized copy fires event handlers.

but since custom event handler has been registered on global scene, handler functions executed on node object within global scene. therefore, 1 should use sender object provided event handler in order access scene node objects.

this example register mouse handler on first plot cube object contained in common (global) scene. handler reset scene custom view:

ilpanel1.scene.first<ilplotcube>().mousedoubleclick += (s,a) => {      // need true target of event. may differs 'this'!     var plotcube = s ilplotcube;      // event sender modified:      plotcube.rotation = matrix4.identity;     float max = 1000f;     plotcube.limits.ymax = max;     plotcube.limits.xmax = max;     plotcube.limits.zmax = max;     plotcube.limits.ymin = -max;     plotcube.limits.xmin = -max;     plotcube.limits.zmin = -max;     plotcube.aspectratiomode = aspectratiomode.maintainratios;      // disable default double click handler reset scene     a.cancel = true;     // trigger redraw of scene     a.refresh = true; }; 

inside handler, fetch reference scene object ilpanel.scene.first<ilplotcube>().... instead, take object provided s target of fired event. corresponds synchronized version of plot cube - 1 used rendering. use instead , changes show properly.


Comments

Popular posts from this blog

python - Subclassed QStyledItemDelegate ignores Stylesheet -

java - HttpClient 3.1 Connection pooling vs HttpClient 4.3.2 -

SQL: Divide the sum of values in one table with the count of rows in another -