Doxygen
Loading...
Searching...
No Matches
formula.h
Go to the documentation of this file.
1/******************************************************************************
2 *
3 * Copyright (C) 1997-2022 by Dimitri van Heesch.
4 *
5 * Permission to use, copy, modify, and distribute this software and its
6 * documentation under the terms of the GNU General Public License is hereby
7 * granted. No representations are made about the suitability of this software
8 * for any purpose. It is provided "as is" without express or implied warranty.
9 * See the GNU General Public License for more details.
10 *
11 * Documents produced by Doxygen are derivative works derived from the
12 * input used in their production; they are not affected by this license.
13 *
14 */
15
16#ifndef FORMULA_H
17#define FORMULA_H
18
19#include <memory>
20#include <string>
21
22#include "qcstring.h"
23#include "containers.h"
24
25class Dir;
26
27/** Class representing a LaTeX formula as found in the documentation */
29{
30 public:
31 Formula(const QCString &text,int id,int width=-1,int height=-1)
33
34 int width() const { return m_width; }
35 int height() const { return m_height; }
36 int id() const { return m_id; }
37 QCString text() const { return m_text; }
38 bool isCached() const { return m_cached && !m_forceRegen; }
39 bool isCachedDark() const { return m_cached && !m_forceRegen; }
40 void setWidth(int width) { m_width = width; }
42
43 private:
44 friend class FormulaManager;
45 void setCached(bool cached) { m_cached = cached; m_forceRegen = m_forceRegen || !cached; }
46 void setCachedDark(bool cached) { m_cachedDark = cached; m_forceRegen = m_forceRegen || !cached; }
47
49 int m_id;
52 bool m_cached = false;
53 bool m_cachedDark = false; // dark version cached?
54 bool m_forceRegen = false; // true if there is an inconsistency in setCache calls
55};
56
57/*! Manager class to handle formulas */
59{
60 public:
61 static FormulaManager &instance();
62
63 //! @name repository functions
64 //! @{
65 void initFromRepository(const QCString &dir);
66 void checkRepositories();
67 //! @}
68
69 //! @name formula functions
70 //! @{
71 void clear();
72 int addFormula(const std::string &formulaText,int width=-1,int height=-1);
73 const Formula *findFormula(int formulaId) const;
74 bool hasFormulas() const;
75 //! @}
76
77 //! @name generator functions
78 //! @{
79 enum class Format { Bitmap, Vector };
80 enum class HighDPI { On, Off };
81 enum class Mode { Dark, Light };
82 void generateImages(const QCString &outputDir,Format format,HighDPI hd = HighDPI::Off);
83 //! @}
84
85 private:
86 void createFormulasTexFile(Dir &d,Format format,HighDPI hd,Mode mode);
87 void createLatexFile(const QCString &fileName,Format format,Mode mode,IntVector &formulasToGenerate);
89 struct Private;
90 std::unique_ptr<Private> p;
91};
92
93#endif
Class representing a directory in the file system.
Definition dir.h:75
Class representing a LaTeX formula as found in the documentation.
Definition formula.h:29
bool isCachedDark() const
Definition formula.h:39
bool m_cached
Definition formula.h:52
int width() const
Definition formula.h:34
bool isCached() const
Definition formula.h:38
void setCachedDark(bool cached)
Definition formula.h:46
int m_height
Definition formula.h:51
QCString text() const
Definition formula.h:37
int m_width
Definition formula.h:50
bool m_cachedDark
Definition formula.h:53
friend class FormulaManager
Definition formula.h:44
QCString m_text
Definition formula.h:48
void setHeight(int height)
Definition formula.h:41
void setCached(bool cached)
Definition formula.h:45
int height() const
Definition formula.h:35
Formula(const QCString &text, int id, int width=-1, int height=-1)
Definition formula.h:31
void setWidth(int width)
Definition formula.h:40
bool m_forceRegen
Definition formula.h:54
int id() const
Definition formula.h:36
int m_id
Definition formula.h:49
void createLatexFile(const QCString &fileName, Format format, Mode mode, IntVector &formulasToGenerate)
Definition formula.cpp:184
void initFromRepository(const QCString &dir)
Definition formula.cpp:60
int addFormula(const std::string &formulaText, int width=-1, int height=-1)
Definition formula.cpp:691
bool hasFormulas() const
Definition formula.cpp:720
void checkRepositories()
Definition formula.cpp:173
const Formula * findFormula(int formulaId) const
Definition formula.cpp:705
void createFormulasTexFile(Dir &d, Format format, HighDPI hd, Mode mode)
Definition formula.cpp:553
static FormulaManager & instance()
Definition formula.cpp:54
std::unique_ptr< Private > p
Definition formula.h:90
void generateImages(const QCString &outputDir, Format format, HighDPI hd=HighDPI::Off)
Definition formula.cpp:636
This is an alternative implementation of QCString.
Definition qcstring.h:101
std::vector< int > IntVector
Definition containers.h:38
@ Private
Definition types.h:26