|
From: Markus R. <rol...@us...> - 2007-05-17 17:49:29
|
Update of /cvsroot/simspark/simspark/contrib/rsgedit In directory sc8-pr-cvs8.sourceforge.net:/tmp/cvs-serv17034/contrib/rsgedit Modified Files: constants.h mainframe.cpp mainframe.h property.cpp propertyframe.cpp propertylist.cpp rsgedit.rb rsgedit.wxg sparkcontext.cpp sparkcontext.h sparktree.cpp sparktree.h Log Message: Index: constants.h =================================================================== RCS file: /cvsroot/simspark/simspark/contrib/rsgedit/constants.h,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** constants.h 15 Apr 2007 12:18:20 -0000 1.5 --- constants.h 17 May 2007 17:49:23 -0000 1.6 *************** *** 48,52 **** ID_AGENT_KILL = (wxID_HIGHEST+28), ! ID_SPARK_CONTEXT = (wxID_HIGHEST+29) }; --- 48,57 ---- ID_AGENT_KILL = (wxID_HIGHEST+28), ! ID_SPARK_CONTEXT = (wxID_HIGHEST+29), ! ! ID_CONTEXT_PROPERTIES = (wxID_HIGHEST+30), ! ID_CONTEXT_EDIT_SOURCE = (wxID_HIGHEST+31), ! ID_CONTEXT_COPY_FILENAME = (wxID_HIGHEST+32), ! ID_CONTEXT_COPY_PATH = (wxID_HIGHEST+33) }; Index: mainframe.h =================================================================== RCS file: /cvsroot/simspark/simspark/contrib/rsgedit/mainframe.h,v retrieving revision 1.12 retrieving revision 1.13 diff -C2 -d -r1.12 -r1.13 *** mainframe.h 15 Apr 2007 11:16:11 -0000 1.12 --- mainframe.h 17 May 2007 17:49:23 -0000 1.13 *************** *** 28,31 **** --- 28,32 ---- #include "sparktree.h" #include "propertylist.h" + #include <oxygen/sceneserver/scenedict.h> #ifndef MAINFRAME_H *************** *** 101,104 **** --- 102,110 ---- void OnHelpAbout(wxCommandEvent& event); + void OnContextProperties(wxCommandEvent& event); + void OnContextEditSource(wxCommandEvent& event); + void OnContextCopyFileName(wxCommandEvent& event); + void OnContextCopyPath(wxCommandEvent& event); + void OnExit(wxCommandEvent& event); void OnClose( wxCloseEvent& event ); *************** *** 145,148 **** --- 151,162 ---- void UpdateCached(); + /** edit the given file starting at the given line */ + void EditFile(const wxString& fname, int line); + + /** lookup the FileRef for the context node */ + const oxygen::SceneDict::FileRef* GetContextFileRef(); + + /** copy the given string to the sytem clipboard */ + void CopyToClipboard(const wxString& str) const; protected: Index: propertyframe.cpp =================================================================== RCS file: /cvsroot/simspark/simspark/contrib/rsgedit/propertyframe.cpp,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** propertyframe.cpp 15 Mar 2007 07:26:24 -0000 1.3 --- propertyframe.cpp 17 May 2007 17:49:23 -0000 1.4 *************** *** 48,52 **** // begin wxGlade: propertyframe::set_properties SetTitle(wxT("frame_1")); ! SetSize(wxSize(300, 150)); // end wxGlade } --- 48,52 ---- // begin wxGlade: propertyframe::set_properties SetTitle(wxT("frame_1")); ! SetSize(wxSize(400, 150)); // end wxGlade } Index: sparktree.cpp =================================================================== RCS file: /cvsroot/simspark/simspark/contrib/rsgedit/sparktree.cpp,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** sparktree.cpp 25 Apr 2007 20:08:43 -0000 1.7 --- sparktree.cpp 17 May 2007 17:49:23 -0000 1.8 *************** *** 262,263 **** --- 262,287 ---- return true; } + + void SparkTree::MarkItemInternal(const wxTreeItemId id, bool mark) + { + if (! id.IsOk()) + { + return; + } + if (mark) + { + mTree->SetItemTextColour(id, wxColour(230, 26, 230)); + mTree->SetItemBold(id,true); + } else + { + mTree->SetItemTextColour(id, wxNullColour); + mTree->SetItemBold(id,false); + } + } + + void SparkTree::MarkItem(const wxTreeItemId id) + { + MarkItemInternal(mLastMarkedNode,false); + MarkItemInternal(id, true); + mLastMarkedNode = id; + } Index: rsgedit.wxg =================================================================== RCS file: /cvsroot/simspark/simspark/contrib/rsgedit/rsgedit.wxg,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** rsgedit.wxg 15 Mar 2007 07:26:24 -0000 1.5 --- rsgedit.wxg 17 May 2007 17:49:23 -0000 1.6 *************** *** 1,4 **** <?xml version="1.0"?> ! <!-- generated by wxGlade 0.4.1 on Tue Mar 06 22:13:36 2007 --> <application path="." name="" class="" option="1" language="C++" top_window="MainFrame" encoding="UTF-8" use_gettext="0" overwrite="0" use_new_namespace="1" for_version="2.6"> --- 1,4 ---- <?xml version="1.0"?> ! <!-- generated by wxGlade 0.4.1 on Tue May 01 10:32:21 2007 --> <application path="." name="" class="" option="1" language="C++" top_window="MainFrame" encoding="UTF-8" use_gettext="0" overwrite="0" use_new_namespace="1" for_version="2.6"> *************** *** 180,184 **** <style>wxCAPTION|wxCLOSE_BOX|wxMINIMIZE_BOX|wxMAXIMIZE_BOX|wxSYSTEM_MENU|wxRESIZE_BORDER|wxFRAME_NO_TASKBAR|wxFRAME_FLOAT_ON_PARENT|wxCLIP_CHILDREN</style> <title>frame_1</title> ! <size>300, 150</size> <object class="wxBoxSizer" name="sizer_3" base="EditBoxSizer"> <orient>wxVERTICAL</orient> --- 180,184 ---- <style>wxCAPTION|wxCLOSE_BOX|wxMINIMIZE_BOX|wxMAXIMIZE_BOX|wxSYSTEM_MENU|wxRESIZE_BORDER|wxFRAME_NO_TASKBAR|wxFRAME_FLOAT_ON_PARENT|wxCLIP_CHILDREN</style> <title>frame_1</title> ! <size>400, 150</size> <object class="wxBoxSizer" name="sizer_3" base="EditBoxSizer"> <orient>wxVERTICAL</orient> Index: propertylist.cpp =================================================================== RCS file: /cvsroot/simspark/simspark/contrib/rsgedit/propertylist.cpp,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** propertylist.cpp 22 Jan 2006 17:24:45 -0000 1.1 --- propertylist.cpp 17 May 2007 17:49:23 -0000 1.2 *************** *** 90,93 **** --- 90,94 ---- } + mCtrList->Freeze(); bool valRefresh = *************** *** 111,115 **** if (valRefresh) { ! // just refresh values to prevent flicker mCtrList->SetItem(line, 1, entry.value); } else --- 112,116 ---- if (valRefresh) { ! // just refresh values mCtrList->SetItem(line, 1, entry.value); } else *************** *** 122,124 **** --- 123,127 ---- ++line; } + + mCtrList->Thaw(); } Index: rsgedit.rb =================================================================== RCS file: /cvsroot/simspark/simspark/contrib/rsgedit/rsgedit.rb,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** rsgedit.rb 26 Apr 2007 17:54:05 -0000 1.8 --- rsgedit.rb 17 May 2007 17:49:23 -0000 1.9 *************** *** 34,37 **** --- 34,41 ---- run "bindings.rb" + # register from which rsg file nodes were created + rubySceneImporter = get($serverPath+'scene/RubySceneImporter') + rubySceneImporter.enableSceneDictionary(true); + # create custom materials material = new('kerosin/MaterialSolid', $serverPath+'material/matYellow'); Index: sparkcontext.cpp =================================================================== RCS file: /cvsroot/simspark/simspark/contrib/rsgedit/sparkcontext.cpp,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** sparkcontext.cpp 15 Apr 2007 11:17:08 -0000 1.3 --- sparkcontext.cpp 17 May 2007 17:49:23 -0000 1.4 *************** *** 20,25 **** --- 20,30 ---- #include "sparkcontext.h" #include "sparkcontextevent.h" + #include "constants.h" + #include <wx/menu.h> + #include <zeitgeist/leaf.h> + #include <oxygen/sceneserver/scenedict.h> using namespace zeitgeist; + using namespace oxygen; using namespace boost; *************** *** 77,78 **** --- 82,117 ---- return mEventId; } + + wxMenu* SparkContext::GetContextMenu(weak_ptr<Leaf> leaf) + { + if (leaf.expired()) + { + assert(false); + return 0; + } + + mContextNode = leaf; + + long style = 0; + wxMenu* menu(new wxMenu(leaf.lock()->GetFullPath(), 0)); + + menu->Append(ID_CONTEXT_COPY_PATH, wxT("&Copy node path")); + + const SceneDict::FileRef* ref = SceneDict::GetInstance().Lookup(leaf); + if (ref != 0) + { + menu->AppendSeparator(); + menu->Append(ID_CONTEXT_COPY_FILENAME, wxT("C&opy filename")); + menu->Append(ID_CONTEXT_EDIT_SOURCE, wxT("&Edit source file")); + } + + menu->AppendSeparator(); + menu->Append(ID_CONTEXT_PROPERTIES, wxT("&Properties")); + + return menu; + } + + weak_ptr<Leaf> SparkContext::GetContextNode() const + { + return mContextNode; + } Index: mainframe.cpp =================================================================== RCS file: /cvsroot/simspark/simspark/contrib/rsgedit/mainframe.cpp,v retrieving revision 1.16 retrieving revision 1.17 diff -C2 -d -r1.16 -r1.17 *** mainframe.cpp 15 Apr 2007 11:49:06 -0000 1.16 --- mainframe.cpp 17 May 2007 17:49:23 -0000 1.17 *************** *** 26,30 **** --- 26,32 ---- #include <wx/filename.h> + #include <wx/mimetype.h> #include <wx/filedlg.h> + #include <wx/clipbrd.h> #include <rsgedit/res/xpm_play.xpm> *************** *** 78,81 **** --- 80,88 ---- EVT_MENU(ID_HELP_ABOUT, mainframe::OnHelpAbout) + EVT_MENU(ID_CONTEXT_PROPERTIES, mainframe::OnContextProperties) + EVT_MENU(ID_CONTEXT_EDIT_SOURCE, mainframe::OnContextEditSource) + EVT_MENU(ID_CONTEXT_COPY_FILENAME, mainframe::OnContextCopyFileName) + EVT_MENU(ID_CONTEXT_COPY_PATH, mainframe::OnContextCopyPath) + EVT_TIMER(TI_LOG, mainframe::OnLogTimer) EVT_TIMER(TI_FPS, mainframe::OnFPSTimer) *************** *** 602,605 **** --- 609,625 ---- { shared_ptr<Leaf> leaf = mSparkTree.GetLeaf(event.GetItem()).lock(); + wxMenu* context = SparkContext::GetInstance().GetContextMenu(leaf); + + if (context == 0) + { + return; + } + + PopupMenu(context); + } + + void mainframe::OnTreeItemActivated(wxTreeEvent& event) + { + shared_ptr<Leaf> leaf = mSparkTree.GetLeaf(event.GetItem()).lock(); if (leaf.get() == 0) { *************** *** 607,611 **** } ! wxString location(leaf->GetFullPath().c_str(), wxConvUTF8); propertyframe* frame(new propertyframe(this, wxID_ANY, location)); --- 627,644 ---- } ! SparkContext::GetInstance().SetSelection(leaf); ! } ! ! ! void mainframe::OnContextProperties(wxCommandEvent& event) ! { ! weak_ptr<Leaf> leaf = SparkContext::GetInstance().GetContextNode(); ! if (leaf.expired()) ! { ! assert(false); ! return; ! } ! ! wxString location(leaf.lock()->GetFullPath().c_str(), wxConvUTF8); propertyframe* frame(new propertyframe(this, wxID_ANY, location)); *************** *** 615,627 **** } ! void mainframe::OnTreeItemActivated(wxTreeEvent& event) { ! shared_ptr<Leaf> leaf = mSparkTree.GetLeaf(event.GetItem()).lock(); ! if (leaf.get() == 0) { return; } ! SparkContext::GetInstance().SetSelection(leaf); } --- 648,726 ---- } ! void mainframe::OnContextEditSource(wxCommandEvent& event) { ! const SceneDict::FileRef* ref = GetContextFileRef(); ! if (ref == 0) ! { ! assert(false); ! return; ! } ! ! EditFile(ref->fname, ref->line); ! } ! ! void mainframe::OnContextCopyFileName(wxCommandEvent& event) ! { ! const SceneDict::FileRef* ref = GetContextFileRef(); ! if (ref == 0) ! { ! assert(false); ! return; ! } ! ! wxFileName fn(ref->fname.c_str()); ! fn.Normalize(); ! CopyToClipboard(fn.GetFullPath()); ! } ! ! void mainframe::OnContextCopyPath(wxCommandEvent& event) ! { ! weak_ptr<Leaf> leaf = SparkContext::GetInstance().GetContextNode(); ! if (leaf.expired()) { + assert(false); return; } ! CopyToClipboard(leaf.lock()->GetFullPath()); ! } ! ! const SceneDict::FileRef* mainframe::GetContextFileRef() ! { ! weak_ptr<Leaf> leaf = SparkContext::GetInstance().GetContextNode(); ! if (leaf.expired()) ! { ! assert(false); ! return 0; ! } ! ! return SceneDict::GetInstance().Lookup(leaf); ! } ! ! void mainframe::CopyToClipboard(const wxString& str) const ! { ! wxTheClipboard->Open(); ! wxTheClipboard->SetData(new wxTextDataObject(str)); ! wxTheClipboard->Close(); ! } ! ! void mainframe::EditFile(const wxString& fname, int line) ! { ! wxFileType *ft = wxTheMimeTypesManager->GetFileTypeFromMimeType("text/plain"); ! if (ft == 0) ! { ! return; ! } ! ! wxFileName fn(fname); ! fn.Normalize(); ! ! wxString cmd = ft->GetOpenCommand(fn.GetFullPath()); ! if (cmd.IsEmpty()) ! { ! return; ! } ! ! wxExecute(cmd); } *************** *** 859,868 **** case SparkContextEvent::T_SELECTION_CHANGED: ! // redraw gl canvas ! bool swapBuffers = true; ! wxClientDC dc(this); ! mCanvas->Render(dc, swapBuffers); ! mSparkTree.SelectLeaf(SparkContext::GetInstance().GetSelection()); ! break; } } --- 958,978 ---- case SparkContextEvent::T_SELECTION_CHANGED: ! { ! // redraw gl canvas ! bool swapBuffers = true; ! wxClientDC dc(this); ! mCanvas->Render(dc, swapBuffers); ! ! weak_ptr<Leaf> leaf = SparkContext::GetInstance().GetSelection(); ! if (mSparkTree.SelectLeaf(leaf)) ! { ! mSparkTree.MarkItem(mCtrTree->GetSelection()); ! } else ! { ! mSparkTree.MarkItem(wxTreeItemId()); ! } ! ! break; ! } } } Index: sparkcontext.h =================================================================== RCS file: /cvsroot/simspark/simspark/contrib/rsgedit/sparkcontext.h,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** sparkcontext.h 15 Apr 2007 11:17:10 -0000 1.3 --- sparkcontext.h 17 May 2007 17:49:23 -0000 1.4 *************** *** 30,33 **** --- 30,34 ---- class wxEvtHandler; + class wxMenu; class SparkContext *************** *** 45,48 **** --- 46,52 ---- int GetEventId(); + wxMenu* GetContextMenu(boost::weak_ptr<zeitgeist::Leaf> leaf); + boost::weak_ptr<zeitgeist::Leaf> GetContextNode() const; + private: SparkContext(); *************** *** 52,55 **** --- 56,62 ---- boost::weak_ptr<zeitgeist::Leaf> mSelectedNode; + //! the node that context menu commands refer to + boost::weak_ptr<zeitgeist::Leaf> mContextNode; + //! assigned event notification target wxEvtHandler* mEventHandler; Index: sparktree.h =================================================================== RCS file: /cvsroot/simspark/simspark/contrib/rsgedit/sparktree.h,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** sparktree.h 15 Apr 2007 11:48:42 -0000 1.4 --- sparktree.h 17 May 2007 17:49:23 -0000 1.5 *************** *** 54,60 **** --- 54,63 ---- bool SelectLeaf(boost::weak_ptr<zeitgeist::Leaf> leaf); + void MarkItem(const wxTreeItemId id); + protected: void SetItemData(wxTreeItemId id, boost::weak_ptr<zeitgeist::Leaf> leaf); ItemData* GetItemData(wxTreeItemId id); + void MarkItemInternal(const wxTreeItemId id, bool mark); protected: *************** *** 62,65 **** --- 65,69 ---- boost::shared_ptr<zeitgeist::Core> mCore; wxTreeItemId mRootId; + wxTreeItemId mLastMarkedNode; }; Index: property.cpp =================================================================== RCS file: /cvsroot/simspark/simspark/contrib/rsgedit/property.cpp,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** property.cpp 19 Feb 2006 15:45:37 -0000 1.8 --- property.cpp 17 May 2007 17:49:23 -0000 1.9 *************** *** 33,36 **** --- 33,37 ---- #include <oxygen/sceneserver/basenode.h> #include <oxygen/sceneserver/transform.h> + #include <oxygen/sceneserver/scenedict.h> #include <oxygen/physicsserver/body.h> #include <oxygen/physicsserver/joint.h> *************** *** 117,120 **** --- 118,133 ---- { entries.push_back(Entry(_T("GetFullPath"), wxString(leaf->GetFullPath().c_str(), wxConvUTF8))); + + const SceneDict::FileRef* ref + = SceneDict::GetInstance().Lookup(leaf); + + if (ref == 0) + { + return; + } + + wxString strRef = wxString(ref->fname.c_str(), wxConvUTF8) + + wxString::Format(":%d",ref->line); + entries.push_back(Entry(_T("rsg file"), strRef)); } |