aboutsummaryrefslogtreecommitdiff
path: root/core/src/Model/Template/TableTemplate.hpp
diff options
context:
space:
mode:
Diffstat (limited to 'core/src/Model/Template/TableTemplate.hpp')
-rw-r--r--core/src/Model/Template/TableTemplate.hpp66
1 files changed, 44 insertions, 22 deletions
diff --git a/core/src/Model/Template/TableTemplate.hpp b/core/src/Model/Template/TableTemplate.hpp
index 6454ccd..be043a9 100644
--- a/core/src/Model/Template/TableTemplate.hpp
+++ b/core/src/Model/Template/TableTemplate.hpp
@@ -1,4 +1,4 @@
-#pragma once
+#pragma once
#include "Utils/Vector.hpp"
#include "Utils/VectorHash.hpp"
@@ -24,7 +24,8 @@ public:
enum CellType
{
ConstantCell,
- ParametricCell,
+ SingularParametricCell,
+ ArrayParametricCell,
};
public:
@@ -38,15 +39,23 @@ public:
TextAlignment HorizontalAlignment = AlignAxisMin;
TextAlignment VerticalAlignment = AlignAxisMin;
CellType Type;
+ /// The id of the group description object, if this cell isn't a constant or singluar parameter cell. Otherwise, this value is -1.
+ int DataId = -1;
public:
+ /// Return whether this cell holds meaningful data, i.e. true when this cell is either unmerged or the primary cell of a merged range.
+ bool IsDataHoldingCell() const;
+ /// Return whether this cell is the primary (i.e. top left) cell of a merged range or not.
bool IsPrimaryCell() const;
+ /// Return whether this cell is a part of a merged range or not. Includes the primary cell.
bool IsMergedCell() const;
};
-/// Parameter group information for a grouped array of cells, either horizontal or vertical.
-/// These cells can have "expansion behavior", i.e. when instanciating, a list of cell values would be provided by
-/// the caller:
+// TODO support reverse (bottom to top) filling order
+// TODO support horizontal filling order
+/// Parameter group information for a grouped array of cells. When instanciated, an array of 0 or more
+/// elements shall be provided by the user, which will replace the group of templated cells with a list
+/// of rows, each instanciated with the n-th element in the provided array.
/// \code
/// [["foo", "bar", "foobar"],
/// ["a", "b", c"],
@@ -54,11 +63,9 @@ public:
/// ["x", "y", "z"]]
/// // ... may be more
/// \endcode
+/// This would create 4 rows of data in the place of the original parameter group.
///
-/// For a array parameter group that vertically expands, this would create 4 rows of data in the place of the
-/// original parameter group. If more than one array parameter groups are on the same row, they would share space
-/// between each other :
-///
+/// If more than one array parameter groups are on the same row, they would share space between each other:
/// \code
/// | 2 elements was fed to it
/// | | 1 element was fed to it
@@ -70,19 +77,23 @@ public:
/// | Cool | Example | |
/// +------+---------+---------------+
/// \endcode
-class TableArrayParameterGroup
+///
+/// \see TableCell
+/// \see TableInstanciationParameters
+/// \see TableTemplate
+class TableCellArrayGroup
{
public:
- enum ExpansionDirection
- {
- ExpandUp,
- ExpandDown,
- ExpandLeft,
- ExpandRight,
- };
+ int Row;
+ /// Leftmost cell in this group
+ int LeftCell;
+ /// Rightmost cell in this group
+ int RightCell;
public:
- ExpansionDirection ExpandDirection;
+ Vec2i GetLeftCell() const;
+ Vec2i GetRightCell() const;
+ int GetCount() const;
};
// Forward declaration of libxlsxwriter structs
@@ -94,11 +105,22 @@ struct lxw_worksheet;
class TableInstanciationParameters
{
private:
- TableTemplate* mTemplate;
- tsl::robin_map<Vec2i, std::string> ParametricCells;
+ const TableTemplate* mTable;
public:
- // TODO
+ tsl::robin_map<Vec2i, std::string> SingularCells;
+
+ using ArrayGroupRow = std::vector<std::string>;
+ using ArrayGroupData = std::vector<ArrayGroupRow>;
+ std::vector<ArrayGroupData> ArrayGroups;
+
+public:
+ TableInstanciationParameters(const TableTemplate& table);
+
+ TableInstanciationParameters& ResetTable(const TableTemplate& newTable);
+ TableInstanciationParameters RebindTable(const TableTemplate& newTable) const;
+
+ const TableTemplate& GetTable() const;
};
/// A table template, where individual cells can be filled by workflows instanciating this template. Merged cells,
@@ -109,7 +131,7 @@ class TableTemplate
{
private:
std::vector<TableCell> mCells;
- std::vector<TableArrayParameterGroup> mArrayGroups;
+ std::vector<TableCellArrayGroup> mArrayGroups;
int mTableWidth;
int mTableHeight;