Translate documentation + Fix indentation

This commit is contained in:
Simon De Backer
2020-08-02 20:29:06 +02:00
parent d4d364cfde
commit effc86e72c

View File

@@ -50,7 +50,10 @@ int Diagram::xKeyGridFine = 1;
int Diagram::yKeyGridFine = 1; int Diagram::yKeyGridFine = 1;
const qreal Diagram::margin = 5.0; const qreal Diagram::margin = 5.0;
// static variable to keep track of present background color of the diagram. /**
@brief Diagram::background_color
static variable to keep track of present background color of the diagram.
*/
QColor Diagram::background_color = Qt::white; QColor Diagram::background_color = Qt::white;
/** /**
@@ -111,8 +114,8 @@ Diagram::Diagram(QETProject *project) :
} }
/** /**
* @brief Diagram::~Diagram @brief Diagram::~Diagram
* Destructor Destructor
*/ */
Diagram::~Diagram() Diagram::~Diagram()
{ {
@@ -141,18 +144,26 @@ Diagram::~Diagram()
} }
/** /**
Dessine l'arriere-plan du schema, cad la grille. @brief Diagram::drawBackground
@param p Le QPainter a utiliser pour dessiner Draw the background of the diagram, ie the grid.
@param r Le rectangle de la zone a dessiner \~French Dessine l'arriere-plan du schema, cad la grille.
\~ @param p :
The QPainter to use for drawing
\~French Le QPainter a utiliser pour dessiner
\~ @param r :
The rectangle of the area to be drawn
\~French Le rectangle de la zone a dessiner
*/ */
void Diagram::drawBackground(QPainter *p, const QRectF &r) { void Diagram::drawBackground(QPainter *p, const QRectF &r) {
p -> save(); p -> save();
// disable all antialiasing, except for text
// desactive tout antialiasing, sauf pour le texte // desactive tout antialiasing, sauf pour le texte
p -> setRenderHint(QPainter::Antialiasing, false); p -> setRenderHint(QPainter::Antialiasing, false);
p -> setRenderHint(QPainter::TextAntialiasing, true); p -> setRenderHint(QPainter::TextAntialiasing, true);
p -> setRenderHint(QPainter::SmoothPixmapTransform, false); p -> setRenderHint(QPainter::SmoothPixmapTransform, false);
// draw a white background
// dessine un fond blanc // dessine un fond blanc
p -> setPen(Qt::NoPen); p -> setPen(Qt::NoPen);
//set brush color to present background color. //set brush color to present background color.
@@ -160,8 +171,11 @@ void Diagram::drawBackground(QPainter *p, const QRectF &r) {
p -> drawRect(r); p -> drawRect(r);
if (draw_grid_) { if (draw_grid_) {
//Draw the point of the grid /* Draw the point of the grid
// if background color is black, then grid spots shall be white, else they shall be black in color. * if background color is black,
* then grid spots shall be white,
* else they shall be black in color.
*/
QPen pen; QPen pen;
Diagram::background_color == Qt::black? pen.setColor(Qt::white) : pen.setColor(Qt::black); Diagram::background_color == Qt::black? pen.setColor(Qt::white) : pen.setColor(Qt::black);
pen.setCosmetic(true); pen.setCosmetic(true);
@@ -169,7 +183,8 @@ void Diagram::drawBackground(QPainter *p, const QRectF &r) {
p -> setBrush(Qt::NoBrush); p -> setBrush(Qt::NoBrush);
//If user allow zoom out beyond of folio, we draw grid outside of border. // If user allow zoom out beyond of folio,
// we draw grid outside of border.
QSettings settings; QSettings settings;
int xGrid = settings.value("diagrameditor/Xgrid", Diagram::xGrid).toInt(); int xGrid = settings.value("diagrameditor/Xgrid", Diagram::xGrid).toInt();
int yGrid = settings.value("diagrameditor/Ygrid", Diagram::yGrid).toInt(); int yGrid = settings.value("diagrameditor/Ygrid", Diagram::yGrid).toInt();
@@ -199,9 +214,9 @@ void Diagram::drawBackground(QPainter *p, const QRectF &r) {
} }
/** /**
* @brief Diagram::mouseDoubleClickEvent @brief Diagram::mouseDoubleClickEvent
* This event is managed by diagram event interface if any. This event is managed by diagram event interface if any.
* @param event : @param event :
*/ */
void Diagram::mouseDoubleClickEvent(QGraphicsSceneMouseEvent *event) void Diagram::mouseDoubleClickEvent(QGraphicsSceneMouseEvent *event)
{ {
@@ -218,9 +233,9 @@ void Diagram::mouseDoubleClickEvent(QGraphicsSceneMouseEvent *event)
} }
/** /**
* @brief Diagram::mousePressEvent @brief Diagram::mousePressEvent
* This event is managed by diagram event interface if any. This event is managed by diagram event interface if any.
* @param event @param event
*/ */
void Diagram::mousePressEvent(QGraphicsSceneMouseEvent *event) void Diagram::mousePressEvent(QGraphicsSceneMouseEvent *event)
{ {
@@ -237,9 +252,9 @@ void Diagram::mousePressEvent(QGraphicsSceneMouseEvent *event)
} }
/** /**
* @brief Diagram::mouseMoveEvent @brief Diagram::mouseMoveEvent
* This event is managed by diagram event interface if any. This event is managed by diagram event interface if any.
* @param event @param event
*/ */
void Diagram::mouseMoveEvent(QGraphicsSceneMouseEvent *event) void Diagram::mouseMoveEvent(QGraphicsSceneMouseEvent *event)
{ {
@@ -256,9 +271,9 @@ void Diagram::mouseMoveEvent(QGraphicsSceneMouseEvent *event)
} }
/** /**
* @brief Diagram::mouseReleaseEvent @brief Diagram::mouseReleaseEvent
* This event is managed by diagram event interface if any. This event is managed by diagram event interface if any.
* @param event @param event
*/ */
void Diagram::mouseReleaseEvent(QGraphicsSceneMouseEvent *event) void Diagram::mouseReleaseEvent(QGraphicsSceneMouseEvent *event)
{ {
@@ -275,9 +290,9 @@ void Diagram::mouseReleaseEvent(QGraphicsSceneMouseEvent *event)
} }
/** /**
* @brief Diagram::wheelEvent @brief Diagram::wheelEvent
* This event is managed by diagram event interface if any. This event is managed by diagram event interface if any.
* @param event @param event
*/ */
void Diagram::wheelEvent(QGraphicsSceneWheelEvent *event) void Diagram::wheelEvent(QGraphicsSceneWheelEvent *event)
{ {
@@ -294,10 +309,10 @@ void Diagram::wheelEvent(QGraphicsSceneWheelEvent *event)
} }
/** /**
* @brief Diagram::keyPressEvent @brief Diagram::keyPressEvent
* This event is managed by diagram event interface if any. This event is managed by diagram event interface if any.
* Else move selected elements Else move selected elements
* @param e @param e
*/ */
void Diagram::keyPressEvent(QKeyEvent *event) void Diagram::keyPressEvent(QKeyEvent *event)
{ {
@@ -427,10 +442,10 @@ void Diagram::keyPressEvent(QKeyEvent *event)
} }
/** /**
* @brief Diagram::keyReleaseEvent @brief Diagram::keyReleaseEvent
* This event is managed by diagram event interface if any. This event is managed by diagram event interface if any.
* Else move selected element Else move selected element
* @param e @param e
*/ */
void Diagram::keyReleaseEvent(QKeyEvent *e) void Diagram::keyReleaseEvent(QKeyEvent *e)
{ {
@@ -445,7 +460,11 @@ void Diagram::keyReleaseEvent(QKeyEvent *e)
bool transmit_event = true; bool transmit_event = true;
if (!isReadOnly()) { if (!isReadOnly()) {
// detecte le relachement d'une touche de direction ( = deplacement d'elements) /* detects the release of a direction key
* (= movement of elements)
* detecte le relachement d'une touche de direction
* ( = deplacement d'elements)
*/
if ( if (
(e -> key() == Qt::Key_Left || e -> key() == Qt::Key_Right || (e -> key() == Qt::Key_Left || e -> key() == Qt::Key_Right ||
e -> key() == Qt::Key_Up || e -> key() == Qt::Key_Down) && e -> key() == Qt::Key_Up || e -> key() == Qt::Key_Down) &&
@@ -462,20 +481,20 @@ void Diagram::keyReleaseEvent(QKeyEvent *e)
} }
/** /**
* @brief Diagram::uuid @brief Diagram::uuid
* @return the uuid of this diagram @return the uuid of this diagram
*/ */
QUuid Diagram::uuid() { QUuid Diagram::uuid() {
return m_uuid; return m_uuid;
} }
/** /**
* @brief Diagram::setEventInterface @brief Diagram::setEventInterface
* Set event_interface has current interface. Set event_interface has current interface.
* Diagram become the ownership of event_interface Diagram become the ownership of event_interface
* If there is a previous interface, they will be delete before If there is a previous interface, they will be delete before
* and call init() to the new interface. and call init() to the new interface.
* @param event_interface @param event_interface
*/ */
void Diagram::setEventInterface(DiagramEventInterface *event_interface) void Diagram::setEventInterface(DiagramEventInterface *event_interface)
{ {
@@ -494,8 +513,8 @@ void Diagram::setEventInterface(DiagramEventInterface *event_interface)
} }
/** /**
* @brief Diagram::clearEventInterface @brief Diagram::clearEventInterface
* Clear the current event interface. Clear the current event interface.
*/ */
void Diagram::clearEventInterface() void Diagram::clearEventInterface()
{ {
@@ -507,16 +526,16 @@ void Diagram::clearEventInterface()
} }
/** /**
* @brief Diagram::conductorsAutonumName @brief Diagram::conductorsAutonumName
* @return the name of autonum to use. @return the name of autonum to use.
*/ */
QString Diagram::conductorsAutonumName() const { QString Diagram::conductorsAutonumName() const {
return m_conductors_autonum_name; return m_conductors_autonum_name;
} }
/** /**
* @brief Diagram::setConductorsAutonumName @brief Diagram::setConductorsAutonumName
* @param name, name of autonum to use. @param name, name of autonum to use.
*/ */
void Diagram::setConductorsAutonumName(const QString &name) { void Diagram::setConductorsAutonumName(const QString &name) {
m_conductors_autonum_name= name; m_conductors_autonum_name= name;
@@ -546,23 +565,28 @@ bool Diagram::toPaintDevice(QPaintDevice &pix, int width, int height, Qt::Aspect
// si les dimensions ne sont pas precisees, l'image est exportee a l'echelle 1:1 // si les dimensions ne sont pas precisees, l'image est exportee a l'echelle 1:1
QSize image_size = (width == -1 && height == -1) ? source_area.size().toSize() : QSize(width, height); QSize image_size = (width == -1 && height == -1) ? source_area.size().toSize() : QSize(width, height);
// prepare the rendering
// prepare le rendu // prepare le rendu
QPainter p; QPainter p;
if (!p.begin(&pix)) return(false); if (!p.begin(&pix)) return(false);
// anti-aliasis rendering
// rendu antialiase // rendu antialiase
p.setRenderHint(QPainter::Antialiasing, true); p.setRenderHint(QPainter::Antialiasing, true);
p.setRenderHint(QPainter::TextAntialiasing, true); p.setRenderHint(QPainter::TextAntialiasing, true);
p.setRenderHint(QPainter::SmoothPixmapTransform, true); p.setRenderHint(QPainter::SmoothPixmapTransform, true);
// deselect all elements
// deselectionne tous les elements // deselectionne tous les elements
QList<QGraphicsItem *> selected_elmts = selectedItems(); QList<QGraphicsItem *> selected_elmts = selectedItems();
foreach (QGraphicsItem *qgi, selected_elmts) qgi -> setSelected(false); foreach (QGraphicsItem *qgi, selected_elmts) qgi -> setSelected(false);
// renders itself
// effectue le rendu lui-meme // effectue le rendu lui-meme
render(&p, QRect(QPoint(0, 0), image_size), source_area, aspectRatioMode); render(&p, QRect(QPoint(0, 0), image_size), source_area, aspectRatioMode);
p.end(); p.end();
// restore selected items
// restaure les elements selectionnes // restaure les elements selectionnes
foreach (QGraphicsItem *qgi, selected_elmts) qgi -> setSelected(true); foreach (QGraphicsItem *qgi, selected_elmts) qgi -> setSelected(true);
@@ -570,8 +594,13 @@ bool Diagram::toPaintDevice(QPaintDevice &pix, int width, int height, Qt::Aspect
} }
/** /**
Permet de connaitre les dimensions qu'aura l'image generee par la methode toImage() @brief Diagram::imageSize
@return La taille de l'image generee par toImage() Allows you to know the dimensions
that the image generated by the toImage() method will have
\~French Permet de connaitre les dimensions
qu'aura l'image generee par la methode toImage()
\~ @return The size of the image generated by toImage()
\~French La taille de l'image generee par toImage()
*/ */
QSize Diagram::imageSize() const { QSize Diagram::imageSize() const {
// determine la zone source = contenu du schema + marges // determine la zone source = contenu du schema + marges
@@ -588,12 +617,16 @@ QSize Diagram::imageSize() const {
image_width += 2.0 * margin; image_width += 2.0 * margin;
image_height += 2.0 * margin; image_height += 2.0 * margin;
// returns the size of the source area
// renvoie la taille de la zone source // renvoie la taille de la zone source
return(QSizeF(image_width, image_height).toSize()); return(QSizeF(image_width, image_height).toSize());
} }
/** /**
@return true si le schema est considere comme vide, false sinon. @brief Diagram::isEmpty
An empty schema contains no element, conductor, or text field
@return true if the schema is considered empty, false otherwise.
\~French true si le schema est considere comme vide, false sinon.
Un schema vide ne contient ni element, ni conducteur, ni champ de texte Un schema vide ne contient ni element, ni conducteur, ni champ de texte
*/ */
bool Diagram::isEmpty() const { bool Diagram::isEmpty() const {
@@ -601,9 +634,10 @@ bool Diagram::isEmpty() const {
} }
/** /**
* @brief Diagram::potential @brief Diagram::potential
* @return all potential in the diagram @return all potential in the diagram
*each potential are in the QList and each conductors of one potential are in the QSet each potential are in the QList
and each conductors of one potential are in the QSet
*/ */
QList < QSet <Conductor *> > Diagram::potentials() { QList < QSet <Conductor *> > Diagram::potentials() {
QList < QSet <Conductor *> > potential_List; QList < QSet <Conductor *> > potential_List;
@@ -621,21 +655,29 @@ QList < QSet <Conductor *> > Diagram::potentials() {
} }
/** /**
Exporte tout ou partie du schema @brief Diagram::toXml
@param whole_content Booleen (a vrai par defaut) indiquant si le XML genere doit Exports all or part of the schema
\~French Exporte tout ou partie du schema
\~ @param whole_content :
Boolean (to true by default) indicating if the generated XML must
represent the entire schema or only the selected content
\~French Booleen (a vrai par defaut) indiquant si le XML genere doit
representer l'integralite du schema ou seulement le contenu selectionne representer l'integralite du schema ou seulement le contenu selectionne
@return Un Document XML (QDomDocument) \~ @return An XML Document (QDomDocument)
\~French Un Document XML (QDomDocument)
*/ */
QDomDocument Diagram::toXml(bool whole_content) { QDomDocument Diagram::toXml(bool whole_content) {
// document // document
QDomDocument document; QDomDocument document;
// XML tree root
// racine de l'arbre XML // racine de l'arbre XML
auto dom_root = document.createElement("diagram"); auto dom_root = document.createElement("diagram");
// add the application version number // add the application version number
dom_root.setAttribute("version", QET::version); dom_root.setAttribute("version", QET::version);
// schema properties
// proprietes du schema // proprietes du schema
if (whole_content) { if (whole_content) {
border_and_titleblock.titleBlockToXml(dom_root); border_and_titleblock.titleBlockToXml(dom_root);
@@ -764,6 +806,7 @@ QDomDocument Diagram::toXml(bool whole_content) {
} }
} }
// correspondence table between the addresses of the terminals and their ids
// table de correspondance entre les adresses des bornes et leurs ids // table de correspondance entre les adresses des bornes et leurs ids
QHash<Terminal *, int> table_adr_id; QHash<Terminal *, int> table_adr_id;
@@ -838,17 +881,35 @@ void Diagram::folioSequentialsToXml(QHash<QString, QStringList> *hash, QDomEleme
} }
/** /**
Importe le schema decrit dans un document XML. Si une position est @brief Diagram::fromXml
precisee, les elements importes sont positionnes de maniere a ce que le Imports the described schema into an XML document.
coin superieur gauche du plus petit rectangle pouvant les entourant tous If a position is specified,
the imported elements are positioned so that the upper left corner
of the smallest rectangle that can surround them all
(the bounding rect) is at this position.
\~French Importe le schema decrit dans un document XML.
Si une position estprecisee,
les elements importes sont positionnes de maniere a ce que le coin
superieur gauche du plus petit rectangle pouvant les entourant tous
(le bounding rect) soit a cette position. (le bounding rect) soit a cette position.
@param document Le document XML a analyser \~ @param document :
@param position La position du schema importe The XML document to analyze
@param consider_informations Si vrai, les informations complementaires \~French Le document XML a analyser
\~ @param position :
The position of the diagram matters
\~French La position du schema importe
\~ @param consider_informations :
If true, additional information
(author, title, ...) will be taken into account
\~French Si vrai, les informations complementaires
(auteur, titre, ...) seront prises en compte (auteur, titre, ...) seront prises en compte
@param content_ptr si ce pointeur vers un DiagramContent est different de 0, \~ @param content_ptr :
if this pointer to a DiagramContent is different from 0,
it will be filled with the content added to the schema by the fromXml
\~French si ce pointeur vers un DiagramContent est different de 0,
il sera rempli avec le contenu ajoute au schema par le fromXml il sera rempli avec le contenu ajoute au schema par le fromXml
@return true si l'import a reussi, false sinon \~ @return true if the import was successful, false otherwise
\~French true si l'import a reussi, false sinon
*/ */
bool Diagram::fromXml(QDomDocument &document, QPointF position, bool consider_informations, DiagramContent *content_ptr) { bool Diagram::fromXml(QDomDocument &document, QPointF position, bool consider_informations, DiagramContent *content_ptr) {
QDomElement root = document.documentElement(); QDomElement root = document.documentElement();
@@ -856,19 +917,34 @@ bool Diagram::fromXml(QDomDocument &document, QPointF position, bool consider_in
} }
/** /**
Importe le schema decrit dans un element XML. Cette methode delegue son travail a Diagram::fromXml @brief Diagram::initFromXml
Imports the described schema in an XML element.
This method delegates its work to Diagram :: fromXml
If the import is successful,
this method also initializes the XML document internal allowing to
manage the recording of this diagram in the project to which it belongs.
@see Diagram::fromXml
\~French Importe le schema decrit dans un element XML.
Cette methode delegue son travail a Diagram::fromXml
Si l'import reussit, cette methode initialise egalement le document XML Si l'import reussit, cette methode initialise egalement le document XML
interne permettant de bien gerer l'enregistrement de ce schema dans le interne permettant de bien gerer l'enregistrement de ce schema dans le
projet auquel il appartient. projet auquel il appartient.
@see Diagram::fromXml \~ @param document : The XML document to analyze
@param document Le document XML a analyser \~French Le document XML a analyser
@param position La position du schema importe \~ @param position : The position of the diagram matters
@param consider_informations Si vrai, les informations complementaires \~French La position du schema importe
\~ @param consider_informations :
If true, additional information
(author, title, ...) will be taken into account
\~French Si vrai, les informations complementaires
(auteur, titre, ...) seront prises en compte (auteur, titre, ...) seront prises en compte
@param content_ptr si ce pointeur vers un DiagramContent est different de 0, \~ @param content_ptr :
if this pointer to a DiagramContent is different from 0,
it will be filled with the content added to the schema by the fromXml
\~French si ce pointeur vers un DiagramContent est different de 0,
il sera rempli avec le contenu ajoute au schema par le fromXml il sera rempli avec le contenu ajoute au schema par le fromXml
@return true si l'import a reussi, false sinon \~ @return true if the import was successful, false otherwise
\~French true si l'import a reussi, false sinon
*/ */
bool Diagram::initFromXml(QDomElement &document, QPointF position, bool consider_informations, DiagramContent *content_ptr) { bool Diagram::initFromXml(QDomElement &document, QPointF position, bool consider_informations, DiagramContent *content_ptr) {
// import le contenu et les proprietes du schema depuis l'element XML fourni en parametre // import le contenu et les proprietes du schema depuis l'element XML fourni en parametre
@@ -914,7 +990,8 @@ Terminal* findTerminal(int conductor_index, QDomElement& f, QHash<int, Terminal
if (!element_found) if (!element_found)
qDebug() << "Diagram::fromXml() : " << element_index << ": " << element_uuid << "not found"; qDebug() << "Diagram::fromXml() : " << element_index << ": " << element_uuid << "not found";
} else { } else {
// Backward compatibility. Until version 0.7 a generated id is used to link the terminal. // Backward compatibility.
// Until version 0.7 a generated id is used to link the terminal.
int id_p1 = f.attribute(terminal_index).toInt(); int id_p1 = f.attribute(terminal_index).toInt();
if (!table_adr_id.contains(id_p1)) { if (!table_adr_id.contains(id_p1)) {
qDebug() << "Diagram::fromXml() : terminal id " << id_p1 << " not found"; qDebug() << "Diagram::fromXml() : terminal id " << id_p1 << " not found";
@@ -925,17 +1002,35 @@ Terminal* findTerminal(int conductor_index, QDomElement& f, QHash<int, Terminal
} }
/** /**
Importe le schema decrit dans un element XML. Si une position est @brief Diagram::fromXml
precisee, les elements importes sont positionnes de maniere a ce que le Imports the described schema in an XML element. If a position is
specified, the imported elements are positioned in such a way that the
upper left corner of the smallest rectangle that can surround them all
(the bounding rect) either at this position.
\~French Importe le schema decrit dans un element XML.
Si une position est precisee,
les elements importes sont positionnes de maniere a ce que le
coin superieur gauche du plus petit rectangle pouvant les entourant tous coin superieur gauche du plus petit rectangle pouvant les entourant tous
(le bounding rect) soit a cette position. (le bounding rect) soit a cette position.
@param document Le document XML a analyser \~ @param document :
@param position La position du schema importe The XML document to analyze
@param consider_informations Si vrai, les informations complementaires \~French Le document XML a analyser
\~ @param position :
The position of the diagram matters
\~French La position du schema importe
\~ @param consider_informations :
If true, additional information
(author, title, ...) will be taken into account
\~French Si vrai, les informations complementaires
(auteur, titre, ...) seront prises en compte (auteur, titre, ...) seront prises en compte
@param content_ptr si ce pointeur vers un DiagramContent est different de 0, \~ @param content_ptr :
if this pointer to a DiagramContent is different from 0,
it will be filled with the content added to the schema by the fromXml
\~French si ce pointeur vers un DiagramContent est different de 0,
il sera rempli avec le contenu ajoute au schema par le fromXml il sera rempli avec le contenu ajoute au schema par le fromXml
@return true si l'import a reussi, false sinon \~ @return
true if the import was successful, false otherwise
\~French true si l'import a reussi, false sinon
*/ */
bool Diagram::fromXml(QDomElement &document, QPointF position, bool consider_informations, DiagramContent *content_ptr) { bool Diagram::fromXml(QDomElement &document, QPointF position, bool consider_informations, DiagramContent *content_ptr) {
const QDomElement& root = document; const QDomElement& root = document;
@@ -987,11 +1082,13 @@ bool Diagram::fromXml(QDomElement &document, QPointF position, bool consider_inf
return(true); return(true);
} }
// Backward compatibility: prior to version 0.3, we need to compensate, at /* Backward compatibility: prior to version 0.3, we need to compensate,
// diagram-opening time, the rotation of the element for each of its * at diagram-opening time, the rotation of the element for each of its
// textfields having the "FollowParentRotation" option disabled. * textfields having the "FollowParentRotation" option disabled.
// After 0.3, elements textfields get userx, usery and userrotation attributes * After 0.3, elements textfields get userx,
// that explicitly specify their position and orientation. * usery and userrotation attributes that explicitly specify
* their position and orientation.
*/
qreal project_qet_version = declaredQElectroTechVersion(true); qreal project_qet_version = declaredQElectroTechVersion(true);
bool handle_inputs_rotation = ( bool handle_inputs_rotation = (
project_qet_version != -1 && project_qet_version < 0.3 && project_qet_version != -1 && project_qet_version < 0.3 &&
@@ -1198,11 +1295,12 @@ void Diagram::folioSequentialsFromXml(const QDomElement &root, QHash<QString, QS
} }
/** /**
* @brief Diagram::refreshContents @brief Diagram::refreshContents
* refresh all content of diagram. refresh all content of diagram.
* - refresh conductor text. - refresh conductor text.
* - linking the elements waiting to be linked - linking the elements waiting to be linked
* - Refresh the connection of the dynamic element text item (use for text with source of text label) - Refresh the connection of the dynamic element text item
(use for text with source of text label)
*/ */
void Diagram::refreshContents() void Diagram::refreshContents()
{ {
@@ -1223,10 +1321,10 @@ void Diagram::refreshContents()
} }
/** /**
* @brief Diagram::addItem @brief Diagram::addItem
* Réimplemented from QGraphicsScene::addItem(QGraphicsItem *item) Réimplemented from QGraphicsScene::addItem(QGraphicsItem *item)
* Do some specific operation if item need it (for exemple an element) Do some specific operation if item need it (for exemple an element)
* @param item @param item
*/ */
void Diagram::addItem(QGraphicsItem *item) void Diagram::addItem(QGraphicsItem *item)
{ {
@@ -1253,10 +1351,10 @@ void Diagram::addItem(QGraphicsItem *item)
} }
/** /**
* @brief Diagram::removeItem @brief Diagram::removeItem
* Reimplemented from QGraphicsScene::removeItem(QGraphicsItem *item) Reimplemented from QGraphicsScene::removeItem(QGraphicsItem *item)
* Do some specific operation if item need it (for exemple an element) Do some specific operation if item need it (for exemple an element)
* @param item @param item
*/ */
void Diagram::removeItem(QGraphicsItem *item) void Diagram::removeItem(QGraphicsItem *item)
{ {
@@ -1293,6 +1391,7 @@ void Diagram::titleChanged(const QString &title) {
} }
/** /**
@brief Diagram::titleBlockTemplateChanged
This slot may be used to inform the diagram object that the given title This slot may be used to inform the diagram object that the given title
block template has changed. The diagram will thus flush its title block template has changed. The diagram will thus flush its title
block-dedicated rendering cache. block-dedicated rendering cache.
@@ -1306,6 +1405,7 @@ void Diagram::titleBlockTemplateChanged(const QString &template_name) {
} }
/** /**
@brief Diagram::titleBlockTemplateRemoved
This slot has to be be used to inform this class that the given title block This slot has to be be used to inform this class that the given title block
template is about to be removed and is no longer accessible. This class template is about to be removed and is no longer accessible. This class
will either use the provided optional TitleBlockTemplate or the default will either use the provided optional TitleBlockTemplate or the default
@@ -1322,6 +1422,7 @@ void Diagram::titleBlockTemplateRemoved(const QString &template_name, const QStr
} }
/** /**
@brief Diagram::setTitleBlockTemplate
Set the template to use to render the title block of this diagram. Set the template to use to render the title block of this diagram.
@param template_name Name of the title block template. @param template_name Name of the title block template.
*/ */
@@ -1338,7 +1439,9 @@ void Diagram::setTitleBlockTemplate(const QString &template_name)
} }
/** /**
Selectionne tous les objets du schema @brief Diagram::selectAll
Select all schema objects
\~French Selectionne tous les objets du schema
*/ */
void Diagram::selectAll() { void Diagram::selectAll() {
if (items().isEmpty()) return; if (items().isEmpty()) return;
@@ -1350,7 +1453,9 @@ void Diagram::selectAll() {
} }
/** /**
Deslectionne tous les objets selectionnes @brief Diagram::deselectAll
Deselects all selected objects
\~French Deslectionne tous les objets selectionnes
*/ */
void Diagram::deselectAll() { void Diagram::deselectAll() {
if (items().isEmpty()) return; if (items().isEmpty()) return;
@@ -1359,6 +1464,8 @@ void Diagram::deselectAll() {
} }
/** /**
@brief Diagram::invertSelection
Reverses the selection state of all schema objects
Inverse l'etat de selection de tous les objets du schema Inverse l'etat de selection de tous les objets du schema
*/ */
void Diagram::invertSelection() { void Diagram::invertSelection() {
@@ -1371,9 +1478,9 @@ void Diagram::invertSelection() {
} }
/** /**
* @brief Diagram::updateLabels @brief Diagram::updateLabels
* Update elements and conductors that reference folio field Update elements and conductors that reference folio field
* in their labels. in their labels.
*/ */
void Diagram::updateLabels() void Diagram::updateLabels()
{ {
@@ -1427,8 +1534,8 @@ void Diagram::loadFolioSeqHash(QHash<QString, QStringList> *hash, const QString&
} }
/** /**
* @brief Diagram::changeZValue @brief Diagram::changeZValue
* Change the Z value of the current selected item, according to @option Change the Z value of the current selected item, according to @option
*/ */
void Diagram::changeZValue(QET::DepthOption option) void Diagram::changeZValue(QET::DepthOption option)
{ {
@@ -1483,9 +1590,9 @@ void Diagram::changeZValue(QET::DepthOption option)
} }
/** /**
* @brief Diagram::loadElmtFolioSeq @brief Diagram::loadElmtFolioSeq
* This class loads all folio sequential variables related This class loads all folio sequential variables related
* to the current autonum to the current autonum
*/ */
void Diagram::loadElmtFolioSeq() { void Diagram::loadElmtFolioSeq() {
QString title = project()->elementCurrentAutoNum(); QString title = project()->elementCurrentAutoNum();
@@ -1541,9 +1648,9 @@ void Diagram::loadElmtFolioSeq() {
} }
/** /**
* @brief Diagram::loadCndFolioSeq @brief Diagram::loadCndFolioSeq
* This class loads all conductor folio sequential variables related This class loads all conductor folio sequential variables related
* to the current autonum to the current autonum
*/ */
void Diagram::loadCndFolioSeq() { void Diagram::loadCndFolioSeq() {
//Conductor //Conductor
@@ -1601,12 +1708,18 @@ void Diagram::loadCndFolioSeq() {
} }
/** /**
@return le titre du cartouche @brief Diagram::title
@return title of the titleblock
\~Frenchle titre du cartouche
*/ */
QString Diagram::title() const { QString Diagram::title() const {
return(border_and_titleblock.title()); return(border_and_titleblock.title());
} }
/**
@brief Diagram::elements
@return the list containing all elements
*/
QList <Element *> Diagram::elements() const { QList <Element *> Diagram::elements() const {
QList<Element *> element_list; QList<Element *> element_list;
foreach (QGraphicsItem *qgi, items()) { foreach (QGraphicsItem *qgi, items()) {
@@ -1617,8 +1730,8 @@ QList <Element *> Diagram::elements() const {
} }
/** /**
* @brief Diagram::conductors @brief Diagram::conductors
* Return the list containing all conductors @return the list containing all conductors
*/ */
QList <Conductor *> Diagram::conductors() const { QList <Conductor *> Diagram::conductors() const {
QList<Conductor *> cnd_list; QList<Conductor *> cnd_list;
@@ -1629,18 +1742,32 @@ QList <Conductor *> Diagram::conductors() const {
return (cnd_list); return (cnd_list);
} }
/**
@brief Diagram::elementsMover
@return
*/
ElementsMover &Diagram::elementsMover() { ElementsMover &Diagram::elementsMover() {
return m_elements_mover; return m_elements_mover;
} }
/**
@brief Diagram::elementTextsMover
@return
*/
ElementTextsMover &Diagram::elementTextsMover() { ElementTextsMover &Diagram::elementTextsMover() {
return m_element_texts_mover; return m_element_texts_mover;
} }
/** /**
Permet de savoir si un element est utilise sur un schema @brief Diagram::usesElement
@param location Emplacement d'un element Used to find out if an element is used on a schema
@return true si l'element location est utilise sur ce schema, false sinon \~French Permet de savoir si un element est utilise sur un schema
\~ @param location : Location of an element
\~French Emplacement d'un element
\~ @return true if the location element is used on this schema,
false otherwise
\~French true si l'element location est utilise sur ce schema,
false sinon
*/ */
bool Diagram::usesElement(const ElementsLocation &location) bool Diagram::usesElement(const ElementsLocation &location)
{ {
@@ -1653,7 +1780,8 @@ bool Diagram::usesElement(const ElementsLocation &location)
} }
/** /**
@param a title block template name @brief Diagram::usesTitleBlockTemplate
@param name : a title block template name
@return true if the provided template is used by this diagram, false @return true if the provided template is used by this diagram, false
otherwise. otherwise.
*/ */
@@ -1662,8 +1790,8 @@ bool Diagram::usesTitleBlockTemplate(const QString &name) {
} }
/** /**
* @brief Diagram::freezeElements @brief Diagram::freezeElements
* Freeze every existent element label. Freeze every existent element label.
*/ */
void Diagram::freezeElements(bool freeze) { void Diagram::freezeElements(bool freeze) {
foreach (Element *elmt, elements()) { foreach (Element *elmt, elements()) {
@@ -1672,8 +1800,8 @@ void Diagram::freezeElements(bool freeze) {
} }
/** /**
* @brief Diagram::unfreezeElements @brief Diagram::unfreezeElements
* Unfreeze every existent element label. Unfreeze every existent element label.
*/ */
void Diagram::unfreezeElements() { void Diagram::unfreezeElements() {
foreach (Element *elmt, elements()) { foreach (Element *elmt, elements()) {
@@ -1682,24 +1810,24 @@ void Diagram::unfreezeElements() {
} }
/** /**
* @brief Diagram::freezeNewElements @brief Diagram::freezeNewElements
* Set new element label to be frozen. Set new element label to be frozen.
*/ */
void Diagram::setFreezeNewElements(bool b) { void Diagram::setFreezeNewElements(bool b) {
m_freeze_new_elements = b; m_freeze_new_elements = b;
} }
/** /**
* @brief Diagram::freezeNewElements @brief Diagram::freezeNewElements
* @return current freeze new element status . @return current freeze new element status .
*/ */
bool Diagram::freezeNewElements() { bool Diagram::freezeNewElements() {
return m_freeze_new_elements; return m_freeze_new_elements;
} }
/** /**
* @brief Diagram::freezeConductors @brief Diagram::freezeConductors
* Freeze every existent conductor label. Freeze every existent conductor label.
*/ */
void Diagram::freezeConductors(bool freeze) { void Diagram::freezeConductors(bool freeze) {
foreach (Conductor *cnd, conductors()) { foreach (Conductor *cnd, conductors()) {
@@ -1708,24 +1836,24 @@ void Diagram::freezeConductors(bool freeze) {
} }
/** /**
* @brief Diagram::setfreezeNewConductors @brief Diagram::setfreezeNewConductors
* Set new conductor label to be frozen. Set new conductor label to be frozen.
*/ */
void Diagram::setFreezeNewConductors(bool b) { void Diagram::setFreezeNewConductors(bool b) {
m_freeze_new_conductors_ = b; m_freeze_new_conductors_ = b;
} }
/** /**
* @brief Diagram::freezeNewConductors @brief Diagram::freezeNewConductors
* @return current freeze new conductor status . @return current freeze new conductor status .
*/ */
bool Diagram::freezeNewConductors() { bool Diagram::freezeNewConductors() {
return m_freeze_new_conductors_; return m_freeze_new_conductors_;
} }
/** /**
* @brief Diagram::adjustSceneRect @brief Diagram::adjustSceneRect
* Recalcul and adjust the size of the scene Recalcul and adjust the size of the scene
*/ */
void Diagram::adjustSceneRect() void Diagram::adjustSceneRect()
{ {
@@ -1735,10 +1863,16 @@ void Diagram::adjustSceneRect()
} }
/** /**
Cette methode permet d'appliquer de nouvelles options de rendu tout en @brief Diagram::applyProperties
accedant aux proprietes de rendu en cours. This method allows you to apply new rendering options while
@param new_properties Nouvelles options de rendu a appliquer accessing the current rendering properties.
@return les options de rendu avant l'application de new_properties \~French Cette methode permet d'appliquer de nouvelles options de rendu
tout en accedant aux proprietes de rendu en cours.
\~ @param new_properties :
New rendering options to apply
\~French Nouvelles options de rendu a appliquer
\~ @return rendering options before applying new_properties
\~French les options de rendu avant l'application de new_properties
*/ */
ExportProperties Diagram::applyProperties(const ExportProperties &new_properties) { ExportProperties Diagram::applyProperties(const ExportProperties &new_properties) {
// exporte les options de rendu en cours // exporte les options de rendu en cours
@@ -1750,6 +1884,7 @@ ExportProperties Diagram::applyProperties(const ExportProperties &new_properties
old_properties.draw_colored_conductors = drawColoredConductors(); old_properties.draw_colored_conductors = drawColoredConductors();
old_properties.exported_area = useBorder() ? QET::BorderArea : QET::ElementsArea; old_properties.exported_area = useBorder() ? QET::BorderArea : QET::ElementsArea;
// apply the new rendering options
// applique les nouvelles options de rendu // applique les nouvelles options de rendu
setUseBorder (new_properties.exported_area == QET::BorderArea); setUseBorder (new_properties.exported_area == QET::BorderArea);
setDrawTerminals (new_properties.draw_terminals); setDrawTerminals (new_properties.draw_terminals);
@@ -1758,14 +1893,20 @@ ExportProperties Diagram::applyProperties(const ExportProperties &new_properties
border_and_titleblock.displayBorder(new_properties.draw_border); border_and_titleblock.displayBorder(new_properties.draw_border);
border_and_titleblock.displayTitleBlock (new_properties.draw_titleblock); border_and_titleblock.displayTitleBlock (new_properties.draw_titleblock);
// return old rendering options
// retourne les anciennes options de rendu // retourne les anciennes options de rendu
return(old_properties); return(old_properties);
} }
/** /**
@param pos Position cartesienne (ex : 10.3, 45.2) a transformer en position @brief Diagram::convertPosition
@param pos :
Cartesian position (ex: 10.3, 45.2) to transform into position
in the grid (ex: B2)
\~French Position cartesienne (ex : 10.3, 45.2) a transformer en position
dans la grille (ex : B2) dans la grille (ex : B2)
@return la position dans la grille correspondant a pos \~ @return a position in the grid corresponding to pos
\~French la position dans la grille correspondant a pos
*/ */
DiagramPosition Diagram::convertPosition(const QPointF &pos) { DiagramPosition Diagram::convertPosition(const QPointF &pos) {
// delegue le calcul au BorderTitleBlock // delegue le calcul au BorderTitleBlock
@@ -1806,8 +1947,11 @@ QPointF Diagram::snapToGrid(const QPointF &p)
/** /**
Definit s'il faut afficher ou non les bornes @brief Diagram::setDrawTerminals
@param dt true pour afficher les bornes, false sinon Defines whether or not to display the terminals
\~French Definit s'il faut afficher ou non les bornes
\~ @param dt : true to display the bounds, false otherwise
\~French true pour afficher les bornes, false sinon
*/ */
void Diagram::setDrawTerminals(bool dt) { void Diagram::setDrawTerminals(bool dt) {
foreach(QGraphicsItem *qgi, items()) { foreach(QGraphicsItem *qgi, items()) {
@@ -1818,16 +1962,22 @@ void Diagram::setDrawTerminals(bool dt) {
} }
/** /**
Definit s'il faut respecter ou non les couleurs des conducteurs. @brief Diagram::setDrawColoredConductors
Defines whether or not to respect the colors of the conductors.
If not, the conductors are all drawn in black.
\~French Definit s'il faut respecter ou non les couleurs des conducteurs.
Si non, les conducteurs sont tous dessines en noir. Si non, les conducteurs sont tous dessines en noir.
@param dcc true pour respecter les couleurs, false sinon \~ @param dcc true to respect the colors, false otherwise
\~French dcc true pour respecter les couleurs, false sinon
*/ */
void Diagram::setDrawColoredConductors(bool dcc) { void Diagram::setDrawColoredConductors(bool dcc) {
draw_colored_conductors_ = dcc; draw_colored_conductors_ = dcc;
} }
/** /**
@return la liste des conducteurs selectionnes sur le schema @brief Diagram::selectedConductors
@return the list of conductors selected on the diagram
\~French la liste des conducteurs selectionnes sur le schema
*/ */
QSet<Conductor *> Diagram::selectedConductors() const { QSet<Conductor *> Diagram::selectedConductors() const {
QSet<Conductor *> conductors_set; QSet<Conductor *> conductors_set;
@@ -1839,7 +1989,11 @@ QSet<Conductor *> Diagram::selectedConductors() const {
return(conductors_set); return(conductors_set);
} }
/// @return true si le presse-papier semble contenir un schema /**
@brief Diagram::clipboardMayContainDiagram
@return true if the clipboard appears to contain a schema
\~French true si le presse-papier semble contenir un schema
*/
bool Diagram::clipboardMayContainDiagram() { bool Diagram::clipboardMayContainDiagram() {
QString clipboard_text = QApplication::clipboard() -> text().trimmed(); QString clipboard_text = QApplication::clipboard() -> text().trimmed();
bool may_be_diagram = clipboard_text.startsWith("<diagram") && clipboard_text.endsWith("</diagram>"); bool may_be_diagram = clipboard_text.startsWith("<diagram") && clipboard_text.endsWith("</diagram>");
@@ -1847,16 +2001,20 @@ bool Diagram::clipboardMayContainDiagram() {
} }
/** /**
@return le projet auquel ce schema appartient ou 0 s'il s'agit d'un schema @brief Diagram::project
independant. @return the project to which this schema belongs
or 0 if it is an independent schema.
\~French le projet auquel ce schema appartient
ou 0 s'il s'agit d'un schema independant.
*/ */
QETProject *Diagram::project() const { QETProject *Diagram::project() const {
return(m_project); return(m_project);
} }
/** /**
@return the folio number of this diagram within its parent project, or -1 @brief Diagram::folioIndex
if it is has no parent project @return the folio number of this diagram within its parent project,
or -1 if it is has no parent project
*/ */
int Diagram::folioIndex() const { int Diagram::folioIndex() const {
if (!m_project) return(-1); if (!m_project) return(-1);
@@ -1864,7 +2022,9 @@ int Diagram::folioIndex() const {
} }
/** /**
@param fallback_to_project When a diagram does not have a declared version, @brief Diagram::declaredQElectroTechVersion
@param fallback_to_project :
When a diagram does not have a declared version,
this method will use the one declared by its parent project only if this method will use the one declared by its parent project only if
fallback_to_project is true. fallback_to_project is true.
@return the declared QElectroTech version of this diagram @return the declared QElectroTech version of this diagram
@@ -1880,9 +2040,9 @@ qreal Diagram::declaredQElectroTechVersion(bool fallback_to_project) const {
} }
/** /**
* @brief Diagram::isReadOnly @brief Diagram::isReadOnly
* @return true if this diagram is read only. @return true if this diagram is read only.
* This method is same has call Diagram::project() -> isReadOnly() This method is same has call Diagram::project() -> isReadOnly()
*/ */
bool Diagram::isReadOnly() const bool Diagram::isReadOnly() const
{ {
@@ -1890,7 +2050,10 @@ bool Diagram::isReadOnly() const
} }
/** /**
@return Le contenu du schema. Les conducteurs sont tous places dans @brief Diagram::content
@return The content of the diagram.
The conductors are all seated in conductorsToMove.
\~French Le contenu du schema. Les conducteurs sont tous places dans
conductorsToMove. conductorsToMove.
*/ */
DiagramContent Diagram::content() const { DiagramContent Diagram::content() const {
@@ -1908,8 +2071,8 @@ DiagramContent Diagram::content() const {
} }
/** /**
* @brief Diagram::canRotateSelection @brief Diagram::canRotateSelection
* @return True if a least one of selected items can be rotated @return True if a least one of selected items can be rotated
*/ */
bool Diagram::canRotateSelection() const bool Diagram::canRotateSelection() const
{ {