这个函数定义有什么问题?我创建了这两个函数,第二个调用了第一个函数,所以我想要的是,取决于第一个函数中的if,调用AlignCamera();将改变AlignXAXis();
中发生的事情void AlignCamera();
{
double cx = ox+(0.5*(xmax-xmin))*sx;
double cy = oy+(0.5*(ymax-ymin))*sy;
double cz = oz+(0.5*(zmax-zmin))*sz;
int vx=0;
int vy=0;
int vz=0;
int nx=0;
int ny=0;
int nz=0;
int iaxis = current_widget->GetPlaneOrientation();
if (iaxis == 0)
{
vz = -1;
nx = ox + xmax*sx;
cx = ox + 256*sx;
}
else if (iaxis == 1)
{
vz = -1;
ny = oy + ymax*sy;
cy = oy + 512*sy;
}
else
{
vy = 1;
nz = oz +zmax*sz;
cz = oz + 64*sz;
}
int px = cx+nx*2;
int py = cy+ny*2;
int pz = cz+nz*3;
vtkCamera *camera=ren->GetActiveCamera();
camera->SetViewUp(vx, vy, vz);
camera->SetFocalPoint(cx, cy, cz);
camera->SetPosition(px, py, pz);
camera->OrthogonalizeViewUp();
ren->ResetCameraClippingRange();
renWin->Render();
}
// Define the action of AlignXAxis
void AlignXAxis();
{
int slice_number;
int po = planeX->GetPlaneOrientation();
if (po == 3)
{
planeX->SetPlaneOrientationToXAxes();
slice_number = (xmax-xmin)/2;
planeX->SetSliceIndex(slice_number);
}
else
{
slice_number = planeX->GetSliceIndex();
}
current_widget= planeX;
ui->horizontalScrollBar->setValue(slice_number);
ui->horizontalScrollBar->setMinimum(xmin);
ui->horizontalScrollBar->setMaximum(xmax);
AlignCamera();
}
所需的变量在它之前定义,例如ox,oy,oz ....
当我运行它时,它表示对'AlignCamera()'或'AlignXAxis()'的未定义引用。
答案 0 :(得分:3)
void AlignCamera(); //This is merely a prototype, not a declaration.
删除分号,或之后创建声明。
void AlignCamera(); //Prototype
void AlignCamera() { //Declaration
//Do Stuff
}
这同样适用于其他功能。删除分号。
答案 1 :(得分:2)
删除分号,所以:
void AlignCamera();
{
...
}
变为
void AlignCamera()
{
...
}