Is it possible to have a gnuplot plot in wxFrame window.

If you are using the main C++ distribution of wxWidgets, Feel free to ask any question related to wxWidgets development here. This means questions regarding to C++ and wxWidgets, not compile problems.
User avatar
[email protected]
Experienced Solver
Experienced Solver
Posts: 68
Joined: Wed Jul 29, 2020 6:06 pm

Re: Is it possible to have a gnuplot plot in wxFrame window.

Post by [email protected] » Wed Jan 13, 2021 9:50 am

Can you try setting the whole SVG as source with wxWebView::SetPage()?

lr83
Earned a small fee
Earned a small fee
Posts: 15
Joined: Sat Nov 28, 2020 2:15 pm

Re: Is it possible to have a gnuplot plot in wxFrame window.

Post by lr83 » Wed Jan 13, 2021 10:57 am

Humm, SetPage() need an html code in a string.
So in a first try, I put the stream in a wxString like that :

Code: Select all

  wxChar* buffer=new wxChar[mos->GetSize()];

  mos->SeekO(0);
  mos->CopyTo(buffer, mos->GetSize());

  wxString page = wxString(buffer);

  m_plotWindow->SetPage(page, "");
  delete buffer;
Result is pretty funny :lol:
Attachments
funny.png
funny.png (67.3 KiB) Viewed 186 times

User avatar
[email protected]
Experienced Solver
Experienced Solver
Posts: 68
Joined: Wed Jul 29, 2020 6:06 pm

Re: Is it possible to have a gnuplot plot in wxFrame window.

Post by [email protected] » Wed Jan 13, 2021 11:17 am

Code: Select all

wxChar * buffer=new wxChar[mos->GetSize()];
Don't use wxChar here.

Use a char or unsigned char buffer and then:

Code: Select all

wxString page = wxString::From8BitData(buffer, mos->GetSize());

lr83
Earned a small fee
Earned a small fee
Posts: 15
Joined: Sat Nov 28, 2020 2:15 pm

Re: Is it possible to have a gnuplot plot in wxFrame window.

Post by lr83 » Wed Jan 13, 2021 12:40 pm

Ok, I try :

Code: Select all

  char * buffer = new char[mos->GetSize()];
  mos->SeekO(0);
  mos->CopyTo(buffer, mos->GetSize());
  wxString page = wxString::From8BitData((const char *)buffer, mos->GetSize());

//  std::cout << "Page:  " << page <<  std::endl;
  m_plotWindow->SetPage(page, "");
and I have a blank page.
Note : I have verified that page string contain well the svg code.

User avatar
[email protected]
Experienced Solver
Experienced Solver
Posts: 68
Joined: Wed Jul 29, 2020 6:06 pm

Re: Is it possible to have a gnuplot plot in wxFrame window.

Post by [email protected] » Wed Jan 13, 2021 1:12 pm

Sorry, i'm out of ideas for now. I'll need to make some tests myself, but i won't have time for that until i get home in a few hours.

lr83
Earned a small fee
Earned a small fee
Posts: 15
Joined: Sat Nov 28, 2020 2:15 pm

Re: Is it possible to have a gnuplot plot in wxFrame window.

Post by lr83 » Wed Jan 13, 2021 1:27 pm

Thanks :wink:
In summary :
- if I get page from the stream with LoadURL("memory:a.svg") => not work
- if I store the stream into a file and after load that file with LoadURL("path to the file") => work

New Pagodi
Super wx Problem Solver
Super wx Problem Solver
Posts: 380
Joined: Tue Jun 20, 2006 6:47 pm
Contact:

Re: Is it possible to have a gnuplot plot in wxFrame window.

Post by New Pagodi » Wed Jan 13, 2021 7:10 pm

It works on windows 10, but it may not work on windows 7. You can maybe try calling

Code: Select all

wxWebViewIE::MSWSetEmulationLevel(wxWEBVIEWIE_EMU_IE11);
That should set the IE rendering engine to use the latest version available. Maybe that latest version can render the SVG.

User avatar
doublemax
Moderator
Moderator
Posts: 15672
Joined: Fri Apr 21, 2006 8:03 pm
Location: $FCE2

Re: Is it possible to have a gnuplot plot in wxFrame window.

Post by doublemax » Thu Jan 14, 2021 12:55 am

I tested this under Windows 7 with the IE7 backend and both the "memory:a.svg" version and the "SetPage" version worked.

Is it possible that you made the calls too early? E.g. the documentation for SetPage says:
When using wxWEBVIEW_BACKEND_IE you must wait for the current page to finish loading before calling SetPage().
For my tests i put the loading code into one of the menu event handlers, and loaded the SVG from there and it worked for both variants.
Use the source, Luke!

lr83
Earned a small fee
Earned a small fee
Posts: 15
Joined: Sat Nov 28, 2020 2:15 pm

Re: Is it possible to have a gnuplot plot in wxFrame window.

Post by lr83 » Thu Jan 14, 2021 9:20 am

And the winner is ... New Pagodi :lol:
I add

Code: Select all

wxWebViewIE::MSWSetEmulationLevel(wxWEBVIEWIE_EMU_IE11);
with the include <wx/msw/webview_ie.h>
and now it work :D :D
Note : I am on Win7 and have IE11 installed (but not used, I use Firefox). WxWidgets is 3.1.4

Note 2 : @doublemax : the load of the svg is complete (my modification from the first version of New Pagodi) so the call can not be too early.

Post Reply