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
 getting graph color
 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 - 09/06/2018 :  03:53:01 AM  Show Profile  Edit Topic  Reply with Quote  View user's IP address  Delete Topic
Origin Ver. and Service Release (Select Help-->About Origin): 2018b
Operating System: win10

Hi,

I want to check if graph color is single or by point, something similar to LT get name -clo [variableName]
How can I check that ?

In tree style, I can't rely on Colormap node because it still has colormap informations if graph was previously set to colormap and thereafter changed to single color

Couldn't find were to find color increment.

thanks

Edited by - couturier on 09/06/2018 04:12:19 AM

Castiel

343 Posts

Posted - 09/06/2018 :  11:16:22 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
quote:
Originally posted by couturier

Origin Ver. and Service Release (Select Help-->About Origin): 2018b
Operating System: win10

Hi,

I want to check if graph color is single or by point, something similar to LT get name -clo [variableName]
How can I check that ?

In tree style, I can't rely on Colormap node because it still has colormap informations if graph was previously set to colormap and thereafter changed to single color

Couldn't find were to find color increment.

thanks



That information is actually included in the Color node.

Take a DataPlot of line for example, assuming there are 4 columns (A,B,C,D) of data and the line plot is created with B as x and C as Y:

1. Get the format of the DataPlot or GraphLayer or GraphPage as trFormat
2. Get the curve line color node as trCurveLineColor = tree_get_node_by_id(trFormat, 0x89, true) where 0x89 is the value of OTID_CURVE_LINE_COLOR in okThemeID.h
3. Get the curve line color node value as __int64 dw64 = trCurveLineColor.nVal64

If the line color is by index:
By Index A: dw64 = 0xfffffffd00080066
By Index B: dw64 = 0xfffffffe00080065
By Index C: dw64 = 0x0000000100000064
By Index D: dw64 = 0x0000000200000065


If the line color is by RGB:
By RGB A: dw64 = 0xfffffffd00880066
By RGB B: dw64 = 0xfffffffe00880065
By RGB C: dw64 = 0x0000000100800064
By RGB D: dw64 = 0x0000000200800065


By Color Mapping
By Mapping A: dw64 = 0xfffffffd00480066
By Mapping B: dw64 = 0xfffffffe00480065
By Mapping C: dw64 = 0x0000000100400064
By Mapping D: dw64 = 0x0000000200400065


By Single Point:
dw64 = 0x00000000xxxxxxxx


Obviously,

bool bRef     =   dw64 & 0xffffffff00000000;
bool bIndex   = !(dw64 & 0x0000000000f00000);
bool bRGB     =   dw64 & 0x0000000000800000;
bool bMapping =   dw64 & 0x0000000000400000;


When by single point, bRef is FALSE, otherwise TRUE.



For custom color increment, you should check the node with NodeID = 0x645, 0x646 and 0x647. You can get system increment list using okutil_theme_get_system_increment_list().


Note the above conclusions come from testing but have never been confirmed officially.


     #####
    #### _\_  ________
    ##=-[.].]| \      
    #(    _\ |  |------|
     #   __| |  ||||||||
      \  _/  |  ||||||||
   .--'--'-. |  | ____ |
  / __      `|__|[o__o]|
_(____nm_______ /____\____ 
Go to Top of Page

yuki_wu

896 Posts

Posted - 09/07/2018 :  03:09:26 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Hi couturier,

In OC, we need to get the plot color form OC theme as Castiel mentioned. To see how the line color is defined, there is an undocumented function for column type color:

BOOL okutil_get_col_by_ocolor(OQCOLOR oqColor, int nMainColIndex, int* pnModifiedColIndex, int* pnColType)

enum
{
COLTYPE_COLOR_INDEX = SYMB_COLOR_COLTYPE_INDEX,
COLTYPE_COLOR_RGB = SYMB_COLOR_COLTYPE_RGB,
COLTYPE_COLOR_COLORMAP = SYMB_COLOR_COLTYPE_COLORMAP,
COLTYPE_MISCELLANEOUS,
};


For example,
void get_plot_color_2()
{
	GraphLayer gl = Project.ActiveLayer();
	DataPlot dp(gl.DataPlots(0));	
	if(!dp)
		return;
	Tree tr;
	tr = dp.GetFormat(FPB_ALL, FOB_ALL, true, true);
	__int64 qColor = tr.Root.Line.Color.nVal64;
	int nColType = -1;
	if (okutil_get_col_by_ocolor(qColor, 0, NULL, &nColType))
		printf("qcolor is column color, type=%d", nColType);
}


However, it seems that there is no function could be used to check if the color is single color or increment color. Perhaps use okutil_ocolor_to_HTML trickily. Return HTML color except “#000000” is a single color, otherwise, it may the color by point or auto color.
https://www.originlab.com/doc/OriginC/ref/okutil_ocolor_to_HTML

Anyway, I will bring up this issue in our share meeting to see if we should create a new OC function to do this.

Regards,
Yuki
OriginLab

Edited by - yuki_wu on 09/07/2018 03:10:12 AM
Go to Top of Page

couturier

France
291 Posts

Posted - 09/07/2018 :  06:32:47 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Castiel, I'm impressed !
Thanks a lot

Thanks Yuki for the additionnal informations

Edited by - couturier on 09/07/2018 06:34:20 AM
Go to Top of Page

rdremov

USA
28 Posts

Posted - 09/07/2018 :  1:06:27 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
If plot is a group plot and one of its colors is incremented you could find this out like this. Look for plot theme Increment branch (OTID_GROUP_INC = 0x00f7) and Stretch property (OTID_GROUP_INC_STRETCH = 0x03ed).

It is int array with values following these rules:
1. Index is one of OENUMGROUPINDEX (oc_const.h). E.g. Line color index is 0 (OEGI_COLOR)
2. values is one of INCSTRETCHMODE (oc_const.h). E.g. if color is incremented by one value is ISM_ONE.

If no Increment branch or no Stretch property or your index is missing or its value is ISM_NONE that property is NOT incremented and color is a OQCOLOR (64 bits) or simplified OCOLOR (32 bits) (see posts above). Please also keep in mind different plot types will have different increment indices (line vs symbol etc) available.

Here is OC code example to test if a particular group plot property is incremented:

bool is_active_group_plot_property_incremented(int nIndex = OEGI_COLOR)
{
	GraphLayer gl = Project.ActiveLayer();
	if(!gl)
		return false;
	DataPlot dp = gl.DataPlots(0);
	if(!dp)
		return false;
	GroupPlot gp = dp.GetGroupPlot();
	if(!gp)
		return false;
	Tree tr;
	tr = gp.GetFormat(FPB_ALL, FOB_ALL, TRUE, TRUE);
	out_tree(tr);
	if(!tr || !tr.Root)
		return false;
	TreeNode trIncrement = tr.Root.Increment;
	if(!tr.Root.Increment)
		return false;
	TreeNode trStretch = trIncrement.Stretch;
	if(!trStretch)
		return false;
	vector<int> props;
	props = trStretch.nVals;
	if(nIndex >= props.GetSize())
		return false;
	if(props[nIndex] == ISM_NONE)
		return false;
	return true;
}

Edited by - rdremov on 09/07/2018 1:47:24 PM
Go to Top of Page

cpyang

USA
1406 Posts

Posted - 09/07/2018 :  6:12:18 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Roman's code answer the question on group plot, and Yuki's answer single plot, and the function return from okutil_get_col_by_ocolor can answer the question of single or by point. I will add these to our documentation.


//assume graph with a line plot or a scatter plot
void pp()
{
	GraphLayer gl = Project.ActiveLayer();
	DataPlot dp(gl.DataPlots(0));	
	Tree tr;
	tr = dp.GetFormat(FPB_ALL, FOB_ALL, true, true);
	__int64 qColor;
	if(tr.Root.Line)
		qColor = tr.Root.Line.Color.nVal64;
	else if(tr.Root.Symbol)
		qColor = tr.Root.Symbol.EdgeColor.nVal64;
	else {
		out_str("plot type not having line nor symbol");
		return;
	}
	int nRefType = -1;
	if (okutil_get_col_by_ocolor(qColor, 0, NULL, &nRefType))
		printf("plot color by points, color linking type=%d\n", nRefType);
	else
		out_str("plot single color");	
}


CP
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