Advertisement
suggestname

Diff

Jan 13th, 2017
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Diff 8.33 KB | None | 0 0
  1. diff --git a/src/core/applications/application.h b/src/core/applications/application.h
  2. index 3121ef5..bf40898 100644
  3. --- a/src/core/applications/application.h
  4. +++ b/src/core/applications/application.h
  5. @@ -104,6 +104,7 @@ public:
  6.          Module_RiskFailure,
  7.          Module_PLSCADDTools,
  8.          Module_ShieldWireDesign,
  9. +        Module_CableSag,
  10.          Module_Last
  11.      };
  12.  
  13. diff --git a/src/core/applications/sagtension.cpp b/src/core/applications/sagtension.cpp
  14. index b258887..1fc8336 100644
  15. --- a/src/core/applications/sagtension.cpp
  16. +++ b/src/core/applications/sagtension.cpp
  17. @@ -17,6 +17,7 @@ SagTension::SagTension(Project *project) :
  18.      m_modules[Module_CableTypeCrossSection] = true;
  19.      m_modules[Module_CableTypeLinearWeight] = true;
  20.      m_modules[Module_CableTypeTensileStrength] = true;
  21. +    m_modules[Module_CableSag] = true;
  22.  
  23.      g_sagTension = this;
  24.  }
  25. diff --git a/src/core/core.pro b/src/core/core.pro
  26. index 8fe8199..e7415a8 100644
  27. --- a/src/core/core.pro
  28. +++ b/src/core/core.pro
  29. @@ -46,7 +46,8 @@ HEADERS = \
  30.      transmissionline.h \
  31.      company.h \
  32.      person.h \
  33. -    cablestressstrain.h
  34. +    cablestressstrain.h \
  35. +    cablesag.h
  36.  
  37.  SOURCES = \
  38.      applications/application.cpp \
  39. @@ -92,7 +93,8 @@ SOURCES = \
  40.      transmissionline.cpp \
  41.      company.cpp \
  42.      person.cpp \
  43. -    cablestressstrain.cpp
  44. +    cablestressstrain.cpp \
  45. +    cablesag.cpp
  46.  
  47.  TARGET = core
  48.  TEMPLATE = lib
  49. diff --git a/src/core/project.h b/src/core/project.h
  50. index f45ae4c..c1a87e0 100644
  51. --- a/src/core/project.h
  52. +++ b/src/core/project.h
  53. @@ -143,6 +143,7 @@ public:
  54.      uint getPipelineUidGen() { return m_pipelineUidGen++; }
  55.      uint getSubstationUidGen() { return m_substationUidGen++; }
  56.      uint getTransmissionLineUidGen() { return m_transmissionLineUidGen++; }
  57. +    uint getCableSagUidGen() { return m_cableSagUidGen++; }
  58.  
  59.  private:
  60.      void createApplications();
  61. @@ -188,6 +189,7 @@ private:
  62.      uint m_pipelineUidGen = 1;
  63.      uint m_substationUidGen = 1;
  64.      uint m_transmissionLineUidGen = 1;
  65. +    uint m_cableSagUidGen = 1;
  66.  
  67.  private slots:
  68.      void checkFiles();
  69. diff --git a/src/core/transmissionline.cpp b/src/core/transmissionline.cpp
  70. index b90c3b9..5f28dec 100644
  71. --- a/src/core/transmissionline.cpp
  72. +++ b/src/core/transmissionline.cpp
  73. @@ -6,6 +6,7 @@
  74.  #include "circuit.h"
  75.  #include "shieldwire.h"
  76.  #include "riskfailuregap.h"
  77. +#include "cablesag.h"
  78.  #include "section.h"
  79.  #include <QFile>
  80.  #include <QTextStream>
  81. @@ -121,6 +122,17 @@ void TransmissionLine::load(QSettings *settings)
  82.          settings->endGroup();
  83.      }
  84.      settings->endGroup();
  85. +
  86. +    settings->beginGroup("CableSags");
  87. +    removeCableSags();
  88. +    for(const QString& group : settings->childGroups()) {
  89. +        settings->beginGroup(group);
  90. +        CableSag *c = new CableSag();
  91. +        c->load(settings);
  92. +        m_cableSags.push_back(c);
  93. +        settings->endGroup();
  94. +    }
  95. +    settings->endGroup();
  96.  }
  97.  
  98.  void TransmissionLine::save(QSettings *settings, bool saveTemporary)
  99. @@ -211,6 +223,18 @@ void TransmissionLine::save(QSettings *settings, bool saveTemporary)
  100.      }
  101.      settings->endGroup();
  102.  
  103. +    settings->beginGroup("CableSags");
  104. +    settings->setValue("_isArray", true);
  105. +    int cablesSagCount = m_cableSags.size();
  106. +    int csDigits = (int)std::log10(cablesSagCount) + 1;
  107. +    for(int i = 0; i < cablesSagCount; ++i) {
  108. +        CableSag *cableSag = m_cableSags[i];
  109. +        settings->beginGroup(QString("CableSag%1").arg(i, csDigits, 10, QChar('0')));
  110. +        cableSag->save(settings);
  111. +        settings->endGroup();
  112. +    }
  113. +    settings->endGroup();
  114. +
  115.      if(saveTemporary) {
  116.          settings->beginGroup("Sections");
  117.          settings->setValue("_isArray", true);
  118. @@ -1010,6 +1034,71 @@ bool TransmissionLine::moveRiskFailureGaps(int fromIndex, int toIndex)
  119.      return true;
  120.  }
  121.  
  122. +CableSag *TransmissionLine::addCableSag(int index, bool clone)
  123. +{
  124. +    CableSag *cableSag;
  125. +    if(index > 0 && index < m_cableSags.size() && clone)
  126. +        cableSag = m_cableSags[index]->clone();
  127. +    else {
  128. +        cableSag = new CableSag();
  129. +        cableSag->setId(g_project->getCableSagUidGen());
  130. +    }
  131. +
  132. +    if(index > 0 && index < m_cableSags.size())
  133. +        m_cableSags.insert(index, cableSag);
  134. +    else
  135. +        m_cableSags.push_back(cableSag);
  136. +
  137. +    return cableSag;
  138. +}
  139. +
  140. +bool TransmissionLine::removeCableSag(int index, QString& error)
  141. +{
  142. +    if(index < 0 || index >= m_cableSags.size()) {
  143. +        error += QObject::tr("This cable sag does not exist.") + "\n";
  144. +        return false;
  145. +    }
  146. +
  147. +    auto it = m_cableSags.begin() + index;
  148. +    delete (*it);
  149. +    m_cableSags.erase(it);
  150. +    return true;
  151. +}
  152. +
  153. +bool TransmissionLine::removeCableSagById(uint id)
  154. +{
  155. +    for(auto it = m_cableSags.begin(); it < m_cableSags.end(); it++) {
  156. +        if((*it)->getId() == id) {
  157. +            m_cableSags.erase(it);
  158. +            return true;
  159. +        }
  160. +    }
  161. +    return false;
  162. +}
  163. +
  164. +void TransmissionLine::removeCableSags()
  165. +{
  166. +    for(CableSag *cableSag : m_cableSags)
  167. +        delete cableSag;
  168. +    m_cableSags.clear();
  169. +}
  170. +
  171. +CableSag *TransmissionLine::getCableSag(int index)
  172. +{
  173. +    if(index < 0 || index >= m_cableSags.size())
  174. +        return nullptr;
  175. +    return m_cableSags[index];
  176. +}
  177. +
  178. +bool TransmissionLine::moveCableSags(int fromIndex, int toIndex)
  179. +{
  180. +    if(fromIndex < 0 || fromIndex >= m_cableSags.size() || toIndex < 0 || toIndex >= m_cableSags.size())
  181. +        return false;
  182. +
  183. +    std::swap(m_cableSags[fromIndex], m_cableSags[toIndex]);
  184. +    return true;
  185. +}
  186. +
  187.  void TransmissionLine::setAverageElevation(const QString& elevation)
  188.  {
  189.      for(Tower *tower : m_towers)
  190. diff --git a/src/core/transmissionline.h b/src/core/transmissionline.h
  191. index b4d2cb5..3dbf3cf 100644
  192. --- a/src/core/transmissionline.h
  193. +++ b/src/core/transmissionline.h
  194. @@ -13,6 +13,7 @@ class Circuit;
  195.  class ShieldWire;
  196.  class Section;
  197.  class RiskFailureGap;
  198. +class CableSag;
  199.  class QSettings;
  200.  
  201.  struct TransmissionLineFaultLocation
  202. @@ -84,6 +85,14 @@ public:
  203.      const QVector<RiskFailureGap*>& getRiskFailureGaps() { return m_riskFailureGaps; }
  204.      bool moveRiskFailureGaps(int fromIndex, int toIndex);
  205.  
  206. +    CableSag *addCableSag(int index, bool clone = false);
  207. +    bool removeCableSag(int index, QString& error);
  208. +    bool removeCableSagById(uint id);
  209. +    void removeCableSags();
  210. +    CableSag *getCableSag(int index);
  211. +    const QVector<CableSag*>& getCableSags() { return m_cableSags; }
  212. +    bool moveCableSags(int fromIndex, int toIndex);
  213. +
  214.      void setId(uint id) { m_id = id; }
  215.      void setName(const QString& name) { m_name = name; }
  216.      void setNominalVoltageText(const QString& nominalVoltage) { m_nominalVoltage = nominalVoltage; }
  217. @@ -193,6 +202,7 @@ private:
  218.      QVector<Circuit*> m_circuits;
  219.      QVector<ShieldWire*> m_shieldWires;
  220.      QVector<RiskFailureGap*> m_riskFailureGaps;
  221. +    QVector<CableSag*> m_cableSags;
  222.      bool m_ignored = false;
  223.  
  224.      // Output variables
  225. diff --git a/src/views/inputview.cpp b/src/views/inputview.cpp
  226. index a01d515..f0c5837 100644
  227. --- a/src/views/inputview.cpp
  228. +++ b/src/views/inputview.cpp
  229. @@ -17,6 +17,7 @@
  230.  #include "shieldwiresview.h"
  231.  #include "reportoptionsview.h"
  232.  #include "plscaddtoolsview.h"
  233. +#include "cablesagview.h"
  234.  #include <core/project.h>
  235.  #include <QFile>
  236.  
  237. @@ -61,6 +62,9 @@ InputView::InputView(QWidget *parent) :
  238.  
  239.          if(g_project->hasModule(Application::Module_Tower))
  240.              insertTab(new TowersView(this), tr("Structures"), "towers", tlTab);
  241. +
  242. +        if(g_project->hasModule(Application::Module_CableSag))
  243. +            insertTab(new CableSagView(this), tr("Cables"), "cableSag", tlTab);
  244.      }
  245.  
  246.      if(g_project->hasModule(Application::Module_AudibleNoise))
  247. diff --git a/src/views/views.pro b/src/views/views.pro
  248. index e92ff64..3a74c8d 100644
  249. --- a/src/views/views.pro
  250. +++ b/src/views/views.pro
  251. @@ -52,7 +52,8 @@ HEADERS = \
  252.      sectiongraphview.h \
  253.      sectiongraph.h \
  254.      personview.h \
  255. -    cablestressstrainview.h
  256. +    cablestressstrainview.h \
  257. +    cablesagview.h
  258.  
  259.  SOURCES = \
  260.      audiblenoiseview.cpp \
  261. @@ -104,7 +105,8 @@ SOURCES = \
  262.      sectiongraphview.cpp \
  263.      sectiongraph.cpp \
  264.      personview.cpp \
  265. -    cablestressstrainview.cpp
  266. +    cablestressstrainview.cpp \
  267. +    cablesagview.cpp
  268.  
  269.  TEMPLATE = lib
  270.  TARGET = views
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement