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
 Data Reader
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic Lock Topic Edit Topic Delete Topic New Topic Reply to Topic

florenciapw

Argentina
Posts

Posted - 03/10/2010 :  09:35:01 AM  Show Profile  Edit Topic  Reply with Quote  View user's IP address  Delete Topic
Origin Ver. and Service Release (Select Help-->About Origin): 8
Operating System: Windows XP

I am a beginner at Origin C (I used to use LabTalk) and I do not get how to manage the DataReader. Could anybody give me a hint? Thanks.

Penn

China
644 Posts

Posted - 03/11/2010 :  04:52:20 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Hi,

You can refer to this example.

Penn
OriginLab Technical Services
Go to Top of Page

florenciapw

Argentina
Posts

Posted - 03/11/2010 :  12:18:40 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Thanks, the example has been very useful. I have another question now. Once I select a point in a graph I need to identify the worksheet that data belongs to, and after that I have to add columns, change column names, etc. How to operate on a worksheet seems easy as far as I understand from the Origin help. The step I do not know how to do is to identify and access the worksheet the data I have selected in the graph belongs to.

Could you help me with that? Thanks.
Go to Top of Page

Penn

China
644 Posts

Posted - 03/12/2010 :  03:24:37 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Hi,

In Origin 8.1, you can use method GetGraphPoints::GetData to get plot index of the selected point, then get data range from the plot, and finally get the book name and sheet name.

void test_GetData()
{
    GraphLayer gl = Project.GraphPages(-1).Layers(-1);
    if(!gl)
        return;
    
    int nNumPoints = 2;
    
    GetGraphPoints sp;
    sp.SetFollowData(true, -1);  // not following any data plot
    sp.GetPoints(nNumPoints, gl);  // select two points from graph layer
    
    vector vx, vy;
    vector<int> vnIndices;
    vector<int> vnDataPlotIndices;
    sp.GetData(vx, vy, vnIndices, vnDataPlotIndices);  // get the selected data
    
    for(int iIndex=0; iIndex<vnIndices.GetSize(); iIndex++)
    {
    	out_str("The result of GetPoints:");
    	
    	DataPlot dp = gl.DataPlots(vnDataPlotIndices[iIndex]);  // get the plot
    	if(!dp)
    		continue;
    	
    	DataRange dr;
    	dp.GetDataRange(dr);  // get data range from plot
    	
    	string strBook;
    	string strSheet;
    	dr.GetBookSheet(strBook, strSheet, 0);  // get book name and sheet name
    	
    	printf("Point %d: X=%f, Y=%f, Index=%d, Book=%s, Sheet=%s\n", iIndex+1, vx[iIndex], vy[iIndex], vnIndices[iIndex], strBook, strSheet);
    }
}


If you are using Origin 8, you can download a demo version of Origin 8.1 to have a try.

Penn
OriginLab Technical Services
Go to Top of Page

florenciapw

Argentina
Posts

Posted - 03/12/2010 :  5:25:48 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Thanks a lot!
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