Alan,

Thanks for the quick response. You are correct, this was a rather convoluted piecemeal hack of several examples from both wxwidgets and plplot.

Attached is a simplified version. There is one, and only on, plot function, and a very simple widgets GUI with no buttons or menus. The issue is present, i.e. no tick mark values and no labels. I did not add any external frames, rather than show a difference I opted to show one thing in this example.

The only real difference is that I am using a wxPanel to make the plot in the splitter window.

I am fairly new to both PLplot and wxWidgets so I may be using these functions incorrectly (it is not my intent to unnecessarily spin people up for help but I have tried and am clearly missing something). Viable hypotheses are (1) I'm instantiating the Panel incorrectly, (2) invoking the plot incorrectly, (3) that plots and panels don't work like plots and frames do (and I'm missing some data), (4) there is a size issue and the text I expect to see is outside the limits of the Panel.

As I stated before, in a more complex code base this issue goes away if I "re-plot" the same plot in the same window via an external button push. Would it help if the plot function was "owned" by the myApp?

David


On 5/3/2018 4:45 PM, Alan W. Irwin wrote:
On 2018-05-03 13:56-0400 David Bergman wrote:

P.S. I noticed just after (natch) I sent off my previous post that you
had included source code in your post, but it is hard for me to
evaluate whether you have simplified that example as much as possible.

So here is what I would like you to do instead. Please give us the
simplest possible patch for examples/c++/wxPLplotDemo.cpp that
demonstrates the issue. Such a patch clearly demonstrates the minimal
changes required to show the issue.  It also should allow our current
build and test system to build and test your (slight) modification of
examples/c++/wxPLplotDemo.cpp, and that would be a great convenience
for us when we are attempting to replicate the issue on our various
platforms.

Alan
__________________________
Alan W. Irwin

Astronomical research affiliation with Department of Physics and Astronomy,
University of Victoria (astrowww.phys.uvic.ca).

Programming affiliations with the FreeEOS equation-of-state
implementation for stellar interiors (freeeos.sf.net); the Time
Ephemerides project (timeephem.sf.net); PLplot scientific plotting
software package (plplot.sf.net); the libLASi project
(unifont.org/lasi); the Loads of Linux Links project (loll.sf.net);
and the Linux Brochure Project (lbproject.sf.net).
__________________________

Linux-powered Science
__________________________




---
This email has been checked for viruses by Avast antivirus software.
https://www.avast.com/antivirus
// For compilers that support precompilation, includes "wx/wx.h".
#include "wx/wxprec.h"

#ifdef __BORLANDC__
#pragma hdrstop
#endif

// for all others, include the necessary headers (this file is usually all you
// need because it includes almost all "standard" wxWidgets headers)
#ifndef WX_PRECOMP
        #include "wx/wx.h"
        #include "wx/log.h"

        #include "wx/app.h"
        #include "wx/frame.h"

        #include "wx/scrolwin.h"
        #include "wx/menu.h"
        #include "wx/textctrl.h"
        #include "wx/textdlg.h"  
#endif

#include "wx/wx.h"
#include "wx/app.h"
#include "wx/frame.h"
#include "wx/panel.h"

#include "wx/scrolwin.h"
#include "wx/menu.h"
#include "wx/textctrl.h"
#include "wx/textdlg.h"
#include "wx/intl.h"
#include "wx/file.h"
#include "wx/log.h"
#include "wx/cmdline.h"
#include "wx/calctrl.h"
#include "wx/splitter.h"
#include "wx/dcmirror.h"

//*****
// Cut from wxPLplotDemo
//*****

#include "wxPLplotwindow.h"
#include <stdlib.h>
#include <iostream>
#include <fstream>
#include <string>
#include <sstream>
#include <math.h>
#include <complex>
#include <cmath>

using namespace std;

#define MAX( a, b )    ( ( a ) < ( b ) ? ( b ) : ( a ) )
#define MIN( a, b )    ( ( a ) < ( b ) ? ( a ) : ( b ) )

//  Plotting function
template< class WXWINDOW >
void Plot(wxPLplotwindow<WXWINDOW> *plotwindow)
{
        if (!plotwindow->IsReady())
        {
                wxMessageBox(wxT("Somehow we attempted to plot before the 
wxPLplotwindow was ready. The plot will not be drawn."));
                return;
        }
        wxPLplotstream* pls = plotwindow->GetStream();
        PLPLOT_wxLogDebug("Plot()");
        assert(pls);

        const size_t np = 500;
        PLFLT        x[np], y[np];
        PLFLT        xmin, xmax;
        PLFLT        ymin = 1e30, ymax = 1e-30;

        xmin = -2.0;
        xmax = 10.0;
        for (size_t i = 0; i < np; i++)
        {
                x[i] = (xmax - xmin) * i / np + xmin;
                y[i] = 1.0;
                if (x[i] != 0.0)
                        y[i] = sin(x[i]) / x[i];
                ymin = MIN(ymin, y[i]);
                ymax = MAX(ymax, y[i]);
        }

        pls->scolbg(255, 255, 255);
        pls->scol0(1, 0, 0, 0);
        pls->scol0(2, 0, 130, 130);
        pls->adv(0);
        pls->col0(1);
        pls->width(2);
        pls->env(xmin, xmax, ymin, ymax, 0, 0);
        pls->lab("x", "y", "sin(x)/x");
        pls->col0(3);
        pls->width(2);
        pls->line(np, x, y);

        plotwindow->RenewPlot();
}

// Define a new application type, each program should derive a class from wxApp
class MyApp : public wxApp
{
public:
        MyApp() { }
        virtual bool OnInit() wxOVERRIDE;
        wxDECLARE_NO_COPY_CLASS(MyApp);
};

// Define a new frame type: this is going to be our main frame
class MyFrame : public wxFrame
{
public:
        MyFrame();
private:
        wxPLplotwindow<wxPanel> *m_right;
        wxTextCtrl *m_left;
        wxSplitterWindow* m_splitter;
        wxWindow *m_replacewindow;
};

// ============================================================================
// implementation
// ============================================================================

wxIMPLEMENT_APP(MyApp);

bool MyApp::OnInit()
{
        if (!wxApp::OnInit())
                return false;
        MyFrame *frame = new MyFrame;
        frame->Show(true);
        return true;
}

// frame constructor
MyFrame::MyFrame()
        : wxFrame(NULL, wxID_ANY, wxT("Test!"),
                wxDefaultPosition, wxSize(1020, 600),
                wxDEFAULT_FRAME_STYLE | wxNO_FULL_REPAINT_ON_RESIZE)
{       
        //  Here is a new attempt which uses the splitter window and tries to 
get a plot in one of the windows.
        m_splitter = new wxSplitterWindow(this);
        m_splitter->SetSashGravity(1.0);

        m_left = new wxTextCtrl(m_splitter, wxID_ANY, wxEmptyString,
                wxDefaultPosition, wxDefaultSize,
                wxTE_MULTILINE | wxTE_READONLY);

        m_right = new wxPLplotwindow<wxPanel>();
        m_right->Create(m_splitter, wxID_ANY);

        m_splitter->SplitVertically(m_left, m_right);
        m_splitter->SetSashGravity(0.2);

        Plot(m_right);
        
        m_replacewindow = NULL;
}
------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
Plplot-general mailing list
Plplot-general@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/plplot-general

Reply via email to