QElectroTech
0.8-dev
|
The TitleBlockTemplate class This class represents an title block template for an electric diagram. It can read from an XML document the layout of the table that graphically represents the title block, and can produce a graphical rendering of it from a diagram context (object embedding the informations of the diagram we want to represent the title block. More...
#include <titleblocktemplate.h>
Inherits QObject.
Static Public Member Functions | |
static QFont | fontForCell (const TitleBlockCell &) |
TitleBlockTemplate::fontForCell. More... | |
Protected Member Functions | |
void | loadInformation (const QDomElement &) |
TitleBlockTemplate::loadInformation Import text informations from a given XML title block template. More... | |
bool | loadLogos (const QDomElement &, bool=false) |
TitleBlockTemplate::loadLogos Import the logos from a given XML titleblock template. More... | |
bool | loadLogo (const QDomElement &) |
TitleBlockTemplate::loadLogo Import the logo from a given XML logo description. More... | |
bool | loadGrid (const QDomElement &) |
bool | loadCells (const QDomElement &) |
TitleBlockTemplate::loadCells Analyze an XML element, looking for grid cells. The grid cells are checked and stored in this object. More... | |
void | loadCell (const QDomElement &) |
TitleBlockTemplate::loadCell Load a cell into this template. More... | |
void | saveInformation (QDomElement &) const |
TitleBlockTemplate::saveInformation Export this template's extra information. More... | |
void | saveLogos (QDomElement &) const |
TitleBlockTemplate::saveLogos Export this template's logos as XML. More... | |
void | saveLogo (const QString &, QDomElement &) const |
TitleBlockTemplate::saveLogo Export a specific logo as XML. More... | |
void | saveGrid (QDomElement &) const |
TitleBlockTemplate::saveGrid Export this template's cells grid as XML. More... | |
void | saveCells (QDomElement &) const |
TitleBlockTemplate::saveCells Export this template's cells as XML (without the grid-related information, usch as rows and cols) More... | |
void | saveCell (TitleBlockCell *, QDomElement &, bool=false) const |
TitleBlockTemplate::saveCell Export a specific cell as XML. More... | |
QList< TitleBlockCell * > | createCellsList (int) |
TitleBlockTemplate::createCellsList. More... | |
Private Member Functions | |
TitleBlockTemplate (const TitleBlockTemplate &) | |
void | parseRows (const QString &) |
TitleBlockTemplate::parseRows Parse the rows heights. More... | |
void | parseColumns (const QString &) |
TitleBlockTemplate::parseColumns Parse the columns widths. More... | |
bool | checkCell (const QDomElement &, TitleBlockCell **=nullptr) |
TitleBlockTemplate::checkCell Load the essential attributes of a cell: row and column indices and spans. More... | |
void | flushCells () |
void | initCells () |
TitleBlockTemplate::initCells Initialize the internal cells grid with the row and column counts. Note that this method does nothing if one of the internal lists columns_width_ and rows_heights_ is empty. More... | |
int | lengthRange (int, int, const QList< int > &) const |
TitleBlockTemplate::lengthRange. More... | |
QString | finalTextForCell (const TitleBlockCell &, const DiagramContext &) const |
TitleBlockTemplate::finalTextForCell. More... | |
QString | interpreteVariables (const QString &, const DiagramContext &) const |
TitleBlockTemplate::interpreteVariables. More... | |
void | renderTextCell (QPainter &, const QString &, const TitleBlockCell &, const QRectF &) const |
TitleBlockTemplate::renderTextCell This method uses a painter to render the text of a cell into the cell_rect rectangle. The alignment, font_size and other cell parameters are taken into account when rendering. More... | |
void | renderTextCellDxf (QString &, const QString &, const TitleBlockCell &, qreal, qreal, qreal, qreal, int) const |
TitleBlockTemplate::renderTextCellDxf. More... | |
Private Attributes | |
QString | name_ |
name_ : name identifying the Title Block Template within its parent collection More... | |
QString | information_ |
QHash< QString, QByteArray > | data_logos_ |
data_logos_ : Logos raw data More... | |
QHash< QString, QString > | storage_logos_ |
storage_logos_ : Logos applied storage type (e.g. "xml" or "base64") More... | |
QHash< QString, QString > | type_logos_ |
type_logos_ : Logos types (e.g. "png", "jpeg", "svg") More... | |
QHash< QString, QSvgRenderer * > | vector_logos_ |
vector_logos_ : Rendered objects for vector logos More... | |
QHash< QString, QPixmap > | bitmap_logos_ |
bitmap_logos_ : Pixmaps for bitmap logos More... | |
QList< int > | rows_heights_ |
rows heights – simple integers More... | |
QList< TitleBlockDimension > | columns_width_ |
columns_width_ : columns widths – More... | |
QList< TitleBlockCell * > | registered_cells_ |
registered_cells_ : Cells objects created rattached to this template, but not mandatorily used More... | |
QList< QList< TitleBlockCell * > > | cells_ |
Cells grid. More... | |
The TitleBlockTemplate class This class represents an title block template for an electric diagram. It can read from an XML document the layout of the table that graphically represents the title block, and can produce a graphical rendering of it from a diagram context (object embedding the informations of the diagram we want to represent the title block.
TitleBlockTemplate::TitleBlockTemplate | ( | QObject * | parent = nullptr | ) |
TitleBlockTemplate::TitleBlockTemplate Constructor.
parent | parent QObject |
|
override |
|
private |
void TitleBlockTemplate::addColumn | ( | int | i = -1 | ) |
TitleBlockTemplate::addColumn Add a new 50px-wide column at the provided index.
i | : Index of the added column, -1 meaning "last position" |
bool TitleBlockTemplate::addLogo | ( | const QString & | logo_name, |
QByteArray * | logo_data, | ||
const QString & | logo_type = "svg" , |
||
const QString & | logo_storage = "xml" |
||
) |
logo_name | : Logo name to be added / replaced |
logo_data | : Logo data |
logo_type | : |
logo_storage | : |
bool TitleBlockTemplate::addLogoFromFile | ( | const QString & | filepath, |
const QString & | name = QString() |
||
) |
TitleBlockTemplate::addLogoFromFile.
filepath | : Path of the image file to add as a logo |
name | : Name used to store the logo; if none is provided, the basename of the first argument is used. |
void TitleBlockTemplate::addRow | ( | int | i = -1 | ) |
TitleBlockTemplate::addRow Add a new 25px-wide row at the provided index.
i | : Index of the added row, -1 meaning "last position" |
void TitleBlockTemplate::applyCellSpan | ( | TitleBlockCell * | cell | ) |
TitleBlockTemplate::applyCellSpan Ensure the spans of the provided cell are applied within the grid structure.
cell | : Potentially spanning cell |
void TitleBlockTemplate::applyCellSpans | ( | ) |
TitleBlockTemplate::applyCellSpans Forget any previously applied span, then apply again all spans defined by existing cells.
void TitleBlockTemplate::applyRowColNums | ( | ) |
TitleBlockTemplate::applyRowColNums Ensure all cells have the right col+row numbers.
QPixmap TitleBlockTemplate::bitmapLogo | ( | const QString & | logo_name | ) | const |
TitleBlockTemplate::bitmapLogo.
logo_name | : Name of a logo embedded within this title block template. |
TitleBlockCell * TitleBlockTemplate::cell | ( | int | row, |
int | col | ||
) | const |
row | : A row number (starting from 0) |
col | : A column number (starting from 0) |
|
private |
TitleBlockTemplate::checkCell Load the essential attributes of a cell: row and column indices and spans.
xml_element | : XML element representing a cell, i.e. either an titleblock logo or an titleblock field. |
titleblock_cell_ptr | : Pointer to a TitleBlockCell object pointer - if non-zero and if this method returns true, will be filled with the created TitleBlockCell |
bool TitleBlockTemplate::checkCellSpan | ( | TitleBlockCell * | cell | ) |
TitleBlockTemplate::checkCellSpan Check whether a given cell can be spanned according to its row_span and col_span attributes. the following attributes of cell are updated according to what is really possible: applied_col_span applied_row_span span_state.
cell | : Cell we want to check |
TitleBlockTemplate * TitleBlockTemplate::clone | ( | ) | const |
TitleBlockDimension TitleBlockTemplate::columnDimension | ( | int | i | ) |
TitleBlockTemplate::columnDimension.
i | : column index |
int TitleBlockTemplate::columnsCount | ( | ) | const |
TitleBlockTemplate::columnsCount.
QList< int > TitleBlockTemplate::columnsWidth | ( | int | total_width | ) | const |
TitleBlockTemplate::columnsWidth.
total_width | : The total width of the titleblock to render |
int TitleBlockTemplate::columnTypeCount | ( | QET::TitleBlockColumnLength | type | ) |
TitleBlockTemplate::columnTypeCount.
type | : a column type |
int TitleBlockTemplate::columnTypeTotal | ( | QET::TitleBlockColumnLength | type | ) |
TitleBlockTemplate::columnTypeTotal.
type | : a column type |
TitleBlockCell * TitleBlockTemplate::createCell | ( | const TitleBlockCell * | existing_cell = nullptr | ) |
TitleBlockTemplate::createCell Create a new cell and associate it with this template, which means that it will be deleted when this template is destroyed.
existing_cell | (optional) An existing cell that will be copied |
|
protected |
TitleBlockTemplate::createCellsList.
count | : Number of cells expected in the list |
QList< TitleBlockCell * > TitleBlockTemplate::createColumn | ( | ) |
TitleBlockTemplate::createColumn.
QList< TitleBlockCell * > TitleBlockTemplate::createRow | ( | ) |
TitleBlockTemplate::createRow.
void TitleBlockTemplate::exportCellToXml | ( | TitleBlockCell * | cell, |
QDomElement & | xml_element | ||
) | const |
TitleBlockTemplate::exportCellToXml.
cell | : Cell to export |
xml_element | : Parent XML element to be used when exporting cell |
|
private |
TitleBlockTemplate::finalTextForCell.
cell | : A cell from this template |
diagram_context | : Diagram context to use to generate the final text for the given cell |
|
private |
|
static |
TitleBlockTemplate::fontForCell.
cell | : An existing cell |
void TitleBlockTemplate::forgetSpanning | ( | ) |
TitleBlockTemplate::forgetSpanning Set the spanner_cell attribute of every cell to 0.
void TitleBlockTemplate::forgetSpanning | ( | TitleBlockCell * | spanning_cell, |
bool | modify_cell = true |
||
) |
TitleBlockTemplate::forgetSpanning Set the spanner_cell attribute of every cell spanned by spanning_cell to 0.
spanning_cell | : |
modify_cell | : (Optional, defaults to true) Whether to set row_span and col_span of spanning_cell to 0. |
QHash< TitleBlockCell *, QPair< int, int > > TitleBlockTemplate::getAllSpans | ( | ) | const |
TitleBlockTemplate::getAllSpans Export the span parameters of all cell in the current grid.
int TitleBlockTemplate::height | ( | ) | const |
QString TitleBlockTemplate::information | ( | ) | const |
TitleBlockTemplate::information.
|
private |
TitleBlockTemplate::initCells Initialize the internal cells grid with the row and column counts. Note that this method does nothing if one of the internal lists columns_width_ and rows_heights_ is empty.
bool TitleBlockTemplate::insertColumn | ( | const TitleBlockDimension & | dimension, |
const QList< TitleBlockCell * > & | column, | ||
int | i = -1 |
||
) |
TitleBlockTemplate::insertColumn.
dimension | : Size of the column to be added |
column | : Column to be added |
i | : Index of the column after insertion, -1 meaning "last position" |
bool TitleBlockTemplate::insertRow | ( | int | dimension, |
const QList< TitleBlockCell * > & | row, | ||
int | i = -1 |
||
) |
TitleBlockTemplate::insertRow.
dimension | : dimension Size of the row to be added (always absolute, in pixels) |
row | : column Row to be added |
i | : Index of the column after insertion, -1 meaning "last position" |
|
private |
TitleBlockTemplate::interpreteVariables.
string | : A text containing 0 to n variables, e.g. "%var" or "%{var}" |
diagram_context | : Diagram context to use to interprete variables |
|
private |
TitleBlockTemplate::lengthRange.
start | : start border number |
end | : end border number |
lengths_list | : |
QStringList TitleBlockTemplate::listOfVariables | ( | ) |
TitleBlockTemplate::listOfVariables Get list of variables.
|
protected |
TitleBlockTemplate::loadCell Load a cell into this template.
cell_element | : XML element describing a cell within a title block template |
|
protected |
TitleBlockTemplate::loadCells Analyze an XML element, looking for grid cells. The grid cells are checked and stored in this object.
xml_element | XML element to analyze |
bool TitleBlockTemplate::loadFromXmlElement | ( | const QDomElement & | xml_element | ) |
TitleBlockTemplate::loadFromXmlElement.
xml_element | : An XML document to read the template from. |
bool TitleBlockTemplate::loadFromXmlFile | ( | const QString & | filepath | ) |
TitleBlockTemplate::loadFromXmlFile Load a titleblock template from an XML file.
filepath | : A file path to read the template from. |
|
protected |
Import the grid from a given XML titleblock template.
xml_element | An XML element representing an titleblock template. |
|
protected |
TitleBlockTemplate::loadInformation Import text informations from a given XML title block template.
xml_element |
|
protected |
TitleBlockTemplate::loadLogo Import the logo from a given XML logo description.
xml_element | : An XML element representing a logo within an titleblock template. |
|
protected |
TitleBlockTemplate::loadLogos Import the logos from a given XML titleblock template.
xml_element | : An XML element representing an titleblock template. |
reset | : true to delete all previously known logos before, false otherwise. |
QList< QString > TitleBlockTemplate::logos | ( | ) | const |
QString TitleBlockTemplate::logoType | ( | const QString & | logo_name | ) | const |
logo_name | : Name of a logo embedded within this title block template. |
int TitleBlockTemplate::maximumWidth | ( | ) |
TitleBlockTemplate::maximumWidth.
int TitleBlockTemplate::minimumWidth | ( | ) |
bool TitleBlockTemplate::moveColumn | ( | int | from, |
int | to | ||
) |
TitleBlockTemplate::moveColumn Move the column at index "from" to index "to".
from | : Source index of the moved column |
to | : Target index of the moved column |
bool TitleBlockTemplate::moveRow | ( | int | from, |
int | to | ||
) |
TitleBlockTemplate::moveRow Move a row within this template.
from | : Index of the moved row |
to | : Arrival index of the moved row |
QString TitleBlockTemplate::name | ( | ) | const |
|
private |
TitleBlockTemplate::parseColumns Parse the columns widths.
cols_string | : A string describing the columns widths of the titleblock |
|
private |
TitleBlockTemplate::parseRows Parse the rows heights.
rows_string | : A string describing the rows heights of the titleblock |
bool TitleBlockTemplate::removeLogo | ( | const QString & | logo_name | ) |
TitleBlockTemplate::removeLogo.
logo_name | : Name of the logo to remove |
TODO check existing cells using this logo.
bool TitleBlockTemplate::renameLogo | ( | const QString & | logo_name, |
const QString & | new_name | ||
) |
TitleBlockTemplate::renameLogo Rename the logo_name logo to new_name.
logo_name | : Name of the logo to be renamed |
new_name | : New name of the renamed logo |
TODO check existing cells using this logo.
void TitleBlockTemplate::render | ( | QPainter & | painter, |
const DiagramContext & | diagram_context, | ||
int | titleblock_width | ||
) | const |
TitleBlockTemplate::render Render the titleblock.
painter | : Painter to use to render the titleblock |
diagram_context | : Diagram context to use to generate the titleblock strings |
titleblock_width | : Width of the titleblock to render |
void TitleBlockTemplate::renderCell | ( | QPainter & | painter, |
const TitleBlockCell & | cell, | ||
const DiagramContext & | diagram_context, | ||
const QRect & | cell_rect | ||
) | const |
TitleBlockTemplate::renderCell Render a titleblock cell.
painter | : Painter to use to render the titleblock |
cell | : |
diagram_context | : Diagram context to use to generate the titleblock strings |
cell_rect | : Rectangle the cell must be rendered into. |
void TitleBlockTemplate::renderDxf | ( | QRectF & | title_block_rect, |
const DiagramContext & | diagram_context, | ||
int | titleblock_width, | ||
QString & | file_path, | ||
int | color | ||
) | const |
TitleBlockTemplate::renderDxf Render the titleblock in DXF.
title_block_rect | : |
diagram_context | : Diagram context to use to generate the titleblock strings |
titleblock_width | : Width of the titleblock to render |
file_path | : |
color | : |
|
private |
TitleBlockTemplate::renderTextCell This method uses a painter to render the text of a cell into the cell_rect rectangle. The alignment, font_size and other cell parameters are taken into account when rendering.
painter | : QPainter used to render the text |
text | : Text to render |
cell | : Cell the rendered text is rattached to |
cell_rect | : Rectangle delimiting the cell area |
|
private |
TitleBlockTemplate::renderTextCellDxf.
file_path | |
text | |
cell | |
x | |
y | |
w | |
h | |
color |
void TitleBlockTemplate::rowColsChanged | ( | ) |
TitleBlockTemplate::rowColsChanged Take care of consistency and span-related problematics when adding/moving/deleting rows and columns.
int TitleBlockTemplate::rowDimension | ( | int | i | ) |
int TitleBlockTemplate::rowsCount | ( | ) | const |
TitleBlockTemplate::rowsCount.
QList< int > TitleBlockTemplate::rowsHeights | ( | ) | const |
TitleBlockTemplate::rowsHeights.
|
protected |
TitleBlockTemplate::saveCell Export a specific cell as XML.
cell | : Cell to be exported as XML |
xml_element | : XML element under which the <cell> element will be attached |
save_empty | : If true, the cell will be saved even if it is an empty one |
|
protected |
TitleBlockTemplate::saveCells Export this template's cells as XML (without the grid-related information, usch as rows and cols)
xml_element | : XML element under which the <cell> elements will be attached |
|
protected |
TitleBlockTemplate::saveGrid Export this template's cells grid as XML.
xml_element | : XML element under which the <grid> element will be attached |
|
protected |
TitleBlockTemplate::saveInformation Export this template's extra information.
xml_element | : XML element under which extra informations will be attached |
|
protected |
TitleBlockTemplate::saveLogo Export a specific logo as XML.
logo_name | : Name of the logo to be exported |
xml_element | : XML element in which the logo will be exported |
|
protected |
TitleBlockTemplate::saveLogos Export this template's logos as XML.
xml_element | : XML Element under which the <logos> element will be attached |
bool TitleBlockTemplate::saveLogoToFile | ( | const QString & | logo_name, |
const QString & | filepath | ||
) |
TitleBlockTemplate::saveLogoToFile.
logo_name | : Name used to store the logo |
filepath | : Path the logo will be saved as |
bool TitleBlockTemplate::saveToXmlElement | ( | QDomElement & | xml_element | ) | const |
TitleBlockTemplate::saveToXmlElement Save the title block template as XML.
xml_element | : The XML element this title block template should be saved to. |
bool TitleBlockTemplate::saveToXmlFile | ( | const QString & | filepath | ) |
TitleBlockTemplate::saveToXmlFile Save the title block template into an XML file.
filepath | : The file path this title block template should be saved to. |
void TitleBlockTemplate::setAllSpans | ( | const QHash< TitleBlockCell *, QPair< int, int > > & | spans | ) |
TitleBlockTemplate::setAllSpans Restore a set of span parameters.
spans | : |
void TitleBlockTemplate::setColumnDimension | ( | int | i, |
const TitleBlockDimension & | dimension | ||
) |
TitleBlockTemplate::setColumnDimension Set the width of a column.
i | : column index |
dimension | : New width of the column at index i |
void TitleBlockTemplate::setInformation | ( | const QString & | info | ) |
TitleBlockTemplate::setInformation.
info | information to be attached to this template |
void TitleBlockTemplate::setLogoStorage | ( | const QString & | logo_name, |
const QString & | storage | ||
) |
TitleBlockTemplate::setLogoStorage Set the kind of storage for the logo_name logo.
logo_name | : Name of the logo which kind of storage is to be changed |
storage | : The kind of storage to use for the logo, e.g. "xml" or "base64". |
void TitleBlockTemplate::setRowDimension | ( | int | i, |
const TitleBlockDimension & | dimension | ||
) |
TitleBlockTemplate::setRowDimension Set the height of a row.
i | : row index |
dimension | : New height of the row at index i |
QSet< TitleBlockCell * > TitleBlockTemplate::spannedCells | ( | const TitleBlockCell * | given_cell, |
bool | ignore_span_state = false |
||
) | const |
TitleBlockTemplate::spannedCells.
given_cell | : cell A cell belonging to this title block template |
ignore_span_state | : (Optional, defaults to false) If true, will consider cells theoretically spanned (i.e. row_span and col_span attributes). Otherwise, will take span_state attribute into account. |
QList< TitleBlockCell * > TitleBlockTemplate::takeColumn | ( | int | i | ) |
TitleBlockTemplate::takeColumn Removes the column at index i.
i | : Index of the column to be removed |
QList< TitleBlockCell * > TitleBlockTemplate::takeRow | ( | int | i | ) |
TitleBlockTemplate::takeRow Removes the row at index i.
i | : Index of the column to be removed |
QSvgRenderer * TitleBlockTemplate::vectorLogo | ( | const QString & | logo_name | ) | const |
TitleBlockTemplate::vectorLogo.
logo_name | : Name of a vector logo embedded within this title block template. |
int TitleBlockTemplate::width | ( | int | total_width | ) |
total_width | : The total width initially planned for the rendering |
|
private |
bitmap_logos_ : Pixmaps for bitmap logos
|
private |
Cells grid.
|
private |
columns_width_ : columns widths –
|
private |
data_logos_ : Logos raw data
|
private |
|
private |
name_ : name identifying the Title Block Template within its parent collection
|
private |
registered_cells_ : Cells objects created rattached to this template, but not mandatorily used
|
private |
rows heights – simple integers
|
private |
storage_logos_ : Logos applied storage type (e.g. "xml" or "base64")
|
private |
type_logos_ : Logos types (e.g. "png", "jpeg", "svg")
|
private |
vector_logos_ : Rendered objects for vector logos