Re: [Plplot-devel] wxPLplotDemo.cpp errors - FIXED , with workaround

2016-12-12 Thread Pedro Vicente

Hi Phil

Here's the fix I did for the linux wxwidgets driver bug

https://github.com/pedro-vicente/plplot-wxwidgets


these are the comments I added in the code



// Modified from PLplot Copyright (C) 2015  Phil Rosenberg
// Changes:
// A non templated class derived from wxFrame
// Use of events by wxDECLARE_EVENT_TABLE()
// Explicit call to CreatePLplotstream() after Create()
//wx_PLplotFrame_stream *frame = new wx_PLplotFrame_stream();
//frame->Create(...);
//frame->CreatePLplotstream();
//frame->Show();

one thing that caught my attention in your code was this way of handling 
events

WXWINDOW::Connect( wxEVT_SIZE, wxSizeEventHandler( 
wxPLplotwindow::OnSize ) );

I usually do a static event table, in fact all the wxWidgets samples do the 
same, except
for some thread related code

but even using the static event table in your code, the bug still was there.
so the only way was to do an explicit call to

frame->CreatePLplotstream();

let me know if you have any questions
-Pedro


- Original Message - 
From: "Pedro Vicente" 
To: "Phil Rosenberg" ; 

Sent: Saturday, December 10, 2016 11:25 PM
Subject: Re: [Plplot-devel] wxPLplotDemo.cpp errors - FIXED , with 
workaround


> Hi Phil
>
> There is actually a very simple solution.
> Instead of figuring out why the OnCreate event is not triggered in some
> linux cases, you can explicitally call that code with some function.
>
> I did just that, like this, where
> frame->CreatePLplotstream();
>
> is a function that contains your code that is in OnCreate()
>
> this makes it needed to a user to call this extra function, but well, you
> can't win them all
>
> this code below makes a plot in Windows and Linux
>
> Note:
> I did my own class
> wx_PLplotFrame
>
> that is virtually identical to wxPLplotwindow, but not templated
>
> I'll put this code in github when I have a chance later
>
> bool wxAppPlot::OnInit()
> {
>  wx_PLplotFrame *frame = new wx_PLplotFrame();
>  frame->Create(NULL, wxID_ANY, wxT("wxPLplot"),
>wxDefaultPosition,
>wxSize(900, 700));
>  frame->CreatePLplotstream();
>  frame->Show();
>  wxPLplotstream* pls = frame->GetStream();
>  assert(pls);
>  PLFLT x[4] = { 1, 2, 3, 4 };
>  PLFLT y[4] = { 1, 2, 3, 4 };
>  pls->env(0, 5, 0, 5, 0, 0);
>  pls->line(4, x, y);
>  return true;
> }
>
> -Pedro
>
>
> - Original Message - 
> From: "Phil Rosenberg" 
> To: "Pedro Vicente" ;
> 
> Sent: Saturday, December 10, 2016 3:57 AM
> Subject: Re: [Plplot-devel] wxPLplotDemo.cpp errors
>
>
>> Hi Pedro
>> I have included the devel list on this email, so the thread will get
>> documented on the mailing list.
>>
>> It is very strange that the OnCreate function is not being called. If
>> you are calling Create then you should be generating a create event.
>> Am I correct in saying that you are getting this segfault with the
>> unchanged demo app?
>>
>> This location really is the best (and maybe only) place this
>> initialisation should be done. It cannot be included in the
>> constructor, because the generic nature of the template specification
>> means the code in the constructor does not know which type of wxWindow
>> we are inheriting from so cannot pass the correct parameters to the
>> constructor. By the time OnPaint is called it is really too late,
>> because we would like to already have the plot initialised and ready
>> to draw and it would be a real pain for you in your code if you had to
>> somehow wait for the first paint or resize event.
>>
>> I do have access to a CentOS machine at work, although I think I have
>> only got access to wxWidgets 2.8 on that system. I will check. I may
>> be able to build 3.1 from source. I presume you are using 3.1.0 as
>> released in February, rather than the head of the master branch?
>>
>> On 10 December 2016 at 07:52, Pedro Vicente
>>  wrote:
>>> Hi Phil
>>>
>>> My idea for a fix is to move the stream initialization that is now  on
>>>
>>> void wxPLplotwindow::OnCreate( wxWindowCreateEvent 
>>> {
>>> if ( !m_created )
>>>
>>> either to the OnSize or onPaint events
>>>
>>> void wxPLplotwindow::OnSize( wxSizeEvent& WXUNUSED( event ) )
>>>
>>> and also in the plot call do this
>>>
>>> template< class WXWINDOW >
>>> void Plot( wxPLplotwindow *plotwindow )
>>> {
>>>wxPLplotstream* pls = plotwindow->GetStream();
>>>
>>>if (pls == NULL)
>>>{
>>>  return;
>>>}
>>>
>>>
>>> Like this , in this sequence
>>>
>>>
>>> wxPLplotwindow *frame = new wxPLplotwindow();
>>>frame->Create( NULL, wxID_ANY, wxT( "wxPLplotDemo" ) );
>>>frame->SetIcon( wxIcon( graph ) );
>>>frame->Show();
>>>Plot( frame );
>>>
>>>
>>> first we go to
>>> Plot( frame );
>>>
>>> but the stream is NULL because
>>> :OnCreate
>>> was not called, but the function returns, avoiding the seg fault

Re: [Plplot-devel] build plplot using CMAKE using MSYS makefiles on windows 10

2016-12-12 Thread Greg Jung
I recognize one aspect of your problems in that winundef.h is imperfectly
written and will fail in the case
of using the unicode wxwidgets without explicitly already being unicode
through-and-through - which is what winundef tries to do. Attached is a
fixed version of that file from wx-3.0/wx/msw/ - I haven't gone to 3.1 yet,
it is probably the same for that.
Greg

On Sat, Dec 10, 2016 at 6:58 AM, Laurent Berger <
laurent.ber...@univ-lemans.fr> wrote:

> Hi phil,
>
> Thanks for your answer.
>
> I have try to solve problem in a bad way :
>
> I have changed some lines in pkg-config.cmake : line298--305 are now :
>
>if(_list_element STREQUAL "-l${_list_element1}")
>  set(_library_pathname "_library_pathname-NOTFOUND")
>  find_library(
>   _library_pathname
>   ${_list_element1}
>   PATHS ${_link_directory_list} "f:/lib/wxWidgets-3.1.0/lib"
> "F:/mingw-w64/x86_64-6.2.0-posix-sjlj-rt_v5-rev1/mingw64/
> x86_64-w64-mingw32/lib32"
>   NO_DEFAULT_PATH
>  )
>
>
> I can start build plplot using MSYS-mingw64. Now I have some compilation
> errors and try to understand it
>
> $ make
> [  3%] Built target csirocsa
> [  6%] Built target deltaT-gen
> [  7%] Built target deltaT.h_built
> [  9%] Built target tai-utc-gen
> [ 10%] Built target tai-utc.h_built
> [ 15%] Built target qsastime
> [ 16%] Built target plhershey-unicode-gen
> [ 18%] Built target plhershey-unicode.h_built
> [ 19%] Building CXX object
> src/CMakeFiles/plplot.dir/__/drivers/wxwidgets_comms.cpp.obj
> In file included from
> F:/mingw-w64/x86_64-6.2.0-posix-sjlj-rt_v5-rev1/mingw64/
> x86_64-w64-mingw32/include/Windows.h:72:0,
>   from G:/Lib/plplot/drivers/wxwidgets_comms.h:25,
>   from G:/Lib/plplot/drivers/wxwidgets_comms.cpp:20:
> F:/lib/wxWidgets-3.1.0/include/wx/msw/winundef.h: In function 'HWND__*
> CreateDialog(HINSTANCE, LPCTSTR, HWND, DLGPROC)':
> F:/lib/wxWidgets-3.1.0/include/wx/msw/winundef.h:38:20: error: cannot
> convert 'LPCTSTR {aka const char*}' to 'LPCWSTR {aka const wchar_t*}'
> for argument '2' to 'HWND__* CreateDialogParamW(HINSTANCE, LPCWSTR,
> HWND, DLGPROC, LPARAM)'
>   return CreateDialogW(hInstance, pTemplate, hwndParent,
> pDlgProc);
>  ^
> In file included from F:/lib/wxWidgets-3.1.0/include/wx/defs.h:3302:0,
>   from F:/lib/wxWidgets-3.1.0/include/wx/font.h:18,
>   from G:/Lib/plplot/drivers/wxwidgets_comms.h:34,
>   from G:/Lib/plplot/drivers/wxwidgets_comms.cpp:20:
> F:/lib/wxWidgets-3.1.0/include/wx/msw/winundef.h: In function 'HFONT__*
> CreateFont(int, int, int, int, int, DWORD, DWORD, DWORD, DWORD, DWORD,
> DWORD, DWORD, DWORD, LPCTSTR)':
> F:/lib/wxWidgets-3.1.0/include/wx/msw/winundef.h:69:48: error: cannot
> convert 'LPCTSTR {aka const char*}' to 'LPCWSTR {aka const wchar_t*}'
> for argument '14' to 'HFONT__* CreateFontW(int, int, int, int, int,
> DWORD, DWORD, DWORD, DWORD, DWORD, DWORD, DWORD, DWORD, LPCWSTR)'
>  family, facename);
>  ^
> In file included from
> F:/mingw-w64/x86_64-6.2.0-posix-sjlj-rt_v5-rev1/mingw64/
> x86_64-w64-mingw32/include/Windows.h:72:0,
>   from G:/Lib/plplot/drivers/wxwidgets_comms.h:25,
>   from G:/Lib/plplot/drivers/wxwidgets_comms.cpp:20:
> F:/lib/wxWidgets-3.1.0/include/wx/msw/winundef.h: In function 'HWND__*
> CreateWindow(LPCTSTR, LPCTSTR, DWORD, int, int, int, int, HWND, HMENU,
> HINSTANCE, LPVOID)':
> F:/lib/wxWidgets-3.1.0/include/wx/msw/winundef.h:94:20: error: cannot
> convert 'LPCTSTR {aka const char*}' to 'LPCWSTR {aka const wchar_t*}'
> for argument '2' to 'HWND__* CreateWindowExW(DWORD, LPCWSTR, LPCWSTR,
> DWORD, int, int, int, int, HWND, HMENU, HINSTANCE, LPVOID)'
>   return CreateWindowW(lpClassName, lpWndClass, dwStyle, x,
> y, w, h,
>  ^
> In file included from F:/lib/wxWidgets-3.1.0/include/wx/defs.h:3302:0,
>   from F:/lib/wxWidgets-3.1.0/include/wx/font.h:18,
>   from G:/Lib/plplot/drivers/wxwidgets_comms.h:34,
>   from G:/Lib/plplot/drivers/wxwidgets_comms.cpp:20:
> F:/lib/wxWidgets-3.1.0/include/wx/msw/winundef.h: In function 'HMENU__*
> LoadMenu(HINSTANCE, LPCTSTR)':
> F:/lib/wxWidgets-3.1.0/include/wx/msw/winundef.h:111:44: error: cannot
> convert 'LPCTSTR {aka const char*}' to 'LPCWSTR {aka const wchar_t*}'
> for argument '2' to 'HMENU__* LoadMenuW(HINSTANCE, LPCWSTR)'
>   return LoadMenuW(instance, name);
>  ^
> F:/lib/wxWidgets-3.1.0/include/wx/msw/winundef.h: In function 'HWND__*
> FindText(LPFINDREPLACE)':
> F:/lib/wxWidgets-3.1.0/include/wx/msw/winundef.h:126:43: error: cannot
> convert 'LPFINDREPLACE {aka tagFINDREPLACEA*}' to 'LPFINDREPLACEW {aka
> tagFINDREPLACEW*}' for argument '1' to 'HWND__* FindTextW(LPFINDREPLACEW)'
>   

Re: [Plplot-devel] build plplot using CMAKE using MSYS makefiles on windows 10

2016-12-12 Thread Phil Rosenberg
Hmm
And the fact that the wx libraries that were found have the suffix u,
suggests they were built with Unicode support. Perhaps the compile
issue you had was because plplot was not built with the Unicode flag
on. As I said instructions are on the wiki to do this for a visual
studio build at
https://sourceforge.net/p/plplot/wiki/Configure_PLplot_for_the_Visual_Studio_IDE/,
but I don't know how one would do it in MSYS. Perhaps setting the same
flags would do it.

Phil

On 11 December 2016 at 10:23, Alan W. Irwin  wrote:
> On 2016-12-10 01:11- Phil Rosenberg wrote:
>
>> I'm sorry Laurent, but I think I am the main Windows user on the list
>> and I have absolutely no experience with MSys.
>>
>> However, I believe we have now returned to the CMake default wxWidgets
>> find module. Alan, can you comment on this and whether this looks like
>> a bug in that module or a bug in our build system?
>
>
> @ Phil and Laurent:
>
> Yes, we are using the absolutely latest official CMake wxWidgets find
> module that is heavily maintained by the CMake developers.  So I doubt
> there are any obvious bugs in that find module.
>
> @Laurent:
>
> My apologies for not answering sooner but I was otherwise occupied with
> other issues currently being discussed on the PLplot devel list.
>
> The short explanation of the message you were getting is that our build
> system gets a list of libraries from the official find module.  Some of
> those are actual locations, and some are in the -L...-l... form.  So we
> transform the latter to actual location by looking for the library
> using the find_library command, and for some reason some of those
> could not be found.  The cure for this is to identify the libraries
> that were not found from comparing the old and transformed lists, then
> installing the relevant libraries or adjust environment variables
> such as PATH and/or CMAKE_LIBRARY_PATH to help CMake find the
> relevant libraries.
>
> I must say, however, that the comparison of the two lists given to you
> is a far less than optimal way to find what libraries could not be
> found so I plan in the next few days to update that part of our build
> system to make this WARNING message a lot clearer.
>
> For now, though, you are stuck with correlating the following two
> lists (i.e., search for a NOTFOUND result on the second list and find
> from its position what -l form it corresponded to in the orignal list)
> to find what libraries are missing.
>
>>> cmake_link_flags WARNING: (original link flags) =
>>>
>>> -L/f/lib/wxWidgets-3.1.0/lib;;;-Wl,--subsystem,windows;-mwindows;/f/lib/wxWidgets-3.1.0/lib/libwx_mswu_core-3.1.a;/f/lib/wxWidgets-3.1.0/lib/libwx_baseu-3.1.a;-lwxregexu-3.1;-lwxexpat-3.1;-lwxtiff-3.1;-lwxjpeg-3.1;-lwxpng-3.1;-lz;-lrpcrt4;-loleaut32;-lole32;-luuid;-lwinspool;-lwinmm;-lshell32;-lshlwapi;-lcomctl32;-lcomdlg32;-ladvapi32;-lversion;-lwsock32;-lgdi32
>>>
>>> cmake_link_flags WARNING: wxwidgets_LINK_FLAGS =
>>>
>>> -Wl,--subsystem,windows;-mwindows;/f/lib/wxWidgets-3.1.0/lib/libwx_mswu_core-3.1.a;/f/lib/wxWidgets-3.1.0/lib/libwx_baseu-3.1.a;_library_pathname-NOTFOUND;_library_pathname-NOTFOUND;_library_pathname-NOTFOUND;_library_pathname-NOTFOUND;_library_pathname-NOTFOUND;F:/mingw-w64/Strawberry/c/lib/libz.a;C:/Windows/System32/rpcrt4.dll;C:/Windows/System32/oleaut32.dll;C:/Windows/System32/ole32.dll;_library_pathname-NOTFOUND;_library_pathname-NOTFOUND;C:/Windows/System32/winmm.dll;C:/Windows/System32/shell32.dll;C:/Windows/System32/shlwapi.dll;C:/Windows/System32/comctl32.dll;C:/Windows/System32/comdlg32.dll;C:/Windows/System32/advapi32.dll;C:/Windows/System32/version.dll;C:/Windows/System32/wsock32.dll;C:/Windows/System32/gdi32.dll
>
>
> To make the explanation simpler, let me break down both lists at the
> semicolons:
>
> That means original =
>
>
> -L/f/lib/wxWidgets-3.1.0/lib;
> ;
> ;
> -Wl,--subsystem,windows;
> -mwindows;
> /f/lib/wxWidgets-3.1.0/lib/libwx_mswu_core-3.1.a;
> /f/lib/wxWidgets-3.1.0/lib/libwx_baseu-3.1.a;
> -lwxregexu-3.1;
> -lwxexpat-3.1;
> -lwxtiff-3.1;
> -lwxjpeg-3.1;
> -lwxpng-3.1;
> -lz;
> -lrpcrt4;
> -loleaut32;
> -lole32;
> -luuid;
> -lwinspool;
> -lwinmm;
> -lshell32;
> -lshlwapi;
> -lcomctl32;
> -lcomdlg32;
> -ladvapi32;
> -lversion;
> -lwsock32;
> -lgdi32
>
> Transformed = -Wl,--subsystem,windows;
> -mwindows;
> /f/lib/wxWidgets-3.1.0/lib/libwx_mswu_core-3.1.a;
> /f/lib/wxWidgets-3.1.0/lib/libwx_baseu-3.1.a;
> _library_pathname-NOTFOUND;
> _library_pathname-NOTFOUND;
> _library_pathname-NOTFOUND;
> _library_pathname-NOTFOUND;
> _library_pathname-NOTFOUND;
> F:/mingw-w64/Strawberry/c/lib/libz.a;
> C:/Windows/System32/rpcrt4.dll;
> C:/Windows/System32/oleaut32.dll;
> C:/Windows/System32/ole32.dll;
> _library_pathname-NOTFOUND;
> _library_pathname-NOTFOUND;
> C:/Windows/System32/winmm.dll;
> C:/Windows/System32/shell32.dll;
> C:/Windows/System32/shlwapi.dll;
> C:/Windows/System32/comctl32.dll;
> C:/Windows/System32/comdlg32.dll;
>