mirror of
https://gitlab.com/kicad/code/kicad.git
synced 2025-09-13 17:53:11 +02:00
Iterator safety.
This commit is contained in:
parent
3a3d1708d4
commit
ca1db93013
@ -171,17 +171,15 @@ unsigned int OPENGL_COMPOSITOR::CreateBuffer( VECTOR2I 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 );
|
||||
|
||||
if( maxTextureSize < (int) aDimensions.x || maxTextureSize < (int) aDimensions.y )
|
||||
{
|
||||
throw std::runtime_error( "Requested texture size is not supported. "
|
||||
"Could not create a buffer." );
|
||||
throw std::runtime_error( "Requested texture size is not supported. Could not create a buffer." );
|
||||
}
|
||||
|
||||
// GL_COLOR_ATTACHMENTn are consecutive integers
|
||||
@ -197,16 +195,14 @@ unsigned int OPENGL_COMPOSITOR::CreateBuffer( VECTOR2I aDimensions )
|
||||
|
||||
// Set texture parameters
|
||||
glTexEnvf( GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE );
|
||||
glTexImage2D( GL_TEXTURE_2D, 0, GL_RGBA8, aDimensions.x, aDimensions.y, 0, GL_RGBA,
|
||||
GL_UNSIGNED_BYTE, nullptr );
|
||||
glTexImage2D( GL_TEXTURE_2D, 0, GL_RGBA8, aDimensions.x, aDimensions.y, 0, GL_RGBA, GL_UNSIGNED_BYTE, nullptr );
|
||||
checkGlError( "creating framebuffer texture", __FILE__, __LINE__ );
|
||||
glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST );
|
||||
glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST );
|
||||
|
||||
// Bind the texture to the specific attachment point, clear and rebind the screen
|
||||
bindFb( m_mainFbo );
|
||||
glFramebufferTexture2DEXT( GL_FRAMEBUFFER_EXT, attachmentPoint, GL_TEXTURE_2D, textureTarget,
|
||||
0 );
|
||||
glFramebufferTexture2DEXT( GL_FRAMEBUFFER_EXT, attachmentPoint, GL_TEXTURE_2D, textureTarget, 0 );
|
||||
|
||||
// Check the status, exit if the framebuffer can't be created
|
||||
GLenum status = glCheckFramebufferStatusEXT( GL_FRAMEBUFFER_EXT );
|
||||
@ -222,20 +218,17 @@ unsigned int OPENGL_COMPOSITOR::CreateBuffer( VECTOR2I aDimensions )
|
||||
throw std::runtime_error( "No images attached to the framebuffer." );
|
||||
|
||||
case GL_FRAMEBUFFER_INCOMPLETE_DRAW_BUFFER_EXT:
|
||||
throw std::runtime_error( "The framebuffer does not have at least one "
|
||||
"image attached to it." );
|
||||
throw std::runtime_error( "The framebuffer does not have at least one image attached to it." );
|
||||
|
||||
case GL_FRAMEBUFFER_INCOMPLETE_READ_BUFFER_EXT:
|
||||
throw std::runtime_error( "The framebuffer read buffer is incomplete." );
|
||||
|
||||
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." );
|
||||
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" );
|
||||
throw std::runtime_error( "GL_RENDERBUFFER_SAMPLES is not the same for all attached renderbuffers" );
|
||||
|
||||
case GL_FRAMEBUFFER_INCOMPLETE_LAYER_TARGETS_EXT:
|
||||
throw std::runtime_error( "Framebuffer incomplete layer targets errors." );
|
||||
@ -263,15 +256,14 @@ unsigned int OPENGL_COMPOSITOR::CreateBuffer( VECTOR2I aDimensions )
|
||||
|
||||
GLenum OPENGL_COMPOSITOR::GetBufferTexture( unsigned int aBufferHandle )
|
||||
{
|
||||
wxASSERT( aBufferHandle > 0 && aBufferHandle <= usedBuffers() );
|
||||
wxCHECK( aBufferHandle > 0 && aBufferHandle <= usedBuffers(), 0 );
|
||||
return m_buffers[aBufferHandle - 1].textureTarget;
|
||||
}
|
||||
|
||||
|
||||
void OPENGL_COMPOSITOR::SetBuffer( unsigned int aBufferHandle )
|
||||
{
|
||||
wxASSERT( m_initialized );
|
||||
wxASSERT( aBufferHandle <= usedBuffers() );
|
||||
wxCHECK( m_initialized && aBufferHandle <= usedBuffers(), /* void */ );
|
||||
|
||||
// Either unbind the FBO for direct rendering, or bind the one with target textures
|
||||
bindFb( aBufferHandle == DIRECT_RENDERING ? DIRECT_RENDERING : m_mainFbo );
|
||||
@ -283,8 +275,7 @@ void OPENGL_COMPOSITOR::SetBuffer( unsigned int aBufferHandle )
|
||||
glDrawBuffer( m_buffers[m_curBuffer].attachmentPoint );
|
||||
checkGlError( "setting draw buffer", __FILE__, __LINE__ );
|
||||
|
||||
glViewport( 0, 0, m_buffers[m_curBuffer].dimensions.x,
|
||||
m_buffers[m_curBuffer].dimensions.y );
|
||||
glViewport( 0, 0, m_buffers[m_curBuffer].dimensions.x, m_buffers[m_curBuffer].dimensions.y );
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -295,7 +286,7 @@ void OPENGL_COMPOSITOR::SetBuffer( unsigned int aBufferHandle )
|
||||
|
||||
void OPENGL_COMPOSITOR::ClearBuffer( const COLOR4D& aColor )
|
||||
{
|
||||
wxASSERT( m_initialized );
|
||||
wxCHECK( m_initialized, /* void */ );
|
||||
|
||||
glClearColor( aColor.r, aColor.g, aColor.b, m_curFbo == DIRECT_RENDERING ? 1.0f : 0.0f );
|
||||
glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT );
|
||||
@ -326,9 +317,8 @@ void OPENGL_COMPOSITOR::DrawBuffer( unsigned int aBufferHandle )
|
||||
|
||||
void OPENGL_COMPOSITOR::DrawBuffer( unsigned int aSourceHandle, unsigned int aDestHandle )
|
||||
{
|
||||
wxASSERT( m_initialized );
|
||||
wxASSERT( aSourceHandle != 0 && aSourceHandle <= usedBuffers() );
|
||||
wxASSERT( aDestHandle <= usedBuffers() );
|
||||
wxCHECK( m_initialized && aSourceHandle != 0 && aSourceHandle <= usedBuffers(), /* void */ );
|
||||
wxCHECK( aDestHandle <= usedBuffers(), /* void */ );
|
||||
|
||||
// Switch to the destination buffer and blit the scene
|
||||
SetBuffer( aDestHandle );
|
||||
@ -393,7 +383,7 @@ void OPENGL_COMPOSITOR::bindFb( unsigned int aFb )
|
||||
|
||||
void OPENGL_COMPOSITOR::clean()
|
||||
{
|
||||
wxASSERT( m_initialized );
|
||||
wxCHECK( m_initialized, /* void */ );
|
||||
|
||||
bindFb( DIRECT_RENDERING );
|
||||
|
||||
|
@ -799,9 +799,7 @@ void ACTION_TOOLBAR::popupPalette( wxAuiToolBarItem* aItem )
|
||||
|
||||
wxWindow* toolParent = dynamic_cast<wxWindow*>( m_toolManager->GetToolHolder() );
|
||||
|
||||
wxASSERT( GetParent() );
|
||||
wxASSERT( m_auiManager );
|
||||
wxASSERT( toolParent );
|
||||
wxCHECK( GetParent() && m_auiManager && toolParent, /* void */ );
|
||||
|
||||
// Ensure the item we are using for the palette has a group associated with it.
|
||||
const auto it = m_actionGroups.find( aItem->GetId() );
|
||||
|
@ -192,7 +192,8 @@ void CVPCB_MAINFRAME::AutomaticFootprintMatching()
|
||||
error_msg.Empty();
|
||||
|
||||
bool firstAssoc = true;
|
||||
for( unsigned kk = 0; kk < m_netlist.GetCount(); kk++ )
|
||||
|
||||
for( int kk = 0; kk < (int) m_netlist.GetCount(); kk++ )
|
||||
{
|
||||
COMPONENT* component = m_netlist.GetComponent( kk );
|
||||
|
||||
@ -207,37 +208,29 @@ void CVPCB_MAINFRAME::AutomaticFootprintMatching()
|
||||
// for example)
|
||||
wxString fpid_candidate;
|
||||
|
||||
for( unsigned idx = 0; idx < equivList.size(); idx++ )
|
||||
for( int idx = 0; idx < (int) equivList.size(); idx++ )
|
||||
{
|
||||
FOOTPRINT_EQUIVALENCE& equivItem = equivList[idx];
|
||||
|
||||
if( equivItem.m_ComponentValue.CmpNoCase( component->GetValue() ) != 0 )
|
||||
continue;
|
||||
|
||||
const FOOTPRINT_INFO* fp =
|
||||
m_FootprintsList->GetFootprintInfo( equivItem.m_FootprintFPID );
|
||||
const FOOTPRINT_INFO* fp = m_FootprintsList->GetFootprintInfo( equivItem.m_FootprintFPID );
|
||||
|
||||
bool equ_is_unique = true;
|
||||
unsigned next = idx+1;
|
||||
int next = idx+1;
|
||||
int previous = idx-1;
|
||||
|
||||
if( next < equivList.size()
|
||||
&& equivItem.m_ComponentValue == equivList[next].m_ComponentValue )
|
||||
{
|
||||
if( next < (int) equivList.size() && equivItem.m_ComponentValue == equivList[next].m_ComponentValue )
|
||||
equ_is_unique = false;
|
||||
}
|
||||
|
||||
if( previous >= 0
|
||||
&& equivItem.m_ComponentValue == equivList[previous].m_ComponentValue )
|
||||
{
|
||||
if( previous >= 0 && equivItem.m_ComponentValue == equivList[previous].m_ComponentValue )
|
||||
equ_is_unique = false;
|
||||
}
|
||||
|
||||
// If the equivalence is unique, no ambiguity: use the association
|
||||
if( fp && equ_is_unique )
|
||||
{
|
||||
AssociateFootprint( CVPCB_ASSOCIATION( kk, equivItem.m_FootprintFPID ),
|
||||
firstAssoc );
|
||||
AssociateFootprint( CVPCB_ASSOCIATION( kk, equivItem.m_FootprintFPID ), firstAssoc );
|
||||
firstAssoc = false;
|
||||
found = true;
|
||||
break;
|
||||
@ -254,18 +247,18 @@ void CVPCB_MAINFRAME::AutomaticFootprintMatching()
|
||||
if( fp )
|
||||
{
|
||||
size_t filtercount = component->GetFootprintFilters().GetCount();
|
||||
found = ( 0 == filtercount ); // if no entries, do not filter
|
||||
found = ( filtercount == 0 ); // if no entries, do not filter
|
||||
|
||||
for( size_t jj = 0; jj < filtercount && !found; jj++ )
|
||||
found = fp->GetFootprintName().Matches( component->GetFootprintFilters()[jj] );
|
||||
}
|
||||
else
|
||||
{
|
||||
msg.Printf( _( "Component %s: footprint %s not found in any of the project "
|
||||
"footprint libraries." ),
|
||||
component->GetReference(), equivItem.m_FootprintFPID );
|
||||
msg.Printf( _( "Component %s: footprint %s not found in any of the project footprint libraries." ),
|
||||
component->GetReference(),
|
||||
equivItem.m_FootprintFPID );
|
||||
|
||||
if( ! error_msg.IsEmpty() )
|
||||
if( !error_msg.IsEmpty() )
|
||||
error_msg << wxT("\n\n");
|
||||
|
||||
error_msg += msg;
|
||||
@ -273,8 +266,7 @@ void CVPCB_MAINFRAME::AutomaticFootprintMatching()
|
||||
|
||||
if( found )
|
||||
{
|
||||
AssociateFootprint( CVPCB_ASSOCIATION( kk, equivItem.m_FootprintFPID ),
|
||||
firstAssoc );
|
||||
AssociateFootprint( CVPCB_ASSOCIATION( kk, equivItem.m_FootprintFPID ), firstAssoc );
|
||||
firstAssoc = false;
|
||||
break;
|
||||
}
|
||||
@ -292,14 +284,13 @@ void CVPCB_MAINFRAME::AutomaticFootprintMatching()
|
||||
}
|
||||
|
||||
// obviously the last chance: there's only one filter matching one footprint
|
||||
if( 1 == component->GetFootprintFilters().GetCount() )
|
||||
if( component->GetFootprintFilters().GetCount() == 1 )
|
||||
{
|
||||
// we do not need to analyze wildcards: single footprint do not
|
||||
// contain them and if there are wildcards it just will not match any
|
||||
if( m_FootprintsList->GetFootprintInfo( component->GetFootprintFilters()[0] ) )
|
||||
{
|
||||
AssociateFootprint( CVPCB_ASSOCIATION( kk, component->GetFootprintFilters()[0] ),
|
||||
firstAssoc );
|
||||
AssociateFootprint( CVPCB_ASSOCIATION( kk, component->GetFootprintFilters()[0] ), firstAssoc );
|
||||
firstAssoc = false;
|
||||
}
|
||||
}
|
||||
|
@ -138,7 +138,8 @@ static void add_category( const std::string& aCategoryPath, CATEGORY_STORE& aCat
|
||||
|
||||
aCategoryStore.insert( aCategoryStore.end(), { aCategoryPath, categoryNode.get() } );
|
||||
|
||||
parent_iter->second->push_back( std::move( categoryNode ) );
|
||||
if( parent_iter != aCategoryStore.end() )
|
||||
parent_iter->second->push_back( std::move( categoryNode ) );
|
||||
}
|
||||
|
||||
|
||||
@ -219,11 +220,13 @@ void NL_SCHEMATIC_PLUGIN_IMPL::exportCommandsAndImages()
|
||||
}
|
||||
}
|
||||
|
||||
wxLogTrace( m_logTrace, wxT( "Inserting command: %s, description: %s, in category: %s" ),
|
||||
name, description, iter->first );
|
||||
if( iter != categoryStore.end() )
|
||||
{
|
||||
wxLogTrace( m_logTrace, wxT( "Inserting command: %s, description: %s, in category: %s" ),
|
||||
name, description, iter->first );
|
||||
|
||||
iter->second->push_back(
|
||||
CCommand( std::move( name ), std::move( label ), std::move( description ) ) );
|
||||
iter->second->push_back( CCommand( name, label, description ) );
|
||||
}
|
||||
}
|
||||
|
||||
NAV_3D::AddCommandSet( commandSet );
|
||||
@ -233,7 +236,7 @@ void NL_SCHEMATIC_PLUGIN_IMPL::exportCommandsAndImages()
|
||||
|
||||
long NL_SCHEMATIC_PLUGIN_IMPL::GetCameraMatrix( navlib::matrix_t& matrix ) const
|
||||
{
|
||||
if( m_view == nullptr )
|
||||
if( !m_view )
|
||||
return navlib::make_result_code( navlib::navlib_errc::no_data_available );
|
||||
|
||||
m_viewPosition = m_view->GetCenter();
|
||||
@ -253,7 +256,7 @@ long NL_SCHEMATIC_PLUGIN_IMPL::GetCameraMatrix( navlib::matrix_t& matrix ) const
|
||||
|
||||
long NL_SCHEMATIC_PLUGIN_IMPL::GetPointerPosition( navlib::point_t& position ) const
|
||||
{
|
||||
if( m_view == nullptr )
|
||||
if( !m_view )
|
||||
return navlib::make_result_code( navlib::navlib_errc::no_data_available );
|
||||
|
||||
VECTOR2D mouse_pointer = m_viewport2D->GetViewControls()->GetMousePosition();
|
||||
@ -268,7 +271,7 @@ long NL_SCHEMATIC_PLUGIN_IMPL::GetPointerPosition( navlib::point_t& position ) c
|
||||
|
||||
long NL_SCHEMATIC_PLUGIN_IMPL::GetViewExtents( navlib::box_t& extents ) const
|
||||
{
|
||||
if( m_view == nullptr )
|
||||
if( !m_view )
|
||||
return navlib::make_result_code( navlib::navlib_errc::no_data_available );
|
||||
|
||||
double scale = m_viewport2D->GetGAL()->GetWorldScale();
|
||||
@ -296,14 +299,13 @@ long NL_SCHEMATIC_PLUGIN_IMPL::GetIsViewPerspective( navlib::bool_t& perspective
|
||||
|
||||
long NL_SCHEMATIC_PLUGIN_IMPL::SetCameraMatrix( const navlib::matrix_t& matrix )
|
||||
{
|
||||
if( m_view == nullptr )
|
||||
if( !m_view )
|
||||
return navlib::make_result_code( navlib::navlib_errc::invalid_operation );
|
||||
|
||||
long result = 0;
|
||||
VECTOR2D viewPos( matrix.m4x4[3][0], matrix.m4x4[3][1] );
|
||||
|
||||
if( !equals( m_view->GetCenter(), m_viewPosition,
|
||||
static_cast<VECTOR2D::coord_type>( FLT_EPSILON ) ) )
|
||||
if( !equals( m_view->GetCenter(), m_viewPosition, static_cast<VECTOR2D::coord_type>( FLT_EPSILON ) ) )
|
||||
{
|
||||
m_view->SetCenter( viewPos + m_view->GetCenter() - m_viewPosition );
|
||||
result = navlib::make_result_code( navlib::navlib_errc::error );
|
||||
@ -321,7 +323,7 @@ long NL_SCHEMATIC_PLUGIN_IMPL::SetCameraMatrix( const navlib::matrix_t& matrix )
|
||||
|
||||
long NL_SCHEMATIC_PLUGIN_IMPL::SetViewExtents( const navlib::box_t& extents )
|
||||
{
|
||||
if( m_view == nullptr )
|
||||
if( !m_view )
|
||||
return navlib::make_result_code( navlib::navlib_errc::invalid_operation );
|
||||
|
||||
long result = 0;
|
||||
@ -356,7 +358,7 @@ long NL_SCHEMATIC_PLUGIN_IMPL::SetViewFrustum( const navlib::frustum_t& frustum
|
||||
|
||||
long NL_SCHEMATIC_PLUGIN_IMPL::GetModelExtents( navlib::box_t& extents ) const
|
||||
{
|
||||
if( m_view == nullptr )
|
||||
if( !m_view )
|
||||
return navlib::make_result_code( navlib::navlib_errc::no_data_available );
|
||||
|
||||
BOX2I box = static_cast<SCH_BASE_FRAME*>( m_viewport2D->GetParent() )->GetDocumentExtents();
|
||||
@ -424,7 +426,7 @@ long NL_SCHEMATIC_PLUGIN_IMPL::SetActiveCommand( std::string commandId )
|
||||
context = action;
|
||||
}
|
||||
|
||||
if( context != nullptr )
|
||||
if( context )
|
||||
{
|
||||
wxWindow* parent = m_viewport2D->GetParent();
|
||||
|
||||
|
@ -63,6 +63,7 @@ NL_GERBVIEW_PLUGIN_IMPL::~NL_GERBVIEW_PLUGIN_IMPL()
|
||||
{
|
||||
std::error_code m_errCode;
|
||||
EnableNavigation( false, m_errCode );
|
||||
|
||||
if( m_errCode.value() != 0 )
|
||||
{
|
||||
wxLogTrace( wxT( "KI_TRACE_NAVLIB" ),
|
||||
@ -77,16 +78,12 @@ void NL_GERBVIEW_PLUGIN_IMPL::SetCanvas( EDA_DRAW_PANEL_GAL* aViewport )
|
||||
m_viewport2D = aViewport;
|
||||
|
||||
if( m_viewport2D == nullptr )
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
m_view = m_viewport2D->GetView();
|
||||
|
||||
if( m_view == nullptr )
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
m_viewportWidth = m_view->GetBoundary().GetWidth();
|
||||
|
||||
@ -145,7 +142,8 @@ static void add_category( const std::string& aCategoryPath, CATEGORY_STORE& aCat
|
||||
|
||||
aCategoryStore.try_emplace( aCategoryStore.end(), aCategoryPath, categoryNode.get() );
|
||||
|
||||
parent_iter->second->push_back( std::move( categoryNode ) );
|
||||
if( parent_iter != aCategoryStore.end() )
|
||||
parent_iter->second->push_back( std::move( categoryNode ) );
|
||||
}
|
||||
|
||||
|
||||
@ -160,9 +158,7 @@ static void add_category( const std::string& aCategoryPath, CATEGORY_STORE& aCat
|
||||
static void try_add_category( const std::string& aCategoryPath, CATEGORY_STORE& aCategoryStore )
|
||||
{
|
||||
if( !aCategoryStore.contains( aCategoryPath ) )
|
||||
{
|
||||
add_category( aCategoryPath, aCategoryStore );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -232,11 +228,13 @@ void NL_GERBVIEW_PLUGIN_IMPL::exportCommandsAndImages()
|
||||
}
|
||||
}
|
||||
|
||||
wxLogTrace( m_logTrace, wxT( "Inserting command: %s, description: %s, in category: %s" ),
|
||||
name, description, iter->first );
|
||||
if( iter != categoryStore.end() )
|
||||
{
|
||||
wxLogTrace( m_logTrace, wxT( "Inserting command: %s, description: %s, in category: %s" ),
|
||||
name, description, iter->first );
|
||||
|
||||
iter->second->push_back(
|
||||
CCommand( std::move( name ), std::move( label ), std::move( description ) ) );
|
||||
iter->second->push_back( CCommand( name, label, description ) );
|
||||
}
|
||||
}
|
||||
|
||||
NAV_3D::AddCommandSet( commandSet );
|
||||
@ -259,8 +257,7 @@ long NL_GERBVIEW_PLUGIN_IMPL::GetCameraMatrix( navlib::matrix_t& matrix ) const
|
||||
|
||||
// Note: the connexion has been configured as row vectors, the coordinate system is defined in
|
||||
// NL_GERBVIEW_PLUGIN_IMPL::GetCoordinateSystem and the front view in NL_GERBVIEW_PLUGIN_IMPL::GetFrontView.
|
||||
matrix = { { { x, 0, 0, 0, 0, y, 0, 0, 0, 0, z, 0, m_viewPosition.x, m_viewPosition.y, 0,
|
||||
1 } } };
|
||||
matrix = { { { x, 0, 0, 0, 0, y, 0, 0, 0, 0, z, 0, m_viewPosition.x, m_viewPosition.y, 0, 1 } } };
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -316,8 +313,7 @@ long NL_GERBVIEW_PLUGIN_IMPL::SetCameraMatrix( const navlib::matrix_t& matrix )
|
||||
long result = 0;
|
||||
VECTOR2D viewPos( matrix.m4x4[3][0], matrix.m4x4[3][1] );
|
||||
|
||||
if( !equals( m_view->GetCenter(), m_viewPosition,
|
||||
static_cast<VECTOR2D::coord_type>( FLT_EPSILON ) ) )
|
||||
if( !equals( m_view->GetCenter(), m_viewPosition, static_cast<VECTOR2D::coord_type>( FLT_EPSILON ) ) )
|
||||
{
|
||||
m_view->SetCenter( viewPos + m_view->GetCenter() - m_viewPosition );
|
||||
result = navlib::make_result_code( navlib::navlib_errc::error );
|
||||
@ -426,35 +422,26 @@ long NL_GERBVIEW_PLUGIN_IMPL::SetActiveCommand( std::string commandId )
|
||||
if( commandId.empty() )
|
||||
return 0;
|
||||
|
||||
if(m_viewport2D == nullptr)
|
||||
{
|
||||
if( !m_viewport2D )
|
||||
return navlib::make_result_code( navlib::navlib_errc::invalid_operation );
|
||||
}
|
||||
|
||||
wxWindow* parent = m_viewport2D->GetParent();
|
||||
|
||||
// Only allow command execution if the window is enabled. i.e. there is not a modal dialog
|
||||
// currently active.
|
||||
if( parent == nullptr || !parent->IsEnabled() )
|
||||
{
|
||||
if( !parent || !parent->IsEnabled() )
|
||||
return navlib::make_result_code( navlib::navlib_errc::invalid_operation );
|
||||
}
|
||||
|
||||
TOOL_MANAGER* tool_manager = dynamic_cast<TOOLS_HOLDER*>( parent )->GetToolManager();
|
||||
|
||||
// Only allow for command execution if the tool manager is accessible.
|
||||
if( tool_manager == nullptr )
|
||||
{
|
||||
if( !tool_manager )
|
||||
return navlib::make_result_code( navlib::navlib_errc::invalid_operation );
|
||||
}
|
||||
|
||||
for( std::list<TOOL_ACTION*> actions = ACTION_MANAGER::GetActionList();
|
||||
const auto action : actions )
|
||||
for( std::list<TOOL_ACTION*> actions = ACTION_MANAGER::GetActionList(); const auto action : actions )
|
||||
{
|
||||
if( action == nullptr )
|
||||
{
|
||||
if( !action )
|
||||
continue;
|
||||
}
|
||||
|
||||
if( commandId == action->GetName() )
|
||||
{
|
||||
@ -464,10 +451,8 @@ long NL_GERBVIEW_PLUGIN_IMPL::SetActiveCommand( std::string commandId )
|
||||
const ACTION_CONDITIONS* aCond =
|
||||
tool_manager->GetActionManager()->GetCondition( *action );
|
||||
|
||||
if( aCond == nullptr )
|
||||
{
|
||||
if( !aCond )
|
||||
return navlib::make_result_code( navlib::navlib_errc::invalid_operation );
|
||||
}
|
||||
|
||||
aCond->enableCondition( sel );
|
||||
tool_manager->RunAction( *action );
|
||||
|
@ -122,7 +122,8 @@ static void add_category( const std::string& aCategoryPath, CATEGORY_STORE& aCat
|
||||
|
||||
aCategoryStore.insert( aCategoryStore.end(), { aCategoryPath, categoryNode.get() } );
|
||||
|
||||
parent_iter->second->push_back( std::move( categoryNode ) );
|
||||
if( parent_iter != aCategoryStore.end() )
|
||||
parent_iter->second->push_back( std::move( categoryNode ) );
|
||||
}
|
||||
|
||||
|
||||
@ -203,11 +204,13 @@ void NL_PCBNEW_PLUGIN_IMPL::exportCommandsAndImages()
|
||||
}
|
||||
}
|
||||
|
||||
wxLogTrace( m_logTrace, wxT( "Inserting command: %s, description: %s, in category: %s" ),
|
||||
name, description, iter->first );
|
||||
if( iter != categoryStore.end() )
|
||||
{
|
||||
wxLogTrace( m_logTrace, wxT( "Inserting command: %s, description: %s, in category: %s" ),
|
||||
name, description, iter->first );
|
||||
|
||||
iter->second->push_back( CCommand( std::move( name ), std::move( label ),
|
||||
std::move( description ) ) );
|
||||
iter->second->push_back( CCommand( name, label, description ) );
|
||||
}
|
||||
}
|
||||
|
||||
NAV_3D::AddCommandSet( commandSet );
|
||||
@ -217,7 +220,7 @@ void NL_PCBNEW_PLUGIN_IMPL::exportCommandsAndImages()
|
||||
|
||||
long NL_PCBNEW_PLUGIN_IMPL::GetCameraMatrix( navlib::matrix_t& matrix ) const
|
||||
{
|
||||
if( m_view == nullptr )
|
||||
if( !m_view )
|
||||
return navlib::make_result_code( navlib::navlib_errc::no_data_available );
|
||||
|
||||
m_viewPosition = m_view->GetCenter();
|
||||
@ -237,7 +240,7 @@ long NL_PCBNEW_PLUGIN_IMPL::GetCameraMatrix( navlib::matrix_t& matrix ) const
|
||||
|
||||
long NL_PCBNEW_PLUGIN_IMPL::GetPointerPosition( navlib::point_t& position ) const
|
||||
{
|
||||
if( m_view == nullptr )
|
||||
if( !m_view )
|
||||
return navlib::make_result_code( navlib::navlib_errc::no_data_available );
|
||||
|
||||
VECTOR2D mouse_pointer = m_viewport2D->GetViewControls()->GetMousePosition();
|
||||
@ -252,7 +255,7 @@ long NL_PCBNEW_PLUGIN_IMPL::GetPointerPosition( navlib::point_t& position ) cons
|
||||
|
||||
long NL_PCBNEW_PLUGIN_IMPL::GetViewExtents( navlib::box_t& extents ) const
|
||||
{
|
||||
if( m_view == nullptr )
|
||||
if( !m_view )
|
||||
return navlib::make_result_code( navlib::navlib_errc::no_data_available );
|
||||
|
||||
double scale = m_viewport2D->GetGAL()->GetWorldScale();
|
||||
@ -281,14 +284,13 @@ long NL_PCBNEW_PLUGIN_IMPL::GetIsViewPerspective( navlib::bool_t& perspective )
|
||||
|
||||
long NL_PCBNEW_PLUGIN_IMPL::SetCameraMatrix( const navlib::matrix_t& matrix )
|
||||
{
|
||||
if( m_view == nullptr )
|
||||
if( !m_view )
|
||||
return navlib::make_result_code( navlib::navlib_errc::invalid_operation );
|
||||
|
||||
long result = 0;
|
||||
VECTOR2D viewPos( matrix.m4x4[3][0], matrix.m4x4[3][1] );
|
||||
|
||||
if( !equals( m_view->GetCenter(), m_viewPosition,
|
||||
static_cast<VECTOR2D::coord_type>( FLT_EPSILON ) ) )
|
||||
if( !equals( m_view->GetCenter(), m_viewPosition, static_cast<VECTOR2D::coord_type>( FLT_EPSILON ) ) )
|
||||
{
|
||||
m_view->SetCenter( viewPos + m_view->GetCenter() - m_viewPosition );
|
||||
result = navlib::make_result_code( navlib::navlib_errc::error );
|
||||
@ -306,7 +308,7 @@ long NL_PCBNEW_PLUGIN_IMPL::SetCameraMatrix( const navlib::matrix_t& matrix )
|
||||
|
||||
long NL_PCBNEW_PLUGIN_IMPL::SetViewExtents( const navlib::box_t& extents )
|
||||
{
|
||||
if( m_view == nullptr )
|
||||
if( !m_view )
|
||||
return navlib::make_result_code( navlib::navlib_errc::invalid_operation );
|
||||
|
||||
long result = 0;
|
||||
@ -341,7 +343,7 @@ long NL_PCBNEW_PLUGIN_IMPL::SetViewFrustum( const navlib::frustum_t& frustum )
|
||||
|
||||
long NL_PCBNEW_PLUGIN_IMPL::GetModelExtents( navlib::box_t& extents ) const
|
||||
{
|
||||
if( m_view == nullptr )
|
||||
if( !m_view )
|
||||
return navlib::make_result_code( navlib::navlib_errc::no_data_available );
|
||||
|
||||
BOX2I box = static_cast<PCB_BASE_FRAME*>( m_viewport2D->GetParent() )->GetDocumentExtents();
|
||||
@ -409,7 +411,7 @@ long NL_PCBNEW_PLUGIN_IMPL::SetActiveCommand( std::string commandId )
|
||||
context = action;
|
||||
}
|
||||
|
||||
if( context != nullptr )
|
||||
if( context )
|
||||
{
|
||||
wxWindow* parent = m_viewport2D->GetParent();
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user