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
 Extracting both x and y data from GetN graph
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic Lock Topic Edit Topic Delete Topic New Topic Reply to Topic

michaelbraun

USA
21 Posts

Posted - 07/10/2015 :  5:20:25 PM  Show Profile  Edit Topic  Reply with Quote  View user's IP address  Delete Topic
Origin Ver. and Service Release (Select Help-->About Origin): Origin 2015 sr2
Operating System: Windows

Hi, I am attempting to select a certain data range on a plot using GetN. I get the dialog to come up and successfully select the correct data. However, I can only get the y data points to export? I think I am missing a dr.Add command, but I don't know what to reference to get the x points corresponding to each y point?

My header and relevant code, the last 2 lines add the grabbed y data points to the appropriate column in my worksheet:

#include <Origin.h>
#include <..\OriginLab\theme_utils.h>
#include <GetNBox.h>

                        GETN_TREE(gettr)	
			GETN_INTERACTIVE(Range1, "Select Range", "Graph")
			vector yData, xData;
			if( GetNBox(gettr) ) // returns true if click OK button
			{
				DataRange dr;
				dr.Add("Range1", gettr.Range1.strVal);
				dr.GetData(&yData, 0); //0 is the index location of data
				dr.GetData(&xData, 1); //This doesn't do anything right now, but I would like it to.
			}
		
		
		//write selected data to original worksheet
				vectorbase& vy = wks.Columns(4).GetDataObject();
				vy = yData;



Edited by - michaelbraun on 07/10/2015 5:29:26 PM

Castiel

343 Posts

Posted - 07/10/2015 :  9:03:10 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
quote:
Originally posted by michaelbraun

Origin Ver. and Service Release (Select Help-->About Origin): Origin 2015 sr2
Operating System: Windows

Hi, I am attempting to select a certain data range on a plot using GetN. I get the dialog to come up and successfully select the correct data. However, I can only get the y data points to export? I think I am missing a dr.Add command, but I don't know what to reference to get the x points corresponding to each y point?

My header and relevant code, the last 2 lines add the grabbed y data points to the appropriate column in my worksheet:

#include <Origin.h>
#include <..\OriginLab\theme_utils.h>
#include <GetNBox.h>

                        GETN_TREE(gettr)	
			GETN_INTERACTIVE(Range1, "Select Range", "Graph")
			vector yData, xData;
			if( GetNBox(gettr) ) // returns true if click OK button
			{
				DataRange dr;
				dr.Add("Range1", gettr.Range1.strVal);
				dr.GetData(&yData, 0); //0 is the index location of data
				dr.GetData(&xData, 1); //This doesn't do anything right now, but I would like it to.
			}
		
		
		//write selected data to original worksheet
				vectorbase& vy = wks.Columns(4).GetDataObject();
				vy = yData;





Should have been GETN_XYRANGE.

GETN_TREE(gettr)	
//GETN_INTERACTIVE(Range1, "Select Range", "Graph")
GETN_XYRANGE(Range1, "Select Range", 1, "")
if( GetNBox(gettr) ) // returns true if click OK button
{
    XYRange dr;
    xy_range_from_GetN_data_node(gettr.Range1.Range1, dr);
			 
    vector xData, yData;
    dr.GetData(yData, xData);
}


妾+   午旦  妹罕妾  妾伊    用仇  妾/     岫ㄞ
 妾京用 仍巨  件 侈   件戶' 甘岫平   /欠  白岫妹
   併             艮          岫  奈 白   岫
                              岫
Go to Top of Page

michaelbraun

USA
21 Posts

Posted - 07/10/2015 :  9:54:55 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Worked great, thank you! Just a note for anyone else coming across this, if you want to use the selected data placed into the xData and yData vectors, they need to be initialized outside the if statement. My section of working code is:

#include <Origin.h>
#include <..\OriginLab\theme_utils.h>
#include <GetNBox.h>
                //Select data from graph
                        GETN_TREE(gettr)	
			GETN_XYRANGE(Range1, "Select Range", 1, "")
			vector yData, xData;
			if( GetNBox(gettr) ) // returns true if click OK button
			{
				XYRange dr;
				xy_range_from_GetN_data_node(gettr.Range1.Range1, dr);
				dr.GetData(yData, xData);
			}
			
		//write selected data to original worksheet
				vectorbase& vy = wks.Columns(4).GetDataObject();
				vy = yData;
				vectorbase& vx = wks.Columns(3).GetDataObject();
				vx = xData;





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