From: Markus R. <rol...@us...> - 2007-04-15 10:36:44
|
Update of /cvsroot/simspark/simspark/contrib/rsgedit In directory sc8-pr-cvs8.sourceforge.net:/tmp/cvs-serv5559 Modified Files: rsgedit.vcproj sparkglcanvas.cpp sparkglrender.cpp sparkglrender.h Added Files: sparkcontext.cpp sparkcontext.h Log Message: - move selection state into SparkContext class Index: sparkglrender.cpp =================================================================== RCS file: /cvsroot/simspark/simspark/contrib/rsgedit/sparkglrender.cpp,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** sparkglrender.cpp 9 Apr 2007 17:41:01 -0000 1.3 --- sparkglrender.cpp 15 Apr 2007 10:31:04 -0000 1.4 *************** *** 27,30 **** --- 27,31 ---- #include <kerosin/materialserver/material.h> #include "simspark.h" + #include "sparkcontext.h" using namespace boost; *************** *** 97,114 **** void SparkGLRender::RenderSelection() { ! if (mSelectedNode.expired()) ! { ! return; ! } glDisable(GL_LIGHTING); glDisable(GL_DEPTH_TEST); - shared_ptr<RenderNode> node = mSelectedNode.lock(); - glPushMatrix(); glMultMatrixf(node->GetWorldTransform().m); ! shared_ptr<SingleMatNode> sMatNode = shared_dynamic_cast<SingleMatNode>(node); --- 98,116 ---- void SparkGLRender::RenderSelection() { ! shared_ptr<RenderNode> node = shared_dynamic_cast<RenderNode> ! (SparkContext::GetInstance().GetSelection().lock()); ! ! if (node.get() == 0) ! { ! return; ! } glDisable(GL_LIGHTING); glDisable(GL_DEPTH_TEST); glPushMatrix(); glMultMatrixf(node->GetWorldTransform().m); ! shared_ptr<SingleMatNode> sMatNode = shared_dynamic_cast<SingleMatNode>(node); *************** *** 131,142 **** glPopMatrix(); } - - void SparkGLRender::SetSelection(weak_ptr<RenderNode> selection) - { - mSelectedNode = selection; - } - - void SparkGLRender::ResetSelection() - { - mSelectedNode.reset(); - } --- 133,134 ---- Index: sparkglcanvas.cpp =================================================================== RCS file: /cvsroot/simspark/simspark/contrib/rsgedit/sparkglcanvas.cpp,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 *** sparkglcanvas.cpp 9 Apr 2007 17:42:50 -0000 1.9 --- sparkglcanvas.cpp 15 Apr 2007 10:31:04 -0000 1.10 *************** *** 23,26 **** --- 23,27 ---- #include "simspark.h" + #include "sparkcontext.h" //! wxWidgets and zeitgeist both use a 'DECLARE_CLASS' macro *************** *** 110,114 **** void SparkGLCanvas::ResetSelection(wxDC& dc) { ! mRender.ResetSelection(); bool swapBuffers = true; --- 111,115 ---- void SparkGLCanvas::ResetSelection(wxDC& dc) { ! SparkContext::GetInstance().ResetSelection(); bool swapBuffers = true; *************** *** 150,154 **** } ! mRender.SetSelection(pickedNode); } --- 151,155 ---- } ! SparkContext::GetInstance().SetSelection(pickedNode); } Index: rsgedit.vcproj =================================================================== RCS file: /cvsroot/simspark/simspark/contrib/rsgedit/rsgedit.vcproj,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** rsgedit.vcproj 15 Mar 2007 07:26:24 -0000 1.2 --- rsgedit.vcproj 15 Apr 2007 10:31:04 -0000 1.3 *************** *** 264,267 **** --- 264,275 ---- </File> <File + RelativePath=".\sparkcontext.cpp" + > + </File> + <File + RelativePath=".\sparkcontext.h" + > + </File> + <File RelativePath=".\sparkglcanvas.cpp" > --- NEW FILE: sparkcontext.cpp --- /* -*- mode: c++; c-basic-offset: 4; indent-tabs-mode: nil -*- this file is part of rcssserver3D Fri May 9 2003 Copyright (C) 2003 Koblenz University $Id: sparkcontext.cpp,v 1.1 2007/04/15 10:31:09 rollmark Exp $ This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; version 2 of the License. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #include "sparkcontext.h" using namespace oxygen; using namespace boost; SparkContext::SparkContext() { } SparkContext::~SparkContext() { } SparkContext& SparkContext::GetInstance() { static SparkContext theInstance; return theInstance; } void SparkContext::SetSelection(weak_ptr<BaseNode> node) { mSelectedNode = node; } boost::weak_ptr<BaseNode> SparkContext::GetSelection() const { return mSelectedNode; } void SparkContext::ResetSelection() { mSelectedNode.reset(); } --- NEW FILE: sparkcontext.h --- /* -*- mode: c++; c-basic-offset: 4; indent-tabs-mode: nil -*- this file is part of rcssserver3D Fri May 9 2003 Copyright (C) 2003 Koblenz University $Id: sparkcontext.h,v 1.1 2007/04/15 10:31:11 rollmark Exp $ This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; version 2 of the License. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #ifndef SPARKCONTEXT_H__ #define SPARKCONTEXT_H__ #include <boost/shared_ptr.hpp> #include <boost/weak_ptr.hpp> namespace oxygen { class BaseNode; } class SparkContext { public: static SparkContext& GetInstance(); ~SparkContext(); void SetSelection(boost::weak_ptr<oxygen::BaseNode> node); boost::weak_ptr<oxygen::BaseNode> GetSelection() const; void ResetSelection(); private: SparkContext(); protected: boost::weak_ptr<oxygen::BaseNode> mSelectedNode; }; #endif // SPARKCONTEXT_H__ Index: sparkglrender.h =================================================================== RCS file: /cvsroot/simspark/simspark/contrib/rsgedit/sparkglrender.h,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** sparkglrender.h 9 Apr 2007 17:41:01 -0000 1.4 --- sparkglrender.h 15 Apr 2007 10:31:05 -0000 1.5 *************** *** 39,43 **** { class RenderServer; - class RenderNode; } --- 39,42 ---- *************** *** 51,57 **** void Render(int width, int height); - void SetSelection(boost::weak_ptr<kerosin::RenderNode> selection); - void ResetSelection(); - protected: void RenderSelection(); --- 50,53 ---- *************** *** 62,66 **** boost::shared_ptr<oxygen::SceneServer> mSceneServer; boost::shared_ptr<kerosin::RenderServer> mRenderServer; - boost::weak_ptr<kerosin::RenderNode> mSelectedNode; }; --- 58,61 ---- |