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
 Append layer linked to a existing 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

seaquel

Hong Kong
Posts

Posted - 04/01/2005 :  10:35:30 AM  Show Profile  Edit Topic  Reply with Quote  View user's IP address  Delete Topic
Origin Version (Select Help-->About Origin): Origin 7.0 SR0
Operating System: Win XP professional

Hi, I am trying plot a curve on the first layer on a graphpage, then append another layer for second curve. I want to make the second layer linked to the first one by using same X axis, which is to realize the same function described as following:
right click a Graph-> New Layer(Axes)-> (linked):Right Y
But I dont know how to write the code. My part code is following:


GraphPage grph;
string strTemplate = "MyTemplate.OTP";
BOOL bOK = grph.Create(strTemplate, CREATE_VISIBLE);
if (!bOK)
return;

// Get the first layer:
GraphLayer grlay = grph.Layers(0);
ASSERT(grlay.IsValid());
ASSERT(ORIGIV.IsValid()); //ORIGIV is the first curve.
// Add one data plot to the graph layer:
bOK = 0 <= grlay.AddPlot(ORIGIV);
if (!bOK)
return;
grlay.Rescale();

// Add another layer to graph page:
bOK = grph.AppendLayers(NULL);
if (!bOK)
return;
// Get the second layer:
GraphLayer grlay2 = grph.Layers(1);
ASSERT(grlay2.IsValid());
ASSERT(tempCvIV.IsValid()); //tempCvIV is the second curve.

// Add one data plot to the second layer:
bOK = 0 <= grlay2.AddPlot(tempCvIV);
grlay2.Rescale();

Could you please help me adding the code? Thank you.

easwar

USA
1965 Posts

Posted - 04/01/2005 :  2:08:41 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Hi,

The easiest way to do this is to just create a graph in the first place using a pre-existing template that suits your need. So in your case, you could do:


GraphPage gpg;
gpg.Create("RightY");
GraphLayer gly1, gly2;
gly1 = gpg.Layers(0);
gly2 = gpg.Layers(1);


which will create a 2-layer graph with the right-y axis already in place and layer 2 already linked to layer 1 via x-axis. You can then access each layer and move in data etc.

Note that if a template does not already exist, that meets your requirement, you can always create a custom template in the GUI by making an instance of the graph and then saving it as a template. You can then just create a new graph page in the code by pointing to your saved template.

Now, if you still want to build the graph from scratch layer by layer using Origin C code, you can do that as well, but that will be more work in setting all needed properties.

To see what properties are available, and how to set, you can get the various property branches and dump to script window to see what is there. For example:


GraphPage gpg;
gpg.Create("RightY");
GraphLayer gly1, gly2;
gly1 = gpg.Layers(0);
gly2 = gpg.Layers(1);

// Get the link properties of layer 2 and dump
Tree tr;
tr = gly2.Link;
out_tree(tr);

// Unlink layer 2:
gly2.Link.LinkTo.nVal = 0;

// Get and dump dimensions of layer2
tr = gly2.Dimension;
out_tree(tr);
// etc



Easwar
OriginLab



Edited by - easwar on 04/01/2005 2:11:02 PM
Go to Top of Page

seaquel

Hong Kong
Posts

Posted - 04/02/2005 :  12:25:45 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
I adopt the first option. It seems eassier and works very well now.
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