DPLOT structure lpszCommands parameter

Q&A for C, C++, and/or C# developers using DPlot

Moderator: DPlotAdmin

Post Reply
Gogeta70
Posts: 7
Joined: Tue Mar 05, 2013 12:08 pm

DPLOT structure lpszCommands parameter

Post by Gogeta70 »

I'm writing a file import plugin for dplot. Since a single curve can only contain up to 1024 points, i'm using multiple curves to represent a single line in a graph. Because of this, i need to set the curves that represent the same line to the same color.

The problem is that chaining together commands doesn't seem to work for the lpszCommands parameter in the DPLOT structure.

Currently, for testing, i just have my code settings all curves to the same color, but it doesn't work...

Here's the gist of the code relating to setting the lpszCommands value:

Code: Select all

// creating and zeroing out the commands variable
	char *commands = new char[10000];
	
	for(int i = 0; i < 10000; i++)
		commands[i] = 0;

// inside the loop for setting the points for each curve
			int clen = strlen(commands);
			
			char addcmd[1000] = {0};
			sprintf(addcmd, "[Color(%lu,255,0,0)]", DPlot->NumCurves);
			
			strcpy(commands+clen, addcmd);

// just before returning PLUGIN_SUCCESS
	fprintf(DEBUG, "%s\r\n", commands);
	DPlot->lpszCommands = commands;
the fprintf() call writes data to a text file for debugging purposes. In this case, i have it write the contents of the lpszCommand variable to the text file. Here is the resulting command string:
[Color(1,255,0,0)][Color(2,255,0,0)][Color(3,255,0,0)][Color(4,255,0,0)][Color(5,255,0,0)][Color(6,255,0,0)][Color(7,255,0,0)][Color(8,255,0,0)][Color(9,255,0,0)][Color(10,255,0,0)]
So why doesn't this work?
Gogeta70
Posts: 7
Joined: Tue Mar 05, 2013 12:08 pm

Post by Gogeta70 »

Ahh, never mind. After searching around DPlot's help file, i found out dplot provides the string in the lpszCommands parameter.

Doing:
strcpy(DPlot->lpszCommands, commands);
Did the the trick.
User avatar
DPlotAdmin
Posts: 2312
Joined: Tue Jun 24, 2003 9:34 pm
Location: Vicksburg, Mississippi
Contact:

Post by DPlotAdmin »

Since a single curve can only contain up to 1024 points
I'm glad you figured out the command string, but the above statement certainly isn't true.

If on entry the MaxPoints member is less than what you need, then do something like this:

Code: Select all

   ' N = maximum number of points in any curve read from the file
   ' M = number of curves in the file
	if(N > (LONG)DPlot->MaxPoints || DPlot->NumCurves+M > (int)DPlot->MaxCurves)
	{
		fclose(f);
		DPlot->MaxPoints = max(DPlot->MaxPoints,N);
		DPlot->MaxCurves = DPlot->NumCurves + M;
		return PLUGIN_BADARRAYSIZE;
	}
Visualize Your Data
support@dplot.com
Gogeta70
Posts: 7
Joined: Tue Mar 05, 2013 12:08 pm

Post by Gogeta70 »

I see, so you can make DPlot resize the arrays.

Is there any max value for MaxPoints or MaxCurves? Say if i set one of those to 1,000,000 (which is just ridiculous) and then returned PLUGIN_BADARRAYSIZE, would it then provide an array that could contain up to 1,000,000 points/curves?
User avatar
DPlotAdmin
Posts: 2312
Joined: Tue Jun 24, 2003 9:34 pm
Location: Vicksburg, Mississippi
Contact:

Post by DPlotAdmin »

The only max. size as far as DPlot is concerned is the magnitude of 32-bit integer: 2 billion+. But you'll run out of memory far before then. 1 million should not be a problem.
Visualize Your Data
support@dplot.com
Gogeta70
Posts: 7
Joined: Tue Mar 05, 2013 12:08 pm

Post by Gogeta70 »

Perfect, thank you.
Post Reply