Skip to content

Commit d42459a

Browse files
committed
Merge remote-tracking branch 'upstream/gui_B'
2 parents 37c3e77 + 25001ad commit d42459a

File tree

13 files changed

+438
-227
lines changed

13 files changed

+438
-227
lines changed

src/Dataflow/Network/Module.cc

Lines changed: 23 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -222,26 +222,29 @@ size_t Module::num_output_ports() const
222222
return oports_.size();
223223
}
224224

225-
namespace //TODO requirements for state metadata reporting
225+
//TODO requirements for state metadata reporting
226+
std::string Module::stateMetaInfo() const
226227
{
227-
std::string stateMetaInfo(ModuleStateHandle state)
228+
if (!state_)
229+
return "Null state map.";
230+
auto keys = state_->getKeys();
231+
size_t i = 0;
232+
std::ostringstream ostr;
233+
ostr << "\n\t{";
234+
for (const auto& key : keys)
228235
{
229-
if (!state)
230-
return "Null state map.";
231-
auto keys = state->getKeys();
232-
size_t i = 0;
233-
std::ostringstream ostr;
234-
ostr << "\n\t{";
235-
for (const auto& key : keys)
236-
{
237-
ostr << "[" << key.name() << ", " << state->getValue(key).value() << "]";
238-
i++;
239-
if (i < keys.size())
240-
ostr << ",\n\t";
241-
}
242-
ostr << "}";
243-
return ostr.str();
236+
ostr << "[" << key.name() << ", " << state_->getValue(key).value() << "]";
237+
i++;
238+
if (i < keys.size())
239+
ostr << ",\n\t";
244240
}
241+
ostr << "}";
242+
return ostr.str();
243+
}
244+
245+
void Module::copyStateToMetadata()
246+
{
247+
metadata_.setMetadata("Module state", stateMetaInfo());
245248
}
246249

247250
bool Module::executeWithSignals() NOEXCEPT
@@ -253,7 +256,7 @@ bool Module::executeWithSignals() NOEXCEPT
253256
{
254257
std::string isoString = boost::posix_time::to_simple_string(boost::posix_time::microsec_clock::universal_time());
255258
metadata_.setMetadata("Last execution timestamp", isoString);
256-
metadata_.setMetadata("Module state", stateMetaInfo(get_state()));
259+
copyStateToMetadata();
257260
}
258261
/// @todo: status() calls should be logged everywhere, need to change legacy loggers. issue #nnn
259262
status("STARTING MODULE: " + id_.id_);
@@ -362,6 +365,7 @@ void Module::set_state(ModuleStateHandle state)
362365
}
363366
initStateObserver(state_.get());
364367
postStateChangeInternalSignalHookup();
368+
copyStateToMetadata();
365369
}
366370

367371
AlgorithmBase& Module::algo()
@@ -537,6 +541,7 @@ Module::Builder& Module::Builder::setStateDefaults()
537541
if (module_)
538542
{
539543
module_->setStateDefaults();
544+
module_->copyStateToMetadata();
540545
}
541546
return *this;
542547
}

src/Dataflow/Network/Module.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -277,6 +277,9 @@ namespace Networks {
277277
virtual void postStateChangeInternalSignalHookup() {}
278278
void sendFeedbackUpstreamAlongIncomingConnections(const Core::Datatypes::ModuleFeedback& feedback) const;
279279

280+
std::string stateMetaInfo() const;
281+
void copyStateToMetadata();
282+
280283
private:
281284
template <class T>
282285
boost::shared_ptr<T> getRequiredInputAtIndex(const PortId& id);

src/Interface/Application/Connection.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -279,7 +279,7 @@ ConnectionLine::ConnectionLine(PortWidget* fromPort, PortWidget* toPort, const C
279279
setFlags(ItemIsSelectable | ItemIsMovable | ItemSendsGeometryChanges | ItemIsFocusable);
280280

281281
setZValue(defaultZValue());
282-
setToolTip("<font color=\"#000000\" size=2>Left - Highlight\nDouble-Left - Menu\ni - Datatype info");
282+
setToolTip("<font color=\"#EEEEEE\" size=2>Left - Highlight<br>Double-Left - Menu<br>i - Datatype info");
283283
setAcceptHoverEvents(true);
284284

285285
menu_ = new ConnectionMenu(this);

src/Interface/Application/ModuleProxyWidget.cc

Lines changed: 40 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -111,8 +111,6 @@ namespace SCIRun
111111
}
112112
}
113113

114-
const int fadeInSeconds = 1;
115-
116114
ModuleProxyWidget::ModuleProxyWidget(ModuleWidget* module, QGraphicsItem* parent/* = 0*/)
117115
: QGraphicsProxyWidget(parent),
118116
NoteDisplayHelper(boost::make_shared<ModuleWidgetNoteDisplayStrategy>()),
@@ -136,23 +134,55 @@ ModuleProxyWidget::ModuleProxyWidget(ModuleWidget* module, QGraphicsItem* parent
136134

137135
originalSize_ = size();
138136

139-
{
140-
timeLine_ = new QTimeLine(fadeInSeconds * 1000, this);
141-
connect(timeLine_, SIGNAL(valueChanged(qreal)), this, SLOT(animate(qreal)));
142-
//timeLine_->start();
143-
}
137+
// {
138+
// const int fadeInSeconds = 1;
139+
// timeLine_ = new QTimeLine(fadeInSeconds * 1000, this);
140+
// connect(timeLine_, SIGNAL(valueChanged(qreal)), this, SLOT(loadAnimate(qreal)));
141+
// timeLine_->start();
142+
// }
144143
}
145144

146145
ModuleProxyWidget::~ModuleProxyWidget()
147146
{
148147
}
149148

150-
void ModuleProxyWidget::animate(qreal val)
149+
void ModuleProxyWidget::showAndColor(const QColor& color)
150+
{
151+
animateColor_ = color;
152+
timeLine_ = new QTimeLine(4000, this);
153+
connect(timeLine_, SIGNAL(valueChanged(qreal)), this, SLOT(colorAnimate(qreal)));
154+
timeLine_->start();
155+
ensureThisVisible();
156+
}
157+
158+
void ModuleProxyWidget::loadAnimate(qreal val)
151159
{
152160
setOpacity(val);
153161
setScale(val);
154162
}
155163

164+
void ModuleProxyWidget::colorAnimate(qreal val)
165+
{
166+
if (val < 1)
167+
{
168+
auto effect = graphicsEffect();
169+
if (!effect)
170+
{
171+
auto colorize = new QGraphicsColorizeEffect;
172+
colorize->setColor(animateColor_);
173+
setGraphicsEffect(colorize);
174+
}
175+
else if (auto c = dynamic_cast<QGraphicsColorizeEffect*>(effect))
176+
{
177+
auto newColor = c->color();
178+
newColor.setAlphaF(1 - val);
179+
c->setColor(newColor);
180+
}
181+
}
182+
else // 1 = done coloring
183+
setGraphicsEffect(nullptr);
184+
}
185+
156186
void ModuleProxyWidget::adjustHeight(int delta)
157187
{
158188
auto p = pos();
@@ -181,7 +211,7 @@ void ModuleProxyWidget::ensureThisVisible()
181211

182212
void ModuleProxyWidget::ensureItemVisible(QGraphicsItem* item)
183213
{
184-
auto views = scene()->views();
214+
auto views = item->scene()->views();
185215
if (!views.isEmpty())
186216
{
187217
auto netEd = qobject_cast<NetworkEditor*>(views[0]);
@@ -213,6 +243,7 @@ void ModuleProxyWidget::disableModuleGUI(bool disabled)
213243

214244
void ModuleProxyWidget::mousePressEvent(QGraphicsSceneMouseEvent *event)
215245
{
246+
clearNoteCursor();
216247
auto taggingOn = data(TagLayerKey).toBool();
217248
auto currentTag = data(CurrentTagKey).toInt();
218249
if (taggingOn && currentTag > NoTag)

src/Interface/Application/ModuleProxyWidget.h

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -53,12 +53,17 @@ namespace SCIRun
5353
void adjustHeight(int delta);
5454
void adjustWidth(int delta);
5555

56+
//TODO: move to utility
57+
static void ensureItemVisible(QGraphicsItem* item);
58+
5659
public Q_SLOTS:
5760
void highlightIfSelected();
5861
void setDefaultNotePosition(NotePosition position);
5962
void createPortPositionProviders();
6063
void snapToGrid();
6164
void highlightPorts(int state);
65+
void ensureThisVisible();
66+
void showAndColor(const QColor& color);
6267

6368
Q_SIGNALS:
6469
void selected();
@@ -74,15 +79,15 @@ namespace SCIRun
7479
virtual void setNoteGraphicsContext() override;
7580
private Q_SLOTS:
7681
void updateNote(const Note& note);
77-
void ensureThisVisible();
7882
void disableModuleGUI(bool disabled);
79-
void animate(qreal val);
83+
void loadAnimate(qreal val);
84+
void colorAnimate(qreal val);
8085
private:
81-
void ensureItemVisible(QGraphicsItem* item);
8286
bool isSubwidget(QWidget* alienWidget) const;
8387
void updatePressedSubWidget(QGraphicsSceneMouseEvent* event);
8488

8589
ModuleWidget* module_;
90+
QColor animateColor_;
8691
bool grabbedByWidget_, isSelected_;
8792
QWidget* pressedSubWidget_;
8893
QPointF position_;

src/Interface/Application/ModuleWidget.cc

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1075,11 +1075,12 @@ void ModuleWidget::makeOptionsDialog()
10751075
}
10761076

10771077
auto expand = Core::Application::Instance().parameters()->developerParameters()->guiExpandFactor().get_value_or(-1);
1078-
if (expand > 0)
1078+
if (expand > 1)
10791079
{
10801080
qDebug() << "expand factor for dialogs:" << expand;
10811081
qDebug() << dialog_->size();
10821082
dialog_->setFixedHeight(dialog_->size().height() * expand);
1083+
dialog_->setFixedWidth(dialog_->size().width() * ((expand - 1) * 0.5) + 1);
10831084
qDebug() << dialog_->size();
10841085
}
10851086

@@ -1356,20 +1357,20 @@ void ModuleWidget::unhighlightPorts()
13561357
Q_EMIT displayChanged();
13571358
}
13581359

1359-
void ModuleWidget::updateMetadata(bool active)
1360+
QString ModuleWidget::metadataToString() const
13601361
{
1361-
if (active)
1362+
auto metadata = theModule_->metadata().getFullMap();
1363+
QStringList display;
1364+
for (const auto& metaPair : metadata)
13621365
{
1363-
auto metadata = theModule_->metadata().getFullMap();
1364-
QStringList display;
1365-
for (const auto& metaPair : metadata)
1366-
{
1367-
display.append(QString::fromStdString(metaPair.first) + " : " + QString::fromStdString(metaPair.second));
1368-
}
1369-
setToolTip("Metadata:\n" + display.join("\n"));
1366+
display.append(QString::fromStdString(metaPair.first) + " : " + QString::fromStdString(metaPair.second));
13701367
}
1371-
else
1372-
setToolTip("");
1368+
return display.join("\n");
1369+
}
1370+
1371+
void ModuleWidget::updateMetadata(bool active)
1372+
{
1373+
setToolTip(active ? "Metadata:\n" + metadataToString() : "");
13731374
}
13741375

13751376
void ModuleWidget::setExecutionDisabled(bool disabled)

src/Interface/Application/ModuleWidget.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -159,6 +159,8 @@ class ModuleWidget : public QStackedWidget,
159159
~NetworkClearingScope();
160160
};
161161

162+
QString metadataToString() const;
163+
162164
public Q_SLOTS:
163165
virtual bool executeWithSignals() override;
164166
void toggleOptionsDialog();

0 commit comments

Comments
 (0)