/***************************************************************************
* Copyright (C) 2004 by Raphael Langerhorst *
* raphael-langerhorst@gmx.at *
* *
* Permission is hereby granted, free of charge, to any person obtaining *
* a copy of this software and associated documentation files (the *
* "Software"), to deal in the Software without restriction, including *
* without limitation the rights to use, copy, modify, merge, publish, *
* distribute, sublicense, and/or sell copies of the Software, and to *
* permit persons to whom the Software is furnished to do so, subject to *
* the following conditions: *
* *
* The above copyright notice and this permission notice shall be *
* included in all copies or substantial portions of the Software. *
* *
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, *
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF *
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*
* IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR *
* OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, *
* ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR *
* OTHER DEALINGS IN THE SOFTWARE. *
***************************************************************************/
#ifndef GBEGENERGYFORMAGENT_H
#define GBEGENERGYFORMAGENT_H
#include <GAgent.h>
#include <GVector3.h>
namespace GBE
{
/**
\class GEnergyFormAgent GEnergyFormAgent.h
\brief Modifies the form according to the energy attributes.
@author Raphael Langerhorst
The form of the element is modified according to energy. The
energy level is represented by form colour, the energy amount
is represented by form radius.
The colour ranges from dark blue to yellow-white between
LevelRangeMin and LevelRangeMax.
The sizefactor is directly reflected in the form's ellipsoid
attribute.
Adds the following xml data to the element data:
<appearance>
<energyrange>
<minlevel>double value</minlevel>
<maxlevel>double value</maxlevel>
</energyrange>
<colour> <!-- periodically updated in the run() method of the agent -->
<enabled>bool</enabled> <!-- if false then the whole colour tag can be ignored -->
<r>double value</r>
<g>double value</g>
<b>double value</b>
<a>double value</a> <!-- not updated, but set with initAlpha() -->
</colour>
</appearance>
<form>
<sizefactor>
<enabled>bool</enabled> <!-- if false then the whole form sizefactor can be ignored -->
<x>double value</x>
<y>double value</y>
<z>double value</z>
</sizefactor>
</form>
*/
class GEnergyFormAgent : public GCS::GAgent
{
Q_OBJECT
public:
/**
* Constructor.
*/
GEnergyFormAgent();
/**
* Destructor.
*/
virtual ~GEnergyFormAgent();
protected:
/**
* Periodically updates the form of the element according to
* the current energy.
*/
virtual void run();
public:
/**
* Initializes energy range max in the element data.
*
* The maximum energy level is used to determine where the appearance
* should be light.
*/
void initRangeMin(double energy_level_min);
/**
* Initializes energy range min in the element data.
* The minimum energy level is used to determine where the appearance
* should be dark.
*/
void initRangeMax(double energy_level_max);
/**
* Initializes alpha colour value in the element data.
*
* The alpha component of the colour is not updated by the agent,
* it can be set here and won't be changed afterwards.
*/
void initAlpha(double alpha_colour_component);
/**
* Initializes size factor in the element data.
*
* The radius of the form is determined by the energy amount multiplied
* with given factors.
*/
void initSizeFactor(const GCS::GVector3& size_factor);
/**
* Enables or disables colour updating based on energy level.
* Enabled by default.
*/
void initColourEnabled(bool enabled);
/**
* Enables or disables form size updating based on energy amount.
* Enabled by default.
*/
void initSizeFactorEnabled(bool enabled);
};
};
#endif
syntax highlighted by Code2HTML, v. 0.9.1