本文整理汇总了C++中MarkerItem::xValue方法的典型用法代码示例。如果您正苦于以下问题:C++ MarkerItem::xValue方法的具体用法?C++ MarkerItem::xValue怎么用?C++ MarkerItem::xValue使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MarkerItem
的用法示例。
在下文中一共展示了MarkerItem::xValue方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: move
void CanvasPicker::move( const QPoint &pos )
{
if( !m_dragAndDropInProgress )
return;
PlotWidget* plotWidget = dynamic_cast<PlotWidget*>( plot() );
switch( m_typeOfItemsToDrag )
{
case Globals::Rtti_PlotMarker:
{
const double dX = plot()->invTransform( QwtPlot::xBottom, pos.x() ) - plot()->invTransform( QwtPlot::xBottom, m_previousPoint.x() );
const double dY = plot()->invTransform( QwtPlot::yLeft, pos.y() ) - plot()->invTransform( QwtPlot::yLeft, m_previousPoint.y() );
QList<QwtPlotItem*>& listOfSelectedMarkers = plotWidget->listOfSelectedItems( Globals::Rtti_PlotMarker );
foreach( QwtPlotItem* item, listOfSelectedMarkers )
{
MarkerItem* markerItem = dynamic_cast<MarkerItem*>( item );
markerItem->setValue( markerItem->xValue() + dX, markerItem->yValue() + dY );
emit dataChanged( markerItem );
}
break;
}
case Globals::Rtti_PlotKnot:
{
const double dX = plot()->invTransform( QwtPlot::xBottom, pos.x() ) - plot()->invTransform( QwtPlot::xBottom, m_previousPoint.x() );
QList<QwtPlotItem*>& listOfSelectedKnots = plotWidget->listOfSelectedItems( Globals::Rtti_PlotKnot );
foreach( QwtPlotItem* item, listOfSelectedKnots )
{
KnotItem* knotItem = dynamic_cast<KnotItem*>( item );
if( knotItem->isEditAllowed() )
{
knotItem->setCoordinate( knotItem->coordinate() + dX );
emit dataChanged( knotItem );
}
}
break;
}
示例2: select
void CanvasPicker::select( const QPoint &pos, Qt::KeyboardModifiers modifiers )
{
m_selectionPoint = pos;
m_previousPoint = pos;
double minDistanceMarkers = 10e10;
double minDistanceKnots = 10e10;
MarkerItem* markerWithMinDistance = 0;
KnotItem* knotWithMinDistance = 0;
int selectionType = -1;
PlotWidget* plotWidget = dynamic_cast<PlotWidget*>( plot() );
const QwtScaleMap xMap = plot()->canvasMap( QwtPlot::xBottom );
const QwtScaleMap yMap = plot()->canvasMap( QwtPlot::yLeft );
const QwtPlotItemList& itemList = plot()->itemList();
for ( QwtPlotItemIterator it = itemList.begin(); it != itemList.end(); ++it )
{
if ( ( *it )->rtti() == Globals::Rtti_PlotMarker )
{
MarkerItem* marker = static_cast<MarkerItem*>( *it );
const double deltaX = xMap.transform( marker->xValue() ) - pos.x();
const double deltaY = yMap.transform( marker->yValue() ) - pos.y();
const double distance = qSqrt( qwtSqr( deltaX ) + qwtSqr( deltaY ) );
if ( distance < minDistanceMarkers )
{
minDistanceMarkers = distance;
markerWithMinDistance = marker;
}
}
else if ( ( *it )->rtti() == Globals::Rtti_PlotKnot )
{
KnotItem* knot = static_cast<KnotItem*>( *it );
const double distance = qAbs( xMap.transform( knot->coordinate() ) - pos.x() );
if( distance < minDistanceKnots )
{
minDistanceKnots = distance;
knotWithMinDistance = knot;
}
}
}
// Give a priority to the markers
if( minDistanceMarkers < Globals::SELECTION_PIXEL_TOLERANCE && markerWithMinDistance != 0 )
{
m_itemToPick = markerWithMinDistance;
selectionType = Globals::Rtti_PlotMarker;
}
else if( minDistanceKnots < Globals::SELECTION_PIXEL_TOLERANCE && knotWithMinDistance != 0 )
{
m_itemToPick = knotWithMinDistance;
selectionType = Globals::Rtti_PlotKnot;
}
if( selectionType == -1 )
{
emit picked( modifiers, 0 );
return;
}
QList<QwtPlotItem*>& listOfSelectedItems = plotWidget->listOfSelectedItems( selectionType );
if( listOfSelectedItems.count() == 0 )
{
// Select and allow the user to drag and drop.
emit picked( modifiers, m_itemToPick );
m_typeOfItemsToDrag = selectionType;
m_dragAndDropInProgress = true;
m_itemToPick = 0;
}
else
{
if( listOfSelectedItems.contains( m_itemToPick ) )
{
// We don't know yet whether the user wants to do a selection or a drag and drop operation.
// The picking operation will be detected in CanvasPicker::release().
m_typeOfItemsToDrag = selectionType;
m_dragAndDropInProgress = true;
}
else
{
emit picked( modifiers, m_itemToPick );
m_itemToPick = 0;
if( listOfSelectedItems.count() == 1 )
{
m_typeOfItemsToDrag = selectionType;
m_dragAndDropInProgress = true;
}
}
}
}