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
 All Forums
 Origin Forum for Programming
 Forum for Origin C
 Accessing axis tree

Note: You must be registered in order to post a reply.
To register, click here. Registration is FREE!

Screensize:
UserName:
Password:
Anti-Spam Code:
Format Mode:
Format: BoldItalicizedUnderlineStrikethrough Align LeftCenteredAlign Right Horizontal Rule Insert HyperlinkUpload FileInsert Image Insert CodeInsert QuoteInsert List
   
Message:

* HTML is OFF
* Forum Code is ON
Smilies
Smile [:)] Big Smile [:D] Cool [8D] Blush [:I]
Tongue [:P] Evil [):] Wink [;)] Clown [:o)]
Black Eye [B)] Eight Ball [8] Frown [:(] Shy [8)]
Shocked [:0] Angry [:(!] Dead [xx(] Sleepy [|)]
Kisses [:X] Approve [^] Disapprove [V] Question [?]

 
Check here to subscribe to this topic.
   

T O P I C    R E V I E W
couturier Posted - 01/18/2022 : 2:09:53 PM
Origin Ver. and Service Release (Select Help-->About Origin): 2022
Operating System:win 10

Hi,

I'm facing a weird issue when trying to access axis tree.

void add_special_tick(double dTick, string strTick)
{
	GraphLayer gl = Project.ActiveLayer();
	if (gl)
	{
		Axis axesX = gl.XAxis;
		Scale scX(gl.X);
		Tree tr;
		
		tr = axesX.GetFormat(FPB_ALL, FOB_ALL, true, true);
		
		tr.Root.NewAxes.NewAxis2.Specials.SpecialCount.nVal = 1;
		tr.Root.NewAxes.NewAxis2.Specials.Specials.Special1.Type.nVal = 35;
		tr.Root.NewAxes.NewAxis2.Specials.Specials.Special1.Value.dVal = dTick;
		tr.Root.NewAxes.NewAxis2.Specials.Specials.Special1.EnableLabel.nVal = 1;
		tr.Root.NewAxes.NewAxis2.Specials.Specials.Special1.Label.strVal = strTick;
		
		double dX1 = scX.From;
		double dX2 = scX.To;
		double dTol = (dX2 - dX1) / 20;
		
		TreeNodeCollection tnc(tr.Root.NewAxes.NewAxis2.RefLines.RefLines, "RefLine");
		foreach (TreeNode tn in tnc)
		{
			if (dTick + dTol > tn.Value.dVal && dTick - dTol < tn.Value.dVal) 
				tn.Labels.Label1.Show.nVal = 0;
		}
		
		if (0 == axesX.UpdateThemeIDs(tr.Root))
		{
			bool bRet = axesX.ApplyFormat(tr, true, true);
		}
	}
}


1st Issue:
If I want to get axis from and to, I need to use Scale object
If I try to read tr.Root.Scale.From.dVal or tr.Root.Scale.To.dVal, I get an error saying that those variables are not declared.
Why that ?
When debugging, I can see that they exist
Moreover, it's a treenode, so compiler shouldn't care whether that leaf exists or not

2nd issue:
The function will add a special tick with label in a graph that has a few reflines with labels.
If the special tick is near reflines labels, I will hide them
Here again, I have an error saying that tn.Labels.Label1.Show.nVal is not declared

Thanks for the help
2   L A T E S T    R E P L I E S    (Newest First)
couturier Posted - 01/19/2022 : 09:13:53 AM
quote:
The following code works.
double dX1 = gl.X.From;
double dX2 = gl.X.To;

Yes, that was my workaround
But the following doesn't work
double dX1 = tr.Root.Scale.From.dVal;
double dX2 = tr.Root.Scale.To.dVal;


Thaks a lot for the explanations about Show property
Castiel Posted - 01/19/2022 : 05:38:40 AM
quote:

1st Issue:
If I want to get axis from and to, I need to use Scale object
If I try to read tr.Root.Scale.From.dVal or tr.Root.Scale.To.dVal, I get an error saying that those variables are not declared.
Why that ?
When debugging, I can see that they exist
Moreover, it's a treenode, so compiler shouldn't care whether that leaf exists or not


The following code works.
double dX1 = gl.X.From;
double dX2 = gl.X.To;


I don't see any problem of tr.Root.Scale.From.dVal or tr.Root.Scale.To.dVal. You may show an example of this very issue.

quote:

2nd issue:
The function will add a special tick with label in a graph that has a few reflines with labels.
If the special tick is near reflines labels, I will hide them
Here again, I have an error saying that tn.Labels.Label1.Show.nVal is not declared

Thanks for the help



"Show" is a member of TreeNode. You have to write the code similar to this:
TreeNode tnShow = tn.Labels.Label1.GetNode("Show");
//tnShow.nVal = 1;



------------------------------------------
       Be The Change
             You Want To See
                   In The World
------------------------------------------

The Origin Forum © 2020 Originlab Corporation Go To Top Of Page
Snitz Forums 2000