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
 Showing Top and Right Axes
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic Lock Topic Edit Topic Delete Topic New Topic Reply to Topic

rikseventyseven

Switzerland
10 Posts

Posted - 06/20/2009 :  1:13:45 PM  Show Profile  Edit Topic  Reply with Quote  View user's IP address  Delete Topic
Origin 8.0

I'm pretty new to OriginC programming.
I have the following problem:
I manipulated and did some math using some worksheet columns. Now, I wrote a small code that generates a plot using these datasets. I can set the line colors and marker size/type.
Now since I'm fanatic of Top and Right axes I would like to activate them.
I read an example where they use the tree structure to import the properties of the axes. I can set for example the position and the color of the Bottom and Left axes using :

trAxes.X.Ticks.BottomTicks.Major.nVal = 1; // Set the major ticks to In & Out format for X axes
//trAxes.X.Ticks.TopTicks.Show.nVal = true;
trAxes.Y.Ticks.LeftTicks.Major.nVal = 1; // Set the major ticks to In & Out format for Y axes
//trAxes.Y.Ticks.RightTicks.Show.nVal = true;
trAxes.All.Ticks.All.Color.nVal = 0; // Set the color of axes to bule
gl.ApplyFormat(tr1);


The frustrating thing is that if I uncomment the green lines I cannot compile and I get an error!
Why?!!?!?

I tryied to use the tree_to_str function on the layer's tree and these parameters for Top and Right axes are there!
What's wrong with this code?!

Thanks a lot!

rikseventyseven

-------------------------------
"Stay hungry, stay foolish."

cpyang

USA
1406 Posts

Posted - 06/20/2009 :  8:35:12 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
The problem is with the Show property. Origin C TreeNode has a built-in property called Show and thus a tree tagName called Show will lead to a conflict. We can fix this in later SR but for now, you can use lower case "show", since the theme tree tagname is case insensitive.

The following code will work fine:



void show_top_right_axes()
{
	GraphLayer gl = Project.ActiveLayer();
	if( !gl )
		return;    
	
	Tree trFormat;
	// first turn on top-right axes with a separate set theme call
	trFormat.Root.Axes.X.Ticks.TopTicks.show.nVal = 1;
	trFormat.Root.Axes.Y.Ticks.RightTicks.show.nVal = 1;
	int nErr = gl.UpdateThemeIDs( trFormat.Root ) ;//assign node IDs to all nodes in trFormat, return number of errors
	if(0 != nErr)
		out_str("Fail to Update Theme IDs, theme tree has wrong structure");
	gl.ApplyFormat( trFormat, true, true, true ); //update graphlayer's format
	// then change settings can be done after needed axes are already turned on
	trFormat.Root.Axes.X.Ticks.BottomTicks.Major.nVal = 1; // Set the major ticks to In & Out format for X axes
	trFormat.Root.Axes.Y.Ticks.LeftTicks.Major.nVal = 1; // Set the major ticks to In & Out format for Y axes
	trFormat.Root.Axes.All.Ticks.All.Color.nVal = SYSCOLOR_BLUE; // Set the color of axes to bule 
	nErr = gl.UpdateThemeIDs( trFormat.Root ) ;//assign node IDs to all nodes in trFormat, return number of errors
	if(0 != nErr)
		out_str("Fail to Update Theme IDs, theme tree has wrong structure");
	
	gl.ApplyFormat( trFormat, true, true, true ); 
}




Thanks for posting about this problem, and I have updated our ocwiki with a new example:

http://ocwiki.originlab.com/index.php?title=OriginC:Accessing_Graph_Format_with_Theme_Tree#Turn_On_Top-Right_Axes


Go to Top of Page

rikseventyseven

Switzerland
10 Posts

Posted - 06/22/2009 :  10:27:10 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
That solved the problem!!!
Thank you very much for the hint!

In 30 sec you managed to do better then me in 2 hours...

Thank a lot!


-------------------------------
"Stay hungry, stay foolish."
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