We help IT Professionals succeed at work.

We've partnered with Certified Experts, Carl Webster and Richard Faulkner, to bring you two Citrix podcasts. Learn about 2020 trends and get answers to your biggest Citrix questions!Listen Now

x

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

Nikhilesh_K
Nikhilesh_K asked
on
Medium Priority
354 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
Comment
Watch Question

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

Not the solution you were looking for? Getting a personalized solution is easy.

Ask the Experts

Author

Commented:
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
Commented:
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
Access more of Experts Exchange with a free account
Thanks for using Experts Exchange.

Create a free account to continue.

Limited access with a free account allows you to:

  • View three pieces of content (articles, solutions, posts, and videos)
  • Ask the experts questions (counted toward content limit)
  • Customize your dashboard and profile

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

OR

Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.