2019-04-29 20:38:05 +00:00
|
|
|
/*
|
|
|
|
* This program source code file is part of KiCad, a free EDA CAD application.
|
|
|
|
*
|
2019-08-14 08:28:07 +00:00
|
|
|
* Copyright (C) 2019 CERN
|
2021-02-24 13:48:02 +00:00
|
|
|
* Copyright (C) 2019-2021 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>
|
2019-04-29 20:38:05 +00:00
|
|
|
#include <confirm.h>
|
|
|
|
#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>
|
2019-06-01 18:36:49 +00:00
|
|
|
#include <sim/sim_plot_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>
|
2021-09-14 18:26:03 +00:00
|
|
|
#include <dialogs/dialog_display_html_text_base.h>
|
2020-11-03 19:24:05 +00:00
|
|
|
#include <dialogs/dialog_erc.h>
|
2020-01-07 17:12:59 +00:00
|
|
|
#include <math/util.h> // for KiROUND
|
2019-04-29 20:38:05 +00:00
|
|
|
|
|
|
|
|
2021-09-14 18:26:03 +00:00
|
|
|
class DIALOG_DISPLAY_HTML_TEXT : public DIALOG_DISPLAY_HTML_TEXT_BASE
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
DIALOG_DISPLAY_HTML_TEXT( wxWindow* aParent, wxWindowID aId, const wxString& aTitle,
|
|
|
|
const wxPoint& aPos, const wxSize& aSize, long aStyle = 0 ) :
|
|
|
|
DIALOG_DISPLAY_HTML_TEXT_BASE( aParent, aId, aTitle, aPos, aSize, aStyle )
|
|
|
|
{ }
|
|
|
|
|
|
|
|
~DIALOG_DISPLAY_HTML_TEXT()
|
|
|
|
{ }
|
|
|
|
|
2021-10-10 12:52:37 +00:00
|
|
|
void SetPage( const wxString& message ) { m_htmlWindow->SetPage( message ); }
|
2021-09-14 18:26:03 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
2020-11-03 19:24:05 +00:00
|
|
|
EE_INSPECTION_TOOL::EE_INSPECTION_TOOL() :
|
|
|
|
EE_TOOL_BASE<SCH_BASE_FRAME>( "eeschema.InspectionTool" ),
|
|
|
|
m_ercDialog( nullptr )
|
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;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2020-11-03 19:24:05 +00:00
|
|
|
void EE_INSPECTION_TOOL::Reset( RESET_REASON aReason )
|
|
|
|
{
|
|
|
|
EE_TOOL_BASE::Reset( aReason );
|
|
|
|
|
|
|
|
if( aReason == MODEL_RELOAD )
|
|
|
|
{
|
2020-11-04 01:07:46 +00:00
|
|
|
DestroyERCDialog();
|
2020-11-03 19:24:05 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
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
|
|
|
{
|
2020-11-21 20:42:27 +00:00
|
|
|
if( m_frame->IsType( FRAME_SCH ) )
|
2019-06-02 18:58:09 +00:00
|
|
|
{
|
2020-11-03 19:24:05 +00:00
|
|
|
if( m_ercDialog )
|
2020-04-08 08:03:51 +00:00
|
|
|
{
|
|
|
|
// Needed at least on Windows. Raise() is not enough
|
2020-11-03 19:24:05 +00:00
|
|
|
m_ercDialog->Show( true );
|
2019-06-02 18:58:09 +00:00
|
|
|
// Bring it to the top if already open. Dual monitor users need this.
|
2020-11-03 19:24:05 +00:00
|
|
|
m_ercDialog->Raise();
|
2020-04-08 08:03:51 +00:00
|
|
|
}
|
2019-06-02 18:58:09 +00:00
|
|
|
else
|
2020-11-03 19:24:05 +00:00
|
|
|
{
|
|
|
|
// This is a modeless dialog, so new it rather than instantiating on stack.
|
|
|
|
m_ercDialog = new DIALOG_ERC( static_cast<SCH_EDIT_FRAME*>( m_frame ) );
|
|
|
|
|
|
|
|
m_ercDialog->Show( true );
|
|
|
|
}
|
2019-06-02 18:58:09 +00:00
|
|
|
}
|
2019-06-01 15:28:39 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2020-11-04 01:07:46 +00:00
|
|
|
void EE_INSPECTION_TOOL::DestroyERCDialog()
|
|
|
|
{
|
|
|
|
if( m_ercDialog )
|
|
|
|
m_ercDialog->Destroy();
|
|
|
|
|
|
|
|
m_ercDialog = nullptr;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2020-12-01 22:35:11 +00:00
|
|
|
int EE_INSPECTION_TOOL::PrevMarker( const TOOL_EVENT& aEvent )
|
|
|
|
{
|
|
|
|
if( m_ercDialog )
|
|
|
|
{
|
|
|
|
m_ercDialog->Show( true );
|
|
|
|
m_ercDialog->Raise();
|
|
|
|
m_ercDialog->PrevMarker();
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
ShowERCDialog();
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
int EE_INSPECTION_TOOL::NextMarker( const TOOL_EVENT& aEvent )
|
|
|
|
{
|
|
|
|
if( m_ercDialog )
|
|
|
|
{
|
|
|
|
m_ercDialog->Show( true );
|
|
|
|
m_ercDialog->Raise();
|
|
|
|
m_ercDialog->NextMarker();
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
ShowERCDialog();
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
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() );
|
|
|
|
|
2020-12-01 22:35:11 +00:00
|
|
|
if( m_ercDialog )
|
2021-02-19 14:51:18 +00:00
|
|
|
{
|
|
|
|
// Let the ERC dialog handle it since it has more update hassles to worry about
|
2021-12-30 16:51:04 +00:00
|
|
|
// Note that if marker is nullptr the dialog will exclude whichever marker is selected
|
|
|
|
// in the dialog itself
|
|
|
|
m_ercDialog->ExcludeMarker( marker );
|
2021-02-19 14:51:18 +00:00
|
|
|
}
|
2021-12-30 16:51:04 +00:00
|
|
|
else 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;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2019-06-02 18:58:09 +00:00
|
|
|
// helper function to sort pins by pin num
|
|
|
|
bool sort_by_pin_number( const LIB_PIN* ref, const LIB_PIN* tst )
|
|
|
|
{
|
|
|
|
// Use number as primary key
|
|
|
|
int test = ref->GetNumber().Cmp( tst->GetNumber() );
|
|
|
|
|
|
|
|
// Use DeMorgan variant as secondary key
|
|
|
|
if( test == 0 )
|
|
|
|
test = ref->GetConvert() - tst->GetConvert();
|
|
|
|
|
|
|
|
// Use unit as tertiary key
|
|
|
|
if( test == 0 )
|
|
|
|
test = ref->GetUnit() - tst->GetUnit();
|
|
|
|
|
|
|
|
return test < 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
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();
|
2021-07-23 16:23:11 +00:00
|
|
|
EDA_UNITS units = m_frame->GetUserUnits();
|
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-05-05 22:31:47 +00:00
|
|
|
LIB_PINS pinList;
|
2021-06-10 18:51:46 +00:00
|
|
|
symbol->GetPins( pinList );
|
2019-06-02 18:58:09 +00:00
|
|
|
|
2021-07-24 16:59:28 +00:00
|
|
|
// Test for duplicates:
|
2019-06-02 18:58:09 +00:00
|
|
|
// Sort pins by pin num, so 2 duplicate pins
|
|
|
|
// (pins with the same number) will be consecutive in list
|
|
|
|
sort( pinList.begin(), pinList.end(), sort_by_pin_number );
|
|
|
|
|
2021-07-23 16:23:11 +00:00
|
|
|
// The minimal grid size allowed to place a pin is 25 mils
|
|
|
|
// the best grid size is 50 mils, but 25 mils is still usable
|
|
|
|
// this is because all symbols are using a 50 mils grid to place pins, and therefore
|
|
|
|
// the wires must be on the 50 mils grid
|
|
|
|
// So raise an error if a pin is not on a 25 (or bigger :50 or 100) mils grid
|
|
|
|
const int min_grid_size = Mils2iu( 25 );
|
2021-01-18 15:08:19 +00:00
|
|
|
const int grid_size = KiROUND( getView()->GetGAL()->GetGridSize().x );
|
|
|
|
const int clamped_grid_size = ( grid_size < min_grid_size ) ? min_grid_size : grid_size;
|
2020-02-27 23:06:48 +00:00
|
|
|
|
2021-01-18 15:08:19 +00:00
|
|
|
std::vector<wxString> messages;
|
|
|
|
wxString msg;
|
2019-06-02 18:58:09 +00:00
|
|
|
|
|
|
|
for( unsigned ii = 1; ii < pinList.size(); ii++ )
|
|
|
|
{
|
|
|
|
LIB_PIN* pin = pinList[ii - 1];
|
|
|
|
LIB_PIN* next = pinList[ii];
|
|
|
|
|
2022-05-23 09:33:43 +00:00
|
|
|
if( pin->GetNumber() != next->GetNumber() )
|
2019-06-02 18:58:09 +00:00
|
|
|
continue;
|
|
|
|
|
2022-05-23 09:33:43 +00:00
|
|
|
// Pins are not duplicated only if they are in different convert bodies
|
|
|
|
// (but GetConvert() == 0 means commun to all convert bodies)
|
|
|
|
if( pin->GetConvert() != 0 && next->GetConvert() != 0 )
|
|
|
|
{
|
|
|
|
if( pin->GetConvert() != next->GetConvert() )
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
2021-01-18 15:08:19 +00:00
|
|
|
wxString pinName;
|
|
|
|
wxString nextName;
|
|
|
|
|
2022-02-08 23:14:18 +00:00
|
|
|
if( pin->GetName() != wxT( "~" ) && !pin->GetName().IsEmpty() )
|
|
|
|
pinName = wxT( " '" ) + pin->GetName() + wxT( "'" );
|
2021-01-18 15:08:19 +00:00
|
|
|
|
2022-02-08 23:14:18 +00:00
|
|
|
if( next->GetName() != wxT( "~" ) && !next->GetName().IsEmpty() )
|
|
|
|
nextName = wxT( " '" ) + next->GetName() + wxT( "'" );
|
2021-01-18 15:08:19 +00:00
|
|
|
|
2021-06-10 18:51:46 +00:00
|
|
|
if( symbol->HasConversion() && next->GetConvert() )
|
2019-06-02 18:58:09 +00:00
|
|
|
{
|
2021-06-10 18:51:46 +00:00
|
|
|
if( symbol->GetUnitCount() <= 1 )
|
2020-10-20 19:05:04 +00:00
|
|
|
{
|
2021-02-04 22:46:57 +00:00
|
|
|
msg.Printf( _( "<b>Duplicate pin %s</b> %s at location <b>(%.3f, %.3f)</b>"
|
2021-01-18 15:08:19 +00:00
|
|
|
" conflicts with pin %s%s at location <b>(%.3f, %.3f)</b>"
|
2021-02-04 22:46:57 +00:00
|
|
|
" of converted." ),
|
2021-01-18 15:08:19 +00:00
|
|
|
next->GetNumber(),
|
|
|
|
nextName,
|
2021-07-23 16:23:11 +00:00
|
|
|
MessageTextFromValue( units, next->GetPosition().x ),
|
|
|
|
MessageTextFromValue( units, -next->GetPosition().y ),
|
2021-01-18 15:08:19 +00:00
|
|
|
pin->GetNumber(),
|
|
|
|
pin->GetName(),
|
2021-07-23 16:23:11 +00:00
|
|
|
MessageTextFromValue( units, pin->GetPosition().x ),
|
|
|
|
MessageTextFromValue( units, -pin->GetPosition().y ) );
|
2020-10-20 19:05:04 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2021-02-04 22:46:57 +00:00
|
|
|
msg.Printf( _( "<b>Duplicate pin %s</b> %s at location <b>(%.3f, %.3f)</b>"
|
2021-01-18 15:08:19 +00:00
|
|
|
" conflicts with pin %s%s at location <b>(%.3f, %.3f)</b>"
|
2021-02-04 22:46:57 +00:00
|
|
|
" in units %c and %c of converted." ),
|
2021-01-18 15:08:19 +00:00
|
|
|
next->GetNumber(),
|
|
|
|
nextName,
|
2021-07-23 16:23:11 +00:00
|
|
|
MessageTextFromValue( units, next->GetPosition().x ),
|
|
|
|
MessageTextFromValue( units, -next->GetPosition().y ),
|
2021-01-18 15:08:19 +00:00
|
|
|
pin->GetNumber(),
|
|
|
|
pinName,
|
2021-07-23 16:23:11 +00:00
|
|
|
MessageTextFromValue( units, pin->GetPosition().x ),
|
|
|
|
MessageTextFromValue( units, -pin->GetPosition().y ),
|
2021-01-18 15:08:19 +00:00
|
|
|
'A' + next->GetUnit() - 1,
|
|
|
|
'A' + pin->GetUnit() - 1 );
|
2020-10-20 19:05:04 +00:00
|
|
|
}
|
2019-06-02 18:58:09 +00:00
|
|
|
}
|
2020-10-20 19:05:04 +00:00
|
|
|
else
|
2019-06-02 18:58:09 +00:00
|
|
|
{
|
2021-06-10 18:51:46 +00:00
|
|
|
if( symbol->GetUnitCount() <= 1 )
|
2020-10-20 19:05:04 +00:00
|
|
|
{
|
2021-07-23 16:23:11 +00:00
|
|
|
msg.Printf( _( "<b>Duplicate pin %s</b> %s at location <b>(%s, %s)</b>"
|
|
|
|
" conflicts with pin %s%s at location <b>(%s, %s)</b>." ),
|
2021-01-18 15:08:19 +00:00
|
|
|
next->GetNumber(),
|
|
|
|
nextName,
|
2021-07-23 16:23:11 +00:00
|
|
|
MessageTextFromValue( units, next->GetPosition().x ),
|
|
|
|
MessageTextFromValue( units, -next->GetPosition().y ),
|
2021-01-18 15:08:19 +00:00
|
|
|
pin->GetNumber(),
|
|
|
|
pinName,
|
2021-07-23 16:23:11 +00:00
|
|
|
MessageTextFromValue( units, pin->GetPosition().x ),
|
|
|
|
MessageTextFromValue( units, -pin->GetPosition().y ) );
|
2020-10-20 19:05:04 +00:00
|
|
|
}
|
2019-06-02 18:58:09 +00:00
|
|
|
else
|
2020-10-20 19:05:04 +00:00
|
|
|
{
|
2021-07-23 16:23:11 +00:00
|
|
|
msg.Printf( _( "<b>Duplicate pin %s</b> %s at location <b>(%s, %s)</b>"
|
|
|
|
" conflicts with pin %s%s at location <b>(%s, %s)</b>"
|
2021-02-04 22:46:57 +00:00
|
|
|
" in units %c and %c." ),
|
2021-01-18 15:08:19 +00:00
|
|
|
next->GetNumber(),
|
|
|
|
nextName,
|
2021-07-23 16:23:11 +00:00
|
|
|
MessageTextFromValue( units, next->GetPosition().x ),
|
|
|
|
MessageTextFromValue( units, -next->GetPosition().y ),
|
2021-01-18 15:08:19 +00:00
|
|
|
pin->GetNumber(),
|
|
|
|
pinName,
|
2021-07-23 16:23:11 +00:00
|
|
|
MessageTextFromValue( units, pin->GetPosition().x ),
|
|
|
|
MessageTextFromValue( units, -pin->GetPosition().y ),
|
2021-01-18 15:08:19 +00:00
|
|
|
'A' + next->GetUnit() - 1,
|
|
|
|
'A' + pin->GetUnit() - 1 );
|
2020-10-20 19:05:04 +00:00
|
|
|
}
|
2019-06-02 18:58:09 +00:00
|
|
|
}
|
|
|
|
|
2021-02-04 22:46:57 +00:00
|
|
|
msg += wxT( "<br><br>" );
|
2020-02-27 23:06:48 +00:00
|
|
|
messages.push_back( msg );
|
2019-06-02 18:58:09 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
for( LIB_PIN* pin : pinList )
|
|
|
|
{
|
2021-01-18 15:08:19 +00:00
|
|
|
wxString pinName = pin->GetName();
|
|
|
|
|
2022-02-08 23:14:18 +00:00
|
|
|
if( pinName.IsEmpty() || pinName == wxT( "~" ) )
|
2022-02-09 18:33:52 +00:00
|
|
|
pinName = wxEmptyString;
|
2021-01-18 15:08:19 +00:00
|
|
|
else
|
2022-02-08 23:14:18 +00:00
|
|
|
pinName = wxT( "'" ) + pinName + wxT( "'" );
|
2021-01-18 15:08:19 +00:00
|
|
|
|
2021-06-10 18:51:46 +00:00
|
|
|
if( !symbol->IsPower()
|
2021-02-04 22:46:57 +00:00
|
|
|
&& pin->GetType() == ELECTRICAL_PINTYPE::PT_POWER_IN
|
|
|
|
&& !pin->IsVisible() )
|
2020-10-21 19:27:40 +00:00
|
|
|
{
|
2021-02-04 22:46:57 +00:00
|
|
|
// hidden power pin
|
2021-06-10 18:51:46 +00:00
|
|
|
if( symbol->HasConversion() && pin->GetConvert() )
|
2020-10-21 19:27:40 +00:00
|
|
|
{
|
2021-06-10 18:51:46 +00:00
|
|
|
if( symbol->GetUnitCount() <= 1 )
|
2021-02-04 22:46:57 +00:00
|
|
|
{
|
2021-07-24 15:03:36 +00:00
|
|
|
msg.Printf( _( "Info: <b>Hidden power pin %s</b> %s at location <b>(%s, %s)</b>"
|
2021-02-04 22:46:57 +00:00
|
|
|
" of converted." ),
|
|
|
|
pin->GetNumber(),
|
|
|
|
pinName,
|
2021-07-23 16:23:11 +00:00
|
|
|
MessageTextFromValue( units, pin->GetPosition().x ),
|
|
|
|
MessageTextFromValue( units, -pin->GetPosition().y ) );
|
2021-02-04 22:46:57 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2021-07-24 15:03:36 +00:00
|
|
|
msg.Printf( _( "Info: <b>Hidden power pin %s</b> %s at location <b>(%s, %s)</b>"
|
2021-02-04 22:46:57 +00:00
|
|
|
" in unit %c of converted." ),
|
|
|
|
pin->GetNumber(),
|
|
|
|
pinName,
|
2021-07-23 16:23:11 +00:00
|
|
|
MessageTextFromValue( units, pin->GetPosition().x ),
|
|
|
|
MessageTextFromValue( units, -pin->GetPosition().y ),
|
2021-02-04 22:46:57 +00:00
|
|
|
'A' + pin->GetUnit() - 1 );
|
|
|
|
}
|
2020-10-21 19:27:40 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2021-06-10 18:51:46 +00:00
|
|
|
if( symbol->GetUnitCount() <= 1 )
|
2021-02-04 22:46:57 +00:00
|
|
|
{
|
2021-07-24 15:03:36 +00:00
|
|
|
msg.Printf( _( "Info: <b>Hidden power pin %s</b> %s at location <b>(%s, %s)</b>." ),
|
2021-02-04 22:46:57 +00:00
|
|
|
pin->GetNumber(),
|
|
|
|
pinName,
|
2021-07-23 16:23:11 +00:00
|
|
|
MessageTextFromValue( units, pin->GetPosition().x ),
|
|
|
|
MessageTextFromValue( units, -pin->GetPosition().y ) );
|
2021-02-04 22:46:57 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2021-07-24 15:03:36 +00:00
|
|
|
msg.Printf( _( "Info: <b>Hidden power pin %s</b> %s at location <b>(%s, %s)</b>"
|
2021-02-04 22:46:57 +00:00
|
|
|
" in unit %c." ),
|
|
|
|
pin->GetNumber(),
|
|
|
|
pinName,
|
2021-07-23 16:23:11 +00:00
|
|
|
MessageTextFromValue( units, pin->GetPosition().x ),
|
|
|
|
MessageTextFromValue( units, -pin->GetPosition().y ),
|
2021-02-04 22:46:57 +00:00
|
|
|
'A' + pin->GetUnit() - 1 );
|
|
|
|
}
|
2020-10-21 19:27:40 +00:00
|
|
|
}
|
2021-02-04 22:46:57 +00:00
|
|
|
|
|
|
|
msg += wxT( "<br>" );
|
|
|
|
msg += _( "(Hidden power pins will drive their pin names on to any connected nets.)" );
|
|
|
|
msg += wxT( "<br><br>" );
|
|
|
|
messages.push_back( msg );
|
2020-10-21 19:27:40 +00:00
|
|
|
}
|
2021-02-04 22:46:57 +00:00
|
|
|
|
|
|
|
if( ( (pin->GetPosition().x % clamped_grid_size) != 0 )
|
|
|
|
|| ( (pin->GetPosition().y % clamped_grid_size) != 0 ) )
|
2019-06-02 18:58:09 +00:00
|
|
|
{
|
2021-02-04 22:46:57 +00:00
|
|
|
// pin is off grid
|
2021-06-10 18:51:46 +00:00
|
|
|
if( symbol->HasConversion() && pin->GetConvert() )
|
2020-10-21 19:27:40 +00:00
|
|
|
{
|
2021-06-10 18:51:46 +00:00
|
|
|
if( symbol->GetUnitCount() <= 1 )
|
2021-02-04 22:46:57 +00:00
|
|
|
{
|
2021-07-23 16:23:11 +00:00
|
|
|
msg.Printf( _( "<b>Off grid pin %s</b> %s at location <b>(%s, %s)</b>"
|
2021-02-04 22:46:57 +00:00
|
|
|
" of converted." ),
|
|
|
|
pin->GetNumber(),
|
|
|
|
pinName,
|
2021-07-23 16:23:11 +00:00
|
|
|
MessageTextFromValue( units, pin->GetPosition().x ),
|
|
|
|
MessageTextFromValue( units, -pin->GetPosition().y ) );
|
2021-02-04 22:46:57 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2021-07-23 16:23:11 +00:00
|
|
|
msg.Printf( _( "<b>Off grid pin %s</b> %s at location <b>(%.3s, %.3s)</b>"
|
2021-02-04 22:46:57 +00:00
|
|
|
" in unit %c of converted." ),
|
|
|
|
pin->GetNumber(),
|
|
|
|
pinName,
|
2021-07-23 16:23:11 +00:00
|
|
|
MessageTextFromValue( units, pin->GetPosition().x ),
|
|
|
|
MessageTextFromValue( units, -pin->GetPosition().y ),
|
2021-02-04 22:46:57 +00:00
|
|
|
'A' + pin->GetUnit() - 1 );
|
|
|
|
}
|
2020-10-21 19:27:40 +00:00
|
|
|
}
|
2019-06-02 18:58:09 +00:00
|
|
|
else
|
2020-10-21 19:27:40 +00:00
|
|
|
{
|
2021-06-10 18:51:46 +00:00
|
|
|
if( symbol->GetUnitCount() <= 1 )
|
2021-02-04 22:46:57 +00:00
|
|
|
{
|
2021-07-23 16:23:11 +00:00
|
|
|
msg.Printf( _( "<b>Off grid pin %s</b> %s at location <b>(%s, %s)</b>." ),
|
2021-02-04 22:46:57 +00:00
|
|
|
pin->GetNumber(),
|
|
|
|
pinName,
|
2021-07-23 16:23:11 +00:00
|
|
|
MessageTextFromValue( units, pin->GetPosition().x ),
|
|
|
|
MessageTextFromValue( units, -pin->GetPosition().y ) );
|
2021-02-04 22:46:57 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2021-07-23 16:23:11 +00:00
|
|
|
msg.Printf( _( "<b>Off grid pin %s</b> %s at location <b>(%s, %s)</b>"
|
2021-02-04 22:46:57 +00:00
|
|
|
" in unit %c." ),
|
|
|
|
pin->GetNumber(),
|
|
|
|
pinName,
|
2021-07-23 16:23:11 +00:00
|
|
|
MessageTextFromValue( units, pin->GetPosition().x ),
|
|
|
|
MessageTextFromValue( units, -pin->GetPosition().y ),
|
2021-02-04 22:46:57 +00:00
|
|
|
'A' + pin->GetUnit() - 1 );
|
|
|
|
}
|
2020-10-21 19:27:40 +00:00
|
|
|
}
|
2019-06-02 18:58:09 +00:00
|
|
|
|
2021-02-04 22:46:57 +00:00
|
|
|
msg += wxT( "<br><br>" );
|
|
|
|
messages.push_back( msg );
|
|
|
|
}
|
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
|
|
|
{
|
2021-10-10 12:52:37 +00:00
|
|
|
wxString outmsg;
|
2020-02-27 23:06:48 +00:00
|
|
|
|
2021-09-20 18:45:27 +00:00
|
|
|
for( const wxString& single_msg : messages )
|
|
|
|
outmsg += single_msg;
|
2020-02-27 23:06:48 +00:00
|
|
|
|
2021-09-14 18:26:03 +00:00
|
|
|
DIALOG_DISPLAY_HTML_TEXT error_display( m_frame, wxID_ANY, _( "Symbol Warnings" ),
|
|
|
|
wxDefaultPosition, wxSize( 700, 350 ) );
|
2021-07-24 16:59:28 +00:00
|
|
|
|
2021-09-14 18:26:03 +00:00
|
|
|
error_display.SetPage( outmsg );
|
2019-06-02 18:58:09 +00:00
|
|
|
error_display.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
|
|
|
}
|
|
|
|
|
|
|
|
|
2019-06-01 18:36:49 +00:00
|
|
|
int EE_INSPECTION_TOOL::RunSimulation( const TOOL_EVENT& aEvent )
|
|
|
|
{
|
|
|
|
#ifdef KICAD_SPICE
|
|
|
|
SIM_PLOT_FRAME* simFrame = (SIM_PLOT_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();
|
|
|
|
#endif /* KICAD_SPICE */
|
|
|
|
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
|
|
|
}
|
2019-06-02 18:58:09 +00:00
|
|
|
else if( m_frame->IsType( FRAME_SCH_VIEWER ) || m_frame->IsType( FRAME_SCH_VIEWER_MODAL ) )
|
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
|
|
|
{
|
2021-06-14 18:00:08 +00:00
|
|
|
EE_SELECTION& selection = m_selectionTool->RequestSelection( EE_COLLECTOR::SymbolsOnly );
|
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
|
|
|
|
2022-02-18 21:43:37 +00:00
|
|
|
// Use GetShownText() to resolve any text variables
|
|
|
|
datasheet = symbol->GetField( DATASHEET_FIELD )->GetShownText();
|
2019-06-01 18:36:49 +00:00
|
|
|
}
|
|
|
|
|
2021-04-21 14:21:34 +00:00
|
|
|
if( datasheet.IsEmpty() || datasheet == wxT( "~" ) )
|
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
|
|
|
{
|
2022-05-11 01:28:48 +00:00
|
|
|
GetAssociatedDocument( m_frame, datasheet, &m_frame->Prj(), m_frame->Prj().SchSearchS() );
|
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
|
|
|
{
|
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
|
|
|
|
|
|
|
if( selection.GetSize() == 1 )
|
|
|
|
{
|
2019-05-06 12:32:51 +00:00
|
|
|
EDA_ITEM* item = (EDA_ITEM*) selection.Front();
|
2019-04-30 18:36:11 +00:00
|
|
|
|
2021-09-26 23:22:32 +00:00
|
|
|
std::vector<MSG_PANEL_ITEM> msgItems;
|
2020-04-24 13:36:10 +00:00
|
|
|
item->GetMsgPanelInfo( m_frame, msgItems );
|
2019-04-30 18:36:11 +00:00
|
|
|
m_frame->SetMsgPanel( msgItems );
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
m_frame->ClearMsgPanel();
|
|
|
|
}
|
|
|
|
|
2020-08-13 21:30:30 +00:00
|
|
|
if( SCH_EDIT_FRAME* editFrame = dynamic_cast<SCH_EDIT_FRAME*>( m_frame ) )
|
|
|
|
editFrame->UpdateNetHighlightStatus();
|
|
|
|
|
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() );
|
|
|
|
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() );
|
2019-06-01 18:36:49 +00:00
|
|
|
Go( &EE_INSPECTION_TOOL::RunSimulation, EE_ACTIONS::runSimulation.MakeEvent() );
|
|
|
|
|
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
|
|
|
|
2019-05-10 17:19:48 +00:00
|
|
|
Go( &EE_INSPECTION_TOOL::UpdateMessagePanel, EVENTS::SelectedEvent );
|
|
|
|
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
|
|
|
}
|
|
|
|
|
|
|
|
|