1 /***************************************************************************
3 * Copyright 2010,2011 BMW Car IT GmbH
6 * Licensed under the Apache License, Version 2.0 (the "License");
7 * you may not use this file except in compliance with the License.
8 * You may obtain a copy of the License at
10 * http://www.apache.org/licenses/LICENSE-2.0
12 * Unless required by applicable law or agreed to in writing, software
13 * distributed under the License is distributed on an "AS IS" BASIS,
14 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 * See the License for the specific language governing permissions and
16 * limitations under the License.
18 ****************************************************************************/
19 #include "LayerSetRenderOrderCommand.h"
20 #include "ICommandExecutor.h"
24 LayerSetRenderOrderCommand::~LayerSetRenderOrderCommand()
29 ExecutionResult LayerSetRenderOrderCommand::execute(ICommandExecutor* executor)
31 Scene& scene = *(executor->getScene());
33 ExecutionResult result = ExecutionFailed;
35 Layer* layer = scene.getLayer(m_layerid);
39 result = layer->removeAllSurfaces() ? ExecutionSuccessRedraw : ExecutionSuccess;
41 for (unsigned int surfaceIndex = 0; surfaceIndex < m_length; ++surfaceIndex)
43 Surface* surface = scene.getSurface(m_array[surfaceIndex]);
47 unsigned int layer_id = surface->getContainingLayerId();
48 if (layer->addSurface(surface))
50 LOG_DEBUG("LayerSetRenderOrderCommand","Adding surface " << surface->getID() << " to renderorder of layer " << m_layerid);
51 result = ExecutionSuccessRedraw;
55 LOG_WARNING("LayerSetRenderOrderCommand","surface : id [ " << m_array[surfaceIndex] << " ] already belongs to layer : id [ " << layer_id << " ]");
64 const std::string LayerSetRenderOrderCommand::getString()
66 std::stringstream description;
67 description << "LayerSetRenderOrderCommand("
68 << "layerid=" << m_layerid << "(0x" << std::hex << m_layerid << ")" << std::dec
71 for (unsigned int i = 0; i < m_length; ++i)
73 description << m_array[i] << ",";
75 description << "], m_length=" << m_length
77 return description.str();