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

Method LassoSelectInternal

Views/Infovis/vtkParallelCoordinatesRepresentation.cxx:1439–1492  ·  view source on GitHub ↗

------------------------------------------------------------------------------

Source from the content-addressed store, hash-verified

1437
1438//------------------------------------------------------------------------------
1439void vtkParallelCoordinatesRepresentation::LassoSelectInternal(
1440 vtkPoints* brushPoints, vtkIdTypeArray* outIds)
1441{
1442 if (brushPoints->GetNumberOfPoints() <= 0)
1443 return;
1444
1445 double* p = brushPoints->GetPoint(0);
1446 int position = this->ComputePointPosition(p);
1447
1448 if (position < 0 || position >= this->NumberOfAxes)
1449 return;
1450
1451 double leftAxisRange[2], rightAxisRange[2];
1452 leftAxisRange[0] = leftAxisRange[1] = rightAxisRange[0] = rightAxisRange[1] = 0;
1453 this->GetRangeAtPosition(position, leftAxisRange);
1454 this->GetRangeAtPosition(position + 1, rightAxisRange);
1455
1456 double dLeft = leftAxisRange[1] - leftAxisRange[0];
1457 double dRight = rightAxisRange[1] - rightAxisRange[0];
1458 double dy = this->YMax - this->YMin;
1459
1460 this->LinearThreshold->Initialize();
1461 this->LinearThreshold->SetLinearThresholdTypeToBetween();
1462 this->LinearThreshold->SetDistanceThreshold(this->AngleBrushThreshold);
1463 this->LinearThreshold->UseNormalizedDistanceOn();
1464 this->LinearThreshold->SetColumnRanges(dLeft, dRight);
1465 this->LinearThreshold->AddColumnToThreshold(position, 0);
1466 this->LinearThreshold->AddColumnToThreshold(position + 1, 0);
1467
1468 // add a line equation for each brush point
1469 for (int i = 0; i < brushPoints->GetNumberOfPoints(); i++)
1470 {
1471 p = brushPoints->GetPoint(i);
1472
1473 // normalize p into [0,1]x[0,1]
1474 double pn[2] = { (p[0] - this->Xs[position]) / (this->Xs[position + 1] - this->Xs[position]),
1475 (p[1] - this->YMin) / dy };
1476
1477 // now compute actual data values for two PC lines passing through pn,
1478 // starting from the endpoints of the left axis
1479 double q[2] = { leftAxisRange[0], rightAxisRange[0] + pn[1] / pn[0] * dRight };
1480
1481 double r[2] = { leftAxisRange[1], rightAxisRange[0] + (1.0 + (pn[1] - 1.0) / pn[0]) * dRight };
1482
1483 this->LinearThreshold->AddLineEquation(q, r);
1484 }
1485
1486 this->LinearThreshold->Update();
1487 vtkIdTypeArray* ids = this->LinearThreshold->GetSelectedRowIds();
1488 for (int i = 0; i < ids->GetNumberOfTuples(); i++)
1489 {
1490 outIds->InsertNextTuple(i, ids);
1491 }
1492}
1493//------------------------------------------------------------------------------
1494// All lines that have the same slope in PC space represent a set of points
1495// that define a line in XY space. PC lines that have similar slope are all

Callers 1

LassoSelectMethod · 0.95

Calls 11

ComputePointPositionMethod · 0.95
GetRangeAtPositionMethod · 0.95
AddColumnToThresholdMethod · 0.80
AddLineEquationMethod · 0.80
GetSelectedRowIdsMethod · 0.80
GetNumberOfPointsMethod · 0.45
GetPointMethod · 0.45
InitializeMethod · 0.45
UpdateMethod · 0.45
GetNumberOfTuplesMethod · 0.45
InsertNextTupleMethod · 0.45

Tested by

no test coverage detected