Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added sendMessage signal to surface calculation #1959

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 18 additions & 5 deletions avogadro/qtplugins/surfaces/surfaces.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,9 @@ namespace {
#include <QtWidgets/QFileDialog>
#include <QtWidgets/QMessageBox>
#include <QtWidgets/QProgressDialog>

#include<QJsonObject>
#include<QJsonDocument>
#include<QObject>
#include <QGuiApplication>
#include <QScreen>

Expand All @@ -76,6 +78,8 @@ class Surfaces::PIMPL
public:
GifWriter* gifWriter = nullptr;
gwavi_t* gwaviWriter = nullptr;
signals:
void sendMessage(const QJsonObject& message);
};

Surfaces::Surfaces(QObject* p) : ExtensionPlugin(p), d(new PIMPL())
Expand Down Expand Up @@ -368,7 +372,10 @@ float inline square(float x)
{
return x * x;
}

void sendMessage(QString& message)
{
qDebug() << "Message received:" << message;
}
void Surfaces::calculateEDT(Type type, float defaultResolution)
{
if (type == Unknown && m_dialog != nullptr)
Expand Down Expand Up @@ -447,7 +454,14 @@ void Surfaces::calculateEDT(Type type, float defaultResolution)
}
}
});

QJsonObject jsonMessage;
jsonMessage["status"] = "finished";
jsonMessage["message"] = "Surface calculation completed successfully.";
QJsonDocument doc(jsonMessage);
QString jsonString = doc.toJson(QJsonDocument::Compact);

// Emitting the signal to notify the plugin that the calculation is finished
emit sendMessage(jsonString);
innerFuture.waitForFinished();
});

Expand Down Expand Up @@ -514,8 +528,7 @@ void Surfaces::performEDTStep()
}
}
});

innerFuture.waitForFinished();

});

m_displayMeshWatcher.setFuture(future);
Expand Down
Loading