mirror of
https://github.com/qelectrotech/qelectrotech-source-mirror.git
synced 2025-12-19 14:50:53 +01:00
foret file from previous comit.
git-svn-id: svn+ssh://svn.tuxfamily.org/svnroot/qet/qet/trunk@3240 bfdf4180-ca20-0410-9c96-a3a8aa849046
This commit is contained in:
@@ -20,38 +20,19 @@
|
|||||||
#include "diagramcommands.h"
|
#include "diagramcommands.h"
|
||||||
#include "numerotationcontextcommands.h"
|
#include "numerotationcontextcommands.h"
|
||||||
#include "qetdiagrameditor.h"
|
#include "qetdiagrameditor.h"
|
||||||
|
#include "conductor.h"
|
||||||
|
#include "diagram.h"
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*Constructor
|
*Constructor
|
||||||
* @param c the conductor to apply automatic numerotation
|
* @param c the conductor to apply automatic numerotation
|
||||||
*/
|
*/
|
||||||
ConductorAutoNumerotation::ConductorAutoNumerotation(Conductor *c) :
|
ConductorAutoNumerotation::ConductorAutoNumerotation(Conductor *c) :
|
||||||
AutoNumerotation (c -> diagram()),
|
m_diagram (c -> diagram()),
|
||||||
conductor_ (c),
|
conductor_ (c),
|
||||||
conductor_list(c -> relatedPotentialConductors())
|
conductor_list (c -> relatedPotentialConductors())
|
||||||
{
|
|
||||||
num_context = diagram_ -> getNumerotation(Diagram::Conductors);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Constructor
|
|
||||||
* @param d a diagram to apply automatic numerotation
|
|
||||||
*/
|
|
||||||
ConductorAutoNumerotation::ConductorAutoNumerotation(Diagram *d) :
|
|
||||||
AutoNumerotation (d),
|
|
||||||
conductor_ (NULL)
|
|
||||||
{}
|
{}
|
||||||
|
|
||||||
/**
|
|
||||||
* @param c the conductor to apply automatic numerotation
|
|
||||||
*/
|
|
||||||
void ConductorAutoNumerotation::setConductor(Conductor *c) {
|
|
||||||
conductor_ = c;
|
|
||||||
diagram_ = c -> diagram();
|
|
||||||
conductor_list = c -> relatedPotentialConductors();
|
|
||||||
num_context = diagram_ -> getNumerotation(Diagram::Conductors);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief ConductorAutoNumerotation::numerate
|
* @brief ConductorAutoNumerotation::numerate
|
||||||
* execute the automatic numerotation
|
* execute the automatic numerotation
|
||||||
@@ -60,24 +41,6 @@ void ConductorAutoNumerotation::numerate() {
|
|||||||
if (!conductor_) return;
|
if (!conductor_) return;
|
||||||
if (conductor_list.size() >= 1 ) numeratePotential();
|
if (conductor_list.size() >= 1 ) numeratePotential();
|
||||||
else if (conductor_ -> properties().type == ConductorProperties::Multi) numerateNewConductor();
|
else if (conductor_ -> properties().type == ConductorProperties::Multi) numerateNewConductor();
|
||||||
else return;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief ConductorAutoNumerotation::numerateDiagram
|
|
||||||
* Numerate all conductor in diagram
|
|
||||||
*/
|
|
||||||
void ConductorAutoNumerotation::numerateDiagram() {
|
|
||||||
if (!diagram_) return;
|
|
||||||
//Get all potentials presents in diagram
|
|
||||||
QList <QSet <Conductor *> > potential_list = diagram_ -> potentials();
|
|
||||||
//Browse all potentials and set new numerotation
|
|
||||||
for (int i=0; i < potential_list.size(); ++i) {
|
|
||||||
setConductor (potential_list.at(i).toList().first());
|
|
||||||
NumerotationContextCommands ncc(diagram_, num_context);
|
|
||||||
applyText(ncc.toRepresentedString());
|
|
||||||
diagram_ -> setNumerotation(Diagram::Conductors, ncc.next());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -99,7 +62,7 @@ void ConductorAutoNumerotation::checkPotential(Conductor *conductor) {
|
|||||||
if (!eachIsEqual(strl)) {
|
if (!eachIsEqual(strl)) {
|
||||||
ConductorAutoNumerotationWidget canw(c_list, conductor -> diagramEditor());
|
ConductorAutoNumerotationWidget canw(c_list, conductor -> diagramEditor());
|
||||||
ConductorAutoNumerotation can(conductor);
|
ConductorAutoNumerotation can(conductor);
|
||||||
connect(&canw, SIGNAL(textIsSelected(QString)), &can, SLOT(applyText(QString)));
|
//connect(&canw, SIGNAL(textIsSelected(QString)), &can, SLOT(applyText(QString)));
|
||||||
canw.exec();
|
canw.exec();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -117,7 +80,7 @@ void ConductorAutoNumerotation::applyText(QString t) {
|
|||||||
ConductorProperties cp = conductor_ -> properties();
|
ConductorProperties cp = conductor_ -> properties();
|
||||||
cp.text = t;
|
cp.text = t;
|
||||||
ccpc -> setNewSettings(cp);
|
ccpc -> setNewSettings(cp);
|
||||||
diagram_ -> undoStack().push(ccpc);
|
m_diagram -> undoStack().push(ccpc);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
QList <Conductor *> clist = conductor_list.toList();
|
QList <Conductor *> clist = conductor_list.toList();
|
||||||
@@ -135,21 +98,7 @@ void ConductorAutoNumerotation::applyText(QString t) {
|
|||||||
ChangeSeveralConductorsPropertiesCommand *cscpc = new ChangeSeveralConductorsPropertiesCommand(clist);
|
ChangeSeveralConductorsPropertiesCommand *cscpc = new ChangeSeveralConductorsPropertiesCommand(clist);
|
||||||
cscpc -> setOldSettings(old_properties);
|
cscpc -> setOldSettings(old_properties);
|
||||||
cscpc -> setNewSettings(new_properties);
|
cscpc -> setNewSettings(new_properties);
|
||||||
diagram_ -> undoStack().push(cscpc);
|
m_diagram -> undoStack().push(cscpc);
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Set the default text to all potentials of the diagram
|
|
||||||
*/
|
|
||||||
void ConductorAutoNumerotation::removeNumOfDiagram() {
|
|
||||||
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++) {
|
|
||||||
setConductor (potential_list.at(i).toList().first());
|
|
||||||
applyText (diagram_ -> defaultConductorProperties.text);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -170,8 +119,8 @@ void ConductorAutoNumerotation::numeratePotential() {
|
|||||||
//the texts isn't identicals
|
//the texts isn't identicals
|
||||||
else {
|
else {
|
||||||
ConductorAutoNumerotationWidget *canw = new ConductorAutoNumerotationWidget(conductor_list, conductor_ -> diagramEditor());
|
ConductorAutoNumerotationWidget *canw = new ConductorAutoNumerotationWidget(conductor_list, conductor_ -> diagramEditor());
|
||||||
connect(canw, SIGNAL(textIsSelected(QString)),
|
/*connect(canw, SIGNAL(textIsSelected(QString)),
|
||||||
this, SLOT(applyText(QString)));
|
this, SLOT(applyText(QString)));*/
|
||||||
canw -> exec();
|
canw -> exec();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -181,11 +130,12 @@ void ConductorAutoNumerotation::numeratePotential() {
|
|||||||
* create and apply a new numerotation to @conductor_
|
* create and apply a new numerotation to @conductor_
|
||||||
*/
|
*/
|
||||||
void ConductorAutoNumerotation::numerateNewConductor() {
|
void ConductorAutoNumerotation::numerateNewConductor() {
|
||||||
if (!conductor_ || num_context.isEmpty()) return;
|
if (!conductor_ || m_diagram->conductorsAutonumName().isEmpty()) return;
|
||||||
|
|
||||||
NumerotationContextCommands ncc (diagram_, num_context);
|
QString name = m_diagram -> conductorsAutonumName();
|
||||||
|
NumerotationContextCommands ncc (m_diagram, m_diagram->project()->conductorAutoNum(name));
|
||||||
applyText(ncc.toRepresentedString());
|
applyText(ncc.toRepresentedString());
|
||||||
diagram_-> setNumerotation(Diagram::Conductors, ncc.next());
|
m_diagram->project()->addConductorAutoNum(name, ncc.next());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -18,25 +18,19 @@
|
|||||||
#ifndef CONDUCTORAUTONUMEROTATION_H
|
#ifndef CONDUCTORAUTONUMEROTATION_H
|
||||||
#define CONDUCTORAUTONUMEROTATION_H
|
#define CONDUCTORAUTONUMEROTATION_H
|
||||||
|
|
||||||
#include "qetgraphicsitem/conductor.h"
|
#include <QSet>
|
||||||
#include "numerotationcontext.h"
|
|
||||||
#include "autonumerotation.h"
|
|
||||||
|
|
||||||
class ConductorAutoNumerotation: public AutoNumerotation
|
class Diagram;
|
||||||
{
|
class Conductor;
|
||||||
|
|
||||||
|
class ConductorAutoNumerotation {
|
||||||
public:
|
public:
|
||||||
//constructors & destructor
|
//constructors & destructor
|
||||||
ConductorAutoNumerotation (Conductor *);
|
ConductorAutoNumerotation (Conductor *);
|
||||||
ConductorAutoNumerotation (Diagram *);
|
|
||||||
|
|
||||||
//methods
|
//methods
|
||||||
void setConductor(Conductor *);
|
|
||||||
void numerate();
|
void numerate();
|
||||||
void numerateDiagram();
|
|
||||||
void removeNumOfDiagram();
|
|
||||||
static void checkPotential(Conductor *);
|
static void checkPotential(Conductor *);
|
||||||
|
|
||||||
public slots:
|
|
||||||
void applyText(QString);
|
void applyText(QString);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
@@ -45,7 +39,8 @@ class ConductorAutoNumerotation: public AutoNumerotation
|
|||||||
void numerateNewConductor ();
|
void numerateNewConductor ();
|
||||||
|
|
||||||
//attributes
|
//attributes
|
||||||
Conductor *conductor_;
|
Diagram *m_diagram;
|
||||||
|
Conductor *conductor_;
|
||||||
QSet <Conductor *> conductor_list;
|
QSet <Conductor *> conductor_list;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user