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
 How to rearrange plots in a layer

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
cpyang Posted - 09/17/2004 : 3:43:19 PM
Origin Version: 7.5

I have written the following sample code to show how to move a particular data plot to the bottom of the plot list. This area were not completely finished in terms of Origin C support and thus no documentation were available. But I found that given the current (Origin 7.5) implementation, it is already possible to do some limited manipulations.




static bool dataplots_move_row_to_bottom_top(TreeNode& tr, int nRow, bool bMoveToTopOfTree = true)
{
Tree trTemp;
TreeNode tr1stPlot;// for the case of bMoveToTopOfTree
int nCount = 0;
string strName;
string strPrefix;
foreach(TreeNode trNode in tr.Children)
{
strName = trNode.tagName;
int nIndex = string_to_prefix_end_number(strPrefix.GetBuffer(MAXLINE), strName);
strPrefix.ReleaseBuffer();
if(strPrefix.CompareNoCase("DataPlot") != 0)
continue;

if(!tr1stPlot)
tr1stPlot = trNode;// remember 1st DataPlot node for insert later

// top level
if(nRow == nCount)
{
trTemp = trNode; // make copy
tr.RemoveChild(trNode);
break;
}
nCount++;
}
if(trTemp)
{
if(!bMoveToTopOfTree) // bottom of tree, then top of plot list
tr.AddNode(trTemp.Clone());
else // move to bottom of plot list, which means top of the tree
{
if(!tr1stPlot)
{
out_str("No data plot in layer, nothing to move");
return false;
}
TreeNode tr1 = tr.InsertNode(tr1stPlot, "Junk");// tagName does not matter, will be replaced later
tr1.Replace(trTemp.Clone());
}
return true;
}
return false;
}



void test_mv_plot(int nPlot, bool bRegroup = false)
{
GraphLayer gl = Project.ActiveLayer();
if(!gl)
return;
Tree tr;
bool bWasGroup = gl.UngroupPlots();
gl.GetLayerContents(tr, GETLC_DATAPLOTS);

if(dataplots_move_row_to_bottom_top(tr.FirstNode, nPlot))
{
gl.AddPlots(tr.FirstNode, ADDPLOTSFROMTREE_EDIT);
if(bWasGroup && bRegroup)
gl.GroupPlots(0);

gl.LT_execute("legend -s");// this will force the legend to update
gl.GetPage().Refresh();
}
}







CP




Edited by - cpyang on 09/20/2004 4:00:00 PM

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