Compare commits

..

1 Commits

Author SHA1 Message Date
Wayne Stambaugh ef49d83bc1 Begin version 10 development. 2025-02-19 11:01:40 -05:00
943 changed files with 274631 additions and 295695 deletions
-2
View File
@@ -24,7 +24,6 @@ common/template_fieldnames_lexer.h
eeschema/schematic_keywords.*
pcbnew/pcb_plot_params_keywords.cpp
pcbnew/pcb_plot_params_lexer.h
pcbnew/dialogs/panel_setup_rules_help_*.h
Makefile
CMakeUserPresets.json
CMakeCache.txt
@@ -52,7 +51,6 @@ common/pcb_keywords.cpp
include/pcb_lexer.h
fp-info-cache
qa/tests/output/**
qa/tests/cli/output/**
# demo project auxiliary files
demos/**/*-bak
+6 -7
View File
@@ -141,13 +141,12 @@ S3D_CACHE::~S3D_CACHE()
SCENEGRAPH* S3D_CACHE::load( const wxString& aModelFile, const wxString& aBasePath,
S3D_CACHE_ENTRY** aCachePtr,
std::vector<const EMBEDDED_FILES*> aEmbeddedFilesStack )
S3D_CACHE_ENTRY** aCachePtr, const EMBEDDED_FILES* aEmbeddedFiles )
{
if( aCachePtr )
*aCachePtr = nullptr;
wxString full3Dpath = m_FNResolver->ResolvePath( aModelFile, aBasePath, aEmbeddedFilesStack );
wxString full3Dpath = m_FNResolver->ResolvePath( aModelFile, aBasePath, aEmbeddedFiles );
if( full3Dpath.empty() )
{
@@ -213,9 +212,9 @@ SCENEGRAPH* S3D_CACHE::load( const wxString& aModelFile, const wxString& aBasePa
SCENEGRAPH* S3D_CACHE::Load( const wxString& aModelFile, const wxString& aBasePath,
std::vector<const EMBEDDED_FILES*> aEmbeddedFilesStack )
const EMBEDDED_FILES* aEmbeddedFiles )
{
return load( aModelFile, aBasePath, nullptr, aEmbeddedFilesStack );
return load( aModelFile, aBasePath, nullptr, aEmbeddedFiles );
}
@@ -549,10 +548,10 @@ void S3D_CACHE::ClosePlugins()
S3DMODEL* S3D_CACHE::GetModel( const wxString& aModelFileName, const wxString& aBasePath,
std::vector<const EMBEDDED_FILES*> aEmbeddedFilesStack )
const EMBEDDED_FILES* aEmbeddedFiles )
{
S3D_CACHE_ENTRY* cp = nullptr;
SCENEGRAPH* sp = load( aModelFileName, aBasePath, &cp, aEmbeddedFilesStack );
SCENEGRAPH* sp = load( aModelFileName, aBasePath, &cp, aEmbeddedFiles );
if( !sp )
return nullptr;
+5 -7
View File
@@ -95,12 +95,11 @@ public:
*
* @param aModelFile is the partial or full path to the model to be loaded.
* @param aBasePath is the path to search for any relative files
* @param aEmbeddedFilesStack is a list of pointers to the embedded files list. They will
* be searched from the front of the list.
* @param aEmbeddedFiles is a pointer to the embedded files list.
* @return true if the model was successfully loaded, otherwise false.
*/
SCENEGRAPH* Load( const wxString& aModelFile, const wxString& aBasePath,
std::vector<const EMBEDDED_FILES*> aEmbeddedFilesStack );
const EMBEDDED_FILES* aEmbeddedFiles );
FILENAME_RESOLVER* GetResolver() noexcept;
@@ -129,12 +128,11 @@ public:
*
* @param aModelFileName is the full path to the model to be loaded.
* @param aBasePath is the path to search for any relative files.
* @param aEmbeddedFilesStack is a stack of pointers to the embedded files lists. They will
* be searched from the bottom of the stack.
* @param aEmbeddedFiles is a pointer to the embedded files list.
* @return is a pointer to the render data or NULL if not available.
*/
S3DMODEL* GetModel( const wxString& aModelFileName, const wxString& aBasePath,
std::vector<const EMBEDDED_FILES*> aEmbeddedFilesStack );
const EMBEDDED_FILES* aEmbeddedFiles );
/**
* Delete up old cache files in cache directory.
@@ -176,7 +174,7 @@ private:
// the real load function (can supply a cache entry pointer to member functions)
SCENEGRAPH* load( const wxString& aModelFile, const wxString& aBasePath,
S3D_CACHE_ENTRY** aCachePtr = nullptr,
std::vector<const EMBEDDED_FILES*> aEmbeddedFilesStack = {} );
const EMBEDDED_FILES* aEmbeddedFiles = nullptr );
/// Cache entries.
std::list< S3D_CACHE_ENTRY* > m_CacheList;
+73 -101
View File
@@ -91,6 +91,7 @@ BOARD_ADAPTER::BOARD_ADAPTER() :
m_IsPreviewer( false ),
m_board( nullptr ),
m_3dModelManager( nullptr ),
m_colors( nullptr ),
m_layerZcoordTop(),
m_layerZcoordBottom()
{
@@ -136,14 +137,13 @@ BOARD_ADAPTER::BOARD_ADAPTER() :
m_ECO1Color = SFVEC4F( 0.70, 0.10, 0.10, 1.0 );
m_ECO2Color = SFVEC4F( 0.70, 0.10, 0.10, 1.0 );
for( int ii = 0; ii < 45; ++ii )
m_UserDefinedLayerColor[ii] = SFVEC4F( 0.70, 0.10, 0.10, 1.0 );
m_platedPadsFront = nullptr;
m_platedPadsBack = nullptr;
m_offboardPadsFront = nullptr;
m_offboardPadsBack = nullptr;
m_frontPlatedPadAndGraphicPolys = nullptr;
m_backPlatedPadAndGraphicPolys = nullptr;
m_frontPlatedCopperPolys = nullptr;
m_backPlatedCopperPolys = nullptr;
@@ -229,12 +229,11 @@ void BOARD_ADAPTER::ReloadColorSettings() noexcept
SETTINGS_MANAGER& mgr = Pgm().GetSettingsManager();
PCBNEW_SETTINGS* cfg = mgr.GetAppSettings<PCBNEW_SETTINGS>( "pcbnew" );
COLOR_SETTINGS* colors = mgr.GetColorSettings( cfg ? cfg->m_ColorTheme : wxString( "" ) );
if( colors )
if( cfg )
{
for( int layer = F_Cu; layer < PCB_LAYER_ID_COUNT; ++layer )
m_BoardEditorColors[ layer ] = colors->GetColor( layer );
m_colors = Pgm().GetSettingsManager().GetColorSettings( cfg->m_ColorTheme );
GetBoardEditorCopperLayerColors( cfg );
}
}
@@ -263,15 +262,7 @@ bool BOARD_ADAPTER::Is3dLayerEnabled( PCB_LAYER_ID aLayer,
case Cmts_User: return aVisibilityFlags.test( LAYER_3D_USER_COMMENTS );
case Eco1_User: return aVisibilityFlags.test( LAYER_3D_USER_ECO1 );
case Eco2_User: return aVisibilityFlags.test( LAYER_3D_USER_ECO2 );
default:
{
int layer3D = MapPCBLayerTo3DLayer( aLayer );
if( layer3D != UNDEFINED_LAYER )
return aVisibilityFlags.test( layer3D );
return m_board && m_board->IsLayerVisible( aLayer );
}
default: return m_board && m_board->IsLayerVisible( aLayer );
}
}
@@ -474,14 +465,26 @@ void BOARD_ADAPTER::InitSettings( REPORTER* aStatusReporter, REPORTER* aWarningR
const float zpos_copperTop_back = m_layerZcoordTop[B_Cu];
const float zpos_copperTop_front = m_layerZcoordTop[F_Cu];
// Fill not copper layers zpos
// Fill not copper layers zpos with a dummy position
// (m_layerZcoordTop[B_Cu]with a small margin)
// Some important layer position will be set later
for( int layer_id = 0; layer_id < PCB_LAYER_ID_COUNT; layer_id++ )
{
if( IsCopperLayer( (PCB_LAYER_ID)layer_id ) )
continue;
float zposBottom = zpos_copperTop_front + 2.0f * zpos_offset;
float zposTop = zposBottom + m_frontCopperThickness3DU;
m_layerZcoordBottom[(PCB_LAYER_ID)layer_id] = zpos_copperTop_back - 2.0f * zpos_offset;
m_layerZcoordTop[(PCB_LAYER_ID) layer_id] =
m_layerZcoordBottom[(PCB_LAYER_ID) layer_id] - m_backCopperThickness3DU;
}
// calculate z position for each technical layer
// Solder mask and Solder paste have the same Z position
for( PCB_LAYER_ID layer_id :
{ B_Adhes, B_Mask, B_Paste, F_Adhes, F_Mask, F_Paste, B_SilkS, F_SilkS } )
{
float zposTop = 0.0;
float zposBottom = 0.0;
switch( layer_id )
{
@@ -529,8 +532,8 @@ void BOARD_ADAPTER::InitSettings( REPORTER* aStatusReporter, REPORTER* aWarningR
break;
}
m_layerZcoordTop[(PCB_LAYER_ID)layer_id] = zposTop;
m_layerZcoordBottom[(PCB_LAYER_ID)layer_id] = zposBottom;
m_layerZcoordTop[layer_id] = zposTop;
m_layerZcoordBottom[layer_id] = zposBottom;
}
m_boardCenter = SFVEC3F( m_boardPos.x * m_biuTo3Dunits, m_boardPos.y * m_biuTo3Dunits, 0.0f );
@@ -577,9 +580,6 @@ void BOARD_ADAPTER::InitSettings( REPORTER* aStatusReporter, REPORTER* aWarningR
m_UserCommentsColor = to_SFVEC4F( colors[ LAYER_3D_USER_COMMENTS ] );
m_ECO1Color = to_SFVEC4F( colors[ LAYER_3D_USER_ECO1 ] );
m_ECO2Color = to_SFVEC4F( colors[ LAYER_3D_USER_ECO2 ] );
for( int layer = LAYER_3D_USER_1; layer <= LAYER_3D_USER_45; ++layer )
m_UserDefinedLayerColor[ layer - LAYER_3D_USER_1 ] = to_SFVEC4F( colors[ layer ] );
}
@@ -602,15 +602,28 @@ std::map<int, COLOR4D> BOARD_ADAPTER::GetDefaultColors() const
colors[ LAYER_3D_USER_ECO1 ] = BOARD_ADAPTER::g_DefaultECOs;
colors[ LAYER_3D_USER_ECO2 ] = BOARD_ADAPTER::g_DefaultECOs;
COLOR_SETTINGS* settings = Pgm().GetSettingsManager().GetColorSettings( wxEmptyString );
for( int layer = LAYER_3D_USER_1; layer <= LAYER_3D_USER_45; ++layer )
colors[ layer ] = settings->GetColor( layer );
return colors;
}
void BOARD_ADAPTER::GetBoardEditorCopperLayerColors( PCBNEW_SETTINGS* aCfg )
{
m_BoardEditorColors.clear();
if( m_copperLayersCount <= 0 )
return;
COLOR_SETTINGS* settings = Pgm().GetSettingsManager().GetColorSettings( aCfg->m_ColorTheme );
LSET copperLayers = LSET::AllCuMask();
for( auto layer : LAYER_RANGE( F_Cu, B_Cu, m_copperLayersCount ) )
{
m_BoardEditorColors[ layer ] = settings->GetColor( layer );
}
}
std::map<int, COLOR4D> BOARD_ADAPTER::GetLayerColors() const
{
std::map<int, COLOR4D> colors;
@@ -734,13 +747,8 @@ void BOARD_ADAPTER::SetLayerColors( const std::map<int, COLOR4D>& aColors )
COLOR_SETTINGS* settings = Pgm().GetSettingsManager().GetColorSettings();
for( const auto& [ layer, color ] : aColors )
{
settings->SetColor( layer, color );
if( layer >= LAYER_3D_USER_1 && layer <= LAYER_3D_USER_45 )
m_UserDefinedLayerColor[ layer - LAYER_3D_USER_1 ] = GetColor( color );
}
Pgm().GetSettingsManager().SaveColorSettings( settings, "3d_viewer" );
}
@@ -761,9 +769,6 @@ void BOARD_ADAPTER::SetVisibleLayers( const std::bitset<LAYER_3D_END>& aLayers )
m_Cfg->m_Render.show_eco1 = aLayers.test( LAYER_3D_USER_ECO1 );
m_Cfg->m_Render.show_eco2 = aLayers.test( LAYER_3D_USER_ECO2 );
for( int layer = LAYER_3D_USER_1; layer <= LAYER_3D_USER_45; ++layer )
m_Cfg->m_Render.show_user[ layer - LAYER_3D_USER_1 ] = aLayers.test( layer );
m_Cfg->m_Render.show_footprints_normal = aLayers.test( LAYER_3D_TH_MODELS );
m_Cfg->m_Render.show_footprints_insert = aLayers.test( LAYER_3D_SMD_MODELS );
m_Cfg->m_Render.show_footprints_virtual = aLayers.test( LAYER_3D_VIRTUAL_MODELS );
@@ -784,46 +789,6 @@ std::bitset<LAYER_3D_END> BOARD_ADAPTER::GetVisibleLayers() const
{
std::bitset<LAYER_3D_END> ret;
if( m_board && m_board->IsFootprintHolder() )
{
if( m_Cfg->m_Render.preview_show_board_body )
{
ret.set( LAYER_3D_BOARD, m_Cfg->m_Render.show_board_body );
ret.set( LAYER_3D_SOLDERMASK_TOP, m_Cfg->m_Render.show_soldermask_top );
ret.set( LAYER_3D_SOLDERMASK_BOTTOM, m_Cfg->m_Render.show_soldermask_bottom );
ret.set( LAYER_3D_SOLDERPASTE, m_Cfg->m_Render.show_solderpaste );
ret.set( LAYER_3D_ADHESIVE, m_Cfg->m_Render.show_adhesive );
}
ret.set( LAYER_3D_COPPER_TOP, true );
ret.set( LAYER_3D_COPPER_BOTTOM, true );
ret.set( LAYER_3D_SILKSCREEN_TOP, true );
ret.set( LAYER_3D_SILKSCREEN_BOTTOM, true );
ret.set( LAYER_3D_USER_COMMENTS, true );
ret.set( LAYER_3D_USER_DRAWINGS, true );
ret.set( LAYER_3D_USER_ECO1, true );
ret.set( LAYER_3D_USER_ECO2, true );
for( int layer = LAYER_3D_USER_1; layer <= LAYER_3D_USER_45; ++layer )
ret.set( layer, true );
ret.set( LAYER_FP_REFERENCES, true );
ret.set( LAYER_FP_VALUES, true );
ret.set( LAYER_FP_TEXT, true );
ret.set( LAYER_3D_TH_MODELS, true );
ret.set( LAYER_3D_SMD_MODELS, true );
ret.set( LAYER_3D_VIRTUAL_MODELS, true );
ret.set( LAYER_3D_MODELS_NOT_IN_POS, true );
ret.set( LAYER_3D_MODELS_MARKED_DNP, true );
ret.set( LAYER_3D_BOUNDING_BOXES, m_Cfg->m_Render.show_model_bbox );
ret.set( LAYER_3D_OFF_BOARD_SILK, m_Cfg->m_Render.show_off_board_silk );
ret.set( LAYER_3D_AXES, m_Cfg->m_Render.show_axis );
return ret;
}
ret.set( LAYER_3D_BOARD, m_Cfg->m_Render.show_board_body );
ret.set( LAYER_3D_COPPER_TOP, m_Cfg->m_Render.show_copper_top );
ret.set( LAYER_3D_COPPER_BOTTOM, m_Cfg->m_Render.show_copper_bottom );
@@ -838,9 +803,6 @@ std::bitset<LAYER_3D_END> BOARD_ADAPTER::GetVisibleLayers() const
ret.set( LAYER_3D_USER_ECO1, m_Cfg->m_Render.show_eco1 );
ret.set( LAYER_3D_USER_ECO2, m_Cfg->m_Render.show_eco2 );
for( int layer = LAYER_3D_USER_1; layer <= LAYER_3D_USER_45; ++layer )
ret.set( layer, m_Cfg->m_Render.show_user[ layer - LAYER_3D_USER_1 ] );
ret.set( LAYER_FP_REFERENCES, m_Cfg->m_Render.show_fp_references );
ret.set( LAYER_FP_VALUES, m_Cfg->m_Render.show_fp_values );
ret.set( LAYER_FP_TEXT, m_Cfg->m_Render.show_fp_text );
@@ -883,10 +845,7 @@ std::bitset<LAYER_3D_END> BOARD_ADAPTER::GetVisibleLayers() const
return ret;
const PCB_PLOT_PARAMS& plotParams = m_board->GetPlotOptions();
LSET layers = plotParams.GetLayerSelection();
for( PCB_LAYER_ID commonLayer : plotParams.GetPlotOnAllLayersSequence() )
layers.set( commonLayer );
LSET layers = plotParams.GetLayerSelection() | plotParams.GetPlotOnAllLayersSelection();
ret.set( LAYER_3D_BOARD, true );
ret.set( LAYER_3D_COPPER_TOP, layers.test( F_Cu ) );
@@ -902,9 +861,6 @@ std::bitset<LAYER_3D_END> BOARD_ADAPTER::GetVisibleLayers() const
ret.set( LAYER_3D_USER_ECO1, layers.test( Eco1_User ) );
ret.set( LAYER_3D_USER_ECO2, layers.test( Eco2_User ) );
for( int layer = LAYER_3D_USER_1; layer <= LAYER_3D_USER_45; ++layer )
ret.set( layer, layers.test( Map3DLayerToPCBLayer( layer ) ) );
ret.set( LAYER_FP_REFERENCES, plotParams.GetPlotReference() );
ret.set( LAYER_FP_VALUES, plotParams.GetPlotValue() );
ret.set( LAYER_FP_TEXT, plotParams.GetPlotFPText() );
@@ -913,6 +869,26 @@ std::bitset<LAYER_3D_END> BOARD_ADAPTER::GetVisibleLayers() const
{
ret = preset->layers;
}
else
{
ret.set( LAYER_3D_BOARD, m_Cfg->m_Render.show_board_body );
ret.set( LAYER_3D_COPPER_TOP, m_Cfg->m_Render.show_copper_top );
ret.set( LAYER_3D_COPPER_BOTTOM, m_Cfg->m_Render.show_copper_bottom );
ret.set( LAYER_3D_SILKSCREEN_TOP, m_Cfg->m_Render.show_silkscreen_top );
ret.set( LAYER_3D_SILKSCREEN_BOTTOM, m_Cfg->m_Render.show_silkscreen_bottom );
ret.set( LAYER_3D_SOLDERMASK_TOP, m_Cfg->m_Render.show_soldermask_top );
ret.set( LAYER_3D_SOLDERMASK_BOTTOM, m_Cfg->m_Render.show_soldermask_bottom );
ret.set( LAYER_3D_SOLDERPASTE, m_Cfg->m_Render.show_solderpaste );
ret.set( LAYER_3D_ADHESIVE, m_Cfg->m_Render.show_adhesive );
ret.set( LAYER_3D_USER_COMMENTS, m_Cfg->m_Render.show_comments );
ret.set( LAYER_3D_USER_DRAWINGS, m_Cfg->m_Render.show_drawings );
ret.set( LAYER_3D_USER_ECO1, m_Cfg->m_Render.show_eco1 );
ret.set( LAYER_3D_USER_ECO2, m_Cfg->m_Render.show_eco2 );
ret.set( LAYER_FP_REFERENCES, m_Cfg->m_Render.show_fp_references );
ret.set( LAYER_FP_VALUES, m_Cfg->m_Render.show_fp_values );
ret.set( LAYER_FP_TEXT, m_Cfg->m_Render.show_fp_text );
}
return ret;
}
@@ -936,9 +912,6 @@ std::bitset<LAYER_3D_END> BOARD_ADAPTER::GetDefaultVisibleLayers() const
ret.set( LAYER_3D_USER_ECO1, false );
ret.set( LAYER_3D_USER_ECO2, false );
for( int layer = LAYER_3D_USER_1; layer <= LAYER_3D_USER_45; ++layer )
ret.set( layer, false );
ret.set( LAYER_FP_REFERENCES, true );
ret.set( LAYER_FP_VALUES, true );
ret.set( LAYER_FP_TEXT, true );
@@ -957,12 +930,6 @@ std::bitset<LAYER_3D_END> BOARD_ADAPTER::GetDefaultVisibleLayers() const
}
bool BOARD_ADAPTER::GetUseBoardEditorCopperLayerColors() const
{
return m_Cfg->m_Render.use_board_editor_copper_colors && !m_board->IsFootprintHolder();
}
bool BOARD_ADAPTER::createBoardPolygon( wxString* aErrorMsg )
{
m_board_poly.RemoveAllContours();
@@ -1025,14 +992,19 @@ float BOARD_ADAPTER::GetFootprintZPos( bool aIsFlipped ) const
}
SFVEC4F BOARD_ADAPTER::GetLayerColor( int aLayerId ) const
SFVEC4F BOARD_ADAPTER::GetLayerColor( PCB_LAYER_ID aLayerId ) const
{
if( aLayerId >= LAYER_3D_USER_1 && aLayerId <= LAYER_3D_USER_45 )
aLayerId = Map3DLayerToPCBLayer( aLayerId );
wxASSERT( aLayerId < PCB_LAYER_ID_COUNT );
return GetColor( m_BoardEditorColors.at( aLayerId ) );
const COLOR4D color = m_colors->GetColor( aLayerId );
return SFVEC4F( color.r, color.g, color.b, color.a );
}
SFVEC4F BOARD_ADAPTER::GetItemColor( int aItemId ) const
{
return GetColor( m_colors->GetColor( aItemId ) );
}
+22 -9
View File
@@ -112,6 +112,11 @@ public:
*/
std::map<int, COLOR4D> GetLayerColors() const;
/**
* Build the copper color list used by the board editor, and store it in m_BoardEditorColors
*/
void GetBoardEditorCopperLayerColors( PCBNEW_SETTINGS* aCfg );
std::map<int, COLOR4D> GetDefaultColors() const;
void SetLayerColors( const std::map<int, COLOR4D>& aColors );
@@ -119,8 +124,6 @@ public:
std::bitset<LAYER_3D_END> GetDefaultVisibleLayers() const;
void SetVisibleLayers( const std::bitset<LAYER_3D_END>& aLayers );
bool GetUseBoardEditorCopperLayerColors() const;
/**
* Function to be called by the render when it need to reload the settings for the board.
*
@@ -207,7 +210,15 @@ public:
* @param aLayerId the layer to get the color information.
* @return the color in SFVEC3F format.
*/
SFVEC4F GetLayerColor( int aLayerId ) const;
SFVEC4F GetLayerColor( PCB_LAYER_ID aLayerId ) const;
/**
* Get the technical color of a layer.
*
* @param aItemId the item id to get the color information.
* @return the color in SFVEC3F format.
*/
SFVEC4F GetItemColor( int aItemId ) const;
/**
* @param[in] aColor is the color mapped.
@@ -341,14 +352,14 @@ public:
*/
const MAP_POLY& GetPolyMap() const noexcept { return m_layers_poly; }
const SHAPE_POLY_SET* GetFrontPlatedCopperPolys()
const SHAPE_POLY_SET* GetFrontPlatedPadAndGraphicPolys()
{
return m_frontPlatedCopperPolys;
return m_frontPlatedPadAndGraphicPolys;
}
const SHAPE_POLY_SET* GetBackPlatedCopperPolys()
const SHAPE_POLY_SET* GetBackPlatedPadAndGraphicPolys()
{
return m_backPlatedCopperPolys;
return m_backPlatedPadAndGraphicPolys;
}
const MAP_POLY& GetHoleIdPolysMap() const noexcept { return m_layerHoleIdPolys; }
@@ -375,7 +386,7 @@ private:
int aInflateValue );
void addPads( const FOOTPRINT* aFootprint, CONTAINER_2D_BASE* aDstContainer,
PCB_LAYER_ID aLayerId );
PCB_LAYER_ID aLayerId, bool aSkipPlatedPads, bool aSkipNonPlatedPads );
void addFootprintShapes( const FOOTPRINT* aFootprint, CONTAINER_2D_BASE* aDstContainer,
PCB_LAYER_ID aLayerId,
@@ -444,7 +455,6 @@ public:
SFVEC4F m_UserCommentsColor;
SFVEC4F m_ECO1Color;
SFVEC4F m_ECO2Color;
SFVEC4F m_UserDefinedLayerColor[45];
std::map<int, COLOR4D> m_ColorOverrides; ///< allows to override color scheme colors
std::map<int, COLOR4D> m_BoardEditorColors; ///< list of colors used by the board editor
@@ -452,6 +462,7 @@ public:
private:
BOARD* m_board;
S3D_CACHE* m_3dModelManager;
COLOR_SETTINGS* m_colors;
VECTOR2I m_boardPos; ///< Board center position in board internal units.
VECTOR2I m_boardSize; ///< Board size in board internal units.
@@ -461,6 +472,8 @@ private:
MAP_POLY m_layers_poly; ///< Amalgamated polygon contours for various types
///< of items
SHAPE_POLY_SET* m_frontPlatedPadAndGraphicPolys;
SHAPE_POLY_SET* m_backPlatedPadAndGraphicPolys;
SHAPE_POLY_SET* m_frontPlatedCopperPolys;
SHAPE_POLY_SET* m_backPlatedCopperPolys;
@@ -188,23 +188,23 @@ void BOARD_ADAPTER::addShape( const PCB_DIMENSION_BASE* aDimension, CONTAINER_2D
void BOARD_ADAPTER::addFootprintShapes( const FOOTPRINT* aFootprint, CONTAINER_2D_BASE* aContainer,
PCB_LAYER_ID aLayerId,
const std::bitset<LAYER_3D_END>& aFlags )
const std::bitset<LAYER_3D_END>& aVisibilityFlags )
{
KIGFX::GAL_DISPLAY_OPTIONS empty_opts;
for( PCB_FIELD* field : aFootprint->GetFields( true /* visibleOnly */ ) )
for( PCB_FIELD* field : aFootprint->GetFields() )
{
if( !aFlags.test( LAYER_FP_TEXT ) )
continue;
if( field->GetLayer() == aLayerId && field->IsVisible() )
{
if( !aVisibilityFlags.test( LAYER_FP_TEXT ) )
continue;
else if( field->IsReference() && !aVisibilityFlags.test( LAYER_FP_REFERENCES ) )
continue;
else if( field->IsValue() && !aVisibilityFlags.test( LAYER_FP_VALUES ) )
continue;
if( field->IsReference() && !aFlags.test( LAYER_FP_REFERENCES ) )
continue;
if( field->IsValue() && !aFlags.test( LAYER_FP_VALUES ) )
continue;
if( field->GetLayer() == aLayerId )
addText( field, aContainer, field );
}
}
for( BOARD_ITEM* item : aFootprint->GraphicalItems() )
@@ -215,17 +215,19 @@ void BOARD_ADAPTER::addFootprintShapes( const FOOTPRINT* aFootprint, CONTAINER_2
{
PCB_TEXT* text = static_cast<PCB_TEXT*>( item );
if( !aFlags.test( LAYER_FP_TEXT ) )
continue;
if( text->GetLayer() == aLayerId && text->IsVisible() )
{
if( !aVisibilityFlags.test( LAYER_FP_TEXT ) )
continue;
else if( text->GetText() == wxT( "${REFERENCE}" )
&& !aVisibilityFlags.test( LAYER_FP_REFERENCES ) )
continue;
else if( text->GetText() == wxT( "${VALUE}" )
&& !aVisibilityFlags.test( LAYER_FP_VALUES ) )
continue;
if( text->GetText() == wxT( "${REFERENCE}" ) && !aFlags.test( LAYER_FP_REFERENCES ) )
continue;
if( text->GetText() == wxT( "${VALUE}" ) && !aFlags.test( LAYER_FP_VALUES ) )
continue;
if( text->GetLayer() == aLayerId )
addText( text, aContainer, text );
}
break;
}
@@ -281,7 +283,7 @@ void BOARD_ADAPTER::addFootprintShapes( const FOOTPRINT* aFootprint, CONTAINER_2
}
void BOARD_ADAPTER::createTrackWithMargin( const PCB_TRACK* aTrack,
void BOARD_ADAPTER::createTrackWithMargin( const PCB_TRACK* aTrack,
CONTAINER_2D_BASE* aDstContainer, PCB_LAYER_ID aLayer,
int aMargin )
{
@@ -503,7 +505,7 @@ void BOARD_ADAPTER::createPadWithHole( const PAD* aPad, CONTAINER_2D_BASE* aDstC
void BOARD_ADAPTER::addPads( const FOOTPRINT* aFootprint, CONTAINER_2D_BASE* aContainer,
PCB_LAYER_ID aLayerId )
PCB_LAYER_ID aLayerId, bool aSkipPlatedPads, bool aSkipNonPlatedPads )
{
for( PAD* pad : aFootprint->Pads() )
{
@@ -527,6 +529,24 @@ void BOARD_ADAPTER::addPads( const FOOTPRINT* aFootprint, CONTAINER_2D_BASE* aCo
switch( aLayerId )
{
case F_Cu:
if( aSkipPlatedPads && pad->FlashLayer( F_Mask ) )
continue;
if( aSkipNonPlatedPads && !pad->FlashLayer( F_Mask ) )
continue;
break;
case B_Cu:
if( aSkipPlatedPads && pad->FlashLayer( B_Mask ) )
continue;
if( aSkipNonPlatedPads && !pad->FlashLayer( B_Mask ) )
continue;
break;
case F_Mask:
case B_Mask:
margin.x += pad->GetSolderMaskExpansion( aLayerId );
@@ -773,18 +793,11 @@ void BOARD_ADAPTER::addShape( const PCB_TEXTBOX* aTextBox, CONTAINER_2D_BASE* aC
void BOARD_ADAPTER::addTable( const PCB_TABLE* aTable, CONTAINER_2D_BASE* aContainer,
const BOARD_ITEM* aOwner )
{
aTable->DrawBorders(
[&]( const VECTOR2I& ptA, const VECTOR2I& ptB, const STROKE_PARAMS& stroke )
{
addROUND_SEGMENT_2D( aContainer, TO_SFVEC2F( ptA ), TO_SFVEC2F( ptB ),
TO_3DU( stroke.GetWidth() ), *aOwner );
} );
// JEY TODO: tables
// add borders
for( PCB_TABLECELL* cell : aTable->GetCells() )
{
if( cell->GetColSpan() > 0 && cell->GetRowSpan() > 0 )
addText( cell, aContainer, aOwner );
}
addText( cell, aContainer, aOwner );
}
+144 -241
View File
@@ -103,68 +103,6 @@ void transformFPShapesToPolySet( const FOOTPRINT* aFootprint, PCB_LAYER_ID aLaye
}
void transformFPTextToPolySet( const FOOTPRINT* aFootprint, PCB_LAYER_ID aLayer,
const std::bitset<LAYER_3D_END>& aFlags, SHAPE_POLY_SET& aBuffer,
int aMaxError, ERROR_LOC aErrorLoc )
{
for( BOARD_ITEM* item : aFootprint->GraphicalItems() )
{
if( item->GetLayer() != aLayer )
continue;
if( item->Type() == PCB_TEXT_T )
{
PCB_TEXT* text = static_cast<PCB_TEXT*>( item );
if( !aFlags.test( LAYER_FP_TEXT ) )
continue;
if( text->GetText() == wxT( "${REFERENCE}" ) && !aFlags.test( LAYER_FP_REFERENCES ) )
continue;
if( text->GetText() == wxT( "${VALUE}" ) && !aFlags.test( LAYER_FP_VALUES ) )
continue;
if( aLayer != UNDEFINED_LAYER && text->GetLayer() == aLayer )
text->TransformTextToPolySet( aBuffer, 0, aMaxError, aErrorLoc );
}
if( item->Type() == PCB_TEXTBOX_T )
{
PCB_TEXTBOX* textbox = static_cast<PCB_TEXTBOX*>( item );
if( aLayer != UNDEFINED_LAYER && textbox->GetLayer() == aLayer )
{
// border
if( textbox->IsBorderEnabled() )
{
textbox->PCB_SHAPE::TransformShapeToPolygon( aBuffer, aLayer, 0, aMaxError,
aErrorLoc );
}
// text
textbox->TransformTextToPolySet( aBuffer, 0, aMaxError, aErrorLoc );
}
}
}
for( const PCB_FIELD* field : aFootprint->GetFields( true /* visibleOnly */ ) )
{
if( !aFlags.test( LAYER_FP_TEXT ) )
continue;
if( field->IsReference() && !aFlags.test( LAYER_FP_REFERENCES ) )
continue;
if( field->IsValue() && !aFlags.test( LAYER_FP_VALUES ) )
continue;
if( field && field->GetLayer() == aLayer )
field->TransformTextToPolySet( aBuffer, 0, aMaxError, aErrorLoc );
}
}
void BOARD_ADAPTER::destroyLayers()
{
#define DELETE_AND_FREE( ptr ) \
@@ -183,6 +121,8 @@ void BOARD_ADAPTER::destroyLayers()
DELETE_AND_FREE_MAP( m_layers_poly );
DELETE_AND_FREE( m_frontPlatedPadAndGraphicPolys )
DELETE_AND_FREE( m_backPlatedPadAndGraphicPolys )
DELETE_AND_FREE( m_frontPlatedCopperPolys )
DELETE_AND_FREE( m_backPlatedCopperPolys )
@@ -300,6 +240,8 @@ void BOARD_ADAPTER::createLayers( REPORTER* aStatusReporter )
if( cfg.DifferentiatePlatedCopper() )
{
m_frontPlatedPadAndGraphicPolys = new SHAPE_POLY_SET;
m_backPlatedPadAndGraphicPolys = new SHAPE_POLY_SET;
m_frontPlatedCopperPolys = new SHAPE_POLY_SET;
m_backPlatedCopperPolys = new SHAPE_POLY_SET;
@@ -330,8 +272,11 @@ void BOARD_ADAPTER::createLayers( REPORTER* aStatusReporter )
continue;
// Skip vias annulus when not flashed on this layer
if( track->Type() == PCB_VIA_T && !static_cast<const PCB_VIA*>( track )->FlashLayer( layer ) )
if( track->Type() == PCB_VIA_T
&& !static_cast<const PCB_VIA*>( track )->FlashLayer( layer ) )
{
continue;
}
// Add object item to layer container
createTrackWithMargin( track, layerContainer, layer );
@@ -387,7 +332,8 @@ void BOARD_ADAPTER::createLayers( REPORTER* aStatusReporter )
}
// Add a hole for this layer
layerHoleContainer->Add( new FILLED_CIRCLE_2D( via_center, hole_inner_radius + thickness,
layerHoleContainer->Add( new FILLED_CIRCLE_2D( via_center,
hole_inner_radius + thickness,
*track ) );
}
else if( layer == layer_ids[0] ) // it only adds once the THT holes
@@ -596,38 +542,54 @@ void BOARD_ADAPTER::createLayers( REPORTER* aStatusReporter )
}
}
// Add footprints copper items (pads, shapes and text) to containers
// Add footprints PADs objects to containers
for( PCB_LAYER_ID layer : layer_ids )
{
wxASSERT( m_layerMap.find( layer ) != m_layerMap.end() );
BVH_CONTAINER_2D *layerContainer = m_layerMap[layer];
for( FOOTPRINT* fp : m_board->Footprints() )
// ADD PADS
for( FOOTPRINT* footprint : m_board->Footprints() )
{
addPads( fp, layerContainer, layer );
addFootprintShapes( fp, layerContainer, layer, visibilityFlags );
addPads( footprint, layerContainer, layer, cfg.DifferentiatePlatedCopper(), false );
// Add copper item to the plated copper polygon list if required
if( cfg.DifferentiatePlatedCopper() && ( layer == F_Cu || layer == B_Cu ) )
// Micro-wave footprints may have items on copper layers
addFootprintShapes( footprint, layerContainer, layer, visibilityFlags );
}
}
// Add footprints PADs poly contours (vertical outlines)
if( cfg.opengl_copper_thickness && cfg.engine == RENDER_ENGINE::OPENGL )
{
for( PCB_LAYER_ID layer : layer_ids )
{
wxASSERT( m_layers_poly.find( layer ) != m_layers_poly.end() );
SHAPE_POLY_SET *layerPoly = m_layers_poly[layer];
// Add pads to polygon list
for( FOOTPRINT* footprint : m_board->Footprints() )
{
SHAPE_POLY_SET* layerPoly = layer == F_Cu ? m_frontPlatedCopperPolys : m_backPlatedCopperPolys;
// Note: NPTH pads are not drawn on copper layers when the pad has same shape as
// its hole
footprint->TransformPadsToPolySet( *layerPoly, layer, 0, maxError, ERROR_INSIDE,
true, cfg.DifferentiatePlatedCopper(), false );
fp->TransformPadsToPolySet( *layerPoly, layer, 0, maxError, ERROR_INSIDE, true );
transformFPTextToPolySet( fp, layer, visibilityFlags, *layerPoly, maxError, ERROR_INSIDE );
transformFPShapesToPolySet( fp, layer, *layerPoly, maxError, ERROR_INSIDE );
transformFPShapesToPolySet( footprint, layer, *layerPoly, maxError, ERROR_INSIDE );
}
}
// Add copper item to poly contours (vertical outlines) if required
if( cfg.opengl_copper_thickness && cfg.engine == RENDER_ENGINE::OPENGL )
if( cfg.DifferentiatePlatedCopper() )
{
// ADD PLATED PADS contours
for( FOOTPRINT* footprint : m_board->Footprints() )
{
wxASSERT( m_layers_poly.contains( layer ) );
footprint->TransformPadsToPolySet( *m_frontPlatedPadAndGraphicPolys, F_Cu, 0, maxError,
ERROR_INSIDE, true, false, true );
SHAPE_POLY_SET* layerPoly = m_layers_poly[layer];
fp->TransformPadsToPolySet( *layerPoly, layer, 0, maxError, ERROR_INSIDE, true );
transformFPTextToPolySet( fp, layer, visibilityFlags, *layerPoly, maxError, ERROR_INSIDE );
transformFPShapesToPolySet( fp, layer, *layerPoly, maxError, ERROR_INSIDE );
footprint->TransformPadsToPolySet( *m_backPlatedPadAndGraphicPolys, B_Cu, 0, maxError,
ERROR_INSIDE, true, false, true );
}
}
}
@@ -672,42 +634,59 @@ void BOARD_ADAPTER::createLayers( REPORTER* aStatusReporter )
break;
default:
wxLogTrace( m_logTrace, wxT( "createLayers: item type: %d not implemented" ), item->Type() );
wxLogTrace( m_logTrace, wxT( "createLayers: item type: %d not implemented" ),
item->Type() );
break;
}
// Add copper item to the plated copper polygon list if required
if( cfg.DifferentiatePlatedCopper() && ( layer == F_Cu || layer == B_Cu ) )
// add also this shape to the plated copper polygon list if required
if( cfg.DifferentiatePlatedCopper() )
{
SHAPE_POLY_SET* copperPolys = layer == F_Cu ? m_frontPlatedCopperPolys : m_backPlatedCopperPolys;
// Note: for TEXT and TEXTBOX, TransformShapeToPolygon returns the bounding
// box shape, not the exact text shape. So it is not used for these items
if( item->Type() == PCB_TEXTBOX_T )
if( layer == F_Cu || layer == B_Cu )
{
PCB_TEXTBOX* text_box = static_cast<PCB_TEXTBOX*>( item );
text_box->TransformTextToPolySet( *copperPolys, 0, maxError, ERROR_INSIDE );
// Add box outlines
text_box->PCB_SHAPE::TransformShapeToPolygon( *copperPolys, layer, 0, maxError,
ERROR_INSIDE );
}
else if( item->Type() == PCB_TEXT_T )
{
PCB_TEXT* text = static_cast<PCB_TEXT*>( item );
text->TransformTextToPolySet( *copperPolys, 0, maxError, ERROR_INSIDE );
}
else
{
item->TransformShapeToPolygon( *copperPolys, layer, 0, maxError, ERROR_INSIDE );
SHAPE_POLY_SET* platedCopperPolys = layer == F_Cu
? m_frontPlatedCopperPolys
: m_backPlatedCopperPolys;
if( item->Type() == PCB_TEXTBOX_T )
{
PCB_TEXTBOX* text_box = static_cast<PCB_TEXTBOX*>( item );
text_box->TransformTextToPolySet( *platedCopperPolys,
0, maxError, ERROR_INSIDE );
// Add box outlines
text_box->PCB_SHAPE::TransformShapeToPolygon( *platedCopperPolys, layer,
0, maxError, ERROR_INSIDE );
}
else if( item->Type() == PCB_TEXT_T )
{
static_cast<PCB_TEXT*>( item )->TransformTextToPolySet(
*platedCopperPolys,
0, maxError, ERROR_INSIDE );
}
else
item->TransformShapeToPolygon( *platedCopperPolys, layer,
0, maxError, ERROR_INSIDE );
}
}
}
}
// Add copper item to poly contours (vertical outlines) if required
if( cfg.opengl_copper_thickness && cfg.engine == RENDER_ENGINE::OPENGL )
// Add graphic item on copper layers to poly contours (vertical outlines)
if( cfg.opengl_copper_thickness && cfg.engine == RENDER_ENGINE::OPENGL )
{
for( PCB_LAYER_ID layer : layer_ids )
{
wxASSERT( m_layers_poly.find( layer ) != m_layers_poly.end() );
SHAPE_POLY_SET *layerPoly = m_layers_poly[layer];
// Add graphic items on copper layers (texts and other )
for( BOARD_ITEM* item : m_board->Drawings() )
{
wxASSERT( m_layers_poly.contains( layer ) );
SHAPE_POLY_SET *layerPoly = m_layers_poly[layer];
if( !item->IsOnLayer( layer ) )
continue;
switch( item->Type() )
{
@@ -727,51 +706,17 @@ void BOARD_ADAPTER::createLayers( REPORTER* aStatusReporter )
{
PCB_TEXTBOX* textbox = static_cast<PCB_TEXTBOX*>( item );
if( textbox->IsBorderEnabled() )
{
textbox->PCB_SHAPE::TransformShapeToPolygon( *layerPoly, layer, 0,
maxError, ERROR_INSIDE );
}
textbox->TransformTextToPolySet( *layerPoly, 0, maxError, ERROR_INSIDE );
break;
}
case PCB_TABLE_T:
{
PCB_TABLE* table = static_cast<PCB_TABLE*>( item );
for( PCB_TABLECELL* cell : table->GetCells() )
cell->TransformTextToPolySet( *layerPoly, 0, maxError, ERROR_INSIDE );
table->DrawBorders(
[&]( const VECTOR2I& ptA, const VECTOR2I& ptB,
const STROKE_PARAMS& stroke )
{
SHAPE_SEGMENT seg( ptA, ptB, stroke.GetWidth() );
seg.TransformToPolygon( *layerPoly, maxError, ERROR_INSIDE );
} );
// JEY TODO: tables
break;
}
case PCB_DIM_ALIGNED_T:
case PCB_DIM_CENTER_T:
case PCB_DIM_RADIAL_T:
case PCB_DIM_ORTHOGONAL_T:
case PCB_DIM_LEADER_T:
{
PCB_DIMENSION_BASE* dimension = static_cast<PCB_DIMENSION_BASE*>( item );
dimension->TransformTextToPolySet( *layerPoly, 0, maxError, ERROR_INSIDE );
for( const std::shared_ptr<SHAPE>& shape : dimension->GetShapes() )
shape->TransformToPolygon( *layerPoly, maxError, ERROR_INSIDE );
break;
}
default:
wxLogTrace( m_logTrace, wxT( "createLayers: item type: %d not implemented" ), item->Type() );
wxLogTrace( m_logTrace, wxT( "createLayers: item type: %d not implemented" ),
item->Type() );
break;
}
}
@@ -793,11 +738,15 @@ void BOARD_ADAPTER::createLayers( REPORTER* aStatusReporter )
zones.emplace_back( std::make_pair( zone, layer ) );
layer_lock.emplace( layer, std::make_unique<std::mutex>() );
if( cfg.DifferentiatePlatedCopper() && ( layer == F_Cu || layer == B_Cu ) )
if( cfg.DifferentiatePlatedCopper() && layer == F_Cu )
{
SHAPE_POLY_SET* copperPolys = layer == F_Cu ? m_frontPlatedCopperPolys : m_backPlatedCopperPolys;
zone->TransformShapeToPolygon( *copperPolys, layer, 0, maxError, ERROR_INSIDE );
zone->TransformShapeToPolygon( *m_frontPlatedCopperPolys, F_Cu, 0, maxError,
ERROR_INSIDE );
}
else if( cfg.DifferentiatePlatedCopper() && layer == B_Cu )
{
zone->TransformShapeToPolygon( *m_backPlatedCopperPolys, B_Cu, 0, maxError,
ERROR_INSIDE );
}
}
}
@@ -879,52 +828,7 @@ void BOARD_ADAPTER::createLayers( REPORTER* aStatusReporter )
Dwgs_User,
Cmts_User,
Eco1_User,
Eco2_User,
User_1,
User_2,
User_3,
User_4,
User_5,
User_6,
User_7,
User_8,
User_9,
User_10,
User_11,
User_12,
User_13,
User_14,
User_15,
User_16,
User_17,
User_18,
User_19,
User_20,
User_21,
User_22,
User_23,
User_24,
User_25,
User_26,
User_27,
User_28,
User_29,
User_30,
User_31,
User_32,
User_33,
User_34,
User_35,
User_36,
User_37,
User_38,
User_39,
User_40,
User_41,
User_42,
User_43,
User_44,
User_45,
Eco2_User
} );
std::bitset<LAYER_3D_END> enabledFlags = visibilityFlags;
@@ -972,7 +876,7 @@ void BOARD_ADAPTER::createLayers( REPORTER* aStatusReporter )
break;
case PCB_TABLE_T:
addTable( static_cast<PCB_TABLE*>( item ), layerContainer, item );
// JEY TODO: tables
break;
case PCB_DIM_ALIGNED_T:
@@ -1025,7 +929,7 @@ void BOARD_ADAPTER::createLayers( REPORTER* aStatusReporter )
}
else
{
addPads( footprint, layerContainer, layer );
addPads( footprint, layerContainer, layer, false, false );
}
addFootprintShapes( footprint, layerContainer, layer, visibilityFlags );
@@ -1071,33 +975,13 @@ void BOARD_ADAPTER::createLayers( REPORTER* aStatusReporter )
{
PCB_TEXTBOX* textbox = static_cast<PCB_TEXTBOX*>( item );
if( textbox->IsBorderEnabled() )
{
textbox->PCB_SHAPE::TransformShapeToPolygon( *layerPoly, layer, 0,
maxError, ERROR_INSIDE );
}
textbox->TransformTextToPolySet( *layerPoly, 0, maxError, ERROR_INSIDE );
break;
}
case PCB_TABLE_T:
{
PCB_TABLE* table = static_cast<PCB_TABLE*>( item );
for( PCB_TABLECELL* cell : table->GetCells() )
cell->TransformTextToPolySet( *layerPoly, 0, maxError, ERROR_INSIDE );
table->DrawBorders(
[&]( const VECTOR2I& ptA, const VECTOR2I& ptB,
const STROKE_PARAMS& stroke )
{
SHAPE_SEGMENT seg( ptA, ptB, stroke.GetWidth() );
seg.TransformToPolygon( *layerPoly, maxError, ERROR_INSIDE );
} );
// JEY TODO: tables
break;
}
default:
break;
@@ -1111,23 +995,12 @@ void BOARD_ADAPTER::createLayers( REPORTER* aStatusReporter )
for( PCB_TRACK* track : m_board->Tracks() )
{
if( track->Type() == PCB_VIA_T )
if( track->Type() == PCB_VIA_T
&& static_cast<const PCB_VIA*>( track )->FlashLayer( layer )
&& !static_cast<const PCB_VIA*>( track )->IsTented( layer ) )
{
const PCB_VIA* via = static_cast<const PCB_VIA*>( track );
if( via->FlashLayer( layer ) && !via->IsTented( layer ) )
{
track->TransformShapeToPolygon( *layerPoly, layer, maskExpansion, maxError,
ERROR_INSIDE );
}
}
else
{
if( track->HasSolderMask() )
{
track->TransformShapeToPolygon( *layerPoly, layer, maskExpansion, maxError,
ERROR_INSIDE );
}
track->TransformShapeToPolygon( *layerPoly, layer, maskExpansion, maxError,
ERROR_INSIDE );
}
}
}
@@ -1150,14 +1023,14 @@ void BOARD_ADAPTER::createLayers( REPORTER* aStatusReporter )
}
else
{
footprint->TransformPadsToPolySet( *layerPoly, layer, 0, maxError,
ERROR_INSIDE );
footprint->TransformPadsToPolySet( *layerPoly, layer, 0, maxError, ERROR_INSIDE );
}
transformFPTextToPolySet( footprint, layer, visibilityFlags, *layerPoly, maxError,
ERROR_INSIDE );
transformFPShapesToPolySet( footprint, layer, *layerPoly, maxError,
ERROR_INSIDE );
// On tech layers, use a poor circle approximation, only for texts (stroke font)
footprint->TransformFPTextToPolySet( *layerPoly, layer, 0, maxError, ERROR_INSIDE );
// Add the remaining things with dynamic seg count for circles
transformFPShapesToPolySet( footprint, layer, *layerPoly, maxError, ERROR_INSIDE );
}
if( cfg.show_zones || layer == F_Mask || layer == B_Mask )
@@ -1186,9 +1059,9 @@ void BOARD_ADAPTER::createLayers( REPORTER* aStatusReporter )
if( !footprint->GetBoundingBox().Intersects( boardBBox ) )
{
if( footprint->IsFlipped() )
addPads( footprint, m_offboardPadsBack, B_Cu );
addPads( footprint, m_offboardPadsBack, B_Cu, false, false );
else
addPads( footprint, m_offboardPadsFront, F_Cu );
addPads( footprint, m_offboardPadsFront, F_Cu, false, false );
}
}
@@ -1218,11 +1091,41 @@ void BOARD_ADAPTER::createLayers( REPORTER* aStatusReporter )
}
// Subtract plated copper from unplated copper
bool hasF_Cu = false;
bool hasB_Cu = false;
if( m_layers_poly.find( F_Cu ) != m_layers_poly.end() )
{
m_layers_poly[F_Cu]->BooleanSubtract( *m_frontPlatedPadAndGraphicPolys );
m_layers_poly[F_Cu]->BooleanSubtract( *m_frontPlatedCopperPolys );
hasF_Cu = true;
}
if( m_layers_poly.find( B_Cu ) != m_layers_poly.end() )
{
m_layers_poly[B_Cu]->BooleanSubtract( *m_backPlatedPadAndGraphicPolys );
m_layers_poly[B_Cu]->BooleanSubtract( *m_backPlatedCopperPolys );
hasB_Cu = true;
}
// Add plated graphic items to build vertical walls
if( hasF_Cu && m_frontPlatedCopperPolys->OutlineCount() )
m_frontPlatedPadAndGraphicPolys->Append( *m_frontPlatedCopperPolys );
if( hasB_Cu && m_backPlatedCopperPolys->OutlineCount() )
m_backPlatedPadAndGraphicPolys->Append( *m_backPlatedCopperPolys );
m_frontPlatedPadAndGraphicPolys->Simplify();
m_backPlatedPadAndGraphicPolys->Simplify();
m_frontPlatedCopperPolys->Simplify();
m_backPlatedCopperPolys->Simplify();
// ADD PLATED PADS
for( FOOTPRINT* footprint : m_board->Footprints() )
{
addPads( footprint, m_platedPadsFront, F_Cu, false, true );
addPads( footprint, m_platedPadsBack, B_Cu, false, true );
}
// ADD PLATED COPPER
ConvertPolygonToTriangles( *m_frontPlatedCopperPolys, *m_platedPadsFront, m_biuTo3Dunits,
+2 -2
View File
@@ -451,7 +451,7 @@ void EDA_3D_CANVAS::DoRePaint()
return;
}
// Don't attempt to ray trace if OpenGL doesn't support it.
// Don't attend to ray trace if OpenGL doesn't support it.
if( !m_opengl_supports_raytracing )
{
m_3d_render = m_3d_render_opengl;
@@ -459,7 +459,7 @@ void EDA_3D_CANVAS::DoRePaint()
m_boardAdapter.m_Cfg->m_Render.engine = RENDER_ENGINE::OPENGL;
}
// Check if a raytracing was requested and need to switch to raytracing mode
// Check if a raytacing was requested and need to switch to raytracing mode
if( m_boardAdapter.m_Cfg->m_Render.engine == RENDER_ENGINE::OPENGL )
{
const bool was_camera_changed = m_camera.ParametersChanged();
@@ -157,7 +157,7 @@ void EDA_3D_MODEL_VIEWER::Set3DModel( const wxString& aModelPathName)
if( m_cacheManager )
{
const S3DMODEL* model = m_cacheManager->GetModel( aModelPathName, wxEmptyString, {} );
const S3DMODEL* model = m_cacheManager->GetModel( aModelPathName, wxEmptyString, nullptr );
if( model )
Set3DModel( (const S3DMODEL &)*model );
+14 -15
View File
@@ -607,12 +607,14 @@ void RENDER_3D_OPENGL::reload( REPORTER* aStatusReporter, REPORTER* aWarningRepo
if( m_boardAdapter.m_Cfg->m_Render.DifferentiatePlatedCopper() )
{
const SHAPE_POLY_SET* frontPlatedCopperPolys = m_boardAdapter.GetFrontPlatedCopperPolys();
const SHAPE_POLY_SET* backPlatedCopperPolys = m_boardAdapter.GetBackPlatedCopperPolys();
const SHAPE_POLY_SET* frontPlatedPadAndGraphicPolys =
m_boardAdapter.GetFrontPlatedPadAndGraphicPolys();
const SHAPE_POLY_SET* backPlatedPadAndGraphicPolys =
m_boardAdapter.GetBackPlatedPadAndGraphicPolys();
if( frontPlatedCopperPolys )
if( frontPlatedPadAndGraphicPolys )
{
SHAPE_POLY_SET poly = frontPlatedCopperPolys->CloneDropTriangulation();
SHAPE_POLY_SET poly = frontPlatedPadAndGraphicPolys->CloneDropTriangulation();
poly.BooleanIntersection( m_boardAdapter.GetBoardPoly() );
poly.BooleanSubtract( m_boardAdapter.GetTH_ODPolys() );
poly.BooleanSubtract( m_boardAdapter.GetNPTH_ODPolys() );
@@ -625,9 +627,9 @@ void RENDER_3D_OPENGL::reload( REPORTER* aStatusReporter, REPORTER* aWarningRepo
m_layers[F_Cu] = generateEmptyLayerList( F_Cu );
}
if( backPlatedCopperPolys )
if( backPlatedPadAndGraphicPolys )
{
SHAPE_POLY_SET poly = backPlatedCopperPolys->CloneDropTriangulation();
SHAPE_POLY_SET poly = backPlatedPadAndGraphicPolys->CloneDropTriangulation();
poly.BooleanIntersection( m_boardAdapter.GetBoardPoly() );
poly.BooleanSubtract( m_boardAdapter.GetTH_ODPolys() );
poly.BooleanSubtract( m_boardAdapter.GetNPTH_ODPolys() );
@@ -926,8 +928,8 @@ void RENDER_3D_OPENGL::load3dModels( REPORTER* aStatusReporter )
// Go for all footprints
for( const FOOTPRINT* footprint : m_boardAdapter.GetBoard()->Footprints() )
{
wxString libraryName = footprint->GetFPID().GetLibNickname();
wxString footprintBasePath = wxEmptyString;
wxString libraryName = footprint->GetFPID().GetLibNickname();
wxString footprintBasePath = wxEmptyString;
if( m_boardAdapter.GetBoard()->GetProject() )
{
@@ -965,13 +967,10 @@ void RENDER_3D_OPENGL::load3dModels( REPORTER* aStatusReporter )
if( m_3dModelMap.find( fp_model.m_Filename ) == m_3dModelMap.end() )
{
// It is not present, try get it from cache
std::vector<const EMBEDDED_FILES*> embeddedFilesStack;
embeddedFilesStack.push_back( footprint->GetEmbeddedFiles() );
embeddedFilesStack.push_back( m_boardAdapter.GetBoard()->GetEmbeddedFiles() );
const S3DMODEL* modelPtr = m_boardAdapter.Get3dCacheManager()->GetModel( fp_model.m_Filename,
footprintBasePath,
embeddedFilesStack );
const S3DMODEL* modelPtr =
m_boardAdapter.Get3dCacheManager()->GetModel( fp_model.m_Filename,
footprintBasePath,
footprint );
// only add it if the return is not NULL
if( modelPtr )
@@ -271,7 +271,9 @@ void RENDER_3D_OPENGL::setupMaterials()
void RENDER_3D_OPENGL::setLayerMaterial( PCB_LAYER_ID aLayerID )
{
if( m_boardAdapter.GetUseBoardEditorCopperLayerColors() && IsCopperLayer( aLayerID ) )
EDA_3D_VIEWER_SETTINGS::RENDER_SETTINGS& cfg = m_boardAdapter.m_Cfg->m_Render;
if( cfg.use_board_editor_copper_colors && IsCopperLayer( aLayerID ) )
{
COLOR4D copper_color = m_boardAdapter.m_BoardEditorColors[aLayerID];
m_materials.m_Copper.m_Diffuse = SFVEC3F( copper_color.r, copper_color.g,
@@ -360,34 +362,10 @@ void RENDER_3D_OPENGL::setLayerMaterial( PCB_LAYER_ID aLayerID )
break;
default:
{
int layer3D = MapPCBLayerTo3DLayer( aLayerID );
// Note: MUST do this in LAYER_3D space; User_1..User_45 are NOT contiguous
if( layer3D >= LAYER_3D_USER_1 && layer3D <= LAYER_3D_USER_45 )
{
int user_idx = layer3D - LAYER_3D_USER_1;
m_materials.m_Plastic.m_Diffuse = m_boardAdapter.m_UserDefinedLayerColor[ user_idx ];
m_materials.m_Plastic.m_Ambient = SFVEC3F( m_materials.m_Plastic.m_Diffuse.r * 0.05f,
m_materials.m_Plastic.m_Diffuse.g * 0.05f,
m_materials.m_Plastic.m_Diffuse.b * 0.05f );
m_materials.m_Plastic.m_Specular = SFVEC3F( m_materials.m_Plastic.m_Diffuse.r * 0.7f,
m_materials.m_Plastic.m_Diffuse.g * 0.7f,
m_materials.m_Plastic.m_Diffuse.b * 0.7f );
m_materials.m_Plastic.m_Shininess = 0.078125f * 128.0f;
m_materials.m_Plastic.m_Emissive = SFVEC3F( 0.0f, 0.0f, 0.0f );
OglSetMaterial( m_materials.m_Plastic, 1.0f );
break;
}
m_materials.m_Copper.m_Diffuse = m_boardAdapter.m_CopperColor;
OglSetMaterial( m_materials.m_Copper, 1.0f );
break;
}
}
}
@@ -632,15 +632,7 @@ void RENDER_3D_RAYTRACE_BASE::Reload( REPORTER* aStatusReporter, REPORTER* aWarn
break;
default:
{
int layer3D = MapPCBLayerTo3DLayer( layer_id );
// Note: MUST do this in LAYER_3D space; User_1..User_45 are NOT contiguous
if( layer3D >= LAYER_3D_USER_1 && layer3D <= LAYER_3D_USER_45 )
{
layerColor = m_boardAdapter.m_UserDefinedLayerColor[ layer3D - LAYER_3D_USER_1 ];
}
else if( m_boardAdapter.m_Cfg->m_Render.differentiate_plated_copper )
if( m_boardAdapter.m_Cfg->m_Render.differentiate_plated_copper )
{
layerColor = SFVEC3F( 184.0f / 255.0f, 115.0f / 255.0f, 50.0f / 255.0f );
materialLayer = &m_materials.m_NonPlatedCopper;
@@ -653,7 +645,6 @@ void RENDER_3D_RAYTRACE_BASE::Reload( REPORTER* aStatusReporter, REPORTER* aWarn
break;
}
}
createItemsFromContainer( container2d, layer_id, materialLayer, layerColor, 0.0f );
} // for each layer on map
@@ -1291,12 +1282,8 @@ void RENDER_3D_RAYTRACE_BASE::load3DModels( CONTAINER_3D& aDstContainer,
continue;
// get it from cache
std::vector<const EMBEDDED_FILES*> embeddedFilesStack;
embeddedFilesStack.push_back( fp->GetEmbeddedFiles() );
embeddedFilesStack.push_back( m_boardAdapter.GetBoard()->GetEmbeddedFiles() );
const S3DMODEL* modelPtr = cacheMgr->GetModel( model.m_Filename, footprintBasePath,
embeddedFilesStack );
const S3DMODEL* modelPtr =
cacheMgr->GetModel( model.m_Filename, footprintBasePath, fp );
// only add it if the return is not NULL.
if( modelPtr )
@@ -274,12 +274,10 @@ void RENDER_3D_RAYTRACE_BASE::renderTracing( uint8_t* ptrPBO, REPORTER* aStatusR
}
};
BS::multi_future<void> futures;
for( size_t i = 0; i < tp.get_thread_count() + 1; ++i )
tp.push_task( processBlocks );
for( size_t i = 0; i < tp.get_thread_count(); ++i )
futures.push_back( tp.submit( processBlocks ) );
futures.wait();
tp.wait_for_tasks();
m_blockRenderProgressCount += numBlocksRendered;
@@ -482,8 +482,6 @@ void EDA_3D_VIEWER_FRAME::Process_Special_Functions( wxCommandEvent &event )
SETTINGS_MANAGER& mgr = Pgm().GetSettingsManager();
EDA_3D_VIEWER_SETTINGS* cfg = mgr.GetAppSettings<EDA_3D_VIEWER_SETTINGS>( "3d_viewer" );
m_boardAdapter.SetLayerColors( m_boardAdapter.GetDefaultColors() );
cfg->ResetToDefaults();
LoadSettings( cfg );
+16 -112
View File
@@ -19,7 +19,6 @@
* with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include <fmt/format.h>
#include <3d_enums.h>
#include <common_ogl/ogl_attr_list.h>
#include <settings/parameters.h>
@@ -82,35 +81,6 @@ PARAM_LAYER_PRESET_3D::PARAM_LAYER_PRESET_3D( const std::string& aPath,
m_presets( aPresetList )
{
wxASSERT( aPresetList );
#define LAYER( n, l ) m_layerToLayerNameMap[l] = n; m_layerNameToLayerMap[n] = l;
LAYER( "fp_values", LAYER_FP_VALUES );
LAYER( "fp_references", LAYER_FP_REFERENCES );
LAYER( "fp_text", LAYER_FP_TEXT );
LAYER( "background_bottom", LAYER_3D_BACKGROUND_BOTTOM );
LAYER( "background_top", LAYER_3D_BACKGROUND_TOP );
LAYER( "board", LAYER_3D_BOARD );
LAYER( "copper", LAYER_3D_COPPER_TOP );
LAYER( "copper_bottom", LAYER_3D_COPPER_BOTTOM );
LAYER( "silkscreen_bottom", LAYER_3D_SILKSCREEN_BOTTOM );
LAYER( "silkscreen_top", LAYER_3D_SILKSCREEN_TOP );
LAYER( "soldermask_bottom", LAYER_3D_SOLDERMASK_BOTTOM );
LAYER( "soldermask_top", LAYER_3D_SOLDERMASK_TOP );
LAYER( "solderpaste", LAYER_3D_SOLDERPASTE );
LAYER( "adhesive", LAYER_3D_ADHESIVE );
LAYER( "user_comments", LAYER_3D_USER_COMMENTS );
LAYER( "user_drawings", LAYER_3D_USER_DRAWINGS );
LAYER( "user_eco1", LAYER_3D_USER_ECO1 );
LAYER( "user_eco2", LAYER_3D_USER_ECO2 );
LAYER( "3d_axes", LAYER_3D_AXES );
LAYER( "th_models", LAYER_3D_TH_MODELS );
LAYER( "smd_models", LAYER_3D_SMD_MODELS );
LAYER( "virtual_models", LAYER_3D_VIRTUAL_MODELS );
LAYER( "non_pos_file_models", LAYER_3D_MODELS_NOT_IN_POS );
LAYER( "dnp_models", LAYER_3D_MODELS_MARKED_DNP );
LAYER( "bounding_boxes", LAYER_3D_BOUNDING_BOXES );
LAYER( "off_board_silk", LAYER_3D_OFF_BOARD_SILK );
}
@@ -129,7 +99,7 @@ nlohmann::json PARAM_LAYER_PRESET_3D::presetsToJson()
for( int layer = 0; layer < LAYER_3D_END; ++layer )
{
if( preset.layers.test( layer ) )
layers.push_back( m_layerToLayerNameMap[layer] );
layers.push_back( layer );
}
js["layers"] = layers;
@@ -139,7 +109,7 @@ nlohmann::json PARAM_LAYER_PRESET_3D::presetsToJson()
for( const auto& [ layer, color ] : preset.colors )
{
nlohmann::json layerColor = {
{ "layer", m_layerToLayerNameMap[layer] },
{ "layer", layer },
{ "color", color.ToCSSString() }
};
@@ -174,20 +144,26 @@ void PARAM_LAYER_PRESET_3D::jsonToPresets( const nlohmann::json& aJson )
for( const nlohmann::json& layer : preset.at( "layers" ) )
{
if( layer.is_string() )
p.layers.set( m_layerNameToLayerMap[layer.get<wxString>()] );
if( layer.is_number_integer() )
{
int layerNum = layer.get<int>();
if( layerNum >= 0 && layerNum < LAYER_3D_END )
p.layers.set( layerNum );
}
}
}
if( preset.contains( "colors" ) && preset.at( "colors" ).is_array() )
{
for( const nlohmann::json& entry : preset.at( "colors" ) )
for( const nlohmann::json& layerColor : preset.at( "colors" ) )
{
if( entry.contains( "layer" ) && entry.contains( "color" )
&& entry.at( "layer" ).is_string() )
if( layerColor.contains( "layer" ) && layerColor.contains( "color" )
&& layerColor.at( "layer" ).is_number_integer() )
{
int layerNum = m_layerNameToLayerMap[entry.at( "layer" ).get<wxString>()];
p.colors[ layerNum ] = entry.at( "color" ).get<COLOR4D>();
int layerNum = layerColor.at( "layer" ).get<int>();
COLOR4D color = layerColor.at( "color" ).get<COLOR4D>();
p.colors[ layerNum ] = color;
}
}
}
@@ -199,7 +175,7 @@ void PARAM_LAYER_PRESET_3D::jsonToPresets( const nlohmann::json& aJson )
///! Update the schema version whenever a migration is required
const int viewer3dSchemaVersion = 4;
const int viewer3dSchemaVersion = 3;
EDA_3D_VIEWER_SETTINGS::EDA_3D_VIEWER_SETTINGS() :
@@ -354,13 +330,6 @@ EDA_3D_VIEWER_SETTINGS::EDA_3D_VIEWER_SETTINGS() :
&m_Render.show_eco1, true ) );
m_params.emplace_back( new PARAM<bool>( "render.show_eco2",
&m_Render.show_eco2, true ) );
for( int layer = 0; layer < 45; ++layer )
{
m_params.emplace_back( new PARAM<bool>( fmt::format( "render.show_user{}", layer + 1 ),
&m_Render.show_user[layer], false ) );
}
m_params.emplace_back( new PARAM<bool>( "render.show_footprints_insert",
&m_Render.show_footprints_insert, true ) );
m_params.emplace_back( new PARAM<bool>( "render.show_footprints_normal",
@@ -401,8 +370,6 @@ EDA_3D_VIEWER_SETTINGS::EDA_3D_VIEWER_SETTINGS() :
&m_Render.differentiate_plated_copper, false ) );
m_params.emplace_back( new PARAM<bool>( "render.use_board_editor_copper_colors",
&m_Render.use_board_editor_copper_colors, false ) );
m_params.emplace_back( new PARAM<bool>( "render.preview_show_board_body",
&m_Render.preview_show_board_body, true ) );
m_params.emplace_back( new PARAM<bool>( "camera.animation_enabled",
&m_Camera.animation_enabled, true ) );
m_params.emplace_back( new PARAM<int>( "camera.moving_speed_multiplier",
@@ -458,69 +425,6 @@ EDA_3D_VIEWER_SETTINGS::EDA_3D_VIEWER_SETTINGS() :
Set( "render.show_eco2", *optval );
}
return true;
} );
registerMigration( 3, 4,
[&]() -> bool
{
std::map<int, wxString> legacyColorMap;
legacyColorMap[142] = "fp_values";
legacyColorMap[143] = "fp_references";
legacyColorMap[130] = "fp_text";
legacyColorMap[466] = "background_bottom";
legacyColorMap[467] = "background_top";
legacyColorMap[468] = "board";
legacyColorMap[469] = "copper";
legacyColorMap[470] = "copper_bottom";
legacyColorMap[471] = "silkscreen_bottom";
legacyColorMap[472] = "silkscreen_top";
legacyColorMap[473] = "soldermask_bottom";
legacyColorMap[474] = "soldermask_top";
legacyColorMap[475] = "solderpaste";
legacyColorMap[476] = "adhesive";
legacyColorMap[477] = "user_comments";
legacyColorMap[478] = "user_drawings";
legacyColorMap[479] = "user_eco1";
legacyColorMap[480] = "user_eco2";
legacyColorMap[481] = "th_models";
legacyColorMap[482] = "smd_models";
legacyColorMap[483] = "virtual_models";
legacyColorMap[484] = "non_pos_file_models";
legacyColorMap[485] = "dnp_models";
legacyColorMap[486] = "3d_axes";
legacyColorMap[487] = "bounding_boxes";
legacyColorMap[488] = "off_board_silk";
if( !Contains( "layer_presets" ) || !At( "layer_presets" ).is_array() )
return true;
for( nlohmann::json& preset : At( "layer_presets" ) )
{
if( preset.contains( "colors" ) && preset.at( "colors" ).is_array() )
{
for( nlohmann::json& color : preset.at( "colors" ) )
{
if( color.contains( "layer" ) && color.at( "layer" ).is_number_integer() )
color["layer"] = legacyColorMap[color["layer"].get<int>()];
}
}
if( preset.contains( "layers" ) && preset.at( "layers" ).is_array() )
{
nlohmann::json mappedLayers = nlohmann::json::array();
for( const nlohmann::json& layer : preset.at( "layers" ) )
{
if( layer.is_number_integer() )
mappedLayers.push_back( legacyColorMap[layer.get<int>()] );
}
preset["layers"] = mappedLayers;
}
}
return true;
} );
}
+8 -11
View File
@@ -64,11 +64,7 @@ private:
void jsonToPresets( const nlohmann::json& aJson );
private:
std::vector<LAYER_PRESET_3D>* m_presets;
std::map<int, wxString> m_layerToLayerNameMap;
std::map<wxString, int> m_layerNameToLayerMap;
};
@@ -132,7 +128,6 @@ public:
bool show_drawings;
bool show_eco1;
bool show_eco2;
bool show_user[45];
bool show_footprints_insert;
bool show_footprints_normal;
bool show_footprints_virtual;
@@ -152,19 +147,21 @@ public:
bool subtract_mask_from_silk;
bool clip_silk_on_via_annuli;
bool differentiate_plated_copper;
bool use_board_editor_copper_colors; // OpenGL only
bool preview_show_board_body;
// Board editor copper colors are used only in OpenGL mode if
// use_board_editor_copper_colors is true
bool use_board_editor_copper_colors;
/**
* return true if platted copper aeras and non platted copper areas must be drawn
* using a different color
* in OPENGL mode, if use_board_editor_copper_colors, always false
* in RAYTRACING mode, use_board_editor_copper_colors is ignored (board editor copper
* colors are ignored)
*/
bool DifferentiatePlatedCopper()
{
if( engine == RENDER_ENGINE::OPENGL && use_board_editor_copper_colors )
return false;
return differentiate_plated_copper;
return engine == RENDER_ENGINE::RAYTRACING ? differentiate_plated_copper
: differentiate_plated_copper && !use_board_editor_copper_colors;
}
};
+73 -137
View File
@@ -29,7 +29,8 @@
#include <eda_3d_viewer_frame.h>
#include <pcbnew_settings.h>
#include <project.h>
#include <board.h>
#include <settings/settings_manager.h>
#include <settings/color_settings.h>
#include <tool/tool_manager.h>
#include <tools/pcb_actions.h>
#include <tools/eda_3d_actions.h>
@@ -47,87 +48,44 @@
/// Render Row abbreviation to reduce source width.
#define RR APPEARANCE_CONTROLS_3D::APPEARANCE_SETTING_3D
// clang-format off
/// Template for object appearance settings
const APPEARANCE_CONTROLS_3D::APPEARANCE_SETTING_3D APPEARANCE_CONTROLS_3D::s_layerSettings[] = {
// text id tooltip
RR( _HKI( "Board Body" ), LAYER_3D_BOARD, _HKI( "Show board body" ) ),
RR( wxS( "F.Cu" ), LAYER_3D_COPPER_TOP, _HKI( "Show front copper / surface finish color" ) ),
RR( wxS( "B.Cu" ), LAYER_3D_COPPER_BOTTOM, _HKI( "Show back copper / surface finish color" ) ),
RR( _HKI( "Adhesive" ), LAYER_3D_ADHESIVE, _HKI( "Show adhesive" ) ),
RR( _HKI( "Solder Paste" ), LAYER_3D_SOLDERPASTE, _HKI( "Show solder paste" ) ),
RR( wxS( "F.Silkscreen" ), LAYER_3D_SILKSCREEN_TOP, _HKI( "Show front silkscreen" ) ),
RR( wxS( "B.Silkscreen" ), LAYER_3D_SILKSCREEN_BOTTOM, _HKI( "Show back silkscreen" ) ),
RR( wxS( "F.Mask" ), LAYER_3D_SOLDERMASK_TOP, _HKI( "Show front solder mask" ) ),
RR( wxS( "B.Mask" ), LAYER_3D_SOLDERMASK_BOTTOM, _HKI( "Show back solder mask" ) ),
RR( wxS( "User.Drawings" ), LAYER_3D_USER_DRAWINGS, _HKI( "Show user drawings layer" ) ),
RR( wxS( "User.Comments" ), LAYER_3D_USER_COMMENTS, _HKI( "Show user comments layer" ) ),
RR( wxS( "User.Eco1" ), LAYER_3D_USER_ECO1, _HKI( "Show user ECO1 layer" ) ),
RR( wxS( "User.Eco2" ), LAYER_3D_USER_ECO2, _HKI( "Show user ECO2 layer" ) ),
RR( wxS( "User.1" ), LAYER_3D_USER_1, _HKI( "Show user defined layer 1" ) ),
RR( wxS( "User.2" ), LAYER_3D_USER_2, _HKI( "Show user defined layer 2" ) ),
RR( wxS( "User.3" ), LAYER_3D_USER_3, _HKI( "Show user defined layer 3" ) ),
RR( wxS( "User.4" ), LAYER_3D_USER_4, _HKI( "Show user defined layer 4" ) ),
RR( wxS( "User.5" ), LAYER_3D_USER_5, _HKI( "Show user defined layer 5" ) ),
RR( wxS( "User.6" ), LAYER_3D_USER_6, _HKI( "Show user defined layer 6" ) ),
RR( wxS( "User.7" ), LAYER_3D_USER_7, _HKI( "Show user defined layer 7" ) ),
RR( wxS( "User.8" ), LAYER_3D_USER_8, _HKI( "Show user defined layer 8" ) ),
RR( wxS( "User.9" ), LAYER_3D_USER_9, _HKI( "Show user defined layer 9" ) ),
RR( wxS( "User.10" ), LAYER_3D_USER_10, _HKI( "Show user defined layer 10" ) ),
RR( wxS( "User.11" ), LAYER_3D_USER_11, _HKI( "Show user defined layer 11" ) ),
RR( wxS( "User.12" ), LAYER_3D_USER_12, _HKI( "Show user defined layer 12" ) ),
RR( wxS( "User.13" ), LAYER_3D_USER_13, _HKI( "Show user defined layer 13" ) ),
RR( wxS( "User.14" ), LAYER_3D_USER_14, _HKI( "Show user defined layer 14" ) ),
RR( wxS( "User.15" ), LAYER_3D_USER_15, _HKI( "Show user defined layer 15" ) ),
RR( wxS( "User.16" ), LAYER_3D_USER_16, _HKI( "Show user defined layer 16" ) ),
RR( wxS( "User.17" ), LAYER_3D_USER_17, _HKI( "Show user defined layer 17" ) ),
RR( wxS( "User.18" ), LAYER_3D_USER_18, _HKI( "Show user defined layer 18" ) ),
RR( wxS( "User.19" ), LAYER_3D_USER_19, _HKI( "Show user defined layer 19" ) ),
RR( wxS( "User.20" ), LAYER_3D_USER_20, _HKI( "Show user defined layer 20" ) ),
RR( wxS( "User.21" ), LAYER_3D_USER_21, _HKI( "Show user defined layer 21" ) ),
RR( wxS( "User.22" ), LAYER_3D_USER_22, _HKI( "Show user defined layer 22" ) ),
RR( wxS( "User.23" ), LAYER_3D_USER_23, _HKI( "Show user defined layer 23" ) ),
RR( wxS( "User.24" ), LAYER_3D_USER_24, _HKI( "Show user defined layer 24" ) ),
RR( wxS( "User.25" ), LAYER_3D_USER_25, _HKI( "Show user defined layer 25" ) ),
RR( wxS( "User.26" ), LAYER_3D_USER_26, _HKI( "Show user defined layer 26" ) ),
RR( wxS( "User.27" ), LAYER_3D_USER_27, _HKI( "Show user defined layer 27" ) ),
RR( wxS( "User.28" ), LAYER_3D_USER_28, _HKI( "Show user defined layer 28" ) ),
RR( wxS( "User.29" ), LAYER_3D_USER_29, _HKI( "Show user defined layer 29" ) ),
RR( wxS( "User.30" ), LAYER_3D_USER_30, _HKI( "Show user defined layer 30" ) ),
RR( wxS( "User.31" ), LAYER_3D_USER_31, _HKI( "Show user defined layer 31" ) ),
RR( wxS( "User.32" ), LAYER_3D_USER_32, _HKI( "Show user defined layer 32" ) ),
RR( wxS( "User.33" ), LAYER_3D_USER_33, _HKI( "Show user defined layer 33" ) ),
RR( wxS( "User.34" ), LAYER_3D_USER_34, _HKI( "Show user defined layer 34" ) ),
RR( wxS( "User.35" ), LAYER_3D_USER_35, _HKI( "Show user defined layer 35" ) ),
RR( wxS( "User.36" ), LAYER_3D_USER_36, _HKI( "Show user defined layer 36" ) ),
RR( wxS( "User.37" ), LAYER_3D_USER_37, _HKI( "Show user defined layer 37" ) ),
RR( wxS( "User.38" ), LAYER_3D_USER_38, _HKI( "Show user defined layer 38" ) ),
RR( wxS( "User.39" ), LAYER_3D_USER_39, _HKI( "Show user defined layer 39" ) ),
RR( wxS( "User.40" ), LAYER_3D_USER_40, _HKI( "Show user defined layer 40" ) ),
RR( wxS( "User.41" ), LAYER_3D_USER_41, _HKI( "Show user defined layer 41" ) ),
RR( wxS( "User.42" ), LAYER_3D_USER_42, _HKI( "Show user defined layer 42" ) ),
RR( wxS( "User.43" ), LAYER_3D_USER_43, _HKI( "Show user defined layer 43" ) ),
RR( wxS( "User.44" ), LAYER_3D_USER_44, _HKI( "Show user defined layer 44" ) ),
RR( wxS( "User.45" ), LAYER_3D_USER_45, _HKI( "Show user defined layer 45" ) ),
// text id tooltip
RR( _HKI( "Board Body" ), LAYER_3D_BOARD, _HKI( "Show board body" ) ),
RR( _HKI( "F.Cu" ), LAYER_3D_COPPER_TOP, _HKI( "Show front copper / surface finish color" ) ),
RR( _HKI( "B.Cu" ), LAYER_3D_COPPER_BOTTOM, _HKI( "Show back copper / surface finish color" ) ),
RR( _HKI( "Adhesive" ), LAYER_3D_ADHESIVE, _HKI( "Show adhesive" ) ),
RR( _HKI( "Solder Paste" ), LAYER_3D_SOLDERPASTE, _HKI( "Show solder paste" ) ),
RR( _HKI( "F.Silkscreen" ), LAYER_3D_SILKSCREEN_TOP, _HKI( "Show front silkscreen" ) ),
RR( _HKI( "B.Silkscreen" ), LAYER_3D_SILKSCREEN_BOTTOM, _HKI( "Show back silkscreen" ) ),
RR( _HKI( "F.Mask" ), LAYER_3D_SOLDERMASK_TOP, _HKI( "Show front solder mask" ) ),
RR( _HKI( "B.Mask" ), LAYER_3D_SOLDERMASK_BOTTOM, _HKI( "Show back solder mask" ) ),
RR( _HKI( "User.Drawings" ), LAYER_3D_USER_DRAWINGS, _HKI( "Show user drawings layer" ) ),
RR( _HKI( "User.Comments" ), LAYER_3D_USER_COMMENTS, _HKI( "Show user comments layer" ) ),
RR( _HKI( "User.Eco1" ), LAYER_3D_USER_ECO1, _HKI( "Show user ECO1 layer" ) ),
RR( _HKI( "User.Eco2" ), LAYER_3D_USER_ECO2, _HKI( "Show user ECO2 layer" ) ),
RR(),
RR( _HKI( "Through-hole Models" ), LAYER_3D_TH_MODELS, EDA_3D_ACTIONS::showTHT ),
RR( _HKI( "SMD Models" ), LAYER_3D_SMD_MODELS, EDA_3D_ACTIONS::showSMD ),
RR( _HKI( "Virtual Models" ), LAYER_3D_VIRTUAL_MODELS, EDA_3D_ACTIONS::showVirtual ),
RR( _HKI( "Models not in POS File" ), LAYER_3D_MODELS_NOT_IN_POS, EDA_3D_ACTIONS::showNotInPosFile ),
RR( _HKI( "Models marked DNP" ), LAYER_3D_MODELS_MARKED_DNP, EDA_3D_ACTIONS::showDNP ),
RR( _HKI( "Model Bounding Boxes" ), LAYER_3D_BOUNDING_BOXES, EDA_3D_ACTIONS::showBBoxes ),
RR( _HKI( "Through-hole Models" ), LAYER_3D_TH_MODELS, EDA_3D_ACTIONS::showTHT ),
RR( _HKI( "SMD Models" ), LAYER_3D_SMD_MODELS, EDA_3D_ACTIONS::showSMD ),
RR( _HKI( "Virtual Models" ), LAYER_3D_VIRTUAL_MODELS, EDA_3D_ACTIONS::showVirtual ),
RR( _HKI( "Models not in POS File" ), LAYER_3D_MODELS_NOT_IN_POS,
EDA_3D_ACTIONS::showNotInPosFile ),
RR( _HKI( "Models marked DNP" ), LAYER_3D_MODELS_MARKED_DNP, EDA_3D_ACTIONS::showDNP ),
RR( _HKI( "Model Bounding Boxes" ), LAYER_3D_BOUNDING_BOXES, EDA_3D_ACTIONS::showBBoxes ),
RR(),
RR( _HKI( "Values" ), LAYER_FP_VALUES, _HKI( "Show footprint values" ) ),
RR( _HKI( "References" ), LAYER_FP_REFERENCES, _HKI( "Show footprint references" ) ),
RR( _HKI( "Footprint Text" ), LAYER_FP_TEXT, _HKI( "Show all footprint text" ) ),
RR( _HKI( "Off-board Silkscreen" ), LAYER_3D_OFF_BOARD_SILK, _HKI( "Do not clip silk layers to board outline" ) ),
RR( _HKI( "Values" ), LAYER_FP_VALUES, _HKI( "Show footprint values" ) ),
RR( _HKI( "References" ), LAYER_FP_REFERENCES, _HKI( "Show footprint references" ) ),
RR( _HKI( "Footprint Text" ), LAYER_FP_TEXT, _HKI( "Show all footprint text" ) ),
RR( _HKI( "Off-board Silkscreen" ), LAYER_3D_OFF_BOARD_SILK,
_HKI( "Do not clip silk layers to board outline" ) ),
RR(),
RR( _HKI( "3D Axis" ), LAYER_3D_AXES, EDA_3D_ACTIONS::showAxis ),
RR( _HKI( "Background Start" ), LAYER_3D_BACKGROUND_TOP, _HKI( "Background gradient start color" ) ),
RR( _HKI( "Background End" ), LAYER_3D_BACKGROUND_BOTTOM, _HKI( "Background gradient end color" ) ),
RR( _HKI( "3D Axis" ), LAYER_3D_AXES, EDA_3D_ACTIONS::showAxis ),
RR( _HKI( "Background Start" ), LAYER_3D_BACKGROUND_TOP,
_HKI( "Background gradient start color" ) ),
RR( _HKI( "Background End" ), LAYER_3D_BACKGROUND_BOTTOM,
_HKI( "Background gradient end color" ) ),
};
// clang-format on
// The list of IDs that can have colors coming from the board stackup, and cannot be
// modified if use colors from stackup is activated
@@ -177,14 +135,15 @@ APPEARANCE_CONTROLS_3D::APPEARANCE_CONTROLS_3D( EDA_3D_VIEWER_FRAME* aParent,
cfg->m_UseStackupColors = aEvent.IsChecked();
UpdateLayerCtls();
syncLayerPresetSelection();
m_frame->NewDisplay( true );
} );
m_cbUseBoardEditorCopperColors = new wxCheckBox( m_panelLayers, wxID_ANY,
_( "Use PCB editor copper colors" ) );
_( "Use board editor copper colors" ) );
m_cbUseBoardEditorCopperColors->SetFont( infoFont );
m_cbUseBoardEditorCopperColors->SetToolTip( _( "Use the board editor layer colors for copper "
"layers (realtime renderer only)" ) );
m_cbUseBoardEditorCopperColors->SetToolTip(
_( "Use the board editor copper colors (openGL only)" ) );
m_cbUseBoardEditorCopperColors->Bind( wxEVT_CHECKBOX,
[this]( wxCommandEvent& aEvent )
@@ -193,12 +152,14 @@ APPEARANCE_CONTROLS_3D::APPEARANCE_CONTROLS_3D( EDA_3D_VIEWER_FRAME* aParent,
cfg->m_Render.use_board_editor_copper_colors = aEvent.IsChecked();
UpdateLayerCtls();
syncLayerPresetSelection();
m_frame->NewDisplay( true );
} );
m_panelLayersSizer->Add( m_cbUseBoardStackupColors, 0, wxEXPAND | wxTOP | wxLEFT | wxRIGHT, 5 );
m_panelLayersSizer->Add( m_cbUseBoardStackupColors, 0, wxEXPAND | wxTOP | wxLEFT | wxRIGHT, 7 );
m_panelLayersSizer->Add( m_cbUseBoardEditorCopperColors, 0,
wxEXPAND | wxALL, 5 );
wxEXPAND | wxTOP | wxLEFT | wxRIGHT, 7 );
m_cbLayerPresets->SetToolTip( wxString::Format( _( "Save and restore color and visibility "
"combinations.\n"
@@ -312,19 +273,22 @@ void APPEARANCE_CONTROLS_3D::CommonSettingsChanged()
rebuildControls();
UpdateLayerCtls();
const wxString& currentPreset = m_frame->GetAdapter().m_Cfg->m_CurrentPreset;
if( currentPreset == FOLLOW_PCB || currentPreset == FOLLOW_PLOT_SETTINGS )
updateLayerPresetWidget( currentPreset );
else
syncLayerPresetSelection();
syncLayerPresetSelection();
}
void APPEARANCE_CONTROLS_3D::ApplyLayerPreset( const wxString& aPresetName )
{
doApplyLayerPreset( aPresetName );
if( aPresetName == FOLLOW_PCB || aPresetName == FOLLOW_PLOT_SETTINGS )
{
m_frame->GetAdapter().m_Cfg->m_CurrentPreset = aPresetName;
UpdateLayerCtls();
m_frame->NewDisplay( true );
}
else if( LAYER_PRESET_3D* preset = m_frame->GetAdapter().m_Cfg->FindPreset( aPresetName ) )
{
doApplyLayerPreset( *preset );
}
// Move to front of MRU list
if( m_presetMRU.Index( aPresetName ) != wxNOT_FOUND )
@@ -456,10 +420,6 @@ void APPEARANCE_CONTROLS_3D::OnLayerVisibilityChanged( int aLayer, bool isVisibl
default:
visibleLayers.set( aLayer, isVisible );
if( aLayer >= LAYER_3D_USER_1 && aLayer <= LAYER_3D_USER_45 )
killFollow = true;
break;
}
@@ -493,6 +453,7 @@ void APPEARANCE_CONTROLS_3D::onColorSwatchChanged( COLOR_SWATCH* aSwatch )
std::map<int, COLOR4D> colors = m_frame->GetAdapter().GetLayerColors();
m_frame->GetAdapter().SetVisibleLayers( visibleLayers );
m_frame->GetAdapter().SetLayerColors( colors );
int layer = aSwatch->GetId();
COLOR4D newColor = aSwatch->GetSwatchColor();
@@ -506,12 +467,7 @@ void APPEARANCE_CONTROLS_3D::onColorSwatchChanged( COLOR_SWATCH* aSwatch )
m_frame->GetAdapter().SetLayerColors( colors );
const wxString& currentPreset = m_frame->GetAdapter().m_Cfg->m_CurrentPreset;
if( currentPreset == FOLLOW_PCB || currentPreset == FOLLOW_PLOT_SETTINGS )
updateLayerPresetWidget( currentPreset );
else
syncLayerPresetSelection();
syncLayerPresetSelection();
m_frame->NewDisplay( true );
}
@@ -524,7 +480,6 @@ void APPEARANCE_CONTROLS_3D::rebuildLayers()
std::bitset<LAYER_3D_END> visibleLayers = m_frame->GetAdapter().GetVisibleLayers();
std::map<int, COLOR4D> colors = m_frame->GetAdapter().GetLayerColors();
std::map<int, COLOR4D> defaultColors = m_frame->GetAdapter().GetDefaultColors();
LSET enabled = m_frame->GetBoard()->GetEnabledLayers();
m_layerSettings.clear();
m_layersOuterSizer->Clear( true );
@@ -579,13 +534,8 @@ void APPEARANCE_CONTROLS_3D::rebuildLayers()
sizer->AddSpacer( 5 );
wxString layerName = aSetting->GetLabel();
PCB_LAYER_ID boardLayer = Map3DLayerToPCBLayer( layer );
if( boardLayer != UNDEFINED_LAYER )
layerName = m_frame->GetBoard()->GetLayerName( boardLayer );
wxStaticText* label = new wxStaticText( m_windowLayers, layer, layerName );
wxStaticText* label = new wxStaticText( m_windowLayers, layer,
aSetting->GetLabel() );
label->Wrap( -1 );
label->SetToolTip( aSetting->GetTooltip() );
@@ -630,18 +580,9 @@ void APPEARANCE_CONTROLS_3D::rebuildLayers()
std::unique_ptr<APPEARANCE_SETTING_3D>& setting = m_layerSettings.back();
if( setting->m_Spacer )
{
m_layersOuterSizer->AddSpacer( m_pointSize );
}
else if( setting->m_Id >= LAYER_3D_USER_1 && setting->m_Id <= LAYER_3D_USER_45 )
{
if( enabled.test( Map3DLayerToPCBLayer( setting->m_Id ) ) )
appendLayer( setting );
}
else
{
appendLayer( setting );
}
m_layerSettingsMap[setting->m_Id] = setting.get();
}
@@ -790,11 +731,17 @@ void APPEARANCE_CONTROLS_3D::onLayerPresetChanged( wxCommandEvent& aEvent )
if( index == 0 )
{
doApplyLayerPreset( FOLLOW_PCB );
name = FOLLOW_PCB;
cfg->m_CurrentPreset = name;
UpdateLayerCtls();
m_frame->NewDisplay( true );
}
else if( index == 1 )
{
doApplyLayerPreset( FOLLOW_PLOT_SETTINGS );
name = FOLLOW_PLOT_SETTINGS;
cfg->m_CurrentPreset = name;
UpdateLayerCtls();
m_frame->NewDisplay( true );
}
else if( index == count - 3 )
{
@@ -880,9 +827,10 @@ void APPEARANCE_CONTROLS_3D::onLayerPresetChanged( wxCommandEvent& aEvent )
resetSelection();
return;
}
else
else if( LAYER_PRESET_3D* preset = cfg->FindPreset( m_cbLayerPresets->GetStringSelection() ) )
{
doApplyLayerPreset( m_cbLayerPresets->GetStringSelection() );
name = preset->name;
doApplyLayerPreset( *preset );
}
// Move to front of MRU list
@@ -895,28 +843,16 @@ void APPEARANCE_CONTROLS_3D::onLayerPresetChanged( wxCommandEvent& aEvent )
}
void APPEARANCE_CONTROLS_3D::doApplyLayerPreset( const wxString& aPresetName )
void APPEARANCE_CONTROLS_3D::doApplyLayerPreset( const LAYER_PRESET_3D& aPreset )
{
BOARD_ADAPTER& adapter = m_frame->GetAdapter();
if( aPresetName == FOLLOW_PCB || aPresetName == FOLLOW_PLOT_SETTINGS )
{
adapter.m_Cfg->m_CurrentPreset = aPresetName;
adapter.SetVisibleLayers( adapter.GetVisibleLayers() );
}
else if( LAYER_PRESET_3D* preset = adapter.m_Cfg->FindPreset( aPresetName ) )
{
adapter.m_Cfg->m_CurrentPreset = aPresetName;
adapter.SetVisibleLayers( preset->layers );
adapter.SetLayerColors( preset->colors );
adapter.m_Cfg->m_CurrentPreset = aPreset.name;
adapter.SetVisibleLayers( aPreset.layers );
adapter.SetLayerColors( aPreset.colors );
if( preset->name.Lower() == _( "legacy colors" ) )
adapter.m_Cfg->m_UseStackupColors = false;
}
else
{
return;
}
if( aPreset.name.Lower() == _( "legacy colors" ) )
adapter.m_Cfg->m_UseStackupColors = false;
UpdateLayerCtls();
m_frame->NewDisplay( true );
+1 -1
View File
@@ -157,7 +157,7 @@ private:
void onLayerPresetChanged( wxCommandEvent& aEvent ) override;
void doApplyLayerPreset( const wxString& aPresetName );
void doApplyLayerPreset( const LAYER_PRESET_3D& aPreset );
void onViewportChanged( wxCommandEvent& aEvent ) override;
void onUpdateViewportsCb( wxUpdateUIEvent& aEvent ) override;
@@ -11,7 +11,7 @@
APPEARANCE_CONTROLS_3D_BASE::APPEARANCE_CONTROLS_3D_BASE( wxWindow* parent, wxWindowID id, const wxPoint& pos, const wxSize& size, long style, const wxString& name ) : WX_PANEL( parent, id, pos, size, style, name )
{
this->SetMinSize( wxSize( 210,360 ) );
this->SetMinSize( wxSize( 200,360 ) );
m_sizerOuter = new wxBoxSizer( wxVERTICAL );
@@ -45,7 +45,7 @@
<property name="hidden">0</property>
<property name="id">wxID_ANY</property>
<property name="maximum_size"></property>
<property name="minimum_size">210,360</property>
<property name="minimum_size">200,360</property>
<property name="name">APPEARANCE_CONTROLS_3D_BASE</property>
<property name="pos"></property>
<property name="size">-1,-1</property>
+28 -25
View File
@@ -27,7 +27,6 @@
#include "panel_preview_3d_model.h"
#include <dialogs/dialog_unit_entry.h>
#include <3d_canvas/eda_3d_canvas.h>
#include <3d_rendering/opengl/render_3d_opengl.h>
#include <tool/tool_manager.h>
#include <tool/tool_dispatcher.h>
#include <tools/eda_3d_actions.h>
@@ -65,11 +64,12 @@ PANEL_PREVIEW_3D_MODEL::PANEL_PREVIEW_3D_MODEL( wxWindow* aParent, PCB_BASE_FRAM
m_dummyBoard = new BOARD();
m_dummyBoard->SetProject( &aFrame->Prj(), true );
m_dummyBoard->SetEmbeddedFilesDelegate( aFrame->GetBoard() );
// This board will only be used to hold a footprint for viewing
m_dummyBoard->SetBoardUse( BOARD_USE::FPHOLDER );
m_bodyStyleShowAll = true;
BOARD_DESIGN_SETTINGS parent_bds = aFrame->GetDesignSettings();
BOARD_DESIGN_SETTINGS& dummy_bds = m_dummyBoard->GetDesignSettings();
dummy_bds.SetBoardThickness( parent_bds.GetBoardThickness() );
@@ -225,6 +225,16 @@ void PANEL_PREVIEW_3D_MODEL::loadSettings()
m_previewPane->SetAnimationEnabled( cfg->m_Camera.animation_enabled );
m_previewPane->SetMovingSpeedMultiplier( cfg->m_Camera.moving_speed_multiplier );
m_previewPane->SetProjectionMode( cfg->m_Camera.projection_mode );
// Ensure the board body is always shown, and do not use the settings of the 3D viewer
cfg->m_Render.show_copper_top = m_bodyStyleShowAll;
cfg->m_Render.show_copper_bottom = m_bodyStyleShowAll;
cfg->m_Render.show_soldermask_top = m_bodyStyleShowAll;
cfg->m_Render.show_soldermask_bottom = m_bodyStyleShowAll;
cfg->m_Render.show_solderpaste = m_bodyStyleShowAll;
cfg->m_Render.show_zones = m_bodyStyleShowAll;
cfg->m_Render.show_board_body = m_bodyStyleShowAll;
cfg->m_Render.use_board_editor_copper_colors = false;
}
}
@@ -276,7 +286,7 @@ wxString PANEL_PREVIEW_3D_MODEL::formatRotationValue( double aValue )
wxString PANEL_PREVIEW_3D_MODEL::formatOffsetValue( double aValue )
{
// Convert from internal units (mm) to user units
if( m_userUnits == EDA_UNITS::INCH )
if( m_userUnits == EDA_UNITS::INCHES )
aValue /= 25.4;
else if( m_userUnits == EDA_UNITS::MILS )
aValue /= 25.4 / 1e3;
@@ -395,7 +405,13 @@ void PANEL_PREVIEW_3D_MODEL::setBodyStyleView( wxCommandEvent& event )
if( !cfg )
return;
cfg->m_Render.preview_show_board_body = !cfg->m_Render.preview_show_board_body;
m_bodyStyleShowAll = !m_bodyStyleShowAll;
cfg->m_Render.show_soldermask_top = m_bodyStyleShowAll;
cfg->m_Render.show_soldermask_bottom = m_bodyStyleShowAll;
cfg->m_Render.show_solderpaste = m_bodyStyleShowAll;
cfg->m_Render.show_zones = m_bodyStyleShowAll;
cfg->m_Render.show_board_body = m_bodyStyleShowAll;
m_previewPane->ReloadRequest();
m_previewPane->Refresh();
@@ -428,9 +444,7 @@ void PANEL_PREVIEW_3D_MODEL::View3DSettings( wxCommandEvent& event )
void PANEL_PREVIEW_3D_MODEL::doIncrementScale( wxSpinEvent& event, double aSign )
{
wxSpinButton* spinCtrl = dynamic_cast<wxSpinButton*>( event.GetEventObject() );
wxCHECK( spinCtrl, /* void */ );
wxSpinButton* spinCtrl = (wxSpinButton*) event.GetEventObject();
wxTextCtrl * textCtrl = xscale;
@@ -457,10 +471,7 @@ void PANEL_PREVIEW_3D_MODEL::doIncrementScale( wxSpinEvent& event, double aSign
void PANEL_PREVIEW_3D_MODEL::doIncrementRotation( wxSpinEvent& aEvent, double aSign )
{
wxSpinButton* spinCtrl = dynamic_cast<wxSpinButton*>( aEvent.GetEventObject() );
wxCHECK( spinCtrl, /* void */ );
wxSpinButton* spinCtrl = (wxSpinButton*) aEvent.GetEventObject();
wxTextCtrl* textCtrl = xrot;
if( spinCtrl == m_spinYrot )
@@ -486,9 +497,7 @@ void PANEL_PREVIEW_3D_MODEL::doIncrementRotation( wxSpinEvent& aEvent, double aS
void PANEL_PREVIEW_3D_MODEL::doIncrementOffset( wxSpinEvent& event, double aSign )
{
wxSpinButton* spinCtrl = dynamic_cast<wxSpinButton*>( event.GetEventObject() );
wxCHECK( spinCtrl, /* void */ );
wxSpinButton* spinCtrl = (wxSpinButton*) event.GetEventObject();
wxTextCtrl * textCtrl = xoff;
@@ -502,7 +511,7 @@ void PANEL_PREVIEW_3D_MODEL::doIncrementOffset( wxSpinEvent& event, double aSign
if( wxGetMouseState().ShiftDown( ) )
step_mm = OFFSET_INCREMENT_MM_FINE;
if( m_userUnits == EDA_UNITS::MILS || m_userUnits == EDA_UNITS::INCH )
if( m_userUnits == EDA_UNITS::MILS || m_userUnits == EDA_UNITS::INCHES )
{
step_mm = 25.4*OFFSET_INCREMENT_MIL/1000;
@@ -524,9 +533,7 @@ void PANEL_PREVIEW_3D_MODEL::doIncrementOffset( wxSpinEvent& event, double aSign
void PANEL_PREVIEW_3D_MODEL::onMouseWheelScale( wxMouseEvent& event )
{
wxTextCtrl* textCtrl = dynamic_cast<wxTextCtrl*>( event.GetEventObject() );
wxCHECK( textCtrl, /* void */ );
wxTextCtrl* textCtrl = (wxTextCtrl*) event.GetEventObject();
double step = SCALE_INCREMENT;
@@ -549,9 +556,7 @@ void PANEL_PREVIEW_3D_MODEL::onMouseWheelScale( wxMouseEvent& event )
void PANEL_PREVIEW_3D_MODEL::onMouseWheelRot( wxMouseEvent& event )
{
wxTextCtrl* textCtrl = dynamic_cast<wxTextCtrl*>( event.GetEventObject() );
wxCHECK( textCtrl, /* void */ );
wxTextCtrl* textCtrl = (wxTextCtrl*) event.GetEventObject();
double step = ROTATION_INCREMENT;
@@ -574,16 +579,14 @@ void PANEL_PREVIEW_3D_MODEL::onMouseWheelRot( wxMouseEvent& event )
void PANEL_PREVIEW_3D_MODEL::onMouseWheelOffset( wxMouseEvent& event )
{
wxTextCtrl* textCtrl = dynamic_cast<wxTextCtrl*>( event.GetEventObject() );
wxCHECK( textCtrl, /* void */ );
wxTextCtrl* textCtrl = (wxTextCtrl*) event.GetEventObject();
double step_mm = OFFSET_INCREMENT_MM;
if( event.ShiftDown( ) )
step_mm = OFFSET_INCREMENT_MM_FINE;
if( m_userUnits == EDA_UNITS::MILS || m_userUnits == EDA_UNITS::INCH )
if( m_userUnits == EDA_UNITS::MILS || m_userUnits == EDA_UNITS::INCHES )
{
step_mm = 25.4*OFFSET_INCREMENT_MIL/1000.0;
+3 -3
View File
@@ -222,11 +222,11 @@ private:
int m_selected; /// Index into m_parentInfoList
EDA_UNITS m_userUnits;
bool m_bodyStyleShowAll; /// true if the board body is show
/// The 3d viewer Render initial settings (must be saved and restored)
EDA_3D_VIEWER_SETTINGS::RENDER_SETTINGS m_initialRender;
EDA_3D_VIEWER_SETTINGS::RENDER_SETTINGS m_initialRender;
std::unique_ptr<NL_FOOTPRINT_PROPERTIES_PLUGIN> m_spaceMouse;
std::unique_ptr<NL_FOOTPRINT_PROPERTIES_PLUGIN> m_spaceMouse;
};
#endif // PANEL_PREVIEW_3D_MODEL_H
+1 -1
View File
@@ -621,7 +621,7 @@
欠陥電気
木 王
郝弘毅
Eli Hughes
See git repo on GitLab for contributors at
https://gitlab.com/kicad/code/kicad/-/graphs/master
-24
View File
@@ -58,30 +58,6 @@ message GraphicsDefaultsResponse
kiapi.board.GraphicsDefaults defaults = 1;
}
enum BoardOriginType
{
BOT_UNKNOWN = 0;
BOT_GRID = 1;
BOT_DRILL = 2;
}
// Returns a Vector2 with the specified origin point
message GetBoardOrigin
{
kiapi.common.types.DocumentSpecifier board = 1;
BoardOriginType type = 2;
}
message SetBoardOrigin
{
kiapi.common.types.DocumentSpecifier board = 1;
BoardOriginType type = 2;
kiapi.common.types.Vector2 origin = 3;
}
/*
* Net management
*/
-39
View File
@@ -89,42 +89,6 @@ enum BoardLayer
BL_User_8 = 60;
BL_User_9 = 61;
BL_Rescue = 62;
BL_User_10 = 63;
BL_User_11 = 64;
BL_User_12 = 65;
BL_User_13 = 66;
BL_User_14 = 67;
BL_User_15 = 68;
BL_User_16 = 69;
BL_User_17 = 70;
BL_User_18 = 71;
BL_User_19 = 72;
BL_User_20 = 73;
BL_User_21 = 74;
BL_User_22 = 75;
BL_User_23 = 76;
BL_User_24 = 77;
BL_User_25 = 78;
BL_User_26 = 79;
BL_User_27 = 80;
BL_User_28 = 81;
BL_User_29 = 82;
BL_User_30 = 83;
BL_User_31 = 84;
BL_User_32 = 85;
BL_User_33 = 86;
BL_User_34 = 87;
BL_User_35 = 88;
BL_User_36 = 89;
BL_User_37 = 90;
BL_User_38 = 91;
BL_User_39 = 92;
BL_User_40 = 93;
BL_User_41 = 94;
BL_User_42 = 95;
BL_User_43 = 96;
BL_User_44 = 97;
BL_User_45 = 98;
}
message NetCode
@@ -804,9 +768,6 @@ message Field
FieldId id = 1;
string name = 2;
BoardText text = 3;
// Since 9.0.1
bool visible = 4;
}
enum FootprintMountingStyle
+2 -5
View File
@@ -291,10 +291,7 @@ message TextAttributes
bool italic = 7;
bool bold = 8;
bool underlined = 9;
// Deprecated since 9.0.1 (text items are now always visible, only Fields can be hidden)
bool visible = 10;
bool mirrored = 11;
bool multiline = 12;
bool keep_upright = 13;
@@ -308,7 +305,7 @@ message Text
kiapi.common.types.Vector2 position = 2;
kiapi.common.types.TextAttributes attributes = 3;
// Reserved for future use; base objects don't support locking right now
// Reserved for future use; base objects don't support locking right nos
//kiapi.common.types.LockedState locked = 4;
string text = 5;
@@ -321,7 +318,7 @@ message TextBox
kiapi.common.types.Vector2 bottom_right = 3;
kiapi.common.types.TextAttributes attributes = 4;
// Reserved for future use; base objects don't support locking right now
// Reserved for future use; base objects don't support locking right nos
//kiapi.common.types.LockedState locked = 5;
string text = 6;
+9 -9
View File
@@ -51,7 +51,7 @@ IMAGE_SIZE::IMAGE_SIZE()
m_outputSize = 0.0;
m_originalDPI = DEFAULT_DPI;
m_originalSizePixels = 0;
m_unit = EDA_UNITS::MM;
m_unit = EDA_UNITS::MILLIMETRES;
}
@@ -61,9 +61,9 @@ void IMAGE_SIZE::SetOutputSizeFromInitialImageSize()
m_originalDPI = std::max( 1, m_originalDPI );
// Set the m_outputSize value from the m_originalSizePixels and the selected unit
if( m_unit == EDA_UNITS::MM )
if( m_unit == EDA_UNITS::MILLIMETRES )
m_outputSize = (double)GetOriginalSizePixels() / m_originalDPI * 25.4;
else if( m_unit == EDA_UNITS::INCH )
else if( m_unit == EDA_UNITS::INCHES )
m_outputSize = (double)GetOriginalSizePixels() / m_originalDPI;
else
m_outputSize = m_originalDPI;
@@ -74,9 +74,9 @@ int IMAGE_SIZE::GetOutputDPI()
{
int outputDPI;
if( m_unit == EDA_UNITS::MM )
if( m_unit == EDA_UNITS::MILLIMETRES )
outputDPI = GetOriginalSizePixels() / ( m_outputSize / 25.4 );
else if( m_unit == EDA_UNITS::INCH )
else if( m_unit == EDA_UNITS::INCHES )
outputDPI = GetOriginalSizePixels() / m_outputSize;
else
outputDPI = KiROUND( m_outputSize );
@@ -98,11 +98,11 @@ void IMAGE_SIZE::SetUnit( EDA_UNITS aUnit )
// Convert m_outputSize to mm:
double size_mm;
if( m_unit == EDA_UNITS::MM )
if( m_unit == EDA_UNITS::MILLIMETRES )
{
size_mm = m_outputSize;
}
else if( m_unit == EDA_UNITS::INCH )
else if( m_unit == EDA_UNITS::INCHES )
{
size_mm = m_outputSize * 25.4;
}
@@ -117,11 +117,11 @@ void IMAGE_SIZE::SetUnit( EDA_UNITS aUnit )
}
// Convert m_outputSize to new value:
if( aUnit == EDA_UNITS::MM )
if( aUnit == EDA_UNITS::MILLIMETRES )
{
m_outputSize = size_mm;
}
else if( aUnit == EDA_UNITS::INCH )
else if( aUnit == EDA_UNITS::INCHES )
{
m_outputSize = size_mm / 25.4;
}
+4 -4
View File
@@ -266,9 +266,9 @@ wxString BITMAP2CMP_PANEL::formatOutputSize( double aSize )
{
wxString text;
if( getUnitFromSelection() == EDA_UNITS::MM )
if( getUnitFromSelection() == EDA_UNITS::MILLIMETRES )
text.Printf( wxS( "%.1f" ), aSize );
else if( getUnitFromSelection() == EDA_UNITS::INCH )
else if( getUnitFromSelection() == EDA_UNITS::INCHES )
text.Printf( wxS( "%.2f" ), aSize );
else
text.Printf( wxT( "%d" ), KiROUND( aSize ) );
@@ -295,10 +295,10 @@ EDA_UNITS BITMAP2CMP_PANEL::getUnitFromSelection()
// return the EDA_UNITS from the m_PixelUnit choice
switch( m_PixelUnit->GetSelection() )
{
case 1: return EDA_UNITS::INCH;
case 1: return EDA_UNITS::INCHES;
case 2: return EDA_UNITS::UNSCALED;
case 0:
default: return EDA_UNITS::MM;
default: return EDA_UNITS::MILLIMETRES;
}
}
+1 -1
View File
@@ -37,7 +37,7 @@ unset(_Python_NAMES)
set(_PYTHON1_VERSIONS 1.6 1.5)
set(_PYTHON2_VERSIONS 2.7 2.6 2.5 2.4 2.3 2.2 2.1 2.0)
set(_PYTHON3_VERSIONS 3.14 3.13 3.12 3.11 3.10 3.9 3.8 3.7 3.6 3.5 3.4 3.3 3.2 3.1 3.0)
set(_PYTHON3_VERSIONS 3.13 3.12 3.11 3.10 3.9 3.8 3.7 3.6 3.5 3.4 3.3 3.2 3.1 3.0)
# Disabling the "search every possible place" code for now
# see https://gitlab.com/kicad/code/kicad/-/issues/8553
+1 -1
View File
@@ -44,7 +44,7 @@ cmake_find_frameworks(Python)
set(_PYTHON1_VERSIONS 1.6 1.5)
set(_PYTHON2_VERSIONS 2.7 2.6 2.5 2.4 2.3 2.2 2.1 2.0)
set(_PYTHON3_VERSIONS 3.14 3.13 3.12 3.11 3.10 3.9 3.8 3.7 3.6 3.5 3.4 3.3 3.2 3.1 3.0)
set(_PYTHON3_VERSIONS 3.13 3.12 3.11 3.10 3.9 3.8 3.7 3.6 3.5 3.4 3.3 3.2 3.1 3.0)
if(PythonLibs_FIND_VERSION)
if(PythonLibs_FIND_VERSION MATCHES "^[0-9]+\\.[0-9]+(\\.[0-9]+.*)?$")
+1 -1
View File
@@ -37,7 +37,7 @@
# KiCad.
#
# Note: This version string should follow the semantic versioning system
set( KICAD_SEMANTIC_VERSION "9.0.2" )
set( KICAD_SEMANTIC_VERSION "9.99.0-unknown" )
# Default the version to the semantic version.
# This is overridden by the git repository tag though (if using git)
+1 -2
View File
@@ -72,7 +72,6 @@ set( KICOMMON_SRCS
jobs/job_export_pcb_gerber.cpp
jobs/job_export_pcb_gerbers.cpp
jobs/job_export_pcb_ipc2581.cpp
jobs/job_export_pcb_ipcd356.cpp
jobs/job_export_pcb_odb.cpp
jobs/job_export_pcb_pdf.cpp
jobs/job_export_pcb_plot.cpp
@@ -432,7 +431,6 @@ set( COMMON_WIDGET_SRCS
widgets/gal_options_panel_base.cpp
widgets/grid_bitmap_toggle.cpp
widgets/grid_button.cpp
widgets/grid_checkbox.cpp
widgets/grid_color_swatch_helpers.cpp
widgets/grid_combobox.cpp
widgets/grid_icon_text_helpers.cpp
@@ -812,6 +810,7 @@ set( PCB_COMMON_SRCS
${CMAKE_SOURCE_DIR}/pcbnew/netlist_reader/kicad_netlist_reader.cpp
${CMAKE_SOURCE_DIR}/pcbnew/netlist_reader/legacy_netlist_reader.cpp
${CMAKE_SOURCE_DIR}/pcbnew/netlist_reader/netlist_reader.cpp
${CMAKE_SOURCE_DIR}/pcbnew/pad_custom_shape_functions.cpp
${CMAKE_SOURCE_DIR}/pcbnew/pcb_draw_panel_gal.cpp
${CMAKE_SOURCE_DIR}/pcbnew/netlist_reader/pcb_netlist.cpp
${CMAKE_SOURCE_DIR}/pcbnew/pcb_origin_transforms.cpp
+5 -14
View File
@@ -100,6 +100,7 @@ static const wxChar V3DRT_BevelHeight_um[] = wxT( "V3DRT_BevelHeight_um" );
static const wxChar V3DRT_BevelExtentFactor[] = wxT( "V3DRT_BevelExtentFactor" );
static const wxChar EnableDesignBlocks[] = wxT( "EnableDesignBlocks" );
static const wxChar EnableGenerators[] = wxT( "EnableGenerators" );
static const wxChar EnableGit[] = wxT( "EnableGit" );
static const wxChar EnableLibWithText[] = wxT( "EnableLibWithText" );
static const wxChar EnableLibDir[] = wxT( "EnableLibDir" );
static const wxChar EnableEeschemaPrintCairo[] = wxT( "EnableEeschemaPrintCairo" );
@@ -126,8 +127,6 @@ static const wxChar MsgPanelShowUuids[] = wxT( "MsgPanelShowUuids" );
static const wxChar MaximumThreads[] = wxT( "MaximumThreads" );
static const wxChar NetInspectorBulkUpdateOptimisationThreshold[] =
wxT( "NetInspectorBulkUpdateOptimisationThreshold" );
static const wxChar ExcludeFromSimulationLineWidth[] = wxT( "ExcludeFromSimulationLineWidth" );
static const wxChar GitIconRefreshInterval[] = wxT( "GitIconRefreshInterval" );
} // namespace KEYS
@@ -258,6 +257,7 @@ ADVANCED_CFG::ADVANCED_CFG()
m_ShowRepairSchematic = false;
m_EnableDesignBlocks = true;
m_EnableGenerators = false;
m_EnableGit = true;
m_EnableLibWithText = false;
m_EnableLibDir = false;
@@ -307,10 +307,6 @@ ADVANCED_CFG::ADVANCED_CFG()
m_NetInspectorBulkUpdateOptimisationThreshold = 25;
m_ExcludeFromSimulationLineWidth = 25;
m_GitIconRefreshInterval = 10000;
loadFromConfigFile();
}
@@ -500,6 +496,9 @@ void ADVANCED_CFG::loadSettings( wxConfigBase& aCfg )
configParams.push_back( new PARAM_CFG_BOOL( true, AC_KEYS::EnableAPILogging,
&m_EnableAPILogging, m_EnableAPILogging ) );
configParams.push_back( new PARAM_CFG_BOOL( true, AC_KEYS::EnableGit,
&m_EnableGit, m_EnableGit ) );
configParams.push_back( new PARAM_CFG_BOOL( true, AC_KEYS::EnableLibWithText,
&m_EnableLibWithText, m_EnableLibWithText ) );
@@ -593,14 +592,6 @@ void ADVANCED_CFG::loadSettings( wxConfigBase& aCfg )
&m_NetInspectorBulkUpdateOptimisationThreshold,
m_NetInspectorBulkUpdateOptimisationThreshold, 0, 1000 ) );
configParams.push_back( new PARAM_CFG_INT( true, AC_KEYS::ExcludeFromSimulationLineWidth,
&m_ExcludeFromSimulationLineWidth,
m_ExcludeFromSimulationLineWidth, 1, 100 ) );
configParams.push_back( new PARAM_CFG_INT( true, AC_KEYS::GitIconRefreshInterval,
&m_GitIconRefreshInterval,
m_GitIconRefreshInterval, 0, 100000 ) );
// Special case for trace mask setting...we just grab them and set them immediately
// Because we even use wxLogTrace inside of advanced config
wxString traceMasks;
-72
View File
@@ -214,42 +214,6 @@ PCB_LAYER_ID FromProtoEnum( board::types::BoardLayer aValue )
case board::types::BoardLayer::BL_User_8: return User_8;
case board::types::BoardLayer::BL_User_9: return User_9;
case board::types::BoardLayer::BL_Rescue: return Rescue;
case board::types::BoardLayer::BL_User_10: return User_10;
case board::types::BoardLayer::BL_User_11: return User_11;
case board::types::BoardLayer::BL_User_12: return User_12;
case board::types::BoardLayer::BL_User_13: return User_13;
case board::types::BoardLayer::BL_User_14: return User_14;
case board::types::BoardLayer::BL_User_15: return User_15;
case board::types::BoardLayer::BL_User_16: return User_16;
case board::types::BoardLayer::BL_User_17: return User_17;
case board::types::BoardLayer::BL_User_18: return User_18;
case board::types::BoardLayer::BL_User_19: return User_19;
case board::types::BoardLayer::BL_User_20: return User_20;
case board::types::BoardLayer::BL_User_21: return User_21;
case board::types::BoardLayer::BL_User_22: return User_22;
case board::types::BoardLayer::BL_User_23: return User_23;
case board::types::BoardLayer::BL_User_24: return User_24;
case board::types::BoardLayer::BL_User_25: return User_25;
case board::types::BoardLayer::BL_User_26: return User_26;
case board::types::BoardLayer::BL_User_27: return User_27;
case board::types::BoardLayer::BL_User_28: return User_28;
case board::types::BoardLayer::BL_User_29: return User_29;
case board::types::BoardLayer::BL_User_30: return User_30;
case board::types::BoardLayer::BL_User_31: return User_31;
case board::types::BoardLayer::BL_User_32: return User_32;
case board::types::BoardLayer::BL_User_33: return User_33;
case board::types::BoardLayer::BL_User_34: return User_34;
case board::types::BoardLayer::BL_User_35: return User_35;
case board::types::BoardLayer::BL_User_36: return User_36;
case board::types::BoardLayer::BL_User_37: return User_37;
case board::types::BoardLayer::BL_User_38: return User_38;
case board::types::BoardLayer::BL_User_39: return User_39;
case board::types::BoardLayer::BL_User_40: return User_40;
case board::types::BoardLayer::BL_User_41: return User_41;
case board::types::BoardLayer::BL_User_42: return User_42;
case board::types::BoardLayer::BL_User_43: return User_43;
case board::types::BoardLayer::BL_User_44: return User_44;
case board::types::BoardLayer::BL_User_45: return User_45;
case board::types::BoardLayer::BL_UNKNOWN: return UNDEFINED_LAYER;
default:
@@ -326,42 +290,6 @@ board::types::BoardLayer ToProtoEnum( PCB_LAYER_ID aValue )
case User_8: return board::types::BoardLayer::BL_User_8;
case User_9: return board::types::BoardLayer::BL_User_9;
case Rescue: return board::types::BoardLayer::BL_Rescue;
case User_10: return board::types::BoardLayer::BL_User_10;
case User_11: return board::types::BoardLayer::BL_User_11;
case User_12: return board::types::BoardLayer::BL_User_12;
case User_13: return board::types::BoardLayer::BL_User_13;
case User_14: return board::types::BoardLayer::BL_User_14;
case User_15: return board::types::BoardLayer::BL_User_15;
case User_16: return board::types::BoardLayer::BL_User_16;
case User_17: return board::types::BoardLayer::BL_User_17;
case User_18: return board::types::BoardLayer::BL_User_18;
case User_19: return board::types::BoardLayer::BL_User_19;
case User_20: return board::types::BoardLayer::BL_User_20;
case User_21: return board::types::BoardLayer::BL_User_21;
case User_22: return board::types::BoardLayer::BL_User_22;
case User_23: return board::types::BoardLayer::BL_User_23;
case User_24: return board::types::BoardLayer::BL_User_24;
case User_25: return board::types::BoardLayer::BL_User_25;
case User_26: return board::types::BoardLayer::BL_User_26;
case User_27: return board::types::BoardLayer::BL_User_27;
case User_28: return board::types::BoardLayer::BL_User_28;
case User_29: return board::types::BoardLayer::BL_User_29;
case User_30: return board::types::BoardLayer::BL_User_30;
case User_31: return board::types::BoardLayer::BL_User_31;
case User_32: return board::types::BoardLayer::BL_User_32;
case User_33: return board::types::BoardLayer::BL_User_33;
case User_34: return board::types::BoardLayer::BL_User_34;
case User_35: return board::types::BoardLayer::BL_User_35;
case User_36: return board::types::BoardLayer::BL_User_36;
case User_37: return board::types::BoardLayer::BL_User_37;
case User_38: return board::types::BoardLayer::BL_User_38;
case User_39: return board::types::BoardLayer::BL_User_39;
case User_40: return board::types::BoardLayer::BL_User_40;
case User_41: return board::types::BoardLayer::BL_User_41;
case User_42: return board::types::BoardLayer::BL_User_42;
case User_43: return board::types::BoardLayer::BL_User_43;
case User_44: return board::types::BoardLayer::BL_User_44;
case User_45: return board::types::BoardLayer::BL_User_45;
default:
wxCHECK_MSG( false, board::types::BoardLayer::BL_UNKNOWN,
"Unhandled case in ToProtoEnum<PCB_LAYER_ID>");
+1 -1
View File
@@ -19,7 +19,7 @@
*/
#include <magic_enum.hpp>
#include <json_common.h>
#include <nlohmann/json.hpp>
#include <wx/log.h>
#include <wx/regex.h>
#include <wx/stdstream.h>
+1 -1
View File
@@ -208,7 +208,7 @@ bool BITMAP_BASE::SaveImageData( wxOutputStream& aOutStream ) const
else
{
// Write the contents of m_imageData to the stream.
aOutStream.Write( m_imageData.GetData(), m_imageData.GetDataLen() );
aOutStream.Write( m_imageData.GetData(), m_imageData.GetBufSize() );
}
return true;
+3 -5
View File
@@ -118,12 +118,11 @@ wxString ExpandTextVars( const wxString& aSource,
}
wxString GetGeneratedFieldDisplayName( const wxString& aSource )
wxString GetTextVars( const wxString& aSource )
{
std::function<bool( wxString* )> tokenExtractor =
[&]( wxString* token ) -> bool
{
*token = *token; // token value is the token name
return true;
};
@@ -131,10 +130,9 @@ wxString GetGeneratedFieldDisplayName( const wxString& aSource )
}
bool IsGeneratedField( const wxString& aSource )
bool IsTextVar( const wxString& aSource )
{
static wxRegEx expr( wxS( "^\\$\\{\\w*\\}$" ) );
return expr.Matches( aSource );
return aSource.StartsWith( wxS( "${" ) );
}
+1 -1
View File
@@ -23,7 +23,7 @@
*/
#include <kicommon.h>
#include <lib_id.h>
#include <json_common.h>
#include <nlohmann/json.hpp>
class KICOMMON_API DESIGN_BLOCK
-2
View File
@@ -72,9 +72,7 @@ std::vector<SEARCH_TERM> DESIGN_BLOCK_INFO::GetSearchTerms()
{
std::vector<SEARCH_TERM> terms;
terms.emplace_back( SEARCH_TERM( GetLibNickname(), 4 ) );
terms.emplace_back( SEARCH_TERM( GetName(), 8 ) );
terms.emplace_back( SEARCH_TERM( GetLIB_ID().Format(), 16 ) );
wxStringTokenizer keywordTokenizer( GetKeywords(), wxS( " " ), wxTOKEN_STRTOK );
+1 -3
View File
@@ -74,10 +74,8 @@ DESIGN_BLOCK_IO_MGR::DESIGN_BLOCK_FILE_T
DESIGN_BLOCK_IO_MGR::GuessPluginTypeFromLibPath( const wxString& aLibPath, int aCtl )
{
if( IO_RELEASER<DESIGN_BLOCK_IO>( FindPlugin( KICAD_SEXP ) )->CanReadLibrary( aLibPath )
&& aCtl != KICTL_NONKICAD_ONLY )
{
&& aCtl != KICTL_NONKICAD_ONLY )
return KICAD_SEXP;
}
return DESIGN_BLOCK_IO_MGR::FILE_TYPE_NONE;
}
+19 -27
View File
@@ -205,8 +205,7 @@ void DESIGN_BLOCK_LIB_TABLE::Parse( LIB_TABLE_LEXER* in )
row->SetVisible();
break;
default:
in->Unexpected( tok );
default: in->Unexpected( tok );
}
in->NeedRIGHT();
@@ -254,9 +253,7 @@ bool DESIGN_BLOCK_LIB_TABLE::operator==( const DESIGN_BLOCK_LIB_TABLE& aDesignBl
{
if( (DESIGN_BLOCK_LIB_TABLE_ROW&) m_rows[i]
!= (DESIGN_BLOCK_LIB_TABLE_ROW&) aDesignBlockTable.m_rows[i] )
{
return false;
}
}
return true;
@@ -271,8 +268,8 @@ void DESIGN_BLOCK_LIB_TABLE::Format( OUTPUTFORMATTER* aOutput, int aIndentLevel
aOutput->Print( aIndentLevel, "(design_block_lib_table\n" );
aOutput->Print( aIndentLevel + 1, "(version %d)\n", m_version );
for( const LIB_TABLE_ROW& row : m_rows)
row.Format( aOutput, aIndentLevel + 1 );
for( LIB_TABLE_ROWS_CITER it = m_rows.begin(); it != m_rows.end(); ++it )
it->Format( aOutput, aIndentLevel + 1 );
aOutput->Print( aIndentLevel, ")\n" );
}
@@ -333,9 +330,9 @@ const DESIGN_BLOCK_LIB_TABLE_ROW* DESIGN_BLOCK_LIB_TABLE::FindRow( const wxStrin
if( !row )
{
THROW_IO_ERROR( wxString::Format( _( "design-block-lib-table files contain no library "
"named '%s'." ),
aNickname ) );
wxString msg = wxString::Format(
_( "design-block-lib-table files contain no library named '%s'." ), aNickname );
THROW_IO_ERROR( msg );
}
if( !row->plugin )
@@ -493,12 +490,14 @@ DESIGN_BLOCK_LIB_TABLE::DesignBlockLoadWithOptionalNickname( const LIB_ID& aDesi
// nickname is empty, sequentially search (alphabetically) all libs/nicks for first match:
else
{
std::vector<wxString> nicks = GetLogicalLibs();
// Search each library going through libraries alphabetically.
for( const wxString& library : GetLogicalLibs() )
for( unsigned i = 0; i < nicks.size(); ++i )
{
// DesignBlockLoad() returns NULL on not found, does not throw exception
// unless there's an IO_ERROR.
DESIGN_BLOCK* ret = DesignBlockLoad( library, DesignBlockname, aKeepUUID );
DESIGN_BLOCK* ret = DesignBlockLoad( nicks[i], DesignBlockname, aKeepUUID );
if( ret )
return ret;
@@ -521,8 +520,7 @@ public:
explicit PCM_DESIGN_BLOCK_LIB_TRAVERSER( const wxString& aPath, DESIGN_BLOCK_LIB_TABLE& aTable,
const wxString& aPrefix ) :
m_lib_table( aTable ),
m_path_prefix( aPath ),
m_lib_prefix( aPrefix )
m_path_prefix( aPath ), m_lib_prefix( aPrefix )
{
wxFileName f( aPath, wxS( "" ) );
m_prefix_dir_count = f.GetDirCount();
@@ -541,9 +539,8 @@ public:
FILEEXT::KiCadDesignBlockLibPathExtension ) )
&& dir.GetDirCount() >= m_prefix_dir_count + 3 )
{
wxString versionedPath;
versionedPath.Printf( wxS( "${%s}" ),
ENV_VAR::GetVersionedEnvVarName( wxS( "3RD_PARTY" ) ) );
wxString versionedPath = wxString::Format(
wxS( "${%s}" ), ENV_VAR::GetVersionedEnvVarName( wxS( "3RD_PARTY" ) ) );
wxArrayString parts = dir.GetDirs();
parts.RemoveAt( 0, m_prefix_dir_count );
@@ -554,21 +551,16 @@ public:
if( !m_lib_table.HasLibraryWithPath( libPath ) )
{
wxString name = parts.Last().substr( 0, parts.Last().length() - 7 );
wxString nickname;
nickname.Printf( wxS( "%s%s" ),
m_lib_prefix,
name );
wxString nickname = wxString::Format( wxS( "%s%s" ), m_lib_prefix, name );
if( m_lib_table.HasLibrary( nickname ) )
{
int increment = 1;
do
{
nickname.Printf( wxS( "%s%s_%d" ),
m_lib_prefix,
name,
increment++ );
nickname =
wxString::Format( wxS( "%s%s_%d" ), m_lib_prefix, name, increment );
increment++;
} while( m_lib_table.HasLibrary( nickname ) );
}
@@ -611,8 +603,8 @@ bool DESIGN_BLOCK_LIB_TABLE::LoadGlobalTable( DESIGN_BLOCK_LIB_TABLE& aTable )
SystemDirsAppend( &ss );
const ENV_VAR_MAP& envVars = Pgm().GetLocalEnvVariables();
std::optional<wxString> v = ENV_VAR::GetVersionedEnvVarValue( envVars,
wxT( "TEMPLATE_DIR" ) );
std::optional<wxString> v =
ENV_VAR::GetVersionedEnvVarValue( envVars, wxT( "TEMPLATE_DIR" ) );
if( v && !v->IsEmpty() )
ss.AddPaths( *v, 0 );
-1
View File
@@ -622,7 +622,6 @@ static void buildKicadAboutBanner( EDA_BASE_FRAME* aParent, ABOUT_APP_INFO& aInf
ADD_DEV( wxT( "Nick Østergaard" ), CONTRIB_DEV );
ADD_DEV( wxT( "木 王" ), CONTRIB_DEV );
ADD_DEV( wxT( "wh201906" ), CONTRIB_DEV );
// The document writers
#define DOC_TEAM _( "Documentation Team" )
+61 -50
View File
@@ -42,6 +42,43 @@
#include <algorithm>
/// Toggle a window's "enable" status to disabled, then enabled on destruction.
class WDO_ENABLE_DISABLE
{
wxWindow* m_win;
public:
WDO_ENABLE_DISABLE( wxWindow* aWindow ) :
m_win( aWindow )
{
if( m_win )
m_win->Disable();
}
~WDO_ENABLE_DISABLE()
{
if( m_win )
{
m_win->Enable();
m_win->Raise(); // let's focus back on the parent window
}
}
void SuspendForTrueModal()
{
if( m_win )
m_win->Enable();
}
void ResumeAfterTrueModal()
{
if( m_win )
m_win->Disable();
}
};
BEGIN_EVENT_TABLE( DIALOG_SHIM, wxDialog )
EVT_CHAR_HOOK( DIALOG_SHIM::OnCharHook )
END_EVENT_TABLE()
@@ -50,17 +87,17 @@ END_EVENT_TABLE()
DIALOG_SHIM::DIALOG_SHIM( wxWindow* aParent, wxWindowID id, const wxString& title,
const wxPoint& pos, const wxSize& size, long style,
const wxString& name ) :
wxDialog( aParent, id, title, pos, size, style, name ),
KIWAY_HOLDER( nullptr, KIWAY_HOLDER::DIALOG ),
m_units( EDA_UNITS::MM ),
m_useCalculatedSize( false ),
m_firstPaintEvent( true ),
m_initialFocusTarget( nullptr ),
m_isClosing( false ),
m_qmodal_loop( nullptr ),
m_qmodal_showing( false ),
m_qmodal_parent_disabler( nullptr ),
m_parentFrame( nullptr )
wxDialog( aParent, id, title, pos, size, style, name ),
KIWAY_HOLDER( nullptr, KIWAY_HOLDER::DIALOG ),
m_units( EDA_UNITS::MILLIMETRES ),
m_useCalculatedSize( false ),
m_firstPaintEvent( true ),
m_initialFocusTarget( nullptr ),
m_isClosing( false ),
m_qmodal_loop( nullptr ),
m_qmodal_showing( false ),
m_qmodal_parent_disabler( nullptr ),
m_parentFrame( nullptr )
{
KIWAY_HOLDER* kiwayHolder = nullptr;
m_initialSize = size;
@@ -484,7 +521,15 @@ int DIALOG_SHIM::ShowModal()
int DIALOG_SHIM::ShowQuasiModal()
{
NULLER raii_nuller( (void*&) m_qmodal_loop );
// This is an exception safe way to zero a pointer before returning.
// Yes, even though DismissModal() clears this first normally, this is
// here in case there's an exception before the dialog is dismissed.
struct NULLER
{
void*& m_what;
NULLER( void*& aPtr ) : m_what( aPtr ) {}
~NULLER() { m_what = nullptr; } // indeed, set it to NULL on destruction
} clear_this( (void*&) m_qmodal_loop );
// release the mouse if it's currently captured as the window having it
// will be disabled when this dialog is shown -- but will still keep the
@@ -500,7 +545,7 @@ int DIALOG_SHIM::ShowQuasiModal()
"window?" ) );
// quasi-modal: disable only my "optimal" parent
m_qmodal_parent_disabler = new WINDOW_DISABLER( parent );
m_qmodal_parent_disabler = new WDO_ENABLE_DISABLE( parent );
// Apple in its infinite wisdom will raise a disabled window before even passing
// us the event, so we have no way to stop it. Instead, we must set an order on
@@ -653,43 +698,9 @@ void DIALOG_SHIM::OnCharHook( wxKeyEvent& aEvt )
return;
}
}
// shift-return (Mac default) or Ctrl-Return (GTK) for new line input
else if( ( aEvt.GetKeyCode() == WXK_RETURN || aEvt.GetKeyCode() == WXK_NUMPAD_ENTER ) && aEvt.ShiftDown() )
{
wxObject* eventSource = aEvt.GetEventObject();
if( wxTextCtrl* textCtrl = dynamic_cast<wxTextCtrl*>( eventSource ) )
{
#if defined( __WXMAC__ ) || defined( __WXMSW__ )
wxString eol = "\r\n";
#else
wxString eol = "\n";
#endif
long pos = textCtrl->GetInsertionPoint();
textCtrl->WriteText( eol );
textCtrl->SetInsertionPoint( pos + eol.length() );
return;
}
else if( wxStyledTextCtrl* scintilla = dynamic_cast<wxStyledTextCtrl*>( eventSource ) )
{
wxString eol = "\n";
switch( scintilla->GetEOLMode() )
{
case wxSTC_EOL_CRLF: eol = "\r\n"; break;
case wxSTC_EOL_CR: eol = "\r"; break;
case wxSTC_EOL_LF: eol = "\n"; break;
}
long pos = scintilla->GetCurrentPos();
scintilla->InsertText( pos, eol );
scintilla->GotoPos( pos + eol.length() );
return;
}
return;
}
// command-return (Mac default) or Ctrl-Return (GTK) for OK
else if( ( aEvt.GetKeyCode() == WXK_RETURN || aEvt.GetKeyCode() == WXK_NUMPAD_ENTER ) && aEvt.ControlDown() )
// shift-return (Mac default) or Ctrl-Return (GTK) for OK
else if( ( aEvt.GetKeyCode() == WXK_RETURN || aEvt.GetKeyCode() == WXK_NUMPAD_ENTER )
&& ( aEvt.ShiftDown() || aEvt.ControlDown() ) )
{
wxPostEvent( this, wxCommandEvent( wxEVT_COMMAND_BUTTON_CLICKED, wxID_OK ) );
return;
+6 -6
View File
@@ -77,14 +77,14 @@ bool DIALOG_GRID_SETTINGS::TransferDataFromWindow()
{
double gridX = m_gridSizeX.GetDoubleValue();
if( !m_gridSizeX.Validate( 0.001, 1000.0, EDA_UNITS::MM ) )
if( !m_gridSizeX.Validate( 0.001, 1000.0, EDA_UNITS::MILLIMETRES ) )
{
wxMessageBox( _( "Grid size X out of range." ), _( "Error" ), wxOK | wxICON_ERROR );
return false;
}
if( !m_checkLinked->IsChecked()
&& !m_gridSizeY.Validate( 0.001, 1000.0, EDA_UNITS::MM ) )
&& !m_gridSizeY.Validate( 0.001, 1000.0, EDA_UNITS::MILLIMETRES ) )
{
wxMessageBox( _( "Grid size Y out of range." ), _( "Error" ), wxOK | wxICON_ERROR );
return false;
@@ -94,10 +94,10 @@ bool DIALOG_GRID_SETTINGS::TransferDataFromWindow()
m_grid.name = m_textName->GetValue();
// Grid X/Y are always stored in millimeters so we can compare them easily
m_grid.x = EDA_UNIT_UTILS::UI::StringFromValue( m_unitsProvider->GetIuScale(), EDA_UNITS::MM,
gridX );
m_grid.y = EDA_UNIT_UTILS::UI::StringFromValue( m_unitsProvider->GetIuScale(), EDA_UNITS::MM,
gridY );
m_grid.x = EDA_UNIT_UTILS::UI::StringFromValue( m_unitsProvider->GetIuScale(),
EDA_UNITS::MILLIMETRES, gridX );
m_grid.y = EDA_UNIT_UTILS::UI::StringFromValue( m_unitsProvider->GetIuScale(),
EDA_UNITS::MILLIMETRES, gridY );
return true;
}
+1 -11
View File
@@ -21,13 +21,11 @@
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
*/
#include "kicad_manager_frame.h"
#include <dialogs/dialog_hotkey_list.h>
#include <kiface_base.h>
#include <eda_base_frame.h>
#include <panel_hotkeys_editor.h>
#include <widgets/ui_common.h>
#include <tool/tool_manager.h>
#include <wx/sizer.h>
#include <wx/button.h>
@@ -41,15 +39,7 @@ DIALOG_LIST_HOTKEYS::DIALOG_LIST_HOTKEYS( EDA_BASE_FRAME* aParent ):
m_hk_list = new PANEL_HOTKEYS_EDITOR( aParent, this, true );
wxWindow* kicadMgr_window = wxWindow::FindWindowByName( KICAD_MANAGER_FRAME_NAME );
if( KICAD_MANAGER_FRAME* kicadMgr = static_cast<KICAD_MANAGER_FRAME*>( kicadMgr_window ) )
{
ACTION_MANAGER* actionMgr = kicadMgr->GetToolManager()->GetActionManager();
for( const auto& [name, action] : actionMgr->GetActions() )
m_hk_list->ActionsList().push_back( action );
}
Kiway().GetActions( m_hk_list->ActionsList() );
kiface = Kiway().KiFACE( KIWAY::FACE_SCH );
kiface->GetActions( m_hk_list->ActionsList() );
@@ -27,7 +27,7 @@ DIALOG_LOCKED_ITEMS_QUERY_BASE::DIALOG_LOCKED_ITEMS_QUERY_BASE( wxWindow* parent
wxBoxSizer* bSizer4;
bSizer4 = new wxBoxSizer( wxVERTICAL );
m_messageLine1 = new wxStaticText( this, wxID_ANY, _("The selection contains %zu locked items."), wxDefaultPosition, wxDefaultSize, 0 );
m_messageLine1 = new wxStaticText( this, wxID_ANY, _("The selection contains %lu locked items."), wxDefaultPosition, wxDefaultSize, 0 );
m_messageLine1->Wrap( -1 );
bSizer4->Add( m_messageLine1, 0, wxALL, 5 );
@@ -182,7 +182,7 @@
<property name="gripper">0</property>
<property name="hidden">0</property>
<property name="id">wxID_ANY</property>
<property name="label">The selection contains %zu locked items.</property>
<property name="label">The selection contains %lu locked items.</property>
<property name="markup">0</property>
<property name="max_size"></property>
<property name="maximize_button">0</property>
+1 -1
View File
@@ -477,7 +477,7 @@ bool DIALOG_PAGES_SETTINGS::SavePageSettings()
if( fileName != BASE_SCREEN::m_DrawingSheetFileName )
{
wxString fullFileName = m_filenameResolver->ResolvePath( fileName, m_projectPath,
{ m_embeddedFiles } );
m_embeddedFiles );
BASE_SCREEN::m_DrawingSheetFileName = fileName;
+3 -10
View File
@@ -50,13 +50,11 @@ int WX_UNIT_ENTRY_DIALOG::GetValue()
WX_PT_ENTRY_DIALOG::WX_PT_ENTRY_DIALOG( EDA_DRAW_FRAME* aParent, const wxString& aCaption,
const wxString& aLabelX, const wxString& aLabelY,
const VECTOR2I& aDefaultValue, bool aShowResetButt ) :
const VECTOR2I& aDefaultValue ) :
WX_PT_ENTRY_DIALOG_BASE( ( wxWindow* ) aParent, wxID_ANY, aCaption ),
m_unit_binder_x( aParent, m_labelX, m_textCtrlX, m_unitsX, true ),
m_unit_binder_y( aParent, m_labelY, m_textCtrlY, m_unitsY, true )
{
m_ButtonReset->Show( aShowResetButt );
m_labelX->SetLabel( aLabelX );
m_labelY->SetLabel( aLabelY );
@@ -69,7 +67,8 @@ WX_PT_ENTRY_DIALOG::WX_PT_ENTRY_DIALOG( EDA_DRAW_FRAME* aParent, const wxString&
SetInitialFocus( m_textCtrlX );
SetupStandardButtons();
finishDialogSettings();
Layout();
bSizerMain->Fit( this );
}
@@ -77,9 +76,3 @@ VECTOR2I WX_PT_ENTRY_DIALOG::GetValue()
{
return VECTOR2I( m_unit_binder_x.GetIntValue(), m_unit_binder_y.GetIntValue() );
}
void WX_PT_ENTRY_DIALOG::ResetValues( wxCommandEvent& event )
{
m_unit_binder_x.SetValue( 0 );
m_unit_binder_y.SetValue( 0 );
}
+2 -11
View File
@@ -1,5 +1,5 @@
///////////////////////////////////////////////////////////////////////////
// C++ code generated with wxFormBuilder (version 4.2.1-0-g80c4cb6)
// C++ code generated with wxFormBuilder (version 3.10.1-0-g8feb16b)
// http://www.wxformbuilder.org/
//
// PLEASE DO *NOT* EDIT THIS FILE!
@@ -102,11 +102,8 @@ WX_PT_ENTRY_DIALOG_BASE::WX_PT_ENTRY_DIALOG_BASE( wxWindow* parent, wxWindowID i
wxBoxSizer* bSizerButtons;
bSizerButtons = new wxBoxSizer( wxHORIZONTAL );
m_ButtonReset = new wxButton( this, wxID_ANY, _("Reset"), wxDefaultPosition, wxDefaultSize, 0 );
bSizerButtons->Add( m_ButtonReset, 0, wxALL|wxRESERVE_SPACE_EVEN_IF_HIDDEN, 5 );
bSizerButtons->Add( 30, 0, 1, wxALIGN_CENTER_VERTICAL, 5 );
bSizerButtons->Add( 100, 0, 1, wxALIGN_CENTER_VERTICAL, 5 );
m_sdbSizer1 = new wxStdDialogButtonSizer();
m_sdbSizer1OK = new wxButton( this, wxID_OK );
@@ -126,14 +123,8 @@ WX_PT_ENTRY_DIALOG_BASE::WX_PT_ENTRY_DIALOG_BASE( wxWindow* parent, wxWindowID i
bSizerMain->Fit( this );
this->Centre( wxBOTH );
// Connect Events
m_ButtonReset->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( WX_PT_ENTRY_DIALOG_BASE::ResetValues ), NULL, this );
}
WX_PT_ENTRY_DIALOG_BASE::~WX_PT_ENTRY_DIALOG_BASE()
{
// Disconnect Events
m_ButtonReset->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( WX_PT_ENTRY_DIALOG_BASE::ResetValues ), NULL, this );
}
File diff suppressed because it is too large Load Diff
+2 -9
View File
@@ -1,5 +1,5 @@
///////////////////////////////////////////////////////////////////////////
// C++ code generated with wxFormBuilder (version 4.2.1-0-g80c4cb6)
// C++ code generated with wxFormBuilder (version 3.10.1-0-g8feb16b)
// http://www.wxformbuilder.org/
//
// PLEASE DO *NOT* EDIT THIS FILE!
@@ -21,12 +21,10 @@
#include <wx/sizer.h>
#include <wx/button.h>
#include <wx/dialog.h>
#include <wx/bitmap.h>
#include <wx/image.h>
#include <wx/icon.h>
///////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
/// Class WX_UNIT_ENTRY_DIALOG_BASE
///////////////////////////////////////////////////////////////////////////////
@@ -66,15 +64,10 @@ class WX_PT_ENTRY_DIALOG_BASE : public DIALOG_SHIM
wxStaticText* m_labelY;
wxTextCtrl* m_textCtrlY;
wxStaticText* m_unitsY;
wxButton* m_ButtonReset;
wxStdDialogButtonSizer* m_sdbSizer1;
wxButton* m_sdbSizer1OK;
wxButton* m_sdbSizer1Cancel;
// Virtual event handlers, override them in your derived class
virtual void ResetValues( wxCommandEvent& event ) { event.Skip(); }
public:
WX_PT_ENTRY_DIALOG_BASE( wxWindow* parent, wxWindowID id = wxID_ANY, const wxString& title = _("Move Point to Location"), const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxSize( -1,-1 ), long style = wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER );
+85 -57
View File
@@ -25,9 +25,6 @@
#include <confirm.h>
#include <git2.h>
#include <git/kicad_git_memory.h>
#include <git/kicad_git_common.h>
#include <git/git_repo_mixin.h>
#include <gestfich.h>
#include <cerrno>
@@ -45,6 +42,9 @@ DIALOG_GIT_REPOSITORY::DIALOG_GIT_REPOSITORY( wxWindow* aParent, git_repository*
DIALOG_GIT_REPOSITORY_BASE( aParent ),
m_repository( aRepository ),
m_prevFile( wxEmptyString ),
m_tested( 0 ),
m_failedTest( false ),
m_testError( wxEmptyString ),
m_tempRepo( false )
{
m_txtURL->SetFocus();
@@ -68,17 +68,12 @@ DIALOG_GIT_REPOSITORY::DIALOG_GIT_REPOSITORY( wxWindow* aParent, git_repository*
if( !m_txtURL->GetValue().IsEmpty() )
updateURLData();
else
m_ConnType->SetSelection( static_cast<int>( KIGIT_COMMON::GIT_CONN_TYPE::GIT_CONN_LOCAL ) );
SetupStandardButtons( { { wxID_HELP, _( "Test Connection" ) } } );
Layout();
finishDialogSettings();
SetupStandardButtons();
updateAuthControls();
}
Layout();
}
DIALOG_GIT_REPOSITORY::~DIALOG_GIT_REPOSITORY()
{
@@ -145,13 +140,6 @@ void DIALOG_GIT_REPOSITORY::setDefaultSSHKey()
}
void DIALOG_GIT_REPOSITORY::onCbCustom( wxCommandEvent& event )
{
updateAuthControls();
event.Skip();
}
void DIALOG_GIT_REPOSITORY::OnUpdateUI( wxUpdateUIEvent& event )
{
// event.Enable( !m_txtName->GetValue().IsEmpty() && !m_txtURL->GetValue().IsEmpty() );
@@ -173,7 +161,6 @@ void DIALOG_GIT_REPOSITORY::SetEncrypted( bool aEncrypted )
}
}
std::tuple<bool,wxString,wxString,wxString> DIALOG_GIT_REPOSITORY::isValidHTTPS( const wxString& url )
{
wxRegEx regex( R"((https?:\/\/)(([^:]+)(:([^@]+))?@)?([^\/]+\/[^\s]+))" );
@@ -241,7 +228,6 @@ void DIALOG_GIT_REPOSITORY::updateURLData()
if( valid )
{
m_fullURL = url;
m_ConnType->SetSelection( static_cast<int>( KIGIT_COMMON::GIT_CONN_TYPE::GIT_CONN_HTTPS ) );
SetUsername( username );
SetPassword( password );
@@ -249,6 +235,7 @@ void DIALOG_GIT_REPOSITORY::updateURLData()
if( m_txtName->GetValue().IsEmpty() )
m_txtName->SetValue( get_repo_name( repoAddress ) );
}
}
else if( url.Contains( "ssh://" ) || url.Contains( "git@" ) )
@@ -257,7 +244,6 @@ void DIALOG_GIT_REPOSITORY::updateURLData()
if( valid )
{
m_fullURL = url;
m_ConnType->SetSelection( static_cast<int>( KIGIT_COMMON::GIT_CONN_TYPE::GIT_CONN_SSH ) );
m_txtUsername->SetValue( username );
m_txtURL->SetValue( repoAddress );
@@ -273,11 +259,6 @@ void DIALOG_GIT_REPOSITORY::updateURLData()
void DIALOG_GIT_REPOSITORY::OnTestClick( wxCommandEvent& event )
{
if( m_txtURL->GetValue().Trim().Trim( false ).IsEmpty() )
return;
wxString error;
bool success = false;
git_remote* remote = nullptr;
git_remote_callbacks callbacks;
git_remote_init_callbacks( &callbacks, GIT_REMOTE_CALLBACKS_VERSION );
@@ -285,40 +266,81 @@ void DIALOG_GIT_REPOSITORY::OnTestClick( wxCommandEvent& event )
// We track if we have already tried to connect.
// If we have, the server may come back to offer another connection
// type, so we need to keep track of how many times we have tried.
m_tested = 0;
KIGIT_COMMON common( m_repository );
common.SetRemote( m_txtURL->GetValue() );
callbacks.credentials = credentials_cb;
common.SetPassword( m_txtPassword->GetValue() );
common.SetUsername( m_txtUsername->GetValue() );
common.SetSSHKey( m_fpSSHKey->GetFileName().GetFullPath() );
KIGIT_REPO_MIXIN repoMixin( &common );
callbacks.payload = &repoMixin;
callbacks.credentials = []( git_cred** aOut, const char* aUrl, const char* aUsername,
unsigned int aAllowedTypes, void* aPayload ) -> int
{
DIALOG_GIT_REPOSITORY* dialog = static_cast<DIALOG_GIT_REPOSITORY*>( aPayload );
if( dialog->GetRepoType() == KIGIT_COMMON::GIT_CONN_TYPE::GIT_CONN_LOCAL )
return GIT_PASSTHROUGH;
if( aAllowedTypes & GIT_CREDTYPE_USERNAME
&& !( dialog->GetTested() & GIT_CREDTYPE_USERNAME ) )
{
wxString username = dialog->GetUsername().Trim().Trim( false );
git_cred_username_new( aOut, username.ToStdString().c_str() );
dialog->GetTested() |= GIT_CREDTYPE_USERNAME;
}
else if( dialog->GetRepoType() == KIGIT_COMMON::GIT_CONN_TYPE::GIT_CONN_HTTPS
&& ( aAllowedTypes & GIT_CREDTYPE_USERPASS_PLAINTEXT )
&& !( dialog->GetTested() & GIT_CREDTYPE_USERPASS_PLAINTEXT ) )
{
wxString username = dialog->GetUsername().Trim().Trim( false );
wxString password = dialog->GetPassword().Trim().Trim( false );
git_cred_userpass_plaintext_new( aOut, username.ToStdString().c_str(),
password.ToStdString().c_str() );
dialog->GetTested() |= GIT_CREDTYPE_USERPASS_PLAINTEXT;
}
else if( dialog->GetRepoType() == KIGIT_COMMON::GIT_CONN_TYPE::GIT_CONN_SSH
&& ( aAllowedTypes & GIT_CREDTYPE_SSH_KEY )
&& !( dialog->GetTested() & GIT_CREDTYPE_SSH_KEY ) )
{
// SSH key authentication
wxString sshKey = dialog->GetRepoSSHPath();
wxString sshPubKey = sshKey + ".pub";
wxString username = dialog->GetUsername().Trim().Trim( false );
wxString password = dialog->GetPassword().Trim().Trim( false );
git_cred_ssh_key_new( aOut, username.ToStdString().c_str(),
sshPubKey.ToStdString().c_str(), sshKey.ToStdString().c_str(),
password.ToStdString().c_str() );
dialog->GetTested() |= GIT_CREDTYPE_SSH_KEY;
}
else
{
return GIT_PASSTHROUGH;
}
return GIT_OK;
};
callbacks.payload = this;
wxString txtURL = m_txtURL->GetValue();
git_remote_create_with_fetchspec( &remote, m_repository, "origin", txtURL.mbc_str(),
git_remote_create_with_fetchspec( &remote, m_repository, "origin", txtURL.ToStdString().c_str(),
"+refs/heads/*:refs/remotes/origin/*" );
KIGIT::GitRemotePtr remotePtr( remote );
if( git_remote_connect( remote, GIT_DIRECTION_FETCH, &callbacks, nullptr, nullptr ) == GIT_OK )
success = true;
if( git_remote_connect( remote, GIT_DIRECTION_FETCH, &callbacks, nullptr, nullptr ) != GIT_OK )
SetTestResult( true, git_error_last()->message );
else
error = KIGIT_COMMON::GetLastGitError();
SetTestResult( false, wxEmptyString );
git_remote_disconnect( remote );
git_remote_free( remote );
auto dlg = wxMessageDialog( this, wxEmptyString, _( "Test Connection" ),
wxOK | wxICON_INFORMATION );
auto dlg = wxMessageDialog( this, wxEmptyString, _( "Test connection" ), wxOK | wxICON_INFORMATION );
if( success )
if( !m_failedTest )
{
dlg.SetMessage( _( "Connection successful" ) );
}
else
{
dlg.SetMessage( wxString::Format( _( "Could not connect to '%s' " ),
m_txtURL->GetValue() ) );
dlg.SetExtendedMessage( error );
dlg.SetMessage( wxString::Format( _( "Could not connect to '%s' " ), m_txtURL->GetValue() ) );
dlg.SetExtendedMessage( m_testError );
}
dlg.ShowModal();
@@ -391,6 +413,13 @@ void DIALOG_GIT_REPOSITORY::OnOKClick( wxCommandEvent& event )
{
// Save the repository details
if( m_txtName->GetValue().IsEmpty() )
{
DisplayErrorMessage( this, _( "Missing information" ),
_( "Please enter a name for the repository" ) );
return;
}
if( m_txtURL->GetValue().IsEmpty() )
{
DisplayErrorMessage( this, _( "Missing information" ),
@@ -406,29 +435,28 @@ void DIALOG_GIT_REPOSITORY::updateAuthControls()
{
if( m_ConnType->GetSelection() == static_cast<int>( KIGIT_COMMON::GIT_CONN_TYPE::GIT_CONN_LOCAL ) )
{
m_panelAuth->Enable( false );
m_panelAuth->Show( false );
}
else
{
m_panelAuth->Enable( true );
m_panelAuth->Show( true );
if( m_ConnType->GetSelection() == static_cast<int>( KIGIT_COMMON::GIT_CONN_TYPE::GIT_CONN_SSH ) )
{
m_cbCustom->Enable( true );
m_fpSSHKey->Enable( m_cbCustom->IsChecked() );
m_txtUsername->Enable( m_cbCustom->IsChecked() );
m_txtPassword->Enable( m_cbCustom->IsChecked() );
m_labelPass1->SetLabel( _( "SSH key password:" ) );
m_fpSSHKey->Show( true );
m_labelSSH->Show( true );
m_labelPass1->SetLabel( _( "SSH Key Password" ) );
}
else
{
m_cbCustom->Enable( false );
m_fpSSHKey->Enable( false );
m_txtUsername->Enable( true );
m_txtPassword->Enable( true );
m_labelPass1->SetLabel( _( "Password:" ) );
m_fpSSHKey->Show( false );
m_labelSSH->Show( false );
m_labelPass1->SetLabel( _( "Password" ) );
setDefaultSSHKey();
}
}
Layout();
}
+12 -4
View File
@@ -36,6 +36,12 @@ public:
wxString aURL = wxEmptyString );
~DIALOG_GIT_REPOSITORY() override;
void SetTestResult( bool aFailed, const wxString& aError )
{
m_failedTest = aFailed;
m_testError = aError;
}
void SetRepoType( KIGIT_COMMON::GIT_CONN_TYPE aType )
{
m_ConnType->SetSelection( static_cast<int>( aType ) );
@@ -72,8 +78,6 @@ public:
return url;
}
const wxString& GetFullURL() const { return m_fullURL; }
void SetUsername( const wxString& aUsername ) { m_txtUsername->SetValue( aUsername ); }
wxString GetUsername() const { return m_txtUsername->GetValue(); }
@@ -83,6 +87,8 @@ public:
void SetRepoSSHPath( const wxString& aPath ) { m_fpSSHKey->SetFileName( aPath ); m_prevFile = aPath; }
wxString GetRepoSSHPath() const { return m_fpSSHKey->GetFileName().GetFullPath(); }
unsigned& GetTested() { return m_tested; }
void SetEncrypted( bool aEncrypted = true );
private:
@@ -94,7 +100,6 @@ private:
void OnTestClick( wxCommandEvent& event ) override;
void OnFileUpdated( wxFileDirPickerEvent& event ) override;
void onCbCustom( wxCommandEvent& event ) override;
void setDefaultSSHKey();
@@ -107,10 +112,13 @@ private:
private:
git_repository* m_repository;
wxString m_fullURL;
wxString m_prevFile;
unsigned m_tested;
bool m_failedTest;
wxString m_testError;
bool m_tempRepo;
wxString m_tempPath;
};
@@ -1,5 +1,5 @@
///////////////////////////////////////////////////////////////////////////
// C++ code generated with wxFormBuilder (version 4.2.1-0-g80c4cb6a-dirty)
// C++ code generated with wxFormBuilder (version 3.10.1-254-gc2ef7767)
// http://www.wxformbuilder.org/
//
// PLEASE DO *NOT* EDIT THIS FILE!
@@ -13,6 +13,7 @@ DIALOG_GIT_REPOSITORY_BASE::DIALOG_GIT_REPOSITORY_BASE( wxWindow* parent, wxWind
{
this->SetSizeHints( wxSize( -1,-1 ), wxDefaultSize );
wxBoxSizer* bSizerMain;
bSizerMain = new wxBoxSizer( wxVERTICAL );
m_staticText1 = new wxStaticText( this, wxID_ANY, _("Connection"), wxDefaultPosition, wxDefaultSize, 0 );
@@ -20,37 +21,31 @@ DIALOG_GIT_REPOSITORY_BASE::DIALOG_GIT_REPOSITORY_BASE( wxWindow* parent, wxWind
bSizerMain->Add( m_staticText1, 0, wxLEFT|wxTOP, 10 );
m_staticline1 = new wxStaticLine( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxLI_HORIZONTAL );
bSizerMain->Add( m_staticline1, 0, wxALL|wxEXPAND, 5 );
bSizerMain->Add( m_staticline1, 0, wxEXPAND|wxTOP, 5 );
wxFlexGridSizer* fgSizer2;
fgSizer2 = new wxFlexGridSizer( 0, 2, 5, 0 );
fgSizer2 = new wxFlexGridSizer( 0, 2, 0, 0 );
fgSizer2->AddGrowableCol( 1 );
fgSizer2->SetFlexibleDirection( wxBOTH );
fgSizer2->SetNonFlexibleGrowMode( wxFLEX_GROWMODE_SPECIFIED );
m_staticText3 = new wxStaticText( this, wxID_ANY, _("Name:"), wxDefaultPosition, wxDefaultSize, 0 );
m_staticText3 = new wxStaticText( this, wxID_ANY, _("Name"), wxDefaultPosition, wxDefaultSize, 0 );
m_staticText3->Wrap( -1 );
m_staticText3->Hide();
fgSizer2->Add( m_staticText3, 0, wxALIGN_CENTER_VERTICAL|wxLEFT, 5 );
fgSizer2->Add( m_staticText3, 0, wxALL, 5 );
m_txtName = new wxTextCtrl( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 );
m_txtName->Hide();
fgSizer2->Add( m_txtName, 0, wxALL|wxEXPAND, 5 );
fgSizer2->Add( m_txtName, 0, wxEXPAND|wxRIGHT, 5 );
m_staticText4 = new wxStaticText( this, wxID_ANY, _("Location:"), wxDefaultPosition, wxDefaultSize, 0 );
m_staticText4 = new wxStaticText( this, wxID_ANY, _("Location"), wxDefaultPosition, wxDefaultSize, 0 );
m_staticText4->Wrap( -1 );
fgSizer2->Add( m_staticText4, 0, wxALIGN_CENTER_VERTICAL|wxLEFT|wxRIGHT, 5 );
fgSizer2->Add( m_staticText4, 0, wxALL, 5 );
m_txtURL = new wxTextCtrl( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 );
fgSizer2->Add( m_txtURL, 0, wxEXPAND|wxRIGHT, 5 );
fgSizer2->Add( m_txtURL, 0, wxALL|wxEXPAND, 5 );
m_staticText9 = new wxStaticText( this, wxID_ANY, _("Connection type:"), wxDefaultPosition, wxDefaultSize, 0 );
m_staticText9 = new wxStaticText( this, wxID_ANY, _("Connection Type"), wxDefaultPosition, wxDefaultSize, 0 );
m_staticText9->Wrap( -1 );
m_staticText9->Hide();
fgSizer2->Add( m_staticText9, 0, wxALIGN_CENTER_VERTICAL|wxLEFT|wxRIGHT, 5 );
fgSizer2->Add( m_staticText9, 0, wxALL, 5 );
wxBoxSizer* bSizer3;
bSizer3 = new wxBoxSizer( wxHORIZONTAL );
@@ -59,84 +54,97 @@ DIALOG_GIT_REPOSITORY_BASE::DIALOG_GIT_REPOSITORY_BASE( wxWindow* parent, wxWind
int m_ConnTypeNChoices = sizeof( m_ConnTypeChoices ) / sizeof( wxString );
m_ConnType = new wxChoice( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, m_ConnTypeNChoices, m_ConnTypeChoices, 0 );
m_ConnType->SetSelection( 0 );
m_ConnType->Hide();
bSizer3->Add( m_ConnType, 0, wxRIGHT, 5 );
bSizer3->Add( m_ConnType, 1, wxEXPAND|wxLEFT|wxRIGHT, 5 );
bSizer3->Add( 0, 0, 0, wxEXPAND, 5 );
bSizer3->Add( 0, 0, 1, wxEXPAND, 5 );
fgSizer2->Add( bSizer3, 1, wxEXPAND, 5 );
bSizerMain->Add( fgSizer2, 0, wxEXPAND, 5 );
bSizerMain->Add( fgSizer2, 1, wxEXPAND, 5 );
m_panelAuth = new wxPanel( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL );
wxBoxSizer* m_szAuth;
m_szAuth = new wxBoxSizer( wxVERTICAL );
m_szAuth->Add( 0, 0, 1, wxEXPAND, 5 );
wxBoxSizer* bSizer11;
bSizer11 = new wxBoxSizer( wxHORIZONTAL );
m_staticText2 = new wxStaticText( m_panelAuth, wxID_ANY, _("Authentication"), wxDefaultPosition, wxDefaultSize, 0 );
m_staticText2->Wrap( -1 );
m_szAuth->Add( m_staticText2, 0, wxLEFT|wxTOP, 10 );
bSizer11->Add( m_staticText2, 0, wxLEFT|wxTOP, 10 );
bSizer11->Add( 0, 0, 1, wxEXPAND, 5 );
m_szAuth->Add( bSizer11, 0, wxEXPAND, 5 );
m_staticline2 = new wxStaticLine( m_panelAuth, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxLI_HORIZONTAL );
m_szAuth->Add( m_staticline2, 0, wxEXPAND | wxALL, 5 );
wxFlexGridSizer* fgSizer21;
fgSizer21 = new wxFlexGridSizer( 0, 2, 5, 0 );
fgSizer21->SetFlexibleDirection( wxBOTH );
fgSizer21->SetNonFlexibleGrowMode( wxFLEX_GROWMODE_SPECIFIED );
wxFlexGridSizer* fgSshSizer;
fgSshSizer = new wxFlexGridSizer( 0, 2, 0, 0 );
fgSshSizer->AddGrowableCol( 1 );
fgSshSizer->SetFlexibleDirection( wxBOTH );
fgSshSizer->SetNonFlexibleGrowMode( wxFLEX_GROWMODE_SPECIFIED );
m_cbCustom = new wxCheckBox( m_panelAuth, wxID_ANY, _("SSH private key: "), wxDefaultPosition, wxDefaultSize, 0 );
fgSizer21->Add( m_cbCustom, 0, wxALL, 5 );
m_labelSSH = new wxStaticText( m_panelAuth, wxID_ANY, _("SSH Private Key"), wxDefaultPosition, wxDefaultSize, 0 );
m_labelSSH->Wrap( -1 );
fgSshSizer->Add( m_labelSSH, 0, wxALIGN_CENTER_VERTICAL|wxALL|wxRESERVE_SPACE_EVEN_IF_HIDDEN, 5 );
wxBoxSizer* bSizer41;
bSizer41 = new wxBoxSizer( wxHORIZONTAL );
m_fpSSHKey = new wxFilePickerCtrl( m_panelAuth, wxID_ANY, wxEmptyString, _("Select SSH private key file"), _("*"), wxDefaultPosition, wxDefaultSize, wxFLP_DEFAULT_STYLE|wxFLP_FILE_MUST_EXIST|wxFLP_OPEN );
m_fpSSHKey->SetMinSize( wxSize( 250,-1 ) );
bSizer41->Add( m_fpSSHKey, 1, wxEXPAND|wxLEFT|wxRESERVE_SPACE_EVEN_IF_HIDDEN|wxRIGHT, 5 );
fgSizer21->Add( m_fpSSHKey, 0, wxEXPAND|wxRIGHT, 5 );
m_btnTest = new wxButton( m_panelAuth, wxID_ANY, _("Test"), wxDefaultPosition, wxDefaultSize, 0 );
bSizer41->Add( m_btnTest, 0, wxLEFT|wxRIGHT, 5 );
m_staticText11 = new wxStaticText( m_panelAuth, wxID_ANY, _("User name:"), wxDefaultPosition, wxDefaultSize, 0 );
fgSshSizer->Add( bSizer41, 1, wxEXPAND, 5 );
m_staticText11 = new wxStaticText( m_panelAuth, wxID_ANY, _("Username"), wxDefaultPosition, wxDefaultSize, 0 );
m_staticText11->Wrap( -1 );
fgSizer21->Add( m_staticText11, 0, wxALIGN_CENTER_VERTICAL|wxLEFT|wxRIGHT, 5 );
fgSshSizer->Add( m_staticText11, 0, wxALL, 5 );
m_txtUsername = new wxTextCtrl( m_panelAuth, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 );
fgSizer21->Add( m_txtUsername, 0, wxEXPAND|wxRIGHT, 5 );
fgSshSizer->Add( m_txtUsername, 0, wxALL|wxEXPAND, 5 );
m_labelPass1 = new wxStaticText( m_panelAuth, wxID_ANY, _("SSH key password:"), wxDefaultPosition, wxDefaultSize, 0 );
m_labelPass1 = new wxStaticText( m_panelAuth, wxID_ANY, _("SSH Key Password"), wxDefaultPosition, wxDefaultSize, 0 );
m_labelPass1->Wrap( -1 );
fgSizer21->Add( m_labelPass1, 0, wxALIGN_CENTER_VERTICAL|wxLEFT|wxRIGHT, 5 );
fgSshSizer->Add( m_labelPass1, 0, wxALL, 5 );
m_txtPassword = new wxTextCtrl( m_panelAuth, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 );
fgSizer21->Add( m_txtPassword, 0, wxEXPAND|wxRIGHT, 5 );
fgSshSizer->Add( m_txtPassword, 0, wxALL|wxEXPAND, 5 );
m_szAuth->Add( fgSizer21, 1, wxBOTTOM|wxEXPAND, 5 );
m_szAuth->Add( fgSshSizer, 1, wxEXPAND, 5 );
m_panelAuth->SetSizer( m_szAuth );
m_panelAuth->Layout();
m_szAuth->Fit( m_panelAuth );
bSizerMain->Add( m_panelAuth, 0, wxEXPAND|wxTOP, 5 );
bSizerMain->Add( 0, 0, 1, wxEXPAND, 5 );
bSizerMain->Add( m_panelAuth, 1, wxALL|wxEXPAND|wxRESERVE_SPACE_EVEN_IF_HIDDEN, 0 );
m_sdbSizer = new wxStdDialogButtonSizer();
m_sdbSizerOK = new wxButton( this, wxID_OK );
m_sdbSizer->AddButton( m_sdbSizerOK );
m_sdbSizerCancel = new wxButton( this, wxID_CANCEL );
m_sdbSizer->AddButton( m_sdbSizerCancel );
m_sdbSizerHelp = new wxButton( this, wxID_HELP );
m_sdbSizer->AddButton( m_sdbSizerHelp );
m_sdbSizer->Realize();
bSizerMain->Add( m_sdbSizer, 0, wxBOTTOM|wxEXPAND|wxTOP, 5 );
bSizerMain->Add( m_sdbSizer, 0, wxALL|wxEXPAND, 5 );
this->SetSizer( bSizerMain );
this->Layout();
bSizerMain->Fit( this );
this->Centre( wxBOTH );
@@ -145,9 +153,8 @@ DIALOG_GIT_REPOSITORY_BASE::DIALOG_GIT_REPOSITORY_BASE( wxWindow* parent, wxWind
this->Connect( wxEVT_UPDATE_UI, wxUpdateUIEventHandler( DIALOG_GIT_REPOSITORY_BASE::OnUpdateUI ) );
m_txtURL->Connect( wxEVT_KILL_FOCUS, wxFocusEventHandler( DIALOG_GIT_REPOSITORY_BASE::OnLocationExit ), NULL, this );
m_ConnType->Connect( wxEVT_COMMAND_CHOICE_SELECTED, wxCommandEventHandler( DIALOG_GIT_REPOSITORY_BASE::OnSelectConnType ), NULL, this );
m_cbCustom->Connect( wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler( DIALOG_GIT_REPOSITORY_BASE::onCbCustom ), NULL, this );
m_fpSSHKey->Connect( wxEVT_COMMAND_FILEPICKER_CHANGED, wxFileDirPickerEventHandler( DIALOG_GIT_REPOSITORY_BASE::OnFileUpdated ), NULL, this );
m_sdbSizerHelp->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_GIT_REPOSITORY_BASE::OnTestClick ), NULL, this );
m_btnTest->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_GIT_REPOSITORY_BASE::OnTestClick ), NULL, this );
m_sdbSizerOK->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_GIT_REPOSITORY_BASE::OnOKClick ), NULL, this );
}
@@ -158,9 +165,8 @@ DIALOG_GIT_REPOSITORY_BASE::~DIALOG_GIT_REPOSITORY_BASE()
this->Disconnect( wxEVT_UPDATE_UI, wxUpdateUIEventHandler( DIALOG_GIT_REPOSITORY_BASE::OnUpdateUI ) );
m_txtURL->Disconnect( wxEVT_KILL_FOCUS, wxFocusEventHandler( DIALOG_GIT_REPOSITORY_BASE::OnLocationExit ), NULL, this );
m_ConnType->Disconnect( wxEVT_COMMAND_CHOICE_SELECTED, wxCommandEventHandler( DIALOG_GIT_REPOSITORY_BASE::OnSelectConnType ), NULL, this );
m_cbCustom->Disconnect( wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler( DIALOG_GIT_REPOSITORY_BASE::onCbCustom ), NULL, this );
m_fpSSHKey->Disconnect( wxEVT_COMMAND_FILEPICKER_CHANGED, wxFileDirPickerEventHandler( DIALOG_GIT_REPOSITORY_BASE::OnFileUpdated ), NULL, this );
m_sdbSizerHelp->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_GIT_REPOSITORY_BASE::OnTestClick ), NULL, this );
m_btnTest->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_GIT_REPOSITORY_BASE::OnTestClick ), NULL, this );
m_sdbSizerOK->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_GIT_REPOSITORY_BASE::OnOKClick ), NULL, this );
}
File diff suppressed because it is too large Load Diff
@@ -1,5 +1,5 @@
///////////////////////////////////////////////////////////////////////////
// C++ code generated with wxFormBuilder (version 4.2.1-0-g80c4cb6a-dirty)
// C++ code generated with wxFormBuilder (version 3.10.1-254-gc2ef7767)
// http://www.wxformbuilder.org/
//
// PLEASE DO *NOT* EDIT THIS FILE!
@@ -21,14 +21,17 @@
#include <wx/textctrl.h>
#include <wx/choice.h>
#include <wx/sizer.h>
#include <wx/checkbox.h>
#include <wx/filepicker.h>
#include <wx/panel.h>
#include <wx/button.h>
#include <wx/bitmap.h>
#include <wx/image.h>
#include <wx/icon.h>
#include <wx/panel.h>
#include <wx/dialog.h>
///////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
/// Class DIALOG_GIT_REPOSITORY_BASE
///////////////////////////////////////////////////////////////////////////////
@@ -37,7 +40,6 @@ class DIALOG_GIT_REPOSITORY_BASE : public DIALOG_SHIM
private:
protected:
wxBoxSizer* bSizerMain;
wxStaticText* m_staticText1;
wxStaticLine* m_staticline1;
wxStaticText* m_staticText3;
@@ -49,8 +51,9 @@ class DIALOG_GIT_REPOSITORY_BASE : public DIALOG_SHIM
wxPanel* m_panelAuth;
wxStaticText* m_staticText2;
wxStaticLine* m_staticline2;
wxCheckBox* m_cbCustom;
wxStaticText* m_labelSSH;
wxFilePickerCtrl* m_fpSSHKey;
wxButton* m_btnTest;
wxStaticText* m_staticText11;
wxTextCtrl* m_txtUsername;
wxStaticText* m_labelPass1;
@@ -58,14 +61,12 @@ class DIALOG_GIT_REPOSITORY_BASE : public DIALOG_SHIM
wxStdDialogButtonSizer* m_sdbSizer;
wxButton* m_sdbSizerOK;
wxButton* m_sdbSizerCancel;
wxButton* m_sdbSizerHelp;
// Virtual event handlers, override them in your derived class
virtual void OnClose( wxCloseEvent& event ) { event.Skip(); }
virtual void OnUpdateUI( wxUpdateUIEvent& event ) { event.Skip(); }
virtual void OnLocationExit( wxFocusEvent& event ) { event.Skip(); }
virtual void OnSelectConnType( wxCommandEvent& event ) { event.Skip(); }
virtual void onCbCustom( wxCommandEvent& event ) { event.Skip(); }
virtual void OnFileUpdated( wxFileDirPickerEvent& event ) { event.Skip(); }
virtual void OnTestClick( wxCommandEvent& event ) { event.Skip(); }
virtual void OnOKClick( wxCommandEvent& event ) { event.Skip(); }
@@ -73,7 +74,7 @@ class DIALOG_GIT_REPOSITORY_BASE : public DIALOG_SHIM
public:
DIALOG_GIT_REPOSITORY_BASE( wxWindow* parent, wxWindowID id = wxID_ANY, const wxString& title = _("Git Repository"), const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxSize( -1,-1 ), long style = wxCAPTION|wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER );
DIALOG_GIT_REPOSITORY_BASE( wxWindow* parent, wxWindowID id = wxID_ANY, const wxString& title = _("Git Repository"), const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxSize( 682,598 ), long style = wxCAPTION|wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER );
~DIALOG_GIT_REPOSITORY_BASE();
+13 -15
View File
@@ -24,13 +24,9 @@
#include "dialog_git_switch.h"
#include <git/kicad_git_memory.h>
#include <trace_helpers.h>
#include <wx/button.h>
#include <wx/checkbox.h>
#include <wx/listctrl.h>
#include <wx/log.h>
#include <wx/event.h>
#include <wx/sizer.h>
#include <wx/timer.h>
@@ -244,42 +240,39 @@ void DIALOG_GIT_SWITCH::GetBranches()
git_reference* currentBranchReference = nullptr;
git_repository_head( &currentBranchReference, m_repository );
if( !currentBranchReference )
// Get the current branch name
if( currentBranchReference )
{
wxLogTrace( traceGit, "Failed to get current branch" );
return;
m_currentBranch = git_reference_shorthand( currentBranchReference );
git_reference_free( currentBranchReference );
}
KIGIT::GitReferencePtr currentBranch( currentBranchReference );
m_currentBranch = git_reference_shorthand( currentBranchReference );
// Initialize branch iterator
git_branch_iterator_new( &branchIterator, m_repository, GIT_BRANCH_ALL );
KIGIT::GitBranchIteratorPtr branchIteratorPtr( branchIterator );
// Iterate over local branches
git_reference* branchReference = nullptr;
while( git_branch_next( &branchReference, &branchType, branchIterator ) == 0 )
{
KIGIT::GitReferencePtr branchReferencePtr( branchReference );
// Get the branch OID
const git_oid* branchOid = git_reference_target( branchReference );
// Skip this branch if it doesn't have an OID
if( !branchOid )
{
git_reference_free( branchReference );
continue;
}
git_commit* commit = nullptr;
if( git_commit_lookup( &commit, m_repository, branchOid ) )
{
// Skip this branch if it doesn't have a commit
git_reference_free( branchReference );
continue;
}
KIGIT::GitCommitPtr commitPtr( commit );
// Retrieve commit details
BranchData branchData;
branchData.commitString = git_commit_message( commit );
@@ -287,5 +280,10 @@ void DIALOG_GIT_SWITCH::GetBranches()
branchData.isRemote = branchType == GIT_BRANCH_REMOTE;
m_branches[git_reference_shorthand( branchReference )] = branchData;
git_commit_free( commit );
git_reference_free( branchReference );
}
git_branch_iterator_free( branchIterator );
}
+274 -41
View File
@@ -24,12 +24,10 @@
#include <kiplatform/secrets.h>
#include <pgm_base.h>
#include <settings/common_settings.h>
#include <trace_helpers.h>
#include <widgets/std_bitmap_button.h>
#include <widgets/wx_grid.h>
#include <git2.h>
#include <git/kicad_git_memory.h>
#include <wx/bmpbuttn.h>
#include <wx/button.h>
#include <wx/checkbox.h>
@@ -38,6 +36,11 @@
PANEL_GIT_REPOS::PANEL_GIT_REPOS( wxWindow* aParent ) : PANEL_GIT_REPOS_BASE( aParent)
{
m_btnAddRepo->SetBitmap( KiBitmapBundle( BITMAPS::small_plus ) );
m_btnEditRepo->SetBitmap( KiBitmapBundle( BITMAPS::small_edit ) );
m_btnDelete->SetBitmap( KiBitmapBundle( BITMAPS::small_trash ) );
}
PANEL_GIT_REPOS::~PANEL_GIT_REPOS()
@@ -47,6 +50,7 @@ PANEL_GIT_REPOS::~PANEL_GIT_REPOS()
void PANEL_GIT_REPOS::ResetPanel()
{
m_grid->ClearGrid();
m_cbDefault->SetValue( true );
m_author->SetValue( wxEmptyString );
m_authorEmail->SetValue( wxEmptyString );
@@ -63,44 +67,56 @@ static std::pair<wxString, wxString> getDefaultAuthorAndEmail()
if( git_config_open_default( &config ) != 0 )
{
wxLogTrace( traceGit, "Failed to open default Git config: %s", KIGIT_COMMON::GetLastGitError() );
printf( "Failed to open default Git config: %s\n", giterr_last()->message );
return std::make_pair( name, email );
}
KIGIT::GitConfigPtr configPtr( config );
if( git_config_get_entry( &name_c, config, "user.name" ) != 0 )
{
wxLogTrace( traceGit, "Failed to get user.name from Git config: %s", KIGIT_COMMON::GetLastGitError() );
return std::make_pair( name, email );
printf( "Failed to get user.name from Git config: %s\n", giterr_last()->message );
}
KIGIT::GitConfigEntryPtr namePtr( name_c );
if( git_config_get_entry( &email_c, config, "user.email" ) != 0 )
{
wxLogTrace( traceGit, "Failed to get user.email from Git config: %s", KIGIT_COMMON::GetLastGitError() );
return std::make_pair( name, email );
printf( "Failed to get user.email from Git config: %s\n", giterr_last()->message );
}
KIGIT::GitConfigEntryPtr emailPtr( email_c );
if( name_c )
name = name_c->value;
if( email_c )
email = email_c->value;
git_config_entry_free( name_c );
git_config_entry_free( email_c );
git_config_free( config );
return std::make_pair( name, email );
}
bool PANEL_GIT_REPOS::TransferDataFromWindow()
{
COMMON_SETTINGS* settings = Pgm().GetCommonSettings();
COMMON_SETTINGS* settings = Pgm().GetCommonSettings();
std::vector<COMMON_SETTINGS::GIT_REPOSITORY>& repos = settings->m_Git.repositories;
repos.clear();
for( int row = 0; row < m_grid->GetNumberRows(); row++ )
{
COMMON_SETTINGS::GIT_REPOSITORY repo;
repo.active = m_grid->GetCellValue( row, COL_ACTIVE ) == "1";
repo.name = m_grid->GetCellValue( row, COL_NAME );
repo.path = m_grid->GetCellValue( row, COL_PATH );
repo.authType = m_grid->GetCellValue( row, COL_AUTH_TYPE );
repo.username = m_grid->GetCellValue( row, COL_USERNAME );
KIPLATFORM::SECRETS::StoreSecret( repo.path, repo.username,
m_grid->GetCellValue( row, COL_PASSWORD ) );
repo.ssh_path = m_grid->GetCellValue( row, COL_SSH_PATH );
repo.checkValid = m_grid->GetCellValue( row, COL_STATUS ) == "1";
repos.push_back( repo );
}
settings->m_Git.enableGit = m_enableGit->GetValue();
settings->m_Git.updatInterval = m_updateInterval->GetValue();
settings->m_Git.useDefaultAuthor = m_cbDefault->GetValue();
settings->m_Git.authorName = m_author->GetValue();
settings->m_Git.authorEmail = m_authorEmail->GetValue();
@@ -108,38 +124,153 @@ bool PANEL_GIT_REPOS::TransferDataFromWindow()
return true;
}
static bool testRepositoryConnection( COMMON_SETTINGS::GIT_REPOSITORY& repository)
{
git_libgit2_init();
git_remote_callbacks callbacks;
callbacks.version = GIT_REMOTE_CALLBACKS_VERSION;
typedef struct
{
COMMON_SETTINGS::GIT_REPOSITORY* repo;
bool success;
} callbacksPayload;
callbacksPayload cb_data( { &repository, true } ); // If we don't need authentication, then,
// we are successful
callbacks.payload = &cb_data;
callbacks.credentials =
[](git_cred** out, const char* url, const char* username, unsigned int allowed_types,
void* payload) -> int
{
// If we are asking for credentials, then, we need authentication
callbacksPayload* data = static_cast<callbacksPayload*>(payload);
data->success = false;
if( allowed_types & GIT_CREDTYPE_USERNAME )
{
data->success = true;
}
else if( data->repo->authType == "ssh" && ( allowed_types & GIT_CREDTYPE_SSH_KEY ) )
{
wxString sshKeyPath = data->repo->ssh_path;
// Check if the SSH key exists and is readable
if( wxFileExists( sshKeyPath ) && wxFile::Access( sshKeyPath, wxFile::read ) )
data->success = true;
}
else if( data->repo->authType == "password" )
{
data->success = ( allowed_types & GIT_CREDTYPE_USERPASS_PLAINTEXT );
}
return 0;
};
// Create a temporary directory to initialize the Git repository
wxString tempDirPath = wxFileName::CreateTempFileName(wxT("kigit_temp"));
if( !wxFileName::Mkdir( tempDirPath, wxS_DIR_DEFAULT ) )
{
git_libgit2_shutdown();
wxLogError( "Failed to create temporary directory for Git repository (%s): %s", tempDirPath,
wxSysErrorMsg() );
return false;
}
// Initialize the Git repository
git_repository* repo = nullptr;
int result = git_repository_init( &repo, tempDirPath.mb_str( wxConvUTF8 ), 0 );
if (result != 0)
{
git_repository_free(repo);
git_libgit2_shutdown();
wxRmdir(tempDirPath);
return false;
}
git_remote* remote = nullptr;
result = git_remote_create_anonymous( &remote, repo, tempDirPath.mb_str( wxConvUTF8 ) );
if (result != 0)
{
git_remote_free(remote);
git_repository_free(repo);
git_libgit2_shutdown();
wxRmdir(tempDirPath);
return false;
}
// We don't really care about the result of this call, the authentication callback
// will set the return values we need
git_remote_connect(remote, GIT_DIRECTION_FETCH, &callbacks, nullptr, nullptr);
git_remote_disconnect(remote);
git_remote_free(remote);
git_repository_free(repo);
git_libgit2_shutdown();
// Clean up the temporary directory
wxRmdir(tempDirPath);
return cb_data.success;
}
bool PANEL_GIT_REPOS::TransferDataToWindow()
{
COMMON_SETTINGS* settings = Pgm().GetCommonSettings();
std::pair<wxString, wxString> defaultAuthor = getDefaultAuthorAndEmail();
m_enableGit->SetValue( settings->m_Git.enableGit );
m_updateInterval->SetValue( settings->m_Git.updatInterval );
m_grid->ClearGrid();
for( COMMON_SETTINGS::GIT_REPOSITORY& repo : settings->m_Git.repositories )
{
if( repo.name.IsEmpty() || repo.path.IsEmpty() )
continue;
int row = m_grid->GetNumberRows();
m_grid->AppendRows( 1 );
m_grid->SetCellRenderer( row, COL_ACTIVE, new wxGridCellBoolRenderer() );
m_grid->SetCellEditor( row, COL_ACTIVE, new wxGridCellBoolEditor() );
m_grid->SetCellValue( row, COL_ACTIVE, repo.active ? "1" : "0" );
m_grid->SetCellValue( row, COL_NAME, repo.name );
m_grid->SetCellValue( row, COL_PATH, repo.path );
m_grid->SetCellValue( row, COL_AUTH_TYPE, repo.authType );
m_grid->SetCellValue( row, COL_USERNAME, repo.username );
wxString password;
KIPLATFORM::SECRETS::GetSecret( repo.path, repo.username, password );
m_grid->SetCellValue( row, COL_PASSWORD, password );
m_grid->SetCellValue( row, COL_SSH_PATH, repo.ssh_path );
if( repo.active )
m_grid->SetCellValue( row, 3, testRepositoryConnection( repo ) ? "C" : "NC" );
}
m_cbDefault->SetValue( settings->m_Git.useDefaultAuthor );
if( settings->m_Git.useDefaultAuthor )
{
std::pair<wxString, wxString> defaultAuthor = getDefaultAuthorAndEmail();
m_author->SetValue( defaultAuthor.first );
m_authorEmail->SetValue( defaultAuthor.second );
m_author->Disable();
m_authorEmail->Disable();
}
else
{
if( settings->m_Git.authorName.IsEmpty() )
m_author->SetValue( defaultAuthor.first );
else
m_author->SetValue( settings->m_Git.authorName );
if( settings->m_Git.authorEmail.IsEmpty() )
m_authorEmail->SetValue( defaultAuthor.second );
else
m_authorEmail->SetValue( settings->m_Git.authorEmail );
m_author->SetValue( settings->m_Git.authorName );
m_authorEmail->SetValue( settings->m_Git.authorEmail );
}
wxCommandEvent event;
onDefaultClick( event );
onEnableGitClick( event );
return true;
}
@@ -151,13 +282,115 @@ void PANEL_GIT_REPOS::onDefaultClick( wxCommandEvent& event )
m_authorEmailLabel->Enable( !m_cbDefault->GetValue() );
}
void PANEL_GIT_REPOS::onEnableGitClick( wxCommandEvent& aEvent )
void PANEL_GIT_REPOS::onGridDClick( wxGridEvent& event )
{
bool enable = m_enableGit->GetValue();
m_updateInterval->Enable( enable );
m_cbDefault->Enable( enable );
m_author->Enable( enable && !m_cbDefault->GetValue() );
m_authorEmail->Enable( enable && !m_cbDefault->GetValue() );
m_authorLabel->Enable( enable && !m_cbDefault->GetValue() );
m_authorEmailLabel->Enable( enable && !m_cbDefault->GetValue() );
if( m_grid->GetNumberRows() <= 0 )
{
wxCommandEvent evt;
onAddClick( evt );
return;
}
int row = event.GetRow();
if( row < 0 || row >= m_grid->GetNumberRows() )
return;
DIALOG_GIT_REPOSITORY dialog( this, nullptr );
dialog.SetRepoName( m_grid->GetCellValue( row, COL_NAME ) );
dialog.SetRepoURL( m_grid->GetCellValue( row, COL_PATH ) );
dialog.SetUsername( m_grid->GetCellValue( row, COL_USERNAME ) );
dialog.SetRepoSSHPath( m_grid->GetCellValue( row, COL_SSH_PATH ) );
dialog.SetPassword( m_grid->GetCellValue( row, COL_PASSWORD ) );
wxString type = m_grid->GetCellValue( row, COL_AUTH_TYPE );
if( type == "password" )
dialog.SetRepoType( KIGIT_COMMON::GIT_CONN_TYPE::GIT_CONN_HTTPS );
else if( type == "ssh" )
dialog.SetRepoType( KIGIT_COMMON::GIT_CONN_TYPE::GIT_CONN_SSH );
else
dialog.SetRepoType( KIGIT_COMMON::GIT_CONN_TYPE::GIT_CONN_LOCAL);
if( dialog.ShowModal() == wxID_OK )
{
m_grid->SetCellValue( row, COL_NAME, dialog.GetRepoName() );
m_grid->SetCellValue( row, COL_PATH, dialog.GetRepoURL() );
m_grid->SetCellValue( row, COL_USERNAME, dialog.GetUsername() );
m_grid->SetCellValue( row, COL_SSH_PATH, dialog.GetRepoSSHPath() );
m_grid->SetCellValue( row, COL_PASSWORD, dialog.GetPassword() );
if( dialog.GetRepoType() == KIGIT_COMMON::GIT_CONN_TYPE::GIT_CONN_HTTPS )
{
m_grid->SetCellValue( row, COL_AUTH_TYPE, "password" );
}
else if( dialog.GetRepoType() == KIGIT_COMMON::GIT_CONN_TYPE::GIT_CONN_SSH )
{
m_grid->SetCellValue( row, COL_AUTH_TYPE, "ssh" );
}
else
{
m_grid->SetCellValue( row, COL_AUTH_TYPE, "none" );
}
}
}
void PANEL_GIT_REPOS::onAddClick( wxCommandEvent& event )
{
DIALOG_GIT_REPOSITORY dialog( m_parent, nullptr );
if( dialog.ShowModal() == wxID_OK )
{
int row = m_grid->GetNumberRows();
m_grid->AppendRows( 1 );
m_grid->SetCellValue( row, COL_NAME, dialog.GetRepoName() );
m_grid->SetCellValue( row, COL_PATH, dialog.GetRepoURL() );
m_grid->SetCellValue( row, COL_USERNAME, dialog.GetUsername() );
m_grid->SetCellValue( row, COL_SSH_PATH, dialog.GetRepoSSHPath() );
m_grid->SetCellValue( row, COL_PASSWORD, dialog.GetPassword() );
if( dialog.GetRepoType() == KIGIT_COMMON::GIT_CONN_TYPE::GIT_CONN_HTTPS )
{
m_grid->SetCellValue( row, COL_AUTH_TYPE, "password" );
}
else if( dialog.GetRepoType() == KIGIT_COMMON::GIT_CONN_TYPE::GIT_CONN_SSH )
{
m_grid->SetCellValue( row, COL_AUTH_TYPE, "ssh" );
}
else
{
m_grid->SetCellValue( row, COL_AUTH_TYPE, "none" );
}
m_grid->MakeCellVisible( row, 0 );
}
}
void PANEL_GIT_REPOS::onEditClick( wxCommandEvent& event )
{
wxGridEvent evt( m_grid->GetId(), wxEVT_GRID_CELL_LEFT_DCLICK, m_grid,
m_grid->GetGridCursorRow(), m_grid->GetGridCursorCol() );
onGridDClick( evt );
}
void PANEL_GIT_REPOS::onDeleteClick( wxCommandEvent& event )
{
if( !m_grid->CommitPendingChanges() || m_grid->GetNumberRows() <= 0 )
return;
int curRow = m_grid->GetGridCursorRow();
m_grid->DeleteRows( curRow );
curRow = std::max( 0, curRow - 1 );
m_grid->MakeCellVisible( curRow, m_grid->GetGridCursorCol() );
m_grid->SetGridCursor( curRow, m_grid->GetGridCursorCol() );
}
+4 -1
View File
@@ -49,7 +49,10 @@ public:
private:
void onDefaultClick( wxCommandEvent& event ) override;
void onEnableGitClick( wxCommandEvent& event ) override;
void onGridDClick( wxGridEvent& event ) override;
void onAddClick( wxCommandEvent& event ) override;
void onEditClick( wxCommandEvent& event ) override;
void onDeleteClick( wxCommandEvent& event ) override;
};
+87 -55
View File
@@ -1,10 +1,13 @@
///////////////////////////////////////////////////////////////////////////
// C++ code generated with wxFormBuilder (version 4.2.1-0-g80c4cb6a-dirty)
// C++ code generated with wxFormBuilder (version 3.10.1-254-gc2ef7767)
// http://www.wxformbuilder.org/
//
// PLEASE DO *NOT* EDIT THIS FILE!
///////////////////////////////////////////////////////////////////////////
#include "widgets/std_bitmap_button.h"
#include "widgets/wx_grid.h"
#include "panel_git_repos_base.h"
///////////////////////////////////////////////////////////////////////////
@@ -17,57 +20,9 @@ PANEL_GIT_REPOS_BASE::PANEL_GIT_REPOS_BASE( wxWindow* parent, wxWindowID id, con
wxBoxSizer* bLeftSizer;
bLeftSizer = new wxBoxSizer( wxVERTICAL );
m_enableGit = new wxCheckBox( this, wxID_ANY, _("Enable Git Tracking"), wxDefaultPosition, wxDefaultSize, 0 );
bLeftSizer->Add( m_enableGit, 0, wxEXPAND|wxLEFT|wxRIGHT|wxTOP, 13 );
m_gitSizer = new wxBoxSizer( wxVERTICAL );
wxBoxSizer* bSizerUpdate;
bSizerUpdate = new wxBoxSizer( wxVERTICAL );
m_staticText6 = new wxStaticText( this, wxID_ANY, _("Remote Tracking"), wxDefaultPosition, wxDefaultSize, 0 );
m_staticText6->Wrap( -1 );
bSizerUpdate->Add( m_staticText6, 0, wxEXPAND|wxLEFT|wxRIGHT|wxTOP, 13 );
m_staticline2 = new wxStaticLine( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxLI_HORIZONTAL );
bSizerUpdate->Add( m_staticline2, 0, wxEXPAND | wxALL, 5 );
wxGridBagSizer* gbUpdate;
gbUpdate = new wxGridBagSizer( 4, 5 );
gbUpdate->SetFlexibleDirection( wxBOTH );
gbUpdate->SetNonFlexibleGrowMode( wxFLEX_GROWMODE_SPECIFIED );
gbUpdate->SetEmptyCellSize( wxSize( -1,2 ) );
m_updateLabel = new wxStaticText( this, wxID_ANY, _("Update interval:"), wxDefaultPosition, wxDefaultSize, 0 );
m_updateLabel->Wrap( -1 );
gbUpdate->Add( m_updateLabel, wxGBPosition( 0, 0 ), wxGBSpan( 1, 1 ), wxALIGN_CENTER_VERTICAL|wxLEFT|wxRIGHT, 5 );
m_updateInterval = new wxSpinCtrl( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxSP_ARROW_KEYS, 0, 60, 5 );
m_updateInterval->SetToolTip( _("Number of minutes between remote update checks. Zero disables automatic checks.") );
gbUpdate->Add( m_updateInterval, wxGBPosition( 0, 1 ), wxGBSpan( 1, 1 ), wxALIGN_CENTER_VERTICAL|wxEXPAND, 5 );
m_staticText7 = new wxStaticText( this, wxID_ANY, _("minutes"), wxDefaultPosition, wxDefaultSize, 0 );
m_staticText7->Wrap( -1 );
gbUpdate->Add( m_staticText7, wxGBPosition( 0, 2 ), wxGBSpan( 1, 1 ), wxALIGN_CENTER_VERTICAL|wxLEFT|wxRIGHT, 5 );
gbUpdate->AddGrowableCol( 2 );
bSizerUpdate->Add( gbUpdate, 0, wxEXPAND|wxLEFT, 13 );
m_gitSizer->Add( bSizerUpdate, 0, wxEXPAND, 5 );
wxBoxSizer* bSizerCommitData;
bSizerCommitData = new wxBoxSizer( wxVERTICAL );
m_staticText12 = new wxStaticText( this, wxID_ANY, _("Git Commit Data"), wxDefaultPosition, wxDefaultSize, 0 );
m_staticText12->Wrap( -1 );
bSizerCommitData->Add( m_staticText12, 0, wxEXPAND|wxLEFT|wxTOP, 13 );
m_staticline31 = new wxStaticLine( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxLI_HORIZONTAL );
bSizerCommitData->Add( m_staticline31, 0, wxEXPAND | wxALL, 5 );
bLeftSizer->Add( m_staticText12, 0, wxEXPAND|wxLEFT|wxTOP, 10 );
wxFlexGridSizer* fgSizer1;
fgSizer1 = new wxFlexGridSizer( 0, 2, 0, 0 );
@@ -105,13 +60,84 @@ PANEL_GIT_REPOS_BASE::PANEL_GIT_REPOS_BASE( wxWindow* parent, wxWindowID id, con
fgSizer1->Add( m_authorEmail, 0, wxALL|wxEXPAND, 5 );
bSizerCommitData->Add( fgSizer1, 0, wxBOTTOM|wxEXPAND|wxLEFT, 8 );
bLeftSizer->Add( fgSizer1, 1, wxBOTTOM|wxEXPAND|wxLEFT|wxTOP, 13 );
m_staticline3 = new wxStaticLine( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxLI_HORIZONTAL );
bLeftSizer->Add( m_staticline3, 0, wxEXPAND|wxBOTTOM, 5 );
m_staticText20 = new wxStaticText( this, wxID_ANY, _("Git Repositories"), wxDefaultPosition, wxDefaultSize, 0 );
m_staticText20->Wrap( -1 );
bLeftSizer->Add( m_staticText20, 0, wxEXPAND|wxLEFT|wxRIGHT, 13 );
wxBoxSizer* bAntialiasingSizer;
bAntialiasingSizer = new wxBoxSizer( wxVERTICAL );
m_grid = new WX_GRID( this, wxID_ANY, wxDefaultPosition, wxSize( 820,200 ), 0 );
// Grid
m_grid->CreateGrid( 0, 10 );
m_grid->EnableEditing( false );
m_grid->EnableGridLines( true );
m_grid->EnableDragGridSize( false );
m_grid->SetMargins( 0, 0 );
// Columns
m_grid->SetColSize( 0, 60 );
m_grid->SetColSize( 1, 200 );
m_grid->SetColSize( 2, 500 );
m_grid->SetColSize( 3, 60 );
m_grid->SetColSize( 4, 0 );
m_grid->SetColSize( 5, 0 );
m_grid->SetColSize( 6, 0 );
m_grid->SetColSize( 7, 0 );
m_grid->SetColSize( 8, 0 );
m_grid->SetColSize( 9, 0 );
m_grid->EnableDragColMove( false );
m_grid->EnableDragColSize( true );
m_grid->SetColLabelValue( 0, _("Active") );
m_grid->SetColLabelValue( 1, _("Name") );
m_grid->SetColLabelValue( 2, _("Path") );
m_grid->SetColLabelValue( 3, _("Status") );
m_grid->SetColLabelSize( 22 );
m_grid->SetColLabelAlignment( wxALIGN_CENTER, wxALIGN_CENTER );
// Rows
m_grid->EnableDragRowSize( true );
m_grid->SetRowLabelSize( 0 );
m_grid->SetRowLabelAlignment( wxALIGN_CENTER, wxALIGN_CENTER );
// Label Appearance
// Cell Defaults
m_grid->SetDefaultCellAlignment( wxALIGN_LEFT, wxALIGN_TOP );
bAntialiasingSizer->Add( m_grid, 5, wxALL|wxEXPAND, 5 );
m_gitSizer->Add( bSizerCommitData, 1, wxEXPAND, 5 );
bLeftSizer->Add( bAntialiasingSizer, 0, wxEXPAND|wxLEFT|wxTOP, 5 );
wxBoxSizer* bButtonsSizer;
bButtonsSizer = new wxBoxSizer( wxHORIZONTAL );
m_btnAddRepo = new STD_BITMAP_BUTTON( this, wxID_ANY, wxNullBitmap, wxDefaultPosition, wxDefaultSize, wxBU_AUTODRAW|0 );
m_btnAddRepo->SetToolTip( _("Add new repository") );
bButtonsSizer->Add( m_btnAddRepo, 0, wxALL, 5 );
m_btnEditRepo = new STD_BITMAP_BUTTON( this, wxID_ANY, wxNullBitmap, wxDefaultPosition, wxDefaultSize, wxBU_AUTODRAW|0 );
m_btnEditRepo->SetToolTip( _("Edit repository properties") );
bButtonsSizer->Add( m_btnEditRepo, 0, wxALL, 5 );
bLeftSizer->Add( m_gitSizer, 0, wxEXPAND, 0 );
bButtonsSizer->Add( 0, 0, 1, wxEXPAND, 5 );
m_btnDelete = new STD_BITMAP_BUTTON( this, wxID_ANY, wxNullBitmap, wxDefaultPosition, wxDefaultSize, wxBU_AUTODRAW|0 );
m_btnDelete->SetToolTip( _("Remove Git Repository") );
bButtonsSizer->Add( m_btnDelete, 0, wxBOTTOM|wxRIGHT|wxTOP, 5 );
bLeftSizer->Add( bButtonsSizer, 1, wxALL|wxEXPAND, 5 );
bPanelSizer->Add( bLeftSizer, 0, wxRIGHT, 20 );
@@ -122,14 +148,20 @@ PANEL_GIT_REPOS_BASE::PANEL_GIT_REPOS_BASE( wxWindow* parent, wxWindowID id, con
bPanelSizer->Fit( this );
// Connect Events
m_enableGit->Connect( wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler( PANEL_GIT_REPOS_BASE::onEnableGitClick ), NULL, this );
m_cbDefault->Connect( wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler( PANEL_GIT_REPOS_BASE::onDefaultClick ), NULL, this );
m_grid->Connect( wxEVT_GRID_CELL_LEFT_DCLICK, wxGridEventHandler( PANEL_GIT_REPOS_BASE::onGridDClick ), NULL, this );
m_btnAddRepo->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( PANEL_GIT_REPOS_BASE::onAddClick ), NULL, this );
m_btnEditRepo->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( PANEL_GIT_REPOS_BASE::onEditClick ), NULL, this );
m_btnDelete->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( PANEL_GIT_REPOS_BASE::onDeleteClick ), NULL, this );
}
PANEL_GIT_REPOS_BASE::~PANEL_GIT_REPOS_BASE()
{
// Disconnect Events
m_enableGit->Disconnect( wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler( PANEL_GIT_REPOS_BASE::onEnableGitClick ), NULL, this );
m_cbDefault->Disconnect( wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler( PANEL_GIT_REPOS_BASE::onDefaultClick ), NULL, this );
m_grid->Disconnect( wxEVT_GRID_CELL_LEFT_DCLICK, wxGridEventHandler( PANEL_GIT_REPOS_BASE::onGridDClick ), NULL, this );
m_btnAddRepo->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( PANEL_GIT_REPOS_BASE::onAddClick ), NULL, this );
m_btnEditRepo->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( PANEL_GIT_REPOS_BASE::onEditClick ), NULL, this );
m_btnDelete->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( PANEL_GIT_REPOS_BASE::onDeleteClick ), NULL, this );
}
+24 -16
View File
@@ -1,5 +1,5 @@
///////////////////////////////////////////////////////////////////////////
// C++ code generated with wxFormBuilder (version 4.2.1-0-g80c4cb6a-dirty)
// C++ code generated with wxFormBuilder (version 3.10.1-254-gc2ef7767)
// http://www.wxformbuilder.org/
//
// PLEASE DO *NOT* EDIT THIS FILE!
@@ -10,19 +10,26 @@
#include <wx/artprov.h>
#include <wx/xrc/xmlres.h>
#include <wx/intl.h>
class STD_BITMAP_BUTTON;
class WX_GRID;
#include "widgets/resettable_panel.h"
#include <wx/string.h>
#include <wx/checkbox.h>
#include <wx/stattext.h>
#include <wx/gdicmn.h>
#include <wx/font.h>
#include <wx/colour.h>
#include <wx/settings.h>
#include <wx/stattext.h>
#include <wx/statline.h>
#include <wx/spinctrl.h>
#include <wx/gbsizer.h>
#include <wx/sizer.h>
#include <wx/checkbox.h>
#include <wx/textctrl.h>
#include <wx/sizer.h>
#include <wx/statline.h>
#include <wx/grid.h>
#include <wx/bmpbuttn.h>
#include <wx/bitmap.h>
#include <wx/image.h>
#include <wx/icon.h>
#include <wx/button.h>
#include <wx/panel.h>
///////////////////////////////////////////////////////////////////////////
@@ -35,24 +42,25 @@ class PANEL_GIT_REPOS_BASE : public RESETTABLE_PANEL
private:
protected:
wxCheckBox* m_enableGit;
wxBoxSizer* m_gitSizer;
wxStaticText* m_staticText6;
wxStaticLine* m_staticline2;
wxStaticText* m_updateLabel;
wxSpinCtrl* m_updateInterval;
wxStaticText* m_staticText7;
wxStaticText* m_staticText12;
wxStaticLine* m_staticline31;
wxCheckBox* m_cbDefault;
wxStaticText* m_authorLabel;
wxTextCtrl* m_author;
wxStaticText* m_authorEmailLabel;
wxTextCtrl* m_authorEmail;
wxStaticLine* m_staticline3;
wxStaticText* m_staticText20;
WX_GRID* m_grid;
STD_BITMAP_BUTTON* m_btnAddRepo;
STD_BITMAP_BUTTON* m_btnEditRepo;
STD_BITMAP_BUTTON* m_btnDelete;
// Virtual event handlers, override them in your derived class
virtual void onEnableGitClick( wxCommandEvent& event ) { event.Skip(); }
virtual void onDefaultClick( wxCommandEvent& event ) { event.Skip(); }
virtual void onGridDClick( wxGridEvent& event ) { event.Skip(); }
virtual void onAddClick( wxCommandEvent& event ) { event.Skip(); }
virtual void onEditClick( wxCommandEvent& event ) { event.Skip(); }
virtual void onDeleteClick( wxCommandEvent& event ) { event.Skip(); }
public:
File diff suppressed because it is too large Load Diff
+4 -9
View File
@@ -36,7 +36,6 @@
#include <wx/filename.h>
#include <wx/log.h>
#include <wx/menu.h>
#include <wx/wfstream.h>
/* ---------- GRID_TRICKS for embedded files grid ---------- */
@@ -318,7 +317,7 @@ void PANEL_EMBEDDED_FILES::onAddEmbeddedFiles( wxCommandEvent& event )
{
// TODO: Update strings to reflect that multiple files can be selected.
wxFileDialog fileDialog( this, _( "Select a file to embed" ), wxEmptyString, wxEmptyString,
_( "All Files" ) + wxT( " (*.*)|*.*" ),
_( "All files|*.*" ),
wxFD_OPEN | wxFD_FILE_MUST_EXIST | wxFD_MULTIPLE );
if( fileDialog.ShowModal() == wxID_OK )
@@ -446,10 +445,9 @@ void PANEL_EMBEDDED_FILES::onExportFiles( wxCommandEvent& event )
if( skip_file )
continue;
wxFFile ffile( fileName.GetFullPath(), wxT( "w" ) );
wxFFileOutputStream out( fileName.GetFullPath() );
if( !out.IsOk() )
if( !ffile.IsOpened() )
{
wxString msg = wxString::Format( _( "Failed to open file '%s'." ),
fileName.GetFullName() );
@@ -459,15 +457,12 @@ void PANEL_EMBEDDED_FILES::onExportFiles( wxCommandEvent& event )
continue;
}
out.Write( file->decompressedData.data(), file->decompressedData.size() );
if( !out.IsOk() || ( out.LastWrite() != file->decompressedData.size() ) )
if( !ffile.Write( file->decompressedData.data(), file->decompressedData.size() ) )
{
wxString msg = wxString::Format( _( "Failed to write file '%s'." ),
fileName.GetFullName() );
KIDIALOG errorDlg( m_parent, msg, _( "Error" ), wxOK | wxICON_ERROR );
errorDlg.ShowModal();
}
}
+1 -1
View File
@@ -35,7 +35,7 @@ PANEL_EMBEDDED_FILES_BASE::PANEL_EMBEDDED_FILES_BASE( wxWindow* parent, wxWindow
m_files_grid->EnableDragColMove( false );
m_files_grid->EnableDragColSize( true );
m_files_grid->SetColLabelValue( 0, _("Filename") );
m_files_grid->SetColLabelValue( 1, _("Embedded Reference") );
m_files_grid->SetColLabelValue( 1, _("Internal Reference") );
m_files_grid->SetColLabelSize( 22 );
m_files_grid->SetColLabelAlignment( wxALIGN_CENTER, wxALIGN_CENTER );
+1 -1
View File
@@ -98,7 +98,7 @@
<property name="close_button">1</property>
<property name="col_label_horiz_alignment">wxALIGN_CENTER</property>
<property name="col_label_size">22</property>
<property name="col_label_values">&quot;Filename&quot; &quot;Embedded Reference&quot;</property>
<property name="col_label_values">&quot;Filename&quot; &quot;Internal Reference&quot;</property>
<property name="col_label_vert_alignment">wxALIGN_CENTER</property>
<property name="cols">2</property>
<property name="column_sizes">440,180</property>
+1 -63
View File
@@ -86,9 +86,7 @@ PANEL_SETUP_NETCLASSES::PANEL_SETUP_NETCLASSES( wxWindow* aParentWindow, EDA_DRA
m_netNames( aNetNames ),
m_lastCheckedTicker( 0 ),
m_hoveredCol( -1 ),
m_lastNetclassGridWidth( -1 ),
m_sortAsc( false ),
m_sortCol( 0 )
m_lastNetclassGridWidth( -1 )
{
// Clear and re-load each time. Language (or darkmode) might have changed.
g_lineStyleIcons.clear();
@@ -234,11 +232,6 @@ PANEL_SETUP_NETCLASSES::PANEL_SETUP_NETCLASSES( wxWindow* aParentWindow, EDA_DRA
&PANEL_SETUP_NETCLASSES::OnNetclassGridMouseEvent,
this );
// Allow sorting assignments by column
m_assignmentGrid->Connect(
wxEVT_GRID_LABEL_LEFT_CLICK,
wxGridEventHandler( PANEL_SETUP_NETCLASSES::OnNetclassAssignmentSort ), nullptr, this );
m_frame->Bind( EDA_EVT_UNITS_CHANGED, &PANEL_SETUP_NETCLASSES::onUnitsChanged, this );
m_netclassGrid->EndBatch();
@@ -282,10 +275,6 @@ PANEL_SETUP_NETCLASSES::~PANEL_SETUP_NETCLASSES()
wxGridEventHandler( PANEL_SETUP_NETCLASSES::OnNetclassGridCellChanging ),
nullptr, this );
m_assignmentGrid->Disconnect(
wxEVT_GRID_LABEL_LEFT_CLICK,
wxGridEventHandler( PANEL_SETUP_NETCLASSES::OnNetclassAssignmentSort ), nullptr, this );
m_frame->Unbind( EDA_EVT_UNITS_CHANGED, &PANEL_SETUP_NETCLASSES::onUnitsChanged, this );
}
@@ -628,57 +617,6 @@ void PANEL_SETUP_NETCLASSES::OnNetclassGridCellChanging( wxGridEvent& event )
}
}
void PANEL_SETUP_NETCLASSES::OnNetclassAssignmentSort( wxGridEvent& event )
{
event.Skip();
if( !m_assignmentGrid->CommitPendingChanges() )
return;
if( ( event.GetCol() < 0 ) || ( event.GetCol() >= m_assignmentGrid->GetNumberCols() ) )
return;
// Toggle sort order if the same column is clicked
if( event.GetCol() != m_sortCol )
{
m_sortCol = event.GetCol();
m_sortAsc = true;
}
else
{
m_sortAsc = !m_sortAsc;
}
std::vector<std::pair<wxString, wxString>> netclassesassignments;
netclassesassignments.reserve( m_assignmentGrid->GetNumberRows() );
for( int row = 0; row < m_assignmentGrid->GetNumberRows(); ++row )
{
netclassesassignments.emplace_back( m_assignmentGrid->GetCellValue( row, 0 ),
m_assignmentGrid->GetCellValue( row, 1 ) );
}
std::sort( netclassesassignments.begin(), netclassesassignments.end(),
[this]( const std::pair<wxString, wxString>& assign1,
const std::pair<wxString, wxString>& assign2 )
{
const wxString& str1 = ( m_sortCol == 0 ) ? assign1.first : assign1.second;
const wxString& str2 = ( m_sortCol == 0 ) ? assign2.first : assign2.second;
return m_sortAsc ? ( str1 < str2 ) : ( str1 > str2 );
} );
m_assignmentGrid->ClearRows();
m_assignmentGrid->AppendRows( netclassesassignments.size() );
int row = 0;
for( const auto& [pattern, netclassName] : netclassesassignments )
{
m_assignmentGrid->SetCellValue( row, 0, pattern );
m_assignmentGrid->SetCellValue( row, 1, netclassName );
row++;
}
}
void PANEL_SETUP_NETCLASSES::OnNetclassGridMouseEvent( wxMouseEvent& aEvent )
{
+7 -4
View File
@@ -160,7 +160,11 @@ EDA_DRAW_PANEL_GAL::EDA_DRAW_PANEL_GAL( wxWindow* aParentWindow, wxWindowID aWin
Connect( m_refreshTimer.GetId(), wxEVT_TIMER,
wxTimerEventHandler( EDA_DRAW_PANEL_GAL::onRefreshTimer ), nullptr, this );
Connect( wxEVT_SHOW, wxShowEventHandler( EDA_DRAW_PANEL_GAL::onShowEvent ), nullptr, this );
// Set up timer to execute OnShow() method when the window appears on the screen
m_onShowTimer.SetOwner( this );
Connect( m_onShowTimer.GetId(), wxEVT_TIMER,
wxTimerEventHandler( EDA_DRAW_PANEL_GAL::onShowTimer ), nullptr, this );
m_onShowTimer.Start( 10 );
}
@@ -439,8 +443,6 @@ void EDA_DRAW_PANEL_GAL::StopDrawing()
m_refreshTimer.Stop();
m_drawingEnabled = false;
Disconnect( wxEVT_SHOW, wxShowEventHandler( EDA_DRAW_PANEL_GAL::onShowEvent ), nullptr, this );
Disconnect( wxEVT_PAINT, wxPaintEventHandler( EDA_DRAW_PANEL_GAL::onPaint ), nullptr, this );
Disconnect( wxEVT_IDLE, wxIdleEventHandler( EDA_DRAW_PANEL_GAL::onIdle ), nullptr, this );
@@ -648,10 +650,11 @@ void EDA_DRAW_PANEL_GAL::onRefreshTimer( wxTimerEvent& aEvent )
}
void EDA_DRAW_PANEL_GAL::onShowEvent( wxShowEvent& aEvent )
void EDA_DRAW_PANEL_GAL::onShowTimer( wxTimerEvent& aEvent )
{
if( m_gal && m_gal->IsInitialized() && m_gal->IsVisible() )
{
m_onShowTimer.Stop();
OnShow();
}
}
+35 -17
View File
@@ -24,7 +24,6 @@
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
*/
#include "kicad_manager_frame.h"
#include <eda_base_frame.h>
#include <advanced_config.h>
@@ -174,7 +173,7 @@ EDA_BASE_FRAME::EDA_BASE_FRAME( wxWindow* aParent, FRAME_T aFrameType, const wxS
wxFrame( aParent, wxID_ANY, aTitle, aPos, aSize, aStyle, aFrameName ),
TOOLS_HOLDER(),
KIWAY_HOLDER( aKiway, KIWAY_HOLDER::FRAME ),
UNITS_PROVIDER( aIuScale, EDA_UNITS::MM )
UNITS_PROVIDER( aIuScale, EDA_UNITS::MILLIMETRES )
{
commonInit( aFrameType );
}
@@ -503,6 +502,22 @@ void EDA_BASE_FRAME::ReCreateMenuBar()
}
void EDA_BASE_FRAME::SetMenuBar( wxMenuBar* menu_bar )
{
wxFrame::SetMenuBar( menu_bar );
// Move Help menu back to end of menubar
int pos = GetMenuBar()->FindMenu( _( "&Help" ) + wxS( " " ) );
if( pos != wxNOT_FOUND )
{
wxMenu* helpMenu = GetMenuBar()->Remove( pos );
GetMenuBar()->Append( helpMenu, _( "&Help" ) + wxS( " " ) );
}
}
void EDA_BASE_FRAME::AddStandardHelpMenu( wxMenuBar* aMenuBar )
{
COMMON_CONTROL* commonControl = m_toolManager->GetTool<COMMON_CONTROL>();
@@ -518,7 +533,13 @@ void EDA_BASE_FRAME::AddStandardHelpMenu( wxMenuBar* aMenuBar )
helpMenu->AppendSeparator();
helpMenu->Add( ACTIONS::about );
aMenuBar->Append( helpMenu, _( "&Help" ) );
// Trailing space keeps OSX from hijacking our menu (and disabling everything in it).
aMenuBar->Append( helpMenu, _( "&Help" ) + wxS( " " ) );
// This change is only needed on macOS, and creates a bug on Windows
#ifdef __WXMAC__
helpMenu->wxMenu::SetTitle( _( "&Help" ) + wxS( " " ) );
#endif
}
@@ -1067,15 +1088,7 @@ void EDA_BASE_FRAME::ShowPreferences( wxString aStartPage, wxString aStartParent
KIFACE* kiface = nullptr;
std::vector<int> expand;
wxWindow* kicadMgr_window = wxWindow::FindWindowByName( KICAD_MANAGER_FRAME_NAME );
if( KICAD_MANAGER_FRAME* kicadMgr = static_cast<KICAD_MANAGER_FRAME*>( kicadMgr_window ) )
{
ACTION_MANAGER* actionMgr = kicadMgr->GetToolManager()->GetActionManager();
for( const auto& [name, action] : actionMgr->GetActions() )
hotkeysPanel->ActionsList().push_back( action );
}
Kiway().GetActions( hotkeysPanel->ActionsList() );
book->AddLazyPage(
[]( wxWindow* aParent ) -> wxWindow*
@@ -1092,11 +1105,16 @@ void EDA_BASE_FRAME::ShowPreferences( wxString aStartPage, wxString aStartParent
book->AddPage( hotkeysPanel, _( "Hotkeys" ) );
book->AddLazyPage(
[]( wxWindow* aParent ) -> wxWindow*
{
return new PANEL_GIT_REPOS( aParent );
}, _( "Version Control" ) );
// This currently allows pre-defined repositories that we
// don't use, so keep it disabled at the moment
if( ADVANCED_CFG::GetCfg().m_EnableGit && false )
{
book->AddLazyPage(
[]( wxWindow* aParent ) -> wxWindow*
{
return new PANEL_GIT_REPOS( aParent );
}, _( "Version Control" ) );
}
#ifdef KICAD_USE_SENTRY
book->AddLazyPage(
+5 -10
View File
@@ -60,7 +60,7 @@ static const wxFileTypeInfo EDAfallbacks[] =
bool GetAssociatedDocument( wxWindow* aParent, const wxString& aDocName, PROJECT* aProject,
SEARCH_STACK* aPaths, std::vector<EMBEDDED_FILES*> aFilesStack )
SEARCH_STACK* aPaths, EMBEDDED_FILES* aFiles )
{
wxString docname;
wxString fullfilename;
@@ -87,7 +87,7 @@ bool GetAssociatedDocument( wxWindow* aParent, const wxString& aDocName, PROJECT
}
else
{
if( aFilesStack.empty() )
if( !aFiles )
{
wxLogTrace( wxT( "KICAD_EMBED" ),
wxT( "No EMBEDDED_FILES object provided for kicad_embed URI" ) );
@@ -101,13 +101,9 @@ bool GetAssociatedDocument( wxWindow* aParent, const wxString& aDocName, PROJECT
return false;
}
docname = docname.Mid( wxString( FILEEXT::KiCadUriPrefix + "://" ).length() );
docname = docname.Mid( 14 );
wxFileName temp_file = aFilesStack[0]->GetTemporaryFileName( docname );
int ii = 1;
while( !temp_file.IsOk() && ii < (int) aFilesStack.size() )
temp_file = aFilesStack[ii++]->GetTemporaryFileName( docname );
wxFileName temp_file = aFiles->GetTemporaryFileName( docname );
if( !temp_file.IsOk() )
{
@@ -118,8 +114,7 @@ bool GetAssociatedDocument( wxWindow* aParent, const wxString& aDocName, PROJECT
wxLogTrace( wxT( "KICAD_EMBED" ),
wxT( "Opening embedded file '%s' as '%s'" ),
docname,
temp_file.GetFullPath() );
docname, temp_file.GetFullPath() );
docname = temp_file.GetFullPath();
}
}
+16 -17
View File
@@ -96,10 +96,9 @@ EDA_DRAW_FRAME::EDA_DRAW_FRAME( KIWAY* aKiway, wxWindow* aParent, FRAME_T aFrame
const wxString& aTitle, const wxPoint& aPos, const wxSize& aSize,
long aStyle, const wxString& aFrameName,
const EDA_IU_SCALE& aIuScale ) :
KIWAY_PLAYER( aKiway, aParent, aFrameType, aTitle, aPos, aSize, aStyle, aFrameName,
aIuScale ),
m_socketServer( nullptr ),
m_lastToolbarIconSize( 0 )
KIWAY_PLAYER( aKiway, aParent, aFrameType, aTitle, aPos, aSize, aStyle, aFrameName, aIuScale ),
m_socketServer( nullptr ),
m_lastToolbarIconSize( 0 )
{
m_mainToolBar = nullptr;
m_drawToolBar = nullptr;
@@ -126,7 +125,7 @@ EDA_DRAW_FRAME::EDA_DRAW_FRAME( KIWAY* aKiway, wxWindow* aParent, FRAME_T aFrame
m_propertiesPanel = nullptr;
m_netInspectorPanel = nullptr;
SetUserUnits( EDA_UNITS::MM );
SetUserUnits( EDA_UNITS::MILLIMETRES );
m_auimgr.SetFlags( wxAUI_MGR_DEFAULT );
@@ -177,8 +176,7 @@ EDA_DRAW_FRAME::EDA_DRAW_FRAME( KIWAY* aKiway, wxWindow* aParent, FRAME_T aFrame
EDA_DRAW_FRAME::~EDA_DRAW_FRAME()
{
if( !m_openGLFailureOccured )
saveCanvasTypeSetting( m_canvasType );
saveCanvasTypeSetting( m_canvasType );
delete m_actions;
delete m_toolManager;
@@ -285,7 +283,8 @@ void EDA_DRAW_FRAME::ToggleUserUnits()
}
else
{
SetUserUnits( GetUserUnits() == EDA_UNITS::INCH ? EDA_UNITS::MM : EDA_UNITS::INCH );
SetUserUnits( GetUserUnits() == EDA_UNITS::INCHES ? EDA_UNITS::MILLIMETRES
: EDA_UNITS::INCHES );
unitsChangeRefresh();
wxCommandEvent e( EDA_EVT_UNITS_CHANGED );
@@ -649,10 +648,10 @@ void EDA_DRAW_FRAME::DisplayUnitsMsg()
switch( GetUserUnits() )
{
case EDA_UNITS::INCH: msg = _( "inches" ); break;
case EDA_UNITS::MILS: msg = _( "mils" ); break;
case EDA_UNITS::MM: msg = _( "mm" ); break;
default: msg = _( "Units" ); break;
case EDA_UNITS::INCHES: msg = _( "inches" ); break;
case EDA_UNITS::MILS: msg = _( "mils" ); break;
case EDA_UNITS::MILLIMETRES: msg = _( "mm" ); break;
default: msg = _( "Units" ); break;
}
SetStatusText( msg, 5 );
@@ -1236,7 +1235,7 @@ void EDA_DRAW_FRAME::ShowChangedLanguage()
void EDA_DRAW_FRAME::UpdateProperties()
{
if( m_isClosing || !m_propertiesPanel || !m_propertiesPanel->IsShownOnScreen() )
if( !m_propertiesPanel || !m_propertiesPanel->IsShownOnScreen() )
return;
m_propertiesPanel->UpdateData();
@@ -1277,9 +1276,9 @@ void EDA_DRAW_FRAME::setupUnits( APP_SETTINGS_BASE* aCfg )
switch( static_cast<EDA_UNITS>( aCfg->m_System.units ) )
{
default:
case EDA_UNITS::MM: m_toolManager->RunAction( ACTIONS::millimetersUnits ); break;
case EDA_UNITS::INCH: m_toolManager->RunAction( ACTIONS::inchesUnits ); break;
case EDA_UNITS::MILS: m_toolManager->RunAction( ACTIONS::milsUnits ); break;
case EDA_UNITS::MILLIMETRES: m_toolManager->RunAction( ACTIONS::millimetersUnits ); break;
case EDA_UNITS::INCHES: m_toolManager->RunAction( ACTIONS::inchesUnits ); break;
case EDA_UNITS::MILS: m_toolManager->RunAction( ACTIONS::milsUnits ); break;
}
}
@@ -1296,7 +1295,7 @@ void EDA_DRAW_FRAME::GetUnitPair( EDA_UNITS& aPrimaryUnit, EDA_UNITS& aSecondary
if( cmnTool )
aSecondaryUnits = cmnTool->GetLastMetricUnits();
else
aSecondaryUnits = EDA_UNITS::MM;
aSecondaryUnits = EDA_UNITS::MILLIMETRES;
}
else
{
+3 -6
View File
@@ -39,8 +39,7 @@ EDA_ITEM::EDA_ITEM( EDA_ITEM* parent, KICAD_T idType, bool isSCH_ITEM, bool isBO
m_structType( idType ),
m_flags( 0 ),
m_parent( parent ),
m_forceVisible( false ),
m_isRollover( false )
m_forceVisible( false )
{ }
@@ -49,8 +48,7 @@ EDA_ITEM::EDA_ITEM( KICAD_T idType, bool isSCH_ITEM, bool isBOARD_ITEM ) :
m_structType( idType ),
m_flags( 0 ),
m_parent( nullptr ),
m_forceVisible( false ),
m_isRollover( false )
m_forceVisible( false )
{ }
@@ -60,8 +58,7 @@ EDA_ITEM::EDA_ITEM( const EDA_ITEM& base ) :
m_structType( base.m_structType ),
m_flags( base.m_flags ),
m_parent( base.m_parent ),
m_forceVisible( base.m_forceVisible ),
m_isRollover( false )
m_forceVisible( base.m_forceVisible )
{
SetForcedTransparency( base.GetForcedTransparency() );
}
+24 -143
View File
@@ -1416,122 +1416,6 @@ std::vector<VECTOR2I> EDA_SHAPE::GetRectCorners() const
}
std::vector<VECTOR2I> EDA_SHAPE::GetCornersInSequence( EDA_ANGLE angle ) const
{
std::vector<VECTOR2I> pts;
angle.Normalize();
BOX2I bbox = getBoundingBox();
bbox.Normalize();
if( angle.IsCardinal() )
{
if( angle == ANGLE_0 )
{
pts.emplace_back( VECTOR2I( bbox.GetLeft(), bbox.GetTop() ) );
pts.emplace_back( VECTOR2I( bbox.GetRight(), bbox.GetTop() ) );
pts.emplace_back( VECTOR2I( bbox.GetRight(), bbox.GetBottom() ) );
pts.emplace_back( VECTOR2I( bbox.GetLeft(), bbox.GetBottom() ) );
}
else if( angle == ANGLE_90 )
{
pts.emplace_back( VECTOR2I( bbox.GetLeft(), bbox.GetBottom() ) );
pts.emplace_back( VECTOR2I( bbox.GetLeft(), bbox.GetTop() ) );
pts.emplace_back( VECTOR2I( bbox.GetRight(), bbox.GetTop() ) );
pts.emplace_back( VECTOR2I( bbox.GetRight(), bbox.GetBottom() ) );
}
else if( angle == ANGLE_180 )
{
pts.emplace_back( VECTOR2I( bbox.GetRight(), bbox.GetBottom() ) );
pts.emplace_back( VECTOR2I( bbox.GetLeft(), bbox.GetBottom() ) );
pts.emplace_back( VECTOR2I( bbox.GetLeft(), bbox.GetTop() ) );
pts.emplace_back( VECTOR2I( bbox.GetRight(), bbox.GetTop() ) );
}
else if( angle == ANGLE_270 )
{
pts.emplace_back( VECTOR2I( bbox.GetRight(), bbox.GetTop() ) );
pts.emplace_back( VECTOR2I( bbox.GetRight(), bbox.GetBottom() ) );
pts.emplace_back( VECTOR2I( bbox.GetLeft(), bbox.GetBottom() ) );
pts.emplace_back( VECTOR2I( bbox.GetLeft(), bbox.GetTop() ) );
}
}
else
{
// This function was originally located in pcb_textbox.cpp and was later moved to eda_shape.cpp.
// As a result of this move, access to getCorners was lost, since it is defined in the PCB_SHAPE
// class within pcb_shape.cpp and is not available in the current context.
//
// Additionally, GetRectCorners() cannot be used here, as it assumes the rectangle is rotated by
// a cardinal angle. In non-cardinal cases, it returns incorrect values (e.g., (0, 0)).
//
// To address this, a portion of the getCorners implementation for SHAPE_T::POLY elements
// has been replicated here to restore the correct behavior.
std::vector<VECTOR2I> corners;
for( int ii = 0; ii < GetPolyShape().OutlineCount(); ++ii )
{
for( const VECTOR2I& pt : GetPolyShape().Outline( ii ).CPoints() )
corners.emplace_back( pt );
}
while( corners.size() < 4 )
corners.emplace_back( corners.back() + VECTOR2I( 10, 10 ) );
VECTOR2I minX = corners[0];
VECTOR2I maxX = corners[0];
VECTOR2I minY = corners[0];
VECTOR2I maxY = corners[0];
for( const VECTOR2I& corner : corners )
{
if( corner.x < minX.x )
minX = corner;
if( corner.x > maxX.x )
maxX = corner;
if( corner.y < minY.y )
minY = corner;
if( corner.y > maxY.y )
maxY = corner;
}
if( angle < ANGLE_90 )
{
pts.emplace_back( minX );
pts.emplace_back( minY );
pts.emplace_back( maxX );
pts.emplace_back( maxY );
}
else if( angle < ANGLE_180 )
{
pts.emplace_back( maxY );
pts.emplace_back( minX );
pts.emplace_back( minY );
pts.emplace_back( maxX );
}
else if( angle < ANGLE_270 )
{
pts.emplace_back( maxX );
pts.emplace_back( maxY );
pts.emplace_back( minX );
pts.emplace_back( minY );
}
else
{
pts.emplace_back( minY );
pts.emplace_back( maxX );
pts.emplace_back( maxY );
pts.emplace_back( minX );
}
}
return pts;
}
void EDA_SHAPE::computeArcBBox( BOX2I& aBBox ) const
{
// Start, end, and each inflection point the arc crosses will enclose the entire arc.
@@ -2022,7 +1906,7 @@ int EDA_SHAPE::Compare( const EDA_SHAPE* aOther ) const
if( m_shape == SHAPE_T::ARC )
{
TEST_PT( GetArcMid(), aOther->GetArcMid() );
TEST_PT( m_arcCenter, aOther->m_arcCenter );
}
else if( m_shape == SHAPE_T::BEZIER )
{
@@ -2336,35 +2220,32 @@ static struct EDA_SHAPE_DESC
PROPERTY_MANAGER& propMgr = PROPERTY_MANAGER::Instance();
REGISTER_TYPE( EDA_SHAPE );
auto isNotPolygonOrCircle =
[]( INSPECTABLE* aItem ) -> bool
{
// Polygons, unlike other shapes, have no meaningful start or end coordinates
if( EDA_SHAPE* shape = dynamic_cast<EDA_SHAPE*>( aItem ) )
return shape->GetShape() != SHAPE_T::POLY && shape->GetShape() != SHAPE_T::CIRCLE;
auto isNotPolygonOrCircle = []( INSPECTABLE* aItem ) -> bool
{
// Polygons, unlike other shapes, have no meaningful start or end coordinates
if( EDA_SHAPE* shape = dynamic_cast<EDA_SHAPE*>( aItem ) )
return shape->GetShape() != SHAPE_T::POLY && shape->GetShape() != SHAPE_T::CIRCLE;
return false;
};
return false;
};
auto isCircle =
[]( INSPECTABLE* aItem ) -> bool
{
// Polygons, unlike other shapes, have no meaningful start or end coordinates
if( EDA_SHAPE* shape = dynamic_cast<EDA_SHAPE*>( aItem ) )
return shape->GetShape() == SHAPE_T::CIRCLE;
auto isCircle = []( INSPECTABLE* aItem ) -> bool
{
// Polygons, unlike other shapes, have no meaningful start or end coordinates
if( EDA_SHAPE* shape = dynamic_cast<EDA_SHAPE*>( aItem ) )
return shape->GetShape() == SHAPE_T::CIRCLE;
return false;
};
return false;
};
auto isRectangle =
[]( INSPECTABLE* aItem ) -> bool
{
// Polygons, unlike other shapes, have no meaningful start or end coordinates
if( EDA_SHAPE* shape = dynamic_cast<EDA_SHAPE*>( aItem ) )
return shape->GetShape() == SHAPE_T::RECTANGLE;
auto isRectangle = []( INSPECTABLE* aItem ) -> bool
{
// Polygons, unlike other shapes, have no meaningful start or end coordinates
if( EDA_SHAPE* shape = dynamic_cast<EDA_SHAPE*>( aItem ) )
return shape->GetShape() == SHAPE_T::RECTANGLE;
return false;
};
return false;
};
const wxString shapeProps = _HKI( "Shape Properties" );
@@ -2415,13 +2296,13 @@ static struct EDA_SHAPE_DESC
propMgr.AddProperty( new PROPERTY<EDA_SHAPE, int>( _HKI( "Width" ),
&EDA_SHAPE::SetRectangleWidth, &EDA_SHAPE::GetRectangleWidth,
PROPERTY_DISPLAY::PT_SIZE, ORIGIN_TRANSFORMS::NOT_A_COORD ),
PROPERTY_DISPLAY::PT_COORD, ORIGIN_TRANSFORMS::ABS_Y_COORD ),
shapeProps )
.SetAvailableFunc( isRectangle );
propMgr.AddProperty( new PROPERTY<EDA_SHAPE, int>( _HKI( "Height" ),
&EDA_SHAPE::SetRectangleHeight, &EDA_SHAPE::GetRectangleHeight,
PROPERTY_DISPLAY::PT_SIZE, ORIGIN_TRANSFORMS::NOT_A_COORD ),
PROPERTY_DISPLAY::PT_COORD, ORIGIN_TRANSFORMS::ABS_Y_COORD ),
shapeProps )
.SetAvailableFunc( isRectangle );
+14 -22
View File
@@ -48,7 +48,7 @@
#include <font/outline_font.h>
#include <geometry/shape_poly_set.h>
#include <properties/property_validators.h>
#include <ctl_flags.h>
#include <ctl_flags.h> // for CTL_OMIT_HIDE definition
#include <api/api_enums.h>
#include <api/api_utils.h>
#include <api/common/types/base_types.pb.h>
@@ -93,10 +93,9 @@ GR_TEXT_V_ALIGN_T EDA_TEXT::MapVertJustify( int aVertJustify )
EDA_TEXT::EDA_TEXT( const EDA_IU_SCALE& aIuScale, const wxString& aText ) :
m_IuScale( aIuScale ),
m_text( aText ),
m_render_cache_font( nullptr ),
m_visible( true )
m_IuScale( aIuScale ),
m_render_cache_font( nullptr )
{
SetTextSize( VECTOR2I( EDA_UNIT_UTILS::Mils2IU( m_IuScale, DEFAULT_SIZE_TEXT ),
EDA_UNIT_UTILS::Mils2IU( m_IuScale, DEFAULT_SIZE_TEXT ) ) );
@@ -123,7 +122,6 @@ EDA_TEXT::EDA_TEXT( const EDA_TEXT& aText ) :
m_attributes = aText.m_attributes;
m_pos = aText.m_pos;
m_visible = aText.m_visible;
m_render_cache_font = aText.m_render_cache_font;
m_render_cache_text = aText.m_render_cache_text;
@@ -159,7 +157,6 @@ EDA_TEXT& EDA_TEXT::operator=( const EDA_TEXT& aText )
m_attributes = aText.m_attributes;
m_pos = aText.m_pos;
m_visible = aText.m_visible;
m_render_cache_font = aText.m_render_cache_font;
m_render_cache_text = aText.m_render_cache_text;
@@ -210,7 +207,7 @@ void EDA_TEXT::Serialize( google::protobuf::Any &aContainer ) const
attrs->set_italic( IsItalic() );
attrs->set_bold( IsBold() );
attrs->set_underlined( GetAttributes().m_Underlined );
attrs->set_visible( true );
attrs->set_visible( IsVisible() );
attrs->set_mirrored( IsMirrored() );
attrs->set_multiline( IsMultilineAllowed() );
attrs->set_keep_upright( IsKeepUpright() );
@@ -239,6 +236,7 @@ bool EDA_TEXT::Deserialize( const google::protobuf::Any &aContainer )
attrs.m_Bold = text.attributes().bold();
attrs.m_Italic = text.attributes().italic();
attrs.m_Underlined = text.attributes().underlined();
attrs.m_Visible = text.attributes().visible();
attrs.m_Mirrored = text.attributes().mirrored();
attrs.m_Multiline = text.attributes().multiline();
attrs.m_KeepUpright = text.attributes().keep_upright();
@@ -378,7 +376,7 @@ void EDA_TEXT::SetBoldFlag( bool aBold )
void EDA_TEXT::SetVisible( bool aVisible )
{
m_visible = aVisible;
m_attributes.m_Visible = aVisible;
ClearRenderCache();
}
@@ -1038,7 +1036,8 @@ void EDA_TEXT::SetFontIndex( int aIdx )
bool EDA_TEXT::IsDefaultFormatting() const
{
return ( !IsMirrored()
return ( IsVisible()
&& !IsMirrored()
&& GetHorizJustify() == GR_TEXT_H_ALIGN_CENTER
&& GetVertJustify() == GR_TEXT_V_ALIGN_CENTER
&& GetTextThickness() == 0
@@ -1110,8 +1109,13 @@ void EDA_TEXT::Format( OUTPUTFORMATTER* aFormatter, int aControlBits ) const
aFormatter->Print( ")" ); // (justify
}
if( !( aControlBits & CTL_OMIT_HIDE ) && !IsVisible() )
KICAD_FORMAT::FormatBool( aFormatter, "hide", true );
if( !( aControlBits & CTL_OMIT_HYPERLINK ) && HasHyperlink() )
{
aFormatter->Print( "(href %s)", aFormatter->Quotew( GetHyperlink() ).c_str() );
}
aFormatter->Print( ")" ); // (effects
}
@@ -1371,21 +1375,9 @@ static struct EDA_TEXT_DESC
propMgr.AddProperty( new PROPERTY<EDA_TEXT, bool>( _HKI( "Mirrored" ),
&EDA_TEXT::SetMirrored, &EDA_TEXT::IsMirrored ),
textProps );
auto isField =
[]( INSPECTABLE* aItem ) -> bool
{
if( EDA_ITEM* item = dynamic_cast<EDA_ITEM*>( aItem ) )
return item->Type() == SCH_FIELD_T || item->Type() == PCB_FIELD_T;
return false;
};
propMgr.AddProperty( new PROPERTY<EDA_TEXT, bool>( _HKI( "Visible" ),
&EDA_TEXT::SetVisible, &EDA_TEXT::IsVisible ),
textProps )
.SetAvailableFunc( isField );
textProps );
propMgr.AddProperty( new PROPERTY<EDA_TEXT, int>( _HKI( "Width" ),
&EDA_TEXT::SetTextWidth, &EDA_TEXT::GetTextWidth,
PROPERTY_DISPLAY::PT_SIZE ),
+105 -49
View File
@@ -48,7 +48,7 @@ bool EDA_UNIT_UTILS::IsImperialUnit( EDA_UNITS aUnit )
{
switch( aUnit )
{
case EDA_UNITS::INCH:
case EDA_UNITS::INCHES:
case EDA_UNITS::MILS:
return true;
@@ -62,9 +62,9 @@ bool EDA_UNIT_UTILS::IsMetricUnit( EDA_UNITS aUnit )
{
switch( aUnit )
{
case EDA_UNITS::UM:
case EDA_UNITS::MM:
case EDA_UNITS::CM:
case EDA_UNITS::MICROMETRES:
case EDA_UNITS::MILLIMETRES:
case EDA_UNITS::CENTIMETRES:
return true;
default:
@@ -106,15 +106,15 @@ bool EDA_UNIT_UTILS::FetchUnitsFromString( const wxString& aTextValue, EDA_UNITS
//check for um, μm (µ is MICRO SIGN) and µm (µ is GREEK SMALL LETTER MU) for micrometre
if( unit == wxT( "um" ) || unit == wxT( "\u00B5m" ) || unit == wxT( "\u03BCm" ) )
aUnits = EDA_UNITS::UM;
aUnits = EDA_UNITS::MICROMETRES;
else if( unit == wxT( "mm" ) )
aUnits = EDA_UNITS::MM;
aUnits = EDA_UNITS::MILLIMETRES;
if( unit == wxT( "cm" ) )
aUnits = EDA_UNITS::CM;
aUnits = EDA_UNITS::CENTIMETRES;
else if( unit == wxT( "mi" ) || unit == wxT( "th" ) ) // "mils" or "thou"
aUnits = EDA_UNITS::MILS;
else if( unit == wxT( "in" ) || unit == wxT( "\"" ) )
aUnits = EDA_UNITS::INCH;
aUnits = EDA_UNITS::INCHES;
else if( unit == wxT( "de" ) || unit == wxT( "ra" ) ) // "deg" or "rad"
aUnits = EDA_UNITS::DEGREES;
else
@@ -130,15 +130,15 @@ wxString EDA_UNIT_UTILS::GetText( EDA_UNITS aUnits, EDA_DATA_TYPE aType )
switch( aUnits )
{
case EDA_UNITS::UM: label = wxT( " \u00B5m" ); break; //00B5 for µ
case EDA_UNITS::MM: label = wxT( " mm" ); break;
case EDA_UNITS::CM: label = wxT( " cm" ); break;
case EDA_UNITS::DEGREES: label = wxT( "°" ); break;
case EDA_UNITS::MILS: label = wxT( " mils" ); break;
case EDA_UNITS::INCH: label = wxT( " in" ); break;
case EDA_UNITS::PERCENT: label = wxT( "%" ); break;
case EDA_UNITS::UNSCALED: break;
default: UNIMPLEMENTED_FOR( wxS( "Unknown units" ) ); break;
case EDA_UNITS::MICROMETRES: label = wxT( " \u00B5m" ); break; //00B5 for µ
case EDA_UNITS::MILLIMETRES: label = wxT( " mm" ); break;
case EDA_UNITS::CENTIMETRES: label = wxT( " cm" ); break;
case EDA_UNITS::DEGREES: label = wxT( "°" ); break;
case EDA_UNITS::MILS: label = wxT( " mils" ); break;
case EDA_UNITS::INCHES: label = wxT( " in" ); break;
case EDA_UNITS::PERCENT: label = wxT( "%" ); break;
case EDA_UNITS::UNSCALED: break;
default: UNIMPLEMENTED_FOR( wxS( "Unknown units" ) ); break;
}
switch( aType )
@@ -263,13 +263,26 @@ double EDA_UNIT_UTILS::UI::ToUserUnit( const EDA_IU_SCALE& aIuScale, EDA_UNITS a
{
switch( aUnit )
{
case EDA_UNITS::UM: return IU_TO_MM( aValue, aIuScale ) * 1000;
case EDA_UNITS::MM: return IU_TO_MM( aValue, aIuScale );
case EDA_UNITS::CM: return IU_TO_MM( aValue, aIuScale ) / 10;
case EDA_UNITS::MILS: return IU_TO_MILS( aValue, aIuScale );
case EDA_UNITS::INCH: return IU_TO_IN( aValue, aIuScale );
case EDA_UNITS::DEGREES: return aValue;
default: return aValue;
case EDA_UNITS::MICROMETRES:
return IU_TO_MM( aValue, aIuScale ) * 1000;
case EDA_UNITS::MILLIMETRES:
return IU_TO_MM( aValue, aIuScale );
case EDA_UNITS::CENTIMETRES:
return IU_TO_MM( aValue, aIuScale ) / 10;
case EDA_UNITS::MILS:
return IU_TO_MILS( aValue, aIuScale );
case EDA_UNITS::INCHES:
return IU_TO_IN( aValue, aIuScale );
case EDA_UNITS::DEGREES:
return aValue;
default:
return aValue;
}
}
@@ -304,10 +317,21 @@ wxString EDA_UNIT_UTILS::UI::StringFromValue( const EDA_IU_SCALE& aIuScale, EDA_
switch( aUnits )
{
case EDA_UNITS::MILS: format = is_eeschema ? wxT( "%.3f" ) : wxT( "%.5f" ); break;
case EDA_UNITS::INCH: format = is_eeschema ? wxT( "%.6f" ) : wxT( "%.8f" ); break;
case EDA_UNITS::DEGREES: format = wxT( "%.4f" ); break;
default: format = wxT( "%.10f" ); break;
case EDA_UNITS::MILS:
format = is_eeschema ? wxT( "%.3f" ) : wxT( "%.5f" );
break;
case EDA_UNITS::INCHES:
format = is_eeschema ? wxT( "%.6f" ) : wxT( "%.8f" );
break;
case EDA_UNITS::DEGREES:
format = wxT( "%.4f" );
break;
default:
format = wxT( "%.10f" );
break;
}
wxString text;
@@ -390,13 +414,34 @@ wxString EDA_UNIT_UTILS::UI::MessageTextFromValue( const EDA_IU_SCALE& aIuScale,
switch( aUnits )
{
default:
case EDA_UNITS::UM: format = is_eeschema ? wxT( "%.0f" ) : wxT( "%.1f" ); break;
case EDA_UNITS::MM: format = is_eeschema ? wxT( "%.2f" ) : wxT( "%.4f" ); break;
case EDA_UNITS::CM: format = is_eeschema ? wxT( "%.3f" ) : wxT( "%.5f" ); break;
case EDA_UNITS::MILS: format = is_eeschema ? wxT( "%.0f" ) : wxT( "%.2f" ); break;
case EDA_UNITS::INCH: format = is_eeschema ? wxT( "%.3f" ) : wxT( "%.4f" ); break;
case EDA_UNITS::DEGREES: format = wxT( "%.3f" ); break;
case EDA_UNITS::UNSCALED: format = wxT( "%.0f" ); break;
case EDA_UNITS::MICROMETRES:
format = is_eeschema ? wxT( "%.0f" ) : wxT( "%.1f" );
break;
case EDA_UNITS::MILLIMETRES:
format = is_eeschema ? wxT( "%.2f" ) : wxT( "%.4f" );
break;
case EDA_UNITS::CENTIMETRES:
format = is_eeschema ? wxT( "%.3f" ) : wxT( "%.5f" );
break;
case EDA_UNITS::MILS:
format = is_eeschema ? wxT( "%.0f" ) : wxT( "%.2f" );
break;
case EDA_UNITS::INCHES:
format = is_eeschema ? wxT( "%.3f" ) : wxT( "%.4f" );
break;
case EDA_UNITS::DEGREES:
// 3 digits in mantissa should be good for rotation in degree
format = wxT( "%.3f" );
break;
case EDA_UNITS::UNSCALED:
format = wxT( "%.0f" );
break;
}
text.Printf( format, value );
@@ -444,15 +489,26 @@ double EDA_UNIT_UTILS::UI::FromUserUnit( const EDA_IU_SCALE& aIuScale, EDA_UNITS
{
switch( aUnits )
{
case EDA_UNITS::UM: return MM_TO_IU( aValue / 1000.0, aIuScale );
case EDA_UNITS::MM: return MM_TO_IU( aValue, aIuScale );
case EDA_UNITS::CM: return MM_TO_IU( aValue * 10, aIuScale );
case EDA_UNITS::MILS: return MILS_TO_IU( aValue, aIuScale );
case EDA_UNITS::INCH: return IN_TO_IU( aValue, aIuScale );
case EDA_UNITS::MICROMETRES:
return MM_TO_IU( aValue / 1000.0, aIuScale );
case EDA_UNITS::MILLIMETRES:
return MM_TO_IU( aValue, aIuScale );
case EDA_UNITS::CENTIMETRES:
return MM_TO_IU( aValue * 10, aIuScale );
case EDA_UNITS::MILS:
return MILS_TO_IU( aValue, aIuScale );
case EDA_UNITS::INCHES:
return IN_TO_IU( aValue, aIuScale );
default:
case EDA_UNITS::DEGREES:
case EDA_UNITS::UNSCALED:
case EDA_UNITS::PERCENT: return aValue;
case EDA_UNITS::PERCENT:
return aValue;
}
}
@@ -528,24 +584,24 @@ double EDA_UNIT_UTILS::UI::DoubleValueFromString( const EDA_IU_SCALE& aIuScale,
// Check the optional unit designator (2 ch significant)
wxString unit( buf.Mid( brk_point ).Strip( wxString::leading ).Left( 2 ).Lower() );
if( aUnits == EDA_UNITS::UM
|| aUnits == EDA_UNITS::MM
|| aUnits == EDA_UNITS::CM
if( aUnits == EDA_UNITS::MICROMETRES
|| aUnits == EDA_UNITS::MILLIMETRES
|| aUnits == EDA_UNITS::CENTIMETRES
|| aUnits == EDA_UNITS::MILS
|| aUnits == EDA_UNITS::INCH )
|| aUnits == EDA_UNITS::INCHES )
{
//check for um, μm (µ is MICRO SIGN) and µm (µ is GREEK SMALL LETTER MU) for micrometre
if( unit == wxT( "um" ) || unit == wxT( "\u00B5m" ) || unit == wxT( "\u03BCm" ) )
{
aUnits = EDA_UNITS::UM;
aUnits = EDA_UNITS::MICROMETRES;
}
else if( unit == wxT( "mm" ) )
{
aUnits = EDA_UNITS::MM;
aUnits = EDA_UNITS::MILLIMETRES;
}
else if( unit == wxT( "cm" ) )
{
aUnits = EDA_UNITS::CM;
aUnits = EDA_UNITS::CENTIMETRES;
}
else if( unit == wxT( "mi" ) || unit == wxT( "th" ) )
{
@@ -553,7 +609,7 @@ double EDA_UNIT_UTILS::UI::DoubleValueFromString( const EDA_IU_SCALE& aIuScale,
}
else if( unit == wxT( "in" ) || unit == wxT( "\"" ) )
{
aUnits = EDA_UNITS::INCH;
aUnits = EDA_UNITS::INCHES;
}
else if( unit == wxT( "oz" ) ) // 1 oz = 1.37 mils
{
+1 -24
View File
@@ -162,13 +162,6 @@ void EMBEDDED_FILES::WriteEmbeddedFiles( OUTPUTFORMATTER& aOut, bool aWriteData
{
const EMBEDDED_FILE& file = *entry;
// Skip empty files
if( file.compressedEncodedData.empty() )
{
wxLogDebug( wxT( "Error: Embedded file '%s' is empty" ), file.name );
continue;
}
aOut.Print( "(file " );
aOut.Print( "(name %s)", aOut.Quotew( file.name ).c_str() );
@@ -383,23 +376,7 @@ void EMBEDDED_FILES_PARSER::ParseEmbedded( EMBEDDED_FILES* aFiles )
break;
case T_data:
try
{
NeedBAR();
}
catch( const PARSE_ERROR& e )
{
// No data in the file -- due to bug in writer for 9.0.0
if( curTok == T_RIGHT )
break;
else
throw e;
}
catch( ... )
{
throw;
}
NeedBAR();
token = NextTok();
file->compressedEncodedData.reserve( 1 << 17 );
+5 -10
View File
@@ -78,7 +78,7 @@ bool FILENAME_RESOLVER::Set3DConfigDir( const wxString& aConfigDir )
}
bool FILENAME_RESOLVER::SetProject( const PROJECT* aProject, bool* flgChanged )
bool FILENAME_RESOLVER::SetProject( PROJECT* aProject, bool* flgChanged )
{
m_project = aProject;
@@ -244,7 +244,7 @@ bool FILENAME_RESOLVER::UpdatePathList( const std::vector< SEARCH_PATH >& aPathL
wxString FILENAME_RESOLVER::ResolvePath( const wxString& aFileName, const wxString& aWorkingPath,
std::vector<const EMBEDDED_FILES*> aEmbeddedFilesStack )
const EMBEDDED_FILES* aFiles )
{
std::lock_guard<std::mutex> lock( mutex_resolver );
@@ -266,20 +266,15 @@ wxString FILENAME_RESOLVER::ResolvePath( const wxString& aFileName, const wxStri
// Check to see if the file is a URI for an embedded file.
if( tname.StartsWith( FILEEXT::KiCadUriPrefix + "://" ) )
{
if( aEmbeddedFilesStack.empty() )
if( !aFiles )
{
wxLogTrace( wxT( "KICAD_EMBED" ),
wxT( "No EMBEDDED_FILES object provided for kicad_embed URI" ) );
return wxEmptyString;
}
wxString path = tname.Mid( wxString( FILEEXT::KiCadUriPrefix + "://" ).length() );
wxFileName temp_file = aEmbeddedFilesStack[0]->GetTemporaryFileName( path );
int ii = 1;
while( !temp_file.IsOk() && ii < (int) aEmbeddedFilesStack.size() )
temp_file = aEmbeddedFilesStack[ii++]->GetTemporaryFileName( path );
wxString path = tname.Mid( 14 );
wxFileName temp_file = aFiles->GetTemporaryFileName( path );
if( !temp_file.IsOk() )
{
+8 -6
View File
@@ -68,16 +68,18 @@ public:
std::unique_ptr<MARKUP::NODE> root;
};
typedef std::pair<wxString, ENTRY> CACHE_ENTRY;
MARKUP_CACHE( size_t aMaxSize ) :
m_maxSize( aMaxSize )
{
}
ENTRY& Put( const wxString& aQuery, ENTRY&& aResult )
ENTRY& Put( const CACHE_ENTRY::first_type& aQuery, ENTRY&& aResult )
{
auto it = m_cache.find( aQuery );
m_cacheMru.emplace_front( std::make_pair( aQuery, std::move( aResult ) ) );
m_cacheMru.emplace_front( CACHE_ENTRY( aQuery, std::move( aResult ) ) );
if( it != m_cache.end() )
{
@@ -98,7 +100,7 @@ public:
return m_cacheMru.begin()->second;
}
ENTRY* Get( const wxString& aQuery )
ENTRY* Get( const CACHE_ENTRY::first_type& aQuery )
{
auto it = m_cache.find( aQuery );
@@ -117,9 +119,9 @@ public:
}
private:
size_t m_maxSize;
std::list<std::pair<wxString, ENTRY>> m_cacheMru;
std::unordered_map<wxString, std::list<std::pair<wxString, ENTRY>>::iterator> m_cache;
size_t m_maxSize;
std::list<CACHE_ENTRY> m_cacheMru;
std::unordered_map<wxString, std::list<CACHE_ENTRY>::iterator> m_cache;
};
+5
View File
@@ -32,6 +32,7 @@ TEXT_ATTRIBUTES::TEXT_ATTRIBUTES( KIFONT::FONT* aFont ) :
m_Bold( false ),
m_Underlined( false ),
m_Color( KIGFX::COLOR4D::UNSPECIFIED ),
m_Visible( true ),
m_Mirrored( false ),
m_Multiline( true ),
m_KeepUpright( false ),
@@ -92,6 +93,9 @@ int TEXT_ATTRIBUTES::Compare( const TEXT_ATTRIBUTES& aRhs ) const
if( retv )
return retv;
if( m_Visible != aRhs.m_Visible )
return m_Visible - aRhs.m_Visible;
if( m_Mirrored != aRhs.m_Mirrored )
return m_Mirrored - aRhs.m_Mirrored;
@@ -121,6 +125,7 @@ std::ostream& operator<<( std::ostream& aStream, const TEXT_ATTRIBUTES& aAttribu
<< "Bold: " << aAttributes.m_Bold << std::endl
<< "Underline: " << aAttributes.m_Underlined << std::endl
<< "Color: " << aAttributes.m_Color << std::endl
<< "Visible " << aAttributes.m_Visible << std::endl
<< "Mirrored " << aAttributes.m_Mirrored << std::endl
<< "Multilined: " << aAttributes.m_Multiline << std::endl
<< "Size: " << aAttributes.m_Size << std::endl
-2
View File
@@ -74,9 +74,7 @@ std::vector<SEARCH_TERM> FOOTPRINT_INFO::GetSearchTerms()
{
std::vector<SEARCH_TERM> terms;
terms.emplace_back( SEARCH_TERM( GetLibNickname(), 4 ) );
terms.emplace_back( SEARCH_TERM( GetName(), 8 ) );
terms.emplace_back( SEARCH_TERM( GetLIB_ID().Format(), 16 ) );
wxStringTokenizer keywordTokenizer( GetKeywords(), wxS( " " ), wxTOKEN_STRTOK );
+1 -1
View File
@@ -24,7 +24,7 @@
*/
#include <map>
#include <json_common.h>
#include <nlohmann/json.hpp>
#include <gal/color4d.h>
#include <i18n_utility.h>
#include <wx/crt.h>
+6 -5
View File
@@ -22,7 +22,6 @@
*/
#include "git_add_to_index_handler.h"
#include <git/kicad_git_memory.h>
#include <iterator>
@@ -54,14 +53,15 @@ bool GIT_ADD_TO_INDEX_HANDLER::AddToIndex( const wxString& aFilePath )
return false;
}
KIGIT::GitIndexPtr indexPtr( index );
if( git_index_find( &at_pos, index, aFilePath.ToUTF8().data() ) == GIT_OK )
{
git_index_free( index );
wxLogError( "%s already in index", aFilePath );
return false;
}
git_index_free( index );
// Add file to index if not already there
m_filesToAdd.push_back( aFilePath );
@@ -82,8 +82,6 @@ bool GIT_ADD_TO_INDEX_HANDLER::PerformAddToIndex()
return false;
}
KIGIT::GitIndexPtr indexPtr( index );
for( auto& file : m_filesToAdd )
{
if( git_index_add_bypath( index, file.ToUTF8().data() ) != 0 )
@@ -101,8 +99,11 @@ bool GIT_ADD_TO_INDEX_HANDLER::PerformAddToIndex()
m_filesFailedToAdd.clear();
std::copy( m_filesToAdd.begin(), m_filesToAdd.end(),
std::back_inserter( m_filesFailedToAdd ) );
git_index_free( index );
return false;
}
git_index_free( index );
return true;
}
+8 -20
View File
@@ -24,31 +24,23 @@
#include "git_clone_handler.h"
#include <git/kicad_git_common.h>
#include <git/kicad_git_memory.h>
#include <trace_helpers.h>
#include <git2.h>
#include <wx/filename.h>
#include <wx/log.h>
GIT_CLONE_HANDLER::GIT_CLONE_HANDLER( KIGIT_COMMON* aCommon ) : KIGIT_REPO_MIXIN( aCommon )
GIT_CLONE_HANDLER::GIT_CLONE_HANDLER() : KIGIT_COMMON( nullptr )
{}
GIT_CLONE_HANDLER::~GIT_CLONE_HANDLER()
{}
{
if( m_repo )
git_repository_free( m_repo );
}
bool GIT_CLONE_HANDLER::PerformClone()
{
std::unique_lock<std::mutex> lock( GetCommon()->m_gitActionMutex, std::try_to_lock );
if( !lock.owns_lock() )
{
wxLogTrace( traceGit, "GIT_CLONE_HANDLER::PerformClone() could not lock" );
return false;
}
wxFileName clonePath( m_clonePath );
if( !clonePath.DirExists() )
@@ -70,20 +62,16 @@ bool GIT_CLONE_HANDLER::PerformClone()
cloneOptions.fetch_opts.callbacks.credentials = credentials_cb;
cloneOptions.fetch_opts.callbacks.payload = this;
TestedTypes() = 0;
m_testedTypes = 0;
ResetNextKey();
git_repository* newRepo = nullptr;
wxString remote = GetCommon()->m_remote;
if( git_clone( &newRepo, remote.mbc_str(), m_clonePath.mbc_str(),
if( git_clone( &m_repo, m_URL.ToStdString().c_str(), m_clonePath.ToStdString().c_str(),
&cloneOptions ) != 0 )
{
AddErrorString( wxString::Format( _( "Could not clone repository '%s'" ), remote ) );
AddErrorString( wxString::Format( _( "Could not clone repository '%s'" ), m_URL ) );
return false;
}
GetCommon()->SetRepo( newRepo );
if( m_progressReporter )
m_progressReporter->Hide();
+8 -7
View File
@@ -24,29 +24,30 @@
#ifndef GIT_CLONE_HANDLER_H_
#define GIT_CLONE_HANDLER_H_
#include "kicad_git_common.h"
#include "git_repo_mixin.h"
#include "git_progress.h"
#include <git/kicad_git_common.h>
#include <git/git_progress.h>
class GIT_CLONE_HANDLER : public KIGIT_REPO_MIXIN
class GIT_CLONE_HANDLER : public KIGIT_COMMON, public GIT_PROGRESS
{
public:
GIT_CLONE_HANDLER( KIGIT_COMMON* aCommon );
GIT_CLONE_HANDLER();
~GIT_CLONE_HANDLER();
bool PerformClone();
void SetURL( const wxString& aURL ) { m_URL = aURL; }
wxString GetURL() const { return m_URL; }
void SetBranch( const wxString& aBranch ) { m_branch = aBranch; }
wxString GetBranch() const { return m_branch; }
void SetClonePath( const wxString& aPath ) { m_clonePath = aPath; }
wxString GetClonePath() const { return m_clonePath; }
void SetRemote( const wxString& aRemote ) { GetCommon()->m_remote = aRemote; }
void UpdateProgress( int aCurrent, int aTotal, const wxString& aMessage ) override;
private:
wxString m_URL;
wxString m_branch;
wxString m_clonePath;
};
-2
View File
@@ -62,8 +62,6 @@ public:
}
}
virtual void UpdateProgress( int aCurrent, int aTotal, const wxString& aMessage ) {};
protected:
int m_previousProgress;
+114 -311
View File
@@ -23,53 +23,31 @@
#include "git_pull_handler.h"
#include <git/kicad_git_common.h>
#include <git/kicad_git_memory.h>
#include <trace_helpers.h>
#include <wx/log.h>
#include <iostream>
#include <time.h>
#include <memory>
GIT_PULL_HANDLER::GIT_PULL_HANDLER( KIGIT_COMMON* aCommon ) : KIGIT_REPO_MIXIN( aCommon )
{
}
GIT_PULL_HANDLER::GIT_PULL_HANDLER( KIGIT_COMMON* aRepo ) : KIGIT_COMMON( *aRepo )
{}
GIT_PULL_HANDLER::~GIT_PULL_HANDLER()
{}
bool GIT_PULL_HANDLER::PerformFetch()
{
}
bool GIT_PULL_HANDLER::PerformFetch( bool aSkipLock )
{
if( !GetRepo() )
{
wxLogTrace( traceGit, "GIT_PULL_HANDLER::PerformFetch() - No repository found" );
return false;
}
std::unique_lock<std::mutex> lock( GetCommon()->m_gitActionMutex, std::try_to_lock );
if( !aSkipLock && !lock.owns_lock() )
{
wxLogTrace( traceGit, "GIT_PULL_HANDLER::PerformFetch() - Could not lock mutex" );
return false;
}
// Fetch updates from remote repository
// Fetch updates from remote repository
git_remote* remote = nullptr;
if( git_remote_lookup( &remote, GetRepo(), "origin" ) != 0 )
if( git_remote_lookup( &remote, m_repo, "origin" ) != 0 )
{
wxLogTrace( traceGit, "GIT_PULL_HANDLER::PerformFetch() - Failed to lookup remote 'origin'" );
AddErrorString( wxString::Format( _( "Could not lookup remote '%s'" ), "origin" ) );
return false;
}
KIGIT::GitRemotePtr remotePtr( remote );
git_remote_callbacks remoteCallbacks;
git_remote_init_callbacks( &remoteCallbacks, GIT_REMOTE_CALLBACKS_VERSION );
remoteCallbacks.sideband_progress = progress_cb;
@@ -77,14 +55,14 @@ bool GIT_PULL_HANDLER::PerformFetch( bool aSkipLock )
remoteCallbacks.credentials = credentials_cb;
remoteCallbacks.payload = this;
TestedTypes() = 0;
m_testedTypes = 0;
ResetNextKey();
if( git_remote_connect( remote, GIT_DIRECTION_FETCH, &remoteCallbacks, nullptr, nullptr ) )
{
wxString errorMsg = KIGIT_COMMON::GetLastGitError();
wxLogTrace( traceGit, "GIT_PULL_HANDLER::PerformFetch() - Failed to connect to remote: %s", errorMsg );
AddErrorString( wxString::Format( _( "Could not connect to remote '%s': %s" ), "origin", errorMsg ) );
git_remote_free( remote );
AddErrorString( wxString::Format( _( "Could not connect to remote '%s': %s" ), "origin",
git_error_last()->message ) );
return false;
}
@@ -94,35 +72,28 @@ bool GIT_PULL_HANDLER::PerformFetch( bool aSkipLock )
if( git_remote_fetch( remote, nullptr, &fetchOptions, nullptr ) )
{
wxString errorMsg = KIGIT_COMMON::GetLastGitError();
wxLogTrace( traceGit, "GIT_PULL_HANDLER::PerformFetch() - Failed to fetch from remote: %s", errorMsg );
AddErrorString( wxString::Format( _( "Could not fetch data from remote '%s': %s" ), "origin", errorMsg ) );
git_remote_free( remote );
AddErrorString( wxString::Format( _( "Could not fetch data from remote '%s': %s" ),
"origin", git_error_last()->message ) );
return false;
}
wxLogTrace( traceGit, "GIT_PULL_HANDLER::PerformFetch() - Fetch completed successfully" );
git_remote_free( remote );
return true;
}
PullResult GIT_PULL_HANDLER::PerformPull()
{
PullResult result = PullResult::Success;
std::unique_lock<std::mutex> lock( GetCommon()->m_gitActionMutex, std::try_to_lock );
PullResult result = PullResult::Success;
if( !lock.owns_lock() )
{
wxLogTrace( traceGit, "GIT_PULL_HANDLER::PerformPull() - Could not lock mutex" );
return PullResult::Error;
}
if( !PerformFetch( true ) )
if( !PerformFetch() )
return PullResult::Error;
git_oid pull_merge_oid = {};
if( git_repository_fetchhead_foreach( GetRepo(), fetchhead_foreach_cb,
&pull_merge_oid ) )
if( git_repository_fetchhead_foreach( m_repo, fetchhead_foreach_cb, &pull_merge_oid ) )
{
AddErrorString( _( "Could not read 'FETCH_HEAD'" ) );
return PullResult::Error;
@@ -130,23 +101,26 @@ PullResult GIT_PULL_HANDLER::PerformPull()
git_annotated_commit* fetchhead_commit;
if( git_annotated_commit_lookup( &fetchhead_commit, GetRepo(), &pull_merge_oid ) )
if( git_annotated_commit_lookup( &fetchhead_commit, m_repo, &pull_merge_oid ) )
{
AddErrorString( _( "Could not lookup commit" ) );
return PullResult::Error;
}
KIGIT::GitAnnotatedCommitPtr fetchheadCommitPtr( fetchhead_commit );
const git_annotated_commit* merge_commits[] = { fetchhead_commit };
git_merge_analysis_t merge_analysis;
git_merge_preference_t merge_preference = GIT_MERGE_PREFERENCE_NONE;
const git_annotated_commit* merge_commits[] = { fetchhead_commit };
git_merge_analysis_t merge_analysis;
git_merge_preference_t merge_preference = GIT_MERGE_PREFERENCE_NONE;
if( git_merge_analysis( &merge_analysis, &merge_preference, GetRepo(), merge_commits, 1 ) )
if( git_merge_analysis( &merge_analysis, &merge_preference, m_repo, merge_commits, 1 ) )
{
AddErrorString( _( "Could not analyze merge" ) );
git_annotated_commit_free( fetchhead_commit );
return PullResult::Error;
}
if( !( merge_analysis & GIT_MERGE_ANALYSIS_NORMAL ) )
git_annotated_commit_free( fetchhead_commit );
if( merge_analysis & GIT_MERGE_ANALYSIS_UNBORN )
{
AddErrorString( _( "Invalid HEAD. Cannot merge." ) );
@@ -156,27 +130,23 @@ PullResult GIT_PULL_HANDLER::PerformPull()
// Nothing to do if the repository is up to date
if( merge_analysis & GIT_MERGE_ANALYSIS_UP_TO_DATE )
{
wxLogTrace( traceGit, "GIT_PULL_HANDLER::PerformPull() - Repository is up to date" );
git_repository_state_cleanup( GetRepo() );
git_repository_state_cleanup( m_repo );
return PullResult::UpToDate;
}
// Fast-forward is easy, just update the local reference
if( merge_analysis & GIT_MERGE_ANALYSIS_FASTFORWARD )
{
wxLogTrace( traceGit, "GIT_PULL_HANDLER::PerformPull() - Fast-forward merge" );
return handleFastForward();
}
if( merge_analysis & GIT_MERGE_ANALYSIS_NORMAL )
{
wxLogTrace( traceGit, "GIT_PULL_HANDLER::PerformPull() - Normal merge" );
PullResult ret = handleRebase( merge_commits, 1 );
// PullResult ret = handleMerge( merge_commits, 1 );
PullResult ret = handleMerge( merge_commits, 1 );
git_annotated_commit_free( fetchhead_commit );
return ret;
}
wxLogTrace( traceGit, "GIT_PULL_HANDLER::PerformPull() - Merge needs resolution" );
//TODO: handle merges when they need to be resolved
return result;
@@ -191,9 +161,6 @@ GIT_PULL_HANDLER::GetFetchResults() const
std::string GIT_PULL_HANDLER::getFirstLineFromCommitMessage( const std::string& aMessage )
{
if( aMessage.empty() )
return aMessage;
size_t firstLineEnd = aMessage.find_first_of( '\n' );
if( firstLineEnd != std::string::npos )
@@ -205,180 +172,101 @@ std::string GIT_PULL_HANDLER::getFirstLineFromCommitMessage( const std::string&
std::string GIT_PULL_HANDLER::getFormattedCommitDate( const git_time& aTime )
{
char dateBuffer[64];
char dateBuffer[64];
time_t time = static_cast<time_t>( aTime.time );
struct tm timeInfo;
#ifdef _WIN32
localtime_s( &timeInfo, &time );
#else
gmtime_r( &time, &timeInfo );
#endif
strftime( dateBuffer, sizeof( dateBuffer ), "%Y-%b-%d %H:%M:%S", &timeInfo );
strftime( dateBuffer, sizeof( dateBuffer ), "%Y-%b-%d %H:%M:%S", gmtime( &time ) );
return dateBuffer;
}
PullResult GIT_PULL_HANDLER::handleFastForward()
{
git_reference* rawRef = nullptr;
// Update local references with fetched data
auto git_reference_deleter =
[]( void* p )
{
git_reference_free( static_cast<git_reference*>( p ) );
};
// Get the current HEAD reference
if( git_repository_head( &rawRef, GetRepo() ) )
{
AddErrorString( _( "Could not get repository head" ) );
return PullResult::Error;
}
git_reference* rawRef = nullptr;
KIGIT::GitReferencePtr headRef( rawRef );
git_oid updatedRefOid;
const char* currentBranchName = git_reference_name( rawRef );
wxString remoteBranchName = wxString::Format( "refs/remotes/origin/%s",
currentBranchName + strlen( "refs/heads/" ) );
// Get the OID of the updated reference (remote-tracking branch)
if( git_reference_name_to_id( &updatedRefOid, GetRepo(), remoteBranchName.c_str() ) != GIT_OK )
{
AddErrorString( wxString::Format( _( "Could not get reference OID for reference '%s'" ),
remoteBranchName ) );
return PullResult::Error;
}
// Get the target commit object
git_commit* targetCommit = nullptr;
if( git_commit_lookup( &targetCommit, GetRepo(), &updatedRefOid ) != GIT_OK )
{
AddErrorString( _( "Could not look up target commit" ) );
return PullResult::Error;
}
KIGIT::GitCommitPtr targetCommitPtr( targetCommit );
// Get the tree from the target commit
git_tree* targetTree = nullptr;
if( git_commit_tree( &targetTree, targetCommit ) != GIT_OK )
{
git_commit_free( targetCommit );
AddErrorString( _( "Could not get tree from target commit" ) );
return PullResult::Error;
}
KIGIT::GitTreePtr targetTreePtr( targetTree );
// Perform a checkout to update the working directory
git_checkout_options checkoutOptions;
git_checkout_init_options( &checkoutOptions, GIT_CHECKOUT_OPTIONS_VERSION );
auto notify_cb = []( git_checkout_notify_t why, const char* path, const git_diff_file* baseline,
const git_diff_file* target, const git_diff_file* workdir, void* payload ) -> int
{
switch( why )
if( git_repository_head( &rawRef, m_repo ) )
{
case GIT_CHECKOUT_NOTIFY_CONFLICT:
wxLogTrace( traceGit, "Checkout conflict: %s", path ? path : "unknown" );
break;
case GIT_CHECKOUT_NOTIFY_DIRTY:
wxLogTrace( traceGit, "Checkout dirty: %s", path ? path : "unknown" );
break;
case GIT_CHECKOUT_NOTIFY_UPDATED:
wxLogTrace( traceGit, "Checkout updated: %s", path ? path : "unknown" );
break;
case GIT_CHECKOUT_NOTIFY_UNTRACKED:
wxLogTrace( traceGit, "Checkout untracked: %s", path ? path : "unknown" );
break;
case GIT_CHECKOUT_NOTIFY_IGNORED:
wxLogTrace( traceGit, "Checkout ignored: %s", path ? path : "unknown" );
break;
default:
break;
}
return 0;
};
checkoutOptions.checkout_strategy = GIT_CHECKOUT_SAFE | GIT_CHECKOUT_ALLOW_CONFLICTS;
checkoutOptions.notify_flags = GIT_CHECKOUT_NOTIFY_ALL;
checkoutOptions.notify_cb = notify_cb;
if( git_checkout_tree( GetRepo(), reinterpret_cast<git_object*>( targetTree ), &checkoutOptions ) != GIT_OK )
{
AddErrorString( _( "Failed to perform checkout operation." ) );
return PullResult::Error;
}
git_reference* updatedRef = nullptr;
// Update the current branch to point to the new commit
if (git_reference_set_target(&updatedRef, rawRef, &updatedRefOid, nullptr) != GIT_OK)
{
AddErrorString( wxString::Format( _( "Failed to update reference '%s' to point to '%s'" ), currentBranchName,
git_oid_tostr_s( &updatedRefOid ) ) );
return PullResult::Error;
}
KIGIT::GitReferencePtr updatedRefPtr( updatedRef );
// Clean up the repository state
if( git_repository_state_cleanup( GetRepo() ) != GIT_OK )
{
AddErrorString( _( "Failed to clean up repository state after fast-forward." ) );
return PullResult::Error;
}
git_revwalk* revWalker = nullptr;
// Collect commit details for updated references
if( git_revwalk_new( &revWalker, GetRepo() ) != GIT_OK )
{
AddErrorString( _( "Failed to initialize revision walker." ) );
return PullResult::Error;
}
KIGIT::GitRevWalkPtr revWalkerPtr( revWalker );
git_revwalk_sorting( revWalker, GIT_SORT_TIME );
if( git_revwalk_push_glob( revWalker, currentBranchName ) != GIT_OK )
{
AddErrorString( _( "Failed to push reference to revision walker." ) );
return PullResult::Error;
}
std::pair<std::string, std::vector<CommitDetails>>& branchCommits = m_fetchResults.emplace_back();
branchCommits.first = currentBranchName;
git_oid commitOid;
while( git_revwalk_next( &commitOid, revWalker ) == GIT_OK )
{
git_commit* commit = nullptr;
if( git_commit_lookup( &commit, GetRepo(), &commitOid ) )
{
AddErrorString( wxString::Format( _( "Could not lookup commit '%s'" ),
git_oid_tostr_s( &commitOid ) ) );
AddErrorString( _( "Could not get repository head" ) );
return PullResult::Error;
}
KIGIT::GitCommitPtr commitPtr( commit );
// Defer destruction of the git_reference until this function exits somewhere, since
// updatedRefName etc. just point to memory inside the reference
std::unique_ptr<git_reference, decltype( git_reference_deleter )> updatedRef( rawRef );
CommitDetails details;
details.m_sha = git_oid_tostr_s( &commitOid );
details.m_firstLine = getFirstLineFromCommitMessage( git_commit_message( commit ) );
details.m_author = git_commit_author( commit )->name;
details.m_date = getFormattedCommitDate( git_commit_author( commit )->when );
const char* updatedRefName = git_reference_name( updatedRef.get() );
branchCommits.second.push_back( details );
}
git_oid updatedRefOid;
return PullResult::FastForward;
if( git_reference_name_to_id( &updatedRefOid, m_repo, updatedRefName ) )
{
AddErrorString( wxString::Format( _( "Could not get reference OID for reference '%s'" ),
updatedRefName ) );
return PullResult::Error;
}
git_checkout_options checkoutOptions;
git_checkout_init_options( &checkoutOptions, GIT_CHECKOUT_OPTIONS_VERSION );
checkoutOptions.checkout_strategy = GIT_CHECKOUT_SAFE;
if( git_checkout_head( m_repo, &checkoutOptions ) )
{
AddErrorString( _( "Failed to perform checkout operation." ) );
return PullResult::Error;
}
// Collect commit details for updated references
git_revwalk* revWalker = nullptr;
git_revwalk_new( &revWalker, m_repo );
git_revwalk_sorting( revWalker, GIT_SORT_TIME );
git_revwalk_push_glob( revWalker, updatedRefName );
git_oid commitOid;
while( git_revwalk_next( &commitOid, revWalker ) == 0 )
{
git_commit* commit = nullptr;
if( git_commit_lookup( &commit, m_repo, &commitOid ) )
{
AddErrorString( wxString::Format( _( "Could not lookup commit '{}'" ),
git_oid_tostr_s( &commitOid ) ) );
git_revwalk_free( revWalker );
return PullResult::Error;
}
CommitDetails details;
details.m_sha = git_oid_tostr_s( &commitOid );
details.m_firstLine = getFirstLineFromCommitMessage( git_commit_message( commit ) );
details.m_author = git_commit_author( commit )->name;
details.m_date = getFormattedCommitDate( git_commit_author( commit )->when );
std::pair<std::string, std::vector<CommitDetails>>& branchCommits =
m_fetchResults.emplace_back();
branchCommits.first = updatedRefName;
branchCommits.second.push_back( details );
//TODO: log these to the parent
git_commit_free( commit );
}
git_revwalk_free( revWalker );
git_repository_state_cleanup( m_repo );
return PullResult::FastForward;
}
PullResult GIT_PULL_HANDLER::handleMerge( const git_annotated_commit** aMergeHeads,
size_t aMergeHeadsCount )
{
git_merge_options merge_opts;
git_merge_options merge_opts;
git_merge_options_init( &merge_opts, GIT_MERGE_OPTIONS_VERSION );
git_checkout_options checkout_opts;
@@ -386,7 +274,7 @@ PullResult GIT_PULL_HANDLER::handleMerge( const git_annotated_commit** aMergeHea
checkout_opts.checkout_strategy = GIT_CHECKOUT_SAFE;
if( git_merge( GetRepo(), aMergeHeads, aMergeHeadsCount, &merge_opts, &checkout_opts ) )
if( git_merge( m_repo, aMergeHeads, aMergeHeadsCount, &merge_opts, &checkout_opts ) )
{
AddErrorString( _( "Could not merge commits" ) );
return PullResult::Error;
@@ -395,14 +283,12 @@ PullResult GIT_PULL_HANDLER::handleMerge( const git_annotated_commit** aMergeHea
// Get the repository index
git_index* index = nullptr;
if( git_repository_index( &index, GetRepo() ) )
if( git_repository_index( &index, m_repo ) )
{
AddErrorString( _( "Could not get repository index" ) );
return PullResult::Error;
}
KIGIT::GitIndexPtr indexPtr( index );
// Check for conflicts
git_index_conflict_iterator* conflicts = nullptr;
@@ -412,11 +298,9 @@ PullResult GIT_PULL_HANDLER::handleMerge( const git_annotated_commit** aMergeHea
return PullResult::Error;
}
KIGIT::GitIndexConflictIteratorPtr conflictsPtr( conflicts );
const git_index_entry* ancestor = nullptr;
const git_index_entry* our = nullptr;
const git_index_entry* their = nullptr;
const git_index_entry* ancestor = nullptr;
const git_index_entry* our = nullptr;
const git_index_entry* their = nullptr;
std::vector<ConflictData> conflict_data;
while( git_index_conflict_next( &ancestor, &our, &their, conflicts ) == 0 )
@@ -475,95 +359,14 @@ PullResult GIT_PULL_HANDLER::handleMerge( const git_annotated_commit** aMergeHea
git_index_write( index );
}
git_index_conflict_iterator_free( conflicts );
git_index_free( index );
return conflict_data.empty() ? PullResult::Success : PullResult::MergeFailed;
}
PullResult GIT_PULL_HANDLER::handleRebase( const git_annotated_commit** aMergeHeads, size_t aMergeHeadsCount )
{
// Get the current branch reference
git_reference* head_ref = nullptr;
if( git_repository_head( &head_ref, GetRepo() ) )
{
wxString errorMsg = KIGIT_COMMON::GetLastGitError();
wxLogTrace( traceGit, "GIT_PULL_HANDLER::handleRebase() - Failed to get HEAD: %s", errorMsg );
return PullResult::Error;
}
KIGIT::GitReferencePtr headRefPtr(head_ref);
// Initialize rebase operation
git_rebase* rebase = nullptr;
git_rebase_options rebase_opts = GIT_REBASE_OPTIONS_INIT;
rebase_opts.checkout_options.checkout_strategy = GIT_CHECKOUT_SAFE;
if( git_rebase_init( &rebase, GetRepo(), nullptr, nullptr, aMergeHeads[0], &rebase_opts ) )
{
wxString errorMsg = KIGIT_COMMON::GetLastGitError();
wxLogTrace( traceGit, "GIT_PULL_HANDLER::handleRebase() - Failed to initialize rebase: %s", errorMsg );
return PullResult::Error;
}
KIGIT::GitRebasePtr rebasePtr( rebase );
git_rebase_operation* operation = nullptr;
while( git_rebase_next( &operation, rebase ) != GIT_ITEROVER )
{
// Check for conflicts
git_index* index = nullptr;
if( git_repository_index( &index, GetRepo() ) )
{
wxLogTrace( traceGit, "GIT_PULL_HANDLER::handleRebase() - Failed to get index: %s",
KIGIT_COMMON::GetLastGitError() );
return PullResult::Error;
}
KIGIT::GitIndexPtr indexPtr( index );
if( git_index_has_conflicts( index ) )
{
// Abort the rebase if there are conflicts because we need to merge manually
git_rebase_abort( rebase );
AddErrorString( _( "Conflicts detected during rebase" ) );
return PullResult::MergeFailed;
}
git_oid commit_id;
git_signature* committer = nullptr;
if( git_signature_default( &committer, GetRepo() ) )
{
wxLogTrace( traceGit, "GIT_PULL_HANDLER::handleRebase() - Failed to create signature: %s",
KIGIT_COMMON::GetLastGitError() );
return PullResult::Error;
}
KIGIT::GitSignaturePtr committerPtr( committer );
if( git_rebase_commit( &commit_id, rebase, nullptr, committer, nullptr, nullptr ) != GIT_OK )
{
wxString errorMsg = KIGIT_COMMON::GetLastGitError();
wxLogTrace( traceGit, "GIT_PULL_HANDLER::handleRebase() - Failed to commit operation: %s", errorMsg );
git_rebase_abort( rebase );
return PullResult::Error;
}
}
// Finish the rebase
if( git_rebase_finish( rebase, nullptr ) )
{
wxLogTrace( traceGit, "GIT_PULL_HANDLER::handleRebase() - Failed to finish rebase: %s",
KIGIT_COMMON::GetLastGitError() );
return PullResult::Error;
}
wxLogTrace( traceGit, "GIT_PULL_HANDLER::handleRebase() - Rebase completed successfully" );
git_repository_state_cleanup( GetRepo() );
return PullResult::Success;
}
void GIT_PULL_HANDLER::UpdateProgress( int aCurrent, int aTotal, const wxString& aMessage )
{
ReportProgress( aCurrent, aTotal, aMessage );
}
+26 -17
View File
@@ -21,15 +21,17 @@
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
*/
#ifndef _GIT_PULL_HANDLER_H_
#define _GIT_PULL_HANDLER_H_
#include <git/git_repo_mixin.h>
#ifndef GITPULLHANDLER_HPP
#define GITPULLHANDLER_HPP
#include <git2.h>
#include <functional>
#include <vector>
#include <string>
#include <wx/string.h>
#include <git2.h>
#include "kicad_git_common.h"
#include <git/git_progress.h>
// Structure to store commit details
struct CommitDetails
@@ -63,29 +65,36 @@ struct ConflictData
};
class GIT_PULL_HANDLER : public KIGIT_REPO_MIXIN
class GIT_PULL_HANDLER : public KIGIT_COMMON, public GIT_PROGRESS
{
public:
GIT_PULL_HANDLER( KIGIT_COMMON* aCommon );
~GIT_PULL_HANDLER();
bool PerformFetch( bool aSkipLock = false );
PullResult PerformPull();
bool PerformFetch();
const std::vector<std::pair<std::string, std::vector<CommitDetails>>>& GetFetchResults() const;
// Implementation for progress updates
// Set the callback function for conflict resolution
void SetConflictCallback(
std::function<int( std::vector<ConflictData>& aConflicts )> aCallback )
{
m_conflictCallback = aCallback;
}
void UpdateProgress( int aCurrent, int aTotal, const wxString& aMessage ) override;
private:
std::vector<std::pair<std::string, std::vector<CommitDetails>>> m_fetchResults;
std::string getFirstLineFromCommitMessage( const std::string& aMessage );
std::string getFormattedCommitDate( const git_time& aTime );
PullResult handleFastForward();
PullResult handleMerge( const git_annotated_commit** aMergeHeads, size_t aMergeHeadsCount );
PullResult handleRebase( const git_annotated_commit** aMergeHeads, size_t aMergeHeadsCount );
std::string getFormattedCommitDate( const git_time& aTime );private:
PullResult handleFastForward();
PullResult handleMerge( const git_annotated_commit** aMergeHeads, size_t aMergeHeadsCount);
std::vector<std::pair<std::string, std::vector<CommitDetails>>> m_fetchResults;
std::function<int( std::vector<ConflictData>& aConflicts )> m_conflictCallback;
};
#endif // _GIT_PULL_HANDLER_H_
#endif // GITPULLHANDLER_HPP
+15 -25
View File
@@ -23,44 +23,32 @@
#include "git_push_handler.h"
#include <git/kicad_git_common.h>
#include <git/kicad_git_memory.h>
#include <trace_helpers.h>
#include <iostream>
#include <wx/log.h>
GIT_PUSH_HANDLER::GIT_PUSH_HANDLER( KIGIT_COMMON* aRepo ) : KIGIT_REPO_MIXIN( aRepo )
GIT_PUSH_HANDLER::GIT_PUSH_HANDLER( KIGIT_COMMON* aRepo ) : KIGIT_COMMON( *aRepo )
{}
GIT_PUSH_HANDLER::~GIT_PUSH_HANDLER()
{}
PushResult GIT_PUSH_HANDLER::PerformPush()
{
std::unique_lock<std::mutex> lock( GetCommon()->m_gitActionMutex, std::try_to_lock );
if(!lock.owns_lock())
{
wxLogTrace(traceGit, "GIT_PUSH_HANDLER::PerformPush: Could not lock mutex");
return PushResult::Error;
}
PushResult result = PushResult::Success;
// Fetch updates from remote repository
git_remote* remote = nullptr;
if(git_remote_lookup(&remote, GetRepo(), "origin") != 0)
if( git_remote_lookup( &remote, m_repo, "origin" ) != 0 )
{
AddErrorString(_("Could not lookup remote"));
AddErrorString( _( "Could not lookup remote" ) );
return PushResult::Error;
}
KIGIT::GitRemotePtr remotePtr(remote);
git_remote_callbacks remoteCallbacks;
git_remote_init_callbacks(&remoteCallbacks, GIT_REMOTE_CALLBACKS_VERSION);
git_remote_init_callbacks( &remoteCallbacks, GIT_REMOTE_CALLBACKS_VERSION );
remoteCallbacks.sideband_progress = progress_cb;
remoteCallbacks.transfer_progress = transfer_progress_cb;
remoteCallbacks.update_tips = update_cb;
@@ -68,13 +56,14 @@ PushResult GIT_PUSH_HANDLER::PerformPush()
remoteCallbacks.credentials = credentials_cb;
remoteCallbacks.payload = this;
TestedTypes() = 0;
m_testedTypes = 0;
ResetNextKey();
if( git_remote_connect( remote, GIT_DIRECTION_PUSH, &remoteCallbacks, nullptr, nullptr ) )
{
AddErrorString( wxString::Format( _( "Could not connect to remote: %s" ),
KIGIT_COMMON::GetLastGitError() ) );
git_error_last()->message ) );
git_remote_free( remote );
return PushResult::Error;
}
@@ -85,29 +74,30 @@ PushResult GIT_PUSH_HANDLER::PerformPush()
// Get the current HEAD reference
git_reference* head = nullptr;
if( git_repository_head( &head, GetRepo() ) != 0 )
if( git_repository_head( &head, m_repo ) != 0 )
{
git_remote_disconnect( remote );
AddErrorString( _( "Could not get repository head" ) );
git_remote_free( remote );
return PushResult::Error;
}
KIGIT::GitReferencePtr headPtr( head );
// Create refspec for current branch
const char* refs[1];
refs[0] = git_reference_name( head );
const git_strarray refspecs = { (char**) refs, 1 };
git_reference_free(head);
if( git_remote_push( remote, &refspecs, &pushOptions ) )
{
AddErrorString( wxString::Format( _( "Could not push to remote: %s" ),
KIGIT_COMMON::GetLastGitError() ) );
git_error_last()->message ) );
git_remote_disconnect( remote );
git_remote_free( remote );
return PushResult::Error;
}
git_remote_disconnect( remote );
git_remote_free( remote );
return result;
}
+15 -15
View File
@@ -21,37 +21,37 @@
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
*/
#ifndef _GIT_PUSH_HANDLER_H_
#define _GIT_PUSH_HANDLER_H_
#ifndef GITPUSHHANDLER_HPP
#define GITPUSHHANDLER_HPP
#include <git2.h>
#include <functional>
#include <vector>
#include <string>
#include "kicad_git_common.h"
#include <git/git_progress.h>
#include <git/git_repo_mixin.h>
#include <git/kicad_git_errors.h>
#include <wx/string.h>
class KIGIT_COMMON;
// Enum for result codes
enum class PushResult
{
Success,
Error
Error,
UpToDate
};
class GIT_PUSH_HANDLER : public KIGIT_REPO_MIXIN
class GIT_PUSH_HANDLER : public KIGIT_COMMON, public GIT_PROGRESS
{
public:
GIT_PUSH_HANDLER( KIGIT_COMMON* aCommon );
GIT_PUSH_HANDLER( KIGIT_COMMON* aRepo );
~GIT_PUSH_HANDLER();
PushResult PerformPush();
// Virtual method for progress reporting
virtual void ReportProgress(int aCurrent, int aTotal, const wxString& aMessage) {}
void UpdateProgress( int aCurrent, int aTotal, const wxString& aMessage ) override;
private:
// Implementation of GIT_PROGRESS's virtual method
void UpdateProgress(int aCurrent, int aTotal, const wxString& aMessage) override;
};
#endif // _GIT_PUSH_HANDLER_H_
#endif // GITPUSHHANDLER_HPP
+5 -5
View File
@@ -24,7 +24,6 @@
#include <wx/string.h>
#include <wx/log.h>
#include <git/kicad_git_memory.h>
#include "git_remove_from_index_handler.h"
GIT_REMOVE_FROM_INDEX_HANDLER::GIT_REMOVE_FROM_INDEX_HANDLER( git_repository* aRepository )
@@ -52,14 +51,15 @@ bool GIT_REMOVE_FROM_INDEX_HANDLER::RemoveFromIndex( const wxString& aFilePath )
return false;
}
KIGIT::GitIndexPtr indexPtr( index );
if( git_index_find( &at_pos, index, aFilePath.ToUTF8().data() ) != 0 )
{
git_index_free( index );
wxLogError( "Failed to find index entry for %s", aFilePath );
return false;
}
git_index_free( index );
m_filesToRemove.push_back( aFilePath );
return true;
}
@@ -78,8 +78,6 @@ void GIT_REMOVE_FROM_INDEX_HANDLER::PerformRemoveFromIndex()
return;
}
KIGIT::GitIndexPtr indexPtr( index );
if( git_index_remove_bypath( index, file.ToUTF8().data() ) != 0 )
{
wxLogError( "Failed to remove index entry for %s", file );
@@ -97,5 +95,7 @@ void GIT_REMOVE_FROM_INDEX_HANDLER::PerformRemoveFromIndex()
wxLogError( "Failed to write index tree" );
return;
}
git_index_free( index );
}
}
-188
View File
@@ -1,188 +0,0 @@
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, see <http://www.gnu.org/licenses/>.
#ifndef GIT_REPO_MIXIN_H
#define GIT_REPO_MIXIN_H
#include "kicad_git_common.h"
#include "kicad_git_errors.h"
#include "git_progress.h"
class KIGIT_REPO_MIXIN: public KIGIT_ERRORS, public GIT_PROGRESS
{
public:
KIGIT_REPO_MIXIN( KIGIT_COMMON* aCommon ) : m_common( aCommon )
{
// Ensure m_common is initialized
wxASSERT( aCommon != nullptr );
}
virtual ~KIGIT_REPO_MIXIN()
{
// Non-owning, don't delete
}
/**
* @brief Get the current branch name
* @return The current branch name
*/
wxString GetCurrentBranchName() const
{
return m_common->GetCurrentBranchName();
}
/**
* @brief Get a list of branch names
* @return A vector of branch names
*/
std::vector<wxString> GetBranchNames() const
{
return m_common->GetBranchNames();
}
/**
* @brief Get a list of project directories
* @return A vector of project directories
*/
std::vector<wxString> GetProjectDirs()
{
return m_common->GetProjectDirs();
}
/**
* @brief Get a pointer to the git repository
* @return A pointer to the git repository
*/
git_repository* GetRepo() const
{
return m_common->GetRepo();
}
/**
* @brief Get a pair of sets of files that differ locally from the remote repository
* @return A pair of sets of files that differ locally from the remote repository
*/
std::pair<std::set<wxString>, std::set<wxString>> GetDifferentFiles() const
{
return m_common->GetDifferentFiles();
}
/**
* @brief Get the common object
* @return The common object
*/
KIGIT_COMMON* GetCommon() const
{
return m_common;
}
/**
* @brief Reset the next public key to test
*/
void ResetNextKey() { m_common->ResetNextKey(); }
/**
* @brief Get the next public key
* @return The next public key
*/
wxString GetNextPublicKey()
{
return m_common->GetNextPublicKey();
}
/**
* @brief Get the connection type
* @return The connection type
*/
KIGIT_COMMON::GIT_CONN_TYPE GetConnType() const
{
return m_common->GetConnType();
}
/**
* @brief Get the username
* @return The username
*/
wxString GetUsername() const
{
return m_common->GetUsername();
}
/**
* @brief Get the password
* @return The password
*/
wxString GetPassword() const
{
return m_common->GetPassword();
}
/**
* @brief Set the username
* @param aUsername The username
*/
void SetUsername( const wxString& aUsername )
{
m_common->SetUsername( aUsername );
}
/**
* @brief Set the password
* @param aPassword The password
*/
void SetPassword( const wxString& aPassword )
{
m_common->SetPassword( aPassword );
}
/**
* @brief Set the SSH key
* @param aSSHKey The SSH key
*/
void SetSSHKey( const wxString& aSSHKey )
{
m_common->SetSSHKey( aSSHKey );
}
/**
* @brief Get the remote name
* @return The remote name
*/
wxString GetRemotename() const
{
return m_common->GetRemotename();
}
/**
* @brief Get the git root directory
* @return The git root directory
*/
wxString GetGitRootDirectory() const
{
return m_common->GetGitRootDirectory();
}
/**
* @brief Return the connection types that have been tested for authentication
* @return The connection types that have been tested for authentication
*/
unsigned& TestedTypes() { return m_common->TestedTypes(); }
private:
KIGIT_COMMON* m_common;
};
#endif // GIT_REPO_MIXIN_H
+120 -323
View File
@@ -22,15 +22,9 @@
*/
#include "kicad_git_common.h"
#include "kicad_git_memory.h"
#include "git_repo_mixin.h"
#include <git/git_progress.h>
#include <git/kicad_git_compat.h>
#include <kiplatform/secrets.h>
#include <trace_helpers.h>
#include <git2.h>
#include <wx/filename.h>
#include <wx/log.h>
#include <wx/textfile.h>
@@ -39,25 +33,9 @@
#include <vector>
KIGIT_COMMON::KIGIT_COMMON( git_repository* aRepo ) :
m_repo( aRepo ), m_connType( GIT_CONN_TYPE::GIT_CONN_LOCAL ), m_testedTypes( 0 ),
m_nextPublicKey( 0 )
m_repo( aRepo ), m_connType( GIT_CONN_TYPE::GIT_CONN_LOCAL ), m_testedTypes( 0 )
{}
KIGIT_COMMON::KIGIT_COMMON( const KIGIT_COMMON& aOther ) :
// Initialize base class and member variables
m_repo( aOther.m_repo ),
m_connType( aOther.m_connType ),
m_remote( aOther.m_remote ),
m_hostname( aOther.m_hostname ),
m_username( aOther.m_username ),
m_password( aOther.m_password ),
m_testedTypes( aOther.m_testedTypes ),
// The mutex is default-initialized, not copied
m_gitActionMutex(),
m_publicKeys( aOther.m_publicKeys ),
m_nextPublicKey( aOther.m_nextPublicKey )
{
}
KIGIT_COMMON::~KIGIT_COMMON()
{}
@@ -78,24 +56,25 @@ wxString KIGIT_COMMON::GetCurrentBranchName() const
if( retval && retval != GIT_EUNBORNBRANCH && retval != GIT_ENOTFOUND )
return wxEmptyString;
KIGIT::GitReferencePtr headPtr( head );
git_reference* branch;
git_reference *branch;
if( git_reference_resolve( &branch, head ) )
{
wxLogTrace( traceGit, "Failed to resolve branch" );
git_reference_free( head );
return wxEmptyString;
}
KIGIT::GitReferencePtr branchPtr( branch );
const char* branchName = "";
git_reference_free( head );
const char* branchName = "";
if( git_branch_name( &branchName, branch ) )
{
wxLogTrace( traceGit, "Failed to get branch name" );
git_reference_free( branch );
return wxEmptyString;
}
git_reference_free( branch );
return wxString( branchName );
}
@@ -112,45 +91,38 @@ std::vector<wxString> KIGIT_COMMON::GetBranchNames() const
git_branch_iterator* branchIterator = nullptr;
if( git_branch_iterator_new( &branchIterator, m_repo, GIT_BRANCH_LOCAL ) )
{
wxLogTrace( traceGit, "Failed to get branch iterator" );
return branchNames;
}
KIGIT::GitBranchIteratorPtr branchIteratorPtr( branchIterator );
git_reference* branchReference = nullptr;
git_branch_t branchType;
git_reference* branchReference = nullptr;
git_branch_t branchType;
while( git_branch_next( &branchReference, &branchType, branchIterator ) != GIT_ITEROVER )
{
const char* branchName = "";
KIGIT::GitReferencePtr branchReferencePtr( branchReference );
if( git_branch_name( &branchName, branchReference ) )
{
wxLogTrace( traceGit, "Failed to get branch name in iter loop" );
continue;
}
const git_oid* commitId = git_reference_target( branchReference );
git_commit* commit = nullptr;
if( git_commit_lookup( &commit, m_repo, commitId ) )
{
wxLogTrace( traceGit, "Failed to get commit in iter loop" );
continue;
}
KIGIT::GitCommitPtr commitPtr( commit );
git_time_t commitTime = git_commit_time( commit );
git_time_t commitTime = git_commit_time( commit );
if( git_branch_is_head( branchReference ) )
firstName = branchName;
else
branchNamesMap.emplace( commitTime, branchName );
git_commit_free( commit );
git_reference_free( branchReference );
}
git_branch_iterator_free( branchIterator );
// Add the current branch to the top of the list
if( !firstName.IsEmpty() )
branchNames.push_back( firstName );
@@ -174,26 +146,22 @@ std::vector<wxString> KIGIT_COMMON::GetProjectDirs()
if( git_reference_name_to_id( &oid, m_repo, "HEAD" ) != GIT_OK )
{
wxLogTrace( traceGit, "An error occurred: %s", KIGIT_COMMON::GetLastGitError() );
wxLogError( "An error occurred: %s", git_error_last()->message );
return projDirs;
}
if( git_commit_lookup( &commit, m_repo, &oid ) != GIT_OK )
{
wxLogTrace( traceGit, "An error occurred: %s", KIGIT_COMMON::GetLastGitError() );
wxLogError( "An error occurred: %s", git_error_last()->message );
return projDirs;
}
KIGIT::GitCommitPtr commitPtr( commit );
if( git_commit_tree( &tree, commit ) != GIT_OK )
{
wxLogTrace( traceGit, "An error occurred: %s", KIGIT_COMMON::GetLastGitError() );
wxLogError( "An error occurred: %s", git_error_last()->message );
return projDirs;
}
KIGIT::GitTreePtr treePtr( tree );
// Define callback
git_tree_walk(
tree, GIT_TREEWALK_PRE,
@@ -214,6 +182,9 @@ std::vector<wxString> KIGIT_COMMON::GetProjectDirs()
},
&projDirs );
git_tree_free( tree );
git_commit_free( commit );
std::sort( projDirs.begin(), projDirs.end(),
[]( const wxString& a, const wxString& b )
{
@@ -233,33 +204,21 @@ std::vector<wxString> KIGIT_COMMON::GetProjectDirs()
std::pair<std::set<wxString>,std::set<wxString>> KIGIT_COMMON::GetDifferentFiles() const
{
auto get_modified_files = [&]( const git_oid* from_oid, const git_oid* to_oid ) -> std::set<wxString>
auto get_modified_files = [&]( git_oid* from_oid, git_oid* to_oid ) -> std::set<wxString>
{
std::set<wxString> modified_set;
git_revwalk* walker = nullptr;
if( !m_repo || !from_oid )
return modified_set;
if( git_revwalk_new( &walker, m_repo ) != GIT_OK )
{
wxLogTrace( traceGit, "Failed to create revwalker: %s", KIGIT_COMMON::GetLastGitError() );
return modified_set;
}
KIGIT::GitRevWalkPtr walkerPtr( walker );
if( git_revwalk_push( walker, from_oid ) != GIT_OK )
if( ( git_revwalk_push( walker, from_oid ) != GIT_OK )
|| ( git_revwalk_hide( walker, to_oid ) != GIT_OK ) )
{
wxLogTrace( traceGit, "Failed to set from commit: %s", KIGIT_COMMON::GetLastGitError() );
git_revwalk_free( walker );
return modified_set;
}
if( to_oid && git_revwalk_hide( walker, to_oid ) != GIT_OK )
{
wxLogTrace( traceGit, "Failed to set end commit (maybe new repo): %s", KIGIT_COMMON::GetLastGitError() );
}
git_oid oid;
git_commit* commit;
@@ -267,65 +226,46 @@ std::pair<std::set<wxString>,std::set<wxString>> KIGIT_COMMON::GetDifferentFiles
while( git_revwalk_next( &oid, walker ) == GIT_OK )
{
if( git_commit_lookup( &commit, m_repo, &oid ) != GIT_OK )
{
wxLogTrace( traceGit, "Failed to lookup commit: %s", KIGIT_COMMON::GetLastGitError() );
continue;
}
KIGIT::GitCommitPtr commitPtr( commit );
git_tree *tree, *parent_tree = nullptr;
if( git_commit_tree( &tree, commit ) != GIT_OK )
{
wxLogTrace( traceGit, "Failed to get commit tree: %s", KIGIT_COMMON::GetLastGitError() );
git_commit_free( commit );
continue;
}
KIGIT::GitTreePtr treePtr( tree );
// get parent commit tree to diff against
if( !git_commit_parentcount( commit ) )
{
git_tree_walk(
tree, GIT_TREEWALK_PRE,
[]( const char* root, const git_tree_entry* entry, void* payload )
{
std::set<wxString>* modified_set_internal = static_cast<std::set<wxString>*>( payload );
wxString filePath = wxString::Format( "%s%s", root, git_tree_entry_name( entry ) );
modified_set_internal->insert( filePath );
return 0; // continue walking
},
&modified_set );
git_tree_free( tree );
git_commit_free( commit );
continue;
}
git_commit* parent;
if( git_commit_parent( &parent, commit, 0 ) != GIT_OK )
{
wxLogTrace( traceGit, "Failed to get parent commit: %s", KIGIT_COMMON::GetLastGitError() );
git_tree_free( tree );
git_commit_free( commit );
continue;
}
KIGIT::GitCommitPtr parentPtr( parent );
if( git_commit_tree( &parent_tree, parent ) != GIT_OK )
{
wxLogTrace( traceGit, "Failed to get parent commit tree: %s", KIGIT_COMMON::GetLastGitError() );
git_tree_free( tree );
git_commit_free( commit );
git_commit_free( parent );
continue;
}
KIGIT::GitTreePtr parentTreePtr( parent_tree );
git_diff* diff;
git_diff_options diff_opts;
git_diff_init_options( &diff_opts, GIT_DIFF_OPTIONS_VERSION );
if( !m_repo || !parent_tree || !tree )
continue;
if( git_diff_tree_to_tree( &diff, m_repo, parent_tree, tree, &diff_opts ) == GIT_OK )
{
size_t num_deltas = git_diff_num_deltas( diff );
@@ -338,13 +278,14 @@ std::pair<std::set<wxString>,std::set<wxString>> KIGIT_COMMON::GetDifferentFiles
git_diff_free( diff );
}
else
{
wxLogTrace( traceGit, "Failed to diff trees: %s", KIGIT_COMMON::GetLastGitError() );
}
git_tree_free( parent_tree );
git_commit_free( parent );
git_tree_free( tree );
git_commit_free( commit );
}
wxLogTrace( traceGit, "Finished walking commits with end: %s", KIGIT_COMMON::GetLastGitError() );
git_revwalk_free( walker );
return modified_set;
};
@@ -358,28 +299,22 @@ std::pair<std::set<wxString>,std::set<wxString>> KIGIT_COMMON::GetDifferentFiles
git_reference* remote_head = nullptr;
if( git_repository_head( &head, m_repo ) != GIT_OK )
{
wxLogTrace( traceGit, "Failed to get modified HEAD" );
return modified_files;
}
KIGIT::GitReferencePtr headPtr( head );
if( git_branch_upstream( &remote_head, head ) != GIT_OK )
{
wxLogTrace( traceGit, "Failed to get modified remote HEAD" );
git_reference_free( head );
return modified_files;
}
KIGIT::GitReferencePtr remoteHeadPtr( remote_head );
git_oid head_oid = *git_reference_target( head );
git_oid remote_oid = *git_reference_target( remote_head );
if( remote_head != nullptr && head != nullptr )
{
const git_oid* head_oid = git_reference_target( head );
const git_oid* remote_oid = git_reference_target( remote_head );
git_reference_free( head );
git_reference_free( remote_head );
modified_files.first = get_modified_files( head_oid, remote_oid );
modified_files.second = get_modified_files( remote_oid, head_oid );
}
modified_files.first = get_modified_files( &head_oid, &remote_oid );
modified_files.second = get_modified_files( &remote_oid, &head_oid );
return modified_files;
}
@@ -394,42 +329,29 @@ bool KIGIT_COMMON::HasLocalCommits() const
git_reference* remote_head = nullptr;
if( git_repository_head( &head, m_repo ) != GIT_OK )
{
wxLogTrace( traceGit, "Failed to get HEAD: %s", KIGIT_COMMON::GetLastGitError() );
return false;
}
KIGIT::GitReferencePtr headPtr( head );
if( git_branch_upstream( &remote_head, head ) != GIT_OK )
{
// No remote branch, so we have local commits (new repo?)
wxLogTrace( traceGit, "Failed to get remote HEAD: %s", KIGIT_COMMON::GetLastGitError() );
return true;
git_reference_free( head );
return false;
}
KIGIT::GitReferencePtr remoteHeadPtr( remote_head );
const git_oid* head_oid = git_reference_target( head );
const git_oid* remote_oid = git_reference_target( remote_head );
git_revwalk* walker = nullptr;
git_oid head_oid = *git_reference_target( head );
git_oid remote_oid = *git_reference_target( remote_head );
git_reference_free( head );
git_reference_free( remote_head );
git_revwalk* walker = nullptr;
if( git_revwalk_new( &walker, m_repo ) != GIT_OK )
{
wxLogTrace( traceGit, "Failed to create revwalker: %s", KIGIT_COMMON::GetLastGitError() );
return false;
}
KIGIT::GitRevWalkPtr walkerPtr( walker );
if( !head_oid || git_revwalk_push( walker, head_oid ) != GIT_OK )
if( ( git_revwalk_push( walker, &head_oid ) != GIT_OK )
|| ( git_revwalk_hide( walker, &remote_oid ) != GIT_OK ) )
{
wxLogTrace( traceGit, "Failed to push commits: %s", KIGIT_COMMON::GetLastGitError() );
return false;
}
if( remote_oid && git_revwalk_hide( walker, remote_oid ) != GIT_OK )
{
wxLogTrace( traceGit, "Failed to push/hide commits: %s", KIGIT_COMMON::GetLastGitError() );
git_revwalk_free( walker );
return false;
}
@@ -438,10 +360,11 @@ bool KIGIT_COMMON::HasLocalCommits() const
// If we can't walk to the next commit, then we are at or behind the remote
if( git_revwalk_next( &oid, walker ) != GIT_OK )
{
wxLogTrace( traceGit, "Failed to walk to next commit: %s", KIGIT_COMMON::GetLastGitError() );
git_revwalk_free( walker );
return false;
}
git_revwalk_free( walker );
return true;
}
@@ -453,12 +376,9 @@ bool KIGIT_COMMON::HasPushAndPullRemote() const
if( git_remote_lookup( &remote, m_repo, "origin" ) != GIT_OK )
{
wxLogTrace( traceGit, "Failed to get remote for haspushpull" );
return false;
}
KIGIT::GitRemotePtr remotePtr( remote );
// Get the URLs associated with the remote
const char* fetch_url = git_remote_url( remote );
const char* push_url = git_remote_pushurl( remote );
@@ -466,10 +386,13 @@ bool KIGIT_COMMON::HasPushAndPullRemote() const
// If no push URL is set, libgit2 defaults to using the fetch URL for pushing
if( !push_url )
{
wxLogTrace( traceGit, "No push URL set, using fetch URL" );
push_url = fetch_url;
}
// Clean up the remote object
git_remote_free( remote );
// Check if both URLs are valid (i.e., not NULL)
return fetch_url && push_url;
}
@@ -483,63 +406,22 @@ wxString KIGIT_COMMON::GetRemotename() const
git_reference* upstream = nullptr;
if( git_repository_head( &head, m_repo ) != GIT_OK )
{
wxLogTrace( traceGit, "Failed to get remote name: %s", KIGIT_COMMON::GetLastGitError() );
return retval;
}
KIGIT::GitReferencePtr headPtr( head );
if( git_branch_upstream( &upstream, head ) != GIT_OK )
if( git_branch_upstream( &upstream, head ) == GIT_OK )
{
wxLogTrace( traceGit, "Failed to get upstream branch: %s", KIGIT_COMMON::GetLastGitError() );
git_strarray remotes = { nullptr, 0 };
git_buf remote_name = GIT_BUF_INIT_CONST( nullptr, 0 );
if( git_remote_list( &remotes, m_repo ) == GIT_OK )
if( git_branch_remote_name( &remote_name, m_repo, git_reference_name( upstream ) ) == GIT_OK )
{
if( remotes.count == 1 )
retval = remotes.strings[0];
git_strarray_dispose( &remotes );
}
else
{
wxLogTrace( traceGit, "Failed to list remotes: %s", KIGIT_COMMON::GetLastGitError() );
// If we can't get the remote name from the upstream branch or the list of remotes,
// just return the default remote name
git_remote* remote = nullptr;
if( git_remote_lookup( &remote, m_repo, "origin" ) == GIT_OK )
{
retval = git_remote_name( remote );
git_remote_free( remote );
}
else
{
wxLogTrace( traceGit, "Failed to get remote name from default remote: %s",
KIGIT_COMMON::GetLastGitError() );
}
retval = remote_name.ptr;
git_buf_dispose( &remote_name );
}
return retval;
git_reference_free( upstream );
}
KIGIT::GitReferencePtr upstreamPtr( upstream );
git_buf remote_name = GIT_BUF_INIT_CONST( nullptr, 0 );
if( git_branch_remote_name( &remote_name, m_repo, git_reference_name( upstream ) ) == GIT_OK )
{
retval = remote_name.ptr;
git_buf_dispose( &remote_name );
}
else
{
wxLogTrace( traceGit,
"Failed to get remote name from upstream branch: %s",
KIGIT_COMMON::GetLastGitError() );
}
git_reference_free( head );
return retval;
}
@@ -662,26 +544,6 @@ void KIGIT_COMMON::UpdateCurrentBranchInfo()
updatePublicKeys();
}
KIGIT_COMMON::GIT_CONN_TYPE KIGIT_COMMON::GetConnType() const
{
wxString remote = m_remote;
if( remote.IsEmpty() )
remote = GetRemotename();
if( remote.StartsWith( "https://" ) || remote.StartsWith( "http://" ) )
{
return GIT_CONN_TYPE::GIT_CONN_HTTPS;
}
else if( remote.StartsWith( "ssh://" ) || remote.StartsWith( "git@" ) || remote.StartsWith( "git+ssh://" )
|| remote.EndsWith( ".git" ) )
{
return GIT_CONN_TYPE::GIT_CONN_SSH;
}
return GIT_CONN_TYPE::GIT_CONN_LOCAL;
}
void KIGIT_COMMON::updateConnectionType()
{
if( m_remote.StartsWith( "https://" ) || m_remote.StartsWith( "http://" ) )
@@ -751,62 +613,6 @@ void KIGIT_COMMON::updateConnectionType()
}
int KIGIT_COMMON::HandleSSHKeyAuthentication( git_cred** aOut, const wxString& aUsername )
{
if( !( m_testedTypes & KIGIT_CREDENTIAL_SSH_AGENT ) )
return HandleSSHAgentAuthentication( aOut, aUsername );
// SSH key authentication with password
wxString sshKey = GetNextPublicKey();
if( sshKey.IsEmpty() )
{
wxLogTrace( traceGit, "Finished testing all possible ssh keys" );
m_testedTypes |= GIT_CREDENTIAL_SSH_KEY;
return GIT_PASSTHROUGH;
}
wxString sshPubKey = sshKey + ".pub";
wxString password = GetPassword();
wxLogTrace( traceGit, "Testing %s\n", sshKey );
if( git_credential_ssh_key_new( aOut, aUsername.mbc_str(), sshPubKey.mbc_str(), sshKey.mbc_str(),
password.mbc_str() ) != GIT_OK )
{
wxLogTrace( traceGit, "Failed to create SSH key credential for %s: %s",
aUsername, KIGIT_COMMON::GetLastGitError() );
return GIT_PASSTHROUGH;
}
return GIT_OK;
}
int KIGIT_COMMON::HandlePlaintextAuthentication( git_cred** aOut, const wxString& aUsername )
{
wxString password = GetPassword();
git_credential_userpass_plaintext_new( aOut, aUsername.mbc_str(), password.mbc_str() );
m_testedTypes |= GIT_CREDENTIAL_USERPASS_PLAINTEXT;
return GIT_OK;
}
int KIGIT_COMMON::HandleSSHAgentAuthentication( git_cred** aOut, const wxString& aUsername )
{
if( git_credential_ssh_key_from_agent( aOut, aUsername.mbc_str() ) != GIT_OK )
{
wxLogTrace( traceGit, "Failed to create SSH agent credential for %s: %s",
aUsername, KIGIT_COMMON::GetLastGitError() );
return GIT_PASSTHROUGH;
}
m_testedTypes |= KIGIT_CREDENTIAL_SSH_AGENT;
return GIT_OK;
}
extern "C" int fetchhead_foreach_cb( const char*, const char*,
const git_oid* aOID, unsigned int aIsMerge, void* aPayload )
{
@@ -817,18 +623,18 @@ extern "C" int fetchhead_foreach_cb( const char*, const char*,
}
extern "C" void clone_progress_cb( const char* aStr, size_t aLen, size_t aTotal, void* aPayload )
extern "C" void clone_progress_cb( const char* aStr, size_t aLen, size_t aTotal, void* data )
{
KIGIT_REPO_MIXIN* parent = reinterpret_cast<KIGIT_REPO_MIXIN*>( aPayload );
KIGIT_COMMON* parent = (KIGIT_COMMON*) data;
wxString progressMessage( aStr );
parent->UpdateProgress( aLen, aTotal, progressMessage );
}
extern "C" int progress_cb( const char* str, int len, void* aPayload )
extern "C" int progress_cb( const char* str, int len, void* data )
{
KIGIT_REPO_MIXIN* parent = reinterpret_cast<KIGIT_REPO_MIXIN*>( aPayload );
KIGIT_COMMON* parent = (KIGIT_COMMON*) data;
wxString progressMessage( str, len );
parent->UpdateProgress( 0, 0, progressMessage );
@@ -839,11 +645,10 @@ extern "C" int progress_cb( const char* str, int len, void* aPayload )
extern "C" int transfer_progress_cb( const git_transfer_progress* aStats, void* aPayload )
{
KIGIT_REPO_MIXIN* parent = reinterpret_cast<KIGIT_REPO_MIXIN*>( aPayload );
wxString progressMessage = wxString::Format( _( "Received %u of %u objects" ),
aStats->received_objects,
aStats->total_objects );
KIGIT_COMMON* parent = (KIGIT_COMMON*) aPayload;
wxString progressMessage = wxString::Format( _( "Received %u of %u objects" ),
aStats->received_objects,
aStats->total_objects );
parent->UpdateProgress( aStats->received_objects, aStats->total_objects, progressMessage );
@@ -858,8 +663,8 @@ extern "C" int update_cb( const char* aRefname, const git_oid* aFirst, const git
char a_str[cstring_len + 1];
char b_str[cstring_len + 1];
KIGIT_REPO_MIXIN* parent = reinterpret_cast<KIGIT_REPO_MIXIN*>( aPayload );
wxString status;
KIGIT_COMMON* parent = (KIGIT_COMMON*) aPayload;
wxString status;
git_oid_tostr( b_str, cstring_len, aSecond );
@@ -886,8 +691,8 @@ extern "C" int update_cb( const char* aRefname, const git_oid* aFirst, const git
extern "C" int push_transfer_progress_cb( unsigned int aCurrent, unsigned int aTotal, size_t aBytes,
void* aPayload )
{
long long progress = 100;
KIGIT_REPO_MIXIN* parent = reinterpret_cast<KIGIT_REPO_MIXIN*>( aPayload );
long long progress = 100;
KIGIT_COMMON* parent = (KIGIT_COMMON*) aPayload;
if( aTotal != 0 )
{
@@ -904,8 +709,8 @@ extern "C" int push_transfer_progress_cb( unsigned int aCurrent, unsigned int aT
extern "C" int push_update_reference_cb( const char* aRefname, const char* aStatus, void* aPayload )
{
KIGIT_REPO_MIXIN* parent = reinterpret_cast<KIGIT_REPO_MIXIN*>( aPayload );
wxString status( aStatus );
KIGIT_COMMON* parent = (KIGIT_COMMON*) aPayload;
wxString status( aStatus );
if( !status.IsEmpty() )
{
@@ -925,62 +730,54 @@ extern "C" int push_update_reference_cb( const char* aRefname, const char* aStat
extern "C" int credentials_cb( git_cred** aOut, const char* aUrl, const char* aUsername,
unsigned int aAllowedTypes, void* aPayload )
{
KIGIT_REPO_MIXIN* parent = reinterpret_cast<KIGIT_REPO_MIXIN*>( aPayload );
KIGIT_COMMON* common = parent->GetCommon();
wxLogTrace( traceGit, "Credentials callback for %s, testing %d", aUrl, aAllowedTypes );
KIGIT_COMMON* parent = static_cast<KIGIT_COMMON*>( aPayload );
if( parent->GetConnType() == KIGIT_COMMON::GIT_CONN_TYPE::GIT_CONN_LOCAL )
{
wxLogTrace( traceGit, "Local repository, no credentials needed" );
return GIT_PASSTHROUGH;
}
if( aAllowedTypes & GIT_CREDENTIAL_USERNAME
&& !( parent->TestedTypes() & GIT_CREDENTIAL_USERNAME ) )
if( aAllowedTypes & GIT_CREDTYPE_USERNAME
&& !( parent->TestedTypes() & GIT_CREDTYPE_USERNAME ) )
{
wxString username = parent->GetUsername().Trim().Trim( false );
wxLogTrace( traceGit, "Username credential for %s at %s with allowed type %d",
username, aUrl, aAllowedTypes );
if( git_credential_username_new( aOut, username.ToStdString().c_str() ) != GIT_OK )
{
wxLogTrace( traceGit, "Failed to create username credential for %s: %s",
username, KIGIT_COMMON::GetLastGitError() );
}
else
{
wxLogTrace( traceGit, "Created username credential for %s", username );
}
parent->TestedTypes() |= GIT_CREDENTIAL_USERNAME;
git_cred_username_new( aOut, username.ToStdString().c_str() );
parent->TestedTypes() |= GIT_CREDTYPE_USERNAME;
}
else if( parent->GetConnType() == KIGIT_COMMON::GIT_CONN_TYPE::GIT_CONN_HTTPS
&& ( aAllowedTypes & GIT_CREDENTIAL_USERPASS_PLAINTEXT )
&& !( parent->TestedTypes() & GIT_CREDENTIAL_USERPASS_PLAINTEXT ) )
&& ( aAllowedTypes & GIT_CREDTYPE_USERPASS_PLAINTEXT )
&& !( parent->TestedTypes() & GIT_CREDTYPE_USERPASS_PLAINTEXT ) )
{
// Plaintext authentication
wxLogTrace( traceGit, "Plaintext authentication for %s at %s with allowed type %d",
parent->GetUsername(), aUrl, aAllowedTypes );
return common->HandlePlaintextAuthentication( aOut, parent->GetUsername() );
wxString username = parent->GetUsername().Trim().Trim( false );
wxString password = parent->GetPassword().Trim().Trim( false );
git_cred_userpass_plaintext_new( aOut, username.ToStdString().c_str(),
password.ToStdString().c_str() );
parent->TestedTypes() |= GIT_CREDTYPE_USERPASS_PLAINTEXT;
}
else if( parent->GetConnType() == KIGIT_COMMON::GIT_CONN_TYPE::GIT_CONN_SSH
&& ( aAllowedTypes & GIT_CREDENTIAL_SSH_KEY )
&& !( parent->TestedTypes() & GIT_CREDENTIAL_SSH_KEY ) )
&& ( aAllowedTypes & GIT_CREDTYPE_SSH_KEY )
&& !( parent->TestedTypes() & GIT_CREDTYPE_SSH_KEY ) )
{
// SSH key authentication
return common->HandleSSHKeyAuthentication( aOut, parent->GetUsername() );
wxString sshKey = parent->GetNextPublicKey();
if( sshKey.IsEmpty() )
{
parent->TestedTypes() |= GIT_CREDTYPE_SSH_KEY;
return GIT_PASSTHROUGH;
}
wxString sshPubKey = sshKey + ".pub";
wxString username = parent->GetUsername().Trim().Trim( false );
wxString password = parent->GetPassword().Trim().Trim( false );
git_cred_ssh_key_new( aOut, username.ToStdString().c_str(),
sshPubKey.ToStdString().c_str(),
sshKey.ToStdString().c_str(),
password.ToStdString().c_str() );
}
else
{
// If we didn't find anything to try, then we don't have a callback set that the
// server likes
if( !parent->TestedTypes() )
return GIT_PASSTHROUGH;
git_error_clear();
git_error_set_str( GIT_ERROR_NET, _( "Unable to authenticate" ).mbc_str() );
// Otherwise, we did try something but we failed, so return an authentication error
return GIT_EAUTH;
return GIT_PASSTHROUGH;
}
return GIT_OK;
+13 -38
View File
@@ -27,17 +27,15 @@
#include <git/kicad_git_errors.h>
#include <git2.h>
#include <mutex>
#include <set>
#include <wx/string.h>
class KIGIT_COMMON
class KIGIT_COMMON : public KIGIT_ERRORS
{
public:
KIGIT_COMMON( git_repository* aRepo );
KIGIT_COMMON( const KIGIT_COMMON& aOther );
~KIGIT_COMMON();
git_repository* GetRepo() const;
@@ -51,6 +49,8 @@ public:
std::vector<wxString> GetBranchNames() const;
virtual void UpdateProgress( int aCurrent, int aTotal, const wxString& aMessage ) {};
/**
* Return a vector of project files in the repository. Sorted by the depth of
* the project file in the directory tree
@@ -76,7 +76,6 @@ public:
GIT_STATUS_BEHIND, // File changed in remote repository but not in local
GIT_STATUS_AHEAD, // File changed in local repository but not in remote
GIT_STATUS_CONFLICTED,
GIT_STATUS_IGNORED,
GIT_STATUS_LAST
};
@@ -90,12 +89,19 @@ public:
wxString GetUsername() const { return m_username; }
wxString GetPassword() const { return m_password; }
GIT_CONN_TYPE GetConnType() const;
GIT_CONN_TYPE GetConnType() const { return m_connType; }
void SetUsername( const wxString& aUsername ) { m_username = aUsername; }
void SetPassword( const wxString& aPassword ) { m_password = aPassword; }
void SetSSHKey( const wxString& aSSHKey );
void SetConnType( GIT_CONN_TYPE aConnType ) { m_connType = aConnType; }
void SetConnType( unsigned aConnType )
{
if( aConnType < static_cast<unsigned>( GIT_CONN_TYPE::GIT_CONN_LAST ) )
m_connType = static_cast<GIT_CONN_TYPE>( aConnType );
}
// Holds a temporary variable that can be used by the authentication callback
// to remember which types of authentication have been tested so that we
// don't loop forever.
@@ -124,28 +130,6 @@ public:
return m_publicKeys[m_nextPublicKey++];
}
void SetRemote( const wxString& aRemote )
{
m_remote = aRemote;
updateConnectionType();
}
int HandleSSHKeyAuthentication( git_cred** aOut, const wxString& aUsername );
int HandlePlaintextAuthentication( git_cred** aOut, const wxString& aUsername );
int HandleSSHAgentAuthentication( git_cred** aOut, const wxString& aUsername );
static wxString GetLastGitError()
{
const git_error* error = git_error_last();
if( error == nullptr )
return wxString( "No error" );
return wxString( error->message );
}
protected:
git_repository* m_repo;
@@ -157,13 +141,6 @@ protected:
unsigned m_testedTypes;
std::mutex m_gitActionMutex;
// Make git handlers friends so they can access the mutex
friend class GIT_PUSH_HANDLER;
friend class GIT_PULL_HANDLER;
friend class GIT_CLONE_HANDLER;
private:
void updatePublicKeys();
void updateConnectionType();
@@ -171,12 +148,10 @@ private:
std::vector<wxString> m_publicKeys;
int m_nextPublicKey;
// Create a dummy flag to tell if we have tested ssh agent credentials separately
// from the ssh key credentials
static const unsigned KIGIT_CREDENTIAL_SSH_AGENT = 1 << sizeof( m_testedTypes - 1 );
};
extern "C" int progress_cb( const char* str, int len, void* data );
extern "C" int progress_cb( const char* str, int len, void* data );
extern "C" void clone_progress_cb( const char* str, size_t len, size_t total, void* data );
extern "C" int transfer_progress_cb( const git_transfer_progress* aStats, void* aPayload );
extern "C" int update_cb( const char* aRefname, const git_oid* aFirst, const git_oid* aSecond,
-4
View File
@@ -31,8 +31,4 @@
#define GIT_BUF_INIT { NULL, 0, 0 }
#endif
#if LIBGIT2_VER_MAJOR > 1 || ( LIBGIT2_VER_MAJOR == 1 && LIBGIT2_VER_MINOR >= 8 )
#include <git2/sys/errors.h>
#endif
#endif // KICAD_GIT_COMPAT_H_
-263
View File
@@ -1,263 +0,0 @@
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, see <http://www.gnu.org/licenses/>.
#ifndef KICAD_GIT_MEMORY_H
#define KICAD_GIT_MEMORY_H
#include <memory>
#include <git2.h>
namespace KIGIT
{
/**
* @brief A unique pointer for git_repository objects with automatic cleanup.
*/
using GitRepositoryPtr = std::unique_ptr<git_repository,
decltype([](git_repository* aRepo) {
git_repository_free(aRepo);
})>;
/**
* @brief A unique pointer for git_reference objects with automatic cleanup.
*/
using GitReferencePtr = std::unique_ptr<git_reference,
decltype([](git_reference* aRef) {
git_reference_free(aRef);
})>;
/**
* @brief A unique pointer for git_object objects with automatic cleanup.
*/
using GitObjectPtr = std::unique_ptr<git_object,
decltype([](git_object* aObject) {
git_object_free(aObject);
})>;
/**
* @brief A unique pointer for git_commit objects with automatic cleanup.
*/
using GitCommitPtr = std::unique_ptr<git_commit,
decltype([](git_commit* aCommit) {
git_commit_free(aCommit);
})>;
/**
* @brief A unique pointer for git_tree objects with automatic cleanup.
*/
using GitTreePtr = std::unique_ptr<git_tree,
decltype([](git_tree* aTree) {
git_tree_free(aTree);
})>;
/**
* @brief A unique pointer for git_index objects with automatic cleanup.
*/
using GitIndexPtr = std::unique_ptr<git_index,
decltype([](git_index* aIndex) {
git_index_free(aIndex);
})>;
/**
* @brief A unique pointer for git_rebase objects with automatic cleanup.
*/
using GitRebasePtr = std::unique_ptr<git_rebase,
decltype([](git_rebase* aRebase) {
git_rebase_free(aRebase);
})>;
/**
* @brief A unique pointer for git_revwalk objects with automatic cleanup.
*/
using GitRevWalkPtr = std::unique_ptr<git_revwalk,
decltype([](git_revwalk* aWalker) {
git_revwalk_free(aWalker);
})>;
/**
* @brief A unique pointer for git_diff objects with automatic cleanup.
*/
using GitDiffPtr = std::unique_ptr<git_diff,
decltype([](git_diff* aDiff) {
git_diff_free(aDiff);
})>;
/**
* @brief A unique pointer for git_signature objects with automatic cleanup.
*/
using GitSignaturePtr = std::unique_ptr<git_signature,
decltype([](git_signature* aSignature) {
git_signature_free(aSignature);
})>;
/**
* @brief A unique pointer for git_config objects with automatic cleanup.
*/
using GitConfigPtr = std::unique_ptr<git_config,
decltype([](git_config* aConfig) {
git_config_free(aConfig);
})>;
/**
* @brief A unique pointer for git_remote objects with automatic cleanup.
*/
using GitRemotePtr = std::unique_ptr<git_remote,
decltype([](git_remote* aRemote) {
git_remote_free(aRemote);
})>;
/**
* @brief A unique pointer for git_annotated_commit objects with automatic cleanup.
*/
using GitAnnotatedCommitPtr = std::unique_ptr<git_annotated_commit,
decltype([](git_annotated_commit* aCommit) {
git_annotated_commit_free(aCommit);
})>;
/**
* @brief A unique pointer for git_oid objects with automatic cleanup.
*/
using GitOidPtr = std::unique_ptr<git_oid,
decltype([](git_oid* aOid) {
delete aOid;
})>;
/**
* @brief A unique pointer for git_buf objects with automatic cleanup.
*/
using GitBufPtr = std::unique_ptr<git_buf,
decltype([](git_buf* aBuf) {
git_buf_free(aBuf);
})>;
/**
* @brief A unique pointer for git_blame objects with automatic cleanup.
*/
using GitBlamePtr = std::unique_ptr<git_blame,
decltype([](git_blame* aBlame) {
git_blame_free(aBlame);
})>;
/**
* @brief A unique pointer for git_blob objects with automatic cleanup.
*/
using GitBlobPtr = std::unique_ptr<git_blob,
decltype([](git_blob* aBlob) {
git_blob_free(aBlob);
})>;
/**
* @brief A unique pointer for git_branch_iterator objects with automatic cleanup.
*/
using GitBranchIteratorPtr = std::unique_ptr<git_branch_iterator,
decltype([](git_branch_iterator* aIter) {
git_branch_iterator_free(aIter);
})>;
/**
* @brief A unique pointer for git_config_entry objects with automatic cleanup.
*/
using GitConfigEntryPtr = std::unique_ptr<git_config_entry,
decltype([](git_config_entry* aEntry) {
git_config_entry_free(aEntry);
})>;
/**
* @brief A unique pointer for git_config_iterator objects with automatic cleanup.
*/
using GitConfigIteratorPtr = std::unique_ptr<git_config_iterator,
decltype([](git_config_iterator* aIter) {
git_config_iterator_free(aIter);
})>;
/**
* @brief A unique pointer for git_credential objects with automatic cleanup.
*/
using GitCredentialPtr = std::unique_ptr<git_credential,
decltype([](git_credential* aCred) {
git_credential_free(aCred);
})>;
/**
* @brief A unique pointer for git_oidarray objects with automatic cleanup.
*/
using GitOidArrayPtr = std::unique_ptr<git_oidarray,
decltype([](git_oidarray* aArray) {
git_oidarray_free(aArray);
})>;
/**
* @brief A unique pointer for git_strarray objects with automatic cleanup.
*/
using GitStrArrayPtr = std::unique_ptr<git_strarray,
decltype([](git_strarray* aArray) {
git_strarray_free(aArray);
})>;
/**
* @brief A unique pointer for git_describe_result objects with automatic cleanup.
*/
using GitDescribeResultPtr = std::unique_ptr<git_describe_result,
decltype([](git_describe_result* aResult) {
git_describe_result_free(aResult);
})>;
/**
* @brief A unique pointer for git_diff_stats objects with automatic cleanup.
*/
using GitDiffStatsPtr = std::unique_ptr<git_diff_stats,
decltype([](git_diff_stats* aStats) {
git_diff_stats_free(aStats);
})>;
/**
* @brief A unique pointer for git_filter_list objects with automatic cleanup.
*/
using GitFilterListPtr = std::unique_ptr<git_filter_list,
decltype([](git_filter_list* aFilters) {
git_filter_list_free(aFilters);
})>;
/**
* @brief A unique pointer for git_indexer objects with automatic cleanup.
*/
using GitIndexerPtr = std::unique_ptr<git_indexer,
decltype([](git_indexer* aIdx) {
git_indexer_free(aIdx);
})>;
/**
* @brief A unique pointer for git_index_iterator objects with automatic cleanup.
*/
using GitIndexIteratorPtr = std::unique_ptr<git_index_iterator,
decltype([](git_index_iterator* aIterator) {
git_index_iterator_free(aIterator);
})>;
/**
* @brief A unique pointer for git_index_conflict_iterator objects with automatic cleanup.
*/
using GitIndexConflictIteratorPtr = std::unique_ptr<git_index_conflict_iterator,
decltype([](git_index_conflict_iterator* aIterator) {
git_index_conflict_iterator_free(aIterator);
})>;
/**
* @brief A unique pointer for git_status_list objects with automatic cleanup.
*/
using GitStatusListPtr = std::unique_ptr<git_status_list,
decltype([](git_status_list* aList) {
git_status_list_free(aList);
})>;
} // namespace KIGIT
#endif // KICAD_GIT_MEMORY_H
+5 -8
View File
@@ -232,15 +232,13 @@ void GRID_TRICKS::onGridCellLeftClick( wxGridEvent& aEvent )
wxString newVal = m_grid->GetCellValue( row, col );
for( int otherRow = m_sel_row_start; otherRow < m_sel_row_start + m_sel_row_count; ++otherRow )
for( int affectedRow = m_sel_row_start; affectedRow < m_sel_row_count; ++affectedRow )
{
if( otherRow == row )
if( affectedRow == row )
continue;
m_grid->SetCellValue( otherRow, col, newVal );
m_grid->SetCellValue( affectedRow, col, newVal );
}
return;
}
}
@@ -854,9 +852,6 @@ void GRID_TRICKS::cutcopy( bool doCopy, bool doDelete )
// fill txt with a format that is compatible with most spreadsheets
for( int row = m_sel_row_start; row < m_sel_row_start + m_sel_row_count; ++row )
{
if( !txt.IsEmpty() )
txt += ROW_SEP;
for( int col = m_sel_col_start; col < m_sel_col_start + m_sel_col_count; ++col )
{
if( !m_grid->IsColShown( col ) )
@@ -875,6 +870,8 @@ void GRID_TRICKS::cutcopy( bool doCopy, bool doDelete )
tbl->SetValue( row, col, wxEmptyString );
}
}
txt += ROW_SEP;
}
if( doCopy )
+1 -11
View File
@@ -264,16 +264,6 @@ size_t hash_fp_item( const EDA_ITEM* aItem, int aFlags )
point -= shape->GetPosition();
}
//Basic sort of start/end points to try to always draw the same direction (left to right, down to up)
//The hashes are summed, so it doesn't matter what order the lines are drawn, only that the same points are used
if( points.size() > 1 )
{
if( points[0].x > points[1].x || points[0].y > points[1].y )
{
std::swap( points[0], points[1] );
}
}
for( VECTOR2I& point : points )
hash_combine( ret, point.x, point.y );
}
@@ -333,7 +323,7 @@ size_t hash_fp_item( const EDA_ITEM* aItem, int aFlags )
ret = hash_board_item( table, aFlags );
hash_combine( ret, table->StrokeExternal() );
hash_combine( ret, table->StrokeHeaderSeparator() );
hash_combine( ret, table->StrokeHeader() );
hash_combine( ret, table->StrokeColumns() );
hash_combine( ret, table->StrokeRows() );
+1 -1
View File
@@ -24,7 +24,7 @@
#include <ctime>
#include <boost/algorithm/string.hpp>
#include <json_common.h>
#include <nlohmann/json.hpp>
#include <wx/base64.h>
#include <kicad_curl/kicad_curl_easy.h>
+1 -1
View File
@@ -22,7 +22,7 @@
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
*/
#include <json_common.h>
#include <nlohmann/json.hpp>
#include <settings/parameters.h>
#include <wildcards_and_files_ext.h>
+6 -6
View File
@@ -1006,10 +1006,10 @@ double DXF_IMPORT_PLUGIN::getCurrentUnitScale()
switch( m_currentUnit )
{
case DXF_IMPORT_UNITS::INCH: scale = 25.4; break;
case DXF_IMPORT_UNITS::INCHES: scale = 25.4; break;
case DXF_IMPORT_UNITS::FEET: scale = 304.8; break;
case DXF_IMPORT_UNITS::MM: scale = 1.0; break;
case DXF_IMPORT_UNITS::CM: scale = 10.0; break;
case DXF_IMPORT_UNITS::MILLIMETERS: scale = 1.0; break;
case DXF_IMPORT_UNITS::CENTIMETERS: scale = 10.0; break;
case DXF_IMPORT_UNITS::METERS: scale = 1000.0; break;
case DXF_IMPORT_UNITS::MICROINCHES: scale = 2.54e-5; break;
case DXF_IMPORT_UNITS::MILS: scale = 0.0254; break;
@@ -1065,10 +1065,10 @@ void DXF_IMPORT_PLUGIN::setVariableInt( const std::string& key, int value, int c
switch( value )
{
case 1: m_currentUnit = DXF_IMPORT_UNITS::INCH; break;
case 1: m_currentUnit = DXF_IMPORT_UNITS::INCHES; break;
case 2: m_currentUnit = DXF_IMPORT_UNITS::FEET; break;
case 4: m_currentUnit = DXF_IMPORT_UNITS::MM; break;
case 5: m_currentUnit = DXF_IMPORT_UNITS::CM; break;
case 4: m_currentUnit = DXF_IMPORT_UNITS::MILLIMETERS; break;
case 5: m_currentUnit = DXF_IMPORT_UNITS::CENTIMETERS; break;
case 6: m_currentUnit = DXF_IMPORT_UNITS::METERS; break;
case 8: m_currentUnit = DXF_IMPORT_UNITS::MICROINCHES; break;
case 9: m_currentUnit = DXF_IMPORT_UNITS::MILS; break;

Some files were not shown because too many files have changed in this diff Show More