Remove all information about internal connection in element (obselete since internal connection is always allowed)

git-svn-id: svn+ssh://svn.tuxfamily.org/svnroot/qet/qet/trunk@3568 bfdf4180-ca20-0410-9c96-a3a8aa849046
This commit is contained in:
blacksun
2014-12-23 19:00:37 +00:00
parent 10d086d378
commit 2c4af2b128
6 changed files with 29 additions and 64 deletions

View File

@@ -599,33 +599,28 @@ bool Diagram::fromXml(QDomElement &document, QPointF position, bool consider_inf
added_shapes << dii; added_shapes << dii;
} }
// Load conductor // Load conductor
QList<Conductor *> added_conductors; QList<Conductor *> added_conductors;
foreach (QDomElement f, QET::findInDomElement(root, "conductors", "conductor")) { foreach (QDomElement f, QET::findInDomElement(root, "conductors", "conductor"))
{
if (!Conductor::valideXml(f)) continue; if (!Conductor::valideXml(f)) continue;
// verifie que les bornes que le conducteur relie sont connues
//Check if terminal that conductor must be linked is know
int id_p1 = f.attribute("terminal1").toInt(); int id_p1 = f.attribute("terminal1").toInt();
int id_p2 = f.attribute("terminal2").toInt(); int id_p2 = f.attribute("terminal2").toInt();
if (table_adr_id.contains(id_p1) && table_adr_id.contains(id_p2)) { if (table_adr_id.contains(id_p1) && table_adr_id.contains(id_p2))
// pose le conducteur... si c'est possible {
Terminal *p1 = table_adr_id.value(id_p1); Terminal *p1 = table_adr_id.value(id_p1);
Terminal *p2 = table_adr_id.value(id_p2); Terminal *p2 = table_adr_id.value(id_p2);
if (p1 != p2) { if (p1 != p2)
bool can_add_conductor = true; {
bool cia = ((Element *)p2 -> parentItem()) -> internalConnections(); Conductor *c = new Conductor(table_adr_id.value(id_p1), table_adr_id.value(id_p2));
if (!cia) { addItem(c);
foreach(QGraphicsItem *item, p2 -> parentItem() -> children()) { c -> fromXml(f);
if (item == p1) can_add_conductor = false; added_conductors << c;
}
}
if (can_add_conductor) {
Conductor *c = new Conductor(table_adr_id.value(id_p1), table_adr_id.value(id_p2));
addItem(c);
c -> fromXml(f);
added_conductors << c;
}
} }
} else qDebug() << "Diagram::fromXml() : Le chargement du conducteur" << id_p1 << id_p2 << "a echoue"; }
else qDebug() << "Diagram::fromXml() : Le chargement du conducteur" << id_p1 << id_p2 << "a echoue";
} }
//Translate items if a new position was given in parameter //Translate items if a new position was given in parameter

View File

@@ -137,13 +137,12 @@ bool CustomElement::buildFromXml(const QDomElement &xml_def_elmt, int *state) {
return(false); return(false);
} }
// on peut d'ores et deja specifier la taille et le hotspot
setSize(w, h); setSize(w, h);
setHotspot(QPoint(hot_x, hot_y)); setHotspot(QPoint(hot_x, hot_y));
setInternalConnections(xml_def_elmt.attribute("ic") == "true");
// la definition est supposee avoir des enfants //the definition must have childs
if (xml_def_elmt.firstChild().isNull()) { if (xml_def_elmt.firstChild().isNull())
{
if (state) *state = 6; if (state) *state = 6;
return(false); return(false);
} }

View File

@@ -32,7 +32,6 @@
*/ */
Element::Element(QGraphicsItem *parent) : Element::Element(QGraphicsItem *parent) :
QetGraphicsItem(parent), QetGraphicsItem(parent),
internal_connections_(false),
must_highlight_(false), must_highlight_(false),
m_mouse_over(false) m_mouse_over(false)
{ {

View File

@@ -160,9 +160,6 @@ class Element : public QetGraphicsItem {
void select(); void select();
void deselect(); void deselect();
// methods related to internal connections
bool internalConnections();
void setInternalConnections(bool);
virtual void rotateBy(const qreal &); virtual void rotateBy(const qreal &);
virtual void editProperty(); virtual void editProperty();
@@ -179,7 +176,6 @@ class Element : public QetGraphicsItem {
void drawAxes(QPainter *, const QStyleOptionGraphicsItem *); void drawAxes(QPainter *, const QStyleOptionGraphicsItem *);
private: private:
bool internal_connections_;
bool must_highlight_; bool must_highlight_;
void drawSelection(QPainter *, const QStyleOptionGraphicsItem *); void drawSelection(QPainter *, const QStyleOptionGraphicsItem *);
void drawHighlight(QPainter *, const QStyleOptionGraphicsItem *); void drawHighlight(QPainter *, const QStyleOptionGraphicsItem *);
@@ -199,24 +195,6 @@ inline bool Element::isFree() const {
return (connected_elements.isEmpty()); return (connected_elements.isEmpty());
} }
/**
Indicate whether this element allows internal connections, i.e. whether its
terminals can be linked together using a conductor.
@return true if internal connections are accepted, false otherwise
*/
inline bool Element::internalConnections() {
return(internal_connections_);
}
/**
Specify whether this element allows internal connections, i.e. whether its
terminals can be linked together using a conductor.
@return true for internal connections to be accepted, false otherwise
*/
inline void Element::setInternalConnections(bool ic) {
internal_connections_ = ic;
}
/** /**
Indicate the current orientation of this element Indicate the current orientation of this element
O = 0° O = 0°

View File

@@ -73,7 +73,6 @@ bool GhostElement::fromXml(QDomElement &e, QHash<int, Terminal *> &table_id_adr,
QRect final_bounding_rect = minimalBoundingRect().united(childrenBoundingRect()).toAlignedRect(); QRect final_bounding_rect = minimalBoundingRect().united(childrenBoundingRect()).toAlignedRect();
setSize(final_bounding_rect.width(), final_bounding_rect.height()); setSize(final_bounding_rect.width(), final_bounding_rect.height());
setHotspot(QPoint() - final_bounding_rect.topLeft()); setHotspot(QPoint() - final_bounding_rect.topLeft());
setInternalConnections(true);
// on peut desormais confectionner le rendu de l'element // on peut desormais confectionner le rendu de l'element
generateDrawings(); generateDrawings();

View File

@@ -442,22 +442,17 @@ bool Terminal::isLinkedTo(Terminal *other_terminal) {
} }
/** /**
@param other_terminal Autre borne * @brief Terminal::canBeLinkedTo
@return true si cette borne peut etre reliee a other_terminal, false sion * @param other_terminal
*/ * @return true if this terminal can be linked to @other_terminal,
bool Terminal::canBeLinkedTo(Terminal *other_terminal) { * otherwise false
if (other_terminal == this) return(false); */
bool Terminal::canBeLinkedTo(Terminal *other_terminal)
// l'autre borne appartient-elle au meme element ? {
bool same_element = other_terminal -> parentElement() == parentElement(); if (other_terminal == this || isLinkedTo(other_terminal))
// les connexions internes sont-elles autorisees ? return false;
bool internal_connections_allowed = parentElement() -> internalConnections();
// les deux bornes sont-elles deja liees ? return true;
bool already_linked = isLinkedTo(other_terminal);
// la liaison des deux bornes est-elle interdite ?
bool link_forbidden = (same_element && !internal_connections_allowed) || already_linked;
return(!link_forbidden);
} }
/** /**