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
 Name of matrix page from graph layer?
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic Lock Topic Edit Topic Delete Topic New Topic Reply to Topic

farrow22

2 Posts

Posted - 08/22/2011 :  5:14:32 PM  Show Profile  Edit Topic  Reply with Quote  View user's IP address  Delete Topic
Origin 8.5.1 SR 2 Windows XP

How does one get the name of the matrix used to plot a graph layer?

In other words, if you right-click on a contour plot, one of the options in the context menu is (for example) "Go to MBook5".

How do I get this information using Origin C?

Thanks,
Roger

Penn

China
644 Posts

Posted - 08/22/2011 :  11:49:45 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Hi Roger,

Please try the following code, I have added comments for the key lines.

void goToSourceWindow() {
	GraphLayer gl = Project.ActiveLayer();
	if(!gl) {
		out_str("Please Activate A Graph!");
		return;
	}
	DataPlot dp = gl.DataPlots(0);  // get first data plot in layer
	if(!dp) {
		out_str("No Data Plot In Graph Layer!");
		return;
	}

	DataRange dr;
	dp.GetDataRange(dr);  // get data range of the plot
		
	MatrixLayer ml;  // source matrix layer
	int c1, c2;  // matrix object index
	dr.GetRange(ml, c1, c2);  // get the source matrix layer
	
	set_active_layer(ml);  // set the matrix layer active
	ml.SetActive(c1);  // set the matrix object active
}


Penn
Go to Top of Page

farrow22

2 Posts

Posted - 08/23/2011 :  01:29:27 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Penn,

thanks very much, your code does the trick.

And to get the name of the matrix page, I found that

string strMatName = dp.GetDatasetName();

seems to work.

Best,
Roger
Go to Top of Page

Penn

China
644 Posts

Posted - 08/23/2011 :  02:37:10 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Hi Roger,

If the matrix book contains only one matrix sheet with one matrix object, the line you mentioned can work. Otherwise, it needs to activate the corresponding matrix object of the source matrix sheet, then the code I posted will work in such case.

Penn
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