22 #include <QGraphicsSceneContextMenuEvent> 150 if (point == line.p1())
return(
true);
151 QLineF point_line(line.p1(), point);
152 if (point_line.unitVector() != line.unitVector())
return(
false);
153 return(point_line.length() <= line.length());
167 QLineF line_normal_vector(line.normalVector());
168 QPointF normal_vector(line_normal_vector.dx(), line_normal_vector.dy());
171 QLineF perpendicular_line(point, point + normal_vector);
174 QPointF intersection_point;
175 QLineF::IntersectType
it = line.intersect(perpendicular_line, &intersection_point);
178 if (
it == QLineF::NoIntersection)
return(
false);
182 *intersection = intersection_point;
202 if (!e.hasAttribute(nom_attribut))
return(
false);
205 int tmp = e.attribute(nom_attribut).toInt(&ok);
206 if (!ok)
return(
false);
207 if (entier !=
nullptr) *entier = tmp;
221 if (!e.hasAttribute(nom_attribut))
return(
false);
224 qreal tmp = e.attribute(nom_attribut).toDouble(&ok);
225 if (!ok)
return(
false);
226 if (reel !=
nullptr) *reel = tmp;
242 if (elements_count) {
245 "part of a sentence listing the content of a diagram",
250 if (conductors_count) {
251 if (!text.isEmpty()) text +=
", ";
254 "part of a sentence listing the content of a diagram",
260 if (!text.isEmpty()) text +=
", ";
262 "%n champ(s) de texte",
263 "part of a sentence listing the content of a diagram",
269 if (!text.isEmpty()) text +=
", ";
272 "part of a sentence listing the content of a diagram",
278 if (!text.isEmpty()) text +=
", ";
281 "part of a sentence listing the content of a diagram",
286 if (element_text_count) {
287 if (!text.isEmpty()) text +=
", ";
289 "%n texte(s) d'élément",
290 "part of a sentence listing the content of a diagram",
301 QList<QDomElement> return_list;
302 for (QDomNode node = e.firstChild() ; !node.isNull() ; node = node.nextSibling()) {
303 if (!node.isElement())
continue;
304 QDomElement element = node.toElement();
305 if (element.isNull() || element.tagName() != tag_name)
continue;
306 return_list << element;
320 QList<QDomElement> return_list;
323 for (QDomNode enfant = e.firstChild() ; !enfant.isNull() ; enfant = enfant.nextSibling()) {
325 QDomElement parents = enfant.toElement();
326 if (parents.isNull() || parents.tagName() != parent)
continue;
328 for (QDomNode node_children = parents.firstChild() ; !node_children.isNull() ; node_children = node_children.nextSibling()) {
330 QDomElement n_children = node_children.toElement();
331 if (!n_children.isNull() && n_children.tagName() == children) return_list.append(n_children);
340 QFile *file_license =
new QFile(
":/LICENSE");
343 if (!file_license -> exists()) {
344 txt_license = QString(
QObject::tr(
"Le fichier texte contenant la licence GNU/GPL est introuvable - bon bah de toute façon, vous la connaissez par coeur non ?"));
347 if (!file_license -> open(QIODevice::ReadOnly | QIODevice::Text)) {
348 txt_license = QString(
QObject::tr(
"Le fichier texte contenant la licence GNU/GPL existe mais n'a pas pu être ouvert - bon bah de toute façon, vous la connaissez par coeur non ?"));
351 QTextStream in(file_license);
352 txt_license = QString(
"");
353 while (!in.atEnd()) txt_license += in.readLine()+
"\n";
355 file_license -> close();
367 return(QList<QChar>() <<
'\\' <<
'/' <<
':' <<
'*' <<
'?' <<
'"' <<
'<' <<
'>' <<
'|');
380 QString file_name(name.toLower());
384 file_name.replace(c,
'-');
388 file_name.replace(
' ',
'_');
399 return(QString(
string).replace(
'\\',
"\\\\").replace(
' ',
"\\ "));
408 return(QString(
string).replace(
"\\\\",
"\\").replace(
"\\ ",
" "));
418 QString returned_string;
420 for (
int i = 0 ; i < string_list.count() ; ++ i) {
422 if (i != string_list.count() - 1) returned_string +=
" ";
425 return(returned_string);
436 QStringList escaped_strings =
string.split(QRegExp(
"[^\\]?(?:\\\\)* "), QString::SkipEmptyParts);
438 QStringList returned_list;
439 foreach(QString escaped_string, escaped_strings) {
442 return(returned_list);
480 else return(
"border");
489 if (!
string.compare(
"border", Qt::CaseInsensitive))
return(
QET::BorderArea);
498 return(
int(x * epsilon) / epsilon);
507 qreal corrected_angle = angle;
508 while (corrected_angle <= -360.0) corrected_angle += 360.0;
509 while (corrected_angle >= 360.0) corrected_angle -= 360.0;
510 return(corrected_angle);
520 QString first_canonical_path = QFileInfo(first).canonicalFilePath();
521 if (first_canonical_path.isEmpty())
return(
false);
523 QString second_canonical_path = QFileInfo(second).canonicalFilePath();
524 if (second_canonical_path.isEmpty())
return(
false);
528 first_canonical_path = first_canonical_path.toLower();
529 second_canonical_path = second_canonical_path.toLower();
532 return(first_canonical_path == second_canonical_path);
546 QSaveFile file(filepath);
549 bool file_opening = file.open(QIODevice::WriteOnly);
554 *error_message = QString(
QObject::tr(
"Impossible d'ouvrir le fichier %1 en écriture, erreur %2 rencontrée.",
555 "error message when attempting to write an XML file")).arg(filepath).arg(file.error());
560 QTextStream out(&file);
561 out.setCodec(
"UTF-8");
562 out.setGenerateByteOrderMark(
false);
563 out << xml_doc.toString(4);
567 *error_message = QString(
QObject::tr(
"Une erreur est survenue lors de l'écriture du fichier %1, erreur %2 rencontrée.",
568 "error message when attempting to write an XML file")).arg(filepath).arg(file.error());
585 if (qsl.size() == 1)
return true;
586 foreach (
const QString t, qsl) {
587 if (qsl.at(0) != t)
return false;
622 else if (str ==
"custom")
624 else if (str ==
"embedded")
638 QActionGroup *action_group =
new QActionGroup(parent);
645 edit_forward ->setStatusTip(
QObject::tr(
"Ramène la ou les sélections au premier plan"));
646 edit_raise ->setStatusTip(
QObject::tr(
"Rapproche la ou les sélections"));
647 edit_lower ->setStatusTip(
QObject::tr(
"Éloigne la ou les sélections"));
648 edit_backward->setStatusTip(
QObject::tr(
"Envoie en arrière plan la ou les sélections"));
650 edit_raise ->setShortcut(QKeySequence(
QObject::tr(
"Ctrl+Shift+Up")));
651 edit_lower ->setShortcut(QKeySequence(
QObject::tr(
"Ctrl+Shift+Down")));
652 edit_backward->setShortcut(QKeySequence(
QObject::tr(
"Ctrl+Shift+End")));
653 edit_forward ->setShortcut(QKeySequence(
QObject::tr(
"Ctrl+Shift+Home")));
665 bool opened_here = file->isOpen() ? false :
true;
669 bool open_ = file->open(QIODevice::WriteOnly);
674 QFileInfo info_(*file);
675 *error_message = QString(
676 QObject::tr(
"Impossible d'ouvrir le fichier %1 en écriture, erreur %2 rencontrée.",
677 "error message when attempting to write an XML file")
678 ).arg(info_.absoluteFilePath()).arg(file->error());
684 QTextStream out(file);
686 out.setCodec(
"UTF-8");
687 out.setGenerateByteOrderMark(
false);
688 out << xml_doc.toString(4);
EndType
This enum lists the various available endings for line primitives when drawing an electrical element...
bool attributeIsAnInteger(const QDomElement &, const QString &, int *=nullptr)
QET::DiagramArea diagramAreaFromString(const QString &)
Send item one layer below their current one; zValues are decremented.
QStringList splitWithSpaces(const QString &)
From an embedded collection (a project for exemple)
Raise item one layer above their current one; zValues are incremented.
static Qet::Orientation nextOrientation(Qet::Orientation)
static bool isHorizontal(Qet::Orientation)
Qet::isHorizontal.
QString joinWithSpaces(const QStringList &)
bool compareCanonicalFilePaths(const QString &, const QString &)
bool orthogonalProjection(const QPointF &, const QLineF &, QPointF *=nullptr)
QetCollection
Enum used to specify the origin of a collection of thing (title block, element etc...)
QString diagramAreaToString(const QET::DiagramArea &)
Bring item to the foreground so they have the highest zValue.
QString qetCollectionToString(const QetCollection &c)
QET::qetCollectionToString.
static Qet::Orientation orientationFromString(const QString &)
static QString endTypeToString(const Qet::EndType &)
QetCollection qetCollectionFromString(const QString &str)
QET::qetCollectionFromString.
static bool isOpposed(Qet::Orientation a, Qet::Orientation b)
Qet::isOpposed.
qreal correctAngle(const qreal &)
qreal round(qreal, qreal)
QString ElementsAndConductorsSentence(int, int, int=0, int=0, int=0, int=0)
Export the content of the diagram only.
bool writeToFile(QDomDocument &xml_doc, QFile *file, QString *error_message=nullptr)
QList< QDomElement > findInDomElement(const QDomElement &, const QString &)
bool writeXmlFile(QDomDocument &xml_doc, const QString &filepath, QString *error_message=nullptr)
static bool surLeMemeAxe(Qet::Orientation, Qet::Orientation)
static Qet::EndType endTypeFromString(const QString &)
static QString orientationToString(Qet::Orientation)
QString stringToFileName(const QString &)
bool attributeIsAReal(const QDomElement &, const QString &, qreal *=nullptr)
QString escapeSpaces(const QString &)
static bool isVertical(Qet::Orientation)
Qet::isVertical.
bool lineContainsPoint(const QLineF &, const QPointF &)
QString unescapeSpaces(const QString &)
Send item to the background so they have the lowest zValue.
Export the diagram along with its border and title block.
QActionGroup * depthActionGroup(QObject *parent=nullptr)
QET::depthActionGroup.
static Qet::Orientation previousOrientation(Qet::Orientation)
QList< QChar > forbiddenCharacters()
Orientation
Orientation (used for electrical elements and their terminals)
bool eachStrIsEqual(const QStringList &qsl)
QET::eachStrIsEqual.