Skip to content

Commit 1589036

Browse files
authored
[MCP] Make the classDiagram output structured (#15345)
This way we can query the extents more easily
1 parent 0dd302e commit 1589036

1 file changed

Lines changed: 13 additions & 3 deletions

File tree

OMEdit/OMEditLIB/MCP/MCPToolsDiagram.cpp

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -198,9 +198,19 @@ QHttpServerResponse MCPServer::handleDiagramTool(const QString &toolName, QJsonV
198198
QImage modelImage = mainWindow->exportModelAsImage(".png", true, viewSelection, pModelWidget, QSize(1024, 1024));
199199
QRectF extent = pGraphicsView->mMergedCoordinateSystem.getExtentRectangle();
200200
QString extentStr = QString("(%1,%2), (%3,%4)").arg(extent.topLeft().x()).arg(extent.topLeft().y()).arg(extent.bottomRight().x()).arg(extent.bottomRight().y());
201-
QString label = isIcon ? "Icon diagram for " : "Model diagram for ";
202-
QString extentNote = isIcon ? ". The diagram has the extent: " : ". The diagram has the extent (marked by a rectangle with a thin gray border): ";
203-
QJsonArray contents = QJsonArray{{makeContent(label + className + extentNote + extentStr + " image size: " + QString::number(modelImage.width()) + "x" + QString::number(modelImage.height()))}, makeContent(modelImage)};
201+
QJsonObject resultInfo = QJsonObject{
202+
{"className", className},
203+
{"info", isIcon ? "Icon diagram generated successfully" : "Model diagram generated successfully. The extent of the diagram in the model is given in the 'extent' field and is also marked by a thin gray border in the image."},
204+
{"extent", QJsonObject{
205+
{"x1", extent.topLeft().x()},
206+
{"y1", extent.topLeft().y()},
207+
{"x2", extent.bottomRight().x()},
208+
{"y2", extent.bottomRight().y()}
209+
}},
210+
{"imageWidth", modelImage.width()},
211+
{"imageHeight", modelImage.height()}
212+
};
213+
QJsonArray contents = QJsonArray{{makeContent(resultInfo), makeContent(modelImage)}};
204214
return makeMCPToolResponse(id, contents);
205215
}
206216
if (toolName == "addComponent") {

0 commit comments

Comments
 (0)