Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add render event #70

Merged
merged 4 commits into from
Jun 8, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@ -35,7 +35,11 @@

#include <ignition/transport/Node.hh>

#include "ignition/gui/Application.hh"
#include "ignition/gui/Conversions.hh"
#include "ignition/gui/GuiEvents.hh"
Sarath18 marked this conversation as resolved.
Show resolved Hide resolved
#include "ignition/gui/MainWindow.hh"

#include "Scene3D.hh"

namespace ignition
Expand Down Expand Up @@ -832,6 +836,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