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
 LabTalk Forum
 How do you draw a curved line?
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic Lock Topic Edit Topic Delete Topic New Topic Reply to Topic

realmatt47

1 Posts

Posted - 10/27/2011 :  2:46:27 PM  Show Profile  Edit Topic  Reply with Quote  View user's IP address  Delete Topic
I can draw a straight line using:

GObject myLine = line1;
draw -n myLine -lm {1,2,3,4};

But I want to draw a curved line like when you do:

dotool 8
(and then click on 4 points on the graph).

I've been searching documentation for an hour, and can't figure out how to either draw it, change a straight line to a curved one, or generate a "click" using code.

Penn

China
644 Posts

Posted - 11/01/2011 :  05:21:36 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Hi,

It seems that there is no such LabTalk command yet. However, you can use Origin C to implement it. Please refer to Add Curved Arrow Tool example. Here is the steps how I implement it.

1. Open the Code Builder by menu View: Code Builder.
2. Create a new C File in Code Builder by File: New, and name it MyCurvedLine for example.
3. Copy and paste the following Origin C code after the line "// Start your functions here." of the newly created C file.

#include <..\Originlab\grobj_utils.h>
void graph_object_curved_line(double x1=2.2, double x2=4.7, double x3=6.58, double x4=7.16, double y1=5.7, double y2=4.22, double y3=5.12, double y4=7.35)
{
	GraphLayer gl = Project.ActiveLayer();
	if(!gl)
	{
		out_str("please activate a graph layer");
		return;
	}
	GraphObject go;
	go = gl.CreateGraphObject(GROBJ_TN_LINE4); 	
	go.Attach = ATTACH_TO_SCALE; 
	Tree tr;	
	//tr = go.GetFormat(FPB_DATA, FOB_ALL, true, true); 
	//// to take a look on default position	
	//vector vx0, vy0;
	//vx0 = tr.Root.Data.X.dVals;	
	//vy0 = tr.Root.Data.Y.dVals; 
	// to set the proper position for four points
	//vector vx = {2.2, 4.7, 6.58, 7.16};
	//vector vy = {5.7, 4.22, 5.12, 7.35};
	vector vx(4);
	vx[0] = x1;
	vx[1] = x2;
	vx[2] = x3;
	vx[3] = x4;
	vector vy(4);
	vy[0] = y1;
	vy[1] = y2;
	vy[2] = y3;
	vy[3] = y4;
	tr.Root.Data.X.dVals = vx;	
	tr.Root.Data.Y.dVals = vy;
    tr.Root.Arrow.End.Style.nVal = 1; // add arrow to the end 
	int nErr = go.UpdateThemeIDs(tr.Root);	
	if(nErr == 0)	
	{
		go.ApplyFormat(tr, true, true);	
	}	
	else	
	{		
		out_int("err = ", nErr);	
	}
}

4. Save this file, and then drag this file from the left panel (Workspace panel), drag this file from the User folder to the System folder.
5. Close Code Builder and restart Origin.

Now, you can use the function "graph_object_curved_line(double x1=2.2, double x2=4.7, double x3=6.58, double x4=7.16, double y1=5.7, double y2=4.22, double y3=5.12, double y4=7.35)" as a command to draw a curved line by passing four points. For example,

graph_object_curved_line(4, 2, 5, 4, 2, 4, 8, 8);


Penn

Edited by - Penn on 11/01/2011 05:23:42 AM
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