From 10fae0f9392e3eaf390fd4cc0ac0a888b9d103e0 Mon Sep 17 00:00:00 2001 From: corredor <> Date: Wed, 5 May 2010 13:19:36 +0000 Subject: [PATCH] It is possible to center the view to the original point --- data/icons/wxart_centerview.xpm | 22 +++++++++++++++++++ .../wxVtkSceneManager.cxx | 17 +++++++++++++- .../wxVtkSceneManager.h | 2 ++ .../manualConnectorContourController.cxx | 5 ++++- .../bbtkwxGUIEditorGraphicBBS.cxx | 11 ++++++++++ .../bbtkwxGUIEditorGraphicBBS.h | 2 ++ .../wxGEditorTabPanel.cxx | 7 ++++++ .../bbsWxGUIEditorGraphic/wxGEditorTabPanel.h | 3 +++ .../wxTabPanelsManager.cxx | 7 ++++++ .../wxTabPanelsManager.h | 1 + 10 files changed, 75 insertions(+), 2 deletions(-) create mode 100644 data/icons/wxart_centerview.xpm diff --git a/data/icons/wxart_centerview.xpm b/data/icons/wxart_centerview.xpm new file mode 100644 index 0000000..4a987f6 --- /dev/null +++ b/data/icons/wxart_centerview.xpm @@ -0,0 +1,22 @@ +/* XPM */ +static const char * centerview_xpm[] = { +"17 15 3 1", +" c None", +". c #101010", +"+ c #404040", +" ............... ", +" . . ", +" . . ", +" . +++++++++ . ", +" . + + . ", +" . + + . ", +" . + + . ", +" . + + + . ", +" . + + . ", +" . + + . ", +" . + + . ", +" . +++++++++ . ", +" . . ", +" . . ", +" ............... ", +}; diff --git a/lib/EditorGraphicBBS/bbsKernelEditorGraphic/wxVtkSceneManager.cxx b/lib/EditorGraphicBBS/bbsKernelEditorGraphic/wxVtkSceneManager.cxx index 1e32532..57a0358 100644 --- a/lib/EditorGraphicBBS/bbsKernelEditorGraphic/wxVtkSceneManager.cxx +++ b/lib/EditorGraphicBBS/bbsKernelEditorGraphic/wxVtkSceneManager.cxx @@ -921,7 +921,7 @@ namespace bbtk //========================================================================= void wxVtkSceneManager::deleteAllBoxes() - { + { std::map::iterator it; for(it = _controllers.begin(); it != _controllers.end(); ++it) { @@ -942,6 +942,21 @@ namespace bbtk } //========================================================================= + + void wxVtkSceneManager::centerView() + { + double temp[3]; + _baseView->GetRenderer()->GetActiveCamera()->GetFocalPoint(temp); + printf("RaC wxVtkSceneManager::deleteAllBoxes() GetFocalPoint x:%f y:%f z:%f \n",temp[0],temp[1],temp[2]); + _baseView->GetRenderer()->GetActiveCamera()->SetFocalPoint(0,0,temp[2]); + _baseView->GetRenderer()->GetActiveCamera()->GetPosition(temp); + printf("RaC wxVtkSceneManager::deleteAllBoxes() GetPosition x:%f y:%f z:%f \n",temp[0],temp[1],temp[2]); + _baseView->GetRenderer()->GetActiveCamera()->SetPosition(0,0,temp[2]); + _baseView->RefreshView(); + + } + + //========================================================================= } // EO namespace bbtk diff --git a/lib/EditorGraphicBBS/bbsKernelEditorGraphic/wxVtkSceneManager.h b/lib/EditorGraphicBBS/bbsKernelEditorGraphic/wxVtkSceneManager.h index 0f795e8..d789c7a 100644 --- a/lib/EditorGraphicBBS/bbsKernelEditorGraphic/wxVtkSceneManager.h +++ b/lib/EditorGraphicBBS/bbsKernelEditorGraphic/wxVtkSceneManager.h @@ -117,6 +117,8 @@ namespace bbtk std::string getDiagramScript(); void deleteObject(int id); void deleteAllBoxes(); + + void centerView(); void refreshScene(); diff --git a/lib/EditorGraphicBBS/bbsVtkGUIEditorGraphic/manualConnectorContourController.cxx b/lib/EditorGraphicBBS/bbsVtkGUIEditorGraphic/manualConnectorContourController.cxx index 6a7c068..0a35264 100644 --- a/lib/EditorGraphicBBS/bbsVtkGUIEditorGraphic/manualConnectorContourController.cxx +++ b/lib/EditorGraphicBBS/bbsVtkGUIEditorGraphic/manualConnectorContourController.cxx @@ -128,7 +128,10 @@ namespace bbtk { ok=true; _bakIdPoint = GetManualViewBaseContour()->GetIdPoint(x,y,z); - SetState(5); + if(_bakIdPoint!=0 && _bakIdPoint!=GetManualViewBaseContour()->GetNumberOfPoints()-1) + { + SetState(5); + } } // If nothing selected _state=7 if ( (GetState()==0) && (GetManualViewBaseContour()->GetIdPoint(x,y,z)==-1 ) ) diff --git a/lib/EditorGraphicBBS/bbsWxGUIEditorGraphic/bbtkwxGUIEditorGraphicBBS.cxx b/lib/EditorGraphicBBS/bbsWxGUIEditorGraphic/bbtkwxGUIEditorGraphicBBS.cxx index 7f8e8ac..8d63e0d 100644 --- a/lib/EditorGraphicBBS/bbsWxGUIEditorGraphic/bbtkwxGUIEditorGraphicBBS.cxx +++ b/lib/EditorGraphicBBS/bbsWxGUIEditorGraphic/bbtkwxGUIEditorGraphicBBS.cxx @@ -88,6 +88,7 @@ namespace bbtk wxBitmap bmp_new(new_xpm); wxBitmap bmp_run(run_xpm); wxBitmap bmp_delete(delete_xpm); + wxBitmap bmp_centerview(centerview_xpm); wxToolBar *_toolbar = new wxToolBar(this, wxID_ANY); @@ -95,6 +96,7 @@ namespace bbtk _toolbar->AddTool(1000,_T("New"),bmp_new, wxNullBitmap, wxITEM_NORMAL,_T("New tab"), _T("Create a new panel tab")); _toolbar->AddTool(1001,_T("Execute"),bmp_run, wxNullBitmap, wxITEM_NORMAL,_T("Execute actual diagram"), _T("Execute actual diagram")); _toolbar->AddTool(1002,_T("Delete all"),bmp_delete, wxNullBitmap, wxITEM_NORMAL,_T("Delete all boxes"), _T("Delete all boxes")); + _toolbar->AddTool(1003,_T("Center view"),bmp_centerview, wxNullBitmap, wxITEM_NORMAL,_T("Center view"), _T("Center view")); _toolbar->SetMargins( 2, 2 ); _toolbar->Realize(); @@ -104,6 +106,7 @@ namespace bbtk Connect(1000,wxEVT_COMMAND_TOOL_CLICKED,wxCommandEventHandler(wxGUIEditorGraphicBBS::OnCreateNewTab)); Connect(1001,wxEVT_COMMAND_TOOL_CLICKED,wxCommandEventHandler(wxGUIEditorGraphicBBS::OnExecuteActualDiagram)); Connect(1002,wxEVT_COMMAND_TOOL_CLICKED,wxCommandEventHandler(wxGUIEditorGraphicBBS::OnDeleteAllBoxesActualDiagram)); + Connect(1003,wxEVT_COMMAND_TOOL_CLICKED,wxCommandEventHandler(wxGUIEditorGraphicBBS::OnCenterViewActualDiagram)); } //========================================================================= @@ -362,12 +365,20 @@ namespace bbtk //========================================================================= + void wxGUIEditorGraphicBBS::OnCenterViewActualDiagram(wxCommandEvent& event) + { + _tabsMgr->centerViewActualDiagram(); + } + + //========================================================================= + void wxGUIEditorGraphicBBS::OnExit(wxCommandEvent& event) { Close(true); } + } // EO namespace bbtk // EOF diff --git a/lib/EditorGraphicBBS/bbsWxGUIEditorGraphic/bbtkwxGUIEditorGraphicBBS.h b/lib/EditorGraphicBBS/bbsWxGUIEditorGraphic/bbtkwxGUIEditorGraphicBBS.h index 2994c61..46dfd39 100644 --- a/lib/EditorGraphicBBS/bbsWxGUIEditorGraphic/bbtkwxGUIEditorGraphicBBS.h +++ b/lib/EditorGraphicBBS/bbsWxGUIEditorGraphic/bbtkwxGUIEditorGraphicBBS.h @@ -51,6 +51,7 @@ #include "wxart_new.xpm" // JPR #include "wxart_run.xpm" #include "wxart_delete.xpm" +#include "wxart_centerview.xpm" //Includes creaMaracasVisu @@ -110,6 +111,7 @@ namespace bbtk void OnCreateNewTab(wxCommandEvent& event); void OnExecuteActualDiagram(wxCommandEvent& event); void OnDeleteAllBoxesActualDiagram(wxCommandEvent& event); + void OnCenterViewActualDiagram(wxCommandEvent& event); void OnExit(wxCommandEvent& event); diff --git a/lib/EditorGraphicBBS/bbsWxGUIEditorGraphic/wxGEditorTabPanel.cxx b/lib/EditorGraphicBBS/bbsWxGUIEditorGraphic/wxGEditorTabPanel.cxx index 66dd7b0..97a3d3a 100644 --- a/lib/EditorGraphicBBS/bbsWxGUIEditorGraphic/wxGEditorTabPanel.cxx +++ b/lib/EditorGraphicBBS/bbsWxGUIEditorGraphic/wxGEditorTabPanel.cxx @@ -147,6 +147,13 @@ namespace bbtk //========================================================================= + void wxGEditorTabPanel::centerView() + { + _sceneManager->centerView(); + } + + //========================================================================= + } // EO namespace bbtk // EOF diff --git a/lib/EditorGraphicBBS/bbsWxGUIEditorGraphic/wxGEditorTabPanel.h b/lib/EditorGraphicBBS/bbsWxGUIEditorGraphic/wxGEditorTabPanel.h index a50bda3..3f6e699 100644 --- a/lib/EditorGraphicBBS/bbsWxGUIEditorGraphic/wxGEditorTabPanel.h +++ b/lib/EditorGraphicBBS/bbsWxGUIEditorGraphic/wxGEditorTabPanel.h @@ -85,6 +85,9 @@ namespace bbtk void editBlackBox(GBlackBoxModel *bbmodel); void editDiagramParameters(wxVtkSceneManager* scene); void deleteAllBoxes(); + void centerView(); + + //========================================================================= private: diff --git a/lib/EditorGraphicBBS/bbsWxGUIEditorGraphic/wxTabPanelsManager.cxx b/lib/EditorGraphicBBS/bbsWxGUIEditorGraphic/wxTabPanelsManager.cxx index 6f6b9e9..e6c91c1 100644 --- a/lib/EditorGraphicBBS/bbsWxGUIEditorGraphic/wxTabPanelsManager.cxx +++ b/lib/EditorGraphicBBS/bbsWxGUIEditorGraphic/wxTabPanelsManager.cxx @@ -124,6 +124,13 @@ namespace bbtk //========================================================================= + void wxTabPanelsManager::centerViewActualDiagram() + { + _actual->centerView(); + } + + //========================================================================= + } // EO namespace bbtk // EOF diff --git a/lib/EditorGraphicBBS/bbsWxGUIEditorGraphic/wxTabPanelsManager.h b/lib/EditorGraphicBBS/bbsWxGUIEditorGraphic/wxTabPanelsManager.h index b41f027..05b8b7c 100644 --- a/lib/EditorGraphicBBS/bbsWxGUIEditorGraphic/wxTabPanelsManager.h +++ b/lib/EditorGraphicBBS/bbsWxGUIEditorGraphic/wxTabPanelsManager.h @@ -78,6 +78,7 @@ namespace bbtk void editBlackBox(GBlackBoxModel *bbmodel); void editDiagramParameters(wxVtkSceneManager* scene); void deleteAllBoxesActualDiagram(); + void centerViewActualDiagram(); private: -- 2.45.1