77 std::pair<std::map<Color, Color>::iterator,
bool> inserter =
m_colorMap.insert(std::make_pair(source, target));
78 if (!inserter.second) {
79 Color& c = inserter.first->second;
103 throw Duplicate(
"Object already contains visualization");
106 object->adoptVisual(v);
114 m_angle2img[angle % 360] = image_index;
118 int32_t closestMatch = 0;
124 m_map[angle % 360] = angle % 360;
125 std::pair<AngleColorOverlayMap::iterator, bool> inserter = m_colorOverlayMap.insert(std::make_pair(angle % 360, colors));
126 if (!inserter.second) {
131 const std::map<Color, Color>& colorMap = tmp.
getColors();
132 std::map<Color, Color>::const_iterator it = colorMap.begin();
133 for (; it != colorMap.end(); ++it) {
140 if (m_colorOverlayMap.empty()) {
143 int32_t closestMatch = 0;
144 return &m_colorOverlayMap[
getIndexByAngle(angle, m_map, closestMatch)];
148 if (m_colorOverlayMap.empty()) {
151 int32_t closestMatch = 0;
153 m_colorOverlayMap.erase(index);
158 int32_t closestMatch = 0;
165 type_angle2id::const_iterator i(m_angle2img.begin());
166 while (i != m_angle2img.end()) {
167 angles.push_back(i->first);
181 throw Duplicate(
"Instance already contains visualization");
230 throw Duplicate(
"Action already contains visualization");
242 m_map[angle % 360] = angle % 360;
246 int32_t closestMatch = 0;
252 m_map[angle % 360] = angle % 360;
253 orderMap.insert(std::pair<int32_t, AnimationPtr>(order, animationptr));
257 int32_t closestMatch = 0;
265 int32_t closestMatch = 0;
268 it->second.erase(order);
269 if (it->second.empty()) {
276 m_map[angle % 360] = angle % 360;
277 std::pair<AngleColorOverlayMap::iterator, bool> inserter =
m_colorOverlayMap.insert(std::make_pair(angle % 360, colors));
278 if (!inserter.second) {
283 const std::map<Color, Color>& colorMap = tmp.
getColors();
284 std::map<Color, Color>::const_iterator it = colorMap.begin();
285 for (; it != colorMap.end(); ++it) {
295 int32_t closestMatch = 0;
307 int32_t closestMatch = 0;
314 m_map[angle % 360] = angle % 360;
315 std::pair<std::map<int32_t, OverlayColors>::iterator,
bool> inserter = orderMap.insert(std::make_pair(order, colors));
316 if (!inserter.second) {
321 const std::map<Color, Color>& colorMap = tmp.
getColors();
322 std::map<Color, Color>::const_iterator it = colorMap.begin();
323 for (; it != colorMap.end(); ++it) {
334 int32_t closestMatch = 0;
337 std::map<int32_t, OverlayColors>::iterator sit = it->second.find(order);
338 if (sit != it->second.end()) {
339 return &it->second[order];
350 int32_t closestMatch = 0;
353 it->second.erase(order);
354 if (it->second.empty()) {
362 type_angle2id::const_iterator i(
m_map.begin());
363 while (i !=
m_map.end()) {
364 angles.push_back(i->first);
371 type_angle2id::const_iterator it =
m_map.begin();
372 for (; it !=
m_map.end(); ++it) {
static InstanceVisual * create(Instance *instance)
Constructs and assigns it to the passed item.
void callOnVisibleChange()
void setColorOverlayAnimation(AnimationPtr animation)
ObjectVisual()
Constructor.
AngleAnimationMap m_animation_map
int32_t getClosestMatchingAngle(int32_t angle)
Returns closest matching image angle for given angle.
AngleColorAnimationOverlayMap m_colorAnimationOverlayMap
int32_t getStackPosition()
Gets current stack position of instance.
std::map< Color, Color > m_colorMap
Visual2DGfx()
Constructor.
Instance visual contains data that is needed to visualize the instance on screen. ...
void convertToOverlays(bool color)
Convertes animations and optional color overlay to default animation overlay.
ActionVisual()
Constructor.
Action visual contains data that is needed to visualize different actions on screen.
virtual ~Visual2DGfx()
Destructor.
static ActionVisual * create(Action *action)
Constructs and assigns it to the passed item.
void removeAnimationOverlay(uint32_t angle, int32_t order)
Removes animation overlay with given angle (degrees) and order.
static Logger _log(LM_AUDIO)
void setVisual(IVisual *visual)
Sets visualization to be used.
void removeStaticColorOverlay(int32_t angle)
Removes a static color overlay with given angle (degrees).
void setTransparency(uint8_t transparency)
Sets transparency value for object to be visualized.
void callOnTransparencyChange()
OverlayColors * getStaticColorOverlay(int32_t angle)
Returns closest matching static color overlay for given angle.
void set(uint8_t r, uint8_t g, uint8_t b, uint8_t alpha)
Set all color channel values.
OverlayColors * getColorOverlay(int32_t angle)
Gets OverlayColors for given angle (degrees).
int32_t getStaticImageIndexByAngle(int32_t angle)
Returns closest matching static image for given angle.
AngleColorOverlayMap m_colorOverlayMap
bool isVisible()
Is instance visible or not.
void changeColor(const Color &source, const Color &target)
void removeColorOverlay(int32_t angle)
Removes color overlay with given angle (degrees).
AngleAnimationOverlayMap m_animationOverlayMap
void setColorOverlayImage(ImagePtr image)
void setVisible(bool visible)
Sets visibility value for object to be visualized.
void getActionImageAngles(std::vector< int32_t > &angles)
Returns list of available angles for this Action.
void addColorOverlay(uint32_t angle, const OverlayColors &colors)
Adds new color overlay with given angle (degrees) and colors.
void callOnStackPositionChange()
void addAnimationOverlay(uint32_t angle, int32_t order, AnimationPtr animationptr)
Adds new animation overlay with given angle (degrees) and order.
void getStaticImageAngles(std::vector< int32_t > &angles)
Returns list of available static image angles for this object.
const std::map< Color, Color > & getColors()
void addAnimation(uint32_t angle, AnimationPtr animationptr)
Adds new animation with given angle (degrees)
void addStaticColorOverlay(uint32_t angle, const OverlayColors &colors)
Adds new static color overlay with given angle (degrees).
ImagePtr getColorOverlayImage()
virtual ~ActionVisual()
Destructor.
InstanceVisual()
Constructor.
Object visual contains data that is needed for visualizing objects.
static ObjectVisual * create(Object *object)
Constructs and assigns it to the passed item.
void addStaticImage(uint32_t angle, int32_t image_index)
Adds new static image with given angle (degrees) Static images are used in case there are no actions ...
AnimationPtr getAnimationByAngle(int32_t angle)
Gets index to animation closest to given angle.
uint8_t getTransparency()
Gets current transparency value (0-255)
void setStackPosition(int32_t stackposition)
Sets stack position of the instance Stack position is used to define the order in which instances res...
int32_t getIndexByAngle(int32_t angle, const type_angle2id &angle2id, int32_t &closestMatchingAngle)
Returns id for given angle from angle2id map in case there are no elements in the map...
virtual ~ObjectVisual()
Destructor.
T * getVisual() const
Gets used visualization.
virtual ~InstanceVisual()
Destructor.
AnimationPtr getColorOverlayAnimation()
OverlayColors()
Constructors.
T * getVisual() const
Gets used visualization.
T * getVisual() const
Gets used visualization.
~OverlayColors()
Destructor.
An Instance is an "instantiation" of an Object at a Location.
std::map< int32_t, AnimationPtr > getAnimationOverlay(int32_t angle)
Gets map with animations closest to given angle.
void adoptVisual(IVisual *visual)
Sets visualization to be used.