diff --git a/modules/gfx/pymod/export_map.cc b/modules/gfx/pymod/export_map.cc index 00ffbf165792dffffa848399b40500920c9f2171..62dcb4ca7550a3f19a8e82a01cee34a592e2846f 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 9c7f1c878096954621b46e24351a8c2f515d1efa..87662056b2602bd77035264a5032566d0770ca5d 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 c69979ef06aa9b9bc8082638ce27db1b8fcd32cd..d69cfe76036277795dc4869db12fcc9e75f5add5 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 edcc057b2342298793460df763b50599f298e532..3bb9dbf196e96518dd13c442a444972b5cb223bc 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 f6c7c84c8e38e89c02badf3632c9275bdeea3fa5..9e3115b8be6ddbb32076bab9045bb319002a60ba 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 748d194bd7df8fe3b115daa5196eb9e5e1ccc4ed..77138a273258f6db01529c5bd24597835cafcf43 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");