diff --git a/src/common/CMakeLists.txt b/src/common/CMakeLists.txt index 9694790d0..d8f2a0b4b 100644 --- a/src/common/CMakeLists.txt +++ b/src/common/CMakeLists.txt @@ -8,9 +8,8 @@ if(EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/../../ML_VERSION") endif() set(HEADERS - parameters/rich_parameter.h - parameters/rich_parameter_list.h - parameters/value.h + globals/globals.h + globals/singletons.h interfaces/decorate_plugin_interface.h interfaces/edit_plugin_interface.h interfaces/filter_plugin_interface.h @@ -28,11 +27,13 @@ set(HEADERS ml_document/mesh_model_state.h ml_document/raster_model.h ml_document/render_raster.h + parameters/rich_parameter.h + parameters/rich_parameter_list.h + parameters/value.h utilities/file_format.h GLExtensionsManager.h GLLogStream.h filterscript.h - meshlab_singletons.h meshlabdocumentbundler.h meshlabdocumentxml.h ml_selection_buffers.h @@ -44,9 +45,8 @@ set(HEADERS searcher.h) set(SOURCES - parameters/rich_parameter.cpp - parameters/rich_parameter_list.cpp - parameters/value.cpp + globals/globals.cpp + globals/singletons.cpp interfaces/decorate_plugin_interface.cpp interfaces/filter_plugin_interface.cpp interfaces/plugin_interface.cpp @@ -57,10 +57,12 @@ set(SOURCES ml_document/mesh_model_state.cpp ml_document/raster_model.cpp ml_document/render_raster.cpp + parameters/rich_parameter.cpp + parameters/rich_parameter_list.cpp + parameters/value.cpp GLExtensionsManager.cpp GLLogStream.cpp filterscript.cpp - meshlab_singletons.cpp meshlabdocumentbundler.cpp meshlabdocumentxml.cpp ml_selection_buffers.cpp diff --git a/src/common/common.pro b/src/common/common.pro index 3ae41a50a..305afc04e 100644 --- a/src/common/common.pro +++ b/src/common/common.pro @@ -40,12 +40,8 @@ exists(../../ML_VERSION){ # Input HEADERS += \ - GLExtensionsManager.h \ - parameters/rich_parameter_list.h \ - parameters/value.h \ - parameters/rich_parameter.h \ - filterscript.h \ - GLLogStream.h \ + globals/globals.h \ + globals/singletons.h \ interfaces/decorate_plugin_interface.h \ interfaces/edit_plugin_interface.h \ interfaces/filter_plugin_interface.h \ @@ -62,8 +58,13 @@ HEADERS += \ ml_document/mesh_document.h \ ml_document/raster_model.h \ ml_document/render_raster.h \ + parameters/rich_parameter_list.h \ + parameters/value.h \ + parameters/rich_parameter.h \ utilities/file_format.h \ - meshlab_singletons.h \ + GLExtensionsManager.h \ + filterscript.h \ + GLLogStream.h \ plugin_manager.h \ mlexception.h \ mlapplication.h \ @@ -73,12 +74,8 @@ HEADERS += \ meshlabdocumentxml.h SOURCES += \ - GLExtensionsManager.cpp \ - parameters/rich_parameter.cpp \ - parameters/rich_parameter_list.cpp \ - parameters/value.cpp \ - filterscript.cpp \ - GLLogStream.cpp \ + globals/globals.cpp \ + globals/singletons.cpp \ interfaces/decorate_plugin_interface.cpp \ interfaces/filter_plugin_interface.cpp \ interfaces/plugin_interface.cpp \ @@ -89,7 +86,12 @@ SOURCES += \ ml_document/mesh_document.cpp \ ml_document/raster_model.cpp \ ml_document/render_raster.cpp \ - meshlab_singletons.cpp \ + parameters/rich_parameter.cpp \ + parameters/rich_parameter_list.cpp \ + parameters/value.cpp \ + GLExtensionsManager.cpp \ + filterscript.cpp \ + GLLogStream.cpp \ plugin_manager.cpp \ mlapplication.cpp \ searcher.cpp \ diff --git a/src/common/globals/globals.cpp b/src/common/globals/globals.cpp new file mode 100644 index 000000000..023da242d --- /dev/null +++ b/src/common/globals/globals.cpp @@ -0,0 +1,99 @@ +/**************************************************************************** +* MeshLab o o * +* A versatile mesh processing toolbox o o * +* _ O _ * +* Copyright(C) 2005-2020 \/)\/ * +* Visual Computing Lab /\/| * +* ISTI - Italian National Research Council | * +* \ * +* All rights reserved. * +* * +* This program is free software; you can redistribute it and/or modify * +* it under the terms of the GNU General Public License as published by * +* the Free Software Foundation; either version 2 of the License, or * +* (at your option) any later version. * +* * +* This program is distributed in the hope that it will be useful, * +* but WITHOUT ANY WARRANTY; without even the implied warranty of * +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * +* GNU General Public License (http://www.gnu.org/licenses/gpl.txt) * +* for more details. * +* * +****************************************************************************/ + +#include "globals.h" + +#include +#include + +#include "../parameters/rich_parameter_list.h" + +RichParameterList& meshlab::defaultGlobalParameterList() +{ + static RichParameterList globalRPS; + return globalRPS; +} + +QString basePath() +{ + QDir baseDir(qApp->applicationDirPath()); + +#if defined(Q_OS_WIN) + // Windows: + // during development with visual studio binary could be in the debug/release subdir. + // once deployed plugins dir is in the application directory, so + if (baseDir.dirName() == "debug" || baseDir.dirName() == "release") baseDir.cdUp(); +#endif + +#if defined(Q_OS_MAC) + // Mac: during developmentwith xcode and well deployed the binary is well buried. + for(int i=0;i<6;++i){ + if(baseDir.exists("plugins")) break; + baseDir.cdUp(); + } + qDebug("The base dir is %s", qUtf8Printable(baseDir.absolutePath())); +#endif + return baseDir.absolutePath(); +} + +QString meshlab::defaultPluginPath() +{ + QDir pluginsDir(basePath()); +#if defined(Q_OS_WIN) + QString d = pluginsDir.dirName(); + QString dLower = d.toLower(); + if (dLower == "release" || dLower == "relwithdebinfo" || dLower == "debug" || + dLower == "minsizerel") { + // This is a configuration directory for MS Visual Studio. + pluginsDir.cdUp(); + } else { + d.clear(); + } +#endif + if (pluginsDir.exists("plugins")) { + pluginsDir.cd("plugins"); + +#if defined(Q_OS_WIN) + // Re-apply the configuration dir, if any. + if (!d.isEmpty() && pluginsDir.exists(d)) { + pluginsDir.cd(d); + } +#endif + + return pluginsDir.absolutePath(); + } +#if !defined(Q_OS_MAC) && !defined(Q_OS_WIN) + else if (pluginsDir.dirName() == "bin") { + pluginsDir.cdUp(); + pluginsDir.cd("lib"); + pluginsDir.cd("meshlab"); + if (pluginsDir.exists("plugins")) { + pluginsDir.cd("plugins"); + return pluginsDir.absolutePath(); + } + } +#endif + //QMessageBox::warning(0,"Meshlab Initialization","Serious error. Unable to find the plugins directory."); + qDebug("Meshlab Initialization: Serious error. Unable to find the plugins directory."); + return {}; +} diff --git a/src/common/globals/globals.h b/src/common/globals/globals.h new file mode 100644 index 000000000..a5350bb2f --- /dev/null +++ b/src/common/globals/globals.h @@ -0,0 +1,38 @@ +/**************************************************************************** +* MeshLab o o * +* A versatile mesh processing toolbox o o * +* _ O _ * +* Copyright(C) 2005-2020 \/)\/ * +* Visual Computing Lab /\/| * +* ISTI - Italian National Research Council | * +* \ * +* All rights reserved. * +* * +* This program is free software; you can redistribute it and/or modify * +* it under the terms of the GNU General Public License as published by * +* the Free Software Foundation; either version 2 of the License, or * +* (at your option) any later version. * +* * +* This program is distributed in the hope that it will be useful, * +* but WITHOUT ANY WARRANTY; without even the implied warranty of * +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * +* GNU General Public License (http://www.gnu.org/licenses/gpl.txt) * +* for more details. * +* * +****************************************************************************/ + +#ifndef MESHLAB_GLOBALS_H +#define MESHLAB_GLOBALS_H + +#include + +class RichParameterList; + +namespace meshlab { + +RichParameterList& defaultGlobalParameterList(); +QString defaultPluginPath(); + +} + +#endif // MESHLAB_GLOBALS_H diff --git a/src/common/meshlab_singletons.cpp b/src/common/globals/singletons.cpp similarity index 56% rename from src/common/meshlab_singletons.cpp rename to src/common/globals/singletons.cpp index d9f73f875..66bd2c91a 100644 --- a/src/common/meshlab_singletons.cpp +++ b/src/common/globals/singletons.cpp @@ -1,6 +1,7 @@ -#include "meshlab_singletons.h" +#include "singletons.h" -#include "plugin_manager.h" +#include "../plugin_manager.h" +#include "globals.h" namespace meshlab { @@ -8,19 +9,13 @@ MeshLabSingletons::MeshLabSingletons() { } -RichParameterList& MeshLabSingletons::globalRPLInstance() -{ - static RichParameterList globalRPS; - return globalRPS; -} - PluginManager& MeshLabSingletons::pluginManagerInstance() { static bool initialized = false; static PluginManager pm; if (!initialized){ initialized = true; - RichParameterList& globalRPS = globalRPLInstance(); + RichParameterList& globalRPS = defaultGlobalParameterList(); pm.loadPlugins(globalRPS); } return pm; diff --git a/src/common/meshlab_singletons.h b/src/common/globals/singletons.h similarity index 92% rename from src/common/meshlab_singletons.h rename to src/common/globals/singletons.h index 3db455afc..3b4f8f186 100644 --- a/src/common/meshlab_singletons.h +++ b/src/common/globals/singletons.h @@ -29,11 +29,16 @@ class PluginManager; namespace meshlab { +/** + * @brief The MeshLabSingletons class + * This class contains all the singleton instances used on MeshLab. + * - pluginManager + * - defaultGlobalParameterList + */ class MeshLabSingletons { public: /** Singleton Instances **/ - static RichParameterList& globalRPLInstance(); static PluginManager& pluginManagerInstance(); MeshLabSingletons(MeshLabSingletons const&) = delete; diff --git a/src/meshlabplugins/decorate_background/decorate_background.cpp b/src/meshlabplugins/decorate_background/decorate_background.cpp index d7c78c6f5..199a69a24 100644 --- a/src/meshlabplugins/decorate_background/decorate_background.cpp +++ b/src/meshlabplugins/decorate_background/decorate_background.cpp @@ -66,11 +66,6 @@ void DecorateBackgroundPlugin::initGlobalParameterList(const QAction* action, Ri switch(ID(action)) { case DP_SHOW_CUBEMAPPED_ENV : - if(!parset.hasParameter(CubeMapPathParam())) - { - QString cubemapDirPath = PluginManager::getBaseDirPath() + QString("/textures/cubemaps/uffizi.jpg"); - //parset.addParam(RichString(CubeMapPathParam(), cubemapDirPath,"","")); - } break; case DP_SHOW_GRID : parset.addParam(RichFloat(BoxRatioParam(),1.2f,"Box Ratio","The size of the grid around the object w.r.t. the bbox of the object")); diff --git a/src/meshlabserver/mainserver.cpp b/src/meshlabserver/mainserver.cpp index c042e4cd6..5e3b7e3b8 100644 --- a/src/meshlabserver/mainserver.cpp +++ b/src/meshlabserver/mainserver.cpp @@ -24,7 +24,7 @@ #include #include #include -#include +#include #include #include #include