Skip to content

Commit 4ddb6cb

Browse files
committed
Finish moving state vars to macros
1 parent f345f76 commit 4ddb6cb

File tree

3 files changed

+48
-62
lines changed

3 files changed

+48
-62
lines changed

src/Interface/Modules/Render/ViewScene.cc

Lines changed: 26 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -394,7 +394,7 @@ ViewSceneDialog::ViewSceneDialog(const std::string& name, ModuleStateHandle stat
394394
state->connectSpecificStateChanged(Parameters::GeomData,[this](){Q_EMIT newGeometryValueForwarder();});
395395
connect(this, SIGNAL(newGeometryValueForwarder()), this, SLOT(updateModifiedGeometriesAndSendScreenShot()));
396396

397-
state->connectSpecificStateChanged(Parameters::CameraRotation1,[this](){Q_EMIT cameraRotationChangeForwarder();});
397+
state->connectSpecificStateChanged(Parameters::CameraRotation,[this](){Q_EMIT cameraRotationChangeForwarder();});
398398
connect(this, SIGNAL(cameraRotationChangeForwarder()), this, SLOT(pullCameraRotation()));
399399

400400
state->connectSpecificStateChanged(Parameters::CameraLookAt,[this](){Q_EMIT cameraLookAtChangeForwarder();});
@@ -771,9 +771,9 @@ void ViewSceneDialog::pullCameraRotation()
771771
return;
772772

773773
glm::quat q;
774-
auto rotVariable = state_->getValue(Parameters::CameraRotation1);
774+
auto rotVariable = state_->getValue(Parameters::CameraRotation);
775775
if (rotVariable.value().type() == typeid(std::string)) // Legacy interpreter for networks that have this stored as string
776-
q = ViewSceneUtility::stringToQuat(state_->getValue(Parameters::CameraRotation1).toString());
776+
q = ViewSceneUtility::stringToQuat(state_->getValue(Parameters::CameraRotation).toString());
777777
else
778778
{
779779
auto rotation = toDoubleVector(rotVariable.toVector());
@@ -864,7 +864,7 @@ void ViewSceneDialog::pushCameraRotation()
864864
if (!spire) return;
865865

866866
auto q = spire->getCameraRotation();
867-
state_->setValue(Parameters::CameraRotation1, makeAnonymousVariableList(q.w, q.x, q.y, q.z));
867+
state_->setValue(Parameters::CameraRotation, makeAnonymousVariableList(q.w, q.x, q.y, q.z));
868868
pushingCameraState_ = false;
869869
}
870870

@@ -1340,20 +1340,20 @@ void ViewSceneDialog::mouseMoveEvent(QMouseEvent* event)
13401340
auto spire = mSpire.lock();
13411341
if(!spire) return;
13421342

1343-
int x_window = event->x() - mGLWidget->pos().x();
1344-
int y_window = event->y() - mGLWidget->pos().y();
1343+
const int x_window = event->x() - mGLWidget->pos().x();
1344+
const int y_window = event->y() - mGLWidget->pos().y();
13451345

1346-
auto btn = getSpireButton(event);
1346+
const auto btn = getSpireButton(event);
13471347

13481348
if (selectedWidget_)
13491349
{
13501350
spire->widgetMouseMove(x_window, y_window);
13511351
}
1352-
else if(!shiftdown_)
1352+
else if (!shiftdown_)
13531353
{
13541354
float x_ss, y_ss;
13551355
spire->calculateScreenSpaceCoords(x_window, y_window, x_ss, y_ss);
1356-
for (auto vsd : viewScenesToUpdate)
1356+
for (auto* vsd : viewScenesToUpdate)
13571357
vsd->inputMouseMoveHelper(btn, x_ss, y_ss);
13581358
}
13591359
else
@@ -1366,7 +1366,7 @@ void ViewSceneDialog::mouseMoveEvent(QMouseEvent* event)
13661366
//--------------------------------------------------------------------------------------------------
13671367
bool ViewSceneDialog::needToWaitForWidgetSelection()
13681368
{
1369-
auto lastExec = transient_value_cast<unsigned long>(state_->getTransientValue(Modules::Render::ViewScene::TimeExecutionFinished));
1369+
const auto lastExec = transient_value_cast<unsigned long>(state_->getTransientValue(Parameters::TimeExecutionFinished));
13701370

13711371
return previousWidgetInfo_->timeSince(lastExec) < delayAfterModuleExecution_
13721372
|| previousWidgetInfo_->timeSinceWidgetColorRestored() < delayAfterWidgetColorRestored_
@@ -1390,7 +1390,7 @@ void ViewSceneDialog::mousePressEvent(QMouseEvent* event)
13901390
if (!clickedInViewer(event))
13911391
return;
13921392

1393-
auto btn = getSpireButton(event);
1393+
const auto btn = getSpireButton(event);
13941394
if (!tryWidgetSelection(event->x(), event->y(), btn))
13951395
{
13961396
auto spire = mSpire.lock();
@@ -1402,7 +1402,6 @@ void ViewSceneDialog::mousePressEvent(QMouseEvent* event)
14021402
float x_ss, y_ss;
14031403
spire->calculateScreenSpaceCoords(x_window, y_window, x_ss, y_ss);
14041404

1405-
14061405
for (auto vsd : viewScenesToUpdate)
14071406
vsd->inputMouseDownHelper(x_ss, y_ss);
14081407
}
@@ -1440,7 +1439,8 @@ void ViewSceneDialog::mouseReleaseEvent(QMouseEvent* event)
14401439
}
14411440
else if (!shiftdown_)
14421441
{
1443-
for (auto vsd : viewScenesToUpdate) vsd->inputMouseUpHelper();
1442+
for (auto* vsd : viewScenesToUpdate)
1443+
vsd->inputMouseUpHelper();
14441444
}
14451445

14461446
mouseButtonPressed_ = false;
@@ -1467,6 +1467,7 @@ void ViewSceneDialog::keyPressEvent(QKeyEvent* event)
14671467
shiftdown_ = true;
14681468
updateCursor();
14691469
break;
1470+
default: ;
14701471
}
14711472
}
14721473

@@ -1479,6 +1480,7 @@ void ViewSceneDialog::keyReleaseEvent(QKeyEvent* event)
14791480
shiftdown_ = false;
14801481
updateCursor();
14811482
break;
1483+
default: ;
14821484
}
14831485
}
14841486

@@ -1508,7 +1510,6 @@ void ViewSceneDialog::updateCursor()
15081510
//---------------- Camera --------------------------------------------------------------------------
15091511
//--------------------------------------------------------------------------------------------------
15101512

1511-
//--------------------------------------------------------------------------------------------------
15121513
void ViewSceneDialog::viewAxisSelected(const QString& name)
15131514
{
15141515
mUpVectorBox->clear();
@@ -1531,7 +1532,6 @@ void ViewSceneDialog::viewAxisSelected(const QString& name)
15311532
mUpVectorBox->setEnabled(true);
15321533
}
15331534

1534-
//--------------------------------------------------------------------------------------------------
15351535
void ViewSceneDialog::viewVectorSelected(const QString& name)
15361536
{
15371537
if (name.isEmpty())
@@ -1548,7 +1548,6 @@ void ViewSceneDialog::viewVectorSelected(const QString& name)
15481548
pushCameraState();
15491549
}
15501550

1551-
//--------------------------------------------------------------------------------------------------
15521551
void ViewSceneDialog::autoViewClicked()
15531552
{
15541553
auto spire = mSpire.lock();
@@ -1559,7 +1558,6 @@ void ViewSceneDialog::autoViewClicked()
15591558
pushCameraState();
15601559
}
15611560

1562-
//--------------------------------------------------------------------------------------------------
15631561
void ViewSceneDialog::menuMouseControlChanged(int index)
15641562
{
15651563
auto spire = mSpire.lock();
@@ -1579,51 +1577,44 @@ void ViewSceneDialog::menuMouseControlChanged(int index)
15791577
mConfigurationDock->updateZoomOptionVisibility();
15801578
}
15811579

1582-
//--------------------------------------------------------------------------------------------------
15831580
void ViewSceneDialog::invertZoomClicked(bool value)
15841581
{
15851582
auto spire = mSpire.lock();
15861583
spire->setZoomInverted(value);
15871584
Preferences::Instance().invertMouseZoom.setValue(value);
15881585
}
15891586

1590-
//--------------------------------------------------------------------------------------------------
15911587
void ViewSceneDialog::adjustZoomSpeed(int value)
15921588
{
15931589
auto spire = mSpire.lock();
15941590
spire->setZoomSpeed(value);
15951591
}
15961592

1597-
//--------------------------------------------------------------------------------------------------
15981593
void ViewSceneDialog::toggleLockColor(bool locked)
15991594
{
16001595
QString color = locked ? "red" : "rgb(66,66,69)";
16011596
controlLock_->setStyleSheet("QPushButton { background-color: " + color + "; }");
16021597
autoViewButton_->setDisabled(locked);
16031598
}
16041599

1605-
//--------------------------------------------------------------------------------------------------
16061600
void ViewSceneDialog::lockRotationToggled()
16071601
{
16081602
mGLWidget->setLockRotation(lockRotation_->isChecked());
16091603
toggleLockColor(lockRotation_->isChecked() || lockPan_->isChecked() || lockZoom_->isChecked());
16101604
}
16111605

1612-
//--------------------------------------------------------------------------------------------------
16131606
void ViewSceneDialog::lockPanningToggled()
16141607
{
16151608
mGLWidget->setLockPanning(lockPan_->isChecked());
16161609
toggleLockColor(lockRotation_->isChecked() || lockPan_->isChecked() || lockZoom_->isChecked());
16171610
}
16181611

1619-
//--------------------------------------------------------------------------------------------------
16201612
void ViewSceneDialog::lockZoomToggled()
16211613
{
16221614
mGLWidget->setLockZoom(lockZoom_->isChecked());
16231615
toggleLockColor(lockRotation_->isChecked() || lockPan_->isChecked() || lockZoom_->isChecked());
16241616
}
16251617

1626-
//--------------------------------------------------------------------------------------------------
16271618
void ViewSceneDialog::lockAllTriggered()
16281619
{
16291620
lockRotation_->setChecked(true);
@@ -1635,7 +1626,6 @@ void ViewSceneDialog::lockAllTriggered()
16351626
toggleLockColor(true);
16361627
}
16371628

1638-
//--------------------------------------------------------------------------------------------------
16391629
void ViewSceneDialog::unlockAllTriggered()
16401630
{
16411631
lockRotation_->setChecked(false);
@@ -1685,7 +1675,6 @@ void ViewSceneDialog::autoRotateDown()
16851675
//---------------- Widgets -------------------------------------------------------------------------
16861676
//--------------------------------------------------------------------------------------------------
16871677

1688-
//--------------------------------------------------------------------------------------------------
16891678
void ViewSceneDialog::updateMeshComponentSelection(const QString& showFieldName, const QString& component, bool selected)
16901679
{
16911680
auto name = showFieldName.toStdString();
@@ -1697,8 +1686,7 @@ void ViewSceneDialog::updateMeshComponentSelection(const QString& showFieldName,
16971686
state_->setTransientValue(Parameters::MeshComponentSelection, sel);
16981687
}
16991688

1700-
//--------------------------------------------------------------------------------------------------
1701-
static std::vector<WidgetHandle> filterGeomObjectsForWidgets(SCIRun::Modules::Render::ViewScene::GeomListPtr geomData, ViewSceneControlsDock* mConfigurationDock)
1689+
static std::vector<WidgetHandle> filterGeomObjectsForWidgets(ViewScene::GeomListPtr geomData, ViewSceneControlsDock* mConfigurationDock)
17021690
{
17031691
//getting geom list
17041692
std::vector<WidgetHandle> objList;
@@ -1751,7 +1739,7 @@ ViewScene::GeomListPtr ViewSceneDialog::getGeomData()
17511739

17521740
void ViewSceneDialog::selectObject(const int x, const int y, MouseButton button)
17531741
{
1754-
bool geomDataPresent = false;
1742+
auto geomDataPresent = false;
17551743
{
17561744
LOG_DEBUG("ViewSceneDialog::asyncExecute before locking");
17571745
Guard lock(Modules::Render::ViewScene::mutex_.get());
@@ -1760,22 +1748,22 @@ void ViewSceneDialog::selectObject(const int x, const int y, MouseButton button)
17601748
auto spire = mSpire.lock();
17611749
if (!spire) return;
17621750

1763-
auto geomData = getGeomData();
1751+
const auto geomData = getGeomData();
17641752
if (geomData)
17651753
{
17661754
geomDataPresent = true;
17671755
// Search for new widgets if geometry has changed
1768-
bool newGeometry = state_->getValue(Modules::Render::ViewScene::HasNewGeometry).toBool();
1756+
const bool newGeometry = state_->getValue(Parameters::HasNewGeometry).toBool();
17691757
if (newGeometry)
17701758
{
17711759
widgetHandles_ = filterGeomObjectsForWidgets(geomData, mConfigurationDock);
1772-
state_->setValue(Modules::Render::ViewScene::HasNewGeometry, false);
1760+
state_->setValue(Parameters::HasNewGeometry, false);
17731761
}
17741762

17751763
// Search for new widget unless mouse and camera wasn't moved
1776-
auto adjustedX = x - mGLWidget->pos().x();
1777-
auto adjustedY = y - mGLWidget->pos().y();
1778-
auto currentCameraTransform = spire->getWorldToProjection();
1764+
const auto adjustedX = x - mGLWidget->pos().x();
1765+
const auto adjustedY = y - mGLWidget->pos().y();
1766+
const auto currentCameraTransform = spire->getWorldToProjection();
17791767
//TODO: extract function
17801768
const bool reuseWidget = !newGeometry && previousWidgetInfo_->hasSameMousePosition(x, y)
17811769
&& previousWidgetInfo_->hasSameCameraTansform(currentCameraTransform);
@@ -1813,13 +1801,12 @@ void ViewSceneDialog::selectObject(const int x, const int y, MouseButton button)
18131801

18141802
bool ViewSceneDialog::checkForSelectedWidget(WidgetHandle widget)
18151803
{
1816-
auto geomData = getGeomData();
1804+
const auto geomData = getGeomData();
18171805
if (geomData)
18181806
{
1819-
auto id = widget->uniqueID();
1820-
for (auto it = geomData->begin(); it != geomData->end(); ++it)
1807+
const auto id = widget->uniqueID();
1808+
for (const auto& obj : *geomData)
18211809
{
1822-
auto obj = *it;
18231810
if (obj->uniqueID() == id)
18241811
return true;
18251812
}

src/Modules/Render/ViewScene.cc

Lines changed: 16 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -57,12 +57,12 @@ Mutex ViewScene::mutex_("ViewScene");
5757
ViewScene::ScopedExecutionReporter::ScopedExecutionReporter(ModuleStateHandle state)
5858
: state_(state)
5959
{
60-
state_->setValue(IsExecuting, true);
60+
state_->setValue(Parameters::IsExecuting, true);
6161
}
6262

6363
ViewScene::ScopedExecutionReporter::~ScopedExecutionReporter()
6464
{
65-
state_->setValue(IsExecuting, false);
65+
state_->setValue(Parameters::IsExecuting, false);
6666
}
6767

6868
ALGORITHM_PARAMETER_DEF(Render, GeomData);
@@ -125,15 +125,18 @@ ALGORITHM_PARAMETER_DEF(Render, IsFloating);
125125
ALGORITHM_PARAMETER_DEF(Render, CameraDistance);
126126
ALGORITHM_PARAMETER_DEF(Render, CameraDistanceMinimum);
127127
ALGORITHM_PARAMETER_DEF(Render, CameraLookAt);
128-
ALGORITHM_PARAMETER_DEF(Render, CameraRotation1);
128+
ALGORITHM_PARAMETER_DEF(Render, CameraRotation);
129+
ALGORITHM_PARAMETER_DEF(Render, IsExecuting);
130+
ALGORITHM_PARAMETER_DEF(Render, TimeExecutionFinished);
131+
ALGORITHM_PARAMETER_DEF(Render, HasNewGeometry);
129132

130133
ViewScene::ViewScene() : ModuleWithAsyncDynamicPorts(staticInfo_, true)
131134
{
132135
RENDERER_LOG_FUNCTION_SCOPE;
133-
INITIALIZE_PORT(GeneralGeom);
134-
INITIALIZE_PORT(ScreenshotDataRed);
135-
INITIALIZE_PORT(ScreenshotDataGreen);
136-
INITIALIZE_PORT(ScreenshotDataBlue);
136+
INITIALIZE_PORT(GeneralGeom)
137+
INITIALIZE_PORT(ScreenshotDataRed)
138+
INITIALIZE_PORT(ScreenshotDataGreen)
139+
INITIALIZE_PORT(ScreenshotDataBlue)
137140

138141
get_state()->setTransientValue(Parameters::VSMutex, &screenShotMutex_, true);
139142
}
@@ -199,12 +202,12 @@ void ViewScene::setStateDefaults()
199202
state->setValue(Parameters::WindowPositionY, 200);
200203
state->setValue(Parameters::IsFloating, true);
201204
state->setValue(Parameters::CameraDistance, 3.0);
202-
state->setValue(IsExecuting, false);
203-
state->setTransientValue(TimeExecutionFinished, 0, false);
205+
state->setValue(Parameters::IsExecuting, false);
206+
state->setTransientValue(Parameters::TimeExecutionFinished, 0, false);
204207
state->setValue(Parameters::CameraDistanceMinimum, 1e-10);
205208
state->setValue(Parameters::CameraLookAt, makeAnonymousVariableList(0.0, 0.0, 0.0));
206-
state->setValue(Parameters::CameraRotation1, makeAnonymousVariableList(1.0, 0.0, 0.0, 0.0));
207-
state->setValue(HasNewGeometry, false);
209+
state->setValue(Parameters::CameraRotation, makeAnonymousVariableList(1.0, 0.0, 0.0, 0.0));
210+
state->setValue(Parameters::HasNewGeometry, false);
208211

209212
get_state()->connectSpecificStateChanged(Parameters::GeometryFeedbackInfo, [this]() { processViewSceneObjectFeedback(); });
210213
get_state()->connectSpecificStateChanged(Parameters::MeshComponentSelection, [this]() { processMeshComponentSelection(); });
@@ -335,8 +338,8 @@ void ViewScene::execute()
335338
}
336339
}
337340
#endif
338-
state->setValue(HasNewGeometry, true);
339-
state->setTransientValue(TimeExecutionFinished, getCurrentTimeSinceEpoch(), false);
341+
state->setValue(Parameters::HasNewGeometry, true);
342+
state->setTransientValue(Parameters::TimeExecutionFinished, getCurrentTimeSinceEpoch(), false);
340343
}
341344

342345
unsigned long ViewScene::getCurrentTimeSinceEpoch()
@@ -368,7 +371,3 @@ void ViewScene::processMeshComponentSelection()
368371
sendFeedbackUpstreamAlongIncomingConnections(vsInfo);
369372
}
370373
}
371-
372-
const AlgorithmParameterName ViewScene::IsExecuting("IsExecuting");
373-
const AlgorithmParameterName ViewScene::TimeExecutionFinished("TimeExecutionFinished");
374-
const AlgorithmParameterName ViewScene::HasNewGeometry("HasNewGeometry");

src/Modules/Render/ViewScene.h

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,11 @@ namespace SCIRun
4949
ALGORITHM_PARAMETER_DECL(VSMutex);
5050
ALGORITHM_PARAMETER_DECL(GeometryFeedbackInfo);
5151
ALGORITHM_PARAMETER_DECL(ScreenshotData);
52+
53+
ALGORITHM_PARAMETER_DECL(IsExecuting);
54+
ALGORITHM_PARAMETER_DECL(TimeExecutionFinished);
55+
ALGORITHM_PARAMETER_DECL(HasNewGeometry);
56+
5257
// these should move from transient to saved
5358
ALGORITHM_PARAMETER_DECL(MeshComponentSelection);
5459
ALGORITHM_PARAMETER_DECL(ShowFieldStates);
@@ -88,7 +93,7 @@ namespace SCIRun
8893
ALGORITHM_PARAMETER_DECL(CameraDistance);
8994
ALGORITHM_PARAMETER_DECL(CameraDistanceMinimum);
9095
ALGORITHM_PARAMETER_DECL(CameraLookAt);
91-
ALGORITHM_PARAMETER_DECL(CameraRotation1);
96+
ALGORITHM_PARAMETER_DECL(CameraRotation);
9297

9398
// save/load has issues.
9499
ALGORITHM_PARAMETER_DECL(HeadLightOn);
@@ -154,11 +159,6 @@ namespace Render {
154159
void asyncExecute(const Dataflow::Networks::PortId& pid, Core::Datatypes::DatatypeHandle data) override;
155160
void setStateDefaults() override;
156161

157-
158-
static const Core::Algorithms::AlgorithmParameterName IsExecuting;
159-
static const Core::Algorithms::AlgorithmParameterName TimeExecutionFinished;
160-
static const Core::Algorithms::AlgorithmParameterName HasNewGeometry;
161-
162162
INPUT_PORT_DYNAMIC(0, GeneralGeom, GeometryObject)
163163
OUTPUT_PORT(0, ScreenshotDataRed, DenseMatrix)
164164
OUTPUT_PORT(1, ScreenshotDataGreen, DenseMatrix)

0 commit comments

Comments
 (0)