← Back to team overview

kicad-developers team mailing list archive

[PATCH] Fix vertical offset for multiline text in VRML exporter

 

Greetings

After the fuzz with the multiline text's origin [1], this was not
fixed in the VRML export, maybe also some other exporters, I have not
tried those.

Here is a patch that applies the same method to the export_vrml.cpp as
was done in rev 4577.

I am not sure if the (EDA_COLOR_T) cast should be there or not, I
guess not. I also indented the arguments of the function calls around
that area. I can't see exactly in the style guide if this is how it is
supposed to be, but that is how it is done in almost all the other
places I have looked.

I have tested this by importing to blender.

Regards
Nick Østergaard

[1] https://bugs.launchpad.net/kicad/+bug/1263798
=== modified file 'pcbnew/exporters/export_vrml.cpp'
--- pcbnew/exporters/export_vrml.cpp	2014-03-20 06:24:33 +0000
+++ pcbnew/exporters/export_vrml.cpp	2014-04-15 13:06:21 +0000
@@ -600,38 +600,36 @@
     if( text->IsMirrored() )
         NEGATE( size.x );
 
+    EDA_COLOR_T color = BLACK;  // not actually used, but needed by DrawGraphicText
+
     if( text->IsMultilineAllowed() )
     {
-        wxPoint pos = text->GetTextPosition();
         wxArrayString* list = wxStringSplit( text->GetText(), '\n' );
-        wxPoint offset;
-
-        offset.y = text->GetInterline();
-
-        RotatePoint( &offset, text->GetOrientation() );
-
-        for( unsigned i = 0; i<list->Count(); i++ )
+        std::vector<wxPoint> positions;
+        positions.reserve( list->Count() );
+        text->GetPositionsOfLinesOfMultilineText( positions, list->Count() );
+
+        for( unsigned ii = 0; ii < list->Count(); ii++ )
         {
-            wxString txt = list->Item( i );
-            DrawGraphicText( NULL, NULL, pos, BLACK,
-                    txt, text->GetOrientation(), size,
-                    text->GetHorizJustify(), text->GetVertJustify(),
-                    text->GetThickness(), text->IsItalic(),
-                    true,
-                    vrml_text_callback );
-            pos += offset;
+            wxString txt = list->Item( ii );
+            DrawGraphicText( NULL, NULL, positions[ii], color,
+                             txt, text->GetOrientation(), size,
+                             text->GetHorizJustify(), text->GetVertJustify(),
+                             text->GetThickness(), text->IsItalic(),
+                             true,
+                             vrml_text_callback );
         }
 
         delete (list);
     }
     else
     {
-        DrawGraphicText( NULL, NULL, text->GetTextPosition(), BLACK,
-                text->GetText(), text->GetOrientation(), size,
-                text->GetHorizJustify(), text->GetVertJustify(),
-                text->GetThickness(), text->IsItalic(),
-                true,
-                vrml_text_callback );
+        DrawGraphicText( NULL, NULL, text->GetTextPosition(), color,
+                         text->GetText(), text->GetOrientation(), size,
+                         text->GetHorizJustify(), text->GetVertJustify(),
+                         text->GetThickness(), text->IsItalic(),
+                         true,
+                         vrml_text_callback );
     }
 }
 


Follow ups