mirror of
https://github.com/qelectrotech/qelectrotech-source-mirror.git
synced 2025-12-17 12:40:35 +01:00
add method for get each potentials in a diagram and revamp method for reset all conductors text in a diagram
git-svn-id: svn+ssh://svn.tuxfamily.org/svnroot/qet/qet/trunk@2121 bfdf4180-ca20-0410-9c96-a3a8aa849046
This commit is contained in:
@@ -26,6 +26,16 @@ ConductorAutoNumerotation::ConductorAutoNumerotation(Conductor *c) :
|
||||
strategy_ (0)
|
||||
{}
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
* @param d a diagram to apply automatic numerotation
|
||||
*/
|
||||
ConductorAutoNumerotation::ConductorAutoNumerotation(Diagram *d) :
|
||||
conductor_ (0),
|
||||
diagram_ (d),
|
||||
strategy_ (0)
|
||||
{}
|
||||
|
||||
/**
|
||||
*destructor
|
||||
*/
|
||||
@@ -120,15 +130,17 @@ void ConductorAutoNumerotation::setNumStrategy() {}
|
||||
|
||||
|
||||
/**
|
||||
* @brief Set the default text to all conductors of the diagram
|
||||
* @brief Set the default text to all potentials of the diagram
|
||||
* @param dg the diagram
|
||||
*/
|
||||
void ConductorAutoNumerotation::removeNum_ofDiagram(Diagram *dg) {
|
||||
// Get all conductors presents in diagram
|
||||
QList<Conductor *> Conductors = dg -> content().conductors();
|
||||
// Browse all conductors and set the default value
|
||||
for (int i=0; i<Conductors.count(); i++) {
|
||||
Conductors.at(i) -> setText( dg ->defaultConductorProperties.text );
|
||||
void ConductorAutoNumerotation::removeNum_ofDiagram() {
|
||||
if (!diagram_) return;
|
||||
//Get all potentials presents in diagram
|
||||
QList <QSet <Conductor *> > potential_list = diagram_ -> potentials();
|
||||
//Browse all potentials and set the default text
|
||||
for (int i=0; i < potential_list.size(); i++) {
|
||||
ConductorAutoNumerotation can (potential_list.at(i).toList().first());
|
||||
can.applyText(diagram_ -> defaultConductorProperties.text);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -15,12 +15,13 @@ class ConductorAutoNumerotation: public QObject
|
||||
//constructors & destructor
|
||||
ConductorAutoNumerotation ();
|
||||
ConductorAutoNumerotation (Conductor *);
|
||||
ConductorAutoNumerotation (Diagram *);
|
||||
~ConductorAutoNumerotation();
|
||||
|
||||
//methods
|
||||
void setConductor(Conductor *);
|
||||
void numerate();
|
||||
void removeNum_ofDiagram(Diagram *);
|
||||
void removeNum_ofDiagram();
|
||||
|
||||
public slots:
|
||||
void applyText(QString);
|
||||
|
||||
@@ -272,6 +272,26 @@ bool Diagram::isEmpty() const {
|
||||
return(!items().count());
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Diagram::potential
|
||||
* @return all potential in the diagram
|
||||
*each potential are in the QList and each conductors of one potential are in the QSet
|
||||
*/
|
||||
QList < QSet <Conductor *> > Diagram::potentials() {
|
||||
QList < QSet <Conductor *> > potential_List;
|
||||
if (content().conductors().size() == 0) return (potential_List); //return an empty potential
|
||||
QList <Conductor *> conductors_list = content().conductors();
|
||||
|
||||
do {
|
||||
QSet <Conductor *> one_potential = conductors_list.first() -> relatedPotentialConductors();
|
||||
one_potential << conductors_list.takeFirst();
|
||||
foreach (Conductor *c, one_potential) conductors_list.removeOne(c);
|
||||
potential_List << one_potential;
|
||||
} while (!conductors_list.empty());
|
||||
|
||||
return (potential_List);
|
||||
}
|
||||
|
||||
/**
|
||||
Exporte tout ou partie du schema
|
||||
@param whole_content Booleen (a vrai par defaut) indiquant si le XML genere doit
|
||||
|
||||
@@ -109,6 +109,7 @@ class Diagram : public QGraphicsScene {
|
||||
void setConductor(bool);
|
||||
void setConductorStart (QPointF);
|
||||
void setConductorStop(QPointF);
|
||||
QList < QSet <Conductor *> > potentials();
|
||||
|
||||
// methods related to XML import/export
|
||||
QDomDocument toXml(bool = true);
|
||||
|
||||
@@ -36,8 +36,8 @@ void DialogConductorAutoNum::on_pushButton_delete_clicked() {
|
||||
|
||||
// if yes remove all
|
||||
if( answer == QMessageBox::Yes) {
|
||||
ConductorAutoNumerotation ConductorNum;
|
||||
ConductorNum.removeNum_ofDiagram( dg_ );
|
||||
ConductorAutoNumerotation can(dg_);
|
||||
can.removeNum_ofDiagram();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user