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


C++ Filter::FindPinByPos方法代码示例

本文整理汇总了C++中Filter::FindPinByPos方法的典型用法代码示例。如果您正苦于以下问题:C++ Filter::FindPinByPos方法的具体用法?C++ Filter::FindPinByPos怎么用?C++ Filter::FindPinByPos使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Filter的用法示例。


在下文中一共展示了Filter::FindPinByPos方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: OnMouseMove

void DisplayView::OnMouseMove(UINT nFlags, CPoint point)
{
    point += GetScrollPosition();
    bool need_invalidate = false;

    // loop through the filters...
    if (nFlags & MK_LBUTTON) {


        switch (drag_mode) {
        case DisplayView::DRAG_GROUP:
        {
            // we are dragging now
            int	deltax = point.x - start_drag_point.x;
            int deltay = point.y - start_drag_point.y;

            // verify the deltas
            int i, selected_count = 0;
            for (i=0; i<graph.filters.GetCount(); i++) {
                Filter *filter = graph.filters[i];
                if (filter->selected) {
                    selected_count ++;
                    filter->VerifyDrag(&deltax, &deltay);
                }
            }

            // exit if there's no selected filter
            if (selected_count == 0) return ;

            // update their position
            for (i=0; i<graph.filters.GetCount(); i++) {
                Filter *filter = graph.filters[i];
                if (filter->selected) {
                    int px = filter->start_drag_pos.x + deltax;
                    int py = filter->start_drag_pos.y + deltay;

                    // snap to grid
                    px = (px+7)&~0x07;
                    py = (py+7)&~0x07;

                    if (px != filter->posx || py != filter->posy) {
                        filter->posx = px;
                        filter->posy = py;
                        need_invalidate = true;
                    }
                }
            }
        }
        break;

        case DisplayView::DRAG_CONNECTION:
        {
            new_connection_end = point;

            Filter	*current = graph.FindFilterByPos(point);
            if (current) {
                Pin *drop_end = current->FindPinByPos(point);
                if (drop_end) {
                    drop_end->GetCenterPoint(&new_connection_end);
                }
            }

            need_invalidate = true;
        }
        break;
        case DisplayView::DRAG_SELECTION:
        {
            int	minx = start_drag_point.x;
            int miny = start_drag_point.y;
            int maxx = point.x;
            int maxy = point.y;

            if (minx > maxx) {
                minx = point.x;
                maxx = start_drag_point.x;
            }
            if (miny > maxy) {
                miny = point.y;
                maxy = start_drag_point.y;
            }

            end_drag_point = point;
            CRect	rc(minx, miny, maxx, maxy);

            for (int i=0; i<graph.filters.GetCount(); i++) {
                Filter *filter = graph.filters[i];

                CRect	rc2(filter->posx, filter->posy,
                            filter->posx+filter->width,
                            filter->posy+filter->height);
                CRect	rc3;

                rc3.IntersectRect(&rc, &rc2);
                bool sel = (rc3.IsRectEmpty() ? false : true);

                if (sel != filter->selected) {
                    filter->Select(sel);
                    need_invalidate = true;
                }
            }
//.........这里部分代码省略.........
开发者ID:CyberShadow,项目名称:graphstudio,代码行数:101,代码来源:display_view.cpp

示例2: OnLButtonDown

void DisplayView::OnLButtonDown(UINT nFlags, CPoint point)
{
    point += GetScrollPosition();

    SetCapture();
    start_drag_point = point;
    end_drag_point = point;

    Filter	*current = graph.FindFilterByPos(point);
    if (!current) {
        // deselect all filters
        bool need_invalidate = false;
        for (int i=0; i<graph.filters.GetCount(); i++) {
            if (graph.filters[i]->selected) {
                graph.filters[i]->Select(false);
            }
            graph.filters[i]->SelectConnection(nFlags, point);
            need_invalidate = true;
        }

        // store the selection point
        drag_mode = DisplayView::DRAG_SELECTION;

        if (need_invalidate) {
            graph.Dirty();
            Invalidate();
        }
        return ;
    }

    // check if we hit a pin
    Pin *hitpin = current->FindPinByPos(point);
    if (hitpin) {
        // deselect all filters
        for (int i=0; i<graph.filters.GetCount(); i++) {
            graph.filters[i]->Select(false);
        }

        // remember the start point
        hitpin->GetCenterPoint(&new_connection_start);
        new_connection_end = new_connection_start;
        drag_mode = DisplayView::DRAG_CONNECTION;

    } else {

        int icon = current->CheckIcons(point);
        if (icon >= 0) {
            drag_mode = DisplayView::DRAG_OVERLAY_ICON;
            return ;
        }

        if (current->selected) {
            if (nFlags & MK_SHIFT) {
                current->Select(false);
                graph.Dirty();
                Invalidate();
            } else {
                // nothing here...
            }
        } else {
            if (nFlags & MK_SHIFT) {
                current->Select(true);
                graph.Dirty();
                Invalidate();
            } else {
                // deselect all filters but this
                for (int i=0; i<graph.filters.GetCount(); i++) {
                    graph.filters[i]->Select(false);
                }
                current->Select(true);
                graph.Dirty();
                Invalidate();
            }
        }

        drag_mode = DisplayView::DRAG_GROUP;

        // start dragging operation on all selected filters
        start_drag_point = point;
        for (int i=0; i<graph.filters.GetCount(); i++) {
            graph.filters[i]->BeginDrag();
        }
    }
}
开发者ID:CyberShadow,项目名称:graphstudio,代码行数:84,代码来源:display_view.cpp


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