There seems to be a bug in the version in Ubuntu Edgy (latest stable
version). The compilation fails with an error for a missing file,
/usr/share/pygtk/2.0/defs/gtk-extrafuncs.defs
Touching this file solves the problem, but then fails with more errors.
/home/andrew/software/plplot/plplot/bindings/wxwidgets/wxPLplotstream.cpp:
In constructor 'wxPLplotstream::wxPLplotstream(wxDC*, int, int, long
int)':
/home/andrew/software/plplot/plplot/bindings/wxwidgets/wxPLplotstream.cpp:47:
error: invalid conversion from 'const char*' to 'char*'
/home/andrew/software/plplot/plplot/bindings/wxwidgets/wxPLplotstream.cpp:47:
error: initializing argument 2 of 'int plstream::SetOpt(char*, char*)'
This is with pygtk 2.10.3 on Linux AMD64.
Anyone else having problems?
Andrew
On Sun, Feb 04, 2007 at 11:21:46PM +0000, Werner Smekal wrote:
> Update of /cvsroot/plplot/plplot/bindings/wxwidgets
> In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv16258/bindings/wxwidgets
>
> Added Files:
> CMakeLists.txt wxPLplotstream.cpp wxPLplotstream.h
> wxPLplotwindow.cpp wxPLplotwindow.h
> Log Message:
> Initial commit of wxwidgets bindings to plplot. This files provide an
> interface to PLplot for wxwidgets applications, similar to the Gnome2
> bindings. Basically a inherited class of plstream (wxPLplotstream) and a
> widget (wxPLplotWindow) are made available. The wxWidgets bindings are
> enabled via -DENABLE_wxwidgets=ON. If the wxWidgets driver is disabled the
> bindings are disabled as well, since the wxWidgets bindings depend on the
> wxWidgets driver.
>
> --- NEW FILE: wxPLplotwindow.h ---
> /* $Id: wxPLplotwindow.h,v 1.1 2007/02/04 23:21:44 smekal Exp $
>
> Copyright (C) 2005 Werner Smekal
>
> This file is part of PLplot.
>
> PLplot is free software; you can redistribute it and/or modify
> it under the terms of the GNU General Library Public License as published
> by the Free Software Foundation; either version 2 of the License, or
> (at your option) any later version.
>
> PLplot is distributed in the hope that it will be useful,
> but WITHOUT ANY WARRANTY; without even the implied warranty of
> MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
> GNU Library General Public License for more details.
>
> You should have received a copy of the GNU Library General Public License
> along with PLplot; if not, write to the Free Software
> Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301
> USA
> */
>
> #if !defined( WXPLPLOTWINDOW_H__INCLUDED_ )
> #define WXPLPLOTWINDOW_H__INCLUDED_
>
> #include "wx/window.h"
> #include "wx/dcmemory.h"
> #include "wxPLplotstream.h"
>
>
> /*! A plot widget which takes care of double buffering and other stuff, but
> does not
> * provide an own plot API. You have to get a pointer to wxPLplotstream via
> the
> * GetStream() method to gain access to the PLplot API.
> */
> class PLDLLIMPEXP wxPLplotwindow : public wxWindow
> {
> public:
> wxPLplotwindow( wxWindow* parent, wxWindowID id=-1, const wxPoint& pos
> = wxDefaultPosition,
> const wxSize& size = wxDefaultSize, long style = 0,
> long pl_style = wxPLPLOT_NONE ); //!< Constructor.
> ~wxPLplotwindow( void ); //!< Deconstructor.
>
> void RenewPlot( void ); //!< Redo plot.
> void SavePlot( const wxString& driver, const wxString& filename );
> //!< Save plot using a different driver.
> wxPLplotstream* GetStream() { return m_stream; } //!< Get pointer to
> wxPLplotstream of this widget.
>
> protected:
> virtual void OnPaint( wxPaintEvent& event ); //!< Paint event.
> virtual void OnErase( wxEraseEvent &WXUNUSED(event) ); //!< Erase
> event.
>
> private:
> // variables regarding double buffering
> wxMemoryDC* MemPlotDC; //!< Pointer to wxMemoryDC, used for double
> buffering
> int MemPlotDC_width; //!< Saved width of MemoryDC, to find out if
> size changed.
> int MemPlotDC_height; //!< Saved height of MemoryDC, to find out if
> size changed.
> wxBitmap* MemPlotDCBitmap; //!< Pointer to bitmap, used for double
> buffering.
>
> protected:
> wxPLplotstream* m_stream; //!< Pointer to the wxPLplotstream
> which belongs to this plot widget
>
> DECLARE_EVENT_TABLE()
> };
>
>
> #endif // !defined( WXPLPLOTWINDOW_H__INCLUDED_ )
>
> --- NEW FILE: wxPLplotwindow.cpp ---
> /* $Id: wxPLplotwindow.cpp,v 1.1 2007/02/04 23:21:44 smekal Exp $
>
> Copyright (C) 2005 Werner Smekal
>
> This file is part of PLplot.
>
> PLplot is free software; you can redistribute it and/or modify
> it under the terms of the GNU General Library Public License as published
> by the Free Software Foundation; either version 2 of the License, or
> (at your option) any later version.
>
> PLplot is distributed in the hope that it will be useful,
> but WITHOUT ANY WARRANTY; without even the implied warranty of
> MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
> GNU Library General Public License for more details.
>
> You should have received a copy of the GNU Library General Public License
> along with PLplot; if not, write to the Free Software
> Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301
> USA
> */
>
> #include "plplotP.h"
> #include "wxPLplotwindow.h"
> #include "wxPLplotstream.h"
> #include "wx/window.h"
>
>
> BEGIN_EVENT_TABLE( wxPLplotwindow, wxWindow )
> EVT_PAINT( wxPLplotwindow::OnPaint )
> EVT_ERASE_BACKGROUND( wxPLplotwindow::OnErase )
> END_EVENT_TABLE()
>
>
> /*! Constructor allocates wxMemoryDC, a wxPLplotstream and initializes
> parameters.
> */
> wxPLplotwindow::wxPLplotwindow( wxWindow* parent, wxWindowID id, const
> wxPoint& pos,
> const wxSize& size, long style, long pl_style
> ) :
> wxWindow( parent, id, pos, size, style|wxFULL_REPAINT_ON_RESIZE )
> {
> // create MemoryDC and set size - if size not set (-1, -1) than
> // set size to (640,400)
> MemPlotDC = new wxMemoryDC;
> if( size.GetWidth()<0 || size.GetHeight()<0 ) {
> MemPlotDC_width = 640;
> MemPlotDC_height = 400;
> } else {
> MemPlotDC_width = size.GetWidth();
> MemPlotDC_height = size.GetHeight();
> }
>
> MemPlotDCBitmap = new wxBitmap( MemPlotDC_width, MemPlotDC_height, -1 );
> MemPlotDC->SelectObject( *MemPlotDCBitmap );
>
> m_stream = new wxPLplotstream( (wxDC*)MemPlotDC, MemPlotDC_width,
> MemPlotDC_height, pl_style );
>
> // tell wxWidgets to leave the background painting to this control
> SetBackgroundStyle( wxBG_STYLE_CUSTOM );
> }
>
>
> /*! Deconstructor takes care that all is deleted in the correct order.
> */
> wxPLplotwindow::~wxPLplotwindow( void )
> {
> MemPlotDC->SelectObject( wxNullBitmap );
>
> if( MemPlotDCBitmap )
> delete MemPlotDCBitmap;
>
> if( m_stream )
> delete m_stream;
>
> delete MemPlotDC;
> }
>
>
> /*! In the OnPaint Method we check if the Windows was resized (will be moved
> to OnSize() sometimes
> * later), we also implement our own double buffering here (since the PLplot
> wxWidgets driver draws
> * into a wxMemoryDC)
> */
> void wxPLplotwindow::OnPaint( wxPaintEvent &WXUNUSED(event) )
> {
> int width, height;
> GetSize( &width, &height );
>
> // Check if we window was resized (or dc is invalid)
> if( (m_stream == NULL) || (MemPlotDC_width!=width) ||
> (MemPlotDC_height!=height) )
> {
> MemPlotDC->SelectObject( wxNullBitmap );
>
> if( MemPlotDCBitmap )
> delete MemPlotDCBitmap;
> MemPlotDCBitmap = new wxBitmap( width, height, -1 );
> MemPlotDC->SelectObject( *MemPlotDCBitmap );
>
> m_stream->SetSize( width, height );
> m_stream->RenewPlot();
>
> MemPlotDC_width = width;
> MemPlotDC_height = height;
> }
>
> wxPaintDC dc( this );
> dc.SetClippingRegion( GetUpdateRegion() );
> dc.Blit( 0, 0, width, height, MemPlotDC, 0, 0 );
> }
>
>
> /*! Together with "SetBackgroundStyle( wxBG_STYLE_CUSTOM );" in the
> constructor this method
> * is responsible that the background is not erased in order to prevent
> flickering.
> */
> void wxPLplotwindow::OnErase( wxEraseEvent &WXUNUSED(event) )
> {
> }
>
>
> /*! Redo the whole plot.
> */
> void wxPLplotwindow::RenewPlot( void )
> {
> if( m_stream ) {
> m_stream->RenewPlot();
> Refresh( true );
> }
> }
>
> --- NEW FILE: CMakeLists.txt ---
> # bindings/wxwidgets/CMakeLists.txt
> ### Process this file with cmake to produce Makefile
> ###
> # Copyright (C) 2007 Werner Smekal
> #
> # This file is part of PLplot.
> #
> # PLplot is free software; you can redistribute it and/or modify
> # it under the terms of the GNU Library General Public License as published
> # by the Free Software Foundation; version 2 of the License.
> #
> # PLplot is distributed in the hope that it will be useful,
> # but WITHOUT ANY WARRANTY; without even the implied warranty of
> # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
> # GNU Library General Public License for more details.
> #
> # You should have received a copy of the GNU Library General Public License
> # along with PLplot; if not, write to the Free Software
> # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301
> USA
>
> if(ENABLE_wxwidgets)
> set(plplotwxwidgets${LIB_TAG}_LIB_SRCS
> wxPLplotstream.cpp
> wxPLplotwindow.cpp
> )
>
> set(plplotwxwidgets${LIB_TAG}_INSTALLED_HEADERS
> wxPLplotstream.h
> wxPLplotwindow.h
> )
>
> # Set the include path
> include_directories(
> ${CMAKE_SOURCE_DIR}/include
> ${CMAKE_SOURCE_DIR}/bindings/c++
> ${CMAKE_BINARY_DIR}
> ${CMAKE_BINARY_DIR}/include
> )
>
> # Create plplotwxwidgets[d] library
> add_library(plplotwxwidgets${LIB_TAG} ${plplotwxwidgets${LIB_TAG}_LIB_SRCS})
>
> if(WIN32 AND BUILD_SHARED_LIBS)
> SET_SOURCE_FILES_PROPERTIES(${plplotwxwidgets${LIB_TAG}_LIB_SRCS}
> PROPERTIES COMPILE_FLAGS "-DMAKINGPLDLL" )
> endif(WIN32 AND BUILD_SHARED_LIBS)
>
> INCLUDE_DIRECTORIES( ${wxWidgets_INCLUDE_DIRS} )
> ADD_DEFINITIONS( ${wxWidgets_DEFINITIONS} )
>
> target_link_libraries(plplotwxwidgets${LIB_TAG} plplotcxx${LIB_TAG}
> ${wxWidgets_LIBRARIES})
>
> get_target_property(LIB_INSTALL_RPATH plplot${LIB_TAG} INSTALL_RPATH)
> set_target_properties(plplotwxwidgets${LIB_TAG}
> PROPERTIES
> SOVERSION ${plplotwxwidgets_SOVERSION}
> VERSION ${plplotwxwidgets_VERSION}
> INSTALL_RPATH "${LIB_INSTALL_RPATH}"
> INSTALL_NAME_DIR "${LIB_DIR}"
> )
>
> # Install library in lib/
> install(TARGETS plplotwxwidgets${LIB_TAG}
> ARCHIVE DESTINATION ${LIB_DIR}
> LIBRARY DESTINATION ${LIB_DIR}
> RUNTIME DESTINATION ${BIN_DIR}
> )
>
> install(FILES
> ${plplotwxwidgets${LIB_TAG}_INSTALLED_HEADERS}
> DESTINATION ${INCLUDE_DIR}
> )
>
> # Configure pkg-config *.pc file corresponding to
> libplplotwxwidgets${LIB_TAG}
> if(PKGCONFIG_EXECUTABLE)
> if(LIB_TAG)
> set(PC_PRECISION "double")
> else(LIB_TAG)
> set(PC_PRECISION "single")
> endif(LIB_TAG)
> # Each list element must consist of a colon-separated string with the
> # following fields which are parsed out in the foreach loop below and
> # used to configure the corresponding pkg-config *.pc file.
> # BINDING - ENABLE_${BINDING} keeps track of whether a
> # binding has been enabled (ON) or not (OFF).
> # Also, ${BINDING} used to determine PC_FILE_SUFFIX
> # which helps to determine name of configured
> # *.pc file.
> # PC_SHORT_NAME - Used in *.pc NAME: field
> # PC_LONG_NAME - Used in *.pc Description: field
> # PC_LIBRARY_NAME - Used in *.pc Libs: field
> # Also used to determine PC_LINK_FLAGS and
> # PC_COMPILE_FLAGS used in *.pc Libs: and Cflags:
> # fields.
> set(PC_DATA "wxwidgets:wxWidgets:wxWidgets bindings,
> :plplotwxwidgets${LIB_TAG}")
>
> string(REGEX REPLACE "^(.*):.*:.*:.*$" "\\1" BINDING ${PC_DATA})
> set(PC_FILE_SUFFIX "-${BINDING}")
> set(PC_REQUIRES "plplotcxx${LIB_TAG}")
> string(REGEX REPLACE "^.*:(.*):.*:.*$" "\\1" PC_SHORT_NAME ${PC_DATA})
> string(REGEX REPLACE "^.*:.*:(.*):.*$" "\\1" PC_LONG_NAME ${PC_DATA})
> string(REGEX REPLACE "^.*:.*:.*:(.*)$" "\\1" PC_LIBRARY_NAME ${PC_DATA})
> set(PC_LINK_FLAGS "${lib${PC_LIBRARY_NAME}_LINK_FLAGS}")
> set(PC_COMPILE_FLAGS "${lib${PC_LIBRARY_NAME}_COMPILE_FLAGS}")
> set(PC_LINK_FLAGS "-l${PC_LIBRARY_NAME} ${PC_LINK_FLAGS}")
> set(PC_CONFIGURED_FILE
> ${CMAKE_BINARY_DIR}/pkgcfg/plplot${LIB_TAG}${PC_FILE_SUFFIX}.pc
> )
> configure_file(
> ${CMAKE_SOURCE_DIR}/pkgcfg/plplot-template.pc.cmake
> ${PC_CONFIGURED_FILE}
> @ONLY
> )
> install(FILES ${PC_CONFIGURED_FILE} DESTINATION ${PKG_CONFIG_DIR})
> endif(PKGCONFIG_EXECUTABLE)
> endif(ENABLE_wxwidgets)
>
> --- NEW FILE: wxPLplotstream.h ---
> /* $Id: wxPLplotstream.h,v 1.1 2007/02/04 23:21:44 smekal Exp $
>
> Copyright (C) 2005 Werner Smekal
>
> This file is part of PLplot.
>
> PLplot is free software; you can redistribute it and/or modify
> it under the terms of the GNU General Library Public License as published
> by the Free Software Foundation; either version 2 of the License, or
> (at your option) any later version.
>
> PLplot is distributed in the hope that it will be useful,
> but WITHOUT ANY WARRANTY; without even the implied warranty of
> MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
> GNU Library General Public License for more details.
>
> You should have received a copy of the GNU Library General Public License
> along with PLplot; if not, write to the Free Software
> Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301
> USA
> */
>
> #if !defined( WXPLPLOTSTREAM_H__INCLUDED_ )
> #define WXPLPLOTSTREAM_H__INCLUDED_
>
> #include "plstream.h"
>
> // forward declarations
> class wxImage;
> class wxDC;
>
> /*! Style options for wxPLplotstream:
> * wxPLPLOT_NONE: no option
> * wxPLPLOT_FREETYPE: use freetype library instead of Hershey fonts
> * wxPLPLOT_SMOOTHTEXT: antialiase font (if freetype library is used)
> * wxPLPLOT_ANTIALIZED: antialize plot (if agg library is available)
> */
> enum wxPLplotstreamstyle {
> wxPLPLOT_NONE = 0,
> wxPLPLOT_FREETYPE = 1,
> wxPLPLOT_SMOOTHTEXT = 2,
> wxPLPLOT_ANTIALIZED = 4
> };
>
> /*! wxPLplotstream is inherited from plstream, which is the C++ interface
> * to the plplot API. The documentation of this interface is described in
> * the PLplot manual, not here.
> */
> class PLDLLIMPEXP wxPLplotstream : public plstream
> {
> public:
> wxPLplotstream( wxDC *dc, int width, int height, long style = wxPLPLOT_NONE
> ); //!< Constructor.
> void set_stream(); //!< Calls some code before every PLplot command.
> void SetSize( int width, int height ); //!< Set new size of plot area.
> void RenewPlot(); //!< Redo plot.
>
> private:
> wxDC* m_dc; //!< Pointer to wxDC to plot into.
> wxImage* m_image; //!< pointer to wxImage
> int m_width; //!< Width of dc/plot area.
> int m_height; //!< Height of dc/plot area.
> long m_style; //!< style of this plot
> };
>
>
> #endif // !defined( WXPLPLOTSTREAM_H__INCLUDED_ )
>
> --- NEW FILE: wxPLplotstream.cpp ---
> /* $Id: wxPLplotstream.cpp,v 1.1 2007/02/04 23:21:44 smekal Exp $
>
> Copyright (C) 2005 Werner Smekal
>
> This file is part of PLplot.
>
> PLplot is free software; you can redistribute it and/or modify
> it under the terms of the GNU General Library Public License as published
> by the Free Software Foundation; either version 2 of the License, or
> (at your option) any later version.
>
> PLplot is distributed in the hope that it will be useful,
> but WITHOUT ANY WARRANTY; without even the implied warranty of
> MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
> GNU Library General Public License for more details.
>
> You should have received a copy of the GNU Library General Public License
> along with PLplot; if not, write to the Free Software
> Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301
> USA
> */
>
> #include "plplotP.h"
> #include "wxPLplotstream.h"
> #include "wx/image.h"
> #include "wx/dcmemory.h"
>
>
> /*! Constructor of wxPLplotstream class which is inherited from plstream.
> * Here we set the driver (wxwidgets :), and tell plplot in which dc to
> * plot to and the size of the canvas. We also check and set several
> * device style options.
> */
> wxPLplotstream::wxPLplotstream( wxDC *dc, int width, int height, long style )
> :
> m_dc(dc), m_width(width), m_height(height), m_style(style)
> {
> ::plstream();
>
> sdev( "wxwidgets" );
> spage( 0.0, 0.0, m_width, m_height, 0, 0 );
>
> // use freetype?
> wxString option=wxString::Format(
> "text=%d,smooth=%d,antialized=%d",
> m_style & wxPLPLOT_FREETYPE ? 1 : 0,
> m_style & wxPLPLOT_SMOOTHTEXT ? 1 : 0,
> m_style & wxPLPLOT_ANTIALIZED ? 1 : 0 );
> SetOpt( "-drvopt", (char*)option.mb_str(*wxConvCurrent) );
>
> init();
> if( m_style & wxPLPLOT_ANTIALIZED ) {
> m_image = new wxImage( m_width, m_height );
> cmd( PLESC_DEVINIT, (void*)m_image );
> } else
> cmd( PLESC_DEVINIT, (void*)m_dc );
> }
>
>
> /*! This is the overloaded set_stream() function, where we could have some
> * code processed before every call of a plplot functions, since set_stream()
> * is called before every plplot function. Not used in the moment.
> */
> void wxPLplotstream::set_stream()
> {
> plstream::set_stream();
> }
>
>
> /*! Call this method if the size of the dc changed (because of resizing)
> * to set the new size. You need to call RenewPlot afterwards.
> */
> void wxPLplotstream::SetSize( int width, int height )
> {
> m_width=width;
> m_height=height;
>
> if( m_style & wxPLPLOT_ANTIALIZED )
> m_image->Resize( wxSize(m_width, m_height), wxPoint(0, 0) );
>
> wxSize size( m_width, m_height );
> cmd( PLESC_RESIZE, (void*)&size );
> }
>
>
> /*! Clear the background and replot everything. TODO: actually this should
> * not be necessary, but bop() is not working as it should?
> */
> void wxPLplotstream::RenewPlot()
> {
> cmd( PLESC_CLEAR, NULL );
> replot();
>
> if( m_style & wxPLPLOT_ANTIALIZED ) {
> wxMemoryDC MemoryDC;
> MemoryDC.SelectObject( wxBitmap(m_image, -1) );
> m_dc->Blit( 0, 0, m_width, m_height, &MemoryDC, 0, 0 );
> MemoryDC.SelectObject( wxNullBitmap );
> }
> }
>
>
>
> -------------------------------------------------------------------------
> Using Tomcat but need to do more? Need to support web services, security?
> Get stuff done quickly with pre-integrated technology to make your job easier.
> Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
> http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
> _______________________________________________
> Plplot-cvs mailing list
> [EMAIL PROTECTED]
> https://lists.sourceforge.net/lists/listinfo/plplot-cvs
>
-------------------------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier.
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
_______________________________________________
Plplot-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/plplot-devel