Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- diff --git a/src/core/applications/application.h b/src/core/applications/application.h
- index 3121ef5..bf40898 100644
- --- a/src/core/applications/application.h
- +++ b/src/core/applications/application.h
- @@ -104,6 +104,7 @@ public:
- Module_RiskFailure,
- Module_PLSCADDTools,
- Module_ShieldWireDesign,
- + Module_CableSag,
- Module_Last
- };
- diff --git a/src/core/applications/sagtension.cpp b/src/core/applications/sagtension.cpp
- index b258887..1fc8336 100644
- --- a/src/core/applications/sagtension.cpp
- +++ b/src/core/applications/sagtension.cpp
- @@ -17,6 +17,7 @@ SagTension::SagTension(Project *project) :
- m_modules[Module_CableTypeCrossSection] = true;
- m_modules[Module_CableTypeLinearWeight] = true;
- m_modules[Module_CableTypeTensileStrength] = true;
- + m_modules[Module_CableSag] = true;
- g_sagTension = this;
- }
- diff --git a/src/core/core.pro b/src/core/core.pro
- index 8fe8199..e7415a8 100644
- --- a/src/core/core.pro
- +++ b/src/core/core.pro
- @@ -46,7 +46,8 @@ HEADERS = \
- transmissionline.h \
- company.h \
- person.h \
- - cablestressstrain.h
- + cablestressstrain.h \
- + cablesag.h
- SOURCES = \
- applications/application.cpp \
- @@ -92,7 +93,8 @@ SOURCES = \
- transmissionline.cpp \
- company.cpp \
- person.cpp \
- - cablestressstrain.cpp
- + cablestressstrain.cpp \
- + cablesag.cpp
- TARGET = core
- TEMPLATE = lib
- diff --git a/src/core/project.h b/src/core/project.h
- index f45ae4c..c1a87e0 100644
- --- a/src/core/project.h
- +++ b/src/core/project.h
- @@ -143,6 +143,7 @@ public:
- uint getPipelineUidGen() { return m_pipelineUidGen++; }
- uint getSubstationUidGen() { return m_substationUidGen++; }
- uint getTransmissionLineUidGen() { return m_transmissionLineUidGen++; }
- + uint getCableSagUidGen() { return m_cableSagUidGen++; }
- private:
- void createApplications();
- @@ -188,6 +189,7 @@ private:
- uint m_pipelineUidGen = 1;
- uint m_substationUidGen = 1;
- uint m_transmissionLineUidGen = 1;
- + uint m_cableSagUidGen = 1;
- private slots:
- void checkFiles();
- diff --git a/src/core/transmissionline.cpp b/src/core/transmissionline.cpp
- index b90c3b9..5f28dec 100644
- --- a/src/core/transmissionline.cpp
- +++ b/src/core/transmissionline.cpp
- @@ -6,6 +6,7 @@
- #include "circuit.h"
- #include "shieldwire.h"
- #include "riskfailuregap.h"
- +#include "cablesag.h"
- #include "section.h"
- #include <QFile>
- #include <QTextStream>
- @@ -121,6 +122,17 @@ void TransmissionLine::load(QSettings *settings)
- settings->endGroup();
- }
- settings->endGroup();
- +
- + settings->beginGroup("CableSags");
- + removeCableSags();
- + for(const QString& group : settings->childGroups()) {
- + settings->beginGroup(group);
- + CableSag *c = new CableSag();
- + c->load(settings);
- + m_cableSags.push_back(c);
- + settings->endGroup();
- + }
- + settings->endGroup();
- }
- void TransmissionLine::save(QSettings *settings, bool saveTemporary)
- @@ -211,6 +223,18 @@ void TransmissionLine::save(QSettings *settings, bool saveTemporary)
- }
- settings->endGroup();
- + settings->beginGroup("CableSags");
- + settings->setValue("_isArray", true);
- + int cablesSagCount = m_cableSags.size();
- + int csDigits = (int)std::log10(cablesSagCount) + 1;
- + for(int i = 0; i < cablesSagCount; ++i) {
- + CableSag *cableSag = m_cableSags[i];
- + settings->beginGroup(QString("CableSag%1").arg(i, csDigits, 10, QChar('0')));
- + cableSag->save(settings);
- + settings->endGroup();
- + }
- + settings->endGroup();
- +
- if(saveTemporary) {
- settings->beginGroup("Sections");
- settings->setValue("_isArray", true);
- @@ -1010,6 +1034,71 @@ bool TransmissionLine::moveRiskFailureGaps(int fromIndex, int toIndex)
- return true;
- }
- +CableSag *TransmissionLine::addCableSag(int index, bool clone)
- +{
- + CableSag *cableSag;
- + if(index > 0 && index < m_cableSags.size() && clone)
- + cableSag = m_cableSags[index]->clone();
- + else {
- + cableSag = new CableSag();
- + cableSag->setId(g_project->getCableSagUidGen());
- + }
- +
- + if(index > 0 && index < m_cableSags.size())
- + m_cableSags.insert(index, cableSag);
- + else
- + m_cableSags.push_back(cableSag);
- +
- + return cableSag;
- +}
- +
- +bool TransmissionLine::removeCableSag(int index, QString& error)
- +{
- + if(index < 0 || index >= m_cableSags.size()) {
- + error += QObject::tr("This cable sag does not exist.") + "\n";
- + return false;
- + }
- +
- + auto it = m_cableSags.begin() + index;
- + delete (*it);
- + m_cableSags.erase(it);
- + return true;
- +}
- +
- +bool TransmissionLine::removeCableSagById(uint id)
- +{
- + for(auto it = m_cableSags.begin(); it < m_cableSags.end(); it++) {
- + if((*it)->getId() == id) {
- + m_cableSags.erase(it);
- + return true;
- + }
- + }
- + return false;
- +}
- +
- +void TransmissionLine::removeCableSags()
- +{
- + for(CableSag *cableSag : m_cableSags)
- + delete cableSag;
- + m_cableSags.clear();
- +}
- +
- +CableSag *TransmissionLine::getCableSag(int index)
- +{
- + if(index < 0 || index >= m_cableSags.size())
- + return nullptr;
- + return m_cableSags[index];
- +}
- +
- +bool TransmissionLine::moveCableSags(int fromIndex, int toIndex)
- +{
- + if(fromIndex < 0 || fromIndex >= m_cableSags.size() || toIndex < 0 || toIndex >= m_cableSags.size())
- + return false;
- +
- + std::swap(m_cableSags[fromIndex], m_cableSags[toIndex]);
- + return true;
- +}
- +
- void TransmissionLine::setAverageElevation(const QString& elevation)
- {
- for(Tower *tower : m_towers)
- diff --git a/src/core/transmissionline.h b/src/core/transmissionline.h
- index b4d2cb5..3dbf3cf 100644
- --- a/src/core/transmissionline.h
- +++ b/src/core/transmissionline.h
- @@ -13,6 +13,7 @@ class Circuit;
- class ShieldWire;
- class Section;
- class RiskFailureGap;
- +class CableSag;
- class QSettings;
- struct TransmissionLineFaultLocation
- @@ -84,6 +85,14 @@ public:
- const QVector<RiskFailureGap*>& getRiskFailureGaps() { return m_riskFailureGaps; }
- bool moveRiskFailureGaps(int fromIndex, int toIndex);
- + CableSag *addCableSag(int index, bool clone = false);
- + bool removeCableSag(int index, QString& error);
- + bool removeCableSagById(uint id);
- + void removeCableSags();
- + CableSag *getCableSag(int index);
- + const QVector<CableSag*>& getCableSags() { return m_cableSags; }
- + bool moveCableSags(int fromIndex, int toIndex);
- +
- void setId(uint id) { m_id = id; }
- void setName(const QString& name) { m_name = name; }
- void setNominalVoltageText(const QString& nominalVoltage) { m_nominalVoltage = nominalVoltage; }
- @@ -193,6 +202,7 @@ private:
- QVector<Circuit*> m_circuits;
- QVector<ShieldWire*> m_shieldWires;
- QVector<RiskFailureGap*> m_riskFailureGaps;
- + QVector<CableSag*> m_cableSags;
- bool m_ignored = false;
- // Output variables
- diff --git a/src/views/inputview.cpp b/src/views/inputview.cpp
- index a01d515..f0c5837 100644
- --- a/src/views/inputview.cpp
- +++ b/src/views/inputview.cpp
- @@ -17,6 +17,7 @@
- #include "shieldwiresview.h"
- #include "reportoptionsview.h"
- #include "plscaddtoolsview.h"
- +#include "cablesagview.h"
- #include <core/project.h>
- #include <QFile>
- @@ -61,6 +62,9 @@ InputView::InputView(QWidget *parent) :
- if(g_project->hasModule(Application::Module_Tower))
- insertTab(new TowersView(this), tr("Structures"), "towers", tlTab);
- +
- + if(g_project->hasModule(Application::Module_CableSag))
- + insertTab(new CableSagView(this), tr("Cables"), "cableSag", tlTab);
- }
- if(g_project->hasModule(Application::Module_AudibleNoise))
- diff --git a/src/views/views.pro b/src/views/views.pro
- index e92ff64..3a74c8d 100644
- --- a/src/views/views.pro
- +++ b/src/views/views.pro
- @@ -52,7 +52,8 @@ HEADERS = \
- sectiongraphview.h \
- sectiongraph.h \
- personview.h \
- - cablestressstrainview.h
- + cablestressstrainview.h \
- + cablesagview.h
- SOURCES = \
- audiblenoiseview.cpp \
- @@ -104,7 +105,8 @@ SOURCES = \
- sectiongraphview.cpp \
- sectiongraph.cpp \
- personview.cpp \
- - cablestressstrainview.cpp
- + cablestressstrainview.cpp \
- + cablesagview.cpp
- TEMPLATE = lib
- TARGET = views
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement