本文整理汇总了C++中InteractionPositionEvent::GetPointerPositionOnScreen方法的典型用法代码示例。如果您正苦于以下问题:C++ InteractionPositionEvent::GetPointerPositionOnScreen方法的具体用法?C++ InteractionPositionEvent::GetPointerPositionOnScreen怎么用?C++ InteractionPositionEvent::GetPointerPositionOnScreen使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类InteractionPositionEvent
的用法示例。
在下文中一共展示了InteractionPositionEvent::GetPointerPositionOnScreen方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1:
bool mitk::DisplayInteractor::Move(StateMachineAction*, InteractionEvent* interactionEvent)
{
BaseRenderer* sender = interactionEvent->GetSender();
InteractionPositionEvent* positionEvent = static_cast<InteractionPositionEvent*>(interactionEvent);
float invertModifier = -1.0;
if ( m_InvertMoveDirection )
{
invertModifier = 1.0;
}
// perform translation
sender->GetDisplayGeometry()->MoveBy( (positionEvent->GetPointerPositionOnScreen() - m_LastDisplayCoordinate) * invertModifier );
sender->GetRenderingManager()->RequestUpdate(sender->GetRenderWindow());
m_LastDisplayCoordinate = positionEvent->GetPointerPositionOnScreen();
return true;
}
示例2:
bool mitk::DisplayInteractor::Init(StateMachineAction*, InteractionEvent* interactionEvent)
{
BaseRenderer* sender = interactionEvent->GetSender();
InteractionPositionEvent* positionEvent = dynamic_cast<InteractionPositionEvent*>(interactionEvent);
if (positionEvent == NULL)
{
MITK_WARN<< "DisplayVectorInteractor cannot process the event: " << interactionEvent->GetNameOfClass();
return false;
}
Vector2D origin = sender->GetDisplayGeometry()->GetOriginInMM();
double scaleFactorMMPerDisplayUnit = sender->GetDisplayGeometry()->GetScaleFactorMMPerDisplayUnit();
m_StartDisplayCoordinate = positionEvent->GetPointerPositionOnScreen();
m_LastDisplayCoordinate = positionEvent->GetPointerPositionOnScreen();
m_CurrentDisplayCoordinate = positionEvent->GetPointerPositionOnScreen();
m_StartCoordinateInMM = mitk::Point2D(
(origin + m_StartDisplayCoordinate.GetVectorFromOrigin() * scaleFactorMMPerDisplayUnit).GetDataPointer());
return true;
}
示例3:
void mitk::ClippingPlaneInteractor3D::TranslateObject (StateMachineAction*, InteractionEvent* interactionEvent)
{
InteractionPositionEvent* positionEvent = dynamic_cast<InteractionPositionEvent*>(interactionEvent);
if(positionEvent == NULL)
return;
double currentWorldPoint[4];
mitk::Point2D currentDisplayPoint = positionEvent->GetPointerPositionOnScreen();
vtkInteractorObserver::ComputeDisplayToWorld(
interactionEvent->GetSender()->GetVtkRenderer(),
currentDisplayPoint[0],
currentDisplayPoint[1],
0.0, //m_InitialInteractionPickedPoint[2],
currentWorldPoint);
Vector3D interactionMove;
interactionMove[0] = currentWorldPoint[0] - m_InitialPickedWorldPoint[0];
interactionMove[1] = currentWorldPoint[1] - m_InitialPickedWorldPoint[1];
interactionMove[2] = currentWorldPoint[2] - m_InitialPickedWorldPoint[2];
Point3D origin = m_OriginalGeometry->GetOrigin();
// Get the timestep to also support 3D+t
int timeStep = interactionEvent->GetSender()->GetTimeStep(this->GetDataNode()->GetData());
// If data is an mitk::Surface, extract it
Surface::Pointer surface = dynamic_cast< Surface* >(this->GetDataNode()->GetData());
vtkPolyData* polyData = NULL;
if (surface.IsNotNull())
{
polyData = surface->GetVtkPolyData( timeStep );
// Extract surface normal from surface (if existent, otherwise use default)
vtkPointData* pointData = polyData->GetPointData();
if (pointData != NULL)
{
vtkDataArray* normal = polyData->GetPointData()->GetVectors("planeNormal");
if (normal != NULL)
{
m_ObjectNormal[0] = normal->GetComponent( 0, 0 );
m_ObjectNormal[1] = normal->GetComponent( 0, 1 );
m_ObjectNormal[2] = normal->GetComponent( 0, 2 );
}
}
}
Vector3D transformedObjectNormal;
this->GetDataNode()->GetData()->GetGeometry( timeStep )->IndexToWorld(m_ObjectNormal, transformedObjectNormal);
this->GetDataNode()->GetData()->GetGeometry( timeStep )->SetOrigin(origin + transformedObjectNormal * (interactionMove * transformedObjectNormal));
interactionEvent->GetSender()->GetRenderingManager()->RequestUpdateAll();
}
示例4:
void mitk::AffineImageCropperInteractor::InitDeformation(StateMachineAction*, InteractionEvent* interactionEvent)
{
InteractionPositionEvent* positionEvent = dynamic_cast<InteractionPositionEvent*>(interactionEvent);
if(positionEvent == NULL)
return;
m_InitialPickedPoint = positionEvent->GetPositionInWorld();
m_InitialPickedDisplayPoint = positionEvent->GetPointerPositionOnScreen();
mitk::Surface::Pointer surface = dynamic_cast<mitk::Surface*> (m_SelectedNode->GetData());
mitk::BaseGeometry::Pointer surGeo = surface->GetGeometry();
m_OriginalGeometry = dynamic_cast<mitk::Geometry3D*> (surGeo.GetPointer());
}
示例5:
bool mitk::AffineDataInteractor3D::InitRotate(StateMachineAction*, InteractionEvent* interactionEvent)
{
InteractionPositionEvent* positionEvent = dynamic_cast<InteractionPositionEvent*>(interactionEvent);
if(positionEvent == NULL)
return false;
m_InitialPickedPoint = positionEvent->GetPositionInWorld();
m_InitialPickedDisplayPoint = positionEvent->GetPointerPositionOnScreen();
// Get the timestep to also support 3D+t
int timeStep = interactionEvent->GetSender()->GetTimeStep(this->GetDataNode()->GetData());
// Make deep copy of current Geometry3D of the plane
this->GetDataNode()->GetData()->UpdateOutputInformation(); // make sure that the Geometry is up-to-date
m_OriginalGeometry = static_cast<Geometry3D*>(this->GetDataNode()->GetData()->GetGeometry(timeStep)->Clone().GetPointer());
return true;
}
示例6: op
void mitk::AffineImageCropperInteractor::RotateObject (StateMachineAction*, InteractionEvent* interactionEvent)
{
InteractionPositionEvent* positionEvent = dynamic_cast<InteractionPositionEvent*>(interactionEvent);
if(positionEvent == NULL)
return;
Point2D currentPickedDisplayPoint = positionEvent->GetPointerPositionOnScreen();
if(currentPickedDisplayPoint.EuclideanDistanceTo(m_InitialPickedDisplayPoint) < 1)
return;
vtkRenderer* currentVtkRenderer = interactionEvent->GetSender()->GetVtkRenderer();
if ( currentVtkRenderer && currentVtkRenderer->GetActiveCamera())
{
double vpn[3];
currentVtkRenderer->GetActiveCamera()->GetViewPlaneNormal( vpn );
Vector3D rotationAxis;
rotationAxis[0] = vpn[0];
rotationAxis[1] = vpn[1];
rotationAxis[2] = vpn[2];
rotationAxis.Normalize();
Vector2D move = currentPickedDisplayPoint - m_InitialPickedDisplayPoint;
double rotationAngle = -57.3 * atan(move[0]/move[1]);
if(move[1]<0) rotationAngle +=180;
// Use center of data bounding box as center of rotation
Point3D rotationCenter = m_OriginalGeometry->GetCenter();
if(positionEvent->GetSender()->GetMapperID() == BaseRenderer::Standard2D)
rotationCenter = m_InitialPickedPoint;
// Reset current Geometry3D to original state (pre-interaction) and
// apply rotation
RotationOperation op( OpROTATE, rotationCenter, rotationAxis, rotationAngle );
Geometry3D::Pointer newGeometry = static_cast<Geometry3D*>(m_OriginalGeometry->Clone().GetPointer());
newGeometry->ExecuteOperation( &op );
m_SelectedNode->GetData()->SetGeometry(newGeometry);
interactionEvent->GetSender()->GetRenderingManager()->RequestUpdateAll();
}
}
示例7: if
bool mitk::DisplayInteractor::Zoom(StateMachineAction*, InteractionEvent* interactionEvent)
{
const BaseRenderer::Pointer sender = interactionEvent->GetSender();
InteractionPositionEvent* positionEvent = static_cast<InteractionPositionEvent*>(interactionEvent);
float factor = 1.0;
float distance = 0;
if (m_ZoomDirection == "updown")
{
distance = m_CurrentDisplayCoordinate[1] - m_LastDisplayCoordinate[1];
}
else
{
distance = m_CurrentDisplayCoordinate[0] - m_LastDisplayCoordinate[0];
}
if ( m_InvertZoomDirection )
{
distance *= -1.0;
}
// set zooming speed
if (distance < 0.0)
{
factor = 1.0 / m_ZoomFactor;
}
else if (distance > 0.0)
{
factor = 1.0 * m_ZoomFactor;
}
if (factor != 1.0)
{
sender->GetDisplayGeometry()->ZoomWithFixedWorldCoordinates(factor, m_StartDisplayCoordinate, m_StartCoordinateInMM);
sender->GetRenderingManager()->RequestUpdate(sender->GetRenderWindow());
}
m_LastDisplayCoordinate = m_CurrentDisplayCoordinate;
m_CurrentDisplayCoordinate = positionEvent->GetPointerPositionOnScreen();
return true;
}
示例8:
bool mitk::DisplayInteractor::AdjustLevelWindow(StateMachineAction*, InteractionEvent* interactionEvent)
{
BaseRenderer::Pointer sender = interactionEvent->GetSender();
InteractionPositionEvent* positionEvent = static_cast<InteractionPositionEvent*>(interactionEvent);
m_LastDisplayCoordinate = m_CurrentDisplayCoordinate;
m_CurrentDisplayCoordinate = positionEvent->GetPointerPositionOnScreen();
// search for active image
mitk::DataStorage::Pointer storage = sender->GetDataStorage();
mitk::DataNode::Pointer node = NULL;
mitk::DataStorage::SetOfObjects::ConstPointer allImageNodes = storage->GetSubset(mitk::NodePredicateDataType::New("Image"));
for (unsigned int i = 0; i < allImageNodes->size(); i++)
{
bool isActiveImage = false;
bool propFound = allImageNodes->at(i)->GetBoolProperty("imageForLevelWindow", isActiveImage);
if (propFound && isActiveImage)
{
node = allImageNodes->at(i);
continue;
}
}
if (node.IsNull())
{
node = storage->GetNode(mitk::NodePredicateDataType::New("Image"));
}
if (node.IsNull())
{
return false;
}
mitk::LevelWindow lv = mitk::LevelWindow();
node->GetLevelWindow(lv);
ScalarType level = lv.GetLevel();
ScalarType window = lv.GetWindow();
int levelIndex = 0;
int windowIndex = 1;
if ( m_LevelDirection != "leftright" )
{
levelIndex = 1;
windowIndex = 0;
}
int directionModifier = 1;
if ( m_InvertLevelWindowDirection )
{
directionModifier = -1;
}
// calculate adjustments from mouse movements
level += (m_CurrentDisplayCoordinate[levelIndex] - m_LastDisplayCoordinate[levelIndex]) * static_cast<ScalarType>(2) * directionModifier;
window += (m_CurrentDisplayCoordinate[windowIndex] - m_LastDisplayCoordinate[windowIndex]) * static_cast<ScalarType>(2) * directionModifier;
lv.SetLevelWindow(level, window);
dynamic_cast<mitk::LevelWindowProperty*>(node->GetProperty("levelwindow"))->SetLevelWindow(lv);
sender->GetRenderingManager()->RequestUpdateAll();
return true;
}
示例9: op
void mitk::AffineBaseDataInteractor3D::RotateObject (StateMachineAction*, InteractionEvent* interactionEvent)
{
InteractionPositionEvent* positionEvent = dynamic_cast<InteractionPositionEvent*>(interactionEvent);
if(positionEvent == NULL)
return;
Point2D currentPickedDisplayPoint = positionEvent->GetPointerPositionOnScreen();
Point3D currentWorldPoint = positionEvent->GetPositionInWorld();
vtkCamera* camera = NULL;
vtkRenderer* currentVtkRenderer = NULL;
if ((interactionEvent->GetSender()) != NULL)
{
camera = interactionEvent->GetSender()->GetVtkRenderer()->GetActiveCamera();
currentVtkRenderer = interactionEvent->GetSender()->GetVtkRenderer();
}
if ( camera && currentVtkRenderer)
{
double vpn[3];
camera->GetViewPlaneNormal( vpn );
Vector3D viewPlaneNormal;
viewPlaneNormal[0] = vpn[0];
viewPlaneNormal[1] = vpn[1];
viewPlaneNormal[2] = vpn[2];
Vector3D interactionMove;
interactionMove[0] = currentWorldPoint[0] - m_InitialPickedWorldPoint[0];
interactionMove[1] = currentWorldPoint[1] - m_InitialPickedWorldPoint[1];
interactionMove[2] = currentWorldPoint[2] - m_InitialPickedWorldPoint[2];
if (interactionMove[0] == 0 && interactionMove[1] == 0 && interactionMove[2] == 0)
return;
Vector3D rotationAxis = itk::CrossProduct(viewPlaneNormal, interactionMove);
rotationAxis.Normalize();
int* size = currentVtkRenderer->GetSize();
double l2 =
(currentPickedDisplayPoint[0] - m_InitialPickedDisplayPoint[0]) *
(currentPickedDisplayPoint[0] - m_InitialPickedDisplayPoint[0]) +
(currentPickedDisplayPoint[1] - m_InitialPickedDisplayPoint[1]) *
(currentPickedDisplayPoint[1] - m_InitialPickedDisplayPoint[1]);
double rotationAngle = 360.0 * sqrt(l2 / (size[0] * size[0] + size[1] * size[1]));
// Use center of data bounding box as center of rotation
Point3D rotationCenter = m_OriginalGeometry->GetCenter();
int timeStep = 0;
if ((interactionEvent->GetSender()) != NULL)
timeStep = interactionEvent->GetSender()->GetTimeStep(this->GetDataNode()->GetData());
// Reset current Geometry3D to original state (pre-interaction) and
// apply rotation
RotationOperation op( OpROTATE, rotationCenter, rotationAxis, rotationAngle );
Geometry3D::Pointer newGeometry = static_cast<Geometry3D*>(m_OriginalGeometry->Clone().GetPointer());
newGeometry->ExecuteOperation( &op );
mitk::TimeGeometry::Pointer timeGeometry = this->GetDataNode()->GetData()->GetTimeGeometry();
if (timeGeometry.IsNotNull())
timeGeometry->SetTimeStepGeometry(newGeometry, timeStep);
interactionEvent->GetSender()->GetRenderingManager()->RequestUpdateAll();
}
}