36 #include <vtkObjectFactory.h> 37 #include <vtkTextProperty.h> 38 #include <vtkRenderWindowInteractor.h> 39 #include <vtkAbstractPicker.h> 40 #include <vtkRenderWindow.h> 41 #include <vtkRendererCollection.h> 42 #include <vtkPointPicker.h> 43 #include <vtkCamera.h> 44 #include <vtkCallbackCommand.h> 45 #include <vtkSphereSource.h> 46 #include <vtkPolyData.h> 47 #include <vtkSmartPointer.h> 48 #include <vtkPolyDataMapper.h> 49 #include <vtkProperty.h> 51 #include <vtkActorCollection.h> 52 #include <vtkCubeSource.h> 53 #include <vtkPlanes.h> 54 #include <vtkAreaPicker.h> 55 #include <vtkVertexGlyphFilter.h> 56 #include <vtkVersion.h> 57 #include <vtkPointData.h> 58 #include <vtkIdTypeArray.h> 59 #include <vtkDataSetSurfaceFilter.h> 60 #include <vtkPolyLine.h> 61 #include <vtkObjectFactory.h> 62 #include <vtkPointSource.h> 63 #include <vtkExtractGeometry.h> 64 #include <vtkDataSetMapper.h> 65 #include <vtkUnstructuredGrid.h> 66 #include <vtkIdFilter.h> 76 m_motionFactor(50), m_rotationFactor(20), m_interactorMode(TRACKBALL)
89 vtkSmartPointer<vtkTextProperty>
p = vtkSmartPointer<vtkTextProperty>::New();
90 p->SetColor(1.0, 1.0, 0.0);
109 vtkSmartPointer<vtkSphereSource> sphereSource = vtkSmartPointer<vtkSphereSource>::New();
110 sphereSource->SetCenter(0.0, 0.0, 0.0);
115 double s = std::max(fabs(b[0] - b[1]), std::max(fabs(b[2] - b[3]), fabs(b[4] - b[5]))) * 0.1;
117 sphereSource->SetRadius(s);
119 vtkSmartPointer<vtkPolyDataMapper> mapper = vtkSmartPointer<vtkPolyDataMapper>::New();
120 mapper->SetInputConnection(sphereSource->GetOutputPort());
127 double focalPoint[3];
128 m_renderer->GetActiveCamera()->GetFocalPoint(focalPoint);
129 m_sphereActor->SetPosition(focalPoint[0], focalPoint[1], focalPoint[2]);
136 vtkRenderWindowInteractor *rwi = this->Interactor;
137 if(state == Qt::Checked)
139 rwi->GetRenderWindow()->StereoRenderOn();
143 rwi->GetRenderWindow()->StereoRenderOff();
150 if(state == Qt::Checked)
158 vtkRenderWindowInteractor *rwi = this->Interactor;
164 double focalPoint[3];
165 m_renderer->GetActiveCamera()->GetFocalPoint(focalPoint);
166 m_sphereActor->SetPosition(focalPoint[0], focalPoint[1], focalPoint[2]);
538 vtkRenderWindowInteractor *rwi = this->Interactor;
539 vtkCamera *camera = this->CurrentRenderer->GetActiveCamera();
546 double focalPoint[3];
548 camera->GetPosition(position);
549 camera->GetDirectionOfProjection(direction);
550 camera->GetFocalPoint(focalPoint);
551 camera->GetViewUp(viewUp[0], viewUp[1], viewUp[2]);
553 vtkMath::Cross(direction, viewUp, cross);
557 position[0] + 3 * factor * cross[0],
558 position[1] + 3 * factor * cross[1],
559 position[2] + 3 * factor * cross[2]);
562 camera->SetFocalPoint(
563 focalPoint[0] + 3 * factor * cross[0],
564 focalPoint[1] + 3 * factor * cross[1],
565 focalPoint[2] + 3 * factor * cross[2]);
567 camera->OrthogonalizeViewUp();
569 if (this->AutoAdjustCameraClippingRange)
571 this->CurrentRenderer->ResetCameraClippingRange();
580 vtkRenderWindowInteractor *rwi = this->Interactor;
581 vtkCamera *camera = this->CurrentRenderer->GetActiveCamera();
588 vtkRenderWindowInteractor *rwi = this->Interactor;
589 if(this->CurrentRenderer!=
nullptr)
591 this->CurrentRenderer->ResetCamera();
595 vtkWarningMacro(<<
"no current renderer on the interactor style.");
603 vtkRenderWindowInteractor *rwi = this->Interactor;
604 vtkCamera *camera = this->CurrentRenderer->GetActiveCamera();
609 camera->GetPosition(position);
610 camera->GetDirectionOfProjection(direction);
612 camera->SetFocalPoint(
613 position[0] + 3 * fabs(factor) * direction[0],
614 position[1] + 3 * fabs(factor) * direction[1],
615 position[2] + 3 * fabs(factor) * direction[2]);
621 position[0] - factor * direction[0],
622 position[1] - factor * direction[1],
623 position[2] - factor * direction[2]);
625 camera->OrthogonalizeViewUp();
627 if (this->AutoAdjustCameraClippingRange)
629 this->CurrentRenderer->ResetCameraClippingRange();
638 vtkRenderWindowInteractor *rwi = this->Interactor;
639 vtkCamera *camera = this->CurrentRenderer->GetActiveCamera();
642 int mx = rwi->GetSize()[0] / 2;
643 int my = rwi->GetSize()[1] / 2;
651 camera->Yaw(-yawAngle);
652 camera->Pitch(pitchAngle);
653 camera->OrthogonalizeViewUp();
654 camera->ViewingRaysModified();
656 if (this->AutoAdjustCameraClippingRange)
658 this->CurrentRenderer->ResetCameraClippingRange();
666 vtkRenderWindowInteractor *rwi = this->Interactor;
667 vtkCamera *camera = this->CurrentRenderer->GetActiveCamera();
669 int my = rwi->GetSize()[1] / 2;
677 camera->GetPosition(position);
678 camera->GetFocalPoint(focal);
679 camera->GetViewUp(direction);
686 position[0] + step * direction[0],
687 position[1] + step * direction[1],
688 position[2] + step * direction[2]);
691 camera->SetFocalPoint(
692 focal[0] + step * direction[0],
693 focal[1] + step * direction[1],
694 focal[2] + step * direction[2]);
697 camera->ViewingRaysModified();
699 if (this->AutoAdjustCameraClippingRange)
701 this->CurrentRenderer->ResetCameraClippingRange();
732 this->FindPokedRenderer(this->Interactor->GetEventPosition()[0],
733 this->Interactor->GetEventPosition()[1]);
734 if (this->CurrentRenderer ==
nullptr)
739 GrabFocus(this->EventCallbackCommand,
nullptr);
743 vtkRenderWindowInteractor *rwi = this->Interactor;
754 if ( this->Interactor )
756 this->ReleaseFocus();
785 if ( this->Interactor )
787 this->ReleaseFocus();
796 this->FindPokedRenderer(this->Interactor->GetEventPosition()[0],
797 this->Interactor->GetEventPosition()[1]);
798 if (this->CurrentRenderer ==
nullptr)
803 GrabFocus(this->EventCallbackCommand,
nullptr);
807 vtkRenderWindowInteractor *rwi = this->Interactor;
834 if (this->CurrentRenderer ==
nullptr)
839 vtkRenderWindowInteractor *rwi = this->Interactor;
840 vtkCamera *camera = this->CurrentRenderer->GetActiveCamera();
841 double *center = this->CurrentRenderer->GetCenter();
843 int dy = rwi->GetEventPosition()[1] - rwi->GetLastEventPosition()[1];
845 double zoomFactor = pow(1.1, dyf);
847 if (camera->GetParallelProjection())
849 camera->SetParallelScale(camera->GetParallelScale() / zoomFactor);
853 camera->Dolly( zoomFactor );
854 if (this->AutoAdjustCameraClippingRange)
856 this->CurrentRenderer->ResetCameraClippingRange();
860 if (rwi->GetLightFollowCamera())
862 this->CurrentRenderer->UpdateLightsGeometryToFollowCamera();
875 if (this->CurrentRenderer ==
nullptr)
880 vtkRenderWindowInteractor *rwi = this->Interactor;
884 double fp[3], focalPoint[3], pos[3], v[3], p1[4], p2[4];
886 vtkCamera *camera = this->CurrentRenderer->GetActiveCamera();
887 camera->GetPosition( pos );
888 camera->GetFocalPoint( fp );
890 this->ComputeWorldToDisplay(fp[0], fp[1], fp[2],
893 this->ComputeDisplayToWorld(rwi->GetEventPosition()[0],
894 rwi->GetEventPosition()[1],
898 this->ComputeDisplayToWorld(rwi->GetLastEventPosition()[0],
899 rwi->GetLastEventPosition()[1],
903 for (
int i=0; i<3; i++)
905 v[i] = p2[i] - p1[i];
910 camera->SetPosition( pos );
911 camera->SetFocalPoint( fp );
913 if (rwi->GetLightFollowCamera())
915 this->CurrentRenderer->UpdateLightsGeometryToFollowCamera();
933 if (this->CurrentRenderer ==
nullptr)
938 vtkRenderWindowInteractor *rwi = this->Interactor;
940 int dx = - ( rwi->GetEventPosition()[0] - rwi->GetLastEventPosition()[0] );
941 int dy = - ( rwi->GetEventPosition()[1] - rwi->GetLastEventPosition()[1] );
943 int *size = this->CurrentRenderer->GetRenderWindow()->GetSize();
945 double a = dx /
static_cast<double>( size[0]) * 180.0;
946 double e = dy /
static_cast<double>( size[1]) * 180.0;
948 if (rwi->GetShiftKey())
950 if(
abs( dx ) >=
abs( dy ))
963 vtkCamera *camera = this->CurrentRenderer->GetActiveCamera();
964 camera->Azimuth( a );
966 double dop[3], vup[3];
968 camera->GetDirectionOfProjection( dop );
969 vtkMath::Normalize( dop );
970 camera->GetViewUp( vup );
971 vtkMath::Normalize( vup );
973 double angle = vtkMath::DegreesFromRadians( acos(vtkMath::Dot( dop, vup) ) );
974 if ( ( angle + e ) > 179.0 ||
975 ( angle + e ) < 1.0 )
980 camera->Elevation( e );
982 if ( this->AutoAdjustCameraClippingRange )
984 this->CurrentRenderer->ResetCameraClippingRange();
992 this->FindPokedRenderer(this->Interactor->GetEventPosition()[0],
993 this->Interactor->GetEventPosition()[1]);
994 if (this->CurrentRenderer ==
nullptr)
999 this->GrabFocus(this->EventCallbackCommand);
1000 this->StartRotate();
1005 switch (this->State)
1009 if ( this->Interactor )
1011 this->ReleaseFocus();
1019 int x = this->Interactor->GetEventPosition()[0];
1020 int y = this->Interactor->GetEventPosition()[1];
1022 switch (this->State)
1025 this->FindPokedRenderer(x, y);
1027 this->InvokeEvent(vtkCommand::InteractionEvent,
nullptr);
1031 this->FindPokedRenderer(x, y);
1033 this->InvokeEvent(vtkCommand::InteractionEvent,
nullptr);
1037 this->FindPokedRenderer(x, y);
1039 this->InvokeEvent(vtkCommand::InteractionEvent,
nullptr);
1046 switch (this->State)
1050 if ( this->Interactor )
1052 this->ReleaseFocus();
1060 this->FindPokedRenderer(this->Interactor->GetEventPosition()[0],
1061 this->Interactor->GetEventPosition()[1]);
1062 if (this->CurrentRenderer ==
nullptr)
1067 this->GrabFocus(this->EventCallbackCommand);
1073 switch (this->State)
1077 if ( this->Interactor )
1079 this->ReleaseFocus();
1087 this->FindPokedRenderer(this->Interactor->GetEventPosition()[0],
1088 this->Interactor->GetEventPosition()[1]);
1089 if (this->CurrentRenderer ==
nullptr)
1094 this->GrabFocus(this->EventCallbackCommand);
1110 if (this->CurrentRenderer ==
nullptr)
1115 vtkCamera *camera = this->CurrentRenderer->GetActiveCamera();
1116 if (camera->GetParallelProjection())
1118 camera->SetParallelScale(camera->GetParallelScale() / factor);
1123 double direction[3];
1125 camera->GetPosition(position);
1126 camera->GetDirectionOfProjection(direction);
1129 camera->SetPosition(
1130 position[0] - factor * direction[0],
1131 position[1] - factor * direction[1],
1132 position[2] - factor * direction[2]);
1134 if (this->AutoAdjustCameraClippingRange)
1136 this->CurrentRenderer->ResetCameraClippingRange();
1140 if (this->Interactor->GetLightFollowCamera())
1142 this->CurrentRenderer->UpdateLightsGeometryToFollowCamera();
1145 this->Interactor->Render();
1150 if (this->CurrentRenderer ==
nullptr)
1155 vtkRenderWindowInteractor *rwi = this->Interactor;
1156 double *center = this->CurrentRenderer->GetCenter();
1157 int dy = rwi->GetEventPosition()[1] - rwi->GetLastEventPosition()[1];
1158 double dyf = 1 * dy / center[1];
1160 if (this->CurrentRenderer ==
nullptr)
1165 vtkCamera *camera = this->CurrentRenderer->GetActiveCamera();
1166 if (camera->GetParallelProjection())
1168 camera->SetParallelScale(camera->GetParallelScale() / dyf);
1173 if (this->AutoAdjustCameraClippingRange)
1175 this->CurrentRenderer->ResetCameraClippingRange();
1179 if (this->Interactor->GetLightFollowCamera())
1181 this->CurrentRenderer->UpdateLightsGeometryToFollowCamera();
1184 this->Interactor->Render();
1189 if (this->CurrentRenderer ==
nullptr)
1194 vtkRenderWindowInteractor *rwi = this->Interactor;
1196 double viewFocus[4], focalDepth, viewPoint[3];
1197 double newPickPoint[4], oldPickPoint[4], motionVector[3];
1201 vtkCamera *camera = this->CurrentRenderer->GetActiveCamera();
1202 camera->GetFocalPoint(viewFocus);
1203 this->ComputeWorldToDisplay(viewFocus[0], viewFocus[1], viewFocus[2],
1205 focalDepth = viewFocus[2];
1207 this->ComputeDisplayToWorld(rwi->GetEventPosition()[0],
1208 rwi->GetEventPosition()[1],
1215 this->ComputeDisplayToWorld(rwi->GetLastEventPosition()[0],
1216 rwi->GetLastEventPosition()[1],
1222 motionVector[0] = oldPickPoint[0] - newPickPoint[0];
1223 motionVector[1] = oldPickPoint[1] - newPickPoint[1];
1224 motionVector[2] = oldPickPoint[2] - newPickPoint[2];
1226 camera->GetFocalPoint(viewFocus);
1227 camera->GetPosition(viewPoint);
1228 camera->SetFocalPoint(motionVector[0] + viewFocus[0],
1229 motionVector[1] + viewFocus[1],
1230 motionVector[2] + viewFocus[2]);
1232 camera->SetPosition(motionVector[0] + viewPoint[0],
1233 motionVector[1] + viewPoint[1],
1234 motionVector[2] + viewPoint[2]);
1236 if (rwi->GetLightFollowCamera())
1238 this->CurrentRenderer->UpdateLightsGeometryToFollowCamera();
1246 if ( this->CurrentRenderer ==
nullptr )
1251 vtkRenderWindowInteractor *rwi = this->Interactor;
1253 double *center = this->CurrentRenderer->GetCenter();
1256 vtkMath::DegreesFromRadians( atan2( rwi->GetEventPosition()[1] - center[1],
1257 rwi->GetEventPosition()[0] - center[0] ) );
1260 vtkMath::DegreesFromRadians( atan2( rwi->GetLastEventPosition()[1] - center[1],
1261 rwi->GetLastEventPosition()[0] - center[0] ) );
1263 vtkCamera *camera = this->CurrentRenderer->GetActiveCamera();
1264 camera->Roll( newAngle - oldAngle );
1265 camera->OrthogonalizeViewUp();
1277 if (this->CurrentRenderer ==
nullptr)
1282 vtkRenderWindowInteractor *rwi = this->Interactor;
1284 int dx = rwi->GetEventPosition()[0] - rwi->GetLastEventPosition()[0];
1285 int dy = rwi->GetEventPosition()[1] - rwi->GetLastEventPosition()[1];
1287 int *size = this->CurrentRenderer->GetRenderWindow()->GetSize();
1295 vtkCamera *camera = this->CurrentRenderer->GetActiveCamera();
1296 camera->Azimuth(rxf);
1297 camera->Elevation(ryf);
1298 camera->OrthogonalizeViewUp();
1300 if (this->AutoAdjustCameraClippingRange)
1302 this->CurrentRenderer->ResetCameraClippingRange();
1305 if (rwi->GetLightFollowCamera())
1307 this->CurrentRenderer->UpdateLightsGeometryToFollowCamera();
1315 vtkRenderWindowInteractor *rwi = this->Interactor;
1317 m_textActor->SetInput(
"Pick first correspondence point...");
1325 vtkRenderWindowInteractor *rwi = this->Interactor;
1334 vtkRenderWindowInteractor *rwi = this->Interactor;
1335 m_textActor->SetInput(
"Press \"l\" to select Points");
1346 vtkRenderWindowInteractor *rwi = this->Interactor;
1354 vtkPointPicker* picker = (vtkPointPicker*)this->Interactor->GetPicker();
1360 int pickPosition[2];
1361 this->GetInteractor()->GetEventPosition(pickPosition);
1364 int ydist = pickPosition[1] - this->m_previousPosition[1];
1366 this->m_previousPosition[0] = pickPosition[0];
1367 this->m_previousPosition[1] = pickPosition[1];
1369 int moveDistance = (int)sqrt((
double)(xdist*xdist + ydist*ydist));
1372 if(moveDistance > 5)
1380 double* picked =
new double[3];
1381 picker->Pick(pickPosition[0],
1384 this->Interactor->GetRenderWindow()->GetRenderers()->GetFirstRenderer());
1385 vtkActor* actor = picker->GetActor();
1386 int point = picker->GetPointId();
1392 int* pickPos = this->Interactor->GetEventPosition();
1393 double* picked =
new double[3];
1394 int res = picker->Pick(this->Interactor->GetEventPosition()[0],
1395 this->Interactor->GetEventPosition()[1],
1397 this->Interactor->GetRenderWindow()->GetRenderers()->GetFirstRenderer());
1401 picker->GetPickPosition(picked);
1403 vtkCamera* cam =
m_renderer->GetActiveCamera();
1404 cam->SetFocalPoint(picked[0], picked[1], picked[2]);
1418 int* pickPos = this->Interactor->GetEventPosition();
1419 double* picked =
new double[3];
1420 picker->Pick(this->Interactor->GetEventPosition()[0],
1421 this->Interactor->GetEventPosition()[1],
1423 this->Interactor->GetRenderWindow()->GetRenderers()->GetFirstRenderer());
1424 picker->GetPickPosition(picked);
1439 this->FindPokedRenderer(this->Interactor->GetEventPosition()[0],
1440 this->Interactor->GetEventPosition()[1]);
1441 if (this->CurrentRenderer ==
nullptr)
1451 GrabFocus(this->EventCallbackCommand,
nullptr);
1452 if (this->Interactor->GetShiftKey())
1454 if (this->Interactor->GetControlKey())
1465 if (this->Interactor->GetControlKey())
1471 this->StartRotate();
1478 switch (this->State)
1497 if ( this->Interactor )
1499 this->ReleaseFocus();
1505 int x = this->Interactor->GetEventPosition()[0];
1506 int y = this->Interactor->GetEventPosition()[1];
1508 switch (this->State)
1511 this->FindPokedRenderer(x, y);
1513 this->InvokeEvent(vtkCommand::InteractionEvent,
nullptr);
1517 this->FindPokedRenderer(x, y);
1519 this->InvokeEvent(vtkCommand::InteractionEvent,
nullptr);
1523 this->FindPokedRenderer(x, y);
1525 this->InvokeEvent(vtkCommand::InteractionEvent,
nullptr);
1529 this->FindPokedRenderer(x, y);
1531 this->InvokeEvent(vtkCommand::InteractionEvent,
nullptr);
1538 switch (this->State)
1542 if ( this->Interactor )
1544 this->ReleaseFocus();
1552 this->FindPokedRenderer(this->Interactor->GetEventPosition()[0],
1553 this->Interactor->GetEventPosition()[1]);
1554 if (this->CurrentRenderer ==
nullptr)
1559 this->GrabFocus(this->EventCallbackCommand);
1562 this->
Dolly(-pow(1.1, factor));
1564 this->ReleaseFocus();
1569 this->FindPokedRenderer(this->Interactor->GetEventPosition()[0],
1570 this->Interactor->GetEventPosition()[1]);
1571 if (this->CurrentRenderer ==
nullptr)
1576 this->GrabFocus(this->EventCallbackCommand);
1579 this->
Dolly(pow(1.1, factor));
1581 this->ReleaseFocus();
1586 this->FindPokedRenderer(this->Interactor->GetEventPosition()[0],
1587 this->Interactor->GetEventPosition()[1]);
1588 if (this->CurrentRenderer ==
nullptr)
1593 this->GrabFocus(this->EventCallbackCommand);
1599 switch (this->State)
1604 if ( this->Interactor )
1606 this->ReleaseFocus();
1614 this->FindPokedRenderer(this->Interactor->GetEventPosition()[0],
1615 this->Interactor->GetEventPosition()[1]);
1616 if (this->CurrentRenderer ==
nullptr)
1621 this->GrabFocus(this->EventCallbackCommand);
1633 vtkRenderWindowInteractor *rwi = this->Interactor;
1634 std::string key = rwi->GetKeySym();
1651 m_textActor->SetInput(
"Pick first correspondence point...");
1659 m_textActor->SetInput(
"Pick second correspondence point...");
1694 vtkRenderWindowInteractor *rwi = this->Interactor;
1695 vtkCamera* cam = this->CurrentRenderer->GetActiveCamera();
1696 switch (rwi->GetKeyCode())
1713 cout <<
"D" << endl;
1746 vtkInteractorStyle::OnChar();
1752 vtkRenderWindowInteractor *rwi = this->Interactor;
1753 m_textActor->SetInput(
"Pick new camera focal point...");
1766 int n = polygon->size();
1767 if (n < 3)
return false;
1770 for(i = 0, j = n -1; i < n ; j = i++)
1772 auto& vert = polygon->at(j);
1773 auto& vert_next = polygon->at(i);
1775 if (((vert_next.GetY() > pY) != (vert.GetY() > pY)) &&
1776 (pX < (vert.GetX() - vert_next.GetX()) * (pY - vert_next.GetY()) / (vert.GetY() - vert_next.GetY()) + vert_next.GetX()))
1806 vtkPlanes* frustum =
static_cast<vtkAreaPicker*
>(this->GetInteractor()->GetPicker())->GetFrustum();
1808 vtkSmartPointer<vtkExtractGeometry> extractGeometry =
1809 vtkSmartPointer<vtkExtractGeometry>::New();
1810 extractGeometry->SetImplicitFunction(frustum);
1811 #if VTK_MAJOR_VERSION <= 5 1812 extractGeometry->SetInput(
m_points);
1814 extractGeometry->SetInputData(
m_points);
1816 extractGeometry->Update();
1818 vtkSmartPointer<vtkVertexGlyphFilter> glyphFilter =
1819 vtkSmartPointer<vtkVertexGlyphFilter>::New();
1820 glyphFilter->SetInputConnection(extractGeometry->GetOutputPort());
1821 glyphFilter->Update();
1823 vtkPolyData* selected = glyphFilter->GetOutput();
1825 vtkIdTypeArray* ids = vtkIdTypeArray::SafeDownCast(selected->GetPointData()->GetArray(
"OriginalIds"));
1826 m_selectedIds = vtkIdTypeArray::SafeDownCast(selected->GetPointData()->GetArray(
"OriginalIds"));
1829 vtkSmartPointer<vtkCoordinate> coordinate = vtkSmartPointer<vtkCoordinate>::New();
1830 coordinate->SetCoordinateSystemToWorld();
1833 std::vector<int> selectedPolyPoints;
1834 selectedPolyPoints.resize(ids->GetNumberOfTuples());
1836 for (vtkIdType i = 0; i < ids->GetNumberOfTuples(); i++)
1838 auto selectedPoint =
m_points->GetPoint(ids->GetValue(i));
1839 coordinate->SetValue(selectedPoint[0], selectedPoint[1], selectedPoint[2]);
1841 displayCoord = coordinate->GetComputedViewportValue(this->CurrentRenderer);
1842 if (
isInside(&polygonPoints, displayCoord[0], displayCoord[1]))
1844 selectedPolyPoints.push_back(ids->GetValue(i));
1848 #if VTK_MAJOR_VERSION <= 5 1855 for(
auto selectedPolyPoint : selectedPolyPoints)
1860 auto vertexFilter = vtkSmartPointer<vtkVertexGlyphFilter>::New();
1861 auto selectedVtkPoints = vtkSmartPointer<vtkPoints>::New();
1868 m_points->vtkDataSet::GetPoint(i, point);
1869 selectedVtkPoints->InsertNextPoint(point);
1872 if (selectedPolyPoints.size() > 0)
1877 auto selectedVtkPoly = vtkSmartPointer<vtkPolyData>::New();
1878 selectedVtkPoly->SetPoints(selectedVtkPoints);
1881 vertexFilter->SetInputData(selectedVtkPoly);
1882 vertexFilter->Update();
1884 auto polyData = vtkSmartPointer<vtkPolyData>::New();
1885 polyData->ShallowCopy(vertexFilter->GetOutput());
1887 #if VTK_MAJOR_VERSION <= 5 1904 this->GetInteractor()->GetRenderWindow()->Render();
1905 this->HighlightProp(
NULL);
1911 m_labelColors[item->data(3,0).toInt()] = item->data(3,1).value<QColor>();
1922 m_labelActors[item->data(3,0).toInt()]->GetProperty()->SetColor(r/255.0, g/255.0, b/255.0);
1923 this->GetInteractor()->GetRenderWindow()->Render();
1924 this->HighlightProp(
NULL);
1976 std::set<uint16_t> modifiedActors;
1997 modifiedActors.insert(0);
2006 if (modifiedActors.size() > 0)
2012 for (
auto modifiedActorLabel : modifiedActors)
2037 this->GetInteractor()->GetRenderWindow()->Render();
2038 this->HighlightProp(
NULL);
2056 QMessageBox acceptDialog;
2057 acceptDialog.setText(
"The Label has been modified. Do you want to save your changes?");
2058 acceptDialog.setStandardButtons(QMessageBox::Save | QMessageBox::Discard);
2059 acceptDialog.setDefaultButton(QMessageBox::Save);
2060 int returnValue = acceptDialog.exec();
2063 case QMessageBox::Save:
2066 case QMessageBox::Discard:
2097 vtkRenderWindowInteractor *rwi = this->Interactor;
2103 if (lassoToolSelected)
2115 for (
int pointId : pointIds)
2126 auto updateMapper = vtkSmartPointer<vtkDataSetMapper>::New();
2127 auto updatedActor = vtkSmartPointer<vtkActor>::New();
2128 updatedActor->SetMapper(updateMapper);
2132 auto selectedVtkPoints = vtkSmartPointer<vtkPoints>::New();
2139 m_points->vtkDataSet::GetPoint(i, point);
2140 selectedVtkPoints->InsertNextPoint(point);
2145 auto updatedVtkPoly = vtkSmartPointer<vtkPolyData>::New();
2146 updatedVtkPoly->SetPoints(selectedVtkPoints);
2147 auto vertexFilter = vtkSmartPointer<vtkVertexGlyphFilter>::New();
2148 vertexFilter->SetInputData(updatedVtkPoly);
2149 vertexFilter->Update();
2151 auto polyData = vtkSmartPointer<vtkPolyData>::New();
2152 polyData->ShallowCopy(vertexFilter->GetOutput());
2155 #if VTK_MAJOR_VERSION <= 5 2156 updatedMapper->SetInput(polyData);
2158 updateMapper->SetInputData(polyData);
2160 updateMapper->ScalarVisibilityOff();
2164 updatedActor->GetProperty()->SetColor(r/255.0, g/255.0, b/255.0);
2167 bool visibility =
true;
2173 updatedActor->SetVisibility(visibility);
2177 this->GetInteractor()->GetRenderWindow()->Render();
2178 this->HighlightProp(
NULL);
2187 QMessageBox noLabelDialog;
2188 noLabelDialog.setText(
"No Label Instance was created! Create an instance beofre labeling Points.");
2189 noLabelDialog.setStandardButtons(QMessageBox::Ok);
2190 noLabelDialog.setIcon(QMessageBox::Warning);
2191 int returnValue = noLabelDialog.exec();
2223 if (pointlabel ==
id)
void onRightButtonUpTerrain()
void onMouseWheelBackwardShooter()
void pointSelected(vtkActor *, int)
void labelingStarted(bool)
void onMouseWheelForwardTrackball()
void onLeftButtonUpTrackball()
vtkSmartPointer< vtkActor > m_selectedActor
void onRightButtonUpTrackball()
void onMiddleButtonUpShooter()
void saveCurrentLabelSelection()
void labelSelected(uint16_t)
void onLeftButtonDownShooter()
bool isInside(std::vector< vtkVector2i > *polygon, int &pX, int &pY)
void onMouseMoveTrackball()
void onMiddleButtonDownShooter()
ShooterMode m_shooterMode
void onRightButtonUpShooter()
std::vector< uint16_t > & getLabeles()
vtkSmartPointer< vtkDataSetMapper > m_selectedMapper
virtual void OnMouseWheelBackward()
bool m_correspondenceMode
virtual ~LVRPickingInteractor()
void onMouseMoveTerrain()
void onRightButtonDownTerrain()
virtual void OnLeftButtonUp()
void setPoints(vtkSmartPointer< vtkPolyData > points)
virtual void OnMouseWheelForward()
void responseLabels(std::vector< uint16_t >)
vtkSmartPointer< vtkActor > m_sphereActor
void correspondenceSearchOff()
void OnLeftButtonUp() override
void onLeftButtonDownTrackball()
void secondPointPicked(double *)
vtkSmartPointer< vtkRenderer > m_renderer
std::map< uint16_t, vtkSmartPointer< vtkActor > > m_labelActors
void removeLabel(const int &)
virtual void OnMiddleButtonUp()
vtkSmartPointer< vtkIdTypeArray > m_selectedIds
void onMiddleButtonDownTrackball()
unsigned int m_numberOfClicks
void OnMouseMove() override
void onMiddleButtonUpTrackball()
void setFocalPointRendering(int state)
std::vector< bool > m_selectedPoints
void onLeftButtonUpShooter()
virtual void OnRightButtonUp()
void onLeftButtonUpTerrain()
void setLabel(int, std::vector< int >)
void onMouseWheelForwardShooter()
void pointsLabeled(uint16_t, int)
virtual void OnRightButtonDown()
void onRightButtonDownShooter()
virtual void OnMiddleButtonDown()
void newLabel(QTreeWidgetItem *)
virtual void OnMouseMove()
void setMotionFactor(double factor)
void setRenderer(vtkSmartPointer< vtkRenderer > renderer)
std::vector< uint16_t > m_pointLabels
vtkSmartPointer< vtkTextActor > m_textActor
Text actor to display info if in picking mode.
void calculateSelection(bool select)
PickMode m_pickMode
Indicates picking mode.
void onMouseWheelForwardTerrain()
int m_startCameraMovePosition[2]
void OnLeftButtonDown() override
void firstPointPicked(double *)
void onLeftButtonDownTerrain()
std::map< uint16_t, QColor > m_labelColors
virtual void OnLeftButtonDown()
Overloaded mouse event handling.
virtual void OnKeyPress()
Overloaded keyboard press event handling.
vtkSmartPointer< vtkPolyData > m_points
vtkStandardNewMacro(LVRPickingInteractor)
void setStereoMode(int state)
int m_previousPosition[2]
void onMouseWheelBackwardTrackball()
void correspondenceSearchOn()
void resetViewUpShooter()
InteractorMode m_interactorMode
void onMiddleButtonDownTerrain()
vtkSmartPointer< vtkPolyData > getPoints()
virtual void OnKeyRelease()
Overloaded keyboard release event handling.
void onMouseWheelBackwardTerrain()
void onMiddleButtonUpTerrain()
void labelModeChanged(bool)
void setLabeledPointVisibility(int, bool)
void onRightButtonDownTrackball()
void setRotationFactor(double factor)
__kf_hdevice__ float3 cross(const float3 &v1, const float3 &v2)
void onMouseMoveShooter()
std::vector< vtkVector2i > GetPolygonPoints()
void strafeShooter(double factor)
void OnKeyDown() override