A table entity can be broken into a number of fragments (sub-tables), shown below.
To enable or disable breaking mode for the specified table, the enableBreak() method should be used. It has one input boolean parameter. If its value is true, the breaking mode is enabled; if false, the breaking mode is disabled. For example:
pBrTable->enableBreak(true);
In this example and in the examples described below, the pBrTable is a smart pointer to an OdDbTable object.
Note: By default, breaking mode is disabled.
To check whether the table supports breaking mode, the isBreakEnabled() method should be used. It doesn't have input parameters and returns a boolean value of true if the breaking mode is enabled or false if it is not. For example:
odPrintConsoleString(L"\n Breaking mode is %s", pBrTable->isBreakEnabled()? L"enable" : L"not enable");
There are some properties of breaking tables that are described below.
To set additional break options, the method setBreakOption() is used. It has one input parameter that must be a combination of one or more values from the OdDb::TableBreakOption enumerator:
enum TableBreakOption { kTableBreakNone = 0, // None. kTableBreakEnableBreaking = 0x01, // Enable table breaking. kTableBreakRepeatTopLabels = 0x02, // Repeat top labels for all sub-tables. kTableBreakRepeatBottomLabels = 0x04, // Repeat bottom labels for all sub-tables. kTableBreakAllowManualPositions = 0x08, // Allow manual positions for individual sub-tables. kTableBreakAllowManualHeights = 0x10 // Allow setting manual height of all sub-tables individually. };
To set the break enabling option and to allow a user-defined position and height for each sub-table, this code can be used:
pBrTable->setBreakOption((OdDb::TableBreakOption(pBrTable->breakOption()|OdDb::kTableBreakAllowManualPositions|OdDb::kTableBreakAllowManualHeights)));
The method breakOption() returns the break's options as an integer value:
int i = pBrTable->breakOption();
It is possible to change the flow direction of sub-tables. For example, all sub-tables are arranged horizontally one by another from left to right (right to left), or vertically. The method setBreakFlowDirection() is used for this. It has one input parameter that must be one value from the OdDb::TableBreakFlowDirection enumerator:
enum TableBreakFlowDirection { kTableBreakFlowRight = 0x1, // Break tables in the direction from left to right. kTableBreakFlowDownOrUp = 0x2, // Break tables in the directions from top to bottom (for top-to-bottom table flow) or from bottom to top (for bottom-to-top table flow). kTableBreakFlowLeft = 0x4 // Break tables in the direction from right to left. };
By default, the breaking flow direction is OdDb::kTableBreakFlowRight. In the example below, the vertical break flow direction is set.
pBrTable->setBreakFlowDirection(OdDb::kTableBreakFlowDownOrUp);
Note: For the vertical break flow direction, if the table has the flow direction from top to bottom (setFlowDirection(OdDb::kTtoB)), then sub-tables will also be placed from top-to-bottom (in forward order). If the table has the flow direction from bottom to top (setFlowDirection(OdDb::kBtoT)), sub-tables will also be placed from bottom-to-top (in reverse order). These situations are illustrated below:
The breakFlowDirection() method returns the direction of a table's breaks as a value from the OdDb::TableBreakFlowDirection enumerator:
int i = pBrTable->breakFlowDirection();
The spacing between sub-tables can be changed by the setBreakSpacing() method. It has one input parameter — a double value of spacing size — and does not return anything. For example:
pBrTable->setBreakSpacing (0.5);
The breakSpacing() method returns the current double value of spacing between sub-tables. For example:
odPrintConsoleString(L"\nBreak spacing: %1.2f", pBrTable->breakSpacing());
Each sub-table can have different heights. By default, the table is broken row by row and the height of each sub-table is equal to 0. To set the user defined height for a sub-table, use the setBreakHeight() method. This method has two input parameters: an integer sub-table index and the new double value of the height. The sub-table index should be greater than or equal to 0. For example, to set the height of the second sub-table, use the following:
pBrTable->setBreakHeight(1, 2.0);
To determine how many rows are placed into a sub-table with a new height, the height of each table's row should be considered.
Note: The setBreakHeight() method can be used only if the TableBreakFlowDirection::kTableBreakAllowManualHeights option is enabled.
To get the height of the specified sub-table, the breakHeight() method can be used. It has one input argument — an integer sub-table index — and returns a double value of the break's height. For example:
odPrintConsoleString(L"\n Break height is %1.2f", pBrTable->breakHeight(1));
Sub-tables can be placed in different positions as shown below:
Visually there are three tables in the picture, but there is only one table in the drawing, and the table is in break mode.
To set the user defined position for the specified sub-table, use the setBreakOffset() method. It has two input parameters: the sub-table index as an integer value, and the offset as an object of the OdGeVector3d class. The sub-table index should be greater than or equal to 1. The offset is calculated relative to the position of the original table, which can be determined by the position() method. An example of using the setBreakOffset() method is shown below.
pBrTable->setBreakOffset(1, OdGeVector3d(1.0, 2.2, 0.0));
To get the offset of the specified sub-table, the breakOffset() method is used. It takes one input parameter — a sub-table index as an integer value — and returns the current offset as an OdGeVector3d value. For example:
OdGeVector3d offset = pBrTable->breakOffset(1);
odPrintConsoleString(L"\n Sub-table offset is: x = %1.2f, y = %1.2f, z = %1.2f", offset.x, offset.y, offset.z);
Example of Working with Tables
Copyright © 2002 – 2021. Open Design Alliance. All rights reserved.
|