Skip to content

Commit db2bd8b

Browse files
committed
Added command-line option to set overlay threshold offset
1 parent b598e6e commit db2bd8b

File tree

4 files changed

+38
-2
lines changed

4 files changed

+38
-2
lines changed

freeview/MainWindow.cpp

Lines changed: 35 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2013,6 +2013,10 @@ void MainWindow::RunScript()
20132013
{
20142014
CommandSetSurfaceOverlayOpacity( sa );
20152015
}
2016+
else if ( cmd == "setsurfaceoverlayoffset")
2017+
{
2018+
CommandSetSurfaceOverlayOffset(sa);
2019+
}
20162020
else if ( cmd == "setsurfaceoverlayframe")
20172021
{
20182022
CommandSetSurfaceOverlayFrame( sa );
@@ -3603,7 +3607,7 @@ void MainWindow::CommandLoadSurface( const QStringList& cmd )
36033607
QVariantMap sup_options;
36043608
valid_overlay_options << "overlay_reg" << "overlay_method" << "overlay_threshold" << "overlay_color"
36053609
<< "overlay_rh" << "overlay_opacity" << "overlay_frame" << "overlay_smooth" << "overlay_custom"
3606-
<< "overlay_mask";
3610+
<< "overlay_mask" << "overlay_offset";
36073611
bool bNoAutoLoad = m_defaultSettings["no_autoload"].toBool();
36083612
for (int nOverlay = 0; nOverlay < overlay_list.size(); nOverlay++)
36093613
{
@@ -3622,6 +3626,7 @@ void MainWindow::CommandLoadSurface( const QStringList& cmd )
36223626
QStringList overlay_thresholds;
36233627
QStringList overlay_custom;
36243628
QStringList overlay_mask;
3629+
QString overlay_offset;
36253630
bool bSecondHalfData = false;
36263631
for ( int k = sa_fn.size()-1; k >= 0; k-- )
36273632
{
@@ -3650,6 +3655,8 @@ void MainWindow::CommandLoadSurface( const QStringList& cmd )
36503655
overlay_custom = subArgu.split(",", MD_SkipEmptyParts);
36513656
else if (subOption == "overlay_mask")
36523657
overlay_mask = subArgu.split(",", MD_SkipEmptyParts);
3658+
else if (subOption == "overlay_offset")
3659+
overlay_offset = subArgu;
36533660
}
36543661
}
36553662
if (overlay_reg.isEmpty())
@@ -3764,6 +3771,9 @@ void MainWindow::CommandLoadSurface( const QStringList& cmd )
37643771

37653772
if (!overlay_mask.isEmpty())
37663773
m_scripts.insert(1, QStringList("setsurfaceoverlaymask") << overlay_mask);
3774+
3775+
if (!overlay_offset.isEmpty())
3776+
m_scripts.insert(1, QStringList("setsurfaceoverlayoffset") << overlay_offset);
37673777
}
37683778
else if ( subOption == "mrisps" )
37693779
{
@@ -4077,6 +4087,30 @@ void MainWindow::CommandSetSurfaceOverlayOpacity(const QStringList &cmd)
40774087
}
40784088
}
40794089

4090+
void MainWindow::CommandSetSurfaceOverlayOffset(const QStringList &cmd)
4091+
{
4092+
LayerSurface* surf = (LayerSurface*)GetLayerCollection( "Surface" )->GetActiveLayer();
4093+
if ( surf )
4094+
{
4095+
SurfaceOverlay* overlay = surf->GetActiveOverlay();
4096+
if ( overlay )
4097+
{
4098+
bool ok;
4099+
double val = cmd[1].toDouble(&ok);
4100+
if (ok)
4101+
{
4102+
overlay->GetProperty()->SetOffset(val);
4103+
surf->UpdateOverlay(true);
4104+
overlay->EmitDataUpdated();
4105+
}
4106+
else
4107+
{
4108+
cerr << "Invalid input for overlay offset.\n";
4109+
}
4110+
}
4111+
}
4112+
}
4113+
40804114
void MainWindow::CommandSetSurfaceOverlayFrame(const QStringList &cmd)
40814115
{
40824116
LayerSurface* surf = (LayerSurface*)GetLayerCollection( "Surface" )->GetActiveLayer();

freeview/MainWindow.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -404,6 +404,7 @@ public slots:
404404
void CommandSetSurfaceOverlaySmooth ( const QStringList& cmd );
405405
void CommandSetSurfaceOverlayMask ( const QStringList& cmd );
406406
void CommandSetSurfaceOverlayCustom ( const QStringList& cmd );
407+
void CommandSetSurfaceOverlayOffset ( const QStringList& cmd );
407408
void CommandSetSurfaceColor ( const QStringList& cmd );
408409
void CommandSetSurfaceEdgeColor ( const QStringList& cmd );
409410
void CommandSetSurfaceEdgeThickness ( const QStringList& cmd );

freeview/RenderView3D.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -558,7 +558,7 @@ void RenderView3D::DoUpdateRASPosition( int posX, int posY, bool bCursor, bool b
558558
lc_mri->SetCursorRASPosition( pos );
559559
MainWindow::GetMainWindow()->SetSlicePosition( pos );
560560
}
561-
else if ( lc_mri->HasProp( prop ) || lc_roi->HasProp( prop ) )
561+
else if ( mri_sel || lc_roi->HasProp( prop ) )
562562
{
563563
if ( bCursor )
564564
{

freeview/main.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -200,6 +200,7 @@ int main(int argc, char *argv[])
200200
"':overlay_custom=[filename]val,r,g,b,val2,r2,g2,b2...' Set customized overlay color. If only given one argument as filename, customized color scale will be loaded from the given file.\n\n"
201201
"':overlay_opacity=opacity' Set opacity of overlay.\n\n"
202202
"':overlay_threshold=low,(mid,)high(,percentile)' Set overlay threshold values, separated by comma. When overlay method is linear or linearopaque, only 2 numbers (low and high) are needed. When method is piecewise, 3 numbers are needed. If last element is 'percentile', use the give numbers as percentile.\n\n"
203+
"':overlay_offset=offset' Set the offset for overlay threshold setting.\n\n"
203204
"':overlay_mask=filename(,invert)' Use given label file as mask for overlay. If invert is specified, use the inverted mask.\n\n"
204205
"':overlay_frame=frame_number' Set active frame of multi-frame overlay.\n\n"
205206
"':overlay_smooth=smooth_steps' Set smooth steps for overlay.\n\n"

0 commit comments

Comments
 (0)