Skip to content

Commit 213e4f5

Browse files
committed
Fix bundle modules
1 parent 1419b99 commit 213e4f5

File tree

5 files changed

+31
-23
lines changed

5 files changed

+31
-23
lines changed

src/Dataflow/Network/Module.cc

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@
3535
#include <boost/timer.hpp>
3636
#include <atomic>
3737

38+
#include <Core/Algorithms/Base/AlgorithmPreconditions.h>
3839
#include <Dataflow/Network/PortManager.h>
3940
#include <Dataflow/Network/ModuleStateInterface.h>
4041
#include <Dataflow/Network/Module.h>
@@ -278,6 +279,12 @@ bool Module::executeWithSignals() NOEXCEPT
278279
ostr << "Port not found, it may need initializing the module constructor. " << std::endl << "Message: " << e.what() << std::endl;
279280
error(ostr.str());
280281
}
282+
catch (AlgorithmParameterNotFound& e)
283+
{
284+
std::ostringstream ostr;
285+
ostr << "State key not found, it may need initializing in ModuleClass::setStateDefaults(). " << std::endl << "Message: " << e.what() << std::endl;
286+
error(ostr.str());
287+
}
281288
catch (Core::ExceptionBase& e)
282289
{
283290
/// @todo: this block is repetitive (logging-wise) if the macros are used to log AND throw an exception with the same message. Figure out a reasonable condition to enable it.

src/Modules/BrainStimulator/GenerateROIStatistics.cc

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
Copyright (c) 2015 Scientific Computing and Imaging Institute,
77
University of Utah.
88
9-
9+
1010
Permission is hereby granted, free of charge, to any person obtaining a
1111
copy of this software and associated documentation files (the "Software"),
1212
to deal in the Software without restriction, including without limitation
@@ -52,7 +52,8 @@ GenerateROIStatisticsModule::GenerateROIStatisticsModule() : Module(ModuleLookup
5252

5353
void GenerateROIStatisticsModule::setStateDefaults()
5454
{
55-
setStateStringFromAlgoOption(Parameters::PhysicalUnitStr);
55+
setStateStringFromAlgoOption(Parameters::PhysicalUnitStr);
56+
get_state()->setValue(Parameters::StatisticsTableValues, VariableList());
5657
}
5758

5859
void GenerateROIStatisticsModule::execute()
@@ -63,29 +64,29 @@ void GenerateROIStatisticsModule::execute()
6364
auto atlasMeshLabels_ = getOptionalInput(AtlasMeshLabels);
6465
auto coordinateSpace_ = getOptionalInput(CoordinateSpace);
6566
auto coordinateSpaceLabel_ = getOptionalInput(CoordinateSpaceLabel);
66-
67-
setAlgoListFromState(Parameters::StatisticsTableValues); /// to transfer data between algo and dialog use the state variable
68-
67+
68+
setAlgoListFromState(Parameters::StatisticsTableValues); /// to transfer data between algo and dialog use the state variable
69+
6970
auto roiSpec = transient_value_cast<DenseMatrixHandle>(get_state()->getTransientValue(GenerateROIStatisticsAlgorithm::SpecifyROI)); /// transfer the ROI specification from GUI dialog as additional input
7071
//algorithm input and run
7172
auto input = make_input((MeshDataOnElements, meshData_)(PhysicalUnit, optionalAlgoInput(physicalUnit_))(AtlasMesh, atlasMesh_)(AtlasMeshLabels,
7273
optionalAlgoInput(atlasMeshLabels_))(CoordinateSpace, optionalAlgoInput(coordinateSpace_))(CoordinateSpaceLabel,
7374
optionalAlgoInput(coordinateSpaceLabel_)));
74-
75+
7576
if (roiSpec)
7677
input[GenerateROIStatisticsAlgorithm::SpecifyROI] = roiSpec;
77-
78-
auto output = algo().run(input); /// call run generic
7978

80-
auto table = output.additionalAlgoOutput(); /// get the two outputs, the upper table (as DenseMatrix) and the container that establishes data transfer between GUI/Algo via state
79+
auto output = algo().run(input); /// call run generic
80+
81+
auto table = output.additionalAlgoOutput(); /// get the two outputs, the upper table (as DenseMatrix) and the container that establishes data transfer between GUI/Algo via state
8182
get_state()->setTransientValue(Parameters::StatisticsTableValues, table);
82-
83+
8384
if (physicalUnit_ && *physicalUnit_) /// set physicalUnit string immediately to state, and then to dialog
8485
get_state()->setTransientValue(Parameters::PhysicalUnitStr,(*physicalUnit_)->value());
85-
86+
8687
if (coordinateSpaceLabel_ && *coordinateSpaceLabel_)/// set coordinateSpaceLabel string immediately to state, and then to dialog
87-
get_state()->setTransientValue(Parameters::CoordinateSpaceLabelStr,(*coordinateSpaceLabel_)->value());
88-
88+
get_state()->setTransientValue(Parameters::CoordinateSpaceLabelStr,(*coordinateSpaceLabel_)->value());
89+
8990
//algorithm output
9091
sendOutputFromAlgorithm(StatisticalResults, output); /// set the upper table (DenseMatrix) as only output of the module
9192
}

src/Modules/Legacy/Bundle/InsertFieldsIntoBundle.cc

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
Copyright (c) 2015 Scientific Computing and Imaging Institute,
77
University of Utah.
88
9-
9+
1010
Permission is hereby granted, free of charge, to any person obtaining a
1111
copy of this software and associated documentation files (the "Software"),
1212
to deal in the Software without restriction, including without limitation
@@ -51,18 +51,18 @@ InsertFieldsIntoBundle::InsertFieldsIntoBundle() : Module(staticInfo_)
5151

5252
void InsertFieldsIntoBundle::setStateDefaults()
5353
{
54-
54+
get_state()->setValue(FieldReplace, VariableList());
5555
}
5656

5757
void InsertFieldsIntoBundle::execute()
5858
{
5959
auto bundleOption = getOptionalInput(InputBundle);
6060
auto fields = getRequiredDynamicInputs(InputFields);
6161

62-
//if (inputs_changed_ || guifield1name_.changed() ||
62+
//if (inputs_changed_ || guifield1name_.changed() ||
6363
// guifield2name_.changed() || guifield3name_.changed() ||
6464
// guifield4name_.changed() || guifield5name_.changed() ||
65-
// guifield6name_.changed() ||
65+
// guifield6name_.changed() ||
6666
// guireplace1_.changed() || guireplace2_.changed() ||
6767
// guireplace3_.changed() || guireplace4_.changed() ||
6868
// guireplace5_.changed() || guireplace6_.changed() ||
@@ -126,9 +126,9 @@ void InsertFieldsIntoBundle::execute()
126126

127127
private:
128128
GuiString guifield6name_;
129-
129+
130130
GuiInt guireplace6_;
131-
131+
132132
GuiString guibundlename_;
133133
};
134134

@@ -151,4 +151,4 @@ void InsertFieldsIntoBundle::execute()
151151
{
152152
}
153153

154-
#endif
154+
#endif

src/Modules/Legacy/Bundle/InsertMatricesIntoBundle.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ InsertMatricesIntoBundle::InsertMatricesIntoBundle() : Module(staticInfo_)
5252

5353
void InsertMatricesIntoBundle::setStateDefaults()
5454
{
55-
55+
get_state()->setValue(MatrixReplace, VariableList());
5656
}
5757

5858
void InsertMatricesIntoBundle::execute()

src/Modules/Legacy/Bundle/InsertStringsIntoBundle.cc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
Copyright (c) 2015 Scientific Computing and Imaging Institute,
77
University of Utah.
88
9-
9+
1010
Permission is hereby granted, free of charge, to any person obtaining a
1111
copy of this software and associated documentation files (the "Software"),
1212
to deal in the Software without restriction, including without limitation
@@ -52,7 +52,7 @@ InsertStringsIntoBundle::InsertStringsIntoBundle() : Module(staticInfo_)
5252

5353
void InsertStringsIntoBundle::setStateDefaults()
5454
{
55-
55+
get_state()->setValue(StringReplace, VariableList());
5656
}
5757

5858
void InsertStringsIntoBundle::execute()

0 commit comments

Comments
 (0)