mirror of
https://github.com/qelectrotech/qelectrotech-source-mirror.git
synced 2025-12-17 20:50:34 +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)
|
strategy_ (0)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Constructor
|
||||||
|
* @param d a diagram to apply automatic numerotation
|
||||||
|
*/
|
||||||
|
ConductorAutoNumerotation::ConductorAutoNumerotation(Diagram *d) :
|
||||||
|
conductor_ (0),
|
||||||
|
diagram_ (d),
|
||||||
|
strategy_ (0)
|
||||||
|
{}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*destructor
|
*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
|
* @param dg the diagram
|
||||||
*/
|
*/
|
||||||
void ConductorAutoNumerotation::removeNum_ofDiagram(Diagram *dg) {
|
void ConductorAutoNumerotation::removeNum_ofDiagram() {
|
||||||
// Get all conductors presents in diagram
|
if (!diagram_) return;
|
||||||
QList<Conductor *> Conductors = dg -> content().conductors();
|
//Get all potentials presents in diagram
|
||||||
// Browse all conductors and set the default value
|
QList <QSet <Conductor *> > potential_list = diagram_ -> potentials();
|
||||||
for (int i=0; i<Conductors.count(); i++) {
|
//Browse all potentials and set the default text
|
||||||
Conductors.at(i) -> setText( dg ->defaultConductorProperties.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
|
//constructors & destructor
|
||||||
ConductorAutoNumerotation ();
|
ConductorAutoNumerotation ();
|
||||||
ConductorAutoNumerotation (Conductor *);
|
ConductorAutoNumerotation (Conductor *);
|
||||||
|
ConductorAutoNumerotation (Diagram *);
|
||||||
~ConductorAutoNumerotation();
|
~ConductorAutoNumerotation();
|
||||||
|
|
||||||
//methods
|
//methods
|
||||||
void setConductor(Conductor *);
|
void setConductor(Conductor *);
|
||||||
void numerate();
|
void numerate();
|
||||||
void removeNum_ofDiagram(Diagram *);
|
void removeNum_ofDiagram();
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
void applyText(QString);
|
void applyText(QString);
|
||||||
|
|||||||
@@ -272,6 +272,26 @@ bool Diagram::isEmpty() const {
|
|||||||
return(!items().count());
|
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
|
Exporte tout ou partie du schema
|
||||||
@param whole_content Booleen (a vrai par defaut) indiquant si le XML genere doit
|
@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 setConductor(bool);
|
||||||
void setConductorStart (QPointF);
|
void setConductorStart (QPointF);
|
||||||
void setConductorStop(QPointF);
|
void setConductorStop(QPointF);
|
||||||
|
QList < QSet <Conductor *> > potentials();
|
||||||
|
|
||||||
// methods related to XML import/export
|
// methods related to XML import/export
|
||||||
QDomDocument toXml(bool = true);
|
QDomDocument toXml(bool = true);
|
||||||
|
|||||||
@@ -36,8 +36,8 @@ void DialogConductorAutoNum::on_pushButton_delete_clicked() {
|
|||||||
|
|
||||||
// if yes remove all
|
// if yes remove all
|
||||||
if( answer == QMessageBox::Yes) {
|
if( answer == QMessageBox::Yes) {
|
||||||
ConductorAutoNumerotation ConductorNum;
|
ConductorAutoNumerotation can(dg_);
|
||||||
ConductorNum.removeNum_ofDiagram( dg_ );
|
can.removeNum_ofDiagram();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user