Commit bc305859 authored by Maciej Suminski's avatar Maciej Suminski

Mainly case changes.

parent 0ac3e1fb
...@@ -325,7 +325,7 @@ void CAIRO_GAL::SetIsFill( bool aIsFillEnabled ) ...@@ -325,7 +325,7 @@ void CAIRO_GAL::SetIsFill( bool aIsFillEnabled )
if( isGrouping ) if( isGrouping )
{ {
GroupElement groupElement; GROUP_ELEMENT groupElement;
groupElement.command = CMD_SET_FILL; groupElement.command = CMD_SET_FILL;
groupElement.boolArgument = aIsFillEnabled; groupElement.boolArgument = aIsFillEnabled;
currentGroup->push_back( groupElement ); currentGroup->push_back( groupElement );
...@@ -340,7 +340,7 @@ void CAIRO_GAL::SetIsStroke( bool aIsStrokeEnabled ) ...@@ -340,7 +340,7 @@ void CAIRO_GAL::SetIsStroke( bool aIsStrokeEnabled )
if( isGrouping ) if( isGrouping )
{ {
GroupElement groupElement; GROUP_ELEMENT groupElement;
groupElement.command = CMD_SET_STROKE; groupElement.command = CMD_SET_STROKE;
groupElement.boolArgument = aIsStrokeEnabled; groupElement.boolArgument = aIsStrokeEnabled;
currentGroup->push_back( groupElement ); currentGroup->push_back( groupElement );
...@@ -355,7 +355,7 @@ void CAIRO_GAL::SetStrokeColor( const COLOR4D& aColor ) ...@@ -355,7 +355,7 @@ void CAIRO_GAL::SetStrokeColor( const COLOR4D& aColor )
if( isGrouping ) if( isGrouping )
{ {
GroupElement groupElement; GROUP_ELEMENT groupElement;
groupElement.command = CMD_SET_STROKECOLOR; groupElement.command = CMD_SET_STROKECOLOR;
groupElement.arguments[0] = strokeColor.r; groupElement.arguments[0] = strokeColor.r;
groupElement.arguments[1] = strokeColor.g; groupElement.arguments[1] = strokeColor.g;
...@@ -373,7 +373,7 @@ void CAIRO_GAL::SetFillColor( const COLOR4D& aColor ) ...@@ -373,7 +373,7 @@ void CAIRO_GAL::SetFillColor( const COLOR4D& aColor )
if( isGrouping ) if( isGrouping )
{ {
GroupElement groupElement; GROUP_ELEMENT groupElement;
groupElement.command = CMD_SET_FILLCOLOR; groupElement.command = CMD_SET_FILLCOLOR;
groupElement.arguments[0] = fillColor.r; groupElement.arguments[0] = fillColor.r;
groupElement.arguments[1] = fillColor.g; groupElement.arguments[1] = fillColor.g;
...@@ -392,7 +392,7 @@ void CAIRO_GAL::SetLineWidth( double aLineWidth ) ...@@ -392,7 +392,7 @@ void CAIRO_GAL::SetLineWidth( double aLineWidth )
if( isGrouping ) if( isGrouping )
{ {
GroupElement groupElement; GROUP_ELEMENT groupElement;
groupElement.command = CMD_SET_LINE_WIDTH; groupElement.command = CMD_SET_LINE_WIDTH;
groupElement.arguments[0] = aLineWidth; groupElement.arguments[0] = aLineWidth;
currentGroup->push_back( groupElement ); currentGroup->push_back( groupElement );
...@@ -446,7 +446,7 @@ void CAIRO_GAL::Rotate( double aAngle ) ...@@ -446,7 +446,7 @@ void CAIRO_GAL::Rotate( double aAngle )
if( isGrouping ) if( isGrouping )
{ {
GroupElement groupElement; GROUP_ELEMENT groupElement;
groupElement.command = CMD_ROTATE; groupElement.command = CMD_ROTATE;
groupElement.arguments[0] = aAngle; groupElement.arguments[0] = aAngle;
currentGroup->push_back( groupElement ); currentGroup->push_back( groupElement );
...@@ -464,7 +464,7 @@ void CAIRO_GAL::Translate( const VECTOR2D& aTranslation ) ...@@ -464,7 +464,7 @@ void CAIRO_GAL::Translate( const VECTOR2D& aTranslation )
if( isGrouping ) if( isGrouping )
{ {
GroupElement groupElement; GROUP_ELEMENT groupElement;
groupElement.command = CMD_TRANSLATE; groupElement.command = CMD_TRANSLATE;
groupElement.arguments[0] = aTranslation.x; groupElement.arguments[0] = aTranslation.x;
groupElement.arguments[1] = aTranslation.y; groupElement.arguments[1] = aTranslation.y;
...@@ -483,7 +483,7 @@ void CAIRO_GAL::Scale( const VECTOR2D& aScale ) ...@@ -483,7 +483,7 @@ void CAIRO_GAL::Scale( const VECTOR2D& aScale )
if( isGrouping ) if( isGrouping )
{ {
GroupElement groupElement; GROUP_ELEMENT groupElement;
groupElement.command = CMD_SCALE; groupElement.command = CMD_SCALE;
groupElement.arguments[0] = aScale.x; groupElement.arguments[0] = aScale.x;
groupElement.arguments[1] = aScale.y; groupElement.arguments[1] = aScale.y;
...@@ -502,7 +502,7 @@ void CAIRO_GAL::Save() ...@@ -502,7 +502,7 @@ void CAIRO_GAL::Save()
if( isGrouping ) if( isGrouping )
{ {
GroupElement groupElement; GROUP_ELEMENT groupElement;
groupElement.command = CMD_SAVE; groupElement.command = CMD_SAVE;
currentGroup->push_back( groupElement ); currentGroup->push_back( groupElement );
} }
...@@ -519,7 +519,7 @@ void CAIRO_GAL::Restore() ...@@ -519,7 +519,7 @@ void CAIRO_GAL::Restore()
if( isGrouping ) if( isGrouping )
{ {
GroupElement groupElement; GROUP_ELEMENT groupElement;
groupElement.command = CMD_RESTORE; groupElement.command = CMD_RESTORE;
currentGroup->push_back( groupElement ); currentGroup->push_back( groupElement );
} }
...@@ -538,7 +538,7 @@ int CAIRO_GAL::BeginGroup() ...@@ -538,7 +538,7 @@ int CAIRO_GAL::BeginGroup()
// a attribute was changed or when grouping stops with the end group method. // a attribute was changed or when grouping stops with the end group method.
storePath(); storePath();
Group group; GROUP group;
int groupNumber = getNewGroupNumber(); int groupNumber = getNewGroupNumber();
groups.insert( std::make_pair( groupNumber, group ) ); groups.insert( std::make_pair( groupNumber, group ) );
currentGroup = &groups[groupNumber]; currentGroup = &groups[groupNumber];
...@@ -564,7 +564,7 @@ void CAIRO_GAL::DrawGroup( int aGroupNumber ) ...@@ -564,7 +564,7 @@ void CAIRO_GAL::DrawGroup( int aGroupNumber )
storePath(); storePath();
for( Group::iterator it = groups[aGroupNumber].begin(); for( GROUP::iterator it = groups[aGroupNumber].begin();
it != groups[aGroupNumber].end(); ++it ) it != groups[aGroupNumber].end(); ++it )
{ {
switch( it->command ) switch( it->command )
...@@ -649,7 +649,7 @@ void CAIRO_GAL::ChangeGroupColor( int aGroupNumber, const COLOR4D& aNewColor ) ...@@ -649,7 +649,7 @@ void CAIRO_GAL::ChangeGroupColor( int aGroupNumber, const COLOR4D& aNewColor )
{ {
storePath(); storePath();
for( Group::iterator it = groups[aGroupNumber].begin(); for( GROUP::iterator it = groups[aGroupNumber].begin();
it != groups[aGroupNumber].end(); ++it ) it != groups[aGroupNumber].end(); ++it )
{ {
if( it->command == CMD_SET_FILLCOLOR || it->command == CMD_SET_STROKECOLOR ) if( it->command == CMD_SET_FILLCOLOR || it->command == CMD_SET_STROKECOLOR )
...@@ -675,7 +675,7 @@ void CAIRO_GAL::DeleteGroup( int aGroupNumber ) ...@@ -675,7 +675,7 @@ void CAIRO_GAL::DeleteGroup( int aGroupNumber )
storePath(); storePath();
// Delete the Cairo paths // Delete the Cairo paths
std::deque<GroupElement>::iterator it, end; std::deque<GROUP_ELEMENT>::iterator it, end;
for( it = groups[aGroupNumber].begin(), end = groups[aGroupNumber].end(); it != end; ++it ) for( it = groups[aGroupNumber].begin(), end = groups[aGroupNumber].end(); it != end; ++it )
{ {
...@@ -730,7 +730,7 @@ void CAIRO_GAL::RestoreScreen() ...@@ -730,7 +730,7 @@ void CAIRO_GAL::RestoreScreen()
} }
void CAIRO_GAL::SetTarget( RenderTarget aTarget ) void CAIRO_GAL::SetTarget( RENDER_TARGET aTarget )
{ {
// If the compositor is not set, that means that there is a recaching process going on // If the compositor is not set, that means that there is a recaching process going on
// and we do not need the compositor now // and we do not need the compositor now
...@@ -766,13 +766,13 @@ void CAIRO_GAL::SetTarget( RenderTarget aTarget ) ...@@ -766,13 +766,13 @@ void CAIRO_GAL::SetTarget( RenderTarget aTarget )
} }
RenderTarget CAIRO_GAL::GetTarget() const RENDER_TARGET CAIRO_GAL::GetTarget() const
{ {
return currentTarget; return currentTarget;
} }
void CAIRO_GAL::ClearTarget( RenderTarget aTarget ) void CAIRO_GAL::ClearTarget( RENDER_TARGET aTarget )
{ {
// Save the current state // Save the current state
unsigned int currentBuffer = compositor->GetBuffer(); unsigned int currentBuffer = compositor->GetBuffer();
...@@ -844,7 +844,7 @@ void CAIRO_GAL::storePath() ...@@ -844,7 +844,7 @@ void CAIRO_GAL::storePath()
// add this command to the group list; // add this command to the group list;
if( isStrokeEnabled ) if( isStrokeEnabled )
{ {
GroupElement groupElement; GROUP_ELEMENT groupElement;
groupElement.cairoPath = cairo_copy_path( currentContext ); groupElement.cairoPath = cairo_copy_path( currentContext );
groupElement.command = CMD_STROKE_PATH; groupElement.command = CMD_STROKE_PATH;
currentGroup->push_back( groupElement ); currentGroup->push_back( groupElement );
...@@ -852,7 +852,7 @@ void CAIRO_GAL::storePath() ...@@ -852,7 +852,7 @@ void CAIRO_GAL::storePath()
if( isFillEnabled ) if( isFillEnabled )
{ {
GroupElement groupElement; GROUP_ELEMENT groupElement;
groupElement.cairoPath = cairo_copy_path( currentContext ); groupElement.cairoPath = cairo_copy_path( currentContext );
groupElement.command = CMD_FILL_PATH; groupElement.command = CMD_FILL_PATH;
currentGroup->push_back( groupElement ); currentGroup->push_back( groupElement );
......
...@@ -45,7 +45,7 @@ CACHED_CONTAINER::CACHED_CONTAINER( unsigned int aSize ) : ...@@ -45,7 +45,7 @@ CACHED_CONTAINER::CACHED_CONTAINER( unsigned int aSize ) :
VERTEX_CONTAINER( aSize ), m_item( NULL ) VERTEX_CONTAINER( aSize ), m_item( NULL )
{ {
// In the beginning there is only free space // In the beginning there is only free space
m_freeChunks.insert( Chunk( aSize, 0 ) ); m_freeChunks.insert( CHUNK( aSize, 0 ) );
} }
...@@ -80,7 +80,7 @@ void CACHED_CONTAINER::FinishItem() ...@@ -80,7 +80,7 @@ void CACHED_CONTAINER::FinishItem()
int itemOffset = m_item->GetOffset(); int itemOffset = m_item->GetOffset();
// Add the not used memory back to the pool // Add the not used memory back to the pool
m_freeChunks.insert( Chunk( m_chunkSize - m_itemSize, itemOffset + m_itemSize ) ); m_freeChunks.insert( CHUNK( m_chunkSize - m_itemSize, itemOffset + m_itemSize ) );
m_freeSpace += ( m_chunkSize - m_itemSize ); m_freeSpace += ( m_chunkSize - m_itemSize );
// mergeFreeChunks(); // veery slow and buggy // mergeFreeChunks(); // veery slow and buggy
} }
...@@ -152,7 +152,7 @@ void CACHED_CONTAINER::Delete( VERTEX_ITEM* aItem ) ...@@ -152,7 +152,7 @@ void CACHED_CONTAINER::Delete( VERTEX_ITEM* aItem )
// Insert a free memory chunk entry in the place where item was stored // Insert a free memory chunk entry in the place where item was stored
if( size > 0 ) if( size > 0 )
{ {
m_freeChunks.insert( Chunk( size, offset ) ); m_freeChunks.insert( CHUNK( size, offset ) );
m_freeSpace += size; m_freeSpace += size;
// Indicate that the item is not stored in the container anymore // Indicate that the item is not stored in the container anymore
aItem->setSize( 0 ); aItem->setSize( 0 );
...@@ -186,7 +186,7 @@ void CACHED_CONTAINER::Clear() ...@@ -186,7 +186,7 @@ void CACHED_CONTAINER::Clear()
// Set the size of all the stored VERTEX_ITEMs to 0, so it is clear that they are not held // Set the size of all the stored VERTEX_ITEMs to 0, so it is clear that they are not held
// in the container anymore // in the container anymore
Items::iterator it; ITEMS::iterator it;
for( it = m_items.begin(); it != m_items.end(); ++it ) for( it = m_items.begin(); it != m_items.end(); ++it )
{ {
...@@ -198,7 +198,7 @@ void CACHED_CONTAINER::Clear() ...@@ -198,7 +198,7 @@ void CACHED_CONTAINER::Clear()
// Now there is only free space left // Now there is only free space left
m_freeChunks.clear(); m_freeChunks.clear();
m_freeChunks.insert( Chunk( m_freeSpace, 0 ) ); m_freeChunks.insert( CHUNK( m_freeSpace, 0 ) );
} }
...@@ -240,7 +240,7 @@ unsigned int CACHED_CONTAINER::reallocate( unsigned int aSize ) ...@@ -240,7 +240,7 @@ unsigned int CACHED_CONTAINER::reallocate( unsigned int aSize )
} }
// Look for the free space chunk of at least given size // Look for the free space chunk of at least given size
FreeChunkMap::iterator newChunk = m_freeChunks.lower_bound( aSize ); FREE_CHUNK_MAP::iterator newChunk = m_freeChunks.lower_bound( aSize );
if( newChunk == m_freeChunks.end() ) if( newChunk == m_freeChunks.end() )
{ {
...@@ -277,7 +277,7 @@ unsigned int CACHED_CONTAINER::reallocate( unsigned int aSize ) ...@@ -277,7 +277,7 @@ unsigned int CACHED_CONTAINER::reallocate( unsigned int aSize )
// Free the space previously used by the chunk // Free the space previously used by the chunk
wxASSERT( m_itemSize > 0 ); wxASSERT( m_itemSize > 0 );
m_freeChunks.insert( Chunk( m_itemSize, m_chunkOffset ) ); m_freeChunks.insert( CHUNK( m_itemSize, m_chunkOffset ) );
m_freeSpace += m_itemSize; m_freeSpace += m_itemSize;
} }
...@@ -287,7 +287,7 @@ unsigned int CACHED_CONTAINER::reallocate( unsigned int aSize ) ...@@ -287,7 +287,7 @@ unsigned int CACHED_CONTAINER::reallocate( unsigned int aSize )
// If there is some space left, return it to the pool - add an entry for it // If there is some space left, return it to the pool - add an entry for it
if( chunkSize > aSize ) if( chunkSize > aSize )
{ {
m_freeChunks.insert( Chunk( chunkSize - aSize, chunkOffset + aSize ) ); m_freeChunks.insert( CHUNK( chunkSize - aSize, chunkOffset + aSize ) );
} }
m_freeSpace -= aSize; m_freeSpace -= aSize;
...@@ -321,7 +321,7 @@ bool CACHED_CONTAINER::defragment( VERTEX* aTarget ) ...@@ -321,7 +321,7 @@ bool CACHED_CONTAINER::defragment( VERTEX* aTarget )
} }
int newOffset = 0; int newOffset = 0;
Items::iterator it, it_end; ITEMS::iterator it, it_end;
for( it = m_items.begin(), it_end = m_items.end(); it != it_end; ++it ) for( it = m_items.begin(), it_end = m_items.end(); it != it_end; ++it )
{ {
...@@ -345,7 +345,7 @@ bool CACHED_CONTAINER::defragment( VERTEX* aTarget ) ...@@ -345,7 +345,7 @@ bool CACHED_CONTAINER::defragment( VERTEX* aTarget )
// Now there is only one big chunk of free memory // Now there is only one big chunk of free memory
m_freeChunks.clear(); m_freeChunks.clear();
wxASSERT( m_freeSpace > 0 ); wxASSERT( m_freeSpace > 0 );
m_freeChunks.insert( Chunk( m_freeSpace, m_currentSize - m_freeSpace ) ); m_freeChunks.insert( CHUNK( m_freeSpace, m_currentSize - m_freeSpace ) );
#if CACHED_CONTAINER_TEST > 0 #if CACHED_CONTAINER_TEST > 0
prof_end( &totalTime ); prof_end( &totalTime );
...@@ -369,9 +369,9 @@ void CACHED_CONTAINER::mergeFreeChunks() ...@@ -369,9 +369,9 @@ void CACHED_CONTAINER::mergeFreeChunks()
#endif #endif
// Reversed free chunks map - this one stores chunk size with its offset as the key // Reversed free chunks map - this one stores chunk size with its offset as the key
std::list<Chunk> freeChunks; std::list<CHUNK> freeChunks;
FreeChunkMap::const_iterator it, it_end; FREE_CHUNK_MAP::const_iterator it, it_end;
for( it = m_freeChunks.begin(), it_end = m_freeChunks.end(); it != it_end; ++it ) for( it = m_freeChunks.begin(), it_end = m_freeChunks.end(); it != it_end; ++it )
{ {
...@@ -381,7 +381,7 @@ void CACHED_CONTAINER::mergeFreeChunks() ...@@ -381,7 +381,7 @@ void CACHED_CONTAINER::mergeFreeChunks()
m_freeChunks.clear(); m_freeChunks.clear();
freeChunks.sort(); freeChunks.sort();
std::list<Chunk>::const_iterator itf, itf_end; std::list<CHUNK>::const_iterator itf, itf_end;
unsigned int offset = freeChunks.front().first; unsigned int offset = freeChunks.front().first;
unsigned int size = freeChunks.front().second; unsigned int size = freeChunks.front().second;
freeChunks.pop_front(); freeChunks.pop_front();
...@@ -449,7 +449,7 @@ bool CACHED_CONTAINER::resizeContainer( unsigned int aNewSize ) ...@@ -449,7 +449,7 @@ bool CACHED_CONTAINER::resizeContainer( unsigned int aNewSize )
// We have to correct freeChunks after defragmentation // We have to correct freeChunks after defragmentation
m_freeChunks.clear(); m_freeChunks.clear();
wxASSERT( aNewSize - reservedSpace() > 0 ); wxASSERT( aNewSize - reservedSpace() > 0 );
m_freeChunks.insert( Chunk( aNewSize - reservedSpace(), reservedSpace() ) ); m_freeChunks.insert( CHUNK( aNewSize - reservedSpace(), reservedSpace() ) );
} }
else else
{ {
...@@ -463,7 +463,7 @@ bool CACHED_CONTAINER::resizeContainer( unsigned int aNewSize ) ...@@ -463,7 +463,7 @@ bool CACHED_CONTAINER::resizeContainer( unsigned int aNewSize )
} }
// Add an entry for the new memory chunk at the end of the container // Add an entry for the new memory chunk at the end of the container
m_freeChunks.insert( Chunk( aNewSize - m_currentSize, m_currentSize ) ); m_freeChunks.insert( CHUNK( aNewSize - m_currentSize, m_currentSize ) );
} }
m_vertices = newContainer; m_vertices = newContainer;
......
...@@ -691,7 +691,7 @@ void OPENGL_GAL::RestoreScreen() ...@@ -691,7 +691,7 @@ void OPENGL_GAL::RestoreScreen()
} }
void OPENGL_GAL::SetTarget( RenderTarget aTarget ) void OPENGL_GAL::SetTarget( RENDER_TARGET aTarget )
{ {
switch( aTarget ) switch( aTarget )
{ {
...@@ -713,13 +713,13 @@ void OPENGL_GAL::SetTarget( RenderTarget aTarget ) ...@@ -713,13 +713,13 @@ void OPENGL_GAL::SetTarget( RenderTarget aTarget )
} }
RenderTarget OPENGL_GAL::GetTarget() const RENDER_TARGET OPENGL_GAL::GetTarget() const
{ {
return currentTarget; return currentTarget;
} }
void OPENGL_GAL::ClearTarget( RenderTarget aTarget ) void OPENGL_GAL::ClearTarget( RENDER_TARGET aTarget )
{ {
// Save the current state // Save the current state
unsigned int oldTarget = compositor.GetBuffer(); unsigned int oldTarget = compositor.GetBuffer();
......
...@@ -63,7 +63,7 @@ SHADER::~SHADER() ...@@ -63,7 +63,7 @@ SHADER::~SHADER()
} }
bool SHADER::LoadBuiltinShader( unsigned int aShaderNumber, ShaderType aShaderType ) bool SHADER::LoadBuiltinShader( unsigned int aShaderNumber, SHADER_TYPE aShaderType )
{ {
if( aShaderNumber >= shaders_number ) if( aShaderNumber >= shaders_number )
return false; return false;
...@@ -72,7 +72,7 @@ bool SHADER::LoadBuiltinShader( unsigned int aShaderNumber, ShaderType aShaderTy ...@@ -72,7 +72,7 @@ bool SHADER::LoadBuiltinShader( unsigned int aShaderNumber, ShaderType aShaderTy
} }
bool SHADER::LoadShaderFromFile( const std::string& aShaderSourceName, ShaderType aShaderType ) bool SHADER::LoadShaderFromFile( const std::string& aShaderSourceName, SHADER_TYPE aShaderType )
{ {
// Load shader sources // Load shader sources
const std::string shaderSource = readSource( aShaderSourceName ); const std::string shaderSource = readSource( aShaderSourceName );
...@@ -219,7 +219,7 @@ std::string SHADER::readSource( std::string aShaderSourceName ) ...@@ -219,7 +219,7 @@ std::string SHADER::readSource( std::string aShaderSourceName )
} }
bool SHADER::addSource( const std::string& aShaderSource, ShaderType aShaderType ) bool SHADER::addSource( const std::string& aShaderSource, SHADER_TYPE aShaderType )
{ {
if( isShaderLinked ) if( isShaderLinked )
{ {
......
...@@ -59,7 +59,7 @@ bool STROKE_FONT::LoadNewStrokeFont( const char* const aNewStrokeFont[], int aNe ...@@ -59,7 +59,7 @@ bool STROKE_FONT::LoadNewStrokeFont( const char* const aNewStrokeFont[], int aNe
for( int j = 0; j < aNewStrokeFontSize; j++ ) for( int j = 0; j < aNewStrokeFontSize; j++ )
{ {
Glyph glyph; GLYPH glyph;
double glyphStartX = 0.0; double glyphStartX = 0.0;
double glyphEndX = 0.0; double glyphEndX = 0.0;
VECTOR2D glyphBoundingX; VECTOR2D glyphBoundingX;
...@@ -118,21 +118,21 @@ bool STROKE_FONT::LoadNewStrokeFont( const char* const aNewStrokeFont[], int aNe ...@@ -118,21 +118,21 @@ bool STROKE_FONT::LoadNewStrokeFont( const char* const aNewStrokeFont[], int aNe
} }
BOX2D STROKE_FONT::computeBoundingBox( const Glyph& aGlyph, const VECTOR2D& aGlyphBoundingX ) const BOX2D STROKE_FONT::computeBoundingBox( const GLYPH& aGLYPH, const VECTOR2D& aGLYPHBoundingX ) const
{ {
BOX2D boundingBox; BOX2D boundingBox;
std::deque<VECTOR2D> boundingPoints; std::deque<VECTOR2D> boundingPoints;
boundingPoints.push_back( VECTOR2D( aGlyphBoundingX.x, 0 ) ); boundingPoints.push_back( VECTOR2D( aGLYPHBoundingX.x, 0 ) );
boundingPoints.push_back( VECTOR2D( aGlyphBoundingX.y, 0 ) ); boundingPoints.push_back( VECTOR2D( aGLYPHBoundingX.y, 0 ) );
for( Glyph::const_iterator pointListIt = aGlyph.begin(); pointListIt != aGlyph.end(); ++pointListIt ) for( GLYPH::const_iterator pointListIt = aGLYPH.begin(); pointListIt != aGLYPH.end(); ++pointListIt )
{ {
for( std::deque<VECTOR2D>::const_iterator pointIt = pointListIt->begin(); for( std::deque<VECTOR2D>::const_iterator pointIt = pointListIt->begin();
pointIt != pointListIt->end(); ++pointIt ) pointIt != pointListIt->end(); ++pointIt )
{ {
boundingPoints.push_back( VECTOR2D( aGlyphBoundingX.x, pointIt->y ) ); boundingPoints.push_back( VECTOR2D( aGLYPHBoundingX.x, pointIt->y ) );
} }
} }
...@@ -241,15 +241,15 @@ void STROKE_FONT::Draw( std::string aText, const VECTOR2D& aPosition, double aRo ...@@ -241,15 +241,15 @@ void STROKE_FONT::Draw( std::string aText, const VECTOR2D& aPosition, double aRo
continue; continue;
} }
GlyphList::iterator glyphIt = m_glyphs.begin(); GLYPH_LIST::iterator glyphIt = m_glyphs.begin();
std::deque<BOX2D>::iterator bbIt = m_glyphBoundingBoxes.begin(); std::deque<BOX2D>::iterator bbIt = m_glyphBoundingBoxes.begin();
advance( glyphIt, (int) ( *chIt ) - (int) ' ' ); advance( glyphIt, (int) ( *chIt ) - (int) ' ' );
advance( bbIt, (int) ( *chIt ) - (int) ' ' ); advance( bbIt, (int) ( *chIt ) - (int) ' ' );
Glyph glyph = *glyphIt; GLYPH glyph = *glyphIt;
for( Glyph::iterator pointListIt = glyph.begin(); pointListIt != glyph.end(); for( GLYPH::iterator pointListIt = glyph.begin(); pointListIt != glyph.end();
pointListIt++ ) pointListIt++ )
{ {
std::deque<VECTOR2D> pointListScaled; std::deque<VECTOR2D> pointListScaled;
......
...@@ -22,28 +22,27 @@ ...@@ -22,28 +22,27 @@
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
*/ */
#include <geometry/seg.h> #include <geometry/seg.h>
template<typename T> template <typename T>
int sgn( T val ) int sgn( T aVal )
{ {
return ( T( 0 ) < val ) - ( val < T( 0 ) ); return ( T( 0 ) < aVal ) - ( aVal < T( 0 ) );
} }
bool SEG::PointCloserThan( const VECTOR2I& aP, int dist ) const bool SEG::PointCloserThan( const VECTOR2I& aP, int aDist ) const
{ {
VECTOR2I d = b - a; VECTOR2I d = B - A;
ecoord dist_sq = (ecoord) dist * dist; ecoord dist_sq = (ecoord) aDist * aDist;
SEG::ecoord l_squared = d.Dot( d ); SEG::ecoord l_squared = d.Dot( d );
SEG::ecoord t = d.Dot( aP - a ); SEG::ecoord t = d.Dot( aP - A );
if( t <= 0 || !l_squared ) if( t <= 0 || !l_squared )
return ( aP - a ).SquaredEuclideanNorm() < dist_sq; return ( aP - A ).SquaredEuclideanNorm() < dist_sq;
else if( t >= l_squared ) else if( t >= l_squared )
return ( aP - b ).SquaredEuclideanNorm() < dist_sq; return ( aP - B ).SquaredEuclideanNorm() < dist_sq;
int dxdy = abs( d.x ) - abs( d.y ); int dxdy = abs( d.x ) - abs( d.y );
...@@ -51,7 +50,7 @@ bool SEG::PointCloserThan( const VECTOR2I& aP, int dist ) const ...@@ -51,7 +50,7 @@ bool SEG::PointCloserThan( const VECTOR2I& aP, int dist ) const
{ {
int ca = -sgn( d.y ); int ca = -sgn( d.y );
int cb = sgn( d.x ); int cb = sgn( d.x );
int cc = -ca * a.x - cb * a.y; int cc = -ca * A.x - cb * A.y;
ecoord num = ca * aP.x + cb * aP.y + cc; ecoord num = ca * aP.x + cb * aP.y + cc;
num *= num; num *= num;
...@@ -66,8 +65,8 @@ bool SEG::PointCloserThan( const VECTOR2I& aP, int dist ) const ...@@ -66,8 +65,8 @@ bool SEG::PointCloserThan( const VECTOR2I& aP, int dist ) const
} }
VECTOR2I nearest; VECTOR2I nearest;
nearest.x = a.x + rescale( t, (ecoord) d.x, l_squared ); nearest.x = A.x + rescale( t, (ecoord) d.x, l_squared );
nearest.y = a.y + rescale( t, (ecoord) d.y, l_squared ); nearest.y = A.y + rescale( t, (ecoord) d.y, l_squared );
return ( nearest - aP ).SquaredEuclideanNorm() <= dist_sq; return ( nearest - aP ).SquaredEuclideanNorm() <= dist_sq;
} }
...@@ -81,10 +80,10 @@ SEG::ecoord SEG::SquaredDistance( const SEG& aSeg ) const ...@@ -81,10 +80,10 @@ SEG::ecoord SEG::SquaredDistance( const SEG& aSeg ) const
const VECTOR2I pts[4] = const VECTOR2I pts[4] =
{ {
aSeg.NearestPoint( a ) - a, aSeg.NearestPoint( A ) - A,
aSeg.NearestPoint( b ) - b, aSeg.NearestPoint( B ) - B,
NearestPoint( aSeg.a ) - aSeg.a, NearestPoint( aSeg.A ) - aSeg.A,
NearestPoint( aSeg.b ) - aSeg.b NearestPoint( aSeg.B ) - aSeg.B
}; };
ecoord m = VECTOR2I::ECOORD_MAX; ecoord m = VECTOR2I::ECOORD_MAX;
...@@ -98,9 +97,9 @@ SEG::ecoord SEG::SquaredDistance( const SEG& aSeg ) const ...@@ -98,9 +97,9 @@ SEG::ecoord SEG::SquaredDistance( const SEG& aSeg ) const
OPT_VECTOR2I SEG::Intersect( const SEG& aSeg, bool aIgnoreEndpoints, bool aLines ) const OPT_VECTOR2I SEG::Intersect( const SEG& aSeg, bool aIgnoreEndpoints, bool aLines ) const
{ {
const VECTOR2I e( b - a ); const VECTOR2I e( B - A );
const VECTOR2I f( aSeg.b - aSeg.a ); const VECTOR2I f( aSeg.B - aSeg.A );
const VECTOR2I ac( aSeg.a - a ); const VECTOR2I ac( aSeg.A - A );
ecoord d = f.Cross( e ); ecoord d = f.Cross( e );
ecoord p = f.Cross( ac ); ecoord p = f.Cross( ac );
...@@ -118,16 +117,16 @@ OPT_VECTOR2I SEG::Intersect( const SEG& aSeg, bool aIgnoreEndpoints, bool aLines ...@@ -118,16 +117,16 @@ OPT_VECTOR2I SEG::Intersect( const SEG& aSeg, bool aIgnoreEndpoints, bool aLines
if( !aLines && aIgnoreEndpoints && ( q == 0 || q == d ) && ( p == 0 || p == d ) ) if( !aLines && aIgnoreEndpoints && ( q == 0 || q == d ) && ( p == 0 || p == d ) )
return OPT_VECTOR2I(); return OPT_VECTOR2I();
VECTOR2I ip( aSeg.a.x + rescale( q, (ecoord) f.x, d ), VECTOR2I ip( aSeg.A.x + rescale( q, (ecoord) f.x, d ),
aSeg.a.y + rescale( q, (ecoord) f.y, d ) ); aSeg.A.y + rescale( q, (ecoord) f.y, d ) );
return ip; return ip;
} }
bool SEG::ccw( const VECTOR2I& a, const VECTOR2I& b, const VECTOR2I& c ) const bool SEG::ccw( const VECTOR2I& aA, const VECTOR2I& aB, const VECTOR2I& aC ) const
{ {
return (ecoord) ( c.y - a.y ) * ( b.x - a.x ) > (ecoord) ( b.y - a.y ) * ( c.x - a.x ); return (ecoord) ( aC.y - aA.y ) * ( aB.x - aA.x ) > (ecoord) ( aB.y - aA.y ) * ( aC.x - aA.x );
} }
...@@ -135,17 +134,17 @@ bool SEG::Collide( const SEG& aSeg, int aClearance ) const ...@@ -135,17 +134,17 @@ bool SEG::Collide( const SEG& aSeg, int aClearance ) const
{ {
// check for intersection // check for intersection
// fixme: move to a method // fixme: move to a method
if( ccw( a, aSeg.a, aSeg.b ) != ccw( b, aSeg.a, aSeg.b ) && if( ccw( A, aSeg.A, aSeg.B ) != ccw( B, aSeg.A, aSeg.B ) &&
ccw( a, b, aSeg.a ) != ccw( a, b, aSeg.b ) ) ccw( A, B, aSeg.A ) != ccw( A, B, aSeg.B ) )
return true; return true;
#define CHK( _seg, _pt ) \ #define CHK( _seg, _pt ) \
if( (_seg).PointCloserThan( _pt, aClearance ) ) return true; if( (_seg).PointCloserThan( _pt, aClearance ) ) return true;
CHK( *this, aSeg.a ); CHK( *this, aSeg.A );
CHK( *this, aSeg.b ); CHK( *this, aSeg.B );
CHK( aSeg, a ); CHK( aSeg, A );
CHK( aSeg, b ); CHK( aSeg, B );
#undef CHK #undef CHK
return false; return false;
......
...@@ -50,6 +50,7 @@ static inline bool Collide( const SHAPE_CIRCLE& aA, const SHAPE_CIRCLE& aB, int ...@@ -50,6 +50,7 @@ static inline bool Collide( const SHAPE_CIRCLE& aA, const SHAPE_CIRCLE& aB, int
return true; return true;
} }
static inline bool Collide( const SHAPE_RECT& aA, const SHAPE_CIRCLE& aB, int aClearance, static inline bool Collide( const SHAPE_RECT& aA, const SHAPE_CIRCLE& aB, int aClearance,
bool aNeedMTV, VECTOR2I& aMTV ) bool aNeedMTV, VECTOR2I& aMTV )
{ {
...@@ -154,7 +155,8 @@ static inline bool Collide( const SHAPE_RECT& aA, const SHAPE_LINE_CHAIN& aB, in ...@@ -154,7 +155,8 @@ static inline bool Collide( const SHAPE_RECT& aA, const SHAPE_LINE_CHAIN& aB, in
} }
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 )
{ {
switch( aA->Type() ) switch( aA->Type() )
{ {
...@@ -163,53 +165,56 @@ bool CollideShapes( const SHAPE* aA, const SHAPE* aB, int aClearance, bool aNeed ...@@ -163,53 +165,56 @@ bool CollideShapes( const SHAPE* aA, const SHAPE* aB, int aClearance, bool aNeed
{ {
case SH_CIRCLE: case SH_CIRCLE:
return Collide( *static_cast<const SHAPE_RECT*>( aA ), return Collide( *static_cast<const SHAPE_RECT*>( aA ),
*static_cast<const SHAPE_CIRCLE*>( aB ), aClearance, aNeedMTV, aMTV ); *static_cast<const SHAPE_CIRCLE*>( aB ), aClearance, aNeedMTV, aMTV );
case SH_LINE_CHAIN: case SH_LINE_CHAIN:
return Collide( *static_cast<const SHAPE_RECT*>( aA ), return Collide( *static_cast<const SHAPE_RECT*>( aA ),
*static_cast<const SHAPE_LINE_CHAIN*>( aB ), aClearance, aNeedMTV, aMTV ); *static_cast<const SHAPE_LINE_CHAIN*>( aB ), aClearance, aNeedMTV, aMTV );
default: default:
break; break;
} }
break;
case SH_CIRCLE: case SH_CIRCLE:
switch( aB->Type() ) switch( aB->Type() )
{ {
case SH_RECT: case SH_RECT:
return Collide( *static_cast<const SHAPE_RECT*>( aB ), return Collide( *static_cast<const SHAPE_RECT*>( aB ),
*static_cast<const SHAPE_CIRCLE*>( aA ), aClearance, aNeedMTV, aMTV ); *static_cast<const SHAPE_CIRCLE*>( aA ), aClearance, aNeedMTV, aMTV );
case SH_CIRCLE: case SH_CIRCLE:
return Collide( *static_cast<const SHAPE_CIRCLE*>( aA ), return Collide( *static_cast<const SHAPE_CIRCLE*>( aA ),
*static_cast<const SHAPE_CIRCLE*>( aB ), aClearance, aNeedMTV, aMTV ); *static_cast<const SHAPE_CIRCLE*>( aB ), aClearance, aNeedMTV, aMTV );
case SH_LINE_CHAIN: case SH_LINE_CHAIN:
return Collide( *static_cast<const SHAPE_CIRCLE*>( aA ), return Collide( *static_cast<const SHAPE_CIRCLE*>( aA ),
*static_cast<const SHAPE_LINE_CHAIN *>( aB ), aClearance, aNeedMTV, aMTV ); *static_cast<const SHAPE_LINE_CHAIN *>( aB ), aClearance, aNeedMTV, aMTV );
default: default:
break; break;
} }
break;
case SH_LINE_CHAIN: case SH_LINE_CHAIN:
switch( aB->Type() ) switch( aB->Type() )
{ {
case SH_RECT: case SH_RECT:
return Collide( *static_cast<const SHAPE_RECT*>( aB ), return Collide( *static_cast<const SHAPE_RECT*>( aB ),
*static_cast<const SHAPE_LINE_CHAIN*>( aA ), aClearance, aNeedMTV, aMTV ); *static_cast<const SHAPE_LINE_CHAIN*>( aA ), aClearance, aNeedMTV, aMTV );
case SH_CIRCLE: case SH_CIRCLE:
return Collide( *static_cast<const SHAPE_CIRCLE*>( aB ), return Collide( *static_cast<const SHAPE_CIRCLE*>( aB ),
*static_cast<const SHAPE_LINE_CHAIN*>( aA ), aClearance, aNeedMTV, aMTV ); *static_cast<const SHAPE_LINE_CHAIN*>( aA ), aClearance, aNeedMTV, aMTV );
case SH_LINE_CHAIN: case SH_LINE_CHAIN:
return Collide( *static_cast<const SHAPE_LINE_CHAIN*>( aA ), return Collide( *static_cast<const SHAPE_LINE_CHAIN*>( aA ),
*static_cast<const SHAPE_LINE_CHAIN*>( aB ), aClearance, aNeedMTV, aMTV ); *static_cast<const SHAPE_LINE_CHAIN*>( aB ), aClearance, aNeedMTV, aMTV );
default: default:
break; break;
} }
break;
default: default:
break; break;
......
...@@ -25,7 +25,7 @@ ...@@ -25,7 +25,7 @@
#include <geometry/shape_index.h> #include <geometry/shape_index.h>
template<> template <>
const SHAPE* shapeFunctor( SHAPE* aItem ) const SHAPE* shapeFunctor( SHAPE* aItem )
{ {
return aItem; return aItem;
......
...@@ -31,6 +31,7 @@ using boost::optional; ...@@ -31,6 +31,7 @@ using boost::optional;
bool SHAPE_LINE_CHAIN::Collide( const VECTOR2I& aP, int aClearance ) const bool SHAPE_LINE_CHAIN::Collide( const VECTOR2I& aP, int aClearance ) const
{ {
assert( false ); assert( false );
return false; return false;
} }
...@@ -38,19 +39,20 @@ bool SHAPE_LINE_CHAIN::Collide( const VECTOR2I& aP, int aClearance ) const ...@@ -38,19 +39,20 @@ bool SHAPE_LINE_CHAIN::Collide( const VECTOR2I& aP, int aClearance ) const
bool SHAPE_LINE_CHAIN::Collide( const BOX2I& aBox, int aClearance ) const bool SHAPE_LINE_CHAIN::Collide( const BOX2I& aBox, int aClearance ) const
{ {
assert( false ); assert( false );
return false; return false;
} }
bool SHAPE_LINE_CHAIN::Collide( const SEG& aSeg, int aClearance ) const bool SHAPE_LINE_CHAIN::Collide( const SEG& aSeg, int aClearance ) const
{ {
BOX2I box_a( aSeg.a, aSeg.b - aSeg.a ); BOX2I box_a( aSeg.A, aSeg.B - aSeg.A );
BOX2I::ecoord_type dist_sq = (BOX2I::ecoord_type) aClearance * aClearance; BOX2I::ecoord_type dist_sq = (BOX2I::ecoord_type) aClearance * aClearance;
for( int i = 0; i < SegmentCount(); i++ ) for( int i = 0; i < SegmentCount(); i++ )
{ {
const SEG& s = CSegment( i ); const SEG& s = CSegment( i );
BOX2I box_b( s.a, s.b - s.a ); BOX2I box_b( s.A, s.B - s.A );
BOX2I::ecoord_type d = box_a.SquaredDistance( box_b ); BOX2I::ecoord_type d = box_a.SquaredDistance( box_b );
...@@ -158,7 +160,7 @@ int SHAPE_LINE_CHAIN::Split( const VECTOR2I& aP ) ...@@ -158,7 +160,7 @@ int SHAPE_LINE_CHAIN::Split( const VECTOR2I& aP )
// make sure we are not producing a 'slightly concave' primitive. This might happen // make sure we are not producing a 'slightly concave' primitive. This might happen
// if aP lies very close to one of already existing points. // if aP lies very close to one of already existing points.
if( dist < min_dist && seg.a != aP && seg.b != aP ) if( dist < min_dist && seg.A != aP && seg.B != aP )
{ {
min_dist = dist; min_dist = dist;
ii = s; ii = s;
...@@ -208,8 +210,8 @@ struct compareOriginDistance ...@@ -208,8 +210,8 @@ struct compareOriginDistance
compareOriginDistance( VECTOR2I& aOrigin ) : compareOriginDistance( VECTOR2I& aOrigin ) :
m_origin( aOrigin ) {}; m_origin( aOrigin ) {};
bool operator()( const SHAPE_LINE_CHAIN::Intersection& aA, bool operator()( const SHAPE_LINE_CHAIN::INTERSECTION& aA,
const SHAPE_LINE_CHAIN::Intersection& aB ) const SHAPE_LINE_CHAIN::INTERSECTION& aB )
{ {
return ( m_origin - aA.p ).EuclideanNorm() < ( m_origin - aB.p ).EuclideanNorm(); return ( m_origin - aA.p ).EuclideanNorm() < ( m_origin - aB.p ).EuclideanNorm();
} }
...@@ -218,7 +220,7 @@ struct compareOriginDistance ...@@ -218,7 +220,7 @@ struct compareOriginDistance
}; };
int SHAPE_LINE_CHAIN::Intersect( const SEG& aSeg, Intersections& aIp ) const int SHAPE_LINE_CHAIN::Intersect( const SEG& aSeg, INTERSECTIONS& aIp ) const
{ {
for( int s = 0; s < SegmentCount(); s++ ) for( int s = 0; s < SegmentCount(); s++ )
{ {
...@@ -226,7 +228,7 @@ int SHAPE_LINE_CHAIN::Intersect( const SEG& aSeg, Intersections& aIp ) const ...@@ -226,7 +228,7 @@ int SHAPE_LINE_CHAIN::Intersect( const SEG& aSeg, Intersections& aIp ) const
if( p ) if( p )
{ {
Intersection is; INTERSECTION is;
is.our = CSegment( s ); is.our = CSegment( s );
is.their = aSeg; is.their = aSeg;
is.p = *p; is.p = *p;
...@@ -234,21 +236,21 @@ int SHAPE_LINE_CHAIN::Intersect( const SEG& aSeg, Intersections& aIp ) const ...@@ -234,21 +236,21 @@ int SHAPE_LINE_CHAIN::Intersect( const SEG& aSeg, Intersections& aIp ) const
} }
} }
compareOriginDistance comp( aSeg.a ); compareOriginDistance comp( aSeg.A );
sort( aIp.begin(), aIp.end(), comp ); sort( aIp.begin(), aIp.end(), comp );
return aIp.size(); return aIp.size();
} }
int SHAPE_LINE_CHAIN::Intersect( const SHAPE_LINE_CHAIN& aChain, Intersections& aIp ) const int SHAPE_LINE_CHAIN::Intersect( const SHAPE_LINE_CHAIN& aChain, INTERSECTIONS& aIp ) const
{ {
BOX2I bb_other = aChain.BBox(); BOX2I bb_other = aChain.BBox();
for( int s1 = 0; s1 < SegmentCount(); s1++ ) for( int s1 = 0; s1 < SegmentCount(); s1++ )
{ {
const SEG& a = CSegment( s1 ); const SEG& a = CSegment( s1 );
const BOX2I bb_cur( a.a, a.b - a.a ); const BOX2I bb_cur( a.A, a.B - a.A );
if( !bb_other.Intersects( bb_cur ) ) if( !bb_other.Intersects( bb_cur ) )
continue; continue;
...@@ -256,14 +258,14 @@ int SHAPE_LINE_CHAIN::Intersect( const SHAPE_LINE_CHAIN& aChain, Intersections& ...@@ -256,14 +258,14 @@ int SHAPE_LINE_CHAIN::Intersect( const SHAPE_LINE_CHAIN& aChain, Intersections&
for( int s2 = 0; s2 < aChain.SegmentCount(); s2++ ) for( int s2 = 0; s2 < aChain.SegmentCount(); s2++ )
{ {
const SEG& b = aChain.CSegment( s2 ); const SEG& b = aChain.CSegment( s2 );
Intersection is; INTERSECTION is;
if( a.Collinear( b ) ) if( a.Collinear( b ) )
{ {
if( a.Contains( b.a ) ) { is.p = b.a; aIp.push_back( is ); } if( a.Contains( b.A ) ) { is.p = b.A; aIp.push_back( is ); }
if( a.Contains( b.b ) ) { is.p = b.b; aIp.push_back( is ); } if( a.Contains( b.B ) ) { is.p = b.B; aIp.push_back( is ); }
if( b.Contains( a.a ) ) { is.p = a.a; aIp.push_back( is ); } if( b.Contains( a.A ) ) { is.p = a.A; aIp.push_back( is ); }
if( b.Contains( a.b ) ) { is.p = a.b; aIp.push_back( is ); } if( b.Contains( a.B ) ) { is.p = a.B; aIp.push_back( is ); }
} }
else else
{ {
...@@ -289,7 +291,7 @@ int SHAPE_LINE_CHAIN::Intersect( const SHAPE_LINE_CHAIN& aChain, Intersections& ...@@ -289,7 +291,7 @@ int SHAPE_LINE_CHAIN::Intersect( const SHAPE_LINE_CHAIN& aChain, Intersections&
const SEG& a = CSegment( s1 ); const SEG& a = CSegment( s1 );
const SEG& b = aChain.CSegment( s2 ); const SEG& b = aChain.CSegment( s2 );
OPT_VECTOR2I p = a.Intersect( b ); OPT_VECTOR2I p = a.Intersect( b );
Intersection is; INTERSECTION is;
if( p ) if( p )
{ {
...@@ -300,16 +302,16 @@ int SHAPE_LINE_CHAIN::Intersect( const SHAPE_LINE_CHAIN& aChain, Intersections& ...@@ -300,16 +302,16 @@ int SHAPE_LINE_CHAIN::Intersect( const SHAPE_LINE_CHAIN& aChain, Intersections&
} }
else if( a.Collinear( b ) ) else if( a.Collinear( b ) )
{ {
if( a.a != b.a && a.a != b.b && b.Contains( a.a ) ) if( a.A != b.A && a.A != b.B && b.Contains( a.A ) )
{ {
is.p = a.a; is.p = a.A;
is.our = a; is.our = a;
is.their = b; is.their = b;
aIp.push_back( is ); aIp.push_back( is );
} }
else if( a.b != b.a && a.b != b.b && b.Contains( a.b ) ) else if( a.B != b.A && a.B != b.B && b.Contains( a.B ) )
{ {
is.p = a.b; is.p = a.B;
is.our = a; is.our = a;
is.their = b; is.their = b;
aIp.push_back( is ); aIp.push_back( is );
...@@ -333,7 +335,7 @@ int SHAPE_LINE_CHAIN::PathLength( const VECTOR2I& aP ) const ...@@ -333,7 +335,7 @@ int SHAPE_LINE_CHAIN::PathLength( const VECTOR2I& aP ) const
if( d <= 1 ) if( d <= 1 )
{ {
sum += ( aP - seg.a ).EuclideanNorm(); sum += ( aP - seg.A ).EuclideanNorm();
return sum; return sum;
} }
else else
...@@ -358,7 +360,7 @@ bool SHAPE_LINE_CHAIN::PointInside( const VECTOR2I& aP ) const ...@@ -358,7 +360,7 @@ bool SHAPE_LINE_CHAIN::PointInside( const VECTOR2I& aP ) const
{ {
const SEG s = CSegment( i ); const SEG s = CSegment( i );
if( aP == s.a || aP == s.b ) // edge does not belong to the interior! if( aP == s.A || aP == s.B ) // edge does not belong to the interior!
return false; return false;
if( s.Side( aP ) != cur ) if( s.Side( aP ) != cur )
...@@ -378,7 +380,7 @@ bool SHAPE_LINE_CHAIN::PointOnEdge( const VECTOR2I& aP ) const ...@@ -378,7 +380,7 @@ bool SHAPE_LINE_CHAIN::PointOnEdge( const VECTOR2I& aP ) const
{ {
const SEG s = CSegment( i ); const SEG s = CSegment( i );
if( s.a == aP || s.b == aP ) if( s.A == aP || s.B == aP )
return true; return true;
if( s.Distance( aP ) <= 1 ) if( s.Distance( aP ) <= 1 )
...@@ -389,17 +391,17 @@ bool SHAPE_LINE_CHAIN::PointOnEdge( const VECTOR2I& aP ) const ...@@ -389,17 +391,17 @@ bool SHAPE_LINE_CHAIN::PointOnEdge( const VECTOR2I& aP ) const
} }
const optional<SHAPE_LINE_CHAIN::Intersection> SHAPE_LINE_CHAIN::SelfIntersecting() const const optional<SHAPE_LINE_CHAIN::INTERSECTION> SHAPE_LINE_CHAIN::SelfIntersecting() const
{ {
for( int s1 = 0; s1 < SegmentCount(); s1++ ) for( int s1 = 0; s1 < SegmentCount(); s1++ )
{ {
for( int s2 = s1 + 1; s2 < SegmentCount(); s2++ ) for( int s2 = s1 + 1; s2 < SegmentCount(); s2++ )
{ {
const VECTOR2I s2a = CSegment( s2 ).a, s2b = CSegment( s2 ).b; const VECTOR2I s2a = CSegment( s2 ).A, s2b = CSegment( s2 ).B;
if( s1 + 1 != s2 && CSegment( s1 ).Contains( s2a ) ) if( s1 + 1 != s2 && CSegment( s1 ).Contains( s2a ) )
{ {
Intersection is; INTERSECTION is;
is.our = CSegment( s1 ); is.our = CSegment( s1 );
is.their = CSegment( s2 ); is.their = CSegment( s2 );
is.p = s2a; is.p = s2a;
...@@ -407,7 +409,7 @@ const optional<SHAPE_LINE_CHAIN::Intersection> SHAPE_LINE_CHAIN::SelfIntersectin ...@@ -407,7 +409,7 @@ const optional<SHAPE_LINE_CHAIN::Intersection> SHAPE_LINE_CHAIN::SelfIntersectin
} }
else if( CSegment( s1 ).Contains( s2b ) ) else if( CSegment( s1 ).Contains( s2b ) )
{ {
Intersection is; INTERSECTION is;
is.our = CSegment( s1 ); is.our = CSegment( s1 );
is.their = CSegment( s2 ); is.their = CSegment( s2 );
is.p = s2b; is.p = s2b;
...@@ -419,7 +421,7 @@ const optional<SHAPE_LINE_CHAIN::Intersection> SHAPE_LINE_CHAIN::SelfIntersectin ...@@ -419,7 +421,7 @@ const optional<SHAPE_LINE_CHAIN::Intersection> SHAPE_LINE_CHAIN::SelfIntersectin
if( p ) if( p )
{ {
Intersection is; INTERSECTION is;
is.our = CSegment( s1 ); is.our = CSegment( s1 );
is.their = CSegment( s2 ); is.their = CSegment( s2 );
is.p = *p; is.p = *p;
...@@ -429,7 +431,7 @@ const optional<SHAPE_LINE_CHAIN::Intersection> SHAPE_LINE_CHAIN::SelfIntersectin ...@@ -429,7 +431,7 @@ const optional<SHAPE_LINE_CHAIN::Intersection> SHAPE_LINE_CHAIN::SelfIntersectin
} }
} }
return optional<Intersection>(); return optional<INTERSECTION>();
} }
......
...@@ -28,31 +28,32 @@ ...@@ -28,31 +28,32 @@
#include <climits> #include <climits>
#include <math/math_util.h> #include <math/math_util.h>
template<> template <>
int rescale( int numerator, int value, int denominator ) int rescale( int aNumerator, int aValue, int aDenominator )
{ {
return (int) ( (int64_t) numerator * (int64_t) value / (int64_t) denominator ); return (int) ( (int64_t) aNumerator * (int64_t) aValue / (int64_t) aDenominator );
} }
template<> template <>
int64_t rescale( int64_t numerator, int64_t value, int64_t denominator ) int64_t rescale( int64_t aNumerator, int64_t aValue, int64_t aDenominator )
{ {
int64_t r = 0; int64_t r = 0;
int64_t sign = ( ( numerator < 0) ? -1 : 1 ) * ( denominator < 0 ? -1 : 1 ) * ( value < 0 ? -1 : 1 ); int64_t sign = ( ( aNumerator < 0 ) ? -1 : 1 ) * ( aDenominator < 0 ? -1 : 1 ) *
( aValue < 0 ? -1 : 1 );
int64_t a = std::abs( numerator ); int64_t a = std::abs( aNumerator );
int64_t b = std::abs( value ); int64_t b = std::abs( aValue );
int64_t c = std::abs( denominator ); int64_t c = std::abs( aDenominator );
r = c / 2; r = c / 2;
if( b <= INT_MAX && c <= INT_MAX ) if( b <= INT_MAX && c <= INT_MAX )
{ {
if( a <= INT_MAX ) if( a <= INT_MAX )
return sign * ( (a * b + r ) / c ); return sign * ( ( a * b + r ) / c );
else else
return sign * (a / c * b + (a % c * b + r) / c); return sign * ( a / c * b + ( a % c * b + r ) / c);
} }
else else
{ {
......
...@@ -104,8 +104,8 @@ void CONTEXT_MENU::Add( const TOOL_ACTION& aAction ) ...@@ -104,8 +104,8 @@ void CONTEXT_MENU::Add( const TOOL_ACTION& aAction )
wxString menuEntry; wxString menuEntry;
if( aAction.HasHotKey() ) if( aAction.HasHotKey() )
menuEntry = wxString( ( aAction.GetMenuItem() + '\t' + getHotKeyDescription( aAction ) ).c_str(), menuEntry = wxString( ( aAction.GetMenuItem() + '\t' +
wxConvUTF8 ); getHotKeyDescription( aAction ) ).c_str(), wxConvUTF8 );
else else
menuEntry = wxString( aAction.GetMenuItem().c_str(), wxConvUTF8 ); menuEntry = wxString( aAction.GetMenuItem().c_str(), wxConvUTF8 );
...@@ -134,17 +134,17 @@ std::string CONTEXT_MENU::getHotKeyDescription( const TOOL_ACTION& aAction ) con ...@@ -134,17 +134,17 @@ std::string CONTEXT_MENU::getHotKeyDescription( const TOOL_ACTION& aAction ) con
std::string description = ""; std::string description = "";
if( hotkey & MD_ModAlt ) if( hotkey & MD_ALT )
description += "ALT+"; description += "ALT+";
if( hotkey & MD_ModCtrl ) if( hotkey & MD_CTRL )
description += "CTRL+"; description += "CTRL+";
if( hotkey & MD_ModShift ) if( hotkey & MD_SHIFT )
description += "SHIFT+"; description += "SHIFT+";
// TODO dispatch keys such as Fx, TAB, PG_UP/DN, HOME, END, etc. // TODO dispatch keys such as Fx, TAB, PG_UP/DN, HOME, END, etc.
description += char(hotkey & ~MD_ModifierMask); description += char( hotkey & ~MD_MODIFIER_MASK );
return description; return description;
} }
...@@ -159,7 +159,7 @@ void CONTEXT_MENU::CMEventHandler::onEvent( wxEvent& aEvent ) ...@@ -159,7 +159,7 @@ void CONTEXT_MENU::CMEventHandler::onEvent( wxEvent& aEvent )
// For example, the selection tool can use this to dynamically highlight the current item // For example, the selection tool can use this to dynamically highlight the current item
// from selection clarification popup. // from selection clarification popup.
if( type == wxEVT_MENU_HIGHLIGHT ) if( type == wxEVT_MENU_HIGHLIGHT )
evt = TOOL_EVENT( TC_Command, TA_ContextMenuUpdate, aEvent.GetId() ); evt = TOOL_EVENT( TC_COMMAND, TA_CONTEXT_MENU_UPDATE, aEvent.GetId() );
// One of menu entries was selected.. // One of menu entries was selected..
else if( type == wxEVT_COMMAND_MENU_SELECTED ) else if( type == wxEVT_COMMAND_MENU_SELECTED )
...@@ -172,7 +172,7 @@ void CONTEXT_MENU::CMEventHandler::onEvent( wxEvent& aEvent ) ...@@ -172,7 +172,7 @@ void CONTEXT_MENU::CMEventHandler::onEvent( wxEvent& aEvent )
else else
{ {
// Handling non-action menu entries (e.g. items in clarification list) // Handling non-action menu entries (e.g. items in clarification list)
evt = TOOL_EVENT( TC_Command, TA_ContextMenuChoice, aEvent.GetId() ); evt = TOOL_EVENT( TC_COMMAND, TA_CONTEXT_MENU_CHOICE, aEvent.GetId() );
} }
} }
......
...@@ -40,9 +40,9 @@ ...@@ -40,9 +40,9 @@
using boost::optional; using boost::optional;
///> Stores information about a mouse button state ///> Stores information about a mouse button state
struct TOOL_DISPATCHER::ButtonState struct TOOL_DISPATCHER::BUTTON_STATE
{ {
ButtonState( TOOL_MouseButtons aButton, const wxEventType& aDownEvent, BUTTON_STATE( TOOL_MOUSE_BUTTONS aButton, const wxEventType& aDownEvent,
const wxEventType& aUpEvent ) : const wxEventType& aUpEvent ) :
button( aButton ), button( aButton ),
downEvent( aDownEvent ), downEvent( aDownEvent ),
...@@ -66,7 +66,7 @@ struct TOOL_DISPATCHER::ButtonState ...@@ -66,7 +66,7 @@ struct TOOL_DISPATCHER::ButtonState
double dragMaxDelta; double dragMaxDelta;
///> Determines the mouse button for which information are stored. ///> Determines the mouse button for which information are stored.
TOOL_MouseButtons button; TOOL_MOUSE_BUTTONS button;
///> The type of wxEvent that determines mouse button press. ///> The type of wxEvent that determines mouse button press.
wxEventType downEvent; wxEventType downEvent;
...@@ -89,9 +89,9 @@ struct TOOL_DISPATCHER::ButtonState ...@@ -89,9 +89,9 @@ struct TOOL_DISPATCHER::ButtonState
TOOL_DISPATCHER::TOOL_DISPATCHER( TOOL_MANAGER* aToolMgr, PCB_BASE_FRAME* aEditFrame ) : TOOL_DISPATCHER::TOOL_DISPATCHER( TOOL_MANAGER* aToolMgr, PCB_BASE_FRAME* aEditFrame ) :
m_toolMgr( aToolMgr ), m_editFrame( aEditFrame ) m_toolMgr( aToolMgr ), m_editFrame( aEditFrame )
{ {
m_buttons.push_back( new ButtonState( MB_Left, wxEVT_LEFT_DOWN, wxEVT_LEFT_UP ) ); m_buttons.push_back( new BUTTON_STATE( MB_LEFT, wxEVT_LEFT_DOWN, wxEVT_LEFT_UP ) );
m_buttons.push_back( new ButtonState( MB_Right, wxEVT_RIGHT_DOWN, wxEVT_RIGHT_UP ) ); m_buttons.push_back( new BUTTON_STATE( MB_RIGHT, wxEVT_RIGHT_DOWN, wxEVT_RIGHT_UP ) );
m_buttons.push_back( new ButtonState( MB_Middle, wxEVT_MIDDLE_DOWN, wxEVT_MIDDLE_UP ) ); m_buttons.push_back( new BUTTON_STATE( MB_MIDDLE, wxEVT_MIDDLE_DOWN, wxEVT_MIDDLE_UP ) );
ResetState(); ResetState();
} }
...@@ -99,14 +99,14 @@ TOOL_DISPATCHER::TOOL_DISPATCHER( TOOL_MANAGER* aToolMgr, PCB_BASE_FRAME* aEditF ...@@ -99,14 +99,14 @@ TOOL_DISPATCHER::TOOL_DISPATCHER( TOOL_MANAGER* aToolMgr, PCB_BASE_FRAME* aEditF
TOOL_DISPATCHER::~TOOL_DISPATCHER() TOOL_DISPATCHER::~TOOL_DISPATCHER()
{ {
BOOST_FOREACH( ButtonState* st, m_buttons ) BOOST_FOREACH( BUTTON_STATE* st, m_buttons )
delete st; delete st;
} }
void TOOL_DISPATCHER::ResetState() void TOOL_DISPATCHER::ResetState()
{ {
BOOST_FOREACH( ButtonState* st, m_buttons ) BOOST_FOREACH( BUTTON_STATE* st, m_buttons )
st->Reset(); st->Reset();
} }
...@@ -119,7 +119,7 @@ KIGFX::VIEW* TOOL_DISPATCHER::getView() ...@@ -119,7 +119,7 @@ KIGFX::VIEW* TOOL_DISPATCHER::getView()
bool TOOL_DISPATCHER::handleMouseButton( wxEvent& aEvent, int aIndex, bool aMotion ) bool TOOL_DISPATCHER::handleMouseButton( wxEvent& aEvent, int aIndex, bool aMotion )
{ {
ButtonState* st = m_buttons[aIndex]; BUTTON_STATE* st = m_buttons[aIndex];
wxEventType type = aEvent.GetEventType(); wxEventType type = aEvent.GetEventType();
optional<TOOL_EVENT> evt; optional<TOOL_EVENT> evt;
bool isClick = false; bool isClick = false;
...@@ -137,7 +137,7 @@ bool TOOL_DISPATCHER::handleMouseButton( wxEvent& aEvent, int aIndex, bool aMoti ...@@ -137,7 +137,7 @@ bool TOOL_DISPATCHER::handleMouseButton( wxEvent& aEvent, int aIndex, bool aMoti
st->downPosition = m_lastMousePos; st->downPosition = m_lastMousePos;
st->dragMaxDelta = 0; st->dragMaxDelta = 0;
st->pressed = true; st->pressed = true;
evt = TOOL_EVENT( TC_Mouse, TA_MouseDown, args ); evt = TOOL_EVENT( TC_MOUSE, TA_MOUSE_DOWN, args );
} }
else if( up ) // Handle mouse button release else if( up ) // Handle mouse button release
{ {
...@@ -152,13 +152,13 @@ bool TOOL_DISPATCHER::handleMouseButton( wxEvent& aEvent, int aIndex, bool aMoti ...@@ -152,13 +152,13 @@ bool TOOL_DISPATCHER::handleMouseButton( wxEvent& aEvent, int aIndex, bool aMoti
st->dragMaxDelta < DragDistanceThreshold ) st->dragMaxDelta < DragDistanceThreshold )
isClick = true; isClick = true;
else else
evt = TOOL_EVENT( TC_Mouse, TA_MouseUp, args ); evt = TOOL_EVENT( TC_MOUSE, TA_MOUSE_UP, args );
} }
else else
isClick = true; isClick = true;
if( isClick ) if( isClick )
evt = TOOL_EVENT( TC_Mouse, TA_MouseClick, args ); evt = TOOL_EVENT( TC_MOUSE, TA_MOUSE_CLICK, args );
st->dragging = false; st->dragging = false;
} }
...@@ -174,7 +174,7 @@ bool TOOL_DISPATCHER::handleMouseButton( wxEvent& aEvent, int aIndex, bool aMoti ...@@ -174,7 +174,7 @@ bool TOOL_DISPATCHER::handleMouseButton( wxEvent& aEvent, int aIndex, bool aMoti
if( t - st->downTimestamp > DragTimeThreshold || st->dragMaxDelta > DragDistanceThreshold ) if( t - st->downTimestamp > DragTimeThreshold || st->dragMaxDelta > DragDistanceThreshold )
{ {
evt = TOOL_EVENT( TC_Mouse, TA_MouseDrag, args ); evt = TOOL_EVENT( TC_MOUSE, TA_MOUSE_DRAG, args );
evt->SetMouseDragOrigin( st->dragOrigin ); evt->SetMouseDragOrigin( st->dragOrigin );
evt->SetMouseDelta( m_lastMousePos - st->dragOrigin ); evt->SetMouseDelta( m_lastMousePos - st->dragOrigin );
} }
...@@ -222,7 +222,7 @@ void TOOL_DISPATCHER::DispatchWxEvent( wxEvent& aEvent ) ...@@ -222,7 +222,7 @@ void TOOL_DISPATCHER::DispatchWxEvent( wxEvent& aEvent )
if( !buttonEvents && motion ) if( !buttonEvents && motion )
{ {
evt = TOOL_EVENT( TC_Mouse, TA_MouseMotion ); evt = TOOL_EVENT( TC_MOUSE, TA_MOUSE_MOTION );
evt->SetMousePosition( pos ); evt->SetMousePosition( pos );
} }
} }
...@@ -237,13 +237,13 @@ void TOOL_DISPATCHER::DispatchWxEvent( wxEvent& aEvent ) ...@@ -237,13 +237,13 @@ void TOOL_DISPATCHER::DispatchWxEvent( wxEvent& aEvent )
if( type == wxEVT_KEY_UP ) 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 ); evt = TOOL_EVENT( TC_COMMAND, TA_CANCEL_TOOL );
else else
evt = TOOL_EVENT( TC_Keyboard, TA_KeyUp, key | mods ); evt = TOOL_EVENT( TC_KEYBOARD, TA_KEY_UP, key | mods );
} }
else else
{ {
evt = TOOL_EVENT( TC_Keyboard, TA_KeyDown, key | mods ); evt = TOOL_EVENT( TC_KEYBOARD, TA_KEY_DOWN, key | mods );
} }
} }
......
...@@ -40,14 +40,14 @@ struct FlagString ...@@ -40,14 +40,14 @@ struct FlagString
}; };
static const std::string flag2string( int flag, const FlagString* exps ) static const std::string flag2string( int aFlag, const FlagString* aExps )
{ {
std::string rv; std::string rv;
for( int i = 0; exps[i].str.length(); i++ ) for( int i = 0; aExps[i].str.length(); i++ )
{ {
if( exps[i].flag & flag ) if( aExps[i].flag & aFlag )
rv += exps[i].str + " "; rv += aExps[i].str + " ";
} }
return rv; return rv;
...@@ -66,51 +66,51 @@ const std::string TOOL_EVENT::Format() const ...@@ -66,51 +66,51 @@ const std::string TOOL_EVENT::Format() const
const FlagString categories[] = const FlagString categories[] =
{ {
{ TC_Mouse, "mouse" }, { TC_MOUSE, "mouse" },
{ TC_Keyboard, "keyboard" }, { TC_KEYBOARD, "keyboard" },
{ TC_Command, "command" }, { TC_COMMAND, "command" },
{ TC_Message, "message" }, { TC_MESSAGE, "message" },
{ TC_View, "view" }, { TC_VIEW, "view" },
{ 0, "" } { 0, "" }
}; };
const FlagString actions[] = const FlagString actions[] =
{ {
{ TA_MouseClick, "click" }, { TA_MOUSE_CLICK, "click" },
{ TA_MouseUp, "button-up" }, { TA_MOUSE_UP, "button-up" },
{ TA_MouseDown, "button-down" }, { TA_MOUSE_DOWN, "button-down" },
{ TA_MouseDrag, "drag" }, { TA_MOUSE_DRAG, "drag" },
{ TA_MouseMotion, "motion" }, { TA_MOUSE_MOTION, "motion" },
{ TA_MouseWheel, "wheel" }, { TA_MOUSE_WHEEL, "wheel" },
{ TA_KeyUp, "key-up" }, { TA_KEY_UP, "key-up" },
{ TA_KeyDown, "key-down" }, { TA_KEY_DOWN, "key-down" },
{ TA_ViewRefresh, "view-refresh" }, { TA_VIEW_REFRESH, "view-refresh" },
{ TA_ViewZoom, "view-zoom" }, { TA_VIEW_ZOOM, "view-zoom" },
{ TA_ViewPan, "view-pan" }, { TA_VIEW_PAN, "view-pan" },
{ TA_ViewDirty, "view-dirty" }, { TA_VIEW_DIRTY, "view-dirty" },
{ TA_ChangeLayer, "change-layer" }, { TA_CHANGE_LAYER, "change-layer" },
{ TA_CancelTool, "cancel-tool" }, { TA_CANCEL_TOOL, "cancel-tool" },
{ TA_ContextMenuUpdate, "context-menu-update" }, { TA_CONTEXT_MENU_UPDATE, "context-menu-update" },
{ TA_ContextMenuChoice, "context-menu-choice" }, { TA_CONTEXT_MENU_CHOICE, "context-menu-choice" },
{ TA_Action, "action" }, { TA_ACTION, "action" },
{ 0, "" } { 0, "" }
}; };
const FlagString buttons[] = const FlagString buttons[] =
{ {
{ MB_None, "none" }, { MB_NONE, "none" },
{ MB_Left, "left" }, { MB_LEFT, "left" },
{ MB_Right, "right" }, { MB_RIGHT, "right" },
{ MB_Middle, "middle" }, { MB_MIDDLE, "middle" },
{ 0, "" } { 0, "" }
}; };
const FlagString modifiers[] = const FlagString modifiers[] =
{ {
{ MD_ModShift, "shift" }, { MD_SHIFT, "shift" },
{ MD_ModCtrl, "ctrl" }, { MD_CTRL, "ctrl" },
{ MD_ModAlt, "alt" }, { MD_ALT, "alt" },
{ 0, "" } { 0, "" }
}; };
ev = "category: "; ev = "category: ";
...@@ -118,20 +118,20 @@ const std::string TOOL_EVENT::Format() const ...@@ -118,20 +118,20 @@ const std::string TOOL_EVENT::Format() const
ev += " action: "; ev += " action: ";
ev += flag2string( m_actions, actions ); ev += flag2string( m_actions, actions );
if( m_actions & TA_Mouse ) if( m_actions & TA_MOUSE )
{ {
ev += " btns: "; ev += " btns: ";
ev += flag2string( m_mouseButtons, buttons ); ev += flag2string( m_mouseButtons, buttons );
} }
if( m_actions & TA_Keyboard ) if( m_actions & TA_KEYBOARD )
{ {
char tmp[128]; char tmp[128];
sprintf( tmp, "key: %d", m_keyCode ); sprintf( tmp, "key: %d", m_keyCode );
ev += tmp; ev += tmp;
} }
if( m_actions & ( TA_Mouse | TA_Keyboard ) ) if( m_actions & ( TA_MOUSE | TA_KEYBOARD ) )
{ {
ev += " mods: "; ev += " mods: ";
ev += flag2string( m_modifiers, modifiers ); ev += flag2string( m_modifiers, modifiers );
......
...@@ -30,13 +30,13 @@ ...@@ -30,13 +30,13 @@
#include <tool/context_menu.h> #include <tool/context_menu.h>
TOOL_INTERACTIVE::TOOL_INTERACTIVE( TOOL_ID aId, const std::string& aName ) : TOOL_INTERACTIVE::TOOL_INTERACTIVE( TOOL_ID aId, const std::string& aName ) :
TOOL_BASE( TOOL_Interactive, aId, aName ) TOOL_BASE( INTERACTIVE, aId, aName )
{ {
} }
TOOL_INTERACTIVE::TOOL_INTERACTIVE( const std::string& aName ) : TOOL_INTERACTIVE::TOOL_INTERACTIVE( const std::string& aName ) :
TOOL_BASE( TOOL_Interactive, TOOL_MANAGER::MakeToolId( aName ), aName ) TOOL_BASE( INTERACTIVE, TOOL_MANAGER::MakeToolId( aName ), aName )
{ {
} }
......
...@@ -134,7 +134,7 @@ void TOOL_MANAGER::RegisterTool( TOOL_BASE* aTool ) ...@@ -134,7 +134,7 @@ void TOOL_MANAGER::RegisterTool( TOOL_BASE* aTool )
aTool->m_toolMgr = this; aTool->m_toolMgr = this;
if( aTool->GetType() == TOOL_Interactive ) if( aTool->GetType() == INTERACTIVE )
{ {
bool initState = static_cast<TOOL_INTERACTIVE*>( aTool )->Init(); bool initState = static_cast<TOOL_INTERACTIVE*>( aTool )->Init();
...@@ -158,7 +158,7 @@ bool TOOL_MANAGER::InvokeTool( TOOL_ID aToolId ) ...@@ -158,7 +158,7 @@ bool TOOL_MANAGER::InvokeTool( TOOL_ID aToolId )
{ {
TOOL_BASE* tool = FindTool( aToolId ); TOOL_BASE* tool = FindTool( aToolId );
if( tool && tool->GetType() == TOOL_Interactive ) if( tool && tool->GetType() == INTERACTIVE )
return invokeTool( tool ); return invokeTool( tool );
return false; // there is no tool with the given id return false; // there is no tool with the given id
...@@ -169,7 +169,7 @@ bool TOOL_MANAGER::InvokeTool( const std::string& aToolName ) ...@@ -169,7 +169,7 @@ bool TOOL_MANAGER::InvokeTool( const std::string& aToolName )
{ {
TOOL_BASE* tool = FindTool( aToolName ); TOOL_BASE* tool = FindTool( aToolName );
if( tool && tool->GetType() == TOOL_Interactive ) if( tool && tool->GetType() == INTERACTIVE )
return invokeTool( tool ); return invokeTool( tool );
return false; // there is no tool with the given name return false; // there is no tool with the given name
...@@ -192,7 +192,7 @@ bool TOOL_MANAGER::invokeTool( TOOL_BASE* aTool ) ...@@ -192,7 +192,7 @@ bool TOOL_MANAGER::invokeTool( TOOL_BASE* aTool )
{ {
wxASSERT( aTool != NULL ); wxASSERT( aTool != NULL );
TOOL_EVENT evt( TC_Command, TA_Action, aTool->GetName() ); TOOL_EVENT evt( TC_COMMAND, TA_ACTION, aTool->GetName() );
ProcessEvent( evt ); ProcessEvent( evt );
return true; return true;
...@@ -203,7 +203,7 @@ bool TOOL_MANAGER::runTool( TOOL_ID aToolId ) ...@@ -203,7 +203,7 @@ bool TOOL_MANAGER::runTool( TOOL_ID aToolId )
{ {
TOOL_BASE* tool = FindTool( aToolId ); TOOL_BASE* tool = FindTool( aToolId );
if( tool && tool->GetType() == TOOL_Interactive ) if( tool && tool->GetType() == INTERACTIVE )
return runTool( tool ); return runTool( tool );
return false; // there is no tool with the given id return false; // there is no tool with the given id
...@@ -214,7 +214,7 @@ bool TOOL_MANAGER::runTool( const std::string& aToolName ) ...@@ -214,7 +214,7 @@ bool TOOL_MANAGER::runTool( const std::string& aToolName )
{ {
TOOL_BASE* tool = FindTool( aToolName ); TOOL_BASE* tool = FindTool( aToolName );
if( tool && tool->GetType() == TOOL_Interactive ) if( tool && tool->GetType() == INTERACTIVE )
return runTool( tool ); return runTool( tool );
return false; // there is no tool with the given name return false; // there is no tool with the given name
...@@ -360,13 +360,13 @@ void TOOL_MANAGER::dispatchInternal( TOOL_EVENT& aEvent ) ...@@ -360,13 +360,13 @@ void TOOL_MANAGER::dispatchInternal( TOOL_EVENT& aEvent )
bool TOOL_MANAGER::dispatchStandardEvents( TOOL_EVENT& aEvent ) bool TOOL_MANAGER::dispatchStandardEvents( TOOL_EVENT& aEvent )
{ {
if( aEvent.Action() == TA_KeyUp ) if( aEvent.Action() == TA_KEY_UP )
{ {
// Check if there is a hotkey associated // Check if there is a hotkey associated
if( m_actionMgr->RunHotKey( aEvent.Modifier() | aEvent.KeyCode() ) ) 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 ); dispatchActivation( aEvent );
// do not return false, as the event has to go on to the destined tool // do not return false, as the event has to go on to the destined tool
...@@ -433,11 +433,11 @@ bool TOOL_MANAGER::ProcessEvent( TOOL_EVENT& aEvent ) ...@@ -433,11 +433,11 @@ bool TOOL_MANAGER::ProcessEvent( TOOL_EVENT& aEvent )
// or immediately (CMENU_NOW) mode. The latter is used for clarification lists. // or immediately (CMENU_NOW) mode. The latter is used for clarification lists.
if( st->contextMenuTrigger != CMENU_OFF ) if( st->contextMenuTrigger != CMENU_OFF )
{ {
if( st->contextMenuTrigger == CMENU_BUTTON && !aEvent.IsClick( MB_Right ) ) if( st->contextMenuTrigger == CMENU_BUTTON && !aEvent.IsClick( MB_RIGHT ) )
break; break;
st->pendingWait = true; st->pendingWait = true;
st->waitEvents = TOOL_EVENT( TC_Any, TA_Any ); st->waitEvents = TOOL_EVENT( TC_ANY, TA_ANY );
if( st->contextMenuTrigger == CMENU_NOW ) if( st->contextMenuTrigger == CMENU_NOW )
st->contextMenuTrigger = CMENU_OFF; st->contextMenuTrigger = CMENU_OFF;
...@@ -446,7 +446,7 @@ bool TOOL_MANAGER::ProcessEvent( TOOL_EVENT& aEvent ) ...@@ -446,7 +446,7 @@ bool TOOL_MANAGER::ProcessEvent( TOOL_EVENT& aEvent )
GetEditFrame()->PopupMenu( menu->GetMenu() ); GetEditFrame()->PopupMenu( menu->GetMenu() );
// //
TOOL_EVENT evt( TC_Command, TA_ContextMenuChoice ); TOOL_EVENT evt( TC_COMMAND, TA_CONTEXT_MENU_CHOICE );
dispatchInternal( evt ); dispatchInternal( evt );
break; break;
...@@ -498,7 +498,7 @@ void TOOL_MANAGER::SetEnvironment( EDA_ITEM* aModel, KIGFX::VIEW* aView, ...@@ -498,7 +498,7 @@ void TOOL_MANAGER::SetEnvironment( EDA_ITEM* aModel, KIGFX::VIEW* aView,
{ {
TOOL_BASE* tool = m_toolIdIndex[toolId]->theTool; TOOL_BASE* tool = m_toolIdIndex[toolId]->theTool;
if( tool->GetType() == TOOL_Interactive ) if( tool->GetType() == INTERACTIVE )
static_cast<TOOL_INTERACTIVE*>( tool )->Reset(); static_cast<TOOL_INTERACTIVE*>( tool )->Reset();
} }
} }
......
...@@ -67,7 +67,7 @@ VIEW::VIEW( bool aIsDynamic ) : ...@@ -67,7 +67,7 @@ VIEW::VIEW( bool aIsDynamic ) :
VIEW::~VIEW() VIEW::~VIEW()
{ {
BOOST_FOREACH( LayerMap::value_type& l, m_layers ) BOOST_FOREACH( LAYER_MAP::value_type& l, m_layers )
{ {
delete l.second.items; delete l.second.items;
} }
...@@ -156,7 +156,7 @@ struct queryVisitor ...@@ -156,7 +156,7 @@ struct queryVisitor
void operator()( VIEW_ITEM* aItem ) void operator()( VIEW_ITEM* aItem )
{ {
if( aItem->ViewIsVisible() ) if( aItem->ViewIsVisible() )
m_cont.push_back( VIEW::LayerItemPair( aItem, m_layer ) ); m_cont.push_back( VIEW::LAYER_ITEM_PAIR( aItem, m_layer ) );
} }
Container& m_cont; Container& m_cont;
...@@ -164,7 +164,7 @@ struct queryVisitor ...@@ -164,7 +164,7 @@ struct queryVisitor
}; };
int VIEW::Query( const BOX2I& aRect, std::vector<LayerItemPair>& aResult ) int VIEW::Query( const BOX2I& aRect, std::vector<LAYER_ITEM_PAIR>& aResult )
{ {
if( m_orderedLayers.empty() ) if( m_orderedLayers.empty() )
return 0; return 0;
...@@ -179,7 +179,7 @@ int VIEW::Query( const BOX2I& aRect, std::vector<LayerItemPair>& aResult ) ...@@ -179,7 +179,7 @@ int VIEW::Query( const BOX2I& aRect, std::vector<LayerItemPair>& aResult )
if( ( *i )->displayOnly ) if( ( *i )->displayOnly )
continue; continue;
queryVisitor<std::vector<LayerItemPair> > visitor( aResult, ( *i )->id ); queryVisitor<std::vector<LAYER_ITEM_PAIR> > visitor( aResult, ( *i )->id );
( *i )->items->Query( aRect, visitor ); ( *i )->items->Query( aRect, visitor );
} }
...@@ -424,7 +424,7 @@ void VIEW::UpdateAllLayersColor() ...@@ -424,7 +424,7 @@ void VIEW::UpdateAllLayersColor()
r.SetMaximum(); r.SetMaximum();
for( LayerMapIter i = m_layers.begin(); i != m_layers.end(); ++i ) for( LAYER_MAP_ITER i = m_layers.begin(); i != m_layers.end(); ++i )
{ {
VIEW_LAYER* l = &( ( *i ).second ); VIEW_LAYER* l = &( ( *i ).second );
...@@ -555,7 +555,7 @@ void VIEW::UpdateAllLayersOrder() ...@@ -555,7 +555,7 @@ void VIEW::UpdateAllLayersOrder()
{ {
sortLayers(); sortLayers();
BOOST_FOREACH( LayerMap::value_type& l, m_layers ) BOOST_FOREACH( LAYER_MAP::value_type& l, m_layers )
{ {
ChangeLayerDepth( l.first, l.second.renderingOrder ); ChangeLayerDepth( l.first, l.second.renderingOrder );
} }
...@@ -727,7 +727,7 @@ void VIEW::Clear() ...@@ -727,7 +727,7 @@ void VIEW::Clear()
r.SetMaximum(); r.SetMaximum();
for( LayerMapIter i = m_layers.begin(); i != m_layers.end(); ++i ) for( LAYER_MAP_ITER i = m_layers.begin(); i != m_layers.end(); ++i )
{ {
VIEW_LAYER* l = &( ( *i ).second ); VIEW_LAYER* l = &( ( *i ).second );
unlinkItem v; unlinkItem v;
...@@ -811,7 +811,7 @@ void VIEW::clearGroupCache() ...@@ -811,7 +811,7 @@ void VIEW::clearGroupCache()
r.SetMaximum(); r.SetMaximum();
clearLayerCache visitor( this ); clearLayerCache visitor( this );
for( LayerMapIter i = m_layers.begin(); i != m_layers.end(); ++i ) for( LAYER_MAP_ITER i = m_layers.begin(); i != m_layers.end(); ++i )
{ {
VIEW_LAYER* l = &( ( *i ).second ); VIEW_LAYER* l = &( ( *i ).second );
l->items->Query( r, visitor ); l->items->Query( r, visitor );
...@@ -858,7 +858,7 @@ void VIEW::sortLayers() ...@@ -858,7 +858,7 @@ void VIEW::sortLayers()
m_orderedLayers.resize( m_layers.size() ); m_orderedLayers.resize( m_layers.size() );
for( LayerMapIter i = m_layers.begin(); i != m_layers.end(); ++i ) for( LAYER_MAP_ITER i = m_layers.begin(); i != m_layers.end(); ++i )
m_orderedLayers[n++] = &i->second; m_orderedLayers[n++] = &i->second;
sort( m_orderedLayers.begin(), m_orderedLayers.end(), compareRenderingOrder ); sort( m_orderedLayers.begin(), m_orderedLayers.end(), compareRenderingOrder );
...@@ -974,7 +974,7 @@ void VIEW::RecacheAllItems( bool aImmediately ) ...@@ -974,7 +974,7 @@ void VIEW::RecacheAllItems( bool aImmediately )
prof_start( &totalRealTime, false ); prof_start( &totalRealTime, false );
#endif /* __WXDEBUG__ */ #endif /* __WXDEBUG__ */
for( LayerMapIter i = m_layers.begin(); i != m_layers.end(); ++i ) for( LAYER_MAP_ITER i = m_layers.begin(); i != m_layers.end(); ++i )
{ {
VIEW_LAYER* l = &( ( *i ).second ); VIEW_LAYER* l = &( ( *i ).second );
......
...@@ -142,7 +142,7 @@ void VIEW_GROUP::ItemsSetVisibility( bool aVisible ) ...@@ -142,7 +142,7 @@ void VIEW_GROUP::ItemsSetVisibility( bool aVisible )
} }
void VIEW_GROUP::ItemsViewUpdate( VIEW_ITEM::ViewUpdateFlags aFlags ) void VIEW_GROUP::ItemsViewUpdate( VIEW_ITEM::VIEW_UPDATE_FLAGS aFlags )
{ {
std::set<VIEW_ITEM*>::const_iterator it, it_end; std::set<VIEW_ITEM*>::const_iterator it, it_end;
......
...@@ -39,26 +39,26 @@ WX_VIEW_CONTROLS::WX_VIEW_CONTROLS( VIEW* aView, wxWindow* aParentPanel ) : ...@@ -39,26 +39,26 @@ WX_VIEW_CONTROLS::WX_VIEW_CONTROLS( VIEW* aView, wxWindow* aParentPanel ) :
m_state( IDLE ), m_state( IDLE ),
m_parentPanel( aParentPanel ) m_parentPanel( aParentPanel )
{ {
m_parentPanel->Connect( wxEVT_MOTION, wxMouseEventHandler( m_parentPanel->Connect( wxEVT_MOTION,
WX_VIEW_CONTROLS::onMotion ), NULL, this ); wxMouseEventHandler( WX_VIEW_CONTROLS::onMotion ), NULL, this );
m_parentPanel->Connect( wxEVT_MOUSEWHEEL, wxMouseEventHandler( m_parentPanel->Connect( wxEVT_MOUSEWHEEL,
WX_VIEW_CONTROLS::onWheel ), NULL, this ); wxMouseEventHandler( WX_VIEW_CONTROLS::onWheel ), NULL, this );
m_parentPanel->Connect( wxEVT_MIDDLE_UP, wxMouseEventHandler( m_parentPanel->Connect( wxEVT_MIDDLE_UP,
WX_VIEW_CONTROLS::onButton ), NULL, this ); wxMouseEventHandler( WX_VIEW_CONTROLS::onButton ), NULL, this );
m_parentPanel->Connect( wxEVT_MIDDLE_DOWN, wxMouseEventHandler( m_parentPanel->Connect( wxEVT_MIDDLE_DOWN,
WX_VIEW_CONTROLS::onButton ), NULL, this ); wxMouseEventHandler( WX_VIEW_CONTROLS::onButton ), NULL, this );
m_parentPanel->Connect( wxEVT_LEFT_UP, wxMouseEventHandler( m_parentPanel->Connect( wxEVT_LEFT_UP,
WX_VIEW_CONTROLS::onButton ), NULL, this ); wxMouseEventHandler( WX_VIEW_CONTROLS::onButton ), NULL, this );
m_parentPanel->Connect( wxEVT_LEFT_DOWN, wxMouseEventHandler( m_parentPanel->Connect( wxEVT_LEFT_DOWN,
WX_VIEW_CONTROLS::onButton ), NULL, this ); wxMouseEventHandler( WX_VIEW_CONTROLS::onButton ), NULL, this );
#if defined _WIN32 || defined _WIN64 #if defined _WIN32 || defined _WIN64
m_parentPanel->Connect( wxEVT_ENTER_WINDOW, wxMouseEventHandler( m_parentPanel->Connect( wxEVT_ENTER_WINDOW,
WX_VIEW_CONTROLS::onEnter ), NULL, this ); wxMouseEventHandler( WX_VIEW_CONTROLS::onEnter ), NULL, this );
#endif #endif
m_panTimer.SetOwner( this ); m_panTimer.SetOwner( this );
this->Connect( wxEVT_TIMER, wxTimerEventHandler( this->Connect( wxEVT_TIMER,
WX_VIEW_CONTROLS::onTimer ), NULL, this ); wxTimerEventHandler( WX_VIEW_CONTROLS::onTimer ), NULL, this );
} }
......
...@@ -217,13 +217,13 @@ public: ...@@ -217,13 +217,13 @@ public:
virtual void RestoreScreen(); virtual void RestoreScreen();
/// @copydoc GAL::SetTarget() /// @copydoc GAL::SetTarget()
virtual void SetTarget( RenderTarget aTarget ); virtual void SetTarget( RENDER_TARGET aTarget );
/// @copydoc GAL::GetTarget() /// @copydoc GAL::GetTarget()
virtual RenderTarget GetTarget() const; virtual RENDER_TARGET GetTarget() const;
/// @copydoc GAL::ClearTarget() /// @copydoc GAL::ClearTarget()
virtual void ClearTarget( RenderTarget aTarget ); virtual void ClearTarget( RENDER_TARGET aTarget );
// ------- // -------
// Cursor // Cursor
...@@ -267,7 +267,7 @@ private: ...@@ -267,7 +267,7 @@ private:
boost::shared_ptr<CAIRO_COMPOSITOR> compositor; ///< Object for layers compositing boost::shared_ptr<CAIRO_COMPOSITOR> compositor; ///< Object for layers compositing
unsigned int mainBuffer; ///< Handle to the main buffer unsigned int mainBuffer; ///< Handle to the main buffer
unsigned int overlayBuffer; ///< Handle to the overlay buffer unsigned int overlayBuffer; ///< Handle to the overlay buffer
RenderTarget currentTarget; ///< Current rendering target RENDER_TARGET currentTarget; ///< Current rendering target
bool validCompositor; ///< Compositor initialization flag bool validCompositor; ///< Compositor initialization flag
// Variables related to wxWidgets // Variables related to wxWidgets
...@@ -290,7 +290,8 @@ private: ...@@ -290,7 +290,8 @@ private:
static const int MAX_CAIRO_ARGUMENTS = 6; static const int MAX_CAIRO_ARGUMENTS = 6;
/// Definitions for the command recorder /// Definitions for the command recorder
enum GraphicsCommand { enum GRAPHICS_COMMAND
{
CMD_SET_FILL, ///< Enable/disable filling CMD_SET_FILL, ///< Enable/disable filling
CMD_SET_STROKE, ///< Enable/disable stroking CMD_SET_STROKE, ///< Enable/disable stroking
CMD_SET_FILLCOLOR, ///< Set the fill color CMD_SET_FILLCOLOR, ///< Set the fill color
...@@ -310,20 +311,20 @@ private: ...@@ -310,20 +311,20 @@ private:
/// Type definition for an graphics group element /// Type definition for an graphics group element
typedef struct typedef struct
{ {
GraphicsCommand command; ///< Command to execute GRAPHICS_COMMAND command; ///< Command to execute
double arguments[MAX_CAIRO_ARGUMENTS]; ///< Arguments for Cairo commands double arguments[MAX_CAIRO_ARGUMENTS]; ///< Arguments for Cairo commands
bool boolArgument; ///< A bool argument bool boolArgument; ///< A bool argument
int intArgument; ///< An int argument int intArgument; ///< An int argument
cairo_path_t* cairoPath; ///< Pointer to a Cairo path cairo_path_t* cairoPath; ///< Pointer to a Cairo path
} GroupElement; } GROUP_ELEMENT;
// Variables for the grouping function // Variables for the grouping function
bool isGrouping; ///< Is grouping enabled ? bool isGrouping; ///< Is grouping enabled ?
bool isElementAdded; ///< Was an graphic element added ? bool isElementAdded; ///< Was an graphic element added ?
typedef std::deque<GroupElement> Group; ///< A graphic group type definition typedef std::deque<GROUP_ELEMENT> GROUP; ///< A graphic group type definition
std::map<int, Group> groups; ///< List of graphic groups std::map<int, GROUP> groups; ///< List of graphic groups
unsigned int groupCounter; ///< Counter used for generating keys for groups unsigned int groupCounter; ///< Counter used for generating keys for groups
Group* currentGroup; ///< Currently used group GROUP* currentGroup; ///< Currently used group
// Variables related to Cairo <-> wxWidgets // Variables related to Cairo <-> wxWidgets
cairo_matrix_t cairoWorldScreenMatrix; ///< Cairo world to screen transformation matrix cairo_matrix_t cairoWorldScreenMatrix; ///< Cairo world to screen transformation matrix
......
...@@ -34,9 +34,9 @@ ...@@ -34,9 +34,9 @@
namespace KIGFX namespace KIGFX
{ {
/** /**
* RenderTarget: Possible rendering targets * RENDER_TARGET: Possible rendering targets
*/ */
enum RenderTarget enum RENDER_TARGET
{ {
TARGET_CACHED = 0, ///< Main rendering target (cached) TARGET_CACHED = 0, ///< Main rendering target (cached)
TARGET_NONCACHED, ///< Auxiliary rendering target (noncached) TARGET_NONCACHED, ///< Auxiliary rendering target (noncached)
......
...@@ -589,21 +589,21 @@ public: ...@@ -589,21 +589,21 @@ public:
* *
* @param aTarget is the new target for rendering. * @param aTarget is the new target for rendering.
*/ */
virtual void SetTarget( RenderTarget aTarget ) = 0; virtual void SetTarget( RENDER_TARGET aTarget ) = 0;
/** /**
* @brief Gets the currently used target for rendering. * @brief Gets the currently used target for rendering.
* *
* @return The current rendering target. * @return The current rendering target.
*/ */
virtual RenderTarget GetTarget() const = 0; virtual RENDER_TARGET GetTarget() const = 0;
/** /**
* @brief Clears the target for rendering. * @brief Clears the target for rendering.
* *
* @param aTarget is the target to be cleared. * @param aTarget is the target to be cleared.
*/ */
virtual void ClearTarget( RenderTarget aTarget ) = 0; virtual void ClearTarget( RENDER_TARGET aTarget ) = 0;
// ------------- // -------------
// Grid methods // Grid methods
......
...@@ -49,19 +49,19 @@ class CACHED_CONTAINER : public VERTEX_CONTAINER ...@@ -49,19 +49,19 @@ class CACHED_CONTAINER : public VERTEX_CONTAINER
public: public:
CACHED_CONTAINER( unsigned int aSize = defaultInitSize ); CACHED_CONTAINER( unsigned int aSize = defaultInitSize );
///< @copydoc VERTEX_CONTAINER::SetItem() ///> @copydoc VERTEX_CONTAINER::SetItem()
virtual void SetItem( VERTEX_ITEM* aItem ); virtual void SetItem( VERTEX_ITEM* aItem );
///< @copydoc VERTEX_CONTAINER::FinishItem() ///> @copydoc VERTEX_CONTAINER::FinishItem()
virtual void FinishItem(); virtual void FinishItem();
///< @copydoc VERTEX_CONTAINER::Allocate() ///> @copydoc VERTEX_CONTAINER::Allocate()
virtual VERTEX* Allocate( unsigned int aSize ); virtual VERTEX* Allocate( unsigned int aSize );
///< @copydoc VERTEX_CONTAINER::Delete() ///> @copydoc VERTEX_CONTAINER::Delete()
virtual void Delete( VERTEX_ITEM* aItem ); virtual void Delete( VERTEX_ITEM* aItem );
///< @copydoc VERTEX_CONTAINER::Clear() ///> @copydoc VERTEX_CONTAINER::Clear()
virtual void Clear(); virtual void Clear();
/** /**
...@@ -73,23 +73,23 @@ public: ...@@ -73,23 +73,23 @@ public:
virtual VERTEX* GetVertices( const VERTEX_ITEM* aItem ) const; virtual VERTEX* GetVertices( const VERTEX_ITEM* aItem ) const;
protected: protected:
///< Maps size of free memory chunks to their offsets ///> Maps size of free memory chunks to their offsets
typedef std::pair<unsigned int, unsigned int> Chunk; typedef std::pair<unsigned int, unsigned int> CHUNK;
typedef std::multimap<unsigned int, unsigned int> FreeChunkMap; typedef std::multimap<unsigned int, unsigned int> FREE_CHUNK_MAP;
/// List of all the stored items /// List of all the stored items
typedef std::set<VERTEX_ITEM*> Items; typedef std::set<VERTEX_ITEM*> ITEMS;
///< Stores size & offset of free chunks. ///> Stores size & offset of free chunks.
FreeChunkMap m_freeChunks; FREE_CHUNK_MAP m_freeChunks;
///< Stored VERTEX_ITEMs ///> Stored VERTEX_ITEMs
Items m_items; ITEMS m_items;
///< Currently modified item ///> Currently modified item
VERTEX_ITEM* m_item; VERTEX_ITEM* m_item;
///< Properties of currently modified chunk & item ///> Properties of currently modified chunk & item
unsigned int m_chunkSize; unsigned int m_chunkSize;
unsigned int m_chunkOffset; unsigned int m_chunkOffset;
unsigned int m_itemSize; unsigned int m_itemSize;
...@@ -146,7 +146,7 @@ private: ...@@ -146,7 +146,7 @@ private:
* *
* @param aChunk is the chunk. * @param aChunk is the chunk.
*/ */
inline int getChunkSize( const Chunk& aChunk ) const inline int getChunkSize( const CHUNK& aChunk ) const
{ {
return aChunk.first; return aChunk.first;
} }
...@@ -157,7 +157,7 @@ private: ...@@ -157,7 +157,7 @@ private:
* *
* @param aChunk is the chunk. * @param aChunk is the chunk.
*/ */
inline unsigned int getChunkOffset( const Chunk& aChunk ) const inline unsigned int getChunkOffset( const CHUNK& aChunk ) const
{ {
return aChunk.second; return aChunk.second;
} }
......
...@@ -89,15 +89,17 @@ public: ...@@ -89,15 +89,17 @@ public:
protected: protected:
GPU_MANAGER( VERTEX_CONTAINER* aContainer ); GPU_MANAGER( VERTEX_CONTAINER* aContainer );
///< Drawing status flag. ///> Drawing status flag.
bool m_isDrawing; bool m_isDrawing;
///< Container that stores vertices data. ///> Container that stores vertices data.
VERTEX_CONTAINER* m_container; VERTEX_CONTAINER* m_container;
///< Shader handling ///> Shader handling
SHADER* m_shader; SHADER* m_shader;
int m_shaderAttrib; ///< Location of shader attributes (for glVertexAttribPointer)
///> Location of shader attributes (for glVertexAttribPointer)
int m_shaderAttrib;
}; };
...@@ -107,19 +109,19 @@ public: ...@@ -107,19 +109,19 @@ public:
GPU_CACHED_MANAGER( VERTEX_CONTAINER* aContainer ); GPU_CACHED_MANAGER( VERTEX_CONTAINER* aContainer );
~GPU_CACHED_MANAGER(); ~GPU_CACHED_MANAGER();
///< @copydoc GPU_MANAGER::Initialize() ///> @copydoc GPU_MANAGER::Initialize()
virtual void Initialize(); virtual void Initialize();
///< @copydoc GPU_MANAGER::BeginDrawing() ///> @copydoc GPU_MANAGER::BeginDrawing()
virtual void BeginDrawing(); virtual void BeginDrawing();
///< @copydoc GPU_MANAGER::DrawIndices() ///> @copydoc GPU_MANAGER::DrawIndices()
virtual void DrawIndices( unsigned int aOffset, unsigned int aSize ); virtual void DrawIndices( unsigned int aOffset, unsigned int aSize );
///< @copydoc GPU_MANAGER::DrawAll() ///> @copydoc GPU_MANAGER::DrawAll()
virtual void DrawAll(); virtual void DrawAll();
///< @copydoc GPU_MANAGER::EndDrawing() ///> @copydoc GPU_MANAGER::EndDrawing()
virtual void EndDrawing(); virtual void EndDrawing();
/** /**
...@@ -130,10 +132,19 @@ public: ...@@ -130,10 +132,19 @@ public:
virtual void uploadToGpu(); virtual void uploadToGpu();
protected: protected:
///> Buffers initialization flag
bool m_buffersInitialized; bool m_buffersInitialized;
///> Pointer to the current indices buffer
boost::scoped_array<GLuint> m_indices; boost::scoped_array<GLuint> m_indices;
///> Pointer to the first free cell in the indices buffer
GLuint* m_indicesPtr; GLuint* m_indicesPtr;
///> Handle to vertices buffer
GLuint m_verticesBuffer; GLuint m_verticesBuffer;
///> Number of indices stored in the indices buffer
unsigned int m_indicesSize; unsigned int m_indicesSize;
}; };
...@@ -143,19 +154,19 @@ class GPU_NONCACHED_MANAGER : public GPU_MANAGER ...@@ -143,19 +154,19 @@ class GPU_NONCACHED_MANAGER : public GPU_MANAGER
public: public:
GPU_NONCACHED_MANAGER( VERTEX_CONTAINER* aContainer ); GPU_NONCACHED_MANAGER( VERTEX_CONTAINER* aContainer );
///< @copydoc GPU_MANAGER::Initialize() ///> @copydoc GPU_MANAGER::Initialize()
virtual void Initialize(); virtual void Initialize();
///< @copydoc GPU_MANAGER::BeginDrawing() ///> @copydoc GPU_MANAGER::BeginDrawing()
virtual void BeginDrawing(); virtual void BeginDrawing();
///< @copydoc GPU_MANAGER::DrawIndices() ///> @copydoc GPU_MANAGER::DrawIndices()
virtual void DrawIndices( unsigned int aOffset, unsigned int aSize ); virtual void DrawIndices( unsigned int aOffset, unsigned int aSize );
///< @copydoc GPU_MANAGER::DrawAll() ///> @copydoc GPU_MANAGER::DrawAll()
virtual void DrawAll(); virtual void DrawAll();
///< @copydoc GPU_MANAGER::EndDrawing() ///> @copydoc GPU_MANAGER::EndDrawing()
virtual void EndDrawing(); virtual void EndDrawing();
}; };
} // namespace KIGFX } // namespace KIGFX
......
...@@ -106,7 +106,8 @@ public: ...@@ -106,7 +106,8 @@ public:
virtual void DrawLine( const VECTOR2D& aStartPoint, const VECTOR2D& aEndPoint ); virtual void DrawLine( const VECTOR2D& aStartPoint, const VECTOR2D& aEndPoint );
/// @copydoc GAL::DrawSegment() /// @copydoc GAL::DrawSegment()
virtual void DrawSegment( const VECTOR2D& aStartPoint, const VECTOR2D& aEndPoint, double aWidth ); virtual void DrawSegment( const VECTOR2D& aStartPoint, const VECTOR2D& aEndPoint,
double aWidth );
/// @copydoc GAL::DrawCircle() /// @copydoc GAL::DrawCircle()
virtual void DrawCircle( const VECTOR2D& aCenterPoint, double aRadius ); virtual void DrawCircle( const VECTOR2D& aCenterPoint, double aRadius );
...@@ -209,13 +210,13 @@ public: ...@@ -209,13 +210,13 @@ public:
virtual void RestoreScreen(); virtual void RestoreScreen();
/// @copydoc GAL::SetTarget() /// @copydoc GAL::SetTarget()
virtual void SetTarget( RenderTarget aTarget ); virtual void SetTarget( RENDER_TARGET aTarget );
/// @copydoc GAL::GetTarget() /// @copydoc GAL::GetTarget()
virtual RenderTarget GetTarget() const; virtual RENDER_TARGET GetTarget() const;
/// @copydoc GAL::ClearTarget() /// @copydoc GAL::ClearTarget()
virtual void ClearTarget( RenderTarget aTarget ); virtual void ClearTarget( RENDER_TARGET aTarget );
// ------- // -------
// Cursor // Cursor
...@@ -275,8 +276,8 @@ private: ...@@ -275,8 +276,8 @@ private:
wxEvtHandler* paintListener; wxEvtHandler* paintListener;
// Vertex buffer objects related fields // Vertex buffer objects related fields
typedef std::map< unsigned int, boost::shared_ptr<VERTEX_ITEM> > GroupsMap; typedef std::map< unsigned int, boost::shared_ptr<VERTEX_ITEM> > GROUPS_MAP;
GroupsMap groups; ///< Stores informations about VBO objects (groups) GROUPS_MAP groups; ///< Stores informations about VBO objects (groups)
unsigned int groupCounter; ///< Counter used for generating keys for groups unsigned int groupCounter; ///< Counter used for generating keys for groups
VERTEX_MANAGER* currentManager; ///< Currently used VERTEX_MANAGER (for storing VERTEX_ITEMs) VERTEX_MANAGER* currentManager; ///< Currently used VERTEX_MANAGER (for storing VERTEX_ITEMs)
VERTEX_MANAGER cachedManager; ///< Container for storing cached VERTEX_ITEMs VERTEX_MANAGER cachedManager; ///< Container for storing cached VERTEX_ITEMs
...@@ -287,7 +288,7 @@ private: ...@@ -287,7 +288,7 @@ private:
OPENGL_COMPOSITOR compositor; ///< Handles multiple rendering targets OPENGL_COMPOSITOR compositor; ///< Handles multiple rendering targets
unsigned int mainBuffer; ///< Main rendering target unsigned int mainBuffer; ///< Main rendering target
unsigned int overlayBuffer; ///< Auxiliary rendering target (for menus etc.) unsigned int overlayBuffer; ///< Auxiliary rendering target (for menus etc.)
RenderTarget currentTarget; ///< Current rendering target RENDER_TARGET currentTarget; ///< Current rendering target
// Shader // Shader
SHADER shader; ///< There is only one shader used for different objects SHADER shader; ///< There is only one shader used for different objects
......
...@@ -39,7 +39,7 @@ namespace KIGFX ...@@ -39,7 +39,7 @@ namespace KIGFX
class OPENGL_GAL; class OPENGL_GAL;
/// Type definition for the shader /// Type definition for the shader
enum ShaderType enum SHADER_TYPE
{ {
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_FRAGMENT = GL_FRAGMENT_SHADER, ///< Fragment shader
...@@ -77,7 +77,7 @@ public: ...@@ -77,7 +77,7 @@ public:
* @param aShaderType is the type of the shader. * @param aShaderType is the type of the shader.
* @return True in case of success, false otherwise. * @return True in case of success, false otherwise.
*/ */
bool LoadBuiltinShader( unsigned int aShaderNumber, ShaderType aShaderType ); bool LoadBuiltinShader( unsigned int aShaderNumber, SHADER_TYPE aShaderType );
/** /**
* @brief Loads one of the built-in shaders and compiles it. * @brief Loads one of the built-in shaders and compiles it.
...@@ -86,7 +86,7 @@ public: ...@@ -86,7 +86,7 @@ public:
* @param aShaderType is the type of the shader. * @param aShaderType is the type of the shader.
* @return True in case of success, false otherwise. * @return True in case of success, false otherwise.
*/ */
bool LoadShaderFromFile( const std::string& aShaderSourceName, ShaderType aShaderType ); bool LoadShaderFromFile( const std::string& aShaderSourceName, SHADER_TYPE aShaderType );
/** /**
* @brief Link the shaders. * @brief Link the shaders.
...@@ -193,7 +193,7 @@ private: ...@@ -193,7 +193,7 @@ private:
* @param aShaderType is the type of the shader. * @param aShaderType is the type of the shader.
* @return True in case of success, false otherwise. * @return True in case of success, false otherwise.
*/ */
bool addSource( const std::string& aShaderSource, ShaderType aShaderType ); bool addSource( const std::string& aShaderSource, SHADER_TYPE aShaderType );
std::deque<GLuint> shaderNumbers; ///< Shader number list std::deque<GLuint> shaderNumbers; ///< Shader number list
GLuint programNumber; ///< Shader program number GLuint programNumber; ///< Shader program number
......
...@@ -35,7 +35,7 @@ ...@@ -35,7 +35,7 @@
namespace KIGFX namespace KIGFX
{ {
// Possible types of shaders // Possible types of shaders
enum SHADER_TYPE enum SHADER_MODE
{ {
SHADER_NONE = 0, SHADER_NONE = 0,
SHADER_LINE, SHADER_LINE,
......
...@@ -38,8 +38,8 @@ namespace KIGFX ...@@ -38,8 +38,8 @@ namespace KIGFX
{ {
class GAL; class GAL;
typedef std::deque< std::deque<VECTOR2D> > Glyph; typedef std::deque< std::deque<VECTOR2D> > GLYPH;
typedef std::deque<Glyph> GlyphList; typedef std::deque<GLYPH> GLYPH_LIST;
/** /**
* @brief Class STROKE_FONT implements stroke font drawing. * @brief Class STROKE_FONT implements stroke font drawing.
...@@ -157,7 +157,7 @@ public: ...@@ -157,7 +157,7 @@ public:
private: private:
GAL* m_gal; ///< Pointer to the GAL GAL* m_gal; ///< Pointer to the GAL
GlyphList m_glyphs; ///< Glyph list GLYPH_LIST m_glyphs; ///< Glyph list
std::deque<BOX2D> m_glyphBoundingBoxes; ///< Bounding boxes of the glyphs std::deque<BOX2D> m_glyphBoundingBoxes; ///< Bounding boxes of the glyphs
double m_scaleFactor; ///< Scale factor for the glyph double m_scaleFactor; ///< Scale factor for the glyph
VECTOR2D m_glyphSize; ///< Size of the glyphs VECTOR2D m_glyphSize; ///< Size of the glyphs
...@@ -172,7 +172,7 @@ private: ...@@ -172,7 +172,7 @@ private:
* @param aGlyphBoundingX is the x-component of the bounding box size. * @param aGlyphBoundingX is the x-component of the bounding box size.
* @return is the complete bounding box size. * @return is the complete bounding box size.
*/ */
BOX2D computeBoundingBox( const Glyph& aGlyph, const VECTOR2D& aGlyphBoundingX ) const; BOX2D computeBoundingBox( const GLYPH& aGlyph, const VECTOR2D& aGlyphBoundingX ) const;
/** /**
* @brief Compute the size of a given text. * @brief Compute the size of a given text.
......
This diff is collapsed.
...@@ -31,11 +31,11 @@ ...@@ -31,11 +31,11 @@
#include <geometry/seg.h> #include <geometry/seg.h>
/** /**
* Enum ShapeType * Enum SHAPE_TYPE
* Lists all supported shapes * Lists all supported shapes
*/ */
enum ShapeType enum SHAPE_TYPE
{ {
SH_RECT = 0, ///> axis-aligned rectangle SH_RECT = 0, ///> axis-aligned rectangle
SH_SEGMENT, ///> line segment SH_SEGMENT, ///> line segment
...@@ -50,101 +50,108 @@ enum ShapeType ...@@ -50,101 +50,108 @@ enum ShapeType
*/ */
class SHAPE class SHAPE
{ {
protected: protected:
typedef VECTOR2I::extended_type ecoord; typedef VECTOR2I::extended_type ecoord;
public: public:
/** /**
* Constructor * Constructor
* *
* Creates an empty shape of type aType * Creates an empty shape of type aType
*/ */
SHAPE ( ShapeType aType ) : m_type( aType ) { }; SHAPE ( SHAPE_TYPE aType ) : m_type( aType )
{}
// Destructor
virtual ~SHAPE() {}; // Destructor
virtual ~SHAPE()
/** {}
* Function Type()
* /**
* Returns the type of the shape. * Function Type()
* @retval the type *
*/ * Returns the type of the shape.
ShapeType Type() const { return m_type; } * @retval the type
*/
/** SHAPE_TYPE Type() const
* Function Clone() {
* return m_type;
* Returns a dynamically allocated copy of the shape }
* @retval copy of the shape
*/ /**
virtual SHAPE* Clone() const * Function Clone()
{ *
assert( false ); * Returns a dynamically allocated copy of the shape
return NULL; * @retval copy of the shape
}; */
virtual SHAPE* Clone() const
/** {
* Function Collide() assert( false );
* return NULL;
* Checks if the boundary of shape (this) lies closer to the point aP than aClearance, indicating };
* a collision.
* @return true, if there is a collision. /**
*/ * Function Collide()
virtual bool Collide( const VECTOR2I& aP, int aClearance = 0 ) const *
{ * Checks if the boundary of shape (this) lies closer to the point aP than aClearance,
return Collide( SEG( aP, aP ), aClearance ); * indicating a collision.
} * @return true, if there is a collision.
*/
/** virtual bool Collide( const VECTOR2I& aP, int aClearance = 0 ) const
* Function Collide() {
* return Collide( SEG( aP, aP ), aClearance );
* Checks if the boundary of shape (this) lies closer to the shape aShape than aClearance, indicating }
* a collision.
* @param aShape shape to check collision against /**
* @param aClearance minimum clearance * Function Collide()
* @param aMTV minimum translation vector *
* @return true, if there is a collision. * Checks if the boundary of shape (this) lies closer to the shape aShape than aClearance,
*/ * indicating a collision.
virtual bool Collide( const SHAPE* aShape, int aClerance, VECTOR2I& aMTV ) const; * @param aShape shape to check collision against
virtual bool Collide( const SHAPE* aShape, int aClerance = 0 ) const; * @param aClearance minimum clearance
* @param aMTV minimum translation vector
/** * @return true, if there is a collision.
* Function Collide() */
* virtual bool Collide( const SHAPE* aShape, int aClerance, VECTOR2I& aMTV ) const;
* Checks if the boundary of shape (this) lies closer to the segment aSeg than aClearance, indicating virtual bool Collide( const SHAPE* aShape, int aClerance = 0 ) const;
* a collision.
* @return true, if there is a collision. /**
*/ * Function Collide()
virtual bool Collide( const SEG& aSeg, int aClearance = 0 ) const = 0; *
* Checks if the boundary of shape (this) lies closer to the segment aSeg than aClearance,
/** * indicating a collision.
* Function Collide() * @return true, if there is a collision.
* */
* Computes a bounding box of the shape, with a margin of aClearance virtual bool Collide( const SEG& aSeg, int aClearance = 0 ) const = 0;
* a collision.
* @aClearance how much the bounding box is expanded wrs to the minimum enclosing rectangle for the shape. /**
* @return the bounding box. * Function Collide()
*/ *
virtual const BOX2I BBox( int aClearance = 0 ) const = 0; * Computes a bounding box of the shape, with a margin of aClearance
* a collision.
/** * @aClearance how much the bounding box is expanded wrs to the minimum enclosing rectangle
* Function Centre() * for the shape.
* * @return the bounding box.
* Computes a center-of-mass of the shape */
* @return the center-of-mass point virtual const BOX2I BBox( int aClearance = 0 ) const = 0;
*/
virtual VECTOR2I Centre() const /**
{ * Function Centre()
return BBox( 0 ).Centre(); // if nothing better is available.... *
} * Computes a center-of-mass of the shape
* @return the center-of-mass point
private: */
///> type of our shape virtual VECTOR2I Centre() const
ShapeType m_type; {
return BBox( 0 ).Centre(); // if nothing better is available....
}
private:
///> type of our shape
SHAPE_TYPE m_type;
}; };
bool CollideShapes( const SHAPE* aA, const SHAPE* aB, int aClearance, bool aNeedMTV, VECTOR2I& aMTV ); bool CollideShapes( const SHAPE* aA, const SHAPE* aB, int aClearance,
bool aNeedMTV, VECTOR2I& aMTV );
#endif // __SHAPE_H #endif // __SHAPE_H
...@@ -31,12 +31,15 @@ class SHAPE_CIRCLE : public SHAPE ...@@ -31,12 +31,15 @@ class SHAPE_CIRCLE : public SHAPE
{ {
public: public:
SHAPE_CIRCLE() : SHAPE_CIRCLE() :
SHAPE( SH_CIRCLE ), m_radius( 0 ) {}; SHAPE( SH_CIRCLE ), m_radius( 0 )
{}
SHAPE_CIRCLE( const VECTOR2I& aCenter, int aRadius ) : SHAPE_CIRCLE( const VECTOR2I& aCenter, int aRadius ) :
SHAPE( SH_CIRCLE ), m_radius( aRadius ), m_center( aCenter ) {}; SHAPE( SH_CIRCLE ), m_radius( aRadius ), m_center( aCenter )
{}
~SHAPE_CIRCLE() {}; ~SHAPE_CIRCLE()
{}
const BOX2I BBox( int aClearance = 0 ) const const BOX2I BBox( int aClearance = 0 ) const
{ {
......
...@@ -36,16 +36,16 @@ const SHAPE* defaultShapeFunctor( const T aItem ) ...@@ -36,16 +36,16 @@ const SHAPE* defaultShapeFunctor( const T aItem )
template <class T, const SHAPE* (ShapeFunctor) (const T) = defaultShapeFunctor<T> > template <class T, const SHAPE* (ShapeFunctor) (const T) = defaultShapeFunctor<T> >
class SHAPE_INDEX_LIST class SHAPE_INDEX_LIST
{ {
struct ShapeEntry struct SHAPE_ENTRY
{ {
ShapeEntry( T aParent ) SHAPE_ENTRY( T aParent )
{ {
shape = ShapeFunctor( aParent ); shape = ShapeFunctor( aParent );
bbox = shape->BBox( 0 ); bbox = shape->BBox( 0 );
parent = aParent; parent = aParent;
} }
~ShapeEntry() ~SHAPE_ENTRY()
{ {
} }
...@@ -54,21 +54,24 @@ class SHAPE_INDEX_LIST ...@@ -54,21 +54,24 @@ class SHAPE_INDEX_LIST
BOX2I bbox; BOX2I bbox;
}; };
typedef std::vector<ShapeEntry> ShapeVec; typedef std::vector<SHAPE_ENTRY> SHAPE_VEC;
typedef typename std::vector<ShapeEntry>::iterator ShapeVecIter; typedef typename std::vector<SHAPE_ENTRY>::iterator SHAPE_VEC_ITER;
public: public:
// "Normal" iterator interface, for STL algorithms. // "Normal" iterator interface, for STL algorithms.
class iterator class iterator
{ {
public: public:
iterator() {}; iterator()
{}
iterator( ShapeVecIter aCurrent ) : iterator( SHAPE_VEC_ITER aCurrent ) :
m_current( aCurrent ) {}; m_current( aCurrent )
{}
iterator( const iterator& aB ) : iterator( const iterator& aB ) :
m_current( aB.m_current ) {}; m_current( aB.m_current )
{}
T operator*() const T operator*() const
{ {
...@@ -103,7 +106,7 @@ public: ...@@ -103,7 +106,7 @@ public:
} }
private: private:
ShapeVecIter m_current; SHAPE_VEC_ITER m_current;
}; };
// "Query" iterator, for iterating over a set of spatially matching shapes. // "Query" iterator, for iterating over a set of spatially matching shapes.
...@@ -114,7 +117,7 @@ public: ...@@ -114,7 +117,7 @@ public:
{ {
} }
query_iterator( ShapeVecIter aCurrent, ShapeVecIter aEnd, SHAPE* aShape, query_iterator( SHAPE_VEC_ITER aCurrent, SHAPE_VEC_ITER aEnd, SHAPE* aShape,
int aMinDistance, bool aExact ) : int aMinDistance, bool aExact ) :
m_end( aEnd ), m_end( aEnd ),
m_current( aCurrent ), m_current( aCurrent ),
...@@ -122,80 +125,80 @@ public: ...@@ -122,80 +125,80 @@ public:
m_minDistance( aMinDistance ), m_minDistance( aMinDistance ),
m_exact( aExact ) m_exact( aExact )
{ {
if( aShape ) if( aShape )
{ {
m_refBBox = aShape->BBox(); m_refBBox = aShape->BBox();
next(); next();
}
} }
}
query_iterator( const query_iterator& aB ) : query_iterator( const query_iterator& aB ) :
m_end( aB.m_end ), m_end( aB.m_end ),
m_current( aB.m_current ), m_current( aB.m_current ),
m_shape( aB.m_shape ), m_shape( aB.m_shape ),
m_minDistance( aB.m_minDistance ), m_minDistance( aB.m_minDistance ),
m_exact( aB.m_exact ), m_exact( aB.m_exact ),
m_refBBox( aB.m_refBBox ) m_refBBox( aB.m_refBBox )
{ {
} }
T operator*() const T operator*() const
{ {
return (*m_current).parent; return (*m_current).parent;
} }
query_iterator& operator++() query_iterator& operator++()
{ {
++m_current; ++m_current;
next(); next();
return *this; return *this;
} }
query_iterator& operator++( int aDummy ) query_iterator& operator++( int aDummy )
{ {
++m_current; ++m_current;
next(); next();
return *this; return *this;
} }
bool operator==( const query_iterator& aRhs ) const bool operator==( const query_iterator& aRhs ) const
{ {
return m_current == aRhs.m_current; return m_current == aRhs.m_current;
} }
bool operator!=( const query_iterator& aRhs ) const bool operator!=( const query_iterator& aRhs ) const
{ {
return m_current != aRhs.m_current; return m_current != aRhs.m_current;
} }
const query_iterator& operator=( const query_iterator& aRhs ) const query_iterator& operator=( const query_iterator& aRhs )
{ {
m_end = aRhs.m_end; m_end = aRhs.m_end;
m_current = aRhs.m_current; m_current = aRhs.m_current;
m_shape = aRhs.m_shape; m_shape = aRhs.m_shape;
m_minDistance = aRhs.m_minDistance; m_minDistance = aRhs.m_minDistance;
m_exact = aRhs.m_exact; m_exact = aRhs.m_exact;
m_refBBox = aRhs.m_refBBox; m_refBBox = aRhs.m_refBBox;
return *this; return *this;
} }
private: private:
void next() void next()
{
while( m_current != m_end )
{ {
while( m_current != m_end ) if( m_refBBox.Distance( m_current->bbox ) <= m_minDistance )
{ {
if( m_refBBox.Distance( m_current->bbox ) <= m_minDistance ) if( !m_exact || m_current->shape->Collide( m_shape, m_minDistance ) )
{ return;
if( !m_exact || m_current->shape->Collide( m_shape, m_minDistance ) )
return;
}
++m_current;
} }
++m_current;
} }
}
ShapeVecIter m_end; SHAPE_VEC_ITER m_end;
ShapeVecIter m_current; SHAPE_VEC_ITER m_current;
BOX2I m_refBBox; BOX2I m_refBBox;
bool m_exact; bool m_exact;
SHAPE* m_shape; SHAPE* m_shape;
...@@ -204,14 +207,14 @@ public: ...@@ -204,14 +207,14 @@ public:
void Add( T aItem ) void Add( T aItem )
{ {
ShapeEntry s( aItem ); SHAPE_ENTRY s( aItem );
m_shapes.push_back( s ); m_shapes.push_back( s );
} }
void Remove( const T aItem ) void Remove( const T aItem )
{ {
ShapeVecIter i; SHAPE_VEC_ITER i;
for( i = m_shapes.begin(); i != m_shapes.end(); ++i ) for( i = m_shapes.begin(); i != m_shapes.end(); ++i )
{ {
...@@ -233,7 +236,7 @@ public: ...@@ -233,7 +236,7 @@ public:
template <class Visitor> template <class Visitor>
int Query( const SHAPE* aShape, int aMinDistance, Visitor& aV, bool aExact = true ) // const int Query( const SHAPE* aShape, int aMinDistance, Visitor& aV, bool aExact = true ) // const
{ {
ShapeVecIter i; SHAPE_VEC_ITER i;
int n = 0; int n = 0;
VECTOR2I::extended_type minDistSq = (VECTOR2I::extended_type) aMinDistance * aMinDistance; VECTOR2I::extended_type minDistSq = (VECTOR2I::extended_type) aMinDistance * aMinDistance;
...@@ -282,7 +285,7 @@ public: ...@@ -282,7 +285,7 @@ public:
} }
private: private:
ShapeVec m_shapes; SHAPE_VEC m_shapes;
}; };
#endif #endif
This diff is collapsed.
...@@ -32,126 +32,130 @@ ...@@ -32,126 +32,130 @@
class SHAPE_RECT : public SHAPE class SHAPE_RECT : public SHAPE
{ {
public: public:
/** /**
* Constructor * Constructor
* Creates an empty (0-sized) rectangle * Creates an empty (0-sized) rectangle
*/ */
SHAPE_RECT() : SHAPE_RECT() :
SHAPE( SH_RECT ), m_w( 0 ), m_h( 0 ) {}; SHAPE( SH_RECT ), m_w( 0 ), m_h( 0 )
{}
/**
* Constructor /**
* Creates a rectangle defined by top-left corner (aX0, aY0), width aW and height aH. * Constructor
*/ * Creates a rectangle defined by top-left corner (aX0, aY0), width aW and height aH.
SHAPE_RECT( int aX0, int aY0, int aW, int aH ) : */
SHAPE( SH_RECT ), m_p0( aX0, aY0 ), m_w( aW ), m_h( aH ) {}; SHAPE_RECT( int aX0, int aY0, int aW, int aH ) :
SHAPE( SH_RECT ), m_p0( aX0, aY0 ), m_w( aW ), m_h( aH )
/** {}
* Constructor
* Creates a rectangle defined by top-left corner aP0, width aW and height aH. /**
*/ * Constructor
SHAPE_RECT( const VECTOR2I& aP0, int aW, int aH ) : * Creates a rectangle defined by top-left corner aP0, width aW and height aH.
SHAPE( SH_RECT ), m_p0( aP0 ), m_w( aW ), m_h( aH ) {}; */
SHAPE_RECT( const VECTOR2I& aP0, int aW, int aH ) :
/// @copydoc SHAPE::BBox() SHAPE( SH_RECT ), m_p0( aP0 ), m_w( aW ), m_h( aH )
const BOX2I BBox( int aClearance = 0 ) const {}
/// @copydoc SHAPE::BBox()
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 ) );
//printf("bb : %s\n",bbox.Format().c_str());
return bbox;
}
/**
* Function Diagonal()
*
* Returns length of the diagonal of the rectangle
* @return diagonal length
*/
int Diagonal() const
{
return VECTOR2I( m_w, m_h ).EuclideanNorm();
}
/// @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 ) );
//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( 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 ),
VECTOR2I( m_p0.x, m_p0.y ) };
for( int i = 0; i < 4; i++ )
{ {
BOX2I bbox( VECTOR2I( m_p0.x - aClearance, m_p0.y - aClearance ), SEG s( vts[i], vts[i + 1], i );
VECTOR2I( m_w + 2 * aClearance, m_h + 2 * aClearance ) );
//printf("bb : %s\n",bbox.Format().c_str());
return bbox;
}
/** if( s.Distance( aSeg ) <= aClearance )
* Function Diagonal()
*
* Returns length of the diagonal of the rectangle
* @return diagonal length
*/
int Diagonal() const
{
return VECTOR2I( m_w, m_h ).EuclideanNorm();
}
/// @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 ) );
//if( BBox( 0 ).SquaredDistance( r ) > aClearance * aClearance )
// return false;
if( BBox( 0 ).Contains( aSeg.a ) || BBox( 0 ).Contains( aSeg.b ) )
return true; return true;
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 ),
VECTOR2I( m_p0.x, m_p0.y ) };
for( int i = 0; i < 4; i++ )
{
SEG s( vts[i], vts[i + 1], i );
if( s.Distance( aSeg ) <= aClearance )
return true;
}
return false;
};
/**
* Function GetPosition()
*
* @return top-left corner of the rectangle
*/
const VECTOR2I& GetPosition() const
{
return m_p0;
} }
/** return false;
* Function GetSize() }
*
* @return size of the rectangle /**
*/ * Function GetPosition()
const VECTOR2I GetSize() const *
{ * @return top-left corner of the rectangle
return VECTOR2I( m_w, m_h ); */
} const VECTOR2I& GetPosition() const
{
/** return m_p0;
* Function GetWidth() }
*
* @return width of the rectangle /**
*/ * Function GetSize()
const int GetWidth() const *
{ * @return size of the rectangle
return m_w; */
} const VECTOR2I GetSize() const
{
/** return VECTOR2I( m_w, m_h );
* Function GetHeight() }
*
* @return height of the rectangle /**
*/ * Function GetWidth()
const int GetHeight() const *
{ * @return width of the rectangle
return m_h; */
} const int GetWidth() const
{
private: return m_w;
///> Top-left corner }
VECTOR2I m_p0;
/**
///> Width * Function GetHeight()
int m_w; *
* @return height of the rectangle
///> Height */
int m_h; const int GetHeight() const
}; {
return m_h;
}
private:
///> Top-left corner
VECTOR2I m_p0;
///> Width
int m_w;
///> Height
int m_h;
};
#endif // __SHAPE_RECT_H #endif // __SHAPE_RECT_H
...@@ -35,17 +35,17 @@ ...@@ -35,17 +35,17 @@
*/ */
template <typename T> template <typename T>
T rescale( T numerator, T value, T denominator ) T rescale( T aNumerator, T aValue, T aDenominator )
{ {
return numerator * value / denominator; return aNumerator * aValue / aDenominator;
} }
// explicit specializations for integer types, taking care of overflow. // explicit specializations for integer types, taking care of overflow.
template <> template <>
int rescale( int numerator, int value, int denominator ); int rescale( int aNumerator, int aValue, int aDenominator );
template <> template <>
int64_t rescale( int64_t numerator, int64_t value, int64_t denominator ); int64_t rescale( int64_t aNumerator, int64_t aValue, int64_t aDenominator );
#endif // __MATH_UTIL_H #endif // __MATH_UTIL_H
...@@ -55,7 +55,7 @@ template <class T> ...@@ -55,7 +55,7 @@ template <class T>
class MATRIX3x3; class MATRIX3x3;
template <class T> template <class T>
std::ostream& operator<<( std::ostream& stream, const MATRIX3x3<T>& matrix ); std::ostream& operator<<( std::ostream& aStream, const MATRIX3x3<T>& aMatrix );
template <class T> template <class T>
class MATRIX3x3 class MATRIX3x3
...@@ -92,7 +92,7 @@ public: ...@@ -92,7 +92,7 @@ public:
* *
* The diagonal components of the matrix are set to 1. * The diagonal components of the matrix are set to 1.
*/ */
void SetIdentity( void ); void SetIdentity();
/** /**
* @brief Set the translation components of the matrix. * @brief Set the translation components of the matrix.
...@@ -106,7 +106,7 @@ public: ...@@ -106,7 +106,7 @@ public:
* *
* @return is the translation (2D-vector). * @return is the translation (2D-vector).
*/ */
VECTOR2<T> GetTranslation( void ) const; VECTOR2<T> GetTranslation() const;
/** /**
* @brief Set the rotation components of the matrix. * @brief Set the rotation components of the matrix.
...@@ -129,14 +129,14 @@ public: ...@@ -129,14 +129,14 @@ public:
* *
* @return the scale factors, specified as 2D-vector. * @return the scale factors, specified as 2D-vector.
*/ */
VECTOR2<T> GetScale( void ) const; VECTOR2<T> GetScale() const;
/** /**
* @brief Compute the determinant of the matrix. * @brief Compute the determinant of the matrix.
* *
* @return the determinant value. * @return the determinant value.
*/ */
T Determinant( void ) const; T Determinant() const;
/** /**
* @brief Determine the inverse of the matrix. * @brief Determine the inverse of the matrix.
...@@ -148,33 +148,33 @@ public: ...@@ -148,33 +148,33 @@ public:
* *
* @return the inverse matrix. * @return the inverse matrix.
*/ */
MATRIX3x3 Inverse( void ) const; MATRIX3x3 Inverse() const;
/** /**
* @brief Get the transpose of the matrix. * @brief Get the transpose of the matrix.
* *
* @return the transpose matrix. * @return the transpose matrix.
*/ */
MATRIX3x3 Transpose( void ) const; MATRIX3x3 Transpose() const;
/** /**
* @brief Output to a stream. * @brief Output to a stream.
*/ */
friend std::ostream& operator<<<T>( std::ostream& stream, const MATRIX3x3<T>& matrix ); friend std::ostream& operator<<<T>( std::ostream& aStream, const MATRIX3x3<T>& aMatrix );
}; };
// Operators // Operators
//! @brief Matrix multiplication //! @brief Matrix multiplication
template <class T> MATRIX3x3<T> const operator*( MATRIX3x3<T> const& a, MATRIX3x3<T> const& b ); template <class T> MATRIX3x3<T> const operator*( MATRIX3x3<T> const& aA, MATRIX3x3<T> const& aB );
//! @brief Multiplication with a 2D vector, the 3rd z-component is assumed to be 1 //! @brief Multiplication with a 2D vector, the 3rd z-component is assumed to be 1
template <class T> VECTOR2<T> const operator*( MATRIX3x3<T> const& a, VECTOR2<T> const& b ); template <class T> VECTOR2<T> const operator*( MATRIX3x3<T> const& aA, VECTOR2<T> const& aB );
//! @brief Multiplication with a scalar //! @brief Multiplication with a scalar
template <class T, class S> MATRIX3x3<T> const operator*( MATRIX3x3<T> const& a, T scalar ); template <class T, class S> MATRIX3x3<T> const operator*( MATRIX3x3<T> const& aA, T aScalar );
template <class T, class S> MATRIX3x3<T> const operator*( T scalar, MATRIX3x3<T> const& matrix ); template <class T, class S> MATRIX3x3<T> const operator*( T aScalar, MATRIX3x3<T> const& aMatrix );
// ---------------------- // ----------------------
// --- Implementation --- // --- Implementation ---
...@@ -235,11 +235,12 @@ void MATRIX3x3<T>::SetTranslation( VECTOR2<T> aTranslation ) ...@@ -235,11 +235,12 @@ void MATRIX3x3<T>::SetTranslation( VECTOR2<T> aTranslation )
template <class T> template <class T>
VECTOR2<T> MATRIX3x3<T>::GetTranslation( void ) const VECTOR2<T> MATRIX3x3<T>::GetTranslation() const
{ {
VECTOR2<T> result; VECTOR2<T> result;
result.x = m_data[0][2]; result.x = m_data[0][2];
result.y = m_data[1][2]; result.y = m_data[1][2];
return result; return result;
} }
...@@ -265,15 +266,16 @@ void MATRIX3x3<T>::SetScale( VECTOR2<T> aScale ) ...@@ -265,15 +266,16 @@ void MATRIX3x3<T>::SetScale( VECTOR2<T> aScale )
template <class T> template <class T>
VECTOR2<T> MATRIX3x3<T>::GetScale( void ) const VECTOR2<T> MATRIX3x3<T>::GetScale() const
{ {
VECTOR2<T> result( m_data[0][0], m_data[1][1] ); VECTOR2<T> result( m_data[0][0], m_data[1][1] );
return result; return result;
} }
template <class T> template <class T>
MATRIX3x3<T> const operator*( MATRIX3x3<T> const& a, MATRIX3x3<T> const& b ) MATRIX3x3<T> const operator*( MATRIX3x3<T> const& aA, MATRIX3x3<T> const& aB )
{ {
MATRIX3x3<T> result; MATRIX3x3<T> result;
...@@ -281,8 +283,9 @@ MATRIX3x3<T> const operator*( MATRIX3x3<T> const& a, MATRIX3x3<T> const& b ) ...@@ -281,8 +283,9 @@ MATRIX3x3<T> const operator*( MATRIX3x3<T> const& a, MATRIX3x3<T> const& b )
{ {
for( int j = 0; j < 3; j++ ) for( int j = 0; j < 3; j++ )
{ {
result.m_data[i][j] = a.m_data[i][0] * b.m_data[0][j] + a.m_data[i][1] * b.m_data[1][j] result.m_data[i][j] = aA.m_data[i][0] * aB.m_data[0][j] +
+ a.m_data[i][2] * b.m_data[2][j]; aA.m_data[i][1] * aB.m_data[1][j] +
aA.m_data[i][2] * aB.m_data[2][j];
} }
} }
...@@ -291,21 +294,20 @@ MATRIX3x3<T> const operator*( MATRIX3x3<T> const& a, MATRIX3x3<T> const& b ) ...@@ -291,21 +294,20 @@ MATRIX3x3<T> const operator*( MATRIX3x3<T> const& a, MATRIX3x3<T> const& b )
template <class T> template <class T>
VECTOR2<T> const operator*( MATRIX3x3<T> const& matrix, VECTOR2<T> const operator*( MATRIX3x3<T> const& aMatrix, VECTOR2<T> const& aVector )
VECTOR2<T> const& vector )
{ {
VECTOR2<T> result( 0, 0 ); VECTOR2<T> result( 0, 0 );
result.x = matrix.m_data[0][0] * vector.x + matrix.m_data[0][1] * vector.y result.x = aMatrix.m_data[0][0] * aVector.x + aMatrix.m_data[0][1] * aVector.y
+ matrix.m_data[0][2]; + aMatrix.m_data[0][2];
result.y = matrix.m_data[1][0] * vector.x + matrix.m_data[1][1] * vector.y result.y = aMatrix.m_data[1][0] * aVector.x + aMatrix.m_data[1][1] * aVector.y
+ matrix.m_data[1][2]; + aMatrix.m_data[1][2];
return result; return result;
} }
template <class T> template <class T>
T MATRIX3x3<T>::Determinant( void ) const T MATRIX3x3<T>::Determinant() const
{ {
return m_data[0][0] * ( m_data[1][1] * m_data[2][2] - m_data[1][2] * m_data[2][1] ) return m_data[0][0] * ( m_data[1][1] * m_data[2][2] - m_data[1][2] * m_data[2][1] )
- m_data[0][1] * ( m_data[1][0] * m_data[2][2] - m_data[1][2] * m_data[2][0] ) - m_data[0][1] * ( m_data[1][0] * m_data[2][2] - m_data[1][2] * m_data[2][0] )
...@@ -314,7 +316,7 @@ T MATRIX3x3<T>::Determinant( void ) const ...@@ -314,7 +316,7 @@ T MATRIX3x3<T>::Determinant( void ) const
template <class T, class S> template <class T, class S>
MATRIX3x3<T> const operator*( MATRIX3x3<T> const& matrix, S scalar ) MATRIX3x3<T> const operator*( MATRIX3x3<T> const& aMatrix, S aScalar )
{ {
MATRIX3x3<T> result; MATRIX3x3<T> result;
...@@ -322,7 +324,7 @@ MATRIX3x3<T> const operator*( MATRIX3x3<T> const& matrix, S scalar ) ...@@ -322,7 +324,7 @@ MATRIX3x3<T> const operator*( MATRIX3x3<T> const& matrix, S scalar )
{ {
for( int j = 0; j < 3; j++ ) for( int j = 0; j < 3; j++ )
{ {
result.m_data[i][j] = matrix.m_data[i][j] * scalar; result.m_data[i][j] = aMatrix.m_data[i][j] * aScalar;
} }
} }
...@@ -331,9 +333,9 @@ MATRIX3x3<T> const operator*( MATRIX3x3<T> const& matrix, S scalar ) ...@@ -331,9 +333,9 @@ MATRIX3x3<T> const operator*( MATRIX3x3<T> const& matrix, S scalar )
template <class T, class S> template <class T, class S>
MATRIX3x3<T> const operator*( S scalar, MATRIX3x3<T> const& matrix ) MATRIX3x3<T> const operator*( S aScalar, MATRIX3x3<T> const& aMatrix )
{ {
return matrix * scalar; return aMatrix * aScalar;
} }
......
...@@ -62,7 +62,7 @@ struct VECTOR2_TRAITS<int> ...@@ -62,7 +62,7 @@ struct VECTOR2_TRAITS<int>
template <class T> template <class T>
class VECTOR2; class VECTOR2;
template <class T> template <class T>
std::ostream& operator<<( std::ostream& stream, const VECTOR2<T>& vector ); std::ostream& operator<<( std::ostream& aStream, const VECTOR2<T>& aVector );
/** /**
* Class VECTOR2 * Class VECTOR2
...@@ -351,6 +351,8 @@ VECTOR2<T>& VECTOR2<T>::operator-=( const T& aScalar ) ...@@ -351,6 +351,8 @@ VECTOR2<T>& VECTOR2<T>::operator-=( const T& aScalar )
y -= aScalar; y -= aScalar;
return *this; return *this;
} }
template <class T> template <class T>
VECTOR2<T> VECTOR2<T>::Rotate( double aAngle ) const VECTOR2<T> VECTOR2<T>::Rotate( double aAngle ) const
{ {
......
...@@ -108,9 +108,9 @@ public: ...@@ -108,9 +108,9 @@ public:
* Yield with a value - passes a value of given type to the caller. * Yield with a value - passes a value of given type to the caller.
* Useful for implementing generator objects. * Useful for implementing generator objects.
*/ */
void Yield( ReturnType& retVal ) void Yield( ReturnType& aRetVal )
{ {
m_retVal = retVal; m_retVal = aRetVal;
boost::context::jump_fcontext( m_self, m_saved, 0 ); boost::context::jump_fcontext( m_self, m_saved, 0 );
} }
...@@ -130,7 +130,7 @@ public: ...@@ -130,7 +130,7 @@ public:
* @return true, if the coroutine has yielded and false if it has finished its * @return true, if the coroutine has yielded and false if it has finished its
* execution (returned). * execution (returned).
*/ */
bool Call( ArgType args ) bool Call( ArgType aArgs )
{ {
// fixme: Clean up stack stuff. Add a guard // fixme: Clean up stack stuff. Add a guard
m_stack = malloc( c_defaultStackSize ); m_stack = malloc( c_defaultStackSize );
...@@ -138,7 +138,7 @@ public: ...@@ -138,7 +138,7 @@ public:
// align to 16 bytes // align to 16 bytes
void* sp = (void*) ( ( ( (ptrdiff_t) m_stack ) + m_stackSize - 0xf ) & ( ~0x0f ) ); void* sp = (void*) ( ( ( (ptrdiff_t) m_stack ) + m_stackSize - 0xf ) & ( ~0x0f ) );
m_args = &args; m_args = &aArgs;
m_self = boost::context::make_fcontext( sp, m_stackSize, callerStub ); m_self = boost::context::make_fcontext( sp, m_stackSize, callerStub );
m_saved = new boost::context::fcontext_t(); m_saved = new boost::context::fcontext_t();
...@@ -186,10 +186,10 @@ private: ...@@ -186,10 +186,10 @@ 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 */ /* real entry point of the coroutine */
static void callerStub( intptr_t data ) static void callerStub( intptr_t aData )
{ {
// get pointer to self // get pointer to self
COROUTINE<ReturnType, ArgType>* cor = reinterpret_cast<COROUTINE<ReturnType, ArgType>*>( data ); COROUTINE<ReturnType, ArgType>* cor = reinterpret_cast<COROUTINE<ReturnType, ArgType>*>( aData );
// call the coroutine method // call the coroutine method
cor->m_retVal = cor->m_func( *cor->m_args ); cor->m_retVal = cor->m_func( *cor->m_args );
......
...@@ -45,17 +45,17 @@ public: ...@@ -45,17 +45,17 @@ public:
} }
template <class T> template <class T>
DELEGATE( T* object, ReturnType(T::* ptr)( Arg ) ) DELEGATE( T* aObject, ReturnType(T::* aPtr)( Arg ) )
{ {
m_ptr = reinterpret_cast<MemberPointer>( ptr ); m_ptr = reinterpret_cast<MemberPointer>( aPtr );
m_object = reinterpret_cast<void*>( object ); m_object = reinterpret_cast<void*>( aObject );
}; };
ReturnType operator()( Arg a ) const ReturnType operator()( Arg aA ) const
{ {
DELEGATE<ReturnType, Arg>* casted = reinterpret_cast<DELEGATE<ReturnType, Arg>*>( m_object ); DELEGATE<ReturnType, Arg>* casted = reinterpret_cast<DELEGATE<ReturnType, Arg>*>( m_object );
return (casted->*m_ptr)( a ); return (casted->*m_ptr)( aA );
} }
private: private:
...@@ -79,10 +79,10 @@ public: ...@@ -79,10 +79,10 @@ public:
} }
template <class T> template <class T>
DELEGATE0( T* object, ReturnType(T::* ptr)() ) DELEGATE0( T* aObject, ReturnType(T::* aPtr)() )
{ {
m_ptr = reinterpret_cast<MemberPointer>( ptr ); m_ptr = reinterpret_cast<MemberPointer>( aPtr );
m_object = reinterpret_cast<void*>( object ); m_object = reinterpret_cast<void*>( aObject );
}; };
......
...@@ -45,7 +45,7 @@ ...@@ -45,7 +45,7 @@
class TOOL_ACTION class TOOL_ACTION
{ {
public: public:
TOOL_ACTION( const std::string& aName, TOOL_ActionScope aScope = AS_CONTEXT, TOOL_ACTION( const std::string& aName, TOOL_ACTION_SCOPE aScope = AS_CONTEXT,
int aDefaultHotKey = 0, const std::string& aMenuItem = std::string( "" ), int aDefaultHotKey = 0, const std::string& aMenuItem = std::string( "" ),
const std::string& aMenuDesc = std::string( "" ) ) : const std::string& aMenuDesc = std::string( "" ) ) :
m_name( aName ), m_scope( aScope ), m_defaultHotKey( aDefaultHotKey ), m_name( aName ), m_scope( aScope ), m_defaultHotKey( aDefaultHotKey ),
...@@ -148,7 +148,7 @@ public: ...@@ -148,7 +148,7 @@ public:
*/ */
TOOL_EVENT MakeEvent() const TOOL_EVENT MakeEvent() const
{ {
return TOOL_EVENT( TC_Command, TA_Action, m_name, m_scope ); return TOOL_EVENT( TC_COMMAND, TA_ACTION, m_name, m_scope );
} }
const std::string& GetMenuItem() const const std::string& GetMenuItem() const
...@@ -190,7 +190,7 @@ private: ...@@ -190,7 +190,7 @@ private:
std::string m_name; std::string m_name;
/// Scope of the action (ie. the event that is issued after activation). /// Scope of the action (ie. the event that is issued after activation).
TOOL_ActionScope m_scope; TOOL_ACTION_SCOPE m_scope;
/// Default hot key that activates the action. /// Default hot key that activates the action.
const int m_defaultHotKey; const int m_defaultHotKey;
......
...@@ -40,13 +40,13 @@ class VIEW; ...@@ -40,13 +40,13 @@ class VIEW;
class VIEW_CONTROLS; class VIEW_CONTROLS;
}; };
enum TOOL_Type enum TOOL_TYPE
{ {
///> Tool that interacts with the user ///> Tool that interacts with the user
TOOL_Interactive = 0x01, INTERACTIVE = 0x01,
///> Tool that runs in the background without any user intervention ///> Tool that runs in the background without any user intervention
TOOL_Batch = 0x02 BATCH = 0x02
}; };
/// Unique identifier for tools /// Unique identifier for tools
...@@ -62,7 +62,7 @@ typedef DELEGATE<int, TOOL_EVENT&> TOOL_STATE_FUNC; ...@@ -62,7 +62,7 @@ typedef DELEGATE<int, TOOL_EVENT&> TOOL_STATE_FUNC;
class TOOL_BASE class TOOL_BASE
{ {
public: public:
TOOL_BASE( TOOL_Type aType, TOOL_ID aId, const std::string& aName = std::string( "" ) ) : TOOL_BASE( TOOL_TYPE aType, TOOL_ID aId, const std::string& aName = std::string( "" ) ) :
m_type( aType ), m_type( aType ),
m_toolId( aId ), m_toolId( aId ),
m_toolName( aName ), m_toolName( aName ),
...@@ -75,7 +75,7 @@ public: ...@@ -75,7 +75,7 @@ public:
* Returns the type of the tool. * Returns the type of the tool.
* @return The type of the tool. * @return The type of the tool.
*/ */
TOOL_Type GetType() const TOOL_TYPE GetType() const
{ {
return m_type; return m_type;
} }
...@@ -158,7 +158,7 @@ protected: ...@@ -158,7 +158,7 @@ protected:
* Returns the model object if it matches the requested type. * Returns the model object if it matches the requested type.
*/ */
template <typename T> template <typename T>
T* getModel( KICAD_T modelType ) const T* getModel( KICAD_T aModelType ) const
{ {
EDA_ITEM* m = getModelInt(); EDA_ITEM* m = getModelInt();
...@@ -166,7 +166,7 @@ protected: ...@@ -166,7 +166,7 @@ protected:
} }
///> Stores the type of the tool. ///> Stores the type of the tool.
TOOL_Type m_type; TOOL_TYPE m_type;
///> Unique identifier for the tool, assigned by a TOOL_MANAGER instance. ///> Unique identifier for the tool, assigned by a TOOL_MANAGER instance.
TOOL_ID m_toolId; TOOL_ID m_toolId;
......
...@@ -32,7 +32,8 @@ ...@@ -32,7 +32,8 @@
class TOOL_MANAGER; class TOOL_MANAGER;
class PCB_BASE_FRAME; class PCB_BASE_FRAME;
namespace KIGFX { namespace KIGFX
{
class VIEW; class VIEW;
}; };
...@@ -102,25 +103,25 @@ private: ...@@ -102,25 +103,25 @@ private:
int mods = 0; int mods = 0;
if( aState->ControlDown() ) if( aState->ControlDown() )
mods |= MD_ModCtrl; mods |= MD_CTRL;
if( aState->AltDown() ) if( aState->AltDown() )
mods |= MD_ModAlt; mods |= MD_ALT;
if( aState->ShiftDown() ) if( aState->ShiftDown() )
mods |= MD_ModShift; mods |= MD_SHIFT;
return mods; return mods;
} }
///> Stores all the informations regarding a mouse button state. ///> Stores all the informations regarding a mouse button state.
struct ButtonState; struct BUTTON_STATE;
///> The last mouse cursor position (in world coordinates). ///> The last mouse cursor position (in world coordinates).
VECTOR2D m_lastMousePos; VECTOR2D m_lastMousePos;
///> State of mouse buttons. ///> State of mouse buttons.
std::vector<ButtonState*> m_buttons; std::vector<BUTTON_STATE*> m_buttons;
///> Returns the instance of VIEW, used by the application. ///> Returns the instance of VIEW, used by the application.
KIGFX::VIEW* getView(); KIGFX::VIEW* getView();
......
This diff is collapsed.
...@@ -83,7 +83,7 @@ public: ...@@ -83,7 +83,7 @@ public:
*/ */
template <class T> template <class T>
void Go( int (T::* aStateFunc)( TOOL_EVENT& ), void Go( int (T::* aStateFunc)( TOOL_EVENT& ),
const TOOL_EVENT_LIST& aConditions = TOOL_EVENT( TC_Any, TA_Any ) ); const TOOL_EVENT_LIST& aConditions = TOOL_EVENT( TC_ANY, TA_ANY ) );
/** /**
* Function Wait() * Function Wait()
...@@ -91,7 +91,7 @@ public: ...@@ -91,7 +91,7 @@ public:
* Suspends execution of the tool until an event specified in aEventList arrives. * Suspends execution of the tool until an event specified in aEventList arrives.
* No parameters means waiting for any event. * No parameters means waiting for any event.
*/ */
OPT_TOOL_EVENT Wait( const TOOL_EVENT_LIST& aEventList = TOOL_EVENT (TC_Any, TA_Any) ); OPT_TOOL_EVENT Wait( const TOOL_EVENT_LIST& aEventList = TOOL_EVENT( TC_ANY, TA_ANY ) );
/** functions below are not yet implemented - their interface may change */ /** functions below are not yet implemented - their interface may change */
/*template <class Parameters, class ReturnValue> /*template <class Parameters, class ReturnValue>
...@@ -111,10 +111,10 @@ protected: ...@@ -111,10 +111,10 @@ protected:
const TOOL_EVENT evCommand( int aCommandId = -1 ); const TOOL_EVENT evCommand( int aCommandId = -1 );
const TOOL_EVENT evCommand( std::string aCommandStr = "" ); const TOOL_EVENT evCommand( std::string aCommandStr = "" );
const TOOL_EVENT evMotion(); const TOOL_EVENT evMotion();
const TOOL_EVENT evClick( int aButton = MB_Any ); const TOOL_EVENT evClick( int aButton = MB_ANY );
const TOOL_EVENT evDrag( int aButton = MB_Any ); const TOOL_EVENT evDrag( int aButton = MB_ANY );
const TOOL_EVENT evButtonUp( int aButton = MB_Any ); const TOOL_EVENT evButtonUp( int aButton = MB_ANY );
const TOOL_EVENT evButtonDown(int aButton = MB_Any ); const TOOL_EVENT evButtonDown(int aButton = MB_ANY );
private: private:
void goInternal( TOOL_STATE_FUNC& aState, const TOOL_EVENT_LIST& aConditions ); void goInternal( TOOL_STATE_FUNC& aState, const TOOL_EVENT_LIST& aConditions );
...@@ -123,7 +123,7 @@ private: ...@@ -123,7 +123,7 @@ private:
// hide TOOL_MANAGER implementation // hide TOOL_MANAGER implementation
template <class T> template <class T>
void TOOL_INTERACTIVE::Go( int (T::* aStateFunc)( TOOL_EVENT& ), void TOOL_INTERACTIVE::Go( int (T::* aStateFunc)( TOOL_EVENT& ),
const TOOL_EVENT_LIST& aConditions ) const TOOL_EVENT_LIST& aConditions )
{ {
TOOL_STATE_FUNC sptr( static_cast<T*>( this ), aStateFunc ); TOOL_STATE_FUNC sptr( static_cast<T*>( this ), aStateFunc );
......
...@@ -60,7 +60,7 @@ class VIEW ...@@ -60,7 +60,7 @@ class VIEW
public: public:
friend class VIEW_ITEM; friend class VIEW_ITEM;
typedef std::pair<VIEW_ITEM*, int> LayerItemPair; typedef std::pair<VIEW_ITEM*, int> LAYER_ITEM_PAIR;
/** /**
* Constructor. * Constructor.
...@@ -94,7 +94,7 @@ public: ...@@ -94,7 +94,7 @@ public:
* first). * first).
* @return Number of found items. * @return Number of found items.
*/ */
int Query( const BOX2I& aRect, std::vector<LayerItemPair>& aResult ); int Query( const BOX2I& aRect, std::vector<LAYER_ITEM_PAIR>& aResult );
/** /**
* Function SetRequired() * Function SetRequired()
...@@ -131,7 +131,10 @@ public: ...@@ -131,7 +131,10 @@ public:
* Returns the GAL this view is using to draw graphical primitives. * Returns the GAL this view is using to draw graphical primitives.
* @return Pointer to the currently used GAL instance. * @return Pointer to the currently used GAL instance.
*/ */
GAL* GetGAL() const { return m_gal; } GAL* GetGAL() const
{
return m_gal;
}
/** /**
* Function SetPainter() * Function SetPainter()
...@@ -144,7 +147,10 @@ public: ...@@ -144,7 +147,10 @@ public:
* Returns the painter object used by the view for drawing VIEW_ITEMS. * Returns the painter object used by the view for drawing VIEW_ITEMS.
* @return Pointer to the currently used Painter instance. * @return Pointer to the currently used Painter instance.
*/ */
PAINTER* GetPainter() const { return m_painter; }; PAINTER* GetPainter() const
{
return m_painter;
}
/** /**
* Function SetViewport() * Function SetViewport()
...@@ -189,7 +195,10 @@ public: ...@@ -189,7 +195,10 @@ public:
* Function GetScale() * Function GetScale()
* @return Current scalefactor of this VIEW * @return Current scalefactor of this VIEW
*/ */
double GetScale() const { return m_scale; } double GetScale() const
{
return m_scale;
}
/** /**
* Function SetCenter() * Function SetCenter()
...@@ -204,7 +213,10 @@ public: ...@@ -204,7 +213,10 @@ public:
* Returns the center point of this VIEW (in world space coordinates) * Returns the center point of this VIEW (in world space coordinates)
* @return center point of the view * @return center point of the view
*/ */
const VECTOR2D& GetCenter() const { return m_center; } const VECTOR2D& GetCenter() const
{
return m_center;
}
/** /**
* Function ToWorld() * Function ToWorld()
...@@ -291,7 +303,7 @@ public: ...@@ -291,7 +303,7 @@ public:
* @param aLayer is the layer. * @param aLayer is the layer.
* @param aTarget is the rendering target. * @param aTarget is the rendering target.
*/ */
inline void SetLayerTarget( int aLayer, RenderTarget aTarget ) inline void SetLayerTarget( int aLayer, RENDER_TARGET aTarget )
{ {
m_layers[aLayer].target = aTarget; m_layers[aLayer].target = aTarget;
} }
...@@ -410,7 +422,10 @@ public: ...@@ -410,7 +422,10 @@ public:
* Tells if the VIEW is dynamic (ie. can be changed, for example displaying PCBs in a window) * 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). * or static (that cannot be modified, eg. displaying image/PDF).
*/ */
bool IsDynamic() const { return m_dynamic; } bool IsDynamic() const
{
return m_dynamic;
}
/** /**
* Function IsDirty() * Function IsDirty()
...@@ -488,15 +503,15 @@ private: ...@@ -488,15 +503,15 @@ private:
VIEW_RTREE* items; ///* R-tree indexing all items on this layer. VIEW_RTREE* items; ///* R-tree indexing all items on this layer.
int renderingOrder; ///* rendering order of this layer int renderingOrder; ///* rendering order of this layer
int id; ///* layer ID int id; ///* layer ID
RenderTarget target; ///* where the layer should be rendered RENDER_TARGET target; ///* where the layer should be rendered
std::set<int> requiredLayers; ///* layers that are required to be enabled to show the layer std::set<int> requiredLayers; ///* layers that have to be enabled to show the layer
}; };
// Convenience typedefs // Convenience typedefs
typedef boost::unordered_map<int, VIEW_LAYER> LayerMap; typedef boost::unordered_map<int, VIEW_LAYER> LAYER_MAP;
typedef LayerMap::iterator LayerMapIter; typedef LAYER_MAP::iterator LAYER_MAP_ITER;
typedef std::vector<VIEW_LAYER*> LayerOrder; typedef std::vector<VIEW_LAYER*> LAYER_ORDER;
typedef std::vector<VIEW_LAYER*>::iterator LayerOrderIter; typedef std::vector<VIEW_LAYER*>::iterator LAYER_ORDER_ITER;
// Function objects that need to access VIEW/VIEW_ITEM private/protected members // Function objects that need to access VIEW/VIEW_ITEM private/protected members
struct clearLayerCache; struct clearLayerCache;
...@@ -573,9 +588,9 @@ private: ...@@ -573,9 +588,9 @@ private:
void updateLayers( VIEW_ITEM* aItem ); void updateLayers( VIEW_ITEM* aItem );
/// Determines rendering order of layers. Used in display order sorting function. /// Determines rendering order of layers. Used in display order sorting function.
static bool compareRenderingOrder( VIEW_LAYER* i, VIEW_LAYER* j ) static bool compareRenderingOrder( VIEW_LAYER* aI, VIEW_LAYER* aJ )
{ {
return i->renderingOrder > j->renderingOrder; return aI->renderingOrder > aJ->renderingOrder;
} }
/// Checks if every layer required by the aLayerId layer is enabled. /// Checks if every layer required by the aLayerId layer is enabled.
...@@ -585,10 +600,10 @@ private: ...@@ -585,10 +600,10 @@ private:
bool m_enableOrderModifier; bool m_enableOrderModifier;
/// Contains set of possible displayed layers and its properties /// Contains set of possible displayed layers and its properties
LayerMap m_layers; LAYER_MAP m_layers;
/// Sorted list of pointers to members of m_layers /// Sorted list of pointers to members of m_layers
LayerOrder m_orderedLayers; LAYER_ORDER m_orderedLayers;
/// Stores set of layers that are displayed on the top /// Stores set of layers that are displayed on the top
std::set<unsigned int> m_topLayers; std::set<unsigned int> m_topLayers;
......
...@@ -48,8 +48,11 @@ class VIEW_CONTROLS ...@@ -48,8 +48,11 @@ class VIEW_CONTROLS
public: public:
VIEW_CONTROLS( VIEW* aView ) : m_view( aView ), m_forceCursorPosition( false ), VIEW_CONTROLS( VIEW* aView ) : m_view( aView ), m_forceCursorPosition( false ),
m_snappingEnabled( false ), m_grabMouse( false ), m_autoPanEnabled( false ), m_snappingEnabled( false ), m_grabMouse( false ), m_autoPanEnabled( false ),
m_autoPanMargin( 0.1 ), m_autoPanSpeed( 0.15 ) {}; m_autoPanMargin( 0.1 ), m_autoPanSpeed( 0.15 )
virtual ~VIEW_CONTROLS() {}; {}
virtual ~VIEW_CONTROLS()
{}
/** /**
* Function SetSnapping() * Function SetSnapping()
...@@ -134,6 +137,11 @@ public: ...@@ -134,6 +137,11 @@ public:
m_forceCursorPosition = aEnabled; m_forceCursorPosition = aEnabled;
} }
/**
* Function ShowCursor()
* Enables or disables display of cursor.
* @param aEnabled decides if the cursor should be shown.
*/
virtual void ShowCursor( bool aEnabled ); virtual void ShowCursor( bool aEnabled );
protected: protected:
......
...@@ -164,17 +164,32 @@ public: ...@@ -164,17 +164,32 @@ public:
* *
* @param aFlags determines the way in which items will be updated. * @param aFlags determines the way in which items will be updated.
*/ */
virtual void ItemsViewUpdate( VIEW_ITEM::ViewUpdateFlags aFlags ); virtual void ItemsViewUpdate( VIEW_ITEM::VIEW_UPDATE_FLAGS aFlags );
protected: protected:
/// These functions cannot be used with VIEW_GROUP as they are intended only to work with /// These functions cannot be used with VIEW_GROUP as they are intended only to work with
/// singular VIEW_ITEMs (there is only one-to-one relation between item/layer combination and /// singular VIEW_ITEMs (there is only one-to-one relation between item/layer combination and
/// its group). /// its group).
int getGroup( int aLayer ) const { return -1; }; int getGroup( int aLayer ) const
std::vector<int> getAllGroups() const { return std::vector<int>(); }; {
void setGroup( int aLayer, int aGroup ) {}; return -1;
void deleteGroups() {}; }
bool storesGroups() const { return false; };
std::vector<int> getAllGroups() const
{
return std::vector<int>();
}
void setGroup( int aLayer, int aGroup )
{}
void deleteGroups()
{}
bool storesGroups() const
{
return false;
}
/// Layer on which the group is drawn /// Layer on which the group is drawn
int m_layer; int m_layer;
......
...@@ -155,14 +155,14 @@ class VIEW_ITEM ...@@ -155,14 +155,14 @@ class VIEW_ITEM
{ {
public: public:
/** /**
* Enum ViewUpdateFlags. * Enum VIEW_UPDATE_FLAGS.
* Defines the how severely the shape/appearance of the item has been changed: * Defines the how severely the shape/appearance of the item has been changed:
* - APPEARANCE: shape or layer set of the item have not been affected, * - APPEARANCE: shape or layer set of the item have not been affected,
* only colors or visibility. * only colors or visibility.
* - GEOMETRY: shape or layer set of the item have changed, VIEW may need to reindex it. * - GEOMETRY: shape or layer set of the item have changed, VIEW may need to reindex it.
* - ALL: all flags above */ * - ALL: all flags above */
enum ViewUpdateFlags { enum VIEW_UPDATE_FLAGS {
APPEARANCE = 0x01, /// Visibility flag has changed APPEARANCE = 0x01, /// Visibility flag has changed
COLOR = 0x02, /// Color has changed COLOR = 0x02, /// Color has changed
GEOMETRY = 0x04, /// Position or shape has changed GEOMETRY = 0x04, /// Position or shape has changed
...@@ -212,7 +212,8 @@ public: ...@@ -212,7 +212,8 @@ public:
* @param aLayer: current drawing layer * @param aLayer: current drawing layer
* @param aGal: pointer to the GAL device we are drawing on * @param aGal: pointer to the GAL device we are drawing on
*/ */
virtual void ViewDraw( int aLayer, GAL* aGal ) const {}; virtual void ViewDraw( int aLayer, GAL* aGal ) const
{}
/** /**
* Function ViewGetLayers() * Function ViewGetLayers()
......
This diff is collapsed.
...@@ -82,7 +82,7 @@ public: ...@@ -82,7 +82,7 @@ public:
*/ */
DIRECTION_45( const SEG& aSeg ) DIRECTION_45( const SEG& aSeg )
{ {
construct( aSeg.b - aSeg.a ); construct( aSeg.B - aSeg.A );
} }
/** /**
......
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
...@@ -44,8 +44,8 @@ public: ...@@ -44,8 +44,8 @@ public:
{ {
m_net = aNet; m_net = aNet;
m_shape.Clear(); m_shape.Clear();
m_shape.Append( aSeg.a ); m_shape.Append( aSeg.A );
m_shape.Append( aSeg.b ); m_shape.Append( aSeg.B );
}; };
PNS_SEGMENT( const PNS_LINE& aParentLine, const SEG& aSeg ) : PNS_SEGMENT( const PNS_LINE& aParentLine, const SEG& aSeg ) :
...@@ -55,8 +55,8 @@ public: ...@@ -55,8 +55,8 @@ public:
m_layers = aParentLine.GetLayers(); m_layers = aParentLine.GetLayers();
m_width = aParentLine.GetWidth(); m_width = aParentLine.GetWidth();
m_shape.Clear(); m_shape.Clear();
m_shape.Append( aSeg.a ); m_shape.Append( aSeg.A );
m_shape.Append( aSeg.b ); m_shape.Append( aSeg.B );
}; };
......
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment