QElectroTech  0.70
conductorprofile.cpp
Go to the documentation of this file.
1 /*
2  Copyright 2006-2019 The QElectroTech Team
3  This file is part of QElectroTech.
4 
5  QElectroTech is free software: you can redistribute it and/or modify
6  it under the terms of the GNU General Public License as published by
7  the Free Software Foundation, either version 2 of the License, or
8  (at your option) any later version.
9 
10  QElectroTech is distributed in the hope that it will be useful,
11  but WITHOUT ANY WARRANTY; without even the implied warranty of
12  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  GNU General Public License for more details.
14 
15  You should have received a copy of the GNU General Public License
16  along with QElectroTech. If not, see <http://www.gnu.org/licenses/>.
17 */
18 #include "conductorprofile.h"
21 #include "terminal.h"
22 
25 }
26 
32  fromConductor(conductor);
33 }
34 
42  foreach(ConductorSegmentProfile *csp, c.segments) {
43  segments << new ConductorSegmentProfile(*csp);
44  }
45 }
46 
52  if (&c == this) return(*this);
53 
54  // supprime ses informations
55  setNull();
56 
57  // copie les informations de l'autre profil de conducteur
60  foreach(ConductorSegmentProfile *csp, c.segments) {
61  segments << new ConductorSegmentProfile(*csp);
62  }
63  return(*this);
64 }
65 
68  setNull();
69 }
70 
73  return(segments.isEmpty());
74 }
75 
78  foreach(ConductorSegmentProfile *csp, segments) delete csp;
79  segments.clear();
80 }
81 
83 qreal ConductorProfile::width() const {
84  qreal width = 0.0;
85  foreach(ConductorSegmentProfile *csp, segments) {
86  if (csp -> isHorizontal) width += csp -> length;
87  }
88  return(width);
89 }
90 
93  qreal height = 0.0;
94  foreach(ConductorSegmentProfile *csp, segments) {
95  if (!csp -> isHorizontal) height += csp -> length;
96  }
97  return(height);
98 }
99 
105  if (type == QET::Both) return(segments.count());
106  uint nb_seg = 0;
107  foreach(ConductorSegmentProfile *csp, segments) {
108  if (type == QET::Horizontal && csp -> isHorizontal) ++ nb_seg;
109  else if (type == QET::Vertical && !csp -> isHorizontal) ++ nb_seg;
110  }
111  return(nb_seg);
112 }
113 
115 QList<ConductorSegmentProfile *> ConductorProfile::horizontalSegments() {
116  QList<ConductorSegmentProfile *> segments_list;
117  foreach(ConductorSegmentProfile *csp, segments) {
118  if (csp -> isHorizontal) segments_list << csp;
119  }
120  return(segments_list);
121 }
122 
124 QList<ConductorSegmentProfile *> ConductorProfile::verticalSegments() {
125  QList<ConductorSegmentProfile *> segments_list;
126  foreach(ConductorSegmentProfile *csp, segments) {
127  if (!csp -> isHorizontal) segments_list << csp;
128  }
129  return(segments_list);
130 }
131 
136  // supprime les segments precedents
137  setNull();
138 
139  foreach(ConductorSegment *conductor_segment, conductor -> segmentsList()) {
140  segments << new ConductorSegmentProfile(conductor_segment);
141  }
142  beginOrientation = conductor -> terminal1 -> orientation();
143  endOrientation = conductor -> terminal2 -> orientation();
144 }
145 
151 QDebug &operator<<(QDebug d, ConductorProfile &t) {
152  d << "ConductorProfile {";
153  foreach(ConductorSegmentProfile *csp, t.segments) {
154  d << "CSP" << (csp -> isHorizontal ? "horizontal" : "vertical") << ":" << csp -> length << ",";
155  }
156  d << "}";
157  return(d.space());
158 }
qreal width() const
QList< ConductorSegmentProfile * > verticalSegments()
ConductorSegmentType
Known kinds of conductor segments.
Definition: qet.h:86
QList< ConductorSegmentProfile * > segments
Segments composing the conductor.
qreal height() const
Vertical segment.
Definition: qet.h:88
ConductorProfile & operator=(const ConductorProfile &)
void setNull()
supprime les segments du profil de conducteur
Invalid segment.
Definition: qet.h:89
Qet::Orientation endOrientation
Orientation of the end terminal.
void fromConductor(Conductor *)
QDebug & operator<<(QDebug d, ConductorProfile &t)
QList< ConductorSegmentProfile * > horizontalSegments()
uint segmentsCount(QET::ConductorSegmentType) const
virtual ~ConductorProfile()
destructeur
ConductorProfile()
Constructeur.
Horizontal segment.
Definition: qet.h:87
Qet::Orientation beginOrientation
Orientation of the start terminal.