vprerex-6.5.1/0000755000076400007640000000000013207261475011401 5ustar rdtrdtvprerex-6.5.1/window.h0000644000076400007640000000430313207037261013053 0ustar rdtrdt /**************************************************************************** ** Adapted from PDFviewer, originally published in the QT Quarterly: ** http://doc.trolltech.com/qq/QtQuarterly27.pdf ** Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies). ** Contact: Qt Software Information (qt-info@nokia.com) ** ** Modified for use with prerex: ** http://www.ctan.org/tex-archive/graphics/prerex ** Copyright (C) 2009-14 R. D. Tennent ** School of Computing, Queen's University, rdt@cs.queensu.ca ** This program is free software; you can redistribute it and/or modify it ** under the terms of the GNU General Public License as published by the ** Free Software Foundation; either version 2 of the License, or (at your ** option) any later version. ** ** This program is distributed in the hope that it will be useful, ** but WITHOUT ANY WARRANTY; without even the implied warranty of ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General ** Public License for more details. ** ** You should have received a copy of the GNU General Public License along ** with this program; if not, write to the Free Software Foundation, Inc., ** 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. ** ****************************************************************************/ #ifndef WINDOW_H #define WINDOW_H # include # include "documentwidget.h" # include # include "ui_window.h" # include # include # include const char version[] = "6.5.1"; class QTextBrowser; class Window : public QMainWindow, public Ui_MainWindow { Q_OBJECT public: Window(QWidget *parent = 0); QFileSystemWatcher *fsw; QStatusBar *sb; void setFileNames(QString BaseFileName, QString ChartFileName); void loadDocument(void); void open(); private slots: void scaleDocument(int index); void reloadMessage(); void pathMessage(); void quit(); private: DocumentWidget *documentWidget; QString fileName; QFileInfo fileInfo; QString chartFileName; QFileInfo chartFileInfo; QString pdfFilePath; QVector scaleFactors; QLabel *versionWidget; QProcess *process; }; #endif vprerex-6.5.1/README0000644000076400007640000000201313206532355012252 0ustar rdtrdtvprerex (visual prerex) is a GUI front-end and viewer for the prerex interactive editor of prerequisite-chart descriptions in the prerex format. The viewer may be used just as a minimalist viewer of arbitrary PDF files but supports editing of charts generated using prerex.sty by allowing coordinates of course boxes, arrows, and background points to be conveyed back to the prerex editor command-line using the X11 clipboard. To install: + You must have first installed the qt-5 and poppler libraries, including the poppler-qt5 library. These may be available packaged for your platform or the sources can be obtained from: http://qt.nokia.com/downloads/downloads#qt-lib http://poppler.freedesktop.org/ + Edit vprerex.pro so INCLUDEPATH and LIBS point to the relevant directories. + qmake vprerex.pro (using the qt-4 qmake) + make + install the vprerex binary in a suitable directory such as $HOME/bin or /usr/local/bin. If vprerex is applied to a LaTeX file, it calls xterm and the prerex editor. vprerex-6.5.1/vprerex.10000644000076400007640000000566213206532525013163 0ustar rdtrdt.TH VPREREX 1 2017-11-26 "vprerex-6.5.1" "" .SH NAME .BR vprerex \- graphical front-end and viewer for the .BR prerex (1) prerequisite-chart editor .SH SYNOPSIS .BR vprerex .IR basefile [ .tex ] [ .IR chartfile [ .tex ] ] .PP .BR vprerex .IR file.pdf .PP .BR vprerex .SH DESCRIPTION .B vprerex (visual prerex) is a GUI front-end and viewer for the .BR prerex (1) interactive editor of prerequisite-chart descriptions in the .BR prerex (5) format. The viewer may be used just as a minimalist viewer of arbitrary PDF files but supports editing of charts generated using .BR prerex.sty (7) by allowing coordinates of course boxes, arrows, and background points to be conveyed back to the .BR prerex (1) command-line using the clipboard. .SH USAGE If .B vprerex is invoked on a PDF file, it simply displays that file. .PP If the (first) argument does .I not have the .pdf suffix, it is assumed to be the base file for an existing LaTeX document containing a prerequisite-chart description in .BR prerex (5) format, to be edited using .BR prerex (1). If a .I second argument is supplied, it is regarded as an included file containing the specific chart environment to be edited. .PP If .I no arguments are supplied, a file-opening dialog allows the user the specify the .BR prerex (1) base file to be edited (or the PDF file to be viewed). A second file-opening dialog allows a chart file to be specified. .PP To create an initial "empty" chart, cancel the file-opening dialogue, select a working directory, and enter a file name. .PP If the mouse hovers over a hyperlink in the PDF viewing window, the cursor shape will change to a pointing finger and a tooltip will display the URI. If the PDF file displayed contains a chart generated using .BR prerex.sty (7) and the background coordinate grid has been enabled, left-clicking the mouse on a course box, arrow mid-point, or background point will load the relevant coordinates into the clipboard; right-clicking the mouse on a course box or arrow will .I append the relevant coordinates to the clipboard. The cursor shape changes to a plus-sign to indicate successful capture of the coordinates. Middle-clicking (or, in a Windows shell with "Quick Edit" mode enabled, right-clicking) the mouse at the .BR prerex (1) command-line will then paste those coordinates into a command being composed. If the chart file is regenerated, the updated document will be re-loaded. .SH DEPENDENCIES .B vprerex-6.5 is based on the qt-5 and poppler libraries. It calls .BR xterm (1) and .BR prerex (1) for the editing window and uses .BR poppler-qt5 for rendering PDF files. If an X server isn't running or there is no xterm application, the prerex editor can be started separately. .SH AUTHOR R. D. Tennent (rdt@cs.queensu.ca), adapted from David Boddie's PDFviewer, described in the QT Quarterly: .B http://doc.trolltech.com/qq/QtQuarterly27.pdf. .SH SEE ALSO .BR prerex (1), .BR prerex (5), .BR prerex.sty (7), and .BR xterm (1). vprerex-6.5.1/vprerex.desktop0000644000076400007640000000027112421453543014463 0ustar rdtrdt[Desktop Entry] Name=Vprerex Comment=Edit Prerequisite Charts Exec=vprerex Icon=vprerex MimeType=application/pdf;application/x-tex Terminal=false Type=Application Categories=Graphics; vprerex-6.5.1/ChangeLog0000644000076400007640000000506313207261377013160 0ustar rdtrdtVersion 6.5.1 2017-11-26 - modified for qt5 and poppler-qt5 Version 6.4.4 2014-10-21 - added a file-opening dialog to specify a chart file - allow for creation of a new "null" prerex file Version 6.4.3 2014-10-17 - check that the xterm has started - set xterm font size to 10pt Version 6.4.2 2012-05-30 - allow for Windows (rather than X11) clipboard function Version 6.4.1 2012-05-25 - restore FileSystemWatch path after reloading pdf (needed for Windows) Version 6.4.0 2012-04-13 - references to undeclared sleep() replaced by references to QThread::sleep() (debian bug 667331). Version 6.3.2 2012-03-30 - bump up version number to match prerex.sty and prerex Version 6.3.1 2011-12-22 If a file opening dialogue is used and a tex file is opened, the Working Directory for the prerex process is set to the directory of the tex file. Version 6.3 2011-11-22 Right-clicking on a course box or arrow *appends* coordinates to the clipboard (to simplify multiple deletes/shifts). Version 6.2 2011-09-08 no longer embedding the prerex editing window because of continuing focus issues Version 6.1.1 2011-08-20 - using grabKeyboard to avoid keyboard-focus issues - bump up version number to match prerex.sty and prerex Version 6.0.1 2011-07-27 - modified FocusPolicy Version 6.0 2010-06-23 - files re-organized and distributed as a gzipped tarball Version 5.7 2010-04-06 - corrected coordinate calculations to use the image width/height rather than the widget width/height (and allow for image offsets) Version 5.6 2010-03-26 Version 5.5 2010-03-16 - re-named vprerex (visual prerex) - opens prerex source files by embedding a prerex command-line window - added Quit button to controls - removed docking features from the controls widget - removed resizing from the statusbar This is the first distributed version of vprerex; the version numbers are starting at 5.5 to be compatible with the current version of prerex. Derived from pdfviewer by - excising all UI widgets except the Page spinner and the Scale selector - adding URI tooltips and cursor-shape changes for links - assigning box, edge, and background-point coordinates to the X clipboard when the user clicks on a box, edge mid-point, or background point, resp. (for a prerex chart with the coordinate grid enabled) - adding a file watcher to re-load the PDF when the file changes - posting taskbar messages to identify the program version and the loaded file, and inform the user that the PDF has been re-loaded vprerex-6.5.1/COPYING0000644000076400007640000004312212421453543012432 0ustar rdtrdt GNU GENERAL PUBLIC LICENSE Version 2, June 1991 Copyright (C) 1989, 1991 Free Software Foundation, Inc. 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. Preamble The licenses for most software are designed to take away your freedom to share and change it. By contrast, the GNU General Public License is intended to guarantee your freedom to share and change free software--to make sure the software is free for all its users. This General Public License applies to most of the Free Software Foundation's software and to any other program whose authors commit to using it. (Some other Free Software Foundation software is covered by the GNU Library General Public License instead.) You can apply it to your programs, too. When we speak of free software, we are referring to freedom, not price. Our General Public Licenses are designed to make sure that you have the freedom to distribute copies of free software (and charge for this service if you wish), that you receive source code or can get it if you want it, that you can change the software or use pieces of it in new free programs; and that you know you can do these things. To protect your rights, we need to make restrictions that forbid anyone to deny you these rights or to ask you to surrender the rights. These restrictions translate to certain responsibilities for you if you distribute copies of the software, or if you modify it. For example, if you distribute copies of such a program, whether gratis or for a fee, you must give the recipients all the rights that you have. You must make sure that they, too, receive or can get the source code. And you must show them these terms so they know their rights. We protect your rights with two steps: (1) copyright the software, and (2) offer you this license which gives you legal permission to copy, distribute and/or modify the software. Also, for each author's protection and ours, we want to make certain that everyone understands that there is no warranty for this free software. If the software is modified by someone else and passed on, we want its recipients to know that what they have is not the original, so that any problems introduced by others will not reflect on the original authors' reputations. Finally, any free program is threatened constantly by software patents. We wish to avoid the danger that redistributors of a free program will individually obtain patent licenses, in effect making the program proprietary. To prevent this, we have made it clear that any patent must be licensed for everyone's free use or not licensed at all. The precise terms and conditions for copying, distribution and modification follow. GNU GENERAL PUBLIC LICENSE TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION 0. This License applies to any program or other work which contains a notice placed by the copyright holder saying it may be distributed under the terms of this General Public License. The "Program", below, refers to any such program or work, and a "work based on the Program" means either the Program or any derivative work under copyright law: that is to say, a work containing the Program or a portion of it, either verbatim or with modifications and/or translated into another language. (Hereinafter, translation is included without limitation in the term "modification".) Each licensee is addressed as "you". Activities other than copying, distribution and modification are not covered by this License; they are outside its scope. The act of running the Program is not restricted, and the output from the Program is covered only if its contents constitute a work based on the Program (independent of having been made by running the Program). Whether that is true depends on what the Program does. 1. You may copy and distribute verbatim copies of the Program's source code as you receive it, in any medium, provided that you conspicuously and appropriately publish on each copy an appropriate copyright notice and disclaimer of warranty; keep intact all the notices that refer to this License and to the absence of any warranty; and give any other recipients of the Program a copy of this License along with the Program. You may charge a fee for the physical act of transferring a copy, and you may at your option offer warranty protection in exchange for a fee. 2. You may modify your copy or copies of the Program or any portion of it, thus forming a work based on the Program, and copy and distribute such modifications or work under the terms of Section 1 above, provided that you also meet all of these conditions: a) You must cause the modified files to carry prominent notices stating that you changed the files and the date of any change. b) You must cause any work that you distribute or publish, that in whole or in part contains or is derived from the Program or any part thereof, to be licensed as a whole at no charge to all third parties under the terms of this License. c) If the modified program normally reads commands interactively when run, you must cause it, when started running for such interactive use in the most ordinary way, to print or display an announcement including an appropriate copyright notice and a notice that there is no warranty (or else, saying that you provide a warranty) and that users may redistribute the program under these conditions, and telling the user how to view a copy of this License. (Exception: if the Program itself is interactive but does not normally print such an announcement, your work based on the Program is not required to print an announcement.) These requirements apply to the modified work as a whole. If identifiable sections of that work are not derived from the Program, and can be reasonably considered independent and separate works in themselves, then this License, and its terms, do not apply to those sections when you distribute them as separate works. But when you distribute the same sections as part of a whole which is a work based on the Program, the distribution of the whole must be on the terms of this License, whose permissions for other licensees extend to the entire whole, and thus to each and every part regardless of who wrote it. Thus, it is not the intent of this section to claim rights or contest your rights to work written entirely by you; rather, the intent is to exercise the right to control the distribution of derivative or collective works based on the Program. In addition, mere aggregation of another work not based on the Program with the Program (or with a work based on the Program) on a volume of a storage or distribution medium does not bring the other work under the scope of this License. 3. You may copy and distribute the Program (or a work based on it, under Section 2) in object code or executable form under the terms of Sections 1 and 2 above provided that you also do one of the following: a) Accompany it with the complete corresponding machine-readable source code, which must be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange; or, b) Accompany it with a written offer, valid for at least three years, to give any third party, for a charge no more than your cost of physically performing source distribution, a complete machine-readable copy of the corresponding source code, to be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange; or, c) Accompany it with the information you received as to the offer to distribute corresponding source code. (This alternative is allowed only for noncommercial distribution and only if you received the program in object code or executable form with such an offer, in accord with Subsection b above.) The source code for a work means the preferred form of the work for making modifications to it. For an executable work, complete source code means all the source code for all modules it contains, plus any associated interface definition files, plus the scripts used to control compilation and installation of the executable. However, as a special exception, the source code distributed need not include anything that is normally distributed (in either source or binary form) with the major components (compiler, kernel, and so on) of the operating system on which the executable runs, unless that component itself accompanies the executable. If distribution of executable or object code is made by offering access to copy from a designated place, then offering equivalent access to copy the source code from the same place counts as distribution of the source code, even though third parties are not compelled to copy the source along with the object code. 4. You may not copy, modify, sublicense, or distribute the Program except as expressly provided under this License. Any attempt otherwise to copy, modify, sublicense or distribute the Program is void, and will automatically terminate your rights under this License. However, parties who have received copies, or rights, from you under this License will not have their licenses terminated so long as such parties remain in full compliance. 5. You are not required to accept this License, since you have not signed it. However, nothing else grants you permission to modify or distribute the Program or its derivative works. These actions are prohibited by law if you do not accept this License. Therefore, by modifying or distributing the Program (or any work based on the Program), you indicate your acceptance of this License to do so, and all its terms and conditions for copying, distributing or modifying the Program or works based on it. 6. Each time you redistribute the Program (or any work based on the Program), the recipient automatically receives a license from the original licensor to copy, distribute or modify the Program subject to these terms and conditions. You may not impose any further restrictions on the recipients' exercise of the rights granted herein. You are not responsible for enforcing compliance by third parties to this License. 7. If, as a consequence of a court judgment or allegation of patent infringement or for any other reason (not limited to patent issues), conditions are imposed on you (whether by court order, agreement or otherwise) that contradict the conditions of this License, they do not excuse you from the conditions of this License. If you cannot distribute so as to satisfy simultaneously your obligations under this License and any other pertinent obligations, then as a consequence you may not distribute the Program at all. For example, if a patent license would not permit royalty-free redistribution of the Program by all those who receive copies directly or indirectly through you, then the only way you could satisfy both it and this License would be to refrain entirely from distribution of the Program. If any portion of this section is held invalid or unenforceable under any particular circumstance, the balance of the section is intended to apply and the section as a whole is intended to apply in other circumstances. It is not the purpose of this section to induce you to infringe any patents or other property right claims or to contest validity of any such claims; this section has the sole purpose of protecting the integrity of the free software distribution system, which is implemented by public license practices. Many people have made generous contributions to the wide range of software distributed through that system in reliance on consistent application of that system; it is up to the author/donor to decide if he or she is willing to distribute software through any other system and a licensee cannot impose that choice. This section is intended to make thoroughly clear what is believed to be a consequence of the rest of this License. 8. If the distribution and/or use of the Program is restricted in certain countries either by patents or by copyrighted interfaces, the original copyright holder who places the Program under this License may add an explicit geographical distribution limitation excluding those countries, so that distribution is permitted only in or among countries not thus excluded. In such case, this License incorporates the limitation as if written in the body of this License. 9. The Free Software Foundation may publish revised and/or new versions of the General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns. Each version is given a distinguishing version number. If the Program specifies a version number of this License which applies to it and "any later version", you have the option of following the terms and conditions either of that version or of any later version published by the Free Software Foundation. If the Program does not specify a version number of this License, you may choose any version ever published by the Free Software Foundation. 10. If you wish to incorporate parts of the Program into other free programs whose distribution conditions are different, write to the author to ask for permission. For software which is copyrighted by the Free Software Foundation, write to the Free Software Foundation; we sometimes make exceptions for this. Our decision will be guided by the two goals of preserving the free status of all derivatives of our free software and of promoting the sharing and reuse of software generally. NO WARRANTY 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. END OF TERMS AND CONDITIONS How to Apply These Terms to Your New Programs If you develop a new program, and you want it to be of the greatest possible use to the public, the best way to achieve this is to make it free software which everyone can redistribute and change under these terms. To do so, attach the following notices to the program. It is safest to attach them to the start of each source file to most effectively convey the exclusion of warranty; and each file should have at least the "copyright" line and a pointer to where the full notice is found. Copyright (C) This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA Also add information on how to contact you by electronic and paper mail. If the program is interactive, make it output a short notice like this when it starts in an interactive mode: Gnomovision version 69, Copyright (C) year name of author Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. This is free software, and you are welcome to redistribute it under certain conditions; type `show c' for details. The hypothetical commands `show w' and `show c' should show the appropriate parts of the General Public License. Of course, the commands you use may be called something other than `show w' and `show c'; they could even be mouse-clicks or menu items--whatever suits your program. You should also get your employer (if you work as a programmer) or your school, if any, to sign a "copyright disclaimer" for the program, if necessary. Here is a sample; alter the names: Yoyodyne, Inc., hereby disclaims all copyright interest in the program `Gnomovision' (which makes passes at compilers) written by James Hacker. , 1 April 1989 Ty Coon, President of Vice This General Public License does not permit incorporating your program into proprietary programs. If your program is a subroutine library, you may consider it more useful to permit linking proprietary applications with the library. If this is what you want to do, use the GNU Library General Public License instead of this License. vprerex-6.5.1/documentwidget.h0000644000076400007640000000471113206441247014573 0ustar rdtrdt /**************************************************************************** ** Adapted from PDFviewer, originally published in the QT Quarterly: ** http://doc.trolltech.com/qq/QtQuarterly27.pdf ** Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies). ** Contact: Qt Software Information (qt-info@nokia.com) ** ** Modified for use with prerex: ** http://www.ctan.org/tex-archive/graphics/prerex ** Copyright (C) 2009-12 R. D. Tennent ** School of Computing, Queen's University, rdt@cs.queensu.ca ** This program is free software; you can redistribute it and/or modify it ** under the terms of the GNU General Public License as published by the ** Free Software Foundation; either version 2 of the License, or (at your ** option) any later version. ** ** This program is distributed in the hope that it will be useful, ** but WITHOUT ANY WARRANTY; without even the implied warranty of ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General ** Public License for more details. ** ** You should have received a copy of the GNU General Public License along ** with this program; if not, write to the Free Software Foundation, Inc., ** 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. ** ****************************************************************************/ #ifndef DOCUMENTWIDGET_H #define DOCUMENTWIDGET_H #include #include #include #include #include #include #include class DocumentWidget : public QLabel { Q_OBJECT public: DocumentWidget(QWidget *parent = 0); ~DocumentWidget(); Poppler::Document *document(); QMatrix matrix() const; qreal scale() const; bool setDocument(const QString &filePath); public slots: void reloadDocument1(); void reloadDocument2(); void setPage(int page = -1); void setScale(qreal scale); protected: void mousePressEvent(QMouseEvent *event); void mouseMoveEvent(QMouseEvent *event); void mouseReleaseEvent(QMouseEvent *event); signals: void pageChanged(int currentPage); void documentReloaded(); private: void showPage(int page = -1); Poppler::Document *doc; int currentPage; qreal scaleFactor; QList pageLinks; bool mousePressed; QClipboard *cb; QString currentPath; QTimer *timer ; QFileInfo *fileInfo; int imageWidth; int imageHeight; int imageXoffset; int imageYoffset; }; #endif vprerex-6.5.1/window.cpp0000644000076400007640000001704113207047056013414 0ustar rdtrdt /**************************************************************************** ** Adapted from PDFviewer, originally published in the QT Quarterly: ** http://doc.trolltech.com/qq/QtQuarterly27.pdf ** Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies). ** Contact: Qt Software Information (qt-info@nokia.com) ** ** Modified for use with prerex: ** http://www.ctan.org/tex-archive/graphics/prerex ** Copyright (C) 2009-14 R. D. Tennent ** School of Computing, Queen's University, rdt@cs.queensu.ca ** This program is free software; you can redistribute it and/or modify it ** under the terms of the GNU General Public License as published by the ** Free Software Foundation; either version 2 of the License, or (at your ** option) any later version. ** ** This program is distributed in the hope that it will be useful, ** but WITHOUT ANY WARRANTY; without even the implied warranty of ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General ** Public License for more details. ** ** You should have received a copy of the GNU General Public License along ** with this program; if not, write to the Free Software Foundation, Inc., ** 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. ** ****************************************************************************/ #include #include "window.h" # include # include # include # include #include QString x_terminal_emulator = "xterm" ; class mythread : public QThread { public: static void sleep(unsigned long secs) { QThread::sleep(secs); } }; Window::Window(QWidget *parent) : QMainWindow(parent) { setupUi(this); scaleFactors << 1. << 1.1 << 1.25 << 1.75 << 2.5 << 4.; documentWidget = new DocumentWidget(); scrollAreaWidget->setWidget(documentWidget); fsw = new QFileSystemWatcher(); sb = statusBar(); versionWidget = new QLabel(QString("This is vprerex, v.%1 ").arg(version), this); sb->addPermanentWidget(versionWidget); connect(documentControlsAction, SIGNAL(toggled(bool)), controlsDockWidget, SLOT(setVisible(bool))); connect(pageSpinBox, SIGNAL(valueChanged(int)), documentWidget, SLOT(setPage(int))); connect(documentWidget, SIGNAL(pageChanged(int)), pageSpinBox, SLOT(setValue(int))); connect(scaleComboBox, SIGNAL(currentIndexChanged(int)), this, SLOT(scaleDocument(int))); connect(fsw, SIGNAL(fileChanged(QString)), documentWidget, SLOT(reloadDocument1())); connect(documentWidget, SIGNAL(documentReloaded()), this, SLOT(reloadMessage())); connect(quitButton, SIGNAL(clicked()), this, SLOT(quit())); } void Window::setFileNames(QString FileName, QString ChartFileName ) { fileName.append(FileName); fileInfo.setFile(FileName); chartFileName.append(ChartFileName); chartFileInfo.setFile(ChartFileName); loadDocument(); } void Window::open() { QString fullFileName; QString fullChartFileName; fullFileName.append(QDir::cleanPath(QFileDialog::getOpenFileName(this, "Select a prerex file to edit or a pdf file to view (or Cancel).", QString(), "Prerex source files (*.tex);;Portable Document Format files (*.pdf)"))); if (fullFileName.length() == 0) { // file selection cancelled bool ok; QFile file("tmp.tex"); while (1) { fullFileName.append(QDir::cleanPath(QFileDialog::getExistingDirectory(this, "Select a working directory."))); if ( fullFileName.length() == 0 ) { QMessageBox::critical(this, "vprerex", "Directory selection failed."); close(); exit(1); } fullFileName.append("/"); fullFileName.append(QInputDialog::getText(this, "Creating a new prerex file", "Input file name:", QLineEdit::Normal, "mychart.tex" , &ok)); if (!ok) { QMessageBox::critical(this, "vprerex", "File name input failed."); close(); exit(1); } if (!fullFileName.endsWith(".tex")) fullFileName.append(".tex"); file.setFileName(fullFileName); if (!file.exists()) break; if ( QMessageBox::question(this, "vprerex", "File exists; Ok to overwrite?", QMessageBox::Ok | QMessageBox::No, QMessageBox::Ok) == QMessageBox::Ok) break; fullFileName.clear(); } if (!file.open(QIODevice::WriteOnly | QIODevice::Text)) { QMessageBox::critical(this, "vprerex", "File opening failed."); close(); exit(1); } QTextStream out(&file); out << "\\documentclass{article}\n" << "\\usepackage{geometry}\n" << "\\geometry{noheadfoot, margin=0.5in}\n" << "\\usepackage{prerex}\n" << "\\begin{document}\n" << "\\thispagestyle{empty}\n" << "\\begin{chart}\n" << "\\end{chart}\n" << "\\end{document}\n"; file.close(); fileInfo.setFile(fullFileName); fileName.append(fileInfo.baseName()); fileName.append("."); fileName.append(fileInfo.suffix()); } else { fileInfo.setFile(fullFileName); fileName.append(fileInfo.baseName()); fileName.append("."); fileName.append(fileInfo.suffix()); fullChartFileName.append(QDir::cleanPath(QFileDialog::getOpenFileName(this, "Select a chart file (or Cancel).", fileInfo.absolutePath(), "Prerex chart files (*.tex)"))); if (fullChartFileName.length() > 0) { chartFileInfo.setFile(fullChartFileName); chartFileName.append(chartFileInfo.baseName()); chartFileName.append("."); chartFileName.append(chartFileInfo.suffix()); } } loadDocument(); } void Window::loadDocument(void) { pdfFilePath.append(fileInfo.dir().path()); pdfFilePath.append("/"); pdfFilePath.append(fileInfo.baseName()); pdfFilePath.append(".pdf"); if ( fileName.endsWith(".tex") ) { QStringList arguments; arguments // for xterm << "-geometry" << "100x60" << "-fa" << "Monospace" << "-fs" << "10" << "-e" << "prerex"; arguments.append(fileName); if ( chartFileName.length() > 0 ) arguments.append(chartFileName); process = new QProcess(centralwidget); process->setWorkingDirectory(fileInfo.dir().path()); process->start(x_terminal_emulator, arguments); if (!process->waitForStarted()) { QMessageBox::critical(this, "vprerex", "x-terminal call failed."); close(); exit(1); } } QFileInfo pdfFileInfo; pdfFileInfo.setFile(pdfFilePath); while ( pdfFileInfo.size() == 0 ) { // wait for the PDF file mythread::sleep (1); pdfFileInfo.refresh(); } mythread::sleep (1); sb->showMessage(pdfFilePath); fsw->addPath(pdfFilePath); while ( !(documentWidget->setDocument(pdfFilePath)) ) { // if at first you don't succeed, try, try again mythread::sleep (1); } scaleComboBox->setEnabled(true); pageSpinBox->setEnabled(true); pageSpinBox->setMinimum(1); pageSpinBox->setMaximum(documentWidget->document()->numPages()); pageSpinBox->setValue(1); } void Window::reloadMessage(void) { sb->showMessage(pdfFilePath + " reloaded.", 2000); QTimer::singleShot(2000, this, SLOT(pathMessage())); // On Windows, pdflatex removes the existing pdf file initially and // this removes the file path from the file-system watcher; the // following restores the path to the file-watch list if necessary: if (!fsw->files().contains(pdfFilePath)) fsw->addPath(pdfFilePath); } void Window::pathMessage(void) { sb->showMessage(pdfFilePath); } void Window::scaleDocument(int index) { documentWidget->setScale(scaleFactors[index]); } void Window::quit(void) { close(); } vprerex-6.5.1/INSTALL0000644000076400007640000000113613206532300012416 0ustar rdtrdtTo install: + You must have first installed the qt-5 and poppler libraries, including the poppler-qt5 library. These may be available packaged for your platform or the sources can be obtained from: http://qt.nokia.com/downloads/downloads#qt-lib http://poppler.freedesktop.org/ + Edit vprerex.pro so INCLUDEPATH and LIBS point to the relevant directories. + qmake vprerex.pro (using the qt-5 qmake) + make + install the vprerex binary in a suitable directory such as $HOME/bin or /usr/local/bin. If vprerex is applied to a LaTeX file, it calls xterm and the prerex editor. vprerex-6.5.1/vprerex.png0000644000076400007640000000266312421454325013604 0ustar rdtrdtPNG  IHDRBLV<gAMA a8tEXtSoftwareXV Version 3.10a Rev: 12/29/94 (PNG patch 1.2).IpIDATh횱OHƟ(LM$ H4եKvuC%t[p--ŖٖXɳ h؂"d l!E+aͅ6R쓟\$γ=7t: Qg# Wq2Z X6PjԞxv.n#ď0؄@HZ[IiCLi6ۀ=03 Bax,Dq*x58d@=Uol?ZO5ly3O2(1Rܪ7Ɩ;r~X#]ȓ(M)m|-0ao HӇ.CP'/ λ%Ir'gq>'ɥDm[Ir8I)5Mmu(=ٶnukXaTFQaTe  8Lpx_PW`qqgP_ìG-DVB(Z4ˑ40 3@o*VWW8uiNglAM3VcZFT>cO腸5ы׍^5rp}}j4k!}G*ӲZbaalۯ;aj0/tIME %9#tEXtCommentdate:create# %tEXtdate:create2012-08-22T14:10:54-04:00w4s%tEXtdate:modify2012-08-22T14:10:54-04:00tEXtpdf:VersionPDF-1.5 µBIENDB`vprerex-6.5.1/main.cpp0000644000076400007640000000571213207035623013030 0ustar rdtrdt/**************************************************************************** ** Adapted from PDFviewer, originally published in the QT Quarterly: ** http://doc.trolltech.com/qq/QtQuarterly27.pdf ** Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies). ** Contact: Qt Software Information (qt-info@nokia.com) ** ** Modified for use with prerex: ** http://www.ctan.org/tex-archive/graphics/prerex ** Copyright (C) 2009-14 R. D. Tennent ** School of Computing, Queen's University, rdt@cs.queensu.ca ** This program is free software; you can redistribute it and/or modify it ** under the terms of the GNU General Public License as published by the ** Free Software Foundation; either version 2 of the License, or (at your ** option) any later version. ** ** This program is distributed in the hope that it will be useful, ** but WITHOUT ANY WARRANTY; without even the implied warranty of ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General ** Public License for more details. ** ** You should have received a copy of the GNU General Public License along ** with this program; if not, write to the Free Software Foundation, Inc., ** 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. ** ****************************************************************************/ /* ** vprerex (visual prerex) is a GUI front-end and viewer for the prerex ** interactive editor of prerequisite-chart descriptions in the prerex ** format. The viewer may be used just as a minimalist viewer of ** arbitrary PDF files but supports editing of charts generated using ** prerex.sty by allowing coordinates of course boxes, arrows, and ** background points to be conveyed back to the prerex editor command-line ** using the clipboard. */ #include #include "window.h" #include using namespace std; int main(int argc, char *argv[]) { QApplication app(argc, argv); Window window; QStringList Argv = app.arguments(); printf ("This is vprerex, version %s.\n", version); puts ("Copyright (c) 2008 Nokia Corporation and/or its subsidiary(-ies)."); puts ("Qt Software Information (qt-info@nokia.com)"); puts ("Copyright (c) 2009-17 R. D. Tennent"); puts ("School of Computing, Queen's University, rdt@cs.queensu.ca"); puts ("This program comes with NO WARRANTY. You can redistribute vprerex and/or"); puts ("modify it under the terms of the GNU General Public License version 2."); puts (""); window.show(); if ( argc > 1 ) { QString fileName; QString chartFileName; fileName.append(Argv.at(1)); if (!fileName.endsWith(".tex") && !fileName.endsWith(".pdf")) fileName.append(".tex"); if ( argc > 2 ) { chartFileName.append(Argv.at(2)); if (!chartFileName.endsWith(".tex")) chartFileName.append(".tex"); } window.setFileNames(fileName, chartFileName); } else window.open(); return app.exec(); } vprerex-6.5.1/vprerex.pro0000644000076400007640000000071113206447221013607 0ustar rdtrdtFORMS = window.ui HEADERS = documentwidget.h \ window.h SOURCES = documentwidget.cpp \ main.cpp \ window.cpp QT += widgets # Modify these to refer to the directories on your system # that contain the poppler-qt5.h header file and [lib]poppler-qt5 library. INCLUDEPATH += /usr/include/poppler/qt5 /usr/include/qt5 /usr/include/qt5/QtWidgets LIBS += -L/usr/lib64 -lpoppler-qt5 vprerex-6.5.1/window.ui0000644000076400007640000001604512421453543013251 0ustar rdtrdt MainWindow 0 0 960 1000 vprerex Qt::LeftToRight QMainWindow::AllowNestedDocks|QMainWindow::AllowTabbedDocks|QMainWindow::AnimatedDocks|QMainWindow::ForceTabbedDocks 0 0 Qt::RightToLeft Qt::NoFocus Qt::LeftToRight true Qt::AlignCenter 0 0 946 906 Qt::NoFocus Qt::LeftToRight false true false QDockWidget::NoDockWidgetFeatures Qt::BottomDockWidgetArea|Qt::TopDockWidgetArea 4 4 0 4 0 Qt::NoFocus Quit Qt::Horizontal 40 20 &Page: pageSpinBox false Qt::NoFocus Qt::Horizontal 20 20 &Scale document: scaleComboBox false Qt::NoFocus 1 100% 110% 125% 175% 250% 400% Qt::Horizontal 20 20 &Open... Ctrl+O E&xit Ctrl+Q &Increase Scale Ctrl++ &Decrease Scale Ctrl+- true true &Document Controls vprerex-6.5.1/documentwidget.cpp0000644000076400007640000002225713206442606015133 0ustar rdtrdt /**************************************************************************** ** Adapted from PDFviewer, originally published in the QT Quarterly: ** http://doc.trolltech.com/qq/QtQuarterly27.pdf ** Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies). ** Contact: Qt Software Information (qt-info@nokia.com) ** ** Modified for use with prerex: ** http://www.ctan.org/tex-archive/graphics/prerex ** Copyright (C) 2009-14 R. D. Tennent ** School of Computing, Queen's University, rdt@cs.queensu.ca ** This program is free software; you can redistribute it and/or modify it ** under the terms of the GNU General Public License as published by the ** Free Software Foundation; either version 2 of the License, or (at your ** option) any later version. ** ** This program is distributed in the hope that it will be useful, ** but WITHOUT ANY WARRANTY; without even the implied warranty of ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General ** Public License for more details. ** ** You should have received a copy of the GNU General Public License along ** with this program; if not, write to the Free Software Foundation, Inc., ** 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. ** ****************************************************************************/ #include #include #include "documentwidget.h" DocumentWidget::DocumentWidget(QWidget *parent) : QLabel(parent) { currentPage = -1; doc = NULL; scaleFactor = 1.1; setCursor(Qt::ArrowCursor); setAlignment(Qt::AlignTop | Qt::AlignCenter); mousePressed = false; setMouseTracking(true); cb = QGuiApplication::clipboard(); timer = new QTimer(this); connect(timer, SIGNAL(timeout()), this, SLOT(reloadDocument2())); } DocumentWidget::~DocumentWidget() { delete doc; } Poppler::Document *DocumentWidget::document() { return doc; } void DocumentWidget::mousePressEvent(QMouseEvent *event) { Qt::MouseButton qtm = event->button(); if ( !(qtm == Qt::LeftButton || qtm == Qt::RightButton) ) return; int x1 = 0, y1 = 0, x2 = 0, y2 = 0; // pixel coordinates of anchors int xc1 = 0, yc1 = 0, xc2 = 0, yc2 = 0; // chart coordinates of anchors int n_anchors = 0; // number of anchors found imageXoffset = 0; imageYoffset = 0; // re-compute in case of window re-sizing if (imageWidth < width()) imageXoffset = (width() - imageWidth) / 2; if (imageHeight < height()) // possible after re-scaling despite AlignTop imageYoffset = (height() - imageHeight) / 2; int xmouse = event->pos().x() - imageXoffset; // mouse coordinates in pixels int ymouse = event->pos().y() - imageYoffset; QPointF mousePos // normalized position in [0..1] coordinates = QPointF((qreal)xmouse / (qreal)imageWidth, (qreal)ymouse / (qreal)imageHeight); // iterate through the Links: for (int i = 0; i < pageLinks.size(); ++i) { Poppler::LinkBrowse * link = static_cast(pageLinks[i]); if (link == NULL) continue; // not a Browse Link QString URI = link->url(); QRectF linkRect = pageLinks[i]->linkArea(); if ( linkRect.contains(mousePos) && URI.startsWith(QString("coord:")) ) { // clicked in a coord: x,y box or coord: x0,y0,x1,y1 bullet QString cbString; if ( qtm == Qt::RightButton ) { if (cb->supportsSelection()) cbString.append(cb->text(QClipboard::Selection)); else cbString.append(cb->text(QClipboard::Clipboard)); cbString.append(" "); } URI.remove("coord: "); cbString.append(URI); if (cb->supportsSelection()) cb->setText(cbString, QClipboard::Selection); else cb->setText(cbString, QClipboard::Clipboard); setCursor(Qt::CrossCursor); mousePressed = true; return; } if ( URI.startsWith(QString("anchor:")) ) { QPointF anchorCenter // in [0..1] coordinates = (pageLinks[i]->linkArea()).center(); URI.remove(0,7); // remove "anchor:" int comma = URI.indexOf(','); QString xs = URI.left(comma); // x-coordinate as a string QString ys = URI.remove(0, comma+1); // y-coordinate as a string if (n_anchors == 0) { xc1 = xs.toInt(); yc1 = ys.toInt(); x1 = (int)(imageWidth * anchorCenter.x()); y1 = (int)(imageHeight * anchorCenter.y()); n_anchors++; } else if (n_anchors == 1) { xc2 = xs.toInt(); yc2 = ys.toInt(); x2 = (int)(imageWidth * anchorCenter.x()); y2 = (int)(imageHeight * anchorCenter.y()); n_anchors++; } } } if (n_anchors == 0) return; // coordinate grid off? if (n_anchors == 1) { QMessageBox::warning (this, "vprerex", "Only found one anchor"); return; } // clicked on background grid; must be LeftButton click if ( qtm == Qt::RightButton ) return; // determine chart coordinates of the click point: int xc = (int)( 0.25L + (xc1 + xc2)/2.0L - ((x1 + x2)/2.0L - xmouse) * (qreal)(xc2 - xc1) / (x2 - x1) ); int yc = (int)( 0.75L + (yc1 + yc2)/2.0L - ((y1 + y2)/2.0L - ymouse) * (qreal)(yc2 - yc1) / (y2 - y1) ); if (cb->supportsSelection()) cb->setText(QString("%1,%2").arg(xc).arg(yc), QClipboard::Selection); else cb->setText(QString("%1,%2").arg(xc).arg(yc), QClipboard::Clipboard); mousePressed = true; setCursor(Qt::CrossCursor); } void DocumentWidget::mouseMoveEvent(QMouseEvent *event) { imageXoffset = 0; imageYoffset = 0; // re-compute in case of window re-sizing if (imageWidth < width()) imageXoffset = (width() - imageWidth) / 2; if (imageHeight < height()) // possible after re-scaling despite AlignTop imageYoffset = (height() - imageHeight) / 2; int xmouse = event->pos().x() - imageXoffset; // mouse coordinates in pixels int ymouse = event->pos().y() - imageYoffset; QPointF mousePos // normalized click position in [0..1] coordinates = QPointF((qreal)xmouse / (qreal)imageWidth, (qreal)ymouse / (qreal)imageHeight); // iterate through the Links: for (int i = 0; i < pageLinks.size(); ++i) { Poppler::LinkBrowse * link = static_cast(pageLinks[i]); if (link == NULL) continue; // not a Browse Link QString URI = link->url(); QRectF linkRect = pageLinks[i]->linkArea(); if ( linkRect.contains(mousePos) ) { if ( mousePressed ) return; setCursor(Qt::PointingHandCursor); setToolTip(URI); return; } } if (mousePressed) return; setCursor(Qt::ArrowCursor); } void DocumentWidget::mouseReleaseEvent(QMouseEvent *) { mousePressed = false; setCursor(Qt::ArrowCursor); } qreal DocumentWidget::scale() const { return scaleFactor; } void DocumentWidget::showPage(int page) { if (page != -1 && page != currentPage + 1) { currentPage = page - 1; emit pageChanged(page); } QImage image = doc->page(currentPage)->renderToImage(scaleFactor * physicalDpiX(), scaleFactor * physicalDpiY()); setPixmap(QPixmap::fromImage(image)); imageWidth = image.width(); imageHeight = image.height(); pageLinks = doc -> page(currentPage) -> links(); setCursor(Qt::ArrowCursor); } bool DocumentWidget::setDocument(const QString &filePath) { doc = Poppler::Document::load(filePath); if (doc == NULL) { // temporarily ill-formed pdf? wait for another reload signal return( false ); } currentPath = filePath; fileInfo = new QFileInfo(currentPath); doc->setRenderHint(Poppler::Document::Antialiasing); doc->setRenderHint(Poppler::Document::TextAntialiasing); currentPage = -1; setPage(1); return( true ); } void DocumentWidget::reloadDocument1(void) { fileInfo->refresh(); if (fileInfo->size() == 0) return; // pdflatex clears file.pdf timer->setSingleShot(true); timer->start(2000); // wait for the file to stabilize // When the timer timesout, it calls reloadDocument2 } void DocumentWidget::reloadDocument2(void) { Poppler::Document *savedoc; fileInfo->refresh(); if (fileInfo->size() == 0) return; // pdflatex clears file.pdf savedoc = doc; doc = Poppler::Document::load(currentPath); if (doc == NULL) { // temporarily ill-formed pdf? wait for another reload signal doc = savedoc; return; } delete savedoc; doc->setRenderHint(Poppler::Document::Antialiasing); doc->setRenderHint(Poppler::Document::TextAntialiasing); showPage(currentPage+1); documentReloaded(); } void DocumentWidget::setPage(int page) { if (page != currentPage + 1) { showPage(page); } } void DocumentWidget::setScale(qreal scale) { if (scaleFactor != scale) { scaleFactor = scale; showPage(-1); } }