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
 labtalk "label" for a page in originC

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
christo2 Posted - 09/01/2009 : 07:39:26 AM
Origin Ver. and Service Release (Select Help-->About Origin): 8G SR4
Operating System: XP

Hi.
I got a problem with the labeling of a graphpage. I already found the page_insert_label function, but that one doesn't position my label where I want it to be. In Labtalk I used:

win -a graphpage;
label -s -sa -d 5650 450 strLabel;

How do I get this for OriginC at exactly the same position as with Labtalk?

Many thanks,
conny
6   L A T E S T    R E P L I E S    (Newest First)
christo2 Posted - 09/02/2009 : 05:22:28 AM
Thank you!! Thant one really does it. And I found out, why the bool didn't work (it was too late and I copied it into my program....)

Iris_Bai Posted - 09/02/2009 : 01:54:08 AM
I cleanup rlewis's example functions above to wiki page http://ocwiki.originlab.com/index.php?title=Category:GraphObject%28Examples%29
And we will support more examples about Graph Object later.

Iris
rlewis Posted - 09/01/2009 : 8:28:56 PM
The following combination of OC functions should do ...

bool CreateTextLabel(string strLabelName, int FromLeft, int FromTop, string strLabelText, int TypeFace=-1, int FontSize=-1)
{
/*
		Create TextLabel
		Creates a Text label named "strlabelName" at the coordinates FromLeft and FromTop of the active layer
		TypeFace > 0  ... Alters the Typeface to the new value
		FontSize > 0  ... Alters the FontSize to the new value
		On success: TextLabel created with the text strLabelText ... Returns true
		On Failure: returns false

*/		
	Layer Layr=Project.ActiveLayer();
	GraphObject gO;
	gO=Layr.GraphObjects(strLabelName);
	if(gO.IsValid()==false)
	{
		gO=Layr.CreateGraphObject(GROT_TEXT);
		gO.SetName(strLabelName);
	}
	else
	{
		string strObjType=gO.GetObjectType();
		strObjType.TrimLeft();
		strObjType.TrimRight();
		if(strObjType.CompareNoCase("Text")!=0)
		{
			return (false);
		}
	}
	gO.Text=strLabelText;
	SetFontProperties(gO, TypeFace,FontSize);
	gO.Left=FromLeft;
	gO.Top=FromTop;
	return (true);
}

bool GetFontInfo(GraphObject gO, int &TypeFace, int &FontSize)
{
	if (gO.IsValid()==true)
	{
		string strObjType=gO.GetObjectType();
		strObjType.TrimLeft();
		strObjType.TrimRight();
		if(strObjType.CompareNoCase("Text")!=0)
		{
			return (false);
		}
		Tree trFormat;
		trFormat = gO.GetFormat(FPB_ALL	,FPB_ALL,TRUE,TRUE);
		TypeFace=trFormat.Root.Font.Face.dVal;
		FontSize=trFormat.Root.Font.Size.dVal;
		return (true);
	}
	return (false);
}

bool SetFontProperties(GraphObject &gO,  int TypeFace=-1, int FontSize=-1)
{
	if(gO.IsValid()==true)
	{
		string strObjType=gO.GetObjectType();
		strObjType.TrimLeft();
		strObjType.TrimRight();
		if(strObjType.CompareNoCase("Text")!=0)
		{
			return (false);
		}
		Tree trFormat;
		trFormat = gO.GetFormat(FPB_ALL	,FPB_ALL,TRUE, TRUE);
		if(TypeFace>=0)
		{
			trFormat.Root.Font.Face.dVal=TypeFace;
		}
		if(FontSize>0)
		{
			trFormat.Root.Font.Size.dVal=FontSize;
		}
		gO.ApplyFormat(trFormat,true,true);
		return (true);
	}
	return (false);
}
christo2 Posted - 09/01/2009 : 1:15:47 PM
Thank you!!! It worked like a charm!! (well the boolean didn't want to, but hey, it's at the very end of my program, so i don't care)!
Just another quick question: How do I set the fontsize?

conny
rlewis Posted - 09/01/2009 : 10:45:24 AM
Correction ...

bool CreateTextLabel(string strLabelName, int FromLeft, int FromTop, string strLabelText)
{
/*
		Create TextLabel
		Creates a Text label named "strlabelName" at the coordinates FromLeft and FromTop of the active layer
		On success: TextLabel created with the text strLabelText ... Returns true
		On Failure: returns false

*/		
	Layer Layr=Project.ActiveLayer();
	GraphObject gO;
	gO=Layr.GraphObjects(strLabelName);
	if(gO.IsValid()==false)
	{
		gO=Layr.CreateGraphObject(GROT_TEXT);
		gO.SetName(strLabelName);
	}
	else
	{
		string strObjType=gO.GetObjectType();
		strObjType.TrimLeft();
		strObjType.TrimRight();
		if(strObjType.CompareNoCase("Text")!=0)
		{
			return (false);
		}
	}
	gO.Text=strLabelText;
	gO.Left=FromLeft;
	gO.Top=FromTop;
	return (true);
}

rlewis Posted - 09/01/2009 : 10:42:38 AM
Try this ...

bool CreateTextLabel(string strLabelName, int PageUnits, int FromLeft, int FromTop, string strLabelText)
{
/*
		Create TextLabel
		Creates a Text label named "strlabelName" at the coordinates FromLeft and FromTop of the active layer
		On success: TextLabel created with the text strLabelText ... Returns true
		On Failure: returns false

*/		
	Layer Layr=Project.ActiveLayer();
	GraphObject gO;
	gO=Layr.GraphObjects(strLabelName);
	if(gO.IsValid()==false)
	{
		gO=Layr.CreateGraphObject(GROT_TEXT);
		gO.SetName(strLabelName);
	}
	else
	{
		string strObjType=gO.GetObjectType();
		strObjType.TrimLeft();
		strObjType.TrimRight();
		if(strObjType.CompareNoCase("Text")!=0)
		{
			return (false);
		}
	}
	gO.Text=strLabelText;
	gO.Left=FromLeft;
	gO.Top=FromTop;
	return (true);
}

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