42 #include <OgreRenderWindow.h> 43 #include <OgreSceneManager.h> 44 #include <OgreViewport.h> 45 #include <OgreRectangle2D.h> 46 #include <OgreMaterial.h> 47 #include <OgreMaterialManager.h> 48 #include <OgreTextureUnitState.h> 49 #include <OgreSharedPtr.h> 50 #include <OgreTechnique.h> 51 #include <OgreSceneNode.h> 70 QtOgreRenderWindow::showEvent(event);
79 if (resolved_image ==
"/image")
81 ROS_WARN(
"image topic has not been remapped");
84 std::stringstream title;
85 title <<
"rviz Image Viewer [" << resolved_image <<
"]";
86 setWindowTitle(QString::fromStdString(title.str()));
100 ROS_ERROR(
"%s", (std::string(
"Error subscribing: ") + e.what()).c_str());
103 Ogre::MaterialPtr material = Ogre::MaterialManager::getSingleton().create(
104 "Material", Ogre::ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME);
105 material->setCullingMode(Ogre::CULL_NONE);
106 material->getTechnique(0)->getPass(0)->setDepthWriteEnabled(
true);
107 material->getTechnique(0)->setLightingEnabled(
false);
108 Ogre::TextureUnitState* tu = material->getTechnique(0)->getPass(0)->createTextureUnitState();
110 tu->setTextureFiltering(Ogre::TFO_NONE);
111 tu->setTextureAddressingMode(Ogre::TextureUnitState::TAM_CLAMP);
113 Ogre::Rectangle2D* rect =
new Ogre::Rectangle2D(
true);
114 rect->setCorners(-1.0
f, 1.0
f, 1.0
f, -1.0
f);
115 rect->setMaterial(material->getName());
116 rect->setRenderQueueGroup(Ogre::RENDER_QUEUE_OVERLAY - 1);
117 Ogre::AxisAlignedBox aabb;
119 rect->setBoundingBox(aabb);
121 Ogre::SceneNode* node =
scene_manager_->getRootSceneNode()->createChildSceneNode();
122 node->attachObject(rect);
123 node->setVisible(
true);
125 QTimer* timer =
new QTimer(
this);
126 connect(timer, SIGNAL(timeout()),
this, SLOT(
onTimer()));
134 static bool first =
true;
const Ogre::TexturePtr & getTexture()
void initializeResources(const V_string &resource_paths)
void setAutoRender(bool auto_render)
void textureCallback(const sensor_msgs::Image::ConstPtr &msg)
void showEvent(QShowEvent *event) override
std::vector< std::string > V_string
boost::shared_ptr< image_transport::SubscriberFilter > texture_sub_
void addMessage(const sensor_msgs::Image::ConstPtr &image)
std::string resolveName(const std::string &name, bool remap=true) const
ROSLIB_DECL std::string getPath(const std::string &package_name)
ImageView(QWidget *parent=nullptr)
ROSImageTexture * texture_
ROSCPP_DECL void spinOnce()
void setCamera(Ogre::Camera *camera)
Ogre::SceneManager * scene_manager_
image_transport::ImageTransport texture_it_