wxMaxima
IntCell.h
Go to the documentation of this file.
1 // -*- mode: c++; c-file-style: "linux"; c-basic-offset: 2; indent-tabs-mode: nil -*-
2 //
3 // Copyright (C) 2004-2015 Andrej Vodopivec <andrej.vodopivec@gmail.com>
4 // Copyright (C) 2014-2016 Gunter Königsmann <wxMaxima@physikbuch.de>
5 //
6 // This program is free software; you can redistribute it and/or modify
7 // it under the terms of the GNU General Public License as published by
8 // the Free Software Foundation; either version 2 of the License, or
9 // (at your option) any later version.
10 //
11 // This program is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 // GNU General Public License for more details.
15 //
16 //
17 // You should have received a copy of the GNU General Public License
18 // along with this program; if not, write to the Free Software
19 // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
20 //
21 // SPDX-License-Identifier: GPL-2.0+
22 
29 #ifndef INTCELL_H
30 #define INTCELL_H
31 
32 #include "Cell.h"
33 
38 // cppcheck-suppress ctuOneDefinitionRuleViolation
39 class IntCell final : public Cell
40 {
41 public:
42  IntCell(GroupCell *group, Configuration *config,
43  std::unique_ptr<Cell> &&base, std::unique_ptr<Cell> &&lowerLimit,
44  std::unique_ptr<Cell> &&upperLimit, std::unique_ptr<Cell> &&var);
45  IntCell(GroupCell *group, Configuration *config,
46  std::unique_ptr<Cell> &&base, std::unique_ptr<Cell> &&var);
47  IntCell(GroupCell *group, const IntCell &cell);
48  std::unique_ptr<Cell> Copy(GroupCell *group) const override;
49  const CellTypeInfo &GetInfo() override;
50 
51  size_t GetInnerCellCount() const override { return 9; }
52  // cppcheck-suppress objectIndex
53  Cell *GetInnerCell(size_t index) const override { return (&m_open)[index].get(); }
54 
55  void Recalculate(AFontSize fontsize) override;
56 
57  void Draw(wxPoint point, wxDC *dc, wxDC *antialiassingDC) override;
58 
59  enum IntegralType : int8_t
60  {
62  INT_IDEF
63  };
64 
66  void SetIntStyle(IntegralType style) { m_intStyle = style; }
67 
68  wxString ToMathML() const override;
69  wxString ToMatlab() const override;
70  wxString ToOMML() const override;
71  wxString ToString() const override;
72  wxString ToTeX() const override;
73  wxString ToXML() const override;
74 
75  bool BreakUp() override;
76  void SetNextToDraw(Cell *next) override;
77 
79  bool HasLimits() const {return (m_intStyle == INT_DEF) &&
80  (m_upperLimit != NULL) && (m_lowerLimit != NULL); }
81 
82 private:
83  wxCoord IntSignLimitYoffset() const { return Scale_Px(8); }
84  void MakeBreakUpCells();
85  const static wxString m_svgIntegralSign;
86  // The pointers below point to inner cells and must be kept contiguous.
87  // ** This is the draw list order. All pointers must be the same:
88  // ** either Cell * or std::unique_ptr<Cell>. NO OTHER TYPES are allowed.
90  std::unique_ptr<Cell> m_open;
92  std::unique_ptr<Cell> m_base;
93  std::unique_ptr<Cell> m_comma1;
95  std::unique_ptr<Cell> m_var;
96  std::unique_ptr<Cell> m_comma2;
98  std::unique_ptr<Cell> m_lowerLimit;
99  std::unique_ptr<Cell> m_comma3;
101  std::unique_ptr<Cell> m_upperLimit;
103  std::unique_ptr<Cell> m_close;
104  // The pointers above point to inner cells and must be kept contiguous.
105 
107  wxCoord m_signHeight = 35;
109  wxCoord m_signWidth = 18;
111  wxCoord m_signTop = m_signHeight / 2;
112 #if defined __WXMSW__
113  wxCoord m_charHeight = 12;
114  wxCoord m_charWidth = 12;
115 #endif
116 
118  IntegralType m_intStyle = INT_IDEF;
119 
120 //** Bitfield objects (0 bytes)
121 //**
122  static void InitBitFields_IntCell()
123  { // Keep the initialization order below same as the order
124  // of bit fields in this class!
125  }
126 };
127 
128 #endif // INTCELL_Hs.
The definition of the base class of all cells the worksheet consists of.
A Type-Safe Fixed-Point Font Size.
Definition: FontAttribs.h:98
A class that carries information about the type of a cell.
Definition: Cell.h:93
The base class all cell types the worksheet can consist of are derived from.
Definition: Cell.h:142
wxCoord Scale_Px(double px) const
Scale font sizes and line widths according to the zoom factor.
Definition: Cell.h:176
The configuration storage for the current worksheet.
Definition: Configuration.h:95
A cell grouping input (and, if there is one, also the output) cell to a foldable item.
Definition: GroupCell.h:74
This class represents an integral.
Definition: IntCell.h:40
wxString ToMathML() const override
Convert this cell to a representation fit for saving in a .wxmx file.
Definition: IntCell.cpp:238
const CellTypeInfo & GetInfo() override
Returns the information about this cell's type.
void SetNextToDraw(Cell *next) override
Tells this cell which one should be the next cell to be drawn.
Definition: IntCell.cpp:356
wxString ToXML() const override
Convert this cell to a representation fit for saving in a .wxmx file.
Definition: IntCell.cpp:296
wxString ToMatlab() const override
Convert this cell to its Matlab representation.
Definition: IntCell.cpp:197
IntegralType
Definition: IntCell.h:60
@ INT_DEF
A definite integral, meaning an integral with limits.
Definition: IntCell.h:61
@ INT_IDEF
An indefinite integral, meaning an integral without limits
Definition: IntCell.h:62
Cell * GetInnerCell(size_t index) const override
Retrieve an inner cell with given index which must be less than GetInnerCellCount.
Definition: IntCell.h:53
void Draw(wxPoint point, wxDC *dc, wxDC *antialiassingDC) override
Draw this cell.
Definition: IntCell.cpp:139
std::unique_ptr< Cell > Copy(GroupCell *group) const override
Create a copy of this cell.
bool HasLimits() const
Does this integral have limits?
Definition: IntCell.h:79
void SetIntStyle(IntegralType style)
Choose between definite and indefinite integrals.
Definition: IntCell.h:66
wxString ToString() const override
Returns the cell's representation as a string.
Definition: IntCell.cpp:174
wxString ToTeX() const override
Convert this cell to its LaTeX representation.
Definition: IntCell.cpp:219
wxString ToOMML() const override
Returns the cell's representation as OMML.
Definition: IntCell.cpp:269
size_t GetInnerCellCount() const override
The number of inner cells - for use by the iterators.
Definition: IntCell.h:51
void Recalculate(AFontSize fontsize) override
Recalculate the size of the cell and the difference between top and center.
Definition: IntCell.cpp:84
bool BreakUp() override
Try to split this command into lines to make it fit on the screen.
Definition: IntCell.cpp:329