Commit 15c53a0e authored by Sebastian Eichelbaum's avatar Sebastian Eichelbaum

[CHANGE] added some META file doc to the template module

parent 1eec4fd2
......@@ -261,3 +261,12 @@ std::vector< WModuleMetaInformation::Screenshot > WModuleMetaInformation::getScr
return r;
}
bool WModuleMetaInformation::valueExists( std::string path ) const
{
if( !m_loaded )
{
return false;
}
return m_metaData.exists( path, true );
}
......@@ -209,6 +209,57 @@ public:
* \return the screenshot list.
*/
std::vector< Screenshot > getScreenshots() const;
/**
* Query a value from the META file.
*
* \tparam ResultType the type of the result of the query. The function tries to cast the found value to this type. If this is not possible,
* the default value will be returned.
* \param path the absolute path in the META file. Please be aware that, if you specify a value inside your modules meta block, you need to
* add the module name too. The path is absolute!
* \param defaultValue the default value to return in case of an non-existing element or cast problems.
*
* \throw WTypeMismatch if the value cannot be cast to the specified target type
*
* \return the value, or defaultType.
*/
template< typename ResultType >
ResultType query( std::string path, ResultType defaultValue = ResultType() ) const
{
// find key-value pair
return m_metaData.getValue< ResultType >( path, defaultValue );
}
/**
* Query multiple values from the META file.
*
* \tparam ResultType the type of the result of the query. The function tries to cast the found value to this type. If this is not possible,
* the default value will be returned.
* \param path the absolute path in the META file. Please be aware that, if you specify a value inside your modules meta block, you need to
* add the module name too. The path is absolute!
* \param defaultValue the default value to return in case of an non-existing element or cast problems.
*
* \throw WTypeMismatch if the value cannot be cast to the specified target type
*
* \return the value vector, or defaultType.
*/
template< typename ResultType >
std::vector< ResultType > query( std::string path, const std::vector< ResultType >& defaultValues ) const
{
// find key-value pair
return m_metaData.getValues< ResultType >( path, defaultValues );
}
/**
* Check whether the value specified by "path" exists.
*
* \param path the absolute path in the META file. Please be aware that, if you specify a value inside your modules meta block, you need to
* add the module name too. The path is absolute!
*
* \return true if it exists.
*/
bool valueExists( std::string path ) const;
protected:
private:
/**
......
//---------------------------------------------------------------------------
//
// Project: OpenWalnut ( http://www.openwalnut.org )
//
// Copyright 2009 OpenWalnut Community, BSV@Uni-Leipzig and CNCF@MPI-CBS
// For more information see http://www.openwalnut.org/copying
//
// This file is part of OpenWalnut.
//
// OpenWalnut is free software: you can redistribute it and/or modify
// it under the terms of the GNU Lesser General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// OpenWalnut 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 Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public License
// along with OpenWalnut. If not, see <http://www.gnu.org/licenses/>.
//
//---------------------------------------------------------------------------
#ifndef WCUSTOMWIDGET_H
#define WCUSTOMWIDGET_H
#include "core/common/WDefines.h"
#include "WUIViewWidget.h"
// The former WCustomWidget is now called WUIViewWidget as it provides a view and is not a generic widget.
typedef WUIViewWidget WCustomWidget OW_API_DEPRECATED;
#endif // WCUSTOMWIDGET_H
......@@ -81,7 +81,6 @@ public:
* \return the factory. Use this to create your widget instances.
*/
virtual WUIWidgetFactory::SPtr getWidgetFactory() const = 0;
protected:
/**
* Flag determining whether the UI is properly initialized.
......
......@@ -68,7 +68,7 @@
};
// Provide some tags to have modules nicely grouped and ordered.
// NOTE: tags are handled case insesitive.
// NOTE: tags are handled case insensitive.
// IMPORTANT: the order of appearance will be used by OW to classify your tags
tag = "Navigation";
tag = "MRT";
......@@ -94,7 +94,7 @@
online
{
name="Video Demonstration";
description="Video demonstration showing basic working principoles.";
description="Video demonstration showing basic working principles.";
url="http://www.youtube.com/watch?v=5Afw6P6wWSU&context=C375513dADOEgsToPDskJXOVbrVDAV5rydr7H173AT";
};
......
This is your entry point into OpenWalnut module development!
1. General:
***********
This directory contains a bunch of modules that demonstrate how to develop with/for
OpenWalnut. Get started with WToolkit. This file contains definitions for all the modules
that are required by OpenWalnut during load of your module. Each module listed there can
......@@ -13,5 +16,6 @@ mailing list openwalnut-dev@lists.informatik.uni-leipzig.de.
Now, directly dive into the code. You will see, getting started with OpenWalnut module
development is easy!
Enjoy,
the OpenWalnut Team
2. Files:
*********
......@@ -750,6 +750,14 @@ void WMTemplate::moduleMain()
// Remove the geometry from the scene. If it has never been added, this call does nothing. Always remember to remove your rendering at the
// end of the module loop.
WKernel::getRunningKernel()->getGraphicsEngine()->getScene()->remove( m_rootNode );
// Let us utilize the META file in the resources directory. This file contains several information about a module and
// can also contain custom values. Here, we query the "goodbye" value:
std::string bye = getMetaInformation()->query< std::string >(
"common/goodbye", // the absolute path
"have a nice day" // a default if the element does not exist or cannot be returned as std::string.
);
infoLog() << bye;
}
void WMTemplate::SafeUpdateCallback::operator()( osg::Node* node, osg::NodeVisitor* nv )
......
......@@ -23,10 +23,81 @@
//---------------------------------------------------------------------------
// Provide additional material and descriptions for your module. You can
// provide this for multiple modules if you like.
// provide this for multiple modules if you like.
// The purpose of this file is to allow the developer to provide additional
// material for his module, like documentation links, video tutorials and
// similar. You should always write such a META file for your module, even
// if you do not provide additional material (for now at least).
// NOTE: everything but the module name is optional, even if this makes no
// sense at all.
///////////////////////////////////////////////////////////////////////////////
// SYNTAX
// The syntax is quite simple for those who know C/C++. There are basically
// two things to know: values, blocks and comments
// 1.) values are simple name-value-pairs. Use the syntax:
// valueName = "value value value";
// Note that the value of a variable needs to be embedded into "" and
// must be terminated with ;
//
// 2.) blocks can be seen as a named group of values or blocks. Use the
// syntax:
// "block name with space and stuff"
// {
// values ...
// block ...
// };
// A block is a name (use "" if it contains spaces) and a bunch of
// nested values or blocks. They are embedded in pairs of {} and a
// block is terminated by ;
//
// 3.) Comments ... well as you can see they start with //. Everything after
// // will be ignored
///////////////////////////////////////////////////////////////////////////////
// SEMANTICS and USAGE
// OpenWalnut defines some values and blocks for certain information which can
// will be used by the UI. But you can define your own too! This is very handy
// if you write your toolboxes and want to avoid hard-coding several values.
//
//
// 1.) The predefined blocks and values are shown below. At this point, let us
// have a look on how to query your own values:
//
// Assume you have a block:
// "Some Jokes"
// {
// "For Scientists"
// {
// joke="An electron and a positron walked into a bar ...";
// }; // <- do not miss the ;
// }; // <- do not miss the ;
//
// To query the value of "joke" in your module:
//
// std::string scienceJoke = getMetaInformation()->query< std::string >(
// "Some Jokes/For Scientists/joke", // the absolute path
// "not so funny default joke" // a default if the element does
// // not exist or cannot be returned
// // as std::string.
// );
//
// Thats it. The function getMetaInformation() is a member of WModule,
// thus you always have it available (but not in the constructor). The
// remaining part of the code is quite self-explaining. You define a
// return type and path. The return type tells the system that you expect
// an std::string at this position. The function tries to cast the found
// value to this type. The path is an absolute path. Very handy to define
// a "common" block in your META file to share information amongst multiple
// modules. (see below)
//
// 2.) The predefined values and blocks are shown below. The UI interprets them
// and displays it where appropriate. The Qt4 GUI for example show an
// "About & Help" tab for each module.
//
// NOTE: everything but the module name is optional, even if this makes no
// sense at all.
// This defines some properties of the module "Template". This must
// match the name specified in WMTemplate::getName().
......@@ -34,7 +105,7 @@
{
// Provide an icon. If the icon exists, it overrides the one provided by your
// getXPMIcon method. This path is relative to your module's resource directory.
icon="WMTemplate.xpm";
icon="WMTemplateIcon.png";
// Where to find the module?
website = "http://www.openwalnut.org";
......@@ -43,34 +114,36 @@
// provided by your getDescription method.
// HINT: multi-line strings are not supported. Please provide long texts in
// one line.
description = "This module is intended to be THE reference module. If you would like to program your own modules, you should look at this module's source.";
// Help file. This should be an HTML or TXT document. Only one document allowed.
help ="help/index.html";
description = "Demonstrative module which tries to show the code features in OW and their usage.";
// Provide a list of authors. These authors can have further information associated with them.
// Provide a list of authors. These authors can have further information associated with them. First,
// define the list of authors
author = "OpenWalnut Project";
author = "Students";
// Provide author information. Especially a contact address is very handy.
// This associates some URL and Mail contact info to "OpenWalnut Project".
// To provide further details on one or multiple authors, just open a new block called like
// the author.
//
// * all sub-values are optional
// * Especially a contact address is very handy.
// * This associates some URL and Mail contact info to "OpenWalnut Project".
"OpenWalnut Project"
{
url="http://www.openwalnut.org";
email="contact@openwalnut.org";
what="Design, Development and Bug fixing";
};
// These additional author information are optional.
Students
"Students"
{
what="Bug fixing";
};
}
// Provide some tags to have modules nicely grouped and ordered.
// NOTE: tags are handled case insesitive.
// NOTE: tags are handled case insensitive.
// IMPORTANT: the order of appearance will be used by OW to classify your tags
tag = "MRI";
tag = "fMRI";
tag = "Tutorial";
tag = "Scalar";
// You can provide online resources. They are shown in the GUI. You should
// additionally provide a description to help the user know what this is.
......@@ -100,8 +173,20 @@
// You can also provide screenshots with an optional description. Multiple screenshots allowed.
screenshot
{
description = "The rendering created by this module. It demonstrates simple OpenSceneGraph usage.";
filename = "template.png";
description = "Some red primitives";
filename = "templateScreenshot1.png";
};
screenshot
{
description = "The whole GUI";
filename = "templateScreenshot2.png";
};
};
// A block for sharing values amongst all template modules
"common"
{
// how to say goodbye ...
goodbye = "Auf Wiedersehen!"; // hey
}; // hgeee
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment