[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-edu
Subject:    [kde-edu]: Re: Kig exporters: support linewidth in asymptote
From:       Raoul <raoulb () bluewin ! ch>
Date:       2011-04-22 1:30:06
Message-ID: 20110422033006.2aefc879 () pega ! pega
[Download RAW message or body]

Hi Maurizio,


As announced recently I tried to get a more complete support of
styles for the Asymptote exporter. The patch attached does this
and can process color, linewidth and linestyle information. See
also the demos. However, we may need some fine tuning to get nicer
images, but the basic features are implemented now. (For example
the linewidths are somewhat too thick in asy. And the ratio of
gaps and lineparts of dashed lines is wrong and gives bad results
for circles in combination with thick lines. But all these things
are not really severe and one can always improve the asy file manually.)

Further I enabled the export of cubics and used the generic curve
sampling function for that. In principle it works but we get
strange artefacts at the points where there is a vertical tangent
for some branch of the curve. (I hope that I can fix that with a
new curve sampling algorithm, but this will take some time.)

There are a few other small fixes in the patch, for example I
adjusted the export preset values for grid etc to the ones used
in the latex exporter dialog. And I fixed the axes for asy
output.

I read that there is the soft feature freeze on the 28th of April.
So hopefully we can get this into the repository until then?
Let me know if you have any questions or anything like that.

I would really like to see these things in KDE 4.7 :-)



-- Raoul

[Attachment #3 (application/x-gzip)]
[Attachment #4 (text/x-patch)]

diff --git a/filters/asyexporter.cc b/filters/asyexporter.cc
index a5010bd..cbb872f 100644
--- a/filters/asyexporter.cc
+++ b/filters/asyexporter.cc
@@ -58,9 +58,9 @@ void AsyExporter::run( const KigPart& doc, KigWidget& w )
   kfd->setOptionCaption( i18n( "Asymptote Options" ) );
   AsyExporterOptions* opts = new AsyExporterOptions( 0L );
   kfd->setOptionsWidget( opts );
-  opts->setGrid( false );
-  opts->setAxes( false );
-  opts->setExtraFrame( true );
+  opts->setGrid( true );
+  opts->setAxes( true );
+  opts->setExtraFrame( false );
   if ( !kfd->exec() )
     return;
 
@@ -68,7 +68,7 @@ void AsyExporter::run( const KigPart& doc, KigWidget& w )
   bool showgrid = opts->showGrid();
   bool showaxes = opts->showAxes();
   bool showframe = opts->showExtraFrame();
-  
+
   delete opts;
   delete kfd;
 
@@ -76,8 +76,8 @@ void AsyExporter::run( const KigPart& doc, KigWidget& w )
   if ( ! file.open( QIODevice::WriteOnly ) )
   {
     KMessageBox::sorry( &w, i18n( "The file \"%1\" could not be opened. Please "
-				  "check if the file permissions are set correctly." ,
-			  file_name ) );
+                                  "check if the file permissions are set correctly." \
, +                                  file_name ) );
     return;
   };
 
@@ -89,9 +89,9 @@ void AsyExporter::run( const KigPart& doc, KigWidget& w )
   std::vector<ObjectHolder*> os = doc.document().objects();
   QTextStream stream( &file );
   AsyExporterImpVisitor visitor( stream, w );
-  
+
   // Start building the output stream containing the asymptote script commands
-  
+
   // The file header for pure asymptote
   stream << "settings.outformat=\"pdf\";\n";
   stream << "\n";
@@ -102,18 +102,18 @@ void AsyExporter::run( const KigPart& doc, KigWidget& w )
   stream << "\n";
   stream << "real textboxmargin = 2mm;\n";
   stream << "\n";
-  
-  // grid
+
+  // Grid
   if ( showgrid )
   {
     // TODO: Polar grid
-    // vertical lines...
+    // Vertical lines
     double startingpoint = startingpoint = static_cast<double>( KDE_TRUNC( left ) );
     for ( double i = startingpoint; i < left+width; ++i )
     {
       stream << "draw((" << i << "," << bottom << ")--(" << i << "," << \
bottom+height << "),gray);\n";  }
-    // horizontal lines...
+    // Horizontal lines
     startingpoint = static_cast<double>( KDE_TRUNC( bottom ) );
     for ( double i = startingpoint; i < bottom+height; ++i )
     {
@@ -121,11 +121,11 @@ void AsyExporter::run( const KigPart& doc, KigWidget& w )
     }
   }
 
-  // axes
+  // Axes
   if ( showaxes )
   {
-    stream << "xaxis(\"\", Arrow);\n";
-    stream << "yaxis(\"\", Arrow);\n";
+    stream << "draw(("<<left<<",0)--("<<left+width<<",0), black, Arrow);\n";
+    stream << "draw((0,"<<bottom<<")--(0,"<<bottom+height<<"), black, Arrow);\n";
   }
 
   // Visit all the objects
@@ -135,14 +135,17 @@ void AsyExporter::run( const KigPart& doc, KigWidget& w )
   }
 
   stream << "path frame = ("<<left<<","<<bottom<<")--("
-			    <<left<<","<<bottom+height<<")--("
-			    <<left+width<<","<<bottom+height<<")--("
-			    <<left+width<<","<<bottom<<")--cycle;\n";
-  // extra frame
+          <<left<<","<<bottom+height<<")--("
+          <<left+width<<","<<bottom+height<<")--("
+          <<left+width<<","<<bottom<<")--cycle;\n";
+
+  // Extra frame
   if ( showframe )
   {
     stream << "draw(frame, black);\n";
   }
   stream << "clip(frame);\n";
 
+  // And close the output file
+  file.close();
 }
diff --git a/filters/asyexporterimpvisitor.cc b/filters/asyexporterimpvisitor.cc
index e3ab7ed..06a8bbf 100644
--- a/filters/asyexporterimpvisitor.cc
+++ b/filters/asyexporterimpvisitor.cc
@@ -39,29 +39,58 @@ void AsyExporterImpVisitor::newLine()
 }
 
 
-QString AsyExporterImpVisitor::emitColor( const QColor& c )
+QString AsyExporterImpVisitor::emitPenColor( const QColor& c )
 {
-  QString ret("");
-  ret = "rgb(" + QString::number(c.red()) + "," + QString::number(c.green()) + "," + \
                QString::number(c.blue()) + ")";
-  return ret;
+  QString pencolor("");
+  // Asymptote definition of pen color
+  pencolor = "rgb(" + QString::number(c.red()) + "," + QString::number(c.green()) + \
"," + QString::number(c.blue()) + ")"; +  return pencolor;
 }
 
 
-QString AsyExporterImpVisitor::emitStyle( Qt::PenStyle style )
+QString AsyExporterImpVisitor::emitPenStyle( const Qt::PenStyle& style )
 {
-  QString linetype("");
+  QString penstyle("");
+  // Asymptote definition of pen (line) style
+  // TODO: Needs finetuning of Asymptote linestyle parameters
   if ( style == Qt::SolidLine ) {
-    linetype = "solid";
+    penstyle = "solid";
   } else if ( style == Qt::DashLine ) {
-    linetype = "dashed";
+    penstyle = "dashed";
   } else if ( style == Qt::DotLine ) {
-    linetype = "dotted";
+    penstyle = "dotted";
   } else if ( style == Qt::DashDotLine ) {
-    linetype = "dashdotted";
+    penstyle = "dashdotted";
   } else if ( style == Qt::DashDotDotLine ) {
-    linetype = "longdashdotted";
+    penstyle = "longdashdotted";
   }
-  return linetype;
+  return penstyle;
+}
+
+
+QString AsyExporterImpVisitor::emitPenSize( const int width )
+{
+  QString pensize("");
+  if ( width < 0 )
+  {
+    // Nothing specified, use asymptote default
+    pensize = "linewidth(0.5)";
+  }
+  else
+  {
+    // Asymptote definition of pen size
+    pensize = "linewidth(" + QString::number(width) + ")";
+  }
+  return  pensize;
+}
+
+
+QString AsyExporterImpVisitor::emitPen( const QColor& c, const int width, const \
Qt::PenStyle& style ) +{
+  QString pen("");
+  // Asymptote definition of a pen
+  pen = emitPenColor(c) + "+" + emitPenSize(width) + "+" + emitPenStyle(style);
+  return  pen;
 }
 
 
@@ -87,18 +116,14 @@ void AsyExporterImpVisitor::emitLine( const Coordinate& a, const \
Coordinate& b,  if ( vector == true )
   {
     mstream << "draw(line, "
-	    << emitColor( mcurobj->drawer()->color() )
-	    << "+"
-	    << emitStyle( s )
-	    << ", Arrow );";
+            << emitPen( mcurobj->drawer()->color(), width, s )
+            << ", Arrow );";
   }
   else
   {
     mstream << "draw(line, "
-	    << emitColor( mcurobj->drawer()->color() )
-	    << "+"
-	    << emitStyle( s )
-	    << " );";
+            << emitPen( mcurobj->drawer()->color(), width, s )
+            << " );";
   }
   newLine();
 }
@@ -180,31 +205,31 @@ void AsyExporterImpVisitor::plotGenericCurve( const CurveImp* \
imp )  // Avoid too long lines in the output file
       if(linelength + tmp.length() > maxlinelength)
       {
-	linelength = tmp.length();
-	newLine();
+    linelength = tmp.length();
+    newLine();
       }
       else
       {
-	linelength += tmp.length();
+    linelength += tmp.length();
       }
       mstream << tmp;
       if ( j < s-1 )
       {
-	linelength += 2;
-	mstream << "--";
+    linelength += 2;
+    mstream << "--";
       }
       else
       {
-	mstream << ";";
-	newLine();
-	linelength = 0;
+    mstream << ";";
+    newLine();
+    linelength = 0;
       }
     }
+    int width = mcurobj->drawer()->width();
+    if ( width == -1 ) width = 1;
     mstream << "draw(curve, "
-	    << emitColor( mcurobj->drawer()->color() )
-	    << "+"
-	    << emitStyle( mcurobj->drawer()->style() )
-	    << " );";
+            << emitPen( mcurobj->drawer()->color(), width, \
mcurobj->drawer()->style() ) +            << " );";
     newLine();
   }
 }
@@ -215,8 +240,8 @@ void AsyExporterImpVisitor::visit( const LineImp* imp )
   Coordinate a = imp->data().a;
   Coordinate b = imp->data().b;
   calcBorderPoints( a, b, msr );
-
-  int width = 1;
+  int width = mcurobj->drawer()->width();
+  if ( width == -1 ) width = 1;
   emitLine( a, b, width, mcurobj->drawer()->style() );
 }
 
@@ -227,9 +252,11 @@ void AsyExporterImpVisitor::visit( const PointImp* imp )
           << emitCoord( imp->coordinate() )
           << ";";
   newLine();
+  int width = mcurobj->drawer()->width();
+  if ( width == -1 ) width = 3;
   mstream << "dot(point, "
-	  << emitColor( mcurobj->drawer()->color() )
-	  << ");";
+          << emitPen( mcurobj->drawer()->color(), width, mcurobj->drawer()->style() \
) +          << ");";
   newLine();
 }
 
@@ -242,10 +269,10 @@ void AsyExporterImpVisitor::visit( const TextImp* imp )
           << ";";
   newLine();
   mstream << "Label l = Label(\""
-	  << imp->text()
-	  << "\", "
-	  << emitColor( mcurobj-> drawer()->color() )
-	  << ");";
+          << imp->text()
+          << "\", "
+          << emitPenColor( mcurobj-> drawer()->color() )
+          << ");";
   newLine();
   if ( imp->hasFrame() )
   {
@@ -269,24 +296,22 @@ void AsyExporterImpVisitor::visit( const AngleImp* imp )
 
   startangle = Goniometry::convert( startangle, Goniometry::Rad, Goniometry::Deg );
   endangle = Goniometry::convert( endangle, Goniometry::Rad, Goniometry::Deg );
-  
-  // TODO: Allow arrow tips?
-  
+
   mstream << "path a = Arc("
-	  << emitCoord(center)
-	  << ", "
-	  << radius
-	  << ", "
-	  << startangle
-	  << ", "
-	  << endangle
-	  << " );";
+          << emitCoord(center)
+          << ", "
+          << radius
+          << ", "
+          << startangle
+          << ", "
+          << endangle
+          << " );";
   newLine();
+  int width = mcurobj->drawer()->width();
+  if ( width == -1 ) width = 1;
   mstream << "draw(a, "
-	  << emitColor( mcurobj->drawer()->color() )
-	  << "+"
-	  << emitStyle( mcurobj->drawer()->style() )
-	  << " );";
+          << emitPen( mcurobj->drawer()->color(), width, mcurobj->drawer()->style() \
) +          << ", Arrow );";
   newLine();
 }
 
@@ -295,8 +320,8 @@ void AsyExporterImpVisitor::visit( const VectorImp* imp )
 {
   Coordinate a = imp->data().a;
   Coordinate b = imp->data().b;
-
-  int width = 1;
+  int width = mcurobj->drawer()->width();
+  if ( width == -1 ) width = 1;
   emitLine( a, b, width, mcurobj->drawer()->style(), true );
 }
 
@@ -318,11 +343,11 @@ void AsyExporterImpVisitor::visit( const CircleImp* imp )
   newLine();
   mstream << "path circle = Circle(center, radius);";
   newLine();
+  int width = mcurobj->drawer()->width();
+  if ( width == -1 ) width = 1;
   mstream << "draw(circle, "
-	  << emitColor( mcurobj->drawer()->color() )
-	  << "+"
-	  << emitStyle( mcurobj->drawer()->style() )
-	  << " );";
+          << emitPen( mcurobj->drawer()->color(), width, mcurobj->drawer()->style() \
) +          << " );";
   newLine();
 }
 
@@ -333,10 +358,10 @@ void AsyExporterImpVisitor::visit( const ConicImp* imp )
 }
 
 
-void AsyExporterImpVisitor::visit( const CubicImp* )
+void AsyExporterImpVisitor::visit( const CubicImp* imp )
 {
   // FIXME: cubic are not drawn correctly with plotGenericCurve
-  //  plotGenericCurve( imp );
+  plotGenericCurve( imp );
 }
 
 
@@ -345,7 +370,8 @@ void AsyExporterImpVisitor::visit( const SegmentImp* imp )
   Coordinate a = imp->data().a;
   Coordinate b = imp->data().b;
 
-  int width = 1;
+  int width = mcurobj->drawer()->width();
+  if ( width == -1 ) width = 1;
   emitLine( a, b, width, mcurobj->drawer()->style() );
 }
 
@@ -356,7 +382,8 @@ void AsyExporterImpVisitor::visit( const RayImp* imp )
   Coordinate b = imp->data().b;
   calcRayBorderPoints( a, b, msr );
 
-  int width = 1;
+  int width = mcurobj->drawer()->width();
+  if ( width == -1 ) width = 1;
   emitLine( a, b, width, mcurobj->drawer()->style() );
 }
 
@@ -372,20 +399,20 @@ void AsyExporterImpVisitor::visit( const ArcImp* imp )
   endangle = Goniometry::convert( endangle, Goniometry::Rad, Goniometry::Deg );
 
   mstream << "path arc = Arc("
-	  << emitCoord(center)
-	  << ", "
-	  << radius
-	  << ", "
-	  << startangle
-	  << ", "
-	  << endangle
-	  << " );";
+          << emitCoord(center)
+          << ", "
+          << radius
+          << ", "
+          << startangle
+          << ", "
+          << endangle
+          << " );";
   newLine();
+  int width = mcurobj->drawer()->width();
+  if ( width == -1 ) width = 1;
   mstream << "draw(arc, "
-	  << emitColor( mcurobj->drawer()->color() )
-	  << "+"
-	  << emitStyle( mcurobj->drawer()->style() )
-	  << " );";
+          << emitPen( mcurobj->drawer()->color(), width, mcurobj->drawer()->style() \
) +          << " );";
   newLine();
 }
 
@@ -414,14 +441,14 @@ void AsyExporterImpVisitor::visit( const FilledPolygonImp* imp \
)  mstream << "cycle;";
   newLine();
   mstream << "fill(polygon, "
-	  << emitColor( mcurobj->drawer()->color() )
-	  << "+opacity(0.5) );";
+          << emitPenColor( mcurobj->drawer()->color() )
+          << "+opacity(0.5) );";
   newLine();
+  int width = mcurobj->drawer()->width();
+  if ( width == -1 ) width = 1;
   mstream << "draw(polygon, "
-	  << emitColor( mcurobj->drawer()->color() )
-	  << "+"
-	  << emitStyle( mcurobj->drawer()->style() )
-	  << " );";
+          << emitPen( mcurobj->drawer()->color(), width, mcurobj->drawer()->style() \
) +          << " );";
   newLine();
 }
 
@@ -446,14 +473,14 @@ void AsyExporterImpVisitor::visit(const ClosedPolygonalImp* \
imp)  linelength += tmp.length();
     }
     mstream << tmp;
-  } 
+  }
   mstream << "cycle;";
   newLine();
+  int width = mcurobj->drawer()->width();
+  if ( width == -1 ) width = 1;
   mstream << "draw(polygon, "
-	  << emitColor( mcurobj->drawer()->color() )
-	  << "+"
-	  << emitStyle( mcurobj->drawer()->style() )
-	  << " );";
+          << emitPen( mcurobj->drawer()->color(), width, mcurobj->drawer()->style() \
) +          << " );";
   newLine();
 }
 
@@ -477,7 +504,7 @@ void AsyExporterImpVisitor::visit(const OpenPolygonalImp* imp)
       linelength += tmp.length();
     }
     mstream << tmp;
-    if ( i < pts.size()-1 ) 
+    if ( i < pts.size()-1 )
     {
       linelength += 2;
       mstream << "--";
@@ -489,17 +516,19 @@ void AsyExporterImpVisitor::visit(const OpenPolygonalImp* imp)
     }
   }
   newLine();
+  int width = mcurobj->drawer()->width();
+  if ( width == -1 ) width = 1;
   mstream << "draw(polygon, "
-	  << emitColor( mcurobj->drawer()->color() )
-	  << "+"
-	  << emitStyle( mcurobj->drawer()->style() )
-	  << " );";
+          << emitPen( mcurobj->drawer()->color(), width, mcurobj->drawer()->style() \
) +          << " );";
   newLine();
 }
 
 
 void AsyExporterImpVisitor::visit ( const BezierImp* imp )
 {
+  int width = mcurobj->drawer()->width();
+  if ( width == -1 ) width = 1;
   std::vector<Coordinate> pts = imp->points();
   switch ( pts.size() )
   {
@@ -518,9 +547,7 @@ void AsyExporterImpVisitor::visit ( const BezierImp* imp )
     mstream << ";";
     newLine();
     mstream << "draw(bezier, "
-            << emitColor( mcurobj->drawer()->color() )
-            << "+"
-            << emitStyle( mcurobj->drawer()->style() )
+            << emitPen( mcurobj->drawer()->color(), width, \
mcurobj->drawer()->style() )  << " );";
     newLine();
     break;
@@ -536,9 +563,7 @@ void AsyExporterImpVisitor::visit ( const BezierImp* imp )
     mstream << ";";
     newLine();
     mstream << "draw(bezier, "
-            << emitColor( mcurobj->drawer()->color() )
-            << "+"
-            << emitStyle( mcurobj->drawer()->style() )
+            << emitPen( mcurobj->drawer()->color(), width, \
mcurobj->drawer()->style() )  << " );";
     newLine();
     break;
@@ -553,4 +578,3 @@ void AsyExporterImpVisitor::visit ( const RationalBezierImp* imp \
)  {
   plotGenericCurve ( imp );
 }
-
diff --git a/filters/asyexporterimpvisitor.h b/filters/asyexporterimpvisitor.h
index 7b35bc9..630d091 100644
--- a/filters/asyexporterimpvisitor.h
+++ b/filters/asyexporterimpvisitor.h
@@ -18,11 +18,6 @@
 #ifndef KIG_FILTERS_ASYEXPORTERIMPVISITOR_H
 #define KIG_FILTERS_ASYEXPORTERIMPVISITOR_H
 
-// #include <qcheckbox.h>
-// #include <qcolor.h>
-// #include <qfile.h>
-// #include <qtextstream.h>
-
 #include "../kig/kig_document.h"
 #include "../kig/kig_part.h"
 #include "../kig/kig_view.h"
@@ -82,28 +77,39 @@ private:
     * the lines may have a few more characters.)
     */
   static const uint maxlinelength = 500;
-  
+
   /**
-   * Converts Kig coords to pstrick coord system and sends them to stream
-   * using the format: (xcoord,ycoord)
+   * Return the pen color definition as a string.
    */
-  QString emitCoord( const Coordinate& c );
-  
+  QString emitPenColor( const QColor& c );
+
   /**
-   * Draws a line (segment) or a vector if vector is true.
+   * Return the pen style definition as a string.
    */
-  void emitLine( const Coordinate& a, const Coordinate& b, const int width,
-                 const Qt::PenStyle s, bool vector = false );
+  QString emitPenStyle( const Qt::PenStyle& style );
+
   /**
-   * Writes the color to the stream as rgb(r,g,b)
+   * Return the pen width definition as a string.
    */
-  QString emitColor( const QColor& c );
-  
+  QString emitPenSize( const int width );
+
   /**
-   * Writes a style definition to the stream.
+   * Return the full pen definition including color, size and style as a string.
    */
-  QString emitStyle( Qt::PenStyle style );
-  
+  QString emitPen( const QColor& c, const int width, const Qt::PenStyle& style );
+
+  /**
+   * Converts Kig coords to Asymptote coord system and sends them to stream
+   * using the format (xcoord,ycoord) wich is of asymptote data type "pair".
+   */
+  QString emitCoord( const Coordinate& c );
+
+  /**
+   * Draws a line (segment) or a vector if vector is true.
+   */
+  void emitLine( const Coordinate& a, const Coordinate& b, const int width,
+                 const Qt::PenStyle s, bool vector = false );
+
   /**
    * Sends a new line character ( \n ) to stream.
    */
@@ -114,7 +120,7 @@ private:
    * Kig coordinate system.
    */
   double dimRealToCoord( int dim );
-  
+
   /**
    * Plots a generic curve though its points calc'ed with getPoint.
    */
diff --git a/filters/latexexporter.cc b/filters/latexexporter.cc
index 6b456db..bad5b85 100644
--- a/filters/latexexporter.cc
+++ b/filters/latexexporter.cc
@@ -118,7 +118,7 @@ public:
     void visit( const OpenPolygonalImp* imp );
     void visit( const BezierImp* imp );
     void visit( const RationalBezierImp* imp );
-    
+
     double unit;
 
 private:
@@ -952,7 +952,7 @@ void TikZExportImpVisitor::visit(const BezierImp* imp)
         mstream << "+2/3*";
 	emitCoord(pts.at(1));
 	mstream << "-2/3*";
-	emitCoord(pts.at(0));	
+	emitCoord(pts.at(0));
 	mstream << "+1/3*";
 	emitCoord(pts.at(2));
 	mstream << "-1/3*";
@@ -994,20 +994,20 @@ void LatexExporter::run( const KigPart& doc, KigWidget& w )
     kfd->setOptionCaption( i18n( "Latex Options" ) );
     LatexExporterOptions* opts = new LatexExporterOptions( 0L );
     kfd->setOptionsWidget( opts );
-    
+
     opts->setGrid( doc.document().grid() );
     opts->setAxes( doc.document().axes() );
     opts->setExtraFrame( false );
-    
+
     KConfigGroup cg = KGlobal::config()->group("Latex Exporter");
-    
+
     int fmt = cg.readEntry<int>("OutputFormat", LatexExporterOptions::PSTricks);
     if (fmt > -1 && fmt < LatexExporterOptions::FormatCount)
     {
         opts->setFormat((LatexExporterOptions::LatexOutputFormat)fmt);
     }
     opts->setStandalone(cg.readEntry("Standalone", true));
-    
+
     if ( !kfd->exec() )
         return;
 
@@ -1020,7 +1020,7 @@ void LatexExporter::run( const KigPart& doc, KigWidget& w )
 
     delete opts;
     delete kfd;
-    
+
     cg.writeEntry("OutputFormat", (int)format);
     cg.writeEntry("Standalone", standalone);
 
@@ -1220,7 +1220,7 @@ void LatexExporter::run( const KigPart& doc, KigWidget& w )
         {
           stream << "\\end{document}\n";
         }
-        
+
     }
     else if (format == LatexExporterOptions::Asymptote)
     {
@@ -1228,7 +1228,7 @@ void LatexExporter::run( const KigPart& doc, KigWidget& w )
         const double left = w.showingRect().left();
         const double height = w.showingRect().height();
         const double width = w.showingRect().width();
-      
+
         if (standalone)
         {
 	    // The header if we embed into latex
@@ -1247,7 +1247,7 @@ void LatexExporter::run( const KigPart& doc, KigWidget& w )
 	stream << "\n";
 	stream << "real textboxmargin = 2mm;\n";
 	stream << "\n";
-      
+
 	// grid
 	if ( showgrid )
 	{
@@ -1266,16 +1266,16 @@ void LatexExporter::run( const KigPart& doc, KigWidget& w )
 	  }
 	}
 
-	// axes
-	if ( showaxes )
-	{
-	  stream << "xaxis(\"\", Arrow);\n";
-	  stream << "yaxis(\"\", Arrow);\n";
-	}
-        
+    // axes
+    if ( showaxes )
+    {
+      stream << "draw(("<<left<<",0)--("<<left+width<<",0), black, Arrow);\n";
+      stream << "draw((0,"<<bottom<<")--(0,"<<bottom+height<<"), black, Arrow);\n";
+    }
+
         // Visit all the objects
         AsyExporterImpVisitor visitor( stream, w );
-        
+
         for ( std::vector<ObjectHolder*>::const_iterator i = os.begin(); i != \
os.end(); ++i )  {
             visitor.visit( *i );
@@ -1286,7 +1286,7 @@ void LatexExporter::run( const KigPart& doc, KigWidget& w )
                                   <<left<<","<<bottom+height<<")--("
                                   <<left+width<<","<<bottom+height<<")--("
                                   <<left+width<<","<<bottom<<")--cycle;\n";
-        
+
         if ( showframe )
         {
             stream << "draw(frame, black);\n";
@@ -1294,14 +1294,14 @@ void LatexExporter::run( const KigPart& doc, KigWidget& w )
         stream << "clip(frame);\n";
         stream << "\n";
         stream << "\\end{asy}\n";
-	
+
         // The file footer in case we embed into latex
         if ( standalone )
         {
 	    stream << "\\end{document}\n";
         }
     }
-    
+
     // And close the output file
     file.close();
 }



_______________________________________________
kde-edu mailing list
kde-edu@mail.kde.org
https://mail.kde.org/mailman/listinfo/kde-edu


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic