Move optional access from value() to *operator

`value()` throws.  Where we check for existence, we don't need to use
the throwing version and should just use the unprotected variant
This commit is contained in:
Seth Hillbrand 2022-08-30 13:58:43 -07:00
parent 7768c8f119
commit b736460e71
44 changed files with 181 additions and 162 deletions

View File

@ -264,10 +264,10 @@ COLOR_SETTINGS::COLOR_SETTINGS( const wxString& aFilename, bool aAbsolutePath )
[&]()
{
if( std::optional<COLOR4D> optval = Get<COLOR4D>( "board.grid" ) )
Set( "board.page_limits", optval.value() );
Set( "board.page_limits", *optval );
if( std::optional<COLOR4D> optval = Get<COLOR4D>( "schematic.grid" ) )
Set( "schematic.page_limits", optval.value() );
Set( "schematic.page_limits", *optval );
return true;
} );

View File

@ -212,8 +212,8 @@ bool TOOL_EVENT::IsDblClick( int aButtonMask ) const
bool TOOL_EVENT::IsCancelInteractive() const
{
return ( ( m_commandStr && m_commandStr.value() == ACTIONS::cancelInteractive.GetName() )
|| ( m_commandId && m_commandId.value() == ACTIONS::cancelInteractive.GetId() )
return ( ( m_commandStr && *m_commandStr == ACTIONS::cancelInteractive.GetName() )
|| ( m_commandId && *m_commandId == ACTIONS::cancelInteractive.GetId() )
|| ( m_actions == TA_CANCEL_TOOL ) );
}
@ -229,26 +229,26 @@ bool TOOL_EVENT::IsSelectionEvent() const
bool TOOL_EVENT::IsPointEditor() const
{
return ( ( m_commandStr && m_commandStr.value().find( "PointEditor" ) != GetCommandStr()->npos )
|| ( m_commandId && m_commandId.value() == ACTIONS::activatePointEditor.GetId() ) );
return ( ( m_commandStr && m_commandStr->find( "PointEditor" ) != GetCommandStr()->npos )
|| ( m_commandId && *m_commandId == ACTIONS::activatePointEditor.GetId() ) );
}
bool TOOL_EVENT::IsMoveTool() const
{
return ( m_commandStr
&& m_commandStr.value().find( "InteractiveMove" ) != GetCommandStr()->npos );
&& m_commandStr->find( "InteractiveMove" ) != GetCommandStr()->npos );
}
bool TOOL_EVENT::IsEditorTool() const
{
return ( m_commandStr
&& m_commandStr.value().find( "InteractiveEdit" ) != GetCommandStr()->npos );
&& m_commandStr->find( "InteractiveEdit" ) != GetCommandStr()->npos );
}
bool TOOL_EVENT::IsSimulator() const
{
return ( m_commandStr && m_commandStr.value().find( "Simulation" ) != GetCommandStr()->npos );
return ( m_commandStr && m_commandStr->find( "Simulation" ) != GetCommandStr()->npos );
}

View File

@ -1148,7 +1148,7 @@ bool TOOL_MANAGER::processEvent( const TOOL_EVENT& aEvent )
{
// An tool-selection-event has no position
if( mod_event.GetCommandStr()
&& mod_event.GetCommandStr().value() != GetToolHolder()->CurrentToolName()
&& *mod_event.GetCommandStr() != GetToolHolder()->CurrentToolName()
&& !mod_event.ForceImmediate() )
{
mod_event.SetHasPosition( false );

View File

@ -60,7 +60,11 @@ void ZOOM_TOOL::Reset( RESET_REASON aReason )
int ZOOM_TOOL::Main( const TOOL_EVENT& aEvent )
{
std::string tool = aEvent.GetCommandStr().value();
std::string tool;
if( aEvent.GetCommandStr() )
tool = *aEvent.GetCommandStr();
m_frame->PushTool( tool );
auto setCursor =

View File

@ -771,7 +771,7 @@ bool EESCHEMA_SETTINGS::migrateBomSettings()
if( !Contains( "bom.plugins" ) )
return false;
wxString list = Get<wxString>( "bom.plugins" ).value();
wxString list = *Get<wxString>( "bom.plugins" );
BOM_CFG_PARSER cfg_parser( &m_BomPanel.plugins, TO_UTF8( list ), wxT( "plugins" ) );

View File

@ -225,7 +225,7 @@ SCHEMATIC_SETTINGS::SCHEMATIC_SETTINGS( JSON_SETTINGS* aParent, const std::strin
std::optional<double> tor = Get<double>( "drawing.text_offset_ratio" );
if( tor )
Set( "drawing.label_size_ratio", tor.value() );
Set( "drawing.label_size_ratio", *tor );
return true;
} );

View File

@ -539,17 +539,17 @@ int EE_SELECTION_TOOL::Main( const TOOL_EVENT& aEvent )
m_disambiguateTimer.Stop();
// context sub-menu selection? Handle unit selection or bus unfolding
if( evt->GetCommandId().value() >= ID_POPUP_SCH_SELECT_UNIT_CMP
&& evt->GetCommandId().value() <= ID_POPUP_SCH_SELECT_UNIT_SYM_MAX )
if( *evt->GetCommandId() >= ID_POPUP_SCH_SELECT_UNIT_CMP
&& *evt->GetCommandId() <= ID_POPUP_SCH_SELECT_UNIT_SYM_MAX )
{
SCH_SYMBOL* symbol = dynamic_cast<SCH_SYMBOL*>( m_selection.Front() );
int unit = evt->GetCommandId().value() - ID_POPUP_SCH_SELECT_UNIT_CMP;
int unit = *evt->GetCommandId() - ID_POPUP_SCH_SELECT_UNIT_CMP;
if( symbol )
static_cast<SCH_EDIT_FRAME*>( m_frame )->SelectUnit( symbol, unit );
}
else if( evt->GetCommandId().value() >= ID_POPUP_SCH_UNFOLD_BUS
&& evt->GetCommandId().value() <= ID_POPUP_SCH_UNFOLD_BUS_END )
else if( *evt->GetCommandId() >= ID_POPUP_SCH_UNFOLD_BUS
&& *evt->GetCommandId() <= ID_POPUP_SCH_UNFOLD_BUS_END )
{
wxString* net = new wxString( *evt->Parameter<wxString*>() );
m_toolMgr->RunAction( EE_ACTIONS::unfoldBus, true, net );

View File

@ -144,7 +144,7 @@ int SCH_DRAWING_TOOLS::PlaceSymbol( const TOOL_EVENT& aEvent )
wxFAIL_MSG( "PlaceSymbol(): unexpected request" );
}
std::string tool = aEvent.GetCommandStr().value();
std::string tool = *aEvent.GetCommandStr();
m_frame->PushTool( tool );
auto addSymbol =
@ -252,7 +252,7 @@ int SCH_DRAWING_TOOLS::PlaceSymbol( const TOOL_EVENT& aEvent )
// The tool hotkey is interpreted as a click when drawing
bool isSyntheticClick = symbol
&& evt->IsActivate() && evt->HasPosition()
&& evt->GetCommandStr().value().compare( tool ) == 0;
&& evt->GetCommandStr() == tool;
if( evt->IsCancelInteractive() )
{
@ -400,10 +400,10 @@ int SCH_DRAWING_TOOLS::PlaceSymbol( const TOOL_EVENT& aEvent )
}
else if( evt->Category() == TC_COMMAND && evt->Action() == TA_CHOICE_MENU_CHOICE )
{
if( evt->GetCommandId().value() >= ID_POPUP_SCH_SELECT_UNIT_CMP
&& evt->GetCommandId().value() <= ID_POPUP_SCH_SELECT_UNIT_SYM_MAX )
if( *evt->GetCommandId() >= ID_POPUP_SCH_SELECT_UNIT_CMP
&& *evt->GetCommandId() <= ID_POPUP_SCH_SELECT_UNIT_SYM_MAX )
{
int unit = evt->GetCommandId().value() - ID_POPUP_SCH_SELECT_UNIT_CMP;
int unit = *evt->GetCommandId() - ID_POPUP_SCH_SELECT_UNIT_CMP;
if( symbol )
{
@ -463,7 +463,7 @@ int SCH_DRAWING_TOOLS::PlaceImage( const TOOL_EVENT& aEvent )
m_view->AddToPreview( image->Clone() );
}
std::string tool = aEvent.GetCommandStr().value();
std::string tool = *aEvent.GetCommandStr();
m_frame->PushTool( tool );
auto setCursor =
@ -516,7 +516,7 @@ int SCH_DRAWING_TOOLS::PlaceImage( const TOOL_EVENT& aEvent )
// The tool hotkey is interpreted as a click when drawing
bool isSyntheticClick = image
&& evt->IsActivate() && evt->HasPosition()
&& evt->GetCommandStr().value().compare( tool ) == 0;
&& evt->GetCommandStr() == tool;
if( evt->IsCancelInteractive() )
{
@ -751,7 +751,7 @@ int SCH_DRAWING_TOOLS::SingleClickPlace( const TOOL_EVENT& aEvent )
aEvent.Position() :
controls->GetMousePosition() );
std::string tool = aEvent.GetCommandStr().value();
std::string tool = *aEvent.GetCommandStr();
m_frame->PushTool( tool );
auto setCursor =
@ -1137,7 +1137,7 @@ int SCH_DRAWING_TOOLS::TwoClickPlace( const TOOL_EVENT& aEvent )
m_toolMgr->RunAction( EE_ACTIONS::clearSelection, true );
std::string tool = aEvent.GetCommandStr().value();
std::string tool = *aEvent.GetCommandStr();
m_frame->PushTool( tool );
auto setCursor =
[&]()
@ -1212,7 +1212,7 @@ int SCH_DRAWING_TOOLS::TwoClickPlace( const TOOL_EVENT& aEvent )
// The tool hotkey is interpreted as a click when drawing
bool isSyntheticClick = item
&& evt->IsActivate() && evt->HasPosition()
&& evt->GetCommandStr().value().compare( tool ) == 0;
&& evt->GetCommandStr() == tool;
if( evt->IsCancelInteractive() )
{
@ -1491,7 +1491,7 @@ int SCH_DRAWING_TOOLS::DrawShape( const TOOL_EVENT& aEvent )
m_toolMgr->RunAction( EE_ACTIONS::clearSelection, true );
std::string tool = aEvent.GetCommandStr().value();
std::string tool = *aEvent.GetCommandStr();
m_frame->PushTool( tool );
auto setCursor =
@ -1530,7 +1530,7 @@ int SCH_DRAWING_TOOLS::DrawShape( const TOOL_EVENT& aEvent )
// The tool hotkey is interpreted as a click when drawing
bool isSyntheticClick = item
&& evt->IsActivate() && evt->HasPosition()
&& evt->GetCommandStr().value().compare( tool ) == 0;
&& evt->GetCommandStr() == tool;
if( evt->IsCancelInteractive() )
{
@ -1700,7 +1700,7 @@ int SCH_DRAWING_TOOLS::DrawSheet( const TOOL_EVENT& aEvent )
m_toolMgr->RunAction( EE_ACTIONS::clearSelection, true );
std::string tool = aEvent.GetCommandStr().value();
std::string tool = *aEvent.GetCommandStr();
m_frame->PushTool( tool );
auto setCursor =
@ -1739,7 +1739,7 @@ int SCH_DRAWING_TOOLS::DrawSheet( const TOOL_EVENT& aEvent )
// The tool hotkey is interpreted as a click when drawing
bool isSyntheticClick = sheet
&& evt->IsActivate() && evt->HasPosition()
&& evt->GetCommandStr().value().compare( tool ) == 0;
&& evt->GetCommandStr() == tool;
if( evt->IsCancelInteractive() )
{

View File

@ -1199,7 +1199,7 @@ int SCH_EDIT_TOOL::DoDelete( const TOOL_EVENT& aEvent )
int SCH_EDIT_TOOL::DeleteItemCursor( const TOOL_EVENT& aEvent )
{
std::string tool = aEvent.GetCommandStr().value();
std::string tool = *aEvent.GetCommandStr();
PICKER_TOOL* picker = m_toolMgr->GetTool<PICKER_TOOL>();
m_toolMgr->RunAction( EE_ACTIONS::clearSelection, true );

View File

@ -924,7 +924,7 @@ int SCH_EDITOR_CONTROL::SimProbe( const TOOL_EVENT& aEvent )
m_toolMgr->RunAction( EE_ACTIONS::selectionActivate, false );
} );
std::string tool = aEvent.GetCommandStr().value();
std::string tool = *aEvent.GetCommandStr();
m_toolMgr->RunAction( ACTIONS::pickerTool, true, &tool );
return 0;
@ -1014,7 +1014,7 @@ int SCH_EDITOR_CONTROL::SimTune( const TOOL_EVENT& aEvent )
m_toolMgr->RunAction( EE_ACTIONS::selectionActivate, false );
} );
std::string tool = aEvent.GetCommandStr().value();
std::string tool = *aEvent.GetCommandStr();
m_toolMgr->RunAction( ACTIONS::pickerTool, true, &tool );
return 0;
@ -1332,7 +1332,7 @@ int SCH_EDITOR_CONTROL::HighlightNetCursor( const TOOL_EVENT& aEvent )
if( !ADVANCED_CFG::GetCfg().m_RealTimeConnectivity || !CONNECTION_GRAPH::m_allowRealTime )
m_frame->RecalculateConnections( NO_CLEANUP );
std::string tool = aEvent.GetCommandStr().value();
std::string tool = *aEvent.GetCommandStr();
PICKER_TOOL* picker = m_toolMgr->GetTool<PICKER_TOOL>();
// Deactivate other tools; particularly important if another PICKER is currently running

View File

@ -300,7 +300,7 @@ int SCH_LINE_WIRE_BUS_TOOL::DrawSegments( const TOOL_EVENT& aEvent )
DRAW_SEGMENT_EVENT_PARAMS* params = aEvent.Parameter<DRAW_SEGMENT_EVENT_PARAMS*>();
std::string tool = aEvent.GetCommandStr().value();
std::string tool = *aEvent.GetCommandStr();
m_frame->PushTool( tool );
m_toolMgr->RunAction( EE_ACTIONS::clearSelection, true );
@ -329,7 +329,7 @@ int SCH_LINE_WIRE_BUS_TOOL::UnfoldBus( const TOOL_EVENT& aEvent )
wxString net;
SCH_LINE* segment = nullptr;
std::string tool = aEvent.GetCommandStr().value();
std::string tool = *aEvent.GetCommandStr();
m_frame->PushTool( tool );
Activate();
@ -645,7 +645,7 @@ int SCH_LINE_WIRE_BUS_TOOL::doDrawSegments( const std::string& aTool, int aType,
// The tool hotkey is interpreted as a click when drawing
bool isSyntheticClick = ( segment || m_busUnfold.in_progress )
&& evt->IsActivate() && evt->HasPosition()
&& evt->GetCommandStr().value().compare( aTool ) == 0;
&& evt->GetCommandStr() == aTool;
setCursor();
grid.SetMask( GRID_HELPER::ALL );
@ -980,8 +980,8 @@ int SCH_LINE_WIRE_BUS_TOOL::doDrawSegments( const std::string& aTool, int aType,
}
else if( evt->Category() == TC_COMMAND && evt->Action() == TA_CHOICE_MENU_CHOICE )
{
if( evt->GetCommandId().value() >= ID_POPUP_SCH_UNFOLD_BUS
&& evt->GetCommandId().value() <= ID_POPUP_SCH_UNFOLD_BUS_END )
if( *evt->GetCommandId() >= ID_POPUP_SCH_UNFOLD_BUS
&& *evt->GetCommandId() <= ID_POPUP_SCH_UNFOLD_BUS_END )
{
wxASSERT_MSG( !segment, "Bus unfold event received when already drawing!" );

View File

@ -144,7 +144,7 @@ int SCH_MOVE_TOOL::Main( const TOOL_EVENT& aEvent )
// Must be done after Activate() so that it gets set into the correct context
controls->ShowCursor( true );
std::string tool = aEvent.GetCommandStr().value();
std::string tool = *aEvent.GetCommandStr();
m_frame->PushTool( tool );
if( selection.Empty() )
@ -803,11 +803,11 @@ int SCH_MOVE_TOOL::Main( const TOOL_EVENT& aEvent )
}
else if( evt->Action() == TA_CHOICE_MENU_CHOICE )
{
if( evt->GetCommandId().value() >= ID_POPUP_SCH_SELECT_UNIT_CMP
&& evt->GetCommandId().value() <= ID_POPUP_SCH_SELECT_UNIT_SYM_MAX )
if( *evt->GetCommandId() >= ID_POPUP_SCH_SELECT_UNIT_CMP
&& *evt->GetCommandId() <= ID_POPUP_SCH_SELECT_UNIT_SYM_MAX )
{
SCH_SYMBOL* symbol = dynamic_cast<SCH_SYMBOL*>( selection.Front() );
int unit = evt->GetCommandId().value() - ID_POPUP_SCH_SELECT_UNIT_CMP;
int unit = *evt->GetCommandId() - ID_POPUP_SCH_SELECT_UNIT_CMP;
if( symbol )
{

View File

@ -95,7 +95,7 @@ int SYMBOL_EDITOR_DRAWING_TOOLS::TwoClickPlace( const TOOL_EVENT& aEvent )
m_toolMgr->RunAction( EE_ACTIONS::clearSelection, true );
std::string tool = aEvent.GetCommandStr().value();
std::string tool = *aEvent.GetCommandStr();
m_frame->PushTool( tool );
auto setCursor =
@ -147,7 +147,7 @@ int SYMBOL_EDITOR_DRAWING_TOOLS::TwoClickPlace( const TOOL_EVENT& aEvent )
// The tool hotkey is interpreted as a click when drawing
bool isSyntheticClick = item
&& evt->IsActivate() && evt->HasPosition()
&& evt->GetCommandStr().value().compare( tool ) == 0;
&& evt->GetCommandStr() == tool;
if( evt->IsCancelInteractive() )
{
@ -341,7 +341,7 @@ int SYMBOL_EDITOR_DRAWING_TOOLS::DrawShape( const TOOL_EVENT& aEvent )
m_toolMgr->RunAction( EE_ACTIONS::clearSelection, true );
std::string tool = aEvent.GetCommandStr().value();
std::string tool = *aEvent.GetCommandStr();
m_frame->PushTool( tool );
auto setCursor =
@ -378,7 +378,7 @@ int SYMBOL_EDITOR_DRAWING_TOOLS::DrawShape( const TOOL_EVENT& aEvent )
// The tool hotkey is interpreted as a click when drawing
bool isSyntheticClick = item
&& evt->IsActivate() && evt->HasPosition()
&& evt->GetCommandStr().value().compare( tool ) == 0;
&& evt->GetCommandStr() == tool;
if( evt->IsCancelInteractive() )
{
@ -542,7 +542,7 @@ int SYMBOL_EDITOR_DRAWING_TOOLS::DrawShape( const TOOL_EVENT& aEvent )
int SYMBOL_EDITOR_DRAWING_TOOLS::PlaceAnchor( const TOOL_EVENT& aEvent )
{
std::string tool = aEvent.GetCommandStr().value();
std::string tool = *aEvent.GetCommandStr();
m_frame->PushTool( tool );
auto setCursor =

View File

@ -332,7 +332,7 @@ int SYMBOL_EDITOR_EDIT_TOOL::DoDelete( const TOOL_EVENT& aEvent )
int SYMBOL_EDITOR_EDIT_TOOL::DeleteItemCursor( const TOOL_EVENT& aEvent )
{
std::string tool = aEvent.GetCommandStr().value();
std::string tool = *aEvent.GetCommandStr();
PICKER_TOOL* picker = m_toolMgr->GetTool<PICKER_TOOL>();
m_toolMgr->RunAction( EE_ACTIONS::clearSelection, true );

View File

@ -110,7 +110,7 @@ int SYMBOL_EDITOR_MOVE_TOOL::Main( const TOOL_EVENT& aEvent )
return 0;
}
std::string tool = aEvent.GetCommandStr().value();
std::string tool = *aEvent.GetCommandStr();
m_frame->PushTool( tool );
Activate();

View File

@ -207,7 +207,7 @@ int GERBVIEW_INSPECTION_TOOL::MeasureTool( const TOOL_EVENT& aEvent )
EDA_UNITS units = m_frame->GetUserUnits();
KIGFX::PREVIEW::RULER_ITEM ruler( twoPtMgr, units, false, false );
std::string tool = aEvent.GetCommandStr().value();
std::string tool = *aEvent.GetCommandStr();
m_frame->PushTool( tool );
auto setCursor =

View File

@ -258,7 +258,7 @@ void PANEL_PACKAGES_VIEW::setPackageDetails( const PACKAGE_VIEW_DATA& aPackageDa
write_contact( _( "Author" ), package.author );
if( package.maintainer )
write_contact( _( "Maintainer" ), package.maintainer.value() );
write_contact( _( "Maintainer" ), *package.maintainer );
if( package.resources.size() > 0 )
{
@ -388,7 +388,7 @@ wxString PANEL_PACKAGES_VIEW::toHumanReadableSize( const std::optional<uint64_t>
if( !size )
return "-";
uint64_t b = size.value();
uint64_t b = *size;
if( b >= 1024 * 1024 )
return wxString::Format( "%.1f MB", b / 1000.0 / 1000.0 );
@ -497,7 +497,7 @@ void PANEL_PACKAGES_VIEW::OnDownloadVersionClicked( wxCommandEvent& event )
return;
}
const wxString& url = ver_it->download_url.value();
const wxString& url = *ver_it->download_url;
SETTINGS_MANAGER& mgr = Pgm().GetSettingsManager();
KICAD_SETTINGS* app_settings = mgr.GetAppSettings<KICAD_SETTINGS>();
@ -527,7 +527,7 @@ void PANEL_PACKAGES_VIEW::OnDownloadVersionClicked( wxCommandEvent& event )
{
std::ifstream stream( path.ToUTF8(), std::ios_base::binary );
bool matches = m_pcm->VerifyHash( stream, ver_it->download_sha256.value() );
bool matches = m_pcm->VerifyHash( stream, *ver_it->download_sha256 );
stream.close();

View File

@ -333,10 +333,10 @@ void PLUGIN_CONTENT_MANAGER::ValidateJson( const nlohmann::json& aJson,
}
bool PLUGIN_CONTENT_MANAGER::fetchPackages( const wxString& aUrl,
bool PLUGIN_CONTENT_MANAGER::fetchPackages( const wxString& aUrl,
const std::optional<wxString>& aHash,
std::vector<PCM_PACKAGE>& aPackages,
PROGRESS_REPORTER* aReporter )
std::vector<PCM_PACKAGE>& aPackages,
PROGRESS_REPORTER* aReporter )
{
std::stringstream packages_stream;
@ -352,7 +352,7 @@ bool PLUGIN_CONTENT_MANAGER::fetchPackages( const wxString& aUr
std::istringstream isstream( packages_stream.str() );
if( aHash && !VerifyHash( isstream, aHash.value() ) )
if( aHash && !VerifyHash( isstream, *aHash ) )
{
if( m_dialog )
wxLogError( _( "Packages hash doesn't match. Repository may be corrupted." ) );
@ -507,7 +507,7 @@ const bool PLUGIN_CONTENT_MANAGER::CacheRepository( const wxString& aRepositoryI
if( current_repo.resources )
{
// Check resources file date, redownload if needed
PCM_RESOURCE_REFERENCE& resources = current_repo.resources.value();
PCM_RESOURCE_REFERENCE& resources = *current_repo.resources;
wxFileName resource_file( repo_cache.GetPath(), "resources.zip" );
@ -535,7 +535,7 @@ const bool PLUGIN_CONTENT_MANAGER::CacheRepository( const wxString& aRepositoryI
std::ios_base::binary );
if( resources.sha256 && !VerifyHash( read_stream, resources.sha256.value() ) )
if( resources.sha256 && !VerifyHash( read_stream, *resources.sha256 ) )
{
read_stream.close();
@ -614,7 +614,7 @@ void PLUGIN_CONTENT_MANAGER::updateInstalledPackagesMetadata( const wxString& aR
if( current_version_it == installation_entry.package.versions.end() )
{
installation_entry.package.versions.emplace_back( current_version.value() );
installation_entry.package.versions.emplace_back( *current_version );
// Re-sort the versions by descending version
std::sort( installation_entry.package.versions.begin(),
@ -636,7 +636,7 @@ void PLUGIN_CONTENT_MANAGER::preparePackage( PCM_PACKAGE& aPackage )
int epoch = 0, major = 0, minor = 0, patch = 0;
if( ver.version_epoch )
epoch = ver.version_epoch.value();
epoch = *ver.version_epoch;
wxStringTokenizer version_tokenizer( ver.version, "." );
@ -676,7 +676,7 @@ void PLUGIN_CONTENT_MANAGER::preparePackage( PCM_PACKAGE& aPackage )
ver.compatible = false;
if( ver.kicad_version_max
&& parse_version_tuple( ver.kicad_version_max.value(), 999 ) < m_kicad_version )
&& parse_version_tuple( *ver.kicad_version_max, 999 ) < m_kicad_version )
ver.compatible = false;
#ifdef __WXMSW__
@ -978,7 +978,7 @@ int PLUGIN_CONTENT_MANAGER::GetPackageSearchRank( const PCM_PACKAGE& aPackage,
rank += find_term_matches( aPackage.author.name );
if( aPackage.maintainer )
rank += 3 * find_term_matches( aPackage.maintainer.value().name );
rank += 3 * find_term_matches( aPackage.maintainer->name );
// Match on resources
for( const auto& entry : aPackage.resources )

View File

@ -40,25 +40,25 @@ void to_json( json& j, const PACKAGE_VERSION& v )
{ "kicad_version", v.kicad_version } };
if( v.version_epoch )
j["version_epoch"] = v.version_epoch.value();
j["version_epoch"] = *v.version_epoch;
if( v.download_url )
j["download_url"] = v.download_url.value();
j["download_url"] = *v.download_url;
if( v.download_sha256 )
j["download_sha256"] = v.download_sha256.value();
j["download_sha256"] = *v.download_sha256;
if( v.download_size )
j["download_size"] = v.download_size.value();
j["download_size"] = *v.download_size;
if( v.install_size )
j["install_size"] = v.install_size.value();
j["install_size"] = *v.install_size;
if( v.platforms.size() > 0 )
nlohmann::to_json( j["platforms"], v.platforms );
if( v.kicad_version_max )
j["kicad_version_max"] = v.kicad_version_max.value();
j["kicad_version_max"] = *v.kicad_version_max;
if( v.keep_on_update.size() > 0 )
nlohmann::to_json( j["keep_on_update"], v.keep_on_update );
@ -99,7 +99,7 @@ void to_json( json& j, const PCM_PACKAGE& p )
{ "versions", p.versions } };
if( p.maintainer )
j["maintainer"] = p.maintainer.value();
j["maintainer"] = *p.maintainer;
if( p.tags.size() > 0 )
j["tags"] = p.tags;
@ -136,7 +136,7 @@ void to_json( json& j, const PCM_RESOURCE_REFERENCE& r )
j = json{ { "url", r.url }, { "update_timestamp", r.update_timestamp } };
if( r.sha256 )
j["sha256"] = r.sha256.value();
j["sha256"] = *r.sha256;
}
@ -154,13 +154,13 @@ void to_json( json& j, const PCM_REPOSITORY& r )
j = json{ { "name", r.name }, { "packages", r.packages } };
if( r.resources )
j["resources"] = r.resources.value();
j["resources"] = *r.resources;
if( r.manifests )
j["manifests"] = r.manifests.value();
j["manifests"] = *r.manifests;
if( r.maintainer )
j["maintainer"] = r.maintainer.value();
j["maintainer"] = *r.maintainer;
}

View File

@ -79,7 +79,7 @@ void PCM_TASK_MANAGER::DownloadAndInstall( const PCM_PACKAGE& aPackage, const wx
return;
}
int code = downloadFile( file_path.GetFullPath(), find_pkgver->download_url.value() );
int code = downloadFile( file_path.GetFullPath(), *find_pkgver->download_url );
if( code != CURLE_OK )
{
@ -168,7 +168,7 @@ void PCM_TASK_MANAGER::installDownloadedPackage( const PCM_PACKAGE& aPackage,
if( hash )
{
std::ifstream stream( aFilePath.GetFullPath().ToUTF8(), std::ios::binary );
hash_match = m_pcm->VerifyHash( stream, hash.value() );
hash_match = m_pcm->VerifyHash( stream, *hash );
}
if( !hash_match )

View File

@ -330,10 +330,12 @@ void CornerListToPolygon( SHAPE_POLY_SET& outline, std::vector<ROUNDED_CORNER>&
if( outlineIn.Side( pt ) > 0 )
{
VECTOR2I intersect = outlineIn.IntersectLines( SEG( prevPt, pt ) ).value();
outline.Append( intersect );
OPT_VECTOR2I intersect = outlineIn.IntersectLines( SEG( prevPt, pt ) );
wxCHECK_RET( intersect, wxT( "No solutions exist!" ) );
outline.Append( *intersect );
outline.Append( pt );
arcEnd = SEG( cornerPosition, arcCenter ).ReflectPoint( intersect );
arcEnd = SEG( cornerPosition, arcCenter ).ReflectPoint( *intersect );
break;
}

View File

@ -113,7 +113,7 @@ CIRCLE& CIRCLE::ConstructFromTanTanPt( const SEG& aLineA, const SEG& aLineB, con
// In this code, the prefix "h" denotes "the homothetic image"
OPT_VECTOR2I intersectCalc = aLineA.IntersectLines( aLineB );
wxCHECK_MSG( intersectCalc, *this, wxT( "Lines do not intersect but are not parallel?" ) );
intersectPoint = intersectCalc.value();
intersectPoint = *intersectCalc;
if( aP == intersectPoint )
{
@ -157,11 +157,11 @@ CIRCLE& CIRCLE::ConstructFromTanTanPt( const SEG& aLineA, const SEG& aLineB, con
wxCHECK_MSG( actTanA, *this, wxT( "No solutions exist!" ) );
// Find circle center by perpendicular intersection with the angle bisector
SEG perpendicularToTanA = aLineA.PerpendicularSeg( actTanA.value() );
SEG perpendicularToTanA = aLineA.PerpendicularSeg( *actTanA );
OPT_VECTOR2I actCenter = perpendicularToTanA.IntersectLines( anglebisector );
wxCHECK_MSG( actCenter, *this, wxT( "No solutions exist!" ) );
Center = actCenter.value();
Center = *actCenter;
Radius = aLineA.LineDistance( Center );
}
else
@ -172,11 +172,11 @@ CIRCLE& CIRCLE::ConstructFromTanTanPt( const SEG& aLineA, const SEG& aLineB, con
wxCHECK_MSG( actTanB, *this, wxT( "No solutions exist!" ) );
// Find circle center by perpendicular intersection with the angle bisector
SEG perpendicularToTanB = aLineB.PerpendicularSeg( actTanB.value() );
SEG perpendicularToTanB = aLineB.PerpendicularSeg( *actTanB );
OPT_VECTOR2I actCenter = perpendicularToTanB.IntersectLines( anglebisector );
wxCHECK_MSG( actCenter, *this, wxT( "No solutions exist!" ) );
Center = actCenter.value();
Center = *actCenter;
Radius = aLineB.LineDistance( Center );
}
}

View File

@ -135,14 +135,14 @@ SHAPE_ARC::SHAPE_ARC( const SEG& aSegmentA, const SEG& aSegmentB, int aRadius, i
}
else
{
VECTOR2I pToA = aSegmentA.B - p.value();
VECTOR2I pToB = aSegmentB.B - p.value();
VECTOR2I pToA = aSegmentA.B - *p;
VECTOR2I pToB = aSegmentB.B - *p;
if( pToA.EuclideanNorm() == 0 )
pToA = aSegmentA.A - p.value();
pToA = aSegmentA.A - *p;
if( pToB.EuclideanNorm() == 0 )
pToB = aSegmentB.A - p.value();
pToB = aSegmentB.A - *p;
EDA_ANGLE pToAangle( pToA );
EDA_ANGLE pToBangle( pToB );
@ -153,8 +153,8 @@ SHAPE_ARC::SHAPE_ARC( const SEG& aSegmentA, const SEG& aSegmentB, int aRadius, i
EDA_ANGLE angPC = pToAangle - alpha / 2;
VECTOR2I arcCenter;
arcCenter.x = p.value().x + KiROUND( distPC * angPC.Cos() );
arcCenter.y = p.value().y + KiROUND( distPC * angPC.Sin() );
arcCenter.x = p->x + KiROUND( distPC * angPC.Cos() );
arcCenter.y = p->y + KiROUND( distPC * angPC.Sin() );
// The end points of the arc are the orthogonal projected lines from the line segments
// to the center of the arc

View File

@ -78,7 +78,7 @@ int PL_DRAWING_TOOLS::PlaceItem( const TOOL_EVENT& aEvent )
m_toolMgr->RunAction( PL_ACTIONS::clearSelection, true );
std::string tool = aEvent.GetCommandStr().value();
std::string tool = *aEvent.GetCommandStr();
m_frame->PushTool( tool );
auto setCursor =
@ -226,7 +226,7 @@ int PL_DRAWING_TOOLS::DrawShape( const TOOL_EVENT& aEvent )
m_toolMgr->RunAction( PL_ACTIONS::clearSelection, true );
std::string tool = aEvent.GetCommandStr().value();
std::string tool = *aEvent.GetCommandStr();
m_frame->PushTool( tool );
auto setCursor =

View File

@ -117,7 +117,7 @@ int PL_EDIT_TOOL::Main( const TOOL_EVENT& aEvent )
unique_peers.insert( drawItem->GetPeer() );
}
std::string tool = aEvent.GetCommandStr().value();
std::string tool = *aEvent.GetCommandStr();
m_frame->PushTool( tool );
Activate();
@ -389,7 +389,7 @@ int PL_EDIT_TOOL::DoDelete( const TOOL_EVENT& aEvent )
int PL_EDIT_TOOL::DeleteItemCursor( const TOOL_EVENT& aEvent )
{
std::string tool = aEvent.GetCommandStr().value();
std::string tool = *aEvent.GetCommandStr();
PICKER_TOOL* picker = m_toolMgr->GetTool<PICKER_TOOL>();
// Deactivate other tools; particularly important if another PICKER is currently running

View File

@ -920,8 +920,8 @@ bool BOARD_DESIGN_SETTINGS::migrateSchema0to1()
return true;
}
int units = Get<int>( units_ptr ).value();
int precision = Get<int>( precision_ptr ).value();
int units = *Get<int>( units_ptr );
int precision = *Get<int>( precision_ptr );
// The enum maps directly to precision if the units is mils
int extraDigits = 0;

View File

@ -820,7 +820,7 @@ bool ConvertOutlineToPolygon( std::vector<PCB_SHAPE*>& aSegList, SHAPE_POLY_SET&
BOARD_ITEM* b = fetchOwner( *seg2 );
if( a && b )
(*aErrorHandler)( _( "(self-intersecting)" ), a, b, pt.value() );
(*aErrorHandler)( _( "(self-intersecting)" ), a, b, *pt );
}
selfIntersecting = true;

View File

@ -200,7 +200,7 @@ bool DRC_TEST_PROVIDER_COPPER_CLEARANCE::testTrackAgainstItem( PCB_TRACK* track,
drcItem->SetItems( track, other );
drcItem->SetViolatingRule( constraint.GetParentRule() );
reportViolation( drcItem, intersection.value(), layer );
reportViolation( drcItem, *intersection, layer );
return m_drcEngine->GetReportAllTrackErrors();
}

View File

@ -89,7 +89,7 @@ int MICROWAVE_TOOL::addMicrowaveFootprint( const TOOL_EVENT& aEvent )
MICROWAVE_PLACER placer( this, aEvent.Parameter<MICROWAVE_FOOTPRINT_SHAPE>() );
doInteractiveItemPlacement( aEvent.GetCommandStr().value(), &placer,
doInteractiveItemPlacement( *aEvent.GetCommandStr(), &placer,
_( "Place microwave feature" ),
IPO_REPEAT | IPO_ROTATE | IPO_FLIP );
@ -114,7 +114,7 @@ int MICROWAVE_TOOL::drawMicrowaveInductor( const TOOL_EVENT& aEvent )
KIGFX::VIEW_CONTROLS& controls = *getViewControls();
PCB_EDIT_FRAME& frame = *getEditFrame<PCB_EDIT_FRAME>();
std::string tool = aEvent.GetCommandStr().value();
std::string tool = *aEvent.GetCommandStr();
frame.PushTool( tool );
auto setCursor =

View File

@ -1212,10 +1212,10 @@ void PCB_DIM_RADIAL::updateGeometry()
OPT_VECTOR2I textSegEnd = segPolyIntersection( polyBox, textSeg );
if( arrowSegEnd )
arrowSeg.B = arrowSegEnd.value();
arrowSeg.B = *arrowSegEnd;
if( textSegEnd )
textSeg.B = textSegEnd.value();
textSeg.B = *textSegEnd;
m_shapes.emplace_back( new SHAPE_SEGMENT( arrowSeg ) );

View File

@ -559,7 +559,7 @@ PCBNEW_SETTINGS::PCBNEW_SETTINGS()
[&]()
{
if( std::optional<int> optval = Get<int>( "pcb_display.rotation_angle" ) )
Set( "editing.rotation_angle", optval.value() );
Set( "editing.rotation_angle", *optval );
try
{

View File

@ -1289,8 +1289,12 @@ void ALTIUM_PCB::HelperParseDimensions6Linear( const ADIMENSION6& aElem )
VECTOR2I directionNormalVector = VECTOR2I( -direction.y, direction.x );
SEG segm1( referencePoint0, referencePoint0 + directionNormalVector );
SEG segm2( referencePoint1, referencePoint1 + direction );
VECTOR2I intersection( segm1.Intersect( segm2, true, true ).value() );
dimension->SetEnd( intersection );
OPT_VECTOR2I intersection( segm1.Intersect( segm2, true, true ) );
if( !intersection )
THROW_IO_ERROR( wxT( "Invalid dimension. This should never happen." ) );
dimension->SetEnd( *intersection );
int height = static_cast<int>( EuclideanNorm( direction ) );

View File

@ -268,7 +268,7 @@ int LENGTH_TUNER_TOOL::MainLoop( const TOOL_EVENT& aEvent )
// Deselect all items
m_toolMgr->RunAction( PCB_ACTIONS::selectionClear, true );
std::string tool = aEvent.GetCommandStr().value();
std::string tool = *aEvent.GetCommandStr();
frame()->PushTool( tool );
auto setCursor =

View File

@ -1356,7 +1356,7 @@ SHOVE::SHOVE_STATUS SHOVE::shoveIteration( int aIter )
return SH_OK;
}
bool viaFixup = fixupViaCollisions( &currentLine, nearest.value() );
bool viaFixup = fixupViaCollisions( &currentLine, *nearest );
PNS_DBG( Dbg(), Message, wxString::Format( "iter %d: VF %d", aIter, viaFixup?1:0 ) );
@ -1443,7 +1443,7 @@ SHOVE::SHOVE_STATUS SHOVE::shoveIteration( int aIter )
st = onCollidingSegment( currentLine, (SEGMENT*) ni );
if( st == SH_TRY_WALK )
st = onCollidingSolid( currentLine, ni, nearest.value() );
st = onCollidingSolid( currentLine, ni, *nearest );
PNS_DBGN( Dbg(), EndGroup );
@ -1456,7 +1456,7 @@ SHOVE::SHOVE_STATUS SHOVE::shoveIteration( int aIter )
st = onCollidingArc( currentLine, static_cast<ARC*>( ni ) );
if( st == SH_TRY_WALK )
st = onCollidingSolid( currentLine, ni, nearest.value() );
st = onCollidingSolid( currentLine, ni, *nearest );
PNS_DBGN( Dbg(), EndGroup );
@ -1464,10 +1464,10 @@ SHOVE::SHOVE_STATUS SHOVE::shoveIteration( int aIter )
case ITEM::VIA_T:
PNS_DBG( Dbg(), BeginGroup, wxString::Format( "iter %d: collide-via (fixup: %d)", aIter, 0 ), 0 );
st = onCollidingVia( &currentLine, (VIA*) ni, nearest.value() );
st = onCollidingVia( &currentLine, (VIA*) ni, *nearest );
if( st == SH_TRY_WALK )
st = onCollidingSolid( currentLine, ni, nearest.value() );
st = onCollidingSolid( currentLine, ni, *nearest );
PNS_DBGN( Dbg(), EndGroup );
@ -1475,7 +1475,7 @@ SHOVE::SHOVE_STATUS SHOVE::shoveIteration( int aIter )
case ITEM::SOLID_T:
PNS_DBG( Dbg(), BeginGroup, wxString::Format( "iter %d: walk-solid ", aIter ), 0);
st = onCollidingSolid( currentLine, (SOLID*) ni, nearest.value() );
st = onCollidingSolid( currentLine, (SOLID*) ni, *nearest );
PNS_DBGN( Dbg(), EndGroup );

View File

@ -1487,7 +1487,7 @@ int ROUTER_TOOL::MainLoop( const TOOL_EVENT& aEvent )
// Deselect all items
m_toolMgr->RunAction( PCB_ACTIONS::selectionClear, true );
std::string tool = aEvent.GetCommandStr().value();
std::string tool = *aEvent.GetCommandStr();
frame->PushTool( tool );
auto setCursor =

View File

@ -966,7 +966,7 @@ int BOARD_EDITOR_CONTROL::PlaceFootprint( const TOOL_EVENT& aEvent )
m_toolMgr->RunAction( PCB_ACTIONS::selectionClear, true );
std::string tool = aEvent.GetCommandStr().value();
std::string tool = *aEvent.GetCommandStr();
m_frame->PushTool( tool );
auto setCursor =
@ -1490,7 +1490,7 @@ void BOARD_EDITOR_CONTROL::DoSetDrillOrigin( KIGFX::VIEW* aView, PCB_BASE_FRAME*
int BOARD_EDITOR_CONTROL::DrillOrigin( const TOOL_EVENT& aEvent )
{
std::string tool = aEvent.GetCommandStr().value();
std::string tool = *aEvent.GetCommandStr();
PCB_PICKER_TOOL* picker = m_toolMgr->GetTool<PCB_PICKER_TOOL>();
// Deactivate other tools; particularly important if another PICKER is currently running

View File

@ -1542,7 +1542,7 @@ int BOARD_INSPECTION_TOOL::ClearHighlight( const TOOL_EVENT& aEvent )
#if 0
int BOARD_INSPECTION_TOOL::HighlightNetTool( const TOOL_EVENT& aEvent )
{
std::string tool = aEvent.GetCommandStr().value();
std::string tool = *aEvent.GetCommandStr();
PCB_PICKER_TOOL* picker = m_toolMgr->GetTool<PCB_PICKER_TOOL>();
// Deactivate other tools; particularly important if another PICKER is currently running
@ -1576,7 +1576,7 @@ int BOARD_INSPECTION_TOOL::HighlightNetTool( const TOOL_EVENT& aEvent )
int BOARD_INSPECTION_TOOL::LocalRatsnestTool( const TOOL_EVENT& aEvent )
{
std::string tool = aEvent.GetCommandStr().value();
std::string tool = *aEvent.GetCommandStr();
PCB_PICKER_TOOL* picker = m_toolMgr->GetTool<PCB_PICKER_TOOL>();
BOARD* board = getModel<BOARD>();

View File

@ -557,7 +557,7 @@ int DRAWING_TOOL::InteractivePlaceWithPreview( const TOOL_EVENT& aEvent,
// do not capture or auto-pan until we start placing the table
SCOPED_DRAW_MODE scopedDrawMode( m_mode, MODE::TEXT );
std::string tool = aEvent.GetCommandStr().value();
std::string tool = *aEvent.GetCommandStr();
m_frame->PushTool( tool );
Activate();

View File

@ -313,7 +313,7 @@ int DRAWING_TOOL::DrawLine( const TOOL_EVENT& aEvent )
if( aEvent.HasPosition() )
startingPoint = getViewControls()->GetCursorPosition( !aEvent.DisableGridSnapping() );
std::string tool = aEvent.GetCommandStr().value();
std::string tool = *aEvent.GetCommandStr();
m_frame->PushTool( tool );
Activate();
@ -387,7 +387,7 @@ int DRAWING_TOOL::DrawRectangle( const TOOL_EVENT& aEvent )
if( aEvent.HasPosition() )
startingPoint = getViewControls()->GetCursorPosition( !aEvent.DisableGridSnapping() );
std::string tool = aEvent.GetCommandStr().value();
std::string tool = *aEvent.GetCommandStr();
m_frame->PushTool( tool );
Activate();
@ -447,7 +447,7 @@ int DRAWING_TOOL::DrawCircle( const TOOL_EVENT& aEvent )
if( aEvent.HasPosition() )
startingPoint = getViewControls()->GetCursorPosition( !aEvent.DisableGridSnapping() );
std::string tool = aEvent.GetCommandStr().value();
std::string tool = *aEvent.GetCommandStr();
m_frame->PushTool( tool );
Activate();
@ -495,7 +495,7 @@ int DRAWING_TOOL::DrawArc( const TOOL_EVENT& aEvent )
arc->SetShape( SHAPE_T::ARC );
arc->SetFlags( IS_NEW );
std::string tool = aEvent.GetCommandStr().value();
std::string tool = *aEvent.GetCommandStr();
m_frame->PushTool( tool );
Activate();
@ -553,7 +553,7 @@ int DRAWING_TOOL::PlaceImage( const TOOL_EVENT& aEvent )
m_view->AddToPreview( image->Clone() );
}
std::string tool = aEvent.GetCommandStr().value();
std::string tool = *aEvent.GetCommandStr();
m_frame->PushTool( tool );
auto setCursor =
[&]()
@ -797,7 +797,7 @@ int DRAWING_TOOL::PlaceText( const TOOL_EVENT& aEvent )
m_toolMgr->RunAction( PCB_ACTIONS::selectionClear, true );
std::string tool = aEvent.GetCommandStr().value();
std::string tool = *aEvent.GetCommandStr();
m_frame->PushTool( tool );
Activate();
@ -1079,7 +1079,7 @@ int DRAWING_TOOL::DrawDimension( const TOOL_EVENT& aEvent )
m_toolMgr->RunAction( PCB_ACTIONS::selectionClear, true );
std::string tool = aEvent.GetCommandStr().value();
std::string tool = *aEvent.GetCommandStr();
m_frame->PushTool( tool );
Activate();
@ -1560,7 +1560,7 @@ int DRAWING_TOOL::PlaceImportedGraphics( const TOOL_EVENT& aEvent )
m_toolMgr->RunAction( PCB_ACTIONS::selectionClear, true );
m_toolMgr->RunAction( PCB_ACTIONS::selectItems, true, &selectedItems );
std::string tool = aEvent.GetCommandStr().value();
std::string tool = *aEvent.GetCommandStr();
m_frame->PushTool( tool );
auto setCursor =
@ -1659,7 +1659,7 @@ int DRAWING_TOOL::SetAnchor( const TOOL_EVENT& aEvent )
m_toolMgr->RunAction( PCB_ACTIONS::selectionClear, true );
std::string tool = aEvent.GetCommandStr().value();
std::string tool = *aEvent.GetCommandStr();
m_frame->PushTool( tool );
auto setCursor =
@ -1833,7 +1833,7 @@ bool DRAWING_TOOL::drawShape( const std::string& aTool, PCB_SHAPE** aGraphic,
m_toolMgr->RunAction( ACTIONS::refreshPreview );
if( aStartingPoint )
m_toolMgr->PrimeTool( aStartingPoint.value() );
m_toolMgr->PrimeTool( *aStartingPoint );
// Main loop: keep receiving events
while( TOOL_EVENT* evt = Wait() )
@ -1957,7 +1957,7 @@ bool DRAWING_TOOL::drawShape( const std::string& aTool, PCB_SHAPE** aGraphic,
if( aStartingPoint )
{
cursorPos = aStartingPoint.value();
cursorPos = *aStartingPoint;
aStartingPoint = std::nullopt;
}
@ -2202,7 +2202,7 @@ bool DRAWING_TOOL::drawArc( const std::string& aTool, PCB_SHAPE** aGraphic,
m_toolMgr->RunAction( ACTIONS::refreshPreview );
if( aStartingPoint )
m_toolMgr->PrimeTool(aStartingPoint.value() );
m_toolMgr->PrimeTool( *aStartingPoint );
// Main loop: keep receiving events
while( TOOL_EVENT* evt = Wait() )
@ -2498,7 +2498,7 @@ int DRAWING_TOOL::DrawZone( const TOOL_EVENT& aEvent )
status.SetTextColor( wxColour( 255, 0, 0 ) );
status.SetText( _( "Self-intersecting polygons are not allowed" ) );
std::string tool = aEvent.GetCommandStr().value();
std::string tool = *aEvent.GetCommandStr();
m_frame->PushTool( tool );
auto setCursor =
@ -3033,26 +3033,27 @@ int DRAWING_TOOL::DrawVia( const TOOL_EVENT& aEvent )
VECTOR2I trackStart = track->GetStart();
VECTOR2I trackEnd = track->GetEnd();
SEG trackSeg( trackStart, trackEnd );
VECTOR2I joint1;
VECTOR2I joint2;
OPT_VECTOR2I joint1;
OPT_VECTOR2I joint2;
auto insertChevron =
[&]()
{
if( ( trackStart - joint1 ).SquaredEuclideanNorm()
> ( trackStart - joint2 ).SquaredEuclideanNorm() )
if( ( trackStart - *joint1 ).SquaredEuclideanNorm()
> ( trackStart - *joint2 ).SquaredEuclideanNorm() )
{
std::swap( joint1, joint2 );
}
aCommit.Modify( track );
track->SetStart( trackStart );
track->SetEnd( joint1 );
track->SetEnd( *joint1 );
PCB_TRACK* newTrack = dynamic_cast<PCB_TRACK*>( track->Clone() );
const_cast<KIID&>( newTrack->m_Uuid ) = KIID();
newTrack->SetStart( joint1 );
newTrack->SetStart( *joint1 );
newTrack->SetEnd( viaPos );
aCommit.Add( newTrack );
@ -3060,13 +3061,13 @@ int DRAWING_TOOL::DrawVia( const TOOL_EVENT& aEvent )
const_cast<KIID&>( newTrack->m_Uuid ) = KIID();
newTrack->SetStart( viaPos );
newTrack->SetEnd( joint2 );
newTrack->SetEnd( *joint2 );
aCommit.Add( newTrack );
newTrack = dynamic_cast<PCB_TRACK*>( track->Clone() );
const_cast<KIID&>( newTrack->m_Uuid ) = KIID();
newTrack->SetStart( joint2 );
newTrack->SetStart( *joint2 );
newTrack->SetEnd( trackEnd );
aCommit.Add( newTrack );
};
@ -3115,8 +3116,11 @@ int DRAWING_TOOL::DrawVia( const TOOL_EVENT& aEvent )
if( track->GetBoundingBox().Contains( viaPos ) )
{
joint1 = trackSeg.Intersect( horiz, true, true ).value();
joint2 = trackSeg.Intersect( vert, true, true ).value();
joint1 = trackSeg.Intersect( horiz, true, true );
joint2 = trackSeg.Intersect( vert, true, true );
if( !joint1 || !joint2 )
return false;
insertChevron();
return true;
@ -3207,7 +3211,7 @@ int DRAWING_TOOL::DrawVia( const TOOL_EVENT& aEvent )
SCOPED_DRAW_MODE scopedDrawMode( m_mode, MODE::VIA );
doInteractiveItemPlacement( aEvent.GetCommandStr().value(), &placer, _( "Place via" ),
doInteractiveItemPlacement( *aEvent.GetCommandStr(), &placer, _( "Place via" ),
IPO_REPEAT | IPO_SINGLE_CLICK );
return 0;

View File

@ -361,10 +361,14 @@ int EDIT_TOOL::DragArcTrack( const TOOL_EVENT& aEvent )
SEG tanEnd = SEG( arcCenter, theArc->GetEnd() ).PerpendicularSeg( theArc->GetEnd() );
//Ensure the tangent segments are in the correct orientation
VECTOR2I tanIntersect = tanStart.IntersectLines( tanEnd ).value();
tanStart.A = tanIntersect;
OPT_VECTOR2I tanIntersect = tanStart.IntersectLines( tanEnd );
if( !tanIntersect )
return 0;
tanStart.A = *tanIntersect;
tanStart.B = theArc->GetStart();
tanEnd.A = tanIntersect;
tanEnd.A = *tanIntersect;
tanEnd.B = theArc->GetEnd();
auto getUniqueTrackAtAnchorCollinear =
@ -438,7 +442,8 @@ int EDIT_TOOL::DragArcTrack( const TOOL_EVENT& aEvent )
}
// Recalculate intersection point
tanIntersect = tanStart.IntersectLines( tanEnd ).value();
if( tanIntersect = tanStart.IntersectLines( tanEnd ); !tanIntersect )
return 0;
auto isTrackStartClosestToArcStart =
[&]( PCB_TRACK* aTrack ) -> bool
@ -482,8 +487,8 @@ int EDIT_TOOL::DragArcTrack( const TOOL_EVENT& aEvent )
auto getFurthestPointToTanInterstect =
[&]( VECTOR2I& aPointA, VECTOR2I& aPointB ) -> VECTOR2I
{
if( ( aPointA - tanIntersect ).EuclideanNorm()
> ( aPointB - tanIntersect ).EuclideanNorm() )
if( ( aPointA - *tanIntersect ).EuclideanNorm()
> ( aPointB - *tanIntersect ).EuclideanNorm() )
{
return aPointA;
}
@ -505,8 +510,8 @@ int EDIT_TOOL::DragArcTrack( const TOOL_EVENT& aEvent )
VECTOR2I maxTanPtStart = tanStart.LineProject( maxTanCircle.Center );
VECTOR2I maxTanPtEnd = tanEnd.LineProject( maxTanCircle.Center );
SEG cSegTanStart( maxTanPtStart, tanIntersect );
SEG cSegTanEnd( maxTanPtEnd, tanIntersect );
SEG cSegTanStart( maxTanPtStart, *tanIntersect );
SEG cSegTanEnd( maxTanPtEnd, *tanIntersect );
SEG cSegChord( maxTanPtStart, maxTanPtEnd );
int cSegTanStartSide = cSegTanStart.Side( theArc->GetMid() );
@ -1384,7 +1389,7 @@ int EDIT_TOOL::Remove( const TOOL_EVENT& aEvent )
return 0;
}
std::string tool = aEvent.GetCommandStr().value();
std::string tool = *aEvent.GetCommandStr();
editFrame->PushTool( tool );
std::vector<BOARD_ITEM*> lockedItems;
@ -2030,7 +2035,7 @@ bool EDIT_TOOL::pickReferencePoint( const wxString& aTooltip, const wxString& aS
m_statusPopup->Hide();
if( pickedPoint )
aReferencePoint = pickedPoint.value();
aReferencePoint = *pickedPoint;
return pickedPoint.has_value();
}

View File

@ -375,7 +375,7 @@ int EDIT_TOOL::doMoveSelection( TOOL_EVENT aEvent, bool aPickReference )
if( selection.Empty() )
return 0;
std::string tool = aEvent.GetCommandStr().value();
std::string tool = *aEvent.GetCommandStr();
editFrame->PushTool( tool );
Activate();

View File

@ -299,7 +299,7 @@ int PAD_TOOL::EnumeratePads( const TOOL_EVENT& aEvent )
m_toolMgr->RunAction( PCB_ACTIONS::selectionClear, true );
std::string tool = aEvent.GetCommandStr().value();
std::string tool = *aEvent.GetCommandStr();
frame()->PushTool( tool );
VECTOR2I oldCursorPos; // store the previous mouse cursor position, during mouse drag
@ -555,7 +555,7 @@ int PAD_TOOL::PlacePad( const TOOL_EVENT& aEvent )
PAD_PLACER placer( this );
doInteractiveItemPlacement( aEvent.GetCommandStr().value(), &placer, _( "Place pad" ),
doInteractiveItemPlacement( *aEvent.GetCommandStr(), &placer, _( "Place pad" ),
IPO_REPEAT | IPO_SINGLE_CLICK | IPO_ROTATE | IPO_FLIP );
return 0;

View File

@ -499,7 +499,7 @@ int PCB_CONTROL::GridSetOrigin( const TOOL_EVENT& aEvent )
if( m_isFootprintEditor && !getEditFrame<PCB_BASE_EDIT_FRAME>()->GetModel() )
return 0;
std::string tool = aEvent.GetCommandStr().value();
std::string tool = *aEvent.GetCommandStr();
PCB_PICKER_TOOL* picker = m_toolMgr->GetTool<PCB_PICKER_TOOL>();
if( !picker ) // Happens in footprint wizard
@ -539,7 +539,7 @@ int PCB_CONTROL::DeleteItemCursor( const TOOL_EVENT& aEvent )
if( m_isFootprintEditor && !m_frame->GetBoard()->GetFirstFootprint() )
return 0;
std::string tool = aEvent.GetCommandStr().value();
std::string tool = *aEvent.GetCommandStr();
PCB_PICKER_TOOL* picker = m_toolMgr->GetTool<PCB_PICKER_TOOL>();
m_pickerItem = nullptr;

View File

@ -197,7 +197,7 @@ int PCB_VIEWER_TOOLS::MeasureTool( const TOOL_EVENT& aEvent )
auto& view = *getView();
auto& controls = *getViewControls();
std::string tool = aEvent.GetCommandStr().value();
std::string tool = *aEvent.GetCommandStr();
frame()->PushTool( tool );
TWO_POINT_GEOMETRY_MANAGER twoPtMgr;