mirror of
https://github.com/qelectrotech/qelectrotech-source-mirror.git
synced 2025-12-17 20:50:34 +01:00
Title block can be displayed at right edge of diagram (work in progress)
git-svn-id: svn+ssh://svn.tuxfamily.org/svnroot/qet/qet/trunk@3827 bfdf4180-ca20-0410-9c96-a3a8aa849046
This commit is contained in:
@@ -23,6 +23,12 @@
|
||||
#include "qetapp.h"
|
||||
#include "math.h"
|
||||
#include "createdxf.h"
|
||||
#include "diagram.h"
|
||||
|
||||
#define MIN_COLUMN_COUNT 3
|
||||
#define MIN_ROW_COUNT 3
|
||||
#define MIN_COLUMN_WIDTH 5.0
|
||||
#define MIN_ROW_HEIGHT 5.0
|
||||
|
||||
/**
|
||||
Constructeur simple : construit une bordure en recuperant les dimensions
|
||||
@@ -67,31 +73,58 @@ qreal BorderTitleBlock::titleBlockHeight() const {
|
||||
}
|
||||
|
||||
/**
|
||||
@return Le nombre minimum de colonnes qu'un schema doit comporter
|
||||
*/
|
||||
int BorderTitleBlock::minNbColumns() {
|
||||
return(3);
|
||||
* @brief BorderTitleBlock::titleBlockRect
|
||||
* @return the rectangle of the titleblock in scene coordinate.
|
||||
*/
|
||||
QRectF BorderTitleBlock::titleBlockRect() const
|
||||
{
|
||||
if (m_edge == Qt::BottomEdge)
|
||||
return QRectF(diagram_rect_.bottomLeft(), QSize(diagram_rect_.width(), titleBlockHeight()));
|
||||
else
|
||||
return QRectF(diagram_rect_.topRight(), QSize(titleBlockHeight(), diagram_rect_.height()));
|
||||
}
|
||||
|
||||
/**
|
||||
@return la largeur minimale d'une colonne de schema
|
||||
*/
|
||||
qreal BorderTitleBlock::minColumnsWidth() {
|
||||
return(5.0);
|
||||
* @brief BorderTitleBlock::titleBlockRectForQPainter
|
||||
* @return The title block rect to use with the QPainter in the method draw.
|
||||
* The returned rect is alway horizontal (like displayed at the bottom of rect) only the top left change of pos
|
||||
* according to the edge where the title block need to be displayed.
|
||||
* Rect according to edge:
|
||||
* Bottom : top left is at the bottom left edge of the diagram rect.
|
||||
* Right : top left is at the bottom right of diagram rect. Befor use this rect you need to rotate the QPainter by -90°
|
||||
* for snap the rect at the right edge of diagram.
|
||||
*/
|
||||
QRectF BorderTitleBlock::titleBlockRectForQPainter() const
|
||||
{
|
||||
if (m_edge == Qt::BottomEdge) //Rect at bottom have same position and dimension of displayed rect
|
||||
return titleBlockRect();
|
||||
else
|
||||
return QRectF (diagram_rect_.bottomRight(), QSize(diagram_rect_.height(), titleBlockHeight()));
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
@return Le nombre minimum de lignes qu'un schema doit comporter
|
||||
*/
|
||||
int BorderTitleBlock::minNbRows() {
|
||||
return(2);
|
||||
* @brief BorderTitleBlock::borderRect
|
||||
* @return the bounding rectangle of diagram and titleblock.
|
||||
*/
|
||||
QRectF BorderTitleBlock::borderRect() const {
|
||||
return diagram_rect_ | titleBlockRect();
|
||||
}
|
||||
|
||||
/**
|
||||
@return la hauteur minimale d'une ligne de schema
|
||||
*/
|
||||
qreal BorderTitleBlock::minRowsHeight() {
|
||||
return(5.0);
|
||||
* @brief BorderTitleBlock::borderWidth
|
||||
* @return the border width
|
||||
*/
|
||||
qreal BorderTitleBlock::borderWidth() const {
|
||||
return borderRect().width();
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief BorderTitleBlock::borderHeight
|
||||
* @return the border height
|
||||
*/
|
||||
qreal BorderTitleBlock::borderHeight() const {
|
||||
return borderRect().height();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -162,7 +195,7 @@ void BorderTitleBlock::borderFromXml(const QDomElement &xml_elmt) {
|
||||
displayColumns(xml_elmt.attribute("displaycols") != "false");
|
||||
displayRows(xml_elmt.attribute("displayrows") != "false");
|
||||
|
||||
adjustTitleBlockToColumns();
|
||||
updateRectangles();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -177,20 +210,27 @@ TitleBlockProperties BorderTitleBlock::exportTitleBlock() {
|
||||
ip.filename = fileName();
|
||||
ip.folio = folio();
|
||||
ip.template_name = titleBlockTemplateName();
|
||||
ip.display_at = m_edge;
|
||||
ip.context = additional_fields_;
|
||||
|
||||
return(ip);
|
||||
}
|
||||
|
||||
/**
|
||||
@param ip les nouvelles proprietes du cartouche
|
||||
*/
|
||||
* @brief BorderTitleBlock::importTitleBlock
|
||||
* @param ip the new properties of titleblock
|
||||
*/
|
||||
void BorderTitleBlock::importTitleBlock(const TitleBlockProperties &ip) {
|
||||
setAuthor(ip.author);
|
||||
setDate(ip.date);
|
||||
setTitle(ip.title);
|
||||
setFileName(ip.filename);
|
||||
setFolio(ip.folio);
|
||||
if (m_edge != ip.display_at)
|
||||
{
|
||||
m_edge = ip.display_at;
|
||||
emit(displayChanged());
|
||||
}
|
||||
additional_fields_ = ip.context;
|
||||
|
||||
emit(needFolioData()); // Note: we expect additional data to be provided
|
||||
@@ -320,53 +360,48 @@ void BorderTitleBlock::displayBorder(bool db) {
|
||||
}
|
||||
|
||||
/**
|
||||
Methode recalculant les rectangles composant le cadre et le cartouche en
|
||||
fonction des attributs de taille
|
||||
*/
|
||||
void BorderTitleBlock::updateRectangles() {
|
||||
// rectangle delimitant le schema
|
||||
* @brief BorderTitleBlock::updateRectangles
|
||||
* This method update the diagram rect according to the value of rows and columns (number and size)
|
||||
*/
|
||||
void BorderTitleBlock::updateRectangles()
|
||||
{
|
||||
QRectF previous_diagram = diagram_rect_;
|
||||
diagram_rect_ = QRectF(0, 0, diagramWidth(), diagramHeight());
|
||||
diagram_rect_ = QRectF(Diagram::margin, Diagram::margin, diagramWidth(), diagramHeight());
|
||||
if (diagram_rect_ != previous_diagram) emit(borderChanged(previous_diagram, diagram_rect_));
|
||||
|
||||
// rectangles relatifs au cartouche
|
||||
titleblock_rect_ = QRectF(diagram_rect_.bottomLeft().x(), diagram_rect_.bottomLeft().y(), titleBlockWidth(), titleBlockHeight());
|
||||
}
|
||||
|
||||
/**
|
||||
Dessine le cadre et le cartouche
|
||||
@param qp QPainter a utiliser pour dessiner le cadre et le cartouche
|
||||
@param x Abscisse du cadre
|
||||
@param y Ordonnee du cadre
|
||||
*/
|
||||
void BorderTitleBlock::draw(QPainter *qp, qreal x, qreal y) {
|
||||
// translate tous les rectangles
|
||||
diagram_rect_ .translate(x, y);
|
||||
titleblock_rect_ .translate(x, y);
|
||||
* @brief BorderTitleBlock::draw
|
||||
* Draw the border and the titleblock.
|
||||
* @param painter, QPainter to use for draw this.
|
||||
*/
|
||||
void BorderTitleBlock::draw(QPainter *painter)
|
||||
{
|
||||
//Set the QPainter
|
||||
painter -> save();
|
||||
QPen pen(Qt::black);
|
||||
pen.setCosmetic(true);
|
||||
painter -> setPen(pen);
|
||||
painter -> setBrush(Qt::NoBrush);
|
||||
|
||||
// prepare le QPainter
|
||||
qp -> save();
|
||||
qp -> setPen(Qt::black);
|
||||
qp -> setBrush(Qt::NoBrush);
|
||||
//Draw the borer
|
||||
if (display_border_) painter -> drawRect(diagram_rect_);
|
||||
|
||||
// dessine le cadre
|
||||
if (display_border_) qp -> drawRect(diagram_rect_);
|
||||
painter -> setFont(QETApp::diagramTextsFont());
|
||||
|
||||
qp -> setFont(QETApp::diagramTextsFont());
|
||||
|
||||
// dessine la case vide qui apparait des qu'il y a un entete
|
||||
//Draw the empty case at the top left of diagram when there is header
|
||||
if (display_border_ && (display_columns_ || display_rows_)) {
|
||||
qp -> setBrush(Qt::white);
|
||||
painter -> setBrush(Qt::white);
|
||||
QRectF first_rectangle(
|
||||
diagram_rect_.topLeft().x(),
|
||||
diagram_rect_.topLeft().y(),
|
||||
rows_header_width_,
|
||||
columns_header_height_
|
||||
);
|
||||
qp -> drawRect(first_rectangle);
|
||||
painter -> drawRect(first_rectangle);
|
||||
}
|
||||
|
||||
// dessine la numerotation des colonnes
|
||||
//Draw the nums of columns
|
||||
if (display_border_ && display_columns_) {
|
||||
for (int i = 1 ; i <= columns_count_ ; ++ i) {
|
||||
QRectF numbered_rectangle = QRectF(
|
||||
@@ -375,12 +410,12 @@ void BorderTitleBlock::draw(QPainter *qp, qreal x, qreal y) {
|
||||
columns_width_,
|
||||
columns_header_height_
|
||||
);
|
||||
qp -> drawRect(numbered_rectangle);
|
||||
qp -> drawText(numbered_rectangle, Qt::AlignVCenter | Qt::AlignCenter, QString("%1").arg(i));
|
||||
painter -> drawRect(numbered_rectangle);
|
||||
painter -> drawText(numbered_rectangle, Qt::AlignVCenter | Qt::AlignCenter, QString("%1").arg(i));
|
||||
}
|
||||
}
|
||||
|
||||
// dessine la numerotation des lignes
|
||||
//Draw the nums of rows
|
||||
if (display_border_ && display_rows_) {
|
||||
QString row_string("A");
|
||||
for (int i = 1 ; i <= rows_count_ ; ++ i) {
|
||||
@@ -390,24 +425,32 @@ void BorderTitleBlock::draw(QPainter *qp, qreal x, qreal y) {
|
||||
rows_header_width_,
|
||||
rows_height_
|
||||
);
|
||||
qp -> drawRect(lettered_rectangle);
|
||||
qp -> drawText(lettered_rectangle, Qt::AlignVCenter | Qt::AlignCenter, row_string);
|
||||
painter -> drawRect(lettered_rectangle);
|
||||
painter -> drawText(lettered_rectangle, Qt::AlignVCenter | Qt::AlignCenter, row_string);
|
||||
row_string = incrementLetters(row_string);
|
||||
}
|
||||
}
|
||||
|
||||
// render the titleblock, using the TitleBlockTemplate object
|
||||
if (display_titleblock_) {
|
||||
qp -> translate(titleblock_rect_.topLeft());
|
||||
titleblock_template_renderer_ -> render(qp, titleblock_rect_.width());
|
||||
qp -> translate(-titleblock_rect_.topLeft());
|
||||
QRectF tbt_rect = titleBlockRectForQPainter();
|
||||
if (m_edge == Qt::BottomEdge)
|
||||
{
|
||||
painter -> translate(tbt_rect.topLeft());
|
||||
titleblock_template_renderer_ -> render(painter, tbt_rect.width());
|
||||
painter -> translate(-tbt_rect.topLeft());
|
||||
}
|
||||
else
|
||||
{
|
||||
painter->translate(tbt_rect.topLeft());
|
||||
painter->rotate(-90);
|
||||
titleblock_template_renderer_ -> render(painter, tbt_rect.width());
|
||||
painter->rotate(90);
|
||||
painter -> translate(-tbt_rect.topLeft());
|
||||
}
|
||||
}
|
||||
|
||||
qp -> restore();
|
||||
|
||||
// annule la translation des rectangles
|
||||
diagram_rect_ .translate(-x, -y);
|
||||
titleblock_rect_ .translate(-x, -y);
|
||||
painter -> restore();
|
||||
}
|
||||
|
||||
void BorderTitleBlock::drawDxf(int width, int height, bool keep_aspect_ratio, QString &file_path, int color) {
|
||||
@@ -471,7 +514,8 @@ void BorderTitleBlock::drawDxf(int width, int height, bool keep_aspect_ratio, QS
|
||||
// render the titleblock, using the TitleBlockTemplate object
|
||||
if (display_titleblock_) {
|
||||
//qp -> translate(titleblock_rect_.topLeft());
|
||||
titleblock_template_renderer_ -> renderDxf(titleblock_rect_, titleblock_rect_.width(), file_path, color);
|
||||
QRectF rect = titleBlockRect();
|
||||
titleblock_template_renderer_ -> renderDxf(rect, rect.width(), file_path, color);
|
||||
//qp -> translate(-titleblock_rect_.topLeft());
|
||||
}
|
||||
|
||||
@@ -483,38 +527,6 @@ void BorderTitleBlock::drawDxf(int width, int height, bool keep_aspect_ratio, QS
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
Ajoute une colonne.
|
||||
*/
|
||||
void BorderTitleBlock::addColumn() {
|
||||
setColumnsCount(columnsCount() + 1);
|
||||
}
|
||||
|
||||
/**
|
||||
Enleve une colonne sans passer sous le minimum requis.
|
||||
@see minNbColumns()
|
||||
*/
|
||||
void BorderTitleBlock::removeColumn() {
|
||||
setColumnsCount(columnsCount() - 1);
|
||||
}
|
||||
|
||||
/**
|
||||
Ajoute une ligne.
|
||||
*/
|
||||
void BorderTitleBlock::addRow() {
|
||||
setRowsCount(rowsCount() + 1);
|
||||
}
|
||||
|
||||
/**
|
||||
Enleve une ligne sans passer sous le minimum requis.
|
||||
@see minNbRows()
|
||||
*/
|
||||
void BorderTitleBlock::removeRow() {
|
||||
setRowsCount(rowsCount() - 1);
|
||||
}
|
||||
|
||||
/**
|
||||
Permet de changer le nombre de colonnes.
|
||||
Si ce nombre de colonnes est inferieur au minimum requis, c'est ce minimum
|
||||
@@ -524,8 +536,8 @@ void BorderTitleBlock::removeRow() {
|
||||
*/
|
||||
void BorderTitleBlock::setColumnsCount(int nb_c) {
|
||||
if (nb_c == columnsCount()) return;
|
||||
columns_count_ = qMax(minNbColumns(), nb_c);
|
||||
setTitleBlockWidth(diagramWidth());
|
||||
columns_count_ = qMax(MIN_COLUMN_COUNT , nb_c);
|
||||
updateRectangles();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -537,8 +549,8 @@ void BorderTitleBlock::setColumnsCount(int nb_c) {
|
||||
*/
|
||||
void BorderTitleBlock::setColumnsWidth(const qreal &new_cw) {
|
||||
if (new_cw == columnsWidth()) return;
|
||||
columns_width_ = qMax(minColumnsWidth(), new_cw);
|
||||
setTitleBlockWidth(diagramWidth());
|
||||
columns_width_ = qMax(MIN_COLUMN_WIDTH , new_cw);
|
||||
updateRectangles();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -560,8 +572,7 @@ void BorderTitleBlock::setColumnsHeaderHeight(const qreal &new_chh) {
|
||||
*/
|
||||
void BorderTitleBlock::setRowsCount(int nb_r) {
|
||||
if (nb_r == rowsCount()) return;
|
||||
rows_count_ = qMax(minNbRows(), nb_r);
|
||||
setTitleBlockWidth(diagramWidth());
|
||||
rows_count_ = qMax(MIN_ROW_COUNT, nb_r);
|
||||
updateRectangles();
|
||||
}
|
||||
|
||||
@@ -574,7 +585,7 @@ void BorderTitleBlock::setRowsCount(int nb_r) {
|
||||
*/
|
||||
void BorderTitleBlock::setRowsHeight(const qreal &new_rh) {
|
||||
if (new_rh == rowsHeight()) return;
|
||||
rows_height_ = qMax(minRowsHeight(), new_rh);
|
||||
rows_height_ = qMax(MIN_ROW_HEIGHT, new_rh);
|
||||
updateRectangles();
|
||||
}
|
||||
|
||||
@@ -597,24 +608,6 @@ void BorderTitleBlock::setDiagramHeight(const qreal &height) {
|
||||
setRowsCount(qRound(ceil(height / rows_height_)));
|
||||
}
|
||||
|
||||
/**
|
||||
Change la largeur du cartouche. Cette largeur sera restreinte a celle du
|
||||
schema.
|
||||
*/
|
||||
void BorderTitleBlock::setTitleBlockWidth(const qreal &new_iw) {
|
||||
titleblock_width_ = qMin(diagramWidth(), new_iw);
|
||||
updateRectangles();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Ajuste la largeur du cartouche de facon a ce que celui-ci soit aussi large
|
||||
que le schema
|
||||
*/
|
||||
void BorderTitleBlock::adjustTitleBlockToColumns() {
|
||||
setTitleBlockWidth(diagramWidth());
|
||||
}
|
||||
|
||||
/**
|
||||
@param pos Position cartesienne (ex : 10.3, 45.2) a transformer en position
|
||||
dans la grille (ex : B2)
|
||||
|
||||
@@ -31,10 +31,10 @@ class TitleBlockTemplateRenderer;
|
||||
This class represents the border and the titleblock which frame a
|
||||
particular electric diagram.
|
||||
*/
|
||||
class BorderTitleBlock : public QObject {
|
||||
class BorderTitleBlock : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
// constructors, destructor
|
||||
public:
|
||||
BorderTitleBlock(QObject * = 0);
|
||||
virtual ~BorderTitleBlock();
|
||||
@@ -42,18 +42,13 @@ class BorderTitleBlock : public QObject {
|
||||
private:
|
||||
BorderTitleBlock(const BorderTitleBlock &);
|
||||
|
||||
// methods
|
||||
//METHODS
|
||||
public:
|
||||
static int minNbColumns();
|
||||
static qreal minColumnsWidth();
|
||||
static int minNbRows();
|
||||
static qreal minRowsHeight();
|
||||
|
||||
void draw(QPainter *, qreal = 0.0, qreal = 0.0);
|
||||
void draw(QPainter *painter);
|
||||
void drawDxf(int, int, bool, QString &, int);
|
||||
|
||||
// methods to get dimensions
|
||||
// columns
|
||||
//METHODS TO GET DIMENSION
|
||||
//COLUMNS
|
||||
/// @return the number of columns
|
||||
int columnsCount() const { return(columns_count_); }
|
||||
/// @return the columns width, in pixels
|
||||
@@ -63,7 +58,7 @@ class BorderTitleBlock : public QObject {
|
||||
/// @return the column headers height, in pixels
|
||||
qreal columnsHeaderHeight() const { return(columns_header_height_); }
|
||||
|
||||
// rows
|
||||
//ROWS
|
||||
/// @return the number of rows
|
||||
int rowsCount() const { return(rows_count_); }
|
||||
/// @return the rows height, in pixels
|
||||
@@ -80,15 +75,16 @@ class BorderTitleBlock : public QObject {
|
||||
qreal diagramHeight() const { return(rowsTotalHeight() + columnsHeaderHeight()); }
|
||||
|
||||
// title block
|
||||
/// @return the title block width
|
||||
qreal titleBlockWidth() const { return(titleblock_width_); }
|
||||
qreal titleBlockHeight() const;
|
||||
|
||||
// border + title block
|
||||
/// @return the border width
|
||||
qreal borderWidth() const { return(diagramWidth()); }
|
||||
/// @return the border height
|
||||
qreal borderHeight() const { return(diagramHeight() + titleBlockHeight()); }
|
||||
QRectF titleBlockRect () const;
|
||||
private:
|
||||
QRectF titleBlockRectForQPainter () const;
|
||||
|
||||
public:
|
||||
QRectF borderRect () const;
|
||||
qreal borderWidth () const;
|
||||
qreal borderHeight() const;
|
||||
|
||||
// methods to get title block basic data
|
||||
/// @return the value of the title block "Author" field
|
||||
@@ -113,10 +109,6 @@ class BorderTitleBlock : public QObject {
|
||||
bool borderIsDisplayed() const { return(display_border_); }
|
||||
|
||||
// methods to set dimensions
|
||||
void addColumn();
|
||||
void addRow();
|
||||
void removeColumn();
|
||||
void removeRow();
|
||||
void setColumnsCount(int);
|
||||
void setRowsCount(int);
|
||||
void setColumnsWidth(const qreal &);
|
||||
@@ -124,8 +116,6 @@ class BorderTitleBlock : public QObject {
|
||||
void setColumnsHeaderHeight(const qreal &);
|
||||
void setRowsHeaderWidth(const qreal &);
|
||||
void setDiagramHeight(const qreal &);
|
||||
void setTitleBlockWidth(const qreal &);
|
||||
void adjustTitleBlockToColumns();
|
||||
|
||||
DiagramPosition convertPosition(const QPointF &);
|
||||
|
||||
@@ -218,6 +208,7 @@ class BorderTitleBlock : public QObject {
|
||||
int folio_total_;
|
||||
QString btb_filename_;
|
||||
DiagramContext additional_fields_;
|
||||
Qt::Edge m_edge;
|
||||
|
||||
// border dimensions (rows and columns)
|
||||
// columns: number and dimensions
|
||||
@@ -231,12 +222,10 @@ class BorderTitleBlock : public QObject {
|
||||
qreal rows_header_width_;
|
||||
|
||||
// title block dimensions
|
||||
qreal titleblock_width_;
|
||||
qreal titleblock_height_;
|
||||
|
||||
// rectangles used for drawing operations
|
||||
QRectF diagram_rect_;
|
||||
QRectF titleblock_rect_;
|
||||
|
||||
// display options
|
||||
bool display_titleblock_;
|
||||
|
||||
@@ -152,7 +152,7 @@ void Diagram::drawBackground(QPainter *p, const QRectF &r) {
|
||||
p -> drawPoints(points);
|
||||
}
|
||||
|
||||
if (use_border_) border_and_titleblock.draw(p, margin, margin);
|
||||
if (use_border_) border_and_titleblock.draw(p);
|
||||
p -> restore();
|
||||
}
|
||||
|
||||
@@ -1074,16 +1074,8 @@ void Diagram::invertSelection() {
|
||||
* @return The rectangle (coordinates relative to the scene)
|
||||
* delimiting the edge of the diagram
|
||||
*/
|
||||
QRectF Diagram::border() const
|
||||
{
|
||||
return(
|
||||
QRectF(
|
||||
margin,
|
||||
margin,
|
||||
border_and_titleblock.borderWidth(),
|
||||
border_and_titleblock.borderHeight()
|
||||
)
|
||||
);
|
||||
QRectF Diagram::border() const {
|
||||
return border_and_titleblock.borderRect();
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -112,7 +112,7 @@ void DiagramFolioList::drawBackground(QPainter *p, const QRectF &r)
|
||||
diagram_list[i] -> border_and_titleblock.date().toString(Qt::SystemLocaleShortDate));
|
||||
}
|
||||
|
||||
border_and_titleblock.draw(p, margin, margin);
|
||||
border_and_titleblock.draw(p);
|
||||
p -> restore();
|
||||
}
|
||||
|
||||
|
||||
@@ -1180,14 +1180,6 @@ void DiagramView::mouseDoubleClickEvent(QMouseEvent *e) {
|
||||
|
||||
BorderTitleBlock &bi = scene -> border_and_titleblock;
|
||||
|
||||
//Get the rectangle of the titleblock
|
||||
QRectF titleblock_rect(
|
||||
Diagram::margin,
|
||||
Diagram::margin + bi.diagramHeight(),
|
||||
bi.titleBlockWidth(),
|
||||
bi.titleBlockHeight()
|
||||
);
|
||||
|
||||
// Get the rectangle of the header column
|
||||
QRectF columns_rect(
|
||||
Diagram::margin,
|
||||
@@ -1207,7 +1199,7 @@ void DiagramView::mouseDoubleClickEvent(QMouseEvent *e) {
|
||||
//Get the click pos on the diagram
|
||||
QPointF click_pos = viewportTransform().inverted().map(e -> pos());
|
||||
|
||||
if (titleblock_rect.contains(click_pos) || columns_rect.contains(click_pos) || rows_rect.contains(click_pos)) {
|
||||
if (bi.titleBlockRect().contains(click_pos) || columns_rect.contains(click_pos) || rows_rect.contains(click_pos)) {
|
||||
e->accept();
|
||||
editDiagramProperties();
|
||||
return;
|
||||
|
||||
@@ -25,7 +25,8 @@
|
||||
*/
|
||||
TitleBlockProperties::TitleBlockProperties() :
|
||||
date(),
|
||||
useDate(UseDateValue)
|
||||
useDate(UseDateValue),
|
||||
display_at(Qt::BottomEdge)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -47,7 +48,8 @@ bool TitleBlockProperties::operator==(const TitleBlockProperties &ip) {
|
||||
ip.filename == filename &&\
|
||||
ip.folio == folio &&\
|
||||
ip.template_name == template_name &&\
|
||||
ip.context == context
|
||||
ip.context == context &&\
|
||||
ip.display_at == display_at
|
||||
);
|
||||
}
|
||||
|
||||
@@ -70,6 +72,7 @@ void TitleBlockProperties::toXml(QDomElement &e) const {
|
||||
e.setAttribute("filename", filename);
|
||||
e.setAttribute("folio", folio);
|
||||
e.setAttribute("date", exportDate());
|
||||
e.setAttribute("displayAt", (display_at == Qt::BottomEdge? "bottom" : "right"));
|
||||
if (!template_name.isEmpty()) {
|
||||
e.setAttribute("titleblocktemplate", template_name);
|
||||
}
|
||||
@@ -92,6 +95,7 @@ void TitleBlockProperties::fromXml(const QDomElement &e) {
|
||||
if (e.hasAttribute("filename")) filename = e.attribute("filename");
|
||||
if (e.hasAttribute("folio")) folio = e.attribute("folio");
|
||||
if (e.hasAttribute("date")) setDateFromString(e.attribute("date"));
|
||||
if (e.hasAttribute("displayAt")) display_at = (e.attribute("displayAt") == "bottom" ? Qt::BottomEdge : Qt::RightEdge);
|
||||
|
||||
// reads the template used to render the title block
|
||||
if (e.hasAttribute("titleblocktemplate")) template_name = e.attribute("titleblocktemplate");
|
||||
@@ -114,6 +118,7 @@ void TitleBlockProperties::toSettings(QSettings &settings, const QString &prefix
|
||||
settings.setValue(prefix + "filename", filename);
|
||||
settings.setValue(prefix + "folio", folio);
|
||||
settings.setValue(prefix + "date", exportDate());
|
||||
settings.setValue(prefix + "displayAt", (display_at == Qt::BottomEdge? "bottom" : "right"));
|
||||
context.toSettings(settings, prefix + "properties");
|
||||
}
|
||||
|
||||
@@ -128,6 +133,7 @@ void TitleBlockProperties::fromSettings(QSettings &settings, const QString &pref
|
||||
filename = settings.value(prefix + "filename").toString();
|
||||
folio = settings.value(prefix + "folio", "%id/%total").toString();
|
||||
setDateFromString(settings.value(prefix + "date").toString());
|
||||
display_at = (settings.value(prefix + "displayAt", QVariant("bottom")).toString() == "bottom" ? Qt::BottomEdge : Qt::RightEdge);
|
||||
context.fromSettings(settings, prefix + "properties");
|
||||
}
|
||||
|
||||
|
||||
@@ -55,6 +55,7 @@ class TitleBlockProperties {
|
||||
DateManagement useDate; ///< Wheter to use the date attribute
|
||||
QString template_name; ///< Name of the template used to render the title block - an empty string means "the default template provided by the application"
|
||||
DiagramContext context; ///< Container for the additional, user-defined fields
|
||||
Qt::Edge display_at; ///< Edge to display the titleblock
|
||||
|
||||
private:
|
||||
QString exportDate() const;
|
||||
|
||||
@@ -1228,8 +1228,11 @@ void TitleBlockTemplate::render(QPainter &painter, const DiagramContext &diagram
|
||||
QList<int> widths = columnsWidth(titleblock_width);
|
||||
int titleblock_height = height();
|
||||
|
||||
// prepare the QPainter
|
||||
painter.setPen(Qt::black);
|
||||
painter.save();
|
||||
//Setup the QPainter
|
||||
QPen pen(Qt::black);
|
||||
pen.setCosmetic(true);
|
||||
painter.setPen(pen);
|
||||
painter.setBrush(Qt::white);
|
||||
|
||||
// draw the titleblock border
|
||||
@@ -1256,6 +1259,7 @@ void TitleBlockTemplate::render(QPainter &painter, const DiagramContext &diagram
|
||||
renderCell(painter, *cells_[i][j], diagram_context, cell_rect);
|
||||
}
|
||||
}
|
||||
painter.restore();
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -76,6 +76,7 @@ void TitleBlockPropertiesWidget::setProperties(const TitleBlockProperties &prope
|
||||
ui -> m_author_le -> setText (properties.author);
|
||||
ui -> m_file_le -> setText (properties.filename);
|
||||
ui -> m_folio_le -> setText (properties.folio);
|
||||
ui -> m_display_at_cb -> setCurrentIndex(properties.display_at == Qt::BottomEdge ? 0 : 1);
|
||||
|
||||
//About date
|
||||
ui -> m_date_now_pb -> setDisabled(true);
|
||||
@@ -126,6 +127,7 @@ TitleBlockProperties TitleBlockPropertiesWidget::properties() const {
|
||||
prop.author = ui -> m_author_le -> text();
|
||||
prop.filename = ui -> m_file_le -> text();
|
||||
prop.folio = ui -> m_folio_le -> text();
|
||||
prop.display_at = ui -> m_display_at_cb -> currentIndex() == 0 ? Qt::BottomEdge : Qt::RightEdge;
|
||||
|
||||
if (ui->m_no_date_rb->isChecked()) {
|
||||
prop.useDate = TitleBlockProperties::UseDateValue;
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>528</width>
|
||||
<height>387</height>
|
||||
<height>439</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="sizePolicy">
|
||||
@@ -108,10 +108,10 @@
|
||||
<layout class="QVBoxLayout" name="verticalLayout_2">
|
||||
<item>
|
||||
<layout class="QGridLayout" name="gridLayout_4">
|
||||
<item row="5" column="1">
|
||||
<widget class="QLabel" name="label_6">
|
||||
<property name="text">
|
||||
<string>Folio :</string>
|
||||
<item row="5" column="2">
|
||||
<widget class="QLineEdit" name="m_folio_le">
|
||||
<property name="toolTip">
|
||||
<string>Disponible en tant que %folio pour les modèles de cartouches</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
@@ -122,10 +122,28 @@
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="4" column="2">
|
||||
<widget class="QLineEdit" name="m_file_le">
|
||||
<property name="toolTip">
|
||||
<string>Disponible en tant que %filename pour les modèles de cartouches</string>
|
||||
<item row="7" column="1">
|
||||
<widget class="QLabel" name="label">
|
||||
<property name="text">
|
||||
<string>Afficher :</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="6" column="2">
|
||||
<widget class="QLabel" name="label_7">
|
||||
<property name="frameShape">
|
||||
<enum>QFrame::NoFrame</enum>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Les variables suivantes sont utilisables dans le champ Folio :
|
||||
- %id : numéro du schéma courant dans le projet
|
||||
- %total : nombre total de schémas dans le projet</string>
|
||||
</property>
|
||||
<property name="scaledContents">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
@@ -181,45 +199,6 @@
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item row="1" column="1">
|
||||
<widget class="QLabel" name="label_2">
|
||||
<property name="text">
|
||||
<string>Titre :</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="4" column="1">
|
||||
<widget class="QLabel" name="label_5">
|
||||
<property name="text">
|
||||
<string>Fichier :</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="5" column="2">
|
||||
<widget class="QLineEdit" name="m_folio_le">
|
||||
<property name="toolTip">
|
||||
<string>Disponible en tant que %folio pour les modèles de cartouches</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="6" column="2">
|
||||
<widget class="QLabel" name="label_7">
|
||||
<property name="frameShape">
|
||||
<enum>QFrame::NoFrame</enum>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Les variables suivantes sont utilisables dans le champ Folio :
|
||||
- %id : numéro du schéma courant dans le projet
|
||||
- %total : nombre total de schémas dans le projet</string>
|
||||
</property>
|
||||
<property name="scaledContents">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="1">
|
||||
<widget class="QLabel" name="label_4">
|
||||
<property name="text">
|
||||
@@ -230,10 +209,10 @@
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="2">
|
||||
<widget class="QLineEdit" name="m_author_le">
|
||||
<property name="toolTip">
|
||||
<string>Disponible en tant que %author pour les modèles de cartouches</string>
|
||||
<item row="4" column="1">
|
||||
<widget class="QLabel" name="label_5">
|
||||
<property name="text">
|
||||
<string>Fichier :</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
@@ -244,6 +223,48 @@
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="1">
|
||||
<widget class="QLabel" name="label_2">
|
||||
<property name="text">
|
||||
<string>Titre :</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="2">
|
||||
<widget class="QLineEdit" name="m_author_le">
|
||||
<property name="toolTip">
|
||||
<string>Disponible en tant que %author pour les modèles de cartouches</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="5" column="1">
|
||||
<widget class="QLabel" name="label_6">
|
||||
<property name="text">
|
||||
<string>Folio :</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="4" column="2">
|
||||
<widget class="QLineEdit" name="m_file_le">
|
||||
<property name="toolTip">
|
||||
<string>Disponible en tant que %filename pour les modèles de cartouches</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="7" column="2">
|
||||
<widget class="QComboBox" name="m_display_at_cb">
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>Bas</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>Droite (expérimental)</string>
|
||||
</property>
|
||||
</item>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
|
||||
Reference in New Issue
Block a user