-
Notifications
You must be signed in to change notification settings - Fork 89
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: Table subs division #3353
Conversation
…dudes/table-layout
…feature/dudes/table-layout" This reverts commit 8f74cfa.
…nto feature/dudes/table-layout
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
First pass on test & general functionnalities
TableLayout::Column{{"CoordZ"}, TableLayout::Alignment::left}, | ||
TableLayout::Column{{"Prev\nelement"}, TableLayout::Alignment::right}, | ||
TableLayout::Column{{"Next\nelement"}, TableLayout::Alignment::right}} ); | ||
tableLayout.setValuesAlignment( TableLayout::Alignment::right ); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is the goal of this test to consolidate the setValuesAlignment()
code?
If so,
- keep
tableLayout
non-const, - use your builder pattern here,
- no need to test that more that one time, it makes test heavier for no purposes.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
setValuesAlignment
is for cellValues and alignement TableLayout::Column{}
is for header alignment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok I see, this is not what we discussed at first, but it is good to be able to modify both setting by this way.
So two requests:
- Keep in mind that the value alignement is more likely to be customised than the header alignement. So please modify the
valueAlignment
in theColumn
constructors. - Test the
setValuesAlignment()
only one time. - use your builder pattern here, and declare
tableLayout
constant.
TEST( testTable, testLineWrap ) | ||
{ | ||
//////////// | ||
//////// If setMargin used elsewhere make it public and remove comments for this test | ||
//////////// | ||
//test with tiny margin | ||
// { | ||
// TableLayout tableLayout( { | ||
// TableLayout::ColumnParam{{"Colonne 1"}, TableLayout::Alignment::center}, | ||
// TableLayout::ColumnParam{{"Colonne 2"}, TableLayout::Alignment::center}, | ||
// TableLayout::ColumnParam{{"Colonne 3"}, TableLayout::Alignment::right}, | ||
// TableLayout::ColumnParam{{"Colonne 4"}, TableLayout::Alignment::right}, | ||
// TableLayout::ColumnParam{{"Prev\nelement"}, TableLayout::Alignment::right}, | ||
// TableLayout::ColumnParam{{"Next\nelement"}, TableLayout::Alignment::right}, | ||
// }, "InternalWellGenerator well_injector1" ); | ||
|
||
// //tableLayout.setMargin( TableLayout::MarginValue::tiny ); | ||
|
||
// TableData tableData; | ||
// tableData.addRow( "value 1", "long value 1", "3.0034", 3.0129877, "" , 1 ); | ||
// tableData.addRow( "value 1", "long value 2", "100.45", 4.0129877, 1 , 2 ); | ||
|
||
// TableTextFormatter const tableText( tableLayout ); | ||
// EXPECT_EQ( tableText.toString( tableData ), | ||
// "\n------------------------------------------------------------\n" | ||
// "| InternalWellGenerator well_injector1 |\n" | ||
// "------------------------------------------------------------\n" | ||
// "|Colonne 1| Colonne 2 |Colonne 3|Colonne 4| Prev| Next|\n" | ||
// "| | | | |element|element|\n" | ||
// "------------------------------------------------------------\n" | ||
// "| value 1 |long value 1| 3.0034|3.0129877| | 1|\n" | ||
// "| value 1 |long value 2| 100.45|4.0129877| 1| 2|\n" | ||
// "------------------------------------------------------------\n\n" | ||
// ); | ||
// } | ||
TableLayout tableLayout( {"Cras egestas", "CoordX", "C", "CoordZ", "Prev\nelement", "Next\nelement"} ); | ||
tableLayout.setTitle( "title" ).setMargin( TableLayout::MarginValue::tiny ).disableLineWrap(); | ||
|
||
TableData tableData; | ||
tableData.addRow( "1", "2", "3.0", 3.0129877, 2.0f, 1 ); | ||
tableData.addRow( "1", "2", "3.0", 3.0129877, 2.0f, 1 ); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good thing that we can use a line break in titles :)
testLineBreak
would be more accurate as a name (line wrapping term is more dedicated for automatic line breaks).- I really think it should support line breaks within content lines:
tableData.addRow( "1", "2", "one line text", 3.0129877, 2.0f, 1 );
tableData.addRow( "1", "2", "three\nlines\ntext", 3.0129877, 2.0f, 1 );
tableData.addRow( "1", "2", "one line text", 3.0129877, 2.0f, 1 );
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I can make line break for cell values if needed, not sure if right this is mandatory
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I encountered a scenario that needed this, but I forgot it :(
We can get back on this later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok, what do you think of this?
-------------------------------------
| stat name | component | value |
-------------------------------------
| pressure | all | 123.456 |
| temperature | all | 123.456 |
-------------------------------------
| | oil | 123.456 |
| mass | gaz | 123.456 |
| | water | 123.456 |
-------------------------------------
I think it would need to be able to have a TableData::addSeparatorRow()
, and we may need multiline for doing a tableData.addRow("mass","oil\ngaz\nwater","123.456\n123.456\n123.456")
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
2nd pass, format/table classes
/// Vector containing substring column name delimited by "\n" | ||
std::vector< string > splitColumnNameLines; | ||
std::vector< string > splitColumnNames = {""}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can a user mess with this parameter? It seems like it should be private.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this parameter is assigned in tableFormatter function
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it should be annotated as an "internal computed value", as it is not dedicated to be modified (but public, in a set-up structure).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please, either set it private or anotate it as an "internal computed value".
void TableTextFormatter::splitAndMergeColumnHeaders( std::vector< TableLayout::TableColumnData > & tableColumnsData, | ||
size_t & nbHeaderRows, | ||
std::vector< std::vector< string > > & splitHeaders ) const |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- Do you really use all those out-parameters?
- Why
nbHeaderRows
does not take into account sub-columns? Can it cause issues? (is it tested?)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I removed nbHeaderRows parameters in all signature, no issue for we add '\n' to subcolumn bc it's not implemented yet, it will just take the first part of the string
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it needs more work to either fully implement what those lines tries to do:
if( !tableColumnData.subColumn.empty())
{
std::vector< std::vector< string > > splitSubColHeaders;
size_t nbHeaderSubColRows = 0;
splitAndMergeColumnHeaders( tableColumnData.subColumn, nbHeaderSubColRows, splitSubColHeaders );
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You seem to now correctly store the results of splitAndMergeColumnHeaders()
in splitColumnNames
.
So what is the use of allDividedHeaderParts
out-parameter?
I must say that it is a good thing that your worked on renaming/refactoring some parts, it will helps a lot in understanding. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I added some requests.
Work merged in #3406 |
This PR allows the table to be subdivided, but also simplifies the declaration of the table.
Column declarations can be mixed with string and ColumnParam struct, I.E:
For an example with sub-columns, this will give the following result
Output :
Also, column titles are now centered by default, regardless on the content alignement.