Origin Version 7.5 SR6:
Operating System: Win Vista
and
Origin Version 7.0 SR4:
Operating System: Win XP
I have a problem with the Labtalk getpoint selection tool. When I create a graph with origin C and rescale and maximize the graph window, the internal coordinates of getpoint dotool 2 will be almost everytime false. It's quite funny that clicking manually on the refresh button helps while executing the same script automatically doesn't change anything.
Only the refresh doc -uw in the PointProc macro helps, but thats not a solution.
I have the workaround to ask the user after the point was selected if the point was ok and let him refresh the graph manually.
Here is the sourcecode, the programm needs a wks with data in col 2 and 3.
void hyst()
{
Worksheet wks=Project.ActiveLayer();
if(!wks.IsValid())
{
out_str("Please select a Worksheet");
return;
}
GraphPage grph(wks.GetPage().GetName()+"g");
BOOL bOK=true;
if(!grph.IsValid()) // If graph does not exists, create new one
{
bOK = grph.Create("", CREATE_VISIBLE);
if (!bOK) // break on error
return;
}
// maximize Graph
LT_execute("win -a "+wks.GetPage().GetName()+"g"+";win -z");
// Get the first layer:
GraphLayer grlay = grph.Layers(0);
ASSERT(grlay.IsValid()); //check if ok
// Get the curve object from wks data set "moment"
wks.Columns(2).SetType(OKDATAOBJ_DESIGNATION_X);
Curve cv(wks,2,3); //make curve from wks with X= col2 , Y= col3
ASSERT(cv.IsValid());
// Add one data plot to the graph layer:
bOK = 0 <= grlay.AddPlot(cv);
if (!bOK)
return;
grlay.Rescale(); // Rescale layer
grph.Rename(wks.GetPage().GetName()+"g");
// rescale the dataplot to new range
string str;
str.Format("layer.x.from=%d;layer.x.to=%d;", 0, 20000);
LT_execute(str);
str.Format("layer.y.from=%s;layer.y.to=%d;", "-200", 0);
LT_execute(str);
LT_set_str("%K",wks.GetPage().GetName());
grph.SetShow(PAGE_NORMAL);
grph.Refresh(TRUE); // refresh graph
// grph.SetShow(PAGE_MAXIMIZED); //maximize
grph.Refresh(TRUE); // refresh graph
// execute LT to get points
LT_execute("run.section(%Yrelax\script\hyst.c, getpoint)");
}
#ifdef LABTALK // can be anything not defined
[getpoint]
def EndToolBox
{
nextf(); // start next function
};
def PointProc
{
t=-1;
doc -uw;
type -y "Was the selected point ok?";
if (t==1)
{
{EndToolbox};
doTool 0;
}
else
{
doTool -next;
}
};
// win -a;
plot -c;
label -xb "Magnetic Field (Oe)";
label -yl "Magnetic Moment (emu/g)";
//label -p 50 0 -j 1 "Hysteresis loop";
doc -uw; //window refresh
window -z; // maximize the window
doc -uw; clr; //window refresh
dotool 2;
//getpts -a 1;
clr; doc -uw;
x=11000;
y=-0.5;
//time -p 1;
clr; doc -uw;
//run.section(STANDARD,Refresh);
#endif
void nextf(){return;}
I've already worked more than several days on that problem. There must be something wrong in my code or this is a quite annoying bug.
regards Philipp