← Back to team overview

kicad-developers team mailing list archive

[FIX BUG] pcbnew option to export text as editable text when plotting DXF

 

Hi.
Another one patch related plotting to DXF.
Plot oneline ASCII text as editable.
https://bugs.launchpad.net/kicad/+bug/1423515

P.S. patch is incremental to my previous patches related with plot line width to DXF
>From 162558f598d5fa6ad4a8d4338a71a03f90529642 Mon Sep 17 00:00:00 2001
From: Eldar Khayrullin <eldar.khayrullin@xxxxxxx>
Date: Sun, 16 Apr 2017 20:07:31 +0300
Subject: [PATCH] pcbnew: add the option plot to DXF oneline ASCII text as
 editable text

---
 common/common_plotDXF_functions.cpp |   9 +++-
 pcbnew/dialogs/dialog_plot.cpp      |  12 +++++
 pcbnew/dialogs/dialog_plot_base.cpp |   8 ++-
 pcbnew/dialogs/dialog_plot_base.fbp | 102 +++++++++++++++++++++++++++++++++---
 pcbnew/dialogs/dialog_plot_base.h   |   5 +-
 5 files changed, 124 insertions(+), 12 deletions(-)

diff --git a/common/common_plotDXF_functions.cpp b/common/common_plotDXF_functions.cpp
index 24061a003..dcd9b7f7e 100644
--- a/common/common_plotDXF_functions.cpp
+++ b/common/common_plotDXF_functions.cpp
@@ -652,6 +652,8 @@ void DXF_PLOTTER::Text( const wxPoint&              aPos,
                         bool                        aMultilineAllowed,
                         void*                       aData )
 {
+    SetCurrentLineWidth( aWidth );
+
     // Fix me: see how to use DXF text mode for multiline texts
     if( aMultilineAllowed && !aText.Contains( wxT( "\n" ) ) )
         aMultilineAllowed = false;  // the text has only one line.
@@ -659,7 +661,7 @@ void DXF_PLOTTER::Text( const wxPoint&              aPos,
     if( textAsLines || containsNonAsciiChars( aText ) || aMultilineAllowed )
     {
         // output text as graphics.
-        // Perhaps miltiline texts could be handled as DXF text entity
+        // Perhaps multiline texts could be handled as DXF text entity
         // but I do not want spend time about this (JPC)
         PLOTTER::Text( aPos, aColor, aText, aOrient, aSize, aH_justify, aV_justify,
                 aWidth, aItalic, aBold, aMultilineAllowed );
@@ -668,6 +670,7 @@ void DXF_PLOTTER::Text( const wxPoint&              aPos,
     {
         /* Emit text as a text entity. This loses formatting and shape but it's
            more useful as a CAD object */
+        double pen_w = userToDeviceSize( GetCurrentLineWidth() );
         DPOINT origin_dev = userToDeviceCoordinates( aPos );
         SetColor( aColor );
         wxString cname( m_currentColor.ToColour().GetAsString( wxC2S_CSS_SYNTAX ) );
@@ -716,6 +719,8 @@ void DXF_PLOTTER::Text( const wxPoint&              aPos,
                 "%g\n"          // First point Y
                 "  21\n"
                 "%g\n"          // Second point Y
+                "  39\n"
+                "%g\n"          // Thickness
                 "  40\n"
                 "%g\n"          // Text height
                 "  41\n"
@@ -735,7 +740,7 @@ void DXF_PLOTTER::Text( const wxPoint&              aPos,
                 TO_UTF8( cname ),
                 origin_dev.x, origin_dev.x,
                 origin_dev.y, origin_dev.y,
-                size_dev.y, fabs( size_dev.x / size_dev.y ),
+                pen_w, size_dev.y, fabs( size_dev.x / size_dev.y ),
                 aOrient / 10.0,
                 aItalic ? DXF_OBLIQUE_ANGLE : 0,
                 size_dev.x < 0 ? 2 : 0, // X mirror flag
diff --git a/pcbnew/dialogs/dialog_plot.cpp b/pcbnew/dialogs/dialog_plot.cpp
index ff67b194d..31363150f 100644
--- a/pcbnew/dialogs/dialog_plot.cpp
+++ b/pcbnew/dialogs/dialog_plot.cpp
@@ -383,6 +383,8 @@ void DIALOG_PLOT::SetPlotFormat( wxCommandEvent& event )
         m_plotPSNegativeOpt->Enable( true );
         m_forcePSA4OutputOpt->Enable( false );
         m_forcePSA4OutputOpt->SetValue( false );
+        m_plotTextAsLineOpt->Enable( false );
+        m_plotTextAsLineOpt->SetValue( false );
 
         m_PlotOptionsSizer->Hide( m_GerberOptionsSizer );
         m_PlotOptionsSizer->Hide( m_HPGLOptionsSizer );
@@ -404,6 +406,8 @@ void DIALOG_PLOT::SetPlotFormat( wxCommandEvent& event )
         m_PSFineAdjustWidthOpt->Enable( true );
         m_plotPSNegativeOpt->Enable( true );
         m_forcePSA4OutputOpt->Enable( true );
+        m_plotTextAsLineOpt->Enable( false );
+        m_plotTextAsLineOpt->SetValue( true );
 
         m_PlotOptionsSizer->Hide( m_GerberOptionsSizer );
         m_PlotOptionsSizer->Hide( m_HPGLOptionsSizer );
@@ -430,6 +434,8 @@ void DIALOG_PLOT::SetPlotFormat( wxCommandEvent& event )
         m_plotPSNegativeOpt->SetValue( false );
         m_forcePSA4OutputOpt->Enable( false );
         m_forcePSA4OutputOpt->SetValue( false );
+        m_plotTextAsLineOpt->Enable( false );
+        m_plotTextAsLineOpt->SetValue( true );
 
         m_PlotOptionsSizer->Show( m_GerberOptionsSizer );
         m_PlotOptionsSizer->Hide( m_HPGLOptionsSizer );
@@ -455,6 +461,8 @@ void DIALOG_PLOT::SetPlotFormat( wxCommandEvent& event )
         m_plotPSNegativeOpt->SetValue( false );
         m_plotPSNegativeOpt->Enable( false );
         m_forcePSA4OutputOpt->Enable( true );
+        m_plotTextAsLineOpt->Enable( false );
+        m_plotTextAsLineOpt->SetValue( true );
 
         m_PlotOptionsSizer->Hide( m_GerberOptionsSizer );
         m_PlotOptionsSizer->Show( m_HPGLOptionsSizer );
@@ -479,6 +487,8 @@ void DIALOG_PLOT::SetPlotFormat( wxCommandEvent& event )
         m_plotPSNegativeOpt->SetValue( false );
         m_forcePSA4OutputOpt->Enable( false );
         m_forcePSA4OutputOpt->SetValue( false );
+        m_plotTextAsLineOpt->Enable( true );
+        m_plotTextAsLineOpt->SetValue( false );
 
         m_PlotOptionsSizer->Hide( m_GerberOptionsSizer );
         m_PlotOptionsSizer->Hide( m_HPGLOptionsSizer );
@@ -557,6 +567,8 @@ void DIALOG_PLOT::applyPlotSettings()
     tempOptions.SetMirror( m_plotMirrorOpt->GetValue() );
     tempOptions.SetPlotMode( m_plotModeOpt->GetSelection() == 1 ? SKETCH : FILLED );
     tempOptions.SetPlotViaOnMaskLayer( m_plotNoViaOnMaskOpt->GetValue() );
+    tempOptions.SetTextMode( m_plotTextAsLineOpt->GetValue() ?
+                             PLOTTEXTMODE_DEFAULT : PLOTTEXTMODE_NATIVE );
 
     // Update settings from text fields. Rewrite values back to the fields,
     // since the values may have been constrained by the setters.
diff --git a/pcbnew/dialogs/dialog_plot_base.cpp b/pcbnew/dialogs/dialog_plot_base.cpp
index 2610f6d20..187bd750d 100644
--- a/pcbnew/dialogs/dialog_plot_base.cpp
+++ b/pcbnew/dialogs/dialog_plot_base.cpp
@@ -1,5 +1,5 @@
 ///////////////////////////////////////////////////////////////////////////
-// C++ code generated with wxFormBuilder (version Feb 16 2016)
+// C++ code generated with wxFormBuilder (version Dec 21 2016)
 // http://www.wxformbuilder.org/
 //
 // PLEASE DO "NOT" EDIT THIS FILE!
@@ -128,6 +128,12 @@ DIALOG_PLOT_BASE::DIALOG_PLOT_BASE( wxWindow* parent, wxWindowID id, const wxStr
 	
 	bSizerPlotItems->Add( m_useAuxOriginCheckBox, 0, wxALL, 2 );
 	
+	m_plotTextAsLineOpt = new wxCheckBox( sbOptionsSizer->GetStaticBox(), wxID_ANY, _("Plot all text as line"), wxDefaultPosition, wxDefaultSize, 0 );
+	m_plotTextAsLineOpt->SetValue(true); 
+	m_plotTextAsLineOpt->SetToolTip( _("Otherwise plot oneline ASCII text as editable text") );
+	
+	bSizerPlotItems->Add( m_plotTextAsLineOpt, 0, wxALL, 5 );
+	
 	
 	bSizer192->Add( bSizerPlotItems, 0, wxEXPAND, 5 );
 	
diff --git a/pcbnew/dialogs/dialog_plot_base.fbp b/pcbnew/dialogs/dialog_plot_base.fbp
index 8c66c17dd..41cc1803c 100644
--- a/pcbnew/dialogs/dialog_plot_base.fbp
+++ b/pcbnew/dialogs/dialog_plot_base.fbp
@@ -44,7 +44,7 @@
             <property name="minimum_size">-1,-1</property>
             <property name="name">DIALOG_PLOT_BASE</property>
             <property name="pos"></property>
-            <property name="size">733,673</property>
+            <property name="size">647,840</property>
             <property name="style">wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER</property>
             <property name="subclass">DIALOG_SHIM; dialog_shim.h</property>
             <property name="title">Plot</property>
@@ -88,7 +88,7 @@
             <event name="OnSetFocus"></event>
             <event name="OnSize"></event>
             <event name="OnUpdateUI"></event>
-            <object class="wxBoxSizer" expanded="1">
+            <object class="wxBoxSizer" expanded="0">
                 <property name="minimum_size"></property>
                 <property name="name">m_MainSizer</property>
                 <property name="orient">wxVERTICAL</property>
@@ -1603,6 +1603,94 @@
                                                                 <event name="OnUpdateUI"></event>
                                                             </object>
                                                         </object>
+                                                        <object class="sizeritem" expanded="0">
+                                                            <property name="border">5</property>
+                                                            <property name="flag">wxALL</property>
+                                                            <property name="proportion">0</property>
+                                                            <object class="wxCheckBox" expanded="0">
+                                                                <property name="BottomDockable">1</property>
+                                                                <property name="LeftDockable">1</property>
+                                                                <property name="RightDockable">1</property>
+                                                                <property name="TopDockable">1</property>
+                                                                <property name="aui_layer"></property>
+                                                                <property name="aui_name"></property>
+                                                                <property name="aui_position"></property>
+                                                                <property name="aui_row"></property>
+                                                                <property name="best_size"></property>
+                                                                <property name="bg"></property>
+                                                                <property name="caption"></property>
+                                                                <property name="caption_visible">1</property>
+                                                                <property name="center_pane">0</property>
+                                                                <property name="checked">1</property>
+                                                                <property name="close_button">1</property>
+                                                                <property name="context_help"></property>
+                                                                <property name="context_menu">1</property>
+                                                                <property name="default_pane">0</property>
+                                                                <property name="dock">Dock</property>
+                                                                <property name="dock_fixed">0</property>
+                                                                <property name="docking">Left</property>
+                                                                <property name="enabled">1</property>
+                                                                <property name="fg"></property>
+                                                                <property name="floatable">1</property>
+                                                                <property name="font"></property>
+                                                                <property name="gripper">0</property>
+                                                                <property name="hidden">0</property>
+                                                                <property name="id">wxID_ANY</property>
+                                                                <property name="label">Plot all text as line</property>
+                                                                <property name="max_size"></property>
+                                                                <property name="maximize_button">0</property>
+                                                                <property name="maximum_size"></property>
+                                                                <property name="min_size"></property>
+                                                                <property name="minimize_button">0</property>
+                                                                <property name="minimum_size"></property>
+                                                                <property name="moveable">1</property>
+                                                                <property name="name">m_plotTextAsLineOpt</property>
+                                                                <property name="pane_border">1</property>
+                                                                <property name="pane_position"></property>
+                                                                <property name="pane_size"></property>
+                                                                <property name="permission">protected</property>
+                                                                <property name="pin_button">1</property>
+                                                                <property name="pos"></property>
+                                                                <property name="resize">Resizable</property>
+                                                                <property name="show">1</property>
+                                                                <property name="size"></property>
+                                                                <property name="style"></property>
+                                                                <property name="subclass"></property>
+                                                                <property name="toolbar_pane">0</property>
+                                                                <property name="tooltip">Otherwise plot oneline ASCII text as editable text</property>
+                                                                <property name="validator_data_type"></property>
+                                                                <property name="validator_style">wxFILTER_NONE</property>
+                                                                <property name="validator_type">wxDefaultValidator</property>
+                                                                <property name="validator_variable"></property>
+                                                                <property name="window_extra_style"></property>
+                                                                <property name="window_name"></property>
+                                                                <property name="window_style"></property>
+                                                                <event name="OnChar"></event>
+                                                                <event name="OnCheckBox"></event>
+                                                                <event name="OnEnterWindow"></event>
+                                                                <event name="OnEraseBackground"></event>
+                                                                <event name="OnKeyDown"></event>
+                                                                <event name="OnKeyUp"></event>
+                                                                <event name="OnKillFocus"></event>
+                                                                <event name="OnLeaveWindow"></event>
+                                                                <event name="OnLeftDClick"></event>
+                                                                <event name="OnLeftDown"></event>
+                                                                <event name="OnLeftUp"></event>
+                                                                <event name="OnMiddleDClick"></event>
+                                                                <event name="OnMiddleDown"></event>
+                                                                <event name="OnMiddleUp"></event>
+                                                                <event name="OnMotion"></event>
+                                                                <event name="OnMouseEvents"></event>
+                                                                <event name="OnMouseWheel"></event>
+                                                                <event name="OnPaint"></event>
+                                                                <event name="OnRightDClick"></event>
+                                                                <event name="OnRightDown"></event>
+                                                                <event name="OnRightUp"></event>
+                                                                <event name="OnSetFocus"></event>
+                                                                <event name="OnSize"></event>
+                                                                <event name="OnUpdateUI"></event>
+                                                            </object>
+                                                        </object>
                                                     </object>
                                                 </object>
                                                 <object class="sizeritem" expanded="0">
@@ -2870,11 +2958,11 @@
                                                         <event name="OnUpdateUI"></event>
                                                     </object>
                                                 </object>
-                                                <object class="sizeritem" expanded="1">
+                                                <object class="sizeritem" expanded="0">
                                                     <property name="border">2</property>
                                                     <property name="flag">wxALL</property>
                                                     <property name="proportion">0</property>
-                                                    <object class="wxCheckBox" expanded="1">
+                                                    <object class="wxCheckBox" expanded="0">
                                                         <property name="BottomDockable">1</property>
                                                         <property name="LeftDockable">1</property>
                                                         <property name="RightDockable">1</property>
@@ -4013,11 +4101,11 @@
                         </object>
                     </object>
                 </object>
-                <object class="sizeritem" expanded="1">
+                <object class="sizeritem" expanded="0">
                     <property name="border">5</property>
                     <property name="flag">wxEXPAND</property>
                     <property name="proportion">1</property>
-                    <object class="wxBoxSizer" expanded="1">
+                    <object class="wxBoxSizer" expanded="0">
                         <property name="minimum_size"></property>
                         <property name="name">sbSizerMsg</property>
                         <property name="orient">wxVERTICAL</property>
@@ -4104,7 +4192,7 @@
                         </object>
                     </object>
                 </object>
-                <object class="sizeritem" expanded="1">
+                <object class="sizeritem" expanded="0">
                     <property name="border">5</property>
                     <property name="flag">wxALIGN_RIGHT|wxRIGHT|wxLEFT</property>
                     <property name="proportion">0</property>
diff --git a/pcbnew/dialogs/dialog_plot_base.h b/pcbnew/dialogs/dialog_plot_base.h
index 5d1849b2b..3642be057 100644
--- a/pcbnew/dialogs/dialog_plot_base.h
+++ b/pcbnew/dialogs/dialog_plot_base.h
@@ -1,5 +1,5 @@
 ///////////////////////////////////////////////////////////////////////////
-// C++ code generated with wxFormBuilder (version Feb 16 2016)
+// C++ code generated with wxFormBuilder (version Dec 21 2016)
 // http://www.wxformbuilder.org/
 //
 // PLEASE DO "NOT" EDIT THIS FILE!
@@ -78,6 +78,7 @@ class DIALOG_PLOT_BASE : public DIALOG_SHIM
 		wxCheckBox* m_plotMirrorOpt;
 		wxCheckBox* m_plotPSNegativeOpt;
 		wxCheckBox* m_useAuxOriginCheckBox;
+		wxCheckBox* m_plotTextAsLineOpt;
 		wxStaticText* m_staticText11;
 		wxChoice* m_drillShapeOpt;
 		wxStaticText* m_staticText12;
@@ -131,7 +132,7 @@ class DIALOG_PLOT_BASE : public DIALOG_SHIM
 	
 	public:
 		
-		DIALOG_PLOT_BASE( wxWindow* parent, wxWindowID id = wxID_ANY, const wxString& title = _("Plot"), const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxSize( 733,673 ), long style = wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER ); 
+		DIALOG_PLOT_BASE( wxWindow* parent, wxWindowID id = wxID_ANY, const wxString& title = _("Plot"), const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxSize( 647,840 ), long style = wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER ); 
 		~DIALOG_PLOT_BASE();
 		
 		void DIALOG_PLOT_BASEOnContextMenu( wxMouseEvent &event )
-- 
2.11.0