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
 set color increment list
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic Lock Topic Edit Topic Delete Topic New Topic Reply to Topic

couturier

France
291 Posts

Posted - 11/15/2018 :  09:19:00 AM  Show Profile  Edit Topic  Reply with Quote  View user's IP address  Delete Topic
Origin Ver. and Service Release (Select Help-->About Origin): 2019
Operating System:win10

I have a dataplot (dp) to which I want to apply a incremental color list (stored in vector vColor). The color list is applied to both line and symbol (if any).

In previous version, I could do:
dp.Curve.CustomColorList.ColorValues.nVals = vColor;


in version 2019, lines and symbol can each have a different color list, so I'm doing like this:
Tree tr;
tr = dp.GetFormat(FPB_STYLE_COLOR, FOB_ALL, true, true);
bool dpSymbol = tr.Root.Symbol.EdgeColor.IsValid(), dpLine = tr.Root.Line.Color.IsValid();
	
if ( dpLine ) dp.Curve.Line.ColorListValues.nVals = vecR;
if ( dpSymbol ) dp.Curve.Symbol.EdgeColorListValues.nVals = vecR;


When executed in a loop, that makes a significant time increase.
Is there any faster method ?

yuki_wu

896 Posts

Posted - 11/19/2018 :  02:50:27 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Hi couturier,

Yes, it takes double times in Origin 2019 via new method, but I am not sure if it is the new method that makes a significant time increase. I noticed that you mentioned you used this in a loop, so it might be caused by other lines of code.

Could you please share your code via tech@originlab.com with subject line Attn:Yuki so that we could check and see if find a way to improve it.

Regards,
Yuki

OriginLab
Go to Top of Page

cpyang

USA
1406 Posts

Posted - 11/19/2018 :  06:46:47 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
If there is the extra

tr = dp.GetFormat(FPB_STYLE_COLOR, FOB_ALL, true, true);

line, certainly will cost extra time, this call takes some time.

CP
Go to Top of Page

Castiel

343 Posts

Posted - 11/19/2018 :  10:23:15 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
quote:
Originally posted by couturier
dp.Curve.Line.ColorListValues.nVals = vecR;
dp.Curve.Symbol.EdgeColorListValues.nVals = vecR;




How did you find a DataPlot can be applied to such cases like a Tree? I must have missed something.


                                          &&&&&&&&&
                                        &&&
                                       &&
                                      &  _____ ___________
                                     II__|[] | |   I I   |
                                    |        |_|_  I I  _|
                                   < OO----OOO   OO---OO
**********************************************************
Go to Top of Page

couturier

France
291 Posts

Posted - 11/21/2018 :  04:55:37 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
@Yuki
quote:
Yes, it takes double times in Origin 2019 via new method, but I am not sure if it is the new method that makes a significant time increase. I noticed that you mentioned you used this in a loop, so it might be caused by other lines of code.

I don't think so, because
- if I comment the lines that apply color, everything is smooth
- in previous version, everything is smooth

@CP
quote:
If there is the extra
tr = dp.GetFormat(FPB_STYLE_COLOR, FOB_ALL, true, true);
line, certainly will cost extra time, this call takes some time

This is the only method I know for testing whether I have line and/or symbol in the plot.
I'd be glad to know if there is any better/faster method

@Castiel
quote:
How did you find a DataPlot can be applied to such cases like a Tree? I must have missed something.

Woohoo, I'll remember that day as the day I could do something in OC Castiel didn't know about. I suddenly feel less ignorant than I am

More seriously, I'm not sure how I found that. I guess when reading the OC forum because there's nothing in help.
It's still not clear to me why this method works for some properties but you have to do much slower GetFormat and ApplyFormat method for other properties.
Anyway, it works and it's faster and easier.
Go to Top of Page

cpyang

USA
1406 Posts

Posted - 11/21/2018 :  10:35:22 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
I guess you can use GetPlotType to know, so I tried and this works, see if it is fast enough


	GraphLayer gl = Project.ActiveLayer();
	vector<int> vecR = {0,4,1};
	foreach(DataPlot dp in gl.DataPlots) {
		int nn = dp.GetPlotType();
		if(IDM_PLOT_LINE==nn )
			dp.Curve.Line.ColorListValues.nVals = vecR;
		else if(IDM_PLOT_SCATTER ==nn || IDM_PLOT_LINESYMB==nn)
			dp.Curve.Symbol.EdgeColorListValues.nVals = vecR;
	}





CP

Go to Top of Page

Castiel

343 Posts

Posted - 11/21/2018 :  10:40:40 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
quote:
Originally posted by couturier

@Yuki
quote:
Yes, it takes double times in Origin 2019 via new method, but I am not sure if it is the new method that makes a significant time increase. I noticed that you mentioned you used this in a loop, so it might be caused by other lines of code.

I don't think so, because
- if I comment the lines that apply color, everything is smooth
- in previous version, everything is smooth

@CP
quote:
If there is the extra
tr = dp.GetFormat(FPB_STYLE_COLOR, FOB_ALL, true, true);
line, certainly will cost extra time, this call takes some time

This is the only method I know for testing whether I have line and/or symbol in the plot.
I'd be glad to know if there is any better/faster method

@Castiel
quote:
How did you find a DataPlot can be applied to such cases like a Tree? I must have missed something.

Woohoo, I'll remember that day as the day I could do something in OC Castiel didn't know about. I suddenly feel less ignorant than I am

More seriously, I'm not sure how I found that. I guess when reading the OC forum because there's nothing in help.
It's still not clear to me why this method works for some properties but you have to do much slower GetFormat and ApplyFormat method for other properties.
Anyway, it works and it's faster and easier.



LOL

dp.Curve seems to be introduced in Origin 7.5 according to the following post by Mike Buess:

https://my.originlab.com/forum/topic.asp?TOPIC_ID=4599

Wikipedia says Origin 7.5 was released in 2003/10. CP posted a message on 12/09/2013 which I suppose was the earliest mentioning about it (did not check the help file in Origin 7.5 though):

https://my.originlab.com/forum/topic.asp?TOPIC_ID=2744
Tree tr;
tr = dp.Curve; // get the internal Curve branch of Theme Tree


I suppose you can make the code, without GetFormat(), running faster by using DataPlot::ApplyFormat()


//#include <../OriginLab/okThemeID.h>
Tree tr;
TreeNode trRoot = tr.AddNode("Root", OTID_ROOT);
TreeNode trLine = trRoot.AddNode("Line", OTID_CURVE_LINE);
TreeNode trColorListValues = trLine.AddNode("ColorListValues", OTID_CURVE_LINE_COLOR_CUSTOM_LIST);
trColorListValues.nVals = vecR;

//for(int i = 0; i < 1000; i++) {
    foreach(DataPlot dp in gl.DataPlots)
    {
      //dp.Curve.Line.ColorListValues.nVals = vn;

      // UpdateThemeIDs() is unnecessary: NodeID has been set in AddNode()
      //dp.UpdateThemeIDs(tr.Root);
      dp.ApplyFormat(tr, true, true);
    }
//}


On my computer, for 3000 DataPlots, compared with dp.Curve.Line.ColorListValues.nVals = vn;,
1) the above code with ApplyFormat() only saves about 1/4 running time
2) the above code with both UpdateThemeIDs() and ApplyFormat() saves about 1/5 running time

It's time consuming for GetFormat(). You don't have to worry about if there is line and/or symbol in the plot. ApplyFormat() ignores treenodes cannot be applied to it.


                                          &&&&&&&&&
                                        &&&
                                       &&
                                      &  _____ ___________
                                     II__|[] | |   I I   |
                                    |        |_|_  I I  _|
                                   < OO----OOO   OO---OO
**********************************************************
Go to Top of Page

couturier

France
291 Posts

Posted - 11/22/2018 :  03:44:14 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Thanks for helping.

Couldn't try last code as it doesn't compile:
Error, Variable "OTID_ROOT" not declared
couldn't find any ref to that node ID
Go to Top of Page

Castiel

343 Posts

Posted - 11/22/2018 :  05:01:49 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
quote:
Originally posted by couturier

Thanks for helping.

Couldn't try last code as it doesn't compile:
Error, Variable "OTID_ROOT" not declared
couldn't find any ref to that node ID




OTID_ROOT is defined in okThemeID.h, so please include it as

#include <../OriginLab/okThemeID.h>



                                          &&&&&&&&&
                                        &&&
                                       &&
                                      &  _____ ___________
                                     II__|[] | |   I I   |
                                    |        |_|_  I I  _|
                                   < OO----OOO   OO---OO
**********************************************************
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