mirror of
https://gitlab.com/kicad/code/kicad.git
synced 2025-09-14 02:03:12 +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 )
|
if( (int) usedBuffers() >= maxBuffers )
|
||||||
{
|
{
|
||||||
throw std::runtime_error( "Cannot create more framebuffers. OpenGL rendering backend "
|
throw std::runtime_error( "Cannot create more framebuffers. OpenGL rendering backend requires at "
|
||||||
"requires at least 3 framebuffers. You may try to update/change "
|
"least 3 framebuffers. You may try to update/change your graphic drivers." );
|
||||||
"your graphic drivers." );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
glGetIntegerv( GL_MAX_TEXTURE_SIZE, (GLint*) &maxTextureSize );
|
glGetIntegerv( GL_MAX_TEXTURE_SIZE, (GLint*) &maxTextureSize );
|
||||||
|
|
||||||
if( maxTextureSize < (int) aDimensions.x || maxTextureSize < (int) aDimensions.y )
|
if( maxTextureSize < (int) aDimensions.x || maxTextureSize < (int) aDimensions.y )
|
||||||
{
|
{
|
||||||
throw std::runtime_error( "Requested texture size is not supported. "
|
throw std::runtime_error( "Requested texture size is not supported. Could not create a buffer." );
|
||||||
"Could not create a buffer." );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// GL_COLOR_ATTACHMENTn are consecutive integers
|
// GL_COLOR_ATTACHMENTn are consecutive integers
|
||||||
@ -197,16 +195,14 @@ unsigned int OPENGL_COMPOSITOR::CreateBuffer( VECTOR2I aDimensions )
|
|||||||
|
|
||||||
// Set texture parameters
|
// Set texture parameters
|
||||||
glTexEnvf( GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE );
|
glTexEnvf( GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE );
|
||||||
glTexImage2D( GL_TEXTURE_2D, 0, GL_RGBA8, aDimensions.x, aDimensions.y, 0, GL_RGBA,
|
glTexImage2D( GL_TEXTURE_2D, 0, GL_RGBA8, aDimensions.x, aDimensions.y, 0, GL_RGBA, GL_UNSIGNED_BYTE, nullptr );
|
||||||
GL_UNSIGNED_BYTE, nullptr );
|
|
||||||
checkGlError( "creating framebuffer texture", __FILE__, __LINE__ );
|
checkGlError( "creating framebuffer texture", __FILE__, __LINE__ );
|
||||||
glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST );
|
glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST );
|
||||||
glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MIN_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
|
// Bind the texture to the specific attachment point, clear and rebind the screen
|
||||||
bindFb( m_mainFbo );
|
bindFb( m_mainFbo );
|
||||||
glFramebufferTexture2DEXT( GL_FRAMEBUFFER_EXT, attachmentPoint, GL_TEXTURE_2D, textureTarget,
|
glFramebufferTexture2DEXT( GL_FRAMEBUFFER_EXT, attachmentPoint, GL_TEXTURE_2D, textureTarget, 0 );
|
||||||
0 );
|
|
||||||
|
|
||||||
// Check the status, exit if the framebuffer can't be created
|
// Check the status, exit if the framebuffer can't be created
|
||||||
GLenum status = glCheckFramebufferStatusEXT( GL_FRAMEBUFFER_EXT );
|
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." );
|
throw std::runtime_error( "No images attached to the framebuffer." );
|
||||||
|
|
||||||
case GL_FRAMEBUFFER_INCOMPLETE_DRAW_BUFFER_EXT:
|
case GL_FRAMEBUFFER_INCOMPLETE_DRAW_BUFFER_EXT:
|
||||||
throw std::runtime_error( "The framebuffer does not have at least one "
|
throw std::runtime_error( "The framebuffer does not have at least one image attached to it." );
|
||||||
"image attached to it." );
|
|
||||||
|
|
||||||
case GL_FRAMEBUFFER_INCOMPLETE_READ_BUFFER_EXT:
|
case GL_FRAMEBUFFER_INCOMPLETE_READ_BUFFER_EXT:
|
||||||
throw std::runtime_error( "The framebuffer read buffer is incomplete." );
|
throw std::runtime_error( "The framebuffer read buffer is incomplete." );
|
||||||
|
|
||||||
case GL_FRAMEBUFFER_UNSUPPORTED_EXT:
|
case GL_FRAMEBUFFER_UNSUPPORTED_EXT:
|
||||||
throw std::runtime_error( "The combination of internal formats of the attached "
|
throw std::runtime_error( "The combination of internal formats of the attached images violates "
|
||||||
"images violates an implementation-dependent set of "
|
"an implementation-dependent set of restrictions." );
|
||||||
"restrictions." );
|
|
||||||
|
|
||||||
case GL_FRAMEBUFFER_INCOMPLETE_MULTISAMPLE_EXT:
|
case GL_FRAMEBUFFER_INCOMPLETE_MULTISAMPLE_EXT:
|
||||||
throw std::runtime_error( "GL_RENDERBUFFER_SAMPLES is not the same for "
|
throw std::runtime_error( "GL_RENDERBUFFER_SAMPLES is not the same for all attached renderbuffers" );
|
||||||
"all attached renderbuffers" );
|
|
||||||
|
|
||||||
case GL_FRAMEBUFFER_INCOMPLETE_LAYER_TARGETS_EXT:
|
case GL_FRAMEBUFFER_INCOMPLETE_LAYER_TARGETS_EXT:
|
||||||
throw std::runtime_error( "Framebuffer incomplete layer targets errors." );
|
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 )
|
GLenum OPENGL_COMPOSITOR::GetBufferTexture( unsigned int aBufferHandle )
|
||||||
{
|
{
|
||||||
wxASSERT( aBufferHandle > 0 && aBufferHandle <= usedBuffers() );
|
wxCHECK( aBufferHandle > 0 && aBufferHandle <= usedBuffers(), 0 );
|
||||||
return m_buffers[aBufferHandle - 1].textureTarget;
|
return m_buffers[aBufferHandle - 1].textureTarget;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void OPENGL_COMPOSITOR::SetBuffer( unsigned int aBufferHandle )
|
void OPENGL_COMPOSITOR::SetBuffer( unsigned int aBufferHandle )
|
||||||
{
|
{
|
||||||
wxASSERT( m_initialized );
|
wxCHECK( m_initialized && aBufferHandle <= usedBuffers(), /* void */ );
|
||||||
wxASSERT( aBufferHandle <= usedBuffers() );
|
|
||||||
|
|
||||||
// Either unbind the FBO for direct rendering, or bind the one with target textures
|
// Either unbind the FBO for direct rendering, or bind the one with target textures
|
||||||
bindFb( aBufferHandle == DIRECT_RENDERING ? DIRECT_RENDERING : m_mainFbo );
|
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 );
|
glDrawBuffer( m_buffers[m_curBuffer].attachmentPoint );
|
||||||
checkGlError( "setting draw buffer", __FILE__, __LINE__ );
|
checkGlError( "setting draw buffer", __FILE__, __LINE__ );
|
||||||
|
|
||||||
glViewport( 0, 0, m_buffers[m_curBuffer].dimensions.x,
|
glViewport( 0, 0, m_buffers[m_curBuffer].dimensions.x, m_buffers[m_curBuffer].dimensions.y );
|
||||||
m_buffers[m_curBuffer].dimensions.y );
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -295,7 +286,7 @@ void OPENGL_COMPOSITOR::SetBuffer( unsigned int aBufferHandle )
|
|||||||
|
|
||||||
void OPENGL_COMPOSITOR::ClearBuffer( const COLOR4D& aColor )
|
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 );
|
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 );
|
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 )
|
void OPENGL_COMPOSITOR::DrawBuffer( unsigned int aSourceHandle, unsigned int aDestHandle )
|
||||||
{
|
{
|
||||||
wxASSERT( m_initialized );
|
wxCHECK( m_initialized && aSourceHandle != 0 && aSourceHandle <= usedBuffers(), /* void */ );
|
||||||
wxASSERT( aSourceHandle != 0 && aSourceHandle <= usedBuffers() );
|
wxCHECK( aDestHandle <= usedBuffers(), /* void */ );
|
||||||
wxASSERT( aDestHandle <= usedBuffers() );
|
|
||||||
|
|
||||||
// Switch to the destination buffer and blit the scene
|
// Switch to the destination buffer and blit the scene
|
||||||
SetBuffer( aDestHandle );
|
SetBuffer( aDestHandle );
|
||||||
@ -393,7 +383,7 @@ void OPENGL_COMPOSITOR::bindFb( unsigned int aFb )
|
|||||||
|
|
||||||
void OPENGL_COMPOSITOR::clean()
|
void OPENGL_COMPOSITOR::clean()
|
||||||
{
|
{
|
||||||
wxASSERT( m_initialized );
|
wxCHECK( m_initialized, /* void */ );
|
||||||
|
|
||||||
bindFb( DIRECT_RENDERING );
|
bindFb( DIRECT_RENDERING );
|
||||||
|
|
||||||
|
@ -799,9 +799,7 @@ void ACTION_TOOLBAR::popupPalette( wxAuiToolBarItem* aItem )
|
|||||||
|
|
||||||
wxWindow* toolParent = dynamic_cast<wxWindow*>( m_toolManager->GetToolHolder() );
|
wxWindow* toolParent = dynamic_cast<wxWindow*>( m_toolManager->GetToolHolder() );
|
||||||
|
|
||||||
wxASSERT( GetParent() );
|
wxCHECK( GetParent() && m_auiManager && toolParent, /* void */ );
|
||||||
wxASSERT( m_auiManager );
|
|
||||||
wxASSERT( toolParent );
|
|
||||||
|
|
||||||
// Ensure the item we are using for the palette has a group associated with it.
|
// Ensure the item we are using for the palette has a group associated with it.
|
||||||
const auto it = m_actionGroups.find( aItem->GetId() );
|
const auto it = m_actionGroups.find( aItem->GetId() );
|
||||||
|
@ -192,7 +192,8 @@ void CVPCB_MAINFRAME::AutomaticFootprintMatching()
|
|||||||
error_msg.Empty();
|
error_msg.Empty();
|
||||||
|
|
||||||
bool firstAssoc = true;
|
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 );
|
COMPONENT* component = m_netlist.GetComponent( kk );
|
||||||
|
|
||||||
@ -207,37 +208,29 @@ void CVPCB_MAINFRAME::AutomaticFootprintMatching()
|
|||||||
// for example)
|
// for example)
|
||||||
wxString fpid_candidate;
|
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];
|
FOOTPRINT_EQUIVALENCE& equivItem = equivList[idx];
|
||||||
|
|
||||||
if( equivItem.m_ComponentValue.CmpNoCase( component->GetValue() ) != 0 )
|
if( equivItem.m_ComponentValue.CmpNoCase( component->GetValue() ) != 0 )
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
const FOOTPRINT_INFO* fp =
|
const FOOTPRINT_INFO* fp = m_FootprintsList->GetFootprintInfo( equivItem.m_FootprintFPID );
|
||||||
m_FootprintsList->GetFootprintInfo( equivItem.m_FootprintFPID );
|
|
||||||
|
|
||||||
bool equ_is_unique = true;
|
bool equ_is_unique = true;
|
||||||
unsigned next = idx+1;
|
int next = idx+1;
|
||||||
int previous = idx-1;
|
int previous = idx-1;
|
||||||
|
|
||||||
if( next < equivList.size()
|
if( next < (int) equivList.size() && equivItem.m_ComponentValue == equivList[next].m_ComponentValue )
|
||||||
&& equivItem.m_ComponentValue == equivList[next].m_ComponentValue )
|
|
||||||
{
|
|
||||||
equ_is_unique = false;
|
equ_is_unique = false;
|
||||||
}
|
|
||||||
|
|
||||||
if( previous >= 0
|
if( previous >= 0 && equivItem.m_ComponentValue == equivList[previous].m_ComponentValue )
|
||||||
&& equivItem.m_ComponentValue == equivList[previous].m_ComponentValue )
|
|
||||||
{
|
|
||||||
equ_is_unique = false;
|
equ_is_unique = false;
|
||||||
}
|
|
||||||
|
|
||||||
// If the equivalence is unique, no ambiguity: use the association
|
// If the equivalence is unique, no ambiguity: use the association
|
||||||
if( fp && equ_is_unique )
|
if( fp && equ_is_unique )
|
||||||
{
|
{
|
||||||
AssociateFootprint( CVPCB_ASSOCIATION( kk, equivItem.m_FootprintFPID ),
|
AssociateFootprint( CVPCB_ASSOCIATION( kk, equivItem.m_FootprintFPID ), firstAssoc );
|
||||||
firstAssoc );
|
|
||||||
firstAssoc = false;
|
firstAssoc = false;
|
||||||
found = true;
|
found = true;
|
||||||
break;
|
break;
|
||||||
@ -254,18 +247,18 @@ void CVPCB_MAINFRAME::AutomaticFootprintMatching()
|
|||||||
if( fp )
|
if( fp )
|
||||||
{
|
{
|
||||||
size_t filtercount = component->GetFootprintFilters().GetCount();
|
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++ )
|
for( size_t jj = 0; jj < filtercount && !found; jj++ )
|
||||||
found = fp->GetFootprintName().Matches( component->GetFootprintFilters()[jj] );
|
found = fp->GetFootprintName().Matches( component->GetFootprintFilters()[jj] );
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
msg.Printf( _( "Component %s: footprint %s not found in any of the project "
|
msg.Printf( _( "Component %s: footprint %s not found in any of the project footprint libraries." ),
|
||||||
"footprint libraries." ),
|
component->GetReference(),
|
||||||
component->GetReference(), equivItem.m_FootprintFPID );
|
equivItem.m_FootprintFPID );
|
||||||
|
|
||||||
if( ! error_msg.IsEmpty() )
|
if( !error_msg.IsEmpty() )
|
||||||
error_msg << wxT("\n\n");
|
error_msg << wxT("\n\n");
|
||||||
|
|
||||||
error_msg += msg;
|
error_msg += msg;
|
||||||
@ -273,8 +266,7 @@ void CVPCB_MAINFRAME::AutomaticFootprintMatching()
|
|||||||
|
|
||||||
if( found )
|
if( found )
|
||||||
{
|
{
|
||||||
AssociateFootprint( CVPCB_ASSOCIATION( kk, equivItem.m_FootprintFPID ),
|
AssociateFootprint( CVPCB_ASSOCIATION( kk, equivItem.m_FootprintFPID ), firstAssoc );
|
||||||
firstAssoc );
|
|
||||||
firstAssoc = false;
|
firstAssoc = false;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -292,14 +284,13 @@ void CVPCB_MAINFRAME::AutomaticFootprintMatching()
|
|||||||
}
|
}
|
||||||
|
|
||||||
// obviously the last chance: there's only one filter matching one footprint
|
// 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
|
// we do not need to analyze wildcards: single footprint do not
|
||||||
// contain them and if there are wildcards it just will not match any
|
// contain them and if there are wildcards it just will not match any
|
||||||
if( m_FootprintsList->GetFootprintInfo( component->GetFootprintFilters()[0] ) )
|
if( m_FootprintsList->GetFootprintInfo( component->GetFootprintFilters()[0] ) )
|
||||||
{
|
{
|
||||||
AssociateFootprint( CVPCB_ASSOCIATION( kk, component->GetFootprintFilters()[0] ),
|
AssociateFootprint( CVPCB_ASSOCIATION( kk, component->GetFootprintFilters()[0] ), firstAssoc );
|
||||||
firstAssoc );
|
|
||||||
firstAssoc = false;
|
firstAssoc = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -138,7 +138,8 @@ static void add_category( const std::string& aCategoryPath, CATEGORY_STORE& aCat
|
|||||||
|
|
||||||
aCategoryStore.insert( aCategoryStore.end(), { aCategoryPath, categoryNode.get() } );
|
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" ),
|
if( iter != categoryStore.end() )
|
||||||
name, description, iter->first );
|
{
|
||||||
|
wxLogTrace( m_logTrace, wxT( "Inserting command: %s, description: %s, in category: %s" ),
|
||||||
|
name, description, iter->first );
|
||||||
|
|
||||||
iter->second->push_back(
|
iter->second->push_back( CCommand( name, label, description ) );
|
||||||
CCommand( std::move( name ), std::move( label ), std::move( description ) ) );
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
NAV_3D::AddCommandSet( commandSet );
|
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
|
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 );
|
return navlib::make_result_code( navlib::navlib_errc::no_data_available );
|
||||||
|
|
||||||
m_viewPosition = m_view->GetCenter();
|
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
|
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 );
|
return navlib::make_result_code( navlib::navlib_errc::no_data_available );
|
||||||
|
|
||||||
VECTOR2D mouse_pointer = m_viewport2D->GetViewControls()->GetMousePosition();
|
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
|
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 );
|
return navlib::make_result_code( navlib::navlib_errc::no_data_available );
|
||||||
|
|
||||||
double scale = m_viewport2D->GetGAL()->GetWorldScale();
|
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 )
|
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 );
|
return navlib::make_result_code( navlib::navlib_errc::invalid_operation );
|
||||||
|
|
||||||
long result = 0;
|
long result = 0;
|
||||||
VECTOR2D viewPos( matrix.m4x4[3][0], matrix.m4x4[3][1] );
|
VECTOR2D viewPos( matrix.m4x4[3][0], matrix.m4x4[3][1] );
|
||||||
|
|
||||||
if( !equals( m_view->GetCenter(), m_viewPosition,
|
if( !equals( m_view->GetCenter(), m_viewPosition, static_cast<VECTOR2D::coord_type>( FLT_EPSILON ) ) )
|
||||||
static_cast<VECTOR2D::coord_type>( FLT_EPSILON ) ) )
|
|
||||||
{
|
{
|
||||||
m_view->SetCenter( viewPos + m_view->GetCenter() - m_viewPosition );
|
m_view->SetCenter( viewPos + m_view->GetCenter() - m_viewPosition );
|
||||||
result = navlib::make_result_code( navlib::navlib_errc::error );
|
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 )
|
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 );
|
return navlib::make_result_code( navlib::navlib_errc::invalid_operation );
|
||||||
|
|
||||||
long result = 0;
|
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
|
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 );
|
return navlib::make_result_code( navlib::navlib_errc::no_data_available );
|
||||||
|
|
||||||
BOX2I box = static_cast<SCH_BASE_FRAME*>( m_viewport2D->GetParent() )->GetDocumentExtents();
|
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;
|
context = action;
|
||||||
}
|
}
|
||||||
|
|
||||||
if( context != nullptr )
|
if( context )
|
||||||
{
|
{
|
||||||
wxWindow* parent = m_viewport2D->GetParent();
|
wxWindow* parent = m_viewport2D->GetParent();
|
||||||
|
|
||||||
|
@ -63,6 +63,7 @@ NL_GERBVIEW_PLUGIN_IMPL::~NL_GERBVIEW_PLUGIN_IMPL()
|
|||||||
{
|
{
|
||||||
std::error_code m_errCode;
|
std::error_code m_errCode;
|
||||||
EnableNavigation( false, m_errCode );
|
EnableNavigation( false, m_errCode );
|
||||||
|
|
||||||
if( m_errCode.value() != 0 )
|
if( m_errCode.value() != 0 )
|
||||||
{
|
{
|
||||||
wxLogTrace( wxT( "KI_TRACE_NAVLIB" ),
|
wxLogTrace( wxT( "KI_TRACE_NAVLIB" ),
|
||||||
@ -77,16 +78,12 @@ void NL_GERBVIEW_PLUGIN_IMPL::SetCanvas( EDA_DRAW_PANEL_GAL* aViewport )
|
|||||||
m_viewport2D = aViewport;
|
m_viewport2D = aViewport;
|
||||||
|
|
||||||
if( m_viewport2D == nullptr )
|
if( m_viewport2D == nullptr )
|
||||||
{
|
|
||||||
return;
|
return;
|
||||||
}
|
|
||||||
|
|
||||||
m_view = m_viewport2D->GetView();
|
m_view = m_viewport2D->GetView();
|
||||||
|
|
||||||
if( m_view == nullptr )
|
if( m_view == nullptr )
|
||||||
{
|
|
||||||
return;
|
return;
|
||||||
}
|
|
||||||
|
|
||||||
m_viewportWidth = m_view->GetBoundary().GetWidth();
|
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() );
|
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 )
|
static void try_add_category( const std::string& aCategoryPath, CATEGORY_STORE& aCategoryStore )
|
||||||
{
|
{
|
||||||
if( !aCategoryStore.contains( aCategoryPath ) )
|
if( !aCategoryStore.contains( aCategoryPath ) )
|
||||||
{
|
|
||||||
add_category( aCategoryPath, aCategoryStore );
|
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" ),
|
if( iter != categoryStore.end() )
|
||||||
name, description, iter->first );
|
{
|
||||||
|
wxLogTrace( m_logTrace, wxT( "Inserting command: %s, description: %s, in category: %s" ),
|
||||||
|
name, description, iter->first );
|
||||||
|
|
||||||
iter->second->push_back(
|
iter->second->push_back( CCommand( name, label, description ) );
|
||||||
CCommand( std::move( name ), std::move( label ), std::move( description ) ) );
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
NAV_3D::AddCommandSet( commandSet );
|
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
|
// 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.
|
// 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,
|
matrix = { { { x, 0, 0, 0, 0, y, 0, 0, 0, 0, z, 0, m_viewPosition.x, m_viewPosition.y, 0, 1 } } };
|
||||||
1 } } };
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -316,8 +313,7 @@ long NL_GERBVIEW_PLUGIN_IMPL::SetCameraMatrix( const navlib::matrix_t& matrix )
|
|||||||
long result = 0;
|
long result = 0;
|
||||||
VECTOR2D viewPos( matrix.m4x4[3][0], matrix.m4x4[3][1] );
|
VECTOR2D viewPos( matrix.m4x4[3][0], matrix.m4x4[3][1] );
|
||||||
|
|
||||||
if( !equals( m_view->GetCenter(), m_viewPosition,
|
if( !equals( m_view->GetCenter(), m_viewPosition, static_cast<VECTOR2D::coord_type>( FLT_EPSILON ) ) )
|
||||||
static_cast<VECTOR2D::coord_type>( FLT_EPSILON ) ) )
|
|
||||||
{
|
{
|
||||||
m_view->SetCenter( viewPos + m_view->GetCenter() - m_viewPosition );
|
m_view->SetCenter( viewPos + m_view->GetCenter() - m_viewPosition );
|
||||||
result = navlib::make_result_code( navlib::navlib_errc::error );
|
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() )
|
if( commandId.empty() )
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
if(m_viewport2D == nullptr)
|
if( !m_viewport2D )
|
||||||
{
|
|
||||||
return navlib::make_result_code( navlib::navlib_errc::invalid_operation );
|
return navlib::make_result_code( navlib::navlib_errc::invalid_operation );
|
||||||
}
|
|
||||||
|
|
||||||
wxWindow* parent = m_viewport2D->GetParent();
|
wxWindow* parent = m_viewport2D->GetParent();
|
||||||
|
|
||||||
// Only allow command execution if the window is enabled. i.e. there is not a modal dialog
|
// Only allow command execution if the window is enabled. i.e. there is not a modal dialog
|
||||||
// currently active.
|
// currently active.
|
||||||
if( parent == nullptr || !parent->IsEnabled() )
|
if( !parent || !parent->IsEnabled() )
|
||||||
{
|
|
||||||
return navlib::make_result_code( navlib::navlib_errc::invalid_operation );
|
return navlib::make_result_code( navlib::navlib_errc::invalid_operation );
|
||||||
}
|
|
||||||
|
|
||||||
TOOL_MANAGER* tool_manager = dynamic_cast<TOOLS_HOLDER*>( parent )->GetToolManager();
|
TOOL_MANAGER* tool_manager = dynamic_cast<TOOLS_HOLDER*>( parent )->GetToolManager();
|
||||||
|
|
||||||
// Only allow for command execution if the tool manager is accessible.
|
// 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 );
|
return navlib::make_result_code( navlib::navlib_errc::invalid_operation );
|
||||||
}
|
|
||||||
|
|
||||||
for( std::list<TOOL_ACTION*> actions = ACTION_MANAGER::GetActionList();
|
for( std::list<TOOL_ACTION*> actions = ACTION_MANAGER::GetActionList(); const auto action : actions )
|
||||||
const auto action : actions )
|
|
||||||
{
|
{
|
||||||
if( action == nullptr )
|
if( !action )
|
||||||
{
|
|
||||||
continue;
|
continue;
|
||||||
}
|
|
||||||
|
|
||||||
if( commandId == action->GetName() )
|
if( commandId == action->GetName() )
|
||||||
{
|
{
|
||||||
@ -464,10 +451,8 @@ long NL_GERBVIEW_PLUGIN_IMPL::SetActiveCommand( std::string commandId )
|
|||||||
const ACTION_CONDITIONS* aCond =
|
const ACTION_CONDITIONS* aCond =
|
||||||
tool_manager->GetActionManager()->GetCondition( *action );
|
tool_manager->GetActionManager()->GetCondition( *action );
|
||||||
|
|
||||||
if( aCond == nullptr )
|
if( !aCond )
|
||||||
{
|
|
||||||
return navlib::make_result_code( navlib::navlib_errc::invalid_operation );
|
return navlib::make_result_code( navlib::navlib_errc::invalid_operation );
|
||||||
}
|
|
||||||
|
|
||||||
aCond->enableCondition( sel );
|
aCond->enableCondition( sel );
|
||||||
tool_manager->RunAction( *action );
|
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() } );
|
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" ),
|
if( iter != categoryStore.end() )
|
||||||
name, description, iter->first );
|
{
|
||||||
|
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 ),
|
iter->second->push_back( CCommand( name, label, description ) );
|
||||||
std::move( description ) ) );
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
NAV_3D::AddCommandSet( commandSet );
|
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
|
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 );
|
return navlib::make_result_code( navlib::navlib_errc::no_data_available );
|
||||||
|
|
||||||
m_viewPosition = m_view->GetCenter();
|
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
|
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 );
|
return navlib::make_result_code( navlib::navlib_errc::no_data_available );
|
||||||
|
|
||||||
VECTOR2D mouse_pointer = m_viewport2D->GetViewControls()->GetMousePosition();
|
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
|
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 );
|
return navlib::make_result_code( navlib::navlib_errc::no_data_available );
|
||||||
|
|
||||||
double scale = m_viewport2D->GetGAL()->GetWorldScale();
|
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 )
|
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 );
|
return navlib::make_result_code( navlib::navlib_errc::invalid_operation );
|
||||||
|
|
||||||
long result = 0;
|
long result = 0;
|
||||||
VECTOR2D viewPos( matrix.m4x4[3][0], matrix.m4x4[3][1] );
|
VECTOR2D viewPos( matrix.m4x4[3][0], matrix.m4x4[3][1] );
|
||||||
|
|
||||||
if( !equals( m_view->GetCenter(), m_viewPosition,
|
if( !equals( m_view->GetCenter(), m_viewPosition, static_cast<VECTOR2D::coord_type>( FLT_EPSILON ) ) )
|
||||||
static_cast<VECTOR2D::coord_type>( FLT_EPSILON ) ) )
|
|
||||||
{
|
{
|
||||||
m_view->SetCenter( viewPos + m_view->GetCenter() - m_viewPosition );
|
m_view->SetCenter( viewPos + m_view->GetCenter() - m_viewPosition );
|
||||||
result = navlib::make_result_code( navlib::navlib_errc::error );
|
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 )
|
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 );
|
return navlib::make_result_code( navlib::navlib_errc::invalid_operation );
|
||||||
|
|
||||||
long result = 0;
|
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
|
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 );
|
return navlib::make_result_code( navlib::navlib_errc::no_data_available );
|
||||||
|
|
||||||
BOX2I box = static_cast<PCB_BASE_FRAME*>( m_viewport2D->GetParent() )->GetDocumentExtents();
|
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;
|
context = action;
|
||||||
}
|
}
|
||||||
|
|
||||||
if( context != nullptr )
|
if( context )
|
||||||
{
|
{
|
||||||
wxWindow* parent = m_viewport2D->GetParent();
|
wxWindow* parent = m_viewport2D->GetParent();
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user