2019-04-29 20:38:05 +00:00
|
|
|
/*
|
|
|
|
* This program source code file is part of KiCad, a free EDA CAD application.
|
|
|
|
*
|
2023-01-01 23:37:24 +00:00
|
|
|
* Copyright (C) 2019-2023 CERN
|
|
|
|
* Copyright (C) 2019-2023 KiCad Developers, see AUTHORS.txt for contributors.
|
2019-04-29 20:38:05 +00:00
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU General Public License
|
|
|
|
* as published by the Free Software Foundation; either version 2
|
|
|
|
* of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, you may find one here:
|
|
|
|
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
|
|
|
|
* or you may search the http://www.gnu.org website for the version 2 license,
|
|
|
|
* or you may write to the Free Software Foundation, Inc.,
|
|
|
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
|
|
|
|
*/
|
|
|
|
|
2021-02-24 13:48:02 +00:00
|
|
|
#include <sch_symbol.h>
|
2019-06-01 15:28:39 +00:00
|
|
|
#include <id.h>
|
2019-06-01 18:36:49 +00:00
|
|
|
#include <kiway.h>
|
2024-01-07 17:20:34 +00:00
|
|
|
#include <kiplatform/ui.h>
|
2019-04-29 20:38:05 +00:00
|
|
|
#include <confirm.h>
|
2023-03-09 11:25:32 +00:00
|
|
|
#include <string_utils.h>
|
2023-09-18 23:52:27 +00:00
|
|
|
#include <gal/graphics_abstraction_layer.h>
|
2019-04-29 20:38:05 +00:00
|
|
|
#include <tool/conditional_menu.h>
|
|
|
|
#include <tool/selection_conditions.h>
|
2019-06-08 21:48:22 +00:00
|
|
|
#include <tools/ee_actions.h>
|
|
|
|
#include <tools/ee_inspection_tool.h>
|
|
|
|
#include <tools/ee_selection_tool.h>
|
|
|
|
#include <tools/ee_selection.h>
|
2023-03-03 22:36:07 +00:00
|
|
|
#include <sim/simulator_frame.h>
|
2019-04-29 20:38:05 +00:00
|
|
|
#include <sch_edit_frame.h>
|
2020-10-31 01:27:16 +00:00
|
|
|
#include <symbol_edit_frame.h>
|
2020-12-25 23:37:01 +00:00
|
|
|
#include <symbol_viewer_frame.h>
|
2019-04-29 20:38:05 +00:00
|
|
|
#include <eda_doc.h>
|
2021-02-19 14:51:18 +00:00
|
|
|
#include <sch_marker.h>
|
2019-06-01 18:36:49 +00:00
|
|
|
#include <project.h>
|
2023-09-28 03:04:53 +00:00
|
|
|
#include <project_sch.h>
|
2022-03-26 14:22:31 +00:00
|
|
|
#include <dialogs/html_message_box.h>
|
2020-11-03 19:24:05 +00:00
|
|
|
#include <dialogs/dialog_erc.h>
|
2023-03-09 17:41:18 +00:00
|
|
|
#include <dialogs/dialog_book_reporter.h>
|
2023-03-09 11:25:32 +00:00
|
|
|
#include <widgets/wx_html_report_box.h>
|
2023-03-09 17:41:18 +00:00
|
|
|
#include <widgets/symbol_diff_widget.h>
|
2020-01-07 17:12:59 +00:00
|
|
|
#include <math/util.h> // for KiROUND
|
2019-04-29 20:38:05 +00:00
|
|
|
|
|
|
|
|
2020-11-03 19:24:05 +00:00
|
|
|
EE_INSPECTION_TOOL::EE_INSPECTION_TOOL() :
|
2023-03-13 16:03:48 +00:00
|
|
|
EE_TOOL_BASE<SCH_BASE_FRAME>( "eeschema.InspectionTool" )
|
2019-04-29 20:38:05 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2019-05-10 17:19:48 +00:00
|
|
|
bool EE_INSPECTION_TOOL::Init()
|
2019-04-29 20:38:05 +00:00
|
|
|
{
|
2019-05-12 11:49:58 +00:00
|
|
|
EE_TOOL_BASE::Init();
|
2019-04-29 20:38:05 +00:00
|
|
|
|
|
|
|
// Add inspection actions to the selection tool menu
|
|
|
|
//
|
|
|
|
CONDITIONAL_MENU& selToolMenu = m_selectionTool->GetToolMenu().GetMenu();
|
|
|
|
|
2021-12-30 16:51:04 +00:00
|
|
|
selToolMenu.AddItem( EE_ACTIONS::excludeMarker, EE_CONDITIONS::SingleNonExcludedMarker, 100 );
|
2021-02-19 14:51:18 +00:00
|
|
|
|
2021-06-10 18:51:46 +00:00
|
|
|
selToolMenu.AddItem( EE_ACTIONS::showDatasheet,
|
|
|
|
EE_CONDITIONS::SingleSymbol && EE_CONDITIONS::Idle, 220 );
|
2019-04-29 20:38:05 +00:00
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2023-04-12 10:50:56 +00:00
|
|
|
void EE_INSPECTION_TOOL::Reset( RESET_REASON aReason )
|
|
|
|
{
|
|
|
|
EE_TOOL_BASE::Reset( aReason );
|
|
|
|
|
|
|
|
if( aReason == SUPERMODEL_RELOAD )
|
|
|
|
{
|
|
|
|
wxCommandEvent* evt = new wxCommandEvent( EDA_EVT_CLOSE_ERC_DIALOG, wxID_ANY );
|
|
|
|
|
|
|
|
wxQueueEvent( m_frame, evt );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2019-06-01 15:28:39 +00:00
|
|
|
int EE_INSPECTION_TOOL::RunERC( const TOOL_EVENT& aEvent )
|
2020-12-01 22:35:11 +00:00
|
|
|
{
|
|
|
|
ShowERCDialog();
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void EE_INSPECTION_TOOL::ShowERCDialog()
|
2019-06-01 15:28:39 +00:00
|
|
|
{
|
2023-03-13 16:03:48 +00:00
|
|
|
SCH_EDIT_FRAME* frame = dynamic_cast<SCH_EDIT_FRAME*>( m_frame );
|
2020-11-03 19:24:05 +00:00
|
|
|
|
2023-03-13 16:03:48 +00:00
|
|
|
wxCHECK( frame, /* void */ );
|
2019-06-01 15:28:39 +00:00
|
|
|
|
2023-03-13 16:03:48 +00:00
|
|
|
DIALOG_ERC* dlg = frame->GetErcDialog();
|
2019-06-01 15:28:39 +00:00
|
|
|
|
2023-03-13 16:03:48 +00:00
|
|
|
wxCHECK( dlg, /* void */ );
|
2020-11-04 01:07:46 +00:00
|
|
|
|
2023-03-13 16:03:48 +00:00
|
|
|
// Needed at least on Windows. Raise() is not enough
|
|
|
|
dlg->Show( true );
|
|
|
|
|
|
|
|
// Bring it to the top if already open. Dual monitor users need this.
|
|
|
|
dlg->Raise();
|
2024-01-07 17:20:34 +00:00
|
|
|
|
|
|
|
KIPLATFORM::UI::ForceFocus( dlg->FindWindow( wxID_OK ) );
|
2020-11-04 01:07:46 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2020-12-01 22:35:11 +00:00
|
|
|
int EE_INSPECTION_TOOL::PrevMarker( const TOOL_EVENT& aEvent )
|
|
|
|
{
|
2023-03-13 16:03:48 +00:00
|
|
|
SCH_EDIT_FRAME* frame = dynamic_cast<SCH_EDIT_FRAME*>( m_frame );
|
|
|
|
|
|
|
|
wxCHECK( frame, 0 );
|
|
|
|
|
|
|
|
DIALOG_ERC* dlg = frame->GetErcDialog();
|
|
|
|
|
|
|
|
if( dlg )
|
2020-12-01 22:35:11 +00:00
|
|
|
{
|
2023-03-13 16:03:48 +00:00
|
|
|
dlg->Show( true );
|
|
|
|
dlg->Raise();
|
|
|
|
dlg->PrevMarker();
|
2020-12-01 22:35:11 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
int EE_INSPECTION_TOOL::NextMarker( const TOOL_EVENT& aEvent )
|
|
|
|
{
|
2023-03-13 16:03:48 +00:00
|
|
|
SCH_EDIT_FRAME* frame = dynamic_cast<SCH_EDIT_FRAME*>( m_frame );
|
|
|
|
|
|
|
|
wxCHECK( frame, 0 );
|
|
|
|
|
|
|
|
DIALOG_ERC* dlg = frame->GetErcDialog();
|
|
|
|
|
|
|
|
wxCHECK( dlg, 0 );
|
|
|
|
|
|
|
|
dlg->Show( true );
|
|
|
|
dlg->Raise();
|
|
|
|
dlg->NextMarker();
|
2020-12-01 22:35:11 +00:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2022-04-16 23:22:27 +00:00
|
|
|
int EE_INSPECTION_TOOL::CrossProbe( const TOOL_EVENT& aEvent )
|
|
|
|
{
|
2023-03-13 16:03:48 +00:00
|
|
|
EE_SELECTION_TOOL* selectionTool = m_toolMgr->GetTool<EE_SELECTION_TOOL>();
|
|
|
|
|
|
|
|
wxCHECK( selectionTool, 0 );
|
|
|
|
|
|
|
|
EE_SELECTION& selection = selectionTool->GetSelection();
|
|
|
|
|
|
|
|
if( selection.GetSize() == 1 && selection.Front()->Type() == SCH_MARKER_T )
|
|
|
|
{
|
2023-03-17 15:32:18 +00:00
|
|
|
SCH_EDIT_FRAME* frame = dynamic_cast<SCH_EDIT_FRAME*>( m_frame );
|
|
|
|
DIALOG_ERC* dlg = frame ? frame->GetErcDialog() : nullptr;
|
|
|
|
|
|
|
|
if( dlg )
|
|
|
|
{
|
2021-08-19 21:28:54 +00:00
|
|
|
if( !dlg->IsShownOnScreen() )
|
2023-03-17 15:32:18 +00:00
|
|
|
{
|
|
|
|
dlg->Show( true );
|
|
|
|
dlg->Raise();
|
|
|
|
}
|
|
|
|
|
|
|
|
dlg->SelectMarker( static_cast<SCH_MARKER*>( selection.Front() ) );
|
|
|
|
}
|
2022-04-16 23:22:27 +00:00
|
|
|
}
|
|
|
|
|
2022-04-24 16:40:10 +00:00
|
|
|
// Show the item info on a left click on this item
|
|
|
|
UpdateMessagePanel( aEvent );
|
|
|
|
|
2022-04-16 23:22:27 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2020-12-01 22:35:11 +00:00
|
|
|
int EE_INSPECTION_TOOL::ExcludeMarker( const TOOL_EVENT& aEvent )
|
|
|
|
{
|
2021-12-30 16:51:04 +00:00
|
|
|
EE_SELECTION_TOOL* selTool = m_toolMgr->GetTool<EE_SELECTION_TOOL>();
|
|
|
|
EE_SELECTION& selection = selTool->GetSelection();
|
|
|
|
SCH_MARKER* marker = nullptr;
|
|
|
|
|
|
|
|
if( selection.GetSize() == 1 && selection.Front()->Type() == SCH_MARKER_T )
|
|
|
|
marker = static_cast<SCH_MARKER*>( selection.Front() );
|
|
|
|
|
2023-03-13 16:03:48 +00:00
|
|
|
SCH_EDIT_FRAME* frame = dynamic_cast<SCH_EDIT_FRAME*>( m_frame );
|
|
|
|
|
|
|
|
wxCHECK( frame, 0 );
|
|
|
|
|
|
|
|
DIALOG_ERC* dlg = frame->GetErcDialog();
|
|
|
|
|
|
|
|
wxCHECK( dlg, 0 );
|
|
|
|
|
|
|
|
// Let the ERC dialog handle it since it has more update hassles to worry about
|
|
|
|
// Note that if marker is nullptr the dialog will exclude whichever marker is selected
|
|
|
|
// in the dialog itself
|
|
|
|
dlg->ExcludeMarker( marker );
|
|
|
|
|
|
|
|
if( marker != nullptr )
|
2021-02-19 14:51:18 +00:00
|
|
|
{
|
2021-12-30 16:51:04 +00:00
|
|
|
marker->SetExcluded( true );
|
|
|
|
m_frame->GetCanvas()->GetView()->Update( marker );
|
|
|
|
m_frame->GetCanvas()->Refresh();
|
|
|
|
m_frame->OnModify();
|
2021-02-19 14:51:18 +00:00
|
|
|
}
|
2020-12-01 22:35:11 +00:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2022-04-16 16:55:04 +00:00
|
|
|
extern void CheckLibSymbol( LIB_SYMBOL* aSymbol, std::vector<wxString>& aMessages,
|
2022-09-19 09:25:20 +00:00
|
|
|
int aGridForPins, EDA_DRAW_FRAME* aUnitsProvider );
|
2019-06-02 18:58:09 +00:00
|
|
|
|
2020-11-21 20:42:27 +00:00
|
|
|
int EE_INSPECTION_TOOL::CheckSymbol( const TOOL_EVENT& aEvent )
|
2019-06-02 18:58:09 +00:00
|
|
|
{
|
2021-06-15 12:31:28 +00:00
|
|
|
LIB_SYMBOL* symbol = static_cast<SYMBOL_EDIT_FRAME*>( m_frame )->GetCurSymbol();
|
2020-11-21 20:42:27 +00:00
|
|
|
|
2021-06-10 18:51:46 +00:00
|
|
|
if( !symbol )
|
2020-11-21 20:42:27 +00:00
|
|
|
return 0;
|
2019-06-02 18:58:09 +00:00
|
|
|
|
2021-01-18 15:08:19 +00:00
|
|
|
std::vector<wxString> messages;
|
2022-04-16 16:55:04 +00:00
|
|
|
const int grid_size = KiROUND( getView()->GetGAL()->GetGridSize().x );
|
2021-02-04 22:46:57 +00:00
|
|
|
|
2022-09-19 09:25:20 +00:00
|
|
|
CheckLibSymbol( symbol, messages, grid_size, m_frame );
|
2019-06-02 18:58:09 +00:00
|
|
|
|
2021-02-04 22:46:57 +00:00
|
|
|
if( messages.empty() )
|
|
|
|
{
|
|
|
|
DisplayInfoMessage( m_frame, _( "No symbol issues found." ) );
|
|
|
|
}
|
2019-06-02 18:58:09 +00:00
|
|
|
else
|
2020-02-27 23:06:48 +00:00
|
|
|
{
|
2022-03-26 14:22:31 +00:00
|
|
|
HTML_MESSAGE_BOX dlg( m_frame, _( "Symbol Warnings" ) );
|
2020-02-27 23:06:48 +00:00
|
|
|
|
2021-09-20 18:45:27 +00:00
|
|
|
for( const wxString& single_msg : messages )
|
2022-03-26 14:22:31 +00:00
|
|
|
dlg.AddHTML_Text( single_msg );
|
2021-07-24 16:59:28 +00:00
|
|
|
|
2022-03-26 14:22:31 +00:00
|
|
|
dlg.ShowModal();
|
2020-02-27 23:06:48 +00:00
|
|
|
}
|
2020-11-21 20:42:27 +00:00
|
|
|
|
|
|
|
return 0;
|
2019-06-02 18:58:09 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2023-03-09 17:41:18 +00:00
|
|
|
int EE_INSPECTION_TOOL::DiffSymbol( const TOOL_EVENT& aEvent )
|
2023-03-09 11:25:32 +00:00
|
|
|
{
|
2023-03-13 16:03:48 +00:00
|
|
|
SCH_EDIT_FRAME* schEditorFrame = dynamic_cast<SCH_EDIT_FRAME*>( m_frame );
|
|
|
|
|
|
|
|
wxCHECK( schEditorFrame, 0 );
|
2023-03-09 11:25:32 +00:00
|
|
|
|
|
|
|
EE_SELECTION& selection = m_selectionTool->RequestSelection( { SCH_SYMBOL_T } );
|
|
|
|
|
|
|
|
if( selection.Empty() )
|
|
|
|
{
|
|
|
|
m_frame->ShowInfoBarError( _( "Select a symbol to diff against its library equivalent." ) );
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2023-03-13 16:03:48 +00:00
|
|
|
DIALOG_BOOK_REPORTER* dialog = schEditorFrame->GetSymbolDiffDialog();
|
2023-03-09 11:25:32 +00:00
|
|
|
|
2023-03-13 16:03:48 +00:00
|
|
|
wxCHECK( dialog, 0 );
|
2023-03-09 11:25:32 +00:00
|
|
|
|
2023-03-11 19:35:13 +00:00
|
|
|
dialog->DeleteAllPages();
|
2023-03-09 11:25:32 +00:00
|
|
|
|
|
|
|
SCH_SYMBOL* symbol = (SCH_SYMBOL*) selection.Front();
|
|
|
|
wxString symbolDesc = wxString::Format( _( "Symbol %s" ),
|
|
|
|
symbol->GetField( REFERENCE_FIELD )->GetText() );
|
|
|
|
LIB_ID libId = symbol->GetLibId();
|
|
|
|
wxString libName = libId.GetLibNickname();
|
|
|
|
wxString symbolName = libId.GetLibItemName();
|
|
|
|
|
2023-03-11 19:35:13 +00:00
|
|
|
WX_HTML_REPORT_BOX* r = dialog->AddHTMLPage( _( "Summary" ) );
|
2023-03-09 11:25:32 +00:00
|
|
|
|
|
|
|
r->Report( wxS( "<h7>" ) + _( "Schematic vs library diff for:" ) + wxS( "</h7>" ) );
|
|
|
|
r->Report( wxS( "<ul><li>" ) + EscapeHTML( symbolDesc ) + wxS( "</li>" )
|
|
|
|
+ wxS( "<li>" ) + _( "Library: " ) + EscapeHTML( libName ) + wxS( "</li>" )
|
2023-03-13 16:03:48 +00:00
|
|
|
+ wxS( "<li>" ) + _( "Library item: " ) + EscapeHTML( symbolName )
|
|
|
|
+ wxS( "</li></ul>" ) );
|
2023-03-09 11:25:32 +00:00
|
|
|
|
|
|
|
r->Report( "" );
|
|
|
|
|
2023-09-28 03:04:53 +00:00
|
|
|
SYMBOL_LIB_TABLE* libTable = PROJECT_SCH::SchSymbolLibTable( &m_frame->Prj() );
|
2023-03-09 11:25:32 +00:00
|
|
|
const LIB_TABLE_ROW* libTableRow = libTable->FindRow( libName );
|
|
|
|
|
|
|
|
if( !libTableRow )
|
|
|
|
{
|
|
|
|
r->Report( _( "The library is not included in the current configuration." )
|
|
|
|
+ wxS( "  " )
|
|
|
|
+ wxS( "<a href='$CONFIG'>" ) + _( "Manage Symbol Libraries" ) + wxS( "</a>" ) );
|
|
|
|
}
|
|
|
|
else if( !libTable->HasLibrary( libName, true ) )
|
|
|
|
{
|
|
|
|
r->Report( _( "The library is not enabled in the current configuration." )
|
|
|
|
+ wxS( "  " )
|
|
|
|
+ wxS( "<a href='$CONFIG'>" ) + _( "Manage Symbol Libraries" ) + wxS( "</a>" ) );
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
std::unique_ptr<LIB_SYMBOL> flattenedLibSymbol;
|
|
|
|
std::unique_ptr<LIB_SYMBOL> flattenedSchSymbol = symbol->GetLibSymbolRef()->Flatten();
|
|
|
|
|
|
|
|
try
|
|
|
|
{
|
|
|
|
if( LIB_SYMBOL* libAlias = libTable->LoadSymbol( libName, symbolName ) )
|
|
|
|
flattenedLibSymbol = libAlias->Flatten();
|
|
|
|
}
|
|
|
|
catch( const IO_ERROR& )
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
if( !flattenedLibSymbol )
|
|
|
|
{
|
|
|
|
r->Report( wxString::Format( _( "The library no longer contains the item %s." ),
|
|
|
|
symbolName ) );
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
std::vector<LIB_FIELD> fields;
|
|
|
|
|
|
|
|
for( SCH_FIELD& field : symbol->GetFields() )
|
|
|
|
{
|
|
|
|
fields.emplace_back( LIB_FIELD( flattenedLibSymbol.get(), field.GetId(),
|
|
|
|
field.GetName( false ) ) );
|
|
|
|
fields.back().CopyText( field );
|
|
|
|
fields.back().SetAttributes( field );
|
2023-03-09 17:41:18 +00:00
|
|
|
fields.back().Offset( -symbol->GetPosition() );
|
2023-03-09 11:25:32 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
flattenedSchSymbol->SetFields( fields );
|
|
|
|
|
2023-05-29 11:40:00 +00:00
|
|
|
int flags = LIB_ITEM::COMPARE_FLAGS::EQUALITY | LIB_ITEM::COMPARE_FLAGS::ERC;
|
|
|
|
|
|
|
|
if( flattenedSchSymbol->Compare( *flattenedLibSymbol, flags, r ) == 0 )
|
2023-03-09 11:25:32 +00:00
|
|
|
r->Report( _( "No relevant differences detected." ) );
|
2023-03-09 17:41:18 +00:00
|
|
|
|
2023-03-11 19:35:13 +00:00
|
|
|
wxPanel* panel = dialog->AddBlankPage( _( "Visual" ) );
|
2023-03-09 17:41:18 +00:00
|
|
|
SYMBOL_DIFF_WIDGET* diff = constructDiffPanel( panel );
|
|
|
|
|
|
|
|
diff->DisplayDiff( flattenedSchSymbol.release(), flattenedLibSymbol.release(),
|
|
|
|
symbol->GetUnit(), symbol->GetConvert() );
|
2023-03-09 11:25:32 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
r->Flush();
|
|
|
|
|
2023-03-11 19:35:13 +00:00
|
|
|
dialog->Raise();
|
|
|
|
dialog->Show( true );
|
2023-03-09 11:25:32 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2023-03-09 17:41:18 +00:00
|
|
|
SYMBOL_DIFF_WIDGET* EE_INSPECTION_TOOL::constructDiffPanel( wxPanel* aParentPanel )
|
|
|
|
{
|
|
|
|
wxBoxSizer* sizer = new wxBoxSizer( wxVERTICAL );
|
|
|
|
|
|
|
|
EDA_DRAW_PANEL_GAL::GAL_TYPE backend = m_frame->GetCanvas()->GetBackend();
|
|
|
|
SYMBOL_DIFF_WIDGET* diffWidget = new SYMBOL_DIFF_WIDGET( aParentPanel, backend );
|
|
|
|
|
|
|
|
sizer->Add( diffWidget, 1, wxEXPAND | wxALL, 5 );
|
|
|
|
aParentPanel->SetSizer( sizer );
|
|
|
|
aParentPanel->Layout();
|
|
|
|
|
|
|
|
return diffWidget;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2019-06-01 18:36:49 +00:00
|
|
|
int EE_INSPECTION_TOOL::RunSimulation( const TOOL_EVENT& aEvent )
|
|
|
|
{
|
2023-03-03 22:36:07 +00:00
|
|
|
SIMULATOR_FRAME* simFrame = (SIMULATOR_FRAME*) m_frame->Kiway().Player( FRAME_SIMULATOR, true );
|
2021-03-19 23:04:27 +00:00
|
|
|
|
|
|
|
if( !simFrame )
|
|
|
|
return -1;
|
|
|
|
|
2022-07-12 21:44:53 +00:00
|
|
|
if( wxWindow* blocking_win = simFrame->Kiway().GetBlockingDialog() )
|
|
|
|
blocking_win->Close( true );
|
|
|
|
|
2019-06-01 18:36:49 +00:00
|
|
|
simFrame->Show( true );
|
|
|
|
|
|
|
|
// On Windows, Raise() does not bring the window on screen, when iconized
|
|
|
|
if( simFrame->IsIconized() )
|
|
|
|
simFrame->Iconize( false );
|
|
|
|
|
|
|
|
simFrame->Raise();
|
2023-03-20 15:02:45 +00:00
|
|
|
|
2019-06-01 18:36:49 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2019-05-10 17:19:48 +00:00
|
|
|
int EE_INSPECTION_TOOL::ShowDatasheet( const TOOL_EVENT& aEvent )
|
2019-04-29 20:38:05 +00:00
|
|
|
{
|
2019-06-01 18:36:49 +00:00
|
|
|
wxString datasheet;
|
2019-04-29 20:38:05 +00:00
|
|
|
|
2020-10-31 01:27:16 +00:00
|
|
|
if( m_frame->IsType( FRAME_SCH_SYMBOL_EDITOR ) )
|
2019-06-01 18:36:49 +00:00
|
|
|
{
|
2021-06-15 12:31:28 +00:00
|
|
|
LIB_SYMBOL* symbol = static_cast<SYMBOL_EDIT_FRAME*>( m_frame )->GetCurSymbol();
|
2019-06-01 18:36:49 +00:00
|
|
|
|
2021-06-10 18:51:46 +00:00
|
|
|
if( !symbol )
|
2019-06-01 18:36:49 +00:00
|
|
|
return 0;
|
|
|
|
|
2021-06-10 18:51:46 +00:00
|
|
|
datasheet = symbol->GetDatasheetField().GetText();
|
2019-06-01 18:36:49 +00:00
|
|
|
}
|
2023-09-28 13:09:45 +00:00
|
|
|
else if( m_frame->IsType( FRAME_SCH_VIEWER ) )
|
2019-06-01 18:36:49 +00:00
|
|
|
{
|
2021-06-10 18:51:46 +00:00
|
|
|
LIB_SYMBOL* entry = static_cast<SYMBOL_VIEWER_FRAME*>( m_frame )->GetSelectedSymbol();
|
2019-04-29 20:38:05 +00:00
|
|
|
|
2019-06-01 18:36:49 +00:00
|
|
|
if( !entry )
|
|
|
|
return 0;
|
|
|
|
|
2020-06-01 13:13:32 +00:00
|
|
|
datasheet = entry->GetDatasheetField().GetText();
|
2019-06-01 18:36:49 +00:00
|
|
|
}
|
2019-06-02 18:58:09 +00:00
|
|
|
else if( m_frame->IsType( FRAME_SCH ) )
|
2019-06-01 18:36:49 +00:00
|
|
|
{
|
2022-08-20 09:27:35 +00:00
|
|
|
EE_SELECTION& selection = m_selectionTool->RequestSelection( { SCH_SYMBOL_T } );
|
2019-04-29 20:38:05 +00:00
|
|
|
|
2019-06-01 18:36:49 +00:00
|
|
|
if( selection.Empty() )
|
|
|
|
return 0;
|
|
|
|
|
2021-06-10 14:10:55 +00:00
|
|
|
SCH_SYMBOL* symbol = (SCH_SYMBOL*) selection.Front();
|
2019-06-01 18:36:49 +00:00
|
|
|
|
2023-05-05 13:21:56 +00:00
|
|
|
// Use GetShownText() to resolve any text variables, but don't allow adding extra text
|
|
|
|
// (ie: the field name)
|
|
|
|
datasheet = symbol->GetField( DATASHEET_FIELD )->GetShownText( false );
|
2019-06-01 18:36:49 +00:00
|
|
|
}
|
|
|
|
|
2023-03-09 11:25:32 +00:00
|
|
|
if( datasheet.IsEmpty() || datasheet == wxS( "~" ) )
|
2022-02-18 21:43:37 +00:00
|
|
|
{
|
2021-04-21 14:21:34 +00:00
|
|
|
m_frame->ShowInfoBarError( _( "No datasheet defined." ) );
|
2022-02-18 21:43:37 +00:00
|
|
|
}
|
2021-04-21 14:21:34 +00:00
|
|
|
else
|
2022-02-18 21:43:37 +00:00
|
|
|
{
|
2023-09-28 03:04:53 +00:00
|
|
|
GetAssociatedDocument( m_frame, datasheet, &m_frame->Prj(),
|
|
|
|
PROJECT_SCH::SchSearchS( &m_frame->Prj() ) );
|
2022-02-18 21:43:37 +00:00
|
|
|
}
|
2019-04-29 20:38:05 +00:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2019-05-10 17:19:48 +00:00
|
|
|
int EE_INSPECTION_TOOL::UpdateMessagePanel( const TOOL_EVENT& aEvent )
|
2019-04-30 18:36:11 +00:00
|
|
|
{
|
2023-04-16 17:44:58 +00:00
|
|
|
SYMBOL_EDIT_FRAME* symbolEditFrame = dynamic_cast<SYMBOL_EDIT_FRAME*>( m_frame );
|
|
|
|
SCH_EDIT_FRAME* schEditFrame = dynamic_cast<SCH_EDIT_FRAME*>( m_frame );
|
2019-05-10 17:19:48 +00:00
|
|
|
EE_SELECTION_TOOL* selTool = m_toolMgr->GetTool<EE_SELECTION_TOOL>();
|
2019-06-08 21:48:22 +00:00
|
|
|
EE_SELECTION& selection = selTool->GetSelection();
|
2019-04-30 18:36:11 +00:00
|
|
|
|
2023-04-16 17:44:58 +00:00
|
|
|
// Note: the symbol viewer manages its own message panel
|
2019-04-30 18:36:11 +00:00
|
|
|
|
2023-04-16 17:44:58 +00:00
|
|
|
if( symbolEditFrame || schEditFrame )
|
2019-04-30 18:36:11 +00:00
|
|
|
{
|
2023-04-16 17:44:58 +00:00
|
|
|
if( selection.GetSize() == 1 )
|
|
|
|
{
|
|
|
|
EDA_ITEM* item = (EDA_ITEM*) selection.Front();
|
|
|
|
|
|
|
|
std::vector<MSG_PANEL_ITEM> msgItems;
|
|
|
|
item->GetMsgPanelInfo( m_frame, msgItems );
|
|
|
|
m_frame->SetMsgPanel( msgItems );
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
m_frame->ClearMsgPanel();
|
|
|
|
}
|
2019-04-30 18:36:11 +00:00
|
|
|
}
|
|
|
|
|
2023-04-16 17:44:58 +00:00
|
|
|
if( schEditFrame )
|
2022-10-24 22:00:10 +00:00
|
|
|
{
|
2023-04-16 17:44:58 +00:00
|
|
|
schEditFrame->UpdateNetHighlightStatus();
|
|
|
|
schEditFrame->UpdateHierarchySelection();
|
2022-10-24 22:00:10 +00:00
|
|
|
}
|
2020-08-13 21:30:30 +00:00
|
|
|
|
2019-04-30 18:36:11 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2019-05-10 17:19:48 +00:00
|
|
|
void EE_INSPECTION_TOOL::setTransitions()
|
2019-04-29 20:38:05 +00:00
|
|
|
{
|
2019-06-01 15:28:39 +00:00
|
|
|
Go( &EE_INSPECTION_TOOL::RunERC, EE_ACTIONS::runERC.MakeEvent() );
|
2020-12-01 22:35:11 +00:00
|
|
|
Go( &EE_INSPECTION_TOOL::PrevMarker, EE_ACTIONS::prevMarker.MakeEvent() );
|
|
|
|
Go( &EE_INSPECTION_TOOL::NextMarker, EE_ACTIONS::nextMarker.MakeEvent() );
|
2022-04-24 16:40:10 +00:00
|
|
|
// See note 1:
|
2022-07-19 15:00:35 +00:00
|
|
|
Go( &EE_INSPECTION_TOOL::CrossProbe, EVENTS::PointSelectedEvent );
|
2022-04-16 23:22:27 +00:00
|
|
|
Go( &EE_INSPECTION_TOOL::CrossProbe, EVENTS::SelectedEvent );
|
2020-12-01 22:35:11 +00:00
|
|
|
Go( &EE_INSPECTION_TOOL::ExcludeMarker, EE_ACTIONS::excludeMarker.MakeEvent() );
|
|
|
|
|
2020-11-21 20:42:27 +00:00
|
|
|
Go( &EE_INSPECTION_TOOL::CheckSymbol, EE_ACTIONS::checkSymbol.MakeEvent() );
|
2023-03-09 17:41:18 +00:00
|
|
|
Go( &EE_INSPECTION_TOOL::DiffSymbol, EE_ACTIONS::diffSymbol.MakeEvent() );
|
2023-01-01 23:37:24 +00:00
|
|
|
Go( &EE_INSPECTION_TOOL::RunSimulation, EE_ACTIONS::showSimulator.MakeEvent() );
|
2019-06-01 18:36:49 +00:00
|
|
|
|
2019-05-10 17:19:48 +00:00
|
|
|
Go( &EE_INSPECTION_TOOL::ShowDatasheet, EE_ACTIONS::showDatasheet.MakeEvent() );
|
2019-04-30 18:36:11 +00:00
|
|
|
|
2022-04-24 16:40:10 +00:00
|
|
|
// Note 1: tUpdateMessagePanel is called by CrossProbe. So uncomment this line if
|
|
|
|
// call to CrossProbe is modifiied
|
|
|
|
// Go( &EE_INSPECTION_TOOL::UpdateMessagePanel, EVENTS::SelectedEvent );
|
2019-05-10 17:19:48 +00:00
|
|
|
Go( &EE_INSPECTION_TOOL::UpdateMessagePanel, EVENTS::UnselectedEvent );
|
|
|
|
Go( &EE_INSPECTION_TOOL::UpdateMessagePanel, EVENTS::ClearedEvent );
|
2019-06-10 22:42:02 +00:00
|
|
|
Go( &EE_INSPECTION_TOOL::UpdateMessagePanel, EVENTS::SelectedItemsModified );
|
2019-04-29 20:38:05 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|