Skip to content

Commit

Permalink
Add render event (#70)
Browse files Browse the repository at this point in the history
Signed-off-by: Sarathkrishnan Ramesh <sarathkrishnan99@gmail.com>
Co-authored-by: Louise Poubel <louise@openrobotics.org>
  • Loading branch information
Sarath18 and chapulina committed Aug 31, 2020
1 parent bde7242 commit 4306ced
Show file tree
Hide file tree
Showing 2 changed files with 61 additions and 0 deletions.
50 changes: 50 additions & 0 deletions include/ignition/gui/GuiEvents.hh
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
/*
* Copyright (C) 2020 Open Source Robotics Foundation
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/
#ifndef IGNITION_GUI_GUIEVENTS_HH_
#define IGNITION_GUI_GUIEVENTS_HH_

#include <QEvent>
#include <utility>
#include <vector>
#include <ignition/math/Vector3.hh>

namespace ignition
{
namespace gui
{
/// \brief Namespace for all events.
namespace events
{
/// User defined events should start from QEvent::MaxUser and
/// count down to avoid collision with ign-gazebo events

/// \brief Event called in the render thread of a 3D scene.
/// It's safe to make rendering calls in this event's callback.
class Render : public QEvent
{
public: Render()
: QEvent(kType)
{
}
/// \brief Unique type for this event.
static const QEvent::Type kType = QEvent::Type(QEvent::MaxUser);
};
}
}
}

#endif // IGNITION_GUI_GUIEVENTS_HH_
11 changes: 11 additions & 0 deletions src/plugins/scene3d/Scene3D.cc
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,11 @@

#include <ignition/transport/Node.hh>

#include "ignition/gui/Application.hh"
#include "ignition/gui/Conversions.hh"
#include "ignition/gui/GuiEvents.hh"
#include "ignition/gui/MainWindow.hh"

#include "Scene3D.hh"

namespace ignition
Expand Down Expand Up @@ -846,6 +850,13 @@ void IgnRenderer::Render()

// update and render to texture
this->dataPtr->camera->Update();

if (ignition::gui::App())
{
ignition::gui::App()->sendEvent(
ignition::gui::App()->findChild<ignition::gui::MainWindow *>(),
new gui::events::Render());
}
}

/////////////////////////////////////////////////
Expand Down

0 comments on commit 4306ced

Please sign in to comment.