2019-01-23 10:30:10 +00:00
|
|
|
/*
|
|
|
|
* 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-3.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
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
2011-09-30 18:15:37 +00:00
|
|
|
/**
|
|
|
|
* @file pcbnew/cross-probing.cpp
|
|
|
|
* @brief Cross probing functions to handle communication to andfrom Eeschema.
|
|
|
|
*/
|
2008-12-08 15:27:13 +00:00
|
|
|
|
2011-09-30 18:15:37 +00:00
|
|
|
/**
|
|
|
|
* Handle messages between Pcbnew and Eeschema via a socket, the port numbers are
|
|
|
|
* KICAD_PCB_PORT_SERVICE_NUMBER (currently 4242) (Eeschema to Pcbnew)
|
|
|
|
* KICAD_SCH_PORT_SERVICE_NUMBER (currently 4243) (Pcbnew to Eeschema)
|
2008-11-06 17:55:32 +00:00
|
|
|
* Note: these ports must be enabled for firewall protection
|
|
|
|
*/
|
2007-10-07 09:49:08 +00:00
|
|
|
|
2012-01-23 04:33:36 +00:00
|
|
|
#include <fctsys.h>
|
* KIWAY Milestone A): Make major modules into DLL/DSOs.
! The initial testing of this commit should be done using a Debug build so that
all the wxASSERT()s are enabled. Also, be sure and keep enabled the
USE_KIWAY_DLLs option. The tree won't likely build without it. Turning it
off is senseless anyways. If you want stable code, go back to a prior version,
the one tagged with "stable".
* Relocate all functionality out of the wxApp derivative into more finely
targeted purposes:
a) DLL/DSO specific
b) PROJECT specific
c) EXE or process specific
d) configuration file specific data
e) configuration file manipulations functions.
All of this functionality was blended into an extremely large wxApp derivative
and that was incompatible with the desire to support multiple concurrently
loaded DLL/DSO's ("KIFACE")s and multiple concurrently open projects.
An amazing amount of organization come from simply sorting each bit of
functionality into the proper box.
* Switch to wxConfigBase from wxConfig everywhere except instantiation.
* Add classes KIWAY, KIFACE, KIFACE_I, SEARCH_STACK, PGM_BASE, PGM_KICAD,
PGM_SINGLE_TOP,
* Remove "Return" prefix on many function names.
* Remove obvious comments from CMakeLists.txt files, and from else() and endif()s.
* Fix building boost for use in a DSO on linux.
* Remove some of the assumptions in the CMakeLists.txt files that windows had
to be the host platform when building windows binaries.
* Reduce the number of wxStrings being constructed at program load time via
static construction.
* Pass wxConfigBase* to all SaveSettings() and LoadSettings() functions so that
these functions are useful even when the wxConfigBase comes from another
source, as is the case in the KICAD_MANAGER_FRAME.
* Move the setting of the KIPRJMOD environment variable into class PROJECT,
so that it can be moved into a project variable soon, and out of FP_LIB_TABLE.
* Add the KIWAY_PLAYER which is associated with a particular PROJECT, and all
its child wxFrames and wxDialogs now have a Kiway() member function which
returns a KIWAY& that that window tree branch is in support of. This is like
wxWindows DNA in that child windows get this member with proper value at time
of construction.
* Anticipate some of the needs for milestones B) and C) and make code
adjustments now in an effort to reduce work in those milestones.
* No testing has been done for python scripting, since milestone C) has that
being largely reworked and re-thought-out.
2014-03-20 00:42:08 +00:00
|
|
|
#include <pgm_base.h>
|
2014-04-20 04:35:34 +00:00
|
|
|
#include <kiface_i.h>
|
2014-04-21 14:49:33 +00:00
|
|
|
#include <kiway_express.h>
|
2018-01-29 20:58:58 +00:00
|
|
|
#include <pcb_edit_frame.h>
|
2012-01-23 04:33:36 +00:00
|
|
|
#include <eda_dde.h>
|
|
|
|
#include <macros.h>
|
2011-09-23 13:57:12 +00:00
|
|
|
|
2012-01-23 04:33:36 +00:00
|
|
|
#include <pcbnew_id.h>
|
|
|
|
#include <class_board.h>
|
|
|
|
#include <class_module.h>
|
2018-01-07 02:30:31 +00:00
|
|
|
#include <class_track.h>
|
|
|
|
#include <class_zone.h>
|
2011-09-23 13:57:12 +00:00
|
|
|
|
2012-01-23 04:33:36 +00:00
|
|
|
#include <collectors.h>
|
|
|
|
#include <pcbnew.h>
|
2018-02-16 18:26:11 +00:00
|
|
|
#include <board_netlist_updater.h>
|
2016-01-29 10:24:39 +00:00
|
|
|
#include <netlist_reader.h>
|
|
|
|
#include <pcb_netlist.h>
|
|
|
|
#include <dialogs/dialog_update_pcb.h>
|
2007-10-07 09:49:08 +00:00
|
|
|
|
2017-02-21 12:42:08 +00:00
|
|
|
#include <tools/pcb_actions.h>
|
2015-05-05 18:39:41 +00:00
|
|
|
#include <tool/tool_manager.h>
|
2017-03-02 23:42:23 +00:00
|
|
|
#include <tools/selection_tool.h>
|
2015-02-14 20:52:22 +00:00
|
|
|
#include <pcb_draw_panel_gal.h>
|
2018-01-06 20:50:49 +00:00
|
|
|
#include <pcb_painter.h>
|
2007-10-07 09:49:08 +00:00
|
|
|
|
2014-01-08 14:18:51 +00:00
|
|
|
/* Execute a remote command send by Eeschema via a socket,
|
|
|
|
* port KICAD_PCB_PORT_SERVICE_NUMBER
|
|
|
|
* cmdline = received command from Eeschema
|
2007-10-07 09:49:08 +00:00
|
|
|
* Commands are
|
|
|
|
* $PART: "reference" put cursor on component
|
2007-10-07 18:24:15 +00:00
|
|
|
* $PIN: "pin name" $PART: "reference" put cursor on the footprint pin
|
2018-01-06 20:50:49 +00:00
|
|
|
* $NET: "net name" highlight the given net (if highlight tool is active)
|
2019-01-23 10:30:10 +00:00
|
|
|
* They are a keyword followed by a quoted string.
|
2007-10-07 09:49:08 +00:00
|
|
|
*/
|
2014-01-08 14:18:51 +00:00
|
|
|
void PCB_EDIT_FRAME::ExecuteRemoteCommand( const char* cmdline )
|
2007-10-07 09:49:08 +00:00
|
|
|
{
|
2016-01-25 15:16:05 +00:00
|
|
|
char line[1024];
|
|
|
|
wxString msg;
|
|
|
|
wxString modName;
|
|
|
|
char* idcmd;
|
|
|
|
char* text;
|
|
|
|
MODULE* module = NULL;
|
|
|
|
D_PAD* pad = NULL;
|
|
|
|
BOARD* pcb = GetBoard();
|
|
|
|
wxPoint pos;
|
2007-10-07 09:49:08 +00:00
|
|
|
|
|
|
|
strncpy( line, cmdline, sizeof(line) - 1 );
|
2015-01-19 19:03:50 +00:00
|
|
|
line[sizeof(line) - 1] = 0;
|
2007-10-07 09:49:08 +00:00
|
|
|
|
|
|
|
idcmd = strtok( line, " \n\r" );
|
2019-01-23 10:30:10 +00:00
|
|
|
text = strtok( NULL, "\"\n\r" );
|
2008-02-19 07:06:58 +00:00
|
|
|
|
2018-01-06 20:50:49 +00:00
|
|
|
if( idcmd == NULL )
|
|
|
|
return;
|
|
|
|
|
|
|
|
if( strcmp( idcmd, "$NET:" ) == 0 )
|
|
|
|
{
|
|
|
|
if( GetToolId() == ID_PCB_HIGHLIGHT_BUTT )
|
|
|
|
{
|
|
|
|
wxString net_name = FROM_UTF8( text );
|
|
|
|
NETINFO_ITEM* netinfo = pcb->FindNet( net_name );
|
|
|
|
int netcode = 0;
|
|
|
|
|
|
|
|
if( netinfo )
|
|
|
|
netcode = netinfo->GetNet();
|
|
|
|
|
|
|
|
if( IsGalCanvasActive() )
|
|
|
|
{
|
2018-01-07 02:30:31 +00:00
|
|
|
auto view = m_toolManager->GetView();
|
|
|
|
auto rs = view->GetPainter()->GetSettings();
|
2018-01-06 20:50:49 +00:00
|
|
|
rs->SetHighlight( true, netcode );
|
2018-01-07 02:30:31 +00:00
|
|
|
view->UpdateAllLayersColor();
|
|
|
|
|
|
|
|
BOX2I bbox;
|
|
|
|
bool first = true;
|
|
|
|
|
|
|
|
auto merge_area = [netcode, &bbox, &first]( BOARD_CONNECTED_ITEM* aItem )
|
|
|
|
{
|
|
|
|
if( aItem->GetNetCode() == netcode )
|
|
|
|
{
|
|
|
|
if( first )
|
|
|
|
{
|
|
|
|
bbox = aItem->GetBoundingBox();
|
|
|
|
first = false;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
bbox.Merge( aItem->GetBoundingBox() );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
for( auto zone : pcb->Zones() )
|
|
|
|
merge_area( zone );
|
|
|
|
|
|
|
|
for( auto track : pcb->Tracks() )
|
|
|
|
merge_area( track );
|
|
|
|
|
|
|
|
for( auto mod : pcb->Modules() )
|
|
|
|
for ( auto mod_pad : mod->Pads() )
|
|
|
|
merge_area( mod_pad );
|
|
|
|
|
|
|
|
if( netcode > 0 && bbox.GetWidth() > 0 && bbox.GetHeight() > 0 )
|
|
|
|
{
|
|
|
|
auto bbSize = bbox.Inflate( bbox.GetWidth() * 0.2f ).GetSize();
|
|
|
|
auto screenSize = view->ToWorld( GetGalCanvas()->GetClientSize(), false );
|
|
|
|
double ratio = std::max( fabs( bbSize.x / screenSize.x ),
|
|
|
|
fabs( bbSize.y / screenSize.y ) );
|
|
|
|
double scale = view->GetScale() / ratio;
|
|
|
|
|
|
|
|
view->SetScale( scale );
|
|
|
|
view->SetCenter( bbox.Centre() );
|
|
|
|
}
|
|
|
|
|
2018-01-06 20:50:49 +00:00
|
|
|
GetGalCanvas()->Refresh();
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if( netcode > 0 )
|
|
|
|
{
|
|
|
|
pcb->HighLightON();
|
|
|
|
pcb->SetHighLightNet( netcode );
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
pcb->HighLightOFF();
|
|
|
|
pcb->SetHighLightNet( -1 );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if( text == NULL )
|
2007-10-07 09:49:08 +00:00
|
|
|
return;
|
|
|
|
|
|
|
|
if( strcmp( idcmd, "$PART:" ) == 0 )
|
|
|
|
{
|
2011-02-28 18:36:19 +00:00
|
|
|
modName = FROM_UTF8( text );
|
2007-10-07 09:49:08 +00:00
|
|
|
|
2014-01-08 14:18:51 +00:00
|
|
|
module = pcb->FindModuleByReference( modName );
|
2007-10-07 09:49:08 +00:00
|
|
|
|
2008-02-19 07:06:58 +00:00
|
|
|
if( module )
|
2019-01-23 10:30:10 +00:00
|
|
|
msg.Printf( _( "%s found" ), modName );
|
2008-02-19 07:06:58 +00:00
|
|
|
else
|
2019-01-23 10:30:10 +00:00
|
|
|
msg.Printf( _( "%s not found" ), modName );
|
2007-10-07 09:49:08 +00:00
|
|
|
|
2014-01-08 14:18:51 +00:00
|
|
|
SetStatusText( msg );
|
2011-02-11 20:48:13 +00:00
|
|
|
|
2007-10-07 09:49:08 +00:00
|
|
|
if( module )
|
2011-02-11 20:48:13 +00:00
|
|
|
pos = module->GetPosition();
|
2007-10-07 09:49:08 +00:00
|
|
|
}
|
2017-03-02 23:42:23 +00:00
|
|
|
else if( strcmp( idcmd, "$SHEET:" ) == 0 )
|
|
|
|
{
|
2017-12-15 11:37:46 +00:00
|
|
|
msg.Printf( _( "Selecting all from sheet \"%s\"" ), FROM_UTF8( text ) );
|
2017-03-04 15:28:26 +00:00
|
|
|
wxString sheetStamp( FROM_UTF8( text ) );
|
2017-03-02 23:42:23 +00:00
|
|
|
SetStatusText( msg );
|
2017-03-04 16:30:44 +00:00
|
|
|
GetToolManager()->RunAction( PCB_ACTIONS::selectOnSheetFromEeschema, true,
|
2017-03-04 15:28:26 +00:00
|
|
|
static_cast<void*>( &sheetStamp ) );
|
2017-03-02 23:42:23 +00:00
|
|
|
return;
|
|
|
|
}
|
2008-02-19 07:06:58 +00:00
|
|
|
else if( strcmp( idcmd, "$PIN:" ) == 0 )
|
2007-10-07 09:49:08 +00:00
|
|
|
{
|
2008-02-19 07:06:58 +00:00
|
|
|
wxString pinName;
|
2007-10-07 09:49:08 +00:00
|
|
|
int netcode = -1;
|
|
|
|
|
2011-02-28 18:36:19 +00:00
|
|
|
pinName = FROM_UTF8( text );
|
2007-10-07 09:49:08 +00:00
|
|
|
|
|
|
|
text = strtok( NULL, " \n\r" );
|
2019-01-23 10:30:10 +00:00
|
|
|
|
2007-10-07 09:49:08 +00:00
|
|
|
if( text && strcmp( text, "$PART:" ) == 0 )
|
2019-01-23 10:30:10 +00:00
|
|
|
text = strtok( NULL, "\"\n\r" );
|
2007-10-07 09:49:08 +00:00
|
|
|
|
2011-02-28 18:36:19 +00:00
|
|
|
modName = FROM_UTF8( text );
|
2008-02-19 07:06:58 +00:00
|
|
|
|
2011-04-05 17:49:14 +00:00
|
|
|
module = pcb->FindModuleByReference( modName );
|
2011-02-11 20:48:13 +00:00
|
|
|
|
2007-10-07 09:49:08 +00:00
|
|
|
if( module )
|
2008-03-04 04:22:27 +00:00
|
|
|
pad = module->FindPadByName( pinName );
|
2007-10-07 09:49:08 +00:00
|
|
|
|
|
|
|
if( pad )
|
2008-11-06 17:55:32 +00:00
|
|
|
{
|
2014-02-25 10:40:34 +00:00
|
|
|
netcode = pad->GetNetCode();
|
2008-12-08 15:27:13 +00:00
|
|
|
|
2008-11-06 17:55:32 +00:00
|
|
|
// put cursor on the pad:
|
2011-02-11 20:48:13 +00:00
|
|
|
pos = pad->GetPosition();
|
2008-11-06 17:55:32 +00:00
|
|
|
}
|
2007-10-07 09:49:08 +00:00
|
|
|
|
2013-08-03 05:15:23 +00:00
|
|
|
if( netcode > 0 ) // highlight the pad net
|
2007-10-07 09:49:08 +00:00
|
|
|
{
|
2011-09-14 20:04:58 +00:00
|
|
|
pcb->HighLightON();
|
|
|
|
pcb->SetHighLightNet( netcode );
|
2008-11-06 17:55:32 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2011-09-14 20:04:58 +00:00
|
|
|
pcb->HighLightOFF();
|
|
|
|
pcb->SetHighLightNet( -1 );
|
2007-10-07 09:49:08 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if( module == NULL )
|
2011-09-14 20:04:58 +00:00
|
|
|
{
|
2019-01-23 10:30:10 +00:00
|
|
|
msg.Printf( _( "%s not found" ), modName );
|
2011-09-14 20:04:58 +00:00
|
|
|
}
|
2007-10-07 09:49:08 +00:00
|
|
|
else if( pad == NULL )
|
2008-02-23 01:27:50 +00:00
|
|
|
{
|
2019-01-23 10:30:10 +00:00
|
|
|
msg.Printf( _( "%s pin %s not found" ), modName, pinName );
|
2014-01-08 14:18:51 +00:00
|
|
|
SetCurItem( module );
|
2008-02-23 01:27:50 +00:00
|
|
|
}
|
2007-10-07 09:49:08 +00:00
|
|
|
else
|
2008-02-23 01:27:50 +00:00
|
|
|
{
|
2019-01-23 10:30:10 +00:00
|
|
|
msg.Printf( _( "%s pin %s found" ), modName, pinName );
|
2014-01-08 14:18:51 +00:00
|
|
|
SetCurItem( pad );
|
2008-02-23 01:27:50 +00:00
|
|
|
}
|
2007-10-07 09:49:08 +00:00
|
|
|
|
2014-01-08 14:18:51 +00:00
|
|
|
SetStatusText( msg );
|
2007-10-07 09:49:08 +00:00
|
|
|
}
|
|
|
|
|
2008-11-06 17:55:32 +00:00
|
|
|
if( module ) // if found, center the module on screen, and redraw the screen.
|
2011-02-25 19:09:42 +00:00
|
|
|
{
|
2015-02-14 20:52:22 +00:00
|
|
|
if( IsGalCanvasActive() )
|
|
|
|
{
|
2017-02-21 12:42:08 +00:00
|
|
|
GetToolManager()->RunAction( PCB_ACTIONS::crossProbeSchToPcb,
|
2016-01-25 15:16:05 +00:00
|
|
|
true,
|
|
|
|
pad ?
|
|
|
|
static_cast<BOARD_ITEM*>( pad ) :
|
|
|
|
static_cast<BOARD_ITEM*>( module )
|
|
|
|
);
|
2015-02-14 20:52:22 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
SetCrossHairPosition( pos );
|
|
|
|
RedrawScreen( pos, false );
|
|
|
|
}
|
2011-02-25 19:09:42 +00:00
|
|
|
}
|
2007-10-07 09:49:08 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2014-04-21 06:28:17 +00:00
|
|
|
std::string FormatProbeItem( BOARD_ITEM* aItem )
|
2007-10-07 09:49:08 +00:00
|
|
|
{
|
2014-04-21 06:28:17 +00:00
|
|
|
MODULE* module;
|
2007-10-07 09:49:08 +00:00
|
|
|
|
2018-12-24 11:17:35 +00:00
|
|
|
if( !aItem )
|
2018-12-31 12:54:26 +00:00
|
|
|
return "$CLEAR: \"HIGHLIGHTED\""; // message to clear highlight state
|
2018-12-24 11:17:35 +00:00
|
|
|
|
2014-04-21 06:28:17 +00:00
|
|
|
switch( aItem->Type() )
|
2007-10-07 09:49:08 +00:00
|
|
|
{
|
2011-10-01 19:24:27 +00:00
|
|
|
case PCB_MODULE_T:
|
2014-04-21 06:28:17 +00:00
|
|
|
module = (MODULE*) aItem;
|
|
|
|
return StrPrintf( "$PART: \"%s\"", TO_UTF8( module->GetReference() ) );
|
2007-10-07 09:49:08 +00:00
|
|
|
|
2011-10-01 19:24:27 +00:00
|
|
|
case PCB_PAD_T:
|
2014-04-21 06:28:17 +00:00
|
|
|
{
|
|
|
|
module = (MODULE*) aItem->GetParent();
|
2017-08-11 09:22:13 +00:00
|
|
|
wxString pad = ((D_PAD*)aItem)->GetName();
|
2014-04-21 06:28:17 +00:00
|
|
|
|
|
|
|
return StrPrintf( "$PART: \"%s\" $PAD: \"%s\"",
|
|
|
|
TO_UTF8( module->GetReference() ),
|
|
|
|
TO_UTF8( pad ) );
|
|
|
|
}
|
2007-10-07 09:49:08 +00:00
|
|
|
|
2011-10-01 19:24:27 +00:00
|
|
|
case PCB_MODULE_TEXT_T:
|
2014-04-21 06:28:17 +00:00
|
|
|
{
|
2014-09-10 15:18:42 +00:00
|
|
|
module = static_cast<MODULE*>( aItem->GetParent() );
|
2011-09-23 13:57:12 +00:00
|
|
|
|
2014-09-10 15:18:42 +00:00
|
|
|
TEXTE_MODULE* text_mod = static_cast<TEXTE_MODULE*>( aItem );
|
2007-10-07 09:49:08 +00:00
|
|
|
|
2014-04-21 06:28:17 +00:00
|
|
|
const char* text_key;
|
|
|
|
|
2014-09-10 15:18:42 +00:00
|
|
|
/* This can't be a switch since the break need to pull out
|
|
|
|
* from the outer switch! */
|
2014-04-21 06:28:17 +00:00
|
|
|
if( text_mod->GetType() == TEXTE_MODULE::TEXT_is_REFERENCE )
|
|
|
|
text_key = "$REF:";
|
|
|
|
else if( text_mod->GetType() == TEXTE_MODULE::TEXT_is_VALUE )
|
|
|
|
text_key = "$VAL:";
|
|
|
|
else
|
|
|
|
break;
|
|
|
|
|
|
|
|
return StrPrintf( "$PART: \"%s\" %s \"%s\"",
|
|
|
|
TO_UTF8( module->GetReference() ),
|
|
|
|
text_key,
|
|
|
|
TO_UTF8( text_mod->GetText() ) );
|
|
|
|
}
|
2007-10-07 09:49:08 +00:00
|
|
|
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2014-04-21 06:28:17 +00:00
|
|
|
return "";
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2014-11-02 16:25:04 +00:00
|
|
|
/* Send a remote command to Eeschema via a socket,
|
|
|
|
* aSyncItem = item to be located on schematic (module, pin or text)
|
2014-04-21 06:28:17 +00:00
|
|
|
* Commands are
|
|
|
|
* $PART: "reference" put cursor on component anchor
|
|
|
|
* $PART: "reference" $PAD: "pad number" put cursor on the component pin
|
|
|
|
* $PART: "reference" $REF: "reference" put cursor on the component ref
|
|
|
|
* $PART: "reference" $VAL: "value" put cursor on the component value
|
|
|
|
*/
|
|
|
|
void PCB_EDIT_FRAME::SendMessageToEESCHEMA( BOARD_ITEM* aSyncItem )
|
|
|
|
{
|
|
|
|
std::string packet = FormatProbeItem( aSyncItem );
|
|
|
|
|
2018-01-06 20:50:49 +00:00
|
|
|
if( packet.size() )
|
|
|
|
{
|
|
|
|
if( Kiface().IsSingle() )
|
|
|
|
SendCommand( MSG_TO_SCH, packet.c_str() );
|
|
|
|
else
|
|
|
|
{
|
|
|
|
// Typically ExpressMail is going to be s-expression packets, but since
|
|
|
|
// we have existing interpreter of the cross probe packet on the other
|
|
|
|
// side in place, we use that here.
|
|
|
|
Kiway().ExpressMail( FRAME_SCH, MAIL_CROSS_PROBE, packet, this );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void PCB_EDIT_FRAME::SendCrossProbeNetName( const wxString& aNetName )
|
|
|
|
{
|
|
|
|
std::string packet = StrPrintf( "$NET: \"%s\"", TO_UTF8( aNetName ) );
|
|
|
|
|
2014-04-21 06:28:17 +00:00
|
|
|
if( packet.size() )
|
2007-10-07 09:49:08 +00:00
|
|
|
{
|
2014-04-20 04:35:34 +00:00
|
|
|
if( Kiface().IsSingle() )
|
2014-04-21 06:28:17 +00:00
|
|
|
SendCommand( MSG_TO_SCH, packet.c_str() );
|
2014-04-20 04:35:34 +00:00
|
|
|
else
|
|
|
|
{
|
2014-04-21 14:49:33 +00:00
|
|
|
// Typically ExpressMail is going to be s-expression packets, but since
|
|
|
|
// we have existing interpreter of the cross probe packet on the other
|
|
|
|
// side in place, we use that here.
|
|
|
|
Kiway().ExpressMail( FRAME_SCH, MAIL_CROSS_PROBE, packet, this );
|
2014-04-20 04:35:34 +00:00
|
|
|
}
|
2007-10-07 09:49:08 +00:00
|
|
|
}
|
|
|
|
}
|
2014-04-21 06:28:17 +00:00
|
|
|
|
2014-04-21 06:51:33 +00:00
|
|
|
|
|
|
|
void PCB_EDIT_FRAME::KiwayMailIn( KIWAY_EXPRESS& mail )
|
|
|
|
{
|
2014-04-21 14:49:33 +00:00
|
|
|
const std::string& payload = mail.GetPayload();
|
|
|
|
|
|
|
|
switch( mail.Command() )
|
|
|
|
{
|
|
|
|
case MAIL_CROSS_PROBE:
|
|
|
|
ExecuteRemoteCommand( payload.c_str() );
|
|
|
|
break;
|
2014-04-21 06:51:33 +00:00
|
|
|
|
2016-01-29 10:24:39 +00:00
|
|
|
case MAIL_SCH_PCB_UPDATE:
|
|
|
|
{
|
|
|
|
NETLIST netlist;
|
2018-02-16 18:26:11 +00:00
|
|
|
size_t split = payload.find( '\n' );
|
|
|
|
wxCHECK( split != std::string::npos, /*void*/ );
|
|
|
|
|
|
|
|
// Extract options and netlist
|
|
|
|
std::string options = payload.substr( 0, split );
|
|
|
|
std::string netlistData = payload.substr( split + 1 );
|
|
|
|
|
|
|
|
// Quiet update options
|
|
|
|
bool by_reference = options.find( "by-reference" ) != std::string::npos;
|
|
|
|
bool by_timestamp = options.find( "by-timestamp" ) != std::string::npos;
|
|
|
|
wxASSERT( !( by_reference && by_timestamp ) ); // only one at a time please
|
2016-01-29 10:24:39 +00:00
|
|
|
|
2016-10-25 13:34:59 +00:00
|
|
|
try
|
|
|
|
{
|
2018-03-08 05:39:08 +00:00
|
|
|
STRING_LINE_READER* lineReader = new STRING_LINE_READER( netlistData, _( "Eeschema netlist" ) );
|
2016-01-29 10:24:39 +00:00
|
|
|
KICAD_NETLIST_READER netlistReader( lineReader, &netlist );
|
|
|
|
netlistReader.LoadNetlist();
|
|
|
|
}
|
2016-10-10 15:04:48 +00:00
|
|
|
catch( const IO_ERROR& )
|
2016-01-29 10:24:39 +00:00
|
|
|
{
|
|
|
|
assert( false ); // should never happen
|
|
|
|
}
|
|
|
|
|
2018-02-16 18:26:11 +00:00
|
|
|
if( by_reference || by_timestamp )
|
|
|
|
{
|
|
|
|
netlist.SetDeleteExtraFootprints( false );
|
|
|
|
netlist.SetFindByTimeStamp( by_timestamp );
|
|
|
|
netlist.SetReplaceFootprints( true );
|
|
|
|
|
|
|
|
BOARD_NETLIST_UPDATER updater( this, GetBoard() );
|
|
|
|
updater.SetLookupByTimestamp( by_timestamp );
|
|
|
|
updater.SetDeleteUnusedComponents( false );
|
|
|
|
updater.SetReplaceFootprints( true );
|
|
|
|
updater.SetDeleteSinglePadNets( false );
|
|
|
|
updater.UpdateNetlist( netlist );
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
DIALOG_UPDATE_PCB updateDialog( this, &netlist );
|
|
|
|
updateDialog.ShowModal();
|
2018-09-22 14:16:01 +00:00
|
|
|
|
|
|
|
auto selectionTool = static_cast<SELECTION_TOOL*>(
|
|
|
|
m_toolManager->FindTool( "pcbnew.InteractiveSelection" ) );
|
|
|
|
|
|
|
|
if( !selectionTool->GetSelection().Empty() )
|
|
|
|
GetToolManager()->InvokeTool( "pcbnew.InteractiveEdit" );
|
2018-02-16 18:26:11 +00:00
|
|
|
}
|
2016-01-29 10:24:39 +00:00
|
|
|
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2018-02-26 10:34:36 +00:00
|
|
|
case MAIL_IMPORT_FILE:
|
|
|
|
{
|
|
|
|
// Extract file format type and path (plugin type and path separated with \n)
|
|
|
|
size_t split = payload.find( '\n' );
|
|
|
|
wxCHECK( split != std::string::npos, /*void*/ );
|
|
|
|
int importFormat;
|
|
|
|
|
|
|
|
try
|
|
|
|
{
|
|
|
|
importFormat = std::stoi( payload.substr( 0, split ) );
|
|
|
|
}
|
2018-04-18 07:10:29 +00:00
|
|
|
catch( std::invalid_argument& )
|
2018-02-26 10:34:36 +00:00
|
|
|
{
|
|
|
|
wxFAIL;
|
|
|
|
importFormat = -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
std::string path = payload.substr( split + 1 );
|
|
|
|
wxASSERT( !path.empty() );
|
|
|
|
|
|
|
|
if( importFormat >= 0 )
|
|
|
|
importFile( path, importFormat );
|
|
|
|
}
|
|
|
|
|
2014-04-21 14:49:33 +00:00
|
|
|
// many many others.
|
2014-07-07 04:12:04 +00:00
|
|
|
default:
|
|
|
|
;
|
2014-04-21 14:49:33 +00:00
|
|
|
}
|
2014-04-21 06:51:33 +00:00
|
|
|
}
|
|
|
|
|