Re: [Plplot-devel] [Plplot-general] wxWidgets driver -- change thedefault blackbackground

2016-10-06 Thread Pedro Vicente
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 *frame = new wx_PLplotwindow();
  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 *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" 
To: "Phil Rosenberg" 
Cc: ; 

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 *plotwindow);
>
> /
> //wxAppPlot
> /
>
> class wxAppPlot : public wxApp
> {
> public:
>  virtual bool OnInit();
> };
>
> IMPLEMENT_APP(wxAppPlot)
>
> bool wxAppPlot::OnInit()
> {
>  wxPLplotwindow *frame = new wxPLplotwindow();
>  frame->Create(NULL, wxID_ANY, wxT("wxPLplot"),
>wxDefaultPosition,
>wxSize(900, 700));
>  frame->Show();
>  Plot(frame);
>  return true;
> }
>
> /
> //Plot
> /
>
> template< class WXWINDOW >
> void Plot(wxPLplotwindow *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" 
> To: "Pedro Vicente" 
> Cc: ;
> 
> 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

Re: [Plplot-devel] [Plplot-general] wxWidgets driver -- change the default blackbackground

2016-10-06 Thread Pedro Vicente
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 *plotwindow);

/
//wxAppPlot
/

class wxAppPlot : public wxApp
{
public:
  virtual bool OnInit();
};

IMPLEMENT_APP(wxAppPlot)

bool wxAppPlot::OnInit()
{
  wxPLplotwindow *frame = new wxPLplotwindow();
  frame->Create(NULL, wxID_ANY, wxT("wxPLplot"),
wxDefaultPosition,
wxSize(900, 700));
  frame->Show();
  Plot(frame);
  return true;
}

/
//Plot
/

template< class WXWINDOW >
void Plot(wxPLplotwindow *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" 
To: "Pedro Vicente" 
Cc: ; 

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
>  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 *frame = new wxPLplotwindow();
>>   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

Re: [Plplot-devel] [Plplot-general] wxWidgets driver -- change the default blackbackground

2016-10-06 Thread Phil Rosenberg
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
 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 *frame = new wxPLplotwindow();
>   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
> #00
>
> 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 *frame = new wxPLplotwindow();
>
> frame->Create(
>
> NULL, wxID_ANY, wxT("wxPLplot"));
>
> frame->Show();
>
> Plot(frame);
>
> return true;
>
> }
>
> /
>
> //Plot
>
> /
>
> template
>
> < class WXWINDOW >
>
> void
>
> Plot(wxPLplotwindow *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);
>
> pll