The Origin Forum
File Exchange
Try Origin for Free
The Origin Forum
Home | Profile | Register | Active Topics | Members | Search | FAQ | Send File to Tech support
Username:
Password:
Save Password
Forgot your Password? | Admin Options

 All Forums
 Origin Forum for Programming
 Forum for Origin C
 Mouse Position. MarkerGraphObject
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic Lock Topic Edit Topic Delete Topic New Topic Reply to Topic

dkudlay

USA
22 Posts

Posted - 12/07/2009 :  7:12:21 PM  Show Profile  Edit Topic  Reply with Quote  View user's IP address  Delete Topic
I am trying to get precise point information about a contour graph. I could not find anything that would let me get mouse coordinates. I attempted to use the MarkerGraphObject but I have some issues with it.

1) I can't keep only 1 marker object with out setting Attach to 0 (Page) and then setting a negative value for position.

2) My script is never called.

Here is the code.

void AddProfileCross(GraphLayer gl)
{
MarkerGraphObject mObj;
mObj = gl.GraphObjects("Marker");
if( !mObj )
mObj = gl.CreateGraphObject(GROBJ_TN_MARKER);

mObj.SetName("CrossHair");

vector vX = {0, 0};
vector vY = {0, -10};
mObj.SetPoints(vX, vY);
mObj.Attach = 2; // attach to axes scales

TreeNode trFormat = mObj.GetFormat(FPB_ALL, FOB_ALL, true, true);

// 2 circle
// 3 tri up
// 4 tri down
// 5 diamond
// 6 <
// 7 tri >
// 8 hex
// 9 star
trFormat.Root.Symbol.Shape.nVal = 2; // star
trFormat.Root.Symbol.Size.nVal = 20;
trFormat.Root.Symbol.EdgeColor.nVal = SYSCOLOR_RED;
trFormat.Root.Symbol.FillColor.nVal = SYSCOLOR_GREEN;
trFormat.Root.Color.nVal = -4; // to suppress line drawing between the point
trFormat.Root.Script.strVal = "Crosshair(CrossHair.X, CrossHair.Y)";
trFormat.Root.Event.nVal = GRCT_MOVE;

mObj.UpdateThemeIDs(trFormat.Root);

//trFormat.Root.States.nVal = GOC_NO_SELECT; // so that it does not respond to mouse clicks
mObj.ApplyFormat(trFormat, TRUE, TRUE);

}

void Crosshair(double x, double y)
{
out_str("Called crosshair");
int j = x;
int k = y;

j -= k;
}

Iris_Bai

China
Posts

Posted - 12/08/2009 :  01:15:25 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Hi,

MarkerGraphObject class need to attach to one data plot, SetPoints and GetPoints used to get the points on this data plot. But for Contour plot, if you want to get the position of one point, need to use screen reader to read the position of screen. There is not a proper mechanism in Origin C, but you can call Labtalk command "dotool" in Origin C.

Activate one contour graph, and then run "dotool 2" in Command window or Origin C function like

void testPage()
{
	GraphLayer gl = Project.ActiveLayer();
	if( gl )
	{
		LT_execute("dotool 2");
	}
}


Please try and tell me this way if enough for you.


Iris
Go to Top of Page

dkudlay

USA
22 Posts

Posted - 12/08/2009 :  5:42:35 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Hi Iris, What I am trying to do is to get the X-Axis and Y-Axis value at the crosshair point, so then I can reference it into our data set and display all relevant data for the particular point in text objects (a data legend) on the graph.

Alternatively, I was planning on using a small rect, provided there is a way to make it non-resizable. I thought also about linking lines but I did not see that is was possible to move 2 lines (for a cross) at the same time..

Thank you,
Go to Top of Page

cpyang

USA
1406 Posts

Posted - 12/09/2009 :  10:29:46 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
We will work on providing an example OC code to create a box with a crosshair inside. The box will not be resizable but the mouse dragging will not carry the crosshair along until you release the mouse. Once you move it to be close enough, using arrow key to move the box WILL carry the crosshair along. We can improve later so that crosshair can also be dragged together with the box.

Will post OC code later today or tomorrow.


CP
Go to Top of Page

Penn

China
644 Posts

Posted - 12/11/2009 :  12:44:31 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Hi,

A new example Origin C code to create a screen reader with a box and crosshair inside has been added. Please refer to the following page.

http://ocwiki.originlab.com/index.php?title=OriginC:General_Screen_Reader_by_Graph_Object

Penn
OriginLab Technical Services
Go to Top of Page
  Previous Topic Topic Next Topic Lock Topic Edit Topic Delete Topic New Topic Reply to Topic
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
The Origin Forum © 2020 Originlab Corporation Go To Top Of Page
Snitz Forums 2000