← Back to team overview

kicad-developers team mailing list archive

Re: [PATCH] non-interactive plot mode for eeschema

 

Dick Hollenbeck wrote:
> We have too much time invested in the current style, thank you very
> much. But if you really want to continue, I can tell you why blue is
> not only my favorite color, but the best color.

Heh, EMACS or vi ? :-)

> Document model on the bottom, gui or scripting on top. Sounds like my
> last posting without the OpenCASCADE attribute.

Yes. By the way, even if it's off-topic, I would be interested in
knowing what it is that you dislike about OpenCASCADE. In the
context of the project I mentioned, we're also looking for a Free
CAD system, and some of the ones based on OpenCASCADE look very
promising. It would be good to know if there are any issues with
the technology before we commit ourselves to one of the choices.

> i.e. is is possible for you to link your own executable, with modules
> that you need tied to your own main function?

That would be possible, yes. But how about just putting it all in
a separate function with a warning that this isn't something one
should consider a good example ?

I've attached a patch that does this. The change to WinEDA_App::OnInit
is quite small. I also noticed that dialogs now cause the window to
be created. Not sure what happened, but it's a welcome surprise :)

Thanks,
- Werner

---------------------------------- cut here -----------------------------------

This patch adds a command-line option --plot to eeschema that makes it
run File -> Plot -> Plot PostScript -> Plot ALL on the specified file.
It also prevents eeschema from opening a window and from checking for
concurrent instances.

This lets shell scripts generate plots, i.e., of schematics that have
been processed by these scripts.

Known issue: if there is an error or a warning, eeschema will bring up
a dialog instead of just exiting.

This patch is for KiCad SVN revision 1771.

---

Index: kicad/eeschema/eeschema.cpp
===================================================================
--- kicad.orig/eeschema/eeschema.cpp	2009-05-16 19:19:14.000000000 -0300
+++ kicad/eeschema/eeschema.cpp	2009-05-18 01:56:27.000000000 -0300
@@ -12,6 +12,7 @@
#include "general.h"
#include "bitmaps.h"
#include "eda_dde.h"
+#include "plotps.h"

#include "libcmp.h"
#include "protos.h"
@@ -122,6 +123,66 @@
int DefaultTransformMatrix[2][2] = { { 1, 0 }, { 0, -1 } };

+/*
+ * "PlotOnly" is a quick and dirty implementation of a non-interactive plot
+ * mode.
+ *
+ * This is neither a nice nor a complete implementation of this concept. E.g.,
+ * if there are any errors, KiCad may bring up a dialog instead of just
+ * exiting.
+ *
+ * However, this is the best we can do without making considerably intrusive
+ * changes to the internals of KiCad.
+ */
+
+
+static void PlotOnly( WinEDA_App* app )
+{
+ WinEDA_SchematicFrame* frame;
+ wxFileName fn;
+
+ if( app->argc < 3 ) {
+	fprintf( stderr, "usage: %ls [[--plot] filename]\n", *app->argv );
+	exit( 1 );
+ }
+
+ fn = app->argv[2];
+ if( !fn.IsOk() ) {
+	fprintf( stderr, "%ls: bad name\n", app->argv[2] );
+	exit(1);
+ }
+
+ /* init EESCHEMA */
+ SeedLayers();
+ app->GetSettings();
+
+ // Create main frame (schematic frame) :
+ frame = new WinEDA_SchematicFrame( NULL, wxT( "EESchema" ),
+ wxPoint( 0, 0 ), wxSize( 600, 400 ) );
+
+ app->SetTopWindow( frame );
+ frame->Show( FALSE );
+
+ ActiveScreen = frame->GetScreen();
+
+ /* Load file specified in the command line. */
+ if( fn.GetExt() != SchematicFileExtension )
+	fn.SetExt( SchematicFileExtension );
+ wxSetWorkingDirectory( fn.GetPath() );
+ if( !frame->LoadOneEEProject( fn.GetFullPath(), false ) ) {
+	fprintf( stderr, "%ls: can't load\n", app->argv[2] );
+	exit( 1 );
+ }
+
+ WinEDA_PlotPSFrame* Ps_frame = new WinEDA_PlotPSFrame( frame );
+ wxCommandEvent dummy;
+
+ Ps_frame->OnPlotPsAllExecuteClick( dummy );
+
+ exit( 0 );
+}
+
+
/************************************/
/* Called to initialize the program */
/************************************/
@@ -142,6 +203,9 @@

InitEDA_Appl( wxT( "EESchema" ), APP_TYPE_EESCHEMA );

+ if( argc > 1 && !wxStrcmp( argv[1], wxT( "--plot" ) ) )
+	PlotOnly( this );
+
if( m_Checker && m_Checker->IsAnotherRunning() )
{
if( !IsOK( NULL, _( "Eeschema is already running, Continue?" ) ) )

 




Follow ups

References