Skip to content

Commit f0b6124

Browse files
GillesDuvertGiloo
andauthored
Erase with wx ok . (#2141)
Co-authored-by: Giloo <gildas@localhost>
1 parent 1a2f83c commit f0b6124

3 files changed

Lines changed: 34 additions & 38 deletions

File tree

src/gdlwxstream.cpp

Lines changed: 33 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@
1515
* *
1616
***************************************************************************/
1717

18+
#include <wx-3.0/wx/graphics.h>
19+
1820
#include "includefirst.hpp"
1921

2022
#ifdef HAVE_LIBWXWIDGETS
@@ -192,26 +194,41 @@ unsigned long GDLWXStream::GetWindowDepth() {
192194
return wxDisplayDepth();
193195
}
194196

197+
// GD removed use of (wrong) plplot erase function
195198
void GDLWXStream::Clear() {
196-
PLINT red,green,blue;
197-
DByte r,g,b;
198-
PLINT red0,green0,blue0;
199-
200-
GraphicsDevice::GetCT()->Get(0,r,g,b);red=r;green=g;blue=b;
201-
202-
red0=GraphicsDevice::GetDevice()->BackgroundR();
203-
green0=GraphicsDevice::GetDevice()->BackgroundG();
204-
blue0=GraphicsDevice::GetDevice()->BackgroundB();
205-
plstream::scolbg(red0,green0,blue0); //overwrites col[0]
206-
::c_plbop();
207-
::c_plclear();
208-
plstream::scolbg(red,green,blue); //resets col[0]
199+
DByte r = (GraphicsDevice::GetDevice()->BackgroundR());
200+
DByte g = (GraphicsDevice::GetDevice()->BackgroundG());
201+
DByte b = (GraphicsDevice::GetDevice()->BackgroundB());
202+
streamDC->SetBackground(wxBrush(wxColour(r,g,b)));
203+
streamDC->Clear();
204+
Update(); //see #1509
209205
}
210206

211-
//FALSE: REPLACE With Clear(DLong chan) as in X //TBD
212-
void GDLWXStream::Clear(DLong bColor) {
213-
Clear();
207+
void GDLWXStream::Clear(DLong chan) {
208+
DByte r = (GraphicsDevice::GetDevice()->BackgroundR());
209+
DByte g = (GraphicsDevice::GetDevice()->BackgroundG());
210+
DByte b = (GraphicsDevice::GetDevice()->BackgroundB());
211+
wxBitmap bmp=streamDC->GetAsBitmap();
212+
wxImage image=bmp.ConvertToImage();
213+
unsigned char* pixels=image.GetData();
214+
SizeT size=image.GetHeight()*image.GetWidth();
215+
DByte* colorComponent=&r;
216+
switch(chan){
217+
case 0: //R
218+
colorComponent=&r;
219+
break;
220+
case 1:
221+
colorComponent=&g;
222+
break;
223+
case 2:
224+
colorComponent=&b;
225+
break;
226+
}
227+
for (auto i=0; i<size; ++i) pixels[3*i+chan]=*colorComponent;
228+
streamDC->DrawBitmap(wxBitmap(image,3),0,0);
229+
Update(); //see #1509
214230
}
231+
215232
#include <wx/rawbmp.h>
216233
bool GDLWXStream::PaintImage(unsigned char *idata, PLINT nx, PLINT ny, DLong *pos,
217234
DLong trueColorOrder, DLong chan) {

src/gdlwxstream.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ class GDLWXStream: public GDLGStream
7171
// bool UnsetFocus(); UnsetFocus is dangerous: it prevents using wxEvents correctly.
7272
bool SetBackingStore(int value){return true;}
7373
void Clear();
74-
void Clear( DLong bColor);
74+
void Clear( DLong chan);
7575
void Raise();
7676
void Lower();
7777
void Iconic();

src/gdlxstream.cpp

Lines changed: 0 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -140,29 +140,8 @@ void GDLXStream::GetGeometry(long& xSize, long& ySize) {
140140
return true;
141141
}
142142

143-
// plplot 5.3 does not provide the clear function for c++
144-
145143
void GDLXStream::Clear() {
146144
Clear(-1);
147-
// // this mimics better the *DL behaviour but plbop create a new page, etc..
148-
// //plclear clears only the current subpage. But it clears it. One has
149-
// //just to set the number of subpages to 1
150-
// PLINT red, green, blue;
151-
// DByte r, g, b;
152-
// PLINT red0, green0, blue0;
153-
//
154-
// GraphicsDevice::GetCT( )->Get( 0, r, g, b );
155-
// red = r;
156-
// green = g;
157-
// blue = b;
158-
////we get around the index 0=background color "feature" of plplot. GDL uses a separate backgroud color.
159-
// red0 = GraphicsDevice::GetDevice( )->BackgroundR( );
160-
// green0 = GraphicsDevice::GetDevice( )->BackgroundG( );
161-
// blue0 = GraphicsDevice::GetDevice( )->BackgroundB( );
162-
// plstream::scolbg( red0, green0, blue0 ); //overwrites col[0]
163-
// ::c_plbop( );
164-
//// ::c_plclear( );
165-
// plstream::scolbg( red, green, blue ); //resets col[0]
166145
}
167146

168147
void GDLXStream::Clear(DLong chan) {

0 commit comments

Comments
 (0)