Exemplo n.º 1
0
void DialogTransformVolume::RespondTextTranslate( int n )
{
  if ( isVisible() )
  {
    bool bOK;
    double dvalue =m_textTranslate[n]->text().toDouble(&bOK);
    if ( bOK )
    {
      LayerMRI* layer = ( LayerMRI* )MainWindow::GetMainWindow()->GetActiveLayer( "MRI" );
      if ( layer )
      {
        double pos[3];
        layer->GetTranslate( pos );
        pos[n] = dvalue;
        layer->SetTranslate( pos );
        MainWindow::GetMainWindow()->RequestRedraw();

        double* vs = layer->GetWorldVoxelSize();
        int range = m_scrollTranslate[n]->maximum();
        m_scrollTranslate[n]->blockSignals(true);
        m_scrollTranslate[n]->setValue(range/2 + (int)( pos[n] / vs[n] ) );
        m_scrollTranslate[n]->blockSignals(false);
        UpdateUI( 1 );
      }
    }
  }
}
void DialogTransformVolume::RespondScrollTranslate( int n )
{
  if ( isVisible() )
  {
    LayerMRI* layer = ( LayerMRI* )MainWindow::GetMainWindow()->GetActiveLayer( "MRI" );
    if ( layer )
    {
      double pos[3];
      layer->GetTranslate( pos );
      int range = m_scrollTranslate[n]->maximum();
      int npos = m_scrollTranslate[n]->value();
      pos[n] = ( npos - range/2 ) * m_dIncrementTranslate;
      layer->SetTranslate( pos );
      MainWindow::GetMainWindow()->RequestRedraw();
      ChangeLineEditNumber(m_textTranslate[n], pos[n], 2, true);
      UpdateUI( 1 );
    }
  }
}