From b1e4579863e55496c4b143f18c84cdcb973dd6af Mon Sep 17 00:00:00 2001 From: Aleks Kissinger Date: Thu, 24 Jan 2019 17:58:31 +0100 Subject: increment version number --- src/tikzit.h | 2 +- tikzit.pro | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/tikzit.h b/src/tikzit.h index 4b99062..94aba9d 100644 --- a/src/tikzit.h +++ b/src/tikzit.h @@ -49,7 +49,7 @@ #ifndef TIKZIT_H #define TIKZIT_H -#define TIKZIT_VERSION "2.1.3" +#define TIKZIT_VERSION "2.1.4" #include "mainwindow.h" #include "mainmenu.h" diff --git a/tikzit.pro b/tikzit.pro index 83a8820..6fe8471 100644 --- a/tikzit.pro +++ b/tikzit.pro @@ -2,7 +2,7 @@ QT += core gui widgets network -VERSION = 2.1.3 +VERSION = 2.1.4 test { CONFIG += testcase -- cgit v1.2.3 From 0755b73637711e803069da01560df9e491dd7d51 Mon Sep 17 00:00:00 2001 From: Aleks Kissinger Date: Thu, 24 Jan 2019 22:24:36 +0100 Subject: made hold shift to scroll a preference (closes #53) --- src/gui/preferencedialog.cpp | 2 ++ src/gui/preferencedialog.ui | 17 ++++++++++++----- src/gui/tikzview.cpp | 10 ++++++++-- 3 files changed, 22 insertions(+), 7 deletions(-) diff --git a/src/gui/preferencedialog.cpp b/src/gui/preferencedialog.cpp index 14cacf0..0fdd5c3 100644 --- a/src/gui/preferencedialog.cpp +++ b/src/gui/preferencedialog.cpp @@ -31,6 +31,7 @@ PreferenceDialog::PreferenceDialog(QWidget *parent) : connect(ui->minorColor, SIGNAL(clicked()), this, SLOT(colorClick())); ui->selectNewEdges->setChecked(settings.value("select-new-edges", false).toBool()); + ui->shiftToScroll->setChecked(settings.value("shift-to-scroll", false).toBool()); } PreferenceDialog::~PreferenceDialog() @@ -47,6 +48,7 @@ void PreferenceDialog::accept() settings.setValue("grid-color-major", color(ui->majorColor)); settings.setValue("grid-color-minor", color(ui->minorColor)); settings.setValue("select-new-edges", ui->selectNewEdges->isChecked()); + settings.setValue("shift-to-scroll", ui->shiftToScroll->isChecked()); QDialog::accept(); } diff --git a/src/gui/preferencedialog.ui b/src/gui/preferencedialog.ui index 80bdc57..894d356 100644 --- a/src/gui/preferencedialog.ui +++ b/src/gui/preferencedialog.ui @@ -47,7 +47,7 @@ - Grid colors + Grid Colors @@ -220,17 +220,24 @@ - + - Auto-select new edges + UI Options - + - + Auto-select new edges + + + + + + + Hold shift to scroll with wheel or touchpad diff --git a/src/gui/tikzview.cpp b/src/gui/tikzview.cpp index ddbc404..3615685 100644 --- a/src/gui/tikzview.cpp +++ b/src/gui/tikzview.cpp @@ -134,10 +134,16 @@ void TikzView::drawBackground(QPainter *painter, const QRectF &rect) void TikzView::wheelEvent(QWheelEvent *event) { - if (event->modifiers() & Qt::ShiftModifier) { + QSettings settings("tikzit", "tikzit"); + bool shiftScroll = settings.value("shift-to-scroll", false).toBool(); + if ((!shiftScroll && event->modifiers() == Qt::NoModifier) || + (shiftScroll && (event->modifiers() == Qt::ShiftModifier))) + { event->setModifiers(Qt::NoModifier); QGraphicsView::wheelEvent(event); - } else if (event->modifiers() & Qt::ControlModifier) { + } + + if (event->modifiers() & Qt::ControlModifier) { if (event->angleDelta().y() > 0) { zoomIn(); } else if (event->angleDelta().y() < 0) { -- cgit v1.2.3 From ce94cb38ec38ce5a304b3bab1b9a2d903e1d15e9 Mon Sep 17 00:00:00 2001 From: Aleks Kissinger Date: Fri, 25 Jan 2019 14:56:15 +0100 Subject: set window geometry after showing it for the first time --- src/gui/mainwindow.cpp | 33 +++++++++++++++++++++------------ src/gui/mainwindow.h | 1 + src/gui/previewwindow.cpp | 23 ++++++++++++++++------- src/gui/previewwindow.h | 2 ++ src/tikzit.cpp | 8 ++++++++ 5 files changed, 48 insertions(+), 19 deletions(-) diff --git a/src/gui/mainwindow.cpp b/src/gui/mainwindow.cpp index 71fea63..71b9070 100644 --- a/src/gui/mainwindow.cpp +++ b/src/gui/mainwindow.cpp @@ -46,19 +46,7 @@ MainWindow::MainWindow(QWidget *parent) : _menu->setParent(this); setMenuBar(_menu); - QVariant geom = settings.value(QString("geometry-main-qt") + qVersion()); - QVariant state = settings.value(QString("windowState-main-qt") + qVersion()); - - if (geom.isValid()) { - restoreGeometry(geom.toByteArray()); - } - if (state.isValid()) { - restoreState(state.toByteArray(), 2); - } else { - addDockWidget(Qt::RightDockWidgetArea, _stylePalette); - resizeDocks({_stylePalette}, {130}, Qt::Horizontal); - } // initially, the source view should be collapsed QList sz = ui->splitter->sizes(); @@ -76,6 +64,15 @@ MainWindow::MainWindow(QWidget *parent) : #else ui->tikzSource->setTabStopWidth(20); #endif + + + QVariant state = settings.value(QString("windowState-main-qt") + qVersion()); + if (state.isValid()) { + restoreState(state.toByteArray(), 2); + } else { + addDockWidget(Qt::RightDockWidgetArea, _stylePalette); + resizeDocks({_stylePalette}, {130}, Qt::Horizontal); + } } MainWindow::~MainWindow() @@ -84,6 +81,18 @@ MainWindow::~MainWindow() delete ui; } +void MainWindow::restorePosition() +{ + QSettings settings("tikzit", "tikzit"); + QVariant geom = settings.value(QString("geometry-main-qt") + qVersion()); + + if (geom.isValid()) { + restoreGeometry(geom.toByteArray()); + } + + +} + void MainWindow::open(QString fileName) { _tikzDocument->open(fileName); diff --git a/src/gui/mainwindow.h b/src/gui/mainwindow.h index 21fbd5a..48a88dd 100644 --- a/src/gui/mainwindow.h +++ b/src/gui/mainwindow.h @@ -29,6 +29,7 @@ public: explicit MainWindow(QWidget *parent = 0); ~MainWindow(); + void restorePosition(); void open(QString fileName); int windowId() const; TikzView *tikzView() const; diff --git a/src/gui/previewwindow.cpp b/src/gui/previewwindow.cpp index acce1a1..4906484 100644 --- a/src/gui/previewwindow.cpp +++ b/src/gui/previewwindow.cpp @@ -41,15 +41,10 @@ PreviewWindow::PreviewWindow(QWidget *parent) : QDialog(parent), ui(new Ui::PreviewWindow) { - QSettings settings("tikzit", "tikzit"); - ui->setupUi(this); - QVariant geom = settings.value(QString("geometry-preview-qt") + qVersion()); - - if (geom.isValid()) { - restoreGeometry(geom.toByteArray()); - } + ui->setupUi(this); + _positionRestored = false; _doc = nullptr; _loader = new QLabel(ui->tabWidget->tabBar()); @@ -90,6 +85,20 @@ PreviewWindow::~PreviewWindow() delete ui; } +void PreviewWindow::restorePosition() +{ + // only restore position 1 time + if (_positionRestored) return; + + QSettings settings("tikzit", "tikzit"); + QVariant geom = settings.value(QString("geometry-preview-qt") + qVersion()); + + if (geom.isValid()) { + restoreGeometry(geom.toByteArray()); + } + _positionRestored = true; +} + void PreviewWindow::setPdf(QString file) { // use loadFromData to avoid holding a lock on the PDF file in windows diff --git a/src/gui/previewwindow.h b/src/gui/previewwindow.h index a14303b..0cb10aa 100644 --- a/src/gui/previewwindow.h +++ b/src/gui/previewwindow.h @@ -46,6 +46,7 @@ public: }; explicit PreviewWindow(QWidget *parent = nullptr); ~PreviewWindow() override; + void restorePosition(); void setPdf(QString file); QString preparePreview(QString tikz); QPlainTextEdit *outputTextEdit(); @@ -67,6 +68,7 @@ private: Ui::PreviewWindow *ui; PdfDocument *_doc; QLabel *_loader; + bool _positionRestored; }; #endif // PREVIEWWINDOW_H diff --git a/src/tikzit.cpp b/src/tikzit.cpp index 8569817..f2ad661 100644 --- a/src/tikzit.cpp +++ b/src/tikzit.cpp @@ -61,6 +61,7 @@ void Tikzit::init() //_stylePalette->show(); _windows << new MainWindow(); _windows[0]->show(); + _windows[0]->restorePosition(); _styleFile = ""; _styleFilePath = ""; @@ -187,6 +188,7 @@ void Tikzit::newDoc() { MainWindow *w = new MainWindow(); w->show(); + w->restorePosition(); _windows << w; } @@ -250,6 +252,7 @@ void Tikzit::open(QString fileName) MainWindow *w = new MainWindow(); _windows << w; w->show(); + w->restorePosition(); w->open(fileName); } } @@ -437,7 +440,12 @@ void Tikzit::makePreview() } else { _latex->makePreview(activeWindow()->tikzSource()); } + _preview->show(); + + // restores position from settings the first time this is called, otherwise + // do nothing. + _preview->restorePosition(); _preview->raise(); } } -- cgit v1.2.3 From 8b0c46c6c0203b9c33c991fb5446663e257d429c Mon Sep 17 00:00:00 2001 From: Aleks Kissinger Date: Sun, 27 Jan 2019 13:24:55 +0100 Subject: added more deps to the deploy script --- deploy-linux.sh | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/deploy-linux.sh b/deploy-linux.sh index 373092a..dddf539 100755 --- a/deploy-linux.sh +++ b/deploy-linux.sh @@ -1,5 +1,13 @@ #!/bin/bash +# Deployment script for Linux x64 portable binary. This +# script is tested on a clean Ubuntu 18.04, after running: +# +# apt-get -y install \ +# flex bison qt5-default libpoppler-dev \ +# libpoppler-qt5-dev +# + # directory where libQt5XXX.so files can be found LIBDIR=/usr/lib/x86_64-linux-gnu @@ -15,7 +23,7 @@ mkdir -p plugins # add README file cat > README << 'EOF' -This is a portable version of TikZiT 2.0. To launch TikZiT, simply run +This is a portable version of TikZiT 2.1. To launch TikZiT, simply run 'bin/tikzit'. To install launcher and icons for the current user, make sure the 'bin' sub-directory is in your $PATH and run: @@ -84,6 +92,18 @@ cp --no-dereference $LIBDIR/libcrypto.so* lib cp --no-dereference $LIBDIR/libpoppler.so* lib cp --no-dereference $LIBDIR/libpoppler-qt5.so* lib +# add dependencies of poppler that are on Ubuntu 18.04, +# but maybe not other distros... +cp --no-dereference $LIBDIR/libfontconfig.so.1* lib +cp --no-dereference $LIBDIR/libfreetype.so.6* lib +cp --no-dereference $LIBDIR/libgraphite2.so.3* lib +cp --no-dereference $LIBDIR/libharfbuzz.so.0* lib +cp --no-dereference $LIBDIR/libjbig.so.0* lib +cp --no-dereference $LIBDIR/libjpeg.so.8* lib +cp --no-dereference $LIBDIR/liblcms2.so.2* lib +cp --no-dereference $LIBDIR/libpng16.so.16* lib + + # add Qt plugins used by TikZiT cp -R $PLUGINDIR/platforms plugins cp -R $PLUGINDIR/imageformats plugins -- cgit v1.2.3 From 2dbd1601ba691f021233d05b9564b010246cf055 Mon Sep 17 00:00:00 2001 From: Aleks Kissinger Date: Sun, 27 Jan 2019 14:08:20 +0100 Subject: take font libs back out of linux package --- deploy-linux.sh | 2 -- 1 file changed, 2 deletions(-) diff --git a/deploy-linux.sh b/deploy-linux.sh index dddf539..d0fc9f7 100755 --- a/deploy-linux.sh +++ b/deploy-linux.sh @@ -94,8 +94,6 @@ cp --no-dereference $LIBDIR/libpoppler-qt5.so* lib # add dependencies of poppler that are on Ubuntu 18.04, # but maybe not other distros... -cp --no-dereference $LIBDIR/libfontconfig.so.1* lib -cp --no-dereference $LIBDIR/libfreetype.so.6* lib cp --no-dereference $LIBDIR/libgraphite2.so.3* lib cp --no-dereference $LIBDIR/libharfbuzz.so.0* lib cp --no-dereference $LIBDIR/libjbig.so.0* lib -- cgit v1.2.3 From 93c01fdf84c8a694cbe1e8115e55f6879382355c Mon Sep 17 00:00:00 2001 From: Aleks Kissinger Date: Mon, 28 Jan 2019 09:37:10 +0100 Subject: added libz to linux dist --- deploy-linux.sh | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/deploy-linux.sh b/deploy-linux.sh index d0fc9f7..cea0a2f 100755 --- a/deploy-linux.sh +++ b/deploy-linux.sh @@ -8,8 +8,11 @@ # libpoppler-qt5-dev # -# directory where libQt5XXX.so files can be found -LIBDIR=/usr/lib/x86_64-linux-gnu +# system library directory +SYSLIBDIR=/lib/x86_64-linux-gnu + +# userspace library directory +LIBDIR=/usr$SYSLIBDIR # directory where Qt plugins can be found PLUGINDIR=$LIBDIR/qt5/plugins @@ -100,7 +103,7 @@ cp --no-dereference $LIBDIR/libjbig.so.0* lib cp --no-dereference $LIBDIR/libjpeg.so.8* lib cp --no-dereference $LIBDIR/liblcms2.so.2* lib cp --no-dereference $LIBDIR/libpng16.so.16* lib - +cp --no-dereference $SYSLIBDIR/libz.so.1* lib # add Qt plugins used by TikZiT cp -R $PLUGINDIR/platforms plugins -- cgit v1.2.3 From 3ad8769fe1a1d4fbafc6bb6604451b2f5759c6b7 Mon Sep 17 00:00:00 2001 From: Aleks Kissinger Date: Mon, 28 Jan 2019 11:44:57 +0100 Subject: updated CMakeLists --- CMakeLists.txt | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index 311dac4..94595c1 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -28,21 +28,29 @@ ADD_FLEX_BISON_DEPENDENCY(LEXER PARSER) cmake_policy(SET CMP0071 NEW) # run AUTOXXX on generated files ('NEW' default behaviour) set(SOURCES + src/data/delimitedstringvalidator.cpp src/data/edge.cpp src/data/graph.cpp src/data/graphelementdata.cpp src/data/graphelementproperty.cpp src/data/node.cpp + src/data/pdfdocument.cpp src/data/style.cpp src/data/stylelist.cpp src/data/tikzassembler.cpp src/data/tikzdocument.cpp + src/data/tikzlexer.lexer.cpp + src/data/tikzparser.parser.cpp src/data/tikzstyles.cpp src/gui/commands.cpp + src/gui/delimitedstringitemdelegate.cpp src/gui/edgeitem.cpp + src/gui/exportdialog.cpp + src/gui/latexprocess.cpp src/gui/mainmenu.cpp src/gui/mainwindow.cpp src/gui/nodeitem.cpp + src/gui/preferencedialog.cpp src/gui/previewwindow.cpp src/gui/propertypalette.cpp src/gui/styleeditor.cpp @@ -52,6 +60,10 @@ set(SOURCES src/gui/toolpalette.cpp src/gui/undocommands.cpp src/main.cpp + src/test/testmain.cpp + src/test/testparser.cpp + src/test/testtest.cpp + src/test/testtikzoutput.cpp src/tikzit.cpp src/util.cpp ) @@ -62,6 +74,7 @@ set(HEADERS src/data/graphelementdata.h src/data/graphelementproperty.h src/data/node.h + src/data/pdfdocument.h src/data/style.h src/data/stylelist.h src/data/tikzassembler.h @@ -69,10 +82,14 @@ set(HEADERS src/data/tikzparserdefs.h src/data/tikzstyles.h src/gui/commands.h + src/gui/delimitedstringitemdelegate.h src/gui/edgeitem.h + src/gui/exportdialog.h + src/gui/latexprocess.h src/gui/mainmenu.h src/gui/mainwindow.h src/gui/nodeitem.h + src/gui/preferencedialog.h src/gui/previewwindow.h src/gui/propertypalette.h src/gui/styleeditor.h @@ -81,13 +98,18 @@ set(HEADERS src/gui/tikzview.h src/gui/toolpalette.h src/gui/undocommands.h + src/test/testparser.h + src/test/testtest.h + src/test/testtikzoutput.h src/tikzit.h src/util.h ) set(FORMS + src/gui/exportdialog.ui src/gui/mainmenu.ui src/gui/mainwindow.ui + src/gui/preferencedialog.ui src/gui/previewwindow.ui src/gui/propertypalette.ui src/gui/styleeditor.ui -- cgit v1.2.3 From c1d67c27dc4e8a04700dfc4bfd5c4262b094f2e3 Mon Sep 17 00:00:00 2001 From: Aleks Kissinger Date: Tue, 29 Jan 2019 14:54:42 +0100 Subject: updated CMakeLists as suggested in #25 --- CMakeLists.txt | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 94595c1..67b61fa 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -25,7 +25,9 @@ include_directories( BISON_TARGET(PARSER src/data/tikzparser.y ${CMAKE_CURRENT_BINARY_DIR}/tikzparser.parser.cpp) FLEX_TARGET(LEXER src/data/tikzlexer.l ${CMAKE_CURRENT_BINARY_DIR}/tikzlexer.lexer.cpp) ADD_FLEX_BISON_DEPENDENCY(LEXER PARSER) -cmake_policy(SET CMP0071 NEW) # run AUTOXXX on generated files ('NEW' default behaviour) + + +#cmake_policy(SET CMP0071 NEW) # run AUTOXXX on generated files ('NEW' default behaviour) set(SOURCES src/data/delimitedstringvalidator.cpp @@ -39,8 +41,6 @@ set(SOURCES src/data/stylelist.cpp src/data/tikzassembler.cpp src/data/tikzdocument.cpp - src/data/tikzlexer.lexer.cpp - src/data/tikzparser.parser.cpp src/data/tikzstyles.cpp src/gui/commands.cpp src/gui/delimitedstringitemdelegate.cpp @@ -60,10 +60,6 @@ set(SOURCES src/gui/toolpalette.cpp src/gui/undocommands.cpp src/main.cpp - src/test/testmain.cpp - src/test/testparser.cpp - src/test/testtest.cpp - src/test/testtikzoutput.cpp src/tikzit.cpp src/util.cpp ) @@ -98,9 +94,6 @@ set(HEADERS src/gui/tikzview.h src/gui/toolpalette.h src/gui/undocommands.h - src/test/testparser.h - src/test/testtest.h - src/test/testtikzoutput.h src/tikzit.h src/util.h ) @@ -132,3 +125,5 @@ add_executable(tikzit target_link_libraries(${PROJECT_NAME} Qt5::Core Qt5::Gui Qt5::Widgets Qt5::Network ${Poppler_LIBRARIES}) + +install (TARGETS tikzit DESTINATION bin) -- cgit v1.2.3 From 3bd193256b17e578f5274d4c9acf6339b3936bfe Mon Sep 17 00:00:00 2001 From: Aleks Kissinger Date: Thu, 31 Jan 2019 22:49:58 +0100 Subject: replace tex constants with unicode equivalent --- src/gui/nodeitem.cpp | 9 ++-- src/tikzit.cpp | 2 + src/util.cpp | 120 ++++++++++++++++++++++++++++++++++++++++++++++++++- src/util.h | 4 ++ 4 files changed, 130 insertions(+), 5 deletions(-) diff --git a/src/gui/nodeitem.cpp b/src/gui/nodeitem.cpp index 78fe66e..82692f2 100644 --- a/src/gui/nodeitem.cpp +++ b/src/gui/nodeitem.cpp @@ -19,6 +19,7 @@ #include "tikzit.h" #include "nodeitem.h" #include "tikzscene.h" +#include "util.h" #include #include @@ -50,7 +51,7 @@ void NodeItem::writePos() } QRectF NodeItem::labelRect() const { - QString label = _node->label(); + QString label = replaceTexConstants(_node->label()); QFontMetrics fm(Tikzit::LABEL_FONT); QRectF rect = fm.boundingRect(label); rect.moveCenter(QPointF(0,0)); @@ -58,7 +59,7 @@ QRectF NodeItem::labelRect() const { } QRectF NodeItem::outerLabelRect() const { - QString label = _node->data()->property("label"); + QString label = replaceTexConstants(_node->data()->property("label")); label.replace(QRegularExpression("^[^:]*:"), ""); QFontMetrics fm(Tikzit::LABEL_FONT); QRectF rect = fm.boundingRect(label); @@ -102,11 +103,11 @@ void NodeItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *, QWidge painter->setPen(QPen(Qt::black)); painter->setFont(Tikzit::LABEL_FONT); - painter->drawText(rect, Qt::AlignCenter, _node->label()); + painter->drawText(rect, Qt::AlignCenter, replaceTexConstants(_node->label())); } if (_node->data()->hasProperty("label")) { - QString label = _node->data()->property("label"); + QString label = replaceTexConstants(_node->data()->property("label")); label.replace(QRegularExpression("^[^:]*:"), ""); QRectF rect = outerLabelRect(); diff --git a/src/tikzit.cpp b/src/tikzit.cpp index f2ad661..a286630 100644 --- a/src/tikzit.cpp +++ b/src/tikzit.cpp @@ -21,6 +21,7 @@ #include "tikzstyles.h" #include "previewwindow.h" #include "latexprocess.h" +#include "util.h" #include #include @@ -47,6 +48,7 @@ void Tikzit::init() QSettings settings("tikzit", "tikzit"); initColors(); + initTexConstants(); _mainMenu = new MainMenu(); QMainWindow *dummy = new QMainWindow(); diff --git a/src/util.cpp b/src/util.cpp index 304f9e7..b9c87b2 100644 --- a/src/util.cpp +++ b/src/util.cpp @@ -21,7 +21,7 @@ qreal bezierInterpolate(qreal dist, qreal c0, qreal c1, qreal c2, qreal c3) { qreal distp = 1 - dist; - return (distp*distp*distp) * c0 + + return (distp*distp*distp) * c0 + 3 * (distp*distp) * dist * c1 + 3 * (dist*dist) * distp * c2 + (dist*dist*dist) * c3; @@ -80,3 +80,121 @@ QString floatToString(qreal f) { else return QString::number(f); } + +static QList texConstantNames; +static QList texConstantCodes; +static QList texModifierNames; + + +void initTexConstants() { + texConstantNames + << "\\alpha" + << "\\beta" + << "\\gamma" + << "\\delta" + << "\\epsilon" + << "\\zeta" + << "\\eta" + << "\\theta" + << "\\iota" + << "\\kappa" + << "\\lambda" + << "\\mu" + << "\\nu" + << "\\xi" + << "\\pi" + << "\\rho" + << "\\sigma" + << "\\tau" + << "\\upsilon" + << "\\phi" + << "\\chi" + << "\\psi" + << "\\omega" + << "\\Gamma" + << "\\Delta" + << "\\Theta" + << "\\Lambda" + << "\\Xi" + << "\\Pi" + << "\\Sigma" + << "\\Upsilon" + << "\\Phi" + << "\\Psi" + << "\\Omega" + << "\\pm" + << "\\to" + << "\\Rightarrow" + << "\\Leftrightarrow" + << "\\forall" + << "\\partial" + << "\\exists" + << "\\emptyset" + << "\\nabla" + << "\\in" + << "\\notin" + << "\\prod" + << "\\sum" + << "\\surd" + << "\\infty" + << "\\wedge" + << "\\vee" + << "\\cap" + << "\\cup" + << "\\int" + << "\\approx" + << "\\neq" + << "\\equiv" + << "\\leq" + << "\\geq" + << "\\subset" + << "\\supset" + << "\\cdot" + << "\\ldots"; + + texConstantCodes << + "\u03b1" << "\u03b2" << "\u03b3" << "\u03b4" << "\u03b5" << "\u03b6" << "\u03b7" << + "\u03b8" << "\u03b9" << "\u03ba" << "\u03bb" << "\u03bc" << "\u03bd" << "\u03be" << + "\u03c0" << "\u03c1" << "\u03c3" << "\u03c4" << "\u03c5" << "\u03c6" << "\u03c7" << + "\u03c8" << "\u03c9" << "\u0393" << "\u0394" << "\u0398" << "\u039b" << "\u039e" << + "\u03a0" << "\u03a3" << "\u03a5" << "\u03a6" << "\u03a8" << "\u03a9" << + + "\u00b1" << "\u2192" << "\u21d2" << "\u21d4" << "\u2200" << "\u2202" << "\u2203" << + "\u2205" << "\u2207" << "\u2208" << "\u2209" << "\u220f" << "\u2211" << "\u221a" << + "\u221e" << "\u2227" << "\u2228" << "\u2229" << "\u222a" << "\u222b" << "\u2248" << + "\u2260" << "\u2261" << "\u2264" << "\u2265" << "\u2282" << "\u2283" << "\u22c5" << + "\u2026"; + + texModifierNames + << "\\tiny" + << "\\scriptsize" + << "\\footnotesize" + << "\\small" + << "\\normalsize" + << "\\large" + << "\\Large" + << "\\LARGE" + << "\\huge" + << "\\Huge"; +} + +QString replaceTexConstants(QString s) { + QString s1 = s; + for (int i = 0; i < texConstantNames.length(); ++i) { + s1 = s1.replace(texConstantNames[i], texConstantCodes[i]); + } + + for (int i = 0; i < texModifierNames.length(); ++i) { + s1 = s1.replace(texModifierNames[i], ""); + } + + if (s1.startsWith('$') && s1.endsWith('$')) { + s1 = s1.mid(1, s1.length()-2); + } + + return s1; +} + + + + diff --git a/src/util.h b/src/util.h index 5d1073a..3ddaf17 100644 --- a/src/util.h +++ b/src/util.h @@ -48,4 +48,8 @@ qreal degreesToRadians(qreal degrees); int normaliseAngleDeg (int degrees); qreal normaliseAngleRad (qreal rads); +// strings +void initTexConstants(); +QString replaceTexConstants(QString s); + #endif // UTIL_H -- cgit v1.2.3 From 3a4a7e8b5e34e101a4ba7468fcd09d88977ca25c Mon Sep 17 00:00:00 2001 From: Aleks Kissinger Date: Fri, 1 Feb 2019 08:43:19 +0100 Subject: recognise more tex symbols --- src/util.cpp | 114 ++++++++++++++++++++--------------------------------------- 1 file changed, 39 insertions(+), 75 deletions(-) diff --git a/src/util.cpp b/src/util.cpp index b9c87b2..75cfa76 100644 --- a/src/util.cpp +++ b/src/util.cpp @@ -88,82 +88,46 @@ static QList texModifierNames; void initTexConstants() { texConstantNames - << "\\alpha" - << "\\beta" - << "\\gamma" - << "\\delta" - << "\\epsilon" - << "\\zeta" - << "\\eta" - << "\\theta" - << "\\iota" - << "\\kappa" - << "\\lambda" - << "\\mu" - << "\\nu" - << "\\xi" - << "\\pi" - << "\\rho" - << "\\sigma" - << "\\tau" - << "\\upsilon" - << "\\phi" - << "\\chi" - << "\\psi" - << "\\omega" - << "\\Gamma" - << "\\Delta" - << "\\Theta" - << "\\Lambda" - << "\\Xi" - << "\\Pi" - << "\\Sigma" - << "\\Upsilon" - << "\\Phi" - << "\\Psi" + << "\\alpha" << "\\beta" << "\\gamma" << "\\delta" << "\\epsilon" + << "\\zeta" << "\\eta" << "\\theta" << "\\iota" << "\\kappa" + << "\\lambda" << "\\mu" << "\\nu" << "\\xi" << "\\pi" + << "\\rho" << "\\sigma" << "\\tau" << "\\upsilon" << "\\phi" + << "\\chi" << "\\psi" << "\\omega" + + << "\\Gamma" << "\\Delta" << "\\Theta" << "\\Lambda" << "\\Xi" + << "\\Pi" << "\\Sigma" << "\\Upsilon" << "\\Phi" << "\\Psi" << "\\Omega" - << "\\pm" - << "\\to" - << "\\Rightarrow" - << "\\Leftrightarrow" - << "\\forall" - << "\\partial" - << "\\exists" - << "\\emptyset" - << "\\nabla" - << "\\in" - << "\\notin" - << "\\prod" - << "\\sum" - << "\\surd" - << "\\infty" - << "\\wedge" - << "\\vee" - << "\\cap" - << "\\cup" - << "\\int" - << "\\approx" - << "\\neq" - << "\\equiv" - << "\\leq" - << "\\geq" - << "\\subset" - << "\\supset" - << "\\cdot" - << "\\ldots"; - - texConstantCodes << - "\u03b1" << "\u03b2" << "\u03b3" << "\u03b4" << "\u03b5" << "\u03b6" << "\u03b7" << - "\u03b8" << "\u03b9" << "\u03ba" << "\u03bb" << "\u03bc" << "\u03bd" << "\u03be" << - "\u03c0" << "\u03c1" << "\u03c3" << "\u03c4" << "\u03c5" << "\u03c6" << "\u03c7" << - "\u03c8" << "\u03c9" << "\u0393" << "\u0394" << "\u0398" << "\u039b" << "\u039e" << - "\u03a0" << "\u03a3" << "\u03a5" << "\u03a6" << "\u03a8" << "\u03a9" << - - "\u00b1" << "\u2192" << "\u21d2" << "\u21d4" << "\u2200" << "\u2202" << "\u2203" << - "\u2205" << "\u2207" << "\u2208" << "\u2209" << "\u220f" << "\u2211" << "\u221a" << - "\u221e" << "\u2227" << "\u2228" << "\u2229" << "\u222a" << "\u222b" << "\u2248" << - "\u2260" << "\u2261" << "\u2264" << "\u2265" << "\u2282" << "\u2283" << "\u22c5" << - "\u2026"; + + << "\\pm" << "\\to" << "\\Rightarrow" << "\\Leftrightarrow" << "\\forall" + << "\\partial" << "\\exists" << "\\emptyset" << "\\nabla" << "\\in" + << "\\notin" << "\\prod" << "\\sum" << "\\surd" << "\\infty" + << "\\wedge" << "\\vee" << "\\cap" << "\\cup" << "\\int" + << "\\approx" << "\\neq" << "\\equiv" << "\\leq" << "\\geq" + << "\\subset" << "\\supset" + + << "\\ldots" << "\\vdots" << "\\cdots" << "\\ddots" << "\\iddots" + << "\\cdot"; + + texConstantCodes + << "\u03b1" << "\u03b2" << "\u03b3" << "\u03b4" << "\u03b5" + << "\u03b6" << "\u03b7" << "\u03b8" << "\u03b9" << "\u03ba" + << "\u03bb" << "\u03bc" << "\u03bd" << "\u03be" << "\u03c0" + << "\u03c1" << "\u03c3" << "\u03c4" << "\u03c5" << "\u03c6" + << "\u03c7" << "\u03c8" << "\u03c9" + + << "\u0393" << "\u0394" << "\u0398" << "\u039b" << "\u039e" + << "\u03a0" << "\u03a3" << "\u03a5" << "\u03a6" << "\u03a8" + << "\u03a9" + + << "\u00b1" << "\u2192" << "\u21d2" << "\u21d4" << "\u2200" + << "\u2202" << "\u2203" << "\u2205" << "\u2207" << "\u2208" + << "\u2209" << "\u220f" << "\u2211" << "\u221a" << "\u221e" + << "\u2227" << "\u2228" << "\u2229" << "\u222a" << "\u222b" + << "\u2248" << "\u2260" << "\u2261" << "\u2264" << "\u2265" + << "\u2282" << "\u2283" + + << "\u2026" << "\u22ee" << "\u22ef" << "\u22f1" << "\u22f0" + << "\u22c5"; texModifierNames << "\\tiny" -- cgit v1.2.3