Cleaned up osgWidget::VncClient and osgWidget::Browser so that their implementations are all more consitent with the osgWidget::PdfReader.
This commit is contained in:
@@ -1,50 +1,9 @@
|
||||
#include <osg/Image>
|
||||
#include <osg/Geometry>
|
||||
#include <osg/Texture2D>
|
||||
#include <osg/io_utils>
|
||||
#include <osg/GraphicsThread>
|
||||
|
||||
#include <osgViewer/Viewer>
|
||||
#include <osgViewer/ViewerEventHandlers>
|
||||
#include <osgGA/TrackballManipulator>
|
||||
|
||||
#include <osgDB/FileUtils>
|
||||
#include <osgDB/FileNameUtils>
|
||||
#include <osgDB/ReadFile>
|
||||
|
||||
#include <osgWidget/Browser>
|
||||
|
||||
|
||||
osg::Node* createInteractiveQuad(const osg::Vec3& origin, osg::Vec3& widthAxis, osg::Vec3& heightAxis,
|
||||
osg::Image* image)
|
||||
{
|
||||
bool flip = image->getOrigin()==osg::Image::TOP_LEFT;
|
||||
|
||||
osg::Geometry* pictureQuad = osg::createTexturedQuadGeometry(origin, widthAxis, heightAxis,
|
||||
0.0f, flip ? 1.0f : 0.0f , 1.0f, flip ? 0.0f : 1.0f);
|
||||
|
||||
osg::Texture2D* texture = new osg::Texture2D(image);
|
||||
texture->setResizeNonPowerOfTwoHint(false);
|
||||
texture->setFilter(osg::Texture::MIN_FILTER,osg::Texture::LINEAR);
|
||||
texture->setWrap(osg::Texture::WRAP_S, osg::Texture::CLAMP_TO_EDGE);
|
||||
texture->setWrap(osg::Texture::WRAP_T, osg::Texture::CLAMP_TO_EDGE);
|
||||
|
||||
pictureQuad->getOrCreateStateSet()->setTextureAttributeAndModes(0,
|
||||
texture,
|
||||
osg::StateAttribute::ON);
|
||||
|
||||
osg::ref_ptr<osgViewer::InteractiveImageHandler> callback = new osgViewer::InteractiveImageHandler(image);
|
||||
|
||||
pictureQuad->setEventCallback(callback.get());
|
||||
pictureQuad->setCullCallback(callback.get());
|
||||
|
||||
osg::Geode* geode = new osg::Geode;
|
||||
geode->addDrawable(pictureQuad);
|
||||
|
||||
return geode;
|
||||
}
|
||||
|
||||
int main( int argc, char* argv[] )
|
||||
int main(int argc,char** argv)
|
||||
{
|
||||
osg::ArgumentParser arguments(&argc, argv);
|
||||
|
||||
@@ -52,43 +11,31 @@ int main( int argc, char* argv[] )
|
||||
|
||||
osgViewer::Viewer viewer(arguments);
|
||||
|
||||
typedef std::list< osg::ref_ptr<osg::Image> > Images;
|
||||
Images images;
|
||||
osgWidget::GeometryHints hints(osg::Vec3(0.0f,0.0f,0.0f),
|
||||
osg::Vec3(1.0f,0.0f,0.0f),
|
||||
osg::Vec3(0.0f,0.0f,1.0f),
|
||||
osg::Vec4(1.0f,1.0f,1.0f,1.0f),
|
||||
osgWidget::GeometryHints::RESIZE_HEIGHT_TO_MAINTAINCE_ASPECT_RATIO);
|
||||
|
||||
osg::ref_ptr<osg::Group> group = new osg::Group;
|
||||
|
||||
for(int i=1; i<arguments.argc(); ++i)
|
||||
{
|
||||
if (!arguments.isOption(i))
|
||||
{
|
||||
std::string url_browser = std::string(arguments[i])+std::string(".gecko");
|
||||
osg::ref_ptr<osg::Image> image = osgDB::readImageFile(url_browser);
|
||||
if (image.valid()) images.push_back(image.get());
|
||||
osg::ref_ptr<osgWidget::Browser> browser = new osgWidget::Browser;
|
||||
if (browser->open(arguments[i], hints))
|
||||
{
|
||||
group->addChild(browser.get());
|
||||
|
||||
hints.position.x() += 1.1f;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
bool xyPlane = false;
|
||||
|
||||
osg::Group* group = new osg::Group;
|
||||
|
||||
osg::Vec3 origin = osg::Vec3(0.0f,0.0f,0.0f);
|
||||
for(Images::iterator itr = images.begin();
|
||||
itr != images.end();
|
||||
++itr)
|
||||
{
|
||||
osg::Image* image = itr->get();
|
||||
float width = 1.0;
|
||||
float height = float(image->t())/float(image->s());
|
||||
|
||||
osg::Vec3 widthAxis = osg::Vec3(width,0.0f,0.0f);
|
||||
osg::Vec3 heightAxis = xyPlane ? osg::Vec3(0.0f,height,0.0f) : osg::Vec3(0.0f,0.0f,height);
|
||||
|
||||
group->addChild(createInteractiveQuad(origin, widthAxis, heightAxis, image));
|
||||
|
||||
origin += widthAxis*1.1f;
|
||||
}
|
||||
|
||||
viewer.setSceneData(group);
|
||||
viewer.setSceneData(group.get());
|
||||
|
||||
viewer.addEventHandler(new osgViewer::StatsHandler);
|
||||
|
||||
|
||||
return viewer.run();
|
||||
}
|
||||
|
||||
@@ -1,15 +1,6 @@
|
||||
#include <osg/Image>
|
||||
#include <osg/Geometry>
|
||||
#include <osg/Texture2D>
|
||||
#include <osg/io_utils>
|
||||
|
||||
#include <osgViewer/Viewer>
|
||||
#include <osgViewer/ViewerEventHandlers>
|
||||
|
||||
#include <osgDB/FileUtils>
|
||||
#include <osgDB/FileNameUtils>
|
||||
#include <osgDB/ReadFile>
|
||||
|
||||
#include <osgWidget/PdfReader>
|
||||
|
||||
int main(int argc,char** argv)
|
||||
@@ -17,7 +8,7 @@ int main(int argc,char** argv)
|
||||
osg::ArgumentParser arguments(&argc, argv);
|
||||
osgViewer::Viewer viewer(arguments);
|
||||
|
||||
osgWidget::GeometryHints hints(osg::Vec3(1.0f,0.0f,0.0f),
|
||||
osgWidget::GeometryHints hints(osg::Vec3(0.0f,0.0f,0.0f),
|
||||
osg::Vec3(1.0f,0.0f,0.0f),
|
||||
osg::Vec3(0.0f,0.0f,1.0f),
|
||||
osg::Vec4(1.0f,1.0f,1.0f,1.0f),
|
||||
|
||||
@@ -1,19 +1,8 @@
|
||||
#include <osg/Image>
|
||||
#include <osg/Geometry>
|
||||
#include <osg/Texture2D>
|
||||
|
||||
#include <osgGA/TrackballManipulator>
|
||||
|
||||
#include <osgWidget/VncClient>
|
||||
|
||||
#include <osgViewer/Viewer>
|
||||
#include <osgViewer/ViewerEventHandlers>
|
||||
|
||||
#include <iostream>
|
||||
#include <osg/io_utils>
|
||||
|
||||
#include <osgDB/ReadFile>
|
||||
|
||||
class EscapeHandler : public osgGA::GUIEventHandler
|
||||
{
|
||||
public:
|
||||
@@ -49,7 +38,7 @@ int main(int argc,char** argv)
|
||||
osg::ArgumentParser arguments(&argc, argv);
|
||||
osgViewer::Viewer viewer(arguments);
|
||||
|
||||
osgWidget::GeometryHints hints(osg::Vec3(1.0f,0.0f,0.0f),
|
||||
osgWidget::GeometryHints hints(osg::Vec3(0.0f,0.0f,0.0f),
|
||||
osg::Vec3(1.0f,0.0f,0.0f),
|
||||
osg::Vec3(0.0f,0.0f,1.0f),
|
||||
osg::Vec4(1.0f,1.0f,1.0f,1.0f),
|
||||
|
||||
Reference in New Issue
Block a user