mirror of
https://github.com/qelectrotech/qelectrotech-source-mirror.git
synced 2025-12-17 20:50:34 +01:00
Autonumerotation: Auto numbering isn't increased through the terminal Elements
git-svn-id: svn+ssh://svn.tuxfamily.org/svnroot/qet/qet/trunk@3229 bfdf4180-ca20-0410-9c96-a3a8aa849046
This commit is contained in:
@@ -20,10 +20,11 @@
|
||||
#include "elementscollectionitem.h"
|
||||
#include "qetapp.h"
|
||||
#include "QDomElement"
|
||||
#include "qetgraphicsitem/simpleelement.h"
|
||||
#include "qetgraphicsitem/reportelement.h"
|
||||
#include "qetgraphicsitem/masterelement.h"
|
||||
#include "qetgraphicsitem/slaveelement.h"
|
||||
#include "simpleelement.h"
|
||||
#include "reportelement.h"
|
||||
#include "masterelement.h"
|
||||
#include "slaveelement.h"
|
||||
#include "terminalelement.h"
|
||||
|
||||
ElementFactory* ElementFactory::factory_ = 0;
|
||||
/**
|
||||
@@ -48,8 +49,9 @@ Element * ElementFactory::createElement(const ElementsLocation &location, QGraph
|
||||
if (element_definition->xml().hasAttribute("link_type")) {
|
||||
QString link_type = element_definition->xml().attribute("link_type");
|
||||
if (link_type == "next_report" || link_type == "previous_report") return (new ReportElement(location, link_type, qgi, s, state));
|
||||
if (link_type == "master") return (new MasterElement(location, qgi, s, state));
|
||||
if (link_type == "master") return (new MasterElement (location, qgi, s, state));
|
||||
if (link_type == "slave") return (new SlaveElement (location, qgi, s, state));
|
||||
if (link_type == "terminal") return (new TerminalElement (location, qgi, s, state));
|
||||
}
|
||||
|
||||
//default if nothing match for link_type
|
||||
|
||||
@@ -1325,6 +1325,13 @@ QSet<Conductor *> Conductor::relatedConductors() const {
|
||||
* @return les conducteurs avec lesquels ce conducteur partage
|
||||
* le meme potentiel electrique a l'exception de lui même
|
||||
*/
|
||||
/**
|
||||
* @brief Conductor::relatedPotentialConductors
|
||||
* Return all conductors at the same potential of this conductor, this conductor isn't
|
||||
* part of the returned QSet.
|
||||
* @param t_list, a list of terminal already cheched for the serach of potential.
|
||||
* @return a QSet of conductor at the same potential.
|
||||
*/
|
||||
QSet<Conductor *> Conductor::relatedPotentialConductors(QList <Terminal *> *t_list) {
|
||||
bool declar_t_list = false;
|
||||
if (t_list == 0) {
|
||||
@@ -1333,46 +1340,31 @@ QSet<Conductor *> Conductor::relatedPotentialConductors(QList <Terminal *> *t_li
|
||||
}
|
||||
|
||||
QSet <Conductor *> other_conductors;
|
||||
//renvoie tous les conducteurs du terminal 1
|
||||
if (!t_list -> contains(terminal1)) {
|
||||
t_list -> append(terminal1);
|
||||
QList <Conductor *> other_conductors_list_t1 = terminal1 -> conductors();
|
||||
QList <Terminal *> this_terminal{terminal1, terminal2};
|
||||
|
||||
//get terminal share the same potential of terminal1
|
||||
Terminal *t1_bis = relatedPotentialTerminal(terminal1);
|
||||
// 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();
|
||||
|
||||
//get terminal share the same potential of @terminal, of parent element
|
||||
Terminal *t1_bis = relatedPotentialTerminal(terminal);
|
||||
if (t1_bis && !t_list->contains(t1_bis)) {
|
||||
t_list -> append(t1_bis);
|
||||
other_conductors_list_t1 += t1_bis->conductors();
|
||||
other_conductors_list_t += t1_bis->conductors();
|
||||
}
|
||||
|
||||
other_conductors_list_t1.removeAll(this);
|
||||
//recherche les conducteurs connecté au conducteur déjà trouvé
|
||||
foreach (Conductor *c, other_conductors_list_t1) {
|
||||
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(t_list);
|
||||
}
|
||||
other_conductors += other_conductors_list_t1.toSet();
|
||||
other_conductors += other_conductors_list_t.toSet();
|
||||
}
|
||||
}
|
||||
|
||||
//renvoie tous les conducteurs du terminal 2
|
||||
if (!t_list -> contains(terminal2)) {
|
||||
t_list -> append(terminal2);
|
||||
QList <Conductor *> other_conductors_list_t2 = terminal2 -> conductors();
|
||||
|
||||
//get terminal share the same potential of terminal1
|
||||
Terminal *t2_bis = relatedPotentialTerminal(terminal2);
|
||||
if (t2_bis && !t_list->contains(t2_bis)) {
|
||||
t_list -> append(t2_bis);
|
||||
other_conductors_list_t2 += t2_bis->conductors();
|
||||
}
|
||||
|
||||
other_conductors_list_t2.removeAll(this);
|
||||
//recherche les conducteurs connecté au conducteur déjà trouvé
|
||||
foreach (Conductor *c, other_conductors_list_t2) {
|
||||
other_conductors += c -> relatedPotentialConductors(t_list);
|
||||
}
|
||||
other_conductors += other_conductors_list_t2.toSet();
|
||||
}
|
||||
other_conductors.remove(const_cast<Conductor *>(this));
|
||||
other_conductors.remove(this);
|
||||
|
||||
if (declar_t_list) delete t_list;
|
||||
return(other_conductors);
|
||||
@@ -1380,17 +1372,30 @@ QSet<Conductor *> Conductor::relatedPotentialConductors(QList <Terminal *> *t_li
|
||||
|
||||
/**
|
||||
* @brief Conductor::relatedPotentialTerminal
|
||||
* find another terminal in the same electric potential of terminal @t
|
||||
* Return terminal at the same potential from the same
|
||||
* parent element of @t.
|
||||
* For folio report, return the terminal of linked other report.
|
||||
* For Terminal element, return the other terminal of terminal element.
|
||||
* @param t terminal to start search
|
||||
* @return
|
||||
*/
|
||||
Terminal * Conductor::relatedPotentialTerminal (Terminal *t) {
|
||||
//terminal must have a folio report parent.
|
||||
// If terminal parent element is a folio report.
|
||||
if (t->parentElement()->linkType() & Element::AllReport) {
|
||||
QList <Element *> elmt_list = t->parentElement()->linkedElements();
|
||||
if (!elmt_list.isEmpty()) {
|
||||
return (elmt_list.first()->terminals().first());
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
// If terminal parent element is a Terminal element.
|
||||
if (t->parentElement() -> linkType() & Element::Terminale) {
|
||||
QList <Terminal *> terminals = t->parentElement()->terminals();
|
||||
terminals.removeAll(t);
|
||||
if (!terminals.isEmpty()) return terminals.first();
|
||||
else return nullptr;
|
||||
}
|
||||
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -53,7 +53,7 @@ class Element : public QetGraphicsItem {
|
||||
AllReport = 6,
|
||||
Master = 8,
|
||||
Slave = 16,
|
||||
Bornier = 32};
|
||||
Terminale = 32};
|
||||
|
||||
private:
|
||||
QSize dimensions;
|
||||
|
||||
34
sources/qetgraphicsitem/terminalelement.cpp
Normal file
34
sources/qetgraphicsitem/terminalelement.cpp
Normal file
@@ -0,0 +1,34 @@
|
||||
/*
|
||||
Copyright 2006-2014 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/>.
|
||||
*/
|
||||
#include "terminalelement.h"
|
||||
|
||||
/**
|
||||
* @brief TerminalElement::TerminalElement
|
||||
* Default constructor
|
||||
* @param location location of xml definition
|
||||
* @param qgi parent QGraphicItem
|
||||
* @param s parent diagram
|
||||
* @param state int used to know if the creation of element have error
|
||||
*/
|
||||
TerminalElement::TerminalElement(const ElementsLocation &location, QGraphicsItem *qgi, Diagram *s, int *state) :
|
||||
CustomElement(location, qgi, s, state)
|
||||
{
|
||||
link_type_ = Terminale;
|
||||
}
|
||||
|
||||
TerminalElement::~TerminalElement() {}
|
||||
31
sources/qetgraphicsitem/terminalelement.h
Normal file
31
sources/qetgraphicsitem/terminalelement.h
Normal file
@@ -0,0 +1,31 @@
|
||||
/*
|
||||
Copyright 2006-2014 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 TERMINALELEMENT_H
|
||||
#define TERMINALELEMENT_H
|
||||
|
||||
#include "customelement.h"
|
||||
|
||||
class TerminalElement : public CustomElement
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
TerminalElement(const ElementsLocation &, QGraphicsItem * = 0, Diagram * = 0, int * = 0);
|
||||
~TerminalElement();
|
||||
};
|
||||
|
||||
#endif // TERMINALELEMENT_H
|
||||
@@ -131,7 +131,7 @@ void elementpropertieswidget::buildInterface() {
|
||||
lsew_ = new LinkSingleElementWidget(element_, this);
|
||||
tab_ -> addTab(lsew_, tr("R\351f\351rence crois\351e (esclave)"));
|
||||
break;
|
||||
case Element::Bornier:
|
||||
case Element::Terminale:
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
|
||||
Reference in New Issue
Block a user