From: Markus R. <rol...@us...> - 2007-04-09 17:33:57
|
Update of /cvsroot/simspark/simspark/contrib/rsgedit In directory sc8-pr-cvs8.sourceforge.net:/tmp/cvs-serv1814 Modified Files: sparkglcanvas.cpp sparkglcanvas.h Log Message: - added left double click handler OnLeftDClick() - added method Pick() that uses the RenderServer to determine the closest object to the current mouse pointer position Index: sparkglcanvas.h =================================================================== RCS file: /cvsroot/simspark/simspark/contrib/rsgedit/sparkglcanvas.h,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** sparkglcanvas.h 1 Apr 2007 15:48:33 -0000 1.5 --- sparkglcanvas.h 9 Apr 2007 17:04:34 -0000 1.6 *************** *** 32,35 **** --- 32,36 ---- { class InputSystem; + class RenderServer; } *************** *** 56,59 **** --- 57,61 ---- void OnKeyUp(wxKeyEvent& event); void OnLeftDown(wxMouseEvent& event); + void OnLeftDClick(wxMouseEvent& event); void OnLeftUp(wxMouseEvent& event); void OnMiddleDown(wxMouseEvent& event); *************** *** 66,69 **** --- 68,72 ---- void Render(wxDC& dc); void Reset(); + void Pick(wxDC& dc); protected: *************** *** 75,78 **** --- 78,82 ---- SparkGLRender mRender; boost::shared_ptr<kerosin::InputSystem> mInputSystem; + boost::shared_ptr<kerosin::RenderServer> mRenderServer; bool mMouseCaptured; Index: sparkglcanvas.cpp =================================================================== RCS file: /cvsroot/simspark/simspark/contrib/rsgedit/sparkglcanvas.cpp,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** sparkglcanvas.cpp 1 Apr 2007 15:48:33 -0000 1.7 --- sparkglcanvas.cpp 9 Apr 2007 17:04:33 -0000 1.8 *************** *** 30,33 **** --- 30,35 ---- #include <kerosin/inputserver/inputserver.h> #include <kerosin/inputserver/inputsystem.h> + #include <kerosin/renderserver/renderserver.h> + #include <kerosin/renderserver/rendernode.h> BEGIN_EVENT_TABLE(SparkGLCanvas, wxGLCanvas) *************** *** 40,43 **** --- 42,46 ---- EVT_LEFT_DOWN(SparkGLCanvas::OnLeftDown) EVT_LEFT_UP(SparkGLCanvas::OnLeftUp) + EVT_LEFT_DCLICK(SparkGLCanvas::OnLeftDClick) EVT_MIDDLE_DOWN(SparkGLCanvas::OnMiddleDown) EVT_MIDDLE_UP(SparkGLCanvas::OnMiddleUp) *************** *** 50,53 **** --- 53,57 ---- using namespace boost; using namespace kerosin; + using namespace salt; SparkGLCanvas::SparkGLCanvas(wxWindow *parent, wxWindowID id, *************** *** 100,103 **** --- 104,141 ---- } + void SparkGLCanvas::Pick(wxDC& dc) + { + shared_ptr<SimSpark> spark = wxGetApp().GetSpark(); + if ( + (spark.get() == 0) || + (mRenderServer.get() == 0) + ) + { + assert(false); + return; + } + + wxPoint ptMouse = wxGetMousePosition(); + ScreenToClient(&ptMouse.x, &ptMouse.y); + + double pickRange = 5.0; + mRenderServer->EnablePicking(true, Vector2f(ptMouse.x, ptMouse.y), pickRange); + + Render(dc); + + mRenderServer->DisablePicking(); + + weak_ptr<RenderNode> pickedNode = mRenderServer->GetPickedNode(); + if (pickedNode.expired()) + { + spark->GetLog()->Normal() + << "(SparkGLCanvas) SparkGLCanvas::Pick no node picked\n"; + } else + { + spark->GetLog()->Normal() + << "(SparkGLCanvas) SparkGLCanvas::Pick picked " << pickedNode.lock()->GetFullPath() << std::endl; + } + } + void SparkGLCanvas::OnPaint( wxPaintEvent& WXUNUSED(event) ) { *************** *** 140,143 **** --- 178,190 ---- } + mRenderServer = shared_dynamic_cast<RenderServer> + (spark->GetCore()->Get("/sys/server/render")); + + if (mRenderServer.get() == 0) + { + spark->GetLog()->Error() + << "(SparkGLCanvas) ERROR: RenderServer not found\n"; + } + mRender.Init(spark); return true; *************** *** 166,169 **** --- 213,223 ---- } + void SparkGLCanvas::OnLeftDClick(wxMouseEvent& event) + { + wxClientDC dc(this); + Pick(dc); + Render(dc); + } + void SparkGLCanvas::OnLeftUp(wxMouseEvent& event) { |