diff --git a/common/settings/color_settings.cpp b/common/settings/color_settings.cpp index 6fffb3e7ac..325d89dc14 100644 --- a/common/settings/color_settings.cpp +++ b/common/settings/color_settings.cpp @@ -264,10 +264,10 @@ COLOR_SETTINGS::COLOR_SETTINGS( const wxString& aFilename, bool aAbsolutePath ) [&]() { if( std::optional optval = Get( "board.grid" ) ) - Set( "board.page_limits", optval.value() ); + Set( "board.page_limits", *optval ); if( std::optional optval = Get( "schematic.grid" ) ) - Set( "schematic.page_limits", optval.value() ); + Set( "schematic.page_limits", *optval ); return true; } ); diff --git a/common/tool/tool_event.cpp b/common/tool/tool_event.cpp index 26d13cbd61..c19405a526 100644 --- a/common/tool/tool_event.cpp +++ b/common/tool/tool_event.cpp @@ -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 ); } diff --git a/common/tool/tool_manager.cpp b/common/tool/tool_manager.cpp index 6d56c02c00..e642a1f4e4 100644 --- a/common/tool/tool_manager.cpp +++ b/common/tool/tool_manager.cpp @@ -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 ); diff --git a/common/tool/zoom_tool.cpp b/common/tool/zoom_tool.cpp index 197d9c1b72..e905fc6d34 100644 --- a/common/tool/zoom_tool.cpp +++ b/common/tool/zoom_tool.cpp @@ -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 = diff --git a/eeschema/eeschema_settings.cpp b/eeschema/eeschema_settings.cpp index 4352636b76..cdecd00d60 100644 --- a/eeschema/eeschema_settings.cpp +++ b/eeschema/eeschema_settings.cpp @@ -771,7 +771,7 @@ bool EESCHEMA_SETTINGS::migrateBomSettings() if( !Contains( "bom.plugins" ) ) return false; - wxString list = Get( "bom.plugins" ).value(); + wxString list = *Get( "bom.plugins" ); BOM_CFG_PARSER cfg_parser( &m_BomPanel.plugins, TO_UTF8( list ), wxT( "plugins" ) ); diff --git a/eeschema/schematic_settings.cpp b/eeschema/schematic_settings.cpp index 3931b6de6a..a7c4d04911 100644 --- a/eeschema/schematic_settings.cpp +++ b/eeschema/schematic_settings.cpp @@ -225,7 +225,7 @@ SCHEMATIC_SETTINGS::SCHEMATIC_SETTINGS( JSON_SETTINGS* aParent, const std::strin std::optional tor = Get( "drawing.text_offset_ratio" ); if( tor ) - Set( "drawing.label_size_ratio", tor.value() ); + Set( "drawing.label_size_ratio", *tor ); return true; } ); diff --git a/eeschema/tools/ee_selection_tool.cpp b/eeschema/tools/ee_selection_tool.cpp index 561ab4bc3c..19743c0082 100644 --- a/eeschema/tools/ee_selection_tool.cpp +++ b/eeschema/tools/ee_selection_tool.cpp @@ -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( 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( 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() ); m_toolMgr->RunAction( EE_ACTIONS::unfoldBus, true, net ); diff --git a/eeschema/tools/sch_drawing_tools.cpp b/eeschema/tools/sch_drawing_tools.cpp index b7a31b7e97..e7e8d7fb1f 100644 --- a/eeschema/tools/sch_drawing_tools.cpp +++ b/eeschema/tools/sch_drawing_tools.cpp @@ -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() ) { diff --git a/eeschema/tools/sch_edit_tool.cpp b/eeschema/tools/sch_edit_tool.cpp index 9c3a9abc9e..871f95a062 100644 --- a/eeschema/tools/sch_edit_tool.cpp +++ b/eeschema/tools/sch_edit_tool.cpp @@ -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(); m_toolMgr->RunAction( EE_ACTIONS::clearSelection, true ); diff --git a/eeschema/tools/sch_editor_control.cpp b/eeschema/tools/sch_editor_control.cpp index 2879b75af7..78674b5ada 100644 --- a/eeschema/tools/sch_editor_control.cpp +++ b/eeschema/tools/sch_editor_control.cpp @@ -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(); // Deactivate other tools; particularly important if another PICKER is currently running diff --git a/eeschema/tools/sch_line_wire_bus_tool.cpp b/eeschema/tools/sch_line_wire_bus_tool.cpp index d7b0d360f6..c2db7063d1 100644 --- a/eeschema/tools/sch_line_wire_bus_tool.cpp +++ b/eeschema/tools/sch_line_wire_bus_tool.cpp @@ -300,7 +300,7 @@ int SCH_LINE_WIRE_BUS_TOOL::DrawSegments( const TOOL_EVENT& aEvent ) DRAW_SEGMENT_EVENT_PARAMS* params = aEvent.Parameter(); - 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!" ); diff --git a/eeschema/tools/sch_move_tool.cpp b/eeschema/tools/sch_move_tool.cpp index 0565117bae..002b36deec 100644 --- a/eeschema/tools/sch_move_tool.cpp +++ b/eeschema/tools/sch_move_tool.cpp @@ -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( 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 ) { diff --git a/eeschema/tools/symbol_editor_drawing_tools.cpp b/eeschema/tools/symbol_editor_drawing_tools.cpp index b2f00f5284..6ce9fb8f81 100644 --- a/eeschema/tools/symbol_editor_drawing_tools.cpp +++ b/eeschema/tools/symbol_editor_drawing_tools.cpp @@ -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 = diff --git a/eeschema/tools/symbol_editor_edit_tool.cpp b/eeschema/tools/symbol_editor_edit_tool.cpp index f6833d66bc..7ab14f50aa 100644 --- a/eeschema/tools/symbol_editor_edit_tool.cpp +++ b/eeschema/tools/symbol_editor_edit_tool.cpp @@ -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(); m_toolMgr->RunAction( EE_ACTIONS::clearSelection, true ); diff --git a/eeschema/tools/symbol_editor_move_tool.cpp b/eeschema/tools/symbol_editor_move_tool.cpp index 2345be883a..3b2328f38a 100644 --- a/eeschema/tools/symbol_editor_move_tool.cpp +++ b/eeschema/tools/symbol_editor_move_tool.cpp @@ -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(); diff --git a/gerbview/tools/gerbview_inspection_tool.cpp b/gerbview/tools/gerbview_inspection_tool.cpp index 08c5416bfa..85380da3f5 100644 --- a/gerbview/tools/gerbview_inspection_tool.cpp +++ b/gerbview/tools/gerbview_inspection_tool.cpp @@ -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 = diff --git a/kicad/pcm/dialogs/panel_packages_view.cpp b/kicad/pcm/dialogs/panel_packages_view.cpp index 575d7948fe..b7483bdcfe 100644 --- a/kicad/pcm/dialogs/panel_packages_view.cpp +++ b/kicad/pcm/dialogs/panel_packages_view.cpp @@ -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 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(); @@ -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(); diff --git a/kicad/pcm/pcm.cpp b/kicad/pcm/pcm.cpp index 92bf2f3843..6ffcc6b2e5 100644 --- a/kicad/pcm/pcm.cpp +++ b/kicad/pcm/pcm.cpp @@ -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& aHash, - std::vector& aPackages, - PROGRESS_REPORTER* aReporter ) + std::vector& 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 ) diff --git a/kicad/pcm/pcm_data.cpp b/kicad/pcm/pcm_data.cpp index 572fde3840..a9b02704ec 100644 --- a/kicad/pcm/pcm_data.cpp +++ b/kicad/pcm/pcm_data.cpp @@ -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; } diff --git a/kicad/pcm/pcm_task_manager.cpp b/kicad/pcm/pcm_task_manager.cpp index c0f8319c7a..325fdbb6b5 100644 --- a/kicad/pcm/pcm_task_manager.cpp +++ b/kicad/pcm/pcm_task_manager.cpp @@ -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 ) diff --git a/libs/kimath/src/convert_basic_shapes_to_polygon.cpp b/libs/kimath/src/convert_basic_shapes_to_polygon.cpp index 1fd241a5d8..413e7fc2ab 100644 --- a/libs/kimath/src/convert_basic_shapes_to_polygon.cpp +++ b/libs/kimath/src/convert_basic_shapes_to_polygon.cpp @@ -330,10 +330,12 @@ void CornerListToPolygon( SHAPE_POLY_SET& outline, std::vector& 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; } diff --git a/libs/kimath/src/geometry/circle.cpp b/libs/kimath/src/geometry/circle.cpp index ccef4b14c1..41bbe4afd6 100644 --- a/libs/kimath/src/geometry/circle.cpp +++ b/libs/kimath/src/geometry/circle.cpp @@ -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 ); } } diff --git a/libs/kimath/src/geometry/shape_arc.cpp b/libs/kimath/src/geometry/shape_arc.cpp index f9e321bbe6..58adb3ec45 100644 --- a/libs/kimath/src/geometry/shape_arc.cpp +++ b/libs/kimath/src/geometry/shape_arc.cpp @@ -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 diff --git a/pagelayout_editor/tools/pl_drawing_tools.cpp b/pagelayout_editor/tools/pl_drawing_tools.cpp index bf130b8f67..714f2693cf 100644 --- a/pagelayout_editor/tools/pl_drawing_tools.cpp +++ b/pagelayout_editor/tools/pl_drawing_tools.cpp @@ -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 = diff --git a/pagelayout_editor/tools/pl_edit_tool.cpp b/pagelayout_editor/tools/pl_edit_tool.cpp index 598d501303..dfcd547b96 100644 --- a/pagelayout_editor/tools/pl_edit_tool.cpp +++ b/pagelayout_editor/tools/pl_edit_tool.cpp @@ -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(); // Deactivate other tools; particularly important if another PICKER is currently running diff --git a/pcbnew/board_design_settings.cpp b/pcbnew/board_design_settings.cpp index 771d1f051d..1e2bfc7a87 100644 --- a/pcbnew/board_design_settings.cpp +++ b/pcbnew/board_design_settings.cpp @@ -920,8 +920,8 @@ bool BOARD_DESIGN_SETTINGS::migrateSchema0to1() return true; } - int units = Get( units_ptr ).value(); - int precision = Get( precision_ptr ).value(); + int units = *Get( units_ptr ); + int precision = *Get( precision_ptr ); // The enum maps directly to precision if the units is mils int extraDigits = 0; diff --git a/pcbnew/convert_shape_list_to_polygon.cpp b/pcbnew/convert_shape_list_to_polygon.cpp index b33b595617..c74bde4dcc 100644 --- a/pcbnew/convert_shape_list_to_polygon.cpp +++ b/pcbnew/convert_shape_list_to_polygon.cpp @@ -820,7 +820,7 @@ bool ConvertOutlineToPolygon( std::vector& 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; diff --git a/pcbnew/drc/drc_test_provider_copper_clearance.cpp b/pcbnew/drc/drc_test_provider_copper_clearance.cpp index d3f4f9730b..5ca6d0cf5f 100644 --- a/pcbnew/drc/drc_test_provider_copper_clearance.cpp +++ b/pcbnew/drc/drc_test_provider_copper_clearance.cpp @@ -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(); } diff --git a/pcbnew/microwave/microwave_tool.cpp b/pcbnew/microwave/microwave_tool.cpp index 2ea2c82b5e..0a233103bf 100644 --- a/pcbnew/microwave/microwave_tool.cpp +++ b/pcbnew/microwave/microwave_tool.cpp @@ -89,7 +89,7 @@ int MICROWAVE_TOOL::addMicrowaveFootprint( const TOOL_EVENT& aEvent ) MICROWAVE_PLACER placer( this, aEvent.Parameter() ); - 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(); - std::string tool = aEvent.GetCommandStr().value(); + std::string tool = *aEvent.GetCommandStr(); frame.PushTool( tool ); auto setCursor = diff --git a/pcbnew/pcb_dimension.cpp b/pcbnew/pcb_dimension.cpp index c071a9051b..ae22f74f10 100644 --- a/pcbnew/pcb_dimension.cpp +++ b/pcbnew/pcb_dimension.cpp @@ -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 ) ); diff --git a/pcbnew/pcbnew_settings.cpp b/pcbnew/pcbnew_settings.cpp index cad8bacc9a..d726c526ba 100644 --- a/pcbnew/pcbnew_settings.cpp +++ b/pcbnew/pcbnew_settings.cpp @@ -559,7 +559,7 @@ PCBNEW_SETTINGS::PCBNEW_SETTINGS() [&]() { if( std::optional optval = Get( "pcb_display.rotation_angle" ) ) - Set( "editing.rotation_angle", optval.value() ); + Set( "editing.rotation_angle", *optval ); try { diff --git a/pcbnew/plugins/altium/altium_pcb.cpp b/pcbnew/plugins/altium/altium_pcb.cpp index e3b9e5a918..2ec820b044 100644 --- a/pcbnew/plugins/altium/altium_pcb.cpp +++ b/pcbnew/plugins/altium/altium_pcb.cpp @@ -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( EuclideanNorm( direction ) ); diff --git a/pcbnew/router/length_tuner_tool.cpp b/pcbnew/router/length_tuner_tool.cpp index 76c15330f4..48ff85072a 100644 --- a/pcbnew/router/length_tuner_tool.cpp +++ b/pcbnew/router/length_tuner_tool.cpp @@ -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 = diff --git a/pcbnew/router/pns_shove.cpp b/pcbnew/router/pns_shove.cpp index df20ba9e89..082bd8a6b6 100644 --- a/pcbnew/router/pns_shove.cpp +++ b/pcbnew/router/pns_shove.cpp @@ -1356,7 +1356,7 @@ SHOVE::SHOVE_STATUS SHOVE::shoveIteration( int aIter ) return SH_OK; } - bool viaFixup = fixupViaCollisions( ¤tLine, nearest.value() ); + bool viaFixup = fixupViaCollisions( ¤tLine, *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( 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( ¤tLine, (VIA*) ni, nearest.value() ); + st = onCollidingVia( ¤tLine, (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 ); diff --git a/pcbnew/router/router_tool.cpp b/pcbnew/router/router_tool.cpp index 5721f53256..55ecca3cb4 100644 --- a/pcbnew/router/router_tool.cpp +++ b/pcbnew/router/router_tool.cpp @@ -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 = diff --git a/pcbnew/tools/board_editor_control.cpp b/pcbnew/tools/board_editor_control.cpp index 16f7a6d2ab..c27e3bbe7c 100644 --- a/pcbnew/tools/board_editor_control.cpp +++ b/pcbnew/tools/board_editor_control.cpp @@ -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(); // Deactivate other tools; particularly important if another PICKER is currently running diff --git a/pcbnew/tools/board_inspection_tool.cpp b/pcbnew/tools/board_inspection_tool.cpp index 417341f651..be4d2c0cba 100644 --- a/pcbnew/tools/board_inspection_tool.cpp +++ b/pcbnew/tools/board_inspection_tool.cpp @@ -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(); // 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(); BOARD* board = getModel(); diff --git a/pcbnew/tools/drawing_stackup_table_tool.cpp b/pcbnew/tools/drawing_stackup_table_tool.cpp index 510dc38a93..905f68c917 100644 --- a/pcbnew/tools/drawing_stackup_table_tool.cpp +++ b/pcbnew/tools/drawing_stackup_table_tool.cpp @@ -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(); diff --git a/pcbnew/tools/drawing_tool.cpp b/pcbnew/tools/drawing_tool.cpp index a5cf5372fd..9fd5d71fda 100644 --- a/pcbnew/tools/drawing_tool.cpp +++ b/pcbnew/tools/drawing_tool.cpp @@ -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( track->Clone() ); const_cast( 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( newTrack->m_Uuid ) = KIID(); newTrack->SetStart( viaPos ); - newTrack->SetEnd( joint2 ); + newTrack->SetEnd( *joint2 ); aCommit.Add( newTrack ); newTrack = dynamic_cast( track->Clone() ); const_cast( 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; diff --git a/pcbnew/tools/edit_tool.cpp b/pcbnew/tools/edit_tool.cpp index 9cb7679dcc..8cb7be994f 100644 --- a/pcbnew/tools/edit_tool.cpp +++ b/pcbnew/tools/edit_tool.cpp @@ -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 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(); } diff --git a/pcbnew/tools/edit_tool_move_fct.cpp b/pcbnew/tools/edit_tool_move_fct.cpp index 16bce45a18..bd721ca3ad 100644 --- a/pcbnew/tools/edit_tool_move_fct.cpp +++ b/pcbnew/tools/edit_tool_move_fct.cpp @@ -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(); diff --git a/pcbnew/tools/pad_tool.cpp b/pcbnew/tools/pad_tool.cpp index 37ed6364c2..95e20e8907 100644 --- a/pcbnew/tools/pad_tool.cpp +++ b/pcbnew/tools/pad_tool.cpp @@ -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; diff --git a/pcbnew/tools/pcb_control.cpp b/pcbnew/tools/pcb_control.cpp index a488d4ee9e..aaeb1f54a8 100644 --- a/pcbnew/tools/pcb_control.cpp +++ b/pcbnew/tools/pcb_control.cpp @@ -499,7 +499,7 @@ int PCB_CONTROL::GridSetOrigin( const TOOL_EVENT& aEvent ) if( m_isFootprintEditor && !getEditFrame()->GetModel() ) return 0; - std::string tool = aEvent.GetCommandStr().value(); + std::string tool = *aEvent.GetCommandStr(); PCB_PICKER_TOOL* picker = m_toolMgr->GetTool(); 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(); m_pickerItem = nullptr; diff --git a/pcbnew/tools/pcb_viewer_tools.cpp b/pcbnew/tools/pcb_viewer_tools.cpp index 485ea3b897..0d56f8f947 100644 --- a/pcbnew/tools/pcb_viewer_tools.cpp +++ b/pcbnew/tools/pcb_viewer_tools.cpp @@ -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;