mirror of
https://gitlab.com/kicad/code/kicad.git
synced 2025-09-14 02:03:12 +02:00
Compare commits
4 Commits
2f06ffa279
...
025a459696
Author | SHA1 | Date | |
---|---|---|---|
|
025a459696 | ||
|
5dc6d43f43 | ||
|
98dd5a68eb | ||
|
13cd170f5a |
@ -26,6 +26,7 @@
|
||||
#include "render_3d_opengl.h"
|
||||
#include <board.h>
|
||||
#include <footprint.h>
|
||||
#include <pcb_track.h>
|
||||
#include "../../3d_math.h"
|
||||
#include "convert_basic_shapes_to_polygon.h"
|
||||
#include <lset.h>
|
||||
@ -726,6 +727,54 @@ void RENDER_3D_OPENGL::generateCylinder( const SFVEC2F& aCenter, float aInnerRad
|
||||
}
|
||||
|
||||
|
||||
void RENDER_3D_OPENGL::generateDisk( const SFVEC2F& aCenter, float aRadius, float aZ,
|
||||
unsigned int aNr_sides_per_circle, TRIANGLE_DISPLAY_LIST* aDstLayer,
|
||||
bool aTop )
|
||||
{
|
||||
const float delta = 2.0f * glm::pi<float>() / (float) aNr_sides_per_circle;
|
||||
|
||||
for( unsigned int i = 0; i < aNr_sides_per_circle; ++i )
|
||||
{
|
||||
float a0 = delta * i;
|
||||
float a1 = delta * ( i + 1 );
|
||||
const SFVEC3F p0( aCenter.x + cosf( a0 ) * aRadius,
|
||||
aCenter.y + sinf( a0 ) * aRadius, aZ );
|
||||
const SFVEC3F p1( aCenter.x + cosf( a1 ) * aRadius,
|
||||
aCenter.y + sinf( a1 ) * aRadius, aZ );
|
||||
const SFVEC3F c( aCenter.x, aCenter.y, aZ );
|
||||
|
||||
if( aTop )
|
||||
aDstLayer->m_layer_top_triangles->AddTriangle( p1, p0, c );
|
||||
else
|
||||
aDstLayer->m_layer_bot_triangles->AddTriangle( p0, p1, c );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void RENDER_3D_OPENGL::generateDimple( const SFVEC2F& aCenter, float aRadius, float aZ,
|
||||
float aDepth, unsigned int aNr_sides_per_circle,
|
||||
TRIANGLE_DISPLAY_LIST* aDstLayer, bool aTop )
|
||||
{
|
||||
const float delta = 2.0f * glm::pi<float>() / (float) aNr_sides_per_circle;
|
||||
const SFVEC3F c( aCenter.x, aCenter.y, aTop ? aZ - aDepth : aZ + aDepth );
|
||||
|
||||
for( unsigned int i = 0; i < aNr_sides_per_circle; ++i )
|
||||
{
|
||||
float a0 = delta * i;
|
||||
float a1 = delta * ( i + 1 );
|
||||
const SFVEC3F p0( aCenter.x + cosf( a0 ) * aRadius,
|
||||
aCenter.y + sinf( a0 ) * aRadius, aZ );
|
||||
const SFVEC3F p1( aCenter.x + cosf( a1 ) * aRadius,
|
||||
aCenter.y + sinf( a1 ) * aRadius, aZ );
|
||||
|
||||
if( aTop )
|
||||
aDstLayer->m_layer_top_triangles->AddTriangle( p0, p1, c );
|
||||
else
|
||||
aDstLayer->m_layer_bot_triangles->AddTriangle( p1, p0, c );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void RENDER_3D_OPENGL::generateViasAndPads()
|
||||
{
|
||||
if( !m_boardAdapter.GetBoard() )
|
||||
@ -882,6 +931,63 @@ void RENDER_3D_OPENGL::generateViasAndPads()
|
||||
delete layerTriangles;
|
||||
}
|
||||
}
|
||||
|
||||
TRIANGLE_DISPLAY_LIST* frontCover = new TRIANGLE_DISPLAY_LIST( m_boardAdapter.GetViaCount() );
|
||||
TRIANGLE_DISPLAY_LIST* backCover = new TRIANGLE_DISPLAY_LIST( m_boardAdapter.GetViaCount() );
|
||||
|
||||
for( const PCB_TRACK* track : m_boardAdapter.GetBoard()->Tracks() )
|
||||
{
|
||||
if( track->Type() != PCB_VIA_T )
|
||||
continue;
|
||||
|
||||
const PCB_VIA* via = static_cast<const PCB_VIA*>( track );
|
||||
|
||||
const float holediameter = via->GetDrillValue() * m_boardAdapter.BiuTo3dUnits();
|
||||
const float hole_radius = holediameter / 2.0f + 2.0 * platingThickness3d;
|
||||
const SFVEC2F center( via->GetStart().x * m_boardAdapter.BiuTo3dUnits(),
|
||||
-via->GetStart().y * m_boardAdapter.BiuTo3dUnits() );
|
||||
unsigned int seg = m_boardAdapter.GetCircleSegmentCount( via->GetDrillValue() );
|
||||
|
||||
PCB_LAYER_ID top_layer, bottom_layer;
|
||||
via->LayerPair( &top_layer, &bottom_layer );
|
||||
float ztop, zbot, dummy;
|
||||
getLayerZPos( top_layer, ztop, dummy );
|
||||
getLayerZPos( bottom_layer, dummy, zbot );
|
||||
|
||||
bool frontCovering = via->GetFrontCoveringMode() == COVERING_MODE::COVERED || via->IsTented( F_Mask );
|
||||
bool backCovering = via->GetBackCoveringMode() == COVERING_MODE::COVERED || via->IsTented( B_Mask );
|
||||
bool frontPlugged = via->GetFrontPluggingMode() == PLUGGING_MODE::PLUGGED;
|
||||
bool backPlugged = via->GetBackPluggingMode() == PLUGGING_MODE::PLUGGED;
|
||||
bool filled = via->GetFillingMode() == FILLING_MODE::FILLED
|
||||
|| via->GetCappingMode() == CAPPING_MODE::CAPPED;
|
||||
|
||||
const float depth = hole_radius * 0.3f;
|
||||
|
||||
if( frontCovering )
|
||||
{
|
||||
if( filled || !frontPlugged )
|
||||
generateDisk( center, hole_radius, ztop, seg, frontCover, true );
|
||||
else
|
||||
generateDimple( center, hole_radius, ztop, depth, seg, frontCover, true );
|
||||
}
|
||||
|
||||
if( backCovering )
|
||||
{
|
||||
if( filled || !backPlugged )
|
||||
generateDisk( center, hole_radius, zbot, seg, backCover, false );
|
||||
else
|
||||
generateDimple( center, hole_radius, zbot, depth, seg, backCover, false );
|
||||
}
|
||||
}
|
||||
|
||||
if( frontCover->m_layer_top_triangles->GetVertexSize() > 0 )
|
||||
m_viaFrontCover = new OPENGL_RENDER_LIST( *frontCover, 0, 0.0f, 0.0f );
|
||||
|
||||
if( backCover->m_layer_bot_triangles->GetVertexSize() > 0 )
|
||||
m_viaBackCover = new OPENGL_RENDER_LIST( *backCover, 0, 0.0f, 0.0f );
|
||||
|
||||
delete frontCover;
|
||||
delete backCover;
|
||||
}
|
||||
|
||||
|
||||
|
@ -72,6 +72,8 @@ RENDER_3D_OPENGL::RENDER_3D_OPENGL( EDA_3D_CANVAS* aCanvas, BOARD_ADAPTER& aAdap
|
||||
m_outerViaThroughHoles = nullptr;
|
||||
m_microviaHoles = nullptr;
|
||||
m_padHoles = nullptr;
|
||||
m_viaFrontCover = nullptr;
|
||||
m_viaBackCover = nullptr;
|
||||
|
||||
m_circleTexture = 0;
|
||||
m_grid = 0;
|
||||
@ -947,6 +949,8 @@ void RENDER_3D_OPENGL::freeAllLists()
|
||||
|
||||
DELETE_AND_FREE( m_microviaHoles )
|
||||
DELETE_AND_FREE( m_padHoles )
|
||||
DELETE_AND_FREE( m_viaFrontCover )
|
||||
DELETE_AND_FREE( m_viaBackCover )
|
||||
}
|
||||
|
||||
|
||||
@ -968,6 +972,17 @@ void RENDER_3D_OPENGL::renderSolderMaskLayer( PCB_LAYER_ID aLayerID, float aZPos
|
||||
setLayerMaterial( aLayerID );
|
||||
m_board->SetItIsTransparent( true );
|
||||
m_board->DrawCulled( aShowThickness, solder_mask, via_holes );
|
||||
|
||||
if( aLayerID == F_Mask && m_viaFrontCover )
|
||||
{
|
||||
m_viaFrontCover->ApplyScalePosition( aZPos, 4 * m_boardAdapter.GetNonCopperLayerThickness() );
|
||||
m_viaFrontCover->DrawTop();
|
||||
}
|
||||
else if( aLayerID == B_Mask && m_viaBackCover )
|
||||
{
|
||||
m_viaBackCover->ApplyScalePosition( aZPos, 4 * m_boardAdapter.GetNonCopperLayerThickness() );
|
||||
m_viaBackCover->DrawBot();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -123,6 +123,14 @@ private:
|
||||
float aZtop, float aZbot, unsigned int aNr_sides_per_circle,
|
||||
TRIANGLE_DISPLAY_LIST* aDstLayer );
|
||||
|
||||
void generateDisk( const SFVEC2F& aCenter, float aRadius, float aZ,
|
||||
unsigned int aNr_sides_per_circle, TRIANGLE_DISPLAY_LIST* aDstLayer,
|
||||
bool aTop );
|
||||
|
||||
void generateDimple( const SFVEC2F& aCenter, float aRadius, float aZ, float aDepth,
|
||||
unsigned int aNr_sides_per_circle, TRIANGLE_DISPLAY_LIST* aDstLayer,
|
||||
bool aTop );
|
||||
|
||||
void generateViasAndPads();
|
||||
|
||||
/**
|
||||
@ -236,6 +244,8 @@ private:
|
||||
|
||||
OPENGL_RENDER_LIST* m_microviaHoles;
|
||||
OPENGL_RENDER_LIST* m_padHoles;
|
||||
OPENGL_RENDER_LIST* m_viaFrontCover;
|
||||
OPENGL_RENDER_LIST* m_viaBackCover;
|
||||
|
||||
// Caches
|
||||
std::map<wxString, MODEL_3D*> m_3dModelMap;
|
||||
|
@ -214,6 +214,7 @@ set( KICOMMON_SRCS
|
||||
trace_helpers.cpp
|
||||
wildcards_and_files_ext.cpp
|
||||
wx_filename.cpp
|
||||
startup_key_handler.cpp
|
||||
|
||||
singleton.cpp
|
||||
pgm_base.cpp
|
||||
|
120
common/startup_key_handler.cpp
Normal file
120
common/startup_key_handler.cpp
Normal file
@ -0,0 +1,120 @@
|
||||
/*
|
||||
* This program source code file is part of KiCad, a free EDA CAD application.
|
||||
*
|
||||
* Copyright The KiCad Developers, see AUTHORS.txt for contributors.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License 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/>.
|
||||
*/
|
||||
|
||||
#include <functional>
|
||||
|
||||
#include <startup_key_handler.h>
|
||||
#include <wx/msgdlg.h>
|
||||
#include <gestfich.h>
|
||||
#include <paths.h>
|
||||
#include <confirm.h>
|
||||
|
||||
|
||||
StartupKeyHandler::StartupKeyHandler()
|
||||
{
|
||||
//Setup Keys and required actions to perform
|
||||
m_keyActions[{ WXK_CONTROL }] = { KEY_ACTION::RESET_TO_FACTORY_DEFAULTS };
|
||||
}
|
||||
|
||||
|
||||
StartupKeyHandler::~StartupKeyHandler()
|
||||
{
|
||||
m_keyActions.clear();
|
||||
}
|
||||
|
||||
|
||||
void StartupKeyHandler::CheckStartupKeys()
|
||||
{
|
||||
for( const auto& [keySequence, actions] : m_keyActions )
|
||||
{
|
||||
// We can request multiple combinations of modifying keys
|
||||
if( std::all_of( keySequence.begin(), keySequence.end(),
|
||||
[]( wxKeyCode keyCode )
|
||||
{
|
||||
return isKeyActionRequested( keyCode );
|
||||
} ) )
|
||||
{
|
||||
performKeyActions( actions );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
bool StartupKeyHandler::isKeyActionRequested( wxKeyCode aKeyCode )
|
||||
{
|
||||
return wxGetKeyState( aKeyCode );
|
||||
}
|
||||
|
||||
|
||||
void StartupKeyHandler::performKeyActions( const std::vector<KEY_ACTION>& aActions )
|
||||
{
|
||||
for( const KEY_ACTION& action : aActions )
|
||||
{
|
||||
switch( action )
|
||||
{
|
||||
case KEY_ACTION::RESET_TO_FACTORY_DEFAULTS:
|
||||
resetToFactoryDefaults();
|
||||
break;
|
||||
|
||||
default: break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void StartupKeyHandler::resetToFactoryDefaults()
|
||||
{
|
||||
wxString errors;
|
||||
|
||||
if( IsOK( nullptr, _( "Reset settings to default?" ) ) )
|
||||
{
|
||||
wxString sourcePath = PATHS::GetUserSettingsPath();
|
||||
wxString destPath = sourcePath + ".backup";
|
||||
|
||||
// Remove existing backup if exists
|
||||
if( !RmDirRecursive( destPath, &errors ) )
|
||||
{
|
||||
if( !errors.empty() )
|
||||
{
|
||||
DisplayErrorMessage( nullptr, errors );
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
// Create backup before deleting
|
||||
if( !CopyDirectory( sourcePath, destPath, errors ) )
|
||||
{
|
||||
if( !errors.empty() )
|
||||
{
|
||||
DisplayErrorMessage( nullptr, errors );
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
//delete
|
||||
if( !RmDirRecursive( sourcePath, &errors ) )
|
||||
{
|
||||
if( !errors.empty() )
|
||||
{
|
||||
DisplayErrorMessage( nullptr, errors );
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
63
include/startup_key_handler.h
Normal file
63
include/startup_key_handler.h
Normal file
@ -0,0 +1,63 @@
|
||||
/*
|
||||
* This program source code file is part of KiCad, a free EDA CAD application.
|
||||
*
|
||||
* Copyright The KiCad Developers, see AUTHORS.txt for contributors.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License 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 STARTUP_KEY_HANDLER_H
|
||||
#define STARTUP_KEY_HANDLER_H
|
||||
|
||||
#include <kicommon.h>
|
||||
#include <map>
|
||||
#include <vector>
|
||||
#include <wx/wx.h>
|
||||
|
||||
|
||||
// A class to handle key press detection and execute multiple actions at startup
|
||||
class KICOMMON_API StartupKeyHandler
|
||||
{
|
||||
public:
|
||||
// Enum to define actions for key presses
|
||||
enum class KEY_ACTION
|
||||
{
|
||||
RESET_TO_FACTORY_DEFAULTS
|
||||
};
|
||||
|
||||
// Constructor to initialize key-action mappings
|
||||
StartupKeyHandler();
|
||||
|
||||
~StartupKeyHandler();
|
||||
|
||||
// Function to handle the startup key check
|
||||
void CheckStartupKeys();
|
||||
|
||||
private:
|
||||
// Function to check if a ctrl key is pressed
|
||||
static bool isKeyActionRequested( wxKeyCode aKeyCode );
|
||||
|
||||
// Function to perform actions if ctrl key pressed
|
||||
void performKeyActions( const std::vector<KEY_ACTION>& aActions );
|
||||
|
||||
// Resets all user-configurable settings to their original factory default values.
|
||||
// This operation will erase any customized settings or preferences.
|
||||
void resetToFactoryDefaults();
|
||||
|
||||
private:
|
||||
// A map to store the combination of keys and their corresponding list of actions
|
||||
std::map<std::vector<wxKeyCode>, std::vector<KEY_ACTION>> m_keyActions;
|
||||
};
|
||||
|
||||
#endif // STARTUP_KEY_HANDLER_H
|
@ -63,6 +63,8 @@
|
||||
#include <api/api_server.h>
|
||||
#endif
|
||||
|
||||
#include "startup_key_handler.h"
|
||||
|
||||
// a dummy to quiet linking with EDA_BASE_FRAME::config();
|
||||
#include <kiface_base.h>
|
||||
KIFACE_BASE& Kiface()
|
||||
@ -86,6 +88,9 @@ PGM_KICAD& PgmTop()
|
||||
|
||||
bool PGM_KICAD::OnPgmInit()
|
||||
{
|
||||
StartupKeyHandler keyHandler;
|
||||
keyHandler.CheckStartupKeys();
|
||||
|
||||
App().SetAppDisplayName( wxT( "KiCad" ) );
|
||||
|
||||
#if defined(DEBUG)
|
||||
|
@ -542,7 +542,8 @@ void DRC_ENGINE::compileRules()
|
||||
}
|
||||
|
||||
if( error_semaphore.HasMessageOfSeverity( RPT_SEVERITY_ERROR ) )
|
||||
THROW_PARSE_ERROR( wxT( "Parse error" ), rule->m_Name, rule->m_Condition->GetExpression(), 0, 0 );
|
||||
THROW_PARSE_ERROR( wxT( "Parse error" ), rule->m_Name,
|
||||
TO_UTF8( rule->m_Condition->GetExpression() ), 0, 0 );
|
||||
|
||||
for( const DRC_CONSTRAINT& constraint : rule->m_Constraints )
|
||||
{
|
||||
|
Loading…
x
Reference in New Issue
Block a user