0

我在代码中的某个地方遇到了这个问题,当我尝试添加一个分数时,代码只是忽略了该部分并表现得好像它不存在一样。我将在这里放一些我的代码示例。

例如在我的 vtkBMPReader 中:

  vtkBMPReader *bmp= vtkBMPReader::New();
    bmp->SetDataByteOrderToLittleEndian();
    bmp->SetFilePrefix ("/home/matt/Desktop/ouBMP/exemplo");
    bmp->SetFilePattern("%s%d.bmp");
    bmp->SetFileNameSliceSpacing(1);
    bmp->SetNumberOfScalarComponents(3);
    bmp->SetDataOrigin(0,0,0);
    bmp->SetDataSpacing(0.011741683,0.005865103,0.047244094);//here it should be (6/511,6/1023,6/127)
    bmp->SetDataExtent(0,511,0,1023,1,128);
    bmp->Update();

和这里:

// Function to transform the slider scale from pixel to mm
void planevolume::mm()
{
    // Set the sliders ranges and connections
    // X Slider
      double xvalue=ui->lcdNumber->value();
      ui->Slider->setValue(xvalue/(256/3));//here it does not work
      ui->Slider->setRange(xmin, xmax/(512/6), 1.0/(512/6));
      ui->Slider->setScale(xmin, (xmax+1)/(256/3), ((xmax+1)/16)/(256/3));//the last member does not work
      connect(ui->Slider, SIGNAL(valueChanged(double)), ui->lcdNumber, SLOT(display(double)));

    // Y Slider
      double yvalue=ui->lcdNumber_2->value();
      ui->Slider_2->setValue(yvalue/(512));//as here
      ui->Slider_2->setRange(ymin, ymax/(1023/2), 1.0/(1023/2));
      ui->Slider_2->setScale(ymin, (ymax+1)/512, (((ymax+1)/16)/512));//as here
      connect(ui->Slider_2, SIGNAL(valueChanged(double)), ui->lcdNumber_2, SLOT(display(double)));

    // Z Slider
      double zvalue=ui->lcdNumber_3->value();
      ui->Slider_3->setValue(zvalue/(64/3));//as here
      ui->Slider_3->setRange(zmin, zmax/(127/6), 1.0/(127/6));
      ui->Slider_3->setScale(zmin, (zmax+1)/(64/3),(((zmax+1)/16)/(64/3)));//as here
      connect(ui->Slider_3, SIGNAL(valueChanged(double)), ui->lcdNumber_3, SLOT(display(double)));
}

但在这个类似的情况下,它确实有效!

// Function to transform the slider scale from mm to pixel
void planevolume::pixel()
{
// Set the sliders ranges and connections
// X Slider
  double xvalue=ui->lcdNumber->value();
  ui->Slider->setValue(xvalue*(256/3));//here it works!!
  ui->Slider->setRange(xmin, xmax, 1.0);
  ui->Slider->setScale(xmin, xmax+1, (xmax+1)/16);
  connect(ui->Slider, SIGNAL(valueChanged(double)), ui->lcdNumber, SLOT(display(double)));

// Y Slider
  double yvalue=ui->lcdNumber_2->value();
  ui->Slider_2->setValue(yvalue*512);//here it works!!
  ui->Slider_2->setRange(ymin, ymax, 1.0);
  ui->Slider_2->setScale(ymin, ymax+1, (ymax+1)/16);
  connect(ui->Slider_2, SIGNAL(valueChanged(double)), ui->lcdNumber_2, SLOT(display(double)));

// Z Slider
  double zvalue=ui->lcdNumber_3->value();
  ui->Slider_3->setValue(zvalue*(64/3));//here it works!!
  ui->Slider_3->setRange(zmin, zmax, 1.0);
  ui->Slider_3->setScale(zmin, zmax+1, (zmax+1)/16);
  connect(ui->Slider_3, SIGNAL(valueChanged(double)), ui->lcdNumber_3, SLOT(display(double)));

}

如果有人知道我能做什么,请帮助我。

4

1 回答 1

0

我只需在所有数字上添加 .0 就可以了。

于 2012-08-24T10:03:36.257 回答