本文整理汇总了C++中kigfx::VIEW::Query方法的典型用法代码示例。如果您正苦于以下问题:C++ VIEW::Query方法的具体用法?C++ VIEW::Query怎么用?C++ VIEW::Query使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类kigfx::VIEW
的用法示例。
在下文中一共展示了VIEW::Query方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: selectMultiple
bool SELECTION_TOOL::selectMultiple()
{
bool cancelled = false; // Was the tool cancelled while it was running?
m_multiple = true; // Multiple selection mode is active
KIGFX::VIEW* view = getView();
getViewControls()->SetAutoPan( true );
SELECTION_AREA area;
view->Add( &area );
while( OPT_TOOL_EVENT evt = Wait() )
{
if( evt->IsCancel() )
{
cancelled = true;
break;
}
if( evt->IsDrag( BUT_LEFT ) )
{
if( !m_additive )
clearSelection();
// Start drawing a selection box
area.SetOrigin( evt->DragOrigin() );
area.SetEnd( evt->Position() );
area.ViewSetVisible( true );
area.ViewUpdate( KIGFX::VIEW_ITEM::GEOMETRY );
}
if( evt->IsMouseUp( BUT_LEFT ) )
{
// End drawing the selection box
area.ViewSetVisible( false );
// Mark items within the selection box as selected
std::vector<KIGFX::VIEW::LAYER_ITEM_PAIR> selectedItems;
BOX2I selectionBox = area.ViewBBox();
view->Query( selectionBox, selectedItems ); // Get the list of selected items
std::vector<KIGFX::VIEW::LAYER_ITEM_PAIR>::iterator it, it_end;
for( it = selectedItems.begin(), it_end = selectedItems.end(); it != it_end; ++it )
{
BOARD_ITEM* item = static_cast<BOARD_ITEM*>( it->first );
// Add only those items that are visible and fully within the selection box
if( !item->IsSelected() && selectable( item ) &&
selectionBox.Contains( item->ViewBBox() ) )
{
select( item );
}
}
// Do not display information about selected item,as there is more than one
m_frame->SetCurItem( NULL );
if( !m_selection.Empty() )
{
// Inform other potentially interested tools
m_toolMgr->ProcessEvent( SelectedEvent );
}
break; // Stop waiting for events
}
}
// Stop drawing the selection box
area.ViewSetVisible( false );
view->Remove( &area );
m_multiple = false; // Multiple selection mode is inactive
getViewControls()->SetAutoPan( false );
return cancelled;
}
示例2: selectMultiple
bool GERBVIEW_SELECTION_TOOL::selectMultiple()
{
bool cancelled = false; // Was the tool cancelled while it was running?
m_multiple = true; // Multiple selection mode is active
KIGFX::VIEW* view = getView();
getViewControls()->SetAutoPan( true );
KIGFX::PREVIEW::SELECTION_AREA area;
view->Add( &area );
while( OPT_TOOL_EVENT evt = Wait() )
{
if( evt->IsCancel() )
{
cancelled = true;
break;
}
if( evt->IsDrag( BUT_LEFT ) )
{
// Start drawing a selection box
area.SetOrigin( evt->DragOrigin() );
area.SetEnd( evt->Position() );
area.SetAdditive( m_additive );
area.SetSubtractive( m_subtractive );
view->SetVisible( &area, true );
view->Update( &area );
}
if( evt->IsMouseUp( BUT_LEFT ) )
{
// End drawing the selection box
view->SetVisible( &area, false );
// Mark items within the selection box as selected
std::vector<KIGFX::VIEW::LAYER_ITEM_PAIR> selectedItems;
// Filter the view items based on the selection box
BOX2I selectionBox = area.ViewBBox();
view->Query( selectionBox, selectedItems ); // Get the list of selected items
std::vector<KIGFX::VIEW::LAYER_ITEM_PAIR>::iterator it, it_end;
int width = area.GetEnd().x - area.GetOrigin().x;
int height = area.GetEnd().y - area.GetOrigin().y;
// Construct an EDA_RECT to determine EDA_ITEM selection
EDA_RECT selectionRect( wxPoint( area.GetOrigin().x, area.GetOrigin().y ),
wxSize( width, height ) );
selectionRect.Normalize();
for( it = selectedItems.begin(), it_end = selectedItems.end(); it != it_end; ++it )
{
auto item = static_cast<GERBER_DRAW_ITEM*>( it->first );
if( !item || !selectable( item ) )
continue;
/* Selection mode depends on direction of drag-selection:
* Left > Right : Select objects that are fully enclosed by selection
* Right > Left : Select objects that are crossed by selection
*/
if( width >= 0 )
{
if( selectionBox.Contains( item->ViewBBox() ) )
{
if( m_subtractive )
unselect( item );
else
select( item );
}
}
else
{
if( item->HitTest( selectionRect ) )
{
if( m_subtractive )
unselect( item );
else
select( item );
}
}
}
if( m_selection.Size() == 1 )
m_frame->SetCurItem( static_cast<GERBER_DRAW_ITEM*>( m_selection.Front() ) );
else
m_frame->SetCurItem( NULL );
// Inform other potentially interested tools
if( !m_selection.Empty() )
m_toolMgr->ProcessEvent( SelectedEvent );
break; // Stop waiting for events
}
//.........这里部分代码省略.........