[med-svn] [SCM] aghermann branch, master, updated. c0bd21ca8eb529ade7e0c7aad22951a308a8dc8f

Andrei Zavada johnhommer at gmail.com
Wed May 1 00:09:49 UTC 2013


The following commit has been merged in the master branch:
commit e0a68d83dacf64566502d258d068085578c764be
Author: Andrei Zavada <johnhommer at gmail.com>
Date:   Wed May 1 02:37:07 2013 +0300

    simplify ui->expdesign shortcuts in SScoringFacility::SChannel

diff --git a/src/ui/sf/channel.cc b/src/ui/sf/channel.cc
index ef1ce26..6038024 100644
--- a/src/ui/sf/channel.cc
+++ b/src/ui/sf/channel.cc
@@ -32,12 +32,10 @@ SChannel (agh::CRecording& r,
 	  SScoringFacility& parent,
 	  size_t y0,
 	  int seq)
-      : name (r.channel()),
-	crecording (r),
-	_h (r.F().channel_id(name)),
-	filters (r.F().filters( _h)),
-	annotations (r.F().annotations(_h)),
-	artifacts (r.F().artifacts(_h)),
+      : crecording (r),
+	filters (r.F().filters(h())),
+	annotations (r.F().annotations(h())),
+	artifacts (r.F().artifacts(r.h())),
 	_p (parent),
 	signal_lowpass  ({signal_filtered, samplerate()}),
 	signal_bandpass ({signal_filtered, samplerate()}),
@@ -164,7 +162,7 @@ aghui::SScoringFacility::SChannel::
 get_signal_original()
 {
 	signal_original =
-		crecording.F().get_signal_original( _h);
+		crecording.F().get_signal_original( h());
 	// signal_original_resampled =
 	// 	sigproc::resample( signal_original, 0, signal_original.size(),
 	// 			   signal_original.size() / spp());
@@ -178,7 +176,7 @@ aghui::SScoringFacility::SChannel::
 get_signal_filtered()
 {
 	signal_filtered =
-		crecording.F().get_signal_filtered( _h);
+		crecording.F().get_signal_filtered( h());
 	// filtered is already zeromean as shipped
 	drop_cached_signal_properties();
 }
@@ -193,7 +191,6 @@ aghui::SScoringFacility::SChannel::
 in_annotations( const double time) const
 {
 	// select this channel's annotations
-	auto& annotations = crecording.F().annotations(_h);
 	list<sigfile::SAnnotation*>
 		ret;
 	for ( auto &A : annotations )
@@ -367,8 +364,7 @@ aghui::SScoringFacility::SChannel::
 calculate_dirty_percent()
 {
 	size_t total = 0; // in samples
-	auto& af = crecording.F().artifacts(_h);
-	for ( auto &A : af() )
+	for ( auto &A : artifacts() )
 		total += A.size();
 	return percent_dirty = (float)total / n_samples();
 }
@@ -397,7 +393,7 @@ detect_artifacts( const metrics::mc::SArtifactDetectionPP& P)
 		get_raw_profile();
 
 		// if ( this == channel currently displayed on measurements overview )
-		if ( name == _p._p.AghH() )
+		if ( strcmp( name(), _p._p.AghH()) == 0 )
 			_p.redraw_ssubject_timeline();
 	}
 }
@@ -438,7 +434,7 @@ mark_flat_regions_as_artifacts( const double minsize, const double pad)
 		get_mc_course();
 
 		// if ( this == channel currently displayed on measurements overview )
-		if ( name == _p._p.AghH() )
+		if ( strcmp( name(), _p._p.AghH()) == 0 )
 			_p.redraw_ssubject_timeline();
 	}
 
@@ -454,11 +450,11 @@ aghui::SScoringFacility::SChannel::
 mark_region_as_artifact( const bool do_mark)
 {
 	if ( do_mark )
-		crecording.F().artifacts(_h).mark_artifact(
+		artifacts.mark_artifact(
 			selection_start_time,
 			selection_end_time);
 	else
-		crecording.F().artifacts(_h).clear_artifact(
+		artifacts.clear_artifact(
 			selection_start_time,
 			selection_end_time);
 
@@ -473,7 +469,7 @@ mark_region_as_artifact( const bool do_mark)
 		get_swu_course();
 		get_mc_course();
 
-		if ( name == _p._p.AghH() )
+		if ( strcmp( name(), _p._p.AghH()) == 0 )
 			_p.redraw_ssubject_timeline();
 	}
 }
@@ -484,7 +480,7 @@ mark_region_as_annotation( const string& label,
 			   const sigfile::SAnnotation::TType type)
 {
 	sigfile::mark_annotation(
-		crecording.F().annotations(_h),
+		annotations,
 		selection_start_time, selection_end_time,
 		label,
 		type);
diff --git a/src/ui/sf/d/artifacts_cb.cc b/src/ui/sf/d/artifacts_cb.cc
index 5c0260a..027d13a 100644
--- a/src/ui/sf/d/artifacts_cb.cc
+++ b/src/ui/sf/d/artifacts_cb.cc
@@ -233,7 +233,7 @@ wSFAD_show_cb(
 	gtk_toggle_button_set_active( AD.bSFADPreview, FALSE);
 	AD.suppress_preview_handler = false;
 
-	snprintf_buf( "Artifact detection in channel %s", SF.using_channel->name.c_str());
+	snprintf_buf( "Artifact detection in channel %s", SF.using_channel->name());
 	gtk_label_set_text( AD.lSFADInfo, __buf__);
 	snprintf_buf( "%4.2f%% marked", SF.using_channel->calculate_dirty_percent() * 100);
 	gtk_label_set_text( AD.lSFADDirtyPercent, __buf__);
diff --git a/src/ui/sf/d/patterns-construct.cc b/src/ui/sf/d/patterns-construct.cc
index 0f1eef1..b32bb8a 100644
--- a/src/ui/sf/d/patterns-construct.cc
+++ b/src/ui/sf/d/patterns-construct.cc
@@ -87,7 +87,7 @@ SPatternsDialogWidgets (SScoringFacility& SF)
 		GtkTreeIter iter;
 		gtk_list_store_append( mSFFDChannels, &iter);
 		gtk_list_store_set( mSFFDChannels, &iter,
-				    0, H.name.c_str(),
+				    0, H.name(),
 				    -1);
 	}
 	gtk_combo_box_set_model_properly( eSFFDChannel, mSFFDChannels);
diff --git a/src/ui/sf/d/patterns_cb.cc b/src/ui/sf/d/patterns_cb.cc
index 16f5b39..1028ec7 100644
--- a/src/ui/sf/d/patterns_cb.cc
+++ b/src/ui/sf/d/patterns_cb.cc
@@ -399,7 +399,7 @@ eSFFD_any_criteria_value_changed_cb(
 		snprintf_buf(
 			"%zu match%s in <b>%s</b>",
 			FD.occurrences.size(), (FD.occurrences.size() == 1) ? "" : "es",
-			FD.field_channel->name.c_str());
+			FD.field_channel->name());
 		gtk_label_set_markup( FD.lSFFDFoundInfo, __buf__);
 
 		FD.set_profile_manage_buttons_visibility();
diff --git a/src/ui/sf/d/phasediff-construct.cc b/src/ui/sf/d/phasediff-construct.cc
index 8b9a6b8..e90dd68 100644
--- a/src/ui/sf/d/phasediff-construct.cc
+++ b/src/ui/sf/d/phasediff-construct.cc
@@ -40,7 +40,7 @@ SPhasediffDialogWidgets (SScoringFacility& SF)
 			GtkTreeIter iter;
 			gtk_list_store_append( mSFPDChannels, &iter);
 			gtk_list_store_set( mSFPDChannels, &iter,
-					    0, H.name.c_str(),
+					    0, H.name(),
 					    -1);
 		}
 
diff --git a/src/ui/sf/d/phasediff.cc b/src/ui/sf/d/phasediff.cc
index c31b771..5512038 100644
--- a/src/ui/sf/d/phasediff.cc
+++ b/src/ui/sf/d/phasediff.cc
@@ -92,7 +92,7 @@ channel_from_cbox( GtkComboBox *cbox)
 			    0, &entry,
 			    -1);
 	for ( auto &H : _p.channels )
-		if ( entry == H.name )
+		if ( strcmp( entry, H.name()) == 0 )
 			return &H;
 	return nullptr;
 }
diff --git a/src/ui/sf/d/phasediff_cb.cc b/src/ui/sf/d/phasediff_cb.cc
index 19bd1d1..b3448eb 100644
--- a/src/ui/sf/d/phasediff_cb.cc
+++ b/src/ui/sf/d/phasediff_cb.cc
@@ -165,8 +165,8 @@ wSFPD_show_cb(
 	     gtk_combo_box_get_active( PD.eSFPDChannelB) == -1 ) {
 		PD.channel1 = &*SF.channels.begin();
 		PD.channel2 = &*next(SF.channels.begin());
-		PD.preselect_channel( PD.eSFPDChannelA, PD.channel1->name.c_str());
-		PD.preselect_channel( PD.eSFPDChannelB, PD.channel2->name.c_str());
+		PD.preselect_channel( PD.eSFPDChannelA, PD.channel1->name());
+		PD.preselect_channel( PD.eSFPDChannelB, PD.channel2->name());
 	} else {
 		// they have been nicely set before, havent't they
 		// PD.channel1 = PD.channel_from_cbox( eSFPDChannelA);
diff --git a/src/ui/sf/ica.cc b/src/ui/sf/ica.cc
index 75ceedd..f11baed 100644
--- a/src/ui/sf/ica.cc
+++ b/src/ui/sf/ica.cc
@@ -99,7 +99,7 @@ setup_ica()
 	gtk_container_foreach( (GtkContainer*)iiSFICAPage, (GtkCallback)gtk_widget_destroy, NULL);
 	GSList *group = nullptr;
 	for ( auto &H : channels ) {
-		auto item = (GtkWidget*)gtk_radio_menu_item_new_with_label( group, H.name.c_str());
+		auto item = (GtkWidget*)gtk_radio_menu_item_new_with_label( group, H.name());
 		group = gtk_radio_menu_item_get_group( (GtkRadioMenuItem*)item);
 		g_object_set( (GObject*)item,
 			      "visible", TRUE,
diff --git a/src/ui/sf/montage.cc b/src/ui/sf/montage.cc
index 6973e2e..e465a00 100644
--- a/src/ui/sf/montage.cc
+++ b/src/ui/sf/montage.cc
@@ -678,7 +678,7 @@ _draw_matrix_to_montage( cairo_t *cr, const itpp::Mat<T>& mat)
 				cairo_set_font_size( cr, 28);
 				cairo_move_to( cr, 30, our_y-10);
 				cairo_set_source_rgba( cr, .3, .1, .2, .65);
-				cairo_show_text( cr, channel_by_idx(ica_map[r].m).name.c_str());
+				cairo_show_text( cr, channel_by_idx(ica_map[r].m).name());
 			    break;
 			default:
 				cairo_move_to( cr, da_wd * .06, our_y - gap/2.5);
diff --git a/src/ui/sf/montage_cb.cc b/src/ui/sf/montage_cb.cc
index bd33190..7b5f055 100644
--- a/src/ui/sf/montage_cb.cc
+++ b/src/ui/sf/montage_cb.cc
@@ -90,7 +90,7 @@ daSFMontage_button_press_event_cb(
 		} else if ( SF.remix_mode == SScoringFacility::TICARemixMode::map ) {
 			const char *mapped =
 				(SF.ica_map[SF.using_ic].m != -1)
-				? SF.channel_by_idx( SF.ica_map[SF.using_ic].m) . name.c_str()
+				? SF.channel_by_idx( SF.ica_map[SF.using_ic].m) . name()
 				: SScoringFacility::ica_unmapped_menu_item_label;
 			SF.suppress_redraw = true;
 			gtk_container_foreach(
@@ -272,7 +272,7 @@ daSFMontage_motion_notify_event_cb(
 	if ( SF.mode == SScoringFacility::TMode::scoring ) {
 		gtk_label_set_text(
 			SF.lSFOverChannel,
-			SF.channel_near( event->y) -> name.c_str());
+			SF.channel_near( event->y) -> name());
 	} else
 		gtk_label_set_text( SF.lSFOverChannel, "");
 
@@ -547,7 +547,7 @@ iSFPageHide_activate_cb(
 	SF.using_channel->hidden = true;
 	// add an item to iSFPageHidden
 	auto item = (GtkWidget*)(SF.using_channel->menu_item_when_hidden =
-				 (GtkMenuItem*)gtk_menu_item_new_with_label( SF.using_channel->name.c_str()));
+				 (GtkMenuItem*)gtk_menu_item_new_with_label( SF.using_channel->name()));
 	g_object_set( (GObject*)item,
 		      "visible", TRUE,
 		      NULL);
@@ -718,7 +718,7 @@ iSFPageFilter_activate_cb(
 	FD.P = H.filters;
 	FD.W_V.up();
 
-	snprintf_buf( "<big>Filters for channel <b>%s</b></big>", SF.using_channel->name.c_str());
+	snprintf_buf( "<big>Filters for channel <b>%s</b></big>", SF.using_channel->name());
 	gtk_label_set_markup( FD.lSFFilterCaption,
 			      __buf__);
 
@@ -735,7 +735,7 @@ iSFPageFilter_activate_cb(
 		}
 		gtk_widget_queue_draw( (GtkWidget*)SF.daSFMontage);
 
-		if ( SF.using_channel->name == SF._p.AghH() )
+		if ( strcmp( SF.using_channel->name(), SF._p.AghH()) == 0 )
 			SF.redraw_ssubject_timeline();
 	}
 }
@@ -783,7 +783,7 @@ iSFPageArtifactsClear_activate_cb(
 {
 	auto& SF = *(SScoringFacility*)userdata;
 
-	char* chnamee = g_markup_escape_text( SF.using_channel->name.c_str(), -1);
+	char* chnamee = g_markup_escape_text( SF.using_channel->name(), -1);
 	if ( GTK_RESPONSE_YES == pop_question(
 		     SF.wSF,
 		     "All marked artifacts will be lost in channel <b>%s</b>.\n\n"
@@ -970,7 +970,7 @@ iSFPageAnnotationClearAll_activate_cb(
 {
 	auto& SF = *(SScoringFacility*)userdata;
 
-	char* chnamee = g_markup_escape_text( SF.using_channel->name.c_str(), -1);
+	char* chnamee = g_markup_escape_text( SF.using_channel->name(), -1);
 	if ( GTK_RESPONSE_YES
 	     == pop_question(
 		     SF.wSF,
@@ -1043,7 +1043,7 @@ iSFICAPageMapIC_activate_cb(
 	int target = -1;
 	int h = 0;
 	for ( auto H = SF.channels.begin(); H != SF.channels.end(); ++H, ++h )
-		if ( H->name == label ) {
+		if ( strcmp( H->name(), label) == 0 ) {
 			target = h;
 			break;
 		}
diff --git a/src/ui/sf/sf.cc b/src/ui/sf/sf.cc
index b32bac8..a9e4d22 100644
--- a/src/ui/sf/sf.cc
+++ b/src/ui/sf/sf.cc
@@ -244,7 +244,7 @@ SScoringFacility (agh::CSubject& J,
 		if ( H.hidden ) {
 			++n_hidden;
 			auto item = (GtkWidget*)(H.menu_item_when_hidden =
-						 (GtkMenuItem*)gtk_menu_item_new_with_label( H.name.c_str()));
+						 (GtkMenuItem*)gtk_menu_item_new_with_label( H.name()));
 			g_object_set(
 				(GObject*)item,
 				"visible", TRUE,
diff --git a/src/ui/sf/sf.hh b/src/ui/sf/sf.hh
index 354fde7..08cdcfc 100644
--- a/src/ui/sf/sf.hh
+++ b/src/ui/sf/sf.hh
@@ -72,16 +72,23 @@ class SScoringFacility
 
 		DELETE_DEFAULT_METHODS (SChannel);
 
-		string	name;
 		bool operator==( const string&) const;
 		bool operator==( const SChannel&) const;
 
 		agh::CRecording&
 			crecording;
-		int	_h;
+
+		// shortcuts
+		int
+		h() const
+			{ return crecording.h(); }
 		const sigfile::SChannel&
 		schannel() const
-			{ return crecording.F().channel_by_id(_h); }
+			{ return crecording.F().channel_by_id( h()); }
+		const char*
+		name() const
+			{ return schannel().name(); }
+
 		sigfile::SFilterPack&
 			filters;
 		list<sigfile::SAnnotation>&
@@ -203,11 +210,6 @@ class SScoringFacility
 	      // ctor, dtor
 		SChannel( agh::CRecording& r, SScoringFacility&, size_t y, int seq);
 
-		int h() const
-			{
-				return _h;
-			}
-
 		double	zeroy;
 		bool operator<( const SChannel&) const;
 
@@ -576,14 +578,14 @@ inline bool
 SScoringFacility::SChannel::
 operator==( const string& _name) const
 {
-	return name == _name;
-}
-inline bool
-SScoringFacility::SChannel::
-operator==( const SChannel& rv) const
-{
-	return name == rv.name;
+	return _name == name();
 }
+// inline bool
+// SScoringFacility::SChannel::
+// operator==( const SChannel& rv) const
+// {
+// 	return name == rv.name;
+// }
 
 
 inline bool
@@ -654,7 +656,7 @@ inline size_t
 SScoringFacility::SChannel::
 samplerate() const
 {
-	return crecording.F().samplerate(_h);
+	return crecording.F().samplerate(h());
 }
 
 

-- 
Sleep experiment manager



More information about the debian-med-commit mailing list