Phil

I believe there is stiil an issue with this solution

my sample worked because I had

plcol0(8);

that does the plot in brown color

if I try to plot in black color (on white bacground now) by doing

plcol0(0);

then I have no plot, since color 0 is now white

is there a way with this solution to define color 0 as black for the plot?

I tried to call

plscol0(0, 0, 0, 0);

as

wxPLplotstream* pls = plotwindow->GetStream();
  pls->adv(0);
  pls->scolbg(255, 255, 255);
  pls->clear();
  plscol0(0, 0, 0, 0);

but like this I have the default red on black again


for now, the way I was able to have the black on white background was to 
replicate all the code
of
wxPLplotwindow
wxPLplotwindow

into new classes , giving them another name, commenting the init() call on 
them and then
 doing this code (note that the classes are renamed to wx_PLplotwindow and 
wx_PLplotstream)




bool wxAppPlot::OnInit()
{
  wx_PLplotwindow<wxFrame> *frame = new wx_PLplotwindow<wxFrame>();
  frame->Create(NULL, wxID_ANY, wxT("wxPLplot"),
    wxDefaultPosition,
    wxSize(900, 700));
  frame->Show();

  //set background color (0) to white RGB(255,255,255)
  //must be called before plinit()
  plscolbg(255, 255, 255);

  wx_PLplotstream* pls = frame->GetStream();
  pls->init();

  //change color (0) to black RGB(0, 0, 0)
  //must be called after plinit()
  plscol0(0, 0, 0, 0);

  Plot(frame);
  return true;
}

/////////////////////////////////////////////////////////////////////////////////////////////////////
//Plot
/////////////////////////////////////////////////////////////////////////////////////////////////////

template< class WXWINDOW >
void Plot(wx_PLplotwindow<WXWINDOW> *plotwindow)
{
  wx_PLplotstream* pls = plotwindow->GetStream();

  //render
  const int NSIZE = 101;
  PLFLT x[NSIZE], y[NSIZE];
  PLFLT xmin = 0, xmax = 100, ymin = 0, ymax = 10;

  for (int i = 0; i < NSIZE; i++)
  {
    x[i] = i;
    y[i] = 5;
  }

  plschr(0, 1.0);
  plcol0(0);
  plenv(xmin, xmax, ymin, ymax, 0, 0);
  pllab("x", "y", "Label");
  plpoin(NSIZE, x, y, 46);

  plotwindow->RenewPlot();
}




----- Original Message ----- 
From: "Pedro Vicente" <pedro.vice...@space-research.org>
To: "Phil Rosenberg" <p.d.rosenb...@gmail.com>
Cc: <plplot-gene...@lists.sourceforge.net>; 
<plplot-devel@lists.sourceforge.net>
Sent: Thursday, October 06, 2016 10:44 AM
Subject: Re: [Plplot-devel] [Plplot-general] wxWidgets driver -- change 
thedefault blackbackground


> Hi Phil, Alan
>
> This solution worked for me, thanks
>
>
>> The easiest way to do this at the moment is something like
>>
>> wxPLplotstream* pls = plotwindow->GetStream();
>> pls->adv( 0 );
>> pls->scolbg(255, 255, 255);
>> pls->clear();
>> //rest of your plotting code
>
>
>
>> I'm very open to better ways
>> to do this if you have suggestions.
>
> The only suggestion I have is the one I sent on my previous mail, that
> was *not* to have
>
> wxPLplotstream::Create
>
> call
>
> init()
>
> and let the user do that on his application.
>
>
> By looking at the samples, I believe they all call plinit() at start,
>
>
>
> my complete test code is now
>
>
> #include "wx/wxprec.h"
> #include "wx/wx.h"
> #include "wxPLplotwindow.h"
>
> template< class WXWINDOW >
> void Plot(wxPLplotwindow<WXWINDOW> *plotwindow);
>
> /////////////////////////////////////////////////////////////////////////////////////////////////////
> //wxAppPlot
> /////////////////////////////////////////////////////////////////////////////////////////////////////
>
> class wxAppPlot : public wxApp
> {
> public:
>  virtual bool OnInit();
> };
>
> IMPLEMENT_APP(wxAppPlot)
>
> bool wxAppPlot::OnInit()
> {
>  wxPLplotwindow<wxFrame> *frame = new wxPLplotwindow<wxFrame>();
>  frame->Create(NULL, wxID_ANY, wxT("wxPLplot"),
>    wxDefaultPosition,
>    wxSize(900, 700));
>  frame->Show();
>  Plot(frame);
>  return true;
> }
>
> /////////////////////////////////////////////////////////////////////////////////////////////////////
> //Plot
> /////////////////////////////////////////////////////////////////////////////////////////////////////
>
> template< class WXWINDOW >
> void Plot(wxPLplotwindow<WXWINDOW> *plotwindow)
> {
>  wxPLplotstream* pls = plotwindow->GetStream();
>  pls->adv(0);
>  pls->scolbg(255, 255, 255);
>  pls->clear();
>
>  //render
>
>  const int NSIZE = 101;
>  PLFLT x[NSIZE], y[NSIZE];
>  PLFLT xmin = 0, xmax = 100, ymin = 0, ymax = 10;
>
>  for (int i = 0; i < NSIZE; i++)
>  {
>    x[i] = i;
>    y[i] = 5;
>  }
>
>  plschr(0, 1.0);
>  plcol0(8);
>  plenv(xmin, xmax, ymin, ymax, 0, 0);
>  pllab("x", "y", "Label");
>  plpoin(NSIZE, x, y, 46);
>
>  plotwindow->RenewPlot();
> }
>
>
> -Pedro
>
> ----- Original Message ----- 
> From: "Phil Rosenberg" <p.d.rosenb...@gmail.com>
> To: "Pedro Vicente" <pedro.vice...@space-research.org>
> Cc: <plplot-gene...@lists.sourceforge.net>;
> <plplot-devel@lists.sourceforge.net>
> Sent: Thursday, October 06, 2016 5:55 AM
> Subject: Re: [Plplot-devel] [Plplot-general] wxWidgets driver -- change 
> the
> default blackbackground
>
>
>> Hi Pedro
>> The easiest way to do this at the moment is something like
>>
>> wxPLplotstream* pls = plotwindow->GetStream();
>> pls->adv( 0 );
>> pls->scolbg(255, 255, 255);
>> pls->clear();
>> //rest of your plotting code
>>
>> If you have multiple subpages then you will need to do this on each
>> page. Also if your subpages don't cover all the windows then you can
>> call the SetBackgroundColour method of wxPLplotwindow and this will
>> clear the whole window to the given colour initially.
>>
>> Hope that helps. If not then let me know. I'm very open to better ways
>> to do this if you have suggestions.
>>
>> Phil
>>
>>
>> On 6 October 2016 at 06:00, Pedro Vicente
>> <pedro.vice...@space-research.org> wrote:
>>>
>>> so, there are at least 2 solutions for this :
>>> 1) the quick is just to modify the PLplot source code , in the call to
>>>
>>> void wxPLplotstream::Create
>>>
>>> comment the call to
>>>
>>> //init();
>>>
>>> then in our app code , do the init() call after Create() . as
>>>
>>> ~~~
>>> bool wxAppPlot::OnInit()
>>> {
>>>   wxPLplotwindow<wxFrame> *frame = new wxPLplotwindow<wxFrame>();
>>>   frame->Create(NULL, wxID_ANY, wxT("wxPLplot"),
>>>     wxDefaultPosition,
>>>     wxSize(900, 700));
>>>   frame->Show();
>>>
>>>   //set background color (0) to white RGB(255,255,255)
>>>   //must be called before plinit()
>>>   plscolbg(255, 255, 255);
>>>
>>>   wxPLplotstream* pls = frame->GetStream();
>>>   pls->init();
>>>
>>>   //change color (0) to black RGB(0, 0, 0)
>>>   //must be called after plinit()
>>>   plscol0(0, 0, 0, 0);
>>>
>>>   Plot(frame);
>>>   return true;
>>> }
>>> ~~~
>>>
>>>
>>> since it seems the only way to modiy the background color is to do the
>>> above
>>> sequence
>>> this is a change that I recommend to be included in the libray, since I
>>> believe the other drivers require a call to init() too, but not the
>>> wxWidgets driver.
>>>
>>> 2) not modifying the source code. In this case , I think it should be
>>> possible to derive 2 classes ,
>>> a) one from wxPLplotwindow
>>> b) other from wxPLplotwindow
>>>
>>> then do everything in those classes as now except the call to init()
>>>
>>>
>>> but if the developers could do option 1) that probably would be the best
>>> thanks
>>>
>>>
>>> -Pedro
>>>
>>>
>>>
>>>
>>> ----- Original Message -----
>>> From: Pedro Vicente
>>> To: plplot-gene...@lists.sourceforge.net
>>> Sent: Wednesday, October 05, 2016 6:42 PM
>>> Subject: [Plplot-general] wxWidgets driver -- change the default
>>> blackbackground
>>>
>>> Hi
>>>
>>>
>>> I am trying to change the default black background color using the
>>> wxWidgets
>>> driver
>>>
>>> If using the SVG driver this can be done as explained here
>>>
>>> https://sourceforge.net/p/plplot/mailman/message/2817799/
>>>
>>> the trick being calling
>>>
>>> plscolbg()
>>>
>>> before
>>>
>>> plinit();
>>>
>>> like the  sample code below marked "SVG Driver" does
>>>
>>>
>>> However for the wxWidegts driver , it seems we do not do a call to
>>>
>>> plinit();
>>>
>>> but rather this is done inside the C++ stream initialization
>>>
>>> From the wxWidgets PLplot sample below
>>>
>>> the
>>>
>>> plinit();
>>>
>>> is made inside
>>>
>>>
>>>
>>> frame->Create(NULL, wxID_ANY, wxT("wxPLplot"));
>>>
>>>
>>> so I don't find a way to call the plscolbg() function before
>>>
>>>
>>> How can this be accomplished ?
>>>
>>>
>>>
>>>
>>> I also tried to modify the default colors of the default palette
>>>
>>> cmap0_default.pal
>>>
>>> 16
>>> #000000
>>>
>>> so that the first is white
>>>
>>> this does work *but* only after the window is redrawn (it first shows 
>>> the
>>> default red on black);
>>> this seems like a bug to me
>>>
>>>
>>> Also, what's the call to increase the font size?
>>> On the wxWidgets driver the font looks tiny
>>>
>>> Thanks !
>>>
>>>
>>> Sample code wxWidgets
>>>
>>>
>>>
>>> bool
>>>
>>> wxAppPlot::OnInit()
>>>
>>> {
>>>
>>> wxPLplotwindow<wxFrame> *frame = new wxPLplotwindow<wxFrame>();
>>>
>>> frame->Create(
>>>
>>> NULL, wxID_ANY, wxT("wxPLplot"));
>>>
>>> frame->Show();
>>>
>>> Plot(frame);
>>>
>>> return true;
>>>
>>> }
>>>
>>> /////////////////////////////////////////////////////////////////////////////////////////////////////
>>>
>>> //Plot
>>>
>>> /////////////////////////////////////////////////////////////////////////////////////////////////////
>>>
>>> template
>>>
>>> < class WXWINDOW >
>>>
>>> void
>>>
>>> Plot(wxPLplotwindow<WXWINDOW> *plotwindow)
>>>
>>> {
>>>
>>> wxPLplotstream* pls = plotwindow->GetStream();
>>>
>>> //render
>>>
>>> plotwindow->RenewPlot();
>>>
>>> }
>>>
>>>
>>>
>>>
>>> Sample code SVG driver
>>>
>>> void
>>>
>>> atms_dwell_granu_t::plot()
>>>
>>> {
>>>
>>> //set SVG device and output file name
>>>
>>> plsdev("svg");
>>>
>>> plsfnam("atms_dwell_granu.svg");
>>>
>>> //set background color (0) to white RGB(255,255,255)
>>>
>>> //must be called before plinit()
>>>
>>> plscolbg(255, 255, 255);
>>>
>>> //initialize plplot
>>>
>>> plinit();
>>>
>>> //change color (0) to black RGB(0, 0, 0)
>>>
>>> //must be called after plinit()
>>>
>>> plscol0(0, 0, 0, 0);
>>>
>>> /////////////////////////////////////////////////////////////////////////////////////////////////////
>>>
>>> //render
>>>
>>> /////////////////////////////////////////////////////////////////////////////////////////////////////
>>>
>>> PLFLT xmin, xmax, ymin, ymax;
>>>
>>> PLFLT *x, *y;
>>>
>>> const int NSIZE = iOrbit_all;
>>>
>>> xmin = 0;
>>>
>>> xmax = NSIZE;
>>>
>>> ymin = -1.0;
>>>
>>> ymax = 6.0;
>>>
>>> x =
>>>
>>> new PLFLT[NSIZE];
>>>
>>> y =
>>>
>>> new PLFLT[NSIZE];
>>>
>>> plcol0(0);
>>>
>>> plenv(xmin, xmax, ymin, ymax, 0, 0);
>>>
>>> pllab("", "Current (Amps)", "Scan Drive Main Motor Current");
>>>
>>> //time axis
>>>
>>> for (int idx_orb = 0; idx_orb < NSIZE; idx_orb++)
>>>
>>> {
>>>
>>> x[idx_orb] = idx_orb;
>>>
>>> }
>>>
>>> //mean
>>>
>>> for (int idx_orb = 0; idx_orb < NSIZE; idx_orb++)
>>>
>>> {
>>>
>>> y[idx_orb] = DWELL_SAMPLE_APID517_Orbit[0][TLM_NUM_ORBIT - 1][idx_orb];
>>>
>>> }
>>>
>>> plpoin(NSIZE, x, y, 46);
>>>
>>> plend();
>>>
>>> delete[] x;
>>>
>>> delete[] y;
>>>
>>> }
>>>
>>> ________________________________
>>>
>>> ------------------------------------------------------------------------------
>>> 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-gene...@lists.sourceforge.net
>>> https://lists.sourceforge.net/lists/listinfo/plplot-general
>>>
>>>
>>> ------------------------------------------------------------------------------
>>> Check out the vibrant tech community on one of the world's most
>>> engaging tech sites, SlashDot.org! http://sdm.link/slashdot
>>> _______________________________________________
>>> Plplot-devel mailing list
>>> Plplot-devel@lists.sourceforge.net
>>> https://lists.sourceforge.net/lists/listinfo/plplot-devel
>>>
>>
>
>
> ------------------------------------------------------------------------------
> Check out the vibrant tech community on one of the world's most
> engaging tech sites, SlashDot.org! http://sdm.link/slashdot
> _______________________________________________
> Plplot-devel mailing list
> Plplot-devel@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/plplot-devel
> 


------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most 
engaging tech sites, SlashDot.org! http://sdm.link/slashdot
_______________________________________________
Plplot-devel mailing list
Plplot-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/plplot-devel

Reply via email to