From 088da97531935a61870ecada10f06b9b9a8255d1 Mon Sep 17 00:00:00 2001 From: rtk0c Date: Sat, 29 May 2021 13:01:01 -0700 Subject: Table instaciation to xlsx complete --- core/src/Model/Template/TableTemplate.hpp | 66 ++++++++++++++++++++----------- 1 file changed, 44 insertions(+), 22 deletions(-) (limited to 'core/src/Model/Template/TableTemplate.hpp') 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 ParametricCells; + const TableTemplate* mTable; public: - // TODO + tsl::robin_map SingularCells; + + using ArrayGroupRow = std::vector; + using ArrayGroupData = std::vector; + std::vector 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 mCells; - std::vector mArrayGroups; + std::vector mArrayGroups; int mTableWidth; int mTableHeight; -- cgit v1.2.3-70-g09d2