本文整理汇总了C++中BaseRenderer::GetMapperID方法的典型用法代码示例。如果您正苦于以下问题:C++ BaseRenderer::GetMapperID方法的具体用法?C++ BaseRenderer::GetMapperID怎么用?C++ BaseRenderer::GetMapperID使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类BaseRenderer
的用法示例。
在下文中一共展示了BaseRenderer::GetMapperID方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: doOp
// Relict from the old times, when automous decisions were accepted
// behavior. Remains in here, because some RenderWindows do exist outside
// of StdMultiWidgets.
bool
SliceNavigationController
::ExecuteAction( Action* action, StateEvent const* stateEvent )
{
bool ok = false;
const PositionEvent* posEvent = dynamic_cast< const PositionEvent * >(
stateEvent->GetEvent() );
if ( posEvent != NULL )
{
if ( m_CreatedWorldGeometry.IsNull() )
{
return true;
}
switch (action->GetActionId())
{
case AcMOVE:
{
BaseRenderer *baseRenderer = posEvent->GetSender();
if ( !baseRenderer )
{
baseRenderer = const_cast<BaseRenderer *>(
GlobalInteraction::GetInstance()->GetFocus() );
}
if ( baseRenderer )
if ( baseRenderer->GetMapperID() == 1 )
{
PointOperation doOp(OpMOVE, posEvent->GetWorldPosition());
this->ExecuteOperation( &doOp );
// If click was performed in this render window than we have to update the status bar information about position and pixel value.
if(baseRenderer == m_Renderer)
{
{
std::string statusText;
TNodePredicateDataType<mitk::Image>::Pointer isImageData = TNodePredicateDataType<mitk::Image>::New();
mitk::DataStorage::SetOfObjects::ConstPointer nodes = baseRenderer->GetDataStorage()->GetSubset(isImageData).GetPointer();
mitk::Point3D worldposition = posEvent->GetWorldPosition();
//int maxlayer = -32768;
mitk::Image::Pointer image3D;
mitk::DataNode::Pointer node;
mitk::DataNode::Pointer topSourceNode;
bool isBinary (false);
node = this->GetTopLayerNode(nodes,worldposition);
if(node.IsNotNull())
{
node->GetBoolProperty("binary", isBinary);
if(isBinary)
{
mitk::DataStorage::SetOfObjects::ConstPointer sourcenodes = baseRenderer->GetDataStorage()->GetSources(node, NULL, true);
if(!sourcenodes->empty())
{
topSourceNode = this->GetTopLayerNode(sourcenodes,worldposition);
}
if(topSourceNode.IsNotNull())
{
image3D = dynamic_cast<mitk::Image*>(topSourceNode->GetData());
}
else
{
image3D = dynamic_cast<mitk::Image*>(node->GetData());
}
}
else
{
image3D = dynamic_cast<mitk::Image*>(node->GetData());
}
}
std::stringstream stream;
stream.imbue(std::locale::classic());
// get the position and gray value from the image and build up status bar text
if(image3D.IsNotNull())
{
Index3D p;
image3D->GetGeometry()->WorldToIndex(worldposition, p);
stream.precision(2);
stream<<"Position: <" << std::fixed <<worldposition[0] << ", " << std::fixed << worldposition[1] << ", " << std::fixed << worldposition[2] << "> mm";
stream<<"; Index: <"<<p[0] << ", " << p[1] << ", " << p[2] << "> ";
mitk::ScalarType pixelValue = image3D->GetPixelValueByIndex(p, baseRenderer->GetTimeStep());
if (fabs(pixelValue)>1000000 || fabs(pixelValue) < 0.01)
{
stream<<"; Time: " << baseRenderer->GetTime() << " ms; Pixelvalue: " << std::scientific<< pixelValue <<" ";
}
else
{
stream<<"; Time: " << baseRenderer->GetTime() << " ms; Pixelvalue: "<< pixelValue <<" ";
}
}
else
{
stream << "No image information at this position!";
}
//.........这里部分代码省略.........
示例2: isHelper
// Relict from the old times, when automous decisions were accepted
// behavior. Remains in here, because some RenderWindows do exist outside
// of StdMultiWidgets.
bool
SliceNavigationController
::ExecuteAction( Action* action, StateEvent const* stateEvent )
{
bool ok = false;
const PositionEvent* posEvent = dynamic_cast< const PositionEvent * >(
stateEvent->GetEvent() );
if ( posEvent != NULL )
{
if ( m_CreatedWorldGeometry.IsNull() )
{
return true;
}
switch (action->GetActionId())
{
case AcMOVE:
{
BaseRenderer *baseRenderer = posEvent->GetSender();
if ( !baseRenderer )
{
baseRenderer = const_cast<BaseRenderer *>(
GlobalInteraction::GetInstance()->GetFocus() );
}
if ( baseRenderer )
if ( baseRenderer->GetMapperID() == 1 )
{
PointOperation* doOp = new mitk::PointOperation(OpMOVE, posEvent->GetWorldPosition());
if (m_UndoEnabled)
{
m_OldPos = this->GetSlice()->GetPos();
// m_OldPos holds the old slice position. For the undo controller this old position will be stored as index in mitk::PointOperation
PointOperation* undoOp = new mitk::PointOperation(OpMOVE, posEvent->GetWorldPosition(), m_OldPos);
OperationEvent *operationEvent = new mitk::OperationEvent(this, doOp, undoOp, "Move slices");
m_UndoController->SetOperationEvent(operationEvent);
}
this->ExecuteOperation( doOp );
// If click was performed in this render window than we have to update the status bar information about position and pixel value.
if(baseRenderer == m_Renderer)
{
{
std::string statusText;
TNodePredicateDataType<mitk::Image>::Pointer isImageData = TNodePredicateDataType<mitk::Image>::New();
mitk::DataStorage::SetOfObjects::ConstPointer nodes = baseRenderer->GetDataStorage()->GetSubset(isImageData).GetPointer();
mitk::Point3D worldposition = posEvent->GetWorldPosition();
int maxlayer = -32768;
mitk::Image::Pointer image3D;
// find image with largest layer, that is the image shown on top in the render window
for (unsigned int x = 0; x < nodes->size(); x++)
{
//Just consider image data that is no helper object. E.g. do not consider nodes created for the slice interpolation
bool isHelper (false);
nodes->at(x)->GetBoolProperty("helper object", isHelper);
if(nodes->at(x)->GetData()->GetGeometry()->IsInside(worldposition) && isHelper == false)
{
int layer = 0;
if(!(nodes->at(x)->GetIntProperty("layer", layer))) continue;
if(layer > maxlayer)
{
if(static_cast<mitk::DataNode::Pointer>(nodes->at(x))->IsVisible(m_Renderer))
{
image3D = dynamic_cast<mitk::Image*>(nodes->at(x)->GetData());
maxlayer = layer;
}
}
}
}
std::stringstream stream;
stream.imbue(std::locale::classic());
// get the position and gray value from the image and build up status bar text
if(image3D.IsNotNull())
{
Index3D p;
image3D->GetGeometry()->WorldToIndex(worldposition, p);
stream.precision(2);
stream<<"Position: <" << std::fixed <<worldposition[0] << ", " << std::fixed << worldposition[1] << ", " << std::fixed << worldposition[2] << "> mm";
stream<<"; Index: <"<<p[0] << ", " << p[1] << ", " << p[2] << "> ";
mitk::ScalarType pixelValue = image3D->GetPixelValueByIndex(p, baseRenderer->GetTimeStep());
if (fabs(pixelValue)>1000000)
{
stream<<"; Time: " << baseRenderer->GetTime() << " ms; Pixelvalue: "<<std::scientific<<image3D->GetPixelValueByIndex(p, baseRenderer->GetTimeStep())<<" ";
}
else
{
stream<<"; Time: " << baseRenderer->GetTime() << " ms; Pixelvalue: "<<image3D->GetPixelValueByIndex(p, baseRenderer->GetTimeStep())<<" ";
}
}
else
{
stream << "No image information at this position!";
}
//.........这里部分代码省略.........
示例3: DoDecideBetweenRotationAndSliceSelection
bool SlicesRotator::DoDecideBetweenRotationAndSliceSelection(Action*, const StateEvent* e)
{
// Decide between moving and rotation slices.
// For basic decision logic see class documentation.
/*
Detail logic:
1. Find the SliceNavigationController that has sent the event: this one defines our rendering plane and will NOT be rotated. Needs not even be counted or checked.
2. Inspect every other SliceNavigationController
- calculate the line intersection of this SliceNavigationController's plane with our rendering plane
- if there is NO interesection, ignore and continue
- IF there is an intersection
- check the mouse cursor's distance from that line.
0. if the line is NOT near the cursor, remember the plane as "one of the other planes" (which can be rotated in "locked" mode)
1. on first line near the cursor, just remember this intersection line as THE other plane that we want to rotate
2. on every consecutive line near the cursor, check if the line is geometrically identical to the line that we want to rotate
- if yes, we just push this line to the "other" lines and rotate it along
- if no, then we have a situation where the mouse is near two other lines (e.g. crossing point) and don't want to rotate
*/
const DisplayPositionEvent* posEvent = dynamic_cast<const DisplayPositionEvent*>(e->GetEvent());
if (!posEvent) return false;
BaseRenderer* clickedRenderer = e->GetEvent()->GetSender();
const PlaneGeometry* ourViewportGeometry = dynamic_cast<const PlaneGeometry*>( clickedRenderer->GetCurrentWorldPlaneGeometry() );
// These sanity checks were introduced with bug 17877, since plane geometries are now a shared base class of several geometries
// They may ultimately be unecessary
const mitk::AbstractTransformGeometry* abstractGeometry = dynamic_cast< const AbstractTransformGeometry * > (ourViewportGeometry);
if (abstractGeometry != NULL) MITK_WARN << "SliceRotator recieved an AbstractTransformGeometry, expecting a simple PlainGeometry, behaviour should be verified.";
const mitk::DisplayGeometry* displayGeometry = dynamic_cast< const DisplayGeometry * > (ourViewportGeometry);
if (displayGeometry != NULL) MITK_WARN << "SliceRotator recieved a DisplayGeometry, expecting a simple PlainGeometry, behaviour should be verified.";
// End sanity checks
if (!ourViewportGeometry) return false;
DisplayGeometry* clickedDisplayGeometry = clickedRenderer->GetDisplayGeometry();
if (!clickedDisplayGeometry) return false;
MITK_DEBUG << "=============================================";
MITK_DEBUG << "Renderer under cursor is " << clickedRenderer->GetName();
Point3D cursorPosition = posEvent->GetWorldPosition();
const PlaneGeometry* geometryToBeRotated = NULL; // this one is under the mouse cursor
const PlaneGeometry* anyOtherGeometry = NULL; // this is also visible (for calculation of intersection ONLY)
Line3D intersectionLineWithGeometryToBeRotated;
bool hitMultipleLines(false);
m_SNCsToBeRotated.clear();
const double threshholdDistancePixels = 12.0;
for (SNCVector::iterator iter = m_RotatableSNCs.begin(); iter != m_RotatableSNCs.end(); ++iter)
{
// If the mouse cursor is in 3D Renderwindow, do not check for intersecting planes.
if (clickedRenderer->GetMapperID() == BaseRenderer::Standard3D)
break;
const PlaneGeometry* otherRenderersRenderPlane = (*iter)->GetCurrentPlaneGeometry();
if (otherRenderersRenderPlane == NULL) continue; // ignore, we don't see a plane
MITK_DEBUG << " Checking plane of renderer " << (*iter)->GetRenderer()->GetName();
// check if there is an intersection
Line3D intersectionLine; // between rendered/clicked geometry and the one being analyzed
if (!ourViewportGeometry->IntersectionLine( otherRenderersRenderPlane, intersectionLine ))
{
continue; // we ignore this plane, it's parallel to our plane
}
// check distance from intersection line
double distanceFromIntersectionLine = intersectionLine.Distance( cursorPosition );
ScalarType distancePixels = distanceFromIntersectionLine / clickedDisplayGeometry->GetScaleFactorMMPerDisplayUnit();
MITK_DEBUG << " Distance of plane from cursor " << distanceFromIntersectionLine << " mm, which is around " << distancePixels << " px" ;
// far away line, only remember for linked rotation if necessary
if (distanceFromIntersectionLine > threshholdDistancePixels)
{
MITK_DEBUG << " Plane is too far away --> remember as otherRenderersRenderPlane";
anyOtherGeometry = otherRenderersRenderPlane; // we just take the last one, so overwrite each iteration (we just need some crossing point)
// TODO what about multiple crossings? NOW we have undefined behavior / random crossing point is used
if (m_LinkPlanes)
{
m_SNCsToBeRotated.push_back(*iter);
}
}
else // close to cursor
{
MITK_DEBUG << " Plane is close enough to cursor...";
if ( geometryToBeRotated == NULL ) // first one close to the cursor
{
MITK_DEBUG << " It is the first close enough geometry, remember as geometryToBeRotated";
geometryToBeRotated = otherRenderersRenderPlane;
intersectionLineWithGeometryToBeRotated = intersectionLine;
m_SNCsToBeRotated.push_back(*iter);
}
else
{
MITK_DEBUG << " Second or later close enough geometry";
// compare to the line defined by geometryToBeRotated: if identical, just rotate this otherRenderersRenderPlane together with the primary one
//.........这里部分代码省略.........