Skip to content

Commit fd259ab

Browse files
committed
Field/Widget respond to user manipulation. Transforms are off though
1 parent 9539e08 commit fd259ab

File tree

16 files changed

+83
-71
lines changed

16 files changed

+83
-71
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/Dataflow/Network/Module.cc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -960,6 +960,7 @@ void Module::sendFeedbackUpstreamAlongIncomingConnections(const ModuleFeedback&
960960
auto connection = inputPort->connection(0); // only one incoming connection for input ports
961961
//VariableHandle feedback(new Variable(Name(inputPort->id().toString()), info));
962962
//TODO: extract port method
963+
std::cout << get_id() << " Module::sendFeedbackUpstreamAlongIncomingConnections" << std::endl;
963964
connection->oport_->sendConnectionFeedback(feedback);
964965
}
965966
}

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()

src/Dataflow/State/SimpleMapModuleState.h

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -44,23 +44,25 @@ namespace State {
4444
SimpleMapModuleState(SimpleMapModuleState&& rhs);
4545
SimpleMapModuleState(const SimpleMapModuleState& rhs);
4646
SimpleMapModuleState& operator=(const SimpleMapModuleState& rhs);
47-
virtual const Value getValue(const Name& name) const;
48-
virtual void setValue(const Name& name, const SCIRun::Core::Algorithms::AlgorithmParameter::Value& value);
49-
virtual bool containsKey(const Name& name) const;
50-
virtual Keys getKeys() const;
51-
virtual SCIRun::Dataflow::Networks::ModuleStateHandle clone() const;
52-
virtual boost::signals2::connection connect_state_changed(state_changed_sig_t::slot_function_type subscriber);
47+
virtual const Value getValue(const Name& name) const override;
48+
virtual void setValue(const Name& name, const SCIRun::Core::Algorithms::AlgorithmParameter::Value& value) override;
49+
virtual bool containsKey(const Name& name) const override;
50+
virtual Keys getKeys() const override;
51+
virtual SCIRun::Dataflow::Networks::ModuleStateHandle clone() const override;
52+
virtual boost::signals2::connection connectStateChanged(state_changed_sig_t::slot_function_type subscriber) override;
53+
virtual boost::signals2::connection connectSpecificStateChanged(const Name& stateKeyToObserve, state_changed_sig_t::slot_function_type subscriber) override;
5354

54-
virtual TransientValueOption getTransientValue(const Name& name) const;
55-
virtual void setTransientValue(const Name& name, const TransientValue& value, bool fireSignal);
56-
virtual void fireTransientStateChangeSignal();
55+
virtual TransientValueOption getTransientValue(const Name& name) const override;
56+
virtual void setTransientValue(const Name& name, const TransientValue& value, bool fireSignal) override;
57+
virtual void fireTransientStateChangeSignal() override;
5758

5859
protected:
5960
typedef std::map<Name, Value> StateMap;
6061
StateMap stateMap_;
6162
typedef std::map<std::string, TransientValue> TransientStateMap;
6263
TransientStateMap transientStateMap_;
6364
state_changed_sig_t stateChangedSignal_;
65+
std::map<Name, state_changed_sig_t> specificStateChangeSignalMap_;
6466
std::string name_;
6567
private:
6668
void print() const;

0 commit comments

Comments
 (0)