From b4439554663e6006464cf6b429f51ebe6da58af4 Mon Sep 17 00:00:00 2001 From: valerio <valerio@5a81b35b-ba03-0410-adc8-b2c5c5119f08> Date: Thu, 8 Apr 2010 13:56:35 +0000 Subject: [PATCH] Context menu entry in scene menu to View Density Slices for map_isos git-svn-id: https://dng.biozentrum.unibas.ch/svn/openstructure/trunk@1949 5a81b35b-ba03-0410-adc8-b2c5c5119f08 --- modules/gfx/pymod/export_map.cc | 1 + modules/gfx/src/map_iso.cc | 6 +++++ modules/gfx/src/map_iso.hh | 5 ++++ modules/gui/src/scene_selection.cc | 30 +++++++++++++++++++++++ modules/gui/src/scene_selection.hh | 1 + modules/gui/src/scene_win/context_menu.cc | 16 ++++++++++++ 6 files changed, 59 insertions(+) diff --git a/modules/gfx/pymod/export_map.cc b/modules/gfx/pymod/export_map.cc index 00ffbf165..62dcb4ca7 100644 --- a/modules/gfx/pymod/export_map.cc +++ b/modules/gfx/pymod/export_map.cc @@ -55,6 +55,7 @@ void export_Map() .def("SetLevel",&MapIso::SetLevel) .def("GetLevel",&MapIso::GetLevel) .def("GetMean", &MapIso::GetMean) + .def("GetMap", &MapIso::GetMap,return_value_policy<reference_existing_object>()) .def("Rebuild", &MapIso::Rebuild) .def("SetNSF",&MapIso::SetNSF) .def("SetColor", &MapIso::SetColor) diff --git a/modules/gfx/src/map_iso.cc b/modules/gfx/src/map_iso.cc index 9c7f1c878..87662056b 100644 --- a/modules/gfx/src/map_iso.cc +++ b/modules/gfx/src/map_iso.cc @@ -272,6 +272,12 @@ float MapIso::GetStdDev() const return stat.GetStandardDeviation(); } +img::ImageHandle& MapIso::GetMap() +{ + return mh_; +} + + float MapIso::GetMean() const { img::alg::Stat stat; diff --git a/modules/gfx/src/map_iso.hh b/modules/gfx/src/map_iso.hh index c69979ef0..d69cfe760 100644 --- a/modules/gfx/src/map_iso.hh +++ b/modules/gfx/src/map_iso.hh @@ -76,6 +76,11 @@ public: /// \brief get std dev of map. float GetStdDev() const; + /// \brief get the map handle + // The following is a hack. For the DataViewer I need to pass a reference to an ImagHandle + // that never goes out of scope, so I get a reference from here + img::ImageHandle& GetMap(); + /// \brief set color /// /// By default, the color is white. diff --git a/modules/gui/src/scene_selection.cc b/modules/gui/src/scene_selection.cc index edcc057b2..3bb9dbf19 100644 --- a/modules/gui/src/scene_selection.cc +++ b/modules/gui/src/scene_selection.cc @@ -27,6 +27,14 @@ #include <ost/gfx/gfx_object.hh> #include <ost/gfx/entity.hh> +#if OST_IMG_ENABLED + +#include <ost/gfx/map_iso.hh> +#include <ost/gui/main_area.hh> +#include <ost/gui/perspective.hh> + +#endif + #include <ost/gui/gosty_app.hh> #include <ost/gui/scene_win/scene_win.hh> #include <ost/gui/query_dialog.hh> @@ -126,6 +134,28 @@ void SceneSelection::Delete() { } } +#if OST_IMG_ENABLED + +void SceneSelection::ViewDensitySlices() { + for(unsigned int i = 0; i < nodes_.size(); i++){ + gfx::GfxNodeP node = nodes_[i]; + if (node) { + gfx::MapIsoP obj = dyn_cast<gfx::MapIso> (node); + if (obj) { + // The following is a hack. I need to pass a reference to an ImagHandle + // that never goes out of scope, so I get a reference from the MapIso using + // GetMap and pass it to the CreateDataViewer + img::gui::DataViewer* dv = GostyApp::Instance()->CreateDataViewer(obj->GetMap()); + MainArea* ma = GostyApp::Instance()->GetPerspective()->GetMainArea(); + ma->AddWidget(QString(obj->GetName().c_str()), dv) ; + dv->show(); + } + } + } +} + +#endif // OST_IMG_ENABLED + void SceneSelection::Select() { QueryDialog d; if (d.exec() == QDialog::Accepted) { diff --git a/modules/gui/src/scene_selection.hh b/modules/gui/src/scene_selection.hh index f6c7c84c8..9e3115b8b 100644 --- a/modules/gui/src/scene_selection.hh +++ b/modules/gui/src/scene_selection.hh @@ -44,6 +44,7 @@ public: public slots: void CenterOnObjects(); void Delete(); + void ViewDensitySlices(); void CopyViews(); void Select(); void Deselect(); diff --git a/modules/gui/src/scene_win/context_menu.cc b/modules/gui/src/scene_win/context_menu.cc index 748d194bd..77138a273 100644 --- a/modules/gui/src/scene_win/context_menu.cc +++ b/modules/gui/src/scene_win/context_menu.cc @@ -29,6 +29,10 @@ #include <ost/gui/scene_selection.hh> #include <ost/gui/query_dialog.hh> +#if OST_IMG_ENABLED +#include <ost/gfx/map_iso.hh> +#endif // OST_IMG_ENABLED + #include "custom_part_node.hh" #include "entity_node.hh" #include "entity_part_node.hh" @@ -55,6 +59,7 @@ void ContextMenu::ShowMenu(const QPoint& pos) bool all_gfx_objects = true; bool all_entity_views = true; bool all_custom_views = true; + bool all_maps = true; if(indexes.size()>0){ for(int i = 0; i < indexes.size(); i++){ @@ -67,6 +72,7 @@ void ContextMenu::ShowMenu(const QPoint& pos) if(gfx_node->GetType()==0){all_not_scene = false;} if(!dynamic_cast<gfx::GfxObj*> (gfx_node.get())){all_gfx_objects = false;} if(!dynamic_cast<gfx::Entity*> (gfx_node.get())){all_entities = false;} + if(!dynamic_cast<gfx::MapIso*> (gfx_node.get())){all_maps = false;} } else{ all_gfx_objects = false; @@ -148,6 +154,16 @@ void ContextMenu::ShowMenu(const QPoint& pos) } + #if OST_IMG_ENABLED + + if(all_maps){ + action = menu->addAction("View Density Slices"); + connect(action, SIGNAL(triggered()), SceneSelection::Instance(), SLOT(ViewDensitySlices())); + } + + #endif // OST_IMG_ENABLED + + if(all_entity_views){ if(all_custom_views){ action = menu->addAction("Delete"); -- GitLab