Solved

how to plot data from an array in a new frame.

Posted on 2006-10-23
3
241 Views
Last Modified: 2013-11-20
how can i plot an array filled with integer values, in a new frame, on clicking open  from the file menu?
i wish to open a new frame when i click File->open.
in the new frame , how can i plot the data in the array?

nikhil
0
Comment
Question by:Nikhilesh_K
  • 2
3 Comments
 
LVL 4

Assisted Solution

by:bdunz19
bdunz19 earned 250 total points
ID: 17803790
Hi nikhil,

You are asking, i'm supposing, as to how to graph the data you have in a new frame window, correct? Are you looking for bar graphs or what? You run out of options as you are using an array of integers that is only 1 dimensional.

Anyway, what you would want to do in any situation is create a new CWnd that you would draw yourself and make it a child of your frame view. Then you would pass the array to your new CWnd control and paint the control accordingly (OnPaint()). Once you reply with more specifics I can help your with some code.

Thanks,
Brandon
0
 

Author Comment

by:Nikhilesh_K
ID: 17824507
hi
i m using an array on floating numbers. i have a num.csv file which has the array of integer stored in A1 to A400, reading from the csv file is no problem, but getting it on a new frame is the main problem. i get the data in an array num[400] in the OnFileOpen() , plotting the data in is also not a problem, i did it in OnDraw() class. what i want to try is to plot the same in a new frame. so that another wave can be plot in some other frame. something like multiple frames in the same window.
i hope you are getting what i m trying to say.

nikhil
0
 
LVL 4

Accepted Solution

by:
bdunz19 earned 250 total points
ID: 17835475
Ok, so I think the problem you are having is that the data is cahnging in all the child frames when you open a new data file, am I hitting the mark?

What you should do or rather need to do, is pass the new data to your child frame as a copy, rather than a pointer. This way, each frame will have it's own unique copy of data that will not change (unless you want it to!). So, I personally, would take the route of creating a function like SetDataArray(float *array, int size) in your CChildFrame class. When you create your child frame you can then just call this function to copy the data into your child frame, ie:

CMainFrame* pFrame = STATIC_DOWNCAST(CMainFrame, m_pMainWnd);
// create a new MDI child window
CChildCustList* pChild = (CChildCustList*)pFrame->CreateNewChild(
RUNTIME_CLASS(CChildFrame), IDR_csbillserviceTYPE, m_hMDIMenu, m_hMDIAccel);
// Now pass your data to the class
((CChildFrame*)pChild)->SetDataArray(array, arraysize);


Then pass that array and the array size to your view the same way:

void CChildFrame::SetDataArray(float *array, int size)
{
  m_wndView.SetDataArray(array, size); // Pass this data on to your view class.
}

Once you get it there you need to have a member of your child view class that is a float pointer. Then do something like the following:

void CChildView::SetDataArray(float *array, int size)
{
  m_array = new float[size]; // Allocate the correct size for your array.

  for(int i = 0; i < size; i++)
  {
    m_array[i] = array[i]; // Copy the array
  }

  // Now we have our own class member that is a perfect copy of the array data.
}

Let me know how this works,
Brandon
0

Featured Post

6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

Join & Write a Comment

Suggested Solutions

Introduction: Displaying information on the statusbar.   Continuing from the third article about sudoku.   Open the project in visual studio. Status bar – let’s display the timestamp there.  We need to get the timestamp from the document s…
Have you tried to learn about Unicode, UTF-8, and multibyte text encoding and all the articles are just too "academic" or too technical? This article aims to make the whole topic easy for just about anyone to understand.
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
This video discusses moving either the default database or any database to a new volume.

747 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now