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

Added Interactive view control plugin #231

Merged
merged 5 commits into from
Jul 20, 2021
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
13 changes: 13 additions & 0 deletions examples/config/scene3d.config
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,19 @@
<background_color>0.8 0.8 0.8</background_color>
<camera_pose>-6 0 6 0 0.5 0</camera_pose>
</plugin>
<plugin filename="InteractiveViewControl" name="Interactive view control">
<ignition-gui>
<anchors target="View 1">
<line own="right" target="right"/>
<line own="top" target="top"/>
</anchors>
<property key="resizable" type="bool">false</property>
<property key="width" type="double">5</property>
<property key="height" type="double">5</property>
<property key="state" type="string">floating</property>
<property key="showTitleBar" type="bool">false</property>
</ignition-gui>
</plugin>
<plugin filename="TransportSceneManager" name="Transport Scene Manager">
<ignition-gui>
<anchors target="View 1">
Expand Down
22 changes: 22 additions & 0 deletions include/ignition/gui/GuiEvents.hh
Original file line number Diff line number Diff line change
Expand Up @@ -301,6 +301,28 @@ namespace ignition
/// \brief Private data pointer
IGN_UTILS_IMPL_PTR(dataPtr)
};

/// \brief Event that block the Interactive View control when some of the
/// other plugins require it. For example: When the transform control is
/// active we should block the movements of the camera.
class IGNITION_GUI_VISIBLE BlockOrbit : public QEvent
ahcorde marked this conversation as resolved.
Show resolved Hide resolved
{
/// \brief Constructor
/// \param[in] _block True to block otherwise False
public: explicit BlockOrbit(const bool &_block);

/// \brief Unique type for this event.
static const QEvent::Type kType = QEvent::Type(QEvent::MaxUser - 12);

/// \brief Get the if the event should block the Interactive view
/// controller
/// \return True to block otherwise False.
public: bool Block() const;

/// \internal
/// \brief Private data pointer
IGN_UTILS_IMPL_PTR(dataPtr)
};
}
}
}
Expand Down
18 changes: 18 additions & 0 deletions src/GuiEvents.cc
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,11 @@ class ignition::gui::events::RightClickOnScene::Implementation
public: common::MouseEvent mouse;
};

class ignition::gui::events::BlockOrbit::Implementation
{
public: bool block;
};

class ignition::gui::events::KeyReleaseOnScene::Implementation
{
/// \brief Key event
Expand Down Expand Up @@ -230,6 +235,19 @@ const common::MouseEvent &LeftClickOnScene::Mouse() const
return this->dataPtr->mouse;
}

/////////////////////////////////////////////////
BlockOrbit::BlockOrbit(const bool &_block)
: QEvent(kType), dataPtr(utils::MakeImpl<Implementation>())
{
this->dataPtr->block = _block;
}

/////////////////////////////////////////////////
bool BlockOrbit::Block() const
{
return this->dataPtr->block;
}

/////////////////////////////////////////////////
KeyReleaseOnScene::KeyReleaseOnScene(
const common::KeyEvent &_key)
Expand Down
12 changes: 12 additions & 0 deletions src/GuiEvents_TEST.cc
Original file line number Diff line number Diff line change
Expand Up @@ -162,3 +162,15 @@ TEST(GuiEventsTest, DropdownMenuEnabled)
EXPECT_LT(QEvent::User, event2.type());
EXPECT_EQ(false, event2.MenuEnabled());
}

/////////////////////////////////////////////////
TEST(GuiEventsTest, BlockOrbit)
{
events::BlockOrbit event(true);
EXPECT_LT(QEvent::User, event.type());
EXPECT_TRUE(event.Block());

events::BlockOrbit event2(false);
EXPECT_LT(QEvent::User, event2.type());
EXPECT_FALSE(event2.Block());
}
1 change: 1 addition & 0 deletions src/plugins/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,7 @@ add_subdirectory(camera_tracking)
add_subdirectory(grid_3d)
add_subdirectory(grid_config)
add_subdirectory(image_display)
add_subdirectory(interactive_view_control)
add_subdirectory(key_publisher)
add_subdirectory(plotting)
add_subdirectory(publisher)
Expand Down
10 changes: 10 additions & 0 deletions src/plugins/interactive_view_control/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
ign_gui_add_plugin(InteractiveViewControl
SOURCES
InteractiveViewControl.cc
QT_HEADERS
InteractiveViewControl.hh
TEST_SOURCES
# ViewControl_TEST.cc
PUBLIC_LINK_LIBS
ignition-rendering${IGN_RENDERING_VER}::ignition-rendering${IGN_RENDERING_VER}
)
Loading