DPlot Forum Index DPlot
http://www.dplot.com
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

DPLOT structure lpszCommands parameter

 
Post new topic   Reply to topic    DPlot Forum Index -> C, C++, C#
View previous topic :: View next topic  
Author Message
Gogeta70



Joined: 05 Mar 2013
Posts: 7

PostPosted: Mon Mar 11, 2013 5:49 pm    Post subject: DPLOT structure lpszCommands parameter Reply with quote

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:

// 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:

Quote:

[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?
Back to top
View user's profile Send private message
Gogeta70



Joined: 05 Mar 2013
Posts: 7

PostPosted: Mon Mar 11, 2013 6:04 pm    Post subject: Reply with quote

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.
Back to top
View user's profile Send private message
DPlotAdmin
Site Admin


Joined: 24 Jun 2003
Posts: 2290
Location: Vicksburg, Mississippi

PostPosted: Mon Mar 11, 2013 6:55 pm    Post subject: Reply with quote

Quote:
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:
   ' 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;
   }

_________________
David Hyde
support@dplot.com
Back to top
View user's profile Send private message Send e-mail Visit poster's website
Gogeta70



Joined: 05 Mar 2013
Posts: 7

PostPosted: Tue Mar 12, 2013 11:19 am    Post subject: Reply with quote

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?
Back to top
View user's profile Send private message
DPlotAdmin
Site Admin


Joined: 24 Jun 2003
Posts: 2290
Location: Vicksburg, Mississippi

PostPosted: Tue Mar 12, 2013 8:47 pm    Post subject: Reply with quote

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.
_________________
David Hyde
support@dplot.com
Back to top
View user's profile Send private message Send e-mail Visit poster's website
Gogeta70



Joined: 05 Mar 2013
Posts: 7

PostPosted: Wed Mar 13, 2013 10:58 am    Post subject: Reply with quote

Perfect, thank you.
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    DPlot Forum Index -> C, C++, C# All times are GMT - 5 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group