File indexing completed on 2024-05-12 04:35:07

0001 /* This file is part of the TikZKit project.
0002  *
0003  * Copyright (C) 2013 Dominik Haumann <dhaumann@kde.org>
0004  *
0005  * This library is free software; you can redistribute it and/or modify
0006  * it under the terms of the GNU Library General Public License as published
0007  * by the Free Software Foundation, either version 2 of the License, or
0008  * (at your option) any later version.
0009  *
0010  * This library is distributed in the hope that it will be useful,
0011  * but WITHOUT ANY WARRANTY; without even the implied warranty of
0012  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
0013  * GNU Library General Public License for more details.
0014  *
0015  * You should have received a copy of the GNU Library General Public License
0016  * along with this library; see the file COPYING.LIB.  If not, see
0017  * <http://www.gnu.org/licenses/>.
0018  */
0019 
0020 #include "TikzExport.h"
0021 
0022 #include <QDebug>
0023 
0024 namespace tikz {
0025 namespace core {
0026 
0027 TikzExport::TikzExport()
0028 {
0029 }
0030 
0031 TikzExport::~TikzExport()
0032 {
0033 }
0034 
0035 QString TikzExport::tikzCode()
0036 {
0037     QString doc;
0038 
0039     //
0040     // start tikzpicture
0041     //
0042     if (m_documentOptions.isEmpty()) {
0043         doc += "\\begin{tikzpicture}\n";
0044     } else {
0045         doc += "\\begin{tikzpicture}[" + m_documentOptions + "]\n";
0046     }
0047 //     doc += "\\draw[help lines, gray] (-3, -2) grid (4, 4);\n";
0048 
0049     //
0050     // add all lines
0051     //
0052     for (const TikzLine & line : qAsConst(m_lines)) {
0053         doc += line.contents + "\n";
0054     }
0055 
0056     //
0057     // end tikzpicture
0058     //
0059     doc += "\\end{tikzpicture}\n";
0060 
0061     return doc;
0062 }
0063 
0064 void TikzExport::setDocumentOptions(const QString & options)
0065 {
0066     m_documentOptions = options;
0067 }
0068 
0069 void TikzExport::addTikzLine(const TikzLine & line)
0070 {
0071     m_lines.append(line);
0072 }
0073 
0074 }
0075 }
0076 
0077 // kate: indent-width 4; replace-tabs on;