Move show datasheet to SCH_INSPECTOR_TOOL and add show marker info.
This commit is contained in:
parent
902be18a04
commit
2244dcd567
|
@ -190,3 +190,9 @@ SELECTION_CONDITION operator&&( const SELECTION_CONDITION& aConditionA,
|
|||
{
|
||||
return std::bind( &SELECTION_CONDITIONS::andFunc, aConditionA, aConditionB, _1 );
|
||||
}
|
||||
|
||||
|
||||
SELECTION_CONDITION operator!( const SELECTION_CONDITION& aCondition )
|
||||
{
|
||||
return std::bind( &SELECTION_CONDITIONS::notFunc, aCondition, _1 );
|
||||
}
|
||||
|
|
|
@ -244,6 +244,7 @@ set( EESCHEMA_SRCS
|
|||
tools/sch_drawing_tool.cpp
|
||||
tools/sch_edit_tool.cpp
|
||||
tools/sch_editor_control.cpp
|
||||
tools/sch_inspection_tool.cpp
|
||||
tools/sch_picker_tool.cpp
|
||||
tools/sch_selection_tool.cpp
|
||||
tools/selection.cpp
|
||||
|
|
|
@ -50,41 +50,6 @@
|
|||
#include <view/view_group.h>
|
||||
|
||||
|
||||
int SCH_EDIT_FRAME::BlockCommand( EDA_KEY key )
|
||||
{
|
||||
int cmd = BLOCK_IDLE;
|
||||
|
||||
switch( key )
|
||||
{
|
||||
default:
|
||||
cmd = key & 0xFF;
|
||||
break;
|
||||
|
||||
case 0:
|
||||
cmd = BLOCK_MOVE;
|
||||
break;
|
||||
|
||||
case GR_KB_SHIFT:
|
||||
cmd = BLOCK_DUPLICATE;
|
||||
break;
|
||||
|
||||
case GR_KB_CTRL:
|
||||
cmd = BLOCK_DRAG;
|
||||
break;
|
||||
|
||||
case GR_KB_SHIFTCTRL:
|
||||
cmd = BLOCK_DELETE;
|
||||
break;
|
||||
|
||||
case MOUSE_MIDDLE:
|
||||
cmd = BLOCK_ZOOM;
|
||||
break;
|
||||
}
|
||||
|
||||
return cmd;
|
||||
}
|
||||
|
||||
|
||||
void SCH_EDIT_FRAME::InitBlockPasteInfos()
|
||||
{
|
||||
wxFAIL_MSG( "How did we get here? Should have gone through modern toolset..." );
|
||||
|
|
|
@ -151,7 +151,6 @@ enum id_eeschema_frm
|
|||
ID_POPUP_SCH_ADD_JUNCTION,
|
||||
ID_POPUP_SCH_ADD_LABEL,
|
||||
ID_POPUP_SCH_ADD_GLABEL,
|
||||
ID_POPUP_SCH_GETINFO_MARKER,
|
||||
ID_POPUP_END_RANGE,
|
||||
|
||||
// Dynamically bound in AddMenusForBus()
|
||||
|
@ -175,7 +174,6 @@ enum id_eeschema_frm
|
|||
// Change orientation command IDs.
|
||||
ID_SCH_MIRROR_X,
|
||||
ID_SCH_MIRROR_Y,
|
||||
ID_SCH_ORIENT_NORMAL,
|
||||
|
||||
ID_SCH_ROTATE_CLOCKWISE,
|
||||
ID_SCH_ROTATE_COUNTERCLOCKWISE,
|
||||
|
|
|
@ -26,7 +26,6 @@
|
|||
#include <fctsys.h>
|
||||
#include <eeschema_id.h>
|
||||
#include <sch_draw_panel.h>
|
||||
#include <confirm.h>
|
||||
#include <sch_edit_frame.h>
|
||||
#include <menus_helpers.h>
|
||||
|
||||
|
@ -35,22 +34,15 @@
|
|||
#include <connection_graph.h>
|
||||
#include <general.h>
|
||||
#include <hotkeys.h>
|
||||
#include <netlist_object.h>
|
||||
#include <sch_bus_entry.h>
|
||||
#include <sch_marker.h>
|
||||
#include <sch_text.h>
|
||||
#include <sch_junction.h>
|
||||
#include <sch_component.h>
|
||||
#include <sch_line.h>
|
||||
#include <sch_no_connect.h>
|
||||
#include <sch_sheet.h>
|
||||
#include <sch_sheet_path.h>
|
||||
#include <sch_bitmap.h>
|
||||
#include <symbol_lib_table.h>
|
||||
#include <sch_connection.h>
|
||||
#include <sch_view.h>
|
||||
|
||||
#include <iostream>
|
||||
#include <tool/tool_manager.h>
|
||||
#include <tools/sch_actions.h>
|
||||
#include <tools/sch_selection_tool.h>
|
||||
|
@ -60,33 +52,13 @@ static void AddMenusForBus( wxMenu* PopMenu, SCH_LINE* Bus, SCH_EDIT_FRAME* fram
|
|||
static void AddMenusForHierchicalSheet( wxMenu* PopMenu, SCH_SHEET* Sheet );
|
||||
static void AddMenusForComponent( wxMenu* PopMenu, SCH_COMPONENT* Component,
|
||||
SYMBOL_LIB_TABLE* aLibs );
|
||||
static void AddMenusForMarkers( wxMenu* aPopMenu, SCH_MARKER* aMarker, SCH_EDIT_FRAME* aFrame );
|
||||
|
||||
|
||||
bool SCH_EDIT_FRAME::OnRightClick( const wxPoint& aPosition, wxMenu* PopMenu )
|
||||
{
|
||||
SCH_SELECTION_TOOL* selTool = GetToolManager()->GetTool<SCH_SELECTION_TOOL>();
|
||||
SCH_ITEM* item = GetScreen()->GetCurItem();
|
||||
wxString msg;
|
||||
|
||||
// Ugly hack, clear any highligthed symbol, because the HIGHLIGHT flag create issues when creating menus
|
||||
// Will be fixed later
|
||||
GetCanvas()->GetView()->HighlightItem( nullptr, nullptr );
|
||||
|
||||
// Do not start a block command on context menu.
|
||||
m_canvas->SetCanStartBlock( -1 );
|
||||
|
||||
// Try to locate items at cursor position.
|
||||
if( item == NULL || item->GetEditFlags() == 0 )
|
||||
{
|
||||
bool actionCancelled = false;
|
||||
item = selTool->SelectPoint( aPosition, SCH_COLLECTOR::AllItemsButPins, &actionCancelled );
|
||||
|
||||
// If the clarify item selection context menu is aborted, don't show the context menu.
|
||||
if( item == NULL && actionCancelled )
|
||||
return false;
|
||||
}
|
||||
|
||||
// If a command is in progress: add "cancel" and "end tool" menu
|
||||
if( GetToolId() != ID_NO_TOOL_SELECTED )
|
||||
{
|
||||
|
@ -118,19 +90,10 @@ bool SCH_EDIT_FRAME::OnRightClick( const wxPoint& aPosition, wxMenu* PopMenu )
|
|||
|
||||
switch( item->Type() )
|
||||
{
|
||||
case SCH_NO_CONNECT_T:
|
||||
AddMenuItem( PopMenu, ID_SCH_DELETE, _( "Delete No Connect" ),
|
||||
KiBitmap( delete_xpm ) );
|
||||
break;
|
||||
|
||||
case SCH_JUNCTION_T:
|
||||
addJunctionMenuEntries( PopMenu, (SCH_JUNCTION*) item );
|
||||
break;
|
||||
|
||||
case SCH_MARKER_T:
|
||||
AddMenusForMarkers( PopMenu, (SCH_MARKER*) item, this );
|
||||
break;
|
||||
|
||||
case SCH_COMPONENT_T:
|
||||
AddMenusForComponent( PopMenu, (SCH_COMPONENT*) item, Prj().SchSymbolLibTable() );
|
||||
break;
|
||||
|
@ -153,7 +116,6 @@ bool SCH_EDIT_FRAME::OnRightClick( const wxPoint& aPosition, wxMenu* PopMenu )
|
|||
break;
|
||||
}
|
||||
|
||||
PopMenu->AppendSeparator();
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -341,10 +303,3 @@ void AddMenusForHierchicalSheet( wxMenu* PopMenu, SCH_SHEET* Sheet )
|
|||
}
|
||||
|
||||
|
||||
void AddMenusForMarkers( wxMenu* aPopMenu, SCH_MARKER* aMarker, SCH_EDIT_FRAME* aFrame )
|
||||
{
|
||||
AddMenuItem( aPopMenu, ID_POPUP_SCH_GETINFO_MARKER, _( "Marker Error Info" ),
|
||||
KiBitmap( info_xpm ) );
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -1140,16 +1140,6 @@ public:
|
|||
*/
|
||||
void InitBlockPasteInfos() override;
|
||||
|
||||
/**
|
||||
* Return the block command internal code (BLOCK_MOVE, BLOCK_DUPLICATE...)
|
||||
* corresponding to the keys pressed (ALT, SHIFT, SHIFT ALT ..) when
|
||||
* block command is started by dragging the mouse.
|
||||
*
|
||||
* @param aKey = the key modifiers (Alt, Shift ...)
|
||||
* @return the block command id (BLOCK_MOVE, BLOCK_DUPLICATE...)
|
||||
*/
|
||||
virtual int BlockCommand( EDA_KEY aKey ) override;
|
||||
|
||||
/**
|
||||
* Call after HandleBlockEnd, when a block command needs to be executed after the block
|
||||
* is moved to its new place.
|
||||
|
|
|
@ -1416,10 +1416,9 @@ void SCH_PAINTER::draw( SCH_MARKER *aMarker, int aLayer )
|
|||
SHAPE_LINE_CHAIN polygon;
|
||||
aMarker->ShapeToPolygon( polygon );
|
||||
|
||||
COLOR4D color = m_schSettings.GetLayerColor( LAYER_ERC_WARN );
|
||||
|
||||
if( aMarker->GetErrorLevel() == MARKER_BASE::MARKER_SEVERITY_ERROR )
|
||||
color = m_schSettings.GetLayerColor( LAYER_ERC_ERR );
|
||||
int layer = aMarker->GetErrorLevel() == MARKER_BASE::MARKER_SEVERITY_ERROR ? LAYER_ERC_ERR
|
||||
: LAYER_ERC_WARN;
|
||||
COLOR4D color = getRenderColor( aMarker, layer, false );
|
||||
|
||||
m_gal->Save();
|
||||
m_gal->Translate( aMarker->GetPosition() );
|
||||
|
|
|
@ -74,7 +74,6 @@
|
|||
case ID_POPUP_SCH_LEAVE_SHEET:
|
||||
case ID_POPUP_SCH_ADD_JUNCTION:
|
||||
case ID_POPUP_SCH_ADD_LABEL:
|
||||
case ID_POPUP_SCH_GETINFO_MARKER:
|
||||
/* At this point: Do nothing. these commands do not need to stop the
|
||||
* current command (mainly a block command) or reset the current state
|
||||
* They will be executed later, in next switch structure.
|
||||
|
@ -182,12 +181,6 @@
|
|||
}
|
||||
break;
|
||||
|
||||
case ID_POPUP_SCH_GETINFO_MARKER:
|
||||
if( item && item->Type() == SCH_MARKER_T )
|
||||
( (SCH_MARKER*) item )->DisplayMarkerInfo( this );
|
||||
|
||||
break;
|
||||
|
||||
default: // Log error:
|
||||
wxFAIL_MSG( wxString::Format( "Cannot process command event ID %d", event.GetId() ) );
|
||||
break;
|
||||
|
|
|
@ -31,6 +31,7 @@
|
|||
#include <tools/sch_selection_tool.h>
|
||||
#include <tools/sch_actions.h>
|
||||
#include <tools/sch_edit_tool.h>
|
||||
#include <tools/sch_inspection_tool.h>
|
||||
#include <tool/zoom_tool.h>
|
||||
|
||||
|
||||
|
@ -261,4 +262,5 @@ void SCH_ACTIONS::RegisterAllTools( TOOL_MANAGER* aToolManager )
|
|||
aToolManager->RegisterTool( new SCH_PICKER_TOOL );
|
||||
aToolManager->RegisterTool( new SCH_DRAWING_TOOL );
|
||||
aToolManager->RegisterTool( new SCH_EDIT_TOOL );
|
||||
aToolManager->RegisterTool( new SCH_INSPECTION_TOOL );
|
||||
}
|
||||
|
|
|
@ -132,7 +132,6 @@ public:
|
|||
static TOOL_ACTION editValue;
|
||||
static TOOL_ACTION editFootprint;
|
||||
static TOOL_ACTION autoplaceFields;
|
||||
static TOOL_ACTION showDatasheet;
|
||||
static TOOL_ACTION doDelete;
|
||||
static TOOL_ACTION addJunction;
|
||||
static TOOL_ACTION addLabel;
|
||||
|
@ -144,6 +143,10 @@ public:
|
|||
static TOOL_ACTION toGLabel;
|
||||
static TOOL_ACTION toText;
|
||||
|
||||
/// Inspection
|
||||
static TOOL_ACTION showDatasheet;
|
||||
static TOOL_ACTION showMarkerInfo;
|
||||
|
||||
/// Clipboard
|
||||
static TOOL_ACTION cut;
|
||||
static TOOL_ACTION copy;
|
||||
|
|
|
@ -111,11 +111,6 @@ TOOL_ACTION SCH_ACTIONS::autoplaceFields( "eeschema.InteractiveEdit.autoplaceFie
|
|||
_( "Autoplace Fields" ), _( "Runs the automatic placement algorithm on the symbol's fields" ),
|
||||
autoplace_fields_xpm );
|
||||
|
||||
TOOL_ACTION SCH_ACTIONS::showDatasheet( "eeschema.InteractiveEdit.showDatasheet",
|
||||
AS_GLOBAL, TOOL_ACTION::LegacyHotKey( HK_SHOW_COMPONENT_DATASHEET ),
|
||||
_( "Show Datasheet" ), _( "Opens the datasheet in a browser" ),
|
||||
datasheet_xpm );
|
||||
|
||||
TOOL_ACTION SCH_ACTIONS::toShapeSlash( "eeschema.InteractiveEdit.toShapeSlash",
|
||||
AS_GLOBAL, 0,
|
||||
_( "Set Bus Entry Shape /" ), _( "Change the bus entry shape to /" ),
|
||||
|
@ -223,6 +218,29 @@ bool SCH_EDIT_TOOL::Init()
|
|||
}
|
||||
};
|
||||
|
||||
auto hasPropertiesCondition = [] ( const SELECTION& aSel ) {
|
||||
if( aSel.GetSize() != 1 )
|
||||
return false;
|
||||
|
||||
switch( static_cast<EDA_ITEM*>( aSel.GetItem( 0 ) )->Type() )
|
||||
{
|
||||
case SCH_MARKER_T:
|
||||
case SCH_JUNCTION_T:
|
||||
case SCH_NO_CONNECT_T:
|
||||
case SCH_BUS_WIRE_ENTRY_T:
|
||||
case SCH_BUS_BUS_ENTRY_T:
|
||||
case SCH_LINE_T:
|
||||
case SCH_SHEET_PIN_T:
|
||||
case SCH_PIN_T:
|
||||
return false;
|
||||
default:
|
||||
return true;
|
||||
}
|
||||
};
|
||||
|
||||
auto notJustMarkersCondition = SELECTION_CONDITIONS::MoreThan( 0 )
|
||||
&& !SELECTION_CONDITIONS::OnlyType( SCH_MARKER_T );
|
||||
|
||||
auto toLabelCondition = SELECTION_CONDITIONS::Count( 1 )
|
||||
&& ( SELECTION_CONDITIONS::HasType( SCH_GLOBAL_LABEL_T )
|
||||
|| SELECTION_CONDITIONS::HasType( SCH_HIER_LABEL_T )
|
||||
|
@ -275,10 +293,10 @@ bool SCH_EDIT_TOOL::Init()
|
|||
ctxMenu.AddItem( SCH_ACTIONS::rotateCW, orientatableCondition );
|
||||
ctxMenu.AddItem( SCH_ACTIONS::mirrorX, orientatableCondition );
|
||||
ctxMenu.AddItem( SCH_ACTIONS::mirrorY, orientatableCondition );
|
||||
ctxMenu.AddItem( SCH_ACTIONS::duplicate, SELECTION_CONDITIONS::NotEmpty );
|
||||
ctxMenu.AddItem( SCH_ACTIONS::duplicate, notJustMarkersCondition );
|
||||
ctxMenu.AddItem( SCH_ACTIONS::doDelete, SELECTION_CONDITIONS::NotEmpty );
|
||||
|
||||
ctxMenu.AddItem( SCH_ACTIONS::properties, SELECTION_CONDITIONS::Count( 1 ) );
|
||||
ctxMenu.AddItem( SCH_ACTIONS::properties, hasPropertiesCondition );
|
||||
ctxMenu.AddItem( SCH_ACTIONS::editReference, singleComponentCondition );
|
||||
ctxMenu.AddItem( SCH_ACTIONS::editValue, singleComponentCondition );
|
||||
ctxMenu.AddItem( SCH_ACTIONS::editFootprint, singleComponentCondition );
|
||||
|
@ -300,7 +318,7 @@ bool SCH_EDIT_TOOL::Init()
|
|||
drawingMenu.AddItem( SCH_ACTIONS::mirrorX, orientatableCondition, 200 );
|
||||
drawingMenu.AddItem( SCH_ACTIONS::mirrorY, orientatableCondition, 200 );
|
||||
|
||||
drawingMenu.AddItem( SCH_ACTIONS::properties, SELECTION_CONDITIONS::Count( 1 ), 200 );
|
||||
drawingMenu.AddItem( SCH_ACTIONS::properties, hasPropertiesCondition, 200 );
|
||||
drawingMenu.AddItem( SCH_ACTIONS::editReference, singleComponentCondition, 200 );
|
||||
drawingMenu.AddItem( SCH_ACTIONS::editValue, singleComponentCondition, 200 );
|
||||
drawingMenu.AddItem( SCH_ACTIONS::editFootprint, singleComponentCondition, 200 );
|
||||
|
@ -321,10 +339,10 @@ bool SCH_EDIT_TOOL::Init()
|
|||
selToolMenu.AddItem( SCH_ACTIONS::rotateCW, orientatableCondition, 200 );
|
||||
selToolMenu.AddItem( SCH_ACTIONS::mirrorX, orientatableCondition, 200 );
|
||||
selToolMenu.AddItem( SCH_ACTIONS::mirrorY, orientatableCondition, 200 );
|
||||
selToolMenu.AddItem( SCH_ACTIONS::duplicate, SELECTION_CONDITIONS::NotEmpty, 200 );
|
||||
selToolMenu.AddItem( SCH_ACTIONS::duplicate, notJustMarkersCondition, 200 );
|
||||
selToolMenu.AddItem( SCH_ACTIONS::doDelete, SELECTION_CONDITIONS::NotEmpty, 200 );
|
||||
|
||||
selToolMenu.AddItem( SCH_ACTIONS::properties, SELECTION_CONDITIONS::Count( 1 ), 200 );
|
||||
selToolMenu.AddItem( SCH_ACTIONS::properties, hasPropertiesCondition, 200 );
|
||||
selToolMenu.AddItem( SCH_ACTIONS::editReference, singleSymbolCondition, 200 );
|
||||
selToolMenu.AddItem( SCH_ACTIONS::editValue, singleSymbolCondition, 200 );
|
||||
selToolMenu.AddItem( SCH_ACTIONS::editFootprint, singleSymbolCondition, 200 );
|
||||
|
@ -1296,23 +1314,6 @@ int SCH_EDIT_TOOL::AutoplaceFields( const TOOL_EVENT& aEvent )
|
|||
}
|
||||
|
||||
|
||||
int SCH_EDIT_TOOL::ShowDatasheet( const TOOL_EVENT& aEvent )
|
||||
{
|
||||
SELECTION& selection = m_selectionTool->RequestSelection( SCH_COLLECTOR::ComponentsOnly );
|
||||
|
||||
if( selection.Empty() )
|
||||
return 0;
|
||||
|
||||
SCH_COMPONENT* component = (SCH_COMPONENT*) selection.GetItem( 0 );
|
||||
wxString datasheet = component->GetField( DATASHEET )->GetText();
|
||||
|
||||
if( !datasheet.IsEmpty() )
|
||||
GetAssociatedDocument( m_frame, datasheet );
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
int SCH_EDIT_TOOL::Properties( const TOOL_EVENT& aEvent )
|
||||
{
|
||||
SELECTION& selection = m_selectionTool->RequestSelection( SCH_COLLECTOR::EditableItems );
|
||||
|
@ -1500,7 +1501,6 @@ void SCH_EDIT_TOOL::setTransitions()
|
|||
Go( &SCH_EDIT_TOOL::EditField, SCH_ACTIONS::editValue.MakeEvent() );
|
||||
Go( &SCH_EDIT_TOOL::EditField, SCH_ACTIONS::editFootprint.MakeEvent() );
|
||||
Go( &SCH_EDIT_TOOL::AutoplaceFields, SCH_ACTIONS::autoplaceFields.MakeEvent() );
|
||||
Go( &SCH_EDIT_TOOL::ShowDatasheet, SCH_ACTIONS::showDatasheet.MakeEvent() );
|
||||
|
||||
Go( &SCH_EDIT_TOOL::ChangeShape, SCH_ACTIONS::toShapeSlash.MakeEvent() );
|
||||
Go( &SCH_EDIT_TOOL::ChangeShape, SCH_ACTIONS::toShapeBackslash.MakeEvent() );
|
||||
|
|
|
@ -46,10 +46,7 @@ public:
|
|||
void Reset( RESET_REASON aReason ) override;
|
||||
|
||||
///> Get the SCH_DRAWING_TOOL top-level context menu
|
||||
inline TOOL_MENU& GetToolMenu()
|
||||
{
|
||||
return m_menu;
|
||||
}
|
||||
inline TOOL_MENU& GetToolMenu() { return m_menu; }
|
||||
|
||||
/**
|
||||
* Function Main()
|
||||
|
@ -67,7 +64,6 @@ public:
|
|||
int Properties( const TOOL_EVENT& aEvent );
|
||||
int EditField( const TOOL_EVENT& aEvent );
|
||||
int AutoplaceFields( const TOOL_EVENT& aEvent );
|
||||
int ShowDatasheet( const TOOL_EVENT& aEvent );
|
||||
|
||||
int ChangeShape( const TOOL_EVENT& aEvent );
|
||||
int ChangeTextType( const TOOL_EVENT& aEvent );
|
||||
|
|
|
@ -0,0 +1,149 @@
|
|||
/*
|
||||
* This program source code file is part of KiCad, a free EDA CAD application.
|
||||
*
|
||||
* Copyright (C) 2019 KiCad Developers, see AUTHORS.txt for contributors.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation; either version 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
|
||||
*/
|
||||
|
||||
#include <tools/sch_actions.h>
|
||||
#include <tools/sch_inspection_tool.h>
|
||||
#include <tools/sch_selection_tool.h>
|
||||
#include <view/view_controls.h>
|
||||
#include <sch_component.h>
|
||||
#include <sch_marker.h>
|
||||
#include <hotkeys.h>
|
||||
#include <confirm.h>
|
||||
#include <tool/conditional_menu.h>
|
||||
#include <tool/selection_conditions.h>
|
||||
#include <tool/selection.h>
|
||||
#include <tool/tool_manager.h>
|
||||
#include <sch_view.h>
|
||||
#include <sch_edit_frame.h>
|
||||
#include <eda_doc.h>
|
||||
|
||||
|
||||
TOOL_ACTION SCH_ACTIONS::showDatasheet( "eeschema.InspectionTool.showDatasheet",
|
||||
AS_GLOBAL, TOOL_ACTION::LegacyHotKey( HK_SHOW_COMPONENT_DATASHEET ),
|
||||
_( "Show Datasheet" ), _( "Opens the datasheet in a browser" ),
|
||||
datasheet_xpm );
|
||||
|
||||
TOOL_ACTION SCH_ACTIONS::showMarkerInfo( "eeschema.InspectionTool.showMarkerInfo",
|
||||
AS_GLOBAL, 0,
|
||||
_( "Show Marker Info" ), _( "Display the marker's info in a dialog" ),
|
||||
info_xpm );
|
||||
|
||||
|
||||
SCH_INSPECTION_TOOL::SCH_INSPECTION_TOOL()
|
||||
: TOOL_INTERACTIVE( "eeschema.InspectionTool" ),
|
||||
m_selectionTool( nullptr ),
|
||||
m_view( nullptr ),
|
||||
m_controls( nullptr ),
|
||||
m_frame( nullptr )
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
bool SCH_INSPECTION_TOOL::Init()
|
||||
{
|
||||
m_frame = getEditFrame<SCH_EDIT_FRAME>();
|
||||
m_selectionTool = m_toolMgr->GetTool<SCH_SELECTION_TOOL>();
|
||||
|
||||
if( !m_selectionTool )
|
||||
{
|
||||
DisplayError( NULL, _( "eeshema.InteractiveSelection tool is not available" ) );
|
||||
return false;
|
||||
}
|
||||
|
||||
auto singleMarkerCondition = SELECTION_CONDITIONS::OnlyType( SCH_MARKER_T )
|
||||
&& SELECTION_CONDITIONS::Count( 1 );
|
||||
|
||||
auto singleSymbolCondition = [] (const SELECTION& aSel ) {
|
||||
if( aSel.GetSize() == 1 )
|
||||
{
|
||||
SCH_COMPONENT* comp = dynamic_cast<SCH_COMPONENT*>( aSel.GetItem( 0 ) );
|
||||
|
||||
if( comp )
|
||||
{
|
||||
auto partRef = comp->GetPartRef().lock();
|
||||
return !partRef || !partRef->IsPower();
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
};
|
||||
|
||||
// Add inspection actions to the selection tool menu
|
||||
//
|
||||
CONDITIONAL_MENU& selToolMenu = m_selectionTool->GetToolMenu().GetMenu();
|
||||
|
||||
selToolMenu.AddItem( SCH_ACTIONS::showDatasheet, singleSymbolCondition, 400 );
|
||||
selToolMenu.AddItem( SCH_ACTIONS::showMarkerInfo, singleMarkerCondition, 400 );
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
void SCH_INSPECTION_TOOL::Reset( RESET_REASON aReason )
|
||||
{
|
||||
m_view = static_cast<KIGFX::SCH_VIEW*>( getView() );
|
||||
m_controls = getViewControls();
|
||||
m_frame = getEditFrame<SCH_EDIT_FRAME>();
|
||||
}
|
||||
|
||||
|
||||
int SCH_INSPECTION_TOOL::ShowDatasheet( const TOOL_EVENT& aEvent )
|
||||
{
|
||||
SELECTION& selection = m_selectionTool->RequestSelection( SCH_COLLECTOR::ComponentsOnly );
|
||||
|
||||
if( selection.Empty() )
|
||||
return 0;
|
||||
|
||||
SCH_COMPONENT* component = (SCH_COMPONENT*) selection.GetItem( 0 );
|
||||
wxString datasheet = component->GetField( DATASHEET )->GetText();
|
||||
|
||||
if( !datasheet.IsEmpty() )
|
||||
GetAssociatedDocument( m_frame, datasheet );
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
int SCH_INSPECTION_TOOL::ShowMarkerInfo( const TOOL_EVENT& aEvent )
|
||||
{
|
||||
SELECTION& selection = m_selectionTool->GetSelection();
|
||||
|
||||
if( selection.Empty() )
|
||||
return 0;
|
||||
|
||||
SCH_MARKER* marker = dynamic_cast<SCH_MARKER*>( selection.GetItem( 0 ) );
|
||||
|
||||
if( marker )
|
||||
marker->DisplayMarkerInfo( m_frame );
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
void SCH_INSPECTION_TOOL::setTransitions()
|
||||
{
|
||||
Go( &SCH_INSPECTION_TOOL::ShowDatasheet, SCH_ACTIONS::showDatasheet.MakeEvent() );
|
||||
Go( &SCH_INSPECTION_TOOL::ShowMarkerInfo, SCH_ACTIONS::showMarkerInfo.MakeEvent() );
|
||||
}
|
||||
|
||||
|
|
@ -0,0 +1,62 @@
|
|||
/*
|
||||
* This program source code file is part of KiCad, a free EDA CAD application.
|
||||
*
|
||||
* Copyright (C) 2019 KiCad Developers, see AUTHORS.txt for contributors.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation; either version 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
|
||||
*/
|
||||
|
||||
#ifndef SCH_INSPECTION_TOOL_H
|
||||
#define SCH_INSPECTION_TOOL_H
|
||||
|
||||
#include <boost/optional/optional.hpp>
|
||||
#include <tool/tool_interactive.h>
|
||||
#include <sch_base_frame.h>
|
||||
|
||||
|
||||
class SCH_SELECTION_TOOL;
|
||||
class SCH_EDIT_FRAME;
|
||||
|
||||
|
||||
class SCH_INSPECTION_TOOL : public TOOL_INTERACTIVE
|
||||
{
|
||||
public:
|
||||
SCH_INSPECTION_TOOL();
|
||||
~SCH_INSPECTION_TOOL() {}
|
||||
|
||||
/// @copydoc TOOL_INTERACTIVE::Init()
|
||||
bool Init() override;
|
||||
|
||||
///> @copydoc TOOL_INTERACTIVE::Reset()
|
||||
void Reset( RESET_REASON aReason ) override;
|
||||
|
||||
int ShowDatasheet( const TOOL_EVENT& aEvent );
|
||||
int ShowMarkerInfo( const TOOL_EVENT& aEvent );
|
||||
|
||||
private:
|
||||
///> @copydoc TOOL_INTERACTIVE::setTransitions();
|
||||
void setTransitions() override;
|
||||
|
||||
private:
|
||||
SCH_SELECTION_TOOL* m_selectionTool;
|
||||
KIGFX::SCH_VIEW* m_view;
|
||||
KIGFX::VIEW_CONTROLS* m_controls;
|
||||
SCH_EDIT_FRAME* m_frame;
|
||||
};
|
||||
|
||||
#endif /* SCH_INSPECTION_TOOL_H */
|
|
@ -40,6 +40,8 @@ SELECTION_CONDITION operator||( const SELECTION_CONDITION& aConditionA,
|
|||
SELECTION_CONDITION operator&&( const SELECTION_CONDITION& aConditionA,
|
||||
const SELECTION_CONDITION& aConditionB );
|
||||
|
||||
SELECTION_CONDITION operator!( const SELECTION_CONDITION& aCondition );
|
||||
|
||||
|
||||
/**
|
||||
* Class that groups generic conditions for selected items.
|
||||
|
@ -160,11 +162,19 @@ private:
|
|||
return aConditionA( aSelection ) && aConditionB( aSelection );
|
||||
}
|
||||
|
||||
///> Helper function used by operator!
|
||||
static bool notFunc( const SELECTION_CONDITION& aCondition, const SELECTION& aSelection )
|
||||
{
|
||||
return !aCondition( aSelection );
|
||||
}
|
||||
|
||||
friend SELECTION_CONDITION operator||( const SELECTION_CONDITION& aConditionA,
|
||||
const SELECTION_CONDITION& aConditionB );
|
||||
|
||||
friend SELECTION_CONDITION operator&&( const SELECTION_CONDITION& aConditionA,
|
||||
const SELECTION_CONDITION& aConditionB );
|
||||
|
||||
friend SELECTION_CONDITION operator!( const SELECTION_CONDITION& aCondition );
|
||||
};
|
||||
|
||||
#endif /* SELECTION_CONDITIONS_H_ */
|
||||
|
|
Loading…
Reference in New Issue