MCPcopy Create free account
hub / github.com/Kitware/VTK / SetNumberOfHandles

Method SetNumberOfHandles

Interaction/Widgets/vtkSplineWidget.cxx:1158–1219  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1156}
1157
1158void vtkSplineWidget::SetNumberOfHandles(int npts)
1159{
1160 if (this->NumberOfHandles == npts)
1161 {
1162 return;
1163 }
1164 if (npts < 2)
1165 {
1166 vtkGenericWarningMacro(<< "vtkSplineWidget: minimum of 2 points required.");
1167 return;
1168 }
1169
1170 double radius = this->HandleGeometry[0]->GetRadius();
1171 this->Initialize();
1172
1173 this->NumberOfHandles = npts;
1174
1175 // Create the handles
1176 this->Handle = new vtkActor*[this->NumberOfHandles];
1177 this->HandleGeometry = new vtkSphereSource*[this->NumberOfHandles];
1178
1179 int i;
1180 double pt[3];
1181 double u[3];
1182 for (i = 0; i < this->NumberOfHandles; ++i)
1183 {
1184 this->HandleGeometry[i] = vtkSphereSource::New();
1185 this->HandleGeometry[i]->SetThetaResolution(16);
1186 this->HandleGeometry[i]->SetPhiResolution(8);
1187 vtkPolyDataMapper* handleMapper = vtkPolyDataMapper::New();
1188 handleMapper->SetInputConnection(this->HandleGeometry[i]->GetOutputPort());
1189 this->Handle[i] = vtkActor::New();
1190 this->Handle[i]->SetMapper(handleMapper);
1191 handleMapper->Delete();
1192 this->Handle[i]->SetProperty(this->HandleProperty);
1193 u[0] = i / (this->NumberOfHandles - 1.0);
1194 this->ParametricSpline->Evaluate(u, pt, nullptr);
1195 this->HandleGeometry[i]->SetCenter(pt);
1196 this->HandleGeometry[i]->SetRadius(radius);
1197 this->HandlePicker->AddPickList(this->Handle[i]);
1198 }
1199
1200 this->BuildRepresentation();
1201
1202 if (this->Interactor)
1203 {
1204 if (!this->CurrentRenderer)
1205 {
1206 this->SetCurrentRenderer(this->Interactor->FindPokedRenderer(
1207 this->Interactor->GetLastEventPosition()[0], this->Interactor->GetLastEventPosition()[1]));
1208 }
1209 if (this->CurrentRenderer != nullptr)
1210 {
1211 for (i = 0; i < this->NumberOfHandles; ++i)
1212 {
1213 this->CurrentRenderer->AddViewProp(this->Handle[i]);
1214 }
1215 this->SizeHandles();

Callers 6

InitializeHandlesMethod · 0.95
TestSplineWidgetFunction · 0.45
TestOSPRaySplineWidget2Function · 0.45

Calls 15

InitializeMethod · 0.95
BuildRepresentationMethod · 0.95
SizeHandlesMethod · 0.95
SetThetaResolutionMethod · 0.80
SetPhiResolutionMethod · 0.80
DeleteMethod · 0.65
RenderMethod · 0.65
NewFunction · 0.50
GetRadiusMethod · 0.45
SetInputConnectionMethod · 0.45
GetOutputPortMethod · 0.45
SetMapperMethod · 0.45

Tested by 5

TestSplineWidgetFunction · 0.36
TestOSPRaySplineWidget2Function · 0.36