mirror of
https://github.com/qelectrotech/qelectrotech-source-mirror.git
synced 2026-04-25 22:19:58 +02:00
Add TODO compile var + Fix doxygen issue
You can make your code warn on compile time for the TODO's In order to do so, uncomment the following line. in pro file DEFINES += TODO_LIST
This commit is contained in:
@@ -448,7 +448,9 @@ void GraphicsTablePropertiesEditor::setUpEditConnection()
|
||||
m_edit_connection << connect(m_table_button_group, QOverload<int>::of(&QButtonGroup::buttonClicked), this, &GraphicsTablePropertiesEditor::apply);
|
||||
m_edit_connection << connect(m_header_button_group, QOverload<int>::of(&QButtonGroup::buttonClicked), this, &GraphicsTablePropertiesEditor::apply);
|
||||
#else
|
||||
#if TODO_LIST
|
||||
#pragma message("@TODO remove code for QT 5.15 or later")
|
||||
#endif
|
||||
m_edit_connection << connect(m_table_button_group, QOverload<int>::of(&QButtonGroup::idClicked), this, &GraphicsTablePropertiesEditor::apply);
|
||||
m_edit_connection << connect(m_header_button_group, QOverload<int>::of(&QButtonGroup::idClicked), this, &GraphicsTablePropertiesEditor::apply);
|
||||
#endif
|
||||
|
||||
@@ -1,17 +1,17 @@
|
||||
/*
|
||||
Copyright 2006-2020 The QElectroTech Team
|
||||
This file is part of QElectroTech.
|
||||
|
||||
|
||||
QElectroTech is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
|
||||
QElectroTech is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with QElectroTech. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
@@ -94,7 +94,7 @@ Conductor::Conductor(Terminal *p1, Terminal* p2) :
|
||||
bool ajout_p2 = terminal2 -> addConductor(this);
|
||||
//m_valid become false if the conductor can't be added to terminal (conductor already exist)
|
||||
m_valid = (!ajout_p1 || !ajout_p2) ? false : true;
|
||||
|
||||
|
||||
//Default attribut for paint a conductor
|
||||
if (!pen_and_brush_initialized)
|
||||
{
|
||||
@@ -107,7 +107,7 @@ Conductor::Conductor(Terminal *p1, Terminal* p2) :
|
||||
conductor_brush.setStyle(Qt::NoBrush);
|
||||
pen_and_brush_initialized = true;
|
||||
}
|
||||
|
||||
|
||||
//By default, the 4 profils are nuls -> we must to use priv_calculeConductor
|
||||
conductor_profiles.insert(Qt::TopLeftCorner, ConductorProfile());
|
||||
conductor_profiles.insert(Qt::TopRightCorner, ConductorProfile());
|
||||
@@ -118,7 +118,7 @@ Conductor::Conductor(Terminal *p1, Terminal* p2) :
|
||||
generateConductorPath(terminal1 -> dockConductor(), terminal1 -> orientation(), terminal2 -> dockConductor(), terminal2 -> orientation());
|
||||
setFlags(QGraphicsItem::ItemIsSelectable | QGraphicsItem::ItemSendsScenePositionChanges);
|
||||
setAcceptHoverEvents(true);
|
||||
|
||||
|
||||
// Add the text field
|
||||
m_text_item = new ConductorTextItem(m_properties.text, this);
|
||||
connect(m_text_item, &ConductorTextItem::textEdited, this, &Conductor::displayedTextChanged);
|
||||
@@ -178,10 +178,10 @@ void Conductor::updatePath(const QRectF &rect) {
|
||||
void Conductor::segmentsToPath()
|
||||
{
|
||||
QPainterPath path;
|
||||
|
||||
|
||||
if (segments == nullptr)
|
||||
setPath(path);
|
||||
|
||||
|
||||
//Start the path
|
||||
path.moveTo(segments -> firstPoint());
|
||||
//Each segments
|
||||
@@ -192,9 +192,9 @@ void Conductor::segmentsToPath()
|
||||
}
|
||||
//Finish the path
|
||||
path.lineTo(segment -> secondPoint());
|
||||
|
||||
|
||||
setPath(path);
|
||||
|
||||
|
||||
//If conductor is selected and he's not being modified
|
||||
//we update the position of the handlers
|
||||
if (isSelected() && !m_moving_segment)
|
||||
@@ -219,34 +219,34 @@ void Conductor::segmentsToPath()
|
||||
void Conductor::updateConductorPath(const QPointF &p1, Qet::Orientation o1, const QPointF &p2, Qet::Orientation o2) {
|
||||
Q_UNUSED(o1);
|
||||
Q_UNUSED(o2);
|
||||
|
||||
|
||||
ConductorProfile &conductor_profile = conductor_profiles[currentPathType()];
|
||||
|
||||
|
||||
Q_ASSERT_X(conductor_profile.segmentsCount(QET::Both) > 1, "Conductor::priv_modifieConductor", "pas de points a modifier");
|
||||
Q_ASSERT_X(!conductor_profile.isNull(), "Conductor::priv_modifieConductor", "pas de profil utilisable");
|
||||
|
||||
|
||||
// recupere les coordonnees fournies des bornes
|
||||
QPointF new_p1 = mapFromScene(p1);
|
||||
QPointF new_p2 = mapFromScene(p2);
|
||||
QRectF new_rect = QRectF(new_p1, new_p2);
|
||||
|
||||
|
||||
// recupere la largeur et la hauteur du profil
|
||||
qreal profile_width = conductor_profile.width();
|
||||
qreal profile_height = conductor_profile.height();
|
||||
|
||||
|
||||
// calcule les differences verticales et horizontales a appliquer
|
||||
qreal h_diff = (qAbs(new_rect.width()) - qAbs(profile_width) ) * getSign(profile_width);
|
||||
qreal v_diff = (qAbs(new_rect.height()) - qAbs(profile_height)) * getSign(profile_height);
|
||||
|
||||
|
||||
// applique les differences aux segments
|
||||
QMultiHash<ConductorSegmentProfile *, qreal> segments_lengths;
|
||||
segments_lengths.unite(shareOffsetBetweenSegments(h_diff, conductor_profile.horizontalSegments()));
|
||||
segments_lengths.unite(shareOffsetBetweenSegments(v_diff, conductor_profile.verticalSegments()));
|
||||
|
||||
|
||||
// en deduit egalement les coefficients d'inversion (-1 pour une inversion, +1 pour conserver le meme sens)
|
||||
int horiz_coeff = getCoeff(new_rect.width(), profile_width);
|
||||
int verti_coeff = getCoeff(new_rect.height(), profile_height);
|
||||
|
||||
|
||||
// genere les nouveaux points
|
||||
QList<QPointF> points;
|
||||
points << new_p1;
|
||||
@@ -254,14 +254,14 @@ void Conductor::updateConductorPath(const QPointF &p1, Qet::Orientation o1, cons
|
||||
for (int i = 0 ; i < limit ; ++ i) {
|
||||
// dernier point
|
||||
QPointF previous_point = points.last();
|
||||
|
||||
|
||||
// profil de segment de conducteur en cours
|
||||
ConductorSegmentProfile *csp = conductor_profile.segments.at(i);
|
||||
|
||||
|
||||
// coefficient et offset a utiliser pour ce point
|
||||
qreal coeff = csp -> isHorizontal ? horiz_coeff : verti_coeff;
|
||||
qreal offset_applied = segments_lengths.value(csp);
|
||||
|
||||
|
||||
// applique l'offset et le coeff au point
|
||||
if (csp -> isHorizontal) {
|
||||
points << QPointF (
|
||||
@@ -296,15 +296,15 @@ QHash<ConductorSegmentProfile *, qreal> Conductor::shareOffsetBetweenSegments(
|
||||
foreach(ConductorSegmentProfile *csp, segments_list) {
|
||||
segments_hash.insert(csp, csp -> length);
|
||||
}
|
||||
|
||||
|
||||
// memorise le signe de la longueur de chaque segement
|
||||
QHash<ConductorSegmentProfile *, int> segments_signs;
|
||||
foreach(ConductorSegmentProfile *csp, segments_hash.keys()) {
|
||||
segments_signs.insert(csp, getSign(csp -> length));
|
||||
}
|
||||
|
||||
|
||||
//qDebug() << "repartition d'un offset de" << offset << "px sur" << segments_list.count() << "segments";
|
||||
|
||||
|
||||
// repartit l'offset sur les segments
|
||||
qreal remaining_offset = offset;
|
||||
while (remaining_offset > precision || remaining_offset < -precision) {
|
||||
@@ -321,10 +321,10 @@ QHash<ConductorSegmentProfile *, qreal> Conductor::shareOffsetBetweenSegments(
|
||||
// applique l'offset au segment
|
||||
//qreal segment_old_length = segments_hash[csp];
|
||||
segments_hash[csp] += local_offset;
|
||||
|
||||
|
||||
// (la longueur du segment change de signe) <=> (le segment n'a pu absorbe tout l'offset)
|
||||
if (segments_signs[csp] != getSign(segments_hash[csp])) {
|
||||
|
||||
|
||||
// on remet le trop-plein dans la reserve d'offset
|
||||
remaining_offset += qAbs(segments_hash[csp]) * getSign(local_offset);
|
||||
//qDebug() << " trop-plein de" << qAbs(segments_hash[csp]) * getSign(local_offset) << "remaining_offset =" << remaining_offset;
|
||||
@@ -334,7 +334,7 @@ QHash<ConductorSegmentProfile *, qreal> Conductor::shareOffsetBetweenSegments(
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return(segments_hash);
|
||||
}
|
||||
|
||||
@@ -348,18 +348,18 @@ QHash<ConductorSegmentProfile *, qreal> Conductor::shareOffsetBetweenSegments(
|
||||
void Conductor::generateConductorPath(const QPointF &p1, Qet::Orientation o1, const QPointF &p2, Qet::Orientation o2) {
|
||||
QPointF sp1, sp2, depart, newp1, newp2, arrivee, depart0, arrivee0;
|
||||
Qet::Orientation ori_depart, ori_arrivee;
|
||||
|
||||
|
||||
// s'assure qu'il n'y a ni points
|
||||
QList<QPointF> points;
|
||||
|
||||
|
||||
// mappe les points par rapport a la scene
|
||||
sp1 = mapFromScene(p1);
|
||||
sp2 = mapFromScene(p2);
|
||||
|
||||
|
||||
// prolonge les bornes
|
||||
newp1 = extendTerminal(sp1, o1);
|
||||
newp2 = extendTerminal(sp2, o2);
|
||||
|
||||
|
||||
// distingue le depart de l'arrivee : le trajet se fait toujours de gauche a droite (apres prolongation)
|
||||
if (newp1.x() <= newp2.x()) {
|
||||
depart = newp1;
|
||||
@@ -376,13 +376,13 @@ void Conductor::generateConductorPath(const QPointF &p1, Qet::Orientation o1, co
|
||||
ori_depart = o2;
|
||||
ori_arrivee = o1;
|
||||
}
|
||||
|
||||
|
||||
// debut du trajet
|
||||
points << depart0;
|
||||
|
||||
|
||||
// prolongement de la borne de depart
|
||||
points << depart;
|
||||
|
||||
|
||||
// commence le vrai trajet
|
||||
if (depart.y() < arrivee.y()) {
|
||||
// trajet descendant
|
||||
@@ -423,20 +423,20 @@ void Conductor::generateConductorPath(const QPointF &p1, Qet::Orientation o1, co
|
||||
points << QPointF(arrivee.x(), depart.y()); // cas "1"
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// fin du vrai trajet
|
||||
points << arrivee;
|
||||
|
||||
|
||||
// prolongement de la borne d'arrivee
|
||||
points << arrivee0;
|
||||
|
||||
|
||||
// inverse eventuellement l'ordre des points afin que le trajet soit exprime de la borne 1 vers la borne 2
|
||||
if (newp1.x() > newp2.x()) {
|
||||
QList<QPointF> points2;
|
||||
for (int i = points.size() - 1 ; i >= 0 ; -- i) points2 << points.at(i);
|
||||
points = points2;
|
||||
}
|
||||
|
||||
|
||||
pointsToSegments(points);
|
||||
segmentsToPath();
|
||||
}
|
||||
@@ -472,14 +472,14 @@ QPointF Conductor::extendTerminal(const QPointF &terminal, Qet::Orientation term
|
||||
Dessine le conducteur sans antialiasing.
|
||||
@param qp Le QPainter a utiliser pour dessiner le conducteur
|
||||
@param options Les options de style pour le conducteur
|
||||
@param qw Le QWidget sur lequel on dessine
|
||||
@param qw Le QWidget sur lequel on dessine
|
||||
*/
|
||||
void Conductor::paint(QPainter *qp, const QStyleOptionGraphicsItem *options, QWidget *qw)
|
||||
{
|
||||
Q_UNUSED(qw);
|
||||
qp -> save();
|
||||
qp -> setRenderHint(QPainter::Antialiasing, false);
|
||||
|
||||
|
||||
// Set the color of conductor
|
||||
QColor final_conductor_color(m_properties.color);
|
||||
if (must_highlight_ == Normal) {
|
||||
@@ -495,26 +495,26 @@ void Conductor::paint(QPainter *qp, const QStyleOptionGraphicsItem *options, QWi
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//Draw the conductor bigger when is hovered
|
||||
conductor_pen.setWidthF(m_mouse_over? (m_properties.cond_size) +4 : (m_properties.cond_size));
|
||||
|
||||
//Set the QPen and QBrush to the QPainter
|
||||
qp -> setBrush(conductor_brush);
|
||||
QPen final_conductor_pen = conductor_pen;
|
||||
|
||||
|
||||
//Set the conductor style
|
||||
final_conductor_pen.setColor(final_conductor_color);
|
||||
final_conductor_pen.setStyle(m_properties.style);
|
||||
final_conductor_pen.setJoinStyle(Qt::SvgMiterJoin); // better rendering with dot
|
||||
|
||||
|
||||
//Use a cosmetique line, below a certain zoom
|
||||
if (options && options -> levelOfDetail < 1.0) {
|
||||
final_conductor_pen.setCosmetic(true);
|
||||
}
|
||||
|
||||
|
||||
qp -> setPen(final_conductor_pen);
|
||||
|
||||
|
||||
//Draw the conductor
|
||||
qp -> drawPath(path());
|
||||
//Draw the second color
|
||||
@@ -530,7 +530,7 @@ void Conductor::paint(QPainter *qp, const QStyleOptionGraphicsItem *options, QWi
|
||||
qp->drawPath(path());
|
||||
qp->restore();
|
||||
}
|
||||
|
||||
|
||||
if (m_properties.type == ConductorProperties::Single) {
|
||||
qp -> setBrush(final_conductor_color);
|
||||
m_properties.singleLineProperties.draw(
|
||||
@@ -540,7 +540,7 @@ void Conductor::paint(QPainter *qp, const QStyleOptionGraphicsItem *options, QWi
|
||||
);
|
||||
if (isSelected()) qp -> setBrush(Qt::NoBrush);
|
||||
}
|
||||
|
||||
|
||||
//Draw the junctions
|
||||
QList<QPointF> junctions_list = junctions();
|
||||
if (!junctions_list.isEmpty()) {
|
||||
@@ -579,11 +579,11 @@ ConductorTextItem *Conductor::textItem() const
|
||||
bool Conductor::valideXml(QDomElement &e){
|
||||
// verifie le nom du tag
|
||||
if (e.tagName() != "conductor") return(false);
|
||||
|
||||
|
||||
// verifie la presence des attributs minimaux
|
||||
if (!e.hasAttribute("terminal1")) return(false);
|
||||
if (!e.hasAttribute("terminal2")) return(false);
|
||||
|
||||
|
||||
bool conv_ok;
|
||||
// parse l'abscisse
|
||||
if (e.hasAttribute("element1")) {
|
||||
@@ -595,7 +595,7 @@ bool Conductor::valideXml(QDomElement &e){
|
||||
e.attribute("terminal1").toInt(&conv_ok);
|
||||
if (!conv_ok) return(false);
|
||||
}
|
||||
|
||||
|
||||
// parse l'ordonnee
|
||||
if (e.hasAttribute("element2")) {
|
||||
if (QUuid(e.attribute("element2")).isNull())
|
||||
@@ -627,7 +627,7 @@ void Conductor::mouseDoubleClickEvent(QGraphicsSceneMouseEvent *event) {
|
||||
void Conductor::mousePressEvent(QGraphicsSceneMouseEvent *event)
|
||||
{
|
||||
QGraphicsObject::mousePressEvent(event);
|
||||
|
||||
|
||||
if (event->modifiers() & Qt::ControlModifier)
|
||||
setSelected(!isSelected());
|
||||
}
|
||||
@@ -668,7 +668,7 @@ void Conductor::hoverLeaveEvent(QGraphicsSceneHoverEvent *event) {
|
||||
@brief Conductor::itemChange
|
||||
@param change
|
||||
@param value
|
||||
@return
|
||||
@return
|
||||
*/
|
||||
QVariant Conductor::itemChange(GraphicsItemChange change, const QVariant &value)
|
||||
{
|
||||
@@ -689,7 +689,7 @@ QVariant Conductor::itemChange(GraphicsItemChange change, const QVariant &value)
|
||||
else if (change == QGraphicsItem::ItemSceneHasChanged)
|
||||
{
|
||||
calculateTextItemPosition();
|
||||
|
||||
|
||||
if(!scene())
|
||||
removeHandler();
|
||||
else if (scene() && isSelected())
|
||||
@@ -701,7 +701,7 @@ QVariant Conductor::itemChange(GraphicsItemChange change, const QVariant &value)
|
||||
else if (change == QGraphicsItem::ItemPositionHasChanged && isSelected()) {
|
||||
adjusteHandlerPos();
|
||||
}
|
||||
|
||||
|
||||
return(QGraphicsObject::itemChange(change, value));
|
||||
}
|
||||
|
||||
@@ -709,7 +709,7 @@ QVariant Conductor::itemChange(GraphicsItemChange change, const QVariant &value)
|
||||
@brief Conductor::sceneEventFilter
|
||||
@param watched
|
||||
@param event
|
||||
@return
|
||||
@return
|
||||
*/
|
||||
bool Conductor::sceneEventFilter(QGraphicsItem *watched, QEvent *event)
|
||||
{
|
||||
@@ -717,7 +717,7 @@ bool Conductor::sceneEventFilter(QGraphicsItem *watched, QEvent *event)
|
||||
if(watched->type() == QetGraphicsHandlerItem::Type)
|
||||
{
|
||||
QetGraphicsHandlerItem *qghi = qgraphicsitem_cast<QetGraphicsHandlerItem *>(watched);
|
||||
|
||||
|
||||
if(m_handler_vector.contains(qghi)) //Handler must be in m_vector_index, then we can start resize
|
||||
{
|
||||
m_vector_index = m_handler_vector.indexOf(qghi);
|
||||
@@ -746,7 +746,7 @@ bool Conductor::sceneEventFilter(QGraphicsItem *watched, QEvent *event)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -758,7 +758,7 @@ void Conductor::adjusteHandlerPos()
|
||||
{
|
||||
if (m_handler_vector.isEmpty())
|
||||
return;
|
||||
|
||||
|
||||
if (m_handler_vector.size() == handlerPoints().size())
|
||||
{
|
||||
QVector <QPointF> points_vector = mapToScene(handlerPoints());
|
||||
@@ -775,7 +775,7 @@ void Conductor::adjusteHandlerPos()
|
||||
void Conductor::handlerMousePressEvent(QetGraphicsHandlerItem *qghi, QGraphicsSceneMouseEvent *event)
|
||||
{
|
||||
Q_UNUSED(event);
|
||||
|
||||
|
||||
//we get the segment corresponding to the handler
|
||||
if (m_vector_index > -1)
|
||||
{
|
||||
@@ -783,7 +783,7 @@ void Conductor::handlerMousePressEvent(QetGraphicsHandlerItem *qghi, QGraphicsSc
|
||||
m_moving_segment = true;
|
||||
m_moved_segment = segmentsList().at(m_vector_index+1);
|
||||
before_mov_text_pos_ = m_text_item -> pos();
|
||||
|
||||
|
||||
for(QetGraphicsHandlerItem *handler : m_handler_vector)
|
||||
if(handler != qghi)
|
||||
handler->hide();
|
||||
@@ -801,14 +801,14 @@ void Conductor::handlerMouseMoveEvent(QetGraphicsHandlerItem *qghi, QGraphicsSce
|
||||
{
|
||||
//Snap the mouse pos to grid
|
||||
QPointF pos_ = Diagram::snapToGrid(mapFromScene(event->scenePos()));
|
||||
|
||||
|
||||
//Position of the last point
|
||||
QPointF p = m_moved_segment -> middle();
|
||||
|
||||
|
||||
//Calcul the movement
|
||||
m_moved_segment -> moveX(pos_.x() - p.x());
|
||||
m_moved_segment -> moveY(pos_.y() - p.y());
|
||||
|
||||
|
||||
//Apply the movement
|
||||
modified_path = true;
|
||||
has_to_save_profile = true;
|
||||
@@ -827,9 +827,9 @@ void Conductor::handlerMouseReleaseEvent(QetGraphicsHandlerItem *qghi, QGraphics
|
||||
{
|
||||
Q_UNUSED(event);
|
||||
Q_UNUSED(qghi);
|
||||
|
||||
|
||||
m_vector_index = -1;
|
||||
|
||||
|
||||
m_moving_segment = false;
|
||||
if (has_to_save_profile)
|
||||
{
|
||||
@@ -849,9 +849,9 @@ void Conductor::handlerMouseReleaseEvent(QetGraphicsHandlerItem *qghi, QGraphics
|
||||
void Conductor::addHandler()
|
||||
{
|
||||
if (m_handler_vector.isEmpty() && scene())
|
||||
{
|
||||
{
|
||||
m_handler_vector = QetGraphicsHandlerItem::handlerForPoint(mapToScene(handlerPoints()));
|
||||
|
||||
|
||||
for(QetGraphicsHandlerItem *handler : m_handler_vector)
|
||||
{
|
||||
handler->setColor(Qt::blue);
|
||||
@@ -897,7 +897,7 @@ QPainterPath Conductor::shape() const
|
||||
pps.setJoinStyle(conductor_pen.joinStyle());
|
||||
|
||||
QPainterPath shape_(pps.createStroke(path()));
|
||||
|
||||
|
||||
return shape_;
|
||||
}
|
||||
|
||||
@@ -936,23 +936,23 @@ QList<QPointF> Conductor::segmentsToPoints() const
|
||||
{
|
||||
// liste qui sera retournee
|
||||
QList<QPointF> points_list;
|
||||
|
||||
|
||||
// on retourne la liste tout de suite s'il n'y a pas de segments
|
||||
if (segments == nullptr) return(points_list);
|
||||
|
||||
|
||||
// recupere le premier point
|
||||
points_list << segments -> firstPoint();
|
||||
|
||||
|
||||
// parcourt les segments pour recuperer les autres points
|
||||
ConductorSegment *segment = segments;
|
||||
while(segment -> hasNextSegment()) {
|
||||
points_list << segment -> secondPoint();
|
||||
segment = segment -> nextSegment();
|
||||
}
|
||||
|
||||
|
||||
// recupere le dernier point
|
||||
points_list << segment -> secondPoint();
|
||||
|
||||
|
||||
//retourne la liste
|
||||
return(points_list);
|
||||
}
|
||||
@@ -964,7 +964,7 @@ QList<QPointF> Conductor::segmentsToPoints() const
|
||||
void Conductor::pointsToSegments(const QList<QPointF>& points_list) {
|
||||
// supprime les segments actuels
|
||||
deleteSegments();
|
||||
|
||||
|
||||
// cree les segments a partir de la liste de points
|
||||
ConductorSegment *last_segment = nullptr;
|
||||
for (int i = 0 ; i < points_list.size() - 1 ; ++ i) {
|
||||
@@ -1039,7 +1039,7 @@ QDomElement Conductor::toXml(QDomDocument &dom_document,
|
||||
dom_element.setAttribute("terminal2", terminal2->uuid().toString());
|
||||
}
|
||||
dom_element.setAttribute("freezeLabel", m_freeze_label? "true" : "false");
|
||||
|
||||
|
||||
// on n'exporte les segments du conducteur que si ceux-ci ont
|
||||
// ete modifies par l'utilisateur
|
||||
if (modified_path)
|
||||
@@ -1057,7 +1057,7 @@ QDomElement Conductor::toXml(QDomDocument &dom_document,
|
||||
|
||||
QDomElement dom_seq = m_autoNum_seq.toXml(dom_document);
|
||||
dom_element.appendChild(dom_seq);
|
||||
|
||||
|
||||
// Export the properties and text
|
||||
m_properties. toXml(dom_element);
|
||||
if(m_text_item->wasMovedByUser())
|
||||
@@ -1177,10 +1177,10 @@ QVector<QPointF> Conductor::handlerPoints() const
|
||||
const QList<ConductorSegment *> Conductor::segmentsList() const
|
||||
{
|
||||
if (segments == nullptr) return(QList<ConductorSegment *>());
|
||||
|
||||
|
||||
QList<ConductorSegment *> segments_vector;
|
||||
ConductorSegment *segment = segments;
|
||||
|
||||
|
||||
while (segment -> hasNextSegment()) {
|
||||
segments_vector << segment;
|
||||
segment = segment -> nextSegment();
|
||||
@@ -1203,12 +1203,12 @@ qreal Conductor::length() const{
|
||||
ConductorSegment *Conductor::middleSegment()
|
||||
{
|
||||
if (segments == nullptr) return(nullptr);
|
||||
|
||||
|
||||
qreal half_length = length() / 2.0;
|
||||
|
||||
|
||||
ConductorSegment *s = segments;
|
||||
qreal l = 0;
|
||||
|
||||
|
||||
while (s -> hasNextSegment()) {
|
||||
l += qAbs(s -> length());
|
||||
if (l >= half_length) break;
|
||||
@@ -1344,7 +1344,7 @@ void Conductor::calculateTextItemPosition()
|
||||
rotation == Qt::Vertical ? m_text_item -> setRotation(m_properties.verti_rotate_text):
|
||||
m_text_item -> setRotation(m_properties.horiz_rotate_text);
|
||||
}
|
||||
|
||||
|
||||
//Adjust the position of text if his rotation
|
||||
//is 0° or 270°, to be exactly centered to the conductor
|
||||
if (m_text_item -> rotation() == 0)
|
||||
@@ -1359,9 +1359,9 @@ void Conductor::calculateTextItemPosition()
|
||||
if(m_properties.m_vertical_alignment == Qt::AlignLeft)
|
||||
text_pos.rx() -= m_text_item->boundingRect().height();
|
||||
}
|
||||
|
||||
|
||||
m_text_item -> setPos(text_pos);
|
||||
|
||||
|
||||
//Ensure text item don't collide with this conductor
|
||||
while (m_text_item->collidesWithItem(this))
|
||||
{
|
||||
@@ -1491,7 +1491,7 @@ void Conductor::setPath(const QPainterPath &path)
|
||||
{
|
||||
if(path == m_path)
|
||||
return;
|
||||
|
||||
|
||||
prepareGeometryChange();
|
||||
m_path = path;
|
||||
update();
|
||||
@@ -1694,7 +1694,9 @@ QSet<Conductor *> Conductor::relatedPotentialConductors(const bool all_diagram,
|
||||
#if QT_VERSION < QT_VERSION_CHECK(5, 14, 0) // ### Qt 6: remove
|
||||
other_conductors += other_conductors_list_t.toSet();
|
||||
#else
|
||||
#if TODO_LIST
|
||||
#pragma message("@TODO remove code for QT 5.14 or later")
|
||||
#endif
|
||||
other_conductors += QSet<Conductor*>(other_conductors_list_t.begin(),other_conductors_list_t.end());
|
||||
#endif
|
||||
}
|
||||
@@ -1750,17 +1752,17 @@ void Conductor::setUpConnectionForFormula(QString old_formula, QString new_formu
|
||||
//we must to replace %F by the real text, to check if the real text contain the variable %id
|
||||
if (old_formula.contains("%F"))
|
||||
old_formula.replace("%F", diagram()->border_and_titleblock.folio());
|
||||
|
||||
|
||||
if (old_formula.contains("%id"))
|
||||
disconnect(diagram()->project(), &QETProject::projectDiagramsOrderChanged, this, &Conductor::refreshText);
|
||||
|
||||
|
||||
//Label is frozen, so we don't update it.
|
||||
if (m_freeze_label == true)
|
||||
return;
|
||||
|
||||
|
||||
if (new_formula.contains("%F"))
|
||||
new_formula.replace("%F", diagram()->border_and_titleblock.folio());
|
||||
|
||||
|
||||
if (new_formula.contains("%id"))
|
||||
connect(diagram()->project(), &QETProject::projectDiagramsOrderChanged, this, &Conductor::refreshText);
|
||||
}
|
||||
@@ -1785,18 +1787,18 @@ bool isContained(const QPointF &a, const QPointF &b, const QPointF &c) {
|
||||
QList<QPointF> Conductor::junctions() const
|
||||
{
|
||||
QList<QPointF> junctions_list;
|
||||
|
||||
|
||||
// pour qu'il y ait des jonctions, il doit y avoir d'autres conducteurs et des bifurcations
|
||||
QList<Conductor *> other_conductors = relatedConductors(this);
|
||||
QList<ConductorBend> bends_list = bends();
|
||||
if (other_conductors.isEmpty() || bends_list.isEmpty()) {
|
||||
return(junctions_list);
|
||||
}
|
||||
|
||||
|
||||
QList<QPointF> points = segmentsToPoints();
|
||||
for (int i = 1 ; i < (points.size() -1) ; ++ i) {
|
||||
QPointF point = points.at(i);
|
||||
|
||||
|
||||
// determine si le point est une bifurcation ou non
|
||||
bool is_bend = false;
|
||||
Qt::Corner current_bend_type = Qt::TopLeftCorner;
|
||||
@@ -1811,7 +1813,7 @@ QList<QPointF> Conductor::junctions() const
|
||||
}
|
||||
// si le point n'est pas une bifurcation, il ne peut etre une jonction (enfin pas au niveau de ce conducteur)
|
||||
if (!is_bend) continue;
|
||||
|
||||
|
||||
bool is_junction = false;
|
||||
QPointF scene_point = mapToScene(point);
|
||||
foreach(Conductor *c, other_conductors)
|
||||
@@ -1857,7 +1859,7 @@ QList<ConductorBend> Conductor::bends() const
|
||||
{
|
||||
QList<ConductorBend> points;
|
||||
if (!segments) return(points);
|
||||
|
||||
|
||||
// recupere la liste des segments de taille non nulle
|
||||
QList<ConductorSegment *> visible_segments;
|
||||
ConductorSegment *segment = segments;
|
||||
@@ -1866,7 +1868,7 @@ QList<ConductorBend> Conductor::bends() const
|
||||
segment = segment -> nextSegment();
|
||||
}
|
||||
if (!segment -> isPoint()) visible_segments << segment;
|
||||
|
||||
|
||||
ConductorSegment *next_segment;
|
||||
for (int i = 0 ; i < visible_segments.count() -1 ; ++ i) {
|
||||
segment = visible_segments[i];
|
||||
@@ -1877,7 +1879,7 @@ QList<ConductorBend> Conductor::bends() const
|
||||
Qt::Corner bend_type;
|
||||
qreal sl = segment -> length();
|
||||
qreal nsl = next_segment -> length();
|
||||
|
||||
|
||||
if (segment -> isHorizontal()) {
|
||||
if (sl < 0 && nsl < 0) {
|
||||
bend_type = Qt::BottomLeftCorner;
|
||||
@@ -1974,14 +1976,14 @@ QPointF Conductor::movePointIntoPolygon(const QPointF &point, const QPainterPath
|
||||
QList<QPointF> points;
|
||||
foreach(QPolygonF polygon, polygons) {
|
||||
if (polygon.count() <= 1) continue;
|
||||
|
||||
|
||||
// on recense les lignes et les points
|
||||
for (int i = 1 ; i < polygon.count() ; ++ i) {
|
||||
lines << QLineF(polygon.at(i - 1), polygon.at(i));
|
||||
points << polygon.at(i -1);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// on fait des projetes orthogonaux du point sur les differents segments du
|
||||
// polygone, en les triant par longueur croissante
|
||||
QMap<qreal, QPointF> intersections;
|
||||
@@ -2007,7 +2009,7 @@ QPointF Conductor::movePointIntoPolygon(const QPointF &point, const QPainterPath
|
||||
}
|
||||
}
|
||||
// on connait desormais le coin le plus proche du texte
|
||||
|
||||
|
||||
// aucun projete orthogonal n'a donne quoi que ce soit, on met le texte sur un des coins du polygone
|
||||
return(points.at(point_index));
|
||||
}
|
||||
|
||||
@@ -1,17 +1,17 @@
|
||||
/*
|
||||
Copyright 2006-2020 The QElectroTech Team
|
||||
This file is part of QElectroTech.
|
||||
|
||||
|
||||
QElectroTech is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
|
||||
QElectroTech is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with QElectroTech. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
@@ -105,14 +105,14 @@ Element::Element(
|
||||
if (state) {
|
||||
*state = 0;
|
||||
}
|
||||
|
||||
|
||||
setPrefix(autonum::elementPrefixForLocation(location));
|
||||
m_uuid = QUuid::createUuid();
|
||||
setZValue(10);
|
||||
setFlags(QGraphicsItem::ItemIsMovable
|
||||
| QGraphicsItem::ItemIsSelectable);
|
||||
setAcceptHoverEvents(true);
|
||||
|
||||
|
||||
connect(this, &Element::rotationChanged, [this]()
|
||||
{
|
||||
for(QGraphicsItem *qgi : childItems())
|
||||
@@ -150,11 +150,11 @@ QList<Terminal *> Element::terminals() const
|
||||
QList<Conductor *> Element::conductors() const
|
||||
{
|
||||
QList<Conductor *> conductors;
|
||||
|
||||
|
||||
for (Terminal *t : m_terminals) {
|
||||
conductors << t -> conductors();
|
||||
}
|
||||
|
||||
|
||||
return(conductors);
|
||||
}
|
||||
|
||||
@@ -209,13 +209,13 @@ void Element::paint(
|
||||
if (m_must_highlight) {
|
||||
drawHighlight(painter, options);
|
||||
}
|
||||
|
||||
|
||||
if (options && options -> levelOfDetail < 1.0) {
|
||||
painter->drawPicture(0, 0, m_low_zoom_picture);
|
||||
} else {
|
||||
painter->drawPicture(0, 0, m_picture);
|
||||
}
|
||||
|
||||
|
||||
//Draw the selection rectangle
|
||||
if ( isSelected() || m_mouse_over ) {
|
||||
drawSelection(painter, options);
|
||||
@@ -355,7 +355,7 @@ void Element::drawHighlight(
|
||||
{
|
||||
Q_UNUSED(options);
|
||||
painter -> save();
|
||||
|
||||
|
||||
qreal gradient_radius = qMin(boundingRect().width(),
|
||||
boundingRect().height()) / 2.0;
|
||||
QRadialGradient gradient(
|
||||
@@ -366,7 +366,7 @@ void Element::drawHighlight(
|
||||
gradient.setColorAt(0.0, QColor::fromRgb(69, 137, 255, 255));
|
||||
gradient.setColorAt(1.0, QColor::fromRgb(69, 137, 255, 0));
|
||||
QBrush brush(gradient);
|
||||
|
||||
|
||||
painter -> setPen(Qt::NoPen);
|
||||
painter -> setBrush(brush);
|
||||
// Le dessin se fait a partir du rectangle delimitant
|
||||
@@ -463,7 +463,7 @@ bool Element::buildFromXml(const QDomElement &xml_def_elmt, int *state)
|
||||
QDomElement elmts = node.toElement();
|
||||
if (elmts.isNull())
|
||||
continue;
|
||||
|
||||
|
||||
if (elmts.tagName() == "description")
|
||||
{
|
||||
//Minor workaround to find if there is a "input" tagg as label.
|
||||
@@ -485,7 +485,7 @@ bool Element::buildFromXml(const QDomElement &xml_def_elmt, int *state)
|
||||
if(!have_label && !input_field.isEmpty())
|
||||
input_field.first().setAttribute("tagg",
|
||||
"label");
|
||||
|
||||
|
||||
//Parse the definition
|
||||
for (QDomNode n = node.firstChild() ;
|
||||
!n.isNull() ;
|
||||
@@ -494,7 +494,7 @@ bool Element::buildFromXml(const QDomElement &xml_def_elmt, int *state)
|
||||
QDomElement qde = n.toElement();
|
||||
if (qde.isNull())
|
||||
continue;
|
||||
|
||||
|
||||
if (parseElement(qde)) {
|
||||
++ parsed_elements_count;
|
||||
}
|
||||
@@ -513,7 +513,7 @@ bool Element::buildFromXml(const QDomElement &xml_def_elmt, int *state)
|
||||
epf->getPictures(m_location,
|
||||
const_cast<QPicture&>(m_picture),
|
||||
const_cast<QPicture&>(m_low_zoom_picture));
|
||||
|
||||
|
||||
if(!m_picture.isNull())
|
||||
++ parsed_elements_count;
|
||||
|
||||
@@ -581,7 +581,7 @@ bool Element::parseInput(const QDomElement &dom_element)
|
||||
deti->setTextFrom(DynamicElementTextItem::ElementInfo);
|
||||
deti->setInfoName(dom_element.attribute("tagg"));
|
||||
}
|
||||
|
||||
|
||||
//the origin transformation point of PartDynamicTextField is the top left corner, no matter the font size
|
||||
//The origin transformation point of ElementTextItem is the middle of left edge, and so by definition, change with the size of the font
|
||||
//We need to use a QTransform to find the pos of this text from the saved pos of text item
|
||||
@@ -618,7 +618,7 @@ DynamicElementTextItem *Element::parseDynamicText(
|
||||
//Because the xml description of a .elmt file is the same as how a dynamic text field is save to xml in a .qet file
|
||||
//wa call fromXml, we just change the tagg name (.elmt = dynamic_text, .qet = dynamic_elmt_text)
|
||||
//and the uuid (because the uuid, is the uuid of the descritpion and not the uuid of instantiated dynamic text field)
|
||||
|
||||
|
||||
QDomElement dom(dom_element.cloneNode(true).toElement());
|
||||
dom.setTagName(DynamicElementTextItem::xmlTagName());
|
||||
deti->fromXml(dom);
|
||||
@@ -643,7 +643,7 @@ Terminal *Element::parseTerminal(const QDomElement &dom_element)
|
||||
|
||||
Terminal *new_terminal = new Terminal(data, this);
|
||||
m_terminals << new_terminal;
|
||||
|
||||
|
||||
//Sort from top to bottom and left to rigth
|
||||
std::sort(m_terminals.begin(),
|
||||
m_terminals.end(),
|
||||
@@ -655,7 +655,7 @@ Terminal *Element::parseTerminal(const QDomElement &dom_element)
|
||||
else
|
||||
return (a->dockConductor().y() < b->dockConductor().y());
|
||||
});
|
||||
|
||||
|
||||
return(new_terminal);
|
||||
}
|
||||
|
||||
@@ -667,17 +667,17 @@ Terminal *Element::parseTerminal(const QDomElement &dom_element)
|
||||
bool Element::valideXml(QDomElement &e) {
|
||||
// verifie le nom du tag
|
||||
if (e.tagName() != "element") return(false);
|
||||
|
||||
|
||||
// verifie la presence des attributs minimaux
|
||||
if (!e.hasAttribute("type")) return(false);
|
||||
if (!e.hasAttribute("x")) return(false);
|
||||
if (!e.hasAttribute("y")) return(false);
|
||||
|
||||
|
||||
bool conv_ok;
|
||||
// parse l'abscisse
|
||||
e.attribute("x").toDouble(&conv_ok);
|
||||
if (!conv_ok) return(false);
|
||||
|
||||
|
||||
// parse l'ordonnee
|
||||
e.attribute("y").toDouble(&conv_ok);
|
||||
if (!conv_ok) return(false);
|
||||
@@ -713,7 +713,7 @@ bool Element::fromXml(
|
||||
QET::findInDomElement(e, "terminals", "terminal")) {
|
||||
if (Terminal::valideXml(qde)) liste_terminals << qde;
|
||||
}
|
||||
|
||||
|
||||
QHash<int, Terminal *> priv_id_adr;
|
||||
int terminals_non_trouvees = 0;
|
||||
foreach(QGraphicsItem *qgi, childItems()) {
|
||||
@@ -734,12 +734,12 @@ bool Element::fromXml(
|
||||
if (!terminal_trouvee) ++ terminals_non_trouvees;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (terminals_non_trouvees > 0)
|
||||
{
|
||||
m_state = QET::GIOK;
|
||||
return(false);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// verifie que les associations id / adr n'entrent pas en conflit avec table_id_adr
|
||||
@@ -765,7 +765,7 @@ bool Element::fromXml(
|
||||
"link_uuid");
|
||||
foreach (QDomElement qdo, uuid_list)
|
||||
tmp_uuids_link << qdo.attribute("uuid");
|
||||
|
||||
|
||||
//uuid of this element
|
||||
m_uuid= QUuid(e.attribute("uuid", QUuid::createUuid().toString()));
|
||||
|
||||
@@ -793,7 +793,7 @@ bool Element::fromXml(
|
||||
setZValue(e.attribute("z", QString::number(this->zValue())).toDouble());
|
||||
setFlags(QGraphicsItem::ItemIsMovable
|
||||
| QGraphicsItem::ItemIsSelectable);
|
||||
|
||||
|
||||
// orientation
|
||||
bool conv_ok;
|
||||
int read_ori = e.attribute("orientation").toInt(&conv_ok);
|
||||
@@ -803,7 +803,7 @@ bool Element::fromXml(
|
||||
} else {
|
||||
setRotation(90*read_ori);
|
||||
}
|
||||
|
||||
|
||||
//Befor load the dynamic text field,
|
||||
//we remove the dynamic text field created from the description of this element, to avoid doublons.
|
||||
for(DynamicElementTextItem *deti : m_dynamic_text_list)
|
||||
@@ -827,13 +827,13 @@ bool Element::fromXml(
|
||||
//***Element texts item***//
|
||||
//************************//
|
||||
QList<QDomElement> inputs = QET::findInDomElement(e, "inputs", "input");
|
||||
|
||||
|
||||
//First case, we check for the text item converted to dynamic text item
|
||||
const QList <DynamicElementTextItem *> conv_deti_list =
|
||||
m_converted_text_from_xml_description.keys();
|
||||
QList <DynamicElementTextItem *> successfully_converted;
|
||||
QList <DynamicElementTextItem *> successfully_converted;
|
||||
const QList <QDomElement> dom_inputs = inputs;
|
||||
|
||||
|
||||
for (DynamicElementTextItem *deti : conv_deti_list)
|
||||
{
|
||||
for(const QDomElement& dom_input : dom_inputs)
|
||||
@@ -849,26 +849,26 @@ bool Element::fromXml(
|
||||
m_converted_text_from_xml_description.value(deti).y()))
|
||||
{
|
||||
//Once again this 'if', is only for retrocompatibility with old old old project
|
||||
//when element text with tagg "label" is not null, but the element information "label" is.
|
||||
//when element text with tagg "label" is not null, but the element information "label" is.
|
||||
if((deti->textFrom() == DynamicElementTextItem::ElementInfo)
|
||||
&& (deti->infoName() == "label"))
|
||||
m_element_informations.addValue(
|
||||
"label",
|
||||
dom_input.attribute("text"));
|
||||
|
||||
|
||||
deti->setText(dom_input.attribute("text"));
|
||||
|
||||
|
||||
qreal rotation = deti->rotation();
|
||||
QPointF xml_pos = m_converted_text_from_xml_description.value(deti);
|
||||
|
||||
|
||||
if (dom_input.attribute("userrotation").toDouble())
|
||||
rotation = dom_input.attribute("userrotation").toDouble();
|
||||
|
||||
|
||||
if (dom_input.hasAttribute("userx"))
|
||||
xml_pos.setX(dom_input.attribute("userx").toDouble());
|
||||
if(dom_input.hasAttribute("usery"))
|
||||
xml_pos.setY(dom_input.attribute("usery", "0").toDouble());
|
||||
|
||||
|
||||
//the origin transformation point of PartDynamicTextField
|
||||
//is the top left corner, no matter the font size
|
||||
//The origin transformation point of PartTextField
|
||||
@@ -876,10 +876,10 @@ bool Element::fromXml(
|
||||
//change with the size of the font
|
||||
//We need to use a QTransform to find the pos of
|
||||
//this text from the saved pos of text item
|
||||
|
||||
|
||||
deti->setPos(xml_pos);
|
||||
deti->setRotation(rotation);
|
||||
|
||||
|
||||
QTransform transform;
|
||||
//First make the rotation
|
||||
transform.rotate(rotation);
|
||||
@@ -890,7 +890,7 @@ bool Element::fromXml(
|
||||
//Second translate to the pos
|
||||
transform.translate(xml_pos.x(), xml_pos.y());
|
||||
deti->setPos(transform.map(pos));
|
||||
|
||||
|
||||
//dom_input and deti matched we remove
|
||||
//the dom_input from inputs list,
|
||||
//to avoid unnecessary checking made below
|
||||
@@ -903,7 +903,7 @@ bool Element::fromXml(
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//###Firts case : if this is the first time the user open the project since text item are converted to dynamic text,
|
||||
//in the previous opening of the project, every texts field present in the element description was created.
|
||||
//At save time, the values of each of them was save in the 'input' dom element.
|
||||
@@ -915,7 +915,7 @@ bool Element::fromXml(
|
||||
for (DynamicElementTextItem *deti : m_converted_text_from_xml_description.keys())
|
||||
delete deti;
|
||||
m_converted_text_from_xml_description.clear();
|
||||
|
||||
|
||||
for (QDomElement qde : QET::findInDomElement(
|
||||
e,
|
||||
"texts_groups",
|
||||
@@ -925,7 +925,7 @@ bool Element::fromXml(
|
||||
addTextGroup("loaded_from_xml_group");
|
||||
group->fromXml(qde);
|
||||
}
|
||||
|
||||
|
||||
//load informations
|
||||
DiagramContext dc;
|
||||
dc.fromXml(e.firstChildElement("elementInformations"),
|
||||
@@ -939,7 +939,9 @@ bool Element::fromXml(
|
||||
* So we swap the value stored in "label" to "formula" as expected.
|
||||
* @TODO remove this code at version 0.7 or more (probably useless).
|
||||
*/
|
||||
#if TODO_LIST
|
||||
#pragma message("@TODO remove this code for qet 0.7 or later")
|
||||
#endif
|
||||
if (dc["label"].toString().contains("%")
|
||||
&& dc["formula"].toString().isNull())
|
||||
{
|
||||
@@ -949,7 +951,7 @@ bool Element::fromXml(
|
||||
if(dc.value("label").toString().isEmpty() &&
|
||||
!m_element_informations.value("label").toString().isEmpty())
|
||||
dc.addValue("label", m_element_informations.value("label"));
|
||||
|
||||
|
||||
//We must to block the update of the alignment when load the information
|
||||
//otherwise the pos of the text will not be the same as it was at save time.
|
||||
for(DynamicElementTextItem *deti : m_dynamic_text_list)
|
||||
@@ -957,8 +959,8 @@ bool Element::fromXml(
|
||||
setElementInformations(dc);
|
||||
for(DynamicElementTextItem *deti : m_dynamic_text_list)
|
||||
deti->m_block_alignment = false;
|
||||
|
||||
|
||||
|
||||
|
||||
/* During the devel of the version 0.7,
|
||||
* the "old text" was replaced by the dynamic element text item.
|
||||
* When open a project made befor the 0.7,
|
||||
@@ -983,7 +985,7 @@ bool Element::fromXml(
|
||||
bool la = m_element_informations.keyMustShow("label");
|
||||
bool c = m_element_informations.keyMustShow("comment");
|
||||
bool lo = m_element_informations.keyMustShow("location");
|
||||
|
||||
|
||||
if((m_link_type != Master) ||
|
||||
((m_link_type == Master) &&
|
||||
(diagram()->project()->defaultXRefProperties(
|
||||
@@ -1003,7 +1005,7 @@ bool Element::fromXml(
|
||||
&& deti->infoName() == "label")
|
||||
{
|
||||
qreal rotation = deti->rotation();
|
||||
|
||||
|
||||
//Create the comment item
|
||||
DynamicElementTextItem *comment_text = nullptr;
|
||||
if (m_link_type !=PreviousReport
|
||||
@@ -1046,7 +1048,7 @@ bool Element::fromXml(
|
||||
location_text->setPos(deti->x(), deti->y()+20); //+20 is arbitrary, location_text must be below deti and comment
|
||||
addDynamicTextItem(location_text);
|
||||
}
|
||||
|
||||
|
||||
QPointF pos = deti->pos();
|
||||
if (m_link_type !=PreviousReport
|
||||
|| m_link_type !=NextReport)
|
||||
@@ -1071,7 +1073,7 @@ bool Element::fromXml(
|
||||
//so that the text "label" stay in the same
|
||||
//position in scene coordinate
|
||||
group->setPos(pos - deti->pos());
|
||||
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -1117,7 +1119,7 @@ bool Element::fromXml(
|
||||
comment_text->y()+10); //+10 is arbitrary, location_text must be below the comment
|
||||
addDynamicTextItem(location_text);
|
||||
}
|
||||
|
||||
|
||||
//Create the group
|
||||
ElementTextItemGroup *group =
|
||||
addTextGroup(tr("Label + commentaire"));
|
||||
@@ -1142,7 +1144,7 @@ bool Element::fromXml(
|
||||
\~ @param document : XML document to use
|
||||
\~French Document XML a utiliser
|
||||
\~ @param table_adr_id :
|
||||
Correspondence table between the addresses of the terminals
|
||||
Correspondence table between the addresses of the terminals
|
||||
and their id in the XML representation;
|
||||
this table completed by this method
|
||||
\~French Table de correspondance entre les adresses des bornes
|
||||
@@ -1157,7 +1159,7 @@ QDomElement Element::toXml(
|
||||
int> &table_adr_id) const
|
||||
{
|
||||
QDomElement element = document.createElement("element");
|
||||
|
||||
|
||||
// type
|
||||
element.setAttribute("type", m_location.path());
|
||||
|
||||
@@ -1174,13 +1176,13 @@ QDomElement Element::toXml(
|
||||
QDomElement seq = m_autoNum_seq.toXml(document);
|
||||
if (seq.hasChildNodes())
|
||||
element.appendChild(seq);
|
||||
|
||||
|
||||
// position, selection et orientation
|
||||
element.setAttribute("x", QString::number(pos().x()));
|
||||
element.setAttribute("y", QString::number(pos().y()));
|
||||
element.setAttribute("z", QString::number(this->zValue()));
|
||||
element.setAttribute("orientation", QString::number(orientation()));
|
||||
|
||||
|
||||
/* get the first id to use for the bounds of this element
|
||||
* recupere le premier id a utiliser pour les bornes de cet element */
|
||||
int id_terminal = 0;
|
||||
@@ -1192,7 +1194,7 @@ QDomElement Element::toXml(
|
||||
}
|
||||
id_terminal = max_id_t + 1;
|
||||
}
|
||||
|
||||
|
||||
// registration of device terminals
|
||||
// enregistrement des bornes de l'appareil
|
||||
QDomElement xml_terminals = document.createElement("terminals");
|
||||
@@ -1206,7 +1208,7 @@ QDomElement Element::toXml(
|
||||
xml_terminals.appendChild(terminal);
|
||||
}
|
||||
element.appendChild(xml_terminals);
|
||||
|
||||
|
||||
// enregistrement des champ de texte de l'appareil
|
||||
QDomElement inputs = document.createElement("inputs");
|
||||
element.appendChild(inputs);
|
||||
@@ -1236,9 +1238,9 @@ QDomElement Element::toXml(
|
||||
QDomElement dyn_text = document.createElement("dynamic_texts");
|
||||
for (DynamicElementTextItem *deti : m_dynamic_text_list)
|
||||
dyn_text.appendChild(deti->toXml(document));
|
||||
|
||||
|
||||
QDomElement texts_group = document.createElement("texts_groups");
|
||||
|
||||
|
||||
//Dynamic texts owned by groups
|
||||
for(ElementTextItemGroup *group : m_texts_group)
|
||||
{
|
||||
@@ -1248,28 +1250,28 @@ QDomElement Element::toXml(
|
||||
//each time a text is removed from the group, the alignement is not updated
|
||||
Qt::Alignment al = group->alignment();
|
||||
group->setAlignment(Qt::AlignTop);
|
||||
|
||||
|
||||
//Remove the texts from group
|
||||
QList<DynamicElementTextItem *> deti_list = group->texts();
|
||||
for(DynamicElementTextItem *deti : deti_list)
|
||||
group->removeFromGroup(deti);
|
||||
|
||||
|
||||
//Save the texts to xml
|
||||
for (DynamicElementTextItem *deti : deti_list)
|
||||
dyn_text.appendChild(deti->toXml(document));
|
||||
|
||||
|
||||
//Re add texts to group
|
||||
for(DynamicElementTextItem *deti : deti_list)
|
||||
group->addToGroup(deti);
|
||||
|
||||
|
||||
//Restor the alignement
|
||||
group->setAlignment(al);
|
||||
|
||||
|
||||
//Save the group to xml
|
||||
texts_group.appendChild(group->toXml(document));
|
||||
group->blockAlignmentUpdate(false);
|
||||
}
|
||||
|
||||
|
||||
//Append the dynamic texts to element
|
||||
element.appendChild(dyn_text);
|
||||
//Append the texts group to element
|
||||
@@ -1318,7 +1320,7 @@ void Element::removeDynamicTextItem(DynamicElementTextItem *deti)
|
||||
emit textRemoved(deti);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
for(ElementTextItemGroup *group : m_texts_group)
|
||||
{
|
||||
if(group->texts().contains(deti))
|
||||
@@ -1361,7 +1363,7 @@ ElementTextItemGroup *Element::addTextGroup(const QString &name)
|
||||
emit textsGroupAdded(group);
|
||||
return group;
|
||||
}
|
||||
|
||||
|
||||
//Set a new name if name already exist
|
||||
QString rename = name;
|
||||
int i=1;
|
||||
@@ -1370,7 +1372,7 @@ ElementTextItemGroup *Element::addTextGroup(const QString &name)
|
||||
rename = name+QString::number(i);
|
||||
i++;
|
||||
}
|
||||
|
||||
|
||||
//Create the group
|
||||
ElementTextItemGroup *group = new ElementTextItemGroup(rename, this);
|
||||
m_texts_group << group;
|
||||
@@ -1387,7 +1389,7 @@ void Element::addTextGroup(ElementTextItemGroup *group)
|
||||
{
|
||||
if(group->parentElement())
|
||||
return;
|
||||
|
||||
|
||||
m_texts_group << group;
|
||||
group->setParentItem(this);
|
||||
emit textsGroupAdded(group);
|
||||
@@ -1405,9 +1407,9 @@ void Element::removeTextGroup(ElementTextItemGroup *group)
|
||||
{
|
||||
if(!m_texts_group.contains(group))
|
||||
return;
|
||||
|
||||
|
||||
const QList <QGraphicsItem *> items_list = group->childItems();
|
||||
|
||||
|
||||
for(QGraphicsItem *qgi : items_list)
|
||||
{
|
||||
if(qgi->type() == DynamicElementTextItem::Type)
|
||||
@@ -1417,8 +1419,8 @@ void Element::removeTextGroup(ElementTextItemGroup *group)
|
||||
removeTextFromGroup(deti, group);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
emit textsGroupAboutToBeRemoved(group);
|
||||
m_texts_group.removeOne(group);
|
||||
group->setParentItem(nullptr);
|
||||
@@ -1435,7 +1437,7 @@ ElementTextItemGroup *Element::textGroup(const QString &name) const
|
||||
for (ElementTextItemGroup *group : m_texts_group)
|
||||
if(group->name() == name)
|
||||
return group;
|
||||
|
||||
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
@@ -1465,10 +1467,10 @@ bool Element::addTextToGroup(DynamicElementTextItem *text,
|
||||
|
||||
m_dynamic_text_list.removeOne(text);
|
||||
emit textRemoved(text);
|
||||
|
||||
|
||||
group->addToGroup(text);
|
||||
emit textAddedToGroup(text, group);
|
||||
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -1483,7 +1485,7 @@ bool Element::removeTextFromGroup(DynamicElementTextItem *text,
|
||||
{
|
||||
if(!m_texts_group.contains(group))
|
||||
return false;
|
||||
|
||||
|
||||
if(group->texts().contains(text))
|
||||
{
|
||||
group->removeFromGroup(text);
|
||||
@@ -1491,7 +1493,7 @@ bool Element::removeTextFromGroup(DynamicElementTextItem *text,
|
||||
addDynamicTextItem(text);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -1683,7 +1685,7 @@ void Element::hoverLeaveEvent(QGraphicsSceneHoverEvent *e)
|
||||
void Element::setUpFormula(bool code_letter)
|
||||
{
|
||||
Q_UNUSED(code_letter)
|
||||
|
||||
|
||||
if (linkType() == Element::Slave || linkType() & Element::AllReport)
|
||||
return;
|
||||
|
||||
@@ -1694,7 +1696,7 @@ void Element::setUpFormula(bool code_letter)
|
||||
->elementAutoNumCurrentFormula();
|
||||
|
||||
m_element_informations.addValue("formula", formula);
|
||||
|
||||
|
||||
QString element_currentAutoNum = diagram()
|
||||
->project()
|
||||
->elementCurrentAutoNum();
|
||||
@@ -1702,7 +1704,7 @@ void Element::setUpFormula(bool code_letter)
|
||||
->project()
|
||||
->elementAutoNum(element_currentAutoNum);
|
||||
NumerotationContextCommands ncc (nc);
|
||||
|
||||
|
||||
m_autoNum_seq.clear();
|
||||
autonum::setSequential(formula,
|
||||
m_autoNum_seq,
|
||||
|
||||
@@ -52,7 +52,7 @@ QetShapeItem::QetShapeItem(QPointF p1, QPointF p2, ShapeType type, QGraphicsItem
|
||||
for(QetGraphicsHandlerItem *qghi : m_handler_vector)
|
||||
qghi->setZValue(this->zValue()+1);
|
||||
});
|
||||
|
||||
|
||||
m_insert_point = new QAction(tr("Ajouter un point"), this);
|
||||
m_insert_point->setIcon(QET::Icons::Add);
|
||||
connect(m_insert_point, &QAction::triggered, this, &QetShapeItem::insertPoint);
|
||||
@@ -266,7 +266,7 @@ QPainterPath QetShapeItem::shape() const
|
||||
path.moveTo(m_P1);
|
||||
path.lineTo(m_P2);
|
||||
break;
|
||||
case Rectangle:
|
||||
case Rectangle:
|
||||
path.addRoundedRect(
|
||||
QRectF(m_P1, m_P2),
|
||||
m_xRadius,
|
||||
@@ -363,7 +363,7 @@ void QetShapeItem::mousePressEvent(QGraphicsSceneMouseEvent *event)
|
||||
{
|
||||
event->ignore();
|
||||
QetGraphicsItem::mousePressEvent(event);
|
||||
|
||||
|
||||
if (event->button() == Qt::LeftButton) {
|
||||
switchResizeMode();
|
||||
event->accept();
|
||||
@@ -374,7 +374,7 @@ void QetShapeItem::mousePressEvent(QGraphicsSceneMouseEvent *event)
|
||||
@brief QetShapeItem::itemChange
|
||||
@param change
|
||||
@param value
|
||||
@return
|
||||
@return
|
||||
*/
|
||||
QVariant QetShapeItem::itemChange(QGraphicsItem::GraphicsItemChange change,
|
||||
const QVariant &value)
|
||||
@@ -405,7 +405,7 @@ QVariant QetShapeItem::itemChange(QGraphicsItem::GraphicsItemChange change,
|
||||
setSelected(false);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return QGraphicsItem::itemChange(change, value);
|
||||
}
|
||||
|
||||
@@ -413,7 +413,7 @@ QVariant QetShapeItem::itemChange(QGraphicsItem::GraphicsItemChange change,
|
||||
@brief QetShapeItem::sceneEventFilter
|
||||
@param watched
|
||||
@param event
|
||||
@return
|
||||
@return
|
||||
*/
|
||||
bool QetShapeItem::sceneEventFilter(QGraphicsItem *watched, QEvent *event)
|
||||
{
|
||||
@@ -421,7 +421,7 @@ bool QetShapeItem::sceneEventFilter(QGraphicsItem *watched, QEvent *event)
|
||||
if(watched->type() == QetGraphicsHandlerItem::Type)
|
||||
{
|
||||
QetGraphicsHandlerItem *qghi = qgraphicsitem_cast<QetGraphicsHandlerItem *>(watched);
|
||||
|
||||
|
||||
if(m_handler_vector.contains(qghi)) //Handler must be in m_vector_index, then we can start resize
|
||||
{
|
||||
m_vector_index = m_handler_vector.indexOf(qghi);
|
||||
@@ -445,7 +445,7 @@ bool QetShapeItem::sceneEventFilter(QGraphicsItem *watched, QEvent *event)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -456,13 +456,13 @@ bool QetShapeItem::sceneEventFilter(QGraphicsItem *watched, QEvent *event)
|
||||
void QetShapeItem::contextMenuEvent(QGraphicsSceneContextMenuEvent *event)
|
||||
{
|
||||
m_context_menu_pos = event->pos();
|
||||
|
||||
|
||||
if (m_shapeType == QetShapeItem::Polygon)
|
||||
{
|
||||
if (diagram()->selectedItems().isEmpty()) {
|
||||
this->setSelected(true);
|
||||
}
|
||||
|
||||
|
||||
if (isSelected() && scene()->selectedItems().size() == 1)
|
||||
{
|
||||
if (diagram())
|
||||
@@ -477,12 +477,12 @@ void QetShapeItem::contextMenuEvent(QGraphicsSceneContextMenuEvent *event)
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (d_view)
|
||||
{
|
||||
QScopedPointer<QMenu> menu(new QMenu());
|
||||
menu.data()->addAction(m_insert_point);
|
||||
|
||||
|
||||
if (m_handler_vector.count() > 2)
|
||||
{
|
||||
for (QetGraphicsHandlerItem *qghi : m_handler_vector)
|
||||
@@ -494,7 +494,7 @@ void QetShapeItem::contextMenuEvent(QGraphicsSceneContextMenuEvent *event)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
menu.data()->addSeparator();
|
||||
menu.data()->addActions(d_view->contextMenuActions());
|
||||
menu.data()->exec(event->screenPos());
|
||||
@@ -504,7 +504,7 @@ void QetShapeItem::contextMenuEvent(QGraphicsSceneContextMenuEvent *event)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
QetGraphicsItem::contextMenuEvent(event);
|
||||
}
|
||||
|
||||
@@ -557,7 +557,7 @@ void QetShapeItem::switchResizeMode()
|
||||
for (QetGraphicsHandlerItem *qghi : m_handler_vector) {
|
||||
qghi->setColor(Qt::blue);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -587,11 +587,11 @@ void QetShapeItem::addHandler()
|
||||
points_vector = m_polygon;
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
if(!points_vector.isEmpty() && scene())
|
||||
{
|
||||
m_handler_vector = QetGraphicsHandlerItem::handlerForPoint(mapToScene(points_vector));
|
||||
|
||||
|
||||
for(QetGraphicsHandlerItem *handler : m_handler_vector)
|
||||
{
|
||||
handler->setZValue(this->zValue()+1);
|
||||
@@ -612,7 +612,7 @@ void QetShapeItem::adjusteHandlerPos()
|
||||
if (m_handler_vector.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
QVector <QPointF> points_vector;
|
||||
switch (m_shapeType)
|
||||
{
|
||||
@@ -638,7 +638,7 @@ void QetShapeItem::adjusteHandlerPos()
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (m_handler_vector.size() == points_vector.size())
|
||||
{
|
||||
points_vector = mapToScene(points_vector);
|
||||
@@ -658,7 +658,7 @@ void QetShapeItem::insertPoint()
|
||||
if (m_shapeType == QetShapeItem::Polygon)
|
||||
{
|
||||
QPolygonF new_polygon = QetGraphicsHandlerUtility::polygonForInsertPoint(this->polygon(), m_closed, Diagram::snapToGrid(m_context_menu_pos));
|
||||
|
||||
|
||||
if(new_polygon != m_polygon)
|
||||
{
|
||||
//Wrap the undo for avoid to merge the undo commands when user add several points.
|
||||
@@ -674,11 +674,11 @@ void QetShapeItem::removePoint()
|
||||
if (m_shapeType != QetShapeItem::Polygon) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
if (m_handler_vector.size() == 2) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
QPointF point = mapToScene(m_context_menu_pos);
|
||||
int index = -1;
|
||||
for (int i=0 ; i<m_handler_vector.size() ; i++)
|
||||
@@ -694,7 +694,7 @@ void QetShapeItem::removePoint()
|
||||
{
|
||||
QPolygonF polygon = this->polygon();
|
||||
polygon.removeAt(index);
|
||||
|
||||
|
||||
//Wrap the undo for avoid to merge the undo commands when user add several points.
|
||||
QUndoCommand *undo = new QUndoCommand(tr("Supprimer un point d'un polygone"));
|
||||
new QPropertyUndoCommand(this, "polygon", this->polygon(), polygon, undo);
|
||||
@@ -788,7 +788,7 @@ void QetShapeItem::handlerMouseMoveEvent(QGraphicsSceneMouseEvent *event)
|
||||
void QetShapeItem::handlerMouseReleaseEvent()
|
||||
{
|
||||
m_modifie_radius_equaly = false;
|
||||
|
||||
|
||||
if (diagram())
|
||||
{
|
||||
QPropertyUndoCommand *undo = nullptr;
|
||||
@@ -826,7 +826,7 @@ void QetShapeItem::handlerMouseReleaseEvent()
|
||||
}
|
||||
else if (m_shapeType == Polygon && (m_polygon != m_old_polygon))
|
||||
undo = new QPropertyUndoCommand(this, "polygon", m_old_polygon, m_polygon);
|
||||
|
||||
|
||||
if(undo)
|
||||
{
|
||||
undo->setText(tr("Modifier %1").arg(name()));
|
||||
@@ -851,6 +851,9 @@ bool QetShapeItem::fromXml(const QDomElement &e)
|
||||
m_brush = QETXML::brushFromXml(e.firstChildElement("brush"));
|
||||
|
||||
QString type = e.attribute("type");
|
||||
#if TODO_LIST
|
||||
#pragma message("@TODO Compatibility for version older than N°4075, shape type was stored with an int")
|
||||
#endif
|
||||
//@TODO Compatibility for version older than N°4075, shape type was stored with an int
|
||||
if (type.size() == 1)
|
||||
{
|
||||
@@ -875,7 +878,7 @@ bool QetShapeItem::fromXml(const QDomElement &e)
|
||||
m_P1.setY(e.attribute("y1", nullptr).toDouble());
|
||||
m_P2.setX(e.attribute("x2", nullptr).toDouble());
|
||||
m_P2.setY(e.attribute("y2", nullptr).toDouble());
|
||||
|
||||
|
||||
if (m_shapeType == Rectangle)
|
||||
{
|
||||
setXRadius(e.attribute("rx", "0").toDouble());
|
||||
@@ -916,7 +919,7 @@ QDomElement QetShapeItem::toXml(QDomDocument &document) const
|
||||
result.setAttribute("y1", QString::number(mapToScene(m_P1).y()));
|
||||
result.setAttribute("x2", QString::number(mapToScene(m_P2).x()));
|
||||
result.setAttribute("y2", QString::number(mapToScene(m_P2).y()));
|
||||
|
||||
|
||||
if (m_shapeType == Rectangle)
|
||||
{
|
||||
QRectF rect(m_P1, m_P2);
|
||||
@@ -929,7 +932,7 @@ QDomElement QetShapeItem::toXml(QDomDocument &document) const
|
||||
if (y > rect.height()/2) {
|
||||
y = rect.height()/2;
|
||||
}
|
||||
|
||||
|
||||
result.setAttribute("rx", QString::number(m_xRadius));
|
||||
result.setAttribute("ry", QString::number(m_yRadius));
|
||||
}
|
||||
@@ -965,28 +968,28 @@ bool QetShapeItem::toDXF(const QString &filepath,const QPen &pen)
|
||||
switch (m_shapeType)
|
||||
{
|
||||
case Line:
|
||||
Createdxf::drawLine(filepath,
|
||||
QLineF( mapToScene(m_P1),
|
||||
mapToScene(m_P2)),
|
||||
Createdxf::dxfColor(pen));
|
||||
return true;
|
||||
Createdxf::drawLine(filepath,
|
||||
QLineF( mapToScene(m_P1),
|
||||
mapToScene(m_P2)),
|
||||
Createdxf::dxfColor(pen));
|
||||
return true;
|
||||
case Rectangle:
|
||||
Createdxf::drawRectangle(filepath,
|
||||
QRectF(mapToScene(m_P1),
|
||||
mapToScene(m_P2)).normalized(),
|
||||
Createdxf::dxfColor(pen));
|
||||
return true;
|
||||
Createdxf::drawRectangle(filepath,
|
||||
QRectF(mapToScene(m_P1),
|
||||
mapToScene(m_P2)).normalized(),
|
||||
Createdxf::dxfColor(pen));
|
||||
return true;
|
||||
case Ellipse:
|
||||
Createdxf::drawEllipse(filepath,
|
||||
QRectF(mapToScene(m_P1),
|
||||
mapToScene(m_P2)).normalized(),
|
||||
Createdxf::dxfColor(pen));
|
||||
return true;
|
||||
case Polygon:
|
||||
Createdxf::drawPolygon(filepath,m_polygon,Createdxf::dxfColor(pen));
|
||||
return true;
|
||||
default:
|
||||
return false;
|
||||
Createdxf::drawEllipse(filepath,
|
||||
QRectF(mapToScene(m_P1),
|
||||
mapToScene(m_P2)).normalized(),
|
||||
Createdxf::dxfColor(pen));
|
||||
return true;
|
||||
case Polygon:
|
||||
Createdxf::drawPolygon(filepath,m_polygon,Createdxf::dxfColor(pen));
|
||||
return true;
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,17 +1,17 @@
|
||||
/*
|
||||
Copyright 2006-2020 The QElectroTech Team
|
||||
This file is part of QElectroTech.
|
||||
|
||||
|
||||
QElectroTech is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
|
||||
QElectroTech is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with QElectroTech. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
@@ -155,6 +155,9 @@ Terminal::Terminal(TerminalData* data, Element* e) :
|
||||
d(data),
|
||||
parent_element_(e)
|
||||
{
|
||||
#if TODO_LIST
|
||||
#pragma message("@TODO what is when multiple parents exist. So the other relation is lost.")
|
||||
#endif
|
||||
// TODO: what is when multiple parents exist. So the other relation is lost.
|
||||
d->setParent(this);
|
||||
init("_", "_", false);
|
||||
@@ -232,7 +235,7 @@ bool Terminal::addConductor(Conductor *conductor)
|
||||
//Get the other terminal where the conductor must be linked
|
||||
Terminal *other_terminal = (conductor -> terminal1 == this)
|
||||
? conductor->terminal2 : conductor->terminal1;
|
||||
|
||||
|
||||
//Check if this terminal isn't already linked with other_terminal
|
||||
foreach (Conductor* cond, conductors_)
|
||||
if (cond -> terminal1 == other_terminal || cond -> terminal2 == other_terminal)
|
||||
@@ -556,7 +559,7 @@ void Terminal::mousePressEvent(QGraphicsSceneMouseEvent *e)
|
||||
*/
|
||||
void Terminal::mouseMoveEvent(QGraphicsSceneMouseEvent *e)
|
||||
{
|
||||
// pendant la pose d'un conducteur, on adopte un autre curseur
|
||||
// pendant la pose d'un conducteur, on adopte un autre curseur
|
||||
//setCursor(Qt::CrossCursor);
|
||||
|
||||
// d'un mouvement a l'autre, il faut retirer l'effet hover de la borne precedente
|
||||
@@ -571,10 +574,10 @@ void Terminal::mouseMoveEvent(QGraphicsSceneMouseEvent *e)
|
||||
if (!diag) return;
|
||||
// si la scene est un Diagram, on actualise le poseur de conducteur
|
||||
diag -> setConductorStop(e -> scenePos());
|
||||
|
||||
|
||||
// on recupere la liste des qgi sous le pointeur
|
||||
QList<QGraphicsItem *> qgis = diag -> items(e -> scenePos());
|
||||
|
||||
|
||||
/* le qgi le plus haut
|
||||
= le poseur de conductor
|
||||
= le premier element de la liste
|
||||
@@ -582,17 +585,17 @@ void Terminal::mouseMoveEvent(QGraphicsSceneMouseEvent *e)
|
||||
= on prend le deuxieme element de la liste
|
||||
*/
|
||||
Q_ASSERT_X(!(qgis.isEmpty()), "Terminal::mouseMoveEvent", "La liste d'items ne devrait pas etre vide");
|
||||
|
||||
|
||||
// s'il n'y rien d'autre que le poseur de conducteur dans la liste, on arrete la
|
||||
if (qgis.size() <= 1) return;
|
||||
|
||||
|
||||
// sinon on prend le deuxieme element de la liste et on verifie s'il s'agit d'une borne
|
||||
QGraphicsItem *qgi = qgis.at(1);
|
||||
// si le qgi est une borne...
|
||||
Terminal *other_terminal = qgraphicsitem_cast<Terminal *>(qgi);
|
||||
if (!other_terminal) return;
|
||||
previous_terminal_ = other_terminal;
|
||||
|
||||
|
||||
// s'il s'agit d'une borne, on lui applique l'effet hover approprie
|
||||
if (!canBeLinkedTo(other_terminal)) {
|
||||
other_terminal -> hovered_color_ = forbiddenColor;
|
||||
@@ -698,7 +701,7 @@ void Terminal::updateConductor()
|
||||
*/
|
||||
bool Terminal::isLinkedTo(Terminal *other_terminal) {
|
||||
if (other_terminal == this) return(false);
|
||||
|
||||
|
||||
bool already_linked = false;
|
||||
foreach (Conductor *c, conductors_) {
|
||||
if (c -> terminal1 == other_terminal || c -> terminal2 == other_terminal) {
|
||||
@@ -768,25 +771,25 @@ bool Terminal::valideXml(QDomElement &terminal)
|
||||
{
|
||||
// verifie le nom du tag
|
||||
if (terminal.tagName() != "terminal") return(false);
|
||||
|
||||
|
||||
// verifie la presence des attributs minimaux
|
||||
if (!terminal.hasAttribute("x")) return(false);
|
||||
if (!terminal.hasAttribute("y")) return(false);
|
||||
if (!terminal.hasAttribute("orientation")) return(false);
|
||||
|
||||
|
||||
bool conv_ok;
|
||||
// parse l'abscisse
|
||||
terminal.attribute("x").toDouble(&conv_ok);
|
||||
if (!conv_ok) return(false);
|
||||
|
||||
|
||||
// parse l'ordonnee
|
||||
terminal.attribute("y").toDouble(&conv_ok);
|
||||
if (!conv_ok) return(false);
|
||||
|
||||
|
||||
// parse l'id
|
||||
terminal.attribute("id").toInt(&conv_ok);
|
||||
if (!conv_ok) return(false);
|
||||
|
||||
|
||||
// parse l'orientation
|
||||
int terminal_or = terminal.attribute("orientation").toInt(&conv_ok);
|
||||
if (!conv_ok) return(false);
|
||||
@@ -794,7 +797,7 @@ bool Terminal::valideXml(QDomElement &terminal)
|
||||
&& terminal_or != Qet::South
|
||||
&& terminal_or != Qet::East
|
||||
&& terminal_or != Qet::West) return(false);
|
||||
|
||||
|
||||
// a ce stade, la borne est syntaxiquement correcte
|
||||
return(true);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user