From Stephan Huber, "* osgGA: fixed a small bug regarding emulating mouse-events from touch-events
* resthttp/osc: encapsulate RequestHandler-classes in their own namespaces to prevent class-name-lookup-errors in the debugger/code (had some weird crashes) * QTKit: fixed a compile-bug for gcc and blocks * osgPresentation: click_to_* will fire on RELEASE, only if the drawable received a PUSH beforehand * p3d/osgPresentation: implemented "forward_mouse_event_to_device"-tag, which will forward mouse-events to all registered devices of a viewer, if an intersection occurs. The mouse-coordinates get reprojected * present3d: all devices get registered with the viewer * osgViewer: only devices which are capable of receiving events are queried for new events. * GraphicWindowIOS: added a flag to GraphicWindowIOS::WindowData to set up a retained backing buffer (defaults to false) This will enable read-back of the render-buffer with glReadPixels even after the renderbuffer got presented * curl: added an optimized check for file-existance, now only the headers are requested and checked, instead of reading the whole file and handle it with a ReaderWriter * p3d: fixed a bug, where the existence of a local file may prevent the remote loading of a file with the same name. "
This commit is contained in:
parent
521625b343
commit
e76e3a7b1b
@ -311,8 +311,7 @@ void addDeviceTo(osgViewer::Viewer& viewer, const std::string& device_name)
|
||||
if (dev.valid())
|
||||
{
|
||||
OSG_INFO << "Adding Device : " << device_name << std::endl;
|
||||
if (dev->getCapabilities() & osgGA::Device::RECEIVE_EVENTS)
|
||||
viewer.addDevice(dev.get());
|
||||
viewer.addDevice(dev.get());
|
||||
|
||||
if (dev->getCapabilities() & osgGA::Device::SEND_EVENTS)
|
||||
viewer.getEventHandlers().push_front(new ForwardToDeviceEventHandler(dev.get()));
|
||||
|
@ -56,6 +56,8 @@ class OSGPRESENTATION_EXPORT PickEventHandler : public osgGA::GUIEventHandler
|
||||
osgPresentation::Operation _operation;
|
||||
|
||||
JumpData _jumpData;
|
||||
std::set<osg::Drawable*> _drawablesOnPush;
|
||||
|
||||
};
|
||||
|
||||
}
|
||||
|
@ -36,7 +36,8 @@ enum Operation
|
||||
RUN,
|
||||
LOAD,
|
||||
EVENT,
|
||||
JUMP
|
||||
JUMP,
|
||||
FORWARD_EVENT
|
||||
};
|
||||
|
||||
struct JumpData
|
||||
|
@ -149,7 +149,8 @@ class GraphicsWindowIOS : public osgViewer::GraphicsWindow
|
||||
: _windowOrView(window_or_view),
|
||||
_deviceOrientationFlags(orientationFlags),
|
||||
_viewContentScaleFactor(scaleFactor),
|
||||
_createTransparentView(false)
|
||||
_createTransparentView(false),
|
||||
_useRetainedBacking(false)
|
||||
{
|
||||
}
|
||||
|
||||
@ -161,12 +162,17 @@ class GraphicsWindowIOS : public osgViewer::GraphicsWindow
|
||||
|
||||
bool getCreateTransparentView() { return _createTransparentView; }
|
||||
void setCreateTransparentView(bool b) { _createTransparentView = b; }
|
||||
|
||||
bool getUseRetainedBacking() { return _useRetainedBacking; }
|
||||
void setUseRetainedBacking(bool b) { _useRetainedBacking = b; }
|
||||
|
||||
private:
|
||||
|
||||
UIView* _windowOrView;
|
||||
DeviceOrientationFlags _deviceOrientationFlags;
|
||||
float _viewContentScaleFactor;
|
||||
bool _createTransparentView;
|
||||
bool _useRetainedBacking;
|
||||
|
||||
friend class GraphicsWindowIOS;
|
||||
|
||||
|
@ -1794,7 +1794,7 @@ ReaderWriter* Registry::getReaderWriterForProtocolAndExtension(const std::string
|
||||
{
|
||||
// try first the registered ReaderWriter
|
||||
ReaderWriter* result = getReaderWriterForExtension(extension);
|
||||
if (result->acceptsProtocol(protocol))
|
||||
if (result && result->acceptsProtocol(protocol))
|
||||
return result;
|
||||
|
||||
result = NULL;
|
||||
|
@ -409,7 +409,7 @@ GUIEventAdapter* EventQueue::touchBegan(unsigned int id, GUIEventAdapter::Touch
|
||||
{
|
||||
// emulate left mouse button press
|
||||
|
||||
_accumulateEventState->setButtonMask((1) | _accumulateEventState->getButtonMask());
|
||||
_accumulateEventState->setButtonMask(GUIEventAdapter::LEFT_MOUSE_BUTTON | _accumulateEventState->getButtonMask());
|
||||
_accumulateEventState->setX(x);
|
||||
_accumulateEventState->setY(y);
|
||||
}
|
||||
@ -418,7 +418,9 @@ GUIEventAdapter* EventQueue::touchBegan(unsigned int id, GUIEventAdapter::Touch
|
||||
event->setEventType(GUIEventAdapter::PUSH);
|
||||
event->setTime(time);
|
||||
event->addTouchPoint(id, phase, x, y, 0);
|
||||
|
||||
if(_firstTouchEmulatesMouse)
|
||||
event->setButton(GUIEventAdapter::LEFT_MOUSE_BUTTON);
|
||||
|
||||
addEvent(event);
|
||||
|
||||
return event;
|
||||
@ -446,7 +448,7 @@ GUIEventAdapter* EventQueue::touchEnded(unsigned int id, GUIEventAdapter::Touch
|
||||
{
|
||||
if (_firstTouchEmulatesMouse)
|
||||
{
|
||||
_accumulateEventState->setButtonMask(~(1) & _accumulateEventState->getButtonMask());
|
||||
_accumulateEventState->setButtonMask(~GUIEventAdapter::LEFT_MOUSE_BUTTON & _accumulateEventState->getButtonMask());
|
||||
_accumulateEventState->setX(x);
|
||||
_accumulateEventState->setY(y);
|
||||
}
|
||||
@ -455,6 +457,9 @@ GUIEventAdapter* EventQueue::touchEnded(unsigned int id, GUIEventAdapter::Touch
|
||||
event->setEventType(GUIEventAdapter::RELEASE);
|
||||
event->setTime(time);
|
||||
event->addTouchPoint(id, phase, x, y, tap_count);
|
||||
if(_firstTouchEmulatesMouse)
|
||||
event->setButton(GUIEventAdapter::LEFT_MOUSE_BUTTON);
|
||||
|
||||
addEvent(event);
|
||||
|
||||
return event;
|
||||
|
@ -99,9 +99,19 @@ void OSXQTKitVideo::initializeQTKit()
|
||||
if (![NSThread isMainThread]) {
|
||||
dispatch_apply(1, dispatch_get_main_queue(), ^(size_t n) {
|
||||
EnterMovies();
|
||||
QTMovie* movie = [QTMovie movie];
|
||||
// release missing by intent, gets released by the block!
|
||||
movie = NULL;
|
||||
{
|
||||
// workaround for gcc bug. See discussion here
|
||||
// http://stackoverflow.com/questions/6525928/objective-c-block-vs-objective-c-block
|
||||
|
||||
#if (GCC_VERSION <= 40201) && !(__clang__)
|
||||
QTMovie* ::temp_movie = [QTMovie movie];
|
||||
#else
|
||||
QTMovie* temp_movie = [QTMovie movie];
|
||||
#endif
|
||||
|
||||
// release missing by intent, gets released by the block!
|
||||
temp_movie = NULL;
|
||||
}
|
||||
});
|
||||
}
|
||||
else
|
||||
|
@ -17,6 +17,7 @@
|
||||
#include <osgDB/FileUtils>
|
||||
#include "request_handler.hpp"
|
||||
|
||||
namespace RestHttp {
|
||||
|
||||
|
||||
class StandardRequestHandler : public RestHttpDevice::RequestHandler {
|
||||
@ -254,6 +255,7 @@ bool RequestHandlerDispatcherCallback::operator()(const std::string& request_pat
|
||||
return _parent->handleRequest(request_path, reply);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
RestHttpDevice::RestHttpDevice(const std::string& listening_address, const std::string& listening_port, const std::string& doc_root)
|
||||
: osgGA::Device()
|
||||
@ -274,20 +276,20 @@ RestHttpDevice::RestHttpDevice(const std::string& listening_address, const std::
|
||||
{
|
||||
OSG_WARN << "RestHttpDevice :: warning, can't locate document-root '" << doc_root << "'for the http-server, starting anyway" << std::endl;
|
||||
}
|
||||
_server.setCallback(new RequestHandlerDispatcherCallback(this));
|
||||
_server.setCallback(new RestHttp::RequestHandlerDispatcherCallback(this));
|
||||
|
||||
addRequestHandler(new KeyCodeRequestHandler(false));
|
||||
addRequestHandler(new KeyCodeRequestHandler(true));
|
||||
addRequestHandler(new RestHttp::KeyCodeRequestHandler(false));
|
||||
addRequestHandler(new RestHttp::KeyCodeRequestHandler(true));
|
||||
|
||||
addRequestHandler(new SetMouseInputRangeRequestHandler());
|
||||
addRequestHandler(new MouseMotionRequestHandler());
|
||||
addRequestHandler(new MouseButtonRequestHandler(MouseButtonRequestHandler::PRESS));
|
||||
addRequestHandler(new MouseButtonRequestHandler(MouseButtonRequestHandler::RELEASE));
|
||||
addRequestHandler(new MouseButtonRequestHandler(MouseButtonRequestHandler::DOUBLE_PRESS));
|
||||
addRequestHandler(new RestHttp::SetMouseInputRangeRequestHandler());
|
||||
addRequestHandler(new RestHttp::MouseMotionRequestHandler());
|
||||
addRequestHandler(new RestHttp::MouseButtonRequestHandler(RestHttp::MouseButtonRequestHandler::PRESS));
|
||||
addRequestHandler(new RestHttp::MouseButtonRequestHandler(RestHttp::MouseButtonRequestHandler::RELEASE));
|
||||
addRequestHandler(new RestHttp::MouseButtonRequestHandler(RestHttp::MouseButtonRequestHandler::DOUBLE_PRESS));
|
||||
|
||||
addRequestHandler(new HomeRequestHandler());
|
||||
addRequestHandler(new RestHttp::HomeRequestHandler());
|
||||
|
||||
addRequestHandler(new StandardRequestHandler());
|
||||
addRequestHandler(new RestHttp::StandardRequestHandler());
|
||||
|
||||
// start the thread
|
||||
start();
|
||||
|
@ -706,14 +706,33 @@ bool ReaderWriterCURL::read(std::istream& fin, std::string& destination) const
|
||||
}
|
||||
#endif
|
||||
|
||||
size_t empty_write_data(const char *buffer, size_t size, size_t nmemb, char
|
||||
*userp)
|
||||
{
|
||||
return size*nmemb;
|
||||
}
|
||||
|
||||
bool ReaderWriterCURL::fileExists(const std::string& filename, const osgDB::Options* options) const
|
||||
{
|
||||
if (osgDB::containsServerAddress(filename))
|
||||
{
|
||||
std::string data;
|
||||
OSG_NOTICE<<"Checking if file exists using curl plugin: "<<filename<<std::endl;
|
||||
CURL* curl_handle = curl_easy_init();
|
||||
curl_easy_setopt(curl_handle, CURLOPT_URL, filename.c_str());
|
||||
curl_easy_setopt(curl_handle, CURLOPT_NOBODY, 1);
|
||||
curl_easy_setopt(curl_handle, CURLOPT_HEADER, 1);
|
||||
curl_easy_setopt(curl_handle, CURLOPT_FILETIME, 1);
|
||||
curl_easy_setopt(curl_handle, CURLOPT_WRITEFUNCTION, (void*)&empty_write_data);
|
||||
|
||||
ReadResult result = readFile(OBJECT,filename,options);
|
||||
return result.status()==osgDB::ReaderWriter::ReadResult::FILE_LOADED;
|
||||
int result = curl_easy_perform(curl_handle);
|
||||
|
||||
long http_return_code(0);
|
||||
curl_easy_getinfo(curl_handle, CURLINFO_RESPONSE_CODE, &http_return_code);
|
||||
|
||||
curl_easy_cleanup(curl_handle);
|
||||
|
||||
return ((result == 0) && ((http_return_code == 200) || (http_return_code == 0)));
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -21,6 +21,7 @@
|
||||
#include "osc/OscPrintReceivedElements.h"
|
||||
#include "osc/OscHostEndianness.h"
|
||||
|
||||
namespace OscDevice {
|
||||
|
||||
template <class T, int SIZE>
|
||||
struct NativeTypeTraits {
|
||||
@ -709,6 +710,7 @@ public:
|
||||
};
|
||||
|
||||
|
||||
} // end of namespace
|
||||
|
||||
|
||||
|
||||
@ -732,32 +734,32 @@ OscReceivingDevice::OscReceivingDevice(const std::string& server_address, int li
|
||||
|
||||
_socket = new UdpListeningReceiveSocket(IpEndpointName( server_address.c_str(), listening_port ), this);
|
||||
|
||||
addRequestHandler(new KeyCodeRequestHandler(false));
|
||||
addRequestHandler(new KeyCodeRequestHandler(true));
|
||||
addRequestHandler(new KeyPressAndReleaseRequestHandler());
|
||||
addRequestHandler(new OscDevice::KeyCodeRequestHandler(false));
|
||||
addRequestHandler(new OscDevice::KeyCodeRequestHandler(true));
|
||||
addRequestHandler(new OscDevice::KeyPressAndReleaseRequestHandler());
|
||||
|
||||
addRequestHandler(new SetMouseInputRangeRequestHandler());
|
||||
addRequestHandler(new SetMouseOrientationRequestHandler());
|
||||
addRequestHandler(new OscDevice::SetMouseInputRangeRequestHandler());
|
||||
addRequestHandler(new OscDevice::SetMouseOrientationRequestHandler());
|
||||
|
||||
MouseMotionRequestHandler* mm_handler = new MouseMotionRequestHandler();
|
||||
OscDevice::MouseMotionRequestHandler* mm_handler = new OscDevice::MouseMotionRequestHandler();
|
||||
addRequestHandler(mm_handler);
|
||||
addRequestHandler(new MouseButtonRequestHandler(MouseButtonRequestHandler::PRESS));
|
||||
addRequestHandler(new MouseButtonRequestHandler(MouseButtonRequestHandler::RELEASE));
|
||||
addRequestHandler(new MouseButtonRequestHandler(MouseButtonRequestHandler::DOUBLE_PRESS));
|
||||
addRequestHandler(new MouseScrollRequestHandler());
|
||||
addRequestHandler(new OscDevice::MouseButtonRequestHandler(OscDevice::MouseButtonRequestHandler::PRESS));
|
||||
addRequestHandler(new OscDevice::MouseButtonRequestHandler(OscDevice::MouseButtonRequestHandler::RELEASE));
|
||||
addRequestHandler(new OscDevice::MouseButtonRequestHandler(OscDevice::MouseButtonRequestHandler::DOUBLE_PRESS));
|
||||
addRequestHandler(new OscDevice::MouseScrollRequestHandler());
|
||||
|
||||
addRequestHandler(new MouseButtonToggleRequestHandler("1", mm_handler));
|
||||
addRequestHandler(new MouseButtonToggleRequestHandler("2", mm_handler));
|
||||
addRequestHandler(new MouseButtonToggleRequestHandler("3", mm_handler));
|
||||
addRequestHandler(new OscDevice::MouseButtonToggleRequestHandler("1", mm_handler));
|
||||
addRequestHandler(new OscDevice::MouseButtonToggleRequestHandler("2", mm_handler));
|
||||
addRequestHandler(new OscDevice::MouseButtonToggleRequestHandler("3", mm_handler));
|
||||
|
||||
addRequestHandler(new PenPressureRequestHandler());
|
||||
addRequestHandler(new PenOrientationRequestHandler());
|
||||
addRequestHandler(new PenProximityRequestHandler(true));
|
||||
addRequestHandler(new PenProximityRequestHandler(false));
|
||||
addRequestHandler(new OscDevice::PenPressureRequestHandler());
|
||||
addRequestHandler(new OscDevice::PenOrientationRequestHandler());
|
||||
addRequestHandler(new OscDevice::PenProximityRequestHandler(true));
|
||||
addRequestHandler(new OscDevice::PenProximityRequestHandler(false));
|
||||
|
||||
addRequestHandler(new StandardRequestHandler("/osg/set_user_value", true));
|
||||
addRequestHandler(new OscDevice::StandardRequestHandler("/osg/set_user_value", true));
|
||||
|
||||
addRequestHandler(new StandardRequestHandler("", false));
|
||||
addRequestHandler(new OscDevice::StandardRequestHandler("", false));
|
||||
|
||||
start();
|
||||
}
|
||||
|
@ -24,7 +24,6 @@ OscSendingDevice::OscSendingDevice(const std::string& address, int port)
|
||||
, _transmitSocket(IpEndpointName(address.c_str(), port))
|
||||
, _buffer(new char[BUFFER_SIZE])
|
||||
, _oscStream(_buffer, BUFFER_SIZE)
|
||||
, _firstRun(true)
|
||||
{
|
||||
setCapabilities(SEND_EVENTS);
|
||||
|
||||
@ -50,12 +49,14 @@ void OscSendingDevice::sendEvent(const osgGA::GUIEventAdapter &ea)
|
||||
switch(ea.getEventType())
|
||||
{
|
||||
case osgGA::GUIEventAdapter::RESIZE:
|
||||
sendInit(ea);
|
||||
_oscStream << osc::BeginMessage("/osgga/resize") << ea.getWindowX() << ea.getWindowY() << ea.getWindowWidth() << ea.getWindowHeight() << osc::EndMessage;
|
||||
do_send = true;
|
||||
break;
|
||||
|
||||
case osgGA::GUIEventAdapter::SCROLL:
|
||||
beginSendInputRange(ea);
|
||||
_oscStream << osc::BeginMessage("/osgga/mouse/scroll") << ea.getScrollingMotion() << ea.getScrollingDeltaX() << ea.getScrollingDeltaY() << osc::EndMessage;
|
||||
_oscStream << osc::EndBundle;
|
||||
do_send = true;
|
||||
break;
|
||||
|
||||
@ -95,32 +96,31 @@ void OscSendingDevice::sendEvent(const osgGA::GUIEventAdapter &ea)
|
||||
break;
|
||||
|
||||
case osgGA::GUIEventAdapter::PUSH:
|
||||
beginSendInputRange(ea);
|
||||
_oscStream << osc::BeginMessage("/osgga/mouse/press") << ea.getX() << ea.getY() << getButtonNum(ea) << osc::EndMessage;
|
||||
_oscStream << osc::EndBundle;
|
||||
do_send = true;
|
||||
break;
|
||||
|
||||
case osgGA::GUIEventAdapter::RELEASE:
|
||||
beginSendInputRange(ea);
|
||||
_oscStream << osc::BeginMessage("/osgga/mouse/release") << ea.getX() << ea.getY() << getButtonNum(ea) << osc::EndMessage;
|
||||
_oscStream << osc::EndBundle;
|
||||
do_send = true;
|
||||
break;
|
||||
|
||||
case osgGA::GUIEventAdapter::DOUBLECLICK:
|
||||
beginSendInputRange(ea);
|
||||
_oscStream << osc::BeginMessage("/osgga/mouse/doublepress") << ea.getX() << ea.getY() << getButtonNum(ea) << osc::EndMessage;
|
||||
_oscStream << osc::EndBundle;
|
||||
do_send = true;
|
||||
break;
|
||||
|
||||
case osgGA::GUIEventAdapter::MOVE:
|
||||
if (_firstRun)
|
||||
{
|
||||
_firstRun = false;
|
||||
sendInit(ea);
|
||||
do_send = true;
|
||||
break;
|
||||
}
|
||||
// break missing by intent;
|
||||
|
||||
case osgGA::GUIEventAdapter::DRAG:
|
||||
beginSendInputRange(ea);
|
||||
_oscStream << osc::BeginMessage("/osgga/mouse/motion") << ea.getX() << ea.getY() << osc::EndMessage;
|
||||
_oscStream << osc::EndBundle;
|
||||
do_send = true;
|
||||
break;
|
||||
|
||||
@ -150,6 +150,7 @@ void OscSendingDevice::sendEvent(const osgGA::GUIEventAdapter &ea)
|
||||
break;
|
||||
|
||||
}
|
||||
|
||||
if (do_send)
|
||||
{
|
||||
OSG_INFO << "OscDevice :: sending event per OSC " << std::endl;
|
||||
@ -178,13 +179,11 @@ int OscSendingDevice::getButtonNum(const osgGA::GUIEventAdapter& ea)
|
||||
return -1;
|
||||
}
|
||||
|
||||
void OscSendingDevice::sendInit(const osgGA::GUIEventAdapter &ea)
|
||||
void OscSendingDevice::beginSendInputRange(const osgGA::GUIEventAdapter &ea)
|
||||
{
|
||||
_oscStream << osc::BeginBundle();
|
||||
_oscStream << osc::BeginMessage("/osgga/resize") << ea.getWindowX() << ea.getWindowY() << ea.getWindowWidth() << ea.getWindowHeight() << osc::EndMessage;
|
||||
_oscStream << osc::BeginMessage("/osgga/mouse/set_input_range") << ea.getXmin() << ea.getYmin() << ea.getXmax() << ea.getYmax() << osc::EndMessage;
|
||||
_oscStream << osc::BeginMessage("/osgga/mouse/y_orientation_increasing_upwards") << (bool)(ea.getMouseYOrientation() == osgGA::GUIEventAdapter::Y_INCREASING_UPWARDS) << osc::EndMessage;
|
||||
_oscStream << osc::EndBundle;
|
||||
}
|
||||
|
||||
|
||||
|
@ -27,13 +27,12 @@ public:
|
||||
virtual void sendEvent(const osgGA::GUIEventAdapter &ea);
|
||||
|
||||
private:
|
||||
void sendInit(const osgGA::GUIEventAdapter& ea);
|
||||
void beginSendInputRange(const osgGA::GUIEventAdapter& ea);
|
||||
int getButtonNum(const osgGA::GUIEventAdapter& ea);
|
||||
void sendUserDataContainer(const std::string& key, const osg::UserDataContainer* udc, bool asBundle);
|
||||
std::string transliterateKey(const std::string& key) const;
|
||||
UdpTransmitSocket _transmitSocket;
|
||||
char* _buffer;
|
||||
osc::OutboundPacketStream _oscStream;
|
||||
bool _firstRun;
|
||||
};
|
||||
|
||||
|
@ -1458,6 +1458,13 @@ void ReaderWriterP3DXML::parseLayer(osgPresentation::SlideShowConstructor& const
|
||||
OSG_INFO<<"click_to_run ["<<cur->contents<<"]"<<std::endl;
|
||||
constructor.layerClickToDoOperation(cur->contents,osgPresentation::RUN, jumpData);
|
||||
}
|
||||
else if (cur->name == "forward_mouse_event_to_device")
|
||||
{
|
||||
osgPresentation::JumpData jumpData;
|
||||
|
||||
OSG_ALWAYS<<"forward_mouse_event_to_device ["<<cur->contents<<"]"<<std::endl;
|
||||
constructor.layerClickToDoOperation(cur->contents,osgPresentation::FORWARD_EVENT, jumpData);
|
||||
}
|
||||
else if (cur->name == "click_to_load")
|
||||
{
|
||||
osgPresentation::JumpData jumpData;
|
||||
@ -2217,7 +2224,7 @@ class MyReadFileCallback : public virtual osgDB::ReadFileCallback
|
||||
++itr)
|
||||
{
|
||||
const std::string& path = *itr;
|
||||
std::string newpath = path.empty() ? filename : osgDB::concatPaths(path, filename);
|
||||
std::string newpath = osgDB::containsServerAddress(filename) ? filename : path.empty() ? filename : osgDB::concatPaths(path, filename);
|
||||
osgDB::ReaderWriter::ReadResult result;
|
||||
if (osgDB::containsServerAddress(newpath))
|
||||
{
|
||||
@ -2381,7 +2388,8 @@ osgDB::ReaderWriter::ReadResult ReaderWriterP3DXML::readNode(std::istream& fin,
|
||||
|
||||
osg::ref_ptr<osgDB::ReaderWriter::Options> local_opt = options ? static_cast<osgDB::ReaderWriter::Options*>(options->clone(osg::CopyOp::SHALLOW_COPY)) : new Options;
|
||||
local_opt->setReadFileCallback(new MyReadFileCallback);
|
||||
|
||||
local_opt->setFindFileCallback(new MyFindFileCallback);
|
||||
|
||||
return readNode(input, local_opt.get());
|
||||
}
|
||||
|
||||
|
@ -16,6 +16,7 @@
|
||||
#include <osgViewer/Viewer>
|
||||
#include <osg/Notify>
|
||||
#include <osgDB/FileUtils>
|
||||
#include <osg/io_utils>
|
||||
|
||||
#include <stdlib.h>
|
||||
|
||||
@ -23,7 +24,8 @@ using namespace osgPresentation;
|
||||
|
||||
PickEventHandler::PickEventHandler(osgPresentation::Operation operation, const JumpData& jumpData):
|
||||
_operation(operation),
|
||||
_jumpData(jumpData)
|
||||
_jumpData(jumpData),
|
||||
_drawablesOnPush()
|
||||
{
|
||||
OSG_INFO<<"PickEventHandler::PickEventHandler(operation="<<operation<<", jumpData.relativeJump="<<jumpData.relativeJump<<", jumpData.="<<jumpData.slideNum<<", jumpData.layerNum="<<jumpData.layerNum<<std::endl;
|
||||
}
|
||||
@ -31,7 +33,8 @@ PickEventHandler::PickEventHandler(osgPresentation::Operation operation, const J
|
||||
PickEventHandler::PickEventHandler(const std::string& str, osgPresentation::Operation operation, const JumpData& jumpData):
|
||||
_command(str),
|
||||
_operation(operation),
|
||||
_jumpData(jumpData)
|
||||
_jumpData(jumpData),
|
||||
_drawablesOnPush()
|
||||
{
|
||||
OSG_INFO<<"PickEventHandler::PickEventHandler(str="<<str<<", operation="<<operation<<", jumpData.relativeJump="<<jumpData.relativeJump<<", jumpData.="<<jumpData.slideNum<<", jumpData.layerNum="<<jumpData.layerNum<<std::endl;
|
||||
}
|
||||
@ -39,7 +42,8 @@ PickEventHandler::PickEventHandler(const std::string& str, osgPresentation::Oper
|
||||
PickEventHandler::PickEventHandler(const osgPresentation::KeyPosition& keyPos, const JumpData& jumpData):
|
||||
_keyPos(keyPos),
|
||||
_operation(osgPresentation::EVENT),
|
||||
_jumpData(jumpData)
|
||||
_jumpData(jumpData),
|
||||
_drawablesOnPush()
|
||||
{
|
||||
OSG_INFO<<"PickEventHandler::PickEventHandler(keyPos="<<keyPos._key<<", jumpData.relativeJump="<<jumpData.relativeJump<<", jumpData.="<<jumpData.slideNum<<", jumpData.layerNum="<<jumpData.layerNum<<std::endl;
|
||||
}
|
||||
@ -53,8 +57,13 @@ bool PickEventHandler::handle(const osgGA::GUIEventAdapter& ea,osgGA::GUIActionA
|
||||
{
|
||||
case(osgGA::GUIEventAdapter::MOVE):
|
||||
case(osgGA::GUIEventAdapter::PUSH):
|
||||
case(osgGA::GUIEventAdapter::DRAG):
|
||||
case(osgGA::GUIEventAdapter::RELEASE):
|
||||
{
|
||||
if(ea.getEventType() == osgGA::GUIEventAdapter::PUSH)
|
||||
{
|
||||
_drawablesOnPush.clear();
|
||||
}
|
||||
osgViewer::Viewer* viewer = dynamic_cast<osgViewer::Viewer*>(&aa);
|
||||
osgUtil::LineSegmentIntersector::Intersections intersections;
|
||||
if (viewer->computeIntersections(ea.getX(),ea.getY(), nv->getNodePath(), intersections))
|
||||
@ -63,14 +72,48 @@ bool PickEventHandler::handle(const osgGA::GUIEventAdapter& ea,osgGA::GUIActionA
|
||||
hitr!=intersections.end();
|
||||
++hitr)
|
||||
{
|
||||
if (ea.getEventType()==osgGA::GUIEventAdapter::MOVE)
|
||||
if (_operation == FORWARD_EVENT)
|
||||
{
|
||||
OSG_INFO<<"Tooltip..."<<std::endl;
|
||||
osg::ref_ptr<osgGA::GUIEventAdapter> cloned_ea = osg::clone(&ea);
|
||||
const osg::BoundingBox bb(hitr->drawable->getBound());
|
||||
const osg::Vec3& p(hitr->localIntersectionPoint);
|
||||
|
||||
float transformed_x = (p.x() - bb.xMin()) / (bb.xMax() - bb.xMin());
|
||||
float transformed_y = (p.z() - bb.zMin()) / (bb.zMax() - bb.zMin());
|
||||
|
||||
cloned_ea->setX(ea.getXmin() + transformed_x * (ea.getXmax() - ea.getXmin()));
|
||||
cloned_ea->setY(ea.getYmin() + transformed_y * (ea.getYmax() - ea.getYmin()));
|
||||
cloned_ea->setMouseYOrientation(osgGA::GUIEventAdapter::Y_INCREASING_UPWARDS);
|
||||
|
||||
// std::cout << transformed_x << "/" << transformed_x << " -> " << cloned_ea->getX() << "/" <<cloned_ea->getY() << std::endl;
|
||||
|
||||
|
||||
// dispatch cloned event to devices
|
||||
osgViewer::View::Devices& devices = viewer->getDevices();
|
||||
for(osgViewer::View::Devices::iterator i = devices.begin(); i != devices.end(); ++i)
|
||||
{
|
||||
if((*i)->getCapabilities() & osgGA::Device::SEND_EVENTS)
|
||||
{
|
||||
(*i)->sendEvent(*cloned_ea);
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (ea.getEventType()==osgGA::GUIEventAdapter::RELEASE)
|
||||
else
|
||||
{
|
||||
doOperation();
|
||||
return true;
|
||||
if (ea.getEventType()==osgGA::GUIEventAdapter::PUSH)
|
||||
{
|
||||
_drawablesOnPush.insert( hitr->drawable );
|
||||
}
|
||||
else if (ea.getEventType()==osgGA::GUIEventAdapter::MOVE)
|
||||
{
|
||||
OSG_INFO<<"Tooltip..."<<std::endl;
|
||||
}
|
||||
else if (ea.getEventType()==osgGA::GUIEventAdapter::RELEASE)
|
||||
{
|
||||
if (_drawablesOnPush.find(hitr->drawable) != _drawablesOnPush.end())
|
||||
doOperation();
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -178,6 +221,8 @@ void PickEventHandler::doOperation()
|
||||
OSG_INFO<<"Requires jump "<<std::endl;
|
||||
break;
|
||||
}
|
||||
case(osgPresentation::FORWARD_EVENT):
|
||||
break;
|
||||
}
|
||||
|
||||
if (_jumpData.requiresJump())
|
||||
|
@ -933,7 +933,8 @@ void CompositeViewer::eventTraversal()
|
||||
++eitr)
|
||||
{
|
||||
osgGA::Device* es = eitr->get();
|
||||
es->checkEvents();
|
||||
if (es->getCapabilities() & osgGA::Device::RECEIVE_EVENTS)
|
||||
es->checkEvents();
|
||||
|
||||
// open question, will we need to reproject mouse coordinates into current view's coordinate frame as is down for GraphicsWindow provided events?
|
||||
// for now assume now and just get the events directly without any reprojection.
|
||||
|
@ -271,16 +271,18 @@ typedef std::map<void*, unsigned int> TouchPointsIdMapping;
|
||||
if (_win->getTraits()->inheritedWindowData.valid())
|
||||
win_data = dynamic_cast<osgViewer::GraphicsWindowIOS::WindowData*>(_win->getTraits()->inheritedWindowData.get());
|
||||
|
||||
eaglLayer.opaque = win_data ? !win_data->getCreateTransparentView() : YES ;
|
||||
eaglLayer.opaque = win_data ? !win_data->getCreateTransparentView() : YES;
|
||||
bool retained_backing = win_data ? win_data->getUseRetainedBacking() : NO;
|
||||
|
||||
if(_win->getTraits()->alpha > 0)
|
||||
{
|
||||
//create layer with alpha channel RGBA8
|
||||
eaglLayer.drawableProperties = [NSDictionary dictionaryWithObjectsAndKeys:
|
||||
[NSNumber numberWithBool:NO], kEAGLDrawablePropertyRetainedBacking, kEAGLColorFormatRGBA8, kEAGLDrawablePropertyColorFormat, nil];
|
||||
[NSNumber numberWithBool:retained_backing], kEAGLDrawablePropertyRetainedBacking, kEAGLColorFormatRGBA8, kEAGLDrawablePropertyColorFormat, nil];
|
||||
}else{
|
||||
//else no alpha, IOS uses RBG565
|
||||
eaglLayer.drawableProperties = [NSDictionary dictionaryWithObjectsAndKeys:
|
||||
[NSNumber numberWithBool:NO], kEAGLDrawablePropertyRetainedBacking, kEAGLColorFormatRGB565, kEAGLDrawablePropertyColorFormat, nil];
|
||||
[NSNumber numberWithBool:retained_backing], kEAGLDrawablePropertyRetainedBacking, kEAGLColorFormatRGB565, kEAGLDrawablePropertyColorFormat, nil];
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -651,7 +651,8 @@ void Viewer::eventTraversal()
|
||||
++eitr)
|
||||
{
|
||||
osgGA::Device* es = eitr->get();
|
||||
es->checkEvents();
|
||||
if (es->getCapabilities() & osgGA::Device::RECEIVE_EVENTS)
|
||||
es->checkEvents();
|
||||
|
||||
// open question, will we need to reproject mouse coordinates into current view's coordinate frame as is down for GraphicsWindow provided events?
|
||||
// for now assume now and just get the events directly without any reprojection.
|
||||
|
Loading…
Reference in New Issue
Block a user