From c48d69322a19cdeda09308da2bb78b65480679e2 Mon Sep 17 00:00:00 2001 From: Jonathan Grangien Date: Mon, 2 Jul 2018 17:01:39 -0400 Subject: [PATCH] Run file dialog on separate thread and connect chosen file to GUI --- modules/dataloader/operators/loader.cpp | 40 +++++++++++-------- .../DataLoader/PrepareUploadedData.jsx | 4 ++ .../DataLoader/UploadDataButton.jsx | 6 +-- 3 files changed, 28 insertions(+), 22 deletions(-) diff --git a/modules/dataloader/operators/loader.cpp b/modules/dataloader/operators/loader.cpp index 2f11472343..6571dbb28f 100644 --- a/modules/dataloader/operators/loader.cpp +++ b/modules/dataloader/operators/loader.cpp @@ -150,22 +150,28 @@ Loader::Loader() } void Loader::uploadData() { - nfdchar_t *outPath = NULL; - nfdresult_t result = NFD_OpenDialog( "cdf", NULL, &outPath ); - std::string fullPaths; - - // TODO: Separate thread - if ( outPath && result == NFD_OKAY ) { - fullPaths = outPath; - free(outPath); - LINFO("Paths = " + fullPaths); + { + std::thread t([&](){ + LINFO("opened dialog?"); + nfdchar_t *outPath = NULL; + nfdresult_t result = NFD_OpenDialog( "cdf", NULL, &outPath ); //TODO: handle different data types + + if ( outPath && result == NFD_OKAY ) { + LINFO("selected a file."); + _filePaths = outPath; + free(outPath); + } + else if ( result == NFD_CANCEL ) { + LINFO("User pressed cancel."); + } + else { + std::string error = NFD_GetError(); + LINFO("Error: \n" + error ); + } + }); + + t.detach(); } - else if ( result == NFD_CANCEL ) { - LINFO("User pressed cancel."); - } - // else { - // LINFO("Error: \n" + *NFD_GetError() ); - // } // Linux // #ifdef _linux @@ -224,14 +230,14 @@ void Loader::uploadData() { // // Still to do // #endif -; + } void Loader::createInternalDataItemProperties() { module()->validateDataDirectory(); std::vector volumeItems = module()->volumeDataItems(); - LDEBUG("volume items vec size " + std::to_string(volumeItems.size())); + // LDEBUG("volume items vec size " + std::to_string(volumeItems.size())); for (auto item : volumeItems) { const std::string dirLeaf = openspace::dataloader::helpers::getDirLeaf(item); diff --git a/modules/webgui/web/src/components/DataLoader/PrepareUploadedData.jsx b/modules/webgui/web/src/components/DataLoader/PrepareUploadedData.jsx index 5fa769856b..ad50321d50 100644 --- a/modules/webgui/web/src/components/DataLoader/PrepareUploadedData.jsx +++ b/modules/webgui/web/src/components/DataLoader/PrepareUploadedData.jsx @@ -142,7 +142,11 @@ class PrepareUploadedData extends Component { >>>>>> Run file dialog on separate thread and connect chosen file to GUI closeCallback={() => this.setState({ activated: false })}>
{getDirectoryLeaf(this.props.filePaths)} diff --git a/modules/webgui/web/src/components/DataLoader/UploadDataButton.jsx b/modules/webgui/web/src/components/DataLoader/UploadDataButton.jsx index 1619f87f30..d7b2eaff8e 100644 --- a/modules/webgui/web/src/components/DataLoader/UploadDataButton.jsx +++ b/modules/webgui/web/src/components/DataLoader/UploadDataButton.jsx @@ -17,9 +17,8 @@ class UploadDataButton extends Component { } handleClick() { - // this.subscribeToFilepaths(); + this.subscribeToFilepaths(); this.triggerFilesToUpload(); - this.props.setFilePaths("/home/mberg/Data/testData.cdf"); } triggerFilesToUpload() { @@ -32,9 +31,6 @@ class UploadDataButton extends Component { handleUploadedFiles(data) { this.props.setFilePaths(data.Value); - - // Show window for changing task properties - // with "convert" button or something } render() {