2021-02-16 19:44:57 +01:00
|
|
|
/*
|
2021-02-13 13:07:36 +01:00
|
|
|
Copyright 2006-2021 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 ELEMENTDATA_H
|
|
|
|
#define ELEMENTDATA_H
|
|
|
|
|
2021-03-11 19:52:50 +01:00
|
|
|
#include "propertiesinterface.h"
|
2021-02-13 13:07:36 +01:00
|
|
|
#include "../diagramcontext.h"
|
|
|
|
#include "../NameList/nameslist.h"
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief The ElementData class
|
|
|
|
* WARNING
|
|
|
|
* This class inherit from PropertiesInterface but
|
|
|
|
* only fromXml is actually reimplemented.
|
|
|
|
*/
|
|
|
|
class ElementData : public PropertiesInterface
|
|
|
|
{
|
|
|
|
Q_GADGET
|
|
|
|
|
|
|
|
public:
|
|
|
|
enum Type {
|
|
|
|
Simple = 1,
|
|
|
|
NextReport = 2,
|
|
|
|
PreviousReport = 4,
|
|
|
|
AllReport = 6,
|
|
|
|
Master = 8,
|
|
|
|
Slave = 16,
|
|
|
|
Terminale = 32};
|
|
|
|
Q_ENUM(Type)
|
|
|
|
|
|
|
|
enum MasterType {
|
|
|
|
Coil,
|
|
|
|
Protection,
|
|
|
|
Commutator
|
|
|
|
};
|
|
|
|
Q_ENUM(MasterType)
|
|
|
|
|
|
|
|
enum SlaveType {
|
|
|
|
SSimple,
|
|
|
|
Power,
|
|
|
|
DelayOn,
|
|
|
|
DelayOff,
|
|
|
|
delayOnOff
|
|
|
|
};
|
|
|
|
Q_ENUM(SlaveType)
|
|
|
|
|
|
|
|
enum SlaveState {
|
|
|
|
NO,
|
|
|
|
NC,
|
|
|
|
SW
|
|
|
|
};
|
|
|
|
Q_ENUM(SlaveState)
|
|
|
|
|
2021-02-16 19:44:57 +01:00
|
|
|
enum TerminalType {
|
|
|
|
TTGeneric,
|
2021-05-21 19:15:26 +02:00
|
|
|
TTFuse,
|
|
|
|
TTSectional,
|
|
|
|
TTDiode,
|
|
|
|
TTGround
|
2021-02-16 19:44:57 +01:00
|
|
|
};
|
|
|
|
Q_ENUM(TerminalType)
|
|
|
|
|
|
|
|
enum TerminalFunction {
|
|
|
|
TFGeneric,
|
2021-05-21 19:15:26 +02:00
|
|
|
TFPhase,
|
|
|
|
TFNeutral,
|
2021-02-16 19:44:57 +01:00
|
|
|
};
|
|
|
|
Q_ENUM(TerminalFunction)
|
|
|
|
|
2021-02-13 13:07:36 +01:00
|
|
|
ElementData() {}
|
|
|
|
~ElementData() override {}
|
|
|
|
|
2021-03-11 19:52:50 +01:00
|
|
|
void toSettings(QSettings &settings, 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;
|
2021-02-13 21:38:36 +01:00
|
|
|
QDomElement kindInfoToXml(QDomDocument &document);
|
|
|
|
|
|
|
|
bool operator==(const ElementData &data) const;
|
|
|
|
bool operator!=(const ElementData &data) const;
|
2021-02-13 13:07:36 +01:00
|
|
|
|
|
|
|
static QString typeToString(ElementData::Type type);
|
|
|
|
static ElementData::Type typeFromString(const QString &string);
|
|
|
|
|
|
|
|
static QString masterTypeToString(ElementData::MasterType type);
|
|
|
|
static ElementData::MasterType masterTypeFromString(const QString &string);
|
|
|
|
|
|
|
|
static QString slaveTypeToString (ElementData::SlaveType type);
|
|
|
|
static ElementData::SlaveType slaveTypeFromString(const QString &string);
|
|
|
|
|
|
|
|
static QString slaveStateToString(ElementData::SlaveState type);
|
|
|
|
static ElementData::SlaveState slaveStateFromString(const QString &string);
|
|
|
|
|
2021-02-16 19:44:57 +01:00
|
|
|
static QString terminalTypeToString(ElementData::TerminalType type);
|
|
|
|
static ElementData::TerminalType terminalTypeFromString(const QString &string);
|
2021-06-07 19:26:41 +02:00
|
|
|
static QString translatedTerminalType(ElementData::TerminalType type);
|
2021-02-16 19:44:57 +01:00
|
|
|
|
|
|
|
static QString terminalFunctionToString(ElementData::TerminalFunction function);
|
|
|
|
static ElementData::TerminalFunction terminalFunctionFromString(const QString &string);
|
|
|
|
|
2021-02-13 13:07:36 +01:00
|
|
|
// must be public, because this class is a private member
|
|
|
|
// of Element/ element editor and they must access this data
|
2021-02-16 19:44:57 +01:00
|
|
|
ElementData::Type m_type = ElementData::Simple;
|
|
|
|
|
2021-02-13 13:07:36 +01:00
|
|
|
ElementData::MasterType m_master_type = ElementData::Coil;
|
2021-02-16 19:44:57 +01:00
|
|
|
|
2021-02-13 13:07:36 +01:00
|
|
|
ElementData::SlaveType m_slave_type = ElementData::SSimple;
|
|
|
|
ElementData::SlaveState m_slave_state = ElementData::NO;
|
2021-02-16 19:44:57 +01:00
|
|
|
|
|
|
|
ElementData::TerminalType m_terminal_type = ElementData::TTGeneric;
|
|
|
|
ElementData::TerminalFunction m_terminal_function = ElementData::TFGeneric;
|
|
|
|
|
2021-02-13 13:07:36 +01:00
|
|
|
int m_contact_count = 1;
|
|
|
|
DiagramContext m_informations;
|
|
|
|
NamesList m_names_list;
|
|
|
|
QString m_drawing_information;
|
|
|
|
|
|
|
|
private:
|
|
|
|
void kindInfoFromXml(const QDomElement &xml_element);
|
|
|
|
};
|
|
|
|
#endif // ELEMENTDATA_H
|