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
 All Forums
 Origin Forum for Programming
 LabTalk Forum
 How do you draw a curved line?

Note: You must be registered in order to post a reply.
To register, click here. Registration is FREE!

Screensize:
UserName:
Password:
Anti-Spam Code:
Format Mode:
Format: BoldItalicizedUnderlineStrikethrough Align LeftCenteredAlign Right Horizontal Rule Insert HyperlinkUpload FileInsert Image Insert CodeInsert QuoteInsert List
   
Message:

* HTML is OFF
* Forum Code is ON
Smilies
Smile [:)] Big Smile [:D] Cool [8D] Blush [:I]
Tongue [:P] Evil [):] Wink [;)] Clown [:o)]
Black Eye [B)] Eight Ball [8] Frown [:(] Shy [8)]
Shocked [:0] Angry [:(!] Dead [xx(] Sleepy [|)]
Kisses [:X] Approve [^] Disapprove [V] Question [?]

 
Check here to subscribe to this topic.
   

T O P I C    R E V I E W
realmatt47 Posted - 10/27/2011 : 2:46:27 PM
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.
1   L A T E S T    R E P L I E S    (Newest First)
Penn Posted - 11/01/2011 : 05:21:36 AM
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

The Origin Forum © 2020 Originlab Corporation Go To Top Of Page
Snitz Forums 2000