diff --git a/utils/fgqcanvas/canvasconnection.cpp b/utils/fgqcanvas/canvasconnection.cpp index f9d8e72f8..04656495d 100644 --- a/utils/fgqcanvas/canvasconnection.cpp +++ b/utils/fgqcanvas/canvasconnection.cpp @@ -207,7 +207,6 @@ void CanvasConnection::onTextMessageReceived(QString message) if (json.isObject()) { // process new nodes QJsonArray created = json.object().value("created").toArray(); - qInfo() << "new nodes:" << created.size(); Q_FOREACH (QJsonValue v, created) { QJsonObject newProp = v.toObject(); @@ -221,7 +220,7 @@ void CanvasConnection::onTextMessageReceived(QString message) LocalProp* newNode = propertyFromPath(localPath); newNode->setPosition(newProp.value("position").toInt()); // store in the global dict - unsigned int propId = newProp.value("id").toInt(); + int propId = newProp.value("id").toInt(); if (idPropertyDict.contains(propId)) { qWarning() << "duplicate add of:" << nodePath << "old is" << idPropertyDict.value(propId)->path(); } else { @@ -235,7 +234,7 @@ void CanvasConnection::onTextMessageReceived(QString message) // process removes QJsonArray removed = json.object().value("removed").toArray(); Q_FOREACH (QJsonValue v, removed) { - unsigned int propId = v.toInt(); + int propId = v.toInt(); if (!idPropertyDict.contains(propId)) { continue; } @@ -261,7 +260,7 @@ void CanvasConnection::onTextMessageReceived(QString message) continue; } - unsigned int propId = change.at(0).toInt(); + int propId = change.at(0).toInt(); if (!idPropertyDict.contains(propId)) { qWarning() << "ignoring unknown prop ID " << propId; continue; diff --git a/utils/fgqcanvas/fgcanvaselement.cpp b/utils/fgqcanvas/fgcanvaselement.cpp index 89b14acc1..1718c6e3c 100644 --- a/utils/fgqcanvas/fgcanvaselement.cpp +++ b/utils/fgqcanvas/fgcanvaselement.cpp @@ -151,7 +151,7 @@ void FGCanvasElement::polish() _fillColor = parseColorValue(getCascadedStyle("fill")); const auto opacity = getCascadedStyle("fill-opacity"); if (!opacity.isNull()) { - _fillColor.setAlphaF(opacity.toFloat()); + _fillColor.setAlphaF(opacity.toReal()); } _styleDirty = false; @@ -307,7 +307,7 @@ bool FGCanvasElement::onChildAdded(LocalProp *prop) } else if (nm == "id") { connect(prop, &LocalProp::valueChanged, this, &FGCanvasElement::markSVGIDDirty); return true; - } else if (prop->name() == "update") { + } else if (nm == "update") { // disable updates optionally? return true; } else if ((nm == "clip") || (nm == "clip-frame")) { @@ -320,11 +320,16 @@ bool FGCanvasElement::onChildAdded(LocalProp *prop) return true; } - if (prop->name() == "layer-type") { + if (nm == "symbol-type") { + // ignored for now + return true; + } + + if (nm == "layer-type") { connect(prop, &LocalProp::valueChanged, [this](QVariant value) {qDebug() << "layer-type:" << value.toByteArray() << "on" << _propertyRoot->path(); }); return true; - } else if (prop->name() == "z-index") { + } else if (nm == "z-index") { connect(prop, &LocalProp::valueChanged, this, &FGCanvasElement::markZIndexDirty); return true; } @@ -355,12 +360,12 @@ QColor FGCanvasElement::fillColor() const void FGCanvasElement::onCenterChanged(QVariant value) { LocalProp* senderProp = static_cast(sender()); - int centerTerm = senderProp->index(); + const unsigned int centerTerm = senderProp->index(); if (centerTerm == 0) { - _center.setX(value.toFloat()); + _center.setX(value.toReal()); } else { - _center.setY(value.toFloat()); + _center.setY(value.toReal()); } requestPolish(); @@ -522,10 +527,10 @@ void FGCanvasElement::parseCSSClip(QByteArray value) return; } - const float top = parseCSSValue(clipRectDesc.at(0)); - const float right = parseCSSValue(clipRectDesc.at(1)); - const float bottom = parseCSSValue(clipRectDesc.at(2)); - const float left = parseCSSValue(clipRectDesc.at(3)); + const qreal top = parseCSSValue(clipRectDesc.at(0)); + const qreal right = parseCSSValue(clipRectDesc.at(1)); + const qreal bottom = parseCSSValue(clipRectDesc.at(2)); + const qreal left = parseCSSValue(clipRectDesc.at(3)); _clipRect = QRectF(left, top, right - left, bottom - top); // qDebug() << "final clip rect:" << _clipRect << "from" << value; diff --git a/utils/fgqcanvas/fgcanvaspath.cpp b/utils/fgqcanvas/fgcanvaspath.cpp index 41bc88dd1..a21415bbc 100644 --- a/utils/fgqcanvas/fgcanvaspath.cpp +++ b/utils/fgqcanvas/fgcanvaspath.cpp @@ -527,6 +527,37 @@ bool FGCanvasPath::onChildAdded(LocalProp *prop) return false; } +bool FGCanvasPath::onChildRemoved(LocalProp* prop) +{ + if (FGCanvasElement::onChildRemoved(prop)) { + return true; + } + + const auto name = prop->name(); + if (name == "rect") { + _isRect = false; + markPathDirty(); + return true; + } + + if ((name == "cmd") || (name == "coord") || (name == "svg")) { + markPathDirty(); + return true; + } + + if ((name == "cmd-geo") || (name == "coord-geo")) { + // ignored + return true; + } + + if (name.startsWith("stroke")) { + markStrokeDirty(); + return true; + } + + return false; +} + typedef enum { PathClose = ( 0 << 1), @@ -806,8 +837,8 @@ void FGCanvasPath::rebuildPathFromCommands(const std::vector& commands, con bool isRelative = cmd & 0x1; const int op = cmd & ~0x1; const int cmdIndex = op >> 1; - const float baseX = isRelative ? newPath.currentPosition().x() : 0.0f; - const float baseY = isRelative ? newPath.currentPosition().y() : 0.0f; + const qreal baseX = isRelative ? newPath.currentPosition().x() : 0.0f; + const qreal baseY = isRelative ? newPath.currentPosition().y() : 0.0f; if ((currentCoord + CoordsPerCommand[cmdIndex]) > coords.size()) { qWarning() << "insufficient path data" << currentCoord << cmdIndex << CoordsPerCommand[cmdIndex] << coords.size(); diff --git a/utils/fgqcanvas/fgcanvaspath.h b/utils/fgqcanvas/fgcanvaspath.h index 34f0dc227..287aa3a10 100644 --- a/utils/fgqcanvas/fgcanvaspath.h +++ b/utils/fgqcanvas/fgcanvaspath.h @@ -48,6 +48,7 @@ private: void markStrokeDirty(); private: bool onChildAdded(LocalProp *prop) override; + bool onChildRemoved(LocalProp* prop) override; void rebuildPath() const; void rebuildPen() const;