| Author |
Topic  |
|
|
phla8271
Czech Republic
Posts |
Posted - 08/10/2004 : 1:10:36 PM
|
Hi, I have written a script where i can select some region by putting lines(restricted to move in X axis only) , that are named GraphObjects. There is a script asociated with every line that reacts on every move of line.
1)Because there is no possibility to change asociated script via OC/LabTalk, I tryed to save a line by OC
gl.LT_execute("draw -n RLine01 -f save f:\RLine.ogo");
and this seemed to generate a file RLine.ogo . But when i tryed to load such line with
string sCmd; sCmd.Format("draw -n RLine%d -f read f:\RLine.ogo", LineID); gl.LT_execute(sCmd);
nothing happened and when i run it from scriptwindow, it says Error occured! I tryed the some with a text label, and it worked fine. Is this a bug and reading of .ogg containing line is not supported, or am I doying somewhere a mistake?
2) Is there any way to inhibit the invoke of "OnMove" script asociated with GraphObject when changing X or Y property this object wrom within OC function, so "OnMove" invokes only when user moves object by mouse(keyboard), not programatically?
|
|
|
Mike Buess
USA
3037 Posts |
Posted - 08/10/2004 : 2:27:42 PM
|
1) I use this method for creating lines from LabTalk frequently. Often the line is created outside the visible region of the layer. When you run it from the script window are you using the LabTalk command directly? The following should work...
%A=01; draw -n RLine%A -f read f:\RLine.ogo; draw -n RLine%A -l -v X2; // move vertical line to X2
A useful tip for debugging such things... you can list all objects in the active layer with 'list o'.
...Another thing to watch out for: make sure your line is attached to Layer Frame or Layer and Scales (not Page) before you save it to ogo file. Verify that in the Label Control dialog or set object.attach = 0 or 2 (not 1) from the script window.
2) This should work...
object.script=0; // disable the OnMove trigger # move programmatically object.script=2; // enable the OnMove trigger
Mike Buess Origin WebRing Member
Edited by - Mike Buess on 08/10/2004 2:32:21 PM
Edited by - Mike Buess on 08/10/2004 4:48:23 PM |
 |
|
|
phla8271
Czech Republic
Posts |
Posted - 08/18/2004 : 03:24:03 AM
|
Thank you, Mike. This solved my problem. 1)The line really appeared outside the region of view and redrawing it back solved the problem
2)This method is OK, but must be called as LabTalk command in LT_execute. Any chance, that graphics object get the Script property visible in OC? Are there plans to support each script for each event(OnMove, OnScale...) or is there any way to test what event caused the OnAllEvents script to run? It would be nice to have different behaviour for scaling and for user interaction(move).
Are you planning to add support for different GraphicsObjects(Labels, lines...) as classes in OC? I must admit, using LabTalk command draw is not much convenient. Thanks Peter |
 |
|
|
Mike Buess
USA
3037 Posts |
Posted - 08/18/2004 : 07:47:28 AM
|
quote: This method is OK, but must be called as LabTalk command in LT_execute. Any chance, that graphics object get the Script property visible in OC?
Hi Peter,
All labtalk objects are accessible in OC through LabTalk.objectname. In your case...
double xValue = 0; LabTalk.RLine.script = 0; LabTalk.RLine.x = xValue; // move to X = 0 LabTalk.RLine.script = 2;
That will work if RLine is in the active layer. If it's not you may need to use LT_execute...
GraphLayer gl("Graph1",1); // layer 2 of Graph1 gl.LT_execute("RLine.script=0; RLine.x=0; RLine.script=2;");
Although you can also do things like this...
GraphLayer gl("Graph1",1); GraphObject go; double xValue = 0; go = gl.GraphObjects("RLine"); if( go.IsValid() ) { LabTalk.RLine.script = 0; // go.Script doesn't seem to be supported yet in O7.5 SR4 go.X = xValue; LabTalk.RLine.script = 2; }
You really only need to use the draw command to create the line. I doubt that draw -f read is used frequently enough for OriginLab to make an OC version of the command.
...It turns out that the last code snippet will only work if layer 2 is active. When another layer is active you must use gl.LT_execute after all.
Mike Buess Origin WebRing Member
Edited by - Mike Buess on 08/18/2004 07:55:17 AM
Edited by - Mike Buess on 08/18/2004 08:22:20 AM
Edited by - Mike Buess on 08/18/2004 10:56:24 AM |
 |
|
|
Mike Buess
USA
3037 Posts |
Posted - 08/18/2004 : 4:50:20 PM
|
Hi Peter,
There is a way to avoid triggering the OnMove scripts without using LT_execute at all.
1. Start your line's Label Control script with this...
if(this.show==0) return; // abort if line is hidden
2. When moving the line from OC use something like this...
string pgName = "Graph1"; int layIndex = 1; string objName = "RLine"; double xValue = 0; GraphLayer gl(pgName,layIndex); GraphObject go = gl.GraphObjects(objName); if( go.IsValid() ) { go.Show = 0; // hide line go.X = xValue; // move line go.Show = 1; // show line Page pg(pgName); pg.Refresh(); // refresh page to avoid a "ghost" line }
That will work regardless of which layer is active.
Mike Buess Origin WebRing Member |
 |
|
| |
Topic  |
|