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
 change the order of plots in a 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

UKrieger

Switzerland
16 Posts

Posted - 11/01/2012 :  1:18:59 PM  Show Profile  Edit Topic  Reply with Quote  View user's IP address  Delete Topic
Origin Ver. 8.6.0 and Service Release Sr3
Operating System: Windows 7

Hi,

is there a command in Origin C to put a certain plot in front if there are number of plots in one layer in a graph window? The same as you do manually by opening the layer content window and rearranging using the arrows?

Thanks, Uli

JessieWoo

China
46 Posts

Posted - 11/02/2012 :  05:29:02 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Hi,

Please refer to the following example:
1. New a worksheet with three columns, filling with row number
2. Select the three columns to make two scatter plots, one in black and the other in red
//--> the red plot is on top
3. open layer content dialog to upgroup the two plots
4. run function test_changeplotorder() //--> the black plot should be on top

void test_changeplotorder()
{
               GraphLayer glActive = Project.ActiveLayer();
               if(!glActive)
                              return;
               
               DataPlot dp2 = glActive.DataPlots(1);
               if(!dp2)
                              return;
               
               string strDPName = "DataPlot";
               
               Tree trContents;
               glActive.GetLayerContents( trContents, GETLC_DATAPLOTS );
               TreeNode trContentsClone = trContents.Clone();
               TreeNode trLayer = trContentsClone.FirstNode;
               foreach(TreeNode trN in trLayer.Children)
               {
                              if( trN.tagName.Find(strDPName) == 0 )
                              {
                                             trN.Remove();
                              }                                            
               }
               
               int nPlot = 0;
               for(TreeNode trDataPlot = trContents.FirstNode.LastNode; trDataPlot.IsValid(); trDataPlot = trDataPlot.PrevNode)
               {                             
                              if( trDataPlot.tagName.Find(strDPName) != 0 )
                                             continue;
                              
                              string strName = strDPName + (string)(++nPlot);
                              TreeNode trNew = trLayer.AddNode(strName);
                              trNew.Replace(trDataPlot, true, true, false);                                        
                              trNew.DataID = nPlot;
               }
               
               DWORD dwAddPlotsCtrl = ADDPLOTSFROMTREE_EDIT|ADDPLOTSFROMTREE_IMPLICIT_STYLEHOLDERS;
               int nNewPlotNum = glActive.AddPlots( trContentsClone.FirstNode, dwAddPlotsCtrl );
}




Best Regard,
Jessie
Originlab Corp.
Go to Top of Page

UKrieger

Switzerland
16 Posts

Posted - 11/02/2012 :  06:13:04 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Hi Jessie,

thanks a lot, your code does exactly what I needed.

Uli
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