CrossProbes Schematics from eeschema to pcbnew
Adds a similar crossprobe as modules has in pcbnew. When clicking a sheet in eeschema, the items that are exclusive in that scheet will be selected in pcbnew if using the GAL canvas.
This commit is contained in:
parent
69a649c093
commit
dda51ab550
|
@ -87,6 +87,7 @@ SCH_ITEM* SCH_EDIT_FRAME::LocateAndShowItem( const wxPoint& aPosition, const KIC
|
||||||
SendMessageToPCBNEW( item, component );
|
SendMessageToPCBNEW( item, component );
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case SCH_SHEET_T:
|
||||||
case SCH_COMPONENT_T:
|
case SCH_COMPONENT_T:
|
||||||
component = (SCH_COMPONENT*) item;
|
component = (SCH_COMPONENT*) item;
|
||||||
SendMessageToPCBNEW( item, component );
|
SendMessageToPCBNEW( item, component );
|
||||||
|
|
|
@ -129,6 +129,11 @@ std::string FormatProbeItem( EDA_ITEM* aComponent, SCH_COMPONENT* aPart )
|
||||||
aPart = (SCH_COMPONENT*) aComponent;
|
aPart = (SCH_COMPONENT*) aComponent;
|
||||||
return StrPrintf( "$PART: %s", TO_UTF8( aPart->GetField( REFERENCE )->GetText() ) );
|
return StrPrintf( "$PART: %s", TO_UTF8( aPart->GetField( REFERENCE )->GetText() ) );
|
||||||
|
|
||||||
|
case SCH_SHEET_T:
|
||||||
|
aPart = (SCH_COMPONENT*)aComponent;
|
||||||
|
return StrPrintf( "$SHEET: %s", TO_UTF8( wxString::Format( wxT("%8.8lX"),
|
||||||
|
(unsigned long) aPart->GetTimeStamp() ) ) );
|
||||||
|
|
||||||
case LIB_PIN_T:
|
case LIB_PIN_T:
|
||||||
{
|
{
|
||||||
if( !aPart )
|
if( !aPart )
|
||||||
|
|
|
@ -97,6 +97,8 @@ public:
|
||||||
/// Returns the center point of the selection area bounding box.
|
/// Returns the center point of the selection area bounding box.
|
||||||
VECTOR2I GetCenter() const;
|
VECTOR2I GetCenter() const;
|
||||||
|
|
||||||
|
const BOX2I ViewBBox() const override;
|
||||||
|
|
||||||
EDA_ITEM* operator[]( const int index ) const
|
EDA_ITEM* operator[]( const int index ) const
|
||||||
{
|
{
|
||||||
if( index < 0 || (unsigned int) index >= m_items.size() )
|
if( index < 0 || (unsigned int) index >= m_items.size() )
|
||||||
|
|
|
@ -30,6 +30,7 @@
|
||||||
|
|
||||||
#include <tools/pcb_actions.h>
|
#include <tools/pcb_actions.h>
|
||||||
#include <tool/tool_manager.h>
|
#include <tool/tool_manager.h>
|
||||||
|
#include <tools/selection_tool.h>
|
||||||
#include <pcb_draw_panel_gal.h>
|
#include <pcb_draw_panel_gal.h>
|
||||||
|
|
||||||
/* Execute a remote command send by Eeschema via a socket,
|
/* Execute a remote command send by Eeschema via a socket,
|
||||||
|
@ -44,6 +45,7 @@ void PCB_EDIT_FRAME::ExecuteRemoteCommand( const char* cmdline )
|
||||||
char line[1024];
|
char line[1024];
|
||||||
wxString msg;
|
wxString msg;
|
||||||
wxString modName;
|
wxString modName;
|
||||||
|
wxString *sheetStamp;
|
||||||
char* idcmd;
|
char* idcmd;
|
||||||
char* text;
|
char* text;
|
||||||
MODULE* module = NULL;
|
MODULE* module = NULL;
|
||||||
|
@ -76,6 +78,16 @@ void PCB_EDIT_FRAME::ExecuteRemoteCommand( const char* cmdline )
|
||||||
if( module )
|
if( module )
|
||||||
pos = module->GetPosition();
|
pos = module->GetPosition();
|
||||||
}
|
}
|
||||||
|
else if( strcmp( idcmd, "$SHEET:" ) == 0 )
|
||||||
|
{
|
||||||
|
msg.Printf( _( "Selecting all from sheet '%s'" ), FROM_UTF8( text ) );
|
||||||
|
sheetStamp = new wxString( FROM_UTF8( text ) );
|
||||||
|
SetStatusText( msg );
|
||||||
|
GetToolManager()->RunAction( PCB_ACTIONS::selectOnSheet,
|
||||||
|
true,
|
||||||
|
static_cast<void*>( sheetStamp ) );
|
||||||
|
return;
|
||||||
|
}
|
||||||
else if( strcmp( idcmd, "$PIN:" ) == 0 )
|
else if( strcmp( idcmd, "$PIN:" ) == 0 )
|
||||||
{
|
{
|
||||||
wxString pinName;
|
wxString pinName;
|
||||||
|
|
|
@ -67,6 +67,9 @@ public:
|
||||||
/// Selects all connections belonging to a single net.
|
/// Selects all connections belonging to a single net.
|
||||||
static TOOL_ACTION selectNet;
|
static TOOL_ACTION selectNet;
|
||||||
|
|
||||||
|
/// Selects all components on sheet.
|
||||||
|
static TOOL_ACTION selectOnSheet;
|
||||||
|
|
||||||
/// Selects all components on the same sheet.
|
/// Selects all components on the same sheet.
|
||||||
static TOOL_ACTION selectSameSheet;
|
static TOOL_ACTION selectSameSheet;
|
||||||
|
|
||||||
|
|
|
@ -89,6 +89,10 @@ TOOL_ACTION PCB_ACTIONS::selectNet( "pcbnew.InteractiveSelection.SelectNet",
|
||||||
AS_GLOBAL, 0,
|
AS_GLOBAL, 0,
|
||||||
_( "Whole Net" ), _( "Selects all tracks & vias belonging to the same net." ) );
|
_( "Whole Net" ), _( "Selects all tracks & vias belonging to the same net." ) );
|
||||||
|
|
||||||
|
TOOL_ACTION PCB_ACTIONS::selectOnSheet( "pcbnew.InteractiveSelection.SelectOnSheet",
|
||||||
|
AS_GLOBAL, 0,
|
||||||
|
_( "Sheet" ), _( "Selects all modules and tracks in the schematic sheet" ) );
|
||||||
|
|
||||||
TOOL_ACTION PCB_ACTIONS::selectSameSheet( "pcbnew.InteractiveSelection.SelectSameSheet",
|
TOOL_ACTION PCB_ACTIONS::selectSameSheet( "pcbnew.InteractiveSelection.SelectSameSheet",
|
||||||
AS_GLOBAL, 'P',
|
AS_GLOBAL, 'P',
|
||||||
_( "Same Sheet" ), _( "Selects all modules and tracks in the same schematic sheet" ) );
|
_( "Same Sheet" ), _( "Selects all modules and tracks in the same schematic sheet" ) );
|
||||||
|
@ -541,6 +545,7 @@ void SELECTION_TOOL::SetTransitions()
|
||||||
Go( &SELECTION_TOOL::selectCopper, PCB_ACTIONS::selectCopper.MakeEvent() );
|
Go( &SELECTION_TOOL::selectCopper, PCB_ACTIONS::selectCopper.MakeEvent() );
|
||||||
Go( &SELECTION_TOOL::selectNet, PCB_ACTIONS::selectNet.MakeEvent() );
|
Go( &SELECTION_TOOL::selectNet, PCB_ACTIONS::selectNet.MakeEvent() );
|
||||||
Go( &SELECTION_TOOL::selectSameSheet, PCB_ACTIONS::selectSameSheet.MakeEvent() );
|
Go( &SELECTION_TOOL::selectSameSheet, PCB_ACTIONS::selectSameSheet.MakeEvent() );
|
||||||
|
Go( &SELECTION_TOOL::selectOnSheet, PCB_ACTIONS::selectOnSheet.MakeEvent() );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -681,7 +686,7 @@ int SELECTION_TOOL::selectConnection( const TOOL_EVENT& aEvent )
|
||||||
|
|
||||||
int SELECTION_TOOL::selectCopper( const TOOL_EVENT& aEvent )
|
int SELECTION_TOOL::selectCopper( const TOOL_EVENT& aEvent )
|
||||||
{
|
{
|
||||||
if( !selectCursor( ) )
|
if( !selectCursor() )
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
// copy the selection, since we're going to iterate and modify
|
// copy the selection, since we're going to iterate and modify
|
||||||
|
@ -691,7 +696,7 @@ int SELECTION_TOOL::selectCopper( const TOOL_EVENT& aEvent )
|
||||||
{
|
{
|
||||||
auto item = static_cast<BOARD_ITEM*>( i );
|
auto item = static_cast<BOARD_ITEM*>( i );
|
||||||
// only connected items can be traversed in the ratsnest
|
// only connected items can be traversed in the ratsnest
|
||||||
if ( item->IsConnected() )
|
if( item->IsConnected() )
|
||||||
{
|
{
|
||||||
auto& connItem = static_cast<BOARD_CONNECTED_ITEM&>( *item );
|
auto& connItem = static_cast<BOARD_CONNECTED_ITEM&>( *item );
|
||||||
|
|
||||||
|
@ -770,7 +775,7 @@ int SELECTION_TOOL::selectNet( const TOOL_EVENT& aEvent )
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
void SELECTION_TOOL::selectAllItemsOnSheet( wxString sheet )
|
void SELECTION_TOOL::selectAllItemsOnSheet( wxString aSheet )
|
||||||
{
|
{
|
||||||
auto modules = board()->m_Modules.GetFirst();
|
auto modules = board()->m_Modules.GetFirst();
|
||||||
std::list<MODULE*> modList;
|
std::list<MODULE*> modList;
|
||||||
|
@ -778,7 +783,7 @@ void SELECTION_TOOL::selectAllItemsOnSheet( wxString sheet )
|
||||||
// store all modules that are on that sheet
|
// store all modules that are on that sheet
|
||||||
for( MODULE* mitem = modules; mitem; mitem = mitem->Next() )
|
for( MODULE* mitem = modules; mitem; mitem = mitem->Next() )
|
||||||
{
|
{
|
||||||
if ( mitem != NULL && mitem->GetPath().Contains( sheet ) )
|
if( mitem != NULL && mitem->GetPath().Contains( aSheet ) )
|
||||||
{
|
{
|
||||||
modList.push_back( mitem );
|
modList.push_back( mitem );
|
||||||
}
|
}
|
||||||
|
@ -851,6 +856,43 @@ void SELECTION_TOOL::selectAllItemsOnSheet( wxString sheet )
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void SELECTION_TOOL::zoomFitSelection( void )
|
||||||
|
{
|
||||||
|
//Should recalculate the view to zoom in on the selection
|
||||||
|
auto selectionBox = m_selection.ViewBBox();
|
||||||
|
auto canvas = m_frame->GetGalCanvas();
|
||||||
|
auto view = getView();
|
||||||
|
|
||||||
|
VECTOR2D screenSize = view->ToWorld( canvas->GetClientSize(), false );
|
||||||
|
|
||||||
|
if( !( selectionBox.GetWidth() == 0 ) || !( selectionBox.GetHeight() == 0 ) )
|
||||||
|
{
|
||||||
|
VECTOR2D vsize = selectionBox.GetSize();
|
||||||
|
double scale = view->GetScale() / std::max( fabs( vsize.x / screenSize.x ),
|
||||||
|
fabs( vsize.y / screenSize.y ) );
|
||||||
|
view->SetScale( scale );
|
||||||
|
view->SetCenter( selectionBox.Centre() );
|
||||||
|
view->Add( &m_selection );
|
||||||
|
}
|
||||||
|
|
||||||
|
m_frame->GetGalCanvas()->ForceRefresh();
|
||||||
|
}
|
||||||
|
|
||||||
|
int SELECTION_TOOL::selectOnSheet( const TOOL_EVENT& aEvent )
|
||||||
|
{
|
||||||
|
clearSelection();
|
||||||
|
wxString* sheet = aEvent.Parameter<wxString*>();
|
||||||
|
selectAllItemsOnSheet( *sheet );
|
||||||
|
|
||||||
|
zoomFitSelection();
|
||||||
|
|
||||||
|
if( m_selection.Size() > 0 )
|
||||||
|
m_toolMgr->ProcessEvent( SelectedEvent );
|
||||||
|
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
int SELECTION_TOOL::selectSameSheet( const TOOL_EVENT& aEvent )
|
int SELECTION_TOOL::selectSameSheet( const TOOL_EVENT& aEvent )
|
||||||
{
|
{
|
||||||
if( !selectCursor( true ) )
|
if( !selectCursor( true ) )
|
||||||
|
@ -872,7 +914,7 @@ int SELECTION_TOOL::selectSameSheet( const TOOL_EVENT& aEvent )
|
||||||
sheetPath = sheetPath.BeforeLast( '/' );
|
sheetPath = sheetPath.BeforeLast( '/' );
|
||||||
sheetPath = sheetPath.AfterLast( '/' );
|
sheetPath = sheetPath.AfterLast( '/' );
|
||||||
|
|
||||||
selectAllItemsOnSheet(sheetPath);
|
selectAllItemsOnSheet( sheetPath );
|
||||||
|
|
||||||
// Inform other potentially interested tools
|
// Inform other potentially interested tools
|
||||||
if( m_selection.Size() > 0 )
|
if( m_selection.Size() > 0 )
|
||||||
|
@ -1782,6 +1824,28 @@ VECTOR2I SELECTION::GetCenter() const
|
||||||
return centre;
|
return centre;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const BOX2I SELECTION::ViewBBox() const
|
||||||
|
{
|
||||||
|
EDA_RECT eda_bbox;
|
||||||
|
|
||||||
|
if( Size() == 1 )
|
||||||
|
{
|
||||||
|
eda_bbox = Front()->GetBoundingBox();
|
||||||
|
}
|
||||||
|
else if( Size() > 1 )
|
||||||
|
{
|
||||||
|
eda_bbox = Front()->GetBoundingBox();
|
||||||
|
auto i = m_items.begin();
|
||||||
|
++i;
|
||||||
|
|
||||||
|
for( ; i != m_items.end(); ++i )
|
||||||
|
{
|
||||||
|
eda_bbox.Merge( (*i)->GetBoundingBox() );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return BOX2I( eda_bbox.GetOrigin(), eda_bbox.GetSize() );
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
const KIGFX::VIEW_GROUP::ITEMS SELECTION::updateDrawList() const
|
const KIGFX::VIEW_GROUP::ITEMS SELECTION::updateDrawList() const
|
||||||
{
|
{
|
||||||
|
|
|
@ -120,6 +120,9 @@ public:
|
||||||
///> Sets up handlers for various events.
|
///> Sets up handlers for various events.
|
||||||
void SetTransitions() override;
|
void SetTransitions() override;
|
||||||
|
|
||||||
|
///> Zooms the screen to center and fit the current selection.
|
||||||
|
void zoomFitSelection( void );
|
||||||
|
|
||||||
private:
|
private:
|
||||||
/**
|
/**
|
||||||
* Function selectPoint()
|
* Function selectPoint()
|
||||||
|
@ -180,7 +183,10 @@ private:
|
||||||
/**
|
/**
|
||||||
* Selects all items with the given sheet timestamp name
|
* Selects all items with the given sheet timestamp name
|
||||||
*/
|
*/
|
||||||
void selectAllItemsOnSheet( wxString sheet );
|
void selectAllItemsOnSheet( wxString aSheet );
|
||||||
|
|
||||||
|
///> Selects all modules belonging to same sheet.
|
||||||
|
int selectOnSheet( const TOOL_EVENT& aEvent );
|
||||||
|
|
||||||
///> Selects all modules belonging to same sheet.
|
///> Selects all modules belonging to same sheet.
|
||||||
int selectSameSheet( const TOOL_EVENT& aEvent );
|
int selectSameSheet( const TOOL_EVENT& aEvent );
|
||||||
|
|
Loading…
Reference in New Issue