Cleanup
This commit is contained in:
parent
01ebf03110
commit
bee0d69289
|
@ -40,30 +40,6 @@
|
||||||
|
|
||||||
#define METRIC_UNIT_LENGTH (1e9)
|
#define METRIC_UNIT_LENGTH (1e9)
|
||||||
|
|
||||||
void EDA_DRAW_PANEL_GAL::onPaint( wxEvent& event )
|
|
||||||
{
|
|
||||||
m_gal->BeginDrawing();
|
|
||||||
m_gal->SetBackgroundColor( KiGfx::COLOR4D( 0, 0, 0, 1.0 ) );
|
|
||||||
m_gal->ClearScreen();
|
|
||||||
m_gal->SetGridOrigin( VECTOR2D( 0, 0 ) );
|
|
||||||
m_gal->SetGridOriginMarkerSize( 15 );
|
|
||||||
m_gal->SetGridSize( VECTOR2D( METRIC_UNIT_LENGTH / 10000.0, METRIC_UNIT_LENGTH / 10000.0 ) );
|
|
||||||
m_gal->SetGridDrawThreshold( 10 );
|
|
||||||
m_gal->SetLayerDepth( 0 );
|
|
||||||
|
|
||||||
m_gal->DrawGrid();
|
|
||||||
m_view->Redraw();
|
|
||||||
|
|
||||||
m_gal->EndDrawing();
|
|
||||||
m_gal->Flush();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void EDA_DRAW_PANEL_GAL::onSize( wxSizeEvent& aEvent )
|
|
||||||
{
|
|
||||||
m_gal->ResizeScreen( aEvent.GetSize().x, aEvent.GetSize().y );
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
EDA_DRAW_PANEL_GAL::EDA_DRAW_PANEL_GAL( wxWindow* aParentWindow, wxWindowID aWindowId,
|
EDA_DRAW_PANEL_GAL::EDA_DRAW_PANEL_GAL( wxWindow* aParentWindow, wxWindowID aWindowId,
|
||||||
const wxPoint& aPosition, const wxSize& aSize,
|
const wxPoint& aPosition, const wxSize& aSize,
|
||||||
|
@ -102,14 +78,11 @@ EDA_DRAW_PANEL_GAL::EDA_DRAW_PANEL_GAL( wxWindow* aParentWindow, wxWindowID aWin
|
||||||
|
|
||||||
m_viewControls = new KiGfx::WX_VIEW_CONTROLS( m_view, this );
|
m_viewControls = new KiGfx::WX_VIEW_CONTROLS( m_view, this );
|
||||||
|
|
||||||
m_painter = new KiGfx::PCB_PAINTER( m_gal );
|
|
||||||
m_view->SetPainter( m_painter );
|
|
||||||
|
|
||||||
#if wxCHECK_VERSION( 2, 9, 0 )
|
#if wxCHECK_VERSION( 2, 9, 0 )
|
||||||
Connect( KiGfx::EVT_GAL_REDRAW, wxEventHandler( EDA_DRAW_PANEL_GAL::onPaint ), NULL, this );
|
Connect( KiGfx::EVT_GAL_REDRAW, wxPaintEventHandler( EDA_DRAW_PANEL_GAL::onPaint ), NULL, this );
|
||||||
#elif wxCHECK_VERSION( 2, 8, 0 )
|
#elif wxCHECK_VERSION( 2, 8, 0 )
|
||||||
// FIXME Cairo needs this to be uncommented to remove blinking on refreshing
|
// FIXME Cairo needs this to be uncommented to remove blinking on refreshing
|
||||||
Connect( wxEVT_PAINT, wxEventHandler( EDA_DRAW_PANEL_GAL::onPaint ), NULL, this );
|
Connect( wxEVT_PAINT, wxPaintEventHandler( EDA_DRAW_PANEL_GAL::onPaint ), NULL, this );
|
||||||
#endif
|
#endif
|
||||||
Connect( wxEVT_SIZE, wxSizeEventHandler( EDA_DRAW_PANEL_GAL::onSize ), NULL, this );
|
Connect( wxEVT_SIZE, wxSizeEventHandler( EDA_DRAW_PANEL_GAL::onSize ), NULL, this );
|
||||||
}
|
}
|
||||||
|
@ -131,6 +104,30 @@ EDA_DRAW_PANEL_GAL::~EDA_DRAW_PANEL_GAL()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void EDA_DRAW_PANEL_GAL::onPaint( wxPaintEvent& aEvent )
|
||||||
|
{
|
||||||
|
m_gal->BeginDrawing();
|
||||||
|
m_gal->SetBackgroundColor( KiGfx::COLOR4D( 0, 0, 0, 1.0 ) );
|
||||||
|
m_gal->ClearScreen();
|
||||||
|
m_gal->SetGridOrigin( VECTOR2D( 0, 0 ) );
|
||||||
|
m_gal->SetGridOriginMarkerSize( 15 );
|
||||||
|
m_gal->SetGridSize( VECTOR2D( METRIC_UNIT_LENGTH / 10000.0, METRIC_UNIT_LENGTH / 10000.0 ) );
|
||||||
|
m_gal->SetGridDrawThreshold( 10 );
|
||||||
|
m_gal->SetLayerDepth( 0 );
|
||||||
|
|
||||||
|
m_gal->DrawGrid();
|
||||||
|
m_view->Redraw();
|
||||||
|
|
||||||
|
m_gal->EndDrawing();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void EDA_DRAW_PANEL_GAL::onSize( wxSizeEvent& aEvent )
|
||||||
|
{
|
||||||
|
m_gal->ResizeScreen( aEvent.GetSize().x, aEvent.GetSize().y );
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void EDA_DRAW_PANEL_GAL::SwitchBackend( GalType aGalType, bool aUseShaders )
|
void EDA_DRAW_PANEL_GAL::SwitchBackend( GalType aGalType, bool aUseShaders )
|
||||||
{
|
{
|
||||||
if( m_gal )
|
if( m_gal )
|
||||||
|
|
|
@ -51,25 +51,16 @@ CAIRO_GAL::CAIRO_GAL( wxWindow* aParent, wxEvtHandler* aMouseListener,
|
||||||
SetSize( aParent->GetSize() );
|
SetSize( aParent->GetSize() );
|
||||||
|
|
||||||
// Connecting the event handlers
|
// Connecting the event handlers
|
||||||
|
Connect( wxEVT_SIZE, wxSizeEventHandler( CAIRO_GAL::onSize ) );
|
||||||
|
Connect( wxEVT_PAINT, wxPaintEventHandler( CAIRO_GAL::onPaint ) );
|
||||||
|
|
||||||
// Mouse events are skipped to the parent
|
// Mouse events are skipped to the parent
|
||||||
this->Connect( wxEVT_SIZE, wxSizeEventHandler( CAIRO_GAL::onSize ) );
|
Connect( wxEVT_MOTION, wxMouseEventHandler( CAIRO_GAL::skipMouseEvent ) );
|
||||||
this->Connect( wxEVT_PAINT, wxPaintEventHandler( CAIRO_GAL::onPaint ) );
|
Connect( wxEVT_MOUSEWHEEL, wxMouseEventHandler( CAIRO_GAL::skipMouseEvent ) );
|
||||||
this->Connect( wxEVT_ERASE_BACKGROUND, wxEraseEventHandler( CAIRO_GAL::onEraseBackground ) );
|
Connect( wxEVT_RIGHT_DOWN, wxMouseEventHandler( CAIRO_GAL::skipMouseEvent ) );
|
||||||
aParent->Connect( wxEVT_ERASE_BACKGROUND,
|
Connect( wxEVT_RIGHT_UP, wxMouseEventHandler( CAIRO_GAL::skipMouseEvent ) );
|
||||||
wxEraseEventHandler( CAIRO_GAL::onEraseBackground ) );
|
Connect( wxEVT_LEFT_DOWN, wxMouseEventHandler( CAIRO_GAL::skipMouseEvent ) );
|
||||||
aParent->GetParent()->Connect( wxEVT_ERASE_BACKGROUND,
|
Connect( wxEVT_LEFT_UP, wxMouseEventHandler( CAIRO_GAL::skipMouseEvent ) );
|
||||||
wxEraseEventHandler( CAIRO_GAL::onEraseBackground ) );
|
|
||||||
|
|
||||||
SetBackgroundStyle( wxBG_STYLE_CUSTOM );
|
|
||||||
aParent->SetBackgroundStyle( wxBG_STYLE_CUSTOM );
|
|
||||||
aParent->GetParent()->SetBackgroundStyle( wxBG_STYLE_CUSTOM );
|
|
||||||
|
|
||||||
this->Connect( wxEVT_MOTION, wxMouseEventHandler( CAIRO_GAL::skipMouseEvent ) );
|
|
||||||
this->Connect( wxEVT_MOUSEWHEEL, wxMouseEventHandler( CAIRO_GAL::skipMouseEvent ) );
|
|
||||||
this->Connect( wxEVT_RIGHT_DOWN, wxMouseEventHandler( CAIRO_GAL::skipMouseEvent ) );
|
|
||||||
this->Connect( wxEVT_RIGHT_UP, wxMouseEventHandler( CAIRO_GAL::skipMouseEvent ) );
|
|
||||||
this->Connect( wxEVT_LEFT_DOWN, wxMouseEventHandler( CAIRO_GAL::skipMouseEvent ) );
|
|
||||||
this->Connect( wxEVT_LEFT_UP, wxMouseEventHandler( CAIRO_GAL::skipMouseEvent ) );
|
|
||||||
|
|
||||||
// Initialize line attributes map
|
// Initialize line attributes map
|
||||||
lineCapMap[LINE_CAP_BUTT] = CAIRO_LINE_CAP_BUTT;
|
lineCapMap[LINE_CAP_BUTT] = CAIRO_LINE_CAP_BUTT;
|
||||||
|
@ -88,8 +79,6 @@ CAIRO_GAL::CAIRO_GAL( wxWindow* aParent, wxEvtHandler* aMouseListener,
|
||||||
SetCursorColor( COLOR4D( 1.0, 1.0, 1.0, 1.0 ) );
|
SetCursorColor( COLOR4D( 1.0, 1.0, 1.0, 1.0 ) );
|
||||||
initCursor( 21 );
|
initCursor( 21 );
|
||||||
|
|
||||||
screenSizeY = screenSize.y;
|
|
||||||
|
|
||||||
// Allocate memory
|
// Allocate memory
|
||||||
allocateBitmaps();
|
allocateBitmaps();
|
||||||
|
|
||||||
|
@ -105,9 +94,7 @@ CAIRO_GAL::CAIRO_GAL( wxWindow* aParent, wxEvtHandler* aMouseListener,
|
||||||
CAIRO_GAL::~CAIRO_GAL()
|
CAIRO_GAL::~CAIRO_GAL()
|
||||||
{
|
{
|
||||||
// TODO Deleting of list contents like groups and paths
|
// TODO Deleting of list contents like groups and paths
|
||||||
delete[] bitmapBuffer;
|
deleteBitmaps();
|
||||||
delete[] bitmapBufferBackup;
|
|
||||||
delete wxBitmap_;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -117,17 +104,10 @@ void CAIRO_GAL::onPaint( wxPaintEvent& aEvent )
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void CAIRO_GAL::onEraseBackground( wxEraseEvent& aEvent )
|
|
||||||
{
|
|
||||||
// FIXME
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void CAIRO_GAL::ResizeScreen( int aWidth, int aHeight )
|
void CAIRO_GAL::ResizeScreen( int aWidth, int aHeight )
|
||||||
{
|
{
|
||||||
deleteBitmaps();
|
deleteBitmaps();
|
||||||
|
|
||||||
screenSizeY = aHeight;
|
|
||||||
screenSize = VECTOR2D( aWidth, aHeight );
|
screenSize = VECTOR2D( aWidth, aHeight );
|
||||||
|
|
||||||
// Recreate the bitmaps
|
// Recreate the bitmaps
|
||||||
|
@ -141,9 +121,8 @@ void CAIRO_GAL::ResizeScreen( int aWidth, int aHeight )
|
||||||
|
|
||||||
void CAIRO_GAL::onSize( wxSizeEvent& aEvent )
|
void CAIRO_GAL::onSize( wxSizeEvent& aEvent )
|
||||||
{
|
{
|
||||||
wxSize newSize = aEvent.GetSize();
|
ResizeScreen( aEvent.GetSize().x, aEvent.GetSize().y );
|
||||||
|
PostPaint();
|
||||||
ResizeScreen( newSize.x, newSize.y );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -225,7 +204,7 @@ void CAIRO_GAL::EndDrawing()
|
||||||
int offset = 0;
|
int offset = 0;
|
||||||
|
|
||||||
// Copy the cairo image to the wxDC bitmap
|
// Copy the cairo image to the wxDC bitmap
|
||||||
for( int j = 0; j < screenSizeY; j++ )
|
for( int j = 0; j < screenSize.y; j++ )
|
||||||
{
|
{
|
||||||
offset = j * (int) screenSize.x;
|
offset = j * (int) screenSize.x;
|
||||||
|
|
||||||
|
@ -234,7 +213,7 @@ void CAIRO_GAL::EndDrawing()
|
||||||
unsigned int value = bitmapBuffer[offset + column];
|
unsigned int value = bitmapBuffer[offset + column];
|
||||||
pixelIterator.Red() = value >> 16;
|
pixelIterator.Red() = value >> 16;
|
||||||
pixelIterator.Green() = value >> 8;
|
pixelIterator.Green() = value >> 8;
|
||||||
pixelIterator.Blue() = value >> 0;
|
pixelIterator.Blue() = value;
|
||||||
pixelIterator++;
|
pixelIterator++;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -287,7 +266,7 @@ void CAIRO_GAL::SaveScreen()
|
||||||
// Copy the current bitmap to the backup buffer
|
// Copy the current bitmap to the backup buffer
|
||||||
int offset = 0;
|
int offset = 0;
|
||||||
|
|
||||||
for( int j = 0; j < screenSizeY; j++ )
|
for( int j = 0; j < screenSize.y; j++ )
|
||||||
{
|
{
|
||||||
for( int i = 0; i < stride; i++ )
|
for( int i = 0; i < stride; i++ )
|
||||||
{
|
{
|
||||||
|
@ -302,7 +281,7 @@ void CAIRO_GAL::RestoreScreen()
|
||||||
{
|
{
|
||||||
int offset = 0;
|
int offset = 0;
|
||||||
|
|
||||||
for( int j = 0; j < screenSizeY; j++ )
|
for( int j = 0; j < screenSize.y; j++ )
|
||||||
{
|
{
|
||||||
for( int i = 0; i < stride; i++ )
|
for( int i = 0; i < stride; i++ )
|
||||||
{
|
{
|
||||||
|
|
|
@ -88,16 +88,16 @@ OPENGL_GAL::OPENGL_GAL( wxWindow* aParent, wxEvtHandler* aMouseListener,
|
||||||
SetGridLineWidth( 1.0 );
|
SetGridLineWidth( 1.0 );
|
||||||
|
|
||||||
// Connecting the event handlers.
|
// Connecting the event handlers.
|
||||||
this->Connect( wxEVT_SIZE, wxSizeEventHandler( OPENGL_GAL::onSize ) );
|
Connect( wxEVT_SIZE, wxSizeEventHandler( OPENGL_GAL::onSize ) );
|
||||||
this->Connect( wxEVT_PAINT, wxPaintEventHandler( OPENGL_GAL::onPaint ) );
|
Connect( wxEVT_PAINT, wxPaintEventHandler( OPENGL_GAL::onPaint ) );
|
||||||
|
|
||||||
// Mouse events are skipped to the parent
|
// Mouse events are skipped to the parent
|
||||||
this->Connect( wxEVT_MOTION, wxMouseEventHandler( OPENGL_GAL::skipMouseEvent ) );
|
Connect( wxEVT_MOTION, wxMouseEventHandler( OPENGL_GAL::skipMouseEvent ) );
|
||||||
this->Connect( wxEVT_MOUSEWHEEL, wxMouseEventHandler( OPENGL_GAL::skipMouseEvent ) );
|
Connect( wxEVT_MOUSEWHEEL, wxMouseEventHandler( OPENGL_GAL::skipMouseEvent ) );
|
||||||
this->Connect( wxEVT_RIGHT_DOWN, wxMouseEventHandler( OPENGL_GAL::skipMouseEvent ) );
|
Connect( wxEVT_RIGHT_DOWN, wxMouseEventHandler( OPENGL_GAL::skipMouseEvent ) );
|
||||||
this->Connect( wxEVT_RIGHT_UP, wxMouseEventHandler( OPENGL_GAL::skipMouseEvent ) );
|
Connect( wxEVT_RIGHT_UP, wxMouseEventHandler( OPENGL_GAL::skipMouseEvent ) );
|
||||||
this->Connect( wxEVT_LEFT_DOWN, wxMouseEventHandler( OPENGL_GAL::skipMouseEvent ) );
|
Connect( wxEVT_LEFT_DOWN, wxMouseEventHandler( OPENGL_GAL::skipMouseEvent ) );
|
||||||
this->Connect( wxEVT_LEFT_UP, wxMouseEventHandler( OPENGL_GAL::skipMouseEvent ) );
|
Connect( wxEVT_LEFT_UP, wxMouseEventHandler( OPENGL_GAL::skipMouseEvent ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -75,12 +75,11 @@ public:
|
||||||
void SetView( KiGfx::VIEW* aView ) { m_view = aView; }
|
void SetView( KiGfx::VIEW* aView ) { m_view = aView; }
|
||||||
KiGfx::VIEW* GetView() const { return m_view; }
|
KiGfx::VIEW* GetView() const { return m_view; }
|
||||||
|
|
||||||
|
//void Refresh( bool eraseBackground = true, const wxRect* rect = NULL );
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void onPaint( wxEvent& event );
|
void onPaint( wxPaintEvent& aEvent );
|
||||||
void onSize( wxSizeEvent& aEvent );
|
void onSize( wxSizeEvent& aEvent );
|
||||||
void onMotion( wxMouseEvent& event );
|
|
||||||
void onButton( wxMouseEvent& event );
|
|
||||||
void onEraseBackground( wxEvent& event );
|
|
||||||
|
|
||||||
KiGfx::GAL* m_gal; ///< Interface for drawing objects on a 2D-surface
|
KiGfx::GAL* m_gal; ///< Interface for drawing objects on a 2D-surface
|
||||||
KiGfx::VIEW* m_view; ///< Stores view settings (scale, center, etc.)
|
KiGfx::VIEW* m_view; ///< Stores view settings (scale, center, etc.)
|
||||||
|
|
|
@ -377,7 +377,6 @@ private:
|
||||||
* @param aEvent is the paint event.
|
* @param aEvent is the paint event.
|
||||||
*/
|
*/
|
||||||
void onPaint( wxPaintEvent& aEvent );
|
void onPaint( wxPaintEvent& aEvent );
|
||||||
void onEraseBackground( wxEraseEvent& aEvent );
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Window resizing event handler.
|
* @brief Window resizing event handler.
|
||||||
|
|
Loading…
Reference in New Issue