本文整理汇总了C++中InteractionPositionEvent类的典型用法代码示例。如果您正苦于以下问题:C++ InteractionPositionEvent类的具体用法?C++ InteractionPositionEvent怎么用?C++ InteractionPositionEvent使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了InteractionPositionEvent类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: GetPointIndexByPosition
bool mitk::PointSetDataInteractor::UnSelectPoint(StateMachineAction*, InteractionEvent* interactionEvent)
{
InteractionPositionEvent* positionEvent = dynamic_cast<InteractionPositionEvent*>(interactionEvent);
if (positionEvent != NULL)
{
int timeStep = positionEvent->GetSender()->GetTimeStep();
Point3D point = positionEvent->GetPositionInWorld();
// iterate over point set and check if it contains a point close enough to the pointer to be selected
int index = GetPointIndexByPosition(point, timeStep);
// here it is ensured that we don't switch from one point being selected to another one being selected,
// without accepting the unselect of the current point
if (index == -1 || index != m_SelectedPointIndex)
{
m_SelectedPointIndex = -1;
GetDataNode()->SetProperty("contourcolor", ColorProperty::New(1.0, 0.0, 1.0));
mitk::RenderingManager::GetInstance()->RequestUpdateAll();
return true;
}
return false;
}
else
{
return false;
}
}
示例2: if
bool mitk::DisplayInteractor::Zoom(StateMachineAction*, InteractionEvent* interactionEvent)
{
const BaseRenderer::Pointer sender = interactionEvent->GetSender();
InteractionPositionEvent* positionEvent = dynamic_cast<InteractionPositionEvent*>(interactionEvent);
if (positionEvent == NULL)
{
MITK_WARN<< "DisplayVectorInteractor cannot process the event: " << interactionEvent->GetNameOfClass();
return false;
}
float factor = 1.0;
float distance = 0;
if (m_ZoomDirection == "leftright")
{
distance = m_CurrentDisplayCoordinate[1] - m_LastDisplayCoordinate[1];
}
else
{
distance = m_CurrentDisplayCoordinate[0] - m_LastDisplayCoordinate[0];
}
// set zooming speed
if (distance < 0.0)
{
factor = 1.0 / m_ZoomFactor;
}
else if (distance > 0.0)
{
factor = 1.0 * m_ZoomFactor;
}
sender->GetDisplayGeometry()->ZoomWithFixedWorldCoordinates(factor, m_StartDisplayCoordinate, m_StartCoordinateInMM);
sender->GetRenderingManager()->RequestUpdate(sender->GetRenderWindow());
m_LastDisplayCoordinate = m_CurrentDisplayCoordinate;
m_CurrentDisplayCoordinate = positionEvent->GetPointerPositionOnScreen();
return true;
}
示例3: GetDataNode
bool mitk::PointSetDataInteractor::MoveSet(StateMachineAction*, InteractionEvent* interactionEvent)
{
InteractionPositionEvent* positionEvent = dynamic_cast<InteractionPositionEvent*>(interactionEvent);
if (positionEvent != NULL)
{
int timeStep = positionEvent->GetSender()->GetTimeStep();
// Vector that represents movement relative to last position
Point3D movementVector;
movementVector[0] = positionEvent->GetPositionInWorld()[0] - m_PointSet->GetPoint(m_SelectedPointIndex, timeStep)[0];
movementVector[1] = positionEvent->GetPositionInWorld()[1] - m_PointSet->GetPoint(m_SelectedPointIndex, timeStep)[1];
movementVector[2] = positionEvent->GetPositionInWorld()[2] - m_PointSet->GetPoint(m_SelectedPointIndex, timeStep)[2];
PointSet* points = dynamic_cast<PointSet*>(GetDataNode()->GetData());
PointSet::PointsContainer* pointsContainer = points->GetPointSet(timeStep)->GetPoints();
// Iterate over point set and update each point
Point3D newPoint;
for (PointSet::PointsIterator it = pointsContainer->Begin(); it != pointsContainer->End(); it++)
{
newPoint[0] = m_PointSet->GetPoint(it->Index(), timeStep)[0] + movementVector[0];
newPoint[1] = m_PointSet->GetPoint(it->Index(), timeStep)[1] + movementVector[1];
newPoint[2] = m_PointSet->GetPoint(it->Index(), timeStep)[2] + movementVector[2];
m_PointSet->SetPoint(it->Index(), newPoint, timeStep);
}
GetDataNode()->SetData(m_PointSet);
GetDataNode()->Modified();
mitk::RenderingManager::GetInstance()->RequestUpdateAll();
return true;
}
else
{
return false;
}
}
示例4:
void mitk::AffineImageCropperInteractor::DeformObject (StateMachineAction*, InteractionEvent* interactionEvent)
{
InteractionPositionEvent* positionEvent = dynamic_cast<InteractionPositionEvent*>(interactionEvent);
if(positionEvent == NULL)
return;
Point3D currentPickedPoint = positionEvent->GetPositionInWorld();
Vector3D interactionMove = currentPickedPoint-m_InitialPickedPoint;
mitk::Surface::Pointer surface = dynamic_cast<mitk::Surface*> (m_SelectedNode->GetData());
surface->SetGeometry(m_OriginalGeometry);
mitk::BaseGeometry::Pointer surGeo = surface->GetGeometry();
surGeo->WorldToIndex(interactionMove,interactionMove);
Point3D scale;
for(int i = 0 ; i<3 ; ++i)
{
scale[i] = (interactionMove[i]*surGeo->GetMatrixColumn(i).magnitude())-1;
}
mitk::Point3D anchorPoint = surGeo->GetCenter();
ScaleOperation* doOp = new mitk::ScaleOperation(OpSCALE, scale, anchorPoint);
surGeo->ExecuteOperation(doOp);
mitk::RenderingManager::GetInstance()->RequestUpdateAll();
}
示例5: GetPointIndexByPosition
void mitk::PointSetDataInteractor::UnSelectPointAtPosition(StateMachineAction*, InteractionEvent* interactionEvent)
{
unsigned int timeStep = interactionEvent->GetSender()->GetTimeStep(GetDataNode()->GetData());
ScalarType timeInMs = interactionEvent->GetSender()->GetTime();
InteractionPositionEvent* positionEvent = dynamic_cast<InteractionPositionEvent*>(interactionEvent);
if (positionEvent != NULL)
{
Point3D point = positionEvent->GetPositionInWorld();
// iterate over point set and check if it contains a point close enough to the pointer to be selected
int index = GetPointIndexByPosition(point, timeStep);
// here it is ensured that we don't switch from one point being selected to another one being selected,
// without accepting the unselect of the current point
if (index != -1)
{
PointOperation* doOp = new mitk::PointOperation(OpDESELECTPOINT,timeInMs, point, index);
/*if (m_UndoEnabled)
{
PointOperation* undoOp = new mitk::PointOperation(OpSELECTPOINT,timeInMs, point, index);
OperationEvent *operationEvent = new OperationEvent(m_PointSet, doOp, undoOp, "Unselect Point");
OperationEvent::IncCurrObjectEventId();
m_UndoController->SetOperationEvent(operationEvent);
}*/
m_PointSet->ExecuteOperation(doOp);
if ( !m_UndoEnabled )
delete doOp;
}
}
}
示例6: sqrt
void mitk::PointSetDataInteractor::UnSelectAll(mitk::StateMachineAction *, mitk::InteractionEvent *interactionEvent)
{
unsigned int timeStep = interactionEvent->GetSender()->GetTimeStep(GetDataNode()->GetData());
ScalarType timeInMs = interactionEvent->GetSender()->GetTime();
InteractionPositionEvent* positionEvent = dynamic_cast<InteractionPositionEvent*>(interactionEvent);
if (positionEvent != NULL)
{
Point3D positioninWorld = positionEvent->GetPositionInWorld();
PointSet::PointsContainer::Iterator it, end;
PointSet::DataType *itkPointSet = m_PointSet->GetPointSet( timeStep );
end = itkPointSet->GetPoints()->End();
for (it = itkPointSet->GetPoints()->Begin(); it != end; it++)
{
int position = it->Index();
//then declare an operation which unselects this point;
//UndoOperation as well!
if ( m_PointSet->GetSelectInfo(position,timeStep) )
{
float distance = sqrt(positioninWorld.SquaredEuclideanDistanceTo(m_PointSet->GetPoint(position, timeStep)));
if (distance > m_SelectionAccuracy)
{
mitk::Point3D noPoint;
noPoint.Fill( 0 );
mitk::PointOperation* doOp = new mitk::PointOperation(OpDESELECTPOINT,timeInMs, noPoint, position);
/*if ( m_UndoEnabled )
{
mitk::PointOperation* undoOp = new mitk::PointOperation(OpSELECTPOINT, timeInMs, noPoint, position);
OperationEvent *operationEvent = new OperationEvent( m_PointSet, doOp, undoOp, "Unselect Point" );
OperationEvent::IncCurrObjectEventId();
m_UndoController->SetOperationEvent( operationEvent );
}*/
m_PointSet->ExecuteOperation( doOp );
if ( !m_UndoEnabled )
delete doOp;
}
}
}
}
else
{
this->UnselectAll(timeStep,timeInMs);
}
}
示例7:
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();
}
示例8: IsClosedContour
void mitk::PointSetDataInteractor::MovePoint(StateMachineAction* stateMachineAction, InteractionEvent* interactionEvent)
{
unsigned int timeStep = interactionEvent->GetSender()->GetTimeStep(GetDataNode()->GetData());
ScalarType timeInMs = interactionEvent->GetSender()->GetTime();
InteractionPositionEvent* positionEvent = dynamic_cast<InteractionPositionEvent*>(interactionEvent);
if (positionEvent != NULL)
{
IsClosedContour(stateMachineAction, interactionEvent);
mitk::Point3D newPoint, resultPoint;
newPoint = positionEvent->GetPositionInWorld();
// search the elements in the list that are selected then calculate the
// vector, because only with the vector we can move several elements in
// the same direction
// newPoint - lastPoint = vector
// then move all selected and set the lastPoint = newPoint.
// then add all vectors to a summeryVector (to be able to calculate the
// startpoint for undoOperation)
mitk::Vector3D dirVector = newPoint - m_LastPoint;
//sum up all Movement for Undo in FinishMovement
m_SumVec = m_SumVec + dirVector;
mitk::PointSet::PointsIterator it, end;
it = m_PointSet->Begin(timeStep);
end = m_PointSet->End(timeStep);
while( it != end )
{
int position = it->Index();
if ( m_PointSet->GetSelectInfo(position, timeStep) )//if selected
{
PointSet::PointType pt = m_PointSet->GetPoint(position, timeStep);
mitk::Point3D sumVec;
sumVec[0] = pt[0];
sumVec[1] = pt[1];
sumVec[2] = pt[2];
resultPoint = sumVec + dirVector;
PointOperation* doOp = new mitk::PointOperation(OpMOVE,timeInMs, resultPoint, position);
//execute the Operation
//here no undo is stored, because the movement-steps aren't interesting.
// only the start and the end is interisting to store for undo.
m_PointSet->ExecuteOperation(doOp);
delete doOp;
}
++it;
}
m_LastPoint = newPoint;//for calculation of the direction vector
// Update the display
interactionEvent->GetSender()->GetRenderingManager()->RequestUpdateAll();
IsClosedContour(stateMachineAction,interactionEvent);
}
}
示例9:
bool mitk::PointSetDataInteractor::InitMoveAll(StateMachineAction*, InteractionEvent* interactionEvent)
{
InteractionPositionEvent* positionEvent = dynamic_cast<InteractionPositionEvent*>(interactionEvent);
if (positionEvent != NULL)
{
m_LastMovePosition = positionEvent->GetPositionInWorld();
return true;
}
else
{
return false;
}
}
示例10:
bool mitk::DisplayInteractor::Init(StateMachineAction*, InteractionEvent* interactionEvent)
{
BaseRenderer* sender = interactionEvent->GetSender();
InteractionPositionEvent* positionEvent = static_cast<InteractionPositionEvent*>(interactionEvent);
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;
}
示例11:
bool mitk::DisplayInteractor::AdjustLevelWindow(StateMachineAction*, InteractionEvent* interactionEvent)
{
BaseRenderer::Pointer sender = interactionEvent->GetSender();
InteractionPositionEvent* positionEvent = dynamic_cast<InteractionPositionEvent*>(interactionEvent);
if (positionEvent == NULL)
{
MITK_WARN<< "DisplayVectorInteractor::Scroll cannot process the event: " << interactionEvent->GetNameOfClass();
return false;
}
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();
// calculate adjustments from mouse movements
level += (m_CurrentDisplayCoordinate[0] - m_LastDisplayCoordinate[0]) * static_cast<ScalarType>(2);
window += (m_CurrentDisplayCoordinate[1] - m_LastDisplayCoordinate[1]) * static_cast<ScalarType>(2);
lv.SetLevelWindow(level, window);
dynamic_cast<mitk::LevelWindowProperty*>(node->GetProperty("levelwindow"))->SetLevelWindow(lv);
sender->GetRenderingManager()->RequestUpdateAll();
return true;
}
示例12:
void mitk::PointSetDataInteractor::IsClosedContour(StateMachineAction*, InteractionEvent* interactionEvent)
{
unsigned int timeStep = interactionEvent->GetSender()->GetTimeStep(GetDataNode()->GetData());
InteractionPositionEvent* positionEvent = dynamic_cast<InteractionPositionEvent*>(interactionEvent);
if (positionEvent != NULL)
{
Point3D point = positionEvent->GetPositionInWorld();
// iterate over point set and check if it contains a point close enough to the pointer to be selected
if (GetPointIndexByPosition(point, timeStep) != -1 && m_PointSet->GetSize(timeStep) >= 3)
{
InternalEvent::Pointer event = InternalEvent::New(NULL, this, "ClosedContour");
positionEvent->GetSender()->GetDispatcher()->QueueEvent(event.GetPointer());
}
}
}
示例13: OperationEvent
void mitk::SinglePointDataInteractor::AddPoint(StateMachineAction * /*stateMachineAction*/,
InteractionEvent *interactionEvent)
{
unsigned int timeStep = interactionEvent->GetSender()->GetTimeStep(GetDataNode()->GetData());
ScalarType timeInMs = interactionEvent->GetSender()->GetTime();
// To add a point the minimal information is the position, this method accepts all InteractionsPositionEvents
InteractionPositionEvent *positionEvent = dynamic_cast<InteractionPositionEvent *>(interactionEvent);
if (positionEvent != NULL)
{
PointOperation *doOp;
PointOperation *undoOp;
if (m_PointSet->IndexExists(0, timeStep))
{
PointSet::PointType pt = m_PointSet->GetPoint(0, timeStep);
Point3D itkPoint;
itkPoint[0] = pt[0];
itkPoint[1] = pt[1];
itkPoint[2] = pt[2];
doOp = new mitk::PointOperation(OpMOVE, timeInMs, positionEvent->GetPositionInWorld(), 0);
undoOp = new mitk::PointOperation(OpMOVE, timeInMs, itkPoint, 0);
}
else
{
doOp = new mitk::PointOperation(OpINSERT, timeInMs, positionEvent->GetPositionInWorld(), 0);
undoOp = new mitk::PointOperation(OpREMOVE, timeInMs, positionEvent->GetPositionInWorld(), 0);
}
if (m_UndoEnabled)
{
OperationEvent *operationEvent = new OperationEvent(m_PointSet, doOp, undoOp, "Move point");
OperationEvent::IncCurrObjectEventId();
m_UndoController->SetOperationEvent(operationEvent);
}
// execute the Operation
m_PointSet->ExecuteOperation(doOp);
if (!m_UndoEnabled)
delete doOp;
// Request update
interactionEvent->GetSender()->GetRenderingManager()->RequestUpdateAll();
}
}
示例14: while
bool mitk::PointSetDataInteractor::AddPoint(StateMachineAction* stateMachineAction, InteractionEvent* interactionEvent)
{
// Find the position, the point is to be added to: first entry with
// empty index. If the Set is empty, then start with 0. if not empty,
// then take the first index which is not occupied
int lastPosition = 0;
PointSet::PointsContainer* pointsContainer = m_PointSet->GetPointSet(0)->GetPoints();
if (!pointsContainer->empty())
{
mitk::PointSet::PointsIterator it, end;
it = pointsContainer->Begin();
end = pointsContainer->End();
while (it != end)
{
if (!pointsContainer->IndexExists(lastPosition))
break;
++it;
++lastPosition;
}
}
InteractionPositionEvent* positionEvent = dynamic_cast<InteractionPositionEvent*>(interactionEvent);
if (positionEvent != NULL)
{
IsClosedContour(stateMachineAction, interactionEvent);
// Get time step from BaseRenderer
int timeStep = positionEvent->GetSender()->GetTimeStep();
mitk::Point3D point = positionEvent->GetPositionInWorld();
m_PointSet->InsertPoint(lastPosition, point, timeStep);
m_NumberOfPoints++;
GetDataNode()->SetData(m_PointSet);
GetDataNode()->Modified();
if (m_MaxNumberOfPoints != 0 && m_NumberOfPoints >= m_MaxNumberOfPoints)
{
InternalEvent::Pointer event = InternalEvent::New(NULL, this, "MaxNumberOfPoints");
positionEvent->GetSender()->GetDispatcher()->QueueEvent(event.GetPointer());
}
mitk::RenderingManager::GetInstance()->RequestUpdateAll();
return true;
}
else
{
return false;
}
}
示例15: OperationEvent
void mitk::PointSetDataInteractor::RemovePoint(StateMachineAction*, InteractionEvent* interactionEvent)
{
unsigned int timeStep = interactionEvent->GetSender()->GetTimeStep(GetDataNode()->GetData());
ScalarType timeInMs = interactionEvent->GetSender()->GetTime();
InteractionPositionEvent* positionEvent = dynamic_cast<InteractionPositionEvent*>(interactionEvent);
if (positionEvent != NULL)
{
mitk::Point3D itkPoint = positionEvent->GetPositionInWorld();
//search the point in the list
int position = m_PointSet->SearchPoint( itkPoint , m_SelectionAccuracy, timeStep);
if (position>=0)//found a point
{
PointSet::PointType pt = m_PointSet->GetPoint(position, timeStep);
itkPoint[0] = pt[0];
itkPoint[1] = pt[1];
itkPoint[2] = pt[2];
PointOperation* doOp = new mitk::PointOperation(OpREMOVE,timeInMs, itkPoint, position);
if (m_UndoEnabled) //write to UndoMechanism
{
PointOperation* undoOp = new mitk::PointOperation(OpINSERT,timeInMs, itkPoint, position);
OperationEvent *operationEvent = new OperationEvent(m_PointSet, doOp, undoOp, "Remove point");
mitk::OperationEvent::IncCurrObjectEventId();
m_UndoController->SetOperationEvent(operationEvent);
}
//execute the Operation
m_PointSet->ExecuteOperation(doOp);
if ( !m_UndoEnabled )
delete doOp;
/*now select the point "position-1",
and if it is the first in list,
then continue at the last in list*/
//only then a select of a point is possible!
if (m_PointSet->GetSize( timeStep ) > 0)
{
this->SelectPoint( m_PointSet->Begin( timeStep )->Index(), timeStep, timeInMs );
}
}
interactionEvent->GetSender()->GetRenderingManager()->RequestUpdateAll();
}
}