Commit c088b524 authored by Jan Möbius's avatar Jan Möbius
Browse files

Datacontrol function to get object datatype and stringlist of all available...

Datacontrol function to get object datatype and stringlist of all available datatypes. Started scripting documentation. refs #394 

git-svn-id: http://www.openflipper.org/svnrepo/OpenFlipper/branches/Free@13556 383ad7c9-94d9-4d36-a494-682f7c89f535
parent 75fe73f2
......@@ -21,6 +21,7 @@
* - \subpage dataFlow "Dataflow"
* - \subpage options "Command line options and config files"
* - \subpage datatypes "Integrated Datatypes"
* - \subpage scripting
*
* \subpage misc
* - \ref changelog
......
/*!
\page scripting OpenFlipper Scripting
TODO: OpenFlipper Scripting and examples.
\section scripting_datattypes DataTypes
In the scripting system the type DataType is already known. You can do for example
\code
DataType("TriangleMesh");
\endcode
You can get a string list with all available data types via
\code
// Get the string list of data types via DataControl Plugin
var types = datacontrol.availableDataTypeNames();
\endcode
\subsection scripting_datattypes_getting_type Getting the DataType of an Object
\code
// Set the object id
var object = 5;
// Get the DataTypes and print its name
print(datacontrol.dataType(object))
\endcode
\section scripting_examples Scripting Examples
\subsection scripting_examples_qstringlist Iterating over a QStringList
\code
// Get the string list of data types via DataControl Plugin
var types = datacontrol.availableDataTypeNames();
// Iterate over the list and print to the console
for ( i = 0 ; i < types.length ; ++i ) {
print(types[i]);
}
\endcode
*/
......@@ -236,11 +236,11 @@ uint typeCount();
* @{ */
//================================================================================================
/// Get iterator pointing to the first element in the tyoes list
/// Get iterator pointing to the first element in the types list
DLLEXPORT
std::vector< TypeInfo >::const_iterator typesBegin();
/// Get iterator pointing to the last element in the tyoes list
/// Get iterator pointing to the last element in the types list
DLLEXPORT
std::vector< TypeInfo >::const_iterator typesEnd();
......@@ -251,11 +251,11 @@ std::vector< TypeInfo >::const_iterator typesEnd();
* @{ */
//================================================================================================
/// Get DataType Human readable name ( this name might change. Use the typeName insted! )
/// Get DataType Human readable name ( this name might change. Use the typeName instead! )
DLLEXPORT
QString dataTypeName( DataType _id );
/// Get DataType Human readable name ( this name might change. Use the typeName insted! )
/// Get DataType Human readable name ( this name might change. Use the typeName instead! )
DLLEXPORT
QString dataTypeName( QString _typeName);
......@@ -283,7 +283,7 @@ QString typeIconName(QString _name);
DLLEXPORT
QString typeIconName(DataType _id);
/** \brief Get an QIcon associated with the given datatype
/** \brief Get an QIcon associated with the given DataType
*
* The icons are loaded once when set and then the reference is returned here.
* This reduces the time when frequently requesting the icons (e.g. DataControl)
......
......@@ -313,6 +313,9 @@ class DataControlPlugin : public QObject, BaseInterface, ToolboxInterface, KeyIn
/// Get the id of an object by its name
int getObject( QString _name );
/// Get the DataType of a given object
DataType dataType( int objectId );
/// Hide the given Object
void hideObject( int objectId );
......@@ -367,6 +370,9 @@ class DataControlPlugin : public QObject, BaseInterface, ToolboxInterface, KeyIn
/// Returns the number of groups
unsigned int groupCount() const;
/// Returns a list of all available DataTypes
QStringList availableDataTypeNames() const;
/// Print information about all open objects to the console
void printObjectInfoToLog();
......
......@@ -58,6 +58,9 @@ void DataControlPlugin::setDescriptions(){
emit setSlotDescription("getObjectName(int)",tr("Returns the name of an object with given id."),
QStringList(tr("objectId")), QStringList(tr("ID of an object")));
emit setSlotDescription("dataType(int)",tr("Returns the DataType of the object with the given id."),
QStringList(tr("objectId")), QStringList(tr("ID of an object")));
emit setSlotDescription("hideObject(int)",tr("Hide object with the given id."),
QStringList(tr("objectId")), QStringList(tr("ID of an object")));
......@@ -113,6 +116,9 @@ void DataControlPlugin::setDescriptions(){
emit setSlotDescription("hideAll()",tr("Hide all objects"),
QStringList(), QStringList());
emit setSlotDescription("availableDataTypeNames()",tr("Returns a QStringList of all available DataType names."),
QStringList(tr("")), QStringList(tr("")));
emit setSlotDescription("printObjectInfoToLog()",tr("Print info about all objects to log"),
QStringList(), QStringList());
......@@ -172,6 +178,19 @@ QString DataControlPlugin::getObjectName( int objectId ) {
}
//******************************************************************************
/// Get the DataType of a given object
DataType DataControlPlugin::dataType( int _objectId ) {
BaseObject* object = 0;
PluginFunctions::getObject(_objectId,object);
if ( object )
return object->dataType();
else
return DATA_UNKNOWN;
}
//******************************************************************************
......@@ -548,3 +567,21 @@ unsigned int DataControlPlugin::groupCount() const {
}
//******************************************************************************
/** \brief Return available dataType
*
* Returns a space separated list of all available DataTypes
*
* @return List of available data types
*/
QStringList DataControlPlugin::availableDataTypeNames() const {
QStringList list;
for ( std::vector< TypeInfo >::const_iterator dataType = typesBegin(); dataType != typesEnd(); ++dataType )
list.push_back(dataType->name);
return list;
}
//******************************************************************************
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