#include <cpExtensions/Visualization/BaseInteractorStyle.h>
-/*
- Compile ITK and VTK with: cmake -DCMAKE_CXX_FLAGS="-std=c++11" /dir/to/source
+/* =========================================================================
+ * Double click algorithm taken from:
+ * http://www.autohotkey.com/board/topic/56493-easiest-way-to-detect-double-clicks/
+ * =========================================================================
*/
+
/*
- typedef std::chrono::time_point< std::chrono::system_clock > TTime;
- typedef std::chrono::duration< long, std::ratio< 1, 1000 > > TTimeDiff;
+ Compile ITK and VTK with: cmake -DCMAKE_CXX_FLAGS="-std=c++11" /dir/to/source
*/
#include <chrono>
-
#include <vtkCallbackCommand.h>
// -------------------------------------------------------------------------
-/*
- const cpExtensions::Visualization::BaseInteractorStyle::TTime
- cpExtensions::Visualization::BaseInteractorStyle::MinTime =
- cpExtensions::Visualization::BaseInteractorStyle::TTime::min( );
-*/
+const long cpExtensions::Visualization::BaseInteractorStyle::
+MAX_DOUBLE_CLICK = 200;
// -------------------------------------------------------------------------
cpExtensions::Visualization::BaseInteractorStyle::
break;
case vtkCommand::LeftButtonPressEvent:
{
- /*
- if( s->LastButton != Self::ButtonID_Left )
+ long tick_count =
+ std::chrono::duration_cast< std::chrono::milliseconds >(
+ std::chrono::system_clock::now( ).time_since_epoch( )
+ ).count( );
+ if(
+ s->LastButtonHeld < Self::MAX_DOUBLE_CLICK &&
+ ( tick_count - s->LastButtonUp ) < Self::MAX_DOUBLE_CLICK
+ )
+ {
+ std::cout << "double!!!" << std::endl;
+ }
+ else
{
+ std::cout << "single!!!" << std::endl;
+
+ } // fi
+ if( s->LastButtonDown < 0 )
+ s->LastButtonDown = tick_count;
+
+ /*
+ if( s->LastButton != Self::ButtonID_Left )
+ {
s->LastButton = Self::ButtonID_Left;
s->LastButtonClicks = 1;
s->LastButtonTime = std::chrono::system_clock::now( );
- }
- else if( s->LastButton == Self::ButtonID_Left )
+ }
+ else if( s->LastButton == Self::ButtonID_Left )
s->LastButtonClicks++;
*/
}
break;
case vtkCommand::LeftButtonReleaseEvent:
{
- long count =
+ long tick_count =
std::chrono::duration_cast< std::chrono::milliseconds >(
- std::chrono::system_clock::now( )
+ std::chrono::system_clock::now( ).time_since_epoch( )
).count( );
- s->LastButtonUp = count;
- s->LastButtonHeld = count - s->LastButtonDown;
+ s->LastButtonUp = tick_count;
+ s->LastButtonHeld = tick_count - s->LastButtonDown;
s->LastButtonDown = -1;
/*
- if( s->LastButton == Self::ButtonID_Left )
- {
+ if( s->LastButton == Self::ButtonID_Left )
+ {
long d = std::chrono::duration_cast< std::chrono::milliseconds >(
- std::chrono::system_clock::now( ) - s->LastButtonTime
- ).count( );
+ std::chrono::system_clock::now( ) - s->LastButtonTime
+ ).count( );
if( d < 500 )
{
} // fi
- } // fi
+ } // fi
*/
}
break;