当前位置: 首页>>代码示例>>C++>>正文


C++ MarkerItem::xValue方法代码示例

本文整理汇总了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;
		}
开发者ID:Wushaowei001,项目名称:OptimaPlotter,代码行数:43,代码来源:canvaspicker.cpp

示例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;
			}
		}
	}
}
开发者ID:Wushaowei001,项目名称:OptimaPlotter,代码行数:100,代码来源:canvaspicker.cpp


注:本文中的MarkerItem::xValue方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。