Namespace KiGfx->KIGFX.
template<> -> template <> Some more reformatting according to uncrustify results.
This commit is contained in:
parent
22045b61ea
commit
0ac3e1fbf2
|
@ -24,7 +24,8 @@ file( WRITE ${outputFile} "// Do not edit this file, it is autogenerated by CMak
|
|||
#define SHADER_SRC_H
|
||||
|
||||
const unsigned int shaders_number = ${shadersNumber};
|
||||
const char *shaders_src[] = {\n" )
|
||||
const char* shaders_src[] =
|
||||
{\n" )
|
||||
|
||||
foreach( inputFile ${inputFiles} )
|
||||
# put the input file name into the output file
|
||||
|
|
|
@ -231,7 +231,7 @@ void EDA_DRAW_FRAME::OnToggleGridState( wxCommandEvent& aEvent )
|
|||
if( m_galCanvasActive )
|
||||
{
|
||||
m_galCanvas->GetGAL()->SetGridVisibility( IsGridVisible() );
|
||||
m_galCanvas->GetView()->MarkTargetDirty( KiGfx::TARGET_NONCACHED );
|
||||
m_galCanvas->GetView()->MarkTargetDirty( KIGFX::TARGET_NONCACHED );
|
||||
}
|
||||
|
||||
m_canvas->Refresh();
|
||||
|
@ -391,7 +391,7 @@ void EDA_DRAW_FRAME::OnSelectGrid( wxCommandEvent& event )
|
|||
{
|
||||
m_galCanvas->GetGAL()->SetGridSize( VECTOR2D( screen->GetGrid().m_Size.x,
|
||||
screen->GetGrid().m_Size.y ) );
|
||||
m_galCanvas->GetView()->MarkTargetDirty( KiGfx::TARGET_NONCACHED );
|
||||
m_galCanvas->GetView()->MarkTargetDirty( KIGFX::TARGET_NONCACHED );
|
||||
}
|
||||
|
||||
m_canvas->Refresh();
|
||||
|
@ -425,8 +425,8 @@ void EDA_DRAW_FRAME::OnSelectZoom( wxCommandEvent& event )
|
|||
if( m_galCanvasActive )
|
||||
{
|
||||
// Apply computed view settings to GAL
|
||||
KiGfx::VIEW* view = m_galCanvas->GetView();
|
||||
KiGfx::GAL* gal = m_galCanvas->GetGAL();
|
||||
KIGFX::VIEW* view = m_galCanvas->GetView();
|
||||
KIGFX::GAL* gal = m_galCanvas->GetGAL();
|
||||
|
||||
double zoomFactor = gal->GetWorldScale() / gal->GetZoomFactor();
|
||||
double zoom = 1.0 / ( zoomFactor * GetZoom() );
|
||||
|
@ -954,8 +954,8 @@ void EDA_DRAW_FRAME::AdjustScrollBars( const wxPoint& aCenterPositionIU )
|
|||
|
||||
void EDA_DRAW_FRAME::UseGalCanvas( bool aEnable )
|
||||
{
|
||||
KiGfx::VIEW* view = m_galCanvas->GetView();
|
||||
KiGfx::GAL* gal = m_galCanvas->GetGAL();
|
||||
KIGFX::VIEW* view = m_galCanvas->GetView();
|
||||
KIGFX::GAL* gal = m_galCanvas->GetGAL();
|
||||
|
||||
double zoomFactor = gal->GetWorldScale() / gal->GetZoomFactor();
|
||||
|
||||
|
|
|
@ -66,13 +66,13 @@ EDA_DRAW_PANEL_GAL::EDA_DRAW_PANEL_GAL( wxWindow* aParentWindow, wxWindowID aWin
|
|||
m_gal->SetZoomFactor( 1.0 );
|
||||
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->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_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
|
|||
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_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 );
|
||||
|
||||
m_refreshTimer.SetOwner( this );
|
||||
|
@ -122,12 +122,12 @@ void EDA_DRAW_PANEL_GAL::onPaint( wxPaintEvent& WXUNUSED( aEvent ) )
|
|||
m_lastRefresh = wxGetLocalTimeMillis();
|
||||
|
||||
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_view->ClearTargets();
|
||||
// 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_view->Redraw();
|
||||
m_gal->DrawCursor( m_viewControls->GetCursorPosition() );
|
||||
|
@ -139,8 +139,8 @@ void EDA_DRAW_PANEL_GAL::onPaint( wxPaintEvent& WXUNUSED( aEvent ) )
|
|||
void EDA_DRAW_PANEL_GAL::onSize( wxSizeEvent& aEvent )
|
||||
{
|
||||
m_gal->ResizeScreen( aEvent.GetSize().x, aEvent.GetSize().y );
|
||||
m_view->MarkTargetDirty( KiGfx::TARGET_CACHED );
|
||||
m_view->MarkTargetDirty( KiGfx::TARGET_NONCACHED );
|
||||
m_view->MarkTargetDirty( KIGFX::TARGET_CACHED );
|
||||
m_view->MarkTargetDirty( KIGFX::TARGET_NONCACHED );
|
||||
}
|
||||
|
||||
|
||||
|
@ -189,11 +189,11 @@ void EDA_DRAW_PANEL_GAL::SwitchBackend( GalType aGalType )
|
|||
switch( aGalType )
|
||||
{
|
||||
case GAL_TYPE_OPENGL:
|
||||
m_gal = new KiGfx::OPENGL_GAL( this, this, this );
|
||||
m_gal = new KIGFX::OPENGL_GAL( this, this, this );
|
||||
break;
|
||||
|
||||
case GAL_TYPE_CAIRO:
|
||||
m_gal = new KiGfx::CAIRO_GAL( this, this, this );
|
||||
m_gal = new KIGFX::CAIRO_GAL( this, this, this );
|
||||
break;
|
||||
|
||||
case GAL_TYPE_NONE:
|
||||
|
|
|
@ -31,7 +31,7 @@
|
|||
#include <gal/cairo/cairo_compositor.h>
|
||||
#include <wx/log.h>
|
||||
|
||||
using namespace KiGfx;
|
||||
using namespace KIGFX;
|
||||
|
||||
CAIRO_COMPOSITOR::CAIRO_COMPOSITOR( cairo_t** aMainContext ) :
|
||||
m_current( 0 ), m_currentContext( aMainContext ), m_mainContext( *aMainContext )
|
||||
|
@ -67,6 +67,7 @@ unsigned int CAIRO_COMPOSITOR::CreateBuffer()
|
|||
{
|
||||
// Pixel storage
|
||||
BitmapPtr bitmap( new unsigned int[m_bufferSize] );
|
||||
|
||||
memset( bitmap.get(), 0x00, m_bufferSize * sizeof(int) );
|
||||
|
||||
// Create the Cairo surface
|
||||
|
|
|
@ -33,10 +33,10 @@
|
|||
|
||||
#include <limits>
|
||||
|
||||
using namespace KiGfx;
|
||||
using namespace KIGFX;
|
||||
|
||||
CAIRO_GAL::CAIRO_GAL( wxWindow* aParent, wxEvtHandler* aMouseListener,
|
||||
wxEvtHandler* aPaintListener, const wxString& aName ) :
|
||||
wxEvtHandler* aPaintListener, const wxString& aName ) :
|
||||
wxWindow( aParent, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxEXPAND, aName )
|
||||
{
|
||||
parentWindow = aParent;
|
||||
|
@ -92,6 +92,7 @@ CAIRO_GAL::~CAIRO_GAL()
|
|||
void CAIRO_GAL::BeginDrawing()
|
||||
{
|
||||
initSurface();
|
||||
|
||||
if( !validCompositor )
|
||||
setCompositor();
|
||||
|
||||
|
@ -284,6 +285,7 @@ void CAIRO_GAL::ResizeScreen( int aWidth, int aHeight )
|
|||
|
||||
if( validCompositor )
|
||||
compositor->Resize( aWidth, aHeight );
|
||||
|
||||
validCompositor = false;
|
||||
|
||||
SetSize( wxSize( aWidth, aHeight ) );
|
||||
|
@ -788,6 +790,7 @@ void CAIRO_GAL::ClearTarget( RenderTarget aTarget )
|
|||
compositor->SetBuffer( overlayBuffer );
|
||||
break;
|
||||
}
|
||||
|
||||
compositor->ClearBuffer();
|
||||
|
||||
// Restore the previous state
|
||||
|
|
|
@ -26,7 +26,7 @@
|
|||
|
||||
#include <gal/color4d.h>
|
||||
|
||||
using namespace KiGfx;
|
||||
using namespace KIGFX;
|
||||
|
||||
COLOR4D::COLOR4D( EDA_COLOR_T aColor )
|
||||
{
|
||||
|
@ -85,14 +85,14 @@ void COLOR4D::ToHSV( double& aOutH, double& aOutS, double& aOutV ) const
|
|||
return;
|
||||
}
|
||||
|
||||
if( r >= max ) // > is bogus, just keeps compiler happy
|
||||
aOutH = ( g - b ) / delta; // between yellow & magenta
|
||||
if( r >= max ) // > is bogus, just keeps compiler happy
|
||||
aOutH = ( g - b ) / delta; // between yellow & magenta
|
||||
else if( g >= max )
|
||||
aOutH = 2.0 + ( b - r ) / delta; // between cyan & yellow
|
||||
aOutH = 2.0 + ( b - r ) / delta; // between cyan & yellow
|
||||
else
|
||||
aOutH = 4.0 + ( r - g ) / delta; // between magenta & cyan
|
||||
aOutH = 4.0 + ( r - g ) / delta; // between magenta & cyan
|
||||
|
||||
aOutH *= 60.0; // degrees
|
||||
aOutH *= 60.0; // degrees
|
||||
|
||||
if( aOutH < 0.0 )
|
||||
aOutH += 360.0;
|
||||
|
@ -104,7 +104,7 @@ void COLOR4D::FromHSV( double aInH, double aInS, double aInV )
|
|||
double hh, p, q, t, ff;
|
||||
long i;
|
||||
|
||||
if( aInS <= 0.0 ) // < is bogus, just shuts up warnings
|
||||
if( aInS <= 0.0 ) // < is bogus, just shuts up warnings
|
||||
{
|
||||
r = aInV;
|
||||
g = aInV;
|
||||
|
@ -113,8 +113,10 @@ void COLOR4D::FromHSV( double aInH, double aInS, double aInV )
|
|||
}
|
||||
|
||||
hh = aInH;
|
||||
|
||||
if( hh >= 360.0 )
|
||||
hh = 0.0;
|
||||
|
||||
hh /= 60.0;
|
||||
|
||||
i = (long) hh;
|
||||
|
@ -124,18 +126,20 @@ void COLOR4D::FromHSV( double aInH, double aInS, double aInV )
|
|||
q = aInV * ( 1.0 - ( aInS * ff ) );
|
||||
t = aInV * ( 1.0 - ( aInS * ( 1.0 - ff ) ) );
|
||||
|
||||
switch (i)
|
||||
switch( i )
|
||||
{
|
||||
case 0:
|
||||
r = aInV;
|
||||
g = t;
|
||||
b = p;
|
||||
break;
|
||||
|
||||
case 1:
|
||||
r = q;
|
||||
g = aInV;
|
||||
b = p;
|
||||
break;
|
||||
|
||||
case 2:
|
||||
r = p;
|
||||
g = aInV;
|
||||
|
@ -147,11 +151,13 @@ void COLOR4D::FromHSV( double aInH, double aInS, double aInV )
|
|||
g = q;
|
||||
b = aInV;
|
||||
break;
|
||||
|
||||
case 4:
|
||||
r = t;
|
||||
g = p;
|
||||
b = aInV;
|
||||
break;
|
||||
|
||||
case 5:
|
||||
default:
|
||||
r = aInV;
|
||||
|
@ -165,9 +171,9 @@ void COLOR4D::FromHSV( double aInH, double aInS, double aInV )
|
|||
COLOR4D& COLOR4D::Saturate( double aFactor )
|
||||
{
|
||||
double h, s, v;
|
||||
|
||||
ToHSV( h, s, v );
|
||||
FromHSV( h, aFactor, 1.0 );
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
|
|
@ -29,10 +29,10 @@
|
|||
#include <gal/graphics_abstraction_layer.h>
|
||||
#include <gal/definitions.h>
|
||||
|
||||
using namespace KiGfx;
|
||||
using namespace KIGFX;
|
||||
|
||||
GAL::GAL() :
|
||||
strokeFont( this )
|
||||
strokeFont( this )
|
||||
{
|
||||
// Set the default values for the internal variables
|
||||
SetIsFill( false );
|
||||
|
|
|
@ -39,7 +39,7 @@
|
|||
#include <profile.h>
|
||||
#endif /* __WXDEBUG__ */
|
||||
|
||||
using namespace KiGfx;
|
||||
using namespace KIGFX;
|
||||
|
||||
CACHED_CONTAINER::CACHED_CONTAINER( unsigned int aSize ) :
|
||||
VERTEX_CONTAINER( aSize ), m_item( NULL )
|
||||
|
@ -88,7 +88,7 @@ void CACHED_CONTAINER::FinishItem()
|
|||
#if CACHED_CONTAINER_TEST > 1
|
||||
wxLogDebug( wxT( "Finishing item 0x%08lx (size %d)" ), (long) m_item, m_itemSize );
|
||||
test();
|
||||
m_item = NULL; // electric fence
|
||||
m_item = NULL; // electric fence
|
||||
#endif
|
||||
}
|
||||
|
||||
|
@ -157,6 +157,7 @@ void CACHED_CONTAINER::Delete( VERTEX_ITEM* aItem )
|
|||
// Indicate that the item is not stored in the container anymore
|
||||
aItem->setSize( 0 );
|
||||
}
|
||||
|
||||
m_items.erase( aItem );
|
||||
|
||||
#if CACHED_CONTAINER_TEST > 1
|
||||
|
@ -371,6 +372,7 @@ void CACHED_CONTAINER::mergeFreeChunks()
|
|||
std::list<Chunk> freeChunks;
|
||||
|
||||
FreeChunkMap::const_iterator it, it_end;
|
||||
|
||||
for( it = m_freeChunks.begin(), it_end = m_freeChunks.end(); it != it_end; ++it )
|
||||
{
|
||||
freeChunks.push_back( std::make_pair( it->second, it->first ) );
|
||||
|
@ -527,6 +529,7 @@ void CACHED_CONTAINER::test()
|
|||
// Free space check
|
||||
unsigned int freeSpace = 0;
|
||||
FreeChunkMap::iterator itf;
|
||||
|
||||
for( itf = m_freeChunks.begin(); itf != m_freeChunks.end(); ++itf )
|
||||
freeSpace += getChunkSize( *itf );
|
||||
|
||||
|
@ -543,4 +546,5 @@ void CACHED_CONTAINER::test()
|
|||
|
||||
// Overlapping check TBD
|
||||
}
|
||||
|
||||
#endif /* CACHED_CONTAINER_TEST */
|
||||
|
|
|
@ -37,7 +37,7 @@
|
|||
#include <profile.h>
|
||||
#endif
|
||||
|
||||
using namespace KiGfx;
|
||||
using namespace KIGFX;
|
||||
|
||||
GPU_MANAGER* GPU_MANAGER::MakeManager( VERTEX_CONTAINER* aContainer )
|
||||
{
|
||||
|
|
|
@ -31,7 +31,7 @@
|
|||
#include <gal/opengl/noncached_container.h>
|
||||
#include <cstdlib>
|
||||
|
||||
using namespace KiGfx;
|
||||
using namespace KIGFX;
|
||||
|
||||
NONCACHED_CONTAINER::NONCACHED_CONTAINER( unsigned int aSize ) :
|
||||
VERTEX_CONTAINER( aSize ), m_freePtr( 0 )
|
||||
|
|
|
@ -31,7 +31,7 @@
|
|||
#include <gal/opengl/opengl_compositor.h>
|
||||
#include <wx/log.h>
|
||||
|
||||
using namespace KiGfx;
|
||||
using namespace KIGFX;
|
||||
|
||||
OPENGL_COMPOSITOR::OPENGL_COMPOSITOR() :
|
||||
m_initialized( false ), m_current( 0 )
|
||||
|
@ -95,12 +95,12 @@ unsigned int OPENGL_COMPOSITOR::CreateBuffer()
|
|||
{
|
||||
wxASSERT( m_initialized );
|
||||
|
||||
//if( usedBuffers() >= m_maxBuffers )
|
||||
if( usedBuffers() >= m_maxBuffers )
|
||||
{
|
||||
wxLogError( wxT( "Cannot create more framebuffers. OpenGL rendering backend requires at"
|
||||
"least 3 framebuffers. You may try to update/change "
|
||||
"your graphic drivers." ) );
|
||||
return 0; // Unfortunately we have no more free buffers left
|
||||
return 0; // Unfortunately we have no more free buffers left
|
||||
}
|
||||
|
||||
// GL_COLOR_ATTACHMENTn are consecutive integers
|
||||
|
@ -145,7 +145,7 @@ unsigned int OPENGL_COMPOSITOR::CreateBuffer()
|
|||
|
||||
case GL_FRAMEBUFFER_INCOMPLETE_DRAW_BUFFER:
|
||||
wxLogFatalError( wxT( "The framebuffer does not have at least "
|
||||
"one image attached to it." ) );
|
||||
"one image attached to it." ) );
|
||||
break;
|
||||
|
||||
case GL_FRAMEBUFFER_INCOMPLETE_READ_BUFFER:
|
||||
|
@ -225,6 +225,7 @@ void OPENGL_COMPOSITOR::ClearBuffer()
|
|||
void OPENGL_COMPOSITOR::DrawBuffer( unsigned int aBufferHandle )
|
||||
{
|
||||
wxASSERT( m_initialized );
|
||||
|
||||
if( aBufferHandle == 0 || aBufferHandle > usedBuffers() )
|
||||
{
|
||||
wxLogError( wxT( "Wrong framebuffer handle" ) );
|
||||
|
@ -281,6 +282,7 @@ void OPENGL_COMPOSITOR::clean()
|
|||
glDeleteRenderbuffers( 1, &m_depthBuffer );
|
||||
|
||||
OPENGL_BUFFERS::const_iterator it;
|
||||
|
||||
for( it = m_buffers.begin(); it != m_buffers.end(); ++it )
|
||||
{
|
||||
glDeleteTextures( 1, &it->textureTarget );
|
||||
|
|
|
@ -37,7 +37,7 @@
|
|||
|
||||
#include <limits>
|
||||
|
||||
using namespace KiGfx;
|
||||
using namespace KIGFX;
|
||||
|
||||
// Prototypes
|
||||
void InitTesselatorCallbacks( GLUtesselator* aTesselator );
|
||||
|
@ -90,10 +90,12 @@ OPENGL_GAL::OPENGL_GAL( wxWindow* aParent, wxEvtHandler* aMouseListener,
|
|||
// Tesselator initialization
|
||||
tesselator = gluNewTess();
|
||||
InitTesselatorCallbacks( tesselator );
|
||||
|
||||
if( tesselator == NULL )
|
||||
{
|
||||
wxLogFatalError( wxT( "Could not create the tesselator" ) );
|
||||
}
|
||||
|
||||
gluTessProperty( tesselator, GLU_TESS_WINDING_RULE, GLU_TESS_WINDING_POSITIVE );
|
||||
}
|
||||
|
||||
|
@ -367,7 +369,8 @@ void OPENGL_GAL::DrawArc( const VECTOR2D& aCenterPoint, double aRadius, double a
|
|||
currentManager->Color( strokeColor.r, strokeColor.g, strokeColor.b, strokeColor.a );
|
||||
|
||||
VECTOR2D p( cos( aStartAngle ) * aRadius, sin( aStartAngle ) * aRadius );
|
||||
double alpha;
|
||||
double alpha;
|
||||
|
||||
for( alpha = aStartAngle + alphaIncrement; alpha < aEndAngle; alpha += alphaIncrement )
|
||||
{
|
||||
VECTOR2D p_next( cos( alpha ) * aRadius, sin( alpha ) * aRadius );
|
||||
|
@ -570,7 +573,7 @@ void OPENGL_GAL::ClearScreen()
|
|||
|
||||
void OPENGL_GAL::SetStrokeColor( const COLOR4D& aColor )
|
||||
{
|
||||
strokeColor = aColor;
|
||||
strokeColor = aColor;
|
||||
|
||||
// This is the default drawing color
|
||||
currentManager->Color( aColor.r, aColor.g, aColor.b, aColor.a );
|
||||
|
@ -734,6 +737,7 @@ void OPENGL_GAL::ClearTarget( RenderTarget aTarget )
|
|||
compositor.SetBuffer( overlayBuffer );
|
||||
break;
|
||||
}
|
||||
|
||||
compositor.ClearBuffer();
|
||||
|
||||
// Restore the previous state
|
||||
|
|
|
@ -34,7 +34,7 @@
|
|||
#include <gal/opengl/shader.h>
|
||||
#include "shader_src.h"
|
||||
|
||||
using namespace KiGfx;
|
||||
using namespace KIGFX;
|
||||
|
||||
SHADER::SHADER() :
|
||||
isProgramCreated( false ),
|
||||
|
@ -101,17 +101,19 @@ bool SHADER::Link()
|
|||
(GLint*) &isShaderLinked );
|
||||
|
||||
#ifdef __WXDEBUG__
|
||||
|
||||
if( !isShaderLinked )
|
||||
{
|
||||
int maxLength;
|
||||
glGetProgramiv( programNumber, GL_INFO_LOG_LENGTH, &maxLength );
|
||||
maxLength = maxLength + 1;
|
||||
char *linkInfoLog = new char[maxLength];
|
||||
char* linkInfoLog = new char[maxLength];
|
||||
glGetProgramInfoLog( programNumber, maxLength, &maxLength, linkInfoLog );
|
||||
std::cerr << "Shader linking error:" << std::endl;
|
||||
std::cerr << linkInfoLog;
|
||||
delete[] linkInfoLog;
|
||||
}
|
||||
|
||||
#endif /* __WXDEBUG__ */
|
||||
|
||||
return isShaderLinked;
|
||||
|
|
|
@ -73,4 +73,3 @@ void main()
|
|||
gl_FragColor = gl_Color;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -96,4 +96,3 @@ void main()
|
|||
|
||||
gl_FrontColor = gl_Color;
|
||||
}
|
||||
|
||||
|
|
|
@ -33,7 +33,7 @@
|
|||
#include <gal/opengl/shader.h>
|
||||
#include <wx/log.h>
|
||||
|
||||
using namespace KiGfx;
|
||||
using namespace KIGFX;
|
||||
|
||||
VERTEX_CONTAINER* VERTEX_CONTAINER::MakeContainer( bool aCached )
|
||||
{
|
||||
|
|
|
@ -31,7 +31,7 @@
|
|||
#include <gal/opengl/vertex_manager.h>
|
||||
#include <cstring>
|
||||
|
||||
using namespace KiGfx;
|
||||
using namespace KIGFX;
|
||||
|
||||
VERTEX_ITEM::VERTEX_ITEM( const VERTEX_MANAGER& aManager ) :
|
||||
m_manager( aManager ), m_offset( 0 ), m_size( 0 )
|
||||
|
|
|
@ -34,7 +34,7 @@
|
|||
#include <gal/opengl/gpu_manager.h>
|
||||
#include <gal/opengl/vertex_item.h>
|
||||
|
||||
using namespace KiGfx;
|
||||
using namespace KIGFX;
|
||||
|
||||
VERTEX_MANAGER::VERTEX_MANAGER( bool aCached ) :
|
||||
m_noTransform( true ), m_transform( 1.0f )
|
||||
|
@ -106,6 +106,7 @@ void VERTEX_MANAGER::ChangeItemColor( const VERTEX_ITEM& aItem, const COLOR4D& a
|
|||
unsigned int offset = aItem.GetOffset();
|
||||
|
||||
VERTEX* vertex = m_container->GetVertices( offset );
|
||||
|
||||
for( unsigned int i = 0; i < size; ++i )
|
||||
{
|
||||
vertex->r = aColor.r * 255.0;
|
||||
|
@ -125,6 +126,7 @@ void VERTEX_MANAGER::ChangeItemDepth( const VERTEX_ITEM& aItem, GLfloat aDepth )
|
|||
unsigned int offset = aItem.GetOffset();
|
||||
|
||||
VERTEX* vertex = m_container->GetVertices( offset );
|
||||
|
||||
for( unsigned int i = 0; i < size; ++i )
|
||||
{
|
||||
vertex->z = aDepth;
|
||||
|
|
|
@ -27,7 +27,7 @@
|
|||
#include <gal/stroke_font.h>
|
||||
#include <gal/graphics_abstraction_layer.h>
|
||||
|
||||
using namespace KiGfx;
|
||||
using namespace KIGFX;
|
||||
|
||||
|
||||
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
|
|||
case GR_TEXT_HJUSTIFY_RIGHT:
|
||||
if( !m_mirrored )
|
||||
m_gal->Translate( VECTOR2D( -textsize.x, 0 ) );
|
||||
|
||||
break;
|
||||
|
||||
case GR_TEXT_HJUSTIFY_LEFT:
|
||||
if( m_mirrored )
|
||||
m_gal->Translate( VECTOR2D( -textsize.x, 0 ) );
|
||||
|
||||
break;
|
||||
|
||||
default:
|
||||
|
|
|
@ -25,7 +25,9 @@
|
|||
|
||||
#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 ) );
|
||||
}
|
||||
|
||||
|
@ -64,8 +66,8 @@ bool SEG::PointCloserThan( const VECTOR2I& aP, int dist ) const
|
|||
}
|
||||
|
||||
VECTOR2I nearest;
|
||||
nearest.x = a.x + rescale( t, (ecoord)d.x, l_squared );
|
||||
nearest.y = a.y + rescale( t, (ecoord)d.y, l_squared );
|
||||
nearest.x = a.x + rescale( t, (ecoord) d.x, l_squared );
|
||||
nearest.y = a.y + rescale( t, (ecoord) d.y, l_squared );
|
||||
|
||||
return ( nearest - aP ).SquaredEuclideanNorm() <= dist_sq;
|
||||
}
|
||||
|
@ -86,6 +88,7 @@ SEG::ecoord SEG::SquaredDistance( const SEG& aSeg ) const
|
|||
};
|
||||
|
||||
ecoord m = VECTOR2I::ECOORD_MAX;
|
||||
|
||||
for( int i = 0; i < 4; i++ )
|
||||
m = std::min( m, pts[i].SquaredEuclideanNorm() );
|
||||
|
||||
|
@ -95,9 +98,9 @@ SEG::ecoord SEG::SquaredDistance( const SEG& aSeg ) const
|
|||
|
||||
OPT_VECTOR2I SEG::Intersect( const SEG& aSeg, bool aIgnoreEndpoints, bool aLines ) const
|
||||
{
|
||||
const VECTOR2I e ( b - a );
|
||||
const VECTOR2I f ( aSeg.b - aSeg.a );
|
||||
const VECTOR2I ac ( aSeg.a - a );
|
||||
const VECTOR2I e( b - a );
|
||||
const VECTOR2I f( aSeg.b - aSeg.a );
|
||||
const VECTOR2I ac( aSeg.a - a );
|
||||
|
||||
ecoord d = f.Cross( e );
|
||||
ecoord p = f.Cross( ac );
|
||||
|
@ -105,15 +108,18 @@ OPT_VECTOR2I SEG::Intersect( const SEG& aSeg, bool aIgnoreEndpoints, bool aLines
|
|||
|
||||
if( d == 0 )
|
||||
return OPT_VECTOR2I();
|
||||
if ( !aLines && d > 0 && ( q < 0 || q > d || p < 0 || p > d ) )
|
||||
return OPT_VECTOR2I();
|
||||
if ( !aLines && d < 0 && ( q < d || p < d || p > 0 || q > 0 ) )
|
||||
return OPT_VECTOR2I();
|
||||
if ( !aLines && aIgnoreEndpoints && ( q == 0 || q == d ) && ( p == 0 || p == d ) )
|
||||
|
||||
if( !aLines && d > 0 && ( q < 0 || q > d || p < 0 || p > d ) )
|
||||
return OPT_VECTOR2I();
|
||||
|
||||
VECTOR2I ip( aSeg.a.x + rescale( q, (ecoord)f.x, d ),
|
||||
aSeg.a.y + rescale( q, (ecoord)f.y, d ) );
|
||||
if( !aLines && d < 0 && ( q < d || p < d || p > 0 || q > 0 ) )
|
||||
return OPT_VECTOR2I();
|
||||
|
||||
if( !aLines && aIgnoreEndpoints && ( q == 0 || q == d ) && ( p == 0 || p == d ) )
|
||||
return OPT_VECTOR2I();
|
||||
|
||||
VECTOR2I ip( aSeg.a.x + rescale( q, (ecoord) f.x, d ),
|
||||
aSeg.a.y + rescale( q, (ecoord) f.y, d ) );
|
||||
|
||||
return ip;
|
||||
}
|
||||
|
@ -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
|
||||
{
|
||||
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
|
|||
ccw( a, b, aSeg.a ) != ccw( a, b, aSeg.b ) )
|
||||
return true;
|
||||
|
||||
#define CHK(_seg, _pt) \
|
||||
if( (_seg).PointCloserThan (_pt, aClearance ) ) return true;
|
||||
#define CHK( _seg, _pt ) \
|
||||
if( (_seg).PointCloserThan( _pt, aClearance ) ) return true;
|
||||
|
||||
CHK( *this, aSeg.a );
|
||||
CHK( *this, aSeg.b );
|
||||
|
|
|
@ -41,11 +41,11 @@ static inline bool Collide( const SHAPE_CIRCLE& aA, const SHAPE_CIRCLE& aB, int
|
|||
|
||||
ecoord dist_sq = delta.SquaredEuclideanNorm();
|
||||
|
||||
if ( dist_sq >= min_dist_sq )
|
||||
if( dist_sq >= min_dist_sq )
|
||||
return false;
|
||||
|
||||
if ( aNeedMTV )
|
||||
aMTV = delta.Resize( sqrt ( abs( min_dist_sq - dist_sq ) ) + 1 );
|
||||
if( aNeedMTV )
|
||||
aMTV = delta.Resize( sqrt( abs( min_dist_sq - dist_sq ) ) + 1 );
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@ -60,28 +60,29 @@ static inline bool Collide( const SHAPE_RECT& aA, const SHAPE_CIRCLE& aB, int a
|
|||
const ecoord min_dist = aClearance + r;
|
||||
const ecoord min_dist_sq = min_dist * min_dist;
|
||||
|
||||
if ( aA.BBox( 0 ).Contains( c ) )
|
||||
if( aA.BBox( 0 ).Contains( c ) )
|
||||
return true;
|
||||
|
||||
const VECTOR2I vts[] = {
|
||||
VECTOR2I(p0.x, p0.y),
|
||||
VECTOR2I(p0.x, p0.y + size.y),
|
||||
VECTOR2I(p0.x + size.x, p0.y + size.y),
|
||||
VECTOR2I(p0.x + size.x, p0.y),
|
||||
VECTOR2I(p0.x, p0.y) };
|
||||
const VECTOR2I vts[] =
|
||||
{
|
||||
VECTOR2I( p0.x, p0.y ),
|
||||
VECTOR2I( p0.x, p0.y + size.y ),
|
||||
VECTOR2I( p0.x + size.x, p0.y + size.y ),
|
||||
VECTOR2I( p0.x + size.x, p0.y ),
|
||||
VECTOR2I( p0.x, p0.y )
|
||||
};
|
||||
|
||||
ecoord nearest_seg_dist_sq = VECTOR2I::ECOORD_MAX;
|
||||
VECTOR2I nearest;
|
||||
|
||||
bool inside = c.x >= p0.x && c.x <= ( p0.x + size.x )
|
||||
&& c.y >= p0.y && c.y <= ( p0.y + size.y );
|
||||
bool inside = c.x >= p0.x && c.x <= ( p0.x + size.x )
|
||||
&& c.y >= p0.y && c.y <= ( p0.y + size.y );
|
||||
|
||||
if( !inside )
|
||||
{
|
||||
|
||||
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 );
|
||||
|
||||
if( dist_sq < min_dist_sq )
|
||||
|
@ -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++ )
|
||||
{
|
||||
if ( aA.Collide( aB.CSegment( s ), aClearance ) )
|
||||
if( aA.Collide( aB.CSegment( s ), aClearance ) )
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -131,8 +132,9 @@ static inline bool Collide( const SHAPE_LINE_CHAIN& aA, const SHAPE_LINE_CHAIN&
|
|||
bool aNeedMTV, VECTOR2I& aMTV )
|
||||
{
|
||||
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 false;
|
||||
}
|
||||
|
||||
|
@ -143,8 +145,9 @@ static inline bool Collide( const SHAPE_RECT& aA, const SHAPE_LINE_CHAIN& aB, in
|
|||
for( int s = 0; s < aB.SegmentCount(); s++ )
|
||||
{
|
||||
SEG seg = aB.CSegment( s );
|
||||
if( aA.Collide( seg, aClearance ) )
|
||||
return true;
|
||||
|
||||
if( aA.Collide( seg, aClearance ) )
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
|
@ -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
|
||||
{
|
||||
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;
|
||||
|
||||
return CollideShapes( this, aShape, aClerance, false, dummy );
|
||||
}
|
||||
|
|
|
@ -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::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 );
|
||||
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 )
|
||||
{
|
||||
|
@ -64,9 +64,11 @@ bool SHAPE_LINE_CHAIN::Collide( const SEG& aSeg, int aClearance ) const
|
|||
return false;
|
||||
}
|
||||
|
||||
|
||||
const SHAPE_LINE_CHAIN SHAPE_LINE_CHAIN::Reverse() const
|
||||
{
|
||||
SHAPE_LINE_CHAIN a( *this );
|
||||
|
||||
reverse( a.m_points.begin(), a.m_points.end() );
|
||||
a.m_closed = m_closed;
|
||||
|
||||
|
@ -77,6 +79,7 @@ const SHAPE_LINE_CHAIN SHAPE_LINE_CHAIN::Reverse() const
|
|||
int SHAPE_LINE_CHAIN::Length() const
|
||||
{
|
||||
int l = 0;
|
||||
|
||||
for( int i = 0; i < SegmentCount(); i++ )
|
||||
l += CSegment( i ).Length();
|
||||
|
||||
|
@ -88,11 +91,12 @@ void SHAPE_LINE_CHAIN::Replace( int aStartIndex, int aEndIndex, const VECTOR2I&
|
|||
{
|
||||
if( aEndIndex < 0 )
|
||||
aEndIndex += PointCount();
|
||||
|
||||
if( aStartIndex < 0 )
|
||||
aStartIndex += PointCount();
|
||||
|
||||
if( aStartIndex == aEndIndex )
|
||||
m_points [aStartIndex] = aP;
|
||||
m_points[aStartIndex] = aP;
|
||||
else
|
||||
{
|
||||
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
|
|||
{
|
||||
if( aEndIndex < 0 )
|
||||
aEndIndex += PointCount();
|
||||
|
||||
if( aStartIndex < 0 )
|
||||
aStartIndex += PointCount();
|
||||
|
||||
|
@ -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 )
|
||||
{
|
||||
if(aEndIndex < 0)
|
||||
if( aEndIndex < 0 )
|
||||
aEndIndex += PointCount();
|
||||
if(aStartIndex < 0)
|
||||
|
||||
if( aStartIndex < 0 )
|
||||
aStartIndex += PointCount();
|
||||
|
||||
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 )
|
|||
int SHAPE_LINE_CHAIN::Distance( const VECTOR2I& aP ) const
|
||||
{
|
||||
int d = INT_MAX;
|
||||
|
||||
for( int s = 0; s < SegmentCount(); s++ )
|
||||
d = min( d, CSegment( s ).Distance( aP ) );
|
||||
|
||||
|
@ -185,6 +192,7 @@ const SHAPE_LINE_CHAIN SHAPE_LINE_CHAIN::Slice( int aStartIndex, int aEndIndex )
|
|||
|
||||
if( aEndIndex < 0 )
|
||||
aEndIndex += PointCount();
|
||||
|
||||
if( aStartIndex < 0 )
|
||||
aStartIndex += PointCount();
|
||||
|
||||
|
@ -197,7 +205,7 @@ const SHAPE_LINE_CHAIN SHAPE_LINE_CHAIN::Slice( int aStartIndex, int aEndIndex )
|
|||
|
||||
struct compareOriginDistance
|
||||
{
|
||||
compareOriginDistance( VECTOR2I& aOrigin ):
|
||||
compareOriginDistance( VECTOR2I& aOrigin ) :
|
||||
m_origin( aOrigin ) {};
|
||||
|
||||
bool operator()( const SHAPE_LINE_CHAIN::Intersection& aA,
|
||||
|
@ -215,6 +223,7 @@ int SHAPE_LINE_CHAIN::Intersect( const SEG& aSeg, Intersections& aIp ) const
|
|||
for( int s = 0; s < SegmentCount(); s++ )
|
||||
{
|
||||
OPT_VECTOR2I p = CSegment( s ).Intersect( aSeg );
|
||||
|
||||
if( p )
|
||||
{
|
||||
Intersection is;
|
||||
|
@ -236,7 +245,7 @@ int SHAPE_LINE_CHAIN::Intersect( const SHAPE_LINE_CHAIN& aChain, Intersections&
|
|||
{
|
||||
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 BOX2I bb_cur( a.a, a.b - a.a );
|
||||
|
@ -305,7 +314,6 @@ int SHAPE_LINE_CHAIN::Intersect( const SHAPE_LINE_CHAIN& aChain, Intersections&
|
|||
is.their = b;
|
||||
aIp.push_back( is );
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -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 sum = 0;
|
||||
|
||||
for( int i = 0; i < SegmentCount(); i++ )
|
||||
{
|
||||
const SEG seg = CSegment( i );
|
||||
|
@ -340,7 +349,7 @@ bool SHAPE_LINE_CHAIN::PointInside( const VECTOR2I& aP ) const
|
|||
if( !m_closed || SegmentCount() < 3 )
|
||||
return false;
|
||||
|
||||
int cur = CSegment(0).Side( aP );
|
||||
int cur = CSegment( 0 ).Side( aP );
|
||||
|
||||
if( cur == 0 )
|
||||
return false;
|
||||
|
@ -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!
|
||||
return false;
|
||||
|
||||
if( s.Side(aP) != cur )
|
||||
if( s.Side( aP ) != cur )
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -372,7 +381,7 @@ bool SHAPE_LINE_CHAIN::PointOnEdge( const VECTOR2I& aP ) const
|
|||
if( s.a == aP || s.b == aP )
|
||||
return true;
|
||||
|
||||
if( s.Distance(aP) <= 1 )
|
||||
if( s.Distance( aP ) <= 1 )
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -387,6 +396,7 @@ const optional<SHAPE_LINE_CHAIN::Intersection> SHAPE_LINE_CHAIN::SelfIntersectin
|
|||
for( int s2 = s1 + 1; s2 < SegmentCount(); s2++ )
|
||||
{
|
||||
const VECTOR2I s2a = CSegment( s2 ).a, s2b = CSegment( s2 ).b;
|
||||
|
||||
if( s1 + 1 != s2 && CSegment( s1 ).Contains( s2a ) )
|
||||
{
|
||||
Intersection is;
|
||||
|
@ -395,7 +405,7 @@ const optional<SHAPE_LINE_CHAIN::Intersection> SHAPE_LINE_CHAIN::SelfIntersectin
|
|||
is.p = s2a;
|
||||
return is;
|
||||
}
|
||||
else if( CSegment( s1 ).Contains(s2b ) )
|
||||
else if( CSegment( s1 ).Contains( s2b ) )
|
||||
{
|
||||
Intersection is;
|
||||
is.our = CSegment( s1 );
|
||||
|
@ -443,10 +453,11 @@ SHAPE_LINE_CHAIN& SHAPE_LINE_CHAIN::Simplify()
|
|||
int np = PointCount();
|
||||
|
||||
// stage 1: eliminate duplicate vertices
|
||||
while ( i < np )
|
||||
while( i < np )
|
||||
{
|
||||
int j = i + 1;
|
||||
while( j < np && CPoint(i) == CPoint( j ) )
|
||||
|
||||
while( j < np && CPoint( i ) == CPoint( j ) )
|
||||
j++;
|
||||
|
||||
pts_unique.push_back( CPoint( i ) );
|
||||
|
@ -457,17 +468,19 @@ SHAPE_LINE_CHAIN& SHAPE_LINE_CHAIN::Simplify()
|
|||
np = pts_unique.size();
|
||||
|
||||
i = 0;
|
||||
|
||||
// stage 1: eliminate collinear segments
|
||||
while( i < np - 2 )
|
||||
{
|
||||
const VECTOR2I p0 = pts_unique[i];
|
||||
const VECTOR2I p1 = pts_unique[i+1];
|
||||
const VECTOR2I p1 = pts_unique[i + 1];
|
||||
int n = i;
|
||||
|
||||
while( n < np - 2 && SEG( p0, p1 ).LineDistance( pts_unique[n + 2] ) <= 1 )
|
||||
n++;
|
||||
|
||||
m_points.push_back( p0 );
|
||||
|
||||
if( n > i )
|
||||
i = n;
|
||||
|
||||
|
@ -493,9 +506,11 @@ const VECTOR2I SHAPE_LINE_CHAIN::NearestPoint( const VECTOR2I& aP ) const
|
|||
{
|
||||
int min_d = INT_MAX;
|
||||
int nearest = 0;
|
||||
for ( int i = 0; i < SegmentCount(); i++ )
|
||||
|
||||
for( int i = 0; i < SegmentCount(); i++ )
|
||||
{
|
||||
int d = CSegment( i ).Distance( aP );
|
||||
|
||||
if( d < min_d )
|
||||
{
|
||||
min_d = d;
|
||||
|
@ -511,10 +526,10 @@ const string SHAPE_LINE_CHAIN::Format() const
|
|||
{
|
||||
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++ )
|
||||
ss << m_points[i].x << " " << m_points[i].y << " ";// Format() << " ";
|
||||
ss << m_points[i].x << " " << m_points[i].y << " "; // Format() << " ";
|
||||
|
||||
return ss.str();
|
||||
}
|
||||
|
|
|
@ -28,16 +28,18 @@
|
|||
#include <climits>
|
||||
#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 );
|
||||
}
|
||||
|
||||
|
||||
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 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 b = std::abs( value );
|
||||
|
@ -51,7 +53,9 @@ template<> int64_t rescale( int64_t numerator, int64_t value, int64_t denominato
|
|||
return sign * ( (a * b + r ) / c );
|
||||
else
|
||||
return sign * (a / c * b + (a % c * b + r) / c);
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
uint64_t a0 = a & 0xFFFFFFFF;
|
||||
uint64_t a1 = a >> 32;
|
||||
uint64_t b0 = b & 0xFFFFFFFF;
|
||||
|
@ -61,16 +65,16 @@ template<> int64_t rescale( int64_t numerator, int64_t value, int64_t denominato
|
|||
int i;
|
||||
|
||||
a0 = a0 * b0 + t1a;
|
||||
a1 = a1 * b1 + (t1 >> 32) + (a0 < t1a);
|
||||
a1 = a1 * b1 + ( t1 >> 32 ) + ( a0 < t1a );
|
||||
a0 += r;
|
||||
a1 += ((uint64_t)a0) < r;
|
||||
a1 += ( (uint64_t) a0 ) < r;
|
||||
|
||||
for( i = 63; i >= 0; i-- )
|
||||
{
|
||||
a1 += a1 + ( (a0 >> i) & 1 );
|
||||
a1 += a1 + ( ( a0 >> i ) & 1 );
|
||||
t1 += t1;
|
||||
|
||||
if( (uint64_t)c <= a1 )
|
||||
if( (uint64_t) c <= a1 )
|
||||
{
|
||||
a1 -= c;
|
||||
t1++;
|
||||
|
|
|
@ -27,7 +27,7 @@
|
|||
#include <painter.h>
|
||||
#include <gal/graphics_abstraction_layer.h>
|
||||
|
||||
using namespace KiGfx;
|
||||
using namespace KIGFX;
|
||||
|
||||
RENDER_SETTINGS::RENDER_SETTINGS()
|
||||
{
|
||||
|
|
|
@ -36,7 +36,7 @@ ACTION_MANAGER::ACTION_MANAGER( TOOL_MANAGER* aToolManager ) :
|
|||
|
||||
void ACTION_MANAGER::RegisterAction( TOOL_ACTION* aAction )
|
||||
{
|
||||
assert( aAction->GetId() == -1 ); // Check if the TOOL_ACTION was not registered before
|
||||
assert( aAction->GetId() == -1 ); // Check if the TOOL_ACTION was not registered before
|
||||
|
||||
aAction->setId( MakeActionId( aAction->m_name ) );
|
||||
|
||||
|
@ -67,6 +67,7 @@ void ACTION_MANAGER::UnregisterAction( TOOL_ACTION* aAction )
|
|||
int ACTION_MANAGER::MakeActionId( const std::string& aActionName )
|
||||
{
|
||||
static int currentActionId = 1;
|
||||
|
||||
return currentActionId++;
|
||||
}
|
||||
|
||||
|
@ -76,7 +77,7 @@ bool ACTION_MANAGER::RunAction( const std::string& aActionName ) const
|
|||
std::map<std::string, TOOL_ACTION*>::const_iterator it = m_actionNameIndex.find( aActionName );
|
||||
|
||||
if( it == m_actionNameIndex.end() )
|
||||
return false; // no action with given name found
|
||||
return false; // no action with given name found
|
||||
|
||||
runAction( it->second );
|
||||
|
||||
|
@ -89,7 +90,7 @@ bool ACTION_MANAGER::RunHotKey( int aHotKey ) const
|
|||
std::map<int, TOOL_ACTION*>::const_iterator it = m_actionHotKeys.find( aHotKey );
|
||||
|
||||
if( it == m_actionHotKeys.end() )
|
||||
return false; // no appropriate action found for the hotkey
|
||||
return false; // no appropriate action found for the hotkey
|
||||
|
||||
runAction( it->second );
|
||||
|
||||
|
|
|
@ -88,6 +88,7 @@ void CONTEXT_MENU::SetTitle( const wxString& aTitle )
|
|||
void CONTEXT_MENU::Add( const wxString& aLabel, int aId )
|
||||
{
|
||||
#ifdef DEBUG
|
||||
|
||||
if( m_menu.FindItem( aId ) != NULL )
|
||||
wxLogWarning( wxT( "Adding more than one menu entry with the same ID may result in"
|
||||
"undefined behaviour" ) );
|
||||
|
@ -135,13 +136,15 @@ std::string CONTEXT_MENU::getHotKeyDescription( const TOOL_ACTION& aAction ) con
|
|||
|
||||
if( hotkey & MD_ModAlt )
|
||||
description += "ALT+";
|
||||
|
||||
if( hotkey & MD_ModCtrl )
|
||||
description += "CTRL+";
|
||||
|
||||
if( hotkey & MD_ModShift )
|
||||
description += "SHIFT+";
|
||||
|
||||
// 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;
|
||||
}
|
||||
|
|
|
@ -25,13 +25,13 @@
|
|||
#include <tool/tool_event.h>
|
||||
#include <tool/tool_manager.h>
|
||||
|
||||
KiGfx::VIEW* TOOL_BASE::getView() const
|
||||
KIGFX::VIEW* TOOL_BASE::getView() const
|
||||
{
|
||||
return m_toolMgr->GetView();
|
||||
}
|
||||
|
||||
|
||||
KiGfx::VIEW_CONTROLS* TOOL_BASE::getViewControls() const
|
||||
KIGFX::VIEW_CONTROLS* TOOL_BASE::getViewControls() const
|
||||
{
|
||||
return m_toolMgr->GetViewControls();
|
||||
}
|
||||
|
|
|
@ -111,7 +111,7 @@ void TOOL_DISPATCHER::ResetState()
|
|||
}
|
||||
|
||||
|
||||
KiGfx::VIEW* TOOL_DISPATCHER::getView()
|
||||
KIGFX::VIEW* TOOL_DISPATCHER::getView()
|
||||
{
|
||||
return m_editFrame->GetGalCanvas()->GetView();
|
||||
}
|
||||
|
@ -139,7 +139,7 @@ bool TOOL_DISPATCHER::handleMouseButton( wxEvent& aEvent, int aIndex, bool aMoti
|
|||
st->pressed = true;
|
||||
evt = TOOL_EVENT( TC_Mouse, TA_MouseDown, args );
|
||||
}
|
||||
else if( up ) // Handle mouse button release
|
||||
else if( up ) // Handle mouse button release
|
||||
{
|
||||
st->pressed = false;
|
||||
|
||||
|
@ -166,7 +166,8 @@ bool TOOL_DISPATCHER::handleMouseButton( wxEvent& aEvent, int aIndex, bool aMoti
|
|||
if( st->pressed && aMotion )
|
||||
{
|
||||
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 );
|
||||
|
||||
wxLongLong t = wxGetLocalTimeMillis();
|
||||
|
@ -200,17 +201,17 @@ void TOOL_DISPATCHER::DispatchWxEvent( wxEvent& aEvent )
|
|||
|
||||
// Mouse handling
|
||||
if( type == wxEVT_MOTION || type == wxEVT_MOUSEWHEEL ||
|
||||
type == wxEVT_LEFT_DOWN || type == wxEVT_LEFT_UP ||
|
||||
type == wxEVT_MIDDLE_DOWN || type == wxEVT_MIDDLE_UP ||
|
||||
type == wxEVT_RIGHT_DOWN || type == wxEVT_RIGHT_UP ||
|
||||
// Event issued whem mouse retains position in screen coordinates,
|
||||
// but changes in world coordinates (eg. autopanning)
|
||||
type == KiGfx::WX_VIEW_CONTROLS::EVT_REFRESH_MOUSE )
|
||||
type == wxEVT_LEFT_DOWN || type == wxEVT_LEFT_UP ||
|
||||
type == wxEVT_MIDDLE_DOWN || type == wxEVT_MIDDLE_UP ||
|
||||
type == wxEVT_RIGHT_DOWN || type == wxEVT_RIGHT_UP ||
|
||||
// Event issued whem mouse retains position in screen coordinates,
|
||||
// but changes in world coordinates (eg. autopanning)
|
||||
type == KIGFX::WX_VIEW_CONTROLS::EVT_REFRESH_MOUSE )
|
||||
{
|
||||
VECTOR2D screenPos = m_toolMgr->GetViewControls()->GetCursorPosition();
|
||||
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;
|
||||
m_lastMousePos = pos;
|
||||
|
@ -235,7 +236,7 @@ void TOOL_DISPATCHER::DispatchWxEvent( wxEvent& aEvent )
|
|||
|
||||
if( type == wxEVT_KEY_UP )
|
||||
{
|
||||
if( key == WXK_ESCAPE ) // ESC is the special key for cancelling tools
|
||||
if( key == WXK_ESCAPE ) // ESC is the special key for cancelling tools
|
||||
evt = TOOL_EVENT( TC_Command, TA_CancelTool );
|
||||
else
|
||||
evt = TOOL_EVENT( TC_Keyboard, TA_KeyUp, key | mods );
|
||||
|
@ -262,14 +263,15 @@ void TOOL_DISPATCHER::DispatchWxCommand( const wxCommandEvent& aEvent )
|
|||
// fixme: use TOOL_ACTIONs here
|
||||
switch( aEvent.GetId() )
|
||||
{
|
||||
case ID_PNS_ROUTER_TOOL:
|
||||
toolName = "pcbnew.InteractiveRouter";
|
||||
activateTool = true;
|
||||
break;
|
||||
case ID_SELECTION_TOOL:
|
||||
toolName = "pcbnew.InteractiveSelection";
|
||||
activateTool = true;
|
||||
break;
|
||||
case ID_PNS_ROUTER_TOOL:
|
||||
toolName = "pcbnew.InteractiveRouter";
|
||||
activateTool = true;
|
||||
break;
|
||||
|
||||
case ID_SELECTION_TOOL:
|
||||
toolName = "pcbnew.InteractiveSelection";
|
||||
activateTool = true;
|
||||
break;
|
||||
}
|
||||
|
||||
// do nothing if the legacy view is active
|
||||
|
|
|
@ -64,49 +64,53 @@ const std::string TOOL_EVENT::Format() const
|
|||
{
|
||||
std::string ev;
|
||||
|
||||
const FlagString categories[] = {
|
||||
{ TC_Mouse, "mouse" },
|
||||
const FlagString categories[] =
|
||||
{
|
||||
{ TC_Mouse, "mouse" },
|
||||
{ TC_Keyboard, "keyboard" },
|
||||
{ TC_Command, "command" },
|
||||
{ TC_Message, "message" },
|
||||
{ TC_View, "view" },
|
||||
{ 0, "" }
|
||||
{ TC_Command, "command" },
|
||||
{ TC_Message, "message" },
|
||||
{ TC_View, "view" },
|
||||
{ 0, "" }
|
||||
};
|
||||
|
||||
const FlagString actions[] = {
|
||||
{ TA_MouseClick, "click" },
|
||||
{ TA_MouseUp, "button-up" },
|
||||
{ TA_MouseDown, "button-down" },
|
||||
{ TA_MouseDrag, "drag" },
|
||||
{ TA_MouseMotion, "motion" },
|
||||
{ TA_MouseWheel, "wheel" },
|
||||
{ TA_KeyUp, "key-up" },
|
||||
{ TA_KeyDown, "key-down" },
|
||||
{ TA_ViewRefresh, "view-refresh" },
|
||||
{ TA_ViewZoom, "view-zoom" },
|
||||
{ TA_ViewPan, "view-pan" },
|
||||
{ TA_ViewDirty, "view-dirty" },
|
||||
{ TA_ChangeLayer, "change-layer" },
|
||||
{ TA_CancelTool, "cancel-tool" },
|
||||
const FlagString actions[] =
|
||||
{
|
||||
{ TA_MouseClick, "click" },
|
||||
{ TA_MouseUp, "button-up" },
|
||||
{ TA_MouseDown, "button-down" },
|
||||
{ TA_MouseDrag, "drag" },
|
||||
{ TA_MouseMotion, "motion" },
|
||||
{ TA_MouseWheel, "wheel" },
|
||||
{ TA_KeyUp, "key-up" },
|
||||
{ TA_KeyDown, "key-down" },
|
||||
{ TA_ViewRefresh, "view-refresh" },
|
||||
{ TA_ViewZoom, "view-zoom" },
|
||||
{ TA_ViewPan, "view-pan" },
|
||||
{ TA_ViewDirty, "view-dirty" },
|
||||
{ TA_ChangeLayer, "change-layer" },
|
||||
{ TA_CancelTool, "cancel-tool" },
|
||||
{ TA_ContextMenuUpdate, "context-menu-update" },
|
||||
{ TA_ContextMenuChoice, "context-menu-choice" },
|
||||
{ TA_Action, "action" },
|
||||
{ 0, "" }
|
||||
{ TA_Action, "action" },
|
||||
{ 0, "" }
|
||||
};
|
||||
|
||||
const FlagString buttons[] = {
|
||||
{ MB_None, "none" },
|
||||
{ MB_Left, "left" },
|
||||
{ MB_Right, "right" },
|
||||
const FlagString buttons[] =
|
||||
{
|
||||
{ MB_None, "none" },
|
||||
{ MB_Left, "left" },
|
||||
{ MB_Right, "right" },
|
||||
{ MB_Middle, "middle" },
|
||||
{ 0, "" }
|
||||
{ 0, "" }
|
||||
};
|
||||
|
||||
const FlagString modifiers[] = {
|
||||
const FlagString modifiers[] =
|
||||
{
|
||||
{ MD_ModShift, "shift" },
|
||||
{ MD_ModCtrl, "ctrl" },
|
||||
{ MD_ModAlt, "alt" },
|
||||
{ 0, "" }
|
||||
{ MD_ModCtrl, "ctrl" },
|
||||
{ MD_ModAlt, "alt" },
|
||||
{ 0, "" }
|
||||
};
|
||||
|
||||
ev = "category: ";
|
||||
|
|
|
@ -31,12 +31,14 @@
|
|||
|
||||
TOOL_INTERACTIVE::TOOL_INTERACTIVE( TOOL_ID aId, const std::string& aName ) :
|
||||
TOOL_BASE( TOOL_Interactive, aId, aName )
|
||||
{};
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
TOOL_INTERACTIVE::TOOL_INTERACTIVE( const std::string& aName ) :
|
||||
TOOL_BASE( TOOL_Interactive, TOOL_MANAGER::MakeToolId( aName ), aName )
|
||||
{};
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
TOOL_INTERACTIVE::~TOOL_INTERACTIVE()
|
||||
|
|
|
@ -85,12 +85,12 @@ struct TOOL_MANAGER::TOOL_STATE
|
|||
|
||||
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
|
||||
{
|
||||
return ( aRhs.theTool != this->theTool );
|
||||
return aRhs.theTool != this->theTool;
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -137,6 +137,7 @@ void TOOL_MANAGER::RegisterTool( TOOL_BASE* aTool )
|
|||
if( aTool->GetType() == TOOL_Interactive )
|
||||
{
|
||||
bool initState = static_cast<TOOL_INTERACTIVE*>( aTool )->Init();
|
||||
|
||||
if( !initState )
|
||||
{
|
||||
wxLogError( wxT( "Initialization of the %s tool failed" ), aTool->GetName().c_str() );
|
||||
|
@ -232,6 +233,7 @@ bool TOOL_MANAGER::runTool( TOOL_BASE* aTool )
|
|||
// If the tool is already active, do not invoke it again
|
||||
if( state->idle == false )
|
||||
return false;
|
||||
|
||||
state->idle = false;
|
||||
|
||||
static_cast<TOOL_INTERACTIVE*>( aTool )->Reset();
|
||||
|
@ -269,6 +271,7 @@ void TOOL_MANAGER::ScheduleNextState( TOOL_BASE* aTool, TOOL_STATE_FUNC& aHandle
|
|||
const TOOL_EVENT_LIST& aConditions )
|
||||
{
|
||||
TOOL_STATE* st = m_toolState[aTool];
|
||||
|
||||
st->transitions.push_back( TRANSITION( aConditions, aHandler ) );
|
||||
}
|
||||
|
||||
|
@ -309,8 +312,9 @@ void TOOL_MANAGER::dispatchInternal( TOOL_EVENT& aEvent )
|
|||
st->wakeupEvent = aEvent;
|
||||
st->pendingWait = false;
|
||||
st->waitEvents.clear();
|
||||
|
||||
if( st->cofunc && !st->cofunc->Resume() )
|
||||
finishTool( st ); // The couroutine has finished
|
||||
finishTool( st ); // The couroutine has finished
|
||||
|
||||
// If the tool did not request to propagate
|
||||
// the event to other tools, we should stop it now
|
||||
|
@ -345,7 +349,7 @@ void TOOL_MANAGER::dispatchInternal( TOOL_EVENT& aEvent )
|
|||
st->cofunc->Call( aEvent );
|
||||
|
||||
if( !st->cofunc->Running() )
|
||||
finishTool( st ); // The couroutine has finished immediately?
|
||||
finishTool( st ); // The couroutine has finished immediately?
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -360,9 +364,9 @@ bool TOOL_MANAGER::dispatchStandardEvents( TOOL_EVENT& aEvent )
|
|||
{
|
||||
// Check if there is a hotkey associated
|
||||
if( m_actionMgr->RunHotKey( aEvent.Modifier() | aEvent.KeyCode() ) )
|
||||
return false; // hotkey event was handled so it does not go any further
|
||||
return false; // hotkey event was handled so it does not go any further
|
||||
}
|
||||
else if( aEvent.Category() == TC_Command ) // it may be a tool activation event
|
||||
else if( aEvent.Category() == TC_Command ) // it may be a tool activation event
|
||||
{
|
||||
dispatchActivation( aEvent );
|
||||
// do not return false, as the event has to go on to the destined tool
|
||||
|
@ -392,6 +396,7 @@ void TOOL_MANAGER::finishTool( TOOL_STATE* aState )
|
|||
{
|
||||
// Find the tool to be deactivated
|
||||
std::deque<TOOL_ID>::iterator it, it_end;
|
||||
|
||||
for( it = m_activeTools.begin(), it_end = m_activeTools.end(); it != it_end; ++it )
|
||||
{
|
||||
if( aState == m_toolIdIndex[*it] )
|
||||
|
@ -411,7 +416,7 @@ void TOOL_MANAGER::finishTool( TOOL_STATE* aState )
|
|||
|
||||
bool TOOL_MANAGER::ProcessEvent( TOOL_EVENT& aEvent )
|
||||
{
|
||||
// wxLogDebug( "event: %s", aEvent.Format().c_str() );
|
||||
// wxLogDebug( "event: %s", aEvent.Format().c_str() );
|
||||
|
||||
// Early dispatch of events destined for the TOOL_MANAGER
|
||||
if( !dispatchStandardEvents( aEvent ) )
|
||||
|
@ -451,7 +456,7 @@ bool TOOL_MANAGER::ProcessEvent( TOOL_EVENT& aEvent )
|
|||
if( m_view->IsDirty() )
|
||||
{
|
||||
PCB_EDIT_FRAME* f = static_cast<PCB_EDIT_FRAME*>( GetEditFrame() );
|
||||
f->GetGalCanvas()->Refresh(); // fixme: ugly hack, provide a method in TOOL_DISPATCHER.
|
||||
f->GetGalCanvas()->Refresh(); // fixme: ugly hack, provide a method in TOOL_DISPATCHER.
|
||||
}
|
||||
|
||||
return false;
|
||||
|
@ -475,12 +480,13 @@ void TOOL_MANAGER::ScheduleContextMenu( TOOL_BASE* aTool, CONTEXT_MENU* aMenu,
|
|||
TOOL_ID TOOL_MANAGER::MakeToolId( const std::string& aToolName )
|
||||
{
|
||||
static int currentId;
|
||||
|
||||
return currentId++;
|
||||
}
|
||||
|
||||
|
||||
void TOOL_MANAGER::SetEnvironment( EDA_ITEM* aModel, KiGfx::VIEW* aView,
|
||||
KiGfx::VIEW_CONTROLS* aViewControls, wxWindow* aFrame )
|
||||
void TOOL_MANAGER::SetEnvironment( EDA_ITEM* aModel, KIGFX::VIEW* aView,
|
||||
KIGFX::VIEW_CONTROLS* aViewControls, wxWindow* aFrame )
|
||||
{
|
||||
m_model = aModel;
|
||||
m_view = aView;
|
||||
|
|
|
@ -38,7 +38,7 @@
|
|||
#include <profile.h>
|
||||
#endif /* __WXDEBUG__ */
|
||||
|
||||
using namespace KiGfx;
|
||||
using namespace KIGFX;
|
||||
|
||||
VIEW::VIEW( bool aIsDynamic ) :
|
||||
m_enableOrderModifier( true ),
|
||||
|
@ -348,7 +348,7 @@ void VIEW::SetLayerOrder( int aLayer, int aRenderingOrder )
|
|||
|
||||
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
|
|||
struct VIEW::updateItemsColor
|
||||
{
|
||||
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 )
|
|||
m_layers[aLayer].items->Query( r, visitor );
|
||||
}
|
||||
|
||||
int VIEW::GetTopLayer( ) const
|
||||
|
||||
int VIEW::GetTopLayer() const
|
||||
{
|
||||
if( m_topLayers.size() == 0 )
|
||||
return 0;
|
||||
|
@ -512,10 +513,13 @@ void VIEW::SetTopLayer( int aLayer, bool aEnabled )
|
|||
|
||||
void VIEW::EnableTopLayer( bool aEnable )
|
||||
{
|
||||
if( aEnable == m_enableOrderModifier ) return;
|
||||
if( aEnable == m_enableOrderModifier )
|
||||
return;
|
||||
|
||||
m_enableOrderModifier = aEnable;
|
||||
|
||||
std::set<unsigned int>::iterator it;
|
||||
|
||||
if( aEnable )
|
||||
{
|
||||
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
|
|||
{
|
||||
group = m_gal->BeginGroup();
|
||||
aItem->setGroup( aLayer, group );
|
||||
|
||||
if( !m_painter->Draw( aItem, aLayer ) )
|
||||
aItem->ViewDraw( aLayer, m_gal ); // Alternative drawing method
|
||||
|
||||
m_gal->EndGroup();
|
||||
}
|
||||
}
|
||||
|
@ -648,6 +654,7 @@ void VIEW::draw( VIEW_ITEM* aItem, bool aImmediate ) const
|
|||
void VIEW::draw( VIEW_GROUP* aGroup, bool aImmediate ) const
|
||||
{
|
||||
std::set<VIEW_ITEM*>::const_iterator it;
|
||||
|
||||
for( it = aGroup->Begin(); it != aGroup->End(); ++it )
|
||||
{
|
||||
draw( *it, aImmediate );
|
||||
|
@ -687,6 +694,7 @@ struct VIEW::recacheItem
|
|||
{
|
||||
// Remove previously cached group
|
||||
int prevGroup = aItem->getGroup( layer );
|
||||
|
||||
if( prevGroup >= 0 )
|
||||
gal->DeleteGroup( prevGroup );
|
||||
|
||||
|
@ -694,8 +702,10 @@ struct VIEW::recacheItem
|
|||
{
|
||||
int group = gal->BeginGroup();
|
||||
aItem->setGroup( layer, group );
|
||||
|
||||
if( !view->m_painter->Draw( aItem, layer ) )
|
||||
aItem->ViewDraw( layer, gal ); // Alternative drawing method
|
||||
|
||||
gal->EndGroup();
|
||||
}
|
||||
else
|
||||
|
@ -803,7 +813,7 @@ void VIEW::clearGroupCache()
|
|||
|
||||
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 );
|
||||
}
|
||||
}
|
||||
|
@ -881,6 +891,7 @@ void VIEW::updateItemGeometry( VIEW_ITEM* aItem, int aLayer )
|
|||
|
||||
// Redraw the item from scratch
|
||||
int prevGroup = aItem->getGroup( aLayer );
|
||||
|
||||
if( prevGroup >= 0 )
|
||||
m_gal->DeleteGroup( prevGroup );
|
||||
|
||||
|
@ -894,6 +905,7 @@ void VIEW::updateItemGeometry( VIEW_ITEM* aItem, int aLayer )
|
|||
void VIEW::updateBbox( VIEW_ITEM* aItem )
|
||||
{
|
||||
int layers[VIEW_MAX_LAYERS], layers_count;
|
||||
|
||||
aItem->ViewGetLayers( layers, layers_count );
|
||||
|
||||
for( int i = 0; i < layers_count; i++ )
|
||||
|
@ -912,6 +924,7 @@ void VIEW::updateLayers( VIEW_ITEM* aItem )
|
|||
|
||||
// Remove the item from previous layer set
|
||||
aItem->getLayers( layers, layers_count );
|
||||
|
||||
for( int i = 0; i < layers_count; i++ )
|
||||
{
|
||||
VIEW_LAYER& l = m_layers[layers[i]];
|
||||
|
@ -922,6 +935,7 @@ void VIEW::updateLayers( VIEW_ITEM* aItem )
|
|||
// Add the item to new layer set
|
||||
aItem->ViewGetLayers( layers, layers_count );
|
||||
aItem->saveLayers( layers, layers_count );
|
||||
|
||||
for( int i = 0; i < layers_count; i++ )
|
||||
{
|
||||
VIEW_LAYER& l = m_layers[layers[i]];
|
||||
|
@ -938,7 +952,7 @@ bool VIEW::areRequiredLayersEnabled( int aLayerId ) const
|
|||
std::set<int>::iterator it, it_end;
|
||||
|
||||
for( it = m_layers.at( aLayerId ).requiredLayers.begin(),
|
||||
it_end = m_layers.at( aLayerId ).requiredLayers.end(); it != it_end; ++it )
|
||||
it_end = m_layers.at( aLayerId ).requiredLayers.end(); it != it_end; ++it )
|
||||
{
|
||||
// That is enough if just one layer is not enabled
|
||||
if( !m_layers.at( *it ).enabled )
|
||||
|
|
|
@ -39,10 +39,10 @@
|
|||
#include <boost/foreach.hpp>
|
||||
#include <layers_id_colors_and_visibility.h>
|
||||
|
||||
using namespace KiGfx;
|
||||
using namespace KIGFX;
|
||||
|
||||
VIEW_GROUP::VIEW_GROUP( VIEW* aView ) :
|
||||
m_layer( ITEM_GAL_LAYER( GP_OVERLAY ) )
|
||||
m_layer( ITEM_GAL_LAYER( GP_OVERLAY ) )
|
||||
{
|
||||
m_view = aView;
|
||||
}
|
||||
|
@ -80,6 +80,7 @@ unsigned int VIEW_GROUP::GetSize() const
|
|||
const BOX2I VIEW_GROUP::ViewBBox() const
|
||||
{
|
||||
BOX2I maxBox;
|
||||
|
||||
maxBox.SetMaximum();
|
||||
return maxBox;
|
||||
}
|
||||
|
@ -105,7 +106,7 @@ void VIEW_GROUP::ViewDraw( int aLayer, GAL* aGal ) const
|
|||
aGal->AdvanceDepth();
|
||||
|
||||
if( !painter->Draw( item, layers[i] ) )
|
||||
item->ViewDraw( layers[i], aGal ); // Alternative drawing method
|
||||
item->ViewDraw( layers[i], aGal ); // Alternative drawing method
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -27,7 +27,7 @@
|
|||
#include <view/view_item.h>
|
||||
#include <view/view.h>
|
||||
|
||||
using namespace KiGfx;
|
||||
using namespace KIGFX;
|
||||
|
||||
void VIEW_ITEM::ViewSetVisible( bool aIsVisible )
|
||||
{
|
||||
|
@ -69,6 +69,7 @@ void VIEW_ITEM::ViewRelease()
|
|||
void VIEW_ITEM::getLayers( int* aLayers, int& aCount ) const
|
||||
{
|
||||
int* layersPtr = aLayers;
|
||||
|
||||
for( unsigned int i = 0; i < m_layers.size(); ++i )
|
||||
{
|
||||
if( m_layers[i] )
|
||||
|
|
|
@ -30,7 +30,7 @@
|
|||
#include <gal/graphics_abstraction_layer.h>
|
||||
#include <tool/tool_dispatcher.h>
|
||||
|
||||
using namespace KiGfx;
|
||||
using namespace KIGFX;
|
||||
|
||||
const wxEventType WX_VIEW_CONTROLS::EVT_REFRESH_MOUSE = wxNewEventType();
|
||||
|
||||
|
@ -40,25 +40,25 @@ WX_VIEW_CONTROLS::WX_VIEW_CONTROLS( VIEW* aView, wxWindow* aParentPanel ) :
|
|||
m_parentPanel( aParentPanel )
|
||||
{
|
||||
m_parentPanel->Connect( wxEVT_MOTION, wxMouseEventHandler(
|
||||
WX_VIEW_CONTROLS::onMotion ), NULL, this );
|
||||
WX_VIEW_CONTROLS::onMotion ), NULL, this );
|
||||
m_parentPanel->Connect( wxEVT_MOUSEWHEEL, wxMouseEventHandler(
|
||||
WX_VIEW_CONTROLS::onWheel ), NULL, this );
|
||||
WX_VIEW_CONTROLS::onWheel ), NULL, this );
|
||||
m_parentPanel->Connect( wxEVT_MIDDLE_UP, wxMouseEventHandler(
|
||||
WX_VIEW_CONTROLS::onButton ), NULL, this );
|
||||
WX_VIEW_CONTROLS::onButton ), NULL, this );
|
||||
m_parentPanel->Connect( wxEVT_MIDDLE_DOWN, wxMouseEventHandler(
|
||||
WX_VIEW_CONTROLS::onButton ), NULL, this );
|
||||
WX_VIEW_CONTROLS::onButton ), NULL, this );
|
||||
m_parentPanel->Connect( wxEVT_LEFT_UP, wxMouseEventHandler(
|
||||
WX_VIEW_CONTROLS::onButton ), NULL, this );
|
||||
WX_VIEW_CONTROLS::onButton ), NULL, this );
|
||||
m_parentPanel->Connect( wxEVT_LEFT_DOWN, wxMouseEventHandler(
|
||||
WX_VIEW_CONTROLS::onButton ), NULL, this );
|
||||
WX_VIEW_CONTROLS::onButton ), NULL, this );
|
||||
#if defined _WIN32 || defined _WIN64
|
||||
m_parentPanel->Connect( wxEVT_ENTER_WINDOW, wxMouseEventHandler(
|
||||
WX_VIEW_CONTROLS::onEnter ), NULL, this );
|
||||
WX_VIEW_CONTROLS::onEnter ), NULL, this );
|
||||
#endif
|
||||
|
||||
m_panTimer.SetOwner( this );
|
||||
this->Connect( wxEVT_TIMER, wxTimerEventHandler(
|
||||
WX_VIEW_CONTROLS::onTimer ), NULL, this );
|
||||
WX_VIEW_CONTROLS::onTimer ), NULL, this );
|
||||
}
|
||||
|
||||
|
||||
|
@ -133,7 +133,7 @@ void WX_VIEW_CONTROLS::onWheel( wxMouseEvent& aEvent )
|
|||
double timeDiff = timeStamp.ToDouble() - m_timeStamp.ToDouble();
|
||||
|
||||
m_timeStamp = timeStamp;
|
||||
double zoomScale;
|
||||
double zoomScale;
|
||||
|
||||
// Set scaling speed depending on scroll wheel event interval
|
||||
if( timeDiff < 500 && timeDiff > 0 )
|
||||
|
@ -171,6 +171,7 @@ void WX_VIEW_CONTROLS::onButton( wxMouseEvent& aEvent )
|
|||
{
|
||||
m_state = IDLE; // Stop autopanning when user release left mouse button
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
case DRAG_PANNING:
|
||||
|
@ -178,6 +179,7 @@ void WX_VIEW_CONTROLS::onButton( wxMouseEvent& aEvent )
|
|||
{
|
||||
m_state = IDLE;
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -214,7 +216,7 @@ void WX_VIEW_CONTROLS::onTimer( wxTimerEvent& aEvent )
|
|||
}
|
||||
break;
|
||||
|
||||
case IDLE: // Just remove unnecessary warnings
|
||||
case IDLE: // Just remove unnecessary warnings
|
||||
case DRAG_PANNING:
|
||||
break;
|
||||
}
|
||||
|
@ -284,6 +286,7 @@ bool WX_VIEW_CONTROLS::handleAutoPanning( const wxMouseEvent& aEvent )
|
|||
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
break;
|
||||
|
||||
|
@ -295,6 +298,7 @@ bool WX_VIEW_CONTROLS::handleAutoPanning( const wxMouseEvent& aEvent )
|
|||
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
break;
|
||||
|
||||
|
@ -303,5 +307,5 @@ bool WX_VIEW_CONTROLS::handleAutoPanning( const wxMouseEvent& aEvent )
|
|||
}
|
||||
|
||||
wxASSERT_MSG( false, wxT( "This line should never be reached" ) );
|
||||
return false; // Should not be reached, just avoid the compiler warnings..
|
||||
return false; // Should not be reached, just avoid the compiler warnings..
|
||||
}
|
||||
|
|
|
@ -34,7 +34,7 @@
|
|||
#include <layers_id_colors_and_visibility.h>
|
||||
#include <boost/foreach.hpp>
|
||||
|
||||
using namespace KiGfx;
|
||||
using namespace KIGFX;
|
||||
|
||||
WORKSHEET_VIEWITEM::WORKSHEET_VIEWITEM( const std::string& aFileName, const std::string& aSheetName,
|
||||
const PAGE_INFO* aPageInfo, const TITLE_BLOCK* aTitleBlock ) :
|
||||
|
|
|
@ -197,8 +197,8 @@ void EDA_DRAW_FRAME::OnZoom( wxCommandEvent& event )
|
|||
if( m_galCanvasActive )
|
||||
{
|
||||
// Apply computed view settings to GAL
|
||||
KiGfx::VIEW* view = m_galCanvas->GetView();
|
||||
KiGfx::GAL* gal = m_galCanvas->GetGAL();
|
||||
KIGFX::VIEW* view = m_galCanvas->GetView();
|
||||
KIGFX::GAL* gal = m_galCanvas->GetGAL();
|
||||
|
||||
double zoomFactor = gal->GetWorldScale() / gal->GetZoomFactor();
|
||||
double zoom = 1.0 / ( zoomFactor * GetZoom() );
|
||||
|
|
|
@ -301,7 +301,7 @@ typedef unsigned STATUS_FLAGS;
|
|||
* is a base class for most all the KiCad significant classes, used in
|
||||
* schematics and boards.
|
||||
*/
|
||||
class EDA_ITEM : public KiGfx::VIEW_ITEM
|
||||
class EDA_ITEM : public KIGFX::VIEW_ITEM
|
||||
{
|
||||
private:
|
||||
|
||||
|
|
|
@ -38,7 +38,7 @@
|
|||
class BOARD;
|
||||
class TOOL_DISPATCHER;
|
||||
|
||||
namespace KiGfx
|
||||
namespace KIGFX
|
||||
{
|
||||
class GAL;
|
||||
class VIEW;
|
||||
|
@ -73,7 +73,7 @@ public:
|
|||
* Returns a pointer to the GAL instance used in the panel.
|
||||
* @return The instance of GAL.
|
||||
*/
|
||||
KiGfx::GAL* GetGAL() const
|
||||
KIGFX::GAL* GetGAL() const
|
||||
{
|
||||
return m_gal;
|
||||
}
|
||||
|
@ -83,7 +83,7 @@ public:
|
|||
* Returns a pointer to the VIEW instance used in the panel.
|
||||
* @return The instance of VIEW.
|
||||
*/
|
||||
KiGfx::VIEW* GetView() const
|
||||
KIGFX::VIEW* GetView() const
|
||||
{
|
||||
return m_view;
|
||||
}
|
||||
|
@ -93,9 +93,9 @@ public:
|
|||
* Returns a pointer to the VIEW_CONTROLS instance used in the panel.
|
||||
* @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()
|
||||
|
@ -125,12 +125,12 @@ protected:
|
|||
bool m_pendingRefresh;
|
||||
wxTimer m_refreshTimer;
|
||||
|
||||
KiGfx::GAL* m_gal; ///< Interface for drawing objects on a 2D-surface
|
||||
KiGfx::VIEW* m_view; ///< Stores view settings (scale, center, etc.)
|
||||
KIGFX::GAL* m_gal; ///< Interface for drawing objects on a 2D-surface
|
||||
KIGFX::VIEW* m_view; ///< Stores view settings (scale, center, etc.)
|
||||
///< 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
|
||||
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
|
||||
TOOL_DISPATCHER* m_eventDispatcher; ///< Processes and forwards events to tools
|
||||
};
|
||||
|
|
|
@ -36,7 +36,7 @@
|
|||
#include <boost/smart_ptr/shared_array.hpp>
|
||||
#include <deque>
|
||||
|
||||
namespace KiGfx
|
||||
namespace KIGFX
|
||||
{
|
||||
class CAIRO_COMPOSITOR : public COMPOSITOR
|
||||
{
|
||||
|
@ -122,6 +122,6 @@ protected:
|
|||
return m_buffers.size();
|
||||
}
|
||||
};
|
||||
} // namespace KiGfx
|
||||
} // namespace KIGFX
|
||||
|
||||
#endif /* COMPOSITOR_H_ */
|
||||
|
|
|
@ -40,9 +40,9 @@
|
|||
#define SCREEN_DEPTH 24
|
||||
#else
|
||||
#if wxCHECK_VERSION( 2, 9, 0 )
|
||||
#define SCREEN_DEPTH wxBITMAP_SCREEN_DEPTH
|
||||
#define SCREEN_DEPTH wxBITMAP_SCREEN_DEPTH
|
||||
#else
|
||||
#define SCREEN_DEPTH 32
|
||||
#define SCREEN_DEPTH 32
|
||||
#endif
|
||||
#endif
|
||||
|
||||
|
@ -58,7 +58,7 @@
|
|||
* of KiCad graphics surfaces as well.
|
||||
*
|
||||
*/
|
||||
namespace KiGfx
|
||||
namespace KIGFX
|
||||
{
|
||||
class CAIRO_COMPOSITOR;
|
||||
|
||||
|
@ -126,7 +126,7 @@ public:
|
|||
// --------------
|
||||
|
||||
/// @brief Resizes the canvas.
|
||||
virtual void ResizeScreen ( int aWidth, int aHeight );
|
||||
virtual void ResizeScreen( int aWidth, int aHeight );
|
||||
|
||||
/// @brief Shows/hides the GAL canvas
|
||||
virtual bool Show( bool aShow );
|
||||
|
@ -386,6 +386,6 @@ private:
|
|||
/// Format used to store pixels
|
||||
static const cairo_format_t GAL_FORMAT = CAIRO_FORMAT_RGB24;
|
||||
};
|
||||
} // namespace KiGfx
|
||||
} // namespace KIGFX
|
||||
|
||||
#endif // CAIROGAL_H_
|
||||
#endif // CAIROGAL_H_
|
||||
|
|
|
@ -30,7 +30,7 @@
|
|||
#include <colors.h>
|
||||
#include <cassert>
|
||||
|
||||
namespace KiGfx
|
||||
namespace KIGFX
|
||||
{
|
||||
/**
|
||||
* Class COLOR4D
|
||||
|
@ -182,7 +182,7 @@ public:
|
|||
double GetBrightness() const
|
||||
{
|
||||
// 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:
|
|||
double b; ///< Blue component
|
||||
double a; ///< Alpha component
|
||||
};
|
||||
} // namespace KiGfx
|
||||
} // namespace KIGFX
|
||||
|
||||
#endif /* COLOR4D_H_ */
|
||||
|
|
|
@ -31,7 +31,7 @@
|
|||
#ifndef COMPOSITOR_H_
|
||||
#define COMPOSITOR_H_
|
||||
|
||||
namespace KiGfx
|
||||
namespace KIGFX
|
||||
{
|
||||
|
||||
class COMPOSITOR
|
||||
|
@ -101,6 +101,6 @@ protected:
|
|||
unsigned int m_height; ///< Height of the buffer (in pixels)
|
||||
};
|
||||
|
||||
} // namespace KiGfx
|
||||
} // namespace KIGFX
|
||||
|
||||
#endif /* COMPOSITOR_H_ */
|
||||
|
|
|
@ -31,18 +31,18 @@
|
|||
#define SWAP( varA, condition, varB ) if( varA condition varB ) { double tmp = varA; varA = varB; \
|
||||
varB = tmp; }
|
||||
|
||||
namespace KiGfx
|
||||
namespace KIGFX
|
||||
{
|
||||
/**
|
||||
* RenderTarget: Possible rendering targets
|
||||
*/
|
||||
enum RenderTarget
|
||||
{
|
||||
TARGET_CACHED = 0, ///< Main rendering target (cached)
|
||||
TARGET_NONCACHED, ///< Auxiliary rendering target (noncached)
|
||||
TARGET_OVERLAY, ///< Items that may change while the view stays the same (noncached)
|
||||
TARGETS_NUMBER ///< Number of available rendering targets
|
||||
};
|
||||
}
|
||||
/**
|
||||
* RenderTarget: Possible rendering targets
|
||||
*/
|
||||
enum RenderTarget
|
||||
{
|
||||
TARGET_CACHED = 0, ///< Main rendering target (cached)
|
||||
TARGET_NONCACHED, ///< Auxiliary rendering target (noncached)
|
||||
TARGET_OVERLAY, ///< Items that may change while the view stays the same (noncached)
|
||||
TARGETS_NUMBER ///< Number of available rendering targets
|
||||
};
|
||||
} // namespace KIGFX
|
||||
|
||||
#endif /* DEFINITIONS_H_ */
|
||||
|
|
|
@ -40,7 +40,7 @@
|
|||
#include <gal/stroke_font.h>
|
||||
#include <newstroke_font.h>
|
||||
|
||||
namespace KiGfx
|
||||
namespace KIGFX
|
||||
{
|
||||
/**
|
||||
* GridStyle: Type definition of the grid style
|
||||
|
@ -891,6 +891,6 @@ protected:
|
|||
static const int MIN_DEPTH = -2048;
|
||||
static const int MAX_DEPTH = 2047;
|
||||
};
|
||||
} // namespace KiGfx
|
||||
} // namespace KIGFX
|
||||
|
||||
#endif /* GRAPHICSABSTRACTIONLAYER_H_ */
|
||||
|
|
|
@ -37,9 +37,9 @@
|
|||
#include <set>
|
||||
|
||||
// Debug messages verbosity level
|
||||
//#define CACHED_CONTAINER_TEST 1
|
||||
// #define CACHED_CONTAINER_TEST 1
|
||||
|
||||
namespace KiGfx
|
||||
namespace KIGFX
|
||||
{
|
||||
class VERTEX_ITEM;
|
||||
class SHADER;
|
||||
|
@ -173,6 +173,6 @@ private:
|
|||
inline void test() {}
|
||||
#endif /* CACHED_CONTAINER_TEST */
|
||||
};
|
||||
} // namespace KiGfx
|
||||
} // namespace KIGFX
|
||||
|
||||
#endif /* CACHED_CONTAINER_H_ */
|
||||
|
|
|
@ -33,7 +33,7 @@
|
|||
#include <gal/opengl/vertex_common.h>
|
||||
#include <boost/scoped_array.hpp>
|
||||
|
||||
namespace KiGfx
|
||||
namespace KIGFX
|
||||
{
|
||||
class SHADER;
|
||||
class VERTEX_CONTAINER;
|
||||
|
@ -90,14 +90,14 @@ protected:
|
|||
GPU_MANAGER( VERTEX_CONTAINER* aContainer );
|
||||
|
||||
///< Drawing status flag.
|
||||
bool m_isDrawing;
|
||||
bool m_isDrawing;
|
||||
|
||||
///< Container that stores vertices data.
|
||||
VERTEX_CONTAINER* m_container;
|
||||
|
||||
///< Shader handling
|
||||
SHADER* m_shader;
|
||||
int m_shaderAttrib; ///< Location of shader attributes (for glVertexAttribPointer)
|
||||
int m_shaderAttrib; ///< Location of shader attributes (for glVertexAttribPointer)
|
||||
};
|
||||
|
||||
|
||||
|
@ -130,12 +130,11 @@ public:
|
|||
virtual void uploadToGpu();
|
||||
|
||||
protected:
|
||||
bool m_buffersInitialized;
|
||||
bool m_buffersInitialized;
|
||||
boost::scoped_array<GLuint> m_indices;
|
||||
GLuint* m_indicesPtr;
|
||||
GLuint m_verticesBuffer;
|
||||
unsigned int m_indicesSize;
|
||||
|
||||
GLuint* m_indicesPtr;
|
||||
GLuint m_verticesBuffer;
|
||||
unsigned int m_indicesSize;
|
||||
};
|
||||
|
||||
|
||||
|
@ -159,5 +158,5 @@ public:
|
|||
///< @copydoc GPU_MANAGER::EndDrawing()
|
||||
virtual void EndDrawing();
|
||||
};
|
||||
} // namespace KiGfx
|
||||
} // namespace KIGFX
|
||||
#endif /* GPU_MANAGER_H_ */
|
||||
|
|
|
@ -33,7 +33,7 @@
|
|||
|
||||
#include <gal/opengl/vertex_container.h>
|
||||
|
||||
namespace KiGfx
|
||||
namespace KIGFX
|
||||
{
|
||||
class VERTEX_ITEM;
|
||||
class SHADER;
|
||||
|
@ -68,6 +68,6 @@ protected:
|
|||
///< Index of the free first space where a vertex can be stored
|
||||
unsigned int m_freePtr;
|
||||
};
|
||||
} // namespace KiGfx
|
||||
} // namespace KIGFX
|
||||
|
||||
#endif /* NONCACHED_CONTAINER_H_ */
|
||||
|
|
|
@ -35,7 +35,7 @@
|
|||
#include <GL/glew.h>
|
||||
#include <deque>
|
||||
|
||||
namespace KiGfx
|
||||
namespace KIGFX
|
||||
{
|
||||
class OPENGL_COMPOSITOR : public COMPOSITOR
|
||||
{
|
||||
|
@ -105,6 +105,6 @@ protected:
|
|||
return m_buffers.size();
|
||||
}
|
||||
};
|
||||
} // namespace KiGfx
|
||||
} // namespace KIGFX
|
||||
|
||||
#endif /* COMPOSITOR_H_ */
|
||||
|
|
|
@ -57,7 +57,7 @@
|
|||
#define CALLBACK
|
||||
#endif
|
||||
|
||||
namespace KiGfx
|
||||
namespace KIGFX
|
||||
{
|
||||
class SHADER;
|
||||
|
||||
|
@ -253,6 +253,7 @@ public:
|
|||
{
|
||||
/// Manager used for storing new vertices
|
||||
VERTEX_MANAGER* vboManager;
|
||||
|
||||
/// Intersect points, that have to be freed after tessellation
|
||||
std::deque< boost::shared_array<GLdouble> >& intersectPoints;
|
||||
} TessParams;
|
||||
|
@ -377,6 +378,6 @@ private:
|
|||
*/
|
||||
unsigned int getNewGroupNumber();
|
||||
};
|
||||
} // namespace KiGfx
|
||||
} // namespace KIGFX
|
||||
|
||||
#endif // OPENGLGAL_H_
|
||||
#endif // OPENGLGAL_H_
|
||||
|
|
|
@ -34,14 +34,14 @@
|
|||
#include <string>
|
||||
#include <deque>
|
||||
|
||||
namespace KiGfx
|
||||
namespace KIGFX
|
||||
{
|
||||
class OPENGL_GAL;
|
||||
|
||||
/// Type definition for the shader
|
||||
enum ShaderType
|
||||
{
|
||||
SHADER_TYPE_VERTEX = GL_VERTEX_SHADER, ///< Vertex shader
|
||||
SHADER_TYPE_VERTEX = GL_VERTEX_SHADER, ///< Vertex shader
|
||||
SHADER_TYPE_FRAGMENT = GL_FRAGMENT_SHADER, ///< Fragment shader
|
||||
SHADER_TYPE_GEOMETRY = GL_GEOMETRY_SHADER ///< Geometry shader
|
||||
};
|
||||
|
@ -205,6 +205,6 @@ private:
|
|||
GLuint geomOutputType; ///< Output type [e.g. GL_LINES, GL_TRIANGLES, GL_QUADS etc.]
|
||||
std::deque<GLint> parameterLocation; ///< Location of the parameter
|
||||
};
|
||||
} // namespace KiGfx
|
||||
} // namespace KIGFX
|
||||
|
||||
#endif /* SHADER_H_ */
|
||||
|
|
|
@ -32,10 +32,11 @@
|
|||
|
||||
#include <GL/glew.h>
|
||||
|
||||
namespace KiGfx
|
||||
namespace KIGFX
|
||||
{
|
||||
// Possible types of shaders
|
||||
enum SHADER_TYPE {
|
||||
enum SHADER_TYPE
|
||||
{
|
||||
SHADER_NONE = 0,
|
||||
SHADER_LINE,
|
||||
SHADER_FILLED_CIRCLE,
|
||||
|
@ -68,7 +69,6 @@ const unsigned int ShaderSize = sizeof(VERTEX().shader);
|
|||
const unsigned int ShaderStride = ShaderSize / sizeof(GLfloat);
|
||||
|
||||
const unsigned int IndexSize = sizeof(GLuint);
|
||||
|
||||
} // namespace KiGfx
|
||||
} // namespace KIGFX
|
||||
|
||||
#endif /* VERTEX_COMMON_H_ */
|
||||
|
|
|
@ -32,7 +32,7 @@
|
|||
|
||||
#include <gal/opengl/vertex_common.h>
|
||||
|
||||
namespace KiGfx
|
||||
namespace KIGFX
|
||||
{
|
||||
class VERTEX_ITEM;
|
||||
class SHADER;
|
||||
|
@ -45,6 +45,7 @@ public:
|
|||
* Returns a pointer to a new container of an appropriate type.
|
||||
*/
|
||||
static VERTEX_CONTAINER* MakeContainer( bool aCached );
|
||||
|
||||
virtual ~VERTEX_CONTAINER();
|
||||
|
||||
/**
|
||||
|
@ -170,6 +171,6 @@ protected:
|
|||
///< Default initial size of a container (expressed in vertices)
|
||||
static const unsigned int defaultInitSize = 1048576;
|
||||
};
|
||||
} // namespace KiGfx
|
||||
} // namespace KIGFX
|
||||
|
||||
#endif /* VERTEX_CONTAINER_H_ */
|
||||
|
|
|
@ -34,7 +34,7 @@
|
|||
#include <gal/color4d.h>
|
||||
#include <cstddef>
|
||||
|
||||
namespace KiGfx
|
||||
namespace KIGFX
|
||||
{
|
||||
class VERTEX_MANAGER;
|
||||
|
||||
|
@ -98,6 +98,6 @@ private:
|
|||
m_size = aSize;
|
||||
}
|
||||
};
|
||||
} // namespace KiGfx
|
||||
} // namespace KIGFX
|
||||
|
||||
#endif /* VERTEX_ITEM_H_ */
|
||||
|
|
|
@ -40,7 +40,7 @@
|
|||
#include <boost/smart_ptr/shared_ptr.hpp>
|
||||
#include <wx/log.h>
|
||||
|
||||
namespace KiGfx
|
||||
namespace KIGFX
|
||||
{
|
||||
class SHADER;
|
||||
class VERTEX_ITEM;
|
||||
|
@ -342,6 +342,6 @@ protected:
|
|||
GLfloat m_shader[ShaderStride];
|
||||
};
|
||||
|
||||
} // namespace KiGfx
|
||||
} // namespace KIGFX
|
||||
|
||||
#endif /* VERTEX_MANAGER_H_ */
|
||||
|
|
|
@ -34,7 +34,7 @@
|
|||
|
||||
#include <math/box2.h>
|
||||
|
||||
namespace KiGfx
|
||||
namespace KIGFX
|
||||
{
|
||||
class GAL;
|
||||
|
||||
|
@ -184,6 +184,6 @@ private:
|
|||
|
||||
static const double LINE_HEIGHT_RATIO;
|
||||
};
|
||||
} // namespace KiGfx
|
||||
} // namespace KIGFX
|
||||
|
||||
#endif /* STROKE_FONT_H_ */
|
||||
|
|
|
@ -42,9 +42,9 @@
|
|||
// 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>
|
||||
#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>
|
||||
#define RTREE_QUAL RTree<DATATYPE, ELEMTYPE, NUMDIMS, ELEMTYPEREAL, TMAXNODES, \
|
||||
TMINNODES>
|
||||
|
|
|
@ -36,43 +36,42 @@ typedef boost::optional<VECTOR2I> OPT_VECTOR2I;
|
|||
|
||||
class SEG
|
||||
{
|
||||
private:
|
||||
typedef VECTOR2I::extended_type ecoord;
|
||||
private:
|
||||
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
|
||||
* to an object the segment belongs to (e.g. a line chain) or references to locally stored points
|
||||
* (m_a, m_b).
|
||||
*/
|
||||
VECTOR2I& a, b;
|
||||
|
||||
/* Start and the of the segment. Public, to make access simpler. These are references
|
||||
* to an object the segment belongs to (e.g. a line chain) or references to locally stored points
|
||||
* (m_a, m_b).
|
||||
*/
|
||||
VECTOR2I& a, b;
|
||||
/** Default constructor
|
||||
* Creates an empty (0, 0) segment, locally-referenced
|
||||
*/
|
||||
SEG() : a( m_a ), b( m_b )
|
||||
{
|
||||
a = m_a;
|
||||
b = m_b;
|
||||
m_is_local = true;
|
||||
m_index = -1;
|
||||
}
|
||||
|
||||
/** Default constructor
|
||||
* Creates an empty (0, 0) segment, locally-referenced
|
||||
*/
|
||||
SEG() : a( m_a ), b( m_b )
|
||||
{
|
||||
a = m_a;
|
||||
b = m_b;
|
||||
m_is_local = true;
|
||||
m_index = -1;
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
* Creates a segment between (aX1, aY1) and (aX2, aY2), locally referenced
|
||||
*/
|
||||
SEG( int aX1, int aY1, int aX2, int aY2 ) : a( m_a ), b( m_b )
|
||||
{
|
||||
m_a = VECTOR2I( aX1, aY1 );
|
||||
m_b = VECTOR2I( aX2, aY2 );
|
||||
a = m_a;
|
||||
b = m_b;
|
||||
m_is_local = true;
|
||||
m_index = -1;
|
||||
}
|
||||
/**
|
||||
* Constructor
|
||||
* Creates a segment between (aX1, aY1) and (aX2, aY2), locally referenced
|
||||
*/
|
||||
SEG( int aX1, int aY1, int aX2, int aY2 ) : a( m_a ), b( m_b )
|
||||
{
|
||||
m_a = VECTOR2I( aX1, aY1 );
|
||||
m_b = VECTOR2I( aX2, aY2 );
|
||||
a = m_a;
|
||||
b = m_b;
|
||||
m_is_local = true;
|
||||
m_index = -1;
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
|
|
|
@ -35,11 +35,12 @@
|
|||
* Lists all supported shapes
|
||||
*/
|
||||
|
||||
enum ShapeType {
|
||||
SH_RECT = 0, ///> axis-aligned rectangle
|
||||
SH_SEGMENT, ///> line segment
|
||||
SH_LINE_CHAIN, ///> line chain (polyline)
|
||||
SH_CIRCLE ///> circle
|
||||
enum ShapeType
|
||||
{
|
||||
SH_RECT = 0, ///> axis-aligned rectangle
|
||||
SH_SEGMENT, ///> line segment
|
||||
SH_LINE_CHAIN, ///> line chain (polyline)
|
||||
SH_CIRCLE ///> circle
|
||||
};
|
||||
|
||||
/**
|
||||
|
@ -47,7 +48,8 @@ enum ShapeType {
|
|||
*
|
||||
* Represents an abstract shape on 2D plane.
|
||||
*/
|
||||
class SHAPE {
|
||||
class SHAPE
|
||||
{
|
||||
protected:
|
||||
typedef VECTOR2I::extended_type ecoord;
|
||||
|
||||
|
@ -77,7 +79,8 @@ class SHAPE {
|
|||
* Returns a dynamically allocated copy of the shape
|
||||
* @retval copy of the shape
|
||||
*/
|
||||
virtual SHAPE* Clone() const {
|
||||
virtual SHAPE* Clone() const
|
||||
{
|
||||
assert( false );
|
||||
return NULL;
|
||||
};
|
||||
|
@ -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 = 0 ) const;
|
||||
|
||||
/**
|
||||
* Function Collide()
|
||||
*
|
||||
|
@ -139,9 +143,8 @@ class SHAPE {
|
|||
private:
|
||||
///> type of our shape
|
||||
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
|
||||
|
|
|
@ -27,13 +27,13 @@
|
|||
|
||||
#include "shape.h"
|
||||
|
||||
class SHAPE_CIRCLE : public SHAPE {
|
||||
|
||||
class SHAPE_CIRCLE : public SHAPE
|
||||
{
|
||||
public:
|
||||
SHAPE_CIRCLE():
|
||||
SHAPE_CIRCLE() :
|
||||
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_CIRCLE() {};
|
||||
|
@ -41,12 +41,14 @@ public:
|
|||
const BOX2I BBox( int aClearance = 0 ) const
|
||||
{
|
||||
const VECTOR2I rc( m_radius + aClearance, m_radius + aClearance );
|
||||
|
||||
return BOX2I( m_center - rc, rc * 2 );
|
||||
}
|
||||
|
||||
bool Collide( const SEG& aSeg, int aClearance = 0 ) const
|
||||
{
|
||||
int rc = aClearance + m_radius;
|
||||
|
||||
return aSeg.Distance( m_center ) <= rc;
|
||||
}
|
||||
|
||||
|
@ -69,6 +71,7 @@ public:
|
|||
{
|
||||
return m_center;
|
||||
}
|
||||
|
||||
private:
|
||||
int m_radius;
|
||||
VECTOR2I m_center;
|
||||
|
|
|
@ -46,10 +46,11 @@ static const SHAPE* shapeFunctor( T aItem )
|
|||
return aItem->GetShape();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* shapeFunctor template function: specialization for T = SHAPE*
|
||||
*/
|
||||
template<>
|
||||
template <>
|
||||
const SHAPE* shapeFunctor( SHAPE* aItem );
|
||||
|
||||
/**
|
||||
|
@ -67,6 +68,7 @@ BOX2I boundingBox( T aObject )
|
|||
return shapeFunctor( aObject )->BBox();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* acceptVisitor template method
|
||||
*
|
||||
|
@ -82,6 +84,7 @@ void acceptVisitor( T aObject, V aVisitor )
|
|||
aVisitor( aObject );
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* collide template method
|
||||
*
|
||||
|
@ -93,22 +96,23 @@ void acceptVisitor( T aObject, V aVisitor )
|
|||
* @param minDistance minimum collision distance
|
||||
* @return if object and anotherObject collide
|
||||
*/
|
||||
template<class T, class U>
|
||||
template <class T, class U>
|
||||
bool collide( T aObject, U aAnotherObject, int aMinDistance )
|
||||
{
|
||||
return shapeFunctor( aObject )->Collide( aAnotherObject, aMinDistance );
|
||||
}
|
||||
|
||||
template<class T, class V>
|
||||
template <class T, class V>
|
||||
bool queryCallback( T aShape, void* aContext )
|
||||
{
|
||||
V* visitor = (V*) aContext;
|
||||
acceptVisitor<T,V>( aShape, *visitor );
|
||||
|
||||
acceptVisitor<T, V>( aShape, *visitor );
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
template<class T = SHAPE*>
|
||||
template <class T = SHAPE*>
|
||||
class SHAPE_INDEX
|
||||
{
|
||||
public:
|
||||
|
@ -242,7 +246,7 @@ class SHAPE_INDEX
|
|||
* Accepts a visitor for every SHAPE object contained in this INDEX.
|
||||
* @param visitor Visitor object to be run
|
||||
*/
|
||||
template<class V>
|
||||
template <class V>
|
||||
void Accept( V aVisitor )
|
||||
{
|
||||
Iterator iter = this->Begin();
|
||||
|
@ -271,7 +275,7 @@ class SHAPE_INDEX
|
|||
* @param minDistance distance threshold
|
||||
* @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 )
|
||||
{
|
||||
BOX2I box = aShape->BBox();
|
||||
|
@ -299,19 +303,19 @@ class SHAPE_INDEX
|
|||
* Class members implementation
|
||||
*/
|
||||
|
||||
template<class T>
|
||||
template <class T>
|
||||
SHAPE_INDEX<T>::SHAPE_INDEX()
|
||||
{
|
||||
this->m_tree = new RTree<T, int, 2, float>();
|
||||
}
|
||||
|
||||
template<class T>
|
||||
template <class T>
|
||||
SHAPE_INDEX<T>::~SHAPE_INDEX()
|
||||
{
|
||||
delete this->m_tree;
|
||||
}
|
||||
|
||||
template<class T>
|
||||
template <class T>
|
||||
void SHAPE_INDEX<T>::Add( T aShape )
|
||||
{
|
||||
BOX2I box = boundingBox( aShape );
|
||||
|
@ -321,7 +325,7 @@ void SHAPE_INDEX<T>::Add( T aShape )
|
|||
this->m_tree->Insert( min, max, aShape );
|
||||
}
|
||||
|
||||
template<class T>
|
||||
template <class T>
|
||||
void SHAPE_INDEX<T>::Remove( T aShape )
|
||||
{
|
||||
BOX2I box = boundingBox( aShape );
|
||||
|
@ -331,19 +335,20 @@ void SHAPE_INDEX<T>::Remove( T aShape )
|
|||
this->m_tree->Remove( min, max, aShape );
|
||||
}
|
||||
|
||||
template<class T>
|
||||
template <class T>
|
||||
void SHAPE_INDEX<T>::RemoveAll()
|
||||
{
|
||||
this->m_tree->RemoveAll();
|
||||
}
|
||||
|
||||
template<class T>
|
||||
template <class T>
|
||||
void SHAPE_INDEX<T>::Reindex()
|
||||
{
|
||||
RTree<T, int, 2, float>* newTree;
|
||||
newTree = new RTree<T, int, 2, float>();
|
||||
|
||||
Iterator iter = this->Begin();
|
||||
|
||||
while( !iter.IsNull() )
|
||||
{
|
||||
T shape = *iter;
|
||||
|
@ -358,7 +363,7 @@ void SHAPE_INDEX<T>::Reindex()
|
|||
this->m_tree = newTree;
|
||||
}
|
||||
|
||||
template<class T>
|
||||
template <class T>
|
||||
typename SHAPE_INDEX<T>::Iterator SHAPE_INDEX<T>::Begin()
|
||||
{
|
||||
return Iterator( this );
|
||||
|
|
|
@ -27,16 +27,17 @@
|
|||
|
||||
#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();
|
||||
}
|
||||
|
||||
template <class T, const SHAPE* (ShapeFunctor)(const T) = defaultShapeFunctor<T> >
|
||||
|
||||
class SHAPE_INDEX_LIST {
|
||||
|
||||
struct ShapeEntry {
|
||||
template <class T, const SHAPE* (ShapeFunctor) (const T) = defaultShapeFunctor<T> >
|
||||
class SHAPE_INDEX_LIST
|
||||
{
|
||||
struct ShapeEntry
|
||||
{
|
||||
ShapeEntry( T aParent )
|
||||
{
|
||||
shape = ShapeFunctor( aParent );
|
||||
|
@ -58,75 +59,77 @@ class SHAPE_INDEX_LIST {
|
|||
|
||||
public:
|
||||
// "Normal" iterator interface, for STL algorithms.
|
||||
class iterator {
|
||||
public:
|
||||
iterator() {};
|
||||
class iterator
|
||||
{
|
||||
public:
|
||||
iterator() {};
|
||||
|
||||
iterator( ShapeVecIter aCurrent )
|
||||
: m_current( aCurrent ) {};
|
||||
iterator( ShapeVecIter aCurrent ) :
|
||||
m_current( aCurrent ) {};
|
||||
|
||||
iterator( const iterator &aB ) :
|
||||
m_current( aB.m_current ) {};
|
||||
iterator( const iterator& aB ) :
|
||||
m_current( aB.m_current ) {};
|
||||
|
||||
T operator*() const
|
||||
{
|
||||
return (*m_current).parent;
|
||||
}
|
||||
T operator*() const
|
||||
{
|
||||
return (*m_current).parent;
|
||||
}
|
||||
|
||||
void operator++()
|
||||
{
|
||||
++m_current;
|
||||
}
|
||||
void operator++()
|
||||
{
|
||||
++m_current;
|
||||
}
|
||||
|
||||
iterator& operator++( int aDummy )
|
||||
{
|
||||
++m_current;
|
||||
return *this;
|
||||
}
|
||||
iterator& operator++( int aDummy )
|
||||
{
|
||||
++m_current;
|
||||
return *this;
|
||||
}
|
||||
|
||||
bool operator==( const iterator& aRhs ) const
|
||||
{
|
||||
return m_current == aRhs.m_current;
|
||||
}
|
||||
bool operator==( const iterator& aRhs ) const
|
||||
{
|
||||
return m_current == aRhs.m_current;
|
||||
}
|
||||
|
||||
bool operator!=( const iterator& aRhs ) const
|
||||
{
|
||||
return m_current != aRhs.m_current;
|
||||
}
|
||||
bool operator!=( const iterator& aRhs ) const
|
||||
{
|
||||
return m_current != aRhs.m_current;
|
||||
}
|
||||
|
||||
const iterator& operator=( const iterator& aRhs )
|
||||
{
|
||||
m_current = aRhs.m_current;
|
||||
return *this;
|
||||
}
|
||||
const iterator& operator=( const iterator& aRhs )
|
||||
{
|
||||
m_current = aRhs.m_current;
|
||||
return *this;
|
||||
}
|
||||
|
||||
private:
|
||||
ShapeVecIter m_current;
|
||||
private:
|
||||
ShapeVecIter m_current;
|
||||
};
|
||||
|
||||
// "Query" iterator, for iterating over a set of spatially matching shapes.
|
||||
class query_iterator {
|
||||
public:
|
||||
query_iterator()
|
||||
{
|
||||
}
|
||||
class query_iterator
|
||||
{
|
||||
public:
|
||||
query_iterator()
|
||||
{
|
||||
}
|
||||
|
||||
query_iterator( ShapeVecIter aCurrent, ShapeVecIter aEnd, SHAPE* aShape,
|
||||
int aMinDistance, bool aExact ) :
|
||||
m_end( aEnd ),
|
||||
m_current( aCurrent ),
|
||||
m_shape( aShape ),
|
||||
m_minDistance( aMinDistance ),
|
||||
m_exact( aExact )
|
||||
{
|
||||
if( aShape )
|
||||
{
|
||||
query_iterator( ShapeVecIter aCurrent, ShapeVecIter aEnd, SHAPE* aShape,
|
||||
int aMinDistance, bool aExact ) :
|
||||
m_end( aEnd ),
|
||||
m_current( aCurrent ),
|
||||
m_shape( aShape ),
|
||||
m_minDistance( aMinDistance ),
|
||||
m_exact( aExact )
|
||||
{
|
||||
if( aShape )
|
||||
{
|
||||
m_refBBox = aShape->BBox();
|
||||
next();
|
||||
}
|
||||
}
|
||||
|
||||
query_iterator( const query_iterator &aB ) :
|
||||
query_iterator( const query_iterator& aB ) :
|
||||
m_end( aB.m_end ),
|
||||
m_current( aB.m_current ),
|
||||
m_shape( aB.m_shape ),
|
||||
|
@ -191,19 +194,19 @@ public:
|
|||
}
|
||||
}
|
||||
|
||||
ShapeVecIter m_end;
|
||||
ShapeVecIter m_current;
|
||||
BOX2I m_refBBox;
|
||||
bool m_exact;
|
||||
SHAPE *m_shape;
|
||||
int m_minDistance;
|
||||
ShapeVecIter m_end;
|
||||
ShapeVecIter m_current;
|
||||
BOX2I m_refBBox;
|
||||
bool m_exact;
|
||||
SHAPE* m_shape;
|
||||
int m_minDistance;
|
||||
};
|
||||
|
||||
void Add( T aItem )
|
||||
{
|
||||
ShapeEntry s( aItem );
|
||||
|
||||
m_shapes.push_back(s);
|
||||
m_shapes.push_back( s );
|
||||
}
|
||||
|
||||
void Remove( const T aItem )
|
||||
|
@ -227,8 +230,8 @@ public:
|
|||
return m_shapes.size();
|
||||
}
|
||||
|
||||
template<class Visitor>
|
||||
int Query( const SHAPE *aShape, int aMinDistance, Visitor &aV, bool aExact = true ) //const
|
||||
template <class Visitor>
|
||||
int Query( const SHAPE* aShape, int aMinDistance, Visitor& aV, bool aExact = true ) // const
|
||||
{
|
||||
ShapeVecIter i;
|
||||
int n = 0;
|
||||
|
@ -243,11 +246,13 @@ public:
|
|||
if( !aExact || i->shape->Collide( aShape, aMinDistance ) )
|
||||
{
|
||||
n++;
|
||||
|
||||
if( !aV( i->parent ) )
|
||||
return n;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return n;
|
||||
}
|
||||
|
||||
|
@ -263,7 +268,7 @@ public:
|
|||
|
||||
const query_iterator qend()
|
||||
{
|
||||
return query_iterator( m_shapes.end(), m_shapes.end(), NULL, 0, false );
|
||||
return query_iterator( m_shapes.end(), m_shapes.end(), NULL, 0, false );
|
||||
}
|
||||
|
||||
iterator begin()
|
||||
|
|
|
@ -30,7 +30,8 @@
|
|||
#include <geometry/shape_circle.h>
|
||||
#include <geometry/seg.h>
|
||||
|
||||
class SHAPE_RECT : public SHAPE {
|
||||
class SHAPE_RECT : public SHAPE
|
||||
{
|
||||
public:
|
||||
/**
|
||||
* Constructor
|
||||
|
@ -50,11 +51,11 @@ class SHAPE_RECT : public SHAPE {
|
|||
* Constructor
|
||||
* 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 ) {};
|
||||
|
||||
/// @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 ),
|
||||
VECTOR2I( m_w + 2 * aClearance, m_h + 2 * aClearance ) );
|
||||
|
@ -76,17 +77,17 @@ class SHAPE_RECT : public SHAPE {
|
|||
/// @copydoc SHAPE::Collide()
|
||||
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 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));
|
||||
//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 ));
|
||||
//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;
|
||||
|
||||
if( BBox( 0 ).Contains( aSeg.a ) || BBox( 0 ).Contains( aSeg.b ) )
|
||||
return true;
|
||||
|
||||
VECTOR2I vts[] = { VECTOR2I( m_p0.x, m_p0.y ),
|
||||
VECTOR2I vts[] = { VECTOR2I( m_p0.x, m_p0.y ),
|
||||
VECTOR2I( m_p0.x, m_p0.y + m_h ),
|
||||
VECTOR2I( m_p0.x + m_w, m_p0.y + m_h ),
|
||||
VECTOR2I( m_p0.x + m_w, m_p0.y ),
|
||||
|
@ -107,28 +108,40 @@ class SHAPE_RECT : public SHAPE {
|
|||
*
|
||||
* @return top-left corner of the rectangle
|
||||
*/
|
||||
const VECTOR2I& GetPosition() const { return m_p0; }
|
||||
const VECTOR2I& GetPosition() const
|
||||
{
|
||||
return m_p0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Function GetSize()
|
||||
*
|
||||
* @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()
|
||||
*
|
||||
* @return width of the rectangle
|
||||
*/
|
||||
const int GetWidth() const { return m_w; }
|
||||
const int GetWidth() const
|
||||
{
|
||||
return m_w;
|
||||
}
|
||||
|
||||
/**
|
||||
* Function GetHeight()
|
||||
*
|
||||
* @return height of the rectangle
|
||||
*/
|
||||
const int GetHeight() const { return m_h; }
|
||||
const int GetHeight() const
|
||||
{
|
||||
return m_h;
|
||||
}
|
||||
|
||||
private:
|
||||
///> Top-left corner
|
||||
|
|
|
@ -67,7 +67,7 @@ template < typename T > struct LENGTH_TRAITS< T, 0 >
|
|||
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_TRAITS< T, P >;
|
||||
|
@ -109,7 +109,7 @@ public:
|
|||
this->m_U = y.m_U;
|
||||
return *this;
|
||||
}
|
||||
template<typename Y> operator LENGTH< Y, P > ( void )
|
||||
template <typename Y> operator LENGTH< Y, P > ( void )
|
||||
{
|
||||
return this->m_U;
|
||||
}
|
||||
|
|
|
@ -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
|
||||
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
|
||||
#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; }
|
|||
// 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
|
||||
// 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;
|
||||
a = b;
|
||||
|
|
|
@ -39,7 +39,8 @@ template <>
|
|||
class BOX2_TRAITS<VECTOR2I>
|
||||
{
|
||||
public:
|
||||
enum {
|
||||
enum
|
||||
{
|
||||
c_max_size = INT_MAX - 1,
|
||||
c_min_coord_value = INT_MIN / 2 + 1
|
||||
};
|
||||
|
@ -61,7 +62,7 @@ public:
|
|||
typedef typename Vec::coord_type coord_type;
|
||||
typedef typename Vec::extended_type ecoord_type;
|
||||
|
||||
BOX2() { };
|
||||
BOX2() {};
|
||||
|
||||
BOX2( const Vec& aPos, const Vec& aSize ) :
|
||||
m_Pos( aPos ),
|
||||
|
@ -91,6 +92,7 @@ public:
|
|||
void Compute( const Container& aPointList )
|
||||
{
|
||||
Vec vmin, vmax;
|
||||
|
||||
typename Container::const_iterator i;
|
||||
|
||||
if( !aPointList.size() )
|
||||
|
@ -164,7 +166,7 @@ public:
|
|||
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:
|
|||
{
|
||||
ecoord_type x2 = m_Pos.x + m_Size.x;
|
||||
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 ydiff = std::max( aP.y < m_Pos.y ? m_Pos.y - aP.y : m_Pos.y - y2, (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 );
|
||||
return xdiff * xdiff + ydiff * ydiff;
|
||||
}
|
||||
|
||||
|
|
|
@ -34,14 +34,18 @@
|
|||
* 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;
|
||||
}
|
||||
|
||||
|
||||
// explicit specializations for integer types, taking care of overflow.
|
||||
template<> int rescale( int numerator, int value, int denominator );
|
||||
template<> int64_t rescale( int64_t numerator, int64_t value, int64_t denominator );
|
||||
template <>
|
||||
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
|
||||
|
|
|
@ -51,8 +51,11 @@
|
|||
*/
|
||||
|
||||
// Forward declaration for template friends
|
||||
template <class T> class MATRIX3x3;
|
||||
template <class T> std::ostream& operator<<( std::ostream& stream, const MATRIX3x3<T>& matrix );
|
||||
template <class T>
|
||||
class MATRIX3x3;
|
||||
|
||||
template <class T>
|
||||
std::ostream& operator<<( std::ostream& stream, const MATRIX3x3<T>& matrix );
|
||||
|
||||
template <class T>
|
||||
class MATRIX3x3
|
||||
|
@ -164,20 +167,21 @@ public:
|
|||
// Operators
|
||||
|
||||
//! @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
|
||||
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
|
||||
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*( MATRIX3x3<T> const& a, T scalar );
|
||||
template <class T, class S> MATRIX3x3<T> const operator*( T scalar, MATRIX3x3<T> const& matrix );
|
||||
|
||||
// ----------------------
|
||||
// --- Implementation ---
|
||||
// ----------------------
|
||||
|
||||
template<class T> MATRIX3x3<T>::MATRIX3x3()
|
||||
template <class T>
|
||||
MATRIX3x3<T>::MATRIX3x3()
|
||||
{
|
||||
for( int j = 0; j < 3; j++ )
|
||||
{
|
||||
|
@ -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,
|
||||
T a22 )
|
||||
template <class T>
|
||||
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][1] = a01;
|
||||
|
@ -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++ )
|
||||
{
|
||||
|
@ -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[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;
|
||||
result.x = m_data[0][2];
|
||||
|
@ -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 sinValue = sin( 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[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] );
|
||||
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;
|
||||
|
||||
|
@ -279,8 +290,9 @@ template<class T> MATRIX3x3<T> const operator*( MATRIX3x3<T> const& a, MATRIX3x3
|
|||
}
|
||||
|
||||
|
||||
template<class T> VECTOR2<T> const operator*( MATRIX3x3<T> const& matrix,
|
||||
VECTOR2<T> const& vector )
|
||||
template <class T>
|
||||
VECTOR2<T> const operator*( MATRIX3x3<T> const& matrix,
|
||||
VECTOR2<T> const& vector )
|
||||
{
|
||||
VECTOR2<T> result( 0, 0 );
|
||||
result.x = matrix.m_data[0][0] * vector.x + matrix.m_data[0][1] * vector.y
|
||||
|
@ -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] )
|
||||
- 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
|
|||
}
|
||||
|
||||
|
||||
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;
|
||||
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
|
||||
template<class T> MATRIX3x3<T> MATRIX3x3<T>::Inverse( void ) const
|
||||
template <class T>
|
||||
MATRIX3x3<T> MATRIX3x3<T>::Inverse() const
|
||||
{
|
||||
MATRIX3x3<T> result;
|
||||
|
||||
|
@ -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;
|
||||
|
||||
|
@ -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++ )
|
||||
{
|
||||
|
@ -377,6 +395,7 @@ template<class T> std::ostream& operator<<( std::ostream& aStream, const MATRIX3
|
|||
return aStream;
|
||||
}
|
||||
|
||||
|
||||
/* Default specializations */
|
||||
typedef MATRIX3x3<double> MATRIX3x3D;
|
||||
|
||||
|
|
|
@ -102,8 +102,8 @@ public:
|
|||
template <typename CastingType>
|
||||
VECTOR2( const VECTOR2<CastingType>& aVec )
|
||||
{
|
||||
x = (T) aVec.x;
|
||||
y = (T) aVec.y;
|
||||
x = (T) aVec.x;
|
||||
y = (T) aVec.y;
|
||||
}
|
||||
|
||||
/// Casts a vector to another specialized subclass. Beware of rouding
|
||||
|
@ -131,7 +131,7 @@ public:
|
|||
* It is used to calculate the length of the vector.
|
||||
* @return Scalar, the euclidean norm
|
||||
*/
|
||||
extended_type SquaredEuclideanNorm() const;
|
||||
extended_type SquaredEuclideanNorm() const;
|
||||
|
||||
|
||||
/**
|
||||
|
@ -258,24 +258,24 @@ VECTOR2<T>::VECTOR2()
|
|||
template <class T>
|
||||
VECTOR2<T>::VECTOR2( wxPoint const& aPoint )
|
||||
{
|
||||
x = T( aPoint.x );
|
||||
y = T( aPoint.y );
|
||||
x = T( aPoint.x );
|
||||
y = T( aPoint.y );
|
||||
}
|
||||
|
||||
|
||||
template <class T>
|
||||
VECTOR2<T>::VECTOR2( wxSize const& aSize )
|
||||
{
|
||||
x = T( aSize.x );
|
||||
y = T( aSize.y );
|
||||
x = T( aSize.x );
|
||||
y = T( aSize.y );
|
||||
}
|
||||
#endif
|
||||
|
||||
template <class T>
|
||||
VECTOR2<T>::VECTOR2( T aX, T aY )
|
||||
{
|
||||
x = aX;
|
||||
y = aY;
|
||||
x = aX;
|
||||
y = aY;
|
||||
}
|
||||
|
||||
|
||||
|
@ -285,14 +285,14 @@ T VECTOR2<T>::EuclideanNorm() const
|
|||
return sqrt( (extended_type) x * x + (extended_type) y * y );
|
||||
}
|
||||
|
||||
|
||||
template <class T>
|
||||
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>
|
||||
double VECTOR2<T>::Angle() const
|
||||
{
|
||||
|
@ -311,8 +311,8 @@ VECTOR2<T> VECTOR2<T>::Perpendicular() const
|
|||
template <class T>
|
||||
VECTOR2<T>& VECTOR2<T>::operator=( const VECTOR2<T>& aVector )
|
||||
{
|
||||
x = aVector.x;
|
||||
y = aVector.y;
|
||||
x = aVector.x;
|
||||
y = aVector.y;
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
@ -320,8 +320,8 @@ VECTOR2<T>& VECTOR2<T>::operator=( const VECTOR2<T>& aVector )
|
|||
template <class T>
|
||||
VECTOR2<T>& VECTOR2<T>::operator+=( const VECTOR2<T>& aVector )
|
||||
{
|
||||
x += aVector.x;
|
||||
y += aVector.y;
|
||||
x += aVector.x;
|
||||
y += aVector.y;
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
@ -329,8 +329,8 @@ VECTOR2<T>& VECTOR2<T>::operator+=( const VECTOR2<T>& aVector )
|
|||
template <class T>
|
||||
VECTOR2<T>& VECTOR2<T>::operator+=( const T& aScalar )
|
||||
{
|
||||
x += aScalar;
|
||||
y += aScalar;
|
||||
x += aScalar;
|
||||
y += aScalar;
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
@ -338,8 +338,8 @@ VECTOR2<T>& VECTOR2<T>::operator+=( const T& aScalar )
|
|||
template <class T>
|
||||
VECTOR2<T>& VECTOR2<T>::operator-=( const VECTOR2<T>& aVector )
|
||||
{
|
||||
x -= aVector.x;
|
||||
y -= aVector.y;
|
||||
x -= aVector.x;
|
||||
y -= aVector.y;
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
@ -347,8 +347,8 @@ VECTOR2<T>& VECTOR2<T>::operator-=( const VECTOR2<T>& aVector )
|
|||
template <class T>
|
||||
VECTOR2<T>& VECTOR2<T>::operator-=( const T& aScalar )
|
||||
{
|
||||
x -= aScalar;
|
||||
y -= aScalar;
|
||||
x -= aScalar;
|
||||
y -= aScalar;
|
||||
return *this;
|
||||
}
|
||||
template <class T>
|
||||
|
@ -365,15 +365,15 @@ VECTOR2<T> VECTOR2<T>::Rotate( double aAngle ) const
|
|||
template <class T>
|
||||
VECTOR2<T> VECTOR2<T>::Resize( T aNewLength ) const
|
||||
{
|
||||
if(x == 0 && y == 0)
|
||||
return VECTOR2<T> (0, 0);
|
||||
if( x == 0 && y == 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_new = (extended_type) aNewLength * aNewLength;
|
||||
extended_type l_sq_current = (extended_type) x * x + (extended_type) y * y;
|
||||
extended_type l_sq_new = (extended_type) aNewLength * aNewLength;
|
||||
|
||||
return VECTOR2<T> (
|
||||
(this->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)));
|
||||
return VECTOR2<T> (
|
||||
( x < 0 ? -1 : 1 ) * sqrt( rescale( l_sq_new, (extended_type) x * x, l_sq_current ) ),
|
||||
( y < 0 ? -1 : 1 ) * sqrt( rescale( l_sq_new, (extended_type) y * y, l_sq_current ) ) );
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -38,7 +38,7 @@
|
|||
class EDA_ITEM;
|
||||
class COLORS_DESIGN_SETTINGS;
|
||||
|
||||
namespace KiGfx
|
||||
namespace KIGFX
|
||||
{
|
||||
class GAL;
|
||||
class VIEW_ITEM;
|
||||
|
@ -265,6 +265,6 @@ protected:
|
|||
/// Color of brightened item frame
|
||||
COLOR4D m_brightenedColor;
|
||||
};
|
||||
} // namespace KiGfx
|
||||
} // namespace KIGFX
|
||||
|
||||
#endif /* __CLASS_PAINTER_H */
|
||||
|
|
|
@ -36,9 +36,9 @@
|
|||
// 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>
|
||||
#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>
|
||||
#define RTREE_QUAL RTree<DATATYPE, ELEMTYPE, NUMDIMS, ELEMTYPEREAL, TMAXNODES, \
|
||||
TMINNODES>
|
||||
|
|
|
@ -76,8 +76,8 @@ public:
|
|||
bool RunAction( const std::string& aActionName ) const;
|
||||
|
||||
// TODO to be considered
|
||||
//bool RunAction( int aActionId ) const;
|
||||
//bool RunAction( TOOL_ACTION* aAction ) const;
|
||||
// bool RunAction( int aActionId ) const;
|
||||
// bool RunAction( TOOL_ACTION* aAction ) const;
|
||||
|
||||
/**
|
||||
* Function RunHotKey()
|
||||
|
|
|
@ -32,27 +32,27 @@
|
|||
#include "delegate.h"
|
||||
|
||||
/**
|
||||
Class COROUNTINE.
|
||||
Implements a coroutine. Wikipedia has a good explanation:
|
||||
|
||||
"Coroutines are computer program components that generalize subroutines to
|
||||
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
|
||||
tasks, exceptions, event loop, iterators, infinite lists and pipes."
|
||||
|
||||
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,
|
||||
we avoid concurrency problems such as locking / race conditions.
|
||||
|
||||
Uses boost::context library to do the actual context switching.
|
||||
|
||||
This particular version takes a DELEGATE as an entry point, so it can invoke
|
||||
methods within a given object as separate coroutines.
|
||||
|
||||
See coroutine_example.cpp for sample code.
|
||||
* Class COROUNTINE.
|
||||
* Implements a coroutine. Wikipedia has a good explanation:
|
||||
*
|
||||
* "Coroutines are computer program components that generalize subroutines to
|
||||
* 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
|
||||
* tasks, exceptions, event loop, iterators, infinite lists and pipes."
|
||||
*
|
||||
* 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,
|
||||
* we avoid concurrency problems such as locking / race conditions.
|
||||
*
|
||||
* Uses boost::context library to do the actual context switching.
|
||||
*
|
||||
* This particular version takes a DELEGATE as an entry point, so it can invoke
|
||||
* methods within a given object as separate coroutines.
|
||||
*
|
||||
* See coroutine_example.cpp for sample code.
|
||||
*/
|
||||
|
||||
template<class ReturnType, class ArgType>
|
||||
template <class ReturnType, class ArgType>
|
||||
class COROUTINE
|
||||
{
|
||||
public:
|
||||
|
@ -67,8 +67,8 @@ public:
|
|||
* Constructor
|
||||
* Creates a coroutine from a member method of an object
|
||||
*/
|
||||
template<class T>
|
||||
COROUTINE( T* object, ReturnType (T::*ptr)( ArgType ) ) :
|
||||
template <class T>
|
||||
COROUTINE( T* object, ReturnType(T::* ptr)( ArgType ) ) :
|
||||
m_func( object, ptr ), m_saved( NULL ), m_stack( NULL ), m_stackSize( c_defaultStackSize )
|
||||
{
|
||||
}
|
||||
|
@ -78,13 +78,14 @@ public:
|
|||
* Creates a coroutine from a delegate object
|
||||
*/
|
||||
COROUTINE( DELEGATE<ReturnType, ArgType> aEntry ) :
|
||||
m_func( aEntry ), m_saved( NULL ), m_stack( NULL ), m_stackSize( c_defaultStackSize )
|
||||
m_func( aEntry ), m_saved( NULL ), m_stack( NULL ), m_stackSize( c_defaultStackSize )
|
||||
{};
|
||||
|
||||
~COROUTINE()
|
||||
{
|
||||
if( m_saved )
|
||||
delete m_saved;
|
||||
|
||||
if( m_stack )
|
||||
free( m_stack );
|
||||
}
|
||||
|
@ -114,7 +115,7 @@ public:
|
|||
}
|
||||
|
||||
/**
|
||||
<F11>* Function SetEntry()
|
||||
* <F11>* Function SetEntry()
|
||||
*
|
||||
* Defines the entry point for the coroutine, if not set in the constructor.
|
||||
*/
|
||||
|
@ -135,7 +136,7 @@ public:
|
|||
m_stack = malloc( c_defaultStackSize );
|
||||
|
||||
// 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_self = boost::context::make_fcontext( sp, m_stackSize, callerStub );
|
||||
|
@ -157,6 +158,7 @@ public:
|
|||
bool Resume()
|
||||
{
|
||||
boost::context::jump_fcontext( m_saved, m_self, 0 );
|
||||
|
||||
return m_running;
|
||||
}
|
||||
|
||||
|
@ -181,7 +183,7 @@ public:
|
|||
}
|
||||
|
||||
private:
|
||||
static const int c_defaultStackSize = 2000000; // fixme: make configurable
|
||||
static const int c_defaultStackSize = 2000000; // fixme: make configurable
|
||||
|
||||
/* real entry point of the coroutine */
|
||||
static void callerStub( intptr_t data )
|
||||
|
@ -194,17 +196,19 @@ private:
|
|||
cor->m_running = false;
|
||||
|
||||
// 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;
|
||||
};
|
||||
|
||||
DELEGATE<ReturnType, ArgType> m_func;
|
||||
|
|
|
@ -32,67 +32,69 @@
|
|||
* Check delegate_example.cpp for a coding sample.
|
||||
*/
|
||||
|
||||
template<class ReturnType, class Arg>
|
||||
class DELEGATE {
|
||||
public:
|
||||
typedef ReturnType (DELEGATE<ReturnType, Arg>::*MemberPointer)( Arg );
|
||||
typedef ReturnType _ReturnType;
|
||||
typedef Arg _ArgType;
|
||||
template <class ReturnType, class Arg>
|
||||
class DELEGATE
|
||||
{
|
||||
public:
|
||||
typedef ReturnType (DELEGATE<ReturnType, Arg>::* MemberPointer)( Arg );
|
||||
typedef ReturnType _ReturnType;
|
||||
typedef Arg _ArgType;
|
||||
|
||||
DELEGATE ()
|
||||
{
|
||||
}
|
||||
DELEGATE()
|
||||
{
|
||||
}
|
||||
|
||||
template<class T>
|
||||
DELEGATE ( T* object, ReturnType (T::*ptr)( Arg ) )
|
||||
{
|
||||
m_ptr = reinterpret_cast<MemberPointer>( ptr );
|
||||
m_object = reinterpret_cast<void *>( object );
|
||||
};
|
||||
template <class T>
|
||||
DELEGATE( T* object, ReturnType(T::* ptr)( Arg ) )
|
||||
{
|
||||
m_ptr = reinterpret_cast<MemberPointer>( ptr );
|
||||
m_object = reinterpret_cast<void*>( object );
|
||||
};
|
||||
|
||||
|
||||
ReturnType operator()( Arg a ) const
|
||||
{
|
||||
DELEGATE<ReturnType, Arg> *casted = reinterpret_cast<DELEGATE<ReturnType, Arg>*>( m_object );
|
||||
return (casted->*m_ptr)(a);
|
||||
}
|
||||
ReturnType operator()( Arg a ) const
|
||||
{
|
||||
DELEGATE<ReturnType, Arg>* casted = reinterpret_cast<DELEGATE<ReturnType, Arg>*>( m_object );
|
||||
return (casted->*m_ptr)( a );
|
||||
}
|
||||
|
||||
private:
|
||||
MemberPointer m_ptr;
|
||||
void *m_object;
|
||||
void* m_object;
|
||||
};
|
||||
|
||||
/**
|
||||
* Class DELEGATE0
|
||||
* Same as DELEGATE, but with no arguments.
|
||||
*/
|
||||
template<class ReturnType>
|
||||
class DELEGATE0 {
|
||||
public:
|
||||
typedef ReturnType ( DELEGATE0<ReturnType>::*MemberPointer )();
|
||||
typedef ReturnType _ReturnType;
|
||||
template <class ReturnType>
|
||||
class DELEGATE0
|
||||
{
|
||||
public:
|
||||
typedef ReturnType ( DELEGATE0<ReturnType>::* MemberPointer )();
|
||||
typedef ReturnType _ReturnType;
|
||||
|
||||
DELEGATE0 ()
|
||||
{
|
||||
}
|
||||
DELEGATE0()
|
||||
{
|
||||
}
|
||||
|
||||
template<class T>
|
||||
DELEGATE0 ( T* object, ReturnType (T::*ptr)( ) )
|
||||
{
|
||||
m_ptr = reinterpret_cast<MemberPointer>( ptr );
|
||||
m_object = reinterpret_cast<void*>( object );
|
||||
};
|
||||
template <class T>
|
||||
DELEGATE0( T* object, ReturnType(T::* ptr)() )
|
||||
{
|
||||
m_ptr = reinterpret_cast<MemberPointer>( ptr );
|
||||
m_object = reinterpret_cast<void*>( object );
|
||||
};
|
||||
|
||||
|
||||
ReturnType operator()( ) const
|
||||
{
|
||||
DELEGATE0<ReturnType>* casted = reinterpret_cast<DELEGATE0<ReturnType>*>( m_object );
|
||||
return ( casted->*m_ptr )();
|
||||
}
|
||||
ReturnType operator()() const
|
||||
{
|
||||
DELEGATE0<ReturnType>* casted = reinterpret_cast<DELEGATE0<ReturnType>*>( m_object );
|
||||
return ( casted->*m_ptr )();
|
||||
}
|
||||
|
||||
private:
|
||||
MemberPointer m_ptr;
|
||||
void *m_object;
|
||||
void* m_object;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
|
@ -7,39 +7,42 @@ using namespace std;
|
|||
|
||||
typedef COROUTINE<int, int> MyCoroutine;
|
||||
|
||||
class MyClass {
|
||||
class MyClass
|
||||
{
|
||||
public:
|
||||
int CountTo( int n )
|
||||
{
|
||||
printf( "%s: Coroutine says hi. I will count from 1 to %d and yield each value.\n",
|
||||
__FUNCTION__,
|
||||
n );
|
||||
|
||||
public:
|
||||
int CountTo(int n)
|
||||
for( int i = 1; i <= n; i++ )
|
||||
{
|
||||
printf("%s: Coroutine says hi. I will count from 1 to %d and yield each value.\n", __FUNCTION__, n);
|
||||
for(int i = 1; i <= n; i++)
|
||||
{
|
||||
printf("%s: Yielding %d\n", __FUNCTION__, i);
|
||||
cofunc.Yield(i);
|
||||
}
|
||||
printf( "%s: Yielding %d\n", __FUNCTION__, i );
|
||||
cofunc.Yield( i );
|
||||
}
|
||||
}
|
||||
|
||||
void Run()
|
||||
{
|
||||
cofunc = MyCoroutine( this, &MyClass::CountTo );
|
||||
printf( "%s: Calling coroutine that will count from 1 to 5.\n", __FUNCTION__ );
|
||||
cofunc.Call( 5 );
|
||||
|
||||
while( cofunc.Running() )
|
||||
{
|
||||
printf( "%s: Got value: %d\n", __FUNCTION__, cofunc.ReturnValue() );
|
||||
cofunc.Resume();
|
||||
}
|
||||
|
||||
void Run()
|
||||
{
|
||||
cofunc = MyCoroutine (this, &MyClass::CountTo);
|
||||
printf("%s: Calling coroutine that will count from 1 to 5.\n", __FUNCTION__);
|
||||
cofunc.Call(5);
|
||||
while (cofunc.Running())
|
||||
{
|
||||
printf("%s: Got value: %d\n", __FUNCTION__, cofunc.ReturnValue());
|
||||
cofunc.Resume();
|
||||
}
|
||||
printf( "%s: Done!\n", __FUNCTION__ );
|
||||
}
|
||||
|
||||
printf("%s: Done!\n", __FUNCTION__);
|
||||
}
|
||||
|
||||
MyCoroutine cofunc;
|
||||
MyCoroutine cofunc;
|
||||
};
|
||||
|
||||
|
||||
main()
|
||||
{
|
||||
main() {
|
||||
MyClass obj;
|
||||
|
||||
obj.Run();
|
||||
|
|
|
@ -5,14 +5,15 @@
|
|||
|
||||
using namespace std;
|
||||
|
||||
class MyClass {
|
||||
|
||||
public:
|
||||
int MyMethod(const string &arg)
|
||||
{
|
||||
printf("MyClass(this = %p)::MyMethod() called with string '%s', length %d\n", this, arg.c_str(), arg.length());
|
||||
return arg.length();
|
||||
}
|
||||
class MyClass
|
||||
{
|
||||
public:
|
||||
int MyMethod( const string& arg )
|
||||
{
|
||||
printf( "MyClass(this = %p)::MyMethod() called with string '%s', length %d\n", this,
|
||||
arg.c_str(), arg.length() );
|
||||
return arg.length();
|
||||
}
|
||||
};
|
||||
|
||||
typedef DELEGATE<int, const string&> MyDelegate;
|
||||
|
@ -22,14 +23,14 @@ main()
|
|||
MyClass t1;
|
||||
MyClass t2;
|
||||
|
||||
MyDelegate ptr1( &t1, &MyClass::MyMethod );
|
||||
MyDelegate ptr2( &t2, &MyClass::MyMethod );
|
||||
|
||||
MyDelegate ptr1 (&t1, &MyClass::MyMethod);
|
||||
MyDelegate ptr2 (&t2, &MyClass::MyMethod);
|
||||
int retval1, retval2;
|
||||
|
||||
int retval1, retval2;
|
||||
retval1 = ptr1("apples");
|
||||
retval2 = ptr2("cherries");
|
||||
retval1 = ptr1( "apples" );
|
||||
retval2 = ptr2( "cherries" );
|
||||
|
||||
printf("Object 1 returned %d, object 2 returned %d\n", retval1, retval2);
|
||||
return 0;
|
||||
printf( "Object 1 returned %d, object 2 returned %d\n", retval1, retval2 );
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -46,11 +46,11 @@ class TOOL_ACTION
|
|||
{
|
||||
public:
|
||||
TOOL_ACTION( const std::string& aName, TOOL_ActionScope aScope = AS_CONTEXT,
|
||||
int aDefaultHotKey = 0, const std::string& aMenuItem = std::string( "" ),
|
||||
const std::string& aMenuDesc = std::string( "" ) ) :
|
||||
m_name( aName ), m_scope( aScope ), m_defaultHotKey( aDefaultHotKey ),
|
||||
m_currentHotKey( aDefaultHotKey ), m_menuItem( aMenuItem ),
|
||||
m_menuDescription( aMenuDesc ), m_id( -1 ), m_actionMgr( NULL )
|
||||
int aDefaultHotKey = 0, const std::string& aMenuItem = std::string( "" ),
|
||||
const std::string& aMenuDesc = std::string( "" ) ) :
|
||||
m_name( aName ), m_scope( aScope ), m_defaultHotKey( aDefaultHotKey ),
|
||||
m_currentHotKey( aDefaultHotKey ), m_menuItem( aMenuItem ),
|
||||
m_menuDescription( aMenuDesc ), m_id( -1 ), m_actionMgr( NULL )
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -205,7 +205,7 @@ private:
|
|||
std::string m_menuDescription;
|
||||
|
||||
// Icon for menu entry
|
||||
//KiBitmap m_bitmap;
|
||||
// KiBitmap m_bitmap;
|
||||
|
||||
/// Unique ID for fast matching. Assigned by ACTION_MANAGER.
|
||||
int m_id;
|
||||
|
@ -214,10 +214,10 @@ private:
|
|||
ACTION_MANAGER* m_actionMgr;
|
||||
|
||||
/// Origin of the action
|
||||
// const TOOL_BASE* m_origin;
|
||||
// const TOOL_BASE* m_origin;
|
||||
|
||||
/// Originating UI object
|
||||
// wxWindow* m_uiOrigin;
|
||||
// wxWindow* m_uiOrigin;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
|
@ -34,7 +34,7 @@
|
|||
class EDA_ITEM;
|
||||
class TOOL_MANAGER;
|
||||
|
||||
namespace KiGfx
|
||||
namespace KIGFX
|
||||
{
|
||||
class VIEW;
|
||||
class VIEW_CONTROLS;
|
||||
|
@ -66,7 +66,7 @@ public:
|
|||
m_type( aType ),
|
||||
m_toolId( aId ),
|
||||
m_toolName( aName ),
|
||||
m_toolMgr( NULL ){};
|
||||
m_toolMgr( NULL ) {};
|
||||
|
||||
virtual ~TOOL_BASE() {};
|
||||
|
||||
|
@ -130,7 +130,7 @@ protected:
|
|||
* Returns the instance of VIEW object used in the application. It allows tools to draw.
|
||||
* @return The instance of VIEW.
|
||||
*/
|
||||
KiGfx::VIEW* getView() const;
|
||||
KIGFX::VIEW* getView() const;
|
||||
|
||||
/**
|
||||
* Function getViewControls()
|
||||
|
@ -139,14 +139,14 @@ protected:
|
|||
* read & modify user input and its settings (eg. show cursor, enable snapping to grid, etc.)
|
||||
* @return The instance of VIEW_CONTROLS.
|
||||
*/
|
||||
KiGfx::VIEW_CONTROLS* getViewControls() const;
|
||||
KIGFX::VIEW_CONTROLS* getViewControls() const;
|
||||
|
||||
/**
|
||||
* Function getEditFrame()
|
||||
*
|
||||
* Returns the application window object, casted to requested user type.
|
||||
*/
|
||||
template<typename T>
|
||||
template <typename T>
|
||||
T* getEditFrame() const
|
||||
{
|
||||
return static_cast<T*>( getEditFrameInt() );
|
||||
|
@ -157,7 +157,7 @@ protected:
|
|||
*
|
||||
* Returns the model object if it matches the requested type.
|
||||
*/
|
||||
template<typename T>
|
||||
template <typename T>
|
||||
T* getModel( KICAD_T modelType ) const
|
||||
{
|
||||
EDA_ITEM* m = getModelInt();
|
||||
|
|
|
@ -32,8 +32,8 @@
|
|||
class TOOL_MANAGER;
|
||||
class PCB_BASE_FRAME;
|
||||
|
||||
namespace KiGfx {
|
||||
class VIEW;
|
||||
namespace KIGFX {
|
||||
class VIEW;
|
||||
};
|
||||
|
||||
/**
|
||||
|
@ -96,22 +96,23 @@ private:
|
|||
bool handleMouseButton( wxEvent& aEvent, int aIndex, bool aMotion );
|
||||
|
||||
///> Saves the state of key modifiers (Alt, Ctrl and so on).
|
||||
template<class EventType>
|
||||
template <class EventType>
|
||||
static int decodeModifiers( const EventType* aState )
|
||||
{
|
||||
int mods = 0;
|
||||
|
||||
if( aState->ControlDown() )
|
||||
mods |= MD_ModCtrl;
|
||||
|
||||
if( aState->AltDown() )
|
||||
mods |= MD_ModAlt;
|
||||
|
||||
if( aState->ShiftDown() )
|
||||
mods |= MD_ModShift;
|
||||
|
||||
return mods;
|
||||
}
|
||||
|
||||
|
||||
///> Stores all the informations regarding a mouse button state.
|
||||
struct ButtonState;
|
||||
|
||||
|
@ -122,7 +123,7 @@ private:
|
|||
std::vector<ButtonState*> m_buttons;
|
||||
|
||||
///> Returns the instance of VIEW, used by the application.
|
||||
KiGfx::VIEW* getView();
|
||||
KIGFX::VIEW* getView();
|
||||
|
||||
///> Instance of tool manager that cooperates with the dispatcher.
|
||||
TOOL_MANAGER* m_toolMgr;
|
||||
|
|
|
@ -142,7 +142,7 @@ public:
|
|||
const std::string Format() const;
|
||||
|
||||
TOOL_EVENT( TOOL_EventCategory aCategory = TC_None, TOOL_Actions aAction = TA_None,
|
||||
TOOL_ActionScope aScope = AS_GLOBAL ) :
|
||||
TOOL_ActionScope aScope = AS_GLOBAL ) :
|
||||
m_category( aCategory ),
|
||||
m_actions( aAction ),
|
||||
m_scope( aScope ),
|
||||
|
@ -150,40 +150,43 @@ public:
|
|||
m_keyCode( 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_actions( aAction ),
|
||||
m_scope( aScope )
|
||||
{
|
||||
if( aCategory == TC_Mouse )
|
||||
{
|
||||
if( aCategory == TC_Mouse )
|
||||
{
|
||||
m_mouseButtons = aExtraParam & MB_ButtonMask;
|
||||
}
|
||||
else if( aCategory == TC_Keyboard )
|
||||
{
|
||||
m_keyCode = aExtraParam & ~MD_ModifierMask; // Filter out modifiers
|
||||
}
|
||||
else if ( aCategory == TC_Command )
|
||||
{
|
||||
m_commandId = aExtraParam;
|
||||
}
|
||||
|
||||
if( aCategory & ( TC_Mouse | TC_Keyboard ) )
|
||||
{
|
||||
m_modifiers = aExtraParam & MD_ModifierMask;
|
||||
}
|
||||
m_mouseButtons = aExtraParam & MB_ButtonMask;
|
||||
}
|
||||
else if( aCategory == TC_Keyboard )
|
||||
{
|
||||
m_keyCode = aExtraParam & ~MD_ModifierMask; // Filter out modifiers
|
||||
}
|
||||
else if( aCategory == TC_Command )
|
||||
{
|
||||
m_commandId = aExtraParam;
|
||||
}
|
||||
|
||||
if( aCategory & ( TC_Mouse | TC_Keyboard ) )
|
||||
{
|
||||
m_modifiers = aExtraParam & MD_ModifierMask;
|
||||
}
|
||||
}
|
||||
|
||||
TOOL_EVENT( TOOL_EventCategory aCategory, TOOL_Actions aAction,
|
||||
const std::string& aExtraParam, TOOL_ActionScope aScope = AS_GLOBAL ) :
|
||||
const std::string& aExtraParam, TOOL_ActionScope aScope = AS_GLOBAL ) :
|
||||
m_category( aCategory ),
|
||||
m_actions( aAction ),
|
||||
m_scope( aScope ),
|
||||
m_mouseButtons( 0 )
|
||||
{
|
||||
if( aCategory == TC_Command )
|
||||
m_commandStr = aExtraParam;
|
||||
}
|
||||
{
|
||||
if( aCategory == TC_Command )
|
||||
m_commandStr = aExtraParam;
|
||||
}
|
||||
|
||||
///> Returns the category (eg. mouse/keyboard/action) of an event..
|
||||
TOOL_EventCategory Category() const
|
||||
|
@ -201,35 +204,35 @@ public:
|
|||
///> where dragging has started.
|
||||
const VECTOR2D Delta() const
|
||||
{
|
||||
assert( m_category == TC_Mouse ); // this should be used only with mouse events
|
||||
assert( m_category == TC_Mouse ); // this should be used only with mouse events
|
||||
return m_mouseDelta;
|
||||
}
|
||||
|
||||
///> Returns mouse cursor position in world coordinates.
|
||||
const VECTOR2D& Position() const
|
||||
{
|
||||
assert( m_category == TC_Mouse ); // this should be used only with mouse events
|
||||
assert( m_category == TC_Mouse ); // this should be used only with mouse events
|
||||
return m_mousePos;
|
||||
}
|
||||
|
||||
///> Returns the point where dragging has started.
|
||||
const VECTOR2D& DragOrigin() const
|
||||
{
|
||||
assert( m_category == TC_Mouse ); // this should be used only with mouse events
|
||||
assert( m_category == TC_Mouse ); // this should be used only with mouse events
|
||||
return m_mouseDragOrigin;
|
||||
}
|
||||
|
||||
///> Returns information about mouse buttons state.
|
||||
int Buttons() const
|
||||
{
|
||||
assert( m_category == TC_Mouse ); // this should be used only with mouse events
|
||||
assert( m_category == TC_Mouse ); // this should be used only with mouse events
|
||||
return m_mouseButtons;
|
||||
}
|
||||
|
||||
bool IsClick( int aButtonMask = MB_Any ) const
|
||||
{
|
||||
return ( m_actions == TA_MouseClick )
|
||||
&& ( ( m_mouseButtons & aButtonMask ) == aButtonMask );
|
||||
&& ( ( m_mouseButtons & aButtonMask ) == aButtonMask );
|
||||
}
|
||||
|
||||
bool IsDrag( int aButtonMask = MB_Any ) const
|
||||
|
@ -244,7 +247,7 @@ public:
|
|||
|
||||
bool IsMotion() const
|
||||
{
|
||||
return ( m_actions == TA_MouseMotion );
|
||||
return m_actions == TA_MouseMotion;
|
||||
}
|
||||
|
||||
bool IsCancel() const
|
||||
|
@ -255,7 +258,7 @@ public:
|
|||
///> Returns information about key modifiers state (Ctrl, Alt, etc.)
|
||||
int Modifier( int aMask = MD_ModifierMask ) const
|
||||
{
|
||||
return ( m_modifiers & aMask );
|
||||
return m_modifiers & aMask;
|
||||
}
|
||||
|
||||
int KeyCode() const
|
||||
|
@ -273,7 +276,7 @@ public:
|
|||
return m_actions == TA_KeyDown;
|
||||
}
|
||||
|
||||
void SetMouseDragOrigin( const VECTOR2D &aP )
|
||||
void SetMouseDragOrigin( const VECTOR2D& aP )
|
||||
{
|
||||
m_mouseDragOrigin = aP;
|
||||
}
|
||||
|
@ -306,9 +309,10 @@ public:
|
|||
if( m_category == TC_Command )
|
||||
{
|
||||
if( m_commandStr && aEvent.m_commandStr )
|
||||
return ( *m_commandStr == *aEvent.m_commandStr );
|
||||
return *m_commandStr == *aEvent.m_commandStr;
|
||||
|
||||
if( m_commandId && aEvent.m_commandId )
|
||||
return ( *m_commandId == *aEvent.m_commandId );
|
||||
return *m_commandId == *aEvent.m_commandId;
|
||||
}
|
||||
|
||||
return true;
|
||||
|
@ -365,7 +369,8 @@ typedef boost::optional<TOOL_EVENT> OPT_TOOL_EVENT;
|
|||
* A list of TOOL_EVENTs, with overloaded || operators allowing for
|
||||
* concatenating TOOL_EVENTs with little code.
|
||||
*/
|
||||
class TOOL_EVENT_LIST {
|
||||
class TOOL_EVENT_LIST
|
||||
{
|
||||
public:
|
||||
typedef TOOL_EVENT value_type;
|
||||
typedef std::deque<TOOL_EVENT>::iterator iterator;
|
||||
|
@ -388,11 +393,12 @@ public:
|
|||
*/
|
||||
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 )
|
||||
if ( i->Matches( b ) )
|
||||
if( i->Matches( b ) )
|
||||
return *i;
|
||||
|
||||
return boost::optional<const TOOL_EVENT&>();
|
||||
}
|
||||
|
||||
|
@ -441,9 +447,9 @@ public:
|
|||
m_events.clear();
|
||||
|
||||
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;
|
||||
|
@ -481,6 +487,7 @@ inline const TOOL_EVENT_LIST operator||( const TOOL_EVENT& a, const TOOL_EVENT&
|
|||
return l;
|
||||
}
|
||||
|
||||
|
||||
inline const TOOL_EVENT_LIST operator||( const TOOL_EVENT& a, const TOOL_EVENT_LIST& b )
|
||||
{
|
||||
TOOL_EVENT_LIST l( b );
|
||||
|
|
|
@ -81,9 +81,9 @@ public:
|
|||
* Defines which state (aStateFunc) to go when a certain event arrives (aConditions).
|
||||
* No conditions means any event.
|
||||
*/
|
||||
template<class T>
|
||||
void Go( int (T::*aStateFunc)( TOOL_EVENT& ),
|
||||
const TOOL_EVENT_LIST& aConditions = TOOL_EVENT( TC_Any, TA_Any ) );
|
||||
template <class T>
|
||||
void Go( int (T::* aStateFunc)( TOOL_EVENT& ),
|
||||
const TOOL_EVENT_LIST& aConditions = TOOL_EVENT( TC_Any, TA_Any ) );
|
||||
|
||||
/**
|
||||
* Function Wait()
|
||||
|
@ -91,18 +91,18 @@ public:
|
|||
* Suspends execution of the tool until an event specified in aEventList arrives.
|
||||
* 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 */
|
||||
/*template<class Parameters, class ReturnValue>
|
||||
/*template <class Parameters, class ReturnValue>
|
||||
bool InvokeTool( const std::string& aToolName, const Parameters& parameters,
|
||||
ReturnValue& returnValue );
|
||||
|
||||
template<class Parameters, class ReturnValue>
|
||||
template <class Parameters, class ReturnValue>
|
||||
bool InvokeWindow( const std::string& aWindowName, const Parameters& parameters,
|
||||
ReturnValue& returnValue );
|
||||
|
||||
template<class T>
|
||||
template <class T>
|
||||
void Yield( const T& returnValue );*/
|
||||
|
||||
protected:
|
||||
|
@ -121,11 +121,12 @@ private:
|
|||
};
|
||||
|
||||
// hide TOOL_MANAGER implementation
|
||||
template<class T>
|
||||
void TOOL_INTERACTIVE::Go( int (T::*aStateFunc)( TOOL_EVENT& ),
|
||||
const TOOL_EVENT_LIST& aConditions )
|
||||
template <class T>
|
||||
void TOOL_INTERACTIVE::Go( int (T::* aStateFunc)( TOOL_EVENT& ),
|
||||
const TOOL_EVENT_LIST& aConditions )
|
||||
{
|
||||
TOOL_STATE_FUNC sptr( static_cast<T*>( this ), aStateFunc );
|
||||
|
||||
goInternal( sptr, aConditions );
|
||||
}
|
||||
|
||||
|
|
|
@ -134,16 +134,16 @@ public:
|
|||
* These are made available to the tool. Called by the parent frame (PCB_EDIT_FRAME)
|
||||
* when the board is set up.
|
||||
*/
|
||||
void SetEnvironment( EDA_ITEM* aModel, KiGfx::VIEW* aView,
|
||||
KiGfx::VIEW_CONTROLS* aViewControls, wxWindow* aFrame );
|
||||
void SetEnvironment( EDA_ITEM* aModel, KIGFX::VIEW* aView,
|
||||
KIGFX::VIEW_CONTROLS* aViewControls, wxWindow* aFrame );
|
||||
|
||||
/* Accessors for the environment objects (view, model, etc.) */
|
||||
KiGfx::VIEW* GetView() const
|
||||
KIGFX::VIEW* GetView() const
|
||||
{
|
||||
return m_view;
|
||||
}
|
||||
|
||||
KiGfx::VIEW_CONTROLS* GetViewControls() const
|
||||
KIGFX::VIEW_CONTROLS* GetViewControls() const
|
||||
{
|
||||
return m_viewControls;
|
||||
}
|
||||
|
@ -163,7 +163,7 @@ public:
|
|||
* to be called. Called by TOOL_INTERACTIVE::Go(). May be called from a coroutine context.
|
||||
*/
|
||||
void ScheduleNextState( TOOL_BASE* aTool, TOOL_STATE_FUNC& aHandler,
|
||||
const TOOL_EVENT_LIST& aConditions );
|
||||
const TOOL_EVENT_LIST& aConditions );
|
||||
|
||||
/**
|
||||
* Pauses execution of a given tool until one or more events matching aConditions arrives.
|
||||
|
@ -171,7 +171,7 @@ public:
|
|||
* Called only from coroutines.
|
||||
*/
|
||||
boost::optional<TOOL_EVENT> ScheduleWait( TOOL_BASE* aTool,
|
||||
const TOOL_EVENT_LIST& aConditions );
|
||||
const TOOL_EVENT_LIST& aConditions );
|
||||
|
||||
/**
|
||||
* Sets behaviour of the tool's context popup menu.
|
||||
|
@ -183,7 +183,7 @@ public:
|
|||
* May be called from a coroutine context.
|
||||
*/
|
||||
void ScheduleContextMenu( TOOL_BASE* aTool, CONTEXT_MENU* aMenu,
|
||||
CONTEXT_MENU_TRIGGER aTrigger );
|
||||
CONTEXT_MENU_TRIGGER aTrigger );
|
||||
|
||||
/**
|
||||
* Allows a tool to pass the already handled event to the next tool on the stack.
|
||||
|
@ -251,7 +251,7 @@ private:
|
|||
bool runTool( TOOL_BASE* aTool );
|
||||
|
||||
template <class Parameters>
|
||||
void invokeTool( const std::string& aName, const Parameters& aToolParams );
|
||||
void invokeTool( const std::string& aName, const Parameters& aToolParams );
|
||||
|
||||
/**
|
||||
* Function finishTool()
|
||||
|
@ -270,7 +270,7 @@ private:
|
|||
*/
|
||||
bool isRegistered( TOOL_BASE* aTool ) const
|
||||
{
|
||||
return ( m_toolState.count( aTool ) > 0 );
|
||||
return m_toolState.count( aTool ) > 0;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -298,8 +298,8 @@ private:
|
|||
ACTION_MANAGER* m_actionMgr;
|
||||
|
||||
EDA_ITEM* m_model;
|
||||
KiGfx::VIEW* m_view;
|
||||
KiGfx::VIEW_CONTROLS* m_viewControls;
|
||||
KIGFX::VIEW* m_view;
|
||||
KIGFX::VIEW_CONTROLS* m_viewControls;
|
||||
wxWindow* m_editFrame;
|
||||
|
||||
/// Flag saying if the currently processed event should be passed to other tools.
|
||||
|
|
|
@ -32,7 +32,7 @@
|
|||
#include <math/box2.h>
|
||||
#include <gal/definitions.h>
|
||||
|
||||
namespace KiGfx
|
||||
namespace KIGFX
|
||||
{
|
||||
class PAINTER;
|
||||
class GAL;
|
||||
|
@ -76,14 +76,14 @@ public:
|
|||
* Adds a VIEW_ITEM to the view.
|
||||
* @param aItem: item to be added. No ownership is given
|
||||
*/
|
||||
void Add( VIEW_ITEM* aItem );
|
||||
void Add( VIEW_ITEM* aItem );
|
||||
|
||||
/**
|
||||
* Function Remove()
|
||||
* Removes a VIEW_ITEM from the view.
|
||||
* @param aItem: item to be removed. Caller must dispose the removed item if necessary
|
||||
*/
|
||||
void Remove( VIEW_ITEM* aItem );
|
||||
void Remove( VIEW_ITEM* aItem );
|
||||
|
||||
/**
|
||||
* Function Query()
|
||||
|
@ -94,7 +94,7 @@ public:
|
|||
* first).
|
||||
* @return Number of found items.
|
||||
*/
|
||||
int Query( const BOX2I& aRect, std::vector<LayerItemPair>& aResult );
|
||||
int Query( const BOX2I& aRect, std::vector<LayerItemPair>& aResult );
|
||||
|
||||
/**
|
||||
* Function SetRequired()
|
||||
|
@ -104,19 +104,19 @@ public:
|
|||
* @param aRequiredId is the id of the required layer.
|
||||
* @param aRequired tells if the required layer should be added or removed from the list.
|
||||
*/
|
||||
void SetRequired( int aLayerId, int aRequiredId, bool aRequired = true );
|
||||
void SetRequired( int aLayerId, int aRequiredId, bool aRequired = true );
|
||||
|
||||
/**
|
||||
* Function CopySettings()
|
||||
* Copies layers and visibility settings from another view.
|
||||
* @param aOtherView: view from which settings will be copied.
|
||||
*/
|
||||
void CopySettings( const VIEW* aOtherView );
|
||||
void CopySettings( const VIEW* aOtherView );
|
||||
|
||||
/*
|
||||
* Convenience wrappers for adding multiple items
|
||||
* template<class T> void AddItems( const T& aItems );
|
||||
* template<class T> void RemoveItems( const T& aItems );
|
||||
* template <class T> void AddItems( const T& aItems );
|
||||
* template <class T> void RemoveItems( const T& aItems );
|
||||
*/
|
||||
|
||||
/**
|
||||
|
@ -124,27 +124,27 @@ public:
|
|||
* Assigns a rendering device for the VIEW.
|
||||
* @param aGal: pointer to the GAL output device
|
||||
*/
|
||||
void SetGAL( GAL* aGal );
|
||||
void SetGAL( GAL* aGal );
|
||||
|
||||
/**
|
||||
* Function GetGAL()
|
||||
* Returns the GAL this view is using to draw graphical primitives.
|
||||
* @return Pointer to the currently used GAL instance.
|
||||
*/
|
||||
GAL* GetGAL() const { return m_gal; }
|
||||
GAL* GetGAL() const { return m_gal; }
|
||||
|
||||
/**
|
||||
* Function SetPainter()
|
||||
* Sets the painter object used by the view for drawing VIEW_ITEMS.
|
||||
*/
|
||||
void SetPainter( PAINTER* aPainter );
|
||||
void SetPainter( PAINTER* aPainter );
|
||||
|
||||
/**
|
||||
* Function GetPainter()
|
||||
* Returns the painter object used by the view for drawing VIEW_ITEMS.
|
||||
* @return Pointer to the currently used Painter instance.
|
||||
*/
|
||||
PAINTER* GetPainter() const { return m_painter; };
|
||||
PAINTER* GetPainter() const { return m_painter; };
|
||||
|
||||
/**
|
||||
* Function SetViewport()
|
||||
|
@ -152,14 +152,14 @@ public:
|
|||
* @param aViewport: desired visible area, in world space coordinates.
|
||||
* @param aKeepProportions: when true, the X/Y size proportions are kept.
|
||||
*/
|
||||
void SetViewport( const BOX2D& aViewport, bool aKeepProportions = true );
|
||||
void SetViewport( const BOX2D& aViewport, bool aKeepProportions = true );
|
||||
|
||||
/**
|
||||
* Function GetViewport()
|
||||
* Returns the current viewport visible area rectangle.
|
||||
* @return Current viewport rectangle
|
||||
*/
|
||||
BOX2D GetViewport() const;
|
||||
BOX2D GetViewport() const;
|
||||
|
||||
/**
|
||||
* Function SetMirror()
|
||||
|
@ -167,7 +167,7 @@ public:
|
|||
* @param aMirrorX: when true, the X axis is mirrored
|
||||
* @param aMirrorY: when true, the Y axis is mirrored.
|
||||
*/
|
||||
void SetMirror( bool aMirrorX, bool aMirrorY );
|
||||
void SetMirror( bool aMirrorX, bool aMirrorY );
|
||||
|
||||
/**
|
||||
* Function SetScale()
|
||||
|
@ -175,7 +175,7 @@ public:
|
|||
* (depending on correct GAL unit length & DPI settings).
|
||||
* @param aScale: the scalefactor
|
||||
*/
|
||||
void SetScale( double aScale );
|
||||
void SetScale( double aScale );
|
||||
|
||||
/**
|
||||
* Function SetScale()
|
||||
|
@ -183,7 +183,7 @@ public:
|
|||
* (depending on correct GAL unit length & DPI settings).
|
||||
* @param aScale: the scale factor
|
||||
*/
|
||||
void SetScale( double aScale, const VECTOR2D& aAnchor );
|
||||
void SetScale( double aScale, const VECTOR2D& aAnchor );
|
||||
|
||||
/**
|
||||
* Function GetScale()
|
||||
|
@ -197,7 +197,7 @@ public:
|
|||
* of the screen).
|
||||
* @param aCenter: the new center point, in world space coordinates.
|
||||
*/
|
||||
void SetCenter( const VECTOR2D& aCenter );
|
||||
void SetCenter( const VECTOR2D& aCenter );
|
||||
|
||||
/**
|
||||
* Function GetCenter()
|
||||
|
@ -212,7 +212,7 @@ public:
|
|||
* @param aCoord: the point/vector to be converted
|
||||
* @param aAbsolute: when true, aCoord is treated as a point, otherwise - as a direction (vector)
|
||||
*/
|
||||
VECTOR2D ToWorld( const VECTOR2D& aCoord, bool aAbsolute = true ) const;
|
||||
VECTOR2D ToWorld( const VECTOR2D& aCoord, bool aAbsolute = true ) const;
|
||||
|
||||
/**
|
||||
* Function ToScreen()
|
||||
|
@ -220,7 +220,7 @@ public:
|
|||
* @param aCoord: the point/vector to be converted
|
||||
* @param aAbsolute: when true, aCoord is treated as a point, otherwise - as a direction (vector)
|
||||
*/
|
||||
VECTOR2D ToScreen( const VECTOR2D& aCoord, bool aAbsolute = true ) const;
|
||||
VECTOR2D ToScreen( const VECTOR2D& aCoord, bool aAbsolute = true ) const;
|
||||
|
||||
/**
|
||||
* Function ToScreen()
|
||||
|
@ -228,14 +228,14 @@ public:
|
|||
* @param aCoord: the coordinate to be transformed.
|
||||
* @param aAbsolute: when true, aCoord is treated as a point, otherwise - as a direction (vector)
|
||||
*/
|
||||
double ToScreen( double aCoord, bool aAbsolute = true ) const;
|
||||
double ToScreen( double aCoord, bool aAbsolute = true ) const;
|
||||
|
||||
/**
|
||||
* Function GetScreenPixelSize()
|
||||
* Returns the size of the our rendering area, in pixels.
|
||||
* @return viewport screen size
|
||||
*/
|
||||
VECTOR2D GetScreenPixelSize() const;
|
||||
VECTOR2D GetScreenPixelSize() const;
|
||||
|
||||
/**
|
||||
* Function AddLayer()
|
||||
|
@ -244,20 +244,20 @@ public:
|
|||
* @param aDisplayOnly: layer is display-only (example: selection boxes, floating hints/menus).
|
||||
* Objects belonging to this layer are not taken into account by Query() method.
|
||||
*/
|
||||
void AddLayer( int aLayer, bool aDisplayOnly = false );
|
||||
void AddLayer( int aLayer, bool aDisplayOnly = false );
|
||||
|
||||
/**
|
||||
* Function ClearLayer()
|
||||
* Removes all items from a given layer.
|
||||
* @param aLayer: ID of the layer to be cleared
|
||||
*/
|
||||
void ClearLayer( int aLayer );
|
||||
void ClearLayer( int aLayer );
|
||||
|
||||
/**
|
||||
* Function Clear()
|
||||
* Removes all items from the view.
|
||||
*/
|
||||
void Clear();
|
||||
void Clear();
|
||||
|
||||
/**
|
||||
* Function SetLayerVisible()
|
||||
|
@ -302,7 +302,7 @@ public:
|
|||
* @param aLayer: the layer
|
||||
* @param aRenderingOrder: arbitrary number denoting the rendering order.
|
||||
*/
|
||||
void SetLayerOrder( int aLayer, int aRenderingOrder );
|
||||
void SetLayerOrder( int aLayer, int aRenderingOrder );
|
||||
|
||||
/**
|
||||
* Function GetLayerOrder()
|
||||
|
@ -310,7 +310,7 @@ public:
|
|||
* @param aLayer: the layer
|
||||
* @return Rendering order of a particular layer.
|
||||
*/
|
||||
int GetLayerOrder( int aLayer ) const;
|
||||
int GetLayerOrder( int aLayer ) const;
|
||||
|
||||
/**
|
||||
* Function SortLayers()
|
||||
|
@ -320,7 +320,7 @@ public:
|
|||
* @param aLayers stores id of layers to be sorted.
|
||||
* @param aCount stores the number of layers.
|
||||
*/
|
||||
void SortLayers( int aLayers[], int& aCount ) const;
|
||||
void SortLayers( int aLayers[], int& aCount ) const;
|
||||
|
||||
/**
|
||||
* Function UpdateLayerColor()
|
||||
|
@ -328,14 +328,14 @@ public:
|
|||
* @param aLayer is a number of the layer to be updated.
|
||||
* @see RENDER_SETTINGS
|
||||
*/
|
||||
void UpdateLayerColor( int aLayer );
|
||||
void UpdateLayerColor( int aLayer );
|
||||
|
||||
/**
|
||||
* Function UpdateAllLayersColor()
|
||||
* Applies the new coloring scheme to all layers. The used scheme is held by RENDER_SETTINGS.
|
||||
* @see RENDER_SETTINGS
|
||||
*/
|
||||
void UpdateAllLayersColor();
|
||||
void UpdateAllLayersColor();
|
||||
|
||||
/**
|
||||
* Function ChangeLayerDepth()
|
||||
|
@ -343,7 +343,7 @@ public:
|
|||
* @param aLayer is a number of the layer to be updated.
|
||||
* @param aDepth is the new depth.
|
||||
*/
|
||||
void ChangeLayerDepth( int aLayer, int aDepth );
|
||||
void ChangeLayerDepth( int aLayer, int aDepth );
|
||||
|
||||
/**
|
||||
* Function SetTopLayer()
|
||||
|
@ -351,7 +351,7 @@ public:
|
|||
* @param aLayer: the layer or -1 in case when no particular layer should
|
||||
* be displayed on the top.
|
||||
*/
|
||||
void SetTopLayer( int aLayer, bool aEnabled = true );
|
||||
void SetTopLayer( int aLayer, bool aEnabled = true );
|
||||
|
||||
/**
|
||||
* Function EnableTopLayer()
|
||||
|
@ -360,42 +360,42 @@ public:
|
|||
* layer set previously with SetTopLayer function.
|
||||
* @param aEnabled: whether to enable or disable display of the top layer.
|
||||
*/
|
||||
void EnableTopLayer( bool aEnable );
|
||||
void EnableTopLayer( bool aEnable );
|
||||
|
||||
int GetTopLayer() const;
|
||||
int GetTopLayer() const;
|
||||
|
||||
/**
|
||||
* Function ClearTopLayers()
|
||||
* Removes all layers from the on-the-top set (they are no longer displayed over the rest of
|
||||
* layers).
|
||||
*/
|
||||
void ClearTopLayers();
|
||||
void ClearTopLayers();
|
||||
|
||||
/**
|
||||
* Function UpdateLayerOrder()
|
||||
* Does everything that is needed to apply the rendering order of layers. It has to be called
|
||||
* after modification of renderingOrder field of LAYER.
|
||||
*/
|
||||
void UpdateAllLayersOrder();
|
||||
void UpdateAllLayersOrder();
|
||||
|
||||
/**
|
||||
* Function ClearTargets()
|
||||
* Clears targets that are marked as dirty.
|
||||
*/
|
||||
void ClearTargets();
|
||||
void ClearTargets();
|
||||
|
||||
/**
|
||||
* Function Redraw()
|
||||
* Immediately redraws the whole view.
|
||||
*/
|
||||
void Redraw();
|
||||
void Redraw();
|
||||
|
||||
/**
|
||||
* Function PartialRedraw()
|
||||
* Redraws only the parts of the view that have been affected by items
|
||||
* for which ViewUpdate() function has been called since last redraw.
|
||||
*/
|
||||
void PartialRedraw();
|
||||
void PartialRedraw();
|
||||
|
||||
/**
|
||||
* Function RecacheAllItems()
|
||||
|
@ -403,21 +403,21 @@ public:
|
|||
* @param aForceNow decides if every item should be instantly recached. Otherwise items are
|
||||
* going to be recached when they become visible.
|
||||
*/
|
||||
void RecacheAllItems( bool aForceNow = false );
|
||||
void RecacheAllItems( bool aForceNow = false );
|
||||
|
||||
/**
|
||||
* Function IsDynamic()
|
||||
* Tells if the VIEW is dynamic (ie. can be changed, for example displaying PCBs in a window)
|
||||
* or static (that cannot be modified, eg. displaying image/PDF).
|
||||
*/
|
||||
bool IsDynamic() const { return m_dynamic; }
|
||||
bool IsDynamic() const { return m_dynamic; }
|
||||
|
||||
/**
|
||||
* Function IsDirty()
|
||||
* Returns true if any of the VIEW layers needs to be refreshened.
|
||||
* @return True in case if any of layers is marked as dirty.
|
||||
*/
|
||||
bool IsDirty() const;
|
||||
bool IsDirty() const;
|
||||
|
||||
/**
|
||||
* Function IsTargetDirty()
|
||||
|
@ -442,7 +442,7 @@ public:
|
|||
/// Returns true if the layer is cached
|
||||
inline bool IsCached( int aLayer ) const
|
||||
{
|
||||
return ( m_layers.at( aLayer ).target == TARGET_CACHED );
|
||||
return m_layers.at( aLayer ).target == TARGET_CACHED;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -526,7 +526,7 @@ private:
|
|||
* @param aImmediate dictates the way of drawing - it allows to force immediate drawing mode
|
||||
* for cached items.
|
||||
*/
|
||||
void draw( VIEW_ITEM* aItem, int aLayer, bool aImmediate = false ) const;
|
||||
void draw( VIEW_ITEM* aItem, int aLayer, bool aImmediate = false ) const;
|
||||
|
||||
/**
|
||||
* Function draw()
|
||||
|
@ -536,7 +536,7 @@ private:
|
|||
* @param aImmediate dictates the way of drawing - it allows to force immediate drawing mode
|
||||
* for cached items.
|
||||
*/
|
||||
void draw( VIEW_ITEM* aItem, bool aImmediate = false ) const;
|
||||
void draw( VIEW_ITEM* aItem, bool aImmediate = false ) const;
|
||||
|
||||
/**
|
||||
* Function draw()
|
||||
|
@ -546,7 +546,7 @@ private:
|
|||
* @param aImmediate dictates the way of drawing - it allows to force immediate drawing mode
|
||||
* for cached items.
|
||||
*/
|
||||
void draw( VIEW_GROUP* aGroup, bool aImmediate = false ) const;
|
||||
void draw( VIEW_GROUP* aGroup, bool aImmediate = false ) const;
|
||||
|
||||
|
||||
///* Manages dirty flags & redraw queueing when updating an item. Called internally
|
||||
|
@ -585,42 +585,42 @@ private:
|
|||
bool m_enableOrderModifier;
|
||||
|
||||
/// Contains set of possible displayed layers and its properties
|
||||
LayerMap m_layers;
|
||||
LayerMap m_layers;
|
||||
|
||||
/// Sorted list of pointers to members of m_layers
|
||||
LayerOrder m_orderedLayers;
|
||||
LayerOrder m_orderedLayers;
|
||||
|
||||
/// Stores set of layers that are displayed on the top
|
||||
std::set<unsigned int> m_topLayers;
|
||||
|
||||
/// Center point of the VIEW (the point at which we are looking at)
|
||||
VECTOR2D m_center;
|
||||
VECTOR2D m_center;
|
||||
|
||||
/// Scale of displayed VIEW_ITEMs
|
||||
double m_scale;
|
||||
double m_scale;
|
||||
|
||||
/// PAINTER contains information how do draw items
|
||||
PAINTER* m_painter;
|
||||
PAINTER* m_painter;
|
||||
|
||||
/// Gives interface to PAINTER, that is used to draw items
|
||||
GAL* m_gal;
|
||||
GAL* m_gal;
|
||||
|
||||
/// Dynamic VIEW (eg. display PCB in window) allows changes once it is built,
|
||||
/// static (eg. image/PDF) - does not.
|
||||
bool m_dynamic;
|
||||
bool m_dynamic;
|
||||
|
||||
/// Flags to mark targets as dirty, so they have to be redrawn on the next refresh event
|
||||
bool m_dirtyTargets[TARGETS_NUMBER];
|
||||
bool m_dirtyTargets[TARGETS_NUMBER];
|
||||
|
||||
/// Rendering order modifier for layers that are marked as top layers
|
||||
static const int TOP_LAYER_MODIFIER = -VIEW_MAX_LAYERS;
|
||||
|
||||
/// Panning boundaries
|
||||
BOX2I m_panBoundary;
|
||||
BOX2I m_panBoundary;
|
||||
|
||||
/// Zoom limits
|
||||
VECTOR2D m_scaleLimits;
|
||||
VECTOR2D m_scaleLimits;
|
||||
};
|
||||
} // namespace KiGfx
|
||||
} // namespace KIGFX
|
||||
|
||||
#endif
|
||||
|
|
|
@ -34,7 +34,7 @@
|
|||
|
||||
#include <math/box2.h>
|
||||
|
||||
namespace KiGfx
|
||||
namespace KIGFX
|
||||
{
|
||||
class VIEW;
|
||||
|
||||
|
@ -167,6 +167,6 @@ protected:
|
|||
/// How fast is panning when in auto mode
|
||||
float m_autoPanSpeed;
|
||||
};
|
||||
} // namespace KiGfx
|
||||
} // namespace KIGFX
|
||||
|
||||
#endif
|
||||
|
|
|
@ -36,9 +36,8 @@
|
|||
#include <view/view_item.h>
|
||||
#include <deque>
|
||||
|
||||
namespace KiGfx
|
||||
namespace KIGFX
|
||||
{
|
||||
|
||||
class VIEW_GROUP : public VIEW_ITEM
|
||||
{
|
||||
public:
|
||||
|
@ -146,7 +145,7 @@ public:
|
|||
*
|
||||
* @return Pointer to the VIEW instance.
|
||||
*/
|
||||
KiGfx::VIEW* GetView() const
|
||||
KIGFX::VIEW* GetView() const
|
||||
{
|
||||
return m_view;
|
||||
}
|
||||
|
@ -186,6 +185,6 @@ private:
|
|||
/// Container for storing VIEW_ITEMs
|
||||
std::set<VIEW_ITEM*> m_items;
|
||||
};
|
||||
} // namespace KiGfx
|
||||
} // namespace KIGFX
|
||||
|
||||
#endif // VIEW_GROUP_H_
|
||||
|
|
|
@ -40,7 +40,8 @@
|
|||
* Enum KICAD_T
|
||||
* 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
|
||||
|
||||
EOT = 0, ///< search types array terminator (End Of Types)
|
||||
|
@ -134,7 +135,7 @@ enum KICAD_T {
|
|||
};
|
||||
|
||||
|
||||
namespace KiGfx
|
||||
namespace KIGFX
|
||||
{
|
||||
// Forward declarations
|
||||
class GAL;
|
||||
|
@ -347,7 +348,7 @@ protected:
|
|||
*/
|
||||
inline virtual bool storesGroups() const
|
||||
{
|
||||
return ( m_groupsSize > 0 );
|
||||
return m_groupsSize > 0;
|
||||
}
|
||||
|
||||
/// Stores layer numbers used by the item.
|
||||
|
@ -367,8 +368,7 @@ protected:
|
|||
for( int i = 0; i < aCount; ++i )
|
||||
m_layers.set( aLayers[i] );
|
||||
}
|
||||
|
||||
};
|
||||
} // namespace KiGfx
|
||||
} // namespace KIGFX
|
||||
|
||||
#endif
|
||||
|
|
|
@ -29,7 +29,7 @@
|
|||
|
||||
#include <rtree.h>
|
||||
|
||||
namespace KiGfx
|
||||
namespace KIGFX
|
||||
{
|
||||
typedef RTree<VIEW_ITEM*, int, 2, float> VIEW_RTREE_BASE;
|
||||
|
||||
|
@ -88,6 +88,6 @@ public:
|
|||
|
||||
private:
|
||||
};
|
||||
} // namespace KiGfx
|
||||
} // namespace KIGFX
|
||||
|
||||
#endif
|
||||
|
|
|
@ -38,7 +38,7 @@
|
|||
|
||||
class EDA_DRAW_PANEL_GAL;
|
||||
|
||||
namespace KiGfx
|
||||
namespace KIGFX
|
||||
{
|
||||
/**
|
||||
* Class WX_VIEW_CONTROLS
|
||||
|
@ -74,6 +74,7 @@ public:
|
|||
void SetAutoPan( bool aEnabled )
|
||||
{
|
||||
m_autoPanEnabled = aEnabled;
|
||||
|
||||
if( m_state == AUTO_PANNING )
|
||||
m_state = IDLE;
|
||||
}
|
||||
|
@ -90,7 +91,8 @@ public:
|
|||
|
||||
private:
|
||||
/// Possible states for WX_VIEW_CONTROLS
|
||||
enum State {
|
||||
enum State
|
||||
{
|
||||
IDLE = 1, /// Nothing is happening
|
||||
DRAG_PANNING, /// Panning with mouse button pressed
|
||||
AUTO_PANNING, /// Panning on approaching borders of the frame
|
||||
|
@ -127,6 +129,6 @@ private:
|
|||
/// Timer repsonsible for handling autopanning
|
||||
wxTimer m_panTimer;
|
||||
};
|
||||
} // namespace KiGfx
|
||||
} // namespace KIGFX
|
||||
|
||||
#endif
|
||||
|
|
|
@ -40,7 +40,7 @@ class WS_DRAW_ITEM_RECT;
|
|||
class WS_DRAW_ITEM_POLYGON;
|
||||
class WS_DRAW_ITEM_TEXT;
|
||||
|
||||
namespace KiGfx
|
||||
namespace KIGFX
|
||||
{
|
||||
class GAL;
|
||||
|
||||
|
|
|
@ -172,7 +172,7 @@ void PCB_BASE_FRAME::SetBoard( BOARD* aBoard )
|
|||
|
||||
if( m_galCanvas )
|
||||
{
|
||||
KiGfx::VIEW* view = m_galCanvas->GetView();
|
||||
KIGFX::VIEW* view = m_galCanvas->GetView();
|
||||
|
||||
ViewReloadBoard( m_Pcb );
|
||||
|
||||
|
@ -185,7 +185,7 @@ void PCB_BASE_FRAME::SetBoard( BOARD* aBoard )
|
|||
|
||||
void PCB_BASE_FRAME::ViewReloadBoard( const BOARD* aBoard ) const
|
||||
{
|
||||
KiGfx::VIEW* view = m_galCanvas->GetView();
|
||||
KIGFX::VIEW* view = m_galCanvas->GetView();
|
||||
view->Clear();
|
||||
|
||||
// All of PCB drawing elements should be added to the VIEW
|
||||
|
@ -194,7 +194,7 @@ void PCB_BASE_FRAME::ViewReloadBoard( const BOARD* aBoard ) const
|
|||
// Load zones
|
||||
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
|
||||
|
@ -240,7 +240,7 @@ void PCB_BASE_FRAME::ViewReloadBoard( const BOARD* aBoard ) const
|
|||
}
|
||||
|
||||
// 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( GetScreenDesc().mb_str() ),
|
||||
&GetPageSettings(), &GetTitleBlock() );
|
||||
|
@ -520,10 +520,10 @@ void PCB_BASE_FRAME::OnTogglePadDrawMode( wxCommandEvent& aEvent )
|
|||
m_DisplayPadFill = DisplayOpt.DisplayPadFill = !m_DisplayPadFill;
|
||||
|
||||
// Apply new display options to the GAL canvas
|
||||
KiGfx::PCB_PAINTER* painter =
|
||||
static_cast<KiGfx::PCB_PAINTER*> ( m_galCanvas->GetView()->GetPainter() );
|
||||
KiGfx::PCB_RENDER_SETTINGS* settings =
|
||||
static_cast<KiGfx::PCB_RENDER_SETTINGS*> ( painter->GetSettings() );
|
||||
KIGFX::PCB_PAINTER* painter =
|
||||
static_cast<KIGFX::PCB_PAINTER*> ( m_galCanvas->GetView()->GetPainter() );
|
||||
KIGFX::PCB_RENDER_SETTINGS* settings =
|
||||
static_cast<KIGFX::PCB_RENDER_SETTINGS*> ( painter->GetSettings() );
|
||||
settings->LoadDisplayOptions( DisplayOpt );
|
||||
m_galCanvas->GetView()->RecacheAllItems( true );
|
||||
|
||||
|
@ -856,13 +856,13 @@ void PCB_BASE_FRAME::LoadSettings()
|
|||
m_DisplayModText = FILLED;
|
||||
|
||||
// Apply display settings for GAL
|
||||
KiGfx::VIEW* view = m_galCanvas->GetView();
|
||||
KIGFX::VIEW* view = m_galCanvas->GetView();
|
||||
|
||||
// Set rendering order and properties of layers
|
||||
for( LAYER_NUM i = 0; (unsigned) i < sizeof(GAL_LAYER_ORDER) / sizeof(LAYER_NUM); ++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 );
|
||||
|
||||
|
@ -870,13 +870,13 @@ void PCB_BASE_FRAME::LoadSettings()
|
|||
{
|
||||
// Copper layers are required for netname layers
|
||||
view->SetRequired( GetNetnameLayer( layer ), layer );
|
||||
view->SetLayerTarget( layer, KiGfx::TARGET_CACHED );
|
||||
view->SetLayerTarget( layer, KIGFX::TARGET_CACHED );
|
||||
}
|
||||
else if( IsNetnameLayer( layer ) )
|
||||
{
|
||||
// Netnames are drawn only when scale is sufficient (level of details)
|
||||
// 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()
|
|||
view->SetRequired( SOLDERPASTE_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
|
||||
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
|
||||
settings->ImportLegacyColors( m_Pcb->GetColorsSettings() );
|
||||
|
|
|
@ -396,7 +396,7 @@ void PCB_LAYER_WIDGET::OnLayerVisible( LAYER_NUM aLayer, bool isVisible, bool is
|
|||
EDA_DRAW_PANEL_GAL* galCanvas = myframe->GetGalCanvas();
|
||||
if( galCanvas )
|
||||
{
|
||||
KiGfx::VIEW* view = galCanvas->GetView();
|
||||
KIGFX::VIEW* view = galCanvas->GetView();
|
||||
view->SetLayerVisible( aLayer, isVisible );
|
||||
}
|
||||
|
||||
|
@ -418,7 +418,7 @@ void PCB_LAYER_WIDGET::OnRenderEnable( int aId, bool isEnabled )
|
|||
EDA_DRAW_PANEL_GAL *galCanvas = myframe->GetGalCanvas();
|
||||
if( galCanvas )
|
||||
{
|
||||
KiGfx::VIEW* view = galCanvas->GetView();
|
||||
KIGFX::VIEW* view = galCanvas->GetView();
|
||||
view->SetLayerVisible( ITEM_GAL_LAYER( aId ), isEnabled );
|
||||
}
|
||||
|
||||
|
|
|
@ -170,10 +170,10 @@ void DIALOG_DISPLAY_OPTIONS::OnOkClick(wxCommandEvent& event)
|
|||
DisplayOpt.DisplayNetNamesMode = m_ShowNetNamesOption->GetSelection();
|
||||
|
||||
// Apply changes to the GAL
|
||||
KiGfx::VIEW* view = m_Parent->GetGalCanvas()->GetView();
|
||||
KiGfx::PCB_PAINTER* painter = static_cast<KiGfx::PCB_PAINTER*>( view->GetPainter() );
|
||||
KiGfx::PCB_RENDER_SETTINGS* settings =
|
||||
static_cast<KiGfx::PCB_RENDER_SETTINGS*>( painter->GetSettings() );
|
||||
KIGFX::VIEW* view = m_Parent->GetGalCanvas()->GetView();
|
||||
KIGFX::PCB_PAINTER* painter = static_cast<KIGFX::PCB_PAINTER*>( view->GetPainter() );
|
||||
KIGFX::PCB_RENDER_SETTINGS* settings =
|
||||
static_cast<KIGFX::PCB_RENDER_SETTINGS*>( painter->GetSettings() );
|
||||
settings->LoadDisplayOptions( DisplayOpt );
|
||||
view->RecacheAllItems( true );
|
||||
|
||||
|
|
|
@ -159,10 +159,10 @@ void PCB_EDIT_FRAME::OnSelectOptionToolbar( wxCommandEvent& event )
|
|||
{
|
||||
int id = event.GetId();
|
||||
bool state = event.IsChecked();
|
||||
KiGfx::PCB_PAINTER* painter =
|
||||
static_cast<KiGfx::PCB_PAINTER*> ( m_galCanvas->GetView()->GetPainter() );
|
||||
KiGfx::PCB_RENDER_SETTINGS* settings =
|
||||
static_cast<KiGfx::PCB_RENDER_SETTINGS*> ( painter->GetSettings() );
|
||||
KIGFX::PCB_PAINTER* painter =
|
||||
static_cast<KIGFX::PCB_PAINTER*> ( m_galCanvas->GetView()->GetPainter() );
|
||||
KIGFX::PCB_RENDER_SETTINGS* settings =
|
||||
static_cast<KIGFX::PCB_RENDER_SETTINGS*> ( painter->GetSettings() );
|
||||
bool recache = false;
|
||||
|
||||
switch( id )
|
||||
|
|
|
@ -41,7 +41,7 @@
|
|||
#include <pcb_painter.h>
|
||||
#include <gal/graphics_abstraction_layer.h>
|
||||
|
||||
using namespace KiGfx;
|
||||
using namespace KIGFX;
|
||||
|
||||
PCB_RENDER_SETTINGS::PCB_RENDER_SETTINGS()
|
||||
{
|
||||
|
|
|
@ -49,7 +49,7 @@ class TEXTE_MODULE;
|
|||
class DIMENSION;
|
||||
class PCB_TARGET;
|
||||
|
||||
namespace KiGfx
|
||||
namespace KIGFX
|
||||
{
|
||||
class GAL;
|
||||
|
||||
|
@ -152,6 +152,6 @@ protected:
|
|||
void draw( const DIMENSION*, int );
|
||||
void draw( const PCB_TARGET* );
|
||||
};
|
||||
} // namespace KiGfx
|
||||
} // namespace KIGFX
|
||||
|
||||
#endif /* __CLASS_PAINTER_H */
|
||||
|
|
|
@ -774,8 +774,8 @@ bool PCB_EDIT_FRAME::IsMicroViaAcceptable( void )
|
|||
void PCB_EDIT_FRAME::setHighContrastLayer( LAYER_NUM aLayer )
|
||||
{
|
||||
// Set display settings for high contrast mode
|
||||
KiGfx::VIEW* view = m_galCanvas->GetView();
|
||||
KiGfx::RENDER_SETTINGS* rSettings = view->GetPainter()->GetSettings();
|
||||
KIGFX::VIEW* view = m_galCanvas->GetView();
|
||||
KIGFX::RENDER_SETTINGS* rSettings = view->GetPainter()->GetSettings();
|
||||
|
||||
setTopLayer( aLayer );
|
||||
|
||||
|
@ -817,7 +817,7 @@ void PCB_EDIT_FRAME::setHighContrastLayer( LAYER_NUM aLayer )
|
|||
void PCB_EDIT_FRAME::setTopLayer( LAYER_NUM aLayer )
|
||||
{
|
||||
// Set display settings for high contrast mode
|
||||
KiGfx::VIEW* view = m_galCanvas->GetView();
|
||||
KIGFX::VIEW* view = m_galCanvas->GetView();
|
||||
|
||||
view->ClearTopLayers();
|
||||
view->SetTopLayer( aLayer );
|
||||
|
@ -887,7 +887,7 @@ void PCB_EDIT_FRAME::syncLayerVisibilities()
|
|||
{
|
||||
m_Layers->SyncLayerVisibilities();
|
||||
|
||||
KiGfx::VIEW* view = m_galCanvas->GetView();
|
||||
KIGFX::VIEW* view = m_galCanvas->GetView();
|
||||
// Load layer & elements visibility settings
|
||||
for( LAYER_NUM i = 0; i < NB_LAYERS; ++i )
|
||||
{
|
||||
|
|
|
@ -329,4 +329,3 @@ private:
|
|||
};
|
||||
|
||||
#endif // __DIRECTION_H
|
||||
|
||||
|
|
|
@ -260,4 +260,3 @@ PNS_INDEX::NetItemsList* PNS_INDEX::GetItemsForNet( int aNet )
|
|||
}
|
||||
|
||||
#endif
|
||||
|
||||
|
|
|
@ -86,4 +86,3 @@ const std::string PNS_ITEM::GetKindStr() const
|
|||
PNS_ITEM::~PNS_ITEM()
|
||||
{
|
||||
}
|
||||
|
||||
|
|
|
@ -150,9 +150,8 @@ protected:
|
|||
PNS_NODE* m_owner;
|
||||
PNS_LAYERSET m_layers;
|
||||
|
||||
bool m_movable;
|
||||
int m_net;
|
||||
bool m_movable;
|
||||
int m_net;
|
||||
};
|
||||
|
||||
#endif // __PNS_ITEM_Ha
|
||||
|
||||
#endif // __PNS_ITEM_H
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue