Skip to content

Commit

Permalink
MegaMolGraph: prepare use of project directory for modules
Browse files Browse the repository at this point in the history
  • Loading branch information
geringsj committed May 19, 2023
1 parent 4f5d7cc commit 58c547e
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
4 changes: 4 additions & 0 deletions core/include/mmcore/MegaMolGraph.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,9 @@
#include "FrontendResource.h"
#include "FrontendResourcesLookup.h"
#include "ImagePresentationEntryPoints.h"
#include "MegaMolProject.h"
#include "ModuleGraphSubscription.h"

#include "mmcore/MegaMolGraphTypes.h"
#include "mmcore/MegaMolGraph_Convenience.h"
#include "mmcore/RootModuleNamespace.h"
Expand Down Expand Up @@ -136,6 +138,8 @@ class MegaMolGraph {
std::list<Module::ptr_type> graph_entry_points;
megamol::frontend_resources::ImagePresentationEntryPoints* m_image_presentation = nullptr;

megamol::frontend_resources::MegaMolProject* m_current_project_path = nullptr;

MegaMolGraph_Convenience convenience_functions;

frontend_resources::MegaMolGraph_SubscriptionRegistry graph_subscribers;
Expand Down
11 changes: 11 additions & 0 deletions core/src/MegaMolGraph.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -476,6 +476,7 @@ bool megamol::core::MegaMolGraph::AddFrontendResources(

auto [success, graph_resources] = provided_resources_lookup.get_requested_resources({
"ImagePresentationEntryPoints",
"MegaMolProject",
});

if (!success)
Expand All @@ -484,6 +485,9 @@ bool megamol::core::MegaMolGraph::AddFrontendResources(
m_image_presentation = &const_cast<megamol::frontend_resources::ImagePresentationEntryPoints&>(
graph_resources[0].getResource<megamol::frontend_resources::ImagePresentationEntryPoints>());

m_current_project_path = &const_cast<megamol::frontend_resources::MegaMolProject&>(
graph_resources[1].getResource<megamol::frontend_resources::MegaMolProject>());

return true;
}

Expand Down Expand Up @@ -598,6 +602,13 @@ bool megamol::core::MegaMolGraph::add_module(ModuleInstantiationRequest_t const&

module_ptr->setParent(this->dummy_namespace);

// we want to enable filename parameters to open file paths relative to the current .lua project file
// for this to work we need to manually find FilePathParam parameters in created modules and tell them
// the current project directory path
if (m_current_project_path->attributes.has_value()) {
auto project_directory_path = m_current_project_path->attributes.value().project_directory;
}

const auto create_module = [module_description, module_ptr](auto& module_lifetime_dependencies) {
const bool init_ok =
module_ptr->Create(module_lifetime_dependencies); // seems like Create() internally checks IsAvailable()
Expand Down

0 comments on commit 58c547e

Please sign in to comment.