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
 SPECTRUM1

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
cm432 Posted - 07/18/2011 : 08:51:24 AM
I'm trying to format colormap surface and contour colorfill plots. I want to make the color scale or spectrum1 visible on the plots using c and then place it in the upper right hand corner of the plot. Can you please tell me the command to make SPECTRUM1 visible on the plots and also if there's a way to automatically position them as well? Thank you!
3   L A T E S T    R E P L I E S    (Newest First)
Penn Posted - 07/20/2011 : 03:12:42 AM
Hi,

Please note that, LT_execute("spectrum;") only adds SPECTRUM1 to the active graph layer. In your code, I suppose there are two graph layers in the graph page which you want to loop over. If the active layer is layer one, when the loop is going to layer two, LT_execute("spectrum;") will add SPECTRUM1 to layer one, and go = gl.GraphObjects("spectrum1") cannot get SPECTRUM1 from layer two. That is to say, go is NULL. And then, when you try to set the position of SPECTRUM1 by go, the error happens.

So, you can change the line LT_execute("spectrum;"); to

gl.LT_execute("spectrum;"); // add spectrum1


Otherwise, you can activate the layer before LT_execute.

set_active_layer(gl);  // activate the graph layer
LT_execute("spectrum;"); // add spectrum1



Penn
cm432 Posted - 07/19/2011 : 09:59:43 AM
Thank you very much, that was exactly what I needed. I was also trying to run this for every graphpage in the project. It doesn't work for every graphpage and I get an error "Calling members of unattached wrapper class" sometimes. Do you know how I can fix this? I was using the following code:

foreach( GraphPage gp in Project.GraphPages )
{
foreach( GraphLayer gl in gp.Layers )
{
//Add Color Spectrum
if( gp.IsValid() )
{
GraphObject go = gl.GraphObjects("spectrum1"); // get the spectrum1
//if (gl.GraphObjects("spectrum1") == NULL)
if(!go) // if the spectrum1 not exist
{
LT_execute("spectrum;"); // add spectrum1
go = gl.GraphObjects("spectrum1"); // get spectrum1
// set position of spectrum1
if (gl.GraphObjects("YR") == NULL)
{
go.X = 65;
go.Y = 25;
}
else
{
go.X = 165;
go.Y = 0;
}
}
}

// refresh the graph
gl.GetPage().Refresh();
}
}
Penn Posted - 07/19/2011 : 04:52:41 AM
Hi,

Actually, the SPECTRUM1 is a graph object, that is to say, you can use the GraphObject to control SPECTRUM1. If you want to remove the SPECTRUM1 from the graph layer, please use the RemoveGraphObject method. If the SPECTRUM1 does not exist in the layer, use the following line to add it.

LT_execute("spectrum;");  // add spectrum1

The code below is used to set the SPECTRUM1 position.

void layer_set_spectrum1()
{
	GraphLayer gl = Project.ActiveLayer();  // get the active graph layer
	if(!gl)
		return;
	
	GraphObject go = gl.GraphObjects("spectrum1");  // get the spectrum1
	if(!go)  // if the spectrum1 not exist
	{
		LT_execute("spectrum;");  // add spectrum1
		go = gl.GraphObjects("spectrum1");  // get spectrum1
	}
	// set position of spectrum1
	go.X = 0;
	go.Y = 0;
	// refresh the graph
	gl.GetPage().Refresh();
}

Also, you can get more examples on setting colormap.

Penn

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