Backport commit 5307, 5311, 5312

Update changelog 


git-svn-id: svn+ssh://svn.tuxfamily.org/svnroot/qet/qet/branches/0.60@5314 bfdf4180-ca20-0410-9c96-a3a8aa849046
This commit is contained in:
scorpio810
2018-04-08 04:05:18 +00:00
parent 5178de2c15
commit 11cc09a637
12 changed files with 167 additions and 113 deletions

View File

@@ -1517,12 +1517,14 @@ void Conductor::displayedTextChanged()
* part of the returned QSet.
* @param all_diagram : if true search in all diagram of the project,
* false search only in the parent diagram of this conductor
* @param t_list, a list of terminal already cheched for the serach of potential.
* @param t_list, a list of terminal already found for this potential.
* @return a QSet of conductor at the same potential.
*/
QSet<Conductor *> Conductor::relatedPotentialConductors(const bool all_diagram, QList <Terminal *> *t_list) {
QSet<Conductor *> Conductor::relatedPotentialConductors(const bool all_diagram, QList <Terminal *> *t_list)
{
bool declar_t_list = false;
if (t_list == 0) {
if (t_list == nullptr)
{
declar_t_list = true;
t_list = new QList <Terminal *>;
}
@@ -1531,23 +1533,29 @@ QSet<Conductor *> Conductor::relatedPotentialConductors(const bool all_diagram,
QList <Terminal *> this_terminal;
this_terminal << terminal1 << terminal2;
// Return all conductor of terminal 1 and 2
foreach (Terminal *terminal, this_terminal) {
if (!t_list -> contains(terminal)) {
t_list -> append(terminal);
QList <Conductor *> other_conductors_list_t = terminal -> conductors();
// Return all conductors of terminal 1 and 2
for (Terminal *terminal : this_terminal)
{
if (!t_list->contains(terminal))
{
t_list->append(terminal);
QList <Conductor *> other_conductors_list_t = terminal->conductors();
//get terminal share the same potential of @terminal, of parent element
Terminal *t1_bis = relatedPotentialTerminal(terminal, all_diagram);
if (t1_bis && !t_list->contains(t1_bis)) {
t_list -> append(t1_bis);
other_conductors_list_t += t1_bis->conductors();
//Get the other terminals of the parent element of @terminal, who share the same potential
//This is use for element type "folio report" and "terminal element"
for (Terminal *t : relatedPotentialTerminal(terminal, all_diagram))
{
if (!t_list->contains(t))
{
t_list -> append(t);
other_conductors_list_t += t->conductors();
}
}
other_conductors_list_t.removeAll(this);
// Research the conductors connected to conductors already found
foreach (Conductor *c, other_conductors_list_t) {
other_conductors += c -> relatedPotentialConductors(all_diagram, t_list);
//Get the conductors at the same potential for each conductors of other_conductors_list_t
for (Conductor *c : other_conductors_list_t) {
other_conductors += c->relatedPotentialConductors(all_diagram, t_list);
}
other_conductors += other_conductors_list_t.toSet();
}

View File

@@ -765,24 +765,27 @@ Element *Terminal::parentElement() const {
* @param t terminal to start search
* @param all_diagram :if true return all related terminal,
* false return only terminal in the same diagram of @t
* @return
* @return the list of terminal at the same potential
*/
Terminal * relatedPotentialTerminal (const Terminal *terminal, const bool all_diagram) {
// If terminal parent element is a folio report.
if (all_diagram && terminal -> parentElement() -> linkType() & Element::AllReport) {
QList<Terminal *> relatedPotentialTerminal (const Terminal *terminal, const bool all_diagram)
{
// If terminal parent element is a folio report.
if (all_diagram && terminal -> parentElement() -> linkType() & Element::AllReport)
{
QList <Element *> elmt_list = terminal -> parentElement() -> linkedElements();
if (!elmt_list.isEmpty()) {
return (elmt_list.first() -> terminals().first());
if (!elmt_list.isEmpty())
{
return (elmt_list.first()->terminals());
}
}
// If terminal parent element is a Terminal element.
else if (terminal -> parentElement() -> linkType() & Element::Terminale) {
QList <Terminal *> terminals = terminal -> parentElement() -> terminals();
terminals.removeAll(const_cast<Terminal *> (terminal));
if (!terminals.isEmpty())
return terminals.first();
// If terminal parent element is a Terminal element.
else if (terminal -> parentElement() -> linkType() & Element::Terminale)
{
QList <Terminal *> terminals = terminal->parentElement()->terminals();
terminals.removeAll(const_cast<Terminal *>(terminal));
return terminals;
}
return nullptr;
return QList<Terminal *>();
}

View File

@@ -169,6 +169,6 @@ inline QString Terminal::name() const {
return(name_terminal_);
}
Terminal * relatedPotentialTerminal (const Terminal *terminal, const bool all_diagram = true);
QList<Terminal *> relatedPotentialTerminal (const Terminal *terminal, const bool all_diagram = true);
#endif