mirror of
https://github.com/qelectrotech/qelectrotech-source-mirror.git
synced 2026-10-22 22:34:13 +02:00
dc92a57873
Reading where a cable lands meant going back to the drawing: the strip editor said which cable a terminal carries and which core, but never what the cable goes to. A single core (1x16) could not be followed from the terminal to its piece at all. The new Target column names it: Installation, Location and Label (BMK) of the piece the wires land on, past this strip, joined in one line -- the very three fields the strip drawing writes in the box under its cable, in the same order (RealTerminal::cableTarget()). It is worked out of the project like the Cable cells and so follows their rule: a target the drawing names is read only, for only the drawing decides it, and a cell nothing is worked out for takes an edit, so a target the drawing cannot find -- a cable landing on a piece with no Installation, Location nor Label set, a cable going to another strip -- is still worth naming by hand. The text typed in is stored in the element (RealTerminal::cableTargetInfoKey()) and kept until a cable works a target out again, and back once that cable goes, exactly like a cable designation typed by hand: the automatic value is never written, so no stale text can be left behind. The column takes the width of its own text, so a long Installation is never cut off. A text typed in is written the way the fields are shown in the column, "Installation / Location / Label", and gives one line per field: the box under the cable draws three lines without any slash in them, just like a target worked out from the project, instead of one long line carrying its separators as text. tst_terminalcableauto checks the column is empty -- and editable -- without a cable, reads "Plant 7 / Cabinet 7 / -S7" with one, goes empty -- and editable again -- when the core is removed, takes no edit while the drawing names the target, and is headed "Target"; a second case checks a target typed in by hand is taken by the cell, stored by Apply, shown again by a fresh model, set aside for the read only target of the drawing once a cable lands somewhere worth naming, and back once that cable goes; a third one the line per field. tst_cable target paints a strip whose cable ends on one field and the same strip ending on three, the second box two lines deeper than the first.
141 lines
4.9 KiB
C++
141 lines
4.9 KiB
C++
/*
|
|
Copyright 2006-2026 The QElectroTech Team
|
|
This file is part of QElectroTech.
|
|
|
|
QElectroTech is free software: you can redistribute it and/or modify
|
|
it under the terms of the GNU General Public License as published by
|
|
the Free Software Foundation, either version 2 of the License, or
|
|
(at your option) any later version.
|
|
|
|
QElectroTech is distributed in the hope that it will be useful,
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
GNU General Public License for more details.
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
along with QElectroTech. If not, see <http://www.gnu.org/licenses/>.
|
|
*/
|
|
#ifndef REALTERMINAL_H
|
|
#define REALTERMINAL_H
|
|
|
|
#include <QSharedPointer>
|
|
#include <QColor>
|
|
#include <QDomElement>
|
|
#include <QUuid>
|
|
#include "../properties/elementdata.h"
|
|
|
|
class TerminalStrip;
|
|
class Element;
|
|
class TerminalElement;
|
|
class PhysicalTerminal;
|
|
class TerminalStripBridge;
|
|
|
|
/**
|
|
* @brief The RealTerminal class
|
|
* Represent a real terminal.
|
|
* A real terminal can be a drawn terminal in a folio
|
|
* or a terminal set by user but not present
|
|
* on any folio (for example a reserved terminal).
|
|
*
|
|
* When create a new instance of RealTerminal you must
|
|
* call sharedRef() and only use the returned QSharedPointer
|
|
* instead of the raw pointer
|
|
*/
|
|
class RealTerminal
|
|
{
|
|
friend class TerminalElement;
|
|
friend class PhysicalTerminal;
|
|
|
|
private:
|
|
RealTerminal(Element *element);
|
|
|
|
QSharedPointer<RealTerminal> sharedRef();
|
|
QSharedPointer<RealTerminal> sharedRef() const;
|
|
QWeakPointer<RealTerminal> weakRef();
|
|
|
|
void setPhysicalTerminal(const QSharedPointer<PhysicalTerminal> &phy_t);
|
|
|
|
///Where the wires of a cable land, worked out from the project:
|
|
///empty when no cable lands on a piece worth naming (cableTarget()
|
|
///then falls back on the text typed in by hand).
|
|
QVector<QString> automaticCableTarget() const;
|
|
|
|
public:
|
|
~RealTerminal();
|
|
static QSharedPointer<RealTerminal> createSpare(const ElementData &data, const QUuid &uuid = QUuid());
|
|
static QSharedPointer<RealTerminal> spareFromXml(const QDomElement &xml_element);
|
|
bool isSpare() const;
|
|
ElementData spareData() const;
|
|
void setSpareData(const ElementData &data);
|
|
ElementData terminalData() const;
|
|
TerminalStrip *parentStrip() const noexcept;
|
|
QSharedPointer<PhysicalTerminal> physicalTerminal() const noexcept;
|
|
|
|
QDomElement toXml(QDomDocument &parent_document) const;
|
|
|
|
int level() const;
|
|
QString label() const;
|
|
QString Xref() const;
|
|
QString cable() const;
|
|
QString cableWire() const;
|
|
bool cableIsAutomatic() const;
|
|
bool isShield() const;
|
|
QVector<QString> cableTarget() const;
|
|
///True when cableTarget() is worked out from the project (read only),
|
|
///false when it is the text typed in by hand (which may be edited)
|
|
bool cableTargetIsAutomatic() const;
|
|
QColor color() const;
|
|
QColor stripeColor() const;
|
|
qreal section() const;
|
|
qreal widthMm() const;
|
|
QString catalogEntry() const;
|
|
bool hasSeparatorAfter() const;
|
|
|
|
//Keys used to store the cable data in the element informations
|
|
static QString cableInfoKey() { return QStringLiteral("terminal_cable"); }
|
|
static QString cableWireInfoKey() { return QStringLiteral("terminal_cable_wire"); }
|
|
//Target typed in by hand, only read when the cables give none
|
|
static QString cableTargetInfoKey() { return QStringLiteral("terminal_cable_target"); }
|
|
static QString shieldInfoKey() { return QStringLiteral("terminal_shield"); }
|
|
//Keys used to store the color and the section (mm2) of the terminal
|
|
static QString colorInfoKey() { return QStringLiteral("terminal_color"); }
|
|
static QString sectionInfoKey() { return QStringLiteral("terminal_section"); }
|
|
//Key used to store the width (mm) of the terminal, drawn in the terminal strip
|
|
static QString widthInfoKey() { return QStringLiteral("terminal_width"); }
|
|
//Key used to store the terminal chosen in the catalog (TerminalCatalog::WidthEntry::label)
|
|
static QString catalogEntryInfoKey() { return QStringLiteral("terminal_catalog_entry"); }
|
|
//Key used to store if a separator plate is mounted after the terminal
|
|
static QString separatorInfoKey() { return QStringLiteral("terminal_separator"); }
|
|
|
|
static void applyCatalogEntry(DiagramContext &informations, const QString &entry_label);
|
|
|
|
QString conductor() const;
|
|
|
|
ElementData::TerminalType type() const;
|
|
ElementData::TerminalFunction function() const;
|
|
|
|
bool isLed() const;
|
|
bool isElement() const;
|
|
bool isBridged() const;
|
|
|
|
QSharedPointer<TerminalStripBridge> bridge() const;
|
|
|
|
Element* element() const;
|
|
QUuid elementUuid() const;
|
|
|
|
static QString xmlTagName();
|
|
|
|
private :
|
|
bool hasData() const;
|
|
|
|
QPointer<Element> m_element;
|
|
//A spare terminal has no element : it is on no folio, its data are its own
|
|
bool m_spare = false;
|
|
QUuid m_spare_uuid;
|
|
ElementData m_spare_data;
|
|
QWeakPointer<RealTerminal> m_this_weak;
|
|
QSharedPointer<PhysicalTerminal> m_physical_terminal;
|
|
};
|
|
|
|
#endif // REALTERMINAL_H
|