modify view

This commit is contained in:
jiegeaiai 2025-01-13 08:36:26 +08:00
parent 1dc7ec9f8b
commit b900683dbe
5 changed files with 13 additions and 5 deletions

View File

@ -6,6 +6,7 @@
#include <osgWidget/ViewerEventHandlers>
#include "utils/ImageUtils.h"
#include "common/SpdLogger.h"
BackGroundWidget::BackGroundWidget(const std::string& name,
float w,
@ -15,7 +16,8 @@ BackGroundWidget::BackGroundWidget(const std::string& name,
{
//osg::Image *image = ImageUtils::readImage(fileName);
setImage(fileName, true, true);
LOG_INFO("setimage, {}", fileName);
setImage(fileName, true);
setTexCoord(0.0f, 0.0f, osgWidget::Widget::LOWER_LEFT);
setTexCoord(1.0f, 0.0f, osgWidget::Widget::LOWER_RIGHT);

View File

@ -2,6 +2,7 @@
#include "utils/ImageUtils.h"
#include "CompositeWidgetManager.h"
#include "common/SpdLogger.h"
CompositeWidget::CompositeWidget(std::string name,
@ -13,7 +14,7 @@ CompositeWidget::CompositeWidget(std::string name,
CompositeWidgetManager *wm) :osgWidget::Widget(name, w, h)
{
//osg::Image *image = ImageUtils::readImage(fileName);
LOG_INFO("setimage, {}", fileName);
setImage(fileName, true, true);
setTexCoord(0.0f, 0.0f, osgWidget::Widget::LOWER_LEFT);

View File

@ -2,6 +2,7 @@
#include "ZoomWidget.h"
#include "utils/ImageUtils.h"
#include "common/SpdLogger.h"
ZoomWidget::ZoomWidget(std::string name,
float w,
@ -13,14 +14,15 @@ ZoomWidget::ZoomWidget(std::string name,
:osgWidget::Widget(name, w, h)
{
//osg::Image *image = ImageUtils::readImage(fileName);
setImage(fileName, true, true);
LOG_INFO("setimage, {}", fileName);
setImage(fileName, true);
setTexCoord(0.0f, 0.0f, osgWidget::Widget::LOWER_LEFT);
setTexCoord(1.0f, 0.0f, osgWidget::Widget::LOWER_RIGHT);
setTexCoord(1.0f, 1.0f, osgWidget::Widget::UPPER_RIGHT);
setTexCoord(0.0f, 1.0f, osgWidget::Widget::UPPER_LEFT);
setLayer(layer);
setEventMask(osgWidget::EVENT_MOUSE_PUSH | osgWidget::EVENT_MOUSE_RELEASE | osgWidget::EVENT_MOUSE_DRAG);
setColor(1, 1, 1, 0);
setColor(1, 1, 1, 1);
_pointX = _pointY = 0.0;

View File

@ -6,7 +6,7 @@
/// Needed for mixing osg rendering with Qt 2D drawing using QPainter...
/// See http://forum.openscenegraph.org/viewtopic.php?t=15627&view=previous
class GraphicsWindowEx : public osgViewer::GraphicsWindow
class GraphicsWindowEx : public osgViewer::GraphicsWindowEmbedded
{
public:
GraphicsWindowEx(osg::GraphicsContext::Traits* traits);

View File

@ -5,6 +5,7 @@
#include <QApplication>
#include <osg/BlendFunc>
#include <osgEarth/GLUtils>
#include <osgDB/Registry>
#include "common/SpdLogger.h"
#include "viewer/OsgView.h"
@ -20,7 +21,9 @@ OsgViewer::OsgViewer(QObject* parent) noexcept
, compositeViewer_(new osgViewer::CompositeViewer) {
LOG_INFO("actor, self={}", fmt::ptr(this));
compositeViewer_->setKeyEventSetsDone(0);
compositeViewer_->getDatabasePager()->setUnrefImageDataAfterApplyPolicy(true, false);
osgEarth::initialize();
osgDB::Registry::instance()->getObjectWrapperManager()->findWrapper("osg::Image");
compositeViewer_->setThreadingModel(osgViewer::ViewerBase::ThreadingModel::SingleThreaded);
}