diff --git a/common/gal/opengl/opengl_compositor.cpp b/common/gal/opengl/opengl_compositor.cpp index 9ed87f29c1..8610ca4a4a 100644 --- a/common/gal/opengl/opengl_compositor.cpp +++ b/common/gal/opengl/opengl_compositor.cpp @@ -39,6 +39,7 @@ #include #include #include +#include using namespace KIGFX; @@ -171,10 +172,9 @@ unsigned int OPENGL_COMPOSITOR::CreateBuffer( VECTOR2U aDimensions ) if( (int) usedBuffers() >= maxBuffers ) { - throw std::runtime_error( - "Cannot create more framebuffers. OpenGL rendering " - "backend requires at least 3 framebuffers. You may try to update/change " - "your graphic drivers." ); + throw std::runtime_error( "Cannot create more framebuffers. OpenGL rendering backend " + "requires at least 3 framebuffers. You may try to update/change " + "your graphic drivers." ); } glGetIntegerv( GL_MAX_TEXTURE_SIZE, (GLint*) &maxTextureSize ); @@ -218,46 +218,35 @@ unsigned int OPENGL_COMPOSITOR::CreateBuffer( VECTOR2U aDimensions ) { case GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT_EXT: throw std::runtime_error( "The framebuffer attachment points are incomplete." ); - break; case GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT_EXT: throw std::runtime_error( "No images attached to the framebuffer." ); - break; case GL_FRAMEBUFFER_INCOMPLETE_DRAW_BUFFER_EXT: throw std::runtime_error( "The framebuffer does not have at least one " "image attached to it." ); - break; case GL_FRAMEBUFFER_INCOMPLETE_READ_BUFFER_EXT: throw std::runtime_error( "The framebuffer read buffer is incomplete." ); - break; case GL_FRAMEBUFFER_UNSUPPORTED_EXT: - throw std::runtime_error( - "The combination of internal formats of the attached " - "images violates an implementation-dependent set of restrictions." ); - break; + throw std::runtime_error( "The combination of internal formats of the attached " + "images violates an implementation-dependent set of " + "restrictions." ); case GL_FRAMEBUFFER_INCOMPLETE_MULTISAMPLE_EXT: throw std::runtime_error( "GL_RENDERBUFFER_SAMPLES is not the same for " "all attached renderbuffers" ); - break; case GL_FRAMEBUFFER_INCOMPLETE_LAYER_TARGETS_EXT: throw std::runtime_error( "Framebuffer incomplete layer targets errors." ); - break; case GL_FRAMEBUFFER_INCOMPLETE_DIMENSIONS_EXT: throw std::runtime_error( "Framebuffer attachments have different dimensions" ); - break; default: throw std::runtime_error( "Unknown error occurred when creating the framebuffer." ); - break; } - - return 0; } ClearBuffer( COLOR4D::BLACK ); @@ -275,15 +264,15 @@ unsigned int OPENGL_COMPOSITOR::CreateBuffer( VECTOR2U aDimensions ) GLenum OPENGL_COMPOSITOR::GetBufferTexture( unsigned int aBufferHandle ) { - assert( aBufferHandle > 0 && aBufferHandle <= usedBuffers() ); + wxASSERT( aBufferHandle > 0 && aBufferHandle <= usedBuffers() ); return m_buffers[aBufferHandle - 1].textureTarget; } void OPENGL_COMPOSITOR::SetBuffer( unsigned int aBufferHandle ) { - assert( m_initialized ); - assert( aBufferHandle <= usedBuffers() ); + wxASSERT( m_initialized ); + wxASSERT( aBufferHandle <= usedBuffers() ); // Either unbind the FBO for direct rendering, or bind the one with target textures bindFb( aBufferHandle == DIRECT_RENDERING ? DIRECT_RENDERING : m_mainFbo ); @@ -307,7 +296,7 @@ void OPENGL_COMPOSITOR::SetBuffer( unsigned int aBufferHandle ) void OPENGL_COMPOSITOR::ClearBuffer( const COLOR4D& aColor ) { - assert( m_initialized ); + wxASSERT( m_initialized ); glClearColor( aColor.r, aColor.g, aColor.b, 0.0f ); glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT ); @@ -334,9 +323,9 @@ void OPENGL_COMPOSITOR::DrawBuffer( unsigned int aBufferHandle ) void OPENGL_COMPOSITOR::DrawBuffer( unsigned int aSourceHandle, unsigned int aDestHandle ) { - assert( m_initialized ); - assert( aSourceHandle != 0 && aSourceHandle <= usedBuffers() ); - assert( aDestHandle <= usedBuffers() ); + wxASSERT( m_initialized ); + wxASSERT( aSourceHandle != 0 && aSourceHandle <= usedBuffers() ); + wxASSERT( aDestHandle <= usedBuffers() ); // Switch to the destination buffer and blit the scene SetBuffer( aDestHandle ); @@ -388,7 +377,7 @@ void OPENGL_COMPOSITOR::Present() void OPENGL_COMPOSITOR::bindFb( unsigned int aFb ) { // Currently there are only 2 valid FBOs - assert( aFb == DIRECT_RENDERING || aFb == m_mainFbo ); + wxASSERT( aFb == DIRECT_RENDERING || aFb == m_mainFbo ); if( m_curFbo != aFb ) { @@ -401,14 +390,12 @@ void OPENGL_COMPOSITOR::bindFb( unsigned int aFb ) void OPENGL_COMPOSITOR::clean() { - assert( m_initialized ); + wxASSERT( m_initialized ); bindFb( DIRECT_RENDERING ); - for( OPENGL_BUFFERS::const_iterator it = m_buffers.begin(); it != m_buffers.end(); ++it ) - { - glDeleteTextures( 1, &it->textureTarget ); - } + for( const OPENGL_BUFFER& buffer : m_buffers ) + glDeleteTextures( 1, &buffer.textureTarget ); m_buffers.clear(); @@ -426,10 +413,8 @@ int OPENGL_COMPOSITOR::GetAntialiasSupersamplingFactor() const { switch ( m_currentAntialiasingMode ) { - case OPENGL_ANTIALIASING_MODE::SUPERSAMPLING: - return 2; - default: - return 1; + case OPENGL_ANTIALIASING_MODE::SUPERSAMPLING: return 2; + default: return 1; } } @@ -438,6 +423,6 @@ VECTOR2D OPENGL_COMPOSITOR::GetAntialiasRenderingOffset() const switch( m_currentAntialiasingMode ) { case OPENGL_ANTIALIASING_MODE::SUPERSAMPLING: return VECTOR2D( 0.5, -0.5 ); - default: return VECTOR2D( 0, 0 ); + default: return VECTOR2D( 0, 0 ); } } diff --git a/common/gal/opengl/utils.cpp b/common/gal/opengl/utils.cpp index af60c7a3ca..e91d9d87e8 100644 --- a/common/gal/opengl/utils.cpp +++ b/common/gal/opengl/utils.cpp @@ -90,13 +90,13 @@ int checkGlError( const std::string& aInfo, const char* aFile, int aLine, bool a break; case GL_FRAMEBUFFER_UNSUPPORTED_EXT: - errorMsg = "The combination of internal formats of the attached images violates an " - "implementation dependent set of restrictions."; + errorMsg = "The combination of internal formats of the attached images violates " + "an implementation dependent set of restrictions."; break; case GL_FRAMEBUFFER_INCOMPLETE_MULTISAMPLE_EXT: - errorMsg = - "GL_RENDERBUFFER_SAMPLES is not the same for all attached render buffers."; + errorMsg = "GL_RENDERBUFFER_SAMPLES is not the same for all attached render " + "buffers."; break; case GL_FRAMEBUFFER_INCOMPLETE_LAYER_TARGETS_EXT: @@ -140,16 +140,20 @@ int checkGlError( const std::string& aInfo, const char* aFile, int aLine, bool a if( aThrow ) { wxLogTrace( traceGalOpenGlError, wxT( "Throwing exception for glGetError() '%s' " - "in file '%s' on line %d." ), errorMsg, - aFile, aLine ); + "in file '%s' on line %d." ), + errorMsg, + aFile, + aLine ); + throw std::runtime_error( (const char*) errorMsg.char_str() ); } else { - wxString msg; + wxString msg = wxString::Format( wxT( "glGetError() '%s' in file '%s' on line %d." ), + errorMsg, + aFile, + aLine ); - msg.Printf( wxT( "glGetError() '%s' in file '%s' on line %d." ), - errorMsg, aFile, aLine ); DisplayErrorMessage( nullptr, "OpenGL Error", errorMsg ); } } diff --git a/common/tool/edit_points.cpp b/common/tool/edit_points.cpp index a1b8889f2f..92f0a49a3c 100644 --- a/common/tool/edit_points.cpp +++ b/common/tool/edit_points.cpp @@ -53,14 +53,14 @@ EDIT_POINT* EDIT_POINTS::FindPoint( const VECTOR2I& aLocation, KIGFX::VIEW *aVie if( m_allowPoints ) { - for( auto& point : m_points ) + for( EDIT_POINT& point : m_points ) { if( point.WithinPoint( aLocation, size ) ) return &point; } } - for( auto& line : m_lines ) + for( EDIT_LINE& line : m_lines ) { if( line.WithinPoint( aLocation, size ) ) return &line; @@ -244,8 +244,7 @@ const BOX2I EDIT_POINTS::ViewBBox() const void EDIT_POINTS::ViewDraw( int aLayer, KIGFX::VIEW* aView ) const { - auto gal = aView->GetGAL(); - + KIGFX::GAL* gal = aView->GetGAL(); KIGFX::RENDER_SETTINGS* settings = aView->GetPainter()->GetSettings(); KIGFX::COLOR4D drawColor = settings->GetLayerColor( LAYER_AUX_ITEMS ); diff --git a/common/tool/selection.cpp b/common/tool/selection.cpp index 1a99f015cc..e66375f8ed 100644 --- a/common/tool/selection.cpp +++ b/common/tool/selection.cpp @@ -2,6 +2,7 @@ * This program source code file is part of KiCad, a free EDA CAD application. * * Copyright (C) 2013-2017 CERN + * Copyright (C) 2021 KiCad Developers, see AUTHORS.txt for contributors. * @author Tomasz Wlostowski * @author Maciej Suminski * @@ -119,7 +120,7 @@ bool SELECTION::HasType( KICAD_T aType ) const } -const KIGFX::VIEW_GROUP::ITEMS SELECTION::updateDrawList() const +const std::vector SELECTION::updateDrawList() const { std::vector items; diff --git a/common/view/view.cpp b/common/view/view.cpp index ac9b4d371d..a127e5016e 100644 --- a/common/view/view.cpp +++ b/common/view/view.cpp @@ -64,7 +64,7 @@ public: deleteGroups(); } - int getFlags() const + int GetFlags() const { return m_flags; } @@ -124,7 +124,7 @@ private: } // If there was no entry for the given layer - create one - GroupPair* newGroups = new GroupPair[m_groupsSize + 1]; + std::pair* newGroups = new std::pair[m_groupsSize + 1]; if( m_groupsSize > 0 ) { @@ -133,7 +133,7 @@ private: } m_groups = newGroups; - newGroups[m_groupsSize++] = GroupPair( aLayer, aGroup ); + newGroups[m_groupsSize++] = { aLayer, aGroup }; } @@ -177,7 +177,8 @@ private: { new_layer = aReorderMap.at( orig_layer ); } - catch( const std::out_of_range& ) {} + catch( const std::out_of_range& ) + {} m_groups[i].first = new_layer; } @@ -226,22 +227,16 @@ private: return m_flags == VISIBLE; } + VIEW* m_view; ///< Current dynamic view the item is assigned to. + int m_flags; ///< Visibility flags + int m_requiredUpdate; ///< Flag required for updating + int m_drawPriority; ///< Order to draw this item in a layer, lowest first - VIEW* m_view; ///< Current dynamic view the item is assigned to. - int m_flags; ///< Visibility flags - int m_requiredUpdate; ///< Flag required for updating - int m_drawPriority; ///< Order to draw this item in a layer, lowest first + std::pair* m_groups; ///< layer_number:group_id pairs for each layer the + ///< item occupies. + int m_groupsSize; - ///< Helper for storing cached items group ids - typedef std::pair GroupPair; - - ///< Indexes of cached GAL display lists corresponding to the item (for every layer it. - ///< occupies)(in the std::pair "first" stores layer number, "second" stores group id). - GroupPair* m_groups; - int m_groupsSize; - - /// Stores layer numbers used by the item. - std::vector m_layers; + std::vector m_layers; /// Stores layer numbers used by the item. }; @@ -415,7 +410,7 @@ struct QUERY_VISITOR bool operator()( VIEW_ITEM* aItem ) { - if( aItem->viewPrivData()->getFlags() & VISIBLE ) + if( aItem->viewPrivData()->GetFlags() & VISIBLE ) m_cont.push_back( VIEW::LAYER_ITEM_PAIR( aItem, m_layer ) ); return true; @@ -733,7 +728,7 @@ struct VIEW::UPDATE_COLOR_VISITOR { // Obtain the color that should be used for coloring the item const COLOR4D color = painter->GetSettings()->GetColor( aItem, layer ); - int group = aItem->viewPrivData()->getGroup( layer ); + int group = aItem->viewPrivData()->getGroup( layer ); if( group >= 0 ) gal->ChangeGroupColor( group, color ); @@ -787,7 +782,7 @@ void VIEW::UpdateAllLayersColor() for( int i = 0; i < layers_count; ++i ) { const COLOR4D color = m_painter->GetSettings()->GetColor( item, layers[i] ); - int group = viewData->getGroup( layers[i] ); + int group = viewData->getGroup( layers[i] ); if( group >= 0 ) m_gal->ChangeGroupColor( group, color ); @@ -946,8 +941,8 @@ struct VIEW::DRAW_ITEM_VISITOR wxCHECK( aItem->viewPrivData(), false ); // Conditions that have to be fulfilled for an item to be drawn - bool drawCondition = aItem->viewPrivData()->isRenderable() && - aItem->ViewGetLOD( layer, view ) < view->m_scale; + bool drawCondition = aItem->viewPrivData()->isRenderable() + && aItem->ViewGetLOD( layer, view ) < view->m_scale; if( !drawCondition ) return true; @@ -962,15 +957,21 @@ struct VIEW::DRAW_ITEM_VISITOR void deferredDraw() { if( reverseDrawOrder ) + { std::sort( drawItems.begin(), drawItems.end(), - []( VIEW_ITEM* a, VIEW_ITEM* b ) -> bool { + []( VIEW_ITEM* a, VIEW_ITEM* b ) -> bool + { return b->viewPrivData()->m_drawPriority < a->viewPrivData()->m_drawPriority; }); + } else + { std::sort( drawItems.begin(), drawItems.end(), - []( VIEW_ITEM* a, VIEW_ITEM* b ) -> bool { + []( VIEW_ITEM* a, VIEW_ITEM* b ) -> bool + { return a->viewPrivData()->m_drawPriority < b->viewPrivData()->m_drawPriority; }); + } for( VIEW_ITEM* item : drawItems ) view->draw( item, layer ); @@ -1147,11 +1148,13 @@ void VIEW::Redraw() rect.Normalize(); BOX2I recti( rect.GetPosition(), rect.GetSize() ); - // The view rtree uses integer positions. Large screens can overflow - // this size so in this case, simply set the rectangle to the full rtree - if( rect.GetWidth() > std::numeric_limits::max() || - rect.GetHeight() > std::numeric_limits::max() ) + // The view rtree uses integer positions. Large screens can overflow this size so in + // this case, simply set the rectangle to the full rtree. + if( rect.GetWidth() > std::numeric_limits::max() + || rect.GetHeight() > std::numeric_limits::max() ) + { recti.SetMaximum(); + } redrawRect( recti ); @@ -1214,13 +1217,9 @@ void VIEW::invalidateItem( VIEW_ITEM* aItem, int aUpdateFlags ) // updateLayers updates geometry too, so we do not have to update both of them at the // same time if( aUpdateFlags & LAYERS ) - { updateLayers( aItem ); - } else if( aUpdateFlags & GEOMETRY ) - { updateBbox( aItem ); - } } int layers[VIEW_MAX_LAYERS], layers_count; @@ -1376,11 +1375,10 @@ bool VIEW::areRequiredLayersEnabled( int aLayerId ) const std::set::const_iterator it, it_end; - for( it = m_layers.at( aLayerId ).requiredLayers.begin(), - it_end = m_layers.at( aLayerId ).requiredLayers.end(); it != it_end; ++it ) + for( int layer : m_layers.at( aLayerId ).requiredLayers ) { // That is enough if just one layer is not enabled - if( !m_layers.at( *it ).visible || !areRequiredLayersEnabled( *it ) ) + if( !m_layers.at( layer ).visible || !areRequiredLayersEnabled( layer ) ) return false; } diff --git a/common/view/view_group.cpp b/common/view/view_group.cpp index 41bb9a8ea6..1c6a2ec8e9 100644 --- a/common/view/view_group.cpp +++ b/common/view/view_group.cpp @@ -2,6 +2,7 @@ * This program source code file is part of KiCad, a free EDA CAD application. * * Copyright (C) 2013 CERN + * Copyright (C) 2021 KiCad Developers, see AUTHORS.txt for contributors. * @author Maciej Suminski * * This program is free software; you can redistribute it and/or @@ -31,7 +32,7 @@ */ #include -#include +#include #include #include #include @@ -61,14 +62,7 @@ void VIEW_GROUP::Add( VIEW_ITEM* aItem ) void VIEW_GROUP::Remove( VIEW_ITEM* aItem ) { - for( auto iter = m_groupItems.begin(); iter != m_groupItems.end(); ++iter ) - { - if( aItem == *iter ) - { - m_groupItems.erase( iter ); - break; - } - } + alg::delete_matching( m_groupItems, aItem ); } @@ -102,7 +96,7 @@ const BOX2I VIEW_GROUP::ViewBBox() const { bb = m_groupItems[0]->ViewBBox(); - for( auto item : m_groupItems ) + for( VIEW_ITEM* item : m_groupItems ) bb.Merge( item->ViewBBox() ); } @@ -204,7 +198,7 @@ void VIEW_GROUP::FreeItems() } -const VIEW_GROUP::ITEMS VIEW_GROUP::updateDrawList() const +const std::vector VIEW_GROUP::updateDrawList() const { return m_groupItems; } diff --git a/common/view/view_item.cpp b/common/view/view_item.cpp index a543e31649..017cfe78f0 100644 --- a/common/view/view_item.cpp +++ b/common/view/view_item.cpp @@ -2,6 +2,7 @@ * This program source code file is part of KiCad, a free EDA CAD application. * * Copyright (C) 2013-2016 CERN + * Copyright (C) 2021 KiCad Developers, see AUTHORS.txt for contributors. * @author Tomasz Wlostowski * * This program is free software; you can redistribute it and/or @@ -22,8 +23,6 @@ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA */ -#include - #include #include diff --git a/common/view/view_overlay.cpp b/common/view/view_overlay.cpp index 50365e8620..2991773c22 100644 --- a/common/view/view_overlay.cpp +++ b/common/view/view_overlay.cpp @@ -61,8 +61,9 @@ struct VIEW_OVERLAY::COMMAND_LINE : public VIEW_OVERLAY::COMMAND struct VIEW_OVERLAY::COMMAND_RECTANGLE : public VIEW_OVERLAY::COMMAND { COMMAND_RECTANGLE( const VECTOR2D& aP0, const VECTOR2D& aP1 ) : - m_p0( aP0 ), m_p1( aP1 ) - {} + m_p0( aP0 ), + m_p1( aP1 ) + { } virtual void Execute( VIEW* aView ) const override { @@ -78,7 +79,8 @@ struct VIEW_OVERLAY::COMMAND_CIRCLE : public VIEW_OVERLAY::COMMAND { COMMAND_CIRCLE( const VECTOR2D& aCenter, double aRadius ) : m_center(aCenter), - m_radius(aRadius) {} + m_radius(aRadius) + { } virtual void Execute( VIEW* aView ) const override { @@ -114,7 +116,8 @@ struct VIEW_OVERLAY::COMMAND_ARC : public VIEW_OVERLAY::COMMAND struct VIEW_OVERLAY::COMMAND_POLYGON : public VIEW_OVERLAY::COMMAND { COMMAND_POLYGON( const std::deque& aPointList ) : - m_pointList( aPointList ) {} + m_pointList( aPointList ) + { } virtual void Execute( VIEW* aView ) const override { @@ -128,7 +131,8 @@ struct VIEW_OVERLAY::COMMAND_POLYGON : public VIEW_OVERLAY::COMMAND struct VIEW_OVERLAY::COMMAND_POLY_POLYGON : public VIEW_OVERLAY::COMMAND { COMMAND_POLY_POLYGON( const SHAPE_POLY_SET& aPolySet ) : - m_polySet( aPolySet ) {} + m_polySet( aPolySet ) + { } virtual void Execute( VIEW* aView ) const override { @@ -161,7 +165,8 @@ struct VIEW_OVERLAY::COMMAND_POINT_POLYGON : public VIEW_OVERLAY::COMMAND struct VIEW_OVERLAY::COMMAND_SET_STROKE : public VIEW_OVERLAY::COMMAND { COMMAND_SET_STROKE( bool aIsStroke ) : - m_isStroke( aIsStroke ) {} + m_isStroke( aIsStroke ) + { } virtual void Execute( VIEW* aView ) const override { @@ -175,7 +180,8 @@ struct VIEW_OVERLAY::COMMAND_SET_STROKE : public VIEW_OVERLAY::COMMAND struct VIEW_OVERLAY::COMMAND_SET_FILL : public VIEW_OVERLAY::COMMAND { COMMAND_SET_FILL( bool aIsFill ) : - m_isFill( aIsFill ) {} + m_isFill( aIsFill ) + { } virtual void Execute( VIEW* aView ) const override { @@ -190,7 +196,8 @@ struct VIEW_OVERLAY::COMMAND_SET_COLOR : public VIEW_OVERLAY::COMMAND { COMMAND_SET_COLOR( bool aIsStroke, const COLOR4D& aColor ) : m_isStroke( aIsStroke ), - m_color( aColor ) {} + m_color( aColor ) + { } virtual void Execute( VIEW* aView ) const override { @@ -200,15 +207,16 @@ struct VIEW_OVERLAY::COMMAND_SET_COLOR : public VIEW_OVERLAY::COMMAND aView->GetGAL()->SetFillColor( m_color ); } - bool m_isStroke; - COLOR4D m_color; + bool m_isStroke; + COLOR4D m_color; }; struct VIEW_OVERLAY::COMMAND_SET_WIDTH : public VIEW_OVERLAY::COMMAND { COMMAND_SET_WIDTH( double aWidth ) : - m_width( aWidth ) {} + m_width( aWidth ) + { } virtual void Execute( VIEW* aView ) const override { @@ -222,7 +230,8 @@ struct VIEW_OVERLAY::COMMAND_SET_WIDTH : public VIEW_OVERLAY::COMMAND struct VIEW_OVERLAY::COMMAND_GLYPH_SIZE : public VIEW_OVERLAY::COMMAND { COMMAND_GLYPH_SIZE( const VECTOR2D aSize ) : - m_size( aSize ) {}; + m_size( aSize ) + { }; virtual void Execute( VIEW* aView ) const override { @@ -235,11 +244,11 @@ struct VIEW_OVERLAY::COMMAND_GLYPH_SIZE : public VIEW_OVERLAY::COMMAND struct VIEW_OVERLAY::COMMAND_BITMAP_TEXT : public VIEW_OVERLAY::COMMAND { - COMMAND_BITMAP_TEXT( const wxString& aText, const VECTOR2D& aPosition, - double aRotationAngle ) : + COMMAND_BITMAP_TEXT( const wxString& aText, const VECTOR2D& aPosition, double aRotationAngle ) : m_text( aText ), m_pos( aPosition ), - m_angle (aRotationAngle) {}; + m_angle (aRotationAngle) + { } virtual void Execute( VIEW* aView ) const override { @@ -264,7 +273,7 @@ VIEW_OVERLAY::~VIEW_OVERLAY() void VIEW_OVERLAY::releaseCommands() { - for( auto cmd : m_commands ) + for( VIEW_OVERLAY::COMMAND* cmd : m_commands ) delete cmd; m_commands.clear(); @@ -288,7 +297,7 @@ const BOX2I VIEW_OVERLAY::ViewBBox() const void VIEW_OVERLAY::ViewDraw( int aLayer, VIEW* aView ) const { - for( const auto& cmd : m_commands ) + for( const VIEW_OVERLAY::COMMAND* cmd : m_commands ) cmd->Execute( aView ); } @@ -323,10 +332,9 @@ void VIEW_OVERLAY::Polyline( const SHAPE_LINE_CHAIN& aPolyLine ) { SetIsStroke( true ); SetIsFill( false ); + for( int i = 0; i < aPolyLine.SegmentCount(); i++ ) - { Line( aPolyLine.CSegment( i ) ); - } } @@ -354,8 +362,8 @@ void VIEW_OVERLAY::Circle( const VECTOR2D& aCenterPoint, double aRadius ) } -void VIEW_OVERLAY::Arc( const VECTOR2D& aCenterPoint, - double aRadius, double aStartAngle, double aEndAngle ) +void VIEW_OVERLAY::Arc( const VECTOR2D& aCenterPoint, double aRadius, double aStartAngle, + double aEndAngle ) { m_commands.push_back( new COMMAND_ARC( aCenterPoint, aRadius, aStartAngle, aEndAngle ) ); } diff --git a/include/tool/selection.h b/include/tool/selection.h index f86f123972..97ae65cc61 100644 --- a/include/tool/selection.h +++ b/include/tool/selection.h @@ -2,6 +2,7 @@ * This program source code file is part of KiCad, a free EDA CAD application. * * Copyright (C) 2013-2017 CERN + * Copyright (C) 2021 KiCad Developers, see AUTHORS.txt for contributors. * @author Tomasz Wlostowski * @author Maciej Suminski * @@ -171,7 +172,7 @@ public: */ bool HasType( KICAD_T aType ) const; - virtual const VIEW_GROUP::ITEMS updateDrawList() const override; + virtual const std::vector updateDrawList() const override; bool HasReferencePoint() const { diff --git a/include/view/view.h b/include/view/view.h index 60bd2e0304..99d45049b9 100644 --- a/include/view/view.h +++ b/include/view/view.h @@ -645,13 +645,6 @@ public: m_dirtyTargets[i] = false; } - /** - * Add an item to a list of items that are going to be refreshed upon the next frame rendering. - * - * @param aItem is the item to be refreshed. - */ - void MarkForUpdate( VIEW_ITEM* aItem ); - /** * Iterate through the list of items that asked for updating and updates them. */ @@ -689,14 +682,6 @@ public: m_useDrawPriority = aFlag; } - /** - * @return true if draw order is reversed - */ - bool IsDrawOrderReversed() const - { - return m_reverseDrawOrder; - } - /** * Only takes effect if UseDrawPriority is true. * @@ -831,40 +816,30 @@ protected: std::vector m_ownedItems; ///< Whether to use rendering order modifier or not. - bool m_enableOrderModifier; + bool m_enableOrderModifier; ///< The set of possible displayed layers and its properties. - std::vector m_layers; + std::vector m_layers; ///< Sorted list of pointers to members of m_layers. - std::vector m_orderedLayers; + std::vector m_orderedLayers; ///< Flat list of all items. std::shared_ptr> m_allItems; ///< The set of layers that are displayed on the top. - std::set m_topLayers; + std::set m_topLayers; ///< Center point of the VIEW (the point at which we are looking at). - VECTOR2D m_center; + VECTOR2D m_center; - ///< Scale of displayed VIEW_ITEMs. - double m_scale; + double m_scale; + BOX2D m_boundary; + double m_minScale; + double m_maxScale; - ///< View boundaries. - BOX2D m_boundary; - - ///< Scale lower limit. - double m_minScale; - - ///< Scale upper limit. - double m_maxScale; - - ///< Horizontal flip flag. - bool m_mirrorX; - - ///< Vertical flip flag. - bool m_mirrorY; + bool m_mirrorX; + bool m_mirrorY; ///< PAINTER contains information how do draw items. PAINTER* m_painter; diff --git a/include/view/view_group.h b/include/view/view_group.h index 631bb0cb3a..af75b5abcf 100644 --- a/include/view/view_group.h +++ b/include/view/view_group.h @@ -51,22 +51,16 @@ public: /** * Return the number of stored items. - * - * @return Number of stored items. */ virtual unsigned int GetSize() const; /** * Add an item to the group. - * - * @param aItem is the item to be added. */ virtual void Add( VIEW_ITEM* aItem ); /** * Remove an item from the group. - * - * @param aItem is the item to be removed. */ virtual void Remove( VIEW_ITEM* aItem ); @@ -79,8 +73,6 @@ public: /** * Return the bounding box for all stored items covering all its layers. - * - * @return The current bounding box */ virtual const BOX2I ViewBBox() const override; @@ -102,8 +94,6 @@ public: /** * Set layer used to draw the group. - * - * @param aLayer is the layer used for drawing. */ inline virtual void SetLayer( int aLayer ) { @@ -116,15 +106,11 @@ public: void FreeItems(); protected: - typedef std::vector ITEMS; + virtual const std::vector updateDrawList() const; - virtual const ITEMS updateDrawList() const; - - ///< Layer on which the group is drawn. - int m_layer; - - ///< Container for storing VIEW_ITEMs. - ITEMS m_groupItems; +protected: + int m_layer; + std::vector m_groupItems; }; } // namespace KIGFX diff --git a/include/view/view_item.h b/include/view/view_item.h index 69561ffe9c..96edccdf0f 100644 --- a/include/view/view_item.h +++ b/include/view/view_item.h @@ -2,7 +2,7 @@ * This program source code file is part of KiCad, a free EDA CAD application. * * Copyright (C) 2013-2016 CERN - * Copyright (C) 2020 KiCad Developers, see AUTHORS.txt for contributors. + * Copyright (C) 2020-2021 KiCad Developers, see AUTHORS.txt for contributors. * * @author Tomasz Wlostowski * @@ -24,11 +24,6 @@ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA */ -/** - * @file view_item.h - * @brief VIEW_ITEM class definition. - */ - #ifndef __VIEW_ITEM_H #define __VIEW_ITEM_H diff --git a/pcbnew/tools/pcb_selection.cpp b/pcbnew/tools/pcb_selection.cpp index 04c0056469..56f61804ce 100644 --- a/pcbnew/tools/pcb_selection.cpp +++ b/pcbnew/tools/pcb_selection.cpp @@ -4,7 +4,7 @@ * Copyright (C) 2013-2017 CERN * @author Tomasz Wlostowski * @author Maciej Suminski - * Copyright (C) 2017 KiCad Developers, see CHANGELOG.TXT for contributors. + * Copyright (C) 2017-2021 KiCad Developers, see CHANGELOG.TXT for contributors. * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License @@ -24,8 +24,6 @@ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA */ -#include - #include using namespace std::placeholders; @@ -84,7 +82,7 @@ EDA_ITEM* PCB_SELECTION::GetTopLeftItem( bool aFootprintsOnly ) const } -const KIGFX::VIEW_GROUP::ITEMS PCB_SELECTION::updateDrawList() const +const std::vector PCB_SELECTION::updateDrawList() const { std::vector items; diff --git a/pcbnew/tools/pcb_selection.h b/pcbnew/tools/pcb_selection.h index c6568569d8..5038e539a1 100644 --- a/pcbnew/tools/pcb_selection.h +++ b/pcbnew/tools/pcb_selection.h @@ -1,7 +1,7 @@ /* * This program source code file is part of KiCad, a free EDA CAD application. * - * Copyright (C) 2019 KiCad Developers, see CHANGELOG.TXT for contributors. + * Copyright (C) 2019-2021 KiCad Developers, see CHANGELOG.TXT for contributors. * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License @@ -33,7 +33,7 @@ class PCB_SELECTION : public SELECTION public: EDA_ITEM* GetTopLeftItem( bool aFootprintsOnly = false ) const override; - const KIGFX::VIEW_GROUP::ITEMS updateDrawList() const override; + const std::vector updateDrawList() const override; const LSET GetSelectionLayers(); };