Solved

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

Posted on 2006-10-23
3
285 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Secure Your Active Directory - April 20, 2017

Active Directory plays a critical role in your company’s IT infrastructure and keeping it secure in today’s hacker-infested world is a must.
Microsoft published 300+ pages of guidance, but who has the time, money, and resources to implement? Register now to find an easier way.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This is to be the first in a series of articles demonstrating the development of a complete windows based application using the MFC classes.  I’ll try to keep each article focused on one (or a couple) of the tasks that one may meet.   Introductio…
If you use Adobe Reader X it is possible you can't open OLE PDF documents in the standard. The reason is the 'save box mode' in adobe reader X. Many people think the protected Mode of adobe reader x is only to stop the write access. But this fe…
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.
How to Install VMware Tools in Red Hat Enterprise Linux 6.4 (RHEL 6.4) Step-by-Step Tutorial

733 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