Skip to content

Commit

Permalink
Merge 3afef9a into e647570
Browse files Browse the repository at this point in the history
  • Loading branch information
adlarkin committed Feb 10, 2021
2 parents e647570 + 3afef9a commit 302f5ed
Show file tree
Hide file tree
Showing 6 changed files with 170 additions and 3 deletions.
7 changes: 4 additions & 3 deletions examples/worlds/joint_position_controller.sdf
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@
Try sending joint position commands:
ign topic -t "/model/joint_position_controller_demo/joint/j1/0/cmd_pos" -m ignition.msgs.Double -p "data: -1.0"
ign topic -t "/rotor_cmd" -m ignition.msgs.Double -p "data: -1.0"
ign topic -t "/model/joint_position_controller_demo/joint/j1/0/cmd_pos" -m ignition.msgs.Double -p "data: 1.0"
ign topic -t "/rotor_cmd" -m ignition.msgs.Double -p "data: 1.0"
-->
<sdf version="1.6">
<world name="default">
Expand Down Expand Up @@ -45,7 +45,7 @@
<property type="double" key="height">72</property>
<property type="double" key="width">121</property>
<property type="double" key="z">1</property>

<property type="string" key="state">floating</property>
<anchors target="3D View">
<line own="left" target="left"/>
Expand Down Expand Up @@ -156,6 +156,7 @@
filename="ignition-gazebo-joint-position-controller-system"
name="ignition::gazebo::systems::JointPositionController">
<joint_name>j1</joint_name>
<topic>rotor_cmd</topic>
<p_gain>1</p_gain>
<i_gain>0.1</i_gain>
<d_gain>0.01</d_gain>
Expand Down
67 changes: 67 additions & 0 deletions src/gui/AboutDialogHandler.cc
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
/*
* Copyright (C) 2021 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.
*
*/

#include "AboutDialogHandler.hh"

#include <ignition/common/Console.hh>
#include <ignition/common/Profiler.hh>
#include <ignition/gui/Application.hh>

using namespace ignition;
using namespace gazebo;
using namespace gazebo::gui;

/////////////////////////////////////////////////
AboutDialogHandler::AboutDialogHandler()
{
aboutText += std::string(IGNITION_GAZEBO_VERSION_HEADER);
aboutText += "<table class='nostyle'>"
"<tr>"
"<td style='padding-right: 10px;'>Documentation:"
"</td>"
"<td>"
"<a href='https://ignitionrobotics.org/libs/gazebo' "
"style='text-decoration: none; color: #f58113'>"
"https://ignitionrobotics.org/libs/gazebo"
"</a>"
"</td>"
"</tr>"
"<tr>"
"<td style='padding-right: 10px;'>"
"Tutorials:"
"</td>"
"<td>"
"<a href='https://ignitionrobotics.org/docs/' "
"style='text-decoration: none; color: #f58113'>"
"https://ignitionrobotics.org/docs/"
"</a>"
"</td>"
"</tr>"
"</table>";
}

/////////////////////////////////////////////////
QString AboutDialogHandler::getVersionInformation()
{
return QString::fromStdString(this->aboutText);
}

/////////////////////////////////////////////////
void AboutDialogHandler::openURL(QString _url)
{
QDesktopServices::openUrl(QUrl(_url));
}
58 changes: 58 additions & 0 deletions src/gui/AboutDialogHandler.hh
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
/*
* Copyright (C) 2021 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_GAZEBO_GUI_ABOUTDIALOGHANDLER_HH_
#define IGNITION_GAZEBO_GUI_ABOUTDIALOGHANDLER_HH_

#include <QtCore>
#include <QDesktopServices>
#include <string>

#include "ignition/gazebo/EntityComponentManager.hh"
#include "ignition/gazebo/Export.hh"

namespace ignition
{
namespace gazebo
{
// Inline bracket to help doxygen filtering.
inline namespace IGNITION_GAZEBO_VERSION_NAMESPACE {
namespace gui
{
/// \brief Class for handling about dialog
class IGNITION_GAZEBO_VISIBLE AboutDialogHandler : public QObject
{
Q_OBJECT

/// \brief Constructor
public: AboutDialogHandler();

/// \brief Get version information
/// \return Version information in rich text format
Q_INVOKABLE QString getVersionInformation();

/// \brief Function called from QML when user clicks on a link
/// \param[in] _url Url to web page.
Q_INVOKABLE void openURL(QString _url);

/// \brief Version information and links to online resources
private: std::string aboutText;
};
}
}
}
}
#endif
1 change: 1 addition & 0 deletions src/gui/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
set (gui_sources
AboutDialogHandler.cc
Gui.cc
GuiFileHandler.cc
GuiRunner.cc
Expand Down
5 changes: 5 additions & 0 deletions src/gui/Gui.cc
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
#include "ignition/gazebo/gui/TmpIface.hh"

#include "ignition/gazebo/gui/Gui.hh"
#include "AboutDialogHandler.hh"
#include "GuiFileHandler.hh"
#include "PathManager.hh"

Expand Down Expand Up @@ -69,6 +70,9 @@ std::unique_ptr<ignition::gui::Application> createGui(
auto tmp = new ignition::gazebo::TmpIface();
tmp->setParent(app->Engine());

auto aboutDialogHandler = new ignition::gazebo::gui::AboutDialogHandler();
aboutDialogHandler->setParent(app->Engine());

auto guiFileHandler = new ignition::gazebo::gui::GuiFileHandler();
guiFileHandler->setParent(app->Engine());

Expand Down Expand Up @@ -108,6 +112,7 @@ std::unique_ptr<ignition::gui::Application> createGui(
// Let QML files use TmpIface' functions and properties
auto context = new QQmlContext(app->Engine()->rootContext());
context->setContextProperty("TmpIface", tmp);
context->setContextProperty("AboutDialogHandler", aboutDialogHandler);
context->setContextProperty("GuiFileHandler", guiFileHandler);

// Instantiate GazeboDrawer.qml file into a component
Expand Down
35 changes: 35 additions & 0 deletions src/gui/resources/GazeboDrawer.qml
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,9 @@ Rectangle {
case "loadWorld":
loadWorldDialog.open();
break
case "aboutDialog":
aboutDialog.open();
break
// Forward others to default drawer
default:
parent.onAction(_action);
Expand Down Expand Up @@ -110,6 +113,10 @@ Rectangle {
title: "Style settings"
actionElement: "styleSettings"
}
ListElement {
title: "About"
actionElement: "aboutDialog"
}
ListElement {
title: "Quit"
actionElement: "close"
Expand Down Expand Up @@ -165,6 +172,34 @@ Rectangle {
}
}

/**
* About dialog
*/
Dialog {
id: aboutDialog
title: "Ignition Gazebo"

modal: true
focus: true
parent: ApplicationWindow.overlay
width: parent.width / 3 > 500 ? 500 : parent.width / 3
x: (parent.width - width) / 2
y: (parent.height - height) / 2
closePolicy: Popup.CloseOnEscape
standardButtons: StandardButton.Ok

Text {
anchors.fill: parent
id: aboutMessage
wrapMode: Text.Wrap
verticalAlignment: Text.AlignVCenter
color: Material.theme == Material.Light ? "black" : "white"
textFormat: Text.RichText
text: AboutDialogHandler.getVersionInformation()
onLinkActivated: AboutDialogHandler.openURL(link)
}
}

/**
* Dialog with configurations for SDF generation
*/
Expand Down

0 comments on commit 302f5ed

Please sign in to comment.