2021-02-12 19:28:07 +01:00
|
|
|
/*
|
2025-01-04 13:37:40 +01:00
|
|
|
Copyright 2006-2025 The QElectroTech Team
|
2021-02-12 19:28:07 +01:00
|
|
|
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/>.
|
|
|
|
*/
|
2020-05-25 22:17:17 +02:00
|
|
|
#ifndef TERMINALDATA_H
|
|
|
|
#define TERMINALDATA_H
|
|
|
|
|
2020-12-09 15:28:43 +01:00
|
|
|
#include "../qet.h"
|
2021-03-11 19:52:50 +01:00
|
|
|
#include "propertiesinterface.h"
|
2020-05-25 22:17:17 +02:00
|
|
|
|
|
|
|
#include <QPointF>
|
2020-12-09 15:28:43 +01:00
|
|
|
#include <QUuid>
|
2020-05-25 22:17:17 +02:00
|
|
|
|
|
|
|
class QGraphicsObject;
|
|
|
|
|
2020-07-15 18:17:39 +02:00
|
|
|
/**
|
2020-10-17 20:25:30 +02:00
|
|
|
@brief The TerminalData class
|
|
|
|
Data of the terminal.
|
|
|
|
Stored in extra class so it can be used by PartTerminal
|
|
|
|
and Terminal without defining everything again.
|
|
|
|
@note tis class needs to be work on
|
2020-07-15 18:17:39 +02:00
|
|
|
*/
|
2020-05-25 22:17:17 +02:00
|
|
|
class TerminalData : public PropertiesInterface
|
|
|
|
{
|
2021-02-12 19:28:07 +01:00
|
|
|
Q_GADGET
|
|
|
|
|
2020-10-17 20:25:30 +02:00
|
|
|
public:
|
2021-02-06 18:35:55 +01:00
|
|
|
enum Type {
|
|
|
|
Generic,
|
2021-02-12 19:28:07 +01:00
|
|
|
Inner,
|
|
|
|
Outer
|
2021-02-06 18:35:55 +01:00
|
|
|
};
|
2021-02-12 19:28:07 +01:00
|
|
|
Q_ENUM(Type)
|
2021-02-06 18:35:55 +01:00
|
|
|
|
2020-10-17 20:25:30 +02:00
|
|
|
TerminalData();
|
|
|
|
TerminalData(QGraphicsObject* parent);
|
2021-02-05 18:45:04 +01:00
|
|
|
~TerminalData() override;
|
2020-05-25 22:17:17 +02:00
|
|
|
|
2020-10-17 20:25:30 +02:00
|
|
|
void init();
|
2020-05-26 18:47:24 +02:00
|
|
|
|
2020-10-17 20:25:30 +02:00
|
|
|
void setParent(QGraphicsObject* parent);
|
|
|
|
void toSettings(QSettings &settings,
|
2021-03-11 19:52:50 +01:00
|
|
|
const QString prefix = QString()) const override;
|
|
|
|
void fromSettings(const QSettings &settings,
|
|
|
|
const QString prefix = QString()) override;
|
|
|
|
QDomElement toXml(QDomDocument &xml_element) const override;
|
|
|
|
bool fromXml(const QDomElement &xml_element) override;
|
2020-10-16 11:43:45 +02:00
|
|
|
|
2021-02-06 18:35:55 +01:00
|
|
|
static QString typeToString(TerminalData::Type type);
|
|
|
|
static TerminalData::Type typeFromString(const QString &string);
|
|
|
|
|
2020-07-19 20:05:58 +02:00
|
|
|
// must be public, because this class is a private member
|
|
|
|
// of PartTerminal/Terminal and they must access this data
|
2020-10-17 20:25:30 +02:00
|
|
|
public:
|
|
|
|
/**
|
|
|
|
@brief m_orientation
|
|
|
|
Orientation of the terminal
|
|
|
|
*/
|
2021-03-11 19:52:50 +01:00
|
|
|
Qet::Orientation m_orientation;
|
2020-10-17 20:25:30 +02:00
|
|
|
/**
|
2021-03-11 19:52:50 +01:00
|
|
|
@brief second_point
|
2020-10-17 20:25:30 +02:00
|
|
|
Position of the second point of the terminal
|
|
|
|
in scene coordinates
|
|
|
|
*/
|
2021-03-11 19:52:50 +01:00
|
|
|
QPointF m_second_point;
|
2020-10-17 20:25:30 +02:00
|
|
|
/**
|
|
|
|
@brief m_uuid
|
|
|
|
Uuid of the terminal.
|
2020-05-25 22:17:17 +02:00
|
|
|
|
2020-10-17 20:25:30 +02:00
|
|
|
In elementscene.cpp an element gets a new uuid when
|
|
|
|
saving the element. In the current state
|
|
|
|
each connection is made by using the local position
|
|
|
|
of the terminal and a dynamic id. In the new
|
|
|
|
case, each terminal should have it's own uuid to
|
|
|
|
identify it uniquely. When changing each time this
|
|
|
|
uuid, the conductor after updating the part is anymore
|
|
|
|
valid. So if in the loaded document a uuid exists,
|
|
|
|
use this one and don't create a new one.
|
|
|
|
*/
|
2021-03-11 19:52:50 +01:00
|
|
|
QUuid m_uuid;
|
2020-10-17 20:25:30 +02:00
|
|
|
/**
|
|
|
|
@brief m_name
|
|
|
|
Name of the element.
|
|
|
|
It can be used to create wiring harness tables
|
|
|
|
*/
|
|
|
|
QString m_name;
|
2020-05-25 22:17:17 +02:00
|
|
|
|
2020-10-17 20:25:30 +02:00
|
|
|
/**
|
|
|
|
@brief m_pos
|
|
|
|
Position of the terminal. The second point is calculated
|
|
|
|
from this position and the orientation
|
|
|
|
@note
|
|
|
|
Important: this variable is only updated during read
|
|
|
|
from xml and not during mouse move!
|
|
|
|
It is used to store the initial position so that
|
|
|
|
PartTerminal and Terminal have access to it.
|
|
|
|
*/
|
2021-03-11 19:52:50 +01:00
|
|
|
QPointF m_pos;
|
|
|
|
|
2021-02-06 18:35:55 +01:00
|
|
|
TerminalData::Type m_type = TerminalData::Generic;
|
2021-03-11 19:52:50 +01:00
|
|
|
|
2020-10-17 20:25:30 +02:00
|
|
|
private:
|
|
|
|
QGraphicsObject* q{nullptr};
|
2020-05-25 22:17:17 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif // TERMINALDATA_H
|