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

Fix bug when cloning a story with windows #643

Merged
merged 10 commits into from
Dec 23, 2023
2 changes: 2 additions & 0 deletions .github/workflows/app_build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -479,6 +479,8 @@ jobs:
echo "Qt $QT_VERSION already installed"
else
echo "Install aqtinstall, then install Qt $QT_VERSION for ${{ matrix.QT_OS_NAME }} ${{ matrix.QT_ARCH }}"
pip show setuptools
pip install setuptools --upgrade
pip3 install aqtinstall
aqt install-qt --outputdir ./build/Qt-install/ ${{ matrix.QT_OS_NAME }} desktop $QT_VERSION ${{ matrix.QT_ARCH }} -m qtwebchannel qtwebengine qtwebview qt5compat qtpositioning
fi
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/cla.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ jobs:
- name: "CLA Assistant"
if: (github.event.comment.body == 'recheck' || github.event.comment.body == 'I have read the CLA Document and I hereby sign the CLA') || github.event_name == 'pull_request_target'
# Beta Release
uses: cla-assistant/github-action@v2.1.3-beta
uses: cla-assistant/github-action@v2.3.1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
# the below token should have repo scope and must be manually added by you in the repository's secret
Expand Down
2 changes: 1 addition & 1 deletion src/openstudio_app/OpenStudioApp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1288,7 +1288,7 @@ void OpenStudioApp::startMeasureManagerProcess() {
tcpServer.close();

QString portString = QString::number(port);
QString urlString = "http://127.0.0.1:" + portString;
QString urlString = "http://localhost:" + portString;
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jmarrec what do you think about this? For some reason when I run the app from the installer it can't find the measure manager. Is there some reason the new measure manager is only listening to localhost and not 127.0.0.1? I always thought the two were the same for IPv4.

macumber@Automatic-Magic-PC MINGW64 /c/openstudioapplication-1.7.0-rc0/bin
$ ./openstudio classic measure -s 1616
[2023-12-18 20:53:58] INFO  WEBrick 1.6.0
[2023-12-18 20:53:58] INFO  ruby 2.7.2 (2020-10-01) [x64-mswin64_140]
[2023-12-18 20:53:58] INFO  WEBrick::HTTPServer#start: pid=17592 port=1616
127.0.0.1 - - [18/Dec/2023:20:54:15 Mountain Standard Time] "GET / HTTP/1.1" 200 79
- -> /
[2023-12-18 20:54:35] INFO  going to shutdown ...
[2023-12-18 20:54:35] INFO  WEBrick::HTTPServer#start done.
┌────────────────────────────────────────────────────────────────────────────────┐
│  The `classic` command is deprecated and will be removed in a future release   │
└────────────────────────────────────────────────────────────────────────────────┘

macumber@Automatic-Magic-PC MINGW64 /c/openstudioapplication-1.7.0-rc0/bin
$ ./openstudio measure -s 1616
MeasureManager ReadyAccepting requests on: http://localhost:1616/

Copy link
Collaborator

@jmarrec jmarrec Dec 23, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You're on windows I assume (edit: I see MINGW64, so yes)? I kinda just gave up trying to make both localhost and 127.0.0.0 work on windows... It's a limitation of the cpprestsdk afaik. https://github.com/NREL/OpenStudio/blob/05c60768c1e1057083ce644d49711f7377f8ce1e/src/cli/MeasureManager.cpp#L563-L569

QUrl url(urlString);
measureManager().setUrl(url);

Expand Down
44 changes: 28 additions & 16 deletions src/openstudio_lib/GeometryEditorView.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,9 @@
#include <QTcpServer>
#include <QComboBox>
#include <QFileDialog>
#include <QJsonArray>
#include <QJsonDocument>
#include <QJsonObject>
#include <QMessageBox>
#include <QTimer>
#include <QStackedWidget>
Expand Down Expand Up @@ -359,7 +362,7 @@ void FloorspaceEditor::loadEditor() {
}

javascript += "`;\n\
const style = document.createElement('style')\n\
const style = document.createElement('style');\n\
style.type = 'text/css';\n\
style.innerHTML = rules;\n\
document.head.appendChild(style);\n";
Expand Down Expand Up @@ -412,21 +415,30 @@ document.head.appendChild(style);\n";
m_javascriptRunning = true;

std::string json = floorplan.toJSON(false);
// TODO: @macumber: delete this now?
// DLM: temp
// Json::CharReaderBuilder rbuilder;
// std::istringstream ss(json);
// std::string errorString;
// Json::Value value;
// bool parsingSuccessful = Json::parseFromStream(rbuilder, ss, &value, &errorString);
// value.removeMember("stories");
// Json::StreamWriterBuilder wbuilder;
// // mimic the old FastWriter behavior:
// wbuilder["commentStyle"] = "None";
// wbuilder["indentation"] = "";
// const std::string json = Json::writeString(wbuilder, value);

QString javascript = QString("window.api.importLibrary(JSON.stringify(") + QString::fromStdString(json) + QString("));");

QJsonDocument doc = QJsonDocument::fromJson(QString::fromStdString(json).toUtf8());

// ensure any missing required properties are set
if (!doc.isNull()) {
if (doc.isObject()) {
QJsonObject obj = doc.object();
if (!obj.contains("daylighting_control_definitions")) {
obj.insert("daylighting_control_definitions", QJsonArray());
}
if (!obj.contains("door_definitions")) {
obj.insert("door_definitions", QJsonArray());
}
if (!obj.contains("pitched_roofs")) {
obj.insert("pitched_roofs", QJsonArray());
}
if (!obj.contains("window_definitions")) {
obj.insert("window_definitions", QJsonArray());
}
doc.setObject(obj);
}
}

QString javascript = QString("window.api.importLibrary(JSON.stringify(") + doc.toJson(QJsonDocument::Compact) + QString("));");
m_view->page()->runJavaScript(javascript, [this](const QVariant& /*v*/) { m_javascriptRunning = false; });
while (m_javascriptRunning) {
OSAppBase::instance()->processEvents(QEventLoop::ExcludeUserInputEvents, 200);
Expand Down
488 changes: 214 additions & 274 deletions src/openstudio_lib/library/embeddable_geometry_editor.html

Large diffs are not rendered by default.

14 changes: 9 additions & 5 deletions src/shared_gui_components/MeasureManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ bool MeasureManager::waitForStarted(int msec) {
int current = 0;
while (!success && current < numTries) {
QNetworkRequest request(thisUrl);
request.setHeader(QNetworkRequest::ContentTypeHeader, "json");
request.setHeader(QNetworkRequest::ContentTypeHeader, "application/json");

QNetworkAccessManager manager;

Expand Down Expand Up @@ -463,7 +463,7 @@ std::vector<measure::OSArgument> MeasureManager::getArguments(const BCLMeasure&
QString data = QString(R"json({"measure_dir": "%1", "osm_path": "%2"})json").arg(toQString(t_measure.directory()), toQString(m_tempModelPath));

QNetworkRequest request(thisUrl);
request.setHeader(QNetworkRequest::ContentTypeHeader, "json");
request.setHeader(QNetworkRequest::ContentTypeHeader, "application/json");

QNetworkAccessManager manager;

Expand Down Expand Up @@ -579,6 +579,10 @@ boost::optional<measure::OSArgument> MeasureManager::getArgument(const measure::
Json::Value choiceValues = argument.get("choice_values", Json::Value(Json::arrayValue));
Json::Value choiceDisplayNames = argument.get("choice_display_names", Json::Value(Json::arrayValue));

if (choiceValues.empty()) {
choiceValues = argument.get("choices_values", Json::Value(Json::arrayValue));
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a bug in the OS repo, there is a typo of choices_values instead of choice_values

Copy link
Collaborator

@jmarrec jmarrec Dec 23, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I fixed it already in NREL/OpenStudio#5046 but it wasn't selected for 3.7.0 official... I specifically asked for it to be included but it was too last minute

}

Json::ArrayIndex n = choiceValues.size();
if (n != choiceDisplayNames.size()) {
choiceDisplayNames = choiceValues;
Expand Down Expand Up @@ -836,7 +840,7 @@ bool MeasureManager::reset() {
QString data = QString("{}");

QNetworkRequest request(thisUrl);
request.setHeader(QNetworkRequest::ContentTypeHeader, "json");
request.setHeader(QNetworkRequest::ContentTypeHeader, "application/json");

QNetworkAccessManager manager;

Expand Down Expand Up @@ -876,7 +880,7 @@ bool MeasureManager::checkForLocalBCLUpdates() {
QString data = QString("{}");

QNetworkRequest request(thisUrl);
request.setHeader(QNetworkRequest::ContentTypeHeader, "json");
request.setHeader(QNetworkRequest::ContentTypeHeader, "application/json");

QNetworkAccessManager manager;

Expand Down Expand Up @@ -917,7 +921,7 @@ bool MeasureManager::checkForUpdates(const openstudio::path& measureDir, bool fo
QString(R"json({"measure_dir": "%1", "force_reload": "%2"})json").arg(toQString(measureDir), force ? QString("true") : QString("false"));

QNetworkRequest request(thisUrl);
request.setHeader(QNetworkRequest::ContentTypeHeader, "json");
request.setHeader(QNetworkRequest::ContentTypeHeader, "application/json");

QNetworkAccessManager manager;

Expand Down
26 changes: 13 additions & 13 deletions translations/OpenStudioApp_ar.ts
Original file line number Diff line number Diff line change
Expand Up @@ -720,24 +720,24 @@ If you would like to see the OpenStudioApplication translated in your language o
<context>
<name>openstudio::MeasureManager</name>
<message>
<location filename="../src/shared_gui_components/MeasureManager.cpp" line="949"/>
<location filename="../src/shared_gui_components/MeasureManager.cpp" line="968"/>
<location filename="../src/shared_gui_components/MeasureManager.cpp" line="953"/>
<location filename="../src/shared_gui_components/MeasureManager.cpp" line="972"/>
<source>Measures Updated</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../src/shared_gui_components/MeasureManager.cpp" line="949"/>
<location filename="../src/shared_gui_components/MeasureManager.cpp" line="953"/>
<source>All measures are up-to-date.</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../src/shared_gui_components/MeasureManager.cpp" line="953"/>
<location filename="../src/shared_gui_components/MeasureManager.cpp" line="957"/>
<source> measures have been updated on BCL compared to your local BCL directory.
</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../src/shared_gui_components/MeasureManager.cpp" line="954"/>
<location filename="../src/shared_gui_components/MeasureManager.cpp" line="958"/>
<source>Would you like update them?</source>
<translation type="unfinished"></translation>
</message>
Expand All @@ -760,30 +760,30 @@ If you would like to see the OpenStudioApplication translated in your language o
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../src/openstudio_lib/OSDocument.cpp" line="1469"/>
<location filename="../src/openstudio_lib/OSDocument.cpp" line="1544"/>
<location filename="../src/openstudio_lib/OSDocument.cpp" line="1474"/>
<location filename="../src/openstudio_lib/OSDocument.cpp" line="1549"/>
<source>Failed to save model</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../src/openstudio_lib/OSDocument.cpp" line="1470"/>
<location filename="../src/openstudio_lib/OSDocument.cpp" line="1545"/>
<location filename="../src/openstudio_lib/OSDocument.cpp" line="1475"/>
<location filename="../src/openstudio_lib/OSDocument.cpp" line="1550"/>
<source>Failed to save model, make sure that you do not have the location open and that you have correct write access.</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../src/openstudio_lib/OSDocument.cpp" line="1513"/>
<location filename="../src/openstudio_lib/OSDocument.cpp" line="1518"/>
<source>Save</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../src/openstudio_lib/OSDocument.cpp" line="1513"/>
<location filename="../src/openstudio_lib/OSDocument.cpp" line="1518"/>
<source>(*.osm)</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../src/openstudio_lib/OSDocument.cpp" line="1707"/>
<location filename="../src/openstudio_lib/OSDocument.cpp" line="1709"/>
<location filename="../src/openstudio_lib/OSDocument.cpp" line="1712"/>
<location filename="../src/openstudio_lib/OSDocument.cpp" line="1714"/>
<source>Select My Measures Directory</source>
<translation type="unfinished"></translation>
</message>
Expand Down
26 changes: 13 additions & 13 deletions translations/OpenStudioApp_ca.ts
Original file line number Diff line number Diff line change
Expand Up @@ -808,24 +808,24 @@ Si voleu que OpeStudioApplication estigui a la vostra llengua, esperem la vostra
<context>
<name>openstudio::MeasureManager</name>
<message>
<location filename="../src/shared_gui_components/MeasureManager.cpp" line="949"/>
<location filename="../src/shared_gui_components/MeasureManager.cpp" line="968"/>
<location filename="../src/shared_gui_components/MeasureManager.cpp" line="953"/>
<location filename="../src/shared_gui_components/MeasureManager.cpp" line="972"/>
<source>Measures Updated</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../src/shared_gui_components/MeasureManager.cpp" line="949"/>
<location filename="../src/shared_gui_components/MeasureManager.cpp" line="953"/>
<source>All measures are up-to-date.</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../src/shared_gui_components/MeasureManager.cpp" line="953"/>
<location filename="../src/shared_gui_components/MeasureManager.cpp" line="957"/>
<source> measures have been updated on BCL compared to your local BCL directory.
</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../src/shared_gui_components/MeasureManager.cpp" line="954"/>
<location filename="../src/shared_gui_components/MeasureManager.cpp" line="958"/>
<source>Would you like update them?</source>
<translation type="unfinished"></translation>
</message>
Expand All @@ -848,30 +848,30 @@ Si voleu que OpeStudioApplication estigui a la vostra llengua, esperem la vostra
<translation>(*.xml)</translation>
</message>
<message>
<location filename="../src/openstudio_lib/OSDocument.cpp" line="1469"/>
<location filename="../src/openstudio_lib/OSDocument.cpp" line="1544"/>
<location filename="../src/openstudio_lib/OSDocument.cpp" line="1474"/>
<location filename="../src/openstudio_lib/OSDocument.cpp" line="1549"/>
<source>Failed to save model</source>
<translation>Error al desar el model</translation>
</message>
<message>
<location filename="../src/openstudio_lib/OSDocument.cpp" line="1470"/>
<location filename="../src/openstudio_lib/OSDocument.cpp" line="1545"/>
<location filename="../src/openstudio_lib/OSDocument.cpp" line="1475"/>
<location filename="../src/openstudio_lib/OSDocument.cpp" line="1550"/>
<source>Failed to save model, make sure that you do not have the location open and that you have correct write access.</source>
<translation>Error al desar el model, comprova que no tinguis el fitxer obert i que tens privilegis d&apos;accés d&apos;escriptura.</translation>
</message>
<message>
<location filename="../src/openstudio_lib/OSDocument.cpp" line="1513"/>
<location filename="../src/openstudio_lib/OSDocument.cpp" line="1518"/>
<source>Save</source>
<translation>Desar</translation>
</message>
<message>
<location filename="../src/openstudio_lib/OSDocument.cpp" line="1513"/>
<location filename="../src/openstudio_lib/OSDocument.cpp" line="1518"/>
<source>(*.osm)</source>
<translation></translation>
</message>
<message>
<location filename="../src/openstudio_lib/OSDocument.cpp" line="1707"/>
<location filename="../src/openstudio_lib/OSDocument.cpp" line="1709"/>
<location filename="../src/openstudio_lib/OSDocument.cpp" line="1712"/>
<location filename="../src/openstudio_lib/OSDocument.cpp" line="1714"/>
<source>Select My Measures Directory</source>
<translation>Seleccionar la Carpeta &quot;My Measures&quot;</translation>
</message>
Expand Down
26 changes: 13 additions & 13 deletions translations/OpenStudioApp_de.ts
Original file line number Diff line number Diff line change
Expand Up @@ -816,24 +816,24 @@ Wenn Sie möchten, dass die OpenStudio-Applikation in die Sprache Ihrer Wahl üb
<context>
<name>openstudio::MeasureManager</name>
<message>
<location filename="../src/shared_gui_components/MeasureManager.cpp" line="949"/>
<location filename="../src/shared_gui_components/MeasureManager.cpp" line="968"/>
<location filename="../src/shared_gui_components/MeasureManager.cpp" line="953"/>
<location filename="../src/shared_gui_components/MeasureManager.cpp" line="972"/>
<source>Measures Updated</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../src/shared_gui_components/MeasureManager.cpp" line="949"/>
<location filename="../src/shared_gui_components/MeasureManager.cpp" line="953"/>
<source>All measures are up-to-date.</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../src/shared_gui_components/MeasureManager.cpp" line="953"/>
<location filename="../src/shared_gui_components/MeasureManager.cpp" line="957"/>
<source> measures have been updated on BCL compared to your local BCL directory.
</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../src/shared_gui_components/MeasureManager.cpp" line="954"/>
<location filename="../src/shared_gui_components/MeasureManager.cpp" line="958"/>
<source>Would you like update them?</source>
<translation type="unfinished"></translation>
</message>
Expand All @@ -856,30 +856,30 @@ Wenn Sie möchten, dass die OpenStudio-Applikation in die Sprache Ihrer Wahl üb
<translation>(*.xml)</translation>
</message>
<message>
<location filename="../src/openstudio_lib/OSDocument.cpp" line="1469"/>
<location filename="../src/openstudio_lib/OSDocument.cpp" line="1544"/>
<location filename="../src/openstudio_lib/OSDocument.cpp" line="1474"/>
<location filename="../src/openstudio_lib/OSDocument.cpp" line="1549"/>
<source>Failed to save model</source>
<translation>Modell konnte nicht gespeichert werden</translation>
</message>
<message>
<location filename="../src/openstudio_lib/OSDocument.cpp" line="1470"/>
<location filename="../src/openstudio_lib/OSDocument.cpp" line="1545"/>
<location filename="../src/openstudio_lib/OSDocument.cpp" line="1475"/>
<location filename="../src/openstudio_lib/OSDocument.cpp" line="1550"/>
<source>Failed to save model, make sure that you do not have the location open and that you have correct write access.</source>
<translation>Modell konnte nicht gespeichert werden. Vergewissern Sie sich, dass der Speicherort nicht geöffnet ist und dass Sie korrekte Schreibrechte haben.</translation>
</message>
<message>
<location filename="../src/openstudio_lib/OSDocument.cpp" line="1513"/>
<location filename="../src/openstudio_lib/OSDocument.cpp" line="1518"/>
<source>Save</source>
<translation>Speichern</translation>
</message>
<message>
<location filename="../src/openstudio_lib/OSDocument.cpp" line="1513"/>
<location filename="../src/openstudio_lib/OSDocument.cpp" line="1518"/>
<source>(*.osm)</source>
<translation>(*.osm)</translation>
</message>
<message>
<location filename="../src/openstudio_lib/OSDocument.cpp" line="1707"/>
<location filename="../src/openstudio_lib/OSDocument.cpp" line="1709"/>
<location filename="../src/openstudio_lib/OSDocument.cpp" line="1712"/>
<location filename="../src/openstudio_lib/OSDocument.cpp" line="1714"/>
<source>Select My Measures Directory</source>
<translation>Verzeichnis für Meine Measures auswählen</translation>
</message>
Expand Down
Loading
Loading