At creation of a new conductor, if every properties of conductors at the same potential is equal,

we use this properties for the new conductor, instead of the default properties.


git-svn-id: svn+ssh://svn.tuxfamily.org/svnroot/qet/qet/trunk@4126 bfdf4180-ca20-0410-9c96-a3a8aa849046
This commit is contained in:
blacksun
2015-08-17 17:01:39 +00:00
parent 1973e3378f
commit d77011acfb
2 changed files with 76 additions and 31 deletions

View File

@@ -146,7 +146,6 @@ void ElementsMover::endMovement()
QPair <Terminal *, Terminal *> pair = elmt -> AlignedFreeTerminals().takeFirst();
Conductor *conductor = new Conductor(pair.first, pair.second);
conductor -> setProperties(diagram_ -> defaultConductorProperties);
//Create an undo object for each new auto conductor, with undo_object for parent if exist
//Else the first undo for this auto conductor become the undo_object
@@ -155,9 +154,31 @@ void ElementsMover::endMovement()
else
undo_object = new AddItemCommand<Conductor *>(conductor, diagram_, QPointF());
//Autonum the new conductor, the undo command associated for this, have for parent undo_object
ConductorAutoNumerotation can (conductor, diagram_, undo_object);
can.numerate();
//Get all conductors at the same potential of conductor
QSet <Conductor *> conductors_list = conductor->relatedPotentialConductors();
//Compare the properties of every conductors stored in conductors_list,
//if every conductors properties is equal, we use this properties for conductor.
ConductorProperties others_properties;
bool use_properties = false;
if (!conductors_list.isEmpty())
{
use_properties = true;
others_properties = (*conductors_list.begin())->properties();
foreach (Conductor *cond, conductors_list)
if (cond->properties() != others_properties)
use_properties = false;
}
if (use_properties)
conductor->setProperties(others_properties);
else
{
conductor -> setProperties(diagram_ -> defaultConductorProperties);
//Autonum the new conductor, the undo command associated for this, have for parent undo_object
ConductorAutoNumerotation can (conductor, diagram_, undo_object);
can.numerate();
}
};
}