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
 Showing Column Labels?
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic Lock Topic Edit Topic Delete Topic New Topic Reply to Topic

cowsclaw

USA
Posts

Posted - 08/26/2004 :  3:41:17 PM  Show Profile  Edit Topic  Reply with Quote  View user's IP address  Delete Topic
I am trying to show the column labels using the
wksData.ShowLabels();
command. Whenever I run my script, the labels still do not show up. When I go to Format>Worksheet to manually make it show the labels, the check mark is already there. In order to make the labels come up, I have to uncheck it and click ok then recheck it and click ok.

Is this a bug? What is wrong with my code?
//purpose: generate angle data given initial and final angle and step size; plot angle vs. intensity (given in data file in one column)
#include <origin.h>


void xrd_plot(string strFileName)
{


float FirstAngle = 0;
float ScanRange = 0;
float FinalAngle = 0;
float StepSize = 0;

int iLen = strFileName.GetLength();
int iSlash = strFileName.ReverseFind('\\');
int iDot = strFileName.ReverseFind('.');
string strSampleName = strFileName.Mid( iSlash + 1, iDot - iSlash - 1);
printf("Processing file: %s .......", strSampleName);

//Declare root folder of PE for the current project
Folder fldRootFolder = Project.RootFolder;

//Make this folder active
fldRootFolder.Activate();

//Get file path of current project
string strProjectPath;
strProjectPath = Project.GetPath();

//Create a worksheet using custom template
Worksheet wksData;
//string strWksTemplate = "Z:\Origin_script_templates\xrd.OTW";
int nOptionW = CREATE_VISIBLE_SAME;
bool bRetW = wksData.Create();


//Open file and read data into worksheet
stdioFile ffDataFile;
ffDataFile.Open(strFileName, file::modeRead);
int i = 0; //count number
int j = 0;
int iNumberPts = 0;
string strTemp;
string strType = " ";
for(i = 1; i<22; i++)
{
ffDataFile.ReadString(strTemp);
switch(i)
{
case 15:
strType = strTemp.GetToken(1);
case 16:
FirstAngle = atof(strTemp.GetToken(1));
case 17:
ScanRange = atof(strTemp.GetToken(1));
case 18:
StepSize = atof(strTemp.GetToken(1));
case 20:
iNumberPts = atoi(strTemp.GetToken(1));
default:
j++;
} //end switch
}
FinalAngle = FirstAngle + ScanRange;

//Create a graph using custom template
GraphPage grph;
string strTemplate = "Z:\Origin_script_templates\omega2theta.otp";
if(lstrcmpi(strType,"Omega/2Theta") != 0)
{
if(lstrcmpi(strType,"2Theta/Omega") == 0)
strTemplate = "Z:\Origin_script_templates\2thetaomega.OTP";
else if(lstrcmpi(strType,"2Theta") == 0)
strTemplate = "Z:\Origin_script_templates\2theta.OTP";
else if(lstrcmpi(strType,"Theta") == 0)
strTemplate = "Z:\Origin_script_templates\theta.OTP";
}
bool bOK = grph.Create(strTemplate, CREATE_VISIBLE);
if (!bOK)
return;
GraphLayer grlay = grph.Layers(0);
ASSERT(grlay.IsValid());

//Set column widths to fit text name
wksData.Columns(0).SetWidth(strType.GetLength() + 1); //angle
string strTempName = strSampleName.GetToken(0);
wksData.Columns(1).SetWidth(strTempName.GetLength() + 1); //intensity

//Set column names
wksData.Columns(0).SetName("A");
wksData.Columns(1).SetName("B");

//Set column types
wksData.Columns(0).SetType(OKDATAOBJ_DESIGNATION_X);
wksData.Columns(1).SetType(OKDATAOBJ_DESIGNATION_Y);

//Set column labels
wksData.Columns(0).SetLabel(strType);
wksData.Columns(1).SetLabel(strTempName);
wksData.ShowLabels(FALSE);

//Declare datasets in worksheet to copy data from file
Dataset dsAngle(wksData,0);
Dataset dsIntensity(wksData,1);



//Set size to match number of rows (itotal)
dsAngle.SetSize(iNumberPts);
dsIntensity.SetSize(iNumberPts);

for(j=0; j<iNumberPts; j++)
{
dsAngle[j] = j*StepSize + FirstAngle;
ffDataFile.ReadString(strTemp);
dsIntensity[j] = atof(strTemp.GetToken(0));
}
ffDataFile.Close();

Curve cvAvg(dsAngle.GetName(), dsIntensity.GetName());
ASSERT(cvAvg.IsValid());
int blab = grlay.AddPlot(cvAvg);
grlay.Rescale();
Scale s(grlay.X);
s.From = FirstAngle;
s.To = FinalAngle;
wksData.ShowLabels();

}

rlewis

Canada
253 Posts

Posted - 08/26/2004 :  3:56:29 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
after the line "wksData.ShowLabels(); " add the following

wksData.Getpage.Refresh(true);

that should refresh the Worksheep page


Go to Top of Page

rlewis

Canada
253 Posts

Posted - 08/26/2004 :  4:10:53 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
oops ...
Make that ... wksData.GetPage.Refresh(true);
Go to Top of Page

cowsclaw

USA
Posts

Posted - 08/27/2004 :  12:46:35 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
when i try to add that and compile, it says that there is no matching prototype. am i supposed to include some other file?
Go to Top of Page

rlewis

Canada
253 Posts

Posted - 08/27/2004 :  12:55:21 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Sorry ... It should have been

wksData.GetPage().Refresh(true);

must be slipping in my old age ...
Go to Top of Page

cowsclaw

USA
Posts

Posted - 08/27/2004 :  1:01:20 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
I noticed that and i tried it already. I still got the same problem

EDIT: it says there is no matching prototype for the Refresh() function. I couldn't find that function in the Help files either.

Edited by - cowsclaw on 08/27/2004 1:02:50 PM
Go to Top of Page

rlewis

Canada
253 Posts

Posted - 08/27/2004 :  1:11:53 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
The following compiles and executes just fine ... (7.5Pro-SR4)
Thus, there should not be any problems if you are using 7.5-SR4 and your wksData is a valid worksheet ...

void Test_Prog(string strObjName)
{
Worksheet Wks;
if(Wks.Attach(strObjName))
{
Wks.GetPage().Refresh(true);
}
}
Go to Top of Page

cowsclaw

USA
Posts

Posted - 08/27/2004 :  1:19:29 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
it might be because I am using v7.0300 (B300) then (sorry i forgot to mention that). is there any other way to do it?
Go to Top of Page

rlewis

Canada
253 Posts

Posted - 08/27/2004 :  1:42:34 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
you can always try ....
LT_execute("doc -u");
or
LT_execute("doc -uw");
Go to Top of Page

cowsclaw

USA
Posts

Posted - 08/27/2004 :  1:50:35 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
ive tried both of those labtalk commands on wksData and wksData.GetPage() and neither of them work

e.g., wksData.LT_execute("doc -u");
didnt work. nor did
wksData.GetPage().LT_execute("doc -u");
Go to Top of Page

Mike Buess

USA
3037 Posts

Posted - 08/27/2004 :  2:05:25 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
This works fine in Origin 7.0552 (SR4)...

Worksheet wksData = Project.ActiveLayer();
wksData.Columns(0).SetLabel("Test Label");
wksData.ShowLabels();

It isn't necessary to refresh the page. I suggest you apply the SR4 patch.

Mike Buess
Origin WebRing Member
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