Skip to content

Commit 7883b6a

Browse files
committed
Merge branch 'master' into gui_B
2 parents 57c026f + eca6708 commit 7883b6a

File tree

19 files changed

+2066
-83
lines changed

19 files changed

+2066
-83
lines changed

src/Core/GeometryPrimitives/Transform.cc

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,12 @@ Transform::Transform(const Point& p, const Vector& i,
7676
load_basis(p, i, j, k);
7777
}
7878

79+
const Transform& Transform::Identity()
80+
{
81+
static Transform id;
82+
return id;
83+
}
84+
7985
void
8086
Transform::load_basis(const Point &p,
8187
const Vector &x,

src/Core/GeometryPrimitives/Transform.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,8 @@ namespace SCIRun {
7272
double get_imat_val(int i, int j) const { return imat[i][j]; }
7373
void set_imat_val(int i, int j, double val) { imat[i][j] = val; }
7474

75+
static const Transform& Identity();
76+
7577
Transform();
7678
Transform(const Transform&);
7779
Transform& operator=(const Transform&);

src/Core/Utils/Tests/TypeIDTableTests.cc

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,12 +28,14 @@
2828

2929
#include <gtest/gtest.h>
3030
#include <boost/thread.hpp>
31+
#include <boost/lexical_cast.hpp>
32+
#include <boost/format.hpp>
3133

3234
#include <Core/Utils/TypeIDTable.h>
3335

3436
using namespace SCIRun::Core::Utility;
3537

36-
struct Dummy
38+
struct Dummy
3739
{
3840
int x;
3941
};
@@ -51,7 +53,7 @@ bool operator!=(const Dummy& x1, const Dummy& x2)
5153
TEST(TypeIDTableTests, CanConstructEmpty)
5254
{
5355
TypeIDTable<Dummy> table;
54-
56+
5557
auto ctor = table.findConstructorInfo("LatVolMesh");
5658

5759
EXPECT_FALSE(ctor);
@@ -133,3 +135,15 @@ TEST(TypeIDTableTests, MultithreadedAccessIsSafe)
133135

134136
EXPECT_EQ(1, trueCount);
135137
}
138+
139+
TEST(StringFormatting, NewWayMatchesOldWay)
140+
{
141+
double x = 3.14159265;
142+
char s[32];
143+
sprintf(s, "%8.4f", x);
144+
auto expected = boost::lexical_cast<std::string>(s);
145+
146+
auto actual = str(boost::format("%8.4f") % x);
147+
148+
EXPECT_EQ(expected, actual);
149+
}

src/Dataflow/Network/Module.cc

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -963,7 +963,6 @@ void Module::sendFeedbackUpstreamAlongIncomingConnections(const ModuleFeedback&
963963
if (inputPort->nconnections() > 0)
964964
{
965965
auto connection = inputPort->connection(0); // only one incoming connection for input ports
966-
//VariableHandle feedback(new Variable(Name(inputPort->id().toString()), info));
967966
//TODO: extract port method
968967
connection->oport_->sendConnectionFeedback(feedback);
969968
}

src/Dataflow/Network/ModuleStateInterface.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ void StateChangeObserver::initStateObserver(ModuleStateInterface* state)
6060
if (state)
6161
{
6262
//LOG_DEBUG("StateChangeObserver::initStateObserver(), connecting to state" << std::endl);
63-
conn_ = state->connect_state_changed(boost::bind(&StateChangeObserver::stateChanged, this));
63+
conn_ = state->connectStateChanged(boost::bind(&StateChangeObserver::stateChanged, this));
6464
}
6565
}
6666

src/Dataflow/Network/ModuleStateInterface.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,8 @@ namespace Networks {
7777

7878
typedef boost::signals2::signal<void()> state_changed_sig_t;
7979

80-
virtual boost::signals2::connection connect_state_changed(state_changed_sig_t::slot_function_type subscriber) = 0;
80+
virtual boost::signals2::connection connectStateChanged(state_changed_sig_t::slot_function_type subscriber) = 0;
81+
virtual boost::signals2::connection connectSpecificStateChanged(const Name& stateKeyToObserve, state_changed_sig_t::slot_function_type subscriber) = 0;
8182
};
8283

8384
class SCISHARE ModuleStateInterfaceFactory

src/Dataflow/Network/NullModuleState.cc

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,9 +57,14 @@ ModuleStateHandle NullModuleState::clone() const
5757
return boost::make_shared<NullModuleState>();
5858
}
5959

60-
boost::signals2::connection NullModuleState::connect_state_changed(state_changed_sig_t::slot_function_type subscriber)
60+
boost::signals2::connection NullModuleState::connectStateChanged(state_changed_sig_t::slot_function_type)
6161
{
62-
return boost::signals2::connection();
62+
return {};
63+
}
64+
65+
boost::signals2::connection NullModuleState::connectSpecificStateChanged(const Name&, state_changed_sig_t::slot_function_type)
66+
{
67+
return {};
6368
}
6469

6570
NullModuleState::TransientValueOption NullModuleState::getTransientValue(const Name& name) const

src/Dataflow/Network/NullModuleState.h

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -41,15 +41,16 @@ namespace State {
4141
class SCISHARE NullModuleState : public SCIRun::Dataflow::Networks::ModuleStateInterface
4242
{
4343
public:
44-
virtual void setValue(const Name&, const SCIRun::Core::Algorithms::AlgorithmParameter::Value&);
45-
virtual const Value getValue(const Name&) const;
46-
virtual Keys getKeys() const;
47-
virtual bool containsKey(const Name&) const;
48-
virtual SCIRun::Dataflow::Networks::ModuleStateHandle clone() const;
49-
virtual TransientValueOption getTransientValue(const Name& name) const;
50-
virtual void setTransientValue(const Name& name, const TransientValue& value, bool b);
51-
virtual boost::signals2::connection connect_state_changed(state_changed_sig_t::slot_function_type subscriber);
52-
virtual void fireTransientStateChangeSignal() {}
44+
virtual void setValue(const Name&, const SCIRun::Core::Algorithms::AlgorithmParameter::Value&) override;
45+
virtual const Value getValue(const Name&) const override;
46+
virtual Keys getKeys() const override;
47+
virtual bool containsKey(const Name&) const override;
48+
virtual SCIRun::Dataflow::Networks::ModuleStateHandle clone() const override;
49+
virtual TransientValueOption getTransientValue(const Name& name) const override;
50+
virtual void setTransientValue(const Name& name, const TransientValue& value, bool b) override;
51+
virtual boost::signals2::connection connectStateChanged(state_changed_sig_t::slot_function_type subscriber) override;
52+
virtual boost::signals2::connection connectSpecificStateChanged(const Name& stateKeyToObserve, state_changed_sig_t::slot_function_type subscriber) override;
53+
virtual void fireTransientStateChangeSignal() override {}
5354
};
5455

5556
}}}

src/Dataflow/Network/Tests/MockModuleState.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,8 @@ namespace SCIRun {
4747
MOCK_CONST_METHOD0(clone, ModuleStateHandle());
4848
MOCK_CONST_METHOD1(getTransientValue, TransientValueOption(const Name&));
4949
MOCK_METHOD3(setTransientValue, void(const Name&, const TransientValue&, bool));
50-
MOCK_METHOD1(connect_state_changed, boost::signals2::connection(state_changed_sig_t::slot_function_type));
50+
MOCK_METHOD1(connectStateChanged, boost::signals2::connection(state_changed_sig_t::slot_function_type));
51+
MOCK_METHOD2(connectSpecificStateChanged, boost::signals2::connection(const Name&, state_changed_sig_t::slot_function_type));
5152
MOCK_METHOD0(fireTransientStateChangeSignal, void());
5253
};
5354

src/Dataflow/State/SimpleMapModuleState.cc

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -104,16 +104,24 @@ void SimpleMapModuleState::setValue(const Name& parameterName, const SCIRun::Cor
104104
{
105105
LOG_DEBUG("----signaling from state map: (" << parameterName.name_ << ", " << SCIRun::Core::to_string(value) << "), num_slots = " << stateChangedSignal_.num_slots() << std::endl);
106106
stateChangedSignal_();
107+
auto specSig = specificStateChangeSignalMap_.find(parameterName);
108+
if (specSig != specificStateChangeSignalMap_.end())
109+
specSig->second();
107110
}
108111
}
109112

110-
boost::signals2::connection SimpleMapModuleState::connect_state_changed(state_changed_sig_t::slot_function_type subscriber)
113+
boost::signals2::connection SimpleMapModuleState::connectStateChanged(state_changed_sig_t::slot_function_type subscriber)
111114
{
112115
auto conn = stateChangedSignal_.connect(subscriber);
113-
LOG_DEBUG("SimpleMapModuleState::connect_state_changed, num_slots = " << stateChangedSignal_.num_slots() << std::endl);
116+
LOG_DEBUG("SimpleMapModuleState::connectStateChanged, num_slots = " << stateChangedSignal_.num_slots() << std::endl);
114117
return conn;
115118
}
116119

120+
boost::signals2::connection SimpleMapModuleState::connectSpecificStateChanged(const Name& stateKeyToObserve, state_changed_sig_t::slot_function_type subscriber)
121+
{
122+
return specificStateChangeSignalMap_[stateKeyToObserve].connect(subscriber);
123+
}
124+
117125
ModuleStateInterface::Keys SimpleMapModuleState::getKeys() const
118126
{
119127
Keys keys;
@@ -145,7 +153,12 @@ void SimpleMapModuleState::setTransientValue(const Name& name, const TransientVa
145153
//print();
146154

147155
if (fireSignal)
156+
{
148157
fireTransientStateChangeSignal();
158+
auto specSig = specificStateChangeSignalMap_.find(name);
159+
if (specSig != specificStateChangeSignalMap_.end())
160+
specSig->second();
161+
}
149162
}
150163

151164
void SimpleMapModuleState::fireTransientStateChangeSignal()

0 commit comments

Comments
 (0)