* lazzara/igr/gui/segmentation2dt/src/mean_regions_widget.cc,
* lazzara/igr/gui/segmentation2dt/src/mean_regions_widget.hh: Add
mouseclick support for function visualization.
---
milena/sandbox/ChangeLog | 8 +++
.../gui/segmentation2dt/src/mean_regions_widget.cc | 62 +++++++++++++++++++-
.../gui/segmentation2dt/src/mean_regions_widget.hh | 5 ++
3 files changed, 73 insertions(+), 2 deletions(-)
diff --git a/milena/sandbox/ChangeLog b/milena/sandbox/ChangeLog
index 4f62abc..07874a9 100644
--- a/milena/sandbox/ChangeLog
+++ b/milena/sandbox/ChangeLog
@@ -1,5 +1,13 @@
2010-11-15 Guillaume Lazzara <z(a)lrde.epita.fr>
+ Add function visualization in the mean region widget.
+
+ * lazzara/igr/gui/segmentation2dt/src/mean_regions_widget.cc,
+ * lazzara/igr/gui/segmentation2dt/src/mean_regions_widget.hh: Add
+ mouseclick support for function visualization.
+
+2010-11-15 Guillaume Lazzara <z(a)lrde.epita.fr>
+
Allow to save results filtered differently in the 3D segmentation
tool.
diff --git a/milena/sandbox/lazzara/igr/gui/segmentation2dt/src/mean_regions_widget.cc
b/milena/sandbox/lazzara/igr/gui/segmentation2dt/src/mean_regions_widget.cc
index 5a255fe..5756458 100644
--- a/milena/sandbox/lazzara/igr/gui/segmentation2dt/src/mean_regions_widget.cc
+++ b/milena/sandbox/lazzara/igr/gui/segmentation2dt/src/mean_regions_widget.cc
@@ -63,6 +63,16 @@ namespace igr
connect(viewer_, SIGNAL(slider_valueChanged(int)),
data_, SLOT(compute_new_mean_regions_image(int)));
+ // Plot widget related settings.
+ connect(viewer_->scene(), SIGNAL(mouse_pressed(const QPointF&)),
+ this, SLOT(mouse_click_slot(const QPointF&)));
+
+ connect(viewer_->scene(), SIGNAL(mouse_click(const QPointF&)),
+ this, SLOT(mouse_click_slot(const QPointF&)));
+
+ plot_widget_ = new plot_widget();
+ plot_widget_->hide();
+
emit task_ready();
}
@@ -75,6 +85,14 @@ namespace igr
disconnect(viewer_, SIGNAL(slider_valueChanged(int)),
data_, SLOT(compute_new_mean_regions_image(int)));
+ // Plot widget related settings.
+ disconnect(viewer_->scene(), SIGNAL(mouse_pressed(const QPointF&)),
+ this, SLOT(mouse_click_slot(const QPointF&)));
+
+ disconnect(viewer_->scene(), SIGNAL(mouse_click(const QPointF&)),
+ this, SLOT(mouse_click_slot(const QPointF&)));
+
+ delete plot_widget_;
}
@@ -93,14 +111,14 @@ namespace igr
bool mean_regions_widget::has_mouseover_data(const QPointF& p) const
{
point3d p3d(viewer_->current_slice(), p.y(), p.x());
- return data_->mean_regions().domain().has(p3d);
+ return data_->mean_regions_smooth().domain().has(p3d);
}
float mean_regions_widget::compute_mouseover_data(const QPointF& p) const
{
point3d p3d(viewer_->current_slice(), p.y(), p.x());
- return float(data_->mean_regions()(p3d));
+ return float(data_->mean_regions_smooth()(p3d));
}
@@ -109,11 +127,51 @@ namespace igr
disconnect(sender(), SIGNAL(finished()),
this, SLOT(task_finished_slot()));
+ // Preparing x data for plot widget.
+ xData_.resize(data_->mean_regions_smooth().nslis());
+ for (int i = 0; i < xData_.size(); ++i)
+ xData_[i] = i;
+
+
this->already_computed_ = true;
// Result already refreshed and displayed.
}
+ void mean_regions_widget::mouse_click_slot(const QPointF& p)
+ {
+ if (has_mouseover_data(p))
+ {
+ point3d p3d = point3d(0, p.y(), p.x());
+
+ plot_widget_->clear();
+
+ QString title(tr("Function for region %1").arg(data_->seg_smooth()(p3d)));
+ plot_widget_->set_title(title);
+
+ // Copy the data into the curves.
+
+ QwtArray<double> yData;
+ yData.resize(data_->in_nslis());
+
+ // Result of the morpholocial filter.
+ for (int i = 0; i < yData.size(); ++i, ++p3d[0])
+ yData[i] = data_->mean_regions_smooth()(p3d);
+
+ plot_widget_->add_curve(tr("Morphological filtering."),
+ xData_, yData, QPen(Qt::green, 3));
+
+ // Ready to replot.
+ plot_widget_->replot();
+
+
+ // Display result.
+ plot_widget_->show();
+ plot_widget_->raise();
+ }
+ }
+
+
} // end of namespace igr::segmentation
} // end of namespace igr
diff --git a/milena/sandbox/lazzara/igr/gui/segmentation2dt/src/mean_regions_widget.hh
b/milena/sandbox/lazzara/igr/gui/segmentation2dt/src/mean_regions_widget.hh
index 8d78cb5..6ff7a15 100644
--- a/milena/sandbox/lazzara/igr/gui/segmentation2dt/src/mean_regions_widget.hh
+++ b/milena/sandbox/lazzara/igr/gui/segmentation2dt/src/mean_regions_widget.hh
@@ -30,6 +30,7 @@
# include <ui_mean_regions_widget.h>
# include <src/task_widget.hh>
+# include <src/plot_widget.hh>
namespace igr
@@ -55,11 +56,15 @@ namespace igr
private slots:
void task_finished_slot();
+ void mouse_click_slot(const QPointF& p);
private: // Members
virtual void run_task_(task_handler& handler);
private: // Attributes
+ QwtArray<double> xData_;
+
+ plot_widget *plot_widget_;
};
--
1.5.6.5