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
 Colormap is not refreshed.
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic Lock Topic Edit Topic Delete Topic New Topic Reply to Topic

winflowers

USA
34 Posts

Posted - 07/01/2009 :  08:54:54 AM  Show Profile  Edit Topic  Reply with Quote  View user's IP address  Delete Topic
Origin Ver. and Service Release (Select Help-->About Origin): Origin 7.5 SR6 v7.5885(B885)
Operating System: windows XP

I have a problem to draw a contour plot with Origin C. The code is like following:

void ScaleColors ()
{
	Matrix mat("Matrix1");
	double dMax=mat.GetMax();
	
	Page pg("MatPage");
	if (!pg)
		return;
	GraphLayer gly = pg.Layers(ii);
//	set_active_layer(gly);
	DataPlot dp = gly.DataPlots(0);
	Tree tr;
	if( !dp.GetColormap(tr) ) 
		return;
	tr.Min.dVal = 0;
	tr.Max.dVal = dMax*1.1;
	if( !dp.SetColormap(tr) )
		printf("Failed to set color map\n");
}


The Min and Max value can be set by these codes. However, the plot did not change accordingly. I could see the new Min and Max values in Plot details->Color map->Set Levels. If I click OK and Apply without doing anything else, the colormap is changed according to the Min and Max values I have set with the above code.

I searched the forum and found similar topic, but no answer.
http://www.originlab.com/forum/topic.asp?TOPIC_ID=5703

What I need is simple: the color of contour plot can be changed according to given Min and Max values. The color is from Blue(small) to Red(big). What should I do to refresh the colormap?

Thanks in advance for your kind help!

Iris_Bai

China
Posts

Posted - 07/02/2009 :  02:26:20 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Hi,

May be need to refresh, please try the following codes after SetColormap.


bool bRedraw = true;
pg.Refresh(bRedraw);


Iris
Go to Top of Page

winflowers

USA
34 Posts

Posted - 07/02/2009 :  07:06:43 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Thanks for your comments. Unfortunately, it does not help.
Are there anything I forgot in my codes?

By the way, I can see the colormap changes after running the code, but not as I desired. Only when I click "OK" in "Set Levels" of "Plot Details", the colormap shows correctly. More comments?
Go to Top of Page

cpyang

USA
1406 Posts

Posted - 07/02/2009 :  6:06:20 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
try

pg.LT_execute("Z1=Z1");

This may force internal update.

CP
Go to Top of Page

winflowers

USA
34 Posts

Posted - 07/03/2009 :  03:58:49 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
I have tried it, but it doesn't help as well.

Once I changed any values in the "Set Levels" dialog manually and click "OK". Then my code runs correctly. Are there any clues?

I also compared the colormap tree before and after clicking the "OK" button in "Set Levels" dialog, and they are exactly same. By the way, the contour plot was created based on a customized template. Could this make the trouble? I really run out of ideas.
Go to Top of Page

Iris_Bai

China
Posts

Posted - 07/03/2009 :  06:13:45 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Change Rescale Mode and run your function again.
Double click on graph to open Plot Details dialog, in Color Map/ Contours tab there is a list box named Resacle Mode.

Iris
Go to Top of Page

cpyang

USA
1406 Posts

Posted - 07/03/2009 :  08:26:59 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
It seems that your original code should work just fine. I suggested Z1=Z1 before I tried your code. Now I tried and I see no probelm in Origin 7.5 SR6.

Maybe you can email me the OPJ file, cp@originlab.com.

Go to Top of Page

winflowers

USA
34 Posts

Posted - 07/03/2009 :  08:44:37 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
The Rescale Mode was "Normal". I did some experiments according to your suggestion.

1. Rescale Mode = "Normal". Running the code, the colormap does not show correctly;
2. Rescale Mode = "Manual". Running the code, the colormap does not show correctly;
3. Rescale Mode = "Normal". Running the code, the colormap does not show correctly. Then switching Rescale Mode to "Manual", the colormap shows correctly;
4. Rescale Mode = "Manual". Running the code, the colormap did not show correctly. Then switching Rescale Mode to "Manual", the colormap shows correctly;
5. Rescale Mode = "Normal". Running the code, the colormap does not show correctly. Then selecting the Rescale Mode list box, but still selecting the "Normal" mode, the colormap shows correctly;

It seems that I need do something to let Origin believe that something has been changed. Then it updates the plot correctly. But actually I need not do any changes.

Edited by - winflowers on 07/03/2009 10:07:16 AM
Go to Top of Page

winflowers

USA
34 Posts

Posted - 07/03/2009 :  10:07:55 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
quote:
Originally posted by cpyang

It seems that your original code should work just fine. I suggested Z1=Z1 before I tried your code. Now I tried and I see no probelm in Origin 7.5 SR6.

Maybe you can email me the OPJ file, cp@originlab.com.





I have sent you the OPJ file.
Go to Top of Page

winflowers

USA
34 Posts

Posted - 07/09/2009 :  02:56:44 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Is there any solution? I have not got any response yet.
Go to Top of Page

cpyang

USA
1406 Posts

Posted - 07/09/2009 :  05:34:37 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Sorry I didnt get to this earlier.

I looked and found that you must set color map using vector first before you can use the tree. In your case, if you are only changing the z level and not change anything else, you can simply call it with the vector version, like this

void sc()
{
	Matrix mat("QEFLeft");
	double dMax=mat.GetMax();
	double z1 = 0, z2=dMax*1.1;
	
	Page pg("AQEF");
	if (!pg)
		return;
	for(int ii = 0; ii < pg.Layers.Count(); ii++)
	{
		GraphLayer gly = pg.Layers(ii);
		DataPlot dp = gly.DataPlots(0);
		vector vz1;
		BOOL bLogScale = FALSE;
		dp.GetColormap(vz1, bLogScale);
		vector vz2;
		int nLevels = vz1.GetSize();
		
		vz2.Data(z1, z2, (z2-z1)/(nLevels-1));
		
		if( !dp.SetColormap(vz2, bLogScale) )
			printf("Failed to set color map\n");
	}
}


Go to Top of Page

winflowers

USA
34 Posts

Posted - 07/09/2009 :  06:59:30 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Thank CP! The code works!
I am wondering what is going on with my OPJ file because you mentioned in your earlier post that the code worked in your environment. And you said that "you must set color map using vector first before you can use the tree". Is it true for every case or just for my OPJ? What is special in my file?
Thanks everyone again! I am very happy that I can always get answers here.
Go to Top of Page

cpyang

USA
1406 Posts

Posted - 07/09/2009 :  08:21:22 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
I am not sure but it seems best to set z levels with vector.
One thing different from my own simple test is that your colormap has different number of levels(500) then the default(8) and I was using default, maybe that made the difference.
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