#else
#endif
+#if __cplusplus > 199711L
+#include <chrono>
+#endif
+
// Define interaction style
class MouseInteractorStyleDoubleClick : public vtkInteractorStyleTrackballCamera
{
if (this->NumberOfClicks > 1)
{
this->LastClickTime = this->CurrentClickTime;
- this->CurrentClickTime = time(0);
- } else
+#if __cplusplus <= 199711L
+ this->CurrentClickTime = time(0) * 1000;
+#else
+ this->CurrentClickTime = std::chrono::duration_cast<std::chrono::milliseconds>(
+ std::chrono::system_clock::now().time_since_epoch()
+ );
+#endif
+
+ }
+ else
{
- this->CurrentClickTime = time(0);
+#if __cplusplus <= 199711L
+ this->CurrentClickTime = time(0) * 1000;
+#else
+ this->CurrentClickTime = std::chrono::duration_cast<std::chrono::milliseconds>(
+ std::chrono::system_clock::now().time_since_epoch()
+ );
+
+#endif
}
//std::cout << "NumberOfClicks = " << this->NumberOfClicks << std::endl;
if (this->NumberOfClicks == 2)
{
- double seconds = difftime(this->CurrentClickTime, this->LastClickTime);
- if (seconds * 1000 <= this->DoubleClickTolerance)
+ double seconds;
+#if __cplusplus <= 199711L
+ seconds = difftime(this->CurrentClickTime, this->LastClickTime);
+#else
+ seconds = this->CurrentClickTime - this->LastClickTime;
+#endif
+
+ if (seconds <= this->DoubleClickTolerance)
{
std::cout << "Double clicked. with " << seconds << " of diference" << std::endl;
this->NumberOfClicks = 0;
- } else
+ }
+ else
{
std::cout << "Too slow to be considered as a double click" << std::endl;
this->NumberOfClicks = 1;
- }
-
+ }
}
// forward events
vtkInteractorStyleTrackballCamera::OnLeftButtonDown();
}
+
+
private:
unsigned int NumberOfClicks;
int PreviousPosition[2];
int ResetPixelDistance;
double DoubleClickTolerance; // time in miliseconds
+
+#if __cplusplus <= 199711L
time_t LastClickTime;
time_t CurrentClickTime;
+#else
+ std::chrono::milliseconds LastClickTime;
+ std::chrono::milliseconds CurrentClickTime;
+#endif
};
vtkStandardNewMacro(MouseInteractorStyleDoubleClick);