Commit 0ac3e1fb authored by Maciej Suminski's avatar Maciej Suminski

Namespace KiGfx->KIGFX.

template<> -> template <>
Some more reformatting according to uncrustify results.
parent 22045b61
...@@ -24,7 +24,8 @@ file( WRITE ${outputFile} "// Do not edit this file, it is autogenerated by CMak ...@@ -24,7 +24,8 @@ file( WRITE ${outputFile} "// Do not edit this file, it is autogenerated by CMak
#define SHADER_SRC_H #define SHADER_SRC_H
const unsigned int shaders_number = ${shadersNumber}; const unsigned int shaders_number = ${shadersNumber};
const char *shaders_src[] = {\n" ) const char* shaders_src[] =
{\n" )
foreach( inputFile ${inputFiles} ) foreach( inputFile ${inputFiles} )
# put the input file name into the output file # put the input file name into the output file
......
...@@ -231,7 +231,7 @@ void EDA_DRAW_FRAME::OnToggleGridState( wxCommandEvent& aEvent ) ...@@ -231,7 +231,7 @@ void EDA_DRAW_FRAME::OnToggleGridState( wxCommandEvent& aEvent )
if( m_galCanvasActive ) if( m_galCanvasActive )
{ {
m_galCanvas->GetGAL()->SetGridVisibility( IsGridVisible() ); m_galCanvas->GetGAL()->SetGridVisibility( IsGridVisible() );
m_galCanvas->GetView()->MarkTargetDirty( KiGfx::TARGET_NONCACHED ); m_galCanvas->GetView()->MarkTargetDirty( KIGFX::TARGET_NONCACHED );
} }
m_canvas->Refresh(); m_canvas->Refresh();
...@@ -391,7 +391,7 @@ void EDA_DRAW_FRAME::OnSelectGrid( wxCommandEvent& event ) ...@@ -391,7 +391,7 @@ void EDA_DRAW_FRAME::OnSelectGrid( wxCommandEvent& event )
{ {
m_galCanvas->GetGAL()->SetGridSize( VECTOR2D( screen->GetGrid().m_Size.x, m_galCanvas->GetGAL()->SetGridSize( VECTOR2D( screen->GetGrid().m_Size.x,
screen->GetGrid().m_Size.y ) ); screen->GetGrid().m_Size.y ) );
m_galCanvas->GetView()->MarkTargetDirty( KiGfx::TARGET_NONCACHED ); m_galCanvas->GetView()->MarkTargetDirty( KIGFX::TARGET_NONCACHED );
} }
m_canvas->Refresh(); m_canvas->Refresh();
...@@ -425,8 +425,8 @@ void EDA_DRAW_FRAME::OnSelectZoom( wxCommandEvent& event ) ...@@ -425,8 +425,8 @@ void EDA_DRAW_FRAME::OnSelectZoom( wxCommandEvent& event )
if( m_galCanvasActive ) if( m_galCanvasActive )
{ {
// Apply computed view settings to GAL // Apply computed view settings to GAL
KiGfx::VIEW* view = m_galCanvas->GetView(); KIGFX::VIEW* view = m_galCanvas->GetView();
KiGfx::GAL* gal = m_galCanvas->GetGAL(); KIGFX::GAL* gal = m_galCanvas->GetGAL();
double zoomFactor = gal->GetWorldScale() / gal->GetZoomFactor(); double zoomFactor = gal->GetWorldScale() / gal->GetZoomFactor();
double zoom = 1.0 / ( zoomFactor * GetZoom() ); double zoom = 1.0 / ( zoomFactor * GetZoom() );
...@@ -954,8 +954,8 @@ void EDA_DRAW_FRAME::AdjustScrollBars( const wxPoint& aCenterPositionIU ) ...@@ -954,8 +954,8 @@ void EDA_DRAW_FRAME::AdjustScrollBars( const wxPoint& aCenterPositionIU )
void EDA_DRAW_FRAME::UseGalCanvas( bool aEnable ) void EDA_DRAW_FRAME::UseGalCanvas( bool aEnable )
{ {
KiGfx::VIEW* view = m_galCanvas->GetView(); KIGFX::VIEW* view = m_galCanvas->GetView();
KiGfx::GAL* gal = m_galCanvas->GetGAL(); KIGFX::GAL* gal = m_galCanvas->GetGAL();
double zoomFactor = gal->GetWorldScale() / gal->GetZoomFactor(); double zoomFactor = gal->GetWorldScale() / gal->GetZoomFactor();
......
...@@ -66,13 +66,13 @@ EDA_DRAW_PANEL_GAL::EDA_DRAW_PANEL_GAL( wxWindow* aParentWindow, wxWindowID aWin ...@@ -66,13 +66,13 @@ EDA_DRAW_PANEL_GAL::EDA_DRAW_PANEL_GAL( wxWindow* aParentWindow, wxWindowID aWin
m_gal->SetZoomFactor( 1.0 ); m_gal->SetZoomFactor( 1.0 );
m_gal->ComputeWorldScreenMatrix(); m_gal->ComputeWorldScreenMatrix();
m_painter = new KiGfx::PCB_PAINTER( m_gal ); m_painter = new KIGFX::PCB_PAINTER( m_gal );
m_view = new KiGfx::VIEW( true ); m_view = new KIGFX::VIEW( true );
m_view->SetPainter( m_painter ); m_view->SetPainter( m_painter );
m_view->SetGAL( m_gal ); m_view->SetGAL( m_gal );
m_viewControls = new KiGfx::WX_VIEW_CONTROLS( m_view, this ); m_viewControls = new KIGFX::WX_VIEW_CONTROLS( m_view, this );
Connect( wxEVT_PAINT, wxPaintEventHandler( EDA_DRAW_PANEL_GAL::onPaint ), NULL, this ); Connect( wxEVT_PAINT, wxPaintEventHandler( EDA_DRAW_PANEL_GAL::onPaint ), NULL, this );
Connect( wxEVT_SIZE, wxSizeEventHandler( EDA_DRAW_PANEL_GAL::onSize ), NULL, this ); Connect( wxEVT_SIZE, wxSizeEventHandler( EDA_DRAW_PANEL_GAL::onSize ), NULL, this );
...@@ -90,7 +90,7 @@ EDA_DRAW_PANEL_GAL::EDA_DRAW_PANEL_GAL( wxWindow* aParentWindow, wxWindowID aWin ...@@ -90,7 +90,7 @@ EDA_DRAW_PANEL_GAL::EDA_DRAW_PANEL_GAL( wxWindow* aParentWindow, wxWindowID aWin
Connect( wxEVT_KEY_UP, wxEventHandler( EDA_DRAW_PANEL_GAL::onEvent ), NULL, this ); Connect( wxEVT_KEY_UP, wxEventHandler( EDA_DRAW_PANEL_GAL::onEvent ), NULL, this );
Connect( wxEVT_KEY_DOWN, wxEventHandler( EDA_DRAW_PANEL_GAL::onEvent ), NULL, this ); Connect( wxEVT_KEY_DOWN, wxEventHandler( EDA_DRAW_PANEL_GAL::onEvent ), NULL, this );
Connect( wxEVT_ENTER_WINDOW, wxEventHandler( EDA_DRAW_PANEL_GAL::onEnter ), NULL, this ); Connect( wxEVT_ENTER_WINDOW, wxEventHandler( EDA_DRAW_PANEL_GAL::onEnter ), NULL, this );
Connect( KiGfx::WX_VIEW_CONTROLS::EVT_REFRESH_MOUSE, Connect( KIGFX::WX_VIEW_CONTROLS::EVT_REFRESH_MOUSE,
wxEventHandler( EDA_DRAW_PANEL_GAL::onEvent ), NULL, this ); wxEventHandler( EDA_DRAW_PANEL_GAL::onEvent ), NULL, this );
m_refreshTimer.SetOwner( this ); m_refreshTimer.SetOwner( this );
...@@ -122,12 +122,12 @@ void EDA_DRAW_PANEL_GAL::onPaint( wxPaintEvent& WXUNUSED( aEvent ) ) ...@@ -122,12 +122,12 @@ void EDA_DRAW_PANEL_GAL::onPaint( wxPaintEvent& WXUNUSED( aEvent ) )
m_lastRefresh = wxGetLocalTimeMillis(); m_lastRefresh = wxGetLocalTimeMillis();
m_gal->BeginDrawing(); m_gal->BeginDrawing();
m_gal->SetBackgroundColor( KiGfx::COLOR4D( 0.0, 0.0, 0.0, 1.0 ) ); m_gal->SetBackgroundColor( KIGFX::COLOR4D( 0.0, 0.0, 0.0, 1.0 ) );
m_gal->ClearScreen(); m_gal->ClearScreen();
m_view->ClearTargets(); m_view->ClearTargets();
// Grid has to be redrawn only when the NONCACHED target is redrawn // Grid has to be redrawn only when the NONCACHED target is redrawn
if( m_view->IsTargetDirty( KiGfx::TARGET_NONCACHED ) ) if( m_view->IsTargetDirty( KIGFX::TARGET_NONCACHED ) )
m_gal->DrawGrid(); m_gal->DrawGrid();
m_view->Redraw(); m_view->Redraw();
m_gal->DrawCursor( m_viewControls->GetCursorPosition() ); m_gal->DrawCursor( m_viewControls->GetCursorPosition() );
...@@ -139,8 +139,8 @@ void EDA_DRAW_PANEL_GAL::onPaint( wxPaintEvent& WXUNUSED( aEvent ) ) ...@@ -139,8 +139,8 @@ void EDA_DRAW_PANEL_GAL::onPaint( wxPaintEvent& WXUNUSED( aEvent ) )
void EDA_DRAW_PANEL_GAL::onSize( wxSizeEvent& aEvent ) void EDA_DRAW_PANEL_GAL::onSize( wxSizeEvent& aEvent )
{ {
m_gal->ResizeScreen( aEvent.GetSize().x, aEvent.GetSize().y ); m_gal->ResizeScreen( aEvent.GetSize().x, aEvent.GetSize().y );
m_view->MarkTargetDirty( KiGfx::TARGET_CACHED ); m_view->MarkTargetDirty( KIGFX::TARGET_CACHED );
m_view->MarkTargetDirty( KiGfx::TARGET_NONCACHED ); m_view->MarkTargetDirty( KIGFX::TARGET_NONCACHED );
} }
...@@ -189,11 +189,11 @@ void EDA_DRAW_PANEL_GAL::SwitchBackend( GalType aGalType ) ...@@ -189,11 +189,11 @@ void EDA_DRAW_PANEL_GAL::SwitchBackend( GalType aGalType )
switch( aGalType ) switch( aGalType )
{ {
case GAL_TYPE_OPENGL: case GAL_TYPE_OPENGL:
m_gal = new KiGfx::OPENGL_GAL( this, this, this ); m_gal = new KIGFX::OPENGL_GAL( this, this, this );
break; break;
case GAL_TYPE_CAIRO: case GAL_TYPE_CAIRO:
m_gal = new KiGfx::CAIRO_GAL( this, this, this ); m_gal = new KIGFX::CAIRO_GAL( this, this, this );
break; break;
case GAL_TYPE_NONE: case GAL_TYPE_NONE:
......
...@@ -31,7 +31,7 @@ ...@@ -31,7 +31,7 @@
#include <gal/cairo/cairo_compositor.h> #include <gal/cairo/cairo_compositor.h>
#include <wx/log.h> #include <wx/log.h>
using namespace KiGfx; using namespace KIGFX;
CAIRO_COMPOSITOR::CAIRO_COMPOSITOR( cairo_t** aMainContext ) : CAIRO_COMPOSITOR::CAIRO_COMPOSITOR( cairo_t** aMainContext ) :
m_current( 0 ), m_currentContext( aMainContext ), m_mainContext( *aMainContext ) m_current( 0 ), m_currentContext( aMainContext ), m_mainContext( *aMainContext )
...@@ -67,6 +67,7 @@ unsigned int CAIRO_COMPOSITOR::CreateBuffer() ...@@ -67,6 +67,7 @@ unsigned int CAIRO_COMPOSITOR::CreateBuffer()
{ {
// Pixel storage // Pixel storage
BitmapPtr bitmap( new unsigned int[m_bufferSize] ); BitmapPtr bitmap( new unsigned int[m_bufferSize] );
memset( bitmap.get(), 0x00, m_bufferSize * sizeof(int) ); memset( bitmap.get(), 0x00, m_bufferSize * sizeof(int) );
// Create the Cairo surface // Create the Cairo surface
......
...@@ -33,7 +33,7 @@ ...@@ -33,7 +33,7 @@
#include <limits> #include <limits>
using namespace KiGfx; using namespace KIGFX;
CAIRO_GAL::CAIRO_GAL( wxWindow* aParent, wxEvtHandler* aMouseListener, CAIRO_GAL::CAIRO_GAL( wxWindow* aParent, wxEvtHandler* aMouseListener,
wxEvtHandler* aPaintListener, const wxString& aName ) : wxEvtHandler* aPaintListener, const wxString& aName ) :
...@@ -92,6 +92,7 @@ CAIRO_GAL::~CAIRO_GAL() ...@@ -92,6 +92,7 @@ CAIRO_GAL::~CAIRO_GAL()
void CAIRO_GAL::BeginDrawing() void CAIRO_GAL::BeginDrawing()
{ {
initSurface(); initSurface();
if( !validCompositor ) if( !validCompositor )
setCompositor(); setCompositor();
...@@ -284,6 +285,7 @@ void CAIRO_GAL::ResizeScreen( int aWidth, int aHeight ) ...@@ -284,6 +285,7 @@ void CAIRO_GAL::ResizeScreen( int aWidth, int aHeight )
if( validCompositor ) if( validCompositor )
compositor->Resize( aWidth, aHeight ); compositor->Resize( aWidth, aHeight );
validCompositor = false; validCompositor = false;
SetSize( wxSize( aWidth, aHeight ) ); SetSize( wxSize( aWidth, aHeight ) );
...@@ -788,6 +790,7 @@ void CAIRO_GAL::ClearTarget( RenderTarget aTarget ) ...@@ -788,6 +790,7 @@ void CAIRO_GAL::ClearTarget( RenderTarget aTarget )
compositor->SetBuffer( overlayBuffer ); compositor->SetBuffer( overlayBuffer );
break; break;
} }
compositor->ClearBuffer(); compositor->ClearBuffer();
// Restore the previous state // Restore the previous state
......
...@@ -26,7 +26,7 @@ ...@@ -26,7 +26,7 @@
#include <gal/color4d.h> #include <gal/color4d.h>
using namespace KiGfx; using namespace KIGFX;
COLOR4D::COLOR4D( EDA_COLOR_T aColor ) COLOR4D::COLOR4D( EDA_COLOR_T aColor )
{ {
...@@ -113,8 +113,10 @@ void COLOR4D::FromHSV( double aInH, double aInS, double aInV ) ...@@ -113,8 +113,10 @@ void COLOR4D::FromHSV( double aInH, double aInS, double aInV )
} }
hh = aInH; hh = aInH;
if( hh >= 360.0 ) if( hh >= 360.0 )
hh = 0.0; hh = 0.0;
hh /= 60.0; hh /= 60.0;
i = (long) hh; i = (long) hh;
...@@ -124,18 +126,20 @@ void COLOR4D::FromHSV( double aInH, double aInS, double aInV ) ...@@ -124,18 +126,20 @@ void COLOR4D::FromHSV( double aInH, double aInS, double aInV )
q = aInV * ( 1.0 - ( aInS * ff ) ); q = aInV * ( 1.0 - ( aInS * ff ) );
t = aInV * ( 1.0 - ( aInS * ( 1.0 - ff ) ) ); t = aInV * ( 1.0 - ( aInS * ( 1.0 - ff ) ) );
switch (i) switch( i )
{ {
case 0: case 0:
r = aInV; r = aInV;
g = t; g = t;
b = p; b = p;
break; break;
case 1: case 1:
r = q; r = q;
g = aInV; g = aInV;
b = p; b = p;
break; break;
case 2: case 2:
r = p; r = p;
g = aInV; g = aInV;
...@@ -147,11 +151,13 @@ void COLOR4D::FromHSV( double aInH, double aInS, double aInV ) ...@@ -147,11 +151,13 @@ void COLOR4D::FromHSV( double aInH, double aInS, double aInV )
g = q; g = q;
b = aInV; b = aInV;
break; break;
case 4: case 4:
r = t; r = t;
g = p; g = p;
b = aInV; b = aInV;
break; break;
case 5: case 5:
default: default:
r = aInV; r = aInV;
...@@ -165,9 +171,9 @@ void COLOR4D::FromHSV( double aInH, double aInS, double aInV ) ...@@ -165,9 +171,9 @@ void COLOR4D::FromHSV( double aInH, double aInS, double aInV )
COLOR4D& COLOR4D::Saturate( double aFactor ) COLOR4D& COLOR4D::Saturate( double aFactor )
{ {
double h, s, v; double h, s, v;
ToHSV( h, s, v ); ToHSV( h, s, v );
FromHSV( h, aFactor, 1.0 ); FromHSV( h, aFactor, 1.0 );
return *this; return *this;
} }
...@@ -29,7 +29,7 @@ ...@@ -29,7 +29,7 @@
#include <gal/graphics_abstraction_layer.h> #include <gal/graphics_abstraction_layer.h>
#include <gal/definitions.h> #include <gal/definitions.h>
using namespace KiGfx; using namespace KIGFX;
GAL::GAL() : GAL::GAL() :
strokeFont( this ) strokeFont( this )
......
...@@ -39,7 +39,7 @@ ...@@ -39,7 +39,7 @@
#include <profile.h> #include <profile.h>
#endif /* __WXDEBUG__ */ #endif /* __WXDEBUG__ */
using namespace KiGfx; using namespace KIGFX;
CACHED_CONTAINER::CACHED_CONTAINER( unsigned int aSize ) : CACHED_CONTAINER::CACHED_CONTAINER( unsigned int aSize ) :
VERTEX_CONTAINER( aSize ), m_item( NULL ) VERTEX_CONTAINER( aSize ), m_item( NULL )
...@@ -157,6 +157,7 @@ void CACHED_CONTAINER::Delete( VERTEX_ITEM* aItem ) ...@@ -157,6 +157,7 @@ void CACHED_CONTAINER::Delete( VERTEX_ITEM* aItem )
// Indicate that the item is not stored in the container anymore // Indicate that the item is not stored in the container anymore
aItem->setSize( 0 ); aItem->setSize( 0 );
} }
m_items.erase( aItem ); m_items.erase( aItem );
#if CACHED_CONTAINER_TEST > 1 #if CACHED_CONTAINER_TEST > 1
...@@ -371,6 +372,7 @@ void CACHED_CONTAINER::mergeFreeChunks() ...@@ -371,6 +372,7 @@ void CACHED_CONTAINER::mergeFreeChunks()
std::list<Chunk> freeChunks; std::list<Chunk> freeChunks;
FreeChunkMap::const_iterator it, it_end; FreeChunkMap::const_iterator it, it_end;
for( it = m_freeChunks.begin(), it_end = m_freeChunks.end(); it != it_end; ++it ) for( it = m_freeChunks.begin(), it_end = m_freeChunks.end(); it != it_end; ++it )
{ {
freeChunks.push_back( std::make_pair( it->second, it->first ) ); freeChunks.push_back( std::make_pair( it->second, it->first ) );
...@@ -527,6 +529,7 @@ void CACHED_CONTAINER::test() ...@@ -527,6 +529,7 @@ void CACHED_CONTAINER::test()
// Free space check // Free space check
unsigned int freeSpace = 0; unsigned int freeSpace = 0;
FreeChunkMap::iterator itf; FreeChunkMap::iterator itf;
for( itf = m_freeChunks.begin(); itf != m_freeChunks.end(); ++itf ) for( itf = m_freeChunks.begin(); itf != m_freeChunks.end(); ++itf )
freeSpace += getChunkSize( *itf ); freeSpace += getChunkSize( *itf );
...@@ -543,4 +546,5 @@ void CACHED_CONTAINER::test() ...@@ -543,4 +546,5 @@ void CACHED_CONTAINER::test()
// Overlapping check TBD // Overlapping check TBD
} }
#endif /* CACHED_CONTAINER_TEST */ #endif /* CACHED_CONTAINER_TEST */
...@@ -37,7 +37,7 @@ ...@@ -37,7 +37,7 @@
#include <profile.h> #include <profile.h>
#endif #endif
using namespace KiGfx; using namespace KIGFX;
GPU_MANAGER* GPU_MANAGER::MakeManager( VERTEX_CONTAINER* aContainer ) GPU_MANAGER* GPU_MANAGER::MakeManager( VERTEX_CONTAINER* aContainer )
{ {
......
...@@ -31,7 +31,7 @@ ...@@ -31,7 +31,7 @@
#include <gal/opengl/noncached_container.h> #include <gal/opengl/noncached_container.h>
#include <cstdlib> #include <cstdlib>
using namespace KiGfx; using namespace KIGFX;
NONCACHED_CONTAINER::NONCACHED_CONTAINER( unsigned int aSize ) : NONCACHED_CONTAINER::NONCACHED_CONTAINER( unsigned int aSize ) :
VERTEX_CONTAINER( aSize ), m_freePtr( 0 ) VERTEX_CONTAINER( aSize ), m_freePtr( 0 )
......
...@@ -31,7 +31,7 @@ ...@@ -31,7 +31,7 @@
#include <gal/opengl/opengl_compositor.h> #include <gal/opengl/opengl_compositor.h>
#include <wx/log.h> #include <wx/log.h>
using namespace KiGfx; using namespace KIGFX;
OPENGL_COMPOSITOR::OPENGL_COMPOSITOR() : OPENGL_COMPOSITOR::OPENGL_COMPOSITOR() :
m_initialized( false ), m_current( 0 ) m_initialized( false ), m_current( 0 )
...@@ -95,7 +95,7 @@ unsigned int OPENGL_COMPOSITOR::CreateBuffer() ...@@ -95,7 +95,7 @@ unsigned int OPENGL_COMPOSITOR::CreateBuffer()
{ {
wxASSERT( m_initialized ); wxASSERT( m_initialized );
//if( usedBuffers() >= m_maxBuffers ) if( usedBuffers() >= m_maxBuffers )
{ {
wxLogError( wxT( "Cannot create more framebuffers. OpenGL rendering backend requires at" wxLogError( wxT( "Cannot create more framebuffers. OpenGL rendering backend requires at"
"least 3 framebuffers. You may try to update/change " "least 3 framebuffers. You may try to update/change "
...@@ -225,6 +225,7 @@ void OPENGL_COMPOSITOR::ClearBuffer() ...@@ -225,6 +225,7 @@ void OPENGL_COMPOSITOR::ClearBuffer()
void OPENGL_COMPOSITOR::DrawBuffer( unsigned int aBufferHandle ) void OPENGL_COMPOSITOR::DrawBuffer( unsigned int aBufferHandle )
{ {
wxASSERT( m_initialized ); wxASSERT( m_initialized );
if( aBufferHandle == 0 || aBufferHandle > usedBuffers() ) if( aBufferHandle == 0 || aBufferHandle > usedBuffers() )
{ {
wxLogError( wxT( "Wrong framebuffer handle" ) ); wxLogError( wxT( "Wrong framebuffer handle" ) );
...@@ -281,6 +282,7 @@ void OPENGL_COMPOSITOR::clean() ...@@ -281,6 +282,7 @@ void OPENGL_COMPOSITOR::clean()
glDeleteRenderbuffers( 1, &m_depthBuffer ); glDeleteRenderbuffers( 1, &m_depthBuffer );
OPENGL_BUFFERS::const_iterator it; OPENGL_BUFFERS::const_iterator it;
for( it = m_buffers.begin(); it != m_buffers.end(); ++it ) for( it = m_buffers.begin(); it != m_buffers.end(); ++it )
{ {
glDeleteTextures( 1, &it->textureTarget ); glDeleteTextures( 1, &it->textureTarget );
......
...@@ -37,7 +37,7 @@ ...@@ -37,7 +37,7 @@
#include <limits> #include <limits>
using namespace KiGfx; using namespace KIGFX;
// Prototypes // Prototypes
void InitTesselatorCallbacks( GLUtesselator* aTesselator ); void InitTesselatorCallbacks( GLUtesselator* aTesselator );
...@@ -90,10 +90,12 @@ OPENGL_GAL::OPENGL_GAL( wxWindow* aParent, wxEvtHandler* aMouseListener, ...@@ -90,10 +90,12 @@ OPENGL_GAL::OPENGL_GAL( wxWindow* aParent, wxEvtHandler* aMouseListener,
// Tesselator initialization // Tesselator initialization
tesselator = gluNewTess(); tesselator = gluNewTess();
InitTesselatorCallbacks( tesselator ); InitTesselatorCallbacks( tesselator );
if( tesselator == NULL ) if( tesselator == NULL )
{ {
wxLogFatalError( wxT( "Could not create the tesselator" ) ); wxLogFatalError( wxT( "Could not create the tesselator" ) );
} }
gluTessProperty( tesselator, GLU_TESS_WINDING_RULE, GLU_TESS_WINDING_POSITIVE ); gluTessProperty( tesselator, GLU_TESS_WINDING_RULE, GLU_TESS_WINDING_POSITIVE );
} }
...@@ -368,6 +370,7 @@ void OPENGL_GAL::DrawArc( const VECTOR2D& aCenterPoint, double aRadius, double a ...@@ -368,6 +370,7 @@ void OPENGL_GAL::DrawArc( const VECTOR2D& aCenterPoint, double aRadius, double a
VECTOR2D p( cos( aStartAngle ) * aRadius, sin( aStartAngle ) * aRadius ); VECTOR2D p( cos( aStartAngle ) * aRadius, sin( aStartAngle ) * aRadius );
double alpha; double alpha;
for( alpha = aStartAngle + alphaIncrement; alpha < aEndAngle; alpha += alphaIncrement ) for( alpha = aStartAngle + alphaIncrement; alpha < aEndAngle; alpha += alphaIncrement )
{ {
VECTOR2D p_next( cos( alpha ) * aRadius, sin( alpha ) * aRadius ); VECTOR2D p_next( cos( alpha ) * aRadius, sin( alpha ) * aRadius );
...@@ -734,6 +737,7 @@ void OPENGL_GAL::ClearTarget( RenderTarget aTarget ) ...@@ -734,6 +737,7 @@ void OPENGL_GAL::ClearTarget( RenderTarget aTarget )
compositor.SetBuffer( overlayBuffer ); compositor.SetBuffer( overlayBuffer );
break; break;
} }
compositor.ClearBuffer(); compositor.ClearBuffer();
// Restore the previous state // Restore the previous state
......
...@@ -34,7 +34,7 @@ ...@@ -34,7 +34,7 @@
#include <gal/opengl/shader.h> #include <gal/opengl/shader.h>
#include "shader_src.h" #include "shader_src.h"
using namespace KiGfx; using namespace KIGFX;
SHADER::SHADER() : SHADER::SHADER() :
isProgramCreated( false ), isProgramCreated( false ),
...@@ -101,17 +101,19 @@ bool SHADER::Link() ...@@ -101,17 +101,19 @@ bool SHADER::Link()
(GLint*) &isShaderLinked ); (GLint*) &isShaderLinked );
#ifdef __WXDEBUG__ #ifdef __WXDEBUG__
if( !isShaderLinked ) if( !isShaderLinked )
{ {
int maxLength; int maxLength;
glGetProgramiv( programNumber, GL_INFO_LOG_LENGTH, &maxLength ); glGetProgramiv( programNumber, GL_INFO_LOG_LENGTH, &maxLength );
maxLength = maxLength + 1; maxLength = maxLength + 1;
char *linkInfoLog = new char[maxLength]; char* linkInfoLog = new char[maxLength];
glGetProgramInfoLog( programNumber, maxLength, &maxLength, linkInfoLog ); glGetProgramInfoLog( programNumber, maxLength, &maxLength, linkInfoLog );
std::cerr << "Shader linking error:" << std::endl; std::cerr << "Shader linking error:" << std::endl;
std::cerr << linkInfoLog; std::cerr << linkInfoLog;
delete[] linkInfoLog; delete[] linkInfoLog;
} }
#endif /* __WXDEBUG__ */ #endif /* __WXDEBUG__ */
return isShaderLinked; return isShaderLinked;
......
...@@ -73,4 +73,3 @@ void main() ...@@ -73,4 +73,3 @@ void main()
gl_FragColor = gl_Color; gl_FragColor = gl_Color;
} }
} }
...@@ -96,4 +96,3 @@ void main() ...@@ -96,4 +96,3 @@ void main()
gl_FrontColor = gl_Color; gl_FrontColor = gl_Color;
} }
...@@ -33,7 +33,7 @@ ...@@ -33,7 +33,7 @@
#include <gal/opengl/shader.h> #include <gal/opengl/shader.h>
#include <wx/log.h> #include <wx/log.h>
using namespace KiGfx; using namespace KIGFX;
VERTEX_CONTAINER* VERTEX_CONTAINER::MakeContainer( bool aCached ) VERTEX_CONTAINER* VERTEX_CONTAINER::MakeContainer( bool aCached )
{ {
......
...@@ -31,7 +31,7 @@ ...@@ -31,7 +31,7 @@
#include <gal/opengl/vertex_manager.h> #include <gal/opengl/vertex_manager.h>
#include <cstring> #include <cstring>
using namespace KiGfx; using namespace KIGFX;
VERTEX_ITEM::VERTEX_ITEM( const VERTEX_MANAGER& aManager ) : VERTEX_ITEM::VERTEX_ITEM( const VERTEX_MANAGER& aManager ) :
m_manager( aManager ), m_offset( 0 ), m_size( 0 ) m_manager( aManager ), m_offset( 0 ), m_size( 0 )
......
...@@ -34,7 +34,7 @@ ...@@ -34,7 +34,7 @@
#include <gal/opengl/gpu_manager.h> #include <gal/opengl/gpu_manager.h>
#include <gal/opengl/vertex_item.h> #include <gal/opengl/vertex_item.h>
using namespace KiGfx; using namespace KIGFX;
VERTEX_MANAGER::VERTEX_MANAGER( bool aCached ) : VERTEX_MANAGER::VERTEX_MANAGER( bool aCached ) :
m_noTransform( true ), m_transform( 1.0f ) m_noTransform( true ), m_transform( 1.0f )
...@@ -106,6 +106,7 @@ void VERTEX_MANAGER::ChangeItemColor( const VERTEX_ITEM& aItem, const COLOR4D& a ...@@ -106,6 +106,7 @@ void VERTEX_MANAGER::ChangeItemColor( const VERTEX_ITEM& aItem, const COLOR4D& a
unsigned int offset = aItem.GetOffset(); unsigned int offset = aItem.GetOffset();
VERTEX* vertex = m_container->GetVertices( offset ); VERTEX* vertex = m_container->GetVertices( offset );
for( unsigned int i = 0; i < size; ++i ) for( unsigned int i = 0; i < size; ++i )
{ {
vertex->r = aColor.r * 255.0; vertex->r = aColor.r * 255.0;
...@@ -125,6 +126,7 @@ void VERTEX_MANAGER::ChangeItemDepth( const VERTEX_ITEM& aItem, GLfloat aDepth ) ...@@ -125,6 +126,7 @@ void VERTEX_MANAGER::ChangeItemDepth( const VERTEX_ITEM& aItem, GLfloat aDepth )
unsigned int offset = aItem.GetOffset(); unsigned int offset = aItem.GetOffset();
VERTEX* vertex = m_container->GetVertices( offset ); VERTEX* vertex = m_container->GetVertices( offset );
for( unsigned int i = 0; i < size; ++i ) for( unsigned int i = 0; i < size; ++i )
{ {
vertex->z = aDepth; vertex->z = aDepth;
......
...@@ -27,7 +27,7 @@ ...@@ -27,7 +27,7 @@
#include <gal/stroke_font.h> #include <gal/stroke_font.h>
#include <gal/graphics_abstraction_layer.h> #include <gal/graphics_abstraction_layer.h>
using namespace KiGfx; using namespace KIGFX;
const double STROKE_FONT::LINE_HEIGHT_RATIO = 1.6; const double STROKE_FONT::LINE_HEIGHT_RATIO = 1.6;
...@@ -177,11 +177,13 @@ void STROKE_FONT::Draw( std::string aText, const VECTOR2D& aPosition, double aRo ...@@ -177,11 +177,13 @@ void STROKE_FONT::Draw( std::string aText, const VECTOR2D& aPosition, double aRo
case GR_TEXT_HJUSTIFY_RIGHT: case GR_TEXT_HJUSTIFY_RIGHT:
if( !m_mirrored ) if( !m_mirrored )
m_gal->Translate( VECTOR2D( -textsize.x, 0 ) ); m_gal->Translate( VECTOR2D( -textsize.x, 0 ) );
break; break;
case GR_TEXT_HJUSTIFY_LEFT: case GR_TEXT_HJUSTIFY_LEFT:
if( m_mirrored ) if( m_mirrored )
m_gal->Translate( VECTOR2D( -textsize.x, 0 ) ); m_gal->Translate( VECTOR2D( -textsize.x, 0 ) );
break; break;
default: default:
......
...@@ -25,7 +25,9 @@ ...@@ -25,7 +25,9 @@
#include <geometry/seg.h> #include <geometry/seg.h>
template<typename T> int sgn( T val ) { template<typename T>
int sgn( T val )
{
return ( T( 0 ) < val ) - ( val < T( 0 ) ); return ( T( 0 ) < val ) - ( val < T( 0 ) );
} }
...@@ -64,8 +66,8 @@ bool SEG::PointCloserThan( const VECTOR2I& aP, int dist ) const ...@@ -64,8 +66,8 @@ bool SEG::PointCloserThan( const VECTOR2I& aP, int dist ) const
} }
VECTOR2I nearest; VECTOR2I nearest;
nearest.x = a.x + rescale( t, (ecoord)d.x, l_squared ); nearest.x = a.x + rescale( t, (ecoord) d.x, l_squared );
nearest.y = a.y + rescale( t, (ecoord)d.y, l_squared ); nearest.y = a.y + rescale( t, (ecoord) d.y, l_squared );
return ( nearest - aP ).SquaredEuclideanNorm() <= dist_sq; return ( nearest - aP ).SquaredEuclideanNorm() <= dist_sq;
} }
...@@ -86,6 +88,7 @@ SEG::ecoord SEG::SquaredDistance( const SEG& aSeg ) const ...@@ -86,6 +88,7 @@ SEG::ecoord SEG::SquaredDistance( const SEG& aSeg ) const
}; };
ecoord m = VECTOR2I::ECOORD_MAX; ecoord m = VECTOR2I::ECOORD_MAX;
for( int i = 0; i < 4; i++ ) for( int i = 0; i < 4; i++ )
m = std::min( m, pts[i].SquaredEuclideanNorm() ); m = std::min( m, pts[i].SquaredEuclideanNorm() );
...@@ -95,9 +98,9 @@ SEG::ecoord SEG::SquaredDistance( const SEG& aSeg ) const ...@@ -95,9 +98,9 @@ SEG::ecoord SEG::SquaredDistance( const SEG& aSeg ) const
OPT_VECTOR2I SEG::Intersect( const SEG& aSeg, bool aIgnoreEndpoints, bool aLines ) const OPT_VECTOR2I SEG::Intersect( const SEG& aSeg, bool aIgnoreEndpoints, bool aLines ) const
{ {
const VECTOR2I e ( b - a ); const VECTOR2I e( b - a );
const VECTOR2I f ( aSeg.b - aSeg.a ); const VECTOR2I f( aSeg.b - aSeg.a );
const VECTOR2I ac ( aSeg.a - a ); const VECTOR2I ac( aSeg.a - a );
ecoord d = f.Cross( e ); ecoord d = f.Cross( e );
ecoord p = f.Cross( ac ); ecoord p = f.Cross( ac );
...@@ -105,15 +108,18 @@ OPT_VECTOR2I SEG::Intersect( const SEG& aSeg, bool aIgnoreEndpoints, bool aLines ...@@ -105,15 +108,18 @@ OPT_VECTOR2I SEG::Intersect( const SEG& aSeg, bool aIgnoreEndpoints, bool aLines
if( d == 0 ) if( d == 0 )
return OPT_VECTOR2I(); return OPT_VECTOR2I();
if ( !aLines && d > 0 && ( q < 0 || q > d || p < 0 || p > d ) )
if( !aLines && d > 0 && ( q < 0 || q > d || p < 0 || p > d ) )
return OPT_VECTOR2I(); return OPT_VECTOR2I();
if ( !aLines && d < 0 && ( q < d || p < d || p > 0 || q > 0 ) )
if( !aLines && d < 0 && ( q < d || p < d || p > 0 || q > 0 ) )
return OPT_VECTOR2I(); return OPT_VECTOR2I();
if ( !aLines && aIgnoreEndpoints && ( q == 0 || q == d ) && ( p == 0 || p == d ) )
if( !aLines && aIgnoreEndpoints && ( q == 0 || q == d ) && ( p == 0 || p == d ) )
return OPT_VECTOR2I(); return OPT_VECTOR2I();
VECTOR2I ip( aSeg.a.x + rescale( q, (ecoord)f.x, d ), VECTOR2I ip( aSeg.a.x + rescale( q, (ecoord) f.x, d ),
aSeg.a.y + rescale( q, (ecoord)f.y, d ) ); aSeg.a.y + rescale( q, (ecoord) f.y, d ) );
return ip; return ip;
} }
...@@ -121,7 +127,7 @@ OPT_VECTOR2I SEG::Intersect( const SEG& aSeg, bool aIgnoreEndpoints, bool aLines ...@@ -121,7 +127,7 @@ OPT_VECTOR2I SEG::Intersect( const SEG& aSeg, bool aIgnoreEndpoints, bool aLines
bool SEG::ccw( const VECTOR2I& a, const VECTOR2I& b, const VECTOR2I& c ) const bool SEG::ccw( const VECTOR2I& a, const VECTOR2I& b, const VECTOR2I& c ) const
{ {
return (ecoord)( c.y - a.y ) * ( b.x - a.x ) > (ecoord)( b.y - a.y ) * ( c.x - a.x ); return (ecoord) ( c.y - a.y ) * ( b.x - a.x ) > (ecoord) ( b.y - a.y ) * ( c.x - a.x );
} }
...@@ -133,8 +139,8 @@ bool SEG::Collide( const SEG& aSeg, int aClearance ) const ...@@ -133,8 +139,8 @@ bool SEG::Collide( const SEG& aSeg, int aClearance ) const
ccw( a, b, aSeg.a ) != ccw( a, b, aSeg.b ) ) ccw( a, b, aSeg.a ) != ccw( a, b, aSeg.b ) )
return true; return true;
#define CHK(_seg, _pt) \ #define CHK( _seg, _pt ) \
if( (_seg).PointCloserThan (_pt, aClearance ) ) return true; if( (_seg).PointCloserThan( _pt, aClearance ) ) return true;
CHK( *this, aSeg.a ); CHK( *this, aSeg.a );
CHK( *this, aSeg.b ); CHK( *this, aSeg.b );
......
...@@ -41,11 +41,11 @@ static inline bool Collide( const SHAPE_CIRCLE& aA, const SHAPE_CIRCLE& aB, int ...@@ -41,11 +41,11 @@ static inline bool Collide( const SHAPE_CIRCLE& aA, const SHAPE_CIRCLE& aB, int
ecoord dist_sq = delta.SquaredEuclideanNorm(); ecoord dist_sq = delta.SquaredEuclideanNorm();
if ( dist_sq >= min_dist_sq ) if( dist_sq >= min_dist_sq )
return false; return false;
if ( aNeedMTV ) if( aNeedMTV )
aMTV = delta.Resize( sqrt ( abs( min_dist_sq - dist_sq ) ) + 1 ); aMTV = delta.Resize( sqrt( abs( min_dist_sq - dist_sq ) ) + 1 );
return true; return true;
} }
...@@ -60,15 +60,17 @@ static inline bool Collide( const SHAPE_RECT& aA, const SHAPE_CIRCLE& aB, int a ...@@ -60,15 +60,17 @@ static inline bool Collide( const SHAPE_RECT& aA, const SHAPE_CIRCLE& aB, int a
const ecoord min_dist = aClearance + r; const ecoord min_dist = aClearance + r;
const ecoord min_dist_sq = min_dist * min_dist; const ecoord min_dist_sq = min_dist * min_dist;
if ( aA.BBox( 0 ).Contains( c ) ) if( aA.BBox( 0 ).Contains( c ) )
return true; return true;
const VECTOR2I vts[] = { const VECTOR2I vts[] =
VECTOR2I(p0.x, p0.y), {
VECTOR2I(p0.x, p0.y + size.y), VECTOR2I( p0.x, p0.y ),
VECTOR2I(p0.x + size.x, p0.y + size.y), VECTOR2I( p0.x, p0.y + size.y ),
VECTOR2I(p0.x + size.x, p0.y), VECTOR2I( p0.x + size.x, p0.y + size.y ),
VECTOR2I(p0.x, p0.y) }; VECTOR2I( p0.x + size.x, p0.y ),
VECTOR2I( p0.x, p0.y )
};
ecoord nearest_seg_dist_sq = VECTOR2I::ECOORD_MAX; ecoord nearest_seg_dist_sq = VECTOR2I::ECOORD_MAX;
VECTOR2I nearest; VECTOR2I nearest;
...@@ -78,10 +80,9 @@ static inline bool Collide( const SHAPE_RECT& aA, const SHAPE_CIRCLE& aB, int a ...@@ -78,10 +80,9 @@ static inline bool Collide( const SHAPE_RECT& aA, const SHAPE_CIRCLE& aB, int a
if( !inside ) if( !inside )
{ {
for( int i = 0; i < 4; i++ ) for( int i = 0; i < 4; i++ )
{ {
const SEG seg( vts[i], vts[i+1] ); const SEG seg( vts[i], vts[i + 1] );
ecoord dist_sq = seg.SquaredDistance( c ); ecoord dist_sq = seg.SquaredDistance( c );
if( dist_sq < min_dist_sq ) if( dist_sq < min_dist_sq )
...@@ -119,7 +120,7 @@ static inline bool Collide( const SHAPE_CIRCLE& aA, const SHAPE_LINE_CHAIN& aB, ...@@ -119,7 +120,7 @@ static inline bool Collide( const SHAPE_CIRCLE& aA, const SHAPE_LINE_CHAIN& aB,
{ {
for( int s = 0; s < aB.SegmentCount(); s++ ) for( int s = 0; s < aB.SegmentCount(); s++ )
{ {
if ( aA.Collide( aB.CSegment( s ), aClearance ) ) if( aA.Collide( aB.CSegment( s ), aClearance ) )
return true; return true;
} }
...@@ -131,8 +132,9 @@ static inline bool Collide( const SHAPE_LINE_CHAIN& aA, const SHAPE_LINE_CHAIN& ...@@ -131,8 +132,9 @@ static inline bool Collide( const SHAPE_LINE_CHAIN& aA, const SHAPE_LINE_CHAIN&
bool aNeedMTV, VECTOR2I& aMTV ) bool aNeedMTV, VECTOR2I& aMTV )
{ {
for( int i = 0; i < aB.SegmentCount(); i++ ) for( int i = 0; i < aB.SegmentCount(); i++ )
if( aA.Collide( aB.CSegment(i), aClearance ) ) if( aA.Collide( aB.CSegment( i ), aClearance ) )
return true; return true;
return false; return false;
} }
...@@ -143,6 +145,7 @@ static inline bool Collide( const SHAPE_RECT& aA, const SHAPE_LINE_CHAIN& aB, in ...@@ -143,6 +145,7 @@ static inline bool Collide( const SHAPE_RECT& aA, const SHAPE_LINE_CHAIN& aB, in
for( int s = 0; s < aB.SegmentCount(); s++ ) for( int s = 0; s < aB.SegmentCount(); s++ )
{ {
SEG seg = aB.CSegment( s ); SEG seg = aB.CSegment( s );
if( aA.Collide( seg, aClearance ) ) if( aA.Collide( seg, aClearance ) )
return true; return true;
} }
...@@ -222,12 +225,13 @@ bool CollideShapes( const SHAPE* aA, const SHAPE* aB, int aClearance, bool aNeed ...@@ -222,12 +225,13 @@ bool CollideShapes( const SHAPE* aA, const SHAPE* aB, int aClearance, bool aNeed
bool SHAPE::Collide( const SHAPE* aShape, int aClerance, VECTOR2I& aMTV ) const bool SHAPE::Collide( const SHAPE* aShape, int aClerance, VECTOR2I& aMTV ) const
{ {
return CollideShapes( this, aShape, aClerance, true, aMTV); return CollideShapes( this, aShape, aClerance, true, aMTV );
} }
bool SHAPE::Collide ( const SHAPE* aShape, int aClerance ) const bool SHAPE::Collide( const SHAPE* aShape, int aClerance ) const
{ {
VECTOR2I dummy; VECTOR2I dummy;
return CollideShapes( this, aShape, aClerance, false, dummy ); return CollideShapes( this, aShape, aClerance, false, dummy );
} }
...@@ -47,12 +47,12 @@ bool SHAPE_LINE_CHAIN::Collide( const SEG& aSeg, int aClearance ) const ...@@ -47,12 +47,12 @@ bool SHAPE_LINE_CHAIN::Collide( const SEG& aSeg, int aClearance ) const
BOX2I box_a( aSeg.a, aSeg.b - aSeg.a ); BOX2I box_a( aSeg.a, aSeg.b - aSeg.a );
BOX2I::ecoord_type dist_sq = (BOX2I::ecoord_type) aClearance * aClearance; BOX2I::ecoord_type dist_sq = (BOX2I::ecoord_type) aClearance * aClearance;
for( int i = 0; i < SegmentCount() ;i++ ) for( int i = 0; i < SegmentCount(); i++ )
{ {
const SEG& s = CSegment( i ); const SEG& s = CSegment( i );
BOX2I box_b( s.a, s.b - s.a ); BOX2I box_b( s.a, s.b - s.a );
BOX2I::ecoord_type d = box_a.SquaredDistance ( box_b ); BOX2I::ecoord_type d = box_a.SquaredDistance( box_b );
if( d < dist_sq ) if( d < dist_sq )
{ {
...@@ -64,9 +64,11 @@ bool SHAPE_LINE_CHAIN::Collide( const SEG& aSeg, int aClearance ) const ...@@ -64,9 +64,11 @@ bool SHAPE_LINE_CHAIN::Collide( const SEG& aSeg, int aClearance ) const
return false; return false;
} }
const SHAPE_LINE_CHAIN SHAPE_LINE_CHAIN::Reverse() const const SHAPE_LINE_CHAIN SHAPE_LINE_CHAIN::Reverse() const
{ {
SHAPE_LINE_CHAIN a( *this ); SHAPE_LINE_CHAIN a( *this );
reverse( a.m_points.begin(), a.m_points.end() ); reverse( a.m_points.begin(), a.m_points.end() );
a.m_closed = m_closed; a.m_closed = m_closed;
...@@ -77,6 +79,7 @@ const SHAPE_LINE_CHAIN SHAPE_LINE_CHAIN::Reverse() const ...@@ -77,6 +79,7 @@ const SHAPE_LINE_CHAIN SHAPE_LINE_CHAIN::Reverse() const
int SHAPE_LINE_CHAIN::Length() const int SHAPE_LINE_CHAIN::Length() const
{ {
int l = 0; int l = 0;
for( int i = 0; i < SegmentCount(); i++ ) for( int i = 0; i < SegmentCount(); i++ )
l += CSegment( i ).Length(); l += CSegment( i ).Length();
...@@ -88,11 +91,12 @@ void SHAPE_LINE_CHAIN::Replace( int aStartIndex, int aEndIndex, const VECTOR2I& ...@@ -88,11 +91,12 @@ void SHAPE_LINE_CHAIN::Replace( int aStartIndex, int aEndIndex, const VECTOR2I&
{ {
if( aEndIndex < 0 ) if( aEndIndex < 0 )
aEndIndex += PointCount(); aEndIndex += PointCount();
if( aStartIndex < 0 ) if( aStartIndex < 0 )
aStartIndex += PointCount(); aStartIndex += PointCount();
if( aStartIndex == aEndIndex ) if( aStartIndex == aEndIndex )
m_points [aStartIndex] = aP; m_points[aStartIndex] = aP;
else else
{ {
m_points.erase( m_points.begin() + aStartIndex + 1, m_points.begin() + aEndIndex + 1 ); m_points.erase( m_points.begin() + aStartIndex + 1, m_points.begin() + aEndIndex + 1 );
...@@ -105,6 +109,7 @@ void SHAPE_LINE_CHAIN::Replace( int aStartIndex, int aEndIndex, const SHAPE_LINE ...@@ -105,6 +109,7 @@ void SHAPE_LINE_CHAIN::Replace( int aStartIndex, int aEndIndex, const SHAPE_LINE
{ {
if( aEndIndex < 0 ) if( aEndIndex < 0 )
aEndIndex += PointCount(); aEndIndex += PointCount();
if( aStartIndex < 0 ) if( aStartIndex < 0 )
aStartIndex += PointCount(); aStartIndex += PointCount();
...@@ -115,9 +120,10 @@ void SHAPE_LINE_CHAIN::Replace( int aStartIndex, int aEndIndex, const SHAPE_LINE ...@@ -115,9 +120,10 @@ void SHAPE_LINE_CHAIN::Replace( int aStartIndex, int aEndIndex, const SHAPE_LINE
void SHAPE_LINE_CHAIN::Remove( int aStartIndex, int aEndIndex ) void SHAPE_LINE_CHAIN::Remove( int aStartIndex, int aEndIndex )
{ {
if(aEndIndex < 0) if( aEndIndex < 0 )
aEndIndex += PointCount(); aEndIndex += PointCount();
if(aStartIndex < 0)
if( aStartIndex < 0 )
aStartIndex += PointCount(); aStartIndex += PointCount();
m_points.erase( m_points.begin() + aStartIndex, m_points.begin() + aEndIndex + 1 ); m_points.erase( m_points.begin() + aStartIndex, m_points.begin() + aEndIndex + 1 );
...@@ -127,6 +133,7 @@ void SHAPE_LINE_CHAIN::Remove( int aStartIndex, int aEndIndex ) ...@@ -127,6 +133,7 @@ void SHAPE_LINE_CHAIN::Remove( int aStartIndex, int aEndIndex )
int SHAPE_LINE_CHAIN::Distance( const VECTOR2I& aP ) const int SHAPE_LINE_CHAIN::Distance( const VECTOR2I& aP ) const
{ {
int d = INT_MAX; int d = INT_MAX;
for( int s = 0; s < SegmentCount(); s++ ) for( int s = 0; s < SegmentCount(); s++ )
d = min( d, CSegment( s ).Distance( aP ) ); d = min( d, CSegment( s ).Distance( aP ) );
...@@ -185,6 +192,7 @@ const SHAPE_LINE_CHAIN SHAPE_LINE_CHAIN::Slice( int aStartIndex, int aEndIndex ) ...@@ -185,6 +192,7 @@ const SHAPE_LINE_CHAIN SHAPE_LINE_CHAIN::Slice( int aStartIndex, int aEndIndex )
if( aEndIndex < 0 ) if( aEndIndex < 0 )
aEndIndex += PointCount(); aEndIndex += PointCount();
if( aStartIndex < 0 ) if( aStartIndex < 0 )
aStartIndex += PointCount(); aStartIndex += PointCount();
...@@ -197,7 +205,7 @@ const SHAPE_LINE_CHAIN SHAPE_LINE_CHAIN::Slice( int aStartIndex, int aEndIndex ) ...@@ -197,7 +205,7 @@ const SHAPE_LINE_CHAIN SHAPE_LINE_CHAIN::Slice( int aStartIndex, int aEndIndex )
struct compareOriginDistance struct compareOriginDistance
{ {
compareOriginDistance( VECTOR2I& aOrigin ): compareOriginDistance( VECTOR2I& aOrigin ) :
m_origin( aOrigin ) {}; m_origin( aOrigin ) {};
bool operator()( const SHAPE_LINE_CHAIN::Intersection& aA, bool operator()( const SHAPE_LINE_CHAIN::Intersection& aA,
...@@ -215,6 +223,7 @@ int SHAPE_LINE_CHAIN::Intersect( const SEG& aSeg, Intersections& aIp ) const ...@@ -215,6 +223,7 @@ int SHAPE_LINE_CHAIN::Intersect( const SEG& aSeg, Intersections& aIp ) const
for( int s = 0; s < SegmentCount(); s++ ) for( int s = 0; s < SegmentCount(); s++ )
{ {
OPT_VECTOR2I p = CSegment( s ).Intersect( aSeg ); OPT_VECTOR2I p = CSegment( s ).Intersect( aSeg );
if( p ) if( p )
{ {
Intersection is; Intersection is;
...@@ -236,7 +245,7 @@ int SHAPE_LINE_CHAIN::Intersect( const SHAPE_LINE_CHAIN& aChain, Intersections& ...@@ -236,7 +245,7 @@ int SHAPE_LINE_CHAIN::Intersect( const SHAPE_LINE_CHAIN& aChain, Intersections&
{ {
BOX2I bb_other = aChain.BBox(); BOX2I bb_other = aChain.BBox();
for ( int s1 = 0; s1 < SegmentCount(); s1++ ) for( int s1 = 0; s1 < SegmentCount(); s1++ )
{ {
const SEG& a = CSegment( s1 ); const SEG& a = CSegment( s1 );
const BOX2I bb_cur( a.a, a.b - a.a ); const BOX2I bb_cur( a.a, a.b - a.a );
...@@ -305,7 +314,6 @@ int SHAPE_LINE_CHAIN::Intersect( const SHAPE_LINE_CHAIN& aChain, Intersections& ...@@ -305,7 +314,6 @@ int SHAPE_LINE_CHAIN::Intersect( const SHAPE_LINE_CHAIN& aChain, Intersections&
is.their = b; is.their = b;
aIp.push_back( is ); aIp.push_back( is );
} }
} }
} }
} }
...@@ -317,6 +325,7 @@ int SHAPE_LINE_CHAIN::Intersect( const SHAPE_LINE_CHAIN& aChain, Intersections& ...@@ -317,6 +325,7 @@ int SHAPE_LINE_CHAIN::Intersect( const SHAPE_LINE_CHAIN& aChain, Intersections&
int SHAPE_LINE_CHAIN::PathLength( const VECTOR2I& aP ) const int SHAPE_LINE_CHAIN::PathLength( const VECTOR2I& aP ) const
{ {
int sum = 0; int sum = 0;
for( int i = 0; i < SegmentCount(); i++ ) for( int i = 0; i < SegmentCount(); i++ )
{ {
const SEG seg = CSegment( i ); const SEG seg = CSegment( i );
...@@ -340,7 +349,7 @@ bool SHAPE_LINE_CHAIN::PointInside( const VECTOR2I& aP ) const ...@@ -340,7 +349,7 @@ bool SHAPE_LINE_CHAIN::PointInside( const VECTOR2I& aP ) const
if( !m_closed || SegmentCount() < 3 ) if( !m_closed || SegmentCount() < 3 )
return false; return false;
int cur = CSegment(0).Side( aP ); int cur = CSegment( 0 ).Side( aP );
if( cur == 0 ) if( cur == 0 )
return false; return false;
...@@ -352,7 +361,7 @@ bool SHAPE_LINE_CHAIN::PointInside( const VECTOR2I& aP ) const ...@@ -352,7 +361,7 @@ bool SHAPE_LINE_CHAIN::PointInside( const VECTOR2I& aP ) const
if( aP == s.a || aP == s.b ) // edge does not belong to the interior! if( aP == s.a || aP == s.b ) // edge does not belong to the interior!
return false; return false;
if( s.Side(aP) != cur ) if( s.Side( aP ) != cur )
return false; return false;
} }
...@@ -372,7 +381,7 @@ bool SHAPE_LINE_CHAIN::PointOnEdge( const VECTOR2I& aP ) const ...@@ -372,7 +381,7 @@ bool SHAPE_LINE_CHAIN::PointOnEdge( const VECTOR2I& aP ) const
if( s.a == aP || s.b == aP ) if( s.a == aP || s.b == aP )
return true; return true;
if( s.Distance(aP) <= 1 ) if( s.Distance( aP ) <= 1 )
return true; return true;
} }
...@@ -387,6 +396,7 @@ const optional<SHAPE_LINE_CHAIN::Intersection> SHAPE_LINE_CHAIN::SelfIntersectin ...@@ -387,6 +396,7 @@ const optional<SHAPE_LINE_CHAIN::Intersection> SHAPE_LINE_CHAIN::SelfIntersectin
for( int s2 = s1 + 1; s2 < SegmentCount(); s2++ ) for( int s2 = s1 + 1; s2 < SegmentCount(); s2++ )
{ {
const VECTOR2I s2a = CSegment( s2 ).a, s2b = CSegment( s2 ).b; const VECTOR2I s2a = CSegment( s2 ).a, s2b = CSegment( s2 ).b;
if( s1 + 1 != s2 && CSegment( s1 ).Contains( s2a ) ) if( s1 + 1 != s2 && CSegment( s1 ).Contains( s2a ) )
{ {
Intersection is; Intersection is;
...@@ -395,7 +405,7 @@ const optional<SHAPE_LINE_CHAIN::Intersection> SHAPE_LINE_CHAIN::SelfIntersectin ...@@ -395,7 +405,7 @@ const optional<SHAPE_LINE_CHAIN::Intersection> SHAPE_LINE_CHAIN::SelfIntersectin
is.p = s2a; is.p = s2a;
return is; return is;
} }
else if( CSegment( s1 ).Contains(s2b ) ) else if( CSegment( s1 ).Contains( s2b ) )
{ {
Intersection is; Intersection is;
is.our = CSegment( s1 ); is.our = CSegment( s1 );
...@@ -443,10 +453,11 @@ SHAPE_LINE_CHAIN& SHAPE_LINE_CHAIN::Simplify() ...@@ -443,10 +453,11 @@ SHAPE_LINE_CHAIN& SHAPE_LINE_CHAIN::Simplify()
int np = PointCount(); int np = PointCount();
// stage 1: eliminate duplicate vertices // stage 1: eliminate duplicate vertices
while ( i < np ) while( i < np )
{ {
int j = i + 1; int j = i + 1;
while( j < np && CPoint(i) == CPoint( j ) )
while( j < np && CPoint( i ) == CPoint( j ) )
j++; j++;
pts_unique.push_back( CPoint( i ) ); pts_unique.push_back( CPoint( i ) );
...@@ -457,17 +468,19 @@ SHAPE_LINE_CHAIN& SHAPE_LINE_CHAIN::Simplify() ...@@ -457,17 +468,19 @@ SHAPE_LINE_CHAIN& SHAPE_LINE_CHAIN::Simplify()
np = pts_unique.size(); np = pts_unique.size();
i = 0; i = 0;
// stage 1: eliminate collinear segments // stage 1: eliminate collinear segments
while( i < np - 2 ) while( i < np - 2 )
{ {
const VECTOR2I p0 = pts_unique[i]; const VECTOR2I p0 = pts_unique[i];
const VECTOR2I p1 = pts_unique[i+1]; const VECTOR2I p1 = pts_unique[i + 1];
int n = i; int n = i;
while( n < np - 2 && SEG( p0, p1 ).LineDistance( pts_unique[n + 2] ) <= 1 ) while( n < np - 2 && SEG( p0, p1 ).LineDistance( pts_unique[n + 2] ) <= 1 )
n++; n++;
m_points.push_back( p0 ); m_points.push_back( p0 );
if( n > i ) if( n > i )
i = n; i = n;
...@@ -493,9 +506,11 @@ const VECTOR2I SHAPE_LINE_CHAIN::NearestPoint( const VECTOR2I& aP ) const ...@@ -493,9 +506,11 @@ const VECTOR2I SHAPE_LINE_CHAIN::NearestPoint( const VECTOR2I& aP ) const
{ {
int min_d = INT_MAX; int min_d = INT_MAX;
int nearest = 0; int nearest = 0;
for ( int i = 0; i < SegmentCount(); i++ )
for( int i = 0; i < SegmentCount(); i++ )
{ {
int d = CSegment( i ).Distance( aP ); int d = CSegment( i ).Distance( aP );
if( d < min_d ) if( d < min_d )
{ {
min_d = d; min_d = d;
...@@ -511,10 +526,10 @@ const string SHAPE_LINE_CHAIN::Format() const ...@@ -511,10 +526,10 @@ const string SHAPE_LINE_CHAIN::Format() const
{ {
stringstream ss; stringstream ss;
ss << m_points.size() << " " << ( m_closed ? 1 : 0 ) << " " ; ss << m_points.size() << " " << ( m_closed ? 1 : 0 ) << " ";
for( int i = 0; i < PointCount(); i++ ) for( int i = 0; i < PointCount(); i++ )
ss << m_points[i].x << " " << m_points[i].y << " ";// Format() << " "; ss << m_points[i].x << " " << m_points[i].y << " "; // Format() << " ";
return ss.str(); return ss.str();
} }
...@@ -28,16 +28,18 @@ ...@@ -28,16 +28,18 @@
#include <climits> #include <climits>
#include <math/math_util.h> #include <math/math_util.h>
template<> int rescale( int numerator, int value, int denominator ) template<>
int rescale( int numerator, int value, int denominator )
{ {
return (int) ( (int64_t) numerator * (int64_t) value / (int64_t) denominator ); return (int) ( (int64_t) numerator * (int64_t) value / (int64_t) denominator );
} }
template<> int64_t rescale( int64_t numerator, int64_t value, int64_t denominator ) template<>
int64_t rescale( int64_t numerator, int64_t value, int64_t denominator )
{ {
int64_t r = 0; int64_t r = 0;
int64_t sign = ( ( numerator < 0) ? -1 : 1 ) * ( denominator < 0 ? - 1: 1 ) * (value < 0 ? - 1 : 1); int64_t sign = ( ( numerator < 0) ? -1 : 1 ) * ( denominator < 0 ? -1 : 1 ) * ( value < 0 ? -1 : 1 );
int64_t a = std::abs( numerator ); int64_t a = std::abs( numerator );
int64_t b = std::abs( value ); int64_t b = std::abs( value );
...@@ -51,7 +53,9 @@ template<> int64_t rescale( int64_t numerator, int64_t value, int64_t denominato ...@@ -51,7 +53,9 @@ template<> int64_t rescale( int64_t numerator, int64_t value, int64_t denominato
return sign * ( (a * b + r ) / c ); return sign * ( (a * b + r ) / c );
else else
return sign * (a / c * b + (a % c * b + r) / c); return sign * (a / c * b + (a % c * b + r) / c);
} else { }
else
{
uint64_t a0 = a & 0xFFFFFFFF; uint64_t a0 = a & 0xFFFFFFFF;
uint64_t a1 = a >> 32; uint64_t a1 = a >> 32;
uint64_t b0 = b & 0xFFFFFFFF; uint64_t b0 = b & 0xFFFFFFFF;
...@@ -61,16 +65,16 @@ template<> int64_t rescale( int64_t numerator, int64_t value, int64_t denominato ...@@ -61,16 +65,16 @@ template<> int64_t rescale( int64_t numerator, int64_t value, int64_t denominato
int i; int i;
a0 = a0 * b0 + t1a; a0 = a0 * b0 + t1a;
a1 = a1 * b1 + (t1 >> 32) + (a0 < t1a); a1 = a1 * b1 + ( t1 >> 32 ) + ( a0 < t1a );
a0 += r; a0 += r;
a1 += ((uint64_t)a0) < r; a1 += ( (uint64_t) a0 ) < r;
for( i = 63; i >= 0; i-- ) for( i = 63; i >= 0; i-- )
{ {
a1 += a1 + ( (a0 >> i) & 1 ); a1 += a1 + ( ( a0 >> i ) & 1 );
t1 += t1; t1 += t1;
if( (uint64_t)c <= a1 ) if( (uint64_t) c <= a1 )
{ {
a1 -= c; a1 -= c;
t1++; t1++;
......
...@@ -27,7 +27,7 @@ ...@@ -27,7 +27,7 @@
#include <painter.h> #include <painter.h>
#include <gal/graphics_abstraction_layer.h> #include <gal/graphics_abstraction_layer.h>
using namespace KiGfx; using namespace KIGFX;
RENDER_SETTINGS::RENDER_SETTINGS() RENDER_SETTINGS::RENDER_SETTINGS()
{ {
......
...@@ -67,6 +67,7 @@ void ACTION_MANAGER::UnregisterAction( TOOL_ACTION* aAction ) ...@@ -67,6 +67,7 @@ void ACTION_MANAGER::UnregisterAction( TOOL_ACTION* aAction )
int ACTION_MANAGER::MakeActionId( const std::string& aActionName ) int ACTION_MANAGER::MakeActionId( const std::string& aActionName )
{ {
static int currentActionId = 1; static int currentActionId = 1;
return currentActionId++; return currentActionId++;
} }
......
...@@ -88,6 +88,7 @@ void CONTEXT_MENU::SetTitle( const wxString& aTitle ) ...@@ -88,6 +88,7 @@ void CONTEXT_MENU::SetTitle( const wxString& aTitle )
void CONTEXT_MENU::Add( const wxString& aLabel, int aId ) void CONTEXT_MENU::Add( const wxString& aLabel, int aId )
{ {
#ifdef DEBUG #ifdef DEBUG
if( m_menu.FindItem( aId ) != NULL ) if( m_menu.FindItem( aId ) != NULL )
wxLogWarning( wxT( "Adding more than one menu entry with the same ID may result in" wxLogWarning( wxT( "Adding more than one menu entry with the same ID may result in"
"undefined behaviour" ) ); "undefined behaviour" ) );
...@@ -135,13 +136,15 @@ std::string CONTEXT_MENU::getHotKeyDescription( const TOOL_ACTION& aAction ) con ...@@ -135,13 +136,15 @@ std::string CONTEXT_MENU::getHotKeyDescription( const TOOL_ACTION& aAction ) con
if( hotkey & MD_ModAlt ) if( hotkey & MD_ModAlt )
description += "ALT+"; description += "ALT+";
if( hotkey & MD_ModCtrl ) if( hotkey & MD_ModCtrl )
description += "CTRL+"; description += "CTRL+";
if( hotkey & MD_ModShift ) if( hotkey & MD_ModShift )
description += "SHIFT+"; description += "SHIFT+";
// TODO dispatch keys such as Fx, TAB, PG_UP/DN, HOME, END, etc. // TODO dispatch keys such as Fx, TAB, PG_UP/DN, HOME, END, etc.
description += char( hotkey & ~MD_ModifierMask ); description += char(hotkey & ~MD_ModifierMask);
return description; return description;
} }
......
...@@ -25,13 +25,13 @@ ...@@ -25,13 +25,13 @@
#include <tool/tool_event.h> #include <tool/tool_event.h>
#include <tool/tool_manager.h> #include <tool/tool_manager.h>
KiGfx::VIEW* TOOL_BASE::getView() const KIGFX::VIEW* TOOL_BASE::getView() const
{ {
return m_toolMgr->GetView(); return m_toolMgr->GetView();
} }
KiGfx::VIEW_CONTROLS* TOOL_BASE::getViewControls() const KIGFX::VIEW_CONTROLS* TOOL_BASE::getViewControls() const
{ {
return m_toolMgr->GetViewControls(); return m_toolMgr->GetViewControls();
} }
......
...@@ -111,7 +111,7 @@ void TOOL_DISPATCHER::ResetState() ...@@ -111,7 +111,7 @@ void TOOL_DISPATCHER::ResetState()
} }
KiGfx::VIEW* TOOL_DISPATCHER::getView() KIGFX::VIEW* TOOL_DISPATCHER::getView()
{ {
return m_editFrame->GetGalCanvas()->GetView(); return m_editFrame->GetGalCanvas()->GetView();
} }
...@@ -166,7 +166,8 @@ bool TOOL_DISPATCHER::handleMouseButton( wxEvent& aEvent, int aIndex, bool aMoti ...@@ -166,7 +166,8 @@ bool TOOL_DISPATCHER::handleMouseButton( wxEvent& aEvent, int aIndex, bool aMoti
if( st->pressed && aMotion ) if( st->pressed && aMotion )
{ {
st->dragging = true; st->dragging = true;
double dragPixelDistance = getView()->ToScreen( m_lastMousePos - st->dragOrigin, false ).EuclideanNorm(); double dragPixelDistance =
getView()->ToScreen( m_lastMousePos - st->dragOrigin, false ).EuclideanNorm();
st->dragMaxDelta = std::max( st->dragMaxDelta, dragPixelDistance ); st->dragMaxDelta = std::max( st->dragMaxDelta, dragPixelDistance );
wxLongLong t = wxGetLocalTimeMillis(); wxLongLong t = wxGetLocalTimeMillis();
...@@ -205,12 +206,12 @@ void TOOL_DISPATCHER::DispatchWxEvent( wxEvent& aEvent ) ...@@ -205,12 +206,12 @@ void TOOL_DISPATCHER::DispatchWxEvent( wxEvent& aEvent )
type == wxEVT_RIGHT_DOWN || type == wxEVT_RIGHT_UP || type == wxEVT_RIGHT_DOWN || type == wxEVT_RIGHT_UP ||
// Event issued whem mouse retains position in screen coordinates, // Event issued whem mouse retains position in screen coordinates,
// but changes in world coordinates (eg. autopanning) // but changes in world coordinates (eg. autopanning)
type == KiGfx::WX_VIEW_CONTROLS::EVT_REFRESH_MOUSE ) type == KIGFX::WX_VIEW_CONTROLS::EVT_REFRESH_MOUSE )
{ {
VECTOR2D screenPos = m_toolMgr->GetViewControls()->GetCursorPosition(); VECTOR2D screenPos = m_toolMgr->GetViewControls()->GetCursorPosition();
VECTOR2D pos = getView()->ToWorld( screenPos ); VECTOR2D pos = getView()->ToWorld( screenPos );
if( pos != m_lastMousePos || type == KiGfx::WX_VIEW_CONTROLS::EVT_REFRESH_MOUSE ) if( pos != m_lastMousePos || type == KIGFX::WX_VIEW_CONTROLS::EVT_REFRESH_MOUSE )
{ {
motion = true; motion = true;
m_lastMousePos = pos; m_lastMousePos = pos;
...@@ -266,6 +267,7 @@ void TOOL_DISPATCHER::DispatchWxCommand( const wxCommandEvent& aEvent ) ...@@ -266,6 +267,7 @@ void TOOL_DISPATCHER::DispatchWxCommand( const wxCommandEvent& aEvent )
toolName = "pcbnew.InteractiveRouter"; toolName = "pcbnew.InteractiveRouter";
activateTool = true; activateTool = true;
break; break;
case ID_SELECTION_TOOL: case ID_SELECTION_TOOL:
toolName = "pcbnew.InteractiveSelection"; toolName = "pcbnew.InteractiveSelection";
activateTool = true; activateTool = true;
......
...@@ -64,7 +64,8 @@ const std::string TOOL_EVENT::Format() const ...@@ -64,7 +64,8 @@ const std::string TOOL_EVENT::Format() const
{ {
std::string ev; std::string ev;
const FlagString categories[] = { const FlagString categories[] =
{
{ TC_Mouse, "mouse" }, { TC_Mouse, "mouse" },
{ TC_Keyboard, "keyboard" }, { TC_Keyboard, "keyboard" },
{ TC_Command, "command" }, { TC_Command, "command" },
...@@ -73,7 +74,8 @@ const std::string TOOL_EVENT::Format() const ...@@ -73,7 +74,8 @@ const std::string TOOL_EVENT::Format() const
{ 0, "" } { 0, "" }
}; };
const FlagString actions[] = { const FlagString actions[] =
{
{ TA_MouseClick, "click" }, { TA_MouseClick, "click" },
{ TA_MouseUp, "button-up" }, { TA_MouseUp, "button-up" },
{ TA_MouseDown, "button-down" }, { TA_MouseDown, "button-down" },
...@@ -94,7 +96,8 @@ const std::string TOOL_EVENT::Format() const ...@@ -94,7 +96,8 @@ const std::string TOOL_EVENT::Format() const
{ 0, "" } { 0, "" }
}; };
const FlagString buttons[] = { const FlagString buttons[] =
{
{ MB_None, "none" }, { MB_None, "none" },
{ MB_Left, "left" }, { MB_Left, "left" },
{ MB_Right, "right" }, { MB_Right, "right" },
...@@ -102,7 +105,8 @@ const std::string TOOL_EVENT::Format() const ...@@ -102,7 +105,8 @@ const std::string TOOL_EVENT::Format() const
{ 0, "" } { 0, "" }
}; };
const FlagString modifiers[] = { const FlagString modifiers[] =
{
{ MD_ModShift, "shift" }, { MD_ModShift, "shift" },
{ MD_ModCtrl, "ctrl" }, { MD_ModCtrl, "ctrl" },
{ MD_ModAlt, "alt" }, { MD_ModAlt, "alt" },
......
...@@ -31,12 +31,14 @@ ...@@ -31,12 +31,14 @@
TOOL_INTERACTIVE::TOOL_INTERACTIVE( TOOL_ID aId, const std::string& aName ) : TOOL_INTERACTIVE::TOOL_INTERACTIVE( TOOL_ID aId, const std::string& aName ) :
TOOL_BASE( TOOL_Interactive, aId, aName ) TOOL_BASE( TOOL_Interactive, aId, aName )
{}; {
}
TOOL_INTERACTIVE::TOOL_INTERACTIVE( const std::string& aName ) : TOOL_INTERACTIVE::TOOL_INTERACTIVE( const std::string& aName ) :
TOOL_BASE( TOOL_Interactive, TOOL_MANAGER::MakeToolId( aName ), aName ) TOOL_BASE( TOOL_Interactive, TOOL_MANAGER::MakeToolId( aName ), aName )
{}; {
}
TOOL_INTERACTIVE::~TOOL_INTERACTIVE() TOOL_INTERACTIVE::~TOOL_INTERACTIVE()
......
...@@ -85,12 +85,12 @@ struct TOOL_MANAGER::TOOL_STATE ...@@ -85,12 +85,12 @@ struct TOOL_MANAGER::TOOL_STATE
bool operator==( const TOOL_MANAGER::TOOL_STATE& aRhs ) const bool operator==( const TOOL_MANAGER::TOOL_STATE& aRhs ) const
{ {
return ( aRhs.theTool == this->theTool ); return aRhs.theTool == this->theTool;
} }
bool operator!=( const TOOL_MANAGER::TOOL_STATE& aRhs ) const bool operator!=( const TOOL_MANAGER::TOOL_STATE& aRhs ) const
{ {
return ( aRhs.theTool != this->theTool ); return aRhs.theTool != this->theTool;
} }
}; };
...@@ -137,6 +137,7 @@ void TOOL_MANAGER::RegisterTool( TOOL_BASE* aTool ) ...@@ -137,6 +137,7 @@ void TOOL_MANAGER::RegisterTool( TOOL_BASE* aTool )
if( aTool->GetType() == TOOL_Interactive ) if( aTool->GetType() == TOOL_Interactive )
{ {
bool initState = static_cast<TOOL_INTERACTIVE*>( aTool )->Init(); bool initState = static_cast<TOOL_INTERACTIVE*>( aTool )->Init();
if( !initState ) if( !initState )
{ {
wxLogError( wxT( "Initialization of the %s tool failed" ), aTool->GetName().c_str() ); wxLogError( wxT( "Initialization of the %s tool failed" ), aTool->GetName().c_str() );
...@@ -232,6 +233,7 @@ bool TOOL_MANAGER::runTool( TOOL_BASE* aTool ) ...@@ -232,6 +233,7 @@ bool TOOL_MANAGER::runTool( TOOL_BASE* aTool )
// If the tool is already active, do not invoke it again // If the tool is already active, do not invoke it again
if( state->idle == false ) if( state->idle == false )
return false; return false;
state->idle = false; state->idle = false;
static_cast<TOOL_INTERACTIVE*>( aTool )->Reset(); static_cast<TOOL_INTERACTIVE*>( aTool )->Reset();
...@@ -269,6 +271,7 @@ void TOOL_MANAGER::ScheduleNextState( TOOL_BASE* aTool, TOOL_STATE_FUNC& aHandle ...@@ -269,6 +271,7 @@ void TOOL_MANAGER::ScheduleNextState( TOOL_BASE* aTool, TOOL_STATE_FUNC& aHandle
const TOOL_EVENT_LIST& aConditions ) const TOOL_EVENT_LIST& aConditions )
{ {
TOOL_STATE* st = m_toolState[aTool]; TOOL_STATE* st = m_toolState[aTool];
st->transitions.push_back( TRANSITION( aConditions, aHandler ) ); st->transitions.push_back( TRANSITION( aConditions, aHandler ) );
} }
...@@ -309,6 +312,7 @@ void TOOL_MANAGER::dispatchInternal( TOOL_EVENT& aEvent ) ...@@ -309,6 +312,7 @@ void TOOL_MANAGER::dispatchInternal( TOOL_EVENT& aEvent )
st->wakeupEvent = aEvent; st->wakeupEvent = aEvent;
st->pendingWait = false; st->pendingWait = false;
st->waitEvents.clear(); st->waitEvents.clear();
if( st->cofunc && !st->cofunc->Resume() ) if( st->cofunc && !st->cofunc->Resume() )
finishTool( st ); // The couroutine has finished finishTool( st ); // The couroutine has finished
...@@ -392,6 +396,7 @@ void TOOL_MANAGER::finishTool( TOOL_STATE* aState ) ...@@ -392,6 +396,7 @@ void TOOL_MANAGER::finishTool( TOOL_STATE* aState )
{ {
// Find the tool to be deactivated // Find the tool to be deactivated
std::deque<TOOL_ID>::iterator it, it_end; std::deque<TOOL_ID>::iterator it, it_end;
for( it = m_activeTools.begin(), it_end = m_activeTools.end(); it != it_end; ++it ) for( it = m_activeTools.begin(), it_end = m_activeTools.end(); it != it_end; ++it )
{ {
if( aState == m_toolIdIndex[*it] ) if( aState == m_toolIdIndex[*it] )
...@@ -475,12 +480,13 @@ void TOOL_MANAGER::ScheduleContextMenu( TOOL_BASE* aTool, CONTEXT_MENU* aMenu, ...@@ -475,12 +480,13 @@ void TOOL_MANAGER::ScheduleContextMenu( TOOL_BASE* aTool, CONTEXT_MENU* aMenu,
TOOL_ID TOOL_MANAGER::MakeToolId( const std::string& aToolName ) TOOL_ID TOOL_MANAGER::MakeToolId( const std::string& aToolName )
{ {
static int currentId; static int currentId;
return currentId++; return currentId++;
} }
void TOOL_MANAGER::SetEnvironment( EDA_ITEM* aModel, KiGfx::VIEW* aView, void TOOL_MANAGER::SetEnvironment( EDA_ITEM* aModel, KIGFX::VIEW* aView,
KiGfx::VIEW_CONTROLS* aViewControls, wxWindow* aFrame ) KIGFX::VIEW_CONTROLS* aViewControls, wxWindow* aFrame )
{ {
m_model = aModel; m_model = aModel;
m_view = aView; m_view = aView;
......
...@@ -38,7 +38,7 @@ ...@@ -38,7 +38,7 @@
#include <profile.h> #include <profile.h>
#endif /* __WXDEBUG__ */ #endif /* __WXDEBUG__ */
using namespace KiGfx; using namespace KIGFX;
VIEW::VIEW( bool aIsDynamic ) : VIEW::VIEW( bool aIsDynamic ) :
m_enableOrderModifier( true ), m_enableOrderModifier( true ),
...@@ -348,7 +348,7 @@ void VIEW::SetLayerOrder( int aLayer, int aRenderingOrder ) ...@@ -348,7 +348,7 @@ void VIEW::SetLayerOrder( int aLayer, int aRenderingOrder )
int VIEW::GetLayerOrder( int aLayer ) const int VIEW::GetLayerOrder( int aLayer ) const
{ {
return m_layers.at(aLayer).renderingOrder; return m_layers.at( aLayer ).renderingOrder;
} }
...@@ -383,7 +383,7 @@ void VIEW::SortLayers( int aLayers[], int& aCount ) const ...@@ -383,7 +383,7 @@ void VIEW::SortLayers( int aLayers[], int& aCount ) const
struct VIEW::updateItemsColor struct VIEW::updateItemsColor
{ {
updateItemsColor( int aLayer, PAINTER* aPainter, GAL* aGal ) : updateItemsColor( int aLayer, PAINTER* aPainter, GAL* aGal ) :
layer( aLayer ), painter( aPainter), gal( aGal ) layer( aLayer ), painter( aPainter ), gal( aGal )
{ {
} }
...@@ -474,7 +474,8 @@ void VIEW::ChangeLayerDepth( int aLayer, int aDepth ) ...@@ -474,7 +474,8 @@ void VIEW::ChangeLayerDepth( int aLayer, int aDepth )
m_layers[aLayer].items->Query( r, visitor ); m_layers[aLayer].items->Query( r, visitor );
} }
int VIEW::GetTopLayer( ) const
int VIEW::GetTopLayer() const
{ {
if( m_topLayers.size() == 0 ) if( m_topLayers.size() == 0 )
return 0; return 0;
...@@ -512,10 +513,13 @@ void VIEW::SetTopLayer( int aLayer, bool aEnabled ) ...@@ -512,10 +513,13 @@ void VIEW::SetTopLayer( int aLayer, bool aEnabled )
void VIEW::EnableTopLayer( bool aEnable ) void VIEW::EnableTopLayer( bool aEnable )
{ {
if( aEnable == m_enableOrderModifier ) return; if( aEnable == m_enableOrderModifier )
return;
m_enableOrderModifier = aEnable; m_enableOrderModifier = aEnable;
std::set<unsigned int>::iterator it; std::set<unsigned int>::iterator it;
if( aEnable ) if( aEnable )
{ {
for( it = m_topLayers.begin(); it != m_topLayers.end(); ++it ) for( it = m_topLayers.begin(); it != m_topLayers.end(); ++it )
...@@ -615,8 +619,10 @@ void VIEW::draw( VIEW_ITEM* aItem, int aLayer, bool aImmediate ) const ...@@ -615,8 +619,10 @@ void VIEW::draw( VIEW_ITEM* aItem, int aLayer, bool aImmediate ) const
{ {
group = m_gal->BeginGroup(); group = m_gal->BeginGroup();
aItem->setGroup( aLayer, group ); aItem->setGroup( aLayer, group );
if( !m_painter->Draw( aItem, aLayer ) ) if( !m_painter->Draw( aItem, aLayer ) )
aItem->ViewDraw( aLayer, m_gal ); // Alternative drawing method aItem->ViewDraw( aLayer, m_gal ); // Alternative drawing method
m_gal->EndGroup(); m_gal->EndGroup();
} }
} }
...@@ -648,6 +654,7 @@ void VIEW::draw( VIEW_ITEM* aItem, bool aImmediate ) const ...@@ -648,6 +654,7 @@ void VIEW::draw( VIEW_ITEM* aItem, bool aImmediate ) const
void VIEW::draw( VIEW_GROUP* aGroup, bool aImmediate ) const void VIEW::draw( VIEW_GROUP* aGroup, bool aImmediate ) const
{ {
std::set<VIEW_ITEM*>::const_iterator it; std::set<VIEW_ITEM*>::const_iterator it;
for( it = aGroup->Begin(); it != aGroup->End(); ++it ) for( it = aGroup->Begin(); it != aGroup->End(); ++it )
{ {
draw( *it, aImmediate ); draw( *it, aImmediate );
...@@ -687,6 +694,7 @@ struct VIEW::recacheItem ...@@ -687,6 +694,7 @@ struct VIEW::recacheItem
{ {
// Remove previously cached group // Remove previously cached group
int prevGroup = aItem->getGroup( layer ); int prevGroup = aItem->getGroup( layer );
if( prevGroup >= 0 ) if( prevGroup >= 0 )
gal->DeleteGroup( prevGroup ); gal->DeleteGroup( prevGroup );
...@@ -694,8 +702,10 @@ struct VIEW::recacheItem ...@@ -694,8 +702,10 @@ struct VIEW::recacheItem
{ {
int group = gal->BeginGroup(); int group = gal->BeginGroup();
aItem->setGroup( layer, group ); aItem->setGroup( layer, group );
if( !view->m_painter->Draw( aItem, layer ) ) if( !view->m_painter->Draw( aItem, layer ) )
aItem->ViewDraw( layer, gal ); // Alternative drawing method aItem->ViewDraw( layer, gal ); // Alternative drawing method
gal->EndGroup(); gal->EndGroup();
} }
else else
...@@ -803,7 +813,7 @@ void VIEW::clearGroupCache() ...@@ -803,7 +813,7 @@ void VIEW::clearGroupCache()
for( LayerMapIter i = m_layers.begin(); i != m_layers.end(); ++i ) for( LayerMapIter i = m_layers.begin(); i != m_layers.end(); ++i )
{ {
VIEW_LAYER* l = & ( ( *i ).second ); VIEW_LAYER* l = &( ( *i ).second );
l->items->Query( r, visitor ); l->items->Query( r, visitor );
} }
} }
...@@ -881,6 +891,7 @@ void VIEW::updateItemGeometry( VIEW_ITEM* aItem, int aLayer ) ...@@ -881,6 +891,7 @@ void VIEW::updateItemGeometry( VIEW_ITEM* aItem, int aLayer )
// Redraw the item from scratch // Redraw the item from scratch
int prevGroup = aItem->getGroup( aLayer ); int prevGroup = aItem->getGroup( aLayer );
if( prevGroup >= 0 ) if( prevGroup >= 0 )
m_gal->DeleteGroup( prevGroup ); m_gal->DeleteGroup( prevGroup );
...@@ -894,6 +905,7 @@ void VIEW::updateItemGeometry( VIEW_ITEM* aItem, int aLayer ) ...@@ -894,6 +905,7 @@ void VIEW::updateItemGeometry( VIEW_ITEM* aItem, int aLayer )
void VIEW::updateBbox( VIEW_ITEM* aItem ) void VIEW::updateBbox( VIEW_ITEM* aItem )
{ {
int layers[VIEW_MAX_LAYERS], layers_count; int layers[VIEW_MAX_LAYERS], layers_count;
aItem->ViewGetLayers( layers, layers_count ); aItem->ViewGetLayers( layers, layers_count );
for( int i = 0; i < layers_count; i++ ) for( int i = 0; i < layers_count; i++ )
...@@ -912,6 +924,7 @@ void VIEW::updateLayers( VIEW_ITEM* aItem ) ...@@ -912,6 +924,7 @@ void VIEW::updateLayers( VIEW_ITEM* aItem )
// Remove the item from previous layer set // Remove the item from previous layer set
aItem->getLayers( layers, layers_count ); aItem->getLayers( layers, layers_count );
for( int i = 0; i < layers_count; i++ ) for( int i = 0; i < layers_count; i++ )
{ {
VIEW_LAYER& l = m_layers[layers[i]]; VIEW_LAYER& l = m_layers[layers[i]];
...@@ -922,6 +935,7 @@ void VIEW::updateLayers( VIEW_ITEM* aItem ) ...@@ -922,6 +935,7 @@ void VIEW::updateLayers( VIEW_ITEM* aItem )
// Add the item to new layer set // Add the item to new layer set
aItem->ViewGetLayers( layers, layers_count ); aItem->ViewGetLayers( layers, layers_count );
aItem->saveLayers( layers, layers_count ); aItem->saveLayers( layers, layers_count );
for( int i = 0; i < layers_count; i++ ) for( int i = 0; i < layers_count; i++ )
{ {
VIEW_LAYER& l = m_layers[layers[i]]; VIEW_LAYER& l = m_layers[layers[i]];
......
...@@ -39,7 +39,7 @@ ...@@ -39,7 +39,7 @@
#include <boost/foreach.hpp> #include <boost/foreach.hpp>
#include <layers_id_colors_and_visibility.h> #include <layers_id_colors_and_visibility.h>
using namespace KiGfx; using namespace KIGFX;
VIEW_GROUP::VIEW_GROUP( VIEW* aView ) : VIEW_GROUP::VIEW_GROUP( VIEW* aView ) :
m_layer( ITEM_GAL_LAYER( GP_OVERLAY ) ) m_layer( ITEM_GAL_LAYER( GP_OVERLAY ) )
...@@ -80,6 +80,7 @@ unsigned int VIEW_GROUP::GetSize() const ...@@ -80,6 +80,7 @@ unsigned int VIEW_GROUP::GetSize() const
const BOX2I VIEW_GROUP::ViewBBox() const const BOX2I VIEW_GROUP::ViewBBox() const
{ {
BOX2I maxBox; BOX2I maxBox;
maxBox.SetMaximum(); maxBox.SetMaximum();
return maxBox; return maxBox;
} }
......
...@@ -27,7 +27,7 @@ ...@@ -27,7 +27,7 @@
#include <view/view_item.h> #include <view/view_item.h>
#include <view/view.h> #include <view/view.h>
using namespace KiGfx; using namespace KIGFX;
void VIEW_ITEM::ViewSetVisible( bool aIsVisible ) void VIEW_ITEM::ViewSetVisible( bool aIsVisible )
{ {
...@@ -69,6 +69,7 @@ void VIEW_ITEM::ViewRelease() ...@@ -69,6 +69,7 @@ void VIEW_ITEM::ViewRelease()
void VIEW_ITEM::getLayers( int* aLayers, int& aCount ) const void VIEW_ITEM::getLayers( int* aLayers, int& aCount ) const
{ {
int* layersPtr = aLayers; int* layersPtr = aLayers;
for( unsigned int i = 0; i < m_layers.size(); ++i ) for( unsigned int i = 0; i < m_layers.size(); ++i )
{ {
if( m_layers[i] ) if( m_layers[i] )
......
...@@ -30,7 +30,7 @@ ...@@ -30,7 +30,7 @@
#include <gal/graphics_abstraction_layer.h> #include <gal/graphics_abstraction_layer.h>
#include <tool/tool_dispatcher.h> #include <tool/tool_dispatcher.h>
using namespace KiGfx; using namespace KIGFX;
const wxEventType WX_VIEW_CONTROLS::EVT_REFRESH_MOUSE = wxNewEventType(); const wxEventType WX_VIEW_CONTROLS::EVT_REFRESH_MOUSE = wxNewEventType();
...@@ -171,6 +171,7 @@ void WX_VIEW_CONTROLS::onButton( wxMouseEvent& aEvent ) ...@@ -171,6 +171,7 @@ void WX_VIEW_CONTROLS::onButton( wxMouseEvent& aEvent )
{ {
m_state = IDLE; // Stop autopanning when user release left mouse button m_state = IDLE; // Stop autopanning when user release left mouse button
} }
break; break;
case DRAG_PANNING: case DRAG_PANNING:
...@@ -178,6 +179,7 @@ void WX_VIEW_CONTROLS::onButton( wxMouseEvent& aEvent ) ...@@ -178,6 +179,7 @@ void WX_VIEW_CONTROLS::onButton( wxMouseEvent& aEvent )
{ {
m_state = IDLE; m_state = IDLE;
} }
break; break;
} }
...@@ -284,6 +286,7 @@ bool WX_VIEW_CONTROLS::handleAutoPanning( const wxMouseEvent& aEvent ) ...@@ -284,6 +286,7 @@ bool WX_VIEW_CONTROLS::handleAutoPanning( const wxMouseEvent& aEvent )
return false; return false;
} }
return true; return true;
break; break;
...@@ -295,6 +298,7 @@ bool WX_VIEW_CONTROLS::handleAutoPanning( const wxMouseEvent& aEvent ) ...@@ -295,6 +298,7 @@ bool WX_VIEW_CONTROLS::handleAutoPanning( const wxMouseEvent& aEvent )
return true; return true;
} }
return false; return false;
break; break;
......
...@@ -34,7 +34,7 @@ ...@@ -34,7 +34,7 @@
#include <layers_id_colors_and_visibility.h> #include <layers_id_colors_and_visibility.h>
#include <boost/foreach.hpp> #include <boost/foreach.hpp>
using namespace KiGfx; using namespace KIGFX;
WORKSHEET_VIEWITEM::WORKSHEET_VIEWITEM( const std::string& aFileName, const std::string& aSheetName, WORKSHEET_VIEWITEM::WORKSHEET_VIEWITEM( const std::string& aFileName, const std::string& aSheetName,
const PAGE_INFO* aPageInfo, const TITLE_BLOCK* aTitleBlock ) : const PAGE_INFO* aPageInfo, const TITLE_BLOCK* aTitleBlock ) :
......
...@@ -197,8 +197,8 @@ void EDA_DRAW_FRAME::OnZoom( wxCommandEvent& event ) ...@@ -197,8 +197,8 @@ void EDA_DRAW_FRAME::OnZoom( wxCommandEvent& event )
if( m_galCanvasActive ) if( m_galCanvasActive )
{ {
// Apply computed view settings to GAL // Apply computed view settings to GAL
KiGfx::VIEW* view = m_galCanvas->GetView(); KIGFX::VIEW* view = m_galCanvas->GetView();
KiGfx::GAL* gal = m_galCanvas->GetGAL(); KIGFX::GAL* gal = m_galCanvas->GetGAL();
double zoomFactor = gal->GetWorldScale() / gal->GetZoomFactor(); double zoomFactor = gal->GetWorldScale() / gal->GetZoomFactor();
double zoom = 1.0 / ( zoomFactor * GetZoom() ); double zoom = 1.0 / ( zoomFactor * GetZoom() );
......
...@@ -301,7 +301,7 @@ typedef unsigned STATUS_FLAGS; ...@@ -301,7 +301,7 @@ typedef unsigned STATUS_FLAGS;
* is a base class for most all the KiCad significant classes, used in * is a base class for most all the KiCad significant classes, used in
* schematics and boards. * schematics and boards.
*/ */
class EDA_ITEM : public KiGfx::VIEW_ITEM class EDA_ITEM : public KIGFX::VIEW_ITEM
{ {
private: private:
......
...@@ -38,7 +38,7 @@ ...@@ -38,7 +38,7 @@
class BOARD; class BOARD;
class TOOL_DISPATCHER; class TOOL_DISPATCHER;
namespace KiGfx namespace KIGFX
{ {
class GAL; class GAL;
class VIEW; class VIEW;
...@@ -73,7 +73,7 @@ public: ...@@ -73,7 +73,7 @@ public:
* Returns a pointer to the GAL instance used in the panel. * Returns a pointer to the GAL instance used in the panel.
* @return The instance of GAL. * @return The instance of GAL.
*/ */
KiGfx::GAL* GetGAL() const KIGFX::GAL* GetGAL() const
{ {
return m_gal; return m_gal;
} }
...@@ -83,7 +83,7 @@ public: ...@@ -83,7 +83,7 @@ public:
* Returns a pointer to the VIEW instance used in the panel. * Returns a pointer to the VIEW instance used in the panel.
* @return The instance of VIEW. * @return The instance of VIEW.
*/ */
KiGfx::VIEW* GetView() const KIGFX::VIEW* GetView() const
{ {
return m_view; return m_view;
} }
...@@ -93,9 +93,9 @@ public: ...@@ -93,9 +93,9 @@ public:
* Returns a pointer to the VIEW_CONTROLS instance used in the panel. * Returns a pointer to the VIEW_CONTROLS instance used in the panel.
* @return The instance of VIEW_CONTROLS. * @return The instance of VIEW_CONTROLS.
*/ */
KiGfx::VIEW_CONTROLS* GetViewControls() const KIGFX::VIEW_CONTROLS* GetViewControls() const
{ {
return (KiGfx::VIEW_CONTROLS*)( m_viewControls ); return (KIGFX::VIEW_CONTROLS*)( m_viewControls );
} }
/// @copydoc wxWindow::Refresh() /// @copydoc wxWindow::Refresh()
...@@ -125,12 +125,12 @@ protected: ...@@ -125,12 +125,12 @@ protected:
bool m_pendingRefresh; bool m_pendingRefresh;
wxTimer m_refreshTimer; wxTimer m_refreshTimer;
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.)
///< and items to be drawn ///< and items to be drawn
KiGfx::PAINTER* m_painter; ///< Contains information about how to draw items KIGFX::PAINTER* m_painter; ///< Contains information about how to draw items
///< using GAL ///< using GAL
KiGfx::WX_VIEW_CONTROLS* m_viewControls; ///< Control for VIEW (moving, zooming, etc.) KIGFX::WX_VIEW_CONTROLS* m_viewControls; ///< Control for VIEW (moving, zooming, etc.)
GalType m_currentGal; ///< Currently used GAL GalType m_currentGal; ///< Currently used GAL
TOOL_DISPATCHER* m_eventDispatcher; ///< Processes and forwards events to tools TOOL_DISPATCHER* m_eventDispatcher; ///< Processes and forwards events to tools
}; };
......
...@@ -36,7 +36,7 @@ ...@@ -36,7 +36,7 @@
#include <boost/smart_ptr/shared_array.hpp> #include <boost/smart_ptr/shared_array.hpp>
#include <deque> #include <deque>
namespace KiGfx namespace KIGFX
{ {
class CAIRO_COMPOSITOR : public COMPOSITOR class CAIRO_COMPOSITOR : public COMPOSITOR
{ {
...@@ -122,6 +122,6 @@ protected: ...@@ -122,6 +122,6 @@ protected:
return m_buffers.size(); return m_buffers.size();
} }
}; };
} // namespace KiGfx } // namespace KIGFX
#endif /* COMPOSITOR_H_ */ #endif /* COMPOSITOR_H_ */
...@@ -58,7 +58,7 @@ ...@@ -58,7 +58,7 @@
* of KiCad graphics surfaces as well. * of KiCad graphics surfaces as well.
* *
*/ */
namespace KiGfx namespace KIGFX
{ {
class CAIRO_COMPOSITOR; class CAIRO_COMPOSITOR;
...@@ -126,7 +126,7 @@ public: ...@@ -126,7 +126,7 @@ public:
// -------------- // --------------
/// @brief Resizes the canvas. /// @brief Resizes the canvas.
virtual void ResizeScreen ( int aWidth, int aHeight ); virtual void ResizeScreen( int aWidth, int aHeight );
/// @brief Shows/hides the GAL canvas /// @brief Shows/hides the GAL canvas
virtual bool Show( bool aShow ); virtual bool Show( bool aShow );
...@@ -386,6 +386,6 @@ private: ...@@ -386,6 +386,6 @@ private:
/// Format used to store pixels /// Format used to store pixels
static const cairo_format_t GAL_FORMAT = CAIRO_FORMAT_RGB24; static const cairo_format_t GAL_FORMAT = CAIRO_FORMAT_RGB24;
}; };
} // namespace KiGfx } // namespace KIGFX
#endif // CAIROGAL_H_ #endif // CAIROGAL_H_
...@@ -30,7 +30,7 @@ ...@@ -30,7 +30,7 @@
#include <colors.h> #include <colors.h>
#include <cassert> #include <cassert>
namespace KiGfx namespace KIGFX
{ {
/** /**
* Class COLOR4D * Class COLOR4D
...@@ -182,7 +182,7 @@ public: ...@@ -182,7 +182,7 @@ public:
double GetBrightness() const double GetBrightness() const
{ {
// Weighted W3C formula // Weighted W3C formula
return ( r * 0.299 + g * 0.587 + b * 0.117 ); return r * 0.299 + g * 0.587 + b * 0.117;
} }
/** /**
...@@ -217,6 +217,6 @@ public: ...@@ -217,6 +217,6 @@ public:
double b; ///< Blue component double b; ///< Blue component
double a; ///< Alpha component double a; ///< Alpha component
}; };
} // namespace KiGfx } // namespace KIGFX
#endif /* COLOR4D_H_ */ #endif /* COLOR4D_H_ */
...@@ -31,7 +31,7 @@ ...@@ -31,7 +31,7 @@
#ifndef COMPOSITOR_H_ #ifndef COMPOSITOR_H_
#define COMPOSITOR_H_ #define COMPOSITOR_H_
namespace KiGfx namespace KIGFX
{ {
class COMPOSITOR class COMPOSITOR
...@@ -101,6 +101,6 @@ protected: ...@@ -101,6 +101,6 @@ protected:
unsigned int m_height; ///< Height of the buffer (in pixels) unsigned int m_height; ///< Height of the buffer (in pixels)
}; };
} // namespace KiGfx } // namespace KIGFX
#endif /* COMPOSITOR_H_ */ #endif /* COMPOSITOR_H_ */
...@@ -31,18 +31,18 @@ ...@@ -31,18 +31,18 @@
#define SWAP( varA, condition, varB ) if( varA condition varB ) { double tmp = varA; varA = varB; \ #define SWAP( varA, condition, varB ) if( varA condition varB ) { double tmp = varA; varA = varB; \
varB = tmp; } varB = tmp; }
namespace KiGfx namespace KIGFX
{ {
/** /**
* RenderTarget: Possible rendering targets * RenderTarget: Possible rendering targets
*/ */
enum RenderTarget enum RenderTarget
{ {
TARGET_CACHED = 0, ///< Main rendering target (cached) TARGET_CACHED = 0, ///< Main rendering target (cached)
TARGET_NONCACHED, ///< Auxiliary rendering target (noncached) TARGET_NONCACHED, ///< Auxiliary rendering target (noncached)
TARGET_OVERLAY, ///< Items that may change while the view stays the same (noncached) TARGET_OVERLAY, ///< Items that may change while the view stays the same (noncached)
TARGETS_NUMBER ///< Number of available rendering targets TARGETS_NUMBER ///< Number of available rendering targets
}; };
} } // namespace KIGFX
#endif /* DEFINITIONS_H_ */ #endif /* DEFINITIONS_H_ */
...@@ -40,7 +40,7 @@ ...@@ -40,7 +40,7 @@
#include <gal/stroke_font.h> #include <gal/stroke_font.h>
#include <newstroke_font.h> #include <newstroke_font.h>
namespace KiGfx namespace KIGFX
{ {
/** /**
* GridStyle: Type definition of the grid style * GridStyle: Type definition of the grid style
...@@ -891,6 +891,6 @@ protected: ...@@ -891,6 +891,6 @@ protected:
static const int MIN_DEPTH = -2048; static const int MIN_DEPTH = -2048;
static const int MAX_DEPTH = 2047; static const int MAX_DEPTH = 2047;
}; };
} // namespace KiGfx } // namespace KIGFX
#endif /* GRAPHICSABSTRACTIONLAYER_H_ */ #endif /* GRAPHICSABSTRACTIONLAYER_H_ */
...@@ -37,9 +37,9 @@ ...@@ -37,9 +37,9 @@
#include <set> #include <set>
// Debug messages verbosity level // Debug messages verbosity level
//#define CACHED_CONTAINER_TEST 1 // #define CACHED_CONTAINER_TEST 1
namespace KiGfx namespace KIGFX
{ {
class VERTEX_ITEM; class VERTEX_ITEM;
class SHADER; class SHADER;
...@@ -173,6 +173,6 @@ private: ...@@ -173,6 +173,6 @@ private:
inline void test() {} inline void test() {}
#endif /* CACHED_CONTAINER_TEST */ #endif /* CACHED_CONTAINER_TEST */
}; };
} // namespace KiGfx } // namespace KIGFX
#endif /* CACHED_CONTAINER_H_ */ #endif /* CACHED_CONTAINER_H_ */
...@@ -33,7 +33,7 @@ ...@@ -33,7 +33,7 @@
#include <gal/opengl/vertex_common.h> #include <gal/opengl/vertex_common.h>
#include <boost/scoped_array.hpp> #include <boost/scoped_array.hpp>
namespace KiGfx namespace KIGFX
{ {
class SHADER; class SHADER;
class VERTEX_CONTAINER; class VERTEX_CONTAINER;
...@@ -135,7 +135,6 @@ protected: ...@@ -135,7 +135,6 @@ protected:
GLuint* m_indicesPtr; GLuint* m_indicesPtr;
GLuint m_verticesBuffer; GLuint m_verticesBuffer;
unsigned int m_indicesSize; unsigned int m_indicesSize;
}; };
...@@ -159,5 +158,5 @@ public: ...@@ -159,5 +158,5 @@ public:
///< @copydoc GPU_MANAGER::EndDrawing() ///< @copydoc GPU_MANAGER::EndDrawing()
virtual void EndDrawing(); virtual void EndDrawing();
}; };
} // namespace KiGfx } // namespace KIGFX
#endif /* GPU_MANAGER_H_ */ #endif /* GPU_MANAGER_H_ */
...@@ -33,7 +33,7 @@ ...@@ -33,7 +33,7 @@
#include <gal/opengl/vertex_container.h> #include <gal/opengl/vertex_container.h>
namespace KiGfx namespace KIGFX
{ {
class VERTEX_ITEM; class VERTEX_ITEM;
class SHADER; class SHADER;
...@@ -68,6 +68,6 @@ protected: ...@@ -68,6 +68,6 @@ protected:
///< Index of the free first space where a vertex can be stored ///< Index of the free first space where a vertex can be stored
unsigned int m_freePtr; unsigned int m_freePtr;
}; };
} // namespace KiGfx } // namespace KIGFX
#endif /* NONCACHED_CONTAINER_H_ */ #endif /* NONCACHED_CONTAINER_H_ */
...@@ -35,7 +35,7 @@ ...@@ -35,7 +35,7 @@
#include <GL/glew.h> #include <GL/glew.h>
#include <deque> #include <deque>
namespace KiGfx namespace KIGFX
{ {
class OPENGL_COMPOSITOR : public COMPOSITOR class OPENGL_COMPOSITOR : public COMPOSITOR
{ {
...@@ -105,6 +105,6 @@ protected: ...@@ -105,6 +105,6 @@ protected:
return m_buffers.size(); return m_buffers.size();
} }
}; };
} // namespace KiGfx } // namespace KIGFX
#endif /* COMPOSITOR_H_ */ #endif /* COMPOSITOR_H_ */
...@@ -57,7 +57,7 @@ ...@@ -57,7 +57,7 @@
#define CALLBACK #define CALLBACK
#endif #endif
namespace KiGfx namespace KIGFX
{ {
class SHADER; class SHADER;
...@@ -253,6 +253,7 @@ public: ...@@ -253,6 +253,7 @@ public:
{ {
/// Manager used for storing new vertices /// Manager used for storing new vertices
VERTEX_MANAGER* vboManager; VERTEX_MANAGER* vboManager;
/// Intersect points, that have to be freed after tessellation /// Intersect points, that have to be freed after tessellation
std::deque< boost::shared_array<GLdouble> >& intersectPoints; std::deque< boost::shared_array<GLdouble> >& intersectPoints;
} TessParams; } TessParams;
...@@ -377,6 +378,6 @@ private: ...@@ -377,6 +378,6 @@ private:
*/ */
unsigned int getNewGroupNumber(); unsigned int getNewGroupNumber();
}; };
} // namespace KiGfx } // namespace KIGFX
#endif // OPENGLGAL_H_ #endif // OPENGLGAL_H_
...@@ -34,7 +34,7 @@ ...@@ -34,7 +34,7 @@
#include <string> #include <string>
#include <deque> #include <deque>
namespace KiGfx namespace KIGFX
{ {
class OPENGL_GAL; class OPENGL_GAL;
...@@ -205,6 +205,6 @@ private: ...@@ -205,6 +205,6 @@ private:
GLuint geomOutputType; ///< Output type [e.g. GL_LINES, GL_TRIANGLES, GL_QUADS etc.] GLuint geomOutputType; ///< Output type [e.g. GL_LINES, GL_TRIANGLES, GL_QUADS etc.]
std::deque<GLint> parameterLocation; ///< Location of the parameter std::deque<GLint> parameterLocation; ///< Location of the parameter
}; };
} // namespace KiGfx } // namespace KIGFX
#endif /* SHADER_H_ */ #endif /* SHADER_H_ */
...@@ -32,10 +32,11 @@ ...@@ -32,10 +32,11 @@
#include <GL/glew.h> #include <GL/glew.h>
namespace KiGfx namespace KIGFX
{ {
// Possible types of shaders // Possible types of shaders
enum SHADER_TYPE { enum SHADER_TYPE
{
SHADER_NONE = 0, SHADER_NONE = 0,
SHADER_LINE, SHADER_LINE,
SHADER_FILLED_CIRCLE, SHADER_FILLED_CIRCLE,
...@@ -68,7 +69,6 @@ const unsigned int ShaderSize = sizeof(VERTEX().shader); ...@@ -68,7 +69,6 @@ const unsigned int ShaderSize = sizeof(VERTEX().shader);
const unsigned int ShaderStride = ShaderSize / sizeof(GLfloat); const unsigned int ShaderStride = ShaderSize / sizeof(GLfloat);
const unsigned int IndexSize = sizeof(GLuint); const unsigned int IndexSize = sizeof(GLuint);
} // namespace KIGFX
} // namespace KiGfx
#endif /* VERTEX_COMMON_H_ */ #endif /* VERTEX_COMMON_H_ */
...@@ -32,7 +32,7 @@ ...@@ -32,7 +32,7 @@
#include <gal/opengl/vertex_common.h> #include <gal/opengl/vertex_common.h>
namespace KiGfx namespace KIGFX
{ {
class VERTEX_ITEM; class VERTEX_ITEM;
class SHADER; class SHADER;
...@@ -45,6 +45,7 @@ public: ...@@ -45,6 +45,7 @@ public:
* Returns a pointer to a new container of an appropriate type. * Returns a pointer to a new container of an appropriate type.
*/ */
static VERTEX_CONTAINER* MakeContainer( bool aCached ); static VERTEX_CONTAINER* MakeContainer( bool aCached );
virtual ~VERTEX_CONTAINER(); virtual ~VERTEX_CONTAINER();
/** /**
...@@ -170,6 +171,6 @@ protected: ...@@ -170,6 +171,6 @@ protected:
///< Default initial size of a container (expressed in vertices) ///< Default initial size of a container (expressed in vertices)
static const unsigned int defaultInitSize = 1048576; static const unsigned int defaultInitSize = 1048576;
}; };
} // namespace KiGfx } // namespace KIGFX
#endif /* VERTEX_CONTAINER_H_ */ #endif /* VERTEX_CONTAINER_H_ */
...@@ -34,7 +34,7 @@ ...@@ -34,7 +34,7 @@
#include <gal/color4d.h> #include <gal/color4d.h>
#include <cstddef> #include <cstddef>
namespace KiGfx namespace KIGFX
{ {
class VERTEX_MANAGER; class VERTEX_MANAGER;
...@@ -98,6 +98,6 @@ private: ...@@ -98,6 +98,6 @@ private:
m_size = aSize; m_size = aSize;
} }
}; };
} // namespace KiGfx } // namespace KIGFX
#endif /* VERTEX_ITEM_H_ */ #endif /* VERTEX_ITEM_H_ */
...@@ -40,7 +40,7 @@ ...@@ -40,7 +40,7 @@
#include <boost/smart_ptr/shared_ptr.hpp> #include <boost/smart_ptr/shared_ptr.hpp>
#include <wx/log.h> #include <wx/log.h>
namespace KiGfx namespace KIGFX
{ {
class SHADER; class SHADER;
class VERTEX_ITEM; class VERTEX_ITEM;
...@@ -342,6 +342,6 @@ protected: ...@@ -342,6 +342,6 @@ protected:
GLfloat m_shader[ShaderStride]; GLfloat m_shader[ShaderStride];
}; };
} // namespace KiGfx } // namespace KIGFX
#endif /* VERTEX_MANAGER_H_ */ #endif /* VERTEX_MANAGER_H_ */
...@@ -34,7 +34,7 @@ ...@@ -34,7 +34,7 @@
#include <math/box2.h> #include <math/box2.h>
namespace KiGfx namespace KIGFX
{ {
class GAL; class GAL;
...@@ -184,6 +184,6 @@ private: ...@@ -184,6 +184,6 @@ private:
static const double LINE_HEIGHT_RATIO; static const double LINE_HEIGHT_RATIO;
}; };
} // namespace KiGfx } // namespace KIGFX
#endif /* STROKE_FONT_H_ */ #endif /* STROKE_FONT_H_ */
...@@ -42,9 +42,9 @@ ...@@ -42,9 +42,9 @@
// RTree.h // RTree.h
// //
#define RTREE_TEMPLATE template<class DATATYPE, class ELEMTYPE, int NUMDIMS, \ #define RTREE_TEMPLATE template <class DATATYPE, class ELEMTYPE, int NUMDIMS, \
class ELEMTYPEREAL, int TMAXNODES, int TMINNODES> class ELEMTYPEREAL, int TMAXNODES, int TMINNODES>
#define RTREE_SEARCH_TEMPLATE template<class DATATYPE, class ELEMTYPE, int NUMDIMS, \ #define RTREE_SEARCH_TEMPLATE template <class DATATYPE, class ELEMTYPE, int NUMDIMS, \
class ELEMTYPEREAL, int TMAXNODES, int TMINNODES, class VISITOR> class ELEMTYPEREAL, int TMAXNODES, int TMINNODES, class VISITOR>
#define RTREE_QUAL RTree<DATATYPE, ELEMTYPE, NUMDIMS, ELEMTYPEREAL, TMAXNODES, \ #define RTREE_QUAL RTree<DATATYPE, ELEMTYPE, NUMDIMS, ELEMTYPEREAL, TMAXNODES, \
TMINNODES> TMINNODES>
......
...@@ -36,11 +36,10 @@ typedef boost::optional<VECTOR2I> OPT_VECTOR2I; ...@@ -36,11 +36,10 @@ typedef boost::optional<VECTOR2I> OPT_VECTOR2I;
class SEG class SEG
{ {
private: private:
typedef VECTOR2I::extended_type ecoord; typedef VECTOR2I::extended_type ecoord;
public: public:
friend inline std::ostream& operator<<( std::ostream& aStream, const SEG& aSeg ); friend inline std::ostream& operator<<( std::ostream& aStream, const SEG& aSeg );
/* Start and the of the segment. Public, to make access simpler. These are references /* Start and the of the segment. Public, to make access simpler. These are references
......
...@@ -35,7 +35,8 @@ ...@@ -35,7 +35,8 @@
* Lists all supported shapes * Lists all supported shapes
*/ */
enum ShapeType { enum ShapeType
{
SH_RECT = 0, ///> axis-aligned rectangle SH_RECT = 0, ///> axis-aligned rectangle
SH_SEGMENT, ///> line segment SH_SEGMENT, ///> line segment
SH_LINE_CHAIN, ///> line chain (polyline) SH_LINE_CHAIN, ///> line chain (polyline)
...@@ -47,7 +48,8 @@ enum ShapeType { ...@@ -47,7 +48,8 @@ enum ShapeType {
* *
* Represents an abstract shape on 2D plane. * Represents an abstract shape on 2D plane.
*/ */
class SHAPE { class SHAPE
{
protected: protected:
typedef VECTOR2I::extended_type ecoord; typedef VECTOR2I::extended_type ecoord;
...@@ -77,7 +79,8 @@ class SHAPE { ...@@ -77,7 +79,8 @@ class SHAPE {
* Returns a dynamically allocated copy of the shape * Returns a dynamically allocated copy of the shape
* @retval copy of the shape * @retval copy of the shape
*/ */
virtual SHAPE* Clone() const { virtual SHAPE* Clone() const
{
assert( false ); assert( false );
return NULL; return NULL;
}; };
...@@ -106,6 +109,7 @@ class SHAPE { ...@@ -106,6 +109,7 @@ class SHAPE {
*/ */
virtual bool Collide( const SHAPE* aShape, int aClerance, VECTOR2I& aMTV ) const; virtual bool Collide( const SHAPE* aShape, int aClerance, VECTOR2I& aMTV ) const;
virtual bool Collide( const SHAPE* aShape, int aClerance = 0 ) const; virtual bool Collide( const SHAPE* aShape, int aClerance = 0 ) const;
/** /**
* Function Collide() * Function Collide()
* *
...@@ -139,9 +143,8 @@ class SHAPE { ...@@ -139,9 +143,8 @@ class SHAPE {
private: private:
///> type of our shape ///> type of our shape
ShapeType m_type; ShapeType m_type;
}; };
bool CollideShapes( const SHAPE *aA, const SHAPE *aB, int aClearance, bool aNeedMTV, VECTOR2I& aMTV ); bool CollideShapes( const SHAPE* aA, const SHAPE* aB, int aClearance, bool aNeedMTV, VECTOR2I& aMTV );
#endif // __SHAPE_H #endif // __SHAPE_H
...@@ -27,13 +27,13 @@ ...@@ -27,13 +27,13 @@
#include "shape.h" #include "shape.h"
class SHAPE_CIRCLE : public SHAPE { class SHAPE_CIRCLE : public SHAPE
{
public: public:
SHAPE_CIRCLE(): SHAPE_CIRCLE() :
SHAPE( SH_CIRCLE ), m_radius( 0 ) {}; SHAPE( SH_CIRCLE ), m_radius( 0 ) {};
SHAPE_CIRCLE( const VECTOR2I& aCenter, int aRadius ): SHAPE_CIRCLE( const VECTOR2I& aCenter, int aRadius ) :
SHAPE( SH_CIRCLE ), m_radius( aRadius ), m_center( aCenter ) {}; SHAPE( SH_CIRCLE ), m_radius( aRadius ), m_center( aCenter ) {};
~SHAPE_CIRCLE() {}; ~SHAPE_CIRCLE() {};
...@@ -41,12 +41,14 @@ public: ...@@ -41,12 +41,14 @@ public:
const BOX2I BBox( int aClearance = 0 ) const const BOX2I BBox( int aClearance = 0 ) const
{ {
const VECTOR2I rc( m_radius + aClearance, m_radius + aClearance ); const VECTOR2I rc( m_radius + aClearance, m_radius + aClearance );
return BOX2I( m_center - rc, rc * 2 ); return BOX2I( m_center - rc, rc * 2 );
} }
bool Collide( const SEG& aSeg, int aClearance = 0 ) const bool Collide( const SEG& aSeg, int aClearance = 0 ) const
{ {
int rc = aClearance + m_radius; int rc = aClearance + m_radius;
return aSeg.Distance( m_center ) <= rc; return aSeg.Distance( m_center ) <= rc;
} }
...@@ -69,6 +71,7 @@ public: ...@@ -69,6 +71,7 @@ public:
{ {
return m_center; return m_center;
} }
private: private:
int m_radius; int m_radius;
VECTOR2I m_center; VECTOR2I m_center;
......
...@@ -46,10 +46,11 @@ static const SHAPE* shapeFunctor( T aItem ) ...@@ -46,10 +46,11 @@ static const SHAPE* shapeFunctor( T aItem )
return aItem->GetShape(); return aItem->GetShape();
} }
/** /**
* shapeFunctor template function: specialization for T = SHAPE* * shapeFunctor template function: specialization for T = SHAPE*
*/ */
template<> template <>
const SHAPE* shapeFunctor( SHAPE* aItem ); const SHAPE* shapeFunctor( SHAPE* aItem );
/** /**
...@@ -67,6 +68,7 @@ BOX2I boundingBox( T aObject ) ...@@ -67,6 +68,7 @@ BOX2I boundingBox( T aObject )
return shapeFunctor( aObject )->BBox(); return shapeFunctor( aObject )->BBox();
} }
/** /**
* acceptVisitor template method * acceptVisitor template method
* *
...@@ -82,6 +84,7 @@ void acceptVisitor( T aObject, V aVisitor ) ...@@ -82,6 +84,7 @@ void acceptVisitor( T aObject, V aVisitor )
aVisitor( aObject ); aVisitor( aObject );
} }
/** /**
* collide template method * collide template method
* *
...@@ -93,22 +96,23 @@ void acceptVisitor( T aObject, V aVisitor ) ...@@ -93,22 +96,23 @@ void acceptVisitor( T aObject, V aVisitor )
* @param minDistance minimum collision distance * @param minDistance minimum collision distance
* @return if object and anotherObject collide * @return if object and anotherObject collide
*/ */
template<class T, class U> template <class T, class U>
bool collide( T aObject, U aAnotherObject, int aMinDistance ) bool collide( T aObject, U aAnotherObject, int aMinDistance )
{ {
return shapeFunctor( aObject )->Collide( aAnotherObject, aMinDistance ); return shapeFunctor( aObject )->Collide( aAnotherObject, aMinDistance );
} }
template<class T, class V> template <class T, class V>
bool queryCallback( T aShape, void* aContext ) bool queryCallback( T aShape, void* aContext )
{ {
V* visitor = (V*) aContext; V* visitor = (V*) aContext;
acceptVisitor<T,V>( aShape, *visitor );
acceptVisitor<T, V>( aShape, *visitor );
return true; return true;
} }
template<class T = SHAPE*> template <class T = SHAPE*>
class SHAPE_INDEX class SHAPE_INDEX
{ {
public: public:
...@@ -242,7 +246,7 @@ class SHAPE_INDEX ...@@ -242,7 +246,7 @@ class SHAPE_INDEX
* Accepts a visitor for every SHAPE object contained in this INDEX. * Accepts a visitor for every SHAPE object contained in this INDEX.
* @param visitor Visitor object to be run * @param visitor Visitor object to be run
*/ */
template<class V> template <class V>
void Accept( V aVisitor ) void Accept( V aVisitor )
{ {
Iterator iter = this->Begin(); Iterator iter = this->Begin();
...@@ -271,7 +275,7 @@ class SHAPE_INDEX ...@@ -271,7 +275,7 @@ class SHAPE_INDEX
* @param minDistance distance threshold * @param minDistance distance threshold
* @param visitor object to be invoked on every object contained in the search area. * @param visitor object to be invoked on every object contained in the search area.
*/ */
template<class V> template <class V>
int Query( const SHAPE *aShape, int aMinDistance, V& aVisitor, bool aExact ) int Query( const SHAPE *aShape, int aMinDistance, V& aVisitor, bool aExact )
{ {
BOX2I box = aShape->BBox(); BOX2I box = aShape->BBox();
...@@ -299,19 +303,19 @@ class SHAPE_INDEX ...@@ -299,19 +303,19 @@ class SHAPE_INDEX
* Class members implementation * Class members implementation
*/ */
template<class T> template <class T>
SHAPE_INDEX<T>::SHAPE_INDEX() SHAPE_INDEX<T>::SHAPE_INDEX()
{ {
this->m_tree = new RTree<T, int, 2, float>(); this->m_tree = new RTree<T, int, 2, float>();
} }
template<class T> template <class T>
SHAPE_INDEX<T>::~SHAPE_INDEX() SHAPE_INDEX<T>::~SHAPE_INDEX()
{ {
delete this->m_tree; delete this->m_tree;
} }
template<class T> template <class T>
void SHAPE_INDEX<T>::Add( T aShape ) void SHAPE_INDEX<T>::Add( T aShape )
{ {
BOX2I box = boundingBox( aShape ); BOX2I box = boundingBox( aShape );
...@@ -321,7 +325,7 @@ void SHAPE_INDEX<T>::Add( T aShape ) ...@@ -321,7 +325,7 @@ void SHAPE_INDEX<T>::Add( T aShape )
this->m_tree->Insert( min, max, aShape ); this->m_tree->Insert( min, max, aShape );
} }
template<class T> template <class T>
void SHAPE_INDEX<T>::Remove( T aShape ) void SHAPE_INDEX<T>::Remove( T aShape )
{ {
BOX2I box = boundingBox( aShape ); BOX2I box = boundingBox( aShape );
...@@ -331,19 +335,20 @@ void SHAPE_INDEX<T>::Remove( T aShape ) ...@@ -331,19 +335,20 @@ void SHAPE_INDEX<T>::Remove( T aShape )
this->m_tree->Remove( min, max, aShape ); this->m_tree->Remove( min, max, aShape );
} }
template<class T> template <class T>
void SHAPE_INDEX<T>::RemoveAll() void SHAPE_INDEX<T>::RemoveAll()
{ {
this->m_tree->RemoveAll(); this->m_tree->RemoveAll();
} }
template<class T> template <class T>
void SHAPE_INDEX<T>::Reindex() void SHAPE_INDEX<T>::Reindex()
{ {
RTree<T, int, 2, float>* newTree; RTree<T, int, 2, float>* newTree;
newTree = new RTree<T, int, 2, float>(); newTree = new RTree<T, int, 2, float>();
Iterator iter = this->Begin(); Iterator iter = this->Begin();
while( !iter.IsNull() ) while( !iter.IsNull() )
{ {
T shape = *iter; T shape = *iter;
...@@ -358,7 +363,7 @@ void SHAPE_INDEX<T>::Reindex() ...@@ -358,7 +363,7 @@ void SHAPE_INDEX<T>::Reindex()
this->m_tree = newTree; this->m_tree = newTree;
} }
template<class T> template <class T>
typename SHAPE_INDEX<T>::Iterator SHAPE_INDEX<T>::Begin() typename SHAPE_INDEX<T>::Iterator SHAPE_INDEX<T>::Begin()
{ {
return Iterator( this ); return Iterator( this );
......
...@@ -27,16 +27,17 @@ ...@@ -27,16 +27,17 @@
#include <boost/unordered_map.hpp> #include <boost/unordered_map.hpp>
template <class T> const SHAPE* defaultShapeFunctor( const T aItem ) template <class T>
const SHAPE* defaultShapeFunctor( const T aItem )
{ {
return aItem->GetShape(); return aItem->GetShape();
} }
template <class T, const SHAPE* (ShapeFunctor)(const T) = defaultShapeFunctor<T> > template <class T, const SHAPE* (ShapeFunctor) (const T) = defaultShapeFunctor<T> >
class SHAPE_INDEX_LIST
class SHAPE_INDEX_LIST { {
struct ShapeEntry
struct ShapeEntry { {
ShapeEntry( T aParent ) ShapeEntry( T aParent )
{ {
shape = ShapeFunctor( aParent ); shape = ShapeFunctor( aParent );
...@@ -58,14 +59,15 @@ class SHAPE_INDEX_LIST { ...@@ -58,14 +59,15 @@ class SHAPE_INDEX_LIST {
public: public:
// "Normal" iterator interface, for STL algorithms. // "Normal" iterator interface, for STL algorithms.
class iterator { class iterator
{
public: public:
iterator() {}; iterator() {};
iterator( ShapeVecIter aCurrent ) iterator( ShapeVecIter aCurrent ) :
: m_current( aCurrent ) {}; m_current( aCurrent ) {};
iterator( const iterator &aB ) : iterator( const iterator& aB ) :
m_current( aB.m_current ) {}; m_current( aB.m_current ) {};
T operator*() const T operator*() const
...@@ -105,7 +107,8 @@ public: ...@@ -105,7 +107,8 @@ public:
}; };
// "Query" iterator, for iterating over a set of spatially matching shapes. // "Query" iterator, for iterating over a set of spatially matching shapes.
class query_iterator { class query_iterator
{
public: public:
query_iterator() query_iterator()
{ {
...@@ -126,7 +129,7 @@ public: ...@@ -126,7 +129,7 @@ public:
} }
} }
query_iterator( const query_iterator &aB ) : query_iterator( const query_iterator& aB ) :
m_end( aB.m_end ), m_end( aB.m_end ),
m_current( aB.m_current ), m_current( aB.m_current ),
m_shape( aB.m_shape ), m_shape( aB.m_shape ),
...@@ -195,7 +198,7 @@ public: ...@@ -195,7 +198,7 @@ public:
ShapeVecIter m_current; ShapeVecIter m_current;
BOX2I m_refBBox; BOX2I m_refBBox;
bool m_exact; bool m_exact;
SHAPE *m_shape; SHAPE* m_shape;
int m_minDistance; int m_minDistance;
}; };
...@@ -203,7 +206,7 @@ public: ...@@ -203,7 +206,7 @@ public:
{ {
ShapeEntry s( aItem ); ShapeEntry s( aItem );
m_shapes.push_back(s); m_shapes.push_back( s );
} }
void Remove( const T aItem ) void Remove( const T aItem )
...@@ -227,8 +230,8 @@ public: ...@@ -227,8 +230,8 @@ public:
return m_shapes.size(); return m_shapes.size();
} }
template<class Visitor> template <class Visitor>
int Query( const SHAPE *aShape, int aMinDistance, Visitor &aV, bool aExact = true ) //const int Query( const SHAPE* aShape, int aMinDistance, Visitor& aV, bool aExact = true ) // const
{ {
ShapeVecIter i; ShapeVecIter i;
int n = 0; int n = 0;
...@@ -243,11 +246,13 @@ public: ...@@ -243,11 +246,13 @@ public:
if( !aExact || i->shape->Collide( aShape, aMinDistance ) ) if( !aExact || i->shape->Collide( aShape, aMinDistance ) )
{ {
n++; n++;
if( !aV( i->parent ) ) if( !aV( i->parent ) )
return n; return n;
} }
} }
} }
return n; return n;
} }
......
...@@ -30,7 +30,8 @@ ...@@ -30,7 +30,8 @@
#include <geometry/shape_circle.h> #include <geometry/shape_circle.h>
#include <geometry/seg.h> #include <geometry/seg.h>
class SHAPE_RECT : public SHAPE { class SHAPE_RECT : public SHAPE
{
public: public:
/** /**
* Constructor * Constructor
...@@ -50,11 +51,11 @@ class SHAPE_RECT : public SHAPE { ...@@ -50,11 +51,11 @@ class SHAPE_RECT : public SHAPE {
* Constructor * Constructor
* Creates a rectangle defined by top-left corner aP0, width aW and height aH. * Creates a rectangle defined by top-left corner aP0, width aW and height aH.
*/ */
SHAPE_RECT( const VECTOR2I &aP0, int aW, int aH ) : SHAPE_RECT( const VECTOR2I& aP0, int aW, int aH ) :
SHAPE( SH_RECT ), m_p0( aP0 ), m_w( aW ), m_h( aH ) {}; SHAPE( SH_RECT ), m_p0( aP0 ), m_w( aW ), m_h( aH ) {};
/// @copydoc SHAPE::BBox() /// @copydoc SHAPE::BBox()
const BOX2I BBox(int aClearance = 0) const const BOX2I BBox( int aClearance = 0 ) const
{ {
BOX2I bbox( VECTOR2I( m_p0.x - aClearance, m_p0.y - aClearance ), BOX2I bbox( VECTOR2I( m_p0.x - aClearance, m_p0.y - aClearance ),
VECTOR2I( m_w + 2 * aClearance, m_h + 2 * aClearance ) ); VECTOR2I( m_w + 2 * aClearance, m_h + 2 * aClearance ) );
...@@ -76,11 +77,11 @@ class SHAPE_RECT : public SHAPE { ...@@ -76,11 +77,11 @@ class SHAPE_RECT : public SHAPE {
/// @copydoc SHAPE::Collide() /// @copydoc SHAPE::Collide()
bool Collide( const SEG& aSeg, int aClearance = 0 ) const bool Collide( const SEG& aSeg, int aClearance = 0 ) const
{ {
//VECTOR2I pmin = VECTOR2I(std::min(aSeg.a.x, aSeg.b.x), std::min(aSeg.a.y, aSeg.b.y)); //VECTOR2I pmin = VECTOR2I( std::min( aSeg.a.x, aSeg.b.x ), std::min( aSeg.a.y, aSeg.b.y ) );
//VECTOR2I pmax = VECTOR2I(std::max(aSeg.a.x, aSeg.b.x), std::max(aSeg.a.y, aSeg.b.y)); //VECTOR2I pmax = VECTOR2I( std::max( aSeg.a.x, aSeg.b.x ), std::max( aSeg.a.y, aSeg.b.y ));
//BOX2I r(pmin, VECTOR2I(pmax.x - pmin.x, pmax.y - pmin.y)); //BOX2I r( pmin, VECTOR2I( pmax.x - pmin.x, pmax.y - pmin.y ) );
//if (BBox(0).SquaredDistance(r) > aClearance * aClearance) //if( BBox( 0 ).SquaredDistance( r ) > aClearance * aClearance )
// return false; // return false;
if( BBox( 0 ).Contains( aSeg.a ) || BBox( 0 ).Contains( aSeg.b ) ) if( BBox( 0 ).Contains( aSeg.a ) || BBox( 0 ).Contains( aSeg.b ) )
...@@ -107,28 +108,40 @@ class SHAPE_RECT : public SHAPE { ...@@ -107,28 +108,40 @@ class SHAPE_RECT : public SHAPE {
* *
* @return top-left corner of the rectangle * @return top-left corner of the rectangle
*/ */
const VECTOR2I& GetPosition() const { return m_p0; } const VECTOR2I& GetPosition() const
{
return m_p0;
}
/** /**
* Function GetSize() * Function GetSize()
* *
* @return size of the rectangle * @return size of the rectangle
*/ */
const VECTOR2I GetSize() const { return VECTOR2I( m_w, m_h ); } const VECTOR2I GetSize() const
{
return VECTOR2I( m_w, m_h );
}
/** /**
* Function GetWidth() * Function GetWidth()
* *
* @return width of the rectangle * @return width of the rectangle
*/ */
const int GetWidth() const { return m_w; } const int GetWidth() const
{
return m_w;
}
/** /**
* Function GetHeight() * Function GetHeight()
* *
* @return height of the rectangle * @return height of the rectangle
*/ */
const int GetHeight() const { return m_h; } const int GetHeight() const
{
return m_h;
}
private: private:
///> Top-left corner ///> Top-left corner
......
...@@ -67,7 +67,7 @@ template < typename T > struct LENGTH_TRAITS< T, 0 > ...@@ -67,7 +67,7 @@ template < typename T > struct LENGTH_TRAITS< T, 0 >
typedef T flat; typedef T flat;
}; };
template< typename T, int P > class LENGTH template < typename T, int P > class LENGTH
{ {
friend class LENGTH_UNITS< T >; friend class LENGTH_UNITS< T >;
friend class LENGTH_TRAITS< T, P >; friend class LENGTH_TRAITS< T, P >;
...@@ -109,7 +109,7 @@ public: ...@@ -109,7 +109,7 @@ public:
this->m_U = y.m_U; this->m_U = y.m_U;
return *this; return *this;
} }
template<typename Y> operator LENGTH< Y, P > ( void ) template <typename Y> operator LENGTH< Y, P > ( void )
{ {
return this->m_U; return this->m_U;
} }
......
...@@ -58,7 +58,7 @@ static inline const wxChar* GetChars( const wxString& s ) ...@@ -58,7 +58,7 @@ static inline const wxChar* GetChars( const wxString& s )
} }
// This really needs a function? well, it is used *a lot* of times // This really needs a function? well, it is used *a lot* of times
template<class T> inline void NEGATE( T &x ) { x = -x; } template <class T> inline void NEGATE( T &x ) { x = -x; }
/// # of elements in an array /// # of elements in an array
#define DIM( x ) unsigned( sizeof(x) / sizeof( (x)[0] ) ) // not size_t #define DIM( x ) unsigned( sizeof(x) / sizeof( (x)[0] ) ) // not size_t
...@@ -67,7 +67,7 @@ template<class T> inline void NEGATE( T &x ) { x = -x; } ...@@ -67,7 +67,7 @@ template<class T> inline void NEGATE( T &x ) { x = -x; }
// std::swap works only with arguments of the same type (which is saner); // std::swap works only with arguments of the same type (which is saner);
// here the compiler will figure out what to do (I hope to get rid of // here the compiler will figure out what to do (I hope to get rid of
// this soon or late) // this soon or late)
template<class T, class T2> inline void EXCHG( T& a, T2& b ) template <class T, class T2> inline void EXCHG( T& a, T2& b )
{ {
T temp = a; T temp = a;
a = b; a = b;
......
...@@ -39,7 +39,8 @@ template <> ...@@ -39,7 +39,8 @@ template <>
class BOX2_TRAITS<VECTOR2I> class BOX2_TRAITS<VECTOR2I>
{ {
public: public:
enum { enum
{
c_max_size = INT_MAX - 1, c_max_size = INT_MAX - 1,
c_min_coord_value = INT_MIN / 2 + 1 c_min_coord_value = INT_MIN / 2 + 1
}; };
...@@ -61,7 +62,7 @@ public: ...@@ -61,7 +62,7 @@ public:
typedef typename Vec::coord_type coord_type; typedef typename Vec::coord_type coord_type;
typedef typename Vec::extended_type ecoord_type; typedef typename Vec::extended_type ecoord_type;
BOX2() { }; BOX2() {};
BOX2( const Vec& aPos, const Vec& aSize ) : BOX2( const Vec& aPos, const Vec& aSize ) :
m_Pos( aPos ), m_Pos( aPos ),
...@@ -91,6 +92,7 @@ public: ...@@ -91,6 +92,7 @@ public:
void Compute( const Container& aPointList ) void Compute( const Container& aPointList )
{ {
Vec vmin, vmax; Vec vmin, vmax;
typename Container::const_iterator i; typename Container::const_iterator i;
if( !aPointList.size() ) if( !aPointList.size() )
...@@ -164,7 +166,7 @@ public: ...@@ -164,7 +166,7 @@ public:
rel_pos.y += size.y; rel_pos.y += size.y;
} }
return (rel_pos.x >= 0) && (rel_pos.y >= 0) && ( rel_pos.y <= size.y) && ( rel_pos.x <= size.x); return ( rel_pos.x >= 0 ) && ( rel_pos.y >= 0 ) && ( rel_pos.y <= size.y) && ( rel_pos.x <= size.x);
} }
/** /**
...@@ -418,8 +420,8 @@ public: ...@@ -418,8 +420,8 @@ public:
{ {
ecoord_type x2 = m_Pos.x + m_Size.x; ecoord_type x2 = m_Pos.x + m_Size.x;
ecoord_type y2 = m_Pos.y + m_Size.y; ecoord_type y2 = m_Pos.y + m_Size.y;
ecoord_type xdiff = std::max( aP.x < m_Pos.x ? m_Pos.x - aP.x : m_Pos.x - x2, (ecoord_type)0 ); ecoord_type xdiff = std::max( aP.x < m_Pos.x ? m_Pos.x - aP.x : m_Pos.x - x2, (ecoord_type) 0 );
ecoord_type ydiff = std::max( aP.y < m_Pos.y ? m_Pos.y - aP.y : m_Pos.y - y2, (ecoord_type)0 ); ecoord_type ydiff = std::max( aP.y < m_Pos.y ? m_Pos.y - aP.y : m_Pos.y - y2, (ecoord_type) 0 );
return xdiff * xdiff + ydiff * ydiff; return xdiff * xdiff + ydiff * ydiff;
} }
......
...@@ -34,14 +34,18 @@ ...@@ -34,14 +34,18 @@
* Scales a number (value) by rational (numerator/denominator). Numerator must be <= denominator. * Scales a number (value) by rational (numerator/denominator). Numerator must be <= denominator.
*/ */
template<typename T> T rescale( T numerator, T value, T denominator ) template <typename T>
T rescale( T numerator, T value, T denominator )
{ {
return numerator * value / denominator; return numerator * value / denominator;
} }
// explicit specializations for integer types, taking care of overflow. // explicit specializations for integer types, taking care of overflow.
template<> int rescale( int numerator, int value, int denominator ); template <>
template<> int64_t rescale( int64_t numerator, int64_t value, int64_t denominator ); int rescale( int numerator, int value, int denominator );
template <>
int64_t rescale( int64_t numerator, int64_t value, int64_t denominator );
#endif // __MATH_UTIL_H #endif // __MATH_UTIL_H
...@@ -51,8 +51,11 @@ ...@@ -51,8 +51,11 @@
*/ */
// Forward declaration for template friends // Forward declaration for template friends
template <class T> class MATRIX3x3; template <class T>
template <class T> std::ostream& operator<<( std::ostream& stream, const MATRIX3x3<T>& matrix ); class MATRIX3x3;
template <class T>
std::ostream& operator<<( std::ostream& stream, const MATRIX3x3<T>& matrix );
template <class T> template <class T>
class MATRIX3x3 class MATRIX3x3
...@@ -164,20 +167,21 @@ public: ...@@ -164,20 +167,21 @@ public:
// Operators // Operators
//! @brief Matrix multiplication //! @brief Matrix multiplication
template<class T> MATRIX3x3<T> const operator*( MATRIX3x3<T> const& a, MATRIX3x3<T> const& b ); template <class T> MATRIX3x3<T> const operator*( MATRIX3x3<T> const& a, MATRIX3x3<T> const& b );
//! @brief Multiplication with a 2D vector, the 3rd z-component is assumed to be 1 //! @brief Multiplication with a 2D vector, the 3rd z-component is assumed to be 1
template<class T> VECTOR2<T> const operator*( MATRIX3x3<T> const& a, VECTOR2<T> const& b ); template <class T> VECTOR2<T> const operator*( MATRIX3x3<T> const& a, VECTOR2<T> const& b );
//! @brief Multiplication with a scalar //! @brief Multiplication with a scalar
template<class T, class S> MATRIX3x3<T> const operator*( MATRIX3x3<T> const& a, T scalar ); template <class T, class S> MATRIX3x3<T> const operator*( MATRIX3x3<T> const& a, T scalar );
template<class T, class S> MATRIX3x3<T> const operator*( T scalar, MATRIX3x3<T> const& matrix ); template <class T, class S> MATRIX3x3<T> const operator*( T scalar, MATRIX3x3<T> const& matrix );
// ---------------------- // ----------------------
// --- Implementation --- // --- Implementation ---
// ---------------------- // ----------------------
template<class T> MATRIX3x3<T>::MATRIX3x3() template <class T>
MATRIX3x3<T>::MATRIX3x3()
{ {
for( int j = 0; j < 3; j++ ) for( int j = 0; j < 3; j++ )
{ {
...@@ -189,8 +193,8 @@ template<class T> MATRIX3x3<T>::MATRIX3x3() ...@@ -189,8 +193,8 @@ template<class T> MATRIX3x3<T>::MATRIX3x3()
} }
template<class T> MATRIX3x3<T>::MATRIX3x3( T a00, T a01, T a02, T a10, T a11, T a12, T a20, T a21, template <class T>
T a22 ) MATRIX3x3<T>::MATRIX3x3( T a00, T a01, T a02, T a10, T a11, T a12, T a20, T a21, T a22 )
{ {
m_data[0][0] = a00; m_data[0][0] = a00;
m_data[0][1] = a01; m_data[0][1] = a01;
...@@ -206,7 +210,8 @@ template<class T> MATRIX3x3<T>::MATRIX3x3( T a00, T a01, T a02, T a10, T a11, T ...@@ -206,7 +210,8 @@ template<class T> MATRIX3x3<T>::MATRIX3x3( T a00, T a01, T a02, T a10, T a11, T
} }
template<class T> void MATRIX3x3<T>::SetIdentity( void ) template <class T>
void MATRIX3x3<T>::SetIdentity( void )
{ {
for( int j = 0; j < 3; j++ ) for( int j = 0; j < 3; j++ )
{ {
...@@ -221,14 +226,16 @@ template<class T> void MATRIX3x3<T>::SetIdentity( void ) ...@@ -221,14 +226,16 @@ template<class T> void MATRIX3x3<T>::SetIdentity( void )
} }
template<class T> void MATRIX3x3<T>::SetTranslation( VECTOR2<T> aTranslation ) template <class T>
void MATRIX3x3<T>::SetTranslation( VECTOR2<T> aTranslation )
{ {
m_data[0][2] = aTranslation.x; m_data[0][2] = aTranslation.x;
m_data[1][2] = aTranslation.y; m_data[1][2] = aTranslation.y;
} }
template<class T> VECTOR2<T> MATRIX3x3<T>::GetTranslation( void ) const template <class T>
VECTOR2<T> MATRIX3x3<T>::GetTranslation( void ) const
{ {
VECTOR2<T> result; VECTOR2<T> result;
result.x = m_data[0][2]; result.x = m_data[0][2];
...@@ -237,7 +244,8 @@ template<class T> VECTOR2<T> MATRIX3x3<T>::GetTranslation( void ) const ...@@ -237,7 +244,8 @@ template<class T> VECTOR2<T> MATRIX3x3<T>::GetTranslation( void ) const
} }
template<class T> void MATRIX3x3<T>::SetRotation( T aAngle ) template <class T>
void MATRIX3x3<T>::SetRotation( T aAngle )
{ {
T cosValue = cos( aAngle ); T cosValue = cos( aAngle );
T sinValue = sin( aAngle ); T sinValue = sin( aAngle );
...@@ -248,21 +256,24 @@ template<class T> void MATRIX3x3<T>::SetRotation( T aAngle ) ...@@ -248,21 +256,24 @@ template<class T> void MATRIX3x3<T>::SetRotation( T aAngle )
} }
template<class T> void MATRIX3x3<T>::SetScale( VECTOR2<T> aScale ) template <class T>
void MATRIX3x3<T>::SetScale( VECTOR2<T> aScale )
{ {
m_data[0][0] = aScale.x; m_data[0][0] = aScale.x;
m_data[1][1] = aScale.y; m_data[1][1] = aScale.y;
} }
template<class T> VECTOR2<T> MATRIX3x3<T>::GetScale( void ) const template <class T>
VECTOR2<T> MATRIX3x3<T>::GetScale( void ) const
{ {
VECTOR2<T> result( m_data[0][0], m_data[1][1] ); VECTOR2<T> result( m_data[0][0], m_data[1][1] );
return result; return result;
} }
template<class T> MATRIX3x3<T> const operator*( MATRIX3x3<T> const& a, MATRIX3x3<T> const& b ) template <class T>
MATRIX3x3<T> const operator*( MATRIX3x3<T> const& a, MATRIX3x3<T> const& b )
{ {
MATRIX3x3<T> result; MATRIX3x3<T> result;
...@@ -279,7 +290,8 @@ template<class T> MATRIX3x3<T> const operator*( MATRIX3x3<T> const& a, MATRIX3x3 ...@@ -279,7 +290,8 @@ template<class T> MATRIX3x3<T> const operator*( MATRIX3x3<T> const& a, MATRIX3x3
} }
template<class T> VECTOR2<T> const operator*( MATRIX3x3<T> const& matrix, template <class T>
VECTOR2<T> const operator*( MATRIX3x3<T> const& matrix,
VECTOR2<T> const& vector ) VECTOR2<T> const& vector )
{ {
VECTOR2<T> result( 0, 0 ); VECTOR2<T> result( 0, 0 );
...@@ -292,7 +304,8 @@ template<class T> VECTOR2<T> const operator*( MATRIX3x3<T> const& matrix, ...@@ -292,7 +304,8 @@ template<class T> VECTOR2<T> const operator*( MATRIX3x3<T> const& matrix,
} }
template<class T> T MATRIX3x3<T>::Determinant( void ) const template <class T>
T MATRIX3x3<T>::Determinant( void ) const
{ {
return m_data[0][0] * ( m_data[1][1] * m_data[2][2] - m_data[1][2] * m_data[2][1] ) return m_data[0][0] * ( m_data[1][1] * m_data[2][2] - m_data[1][2] * m_data[2][1] )
- m_data[0][1] * ( m_data[1][0] * m_data[2][2] - m_data[1][2] * m_data[2][0] ) - m_data[0][1] * ( m_data[1][0] * m_data[2][2] - m_data[1][2] * m_data[2][0] )
...@@ -300,7 +313,8 @@ template<class T> T MATRIX3x3<T>::Determinant( void ) const ...@@ -300,7 +313,8 @@ template<class T> T MATRIX3x3<T>::Determinant( void ) const
} }
template<class T, class S> MATRIX3x3<T> const operator*( MATRIX3x3<T> const& matrix, S scalar ) template <class T, class S>
MATRIX3x3<T> const operator*( MATRIX3x3<T> const& matrix, S scalar )
{ {
MATRIX3x3<T> result; MATRIX3x3<T> result;
...@@ -316,13 +330,15 @@ template<class T, class S> MATRIX3x3<T> const operator*( MATRIX3x3<T> const& mat ...@@ -316,13 +330,15 @@ template<class T, class S> MATRIX3x3<T> const operator*( MATRIX3x3<T> const& mat
} }
template<class T, class S> MATRIX3x3<T> const operator*( S scalar, MATRIX3x3<T> const& matrix ) template <class T, class S>
MATRIX3x3<T> const operator*( S scalar, MATRIX3x3<T> const& matrix )
{ {
return matrix * scalar; return matrix * scalar;
} }
template<class T> MATRIX3x3<T> MATRIX3x3<T>::Inverse( void ) const template <class T>
MATRIX3x3<T> MATRIX3x3<T>::Inverse() const
{ {
MATRIX3x3<T> result; MATRIX3x3<T> result;
...@@ -342,7 +358,8 @@ template<class T> MATRIX3x3<T> MATRIX3x3<T>::Inverse( void ) const ...@@ -342,7 +358,8 @@ template<class T> MATRIX3x3<T> MATRIX3x3<T>::Inverse( void ) const
} }
template<class T> MATRIX3x3<T> MATRIX3x3<T>::Transpose( void ) const template <class T>
MATRIX3x3<T> MATRIX3x3<T>::Transpose() const
{ {
MATRIX3x3<T> result; MATRIX3x3<T> result;
...@@ -358,7 +375,8 @@ template<class T> MATRIX3x3<T> MATRIX3x3<T>::Transpose( void ) const ...@@ -358,7 +375,8 @@ template<class T> MATRIX3x3<T> MATRIX3x3<T>::Transpose( void ) const
} }
template<class T> std::ostream& operator<<( std::ostream& aStream, const MATRIX3x3<T>& aMatrix ) template <class T>
std::ostream& operator<<( std::ostream& aStream, const MATRIX3x3<T>& aMatrix )
{ {
for( int i = 0; i < 3; i++ ) for( int i = 0; i < 3; i++ )
{ {
...@@ -377,6 +395,7 @@ template<class T> std::ostream& operator<<( std::ostream& aStream, const MATRIX3 ...@@ -377,6 +395,7 @@ template<class T> std::ostream& operator<<( std::ostream& aStream, const MATRIX3
return aStream; return aStream;
} }
/* Default specializations */ /* Default specializations */
typedef MATRIX3x3<double> MATRIX3x3D; typedef MATRIX3x3<double> MATRIX3x3D;
......
...@@ -285,14 +285,14 @@ T VECTOR2<T>::EuclideanNorm() const ...@@ -285,14 +285,14 @@ T VECTOR2<T>::EuclideanNorm() const
return sqrt( (extended_type) x * x + (extended_type) y * y ); return sqrt( (extended_type) x * x + (extended_type) y * y );
} }
template <class T> template <class T>
typename VECTOR2<T>::extended_type VECTOR2<T>::SquaredEuclideanNorm() const typename VECTOR2<T>::extended_type VECTOR2<T>::SquaredEuclideanNorm() const
{ {
return (extended_type)x * x + (extended_type) y * y ; return (extended_type) x * x + (extended_type) y * y;
} }
template <class T> template <class T>
double VECTOR2<T>::Angle() const double VECTOR2<T>::Angle() const
{ {
...@@ -365,15 +365,15 @@ VECTOR2<T> VECTOR2<T>::Rotate( double aAngle ) const ...@@ -365,15 +365,15 @@ VECTOR2<T> VECTOR2<T>::Rotate( double aAngle ) const
template <class T> template <class T>
VECTOR2<T> VECTOR2<T>::Resize( T aNewLength ) const VECTOR2<T> VECTOR2<T>::Resize( T aNewLength ) const
{ {
if(x == 0 && y == 0) if( x == 0 && y == 0 )
return VECTOR2<T> (0, 0); return VECTOR2<T> ( 0, 0 );
extended_type l_sq_current = (extended_type)this->x * this->x + (extended_type)this->y * this->y; extended_type l_sq_current = (extended_type) x * x + (extended_type) y * y;
extended_type l_sq_new = (extended_type) aNewLength * aNewLength; extended_type l_sq_new = (extended_type) aNewLength * aNewLength;
return VECTOR2<T> ( return VECTOR2<T> (
(this->x < 0 ? -1 : 1 ) * sqrt(rescale(l_sq_new, (extended_type) x * x, l_sq_current)), ( x < 0 ? -1 : 1 ) * sqrt( rescale( l_sq_new, (extended_type) x * x, l_sq_current ) ),
(this->y < 0 ? -1 : 1 ) * sqrt(rescale(l_sq_new, (extended_type) y * y, l_sq_current))); ( y < 0 ? -1 : 1 ) * sqrt( rescale( l_sq_new, (extended_type) y * y, l_sq_current ) ) );
} }
......
...@@ -38,7 +38,7 @@ ...@@ -38,7 +38,7 @@
class EDA_ITEM; class EDA_ITEM;
class COLORS_DESIGN_SETTINGS; class COLORS_DESIGN_SETTINGS;
namespace KiGfx namespace KIGFX
{ {
class GAL; class GAL;
class VIEW_ITEM; class VIEW_ITEM;
...@@ -265,6 +265,6 @@ protected: ...@@ -265,6 +265,6 @@ protected:
/// Color of brightened item frame /// Color of brightened item frame
COLOR4D m_brightenedColor; COLOR4D m_brightenedColor;
}; };
} // namespace KiGfx } // namespace KIGFX
#endif /* __CLASS_PAINTER_H */ #endif /* __CLASS_PAINTER_H */
...@@ -36,9 +36,9 @@ ...@@ -36,9 +36,9 @@
// RTree.h // RTree.h
// //
#define RTREE_TEMPLATE template<class DATATYPE, class ELEMTYPE, int NUMDIMS, \ #define RTREE_TEMPLATE template <class DATATYPE, class ELEMTYPE, int NUMDIMS, \
class ELEMTYPEREAL, int TMAXNODES, int TMINNODES> class ELEMTYPEREAL, int TMAXNODES, int TMINNODES>
#define RTREE_SEARCH_TEMPLATE template<class DATATYPE, class ELEMTYPE, int NUMDIMS, \ #define RTREE_SEARCH_TEMPLATE template <class DATATYPE, class ELEMTYPE, int NUMDIMS, \
class ELEMTYPEREAL, int TMAXNODES, int TMINNODES, class VISITOR> class ELEMTYPEREAL, int TMAXNODES, int TMINNODES, class VISITOR>
#define RTREE_QUAL RTree<DATATYPE, ELEMTYPE, NUMDIMS, ELEMTYPEREAL, TMAXNODES, \ #define RTREE_QUAL RTree<DATATYPE, ELEMTYPE, NUMDIMS, ELEMTYPEREAL, TMAXNODES, \
TMINNODES> TMINNODES>
......
...@@ -76,8 +76,8 @@ public: ...@@ -76,8 +76,8 @@ public:
bool RunAction( const std::string& aActionName ) const; bool RunAction( const std::string& aActionName ) const;
// TODO to be considered // TODO to be considered
//bool RunAction( int aActionId ) const; // bool RunAction( int aActionId ) const;
//bool RunAction( TOOL_ACTION* aAction ) const; // bool RunAction( TOOL_ACTION* aAction ) const;
/** /**
* Function RunHotKey() * Function RunHotKey()
......
...@@ -32,27 +32,27 @@ ...@@ -32,27 +32,27 @@
#include "delegate.h" #include "delegate.h"
/** /**
Class COROUNTINE. * Class COROUNTINE.
Implements a coroutine. Wikipedia has a good explanation: * Implements a coroutine. Wikipedia has a good explanation:
*
"Coroutines are computer program components that generalize subroutines to * "Coroutines are computer program components that generalize subroutines to
allow multiple entry points for suspending and resuming execution at certain locations. * allow multiple entry points for suspending and resuming execution at certain locations.
Coroutines are well-suited for implementing more familiar program components such as cooperative * Coroutines are well-suited for implementing more familiar program components such as cooperative
tasks, exceptions, event loop, iterators, infinite lists and pipes." * tasks, exceptions, event loop, iterators, infinite lists and pipes."
*
In other words, a coroutine can be considered a lightweight thread - which can be * In other words, a coroutine can be considered a lightweight thread - which can be
preempted only when it deliberately yields the control to the caller. This way, * preempted only when it deliberately yields the control to the caller. This way,
we avoid concurrency problems such as locking / race conditions. * we avoid concurrency problems such as locking / race conditions.
*
Uses boost::context library to do the actual context switching. * Uses boost::context library to do the actual context switching.
*
This particular version takes a DELEGATE as an entry point, so it can invoke * This particular version takes a DELEGATE as an entry point, so it can invoke
methods within a given object as separate coroutines. * methods within a given object as separate coroutines.
*
See coroutine_example.cpp for sample code. * See coroutine_example.cpp for sample code.
*/ */
template<class ReturnType, class ArgType> template <class ReturnType, class ArgType>
class COROUTINE class COROUTINE
{ {
public: public:
...@@ -67,8 +67,8 @@ public: ...@@ -67,8 +67,8 @@ public:
* Constructor * Constructor
* Creates a coroutine from a member method of an object * Creates a coroutine from a member method of an object
*/ */
template<class T> template <class T>
COROUTINE( T* object, ReturnType (T::*ptr)( ArgType ) ) : COROUTINE( T* object, ReturnType(T::* ptr)( ArgType ) ) :
m_func( object, ptr ), m_saved( NULL ), m_stack( NULL ), m_stackSize( c_defaultStackSize ) m_func( object, ptr ), m_saved( NULL ), m_stack( NULL ), m_stackSize( c_defaultStackSize )
{ {
} }
...@@ -85,6 +85,7 @@ public: ...@@ -85,6 +85,7 @@ public:
{ {
if( m_saved ) if( m_saved )
delete m_saved; delete m_saved;
if( m_stack ) if( m_stack )
free( m_stack ); free( m_stack );
} }
...@@ -114,7 +115,7 @@ public: ...@@ -114,7 +115,7 @@ public:
} }
/** /**
<F11>* Function SetEntry() * <F11>* Function SetEntry()
* *
* Defines the entry point for the coroutine, if not set in the constructor. * Defines the entry point for the coroutine, if not set in the constructor.
*/ */
...@@ -135,7 +136,7 @@ public: ...@@ -135,7 +136,7 @@ public:
m_stack = malloc( c_defaultStackSize ); m_stack = malloc( c_defaultStackSize );
// align to 16 bytes // align to 16 bytes
void *sp = (void *) ( ( ( (ptrdiff_t) m_stack ) + m_stackSize - 0xf ) & ( ~0x0f ) ); void* sp = (void*) ( ( ( (ptrdiff_t) m_stack ) + m_stackSize - 0xf ) & ( ~0x0f ) );
m_args = &args; m_args = &args;
m_self = boost::context::make_fcontext( sp, m_stackSize, callerStub ); m_self = boost::context::make_fcontext( sp, m_stackSize, callerStub );
...@@ -157,6 +158,7 @@ public: ...@@ -157,6 +158,7 @@ public:
bool Resume() bool Resume()
{ {
boost::context::jump_fcontext( m_saved, m_self, 0 ); boost::context::jump_fcontext( m_saved, m_self, 0 );
return m_running; return m_running;
} }
...@@ -194,15 +196,17 @@ private: ...@@ -194,15 +196,17 @@ private:
cor->m_running = false; cor->m_running = false;
// go back to wherever we came from. // go back to wherever we came from.
boost::context::jump_fcontext( cor->m_self, cor->m_saved, 0 ); //reinterpret_cast<intptr_t>( this )); boost::context::jump_fcontext( cor->m_self, cor->m_saved, 0 ); // reinterpret_cast<intptr_t>( this ));
} }
template <typename T> struct strip_ref template <typename T>
struct strip_ref
{ {
typedef T result; typedef T result;
}; };
template <typename T> struct strip_ref<T&> template <typename T>
struct strip_ref<T&>
{ {
typedef T result; typedef T result;
}; };
......
...@@ -32,59 +32,61 @@ ...@@ -32,59 +32,61 @@
* Check delegate_example.cpp for a coding sample. * Check delegate_example.cpp for a coding sample.
*/ */
template<class ReturnType, class Arg> template <class ReturnType, class Arg>
class DELEGATE { class DELEGATE
public: {
typedef ReturnType (DELEGATE<ReturnType, Arg>::*MemberPointer)( Arg ); public:
typedef ReturnType (DELEGATE<ReturnType, Arg>::* MemberPointer)( Arg );
typedef ReturnType _ReturnType; typedef ReturnType _ReturnType;
typedef Arg _ArgType; typedef Arg _ArgType;
DELEGATE () DELEGATE()
{ {
} }
template<class T> template <class T>
DELEGATE ( T* object, ReturnType (T::*ptr)( Arg ) ) DELEGATE( T* object, ReturnType(T::* ptr)( Arg ) )
{ {
m_ptr = reinterpret_cast<MemberPointer>( ptr ); m_ptr = reinterpret_cast<MemberPointer>( ptr );
m_object = reinterpret_cast<void *>( object ); m_object = reinterpret_cast<void*>( object );
}; };
ReturnType operator()( Arg a ) const ReturnType operator()( Arg a ) const
{ {
DELEGATE<ReturnType, Arg> *casted = reinterpret_cast<DELEGATE<ReturnType, Arg>*>( m_object ); DELEGATE<ReturnType, Arg>* casted = reinterpret_cast<DELEGATE<ReturnType, Arg>*>( m_object );
return (casted->*m_ptr)(a); return (casted->*m_ptr)( a );
} }
private: private:
MemberPointer m_ptr; MemberPointer m_ptr;
void *m_object; void* m_object;
}; };
/** /**
* Class DELEGATE0 * Class DELEGATE0
* Same as DELEGATE, but with no arguments. * Same as DELEGATE, but with no arguments.
*/ */
template<class ReturnType> template <class ReturnType>
class DELEGATE0 { class DELEGATE0
public: {
typedef ReturnType ( DELEGATE0<ReturnType>::*MemberPointer )(); public:
typedef ReturnType ( DELEGATE0<ReturnType>::* MemberPointer )();
typedef ReturnType _ReturnType; typedef ReturnType _ReturnType;
DELEGATE0 () DELEGATE0()
{ {
} }
template<class T> template <class T>
DELEGATE0 ( T* object, ReturnType (T::*ptr)( ) ) DELEGATE0( T* object, ReturnType(T::* ptr)() )
{ {
m_ptr = reinterpret_cast<MemberPointer>( ptr ); m_ptr = reinterpret_cast<MemberPointer>( ptr );
m_object = reinterpret_cast<void*>( object ); m_object = reinterpret_cast<void*>( object );
}; };
ReturnType operator()( ) const ReturnType operator()() const
{ {
DELEGATE0<ReturnType>* casted = reinterpret_cast<DELEGATE0<ReturnType>*>( m_object ); DELEGATE0<ReturnType>* casted = reinterpret_cast<DELEGATE0<ReturnType>*>( m_object );
return ( casted->*m_ptr )(); return ( casted->*m_ptr )();
...@@ -92,7 +94,7 @@ template<class ReturnType> ...@@ -92,7 +94,7 @@ template<class ReturnType>
private: private:
MemberPointer m_ptr; MemberPointer m_ptr;
void *m_object; void* m_object;
}; };
#endif #endif
...@@ -7,39 +7,42 @@ using namespace std; ...@@ -7,39 +7,42 @@ using namespace std;
typedef COROUTINE<int, int> MyCoroutine; typedef COROUTINE<int, int> MyCoroutine;
class MyClass { class MyClass
{
public: public:
int CountTo(int n) int CountTo( int n )
{ {
printf("%s: Coroutine says hi. I will count from 1 to %d and yield each value.\n", __FUNCTION__, n); printf( "%s: Coroutine says hi. I will count from 1 to %d and yield each value.\n",
for(int i = 1; i <= n; i++) __FUNCTION__,
n );
for( int i = 1; i <= n; i++ )
{ {
printf("%s: Yielding %d\n", __FUNCTION__, i); printf( "%s: Yielding %d\n", __FUNCTION__, i );
cofunc.Yield(i); cofunc.Yield( i );
} }
} }
void Run() void Run()
{ {
cofunc = MyCoroutine (this, &MyClass::CountTo); cofunc = MyCoroutine( this, &MyClass::CountTo );
printf("%s: Calling coroutine that will count from 1 to 5.\n", __FUNCTION__); printf( "%s: Calling coroutine that will count from 1 to 5.\n", __FUNCTION__ );
cofunc.Call(5); cofunc.Call( 5 );
while (cofunc.Running())
while( cofunc.Running() )
{ {
printf("%s: Got value: %d\n", __FUNCTION__, cofunc.ReturnValue()); printf( "%s: Got value: %d\n", __FUNCTION__, cofunc.ReturnValue() );
cofunc.Resume(); cofunc.Resume();
} }
printf("%s: Done!\n", __FUNCTION__); printf( "%s: Done!\n", __FUNCTION__ );
} }
MyCoroutine cofunc; MyCoroutine cofunc;
}; };
main() main() {
{
MyClass obj; MyClass obj;
obj.Run(); obj.Run();
......
...@@ -5,12 +5,13 @@ ...@@ -5,12 +5,13 @@
using namespace std; using namespace std;
class MyClass { class MyClass
{
public: public:
int MyMethod(const string &arg) int MyMethod( const string& arg )
{ {
printf("MyClass(this = %p)::MyMethod() called with string '%s', length %d\n", this, arg.c_str(), arg.length()); printf( "MyClass(this = %p)::MyMethod() called with string '%s', length %d\n", this,
arg.c_str(), arg.length() );
return arg.length(); return arg.length();
} }
}; };
...@@ -22,14 +23,14 @@ main() ...@@ -22,14 +23,14 @@ main()
MyClass t1; MyClass t1;
MyClass t2; MyClass t2;
MyDelegate ptr1( &t1, &MyClass::MyMethod );
MyDelegate ptr1 (&t1, &MyClass::MyMethod); MyDelegate ptr2( &t2, &MyClass::MyMethod );
MyDelegate ptr2 (&t2, &MyClass::MyMethod);
int retval1, retval2; int retval1, retval2;
retval1 = ptr1("apples");
retval2 = ptr2("cherries");
printf("Object 1 returned %d, object 2 returned %d\n", retval1, retval2); retval1 = ptr1( "apples" );
retval2 = ptr2( "cherries" );
printf( "Object 1 returned %d, object 2 returned %d\n", retval1, retval2 );
return 0; return 0;
} }
...@@ -205,7 +205,7 @@ private: ...@@ -205,7 +205,7 @@ private:
std::string m_menuDescription; std::string m_menuDescription;
// Icon for menu entry // Icon for menu entry
//KiBitmap m_bitmap; // KiBitmap m_bitmap;
/// Unique ID for fast matching. Assigned by ACTION_MANAGER. /// Unique ID for fast matching. Assigned by ACTION_MANAGER.
int m_id; int m_id;
......
...@@ -34,7 +34,7 @@ ...@@ -34,7 +34,7 @@
class EDA_ITEM; class EDA_ITEM;
class TOOL_MANAGER; class TOOL_MANAGER;
namespace KiGfx namespace KIGFX
{ {
class VIEW; class VIEW;
class VIEW_CONTROLS; class VIEW_CONTROLS;
...@@ -66,7 +66,7 @@ public: ...@@ -66,7 +66,7 @@ public:
m_type( aType ), m_type( aType ),
m_toolId( aId ), m_toolId( aId ),
m_toolName( aName ), m_toolName( aName ),
m_toolMgr( NULL ){}; m_toolMgr( NULL ) {};
virtual ~TOOL_BASE() {}; virtual ~TOOL_BASE() {};
...@@ -130,7 +130,7 @@ protected: ...@@ -130,7 +130,7 @@ protected:
* Returns the instance of VIEW object used in the application. It allows tools to draw. * Returns the instance of VIEW object used in the application. It allows tools to draw.
* @return The instance of VIEW. * @return The instance of VIEW.
*/ */
KiGfx::VIEW* getView() const; KIGFX::VIEW* getView() const;
/** /**
* Function getViewControls() * Function getViewControls()
...@@ -139,14 +139,14 @@ protected: ...@@ -139,14 +139,14 @@ protected:
* read & modify user input and its settings (eg. show cursor, enable snapping to grid, etc.) * read & modify user input and its settings (eg. show cursor, enable snapping to grid, etc.)
* @return The instance of VIEW_CONTROLS. * @return The instance of VIEW_CONTROLS.
*/ */
KiGfx::VIEW_CONTROLS* getViewControls() const; KIGFX::VIEW_CONTROLS* getViewControls() const;
/** /**
* Function getEditFrame() * Function getEditFrame()
* *
* Returns the application window object, casted to requested user type. * Returns the application window object, casted to requested user type.
*/ */
template<typename T> template <typename T>
T* getEditFrame() const T* getEditFrame() const
{ {
return static_cast<T*>( getEditFrameInt() ); return static_cast<T*>( getEditFrameInt() );
...@@ -157,7 +157,7 @@ protected: ...@@ -157,7 +157,7 @@ protected:
* *
* Returns the model object if it matches the requested type. * Returns the model object if it matches the requested type.
*/ */
template<typename T> template <typename T>
T* getModel( KICAD_T modelType ) const T* getModel( KICAD_T modelType ) const
{ {
EDA_ITEM* m = getModelInt(); EDA_ITEM* m = getModelInt();
......
...@@ -32,8 +32,8 @@ ...@@ -32,8 +32,8 @@
class TOOL_MANAGER; class TOOL_MANAGER;
class PCB_BASE_FRAME; class PCB_BASE_FRAME;
namespace KiGfx { namespace KIGFX {
class VIEW; class VIEW;
}; };
/** /**
...@@ -96,22 +96,23 @@ private: ...@@ -96,22 +96,23 @@ private:
bool handleMouseButton( wxEvent& aEvent, int aIndex, bool aMotion ); bool handleMouseButton( wxEvent& aEvent, int aIndex, bool aMotion );
///> Saves the state of key modifiers (Alt, Ctrl and so on). ///> Saves the state of key modifiers (Alt, Ctrl and so on).
template<class EventType> template <class EventType>
static int decodeModifiers( const EventType* aState ) static int decodeModifiers( const EventType* aState )
{ {
int mods = 0; int mods = 0;
if( aState->ControlDown() ) if( aState->ControlDown() )
mods |= MD_ModCtrl; mods |= MD_ModCtrl;
if( aState->AltDown() ) if( aState->AltDown() )
mods |= MD_ModAlt; mods |= MD_ModAlt;
if( aState->ShiftDown() ) if( aState->ShiftDown() )
mods |= MD_ModShift; mods |= MD_ModShift;
return mods; return mods;
} }
///> Stores all the informations regarding a mouse button state. ///> Stores all the informations regarding a mouse button state.
struct ButtonState; struct ButtonState;
...@@ -122,7 +123,7 @@ private: ...@@ -122,7 +123,7 @@ private:
std::vector<ButtonState*> m_buttons; std::vector<ButtonState*> m_buttons;
///> Returns the instance of VIEW, used by the application. ///> Returns the instance of VIEW, used by the application.
KiGfx::VIEW* getView(); KIGFX::VIEW* getView();
///> Instance of tool manager that cooperates with the dispatcher. ///> Instance of tool manager that cooperates with the dispatcher.
TOOL_MANAGER* m_toolMgr; TOOL_MANAGER* m_toolMgr;
......
...@@ -150,7 +150,10 @@ public: ...@@ -150,7 +150,10 @@ public:
m_keyCode( 0 ), m_keyCode( 0 ),
m_modifiers( 0 ) {} m_modifiers( 0 ) {}
TOOL_EVENT( TOOL_EventCategory aCategory, TOOL_Actions aAction, int aExtraParam, TOOL_ActionScope aScope = AS_GLOBAL ) : TOOL_EVENT( TOOL_EventCategory aCategory,
TOOL_Actions aAction,
int aExtraParam,
TOOL_ActionScope aScope = AS_GLOBAL ) :
m_category( aCategory ), m_category( aCategory ),
m_actions( aAction ), m_actions( aAction ),
m_scope( aScope ) m_scope( aScope )
...@@ -163,7 +166,7 @@ public: ...@@ -163,7 +166,7 @@ public:
{ {
m_keyCode = aExtraParam & ~MD_ModifierMask; // Filter out modifiers m_keyCode = aExtraParam & ~MD_ModifierMask; // Filter out modifiers
} }
else if ( aCategory == TC_Command ) else if( aCategory == TC_Command )
{ {
m_commandId = aExtraParam; m_commandId = aExtraParam;
} }
...@@ -244,7 +247,7 @@ public: ...@@ -244,7 +247,7 @@ public:
bool IsMotion() const bool IsMotion() const
{ {
return ( m_actions == TA_MouseMotion ); return m_actions == TA_MouseMotion;
} }
bool IsCancel() const bool IsCancel() const
...@@ -255,7 +258,7 @@ public: ...@@ -255,7 +258,7 @@ public:
///> Returns information about key modifiers state (Ctrl, Alt, etc.) ///> Returns information about key modifiers state (Ctrl, Alt, etc.)
int Modifier( int aMask = MD_ModifierMask ) const int Modifier( int aMask = MD_ModifierMask ) const
{ {
return ( m_modifiers & aMask ); return m_modifiers & aMask;
} }
int KeyCode() const int KeyCode() const
...@@ -273,7 +276,7 @@ public: ...@@ -273,7 +276,7 @@ public:
return m_actions == TA_KeyDown; return m_actions == TA_KeyDown;
} }
void SetMouseDragOrigin( const VECTOR2D &aP ) void SetMouseDragOrigin( const VECTOR2D& aP )
{ {
m_mouseDragOrigin = aP; m_mouseDragOrigin = aP;
} }
...@@ -306,9 +309,10 @@ public: ...@@ -306,9 +309,10 @@ public:
if( m_category == TC_Command ) if( m_category == TC_Command )
{ {
if( m_commandStr && aEvent.m_commandStr ) if( m_commandStr && aEvent.m_commandStr )
return ( *m_commandStr == *aEvent.m_commandStr ); return *m_commandStr == *aEvent.m_commandStr;
if( m_commandId && aEvent.m_commandId ) if( m_commandId && aEvent.m_commandId )
return ( *m_commandId == *aEvent.m_commandId ); return *m_commandId == *aEvent.m_commandId;
} }
return true; return true;
...@@ -365,7 +369,8 @@ typedef boost::optional<TOOL_EVENT> OPT_TOOL_EVENT; ...@@ -365,7 +369,8 @@ typedef boost::optional<TOOL_EVENT> OPT_TOOL_EVENT;
* A list of TOOL_EVENTs, with overloaded || operators allowing for * A list of TOOL_EVENTs, with overloaded || operators allowing for
* concatenating TOOL_EVENTs with little code. * concatenating TOOL_EVENTs with little code.
*/ */
class TOOL_EVENT_LIST { class TOOL_EVENT_LIST
{
public: public:
typedef TOOL_EVENT value_type; typedef TOOL_EVENT value_type;
typedef std::deque<TOOL_EVENT>::iterator iterator; typedef std::deque<TOOL_EVENT>::iterator iterator;
...@@ -388,11 +393,12 @@ public: ...@@ -388,11 +393,12 @@ public:
*/ */
const std::string Format() const; const std::string Format() const;
boost::optional<const TOOL_EVENT&> Matches( const TOOL_EVENT &b ) const boost::optional<const TOOL_EVENT&> Matches( const TOOL_EVENT& b ) const
{ {
for( const_iterator i = m_events.begin(); i != m_events.end(); ++i ) for( const_iterator i = m_events.begin(); i != m_events.end(); ++i )
if ( i->Matches( b ) ) if( i->Matches( b ) )
return *i; return *i;
return boost::optional<const TOOL_EVENT&>(); return boost::optional<const TOOL_EVENT&>();
} }
...@@ -443,7 +449,7 @@ public: ...@@ -443,7 +449,7 @@ public:
for( std::deque<TOOL_EVENT>::const_iterator i = b.m_events.begin(); for( std::deque<TOOL_EVENT>::const_iterator i = b.m_events.begin();
i != b.m_events.end(); ++i ) i != b.m_events.end(); ++i )
{ {
m_events.push_back(*i); m_events.push_back( *i );
} }
return *this; return *this;
...@@ -481,6 +487,7 @@ inline const TOOL_EVENT_LIST operator||( const TOOL_EVENT& a, const TOOL_EVENT& ...@@ -481,6 +487,7 @@ inline const TOOL_EVENT_LIST operator||( const TOOL_EVENT& a, const TOOL_EVENT&
return l; return l;
} }
inline const TOOL_EVENT_LIST operator||( const TOOL_EVENT& a, const TOOL_EVENT_LIST& b ) inline const TOOL_EVENT_LIST operator||( const TOOL_EVENT& a, const TOOL_EVENT_LIST& b )
{ {
TOOL_EVENT_LIST l( b ); TOOL_EVENT_LIST l( b );
......
...@@ -81,8 +81,8 @@ public: ...@@ -81,8 +81,8 @@ public:
* Defines which state (aStateFunc) to go when a certain event arrives (aConditions). * Defines which state (aStateFunc) to go when a certain event arrives (aConditions).
* No conditions means any event. * No conditions means any event.
*/ */
template<class T> template <class T>
void Go( int (T::*aStateFunc)( TOOL_EVENT& ), void Go( int (T::* aStateFunc)( TOOL_EVENT& ),
const TOOL_EVENT_LIST& aConditions = TOOL_EVENT( TC_Any, TA_Any ) ); const TOOL_EVENT_LIST& aConditions = TOOL_EVENT( TC_Any, TA_Any ) );
/** /**
...@@ -91,18 +91,18 @@ public: ...@@ -91,18 +91,18 @@ public:
* Suspends execution of the tool until an event specified in aEventList arrives. * Suspends execution of the tool until an event specified in aEventList arrives.
* No parameters means waiting for any event. * No parameters means waiting for any event.
*/ */
OPT_TOOL_EVENT Wait( const TOOL_EVENT_LIST& aEventList = TOOL_EVENT ( TC_Any, TA_Any ) ); OPT_TOOL_EVENT Wait( const TOOL_EVENT_LIST& aEventList = TOOL_EVENT (TC_Any, TA_Any) );
/** functions below are not yet implemented - their interface may change */ /** functions below are not yet implemented - their interface may change */
/*template<class Parameters, class ReturnValue> /*template <class Parameters, class ReturnValue>
bool InvokeTool( const std::string& aToolName, const Parameters& parameters, bool InvokeTool( const std::string& aToolName, const Parameters& parameters,
ReturnValue& returnValue ); ReturnValue& returnValue );
template<class Parameters, class ReturnValue> template <class Parameters, class ReturnValue>
bool InvokeWindow( const std::string& aWindowName, const Parameters& parameters, bool InvokeWindow( const std::string& aWindowName, const Parameters& parameters,
ReturnValue& returnValue ); ReturnValue& returnValue );
template<class T> template <class T>
void Yield( const T& returnValue );*/ void Yield( const T& returnValue );*/
protected: protected:
...@@ -121,11 +121,12 @@ private: ...@@ -121,11 +121,12 @@ private:
}; };
// hide TOOL_MANAGER implementation // hide TOOL_MANAGER implementation
template<class T> template <class T>
void TOOL_INTERACTIVE::Go( int (T::*aStateFunc)( TOOL_EVENT& ), void TOOL_INTERACTIVE::Go( int (T::* aStateFunc)( TOOL_EVENT& ),
const TOOL_EVENT_LIST& aConditions ) const TOOL_EVENT_LIST& aConditions )
{ {
TOOL_STATE_FUNC sptr( static_cast<T*>( this ), aStateFunc ); TOOL_STATE_FUNC sptr( static_cast<T*>( this ), aStateFunc );
goInternal( sptr, aConditions ); goInternal( sptr, aConditions );
} }
......
...@@ -134,16 +134,16 @@ public: ...@@ -134,16 +134,16 @@ public:
* These are made available to the tool. Called by the parent frame (PCB_EDIT_FRAME) * These are made available to the tool. Called by the parent frame (PCB_EDIT_FRAME)
* when the board is set up. * when the board is set up.
*/ */
void SetEnvironment( EDA_ITEM* aModel, KiGfx::VIEW* aView, void SetEnvironment( EDA_ITEM* aModel, KIGFX::VIEW* aView,
KiGfx::VIEW_CONTROLS* aViewControls, wxWindow* aFrame ); KIGFX::VIEW_CONTROLS* aViewControls, wxWindow* aFrame );
/* Accessors for the environment objects (view, model, etc.) */ /* Accessors for the environment objects (view, model, etc.) */
KiGfx::VIEW* GetView() const KIGFX::VIEW* GetView() const
{ {
return m_view; return m_view;
} }
KiGfx::VIEW_CONTROLS* GetViewControls() const KIGFX::VIEW_CONTROLS* GetViewControls() const
{ {
return m_viewControls; return m_viewControls;
} }
...@@ -270,7 +270,7 @@ private: ...@@ -270,7 +270,7 @@ private:
*/ */
bool isRegistered( TOOL_BASE* aTool ) const bool isRegistered( TOOL_BASE* aTool ) const
{ {
return ( m_toolState.count( aTool ) > 0 ); return m_toolState.count( aTool ) > 0;
} }
/** /**
...@@ -298,8 +298,8 @@ private: ...@@ -298,8 +298,8 @@ private:
ACTION_MANAGER* m_actionMgr; ACTION_MANAGER* m_actionMgr;
EDA_ITEM* m_model; EDA_ITEM* m_model;
KiGfx::VIEW* m_view; KIGFX::VIEW* m_view;
KiGfx::VIEW_CONTROLS* m_viewControls; KIGFX::VIEW_CONTROLS* m_viewControls;
wxWindow* m_editFrame; wxWindow* m_editFrame;
/// Flag saying if the currently processed event should be passed to other tools. /// Flag saying if the currently processed event should be passed to other tools.
......
...@@ -32,7 +32,7 @@ ...@@ -32,7 +32,7 @@
#include <math/box2.h> #include <math/box2.h>
#include <gal/definitions.h> #include <gal/definitions.h>
namespace KiGfx namespace KIGFX
{ {
class PAINTER; class PAINTER;
class GAL; class GAL;
...@@ -115,8 +115,8 @@ public: ...@@ -115,8 +115,8 @@ public:
/* /*
* Convenience wrappers for adding multiple items * Convenience wrappers for adding multiple items
* template<class T> void AddItems( const T& aItems ); * template <class T> void AddItems( const T& aItems );
* template<class T> void RemoveItems( const T& aItems ); * template <class T> void RemoveItems( const T& aItems );
*/ */
/** /**
...@@ -442,7 +442,7 @@ public: ...@@ -442,7 +442,7 @@ public:
/// Returns true if the layer is cached /// Returns true if the layer is cached
inline bool IsCached( int aLayer ) const inline bool IsCached( int aLayer ) const
{ {
return ( m_layers.at( aLayer ).target == TARGET_CACHED ); return m_layers.at( aLayer ).target == TARGET_CACHED;
} }
/** /**
...@@ -621,6 +621,6 @@ private: ...@@ -621,6 +621,6 @@ private:
/// Zoom limits /// Zoom limits
VECTOR2D m_scaleLimits; VECTOR2D m_scaleLimits;
}; };
} // namespace KiGfx } // namespace KIGFX
#endif #endif
...@@ -34,7 +34,7 @@ ...@@ -34,7 +34,7 @@
#include <math/box2.h> #include <math/box2.h>
namespace KiGfx namespace KIGFX
{ {
class VIEW; class VIEW;
...@@ -167,6 +167,6 @@ protected: ...@@ -167,6 +167,6 @@ protected:
/// How fast is panning when in auto mode /// How fast is panning when in auto mode
float m_autoPanSpeed; float m_autoPanSpeed;
}; };
} // namespace KiGfx } // namespace KIGFX
#endif #endif
...@@ -36,9 +36,8 @@ ...@@ -36,9 +36,8 @@
#include <view/view_item.h> #include <view/view_item.h>
#include <deque> #include <deque>
namespace KiGfx namespace KIGFX
{ {
class VIEW_GROUP : public VIEW_ITEM class VIEW_GROUP : public VIEW_ITEM
{ {
public: public:
...@@ -146,7 +145,7 @@ public: ...@@ -146,7 +145,7 @@ public:
* *
* @return Pointer to the VIEW instance. * @return Pointer to the VIEW instance.
*/ */
KiGfx::VIEW* GetView() const KIGFX::VIEW* GetView() const
{ {
return m_view; return m_view;
} }
...@@ -186,6 +185,6 @@ private: ...@@ -186,6 +185,6 @@ private:
/// Container for storing VIEW_ITEMs /// Container for storing VIEW_ITEMs
std::set<VIEW_ITEM*> m_items; std::set<VIEW_ITEM*> m_items;
}; };
} // namespace KiGfx } // namespace KIGFX
#endif // VIEW_GROUP_H_ #endif // VIEW_GROUP_H_
...@@ -40,7 +40,8 @@ ...@@ -40,7 +40,8 @@
* Enum KICAD_T * Enum KICAD_T
* is the set of class identification values, stored in EDA_ITEM::m_StructType * is the set of class identification values, stored in EDA_ITEM::m_StructType
*/ */
enum KICAD_T { enum KICAD_T
{
NOT_USED = -1, ///< the 3d code uses this value NOT_USED = -1, ///< the 3d code uses this value
EOT = 0, ///< search types array terminator (End Of Types) EOT = 0, ///< search types array terminator (End Of Types)
...@@ -134,7 +135,7 @@ enum KICAD_T { ...@@ -134,7 +135,7 @@ enum KICAD_T {
}; };
namespace KiGfx namespace KIGFX
{ {
// Forward declarations // Forward declarations
class GAL; class GAL;
...@@ -347,7 +348,7 @@ protected: ...@@ -347,7 +348,7 @@ protected:
*/ */
inline virtual bool storesGroups() const inline virtual bool storesGroups() const
{ {
return ( m_groupsSize > 0 ); return m_groupsSize > 0;
} }
/// Stores layer numbers used by the item. /// Stores layer numbers used by the item.
...@@ -367,8 +368,7 @@ protected: ...@@ -367,8 +368,7 @@ protected:
for( int i = 0; i < aCount; ++i ) for( int i = 0; i < aCount; ++i )
m_layers.set( aLayers[i] ); m_layers.set( aLayers[i] );
} }
}; };
} // namespace KiGfx } // namespace KIGFX
#endif #endif
...@@ -29,7 +29,7 @@ ...@@ -29,7 +29,7 @@
#include <rtree.h> #include <rtree.h>
namespace KiGfx namespace KIGFX
{ {
typedef RTree<VIEW_ITEM*, int, 2, float> VIEW_RTREE_BASE; typedef RTree<VIEW_ITEM*, int, 2, float> VIEW_RTREE_BASE;
...@@ -88,6 +88,6 @@ public: ...@@ -88,6 +88,6 @@ public:
private: private:
}; };
} // namespace KiGfx } // namespace KIGFX
#endif #endif
...@@ -38,7 +38,7 @@ ...@@ -38,7 +38,7 @@
class EDA_DRAW_PANEL_GAL; class EDA_DRAW_PANEL_GAL;
namespace KiGfx namespace KIGFX
{ {
/** /**
* Class WX_VIEW_CONTROLS * Class WX_VIEW_CONTROLS
...@@ -74,6 +74,7 @@ public: ...@@ -74,6 +74,7 @@ public:
void SetAutoPan( bool aEnabled ) void SetAutoPan( bool aEnabled )
{ {
m_autoPanEnabled = aEnabled; m_autoPanEnabled = aEnabled;
if( m_state == AUTO_PANNING ) if( m_state == AUTO_PANNING )
m_state = IDLE; m_state = IDLE;
} }
...@@ -90,7 +91,8 @@ public: ...@@ -90,7 +91,8 @@ public:
private: private:
/// Possible states for WX_VIEW_CONTROLS /// Possible states for WX_VIEW_CONTROLS
enum State { enum State
{
IDLE = 1, /// Nothing is happening IDLE = 1, /// Nothing is happening
DRAG_PANNING, /// Panning with mouse button pressed DRAG_PANNING, /// Panning with mouse button pressed
AUTO_PANNING, /// Panning on approaching borders of the frame AUTO_PANNING, /// Panning on approaching borders of the frame
...@@ -127,6 +129,6 @@ private: ...@@ -127,6 +129,6 @@ private:
/// Timer repsonsible for handling autopanning /// Timer repsonsible for handling autopanning
wxTimer m_panTimer; wxTimer m_panTimer;
}; };
} // namespace KiGfx } // namespace KIGFX
#endif #endif
...@@ -40,7 +40,7 @@ class WS_DRAW_ITEM_RECT; ...@@ -40,7 +40,7 @@ class WS_DRAW_ITEM_RECT;
class WS_DRAW_ITEM_POLYGON; class WS_DRAW_ITEM_POLYGON;
class WS_DRAW_ITEM_TEXT; class WS_DRAW_ITEM_TEXT;
namespace KiGfx namespace KIGFX
{ {
class GAL; class GAL;
......
...@@ -172,7 +172,7 @@ void PCB_BASE_FRAME::SetBoard( BOARD* aBoard ) ...@@ -172,7 +172,7 @@ void PCB_BASE_FRAME::SetBoard( BOARD* aBoard )
if( m_galCanvas ) if( m_galCanvas )
{ {
KiGfx::VIEW* view = m_galCanvas->GetView(); KIGFX::VIEW* view = m_galCanvas->GetView();
ViewReloadBoard( m_Pcb ); ViewReloadBoard( m_Pcb );
...@@ -185,7 +185,7 @@ void PCB_BASE_FRAME::SetBoard( BOARD* aBoard ) ...@@ -185,7 +185,7 @@ void PCB_BASE_FRAME::SetBoard( BOARD* aBoard )
void PCB_BASE_FRAME::ViewReloadBoard( const BOARD* aBoard ) const void PCB_BASE_FRAME::ViewReloadBoard( const BOARD* aBoard ) const
{ {
KiGfx::VIEW* view = m_galCanvas->GetView(); KIGFX::VIEW* view = m_galCanvas->GetView();
view->Clear(); view->Clear();
// All of PCB drawing elements should be added to the VIEW // All of PCB drawing elements should be added to the VIEW
...@@ -194,7 +194,7 @@ void PCB_BASE_FRAME::ViewReloadBoard( const BOARD* aBoard ) const ...@@ -194,7 +194,7 @@ void PCB_BASE_FRAME::ViewReloadBoard( const BOARD* aBoard ) const
// Load zones // Load zones
for( int i = 0; i < aBoard->GetAreaCount(); ++i ) for( int i = 0; i < aBoard->GetAreaCount(); ++i )
{ {
view->Add( (KiGfx::VIEW_ITEM*) ( aBoard->GetArea( i ) ) ); view->Add( (KIGFX::VIEW_ITEM*) ( aBoard->GetArea( i ) ) );
} }
// Load drawings // Load drawings
...@@ -240,7 +240,7 @@ void PCB_BASE_FRAME::ViewReloadBoard( const BOARD* aBoard ) const ...@@ -240,7 +240,7 @@ void PCB_BASE_FRAME::ViewReloadBoard( const BOARD* aBoard ) const
} }
// Add an entry for the worksheet layout // Add an entry for the worksheet layout
KiGfx::WORKSHEET_VIEWITEM* worksheet = new KiGfx::WORKSHEET_VIEWITEM( KIGFX::WORKSHEET_VIEWITEM* worksheet = new KIGFX::WORKSHEET_VIEWITEM(
std::string( aBoard->GetFileName().mb_str() ), std::string( aBoard->GetFileName().mb_str() ),
std::string( GetScreenDesc().mb_str() ), std::string( GetScreenDesc().mb_str() ),
&GetPageSettings(), &GetTitleBlock() ); &GetPageSettings(), &GetTitleBlock() );
...@@ -520,10 +520,10 @@ void PCB_BASE_FRAME::OnTogglePadDrawMode( wxCommandEvent& aEvent ) ...@@ -520,10 +520,10 @@ void PCB_BASE_FRAME::OnTogglePadDrawMode( wxCommandEvent& aEvent )
m_DisplayPadFill = DisplayOpt.DisplayPadFill = !m_DisplayPadFill; m_DisplayPadFill = DisplayOpt.DisplayPadFill = !m_DisplayPadFill;
// Apply new display options to the GAL canvas // Apply new display options to the GAL canvas
KiGfx::PCB_PAINTER* painter = KIGFX::PCB_PAINTER* painter =
static_cast<KiGfx::PCB_PAINTER*> ( m_galCanvas->GetView()->GetPainter() ); static_cast<KIGFX::PCB_PAINTER*> ( m_galCanvas->GetView()->GetPainter() );
KiGfx::PCB_RENDER_SETTINGS* settings = KIGFX::PCB_RENDER_SETTINGS* settings =
static_cast<KiGfx::PCB_RENDER_SETTINGS*> ( painter->GetSettings() ); static_cast<KIGFX::PCB_RENDER_SETTINGS*> ( painter->GetSettings() );
settings->LoadDisplayOptions( DisplayOpt ); settings->LoadDisplayOptions( DisplayOpt );
m_galCanvas->GetView()->RecacheAllItems( true ); m_galCanvas->GetView()->RecacheAllItems( true );
...@@ -856,13 +856,13 @@ void PCB_BASE_FRAME::LoadSettings() ...@@ -856,13 +856,13 @@ void PCB_BASE_FRAME::LoadSettings()
m_DisplayModText = FILLED; m_DisplayModText = FILLED;
// Apply display settings for GAL // Apply display settings for GAL
KiGfx::VIEW* view = m_galCanvas->GetView(); KIGFX::VIEW* view = m_galCanvas->GetView();
// Set rendering order and properties of layers // Set rendering order and properties of layers
for( LAYER_NUM i = 0; (unsigned) i < sizeof(GAL_LAYER_ORDER) / sizeof(LAYER_NUM); ++i ) for( LAYER_NUM i = 0; (unsigned) i < sizeof(GAL_LAYER_ORDER) / sizeof(LAYER_NUM); ++i )
{ {
LAYER_NUM layer = GAL_LAYER_ORDER[i]; LAYER_NUM layer = GAL_LAYER_ORDER[i];
wxASSERT( layer < KiGfx::VIEW::VIEW_MAX_LAYERS ); wxASSERT( layer < KIGFX::VIEW::VIEW_MAX_LAYERS );
view->SetLayerOrder( layer, i ); view->SetLayerOrder( layer, i );
...@@ -870,13 +870,13 @@ void PCB_BASE_FRAME::LoadSettings() ...@@ -870,13 +870,13 @@ void PCB_BASE_FRAME::LoadSettings()
{ {
// Copper layers are required for netname layers // Copper layers are required for netname layers
view->SetRequired( GetNetnameLayer( layer ), layer ); view->SetRequired( GetNetnameLayer( layer ), layer );
view->SetLayerTarget( layer, KiGfx::TARGET_CACHED ); view->SetLayerTarget( layer, KIGFX::TARGET_CACHED );
} }
else if( IsNetnameLayer( layer ) ) else if( IsNetnameLayer( layer ) )
{ {
// Netnames are drawn only when scale is sufficient (level of details) // Netnames are drawn only when scale is sufficient (level of details)
// so there is no point in caching them // so there is no point in caching them
view->SetLayerTarget( layer, KiGfx::TARGET_NONCACHED ); view->SetLayerTarget( layer, KIGFX::TARGET_NONCACHED );
} }
} }
...@@ -895,12 +895,12 @@ void PCB_BASE_FRAME::LoadSettings() ...@@ -895,12 +895,12 @@ void PCB_BASE_FRAME::LoadSettings()
view->SetRequired( SOLDERPASTE_N_BACK, ITEM_GAL_LAYER( PAD_BK_VISIBLE ) ); view->SetRequired( SOLDERPASTE_N_BACK, ITEM_GAL_LAYER( PAD_BK_VISIBLE ) );
view->SetRequired( SOLDERMASK_N_BACK, ITEM_GAL_LAYER( PAD_BK_VISIBLE ) ); view->SetRequired( SOLDERMASK_N_BACK, ITEM_GAL_LAYER( PAD_BK_VISIBLE ) );
view->SetLayerTarget( ITEM_GAL_LAYER( GP_OVERLAY ), KiGfx::TARGET_OVERLAY ); view->SetLayerTarget( ITEM_GAL_LAYER( GP_OVERLAY ), KIGFX::TARGET_OVERLAY );
// Apply layer coloring scheme & display options // Apply layer coloring scheme & display options
if( view->GetPainter() ) if( view->GetPainter() )
{ {
KiGfx::PCB_RENDER_SETTINGS* settings = new KiGfx::PCB_RENDER_SETTINGS(); KIGFX::PCB_RENDER_SETTINGS* settings = new KIGFX::PCB_RENDER_SETTINGS();
// Load layers' colors from PCB data // Load layers' colors from PCB data
settings->ImportLegacyColors( m_Pcb->GetColorsSettings() ); settings->ImportLegacyColors( m_Pcb->GetColorsSettings() );
......
...@@ -396,7 +396,7 @@ void PCB_LAYER_WIDGET::OnLayerVisible( LAYER_NUM aLayer, bool isVisible, bool is ...@@ -396,7 +396,7 @@ void PCB_LAYER_WIDGET::OnLayerVisible( LAYER_NUM aLayer, bool isVisible, bool is
EDA_DRAW_PANEL_GAL* galCanvas = myframe->GetGalCanvas(); EDA_DRAW_PANEL_GAL* galCanvas = myframe->GetGalCanvas();
if( galCanvas ) if( galCanvas )
{ {
KiGfx::VIEW* view = galCanvas->GetView(); KIGFX::VIEW* view = galCanvas->GetView();
view->SetLayerVisible( aLayer, isVisible ); view->SetLayerVisible( aLayer, isVisible );
} }
...@@ -418,7 +418,7 @@ void PCB_LAYER_WIDGET::OnRenderEnable( int aId, bool isEnabled ) ...@@ -418,7 +418,7 @@ void PCB_LAYER_WIDGET::OnRenderEnable( int aId, bool isEnabled )
EDA_DRAW_PANEL_GAL *galCanvas = myframe->GetGalCanvas(); EDA_DRAW_PANEL_GAL *galCanvas = myframe->GetGalCanvas();
if( galCanvas ) if( galCanvas )
{ {
KiGfx::VIEW* view = galCanvas->GetView(); KIGFX::VIEW* view = galCanvas->GetView();
view->SetLayerVisible( ITEM_GAL_LAYER( aId ), isEnabled ); view->SetLayerVisible( ITEM_GAL_LAYER( aId ), isEnabled );
} }
......
...@@ -170,10 +170,10 @@ void DIALOG_DISPLAY_OPTIONS::OnOkClick(wxCommandEvent& event) ...@@ -170,10 +170,10 @@ void DIALOG_DISPLAY_OPTIONS::OnOkClick(wxCommandEvent& event)
DisplayOpt.DisplayNetNamesMode = m_ShowNetNamesOption->GetSelection(); DisplayOpt.DisplayNetNamesMode = m_ShowNetNamesOption->GetSelection();
// Apply changes to the GAL // Apply changes to the GAL
KiGfx::VIEW* view = m_Parent->GetGalCanvas()->GetView(); KIGFX::VIEW* view = m_Parent->GetGalCanvas()->GetView();
KiGfx::PCB_PAINTER* painter = static_cast<KiGfx::PCB_PAINTER*>( view->GetPainter() ); KIGFX::PCB_PAINTER* painter = static_cast<KIGFX::PCB_PAINTER*>( view->GetPainter() );
KiGfx::PCB_RENDER_SETTINGS* settings = KIGFX::PCB_RENDER_SETTINGS* settings =
static_cast<KiGfx::PCB_RENDER_SETTINGS*>( painter->GetSettings() ); static_cast<KIGFX::PCB_RENDER_SETTINGS*>( painter->GetSettings() );
settings->LoadDisplayOptions( DisplayOpt ); settings->LoadDisplayOptions( DisplayOpt );
view->RecacheAllItems( true ); view->RecacheAllItems( true );
......
...@@ -159,10 +159,10 @@ void PCB_EDIT_FRAME::OnSelectOptionToolbar( wxCommandEvent& event ) ...@@ -159,10 +159,10 @@ void PCB_EDIT_FRAME::OnSelectOptionToolbar( wxCommandEvent& event )
{ {
int id = event.GetId(); int id = event.GetId();
bool state = event.IsChecked(); bool state = event.IsChecked();
KiGfx::PCB_PAINTER* painter = KIGFX::PCB_PAINTER* painter =
static_cast<KiGfx::PCB_PAINTER*> ( m_galCanvas->GetView()->GetPainter() ); static_cast<KIGFX::PCB_PAINTER*> ( m_galCanvas->GetView()->GetPainter() );
KiGfx::PCB_RENDER_SETTINGS* settings = KIGFX::PCB_RENDER_SETTINGS* settings =
static_cast<KiGfx::PCB_RENDER_SETTINGS*> ( painter->GetSettings() ); static_cast<KIGFX::PCB_RENDER_SETTINGS*> ( painter->GetSettings() );
bool recache = false; bool recache = false;
switch( id ) switch( id )
......
...@@ -41,7 +41,7 @@ ...@@ -41,7 +41,7 @@
#include <pcb_painter.h> #include <pcb_painter.h>
#include <gal/graphics_abstraction_layer.h> #include <gal/graphics_abstraction_layer.h>
using namespace KiGfx; using namespace KIGFX;
PCB_RENDER_SETTINGS::PCB_RENDER_SETTINGS() PCB_RENDER_SETTINGS::PCB_RENDER_SETTINGS()
{ {
......
...@@ -49,7 +49,7 @@ class TEXTE_MODULE; ...@@ -49,7 +49,7 @@ class TEXTE_MODULE;
class DIMENSION; class DIMENSION;
class PCB_TARGET; class PCB_TARGET;
namespace KiGfx namespace KIGFX
{ {
class GAL; class GAL;
...@@ -152,6 +152,6 @@ protected: ...@@ -152,6 +152,6 @@ protected:
void draw( const DIMENSION*, int ); void draw( const DIMENSION*, int );
void draw( const PCB_TARGET* ); void draw( const PCB_TARGET* );
}; };
} // namespace KiGfx } // namespace KIGFX
#endif /* __CLASS_PAINTER_H */ #endif /* __CLASS_PAINTER_H */
...@@ -774,8 +774,8 @@ bool PCB_EDIT_FRAME::IsMicroViaAcceptable( void ) ...@@ -774,8 +774,8 @@ bool PCB_EDIT_FRAME::IsMicroViaAcceptable( void )
void PCB_EDIT_FRAME::setHighContrastLayer( LAYER_NUM aLayer ) void PCB_EDIT_FRAME::setHighContrastLayer( LAYER_NUM aLayer )
{ {
// Set display settings for high contrast mode // Set display settings for high contrast mode
KiGfx::VIEW* view = m_galCanvas->GetView(); KIGFX::VIEW* view = m_galCanvas->GetView();
KiGfx::RENDER_SETTINGS* rSettings = view->GetPainter()->GetSettings(); KIGFX::RENDER_SETTINGS* rSettings = view->GetPainter()->GetSettings();
setTopLayer( aLayer ); setTopLayer( aLayer );
...@@ -817,7 +817,7 @@ void PCB_EDIT_FRAME::setHighContrastLayer( LAYER_NUM aLayer ) ...@@ -817,7 +817,7 @@ void PCB_EDIT_FRAME::setHighContrastLayer( LAYER_NUM aLayer )
void PCB_EDIT_FRAME::setTopLayer( LAYER_NUM aLayer ) void PCB_EDIT_FRAME::setTopLayer( LAYER_NUM aLayer )
{ {
// Set display settings for high contrast mode // Set display settings for high contrast mode
KiGfx::VIEW* view = m_galCanvas->GetView(); KIGFX::VIEW* view = m_galCanvas->GetView();
view->ClearTopLayers(); view->ClearTopLayers();
view->SetTopLayer( aLayer ); view->SetTopLayer( aLayer );
...@@ -887,7 +887,7 @@ void PCB_EDIT_FRAME::syncLayerVisibilities() ...@@ -887,7 +887,7 @@ void PCB_EDIT_FRAME::syncLayerVisibilities()
{ {
m_Layers->SyncLayerVisibilities(); m_Layers->SyncLayerVisibilities();
KiGfx::VIEW* view = m_galCanvas->GetView(); KIGFX::VIEW* view = m_galCanvas->GetView();
// Load layer & elements visibility settings // Load layer & elements visibility settings
for( LAYER_NUM i = 0; i < NB_LAYERS; ++i ) for( LAYER_NUM i = 0; i < NB_LAYERS; ++i )
{ {
......
...@@ -329,4 +329,3 @@ private: ...@@ -329,4 +329,3 @@ private:
}; };
#endif // __DIRECTION_H #endif // __DIRECTION_H
...@@ -260,4 +260,3 @@ PNS_INDEX::NetItemsList* PNS_INDEX::GetItemsForNet( int aNet ) ...@@ -260,4 +260,3 @@ PNS_INDEX::NetItemsList* PNS_INDEX::GetItemsForNet( int aNet )
} }
#endif #endif
...@@ -86,4 +86,3 @@ const std::string PNS_ITEM::GetKindStr() const ...@@ -86,4 +86,3 @@ const std::string PNS_ITEM::GetKindStr() const
PNS_ITEM::~PNS_ITEM() PNS_ITEM::~PNS_ITEM()
{ {
} }
...@@ -154,5 +154,4 @@ protected: ...@@ -154,5 +154,4 @@ protected:
int m_net; int m_net;
}; };
#endif // __PNS_ITEM_Ha #endif // __PNS_ITEM_H
...@@ -79,4 +79,3 @@ PNS_ITEMSET& PNS_ITEMSET::FilterNet( int aNet ) ...@@ -79,4 +79,3 @@ PNS_ITEMSET& PNS_ITEMSET::FilterNet( int aNet )
m_items = newItems; m_items = newItems;
return *this; return *this;
} }
...@@ -60,4 +60,3 @@ private: ...@@ -60,4 +60,3 @@ private:
}; };
#endif #endif
...@@ -89,8 +89,8 @@ public: ...@@ -89,8 +89,8 @@ public:
m_linkedItems[1]->GetKind() != SEGMENT ) m_linkedItems[1]->GetKind() != SEGMENT )
return false; return false;
PNS_SEGMENT* seg1 = static_cast<PNS_SEGMENT*> (m_linkedItems[0]); PNS_SEGMENT* seg1 = static_cast<PNS_SEGMENT*>( m_linkedItems[0] );
PNS_SEGMENT* seg2 = static_cast<PNS_SEGMENT*> (m_linkedItems[1]); PNS_SEGMENT* seg2 = static_cast<PNS_SEGMENT*>( m_linkedItems[1] );
// joints between segments of different widths are not trivial. // joints between segments of different widths are not trivial.
return seg1->GetWidth() == seg2->GetWidth(); return seg1->GetWidth() == seg2->GetWidth();
...@@ -204,4 +204,3 @@ inline std::size_t hash_value( PNS_JOINT::HashTag const& p ) ...@@ -204,4 +204,3 @@ inline std::size_t hash_value( PNS_JOINT::HashTag const& p )
} }
#endif // __PNS_JOINT_H #endif // __PNS_JOINT_H
...@@ -117,4 +117,3 @@ private: ...@@ -117,4 +117,3 @@ private:
}; };
#endif // __PNS_LAYERSET_H #endif // __PNS_LAYERSET_H
...@@ -434,8 +434,8 @@ void PNS_LINE::NewWalkaround( const SHAPE_LINE_CHAIN& aObstacle, ...@@ -434,8 +434,8 @@ void PNS_LINE::NewWalkaround( const SHAPE_LINE_CHAIN& aObstacle,
path.Append( l_hull.CPoint( j ) ); path.Append( l_hull.CPoint( j ) );
li = l_orig.Find( l_hull.CPoint( j ) ); li = l_orig.Find( l_hull.CPoint( j ) );
if( li >= 0 && ( li == (l_orig.PointCount() - 1 ) || if( li >= 0 && ( li == ( l_orig.PointCount() - 1 ) ||
outside[li + 1]) ) outside[li + 1] ) )
break; break;
} }
...@@ -755,9 +755,8 @@ void PNS_LINE::ShowLinks() ...@@ -755,9 +755,8 @@ void PNS_LINE::ShowLinks()
return; return;
} }
printf( "line %p: %d linked segs\n", this, (int)m_segmentRefs->size() ); printf( "line %p: %d linked segs\n", this, (int) m_segmentRefs->size() );
for( int i = 0; i < (int) m_segmentRefs->size(); i++ ) for( int i = 0; i < (int) m_segmentRefs->size(); i++ )
printf( "seg %d: %p\n", i, (*m_segmentRefs)[i] ); printf( "seg %d: %p\n", i, (*m_segmentRefs)[i] );
} }
...@@ -261,4 +261,3 @@ private: ...@@ -261,4 +261,3 @@ private:
}; };
#endif // __PNS_LINE_H #endif // __PNS_LINE_H
...@@ -184,8 +184,7 @@ bool PNS_LINE_PLACER::handlePullback() ...@@ -184,8 +184,7 @@ bool PNS_LINE_PLACER::handlePullback()
// case 2: regardless of the current routing direction, if the tail/head // case 2: regardless of the current routing direction, if the tail/head
// extremities form an acute or right angle, reduce the tail by one segment // extremities form an acute or right angle, reduce the tail by one segment
// (and hope that further iterations) will result with a cleaner trace // (and hope that further iterations) will result with a cleaner trace
bool pullback_2 = (angle == DIRECTION_45::ANG_RIGHT || bool pullback_2 = (angle == DIRECTION_45::ANG_RIGHT || angle == DIRECTION_45::ANG_ACUTE);
angle == DIRECTION_45::ANG_ACUTE);
if( pullback_1 || pullback_2 ) if( pullback_1 || pullback_2 )
{ {
...@@ -677,4 +676,3 @@ PNS_NODE* PNS_LINE_PLACER::GetCurrentNode() const ...@@ -677,4 +676,3 @@ PNS_NODE* PNS_LINE_PLACER::GetCurrentNode() const
{ {
return m_shove->GetCurrentNode(); return m_shove->GetCurrentNode();
} }
...@@ -252,4 +252,3 @@ private: ...@@ -252,4 +252,3 @@ private:
}; };
#endif // __PNS_LINE_PLACER_H #endif // __PNS_LINE_PLACER_H
...@@ -702,7 +702,7 @@ void PNS_NODE::FindLineEnds( PNS_LINE* aLine, PNS_JOINT& a, PNS_JOINT& b ) ...@@ -702,7 +702,7 @@ void PNS_NODE::FindLineEnds( PNS_LINE* aLine, PNS_JOINT& a, PNS_JOINT& b )
int PNS_NODE::FindLinesBetweenJoints( PNS_JOINT& a, PNS_JOINT& b, vector<PNS_LINE*>& aLines ) int PNS_NODE::FindLinesBetweenJoints( PNS_JOINT& a, PNS_JOINT& b, vector<PNS_LINE*>& aLines )
{ {
BOOST_FOREACH( PNS_ITEM * item, a.GetLinkList() ) BOOST_FOREACH( PNS_ITEM* item, a.GetLinkList() )
{ {
if( item->GetKind() == PNS_ITEM::SEGMENT ) if( item->GetKind() == PNS_ITEM::SEGMENT )
{ {
...@@ -844,11 +844,13 @@ void PNS_NODE::Dump( bool aLong ) ...@@ -844,11 +844,13 @@ void PNS_NODE::Dump( bool aLong )
} }
if( !isRoot() ) if( !isRoot() )
{
for( i = m_root->m_items.begin(); i != m_root->m_items.end(); i++ ) for( i = m_root->m_items.begin(); i != m_root->m_items.end(); i++ )
{ {
if( (*i)->GetKind() == PNS_ITEM::SEGMENT && !overrides( *i ) ) if( (*i)->GetKind() == PNS_ITEM::SEGMENT && !overrides( *i ) )
all_segs.insert( static_cast<PNS_SEGMENT*>(*i) ); all_segs.insert( static_cast<PNS_SEGMENT*>(*i) );
} }
}
JointMap::iterator j; JointMap::iterator j;
...@@ -880,7 +882,6 @@ void PNS_NODE::Dump( bool aLong ) ...@@ -880,7 +882,6 @@ void PNS_NODE::Dump( bool aLong )
} }
int lines_count = 0; int lines_count = 0;
while( !all_segs.empty() ) while( !all_segs.empty() )
...@@ -984,4 +985,3 @@ void PNS_NODE::AllItemsInNet( int aNet, std::list<PNS_ITEM*>& aItems ) ...@@ -984,4 +985,3 @@ void PNS_NODE::AllItemsInNet( int aNet, std::list<PNS_ITEM*>& aItems )
} }
} }
...@@ -512,8 +512,8 @@ PNS_OPTIMIZER::BreakoutList PNS_OPTIMIZER::rectBreakouts( int aWidth, ...@@ -512,8 +512,8 @@ PNS_OPTIMIZER::BreakoutList PNS_OPTIMIZER::rectBreakouts( int aWidth,
VECTOR2I d_offset; VECTOR2I d_offset;
d_offset.x = (s.x > s.y) ? (s.x - s.y) / 2 : 0; d_offset.x = ( s.x > s.y ) ? ( s.x - s.y ) / 2 : 0;
d_offset.y = (s.x < s.y) ? (s.y - s.x) / 2 : 0; d_offset.y = ( s.x < s.y ) ? ( s.y - s.x ) / 2 : 0;
VECTOR2I d_vert = VECTOR2I( 0, s.y / 2 + aWidth ); VECTOR2I d_vert = VECTOR2I( 0, s.y / 2 + aWidth );
VECTOR2I d_horiz = VECTOR2I( s.x / 2 + aWidth, 0 ); VECTOR2I d_horiz = VECTOR2I( s.x / 2 + aWidth, 0 );
...@@ -601,7 +601,7 @@ PNS_ITEM* PNS_OPTIMIZER::findPadOrVia( int aLayer, int aNet, const VECTOR2I& aP ...@@ -601,7 +601,7 @@ PNS_ITEM* PNS_OPTIMIZER::findPadOrVia( int aLayer, int aNet, const VECTOR2I& aP
if( !jt ) if( !jt )
return NULL; return NULL;
BOOST_FOREACH( PNS_ITEM * item, jt->GetLinkList() ) BOOST_FOREACH( PNS_ITEM* item, jt->GetLinkList() )
{ {
if( item->GetKind() == PNS_ITEM::VIA || item->GetKind() == PNS_ITEM::SOLID ) if( item->GetKind() == PNS_ITEM::VIA || item->GetKind() == PNS_ITEM::SOLID )
return item; return item;
...@@ -683,7 +683,7 @@ int PNS_OPTIMIZER::smartPadsSingle( PNS_LINE* aLine, PNS_ITEM* aPad, bool aEnd, ...@@ -683,7 +683,7 @@ int PNS_OPTIMIZER::smartPadsSingle( PNS_LINE* aLine, PNS_ITEM* aPad, bool aEnd,
bool found = false; bool found = false;
int p_best = -1; int p_best = -1;
BOOST_FOREACH( RtVariant & vp, variants ) BOOST_FOREACH( RtVariant& vp, variants )
{ {
PNS_LINE tmp( *aLine, vp.second ); PNS_LINE tmp( *aLine, vp.second );
int cost = PNS_COST_ESTIMATOR::CornerCost( vp.second ); int cost = PNS_COST_ESTIMATOR::CornerCost( vp.second );
...@@ -761,4 +761,3 @@ bool PNS_OPTIMIZER::Optimize( PNS_LINE* aLine, int aEffortLevel, PNS_NODE* aWorl ...@@ -761,4 +761,3 @@ bool PNS_OPTIMIZER::Optimize( PNS_LINE* aLine, int aEffortLevel, PNS_NODE* aWorl
opt.SetCollisionMask( -1 ); opt.SetCollisionMask( -1 );
return opt.Optimize( aLine ); return opt.Optimize( aLine );
} }
...@@ -164,4 +164,3 @@ private: ...@@ -164,4 +164,3 @@ private:
}; };
#endif #endif
...@@ -110,13 +110,13 @@ PNS_ITEM* PNS_ROUTER::syncPad( D_PAD* aPad ) ...@@ -110,13 +110,13 @@ PNS_ITEM* PNS_ROUTER::syncPad( D_PAD* aPad )
int i; int i;
for( i = FIRST_COPPER_LAYER; i <= LAST_COPPER_LAYER; i++ ) for( i = FIRST_COPPER_LAYER; i <= LAST_COPPER_LAYER; i++ )
{
if( lmsk & (1 << i) ) if( lmsk & (1 << i) )
{ {
layers = PNS_LAYERSET( i ); layers = PNS_LAYERSET( i );
break; break;
} }
}
break; break;
} }
...@@ -294,7 +294,7 @@ PNS_ROUTER::PNS_ROUTER() ...@@ -294,7 +294,7 @@ PNS_ROUTER::PNS_ROUTER()
} }
void PNS_ROUTER::SetView( KiGfx::VIEW* aView ) void PNS_ROUTER::SetView( KIGFX::VIEW* aView )
{ {
if( m_previewItems ) if( m_previewItems )
{ {
...@@ -303,7 +303,7 @@ void PNS_ROUTER::SetView( KiGfx::VIEW* aView ) ...@@ -303,7 +303,7 @@ void PNS_ROUTER::SetView( KiGfx::VIEW* aView )
} }
m_view = aView; m_view = aView;
m_previewItems = new KiGfx::VIEW_GROUP( m_view ); m_previewItems = new KIGFX::VIEW_GROUP( m_view );
m_previewItems->SetLayer( ITEM_GAL_LAYER( GP_OVERLAY ) ); m_previewItems->SetLayer( ITEM_GAL_LAYER( GP_OVERLAY ) );
m_view->Add( m_previewItems ); m_view->Add( m_previewItems );
m_previewItems->ViewSetVisible( true ); m_previewItems->ViewSetVisible( true );
...@@ -386,7 +386,7 @@ const VECTOR2I PNS_ROUTER::SnapToItem( PNS_ITEM* item, VECTOR2I aP, bool& aSplit ...@@ -386,7 +386,7 @@ const VECTOR2I PNS_ROUTER::SnapToItem( PNS_ITEM* item, VECTOR2I aP, bool& aSplit
case PNS_ITEM::SEGMENT: case PNS_ITEM::SEGMENT:
{ {
PNS_SEGMENT* seg = static_cast<PNS_SEGMENT*>(item); PNS_SEGMENT* seg = static_cast<PNS_SEGMENT*>( item );
const SEG& s = seg->GetSeg(); const SEG& s = seg->GetSeg();
int w = seg->GetWidth(); int w = seg->GetWidth();
...@@ -462,7 +462,7 @@ void PNS_ROUTER::EraseView() ...@@ -462,7 +462,7 @@ void PNS_ROUTER::EraseView()
if( m_previewItems ) if( m_previewItems )
m_previewItems->FreeItems(); m_previewItems->FreeItems();
m_previewItems->ViewUpdate( KiGfx::VIEW_ITEM::GEOMETRY ); m_previewItems->ViewUpdate( KIGFX::VIEW_ITEM::GEOMETRY );
} }
...@@ -476,7 +476,7 @@ void PNS_ROUTER::DisplayItem( const PNS_ITEM* aItem, bool aIsHead ) ...@@ -476,7 +476,7 @@ void PNS_ROUTER::DisplayItem( const PNS_ITEM* aItem, bool aIsHead )
pitem->MarkAsHead(); pitem->MarkAsHead();
pitem->ViewSetVisible( true ); pitem->ViewSetVisible( true );
m_previewItems->ViewUpdate( KiGfx::VIEW_ITEM::GEOMETRY | KiGfx::VIEW_ITEM::APPEARANCE ); m_previewItems->ViewUpdate( KIGFX::VIEW_ITEM::GEOMETRY | KIGFX::VIEW_ITEM::APPEARANCE );
} }
...@@ -487,7 +487,7 @@ void PNS_ROUTER::DisplayDebugLine( const SHAPE_LINE_CHAIN& aLine, int aType, int ...@@ -487,7 +487,7 @@ void PNS_ROUTER::DisplayDebugLine( const SHAPE_LINE_CHAIN& aLine, int aType, int
pitem->DebugLine( aLine, aWidth, aType ); pitem->DebugLine( aLine, aWidth, aType );
m_previewItems->Add( pitem ); m_previewItems->Add( pitem );
pitem->ViewSetVisible( true ); pitem->ViewSetVisible( true );
m_previewItems->ViewUpdate( KiGfx::VIEW_ITEM::GEOMETRY | KiGfx::VIEW_ITEM::APPEARANCE ); m_previewItems->ViewUpdate( KIGFX::VIEW_ITEM::GEOMETRY | KIGFX::VIEW_ITEM::APPEARANCE );
} }
...@@ -523,7 +523,8 @@ void PNS_ROUTER::Move( const VECTOR2I& aP, PNS_ITEM* endItem ) ...@@ -523,7 +523,8 @@ void PNS_ROUTER::Move( const VECTOR2I& aP, PNS_ITEM* endItem )
m_placer->GetCurrentNode()->GetUpdatedItems( removed, added ); m_placer->GetCurrentNode()->GetUpdatedItems( removed, added );
BOOST_FOREACH( PNS_ITEM* item, added ) { BOOST_FOREACH( PNS_ITEM* item, added )
{
DisplayItem( item ); DisplayItem( item );
} }
...@@ -537,7 +538,7 @@ void PNS_ROUTER::Move( const VECTOR2I& aP, PNS_ITEM* endItem ) ...@@ -537,7 +538,7 @@ void PNS_ROUTER::Move( const VECTOR2I& aP, PNS_ITEM* endItem )
m_hiddenItems.insert( parent ); m_hiddenItems.insert( parent );
parent->ViewSetVisible( false ); parent->ViewSetVisible( false );
parent->ViewUpdate( KiGfx::VIEW_ITEM::APPEARANCE ); parent->ViewUpdate( KIGFX::VIEW_ITEM::APPEARANCE );
} }
} }
} }
...@@ -552,7 +553,7 @@ void PNS_ROUTER::splitAdjacentSegments( PNS_NODE* aNode, PNS_ITEM* aSeg, const V ...@@ -552,7 +553,7 @@ void PNS_ROUTER::splitAdjacentSegments( PNS_NODE* aNode, PNS_ITEM* aSeg, const V
if( jt && jt->LinkCount() >= 1 ) if( jt && jt->LinkCount() >= 1 )
return; return;
PNS_SEGMENT* s_old = static_cast<PNS_SEGMENT*>(aSeg); PNS_SEGMENT* s_old = static_cast<PNS_SEGMENT*>( aSeg );
PNS_SEGMENT* s_new[2]; PNS_SEGMENT* s_new[2];
s_new[0] = s_old->Clone(); s_new[0] = s_old->Clone();
...@@ -627,7 +628,7 @@ void PNS_ROUTER::commitRouting( PNS_NODE* aNode ) ...@@ -627,7 +628,7 @@ void PNS_ROUTER::commitRouting( PNS_NODE* aNode )
newBI->ClearFlags(); newBI->ClearFlags();
m_view->Add( newBI ); m_view->Add( newBI );
m_board->Add( newBI ); m_board->Add( newBI );
newBI->ViewUpdate( KiGfx::VIEW_ITEM::GEOMETRY ); newBI->ViewUpdate( KIGFX::VIEW_ITEM::GEOMETRY );
} }
} }
...@@ -770,8 +771,8 @@ void PNS_ROUTER::FlipPosture() ...@@ -770,8 +771,8 @@ void PNS_ROUTER::FlipPosture()
if( m_placer->GetTail().GetCLine().SegmentCount() == 0 ) if( m_placer->GetTail().GetCLine().SegmentCount() == 0 )
{ {
m_start_diagonal = !m_start_diagonal; m_start_diagonal = !m_start_diagonal;
m_placer->SetInitialDirection( m_start_diagonal ? DIRECTION_45( m_placer->SetInitialDirection( m_start_diagonal ?
DIRECTION_45::NE ) : DIRECTION_45( DIRECTION_45::N ) ); DIRECTION_45( DIRECTION_45::NE ) : DIRECTION_45( DIRECTION_45::N ) );
} }
else else
m_placer->FlipPosture(); m_placer->FlipPosture();
...@@ -810,4 +811,3 @@ void PNS_ROUTER::ToggleViaPlacement() ...@@ -810,4 +811,3 @@ void PNS_ROUTER::ToggleViaPlacement()
m_placer->AddVia( m_placingVia, m_currentViaDiameter, m_currentViaDrill ); m_placer->AddVia( m_placingVia, m_currentViaDiameter, m_currentViaDrill );
} }
} }
...@@ -48,7 +48,7 @@ class PNS_VIA; ...@@ -48,7 +48,7 @@ class PNS_VIA;
class PNS_CLEARANCE_FUNC; class PNS_CLEARANCE_FUNC;
class VIEW_GROUP; class VIEW_GROUP;
namespace KiGfx { namespace KIGFX {
class VIEW; class VIEW;
class VIEW_GROUP; class VIEW_GROUP;
}; };
...@@ -81,7 +81,7 @@ public: ...@@ -81,7 +81,7 @@ public:
void SetBoard( BOARD* aBoard ); void SetBoard( BOARD* aBoard );
void SyncWorld(); void SyncWorld();
void SetView( KiGfx::VIEW* aView ); void SetView( KIGFX::VIEW* aView );
bool RoutingInProgress() const; bool RoutingInProgress() const;
void StartRouting( const VECTOR2I& aP, PNS_ITEM* aItem ); void StartRouting( const VECTOR2I& aP, PNS_ITEM* aItem );
...@@ -173,8 +173,8 @@ private: ...@@ -173,8 +173,8 @@ private:
PNS_NODE* m_world; PNS_NODE* m_world;
PNS_LINE_PLACER* m_placer; PNS_LINE_PLACER* m_placer;
KiGfx::VIEW* m_view; KIGFX::VIEW* m_view;
KiGfx::VIEW_GROUP* m_previewItems; KIGFX::VIEW_GROUP* m_previewItems;
VECTOR2I m_currentEnd; VECTOR2I m_currentEnd;
VECTOR2I m_currentStart; VECTOR2I m_currentStart;
...@@ -191,4 +191,3 @@ private: ...@@ -191,4 +191,3 @@ private:
}; };
#endif #endif
...@@ -51,4 +51,3 @@ public: ...@@ -51,4 +51,3 @@ public:
}; };
#endif #endif
...@@ -122,4 +122,3 @@ private: ...@@ -122,4 +122,3 @@ private:
}; };
#endif #endif
...@@ -491,4 +491,3 @@ PNS_SHOVE::ShoveStatus PNS_SHOVE::ShoveLines( PNS_LINE* aCurrentHead ) ...@@ -491,4 +491,3 @@ PNS_SHOVE::ShoveStatus PNS_SHOVE::ShoveLines( PNS_LINE* aCurrentHead )
return SH_INCOMPLETE; return SH_INCOMPLETE;
} }
} }
...@@ -83,4 +83,3 @@ private: ...@@ -83,4 +83,3 @@ private:
}; };
#endif #endif
...@@ -60,4 +60,3 @@ PNS_ITEM* PNS_SOLID::Clone() const ...@@ -60,4 +60,3 @@ PNS_ITEM* PNS_SOLID::Clone() const
// solids are never cloned as the shove algorithm never moves them // solids are never cloned as the shove algorithm never moves them
assert( false ); assert( false );
} }
...@@ -68,4 +68,3 @@ private: ...@@ -68,4 +68,3 @@ private:
}; };
#endif #endif
...@@ -42,4 +42,3 @@ const SHAPE_LINE_CHAIN OctagonalHull( const VECTOR2I& aP0, ...@@ -42,4 +42,3 @@ const SHAPE_LINE_CHAIN OctagonalHull( const VECTOR2I& aP0,
return s; return s;
} }
...@@ -30,4 +30,3 @@ const SHAPE_LINE_CHAIN OctagonalHull( const VECTOR2I& aP0, const VECTOR2I& aSize ...@@ -30,4 +30,3 @@ const SHAPE_LINE_CHAIN OctagonalHull( const VECTOR2I& aP0, const VECTOR2I& aSize
int aClearance, int aChamfer ); int aClearance, int aChamfer );
#endif // __PNS_UTILS_H #endif // __PNS_UTILS_H
...@@ -196,13 +196,13 @@ PNS_WALKAROUND::WalkaroundStatus PNS_WALKAROUND::Route( const PNS_LINE& aInitial ...@@ -196,13 +196,13 @@ PNS_WALKAROUND::WalkaroundStatus PNS_WALKAROUND::Route( const PNS_LINE& aInitial
const SEG s = l.Segment( i ); const SEG s = l.Segment( i );
VECTOR2I nearest = s.NearestPoint( m_cursorPos ); VECTOR2I nearest = s.NearestPoint( m_cursorPos );
VECTOR2I::extended_type dist_a = (s.a - m_cursorPos).SquaredEuclideanNorm(); VECTOR2I::extended_type dist_a = ( s.a - m_cursorPos ).SquaredEuclideanNorm();
VECTOR2I::extended_type dist_b = (s.b - m_cursorPos).SquaredEuclideanNorm(); VECTOR2I::extended_type dist_b = ( s.b - m_cursorPos ).SquaredEuclideanNorm();
VECTOR2I::extended_type dist_n = (nearest - m_cursorPos).SquaredEuclideanNorm(); VECTOR2I::extended_type dist_n = ( nearest - m_cursorPos ).SquaredEuclideanNorm();
if( dist_n <= dist_a && dist_n < dist_b ) if( dist_n <= dist_a && dist_n < dist_b )
{ {
// PNSDisplayDebugLine(l, 3); // PNSDisplayDebugLine( l, 3 );
l.Remove( i + 1, -1 ); l.Remove( i + 1, -1 );
l.Append( nearest ); l.Append( nearest );
l.Simplify(); l.Simplify();
...@@ -228,4 +228,3 @@ PNS_WALKAROUND::WalkaroundStatus PNS_WALKAROUND::Route( const PNS_LINE& aInitial ...@@ -228,4 +228,3 @@ PNS_WALKAROUND::WalkaroundStatus PNS_WALKAROUND::Route( const PNS_LINE& aInitial
return st; return st;
} }
...@@ -95,4 +95,3 @@ private: ...@@ -95,4 +95,3 @@ private:
}; };
#endif // __PNS_WALKAROUND_H #endif // __PNS_WALKAROUND_H
...@@ -29,7 +29,7 @@ ...@@ -29,7 +29,7 @@
#include "pns_segment.h" #include "pns_segment.h"
#include "pns_via.h" #include "pns_via.h"
using namespace KiGfx; using namespace KIGFX;
ROUTER_PREVIEW_ITEM::ROUTER_PREVIEW_ITEM( const PNS_ITEM* aItem, VIEW_GROUP* aParent ) : ROUTER_PREVIEW_ITEM::ROUTER_PREVIEW_ITEM( const PNS_ITEM* aItem, VIEW_GROUP* aParent ) :
EDA_ITEM( NOT_USED ) EDA_ITEM( NOT_USED )
...@@ -115,7 +115,7 @@ const BOX2I ROUTER_PREVIEW_ITEM::ViewBBox() const ...@@ -115,7 +115,7 @@ const BOX2I ROUTER_PREVIEW_ITEM::ViewBBox() const
} }
void ROUTER_PREVIEW_ITEM::ViewDraw( int aLayer, KiGfx::GAL* aGal ) const void ROUTER_PREVIEW_ITEM::ViewDraw( int aLayer, KIGFX::GAL* aGal ) const
{ {
switch( m_type ) switch( m_type )
{ {
...@@ -227,4 +227,3 @@ const COLOR4D ROUTER_PREVIEW_ITEM::assignColor( int aStyle ) const ...@@ -227,4 +227,3 @@ const COLOR4D ROUTER_PREVIEW_ITEM::assignColor( int aStyle ) const
return color; return color;
} }
...@@ -56,7 +56,7 @@ public: ...@@ -56,7 +56,7 @@ public:
PR_SUGGESTION = 1 PR_SUGGESTION = 1
}; };
ROUTER_PREVIEW_ITEM( const PNS_ITEM* aItem = NULL, KiGfx::VIEW_GROUP* aParent = NULL ); ROUTER_PREVIEW_ITEM( const PNS_ITEM* aItem = NULL, KIGFX::VIEW_GROUP* aParent = NULL );
~ROUTER_PREVIEW_ITEM(); ~ROUTER_PREVIEW_ITEM();
void Update( const PNS_ITEM* aItem ); void Update( const PNS_ITEM* aItem );
...@@ -69,7 +69,7 @@ public: ...@@ -69,7 +69,7 @@ public:
const BOX2I ViewBBox() const; const BOX2I ViewBBox() const;
virtual void ViewDraw( int aLayer, KiGfx::GAL* aGal ) const; virtual void ViewDraw( int aLayer, KIGFX::GAL* aGal ) const;
virtual void ViewGetLayers( int aLayers[], int& aCount ) const virtual void ViewGetLayers( int aLayers[], int& aCount ) const
{ {
...@@ -80,10 +80,10 @@ public: ...@@ -80,10 +80,10 @@ public:
void MarkAsHead(); void MarkAsHead();
private: private:
const KiGfx::COLOR4D assignColor( int aStyle ) const; const KIGFX::COLOR4D assignColor( int aStyle ) const;
const KiGfx::COLOR4D getLayerColor( int aLayer ) const; const KIGFX::COLOR4D getLayerColor( int aLayer ) const;
KiGfx::VIEW_GROUP* m_parent; KIGFX::VIEW_GROUP* m_parent;
PNS_ROUTER* m_router; PNS_ROUTER* m_router;
SHAPE_LINE_CHAIN m_line; SHAPE_LINE_CHAIN m_line;
...@@ -93,11 +93,10 @@ private: ...@@ -93,11 +93,10 @@ private:
int m_width; int m_width;
int m_layer; int m_layer;
KiGfx::COLOR4D m_color; KIGFX::COLOR4D m_color;
VECTOR2I m_stuckPosition; VECTOR2I m_stuckPosition;
VECTOR2I m_viaCenter; VECTOR2I m_viaCenter;
}; };
#endif #endif
...@@ -38,7 +38,7 @@ ...@@ -38,7 +38,7 @@
#include "pns_router.h" #include "pns_router.h"
#include "trace.h" #include "trace.h"
using namespace KiGfx; using namespace KIGFX;
using namespace std; using namespace std;
using boost::optional; using boost::optional;
......
...@@ -77,4 +77,3 @@ private: ...@@ -77,4 +77,3 @@ private:
}; };
#endif #endif
...@@ -27,13 +27,13 @@ ...@@ -27,13 +27,13 @@
#include <iostream> #include <iostream>
#include <boost/format.hpp> #include <boost/format.hpp>
static void _trace_print( const char* funcName, int level, const std::string& msg ) static void _trace_print( const char* aFuncName, int level, const std::string& aMsg )
{ {
std::cerr << "trace[" << level << "]: " << funcName << ": " << msg << std::endl; std::cerr << "trace[" << level << "]: " << aFuncName << ": " << aMsg << std::endl;
} }
#define TRACE( level, fmt, ... ) \ #define TRACE( level, fmt, ... ) \
_trace_print( __FUNCTION__, level, (boost::format( fmt ) % __VA_ARGS__).str() ); _trace_print( __FUNCTION__, level, ( boost::format( fmt ) % __VA_ARGS__ ).str() );
#define TRACEn( level, msg ) \ #define TRACEn( level, msg ) \
_trace_print( __FUNCTION__, level, std::string( msg ) ); _trace_print( __FUNCTION__, level, std::string( msg ) );
......
...@@ -26,7 +26,7 @@ ...@@ -26,7 +26,7 @@
#include <gal/graphics_abstraction_layer.h> #include <gal/graphics_abstraction_layer.h>
#include <class_track.h> #include <class_track.h>
using namespace KiGfx; using namespace KIGFX;
BRIGHT_BOX::BRIGHT_BOX( BOARD_ITEM* aItem ) : BRIGHT_BOX::BRIGHT_BOX( BOARD_ITEM* aItem ) :
EDA_ITEM( NOT_USED ), // this item is never added to a BOARD so it needs no type EDA_ITEM( NOT_USED ), // this item is never added to a BOARD so it needs no type
...@@ -69,4 +69,5 @@ void BRIGHT_BOX::ViewDraw( int aLayer, GAL* aGal ) const ...@@ -69,4 +69,5 @@ void BRIGHT_BOX::ViewDraw( int aLayer, GAL* aGal ) const
} }
} }
const COLOR4D BRIGHT_BOX::BrightColor = KiGfx::COLOR4D( 0.0, 1.0, 0.0, 1.0 );
const COLOR4D BRIGHT_BOX::BrightColor = KIGFX::COLOR4D( 0.0, 1.0, 0.0, 1.0 );
...@@ -44,7 +44,7 @@ public: ...@@ -44,7 +44,7 @@ public:
virtual const BOX2I ViewBBox() const; virtual const BOX2I ViewBBox() const;
void ViewDraw( int aLayer, KiGfx::GAL* aGal ) const; void ViewDraw( int aLayer, KIGFX::GAL* aGal ) const;
void ViewGetLayers( int aLayers[], int& aCount ) const; void ViewGetLayers( int aLayers[], int& aCount ) const;
void Show( int x, std::ostream& st ) const void Show( int x, std::ostream& st ) const
...@@ -53,7 +53,7 @@ public: ...@@ -53,7 +53,7 @@ public:
private: private:
static const int BrightBoxLayer = ITEM_GAL_LAYER( GP_OVERLAY ); static const int BrightBoxLayer = ITEM_GAL_LAYER( GP_OVERLAY );
static const KiGfx::COLOR4D BrightColor; static const KIGFX::COLOR4D BrightColor;
static const double LineWidth = 100000.0; static const double LineWidth = 100000.0;
BOARD_ITEM* item; BOARD_ITEM* item;
......
...@@ -73,6 +73,7 @@ public: ...@@ -73,6 +73,7 @@ public:
std::deque<BOARD_ITEM*>::iterator it, it_end; std::deque<BOARD_ITEM*>::iterator it, it_end;
std::deque<COMMAND>::iterator cmd, cmd_end; std::deque<COMMAND>::iterator cmd, cmd_end;
for( it = m_items.begin(), it_end = m_items.end(); it != it_end; ++it ) for( it = m_items.begin(), it_end = m_items.end(); it != it_end; ++it )
{ {
for( cmd = m_commands.begin(), cmd_end = m_commands.end(); cmd != cmd_end; ++cmd ) for( cmd = m_commands.begin(), cmd_end = m_commands.end(); cmd != cmd_end; ++cmd )
...@@ -105,6 +106,7 @@ public: ...@@ -105,6 +106,7 @@ public:
m_canSave = false; m_canSave = false;
#endif #endif
std::deque<BOARD_ITEM*>::iterator it, it_end; std::deque<BOARD_ITEM*>::iterator it, it_end;
for( it = m_items.begin(), it_end = m_items.end(); it != it_end; ++it ) for( it = m_items.begin(), it_end = m_items.end(); it != it_end; ++it )
(*it)->Move( wxPoint( aMovement.x, aMovement.y ) ); (*it)->Move( wxPoint( aMovement.x, aMovement.y ) );
...@@ -126,6 +128,7 @@ public: ...@@ -126,6 +128,7 @@ public:
m_commands.push_front( COMMAND( COMMAND::ROTATE, aPoint, aAngle ) ); m_commands.push_front( COMMAND( COMMAND::ROTATE, aPoint, aAngle ) );
std::deque<BOARD_ITEM*>::iterator it, it_end; std::deque<BOARD_ITEM*>::iterator it, it_end;
for( it = m_items.begin(), it_end = m_items.end(); it != it_end; ++it ) for( it = m_items.begin(), it_end = m_items.end(); it != it_end; ++it )
(*it)->Rotate( wxPoint( aPoint.x, aPoint.y ), aAngle ); (*it)->Rotate( wxPoint( aPoint.x, aPoint.y ), aAngle );
...@@ -147,6 +150,7 @@ public: ...@@ -147,6 +150,7 @@ public:
m_commands.push_front( COMMAND( COMMAND::FLIP, aPoint ) ); m_commands.push_front( COMMAND( COMMAND::FLIP, aPoint ) );
std::deque<BOARD_ITEM*>::iterator it, it_end; std::deque<BOARD_ITEM*>::iterator it, it_end;
for( it = m_items.begin(), it_end = m_items.end(); it != it_end; ++it ) for( it = m_items.begin(), it_end = m_items.end(); it != it_end; ++it )
(*it)->Flip( wxPoint( aPoint.x, aPoint.y ) ); (*it)->Flip( wxPoint( aPoint.x, aPoint.y ) );
...@@ -166,6 +170,7 @@ public: ...@@ -166,6 +170,7 @@ public:
m_commands.push_front( COMMAND( COMMAND::VISIBILITY ) ); m_commands.push_front( COMMAND( COMMAND::VISIBILITY ) );
std::deque<BOARD_ITEM*>::iterator it, it_end; std::deque<BOARD_ITEM*>::iterator it, it_end;
for( it = m_items.begin(), it_end = m_items.end(); it != it_end; ++it ) for( it = m_items.begin(), it_end = m_items.end(); it != it_end; ++it )
(*it)->ViewSetVisible( !(*it)->ViewIsVisible() ); (*it)->ViewSetVisible( !(*it)->ViewIsVisible() );
} }
...@@ -177,14 +182,14 @@ public: ...@@ -177,14 +182,14 @@ public:
* them properly. * them properly.
* @return Flag required to refresh items. * @return Flag required to refresh items.
*/ */
KiGfx::VIEW_ITEM::ViewUpdateFlags GetUpdateFlag() const KIGFX::VIEW_ITEM::ViewUpdateFlags GetUpdateFlag() const
{ {
if( m_flips % 2 == 1 ) // If number of flips is odd, then we need to change layers if( m_flips % 2 == 1 ) // If number of flips is odd, then we need to change layers
return KiGfx::VIEW_ITEM::LAYERS; return KIGFX::VIEW_ITEM::LAYERS;
else if( m_movement.x != 0.0 || m_movement.y != 0.0 || m_rotation != 0.0 ) else if( m_movement.x != 0.0 || m_movement.y != 0.0 || m_rotation != 0.0 )
return KiGfx::VIEW_ITEM::GEOMETRY; return KIGFX::VIEW_ITEM::GEOMETRY;
return KiGfx::VIEW_ITEM::APPEARANCE; return KIGFX::VIEW_ITEM::APPEARANCE;
} }
private: private:
......
...@@ -31,7 +31,7 @@ ...@@ -31,7 +31,7 @@
#include "selection_tool.h" #include "selection_tool.h"
#include "move_tool.h" #include "move_tool.h"
using namespace KiGfx; using namespace KIGFX;
using boost::optional; using boost::optional;
MOVE_TOOL::MOVE_TOOL() : MOVE_TOOL::MOVE_TOOL() :
...@@ -79,6 +79,7 @@ bool MOVE_TOOL::Init() ...@@ -79,6 +79,7 @@ bool MOVE_TOOL::Init()
int MOVE_TOOL::Main( TOOL_EVENT& aEvent ) int MOVE_TOOL::Main( TOOL_EVENT& aEvent )
{ {
const SELECTION_TOOL::SELECTION& selection = m_selectionTool->GetSelection(); const SELECTION_TOOL::SELECTION& selection = m_selectionTool->GetSelection();
if( selection.Empty() ) if( selection.Empty() )
return 0; // there are no items to operate on return 0; // there are no items to operate on
...@@ -129,6 +130,7 @@ int MOVE_TOOL::Main( TOOL_EVENT& aEvent ) ...@@ -129,6 +130,7 @@ int MOVE_TOOL::Main( TOOL_EVENT& aEvent )
{ {
// Prepare to drag // Prepare to drag
std::set<BOARD_ITEM*>::iterator it; std::set<BOARD_ITEM*>::iterator it;
for( it = selection.items.begin(); it != selection.items.end(); ++it ) for( it = selection.items.begin(); it != selection.items.end(); ++it )
{ {
// Save the state of the selected items, in case it has to be restored // Save the state of the selected items, in case it has to be restored
......
...@@ -33,7 +33,7 @@ ...@@ -33,7 +33,7 @@
class BOARD_ITEM; class BOARD_ITEM;
class SELECTION_TOOL; class SELECTION_TOOL;
namespace KiGfx namespace KIGFX
{ {
class VIEW_GROUP; class VIEW_GROUP;
} }
......
...@@ -71,8 +71,7 @@ void PCB_EDIT_FRAME::destroyTools() ...@@ -71,8 +71,7 @@ void PCB_EDIT_FRAME::destroyTools()
} }
void PCB_EDIT_FRAME::onGenericCommand( wxCommandEvent &aEvent ) void PCB_EDIT_FRAME::onGenericCommand( wxCommandEvent& aEvent )
{ {
m_toolDispatcher->DispatchWxCommand( aEvent ); m_toolDispatcher->DispatchWxCommand( aEvent );
} }
...@@ -26,11 +26,12 @@ ...@@ -26,11 +26,12 @@
#include <gal/graphics_abstraction_layer.h> #include <gal/graphics_abstraction_layer.h>
#include <gal/color4d.h> #include <gal/color4d.h>
using namespace KiGfx; using namespace KIGFX;
const BOX2I SELECTION_AREA::ViewBBox() const const BOX2I SELECTION_AREA::ViewBBox() const
{ {
BOX2I tmp; BOX2I tmp;
tmp.SetOrigin( m_origin ); tmp.SetOrigin( m_origin );
tmp.SetEnd( m_end ); tmp.SetEnd( m_end );
tmp.Normalize(); tmp.Normalize();
...@@ -45,7 +46,7 @@ void SELECTION_AREA::ViewGetLayers( int aLayers[], int& aCount ) const ...@@ -45,7 +46,7 @@ void SELECTION_AREA::ViewGetLayers( int aLayers[], int& aCount ) const
} }
void SELECTION_AREA::ViewDraw( int aLayer, KiGfx::GAL* aGal ) const void SELECTION_AREA::ViewDraw( int aLayer, KIGFX::GAL* aGal ) const
{ {
aGal->SetLineWidth( 1.0 ); aGal->SetLineWidth( 1.0 );
aGal->SetStrokeColor( COLOR4D( 1.0, 1.0, 0.4, 1.0 ) ); aGal->SetStrokeColor( COLOR4D( 1.0, 1.0, 0.4, 1.0 ) );
......
...@@ -29,7 +29,7 @@ ...@@ -29,7 +29,7 @@
#include <layers_id_colors_and_visibility.h> #include <layers_id_colors_and_visibility.h>
#include <math/box2.h> #include <math/box2.h>
namespace KiGfx namespace KIGFX
{ {
class GAL; class GAL;
} }
...@@ -49,16 +49,16 @@ public: ...@@ -49,16 +49,16 @@ public:
virtual const BOX2I ViewBBox() const; virtual const BOX2I ViewBBox() const;
void ViewDraw( int aLayer, KiGfx::GAL* aGal ) const; void ViewDraw( int aLayer, KIGFX::GAL* aGal ) const;
void ViewGetLayers( int aLayers[], int& aCount ) const; void ViewGetLayers( int aLayers[], int& aCount ) const;
void SetOrigin ( VECTOR2I aOrigin ) void SetOrigin( VECTOR2I aOrigin )
{ {
m_origin = aOrigin; m_origin = aOrigin;
} }
void SetEnd ( VECTOR2I aEnd ) void SetEnd( VECTOR2I aEnd )
{ {
m_end = aEnd; m_end = aEnd;
} }
......
...@@ -47,14 +47,14 @@ ...@@ -47,14 +47,14 @@
#include "bright_box.h" #include "bright_box.h"
#include "common_actions.h" #include "common_actions.h"
using namespace KiGfx; using namespace KIGFX;
using boost::optional; using boost::optional;
SELECTION_TOOL::SELECTION_TOOL() : SELECTION_TOOL::SELECTION_TOOL() :
TOOL_INTERACTIVE( "pcbnew.InteractiveSelection" ), m_multiple( false ) TOOL_INTERACTIVE( "pcbnew.InteractiveSelection" ), m_multiple( false )
{ {
m_selArea = new SELECTION_AREA; m_selArea = new SELECTION_AREA;
m_selection.group = new KiGfx::VIEW_GROUP; m_selection.group = new KIGFX::VIEW_GROUP;
} }
...@@ -177,6 +177,7 @@ void SELECTION_TOOL::toggleSelection( BOARD_ITEM* aItem ) ...@@ -177,6 +177,7 @@ void SELECTION_TOOL::toggleSelection( BOARD_ITEM* aItem )
void SELECTION_TOOL::clearSelection() void SELECTION_TOOL::clearSelection()
{ {
VIEW_GROUP::const_iter it, it_end; VIEW_GROUP::const_iter it, it_end;
for( it = m_selection.group->Begin(), it_end = m_selection.group->End(); it != it_end; ++it ) for( it = m_selection.group->Begin(), it_end = m_selection.group->End(); it != it_end; ++it )
{ {
BOARD_ITEM* item = static_cast<BOARD_ITEM*>( *it ); BOARD_ITEM* item = static_cast<BOARD_ITEM*>( *it );
...@@ -208,6 +209,7 @@ void SELECTION_TOOL::selectSingle( const VECTOR2I& aWhere ) ...@@ -208,6 +209,7 @@ void SELECTION_TOOL::selectSingle( const VECTOR2I& aWhere )
case 0: case 0:
if( !m_additive ) if( !m_additive )
clearSelection(); clearSelection();
break; break;
case 1: case 1:
...@@ -220,6 +222,7 @@ void SELECTION_TOOL::selectSingle( const VECTOR2I& aWhere ) ...@@ -220,6 +222,7 @@ void SELECTION_TOOL::selectSingle( const VECTOR2I& aWhere )
for( int i = collector.GetCount() - 1; i >= 0 ; --i ) for( int i = collector.GetCount() - 1; i >= 0 ; --i )
{ {
BOARD_ITEM* boardItem = ( collector )[i]; BOARD_ITEM* boardItem = ( collector )[i];
if( boardItem->Type() == PCB_MODULE_T || !selectable( boardItem ) ) if( boardItem->Type() == PCB_MODULE_T || !selectable( boardItem ) )
collector.Remove( i ); collector.Remove( i );
} }
...@@ -236,6 +239,7 @@ void SELECTION_TOOL::selectSingle( const VECTOR2I& aWhere ) ...@@ -236,6 +239,7 @@ void SELECTION_TOOL::selectSingle( const VECTOR2I& aWhere )
if( item ) if( item )
toggleSelection( item ); toggleSelection( item );
} }
break; break;
} }
} }
...@@ -244,6 +248,7 @@ void SELECTION_TOOL::selectSingle( const VECTOR2I& aWhere ) ...@@ -244,6 +248,7 @@ void SELECTION_TOOL::selectSingle( const VECTOR2I& aWhere )
BOARD_ITEM* SELECTION_TOOL::pickSmallestComponent( GENERAL_COLLECTOR* aCollector ) BOARD_ITEM* SELECTION_TOOL::pickSmallestComponent( GENERAL_COLLECTOR* aCollector )
{ {
int count = aCollector->GetPrimaryCount(); // try to use preferred layer int count = aCollector->GetPrimaryCount(); // try to use preferred layer
if( 0 == count ) if( 0 == count )
count = aCollector->GetCount(); count = aCollector->GetCount();
...@@ -259,7 +264,7 @@ BOARD_ITEM* SELECTION_TOOL::pickSmallestComponent( GENERAL_COLLECTOR* aCollector ...@@ -259,7 +264,7 @@ BOARD_ITEM* SELECTION_TOOL::pickSmallestComponent( GENERAL_COLLECTOR* aCollector
for( int i = 0; i < count; ++i ) for( int i = 0; i < count; ++i )
{ {
MODULE* module = (MODULE*)( *aCollector )[i]; MODULE* module = (MODULE*) ( *aCollector )[i];
int lx = module->GetBoundingBox().GetWidth(); int lx = module->GetBoundingBox().GetWidth();
int ly = module->GetBoundingBox().GetHeight(); int ly = module->GetBoundingBox().GetHeight();
...@@ -317,6 +322,7 @@ bool SELECTION_TOOL::selectMultiple() ...@@ -317,6 +322,7 @@ bool SELECTION_TOOL::selectMultiple()
view->Query( selectionBox, selectedItems ); // Get the list of selected items view->Query( selectionBox, selectedItems ); // Get the list of selected items
std::vector<VIEW::LayerItemPair>::iterator it, it_end; std::vector<VIEW::LayerItemPair>::iterator it, it_end;
for( it = selectedItems.begin(), it_end = selectedItems.end(); it != it_end; ++it ) for( it = selectedItems.begin(), it_end = selectedItems.end(); it != it_end; ++it )
{ {
BOARD_ITEM* item = static_cast<BOARD_ITEM*>( it->first ); BOARD_ITEM* item = static_cast<BOARD_ITEM*>( it->first );
...@@ -349,6 +355,7 @@ BOARD_ITEM* SELECTION_TOOL::disambiguationMenu( GENERAL_COLLECTOR* aCollector ) ...@@ -349,6 +355,7 @@ BOARD_ITEM* SELECTION_TOOL::disambiguationMenu( GENERAL_COLLECTOR* aCollector )
CONTEXT_MENU menu; CONTEXT_MENU menu;
int limit = std::min( 10, aCollector->GetCount() ); int limit = std::min( 10, aCollector->GetCount() );
for( int i = 0; i < limit; ++i ) for( int i = 0; i < limit; ++i )
{ {
wxString text; wxString text;
...@@ -415,7 +422,7 @@ bool SELECTION_TOOL::selectable( const BOARD_ITEM* aItem ) const ...@@ -415,7 +422,7 @@ bool SELECTION_TOOL::selectable( const BOARD_ITEM* aItem ) const
if( highContrast ) if( highContrast )
{ {
bool onActive = false; // Is the item on any of active layers? bool onActive = false; // Is the item on any of active layers?
int layers[KiGfx::VIEW::VIEW_MAX_LAYERS], layers_count; int layers[KIGFX::VIEW::VIEW_MAX_LAYERS], layers_count;
// Filter out items that do not belong to active layers // Filter out items that do not belong to active layers
std::set<unsigned int> activeLayers = getView()->GetPainter()-> std::set<unsigned int> activeLayers = getView()->GetPainter()->
...@@ -436,6 +443,7 @@ bool SELECTION_TOOL::selectable( const BOARD_ITEM* aItem ) const ...@@ -436,6 +443,7 @@ bool SELECTION_TOOL::selectable( const BOARD_ITEM* aItem ) const
} }
BOARD* board = getModel<BOARD>( PCB_T ); BOARD* board = getModel<BOARD>( PCB_T );
switch( aItem->Type() ) switch( aItem->Type() )
{ {
case PCB_VIA_T: case PCB_VIA_T:
...@@ -444,7 +452,7 @@ bool SELECTION_TOOL::selectable( const BOARD_ITEM* aItem ) const ...@@ -444,7 +452,7 @@ bool SELECTION_TOOL::selectable( const BOARD_ITEM* aItem ) const
LAYER_NUM top, bottom; LAYER_NUM top, bottom;
static_cast<const SEGVIA*>( aItem )->ReturnLayerPair( &top, &bottom ); static_cast<const SEGVIA*>( aItem )->ReturnLayerPair( &top, &bottom );
return ( board->IsLayerVisible( top ) || board->IsLayerVisible( bottom ) ); return board->IsLayerVisible( top ) || board->IsLayerVisible( bottom );
} }
break; break;
...@@ -469,6 +477,7 @@ bool SELECTION_TOOL::selectable( const BOARD_ITEM* aItem ) const ...@@ -469,6 +477,7 @@ bool SELECTION_TOOL::selectable( const BOARD_ITEM* aItem ) const
// Module texts are not selectable in multiple selection mode // Module texts are not selectable in multiple selection mode
if( m_multiple ) if( m_multiple )
return false; return false;
break; break;
// These are not selectable, otherwise silkscreen drawings would be easily destroyed // These are not selectable, otherwise silkscreen drawings would be easily destroyed
...@@ -578,6 +587,7 @@ bool SELECTION_TOOL::containsSelected( const VECTOR2I& aPoint ) const ...@@ -578,6 +587,7 @@ bool SELECTION_TOOL::containsSelected( const VECTOR2I& aPoint ) const
// Check if the point is located within any of the currently selected items bounding boxes // Check if the point is located within any of the currently selected items bounding boxes
std::set<BOARD_ITEM*>::iterator it, it_end; std::set<BOARD_ITEM*>::iterator it, it_end;
for( it = m_selection.items.begin(), it_end = m_selection.items.end(); it != it_end; ++it ) for( it = m_selection.items.begin(), it_end = m_selection.items.end(); it != it_end; ++it )
{ {
BOX2I itemBox = (*it)->ViewBBox(); BOX2I itemBox = (*it)->ViewBBox();
......
...@@ -36,7 +36,7 @@ class SELECTION_AREA; ...@@ -36,7 +36,7 @@ class SELECTION_AREA;
class BOARD_ITEM; class BOARD_ITEM;
class GENERAL_COLLECTOR; class GENERAL_COLLECTOR;
namespace KiGfx namespace KIGFX
{ {
class VIEW_GROUP; class VIEW_GROUP;
} }
...@@ -65,7 +65,7 @@ public: ...@@ -65,7 +65,7 @@ public:
std::set<BOARD_ITEM*> items; std::set<BOARD_ITEM*> items;
/// VIEW_GROUP that holds currently selected items /// VIEW_GROUP that holds currently selected items
KiGfx::VIEW_GROUP* group; KIGFX::VIEW_GROUP* group;
/// Checks if there is anything selected /// Checks if there is anything selected
bool Empty() const { return items.empty(); } bool Empty() const { return items.empty(); }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment