wxMaxima
SumCell.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 // (C) 2014-2018 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 
31 #ifndef SUMCELL_H
32 #define SUMCELL_H
33 
34 #include "precomp.h"
35 #include "Cell.h"
36 #include "ParenCell.h"
37 
38 class TextCell;
39 
40 enum sumStyle : int8_t
41 {
42  SM_SUM,
43  SM_PROD
44 };
45 
46 class SumCell final : public Cell
47 {
48 public:
49  SumCell(GroupCell *group, Configuration **config, sumStyle style,
50  std::unique_ptr<Cell> &&under, std::unique_ptr<Cell> &&over,
51  std::unique_ptr<Cell> &&base);
52  SumCell(GroupCell *group, const SumCell &cell);
53  std::unique_ptr<Cell> Copy(GroupCell *group) const override;
54  const CellTypeInfo &GetInfo() override;
55 
56  int GetInnerCellCount() const override { return 10; }
57  // cppcheck-suppress objectIndex
58  Cell *GetInnerCell(int index) const override { return (&m_open)[index].get(); }
59 
60  void Recalculate(AFontSize fontsize) override;
61 
62  void Draw(wxPoint point) override;
63 
64  wxString ToMathML() const override;
65  wxString ToMatlab() const override;
66  wxString ToOMML() const override;
67  wxString ToString() const override;
68  wxString ToTeX() const override;
69  wxString ToXML() const override;
70 
71  void SetAltCopyText(const wxString &text) override { m_altCopyText = text; }
72  const wxString &GetAltCopyText() const override { return m_altCopyText; }
73 
74  bool BreakUp() override;
75  void SetNextToDraw(Cell *next) override;
76  void Unbreak() override final;
77 
78 private:
79  std::unique_ptr<Cell> MakeStart(Cell *under) const;
80  void MakeBreakUpCells();
81 
82  ParenCell *Paren() const;
84  Cell *Base() const;
86  Cell *DisplayedBase() const;
87 
89  wxString m_altCopyText;
90 
91  // The pointers below point to inner cells and must be kept contiguous.
92  // ** This is the partial draw list order. All pointers must be the same:
93  // ** either Cell * or std::unique_ptr<Cell>. NO OTHER TYPES are allowed.
94  std::unique_ptr<Cell> m_open;
95  std::unique_ptr<Cell> m_paren;
96  std::unique_ptr<Cell> m_comma1;
97  std::unique_ptr<Cell> m_var;
98  std::unique_ptr<Cell> m_comma2;
99  std::unique_ptr<Cell> m_start;
100  std::unique_ptr<Cell> m_comma3;
101  std::unique_ptr<Cell> m_over;
102  std::unique_ptr<Cell> m_close;
103  std::unique_ptr<Cell> m_under;
104  // The pointers above point to inner cells and must be kept contiguous.
105 
106  float m_signWidth = 30.0f;
107  int m_signHeight = 50;
108  int m_signWCenter = 15;
109  sumStyle m_sumStyle = SM_SUM;
110 
111 //** Bitfield objects (1 bytes)
112 //**
113  void InitBitFields()
114  { // Keep the initialization order below same as the order
115  // of bit fields in this class!
116  m_displayParen = true;
117  }
118 
120  bool m_displayParen : 1 /* InitBitFields */;
121 };
122 
123 #endif // SUMCELL_H
Cell.h
SumCell::GetInfo
const CellTypeInfo & GetInfo() override
Returns the information about this cell's type.
TextCell
Definition: TextCell.h:36
SumCell::GetInnerCell
Cell * GetInnerCell(int index) const override
Definition: SumCell.h:58
SumCell::GetInnerCellCount
int GetInnerCellCount() const override
The number of inner cells - for use by the iterators.
Definition: SumCell.h:56
SumCell::SetNextToDraw
void SetNextToDraw(Cell *next) override
Definition: SumCell.cpp:435
SumCell::Recalculate
void Recalculate(AFontSize fontsize) override
Definition: SumCell.cpp:120
SumCell::ToOMML
wxString ToOMML() const override
Definition: SumCell.cpp:312
SumCell::ToXML
wxString ToXML() const override
Convert this cell to a representation fit for saving in a .wxmx file.
Definition: SumCell.cpp:337
SumCell::Unbreak
void Unbreak() override final
Definition: SumCell.cpp:398
SumCell::ToString
wxString ToString() const override
Returns the cell's representation as a string.
Definition: SumCell.cpp:223
SumCell
Definition: SumCell.h:46
SumCell::Copy
std::unique_ptr< Cell > Copy(GroupCell *group) const override
Cell
Definition: Cell.h:139
SumCell::SetAltCopyText
void SetAltCopyText(const wxString &text) override
Definition: SumCell.h:71
SumCell::ToMatlab
wxString ToMatlab() const override
Convert this cell to its Matlab representation.
Definition: SumCell.cpp:263
ParenCell.h
AFontSize
Definition: FontAttribs.h:97
Configuration
Definition: Configuration.h:83
ParenCell
Definition: ParenCell.h:49
SumCell::ToTeX
wxString ToTeX() const override
Convert this cell to its LaTeX representation.
Definition: SumCell.cpp:291
SumCell::ToMathML
wxString ToMathML() const override
Convert this cell to a representation fit for saving in a .wxmx file.
Definition: SumCell.cpp:360
GroupCell
Definition: GroupCell.h:68
CellTypeInfo
A class that carries information about the type of a cell.
Definition: Cell.h:90
SumCell::BreakUp
bool BreakUp() override
Definition: SumCell.cpp:404
SumCell::GetAltCopyText
const wxString & GetAltCopyText() const override
Get the text set using SetAltCopyText - may be empty.
Definition: SumCell.h:72