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
 Creating a XYXY graph
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic Lock Topic Edit Topic Delete Topic New Topic Reply to Topic

airflow

USA
Posts

Posted - 12/04/2003 :  02:09:30 AM  Show Profile  Edit Topic  Reply with Quote  View user's IP address  Delete Topic
I cant figure out how to creat a XYXY graph using OriginC.

GraphPage grph;
Curve crv(??????);
grph.Create("VectXYXY.otp", CREATE_VISIBLE);
grph.Layers(0).AddPlot(crv);

Curve can only specify one set of XY.
Could anyone tell me how to creat a XYXY graph?

ML

USA
63 Posts

Posted - 12/04/2003 :  11:57:46 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Hi airflow,

We will add to Origin 7.5 SR2 a couple of utility functions (add_plots_to_layer(), make_plots_tree(), get_plot_type_info() from the code below) to facilitate adding plots to graph layers. For now you can use the code below.

"Your" function (the one that uses those utility functions to create plots) is make_XYXY(). You can call it directly from LabTalk window by passing arguments. As an example I provide (at the bottom of the code below), a little function test_XYXY() that calls make_XYXY().


////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////
#define EXIST_FUNC_PLOT EXIST_PLOT

static int get_plot_type_info(int nPlotID, int nPageType, DWORD dwTargetLayer, DWORD& dwAuxTypeInfo, DWORD& dwAuxPlotInfo, string& strColPattern)
{
int nPlotType = 0;

if(nPlotID)
nPlotType = Project.GetPlotTypeInfo(nPlotID, dwAuxTypeInfo, dwAuxPlotInfo, strColPattern);
if(nPageType)
{
if(EXIST_DATA == nPageType || EXIST_FUNC_PLOT == nPageType)
dwAuxTypeInfo &= ~PCD_CAN_ADD_E_H_L;
if(EXIST_FUNC_PLOT == nPageType)
dwAuxTypeInfo |= PCD_NO_X;
}

if (PCD_LAYER_TRI == dwTargetLayer)
{
DWORD dwSaveModifiers = dwAuxTypeInfo & ( PCD_MODIFIER_SIZE | PCD_MODIFIER_COLOR );
dwAuxTypeInfo = PCD_LAYER_TRI | PCD_EXACT_YCOLS | PCD_Z_PREFER_Y | PCD_GROUP_MULTI_YS | PCD_PREFER_X | PCD_CAN_ADD_E_H_L | PCD_HIDE_ERR_BARS;
dwAuxTypeInfo |= dwSaveModifiers;
}
else if (PCD_LAYER_SMITH == dwTargetLayer)
dwAuxTypeInfo |= PCD_HIDE_ERR_BARS;
return nPlotType;
}


int make_plots_tree(TreeNode &tr, int nPlotType, vector<string> &vsWksPages, vector<string> &vsLayers, vector<string> &vsCols, vector<uint> &vpdesig)
{
DWORD dwAuxTypeInfo, dwLTPlotInfo;
string strColPattern;
uint nExVal = 0;

int nn = get_plot_type_info(nPlotType, EXIST_WKS, 0, dwAuxTypeInfo, dwLTPlotInfo, strColPattern);

int nRet = Project.MakeDataplotsTree(tr, nn, dwAuxTypeInfo, dwLTPlotInfo, strColPattern, nExVal, vpdesig, vsWksPages, vsLayers, vsCols, TRUE);

return nRet;
}


// ---------------------------------------------------------------------------------- //
// It adds one or more plots to a graph layer.
// Parameters:
// lay=graph layer to add the plot(s) to.
// nPlotType=plot type id
// lpcszWksName=the name of the worksheet to take the data from
// vsCols=vector of strings with the column names to use when creating the plot.
// vpdesig=a vector of integers holding the column designations for each column
// from the vector vsCols. The size of the vector vpdesig must match
// the size of the vector vsCols. The column designations must have the
// values from the following enumeration:
// typedef enum tagPlotDesignationEx {
// COLDESIG_NONE = 0,
// COLDESIG_X = 1,
// COLDESIG_Y,
// COLDESIG_Z,
// COLDESIG_ERROR_OR_LABEL_BEGIN,
// COLDESIG_LABEL = COLDESIG_ERROR_OR_LABEL_BEGIN,
// COLDESIG_XERROR,
// COLDESIG_YERROR,
// COLDESIG_YPLUSERROR,
// COLDESIG_ERROR_OR_LABEL_END,
// COLDESIG_YMINUSERROR = COLDESIG_ERROR_OR_LABEL_END,
// COLDESIG_SIZE, // for symbol size in bubble plots
// COLDESIG_COLOR, // for symbol color in scatter color plots
// COLDESIG_VECTOR_ANGLE, // for vector XYAM plots
// COLDESIG_VECTOR_MAGNITUDE, // for vector XYAM plots
// COLDESIG_VECTOR_XEND, // for vector XYXY plots
// COLDESIG_VECTOR_YEND // for vector XYXY plots
// } PlotDesignationEx;
//
// Returns:
// the total number of plots added.
// ---------------------------------------------------------------------------------- //
int add_plots_to_layer(GraphLayer &lay, int nPlotType, LPCSTR lpcszWksName, vector<string> &vsCols, vector<uint> &vpdesig)
{
Tree tr;
vector<string> vsWksPages;
vector<string> vsLayers;

vsWksPages.Add(lpcszWksName);
vsLayers.SetSize(1);


int nRet = make_plots_tree(tr, nPlotType, vsWksPages, vsLayers, vsCols, vpdesig);
if (!nRet)
{
out_str("Cannot create plot tree.");
return FALSE;
}

TreeNode trLayer = tr.FirstNode;
int nNumPlotsAdded = lay.AddPlots(trLayer, ADDPLOTSFROMTREE_NEW);
if (nNumPlotsAdded <= 0)
{
out_str("Failed to add dataplots");
}

return nNumPlotsAdded;
}


// ---------------------------------------------------------------------------------- //
// It creates a graph with a vector XYXY plot.
// Parameters:
// strWksName=the name of the worksheet to take the data from.
// strX1ColName=the name of the column for X1
// strY1ColName=the name of the column for Y1
// strX2ColName=the name of the column for X2
// strY2ColName=the name of the column for Y2
// ---------------------------------------------------------------------------------- //
void make_XYXY(string strWksName, string strX1ColName, string strY1ColName, string strX2ColName, string strY2ColName)
{

GraphPage pg;
// Create a new graph from the template appropriate for vector XYXY graphs:
if ( !pg.Create("VectXYXY"))
{
out_str("Cannot create page");
return;
}

// Get the first layer from the graph:
GraphLayer lay = pg.Layers(0);
if ( !lay )
{
out_str("Cannot get graph layer");
return;
}

// Build the arrays of the column names and designations.
vector<string> vsCols;
vector<uint> vpdesig;

vpdesig.SetSize(4);
vsCols.SetSize(4);

vsCols[0] = strX1ColName;
vpdesig[0] = COLDESIG_X;

vsCols[1] = strY1ColName;
vpdesig[1] = COLDESIG_Y;

vsCols[2] = strX2ColName;
vpdesig[2] = COLDESIG_VECTOR_XEND;

vsCols[3] = strY2ColName;
vpdesig[3] = COLDESIG_VECTOR_YEND;

int nNum = add_plots_to_layer(lay, IDM_PLOT_FLOWVECTOR, strWksName, vsCols, vpdesig);

if (0 < nNum)
lay.Rescale(); // rescale the layer to show all the data points

return;
}

void test_XYXY()
{
// This call assumes, that there exists worksheet "Data1"
// with four columns with names "A", "B", "D", "C".
make_XYXY("Data1", "A", "B", "D", "C");
}

////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////


Edited by - ML on 12/04/2003 3:26:32 PM
Go to Top of Page

airflow

USA
Posts

Posted - 12/05/2003 :  04:39:08 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
WOW!!
Thank you very much,ML!
I will try it.
And Im looking forward to 7.5SR2!!!
Go to Top of Page

airflow

USA
Posts

Posted - 12/05/2003 :  06:03:26 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
I have tried, but couldnt compile this program.
The errors are the syntaxes of add_plots_to_layer,make_plots_tree,get_plot_type_info.
Probably things like "LPCSTR lpcszWksName","TreeNode &tr","DWORD dwTargetLayer" are to blame.
Im now using OriginPro7 SR2.
Could you please tell me what to do?
Go to Top of Page

cpyang

USA
1406 Posts

Posted - 12/05/2003 :  06:34:37 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
quote:

Probably things like "LPCSTR lpcszWksName","TreeNode &tr","DWORD dwTargetLayer" are to blame.



Tree (TreeNode) is a new data type introduced in Origin 7.5, so without Origin 7.5, you will not be able to compile codes using TreeNode.

Also, functions like Project.GetPlotTypeInfo are also Origin 7.5 additions.

CP


Go to Top of Page

airflow

USA
Posts

Posted - 12/05/2003 :  12:00:52 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Oh!
They are not available in 7.0!
I will try using LabTalk, then.
Thank you very much.
Go to Top of Page

airflow

USA
Posts

Posted - 12/06/2003 :  12:34:55 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
>>Origin will assume the next 2 adjacent columns for the second XY.
Hi, Scott!
This is how I can specify 4 columns!!!!
I have been working on it for over 3 days!
It helps me automatically creat vector graphs for PIV(Particle Image Velocimetry)
Thanks a lot!!
Go to Top of Page

airflow

USA
Posts

Posted - 12/06/2003 :  2:27:31 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
I made it!
I could creat a XYXY graph.
But could I ask one last question,please?
I would like to change arrowlength.
But I couldnt figure out how.(Changing its color was not so difficult)
As for its length, I guess I must use LabTalk commands.
I have tried
///////////////////////////////////////
Graph1!layer1.arrowBeginLength = XXX;
This.Graph1!layer1.
system.line4.arrowBeginLength = XXX;
Set WinName_Y -k XXX; //(also tried -ka, -kb)
////////////////////////////////////////
But none of them works.
Help me out please!
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