Skip to content

Commit

Permalink
Remove not needed includes from plugin logger
Browse files Browse the repository at this point in the history
  • Loading branch information
lvk88 committed Aug 16, 2024
1 parent 7c8805f commit 22e70d7
Show file tree
Hide file tree
Showing 5 changed files with 365 additions and 315 deletions.
70 changes: 45 additions & 25 deletions src/common/plugins/interfaces/decorate_plugin.cpp
Original file line number Diff line number Diff line change
@@ -1,56 +1,74 @@
#include "decorate_plugin.h"

#include <QAction>

/** \brief
* This function is called by the framework, for each plugin that has global parameters (e.g. \ref MeshDecorateInterface) at the start of the application.
* The rationale is to allow to each plugin to have a list of global persistent parameters that can be changed from the meshlab itself and whose value is persistent between different meshlab invocations.
* This function is called by the framework, for each plugin that has global parameters (e.g. \ref
MeshDecorateInterface) at the start of the application.
* The rationale is to allow to each plugin to have a list of global persistent parameters that can
be changed from the meshlab itself and whose value is persistent between different meshlab
invocations.
* A typical example is the background color.
*
* For the global parameters the following rules apply:
*
* \li there is a <b>hardwired</b> default value: a safe consistent value that is directly coded into the plugin and to which the user can always revert if needed.
* \li there is a <b>saved</b> value: a value that is stored into a persistent location into the user space (registry/home/library) and it is presented as default value of the parameter at each MeshLab invocation.
* \li there is a <b>current</b> value: a value that is currently used, different for each document instance and that is not stored permanently.
* \li there is a <b>hardwired</b> default value: a safe consistent value that is directly coded
into the plugin and to which the user can always revert if needed.
* \li there is a <b>saved</b> value: a value that is stored into a persistent location into the
user space (registry/home/library) and it is presented as default value of the parameter at each
MeshLab invocation.
* \li there is a <b>current</b> value: a value that is currently used, different for each document
instance and that is not stored permanently.
*
* The plugin use the current value to draw its decoration.
* at startup the current value is always silently initialized to the saved value.
* User can revert current value to the saved values and to the hardwired values.
* In the dialog for each parameter some buttons should be present:
* \li apply: use the currently edited parameter value without saving it anywhere. After the closure of the document these values will be lost.
* \li apply: use the currently edited parameter value without saving it anywhere. After the closure
of the document these values will be lost.
* \li load: load from the saved values
* \li save: save to a permanent location the current value (to the registry),
* \li reset: revert to the hardwired values
* If your plugins/action has no GlobalParameter, do nothing.
* The RichParameterList comes to the StartDecorate already initialized with the values stored on the permanent storage.
* At the start up the initGlobalParameterList function is called with an empty RichParameterList (to collect the default values)
* The RichParameterList comes to the StartDecorate already initialized with the values stored on
the permanent storage.
* At the start up the initGlobalParameterList function is called with an empty RichParameterList
(to collect the default values)
* If a filter wants to save some permanent stuff should set the permanent default values.
*/
void DecoratePlugin::initGlobalParameterList(const QAction* /*format*/, RichParameterList& /*globalparam*/)
void DecoratePlugin::initGlobalParameterList(
const QAction* /*format*/,
RichParameterList& /*globalparam*/)
{
}

QAction* DecoratePlugin::action(QString name) const
{
QString n = name;
for(QAction *tt : actions())
if (name == this->decorationName(ID(tt))) return tt;
n.replace("&","");
for(QAction *tt : actions())
if (n == this->decorationName(ID(tt))) return tt;
for (QAction* tt : actions())
if (name == this->decorationName(ID(tt)))
return tt;
n.replace("&", "");
for (QAction* tt : actions())
if (n == this->decorationName(ID(tt)))
return tt;

qDebug("unable to find the id corresponding to action '%s'", qUtf8Printable(name));
return 0;
}

MeshLabPlugin::ActionIDType DecoratePlugin::ID(const QAction* a) const
{
QString aa=a->text();
foreach(ActionIDType tt, types())
if (a->text() == this->decorationName(tt)) return tt;
aa.replace("&","");
foreach(ActionIDType tt, types())
if (aa == this->decorationName(tt)) return tt;
QString aa = a->text();
foreach (ActionIDType tt, types())
if (a->text() == this->decorationName(tt))
return tt;
aa.replace("&", "");
foreach (ActionIDType tt, types())
if (aa == this->decorationName(tt))
return tt;

qDebug("unable to find the id corresponding to action '%s'", qUtf8Printable(a->text()));
assert(0);
Expand All @@ -60,11 +78,13 @@ MeshLabPlugin::ActionIDType DecoratePlugin::ID(const QAction* a) const
MeshLabPlugin::ActionIDType DecoratePlugin::ID(QString name) const
{
QString n = name;
foreach(ActionIDType tt, types())
if (name == this->decorationName(tt)) return tt;
n.replace("&","");
foreach(ActionIDType tt, types())
if (n == this->decorationName(tt)) return tt;
foreach (ActionIDType tt, types())
if (name == this->decorationName(tt))
return tt;
n.replace("&", "");
foreach (ActionIDType tt, types())
if (n == this->decorationName(tt))
return tt;

qDebug("unable to find the id corresponding to action '%s'", qUtf8Printable(name));
assert(0);
Expand Down
126 changes: 76 additions & 50 deletions src/common/plugins/interfaces/decorate_plugin.h
Original file line number Diff line number Diff line change
@@ -1,33 +1,37 @@
/****************************************************************************
* 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. *
* *
****************************************************************************/
* 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_DECORATE_PLUGIN_H
#define MESHLAB_DECORATE_PLUGIN_H

#include "meshlab_plugin_logger.h"
#include "common/parameters/rich_parameter_list.h"
#include "meshlab_plugin.h"
#include "meshlab_plugin_logger.h"

class GLArea;
class QAction;
class QPainter;
class RichParameterList;

/**
* @class The DecoratePlugin is the base class of all <b> decorators </b>
Expand Down Expand Up @@ -56,17 +60,18 @@ class GLArea;
class DecoratePlugin : virtual public MeshLabPlugin, public MeshLabPluginLogger
{
public:

/** The DecorationClass enum represents the set of keywords that must be used to categorize a filter.
Each filter can belong to one or more filtering class, or-ed together.
/** The DecorationClass enum represents the set of keywords that must be used to categorize a
filter. Each filter can belong to one or more filtering class, or-ed together.
*/
enum DecorationClass
{
Generic = 0x00000, /*!< Should be avoided if possible. */ //
PerMesh = 0x00001, /*!< Decoration that are applied on a single mesh */
PerDocument = 0x00002, /*!< Decoration that are applied on a single mesh */
PreRendering = 0x00004, /*!< Decoration that are applied <i>before</i> the rendering of the document/mesh */
PostRendering = 0x00008 /*!< Decoration that are applied <i>after</i> the rendering of the document/mesh */
enum DecorationClass {
Generic = 0x00000,
/*!< Should be avoided if possible. */ //
PerMesh = 0x00001, /*!< Decoration that are applied on a single mesh */
PerDocument = 0x00002, /*!< Decoration that are applied on a single mesh */
PreRendering = 0x00004, /*!< Decoration that are applied <i>before</i> the rendering of the
document/mesh */
PostRendering = 0x00008 /*!< Decoration that are applied <i>after</i> the rendering of the
document/mesh */
};

DecoratePlugin() : MeshLabPluginLogger() {}
Expand All @@ -77,42 +82,63 @@ class DecoratePlugin : virtual public MeshLabPlugin, public MeshLabPluginLogger
virtual QString decorationName(ActionIDType) const = 0;
virtual QString decorationInfo(ActionIDType) const = 0;

virtual QString decorationName(const QAction *a) const { return decorationName(ID(a)); }
virtual QString decorationInfo(const QAction *a) const { return decorationInfo(ID(a)); }
virtual QString decorationName(const QAction* a) const { return decorationName(ID(a)); }
virtual QString decorationInfo(const QAction* a) const { return decorationInfo(ID(a)); }

// See source file for documentation
virtual void initGlobalParameterList(const QAction* format, RichParameterList& globalparam);

virtual bool startDecorate(const QAction *, MeshDocument &, const RichParameterList *, GLArea *) { return false; }
virtual bool startDecorate(const QAction *, MeshModel &, const RichParameterList *, GLArea *) { return false; }
virtual void decorateMesh(const QAction *, MeshModel &, const RichParameterList *, GLArea *, QPainter *, GLLogStream &) = 0;
virtual void decorateDoc(const QAction *, MeshDocument &, const RichParameterList *, GLArea *, QPainter *, GLLogStream &) = 0;
virtual void endDecorate(const QAction *, MeshModel &, const RichParameterList *, GLArea *) {}
virtual void endDecorate(const QAction *, MeshDocument &, const RichParameterList *, GLArea *) {}
virtual bool startDecorate(const QAction*, MeshDocument&, const RichParameterList*, GLArea*)
{
return false;
}
virtual bool startDecorate(const QAction*, MeshModel&, const RichParameterList*, GLArea*)
{
return false;
}
virtual void decorateMesh(
const QAction*,
MeshModel&,
const RichParameterList*,
GLArea*,
QPainter*,
GLLogStream&) = 0;
virtual void decorateDoc(
const QAction*,
MeshDocument&,
const RichParameterList*,
GLArea*,
QPainter*,
GLLogStream&) = 0;
virtual void endDecorate(const QAction*, MeshModel&, const RichParameterList*, GLArea*) {}
virtual void endDecorate(const QAction*, MeshDocument&, const RichParameterList*, GLArea*) {}

/** \brief tests if a decoration is applicable to a mesh.
* used only for PerMesh Decorators.
For instance curvature cannot be shown on a mesh without curvature.
On failure (returning false) the function fills the MissingItems list with strings describing the missing items.
It is invoked only for decoration of \i PerMesh class;
On failure (returning false) the function fills the MissingItems list with strings describing
the missing items. It is invoked only for decoration of \i PerMesh class;
*/
virtual bool isDecorationApplicable(const QAction *, const MeshModel&, QString&) const { return true; }
virtual bool isDecorationApplicable(const QAction*, const MeshModel&, QString&) const
{
return true;
}

virtual int getDecorationClass(const QAction *) const = 0;
virtual int getDecorationClass(const QAction*) const = 0;

virtual QList<QAction *> actions() const { return actionList; }
virtual QList<QAction*> actions() const { return actionList; }
virtual QList<ActionIDType> types() const { return typeList; }

virtual QAction *action(QString name) const;
virtual QAction* action(QString name) const;

protected:
QList <QAction *> actionList;
QList <ActionIDType> typeList;
virtual ActionIDType ID(const QAction *a) const;
QList<QAction*> actionList;
QList<ActionIDType> typeList;
virtual ActionIDType ID(const QAction* a) const;
virtual ActionIDType ID(QString name) const;
};

#define DECORATE_PLUGIN_IID "vcg.meshlab.DecoratePlugin/1.0"
#define DECORATE_PLUGIN_IID "vcg.meshlab.DecoratePlugin/1.0"
Q_DECLARE_INTERFACE(DecoratePlugin, DECORATE_PLUGIN_IID)

#endif // MESHLAB_DECORATE_PLUGIN_H
Loading

0 comments on commit 22e70d7

Please sign in to comment.